From 25904dea17e89c7dbb8e70e215f98b2190de0962 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 03:33:05 +0000 Subject: [PATCH 01/11] Initialize repository for autorest build 20241120.2 --- eng/Packages.Data.props | 2 +- eng/emitter-package-lock.json | 16 ++++++++-------- eng/emitter-package.json | 5 ++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/eng/Packages.Data.props b/eng/Packages.Data.props index d4c80facc4c71..c8119a42a929f 100644 --- a/eng/Packages.Data.props +++ b/eng/Packages.Data.props @@ -238,7 +238,7 @@ All should have PrivateAssets="All" set so they don't become package dependencies --> - + diff --git a/eng/emitter-package-lock.json b/eng/emitter-package-lock.json index 012d9bc8ed261..37e8c300d2cff 100644 --- a/eng/emitter-package-lock.json +++ b/eng/emitter-package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "@azure-tools/typespec-csharp": "0.2.0-beta.20241118.2" + "@azure-tools/typespec-csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20241120.2.tgz" }, "devDependencies": { "@azure-tools/typespec-autorest": "0.48.0", @@ -22,9 +22,9 @@ } }, "node_modules/@autorest/csharp": { - "version": "3.0.0-beta.20241118.2", - "resolved": "https://registry.npmjs.org/@autorest/csharp/-/csharp-3.0.0-beta.20241118.2.tgz", - "integrity": "sha512-roe5EXurREnX01lgAwvOOhdfqKCmapCSgT7k/G/qCKuo5B5/XB6PoAJ+n4wGTrXa2igWbivXq93gVknytn19Kw==" + "version": "3.0.0-alpha.20241120.2", + "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest/npm/registry/@autorest/csharp/-/csharp-3.0.0-alpha.20241120.2.tgz", + "integrity": "sha512-l9uyY9HRFtL7tsa9jWAkjmGZEQnDbef2Cj8mMwaqdYRH8oSh0lWAYJvy3W7CAUhYa4bX/XvFCatNSFGH3b0Lrg==" }, "node_modules/@azure-tools/typespec-autorest": { "version": "0.48.0", @@ -117,11 +117,11 @@ } }, "node_modules/@azure-tools/typespec-csharp": { - "version": "0.2.0-beta.20241118.2", - "resolved": "https://registry.npmjs.org/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-beta.20241118.2.tgz", - "integrity": "sha512-O6EPE8A1PKBioORd8NO0vESn+WKKDe/aPV3yPC6SeNPu1/NthPXA8z3w7v/wuZTSw+Zv9A2UWcHfrH1/QrX4zg==", + "version": "0.2.0-alpha.20241120.2", + "resolved": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20241120.2.tgz", + "integrity": "sha512-K/1xvRt4j4B1ISS4iGcc7c6numiwDAPIY4iCe50BB8pGONaCHjYBEH9eobG2b11S8VWb4pD2belJeQWLBhlFqQ==", "dependencies": { - "@autorest/csharp": "3.0.0-beta.20241118.2", + "@autorest/csharp": "3.0.0-alpha.20241120.2", "@typespec/http-client-csharp": "0.1.9-alpha.20241114.1", "json-serialize-refs": "0.1.0-0" }, diff --git a/eng/emitter-package.json b/eng/emitter-package.json index 934f3c5c9b813..d2a514e4c3b31 100644 --- a/eng/emitter-package.json +++ b/eng/emitter-package.json @@ -1,7 +1,7 @@ { "main": "dist/src/index.js", "dependencies": { - "@azure-tools/typespec-csharp": "0.2.0-beta.20241118.2" + "@azure-tools/typespec-csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest/npm/registry/@azure-tools/typespec-csharp/-/typespec-csharp-0.2.0-alpha.20241120.2.tgz" }, "devDependencies": { "@azure-tools/typespec-autorest": "0.48.0", @@ -15,5 +15,8 @@ "@typespec/rest": "0.62.0", "@typespec/versioning": "0.62.0", "@typespec/xml": "0.62.0" + }, + "overrides": { + "@autorest/csharp": "https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-js-test-autorest/npm/registry/@autorest/csharp/-/csharp-3.0.0-alpha.20241120.2.tgz" } } From 9b097b006d711d0cf78c2ab68282f92aa9a9ca93 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 03:46:50 +0000 Subject: [PATCH 02/11] Update SDK code co_co_1 --- ...mple_CognitiveServicesAccountCollection.cs | 75 +- ...tiveServicesAccountDeploymentCollection.cs | 120 +- ...nitiveServicesAccountDeploymentResource.cs | 48 +- ...Sample_CognitiveServicesAccountResource.cs | 66 +- ...gnitiveServicesCommitmentPlanCollection.cs | 68 +- ...CognitiveServicesCommitmentPlanResource.cs | 64 +- ...CognitiveServicesDeletedAccountResource.cs | 32 - ...nitiveServicesEncryptionScopeCollection.cs | 118 +- ...ognitiveServicesEncryptionScopeResource.cs | 60 +- ...icesPrivateEndpointConnectionCollection.cs | 48 +- ...mitmentPlanAccountAssociationCollection.cs | 96 +- ...ommitmentPlanAccountAssociationResource.cs | 38 +- .../Sample_CommitmentPlanCollection.cs | 114 +- .../Samples/Sample_CommitmentPlanResource.cs | 56 +- .../Sample_DefenderForAISettingCollection.cs | 96 +- .../Sample_DefenderForAISettingResource.cs | 2 +- ...ecurityPerimeterConfigurationCollection.cs | 48 +- .../Samples/Sample_RaiBlocklistCollection.cs | 96 +- .../Sample_RaiBlocklistItemCollection.cs | 104 +- .../Sample_RaiBlocklistItemResource.cs | 46 +- .../Samples/Sample_RaiBlocklistResource.cs | 53 +- .../Sample_RaiContentFilterCollection.cs | 48 +- .../Samples/Sample_RaiPolicyCollection.cs | 269 ++- .../Samples/Sample_RaiPolicyResource.cs | 87 +- .../Sample_SubscriptionResourceExtensions.cs | 115 +- .../Sample_CommunicationDomainResource.cs | 2 +- ...e_CommunicationDomainResourceCollection.cs | 90 +- .../Sample_CommunicationServiceResource.cs | 166 +- ..._CommunicationServiceResourceCollection.cs | 126 +- .../Samples/Sample_EmailServiceResource.cs | 63 +- .../Sample_EmailServiceResourceCollection.cs | 90 +- .../Samples/Sample_SenderUsernameResource.cs | 52 +- ...Sample_SenderUsernameResourceCollection.cs | 98 +- .../Sample_SubscriptionResourceExtensions.cs | 167 ++ .../Sample_AvailabilitySetCollection.cs | 134 +- .../Samples/Sample_AvailabilitySetResource.cs | 114 +- .../Sample_CapacityReservationCollection.cs | 77 +- ...mple_CapacityReservationGroupCollection.cs | 86 +- ...Sample_CapacityReservationGroupResource.cs | 143 +- .../Sample_CapacityReservationResource.cs | 110 +- .../Samples/Sample_CloudServiceCollection.cs | 190 +- .../Sample_CloudServiceOSFamilyCollection.cs | 62 +- .../Sample_CloudServiceOSVersionCollection.cs | 62 +- .../Samples/Sample_CloudServiceResource.cs | 84 +- .../Sample_CloudServiceRoleCollection.cs | 62 +- ...mple_CloudServiceRoleInstanceCollection.cs | 62 +- ...Sample_CloudServiceRoleInstanceResource.cs | 28 +- .../Sample_CommunityGalleryImageCollection.cs | 62 +- ..._CommunityGalleryImageVersionCollection.cs | 62 +- ...putePrivateEndpointConnectionCollection.cs | 66 +- ...omputePrivateEndpointConnectionResource.cs | 54 +- .../Samples/Sample_DedicatedHostCollection.cs | 120 +- .../Sample_DedicatedHostGroupCollection.cs | 160 +- .../Sample_DedicatedHostGroupResource.cs | 144 +- .../Samples/Sample_DedicatedHostResource.cs | 148 +- .../Samples/Sample_DiskAccessCollection.cs | 76 +- .../Samples/Sample_DiskAccessResource.cs | 80 +- .../Sample_DiskEncryptionSetCollection.cs | 78 +- .../Sample_DiskEncryptionSetResource.cs | 150 +- .../Samples/Sample_DiskImageCollection.cs | 101 +- .../Samples/Sample_DiskImageResource.cs | 68 +- .../Sample_DiskRestorePointCollection.cs | 76 +- .../Sample_GalleryApplicationCollection.cs | 76 +- .../Sample_GalleryApplicationResource.cs | 82 +- ...ple_GalleryApplicationVersionCollection.cs | 103 +- ...ample_GalleryApplicationVersionResource.cs | 83 +- .../Samples/Sample_GalleryCollection.cs | 204 +- .../Samples/Sample_GalleryImageCollection.cs | 62 +- .../Samples/Sample_GalleryImageResource.cs | 52 +- .../Sample_GalleryImageVersionCollection.cs | 641 +++--- .../Sample_GalleryImageVersionResource.cs | 146 +- .../Samples/Sample_GalleryResource.cs | 91 +- .../Samples/Sample_ManagedDiskCollection.cs | 96 +- .../Samples/Sample_ManagedDiskResource.cs | 170 +- ...ample_ProximityPlacementGroupCollection.cs | 72 +- .../Sample_ProximityPlacementGroupResource.cs | 62 +- .../Samples/Sample_RestorePointCollection.cs | 71 +- .../Sample_RestorePointGroupCollection.cs | 90 +- .../Sample_RestorePointGroupResource.cs | 104 +- .../Samples/Sample_RestorePointResource.cs | 61 +- .../Samples/Sample_SharedGalleryCollection.cs | 48 +- .../Sample_SharedGalleryImageCollection.cs | 48 +- ...ple_SharedGalleryImageVersionCollection.cs | 48 +- .../Samples/Sample_SnapshotCollection.cs | 82 +- .../Samples/Sample_SnapshotResource.cs | 134 +- .../Samples/Sample_SshPublicKeyCollection.cs | 114 +- .../Samples/Sample_SshPublicKeyResource.cs | 151 +- .../Sample_SubscriptionResourceExtensions.cs | 881 +++++++- .../Sample_VirtualMachineCollection.cs | 1347 ++++++------ ...ample_VirtualMachineExtensionCollection.cs | 181 +- ..._VirtualMachineExtensionImageCollection.cs | 246 +-- .../Sample_VirtualMachineExtensionResource.cs | 105 +- .../Samples/Sample_VirtualMachineResource.cs | 434 ++-- ...mple_VirtualMachineRunCommandCollection.cs | 71 +- ...Sample_VirtualMachineRunCommandResource.cs | 112 +- ...Sample_VirtualMachineScaleSetCollection.cs | 1863 +++++++---------- ...rtualMachineScaleSetExtensionCollection.cs | 168 +- ...VirtualMachineScaleSetExtensionResource.cs | 90 +- .../Sample_VirtualMachineScaleSetResource.cs | 636 ++---- ...mple_VirtualMachineScaleSetVmCollection.cs | 343 ++- ...ualMachineScaleSetVmExtensionCollection.cs | 69 +- ...rtualMachineScaleSetVmExtensionResource.cs | 41 +- ...Sample_VirtualMachineScaleSetVmResource.cs | 564 +++-- ...alMachineScaleSetVmRunCommandCollection.cs | 73 +- ...tualMachineScaleSetVmRunCommandResource.cs | 40 +- 105 files changed, 7301 insertions(+), 8334 deletions(-) create mode 100644 sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs index 2fab9f9b9fd44..b4b16a58f07da 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountCollection.cs @@ -47,11 +47,11 @@ public async Task CreateOrUpdate_CreateAccount() Kind = "Emotion", Sku = new CognitiveServicesSku("S0"), Identity = new ManagedServiceIdentity("SystemAssigned"), - Properties = new CognitiveServicesAccountProperties() + Properties = new CognitiveServicesAccountProperties { - Encryption = new ServiceAccountEncryptionProperties() + Encryption = new ServiceAccountEncryptionProperties { - KeyVaultProperties = new CognitiveServicesKeyVaultProperties() + KeyVaultProperties = new CognitiveServicesKeyVaultProperties { KeyName = "KeyName", KeyVersion = "891CF236-D241-4738-9462-D506AF493DFA", @@ -59,13 +59,10 @@ public async Task CreateOrUpdate_CreateAccount() }, KeySource = ServiceAccountEncryptionKeySource.MicrosoftKeyVault, }, - UserOwnedStorage = -{ -new ServiceAccountUserOwnedStorage() + UserOwnedStorage = {new ServiceAccountUserOwnedStorage { ResourceId = new ResourceIdentifier("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/myStorageAccount"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); @@ -154,10 +151,10 @@ public async Task Get_GetAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAccount() + public async Task GetAll_ListAccountsByResourceGroup() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetAccount.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListAccountsByResourceGroup.json + // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,16 +171,22 @@ public async Task Exists_GetAccount() // get the collection of this CognitiveServicesAccountResource CognitiveServicesAccountCollection collection = resourceGroupResource.GetCognitiveServicesAccounts(); - // invoke the operation - string accountName = "myAccount"; - bool result = await collection.ExistsAsync(accountName); + // invoke the operation and iterate over the result + await foreach (CognitiveServicesAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAccount() + public async Task Exists_GetAccount() { // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetAccount.json // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -205,29 +208,17 @@ public async Task GetIfExists_GetAccount() // invoke the operation string accountName = "myAccount"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - CognitiveServicesAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAccountsByResourceGroup() + public async Task GetIfExists_GetAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListAccountsByResourceGroup.json - // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetAccount.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -244,17 +235,23 @@ public async Task GetAll_ListAccountsByResourceGroup() // get the collection of this CognitiveServicesAccountResource CognitiveServicesAccountCollection collection = resourceGroupResource.GetCognitiveServicesAccounts(); - // invoke the operation and iterate over the result - await foreach (CognitiveServicesAccountResource item in collection.GetAllAsync()) + // invoke the operation + string accountName = "myAccount"; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + CognitiveServicesAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CognitiveServicesAccountData resourceData = item.Data; + CognitiveServicesAccountData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentCollection.cs index 7f4c824efcac2..ff40f98f12be3 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CognitiveServicesAccountDeploymentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDeployments() + public async Task CreateOrUpdate_PutDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListDeployments.json - // this example is just showing the usage of "Deployments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutDeployment.json + // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,32 @@ public async Task GetAll_ListDeployments() // get the collection of this CognitiveServicesAccountDeploymentResource CognitiveServicesAccountDeploymentCollection collection = cognitiveServicesAccount.GetCognitiveServicesAccountDeployments(); - // invoke the operation and iterate over the result - await foreach (CognitiveServicesAccountDeploymentResource item in collection.GetAllAsync()) + // invoke the operation + string deploymentName = "deploymentName"; + CognitiveServicesAccountDeploymentData data = new CognitiveServicesAccountDeploymentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesAccountDeploymentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new CognitiveServicesSku("Standard") + { + Capacity = 1, + }, + Properties = new CognitiveServicesAccountDeploymentProperties + { + Model = new CognitiveServicesAccountDeploymentModel + { + Format = "OpenAI", + Name = "ada", + Version = "1", + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); + CognitiveServicesAccountDeploymentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesAccountDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +103,10 @@ public async Task Get_GetDeployment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDeployment() + public async Task GetAll_ListDeployments() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetDeployment.json - // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListDeployments.json + // this example is just showing the usage of "Deployments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +124,22 @@ public async Task Exists_GetDeployment() // get the collection of this CognitiveServicesAccountDeploymentResource CognitiveServicesAccountDeploymentCollection collection = cognitiveServicesAccount.GetCognitiveServicesAccountDeployments(); - // invoke the operation - string deploymentName = "deploymentName"; - bool result = await collection.ExistsAsync(deploymentName); + // invoke the operation and iterate over the result + await foreach (CognitiveServicesAccountDeploymentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesAccountDeploymentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDeployment() + public async Task Exists_GetDeployment() { // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetDeployment.json // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +162,17 @@ public async Task GetIfExists_GetDeployment() // invoke the operation string deploymentName = "deploymentName"; - NullableResponse response = await collection.GetIfExistsAsync(deploymentName); - CognitiveServicesAccountDeploymentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(deploymentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesAccountDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutDeployment() + public async Task GetIfExists_GetDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutDeployment.json - // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetDeployment.json + // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,30 +192,21 @@ public async Task CreateOrUpdate_PutDeployment() // invoke the operation string deploymentName = "deploymentName"; - CognitiveServicesAccountDeploymentData data = new CognitiveServicesAccountDeploymentData() - { - Sku = new CognitiveServicesSku("Standard") - { - Capacity = 1, - }, - Properties = new CognitiveServicesAccountDeploymentProperties() - { - Model = new CognitiveServicesAccountDeploymentModel() - { - Format = "OpenAI", - Name = "ada", - Version = "1", - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); - CognitiveServicesAccountDeploymentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(deploymentName); + CognitiveServicesAccountDeploymentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesAccountDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesAccountDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentResource.cs index cb2f9eab207fc..2f6dada3ea8de 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountDeploymentResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetDeployment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateDeployment() + public async Task Delete_DeleteDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/UpdateDeployment.json - // this example is just showing the usage of "Deployments_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteDeployment.json + // this example is just showing the usage of "Deployments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,7 +61,7 @@ public async Task Update_UpdateDeployment() // this example assumes you already have this CognitiveServicesAccountDeploymentResource created on azure // for more information of creating CognitiveServicesAccountDeploymentResource, please refer to the document of CognitiveServicesAccountDeploymentResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "subscriptionId"; string resourceGroupName = "resourceGroupName"; string accountName = "accountName"; string deploymentName = "deploymentName"; @@ -69,29 +69,17 @@ public async Task Update_UpdateDeployment() CognitiveServicesAccountDeploymentResource cognitiveServicesAccountDeployment = client.GetCognitiveServicesAccountDeploymentResource(cognitiveServicesAccountDeploymentResourceId); // invoke the operation - PatchResourceTagsAndSku deployment = new PatchResourceTagsAndSku() - { - Sku = new CognitiveServicesSku("Standard") - { - Capacity = 1, - }, - }; - ArmOperation lro = await cognitiveServicesAccountDeployment.UpdateAsync(WaitUntil.Completed, deployment); - CognitiveServicesAccountDeploymentResource result = lro.Value; + await cognitiveServicesAccountDeployment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesAccountDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDeployment() + public async Task Update_UpdateDeployment() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteDeployment.json - // this example is just showing the usage of "Deployments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/UpdateDeployment.json + // this example is just showing the usage of "Deployments_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +88,7 @@ public async Task Delete_DeleteDeployment() // this example assumes you already have this CognitiveServicesAccountDeploymentResource created on azure // for more information of creating CognitiveServicesAccountDeploymentResource, please refer to the document of CognitiveServicesAccountDeploymentResource - string subscriptionId = "subscriptionId"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "resourceGroupName"; string accountName = "accountName"; string deploymentName = "deploymentName"; @@ -108,9 +96,21 @@ public async Task Delete_DeleteDeployment() CognitiveServicesAccountDeploymentResource cognitiveServicesAccountDeployment = client.GetCognitiveServicesAccountDeploymentResource(cognitiveServicesAccountDeploymentResourceId); // invoke the operation - await cognitiveServicesAccountDeployment.DeleteAsync(WaitUntil.Completed); + PatchResourceTagsAndSku deployment = new PatchResourceTagsAndSku + { + Sku = new CognitiveServicesSku("Standard") + { + Capacity = 1, + }, + }; + ArmOperation lro = await cognitiveServicesAccountDeployment.UpdateAsync(WaitUntil.Completed, deployment); + CognitiveServicesAccountDeploymentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesAccountDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountResource.cs index d1b881f80c4ce..7143bc67263a3 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesAccountResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.CognitiveServices.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CognitiveServices.Samples @@ -19,10 +18,10 @@ public partial class Sample_CognitiveServicesAccountResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAccount() + public async Task Get_GetAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/UpdateAccount.json - // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetAccount.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,18 +31,13 @@ public async Task Update_UpdateAccount() // this example assumes you already have this CognitiveServicesAccountResource created on azure // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - string resourceGroupName = "bvttest"; - string accountName = "bingSearch"; + string resourceGroupName = "myResourceGroup"; + string accountName = "myAccount"; ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); // invoke the operation - CognitiveServicesAccountData data = new CognitiveServicesAccountData(new AzureLocation("global")) - { - Sku = new CognitiveServicesSku("S2"), - }; - ArmOperation lro = await cognitiveServicesAccount.UpdateAsync(WaitUntil.Completed, data); - CognitiveServicesAccountResource result = lro.Value; + CognitiveServicesAccountResource result = await cognitiveServicesAccount.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -80,10 +74,10 @@ public async Task Delete_DeleteAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAccount() + public async Task Update_UpdateAccount() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetAccount.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/UpdateAccount.json + // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,13 +87,18 @@ public async Task Get_GetAccount() // this example assumes you already have this CognitiveServicesAccountResource created on azure // for more information of creating CognitiveServicesAccountResource, please refer to the document of CognitiveServicesAccountResource string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - string resourceGroupName = "myResourceGroup"; - string accountName = "myAccount"; + string resourceGroupName = "bvttest"; + string accountName = "bingSearch"; ResourceIdentifier cognitiveServicesAccountResourceId = CognitiveServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CognitiveServicesAccountResource cognitiveServicesAccount = client.GetCognitiveServicesAccountResource(cognitiveServicesAccountResourceId); // invoke the operation - CognitiveServicesAccountResource result = await cognitiveServicesAccount.GetAsync(); + CognitiveServicesAccountData data = new CognitiveServicesAccountData(new AzureLocation("global")) + { + Sku = new CognitiveServicesSku("S2"), + }; + ArmOperation lro = await cognitiveServicesAccount.UpdateAsync(WaitUntil.Completed, data); + CognitiveServicesAccountResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -108,37 +107,6 @@ public async Task Get_GetAccount() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCognitiveServicesAccounts_ListAccountsBySubscription() - { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListAccountsBySubscription.json - // this example is just showing the usage of "Accounts_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CognitiveServicesAccountResource item in subscriptionResource.GetCognitiveServicesAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetKeys_ListKeys() diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanCollection.cs index f8dc99945e0ab..bc2fce52f2b64 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanCollection.cs @@ -41,16 +41,16 @@ public async Task CreateOrUpdate_CreateCommitmentPlan() // invoke the operation string commitmentPlanName = "commitmentPlanName"; - CommitmentPlanData data = new CommitmentPlanData() + CommitmentPlanData data = new CommitmentPlanData { Kind = "SpeechServices", Sku = new CognitiveServicesSku("S0"), Location = new AzureLocation("West US"), - Properties = new CommitmentPlanProperties() + Properties = new CommitmentPlanProperties { HostingModel = ServiceAccountHostingModel.Web, PlanType = "STT", - Current = new CommitmentPeriod() + Current = new CommitmentPeriod { Tier = "T1", }, @@ -102,10 +102,10 @@ public async Task Get_GetCommitmentPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCommitmentPlan() + public async Task GetAll_ListCommitmentPlansByResourceGroup() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSharedCommitmentPlan.json - // this example is just showing the usage of "CommitmentPlans_GetPlan" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListSharedCommitmentPlansByResourceGroup.json + // this example is just showing the usage of "CommitmentPlans_ListPlansByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,16 +122,22 @@ public async Task Exists_GetCommitmentPlan() // get the collection of this CognitiveServicesCommitmentPlanResource CognitiveServicesCommitmentPlanCollection collection = resourceGroupResource.GetCognitiveServicesCommitmentPlans(); - // invoke the operation - string commitmentPlanName = "commitmentPlanName"; - bool result = await collection.ExistsAsync(commitmentPlanName); + // invoke the operation and iterate over the result + await foreach (CognitiveServicesCommitmentPlanResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommitmentPlanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCommitmentPlan() + public async Task Exists_GetCommitmentPlan() { // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSharedCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_GetPlan" operation, for the dependent resources, they will have to be created separately. @@ -153,29 +159,17 @@ public async Task GetIfExists_GetCommitmentPlan() // invoke the operation string commitmentPlanName = "commitmentPlanName"; - NullableResponse response = await collection.GetIfExistsAsync(commitmentPlanName); - CognitiveServicesCommitmentPlanResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(commitmentPlanName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommitmentPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCommitmentPlansByResourceGroup() + public async Task GetIfExists_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListSharedCommitmentPlansByResourceGroup.json - // this example is just showing the usage of "CommitmentPlans_ListPlansByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSharedCommitmentPlan.json + // this example is just showing the usage of "CommitmentPlans_GetPlan" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,17 +186,23 @@ public async Task GetAll_ListCommitmentPlansByResourceGroup() // get the collection of this CognitiveServicesCommitmentPlanResource CognitiveServicesCommitmentPlanCollection collection = resourceGroupResource.GetCognitiveServicesCommitmentPlans(); - // invoke the operation and iterate over the result - await foreach (CognitiveServicesCommitmentPlanResource item in collection.GetAllAsync()) + // invoke the operation + string commitmentPlanName = "commitmentPlanName"; + NullableResponse response = await collection.GetIfExistsAsync(commitmentPlanName); + CognitiveServicesCommitmentPlanResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CommitmentPlanData resourceData = item.Data; + CommitmentPlanData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanResource.cs index 45e9fcb679ccb..e79122b3253d5 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesCommitmentPlanResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.CognitiveServices.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CognitiveServices.Samples @@ -19,10 +18,10 @@ public partial class Sample_CognitiveServicesCommitmentPlanResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateCommitmentPlan() + public async Task Get_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/UpdateSharedCommitmentPlan.json - // this example is just showing the usage of "CommitmentPlans_UpdatePlan" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSharedCommitmentPlan.json + // this example is just showing the usage of "CommitmentPlans_GetPlan" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +37,7 @@ public async Task Update_CreateCommitmentPlan() CognitiveServicesCommitmentPlanResource cognitiveServicesCommitmentPlan = client.GetCognitiveServicesCommitmentPlanResource(cognitiveServicesCommitmentPlanResourceId); // invoke the operation - PatchResourceTagsAndSku commitmentPlan = new PatchResourceTagsAndSku() - { - Tags = -{ -["name"] = "value", -}, - }; - ArmOperation lro = await cognitiveServicesCommitmentPlan.UpdateAsync(WaitUntil.Completed, commitmentPlan); - CognitiveServicesCommitmentPlanResource result = lro.Value; + CognitiveServicesCommitmentPlanResource result = await cognitiveServicesCommitmentPlan.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -83,10 +74,10 @@ public async Task Delete_DeleteCommitmentPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCommitmentPlan() + public async Task Update_CreateCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSharedCommitmentPlan.json - // this example is just showing the usage of "CommitmentPlans_GetPlan" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/UpdateSharedCommitmentPlan.json + // this example is just showing the usage of "CommitmentPlans_UpdatePlan" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,7 +93,15 @@ public async Task Get_GetCommitmentPlan() CognitiveServicesCommitmentPlanResource cognitiveServicesCommitmentPlan = client.GetCognitiveServicesCommitmentPlanResource(cognitiveServicesCommitmentPlanResourceId); // invoke the operation - CognitiveServicesCommitmentPlanResource result = await cognitiveServicesCommitmentPlan.GetAsync(); + PatchResourceTagsAndSku commitmentPlan = new PatchResourceTagsAndSku + { + Tags = +{ +["name"] = "value" +}, + }; + ArmOperation lro = await cognitiveServicesCommitmentPlan.UpdateAsync(WaitUntil.Completed, commitmentPlan); + CognitiveServicesCommitmentPlanResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -110,36 +109,5 @@ public async Task Get_GetCommitmentPlan() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCognitiveServicesCommitmentPlans_ListAccountsBySubscription() - { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListSharedCommitmentPlansBySubscription.json - // this example is just showing the usage of "CommitmentPlans_ListPlansBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CognitiveServicesCommitmentPlanResource item in subscriptionResource.GetCognitiveServicesCommitmentPlansAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommitmentPlanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountResource.cs index 75989e81177bb..7451818d58915 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesDeletedAccountResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CognitiveServices.Samples @@ -73,36 +72,5 @@ public async Task Delete_DeleteAccount() Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeletedAccounts_ListDeletedAccountsBySubscription() - { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListDeletedAccountsBySubscription.json - // this example is just showing the usage of "DeletedAccounts_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CognitiveServicesDeletedAccountResource item in subscriptionResource.GetDeletedAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesEncryptionScopeCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesEncryptionScopeCollection.cs index af9853e857301..809ba8f55a178 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesEncryptionScopeCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesEncryptionScopeCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CognitiveServicesEncryptionScopeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEncryptionScopes() + public async Task CreateOrUpdate_PutEncryptionScope() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListEncryptionScopes.json - // this example is just showing the usage of "EncryptionScopes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,31 @@ public async Task GetAll_ListEncryptionScopes() // get the collection of this CognitiveServicesEncryptionScopeResource CognitiveServicesEncryptionScopeCollection collection = cognitiveServicesAccount.GetCognitiveServicesEncryptionScopes(); - // invoke the operation and iterate over the result - await foreach (CognitiveServicesEncryptionScopeResource item in collection.GetAllAsync()) + // invoke the operation + string encryptionScopeName = "encryptionScopeName"; + CognitiveServicesEncryptionScopeData data = new CognitiveServicesEncryptionScopeData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesEncryptionScopeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new CognitiveServicesEncryptionScopeProperties + { + State = EncryptionScopeState.Enabled, + KeyVaultProperties = new CognitiveServicesKeyVaultProperties + { + KeyName = "DevKeyWestUS2", + KeyVersion = "9f85549d7bf14ff4bf178c10d3bdca95", + KeyVaultUri = new Uri("https://devkvwestus2.vault.azure.net/"), + IdentityClientId = Guid.Parse("00000000-0000-0000-0000-000000000000"), + }, + KeySource = ServiceAccountEncryptionKeySource.MicrosoftKeyVault, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionScopeName, data); + CognitiveServicesEncryptionScopeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesEncryptionScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +102,10 @@ public async Task Get_GetEncryptionScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetEncryptionScope() + public async Task GetAll_ListEncryptionScopes() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetEncryptionScope.json - // this example is just showing the usage of "EncryptionScopes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListEncryptionScopes.json + // this example is just showing the usage of "EncryptionScopes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +123,22 @@ public async Task Exists_GetEncryptionScope() // get the collection of this CognitiveServicesEncryptionScopeResource CognitiveServicesEncryptionScopeCollection collection = cognitiveServicesAccount.GetCognitiveServicesEncryptionScopes(); - // invoke the operation - string encryptionScopeName = "encryptionScopeName"; - bool result = await collection.ExistsAsync(encryptionScopeName); + // invoke the operation and iterate over the result + await foreach (CognitiveServicesEncryptionScopeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesEncryptionScopeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetEncryptionScope() + public async Task Exists_GetEncryptionScope() { // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetEncryptionScope.json // this example is just showing the usage of "EncryptionScopes_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +161,17 @@ public async Task GetIfExists_GetEncryptionScope() // invoke the operation string encryptionScopeName = "encryptionScopeName"; - NullableResponse response = await collection.GetIfExistsAsync(encryptionScopeName); - CognitiveServicesEncryptionScopeResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(encryptionScopeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesEncryptionScopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutEncryptionScope() + public async Task GetIfExists_GetEncryptionScope() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutEncryptionScope.json - // this example is just showing the usage of "EncryptionScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,29 +191,21 @@ public async Task CreateOrUpdate_PutEncryptionScope() // invoke the operation string encryptionScopeName = "encryptionScopeName"; - CognitiveServicesEncryptionScopeData data = new CognitiveServicesEncryptionScopeData() - { - Properties = new CognitiveServicesEncryptionScopeProperties() - { - State = EncryptionScopeState.Enabled, - KeyVaultProperties = new CognitiveServicesKeyVaultProperties() - { - KeyName = "DevKeyWestUS2", - KeyVersion = "9f85549d7bf14ff4bf178c10d3bdca95", - KeyVaultUri = new Uri("https://devkvwestus2.vault.azure.net/"), - IdentityClientId = Guid.Parse("00000000-0000-0000-0000-000000000000"), - }, - KeySource = ServiceAccountEncryptionKeySource.MicrosoftKeyVault, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionScopeName, data); - CognitiveServicesEncryptionScopeResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(encryptionScopeName); + CognitiveServicesEncryptionScopeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesEncryptionScopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesEncryptionScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesEncryptionScopeResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesEncryptionScopeResource.cs index f230aff43b2d9..3ce8f0f68f5d4 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesEncryptionScopeResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesEncryptionScopeResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetEncryptionScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutEncryptionScope() + public async Task Delete_DeleteEncryptionScope() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutEncryptionScope.json - // this example is just showing the usage of "EncryptionScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,37 +69,17 @@ public async Task Update_PutEncryptionScope() CognitiveServicesEncryptionScopeResource cognitiveServicesEncryptionScope = client.GetCognitiveServicesEncryptionScopeResource(cognitiveServicesEncryptionScopeResourceId); // invoke the operation - CognitiveServicesEncryptionScopeData data = new CognitiveServicesEncryptionScopeData() - { - Properties = new CognitiveServicesEncryptionScopeProperties() - { - State = EncryptionScopeState.Enabled, - KeyVaultProperties = new CognitiveServicesKeyVaultProperties() - { - KeyName = "DevKeyWestUS2", - KeyVersion = "9f85549d7bf14ff4bf178c10d3bdca95", - KeyVaultUri = new Uri("https://devkvwestus2.vault.azure.net/"), - IdentityClientId = Guid.Parse("00000000-0000-0000-0000-000000000000"), - }, - KeySource = ServiceAccountEncryptionKeySource.MicrosoftKeyVault, - }, - }; - ArmOperation lro = await cognitiveServicesEncryptionScope.UpdateAsync(WaitUntil.Completed, data); - CognitiveServicesEncryptionScopeResource result = lro.Value; + await cognitiveServicesEncryptionScope.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesEncryptionScopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteEncryptionScope() + public async Task Update_PutEncryptionScope() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteEncryptionScope.json - // this example is just showing the usage of "EncryptionScopes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,9 +96,29 @@ public async Task Delete_DeleteEncryptionScope() CognitiveServicesEncryptionScopeResource cognitiveServicesEncryptionScope = client.GetCognitiveServicesEncryptionScopeResource(cognitiveServicesEncryptionScopeResourceId); // invoke the operation - await cognitiveServicesEncryptionScope.DeleteAsync(WaitUntil.Completed); + CognitiveServicesEncryptionScopeData data = new CognitiveServicesEncryptionScopeData + { + Properties = new CognitiveServicesEncryptionScopeProperties + { + State = EncryptionScopeState.Enabled, + KeyVaultProperties = new CognitiveServicesKeyVaultProperties + { + KeyName = "DevKeyWestUS2", + KeyVersion = "9f85549d7bf14ff4bf178c10d3bdca95", + KeyVaultUri = new Uri("https://devkvwestus2.vault.azure.net/"), + IdentityClientId = Guid.Parse("00000000-0000-0000-0000-000000000000"), + }, + KeySource = ServiceAccountEncryptionKeySource.MicrosoftKeyVault, + }, + }; + ArmOperation lro = await cognitiveServicesEncryptionScope.UpdateAsync(WaitUntil.Completed, data); + CognitiveServicesEncryptionScopeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesEncryptionScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionCollection.cs index 953e9184ff702..a87cbceb51798 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CognitiveServicesPrivateEndpointConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CognitiveServicesPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetPrivateEndpointConnection() + public async Task Get_GetPrivateEndpointConnection() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListPrivateEndpointConnections.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetPrivateEndpointConnection() // get the collection of this CognitiveServicesPrivateEndpointConnectionResource CognitiveServicesPrivateEndpointConnectionCollection collection = cognitiveServicesAccount.GetCognitiveServicesPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (CognitiveServicesPrivateEndpointConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateEndpointConnectionName = "{privateEndpointConnectionName}"; + CognitiveServicesPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndpointConnection() + public async Task GetAll_GetPrivateEndpointConnection() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListPrivateEndpointConnections.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetPrivateEndpointConnection() // get the collection of this CognitiveServicesPrivateEndpointConnectionResource CognitiveServicesPrivateEndpointConnectionCollection collection = cognitiveServicesAccount.GetCognitiveServicesPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - CognitiveServicesPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (CognitiveServicesPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CognitiveServicesPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationCollection.cs index 673430d73ceeb..45edccc03684d 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CommitmentPlanAccountAssociationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCommitmentPlans() + public async Task CreateOrUpdate_PutCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListSharedCommitmentPlanAssociations.json - // this example is just showing the usage of "CommitmentPlans_ListAssociations" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CreateSharedCommitmentPlanAssociation.json + // this example is just showing the usage of "CommitmentPlans_CreateOrUpdateAssociation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ListCommitmentPlans() // get the collection of this CommitmentPlanAccountAssociationResource CommitmentPlanAccountAssociationCollection collection = cognitiveServicesCommitmentPlan.GetCommitmentPlanAccountAssociations(); - // invoke the operation and iterate over the result - await foreach (CommitmentPlanAccountAssociationResource item in collection.GetAllAsync()) + // invoke the operation + string commitmentPlanAssociationName = "commitmentPlanAssociationName"; + CommitmentPlanAccountAssociationData data = new CommitmentPlanAccountAssociationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommitmentPlanAccountAssociationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AccountId = "/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, commitmentPlanAssociationName, data); + CommitmentPlanAccountAssociationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommitmentPlanAccountAssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetCommitmentPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCommitmentPlan() + public async Task GetAll_ListCommitmentPlans() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSharedCommitmentPlanAssociation.json - // this example is just showing the usage of "CommitmentPlans_GetAssociation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListSharedCommitmentPlanAssociations.json + // this example is just showing the usage of "CommitmentPlans_ListAssociations" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_GetCommitmentPlan() // get the collection of this CommitmentPlanAccountAssociationResource CommitmentPlanAccountAssociationCollection collection = cognitiveServicesCommitmentPlan.GetCommitmentPlanAccountAssociations(); - // invoke the operation - string commitmentPlanAssociationName = "commitmentPlanAssociationName"; - bool result = await collection.ExistsAsync(commitmentPlanAssociationName); + // invoke the operation and iterate over the result + await foreach (CommitmentPlanAccountAssociationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommitmentPlanAccountAssociationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCommitmentPlan() + public async Task Exists_GetCommitmentPlan() { // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSharedCommitmentPlanAssociation.json // this example is just showing the usage of "CommitmentPlans_GetAssociation" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_GetCommitmentPlan() // invoke the operation string commitmentPlanAssociationName = "commitmentPlanAssociationName"; - NullableResponse response = await collection.GetIfExistsAsync(commitmentPlanAssociationName); - CommitmentPlanAccountAssociationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(commitmentPlanAssociationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommitmentPlanAccountAssociationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutCommitmentPlan() + public async Task GetIfExists_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CreateSharedCommitmentPlanAssociation.json - // this example is just showing the usage of "CommitmentPlans_CreateOrUpdateAssociation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetSharedCommitmentPlanAssociation.json + // this example is just showing the usage of "CommitmentPlans_GetAssociation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_PutCommitmentPlan() // invoke the operation string commitmentPlanAssociationName = "commitmentPlanAssociationName"; - CommitmentPlanAccountAssociationData data = new CommitmentPlanAccountAssociationData() - { - AccountId = "/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, commitmentPlanAssociationName, data); - CommitmentPlanAccountAssociationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(commitmentPlanAssociationName); + CommitmentPlanAccountAssociationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommitmentPlanAccountAssociationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommitmentPlanAccountAssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationResource.cs index 2ece8176abb76..5ce8b3e170f59 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanAccountAssociationResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetCommitmentPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutCommitmentPlan() + public async Task Delete_DeleteCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CreateSharedCommitmentPlanAssociation.json - // this example is just showing the usage of "CommitmentPlans_CreateOrUpdateAssociation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteSharedCommitmentPlanAssociation.json + // this example is just showing the usage of "CommitmentPlans_DeleteAssociation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_PutCommitmentPlan() CommitmentPlanAccountAssociationResource commitmentPlanAccountAssociation = client.GetCommitmentPlanAccountAssociationResource(commitmentPlanAccountAssociationResourceId); // invoke the operation - CommitmentPlanAccountAssociationData data = new CommitmentPlanAccountAssociationData() - { - AccountId = "/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName", - }; - ArmOperation lro = await commitmentPlanAccountAssociation.UpdateAsync(WaitUntil.Completed, data); - CommitmentPlanAccountAssociationResource result = lro.Value; + await commitmentPlanAccountAssociation.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommitmentPlanAccountAssociationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteCommitmentPlan() + public async Task Update_PutCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteSharedCommitmentPlanAssociation.json - // this example is just showing the usage of "CommitmentPlans_DeleteAssociation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/CreateSharedCommitmentPlanAssociation.json + // this example is just showing the usage of "CommitmentPlans_CreateOrUpdateAssociation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,18 @@ public async Task Delete_DeleteCommitmentPlan() CommitmentPlanAccountAssociationResource commitmentPlanAccountAssociation = client.GetCommitmentPlanAccountAssociationResource(commitmentPlanAccountAssociationResourceId); // invoke the operation - await commitmentPlanAccountAssociation.DeleteAsync(WaitUntil.Completed); + CommitmentPlanAccountAssociationData data = new CommitmentPlanAccountAssociationData + { + AccountId = "/subscriptions/subscriptionId/resourceGroups/resourceGroupName/providers/Microsoft.CognitiveServices/accounts/accountName", + }; + ArmOperation lro = await commitmentPlanAccountAssociation.UpdateAsync(WaitUntil.Completed, data); + CommitmentPlanAccountAssociationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommitmentPlanAccountAssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanCollection.cs index 6d84d16d3bba5..60bbb77a5b319 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CommitmentPlanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCommitmentPlans() + public async Task CreateOrUpdate_PutCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListCommitmentPlans.json - // this example is just showing the usage of "CommitmentPlans_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutCommitmentPlan.json + // this example is just showing the usage of "CommitmentPlans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,29 @@ public async Task GetAll_ListCommitmentPlans() // get the collection of this CommitmentPlanResource CommitmentPlanCollection collection = cognitiveServicesAccount.GetCommitmentPlans(); - // invoke the operation and iterate over the result - await foreach (CommitmentPlanResource item in collection.GetAllAsync()) + // invoke the operation + string commitmentPlanName = "commitmentPlanName"; + CommitmentPlanData data = new CommitmentPlanData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommitmentPlanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new CommitmentPlanProperties + { + HostingModel = ServiceAccountHostingModel.Web, + PlanType = "Speech2Text", + Current = new CommitmentPeriod + { + Tier = "T1", + }, + AutoRenew = true, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, commitmentPlanName, data); + CommitmentPlanResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommitmentPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +100,10 @@ public async Task Get_GetCommitmentPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCommitmentPlan() + public async Task GetAll_ListCommitmentPlans() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetCommitmentPlan.json - // this example is just showing the usage of "CommitmentPlans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListCommitmentPlans.json + // this example is just showing the usage of "CommitmentPlans_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +121,22 @@ public async Task Exists_GetCommitmentPlan() // get the collection of this CommitmentPlanResource CommitmentPlanCollection collection = cognitiveServicesAccount.GetCommitmentPlans(); - // invoke the operation - string commitmentPlanName = "commitmentPlanName"; - bool result = await collection.ExistsAsync(commitmentPlanName); + // invoke the operation and iterate over the result + await foreach (CommitmentPlanResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommitmentPlanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCommitmentPlan() + public async Task Exists_GetCommitmentPlan() { // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetCommitmentPlan.json // this example is just showing the usage of "CommitmentPlans_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +159,17 @@ public async Task GetIfExists_GetCommitmentPlan() // invoke the operation string commitmentPlanName = "commitmentPlanName"; - NullableResponse response = await collection.GetIfExistsAsync(commitmentPlanName); - CommitmentPlanResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(commitmentPlanName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommitmentPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutCommitmentPlan() + public async Task GetIfExists_GetCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutCommitmentPlan.json - // this example is just showing the usage of "CommitmentPlans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetCommitmentPlan.json + // this example is just showing the usage of "CommitmentPlans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,27 +189,21 @@ public async Task CreateOrUpdate_PutCommitmentPlan() // invoke the operation string commitmentPlanName = "commitmentPlanName"; - CommitmentPlanData data = new CommitmentPlanData() - { - Properties = new CommitmentPlanProperties() - { - HostingModel = ServiceAccountHostingModel.Web, - PlanType = "Speech2Text", - Current = new CommitmentPeriod() - { - Tier = "T1", - }, - AutoRenew = true, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, commitmentPlanName, data); - CommitmentPlanResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(commitmentPlanName); + CommitmentPlanResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommitmentPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommitmentPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanResource.cs index 4dbdf16b1f65c..c00ea462a2aa3 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_CommitmentPlanResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetCommitmentPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutCommitmentPlan() + public async Task Delete_DeleteCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutCommitmentPlan.json - // this example is just showing the usage of "CommitmentPlans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteCommitmentPlan.json + // this example is just showing the usage of "CommitmentPlans_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,35 +69,17 @@ public async Task Update_PutCommitmentPlan() CommitmentPlanResource commitmentPlan = client.GetCommitmentPlanResource(commitmentPlanResourceId); // invoke the operation - CommitmentPlanData data = new CommitmentPlanData() - { - Properties = new CommitmentPlanProperties() - { - HostingModel = ServiceAccountHostingModel.Web, - PlanType = "Speech2Text", - Current = new CommitmentPeriod() - { - Tier = "T1", - }, - AutoRenew = true, - }, - }; - ArmOperation lro = await commitmentPlan.UpdateAsync(WaitUntil.Completed, data); - CommitmentPlanResource result = lro.Value; + await commitmentPlan.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommitmentPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteCommitmentPlan() + public async Task Update_PutCommitmentPlan() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteCommitmentPlan.json - // this example is just showing the usage of "CommitmentPlans_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutCommitmentPlan.json + // this example is just showing the usage of "CommitmentPlans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +96,27 @@ public async Task Delete_DeleteCommitmentPlan() CommitmentPlanResource commitmentPlan = client.GetCommitmentPlanResource(commitmentPlanResourceId); // invoke the operation - await commitmentPlan.DeleteAsync(WaitUntil.Completed); + CommitmentPlanData data = new CommitmentPlanData + { + Properties = new CommitmentPlanProperties + { + HostingModel = ServiceAccountHostingModel.Web, + PlanType = "Speech2Text", + Current = new CommitmentPeriod + { + Tier = "T1", + }, + AutoRenew = true, + }, + }; + ArmOperation lro = await commitmentPlan.UpdateAsync(WaitUntil.Completed, data); + CommitmentPlanResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommitmentPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingCollection.cs index 414619a76248f..5599f369f4d0b 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DefenderForAISettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDefenderForAISetting() + public async Task CreateOrUpdate_PutDefenderForAISetting() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListDefenderForAISetting.json - // this example is just showing the usage of "DefenderForAISettings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutDefenderForAISetting.json + // this example is just showing the usage of "DefenderForAISettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ListDefenderForAISetting() // get the collection of this DefenderForAISettingResource DefenderForAISettingCollection collection = cognitiveServicesAccount.GetDefenderForAISettings(); - // invoke the operation and iterate over the result - await foreach (DefenderForAISettingResource item in collection.GetAllAsync()) + // invoke the operation + string defenderForAISettingName = "Default"; + DefenderForAISettingData data = new DefenderForAISettingData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DefenderForAISettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + State = DefenderForAISettingState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, defenderForAISettingName, data); + DefenderForAISettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DefenderForAISettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_GetDefenderForAISetting() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDefenderForAISetting() + public async Task GetAll_ListDefenderForAISetting() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetDefenderForAISetting.json - // this example is just showing the usage of "DefenderForAISettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListDefenderForAISetting.json + // this example is just showing the usage of "DefenderForAISettings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_GetDefenderForAISetting() // get the collection of this DefenderForAISettingResource DefenderForAISettingCollection collection = cognitiveServicesAccount.GetDefenderForAISettings(); - // invoke the operation - string defenderForAISettingName = "Default"; - bool result = await collection.ExistsAsync(defenderForAISettingName); + // invoke the operation and iterate over the result + await foreach (DefenderForAISettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DefenderForAISettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDefenderForAISetting() + public async Task Exists_GetDefenderForAISetting() { // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetDefenderForAISetting.json // this example is just showing the usage of "DefenderForAISettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_GetDefenderForAISetting() // invoke the operation string defenderForAISettingName = "Default"; - NullableResponse response = await collection.GetIfExistsAsync(defenderForAISettingName); - DefenderForAISettingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(defenderForAISettingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DefenderForAISettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutDefenderForAISetting() + public async Task GetIfExists_GetDefenderForAISetting() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutDefenderForAISetting.json - // this example is just showing the usage of "DefenderForAISettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetDefenderForAISetting.json + // this example is just showing the usage of "DefenderForAISettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_PutDefenderForAISetting() // invoke the operation string defenderForAISettingName = "Default"; - DefenderForAISettingData data = new DefenderForAISettingData() - { - State = DefenderForAISettingState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, defenderForAISettingName, data); - DefenderForAISettingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(defenderForAISettingName); + DefenderForAISettingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DefenderForAISettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DefenderForAISettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingResource.cs index 4ea7db0f1ae0c..5003e2b07273e 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_DefenderForAISettingResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdateDefenderForAISetting() DefenderForAISettingResource defenderForAISetting = client.GetDefenderForAISettingResource(defenderForAISettingResourceId); // invoke the operation - DefenderForAISettingData data = new DefenderForAISettingData() + DefenderForAISettingData data = new DefenderForAISettingData { State = DefenderForAISettingState.Enabled, }; diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs index a3943d5f93df7..0ff592031c273 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkSecurityPerimeterConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNetworkSecurityPerimeterConfigurations() + public async Task Get_GetNetworkSecurityPerimeterConfigurations() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListNetworkSecurityPerimeterConfigurations.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetNetworkSecurityPerimeterConfigurations.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListNetworkSecurityPerimeterConfigurations() // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = cognitiveServicesAccount.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string nspConfigurationName = "NSPConfigurationName"; + NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(nspConfigurationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSecurityPerimeterConfigurations() + public async Task GetAll_ListNetworkSecurityPerimeterConfigurations() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetNetworkSecurityPerimeterConfigurations.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListNetworkSecurityPerimeterConfigurations.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetNetworkSecurityPerimeterConfigurations() // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = cognitiveServicesAccount.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation - string nspConfigurationName = "NSPConfigurationName"; - NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(nspConfigurationName); + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistCollection.cs index 82366497616ac..a6f43c7c4acd8 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RaiBlocklistCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBlocklists() + public async Task CreateOrUpdate_PutRaiBlocklist() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListBlocklists.json - // this example is just showing the usage of "RaiBlocklists_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ListBlocklists() // get the collection of this RaiBlocklistResource RaiBlocklistCollection collection = cognitiveServicesAccount.GetRaiBlocklists(); - // invoke the operation and iterate over the result - await foreach (RaiBlocklistResource item in collection.GetAllAsync()) + // invoke the operation + string raiBlocklistName = "raiBlocklistName"; + RaiBlocklistData data = new RaiBlocklistData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiBlocklistData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + RaiBlocklistDescription = "Basic blocklist description", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, raiBlocklistName, data); + RaiBlocklistResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiBlocklistData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetRaiBlocklist() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRaiBlocklist() + public async Task GetAll_ListBlocklists() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiBlocklist.json - // this example is just showing the usage of "RaiBlocklists_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListBlocklists.json + // this example is just showing the usage of "RaiBlocklists_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_GetRaiBlocklist() // get the collection of this RaiBlocklistResource RaiBlocklistCollection collection = cognitiveServicesAccount.GetRaiBlocklists(); - // invoke the operation - string raiBlocklistName = "raiBlocklistName"; - bool result = await collection.ExistsAsync(raiBlocklistName); + // invoke the operation and iterate over the result + await foreach (RaiBlocklistResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiBlocklistData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRaiBlocklist() + public async Task Exists_GetRaiBlocklist() { // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiBlocklist.json // this example is just showing the usage of "RaiBlocklists_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_GetRaiBlocklist() // invoke the operation string raiBlocklistName = "raiBlocklistName"; - NullableResponse response = await collection.GetIfExistsAsync(raiBlocklistName); - RaiBlocklistResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(raiBlocklistName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiBlocklistData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutRaiBlocklist() + public async Task GetIfExists_GetRaiBlocklist() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiBlocklist.json - // this example is just showing the usage of "RaiBlocklists_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_PutRaiBlocklist() // invoke the operation string raiBlocklistName = "raiBlocklistName"; - RaiBlocklistData data = new RaiBlocklistData() - { - RaiBlocklistDescription = "Basic blocklist description", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, raiBlocklistName, data); - RaiBlocklistResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(raiBlocklistName); + RaiBlocklistResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiBlocklistData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiBlocklistData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemCollection.cs index 950ae74b4f73b..a6b42192cbb16 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RaiBlocklistItemCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBlocklistItems() + public async Task CreateOrUpdate_PutRaiBlocklistItem() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListBlocklistItems.json - // this example is just showing the usage of "RaiBlocklistItems_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,24 @@ public async Task GetAll_ListBlocklistItems() // get the collection of this RaiBlocklistItemResource RaiBlocklistItemCollection collection = raiBlocklist.GetRaiBlocklistItems(); - // invoke the operation and iterate over the result - await foreach (RaiBlocklistItemResource item in collection.GetAllAsync()) + // invoke the operation + string raiBlocklistItemName = "raiBlocklistItemName"; + RaiBlocklistItemData data = new RaiBlocklistItemData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiBlocklistItemData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new RaiBlocklistItemProperties + { + Pattern = "Pattern To Block", + IsRegex = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, raiBlocklistItemName, data); + RaiBlocklistItemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiBlocklistItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +97,10 @@ public async Task Get_GetRaiBlocklistItem() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRaiBlocklistItem() + public async Task GetAll_ListBlocklistItems() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiBlocklistItem.json - // this example is just showing the usage of "RaiBlocklistItems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListBlocklistItems.json + // this example is just showing the usage of "RaiBlocklistItems_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +119,22 @@ public async Task Exists_GetRaiBlocklistItem() // get the collection of this RaiBlocklistItemResource RaiBlocklistItemCollection collection = raiBlocklist.GetRaiBlocklistItems(); - // invoke the operation - string raiBlocklistItemName = "raiBlocklistItemName"; - bool result = await collection.ExistsAsync(raiBlocklistItemName); + // invoke the operation and iterate over the result + await foreach (RaiBlocklistItemResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiBlocklistItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRaiBlocklistItem() + public async Task Exists_GetRaiBlocklistItem() { // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiBlocklistItem.json // this example is just showing the usage of "RaiBlocklistItems_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +158,17 @@ public async Task GetIfExists_GetRaiBlocklistItem() // invoke the operation string raiBlocklistItemName = "raiBlocklistItemName"; - NullableResponse response = await collection.GetIfExistsAsync(raiBlocklistItemName); - RaiBlocklistItemResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(raiBlocklistItemName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiBlocklistItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutRaiBlocklistItem() + public async Task GetIfExists_GetRaiBlocklistItem() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiBlocklistItem.json - // this example is just showing the usage of "RaiBlocklistItems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,22 +189,21 @@ public async Task CreateOrUpdate_PutRaiBlocklistItem() // invoke the operation string raiBlocklistItemName = "raiBlocklistItemName"; - RaiBlocklistItemData data = new RaiBlocklistItemData() - { - Properties = new RaiBlocklistItemProperties() - { - Pattern = "Pattern To Block", - IsRegex = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, raiBlocklistItemName, data); - RaiBlocklistItemResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(raiBlocklistItemName); + RaiBlocklistItemResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiBlocklistItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiBlocklistItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemResource.cs index 9bab3208ab493..3bbe5b7155c40 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistItemResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetRaiBlocklistItem() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutRaiBlocklistItem() + public async Task Delete_DeleteRaiBlocklistItem() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiBlocklistItem.json - // this example is just showing the usage of "RaiBlocklistItems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,30 +71,17 @@ public async Task Update_PutRaiBlocklistItem() RaiBlocklistItemResource raiBlocklistItem = client.GetRaiBlocklistItemResource(raiBlocklistItemResourceId); // invoke the operation - RaiBlocklistItemData data = new RaiBlocklistItemData() - { - Properties = new RaiBlocklistItemProperties() - { - Pattern = "Pattern To Block", - IsRegex = false, - }, - }; - ArmOperation lro = await raiBlocklistItem.UpdateAsync(WaitUntil.Completed, data); - RaiBlocklistItemResource result = lro.Value; + await raiBlocklistItem.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiBlocklistItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRaiBlocklistItem() + public async Task Update_PutRaiBlocklistItem() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteRaiBlocklistItem.json - // this example is just showing the usage of "RaiBlocklistItems_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiBlocklistItem.json + // this example is just showing the usage of "RaiBlocklistItems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,9 +99,22 @@ public async Task Delete_DeleteRaiBlocklistItem() RaiBlocklistItemResource raiBlocklistItem = client.GetRaiBlocklistItemResource(raiBlocklistItemResourceId); // invoke the operation - await raiBlocklistItem.DeleteAsync(WaitUntil.Completed); + RaiBlocklistItemData data = new RaiBlocklistItemData + { + Properties = new RaiBlocklistItemProperties + { + Pattern = "Pattern To Block", + IsRegex = false, + }, + }; + ArmOperation lro = await raiBlocklistItem.UpdateAsync(WaitUntil.Completed, data); + RaiBlocklistItemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiBlocklistItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistResource.cs index da2826a4397e6..def4239756109 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiBlocklistResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetRaiBlocklist() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutRaiBlocklist() + public async Task Delete_DeleteRaiBlocklist() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiBlocklist.json - // this example is just showing the usage of "RaiBlocklists_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_PutRaiBlocklist() RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); // invoke the operation - RaiBlocklistData data = new RaiBlocklistData() - { - RaiBlocklistDescription = "Basic blocklist description", - }; - ArmOperation lro = await raiBlocklist.UpdateAsync(WaitUntil.Completed, data); - RaiBlocklistResource result = lro.Value; + await raiBlocklist.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiBlocklistData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRaiBlocklist() + public async Task Update_PutRaiBlocklist() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteRaiBlocklist.json - // this example is just showing the usage of "RaiBlocklists_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiBlocklist.json + // this example is just showing the usage of "RaiBlocklists_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +97,18 @@ public async Task Delete_DeleteRaiBlocklist() RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); // invoke the operation - await raiBlocklist.DeleteAsync(WaitUntil.Completed); + RaiBlocklistData data = new RaiBlocklistData + { + RaiBlocklistDescription = "Basic blocklist description", + }; + ArmOperation lro = await raiBlocklist.UpdateAsync(WaitUntil.Completed, data); + RaiBlocklistResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiBlocklistData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -135,18 +135,19 @@ public async Task BatchAddRaiBlocklistItem_AddRaiBlocklistItems() // invoke the operation IEnumerable content = new RaiBlocklistItemBulkContent[] { -new RaiBlocklistItemBulkContent() +new RaiBlocklistItemBulkContent { Name = "myblocklistitem1", -Properties = new RaiBlocklistItemProperties() +Properties = new RaiBlocklistItemProperties { Pattern = "^[a-z0-9_-]{2,16}$", IsRegex = true, }, -},new RaiBlocklistItemBulkContent() +}, +new RaiBlocklistItemBulkContent { Name = "myblocklistitem2", -Properties = new RaiBlocklistItemProperties() +Properties = new RaiBlocklistItemProperties { Pattern = "blockwords", IsRegex = false, @@ -184,7 +185,11 @@ public async Task BatchDeleteRaiBlocklistItem_DeleteRaiBlocklistItems() RaiBlocklistResource raiBlocklist = client.GetRaiBlocklistResource(raiBlocklistResourceId); // invoke the operation - BinaryData raiBlocklistItemsNames = BinaryData.FromObjectAsJson(new object[] { "myblocklistitem1", "myblocklistitem2" }); + BinaryData raiBlocklistItemsNames = BinaryData.FromObjectAsJson(new object[] + { +"myblocklistitem1", +"myblocklistitem2" + }); await raiBlocklist.BatchDeleteRaiBlocklistItemAsync(raiBlocklistItemsNames); Console.WriteLine("Succeeded"); diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiContentFilterCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiContentFilterCollection.cs index d14bee7b8f5f4..0f88b79808a20 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiContentFilterCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiContentFilterCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RaiContentFilterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRaiContentFilters() + public async Task Get_GetRaiContentFilters() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListRaiContentFilters.json - // this example is just showing the usage of "RaiContentFilters_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiContentFilter.json + // this example is just showing the usage of "RaiContentFilters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListRaiContentFilters() AzureLocation location = new AzureLocation("WestUS"); RaiContentFilterCollection collection = subscriptionResource.GetRaiContentFilters(location); - // invoke the operation and iterate over the result - await foreach (RaiContentFilterResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiContentFilterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string filterName = "IndirectAttack"; + RaiContentFilterResource result = await collection.GetAsync(filterName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiContentFilterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRaiContentFilters() + public async Task GetAll_ListRaiContentFilters() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiContentFilter.json - // this example is just showing the usage of "RaiContentFilters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListRaiContentFilters.json + // this example is just showing the usage of "RaiContentFilters_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetRaiContentFilters() AzureLocation location = new AzureLocation("WestUS"); RaiContentFilterCollection collection = subscriptionResource.GetRaiContentFilters(location); - // invoke the operation - string filterName = "IndirectAttack"; - RaiContentFilterResource result = await collection.GetAsync(filterName); + // invoke the operation and iterate over the result + await foreach (RaiContentFilterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiContentFilterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiContentFilterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyCollection.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyCollection.cs index 46db1a134689b..23a99d41bb7d3 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyCollection.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RaiPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRaiPolicies() + public async Task CreateOrUpdate_PutRaiPolicy() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListRaiPolicies.json - // this example is just showing the usage of "RaiPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiPolicy.json + // this example is just showing the usage of "RaiPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,105 @@ public async Task GetAll_ListRaiPolicies() // get the collection of this RaiPolicyResource RaiPolicyCollection collection = cognitiveServicesAccount.GetRaiPolicies(); - // invoke the operation and iterate over the result - await foreach (RaiPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string raiPolicyName = "raiPolicyName"; + RaiPolicyData data = new RaiPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new RaiPolicyProperties + { + Mode = RaiPolicyMode.AsynchronousFilter, + BasePolicyName = "Microsoft.Default", + ContentFilters = {new RaiPolicyContentFilter +{ +Name = "hate", +Enabled = false, +SeverityThreshold = RaiPolicyContentLevel.High, +Blocking = false, +Source = RaiPolicyContentSource.Prompt, +}, new RaiPolicyContentFilter +{ +Name = "hate", +Enabled = true, +SeverityThreshold = RaiPolicyContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +}, new RaiPolicyContentFilter +{ +Name = "sexual", +Enabled = true, +SeverityThreshold = RaiPolicyContentLevel.High, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +}, new RaiPolicyContentFilter +{ +Name = "sexual", +Enabled = true, +SeverityThreshold = RaiPolicyContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +}, new RaiPolicyContentFilter +{ +Name = "selfharm", +Enabled = true, +SeverityThreshold = RaiPolicyContentLevel.High, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +}, new RaiPolicyContentFilter +{ +Name = "selfharm", +Enabled = true, +SeverityThreshold = RaiPolicyContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +}, new RaiPolicyContentFilter +{ +Name = "violence", +Enabled = true, +SeverityThreshold = RaiPolicyContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +}, new RaiPolicyContentFilter +{ +Name = "violence", +Enabled = true, +SeverityThreshold = RaiPolicyContentLevel.Medium, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +}, new RaiPolicyContentFilter +{ +Name = "jailbreak", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +}, new RaiPolicyContentFilter +{ +Name = "protected_material_text", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +}, new RaiPolicyContentFilter +{ +Name = "protected_material_code", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Completion, +}, new RaiPolicyContentFilter +{ +Name = "profanity", +Enabled = true, +Blocking = true, +Source = RaiPolicyContentSource.Prompt, +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, raiPolicyName, data); + RaiPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +176,10 @@ public async Task Get_GetRaiPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRaiPolicy() + public async Task GetAll_ListRaiPolicies() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiPolicy.json - // this example is just showing the usage of "RaiPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListRaiPolicies.json + // this example is just showing the usage of "RaiPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +197,22 @@ public async Task Exists_GetRaiPolicy() // get the collection of this RaiPolicyResource RaiPolicyCollection collection = cognitiveServicesAccount.GetRaiPolicies(); - // invoke the operation - string raiPolicyName = "raiPolicyName"; - bool result = await collection.ExistsAsync(raiPolicyName); + // invoke the operation and iterate over the result + await foreach (RaiPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRaiPolicy() + public async Task Exists_GetRaiPolicy() { // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiPolicy.json // this example is just showing the usage of "RaiPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +235,17 @@ public async Task GetIfExists_GetRaiPolicy() // invoke the operation string raiPolicyName = "raiPolicyName"; - NullableResponse response = await collection.GetIfExistsAsync(raiPolicyName); - RaiPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(raiPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutRaiPolicy() + public async Task GetIfExists_GetRaiPolicy() { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/PutRaiPolicy.json - // this example is just showing the usage of "RaiPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/GetRaiPolicy.json + // this example is just showing the usage of "RaiPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,106 +265,21 @@ public async Task CreateOrUpdate_PutRaiPolicy() // invoke the operation string raiPolicyName = "raiPolicyName"; - RaiPolicyData data = new RaiPolicyData() - { - Properties = new RaiPolicyProperties() - { - Mode = RaiPolicyMode.AsynchronousFilter, - BasePolicyName = "Microsoft.Default", - ContentFilters = -{ -new RaiPolicyContentFilter() -{ -Name = "hate", -Enabled = false, -SeverityThreshold = RaiPolicyContentLevel.High, -Blocking = false, -Source = RaiPolicyContentSource.Prompt, -},new RaiPolicyContentFilter() -{ -Name = "hate", -Enabled = true, -SeverityThreshold = RaiPolicyContentLevel.Medium, -Blocking = true, -Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() -{ -Name = "sexual", -Enabled = true, -SeverityThreshold = RaiPolicyContentLevel.High, -Blocking = true, -Source = RaiPolicyContentSource.Prompt, -},new RaiPolicyContentFilter() -{ -Name = "sexual", -Enabled = true, -SeverityThreshold = RaiPolicyContentLevel.Medium, -Blocking = true, -Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() -{ -Name = "selfharm", -Enabled = true, -SeverityThreshold = RaiPolicyContentLevel.High, -Blocking = true, -Source = RaiPolicyContentSource.Prompt, -},new RaiPolicyContentFilter() -{ -Name = "selfharm", -Enabled = true, -SeverityThreshold = RaiPolicyContentLevel.Medium, -Blocking = true, -Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() -{ -Name = "violence", -Enabled = true, -SeverityThreshold = RaiPolicyContentLevel.Medium, -Blocking = true, -Source = RaiPolicyContentSource.Prompt, -},new RaiPolicyContentFilter() -{ -Name = "violence", -Enabled = true, -SeverityThreshold = RaiPolicyContentLevel.Medium, -Blocking = true, -Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() -{ -Name = "jailbreak", -Enabled = true, -Blocking = true, -Source = RaiPolicyContentSource.Prompt, -},new RaiPolicyContentFilter() -{ -Name = "protected_material_text", -Enabled = true, -Blocking = true, -Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() -{ -Name = "protected_material_code", -Enabled = true, -Blocking = true, -Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() -{ -Name = "profanity", -Enabled = true, -Blocking = true, -Source = RaiPolicyContentSource.Prompt, -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, raiPolicyName, data); - RaiPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(raiPolicyName); + RaiPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RaiPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RaiPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyResource.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyResource.cs index 372aa2e7b35b8..675b47542fa42 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyResource.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_RaiPolicyResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetRaiPolicy() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteRaiPolicy() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteRaiPolicy.json + // this example is just showing the usage of "RaiPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this RaiPolicyResource created on azure + // for more information of creating RaiPolicyResource, please refer to the document of RaiPolicyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resourceGroupName"; + string accountName = "accountName"; + string raiPolicyName = "raiPolicyName"; + ResourceIdentifier raiPolicyResourceId = RaiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiPolicyName); + RaiPolicyResource raiPolicy = client.GetRaiPolicyResource(raiPolicyResourceId); + + // invoke the operation + await raiPolicy.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_PutRaiPolicy() @@ -69,96 +96,93 @@ public async Task Update_PutRaiPolicy() RaiPolicyResource raiPolicy = client.GetRaiPolicyResource(raiPolicyResourceId); // invoke the operation - RaiPolicyData data = new RaiPolicyData() + RaiPolicyData data = new RaiPolicyData { - Properties = new RaiPolicyProperties() + Properties = new RaiPolicyProperties { Mode = RaiPolicyMode.AsynchronousFilter, BasePolicyName = "Microsoft.Default", - ContentFilters = -{ -new RaiPolicyContentFilter() + ContentFilters = {new RaiPolicyContentFilter { Name = "hate", Enabled = false, SeverityThreshold = RaiPolicyContentLevel.High, Blocking = false, Source = RaiPolicyContentSource.Prompt, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "hate", Enabled = true, SeverityThreshold = RaiPolicyContentLevel.Medium, Blocking = true, Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "sexual", Enabled = true, SeverityThreshold = RaiPolicyContentLevel.High, Blocking = true, Source = RaiPolicyContentSource.Prompt, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "sexual", Enabled = true, SeverityThreshold = RaiPolicyContentLevel.Medium, Blocking = true, Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "selfharm", Enabled = true, SeverityThreshold = RaiPolicyContentLevel.High, Blocking = true, Source = RaiPolicyContentSource.Prompt, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "selfharm", Enabled = true, SeverityThreshold = RaiPolicyContentLevel.Medium, Blocking = true, Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "violence", Enabled = true, SeverityThreshold = RaiPolicyContentLevel.Medium, Blocking = true, Source = RaiPolicyContentSource.Prompt, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "violence", Enabled = true, SeverityThreshold = RaiPolicyContentLevel.Medium, Blocking = true, Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "jailbreak", Enabled = true, Blocking = true, Source = RaiPolicyContentSource.Prompt, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "protected_material_text", Enabled = true, Blocking = true, Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "protected_material_code", Enabled = true, Blocking = true, Source = RaiPolicyContentSource.Completion, -},new RaiPolicyContentFilter() +}, new RaiPolicyContentFilter { Name = "profanity", Enabled = true, Blocking = true, Source = RaiPolicyContentSource.Prompt, -} -}, +}}, }, }; ArmOperation lro = await raiPolicy.UpdateAsync(WaitUntil.Completed, data); @@ -170,32 +194,5 @@ public async Task Update_PutRaiPolicy() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRaiPolicy() - { - // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/DeleteRaiPolicy.json - // this example is just showing the usage of "RaiPolicies_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this RaiPolicyResource created on azure - // for more information of creating RaiPolicyResource, please refer to the document of RaiPolicyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resourceGroupName"; - string accountName = "accountName"; - string raiPolicyName = "raiPolicyName"; - ResourceIdentifier raiPolicyResourceId = RaiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, raiPolicyName); - RaiPolicyResource raiPolicy = client.GetRaiPolicyResource(raiPolicyResourceId); - - // invoke the operation - await raiPolicy.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 2047a9c31b164..11e46ff371efa 100644 --- a/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/cognitiveservices/Azure.ResourceManager.CognitiveServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,68 @@ namespace Azure.ResourceManager.CognitiveServices.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCognitiveServicesAccounts_ListAccountsBySubscription() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListAccountsBySubscription.json + // this example is just showing the usage of "Accounts_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CognitiveServicesAccountResource item in subscriptionResource.GetCognitiveServicesAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeletedAccounts_ListDeletedAccountsBySubscription() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListDeletedAccountsBySubscription.json + // this example is just showing the usage of "DeletedAccounts_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CognitiveServicesDeletedAccountResource item in subscriptionResource.GetDeletedAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CognitiveServicesAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetResourceSkus_RegenerateKeys() @@ -92,10 +154,7 @@ public async Task CheckSkuAvailability_CheckSKUAvailability() // invoke the operation and iterate over the result AzureLocation location = new AzureLocation("westus"); - CognitiveServicesSkuAvailabilityContent content = new CognitiveServicesSkuAvailabilityContent(new string[] - { -"S0" - }, "Face", new ResourceType("Microsoft.CognitiveServices/accounts")); + CognitiveServicesSkuAvailabilityContent content = new CognitiveServicesSkuAvailabilityContent(new string[] { "S0" }, "Face", new ResourceType("Microsoft.CognitiveServices/accounts")); await foreach (CognitiveServicesSkuAvailabilityList item in subscriptionResource.CheckSkuAvailabilityAsync(location, content)) { Console.WriteLine($"Succeeded: {item}"); @@ -148,35 +207,32 @@ public async Task CalculateModelCapacity_CalculateModelCapacity() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - CalculateModelCapacityContent content = new CalculateModelCapacityContent() + CalculateModelCapacityContent content = new CalculateModelCapacityContent { - Model = new CognitiveServicesAccountDeploymentModel() + Model = new CognitiveServicesAccountDeploymentModel { Format = "OpenAI", Name = "gpt-4", Version = "0613", }, SkuName = "ProvisionedManaged", - Workloads = -{ -new ModelCapacityCalculatorWorkload() + Workloads = {new ModelCapacityCalculatorWorkload { RequestPerMinute = 10L, -RequestParameters = new ModelCapacityCalculatorWorkloadRequestParam() +RequestParameters = new ModelCapacityCalculatorWorkloadRequestParam { AvgPromptTokens = 30L, AvgGeneratedTokens = 50L, }, -},new ModelCapacityCalculatorWorkload() +}, new ModelCapacityCalculatorWorkload { RequestPerMinute = 20L, -RequestParameters = new ModelCapacityCalculatorWorkloadRequestParam() +RequestParameters = new ModelCapacityCalculatorWorkloadRequestParam { AvgPromptTokens = 60L, AvgGeneratedTokens = 20L, }, -} -}, +}}, }; CalculateModelCapacityResult result = await subscriptionResource.CalculateModelCapacityAsync(content); @@ -299,5 +355,36 @@ public async Task GetModelCapacities_ListModelCapacities() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCognitiveServicesCommitmentPlans_ListAccountsBySubscription() + { + // Generated from example definition: specification/cognitiveservices/resource-manager/Microsoft.CognitiveServices/stable/2024-10-01/examples/ListSharedCommitmentPlansBySubscription.json + // this example is just showing the usage of "CommitmentPlans_ListPlansBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CognitiveServicesCommitmentPlanResource item in subscriptionResource.GetCognitiveServicesCommitmentPlansAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommitmentPlanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationDomainResource.cs b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationDomainResource.cs index d180c255c2aa5..b3dd7c6b6214c 100644 --- a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationDomainResource.cs +++ b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationDomainResource.cs @@ -96,7 +96,7 @@ public async Task Update_UpdateDomainsResource() CommunicationDomainResource communicationDomainResource = client.GetCommunicationDomainResource(communicationDomainResourceId); // invoke the operation - CommunicationDomainResourcePatch patch = new CommunicationDomainResourcePatch() + CommunicationDomainResourcePatch patch = new CommunicationDomainResourcePatch { UserEngagementTracking = UserEngagementTracking.Enabled, }; diff --git a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationDomainResourceCollection.cs b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationDomainResourceCollection.cs index 194706fad73db..f3f20e247ebd5 100644 --- a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationDomainResourceCollection.cs +++ b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationDomainResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CommunicationDomainResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDomainsResource() + public async Task CreateOrUpdate_CreateOrUpdateDomainsResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/domains/get.json - // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/domains/createOrUpdate.json + // this example is just showing the usage of "Domains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetDomainsResource() // invoke the operation string domainName = "mydomain.com"; - CommunicationDomainResource result = await collection.GetAsync(domainName); + CommunicationDomainResourceData data = new CommunicationDomainResourceData(new AzureLocation("Global")) + { + DomainManagement = DomainManagement.CustomerManaged, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); + CommunicationDomainResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetDomainsResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDomainsResource() + public async Task Get_GetDomainsResource() { // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/domains/get.json // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetDomainsResource() // invoke the operation string domainName = "mydomain.com"; - bool result = await collection.ExistsAsync(domainName); + CommunicationDomainResource result = await collection.GetAsync(domainName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunicationDomainResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDomainsResource() + public async Task GetAll_ListDomainsResourcesByEmailServiceName() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/domains/get.json - // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/domains/listByEmailService.json + // this example is just showing the usage of "Domains_ListByEmailServiceResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetDomainsResource() // get the collection of this CommunicationDomainResource CommunicationDomainResourceCollection collection = emailServiceResource.GetCommunicationDomainResources(); - // invoke the operation - string domainName = "mydomain.com"; - NullableResponse response = await collection.GetIfExistsAsync(domainName); - CommunicationDomainResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CommunicationDomainResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CommunicationDomainResourceData resourceData = result.Data; + CommunicationDomainResourceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDomainsResource() + public async Task Exists_GetDomainsResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/domains/createOrUpdate.json - // this example is just showing the usage of "Domains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/domains/get.json + // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_CreateOrUpdateDomainsResource() // invoke the operation string domainName = "mydomain.com"; - CommunicationDomainResourceData data = new CommunicationDomainResourceData(new AzureLocation("Global")) - { - DomainManagement = DomainManagement.CustomerManaged, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); - CommunicationDomainResource result = lro.Value; + bool result = await collection.ExistsAsync(domainName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommunicationDomainResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDomainsResourcesByEmailServiceName() + public async Task GetIfExists_GetDomainsResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/domains/listByEmailService.json - // this example is just showing the usage of "Domains_ListByEmailServiceResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/domains/get.json + // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListDomainsResourcesByEmailServiceName() // get the collection of this CommunicationDomainResource CommunicationDomainResourceCollection collection = emailServiceResource.GetCommunicationDomainResources(); - // invoke the operation and iterate over the result - await foreach (CommunicationDomainResource item in collection.GetAllAsync()) + // invoke the operation + string domainName = "mydomain.com"; + NullableResponse response = await collection.GetIfExistsAsync(domainName); + CommunicationDomainResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CommunicationDomainResourceData resourceData = item.Data; + CommunicationDomainResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationServiceResource.cs b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationServiceResource.cs index f0793dcd9ed9b..674756e826952 100644 --- a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationServiceResource.cs +++ b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationServiceResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Communication.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Communication.Samples @@ -20,68 +19,40 @@ public partial class Sample_CommunicationServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CheckCommunicationNameAvailability_CheckNameAvailabilityAvailable() - { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/checkNameAvailabilityAvailable.json - // this example is just showing the usage of "CommunicationServices_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "11112222-3333-4444-5555-666677778888"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - CommunicationServiceNameAvailabilityContent content = new CommunicationServiceNameAvailabilityContent() - { - Name = "MyCommunicationService", - ResourceType = new ResourceType("Microsoft.Communication/CommunicationServices"), - }; - CommunicationNameAvailabilityResult result = await subscriptionResource.CheckCommunicationNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckCommunicationNameAvailability_CheckNameAvailabilityUnavailable() + public async Task Get_GetResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/checkNameAvailabilityUnavailable.json - // this example is just showing the usage of "CommunicationServices_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/get.json + // this example is just showing the usage of "CommunicationServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this CommunicationServiceResource created on azure + // for more information of creating CommunicationServiceResource, please refer to the document of CommunicationServiceResource string subscriptionId = "11112222-3333-4444-5555-666677778888"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "MyResourceGroup"; + string communicationServiceName = "MyCommunicationResource"; + ResourceIdentifier communicationServiceResourceId = CommunicationServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communicationServiceName); + CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId); // invoke the operation - CommunicationServiceNameAvailabilityContent content = new CommunicationServiceNameAvailabilityContent() - { - Name = "MyCommunicationService", - ResourceType = new ResourceType("Microsoft.Communication/CommunicationServices"), - }; - CommunicationNameAvailabilityResult result = await subscriptionResource.CheckCommunicationNameAvailabilityAsync(content); + CommunicationServiceResource result = await communicationServiceResource.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunicationServiceResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task LinkNotificationHub_LinkNotificationHub() + public async Task Delete_DeleteResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/linkNotificationHub.json - // this example is just showing the usage of "CommunicationServices_LinkNotificationHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/delete.json + // this example is just showing the usage of "CommunicationServices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,39 +68,7 @@ public async Task LinkNotificationHub_LinkNotificationHub() CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId); // invoke the operation - LinkNotificationHubContent content = new LinkNotificationHubContent(new ResourceIdentifier("/subscriptions/11112222-3333-4444-5555-666677778888/resourceGroups/MyOtherResourceGroup/providers/Microsoft.NotificationHubs/namespaces/MyNamespace/notificationHubs/MyHub"), "Endpoint=sb://MyNamespace.servicebus.windows.net/;SharedAccessKey=abcd1234"); - LinkedNotificationHub result = await communicationServiceResource.LinkNotificationHubAsync(content: content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCommunicationServiceResources_ListBySubscription() - { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/listBySubscription.json - // this example is just showing the usage of "CommunicationServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "11112222-3333-4444-5555-666677778888"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CommunicationServiceResource item in subscriptionResource.GetCommunicationServiceResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommunicationServiceResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + await communicationServiceResource.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } @@ -155,11 +94,11 @@ public async Task Update_UpdateResource() CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId); // invoke the operation - CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch() + CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch { Tags = { -["newTag"] = "newVal", +["newTag"] = "newVal" }, }; CommunicationServiceResource result = await communicationServiceResource.UpdateAsync(patch); @@ -192,18 +131,18 @@ public async Task Update_UpdateResourceToAddSystemAndUserManagedIdentities() CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId); // invoke the operation - CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch() + CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch { Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/user/assigned/resource/id")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/user/assigned/resource/id")] = new UserAssignedIdentity() }, }, Tags = { -["newTag"] = "newVal", +["newTag"] = "newVal" }, }; CommunicationServiceResource result = await communicationServiceResource.UpdateAsync(patch); @@ -236,12 +175,12 @@ public async Task Update_UpdateResourceToAddASystemAssignedManagedIdentity() CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId); // invoke the operation - CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch() + CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch { Identity = new ManagedServiceIdentity("SystemAssigned"), Tags = { -["newTag"] = "newVal", +["newTag"] = "newVal" }, }; CommunicationServiceResource result = await communicationServiceResource.UpdateAsync(patch); @@ -274,18 +213,18 @@ public async Task Update_UpdateResourceToAddAUserAssignedManagedIdentity() CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId); // invoke the operation - CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch() + CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/user/assigned/resource/id")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/user/assigned/resource/id")] = new UserAssignedIdentity() }, }, Tags = { -["newTag"] = "newVal", +["newTag"] = "newVal" }, }; CommunicationServiceResource result = await communicationServiceResource.UpdateAsync(patch); @@ -318,12 +257,12 @@ public async Task Update_UpdateResourceToRemoveIdentity() CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId); // invoke the operation - CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch() + CommunicationServiceResourcePatch patch = new CommunicationServiceResourcePatch { Identity = new ManagedServiceIdentity("None"), Tags = { -["newTag"] = "newVal", +["newTag"] = "newVal" }, }; CommunicationServiceResource result = await communicationServiceResource.UpdateAsync(patch); @@ -337,40 +276,10 @@ public async Task Update_UpdateResourceToRemoveIdentity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetResource() - { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/get.json - // this example is just showing the usage of "CommunicationServices_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CommunicationServiceResource created on azure - // for more information of creating CommunicationServiceResource, please refer to the document of CommunicationServiceResource - string subscriptionId = "11112222-3333-4444-5555-666677778888"; - string resourceGroupName = "MyResourceGroup"; - string communicationServiceName = "MyCommunicationResource"; - ResourceIdentifier communicationServiceResourceId = CommunicationServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, communicationServiceName); - CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId); - - // invoke the operation - CommunicationServiceResource result = await communicationServiceResource.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommunicationServiceResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteResource() + public async Task LinkNotificationHub_LinkNotificationHub() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/delete.json - // this example is just showing the usage of "CommunicationServices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/linkNotificationHub.json + // this example is just showing the usage of "CommunicationServices_LinkNotificationHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -386,9 +295,10 @@ public async Task Delete_DeleteResource() CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId); // invoke the operation - await communicationServiceResource.DeleteAsync(WaitUntil.Completed); + LinkNotificationHubContent content = new LinkNotificationHubContent(new ResourceIdentifier("/subscriptions/11112222-3333-4444-5555-666677778888/resourceGroups/MyOtherResourceGroup/providers/Microsoft.NotificationHubs/namespaces/MyNamespace/notificationHubs/MyHub"), "Endpoint=sb://MyNamespace.servicebus.windows.net/;SharedAccessKey=abcd1234"); + LinkedNotificationHub result = await communicationServiceResource.LinkNotificationHubAsync(content: content); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -438,7 +348,7 @@ public async Task RegenerateKey_RegenerateKey() CommunicationServiceResource communicationServiceResource = client.GetCommunicationServiceResource(communicationServiceResourceId); // invoke the operation - RegenerateCommunicationServiceKeyContent content = new RegenerateCommunicationServiceKeyContent() + RegenerateCommunicationServiceKeyContent content = new RegenerateCommunicationServiceKeyContent { KeyType = CommunicationServiceKeyType.Primary, }; diff --git a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationServiceResourceCollection.cs b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationServiceResourceCollection.cs index 2edad87b73129..9807af839f7bf 100644 --- a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationServiceResourceCollection.cs +++ b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_CommunicationServiceResourceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_CommunicationServiceResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListByResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/listByResourceGroup.json - // this example is just showing the usage of "CommunicationServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/createOrUpdate.json + // this example is just showing the usage of "CommunicationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_ListByResourceGroup() // get the collection of this CommunicationServiceResource CommunicationServiceResourceCollection collection = resourceGroupResource.GetCommunicationServiceResources(); - // invoke the operation and iterate over the result - await foreach (CommunicationServiceResource item in collection.GetAllAsync()) + // invoke the operation + string communicationServiceName = "MyCommunicationResource"; + CommunicationServiceResourceData data = new CommunicationServiceResourceData(new AzureLocation("Global")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommunicationServiceResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DataLocation = "United States", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationServiceName, data); + CommunicationServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunicationServiceResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetResource() + public async Task CreateOrUpdate_CreateOrUpdateResourceWithManagedIdentity() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/get.json - // this example is just showing the usage of "CommunicationServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/createOrUpdateWithSystemAssignedIdentity.json + // this example is just showing the usage of "CommunicationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +79,13 @@ public async Task Get_GetResource() // invoke the operation string communicationServiceName = "MyCommunicationResource"; - CommunicationServiceResource result = await collection.GetAsync(communicationServiceName); + CommunicationServiceResourceData data = new CommunicationServiceResourceData(new AzureLocation("Global")) + { + Identity = new ManagedServiceIdentity("SystemAssigned"), + DataLocation = "United States", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationServiceName, data); + CommunicationServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +96,7 @@ public async Task Get_GetResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetResource() + public async Task Get_GetResource() { // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/get.json // this example is just showing the usage of "CommunicationServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,17 +118,21 @@ public async Task Exists_GetResource() // invoke the operation string communicationServiceName = "MyCommunicationResource"; - bool result = await collection.ExistsAsync(communicationServiceName); + CommunicationServiceResource result = await collection.GetAsync(communicationServiceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunicationServiceResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetResource() + public async Task GetAll_ListByResourceGroup() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/get.json - // this example is just showing the usage of "CommunicationServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/listByResourceGroup.json + // this example is just showing the usage of "CommunicationServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,31 +149,25 @@ public async Task GetIfExists_GetResource() // get the collection of this CommunicationServiceResource CommunicationServiceResourceCollection collection = resourceGroupResource.GetCommunicationServiceResources(); - // invoke the operation - string communicationServiceName = "MyCommunicationResource"; - NullableResponse response = await collection.GetIfExistsAsync(communicationServiceName); - CommunicationServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CommunicationServiceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CommunicationServiceResourceData resourceData = result.Data; + CommunicationServiceResourceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateResource() + public async Task Exists_GetResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/createOrUpdate.json - // this example is just showing the usage of "CommunicationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/get.json + // this example is just showing the usage of "CommunicationServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,26 +186,17 @@ public async Task CreateOrUpdate_CreateOrUpdateResource() // invoke the operation string communicationServiceName = "MyCommunicationResource"; - CommunicationServiceResourceData data = new CommunicationServiceResourceData(new AzureLocation("Global")) - { - DataLocation = "United States", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationServiceName, data); - CommunicationServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(communicationServiceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommunicationServiceResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateResourceWithManagedIdentity() + public async Task GetIfExists_GetResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/createOrUpdateWithSystemAssignedIdentity.json - // this example is just showing the usage of "CommunicationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/get.json + // this example is just showing the usage of "CommunicationServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,19 +215,21 @@ public async Task CreateOrUpdate_CreateOrUpdateResourceWithManagedIdentity() // invoke the operation string communicationServiceName = "MyCommunicationResource"; - CommunicationServiceResourceData data = new CommunicationServiceResourceData(new AzureLocation("Global")) - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - DataLocation = "United States", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationServiceName, data); - CommunicationServiceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(communicationServiceName); + CommunicationServiceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommunicationServiceResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunicationServiceResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_EmailServiceResource.cs b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_EmailServiceResource.cs index dda018247e6dd..87dbe4882e655 100644 --- a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_EmailServiceResource.cs +++ b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_EmailServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Communication.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Communication.Samples @@ -94,11 +93,11 @@ public async Task Update_UpdateEmailServiceResource() EmailServiceResource emailServiceResource = client.GetEmailServiceResource(emailServiceResourceId); // invoke the operation - EmailServiceResourcePatch patch = new EmailServiceResourcePatch() + EmailServiceResourcePatch patch = new EmailServiceResourcePatch { Tags = { -["newTag"] = "newVal", +["newTag"] = "newVal" }, }; ArmOperation lro = await emailServiceResource.UpdateAsync(WaitUntil.Completed, patch); @@ -110,63 +109,5 @@ public async Task Update_UpdateEmailServiceResource() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEmailServiceResources_ListEmailServiceResourcesBySubscription() - { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/listBySubscription.json - // this example is just showing the usage of "EmailServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "11112222-3333-4444-5555-666677778888"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (EmailServiceResource item in subscriptionResource.GetEmailServiceResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EmailServiceResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVerifiedExchangeOnlineDomainsEmailServices_GetVerifiedExchangeOnlineDomains() - { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/getVerifiedExchangeOnlineDomains.json - // this example is just showing the usage of "EmailServices_ListVerifiedExchangeOnlineDomains" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "11112222-3333-4444-5555-666677778888"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (string item in subscriptionResource.GetVerifiedExchangeOnlineDomainsEmailServicesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_EmailServiceResourceCollection.cs b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_EmailServiceResourceCollection.cs index 2d489a284d5c5..2e1b542959914 100644 --- a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_EmailServiceResourceCollection.cs +++ b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_EmailServiceResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EmailServiceResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetEmailServiceResource() + public async Task CreateOrUpdate_CreateOrUpdateEmailServiceResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/get.json - // this example is just showing the usage of "EmailServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/createOrUpdate.json + // this example is just showing the usage of "EmailServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetEmailServiceResource() // invoke the operation string emailServiceName = "MyEmailServiceResource"; - EmailServiceResource result = await collection.GetAsync(emailServiceName); + EmailServiceResourceData data = new EmailServiceResourceData(new AzureLocation("Global")) + { + DataLocation = "United States", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, emailServiceName, data); + EmailServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetEmailServiceResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetEmailServiceResource() + public async Task Get_GetEmailServiceResource() { // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/get.json // this example is just showing the usage of "EmailServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +78,21 @@ public async Task Exists_GetEmailServiceResource() // invoke the operation string emailServiceName = "MyEmailServiceResource"; - bool result = await collection.ExistsAsync(emailServiceName); + EmailServiceResource result = await collection.GetAsync(emailServiceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EmailServiceResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetEmailServiceResource() + public async Task GetAll_ListEmailServiceResourcesByResourceGroup() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/get.json - // this example is just showing the usage of "EmailServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/listByResourceGroup.json + // this example is just showing the usage of "EmailServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +109,25 @@ public async Task GetIfExists_GetEmailServiceResource() // get the collection of this EmailServiceResource EmailServiceResourceCollection collection = resourceGroupResource.GetEmailServiceResources(); - // invoke the operation - string emailServiceName = "MyEmailServiceResource"; - NullableResponse response = await collection.GetIfExistsAsync(emailServiceName); - EmailServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EmailServiceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EmailServiceResourceData resourceData = result.Data; + EmailServiceResourceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateEmailServiceResource() + public async Task Exists_GetEmailServiceResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/createOrUpdate.json - // this example is just showing the usage of "EmailServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/get.json + // this example is just showing the usage of "EmailServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,26 +146,17 @@ public async Task CreateOrUpdate_CreateOrUpdateEmailServiceResource() // invoke the operation string emailServiceName = "MyEmailServiceResource"; - EmailServiceResourceData data = new EmailServiceResourceData(new AzureLocation("Global")) - { - DataLocation = "United States", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, emailServiceName, data); - EmailServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(emailServiceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EmailServiceResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEmailServiceResourcesByResourceGroup() + public async Task GetIfExists_GetEmailServiceResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/listByResourceGroup.json - // this example is just showing the usage of "EmailServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/get.json + // this example is just showing the usage of "EmailServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_ListEmailServiceResourcesByResourceGroup() // get the collection of this EmailServiceResource EmailServiceResourceCollection collection = resourceGroupResource.GetEmailServiceResources(); - // invoke the operation and iterate over the result - await foreach (EmailServiceResource item in collection.GetAllAsync()) + // invoke the operation + string emailServiceName = "MyEmailServiceResource"; + NullableResponse response = await collection.GetIfExistsAsync(emailServiceName); + EmailServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EmailServiceResourceData resourceData = item.Data; + EmailServiceResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SenderUsernameResource.cs b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SenderUsernameResource.cs index c43ef6b3c02c0..405aaa8c1833c 100644 --- a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SenderUsernameResource.cs +++ b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SenderUsernameResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetSenderUsernamesResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateSenderUsernamesResource() + public async Task Delete_DeleteSenderUsernamesResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/createOrUpdate.json - // this example is just showing the usage of "SenderUsernames_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/delete.json + // this example is just showing the usage of "SenderUsernames_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,35 +62,25 @@ public async Task Update_CreateOrUpdateSenderUsernamesResource() // this example assumes you already have this SenderUsernameResource created on azure // for more information of creating SenderUsernameResource, please refer to the document of SenderUsernameResource string subscriptionId = "11112222-3333-4444-5555-666677778888"; - string resourceGroupName = "contosoResourceGroup"; - string emailServiceName = "contosoEmailService"; - string domainName = "contoso.com"; + string resourceGroupName = "MyResourceGroup"; + string emailServiceName = "MyEmailServiceResource"; + string domainName = "mydomain.com"; string senderUsername = "contosoNewsAlerts"; ResourceIdentifier senderUsernameResourceId = SenderUsernameResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, emailServiceName, domainName, senderUsername); SenderUsernameResource senderUsernameResource = client.GetSenderUsernameResource(senderUsernameResourceId); // invoke the operation - SenderUsernameResourceData data = new SenderUsernameResourceData() - { - Username = "contosoNewsAlerts", - DisplayName = "Contoso News Alerts", - }; - ArmOperation lro = await senderUsernameResource.UpdateAsync(WaitUntil.Completed, data); - SenderUsernameResource result = lro.Value; + await senderUsernameResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SenderUsernameResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSenderUsernamesResource() + public async Task Update_CreateOrUpdateSenderUsernamesResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/delete.json - // this example is just showing the usage of "SenderUsernames_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/createOrUpdate.json + // this example is just showing the usage of "SenderUsernames_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,17 +90,27 @@ public async Task Delete_DeleteSenderUsernamesResource() // this example assumes you already have this SenderUsernameResource created on azure // for more information of creating SenderUsernameResource, please refer to the document of SenderUsernameResource string subscriptionId = "11112222-3333-4444-5555-666677778888"; - string resourceGroupName = "MyResourceGroup"; - string emailServiceName = "MyEmailServiceResource"; - string domainName = "mydomain.com"; + string resourceGroupName = "contosoResourceGroup"; + string emailServiceName = "contosoEmailService"; + string domainName = "contoso.com"; string senderUsername = "contosoNewsAlerts"; ResourceIdentifier senderUsernameResourceId = SenderUsernameResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, emailServiceName, domainName, senderUsername); SenderUsernameResource senderUsernameResource = client.GetSenderUsernameResource(senderUsernameResourceId); // invoke the operation - await senderUsernameResource.DeleteAsync(WaitUntil.Completed); + SenderUsernameResourceData data = new SenderUsernameResourceData + { + Username = "contosoNewsAlerts", + DisplayName = "Contoso News Alerts", + }; + ArmOperation lro = await senderUsernameResource.UpdateAsync(WaitUntil.Completed, data); + SenderUsernameResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SenderUsernameResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SenderUsernameResourceCollection.cs b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SenderUsernameResourceCollection.cs index 17b720fbd2819..5784386d13a4d 100644 --- a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SenderUsernameResourceCollection.cs +++ b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SenderUsernameResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SenderUsernameResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSenderUsernamesResource() + public async Task CreateOrUpdate_CreateOrUpdateSenderUsernamesResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/listByDomain.json - // this example is just showing the usage of "SenderUsernames_ListByDomains" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/createOrUpdate.json + // this example is just showing the usage of "SenderUsernames_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_GetSenderUsernamesResource() // get the collection of this SenderUsernameResource SenderUsernameResourceCollection collection = communicationDomainResource.GetSenderUsernameResources(); - // invoke the operation and iterate over the result - await foreach (SenderUsernameResource item in collection.GetAllAsync()) + // invoke the operation + string senderUsername = "contosoNewsAlerts"; + SenderUsernameResourceData data = new SenderUsernameResourceData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SenderUsernameResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Username = "contosoNewsAlerts", + DisplayName = "Contoso News Alerts", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, senderUsername, data); + SenderUsernameResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SenderUsernameResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +93,10 @@ public async Task Get_GetSenderUsernamesResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSenderUsernamesResource() + public async Task GetAll_GetSenderUsernamesResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/get.json - // this example is just showing the usage of "SenderUsernames_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/listByDomain.json + // this example is just showing the usage of "SenderUsernames_ListByDomains" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +115,22 @@ public async Task Exists_GetSenderUsernamesResource() // get the collection of this SenderUsernameResource SenderUsernameResourceCollection collection = communicationDomainResource.GetSenderUsernameResources(); - // invoke the operation - string senderUsername = "contosoNewsAlerts"; - bool result = await collection.ExistsAsync(senderUsername); + // invoke the operation and iterate over the result + await foreach (SenderUsernameResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SenderUsernameResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSenderUsernamesResource() + public async Task Exists_GetSenderUsernamesResource() { // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/get.json // this example is just showing the usage of "SenderUsernames_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +154,17 @@ public async Task GetIfExists_GetSenderUsernamesResource() // invoke the operation string senderUsername = "contosoNewsAlerts"; - NullableResponse response = await collection.GetIfExistsAsync(senderUsername); - SenderUsernameResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(senderUsername); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SenderUsernameResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateSenderUsernamesResource() + public async Task GetIfExists_GetSenderUsernamesResource() { - // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/createOrUpdate.json - // this example is just showing the usage of "SenderUsernames_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/senderUsernames/get.json + // this example is just showing the usage of "SenderUsernames_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,19 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateSenderUsernamesResource() // invoke the operation string senderUsername = "contosoNewsAlerts"; - SenderUsernameResourceData data = new SenderUsernameResourceData() - { - Username = "contosoNewsAlerts", - DisplayName = "Contoso News Alerts", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, senderUsername, data); - SenderUsernameResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(senderUsername); + SenderUsernameResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SenderUsernameResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SenderUsernameResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..946735c37c80f --- /dev/null +++ b/sdk/communication/Azure.ResourceManager.Communication/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,167 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Communication.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Communication.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckCommunicationNameAvailability_CheckNameAvailabilityAvailable() + { + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/checkNameAvailabilityAvailable.json + // this example is just showing the usage of "CommunicationServices_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "11112222-3333-4444-5555-666677778888"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + CommunicationServiceNameAvailabilityContent content = new CommunicationServiceNameAvailabilityContent + { + Name = "MyCommunicationService", + ResourceType = new ResourceType("Microsoft.Communication/CommunicationServices"), + }; + CommunicationNameAvailabilityResult result = await subscriptionResource.CheckCommunicationNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckCommunicationNameAvailability_CheckNameAvailabilityUnavailable() + { + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/checkNameAvailabilityUnavailable.json + // this example is just showing the usage of "CommunicationServices_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "11112222-3333-4444-5555-666677778888"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + CommunicationServiceNameAvailabilityContent content = new CommunicationServiceNameAvailabilityContent + { + Name = "MyCommunicationService", + ResourceType = new ResourceType("Microsoft.Communication/CommunicationServices"), + }; + CommunicationNameAvailabilityResult result = await subscriptionResource.CheckCommunicationNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCommunicationServiceResources_ListBySubscription() + { + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/communicationServices/listBySubscription.json + // this example is just showing the usage of "CommunicationServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "11112222-3333-4444-5555-666677778888"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CommunicationServiceResource item in subscriptionResource.GetCommunicationServiceResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunicationServiceResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEmailServiceResources_ListEmailServiceResourcesBySubscription() + { + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/listBySubscription.json + // this example is just showing the usage of "EmailServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "11112222-3333-4444-5555-666677778888"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EmailServiceResource item in subscriptionResource.GetEmailServiceResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EmailServiceResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVerifiedExchangeOnlineDomainsEmailServices_GetVerifiedExchangeOnlineDomains() + { + // Generated from example definition: specification/communication/resource-manager/Microsoft.Communication/stable/2023-04-01/examples/emailServices/getVerifiedExchangeOnlineDomains.json + // this example is just showing the usage of "EmailServices_ListVerifiedExchangeOnlineDomains" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "11112222-3333-4444-5555-666677778888"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (string item in subscriptionResource.GetVerifiedExchangeOnlineDomainsEmailServicesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_AvailabilitySetCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_AvailabilitySetCollection.cs index bb67c2bcffe31..d510391d86361 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_AvailabilitySetCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_AvailabilitySetCollection.cs @@ -129,9 +129,9 @@ public async Task Get_AvailabilitySetGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AvailabilitySetGetMaximumSetGen() + public async Task Get_AvailabilitySetGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MaximumSet_Gen.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MinimumSet_Gen.json // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -150,18 +150,22 @@ public async Task Exists_AvailabilitySetGetMaximumSetGen() AvailabilitySetCollection collection = resourceGroupResource.GetAvailabilitySets(); // invoke the operation - string availabilitySetName = "aaaaaaaaaaaa"; - bool result = await collection.ExistsAsync(availabilitySetName); + string availabilitySetName = "aaaaaaaaaaaaaaaaaaaa"; + AvailabilitySetResource result = await collection.GetAsync(availabilitySetName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvailabilitySetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AvailabilitySetGetMaximumSetGen() + public async Task GetAll_AvailabilitySetListMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MaximumSet_Gen.json - // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_List_MaximumSet_Gen.json + // this example is just showing the usage of "AvailabilitySets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,31 +182,25 @@ public async Task GetIfExists_AvailabilitySetGetMaximumSetGen() // get the collection of this AvailabilitySetResource AvailabilitySetCollection collection = resourceGroupResource.GetAvailabilitySets(); - // invoke the operation - string availabilitySetName = "aaaaaaaaaaaa"; - NullableResponse response = await collection.GetIfExistsAsync(availabilitySetName); - AvailabilitySetResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AvailabilitySetResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AvailabilitySetData resourceData = result.Data; + AvailabilitySetData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AvailabilitySetGetMinimumSetGen() + public async Task GetAll_AvailabilitySetListMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MinimumSet_Gen.json - // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_List_MinimumSet_Gen.json + // this example is just showing the usage of "AvailabilitySets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -219,22 +217,24 @@ public async Task Get_AvailabilitySetGetMinimumSetGen() // get the collection of this AvailabilitySetResource AvailabilitySetCollection collection = resourceGroupResource.GetAvailabilitySets(); - // invoke the operation - string availabilitySetName = "aaaaaaaaaaaaaaaaaaaa"; - AvailabilitySetResource result = await collection.GetAsync(availabilitySetName); + // invoke the operation and iterate over the result + await foreach (AvailabilitySetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvailabilitySetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvailabilitySetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AvailabilitySetGetMinimumSetGen() + public async Task Exists_AvailabilitySetGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MinimumSet_Gen.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MaximumSet_Gen.json // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -253,7 +253,7 @@ public async Task Exists_AvailabilitySetGetMinimumSetGen() AvailabilitySetCollection collection = resourceGroupResource.GetAvailabilitySets(); // invoke the operation - string availabilitySetName = "aaaaaaaaaaaaaaaaaaaa"; + string availabilitySetName = "aaaaaaaaaaaa"; bool result = await collection.ExistsAsync(availabilitySetName); Console.WriteLine($"Succeeded: {result}"); @@ -261,7 +261,7 @@ public async Task Exists_AvailabilitySetGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AvailabilitySetGetMinimumSetGen() + public async Task Exists_AvailabilitySetGetMinimumSetGen() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MinimumSet_Gen.json // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. @@ -283,29 +283,17 @@ public async Task GetIfExists_AvailabilitySetGetMinimumSetGen() // invoke the operation string availabilitySetName = "aaaaaaaaaaaaaaaaaaaa"; - NullableResponse response = await collection.GetIfExistsAsync(availabilitySetName); - AvailabilitySetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(availabilitySetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvailabilitySetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AvailabilitySetListMaximumSetGen() + public async Task GetIfExists_AvailabilitySetGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_List_MaximumSet_Gen.json - // this example is just showing the usage of "AvailabilitySets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -322,25 +310,31 @@ public async Task GetAll_AvailabilitySetListMaximumSetGen() // get the collection of this AvailabilitySetResource AvailabilitySetCollection collection = resourceGroupResource.GetAvailabilitySets(); - // invoke the operation and iterate over the result - await foreach (AvailabilitySetResource item in collection.GetAllAsync()) + // invoke the operation + string availabilitySetName = "aaaaaaaaaaaa"; + NullableResponse response = await collection.GetIfExistsAsync(availabilitySetName); + AvailabilitySetResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AvailabilitySetData resourceData = item.Data; + AvailabilitySetData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AvailabilitySetListMinimumSetGen() + public async Task GetIfExists_AvailabilitySetGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_List_MinimumSet_Gen.json - // this example is just showing the usage of "AvailabilitySets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MinimumSet_Gen.json + // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -357,17 +351,23 @@ public async Task GetAll_AvailabilitySetListMinimumSetGen() // get the collection of this AvailabilitySetResource AvailabilitySetCollection collection = resourceGroupResource.GetAvailabilitySets(); - // invoke the operation and iterate over the result - await foreach (AvailabilitySetResource item in collection.GetAllAsync()) + // invoke the operation + string availabilitySetName = "aaaaaaaaaaaaaaaaaaaa"; + NullableResponse response = await collection.GetIfExistsAsync(availabilitySetName); + AvailabilitySetResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AvailabilitySetData resourceData = item.Data; + AvailabilitySetData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_AvailabilitySetResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_AvailabilitySetResource.cs index 1c3c38cb6e157..816502b62349a 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_AvailabilitySetResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_AvailabilitySetResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using NUnit.Framework; @@ -20,10 +19,10 @@ public partial class Sample_AvailabilitySetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AvailabilitySetUpdateMaximumSetGen() + public async Task Get_AvailabilitySetGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Update_MaximumSet_Gen.json - // this example is just showing the usage of "AvailabilitySets_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,35 +33,12 @@ public async Task Update_AvailabilitySetUpdateMaximumSetGen() // for more information of creating AvailabilitySetResource, please refer to the document of AvailabilitySetResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string availabilitySetName = "aaaaaaaaaaaaaaaaaaa"; + string availabilitySetName = "aaaaaaaaaaaa"; ResourceIdentifier availabilitySetResourceId = AvailabilitySetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, availabilitySetName); AvailabilitySetResource availabilitySet = client.GetAvailabilitySetResource(availabilitySetResourceId); // invoke the operation - AvailabilitySetPatch patch = new AvailabilitySetPatch() - { - Sku = new ComputeSku() - { - Name = "DSv3-Type1", - Tier = "aaa", - Capacity = 7L, - }, - PlatformUpdateDomainCount = 20, - PlatformFaultDomainCount = 2, - VirtualMachines = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, - ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), - Tags = -{ -["key2574"] = "aaaaaaaa", -}, - }; - AvailabilitySetResource result = await availabilitySet.UpdateAsync(patch); + AvailabilitySetResource result = await availabilitySet.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -73,10 +49,10 @@ public async Task Update_AvailabilitySetUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AvailabilitySetUpdateMinimumSetGen() + public async Task Get_AvailabilitySetGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Update_MinimumSet_Gen.json - // this example is just showing the usage of "AvailabilitySets_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MinimumSet_Gen.json + // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,8 +68,7 @@ public async Task Update_AvailabilitySetUpdateMinimumSetGen() AvailabilitySetResource availabilitySet = client.GetAvailabilitySetResource(availabilitySetResourceId); // invoke the operation - AvailabilitySetPatch patch = new AvailabilitySetPatch(); - AvailabilitySetResource result = await availabilitySet.UpdateAsync(patch); + AvailabilitySetResource result = await availabilitySet.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -156,10 +131,10 @@ public async Task Delete_AvailabilitySetDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AvailabilitySetGetMaximumSetGen() + public async Task Update_AvailabilitySetUpdateMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MaximumSet_Gen.json - // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Update_MaximumSet_Gen.json + // this example is just showing the usage of "AvailabilitySets_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -170,12 +145,32 @@ public async Task Get_AvailabilitySetGetMaximumSetGen() // for more information of creating AvailabilitySetResource, please refer to the document of AvailabilitySetResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string availabilitySetName = "aaaaaaaaaaaa"; + string availabilitySetName = "aaaaaaaaaaaaaaaaaaa"; ResourceIdentifier availabilitySetResourceId = AvailabilitySetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, availabilitySetName); AvailabilitySetResource availabilitySet = client.GetAvailabilitySetResource(availabilitySetResourceId); // invoke the operation - AvailabilitySetResource result = await availabilitySet.GetAsync(); + AvailabilitySetPatch patch = new AvailabilitySetPatch + { + Sku = new ComputeSku + { + Name = "DSv3-Type1", + Tier = "aaa", + Capacity = 7L, + }, + PlatformUpdateDomainCount = 20, + PlatformFaultDomainCount = 2, + VirtualMachines = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), +}}, + ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), + Tags = +{ +["key2574"] = "aaaaaaaa" +}, + }; + AvailabilitySetResource result = await availabilitySet.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -186,10 +181,10 @@ public async Task Get_AvailabilitySetGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AvailabilitySetGetMinimumSetGen() + public async Task Update_AvailabilitySetUpdateMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Get_MinimumSet_Gen.json - // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_Update_MinimumSet_Gen.json + // this example is just showing the usage of "AvailabilitySets_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -205,7 +200,8 @@ public async Task Get_AvailabilitySetGetMinimumSetGen() AvailabilitySetResource availabilitySet = client.GetAvailabilitySetResource(availabilitySetResourceId); // invoke the operation - AvailabilitySetResource result = await availabilitySet.GetAsync(); + AvailabilitySetPatch patch = new AvailabilitySetPatch(); + AvailabilitySetResource result = await availabilitySet.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -214,38 +210,6 @@ public async Task Get_AvailabilitySetGetMinimumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAvailabilitySets_ListAvailabilitySetsInASubscription() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_ListBySubscription.json - // this example is just showing the usage of "AvailabilitySets_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscriptionId}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string expand = "virtualMachines\\$ref"; - await foreach (AvailabilitySetResource item in subscriptionResource.GetAvailabilitySetsAsync(expand: expand)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvailabilitySetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetAvailableSizes_AvailabilitySetListAvailableSizesMaximumSetGen() diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationCollection.cs index 5a3fa0d07b280..04f296d5eb7ce 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationCollection.cs @@ -41,19 +41,16 @@ public async Task CreateOrUpdate_CreateOrUpdateACapacityReservation() // invoke the operation string capacityReservationName = "myCapacityReservation"; - CapacityReservationData data = new CapacityReservationData(new AzureLocation("westus"), new ComputeSku() + CapacityReservationData data = new CapacityReservationData(new AzureLocation("westus"), new ComputeSku { Name = "Standard_DS1_v2", Capacity = 4L, }) { - Zones = -{ -"1" -}, + Zones = { "1" }, Tags = { -["department"] = "HR", +["department"] = "HR" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, capacityReservationName, data); @@ -103,10 +100,10 @@ public async Task Get_GetACapacityReservation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACapacityReservation() + public async Task GetAll_ListCapacityReservationsInReservationGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Get.json - // this example is just showing the usage of "CapacityReservations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_ListByReservationGroup.json + // this example is just showing the usage of "CapacityReservations_ListByCapacityReservationGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,7 +112,7 @@ public async Task Exists_GetACapacityReservation() // this example assumes you already have this CapacityReservationGroupResource created on azure // for more information of creating CapacityReservationGroupResource, please refer to the document of CapacityReservationGroupResource - string subscriptionId = "{subscriptionId}"; + string subscriptionId = "{subscription-id}"; string resourceGroupName = "myResourceGroup"; string capacityReservationGroupName = "myCapacityReservationGroup"; ResourceIdentifier capacityReservationGroupResourceId = CapacityReservationGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName); @@ -124,17 +121,22 @@ public async Task Exists_GetACapacityReservation() // get the collection of this CapacityReservationResource CapacityReservationCollection collection = capacityReservationGroup.GetCapacityReservations(); - // invoke the operation - string capacityReservationName = "myCapacityReservation"; - CapacityReservationInstanceViewType? expand = CapacityReservationInstanceViewType.InstanceView; - bool result = await collection.ExistsAsync(capacityReservationName, expand: expand); + // invoke the operation and iterate over the result + await foreach (CapacityReservationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CapacityReservationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACapacityReservation() + public async Task Exists_GetACapacityReservation() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Get.json // this example is just showing the usage of "CapacityReservations_Get" operation, for the dependent resources, they will have to be created separately. @@ -158,29 +160,17 @@ public async Task GetIfExists_GetACapacityReservation() // invoke the operation string capacityReservationName = "myCapacityReservation"; CapacityReservationInstanceViewType? expand = CapacityReservationInstanceViewType.InstanceView; - NullableResponse response = await collection.GetIfExistsAsync(capacityReservationName, expand: expand); - CapacityReservationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(capacityReservationName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CapacityReservationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCapacityReservationsInReservationGroup() + public async Task GetIfExists_GetACapacityReservation() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_ListByReservationGroup.json - // this example is just showing the usage of "CapacityReservations_ListByCapacityReservationGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Get.json + // this example is just showing the usage of "CapacityReservations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,7 +179,7 @@ public async Task GetAll_ListCapacityReservationsInReservationGroup() // this example assumes you already have this CapacityReservationGroupResource created on azure // for more information of creating CapacityReservationGroupResource, please refer to the document of CapacityReservationGroupResource - string subscriptionId = "{subscription-id}"; + string subscriptionId = "{subscriptionId}"; string resourceGroupName = "myResourceGroup"; string capacityReservationGroupName = "myCapacityReservationGroup"; ResourceIdentifier capacityReservationGroupResourceId = CapacityReservationGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName); @@ -198,17 +188,24 @@ public async Task GetAll_ListCapacityReservationsInReservationGroup() // get the collection of this CapacityReservationResource CapacityReservationCollection collection = capacityReservationGroup.GetCapacityReservations(); - // invoke the operation and iterate over the result - await foreach (CapacityReservationResource item in collection.GetAllAsync()) + // invoke the operation + string capacityReservationName = "myCapacityReservation"; + CapacityReservationInstanceViewType? expand = CapacityReservationInstanceViewType.InstanceView; + NullableResponse response = await collection.GetIfExistsAsync(capacityReservationName, expand: expand); + CapacityReservationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CapacityReservationData resourceData = item.Data; + CapacityReservationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationGroupCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationGroupCollection.cs index a8659d9fc8486..e58fc7891b5fb 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationGroupCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationGroupCollection.cs @@ -44,23 +44,17 @@ public async Task CreateOrUpdate_CreateOrUpdateACapacityReservationGroup() string capacityReservationGroupName = "myCapacityReservationGroup"; CapacityReservationGroupData data = new CapacityReservationGroupData(new AzureLocation("westus")) { - Zones = -{ -"1","2" -}, - SharingSubscriptionIds = -{ -new WritableSubResource() + Zones = { "1", "2" }, + SharingSubscriptionIds = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscription-id1}"), -},new WritableSubResource() +}, new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscription-id2}"), -} -}, +}}, Tags = { -["department"] = "finance", +["department"] = "finance" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, capacityReservationGroupName, data); @@ -109,10 +103,10 @@ public async Task Get_GetACapacityReservationGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACapacityReservationGroup() + public async Task GetAll_ListCapacityReservationGroupsInResourceGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_Get.json - // this example is just showing the usage of "CapacityReservationGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_ListByResourceGroup.json + // this example is just showing the usage of "CapacityReservationGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,7 +115,7 @@ public async Task Exists_GetACapacityReservationGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscriptionId}"; + string subscriptionId = "{subscription-id}"; string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -129,17 +123,23 @@ public async Task Exists_GetACapacityReservationGroup() // get the collection of this CapacityReservationGroupResource CapacityReservationGroupCollection collection = resourceGroupResource.GetCapacityReservationGroups(); - // invoke the operation - string capacityReservationGroupName = "myCapacityReservationGroup"; - CapacityReservationGroupInstanceViewType? expand = CapacityReservationGroupInstanceViewType.InstanceView; - bool result = await collection.ExistsAsync(capacityReservationGroupName, expand: expand); + // invoke the operation and iterate over the result + CapacityReservationGroupGetExpand? expand = CapacityReservationGroupGetExpand.VirtualMachinesRef; + await foreach (CapacityReservationGroupResource item in collection.GetAllAsync(expand: expand)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CapacityReservationGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACapacityReservationGroup() + public async Task Exists_GetACapacityReservationGroup() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_Get.json // this example is just showing the usage of "CapacityReservationGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -162,29 +162,17 @@ public async Task GetIfExists_GetACapacityReservationGroup() // invoke the operation string capacityReservationGroupName = "myCapacityReservationGroup"; CapacityReservationGroupInstanceViewType? expand = CapacityReservationGroupInstanceViewType.InstanceView; - NullableResponse response = await collection.GetIfExistsAsync(capacityReservationGroupName, expand: expand); - CapacityReservationGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(capacityReservationGroupName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CapacityReservationGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCapacityReservationGroupsInResourceGroup() + public async Task GetIfExists_GetACapacityReservationGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_ListByResourceGroup.json - // this example is just showing the usage of "CapacityReservationGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_Get.json + // this example is just showing the usage of "CapacityReservationGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,7 +181,7 @@ public async Task GetAll_ListCapacityReservationGroupsInResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; + string subscriptionId = "{subscriptionId}"; string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -201,18 +189,24 @@ public async Task GetAll_ListCapacityReservationGroupsInResourceGroup() // get the collection of this CapacityReservationGroupResource CapacityReservationGroupCollection collection = resourceGroupResource.GetCapacityReservationGroups(); - // invoke the operation and iterate over the result - CapacityReservationGroupGetExpand? expand = CapacityReservationGroupGetExpand.VirtualMachinesRef; - await foreach (CapacityReservationGroupResource item in collection.GetAllAsync(expand: expand)) + // invoke the operation + string capacityReservationGroupName = "myCapacityReservationGroup"; + CapacityReservationGroupInstanceViewType? expand = CapacityReservationGroupInstanceViewType.InstanceView; + NullableResponse response = await collection.GetIfExistsAsync(capacityReservationGroupName, expand: expand); + CapacityReservationGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CapacityReservationGroupData resourceData = item.Data; + CapacityReservationGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationGroupResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationGroupResource.cs index d0ebb568170a3..aa21f5b2cdbc1 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationGroupResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationGroupResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -19,47 +18,10 @@ public partial class Sample_CapacityReservationGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CapacityReservationGroupUpdateMaximumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_Update_MaximumSet_Gen.json - // this example is just showing the usage of "CapacityReservationGroups_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CapacityReservationGroupResource created on azure - // for more information of creating CapacityReservationGroupResource, please refer to the document of CapacityReservationGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string capacityReservationGroupName = "aaaaaaaaaaaaaaaaaaaaaa"; - ResourceIdentifier capacityReservationGroupResourceId = CapacityReservationGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName); - CapacityReservationGroupResource capacityReservationGroup = client.GetCapacityReservationGroupResource(capacityReservationGroupResourceId); - - // invoke the operation - CapacityReservationGroupPatch patch = new CapacityReservationGroupPatch() - { - Tags = -{ -["key5355"] = "aaa", -}, - }; - CapacityReservationGroupResource result = await capacityReservationGroup.UpdateAsync(patch); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CapacityReservationGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_CapacityReservationGroupUpdateMinimumSetGen() + public async Task Get_GetACapacityReservationGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_Update_MinimumSet_Gen.json - // this example is just showing the usage of "CapacityReservationGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_Get.json + // this example is just showing the usage of "CapacityReservationGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,15 +30,15 @@ public async Task Update_CapacityReservationGroupUpdateMinimumSetGen() // this example assumes you already have this CapacityReservationGroupResource created on azure // for more information of creating CapacityReservationGroupResource, please refer to the document of CapacityReservationGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string capacityReservationGroupName = "aaaaaaaaaaaaaaaaaaaaaa"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; + string capacityReservationGroupName = "myCapacityReservationGroup"; ResourceIdentifier capacityReservationGroupResourceId = CapacityReservationGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName); CapacityReservationGroupResource capacityReservationGroup = client.GetCapacityReservationGroupResource(capacityReservationGroupResourceId); // invoke the operation - CapacityReservationGroupPatch patch = new CapacityReservationGroupPatch(); - CapacityReservationGroupResource result = await capacityReservationGroup.UpdateAsync(patch); + CapacityReservationGroupInstanceViewType? expand = CapacityReservationGroupInstanceViewType.InstanceView; + CapacityReservationGroupResource result = await capacityReservationGroup.GetAsync(expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -139,10 +101,10 @@ public async Task Delete_CapacityReservationGroupDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACapacityReservationGroup() + public async Task Update_CapacityReservationGroupUpdateMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_Get.json - // this example is just showing the usage of "CapacityReservationGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_Update_MaximumSet_Gen.json + // this example is just showing the usage of "CapacityReservationGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,15 +113,21 @@ public async Task Get_GetACapacityReservationGroup() // this example assumes you already have this CapacityReservationGroupResource created on azure // for more information of creating CapacityReservationGroupResource, please refer to the document of CapacityReservationGroupResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; - string capacityReservationGroupName = "myCapacityReservationGroup"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string capacityReservationGroupName = "aaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier capacityReservationGroupResourceId = CapacityReservationGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName); CapacityReservationGroupResource capacityReservationGroup = client.GetCapacityReservationGroupResource(capacityReservationGroupResourceId); // invoke the operation - CapacityReservationGroupInstanceViewType? expand = CapacityReservationGroupInstanceViewType.InstanceView; - CapacityReservationGroupResource result = await capacityReservationGroup.GetAsync(expand: expand); + CapacityReservationGroupPatch patch = new CapacityReservationGroupPatch + { + Tags = +{ +["key5355"] = "aaa" +}, + }; + CapacityReservationGroupResource result = await capacityReservationGroup.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -170,66 +138,33 @@ public async Task Get_GetACapacityReservationGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetCapacityReservationGroups_ListCapacityReservationGroupsInSubscription() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_ListBySubscription.json - // this example is just showing the usage of "CapacityReservationGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - CapacityReservationGroupGetExpand? expand = CapacityReservationGroupGetExpand.VirtualMachinesRef; - await foreach (CapacityReservationGroupResource item in subscriptionResource.GetCapacityReservationGroupsAsync(expand: expand)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CapacityReservationGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCapacityReservationGroups_ListCapacityReservationGroupsWithResourceIdsOnlyInSubscription() + public async Task Update_CapacityReservationGroupUpdateMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_ListBySubscriptionWithResourceIdsQuery.json - // this example is just showing the usage of "CapacityReservationGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_Update_MinimumSet_Gen.json + // this example is just showing the usage of "CapacityReservationGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this CapacityReservationGroupResource created on azure + // for more information of creating CapacityReservationGroupResource, please refer to the document of CapacityReservationGroupResource string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rgcompute"; + string capacityReservationGroupName = "aaaaaaaaaaaaaaaaaaaaaa"; + ResourceIdentifier capacityReservationGroupResourceId = CapacityReservationGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName); + CapacityReservationGroupResource capacityReservationGroup = client.GetCapacityReservationGroupResource(capacityReservationGroupResourceId); - // invoke the operation and iterate over the result - ResourceIdOptionsForGetCapacityReservationGroup? resourceIdsOnly = ResourceIdOptionsForGetCapacityReservationGroup.All; - await foreach (CapacityReservationGroupResource item in subscriptionResource.GetCapacityReservationGroupsAsync(resourceIdsOnly: resourceIdsOnly)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CapacityReservationGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + CapacityReservationGroupPatch patch = new CapacityReservationGroupPatch(); + CapacityReservationGroupResource result = await capacityReservationGroup.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CapacityReservationGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationResource.cs index 2f6e302aa9df5..85fbd0407e02a 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CapacityReservationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_CapacityReservationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CapacityReservationUpdateMaximumSetGen() + public async Task Get_GetACapacityReservation() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Update_MaximumSet_Gen.json - // this example is just showing the usage of "CapacityReservations_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Get.json + // this example is just showing the usage of "CapacityReservations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,29 +30,16 @@ public async Task Update_CapacityReservationUpdateMaximumSetGen() // this example assumes you already have this CapacityReservationResource created on azure // for more information of creating CapacityReservationResource, please refer to the document of CapacityReservationResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string capacityReservationGroupName = "aaaaaaaaaa"; - string capacityReservationName = "aaaaaaaaaaaaaaaaaaa"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; + string capacityReservationGroupName = "myCapacityReservationGroup"; + string capacityReservationName = "myCapacityReservation"; ResourceIdentifier capacityReservationResourceId = CapacityReservationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName, capacityReservationName); CapacityReservationResource capacityReservation = client.GetCapacityReservationResource(capacityReservationResourceId); // invoke the operation - CapacityReservationPatch patch = new CapacityReservationPatch() - { - Sku = new ComputeSku() - { - Name = "Standard_DS1_v2", - Tier = "aaa", - Capacity = 7L, - }, - Tags = -{ -["key4974"] = "aaaaaaaaaaaaaaaa", -}, - }; - ArmOperation lro = await capacityReservation.UpdateAsync(WaitUntil.Completed, patch); - CapacityReservationResource result = lro.Value; + CapacityReservationInstanceViewType? expand = CapacityReservationInstanceViewType.InstanceView; + CapacityReservationResource result = await capacityReservation.GetAsync(expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -63,10 +50,10 @@ public async Task Update_CapacityReservationUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CapacityReservationUpdateMinimumSetGen() + public async Task Delete_CapacityReservationDeleteMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Update_MinimumSet_Gen.json - // this example is just showing the usage of "CapacityReservations_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "CapacityReservations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,28 +64,22 @@ public async Task Update_CapacityReservationUpdateMinimumSetGen() // for more information of creating CapacityReservationResource, please refer to the document of CapacityReservationResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string capacityReservationGroupName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; - string capacityReservationName = "aaa"; + string capacityReservationGroupName = "aaaaaaaaaaa"; + string capacityReservationName = "aaaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier capacityReservationResourceId = CapacityReservationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName, capacityReservationName); CapacityReservationResource capacityReservation = client.GetCapacityReservationResource(capacityReservationResourceId); // invoke the operation - CapacityReservationPatch patch = new CapacityReservationPatch(); - ArmOperation lro = await capacityReservation.UpdateAsync(WaitUntil.Completed, patch); - CapacityReservationResource result = lro.Value; + await capacityReservation.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CapacityReservationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CapacityReservationDeleteMaximumSetGen() + public async Task Delete_CapacityReservationDeleteMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Delete_MaximumSet_Gen.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Delete_MinimumSet_Gen.json // this example is just showing the usage of "CapacityReservations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -110,8 +91,8 @@ public async Task Delete_CapacityReservationDeleteMaximumSetGen() // for more information of creating CapacityReservationResource, please refer to the document of CapacityReservationResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string capacityReservationGroupName = "aaaaaaaaaaa"; - string capacityReservationName = "aaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string capacityReservationGroupName = "aaa"; + string capacityReservationName = "aaaaaa"; ResourceIdentifier capacityReservationResourceId = CapacityReservationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName, capacityReservationName); CapacityReservationResource capacityReservation = client.GetCapacityReservationResource(capacityReservationResourceId); @@ -123,10 +104,10 @@ public async Task Delete_CapacityReservationDeleteMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CapacityReservationDeleteMinimumSetGen() + public async Task Update_CapacityReservationUpdateMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "CapacityReservations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Update_MaximumSet_Gen.json + // this example is just showing the usage of "CapacityReservations_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,23 +118,41 @@ public async Task Delete_CapacityReservationDeleteMinimumSetGen() // for more information of creating CapacityReservationResource, please refer to the document of CapacityReservationResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string capacityReservationGroupName = "aaa"; - string capacityReservationName = "aaaaaa"; + string capacityReservationGroupName = "aaaaaaaaaa"; + string capacityReservationName = "aaaaaaaaaaaaaaaaaaa"; ResourceIdentifier capacityReservationResourceId = CapacityReservationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName, capacityReservationName); CapacityReservationResource capacityReservation = client.GetCapacityReservationResource(capacityReservationResourceId); // invoke the operation - await capacityReservation.DeleteAsync(WaitUntil.Completed); + CapacityReservationPatch patch = new CapacityReservationPatch + { + Sku = new ComputeSku + { + Name = "Standard_DS1_v2", + Tier = "aaa", + Capacity = 7L, + }, + Tags = +{ +["key4974"] = "aaaaaaaaaaaaaaaa" +}, + }; + ArmOperation lro = await capacityReservation.UpdateAsync(WaitUntil.Completed, patch); + CapacityReservationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CapacityReservationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACapacityReservation() + public async Task Update_CapacityReservationUpdateMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Get.json - // this example is just showing the usage of "CapacityReservations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservation_Update_MinimumSet_Gen.json + // this example is just showing the usage of "CapacityReservations_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -162,16 +161,17 @@ public async Task Get_GetACapacityReservation() // this example assumes you already have this CapacityReservationResource created on azure // for more information of creating CapacityReservationResource, please refer to the document of CapacityReservationResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; - string capacityReservationGroupName = "myCapacityReservationGroup"; - string capacityReservationName = "myCapacityReservation"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string capacityReservationGroupName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; + string capacityReservationName = "aaa"; ResourceIdentifier capacityReservationResourceId = CapacityReservationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName, capacityReservationName); CapacityReservationResource capacityReservation = client.GetCapacityReservationResource(capacityReservationResourceId); // invoke the operation - CapacityReservationInstanceViewType? expand = CapacityReservationInstanceViewType.InstanceView; - CapacityReservationResource result = await capacityReservation.GetAsync(expand: expand); + CapacityReservationPatch patch = new CapacityReservationPatch(); + ArmOperation lro = await capacityReservation.UpdateAsync(WaitUntil.Completed, patch); + CapacityReservationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceCollection.cs index 6899d1e43b807..7b8b18dae0736 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceCollection.cs @@ -46,40 +46,34 @@ public async Task CreateOrUpdate_CreateNewCloudServiceWithMultipleRoles() PackageUri = new Uri("{PackageUrl}"), Configuration = "{ServiceConfiguration}", UpgradeMode = CloudServiceUpgradeMode.Auto, - Roles = -{ -new CloudServiceRoleProfileProperties() + Roles = {new CloudServiceRoleProfileProperties { Name = "ContosoFrontend", -Sku = new CloudServiceRoleSku() +Sku = new CloudServiceRoleSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 1L, }, -},new CloudServiceRoleProfileProperties() +}, new CloudServiceRoleProfileProperties { Name = "ContosoBackend", -Sku = new CloudServiceRoleSku() +Sku = new CloudServiceRoleSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 1L, }, -} -}, - NetworkProfile = new CloudServiceNetworkProfile() +}}, + NetworkProfile = new CloudServiceNetworkProfile { - LoadBalancerConfigurations = -{ -new CloudServiceLoadBalancerConfiguration("contosolb",new LoadBalancerFrontendIPConfiguration[] + LoadBalancerConfigurations = {new CloudServiceLoadBalancerConfiguration("contosolb", new LoadBalancerFrontendIPConfiguration[] { new LoadBalancerFrontendIPConfiguration("contosofe") { PublicIPAddressId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/ConstosoRG/providers/Microsoft.Network/publicIPAddresses/contosopublicip"), } -}) -}, +})}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudServiceName, data); @@ -118,47 +112,38 @@ public async Task CreateOrUpdate_CreateNewCloudServiceWithMultipleRolesInASpecif string cloudServiceName = "{cs-name}"; CloudServiceData data = new CloudServiceData(new AzureLocation("westus")) { - Zones = -{ -"1" -}, + Zones = { "1" }, PackageUri = new Uri("{PackageUrl}"), Configuration = "{ServiceConfiguration}", UpgradeMode = CloudServiceUpgradeMode.Auto, - Roles = -{ -new CloudServiceRoleProfileProperties() + Roles = {new CloudServiceRoleProfileProperties { Name = "ContosoFrontend", -Sku = new CloudServiceRoleSku() +Sku = new CloudServiceRoleSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 1L, }, -},new CloudServiceRoleProfileProperties() +}, new CloudServiceRoleProfileProperties { Name = "ContosoBackend", -Sku = new CloudServiceRoleSku() +Sku = new CloudServiceRoleSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 1L, }, -} -}, - NetworkProfile = new CloudServiceNetworkProfile() +}}, + NetworkProfile = new CloudServiceNetworkProfile { - LoadBalancerConfigurations = -{ -new CloudServiceLoadBalancerConfiguration("contosolb",new LoadBalancerFrontendIPConfiguration[] + LoadBalancerConfigurations = {new CloudServiceLoadBalancerConfiguration("contosolb", new LoadBalancerFrontendIPConfiguration[] { new LoadBalancerFrontendIPConfiguration("contosofe") { PublicIPAddressId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/ConstosoRG/providers/Microsoft.Network/publicIPAddresses/contosopublicip"), } -}) -}, +})}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudServiceName, data); @@ -200,31 +185,25 @@ public async Task CreateOrUpdate_CreateNewCloudServiceWithSingleRole() PackageUri = new Uri("{PackageUrl}"), Configuration = "{ServiceConfiguration}", UpgradeMode = CloudServiceUpgradeMode.Auto, - Roles = -{ -new CloudServiceRoleProfileProperties() + Roles = {new CloudServiceRoleProfileProperties { Name = "ContosoFrontend", -Sku = new CloudServiceRoleSku() +Sku = new CloudServiceRoleSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 1L, }, -} -}, - NetworkProfile = new CloudServiceNetworkProfile() +}}, + NetworkProfile = new CloudServiceNetworkProfile { - LoadBalancerConfigurations = -{ -new CloudServiceLoadBalancerConfiguration("myLoadBalancer",new LoadBalancerFrontendIPConfiguration[] + LoadBalancerConfigurations = {new CloudServiceLoadBalancerConfiguration("myLoadBalancer", new LoadBalancerFrontendIPConfiguration[] { new LoadBalancerFrontendIPConfiguration("myfe") { PublicIPAddressId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/ConstosoRG/providers/Microsoft.Network/publicIPAddresses/myPublicIP"), } -}) -}, +})}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudServiceName, data); @@ -266,45 +245,33 @@ public async Task CreateOrUpdate_CreateNewCloudServiceWithSingleRoleAndCertifica PackageUri = new Uri("{PackageUrl}"), Configuration = "{ServiceConfiguration}", UpgradeMode = CloudServiceUpgradeMode.Auto, - Roles = -{ -new CloudServiceRoleProfileProperties() + Roles = {new CloudServiceRoleProfileProperties { Name = "ContosoFrontend", -Sku = new CloudServiceRoleSku() +Sku = new CloudServiceRoleSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 1L, }, -} -}, - OSSecrets = -{ -new CloudServiceVaultSecretGroup() +}}, + OSSecrets = {new CloudServiceVaultSecretGroup { SourceVaultId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/ConstosoRG/providers/Microsoft.KeyVault/vaults/{keyvault-name}"), -VaultCertificates = -{ -new CloudServiceVaultCertificate() +VaultCertificates = {new CloudServiceVaultCertificate { CertificateUri = new Uri("https://{keyvault-name}.vault.azure.net:443/secrets/ContosoCertificate/{secret-id}"), -} -}, -} -}, - NetworkProfile = new CloudServiceNetworkProfile() +}}, +}}, + NetworkProfile = new CloudServiceNetworkProfile { - LoadBalancerConfigurations = -{ -new CloudServiceLoadBalancerConfiguration("contosolb",new LoadBalancerFrontendIPConfiguration[] + LoadBalancerConfigurations = {new CloudServiceLoadBalancerConfiguration("contosolb", new LoadBalancerFrontendIPConfiguration[] { new LoadBalancerFrontendIPConfiguration("contosofe") { PublicIPAddressId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/ConstosoRG/providers/Microsoft.Network/publicIPAddresses/contosopublicip"), } -}) -}, +})}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudServiceName, data); @@ -346,45 +313,36 @@ public async Task CreateOrUpdate_CreateNewCloudServiceWithSingleRoleAndRDPExtens PackageUri = new Uri("{PackageUrl}"), Configuration = "{ServiceConfiguration}", UpgradeMode = CloudServiceUpgradeMode.Auto, - Roles = -{ -new CloudServiceRoleProfileProperties() + Roles = {new CloudServiceRoleProfileProperties { Name = "ContosoFrontend", -Sku = new CloudServiceRoleSku() +Sku = new CloudServiceRoleSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 1L, }, -} -}, - NetworkProfile = new CloudServiceNetworkProfile() +}}, + NetworkProfile = new CloudServiceNetworkProfile { - LoadBalancerConfigurations = -{ -new CloudServiceLoadBalancerConfiguration("contosolb",new LoadBalancerFrontendIPConfiguration[] + LoadBalancerConfigurations = {new CloudServiceLoadBalancerConfiguration("contosolb", new LoadBalancerFrontendIPConfiguration[] { new LoadBalancerFrontendIPConfiguration("contosofe") { PublicIPAddressId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/ConstosoRG/providers/Microsoft.Network/publicIPAddresses/contosopublicip"), } -}) -}, +})}, }, - Extensions = -{ -new CloudServiceExtension() + Extensions = {new CloudServiceExtension { Name = "RDPExtension", Publisher = "Microsoft.Windows.Azure.Extensions", CloudServiceExtensionPropertiesType = "RDP", TypeHandlerVersion = "1.2", AutoUpgradeMinorVersion = false, -Settings = BinaryData.FromString("\"UserAzure10/22/2021 15:05:45\""), -ProtectedSettings = BinaryData.FromString("\"{password}\""), -} -}, +Settings = BinaryData.FromObjectAsJson("UserAzure10/22/2021 15:05:45"), +ProtectedSettings = BinaryData.FromObjectAsJson("{password}"), +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudServiceName, data); CloudServiceResource result = lro.Value; @@ -431,10 +389,10 @@ public async Task Get_GetCloudServiceWithMultipleRolesAndRDPExtension() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCloudServiceWithMultipleRolesAndRDPExtension() + public async Task GetAll_ListCloudServicesInAResourceGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_Get_WithMultiRoleAndRDP.json - // this example is just showing the usage of "CloudServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_List_ByResourceGroup.json + // this example is just showing the usage of "CloudServices_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -451,16 +409,22 @@ public async Task Exists_GetCloudServiceWithMultipleRolesAndRDPExtension() // get the collection of this CloudServiceResource CloudServiceCollection collection = resourceGroupResource.GetCloudServices(); - // invoke the operation - string cloudServiceName = "{cs-name}"; - bool result = await collection.ExistsAsync(cloudServiceName); + // invoke the operation and iterate over the result + await foreach (CloudServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCloudServiceWithMultipleRolesAndRDPExtension() + public async Task Exists_GetCloudServiceWithMultipleRolesAndRDPExtension() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_Get_WithMultiRoleAndRDP.json // this example is just showing the usage of "CloudServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -482,29 +446,17 @@ public async Task GetIfExists_GetCloudServiceWithMultipleRolesAndRDPExtension() // invoke the operation string cloudServiceName = "{cs-name}"; - NullableResponse response = await collection.GetIfExistsAsync(cloudServiceName); - CloudServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(cloudServiceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCloudServicesInAResourceGroup() + public async Task GetIfExists_GetCloudServiceWithMultipleRolesAndRDPExtension() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_List_ByResourceGroup.json - // this example is just showing the usage of "CloudServices_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_Get_WithMultiRoleAndRDP.json + // this example is just showing the usage of "CloudServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -521,17 +473,23 @@ public async Task GetAll_ListCloudServicesInAResourceGroup() // get the collection of this CloudServiceResource CloudServiceCollection collection = resourceGroupResource.GetCloudServices(); - // invoke the operation and iterate over the result - await foreach (CloudServiceResource item in collection.GetAllAsync()) + // invoke the operation + string cloudServiceName = "{cs-name}"; + NullableResponse response = await collection.GetIfExistsAsync(cloudServiceName); + CloudServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CloudServiceData resourceData = item.Data; + CloudServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceOSFamilyCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceOSFamilyCollection.cs index 3f3b58010c0f6..9d79774ea8476 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceOSFamilyCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceOSFamilyCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetCloudServiceOSFamily() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCloudServiceOSFamily() + public async Task GetAll_ListCloudServiceOSFamiliesInASubscription() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceOSFamily_Get.json - // this example is just showing the usage of "CloudServiceOperatingSystems_GetOSFamily" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceOSFamilies_List.json + // this example is just showing the usage of "CloudServiceOperatingSystems_ListOSFamilies" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,16 +71,22 @@ public async Task Exists_GetCloudServiceOSFamily() AzureLocation location = new AzureLocation("westus2"); CloudServiceOSFamilyCollection collection = subscriptionResource.GetCloudServiceOSFamilies(location); - // invoke the operation - string osFamilyName = "3"; - bool result = await collection.ExistsAsync(osFamilyName); + // invoke the operation and iterate over the result + await foreach (CloudServiceOSFamilyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudServiceOSFamilyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCloudServiceOSFamily() + public async Task Exists_GetCloudServiceOSFamily() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceOSFamily_Get.json // this example is just showing the usage of "CloudServiceOperatingSystems_GetOSFamily" operation, for the dependent resources, they will have to be created separately. @@ -102,29 +108,17 @@ public async Task GetIfExists_GetCloudServiceOSFamily() // invoke the operation string osFamilyName = "3"; - NullableResponse response = await collection.GetIfExistsAsync(osFamilyName); - CloudServiceOSFamilyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(osFamilyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudServiceOSFamilyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCloudServiceOSFamiliesInASubscription() + public async Task GetIfExists_GetCloudServiceOSFamily() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceOSFamilies_List.json - // this example is just showing the usage of "CloudServiceOperatingSystems_ListOSFamilies" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceOSFamily_Get.json + // this example is just showing the usage of "CloudServiceOperatingSystems_GetOSFamily" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,17 +135,23 @@ public async Task GetAll_ListCloudServiceOSFamiliesInASubscription() AzureLocation location = new AzureLocation("westus2"); CloudServiceOSFamilyCollection collection = subscriptionResource.GetCloudServiceOSFamilies(location); - // invoke the operation and iterate over the result - await foreach (CloudServiceOSFamilyResource item in collection.GetAllAsync()) + // invoke the operation + string osFamilyName = "3"; + NullableResponse response = await collection.GetIfExistsAsync(osFamilyName); + CloudServiceOSFamilyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CloudServiceOSFamilyData resourceData = item.Data; + CloudServiceOSFamilyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceOSVersionCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceOSVersionCollection.cs index fa5e1a794e5d7..dae2db3e8a116 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceOSVersionCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceOSVersionCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetCloudServiceOSVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCloudServiceOSVersion() + public async Task GetAll_ListCloudServiceOSVersionsInASubscription() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceOSVersion_Get.json - // this example is just showing the usage of "CloudServiceOperatingSystems_GetOSVersion" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceOSVersion_List.json + // this example is just showing the usage of "CloudServiceOperatingSystems_ListOSVersions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,16 +71,22 @@ public async Task Exists_GetCloudServiceOSVersion() AzureLocation location = new AzureLocation("westus2"); CloudServiceOSVersionCollection collection = subscriptionResource.GetCloudServiceOSVersions(location); - // invoke the operation - string osVersionName = "WA-GUEST-OS-3.90_202010-02"; - bool result = await collection.ExistsAsync(osVersionName); + // invoke the operation and iterate over the result + await foreach (CloudServiceOSVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudServiceOSVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCloudServiceOSVersion() + public async Task Exists_GetCloudServiceOSVersion() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceOSVersion_Get.json // this example is just showing the usage of "CloudServiceOperatingSystems_GetOSVersion" operation, for the dependent resources, they will have to be created separately. @@ -102,29 +108,17 @@ public async Task GetIfExists_GetCloudServiceOSVersion() // invoke the operation string osVersionName = "WA-GUEST-OS-3.90_202010-02"; - NullableResponse response = await collection.GetIfExistsAsync(osVersionName); - CloudServiceOSVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(osVersionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudServiceOSVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCloudServiceOSVersionsInASubscription() + public async Task GetIfExists_GetCloudServiceOSVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceOSVersion_List.json - // this example is just showing the usage of "CloudServiceOperatingSystems_ListOSVersions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceOSVersion_Get.json + // this example is just showing the usage of "CloudServiceOperatingSystems_GetOSVersion" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,17 +135,23 @@ public async Task GetAll_ListCloudServiceOSVersionsInASubscription() AzureLocation location = new AzureLocation("westus2"); CloudServiceOSVersionCollection collection = subscriptionResource.GetCloudServiceOSVersions(location); - // invoke the operation and iterate over the result - await foreach (CloudServiceOSVersionResource item in collection.GetAllAsync()) + // invoke the operation + string osVersionName = "WA-GUEST-OS-3.90_202010-02"; + NullableResponse response = await collection.GetIfExistsAsync(osVersionName); + CloudServiceOSVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CloudServiceOSVersionData resourceData = item.Data; + CloudServiceOSVersionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceResource.cs index 6be476bf883b8..b223dcbb46dac 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -19,10 +18,10 @@ public partial class Sample_CloudServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateExistingCloudServiceToAddTags() + public async Task Get_GetCloudServiceWithMultipleRolesAndRDPExtension() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_Update_ToIncludeTags.json - // this example is just showing the usage of "CloudServices_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_Get_WithMultiRoleAndRDP.json + // this example is just showing the usage of "CloudServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +37,7 @@ public async Task Update_UpdateExistingCloudServiceToAddTags() CloudServiceResource cloudService = client.GetCloudServiceResource(cloudServiceResourceId); // invoke the operation - CloudServicePatch patch = new CloudServicePatch() - { - Tags = -{ -["Documentation"] = "RestAPI", -}, - }; - ArmOperation lro = await cloudService.UpdateAsync(WaitUntil.Completed, patch); - CloudServiceResource result = lro.Value; + CloudServiceResource result = await cloudService.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -83,10 +74,10 @@ public async Task Delete_DeleteCloudService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCloudServiceWithMultipleRolesAndRDPExtension() + public async Task Update_UpdateExistingCloudServiceToAddTags() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_Get_WithMultiRoleAndRDP.json - // this example is just showing the usage of "CloudServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_Update_ToIncludeTags.json + // this example is just showing the usage of "CloudServices_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,7 +93,15 @@ public async Task Get_GetCloudServiceWithMultipleRolesAndRDPExtension() CloudServiceResource cloudService = client.GetCloudServiceResource(cloudServiceResourceId); // invoke the operation - CloudServiceResource result = await cloudService.GetAsync(); + CloudServicePatch patch = new CloudServicePatch + { + Tags = +{ +["Documentation"] = "RestAPI" +}, + }; + ArmOperation lro = await cloudService.UpdateAsync(WaitUntil.Completed, patch); + CloudServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -137,37 +136,6 @@ public async Task GetInstanceView_GetCloudServiceInstanceViewWithMultipleRoles() Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCloudServices_ListCloudServicesInASubscription() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_List_BySubscription.json - // this example is just showing the usage of "CloudServices_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CloudServiceResource item in subscriptionResource.GetCloudServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task PowerOn_StartCloudService() @@ -241,10 +209,7 @@ public async Task Restart_RestartCloudServiceRoleInstancesInACloudService() CloudServiceResource cloudService = client.GetCloudServiceResource(cloudServiceResourceId); // invoke the operation - RoleInstances roleInstances = new RoleInstances(new string[] - { -"ContosoFrontend_IN_0","ContosoBackend_IN_1" - }); + RoleInstances roleInstances = new RoleInstances(new string[] { "ContosoFrontend_IN_0", "ContosoBackend_IN_1" }); await cloudService.RestartAsync(WaitUntil.Completed, roleInstances: roleInstances); Console.WriteLine("Succeeded"); @@ -271,10 +236,7 @@ public async Task Reimage_ReimageCloudServiceRoleInstancesInACloudService() CloudServiceResource cloudService = client.GetCloudServiceResource(cloudServiceResourceId); // invoke the operation - RoleInstances roleInstances = new RoleInstances(new string[] - { -"ContosoFrontend_IN_0","ContosoBackend_IN_1" - }); + RoleInstances roleInstances = new RoleInstances(new string[] { "ContosoFrontend_IN_0", "ContosoBackend_IN_1" }); await cloudService.ReimageAsync(WaitUntil.Completed, roleInstances: roleInstances); Console.WriteLine("Succeeded"); @@ -301,10 +263,7 @@ public async Task Rebuild_RebuildCloudServiceRoleInstancesInACloudService() CloudServiceResource cloudService = client.GetCloudServiceResource(cloudServiceResourceId); // invoke the operation - RoleInstances roleInstances = new RoleInstances(new string[] - { -"ContosoFrontend_IN_0","ContosoBackend_IN_1" - }); + RoleInstances roleInstances = new RoleInstances(new string[] { "ContosoFrontend_IN_0", "ContosoBackend_IN_1" }); await cloudService.RebuildAsync(WaitUntil.Completed, roleInstances: roleInstances); Console.WriteLine("Succeeded"); @@ -331,10 +290,7 @@ public async Task DeleteInstances_DeleteCloudServiceRoleInstancesInACloudService CloudServiceResource cloudService = client.GetCloudServiceResource(cloudServiceResourceId); // invoke the operation - RoleInstances roleInstances = new RoleInstances(new string[] - { -"ContosoFrontend_IN_0","ContosoBackend_IN_1" - }); + RoleInstances roleInstances = new RoleInstances(new string[] { "ContosoFrontend_IN_0", "ContosoBackend_IN_1" }); await cloudService.DeleteInstancesAsync(WaitUntil.Completed, roleInstances: roleInstances); Console.WriteLine("Succeeded"); diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleCollection.cs index 6e35e21f4ad62..c2cee5d56b8d5 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetCloudServiceRole() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCloudServiceRole() + public async Task GetAll_ListRolesInACloudService() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRole_Get.json - // this example is just showing the usage of "CloudServiceRoles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRole_List.json + // this example is just showing the usage of "CloudServiceRoles_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetCloudServiceRole() // get the collection of this CloudServiceRoleResource CloudServiceRoleCollection collection = cloudService.GetCloudServiceRoles(); - // invoke the operation - string roleName = "{role-name}"; - bool result = await collection.ExistsAsync(roleName); + // invoke the operation and iterate over the result + await foreach (CloudServiceRoleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudServiceRoleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCloudServiceRole() + public async Task Exists_GetCloudServiceRole() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRole_Get.json // this example is just showing the usage of "CloudServiceRoles_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetCloudServiceRole() // invoke the operation string roleName = "{role-name}"; - NullableResponse response = await collection.GetIfExistsAsync(roleName); - CloudServiceRoleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(roleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudServiceRoleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRolesInACloudService() + public async Task GetIfExists_GetCloudServiceRole() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRole_List.json - // this example is just showing the usage of "CloudServiceRoles_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRole_Get.json + // this example is just showing the usage of "CloudServiceRoles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ListRolesInACloudService() // get the collection of this CloudServiceRoleResource CloudServiceRoleCollection collection = cloudService.GetCloudServiceRoles(); - // invoke the operation and iterate over the result - await foreach (CloudServiceRoleResource item in collection.GetAllAsync()) + // invoke the operation + string roleName = "{role-name}"; + NullableResponse response = await collection.GetIfExistsAsync(roleName); + CloudServiceRoleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CloudServiceRoleData resourceData = item.Data; + CloudServiceRoleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleInstanceCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleInstanceCollection.cs index b59b1cd763024..60ede4d233bc9 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleInstanceCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleInstanceCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetCloudServiceRoleInstance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCloudServiceRoleInstance() + public async Task GetAll_ListRoleInstancesInACloudService() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRoleInstance_Get.json - // this example is just showing the usage of "CloudServiceRoleInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRolesInstance_List.json + // this example is just showing the usage of "CloudServiceRoleInstances_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetCloudServiceRoleInstance() // get the collection of this CloudServiceRoleInstanceResource CloudServiceRoleInstanceCollection collection = cloudService.GetCloudServiceRoleInstances(); - // invoke the operation - string roleInstanceName = "{roleInstance-name}"; - bool result = await collection.ExistsAsync(roleInstanceName); + // invoke the operation and iterate over the result + await foreach (CloudServiceRoleInstanceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudServiceRoleInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCloudServiceRoleInstance() + public async Task Exists_GetCloudServiceRoleInstance() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRoleInstance_Get.json // this example is just showing the usage of "CloudServiceRoleInstances_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetCloudServiceRoleInstance() // invoke the operation string roleInstanceName = "{roleInstance-name}"; - NullableResponse response = await collection.GetIfExistsAsync(roleInstanceName); - CloudServiceRoleInstanceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(roleInstanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudServiceRoleInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRoleInstancesInACloudService() + public async Task GetIfExists_GetCloudServiceRoleInstance() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRolesInstance_List.json - // this example is just showing the usage of "CloudServiceRoleInstances_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRoleInstance_Get.json + // this example is just showing the usage of "CloudServiceRoleInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ListRoleInstancesInACloudService() // get the collection of this CloudServiceRoleInstanceResource CloudServiceRoleInstanceCollection collection = cloudService.GetCloudServiceRoleInstances(); - // invoke the operation and iterate over the result - await foreach (CloudServiceRoleInstanceResource item in collection.GetAllAsync()) + // invoke the operation + string roleInstanceName = "{roleInstance-name}"; + NullableResponse response = await collection.GetIfExistsAsync(roleInstanceName); + CloudServiceRoleInstanceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CloudServiceRoleInstanceData resourceData = item.Data; + CloudServiceRoleInstanceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleInstanceResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleInstanceResource.cs index 4b46b40a2e617..054c0ddb60785 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleInstanceResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CloudServiceRoleInstanceResource.cs @@ -19,10 +19,10 @@ public partial class Sample_CloudServiceRoleInstanceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteCloudServiceRoleInstance() + public async Task Get_GetCloudServiceRoleInstance() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRoleInstance_Delete.json - // this example is just showing the usage of "CloudServiceRoleInstances_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRoleInstance_Get.json + // this example is just showing the usage of "CloudServiceRoleInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteCloudServiceRoleInstance() CloudServiceRoleInstanceResource cloudServiceRoleInstance = client.GetCloudServiceRoleInstanceResource(cloudServiceRoleInstanceResourceId); // invoke the operation - await cloudServiceRoleInstance.DeleteAsync(WaitUntil.Completed); + CloudServiceRoleInstanceResource result = await cloudServiceRoleInstance.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudServiceRoleInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCloudServiceRoleInstance() + public async Task Delete_DeleteCloudServiceRoleInstance() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRoleInstance_Get.json - // this example is just showing the usage of "CloudServiceRoleInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudServiceRoleInstance_Delete.json + // this example is just showing the usage of "CloudServiceRoleInstances_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,13 +70,9 @@ public async Task Get_GetCloudServiceRoleInstance() CloudServiceRoleInstanceResource cloudServiceRoleInstance = client.GetCloudServiceRoleInstanceResource(cloudServiceRoleInstanceResourceId); // invoke the operation - CloudServiceRoleInstanceResource result = await cloudServiceRoleInstance.GetAsync(); + await cloudServiceRoleInstance.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudServiceRoleInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CommunityGalleryImageCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CommunityGalleryImageCollection.cs index 6c6e39da5a364..f06ed5ec252db 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CommunityGalleryImageCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CommunityGalleryImageCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetACommunityGalleryImage() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACommunityGalleryImage() + public async Task GetAll_ListCommunityGalleryImages() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImage_Get.json - // this example is just showing the usage of "CommunityGalleryImages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImage_List.json + // this example is just showing the usage of "CommunityGalleryImages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetACommunityGalleryImage() // get the collection of this CommunityGalleryImageResource CommunityGalleryImageCollection collection = communityGallery.GetCommunityGalleryImages(); - // invoke the operation - string galleryImageName = "myGalleryImageName"; - bool result = await collection.ExistsAsync(galleryImageName); + // invoke the operation and iterate over the result + await foreach (CommunityGalleryImageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityGalleryImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACommunityGalleryImage() + public async Task Exists_GetACommunityGalleryImage() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImage_Get.json // this example is just showing the usage of "CommunityGalleryImages_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetACommunityGalleryImage() // invoke the operation string galleryImageName = "myGalleryImageName"; - NullableResponse response = await collection.GetIfExistsAsync(galleryImageName); - CommunityGalleryImageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(galleryImageName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommunityGalleryImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCommunityGalleryImages() + public async Task GetIfExists_GetACommunityGalleryImage() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImage_List.json - // this example is just showing the usage of "CommunityGalleryImages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImage_Get.json + // this example is just showing the usage of "CommunityGalleryImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ListCommunityGalleryImages() // get the collection of this CommunityGalleryImageResource CommunityGalleryImageCollection collection = communityGallery.GetCommunityGalleryImages(); - // invoke the operation and iterate over the result - await foreach (CommunityGalleryImageResource item in collection.GetAllAsync()) + // invoke the operation + string galleryImageName = "myGalleryImageName"; + NullableResponse response = await collection.GetIfExistsAsync(galleryImageName); + CommunityGalleryImageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CommunityGalleryImageData resourceData = item.Data; + CommunityGalleryImageData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CommunityGalleryImageVersionCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CommunityGalleryImageVersionCollection.cs index 753aa81b92e92..28346a788e78b 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CommunityGalleryImageVersionCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_CommunityGalleryImageVersionCollection.cs @@ -52,10 +52,10 @@ public async Task Get_GetACommunityGalleryImageVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACommunityGalleryImageVersion() + public async Task GetAll_ListCommunityGalleryImageVersions() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImageVersion_Get.json - // this example is just showing the usage of "CommunityGalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImageVersion_List.json + // this example is just showing the usage of "CommunityGalleryImageVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,16 +74,22 @@ public async Task Exists_GetACommunityGalleryImageVersion() // get the collection of this CommunityGalleryImageVersionResource CommunityGalleryImageVersionCollection collection = communityGalleryImage.GetCommunityGalleryImageVersions(); - // invoke the operation - string galleryImageVersionName = "myGalleryImageVersionName"; - bool result = await collection.ExistsAsync(galleryImageVersionName); + // invoke the operation and iterate over the result + await foreach (CommunityGalleryImageVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CommunityGalleryImageVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACommunityGalleryImageVersion() + public async Task Exists_GetACommunityGalleryImageVersion() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImageVersion_Get.json // this example is just showing the usage of "CommunityGalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +113,17 @@ public async Task GetIfExists_GetACommunityGalleryImageVersion() // invoke the operation string galleryImageVersionName = "myGalleryImageVersionName"; - NullableResponse response = await collection.GetIfExistsAsync(galleryImageVersionName); - CommunityGalleryImageVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(galleryImageVersionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CommunityGalleryImageVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCommunityGalleryImageVersions() + public async Task GetIfExists_GetACommunityGalleryImageVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImageVersion_List.json - // this example is just showing the usage of "CommunityGalleryImageVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/communityGalleryExamples/CommunityGalleryImageVersion_Get.json + // this example is just showing the usage of "CommunityGalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,17 +142,23 @@ public async Task GetAll_ListCommunityGalleryImageVersions() // get the collection of this CommunityGalleryImageVersionResource CommunityGalleryImageVersionCollection collection = communityGalleryImage.GetCommunityGalleryImageVersions(); - // invoke the operation and iterate over the result - await foreach (CommunityGalleryImageVersionResource item in collection.GetAllAsync()) + // invoke the operation + string galleryImageVersionName = "myGalleryImageVersionName"; + NullableResponse response = await collection.GetIfExistsAsync(galleryImageVersionName); + CommunityGalleryImageVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CommunityGalleryImageVersionData resourceData = item.Data; + CommunityGalleryImageVersionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ComputePrivateEndpointConnectionCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ComputePrivateEndpointConnectionCollection.cs index a7987aac2a2da..887c35eb84de3 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ComputePrivateEndpointConnectionCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ComputePrivateEndpointConnectionCollection.cs @@ -41,9 +41,9 @@ public async Task CreateOrUpdate_ApproveAPrivateEndpointConnectionUnderADiskAcce // invoke the operation string privateEndpointConnectionName = "myPrivateEndpointConnection"; - ComputePrivateEndpointConnectionData data = new ComputePrivateEndpointConnectionData() + ComputePrivateEndpointConnectionData data = new ComputePrivateEndpointConnectionData { - ConnectionState = new ComputePrivateLinkServiceConnectionState() + ConnectionState = new ComputePrivateLinkServiceConnectionState { Status = ComputePrivateEndpointServiceConnectionStatus.Approved, Description = "Approving myPrivateEndpointConnection", @@ -95,10 +95,10 @@ public async Task Get_GetInformationAboutAPrivateEndpointConnectionUnderADiskAcc [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetInformationAboutAPrivateEndpointConnectionUnderADiskAccessResource() + public async Task GetAll_GetInformationAboutAPrivateEndpointConnectionUnderADiskAccessResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Get.json - // this example is just showing the usage of "DiskAccesses_GetAPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_ListByDiskAccess.json + // this example is just showing the usage of "DiskAccesses_ListPrivateEndpointConnections" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,16 +116,22 @@ public async Task Exists_GetInformationAboutAPrivateEndpointConnectionUnderADisk // get the collection of this ComputePrivateEndpointConnectionResource ComputePrivateEndpointConnectionCollection collection = diskAccess.GetComputePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "myPrivateEndpointConnection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (ComputePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ComputePrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInformationAboutAPrivateEndpointConnectionUnderADiskAccessResource() + public async Task Exists_GetInformationAboutAPrivateEndpointConnectionUnderADiskAccessResource() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Get.json // this example is just showing the usage of "DiskAccesses_GetAPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +154,17 @@ public async Task GetIfExists_GetInformationAboutAPrivateEndpointConnectionUnder // invoke the operation string privateEndpointConnectionName = "myPrivateEndpointConnection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - ComputePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ComputePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetInformationAboutAPrivateEndpointConnectionUnderADiskAccessResource() + public async Task GetIfExists_GetInformationAboutAPrivateEndpointConnectionUnderADiskAccessResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_ListByDiskAccess.json - // this example is just showing the usage of "DiskAccesses_ListPrivateEndpointConnections" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Get.json + // this example is just showing the usage of "DiskAccesses_GetAPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_GetInformationAboutAPrivateEndpointConnectionUnderADisk // get the collection of this ComputePrivateEndpointConnectionResource ComputePrivateEndpointConnectionCollection collection = diskAccess.GetComputePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (ComputePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "myPrivateEndpointConnection"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + ComputePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ComputePrivateEndpointConnectionData resourceData = item.Data; + ComputePrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ComputePrivateEndpointConnectionResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ComputePrivateEndpointConnectionResource.cs index 88bf945520ff9..10ad67a0c8f5c 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ComputePrivateEndpointConnectionResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ComputePrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ComputePrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveAPrivateEndpointConnectionUnderADiskAccessResource() + public async Task Get_GetInformationAboutAPrivateEndpointConnectionUnderADiskAccessResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Approve.json - // this example is just showing the usage of "DiskAccesses_UpdateAPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Get.json + // this example is just showing the usage of "DiskAccesses_GetAPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,7 @@ public async Task Update_ApproveAPrivateEndpointConnectionUnderADiskAccessResour ComputePrivateEndpointConnectionResource computePrivateEndpointConnection = client.GetComputePrivateEndpointConnectionResource(computePrivateEndpointConnectionResourceId); // invoke the operation - ComputePrivateEndpointConnectionData data = new ComputePrivateEndpointConnectionData() - { - ConnectionState = new ComputePrivateLinkServiceConnectionState() - { - Status = ComputePrivateEndpointServiceConnectionStatus.Approved, - Description = "Approving myPrivateEndpointConnection", - }, - }; - ArmOperation lro = await computePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - ComputePrivateEndpointConnectionResource result = lro.Value; + ComputePrivateEndpointConnectionResource result = await computePrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +49,10 @@ public async Task Update_ApproveAPrivateEndpointConnectionUnderADiskAccessResour [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInformationAboutAPrivateEndpointConnectionUnderADiskAccessResource() + public async Task Delete_DeleteAPrivateEndpointConnectionUnderADiskAccessResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Get.json - // this example is just showing the usage of "DiskAccesses_GetAPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Delete.json + // this example is just showing the usage of "DiskAccesses_DeleteAPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,21 +69,17 @@ public async Task Get_GetInformationAboutAPrivateEndpointConnectionUnderADiskAcc ComputePrivateEndpointConnectionResource computePrivateEndpointConnection = client.GetComputePrivateEndpointConnectionResource(computePrivateEndpointConnectionResourceId); // invoke the operation - ComputePrivateEndpointConnectionResource result = await computePrivateEndpointConnection.GetAsync(); + await computePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ComputePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPrivateEndpointConnectionUnderADiskAccessResource() + public async Task Update_ApproveAPrivateEndpointConnectionUnderADiskAccessResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Delete.json - // this example is just showing the usage of "DiskAccesses_DeleteAPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccessPrivateEndpointConnection_Approve.json + // this example is just showing the usage of "DiskAccesses_UpdateAPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_DeleteAPrivateEndpointConnectionUnderADiskAccessResourc ComputePrivateEndpointConnectionResource computePrivateEndpointConnection = client.GetComputePrivateEndpointConnectionResource(computePrivateEndpointConnectionResourceId); // invoke the operation - await computePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + ComputePrivateEndpointConnectionData data = new ComputePrivateEndpointConnectionData + { + ConnectionState = new ComputePrivateLinkServiceConnectionState + { + Status = ComputePrivateEndpointServiceConnectionStatus.Approved, + Description = "Approving myPrivateEndpointConnection", + }, + }; + ArmOperation lro = await computePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ComputePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ComputePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostCollection.cs index b1b5eec482a36..dd4b52d438b11 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_CreateOrUpdateADedicatedHost() // invoke the operation string hostName = "myDedicatedHost"; - DedicatedHostData data = new DedicatedHostData(new AzureLocation("westus"), new ComputeSku() + DedicatedHostData data = new DedicatedHostData(new AzureLocation("westus"), new ComputeSku { Name = "DSv3-Type1", }) @@ -49,7 +49,7 @@ public async Task CreateOrUpdate_CreateOrUpdateADedicatedHost() PlatformFaultDomain = 1, Tags = { -["department"] = "HR", +["department"] = "HR" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hostName, data); @@ -99,10 +99,10 @@ public async Task Get_GetADedicatedHost() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADedicatedHost() + public async Task GetAll_DedicatedHostListByHostGroupMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Get.json - // this example is just showing the usage of "DedicatedHosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_ListByHostGroup_MaximumSet_Gen.json + // this example is just showing the usage of "DedicatedHosts_ListByHostGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,29 +111,34 @@ public async Task Exists_GetADedicatedHost() // this example assumes you already have this DedicatedHostGroupResource created on azure // for more information of creating DedicatedHostGroupResource, please refer to the document of DedicatedHostGroupResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; - string hostGroupName = "myDedicatedHostGroup"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string hostGroupName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier dedicatedHostGroupResourceId = DedicatedHostGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName); DedicatedHostGroupResource dedicatedHostGroup = client.GetDedicatedHostGroupResource(dedicatedHostGroupResourceId); // get the collection of this DedicatedHostResource DedicatedHostCollection collection = dedicatedHostGroup.GetDedicatedHosts(); - // invoke the operation - string hostName = "myHost"; - InstanceViewType? expand = InstanceViewType.InstanceView; - bool result = await collection.ExistsAsync(hostName, expand: expand); + // invoke the operation and iterate over the result + await foreach (DedicatedHostResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHostData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADedicatedHost() + public async Task GetAll_DedicatedHostListByHostGroupMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Get.json - // this example is just showing the usage of "DedicatedHosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_ListByHostGroup_MinimumSet_Gen.json + // this example is just showing the usage of "DedicatedHosts_ListByHostGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,41 +147,34 @@ public async Task GetIfExists_GetADedicatedHost() // this example assumes you already have this DedicatedHostGroupResource created on azure // for more information of creating DedicatedHostGroupResource, please refer to the document of DedicatedHostGroupResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; - string hostGroupName = "myDedicatedHostGroup"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string hostGroupName = "aaaa"; ResourceIdentifier dedicatedHostGroupResourceId = DedicatedHostGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName); DedicatedHostGroupResource dedicatedHostGroup = client.GetDedicatedHostGroupResource(dedicatedHostGroupResourceId); // get the collection of this DedicatedHostResource DedicatedHostCollection collection = dedicatedHostGroup.GetDedicatedHosts(); - // invoke the operation - string hostName = "myHost"; - InstanceViewType? expand = InstanceViewType.InstanceView; - NullableResponse response = await collection.GetIfExistsAsync(hostName, expand: expand); - DedicatedHostResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DedicatedHostResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DedicatedHostData resourceData = result.Data; + DedicatedHostData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DedicatedHostListByHostGroupMaximumSetGen() + public async Task Exists_GetADedicatedHost() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_ListByHostGroup_MaximumSet_Gen.json - // this example is just showing the usage of "DedicatedHosts_ListByHostGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Get.json + // this example is just showing the usage of "DedicatedHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,34 +183,29 @@ public async Task GetAll_DedicatedHostListByHostGroupMaximumSetGen() // this example assumes you already have this DedicatedHostGroupResource created on azure // for more information of creating DedicatedHostGroupResource, please refer to the document of DedicatedHostGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string hostGroupName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; + string hostGroupName = "myDedicatedHostGroup"; ResourceIdentifier dedicatedHostGroupResourceId = DedicatedHostGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName); DedicatedHostGroupResource dedicatedHostGroup = client.GetDedicatedHostGroupResource(dedicatedHostGroupResourceId); // get the collection of this DedicatedHostResource DedicatedHostCollection collection = dedicatedHostGroup.GetDedicatedHosts(); - // invoke the operation and iterate over the result - await foreach (DedicatedHostResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHostData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string hostName = "myHost"; + InstanceViewType? expand = InstanceViewType.InstanceView; + bool result = await collection.ExistsAsync(hostName, expand: expand); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DedicatedHostListByHostGroupMinimumSetGen() + public async Task GetIfExists_GetADedicatedHost() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_ListByHostGroup_MinimumSet_Gen.json - // this example is just showing the usage of "DedicatedHosts_ListByHostGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Get.json + // this example is just showing the usage of "DedicatedHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -221,26 +214,33 @@ public async Task GetAll_DedicatedHostListByHostGroupMinimumSetGen() // this example assumes you already have this DedicatedHostGroupResource created on azure // for more information of creating DedicatedHostGroupResource, please refer to the document of DedicatedHostGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string hostGroupName = "aaaa"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; + string hostGroupName = "myDedicatedHostGroup"; ResourceIdentifier dedicatedHostGroupResourceId = DedicatedHostGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName); DedicatedHostGroupResource dedicatedHostGroup = client.GetDedicatedHostGroupResource(dedicatedHostGroupResourceId); // get the collection of this DedicatedHostResource DedicatedHostCollection collection = dedicatedHostGroup.GetDedicatedHosts(); - // invoke the operation and iterate over the result - await foreach (DedicatedHostResource item in collection.GetAllAsync()) + // invoke the operation + string hostName = "myHost"; + InstanceViewType? expand = InstanceViewType.InstanceView; + NullableResponse response = await collection.GetIfExistsAsync(hostName, expand: expand); + DedicatedHostResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DedicatedHostData resourceData = item.Data; + DedicatedHostData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostGroupCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostGroupCollection.cs index 2a310042e0b64..99b6278a5fa7b 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostGroupCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostGroupCollection.cs @@ -42,16 +42,13 @@ public async Task CreateOrUpdate_CreateOrUpdateADedicatedHostGroupWithUltraSSDSu string hostGroupName = "myDedicatedHostGroup"; DedicatedHostGroupData data = new DedicatedHostGroupData(new AzureLocation("westus")) { - Zones = -{ -"1" -}, + Zones = { "1" }, PlatformFaultDomainCount = 3, SupportAutomaticPlacement = true, UltraSsdEnabled = true, Tags = { -["department"] = "finance", +["department"] = "finance" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hostGroupName, data); @@ -90,15 +87,12 @@ public async Task CreateOrUpdate_CreateOrUpdateADedicatedHostGroup() string hostGroupName = "myDedicatedHostGroup"; DedicatedHostGroupData data = new DedicatedHostGroupData(new AzureLocation("westus")) { - Zones = -{ -"1" -}, + Zones = { "1" }, PlatformFaultDomainCount = 3, SupportAutomaticPlacement = true, Tags = { -["department"] = "finance", +["department"] = "finance" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hostGroupName, data); @@ -146,9 +140,9 @@ public async Task Get_CreateADedicatedHostGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CreateADedicatedHostGroup() + public async Task Get_CreateAnUltraSSDEnabledDedicatedHostGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get_UltraSSDEnabledDedicatedHostGroup.json // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -168,17 +162,21 @@ public async Task Exists_CreateADedicatedHostGroup() // invoke the operation string hostGroupName = "myDedicatedHostGroup"; - bool result = await collection.ExistsAsync(hostGroupName); + DedicatedHostGroupResource result = await collection.GetAsync(hostGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHostGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CreateADedicatedHostGroup() + public async Task GetAll_DedicatedHostGroupListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get.json - // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "DedicatedHostGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,39 +185,33 @@ public async Task GetIfExists_CreateADedicatedHostGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this DedicatedHostGroupResource DedicatedHostGroupCollection collection = resourceGroupResource.GetDedicatedHostGroups(); - // invoke the operation - string hostGroupName = "myDedicatedHostGroup"; - NullableResponse response = await collection.GetIfExistsAsync(hostGroupName); - DedicatedHostGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DedicatedHostGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DedicatedHostGroupData resourceData = result.Data; + DedicatedHostGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CreateAnUltraSSDEnabledDedicatedHostGroup() + public async Task GetAll_DedicatedHostGroupListByResourceGroupMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get_UltraSSDEnabledDedicatedHostGroup.json - // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "DedicatedHostGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -228,30 +220,32 @@ public async Task Get_CreateAnUltraSSDEnabledDedicatedHostGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this DedicatedHostGroupResource DedicatedHostGroupCollection collection = resourceGroupResource.GetDedicatedHostGroups(); - // invoke the operation - string hostGroupName = "myDedicatedHostGroup"; - DedicatedHostGroupResource result = await collection.GetAsync(hostGroupName); + // invoke the operation and iterate over the result + await foreach (DedicatedHostGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHostGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHostGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CreateAnUltraSSDEnabledDedicatedHostGroup() + public async Task Exists_CreateADedicatedHostGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get_UltraSSDEnabledDedicatedHostGroup.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get.json // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -278,7 +272,7 @@ public async Task Exists_CreateAnUltraSSDEnabledDedicatedHostGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CreateAnUltraSSDEnabledDedicatedHostGroup() + public async Task Exists_CreateAnUltraSSDEnabledDedicatedHostGroup() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get_UltraSSDEnabledDedicatedHostGroup.json // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -300,29 +294,17 @@ public async Task GetIfExists_CreateAnUltraSSDEnabledDedicatedHostGroup() // invoke the operation string hostGroupName = "myDedicatedHostGroup"; - NullableResponse response = await collection.GetIfExistsAsync(hostGroupName); - DedicatedHostGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(hostGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHostGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DedicatedHostGroupListByResourceGroupMaximumSetGen() + public async Task GetIfExists_CreateADedicatedHostGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "DedicatedHostGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get.json + // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -331,33 +313,39 @@ public async Task GetAll_DedicatedHostGroupListByResourceGroupMaximumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this DedicatedHostGroupResource DedicatedHostGroupCollection collection = resourceGroupResource.GetDedicatedHostGroups(); - // invoke the operation and iterate over the result - await foreach (DedicatedHostGroupResource item in collection.GetAllAsync()) + // invoke the operation + string hostGroupName = "myDedicatedHostGroup"; + NullableResponse response = await collection.GetIfExistsAsync(hostGroupName); + DedicatedHostGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DedicatedHostGroupData resourceData = item.Data; + DedicatedHostGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DedicatedHostGroupListByResourceGroupMinimumSetGen() + public async Task GetIfExists_CreateAnUltraSSDEnabledDedicatedHostGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "DedicatedHostGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get_UltraSSDEnabledDedicatedHostGroup.json + // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -366,25 +354,31 @@ public async Task GetAll_DedicatedHostGroupListByResourceGroupMinimumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this DedicatedHostGroupResource DedicatedHostGroupCollection collection = resourceGroupResource.GetDedicatedHostGroups(); - // invoke the operation and iterate over the result - await foreach (DedicatedHostGroupResource item in collection.GetAllAsync()) + // invoke the operation + string hostGroupName = "myDedicatedHostGroup"; + NullableResponse response = await collection.GetIfExistsAsync(hostGroupName); + DedicatedHostGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DedicatedHostGroupData resourceData = item.Data; + DedicatedHostGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostGroupResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostGroupResource.cs index bb983e99b5ee5..2b886dc3304cf 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostGroupResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostGroupResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -19,10 +18,10 @@ public partial class Sample_DedicatedHostGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DedicatedHostGroupUpdateMaximumSetGen() + public async Task Get_CreateADedicatedHostGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Update_MaximumSet_Gen.json - // this example is just showing the usage of "DedicatedHostGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get.json + // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,27 +30,14 @@ public async Task Update_DedicatedHostGroupUpdateMaximumSetGen() // this example assumes you already have this DedicatedHostGroupResource created on azure // for more information of creating DedicatedHostGroupResource, please refer to the document of DedicatedHostGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string hostGroupName = "aaaa"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; + string hostGroupName = "myDedicatedHostGroup"; ResourceIdentifier dedicatedHostGroupResourceId = DedicatedHostGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName); DedicatedHostGroupResource dedicatedHostGroup = client.GetDedicatedHostGroupResource(dedicatedHostGroupResourceId); // invoke the operation - DedicatedHostGroupPatch patch = new DedicatedHostGroupPatch() - { - Zones = -{ -"aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -}, - PlatformFaultDomainCount = 3, - SupportAutomaticPlacement = true, - Tags = -{ -["key9921"] = "aaaaaaaaaa", -}, - }; - DedicatedHostGroupResource result = await dedicatedHostGroup.UpdateAsync(patch); + DedicatedHostGroupResource result = await dedicatedHostGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -62,10 +48,10 @@ public async Task Update_DedicatedHostGroupUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DedicatedHostGroupUpdateMinimumSetGen() + public async Task Get_CreateAnUltraSSDEnabledDedicatedHostGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Update_MinimumSet_Gen.json - // this example is just showing the usage of "DedicatedHostGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get_UltraSSDEnabledDedicatedHostGroup.json + // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +60,14 @@ public async Task Update_DedicatedHostGroupUpdateMinimumSetGen() // this example assumes you already have this DedicatedHostGroupResource created on azure // for more information of creating DedicatedHostGroupResource, please refer to the document of DedicatedHostGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string hostGroupName = "aaaaaaaaaaa"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; + string hostGroupName = "myDedicatedHostGroup"; ResourceIdentifier dedicatedHostGroupResourceId = DedicatedHostGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName); DedicatedHostGroupResource dedicatedHostGroup = client.GetDedicatedHostGroupResource(dedicatedHostGroupResourceId); // invoke the operation - DedicatedHostGroupPatch patch = new DedicatedHostGroupPatch(); - DedicatedHostGroupResource result = await dedicatedHostGroup.UpdateAsync(patch); + DedicatedHostGroupResource result = await dedicatedHostGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -145,10 +130,10 @@ public async Task Delete_DedicatedHostGroupDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CreateADedicatedHostGroup() + public async Task Update_DedicatedHostGroupUpdateMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get.json - // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Update_MaximumSet_Gen.json + // this example is just showing the usage of "DedicatedHostGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -157,14 +142,24 @@ public async Task Get_CreateADedicatedHostGroup() // this example assumes you already have this DedicatedHostGroupResource created on azure // for more information of creating DedicatedHostGroupResource, please refer to the document of DedicatedHostGroupResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; - string hostGroupName = "myDedicatedHostGroup"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string hostGroupName = "aaaa"; ResourceIdentifier dedicatedHostGroupResourceId = DedicatedHostGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName); DedicatedHostGroupResource dedicatedHostGroup = client.GetDedicatedHostGroupResource(dedicatedHostGroupResourceId); // invoke the operation - DedicatedHostGroupResource result = await dedicatedHostGroup.GetAsync(); + DedicatedHostGroupPatch patch = new DedicatedHostGroupPatch + { + Zones = { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" }, + PlatformFaultDomainCount = 3, + SupportAutomaticPlacement = true, + Tags = +{ +["key9921"] = "aaaaaaaaaa" +}, + }; + DedicatedHostGroupResource result = await dedicatedHostGroup.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -175,10 +170,10 @@ public async Task Get_CreateADedicatedHostGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CreateAnUltraSSDEnabledDedicatedHostGroup() + public async Task Update_DedicatedHostGroupUpdateMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Get_UltraSSDEnabledDedicatedHostGroup.json - // this example is just showing the usage of "DedicatedHostGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_Update_MinimumSet_Gen.json + // this example is just showing the usage of "DedicatedHostGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,14 +182,15 @@ public async Task Get_CreateAnUltraSSDEnabledDedicatedHostGroup() // this example assumes you already have this DedicatedHostGroupResource created on azure // for more information of creating DedicatedHostGroupResource, please refer to the document of DedicatedHostGroupResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; - string hostGroupName = "myDedicatedHostGroup"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string hostGroupName = "aaaaaaaaaaa"; ResourceIdentifier dedicatedHostGroupResourceId = DedicatedHostGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName); DedicatedHostGroupResource dedicatedHostGroup = client.GetDedicatedHostGroupResource(dedicatedHostGroupResourceId); // invoke the operation - DedicatedHostGroupResource result = await dedicatedHostGroup.GetAsync(); + DedicatedHostGroupPatch patch = new DedicatedHostGroupPatch(); + DedicatedHostGroupResource result = await dedicatedHostGroup.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -202,67 +198,5 @@ public async Task Get_CreateAnUltraSSDEnabledDedicatedHostGroup() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDedicatedHostGroups_DedicatedHostGroupListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "DedicatedHostGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DedicatedHostGroupResource item in subscriptionResource.GetDedicatedHostGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHostGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDedicatedHostGroups_DedicatedHostGroupListBySubscriptionMinimumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "DedicatedHostGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DedicatedHostGroupResource item in subscriptionResource.GetDedicatedHostGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHostGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostResource.cs index b29cb5a0ccfe7..672fac3511344 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DedicatedHostResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DedicatedHostResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DedicatedHostUpdateMaximumSetGen() + public async Task Get_GetADedicatedHost() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Update_MaximumSet_Gen.json - // this example is just showing the usage of "DedicatedHosts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Get.json + // this example is just showing the usage of "DedicatedHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,26 +30,16 @@ public async Task Update_DedicatedHostUpdateMaximumSetGen() // this example assumes you already have this DedicatedHostResource created on azure // for more information of creating DedicatedHostResource, please refer to the document of DedicatedHostResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string hostGroupName = "aaaaaaaaa"; - string hostName = "aaaaaaaaaaaaaaaaaaaaa"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; + string hostGroupName = "myDedicatedHostGroup"; + string hostName = "myHost"; ResourceIdentifier dedicatedHostResourceId = DedicatedHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName, hostName); DedicatedHostResource dedicatedHost = client.GetDedicatedHostResource(dedicatedHostResourceId); // invoke the operation - DedicatedHostPatch patch = new DedicatedHostPatch() - { - PlatformFaultDomain = 1, - AutoReplaceOnFailure = true, - LicenseType = DedicatedHostLicenseType.WindowsServerHybrid, - Tags = -{ -["key8813"] = "aaaaaaaaaaaaaaaaaaaaaaaaaaa", -}, - }; - ArmOperation lro = await dedicatedHost.UpdateAsync(WaitUntil.Completed, patch); - DedicatedHostResource result = lro.Value; + InstanceViewType? expand = InstanceViewType.InstanceView; + DedicatedHostResource result = await dedicatedHost.GetAsync(expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -60,10 +50,10 @@ public async Task Update_DedicatedHostUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DedicatedHostUpdateMinimumSetGen() + public async Task Delete_DedicatedHostDeleteMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Update_MinimumSet_Gen.json - // this example is just showing the usage of "DedicatedHosts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "DedicatedHosts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,29 +64,23 @@ public async Task Update_DedicatedHostUpdateMinimumSetGen() // for more information of creating DedicatedHostResource, please refer to the document of DedicatedHostResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string hostGroupName = "aa"; - string hostName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; + string hostGroupName = "aaaaaa"; + string hostName = "aaaaaaaaaaaaaaa"; ResourceIdentifier dedicatedHostResourceId = DedicatedHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName, hostName); DedicatedHostResource dedicatedHost = client.GetDedicatedHostResource(dedicatedHostResourceId); // invoke the operation - DedicatedHostPatch patch = new DedicatedHostPatch(); - ArmOperation lro = await dedicatedHost.UpdateAsync(WaitUntil.Completed, patch); - DedicatedHostResource result = lro.Value; + await dedicatedHost.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DedicatedHostUpdateResize() + public async Task Delete_DedicatedHostDeleteMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Update_Resize.json - // this example is just showing the usage of "DedicatedHosts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "DedicatedHosts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,35 +91,23 @@ public async Task Update_DedicatedHostUpdateResize() // for more information of creating DedicatedHostResource, please refer to the document of DedicatedHostResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string hostGroupName = "aaaaaaaaa"; - string hostName = "aaaaaaaaaaaaaaaaaaaaa"; + string hostGroupName = "aaaaaaaaaaaaaaa"; + string hostName = "aaaaa"; ResourceIdentifier dedicatedHostResourceId = DedicatedHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName, hostName); DedicatedHostResource dedicatedHost = client.GetDedicatedHostResource(dedicatedHostResourceId); // invoke the operation - DedicatedHostPatch patch = new DedicatedHostPatch() - { - Sku = new ComputeSku() - { - Name = "DSv3-Type1", - }, - }; - ArmOperation lro = await dedicatedHost.UpdateAsync(WaitUntil.Completed, patch); - DedicatedHostResource result = lro.Value; + await dedicatedHost.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DedicatedHostDeleteMaximumSetGen() + public async Task Update_DedicatedHostUpdateMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "DedicatedHosts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Update_MaximumSet_Gen.json + // this example is just showing the usage of "DedicatedHosts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,23 +118,38 @@ public async Task Delete_DedicatedHostDeleteMaximumSetGen() // for more information of creating DedicatedHostResource, please refer to the document of DedicatedHostResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string hostGroupName = "aaaaaa"; - string hostName = "aaaaaaaaaaaaaaa"; + string hostGroupName = "aaaaaaaaa"; + string hostName = "aaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier dedicatedHostResourceId = DedicatedHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName, hostName); DedicatedHostResource dedicatedHost = client.GetDedicatedHostResource(dedicatedHostResourceId); // invoke the operation - await dedicatedHost.DeleteAsync(WaitUntil.Completed); + DedicatedHostPatch patch = new DedicatedHostPatch + { + PlatformFaultDomain = 1, + AutoReplaceOnFailure = true, + LicenseType = DedicatedHostLicenseType.WindowsServerHybrid, + Tags = +{ +["key8813"] = "aaaaaaaaaaaaaaaaaaaaaaaaaaa" +}, + }; + ArmOperation lro = await dedicatedHost.UpdateAsync(WaitUntil.Completed, patch); + DedicatedHostResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DedicatedHostDeleteMinimumSetGen() + public async Task Update_DedicatedHostUpdateMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "DedicatedHosts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Update_MinimumSet_Gen.json + // this example is just showing the usage of "DedicatedHosts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,23 +160,29 @@ public async Task Delete_DedicatedHostDeleteMinimumSetGen() // for more information of creating DedicatedHostResource, please refer to the document of DedicatedHostResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string hostGroupName = "aaaaaaaaaaaaaaa"; - string hostName = "aaaaa"; + string hostGroupName = "aa"; + string hostName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier dedicatedHostResourceId = DedicatedHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName, hostName); DedicatedHostResource dedicatedHost = client.GetDedicatedHostResource(dedicatedHostResourceId); // invoke the operation - await dedicatedHost.DeleteAsync(WaitUntil.Completed); + DedicatedHostPatch patch = new DedicatedHostPatch(); + ArmOperation lro = await dedicatedHost.UpdateAsync(WaitUntil.Completed, patch); + DedicatedHostResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADedicatedHost() + public async Task Update_DedicatedHostUpdateResize() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Get.json - // this example is just showing the usage of "DedicatedHosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHost_Update_Resize.json + // this example is just showing the usage of "DedicatedHosts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,16 +191,23 @@ public async Task Get_GetADedicatedHost() // this example assumes you already have this DedicatedHostResource created on azure // for more information of creating DedicatedHostResource, please refer to the document of DedicatedHostResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; - string hostGroupName = "myDedicatedHostGroup"; - string hostName = "myHost"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string hostGroupName = "aaaaaaaaa"; + string hostName = "aaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier dedicatedHostResourceId = DedicatedHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostGroupName, hostName); DedicatedHostResource dedicatedHost = client.GetDedicatedHostResource(dedicatedHostResourceId); // invoke the operation - InstanceViewType? expand = InstanceViewType.InstanceView; - DedicatedHostResource result = await dedicatedHost.GetAsync(expand: expand); + DedicatedHostPatch patch = new DedicatedHostPatch + { + Sku = new ComputeSku + { + Name = "DSv3-Type1", + }, + }; + ArmOperation lro = await dedicatedHost.UpdateAsync(WaitUntil.Completed, patch); + DedicatedHostResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskAccessCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskAccessCollection.cs index 19d378a77473b..ea64c42966fdf 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskAccessCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskAccessCollection.cs @@ -86,9 +86,9 @@ public async Task Get_GetInformationAboutADiskAccessResourceWithPrivateEndpoints [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetInformationAboutADiskAccessResourceWithPrivateEndpoints() + public async Task Get_GetInformationAboutADiskAccessResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Get_WithPrivateEndpoints.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Get.json // this example is just showing the usage of "DiskAccesses_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -108,17 +108,21 @@ public async Task Exists_GetInformationAboutADiskAccessResourceWithPrivateEndpoi // invoke the operation string diskAccessName = "myDiskAccess"; - bool result = await collection.ExistsAsync(diskAccessName); + DiskAccessResource result = await collection.GetAsync(diskAccessName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskAccessData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInformationAboutADiskAccessResourceWithPrivateEndpoints() + public async Task GetAll_ListAllDiskAccessResourcesInAResourceGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Get_WithPrivateEndpoints.json - // this example is just showing the usage of "DiskAccesses_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_ListByResourceGroup.json + // this example is just showing the usage of "DiskAccesses_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,30 +139,24 @@ public async Task GetIfExists_GetInformationAboutADiskAccessResourceWithPrivateE // get the collection of this DiskAccessResource DiskAccessCollection collection = resourceGroupResource.GetDiskAccesses(); - // invoke the operation - string diskAccessName = "myDiskAccess"; - NullableResponse response = await collection.GetIfExistsAsync(diskAccessName); - DiskAccessResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DiskAccessResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DiskAccessData resourceData = result.Data; + DiskAccessData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInformationAboutADiskAccessResource() + public async Task Exists_GetInformationAboutADiskAccessResourceWithPrivateEndpoints() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Get_WithPrivateEndpoints.json // this example is just showing the usage of "DiskAccesses_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -178,13 +176,9 @@ public async Task Get_GetInformationAboutADiskAccessResource() // invoke the operation string diskAccessName = "myDiskAccess"; - DiskAccessResource result = await collection.GetAsync(diskAccessName); + bool result = await collection.ExistsAsync(diskAccessName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskAccessData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -218,9 +212,9 @@ public async Task Exists_GetInformationAboutADiskAccessResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInformationAboutADiskAccessResource() + public async Task GetIfExists_GetInformationAboutADiskAccessResourceWithPrivateEndpoints() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Get_WithPrivateEndpoints.json // this example is just showing the usage of "DiskAccesses_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -259,10 +253,10 @@ public async Task GetIfExists_GetInformationAboutADiskAccessResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllDiskAccessResourcesInAResourceGroup() + public async Task GetIfExists_GetInformationAboutADiskAccessResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_ListByResourceGroup.json - // this example is just showing the usage of "DiskAccesses_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Get.json + // this example is just showing the usage of "DiskAccesses_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -279,17 +273,23 @@ public async Task GetAll_ListAllDiskAccessResourcesInAResourceGroup() // get the collection of this DiskAccessResource DiskAccessCollection collection = resourceGroupResource.GetDiskAccesses(); - // invoke the operation and iterate over the result - await foreach (DiskAccessResource item in collection.GetAllAsync()) + // invoke the operation + string diskAccessName = "myDiskAccess"; + NullableResponse response = await collection.GetIfExistsAsync(diskAccessName); + DiskAccessResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DiskAccessData resourceData = item.Data; + DiskAccessData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskAccessResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskAccessResource.cs index f9f4c6d0362b2..da2a631ee0b8c 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskAccessResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskAccessResource.cs @@ -10,52 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples { public partial class Sample_DiskAccessResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateADiskAccessResource() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Update.json - // this example is just showing the usage of "DiskAccesses_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DiskAccessResource created on azure - // for more information of creating DiskAccessResource, please refer to the document of DiskAccessResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string diskAccessName = "myDiskAccess"; - ResourceIdentifier diskAccessResourceId = DiskAccessResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, diskAccessName); - DiskAccessResource diskAccess = client.GetDiskAccessResource(diskAccessResourceId); - - // invoke the operation - DiskAccessPatch patch = new DiskAccessPatch() - { - Tags = -{ -["department"] = "Development", -["project"] = "PrivateEndpoints", -}, - }; - ArmOperation lro = await diskAccess.UpdateAsync(WaitUntil.Completed, patch); - DiskAccessResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskAccessData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetInformationAboutADiskAccessResourceWithPrivateEndpoints() @@ -144,33 +104,41 @@ public async Task Delete_DeleteADiskAccessResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDiskAccesses_ListAllDiskAccessResourcesInASubscription() + public async Task Update_UpdateADiskAccessResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_ListBySubscription.json - // this example is just showing the usage of "DiskAccesses_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_Update.json + // this example is just showing the usage of "DiskAccesses_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this DiskAccessResource created on azure + // for more information of creating DiskAccessResource, please refer to the document of DiskAccessResource string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "myResourceGroup"; + string diskAccessName = "myDiskAccess"; + ResourceIdentifier diskAccessResourceId = DiskAccessResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, diskAccessName); + DiskAccessResource diskAccess = client.GetDiskAccessResource(diskAccessResourceId); - // invoke the operation and iterate over the result - await foreach (DiskAccessResource item in subscriptionResource.GetDiskAccessesAsync()) + // invoke the operation + DiskAccessPatch patch = new DiskAccessPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskAccessData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["department"] = "Development", +["project"] = "PrivateEndpoints" +}, + }; + ArmOperation lro = await diskAccess.UpdateAsync(WaitUntil.Completed, patch); + DiskAccessResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskAccessData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskEncryptionSetCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskEncryptionSetCollection.cs index a006db5cf3937..a34d53bccc474 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskEncryptionSetCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskEncryptionSetCollection.cs @@ -88,7 +88,7 @@ public async Task CreateOrUpdate_CreateADiskEncryptionSetWithKeyVaultFromADiffer { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}")] = new UserAssignedIdentity() }, }, EncryptionType = DiskEncryptionSetType.EncryptionAtRestWithCustomerKey, @@ -183,9 +183,9 @@ public async Task Get_GetInformationAboutADiskEncryptionSetWhenAutoKeyRotationFa [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetInformationAboutADiskEncryptionSetWhenAutoKeyRotationFailed() + public async Task Get_GetInformationAboutADiskEncryptionSet() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get_WithAutoKeyRotationError.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get.json // this example is just showing the usage of "DiskEncryptionSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -205,17 +205,21 @@ public async Task Exists_GetInformationAboutADiskEncryptionSetWhenAutoKeyRotatio // invoke the operation string diskEncryptionSetName = "myDiskEncryptionSet"; - bool result = await collection.ExistsAsync(diskEncryptionSetName); + DiskEncryptionSetResource result = await collection.GetAsync(diskEncryptionSetName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskEncryptionSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInformationAboutADiskEncryptionSetWhenAutoKeyRotationFailed() + public async Task GetAll_ListAllDiskEncryptionSetsInAResourceGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get_WithAutoKeyRotationError.json - // this example is just showing the usage of "DiskEncryptionSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_ListByResourceGroup.json + // this example is just showing the usage of "DiskEncryptionSets_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -232,30 +236,24 @@ public async Task GetIfExists_GetInformationAboutADiskEncryptionSetWhenAutoKeyRo // get the collection of this DiskEncryptionSetResource DiskEncryptionSetCollection collection = resourceGroupResource.GetDiskEncryptionSets(); - // invoke the operation - string diskEncryptionSetName = "myDiskEncryptionSet"; - NullableResponse response = await collection.GetIfExistsAsync(diskEncryptionSetName); - DiskEncryptionSetResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DiskEncryptionSetResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DiskEncryptionSetData resourceData = result.Data; + DiskEncryptionSetData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInformationAboutADiskEncryptionSet() + public async Task Exists_GetInformationAboutADiskEncryptionSetWhenAutoKeyRotationFailed() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get_WithAutoKeyRotationError.json // this example is just showing the usage of "DiskEncryptionSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -275,13 +273,9 @@ public async Task Get_GetInformationAboutADiskEncryptionSet() // invoke the operation string diskEncryptionSetName = "myDiskEncryptionSet"; - DiskEncryptionSetResource result = await collection.GetAsync(diskEncryptionSetName); + bool result = await collection.ExistsAsync(diskEncryptionSetName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskEncryptionSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -315,9 +309,9 @@ public async Task Exists_GetInformationAboutADiskEncryptionSet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInformationAboutADiskEncryptionSet() + public async Task GetIfExists_GetInformationAboutADiskEncryptionSetWhenAutoKeyRotationFailed() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get_WithAutoKeyRotationError.json // this example is just showing the usage of "DiskEncryptionSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -356,10 +350,10 @@ public async Task GetIfExists_GetInformationAboutADiskEncryptionSet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllDiskEncryptionSetsInAResourceGroup() + public async Task GetIfExists_GetInformationAboutADiskEncryptionSet() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_ListByResourceGroup.json - // this example is just showing the usage of "DiskEncryptionSets_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get.json + // this example is just showing the usage of "DiskEncryptionSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -376,17 +370,23 @@ public async Task GetAll_ListAllDiskEncryptionSetsInAResourceGroup() // get the collection of this DiskEncryptionSetResource DiskEncryptionSetCollection collection = resourceGroupResource.GetDiskEncryptionSets(); - // invoke the operation and iterate over the result - await foreach (DiskEncryptionSetResource item in collection.GetAllAsync()) + // invoke the operation + string diskEncryptionSetName = "myDiskEncryptionSet"; + NullableResponse response = await collection.GetIfExistsAsync(diskEncryptionSetName); + DiskEncryptionSetResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DiskEncryptionSetData resourceData = item.Data; + DiskEncryptionSetData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskEncryptionSetResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskEncryptionSetResource.cs index 5cf9bb0e27ba6..fa201cdcc34d0 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskEncryptionSetResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskEncryptionSetResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Compute.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -20,10 +19,10 @@ public partial class Sample_DiskEncryptionSetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateADiskEncryptionSetWithRotationToLatestKeyVersionEnabledSetToTrueSucceeded() + public async Task Get_GetInformationAboutADiskEncryptionSetWhenAutoKeyRotationFailed() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update_WithRotationToLatestKeyVersionEnabled.json - // this example is just showing the usage of "DiskEncryptionSets_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get_WithAutoKeyRotationError.json + // this example is just showing the usage of "DiskEncryptionSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,15 +38,7 @@ public async Task Update_UpdateADiskEncryptionSetWithRotationToLatestKeyVersionE DiskEncryptionSetResource diskEncryptionSet = client.GetDiskEncryptionSetResource(diskEncryptionSetResourceId); // invoke the operation - DiskEncryptionSetPatch patch = new DiskEncryptionSetPatch() - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - EncryptionType = DiskEncryptionSetType.EncryptionAtRestWithCustomerKey, - ActiveKey = new KeyForDiskEncryptionSet(new Uri("https://myvaultdifferentsub.vault-int.azure-int.net/keys/keyName/keyVersion1")), - RotationToLatestKeyVersionEnabled = true, - }; - ArmOperation lro = await diskEncryptionSet.UpdateAsync(WaitUntil.Completed, patch); - DiskEncryptionSetResource result = lro.Value; + DiskEncryptionSetResource result = await diskEncryptionSet.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +49,10 @@ public async Task Update_UpdateADiskEncryptionSetWithRotationToLatestKeyVersionE [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateADiskEncryptionSetWithRotationToLatestKeyVersionEnabledSetToTrueUpdating() + public async Task Get_GetInformationAboutADiskEncryptionSet() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update_WithRotationToLatestKeyVersionEnabledInProgress.json - // this example is just showing the usage of "DiskEncryptionSets_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get.json + // this example is just showing the usage of "DiskEncryptionSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +68,7 @@ public async Task Update_UpdateADiskEncryptionSetWithRotationToLatestKeyVersionE DiskEncryptionSetResource diskEncryptionSet = client.GetDiskEncryptionSetResource(diskEncryptionSetResourceId); // invoke the operation - DiskEncryptionSetPatch patch = new DiskEncryptionSetPatch() - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - EncryptionType = DiskEncryptionSetType.EncryptionAtRestWithCustomerKey, - ActiveKey = new KeyForDiskEncryptionSet(new Uri("https://myvaultdifferentsub.vault-int.azure-int.net/keys/keyName/keyVersion1")), - RotationToLatestKeyVersionEnabled = true, - }; - ArmOperation lro = await diskEncryptionSet.UpdateAsync(WaitUntil.Completed, patch); - DiskEncryptionSetResource result = lro.Value; + DiskEncryptionSetResource result = await diskEncryptionSet.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -96,10 +79,10 @@ public async Task Update_UpdateADiskEncryptionSetWithRotationToLatestKeyVersionE [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateADiskEncryptionSet() + public async Task Delete_DeleteADiskEncryptionSet() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update.json - // this example is just showing the usage of "DiskEncryptionSets_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Delete.json + // this example is just showing the usage of "DiskEncryptionSets_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,35 +98,17 @@ public async Task Update_UpdateADiskEncryptionSet() DiskEncryptionSetResource diskEncryptionSet = client.GetDiskEncryptionSetResource(diskEncryptionSetResourceId); // invoke the operation - DiskEncryptionSetPatch patch = new DiskEncryptionSetPatch() - { - Tags = -{ -["department"] = "Development", -["project"] = "Encryption", -}, - EncryptionType = DiskEncryptionSetType.EncryptionAtRestWithCustomerKey, - ActiveKey = new KeyForDiskEncryptionSet(new Uri("https://myvmvault.vault-int.azure-int.net/keys/keyName/keyVersion")) - { - SourceVaultId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVMVault"), - }, - }; - ArmOperation lro = await diskEncryptionSet.UpdateAsync(WaitUntil.Completed, patch); - DiskEncryptionSetResource result = lro.Value; + await diskEncryptionSet.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskEncryptionSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInformationAboutADiskEncryptionSetWhenAutoKeyRotationFailed() + public async Task Update_UpdateADiskEncryptionSetWithRotationToLatestKeyVersionEnabledSetToTrueSucceeded() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get_WithAutoKeyRotationError.json - // this example is just showing the usage of "DiskEncryptionSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update_WithRotationToLatestKeyVersionEnabled.json + // this example is just showing the usage of "DiskEncryptionSets_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -159,7 +124,15 @@ public async Task Get_GetInformationAboutADiskEncryptionSetWhenAutoKeyRotationFa DiskEncryptionSetResource diskEncryptionSet = client.GetDiskEncryptionSetResource(diskEncryptionSetResourceId); // invoke the operation - DiskEncryptionSetResource result = await diskEncryptionSet.GetAsync(); + DiskEncryptionSetPatch patch = new DiskEncryptionSetPatch + { + Identity = new ManagedServiceIdentity("SystemAssigned"), + EncryptionType = DiskEncryptionSetType.EncryptionAtRestWithCustomerKey, + ActiveKey = new KeyForDiskEncryptionSet(new Uri("https://myvaultdifferentsub.vault-int.azure-int.net/keys/keyName/keyVersion1")), + RotationToLatestKeyVersionEnabled = true, + }; + ArmOperation lro = await diskEncryptionSet.UpdateAsync(WaitUntil.Completed, patch); + DiskEncryptionSetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -170,10 +143,10 @@ public async Task Get_GetInformationAboutADiskEncryptionSetWhenAutoKeyRotationFa [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInformationAboutADiskEncryptionSet() + public async Task Update_UpdateADiskEncryptionSetWithRotationToLatestKeyVersionEnabledSetToTrueUpdating() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Get.json - // this example is just showing the usage of "DiskEncryptionSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update_WithRotationToLatestKeyVersionEnabledInProgress.json + // this example is just showing the usage of "DiskEncryptionSets_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,7 +162,15 @@ public async Task Get_GetInformationAboutADiskEncryptionSet() DiskEncryptionSetResource diskEncryptionSet = client.GetDiskEncryptionSetResource(diskEncryptionSetResourceId); // invoke the operation - DiskEncryptionSetResource result = await diskEncryptionSet.GetAsync(); + DiskEncryptionSetPatch patch = new DiskEncryptionSetPatch + { + Identity = new ManagedServiceIdentity("SystemAssigned"), + EncryptionType = DiskEncryptionSetType.EncryptionAtRestWithCustomerKey, + ActiveKey = new KeyForDiskEncryptionSet(new Uri("https://myvaultdifferentsub.vault-int.azure-int.net/keys/keyName/keyVersion1")), + RotationToLatestKeyVersionEnabled = true, + }; + ArmOperation lro = await diskEncryptionSet.UpdateAsync(WaitUntil.Completed, patch); + DiskEncryptionSetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -200,10 +181,10 @@ public async Task Get_GetInformationAboutADiskEncryptionSet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteADiskEncryptionSet() + public async Task Update_UpdateADiskEncryptionSet() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Delete.json - // this example is just showing the usage of "DiskEncryptionSets_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_Update.json + // this example is just showing the usage of "DiskEncryptionSets_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -219,40 +200,27 @@ public async Task Delete_DeleteADiskEncryptionSet() DiskEncryptionSetResource diskEncryptionSet = client.GetDiskEncryptionSetResource(diskEncryptionSetResourceId); // invoke the operation - await diskEncryptionSet.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDiskEncryptionSets_ListAllDiskEncryptionSetsInASubscription() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_ListBySubscription.json - // this example is just showing the usage of "DiskEncryptionSets_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DiskEncryptionSetResource item in subscriptionResource.GetDiskEncryptionSetsAsync()) + DiskEncryptionSetPatch patch = new DiskEncryptionSetPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskEncryptionSetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["department"] = "Development", +["project"] = "Encryption" +}, + EncryptionType = DiskEncryptionSetType.EncryptionAtRestWithCustomerKey, + ActiveKey = new KeyForDiskEncryptionSet(new Uri("https://myvmvault.vault-int.azure-int.net/keys/keyName/keyVersion")) + { + SourceVaultId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/myVMVault"), + }, + }; + ArmOperation lro = await diskEncryptionSet.UpdateAsync(WaitUntil.Completed, patch); + DiskEncryptionSetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskEncryptionSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskImageCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskImageCollection.cs index 8d68a60aa7775..bf66742ee4161 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskImageCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskImageCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateAVirtualMachineImageFromABlobWithDiskEncr string imageName = "myImage"; DiskImageData data = new DiskImageData(new AzureLocation("West US")) { - StorageProfile = new ImageStorageProfile() + StorageProfile = new ImageStorageProfile { OSDisk = new ImageOSDisk(SupportedOperatingSystemType.Linux, OperatingSystemStateType.Generalized) { @@ -88,7 +88,7 @@ public async Task CreateOrUpdate_CreateAVirtualMachineImageFromABlob() string imageName = "myImage"; DiskImageData data = new DiskImageData(new AzureLocation("West US")) { - StorageProfile = new ImageStorageProfile() + StorageProfile = new ImageStorageProfile { OSDisk = new ImageOSDisk(SupportedOperatingSystemType.Linux, OperatingSystemStateType.Generalized) { @@ -133,7 +133,7 @@ public async Task CreateOrUpdate_CreateAVirtualMachineImageFromAManagedDiskWithD string imageName = "myImage"; DiskImageData data = new DiskImageData(new AzureLocation("West US")) { - StorageProfile = new ImageStorageProfile() + StorageProfile = new ImageStorageProfile { OSDisk = new ImageOSDisk(SupportedOperatingSystemType.Linux, OperatingSystemStateType.Generalized) { @@ -178,7 +178,7 @@ public async Task CreateOrUpdate_CreateAVirtualMachineImageFromAManagedDisk() string imageName = "myImage"; DiskImageData data = new DiskImageData(new AzureLocation("West US")) { - StorageProfile = new ImageStorageProfile() + StorageProfile = new ImageStorageProfile { OSDisk = new ImageOSDisk(SupportedOperatingSystemType.Linux, OperatingSystemStateType.Generalized) { @@ -223,7 +223,7 @@ public async Task CreateOrUpdate_CreateAVirtualMachineImageFromASnapshotWithDisk string imageName = "myImage"; DiskImageData data = new DiskImageData(new AzureLocation("West US")) { - StorageProfile = new ImageStorageProfile() + StorageProfile = new ImageStorageProfile { OSDisk = new ImageOSDisk(SupportedOperatingSystemType.Linux, OperatingSystemStateType.Generalized) { @@ -268,7 +268,7 @@ public async Task CreateOrUpdate_CreateAVirtualMachineImageFromASnapshot() string imageName = "myImage"; DiskImageData data = new DiskImageData(new AzureLocation("West US")) { - StorageProfile = new ImageStorageProfile() + StorageProfile = new ImageStorageProfile { OSDisk = new ImageOSDisk(SupportedOperatingSystemType.Linux, OperatingSystemStateType.Generalized) { @@ -351,19 +351,16 @@ public async Task CreateOrUpdate_CreateAVirtualMachineImageThatIncludesADataDisk string imageName = "myImage"; DiskImageData data = new DiskImageData(new AzureLocation("West US")) { - StorageProfile = new ImageStorageProfile() + StorageProfile = new ImageStorageProfile { OSDisk = new ImageOSDisk(SupportedOperatingSystemType.Linux, OperatingSystemStateType.Generalized) { BlobUri = new Uri("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"), }, - DataDisks = -{ -new ImageDataDisk(1) + DataDisks = {new ImageDataDisk(1) { BlobUri = new Uri("https://mystorageaccount.blob.core.windows.net/dataimages/dataimage.vhd"), -} -}, +}}, ZoneResilient = false, }, }; @@ -403,19 +400,16 @@ public async Task CreateOrUpdate_CreateAVirtualMachineImageThatIncludesADataDisk string imageName = "myImage"; DiskImageData data = new DiskImageData(new AzureLocation("West US")) { - StorageProfile = new ImageStorageProfile() + StorageProfile = new ImageStorageProfile { OSDisk = new ImageOSDisk(SupportedOperatingSystemType.Linux, OperatingSystemStateType.Generalized) { ManagedDiskId = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myManagedDisk"), }, - DataDisks = -{ -new ImageDataDisk(1) + DataDisks = {new ImageDataDisk(1) { ManagedDiskId = new ResourceIdentifier("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myManagedDisk2"), -} -}, +}}, ZoneResilient = false, }, }; @@ -455,19 +449,16 @@ public async Task CreateOrUpdate_CreateAVirtualMachineImageThatIncludesADataDisk string imageName = "myImage"; DiskImageData data = new DiskImageData(new AzureLocation("West US")) { - StorageProfile = new ImageStorageProfile() + StorageProfile = new ImageStorageProfile { OSDisk = new ImageOSDisk(SupportedOperatingSystemType.Linux, OperatingSystemStateType.Generalized) { SnapshotId = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"), }, - DataDisks = -{ -new ImageDataDisk(1) + DataDisks = {new ImageDataDisk(1) { SnapshotId = new ResourceIdentifier("subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot2"), -} -}, +}}, ZoneResilient = true, }, }; @@ -516,10 +507,10 @@ public async Task Get_GetInformationAboutAVirtualMachineImage() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetInformationAboutAVirtualMachineImage() + public async Task GetAll_ListAllVirtualMachineImagesInAResourceGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_Get.json - // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_ListByResourceGroup.json + // this example is just showing the usage of "Images_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -536,16 +527,22 @@ public async Task Exists_GetInformationAboutAVirtualMachineImage() // get the collection of this DiskImageResource DiskImageCollection collection = resourceGroupResource.GetDiskImages(); - // invoke the operation - string imageName = "myImage"; - bool result = await collection.ExistsAsync(imageName); + // invoke the operation and iterate over the result + await foreach (DiskImageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInformationAboutAVirtualMachineImage() + public async Task Exists_GetInformationAboutAVirtualMachineImage() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_Get.json // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. @@ -567,29 +564,17 @@ public async Task GetIfExists_GetInformationAboutAVirtualMachineImage() // invoke the operation string imageName = "myImage"; - NullableResponse response = await collection.GetIfExistsAsync(imageName); - DiskImageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(imageName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllVirtualMachineImagesInAResourceGroup() + public async Task GetIfExists_GetInformationAboutAVirtualMachineImage() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_ListByResourceGroup.json - // this example is just showing the usage of "Images_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_Get.json + // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -606,17 +591,23 @@ public async Task GetAll_ListAllVirtualMachineImagesInAResourceGroup() // get the collection of this DiskImageResource DiskImageCollection collection = resourceGroupResource.GetDiskImages(); - // invoke the operation and iterate over the result - await foreach (DiskImageResource item in collection.GetAllAsync()) + // invoke the operation + string imageName = "myImage"; + NullableResponse response = await collection.GetIfExistsAsync(imageName); + DiskImageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DiskImageData resourceData = item.Data; + DiskImageData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskImageResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskImageResource.cs index 4b96364f677c5..4985aa10fcd9e 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskImageResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskImageResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -19,10 +18,10 @@ public partial class Sample_DiskImageResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesTagsOfAnImage() + public async Task Get_GetInformationAboutAVirtualMachineImage() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_Update.json - // this example is just showing the usage of "Images_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_Get.json + // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,7 @@ public async Task Update_UpdatesTagsOfAnImage() DiskImageResource diskImage = client.GetDiskImageResource(diskImageResourceId); // invoke the operation - DiskImagePatch patch = new DiskImagePatch() - { - SourceVirtualMachineId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM"), - HyperVGeneration = HyperVGeneration.V1, - Tags = -{ -["department"] = "HR", -}, - }; - ArmOperation lro = await diskImage.UpdateAsync(WaitUntil.Completed, patch); - DiskImageResource result = lro.Value; + DiskImageResource result = await diskImage.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -111,10 +100,10 @@ public async Task Delete_ImageDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInformationAboutAVirtualMachineImage() + public async Task Update_UpdatesTagsOfAnImage() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_Get.json - // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_Update.json + // this example is just showing the usage of "Images_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,7 +119,17 @@ public async Task Get_GetInformationAboutAVirtualMachineImage() DiskImageResource diskImage = client.GetDiskImageResource(diskImageResourceId); // invoke the operation - DiskImageResource result = await diskImage.GetAsync(); + DiskImagePatch patch = new DiskImagePatch + { + SourceVirtualMachineId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM"), + HyperVGeneration = HyperVGeneration.V1, + Tags = +{ +["department"] = "HR" +}, + }; + ArmOperation lro = await diskImage.UpdateAsync(WaitUntil.Completed, patch); + DiskImageResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -138,36 +137,5 @@ public async Task Get_GetInformationAboutAVirtualMachineImage() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDiskImages_ListAllVirtualMachineImagesInASubscription() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_ListBySubscription.json - // this example is just showing the usage of "Images_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DiskImageResource item in subscriptionResource.GetDiskImagesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskImageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskRestorePointCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskRestorePointCollection.cs index dccec20695af8..9a4019e76cd1d 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskRestorePointCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_DiskRestorePointCollection.cs @@ -52,9 +52,9 @@ public async Task Get_GetAnIncrementalDiskRestorePointResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnIncrementalDiskRestorePointResource() + public async Task Get_GetAnIncrementalDiskRestorePointWhenSourceResourceIsFromADifferentRegion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_Get_WhenSourceResourceIsFromDifferentRegion.json // this example is just showing the usage of "DiskRestorePoint_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -76,17 +76,21 @@ public async Task Exists_GetAnIncrementalDiskRestorePointResource() // invoke the operation string diskRestorePointName = "TestDisk45ceb03433006d1baee0_b70cd924-3362-4a80-93c2-9415eaa12745"; - bool result = await collection.ExistsAsync(diskRestorePointName); + DiskRestorePointResource result = await collection.GetAsync(diskRestorePointName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskRestorePointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnIncrementalDiskRestorePointResource() + public async Task GetAll_GetAnIncrementalDiskRestorePointResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_Get.json - // this example is just showing the usage of "DiskRestorePoint_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_ListByVmRestorePoint.json + // this example is just showing the usage of "DiskRestorePoint_ListByRestorePoint" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,30 +109,24 @@ public async Task GetIfExists_GetAnIncrementalDiskRestorePointResource() // get the collection of this DiskRestorePointResource DiskRestorePointCollection collection = restorePoint.GetDiskRestorePoints(); - // invoke the operation - string diskRestorePointName = "TestDisk45ceb03433006d1baee0_b70cd924-3362-4a80-93c2-9415eaa12745"; - NullableResponse response = await collection.GetIfExistsAsync(diskRestorePointName); - DiskRestorePointResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DiskRestorePointResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DiskRestorePointData resourceData = result.Data; + DiskRestorePointData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnIncrementalDiskRestorePointWhenSourceResourceIsFromADifferentRegion() + public async Task Exists_GetAnIncrementalDiskRestorePointResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_Get_WhenSourceResourceIsFromDifferentRegion.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_Get.json // this example is just showing the usage of "DiskRestorePoint_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -150,13 +148,9 @@ public async Task Get_GetAnIncrementalDiskRestorePointWhenSourceResourceIsFromAD // invoke the operation string diskRestorePointName = "TestDisk45ceb03433006d1baee0_b70cd924-3362-4a80-93c2-9415eaa12745"; - DiskRestorePointResource result = await collection.GetAsync(diskRestorePointName); + bool result = await collection.ExistsAsync(diskRestorePointName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskRestorePointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -192,9 +186,9 @@ public async Task Exists_GetAnIncrementalDiskRestorePointWhenSourceResourceIsFro [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnIncrementalDiskRestorePointWhenSourceResourceIsFromADifferentRegion() + public async Task GetIfExists_GetAnIncrementalDiskRestorePointResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_Get_WhenSourceResourceIsFromDifferentRegion.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_Get.json // this example is just showing the usage of "DiskRestorePoint_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -235,10 +229,10 @@ public async Task GetIfExists_GetAnIncrementalDiskRestorePointWhenSourceResource [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAnIncrementalDiskRestorePointResource() + public async Task GetIfExists_GetAnIncrementalDiskRestorePointWhenSourceResourceIsFromADifferentRegion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_ListByVmRestorePoint.json - // this example is just showing the usage of "DiskRestorePoint_ListByRestorePoint" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskRestorePointExamples/DiskRestorePoint_Get_WhenSourceResourceIsFromDifferentRegion.json + // this example is just showing the usage of "DiskRestorePoint_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -257,17 +251,23 @@ public async Task GetAll_GetAnIncrementalDiskRestorePointResource() // get the collection of this DiskRestorePointResource DiskRestorePointCollection collection = restorePoint.GetDiskRestorePoints(); - // invoke the operation and iterate over the result - await foreach (DiskRestorePointResource item in collection.GetAllAsync()) + // invoke the operation + string diskRestorePointName = "TestDisk45ceb03433006d1baee0_b70cd924-3362-4a80-93c2-9415eaa12745"; + NullableResponse response = await collection.GetIfExistsAsync(diskRestorePointName); + DiskRestorePointResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DiskRestorePointData resourceData = item.Data; + DiskRestorePointData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationCollection.cs index fe9edc6e07aa9..df3c0e7c3db2c 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationCollection.cs @@ -48,23 +48,17 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryApplication() PrivacyStatementUri = new Uri("myPrivacyStatementUri}"), ReleaseNoteUri = new Uri("myReleaseNoteUri"), SupportedOSType = SupportedOperatingSystemType.Windows, - CustomActions = -{ -new GalleryApplicationCustomAction("myCustomAction","myCustomActionScript") + CustomActions = {new GalleryApplicationCustomAction("myCustomAction", "myCustomActionScript") { Description = "This is the custom action description.", -Parameters = -{ -new GalleryApplicationCustomActionParameter("myCustomActionParameter") +Parameters = {new GalleryApplicationCustomActionParameter("myCustomActionParameter") { IsRequired = false, ParameterType = GalleryApplicationCustomActionParameterType.String, DefaultValue = "default value of parameter.", Description = "This is the description of the parameter", -} -}, -} -}, +}}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryApplicationName, data); GalleryApplicationResource result = lro.Value; @@ -112,10 +106,10 @@ public async Task Get_GetAGalleryApplication() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAGalleryApplication() + public async Task GetAll_ListGalleryApplicationsInAGallery() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Get.json - // this example is just showing the usage of "GalleryApplications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_ListByGallery.json + // this example is just showing the usage of "GalleryApplications_ListByGallery" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,16 +127,22 @@ public async Task Exists_GetAGalleryApplication() // get the collection of this GalleryApplicationResource GalleryApplicationCollection collection = gallery.GetGalleryApplications(); - // invoke the operation - string galleryApplicationName = "myGalleryApplicationName"; - bool result = await collection.ExistsAsync(galleryApplicationName); + // invoke the operation and iterate over the result + await foreach (GalleryApplicationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryApplicationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGalleryApplication() + public async Task Exists_GetAGalleryApplication() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Get.json // this example is just showing the usage of "GalleryApplications_Get" operation, for the dependent resources, they will have to be created separately. @@ -165,29 +165,17 @@ public async Task GetIfExists_GetAGalleryApplication() // invoke the operation string galleryApplicationName = "myGalleryApplicationName"; - NullableResponse response = await collection.GetIfExistsAsync(galleryApplicationName); - GalleryApplicationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(galleryApplicationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGalleryApplicationsInAGallery() + public async Task GetIfExists_GetAGalleryApplication() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_ListByGallery.json - // this example is just showing the usage of "GalleryApplications_ListByGallery" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Get.json + // this example is just showing the usage of "GalleryApplications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -205,17 +193,23 @@ public async Task GetAll_ListGalleryApplicationsInAGallery() // get the collection of this GalleryApplicationResource GalleryApplicationCollection collection = gallery.GetGalleryApplications(); - // invoke the operation and iterate over the result - await foreach (GalleryApplicationResource item in collection.GetAllAsync()) + // invoke the operation + string galleryApplicationName = "myGalleryApplicationName"; + NullableResponse response = await collection.GetIfExistsAsync(galleryApplicationName); + GalleryApplicationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GalleryApplicationData resourceData = item.Data; + GalleryApplicationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationResource.cs index 31eff80595aaa..24390b7a7f359 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GalleryApplicationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASimpleGalleryApplication() + public async Task Get_GetAGalleryApplication() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Update.json - // this example is just showing the usage of "GalleryApplications_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Get.json + // this example is just showing the usage of "GalleryApplications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,33 +38,7 @@ public async Task Update_UpdateASimpleGalleryApplication() GalleryApplicationResource galleryApplication = client.GetGalleryApplicationResource(galleryApplicationResourceId); // invoke the operation - GalleryApplicationPatch patch = new GalleryApplicationPatch() - { - Description = "This is the gallery application description.", - Eula = "This is the gallery application EULA.", - PrivacyStatementUri = new Uri("myPrivacyStatementUri}"), - ReleaseNoteUri = new Uri("myReleaseNoteUri"), - SupportedOSType = SupportedOperatingSystemType.Windows, - CustomActions = -{ -new GalleryApplicationCustomAction("myCustomAction","myCustomActionScript") -{ -Description = "This is the custom action description.", -Parameters = -{ -new GalleryApplicationCustomActionParameter("myCustomActionParameter") -{ -IsRequired = false, -ParameterType = GalleryApplicationCustomActionParameterType.String, -DefaultValue = "default value of parameter.", -Description = "This is the description of the parameter", -} -}, -} -}, - }; - ArmOperation lro = await galleryApplication.UpdateAsync(WaitUntil.Completed, patch); - GalleryApplicationResource result = lro.Value; + GalleryApplicationResource result = await galleryApplication.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -75,10 +49,10 @@ public async Task Update_UpdateASimpleGalleryApplication() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryApplication() + public async Task Delete_DeleteAGalleryApplication() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Get.json - // this example is just showing the usage of "GalleryApplications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Delete.json + // this example is just showing the usage of "GalleryApplications_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,21 +69,17 @@ public async Task Get_GetAGalleryApplication() GalleryApplicationResource galleryApplication = client.GetGalleryApplicationResource(galleryApplicationResourceId); // invoke the operation - GalleryApplicationResource result = await galleryApplication.GetAsync(); + await galleryApplication.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAGalleryApplication() + public async Task Update_UpdateASimpleGalleryApplication() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Delete.json - // this example is just showing the usage of "GalleryApplications_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplication_Update.json + // this example is just showing the usage of "GalleryApplications_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -126,9 +96,33 @@ public async Task Delete_DeleteAGalleryApplication() GalleryApplicationResource galleryApplication = client.GetGalleryApplicationResource(galleryApplicationResourceId); // invoke the operation - await galleryApplication.DeleteAsync(WaitUntil.Completed); + GalleryApplicationPatch patch = new GalleryApplicationPatch + { + Description = "This is the gallery application description.", + Eula = "This is the gallery application EULA.", + PrivacyStatementUri = new Uri("myPrivacyStatementUri}"), + ReleaseNoteUri = new Uri("myReleaseNoteUri"), + SupportedOSType = SupportedOperatingSystemType.Windows, + CustomActions = {new GalleryApplicationCustomAction("myCustomAction", "myCustomActionScript") +{ +Description = "This is the custom action description.", +Parameters = {new GalleryApplicationCustomActionParameter("myCustomActionParameter") +{ +IsRequired = false, +ParameterType = GalleryApplicationCustomActionParameterType.String, +DefaultValue = "default value of parameter.", +Description = "This is the description of the parameter", +}}, +}}, + }; + ArmOperation lro = await galleryApplication.UpdateAsync(WaitUntil.Completed, patch); + GalleryApplicationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationVersionCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationVersionCollection.cs index e0e54dbcb65ac..0eb5a61bb4348 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationVersionCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationVersionCollection.cs @@ -47,32 +47,23 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryApplicationVersion( PublishingProfile = new GalleryApplicationVersionPublishingProfile(new UserArtifactSource("https://mystorageaccount.blob.core.windows.net/mycontainer/package.zip?{sasKey}")) { ManageActions = new UserArtifactManagement("powershell -command \"Expand-Archive -Path package.zip -DestinationPath C:\\package\"", "del C:\\package "), - CustomActions = -{ -new GalleryApplicationCustomAction("myCustomAction","myCustomActionScript") + CustomActions = {new GalleryApplicationCustomAction("myCustomAction", "myCustomActionScript") { Description = "This is the custom action description.", -Parameters = -{ -new GalleryApplicationCustomActionParameter("myCustomActionParameter") +Parameters = {new GalleryApplicationCustomActionParameter("myCustomActionParameter") { IsRequired = false, ParameterType = GalleryApplicationCustomActionParameterType.String, DefaultValue = "default value of parameter.", Description = "This is the description of the parameter", -} -}, -} -}, - TargetRegions = -{ -new TargetRegion("West US") +}}, +}}, + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 1, StorageAccountType = ImageStorageAccountType.StandardLrs, IsExcludedFromLatest = false, -} -}, +}}, ReplicaCount = 1, EndOfLifeOn = DateTimeOffset.Parse("2019-07-01T07:00:00Z"), StorageAccountType = ImageStorageAccountType.StandardLrs, @@ -127,9 +118,9 @@ public async Task Get_GetAGalleryApplicationVersionWithReplicationStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAGalleryApplicationVersionWithReplicationStatus() + public async Task Get_GetAGalleryApplicationVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get_WithReplicationStatus.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get.json // this example is just showing the usage of "GalleryApplicationVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -151,18 +142,21 @@ public async Task Exists_GetAGalleryApplicationVersionWithReplicationStatus() // invoke the operation string galleryApplicationVersionName = "1.0.0"; - ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; - bool result = await collection.ExistsAsync(galleryApplicationVersionName, expand: expand); + GalleryApplicationVersionResource result = await collection.GetAsync(galleryApplicationVersionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryApplicationVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGalleryApplicationVersionWithReplicationStatus() + public async Task GetAll_ListGalleryApplicationVersionsInAGalleryApplicationDefinition() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get_WithReplicationStatus.json - // this example is just showing the usage of "GalleryApplicationVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_ListByGalleryApplication.json + // this example is just showing the usage of "GalleryApplicationVersions_ListByGalleryApplication" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,31 +175,24 @@ public async Task GetIfExists_GetAGalleryApplicationVersionWithReplicationStatus // get the collection of this GalleryApplicationVersionResource GalleryApplicationVersionCollection collection = galleryApplication.GetGalleryApplicationVersions(); - // invoke the operation - string galleryApplicationVersionName = "1.0.0"; - ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; - NullableResponse response = await collection.GetIfExistsAsync(galleryApplicationVersionName, expand: expand); - GalleryApplicationVersionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (GalleryApplicationVersionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GalleryApplicationVersionData resourceData = result.Data; + GalleryApplicationVersionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryApplicationVersion() + public async Task Exists_GetAGalleryApplicationVersionWithReplicationStatus() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get_WithReplicationStatus.json // this example is just showing the usage of "GalleryApplicationVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -227,13 +214,10 @@ public async Task Get_GetAGalleryApplicationVersion() // invoke the operation string galleryApplicationVersionName = "1.0.0"; - GalleryApplicationVersionResource result = await collection.GetAsync(galleryApplicationVersionName); + ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; + bool result = await collection.ExistsAsync(galleryApplicationVersionName, expand: expand); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryApplicationVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -269,9 +253,9 @@ public async Task Exists_GetAGalleryApplicationVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGalleryApplicationVersion() + public async Task GetIfExists_GetAGalleryApplicationVersionWithReplicationStatus() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get_WithReplicationStatus.json // this example is just showing the usage of "GalleryApplicationVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -293,7 +277,8 @@ public async Task GetIfExists_GetAGalleryApplicationVersion() // invoke the operation string galleryApplicationVersionName = "1.0.0"; - NullableResponse response = await collection.GetIfExistsAsync(galleryApplicationVersionName); + ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; + NullableResponse response = await collection.GetIfExistsAsync(galleryApplicationVersionName, expand: expand); GalleryApplicationVersionResource result = response.HasValue ? response.Value : null; if (result == null) @@ -312,10 +297,10 @@ public async Task GetIfExists_GetAGalleryApplicationVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGalleryApplicationVersionsInAGalleryApplicationDefinition() + public async Task GetIfExists_GetAGalleryApplicationVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_ListByGalleryApplication.json - // this example is just showing the usage of "GalleryApplicationVersions_ListByGalleryApplication" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get.json + // this example is just showing the usage of "GalleryApplicationVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -334,17 +319,23 @@ public async Task GetAll_ListGalleryApplicationVersionsInAGalleryApplicationDefi // get the collection of this GalleryApplicationVersionResource GalleryApplicationVersionCollection collection = galleryApplication.GetGalleryApplicationVersions(); - // invoke the operation and iterate over the result - await foreach (GalleryApplicationVersionResource item in collection.GetAllAsync()) + // invoke the operation + string galleryApplicationVersionName = "1.0.0"; + NullableResponse response = await collection.GetIfExistsAsync(galleryApplicationVersionName); + GalleryApplicationVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GalleryApplicationVersionData resourceData = item.Data; + GalleryApplicationVersionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationVersionResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationVersionResource.cs index eacdd2aecd138..aa6ea73b310e6 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationVersionResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryApplicationVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GalleryApplicationVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASimpleGalleryApplicationVersion() + public async Task Get_GetAGalleryApplicationVersionWithReplicationStatus() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Update.json - // this example is just showing the usage of "GalleryApplicationVersions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get_WithReplicationStatus.json + // this example is just showing the usage of "GalleryApplicationVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,28 +39,8 @@ public async Task Update_UpdateASimpleGalleryApplicationVersion() GalleryApplicationVersionResource galleryApplicationVersion = client.GetGalleryApplicationVersionResource(galleryApplicationVersionResourceId); // invoke the operation - GalleryApplicationVersionPatch patch = new GalleryApplicationVersionPatch() - { - PublishingProfile = new GalleryApplicationVersionPublishingProfile(new UserArtifactSource("https://mystorageaccount.blob.core.windows.net/mycontainer/package.zip?{sasKey}")) - { - ManageActions = new UserArtifactManagement("powershell -command \"Expand-Archive -Path package.zip -DestinationPath C:\\package\"", "del C:\\package "), - TargetRegions = -{ -new TargetRegion("West US") -{ -RegionalReplicaCount = 1, -StorageAccountType = ImageStorageAccountType.StandardLrs, -IsExcludedFromLatest = false, -} -}, - ReplicaCount = 1, - EndOfLifeOn = DateTimeOffset.Parse("2019-07-01T07:00:00Z"), - StorageAccountType = ImageStorageAccountType.StandardLrs, - }, - AllowDeletionOfReplicatedLocations = false, - }; - ArmOperation lro = await galleryApplicationVersion.UpdateAsync(WaitUntil.Completed, patch); - GalleryApplicationVersionResource result = lro.Value; + ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; + GalleryApplicationVersionResource result = await galleryApplicationVersion.GetAsync(expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -71,9 +51,9 @@ public async Task Update_UpdateASimpleGalleryApplicationVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryApplicationVersionWithReplicationStatus() + public async Task Get_GetAGalleryApplicationVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get_WithReplicationStatus.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get.json // this example is just showing the usage of "GalleryApplicationVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -92,8 +72,7 @@ public async Task Get_GetAGalleryApplicationVersionWithReplicationStatus() GalleryApplicationVersionResource galleryApplicationVersion = client.GetGalleryApplicationVersionResource(galleryApplicationVersionResourceId); // invoke the operation - ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; - GalleryApplicationVersionResource result = await galleryApplicationVersion.GetAsync(expand: expand); + GalleryApplicationVersionResource result = await galleryApplicationVersion.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -104,10 +83,10 @@ public async Task Get_GetAGalleryApplicationVersionWithReplicationStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryApplicationVersion() + public async Task Delete_DeleteAGalleryApplicationVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Get.json - // this example is just showing the usage of "GalleryApplicationVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Delete.json + // this example is just showing the usage of "GalleryApplicationVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,21 +104,17 @@ public async Task Get_GetAGalleryApplicationVersion() GalleryApplicationVersionResource galleryApplicationVersion = client.GetGalleryApplicationVersionResource(galleryApplicationVersionResourceId); // invoke the operation - GalleryApplicationVersionResource result = await galleryApplicationVersion.GetAsync(); + await galleryApplicationVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryApplicationVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAGalleryApplicationVersion() + public async Task Update_UpdateASimpleGalleryApplicationVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Delete.json - // this example is just showing the usage of "GalleryApplicationVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryApplicationVersion_Update.json + // this example is just showing the usage of "GalleryApplicationVersions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -157,9 +132,31 @@ public async Task Delete_DeleteAGalleryApplicationVersion() GalleryApplicationVersionResource galleryApplicationVersion = client.GetGalleryApplicationVersionResource(galleryApplicationVersionResourceId); // invoke the operation - await galleryApplicationVersion.DeleteAsync(WaitUntil.Completed); + GalleryApplicationVersionPatch patch = new GalleryApplicationVersionPatch + { + PublishingProfile = new GalleryApplicationVersionPublishingProfile(new UserArtifactSource("https://mystorageaccount.blob.core.windows.net/mycontainer/package.zip?{sasKey}")) + { + ManageActions = new UserArtifactManagement("powershell -command \"Expand-Archive -Path package.zip -DestinationPath C:\\package\"", "del C:\\package "), + TargetRegions = {new TargetRegion("West US") +{ +RegionalReplicaCount = 1, +StorageAccountType = ImageStorageAccountType.StandardLrs, +IsExcludedFromLatest = false, +}}, + ReplicaCount = 1, + EndOfLifeOn = DateTimeOffset.Parse("2019-07-01T07:00:00Z"), + StorageAccountType = ImageStorageAccountType.StandardLrs, + }, + AllowDeletionOfReplicatedLocations = false, + }; + ArmOperation lro = await galleryApplicationVersion.UpdateAsync(WaitUntil.Completed, patch); + GalleryApplicationVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryApplicationVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryCollection.cs index ee95006ffe80b..bfd6f7aa95e58 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryCollection.cs @@ -44,10 +44,10 @@ public async Task CreateOrUpdate_CreateACommunityGallery() GalleryData data = new GalleryData(new AzureLocation("West US")) { Description = "This is the gallery description.", - SharingProfile = new SharingProfile() + SharingProfile = new SharingProfile { Permission = GallerySharingPermissionType.Community, - CommunityGalleryInfo = new CommunityGalleryInfo() + CommunityGalleryInfo = new CommunityGalleryInfo { PublisherUriString = "uri", PublisherContact = "pir@microsoft.com", @@ -93,7 +93,7 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryWithSharingProfile( GalleryData data = new GalleryData(new AzureLocation("West US")) { Description = "This is the gallery description.", - SharingProfile = new SharingProfile() + SharingProfile = new SharingProfile { Permission = GallerySharingPermissionType.Groups, }, @@ -220,9 +220,9 @@ public async Task Get_GetACommunityGallery() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACommunityGallery() + public async Task Get_GetAGalleryWithExpandSharingProfileGroups() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/CommunityGallery_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.json // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -242,16 +242,21 @@ public async Task Exists_GetACommunityGallery() // invoke the operation string galleryName = "myGalleryName"; - bool result = await collection.ExistsAsync(galleryName); + GalleryExpand? expand = GalleryExpand.SharingProfileGroups; + GalleryResource result = await collection.GetAsync(galleryName, expand: expand); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACommunityGallery() + public async Task Get_GetAGalleryWithSelectPermissions() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/CommunityGallery_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithSelectPermissions.json // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -271,28 +276,21 @@ public async Task GetIfExists_GetACommunityGallery() // invoke the operation string galleryName = "myGalleryName"; - NullableResponse response = await collection.GetIfExistsAsync(galleryName); - GalleryResource result = response.HasValue ? response.Value : null; + SelectPermission? select = SelectPermission.Permissions; + GalleryResource result = await collection.GetAsync(galleryName, select: select); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryWithExpandSharingProfileGroups() + public async Task Get_GetAGallery() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get.json // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -312,8 +310,7 @@ public async Task Get_GetAGalleryWithExpandSharingProfileGroups() // invoke the operation string galleryName = "myGalleryName"; - GalleryExpand? expand = GalleryExpand.SharingProfileGroups; - GalleryResource result = await collection.GetAsync(galleryName, expand: expand); + GalleryResource result = await collection.GetAsync(galleryName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -324,10 +321,10 @@ public async Task Get_GetAGalleryWithExpandSharingProfileGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAGalleryWithExpandSharingProfileGroups() + public async Task GetAll_ListGalleriesInAResourceGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.json - // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_ListByResourceGroup.json + // this example is just showing the usage of "Galleries_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -344,19 +341,24 @@ public async Task Exists_GetAGalleryWithExpandSharingProfileGroups() // get the collection of this GalleryResource GalleryCollection collection = resourceGroupResource.GetGalleries(); - // invoke the operation - string galleryName = "myGalleryName"; - GalleryExpand? expand = GalleryExpand.SharingProfileGroups; - bool result = await collection.ExistsAsync(galleryName, expand: expand); + // invoke the operation and iterate over the result + await foreach (GalleryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGalleryWithExpandSharingProfileGroups() + public async Task Exists_GetACommunityGallery() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/CommunityGallery_Get.json // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -376,29 +378,16 @@ public async Task GetIfExists_GetAGalleryWithExpandSharingProfileGroups() // invoke the operation string galleryName = "myGalleryName"; - GalleryExpand? expand = GalleryExpand.SharingProfileGroups; - NullableResponse response = await collection.GetIfExistsAsync(galleryName, expand: expand); - GalleryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(galleryName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryWithSelectPermissions() + public async Task Exists_GetAGalleryWithExpandSharingProfileGroups() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithSelectPermissions.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.json // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -418,14 +407,10 @@ public async Task Get_GetAGalleryWithSelectPermissions() // invoke the operation string galleryName = "myGalleryName"; - SelectPermission? select = SelectPermission.Permissions; - GalleryResource result = await collection.GetAsync(galleryName, select: select); + GalleryExpand? expand = GalleryExpand.SharingProfileGroups; + bool result = await collection.ExistsAsync(galleryName, expand: expand); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -460,9 +445,9 @@ public async Task Exists_GetAGalleryWithSelectPermissions() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGalleryWithSelectPermissions() + public async Task Exists_GetAGallery() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithSelectPermissions.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get.json // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -482,29 +467,16 @@ public async Task GetIfExists_GetAGalleryWithSelectPermissions() // invoke the operation string galleryName = "myGalleryName"; - SelectPermission? select = SelectPermission.Permissions; - NullableResponse response = await collection.GetIfExistsAsync(galleryName, select: select); - GalleryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(galleryName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGallery() + public async Task GetIfExists_GetACommunityGallery() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/CommunityGallery_Get.json // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -524,20 +496,28 @@ public async Task Get_GetAGallery() // invoke the operation string galleryName = "myGalleryName"; - GalleryResource result = await collection.GetAsync(galleryName); + NullableResponse response = await collection.GetIfExistsAsync(galleryName); + GalleryResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAGallery() + public async Task GetIfExists_GetAGalleryWithExpandSharingProfileGroups() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithExpandSharingProfileGroups.json // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -557,16 +537,29 @@ public async Task Exists_GetAGallery() // invoke the operation string galleryName = "myGalleryName"; - bool result = await collection.ExistsAsync(galleryName); + GalleryExpand? expand = GalleryExpand.SharingProfileGroups; + NullableResponse response = await collection.GetIfExistsAsync(galleryName, expand: expand); + GalleryResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGallery() + public async Task GetIfExists_GetAGalleryWithSelectPermissions() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get_WithSelectPermissions.json // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -586,7 +579,8 @@ public async Task GetIfExists_GetAGallery() // invoke the operation string galleryName = "myGalleryName"; - NullableResponse response = await collection.GetIfExistsAsync(galleryName); + SelectPermission? select = SelectPermission.Permissions; + NullableResponse response = await collection.GetIfExistsAsync(galleryName, select: select); GalleryResource result = response.HasValue ? response.Value : null; if (result == null) @@ -605,10 +599,10 @@ public async Task GetIfExists_GetAGallery() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGalleriesInAResourceGroup() + public async Task GetIfExists_GetAGallery() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_ListByResourceGroup.json - // this example is just showing the usage of "Galleries_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Get.json + // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -625,17 +619,23 @@ public async Task GetAll_ListGalleriesInAResourceGroup() // get the collection of this GalleryResource GalleryCollection collection = resourceGroupResource.GetGalleries(); - // invoke the operation and iterate over the result - await foreach (GalleryResource item in collection.GetAllAsync()) + // invoke the operation + string galleryName = "myGalleryName"; + NullableResponse response = await collection.GetIfExistsAsync(galleryName); + GalleryResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GalleryData resourceData = item.Data; + GalleryData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageCollection.cs index 23fee20d2de2c..9cc9aa26e79aa 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageCollection.cs @@ -94,10 +94,10 @@ public async Task Get_GetAGalleryImage() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAGalleryImage() + public async Task GetAll_ListGalleryImagesInAGallery() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Get.json - // this example is just showing the usage of "GalleryImages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_ListByGallery.json + // this example is just showing the usage of "GalleryImages_ListByGallery" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +115,22 @@ public async Task Exists_GetAGalleryImage() // get the collection of this GalleryImageResource GalleryImageCollection collection = gallery.GetGalleryImages(); - // invoke the operation - string galleryImageName = "myGalleryImageName"; - bool result = await collection.ExistsAsync(galleryImageName); + // invoke the operation and iterate over the result + await foreach (GalleryImageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGalleryImage() + public async Task Exists_GetAGalleryImage() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Get.json // this example is just showing the usage of "GalleryImages_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,29 +153,17 @@ public async Task GetIfExists_GetAGalleryImage() // invoke the operation string galleryImageName = "myGalleryImageName"; - NullableResponse response = await collection.GetIfExistsAsync(galleryImageName); - GalleryImageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(galleryImageName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGalleryImagesInAGallery() + public async Task GetIfExists_GetAGalleryImage() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_ListByGallery.json - // this example is just showing the usage of "GalleryImages_ListByGallery" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Get.json + // this example is just showing the usage of "GalleryImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +181,23 @@ public async Task GetAll_ListGalleryImagesInAGallery() // get the collection of this GalleryImageResource GalleryImageCollection collection = gallery.GetGalleryImages(); - // invoke the operation and iterate over the result - await foreach (GalleryImageResource item in collection.GetAllAsync()) + // invoke the operation + string galleryImageName = "myGalleryImageName"; + NullableResponse response = await collection.GetIfExistsAsync(galleryImageName); + GalleryImageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GalleryImageData resourceData = item.Data; + GalleryImageData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageResource.cs index d124fbc60bea6..dd6834e39e85e 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GalleryImageResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASimpleGalleryImage() + public async Task Get_GetAGalleryImage() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Update.json - // this example is just showing the usage of "GalleryImages_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Get.json + // this example is just showing the usage of "GalleryImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_UpdateASimpleGalleryImage() GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId); // invoke the operation - GalleryImagePatch patch = new GalleryImagePatch() - { - OSType = SupportedOperatingSystemType.Windows, - OSState = OperatingSystemStateType.Generalized, - HyperVGeneration = HyperVGeneration.V1, - Identifier = new GalleryImageIdentifier("myPublisherName", "myOfferName", "mySkuName"), - }; - ArmOperation lro = await galleryImage.UpdateAsync(WaitUntil.Completed, patch); - GalleryImageResource result = lro.Value; + GalleryImageResource result = await galleryImage.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +49,10 @@ public async Task Update_UpdateASimpleGalleryImage() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryImage() + public async Task Delete_DeleteAGalleryImage() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Get.json - // this example is just showing the usage of "GalleryImages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Delete.json + // this example is just showing the usage of "GalleryImages_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,21 +69,17 @@ public async Task Get_GetAGalleryImage() GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId); // invoke the operation - GalleryImageResource result = await galleryImage.GetAsync(); + await galleryImage.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAGalleryImage() + public async Task Update_UpdateASimpleGalleryImage() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Delete.json - // this example is just showing the usage of "GalleryImages_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImage_Update.json + // this example is just showing the usage of "GalleryImages_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DeleteAGalleryImage() GalleryImageResource galleryImage = client.GetGalleryImageResource(galleryImageResourceId); // invoke the operation - await galleryImage.DeleteAsync(WaitUntil.Completed); + GalleryImagePatch patch = new GalleryImagePatch + { + OSType = SupportedOperatingSystemType.Windows, + OSState = OperatingSystemStateType.Generalized, + HyperVGeneration = HyperVGeneration.V1, + Identifier = new GalleryImageIdentifier("myPublisherName", "myOfferName", "mySkuName"), + }; + ArmOperation lro = await galleryImage.UpdateAsync(WaitUntil.Completed, patch); + GalleryImageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageVersionCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageVersionCollection.cs index 3fd01e934a393..0d13eab4e3cf3 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageVersionCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageVersionCollection.cs @@ -44,64 +44,55 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryImageVersionUsingVM string galleryImageVersionName = "1.0.0"; GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US")) { - PublishingProfile = new GalleryImageVersionPublishingProfile() + PublishingProfile = new GalleryImageVersionPublishingProfile { - TargetRegions = -{ -new TargetRegion("West US") + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 2, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(0) +DataDiskImages = {new DataDiskImageEncryption(0) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"), -},new DataDiskImageEncryption(1) +}, new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -},new TargetRegion("East US") +}, new TargetRegion("East US") { RegionalReplicaCount = 2, StorageAccountType = ImageStorageAccountType.StandardZrs, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(0) +DataDiskImages = {new DataDiskImageEncryption(0) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"), -},new DataDiskImageEncryption(1) +}, new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -} -}, +}}, }, - StorageProfile = new GalleryImageVersionStorageProfile() + StorageProfile = new GalleryImageVersionStorageProfile { - GallerySource = new GalleryArtifactVersionFullSource() + GallerySource = new GalleryArtifactVersionFullSource { VirtualMachineId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmName}"), }, }, - SafetyProfile = new GalleryImageVersionSafetyProfile() + SafetyProfile = new GalleryImageVersionSafetyProfile { AllowDeletionOfReplicatedLocations = false, }, @@ -144,64 +135,55 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryImageVersionUsingCo string galleryImageVersionName = "1.0.0"; GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US")) { - PublishingProfile = new GalleryImageVersionPublishingProfile() + PublishingProfile = new GalleryImageVersionPublishingProfile { - TargetRegions = -{ -new TargetRegion("West US") + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 1, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(0) +DataDiskImages = {new DataDiskImageEncryption(0) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"), -},new DataDiskImageEncryption(1) +}, new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -},new TargetRegion("East US") +}, new TargetRegion("East US") { RegionalReplicaCount = 2, StorageAccountType = ImageStorageAccountType.StandardZrs, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(0) +DataDiskImages = {new DataDiskImageEncryption(0) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"), -},new DataDiskImageEncryption(1) +}, new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -} -}, +}}, }, - StorageProfile = new GalleryImageVersionStorageProfile() + StorageProfile = new GalleryImageVersionStorageProfile { - GallerySource = new GalleryArtifactVersionFullSource() + GallerySource = new GalleryArtifactVersionFullSource { CommunityGalleryImageId = "/communityGalleries/{communityGalleryName}/images/{communityGalleryImageName}", }, }, - SafetyProfile = new GalleryImageVersionSafetyProfile() + SafetyProfile = new GalleryImageVersionSafetyProfile { AllowDeletionOfReplicatedLocations = false, }, @@ -244,64 +226,55 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryImageVersionUsingMa string galleryImageVersionName = "1.0.0"; GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US")) { - PublishingProfile = new GalleryImageVersionPublishingProfile() + PublishingProfile = new GalleryImageVersionPublishingProfile { - TargetRegions = -{ -new TargetRegion("West US") + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 1, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(0) +DataDiskImages = {new DataDiskImageEncryption(0) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"), -},new DataDiskImageEncryption(1) +}, new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -},new TargetRegion("East US") +}, new TargetRegion("East US") { RegionalReplicaCount = 2, StorageAccountType = ImageStorageAccountType.StandardZrs, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(0) +DataDiskImages = {new DataDiskImageEncryption(0) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"), -},new DataDiskImageEncryption(1) +}, new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -} -}, +}}, }, - StorageProfile = new GalleryImageVersionStorageProfile() + StorageProfile = new GalleryImageVersionStorageProfile { - GallerySource = new GalleryArtifactVersionFullSource() + GallerySource = new GalleryArtifactVersionFullSource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"), }, }, - SafetyProfile = new GalleryImageVersionSafetyProfile() + SafetyProfile = new GalleryImageVersionSafetyProfile { AllowDeletionOfReplicatedLocations = false, }, @@ -344,73 +317,61 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryImageVersionUsingMi string galleryImageVersionName = "1.0.0"; GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US")) { - PublishingProfile = new GalleryImageVersionPublishingProfile() + PublishingProfile = new GalleryImageVersionPublishingProfile { - TargetRegions = -{ -new TargetRegion("West US") + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 1, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(1) +DataDiskImages = {new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -},new TargetRegion("East US") +}, new TargetRegion("East US") { RegionalReplicaCount = 2, StorageAccountType = ImageStorageAccountType.StandardZrs, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(1) +DataDiskImages = {new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -} -}, +}}, }, - StorageProfile = new GalleryImageVersionStorageProfile() + StorageProfile = new GalleryImageVersionStorageProfile { - OSDiskImage = new GalleryOSDiskImage() + OSDiskImage = new GalleryOSDiskImage { HostCaching = HostCaching.ReadOnly, - GallerySource = new GalleryDiskImageSource() + GallerySource = new GalleryDiskImageSource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"), }, }, - DataDiskImages = -{ -new GalleryDataDiskImage(1) + DataDiskImages = {new GalleryDataDiskImage(1) { HostCaching = HostCaching.None, -GallerySource = new GalleryDiskImageSource() +GallerySource = new GalleryDiskImageSource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"), }, -} -}, +}}, }, - SafetyProfile = new GalleryImageVersionSafetyProfile() + SafetyProfile = new GalleryImageVersionSafetyProfile { AllowDeletionOfReplicatedLocations = false, }, @@ -453,26 +414,23 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryImageVersionUsingSh string galleryImageVersionName = "1.0.0"; GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US")) { - PublishingProfile = new GalleryImageVersionPublishingProfile() + PublishingProfile = new GalleryImageVersionPublishingProfile { - TargetRegions = -{ -new TargetRegion("West US") + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 1, IsExcludedFromLatest = false, -} -}, +}}, ReplicationMode = GalleryReplicationMode.Shallow, }, - StorageProfile = new GalleryImageVersionStorageProfile() + StorageProfile = new GalleryImageVersionStorageProfile { - GallerySource = new GalleryArtifactVersionFullSource() + GallerySource = new GalleryArtifactVersionFullSource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"), }, }, - SafetyProfile = new GalleryImageVersionSafetyProfile() + SafetyProfile = new GalleryImageVersionSafetyProfile { AllowDeletionOfReplicatedLocations = false, }, @@ -515,64 +473,55 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryImageVersionUsingSh string galleryImageVersionName = "1.0.0"; GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US")) { - PublishingProfile = new GalleryImageVersionPublishingProfile() + PublishingProfile = new GalleryImageVersionPublishingProfile { - TargetRegions = -{ -new TargetRegion("West US") + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 1, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(0) +DataDiskImages = {new DataDiskImageEncryption(0) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"), -},new DataDiskImageEncryption(1) +}, new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -},new TargetRegion("East US") +}, new TargetRegion("East US") { RegionalReplicaCount = 2, StorageAccountType = ImageStorageAccountType.StandardZrs, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(0) +DataDiskImages = {new DataDiskImageEncryption(0) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"), -},new DataDiskImageEncryption(1) +}, new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -} -}, +}}, }, - StorageProfile = new GalleryImageVersionStorageProfile() + StorageProfile = new GalleryImageVersionStorageProfile { - GallerySource = new GalleryArtifactVersionFullSource() + GallerySource = new GalleryArtifactVersionFullSource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageDefinitionName}/versions/{versionName}"), }, }, - SafetyProfile = new GalleryImageVersionSafetyProfile() + SafetyProfile = new GalleryImageVersionSafetyProfile { AllowDeletionOfReplicatedLocations = false, }, @@ -615,73 +564,61 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryImageVersionUsingSn string galleryImageVersionName = "1.0.0"; GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US")) { - PublishingProfile = new GalleryImageVersionPublishingProfile() + PublishingProfile = new GalleryImageVersionPublishingProfile { - TargetRegions = -{ -new TargetRegion("West US") + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 1, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(1) +DataDiskImages = {new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -},new TargetRegion("East US") +}, new TargetRegion("East US") { RegionalReplicaCount = 2, StorageAccountType = ImageStorageAccountType.StandardZrs, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(1) +DataDiskImages = {new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -} -}, +}}, }, - StorageProfile = new GalleryImageVersionStorageProfile() + StorageProfile = new GalleryImageVersionStorageProfile { - OSDiskImage = new GalleryOSDiskImage() + OSDiskImage = new GalleryOSDiskImage { HostCaching = HostCaching.ReadOnly, - GallerySource = new GalleryDiskImageSource() + GallerySource = new GalleryDiskImageSource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/snapshots/{osSnapshotName}"), }, }, - DataDiskImages = -{ -new GalleryDataDiskImage(1) + DataDiskImages = {new GalleryDataDiskImage(1) { HostCaching = HostCaching.None, -GallerySource = new GalleryDiskImageSource() +GallerySource = new GalleryDiskImageSource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/disks/{dataDiskName}"), }, -} -}, +}}, }, - SafetyProfile = new GalleryImageVersionSafetyProfile() + SafetyProfile = new GalleryImageVersionSafetyProfile { AllowDeletionOfReplicatedLocations = false, }, @@ -724,105 +661,75 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryImageVersionUsingVh string galleryImageVersionName = "1.0.0"; GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US")) { - PublishingProfile = new GalleryImageVersionPublishingProfile() + PublishingProfile = new GalleryImageVersionPublishingProfile { - TargetRegions = -{ -new TargetRegion("West US") + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 1, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(1) +DataDiskImages = {new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -},new TargetRegion("East US") +}, new TargetRegion("East US") { RegionalReplicaCount = 2, StorageAccountType = ImageStorageAccountType.StandardZrs, IsExcludedFromLatest = false, -} -}, +}}, }, - StorageProfile = new GalleryImageVersionStorageProfile() + StorageProfile = new GalleryImageVersionStorageProfile { - OSDiskImage = new GalleryOSDiskImage() + OSDiskImage = new GalleryOSDiskImage { HostCaching = HostCaching.ReadOnly, - GallerySource = new GalleryDiskImageSource() + GallerySource = new GalleryDiskImageSource { Uri = new Uri("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"), StorageAccountId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"), }, }, - DataDiskImages = -{ -new GalleryDataDiskImage(1) + DataDiskImages = {new GalleryDataDiskImage(1) { HostCaching = HostCaching.None, -GallerySource = new GalleryDiskImageSource() +GallerySource = new GalleryDiskImageSource { Uri = new Uri("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"), StorageAccountId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"), }, -} -}, +}}, }, - SafetyProfile = new GalleryImageVersionSafetyProfile() + SafetyProfile = new GalleryImageVersionSafetyProfile { AllowDeletionOfReplicatedLocations = false, }, - SecurityUefiSettings = new GalleryImageVersionUefiSettings() + SecurityUefiSettings = new GalleryImageVersionUefiSettings { - SignatureTemplateNames = -{ -UefiSignatureTemplateName.MicrosoftUefiCertificateAuthorityTemplate -}, - AdditionalSignatures = new UefiKeySignatures() + SignatureTemplateNames = { UefiSignatureTemplateName.MicrosoftUefiCertificateAuthorityTemplate }, + AdditionalSignatures = new UefiKeySignatures { - Kek = -{ -new UefiKey() + Kek = {new UefiKey { KeyType = UefiKeyType.Sha256, -Value = -{ -"" -}, -} -}, - Db = -{ -new UefiKey() +Value = {""}, +}}, + Db = {new UefiKey { KeyType = UefiKeyType.X509, -Value = -{ -"" -}, -} -}, - Dbx = -{ -new UefiKey() +Value = {""}, +}}, + Dbx = {new UefiKey { KeyType = UefiKeyType.X509, -Value = -{ -"" -}, -} -}, +Value = {""}, +}}, }, }, }; @@ -864,61 +771,52 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryImageVersionUsingVh string galleryImageVersionName = "1.0.0"; GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US")) { - PublishingProfile = new GalleryImageVersionPublishingProfile() + PublishingProfile = new GalleryImageVersionPublishingProfile { - TargetRegions = -{ -new TargetRegion("West US") + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 1, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(1) +DataDiskImages = {new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -},new TargetRegion("East US") +}, new TargetRegion("East US") { RegionalReplicaCount = 2, StorageAccountType = ImageStorageAccountType.StandardZrs, IsExcludedFromLatest = false, -} -}, +}}, }, - StorageProfile = new GalleryImageVersionStorageProfile() + StorageProfile = new GalleryImageVersionStorageProfile { - OSDiskImage = new GalleryOSDiskImage() + OSDiskImage = new GalleryOSDiskImage { HostCaching = HostCaching.ReadOnly, - GallerySource = new GalleryDiskImageSource() + GallerySource = new GalleryDiskImageSource { Uri = new Uri("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"), StorageAccountId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"), }, }, - DataDiskImages = -{ -new GalleryDataDiskImage(1) + DataDiskImages = {new GalleryDataDiskImage(1) { HostCaching = HostCaching.None, -GallerySource = new GalleryDiskImageSource() +GallerySource = new GalleryDiskImageSource { Uri = new Uri("https://gallerysourcencus.blob.core.windows.net/myvhds/Windows-Server-2012-R2-20171216-en.us-128GB.vhd"), StorageAccountId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Storage/storageAccounts/{storageAccount}"), }, -} -}, +}}, }, - SafetyProfile = new GalleryImageVersionSafetyProfile() + SafetyProfile = new GalleryImageVersionSafetyProfile { AllowDeletionOfReplicatedLocations = false, }, @@ -961,64 +859,55 @@ public async Task CreateOrUpdate_CreateOrUpdateASimpleGalleryImageVersionWithTar string galleryImageVersionName = "1.0.0"; GalleryImageVersionData data = new GalleryImageVersionData(new AzureLocation("West US")) { - PublishingProfile = new GalleryImageVersionPublishingProfile() + PublishingProfile = new GalleryImageVersionPublishingProfile { - TargetRegions = -{ -new TargetRegion("West US") + TargetRegions = {new TargetRegion("West US") { RegionalReplicaCount = 1, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(0) +DataDiskImages = {new DataDiskImageEncryption(0) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherWestUSDiskEncryptionSet"), -},new DataDiskImageEncryption(1) +}, new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myWestUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -},new TargetRegion("East US") +}, new TargetRegion("East US") { RegionalReplicaCount = 2, StorageAccountType = ImageStorageAccountType.StandardZrs, -Encryption = new EncryptionImages() +Encryption = new EncryptionImages { -OSDiskImage = new OSDiskImageEncryption() +OSDiskImage = new OSDiskImageEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), }, -DataDiskImages = -{ -new DataDiskImageEncryption(0) +DataDiskImages = {new DataDiskImageEncryption(0) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myOtherEastUSDiskEncryptionSet"), -},new DataDiskImageEncryption(1) +}, new DataDiskImageEncryption(1) { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSet/myEastUSDiskEncryptionSet"), -} -}, +}}, }, IsExcludedFromLatest = false, -} -}, +}}, }, - StorageProfile = new GalleryImageVersionStorageProfile() + StorageProfile = new GalleryImageVersionStorageProfile { - GallerySource = new GalleryArtifactVersionFullSource() + GallerySource = new GalleryArtifactVersionFullSource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"), }, }, - SafetyProfile = new GalleryImageVersionSafetyProfile() + SafetyProfile = new GalleryImageVersionSafetyProfile { AllowDeletionOfReplicatedLocations = false, }, @@ -1071,9 +960,9 @@ public async Task Get_GetAGalleryImageVersionWithReplicationStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAGalleryImageVersionWithReplicationStatus() + public async Task Get_GetAGalleryImageVersionWithSnapshotsAsASource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithReplicationStatus.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithSnapshotsAsSource.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1095,17 +984,20 @@ public async Task Exists_GetAGalleryImageVersionWithReplicationStatus() // invoke the operation string galleryImageVersionName = "1.0.0"; - ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; - bool result = await collection.ExistsAsync(galleryImageVersionName, expand: expand); + GalleryImageVersionResource result = await collection.GetAsync(galleryImageVersionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryImageVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGalleryImageVersionWithReplicationStatus() + public async Task Get_GetAGalleryImageVersionWithVhdAsASource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithReplicationStatus.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithVhdAsSource.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1127,29 +1019,20 @@ public async Task GetIfExists_GetAGalleryImageVersionWithReplicationStatus() // invoke the operation string galleryImageVersionName = "1.0.0"; - ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; - NullableResponse response = await collection.GetIfExistsAsync(galleryImageVersionName, expand: expand); - GalleryImageVersionResource result = response.HasValue ? response.Value : null; + GalleryImageVersionResource result = await collection.GetAsync(galleryImageVersionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryImageVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryImageVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryImageVersionWithSnapshotsAsASource() + public async Task Get_GetAGalleryImageVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithSnapshotsAsSource.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1182,10 +1065,10 @@ public async Task Get_GetAGalleryImageVersionWithSnapshotsAsASource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAGalleryImageVersionWithSnapshotsAsASource() + public async Task GetAll_ListGalleryImageVersionsInAGalleryImageDefinition() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithSnapshotsAsSource.json - // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_ListByGalleryImage.json + // this example is just showing the usage of "GalleryImageVersions_ListByGalleryImage" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1204,18 +1087,24 @@ public async Task Exists_GetAGalleryImageVersionWithSnapshotsAsASource() // get the collection of this GalleryImageVersionResource GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions(); - // invoke the operation - string galleryImageVersionName = "1.0.0"; - bool result = await collection.ExistsAsync(galleryImageVersionName); + // invoke the operation and iterate over the result + await foreach (GalleryImageVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryImageVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGalleryImageVersionWithSnapshotsAsASource() + public async Task Exists_GetAGalleryImageVersionWithReplicationStatus() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithSnapshotsAsSource.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithReplicationStatus.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1237,28 +1126,17 @@ public async Task GetIfExists_GetAGalleryImageVersionWithSnapshotsAsASource() // invoke the operation string galleryImageVersionName = "1.0.0"; - NullableResponse response = await collection.GetIfExistsAsync(galleryImageVersionName); - GalleryImageVersionResource result = response.HasValue ? response.Value : null; + ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; + bool result = await collection.ExistsAsync(galleryImageVersionName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryImageVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryImageVersionWithVhdAsASource() + public async Task Exists_GetAGalleryImageVersionWithSnapshotsAsASource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithVhdAsSource.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithSnapshotsAsSource.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1280,13 +1158,9 @@ public async Task Get_GetAGalleryImageVersionWithVhdAsASource() // invoke the operation string galleryImageVersionName = "1.0.0"; - GalleryImageVersionResource result = await collection.GetAsync(galleryImageVersionName); + bool result = await collection.ExistsAsync(galleryImageVersionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryImageVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -1322,9 +1196,9 @@ public async Task Exists_GetAGalleryImageVersionWithVhdAsASource() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGalleryImageVersionWithVhdAsASource() + public async Task Exists_GetAGalleryImageVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithVhdAsSource.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1346,28 +1220,16 @@ public async Task GetIfExists_GetAGalleryImageVersionWithVhdAsASource() // invoke the operation string galleryImageVersionName = "1.0.0"; - NullableResponse response = await collection.GetIfExistsAsync(galleryImageVersionName); - GalleryImageVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(galleryImageVersionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryImageVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryImageVersion() + public async Task GetIfExists_GetAGalleryImageVersionWithReplicationStatus() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithReplicationStatus.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1389,20 +1251,29 @@ public async Task Get_GetAGalleryImageVersion() // invoke the operation string galleryImageVersionName = "1.0.0"; - GalleryImageVersionResource result = await collection.GetAsync(galleryImageVersionName); + ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; + NullableResponse response = await collection.GetIfExistsAsync(galleryImageVersionName, expand: expand); + GalleryImageVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryImageVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryImageVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAGalleryImageVersion() + public async Task GetIfExists_GetAGalleryImageVersionWithSnapshotsAsASource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithSnapshotsAsSource.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1424,16 +1295,28 @@ public async Task Exists_GetAGalleryImageVersion() // invoke the operation string galleryImageVersionName = "1.0.0"; - bool result = await collection.ExistsAsync(galleryImageVersionName); + NullableResponse response = await collection.GetIfExistsAsync(galleryImageVersionName); + GalleryImageVersionResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryImageVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGalleryImageVersion() + public async Task GetIfExists_GetAGalleryImageVersionWithVhdAsASource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithVhdAsSource.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1474,10 +1357,10 @@ public async Task GetIfExists_GetAGalleryImageVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGalleryImageVersionsInAGalleryImageDefinition() + public async Task GetIfExists_GetAGalleryImageVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_ListByGalleryImage.json - // this example is just showing the usage of "GalleryImageVersions_ListByGalleryImage" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get.json + // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1496,17 +1379,23 @@ public async Task GetAll_ListGalleryImageVersionsInAGalleryImageDefinition() // get the collection of this GalleryImageVersionResource GalleryImageVersionCollection collection = galleryImage.GetGalleryImageVersions(); - // invoke the operation and iterate over the result - await foreach (GalleryImageVersionResource item in collection.GetAllAsync()) + // invoke the operation + string galleryImageVersionName = "1.0.0"; + NullableResponse response = await collection.GetIfExistsAsync(galleryImageVersionName); + GalleryImageVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GalleryImageVersionData resourceData = item.Data; + GalleryImageVersionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageVersionResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageVersionResource.cs index e157bdc3c61c3..f2f60e8e76448 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageVersionResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryImageVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GalleryImageVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASimpleGalleryImageVersionManagedImageAsSource() + public async Task Get_GetAGalleryImageVersionWithReplicationStatus() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Update.json - // this example is just showing the usage of "GalleryImageVersions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithReplicationStatus.json + // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,32 +39,8 @@ public async Task Update_UpdateASimpleGalleryImageVersionManagedImageAsSource() GalleryImageVersionResource galleryImageVersion = client.GetGalleryImageVersionResource(galleryImageVersionResourceId); // invoke the operation - GalleryImageVersionPatch patch = new GalleryImageVersionPatch() - { - PublishingProfile = new GalleryImageVersionPublishingProfile() - { - TargetRegions = -{ -new TargetRegion("West US") -{ -RegionalReplicaCount = 1, -},new TargetRegion("East US") -{ -RegionalReplicaCount = 2, -StorageAccountType = ImageStorageAccountType.StandardZrs, -} -}, - }, - StorageProfile = new GalleryImageVersionStorageProfile() - { - GallerySource = new GalleryArtifactVersionFullSource() - { - Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"), - }, - }, - }; - ArmOperation lro = await galleryImageVersion.UpdateAsync(WaitUntil.Completed, patch); - GalleryImageVersionResource result = lro.Value; + ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; + GalleryImageVersionResource result = await galleryImageVersion.GetAsync(expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -75,10 +51,10 @@ public async Task Update_UpdateASimpleGalleryImageVersionManagedImageAsSource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASimpleGalleryImageVersionWithoutSourceId() + public async Task Get_GetAGalleryImageVersionWithSnapshotsAsASource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Update_WithoutSourceId.json - // this example is just showing the usage of "GalleryImageVersions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithSnapshotsAsSource.json + // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,26 +72,7 @@ public async Task Update_UpdateASimpleGalleryImageVersionWithoutSourceId() GalleryImageVersionResource galleryImageVersion = client.GetGalleryImageVersionResource(galleryImageVersionResourceId); // invoke the operation - GalleryImageVersionPatch patch = new GalleryImageVersionPatch() - { - PublishingProfile = new GalleryImageVersionPublishingProfile() - { - TargetRegions = -{ -new TargetRegion("West US") -{ -RegionalReplicaCount = 1, -},new TargetRegion("East US") -{ -RegionalReplicaCount = 2, -StorageAccountType = ImageStorageAccountType.StandardZrs, -} -}, - }, - StorageProfile = new GalleryImageVersionStorageProfile(), - }; - ArmOperation lro = await galleryImageVersion.UpdateAsync(WaitUntil.Completed, patch); - GalleryImageVersionResource result = lro.Value; + GalleryImageVersionResource result = await galleryImageVersion.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -126,9 +83,9 @@ public async Task Update_UpdateASimpleGalleryImageVersionWithoutSourceId() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryImageVersionWithReplicationStatus() + public async Task Get_GetAGalleryImageVersionWithVhdAsASource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithReplicationStatus.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithVhdAsSource.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -147,8 +104,7 @@ public async Task Get_GetAGalleryImageVersionWithReplicationStatus() GalleryImageVersionResource galleryImageVersion = client.GetGalleryImageVersionResource(galleryImageVersionResourceId); // invoke the operation - ReplicationStatusType? expand = ReplicationStatusType.ReplicationStatus; - GalleryImageVersionResource result = await galleryImageVersion.GetAsync(expand: expand); + GalleryImageVersionResource result = await galleryImageVersion.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -159,9 +115,9 @@ public async Task Get_GetAGalleryImageVersionWithReplicationStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryImageVersionWithSnapshotsAsASource() + public async Task Get_GetAGalleryImageVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithSnapshotsAsSource.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get.json // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -191,10 +147,10 @@ public async Task Get_GetAGalleryImageVersionWithSnapshotsAsASource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryImageVersionWithVhdAsASource() + public async Task Delete_DeleteAGalleryImageVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get_WithVhdAsSource.json - // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Delete.json + // this example is just showing the usage of "GalleryImageVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -212,21 +168,17 @@ public async Task Get_GetAGalleryImageVersionWithVhdAsASource() GalleryImageVersionResource galleryImageVersion = client.GetGalleryImageVersionResource(galleryImageVersionResourceId); // invoke the operation - GalleryImageVersionResource result = await galleryImageVersion.GetAsync(); + await galleryImageVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryImageVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGalleryImageVersion() + public async Task Update_UpdateASimpleGalleryImageVersionManagedImageAsSource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Get.json - // this example is just showing the usage of "GalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Update.json + // this example is just showing the usage of "GalleryImageVersions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -244,7 +196,29 @@ public async Task Get_GetAGalleryImageVersion() GalleryImageVersionResource galleryImageVersion = client.GetGalleryImageVersionResource(galleryImageVersionResourceId); // invoke the operation - GalleryImageVersionResource result = await galleryImageVersion.GetAsync(); + GalleryImageVersionPatch patch = new GalleryImageVersionPatch + { + PublishingProfile = new GalleryImageVersionPublishingProfile + { + TargetRegions = {new TargetRegion("West US") +{ +RegionalReplicaCount = 1, +}, new TargetRegion("East US") +{ +RegionalReplicaCount = 2, +StorageAccountType = ImageStorageAccountType.StandardZrs, +}}, + }, + StorageProfile = new GalleryImageVersionStorageProfile + { + GallerySource = new GalleryArtifactVersionFullSource + { + Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/images/{imageName}"), + }, + }, + }; + ArmOperation lro = await galleryImageVersion.UpdateAsync(WaitUntil.Completed, patch); + GalleryImageVersionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -255,10 +229,10 @@ public async Task Get_GetAGalleryImageVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAGalleryImageVersion() + public async Task Update_UpdateASimpleGalleryImageVersionWithoutSourceId() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Delete.json - // this example is just showing the usage of "GalleryImageVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/GalleryImageVersion_Update_WithoutSourceId.json + // this example is just showing the usage of "GalleryImageVersions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -276,9 +250,29 @@ public async Task Delete_DeleteAGalleryImageVersion() GalleryImageVersionResource galleryImageVersion = client.GetGalleryImageVersionResource(galleryImageVersionResourceId); // invoke the operation - await galleryImageVersion.DeleteAsync(WaitUntil.Completed); + GalleryImageVersionPatch patch = new GalleryImageVersionPatch + { + PublishingProfile = new GalleryImageVersionPublishingProfile + { + TargetRegions = {new TargetRegion("West US") +{ +RegionalReplicaCount = 1, +}, new TargetRegion("East US") +{ +RegionalReplicaCount = 2, +StorageAccountType = ImageStorageAccountType.StandardZrs, +}}, + }, + StorageProfile = new GalleryImageVersionStorageProfile(), + }; + ArmOperation lro = await galleryImageVersion.UpdateAsync(WaitUntil.Completed, patch); + GalleryImageVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryImageVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryResource.cs index 641e76c103a5c..4da1abda86273 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_GalleryResource.cs @@ -10,48 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples { public partial class Sample_GalleryResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASimpleGallery() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Update.json - // this example is just showing the usage of "Galleries_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this GalleryResource created on azure - // for more information of creating GalleryResource, please refer to the document of GalleryResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string galleryName = "myGalleryName"; - ResourceIdentifier galleryResourceId = GalleryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName); - GalleryResource gallery = client.GetGalleryResource(galleryResourceId); - - // invoke the operation - GalleryPatch patch = new GalleryPatch() - { - Description = "This is the gallery description.", - }; - ArmOperation lro = await gallery.UpdateAsync(WaitUntil.Completed, patch); - GalleryResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetACommunityGallery() @@ -202,33 +166,37 @@ public async Task Delete_DeleteAGallery() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetGalleries_ListGalleriesInASubscription() + public async Task Update_UpdateASimpleGallery() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_ListBySubscription.json - // this example is just showing the usage of "Galleries_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_Update.json + // this example is just showing the usage of "Galleries_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this GalleryResource created on azure + // for more information of creating GalleryResource, please refer to the document of GalleryResource string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "myResourceGroup"; + string galleryName = "myGalleryName"; + ResourceIdentifier galleryResourceId = GalleryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, galleryName); + GalleryResource gallery = client.GetGalleryResource(galleryResourceId); - // invoke the operation and iterate over the result - await foreach (GalleryResource item in subscriptionResource.GetGalleriesAsync()) + // invoke the operation + GalleryPatch patch = new GalleryPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GalleryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "This is the gallery description.", + }; + ArmOperation lro = await gallery.UpdateAsync(WaitUntil.Completed, patch); + GalleryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -254,24 +222,15 @@ public async Task UpdateSharingProfile_AddSharingIdToTheSharingProfileOfAGallery // invoke the operation SharingUpdate sharingUpdate = new SharingUpdate(SharingUpdateOperationType.Add) { - Groups = -{ -new SharingProfileGroup() + Groups = {new SharingProfileGroup { GroupType = SharingProfileGroupType.Subscriptions, -Ids = -{ -"34a4ab42-0d72-47d9-bd1a-aed207386dac","380fd389-260b-41aa-bad9-0a83108c370b" -}, -},new SharingProfileGroup() +Ids = {"34a4ab42-0d72-47d9-bd1a-aed207386dac", "380fd389-260b-41aa-bad9-0a83108c370b"}, +}, new SharingProfileGroup { GroupType = SharingProfileGroupType.AADTenants, -Ids = -{ -"c24c76aa-8897-4027-9b03-8f7928b54ff6" -}, -} -}, +Ids = {"c24c76aa-8897-4027-9b03-8f7928b54ff6"}, +}}, }; ArmOperation lro = await gallery.UpdateSharingProfileAsync(WaitUntil.Completed, sharingUpdate); SharingUpdate result = lro.Value; diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ManagedDiskCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ManagedDiskCollection.cs index a5c3059ab5637..eeb14340529d0 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ManagedDiskCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ManagedDiskCollection.cs @@ -47,12 +47,12 @@ public async Task CreateOrUpdate_CreateAConfidentialVMSupportedDiskEncryptedWith OSType = SupportedOperatingSystemType.Windows, CreationData = new DiskCreationData(DiskCreateOption.FromImage) { - ImageReference = new ImageDiskReference() + ImageReference = new ImageDiskReference { Id = new ResourceIdentifier("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"), }, }, - SecurityProfile = new DiskSecurityProfile() + SecurityProfile = new DiskSecurityProfile { SecurityType = DiskSecurityType.ConfidentialVmDiskEncryptedWithCustomerKey, SecureVmDiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"), @@ -137,7 +137,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskAndAssociateWithDiskEncryptio { CreationData = new DiskCreationData(DiskCreateOption.Empty), DiskSizeGB = 200, - Encryption = new DiskEncryption() + Encryption = new DiskEncryption { DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), }, @@ -309,7 +309,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskFromImportSecureCreateOption( SourceUri = new Uri("https://mystorageaccount.blob.core.windows.net/osimages/osimage.vhd"), SecurityDataUri = new Uri("https://mystorageaccount.blob.core.windows.net/osimages/vmgs.vhd"), }, - SecurityProfile = new DiskSecurityProfile() + SecurityProfile = new DiskSecurityProfile { SecurityType = DiskSecurityType.ConfidentialVmGuestStateOnlyEncryptedWithPlatformKey, }, @@ -355,7 +355,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskFromUploadPreparedSecureCreat { UploadSizeBytes = 10737418752L, }, - SecurityProfile = new DiskSecurityProfile() + SecurityProfile = new DiskSecurityProfile { SecurityType = DiskSecurityType.TrustedLaunch, }, @@ -399,7 +399,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskFromAPlatformImage() OSType = SupportedOperatingSystemType.Windows, CreationData = new DiskCreationData(DiskCreateOption.FromImage) { - ImageReference = new ImageDiskReference() + ImageReference = new ImageDiskReference { Id = new ResourceIdentifier("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/{publisher}/ArtifactTypes/VMImage/Offers/{offer}/Skus/{sku}/Versions/1.0.0"), }, @@ -444,7 +444,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskFromAnAzureComputeGalleryComm OSType = SupportedOperatingSystemType.Windows, CreationData = new DiskCreationData(DiskCreateOption.FromImage) { - GalleryImageReference = new ImageDiskReference() + GalleryImageReference = new ImageDiskReference { CommunityGalleryImageId = "/CommunityGalleries/{communityGalleryPublicGalleryName}/Images/{imageName}/Versions/1.0.0", }, @@ -489,7 +489,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskFromAnAzureComputeGalleryDire OSType = SupportedOperatingSystemType.Windows, CreationData = new DiskCreationData(DiskCreateOption.FromImage) { - GalleryImageReference = new ImageDiskReference() + GalleryImageReference = new ImageDiskReference { SharedGalleryImageId = "/SharedGalleries/{sharedGalleryUniqueName}/Images/{imageName}/Versions/1.0.0", }, @@ -534,7 +534,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskFromAnAzureComputeGalleryImag OSType = SupportedOperatingSystemType.Windows, CreationData = new DiskCreationData(DiskCreateOption.FromImage) { - GalleryImageReference = new ImageDiskReference() + GalleryImageReference = new ImageDiskReference { Id = new ResourceIdentifier("/Subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/Providers/Microsoft.Compute/Galleries/{galleryName}/Images/{imageName}/Versions/1.0.0"), }, @@ -779,7 +779,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskWithPremiumV2AccountType() string diskName = "myPremiumV2Disk"; ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US")) { - Sku = new DiskSku() + Sku = new DiskSku { Name = DiskStorageAccountType.PremiumV2Lrs, }, @@ -827,12 +827,12 @@ public async Task CreateOrUpdate_CreateAManagedDiskWithSecurityProfile() OSType = SupportedOperatingSystemType.Windows, CreationData = new DiskCreationData(DiskCreateOption.FromImage) { - ImageReference = new ImageDiskReference() + ImageReference = new ImageDiskReference { Id = new ResourceIdentifier("/Subscriptions/{subscriptionId}/Providers/Microsoft.Compute/Locations/uswest/Publishers/Microsoft/ArtifactTypes/VMImage/Offers/{offer}"), }, }, - SecurityProfile = new DiskSecurityProfile() + SecurityProfile = new DiskSecurityProfile { SecurityType = DiskSecurityType.TrustedLaunch, }, @@ -873,7 +873,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskWithSsdZrsAccountType() string diskName = "myDisk"; ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US")) { - Sku = new DiskSku() + Sku = new DiskSku { Name = DiskStorageAccountType.PremiumZrs, }, @@ -916,7 +916,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskWithUltraAccountTypeWithReadO string diskName = "myUltraReadOnlyDisk"; ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US")) { - Sku = new DiskSku() + Sku = new DiskSku { Name = DiskStorageAccountType.UltraSsdLrs, }, @@ -927,7 +927,7 @@ public async Task CreateOrUpdate_CreateAManagedDiskWithUltraAccountTypeWithReadO DiskSizeGB = 200, DiskIopsReadWrite = 125L, DiskMBpsReadWrite = 3000L, - Encryption = new DiskEncryption() + Encryption = new DiskEncryption { EncryptionType = ComputeEncryptionType.EncryptionAtRestWithPlatformKey, }, @@ -1009,7 +1009,7 @@ public async Task CreateOrUpdate_CreateAnEmptyManagedDiskInExtendedLocation() string diskName = "myDisk"; ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "{edge-zone-id}", }, @@ -1091,7 +1091,7 @@ public async Task CreateOrUpdate_CreateAnUltraManagedDiskWithLogicalSectorSize51 string diskName = "myDisk"; ManagedDiskData data = new ManagedDiskData(new AzureLocation("West US")) { - Sku = new DiskSku() + Sku = new DiskSku { Name = DiskStorageAccountType.UltraSsdLrs, }, @@ -1146,10 +1146,10 @@ public async Task Get_GetInformationAboutAManagedDisk() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetInformationAboutAManagedDisk() + public async Task GetAll_ListAllManagedDisksInAResourceGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Get.json - // this example is just showing the usage of "Disks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_ListByResourceGroup.json + // this example is just showing the usage of "Disks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1166,16 +1166,22 @@ public async Task Exists_GetInformationAboutAManagedDisk() // get the collection of this ManagedDiskResource ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks(); - // invoke the operation - string diskName = "myManagedDisk"; - bool result = await collection.ExistsAsync(diskName); + // invoke the operation and iterate over the result + await foreach (ManagedDiskResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDiskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInformationAboutAManagedDisk() + public async Task Exists_GetInformationAboutAManagedDisk() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Get.json // this example is just showing the usage of "Disks_Get" operation, for the dependent resources, they will have to be created separately. @@ -1197,29 +1203,17 @@ public async Task GetIfExists_GetInformationAboutAManagedDisk() // invoke the operation string diskName = "myManagedDisk"; - NullableResponse response = await collection.GetIfExistsAsync(diskName); - ManagedDiskResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(diskName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDiskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllManagedDisksInAResourceGroup() + public async Task GetIfExists_GetInformationAboutAManagedDisk() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_ListByResourceGroup.json - // this example is just showing the usage of "Disks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Get.json + // this example is just showing the usage of "Disks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1236,17 +1230,23 @@ public async Task GetAll_ListAllManagedDisksInAResourceGroup() // get the collection of this ManagedDiskResource ManagedDiskCollection collection = resourceGroupResource.GetManagedDisks(); - // invoke the operation and iterate over the result - await foreach (ManagedDiskResource item in collection.GetAllAsync()) + // invoke the operation + string diskName = "myManagedDisk"; + NullableResponse response = await collection.GetIfExistsAsync(diskName); + ManagedDiskResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedDiskData resourceData = item.Data; + ManagedDiskData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ManagedDiskResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ManagedDiskResource.cs index 83e40f9dc7f67..8d9185e102eac 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ManagedDiskResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ManagedDiskResource.cs @@ -10,13 +10,68 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples { public partial class Sample_ManagedDiskResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetInformationAboutAManagedDisk() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Get.json + // this example is just showing the usage of "Disks_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedDiskResource created on azure + // for more information of creating ManagedDiskResource, please refer to the document of ManagedDiskResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "myResourceGroup"; + string diskName = "myManagedDisk"; + ResourceIdentifier managedDiskResourceId = ManagedDiskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, diskName); + ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); + + // invoke the operation + ManagedDiskResource result = await managedDisk.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDiskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAManagedDisk() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Delete.json + // this example is just showing the usage of "Disks_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedDiskResource created on azure + // for more information of creating ManagedDiskResource, please refer to the document of ManagedDiskResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "myResourceGroup"; + string diskName = "myDisk"; + ResourceIdentifier managedDiskResourceId = ManagedDiskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, diskName); + ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); + + // invoke the operation + await managedDisk.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateABurstingEnabledManagedDisk() @@ -38,7 +93,7 @@ public async Task Update_CreateOrUpdateABurstingEnabledManagedDisk() ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); // invoke the operation - ManagedDiskPatch patch = new ManagedDiskPatch() + ManagedDiskPatch patch = new ManagedDiskPatch { DiskSizeGB = 1024, BurstingEnabled = true, @@ -74,9 +129,9 @@ public async Task Update_UpdateAManagedDiskToAddAcceleratedNetworking() ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); // invoke the operation - ManagedDiskPatch patch = new ManagedDiskPatch() + ManagedDiskPatch patch = new ManagedDiskPatch { - SupportedCapabilities = new SupportedCapabilities() + SupportedCapabilities = new SupportedCapabilities { AcceleratedNetwork = false, }, @@ -112,9 +167,9 @@ public async Task Update_UpdateAManagedDiskToAddArchitecture() ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); // invoke the operation - ManagedDiskPatch patch = new ManagedDiskPatch() + ManagedDiskPatch patch = new ManagedDiskPatch { - SupportedCapabilities = new SupportedCapabilities() + SupportedCapabilities = new SupportedCapabilities { Architecture = ArchitectureType.Arm64, }, @@ -150,7 +205,7 @@ public async Task Update_UpdateAManagedDiskToAddPurchasePlan() ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); // invoke the operation - ManagedDiskPatch patch = new ManagedDiskPatch() + ManagedDiskPatch patch = new ManagedDiskPatch { PurchasePlan = new DiskPurchasePlan("myPurchasePlanName", "myPurchasePlanPublisher", "myPurchasePlanProduct") { @@ -188,7 +243,7 @@ public async Task Update_UpdateAManagedDiskToAddSupportsHibernation() ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); // invoke the operation - ManagedDiskPatch patch = new ManagedDiskPatch() + ManagedDiskPatch patch = new ManagedDiskPatch { SupportsHibernation = true, }; @@ -223,7 +278,7 @@ public async Task Update_UpdateAManagedDiskToChangeTier() ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); // invoke the operation - ManagedDiskPatch patch = new ManagedDiskPatch() + ManagedDiskPatch patch = new ManagedDiskPatch { Tier = "P30", }; @@ -258,7 +313,7 @@ public async Task Update_UpdateAManagedDiskToDisableBursting() ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); // invoke the operation - ManagedDiskPatch patch = new ManagedDiskPatch() + ManagedDiskPatch patch = new ManagedDiskPatch { BurstingEnabled = false, }; @@ -293,7 +348,7 @@ public async Task Update_UpdateAManagedDiskToDisableOptimizedForFrequentAttach() ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); // invoke the operation - ManagedDiskPatch patch = new ManagedDiskPatch() + ManagedDiskPatch patch = new ManagedDiskPatch { IsOptimizedForFrequentAttach = false, }; @@ -328,9 +383,9 @@ public async Task Update_UpdateAManagedDiskWithDiskControllerTypes() ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); // invoke the operation - ManagedDiskPatch patch = new ManagedDiskPatch() + ManagedDiskPatch patch = new ManagedDiskPatch { - SupportedCapabilities = new SupportedCapabilities() + SupportedCapabilities = new SupportedCapabilities { DiskControllerTypes = "SCSI", }, @@ -366,7 +421,7 @@ public async Task Update_UpdateManagedDiskToRemoveDiskAccessResourceAssociation( ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); // invoke the operation - ManagedDiskPatch patch = new ManagedDiskPatch() + ManagedDiskPatch patch = new ManagedDiskPatch { NetworkAccessPolicy = NetworkAccessPolicy.AllowAll, }; @@ -380,93 +435,6 @@ public async Task Update_UpdateManagedDiskToRemoveDiskAccessResourceAssociation( Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetInformationAboutAManagedDisk() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Get.json - // this example is just showing the usage of "Disks_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedDiskResource created on azure - // for more information of creating ManagedDiskResource, please refer to the document of ManagedDiskResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string diskName = "myManagedDisk"; - ResourceIdentifier managedDiskResourceId = ManagedDiskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, diskName); - ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); - - // invoke the operation - ManagedDiskResource result = await managedDisk.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDiskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAManagedDisk() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_Delete.json - // this example is just showing the usage of "Disks_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedDiskResource created on azure - // for more information of creating ManagedDiskResource, please refer to the document of ManagedDiskResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string diskName = "myDisk"; - ResourceIdentifier managedDiskResourceId = ManagedDiskResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, diskName); - ManagedDiskResource managedDisk = client.GetManagedDiskResource(managedDiskResourceId); - - // invoke the operation - await managedDisk.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetManagedDisks_ListAllManagedDisksInASubscription() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_ListBySubscription.json - // this example is just showing the usage of "Disks_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ManagedDiskResource item in subscriptionResource.GetManagedDisksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDiskData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GrantAccess_GetASasOnAManagedDisk() diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ProximityPlacementGroupCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ProximityPlacementGroupCollection.cs index 33801f85c198c..11b740efc249e 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ProximityPlacementGroupCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ProximityPlacementGroupCollection.cs @@ -43,15 +43,9 @@ public async Task CreateOrUpdate_CreateOrUpdateAProximityPlacementGroup() string proximityPlacementGroupName = "myProximityPlacementGroup"; ProximityPlacementGroupData data = new ProximityPlacementGroupData(new AzureLocation("westus")) { - Zones = -{ -"1" -}, + Zones = { "1" }, ProximityPlacementGroupType = ProximityPlacementGroupType.Standard, - IntentVmSizes = -{ -"Basic_A0","Basic_A2" -}, + IntentVmSizes = { "Basic_A0", "Basic_A2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, proximityPlacementGroupName, data); ProximityPlacementGroupResource result = lro.Value; @@ -98,10 +92,10 @@ public async Task Get_GetProximityPlacementGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetProximityPlacementGroups() + public async Task GetAll_ListProximityPlacementGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_Get.json - // this example is just showing the usage of "ProximityPlacementGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_ListByResourceGroup.json + // this example is just showing the usage of "ProximityPlacementGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +112,22 @@ public async Task Exists_GetProximityPlacementGroups() // get the collection of this ProximityPlacementGroupResource ProximityPlacementGroupCollection collection = resourceGroupResource.GetProximityPlacementGroups(); - // invoke the operation - string proximityPlacementGroupName = "myProximityPlacementGroup"; - bool result = await collection.ExistsAsync(proximityPlacementGroupName); + // invoke the operation and iterate over the result + await foreach (ProximityPlacementGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProximityPlacementGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetProximityPlacementGroups() + public async Task Exists_GetProximityPlacementGroups() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_Get.json // this example is just showing the usage of "ProximityPlacementGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +149,17 @@ public async Task GetIfExists_GetProximityPlacementGroups() // invoke the operation string proximityPlacementGroupName = "myProximityPlacementGroup"; - NullableResponse response = await collection.GetIfExistsAsync(proximityPlacementGroupName); - ProximityPlacementGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(proximityPlacementGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProximityPlacementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListProximityPlacementGroup() + public async Task GetIfExists_GetProximityPlacementGroups() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_ListByResourceGroup.json - // this example is just showing the usage of "ProximityPlacementGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_Get.json + // this example is just showing the usage of "ProximityPlacementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +176,23 @@ public async Task GetAll_ListProximityPlacementGroup() // get the collection of this ProximityPlacementGroupResource ProximityPlacementGroupCollection collection = resourceGroupResource.GetProximityPlacementGroups(); - // invoke the operation and iterate over the result - await foreach (ProximityPlacementGroupResource item in collection.GetAllAsync()) + // invoke the operation + string proximityPlacementGroupName = "myProximityPlacementGroup"; + NullableResponse response = await collection.GetIfExistsAsync(proximityPlacementGroupName); + ProximityPlacementGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ProximityPlacementGroupData resourceData = item.Data; + ProximityPlacementGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ProximityPlacementGroupResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ProximityPlacementGroupResource.cs index aaf57577c3f01..a3ebfc5725b92 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ProximityPlacementGroupResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_ProximityPlacementGroupResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -19,10 +18,10 @@ public partial class Sample_ProximityPlacementGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAProximityPlacementGroup() + public async Task Get_GetProximityPlacementGroups() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_Patch.json - // this example is just showing the usage of "ProximityPlacementGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_Get.json + // this example is just showing the usage of "ProximityPlacementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,14 +37,7 @@ public async Task Update_UpdateAProximityPlacementGroup() ProximityPlacementGroupResource proximityPlacementGroup = client.GetProximityPlacementGroupResource(proximityPlacementGroupResourceId); // invoke the operation - ProximityPlacementGroupPatch patch = new ProximityPlacementGroupPatch() - { - Tags = -{ -["additionalProp1"] = "string", -}, - }; - ProximityPlacementGroupResource result = await proximityPlacementGroup.UpdateAsync(patch); + ProximityPlacementGroupResource result = await proximityPlacementGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -82,10 +74,10 @@ public async Task Delete_DeleteAProximityPlacementGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetProximityPlacementGroups() + public async Task Update_UpdateAProximityPlacementGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_Get.json - // this example is just showing the usage of "ProximityPlacementGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_Patch.json + // this example is just showing the usage of "ProximityPlacementGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +93,14 @@ public async Task Get_GetProximityPlacementGroups() ProximityPlacementGroupResource proximityPlacementGroup = client.GetProximityPlacementGroupResource(proximityPlacementGroupResourceId); // invoke the operation - ProximityPlacementGroupResource result = await proximityPlacementGroup.GetAsync(); + ProximityPlacementGroupPatch patch = new ProximityPlacementGroupPatch + { + Tags = +{ +["additionalProp1"] = "string" +}, + }; + ProximityPlacementGroupResource result = await proximityPlacementGroup.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -109,36 +108,5 @@ public async Task Get_GetProximityPlacementGroups() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetProximityPlacementGroups_ListProximityPlacementGroups() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_ListBySubscription.json - // this example is just showing the usage of "ProximityPlacementGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ProximityPlacementGroupResource item in subscriptionResource.GetProximityPlacementGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProximityPlacementGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointCollection.cs index e8651a3569ce7..9a925fda23cbf 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_CopyARestorePointToADifferentRegion() // invoke the operation string restorePointName = "rpName"; - RestorePointData data = new RestorePointData() + RestorePointData data = new RestorePointData { SourceRestorePointId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/restorePointCollections/sourceRpcName/restorePoints/sourceRpName"), }; @@ -80,15 +80,12 @@ public async Task CreateOrUpdate_CreateARestorePoint() // invoke the operation string restorePointName = "rpName"; - RestorePointData data = new RestorePointData() + RestorePointData data = new RestorePointData { - ExcludeDisks = -{ -new WritableSubResource() + ExcludeDisks = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/disk123"), -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, restorePointName, data); RestorePointResource result = lro.Value; @@ -136,9 +133,9 @@ public async Task Get_GetARestorePoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetARestorePoint() + public async Task Get_GetRestorePointWithInstanceView() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Get_WithInstanceView.json // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -159,14 +156,18 @@ public async Task Exists_GetARestorePoint() // invoke the operation string restorePointName = "rpName"; - bool result = await collection.ExistsAsync(restorePointName); + RestorePointResource result = await collection.GetAsync(restorePointName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorePointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetARestorePoint() + public async Task Exists_GetARestorePoint() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Get.json // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -189,26 +190,14 @@ public async Task GetIfExists_GetARestorePoint() // invoke the operation string restorePointName = "rpName"; - NullableResponse response = await collection.GetIfExistsAsync(restorePointName); - RestorePointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(restorePointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorePointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRestorePointWithInstanceView() + public async Task Exists_GetRestorePointWithInstanceView() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Get_WithInstanceView.json // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -231,20 +220,16 @@ public async Task Get_GetRestorePointWithInstanceView() // invoke the operation string restorePointName = "rpName"; - RestorePointResource result = await collection.GetAsync(restorePointName); + bool result = await collection.ExistsAsync(restorePointName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorePointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRestorePointWithInstanceView() + public async Task GetIfExists_GetARestorePoint() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Get_WithInstanceView.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Get.json // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -265,9 +250,21 @@ public async Task Exists_GetRestorePointWithInstanceView() // invoke the operation string restorePointName = "rpName"; - bool result = await collection.ExistsAsync(restorePointName); + NullableResponse response = await collection.GetIfExistsAsync(restorePointName); + RestorePointResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorePointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointGroupCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointGroupCollection.cs index f3860295907f6..2c2944a66a5bb 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointGroupCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointGroupCollection.cs @@ -43,13 +43,13 @@ public async Task CreateOrUpdate_CreateOrUpdateARestorePointCollectionForCrossRe string restorePointGroupName = "myRpc"; RestorePointGroupData data = new RestorePointGroupData(new AzureLocation("norwayeast")) { - Source = new RestorePointGroupSource() + Source = new RestorePointGroupSource { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/restorePointCollections/sourceRpcName"), }, Tags = { -["myTag1"] = "tagValue1", +["myTag1"] = "tagValue1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, restorePointGroupName, data); @@ -88,13 +88,13 @@ public async Task CreateOrUpdate_CreateOrUpdateARestorePointCollection() string restorePointGroupName = "myRpc"; RestorePointGroupData data = new RestorePointGroupData(new AzureLocation("norwayeast")) { - Source = new RestorePointGroupSource() + Source = new RestorePointGroupSource { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM"), }, Tags = { -["myTag1"] = "tagValue1", +["myTag1"] = "tagValue1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, restorePointGroupName, data); @@ -142,9 +142,9 @@ public async Task Get_GetARestorePointCollectionButNotTheRestorePointsContainedI [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetARestorePointCollectionButNotTheRestorePointsContainedInTheRestorePointCollection() + public async Task Get_GetARestorePointCollectionIncludingTheRestorePointsContainedInTheRestorePointCollection() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get_WithContainedRestorePoints.json // this example is just showing the usage of "RestorePointCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -163,18 +163,22 @@ public async Task Exists_GetARestorePointCollectionButNotTheRestorePointsContain RestorePointGroupCollection collection = resourceGroupResource.GetRestorePointGroups(); // invoke the operation - string restorePointGroupName = "myRpc"; - bool result = await collection.ExistsAsync(restorePointGroupName); + string restorePointGroupName = "rpcName"; + RestorePointGroupResource result = await collection.GetAsync(restorePointGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorePointGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetARestorePointCollectionButNotTheRestorePointsContainedInTheRestorePointCollection() + public async Task GetAll_GetsTheListOfRestorePointCollectionsInAResourceGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get.json - // this example is just showing the usage of "RestorePointCollections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_ListByResourceGroup.json + // this example is just showing the usage of "RestorePointCollections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,30 +195,24 @@ public async Task GetIfExists_GetARestorePointCollectionButNotTheRestorePointsCo // get the collection of this RestorePointGroupResource RestorePointGroupCollection collection = resourceGroupResource.GetRestorePointGroups(); - // invoke the operation - string restorePointGroupName = "myRpc"; - NullableResponse response = await collection.GetIfExistsAsync(restorePointGroupName); - RestorePointGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (RestorePointGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RestorePointGroupData resourceData = result.Data; + RestorePointGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARestorePointCollectionIncludingTheRestorePointsContainedInTheRestorePointCollection() + public async Task Exists_GetARestorePointCollectionButNotTheRestorePointsContainedInTheRestorePointCollection() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get_WithContainedRestorePoints.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get.json // this example is just showing the usage of "RestorePointCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -233,14 +231,10 @@ public async Task Get_GetARestorePointCollectionIncludingTheRestorePointsContain RestorePointGroupCollection collection = resourceGroupResource.GetRestorePointGroups(); // invoke the operation - string restorePointGroupName = "rpcName"; - RestorePointGroupResource result = await collection.GetAsync(restorePointGroupName); + string restorePointGroupName = "myRpc"; + bool result = await collection.ExistsAsync(restorePointGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorePointGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -274,9 +268,9 @@ public async Task Exists_GetARestorePointCollectionIncludingTheRestorePointsCont [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetARestorePointCollectionIncludingTheRestorePointsContainedInTheRestorePointCollection() + public async Task GetIfExists_GetARestorePointCollectionButNotTheRestorePointsContainedInTheRestorePointCollection() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get_WithContainedRestorePoints.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get.json // this example is just showing the usage of "RestorePointCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -295,7 +289,7 @@ public async Task GetIfExists_GetARestorePointCollectionIncludingTheRestorePoint RestorePointGroupCollection collection = resourceGroupResource.GetRestorePointGroups(); // invoke the operation - string restorePointGroupName = "rpcName"; + string restorePointGroupName = "myRpc"; NullableResponse response = await collection.GetIfExistsAsync(restorePointGroupName); RestorePointGroupResource result = response.HasValue ? response.Value : null; @@ -315,10 +309,10 @@ public async Task GetIfExists_GetARestorePointCollectionIncludingTheRestorePoint [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfRestorePointCollectionsInAResourceGroup() + public async Task GetIfExists_GetARestorePointCollectionIncludingTheRestorePointsContainedInTheRestorePointCollection() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_ListByResourceGroup.json - // this example is just showing the usage of "RestorePointCollections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get_WithContainedRestorePoints.json + // this example is just showing the usage of "RestorePointCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -335,17 +329,23 @@ public async Task GetAll_GetsTheListOfRestorePointCollectionsInAResourceGroup() // get the collection of this RestorePointGroupResource RestorePointGroupCollection collection = resourceGroupResource.GetRestorePointGroups(); - // invoke the operation and iterate over the result - await foreach (RestorePointGroupResource item in collection.GetAllAsync()) + // invoke the operation + string restorePointGroupName = "rpcName"; + NullableResponse response = await collection.GetIfExistsAsync(restorePointGroupName); + RestorePointGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RestorePointGroupData resourceData = item.Data; + RestorePointGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointGroupResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointGroupResource.cs index dfa754c9f8ee2..be76ffc4d7ddf 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointGroupResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointGroupResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -19,10 +18,10 @@ public partial class Sample_RestorePointGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RestorePointCollectionUpdateMaximumSetGen() + public async Task Get_GetARestorePointCollectionButNotTheRestorePointsContainedInTheRestorePointCollection() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Update_MaximumSet_Gen.json - // this example is just showing the usage of "RestorePointCollections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get.json + // this example is just showing the usage of "RestorePointCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +31,13 @@ public async Task Update_RestorePointCollectionUpdateMaximumSetGen() // this example assumes you already have this RestorePointGroupResource created on azure // for more information of creating RestorePointGroupResource, please refer to the document of RestorePointGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string restorePointGroupName = "aaaaaaaaaaaaaaaaaaaa"; + string resourceGroupName = "myResourceGroup"; + string restorePointGroupName = "myRpc"; ResourceIdentifier restorePointGroupResourceId = RestorePointGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, restorePointGroupName); RestorePointGroupResource restorePointGroup = client.GetRestorePointGroupResource(restorePointGroupResourceId); // invoke the operation - RestorePointGroupPatch patch = new RestorePointGroupPatch() - { - Source = new RestorePointGroupSource() - { - Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM"), - }, - Tags = -{ -["key8536"] = "aaaaaaaaaaaaaaaaaaa", -}, - }; - RestorePointGroupResource result = await restorePointGroup.UpdateAsync(patch); + RestorePointGroupResource result = await restorePointGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -60,10 +48,10 @@ public async Task Update_RestorePointCollectionUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RestorePointCollectionUpdateMinimumSetGen() + public async Task Get_GetARestorePointCollectionIncludingTheRestorePointsContainedInTheRestorePointCollection() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Update_MinimumSet_Gen.json - // this example is just showing the usage of "RestorePointCollections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get_WithContainedRestorePoints.json + // this example is just showing the usage of "RestorePointCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,14 +61,13 @@ public async Task Update_RestorePointCollectionUpdateMinimumSetGen() // this example assumes you already have this RestorePointGroupResource created on azure // for more information of creating RestorePointGroupResource, please refer to the document of RestorePointGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string restorePointGroupName = "aaaaaaaaaaaaaaaaaa"; + string resourceGroupName = "myResourceGroup"; + string restorePointGroupName = "rpcName"; ResourceIdentifier restorePointGroupResourceId = RestorePointGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, restorePointGroupName); RestorePointGroupResource restorePointGroup = client.GetRestorePointGroupResource(restorePointGroupResourceId); // invoke the operation - RestorePointGroupPatch patch = new RestorePointGroupPatch(); - RestorePointGroupResource result = await restorePointGroup.UpdateAsync(patch); + RestorePointGroupResource result = await restorePointGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -143,10 +130,10 @@ public async Task Delete_RestorePointCollectionDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARestorePointCollectionButNotTheRestorePointsContainedInTheRestorePointCollection() + public async Task Update_RestorePointCollectionUpdateMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get.json - // this example is just showing the usage of "RestorePointCollections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Update_MaximumSet_Gen.json + // this example is just showing the usage of "RestorePointCollections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -156,13 +143,24 @@ public async Task Get_GetARestorePointCollectionButNotTheRestorePointsContainedI // this example assumes you already have this RestorePointGroupResource created on azure // for more information of creating RestorePointGroupResource, please refer to the document of RestorePointGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string restorePointGroupName = "myRpc"; + string resourceGroupName = "rgcompute"; + string restorePointGroupName = "aaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier restorePointGroupResourceId = RestorePointGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, restorePointGroupName); RestorePointGroupResource restorePointGroup = client.GetRestorePointGroupResource(restorePointGroupResourceId); // invoke the operation - RestorePointGroupResource result = await restorePointGroup.GetAsync(); + RestorePointGroupPatch patch = new RestorePointGroupPatch + { + Source = new RestorePointGroupSource + { + Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM"), + }, + Tags = +{ +["key8536"] = "aaaaaaaaaaaaaaaaaaa" +}, + }; + RestorePointGroupResource result = await restorePointGroup.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -173,10 +171,10 @@ public async Task Get_GetARestorePointCollectionButNotTheRestorePointsContainedI [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARestorePointCollectionIncludingTheRestorePointsContainedInTheRestorePointCollection() + public async Task Update_RestorePointCollectionUpdateMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Get_WithContainedRestorePoints.json - // this example is just showing the usage of "RestorePointCollections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_Update_MinimumSet_Gen.json + // this example is just showing the usage of "RestorePointCollections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,13 +184,14 @@ public async Task Get_GetARestorePointCollectionIncludingTheRestorePointsContain // this example assumes you already have this RestorePointGroupResource created on azure // for more information of creating RestorePointGroupResource, please refer to the document of RestorePointGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string restorePointGroupName = "rpcName"; + string resourceGroupName = "rgcompute"; + string restorePointGroupName = "aaaaaaaaaaaaaaaaaa"; ResourceIdentifier restorePointGroupResourceId = RestorePointGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, restorePointGroupName); RestorePointGroupResource restorePointGroup = client.GetRestorePointGroupResource(restorePointGroupResourceId); // invoke the operation - RestorePointGroupResource result = await restorePointGroup.GetAsync(); + RestorePointGroupPatch patch = new RestorePointGroupPatch(); + RestorePointGroupResource result = await restorePointGroup.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -200,36 +199,5 @@ public async Task Get_GetARestorePointCollectionIncludingTheRestorePointsContain // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetRestorePointGroups_GetsTheListOfRestorePointCollectionsInASubscription() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_ListBySubscription.json - // this example is just showing the usage of "RestorePointCollections_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (RestorePointGroupResource item in subscriptionResource.GetRestorePointGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorePointGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointResource.cs index 174ff17242f03..694d37bdf80b1 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_RestorePointResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RestorePointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CopyARestorePointToADifferentRegion() + public async Task Get_GetARestorePoint() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Copy_BetweenRegions.json - // this example is just showing the usage of "RestorePoints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Get.json + // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,12 +38,7 @@ public async Task Update_CopyARestorePointToADifferentRegion() RestorePointResource restorePoint = client.GetRestorePointResource(restorePointResourceId); // invoke the operation - RestorePointData data = new RestorePointData() - { - SourceRestorePointId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/restorePointCollections/sourceRpcName/restorePoints/sourceRpName"), - }; - ArmOperation lro = await restorePoint.UpdateAsync(WaitUntil.Completed, data); - RestorePointResource result = lro.Value; + RestorePointResource result = await restorePoint.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +49,10 @@ public async Task Update_CopyARestorePointToADifferentRegion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateARestorePoint() + public async Task Get_GetRestorePointWithInstanceView() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Create.json - // this example is just showing the usage of "RestorePoints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Get_WithInstanceView.json + // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,18 +69,7 @@ public async Task Update_CreateARestorePoint() RestorePointResource restorePoint = client.GetRestorePointResource(restorePointResourceId); // invoke the operation - RestorePointData data = new RestorePointData() - { - ExcludeDisks = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/disk123"), -} -}, - }; - ArmOperation lro = await restorePoint.UpdateAsync(WaitUntil.Completed, data); - RestorePointResource result = lro.Value; + RestorePointResource result = await restorePoint.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -150,10 +134,10 @@ public async Task Delete_RestorePointDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARestorePoint() + public async Task Update_CopyARestorePointToADifferentRegion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Get.json - // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Copy_BetweenRegions.json + // this example is just showing the usage of "RestorePoints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -170,7 +154,12 @@ public async Task Get_GetARestorePoint() RestorePointResource restorePoint = client.GetRestorePointResource(restorePointResourceId); // invoke the operation - RestorePointResource result = await restorePoint.GetAsync(); + RestorePointData data = new RestorePointData + { + SourceRestorePointId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/restorePointCollections/sourceRpcName/restorePoints/sourceRpName"), + }; + ArmOperation lro = await restorePoint.UpdateAsync(WaitUntil.Completed, data); + RestorePointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -181,10 +170,10 @@ public async Task Get_GetARestorePoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRestorePointWithInstanceView() + public async Task Update_CreateARestorePoint() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Get_WithInstanceView.json - // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePoint_Create.json + // this example is just showing the usage of "RestorePoints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -201,7 +190,15 @@ public async Task Get_GetRestorePointWithInstanceView() RestorePointResource restorePoint = client.GetRestorePointResource(restorePointResourceId); // invoke the operation - RestorePointResource result = await restorePoint.GetAsync(); + RestorePointData data = new RestorePointData + { + ExcludeDisks = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/disk123"), +}}, + }; + ArmOperation lro = await restorePoint.UpdateAsync(WaitUntil.Completed, data); + RestorePointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryCollection.cs index 0697940c04287..0b1b2b6176249 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SharedGalleryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSharedGalleries() + public async Task Get_GetASharedGallery() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGallery_List.json - // this example is just showing the usage of "SharedGalleries_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGallery_Get.json + // this example is just showing the usage of "SharedGalleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListSharedGalleries() AzureLocation location = new AzureLocation("myLocation"); SharedGalleryCollection collection = subscriptionResource.GetSharedGalleries(location); - // invoke the operation and iterate over the result - await foreach (SharedGalleryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SharedGalleryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string galleryUniqueName = "galleryUniqueName"; + SharedGalleryResource result = await collection.GetAsync(galleryUniqueName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedGalleryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASharedGallery() + public async Task GetAll_ListSharedGalleries() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGallery_Get.json - // this example is just showing the usage of "SharedGalleries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGallery_List.json + // this example is just showing the usage of "SharedGalleries_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetASharedGallery() AzureLocation location = new AzureLocation("myLocation"); SharedGalleryCollection collection = subscriptionResource.GetSharedGalleries(location); - // invoke the operation - string galleryUniqueName = "galleryUniqueName"; - SharedGalleryResource result = await collection.GetAsync(galleryUniqueName); + // invoke the operation and iterate over the result + await foreach (SharedGalleryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedGalleryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SharedGalleryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryImageCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryImageCollection.cs index dc030f18cb4f9..b2c183cb74796 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryImageCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryImageCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SharedGalleryImageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSharedGalleryImages() + public async Task Get_GetASharedGalleryImage() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImages_List.json - // this example is just showing the usage of "SharedGalleryImages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImage_Get.json + // this example is just showing the usage of "SharedGalleryImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListSharedGalleryImages() // get the collection of this SharedGalleryImageResource SharedGalleryImageCollection collection = sharedGallery.GetSharedGalleryImages(); - // invoke the operation and iterate over the result - await foreach (SharedGalleryImageResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SharedGalleryImageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string galleryImageName = "myGalleryImageName"; + SharedGalleryImageResource result = await collection.GetAsync(galleryImageName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedGalleryImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASharedGalleryImage() + public async Task GetAll_ListSharedGalleryImages() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImage_Get.json - // this example is just showing the usage of "SharedGalleryImages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImages_List.json + // this example is just showing the usage of "SharedGalleryImages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetASharedGalleryImage() // get the collection of this SharedGalleryImageResource SharedGalleryImageCollection collection = sharedGallery.GetSharedGalleryImages(); - // invoke the operation - string galleryImageName = "myGalleryImageName"; - SharedGalleryImageResource result = await collection.GetAsync(galleryImageName); + // invoke the operation and iterate over the result + await foreach (SharedGalleryImageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedGalleryImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SharedGalleryImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryImageVersionCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryImageVersionCollection.cs index cfc49579f0dda..e0f6f2c42675b 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryImageVersionCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SharedGalleryImageVersionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SharedGalleryImageVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSharedGalleryImageVersions() + public async Task Get_GetASharedGalleryImageVersion() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImageVersions_List.json - // this example is just showing the usage of "SharedGalleryImageVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImageVersion_Get.json + // this example is just showing the usage of "SharedGalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListSharedGalleryImageVersions() // get the collection of this SharedGalleryImageVersionResource SharedGalleryImageVersionCollection collection = sharedGalleryImage.GetSharedGalleryImageVersions(); - // invoke the operation and iterate over the result - await foreach (SharedGalleryImageVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SharedGalleryImageVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string galleryImageVersionName = "myGalleryImageVersionName"; + SharedGalleryImageVersionResource result = await collection.GetAsync(galleryImageVersionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedGalleryImageVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASharedGalleryImageVersion() + public async Task GetAll_ListSharedGalleryImageVersions() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImageVersion_Get.json - // this example is just showing the usage of "SharedGalleryImageVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/sharedGalleryExamples/SharedGalleryImageVersions_List.json + // this example is just showing the usage of "SharedGalleryImageVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetASharedGalleryImageVersion() // get the collection of this SharedGalleryImageVersionResource SharedGalleryImageVersionCollection collection = sharedGalleryImage.GetSharedGalleryImageVersions(); - // invoke the operation - string galleryImageVersionName = "myGalleryImageVersionName"; - SharedGalleryImageVersionResource result = await collection.GetAsync(galleryImageVersionName); + // invoke the operation and iterate over the result + await foreach (SharedGalleryImageVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedGalleryImageVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SharedGalleryImageVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SnapshotCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SnapshotCollection.cs index 9bcb5da618269..30d8fafb45d84 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SnapshotCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SnapshotCollection.cs @@ -300,9 +300,9 @@ public async Task Get_GetInformationAboutASnapshot() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetInformationAboutASnapshot() + public async Task Get_GetInformationAboutAnIncrementalSnapshot() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_GetIncrementalSnapshot.json // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -321,18 +321,22 @@ public async Task Exists_GetInformationAboutASnapshot() SnapshotCollection collection = resourceGroupResource.GetSnapshots(); // invoke the operation - string snapshotName = "mySnapshot"; - bool result = await collection.ExistsAsync(snapshotName); + string snapshotName = "myIncrementalSnapshot"; + SnapshotResource result = await collection.GetAsync(snapshotName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInformationAboutASnapshot() + public async Task GetAll_ListAllSnapshotsInAResourceGroup() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Get.json - // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_ListByResourceGroup.json + // this example is just showing the usage of "Snapshots_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -349,30 +353,24 @@ public async Task GetIfExists_GetInformationAboutASnapshot() // get the collection of this SnapshotResource SnapshotCollection collection = resourceGroupResource.GetSnapshots(); - // invoke the operation - string snapshotName = "mySnapshot"; - NullableResponse response = await collection.GetIfExistsAsync(snapshotName); - SnapshotResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SnapshotResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SnapshotData resourceData = result.Data; + SnapshotData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInformationAboutAnIncrementalSnapshot() + public async Task Exists_GetInformationAboutASnapshot() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_GetIncrementalSnapshot.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Get.json // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -391,14 +389,10 @@ public async Task Get_GetInformationAboutAnIncrementalSnapshot() SnapshotCollection collection = resourceGroupResource.GetSnapshots(); // invoke the operation - string snapshotName = "myIncrementalSnapshot"; - SnapshotResource result = await collection.GetAsync(snapshotName); + string snapshotName = "mySnapshot"; + bool result = await collection.ExistsAsync(snapshotName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -432,9 +426,9 @@ public async Task Exists_GetInformationAboutAnIncrementalSnapshot() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInformationAboutAnIncrementalSnapshot() + public async Task GetIfExists_GetInformationAboutASnapshot() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_GetIncrementalSnapshot.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Get.json // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -453,7 +447,7 @@ public async Task GetIfExists_GetInformationAboutAnIncrementalSnapshot() SnapshotCollection collection = resourceGroupResource.GetSnapshots(); // invoke the operation - string snapshotName = "myIncrementalSnapshot"; + string snapshotName = "mySnapshot"; NullableResponse response = await collection.GetIfExistsAsync(snapshotName); SnapshotResource result = response.HasValue ? response.Value : null; @@ -473,10 +467,10 @@ public async Task GetIfExists_GetInformationAboutAnIncrementalSnapshot() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllSnapshotsInAResourceGroup() + public async Task GetIfExists_GetInformationAboutAnIncrementalSnapshot() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_ListByResourceGroup.json - // this example is just showing the usage of "Snapshots_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_GetIncrementalSnapshot.json + // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -493,17 +487,23 @@ public async Task GetAll_ListAllSnapshotsInAResourceGroup() // get the collection of this SnapshotResource SnapshotCollection collection = resourceGroupResource.GetSnapshots(); - // invoke the operation and iterate over the result - await foreach (SnapshotResource item in collection.GetAllAsync()) + // invoke the operation + string snapshotName = "myIncrementalSnapshot"; + NullableResponse response = await collection.GetIfExistsAsync(snapshotName); + SnapshotResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SnapshotData resourceData = item.Data; + SnapshotData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SnapshotResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SnapshotResource.cs index 52096c5bc758e..91938af771df7 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SnapshotResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SnapshotResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -19,10 +18,10 @@ public partial class Sample_SnapshotResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASnapshotWithAcceleratedNetworking() + public async Task Get_GetInformationAboutASnapshot() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Update_WithAcceleratedNetwork.json - // this example is just showing the usage of "Snapshots_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Get.json + // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,21 +37,7 @@ public async Task Update_UpdateASnapshotWithAcceleratedNetworking() SnapshotResource snapshot = client.GetSnapshotResource(snapshotResourceId); // invoke the operation - SnapshotPatch patch = new SnapshotPatch() - { - Tags = -{ -["department"] = "Development", -["project"] = "UpdateSnapshots", -}, - DiskSizeGB = 20, - SupportedCapabilities = new SupportedCapabilities() - { - AcceleratedNetwork = false, - }, - }; - ArmOperation lro = await snapshot.UpdateAsync(WaitUntil.Completed, patch); - SnapshotResource result = lro.Value; + SnapshotResource result = await snapshot.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -63,10 +48,10 @@ public async Task Update_UpdateASnapshotWithAcceleratedNetworking() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASnapshot() + public async Task Get_GetInformationAboutAnIncrementalSnapshot() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Update.json - // this example is just showing the usage of "Snapshots_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_GetIncrementalSnapshot.json + // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,22 +62,12 @@ public async Task Update_UpdateASnapshot() // for more information of creating SnapshotResource, please refer to the document of SnapshotResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "myResourceGroup"; - string snapshotName = "mySnapshot"; + string snapshotName = "myIncrementalSnapshot"; ResourceIdentifier snapshotResourceId = SnapshotResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, snapshotName); SnapshotResource snapshot = client.GetSnapshotResource(snapshotResourceId); // invoke the operation - SnapshotPatch patch = new SnapshotPatch() - { - Tags = -{ -["department"] = "Development", -["project"] = "UpdateSnapshots", -}, - DiskSizeGB = 20, - }; - ArmOperation lro = await snapshot.UpdateAsync(WaitUntil.Completed, patch); - SnapshotResource result = lro.Value; + SnapshotResource result = await snapshot.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -103,10 +78,10 @@ public async Task Update_UpdateASnapshot() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInformationAboutASnapshot() + public async Task Delete_DeleteASnapshot() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Get.json - // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Delete.json + // this example is just showing the usage of "Snapshots_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,21 +97,17 @@ public async Task Get_GetInformationAboutASnapshot() SnapshotResource snapshot = client.GetSnapshotResource(snapshotResourceId); // invoke the operation - SnapshotResource result = await snapshot.GetAsync(); + await snapshot.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInformationAboutAnIncrementalSnapshot() + public async Task Update_UpdateASnapshotWithAcceleratedNetworking() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_GetIncrementalSnapshot.json - // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Update_WithAcceleratedNetwork.json + // this example is just showing the usage of "Snapshots_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,12 +118,26 @@ public async Task Get_GetInformationAboutAnIncrementalSnapshot() // for more information of creating SnapshotResource, please refer to the document of SnapshotResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "myResourceGroup"; - string snapshotName = "myIncrementalSnapshot"; + string snapshotName = "mySnapshot"; ResourceIdentifier snapshotResourceId = SnapshotResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, snapshotName); SnapshotResource snapshot = client.GetSnapshotResource(snapshotResourceId); // invoke the operation - SnapshotResource result = await snapshot.GetAsync(); + SnapshotPatch patch = new SnapshotPatch + { + Tags = +{ +["department"] = "Development", +["project"] = "UpdateSnapshots" +}, + DiskSizeGB = 20, + SupportedCapabilities = new SupportedCapabilities + { + AcceleratedNetwork = false, + }, + }; + ArmOperation lro = await snapshot.UpdateAsync(WaitUntil.Completed, patch); + SnapshotResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -163,10 +148,10 @@ public async Task Get_GetInformationAboutAnIncrementalSnapshot() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASnapshot() + public async Task Update_UpdateASnapshot() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Delete.json - // this example is just showing the usage of "Snapshots_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_Update.json + // this example is just showing the usage of "Snapshots_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,40 +167,23 @@ public async Task Delete_DeleteASnapshot() SnapshotResource snapshot = client.GetSnapshotResource(snapshotResourceId); // invoke the operation - await snapshot.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSnapshots_ListAllSnapshotsInASubscription() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_ListBySubscription.json - // this example is just showing the usage of "Snapshots_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SnapshotResource item in subscriptionResource.GetSnapshotsAsync()) + SnapshotPatch patch = new SnapshotPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SnapshotData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["department"] = "Development", +["project"] = "UpdateSnapshots" +}, + DiskSizeGB = 20, + }; + ArmOperation lro = await snapshot.UpdateAsync(WaitUntil.Completed, patch); + SnapshotResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SshPublicKeyCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SshPublicKeyCollection.cs index 2ad475d99f5e2..e8f12c8734870 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SshPublicKeyCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SshPublicKeyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SshPublicKeyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SshPublicKeyListByResourceGroupMaximumSetGen() + public async Task CreateOrUpdate_CreateANewSSHPublicKeyResource() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "SshPublicKeys_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Create.json + // this example is just showing the usage of "SshPublicKeys_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,32 +31,35 @@ public async Task GetAll_SshPublicKeyListByResourceGroupMaximumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; + string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this SshPublicKeyResource SshPublicKeyCollection collection = resourceGroupResource.GetSshPublicKeys(); - // invoke the operation and iterate over the result - await foreach (SshPublicKeyResource item in collection.GetAllAsync()) + // invoke the operation + string sshPublicKeyName = "mySshPublicKeyName"; + SshPublicKeyData data = new SshPublicKeyData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SshPublicKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PublicKey = "{ssh-rsa public key}", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sshPublicKeyName, data); + SshPublicKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SshPublicKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SshPublicKeyListByResourceGroupMinimumSetGen() + public async Task Get_GetAnSshPublicKey() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "SshPublicKeys_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Get.json + // this example is just showing the usage of "SshPublicKeys_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,33 +68,31 @@ public async Task GetAll_SshPublicKeyListByResourceGroupMinimumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this SshPublicKeyResource SshPublicKeyCollection collection = resourceGroupResource.GetSshPublicKeys(); - // invoke the operation and iterate over the result - await foreach (SshPublicKeyResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SshPublicKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string sshPublicKeyName = "mySshPublicKeyName"; + SshPublicKeyResource result = await collection.GetAsync(sshPublicKeyName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SshPublicKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateANewSSHPublicKeyResource() + public async Task GetAll_SshPublicKeyListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Create.json - // this example is just showing the usage of "SshPublicKeys_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "SshPublicKeys_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,35 +102,32 @@ public async Task CreateOrUpdate_CreateANewSSHPublicKeyResource() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; + string resourceGroupName = "rgcompute"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this SshPublicKeyResource SshPublicKeyCollection collection = resourceGroupResource.GetSshPublicKeys(); - // invoke the operation - string sshPublicKeyName = "mySshPublicKeyName"; - SshPublicKeyData data = new SshPublicKeyData(new AzureLocation("westus")) + // invoke the operation and iterate over the result + await foreach (SshPublicKeyResource item in collection.GetAllAsync()) { - PublicKey = "{ssh-rsa public key}", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sshPublicKeyName, data); - SshPublicKeyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SshPublicKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SshPublicKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnSshPublicKey() + public async Task GetAll_SshPublicKeyListByResourceGroupMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Get.json - // this example is just showing the usage of "SshPublicKeys_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "SshPublicKeys_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,23 +136,25 @@ public async Task Get_GetAnSshPublicKey() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this SshPublicKeyResource SshPublicKeyCollection collection = resourceGroupResource.GetSshPublicKeys(); - // invoke the operation - string sshPublicKeyName = "mySshPublicKeyName"; - SshPublicKeyResource result = await collection.GetAsync(sshPublicKeyName); + // invoke the operation and iterate over the result + await foreach (SshPublicKeyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SshPublicKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SshPublicKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SshPublicKeyResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SshPublicKeyResource.cs index e33d5bf4204a8..417a7a2801930 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SshPublicKeyResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SshPublicKeyResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -19,72 +18,10 @@ public partial class Sample_SshPublicKeyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSshPublicKeys_SshPublicKeyListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "SshPublicKeys_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SshPublicKeyResource item in subscriptionResource.GetSshPublicKeysAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SshPublicKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSshPublicKeys_SshPublicKeyListBySubscriptionMinimumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "SshPublicKeys_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SshPublicKeyResource item in subscriptionResource.GetSshPublicKeysAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SshPublicKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_SshPublicKeyUpdateMaximumSetGen() + public async Task Get_GetAnSshPublicKey() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Update_MaximumSet_Gen.json - // this example is just showing the usage of "SshPublicKeys_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Get.json + // this example is just showing the usage of "SshPublicKeys_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,22 +30,14 @@ public async Task Update_SshPublicKeyUpdateMaximumSetGen() // this example assumes you already have this SshPublicKeyResource created on azure // for more information of creating SshPublicKeyResource, please refer to the document of SshPublicKeyResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string sshPublicKeyName = "aaaaaaaaaaaa"; + string subscriptionId = "{subscriptionId}"; + string resourceGroupName = "myResourceGroup"; + string sshPublicKeyName = "mySshPublicKeyName"; ResourceIdentifier sshPublicKeyResourceId = SshPublicKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, sshPublicKeyName); SshPublicKeyResource sshPublicKey = client.GetSshPublicKeyResource(sshPublicKeyResourceId); // invoke the operation - SshPublicKeyPatch patch = new SshPublicKeyPatch() - { - PublicKey = "{ssh-rsa public key}", - Tags = -{ -["key2854"] = "a", -}, - }; - SshPublicKeyResource result = await sshPublicKey.UpdateAsync(patch); + SshPublicKeyResource result = await sshPublicKey.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -119,10 +48,10 @@ public async Task Update_SshPublicKeyUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SshPublicKeyUpdateMinimumSetGen() + public async Task Delete_SshPublicKeyDeleteMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Update_MinimumSet_Gen.json - // this example is just showing the usage of "SshPublicKeys_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "SshPublicKeys_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,26 +62,21 @@ public async Task Update_SshPublicKeyUpdateMinimumSetGen() // for more information of creating SshPublicKeyResource, please refer to the document of SshPublicKeyResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string sshPublicKeyName = "aaaaaaaaaaa"; + string sshPublicKeyName = "aaaaaaaaaa"; ResourceIdentifier sshPublicKeyResourceId = SshPublicKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, sshPublicKeyName); SshPublicKeyResource sshPublicKey = client.GetSshPublicKeyResource(sshPublicKeyResourceId); // invoke the operation - SshPublicKeyPatch patch = new SshPublicKeyPatch(); - SshPublicKeyResource result = await sshPublicKey.UpdateAsync(patch); + await sshPublicKey.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SshPublicKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SshPublicKeyDeleteMaximumSetGen() + public async Task Delete_SshPublicKeyDeleteMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Delete_MaximumSet_Gen.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Delete_MinimumSet_Gen.json // this example is just showing the usage of "SshPublicKeys_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -164,7 +88,7 @@ public async Task Delete_SshPublicKeyDeleteMaximumSetGen() // for more information of creating SshPublicKeyResource, please refer to the document of SshPublicKeyResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string sshPublicKeyName = "aaaaaaaaaa"; + string sshPublicKeyName = "aaaaaaaaaaaaaaaaaaa"; ResourceIdentifier sshPublicKeyResourceId = SshPublicKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, sshPublicKeyName); SshPublicKeyResource sshPublicKey = client.GetSshPublicKeyResource(sshPublicKeyResourceId); @@ -176,10 +100,10 @@ public async Task Delete_SshPublicKeyDeleteMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SshPublicKeyDeleteMinimumSetGen() + public async Task Update_SshPublicKeyUpdateMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "SshPublicKeys_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Update_MaximumSet_Gen.json + // this example is just showing the usage of "SshPublicKeys_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,22 +114,34 @@ public async Task Delete_SshPublicKeyDeleteMinimumSetGen() // for more information of creating SshPublicKeyResource, please refer to the document of SshPublicKeyResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string sshPublicKeyName = "aaaaaaaaaaaaaaaaaaa"; + string sshPublicKeyName = "aaaaaaaaaaaa"; ResourceIdentifier sshPublicKeyResourceId = SshPublicKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, sshPublicKeyName); SshPublicKeyResource sshPublicKey = client.GetSshPublicKeyResource(sshPublicKeyResourceId); // invoke the operation - await sshPublicKey.DeleteAsync(WaitUntil.Completed); + SshPublicKeyPatch patch = new SshPublicKeyPatch + { + PublicKey = "{ssh-rsa public key}", + Tags = +{ +["key2854"] = "a" +}, + }; + SshPublicKeyResource result = await sshPublicKey.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SshPublicKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnSshPublicKey() + public async Task Update_SshPublicKeyUpdateMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Get.json - // this example is just showing the usage of "SshPublicKeys_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_Update_MinimumSet_Gen.json + // this example is just showing the usage of "SshPublicKeys_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -214,14 +150,15 @@ public async Task Get_GetAnSshPublicKey() // this example assumes you already have this SshPublicKeyResource created on azure // for more information of creating SshPublicKeyResource, please refer to the document of SshPublicKeyResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; - string sshPublicKeyName = "mySshPublicKeyName"; + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string sshPublicKeyName = "aaaaaaaaaaa"; ResourceIdentifier sshPublicKeyResourceId = SshPublicKeyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, sshPublicKeyName); SshPublicKeyResource sshPublicKey = client.GetSshPublicKeyResource(sshPublicKeyResourceId); // invoke the operation - SshPublicKeyResource result = await sshPublicKey.GetAsync(); + SshPublicKeyPatch patch = new SshPublicKeyPatch(); + SshPublicKeyResource result = await sshPublicKey.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -251,7 +188,7 @@ public async Task GenerateKeyPair_GenerateAnSSHKeyPairWithEd25519Encryption() SshPublicKeyResource sshPublicKey = client.GetSshPublicKeyResource(sshPublicKeyResourceId); // invoke the operation - SshGenerateKeyPairInputContent content = new SshGenerateKeyPairInputContent() + SshGenerateKeyPairInputContent content = new SshGenerateKeyPairInputContent { EncryptionType = SshEncryptionType.Ed25519, }; @@ -281,7 +218,7 @@ public async Task GenerateKeyPair_GenerateAnSSHKeyPairWithRSAEncryption() SshPublicKeyResource sshPublicKey = client.GetSshPublicKeyResource(sshPublicKeyResourceId); // invoke the operation - SshGenerateKeyPairInputContent content = new SshGenerateKeyPairInputContent() + SshGenerateKeyPairInputContent content = new SshGenerateKeyPairInputContent { EncryptionType = SshEncryptionType.RSA, }; diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 2962c3a54d731..67a53aff962a8 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -129,6 +129,196 @@ public async Task GetVirtualMachineSizes_VirtualMachineSizesListMinimumSetGen() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualMachineScaleSetsByLocation_ListsAllTheVMScaleSetsUnderTheSpecifiedSubscriptionForTheSpecifiedLocation() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_ListBySubscription_ByLocation.json + // this example is just showing the usage of "VirtualMachineScaleSets_ListByLocation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("eastus"); + await foreach (VirtualMachineScaleSetResource item in subscriptionResource.GetVirtualMachineScaleSetsByLocationAsync(location)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualMachineScaleSets_VirtualMachineScaleSetListAllMaximumSetGen() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_ListAll_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSets_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VirtualMachineScaleSetResource item in subscriptionResource.GetVirtualMachineScaleSetsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualMachineScaleSets_VirtualMachineScaleSetListAllMinimumSetGen() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_ListAll_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSets_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VirtualMachineScaleSetResource item in subscriptionResource.GetVirtualMachineScaleSetsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualMachinesByLocation_ListsAllTheVirtualMachinesUnderTheSpecifiedSubscriptionForTheSpecifiedLocation() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_ListBySubscription_ByLocation.json + // this example is just showing the usage of "VirtualMachines_ListByLocation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscriptionId}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("eastus"); + await foreach (VirtualMachineResource item in subscriptionResource.GetVirtualMachinesByLocationAsync(location)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualMachines_VirtualMachineListAllMaximumSetGen() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_ListAll_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachines_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string statusOnly = "aaaaaa"; + string filter = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + await foreach (VirtualMachineResource item in subscriptionResource.GetVirtualMachinesAsync(statusOnly: statusOnly, filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualMachines_VirtualMachineListAllMinimumSetGen() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_ListAll_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachines_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VirtualMachineResource item in subscriptionResource.GetVirtualMachinesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetVirtualMachineImage_VirtualMachineImageGetMaximumSetGen() @@ -206,7 +396,11 @@ public async Task GetVirtualMachineImages_VirtualMachineImageListMaximumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - SubscriptionResourceGetVirtualMachineImagesOptions options = new SubscriptionResourceGetVirtualMachineImagesOptions(location: new AzureLocation("aaaaaaaaaaaaaaa"), publisherName: "aaaaaa", offer: "aaaaaaaaaaaaaaaa", skus: "aaaaaaaaaaaaaaaaaaaaaaa") { Expand = "aaaaaaaaaaaaaaaaaaaaaaaa", Top = 18, Orderby = "aa" }; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaaaa"); + string publisherName = "aaaaaa"; + string offer = "aaaaaaaaaaaaaaaa"; + string skus = "aaaaaaaaaaaaaaaaaaaaaaa"; + SubscriptionResourceGetVirtualMachineImagesOptions options = new SubscriptionResourceGetVirtualMachineImagesOptions(location, publisherName, offer, skus) { Expand = "aaaaaaaaaaaaaaaaaaaaaaaa", Top = 18, Orderby = "aa" }; await foreach (VirtualMachineImageBase item in subscriptionResource.GetVirtualMachineImagesAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -234,7 +428,11 @@ public async Task GetVirtualMachineImages_VirtualMachineImageListMinimumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - SubscriptionResourceGetVirtualMachineImagesOptions options = new SubscriptionResourceGetVirtualMachineImagesOptions(location: new AzureLocation("aaaaaaa"), publisherName: "aaaaaaaaaaa", offer: "aaaaaaaaaa", skus: "aaaaaa") { }; + AzureLocation location = new AzureLocation("aaaaaaa"); + string publisherName = "aaaaaaaaaaa"; + string offer = "aaaaaaaaaa"; + string skus = "aaaaaa"; + SubscriptionResourceGetVirtualMachineImagesOptions options = new SubscriptionResourceGetVirtualMachineImagesOptions(location, publisherName, offer, skus); await foreach (VirtualMachineImageBase item in subscriptionResource.GetVirtualMachineImagesAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -494,7 +692,19 @@ public async Task GetVirtualMachineImagesEdgeZone_VirtualMachineImagesEdgeZoneGe SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - SubscriptionResourceGetVirtualMachineImagesEdgeZoneOptions options = new SubscriptionResourceGetVirtualMachineImagesEdgeZoneOptions(location: new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaaa"), edgeZone: "aaaaaaaa", publisherName: "aaaaaaaaaaaaaaaaaaaaaaa", offer: "aaaaaaaaaaaaaaaaaaaaaaaaaaa", skus: "aaaaaaaaaa", version: "aaaaaaaaaaaaaaaaaaaaaaaaaaa") { }; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaaa"); + string edgeZone = "aaaaaaaa"; + string publisherName = "aaaaaaaaaaaaaaaaaaaaaaa"; + string offer = "aaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string skus = "aaaaaaaaaa"; + string version = "aaaaaaaaaaaaaaaaaaaaaaaaaaa"; + SubscriptionResourceGetVirtualMachineImagesEdgeZoneOptions options = new SubscriptionResourceGetVirtualMachineImagesEdgeZoneOptions( + location, + edgeZone, + publisherName, + offer, + skus, + version); VirtualMachineImage result = await subscriptionResource.GetVirtualMachineImagesEdgeZoneAsync(options); Console.WriteLine($"Succeeded: {result}"); @@ -519,7 +729,19 @@ public async Task GetVirtualMachineImagesEdgeZone_VirtualMachineImagesEdgeZoneGe SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - SubscriptionResourceGetVirtualMachineImagesEdgeZoneOptions options = new SubscriptionResourceGetVirtualMachineImagesEdgeZoneOptions(location: new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaa"), edgeZone: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa", publisherName: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa", offer: "aaaaaaaaaaa", skus: "aaaaaaaaaaaaaaaaaa", version: "aa") { }; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaa"); + string edgeZone = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string offer = "aaaaaaaaaaa"; + string skus = "aaaaaaaaaaaaaaaaaa"; + string version = "aa"; + SubscriptionResourceGetVirtualMachineImagesEdgeZoneOptions options = new SubscriptionResourceGetVirtualMachineImagesEdgeZoneOptions( + location, + edgeZone, + publisherName, + offer, + skus, + version); VirtualMachineImage result = await subscriptionResource.GetVirtualMachineImagesEdgeZoneAsync(options); Console.WriteLine($"Succeeded: {result}"); @@ -544,7 +766,12 @@ public async Task GetVirtualMachineImagesEdgeZones_VirtualMachineImagesEdgeZoneL SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - SubscriptionResourceGetVirtualMachineImagesEdgeZonesOptions options = new SubscriptionResourceGetVirtualMachineImagesEdgeZonesOptions(location: new AzureLocation("aaaaaaaaaaaaaaa"), edgeZone: "aaaaaaaaaaaaaaaaaaaaaaaaa", publisherName: "aaaa", offer: "aaaaaaaaaaaaaaaaaaaaaaaaaa", skus: "aaaaaaaaaaaaaaaaaaaaaaa") { Expand = "aaaaaaaaaaaaaaaaaaaaaaaa", Top = 12, Orderby = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa" }; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaaaa"); + string edgeZone = "aaaaaaaaaaaaaaaaaaaaaaaaa"; + string publisherName = "aaaa"; + string offer = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; + string skus = "aaaaaaaaaaaaaaaaaaaaaaa"; + SubscriptionResourceGetVirtualMachineImagesEdgeZonesOptions options = new SubscriptionResourceGetVirtualMachineImagesEdgeZonesOptions(location, edgeZone, publisherName, offer, skus) { Expand = "aaaaaaaaaaaaaaaaaaaaaaaa", Top = 12, Orderby = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa" }; await foreach (VirtualMachineImageBase item in subscriptionResource.GetVirtualMachineImagesEdgeZonesAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -572,7 +799,12 @@ public async Task GetVirtualMachineImagesEdgeZones_VirtualMachineImagesEdgeZoneL SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - SubscriptionResourceGetVirtualMachineImagesEdgeZonesOptions options = new SubscriptionResourceGetVirtualMachineImagesEdgeZonesOptions(location: new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), edgeZone: "aaaaa", publisherName: "aaaaaaaaaaaaaaaaaaa", offer: "aaaaaaaaaaaaaaaaaaaaaaaaaaa", skus: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa") { }; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + string edgeZone = "aaaaa"; + string publisherName = "aaaaaaaaaaaaaaaaaaa"; + string offer = "aaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string skus = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + SubscriptionResourceGetVirtualMachineImagesEdgeZonesOptions options = new SubscriptionResourceGetVirtualMachineImagesEdgeZonesOptions(location, edgeZone, publisherName, offer, skus); await foreach (VirtualMachineImageBase item in subscriptionResource.GetVirtualMachineImagesEdgeZonesAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -763,10 +995,42 @@ public async Task GetVirtualMachineImageEdgeZoneSkus_VirtualMachineImagesEdgeZon [Test] [Ignore("Only validating compilation of examples")] - public async Task ExportLogAnalyticsRequestRateByInterval_ExportLogsWhichContainAllApiRequestsMadeToComputeResourceProviderWithinTheGivenTimePeriodBrokenDownByIntervals() + public async Task GetAvailabilitySets_ListAvailabilitySetsInASubscription() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/logAnalyticExamples/LogAnalytics_RequestRateByInterval.json - // this example is just showing the usage of "LogAnalytics_ExportRequestRateByInterval" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/availabilitySetExamples/AvailabilitySet_ListBySubscription.json + // this example is just showing the usage of "AvailabilitySets_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscriptionId}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string expand = "virtualMachines\\$ref"; + await foreach (AvailabilitySetResource item in subscriptionResource.GetAvailabilitySetsAsync(expand: expand)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvailabilitySetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetProximityPlacementGroups_ListProximityPlacementGroups() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/proximityPlacementGroupExamples/ProximityPlacementGroup_ListBySubscription.json + // this example is just showing the usage of "ProximityPlacementGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -779,24 +1043,25 @@ public async Task ExportLogAnalyticsRequestRateByInterval_ExportLogsWhichContain ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - // invoke the operation - AzureLocation location = new AzureLocation("westus"); - RequestRateByIntervalContent content = new RequestRateByIntervalContent(new Uri("https://somesasuri"), DateTimeOffset.Parse("2018-01-21T01:54:06.862601Z"), DateTimeOffset.Parse("2018-01-23T01:54:06.862601Z"), IntervalInMins.FiveMins) + // invoke the operation and iterate over the result + await foreach (ProximityPlacementGroupResource item in subscriptionResource.GetProximityPlacementGroupsAsync()) { - GroupByResourceName = true, - }; - ArmOperation lro = await subscriptionResource.ExportLogAnalyticsRequestRateByIntervalAsync(WaitUntil.Completed, location, content); - LogAnalytics result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProximityPlacementGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ExportLogAnalyticsThrottledRequests_ExportLogsWhichContainAllThrottledApiRequestsMadeToComputeResourceProviderWithinTheGivenTimePeriod() + public async Task GetDedicatedHostGroups_DedicatedHostGroupListBySubscriptionMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/logAnalyticExamples/LogAnalytics_ThrottledRequests.json - // this example is just showing the usage of "LogAnalytics_ExportThrottledRequests" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "DedicatedHostGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -809,27 +1074,25 @@ public async Task ExportLogAnalyticsThrottledRequests_ExportLogsWhichContainAllT ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - // invoke the operation - AzureLocation location = new AzureLocation("westus"); - ThrottledRequestsContent content = new ThrottledRequestsContent(new Uri("https://somesasuri"), DateTimeOffset.Parse("2018-01-21T01:54:06.862601Z"), DateTimeOffset.Parse("2018-01-23T01:54:06.862601Z")) + // invoke the operation and iterate over the result + await foreach (DedicatedHostGroupResource item in subscriptionResource.GetDedicatedHostGroupsAsync()) { - GroupByOperationName = true, - GroupByResourceName = false, - GroupByClientApplicationId = false, - GroupByUserAgent = false, - }; - ArmOperation lro = await subscriptionResource.ExportLogAnalyticsThrottledRequestsAsync(WaitUntil.Completed, location, content); - LogAnalytics result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHostGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUs() + public async Task GetDedicatedHostGroups_DedicatedHostGroupListBySubscriptionMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Skus/stable/2021-07-01/examples/skus/ListAvailableResourceSkus.json - // this example is just showing the usage of "ResourceSkus_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/dedicatedHostExamples/DedicatedHostGroup_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "DedicatedHostGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -843,9 +1106,13 @@ public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUs() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - await foreach (ComputeResourceSku item in subscriptionResource.GetComputeResourceSkusAsync()) + await foreach (DedicatedHostGroupResource item in subscriptionResource.GetDedicatedHostGroupsAsync()) { - Console.WriteLine($"Succeeded: {item}"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHostGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } Console.WriteLine("Succeeded"); @@ -853,10 +1120,10 @@ public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUs() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUsForTheSpecifiedRegion() + public async Task GetSshPublicKeys_SshPublicKeyListBySubscriptionMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Skus/stable/2021-07-01/examples/skus/ListAvailableResourceSkusForARegion.json - // this example is just showing the usage of "ResourceSkus_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "SshPublicKeys_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -870,10 +1137,13 @@ public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUsForTheSpec SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - string filter = "location eq 'westus'"; - await foreach (ComputeResourceSku item in subscriptionResource.GetComputeResourceSkusAsync(filter: filter)) + await foreach (SshPublicKeyResource item in subscriptionResource.GetSshPublicKeysAsync()) { - Console.WriteLine($"Succeeded: {item}"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SshPublicKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } Console.WriteLine("Succeeded"); @@ -881,10 +1151,10 @@ public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUsForTheSpec [Test] [Ignore("Only validating compilation of examples")] - public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUsWithExtendedLocationInformation() + public async Task GetSshPublicKeys_SshPublicKeyListBySubscriptionMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Skus/stable/2021-07-01/examples/skus/ListAvailableResourceSkusWithExtendedLocations.json - // this example is just showing the usage of "ResourceSkus_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/sshPublicKeyExamples/SshPublicKey_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "SshPublicKeys_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -898,10 +1168,525 @@ public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUsWithExtend SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - string includeExtendedLocations = "true"; - await foreach (ComputeResourceSku item in subscriptionResource.GetComputeResourceSkusAsync(includeExtendedLocations: includeExtendedLocations)) + await foreach (SshPublicKeyResource item in subscriptionResource.GetSshPublicKeysAsync()) { - Console.WriteLine($"Succeeded: {item}"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SshPublicKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDiskImages_ListAllVirtualMachineImagesInASubscription() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/imageExamples/Image_ListBySubscription.json + // this example is just showing the usage of "Images_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DiskImageResource item in subscriptionResource.GetDiskImagesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetRestorePointGroups_GetsTheListOfRestorePointCollectionsInASubscription() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/restorePointExamples/RestorePointCollection_ListBySubscription.json + // this example is just showing the usage of "RestorePointCollections_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (RestorePointGroupResource item in subscriptionResource.GetRestorePointGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorePointGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCapacityReservationGroups_ListCapacityReservationGroupsInSubscription() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_ListBySubscription.json + // this example is just showing the usage of "CapacityReservationGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + CapacityReservationGroupGetExpand? expand = CapacityReservationGroupGetExpand.VirtualMachinesRef; + await foreach (CapacityReservationGroupResource item in subscriptionResource.GetCapacityReservationGroupsAsync(expand: expand)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CapacityReservationGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCapacityReservationGroups_ListCapacityReservationGroupsWithResourceIdsOnlyInSubscription() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/capacityReservationExamples/CapacityReservationGroup_ListBySubscriptionWithResourceIdsQuery.json + // this example is just showing the usage of "CapacityReservationGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + ResourceIdOptionsForGetCapacityReservationGroup? resourceIdsOnly = ResourceIdOptionsForGetCapacityReservationGroup.All; + await foreach (CapacityReservationGroupResource item in subscriptionResource.GetCapacityReservationGroupsAsync(resourceIdsOnly: resourceIdsOnly)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CapacityReservationGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task ExportLogAnalyticsRequestRateByInterval_ExportLogsWhichContainAllApiRequestsMadeToComputeResourceProviderWithinTheGivenTimePeriodBrokenDownByIntervals() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/logAnalyticExamples/LogAnalytics_RequestRateByInterval.json + // this example is just showing the usage of "LogAnalytics_ExportRequestRateByInterval" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("westus"); + RequestRateByIntervalContent content = new RequestRateByIntervalContent(new Uri("https://somesasuri"), DateTimeOffset.Parse("2018-01-21T01:54:06.862601Z"), DateTimeOffset.Parse("2018-01-23T01:54:06.862601Z"), IntervalInMins.FiveMins) + { + GroupByResourceName = true, + }; + ArmOperation lro = await subscriptionResource.ExportLogAnalyticsRequestRateByIntervalAsync(WaitUntil.Completed, location, content); + LogAnalytics result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task ExportLogAnalyticsThrottledRequests_ExportLogsWhichContainAllThrottledApiRequestsMadeToComputeResourceProviderWithinTheGivenTimePeriod() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/logAnalyticExamples/LogAnalytics_ThrottledRequests.json + // this example is just showing the usage of "LogAnalytics_ExportThrottledRequests" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("westus"); + ThrottledRequestsContent content = new ThrottledRequestsContent(new Uri("https://somesasuri"), DateTimeOffset.Parse("2018-01-21T01:54:06.862601Z"), DateTimeOffset.Parse("2018-01-23T01:54:06.862601Z")) + { + GroupByOperationName = true, + GroupByResourceName = false, + GroupByClientApplicationId = false, + GroupByUserAgent = false, + }; + ArmOperation lro = await subscriptionResource.ExportLogAnalyticsThrottledRequestsAsync(WaitUntil.Completed, location, content); + LogAnalytics result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualMachineRunCommands_VirtualMachineRunCommandList() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/RunCommand_List.json + // this example is just showing the usage of "VirtualMachineRunCommands_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("SoutheastAsia"); + await foreach (RunCommandDocumentBase item in subscriptionResource.GetVirtualMachineRunCommandsAsync(location)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualMachineRunCommand_VirtualMachineRunCommandGet() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/RunCommand_Get.json + // this example is just showing the usage of "VirtualMachineRunCommands_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "24fb23e3-6ba3-41f0-9b6e-e41131d5d61e"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("SoutheastAsia"); + string commandId = "RunPowerShellScript"; + RunCommandDocument result = await subscriptionResource.GetVirtualMachineRunCommandAsync(location, commandId); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetManagedDisks_ListAllManagedDisksInASubscription() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskExamples/Disk_ListBySubscription.json + // this example is just showing the usage of "Disks_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ManagedDiskResource item in subscriptionResource.GetManagedDisksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDiskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDiskAccesses_ListAllDiskAccessResourcesInASubscription() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskAccessExamples/DiskAccess_ListBySubscription.json + // this example is just showing the usage of "DiskAccesses_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DiskAccessResource item in subscriptionResource.GetDiskAccessesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskAccessData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDiskEncryptionSets_ListAllDiskEncryptionSetsInASubscription() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/diskEncryptionSetExamples/DiskEncryptionSet_ListBySubscription.json + // this example is just showing the usage of "DiskEncryptionSets_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DiskEncryptionSetResource item in subscriptionResource.GetDiskEncryptionSetsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskEncryptionSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSnapshots_ListAllSnapshotsInASubscription() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/DiskRP/stable/2024-03-02/examples/snapshotExamples/Snapshot_ListBySubscription.json + // this example is just showing the usage of "Snapshots_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SnapshotResource item in subscriptionResource.GetSnapshotsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SnapshotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUs() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Skus/stable/2021-07-01/examples/skus/ListAvailableResourceSkus.json + // this example is just showing the usage of "ResourceSkus_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ComputeResourceSku item in subscriptionResource.GetComputeResourceSkusAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUsForTheSpecifiedRegion() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Skus/stable/2021-07-01/examples/skus/ListAvailableResourceSkusForARegion.json + // this example is just showing the usage of "ResourceSkus_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string filter = "location eq 'westus'"; + await foreach (ComputeResourceSku item in subscriptionResource.GetComputeResourceSkusAsync(filter: filter)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetComputeResourceSkus_ListsAllAvailableResourceSKUsWithExtendedLocationInformation() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Skus/stable/2021-07-01/examples/skus/ListAvailableResourceSkusWithExtendedLocations.json + // this example is just showing the usage of "ResourceSkus_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string includeExtendedLocations = "true"; + await foreach (ComputeResourceSku item in subscriptionResource.GetComputeResourceSkusAsync(includeExtendedLocations: includeExtendedLocations)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetGalleries_ListGalleriesInASubscription() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/GalleryRP/stable/2023-07-03/examples/galleryExamples/Gallery_ListBySubscription.json + // this example is just showing the usage of "Galleries_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (GalleryResource item in subscriptionResource.GetGalleriesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GalleryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCloudServices_ListCloudServicesInASubscription() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/CloudserviceRP/stable/2022-09-04/examples/CloudService_List_BySubscription.json + // this example is just showing the usage of "CloudServices_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CloudServiceResource item in subscriptionResource.GetCloudServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } Console.WriteLine("Succeeded"); diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineCollection.cs index d1a85862f02b3..be88ca298412c 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineCollection.cs @@ -44,13 +44,13 @@ public async Task CreateOrUpdate_CreateALinuxVmWithAPatchSettingAssessmentModeOf string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2SV3, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "Canonical", Offer = "UbuntuServer", @@ -61,36 +61,33 @@ public async Task CreateOrUpdate_CreateALinuxVmWithAPatchSettingAssessmentModeOf { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", - LinuxConfiguration = new LinuxConfiguration() + LinuxConfiguration = new LinuxConfiguration { ProvisionVmAgent = true, - PatchSettings = new LinuxPatchSettings() + PatchSettings = new LinuxPatchSettings { AssessmentMode = LinuxPatchAssessmentMode.ImageDefault, }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -129,13 +126,13 @@ public async Task CreateOrUpdate_CreateALinuxVmWithAPatchSettingPatchModeOfAutom string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2SV3, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "Canonical", Offer = "UbuntuServer", @@ -146,25 +143,25 @@ public async Task CreateOrUpdate_CreateALinuxVmWithAPatchSettingPatchModeOfAutom { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", - LinuxConfiguration = new LinuxConfiguration() + LinuxConfiguration = new LinuxConfiguration { ProvisionVmAgent = true, - PatchSettings = new LinuxPatchSettings() + PatchSettings = new LinuxPatchSettings { PatchMode = LinuxVmGuestPatchMode.AutomaticByPlatform, AssessmentMode = LinuxPatchAssessmentMode.AutomaticByPlatform, - AutomaticByPlatformSettings = new LinuxVmGuestPatchAutomaticByPlatformSettings() + AutomaticByPlatformSettings = new LinuxVmGuestPatchAutomaticByPlatformSettings { RebootSetting = LinuxVmGuestPatchAutomaticByPlatformRebootSetting.Never, BypassPlatformSafetyChecksOnUserSchedule = true, @@ -172,16 +169,13 @@ public async Task CreateOrUpdate_CreateALinuxVmWithAPatchSettingPatchModeOfAutom }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -220,13 +214,13 @@ public async Task CreateOrUpdate_CreateALinuxVmWithAPatchSettingPatchModeOfImage string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2SV3, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "Canonical", Offer = "UbuntuServer", @@ -237,36 +231,33 @@ public async Task CreateOrUpdate_CreateALinuxVmWithAPatchSettingPatchModeOfImage { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", - LinuxConfiguration = new LinuxConfiguration() + LinuxConfiguration = new LinuxConfiguration { ProvisionVmAgent = true, - PatchSettings = new LinuxPatchSettings() + PatchSettings = new LinuxPatchSettings { PatchMode = LinuxVmGuestPatchMode.ImageDefault, }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -305,13 +296,13 @@ public async Task CreateOrUpdate_CreateALinuxVmWithAPatchSettingsPatchModeAndAss string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2SV3, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "Canonical", Offer = "UbuntuServer", @@ -322,37 +313,34 @@ public async Task CreateOrUpdate_CreateALinuxVmWithAPatchSettingsPatchModeAndAss { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", - LinuxConfiguration = new LinuxConfiguration() + LinuxConfiguration = new LinuxConfiguration { ProvisionVmAgent = true, - PatchSettings = new LinuxPatchSettings() + PatchSettings = new LinuxPatchSettings { PatchMode = LinuxVmGuestPatchMode.AutomaticByPlatform, AssessmentMode = LinuxPatchAssessmentMode.AutomaticByPlatform, }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -391,13 +379,13 @@ public async Task CreateOrUpdate_CreateAVMFromACommunityGalleryImage() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { CommunityGalleryImageId = "/CommunityGalleries/galleryPublicName/Images/communityGalleryImageName/Versions/communityGalleryImageVersionName", }, @@ -405,28 +393,25 @@ public async Task CreateOrUpdate_CreateAVMFromACommunityGalleryImage() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -465,13 +450,13 @@ public async Task CreateOrUpdate_CreateAVMFromASharedGalleryImage() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { SharedGalleryImageUniqueId = "/SharedGalleries/sharedGalleryName/Images/sharedGalleryImageName/Versions/sharedGalleryImageVersionName", }, @@ -479,28 +464,25 @@ public async Task CreateOrUpdate_CreateAVMFromASharedGalleryImage() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -539,22 +521,22 @@ public async Task CreateOrUpdate_CreateAVMWithDiskControllerType() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD4V3, }, - ScheduledEventsPolicy = new ScheduledEventsPolicy() + ScheduledEventsPolicy = new ScheduledEventsPolicy { - UserInitiatedRedeploy = new UserInitiatedRedeploy() + UserInitiatedRedeploy = new UserInitiatedRedeploy { AutomaticallyApprove = true, }, AutomaticallyApprove = true, Enable = true, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -565,31 +547,28 @@ public async Task CreateOrUpdate_CreateAVMWithDiskControllerType() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, DiskControllerType = DiskControllerType.NVMe, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), @@ -632,13 +611,13 @@ public async Task CreateOrUpdate_CreateAVMWithHibernationEnabled() string vmName = "{vm-name}"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("eastus2euap")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2SV3, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -649,34 +628,31 @@ public async Task CreateOrUpdate_CreateAVMWithHibernationEnabled() { Name = "vmOSdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - AdditionalCapabilities = new AdditionalCapabilities() + AdditionalCapabilities = new AdditionalCapabilities { HibernationEnabled = true, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "{vm-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), @@ -718,13 +694,13 @@ public async Task CreateOrUpdate_CreateAVMWithProxyAgentSettingsOfEnabledAndMode string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2SV3, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -735,32 +711,29 @@ public async Task CreateOrUpdate_CreateAVMWithProxyAgentSettingsOfEnabledAndMode { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardSsdLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - ProxyAgentSettings = new ProxyAgentSettings() + ProxyAgentSettings = new ProxyAgentSettings { Enabled = true, Mode = Mode.Enforce, @@ -803,13 +776,13 @@ public async Task CreateOrUpdate_CreateAVMWithUefiSettingsOfSecureBootAndVTPM() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2SV3, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "windowsserver-gen2preview-preview", @@ -820,32 +793,29 @@ public async Task CreateOrUpdate_CreateAVMWithUefiSettingsOfSecureBootAndVTPM() { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardSsdLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - UefiSettings = new UefiSettings() + UefiSettings = new UefiSettings { IsSecureBootEnabled = true, IsVirtualTpmEnabled = true, @@ -889,13 +859,13 @@ public async Task CreateOrUpdate_CreateAVMWithUserData() string vmName = "{vm-name}"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -906,30 +876,27 @@ public async Task CreateOrUpdate_CreateAVMWithUserData() { Name = "vmOSdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "{vm-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), @@ -972,18 +939,18 @@ public async Task CreateOrUpdate_CreateAVMWithVMSizeProperties() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD4V3, - VmSizeProperties = new VirtualMachineSizeProperties() + VmSizeProperties = new VirtualMachineSizeProperties { VCpusAvailable = 1, VCpusPerCore = 1, }, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -994,30 +961,27 @@ public async Task CreateOrUpdate_CreateAVMWithVMSizeProperties() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), @@ -1064,16 +1028,16 @@ public async Task CreateOrUpdate_CreateAVMWithEncryptionIdentity() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity")] = new UserAssignedIdentity() }, }, - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2SV3, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1084,30 +1048,27 @@ public async Task CreateOrUpdate_CreateAVMWithEncryptionIdentity() { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardSsdLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { UserAssignedIdentityResourceId = "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity", }, @@ -1148,13 +1109,13 @@ public async Task CreateOrUpdate_CreateAVMWithNetworkInterfaceConfiguration() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1165,35 +1126,31 @@ public async Task CreateOrUpdate_CreateAVMWithNetworkInterfaceConfiguration() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { NetworkApiVersion = NetworkApiVersion.TwoThousandTwenty1101, - NetworkInterfaceConfigurations = -{ -new VirtualMachineNetworkInterfaceConfiguration("{nic-config-name}") + NetworkInterfaceConfigurations = {new VirtualMachineNetworkInterfaceConfiguration("{nic-config-name}") { Primary = true, DeleteOption = ComputeDeleteOption.Delete, -IPConfigurations = -{ -new VirtualMachineNetworkInterfaceIPConfiguration("{ip-config-name}") +IPConfigurations = {new VirtualMachineNetworkInterfaceIPConfiguration("{ip-config-name}") { Primary = true, PublicIPAddressConfiguration = new VirtualMachinePublicIPAddressConfiguration("{publicIP-config-name}") { -Sku = new ComputePublicIPAddressSku() +Sku = new ComputePublicIPAddressSku { Name = ComputePublicIPAddressSkuName.Basic, Tier = ComputePublicIPAddressSkuTier.Global, @@ -1201,10 +1158,8 @@ public async Task CreateOrUpdate_CreateAVMWithNetworkInterfaceConfiguration() DeleteOption = ComputeDeleteOption.Detach, PublicIPAllocationMethod = PublicIPAllocationMethod.Static, }, -} -}, -} -}, +}}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -1243,13 +1198,13 @@ public async Task CreateOrUpdate_CreateAVMWithNetworkInterfaceConfigurationWithP string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1260,35 +1215,31 @@ public async Task CreateOrUpdate_CreateAVMWithNetworkInterfaceConfigurationWithP { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { NetworkApiVersion = NetworkApiVersion.TwoThousandTwenty1101, - NetworkInterfaceConfigurations = -{ -new VirtualMachineNetworkInterfaceConfiguration("{nic-config-name}") + NetworkInterfaceConfigurations = {new VirtualMachineNetworkInterfaceConfiguration("{nic-config-name}") { Primary = true, DeleteOption = ComputeDeleteOption.Delete, -IPConfigurations = -{ -new VirtualMachineNetworkInterfaceIPConfiguration("{ip-config-name}") +IPConfigurations = {new VirtualMachineNetworkInterfaceIPConfiguration("{ip-config-name}") { Primary = true, PublicIPAddressConfiguration = new VirtualMachinePublicIPAddressConfiguration("{publicIP-config-name}") { -Sku = new ComputePublicIPAddressSku() +Sku = new ComputePublicIPAddressSku { Name = ComputePublicIPAddressSkuName.Basic, Tier = ComputePublicIPAddressSkuTier.Global, @@ -1300,10 +1251,8 @@ public async Task CreateOrUpdate_CreateAVMWithNetworkInterfaceConfigurationWithP }, PublicIPAllocationMethod = PublicIPAllocationMethod.Static, }, -} -}, -} -}, +}}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -1342,13 +1291,13 @@ public async Task CreateOrUpdate_CreateAVMWithSecurityTypeConfidentialVMWithCust string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = new VirtualMachineSizeType("Standard_DC2as_v5"), }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "2019-datacenter-cvm", @@ -1359,10 +1308,10 @@ public async Task CreateOrUpdate_CreateAVMWithSecurityTypeConfidentialVMWithCust { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardSsdLrs, - SecurityProfile = new VirtualMachineDiskSecurityProfile() + SecurityProfile = new VirtualMachineDiskSecurityProfile { SecurityEncryptionType = SecurityEncryptionType.DiskWithVmGuestState, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), @@ -1370,26 +1319,23 @@ public async Task CreateOrUpdate_CreateAVMWithSecurityTypeConfidentialVMWithCust }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - UefiSettings = new UefiSettings() + UefiSettings = new UefiSettings { IsSecureBootEnabled = true, IsVirtualTpmEnabled = true, @@ -1433,13 +1379,13 @@ public async Task CreateOrUpdate_CreateAVMWithSecurityTypeConfidentialVMWithNonP string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = new VirtualMachineSizeType("Standard_DC2es_v5"), }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "UbuntuServer", Offer = "2022-datacenter-cvm", @@ -1450,36 +1396,33 @@ public async Task CreateOrUpdate_CreateAVMWithSecurityTypeConfidentialVMWithNonP { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardSsdLrs, - SecurityProfile = new VirtualMachineDiskSecurityProfile() + SecurityProfile = new VirtualMachineDiskSecurityProfile { SecurityEncryptionType = SecurityEncryptionType.NonPersistedTPM, }, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - UefiSettings = new UefiSettings() + UefiSettings = new UefiSettings { IsSecureBootEnabled = false, IsVirtualTpmEnabled = true, @@ -1523,13 +1466,13 @@ public async Task CreateOrUpdate_CreateAVMWithSecurityTypeConfidentialVMWithPlat string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = new VirtualMachineSizeType("Standard_DC2as_v5"), }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "2019-datacenter-cvm", @@ -1540,36 +1483,33 @@ public async Task CreateOrUpdate_CreateAVMWithSecurityTypeConfidentialVMWithPlat { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardSsdLrs, - SecurityProfile = new VirtualMachineDiskSecurityProfile() + SecurityProfile = new VirtualMachineDiskSecurityProfile { SecurityEncryptionType = SecurityEncryptionType.DiskWithVmGuestState, }, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - UefiSettings = new UefiSettings() + UefiSettings = new UefiSettings { IsSecureBootEnabled = true, IsVirtualTpmEnabled = true, @@ -1613,13 +1553,13 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingAssessmentMode string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1630,37 +1570,34 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingAssessmentMode { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", - WindowsConfiguration = new WindowsConfiguration() + WindowsConfiguration = new WindowsConfiguration { ProvisionVmAgent = true, IsAutomaticUpdatesEnabled = true, - PatchSettings = new PatchSettings() + PatchSettings = new PatchSettings { AssessmentMode = WindowsPatchAssessmentMode.ImageDefault, }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -1699,13 +1636,13 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingPatchModeOfAut string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1716,37 +1653,34 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingPatchModeOfAut { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", - WindowsConfiguration = new WindowsConfiguration() + WindowsConfiguration = new WindowsConfiguration { ProvisionVmAgent = true, IsAutomaticUpdatesEnabled = true, - PatchSettings = new PatchSettings() + PatchSettings = new PatchSettings { PatchMode = WindowsVmGuestPatchMode.AutomaticByOS, }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/nsgExistingNic"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -1785,13 +1719,13 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingPatchModeOfAut string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1802,26 +1736,26 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingPatchModeOfAut { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", - WindowsConfiguration = new WindowsConfiguration() + WindowsConfiguration = new WindowsConfiguration { ProvisionVmAgent = true, IsAutomaticUpdatesEnabled = true, - PatchSettings = new PatchSettings() + PatchSettings = new PatchSettings { PatchMode = WindowsVmGuestPatchMode.AutomaticByPlatform, AssessmentMode = WindowsPatchAssessmentMode.AutomaticByPlatform, - AutomaticByPlatformSettings = new WindowsVmGuestPatchAutomaticByPlatformSettings() + AutomaticByPlatformSettings = new WindowsVmGuestPatchAutomaticByPlatformSettings { RebootSetting = WindowsVmGuestPatchAutomaticByPlatformRebootSetting.Never, BypassPlatformSafetyChecksOnUserSchedule = false, @@ -1829,16 +1763,13 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingPatchModeOfAut }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -1877,13 +1808,13 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingPatchModeOfAut string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1894,38 +1825,35 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingPatchModeOfAut { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", - WindowsConfiguration = new WindowsConfiguration() + WindowsConfiguration = new WindowsConfiguration { ProvisionVmAgent = true, IsAutomaticUpdatesEnabled = true, - PatchSettings = new PatchSettings() + PatchSettings = new PatchSettings { PatchMode = WindowsVmGuestPatchMode.AutomaticByPlatform, EnableHotpatching = true, }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -1964,13 +1892,13 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingPatchModeOfMan string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1981,37 +1909,34 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithAPatchSettingPatchModeOfMan { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", - WindowsConfiguration = new WindowsConfiguration() + WindowsConfiguration = new WindowsConfiguration { ProvisionVmAgent = true, IsAutomaticUpdatesEnabled = true, - PatchSettings = new PatchSettings() + PatchSettings = new PatchSettings { PatchMode = WindowsVmGuestPatchMode.Manual, }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -2050,13 +1975,13 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithPatchSettingsPatchModeAndAs string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2067,38 +1992,35 @@ public async Task CreateOrUpdate_CreateAWindowsVmWithPatchSettingsPatchModeAndAs { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", - WindowsConfiguration = new WindowsConfiguration() + WindowsConfiguration = new WindowsConfiguration { ProvisionVmAgent = true, IsAutomaticUpdatesEnabled = true, - PatchSettings = new PatchSettings() + PatchSettings = new PatchSettings { PatchMode = WindowsVmGuestPatchMode.AutomaticByPlatform, AssessmentMode = WindowsPatchAssessmentMode.AutomaticByPlatform, }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -2137,11 +2059,11 @@ public async Task CreateOrUpdate_CreateACustomImageVmFromAnUnmanagedGeneralizedO string vmName = "{vm-name}"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { OSDisk = new VirtualMachineOSDisk(DiskCreateOptionType.FromImage) { @@ -2152,22 +2074,19 @@ public async Task CreateOrUpdate_CreateACustomImageVmFromAnUnmanagedGeneralizedO Caching = CachingType.ReadWrite, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -2206,13 +2125,13 @@ public async Task CreateOrUpdate_CreateAPlatformImageVmWithUnmanagedOsAndDataDis string vmName = "{vm-name}"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2225,35 +2144,29 @@ public async Task CreateOrUpdate_CreateAPlatformImageVmWithUnmanagedOsAndDataDis VhdUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk.vhd"), Caching = CachingType.ReadWrite, }, - DataDisks = -{ -new VirtualMachineDataDisk(0,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineDataDisk(0, DiskCreateOptionType.Empty) { VhdUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk0.vhd"), DiskSizeGB = 1023, -},new VirtualMachineDataDisk(1,DiskCreateOptionType.Empty) +}, new VirtualMachineDataDisk(1, DiskCreateOptionType.Empty) { VhdUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk1.vhd"), DiskSizeGB = 1023, -} -}, +}}, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -2292,13 +2205,13 @@ public async Task CreateOrUpdate_CreateAVmFromACustomImage() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"), }, @@ -2306,28 +2219,25 @@ public async Task CreateOrUpdate_CreateAVmFromACustomImage() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -2366,13 +2276,13 @@ public async Task CreateOrUpdate_CreateAVmFromAGeneralizedSharedImage() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"), }, @@ -2380,28 +2290,25 @@ public async Task CreateOrUpdate_CreateAVmFromAGeneralizedSharedImage() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -2440,13 +2347,13 @@ public async Task CreateOrUpdate_CreateAVmFromASpecializedSharedImage() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"), }, @@ -2454,22 +2361,19 @@ public async Task CreateOrUpdate_CreateAVmFromASpecializedSharedImage() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -2508,13 +2412,13 @@ public async Task CreateOrUpdate_CreateAVmInAVirtualMachineScaleSetWithCustomerA string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2525,28 +2429,25 @@ public async Task CreateOrUpdate_CreateAVmInAVirtualMachineScaleSetWithCustomerA { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, VirtualMachineScaleSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{existing-flex-vmss-name-with-platformFaultDomainCount-greater-than-1}"), PlatformFaultDomain = 1, @@ -2587,13 +2488,13 @@ public async Task CreateOrUpdate_CreateAVmInAnAvailabilitySet() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2604,28 +2505,25 @@ public async Task CreateOrUpdate_CreateAVmInAnAvailabilitySet() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, AvailabilitySetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/{existing-availability-set-name}"), }; @@ -2665,13 +2563,13 @@ public async Task CreateOrUpdate_CreateAVmWithApplicationProfile() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "{image_publisher}", Offer = "{image_offer}", @@ -2682,40 +2580,34 @@ public async Task CreateOrUpdate_CreateAVmWithApplicationProfile() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - GalleryApplications = -{ -new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0") + GalleryApplications = {new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0") { Tags = "myTag1", Order = 1, ConfigurationReference = "https://mystorageaccount.blob.core.windows.net/configurations/settings.config", TreatFailureAsDeploymentFailure = false, EnableAutomaticUpgrade = false, -},new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1") -}, +}, new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1")}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); VirtualMachineResource result = lro.Value; @@ -2753,13 +2645,13 @@ public async Task CreateOrUpdate_CreateAVmWithDiskEncryptionSetResourceIdInTheOs string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"), }, @@ -2767,52 +2659,46 @@ public async Task CreateOrUpdate_CreateAVmWithDiskEncryptionSetResourceIdInTheOs { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), }, }, - DataDisks = -{ -new VirtualMachineDataDisk(0,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineDataDisk(0, DiskCreateOptionType.Empty) { Caching = CachingType.ReadWrite, DiskSizeGB = 1023, -ManagedDisk = new VirtualMachineManagedDisk() +ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), }, -},new VirtualMachineDataDisk(1,DiskCreateOptionType.Attach) +}, new VirtualMachineDataDisk(1, DiskCreateOptionType.Attach) { Caching = CachingType.ReadWrite, DiskSizeGB = 1023, -ManagedDisk = new VirtualMachineManagedDisk() +ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/{existing-managed-disk-name}"), }, -} -}, +}}, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -2851,19 +2737,19 @@ public async Task CreateOrUpdate_CreateAVmWithHostEncryptionUsingEncryptionAtHos string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardDS1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -2874,30 +2760,27 @@ public async Task CreateOrUpdate_CreateAVmWithHostEncryptionUsingEncryptionAtHos { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { EncryptionAtHost = true, }, @@ -2938,22 +2821,22 @@ public async Task CreateOrUpdate_CreateAVmWithScheduledEventsProfile() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - ScheduledEventsPolicy = new ScheduledEventsPolicy() + ScheduledEventsPolicy = new ScheduledEventsPolicy { - UserInitiatedRedeploy = new UserInitiatedRedeploy() + UserInitiatedRedeploy = new UserInitiatedRedeploy { AutomaticallyApprove = true, }, AutomaticallyApprove = true, Enable = true, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2964,42 +2847,39 @@ public async Task CreateOrUpdate_CreateAVmWithScheduledEventsProfile() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), }, - ScheduledEventsProfile = new ComputeScheduledEventsProfile() + ScheduledEventsProfile = new ComputeScheduledEventsProfile { - TerminateNotificationProfile = new TerminateNotificationProfile() + TerminateNotificationProfile = new TerminateNotificationProfile { NotBeforeTimeout = "PT10M", Enable = true, }, - OSImageNotificationProfile = new OSImageNotificationProfile() + OSImageNotificationProfile = new OSImageNotificationProfile { NotBeforeTimeout = "PT15M", Enable = true, @@ -3042,19 +2922,19 @@ public async Task CreateOrUpdate_CreateAVmWithAMarketplaceImagePlan() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -3065,28 +2945,25 @@ public async Task CreateOrUpdate_CreateAVmWithAMarketplaceImagePlan() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -3125,13 +3002,13 @@ public async Task CreateOrUpdate_CreateAVmWithAnExtensionsTimeBudget() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3142,30 +3019,27 @@ public async Task CreateOrUpdate_CreateAVmWithAnExtensionsTimeBudget() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), @@ -3208,13 +3082,13 @@ public async Task CreateOrUpdate_CreateAVmWithBootDiagnostics() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3225,30 +3099,27 @@ public async Task CreateOrUpdate_CreateAVmWithBootDiagnostics() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), @@ -3290,13 +3161,13 @@ public async Task CreateOrUpdate_CreateAVmWithDataDisksUsingCopyAndRestoreOption string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3307,44 +3178,38 @@ public async Task CreateOrUpdate_CreateAVmWithDataDisksUsingCopyAndRestoreOption { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, - DataDisks = -{ -new VirtualMachineDataDisk(0,DiskCreateOptionType.Copy) + DataDisks = {new VirtualMachineDataDisk(0, DiskCreateOptionType.Copy) { DiskSizeGB = 1023, SourceResourceId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/{existing-snapshot-name}"), -},new VirtualMachineDataDisk(1,DiskCreateOptionType.Copy) +}, new VirtualMachineDataDisk(1, DiskCreateOptionType.Copy) { DiskSizeGB = 1023, SourceResourceId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/{existing-disk-name}"), -},new VirtualMachineDataDisk(2,DiskCreateOptionType.Restore) +}, new VirtualMachineDataDisk(2, DiskCreateOptionType.Restore) { DiskSizeGB = 1023, SourceResourceId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/restorePointCollections/{existing-rpc-name}/restorePoints/{existing-rp-name}/diskRestorePoints/{existing-disk-restore-point-name}"), -} -}, +}}, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -3383,13 +3248,13 @@ public async Task CreateOrUpdate_CreateAVmWithEmptyDataDisks() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3400,38 +3265,32 @@ public async Task CreateOrUpdate_CreateAVmWithEmptyDataDisks() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, - DataDisks = -{ -new VirtualMachineDataDisk(0,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineDataDisk(0, DiskCreateOptionType.Empty) { DiskSizeGB = 1023, -},new VirtualMachineDataDisk(1,DiskCreateOptionType.Empty) +}, new VirtualMachineDataDisk(1, DiskCreateOptionType.Empty) { DiskSizeGB = 1023, -} -}, +}}, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -3470,19 +3329,19 @@ public async Task CreateOrUpdate_CreateAVmWithEphemeralOsDiskProvisioningInCache string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardDS1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -3493,33 +3352,30 @@ public async Task CreateOrUpdate_CreateAVmWithEphemeralOsDiskProvisioningInCache { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - DiffDiskSettings = new DiffDiskSettings() + DiffDiskSettings = new DiffDiskSettings { Option = DiffDiskOption.Local, Placement = DiffDiskPlacement.CacheDisk, }, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -3558,19 +3414,19 @@ public async Task CreateOrUpdate_CreateAVmWithEphemeralOsDiskProvisioningInNvmeD string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardDS1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -3581,33 +3437,30 @@ public async Task CreateOrUpdate_CreateAVmWithEphemeralOsDiskProvisioningInNvmeD { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - DiffDiskSettings = new DiffDiskSettings() + DiffDiskSettings = new DiffDiskSettings { Option = DiffDiskOption.Local, Placement = DiffDiskPlacement.NvmeDisk, }, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -3646,19 +3499,19 @@ public async Task CreateOrUpdate_CreateAVmWithEphemeralOsDiskProvisioningInResou string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardDS1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -3669,33 +3522,30 @@ public async Task CreateOrUpdate_CreateAVmWithEphemeralOsDiskProvisioningInResou { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - DiffDiskSettings = new DiffDiskSettings() + DiffDiskSettings = new DiffDiskSettings { Option = DiffDiskOption.Local, Placement = DiffDiskPlacement.ResourceDisk, }, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -3734,19 +3584,19 @@ public async Task CreateOrUpdate_CreateAVmWithEphemeralOsDisk() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardDS1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -3757,32 +3607,29 @@ public async Task CreateOrUpdate_CreateAVmWithEphemeralOsDisk() { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - DiffDiskSettings = new DiffDiskSettings() + DiffDiskSettings = new DiffDiskSettings { Option = DiffDiskOption.Local, }, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -3821,13 +3668,13 @@ public async Task CreateOrUpdate_CreateAVmWithManagedBootDiagnostics() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3838,30 +3685,27 @@ public async Task CreateOrUpdate_CreateAVmWithManagedBootDiagnostics() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, }, @@ -3902,13 +3746,13 @@ public async Task CreateOrUpdate_CreateAVmWithPasswordAuthentication() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3919,28 +3763,25 @@ public async Task CreateOrUpdate_CreateAVmWithPasswordAuthentication() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -3979,13 +3820,13 @@ public async Task CreateOrUpdate_CreateAVmWithPremiumStorage() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3996,28 +3837,25 @@ public async Task CreateOrUpdate_CreateAVmWithPremiumStorage() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -4056,13 +3894,13 @@ public async Task CreateOrUpdate_CreateAVmWithSshAuthentication() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "{image_publisher}", Offer = "{image_offer}", @@ -4073,39 +3911,33 @@ public async Task CreateOrUpdate_CreateAVmWithSshAuthentication() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", - LinuxConfiguration = new LinuxConfiguration() + LinuxConfiguration = new LinuxConfiguration { IsPasswordAuthenticationDisabled = true, - SshPublicKeys = -{ -new SshPublicKeyConfiguration() + SshPublicKeys = {new SshPublicKeyConfiguration { Path = "/home/{your-username}/.ssh/authorized_keys", KeyData = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1", -} -}, +}}, }, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmName, data); @@ -4144,19 +3976,19 @@ public async Task CreateOrUpdate_CreateOrUpdateAVMWithCapacityReservation() string vmName = "myVM"; VirtualMachineData data = new VirtualMachineData(new AzureLocation("westus")) { - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardDS1V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -4167,28 +3999,25 @@ public async Task CreateOrUpdate_CreateOrUpdateAVMWithCapacityReservation() { Name = "myVMosdisk", Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, CapacityReservationGroupId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"), }; @@ -4238,9 +4067,9 @@ public async Task Get_GetAVirtualMachine() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAVirtualMachine() + public async Task Get_GetAVirtualMachinePlacedOnADedicatedHostGroupThroughAutomaticPlacement() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_AutoPlacedOnDedicatedHostGroup.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -4260,17 +4089,20 @@ public async Task Exists_GetAVirtualMachine() // invoke the operation string vmName = "myVM"; - InstanceViewType? expand = InstanceViewType.UserData; - bool result = await collection.ExistsAsync(vmName, expand: expand); + VirtualMachineResource result = await collection.GetAsync(vmName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAVirtualMachine() + public async Task Get_GetAVirtualMachineWithDiskControllerTypeProperties() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithDiskControllerType.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -4291,28 +4123,20 @@ public async Task GetIfExists_GetAVirtualMachine() // invoke the operation string vmName = "myVM"; InstanceViewType? expand = InstanceViewType.UserData; - NullableResponse response = await collection.GetIfExistsAsync(vmName, expand: expand); - VirtualMachineResource result = response.HasValue ? response.Value : null; + VirtualMachineResource result = await collection.GetAsync(vmName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachinePlacedOnADedicatedHostGroupThroughAutomaticPlacement() + public async Task Get_GetAVirtualMachineWithVMSizeProperties() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_AutoPlacedOnDedicatedHostGroup.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithVMSizeProperties.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -4343,10 +4167,10 @@ public async Task Get_GetAVirtualMachinePlacedOnADedicatedHostGroupThroughAutoma [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAVirtualMachinePlacedOnADedicatedHostGroupThroughAutomaticPlacement() + public async Task GetAll_VirtualMachineListMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_AutoPlacedOnDedicatedHostGroup.json - // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_List_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachines_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -4356,26 +4180,33 @@ public async Task Exists_GetAVirtualMachinePlacedOnADedicatedHostGroupThroughAut // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; + string resourceGroupName = "rgcompute"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this VirtualMachineResource VirtualMachineCollection collection = resourceGroupResource.GetVirtualMachines(); - // invoke the operation - string vmName = "myVM"; - bool result = await collection.ExistsAsync(vmName); + // invoke the operation and iterate over the result + string filter = "aaaaaaaaaaaaaaaaaaaaaaa"; + await foreach (VirtualMachineResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAVirtualMachinePlacedOnADedicatedHostGroupThroughAutomaticPlacement() + public async Task GetAll_VirtualMachineListMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_AutoPlacedOnDedicatedHostGroup.json - // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_List_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachines_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -4385,37 +4216,31 @@ public async Task GetIfExists_GetAVirtualMachinePlacedOnADedicatedHostGroupThrou // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; + string resourceGroupName = "rgcompute"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this VirtualMachineResource VirtualMachineCollection collection = resourceGroupResource.GetVirtualMachines(); - // invoke the operation - string vmName = "myVM"; - NullableResponse response = await collection.GetIfExistsAsync(vmName); - VirtualMachineResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualMachineResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = result.Data; + VirtualMachineData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachineWithDiskControllerTypeProperties() + public async Task Exists_GetAVirtualMachine() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithDiskControllerType.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -4436,20 +4261,16 @@ public async Task Get_GetAVirtualMachineWithDiskControllerTypeProperties() // invoke the operation string vmName = "myVM"; InstanceViewType? expand = InstanceViewType.UserData; - VirtualMachineResource result = await collection.GetAsync(vmName, expand: expand); + bool result = await collection.ExistsAsync(vmName, expand: expand); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAVirtualMachineWithDiskControllerTypeProperties() + public async Task Exists_GetAVirtualMachinePlacedOnADedicatedHostGroupThroughAutomaticPlacement() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithDiskControllerType.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_AutoPlacedOnDedicatedHostGroup.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -4469,15 +4290,14 @@ public async Task Exists_GetAVirtualMachineWithDiskControllerTypeProperties() // invoke the operation string vmName = "myVM"; - InstanceViewType? expand = InstanceViewType.UserData; - bool result = await collection.ExistsAsync(vmName, expand: expand); + bool result = await collection.ExistsAsync(vmName); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAVirtualMachineWithDiskControllerTypeProperties() + public async Task Exists_GetAVirtualMachineWithDiskControllerTypeProperties() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithDiskControllerType.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. @@ -4500,26 +4320,14 @@ public async Task GetIfExists_GetAVirtualMachineWithDiskControllerTypeProperties // invoke the operation string vmName = "myVM"; InstanceViewType? expand = InstanceViewType.UserData; - NullableResponse response = await collection.GetIfExistsAsync(vmName, expand: expand); - VirtualMachineResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vmName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachineWithVMSizeProperties() + public async Task Exists_GetAVirtualMachineWithVMSizeProperties() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithVMSizeProperties.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. @@ -4541,20 +4349,16 @@ public async Task Get_GetAVirtualMachineWithVMSizeProperties() // invoke the operation string vmName = "myVM"; - VirtualMachineResource result = await collection.GetAsync(vmName); + bool result = await collection.ExistsAsync(vmName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAVirtualMachineWithVMSizeProperties() + public async Task GetIfExists_GetAVirtualMachine() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithVMSizeProperties.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -4574,16 +4378,29 @@ public async Task Exists_GetAVirtualMachineWithVMSizeProperties() // invoke the operation string vmName = "myVM"; - bool result = await collection.ExistsAsync(vmName); + InstanceViewType? expand = InstanceViewType.UserData; + NullableResponse response = await collection.GetIfExistsAsync(vmName, expand: expand); + VirtualMachineResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAVirtualMachineWithVMSizeProperties() + public async Task GetIfExists_GetAVirtualMachinePlacedOnADedicatedHostGroupThroughAutomaticPlacement() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithVMSizeProperties.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_AutoPlacedOnDedicatedHostGroup.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -4622,10 +4439,10 @@ public async Task GetIfExists_GetAVirtualMachineWithVMSizeProperties() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineListMaximumSetGen() + public async Task GetIfExists_GetAVirtualMachineWithDiskControllerTypeProperties() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_List_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachines_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithDiskControllerType.json + // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -4635,33 +4452,39 @@ public async Task GetAll_VirtualMachineListMaximumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; + string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this VirtualMachineResource VirtualMachineCollection collection = resourceGroupResource.GetVirtualMachines(); - // invoke the operation and iterate over the result - string filter = "aaaaaaaaaaaaaaaaaaaaaaa"; - await foreach (VirtualMachineResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string vmName = "myVM"; + InstanceViewType? expand = InstanceViewType.UserData; + NullableResponse response = await collection.GetIfExistsAsync(vmName, expand: expand); + VirtualMachineResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = item.Data; + VirtualMachineData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineListMinimumSetGen() + public async Task GetIfExists_GetAVirtualMachineWithVMSizeProperties() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_List_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachines_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithVMSizeProperties.json + // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -4671,24 +4494,30 @@ public async Task GetAll_VirtualMachineListMinimumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; + string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this VirtualMachineResource VirtualMachineCollection collection = resourceGroupResource.GetVirtualMachines(); - // invoke the operation and iterate over the result - await foreach (VirtualMachineResource item in collection.GetAllAsync()) + // invoke the operation + string vmName = "myVM"; + NullableResponse response = await collection.GetIfExistsAsync(vmName); + VirtualMachineResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = item.Data; + VirtualMachineData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionCollection.cs index 097cf1c5216e3..c1f55170288bf 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -50,44 +49,34 @@ public async Task CreateOrUpdate_VirtualMachineExtensionCreateOrUpdateMaximumSet TypeHandlerVersion = "1.2", AutoUpgradeMinorVersion = true, EnableAutomaticUpgrade = true, - Settings = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - ProtectedSettings = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - InstanceView = new VirtualMachineExtensionInstanceView() + Settings = BinaryData.FromObjectAsJson(new object()), + ProtectedSettings = BinaryData.FromObjectAsJson(new object()), + InstanceView = new VirtualMachineExtensionInstanceView { Name = "aaaaaaaaaaaaaaaaa", VirtualMachineExtensionInstanceViewType = "aaaaaaaaa", TypeHandlerVersion = "aaaaaaaaaaaaaaaaaaaaaaaaaa", - Substatuses = -{ -new InstanceViewStatus() + Substatuses = {new InstanceViewStatus { Code = "aaaaaaaaaaaaaaaaaaaaaaa", Level = ComputeStatusLevelType.Info, DisplayStatus = "aaaaaa", Message = "a", Time = DateTimeOffset.Parse("2021-11-30T12:58:26.522Z"), -} -}, - Statuses = -{ -new InstanceViewStatus() +}}, + Statuses = {new InstanceViewStatus { Code = "aaaaaaaaaaaaaaaaaaaaaaa", Level = ComputeStatusLevelType.Info, DisplayStatus = "aaaaaa", Message = "a", Time = DateTimeOffset.Parse("2021-11-30T12:58:26.522Z"), -} -}, +}}, }, SuppressFailures = true, Tags = { -["key9183"] = "aa", +["key9183"] = "aa" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmExtensionName, data); @@ -173,9 +162,9 @@ public async Task Get_VirtualMachineExtensionGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualMachineExtensionGetMaximumSetGen() + public async Task Get_VirtualMachineExtensionGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MaximumSet_Gen.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MinimumSet_Gen.json // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -187,7 +176,7 @@ public async Task Exists_VirtualMachineExtensionGetMaximumSetGen() // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string vmName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string vmName = "myVM"; ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); @@ -195,19 +184,22 @@ public async Task Exists_VirtualMachineExtensionGetMaximumSetGen() VirtualMachineExtensionCollection collection = virtualMachine.GetVirtualMachineExtensions(); // invoke the operation - string vmExtensionName = "aaaaaaa"; - string expand = "aaaaaa"; - bool result = await collection.ExistsAsync(vmExtensionName, expand: expand); + string vmExtensionName = "myVMExtension"; + VirtualMachineExtensionResource result = await collection.GetAsync(vmExtensionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualMachineExtensionGetMaximumSetGen() + public async Task GetAll_VirtualMachineExtensionListMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_List_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -218,39 +210,33 @@ public async Task GetIfExists_VirtualMachineExtensionGetMaximumSetGen() // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string vmName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string vmName = "aaaaaaaaaaaaa"; ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // get the collection of this VirtualMachineExtensionResource VirtualMachineExtensionCollection collection = virtualMachine.GetVirtualMachineExtensions(); - // invoke the operation - string vmExtensionName = "aaaaaaa"; - string expand = "aaaaaa"; - NullableResponse response = await collection.GetIfExistsAsync(vmExtensionName, expand: expand); - VirtualMachineExtensionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string expand = "aaaaaaaaaaaaaaaaa"; + await foreach (VirtualMachineExtensionResource item in collection.GetAllAsync(expand: expand)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineExtensionData resourceData = result.Data; + VirtualMachineExtensionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualMachineExtensionGetMinimumSetGen() + public async Task GetAll_VirtualMachineExtensionListMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_List_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -261,29 +247,31 @@ public async Task Get_VirtualMachineExtensionGetMinimumSetGen() // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string vmName = "myVM"; + string vmName = "aaaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // get the collection of this VirtualMachineExtensionResource VirtualMachineExtensionCollection collection = virtualMachine.GetVirtualMachineExtensions(); - // invoke the operation - string vmExtensionName = "myVMExtension"; - VirtualMachineExtensionResource result = await collection.GetAsync(vmExtensionName); + // invoke the operation and iterate over the result + await foreach (VirtualMachineExtensionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineExtensionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualMachineExtensionGetMinimumSetGen() + public async Task Exists_VirtualMachineExtensionGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MinimumSet_Gen.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MaximumSet_Gen.json // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -295,7 +283,7 @@ public async Task Exists_VirtualMachineExtensionGetMinimumSetGen() // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string vmName = "myVM"; + string vmName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); @@ -303,15 +291,16 @@ public async Task Exists_VirtualMachineExtensionGetMinimumSetGen() VirtualMachineExtensionCollection collection = virtualMachine.GetVirtualMachineExtensions(); // invoke the operation - string vmExtensionName = "myVMExtension"; - bool result = await collection.ExistsAsync(vmExtensionName); + string vmExtensionName = "aaaaaaa"; + string expand = "aaaaaa"; + bool result = await collection.ExistsAsync(vmExtensionName, expand: expand); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualMachineExtensionGetMinimumSetGen() + public async Task Exists_VirtualMachineExtensionGetMinimumSetGen() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MinimumSet_Gen.json // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. @@ -334,29 +323,17 @@ public async Task GetIfExists_VirtualMachineExtensionGetMinimumSetGen() // invoke the operation string vmExtensionName = "myVMExtension"; - NullableResponse response = await collection.GetIfExistsAsync(vmExtensionName); - VirtualMachineExtensionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vmExtensionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineExtensionListMaximumSetGen() + public async Task GetIfExists_VirtualMachineExtensionGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_List_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -367,33 +344,39 @@ public async Task GetAll_VirtualMachineExtensionListMaximumSetGen() // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string vmName = "aaaaaaaaaaaaa"; + string vmName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // get the collection of this VirtualMachineExtensionResource VirtualMachineExtensionCollection collection = virtualMachine.GetVirtualMachineExtensions(); - // invoke the operation and iterate over the result - string expand = "aaaaaaaaaaaaaaaaa"; - await foreach (VirtualMachineExtensionResource item in collection.GetAllAsync(expand: expand)) + // invoke the operation + string vmExtensionName = "aaaaaaa"; + string expand = "aaaaaa"; + NullableResponse response = await collection.GetIfExistsAsync(vmExtensionName, expand: expand); + VirtualMachineExtensionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineExtensionData resourceData = item.Data; + VirtualMachineExtensionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineExtensionListMinimumSetGen() + public async Task GetIfExists_VirtualMachineExtensionGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_List_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -404,24 +387,30 @@ public async Task GetAll_VirtualMachineExtensionListMinimumSetGen() // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string vmName = "aaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string vmName = "myVM"; ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // get the collection of this VirtualMachineExtensionResource VirtualMachineExtensionCollection collection = virtualMachine.GetVirtualMachineExtensions(); - // invoke the operation and iterate over the result - await foreach (VirtualMachineExtensionResource item in collection.GetAllAsync()) + // invoke the operation + string vmExtensionName = "myVMExtension"; + NullableResponse response = await collection.GetIfExistsAsync(vmExtensionName); + VirtualMachineExtensionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineExtensionData resourceData = item.Data; + VirtualMachineExtensionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionImageCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionImageCollection.cs index 2b7ab3047ec94..378bd18ddd949 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionImageCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionImageCollection.cs @@ -53,9 +53,9 @@ public async Task Get_VirtualMachineExtensionImageGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualMachineExtensionImageGetMaximumSetGen() + public async Task Get_VirtualMachineExtensionImageGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_Get_MaximumSet_Gen.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_Get_MinimumSet_Gen.json // this example is just showing the usage of "VirtualMachineExtensionImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -70,24 +70,28 @@ public async Task Exists_VirtualMachineExtensionImageGetMaximumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this VirtualMachineExtensionImageResource - AzureLocation location = new AzureLocation("aaaaaaaaaaaaa"); - string publisherName = "aaaaaaaaaaaaaaaaaaaa"; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaaa"); + string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; VirtualMachineExtensionImageCollection collection = subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName); // invoke the operation - string type = "aaaaaaaaaaaaaaaaaa"; - string version = "aaaaaaaaaaaaaa"; - bool result = await collection.ExistsAsync(type, version); + string type = "aa"; + string version = "aaa"; + VirtualMachineExtensionImageResource result = await collection.GetAsync(type, version); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineExtensionImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualMachineExtensionImageGetMaximumSetGen() + public async Task GetAll_VirtualMachineExtensionImageListTypesMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_Get_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensionImages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_ListTypes_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensionImages_ListTypes" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,36 +105,29 @@ public async Task GetIfExists_VirtualMachineExtensionImageGetMaximumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this VirtualMachineExtensionImageResource - AzureLocation location = new AzureLocation("aaaaaaaaaaaaa"); - string publisherName = "aaaaaaaaaaaaaaaaaaaa"; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaaaaa"); + string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; VirtualMachineExtensionImageCollection collection = subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName); - // invoke the operation - string type = "aaaaaaaaaaaaaaaaaa"; - string version = "aaaaaaaaaaaaaa"; - NullableResponse response = await collection.GetIfExistsAsync(type, version); - VirtualMachineExtensionImageResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualMachineExtensionImageResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineExtensionImageData resourceData = result.Data; + VirtualMachineExtensionImageData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualMachineExtensionImageGetMinimumSetGen() + public async Task GetAll_VirtualMachineExtensionImageListTypesMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_Get_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensionImages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_ListTypes_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensionImages_ListTypes" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,28 +141,29 @@ public async Task Get_VirtualMachineExtensionImageGetMinimumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this VirtualMachineExtensionImageResource - AzureLocation location = new AzureLocation("aaaaaaaaaaaaaa"); - string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; + AzureLocation location = new AzureLocation("aaaa"); + string publisherName = "aa"; VirtualMachineExtensionImageCollection collection = subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName); - // invoke the operation - string type = "aa"; - string version = "aaa"; - VirtualMachineExtensionImageResource result = await collection.GetAsync(type, version); + // invoke the operation and iterate over the result + await foreach (VirtualMachineExtensionImageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineExtensionImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineExtensionImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualMachineExtensionImageGetMinimumSetGen() + public async Task GetAll_VirtualMachineExtensionImageListVersionsMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_Get_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensionImages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_ListVersions_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensionImages_ListVersions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,24 +177,33 @@ public async Task Exists_VirtualMachineExtensionImageGetMinimumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this VirtualMachineExtensionImageResource - AzureLocation location = new AzureLocation("aaaaaaaaaaaaaa"); - string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaaaaa"); + string publisherName = "aaaaaaaaaaaaaaaaaaaa"; VirtualMachineExtensionImageCollection collection = subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName); - // invoke the operation - string type = "aa"; - string version = "aaa"; - bool result = await collection.ExistsAsync(type, version); + // invoke the operation and iterate over the result + string type = "aaaaaaaaaaaaaaaaaa"; + string filter = "aaaaaaaaaaaaaaaaaaaaaaaaa"; + int? top = 22; + string orderby = "a"; + await foreach (VirtualMachineExtensionImageResource item in collection.GetAllAsync(type, filter: filter, top: top, orderby: orderby)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineExtensionImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualMachineExtensionImageGetMinimumSetGen() + public async Task GetAll_VirtualMachineExtensionImageListVersionsMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_Get_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensionImages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_ListVersions_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensionImages_ListVersions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -210,36 +217,30 @@ public async Task GetIfExists_VirtualMachineExtensionImageGetMinimumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this VirtualMachineExtensionImageResource - AzureLocation location = new AzureLocation("aaaaaaaaaaaaaa"); - string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; + AzureLocation location = new AzureLocation("aaaaaaaaa"); + string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; VirtualMachineExtensionImageCollection collection = subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName); - // invoke the operation - string type = "aa"; - string version = "aaa"; - NullableResponse response = await collection.GetIfExistsAsync(type, version); - VirtualMachineExtensionImageResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string type = "aaaa"; + await foreach (VirtualMachineExtensionImageResource item in collection.GetAllAsync(type)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineExtensionImageData resourceData = result.Data; + VirtualMachineExtensionImageData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineExtensionImageListTypesMaximumSetGen() + public async Task Exists_VirtualMachineExtensionImageGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_ListTypes_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensionImages_ListTypes" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_Get_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensionImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -253,29 +254,24 @@ public async Task GetAll_VirtualMachineExtensionImageListTypesMaximumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this VirtualMachineExtensionImageResource - AzureLocation location = new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaaaaa"); - string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaa"); + string publisherName = "aaaaaaaaaaaaaaaaaaaa"; VirtualMachineExtensionImageCollection collection = subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName); - // invoke the operation and iterate over the result - await foreach (VirtualMachineExtensionImageResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineExtensionImageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string type = "aaaaaaaaaaaaaaaaaa"; + string version = "aaaaaaaaaaaaaa"; + bool result = await collection.ExistsAsync(type, version); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineExtensionImageListTypesMinimumSetGen() + public async Task Exists_VirtualMachineExtensionImageGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_ListTypes_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensionImages_ListTypes" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_Get_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensionImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -289,29 +285,24 @@ public async Task GetAll_VirtualMachineExtensionImageListTypesMinimumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this VirtualMachineExtensionImageResource - AzureLocation location = new AzureLocation("aaaa"); - string publisherName = "aa"; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaaa"); + string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; VirtualMachineExtensionImageCollection collection = subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName); - // invoke the operation and iterate over the result - await foreach (VirtualMachineExtensionImageResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineExtensionImageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string type = "aa"; + string version = "aaa"; + bool result = await collection.ExistsAsync(type, version); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineExtensionImageListVersionsMaximumSetGen() + public async Task GetIfExists_VirtualMachineExtensionImageGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_ListVersions_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensionImages_ListVersions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_Get_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensionImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -325,33 +316,36 @@ public async Task GetAll_VirtualMachineExtensionImageListVersionsMaximumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this VirtualMachineExtensionImageResource - AzureLocation location = new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaaaaa"); + AzureLocation location = new AzureLocation("aaaaaaaaaaaaa"); string publisherName = "aaaaaaaaaaaaaaaaaaaa"; VirtualMachineExtensionImageCollection collection = subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName); - // invoke the operation and iterate over the result + // invoke the operation string type = "aaaaaaaaaaaaaaaaaa"; - string filter = "aaaaaaaaaaaaaaaaaaaaaaaaa"; - int? top = 22; - string orderby = "a"; - await foreach (VirtualMachineExtensionImageResource item in collection.GetAllAsync(type, filter: filter, top: top, orderby: orderby)) + string version = "aaaaaaaaaaaaaa"; + NullableResponse response = await collection.GetIfExistsAsync(type, version); + VirtualMachineExtensionImageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineExtensionImageData resourceData = item.Data; + VirtualMachineExtensionImageData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineExtensionImageListVersionsMinimumSetGen() + public async Task GetIfExists_VirtualMachineExtensionImageGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_ListVersions_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensionImages_ListVersions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExtensionImageExamples/VirtualMachineExtensionImage_Get_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensionImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -365,22 +359,28 @@ public async Task GetAll_VirtualMachineExtensionImageListVersionsMinimumSetGen() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this VirtualMachineExtensionImageResource - AzureLocation location = new AzureLocation("aaaaaaaaa"); - string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + AzureLocation location = new AzureLocation("aaaaaaaaaaaaaa"); + string publisherName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; VirtualMachineExtensionImageCollection collection = subscriptionResource.GetVirtualMachineExtensionImages(location, publisherName); - // invoke the operation and iterate over the result - string type = "aaaa"; - await foreach (VirtualMachineExtensionImageResource item in collection.GetAllAsync(type)) + // invoke the operation + string type = "aa"; + string version = "aaa"; + NullableResponse response = await collection.GetIfExistsAsync(type, version); + VirtualMachineExtensionImageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineExtensionImageData resourceData = item.Data; + VirtualMachineExtensionImageData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionResource.cs index 8a41d182a032e..031de32608bac 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineExtensionResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -20,10 +19,10 @@ public partial class Sample_VirtualMachineExtensionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateVMExtension() + public async Task Get_VirtualMachineExtensionGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Update.json - // this example is just showing the usage of "VirtualMachineExtensions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,31 +32,15 @@ public async Task Update_UpdateVMExtension() // this example assumes you already have this VirtualMachineExtensionResource created on azure // for more information of creating VirtualMachineExtensionResource, please refer to the document of VirtualMachineExtensionResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string vmName = "myVM"; - string vmExtensionName = "myVMExtension"; + string resourceGroupName = "rgcompute"; + string vmName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string vmExtensionName = "aaaaaaa"; ResourceIdentifier virtualMachineExtensionResourceId = VirtualMachineExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName, vmExtensionName); VirtualMachineExtensionResource virtualMachineExtension = client.GetVirtualMachineExtensionResource(virtualMachineExtensionResourceId); // invoke the operation - VirtualMachineExtensionPatch patch = new VirtualMachineExtensionPatch() - { - Publisher = "extPublisher", - ExtensionType = "extType", - TypeHandlerVersion = "1.2", - AutoUpgradeMinorVersion = true, - Settings = BinaryData.FromObjectAsJson(new Dictionary() - { - ["UserName"] = "xyz@microsoft.com" - }), - SuppressFailures = true, - KeyVaultProtectedSettings = new KeyVaultSecretReference(new Uri("https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"), new WritableSubResource() - { - Id = new ResourceIdentifier("/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"), - }), - }; - ArmOperation lro = await virtualMachineExtension.UpdateAsync(WaitUntil.Completed, patch); - VirtualMachineExtensionResource result = lro.Value; + string expand = "aaaaaa"; + VirtualMachineExtensionResource result = await virtualMachineExtension.GetAsync(expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -68,10 +51,10 @@ public async Task Update_UpdateVMExtension() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VirtualMachineExtensionDeleteMaximumSetGen() + public async Task Get_VirtualMachineExtensionGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -82,22 +65,26 @@ public async Task Delete_VirtualMachineExtensionDeleteMaximumSetGen() // for more information of creating VirtualMachineExtensionResource, please refer to the document of VirtualMachineExtensionResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string vmName = "aaaaaaaaaaaaa"; - string vmExtensionName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string vmName = "myVM"; + string vmExtensionName = "myVMExtension"; ResourceIdentifier virtualMachineExtensionResourceId = VirtualMachineExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName, vmExtensionName); VirtualMachineExtensionResource virtualMachineExtension = client.GetVirtualMachineExtensionResource(virtualMachineExtensionResourceId); // invoke the operation - await virtualMachineExtension.DeleteAsync(WaitUntil.Completed); + VirtualMachineExtensionResource result = await virtualMachineExtension.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VirtualMachineExtensionDeleteMinimumSetGen() + public async Task Delete_VirtualMachineExtensionDeleteMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Delete_MinimumSet_Gen.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Delete_MaximumSet_Gen.json // this example is just showing the usage of "VirtualMachineExtensions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -109,8 +96,8 @@ public async Task Delete_VirtualMachineExtensionDeleteMinimumSetGen() // for more information of creating VirtualMachineExtensionResource, please refer to the document of VirtualMachineExtensionResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string vmName = "aaaaaaaaaaaaaaaaaaaaaaaaa"; - string vmExtensionName = "aa"; + string vmName = "aaaaaaaaaaaaa"; + string vmExtensionName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineExtensionResourceId = VirtualMachineExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName, vmExtensionName); VirtualMachineExtensionResource virtualMachineExtension = client.GetVirtualMachineExtensionResource(virtualMachineExtensionResourceId); @@ -122,10 +109,10 @@ public async Task Delete_VirtualMachineExtensionDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualMachineExtensionGetMaximumSetGen() + public async Task Delete_VirtualMachineExtensionDeleteMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineExtensions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,28 +123,23 @@ public async Task Get_VirtualMachineExtensionGetMaximumSetGen() // for more information of creating VirtualMachineExtensionResource, please refer to the document of VirtualMachineExtensionResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string vmName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - string vmExtensionName = "aaaaaaa"; + string vmName = "aaaaaaaaaaaaaaaaaaaaaaaaa"; + string vmExtensionName = "aa"; ResourceIdentifier virtualMachineExtensionResourceId = VirtualMachineExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName, vmExtensionName); VirtualMachineExtensionResource virtualMachineExtension = client.GetVirtualMachineExtensionResource(virtualMachineExtensionResourceId); // invoke the operation - string expand = "aaaaaa"; - VirtualMachineExtensionResource result = await virtualMachineExtension.GetAsync(expand: expand); + await virtualMachineExtension.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualMachineExtensionGetMinimumSetGen() + public async Task Update_UpdateVMExtension() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Get_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachineExtension_Update.json + // this example is just showing the usage of "VirtualMachineExtensions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -167,14 +149,31 @@ public async Task Get_VirtualMachineExtensionGetMinimumSetGen() // this example assumes you already have this VirtualMachineExtensionResource created on azure // for more information of creating VirtualMachineExtensionResource, please refer to the document of VirtualMachineExtensionResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; + string resourceGroupName = "myResourceGroup"; string vmName = "myVM"; string vmExtensionName = "myVMExtension"; ResourceIdentifier virtualMachineExtensionResourceId = VirtualMachineExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName, vmExtensionName); VirtualMachineExtensionResource virtualMachineExtension = client.GetVirtualMachineExtensionResource(virtualMachineExtensionResourceId); // invoke the operation - VirtualMachineExtensionResource result = await virtualMachineExtension.GetAsync(); + VirtualMachineExtensionPatch patch = new VirtualMachineExtensionPatch + { + Publisher = "extPublisher", + ExtensionType = "extType", + TypeHandlerVersion = "1.2", + AutoUpgradeMinorVersion = true, + Settings = BinaryData.FromObjectAsJson(new + { + UserName = "xyz@microsoft.com", + }), + SuppressFailures = true, + KeyVaultProtectedSettings = new KeyVaultSecretReference(new Uri("https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"), new WritableSubResource + { + Id = new ResourceIdentifier("/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"), + }), + }; + ArmOperation lro = await virtualMachineExtension.UpdateAsync(WaitUntil.Completed, patch); + VirtualMachineExtensionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineResource.cs index acd87d608b524..da23817dc8e20 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -20,42 +19,41 @@ public partial class Sample_VirtualMachineResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetVirtualMachinesByLocation_ListsAllTheVirtualMachinesUnderTheSpecifiedSubscriptionForTheSpecifiedLocation() + public async Task Get_GetAVirtualMachine() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_ListBySubscription_ByLocation.json - // this example is just showing the usage of "VirtualMachines_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get.json + // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscriptionId}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + // this example assumes you already have this VirtualMachineResource created on azure + // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "myResourceGroup"; + string vmName = "myVM"; + ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); + VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); - // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("eastus"); - await foreach (VirtualMachineResource item in subscriptionResource.GetVirtualMachinesByLocationAsync(location)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + InstanceViewType? expand = InstanceViewType.UserData; + VirtualMachineResource result = await virtualMachine.GetAsync(expand: expand); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Capture_VirtualMachineCaptureMaximumSetGen() + public async Task Get_GetAVirtualMachinePlacedOnADedicatedHostGroupThroughAutomaticPlacement() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Capture_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachines_Capture" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_AutoPlacedOnDedicatedHostGroup.json + // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,25 +63,27 @@ public async Task Capture_VirtualMachineCaptureMaximumSetGen() // this example assumes you already have this VirtualMachineResource created on azure // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string vmName = "aaaaaaaaaaaaaaaaaaaa"; + string resourceGroupName = "myResourceGroup"; + string vmName = "myVM"; ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // invoke the operation - VirtualMachineCaptureContent content = new VirtualMachineCaptureContent("aaaaaaaaa", "aaaaaaa", true); - ArmOperation lro = await virtualMachine.CaptureAsync(WaitUntil.Completed, content); - VirtualMachineCaptureResult result = lro.Value; + VirtualMachineResource result = await virtualMachine.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Capture_VirtualMachineCaptureMinimumSetGen() + public async Task Get_GetAVirtualMachineWithDiskControllerTypeProperties() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Capture_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachines_Capture" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithDiskControllerType.json + // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,17 +93,77 @@ public async Task Capture_VirtualMachineCaptureMinimumSetGen() // this example assumes you already have this VirtualMachineResource created on azure // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string vmName = "aaaaaaaaaaaaa"; + string resourceGroupName = "myResourceGroup"; + string vmName = "myVM"; ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // invoke the operation - VirtualMachineCaptureContent content = new VirtualMachineCaptureContent("aaaaaaaaa", "aaaaaaa", true); - ArmOperation lro = await virtualMachine.CaptureAsync(WaitUntil.Completed, content); - VirtualMachineCaptureResult result = lro.Value; + InstanceViewType? expand = InstanceViewType.UserData; + VirtualMachineResource result = await virtualMachine.GetAsync(expand: expand); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAVirtualMachineWithVMSizeProperties() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithVMSizeProperties.json + // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineResource created on azure + // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "myResourceGroup"; + string vmName = "myVM"; + ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); + VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); + + // invoke the operation + VirtualMachineResource result = await virtualMachine.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ForceDeleteAVM() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Delete_Force.json + // this example is just showing the usage of "VirtualMachines_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineResource created on azure + // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "myResourceGroup"; + string vmName = "myVM"; + ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); + VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); + + // invoke the operation + bool? forceDeletion = true; + await virtualMachine.DeleteAsync(WaitUntil.Completed, forceDeletion: forceDeletion); + + Console.WriteLine("Succeeded"); } [Test] @@ -127,15 +187,15 @@ public async Task Update_UpdateAVMByDetachingDataDisk() VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // invoke the operation - VirtualMachinePatch patch = new VirtualMachinePatch() + VirtualMachinePatch patch = new VirtualMachinePatch { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -146,40 +206,34 @@ public async Task Update_UpdateAVMByDetachingDataDisk() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, - DataDisks = -{ -new VirtualMachineDataDisk(0,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineDataDisk(0, DiskCreateOptionType.Empty) { DiskSizeGB = 1023, ToBeDetached = true, -},new VirtualMachineDataDisk(1,DiskCreateOptionType.Empty) +}, new VirtualMachineDataDisk(1, DiskCreateOptionType.Empty) { DiskSizeGB = 1023, ToBeDetached = false, -} -}, +}}, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await virtualMachine.UpdateAsync(WaitUntil.Completed, patch); @@ -213,15 +267,15 @@ public async Task Update_UpdateAVMByForceDetachingDataDisk() VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // invoke the operation - VirtualMachinePatch patch = new VirtualMachinePatch() + VirtualMachinePatch patch = new VirtualMachinePatch { - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.StandardD2V2, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -232,41 +286,35 @@ public async Task Update_UpdateAVMByForceDetachingDataDisk() { Name = "myVMosdisk", Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, - DataDisks = -{ -new VirtualMachineDataDisk(0,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineDataDisk(0, DiskCreateOptionType.Empty) { DiskSizeGB = 1023, ToBeDetached = true, DetachOption = DiskDetachOptionType.ForceDetach, -},new VirtualMachineDataDisk(1,DiskCreateOptionType.Empty) +}, new VirtualMachineDataDisk(1, DiskCreateOptionType.Empty) { DiskSizeGB = 1023, ToBeDetached = false, -} -}, +}}, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "myVM", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}"), -} -}, +}}, }, }; ArmOperation lro = await virtualMachine.UpdateAsync(WaitUntil.Completed, patch); @@ -281,98 +329,10 @@ public async Task Update_UpdateAVMByForceDetachingDataDisk() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ForceDeleteAVM() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Delete_Force.json - // this example is just showing the usage of "VirtualMachines_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineResource created on azure - // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string vmName = "myVM"; - ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); - VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); - - // invoke the operation - bool? forceDeletion = true; - await virtualMachine.DeleteAsync(WaitUntil.Completed, forceDeletion: forceDeletion); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachine() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get.json - // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineResource created on azure - // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string vmName = "myVM"; - ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); - VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); - - // invoke the operation - InstanceViewType? expand = InstanceViewType.UserData; - VirtualMachineResource result = await virtualMachine.GetAsync(expand: expand); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachinePlacedOnADedicatedHostGroupThroughAutomaticPlacement() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_AutoPlacedOnDedicatedHostGroup.json - // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineResource created on azure - // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string vmName = "myVM"; - ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); - VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); - - // invoke the operation - VirtualMachineResource result = await virtualMachine.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachineWithDiskControllerTypeProperties() + public async Task Capture_VirtualMachineCaptureMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithDiskControllerType.json - // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Capture_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachines_Capture" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -382,28 +342,25 @@ public async Task Get_GetAVirtualMachineWithDiskControllerTypeProperties() // this example assumes you already have this VirtualMachineResource created on azure // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string vmName = "myVM"; + string resourceGroupName = "rgcompute"; + string vmName = "aaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // invoke the operation - InstanceViewType? expand = InstanceViewType.UserData; - VirtualMachineResource result = await virtualMachine.GetAsync(expand: expand); + VirtualMachineCaptureContent content = new VirtualMachineCaptureContent("aaaaaaaaa", "aaaaaaa", true); + ArmOperation lro = await virtualMachine.CaptureAsync(WaitUntil.Completed, content); + VirtualMachineCaptureResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachineWithVMSizeProperties() + public async Task Capture_VirtualMachineCaptureMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Get_WithVMSizeProperties.json - // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_Capture_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachines_Capture" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -413,19 +370,17 @@ public async Task Get_GetAVirtualMachineWithVMSizeProperties() // this example assumes you already have this VirtualMachineResource created on azure // for more information of creating VirtualMachineResource, please refer to the document of VirtualMachineResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string vmName = "myVM"; + string resourceGroupName = "rgcompute"; + string vmName = "aaaaaaaaaaaaa"; ResourceIdentifier virtualMachineResourceId = VirtualMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName); VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // invoke the operation - VirtualMachineResource result = await virtualMachine.GetAsync(); + VirtualMachineCaptureContent content = new VirtualMachineCaptureContent("aaaaaaaaa", "aaaaaaa", true); + ArmOperation lro = await virtualMachine.CaptureAsync(WaitUntil.Completed, content); + VirtualMachineCaptureResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -611,70 +566,6 @@ public async Task Generalize_GeneralizeAVirtualMachine() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVirtualMachines_VirtualMachineListAllMaximumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_ListAll_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachines_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string statusOnly = "aaaaaa"; - string filter = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - await foreach (VirtualMachineResource item in subscriptionResource.GetVirtualMachinesAsync(statusOnly: statusOnly, filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVirtualMachines_VirtualMachineListAllMinimumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineExamples/VirtualMachine_ListAll_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachines_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VirtualMachineResource item in subscriptionResource.GetVirtualMachinesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetAvailableSizes_ListsAllAvailableVirtualMachineSizesToWhichTheSpecifiedVirtualMachineCanBeResized() @@ -960,11 +851,11 @@ public async Task Reimage_ReimageANonEphemeralVirtualMachine() VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // invoke the operation - VirtualMachineReimageContent content = new VirtualMachineReimageContent() + VirtualMachineReimageContent content = new VirtualMachineReimageContent { TempDisk = true, ExactVersion = "aaaaaa", - OSProfile = new OSProfileProvisioningData() + OSProfile = new OSProfileProvisioningData { AdminPassword = "{your-password}", CustomData = "{your-custom-data}", @@ -996,7 +887,7 @@ public async Task Reimage_ReimageAVirtualMachine() VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // invoke the operation - VirtualMachineReimageContent content = new VirtualMachineReimageContent() + VirtualMachineReimageContent content = new VirtualMachineReimageContent { TempDisk = true, }; @@ -1161,12 +1052,9 @@ public async Task InstallPatches_InstallPatchStateOfAVirtualMachine() VirtualMachineInstallPatchesContent content = new VirtualMachineInstallPatchesContent(VmGuestPatchRebootSetting.IfRequired) { MaximumDuration = XmlConvert.ToTimeSpan("PT4H"), - WindowsParameters = new WindowsParameters() + WindowsParameters = new WindowsParameters { - ClassificationsToInclude = -{ -VmGuestPatchClassificationForWindows.Critical,VmGuestPatchClassificationForWindows.Security -}, + ClassificationsToInclude = { VmGuestPatchClassificationForWindows.Critical, VmGuestPatchClassificationForWindows.Security }, MaxPatchPublishOn = DateTimeOffset.Parse("2020-11-19T02:36:43.0539904+00:00"), }, }; @@ -1197,36 +1085,30 @@ public async Task AttachDetachDataDisks_VirtualMachineAttachDetachDataDisksMaxim VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // invoke the operation - AttachDetachDataDisksRequest attachDetachDataDisksRequest = new AttachDetachDataDisksRequest() + AttachDetachDataDisksRequest attachDetachDataDisksRequest = new AttachDetachDataDisksRequest { - DataDisksToAttach = -{ -new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_0_disk2_6c4f554bdafa49baa780eb2d128ff39d") + DataDisksToAttach = {new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_0_disk2_6c4f554bdafa49baa780eb2d128ff39d") { Lun = 1, Caching = CachingType.ReadOnly, DeleteOption = DiskDeleteOptionType.Delete, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), WriteAcceleratorEnabled = true, -},new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_2_disk3_7d5e664bdafa49baa780eb2d128ff38e") +}, new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_2_disk3_7d5e664bdafa49baa780eb2d128ff38e") { Lun = 2, Caching = CachingType.ReadWrite, DeleteOption = DiskDeleteOptionType.Detach, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), WriteAcceleratorEnabled = false, -} -}, - DataDisksToDetach = -{ -new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_1_disk1_1a4e784bdafa49baa780eb2d128ff65x") +}}, + DataDisksToDetach = {new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_1_disk1_1a4e784bdafa49baa780eb2d128ff65x") { DetachOption = DiskDetachOptionType.ForceDetach, -},new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_4_disk4_4d4e784bdafa49baa780eb2d256ff41z") +}, new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_4_disk4_4d4e784bdafa49baa780eb2d256ff41z") { DetachOption = DiskDetachOptionType.ForceDetach, -} -}, +}}, }; ArmOperation lro = await virtualMachine.AttachDetachDataDisksAsync(WaitUntil.Completed, attachDetachDataDisksRequest); VirtualMachineStorageProfile result = lro.Value; @@ -1255,16 +1137,10 @@ public async Task AttachDetachDataDisks_VirtualMachineAttachDetachDataDisksMinim VirtualMachineResource virtualMachine = client.GetVirtualMachineResource(virtualMachineResourceId); // invoke the operation - AttachDetachDataDisksRequest attachDetachDataDisksRequest = new AttachDetachDataDisksRequest() + AttachDetachDataDisksRequest attachDetachDataDisksRequest = new AttachDetachDataDisksRequest { - DataDisksToAttach = -{ -new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_0_disk2_6c4f554bdafa49baa780eb2d128ff39d") -}, - DataDisksToDetach = -{ -new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_1_disk1_1a4e784bdafa49baa780eb2d128ff65x") -}, + DataDisksToAttach = { new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_0_disk2_6c4f554bdafa49baa780eb2d128ff39d") }, + DataDisksToDetach = { new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_1_disk1_1a4e784bdafa49baa780eb2d128ff65x") }, }; ArmOperation lro = await virtualMachine.AttachDetachDataDisksAsync(WaitUntil.Completed, attachDetachDataDisksRequest); VirtualMachineStorageProfile result = lro.Value; diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineRunCommandCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineRunCommandCollection.cs index 0b899895f777e..cba6301775e51 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineRunCommandCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineRunCommandCollection.cs @@ -43,21 +43,18 @@ public async Task CreateOrUpdate_CreateOrUpdateARunCommand() string runCommandName = "myRunCommand"; VirtualMachineRunCommandData data = new VirtualMachineRunCommandData(new AzureLocation("West US")) { - Source = new VirtualMachineRunCommandScriptSource() + Source = new VirtualMachineRunCommandScriptSource { ScriptUri = new Uri("https://mystorageaccount.blob.core.windows.net/scriptcontainer/scriptURI"), }, - Parameters = -{ -new RunCommandInputParameter("param1","value1"),new RunCommandInputParameter("param2","value2") -}, + Parameters = { new RunCommandInputParameter("param1", "value1"), new RunCommandInputParameter("param2", "value2") }, AsyncExecution = false, RunAsUser = "user1", RunAsPassword = "", TimeoutInSeconds = 3600, OutputBlobUri = new Uri("https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/MyScriptoutput.txt"), ErrorBlobUri = new Uri("https://mystorageaccount.blob.core.windows.net/scriptcontainer/scriptURI"), - OutputBlobManagedIdentity = new RunCommandManagedIdentity() + OutputBlobManagedIdentity = new RunCommandManagedIdentity { ClientId = "22d35efb-0c99-4041-8c5b-6d24db33a69a", }, @@ -109,10 +106,10 @@ public async Task Get_GetARunCommand() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetARunCommand() + public async Task GetAll_ListRunCommandsInAVirtualMachine() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineRunCommand_Get.json - // this example is just showing the usage of "VirtualMachineRunCommands_GetByVirtualMachine" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineRunCommand_List.json + // this example is just showing the usage of "VirtualMachineRunCommands_ListByVirtualMachine" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,16 +127,22 @@ public async Task Exists_GetARunCommand() // get the collection of this VirtualMachineRunCommandResource VirtualMachineRunCommandCollection collection = virtualMachine.GetVirtualMachineRunCommands(); - // invoke the operation - string runCommandName = "myRunCommand"; - bool result = await collection.ExistsAsync(runCommandName); + // invoke the operation and iterate over the result + await foreach (VirtualMachineRunCommandResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineRunCommandData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetARunCommand() + public async Task Exists_GetARunCommand() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineRunCommand_Get.json // this example is just showing the usage of "VirtualMachineRunCommands_GetByVirtualMachine" operation, for the dependent resources, they will have to be created separately. @@ -162,29 +165,17 @@ public async Task GetIfExists_GetARunCommand() // invoke the operation string runCommandName = "myRunCommand"; - NullableResponse response = await collection.GetIfExistsAsync(runCommandName); - VirtualMachineRunCommandResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(runCommandName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineRunCommandData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRunCommandsInAVirtualMachine() + public async Task GetIfExists_GetARunCommand() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineRunCommand_List.json - // this example is just showing the usage of "VirtualMachineRunCommands_ListByVirtualMachine" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineRunCommand_Get.json + // this example is just showing the usage of "VirtualMachineRunCommands_GetByVirtualMachine" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -202,17 +193,23 @@ public async Task GetAll_ListRunCommandsInAVirtualMachine() // get the collection of this VirtualMachineRunCommandResource VirtualMachineRunCommandCollection collection = virtualMachine.GetVirtualMachineRunCommands(); - // invoke the operation and iterate over the result - await foreach (VirtualMachineRunCommandResource item in collection.GetAllAsync()) + // invoke the operation + string runCommandName = "myRunCommand"; + NullableResponse response = await collection.GetIfExistsAsync(runCommandName); + VirtualMachineRunCommandResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineRunCommandData resourceData = item.Data; + VirtualMachineRunCommandData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineRunCommandResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineRunCommandResource.cs index 0e17c34946553..8492227ae0f71 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineRunCommandResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineRunCommandResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Compute.Samples @@ -19,64 +18,10 @@ public partial class Sample_VirtualMachineRunCommandResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetVirtualMachineRunCommands_VirtualMachineRunCommandList() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/RunCommand_List.json - // this example is just showing the usage of "VirtualMachineRunCommands_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("SoutheastAsia"); - await foreach (RunCommandDocumentBase item in subscriptionResource.GetVirtualMachineRunCommandsAsync(location)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVirtualMachineRunCommand_VirtualMachineRunCommandGet() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/RunCommand_Get.json - // this example is just showing the usage of "VirtualMachineRunCommands_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "24fb23e3-6ba3-41f0-9b6e-e41131d5d61e"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("SoutheastAsia"); - string commandId = "RunPowerShellScript"; - RunCommandDocument result = await subscriptionResource.GetVirtualMachineRunCommandAsync(location, commandId); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateARunCommand() + public async Task Get_GetARunCommand() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineRunCommand_Update.json - // this example is just showing the usage of "VirtualMachineRunCommands_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineRunCommand_Get.json + // this example is just showing the usage of "VirtualMachineRunCommands_GetByVirtualMachine" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,29 +38,7 @@ public async Task Update_UpdateARunCommand() VirtualMachineRunCommandResource virtualMachineRunCommand = client.GetVirtualMachineRunCommandResource(virtualMachineRunCommandResourceId); // invoke the operation - VirtualMachineRunCommandUpdate runCommand = new VirtualMachineRunCommandUpdate() - { - Source = new VirtualMachineRunCommandScriptSource() - { - Script = "Write-Host Hello World! ; Remove-Item C:\test\testFile.txt", - }, - Parameters = -{ -new RunCommandInputParameter("param1","value1"),new RunCommandInputParameter("param2","value2") -}, - AsyncExecution = false, - RunAsUser = "user1", - RunAsPassword = "", - TimeoutInSeconds = 3600, - OutputBlobUri = new Uri("https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/outputUri"), - ErrorBlobUri = new Uri("https://mystorageaccount.blob.core.windows.net/mycontainer/MyScriptError.txt"), - ErrorBlobManagedIdentity = new RunCommandManagedIdentity() - { - ObjectId = "4231e4d2-33e4-4e23-96b2-17888afa6072", - }, - }; - ArmOperation lro = await virtualMachineRunCommand.UpdateAsync(WaitUntil.Completed, runCommand); - VirtualMachineRunCommandResource result = lro.Value; + VirtualMachineRunCommandResource result = await virtualMachineRunCommand.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -153,10 +76,10 @@ public async Task Delete_DeleteARunCommand() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARunCommand() + public async Task Update_UpdateARunCommand() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineRunCommand_Get.json - // this example is just showing the usage of "VirtualMachineRunCommands_GetByVirtualMachine" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineRunCommand_Update.json + // this example is just showing the usage of "VirtualMachineRunCommands_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,7 +96,26 @@ public async Task Get_GetARunCommand() VirtualMachineRunCommandResource virtualMachineRunCommand = client.GetVirtualMachineRunCommandResource(virtualMachineRunCommandResourceId); // invoke the operation - VirtualMachineRunCommandResource result = await virtualMachineRunCommand.GetAsync(); + VirtualMachineRunCommandUpdate runCommand = new VirtualMachineRunCommandUpdate + { + Source = new VirtualMachineRunCommandScriptSource + { + Script = "Write-Host Hello World! ; Remove-Item C:\test\testFile.txt", + }, + Parameters = { new RunCommandInputParameter("param1", "value1"), new RunCommandInputParameter("param2", "value2") }, + AsyncExecution = false, + RunAsUser = "user1", + RunAsPassword = "", + TimeoutInSeconds = 3600, + OutputBlobUri = new Uri("https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/outputUri"), + ErrorBlobUri = new Uri("https://mystorageaccount.blob.core.windows.net/mycontainer/MyScriptError.txt"), + ErrorBlobManagedIdentity = new RunCommandManagedIdentity + { + ObjectId = "4231e4d2-33e4-4e23-96b2-17888afa6072", + }, + }; + ArmOperation lro = await virtualMachineRunCommand.UpdateAsync(WaitUntil.Completed, runCommand); + VirtualMachineRunCommandResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetCollection.cs index b31f3fc395029..3b50cc58602ad 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -45,27 +44,27 @@ public async Task CreateOrUpdate_CreateAVMSSWithAnExtensionThatHasSuppressFailur string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -75,51 +74,40 @@ public async Task CreateOrUpdate_CreateAVMSSWithAnExtensionThatHasSuppressFailur OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), }, - ExtensionProfile = new VirtualMachineScaleSetExtensionProfile() + ExtensionProfile = new VirtualMachineScaleSetExtensionProfile { - Extensions = -{ -new VirtualMachineScaleSetExtensionData() + Extensions = {new VirtualMachineScaleSetExtensionData { Publisher = "{extension-Publisher}", ExtensionType = "{extension-Type}", TypeHandlerVersion = "{handler-version}", AutoUpgradeMinorVersion = false, -Settings = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), +Settings = BinaryData.FromObjectAsJson(new object()), SuppressFailures = true, -} -}, +}}, }, }, Overprovision = true, @@ -160,27 +148,27 @@ public async Task CreateOrUpdate_CreateAVMSSWithAnExtensionWithProtectedSettings string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -190,54 +178,43 @@ public async Task CreateOrUpdate_CreateAVMSSWithAnExtensionWithProtectedSettings OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), }, - ExtensionProfile = new VirtualMachineScaleSetExtensionProfile() + ExtensionProfile = new VirtualMachineScaleSetExtensionProfile { - Extensions = -{ -new VirtualMachineScaleSetExtensionData() + Extensions = {new VirtualMachineScaleSetExtensionData { Publisher = "{extension-Publisher}", ExtensionType = "{extension-Type}", TypeHandlerVersion = "{handler-version}", AutoUpgradeMinorVersion = false, -Settings = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), -KeyVaultProtectedSettings = new KeyVaultSecretReference(new Uri("https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"),new WritableSubResource() +Settings = BinaryData.FromObjectAsJson(new object()), +KeyVaultProtectedSettings = new KeyVaultSecretReference(new Uri("https://kvName.vault.azure.net/secrets/secretName/79b88b3a6f5440ffb2e73e44a0db712e"), new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/a53f7094-a16c-47af-abe4-b05c05d0d79a/resourceGroups/myResourceGroup/providers/Microsoft.KeyVault/vaults/kvName"), }), -} -}, +}}, }, }, Overprovision = true, @@ -278,25 +255,25 @@ public async Task CreateOrUpdate_CreateACustomImageScaleSetFromAnUnmanagedGenera string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { @@ -305,23 +282,17 @@ public async Task CreateOrUpdate_CreateACustomImageScaleSetFromAnUnmanagedGenera ImageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"), }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -362,27 +333,27 @@ public async Task CreateOrUpdate_CreateAPlatformImageScaleSetWithUnmanagedOsDisk string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -393,29 +364,20 @@ public async Task CreateOrUpdate_CreateAPlatformImageScaleSetWithUnmanagedOsDisk { Name = "osDisk", Caching = CachingType.ReadWrite, - VhdContainers = -{ -"http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer","http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer","http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer","http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer","http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer" -}, + VhdContainers = { "http://{existing-storage-account-name-0}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-1}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-2}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-3}.blob.core.windows.net/vhdContainer", "http://{existing-storage-account-name-4}.blob.core.windows.net/vhdContainer" }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -456,56 +418,50 @@ public async Task CreateOrUpdate_CreateAScaleSetFromACustomImage() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"), }, OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -546,56 +502,50 @@ public async Task CreateOrUpdate_CreateAScaleSetFromAGeneralizedSharedImage() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"), }, OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -636,50 +586,44 @@ public async Task CreateOrUpdate_CreateAScaleSetFromASpecializedSharedImage() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/mySharedGallery/images/mySharedImage"), }, OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -720,73 +664,64 @@ public async Task CreateOrUpdate_CreateAScaleSetWhereNicConfigHasDisableTcpState string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"), }, OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{nicConfig1-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{nicConfig1-name}") { Primary = true, EnableAcceleratedNetworking = true, IsTcpStateTrackingDisabled = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -},new VirtualMachineScaleSetNetworkConfiguration("{nicConfig2-name}") +}, new VirtualMachineScaleSetNetworkConfiguration("{nicConfig2-name}") { Primary = false, EnableAcceleratedNetworking = false, IsTcpStateTrackingDisabled = false, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{nicConfig2-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{nicConfig2-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"), Primary = true, PrivateIPAddressVersion = IPVersion.IPv4, -} -}, +}}, EnableIPForwarding = false, -} -}, +}}, }, }, Overprovision = true, @@ -827,27 +762,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithApplicationProfile() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -857,41 +792,32 @@ public async Task CreateOrUpdate_CreateAScaleSetWithApplicationProfile() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - GalleryApplications = -{ -new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0") + GalleryApplications = {new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdb/resourceGroups/myresourceGroupName2/providers/Microsoft.Compute/galleries/myGallery1/applications/MyApplication1/versions/1.0") { Tags = "myTag1", Order = 1, ConfigurationReference = "https://mystorageaccount.blob.core.windows.net/configurations/settings.config", TreatFailureAsDeploymentFailure = true, EnableAutomaticUpgrade = false, -},new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1") -}, +}, new VirtualMachineGalleryApplication("/subscriptions/32c17a9e-aa7b-4ba5-a45b-e324116b6fdg/resourceGroups/myresourceGroupName3/providers/Microsoft.Compute/galleries/myGallery2/applications/MyApplication2/versions/1.1")}, }, Overprovision = true, }; @@ -931,36 +857,36 @@ public async Task CreateOrUpdate_CreateAScaleSetWithDiskControllerType() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - ScheduledEventsPolicy = new ScheduledEventsPolicy() + ScheduledEventsPolicy = new ScheduledEventsPolicy { - UserInitiatedRedeploy = new UserInitiatedRedeploy() + UserInitiatedRedeploy = new UserInitiatedRedeploy { AutomaticallyApprove = true, }, AutomaticallyApprove = true, Enable = true, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -970,33 +896,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithDiskControllerType() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, DiskControllerType = "NVMe", }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, UserData = "RXhhbXBsZSBVc2VyRGF0YQ==", - HardwareVmSizeProperties = new VirtualMachineSizeProperties() + HardwareVmSizeProperties = new VirtualMachineSizeProperties { VCpusAvailable = 1, VCpusPerCore = 1, @@ -1040,70 +960,61 @@ public async Task CreateOrUpdate_CreateAScaleSetWithDiskEncryptionSetResourceInO string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_DS1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"), }, OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), }, }, - DataDisks = -{ -new VirtualMachineScaleSetDataDisk(0,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineScaleSetDataDisk(0, DiskCreateOptionType.Empty) { Caching = CachingType.ReadWrite, DiskSizeGB = 1023, -ManagedDisk = new VirtualMachineScaleSetManagedDisk() +ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), }, -} -}, +}}, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -1144,71 +1055,62 @@ public async Task CreateOrUpdate_CreateAScaleSetWithFpgaNetworkInterfaces() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"), }, OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -},new VirtualMachineScaleSetNetworkConfiguration("{fpgaNic-Name}") +}, new VirtualMachineScaleSetNetworkConfiguration("{fpgaNic-Name}") { Primary = false, EnableAcceleratedNetworking = false, EnableFpga = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{fpgaNic-Name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{fpgaNic-Name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name}"), Primary = true, PrivateIPAddressVersion = IPVersion.IPv4, -} -}, +}}, EnableIPForwarding = false, -} -}, +}}, }, }, Overprovision = true, @@ -1249,33 +1151,33 @@ public async Task CreateOrUpdate_CreateAScaleSetWithHostEncryptionUsingEncryptio string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_DS1_v2", Tier = "Standard", Capacity = 3L, }, - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -1285,31 +1187,25 @@ public async Task CreateOrUpdate_CreateAScaleSetWithHostEncryptionUsingEncryptio OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { EncryptionAtHost = true, }, @@ -1352,66 +1248,59 @@ public async Task CreateOrUpdate_CreateAScaleSetWithNetworkInterfacesWithPublicI string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/{existing-custom-image-name}"), }, OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{nicConfig1-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{nicConfig1-name}") { Primary = true, EnableAcceleratedNetworking = true, IsTcpStateTrackingDisabled = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, AuxiliaryMode = ComputeNetworkInterfaceAuxiliaryMode.AcceleratedConnections, AuxiliarySku = ComputeNetworkInterfaceAuxiliarySku.A1, -},new VirtualMachineScaleSetNetworkConfiguration("{nicConfig2-name}") +}, new VirtualMachineScaleSetNetworkConfiguration("{nicConfig2-name}") { Primary = false, EnableAcceleratedNetworking = false, IsTcpStateTrackingDisabled = false, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{nicConfig2-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{nicConfig2-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-fpga-subnet-name2}"), Primary = true, @@ -1424,11 +1313,9 @@ public async Task CreateOrUpdate_CreateAScaleSetWithNetworkInterfacesWithPublicI }, }, PrivateIPAddressVersion = IPVersion.IPv4, -} -}, +}}, EnableIPForwarding = false, -} -}, +}}, }, }, Overprovision = true, @@ -1469,27 +1356,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithOSImageScheduledEventsEnable string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1499,33 +1386,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithOSImageScheduledEventsEnable OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - ScheduledEventsProfile = new ComputeScheduledEventsProfile() + ScheduledEventsProfile = new ComputeScheduledEventsProfile { - OSImageNotificationProfile = new OSImageNotificationProfile() + OSImageNotificationProfile = new OSImageNotificationProfile { NotBeforeTimeout = "PT15M", Enable = true, @@ -1570,27 +1451,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithProxyAgentSettingsOfEnabledA string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D2s_v3", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1600,33 +1481,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithProxyAgentSettingsOfEnabledA OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardSsdLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - ProxyAgentSettings = new ProxyAgentSettings() + ProxyAgentSettings = new ProxyAgentSettings { Enabled = true, Mode = Mode.Enforce, @@ -1671,27 +1546,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithResilientVMCreationEnabled() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1701,33 +1576,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithResilientVMCreationEnabled() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = false, - ResiliencyPolicy = new ResiliencyPolicy() + ResiliencyPolicy = new ResiliencyPolicy { ResilientVmCreationPolicyEnabled = true, }, @@ -1768,27 +1637,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithResilientVMDeletionEnabled() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1798,33 +1667,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithResilientVMDeletionEnabled() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = false, - ResiliencyPolicy = new ResiliencyPolicy() + ResiliencyPolicy = new ResiliencyPolicy { ResilientVmDeletionPolicyEnabled = true, }, @@ -1865,31 +1728,31 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSecurityPostureReference() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("eastus2euap")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_A1", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Automatic, - AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy() + AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy { EnableAutomaticOSUpgrade = true, }, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -1902,23 +1765,17 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSecurityPostureReference() Caching = CachingType.ReadWrite, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, SecurityPostureReference = new ComputeSecurityPostureReference(new ResourceIdentifier("/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest")), }, @@ -1960,27 +1817,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSecurityTypeAsConfidentialVM string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_DC2as_v5", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "2019-datacenter-cvm", @@ -1990,37 +1847,31 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSecurityTypeAsConfidentialVM OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardSsdLrs, - SecurityProfile = new VirtualMachineDiskSecurityProfile() + SecurityProfile = new VirtualMachineDiskSecurityProfile { SecurityEncryptionType = SecurityEncryptionType.VmGuestStateOnly, }, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - UefiSettings = new UefiSettings() + UefiSettings = new UefiSettings { IsSecureBootEnabled = true, IsVirtualTpmEnabled = true, @@ -2066,27 +1917,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSecurityTypeAsConfidentialVM string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_DC2es_v5", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "UbuntuServer", Offer = "2022-datacenter-cvm", @@ -2096,37 +1947,31 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSecurityTypeAsConfidentialVM OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardSsdLrs, - SecurityProfile = new VirtualMachineDiskSecurityProfile() + SecurityProfile = new VirtualMachineDiskSecurityProfile { SecurityEncryptionType = SecurityEncryptionType.NonPersistedTPM, }, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - UefiSettings = new UefiSettings() + UefiSettings = new UefiSettings { IsSecureBootEnabled = false, IsVirtualTpmEnabled = true, @@ -2172,31 +2017,31 @@ public async Task CreateOrUpdate_CreateAScaleSetWithServiceArtifactReference() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("eastus2euap")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_A1", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Automatic, - AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy() + AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy { EnableAutomaticOSUpgrade = true, }, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2209,23 +2054,17 @@ public async Task CreateOrUpdate_CreateAScaleSetWithServiceArtifactReference() Caching = CachingType.ReadWrite, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, ServiceArtifactReferenceId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myGalleryName/serviceArtifacts/serviceArtifactName/vmArtifactsProfiles/vmArtifactsProfilesName"), }, @@ -2267,27 +2106,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithUefiSettingsOfSecureBootAndV string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D2s_v3", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "windowsserver-gen2preview-preview", @@ -2297,33 +2136,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithUefiSettingsOfSecureBootAndV OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadOnly, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardSsdLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - UefiSettings = new UefiSettings() + UefiSettings = new UefiSettings { IsSecureBootEnabled = true, IsVirtualTpmEnabled = true, @@ -2369,33 +2202,33 @@ public async Task CreateOrUpdate_CreateAScaleSetWithAMarketplaceImagePlan() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -2405,29 +2238,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithAMarketplaceImagePlan() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -2468,27 +2295,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithAnAzureApplicationGateway() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2498,36 +2325,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithAnAzureApplicationGateway() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -ApplicationGatewayBackendAddressPools = -{ -new WritableSubResource() +ApplicationGatewayBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/applicationGateways/{existing-application-gateway-name}/backendAddressPools/{existing-backend-address-pool-name}"), -} -}, -} -}, +}}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -2568,27 +2386,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithAnAzureLoadBalancer() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2598,47 +2416,35 @@ public async Task CreateOrUpdate_CreateAScaleSetWithAnAzureLoadBalancer() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), PublicIPAddressConfiguration = new VirtualMachineScaleSetPublicIPAddressConfiguration("{vmss-name}") { PublicIPAddressVersion = IPVersion.IPv4, }, -LoadBalancerBackendAddressPools = -{ -new WritableSubResource() +LoadBalancerBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/backendAddressPools/{existing-backend-address-pool-name}"), -} -}, -LoadBalancerInboundNatPools = -{ -new WritableSubResource() +}}, +LoadBalancerInboundNatPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/loadBalancers/{existing-load-balancer-name}/inboundNatPools/{existing-nat-pool-name}"), -} -}, -} -}, +}}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -2679,41 +2485,41 @@ public async Task CreateOrUpdate_CreateAScaleSetWithAutomaticRepairsEnabled() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - ScheduledEventsPolicy = new ScheduledEventsPolicy() + ScheduledEventsPolicy = new ScheduledEventsPolicy { - UserInitiatedRedeploy = new UserInitiatedRedeploy() + UserInitiatedRedeploy = new UserInitiatedRedeploy { AutomaticallyApprove = true, }, AutomaticallyApprove = true, Enable = true, }, - AutomaticRepairsPolicy = new AutomaticRepairsPolicy() + AutomaticRepairsPolicy = new AutomaticRepairsPolicy { Enabled = true, GracePeriod = "PT10M", }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2723,29 +2529,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithAutomaticRepairsEnabled() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -2786,27 +2586,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithBootDiagnostics() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2816,31 +2616,25 @@ public async Task CreateOrUpdate_CreateAScaleSetWithBootDiagnostics() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), @@ -2884,27 +2678,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithEmptyDataDisksOnEachVm() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D2_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -2915,39 +2709,30 @@ public async Task CreateOrUpdate_CreateAScaleSetWithEmptyDataDisksOnEachVm() { Caching = CachingType.ReadWrite, DiskSizeGB = 512, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, - DataDisks = -{ -new VirtualMachineScaleSetDataDisk(0,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineScaleSetDataDisk(0, DiskCreateOptionType.Empty) { DiskSizeGB = 1023, -},new VirtualMachineScaleSetDataDisk(1,DiskCreateOptionType.Empty) +}, new VirtualMachineScaleSetDataDisk(1, DiskCreateOptionType.Empty) { DiskSizeGB = 1023, -} -}, +}}, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -2988,33 +2773,33 @@ public async Task CreateOrUpdate_CreateAScaleSetWithEphemeralOsDiskProvisioningI string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_DS1_v2", Tier = "Standard", Capacity = 3L, }, - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -3024,34 +2809,28 @@ public async Task CreateOrUpdate_CreateAScaleSetWithEphemeralOsDiskProvisioningI OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadOnly, - DiffDiskSettings = new DiffDiskSettings() + DiffDiskSettings = new DiffDiskSettings { Option = DiffDiskOption.Local, Placement = DiffDiskPlacement.NvmeDisk, }, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -3092,33 +2871,33 @@ public async Task CreateOrUpdate_CreateAScaleSetWithEphemeralOsDisksUsingPlaceme string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_DS1_v2", Tier = "Standard", Capacity = 3L, }, - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -3128,34 +2907,28 @@ public async Task CreateOrUpdate_CreateAScaleSetWithEphemeralOsDisksUsingPlaceme OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadOnly, - DiffDiskSettings = new DiffDiskSettings() + DiffDiskSettings = new DiffDiskSettings { Option = DiffDiskOption.Local, Placement = DiffDiskPlacement.ResourceDisk, }, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -3196,33 +2969,33 @@ public async Task CreateOrUpdate_CreateAScaleSetWithEphemeralOsDisks() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_DS1_v2", Tier = "Standard", Capacity = 3L, }, - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", Product = "windows-data-science-vm", }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "microsoft-ads", Offer = "windows-data-science-vm", @@ -3232,33 +3005,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithEphemeralOsDisks() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadOnly, - DiffDiskSettings = new DiffDiskSettings() + DiffDiskSettings = new DiffDiskSettings { Option = DiffDiskOption.Local, }, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -3299,27 +3066,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithExtensionTimeBudget() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3329,50 +3096,39 @@ public async Task CreateOrUpdate_CreateAScaleSetWithExtensionTimeBudget() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), }, - ExtensionProfile = new VirtualMachineScaleSetExtensionProfile() + ExtensionProfile = new VirtualMachineScaleSetExtensionProfile { - Extensions = -{ -new VirtualMachineScaleSetExtensionData() + Extensions = {new VirtualMachineScaleSetExtensionData { Publisher = "{extension-Publisher}", ExtensionType = "{extension-Type}", TypeHandlerVersion = "{handler-version}", AutoUpgradeMinorVersion = false, -Settings = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), -} -}, +Settings = BinaryData.FromObjectAsJson(new object()), +}}, ExtensionsTimeBudget = "PT1H20M", }, }, @@ -3414,27 +3170,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithManagedBootDiagnostics() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3444,31 +3200,25 @@ public async Task CreateOrUpdate_CreateAScaleSetWithManagedBootDiagnostics() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, }, @@ -3511,27 +3261,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithPasswordAuthentication() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3541,29 +3291,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithPasswordAuthentication() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -3604,27 +3348,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithPremiumStorage() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3634,29 +3378,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithPremiumStorage() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.PremiumLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -3697,23 +3435,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithPriorityMixPolicy() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_A8m_v2", Tier = "Standard", Capacity = 10L, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3723,29 +3461,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithPriorityMixPolicy() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, Priority = VirtualMachinePriorityType.Spot, EvictionPolicy = VirtualMachineEvictionPolicyType.Deallocate, @@ -3753,7 +3485,7 @@ public async Task CreateOrUpdate_CreateAScaleSetWithPriorityMixPolicy() }, SinglePlacementGroup = false, OrchestrationMode = OrchestrationMode.Flexible, - PriorityMixPolicy = new VirtualMachineScaleSetPriorityMixPolicy() + PriorityMixPolicy = new VirtualMachineScaleSetPriorityMixPolicy { BaseRegularPriorityCount = 4, RegularPriorityPercentageAboveBase = 50, @@ -3795,27 +3527,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithScaleInPolicy() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3825,38 +3557,29 @@ public async Task CreateOrUpdate_CreateAScaleSetWithScaleInPolicy() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, - ScaleInPolicy = new ScaleInPolicy() + ScaleInPolicy = new ScaleInPolicy { - Rules = -{ -VirtualMachineScaleSetScaleInRule.OldestVm -}, + Rules = { VirtualMachineScaleSetScaleInRule.OldestVm }, ForceDeletion = true, }, }; @@ -3896,22 +3619,22 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSkuProfile() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Mix", Capacity = 10L, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -3921,29 +3644,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSkuProfile() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, Priority = VirtualMachinePriorityType.Spot, EvictionPolicy = VirtualMachineEvictionPolicyType.Deallocate, @@ -3951,26 +3668,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSkuProfile() }, SinglePlacementGroup = false, OrchestrationMode = OrchestrationMode.Flexible, - PriorityMixPolicy = new VirtualMachineScaleSetPriorityMixPolicy() + PriorityMixPolicy = new VirtualMachineScaleSetPriorityMixPolicy { BaseRegularPriorityCount = 4, RegularPriorityPercentageAboveBase = 50, }, - SkuProfile = new ComputeSkuProfile() + SkuProfile = new ComputeSkuProfile { - VmSizes = -{ -new ComputeSkuProfileVmSize() + VmSizes = {new ComputeSkuProfileVmSize { Name = "Standard_D8s_v5", -},new ComputeSkuProfileVmSize() +}, new ComputeSkuProfileVmSize { Name = "Standard_E16s_v5", -},new ComputeSkuProfileVmSize() +}, new ComputeSkuProfileVmSize { Name = "Standard_D2s_v5", -} -}, +}}, AllocationStrategy = ComputeAllocationStrategy.CapacityOptimized, }, }; @@ -4010,27 +3724,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSpotRestorePolicy() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_A8m_v2", Tier = "Standard", Capacity = 2L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -4040,36 +3754,30 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSpotRestorePolicy() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, Priority = VirtualMachinePriorityType.Spot, EvictionPolicy = VirtualMachineEvictionPolicyType.Deallocate, BillingMaxPrice = -1, }, Overprovision = true, - SpotRestorePolicy = new SpotRestorePolicy() + SpotRestorePolicy = new SpotRestorePolicy { Enabled = true, RestoreTimeout = "PT1H", @@ -4111,38 +3819,35 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSshAuthentication() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", - LinuxConfiguration = new LinuxConfiguration() + LinuxConfiguration = new LinuxConfiguration { IsPasswordAuthenticationDisabled = true, - SshPublicKeys = -{ -new SshPublicKeyConfiguration() + SshPublicKeys = {new SshPublicKeyConfiguration { Path = "/home/{your-username}/.ssh/authorized_keys", KeyData = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1", -} -}, +}}, }, }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -4152,29 +3857,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithSshAuthentication() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -4215,27 +3914,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithTerminateScheduledEventsEnab string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -4245,33 +3944,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithTerminateScheduledEventsEnab OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, - ScheduledEventsProfile = new ComputeScheduledEventsProfile() + ScheduledEventsProfile = new ComputeScheduledEventsProfile { - TerminateNotificationProfile = new TerminateNotificationProfile() + TerminateNotificationProfile = new TerminateNotificationProfile { NotBeforeTimeout = "PT5M", Enable = true, @@ -4316,27 +4009,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithUserData() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -4346,29 +4039,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithUserData() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, UserData = "RXhhbXBsZSBVc2VyRGF0YQ==", }, @@ -4410,31 +4097,28 @@ public async Task CreateOrUpdate_CreateAScaleSetWithVirtualMachinesInDifferentZo string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("centralus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_A1_v2", Tier = "Standard", Capacity = 2L, }, - Zones = -{ -"1","3" -}, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + Zones = { "1", "3" }, + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Automatic, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -4445,39 +4129,30 @@ public async Task CreateOrUpdate_CreateAScaleSetWithVirtualMachinesInDifferentZo { Caching = CachingType.ReadWrite, DiskSizeGB = 512, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, - DataDisks = -{ -new VirtualMachineScaleSetDataDisk(0,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineScaleSetDataDisk(0, DiskCreateOptionType.Empty) { DiskSizeGB = 1023, -},new VirtualMachineScaleSetDataDisk(1,DiskCreateOptionType.Empty) +}, new VirtualMachineScaleSetDataDisk(1, DiskCreateOptionType.Empty) { DiskSizeGB = 1023, -} -}, +}}, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -4518,27 +4193,27 @@ public async Task CreateOrUpdate_CreateAScaleSetWithVmSizeProperties() string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -4548,32 +4223,26 @@ public async Task CreateOrUpdate_CreateAScaleSetWithVmSizeProperties() OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, UserData = "RXhhbXBsZSBVc2VyRGF0YQ==", - HardwareVmSizeProperties = new VirtualMachineSizeProperties() + HardwareVmSizeProperties = new VirtualMachineSizeProperties { VCpusAvailable = 1, VCpusPerCore = 1, @@ -4617,36 +4286,36 @@ public async Task CreateOrUpdate_CreateAScaleSetWithZonalPlatformFaultDomainAlig string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_D1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - ScheduledEventsPolicy = new ScheduledEventsPolicy() + ScheduledEventsPolicy = new ScheduledEventsPolicy { - UserInitiatedRedeploy = new UserInitiatedRedeploy() + UserInitiatedRedeploy = new UserInitiatedRedeploy { AutomaticallyApprove = true, }, AutomaticallyApprove = true, Enable = true, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -4656,29 +4325,23 @@ public async Task CreateOrUpdate_CreateAScaleSetWithZonalPlatformFaultDomainAlig OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, }, Overprovision = true, @@ -4720,27 +4383,27 @@ public async Task CreateOrUpdate_CreateOrUpdateAScaleSetWithCapacityReservation( string virtualMachineScaleSetName = "{vmss-name}"; VirtualMachineScaleSetData data = new VirtualMachineScaleSetData(new AzureLocation("westus")) { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "Standard_DS1_v2", Tier = "Standard", Capacity = 3L, }, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, }, - VirtualMachineProfile = new VirtualMachineScaleSetVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetVmProfile { - OSProfile = new VirtualMachineScaleSetOSProfile() + OSProfile = new VirtualMachineScaleSetOSProfile { ComputerNamePrefix = "{vmss-name}", AdminUsername = "{your-username}", AdminPassword = "{your-password}", }, - StorageProfile = new VirtualMachineScaleSetStorageProfile() + StorageProfile = new VirtualMachineScaleSetStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -4750,29 +4413,23 @@ public async Task CreateOrUpdate_CreateOrUpdateAScaleSetWithCapacityReservation( OSDisk = new VirtualMachineScaleSetOSDisk(DiskCreateOptionType.FromImage) { Caching = CachingType.ReadWrite, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new VirtualMachineScaleSetNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetNetworkProfile { - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("{vmss-name}") { Primary = true, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("{vmss-name}") +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("{vmss-name}") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/{existing-virtual-network-name}/subnets/{existing-subnet-name}"), -} -}, +}}, EnableIPForwarding = true, -} -}, +}}, }, CapacityReservationGroupId = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/CapacityReservationGroups/{crgName}"), }, @@ -4824,9 +4481,9 @@ public async Task Get_GetVMScaleSetVMWithDiskControllerType() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVMScaleSetVMWithDiskControllerType() + public async Task Get_GetAVirtualMachineScaleSet() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithDiskControllerType.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get.json // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -4846,17 +4503,20 @@ public async Task Exists_GetVMScaleSetVMWithDiskControllerType() // invoke the operation string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; - bool result = await collection.ExistsAsync(virtualMachineScaleSetName, expand: expand); + VirtualMachineScaleSetResource result = await collection.GetAsync(virtualMachineScaleSetName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVMScaleSetVMWithDiskControllerType() + public async Task Get_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGroupThroughAutomaticPlacement() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithDiskControllerType.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_AutoPlacedOnDedicatedHostGroup.json // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -4876,29 +4536,20 @@ public async Task GetIfExists_GetVMScaleSetVMWithDiskControllerType() // invoke the operation string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; - NullableResponse response = await collection.GetIfExistsAsync(virtualMachineScaleSetName, expand: expand); - VirtualMachineScaleSetResource result = response.HasValue ? response.Value : null; + VirtualMachineScaleSetResource result = await collection.GetAsync(virtualMachineScaleSetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachineScaleSet() + public async Task Get_GetAVirtualMachineScaleSetWithUserData() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithUserData.json // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -4918,7 +4569,8 @@ public async Task Get_GetAVirtualMachineScaleSet() // invoke the operation string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - VirtualMachineScaleSetResource result = await collection.GetAsync(virtualMachineScaleSetName); + VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; + VirtualMachineScaleSetResource result = await collection.GetAsync(virtualMachineScaleSetName, expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -4929,10 +4581,10 @@ public async Task Get_GetAVirtualMachineScaleSet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAVirtualMachineScaleSet() + public async Task GetAll_VirtualMachineScaleSetListMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get.json - // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_List_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -4942,26 +4594,32 @@ public async Task Exists_GetAVirtualMachineScaleSet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; + string resourceGroupName = "rgcompute"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this VirtualMachineScaleSetResource VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets(); - // invoke the operation - string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - bool result = await collection.ExistsAsync(virtualMachineScaleSetName); + // invoke the operation and iterate over the result + await foreach (VirtualMachineScaleSetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAVirtualMachineScaleSet() + public async Task GetAll_VirtualMachineScaleSetListMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get.json - // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_List_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -4971,37 +4629,31 @@ public async Task GetIfExists_GetAVirtualMachineScaleSet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; + string resourceGroupName = "rgcompute"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this VirtualMachineScaleSetResource VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets(); - // invoke the operation - string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - NullableResponse response = await collection.GetIfExistsAsync(virtualMachineScaleSetName); - VirtualMachineScaleSetResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualMachineScaleSetResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = result.Data; + VirtualMachineScaleSetData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGroupThroughAutomaticPlacement() + public async Task Exists_GetVMScaleSetVMWithDiskControllerType() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_AutoPlacedOnDedicatedHostGroup.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithDiskControllerType.json // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -5021,20 +4673,17 @@ public async Task Get_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGroupThrou // invoke the operation string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - VirtualMachineScaleSetResource result = await collection.GetAsync(virtualMachineScaleSetName); + VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; + bool result = await collection.ExistsAsync(virtualMachineScaleSetName, expand: expand); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGroupThroughAutomaticPlacement() + public async Task Exists_GetAVirtualMachineScaleSet() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_AutoPlacedOnDedicatedHostGroup.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get.json // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -5061,7 +4710,7 @@ public async Task Exists_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGroupTh [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGroupThroughAutomaticPlacement() + public async Task Exists_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGroupThroughAutomaticPlacement() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_AutoPlacedOnDedicatedHostGroup.json // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. @@ -5083,26 +4732,14 @@ public async Task GetIfExists_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGr // invoke the operation string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - NullableResponse response = await collection.GetIfExistsAsync(virtualMachineScaleSetName); - VirtualMachineScaleSetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(virtualMachineScaleSetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachineScaleSetWithUserData() + public async Task Exists_GetAVirtualMachineScaleSetWithUserData() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithUserData.json // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. @@ -5125,20 +4762,16 @@ public async Task Get_GetAVirtualMachineScaleSetWithUserData() // invoke the operation string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; - VirtualMachineScaleSetResource result = await collection.GetAsync(virtualMachineScaleSetName, expand: expand); + bool result = await collection.ExistsAsync(virtualMachineScaleSetName, expand: expand); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAVirtualMachineScaleSetWithUserData() + public async Task GetIfExists_GetVMScaleSetVMWithDiskControllerType() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithUserData.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithDiskControllerType.json // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -5159,16 +4792,28 @@ public async Task Exists_GetAVirtualMachineScaleSetWithUserData() // invoke the operation string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; - bool result = await collection.ExistsAsync(virtualMachineScaleSetName, expand: expand); + NullableResponse response = await collection.GetIfExistsAsync(virtualMachineScaleSetName, expand: expand); + VirtualMachineScaleSetResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAVirtualMachineScaleSetWithUserData() + public async Task GetIfExists_GetAVirtualMachineScaleSet() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithUserData.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get.json // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -5188,8 +4833,7 @@ public async Task GetIfExists_GetAVirtualMachineScaleSetWithUserData() // invoke the operation string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; - NullableResponse response = await collection.GetIfExistsAsync(virtualMachineScaleSetName, expand: expand); + NullableResponse response = await collection.GetIfExistsAsync(virtualMachineScaleSetName); VirtualMachineScaleSetResource result = response.HasValue ? response.Value : null; if (result == null) @@ -5208,10 +4852,10 @@ public async Task GetIfExists_GetAVirtualMachineScaleSetWithUserData() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineScaleSetListMaximumSetGen() + public async Task GetIfExists_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGroupThroughAutomaticPlacement() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_List_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_AutoPlacedOnDedicatedHostGroup.json + // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -5221,32 +4865,38 @@ public async Task GetAll_VirtualMachineScaleSetListMaximumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; + string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this VirtualMachineScaleSetResource VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets(); - // invoke the operation and iterate over the result - await foreach (VirtualMachineScaleSetResource item in collection.GetAllAsync()) + // invoke the operation + string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; + NullableResponse response = await collection.GetIfExistsAsync(virtualMachineScaleSetName); + VirtualMachineScaleSetResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = item.Data; + VirtualMachineScaleSetData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineScaleSetListMinimumSetGen() + public async Task GetIfExists_GetAVirtualMachineScaleSetWithUserData() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_List_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithUserData.json + // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -5256,24 +4906,31 @@ public async Task GetAll_VirtualMachineScaleSetListMinimumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; + string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this VirtualMachineScaleSetResource VirtualMachineScaleSetCollection collection = resourceGroupResource.GetVirtualMachineScaleSets(); - // invoke the operation and iterate over the result - await foreach (VirtualMachineScaleSetResource item in collection.GetAllAsync()) + // invoke the operation + string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; + VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; + NullableResponse response = await collection.GetIfExistsAsync(virtualMachineScaleSetName, expand: expand); + VirtualMachineScaleSetResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = item.Data; + VirtualMachineScaleSetData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetExtensionCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetExtensionCollection.cs index 46f6b4a1ff4de..3a5a3cee956cb 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetExtensionCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetExtensionCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -41,7 +40,7 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetExtensionCreateOrUpdateMa // invoke the operation string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaaa"; - VirtualMachineScaleSetExtensionData data = new VirtualMachineScaleSetExtensionData() + VirtualMachineScaleSetExtensionData data = new VirtualMachineScaleSetExtensionData { ForceUpdateTag = "aaaaaaaaa", Publisher = "{extension-Publisher}", @@ -49,16 +48,9 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetExtensionCreateOrUpdateMa TypeHandlerVersion = "{handler-version}", AutoUpgradeMinorVersion = true, EnableAutomaticUpgrade = true, - Settings = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - ProtectedSettings = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - ProvisionAfterExtensions = -{ -"aa" -}, + Settings = BinaryData.FromObjectAsJson(new object()), + ProtectedSettings = BinaryData.FromObjectAsJson(new object()), + ProvisionAfterExtensions = { "aa" }, SuppressFailures = true, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmssExtensionName, data); @@ -144,9 +136,9 @@ public async Task Get_VirtualMachineScaleSetExtensionGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualMachineScaleSetExtensionGetMaximumSetGen() + public async Task Get_VirtualMachineScaleSetExtensionGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MaximumSet_Gen.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MinimumSet_Gen.json // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -158,7 +150,7 @@ public async Task Exists_VirtualMachineScaleSetExtensionGetMaximumSetGen() // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; + string virtualMachineScaleSetName = "a"; ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); @@ -166,19 +158,22 @@ public async Task Exists_VirtualMachineScaleSetExtensionGetMaximumSetGen() VirtualMachineScaleSetExtensionCollection collection = virtualMachineScaleSet.GetVirtualMachineScaleSetExtensions(); // invoke the operation - string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaa"; - string expand = "aaaaaaa"; - bool result = await collection.ExistsAsync(vmssExtensionName, expand: expand); + string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + VirtualMachineScaleSetExtensionResource result = await collection.GetAsync(vmssExtensionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualMachineScaleSetExtensionGetMaximumSetGen() + public async Task GetAll_VirtualMachineScaleSetExtensionListMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_List_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetExtensions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,39 +184,32 @@ public async Task GetIfExists_VirtualMachineScaleSetExtensionGetMaximumSetGen() // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // get the collection of this VirtualMachineScaleSetExtensionResource VirtualMachineScaleSetExtensionCollection collection = virtualMachineScaleSet.GetVirtualMachineScaleSetExtensions(); - // invoke the operation - string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaa"; - string expand = "aaaaaaa"; - NullableResponse response = await collection.GetIfExistsAsync(vmssExtensionName, expand: expand); - VirtualMachineScaleSetExtensionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualMachineScaleSetExtensionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetExtensionData resourceData = result.Data; + VirtualMachineScaleSetExtensionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualMachineScaleSetExtensionGetMinimumSetGen() + public async Task GetAll_VirtualMachineScaleSetExtensionListMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_List_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetExtensions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -232,29 +220,31 @@ public async Task Get_VirtualMachineScaleSetExtensionGetMinimumSetGen() // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "a"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // get the collection of this VirtualMachineScaleSetExtensionResource VirtualMachineScaleSetExtensionCollection collection = virtualMachineScaleSet.GetVirtualMachineScaleSetExtensions(); - // invoke the operation - string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - VirtualMachineScaleSetExtensionResource result = await collection.GetAsync(vmssExtensionName); + // invoke the operation and iterate over the result + await foreach (VirtualMachineScaleSetExtensionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetExtensionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualMachineScaleSetExtensionGetMinimumSetGen() + public async Task Exists_VirtualMachineScaleSetExtensionGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MinimumSet_Gen.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MaximumSet_Gen.json // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -266,7 +256,7 @@ public async Task Exists_VirtualMachineScaleSetExtensionGetMinimumSetGen() // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "a"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); @@ -274,15 +264,16 @@ public async Task Exists_VirtualMachineScaleSetExtensionGetMinimumSetGen() VirtualMachineScaleSetExtensionCollection collection = virtualMachineScaleSet.GetVirtualMachineScaleSetExtensions(); // invoke the operation - string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - bool result = await collection.ExistsAsync(vmssExtensionName); + string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaa"; + string expand = "aaaaaaa"; + bool result = await collection.ExistsAsync(vmssExtensionName, expand: expand); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualMachineScaleSetExtensionGetMinimumSetGen() + public async Task Exists_VirtualMachineScaleSetExtensionGetMinimumSetGen() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MinimumSet_Gen.json // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. @@ -305,29 +296,17 @@ public async Task GetIfExists_VirtualMachineScaleSetExtensionGetMinimumSetGen() // invoke the operation string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - NullableResponse response = await collection.GetIfExistsAsync(vmssExtensionName); - VirtualMachineScaleSetExtensionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vmssExtensionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineScaleSetExtensionListMaximumSetGen() + public async Task GetIfExists_VirtualMachineScaleSetExtensionGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_List_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetExtensions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -338,32 +317,39 @@ public async Task GetAll_VirtualMachineScaleSetExtensionListMaximumSetGen() // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaa"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // get the collection of this VirtualMachineScaleSetExtensionResource VirtualMachineScaleSetExtensionCollection collection = virtualMachineScaleSet.GetVirtualMachineScaleSetExtensions(); - // invoke the operation and iterate over the result - await foreach (VirtualMachineScaleSetExtensionResource item in collection.GetAllAsync()) + // invoke the operation + string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaa"; + string expand = "aaaaaaa"; + NullableResponse response = await collection.GetIfExistsAsync(vmssExtensionName, expand: expand); + VirtualMachineScaleSetExtensionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetExtensionData resourceData = item.Data; + VirtualMachineScaleSetExtensionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineScaleSetExtensionListMinimumSetGen() + public async Task GetIfExists_VirtualMachineScaleSetExtensionGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_List_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetExtensions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -374,24 +360,30 @@ public async Task GetAll_VirtualMachineScaleSetExtensionListMinimumSetGen() // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string virtualMachineScaleSetName = "a"; ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // get the collection of this VirtualMachineScaleSetExtensionResource VirtualMachineScaleSetExtensionCollection collection = virtualMachineScaleSet.GetVirtualMachineScaleSetExtensions(); - // invoke the operation and iterate over the result - await foreach (VirtualMachineScaleSetExtensionResource item in collection.GetAllAsync()) + // invoke the operation + string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + NullableResponse response = await collection.GetIfExistsAsync(vmssExtensionName); + VirtualMachineScaleSetExtensionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetExtensionData resourceData = item.Data; + VirtualMachineScaleSetExtensionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetExtensionResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetExtensionResource.cs index 94709c5606b08..b17b25575d480 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetExtensionResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetExtensionResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_VirtualMachineScaleSetExtensionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VirtualMachineScaleSetExtensionUpdateMaximumSetGen() + public async Task Get_VirtualMachineScaleSetExtensionGetMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Update_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,34 +32,14 @@ public async Task Update_VirtualMachineScaleSetExtensionUpdateMaximumSetGen() // for more information of creating VirtualMachineScaleSetExtensionResource, please refer to the document of VirtualMachineScaleSetExtensionResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - string vmssExtensionName = "aaaa"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; + string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetExtensionResourceId = VirtualMachineScaleSetExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, vmssExtensionName); VirtualMachineScaleSetExtensionResource virtualMachineScaleSetExtension = client.GetVirtualMachineScaleSetExtensionResource(virtualMachineScaleSetExtensionResourceId); // invoke the operation - VirtualMachineScaleSetExtensionPatch patch = new VirtualMachineScaleSetExtensionPatch() - { - ForceUpdateTag = "aaaaaaaaa", - Publisher = "{extension-Publisher}", - ExtensionType = "{extension-Type}", - TypeHandlerVersion = "{handler-version}", - AutoUpgradeMinorVersion = true, - EnableAutomaticUpgrade = true, - Settings = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - ProtectedSettings = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - ProvisionAfterExtensions = -{ -"aa" -}, - SuppressFailures = true, - }; - ArmOperation lro = await virtualMachineScaleSetExtension.UpdateAsync(WaitUntil.Completed, patch); - VirtualMachineScaleSetExtensionResource result = lro.Value; + string expand = "aaaaaaa"; + VirtualMachineScaleSetExtensionResource result = await virtualMachineScaleSetExtension.GetAsync(expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -71,10 +50,10 @@ public async Task Update_VirtualMachineScaleSetExtensionUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VirtualMachineScaleSetExtensionUpdateMinimumSetGen() + public async Task Get_VirtualMachineScaleSetExtensionGetMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Update_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -85,15 +64,13 @@ public async Task Update_VirtualMachineScaleSetExtensionUpdateMinimumSetGen() // for more information of creating VirtualMachineScaleSetExtensionResource, please refer to the document of VirtualMachineScaleSetExtensionResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; - string vmssExtensionName = "aa"; + string virtualMachineScaleSetName = "a"; + string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetExtensionResourceId = VirtualMachineScaleSetExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, vmssExtensionName); VirtualMachineScaleSetExtensionResource virtualMachineScaleSetExtension = client.GetVirtualMachineScaleSetExtensionResource(virtualMachineScaleSetExtensionResourceId); // invoke the operation - VirtualMachineScaleSetExtensionPatch patch = new VirtualMachineScaleSetExtensionPatch(); - ArmOperation lro = await virtualMachineScaleSetExtension.UpdateAsync(WaitUntil.Completed, patch); - VirtualMachineScaleSetExtensionResource result = lro.Value; + VirtualMachineScaleSetExtensionResource result = await virtualMachineScaleSetExtension.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -158,10 +135,10 @@ public async Task Delete_VirtualMachineScaleSetExtensionDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualMachineScaleSetExtensionGetMaximumSetGen() + public async Task Update_VirtualMachineScaleSetExtensionUpdateMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Update_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,14 +149,27 @@ public async Task Get_VirtualMachineScaleSetExtensionGetMaximumSetGen() // for more information of creating VirtualMachineScaleSetExtensionResource, please refer to the document of VirtualMachineScaleSetExtensionResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; - string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaa"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string vmssExtensionName = "aaaa"; ResourceIdentifier virtualMachineScaleSetExtensionResourceId = VirtualMachineScaleSetExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, vmssExtensionName); VirtualMachineScaleSetExtensionResource virtualMachineScaleSetExtension = client.GetVirtualMachineScaleSetExtensionResource(virtualMachineScaleSetExtensionResourceId); // invoke the operation - string expand = "aaaaaaa"; - VirtualMachineScaleSetExtensionResource result = await virtualMachineScaleSetExtension.GetAsync(expand: expand); + VirtualMachineScaleSetExtensionPatch patch = new VirtualMachineScaleSetExtensionPatch + { + ForceUpdateTag = "aaaaaaaaa", + Publisher = "{extension-Publisher}", + ExtensionType = "{extension-Type}", + TypeHandlerVersion = "{handler-version}", + AutoUpgradeMinorVersion = true, + EnableAutomaticUpgrade = true, + Settings = BinaryData.FromObjectAsJson(new object()), + ProtectedSettings = BinaryData.FromObjectAsJson(new object()), + ProvisionAfterExtensions = { "aa" }, + SuppressFailures = true, + }; + ArmOperation lro = await virtualMachineScaleSetExtension.UpdateAsync(WaitUntil.Completed, patch); + VirtualMachineScaleSetExtensionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -190,10 +180,10 @@ public async Task Get_VirtualMachineScaleSetExtensionGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualMachineScaleSetExtensionGetMinimumSetGen() + public async Task Update_VirtualMachineScaleSetExtensionUpdateMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Get_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetExtension_Update_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetExtensions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,13 +194,15 @@ public async Task Get_VirtualMachineScaleSetExtensionGetMinimumSetGen() // for more information of creating VirtualMachineScaleSetExtensionResource, please refer to the document of VirtualMachineScaleSetExtensionResource string subscriptionId = "{subscription-id}"; string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "a"; - string vmssExtensionName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaaaa"; + string vmssExtensionName = "aa"; ResourceIdentifier virtualMachineScaleSetExtensionResourceId = VirtualMachineScaleSetExtensionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, vmssExtensionName); VirtualMachineScaleSetExtensionResource virtualMachineScaleSetExtension = client.GetVirtualMachineScaleSetExtensionResource(virtualMachineScaleSetExtensionResourceId); // invoke the operation - VirtualMachineScaleSetExtensionResource result = await virtualMachineScaleSetExtension.GetAsync(); + VirtualMachineScaleSetExtensionPatch patch = new VirtualMachineScaleSetExtensionPatch(); + ArmOperation lro = await virtualMachineScaleSetExtension.UpdateAsync(WaitUntil.Completed, patch); + VirtualMachineScaleSetExtensionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetResource.cs index a3492acccf0f0..9eb4f66d8831c 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetResource.cs @@ -6,13 +6,11 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Compute.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using NUnit.Framework; @@ -22,32 +20,149 @@ public partial class Sample_VirtualMachineScaleSetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetVirtualMachineScaleSetsByLocation_ListsAllTheVMScaleSetsUnderTheSpecifiedSubscriptionForTheSpecifiedLocation() + public async Task Get_GetVMScaleSetVMWithDiskControllerType() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_ListBySubscription_ByLocation.json - // this example is just showing the usage of "VirtualMachineScaleSets_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithDiskControllerType.json + // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this VirtualMachineScaleSetResource created on azure + // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "myResourceGroup"; + string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; + ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); + VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); - // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("eastus"); - await foreach (VirtualMachineScaleSetResource item in subscriptionResource.GetVirtualMachineScaleSetsByLocationAsync(location)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; + VirtualMachineScaleSetResource result = await virtualMachineScaleSet.GetAsync(expand: expand); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAVirtualMachineScaleSet() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get.json + // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineScaleSetResource created on azure + // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "myResourceGroup"; + string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; + ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); + VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); + + // invoke the operation + VirtualMachineScaleSetResource result = await virtualMachineScaleSet.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGroupThroughAutomaticPlacement() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_AutoPlacedOnDedicatedHostGroup.json + // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineScaleSetResource created on azure + // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "myResourceGroup"; + string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; + ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); + VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); + + // invoke the operation + VirtualMachineScaleSetResource result = await virtualMachineScaleSet.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAVirtualMachineScaleSetWithUserData() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithUserData.json + // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineScaleSetResource created on azure + // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "myResourceGroup"; + string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; + ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); + VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); + + // invoke the operation + VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; + VirtualMachineScaleSetResource result = await virtualMachineScaleSet.GetAsync(expand: expand); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ForceDeleteAVMScaleSet() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Delete_Force.json + // this example is just showing the usage of "VirtualMachineScaleSets_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineScaleSetResource created on azure + // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "myResourceGroup"; + string virtualMachineScaleSetName = "myvmScaleSet"; + ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); + VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); + + // invoke the operation + bool? forceDeletion = true; + await virtualMachineScaleSet.DeleteAsync(WaitUntil.Completed, forceDeletion: forceDeletion); Console.WriteLine("Succeeded"); } @@ -73,15 +188,15 @@ public async Task Update_VirtualMachineScaleSetUpdateMaximumSetGen() VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetPatch patch = new VirtualMachineScaleSetPatch() + VirtualMachineScaleSetPatch patch = new VirtualMachineScaleSetPatch { - Sku = new ComputeSku() + Sku = new ComputeSku { Name = "DSv3-Type1", Tier = "aaa", Capacity = 7L, }, - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "windows2016", Publisher = "microsoft-ads", @@ -92,17 +207,14 @@ public async Task Update_VirtualMachineScaleSetUpdateMaximumSetGen() { UserAssignedIdentities = { -[new ResourceIdentifier("key3951")] = new UserAssignedIdentity(), +[new ResourceIdentifier("key3951")] = new UserAssignedIdentity() }, }, - Zones = -{ -"1","2","3" -}, - UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy() + Zones = { "1", "2", "3" }, + UpgradePolicy = new VirtualMachineScaleSetUpgradePolicy { Mode = VirtualMachineScaleSetUpgradeMode.Manual, - RollingUpgradePolicy = new RollingUpgradePolicy() + RollingUpgradePolicy = new RollingUpgradePolicy { MaxBatchInstancePercent = 49, MaxUnhealthyInstancePercent = 81, @@ -113,94 +225,79 @@ public async Task Update_VirtualMachineScaleSetUpdateMaximumSetGen() RollbackFailedInstancesOnPolicyBreach = true, IsMaxSurgeEnabled = true, }, - AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy() + AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy { EnableAutomaticOSUpgrade = true, DisableAutomaticRollback = true, OSRollingUpgradeDeferral = true, }, }, - AutomaticRepairsPolicy = new AutomaticRepairsPolicy() + AutomaticRepairsPolicy = new AutomaticRepairsPolicy { Enabled = true, GracePeriod = "PT30M", }, - VirtualMachineProfile = new VirtualMachineScaleSetUpdateVmProfile() + VirtualMachineProfile = new VirtualMachineScaleSetUpdateVmProfile { - OSProfile = new VirtualMachineScaleSetUpdateOSProfile() + OSProfile = new VirtualMachineScaleSetUpdateOSProfile { CustomData = "aaaaaaaaaaaaaaaaaaaaaaaaaa", - WindowsConfiguration = new WindowsConfiguration() + WindowsConfiguration = new WindowsConfiguration { ProvisionVmAgent = true, IsAutomaticUpdatesEnabled = true, TimeZone = "aaaaaaaaaaaaaaaa", - AdditionalUnattendContent = -{ -new AdditionalUnattendContent() + AdditionalUnattendContent = {new AdditionalUnattendContent { PassName = PassName.OobeSystem, ComponentName = ComponentName.MicrosoftWindowsShellSetup, SettingName = SettingName.AutoLogon, Content = "aaaaaaaaaaaaaaaaaaaa", -} -}, - PatchSettings = new PatchSettings() +}}, + PatchSettings = new PatchSettings { PatchMode = WindowsVmGuestPatchMode.AutomaticByPlatform, EnableHotpatching = true, AssessmentMode = WindowsPatchAssessmentMode.ImageDefault, - AutomaticByPlatformSettings = new WindowsVmGuestPatchAutomaticByPlatformSettings() + AutomaticByPlatformSettings = new WindowsVmGuestPatchAutomaticByPlatformSettings { RebootSetting = WindowsVmGuestPatchAutomaticByPlatformRebootSetting.Never, }, }, - WinRMListeners = -{ -new WinRMListener() + WinRMListeners = {new WinRMListener { Protocol = WinRMListenerProtocolType.Http, CertificateUri = new Uri("aaaaaaaaaaaaaaaaaaaaaa"), -} -}, +}}, }, - LinuxConfiguration = new LinuxConfiguration() + LinuxConfiguration = new LinuxConfiguration { IsPasswordAuthenticationDisabled = true, - SshPublicKeys = -{ -new SshPublicKeyConfiguration() + SshPublicKeys = {new SshPublicKeyConfiguration { Path = "/home/{your-username}/.ssh/authorized_keys", KeyData = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCeClRAk2ipUs/l5voIsDC5q9RI+YSRd1Bvd/O+axgY4WiBzG+4FwJWZm/mLLe5DoOdHQwmU2FrKXZSW4w2sYE70KeWnrFViCOX5MTVvJgPE8ClugNl8RWth/tU849DvM9sT7vFgfVSHcAS2yDRyDlueii+8nF2ym8XWAPltFVCyLHRsyBp5YPqK8JFYIa1eybKsY3hEAxRCA+/7bq8et+Gj3coOsuRmrehav7rE6N12Pb80I6ofa6SM5XNYq4Xk0iYNx7R3kdz0Jj9XgZYWjAHjJmT0gTRoOnt6upOuxK7xI/ykWrllgpXrCPu3Ymz+c+ujaqcxDopnAl2lmf69/J1", -} -}, +}}, ProvisionVmAgent = true, - PatchSettings = new LinuxPatchSettings() + PatchSettings = new LinuxPatchSettings { PatchMode = LinuxVmGuestPatchMode.ImageDefault, AssessmentMode = LinuxPatchAssessmentMode.ImageDefault, }, }, - Secrets = -{ -new VaultSecretGroup() + Secrets = {new VaultSecretGroup { SourceVaultId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -VaultCertificates = -{ -new VaultCertificate() +VaultCertificates = {new VaultCertificate { CertificateUri = new Uri("aaaaaaa"), CertificateStore = "aaaaaaaaaaaaaaaaaaaaaaaaa", -} -}, -} -}, +}}, +}}, }, - StorageProfile = new VirtualMachineScaleSetUpdateStorageProfile() + StorageProfile = new VirtualMachineScaleSetUpdateStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -209,68 +306,56 @@ public async Task Update_VirtualMachineScaleSetUpdateMaximumSetGen() SharedGalleryImageUniqueId = "aaaaaa", Id = new ResourceIdentifier("aaaaaaaaaaaaaaaaaaa"), }, - OSDisk = new VirtualMachineScaleSetUpdateOSDisk() + OSDisk = new VirtualMachineScaleSetUpdateOSDisk { Caching = CachingType.ReadWrite, WriteAcceleratorEnabled = true, - DiffDiskSettings = new DiffDiskSettings() + DiffDiskSettings = new DiffDiskSettings { Option = DiffDiskOption.Local, Placement = DiffDiskPlacement.CacheDisk, }, DiskSizeGB = 6, ImageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk.vhd"), - VhdContainers = -{ -"aa" -}, - ManagedDisk = new VirtualMachineScaleSetManagedDisk() + VhdContainers = { "aa" }, + ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("aaaaaaaaaaaa"), }, }, - DataDisks = -{ -new VirtualMachineScaleSetDataDisk(26,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineScaleSetDataDisk(26, DiskCreateOptionType.Empty) { Name = "aaaaaaaaaaaaaaaaaaaaaaaaaa", Caching = CachingType.None, WriteAcceleratorEnabled = true, DiskSizeGB = 1023, -ManagedDisk = new VirtualMachineScaleSetManagedDisk() +ManagedDisk = new VirtualMachineScaleSetManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("aaaaaaaaaaaa"), }, DiskIopsReadWrite = 28L, DiskMBpsReadWrite = 15L, -} -}, +}}, }, - NetworkProfile = new VirtualMachineScaleSetUpdateNetworkProfile() + NetworkProfile = new VirtualMachineScaleSetUpdateNetworkProfile { HealthProbeId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/disk123"), - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetUpdateNetworkConfiguration() + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetUpdateNetworkConfiguration { Name = "aaaaaaaa", Primary = true, EnableAcceleratedNetworking = true, EnableFpga = true, NetworkSecurityGroupId = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"), -DnsServers = -{ -}, -IPConfigurations = -{ -new VirtualMachineScaleSetUpdateIPConfiguration() +DnsServers = {}, +IPConfigurations = {new VirtualMachineScaleSetUpdateIPConfiguration { Name = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa", SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/disk123"), Primary = true, -PublicIPAddressConfiguration = new VirtualMachineScaleSetUpdatePublicIPAddressConfiguration() +PublicIPAddressConfiguration = new VirtualMachineScaleSetUpdatePublicIPAddressConfiguration { Name = "a", IdleTimeoutInMinutes = 3, @@ -278,45 +363,31 @@ public async Task Update_VirtualMachineScaleSetUpdateMaximumSetGen() DeleteOption = ComputeDeleteOption.Delete, }, PrivateIPAddressVersion = IPVersion.IPv4, -ApplicationGatewayBackendAddressPools = -{ -new WritableSubResource() +ApplicationGatewayBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"), -} -}, -ApplicationSecurityGroups = -{ -new WritableSubResource() +}}, +ApplicationSecurityGroups = {new WritableSubResource { Id = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"), -} -}, -LoadBalancerBackendAddressPools = -{ -new WritableSubResource() +}}, +LoadBalancerBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"), -} -}, -LoadBalancerInboundNatPools = -{ -new WritableSubResource() +}}, +LoadBalancerInboundNatPools = {new WritableSubResource { Id = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"), -} -}, -} -}, +}}, +}}, EnableIPForwarding = true, DeleteOption = ComputeDeleteOption.Delete, -} -}, +}}, NetworkApiVersion = NetworkApiVersion.TwoThousandTwenty1101, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - UefiSettings = new UefiSettings() + UefiSettings = new UefiSettings { IsSecureBootEnabled = true, IsVirtualTpmEnabled = true, @@ -324,16 +395,14 @@ public async Task Update_VirtualMachineScaleSetUpdateMaximumSetGen() EncryptionAtHost = true, SecurityType = SecurityType.TrustedLaunch, }, - BootDiagnostics = new BootDiagnostics() + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("http://{existing-storage-account-name}.blob.core.windows.net"), }, - ExtensionProfile = new VirtualMachineScaleSetExtensionProfile() + ExtensionProfile = new VirtualMachineScaleSetExtensionProfile { - Extensions = -{ -new VirtualMachineScaleSetExtensionData() + Extensions = {new VirtualMachineScaleSetExtensionData { ForceUpdateTag = "aaaaaaaaa", Publisher = "{extension-Publisher}", @@ -341,26 +410,18 @@ public async Task Update_VirtualMachineScaleSetUpdateMaximumSetGen() TypeHandlerVersion = "{handler-version}", AutoUpgradeMinorVersion = true, EnableAutomaticUpgrade = true, -Settings = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), -ProtectedSettings = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), -ProvisionAfterExtensions = -{ -"aa" -}, +Settings = BinaryData.FromObjectAsJson(new object()), +ProtectedSettings = BinaryData.FromObjectAsJson(new object()), +ProvisionAfterExtensions = {"aa"}, SuppressFailures = true, -} -}, +}}, ExtensionsTimeBudget = "PT1H20M", }, LicenseType = "aaaaaaaaaaaa", BillingMaxPrice = -1, - ScheduledEventsProfile = new ComputeScheduledEventsProfile() + ScheduledEventsProfile = new ComputeScheduledEventsProfile { - TerminateNotificationProfile = new TerminateNotificationProfile() + TerminateNotificationProfile = new TerminateNotificationProfile { NotBeforeTimeout = "PT10M", Enable = true, @@ -371,23 +432,20 @@ public async Task Update_VirtualMachineScaleSetUpdateMaximumSetGen() Overprovision = true, DoNotRunExtensionsOnOverprovisionedVms = true, SinglePlacementGroup = true, - AdditionalCapabilities = new AdditionalCapabilities() + AdditionalCapabilities = new AdditionalCapabilities { UltraSsdEnabled = true, HibernationEnabled = true, }, - ScaleInPolicy = new ScaleInPolicy() + ScaleInPolicy = new ScaleInPolicy { - Rules = -{ -VirtualMachineScaleSetScaleInRule.OldestVm -}, + Rules = { VirtualMachineScaleSetScaleInRule.OldestVm }, ForceDeletion = true, }, ProximityPlacementGroupId = new ResourceIdentifier("subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/snapshots/mySnapshot"), Tags = { -["key246"] = "aaaaaaaaaaaaaaaaaaaaaaaa", +["key246"] = "aaaaaaaaaaaaaaaaaaaaaaaa" }, }; ArmOperation lro = await virtualMachineScaleSet.UpdateAsync(WaitUntil.Completed, patch); @@ -432,155 +490,6 @@ public async Task Update_VirtualMachineScaleSetUpdateMinimumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ForceDeleteAVMScaleSet() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Delete_Force.json - // this example is just showing the usage of "VirtualMachineScaleSets_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineScaleSetResource created on azure - // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string virtualMachineScaleSetName = "myvmScaleSet"; - ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); - VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); - - // invoke the operation - bool? forceDeletion = true; - await virtualMachineScaleSet.DeleteAsync(WaitUntil.Completed, forceDeletion: forceDeletion); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetVMScaleSetVMWithDiskControllerType() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithDiskControllerType.json - // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineScaleSetResource created on azure - // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); - VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); - - // invoke the operation - VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; - VirtualMachineScaleSetResource result = await virtualMachineScaleSet.GetAsync(expand: expand); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachineScaleSet() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get.json - // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineScaleSetResource created on azure - // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); - VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); - - // invoke the operation - VirtualMachineScaleSetResource result = await virtualMachineScaleSet.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachineScaleSetPlacedOnADedicatedHostGroupThroughAutomaticPlacement() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_AutoPlacedOnDedicatedHostGroup.json - // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineScaleSetResource created on azure - // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); - VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); - - // invoke the operation - VirtualMachineScaleSetResource result = await virtualMachineScaleSet.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualMachineScaleSetWithUserData() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_Get_WithUserData.json - // this example is just showing the usage of "VirtualMachineScaleSets_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineScaleSetResource created on azure - // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string virtualMachineScaleSetName = "myVirtualMachineScaleSet"; - ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); - VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); - - // invoke the operation - VirtualMachineScaleSetGetExpand? expand = VirtualMachineScaleSetGetExpand.UserData; - VirtualMachineScaleSetResource result = await virtualMachineScaleSet.GetAsync(expand: expand); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Deallocate_VirtualMachineScaleSetDeallocateMaximumSetGen() @@ -602,12 +511,9 @@ public async Task Deallocate_VirtualMachineScaleSetDeallocateMaximumSetGen() VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds() + VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds { - InstanceIds = -{ -"aaaaaaaaaaaaaaaaa" -}, + InstanceIds = { "aaaaaaaaaaaaaaaaa" }, }; bool? hibernate = true; await virtualMachineScaleSet.DeallocateAsync(WaitUntil.Completed, vmInstanceIds: vmInstanceIds, hibernate: hibernate); @@ -662,10 +568,7 @@ public async Task DeleteInstances_VirtualMachineScaleSetDeleteInstancesMaximumSe VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceRequiredIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceRequiredIds(new string[] - { -"aaaaaaaaaaaaaaaaaaaaaaaaa" - }); + VirtualMachineScaleSetVmInstanceRequiredIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceRequiredIds(new string[] { "aaaaaaaaaaaaaaaaaaaaaaaaa" }); bool? forceDeletion = true; await virtualMachineScaleSet.DeleteInstancesAsync(WaitUntil.Completed, vmInstanceIds, forceDeletion: forceDeletion); @@ -693,10 +596,7 @@ public async Task DeleteInstances_VirtualMachineScaleSetDeleteInstancesMinimumSe VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceRequiredIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceRequiredIds(new string[] - { -"aaaaaaaaaaaaaaaaaaaaaaaaa" - }); + VirtualMachineScaleSetVmInstanceRequiredIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceRequiredIds(new string[] { "aaaaaaaaaaaaaaaaaaaaaaaaa" }); await virtualMachineScaleSet.DeleteInstancesAsync(WaitUntil.Completed, vmInstanceIds); Console.WriteLine("Succeeded"); @@ -754,68 +654,6 @@ public async Task GetInstanceView_VirtualMachineScaleSetGetInstanceViewMinimumSe Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVirtualMachineScaleSets_VirtualMachineScaleSetListAllMaximumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_ListAll_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSets_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VirtualMachineScaleSetResource item in subscriptionResource.GetVirtualMachineScaleSetsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVirtualMachineScaleSets_VirtualMachineScaleSetListAllMinimumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSet_ListAll_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSets_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VirtualMachineScaleSetResource item in subscriptionResource.GetVirtualMachineScaleSetsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSkus_VirtualMachineScaleSetListSkusMaximumSetGen() @@ -953,12 +791,9 @@ public async Task PowerOff_VirtualMachineScaleSetPowerOffMaximumSetGen() VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds() + VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds { - InstanceIds = -{ -"aaaaaaaaaaaaaaaaa" -}, + InstanceIds = { "aaaaaaaaaaaaaaaaa" }, }; bool? skipShutdown = true; await virtualMachineScaleSet.PowerOffAsync(WaitUntil.Completed, vmInstanceIds: vmInstanceIds, skipShutdown: skipShutdown); @@ -1013,12 +848,9 @@ public async Task Restart_VirtualMachineScaleSetRestartMaximumSetGen() VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds() + VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds { - InstanceIds = -{ -"aaaaaaaaaaaaaaaaa" -}, + InstanceIds = { "aaaaaaaaaaaaaaaaa" }, }; await virtualMachineScaleSet.RestartAsync(WaitUntil.Completed, vmInstanceIds: vmInstanceIds); @@ -1072,12 +904,9 @@ public async Task PowerOn_VirtualMachineScaleSetStartMaximumSetGen() VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds() + VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds { - InstanceIds = -{ -"aaaaaaaaaaaaaaaaa" -}, + InstanceIds = { "aaaaaaaaaaaaaaaaa" }, }; await virtualMachineScaleSet.PowerOnAsync(WaitUntil.Completed, vmInstanceIds: vmInstanceIds); @@ -1183,12 +1012,9 @@ public async Task Redeploy_VirtualMachineScaleSetRedeployMaximumSetGen() VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds() + VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds { - InstanceIds = -{ -"aaaaaaaaaaaaaaaaa" -}, + InstanceIds = { "aaaaaaaaaaaaaaaaa" }, }; await virtualMachineScaleSet.RedeployAsync(WaitUntil.Completed, vmInstanceIds: vmInstanceIds); @@ -1242,12 +1068,9 @@ public async Task PerformMaintenance_VirtualMachineScaleSetPerformMaintenanceMax VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds() + VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds { - InstanceIds = -{ -"aaaaaaaaaaaaaaaaa" -}, + InstanceIds = { "aaaaaaaaaaaaaaaaa" }, }; await virtualMachineScaleSet.PerformMaintenanceAsync(WaitUntil.Completed, vmInstanceIds: vmInstanceIds); @@ -1301,10 +1124,7 @@ public async Task UpdateInstances_VirtualMachineScaleSetUpdateInstancesMaximumSe VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceRequiredIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceRequiredIds(new string[] - { -"aaaaaaaaaaaaaaaaaaaaaaaaa" - }); + VirtualMachineScaleSetVmInstanceRequiredIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceRequiredIds(new string[] { "aaaaaaaaaaaaaaaaaaaaaaaaa" }); await virtualMachineScaleSet.UpdateInstancesAsync(WaitUntil.Completed, vmInstanceIds); Console.WriteLine("Succeeded"); @@ -1331,10 +1151,7 @@ public async Task UpdateInstances_VirtualMachineScaleSetUpdateInstancesMinimumSe VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceRequiredIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceRequiredIds(new string[] - { -"aaaaaaaaaaaaaaaaaaaaaaaaa" - }); + VirtualMachineScaleSetVmInstanceRequiredIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceRequiredIds(new string[] { "aaaaaaaaaaaaaaaaaaaaaaaaa" }); await virtualMachineScaleSet.UpdateInstancesAsync(WaitUntil.Completed, vmInstanceIds); Console.WriteLine("Succeeded"); @@ -1361,12 +1178,9 @@ public async Task Reimage_VirtualMachineScaleSetReimageMaximumSetGen() VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetReimageContent content = new VirtualMachineScaleSetReimageContent() + VirtualMachineScaleSetReimageContent content = new VirtualMachineScaleSetReimageContent { - InstanceIds = -{ -"aaaaaaaaaa" -}, + InstanceIds = { "aaaaaaaaaa" }, ForceUpdateOSDiskForEphemeral = true, TempDisk = true, }; @@ -1422,12 +1236,9 @@ public async Task ReimageAll_VirtualMachineScaleSetReimageAllMaximumSetGen() VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds() + VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds { - InstanceIds = -{ -"aaaaaaaaaaaaaaaaa" -}, + InstanceIds = { "aaaaaaaaaaaaaaaaa" }, }; await virtualMachineScaleSet.ReimageAllAsync(WaitUntil.Completed, vmInstanceIds: vmInstanceIds); @@ -1481,12 +1292,9 @@ public async Task ApproveRollingUpgrade_VirtualMachineScaleSetApproveRollingUpgr VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds() + VirtualMachineScaleSetVmInstanceIds vmInstanceIds = new VirtualMachineScaleSetVmInstanceIds { - InstanceIds = -{ -"0","1","2" -}, + InstanceIds = { "0", "1", "2" }, }; await virtualMachineScaleSet.ApproveRollingUpgradeAsync(WaitUntil.Completed, vmInstanceIds: vmInstanceIds); @@ -1568,7 +1376,7 @@ public async Task ConvertToSinglePlacementGroup_VirtualMachineScaleSetConvertToS VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // invoke the operation - VirtualMachineScaleSetConvertToSinglePlacementGroupContent content = new VirtualMachineScaleSetConvertToSinglePlacementGroupContent() + VirtualMachineScaleSetConvertToSinglePlacementGroupContent content = new VirtualMachineScaleSetConvertToSinglePlacementGroupContent { ActivePlacementGroupId = "aaaaaaaaaaaaaaaaaaaaaaaaaaa", }; diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmCollection.cs index 8acdc9387e849..8e9ec101e6aa6 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmCollection.cs @@ -44,25 +44,25 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetVMUpdateMaximumSetGen() string instanceId = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; VirtualMachineScaleSetVmData data = new VirtualMachineScaleSetVmData(new AzureLocation("westus")) { - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "aaaaaaaaaa", Publisher = "aaaaaaaaaaaaaaaaaaaaaa", Product = "aaaaaaaaaaaaaaaaaaaa", PromotionCode = "aaaaaaaaaaaaaaaaaaaa", }, - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.BasicA0, - VmSizeProperties = new VirtualMachineSizeProperties() + VmSizeProperties = new VirtualMachineSizeProperties { VCpusAvailable = 9, VCpusPerCore = 12, }, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -74,13 +74,13 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetVMUpdateMaximumSetGen() OSDisk = new VirtualMachineOSDisk(DiskCreateOptionType.FromImage) { OSType = SupportedOperatingSystemType.Windows, - EncryptionSettings = new DiskEncryptionSettings() + EncryptionSettings = new DiskEncryptionSettings { - DiskEncryptionKey = new KeyVaultSecretReference(new Uri("aaaaaaaa"), new WritableSubResource() + DiskEncryptionKey = new KeyVaultSecretReference(new Uri("aaaaaaaa"), new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), }), - KeyEncryptionKey = new KeyVaultKeyReference(new Uri("aaaaaaaaaaaaaa"), new WritableSubResource() + KeyEncryptionKey = new KeyVaultKeyReference(new Uri("aaaaaaaaaaaaaa"), new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), }), @@ -91,13 +91,13 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetVMUpdateMaximumSetGen() ImageUri = new Uri("https://{storageAccountName}.blob.core.windows.net/{containerName}/{vhdName}.vhd"), Caching = CachingType.None, WriteAcceleratorEnabled = true, - DiffDiskSettings = new DiffDiskSettings() + DiffDiskSettings = new DiffDiskSettings { Option = DiffDiskOption.Local, Placement = DiffDiskPlacement.CacheDisk, }, DiskSizeGB = 127, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("aaaaaaaaaaaa"), @@ -105,9 +105,7 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetVMUpdateMaximumSetGen() }, DeleteOption = DiskDeleteOptionType.Delete, }, - DataDisks = -{ -new VirtualMachineDataDisk(1,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineDataDisk(1, DiskCreateOptionType.Empty) { Name = "vmss3176_vmss3176_0_disk2_6c4f554bdafa49baa780eb2d128ff39d", VhdUri = new Uri("https://{storageAccountName}.blob.core.windows.net/{containerName}/{vhdName}.vhd"), @@ -115,7 +113,7 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetVMUpdateMaximumSetGen() Caching = CachingType.None, WriteAcceleratorEnabled = true, DiskSizeGB = 128, -ManagedDisk = new VirtualMachineManagedDisk() +ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("aaaaaaaaaaaa"), @@ -124,77 +122,65 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetVMUpdateMaximumSetGen() ToBeDetached = true, DetachOption = DiskDetachOptionType.ForceDetach, DeleteOption = DiskDeleteOptionType.Delete, -} -}, +}}, }, - AdditionalCapabilities = new AdditionalCapabilities() + AdditionalCapabilities = new AdditionalCapabilities { UltraSsdEnabled = true, HibernationEnabled = true, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "test000000", AdminUsername = "Foo12", AdminPassword = "aaaaaaaaaaaaaaaa", CustomData = "aaaa", - WindowsConfiguration = new WindowsConfiguration() + WindowsConfiguration = new WindowsConfiguration { ProvisionVmAgent = true, IsAutomaticUpdatesEnabled = true, TimeZone = "aaaaaaaaaaaaaaaaaaaaaaaaaaa", - AdditionalUnattendContent = -{ -new AdditionalUnattendContent() + AdditionalUnattendContent = {new AdditionalUnattendContent { PassName = PassName.OobeSystem, ComponentName = ComponentName.MicrosoftWindowsShellSetup, SettingName = SettingName.AutoLogon, Content = "aaaaaaaaaaaaaaaaaaaa", -} -}, - PatchSettings = new PatchSettings() +}}, + PatchSettings = new PatchSettings { PatchMode = WindowsVmGuestPatchMode.Manual, EnableHotpatching = true, AssessmentMode = WindowsPatchAssessmentMode.ImageDefault, }, - WinRMListeners = -{ -new WinRMListener() + WinRMListeners = {new WinRMListener { Protocol = WinRMListenerProtocolType.Http, CertificateUri = new Uri("aaaaaaaaaaaaaaaaaaaaaa"), -} -}, +}}, }, - LinuxConfiguration = new LinuxConfiguration() + LinuxConfiguration = new LinuxConfiguration { IsPasswordAuthenticationDisabled = true, - SshPublicKeys = -{ -new SshPublicKeyConfiguration() + SshPublicKeys = {new SshPublicKeyConfiguration { Path = "aaa", KeyData = "aaaaaa", -} -}, +}}, ProvisionVmAgent = true, - PatchSettings = new LinuxPatchSettings() + PatchSettings = new LinuxPatchSettings { PatchMode = LinuxVmGuestPatchMode.ImageDefault, AssessmentMode = LinuxPatchAssessmentMode.ImageDefault, }, }, - Secrets = -{ -}, + Secrets = { }, AllowExtensionOperations = true, RequireGuestProvisionSignal = true, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - UefiSettings = new UefiSettings() + UefiSettings = new UefiSettings { IsSecureBootEnabled = true, IsVirtualTpmEnabled = true, @@ -202,21 +188,16 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetVMUpdateMaximumSetGen() EncryptionAtHost = true, SecurityType = SecurityType.TrustedLaunch, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, DeleteOption = ComputeDeleteOption.Delete, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}/virtualMachines/0/networkInterfaces/vmsstestnetconfig5415"), -} -}, +}}, NetworkApiVersion = NetworkApiVersion.TwoThousandTwenty1101, - NetworkInterfaceConfigurations = -{ -new VirtualMachineNetworkInterfaceConfiguration("aaaaaaaaaaa") + NetworkInterfaceConfigurations = {new VirtualMachineNetworkInterfaceConfiguration("aaaaaaaaaaa") { Primary = true, DeleteOption = ComputeDeleteOption.Delete, @@ -224,19 +205,14 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetVMUpdateMaximumSetGen() EnableFpga = true, EnableIPForwarding = true, NetworkSecurityGroupId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -DnsServers = -{ -"aaaaaa" -}, -IPConfigurations = -{ -new VirtualMachineNetworkInterfaceIPConfiguration("aa") +DnsServers = {"aaaaaa"}, +IPConfigurations = {new VirtualMachineNetworkInterfaceIPConfiguration("aa") { SubnetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), Primary = true, PublicIPAddressConfiguration = new VirtualMachinePublicIPAddressConfiguration("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa") { -Sku = new ComputePublicIPAddressSku() +Sku = new ComputePublicIPAddressSku { Name = ComputePublicIPAddressSkuName.Basic, Tier = ComputePublicIPAddressSkuTier.Regional, @@ -244,135 +220,96 @@ public async Task CreateOrUpdate_VirtualMachineScaleSetVMUpdateMaximumSetGen() IdleTimeoutInMinutes = 2, DeleteOption = ComputeDeleteOption.Delete, DnsSettings = new VirtualMachinePublicIPAddressDnsSettingsConfiguration("aaaaaaaaaaaaaaaaaaaaaaaaa"), -IPTags = -{ -new VirtualMachineIPTag() +IPTags = {new VirtualMachineIPTag { IPTagType = "aaaaaaaaaaaaaaaaaaaaaaaaa", Tag = "aaaaaaaaaaaaaaaaaaaa", -} -}, +}}, PublicIPPrefixId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), PublicIPAddressVersion = IPVersion.IPv4, PublicIPAllocationMethod = PublicIPAllocationMethod.Dynamic, }, PrivateIPAddressVersion = IPVersion.IPv4, -ApplicationSecurityGroups = -{ -new WritableSubResource() +ApplicationSecurityGroups = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -ApplicationGatewayBackendAddressPools = -{ -new WritableSubResource() +}}, +ApplicationGatewayBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -LoadBalancerBackendAddressPools = -{ -new WritableSubResource() +}}, +LoadBalancerBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -} -}, +}}, +}}, DscpConfigurationId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, +}}, }, - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("vmsstestnetconfig5415") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("vmsstestnetconfig5415") { Primary = true, EnableAcceleratedNetworking = true, EnableFpga = true, NetworkSecurityGroupId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -DnsServers = -{ -}, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("vmsstestnetconfig9693") +DnsServers = {}, +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("vmsstestnetconfig9693") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/vn4071/subnets/sn5503"), Primary = true, PublicIPAddressConfiguration = new VirtualMachineScaleSetPublicIPAddressConfiguration("aaaaaaaaaaaaaaaaaa") { -Sku = new ComputePublicIPAddressSku() +Sku = new ComputePublicIPAddressSku { Name = ComputePublicIPAddressSkuName.Basic, Tier = ComputePublicIPAddressSkuTier.Regional, }, IdleTimeoutInMinutes = 18, DnsSettings = new VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings("aaaaaaaaaaaaaaaaaa"), -IPTags = -{ -new VirtualMachineScaleSetIPTag() +IPTags = {new VirtualMachineScaleSetIPTag { IPTagType = "aaaaaaa", Tag = "aaaaaaaaaaaaaaaaaaaaaaaaaaa", -} -}, +}}, PublicIPPrefixId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), PublicIPAddressVersion = IPVersion.IPv4, DeleteOption = ComputeDeleteOption.Delete, }, PrivateIPAddressVersion = IPVersion.IPv4, -ApplicationGatewayBackendAddressPools = -{ -new WritableSubResource() +ApplicationGatewayBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -ApplicationSecurityGroups = -{ -new WritableSubResource() +}}, +ApplicationSecurityGroups = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -LoadBalancerBackendAddressPools = -{ -new WritableSubResource() +}}, +LoadBalancerBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -LoadBalancerInboundNatPools = -{ -new WritableSubResource() +}}, +LoadBalancerInboundNatPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -} -}, +}}, +}}, EnableIPForwarding = true, DeleteOption = ComputeDeleteOption.Delete, -} -}, - BootDiagnostics = new BootDiagnostics() +}}, + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("aaaaaaaaaaaaa"), }, AvailabilitySetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), LicenseType = "aaaaaaaaaa", - ProtectionPolicy = new VirtualMachineScaleSetVmProtectionPolicy() + ProtectionPolicy = new VirtualMachineScaleSetVmProtectionPolicy { ProtectFromScaleIn = true, ProtectFromScaleSetActions = true, }, UserData = "RXhhbXBsZSBVc2VyRGF0YQ==", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, instanceId, data); VirtualMachineScaleSetVmResource result = lro.Value; @@ -456,9 +393,9 @@ public async Task Get_GetVMScaleSetVMWithUserData() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVMScaleSetVMWithUserData() + public async Task Get_GetVMScaleSetVMWithVMSizeProperties() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithUserData.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithVMSizeProperties.json // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -479,17 +416,21 @@ public async Task Exists_GetVMScaleSetVMWithUserData() // invoke the operation string instanceId = "0"; - bool result = await collection.ExistsAsync(instanceId); + VirtualMachineScaleSetVmResource result = await collection.GetAsync(instanceId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVMScaleSetVMWithUserData() + public async Task GetAll_VirtualMachineScaleSetVMListMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithUserData.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_List_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -499,39 +440,36 @@ public async Task GetIfExists_GetVMScaleSetVMWithUserData() // this example assumes you already have this VirtualMachineScaleSetResource created on azure // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string virtualMachineScaleSetName = "{vmss-name}"; + string resourceGroupName = "rgcompute"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // get the collection of this VirtualMachineScaleSetVmResource VirtualMachineScaleSetVmCollection collection = virtualMachineScaleSet.GetVirtualMachineScaleSetVms(); - // invoke the operation - string instanceId = "0"; - NullableResponse response = await collection.GetIfExistsAsync(instanceId); - VirtualMachineScaleSetVmResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string filter = "aaaaaaaaaaaaaa"; + string select = "aaaaaaaaaaaaaaaaaaaaa"; + string expand = "aaaaaaaaaaaaa"; + await foreach (VirtualMachineScaleSetVmResource item in collection.GetAllAsync(filter: filter, select: select, expand: expand)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetVmData resourceData = result.Data; + VirtualMachineScaleSetVmData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVMScaleSetVMWithVMSizeProperties() + public async Task GetAll_VirtualMachineScaleSetVMListMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithVMSizeProperties.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_List_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -541,30 +479,32 @@ public async Task Get_GetVMScaleSetVMWithVMSizeProperties() // this example assumes you already have this VirtualMachineScaleSetResource created on azure // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string virtualMachineScaleSetName = "{vmss-name}"; + string resourceGroupName = "rgcompute"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // get the collection of this VirtualMachineScaleSetVmResource VirtualMachineScaleSetVmCollection collection = virtualMachineScaleSet.GetVirtualMachineScaleSetVms(); - // invoke the operation - string instanceId = "0"; - VirtualMachineScaleSetVmResource result = await collection.GetAsync(instanceId); + // invoke the operation and iterate over the result + await foreach (VirtualMachineScaleSetVmResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetVmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVMScaleSetVMWithVMSizeProperties() + public async Task Exists_GetVMScaleSetVMWithUserData() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithVMSizeProperties.json + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithUserData.json // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -592,7 +532,7 @@ public async Task Exists_GetVMScaleSetVMWithVMSizeProperties() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVMScaleSetVMWithVMSizeProperties() + public async Task Exists_GetVMScaleSetVMWithVMSizeProperties() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithVMSizeProperties.json // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. @@ -615,29 +555,17 @@ public async Task GetIfExists_GetVMScaleSetVMWithVMSizeProperties() // invoke the operation string instanceId = "0"; - NullableResponse response = await collection.GetIfExistsAsync(instanceId); - VirtualMachineScaleSetVmResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(instanceId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineScaleSetVMListMaximumSetGen() + public async Task GetIfExists_GetVMScaleSetVMWithUserData() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_List_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithUserData.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -647,36 +575,39 @@ public async Task GetAll_VirtualMachineScaleSetVMListMaximumSetGen() // this example assumes you already have this VirtualMachineScaleSetResource created on azure // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaa"; + string resourceGroupName = "myResourceGroup"; + string virtualMachineScaleSetName = "{vmss-name}"; ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // get the collection of this VirtualMachineScaleSetVmResource VirtualMachineScaleSetVmCollection collection = virtualMachineScaleSet.GetVirtualMachineScaleSetVms(); - // invoke the operation and iterate over the result - string filter = "aaaaaaaaaaaaaa"; - string select = "aaaaaaaaaaaaaaaaaaaaa"; - string expand = "aaaaaaaaaaaaa"; - await foreach (VirtualMachineScaleSetVmResource item in collection.GetAllAsync(filter: filter, select: select, expand: expand)) + // invoke the operation + string instanceId = "0"; + NullableResponse response = await collection.GetIfExistsAsync(instanceId); + VirtualMachineScaleSetVmResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetVmData resourceData = item.Data; + VirtualMachineScaleSetVmData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineScaleSetVMListMinimumSetGen() + public async Task GetIfExists_GetVMScaleSetVMWithVMSizeProperties() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_List_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithVMSizeProperties.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -686,25 +617,31 @@ public async Task GetAll_VirtualMachineScaleSetVMListMinimumSetGen() // this example assumes you already have this VirtualMachineScaleSetResource created on azure // for more information of creating VirtualMachineScaleSetResource, please refer to the document of VirtualMachineScaleSetResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + string resourceGroupName = "myResourceGroup"; + string virtualMachineScaleSetName = "{vmss-name}"; ResourceIdentifier virtualMachineScaleSetResourceId = VirtualMachineScaleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName); VirtualMachineScaleSetResource virtualMachineScaleSet = client.GetVirtualMachineScaleSetResource(virtualMachineScaleSetResourceId); // get the collection of this VirtualMachineScaleSetVmResource VirtualMachineScaleSetVmCollection collection = virtualMachineScaleSet.GetVirtualMachineScaleSetVms(); - // invoke the operation and iterate over the result - await foreach (VirtualMachineScaleSetVmResource item in collection.GetAllAsync()) + // invoke the operation + string instanceId = "0"; + NullableResponse response = await collection.GetIfExistsAsync(instanceId); + VirtualMachineScaleSetVmResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetVmData resourceData = item.Data; + VirtualMachineScaleSetVmData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmExtensionCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmExtensionCollection.cs index b54424f0cde3e..2b335480f421b 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmExtensionCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmExtensionCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -42,15 +41,15 @@ public async Task CreateOrUpdate_CreateVirtualMachineScaleSetVMExtension() // invoke the operation string vmExtensionName = "myVMExtension"; - VirtualMachineScaleSetVmExtensionData data = new VirtualMachineScaleSetVmExtensionData() + VirtualMachineScaleSetVmExtensionData data = new VirtualMachineScaleSetVmExtensionData { Publisher = "extPublisher", ExtensionType = "extType", TypeHandlerVersion = "1.2", AutoUpgradeMinorVersion = true, - Settings = BinaryData.FromObjectAsJson(new Dictionary() + Settings = BinaryData.FromObjectAsJson(new { - ["UserName"] = "xyz@microsoft.com" + UserName = "xyz@microsoft.com", }), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmExtensionName, data); @@ -100,10 +99,10 @@ public async Task Get_GetVirtualMachineScaleSetVMExtension() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualMachineScaleSetVMExtension() + public async Task GetAll_ListExtensionsInVmssInstance() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVMExtension_Get.json - // this example is just showing the usage of "VirtualMachineScaleSetVMExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVMExtension_List.json + // this example is just showing the usage of "VirtualMachineScaleSetVMExtensions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,16 +121,22 @@ public async Task Exists_GetVirtualMachineScaleSetVMExtension() // get the collection of this VirtualMachineScaleSetVmExtensionResource VirtualMachineScaleSetVmExtensionCollection collection = virtualMachineScaleSetVm.GetVirtualMachineScaleSetVmExtensions(); - // invoke the operation - string vmExtensionName = "myVMExtension"; - bool result = await collection.ExistsAsync(vmExtensionName); + // invoke the operation and iterate over the result + await foreach (VirtualMachineScaleSetVmExtensionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetVmExtensionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualMachineScaleSetVMExtension() + public async Task Exists_GetVirtualMachineScaleSetVMExtension() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVMExtension_Get.json // this example is just showing the usage of "VirtualMachineScaleSetVMExtensions_Get" operation, for the dependent resources, they will have to be created separately. @@ -155,29 +160,17 @@ public async Task GetIfExists_GetVirtualMachineScaleSetVMExtension() // invoke the operation string vmExtensionName = "myVMExtension"; - NullableResponse response = await collection.GetIfExistsAsync(vmExtensionName); - VirtualMachineScaleSetVmExtensionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vmExtensionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetVmExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExtensionsInVmssInstance() + public async Task GetIfExists_GetVirtualMachineScaleSetVMExtension() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVMExtension_List.json - // this example is just showing the usage of "VirtualMachineScaleSetVMExtensions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVMExtension_Get.json + // this example is just showing the usage of "VirtualMachineScaleSetVMExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,17 +189,23 @@ public async Task GetAll_ListExtensionsInVmssInstance() // get the collection of this VirtualMachineScaleSetVmExtensionResource VirtualMachineScaleSetVmExtensionCollection collection = virtualMachineScaleSetVm.GetVirtualMachineScaleSetVmExtensions(); - // invoke the operation and iterate over the result - await foreach (VirtualMachineScaleSetVmExtensionResource item in collection.GetAllAsync()) + // invoke the operation + string vmExtensionName = "myVMExtension"; + NullableResponse response = await collection.GetIfExistsAsync(vmExtensionName); + VirtualMachineScaleSetVmExtensionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetVmExtensionData resourceData = item.Data; + VirtualMachineScaleSetVmExtensionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmExtensionResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmExtensionResource.cs index 85a63d93a1f5c..827eb3194d505 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmExtensionResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmExtensionResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_VirtualMachineScaleSetVmExtensionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateVirtualMachineScaleSetVMExtension() + public async Task Get_GetVirtualMachineScaleSetVMExtension() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVMExtension_Update.json - // this example is just showing the usage of "VirtualMachineScaleSetVMExtensions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVMExtension_Get.json + // this example is just showing the usage of "VirtualMachineScaleSetVMExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,19 +39,7 @@ public async Task Update_UpdateVirtualMachineScaleSetVMExtension() VirtualMachineScaleSetVmExtensionResource virtualMachineScaleSetVmExtension = client.GetVirtualMachineScaleSetVmExtensionResource(virtualMachineScaleSetVmExtensionResourceId); // invoke the operation - VirtualMachineScaleSetVmExtensionPatch patch = new VirtualMachineScaleSetVmExtensionPatch() - { - Publisher = "extPublisher", - ExtensionType = "extType", - TypeHandlerVersion = "1.2", - AutoUpgradeMinorVersion = true, - Settings = BinaryData.FromObjectAsJson(new Dictionary() - { - ["UserName"] = "xyz@microsoft.com" - }), - }; - ArmOperation lro = await virtualMachineScaleSetVmExtension.UpdateAsync(WaitUntil.Completed, patch); - VirtualMachineScaleSetVmExtensionResource result = lro.Value; + VirtualMachineScaleSetVmExtensionResource result = await virtualMachineScaleSetVmExtension.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -91,10 +78,10 @@ public async Task Delete_DeleteVirtualMachineScaleSetVMExtension() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualMachineScaleSetVMExtension() + public async Task Update_UpdateVirtualMachineScaleSetVMExtension() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVMExtension_Get.json - // this example is just showing the usage of "VirtualMachineScaleSetVMExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVMExtension_Update.json + // this example is just showing the usage of "VirtualMachineScaleSetVMExtensions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,7 +99,19 @@ public async Task Get_GetVirtualMachineScaleSetVMExtension() VirtualMachineScaleSetVmExtensionResource virtualMachineScaleSetVmExtension = client.GetVirtualMachineScaleSetVmExtensionResource(virtualMachineScaleSetVmExtensionResourceId); // invoke the operation - VirtualMachineScaleSetVmExtensionResource result = await virtualMachineScaleSetVmExtension.GetAsync(); + VirtualMachineScaleSetVmExtensionPatch patch = new VirtualMachineScaleSetVmExtensionPatch + { + Publisher = "extPublisher", + ExtensionType = "extType", + TypeHandlerVersion = "1.2", + AutoUpgradeMinorVersion = true, + Settings = BinaryData.FromObjectAsJson(new + { + UserName = "xyz@microsoft.com", + }), + }; + ArmOperation lro = await virtualMachineScaleSetVmExtension.UpdateAsync(WaitUntil.Completed, patch); + VirtualMachineScaleSetVmExtensionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmResource.cs index cc050d16e441c..b2944336d07d2 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmResource.cs @@ -19,123 +19,10 @@ public partial class Sample_VirtualMachineScaleSetVmResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Reimage_VirtualMachineScaleSetVMReimageMaximumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Reimage_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_Reimage" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure - // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaa"; - string instanceId = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); - VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); - - // invoke the operation - VirtualMachineScaleSetVmReimageContent content = new VirtualMachineScaleSetVmReimageContent() - { - ForceUpdateOSDiskForEphemeral = true, - TempDisk = true, - }; - await virtualMachineScaleSetVm.ReimageAsync(WaitUntil.Completed, content: content); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Reimage_VirtualMachineScaleSetVMReimageMinimumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Reimage_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_Reimage" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure - // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaa"; - string instanceId = "aaaaaaaaaaaaa"; - ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); - VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); - - // invoke the operation - await virtualMachineScaleSetVm.ReimageAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task ReimageAll_VirtualMachineScaleSetVMReimageAllMaximumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_ReimageAll_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_ReimageAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure - // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; - string instanceId = "aaaaaaaaaaaaaaaaaaa"; - ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); - VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); - - // invoke the operation - await virtualMachineScaleSetVm.ReimageAllAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task ReimageAll_VirtualMachineScaleSetVMReimageAllMinimumSetGen() - { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_ReimageAll_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_ReimageAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure - // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaaa"; - string instanceId = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); - VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); - - // invoke the operation - await virtualMachineScaleSetVm.ReimageAllAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task ApproveRollingUpgrade_VirtualMachineScaleSetVMApproveRollingUpgrade() + public async Task Get_GetVMScaleSetVMWithUserData() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_ApproveRollingUpgrade.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_ApproveRollingUpgrade" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithUserData.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,24 +32,28 @@ public async Task ApproveRollingUpgrade_VirtualMachineScaleSetVMApproveRollingUp // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "vmssToApproveRollingUpgradeOn"; - string instanceId = "0123"; + string resourceGroupName = "myResourceGroup"; + string virtualMachineScaleSetName = "{vmss-name}"; + string instanceId = "0"; ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); // invoke the operation - await virtualMachineScaleSetVm.ApproveRollingUpgradeAsync(WaitUntil.Completed); + VirtualMachineScaleSetVmResource result = await virtualMachineScaleSetVm.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Deallocate_VirtualMachineScaleSetVMDeallocateMaximumSetGen() + public async Task Get_GetVMScaleSetVMWithVMSizeProperties() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Deallocate_MaximumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_Deallocate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithVMSizeProperties.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,24 +63,28 @@ public async Task Deallocate_VirtualMachineScaleSetVMDeallocateMaximumSetGen() // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; - string instanceId = "aaaaaaaaaaaaaaaaaaaaaa"; + string resourceGroupName = "myResourceGroup"; + string virtualMachineScaleSetName = "{vmss-name}"; + string instanceId = "0"; ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); // invoke the operation - await virtualMachineScaleSetVm.DeallocateAsync(WaitUntil.Completed); + VirtualMachineScaleSetVmResource result = await virtualMachineScaleSetVm.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineScaleSetVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Deallocate_VirtualMachineScaleSetVMDeallocateMinimumSetGen() + public async Task Delete_ForceDeleteAVirtualMachineFromAVMScaleSet() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Deallocate_MinimumSet_Gen.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_Deallocate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Delete_Force.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,14 +94,15 @@ public async Task Deallocate_VirtualMachineScaleSetVMDeallocateMinimumSetGen() // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "rgcompute"; - string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; - string instanceId = "aaaaaa"; + string resourceGroupName = "myResourceGroup"; + string virtualMachineScaleSetName = "myvmScaleSet"; + string instanceId = "0"; ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); // invoke the operation - await virtualMachineScaleSetVm.DeallocateAsync(WaitUntil.Completed); + bool? forceDeletion = true; + await virtualMachineScaleSetVm.DeleteAsync(WaitUntil.Completed, forceDeletion: forceDeletion); Console.WriteLine("Succeeded"); } @@ -235,25 +131,25 @@ public async Task Update_VirtualMachineScaleSetVMUpdateMaximumSetGen() // invoke the operation VirtualMachineScaleSetVmData data = new VirtualMachineScaleSetVmData(new AzureLocation("westus")) { - Plan = new ComputePlan() + Plan = new ComputePlan { Name = "aaaaaaaaaa", Publisher = "aaaaaaaaaaaaaaaaaaaaaa", Product = "aaaaaaaaaaaaaaaaaaaa", PromotionCode = "aaaaaaaaaaaaaaaaaaaa", }, - HardwareProfile = new VirtualMachineHardwareProfile() + HardwareProfile = new VirtualMachineHardwareProfile { VmSize = VirtualMachineSizeType.BasicA0, - VmSizeProperties = new VirtualMachineSizeProperties() + VmSizeProperties = new VirtualMachineSizeProperties { VCpusAvailable = 9, VCpusPerCore = 12, }, }, - StorageProfile = new VirtualMachineStorageProfile() + StorageProfile = new VirtualMachineStorageProfile { - ImageReference = new ImageReference() + ImageReference = new ImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -265,13 +161,13 @@ public async Task Update_VirtualMachineScaleSetVMUpdateMaximumSetGen() OSDisk = new VirtualMachineOSDisk(DiskCreateOptionType.FromImage) { OSType = SupportedOperatingSystemType.Windows, - EncryptionSettings = new DiskEncryptionSettings() + EncryptionSettings = new DiskEncryptionSettings { - DiskEncryptionKey = new KeyVaultSecretReference(new Uri("aaaaaaaa"), new WritableSubResource() + DiskEncryptionKey = new KeyVaultSecretReference(new Uri("aaaaaaaa"), new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), }), - KeyEncryptionKey = new KeyVaultKeyReference(new Uri("aaaaaaaaaaaaaa"), new WritableSubResource() + KeyEncryptionKey = new KeyVaultKeyReference(new Uri("aaaaaaaaaaaaaa"), new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), }), @@ -282,13 +178,13 @@ public async Task Update_VirtualMachineScaleSetVMUpdateMaximumSetGen() ImageUri = new Uri("https://{storageAccountName}.blob.core.windows.net/{containerName}/{vhdName}.vhd"), Caching = CachingType.None, WriteAcceleratorEnabled = true, - DiffDiskSettings = new DiffDiskSettings() + DiffDiskSettings = new DiffDiskSettings { Option = DiffDiskOption.Local, Placement = DiffDiskPlacement.CacheDisk, }, DiskSizeGB = 127, - ManagedDisk = new VirtualMachineManagedDisk() + ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("aaaaaaaaaaaa"), @@ -296,9 +192,7 @@ public async Task Update_VirtualMachineScaleSetVMUpdateMaximumSetGen() }, DeleteOption = DiskDeleteOptionType.Delete, }, - DataDisks = -{ -new VirtualMachineDataDisk(1,DiskCreateOptionType.Empty) + DataDisks = {new VirtualMachineDataDisk(1, DiskCreateOptionType.Empty) { Name = "vmss3176_vmss3176_0_disk2_6c4f554bdafa49baa780eb2d128ff39d", VhdUri = new Uri("https://{storageAccountName}.blob.core.windows.net/{containerName}/{vhdName}.vhd"), @@ -306,7 +200,7 @@ public async Task Update_VirtualMachineScaleSetVMUpdateMaximumSetGen() Caching = CachingType.None, WriteAcceleratorEnabled = true, DiskSizeGB = 128, -ManagedDisk = new VirtualMachineManagedDisk() +ManagedDisk = new VirtualMachineManagedDisk { StorageAccountType = StorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("aaaaaaaaaaaa"), @@ -315,77 +209,65 @@ public async Task Update_VirtualMachineScaleSetVMUpdateMaximumSetGen() ToBeDetached = true, DetachOption = DiskDetachOptionType.ForceDetach, DeleteOption = DiskDeleteOptionType.Delete, -} -}, +}}, }, - AdditionalCapabilities = new AdditionalCapabilities() + AdditionalCapabilities = new AdditionalCapabilities { UltraSsdEnabled = true, HibernationEnabled = true, }, - OSProfile = new VirtualMachineOSProfile() + OSProfile = new VirtualMachineOSProfile { ComputerName = "test000000", AdminUsername = "Foo12", AdminPassword = "aaaaaaaaaaaaaaaa", CustomData = "aaaa", - WindowsConfiguration = new WindowsConfiguration() + WindowsConfiguration = new WindowsConfiguration { ProvisionVmAgent = true, IsAutomaticUpdatesEnabled = true, TimeZone = "aaaaaaaaaaaaaaaaaaaaaaaaaaa", - AdditionalUnattendContent = -{ -new AdditionalUnattendContent() + AdditionalUnattendContent = {new AdditionalUnattendContent { PassName = PassName.OobeSystem, ComponentName = ComponentName.MicrosoftWindowsShellSetup, SettingName = SettingName.AutoLogon, Content = "aaaaaaaaaaaaaaaaaaaa", -} -}, - PatchSettings = new PatchSettings() +}}, + PatchSettings = new PatchSettings { PatchMode = WindowsVmGuestPatchMode.Manual, EnableHotpatching = true, AssessmentMode = WindowsPatchAssessmentMode.ImageDefault, }, - WinRMListeners = -{ -new WinRMListener() + WinRMListeners = {new WinRMListener { Protocol = WinRMListenerProtocolType.Http, CertificateUri = new Uri("aaaaaaaaaaaaaaaaaaaaaa"), -} -}, +}}, }, - LinuxConfiguration = new LinuxConfiguration() + LinuxConfiguration = new LinuxConfiguration { IsPasswordAuthenticationDisabled = true, - SshPublicKeys = -{ -new SshPublicKeyConfiguration() + SshPublicKeys = {new SshPublicKeyConfiguration { Path = "aaa", KeyData = "aaaaaa", -} -}, +}}, ProvisionVmAgent = true, - PatchSettings = new LinuxPatchSettings() + PatchSettings = new LinuxPatchSettings { PatchMode = LinuxVmGuestPatchMode.ImageDefault, AssessmentMode = LinuxPatchAssessmentMode.ImageDefault, }, }, - Secrets = -{ -}, + Secrets = { }, AllowExtensionOperations = true, RequireGuestProvisionSignal = true, }, - SecurityProfile = new SecurityProfile() + SecurityProfile = new SecurityProfile { - UefiSettings = new UefiSettings() + UefiSettings = new UefiSettings { IsSecureBootEnabled = true, IsVirtualTpmEnabled = true, @@ -393,21 +275,16 @@ public async Task Update_VirtualMachineScaleSetVMUpdateMaximumSetGen() EncryptionAtHost = true, SecurityType = SecurityType.TrustedLaunch, }, - NetworkProfile = new VirtualMachineNetworkProfile() + NetworkProfile = new VirtualMachineNetworkProfile { - NetworkInterfaces = -{ -new VirtualMachineNetworkInterfaceReference() + NetworkInterfaces = {new VirtualMachineNetworkInterfaceReference { Primary = true, DeleteOption = ComputeDeleteOption.Delete, Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachineScaleSets/{vmss-name}/virtualMachines/0/networkInterfaces/vmsstestnetconfig5415"), -} -}, +}}, NetworkApiVersion = NetworkApiVersion.TwoThousandTwenty1101, - NetworkInterfaceConfigurations = -{ -new VirtualMachineNetworkInterfaceConfiguration("aaaaaaaaaaa") + NetworkInterfaceConfigurations = {new VirtualMachineNetworkInterfaceConfiguration("aaaaaaaaaaa") { Primary = true, DeleteOption = ComputeDeleteOption.Delete, @@ -415,19 +292,14 @@ public async Task Update_VirtualMachineScaleSetVMUpdateMaximumSetGen() EnableFpga = true, EnableIPForwarding = true, NetworkSecurityGroupId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -DnsServers = -{ -"aaaaaa" -}, -IPConfigurations = -{ -new VirtualMachineNetworkInterfaceIPConfiguration("aa") +DnsServers = {"aaaaaa"}, +IPConfigurations = {new VirtualMachineNetworkInterfaceIPConfiguration("aa") { SubnetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), Primary = true, PublicIPAddressConfiguration = new VirtualMachinePublicIPAddressConfiguration("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa") { -Sku = new ComputePublicIPAddressSku() +Sku = new ComputePublicIPAddressSku { Name = ComputePublicIPAddressSkuName.Basic, Tier = ComputePublicIPAddressSkuTier.Regional, @@ -435,135 +307,96 @@ public async Task Update_VirtualMachineScaleSetVMUpdateMaximumSetGen() IdleTimeoutInMinutes = 2, DeleteOption = ComputeDeleteOption.Delete, DnsSettings = new VirtualMachinePublicIPAddressDnsSettingsConfiguration("aaaaaaaaaaaaaaaaaaaaaaaaa"), -IPTags = -{ -new VirtualMachineIPTag() +IPTags = {new VirtualMachineIPTag { IPTagType = "aaaaaaaaaaaaaaaaaaaaaaaaa", Tag = "aaaaaaaaaaaaaaaaaaaa", -} -}, +}}, PublicIPPrefixId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), PublicIPAddressVersion = IPVersion.IPv4, PublicIPAllocationMethod = PublicIPAllocationMethod.Dynamic, }, PrivateIPAddressVersion = IPVersion.IPv4, -ApplicationSecurityGroups = -{ -new WritableSubResource() +ApplicationSecurityGroups = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -ApplicationGatewayBackendAddressPools = -{ -new WritableSubResource() +}}, +ApplicationGatewayBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -LoadBalancerBackendAddressPools = -{ -new WritableSubResource() +}}, +LoadBalancerBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -} -}, +}}, +}}, DscpConfigurationId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, +}}, }, - NetworkInterfaceConfigurations = -{ -new VirtualMachineScaleSetNetworkConfiguration("vmsstestnetconfig5415") + NetworkInterfaceConfigurations = {new VirtualMachineScaleSetNetworkConfiguration("vmsstestnetconfig5415") { Primary = true, EnableAcceleratedNetworking = true, EnableFpga = true, NetworkSecurityGroupId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -DnsServers = -{ -}, -IPConfigurations = -{ -new VirtualMachineScaleSetIPConfiguration("vmsstestnetconfig9693") +DnsServers = {}, +IPConfigurations = {new VirtualMachineScaleSetIPConfiguration("vmsstestnetconfig9693") { SubnetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/vn4071/subnets/sn5503"), Primary = true, PublicIPAddressConfiguration = new VirtualMachineScaleSetPublicIPAddressConfiguration("aaaaaaaaaaaaaaaaaa") { -Sku = new ComputePublicIPAddressSku() +Sku = new ComputePublicIPAddressSku { Name = ComputePublicIPAddressSkuName.Basic, Tier = ComputePublicIPAddressSkuTier.Regional, }, IdleTimeoutInMinutes = 18, DnsSettings = new VirtualMachineScaleSetPublicIPAddressConfigurationDnsSettings("aaaaaaaaaaaaaaaaaa"), -IPTags = -{ -new VirtualMachineScaleSetIPTag() +IPTags = {new VirtualMachineScaleSetIPTag { IPTagType = "aaaaaaa", Tag = "aaaaaaaaaaaaaaaaaaaaaaaaaaa", -} -}, +}}, PublicIPPrefixId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), PublicIPAddressVersion = IPVersion.IPv4, DeleteOption = ComputeDeleteOption.Delete, }, PrivateIPAddressVersion = IPVersion.IPv4, -ApplicationGatewayBackendAddressPools = -{ -new WritableSubResource() +ApplicationGatewayBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -ApplicationSecurityGroups = -{ -new WritableSubResource() +}}, +ApplicationSecurityGroups = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -LoadBalancerBackendAddressPools = -{ -new WritableSubResource() +}}, +LoadBalancerBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -LoadBalancerInboundNatPools = -{ -new WritableSubResource() +}}, +LoadBalancerInboundNatPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), -} -}, -} -}, +}}, +}}, EnableIPForwarding = true, DeleteOption = ComputeDeleteOption.Delete, -} -}, - BootDiagnostics = new BootDiagnostics() +}}, + BootDiagnostics = new BootDiagnostics { Enabled = true, StorageUri = new Uri("aaaaaaaaaaaaa"), }, AvailabilitySetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}"), LicenseType = "aaaaaaaaaa", - ProtectionPolicy = new VirtualMachineScaleSetVmProtectionPolicy() + ProtectionPolicy = new VirtualMachineScaleSetVmProtectionPolicy { ProtectFromScaleIn = true, ProtectFromScaleSetActions = true, }, UserData = "RXhhbXBsZSBVc2VyRGF0YQ==", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await virtualMachineScaleSetVm.UpdateAsync(WaitUntil.Completed, data); VirtualMachineScaleSetVmResource result = lro.Value; @@ -610,10 +443,10 @@ public async Task Update_VirtualMachineScaleSetVMUpdateMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ForceDeleteAVirtualMachineFromAVMScaleSet() + public async Task Reimage_VirtualMachineScaleSetVMReimageMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Delete_Force.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Reimage_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_Reimage" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -623,25 +456,29 @@ public async Task Delete_ForceDeleteAVirtualMachineFromAVMScaleSet() // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string virtualMachineScaleSetName = "myvmScaleSet"; - string instanceId = "0"; + string resourceGroupName = "rgcompute"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaa"; + string instanceId = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); // invoke the operation - bool? forceDeletion = true; - await virtualMachineScaleSetVm.DeleteAsync(WaitUntil.Completed, forceDeletion: forceDeletion); + VirtualMachineScaleSetVmReimageContent content = new VirtualMachineScaleSetVmReimageContent + { + ForceUpdateOSDiskForEphemeral = true, + TempDisk = true, + }; + await virtualMachineScaleSetVm.ReimageAsync(WaitUntil.Completed, content: content); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVMScaleSetVMWithUserData() + public async Task Reimage_VirtualMachineScaleSetVMReimageMinimumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithUserData.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Reimage_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_Reimage" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -651,28 +488,24 @@ public async Task Get_GetVMScaleSetVMWithUserData() // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string virtualMachineScaleSetName = "{vmss-name}"; - string instanceId = "0"; + string resourceGroupName = "rgcompute"; + string virtualMachineScaleSetName = "aaaaaaa"; + string instanceId = "aaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); // invoke the operation - VirtualMachineScaleSetVmResource result = await virtualMachineScaleSetVm.GetAsync(); + await virtualMachineScaleSetVm.ReimageAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVMScaleSetVMWithVMSizeProperties() + public async Task ReimageAll_VirtualMachineScaleSetVMReimageAllMaximumSetGen() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Get_WithVMSizeProperties.json - // this example is just showing the usage of "VirtualMachineScaleSetVMs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_ReimageAll_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_ReimageAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -682,20 +515,124 @@ public async Task Get_GetVMScaleSetVMWithVMSizeProperties() // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myResourceGroup"; - string virtualMachineScaleSetName = "{vmss-name}"; - string instanceId = "0"; + string resourceGroupName = "rgcompute"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; + string instanceId = "aaaaaaaaaaaaaaaaaaa"; ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); // invoke the operation - VirtualMachineScaleSetVmResource result = await virtualMachineScaleSetVm.GetAsync(); + await virtualMachineScaleSetVm.ReimageAllAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineScaleSetVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task ReimageAll_VirtualMachineScaleSetVMReimageAllMinimumSetGen() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_ReimageAll_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_ReimageAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure + // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaaa"; + string instanceId = "aaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); + VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); + + // invoke the operation + await virtualMachineScaleSetVm.ReimageAllAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task ApproveRollingUpgrade_VirtualMachineScaleSetVMApproveRollingUpgrade() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_ApproveRollingUpgrade.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_ApproveRollingUpgrade" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure + // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string virtualMachineScaleSetName = "vmssToApproveRollingUpgradeOn"; + string instanceId = "0123"; + ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); + VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); + + // invoke the operation + await virtualMachineScaleSetVm.ApproveRollingUpgradeAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Deallocate_VirtualMachineScaleSetVMDeallocateMaximumSetGen() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Deallocate_MaximumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_Deallocate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure + // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; + string instanceId = "aaaaaaaaaaaaaaaaaaaaaa"; + ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); + VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); + + // invoke the operation + await virtualMachineScaleSetVm.DeallocateAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Deallocate_VirtualMachineScaleSetVMDeallocateMinimumSetGen() + { + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/virtualMachineScaleSetExamples/VirtualMachineScaleSetVM_Deallocate_MinimumSet_Gen.json + // this example is just showing the usage of "VirtualMachineScaleSetVMs_Deallocate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualMachineScaleSetVmResource created on azure + // for more information of creating VirtualMachineScaleSetVmResource, please refer to the document of VirtualMachineScaleSetVmResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "rgcompute"; + string virtualMachineScaleSetName = "aaaaaaaaaaaaaaaaaaaaaaaa"; + string instanceId = "aaaaaa"; + ResourceIdentifier virtualMachineScaleSetVmResourceId = VirtualMachineScaleSetVmResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualMachineScaleSetName, instanceId); + VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); + + // invoke the operation + await virtualMachineScaleSetVm.DeallocateAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); } [Test] @@ -1073,34 +1010,28 @@ public async Task AttachDetachDataDisks_VirtualMachineScaleSetVMAttachDetachData VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); // invoke the operation - AttachDetachDataDisksRequest attachDetachDataDisksRequest = new AttachDetachDataDisksRequest() + AttachDetachDataDisksRequest attachDetachDataDisksRequest = new AttachDetachDataDisksRequest { - DataDisksToAttach = -{ -new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_0_disk2_6c4f554bdafa49baa780eb2d128ff39d") + DataDisksToAttach = {new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_0_disk2_6c4f554bdafa49baa780eb2d128ff39d") { Lun = 1, Caching = CachingType.ReadOnly, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), WriteAcceleratorEnabled = true, -},new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_2_disk3_7d5e664bdafa49baa780eb2d128ff38e") +}, new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_2_disk3_7d5e664bdafa49baa780eb2d128ff38e") { Lun = 2, Caching = CachingType.ReadWrite, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/diskEncryptionSets/{existing-diskEncryptionSet-name}"), WriteAcceleratorEnabled = false, -} -}, - DataDisksToDetach = -{ -new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_1_disk1_1a4e784bdafa49baa780eb2d128ff65x") +}}, + DataDisksToDetach = {new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_1_disk1_1a4e784bdafa49baa780eb2d128ff65x") { DetachOption = DiskDetachOptionType.ForceDetach, -},new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_4_disk4_4d4e784bdafa49baa780eb2d256ff41z") +}, new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_4_disk4_4d4e784bdafa49baa780eb2d256ff41z") { DetachOption = DiskDetachOptionType.ForceDetach, -} -}, +}}, }; ArmOperation lro = await virtualMachineScaleSetVm.AttachDetachDataDisksAsync(WaitUntil.Completed, attachDetachDataDisksRequest); VirtualMachineStorageProfile result = lro.Value; @@ -1130,16 +1061,10 @@ public async Task AttachDetachDataDisks_VirtualMachineScaleSetVMAttachDetachData VirtualMachineScaleSetVmResource virtualMachineScaleSetVm = client.GetVirtualMachineScaleSetVmResource(virtualMachineScaleSetVmResourceId); // invoke the operation - AttachDetachDataDisksRequest attachDetachDataDisksRequest = new AttachDetachDataDisksRequest() + AttachDetachDataDisksRequest attachDetachDataDisksRequest = new AttachDetachDataDisksRequest { - DataDisksToAttach = -{ -new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_0_disk2_6c4f554bdafa49baa780eb2d128ff39d") -}, - DataDisksToDetach = -{ -new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_1_disk1_1a4e784bdafa49baa780eb2d128ff65x") -}, + DataDisksToAttach = { new DataDisksToAttach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_0_disk2_6c4f554bdafa49baa780eb2d128ff39d") }, + DataDisksToDetach = { new DataDisksToDetach("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vmss3176_vmss3176_1_disk1_1a4e784bdafa49baa780eb2d128ff65x") }, }; ArmOperation lro = await virtualMachineScaleSetVm.AttachDetachDataDisksAsync(WaitUntil.Completed, attachDetachDataDisksRequest); VirtualMachineStorageProfile result = lro.Value; @@ -1171,10 +1096,7 @@ public async Task RunCommand_VirtualMachineScaleSetVMsRunCommand() // invoke the operation RunCommandInput input = new RunCommandInput("RunPowerShellScript") { - Script = -{ -"Write-Host Hello World!" -}, + Script = { "Write-Host Hello World!" }, }; ArmOperation lro = await virtualMachineScaleSetVm.RunCommandAsync(WaitUntil.Completed, input); VirtualMachineRunCommandResult result = lro.Value; diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmRunCommandCollection.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmRunCommandCollection.cs index e65b1683b5683..3c99783ca3340 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmRunCommandCollection.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmRunCommandCollection.cs @@ -44,25 +44,22 @@ public async Task CreateOrUpdate_CreateVirtualMachineScaleSetVMRunCommand() string runCommandName = "myRunCommand"; VirtualMachineRunCommandData data = new VirtualMachineRunCommandData(new AzureLocation("West US")) { - Source = new VirtualMachineRunCommandScriptSource() + Source = new VirtualMachineRunCommandScriptSource { ScriptUri = new Uri("https://mystorageaccount.blob.core.windows.net/scriptcontainer/MyScript.ps1"), - ScriptUriManagedIdentity = new RunCommandManagedIdentity() + ScriptUriManagedIdentity = new RunCommandManagedIdentity { ObjectId = "4231e4d2-33e4-4e23-96b2-17888afa6072", }, }, - Parameters = -{ -new RunCommandInputParameter("param1","value1"),new RunCommandInputParameter("param2","value2") -}, + Parameters = { new RunCommandInputParameter("param1", "value1"), new RunCommandInputParameter("param2", "value2") }, AsyncExecution = false, RunAsUser = "user1", RunAsPassword = "", TimeoutInSeconds = 3600, OutputBlobUri = new Uri("https://mystorageaccount.blob.core.windows.net/myscriptoutputcontainer/MyScriptoutput.txt"), ErrorBlobUri = new Uri("https://mystorageaccount.blob.core.windows.net/mycontainer/MyScriptError.txt"), - OutputBlobManagedIdentity = new RunCommandManagedIdentity() + OutputBlobManagedIdentity = new RunCommandManagedIdentity { ClientId = "22d35efb-0c99-4041-8c5b-6d24db33a69a", }, @@ -116,10 +113,10 @@ public async Task Get_GetVirtualMachineScaleSetVMRunCommands() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualMachineScaleSetVMRunCommands() + public async Task GetAll_ListRunCommandsInVmssInstance() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineScaleSetVMRunCommand_Get.json - // this example is just showing the usage of "VirtualMachineScaleSetVMRunCommands_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineScaleSetVMRunCommand_List.json + // this example is just showing the usage of "VirtualMachineScaleSetVMRunCommands_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,16 +135,22 @@ public async Task Exists_GetVirtualMachineScaleSetVMRunCommands() // get the collection of this VirtualMachineScaleSetVmRunCommandResource VirtualMachineScaleSetVmRunCommandCollection collection = virtualMachineScaleSetVm.GetVirtualMachineScaleSetVmRunCommands(); - // invoke the operation - string runCommandName = "myRunCommand"; - bool result = await collection.ExistsAsync(runCommandName); + // invoke the operation and iterate over the result + await foreach (VirtualMachineScaleSetVmRunCommandResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualMachineRunCommandData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualMachineScaleSetVMRunCommands() + public async Task Exists_GetVirtualMachineScaleSetVMRunCommands() { // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineScaleSetVMRunCommand_Get.json // this example is just showing the usage of "VirtualMachineScaleSetVMRunCommands_Get" operation, for the dependent resources, they will have to be created separately. @@ -171,29 +174,17 @@ public async Task GetIfExists_GetVirtualMachineScaleSetVMRunCommands() // invoke the operation string runCommandName = "myRunCommand"; - NullableResponse response = await collection.GetIfExistsAsync(runCommandName); - VirtualMachineScaleSetVmRunCommandResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(runCommandName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualMachineRunCommandData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRunCommandsInVmssInstance() + public async Task GetIfExists_GetVirtualMachineScaleSetVMRunCommands() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineScaleSetVMRunCommand_List.json - // this example is just showing the usage of "VirtualMachineScaleSetVMRunCommands_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineScaleSetVMRunCommand_Get.json + // this example is just showing the usage of "VirtualMachineScaleSetVMRunCommands_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -212,17 +203,23 @@ public async Task GetAll_ListRunCommandsInVmssInstance() // get the collection of this VirtualMachineScaleSetVmRunCommandResource VirtualMachineScaleSetVmRunCommandCollection collection = virtualMachineScaleSetVm.GetVirtualMachineScaleSetVmRunCommands(); - // invoke the operation and iterate over the result - await foreach (VirtualMachineScaleSetVmRunCommandResource item in collection.GetAllAsync()) + // invoke the operation + string runCommandName = "myRunCommand"; + NullableResponse response = await collection.GetIfExistsAsync(runCommandName); + VirtualMachineScaleSetVmRunCommandResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualMachineRunCommandData resourceData = item.Data; + VirtualMachineRunCommandData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmRunCommandResource.cs b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmRunCommandResource.cs index 0116665adb84a..6a0873cda4204 100644 --- a/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmRunCommandResource.cs +++ b/sdk/compute/Azure.ResourceManager.Compute/samples/Generated/Samples/Sample_VirtualMachineScaleSetVmRunCommandResource.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualMachineScaleSetVmRunCommandResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateVirtualMachineScaleSetVMRunCommand() + public async Task Get_GetVirtualMachineScaleSetVMRunCommands() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineScaleSetVMRunCommand_Update.json - // this example is just showing the usage of "VirtualMachineScaleSetVMRunCommands_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineScaleSetVMRunCommand_Get.json + // this example is just showing the usage of "VirtualMachineScaleSetVMRunCommands_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,19 +39,7 @@ public async Task Update_UpdateVirtualMachineScaleSetVMRunCommand() VirtualMachineScaleSetVmRunCommandResource virtualMachineScaleSetVmRunCommand = client.GetVirtualMachineScaleSetVmRunCommandResource(virtualMachineScaleSetVmRunCommandResourceId); // invoke the operation - VirtualMachineRunCommandUpdate runCommand = new VirtualMachineRunCommandUpdate() - { - Source = new VirtualMachineRunCommandScriptSource() - { - ScriptUri = new Uri("https://mystorageaccount.blob.core.windows.net/scriptcontainer/MyScript.ps1"), - ScriptUriManagedIdentity = new RunCommandManagedIdentity() - { - ObjectId = "4231e4d2-33e4-4e23-96b2-17888afa6072", - }, - }, - }; - ArmOperation lro = await virtualMachineScaleSetVmRunCommand.UpdateAsync(WaitUntil.Completed, runCommand); - VirtualMachineScaleSetVmRunCommandResource result = lro.Value; + VirtualMachineScaleSetVmRunCommandResource result = await virtualMachineScaleSetVmRunCommand.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,10 +78,10 @@ public async Task Delete_DeleteVirtualMachineScaleSetVMRunCommand() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualMachineScaleSetVMRunCommands() + public async Task Update_UpdateVirtualMachineScaleSetVMRunCommand() { - // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineScaleSetVMRunCommand_Get.json - // this example is just showing the usage of "VirtualMachineScaleSetVMRunCommands_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/ComputeRP/stable/2024-07-01/examples/runCommandExamples/VirtualMachineScaleSetVMRunCommand_Update.json + // this example is just showing the usage of "VirtualMachineScaleSetVMRunCommands_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,7 +99,19 @@ public async Task Get_GetVirtualMachineScaleSetVMRunCommands() VirtualMachineScaleSetVmRunCommandResource virtualMachineScaleSetVmRunCommand = client.GetVirtualMachineScaleSetVmRunCommandResource(virtualMachineScaleSetVmRunCommandResourceId); // invoke the operation - VirtualMachineScaleSetVmRunCommandResource result = await virtualMachineScaleSetVmRunCommand.GetAsync(); + VirtualMachineRunCommandUpdate runCommand = new VirtualMachineRunCommandUpdate + { + Source = new VirtualMachineRunCommandScriptSource + { + ScriptUri = new Uri("https://mystorageaccount.blob.core.windows.net/scriptcontainer/MyScript.ps1"), + ScriptUriManagedIdentity = new RunCommandManagedIdentity + { + ObjectId = "4231e4d2-33e4-4e23-96b2-17888afa6072", + }, + }, + }; + ArmOperation lro = await virtualMachineScaleSetVmRunCommand.UpdateAsync(WaitUntil.Completed, runCommand); + VirtualMachineScaleSetVmRunCommandResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance From 79faa099ffbe76abbd788d9751b047bb8077be28 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 03:50:46 +0000 Subject: [PATCH 03/11] Update SDK code ne_pr_6 --- .../Samples/Sample_DataProductCollection.cs | 288 +++++---- .../Samples/Sample_DataProductResource.cs | 213 +++---- .../Sample_DataProductsCatalogResource.cs | 63 -- .../Sample_SubscriptionResourceExtensions.cs | 143 +++++ .../Sample_NetworkCloudAgentPoolCollection.cs | 191 +++--- .../Sample_NetworkCloudAgentPoolResource.cs | 11 +- ..._NetworkCloudBareMetalMachineCollection.cs | 48 +- ...rkCloudBareMetalMachineKeySetCollection.cs | 137 ++-- ...workCloudBareMetalMachineKeySetResource.cs | 18 +- ...le_NetworkCloudBareMetalMachineResource.cs | 63 +- .../Sample_NetworkCloudBmcKeySetCollection.cs | 131 ++-- .../Sample_NetworkCloudBmcKeySetResource.cs | 13 +- ...workCloudCloudServicesNetworkCollection.cs | 123 ++-- ...etworkCloudCloudServicesNetworkResource.cs | 43 +- .../Sample_NetworkCloudClusterCollection.cs | 301 +++++---- ...le_NetworkCloudClusterManagerCollection.cs | 180 +++--- ...mple_NetworkCloudClusterManagerResource.cs | 40 +- ...udClusterMetricsConfigurationCollection.cs | 109 ++-- ...loudClusterMetricsConfigurationResource.cs | 9 +- .../Sample_NetworkCloudClusterResource.cs | 97 +-- ...NetworkCloudKubernetesClusterCollection.cs | 599 +++++++----------- ...CloudKubernetesClusterFeatureCollection.cs | 109 ++-- ...rkCloudKubernetesClusterFeatureResource.cs | 9 +- ...e_NetworkCloudKubernetesClusterResource.cs | 48 +- .../Sample_NetworkCloudL2NetworkCollection.cs | 108 ++-- .../Sample_NetworkCloudL2NetworkResource.cs | 36 +- .../Sample_NetworkCloudL3NetworkCollection.cs | 112 ++-- .../Sample_NetworkCloudL3NetworkResource.cs | 36 +- .../Sample_NetworkCloudRackCollection.cs | 48 +- .../Sample_NetworkCloudRackResource.cs | 36 +- .../Sample_NetworkCloudRackSkuCollection.cs | 48 +- ..._NetworkCloudStorageApplianceCollection.cs | 48 +- ...le_NetworkCloudStorageApplianceResource.cs | 43 +- ...le_NetworkCloudTrunkedNetworkCollection.cs | 110 ++-- ...mple_NetworkCloudTrunkedNetworkResource.cs | 36 +- ...le_NetworkCloudVirtualMachineCollection.cs | 170 +++-- ...orkCloudVirtualMachineConsoleCollection.cs | 106 ++-- ...tworkCloudVirtualMachineConsoleResource.cs | 4 +- ...mple_NetworkCloudVirtualMachineResource.cs | 38 +- .../Sample_NetworkCloudVolumeCollection.cs | 104 +-- .../Sample_NetworkCloudVolumeResource.cs | 36 +- .../Sample_SubscriptionResourceExtensions.cs | 391 ++++++++++++ .../Sample_AzureTrafficCollectorCollection.cs | 102 +-- .../Sample_AzureTrafficCollectorResource.cs | 4 +- .../Sample_CollectorPolicyCollection.cs | 137 ++-- .../Samples/Sample_CollectorPolicyResource.cs | 4 +- .../Samples/Sample_NewRelicMonitorResource.cs | 180 ++---- ...ample_NewRelicMonitorResourceCollection.cs | 190 +++--- ...NewRelicMonitoredSubscriptionCollection.cs | 92 +-- ...e_NewRelicMonitoredSubscriptionResource.cs | 32 +- ..._NewRelicObservabilityTagRuleCollection.cs | 242 ++++--- ...le_NewRelicObservabilityTagRuleResource.cs | 20 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Sample_NginxCertificateCollection.cs | 84 +-- .../Sample_NginxCertificateResource.cs | 32 +- .../Sample_NginxConfigurationCollection.cs | 92 +-- .../Sample_NginxConfigurationResource.cs | 32 +- .../Sample_NginxDeploymentCollection.cs | 138 ++-- .../Samples/Sample_NginxDeploymentResource.cs | 64 +- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ ...ificationHubAuthorizationRuleCollection.cs | 69 +- ...otificationHubAuthorizationRuleResource.cs | 33 +- .../Sample_NotificationHubCollection.cs | 84 +-- ...HubNamespaceAuthorizationRuleCollection.cs | 69 +- ...onHubNamespaceAuthorizationRuleResource.cs | 33 +- ...mple_NotificationHubNamespaceCollection.cs | 125 ++-- ...Sample_NotificationHubNamespaceResource.cs | 109 +--- ...nHubPrivateEndpointConnectionCollection.cs | 68 +- ...ionHubPrivateEndpointConnectionResource.cs | 38 +- .../Samples/Sample_NotificationHubResource.cs | 53 +- ...cationHubsPrivateLinkResourceCollection.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 76 +++ .../Sample_LogAnalyticsQueryCollection.cs | 129 ++-- .../Sample_LogAnalyticsQueryPackCollection.cs | 126 ++-- .../Sample_LogAnalyticsQueryPackResource.cs | 134 +--- .../Sample_LogAnalyticsQueryResource.cs | 67 +- ...le_OperationalInsightsClusterCollection.cs | 74 +-- ...mple_OperationalInsightsClusterResource.cs | 70 +- ...OperationalInsightsDataExportCollection.cs | 69 +- ...e_OperationalInsightsDataExportResource.cs | 51 +- ...OperationalInsightsDataSourceCollection.cs | 69 +- ...e_OperationalInsightsDataSourceResource.cs | 27 +- ...rationalInsightsLinkedServiceCollection.cs | 64 +- ...perationalInsightsLinkedServiceResource.cs | 26 +- ...InsightsLinkedStorageAccountsCollection.cs | 69 +- ...alInsightsLinkedStorageAccountsResource.cs | 29 +- ...perationalInsightsSavedSearchCollection.cs | 67 +- ..._OperationalInsightsSavedSearchResource.cs | 55 +- ...mple_OperationalInsightsTableCollection.cs | 83 ++- ...Sample_OperationalInsightsTableResource.cs | 75 ++- ..._OperationalInsightsWorkspaceCollection.cs | 72 +-- ...le_OperationalInsightsWorkspaceResource.cs | 230 +++---- .../Sample_ResourceGroupResourceExtensions.cs | 66 ++ .../Sample_StorageInsightCollection.cs | 74 +-- .../Samples/Sample_StorageInsightResource.cs | 56 +- .../Sample_SubscriptionResourceExtensions.cs | 93 +++ .../Sample_AutonomousDBVersionCollection.cs | 48 +- ...mple_AutonomousDatabaseBackupCollection.cs | 210 +++--- ...Sample_AutonomousDatabaseBackupResource.cs | 64 +- ...utonomousDatabaseCharacterSetCollection.cs | 48 +- .../Sample_AutonomousDatabaseCollection.cs | 350 +++++----- ...sDatabaseNationalCharacterSetCollection.cs | 48 +- .../Sample_AutonomousDatabaseResource.cs | 72 +-- ...le_CloudExadataInfrastructureCollection.cs | 113 ++-- ...mple_CloudExadataInfrastructureResource.cs | 64 +- .../Sample_CloudVmClusterCollection.cs | 173 +++-- .../Sample_CloudVmClusterDBNodeCollection.cs | 48 +- .../Samples/Sample_CloudVmClusterResource.cs | 74 +-- ...mClusterVirtualNetworkAddressCollection.cs | 104 +-- ...dVmClusterVirtualNetworkAddressResource.cs | 46 +- .../Sample_OracleDBServerCollection.cs | 48 +- .../Sample_OracleDBSystemShapeCollection.cs | 48 +- .../Sample_OracleDnsPrivateViewCollection.cs | 48 +- .../Sample_OracleDnsPrivateZoneCollection.cs | 48 +- .../Sample_OracleGIVersionCollection.cs | 48 +- .../Sample_OracleSubscriptionResource.cs | 48 +- .../Sample_OracleSystemVersionCollection.cs | 138 ++-- .../Sample_SubscriptionResourceExtensions.cs | 112 ++++ ...Sample_AvailableGroundStationCollection.cs | 50 +- .../Sample_OrbitalContactCollection.cs | 102 +-- .../Sample_OrbitalContactProfileCollection.cs | 131 ++-- .../Sample_OrbitalContactProfileResource.cs | 36 +- .../Samples/Sample_OrbitalContactResource.cs | 44 +- .../Sample_OrbitalSpacecraftCollection.cs | 107 ++-- .../Sample_OrbitalSpacecraftResource.cs | 38 +- .../Sample_SubscriptionResourceExtensions.cs | 81 +++ ...balRulestackCertificateObjectCollection.cs | 200 +++--- ...lobalRulestackCertificateObjectResource.cs | 76 +-- .../Sample_GlobalRulestackCollection.cs | 282 ++++----- .../Sample_GlobalRulestackFqdnCollection.cs | 202 +++--- .../Sample_GlobalRulestackFqdnResource.cs | 80 ++- .../Sample_GlobalRulestackPrefixCollection.cs | 202 +++--- .../Sample_GlobalRulestackPrefixResource.cs | 80 ++- .../Samples/Sample_GlobalRulestackResource.cs | 109 ++-- ...calRulestackCertificateObjectCollection.cs | 200 +++--- ...LocalRulestackCertificateObjectResource.cs | 76 +-- .../Sample_LocalRulestackCollection.cs | 253 ++++---- .../Sample_LocalRulestackFqdnCollection.cs | 202 +++--- .../Sample_LocalRulestackFqdnResource.cs | 80 ++- .../Sample_LocalRulestackPrefixCollection.cs | 202 +++--- .../Sample_LocalRulestackPrefixResource.cs | 80 ++- .../Samples/Sample_LocalRulestackResource.cs | 162 ++--- .../Sample_LocalRulestackRuleCollection.cs | 292 ++++----- .../Sample_LocalRulestackRuleResource.cs | 170 ++--- ...mple_PaloAltoNetworksFirewallCollection.cs | 418 ++++++------ ...Sample_PaloAltoNetworksFirewallResource.cs | 241 +++---- .../Sample_PostRulestackRuleCollection.cs | 292 ++++----- .../Sample_PostRulestackRuleResource.cs | 170 ++--- .../Sample_PreRulestackRuleCollection.cs | 292 ++++----- .../Sample_PreRulestackRuleResource.cs | 170 ++--- .../Sample_SubscriptionResourceExtensions.cs | 143 +++++ .../Sample_ConnectionMonitorTestCollection.cs | 96 +-- .../Sample_ConnectionMonitorTestResource.cs | 44 +- .../Samples/Sample_PeerAsnCollection.cs | 127 ++-- .../Samples/Sample_PeerAsnResource.cs | 63 +- .../Samples/Sample_PeeringCollection.cs | 251 ++++---- .../Sample_PeeringRegisteredAsnCollection.cs | 94 +-- .../Sample_PeeringRegisteredAsnResource.cs | 38 +- ...ample_PeeringRegisteredPrefixCollection.cs | 90 +-- .../Sample_PeeringRegisteredPrefixResource.cs | 38 +- .../Samples/Sample_PeeringResource.cs | 36 +- .../Sample_PeeringServiceCollection.cs | 96 +-- .../Sample_PeeringServicePrefixCollection.cs | 92 +-- .../Sample_PeeringServicePrefixResource.cs | 40 +- .../Samples/Sample_PeeringServiceResource.cs | 60 +- .../Sample_SubscriptionResourceExtensions.cs | 88 ++- ...mple_PlaywrightTestingAccountCollection.cs | 104 +-- ...Sample_PlaywrightTestingAccountResource.cs | 78 +-- ...Sample_PlaywrightTestingQuotaCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ ...ample_ManagementGroupResourceExtensions.cs | 7 +- .../Sample_PolicyAttestationCollection.cs | 160 ++--- .../Sample_PolicyAttestationResource.cs | 78 ++- .../Sample_PolicyMetadataCollection.cs | 105 ++- .../Sample_PolicyRemediationCollection.cs | 138 ++-- .../Sample_PolicyRemediationResource.cs | 66 +- .../Sample_ResourceGroupResourceExtensions.cs | 30 +- .../Sample_SubscriptionResourceExtensions.cs | 30 +- ...ample_PostgreSqlConfigurationCollection.cs | 64 +- .../Sample_PostgreSqlConfigurationResource.cs | 28 +- .../Sample_PostgreSqlDatabaseCollection.cs | 64 +- .../Sample_PostgreSqlDatabaseResource.cs | 28 +- ...Sample_PostgreSqlFirewallRuleCollection.cs | 62 +- .../Sample_PostgreSqlFirewallRuleResource.cs | 20 +- ...rActiveDirectoryAdministratorCollection.cs | 64 +- ...verActiveDirectoryAdministratorResource.cs | 34 +- ...ostgreSqlFlexibleServerBackupCollection.cs | 62 +- ..._PostgreSqlFlexibleServerBackupResource.cs | 22 +- ...mple_PostgreSqlFlexibleServerCollection.cs | 222 +++---- ...qlFlexibleServerConfigurationCollection.cs | 100 +-- ...eSqlFlexibleServerConfigurationResource.cs | 2 +- ...tgreSqlFlexibleServerDatabaseCollection.cs | 64 +- ...ostgreSqlFlexibleServerDatabaseResource.cs | 28 +- ...SqlFlexibleServerFirewallRuleCollection.cs | 62 +- ...reSqlFlexibleServerFirewallRuleResource.cs | 20 +- ...Sample_PostgreSqlFlexibleServerResource.cs | 283 ++++----- ...versPrivateEndpointConnectionCollection.cs | 106 ++-- ...erversPrivateEndpointConnectionResource.cs | 46 +- ...bleServersPrivateLinkResourceCollection.cs | 48 +- ...reSqlLtrServerBackupOperationCollection.cs | 62 +- .../Sample_PostgreSqlMigrationCollection.cs | 254 ++++---- .../Sample_PostgreSqlMigrationResource.cs | 44 +- ...eSqlPrivateEndpointConnectionCollection.cs | 90 +-- ...greSqlPrivateEndpointConnectionResource.cs | 4 +- ...PostgreSqlPrivateLinkResourceCollection.cs | 48 +- ...e_PostgreSqlServerAdministratorResource.cs | 44 +- .../Sample_PostgreSqlServerCollection.cs | 106 ++-- .../Sample_PostgreSqlServerKeyCollection.cs | 98 +-- .../Sample_PostgreSqlServerKeyResource.cs | 40 +- .../Sample_PostgreSqlServerResource.cs | 66 +- ...eSqlServerSecurityAlertPolicyCollection.cs | 144 ++--- ...greSqlServerSecurityAlertPolicyResource.cs | 14 +- ..._PostgreSqlVirtualNetworkRuleCollection.cs | 92 +-- ...le_PostgreSqlVirtualNetworkRuleResource.cs | 40 +- ...ThreatProtectionSettingsModelCollection.cs | 104 +-- ...erThreatProtectionSettingsModelResource.cs | 2 +- .../Sample_SubscriptionResourceExtensions.cs | 33 +- .../Sample_TenantResourceExtensions.cs | 5 +- .../Samples/Sample_VirtualEndpointResource.cs | 31 +- ...ample_VirtualEndpointResourceCollection.cs | 69 +- .../Sample_AutoScaleVCoreCollection.cs | 108 ++-- .../Samples/Sample_AutoScaleVCoreResource.cs | 36 +- .../Sample_DedicatedCapacityCollection.cs | 107 ++-- .../Sample_DedicatedCapacityResource.cs | 102 +-- .../Sample_SubscriptionResourceExtensions.cs | 139 ++++ .../Samples/Sample_CustomRolloutCollection.cs | 97 ++- .../Samples/Sample_CustomRolloutResource.cs | 7 +- .../Sample_DefaultRolloutCollection.cs | 119 ++-- .../Samples/Sample_DefaultRolloutResource.cs | 15 +- ...le_NestedResourceTypeFirstSkuCollection.cs | 118 ++-- ...mple_NestedResourceTypeFirstSkuResource.cs | 66 +- ...e_NestedResourceTypeSecondSkuCollection.cs | 118 ++-- ...ple_NestedResourceTypeSecondSkuResource.cs | 66 +- ...le_NestedResourceTypeThirdSkuCollection.cs | 118 ++-- ...mple_NestedResourceTypeThirdSkuResource.cs | 66 +- ...mple_NotificationRegistrationCollection.cs | 130 ++-- ...Sample_NotificationRegistrationResource.cs | 78 +-- .../Sample_ProviderRegistrationCollection.cs | 115 ++-- .../Sample_ProviderRegistrationResource.cs | 93 ++- ...mple_ResourceTypeRegistrationCollection.cs | 138 ++-- ...Sample_ResourceTypeRegistrationResource.cs | 90 ++- .../Sample_ResourceTypeSkuCollection.cs | 118 ++-- .../Samples/Sample_ResourceTypeSkuResource.cs | 64 +- 243 files changed, 11114 insertions(+), 11939 deletions(-) create mode 100644 sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs diff --git a/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductCollection.cs b/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductCollection.cs index 6802a20784045..8a6a35624c640 100644 --- a/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductCollection.cs +++ b/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_DataProductCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DataProductsListByResourceGroupMaximumSetGen() + public async Task CreateOrUpdate_DataProductsCreateMaximumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "DataProducts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Create_MaximumSet_Gen.json + // this example is just showing the usage of "DataProducts_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,65 @@ public async Task GetAll_DataProductsListByResourceGroupMaximumSetGen() // get the collection of this DataProductResource DataProductCollection collection = resourceGroupResource.GetDataProducts(); - // invoke the operation and iterate over the result - await foreach (DataProductResource item in collection.GetAllAsync()) + // invoke the operation + string dataProductName = "dataproduct01"; + DataProductData data = new DataProductData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() +}, + }, + Publisher = "Microsoft", + Product = "MCC", + MajorVersion = "1.0.0", + Owners = { "abc@micros.com" }, + Redundancy = DataProductControlState.Disabled, + PurviewAccount = "testpurview", + PurviewCollection = "134567890", + PrivateLinksEnabled = DataProductControlState.Disabled, + PublicNetworkAccess = DataProductControlState.Enabled, + CustomerManagedKeyEncryptionEnabled = DataProductControlState.Enabled, + CustomerEncryptionKey = new EncryptionKeyDetails(new Uri("https://KeyVault.vault.azure.net"), "keyName", "keyVersion"), + Networkacls = new DataProductNetworkAcls(new NetworkAnalyticsVirtualNetworkRule[] + { +new NetworkAnalyticsVirtualNetworkRule("/subscriptions/subscriptionId/resourcegroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/subnets/subnetName") +{ +Action = "Allow", +State = "", +} + }, new NetworkAnalyticsIPRules[] + { +new NetworkAnalyticsIPRules("Allow") +{ +Value = "1.1.1.1", +} + }, new string[] { "1.1.1.1" }, NetworkAclDefaultAction.Allow), + ManagedResourceGroupConfiguration = new NetworkAnalyticsManagedResourceGroupConfiguration("managedResourceGroupName", new AzureLocation("eastus")), + CurrentMinorVersion = "1.0.1", + Tags = +{ +["userSpecifiedKeyName"] = "userSpecifiedKeyValue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataProductName, data); + DataProductResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DataProductsListByResourceGroupMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() + public async Task CreateOrUpdate_DataProductsCreateMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "DataProducts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Create_MinimumSet_Gen.json + // this example is just showing the usage of "DataProducts_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +115,26 @@ public async Task GetAll_DataProductsListByResourceGroupMaximumSetGenGeneratedBy // get the collection of this DataProductResource DataProductCollection collection = resourceGroupResource.GetDataProducts(); - // invoke the operation and iterate over the result - await foreach (DataProductResource item in collection.GetAllAsync()) + // invoke the operation + string dataProductName = "dataproduct01"; + DataProductData data = new DataProductData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Publisher = "Microsoft", + Product = "MCC", + MajorVersion = "1.0.0", + Tags = +{ +["userSpecifiedKeyName"] = "userSpecifiedKeyValue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataProductName, data); + DataProductResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -123,9 +172,9 @@ public async Task Get_DataProductsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DataProductsGetMaximumSetGen() + public async Task Get_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MaximumSet_Gen.json + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MinimumSet_Gen.json // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -145,17 +194,21 @@ public async Task Exists_DataProductsGetMaximumSetGen() // invoke the operation string dataProductName = "dataproduct01"; - bool result = await collection.ExistsAsync(dataProductName); + DataProductResource result = await collection.GetAsync(dataProductName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DataProductsGetMaximumSetGen() + public async Task GetAll_DataProductsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MaximumSet_Gen.json - // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "DataProducts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,31 +225,25 @@ public async Task GetIfExists_DataProductsGetMaximumSetGen() // get the collection of this DataProductResource DataProductCollection collection = resourceGroupResource.GetDataProducts(); - // invoke the operation - string dataProductName = "dataproduct01"; - NullableResponse response = await collection.GetIfExistsAsync(dataProductName); - DataProductResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataProductResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataProductData resourceData = result.Data; + DataProductData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() + public async Task GetAll_DataProductsListByResourceGroupMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MinimumSet_Gen.json - // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "DataProducts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,22 +260,24 @@ public async Task Get_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinim // get the collection of this DataProductResource DataProductCollection collection = resourceGroupResource.GetDataProducts(); - // invoke the operation - string dataProductName = "dataproduct01"; - DataProductResource result = await collection.GetAsync(dataProductName); + // invoke the operation and iterate over the result + await foreach (DataProductResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() + public async Task Exists_DataProductsGetMaximumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MinimumSet_Gen.json + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MaximumSet_Gen.json // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -255,7 +304,7 @@ public async Task Exists_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMi [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() + public async Task Exists_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MinimumSet_Gen.json // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. @@ -277,29 +326,17 @@ public async Task GetIfExists_DataProductsGetMaximumSetGenGeneratedByMinimumSetR // invoke the operation string dataProductName = "dataproduct01"; - NullableResponse response = await collection.GetIfExistsAsync(dataProductName); - DataProductResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataProductName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataProductsCreateMaximumSetGen() + public async Task GetIfExists_DataProductsGetMaximumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Create_MaximumSet_Gen.json - // this example is just showing the usage of "DataProducts_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -318,69 +355,29 @@ public async Task CreateOrUpdate_DataProductsCreateMaximumSetGen() // invoke the operation string dataProductName = "dataproduct01"; - DataProductData data = new DataProductData(new AzureLocation("eastus")) - { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), -}, - }, - Publisher = "Microsoft", - Product = "MCC", - MajorVersion = "1.0.0", - Owners = -{ -"abc@micros.com" -}, - Redundancy = DataProductControlState.Disabled, - PurviewAccount = "testpurview", - PurviewCollection = "134567890", - PrivateLinksEnabled = DataProductControlState.Disabled, - PublicNetworkAccess = DataProductControlState.Enabled, - CustomerManagedKeyEncryptionEnabled = DataProductControlState.Enabled, - CustomerEncryptionKey = new EncryptionKeyDetails(new Uri("https://KeyVault.vault.azure.net"), "keyName", "keyVersion"), - Networkacls = new DataProductNetworkAcls(new NetworkAnalyticsVirtualNetworkRule[] - { -new NetworkAnalyticsVirtualNetworkRule("/subscriptions/subscriptionId/resourcegroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/virtualNetworkName/subnets/subnetName") -{ -Action = "Allow", -State = "", -} - }, new NetworkAnalyticsIPRules[] + NullableResponse response = await collection.GetIfExistsAsync(dataProductName); + DataProductResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new NetworkAnalyticsIPRules("Allow") -{ -Value = "1.1.1.1", -} - }, new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"1.1.1.1" - }, NetworkAclDefaultAction.Allow), - ManagedResourceGroupConfiguration = new NetworkAnalyticsManagedResourceGroupConfiguration("managedResourceGroupName", new AzureLocation("eastus")), - CurrentMinorVersion = "1.0.1", - Tags = -{ -["userSpecifiedKeyName"] = "userSpecifiedKeyValue", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataProductName, data); - DataProductResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataProductsCreateMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() + public async Task GetIfExists_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Create_MinimumSet_Gen.json - // this example is just showing the usage of "DataProducts_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MinimumSet_Gen.json + // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -399,24 +396,21 @@ public async Task CreateOrUpdate_DataProductsCreateMaximumSetGenGeneratedByMinim // invoke the operation string dataProductName = "dataproduct01"; - DataProductData data = new DataProductData(new AzureLocation("eastus")) - { - Publisher = "Microsoft", - Product = "MCC", - MajorVersion = "1.0.0", - Tags = -{ -["userSpecifiedKeyName"] = "userSpecifiedKeyValue", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataProductName, data); - DataProductResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dataProductName); + DataProductResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductResource.cs b/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductResource.cs index 31ca7a3a1ec9c..809f7b7092164 100644 --- a/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductResource.cs +++ b/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductResource.cs @@ -6,13 +6,11 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.NetworkAnalytics.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkAnalytics.Samples @@ -21,72 +19,70 @@ public partial class Sample_DataProductResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDataProducts_DataProductsListBySubscriptionMaximumSetGen() + public async Task Get_DataProductsGetMaximumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "DataProducts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this DataProductResource created on azure + // for more information of creating DataProductResource, please refer to the document of DataProductResource string subscriptionId = "00000000-0000-0000-0000-00000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "aoiresourceGroupName"; + string dataProductName = "dataproduct01"; + ResourceIdentifier dataProductResourceId = DataProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, dataProductName); + DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); - // invoke the operation and iterate over the result - await foreach (DataProductResource item in subscriptionResource.GetDataProductsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + DataProductResource result = await dataProduct.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDataProducts_DataProductsListBySubscriptionMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() + public async Task Get_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "DataProducts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MinimumSet_Gen.json + // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this DataProductResource created on azure + // for more information of creating DataProductResource, please refer to the document of DataProductResource string subscriptionId = "00000000-0000-0000-0000-00000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "aoiresourceGroupName"; + string dataProductName = "dataproduct01"; + ResourceIdentifier dataProductResourceId = DataProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, dataProductName); + DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); - // invoke the operation and iterate over the result - await foreach (DataProductResource item in subscriptionResource.GetDataProductsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + DataProductResource result = await dataProduct.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataProductsGetMaximumSetGen() + public async Task Delete_DataProductsDeleteMaximumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MaximumSet_Gen.json - // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "DataProducts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,21 +98,17 @@ public async Task Get_DataProductsGetMaximumSetGen() DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); // invoke the operation - DataProductResource result = await dataProduct.GetAsync(); + await dataProduct.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() + public async Task Delete_DataProductsDeleteMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Get_MinimumSet_Gen.json - // this example is just showing the usage of "DataProducts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "DataProducts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,13 +124,9 @@ public async Task Get_DataProductsGetMaximumSetGenGeneratedByMinimumSetRuleMinim DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); // invoke the operation - DataProductResource result = await dataProduct.GetAsync(); + await dataProduct.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -162,23 +150,20 @@ public async Task Update_DataProductsUpdateMaximumSetGen() DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); // invoke the operation - DataProductPatch patch = new DataProductPatch() + DataProductPatch patch = new DataProductPatch { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() }, }, Tags = { -["userSpecifiedKeyName"] = "userSpecifiedKeyValue", -}, - Owners = -{ -"abc@micros.com","def@micros.com" +["userSpecifiedKeyName"] = "userSpecifiedKeyValue" }, + Owners = { "abc@micros.com", "def@micros.com" }, PurviewAccount = "testpurview", PurviewCollection = "134567890", PrivateLinksEnabled = DataProductControlState.Disabled, @@ -226,58 +211,6 @@ public async Task Update_DataProductsUpdateMaximumSetGenGeneratedByMinimumSetRul Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DataProductsDeleteMaximumSetGen() - { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "DataProducts_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataProductResource created on azure - // for more information of creating DataProductResource, please refer to the document of DataProductResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - string resourceGroupName = "aoiresourceGroupName"; - string dataProductName = "dataproduct01"; - ResourceIdentifier dataProductResourceId = DataProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, dataProductName); - DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); - - // invoke the operation - await dataProduct.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DataProductsDeleteMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() - { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "DataProducts_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataProductResource created on azure - // for more information of creating DataProductResource, please refer to the document of DataProductResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - string resourceGroupName = "aoiresourceGroupName"; - string dataProductName = "dataproduct01"; - ResourceIdentifier dataProductResourceId = DataProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, dataProductName); - DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); - - // invoke the operation - await dataProduct.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task AddUserRole_DataProductsAddUserRoleMaximumSetGen() @@ -299,10 +232,13 @@ public async Task AddUserRole_DataProductsAddUserRoleMaximumSetGen() DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); // invoke the operation - RoleAssignmentCommonProperties body = new RoleAssignmentCommonProperties("00000000-0000-0000-0000-00000000000", "00000000-0000-0000-0000-00000000000", "UserName", new string[] - { -"scope" - }, "User", DataProductUserRole.Reader); + RoleAssignmentCommonProperties body = new RoleAssignmentCommonProperties( + "00000000-0000-0000-0000-00000000000", + "00000000-0000-0000-0000-00000000000", + "UserName", + new string[] { "scope" }, + "User", + DataProductUserRole.Reader); RoleAssignmentDetail result = await dataProduct.AddUserRoleAsync(body); Console.WriteLine($"Succeeded: {result}"); @@ -329,10 +265,13 @@ public async Task AddUserRole_DataProductsAddUserRoleMaximumSetGenGeneratedByMin DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); // invoke the operation - RoleAssignmentCommonProperties body = new RoleAssignmentCommonProperties("00000000-0000-0000-0000-00000000000", "00000000-0000-0000-0000-00000000000", "userName", new string[] - { -"scope" - }, "User", DataProductUserRole.Reader); + RoleAssignmentCommonProperties body = new RoleAssignmentCommonProperties( + "00000000-0000-0000-0000-00000000000", + "00000000-0000-0000-0000-00000000000", + "userName", + new string[] { "scope" }, + "User", + DataProductUserRole.Reader); RoleAssignmentDetail result = await dataProduct.AddUserRoleAsync(body); Console.WriteLine($"Succeeded: {result}"); @@ -413,9 +352,7 @@ public async Task GetRolesAssignments_DataProductsListRolesAssignmentsMaximumSet DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); // invoke the operation - BinaryData body = BinaryData.FromObjectAsJson(new Dictionary() - { - }); + BinaryData body = BinaryData.FromObjectAsJson(new object()); RoleAssignmentListResult result = await dataProduct.GetRolesAssignmentsAsync(body); Console.WriteLine($"Succeeded: {result}"); @@ -442,9 +379,7 @@ public async Task GetRolesAssignments_DataProductsListRolesAssignmentsMaximumSet DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); // invoke the operation - BinaryData body = BinaryData.FromObjectAsJson(new Dictionary() - { - }); + BinaryData body = BinaryData.FromObjectAsJson(new object()); RoleAssignmentListResult result = await dataProduct.GetRolesAssignmentsAsync(body); Console.WriteLine($"Succeeded: {result}"); @@ -471,10 +406,14 @@ public async Task RemoveUserRole_DataProductsRemoveUserRoleMaximumSetGen() DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); // invoke the operation - RoleAssignmentDetail body = new RoleAssignmentDetail("00000000-0000-0000-0000-00000000000", "00000000-0000-0000-0000-00000000000", "UserName", new string[] - { -"scope" - }, "User", DataProductUserRole.Reader, "00000000-0000-0000-0000-00000000000"); + RoleAssignmentDetail body = new RoleAssignmentDetail( + "00000000-0000-0000-0000-00000000000", + "00000000-0000-0000-0000-00000000000", + "UserName", + new string[] { "scope" }, + "User", + DataProductUserRole.Reader, + "00000000-0000-0000-0000-00000000000"); await dataProduct.RemoveUserRoleAsync(body); Console.WriteLine("Succeeded"); @@ -501,10 +440,14 @@ public async Task RemoveUserRole_DataProductsRemoveUserRoleMaximumSetGenGenerate DataProductResource dataProduct = client.GetDataProductResource(dataProductResourceId); // invoke the operation - RoleAssignmentDetail body = new RoleAssignmentDetail("00000000-0000-0000-0000-00000000000", "00000000-0000-0000-0000-00000000000", "UserName", new string[] - { -"scope" - }, "User", DataProductUserRole.Reader, "00000000-0000-0000-0000-00000000000"); + RoleAssignmentDetail body = new RoleAssignmentDetail( + "00000000-0000-0000-0000-00000000000", + "00000000-0000-0000-0000-00000000000", + "UserName", + new string[] { "scope" }, + "User", + DataProductUserRole.Reader, + "00000000-0000-0000-0000-00000000000"); await dataProduct.RemoveUserRoleAsync(body); Console.WriteLine("Succeeded"); diff --git a/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductsCatalogResource.cs b/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductsCatalogResource.cs index cd6a0ea83d1ca..2df2d2c9cec67 100644 --- a/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductsCatalogResource.cs +++ b/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_DataProductsCatalogResource.cs @@ -9,75 +9,12 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkAnalytics.Samples { public partial class Sample_DataProductsCatalogResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDataProductsCatalogs_DataProductsCatalogsListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProductsCatalogs_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "DataProductsCatalogs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DataProductsCatalogResource item in subscriptionResource.GetDataProductsCatalogsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductsCatalogData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDataProductsCatalogs_DataProductsCatalogsListBySubscriptionMinimumSetGen() - { - // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProductsCatalogs_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "DataProductsCatalogs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DataProductsCatalogResource item in subscriptionResource.GetDataProductsCatalogsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataProductsCatalogData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_DataProductsCatalogsGetMaximumSetGen() diff --git a/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..a1beabd0b434a --- /dev/null +++ b/sdk/networkanalytics/Azure.ResourceManager.NetworkAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.NetworkAnalytics.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataProducts_DataProductsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "DataProducts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataProductResource item in subscriptionResource.GetDataProductsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataProducts_DataProductsListBySubscriptionMaximumSetGenGeneratedByMinimumSetRuleMinimumSetGen() + { + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProducts_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "DataProducts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataProductResource item in subscriptionResource.GetDataProductsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataProductsCatalogs_DataProductsCatalogsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProductsCatalogs_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "DataProductsCatalogs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataProductsCatalogResource item in subscriptionResource.GetDataProductsCatalogsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductsCatalogData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataProductsCatalogs_DataProductsCatalogsListBySubscriptionMinimumSetGen() + { + // Generated from example definition: specification/networkanalytics/resource-manager/Microsoft.NetworkAnalytics/stable/2023-11-15/examples/DataProductsCatalogs_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "DataProductsCatalogs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataProductsCatalogResource item in subscriptionResource.GetDataProductsCatalogsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataProductsCatalogData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudAgentPoolCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudAgentPoolCollection.cs index e533182266320..a68b8b94929b7 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudAgentPoolCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudAgentPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkCloudAgentPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAgentPoolsOfTheKubernetesCluster() + public async Task CreateOrUpdate_CreateOrUpdateKubernetesClusterAgentPool() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/AgentPools_ListByKubernetesCluster.json - // this example is just showing the usage of "AgentPools_ListByKubernetesCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/AgentPools_Create.json + // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,57 @@ public async Task GetAll_ListAgentPoolsOfTheKubernetesCluster() // get the collection of this NetworkCloudAgentPoolResource NetworkCloudAgentPoolCollection collection = networkCloudKubernetesCluster.GetNetworkCloudAgentPools(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudAgentPoolResource item in collection.GetAllAsync()) + // invoke the operation + string agentPoolName = "agentPoolName"; + NetworkCloudAgentPoolData data = new NetworkCloudAgentPoolData(new AzureLocation("location"), 3L, NetworkCloudAgentPoolMode.System, "NC_XXXX") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudAgentPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ExtendedLocation = new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), + AdministratorConfiguration = new AdministratorConfiguration + { + AdminUsername = "azure", + SshPublicKeys = { new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") }, + }, + AgentOptions = new NetworkCloudAgentConfiguration(96L) + { + HugepagesSize = HugepagesSize.OneG, + }, + AttachedNetworkConfiguration = new AttachedNetworkConfiguration + { + L2Networks = {new L2NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName")) +{ +PluginType = KubernetesPluginType.Dpdk, +}}, + L3Networks = {new L3NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) +{ +IpamEnabled = L3NetworkConfigurationIpamEnabled.False, +PluginType = KubernetesPluginType.Sriov, +}}, + TrunkedNetworks = {new TrunkedNetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName")) +{ +PluginType = KubernetesPluginType.Macvlan, +}}, + }, + AvailabilityZones = { "1", "2", "3" }, + Labels = { new KubernetesLabel("kubernetes.label", "true") }, + Taints = { new KubernetesLabel("kubernetes.taint", "true") }, + UpgradeSettings = new AgentPoolUpgradeSettings + { + MaxSurge = "1", + }, + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + NetworkCloudAgentPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +128,10 @@ public async Task Get_GetKubernetesClusterAgentPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetKubernetesClusterAgentPool() + public async Task GetAll_ListAgentPoolsOfTheKubernetesCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/AgentPools_Get.json - // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/AgentPools_ListByKubernetesCluster.json + // this example is just showing the usage of "AgentPools_ListByKubernetesCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +149,22 @@ public async Task Exists_GetKubernetesClusterAgentPool() // get the collection of this NetworkCloudAgentPoolResource NetworkCloudAgentPoolCollection collection = networkCloudKubernetesCluster.GetNetworkCloudAgentPools(); - // invoke the operation - string agentPoolName = "agentPoolName"; - bool result = await collection.ExistsAsync(agentPoolName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudAgentPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudAgentPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetKubernetesClusterAgentPool() + public async Task Exists_GetKubernetesClusterAgentPool() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/AgentPools_Get.json // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +187,17 @@ public async Task GetIfExists_GetKubernetesClusterAgentPool() // invoke the operation string agentPoolName = "agentPoolName"; - NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); - NetworkCloudAgentPoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(agentPoolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudAgentPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateKubernetesClusterAgentPool() + public async Task GetIfExists_GetKubernetesClusterAgentPool() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/AgentPools_Create.json - // this example is just showing the usage of "AgentPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/AgentPools_Get.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,76 +217,21 @@ public async Task CreateOrUpdate_CreateOrUpdateKubernetesClusterAgentPool() // invoke the operation string agentPoolName = "agentPoolName"; - NetworkCloudAgentPoolData data = new NetworkCloudAgentPoolData(new AzureLocation("location"), 3L, NetworkCloudAgentPoolMode.System, "NC_XXXX") - { - ExtendedLocation = new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), - AdministratorConfiguration = new AdministratorConfiguration() - { - AdminUsername = "azure", - SshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") -}, - }, - AgentOptions = new NetworkCloudAgentConfiguration(96L) - { - HugepagesSize = HugepagesSize.OneG, - }, - AttachedNetworkConfiguration = new AttachedNetworkConfiguration() - { - L2Networks = -{ -new L2NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName")) -{ -PluginType = KubernetesPluginType.Dpdk, -} -}, - L3Networks = -{ -new L3NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) -{ -IpamEnabled = L3NetworkConfigurationIpamEnabled.False, -PluginType = KubernetesPluginType.Sriov, -} -}, - TrunkedNetworks = -{ -new TrunkedNetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName")) -{ -PluginType = KubernetesPluginType.Macvlan, -} -}, - }, - AvailabilityZones = -{ -"1","2","3" -}, - Labels = -{ -new KubernetesLabel("kubernetes.label","true") -}, - Taints = -{ -new KubernetesLabel("kubernetes.taint","true") -}, - UpgradeSettings = new AgentPoolUpgradeSettings() - { - MaxSurge = "1", - }, - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); - NetworkCloudAgentPoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); + NetworkCloudAgentPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudAgentPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudAgentPoolResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudAgentPoolResource.cs index bdda22f42bd06..4da98a4b74a4d 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudAgentPoolResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudAgentPoolResource.cs @@ -69,19 +69,16 @@ public async Task Update_PatchKubernetesClusterAgentPool() NetworkCloudAgentPoolResource networkCloudAgentPool = client.GetNetworkCloudAgentPoolResource(networkCloudAgentPoolResourceId); // invoke the operation - NetworkCloudAgentPoolPatch patch = new NetworkCloudAgentPoolPatch() + NetworkCloudAgentPoolPatch patch = new NetworkCloudAgentPoolPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - AdministratorSshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") +["key2"] = "myvalue2" }, + AdministratorSshPublicKeys = { new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") }, Count = 3L, - UpgradeSettings = new AgentPoolUpgradeSettings() + UpgradeSettings = new AgentPoolUpgradeSettings { DrainTimeout = 1800L, MaxSurge = "1", diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineCollection.cs index ecf0bb33bc13e..1fd9e8df1fbeb 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkCloudBareMetalMachineCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBareMetalMachinesForResourceGroup() + public async Task Get_GetBareMetalMachine() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachines_ListByResourceGroup.json - // this example is just showing the usage of "BareMetalMachines_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachines_Get.json + // this example is just showing the usage of "BareMetalMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListBareMetalMachinesForResourceGroup() // get the collection of this NetworkCloudBareMetalMachineResource NetworkCloudBareMetalMachineCollection collection = resourceGroupResource.GetNetworkCloudBareMetalMachines(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudBareMetalMachineResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudBareMetalMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string bareMetalMachineName = "bareMetalMachineName"; + NetworkCloudBareMetalMachineResource result = await collection.GetAsync(bareMetalMachineName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudBareMetalMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetBareMetalMachine() + public async Task GetAll_ListBareMetalMachinesForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachines_Get.json - // this example is just showing the usage of "BareMetalMachines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachines_ListByResourceGroup.json + // this example is just showing the usage of "BareMetalMachines_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetBareMetalMachine() // get the collection of this NetworkCloudBareMetalMachineResource NetworkCloudBareMetalMachineCollection collection = resourceGroupResource.GetNetworkCloudBareMetalMachines(); - // invoke the operation - string bareMetalMachineName = "bareMetalMachineName"; - NetworkCloudBareMetalMachineResource result = await collection.GetAsync(bareMetalMachineName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudBareMetalMachineResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudBareMetalMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudBareMetalMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineKeySetCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineKeySetCollection.cs index 79557a58fd378..2a06b475f2776 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineKeySetCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineKeySetCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkCloudBareMetalMachineKeySetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBareMetalMachineKeySetsOfTheCluster() + public async Task CreateOrUpdate_CreateOrUpdateBareMetalMachineKeySetOfCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachineKeySets_ListByCluster.json - // this example is just showing the usage of "BareMetalMachineKeySets_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachineKeySets_Create.json + // this example is just showing the usage of "BareMetalMachineKeySets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,44 @@ public async Task GetAll_ListBareMetalMachineKeySetsOfTheCluster() // get the collection of this NetworkCloudBareMetalMachineKeySetResource NetworkCloudBareMetalMachineKeySetCollection collection = networkCloudCluster.GetNetworkCloudBareMetalMachineKeySets(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudBareMetalMachineKeySetResource item in collection.GetAllAsync()) + // invoke the operation + string bareMetalMachineKeySetName = "bareMetalMachineKeySetName"; + NetworkCloudBareMetalMachineKeySetData data = new NetworkCloudBareMetalMachineKeySetData( + new AzureLocation("location"), + new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), + "f110271b-XXXX-4163-9b99-214d91660f0e", + DateTimeOffset.Parse("2022-12-31T23:59:59.008Z"), + new IPAddress[] { IPAddress.Parse("192.0.2.1"), IPAddress.Parse("192.0.2.5") }, + BareMetalMachineKeySetPrivilegeLevel.Standard, + new KeySetUser[] { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudBareMetalMachineKeySetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } +new KeySetUser("userABC", new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) +{ +Description = "Needs access for troubleshooting as a part of the support team", +UserPrincipalName = "userABC@contoso.com", +}, +new KeySetUser("userXYZ", new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) +{ +Description = "Needs access for troubleshooting as a part of the support team", +UserPrincipalName = "userABC@contoso.com", +} + }) + { + OSGroupName = "standardAccessGroup", + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bareMetalMachineKeySetName, data); + NetworkCloudBareMetalMachineKeySetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudBareMetalMachineKeySetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +116,10 @@ public async Task Get_GetBareMetalMachineKeySetOfCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetBareMetalMachineKeySetOfCluster() + public async Task GetAll_ListBareMetalMachineKeySetsOfTheCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachineKeySets_Get.json - // this example is just showing the usage of "BareMetalMachineKeySets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachineKeySets_ListByCluster.json + // this example is just showing the usage of "BareMetalMachineKeySets_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +137,22 @@ public async Task Exists_GetBareMetalMachineKeySetOfCluster() // get the collection of this NetworkCloudBareMetalMachineKeySetResource NetworkCloudBareMetalMachineKeySetCollection collection = networkCloudCluster.GetNetworkCloudBareMetalMachineKeySets(); - // invoke the operation - string bareMetalMachineKeySetName = "bareMetalMachineKeySetName"; - bool result = await collection.ExistsAsync(bareMetalMachineKeySetName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudBareMetalMachineKeySetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudBareMetalMachineKeySetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetBareMetalMachineKeySetOfCluster() + public async Task Exists_GetBareMetalMachineKeySetOfCluster() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachineKeySets_Get.json // this example is just showing the usage of "BareMetalMachineKeySets_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +175,17 @@ public async Task GetIfExists_GetBareMetalMachineKeySetOfCluster() // invoke the operation string bareMetalMachineKeySetName = "bareMetalMachineKeySetName"; - NullableResponse response = await collection.GetIfExistsAsync(bareMetalMachineKeySetName); - NetworkCloudBareMetalMachineKeySetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(bareMetalMachineKeySetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudBareMetalMachineKeySetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateBareMetalMachineKeySetOfCluster() + public async Task GetIfExists_GetBareMetalMachineKeySetOfCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachineKeySets_Create.json - // this example is just showing the usage of "BareMetalMachineKeySets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachineKeySets_Get.json + // this example is just showing the usage of "BareMetalMachineKeySets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,37 +205,21 @@ public async Task CreateOrUpdate_CreateOrUpdateBareMetalMachineKeySetOfCluster() // invoke the operation string bareMetalMachineKeySetName = "bareMetalMachineKeySetName"; - NetworkCloudBareMetalMachineKeySetData data = new NetworkCloudBareMetalMachineKeySetData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), "f110271b-XXXX-4163-9b99-214d91660f0e", DateTimeOffset.Parse("2022-12-31T23:59:59.008Z"), new IPAddress[] - { -IPAddress.Parse("192.0.2.1"),IPAddress.Parse("192.0.2.5") - }, BareMetalMachineKeySetPrivilegeLevel.Standard, new KeySetUser[] + NullableResponse response = await collection.GetIfExistsAsync(bareMetalMachineKeySetName); + NetworkCloudBareMetalMachineKeySetResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new KeySetUser("userABC",new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) -{ -Description = "Needs access for troubleshooting as a part of the support team", -UserPrincipalName = "userABC@contoso.com", -},new KeySetUser("userXYZ",new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) -{ -Description = "Needs access for troubleshooting as a part of the support team", -UserPrincipalName = "userABC@contoso.com", -} - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - OSGroupName = "standardAccessGroup", - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bareMetalMachineKeySetName, data); - NetworkCloudBareMetalMachineKeySetResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudBareMetalMachineKeySetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudBareMetalMachineKeySetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineKeySetResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineKeySetResource.cs index eec6df13060f1..d7702759dd95d 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineKeySetResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineKeySetResource.cs @@ -70,30 +70,24 @@ public async Task Update_PatchBareMetalMachineKeySetOfCluster() NetworkCloudBareMetalMachineKeySetResource networkCloudBareMetalMachineKeySet = client.GetNetworkCloudBareMetalMachineKeySetResource(networkCloudBareMetalMachineKeySetResourceId); // invoke the operation - NetworkCloudBareMetalMachineKeySetPatch patch = new NetworkCloudBareMetalMachineKeySetPatch() + NetworkCloudBareMetalMachineKeySetPatch patch = new NetworkCloudBareMetalMachineKeySetPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, ExpireOn = DateTimeOffset.Parse("2022-12-31T23:59:59.008Z"), - JumpHostsAllowed = -{ -IPAddress.Parse("192.0.2.1"),IPAddress.Parse("192.0.2.5") -}, - UserList = -{ -new KeySetUser("userABC",new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) + JumpHostsAllowed = { IPAddress.Parse("192.0.2.1"), IPAddress.Parse("192.0.2.5") }, + UserList = {new KeySetUser("userABC", new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) { Description = "Needs access for troubleshooting as a part of the support team", UserPrincipalName = "userABC@contoso.com", -},new KeySetUser("userXYZ",new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) +}, new KeySetUser("userXYZ", new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) { Description = "Needs access for troubleshooting as a part of the support team", UserPrincipalName = "userABC@contoso.com", -} -}, +}}, }; ArmOperation lro = await networkCloudBareMetalMachineKeySet.UpdateAsync(WaitUntil.Completed, patch); NetworkCloudBareMetalMachineKeySetResource result = lro.Value; diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineResource.cs index 28db57dc977eb..4758d197ea191 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBareMetalMachineResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudBareMetalMachineResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudBareMetalMachines_ListBareMetalMachinesForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachines_ListBySubscription.json - // this example is just showing the usage of "BareMetalMachines_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudBareMetalMachineResource item in subscriptionResource.GetNetworkCloudBareMetalMachinesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudBareMetalMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetBareMetalMachine() @@ -99,12 +67,12 @@ public async Task Update_PatchBareMetalMachine() NetworkCloudBareMetalMachineResource networkCloudBareMetalMachine = client.GetNetworkCloudBareMetalMachineResource(networkCloudBareMetalMachineResourceId); // invoke the operation - NetworkCloudBareMetalMachinePatch patch = new NetworkCloudBareMetalMachinePatch() + NetworkCloudBareMetalMachinePatch patch = new NetworkCloudBareMetalMachinePatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, MachineDetails = "machinedetails", }; @@ -139,7 +107,7 @@ public async Task Cordon_CordonBareMetalMachine() NetworkCloudBareMetalMachineResource networkCloudBareMetalMachine = client.GetNetworkCloudBareMetalMachineResource(networkCloudBareMetalMachineResourceId); // invoke the operation - BareMetalMachineCordonContent content = new BareMetalMachineCordonContent() + BareMetalMachineCordonContent content = new BareMetalMachineCordonContent { Evacuate = BareMetalMachineEvacuate.True, }; @@ -170,7 +138,7 @@ public async Task PowerOff_PowerOffBareMetalMachine() NetworkCloudBareMetalMachineResource networkCloudBareMetalMachine = client.GetNetworkCloudBareMetalMachineResource(networkCloudBareMetalMachineResourceId); // invoke the operation - BareMetalMachinePowerOffContent content = new BareMetalMachinePowerOffContent() + BareMetalMachinePowerOffContent content = new BareMetalMachinePowerOffContent { SkipShutdown = BareMetalMachineSkipShutdown.True, }; @@ -228,7 +196,7 @@ public async Task Replace_ReplaceBareMetalMachine() NetworkCloudBareMetalMachineResource networkCloudBareMetalMachine = client.GetNetworkCloudBareMetalMachineResource(networkCloudBareMetalMachineResourceId); // invoke the operation - BareMetalMachineReplaceContent content = new BareMetalMachineReplaceContent() + BareMetalMachineReplaceContent content = new BareMetalMachineReplaceContent { BmcCredentials = new AdministrativeCredentials("bmcuser") { @@ -295,10 +263,7 @@ public async Task RunCommand_RunCommandOnBareMetalMachine() // invoke the operation BareMetalMachineRunCommandContent content = new BareMetalMachineRunCommandContent(60L, "cHdkCg==") { - Arguments = -{ -"--argument1","argument2" -}, + Arguments = { "--argument1", "argument2" }, }; ArmOperation lro = await networkCloudBareMetalMachine.RunCommandAsync(WaitUntil.Completed, content); NetworkCloudOperationStatusResult result = lro.Value; @@ -331,10 +296,7 @@ public async Task RunDataExtracts_RunDataExtractionOnBareMetalMachine() { new BareMetalMachineCommandSpecification("hardware-support-data-collection") { -Arguments = -{ -"SysInfo","TTYLog" -}, +Arguments = {"SysInfo", "TTYLog"}, } }, 60L); ArmOperation lro = await networkCloudBareMetalMachine.RunDataExtractsAsync(WaitUntil.Completed, content); @@ -368,16 +330,11 @@ public async Task RunReadCommands_RunAndRetrieveOutputFromReadOnlyCommandsOnBare { new BareMetalMachineCommandSpecification("kubectl get") { -Arguments = -{ -"pods","-A" +Arguments = {"pods", "-A"}, }, -},new BareMetalMachineCommandSpecification("ping") +new BareMetalMachineCommandSpecification("ping") { -Arguments = -{ -"192.168.0.99","-c","3" -}, +Arguments = {"192.168.0.99", "-c", "3"}, } }, 60L); ArmOperation lro = await networkCloudBareMetalMachine.RunReadCommandsAsync(WaitUntil.Completed, content); diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBmcKeySetCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBmcKeySetCollection.cs index 1a1f5129538bd..a762457b7274e 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBmcKeySetCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBmcKeySetCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkCloudBmcKeySetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBaseboardManagementControllerKeySetsOfTheCluster() + public async Task CreateOrUpdate_CreateOrUpdateBaseboardManagementControllerKeySetOfCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BmcKeySets_ListByCluster.json - // this example is just showing the usage of "BmcKeySets_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BmcKeySets_Create.json + // this example is just showing the usage of "BmcKeySets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,42 @@ public async Task GetAll_ListBaseboardManagementControllerKeySetsOfTheCluster() // get the collection of this NetworkCloudBmcKeySetResource NetworkCloudBmcKeySetCollection collection = networkCloudCluster.GetNetworkCloudBmcKeySets(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudBmcKeySetResource item in collection.GetAllAsync()) + // invoke the operation + string bmcKeySetName = "bmcKeySetName"; + NetworkCloudBmcKeySetData data = new NetworkCloudBmcKeySetData( + new AzureLocation("location"), + new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), + "f110271b-XXXX-4163-9b99-214d91660f0e", + DateTimeOffset.Parse("2022-12-31T23:59:59.008Z"), + BmcKeySetPrivilegeLevel.Administrator, + new KeySetUser[] { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudBmcKeySetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } +new KeySetUser("userABC", new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) +{ +Description = "Needs access for troubleshooting as a part of the support team", +UserPrincipalName = "userABC@contoso.com", +}, +new KeySetUser("userXYZ", new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) +{ +Description = "Needs access for troubleshooting as a part of the support team", +UserPrincipalName = "userABC@contoso.com", +} + }) + { + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bmcKeySetName, data); + NetworkCloudBmcKeySetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudBmcKeySetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +113,10 @@ public async Task Get_GetBaseboardManagementControllerKeySetOfCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetBaseboardManagementControllerKeySetOfCluster() + public async Task GetAll_ListBaseboardManagementControllerKeySetsOfTheCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BmcKeySets_Get.json - // this example is just showing the usage of "BmcKeySets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BmcKeySets_ListByCluster.json + // this example is just showing the usage of "BmcKeySets_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +134,22 @@ public async Task Exists_GetBaseboardManagementControllerKeySetOfCluster() // get the collection of this NetworkCloudBmcKeySetResource NetworkCloudBmcKeySetCollection collection = networkCloudCluster.GetNetworkCloudBmcKeySets(); - // invoke the operation - string bmcKeySetName = "bmcKeySetName"; - bool result = await collection.ExistsAsync(bmcKeySetName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudBmcKeySetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudBmcKeySetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetBaseboardManagementControllerKeySetOfCluster() + public async Task Exists_GetBaseboardManagementControllerKeySetOfCluster() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BmcKeySets_Get.json // this example is just showing the usage of "BmcKeySets_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +172,17 @@ public async Task GetIfExists_GetBaseboardManagementControllerKeySetOfCluster() // invoke the operation string bmcKeySetName = "bmcKeySetName"; - NullableResponse response = await collection.GetIfExistsAsync(bmcKeySetName); - NetworkCloudBmcKeySetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(bmcKeySetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudBmcKeySetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateBaseboardManagementControllerKeySetOfCluster() + public async Task GetIfExists_GetBaseboardManagementControllerKeySetOfCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BmcKeySets_Create.json - // this example is just showing the usage of "BmcKeySets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BmcKeySets_Get.json + // this example is just showing the usage of "BmcKeySets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,33 +202,21 @@ public async Task CreateOrUpdate_CreateOrUpdateBaseboardManagementControllerKeyS // invoke the operation string bmcKeySetName = "bmcKeySetName"; - NetworkCloudBmcKeySetData data = new NetworkCloudBmcKeySetData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), "f110271b-XXXX-4163-9b99-214d91660f0e", DateTimeOffset.Parse("2022-12-31T23:59:59.008Z"), BmcKeySetPrivilegeLevel.Administrator, new KeySetUser[] + NullableResponse response = await collection.GetIfExistsAsync(bmcKeySetName); + NetworkCloudBmcKeySetResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new KeySetUser("userABC",new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) -{ -Description = "Needs access for troubleshooting as a part of the support team", -UserPrincipalName = "userABC@contoso.com", -},new KeySetUser("userXYZ",new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) -{ -Description = "Needs access for troubleshooting as a part of the support team", -UserPrincipalName = "userABC@contoso.com", -} - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bmcKeySetName, data); - NetworkCloudBmcKeySetResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudBmcKeySetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudBmcKeySetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBmcKeySetResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBmcKeySetResource.cs index 1c9108f3d09c6..a79142ee3e19e 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBmcKeySetResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudBmcKeySetResource.cs @@ -69,26 +69,23 @@ public async Task Update_PatchBaseboardManagementControllerKeySetOfCluster() NetworkCloudBmcKeySetResource networkCloudBmcKeySet = client.GetNetworkCloudBmcKeySetResource(networkCloudBmcKeySetResourceId); // invoke the operation - NetworkCloudBmcKeySetPatch patch = new NetworkCloudBmcKeySetPatch() + NetworkCloudBmcKeySetPatch patch = new NetworkCloudBmcKeySetPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, ExpireOn = DateTimeOffset.Parse("2022-12-31T23:59:59.008Z"), - UserList = -{ -new KeySetUser("userABC",new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) + UserList = {new KeySetUser("userABC", new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) { Description = "Needs access for troubleshooting as a part of the support team", UserPrincipalName = "userABC@contoso.com", -},new KeySetUser("userXYZ",new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) +}, new KeySetUser("userXYZ", new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) { Description = "Needs access for troubleshooting as a part of the support team", UserPrincipalName = "userABC@contoso.com", -} -}, +}}, }; ArmOperation lro = await networkCloudBmcKeySet.UpdateAsync(WaitUntil.Completed, patch); NetworkCloudBmcKeySetResource result = lro.Value; diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudCloudServicesNetworkCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudCloudServicesNetworkCollection.cs index 29029020e890c..3561276ad2ab3 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudCloudServicesNetworkCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudCloudServicesNetworkCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkCloudCloudServicesNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCloudServicesNetworksForResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateCloudServicesNetwork() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/CloudServicesNetworks_ListByResourceGroup.json - // this example is just showing the usage of "CloudServicesNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/CloudServicesNetworks_Create.json + // this example is just showing the usage of "CloudServicesNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,32 @@ public async Task GetAll_ListCloudServicesNetworksForResourceGroup() // get the collection of this NetworkCloudCloudServicesNetworkResource NetworkCloudCloudServicesNetworkCollection collection = resourceGroupResource.GetNetworkCloudCloudServicesNetworks(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudCloudServicesNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string cloudServicesNetworkName = "cloudServicesNetworkName"; + NetworkCloudCloudServicesNetworkData data = new NetworkCloudCloudServicesNetworkData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudCloudServicesNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AdditionalEgressEndpoints = {new EgressEndpoint("azure-resource-management", new EndpointDependency[] +{ +new EndpointDependency("storageaccountex.blob.core.windows.net") +{ +Port = 443L, +} +})}, + EnableDefaultEgressEndpoints = CloudServicesNetworkEnableDefaultEgressEndpoint.False, + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudServicesNetworkName, data); + NetworkCloudCloudServicesNetworkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudCloudServicesNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +102,10 @@ public async Task Get_GetCloudServicesNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCloudServicesNetwork() + public async Task GetAll_ListCloudServicesNetworksForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/CloudServicesNetworks_Get.json - // this example is just showing the usage of "CloudServicesNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/CloudServicesNetworks_ListByResourceGroup.json + // this example is just showing the usage of "CloudServicesNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +122,22 @@ public async Task Exists_GetCloudServicesNetwork() // get the collection of this NetworkCloudCloudServicesNetworkResource NetworkCloudCloudServicesNetworkCollection collection = resourceGroupResource.GetNetworkCloudCloudServicesNetworks(); - // invoke the operation - string cloudServicesNetworkName = "cloudServicesNetworkName"; - bool result = await collection.ExistsAsync(cloudServicesNetworkName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudCloudServicesNetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudCloudServicesNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCloudServicesNetwork() + public async Task Exists_GetCloudServicesNetwork() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/CloudServicesNetworks_Get.json // this example is just showing the usage of "CloudServicesNetworks_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +159,17 @@ public async Task GetIfExists_GetCloudServicesNetwork() // invoke the operation string cloudServicesNetworkName = "cloudServicesNetworkName"; - NullableResponse response = await collection.GetIfExistsAsync(cloudServicesNetworkName); - NetworkCloudCloudServicesNetworkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(cloudServicesNetworkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudCloudServicesNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateCloudServicesNetwork() + public async Task GetIfExists_GetCloudServicesNetwork() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/CloudServicesNetworks_Create.json - // this example is just showing the usage of "CloudServicesNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/CloudServicesNetworks_Get.json + // this example is just showing the usage of "CloudServicesNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,33 +188,21 @@ public async Task CreateOrUpdate_CreateOrUpdateCloudServicesNetwork() // invoke the operation string cloudServicesNetworkName = "cloudServicesNetworkName"; - NetworkCloudCloudServicesNetworkData data = new NetworkCloudCloudServicesNetworkData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation")) - { - AdditionalEgressEndpoints = -{ -new EgressEndpoint("azure-resource-management",new EndpointDependency[] -{ -new EndpointDependency("storageaccountex.blob.core.windows.net") -{ -Port = 443L, -} -}) -}, - EnableDefaultEgressEndpoints = CloudServicesNetworkEnableDefaultEgressEndpoint.False, - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudServicesNetworkName, data); - NetworkCloudCloudServicesNetworkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(cloudServicesNetworkName); + NetworkCloudCloudServicesNetworkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudCloudServicesNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudCloudServicesNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudCloudServicesNetworkResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudCloudServicesNetworkResource.cs index 34e751fc9cc22..f7915628d53dc 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudCloudServicesNetworkResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudCloudServicesNetworkResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudCloudServicesNetworkResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudCloudServicesNetworks_ListCloudServicesNetworksForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/CloudServicesNetworks_ListBySubscription.json - // this example is just showing the usage of "CloudServicesNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudCloudServicesNetworkResource item in subscriptionResource.GetNetworkCloudCloudServicesNetworksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudCloudServicesNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetCloudServicesNetwork() @@ -99,23 +67,20 @@ public async Task Update_PatchCloudServicesNetwork() NetworkCloudCloudServicesNetworkResource networkCloudCloudServicesNetwork = client.GetNetworkCloudCloudServicesNetworkResource(networkCloudCloudServicesNetworkResourceId); // invoke the operation - NetworkCloudCloudServicesNetworkPatch patch = new NetworkCloudCloudServicesNetworkPatch() + NetworkCloudCloudServicesNetworkPatch patch = new NetworkCloudCloudServicesNetworkPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, - AdditionalEgressEndpoints = -{ -new EgressEndpoint("azure-resource-management",new EndpointDependency[] + AdditionalEgressEndpoints = {new EgressEndpoint("azure-resource-management", new EndpointDependency[] { new EndpointDependency("storageaccountex.blob.core.windows.net") { Port = 443L, } -}) -}, +})}, EnableDefaultEgressEndpoints = CloudServicesNetworkEnableDefaultEgressEndpoint.False, }; ArmOperation lro = await networkCloudCloudServicesNetwork.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterCollection.cs index dfe0d45cc3c22..7736592901f9f 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_NetworkCloudClusterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListClustersForResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Clusters_ListByResourceGroup.json - // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Clusters_Create.json + // this example is just showing the usage of "Clusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,119 @@ public async Task GetAll_ListClustersForResourceGroup() // get the collection of this NetworkCloudClusterResource NetworkCloudClusterCollection collection = resourceGroupResource.GetNetworkCloudClusters(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "clusterName"; + NetworkCloudClusterData data = new NetworkCloudClusterData( + new AzureLocation("location"), + new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterManagerExtendedLocationName", "CustomLocation"), + new NetworkCloudRackDefinition(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkRacks/networkRackName"), "AA1234", new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/providers/Microsoft.NetworkCloud/rackSkus/rackSkuName")) + { + BareMetalMachineConfigurationData = {new BareMetalMachineConfiguration(new AdministrativeCredentials("username") +{ +Password = "{password}", +}, "AA:BB:CC:DD:EE:FF", "00:BB:CC:DD:EE:FF", 1L, "BM1219XXX") +{ +MachineDetails = "extraDetails", +MachineName = "bmmName1", +}, new BareMetalMachineConfiguration(new AdministrativeCredentials("username") +{ +Password = "{password}", +}, "AA:BB:CC:DD:EE:00", "00:BB:CC:DD:EE:00", 2L, "BM1219YYY") +{ +MachineDetails = "extraDetails", +MachineName = "bmmName2", +}}, + RackLocation = "Foo Datacenter, Floor 3, Aisle 9, Rack 2", + StorageApplianceConfigurationData = {new StorageApplianceConfiguration(new AdministrativeCredentials("username") +{ +Password = "{password}", +}, 1L, "BM1219XXX") +{ +StorageApplianceName = "vmName", +}}, + }, + ClusterType.SingleRack, + "1.0.0", + new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkFabrics/fabricName")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1")] = new UserAssignedIdentity() +}, + }, + AnalyticsWorkspaceId = new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/microsoft.operationalInsights/workspaces/logAnalyticsWorkspaceName"), + ClusterLocation = "Foo Street, 3rd Floor, row 9", + ClusterServicePrincipal = new ServicePrincipalInformation("12345678-1234-1234-1234-123456789012", "00000008-0004-0004-0004-000000000012", "80000000-4000-4000-4000-120000000000") + { + Password = "{password}", + }, + CommandOutputSettings = new CommandOutputSettings + { + AssociatedIdentity = new IdentitySelector + { + IdentityType = ManagedServiceIdentitySelectorType.UserAssignedIdentity, + UserAssignedIdentityResourceId = new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1"), + }, + ContainerUri = new Uri("https://myaccount.blob.core.windows.net/mycontainer?restype=container"), + }, + ComputeDeploymentThreshold = new ValidationThreshold(ValidationThresholdGrouping.PerCluster, ValidationThresholdType.PercentSuccess, 90L), + ComputeRackDefinitions = {new NetworkCloudRackDefinition(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkRacks/networkRackName"), "AA1234", new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/providers/Microsoft.NetworkCloud/rackSkus/rackSkuName")) +{ +BareMetalMachineConfigurationData = {new BareMetalMachineConfiguration(new AdministrativeCredentials("username") +{ +Password = "{password}", +}, "AA:BB:CC:DD:EE:FF", "00:BB:CC:DD:EE:FF", 1L, "BM1219XXX") +{ +MachineDetails = "extraDetails", +MachineName = "bmmName1", +}, new BareMetalMachineConfiguration(new AdministrativeCredentials("username") +{ +Password = "{password}", +}, "AA:BB:CC:DD:EE:00", "00:BB:CC:DD:EE:00", 2L, "BM1219YYY") +{ +MachineDetails = "extraDetails", +MachineName = "bmmName2", +}}, +RackLocation = "Foo Datacenter, Floor 3, Aisle 9, Rack 2", +StorageApplianceConfigurationData = {new StorageApplianceConfiguration(new AdministrativeCredentials("username") +{ +Password = "{password}", +}, 1L, "BM1219XXX") +{ +StorageApplianceName = "vmName", +}}, +}}, + ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration + { + Location = new AzureLocation("East US"), + Name = "my-managed-rg", + }, + RuntimeProtectionEnforcementLevel = RuntimeProtectionEnforcementLevel.OnDemand, + SecretArchive = new ClusterSecretArchive(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.KeyVault/vaults/keyVaultName")) + { + UseKeyVault = ClusterSecretArchiveEnabled.True, + }, + UpdateStrategy = new ClusterUpdateStrategy(ClusterUpdateStrategyType.Rack, ValidationThresholdType.CountSuccess, 4L) + { + MaxUnavailable = 4L, + WaitTimeMinutes = 10L, + }, + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); + NetworkCloudClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +190,10 @@ public async Task Get_GetCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCluster() + public async Task GetAll_ListClustersForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Clusters_Get.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Clusters_ListByResourceGroup.json + // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +210,22 @@ public async Task Exists_GetCluster() // get the collection of this NetworkCloudClusterResource NetworkCloudClusterCollection collection = resourceGroupResource.GetNetworkCloudClusters(); - // invoke the operation - string clusterName = "clusterName"; - bool result = await collection.ExistsAsync(clusterName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCluster() + public async Task Exists_GetCluster() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Clusters_Get.json // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +247,17 @@ public async Task GetIfExists_GetCluster() // invoke the operation string clusterName = "clusterName"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - NetworkCloudClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateCluster() + public async Task GetIfExists_GetCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Clusters_Create.json - // this example is just showing the usage of "Clusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Clusters_Get.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,126 +276,21 @@ public async Task CreateOrUpdate_CreateOrUpdateCluster() // invoke the operation string clusterName = "clusterName"; - NetworkCloudClusterData data = new NetworkCloudClusterData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterManagerExtendedLocationName", "CustomLocation"), new NetworkCloudRackDefinition(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkRacks/networkRackName"), "AA1234", new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/providers/Microsoft.NetworkCloud/rackSkus/rackSkuName")) + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + NetworkCloudClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - BareMetalMachineConfigurationData = -{ -new BareMetalMachineConfiguration(new AdministrativeCredentials("username") -{ -Password = "{password}", -},"AA:BB:CC:DD:EE:FF","00:BB:CC:DD:EE:FF",1L,"BM1219XXX") -{ -MachineDetails = "extraDetails", -MachineName = "bmmName1", -},new BareMetalMachineConfiguration(new AdministrativeCredentials("username") -{ -Password = "{password}", -},"AA:BB:CC:DD:EE:00","00:BB:CC:DD:EE:00",2L,"BM1219YYY") -{ -MachineDetails = "extraDetails", -MachineName = "bmmName2", -} -}, - RackLocation = "Foo Datacenter, Floor 3, Aisle 9, Rack 2", - StorageApplianceConfigurationData = -{ -new StorageApplianceConfiguration(new AdministrativeCredentials("username") -{ -Password = "{password}", -},1L,"BM1219XXX") -{ -StorageApplianceName = "vmName", -} -}, - }, ClusterType.SingleRack, "1.0.0", new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkFabrics/fabricName")) + Console.WriteLine("Succeeded with null as result"); + } + else { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1")] = new UserAssignedIdentity(), -}, - }, - AnalyticsWorkspaceId = new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/microsoft.operationalInsights/workspaces/logAnalyticsWorkspaceName"), - ClusterLocation = "Foo Street, 3rd Floor, row 9", - ClusterServicePrincipal = new ServicePrincipalInformation("12345678-1234-1234-1234-123456789012", "00000008-0004-0004-0004-000000000012", "80000000-4000-4000-4000-120000000000") - { - Password = "{password}", - }, - CommandOutputSettings = new CommandOutputSettings() - { - AssociatedIdentity = new IdentitySelector() - { - IdentityType = ManagedServiceIdentitySelectorType.UserAssignedIdentity, - UserAssignedIdentityResourceId = new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1"), - }, - ContainerUri = new Uri("https://myaccount.blob.core.windows.net/mycontainer?restype=container"), - }, - ComputeDeploymentThreshold = new ValidationThreshold(ValidationThresholdGrouping.PerCluster, ValidationThresholdType.PercentSuccess, 90L), - ComputeRackDefinitions = -{ -new NetworkCloudRackDefinition(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkRacks/networkRackName"),"AA1234",new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/providers/Microsoft.NetworkCloud/rackSkus/rackSkuName")) -{ -BareMetalMachineConfigurationData = -{ -new BareMetalMachineConfiguration(new AdministrativeCredentials("username") -{ -Password = "{password}", -},"AA:BB:CC:DD:EE:FF","00:BB:CC:DD:EE:FF",1L,"BM1219XXX") -{ -MachineDetails = "extraDetails", -MachineName = "bmmName1", -},new BareMetalMachineConfiguration(new AdministrativeCredentials("username") -{ -Password = "{password}", -},"AA:BB:CC:DD:EE:00","00:BB:CC:DD:EE:00",2L,"BM1219YYY") -{ -MachineDetails = "extraDetails", -MachineName = "bmmName2", -} -}, -RackLocation = "Foo Datacenter, Floor 3, Aisle 9, Rack 2", -StorageApplianceConfigurationData = -{ -new StorageApplianceConfiguration(new AdministrativeCredentials("username") -{ -Password = "{password}", -},1L,"BM1219XXX") -{ -StorageApplianceName = "vmName", -} -}, -} -}, - ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration() - { - Location = new AzureLocation("East US"), - Name = "my-managed-rg", - }, - RuntimeProtectionEnforcementLevel = RuntimeProtectionEnforcementLevel.OnDemand, - SecretArchive = new ClusterSecretArchive(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.KeyVault/vaults/keyVaultName")) - { - UseKeyVault = ClusterSecretArchiveEnabled.True, - }, - UpdateStrategy = new ClusterUpdateStrategy(ClusterUpdateStrategyType.Rack, ValidationThresholdType.CountSuccess, 4L) - { - MaxUnavailable = 4L, - WaitTimeMinutes = 10L, - }, - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); - NetworkCloudClusterResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterManagerCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterManagerCollection.cs index 7155a8b7f02e2..7d1a3daf70c9f 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterManagerCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterManagerCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_NetworkCloudClusterManagerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListClusterManagersForResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateClusterManager() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_ListByResourceGroup.json - // this example is just showing the usage of "ClusterManagers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_Create.json + // this example is just showing the usage of "ClusterManagers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,39 @@ public async Task GetAll_ListClusterManagersForResourceGroup() // get the collection of this NetworkCloudClusterManagerResource NetworkCloudClusterManagerCollection collection = resourceGroupResource.GetNetworkCloudClusterManagers(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudClusterManagerResource item in collection.GetAllAsync()) + // invoke the operation + string clusterManagerName = "clusterManagerName"; + NetworkCloudClusterManagerData data = new NetworkCloudClusterManagerData(new AzureLocation("location"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkFabricControllers/fabricControllerName")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterManagerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("SystemAssigned"), + AnalyticsWorkspaceId = new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/microsoft.operationalInsights/workspaces/logAnalyticsWorkspaceName"), + ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration + { + Location = new AzureLocation("East US"), + Name = "my-managed-rg", + }, + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterManagerName, data); + NetworkCloudClusterManagerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterManagerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetClusterManager() + public async Task CreateOrUpdate_CreateOrUpdateClusterManagerWithUserAssignedIdentity() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_Get.json - // this example is just showing the usage of "ClusterManagers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_Create_Uami.json + // this example is just showing the usage of "ClusterManagers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +91,29 @@ public async Task Get_GetClusterManager() // invoke the operation string clusterManagerName = "clusterManagerName"; - NetworkCloudClusterManagerResource result = await collection.GetAsync(clusterManagerName); + NetworkCloudClusterManagerData data = new NetworkCloudClusterManagerData(new AzureLocation("location"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkFabricControllers/fabricControllerName")) + { + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1")] = new UserAssignedIdentity() +}, + }, + AnalyticsWorkspaceId = new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/microsoft.operationalInsights/workspaces/logAnalyticsWorkspaceName"), + ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration + { + Location = new AzureLocation("East US"), + Name = "my-managed-rg", + }, + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterManagerName, data); + NetworkCloudClusterManagerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +124,7 @@ public async Task Get_GetClusterManager() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetClusterManager() + public async Task Get_GetClusterManager() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_Get.json // this example is just showing the usage of "ClusterManagers_Get" operation, for the dependent resources, they will have to be created separately. @@ -110,17 +146,21 @@ public async Task Exists_GetClusterManager() // invoke the operation string clusterManagerName = "clusterManagerName"; - bool result = await collection.ExistsAsync(clusterManagerName); + NetworkCloudClusterManagerResource result = await collection.GetAsync(clusterManagerName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterManagerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetClusterManager() + public async Task GetAll_ListClusterManagersForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_Get.json - // this example is just showing the usage of "ClusterManagers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_ListByResourceGroup.json + // this example is just showing the usage of "ClusterManagers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,31 +177,25 @@ public async Task GetIfExists_GetClusterManager() // get the collection of this NetworkCloudClusterManagerResource NetworkCloudClusterManagerCollection collection = resourceGroupResource.GetNetworkCloudClusterManagers(); - // invoke the operation - string clusterManagerName = "clusterManagerName"; - NullableResponse response = await collection.GetIfExistsAsync(clusterManagerName); - NetworkCloudClusterManagerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NetworkCloudClusterManagerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkCloudClusterManagerData resourceData = result.Data; + NetworkCloudClusterManagerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateClusterManager() + public async Task Exists_GetClusterManager() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_Create.json - // this example is just showing the usage of "ClusterManagers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_Get.json + // this example is just showing the usage of "ClusterManagers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,37 +214,17 @@ public async Task CreateOrUpdate_CreateOrUpdateClusterManager() // invoke the operation string clusterManagerName = "clusterManagerName"; - NetworkCloudClusterManagerData data = new NetworkCloudClusterManagerData(new AzureLocation("location"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkFabricControllers/fabricControllerName")) - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - AnalyticsWorkspaceId = new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/microsoft.operationalInsights/workspaces/logAnalyticsWorkspaceName"), - ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration() - { - Location = new AzureLocation("East US"), - Name = "my-managed-rg", - }, - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterManagerName, data); - NetworkCloudClusterManagerResource result = lro.Value; + bool result = await collection.ExistsAsync(clusterManagerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterManagerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateClusterManagerWithUserAssignedIdentity() + public async Task GetIfExists_GetClusterManager() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_Create_Uami.json - // this example is just showing the usage of "ClusterManagers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_Get.json + // this example is just showing the usage of "ClusterManagers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -229,35 +243,21 @@ public async Task CreateOrUpdate_CreateOrUpdateClusterManagerWithUserAssignedIde // invoke the operation string clusterManagerName = "clusterManagerName"; - NetworkCloudClusterManagerData data = new NetworkCloudClusterManagerData(new AzureLocation("location"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkFabricControllers/fabricControllerName")) - { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1")] = new UserAssignedIdentity(), -}, - }, - AnalyticsWorkspaceId = new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/microsoft.operationalInsights/workspaces/logAnalyticsWorkspaceName"), - ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration() - { - Location = new AzureLocation("East US"), - Name = "my-managed-rg", - }, - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterManagerName, data); - NetworkCloudClusterManagerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(clusterManagerName); + NetworkCloudClusterManagerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterManagerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterManagerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterManagerResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterManagerResource.cs index c1efde5da9d85..821b79e279294 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterManagerResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterManagerResource.cs @@ -11,44 +11,12 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudClusterManagerResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudClusterManagers_ListClusterManagersForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_ListBySubscription.json - // this example is just showing the usage of "ClusterManagers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudClusterManagerResource item in subscriptionResource.GetNetworkCloudClusterManagersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterManagerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetClusterManager() @@ -100,20 +68,20 @@ public async Task Update_PatchClusterManager() NetworkCloudClusterManagerResource networkCloudClusterManager = client.GetNetworkCloudClusterManagerResource(networkCloudClusterManagerResourceId); // invoke the operation - NetworkCloudClusterManagerPatch patch = new NetworkCloudClusterManagerPatch() + NetworkCloudClusterManagerPatch patch = new NetworkCloudClusterManagerPatch { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1")] = null, -[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity2")] = new UserAssignedIdentity() }, }, Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, }; NetworkCloudClusterManagerResource result = await networkCloudClusterManager.UpdateAsync(patch); diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterMetricsConfigurationCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterMetricsConfigurationCollection.cs index 2c92abbae8677..09e07e4b03c19 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterMetricsConfigurationCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterMetricsConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkCloudClusterMetricsConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListMetricsConfigurationsOfTheCluster() + public async Task CreateOrUpdate_CreateOrUpdateMetricsConfigurationOfCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterMetricsConfigurations_ListByCluster.json - // this example is just showing the usage of "MetricsConfigurations_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterMetricsConfigurations_Create.json + // this example is just showing the usage of "MetricsConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ListMetricsConfigurationsOfTheCluster() // get the collection of this NetworkCloudClusterMetricsConfigurationResource NetworkCloudClusterMetricsConfigurationCollection collection = networkCloudCluster.GetNetworkCloudClusterMetricsConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudClusterMetricsConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string metricsConfigurationName = "default"; + NetworkCloudClusterMetricsConfigurationData data = new NetworkCloudClusterMetricsConfigurationData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), 15L) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterMetricsConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EnabledMetrics = { "metric1", "metric2" }, + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, metricsConfigurationName, data); + NetworkCloudClusterMetricsConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterMetricsConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetMetricsConfigurationOfCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMetricsConfigurationOfCluster() + public async Task GetAll_ListMetricsConfigurationsOfTheCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterMetricsConfigurations_Get.json - // this example is just showing the usage of "MetricsConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterMetricsConfigurations_ListByCluster.json + // this example is just showing the usage of "MetricsConfigurations_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetMetricsConfigurationOfCluster() // get the collection of this NetworkCloudClusterMetricsConfigurationResource NetworkCloudClusterMetricsConfigurationCollection collection = networkCloudCluster.GetNetworkCloudClusterMetricsConfigurations(); - // invoke the operation - string metricsConfigurationName = "default"; - bool result = await collection.ExistsAsync(metricsConfigurationName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudClusterMetricsConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterMetricsConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMetricsConfigurationOfCluster() + public async Task Exists_GetMetricsConfigurationOfCluster() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterMetricsConfigurations_Get.json // this example is just showing the usage of "MetricsConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetMetricsConfigurationOfCluster() // invoke the operation string metricsConfigurationName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(metricsConfigurationName); - NetworkCloudClusterMetricsConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(metricsConfigurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterMetricsConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateMetricsConfigurationOfCluster() + public async Task GetIfExists_GetMetricsConfigurationOfCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterMetricsConfigurations_Create.json - // this example is just showing the usage of "MetricsConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterMetricsConfigurations_Get.json + // this example is just showing the usage of "MetricsConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateMetricsConfigurationOfCluster() // invoke the operation string metricsConfigurationName = "default"; - NetworkCloudClusterMetricsConfigurationData data = new NetworkCloudClusterMetricsConfigurationData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), 15L) - { - EnabledMetrics = -{ -"metric1","metric2" -}, - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, metricsConfigurationName, data); - NetworkCloudClusterMetricsConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(metricsConfigurationName); + NetworkCloudClusterMetricsConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterMetricsConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterMetricsConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterMetricsConfigurationResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterMetricsConfigurationResource.cs index 86633244f42cc..e7ef962a33e04 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterMetricsConfigurationResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterMetricsConfigurationResource.cs @@ -69,18 +69,15 @@ public async Task Update_PatchMetricsConfigurationOfCluster() NetworkCloudClusterMetricsConfigurationResource networkCloudClusterMetricsConfiguration = client.GetNetworkCloudClusterMetricsConfigurationResource(networkCloudClusterMetricsConfigurationResourceId); // invoke the operation - NetworkCloudClusterMetricsConfigurationPatch patch = new NetworkCloudClusterMetricsConfigurationPatch() + NetworkCloudClusterMetricsConfigurationPatch patch = new NetworkCloudClusterMetricsConfigurationPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, CollectionInterval = 15L, - EnabledMetrics = -{ -"metric1","metric2" -}, + EnabledMetrics = { "metric1", "metric2" }, }; ArmOperation lro = await networkCloudClusterMetricsConfiguration.UpdateAsync(WaitUntil.Completed, patch); NetworkCloudClusterMetricsConfigurationResource result = lro.Value; diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterResource.cs index b24a2564ae93c..1fe68520e2ef2 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudClusterResource.cs @@ -11,44 +11,12 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudClusterResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudClusters_ListClustersForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Clusters_ListBySubscription.json - // this example is just showing the usage of "Clusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudClusterResource item in subscriptionResource.GetNetworkCloudClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetCluster() @@ -100,44 +68,38 @@ public async Task Update_PatchClusterAggregatorOrSingleRackDefinition() NetworkCloudClusterResource networkCloudCluster = client.GetNetworkCloudClusterResource(networkCloudClusterResourceId); // invoke the operation - NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch() + NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, AggregatorOrSingleRackDefinition = new NetworkCloudRackDefinition(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/networkRacks/networkRackName"), "newSerialNumber", new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/providers/Microsoft.NetworkCloud/rackSkus/rackSkuName")) { - BareMetalMachineConfigurationData = -{ -new BareMetalMachineConfiguration(new AdministrativeCredentials("username") + BareMetalMachineConfigurationData = {new BareMetalMachineConfiguration(new AdministrativeCredentials("username") { Password = "{password}", -},"AA:BB:CC:DD:EE:FF","00:BB:CC:DD:EE:FF",1L,"BM1219XXX") +}, "AA:BB:CC:DD:EE:FF", "00:BB:CC:DD:EE:FF", 1L, "BM1219XXX") { MachineDetails = "extraDetails", MachineName = "bmmName1", -},new BareMetalMachineConfiguration(new AdministrativeCredentials("username") +}, new BareMetalMachineConfiguration(new AdministrativeCredentials("username") { Password = "{password}", -},"AA:BB:CC:DD:EE:00","00:BB:CC:DD:EE:00",2L,"BM1219YYY") +}, "AA:BB:CC:DD:EE:00", "00:BB:CC:DD:EE:00", 2L, "BM1219YYY") { MachineDetails = "extraDetails", MachineName = "bmmName2", -} -}, +}}, RackLocation = "Foo Datacenter, Floor 3, Aisle 9, Rack 2", - StorageApplianceConfigurationData = -{ -new StorageApplianceConfiguration(new AdministrativeCredentials("username") + StorageApplianceConfigurationData = {new StorageApplianceConfiguration(new AdministrativeCredentials("username") { Password = "{password}", -},1L,"BM1219XXX") +}, 1L, "BM1219XXX") { StorageApplianceName = "vmName", -} -}, +}}, }, ComputeDeploymentThreshold = new ValidationThreshold(ValidationThresholdGrouping.PerCluster, ValidationThresholdType.PercentSuccess, 90L), }; @@ -172,24 +134,24 @@ public async Task Update_PatchClusterCommandOutput() NetworkCloudClusterResource networkCloudCluster = client.GetNetworkCloudClusterResource(networkCloudClusterResourceId); // invoke the operation - NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch() + NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1")] = null, -[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity2")] = new UserAssignedIdentity() }, }, Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, - CommandOutputSettings = new CommandOutputSettings() + CommandOutputSettings = new CommandOutputSettings { - AssociatedIdentity = new IdentitySelector() + AssociatedIdentity = new IdentitySelector { IdentityType = ManagedServiceIdentitySelectorType.UserAssignedIdentity, UserAssignedIdentityResourceId = new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/userIdentity2"), @@ -228,12 +190,12 @@ public async Task Update_PatchClusterLocation() NetworkCloudClusterResource networkCloudCluster = client.GetNetworkCloudClusterResource(networkCloudClusterResourceId); // invoke the operation - NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch() + NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, ClusterLocation = "Foo Street, 3rd Floor, row 9", }; @@ -268,12 +230,12 @@ public async Task Update_PatchRuntimeProtectionConfiguration() NetworkCloudClusterResource networkCloudCluster = client.GetNetworkCloudClusterResource(networkCloudClusterResourceId); // invoke the operation - NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch() + NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, RuntimeProtectionEnforcementLevel = RuntimeProtectionEnforcementLevel.OnDemand, }; @@ -308,12 +270,12 @@ public async Task Update_PatchSecretArchive() NetworkCloudClusterResource networkCloudCluster = client.GetNetworkCloudClusterResource(networkCloudClusterResourceId); // invoke the operation - NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch() + NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, SecretArchive = new ClusterSecretArchive(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.KeyVault/vaults/keyVaultName")) { @@ -351,12 +313,12 @@ public async Task Update_PatchUpdateStrategy() NetworkCloudClusterResource networkCloudCluster = client.GetNetworkCloudClusterResource(networkCloudClusterResourceId); // invoke the operation - NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch() + NetworkCloudClusterPatch patch = new NetworkCloudClusterPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, UpdateStrategy = new ClusterUpdateStrategy(ClusterUpdateStrategyType.Rack, ValidationThresholdType.CountSuccess, 4L) { @@ -395,7 +357,7 @@ public async Task ContinueUpdateVersion_ContinueUpdateClusterVersion() NetworkCloudClusterResource networkCloudCluster = client.GetNetworkCloudClusterResource(networkCloudClusterResourceId); // invoke the operation - ClusterContinueUpdateVersionContent content = new ClusterContinueUpdateVersionContent() + ClusterContinueUpdateVersionContent content = new ClusterContinueUpdateVersionContent { MachineGroupTargetingMode = ClusterContinueUpdateVersionMachineGroupTargetingMode.AlphaByRack, }; @@ -454,12 +416,9 @@ public async Task Deploy_DeployClusterSkippingValidation() NetworkCloudClusterResource networkCloudCluster = client.GetNetworkCloudClusterResource(networkCloudClusterResourceId); // invoke the operation - ClusterDeployContent content = new ClusterDeployContent() + ClusterDeployContent content = new ClusterDeployContent { - SkipValidationsForMachines = -{ -"bmmName1" -}, + SkipValidationsForMachines = { "bmmName1" }, }; ArmOperation lro = await networkCloudCluster.DeployAsync(WaitUntil.Completed, content: content); NetworkCloudOperationStatusResult result = lro.Value; @@ -488,7 +447,7 @@ public async Task ScanRuntime_ExecuteARuntimeProtectionScanOnTheCluster() NetworkCloudClusterResource networkCloudCluster = client.GetNetworkCloudClusterResource(networkCloudClusterResourceId); // invoke the operation - ClusterScanRuntimeContent content = new ClusterScanRuntimeContent() + ClusterScanRuntimeContent content = new ClusterScanRuntimeContent { ScanActivity = ClusterScanRuntimeParametersScanActivity.Scan, }; diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterCollection.cs index ad5028ab25f0c..4d2a3d4f47fac 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterCollection.cs @@ -18,144 +18,6 @@ namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudKubernetesClusterCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListKubernetesClustersForResourceGroup() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusters_ListByResourceGroup.json - // this example is just showing the usage of "KubernetesClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - string resourceGroupName = "resourceGroupName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this NetworkCloudKubernetesClusterResource - NetworkCloudKubernetesClusterCollection collection = resourceGroupResource.GetNetworkCloudKubernetesClusters(); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudKubernetesClusterResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudKubernetesClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetKubernetesCluster() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusters_Get.json - // this example is just showing the usage of "KubernetesClusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - string resourceGroupName = "resourceGroupName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this NetworkCloudKubernetesClusterResource - NetworkCloudKubernetesClusterCollection collection = resourceGroupResource.GetNetworkCloudKubernetesClusters(); - - // invoke the operation - string kubernetesClusterName = "kubernetesClusterName"; - NetworkCloudKubernetesClusterResource result = await collection.GetAsync(kubernetesClusterName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudKubernetesClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetKubernetesCluster() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusters_Get.json - // this example is just showing the usage of "KubernetesClusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - string resourceGroupName = "resourceGroupName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this NetworkCloudKubernetesClusterResource - NetworkCloudKubernetesClusterCollection collection = resourceGroupResource.GetNetworkCloudKubernetesClusters(); - - // invoke the operation - string kubernetesClusterName = "kubernetesClusterName"; - bool result = await collection.ExistsAsync(kubernetesClusterName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetKubernetesCluster() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusters_Get.json - // this example is just showing the usage of "KubernetesClusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - string resourceGroupName = "resourceGroupName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this NetworkCloudKubernetesClusterResource - NetworkCloudKubernetesClusterCollection collection = resourceGroupResource.GetNetworkCloudKubernetesClusters(); - - // invoke the operation - string kubernetesClusterName = "kubernetesClusterName"; - NullableResponse response = await collection.GetIfExistsAsync(kubernetesClusterName); - NetworkCloudKubernetesClusterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudKubernetesClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateKubernetesCluster() @@ -180,128 +42,84 @@ public async Task CreateOrUpdate_CreateOrUpdateKubernetesCluster() // invoke the operation string kubernetesClusterName = "kubernetesClusterName"; - NetworkCloudKubernetesClusterData data = new NetworkCloudKubernetesClusterData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), new ControlPlaneNodeConfiguration(3L, "NC_XXXX") - { - AdministratorConfiguration = new AdministratorConfiguration() + NetworkCloudKubernetesClusterData data = new NetworkCloudKubernetesClusterData( + new AzureLocation("location"), + new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), + new ControlPlaneNodeConfiguration(3L, "NC_XXXX") { - AdminUsername = "azure", - SshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") -}, + AdministratorConfiguration = new AdministratorConfiguration + { + AdminUsername = "azure", + SshPublicKeys = { new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") }, + }, + AvailabilityZones = { "1", "2", "3" }, }, - AvailabilityZones = -{ -"1","2","3" -}, - }, new InitialAgentPoolConfiguration[] + new InitialAgentPoolConfiguration[] { -new InitialAgentPoolConfiguration(3L,NetworkCloudAgentPoolMode.System,"SystemPool-1","NC_XXXX") +new InitialAgentPoolConfiguration(3L, NetworkCloudAgentPoolMode.System, "SystemPool-1", "NC_XXXX") { -AdministratorConfiguration = new AdministratorConfiguration() +AdministratorConfiguration = new AdministratorConfiguration { AdminUsername = "azure", -SshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") -}, +SshPublicKeys = {new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")}, }, AgentOptions = new NetworkCloudAgentConfiguration(96L) { HugepagesSize = HugepagesSize.OneG, }, -AttachedNetworkConfiguration = new AttachedNetworkConfiguration() -{ -L2Networks = +AttachedNetworkConfiguration = new AttachedNetworkConfiguration { -new L2NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName")) +L2Networks = {new L2NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName")) { PluginType = KubernetesPluginType.Dpdk, -} -}, -L3Networks = -{ -new L3NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) +}}, +L3Networks = {new L3NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) { IpamEnabled = L3NetworkConfigurationIpamEnabled.False, PluginType = KubernetesPluginType.Sriov, -} -}, -TrunkedNetworks = -{ -new TrunkedNetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName")) +}}, +TrunkedNetworks = {new TrunkedNetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName")) { PluginType = KubernetesPluginType.Macvlan, -} -}, -}, -AvailabilityZones = -{ -"1","2","3" -}, -Labels = -{ -new KubernetesLabel("kubernetes.label","true") +}}, }, -Taints = -{ -new KubernetesLabel("kubernetes.taint","true") -}, -UpgradeSettings = new AgentPoolUpgradeSettings() +AvailabilityZones = {"1", "2", "3"}, +Labels = {new KubernetesLabel("kubernetes.label", "true")}, +Taints = {new KubernetesLabel("kubernetes.taint", "true")}, +UpgradeSettings = new AgentPoolUpgradeSettings { MaxSurge = "1", }, } - }, "1.XX.Y", new KubernetesClusterNetworkConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) - { - AttachedNetworkConfiguration = new AttachedNetworkConfiguration() + }, + "1.XX.Y", + new KubernetesClusterNetworkConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) { - L2Networks = - { -new L2NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName")) + AttachedNetworkConfiguration = new AttachedNetworkConfiguration + { + L2Networks = {new L2NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName")) { PluginType = KubernetesPluginType.Dpdk, -} - }, - L3Networks = - { -new L3NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) +}}, + L3Networks = {new L3NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) { IpamEnabled = L3NetworkConfigurationIpamEnabled.False, PluginType = KubernetesPluginType.Sriov, -} - }, - TrunkedNetworks = - { -new TrunkedNetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName")) +}}, + TrunkedNetworks = {new TrunkedNetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName")) { PluginType = KubernetesPluginType.Macvlan, -} - }, - }, - BgpServiceLoadBalancerConfiguration = new BgpServiceLoadBalancerConfiguration() - { - BgpAdvertisements = - { -new BgpAdvertisement(new string[] -{ -"pool1" -}) +}}, + }, + BgpServiceLoadBalancerConfiguration = new BgpServiceLoadBalancerConfiguration + { + BgpAdvertisements = {new BgpAdvertisement(new string[]{"pool1"}) { AdvertiseToFabric = AdvertiseToFabric.True, -Communities = -{ -"64512:100" -}, -Peers = -{ -"peer1" -}, -} - }, - BgpPeers = - { -new ServiceLoadBalancerBgpPeer("peer1","203.0.113.254",64497L) +Communities = {"64512:100"}, +Peers = {"peer1"}, +}}, + BgpPeers = {new ServiceLoadBalancerBgpPeer("peer1", "203.0.113.254", 64497L) { BfdEnabled = BfdEnabled.False, BgpMultiHop = BgpMultiHop.False, @@ -309,45 +127,26 @@ public async Task CreateOrUpdate_CreateOrUpdateKubernetesCluster() KeepAliveTime = "P300s", MyAsn = 64512L, PeerPort = 179L, -} - }, - FabricPeeringEnabled = FabricPeeringEnabled.True, - IPAddressPools = - { -new IPAddressPool(new string[] -{ -"198.51.102.0/24" -},"pool1") +}}, + FabricPeeringEnabled = FabricPeeringEnabled.True, + IPAddressPools = {new IPAddressPool(new string[]{"198.51.102.0/24"}, "pool1") { AutoAssign = BfdEnabled.True, OnlyUseHostIPs = BfdEnabled.True, -} - }, - }, - DnsServiceIP = IPAddress.Parse("198.51.101.2"), - PodCidrs = - { -"198.51.100.0/24" - }, - ServiceCidrs = +}}, + }, + DnsServiceIP = IPAddress.Parse("198.51.101.2"), + PodCidrs = { "198.51.100.0/24" }, + ServiceCidrs = { "198.51.101.0/24" }, + }) { -"198.51.101.0/24" - }, - }) - { - AadAdminGroupObjectIds = -{ -"ffffffff-ffff-ffff-ffff-ffffffffffff" -}, - AdministratorConfiguration = new AdministratorConfiguration() + AadAdminGroupObjectIds = { "ffffffff-ffff-ffff-ffff-ffffffffffff" }, + AdministratorConfiguration = new AdministratorConfiguration { AdminUsername = "azure", - SshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") -}, + SshPublicKeys = { new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") }, }, - ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration() + ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration { Location = new AzureLocation("East US"), Name = "my-managed-rg", @@ -355,7 +154,7 @@ public async Task CreateOrUpdate_CreateOrUpdateKubernetesCluster() Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, kubernetesClusterName, data); @@ -392,139 +191,91 @@ public async Task CreateOrUpdate_CreateOrUpdateKubernetesClusterWithALayer2LoadB // invoke the operation string kubernetesClusterName = "kubernetesClusterName"; - NetworkCloudKubernetesClusterData data = new NetworkCloudKubernetesClusterData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), new ControlPlaneNodeConfiguration(3L, "NC_XXXX") - { - AdministratorConfiguration = new AdministratorConfiguration() + NetworkCloudKubernetesClusterData data = new NetworkCloudKubernetesClusterData( + new AzureLocation("location"), + new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), + new ControlPlaneNodeConfiguration(3L, "NC_XXXX") { - AdminUsername = "azure", - SshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") -}, + AdministratorConfiguration = new AdministratorConfiguration + { + AdminUsername = "azure", + SshPublicKeys = { new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") }, + }, + AvailabilityZones = { "1", "2", "3" }, }, - AvailabilityZones = -{ -"1","2","3" -}, - }, new InitialAgentPoolConfiguration[] + new InitialAgentPoolConfiguration[] { -new InitialAgentPoolConfiguration(3L,NetworkCloudAgentPoolMode.System,"SystemPool-1","NC_XXXX") +new InitialAgentPoolConfiguration(3L, NetworkCloudAgentPoolMode.System, "SystemPool-1", "NC_XXXX") { -AdministratorConfiguration = new AdministratorConfiguration() +AdministratorConfiguration = new AdministratorConfiguration { AdminUsername = "azure", -SshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") -}, +SshPublicKeys = {new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")}, }, AgentOptions = new NetworkCloudAgentConfiguration(96L) { HugepagesSize = HugepagesSize.OneG, }, -AttachedNetworkConfiguration = new AttachedNetworkConfiguration() -{ -L2Networks = +AttachedNetworkConfiguration = new AttachedNetworkConfiguration { -new L2NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName")) +L2Networks = {new L2NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName")) { PluginType = KubernetesPluginType.Dpdk, -} -}, -L3Networks = -{ -new L3NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) +}}, +L3Networks = {new L3NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) { IpamEnabled = L3NetworkConfigurationIpamEnabled.False, PluginType = KubernetesPluginType.Sriov, -} -}, -TrunkedNetworks = -{ -new TrunkedNetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName")) +}}, +TrunkedNetworks = {new TrunkedNetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName")) { PluginType = KubernetesPluginType.Macvlan, -} -}, -}, -AvailabilityZones = -{ -"1","2","3" -}, -Labels = -{ -new KubernetesLabel("kubernetes.label","true") +}}, }, -Taints = -{ -new KubernetesLabel("kubernetes.taint","true") -}, -UpgradeSettings = new AgentPoolUpgradeSettings() +AvailabilityZones = {"1", "2", "3"}, +Labels = {new KubernetesLabel("kubernetes.label", "true")}, +Taints = {new KubernetesLabel("kubernetes.taint", "true")}, +UpgradeSettings = new AgentPoolUpgradeSettings { MaxSurge = "1", }, } - }, "1.XX.Y", new KubernetesClusterNetworkConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) - { - AttachedNetworkConfiguration = new AttachedNetworkConfiguration() + }, + "1.XX.Y", + new KubernetesClusterNetworkConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) { - L2Networks = - { -new L2NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName")) + AttachedNetworkConfiguration = new AttachedNetworkConfiguration + { + L2Networks = {new L2NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l2Networks/l2NetworkName")) { PluginType = KubernetesPluginType.Dpdk, -} - }, - L3Networks = - { -new L3NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) +}}, + L3Networks = {new L3NetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName")) { IpamEnabled = L3NetworkConfigurationIpamEnabled.False, PluginType = KubernetesPluginType.Sriov, -} - }, - TrunkedNetworks = - { -new TrunkedNetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName")) +}}, + TrunkedNetworks = {new TrunkedNetworkAttachmentConfiguration(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/trunkedNetworks/trunkedNetworkName")) { PluginType = KubernetesPluginType.Macvlan, -} - }, - }, - DnsServiceIP = IPAddress.Parse("198.51.101.2"), - L2ServiceLoadBalancerIPAddressPools = - { -new IPAddressPool(new string[] -{ -"198.51.102.2-198.51.102.254" -},"pool1") +}}, + }, + DnsServiceIP = IPAddress.Parse("198.51.101.2"), + L2ServiceLoadBalancerIPAddressPools = {new IPAddressPool(new string[]{"198.51.102.2-198.51.102.254"}, "pool1") { AutoAssign = BfdEnabled.True, -} - }, - PodCidrs = - { -"198.51.100.0/24" - }, - ServiceCidrs = - { -"198.51.101.0/24" - }, - }) +}}, + PodCidrs = { "198.51.100.0/24" }, + ServiceCidrs = { "198.51.101.0/24" }, + }) { - AadAdminGroupObjectIds = -{ -"ffffffff-ffff-ffff-ffff-ffffffffffff" -}, - AdministratorConfiguration = new AdministratorConfiguration() + AadAdminGroupObjectIds = { "ffffffff-ffff-ffff-ffff-ffffffffffff" }, + AdministratorConfiguration = new AdministratorConfiguration { AdminUsername = "azure", - SshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") -}, + SshPublicKeys = { new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") }, }, - ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration() + ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration { Location = new AzureLocation("East US"), Name = "my-managed-rg", @@ -532,7 +283,7 @@ public async Task CreateOrUpdate_CreateOrUpdateKubernetesClusterWithALayer2LoadB Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, kubernetesClusterName, data); @@ -544,5 +295,143 @@ public async Task CreateOrUpdate_CreateOrUpdateKubernetesClusterWithALayer2LoadB // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetKubernetesCluster() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusters_Get.json + // this example is just showing the usage of "KubernetesClusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + string resourceGroupName = "resourceGroupName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkCloudKubernetesClusterResource + NetworkCloudKubernetesClusterCollection collection = resourceGroupResource.GetNetworkCloudKubernetesClusters(); + + // invoke the operation + string kubernetesClusterName = "kubernetesClusterName"; + NetworkCloudKubernetesClusterResource result = await collection.GetAsync(kubernetesClusterName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudKubernetesClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListKubernetesClustersForResourceGroup() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusters_ListByResourceGroup.json + // this example is just showing the usage of "KubernetesClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + string resourceGroupName = "resourceGroupName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkCloudKubernetesClusterResource + NetworkCloudKubernetesClusterCollection collection = resourceGroupResource.GetNetworkCloudKubernetesClusters(); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudKubernetesClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudKubernetesClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetKubernetesCluster() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusters_Get.json + // this example is just showing the usage of "KubernetesClusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + string resourceGroupName = "resourceGroupName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkCloudKubernetesClusterResource + NetworkCloudKubernetesClusterCollection collection = resourceGroupResource.GetNetworkCloudKubernetesClusters(); + + // invoke the operation + string kubernetesClusterName = "kubernetesClusterName"; + bool result = await collection.ExistsAsync(kubernetesClusterName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetKubernetesCluster() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusters_Get.json + // this example is just showing the usage of "KubernetesClusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + string resourceGroupName = "resourceGroupName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkCloudKubernetesClusterResource + NetworkCloudKubernetesClusterCollection collection = resourceGroupResource.GetNetworkCloudKubernetesClusters(); + + // invoke the operation + string kubernetesClusterName = "kubernetesClusterName"; + NullableResponse response = await collection.GetIfExistsAsync(kubernetesClusterName); + NetworkCloudKubernetesClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudKubernetesClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterFeatureCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterFeatureCollection.cs index 13d332ed021e1..758c59fc9a3b9 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterFeatureCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterFeatureCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkCloudKubernetesClusterFeatureCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFeaturesForTheKubernetesCluster() + public async Task CreateOrUpdate_CreateOrUpdateKubernetesClusterFeature() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusterFeatures_ListByKubernetesCluster.json - // this example is just showing the usage of "KubernetesClusterFeatures_ListByKubernetesCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusterFeatures_Create.json + // this example is just showing the usage of "KubernetesClusterFeatures_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ListFeaturesForTheKubernetesCluster() // get the collection of this NetworkCloudKubernetesClusterFeatureResource NetworkCloudKubernetesClusterFeatureCollection collection = networkCloudKubernetesCluster.GetNetworkCloudKubernetesClusterFeatures(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudKubernetesClusterFeatureResource item in collection.GetAllAsync()) + // invoke the operation + string featureName = "featureName"; + NetworkCloudKubernetesClusterFeatureData data = new NetworkCloudKubernetesClusterFeatureData(new AzureLocation("location")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudKubernetesClusterFeatureData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Options = { new StringKeyValuePair("featureOptionName", "featureOptionValue") }, + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, featureName, data); + NetworkCloudKubernetesClusterFeatureResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudKubernetesClusterFeatureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetKubernetesClusterFeature() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetKubernetesClusterFeature() + public async Task GetAll_ListFeaturesForTheKubernetesCluster() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusterFeatures_Get.json - // this example is just showing the usage of "KubernetesClusterFeatures_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusterFeatures_ListByKubernetesCluster.json + // this example is just showing the usage of "KubernetesClusterFeatures_ListByKubernetesCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetKubernetesClusterFeature() // get the collection of this NetworkCloudKubernetesClusterFeatureResource NetworkCloudKubernetesClusterFeatureCollection collection = networkCloudKubernetesCluster.GetNetworkCloudKubernetesClusterFeatures(); - // invoke the operation - string featureName = "featureName"; - bool result = await collection.ExistsAsync(featureName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudKubernetesClusterFeatureResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudKubernetesClusterFeatureData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetKubernetesClusterFeature() + public async Task Exists_GetKubernetesClusterFeature() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusterFeatures_Get.json // this example is just showing the usage of "KubernetesClusterFeatures_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetKubernetesClusterFeature() // invoke the operation string featureName = "featureName"; - NullableResponse response = await collection.GetIfExistsAsync(featureName); - NetworkCloudKubernetesClusterFeatureResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(featureName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudKubernetesClusterFeatureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateKubernetesClusterFeature() + public async Task GetIfExists_GetKubernetesClusterFeature() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusterFeatures_Create.json - // this example is just showing the usage of "KubernetesClusterFeatures_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusterFeatures_Get.json + // this example is just showing the usage of "KubernetesClusterFeatures_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateKubernetesClusterFeature() // invoke the operation string featureName = "featureName"; - NetworkCloudKubernetesClusterFeatureData data = new NetworkCloudKubernetesClusterFeatureData(new AzureLocation("location")) - { - Options = -{ -new StringKeyValuePair("featureOptionName","featureOptionValue") -}, - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, featureName, data); - NetworkCloudKubernetesClusterFeatureResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(featureName); + NetworkCloudKubernetesClusterFeatureResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudKubernetesClusterFeatureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudKubernetesClusterFeatureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterFeatureResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterFeatureResource.cs index 016105a0160dd..f5d8e0f43c23f 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterFeatureResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterFeatureResource.cs @@ -97,17 +97,14 @@ public async Task Update_PatchKubernetesClusterFeature() NetworkCloudKubernetesClusterFeatureResource networkCloudKubernetesClusterFeature = client.GetNetworkCloudKubernetesClusterFeatureResource(networkCloudKubernetesClusterFeatureResourceId); // invoke the operation - NetworkCloudKubernetesClusterFeaturePatch patch = new NetworkCloudKubernetesClusterFeaturePatch() + NetworkCloudKubernetesClusterFeaturePatch patch = new NetworkCloudKubernetesClusterFeaturePatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - Options = -{ -new StringKeyValuePair("featureOptionName","featureOptionValue") +["key2"] = "myvalue2" }, + Options = { new StringKeyValuePair("featureOptionName", "featureOptionValue") }, }; ArmOperation lro = await networkCloudKubernetesClusterFeature.UpdateAsync(WaitUntil.Completed, patch); NetworkCloudKubernetesClusterFeatureResource result = lro.Value; diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterResource.cs index 5992b8e86292e..50f6bed4b34a9 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudKubernetesClusterResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudKubernetesClusterResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudKubernetesClusters_ListKubernetesClustersForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusters_ListBySubscription.json - // this example is just showing the usage of "KubernetesClusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudKubernetesClusterResource item in subscriptionResource.GetNetworkCloudKubernetesClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudKubernetesClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetKubernetesCluster() @@ -99,23 +67,17 @@ public async Task Update_PatchKubernetesCluster() NetworkCloudKubernetesClusterResource networkCloudKubernetesCluster = client.GetNetworkCloudKubernetesClusterResource(networkCloudKubernetesClusterResourceId); // invoke the operation - NetworkCloudKubernetesClusterPatch patch = new NetworkCloudKubernetesClusterPatch() + NetworkCloudKubernetesClusterPatch patch = new NetworkCloudKubernetesClusterPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, - AdministratorSshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") -}, - ControlPlaneNodeConfiguration = new ControlPlaneNodePatchConfiguration() + AdministratorSshPublicKeys = { new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") }, + ControlPlaneNodeConfiguration = new ControlPlaneNodePatchConfiguration { - AdministratorSshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") -}, + AdministratorSshPublicKeys = { new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") }, Count = 3L, }, KubernetesVersion = "1.XX.Y", diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL2NetworkCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL2NetworkCollection.cs index acf8d8df33929..32c7ce34c38a3 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL2NetworkCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL2NetworkCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkCloudL2NetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListL2NetworksForResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateL2Network() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L2Networks_ListByResourceGroup.json - // this example is just showing the usage of "L2Networks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L2Networks_Create.json + // this example is just showing the usage of "L2Networks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,26 @@ public async Task GetAll_ListL2NetworksForResourceGroup() // get the collection of this NetworkCloudL2NetworkResource NetworkCloudL2NetworkCollection collection = resourceGroupResource.GetNetworkCloudL2Networks(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudL2NetworkResource item in collection.GetAllAsync()) + // invoke the operation + string l2NetworkName = "l2NetworkName"; + NetworkCloudL2NetworkData data = new NetworkCloudL2NetworkData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/l2IsolationDomains/l2IsolationDomainName")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudL2NetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HybridAksPluginType = HybridAksPluginType.Dpdk, + InterfaceName = "eth0", + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, l2NetworkName, data); + NetworkCloudL2NetworkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudL2NetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +96,10 @@ public async Task Get_GetL2Network() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetL2Network() + public async Task GetAll_ListL2NetworksForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L2Networks_Get.json - // this example is just showing the usage of "L2Networks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L2Networks_ListByResourceGroup.json + // this example is just showing the usage of "L2Networks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +116,22 @@ public async Task Exists_GetL2Network() // get the collection of this NetworkCloudL2NetworkResource NetworkCloudL2NetworkCollection collection = resourceGroupResource.GetNetworkCloudL2Networks(); - // invoke the operation - string l2NetworkName = "l2NetworkName"; - bool result = await collection.ExistsAsync(l2NetworkName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudL2NetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudL2NetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetL2Network() + public async Task Exists_GetL2Network() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L2Networks_Get.json // this example is just showing the usage of "L2Networks_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +153,17 @@ public async Task GetIfExists_GetL2Network() // invoke the operation string l2NetworkName = "l2NetworkName"; - NullableResponse response = await collection.GetIfExistsAsync(l2NetworkName); - NetworkCloudL2NetworkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(l2NetworkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudL2NetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateL2Network() + public async Task GetIfExists_GetL2Network() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L2Networks_Create.json - // this example is just showing the usage of "L2Networks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L2Networks_Get.json + // this example is just showing the usage of "L2Networks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,24 +182,21 @@ public async Task CreateOrUpdate_CreateOrUpdateL2Network() // invoke the operation string l2NetworkName = "l2NetworkName"; - NetworkCloudL2NetworkData data = new NetworkCloudL2NetworkData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/l2IsolationDomains/l2IsolationDomainName")) - { - HybridAksPluginType = HybridAksPluginType.Dpdk, - InterfaceName = "eth0", - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, l2NetworkName, data); - NetworkCloudL2NetworkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(l2NetworkName); + NetworkCloudL2NetworkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudL2NetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudL2NetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL2NetworkResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL2NetworkResource.cs index 9e3384f807653..2aed03f416cce 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL2NetworkResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL2NetworkResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudL2NetworkResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudL2Networks_ListL2NetworksForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L2Networks_ListBySubscription.json - // this example is just showing the usage of "L2Networks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudL2NetworkResource item in subscriptionResource.GetNetworkCloudL2NetworksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudL2NetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetL2Network() @@ -99,12 +67,12 @@ public async Task Update_PatchL2Network() NetworkCloudL2NetworkResource networkCloudL2Network = client.GetNetworkCloudL2NetworkResource(networkCloudL2NetworkResourceId); // invoke the operation - NetworkCloudL2NetworkPatch patch = new NetworkCloudL2NetworkPatch() + NetworkCloudL2NetworkPatch patch = new NetworkCloudL2NetworkPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, }; NetworkCloudL2NetworkResource result = await networkCloudL2Network.UpdateAsync(patch); diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL3NetworkCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL3NetworkCollection.cs index 36dff73c78c6a..367ae24f94546 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL3NetworkCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL3NetworkCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkCloudL3NetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListL3NetworksForResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateL3Network() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L3Networks_ListByResourceGroup.json - // this example is just showing the usage of "L3Networks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L3Networks_Create.json + // this example is just showing the usage of "L3Networks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,28 @@ public async Task GetAll_ListL3NetworksForResourceGroup() // get the collection of this NetworkCloudL3NetworkResource NetworkCloudL3NetworkCollection collection = resourceGroupResource.GetNetworkCloudL3Networks(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudL3NetworkResource item in collection.GetAllAsync()) + // invoke the operation + string l3NetworkName = "l3NetworkName"; + NetworkCloudL3NetworkData data = new NetworkCloudL3NetworkData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/l3IsolationDomains/l3IsolationDomainName"), 12L) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudL3NetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + InterfaceName = "eth0", + IPAllocationType = IPAllocationType.DualStack, + IPv4ConnectedPrefix = "198.51.100.0/24", + IPv6ConnectedPrefix = "2001:db8::/64", + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, l3NetworkName, data); + NetworkCloudL3NetworkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudL3NetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +98,10 @@ public async Task Get_GetL3network() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetL3network() + public async Task GetAll_ListL3NetworksForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L3Networks_Get.json - // this example is just showing the usage of "L3Networks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L3Networks_ListByResourceGroup.json + // this example is just showing the usage of "L3Networks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +118,22 @@ public async Task Exists_GetL3network() // get the collection of this NetworkCloudL3NetworkResource NetworkCloudL3NetworkCollection collection = resourceGroupResource.GetNetworkCloudL3Networks(); - // invoke the operation - string l3NetworkName = "l3NetworkName"; - bool result = await collection.ExistsAsync(l3NetworkName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudL3NetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudL3NetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetL3network() + public async Task Exists_GetL3network() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L3Networks_Get.json // this example is just showing the usage of "L3Networks_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +155,17 @@ public async Task GetIfExists_GetL3network() // invoke the operation string l3NetworkName = "l3NetworkName"; - NullableResponse response = await collection.GetIfExistsAsync(l3NetworkName); - NetworkCloudL3NetworkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(l3NetworkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudL3NetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateL3Network() + public async Task GetIfExists_GetL3network() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L3Networks_Create.json - // this example is just showing the usage of "L3Networks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L3Networks_Get.json + // this example is just showing the usage of "L3Networks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,26 +184,21 @@ public async Task CreateOrUpdate_CreateOrUpdateL3Network() // invoke the operation string l3NetworkName = "l3NetworkName"; - NetworkCloudL3NetworkData data = new NetworkCloudL3NetworkData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/l3IsolationDomains/l3IsolationDomainName"), 12L) - { - InterfaceName = "eth0", - IPAllocationType = IPAllocationType.DualStack, - IPv4ConnectedPrefix = "198.51.100.0/24", - IPv6ConnectedPrefix = "2001:db8::/64", - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, l3NetworkName, data); - NetworkCloudL3NetworkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(l3NetworkName); + NetworkCloudL3NetworkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudL3NetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudL3NetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL3NetworkResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL3NetworkResource.cs index 7d711009a781d..f75ef4d840ee5 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL3NetworkResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudL3NetworkResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudL3NetworkResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudL3Networks_ListL3NetworksForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L3Networks_ListBySubscription.json - // this example is just showing the usage of "L3Networks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudL3NetworkResource item in subscriptionResource.GetNetworkCloudL3NetworksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudL3NetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetL3network() @@ -99,12 +67,12 @@ public async Task Update_PatchL3Network() NetworkCloudL3NetworkResource networkCloudL3Network = client.GetNetworkCloudL3NetworkResource(networkCloudL3NetworkResourceId); // invoke the operation - NetworkCloudL3NetworkPatch patch = new NetworkCloudL3NetworkPatch() + NetworkCloudL3NetworkPatch patch = new NetworkCloudL3NetworkPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, }; NetworkCloudL3NetworkResource result = await networkCloudL3Network.UpdateAsync(patch); diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackCollection.cs index fdc533d28c412..d8052564fadc7 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkCloudRackCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRacksForResourceGroup() + public async Task Get_GetRack() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Racks_ListByResourceGroup.json - // this example is just showing the usage of "Racks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Racks_Get.json + // this example is just showing the usage of "Racks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListRacksForResourceGroup() // get the collection of this NetworkCloudRackResource NetworkCloudRackCollection collection = resourceGroupResource.GetNetworkCloudRacks(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudRackResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudRackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string rackName = "rackName"; + NetworkCloudRackResource result = await collection.GetAsync(rackName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudRackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRack() + public async Task GetAll_ListRacksForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Racks_Get.json - // this example is just showing the usage of "Racks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Racks_ListByResourceGroup.json + // this example is just showing the usage of "Racks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetRack() // get the collection of this NetworkCloudRackResource NetworkCloudRackCollection collection = resourceGroupResource.GetNetworkCloudRacks(); - // invoke the operation - string rackName = "rackName"; - NetworkCloudRackResource result = await collection.GetAsync(rackName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudRackResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudRackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudRackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackResource.cs index 40cd992dc361a..b55e17177f5eb 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudRackResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudRacks_ListRacksForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Racks_ListBySubscription.json - // this example is just showing the usage of "Racks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudRackResource item in subscriptionResource.GetNetworkCloudRacksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudRackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetRack() @@ -99,12 +67,12 @@ public async Task Update_PatchRack() NetworkCloudRackResource networkCloudRack = client.GetNetworkCloudRackResource(networkCloudRackResourceId); // invoke the operation - NetworkCloudRackPatch patch = new NetworkCloudRackPatch() + NetworkCloudRackPatch patch = new NetworkCloudRackPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, RackLocation = "Rack 2B", RackSerialNumber = "RACK_SERIAL_NUMBER", diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackSkuCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackSkuCollection.cs index 7c60bc7c5d375..03ebf04d349db 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackSkuCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudRackSkuCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkCloudRackSkuCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRackSKUsForSubscription() + public async Task Get_GetRackSKUResource() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/RackSkus_ListBySubscription.json - // this example is just showing the usage of "RackSkus_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/RackSkus_Get.json + // this example is just showing the usage of "RackSkus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_ListRackSKUsForSubscription() // get the collection of this NetworkCloudRackSkuResource NetworkCloudRackSkuCollection collection = subscriptionResource.GetNetworkCloudRackSkus(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudRackSkuResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudRackSkuData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string rackSkuName = "rackSkuName"; + NetworkCloudRackSkuResource result = await collection.GetAsync(rackSkuName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudRackSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRackSKUResource() + public async Task GetAll_ListRackSKUsForSubscription() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/RackSkus_Get.json - // this example is just showing the usage of "RackSkus_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/RackSkus_ListBySubscription.json + // this example is just showing the usage of "RackSkus_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +69,17 @@ public async Task Get_GetRackSKUResource() // get the collection of this NetworkCloudRackSkuResource NetworkCloudRackSkuCollection collection = subscriptionResource.GetNetworkCloudRackSkus(); - // invoke the operation - string rackSkuName = "rackSkuName"; - NetworkCloudRackSkuResource result = await collection.GetAsync(rackSkuName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudRackSkuResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudRackSkuData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudRackSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudStorageApplianceCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudStorageApplianceCollection.cs index 517ce1fb429c6..d7b42e0fe4545 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudStorageApplianceCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudStorageApplianceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkCloudStorageApplianceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListStorageAppliancesForResourceGroup() + public async Task Get_GetStorageAppliance() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/StorageAppliances_ListByResourceGroup.json - // this example is just showing the usage of "StorageAppliances_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/StorageAppliances_Get.json + // this example is just showing the usage of "StorageAppliances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListStorageAppliancesForResourceGroup() // get the collection of this NetworkCloudStorageApplianceResource NetworkCloudStorageApplianceCollection collection = resourceGroupResource.GetNetworkCloudStorageAppliances(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudStorageApplianceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudStorageApplianceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string storageApplianceName = "storageApplianceName"; + NetworkCloudStorageApplianceResource result = await collection.GetAsync(storageApplianceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudStorageApplianceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetStorageAppliance() + public async Task GetAll_ListStorageAppliancesForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/StorageAppliances_Get.json - // this example is just showing the usage of "StorageAppliances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/StorageAppliances_ListByResourceGroup.json + // this example is just showing the usage of "StorageAppliances_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetStorageAppliance() // get the collection of this NetworkCloudStorageApplianceResource NetworkCloudStorageApplianceCollection collection = resourceGroupResource.GetNetworkCloudStorageAppliances(); - // invoke the operation - string storageApplianceName = "storageApplianceName"; - NetworkCloudStorageApplianceResource result = await collection.GetAsync(storageApplianceName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudStorageApplianceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudStorageApplianceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudStorageApplianceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudStorageApplianceResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudStorageApplianceResource.cs index 444467830dfe3..b7042404a8535 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudStorageApplianceResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudStorageApplianceResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudStorageApplianceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudStorageAppliances_ListStorageAppliancesForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/StorageAppliances_ListBySubscription.json - // this example is just showing the usage of "StorageAppliances_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudStorageApplianceResource item in subscriptionResource.GetNetworkCloudStorageAppliancesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudStorageApplianceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetStorageAppliance() @@ -99,12 +67,12 @@ public async Task Update_PatchStorageAppliance() NetworkCloudStorageApplianceResource networkCloudStorageAppliance = client.GetNetworkCloudStorageApplianceResource(networkCloudStorageApplianceResourceId); // invoke the operation - NetworkCloudStorageAppliancePatch patch = new NetworkCloudStorageAppliancePatch() + NetworkCloudStorageAppliancePatch patch = new NetworkCloudStorageAppliancePatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, SerialNumber = "BM1219XXX", }; @@ -166,12 +134,9 @@ public async Task EnableRemoteVendorManagement_TurnOnRemoteVendorManagementForSt NetworkCloudStorageApplianceResource networkCloudStorageAppliance = client.GetNetworkCloudStorageApplianceResource(networkCloudStorageApplianceResourceId); // invoke the operation - StorageApplianceEnableRemoteVendorManagementContent content = new StorageApplianceEnableRemoteVendorManagementContent() + StorageApplianceEnableRemoteVendorManagementContent content = new StorageApplianceEnableRemoteVendorManagementContent { - SupportEndpoints = -{ -"10.0.0.0/24" -}, + SupportEndpoints = { "10.0.0.0/24" }, }; ArmOperation lro = await networkCloudStorageAppliance.EnableRemoteVendorManagementAsync(WaitUntil.Completed, content: content); NetworkCloudOperationStatusResult result = lro.Value; diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudTrunkedNetworkCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudTrunkedNetworkCollection.cs index 66460a422c478..3b7e51f7016eb 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudTrunkedNetworkCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudTrunkedNetworkCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkCloudTrunkedNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTrunkedNetworksForResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateTrunkedNetwork() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/TrunkedNetworks_ListByResourceGroup.json - // this example is just showing the usage of "TrunkedNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/TrunkedNetworks_Create.json + // this example is just showing the usage of "TrunkedNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ListTrunkedNetworksForResourceGroup() // get the collection of this NetworkCloudTrunkedNetworkResource NetworkCloudTrunkedNetworkCollection collection = resourceGroupResource.GetNetworkCloudTrunkedNetworks(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudTrunkedNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string trunkedNetworkName = "trunkedNetworkName"; + NetworkCloudTrunkedNetworkData data = new NetworkCloudTrunkedNetworkData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), new ResourceIdentifier[] { new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/l2IsolationDomains/l2IsolationDomainName"), new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/l3IsolationDomains/l3IsolationDomainName") }, new long[] { 12L, 14L }) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudTrunkedNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + InterfaceName = "eth0", + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, trunkedNetworkName, data); + NetworkCloudTrunkedNetworkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudTrunkedNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +95,10 @@ public async Task Get_GetTrunkedNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTrunkedNetwork() + public async Task GetAll_ListTrunkedNetworksForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/TrunkedNetworks_Get.json - // this example is just showing the usage of "TrunkedNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/TrunkedNetworks_ListByResourceGroup.json + // this example is just showing the usage of "TrunkedNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +115,22 @@ public async Task Exists_GetTrunkedNetwork() // get the collection of this NetworkCloudTrunkedNetworkResource NetworkCloudTrunkedNetworkCollection collection = resourceGroupResource.GetNetworkCloudTrunkedNetworks(); - // invoke the operation - string trunkedNetworkName = "trunkedNetworkName"; - bool result = await collection.ExistsAsync(trunkedNetworkName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudTrunkedNetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudTrunkedNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTrunkedNetwork() + public async Task Exists_GetTrunkedNetwork() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/TrunkedNetworks_Get.json // this example is just showing the usage of "TrunkedNetworks_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +152,17 @@ public async Task GetIfExists_GetTrunkedNetwork() // invoke the operation string trunkedNetworkName = "trunkedNetworkName"; - NullableResponse response = await collection.GetIfExistsAsync(trunkedNetworkName); - NetworkCloudTrunkedNetworkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(trunkedNetworkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudTrunkedNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateTrunkedNetwork() + public async Task GetIfExists_GetTrunkedNetwork() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/TrunkedNetworks_Create.json - // this example is just showing the usage of "TrunkedNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/TrunkedNetworks_Get.json + // this example is just showing the usage of "TrunkedNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,29 +181,21 @@ public async Task CreateOrUpdate_CreateOrUpdateTrunkedNetwork() // invoke the operation string trunkedNetworkName = "trunkedNetworkName"; - NetworkCloudTrunkedNetworkData data = new NetworkCloudTrunkedNetworkData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), new ResourceIdentifier[] - { -new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/l2IsolationDomains/l2IsolationDomainName"),new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ManagedNetworkFabric/l3IsolationDomains/l3IsolationDomainName") - }, new long[] + NullableResponse response = await collection.GetIfExistsAsync(trunkedNetworkName); + NetworkCloudTrunkedNetworkResource result = response.HasValue ? response.Value : null; + + if (result == null) { -12L,14L - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - InterfaceName = "eth0", - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, trunkedNetworkName, data); - NetworkCloudTrunkedNetworkResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudTrunkedNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudTrunkedNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudTrunkedNetworkResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudTrunkedNetworkResource.cs index 766319efc5115..936017dd04b3d 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudTrunkedNetworkResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudTrunkedNetworkResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudTrunkedNetworkResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudTrunkedNetworks_ListTrunkedNetworksForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/TrunkedNetworks_ListBySubscription.json - // this example is just showing the usage of "TrunkedNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudTrunkedNetworkResource item in subscriptionResource.GetNetworkCloudTrunkedNetworksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudTrunkedNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetTrunkedNetwork() @@ -99,12 +67,12 @@ public async Task Update_PatchTrunkedNetwork() NetworkCloudTrunkedNetworkResource networkCloudTrunkedNetwork = client.GetNetworkCloudTrunkedNetworkResource(networkCloudTrunkedNetworkResourceId); // invoke the operation - NetworkCloudTrunkedNetworkPatch patch = new NetworkCloudTrunkedNetworkPatch() + NetworkCloudTrunkedNetworkPatch patch = new NetworkCloudTrunkedNetworkPatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, }; NetworkCloudTrunkedNetworkResource result = await networkCloudTrunkedNetwork.UpdateAsync(patch); diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineCollection.cs index 027f2cd765177..3961cb8eb46eb 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkCloudVirtualMachineCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualMachinesForResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateVirtualMachine() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/VirtualMachines_ListByResourceGroup.json - // this example is just showing the usage of "VirtualMachines_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/VirtualMachines_Create.json + // this example is just showing the usage of "VirtualMachines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,56 @@ public async Task GetAll_ListVirtualMachinesForResourceGroup() // get the collection of this NetworkCloudVirtualMachineResource NetworkCloudVirtualMachineCollection collection = resourceGroupResource.GetNetworkCloudVirtualMachines(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudVirtualMachineResource item in collection.GetAllAsync()) + // invoke the operation + string virtualMachineName = "virtualMachineName"; + NetworkCloudVirtualMachineData data = new NetworkCloudVirtualMachineData( + new AzureLocation("location"), + new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), + "username", + new NetworkAttachment(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName"), VirtualMachineIPAllocationMethod.Dynamic), + 2L, + 8L, + new NetworkCloudStorageProfile(new NetworkCloudOSDisk(120L) + { + CreateOption = OSDiskCreateOption.Ephemeral, + DeleteOption = OSDiskDeleteOption.Delete, + }) + { + VolumeAttachments = { new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/volumes/volumeName") }, + }, + "myacr.azurecr.io/foobar:latest") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVirtualMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + BootMethod = VirtualMachineBootMethod.Uefi, + NetworkAttachments = {new NetworkAttachment(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName"), VirtualMachineIPAllocationMethod.Dynamic) +{ +DefaultGateway = DefaultGateway.True, +IPv4Address = "198.51.100.1", +IPv6Address = "2001:0db8:0000:0000:0000:0000:0000:0000", +NetworkAttachmentName = "netAttachName01", +}}, + NetworkData = "bmV0d29ya0RhdGVTYW1wbGU=", + PlacementHints = { new VirtualMachinePlacementHint(VirtualMachinePlacementHintType.Affinity, new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/racks/rackName"), VirtualMachineSchedulingExecution.Hard, new VirtualMachinePlacementHintPodAffinityScope("")) }, + SshPublicKeys = { new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") }, + UserData = "dXNlckRhdGVTYW1wbGU=", + VmDeviceModel = VirtualMachineDeviceModelType.T2, + VmImageRepositoryCredentials = new ImageRepositoryCredentials("myacr.azurecr.io", "myuser") + { + Password = "{password}", + }, + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineName, data); + NetworkCloudVirtualMachineResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +126,10 @@ public async Task Get_GetVirtualMachine() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualMachine() + public async Task GetAll_ListVirtualMachinesForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/VirtualMachines_Get.json - // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/VirtualMachines_ListByResourceGroup.json + // this example is just showing the usage of "VirtualMachines_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +146,22 @@ public async Task Exists_GetVirtualMachine() // get the collection of this NetworkCloudVirtualMachineResource NetworkCloudVirtualMachineCollection collection = resourceGroupResource.GetNetworkCloudVirtualMachines(); - // invoke the operation - string virtualMachineName = "virtualMachineName"; - bool result = await collection.ExistsAsync(virtualMachineName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudVirtualMachineResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVirtualMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualMachine() + public async Task Exists_GetVirtualMachine() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/VirtualMachines_Get.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +183,17 @@ public async Task GetIfExists_GetVirtualMachine() // invoke the operation string virtualMachineName = "virtualMachineName"; - NullableResponse response = await collection.GetIfExistsAsync(virtualMachineName); - NetworkCloudVirtualMachineResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(virtualMachineName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateVirtualMachine() + public async Task GetIfExists_GetVirtualMachine() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/VirtualMachines_Create.json - // this example is just showing the usage of "VirtualMachines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/VirtualMachines_Get.json + // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,58 +212,21 @@ public async Task CreateOrUpdate_CreateOrUpdateVirtualMachine() // invoke the operation string virtualMachineName = "virtualMachineName"; - NetworkCloudVirtualMachineData data = new NetworkCloudVirtualMachineData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), "username", new NetworkAttachment(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/cloudServicesNetworks/cloudServicesNetworkName"), VirtualMachineIPAllocationMethod.Dynamic), 2L, 8L, new NetworkCloudStorageProfile(new NetworkCloudOSDisk(120L) - { - CreateOption = OSDiskCreateOption.Ephemeral, - DeleteOption = OSDiskDeleteOption.Delete, - }) + NullableResponse response = await collection.GetIfExistsAsync(virtualMachineName); + NetworkCloudVirtualMachineResource result = response.HasValue ? response.Value : null; + + if (result == null) { - VolumeAttachments = -{ -new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/volumes/volumeName") -}, - }, "myacr.azurecr.io/foobar:latest") + Console.WriteLine("Succeeded with null as result"); + } + else { - BootMethod = VirtualMachineBootMethod.Uefi, - NetworkAttachments = -{ -new NetworkAttachment(new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/l3Networks/l3NetworkName"),VirtualMachineIPAllocationMethod.Dynamic) -{ -DefaultGateway = DefaultGateway.True, -IPv4Address = "198.51.100.1", -IPv6Address = "2001:0db8:0000:0000:0000:0000:0000:0000", -NetworkAttachmentName = "netAttachName01", -} -}, - NetworkData = "bmV0d29ya0RhdGVTYW1wbGU=", - PlacementHints = -{ -new VirtualMachinePlacementHint(VirtualMachinePlacementHintType.Affinity,new ResourceIdentifier("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.NetworkCloud/racks/rackName"),VirtualMachineSchedulingExecution.Hard,new VirtualMachinePlacementHintPodAffinityScope("")) -}, - SshPublicKeys = -{ -new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm") -}, - UserData = "dXNlckRhdGVTYW1wbGU=", - VmDeviceModel = VirtualMachineDeviceModelType.T2, - VmImageRepositoryCredentials = new ImageRepositoryCredentials("myacr.azurecr.io", "myuser") - { - Password = "{password}", - }, - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineName, data); - NetworkCloudVirtualMachineResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineConsoleCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineConsoleCollection.cs index f0ae338c33626..7c2bad5f7b548 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineConsoleCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineConsoleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkCloudVirtualMachineConsoleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConsolesOfTheVirtualMachine() + public async Task CreateOrUpdate_CreateOrUpdateVirtualMachineConsole() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Consoles_ListByVirtualMachine.json - // this example is just showing the usage of "Consoles_ListByVirtualMachine" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Consoles_Create.json + // this example is just showing the usage of "Consoles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ListConsolesOfTheVirtualMachine() // get the collection of this NetworkCloudVirtualMachineConsoleResource NetworkCloudVirtualMachineConsoleCollection collection = networkCloudVirtualMachine.GetNetworkCloudVirtualMachineConsoles(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudVirtualMachineConsoleResource item in collection.GetAllAsync()) + // invoke the operation + string consoleName = "default"; + NetworkCloudVirtualMachineConsoleData data = new NetworkCloudVirtualMachineConsoleData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterManagerExtendedLocationName", "CustomLocation"), ConsoleEnabled.True, new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVirtualMachineConsoleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ExpireOn = DateTimeOffset.Parse("2022-06-01T01:27:03.008Z"), + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, consoleName, data); + NetworkCloudVirtualMachineConsoleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVirtualMachineConsoleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetVirtualMachineConsole() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualMachineConsole() + public async Task GetAll_ListConsolesOfTheVirtualMachine() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Consoles_Get.json - // this example is just showing the usage of "Consoles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Consoles_ListByVirtualMachine.json + // this example is just showing the usage of "Consoles_ListByVirtualMachine" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetVirtualMachineConsole() // get the collection of this NetworkCloudVirtualMachineConsoleResource NetworkCloudVirtualMachineConsoleCollection collection = networkCloudVirtualMachine.GetNetworkCloudVirtualMachineConsoles(); - // invoke the operation - string consoleName = "default"; - bool result = await collection.ExistsAsync(consoleName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudVirtualMachineConsoleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVirtualMachineConsoleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualMachineConsole() + public async Task Exists_GetVirtualMachineConsole() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Consoles_Get.json // this example is just showing the usage of "Consoles_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetVirtualMachineConsole() // invoke the operation string consoleName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(consoleName); - NetworkCloudVirtualMachineConsoleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(consoleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVirtualMachineConsoleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateVirtualMachineConsole() + public async Task GetIfExists_GetVirtualMachineConsole() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Consoles_Create.json - // this example is just showing the usage of "Consoles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Consoles_Get.json + // this example is just showing the usage of "Consoles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateVirtualMachineConsole() // invoke the operation string consoleName = "default"; - NetworkCloudVirtualMachineConsoleData data = new NetworkCloudVirtualMachineConsoleData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterManagerExtendedLocationName", "CustomLocation"), ConsoleEnabled.True, new NetworkCloudSshPublicKey("ssh-rsa AAtsE3njSONzDYRIZv/WLjVuMfrUSByHp+jfaaOLHTIIB4fJvo6dQUZxE20w2iDHV3tEkmnTo84eba97VMueQD6OzJPEyWZMRpz8UYWOd0IXeRqiFu1lawNblZhwNT/ojNZfpB3af/YDzwQCZgTcTRyNNhL4o/blKUmug0daSsSXISTRnIDpcf5qytjs1Xo+yYyJMvzLL59mhAyb3p/cD+Y3/s3WhAx+l0XOKpzXnblrv9d3q4c2tWmm/SyFqthaqd0= admin@vm")) - { - ExpireOn = DateTimeOffset.Parse("2022-06-01T01:27:03.008Z"), - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, consoleName, data); - NetworkCloudVirtualMachineConsoleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(consoleName); + NetworkCloudVirtualMachineConsoleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVirtualMachineConsoleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVirtualMachineConsoleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineConsoleResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineConsoleResource.cs index 2fbb22df6d2d2..a65328c1ad1be 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineConsoleResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineConsoleResource.cs @@ -69,12 +69,12 @@ public async Task Update_PatchVirtualMachineConsole() NetworkCloudVirtualMachineConsoleResource networkCloudVirtualMachineConsole = client.GetNetworkCloudVirtualMachineConsoleResource(networkCloudVirtualMachineConsoleResourceId); // invoke the operation - NetworkCloudVirtualMachineConsolePatch patch = new NetworkCloudVirtualMachineConsolePatch() + NetworkCloudVirtualMachineConsolePatch patch = new NetworkCloudVirtualMachineConsolePatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, Enabled = ConsoleEnabled.True, ExpireOn = DateTimeOffset.Parse("2022-06-01T01:27:03.008Z"), diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineResource.cs index 401d3e7949e93..9edeeacc6afe4 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVirtualMachineResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudVirtualMachineResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudVirtualMachines_ListVirtualMachinesForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/VirtualMachines_ListBySubscription.json - // this example is just showing the usage of "VirtualMachines_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudVirtualMachineResource item in subscriptionResource.GetNetworkCloudVirtualMachinesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVirtualMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetVirtualMachine() @@ -99,12 +67,12 @@ public async Task Update_PatchVirtualMachine() NetworkCloudVirtualMachineResource networkCloudVirtualMachine = client.GetNetworkCloudVirtualMachineResource(networkCloudVirtualMachineResourceId); // invoke the operation - NetworkCloudVirtualMachinePatch patch = new NetworkCloudVirtualMachinePatch() + NetworkCloudVirtualMachinePatch patch = new NetworkCloudVirtualMachinePatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, VmImageRepositoryCredentials = new ImageRepositoryCredentials("myacr.azurecr.io", "myuser") { @@ -142,7 +110,7 @@ public async Task PowerOff_PowerOffVirtualMachine() NetworkCloudVirtualMachineResource networkCloudVirtualMachine = client.GetNetworkCloudVirtualMachineResource(networkCloudVirtualMachineResourceId); // invoke the operation - VirtualMachinePowerOffContent content = new VirtualMachinePowerOffContent() + VirtualMachinePowerOffContent content = new VirtualMachinePowerOffContent { SkipShutdown = SkipShutdown.True, }; diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVolumeCollection.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVolumeCollection.cs index 18ac911555b2f..47a71f298bd9f 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVolumeCollection.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVolumeCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkCloudVolumeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVolumesForResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateVolume() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Volumes_ListByResourceGroup.json - // this example is just showing the usage of "Volumes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Volumes_Create.json + // this example is just showing the usage of "Volumes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_ListVolumesForResourceGroup() // get the collection of this NetworkCloudVolumeResource NetworkCloudVolumeCollection collection = resourceGroupResource.GetNetworkCloudVolumes(); - // invoke the operation and iterate over the result - await foreach (NetworkCloudVolumeResource item in collection.GetAllAsync()) + // invoke the operation + string volumeName = "volumeName"; + NetworkCloudVolumeData data = new NetworkCloudVolumeData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), 10000L) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVolumeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key1"] = "myvalue1", +["key2"] = "myvalue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, volumeName, data); + NetworkCloudVolumeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVolumeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +94,10 @@ public async Task Get_GetVolume() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVolume() + public async Task GetAll_ListVolumesForResourceGroup() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Volumes_Get.json - // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Volumes_ListByResourceGroup.json + // this example is just showing the usage of "Volumes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +114,22 @@ public async Task Exists_GetVolume() // get the collection of this NetworkCloudVolumeResource NetworkCloudVolumeCollection collection = resourceGroupResource.GetNetworkCloudVolumes(); - // invoke the operation - string volumeName = "volumeName"; - bool result = await collection.ExistsAsync(volumeName); + // invoke the operation and iterate over the result + await foreach (NetworkCloudVolumeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVolumeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVolume() + public async Task Exists_GetVolume() { // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Volumes_Get.json // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +151,17 @@ public async Task GetIfExists_GetVolume() // invoke the operation string volumeName = "volumeName"; - NullableResponse response = await collection.GetIfExistsAsync(volumeName); - NetworkCloudVolumeResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(volumeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVolumeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateVolume() + public async Task GetIfExists_GetVolume() { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Volumes_Create.json - // this example is just showing the usage of "Volumes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Volumes_Get.json + // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,22 +180,21 @@ public async Task CreateOrUpdate_CreateOrUpdateVolume() // invoke the operation string volumeName = "volumeName"; - NetworkCloudVolumeData data = new NetworkCloudVolumeData(new AzureLocation("location"), new ExtendedLocation("/subscriptions/123e4567-e89b-12d3-a456-426655440000/resourceGroups/resourceGroupName/providers/Microsoft.ExtendedLocation/customLocations/clusterExtendedLocationName", "CustomLocation"), 10000L) - { - Tags = -{ -["key1"] = "myvalue1", -["key2"] = "myvalue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, volumeName, data); - NetworkCloudVolumeResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(volumeName); + NetworkCloudVolumeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVolumeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVolumeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVolumeResource.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVolumeResource.cs index d58380e013124..c9ba2f0f32a7a 100644 --- a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVolumeResource.cs +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_NetworkCloudVolumeResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetworkCloud.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetworkCloud.Samples { public partial class Sample_NetworkCloudVolumeResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkCloudVolumes_ListVolumeForSubscription() - { - // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Volumes_ListBySubscription.json - // this example is just showing the usage of "Volumes_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkCloudVolumeResource item in subscriptionResource.GetNetworkCloudVolumesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkCloudVolumeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetVolume() @@ -99,12 +67,12 @@ public async Task Update_PatchVolume() NetworkCloudVolumeResource networkCloudVolume = client.GetNetworkCloudVolumeResource(networkCloudVolumeResourceId); // invoke the operation - NetworkCloudVolumePatch patch = new NetworkCloudVolumePatch() + NetworkCloudVolumePatch patch = new NetworkCloudVolumePatch { Tags = { ["key1"] = "myvalue1", -["key2"] = "myvalue2", +["key2"] = "myvalue2" }, }; NetworkCloudVolumeResource result = await networkCloudVolume.UpdateAsync(patch); diff --git a/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..91ba1da933e3d --- /dev/null +++ b/sdk/networkcloud/Azure.ResourceManager.NetworkCloud/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,391 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.NetworkCloud.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudBareMetalMachines_ListBareMetalMachinesForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/BareMetalMachines_ListBySubscription.json + // this example is just showing the usage of "BareMetalMachines_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudBareMetalMachineResource item in subscriptionResource.GetNetworkCloudBareMetalMachinesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudBareMetalMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudCloudServicesNetworks_ListCloudServicesNetworksForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/CloudServicesNetworks_ListBySubscription.json + // this example is just showing the usage of "CloudServicesNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudCloudServicesNetworkResource item in subscriptionResource.GetNetworkCloudCloudServicesNetworksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudCloudServicesNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudClusterManagers_ListClusterManagersForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/ClusterManagers_ListBySubscription.json + // this example is just showing the usage of "ClusterManagers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudClusterManagerResource item in subscriptionResource.GetNetworkCloudClusterManagersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterManagerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudClusters_ListClustersForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Clusters_ListBySubscription.json + // this example is just showing the usage of "Clusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudClusterResource item in subscriptionResource.GetNetworkCloudClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudKubernetesClusters_ListKubernetesClustersForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/KubernetesClusters_ListBySubscription.json + // this example is just showing the usage of "KubernetesClusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudKubernetesClusterResource item in subscriptionResource.GetNetworkCloudKubernetesClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudKubernetesClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudL2Networks_ListL2NetworksForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L2Networks_ListBySubscription.json + // this example is just showing the usage of "L2Networks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudL2NetworkResource item in subscriptionResource.GetNetworkCloudL2NetworksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudL2NetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudL3Networks_ListL3NetworksForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/L3Networks_ListBySubscription.json + // this example is just showing the usage of "L3Networks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudL3NetworkResource item in subscriptionResource.GetNetworkCloudL3NetworksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudL3NetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudRacks_ListRacksForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Racks_ListBySubscription.json + // this example is just showing the usage of "Racks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudRackResource item in subscriptionResource.GetNetworkCloudRacksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudRackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudStorageAppliances_ListStorageAppliancesForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/StorageAppliances_ListBySubscription.json + // this example is just showing the usage of "StorageAppliances_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudStorageApplianceResource item in subscriptionResource.GetNetworkCloudStorageAppliancesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudStorageApplianceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudTrunkedNetworks_ListTrunkedNetworksForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/TrunkedNetworks_ListBySubscription.json + // this example is just showing the usage of "TrunkedNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudTrunkedNetworkResource item in subscriptionResource.GetNetworkCloudTrunkedNetworksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudTrunkedNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudVirtualMachines_ListVirtualMachinesForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/VirtualMachines_ListBySubscription.json + // this example is just showing the usage of "VirtualMachines_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudVirtualMachineResource item in subscriptionResource.GetNetworkCloudVirtualMachinesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVirtualMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkCloudVolumes_ListVolumeForSubscription() + { + // Generated from example definition: specification/networkcloud/resource-manager/Microsoft.NetworkCloud/preview/2024-06-01-preview/examples/Volumes_ListBySubscription.json + // this example is just showing the usage of "Volumes_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "123e4567-e89b-12d3-a456-426655440000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkCloudVolumeResource item in subscriptionResource.GetNetworkCloudVolumesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkCloudVolumeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_AzureTrafficCollectorCollection.cs b/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_AzureTrafficCollectorCollection.cs index d44ba2d9373e6..a57d3cdf17db9 100644 --- a/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_AzureTrafficCollectorCollection.cs +++ b/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_AzureTrafficCollectorCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AzureTrafficCollectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfTrafficCollectorsByResourceGroup() + public async Task CreateOrUpdate_CreateATrafficCollector() { - // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorsByResourceGroupList.json - // this example is just showing the usage of "AzureTrafficCollectorsByResourceGroup_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorCreate.json + // this example is just showing the usage of "AzureTrafficCollectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,23 @@ public async Task GetAll_ListOfTrafficCollectorsByResourceGroup() // get the collection of this AzureTrafficCollectorResource AzureTrafficCollectorCollection collection = resourceGroupResource.GetAzureTrafficCollectors(); - // invoke the operation and iterate over the result - await foreach (AzureTrafficCollectorResource item in collection.GetAllAsync()) + // invoke the operation + string azureTrafficCollectorName = "atc"; + AzureTrafficCollectorData data = new AzureTrafficCollectorData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureTrafficCollectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureTrafficCollectorName, data); + AzureTrafficCollectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureTrafficCollectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +92,10 @@ public async Task Get_GetTrafficCollector() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTrafficCollector() + public async Task GetAll_ListOfTrafficCollectorsByResourceGroup() { - // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorGet.json - // this example is just showing the usage of "AzureTrafficCollectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorsByResourceGroupList.json + // this example is just showing the usage of "AzureTrafficCollectorsByResourceGroup_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +112,22 @@ public async Task Exists_GetTrafficCollector() // get the collection of this AzureTrafficCollectorResource AzureTrafficCollectorCollection collection = resourceGroupResource.GetAzureTrafficCollectors(); - // invoke the operation - string azureTrafficCollectorName = "atc"; - bool result = await collection.ExistsAsync(azureTrafficCollectorName); + // invoke the operation and iterate over the result + await foreach (AzureTrafficCollectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureTrafficCollectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTrafficCollector() + public async Task Exists_GetTrafficCollector() { // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorGet.json // this example is just showing the usage of "AzureTrafficCollectors_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +149,17 @@ public async Task GetIfExists_GetTrafficCollector() // invoke the operation string azureTrafficCollectorName = "atc"; - NullableResponse response = await collection.GetIfExistsAsync(azureTrafficCollectorName); - AzureTrafficCollectorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(azureTrafficCollectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureTrafficCollectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATrafficCollector() + public async Task GetIfExists_GetTrafficCollector() { - // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorCreate.json - // this example is just showing the usage of "AzureTrafficCollectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/AzureTrafficCollectorGet.json + // this example is just showing the usage of "AzureTrafficCollectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,21 +178,21 @@ public async Task CreateOrUpdate_CreateATrafficCollector() // invoke the operation string azureTrafficCollectorName = "atc"; - AzureTrafficCollectorData data = new AzureTrafficCollectorData(new AzureLocation("West US")) - { - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureTrafficCollectorName, data); - AzureTrafficCollectorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(azureTrafficCollectorName); + AzureTrafficCollectorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureTrafficCollectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureTrafficCollectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_AzureTrafficCollectorResource.cs b/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_AzureTrafficCollectorResource.cs index 250d3d9958a1f..d54c63193901f 100644 --- a/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_AzureTrafficCollectorResource.cs +++ b/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_AzureTrafficCollectorResource.cs @@ -93,12 +93,12 @@ public async Task Update_UpdateTrafficCollectorTags() AzureTrafficCollectorResource azureTrafficCollector = client.GetAzureTrafficCollectorResource(azureTrafficCollectorResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, }; AzureTrafficCollectorResource result = await azureTrafficCollector.UpdateAsync(tagsObject); diff --git a/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_CollectorPolicyCollection.cs b/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_CollectorPolicyCollection.cs index a0c0cc21957da..f419a16699981 100644 --- a/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_CollectorPolicyCollection.cs +++ b/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_CollectorPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CollectorPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfCollectionPolicies() + public async Task CreateOrUpdate_CreateACollectionPolicy() { - // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPoliciesList.json - // this example is just showing the usage of "CollectorPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyCreate.json + // this example is just showing the usage of "CollectorPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,36 @@ public async Task GetAll_ListOfCollectionPolicies() // get the collection of this CollectorPolicyResource CollectorPolicyCollection collection = azureTrafficCollector.GetCollectorPolicies(); - // invoke the operation and iterate over the result - await foreach (CollectorPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string collectorPolicyName = "cp1"; + CollectorPolicyData data = new CollectorPolicyData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CollectorPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IngestionPolicy = new IngestionPolicyPropertiesFormat + { + IngestionType = IngestionType.Ipfix, + IngestionSources = {new IngestionSourcesPropertiesFormat +{ +SourceType = IngestionSourceType.Resource, +ResourceId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteCircuits/circuitName", +}}, + }, + EmissionPolicies = {new EmissionPoliciesPropertiesFormat +{ +EmissionType = EmissionType.Ipfix, +EmissionDestinations = {new EmissionPolicyDestination +{ +DestinationType = EmissionDestinationType.AzureMonitor, +}}, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, collectorPolicyName, data); + CollectorPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CollectorPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +107,10 @@ public async Task Get_GetCollectionPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCollectionPolicy() + public async Task GetAll_ListOfCollectionPolicies() { - // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyGet.json - // this example is just showing the usage of "CollectorPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPoliciesList.json + // this example is just showing the usage of "CollectorPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +128,22 @@ public async Task Exists_GetCollectionPolicy() // get the collection of this CollectorPolicyResource CollectorPolicyCollection collection = azureTrafficCollector.GetCollectorPolicies(); - // invoke the operation - string collectorPolicyName = "cp1"; - bool result = await collection.ExistsAsync(collectorPolicyName); + // invoke the operation and iterate over the result + await foreach (CollectorPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CollectorPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCollectionPolicy() + public async Task Exists_GetCollectionPolicy() { // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyGet.json // this example is just showing the usage of "CollectorPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +166,17 @@ public async Task GetIfExists_GetCollectionPolicy() // invoke the operation string collectorPolicyName = "cp1"; - NullableResponse response = await collection.GetIfExistsAsync(collectorPolicyName); - CollectorPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(collectorPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CollectorPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateACollectionPolicy() + public async Task GetIfExists_GetCollectionPolicy() { - // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyCreate.json - // this example is just showing the usage of "CollectorPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/networkfunction/resource-manager/Microsoft.NetworkFunction/stable/2022-11-01/examples/CollectorPolicyGet.json + // this example is just showing the usage of "CollectorPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,43 +196,21 @@ public async Task CreateOrUpdate_CreateACollectionPolicy() // invoke the operation string collectorPolicyName = "cp1"; - CollectorPolicyData data = new CollectorPolicyData(new AzureLocation("West US")) - { - IngestionPolicy = new IngestionPolicyPropertiesFormat() - { - IngestionType = IngestionType.Ipfix, - IngestionSources = -{ -new IngestionSourcesPropertiesFormat() -{ -SourceType = IngestionSourceType.Resource, -ResourceId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteCircuits/circuitName", -} -}, - }, - EmissionPolicies = -{ -new EmissionPoliciesPropertiesFormat() -{ -EmissionType = EmissionType.Ipfix, -EmissionDestinations = -{ -new EmissionPolicyDestination() -{ -DestinationType = EmissionDestinationType.AzureMonitor, -} -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, collectorPolicyName, data); - CollectorPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(collectorPolicyName); + CollectorPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CollectorPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CollectorPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_CollectorPolicyResource.cs b/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_CollectorPolicyResource.cs index c8f4fb5c51eb2..c381db71d63e4 100644 --- a/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_CollectorPolicyResource.cs +++ b/sdk/networkfunction/Azure.ResourceManager.NetworkFunction/samples/Generated/Samples/Sample_CollectorPolicyResource.cs @@ -96,12 +96,12 @@ public async Task Update_UpdateCollectorPolicyTags() CollectorPolicyResource collectorPolicy = client.GetCollectorPolicyResource(collectorPolicyResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, }; CollectorPolicyResource result = await collectorPolicy.UpdateAsync(tagsObject); diff --git a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitorResource.cs b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitorResource.cs index ff3a547f392a1..50478e5020120 100644 --- a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitorResource.cs +++ b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitorResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.NewRelicObservability.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using NUnit.Framework; @@ -21,41 +20,67 @@ public partial class Sample_NewRelicMonitorResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetNewRelicMonitorResources_MonitorsListBySubscriptionMaximumSetGen() + public async Task Get_MonitorsGetMaximumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "Monitors_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this NewRelicMonitorResource created on azure + // for more information of creating NewRelicMonitorResource, please refer to the document of NewRelicMonitorResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rgNewRelic"; + string monitorName = "cdlymktqw"; + ResourceIdentifier newRelicMonitorResourceId = NewRelicMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); + NewRelicMonitorResource newRelicMonitorResource = client.GetNewRelicMonitorResource(newRelicMonitorResourceId); - // invoke the operation and iterate over the result - await foreach (NewRelicMonitorResource item in subscriptionResource.GetNewRelicMonitorResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicMonitorResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + NewRelicMonitorResource result = await newRelicMonitorResource.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicMonitorResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_MonitorsDeleteMaximumSetGen() + { + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "Monitors_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NewRelicMonitorResource created on azure + // for more information of creating NewRelicMonitorResource, please refer to the document of NewRelicMonitorResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rgopenapi"; + string monitorName = "ipxmlcbonyxtolzejcjshkmlron"; + ResourceIdentifier newRelicMonitorResourceId = NewRelicMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); + NewRelicMonitorResource newRelicMonitorResource = client.GetNewRelicMonitorResource(newRelicMonitorResourceId); + + // invoke the operation + string userEmail = "ruxvg@xqkmdhrnoo.hlmbpm"; + await newRelicMonitorResource.DeleteAsync(WaitUntil.Completed, userEmail); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MonitorsGetMaximumSetGen() + public async Task Delete_MonitorsDeleteMinimumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "Monitors_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,19 +90,16 @@ public async Task Get_MonitorsGetMaximumSetGen() // this example assumes you already have this NewRelicMonitorResource created on azure // for more information of creating NewRelicMonitorResource, please refer to the document of NewRelicMonitorResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rgNewRelic"; - string monitorName = "cdlymktqw"; + string resourceGroupName = "rgopenapi"; + string monitorName = "ipxmlcbonyxtolzejcjshkmlron"; ResourceIdentifier newRelicMonitorResourceId = NewRelicMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); NewRelicMonitorResource newRelicMonitorResource = client.GetNewRelicMonitorResource(newRelicMonitorResourceId); // invoke the operation - NewRelicMonitorResource result = await newRelicMonitorResource.GetAsync(); + string userEmail = "ruxvg@xqkmdhrnoo.hlmbpm"; + await newRelicMonitorResource.DeleteAsync(WaitUntil.Completed, userEmail); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicMonitorResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -101,30 +123,30 @@ public async Task Update_MonitorsUpdateMaximumSetGen() NewRelicMonitorResource newRelicMonitorResource = client.GetNewRelicMonitorResource(newRelicMonitorResourceId); // invoke the operation - NewRelicMonitorResourcePatch patch = new NewRelicMonitorResourcePatch() + NewRelicMonitorResourcePatch patch = new NewRelicMonitorResourcePatch { Identity = new ManagedServiceIdentity("None") { UserAssignedIdentities = { -[new ResourceIdentifier("key8903")] = new UserAssignedIdentity(), +[new ResourceIdentifier("key8903")] = new UserAssignedIdentity() }, }, Tags = { -["key164"] = "jqakdrrmmyzytqu", +["key164"] = "jqakdrrmmyzytqu" }, - NewRelicAccountProperties = new NewRelicAccountProperties() + NewRelicAccountProperties = new NewRelicAccountProperties { UserId = "vcscxlncofcuduadesd", - AccountInfo = new NewRelicObservabilityAccountInfo() + AccountInfo = new NewRelicObservabilityAccountInfo { AccountId = "xhqmg", IngestionKey = "wltnimmhqt", Region = new AzureLocation("ljcf"), }, OrganizationId = "k", - SingleSignOnProperties = new NewRelicSingleSignOnProperties() + SingleSignOnProperties = new NewRelicSingleSignOnProperties { SingleSignOnState = NewRelicSingleSignOnState.Initial, EnterpriseAppId = "kwiwfz", @@ -132,7 +154,7 @@ public async Task Update_MonitorsUpdateMaximumSetGen() ProvisioningState = NewRelicProvisioningState.Accepted, }, }, - UserInfo = new NewRelicObservabilityUserInfo() + UserInfo = new NewRelicObservabilityUserInfo { FirstName = "vdftzcggirefejajwahhwhyibutramdaotvnuf", LastName = "bcsztgqovdlmzfkjdrngidwzqsevagexzzilnlc", @@ -140,7 +162,7 @@ public async Task Update_MonitorsUpdateMaximumSetGen() PhoneNumber = "krf", Country = "hslqnwdanrconqyekwbnttaetv", }, - PlanData = new NewRelicPlanDetails() + PlanData = new NewRelicPlanDetails { UsageType = NewRelicObservabilityUsageType.Payg, NewRelicPlanBillingCycle = "Yearly", @@ -160,60 +182,6 @@ public async Task Update_MonitorsUpdateMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_MonitorsDeleteMaximumSetGen() - { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "Monitors_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NewRelicMonitorResource created on azure - // for more information of creating NewRelicMonitorResource, please refer to the document of NewRelicMonitorResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rgopenapi"; - string monitorName = "ipxmlcbonyxtolzejcjshkmlron"; - ResourceIdentifier newRelicMonitorResourceId = NewRelicMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); - NewRelicMonitorResource newRelicMonitorResource = client.GetNewRelicMonitorResource(newRelicMonitorResourceId); - - // invoke the operation - string userEmail = "ruxvg@xqkmdhrnoo.hlmbpm"; - await newRelicMonitorResource.DeleteAsync(WaitUntil.Completed, userEmail); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_MonitorsDeleteMinimumSetGen() - { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "Monitors_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NewRelicMonitorResource created on azure - // for more information of creating NewRelicMonitorResource, please refer to the document of NewRelicMonitorResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rgopenapi"; - string monitorName = "ipxmlcbonyxtolzejcjshkmlron"; - ResourceIdentifier newRelicMonitorResourceId = NewRelicMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); - NewRelicMonitorResource newRelicMonitorResource = client.GetNewRelicMonitorResource(newRelicMonitorResourceId); - - // invoke the operation - string userEmail = "ruxvg@xqkmdhrnoo.hlmbpm"; - await newRelicMonitorResource.DeleteAsync(WaitUntil.Completed, userEmail); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetMetricRules_MonitorsGetMetricRulesMaximumSetGen() @@ -291,10 +259,7 @@ public async Task GetMetricStatus_MonitorsGetMetricStatusMaximumSetGen() // invoke the operation NewRelicMetricsStatusContent content = new NewRelicMetricsStatusContent("ruxvg@xqkmdhrnoo.hlmbpm") { - AzureResourceIds = -{ -"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgNewRelic/providers/NewRelic.Observability/monitors/fhcjxnxumkdlgpwanewtkdnyuz" -}, + AzureResourceIds = { "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgNewRelic/providers/NewRelic.Observability/monitors/fhcjxnxumkdlgpwanewtkdnyuz" }, }; NewRelicMetricsStatusResult result = await newRelicMonitorResource.GetMetricStatusAsync(content); @@ -324,10 +289,7 @@ public async Task GetMetricStatus_MonitorsGetMetricStatusMinimumSetGen() // invoke the operation NewRelicMetricsStatusContent content = new NewRelicMetricsStatusContent("ruxvg@xqkmdhrnoo.hlmbpm") { - AzureResourceIds = -{ -"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgNewRelic/providers/NewRelic.Observability/monitors/fhcjxnxumkdlgpwanewtkdnyuz" -}, + AzureResourceIds = { "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgNewRelic/providers/NewRelic.Observability/monitors/fhcjxnxumkdlgpwanewtkdnyuz" }, }; NewRelicMetricsStatusResult result = await newRelicMonitorResource.GetMetricStatusAsync(content); @@ -357,10 +319,7 @@ public async Task GetAppServices_MonitorsListAppServicesMaximumSetGen() // invoke the operation and iterate over the result NewRelicAppServicesGetContent content = new NewRelicAppServicesGetContent("ruxvg@xqkmdhrnoo.hlmbpm") { - AzureResourceIds = -{ -new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgNewRelic/providers/NewRelic.Observability/monitors/fhcjxnxumkdlgpwanewtkdnyuz") -}, + AzureResourceIds = { new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgNewRelic/providers/NewRelic.Observability/monitors/fhcjxnxumkdlgpwanewtkdnyuz") }, }; await foreach (NewRelicObservabilityAppServiceInfo item in newRelicMonitorResource.GetAppServicesAsync(content)) { @@ -393,10 +352,7 @@ public async Task GetAppServices_MonitorsListAppServicesMinimumSetGen() // invoke the operation and iterate over the result NewRelicAppServicesGetContent content = new NewRelicAppServicesGetContent("ruxvg@xqkmdhrnoo.hlmbpm") { - AzureResourceIds = -{ -new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgNewRelic/providers/NewRelic.Observability/monitors/fhcjxnxumkdlgpwanewtkdnyuz") -}, + AzureResourceIds = { new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgNewRelic/providers/NewRelic.Observability/monitors/fhcjxnxumkdlgpwanewtkdnyuz") }, }; await foreach (NewRelicObservabilityAppServiceInfo item in newRelicMonitorResource.GetAppServicesAsync(content)) { @@ -431,7 +387,7 @@ public async Task SwitchBilling_MonitorsSwitchBillingMaximumSetGen() { AzureResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgNewRelic/providers/NewRelic.Observability/monitors/fhcjxnxumkdlgpwanewtkdnyuz"), OrganizationId = "k", - PlanData = new NewRelicPlanDetails() + PlanData = new NewRelicPlanDetails { UsageType = NewRelicObservabilityUsageType.Payg, NewRelicPlanBillingCycle = "Yearly", @@ -502,10 +458,7 @@ public async Task GetHosts_MonitorsListHostsMaximumSetGen() // invoke the operation and iterate over the result NewRelicHostsGetContent content = new NewRelicHostsGetContent("ruxvg@xqkmdhrnoo.hlmbpm") { - VmIds = -{ -new ResourceIdentifier("xzphvxvfmvjrnsgyns") -}, + VmIds = { new ResourceIdentifier("xzphvxvfmvjrnsgyns") }, }; await foreach (NewRelicObservabilityVmInfo item in newRelicMonitorResource.GetHostsAsync(content)) { @@ -538,10 +491,7 @@ public async Task GetHosts_MonitorsListHostsMinimumSetGen() // invoke the operation and iterate over the result NewRelicHostsGetContent content = new NewRelicHostsGetContent("ruxvg@xqkmdhrnoo.hlmbpm") { - VmIds = -{ -new ResourceIdentifier("xzphvxvfmvjrnsgyns") -}, + VmIds = { new ResourceIdentifier("xzphvxvfmvjrnsgyns") }, }; await foreach (NewRelicObservabilityVmInfo item in newRelicMonitorResource.GetHostsAsync(content)) { diff --git a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitorResourceCollection.cs b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitorResourceCollection.cs index 165674122d52c..e3bf899f8e670 100644 --- a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitorResourceCollection.cs +++ b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitorResourceCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_NewRelicMonitorResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MonitorsListByResourceGroupMaximumSetGen() + public async Task CreateOrUpdate_MonitorsCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "Monitors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "Monitors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,67 @@ public async Task GetAll_MonitorsListByResourceGroupMaximumSetGen() // get the collection of this NewRelicMonitorResource NewRelicMonitorResourceCollection collection = resourceGroupResource.GetNewRelicMonitorResources(); - // invoke the operation and iterate over the result - await foreach (NewRelicMonitorResource item in collection.GetAllAsync()) + // invoke the operation + string monitorName = "cdlymktqw"; + NewRelicMonitorResourceData data = new NewRelicMonitorResourceData(new AzureLocation("k")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicMonitorResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("key8903")] = new UserAssignedIdentity() +}, + }, + NewRelicAccountProperties = new NewRelicAccountProperties + { + UserId = "vcscxlncofcuduadesd", + AccountInfo = new NewRelicObservabilityAccountInfo + { + AccountId = "xhqmg", + IngestionKey = "wltnimmhqt", + Region = new AzureLocation("ljcf"), + }, + OrganizationId = "k", + SingleSignOnProperties = new NewRelicSingleSignOnProperties + { + SingleSignOnState = NewRelicSingleSignOnState.Initial, + EnterpriseAppId = "kwiwfz", + SingleSignOnUri = new Uri("kvseueuljsxmfwpqctz"), + ProvisioningState = NewRelicProvisioningState.Accepted, + }, + }, + UserInfo = new NewRelicObservabilityUserInfo + { + FirstName = "vdftzcggirefejajwahhwhyibutramdaotvnuf", + LastName = "bcsztgqovdlmzfkjdrngidwzqsevagexzzilnlc", + EmailAddress = "%6%@4-g.N1.3F-kI1.Ue-.lJso", + PhoneNumber = "krf", + Country = "hslqnwdanrconqyekwbnttaetv", + }, + PlanData = new NewRelicPlanDetails + { + UsageType = NewRelicObservabilityUsageType.Payg, + NewRelicPlanBillingCycle = "Yearly", + PlanDetails = "tbbiaga", + EffectiveOn = DateTimeOffset.Parse("2022-12-05T14:11:37.786Z"), + }, + OrgCreationSource = NewRelicObservabilityOrgCreationSource.Liftr, + AccountCreationSource = NewRelicObservabilityAccountCreationSource.Liftr, + SubscriptionState = "Suspended", + SaaSAzureSubscriptionStatus = "Subscribed", + Tags = +{ +["key6976"] = "oaxfhf" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, monitorName, data); + NewRelicMonitorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicMonitorResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +138,10 @@ public async Task Get_MonitorsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MonitorsGetMaximumSetGen() + public async Task GetAll_MonitorsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "Monitors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +158,22 @@ public async Task Exists_MonitorsGetMaximumSetGen() // get the collection of this NewRelicMonitorResource NewRelicMonitorResourceCollection collection = resourceGroupResource.GetNewRelicMonitorResources(); - // invoke the operation - string monitorName = "cdlymktqw"; - bool result = await collection.ExistsAsync(monitorName); + // invoke the operation and iterate over the result + await foreach (NewRelicMonitorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicMonitorResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MonitorsGetMaximumSetGen() + public async Task Exists_MonitorsGetMaximumSetGen() { // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_Get_MaximumSet_Gen.json // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +195,17 @@ public async Task GetIfExists_MonitorsGetMaximumSetGen() // invoke the operation string monitorName = "cdlymktqw"; - NullableResponse response = await collection.GetIfExistsAsync(monitorName); - NewRelicMonitorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(monitorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicMonitorResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_MonitorsCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_MonitorsGetMaximumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "Monitors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,65 +224,21 @@ public async Task CreateOrUpdate_MonitorsCreateOrUpdateMaximumSetGen() // invoke the operation string monitorName = "cdlymktqw"; - NewRelicMonitorResourceData data = new NewRelicMonitorResourceData(new AzureLocation("k")) - { - Identity = new ManagedServiceIdentity("None") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("key8903")] = new UserAssignedIdentity(), -}, - }, - NewRelicAccountProperties = new NewRelicAccountProperties() - { - UserId = "vcscxlncofcuduadesd", - AccountInfo = new NewRelicObservabilityAccountInfo() - { - AccountId = "xhqmg", - IngestionKey = "wltnimmhqt", - Region = new AzureLocation("ljcf"), - }, - OrganizationId = "k", - SingleSignOnProperties = new NewRelicSingleSignOnProperties() - { - SingleSignOnState = NewRelicSingleSignOnState.Initial, - EnterpriseAppId = "kwiwfz", - SingleSignOnUri = new Uri("kvseueuljsxmfwpqctz"), - ProvisioningState = NewRelicProvisioningState.Accepted, - }, - }, - UserInfo = new NewRelicObservabilityUserInfo() - { - FirstName = "vdftzcggirefejajwahhwhyibutramdaotvnuf", - LastName = "bcsztgqovdlmzfkjdrngidwzqsevagexzzilnlc", - EmailAddress = "%6%@4-g.N1.3F-kI1.Ue-.lJso", - PhoneNumber = "krf", - Country = "hslqnwdanrconqyekwbnttaetv", - }, - PlanData = new NewRelicPlanDetails() - { - UsageType = NewRelicObservabilityUsageType.Payg, - NewRelicPlanBillingCycle = "Yearly", - PlanDetails = "tbbiaga", - EffectiveOn = DateTimeOffset.Parse("2022-12-05T14:11:37.786Z"), - }, - OrgCreationSource = NewRelicObservabilityOrgCreationSource.Liftr, - AccountCreationSource = NewRelicObservabilityAccountCreationSource.Liftr, - SubscriptionState = "Suspended", - SaaSAzureSubscriptionStatus = "Subscribed", - Tags = -{ -["key6976"] = "oaxfhf", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, monitorName, data); - NewRelicMonitorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(monitorName); + NewRelicMonitorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicMonitorResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicMonitorResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitoredSubscriptionCollection.cs b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitoredSubscriptionCollection.cs index 5a97f40a8f0d9..1b2cc1b6450b6 100644 --- a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitoredSubscriptionCollection.cs +++ b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitoredSubscriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NewRelicMonitoredSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MonitorsGetMonitoredSubscriptions() + public async Task CreateOrUpdate_MonitorsAddMonitoredSubscriptions() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_List.json - // this example is just showing the usage of "MonitoredSubscriptions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_CreateOrUpdate.json + // this example is just showing the usage of "MonitoredSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,17 @@ public async Task GetAll_MonitorsGetMonitoredSubscriptions() // get the collection of this NewRelicMonitoredSubscriptionResource NewRelicMonitoredSubscriptionCollection collection = newRelicMonitorResource.GetNewRelicMonitoredSubscriptions(); - // invoke the operation and iterate over the result - await foreach (NewRelicMonitoredSubscriptionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicMonitoredSubscriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + MonitoredSubscriptionConfigurationName configurationName = MonitoredSubscriptionConfigurationName.Default; + NewRelicMonitoredSubscriptionData data = new NewRelicMonitoredSubscriptionData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + NewRelicMonitoredSubscriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicMonitoredSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +88,10 @@ public async Task Get_MonitorsGetMonitoredSubscriptions() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MonitorsGetMonitoredSubscriptions() + public async Task GetAll_MonitorsGetMonitoredSubscriptions() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_Get.json - // this example is just showing the usage of "MonitoredSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_List.json + // this example is just showing the usage of "MonitoredSubscriptions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_MonitorsGetMonitoredSubscriptions() // get the collection of this NewRelicMonitoredSubscriptionResource NewRelicMonitoredSubscriptionCollection collection = newRelicMonitorResource.GetNewRelicMonitoredSubscriptions(); - // invoke the operation - MonitoredSubscriptionConfigurationName configurationName = MonitoredSubscriptionConfigurationName.Default; - bool result = await collection.ExistsAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (NewRelicMonitoredSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicMonitoredSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MonitorsGetMonitoredSubscriptions() + public async Task Exists_MonitorsGetMonitoredSubscriptions() { // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_Get.json // this example is just showing the usage of "MonitoredSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_MonitorsGetMonitoredSubscriptions() // invoke the operation MonitoredSubscriptionConfigurationName configurationName = MonitoredSubscriptionConfigurationName.Default; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - NewRelicMonitoredSubscriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicMonitoredSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_MonitorsAddMonitoredSubscriptions() + public async Task GetIfExists_MonitorsGetMonitoredSubscriptions() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_CreateOrUpdate.json - // this example is just showing the usage of "MonitoredSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_Get.json + // this example is just showing the usage of "MonitoredSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,15 +177,21 @@ public async Task CreateOrUpdate_MonitorsAddMonitoredSubscriptions() // invoke the operation MonitoredSubscriptionConfigurationName configurationName = MonitoredSubscriptionConfigurationName.Default; - NewRelicMonitoredSubscriptionData data = new NewRelicMonitoredSubscriptionData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - NewRelicMonitoredSubscriptionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + NewRelicMonitoredSubscriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicMonitoredSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicMonitoredSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitoredSubscriptionResource.cs b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitoredSubscriptionResource.cs index e1a464d162e3f..db236b945aba5 100644 --- a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitoredSubscriptionResource.cs +++ b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicMonitoredSubscriptionResource.cs @@ -49,10 +49,10 @@ public async Task Get_MonitorsGetMonitoredSubscriptions() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MonitorsUpdateMonitoredSubscriptions() + public async Task Delete_MonitorsDeleteMonitoredSubscriptions() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_Update.json - // this example is just showing the usage of "MonitoredSubscriptions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_Delete.json + // this example is just showing the usage of "MonitoredSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,23 +69,17 @@ public async Task Update_MonitorsUpdateMonitoredSubscriptions() NewRelicMonitoredSubscriptionResource newRelicMonitoredSubscription = client.GetNewRelicMonitoredSubscriptionResource(newRelicMonitoredSubscriptionResourceId); // invoke the operation - NewRelicMonitoredSubscriptionData data = new NewRelicMonitoredSubscriptionData(); - ArmOperation lro = await newRelicMonitoredSubscription.UpdateAsync(WaitUntil.Completed, data); - NewRelicMonitoredSubscriptionResource result = lro.Value; + await newRelicMonitoredSubscription.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicMonitoredSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_MonitorsDeleteMonitoredSubscriptions() + public async Task Update_MonitorsUpdateMonitoredSubscriptions() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_Delete.json - // this example is just showing the usage of "MonitoredSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/MonitoredSubscriptions_Update.json + // this example is just showing the usage of "MonitoredSubscriptions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_MonitorsDeleteMonitoredSubscriptions() NewRelicMonitoredSubscriptionResource newRelicMonitoredSubscription = client.GetNewRelicMonitoredSubscriptionResource(newRelicMonitoredSubscriptionResourceId); // invoke the operation - await newRelicMonitoredSubscription.DeleteAsync(WaitUntil.Completed); + NewRelicMonitoredSubscriptionData data = new NewRelicMonitoredSubscriptionData(); + ArmOperation lro = await newRelicMonitoredSubscription.UpdateAsync(WaitUntil.Completed, data); + NewRelicMonitoredSubscriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicMonitoredSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicObservabilityTagRuleCollection.cs b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicObservabilityTagRuleCollection.cs index 4667aa981677a..830c918c05a8e 100644 --- a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicObservabilityTagRuleCollection.cs +++ b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicObservabilityTagRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NewRelicObservabilityTagRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TagRulesListByNewRelicMonitorResourceMaximumSetGen() + public async Task CreateOrUpdate_TagRulesCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_ListByNewRelicMonitorResource_MaximumSet_Gen.json - // this example is just showing the usage of "TagRules_ListByNewRelicMonitorResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,49 @@ public async Task GetAll_TagRulesListByNewRelicMonitorResourceMaximumSetGen() // get the collection of this NewRelicObservabilityTagRuleResource NewRelicObservabilityTagRuleCollection collection = newRelicMonitorResource.GetNewRelicObservabilityTagRules(); - // invoke the operation and iterate over the result - await foreach (NewRelicObservabilityTagRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleSetName = "bxcantgzggsepbhqmedjqyrqeezmfb"; + NewRelicObservabilityTagRuleData data = new NewRelicObservabilityTagRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicObservabilityTagRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + LogRules = new NewRelicObservabilityLogRules + { + SendAadLogs = NewRelicObservabilitySendAadLogsStatus.IsEnabled, + SendSubscriptionLogs = NewRelicObservabilitySendSubscriptionLogsStatus.IsEnabled, + SendActivityLogs = NewRelicObservabilitySendActivityLogsStatus.IsEnabled, + FilteringTags = {new NewRelicObservabilityFilteringTag +{ +Name = "saokgpjvdlorciqbjmjxazpee", +Value = "sarxrqsxouhdjwsrqqicbeirdb", +Action = NewRelicObservabilityTagAction.Include, +}}, + }, + MetricRules = new NewRelicObservabilityMetricRules + { + FilteringTags = {new NewRelicObservabilityFilteringTag +{ +Name = "saokgpjvdlorciqbjmjxazpee", +Value = "sarxrqsxouhdjwsrqqicbeirdb", +Action = NewRelicObservabilityTagAction.Include, +}}, + UserEmail = "test@testing.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName, data); + NewRelicObservabilityTagRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicObservabilityTagRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TagRulesListByNewRelicMonitorResourceMinimumSetGen() + public async Task CreateOrUpdate_TagRulesCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_ListByNewRelicMonitorResource_MinimumSet_Gen.json - // this example is just showing the usage of "TagRules_ListByNewRelicMonitorResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +99,17 @@ public async Task GetAll_TagRulesListByNewRelicMonitorResourceMinimumSetGen() // get the collection of this NewRelicObservabilityTagRuleResource NewRelicObservabilityTagRuleCollection collection = newRelicMonitorResource.GetNewRelicObservabilityTagRules(); - // invoke the operation and iterate over the result - await foreach (NewRelicObservabilityTagRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicObservabilityTagRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string ruleSetName = "bxcantgzggsepbhqmedjqyrqeezmfb"; + NewRelicObservabilityTagRuleData data = new NewRelicObservabilityTagRuleData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName, data); + NewRelicObservabilityTagRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicObservabilityTagRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -124,9 +148,9 @@ public async Task Get_TagRulesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TagRulesGetMaximumSetGen() + public async Task Get_TagRulesGetMinimumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_Get_MaximumSet_Gen.json + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_Get_MinimumSet_Gen.json // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -147,17 +171,21 @@ public async Task Exists_TagRulesGetMaximumSetGen() // invoke the operation string ruleSetName = "bxcantgzggsepbhqmedjqyrqeezmfb"; - bool result = await collection.ExistsAsync(ruleSetName); + NewRelicObservabilityTagRuleResource result = await collection.GetAsync(ruleSetName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicObservabilityTagRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TagRulesGetMaximumSetGen() + public async Task GetAll_TagRulesListByNewRelicMonitorResourceMaximumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_Get_MaximumSet_Gen.json - // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_ListByNewRelicMonitorResource_MaximumSet_Gen.json + // this example is just showing the usage of "TagRules_ListByNewRelicMonitorResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -175,31 +203,25 @@ public async Task GetIfExists_TagRulesGetMaximumSetGen() // get the collection of this NewRelicObservabilityTagRuleResource NewRelicObservabilityTagRuleCollection collection = newRelicMonitorResource.GetNewRelicObservabilityTagRules(); - // invoke the operation - string ruleSetName = "bxcantgzggsepbhqmedjqyrqeezmfb"; - NullableResponse response = await collection.GetIfExistsAsync(ruleSetName); - NewRelicObservabilityTagRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NewRelicObservabilityTagRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NewRelicObservabilityTagRuleData resourceData = result.Data; + NewRelicObservabilityTagRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TagRulesGetMinimumSetGen() + public async Task GetAll_TagRulesListByNewRelicMonitorResourceMinimumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_Get_MinimumSet_Gen.json - // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_ListByNewRelicMonitorResource_MinimumSet_Gen.json + // this example is just showing the usage of "TagRules_ListByNewRelicMonitorResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,22 +239,24 @@ public async Task Get_TagRulesGetMinimumSetGen() // get the collection of this NewRelicObservabilityTagRuleResource NewRelicObservabilityTagRuleCollection collection = newRelicMonitorResource.GetNewRelicObservabilityTagRules(); - // invoke the operation - string ruleSetName = "bxcantgzggsepbhqmedjqyrqeezmfb"; - NewRelicObservabilityTagRuleResource result = await collection.GetAsync(ruleSetName); + // invoke the operation and iterate over the result + await foreach (NewRelicObservabilityTagRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicObservabilityTagRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicObservabilityTagRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TagRulesGetMinimumSetGen() + public async Task Exists_TagRulesGetMaximumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_Get_MinimumSet_Gen.json + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_Get_MaximumSet_Gen.json // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -260,7 +284,7 @@ public async Task Exists_TagRulesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TagRulesGetMinimumSetGen() + public async Task Exists_TagRulesGetMinimumSetGen() { // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_Get_MinimumSet_Gen.json // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -283,29 +307,17 @@ public async Task GetIfExists_TagRulesGetMinimumSetGen() // invoke the operation string ruleSetName = "bxcantgzggsepbhqmedjqyrqeezmfb"; - NullableResponse response = await collection.GetIfExistsAsync(ruleSetName); - NewRelicObservabilityTagRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleSetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicObservabilityTagRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TagRulesCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_TagRulesGetMaximumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_Get_MaximumSet_Gen.json + // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -325,53 +337,29 @@ public async Task CreateOrUpdate_TagRulesCreateOrUpdateMaximumSetGen() // invoke the operation string ruleSetName = "bxcantgzggsepbhqmedjqyrqeezmfb"; - NewRelicObservabilityTagRuleData data = new NewRelicObservabilityTagRuleData() - { - LogRules = new NewRelicObservabilityLogRules() - { - SendAadLogs = NewRelicObservabilitySendAadLogsStatus.IsEnabled, - SendSubscriptionLogs = NewRelicObservabilitySendSubscriptionLogsStatus.IsEnabled, - SendActivityLogs = NewRelicObservabilitySendActivityLogsStatus.IsEnabled, - FilteringTags = -{ -new NewRelicObservabilityFilteringTag() -{ -Name = "saokgpjvdlorciqbjmjxazpee", -Value = "sarxrqsxouhdjwsrqqicbeirdb", -Action = NewRelicObservabilityTagAction.Include, -} -}, - }, - MetricRules = new NewRelicObservabilityMetricRules() - { - FilteringTags = -{ -new NewRelicObservabilityFilteringTag() -{ -Name = "saokgpjvdlorciqbjmjxazpee", -Value = "sarxrqsxouhdjwsrqqicbeirdb", -Action = NewRelicObservabilityTagAction.Include, -} -}, - UserEmail = "test@testing.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName, data); - NewRelicObservabilityTagRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleSetName); + NewRelicObservabilityTagRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicObservabilityTagRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicObservabilityTagRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TagRulesCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_TagRulesGetMinimumSetGen() { - // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/TagRules_Get_MinimumSet_Gen.json + // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -391,15 +379,21 @@ public async Task CreateOrUpdate_TagRulesCreateOrUpdateMinimumSetGen() // invoke the operation string ruleSetName = "bxcantgzggsepbhqmedjqyrqeezmfb"; - NewRelicObservabilityTagRuleData data = new NewRelicObservabilityTagRuleData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName, data); - NewRelicObservabilityTagRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleSetName); + NewRelicObservabilityTagRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NewRelicObservabilityTagRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicObservabilityTagRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicObservabilityTagRuleResource.cs b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicObservabilityTagRuleResource.cs index 631229b4cd3e3..81a8f78bf1226 100644 --- a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicObservabilityTagRuleResource.cs +++ b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_NewRelicObservabilityTagRuleResource.cs @@ -154,34 +154,28 @@ public async Task Update_TagRulesUpdateMaximumSetGen() NewRelicObservabilityTagRuleResource newRelicObservabilityTagRule = client.GetNewRelicObservabilityTagRuleResource(newRelicObservabilityTagRuleResourceId); // invoke the operation - NewRelicObservabilityTagRulePatch patch = new NewRelicObservabilityTagRulePatch() + NewRelicObservabilityTagRulePatch patch = new NewRelicObservabilityTagRulePatch { - LogRules = new NewRelicObservabilityLogRules() + LogRules = new NewRelicObservabilityLogRules { SendAadLogs = NewRelicObservabilitySendAadLogsStatus.IsEnabled, SendSubscriptionLogs = NewRelicObservabilitySendSubscriptionLogsStatus.IsEnabled, SendActivityLogs = NewRelicObservabilitySendActivityLogsStatus.IsEnabled, - FilteringTags = -{ -new NewRelicObservabilityFilteringTag() + FilteringTags = {new NewRelicObservabilityFilteringTag { Name = "saokgpjvdlorciqbjmjxazpee", Value = "sarxrqsxouhdjwsrqqicbeirdb", Action = NewRelicObservabilityTagAction.Include, -} -}, +}}, }, - MetricRules = new NewRelicObservabilityMetricRules() + MetricRules = new NewRelicObservabilityMetricRules { - FilteringTags = -{ -new NewRelicObservabilityFilteringTag() + FilteringTags = {new NewRelicObservabilityFilteringTag { Name = "saokgpjvdlorciqbjmjxazpee", Value = "sarxrqsxouhdjwsrqqicbeirdb", Action = NewRelicObservabilityTagAction.Include, -} -}, +}}, UserEmail = "test@testing.com", }, }; diff --git a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 2f9672ef7bda2..87354fa53f854 100644 --- a/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/newrelicobservability/Azure.ResourceManager.NewRelicObservability/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -75,6 +75,37 @@ public async Task GetNewRelicAccounts_AccountsListMinimumSetGen() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNewRelicMonitorResources_MonitorsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/newrelic/resource-manager/NewRelic.Observability/stable/2024-03-01/examples/Monitors_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "Monitors_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NewRelicMonitorResource item in subscriptionResource.GetNewRelicMonitorResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NewRelicMonitorResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetNewRelicOrganizations_OrganizationsListMaximumSetGen() diff --git a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxCertificateCollection.cs b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxCertificateCollection.cs index dbd1df017b204..264e90e07d4b6 100644 --- a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxCertificateCollection.cs +++ b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxCertificateCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NginxCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CertificatesGet() + public async Task CreateOrUpdate_CertificatesCreateOrUpdate() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_Get.json - // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_CreateOrUpdate.json + // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,9 @@ public async Task Get_CertificatesGet() // invoke the operation string certificateName = "default"; - NginxCertificateResource result = await collection.GetAsync(certificateName); + NginxCertificateData data = new NginxCertificateData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); + NginxCertificateResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_CertificatesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CertificatesGet() + public async Task Get_CertificatesGet() { // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_Get.json // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +76,21 @@ public async Task Exists_CertificatesGet() // invoke the operation string certificateName = "default"; - bool result = await collection.ExistsAsync(certificateName); + NginxCertificateResource result = await collection.GetAsync(certificateName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NginxCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CertificatesGet() + public async Task GetAll_CertificatesList() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_Get.json - // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_List.json + // this example is just showing the usage of "Certificates_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +108,25 @@ public async Task GetIfExists_CertificatesGet() // get the collection of this NginxCertificateResource NginxCertificateCollection collection = nginxDeployment.GetNginxCertificates(); - // invoke the operation - string certificateName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(certificateName); - NginxCertificateResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NginxCertificateResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NginxCertificateData resourceData = result.Data; + NginxCertificateData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CertificatesCreateOrUpdate() + public async Task Exists_CertificatesGet() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_CreateOrUpdate.json - // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_Get.json + // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,23 +146,17 @@ public async Task CreateOrUpdate_CertificatesCreateOrUpdate() // invoke the operation string certificateName = "default"; - NginxCertificateData data = new NginxCertificateData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); - NginxCertificateResource result = lro.Value; + bool result = await collection.ExistsAsync(certificateName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NginxCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CertificatesList() + public async Task GetIfExists_CertificatesGet() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_List.json - // this example is just showing the usage of "Certificates_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_Get.json + // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_CertificatesList() // get the collection of this NginxCertificateResource NginxCertificateCollection collection = nginxDeployment.GetNginxCertificates(); - // invoke the operation and iterate over the result - await foreach (NginxCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string certificateName = "default"; + NullableResponse response = await collection.GetIfExistsAsync(certificateName); + NginxCertificateResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NginxCertificateData resourceData = item.Data; + NginxCertificateData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxCertificateResource.cs b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxCertificateResource.cs index 6d7ab3a8f5e75..66ee4005d5556 100644 --- a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxCertificateResource.cs +++ b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxCertificateResource.cs @@ -48,10 +48,10 @@ public async Task Get_CertificatesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CertificatesCreateOrUpdate() + public async Task Delete_CertificatesDelete() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_CreateOrUpdate.json - // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_Delete.json + // this example is just showing the usage of "Certificates_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,23 +68,17 @@ public async Task Update_CertificatesCreateOrUpdate() NginxCertificateResource nginxCertificate = client.GetNginxCertificateResource(nginxCertificateResourceId); // invoke the operation - NginxCertificateData data = new NginxCertificateData(); - ArmOperation lro = await nginxCertificate.UpdateAsync(WaitUntil.Completed, data); - NginxCertificateResource result = lro.Value; + await nginxCertificate.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NginxCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CertificatesDelete() + public async Task Update_CertificatesCreateOrUpdate() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_Delete.json - // this example is just showing the usage of "Certificates_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Certificates_CreateOrUpdate.json + // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +95,15 @@ public async Task Delete_CertificatesDelete() NginxCertificateResource nginxCertificate = client.GetNginxCertificateResource(nginxCertificateResourceId); // invoke the operation - await nginxCertificate.DeleteAsync(WaitUntil.Completed); + NginxCertificateData data = new NginxCertificateData(); + ArmOperation lro = await nginxCertificate.UpdateAsync(WaitUntil.Completed, data); + NginxCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NginxCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxConfigurationCollection.cs b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxConfigurationCollection.cs index 59dabcbe6d8e3..b6a3d99006c51 100644 --- a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxConfigurationCollection.cs +++ b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NginxConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConfigurationsList() + public async Task CreateOrUpdate_ConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_List.json - // this example is just showing the usage of "Configurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_CreateOrUpdate.json + // this example is just showing the usage of "Configurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_ConfigurationsList() // get the collection of this NginxConfigurationResource NginxConfigurationCollection collection = nginxDeployment.GetNginxConfigurations(); - // invoke the operation and iterate over the result - await foreach (NginxConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NginxConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string configurationName = "default"; + NginxConfigurationData data = new NginxConfigurationData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + NginxConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NginxConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_ConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConfigurationsGet() + public async Task GetAll_ConfigurationsList() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_Get.json - // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_List.json + // this example is just showing the usage of "Configurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_ConfigurationsGet() // get the collection of this NginxConfigurationResource NginxConfigurationCollection collection = nginxDeployment.GetNginxConfigurations(); - // invoke the operation - string configurationName = "default"; - bool result = await collection.ExistsAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (NginxConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NginxConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConfigurationsGet() + public async Task Exists_ConfigurationsGet() { // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_Get.json // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_ConfigurationsGet() // invoke the operation string configurationName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - NginxConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NginxConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConfigurationsCreateOrUpdate() + public async Task GetIfExists_ConfigurationsGet() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_CreateOrUpdate.json - // this example is just showing the usage of "Configurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_Get.json + // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_ConfigurationsCreateOrUpdate() // invoke the operation string configurationName = "default"; - NginxConfigurationData data = new NginxConfigurationData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - NginxConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + NginxConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NginxConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NginxConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxConfigurationResource.cs b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxConfigurationResource.cs index 277bed9ea925a..f95c3fee41841 100644 --- a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxConfigurationResource.cs +++ b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxConfigurationResource.cs @@ -49,10 +49,10 @@ public async Task Get_ConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConfigurationsCreateOrUpdate() + public async Task Delete_ConfigurationsDelete() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_CreateOrUpdate.json - // this example is just showing the usage of "Configurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_Delete.json + // this example is just showing the usage of "Configurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,23 +69,17 @@ public async Task Update_ConfigurationsCreateOrUpdate() NginxConfigurationResource nginxConfiguration = client.GetNginxConfigurationResource(nginxConfigurationResourceId); // invoke the operation - NginxConfigurationData data = new NginxConfigurationData(); - ArmOperation lro = await nginxConfiguration.UpdateAsync(WaitUntil.Completed, data); - NginxConfigurationResource result = lro.Value; + await nginxConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NginxConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ConfigurationsDelete() + public async Task Update_ConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_Delete.json - // this example is just showing the usage of "Configurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Configurations_CreateOrUpdate.json + // this example is just showing the usage of "Configurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_ConfigurationsDelete() NginxConfigurationResource nginxConfiguration = client.GetNginxConfigurationResource(nginxConfigurationResourceId); // invoke the operation - await nginxConfiguration.DeleteAsync(WaitUntil.Completed); + NginxConfigurationData data = new NginxConfigurationData(); + ArmOperation lro = await nginxConfiguration.UpdateAsync(WaitUntil.Completed, data); + NginxConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NginxConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxDeploymentCollection.cs b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxDeploymentCollection.cs index 142e6255421b4..16c9c2e312083 100644 --- a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxDeploymentCollection.cs +++ b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxDeploymentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NginxDeploymentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DeploymentsGet() + public async Task CreateOrUpdate_DeploymentsCreate() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Get.json - // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Create.json + // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,9 @@ public async Task Get_DeploymentsGet() // invoke the operation string deploymentName = "myDeployment"; - NginxDeploymentResource result = await collection.GetAsync(deploymentName); + NginxDeploymentData data = new NginxDeploymentData(default); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); + NginxDeploymentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_DeploymentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DeploymentsGet() + public async Task Get_DeploymentsGet() { // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Get.json // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,16 +75,20 @@ public async Task Exists_DeploymentsGet() // invoke the operation string deploymentName = "myDeployment"; - bool result = await collection.ExistsAsync(deploymentName); + NginxDeploymentResource result = await collection.GetAsync(deploymentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NginxDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DeploymentsGet() + public async Task Get_DeploymentsGetAutoScale() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Get.json + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Get_AutoScale.json // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -102,28 +108,55 @@ public async Task GetIfExists_DeploymentsGet() // invoke the operation string deploymentName = "myDeployment"; - NullableResponse response = await collection.GetIfExistsAsync(deploymentName); - NginxDeploymentResource result = response.HasValue ? response.Value : null; + NginxDeploymentResource result = await collection.GetAsync(deploymentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NginxDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_DeploymentsListByResourceGroup() + { + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_ListByResourceGroup.json + // this example is just showing the usage of "Deployments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NginxDeploymentResource + NginxDeploymentCollection collection = resourceGroupResource.GetNginxDeployments(); + + // invoke the operation and iterate over the result + await foreach (NginxDeploymentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NginxDeploymentData resourceData = result.Data; + NginxDeploymentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DeploymentsGetAutoScale() + public async Task Exists_DeploymentsGet() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Get_AutoScale.json + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Get.json // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -143,13 +176,9 @@ public async Task Get_DeploymentsGetAutoScale() // invoke the operation string deploymentName = "myDeployment"; - NginxDeploymentResource result = await collection.GetAsync(deploymentName); + bool result = await collection.ExistsAsync(deploymentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NginxDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -183,9 +212,9 @@ public async Task Exists_DeploymentsGetAutoScale() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DeploymentsGetAutoScale() + public async Task GetIfExists_DeploymentsGet() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Get_AutoScale.json + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Get.json // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -224,10 +253,10 @@ public async Task GetIfExists_DeploymentsGetAutoScale() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DeploymentsCreate() + public async Task GetIfExists_DeploymentsGetAutoScale() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Create.json - // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Get_AutoScale.json + // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -246,50 +275,21 @@ public async Task CreateOrUpdate_DeploymentsCreate() // invoke the operation string deploymentName = "myDeployment"; - NginxDeploymentData data = new NginxDeploymentData(new AzureLocation("placeholder")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); - NginxDeploymentResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NginxDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_DeploymentsListByResourceGroup() - { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_ListByResourceGroup.json - // this example is just showing the usage of "Deployments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this NginxDeploymentResource - NginxDeploymentCollection collection = resourceGroupResource.GetNginxDeployments(); + NullableResponse response = await collection.GetIfExistsAsync(deploymentName); + NginxDeploymentResource result = response.HasValue ? response.Value : null; - // invoke the operation and iterate over the result - await foreach (NginxDeploymentResource item in collection.GetAllAsync()) + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NginxDeploymentData resourceData = item.Data; + NginxDeploymentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxDeploymentResource.cs b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxDeploymentResource.cs index e6e81908886c0..57bdb981c5008 100644 --- a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxDeploymentResource.cs +++ b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_NginxDeploymentResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Nginx.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Nginx.Samples @@ -79,10 +78,10 @@ public async Task Get_DeploymentsGetAutoScale() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DeploymentsUpdate() + public async Task Delete_DeploymentsDelete() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Update.json - // this example is just showing the usage of "Deployments_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Delete.json + // this example is just showing the usage of "Deployments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,23 +97,17 @@ public async Task Update_DeploymentsUpdate() NginxDeploymentResource nginxDeployment = client.GetNginxDeploymentResource(nginxDeploymentResourceId); // invoke the operation - NginxDeploymentPatch patch = new NginxDeploymentPatch(); - ArmOperation lro = await nginxDeployment.UpdateAsync(WaitUntil.Completed, patch); - NginxDeploymentResource result = lro.Value; + await nginxDeployment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NginxDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeploymentsDelete() + public async Task Update_DeploymentsUpdate() { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Delete.json - // this example is just showing the usage of "Deployments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_Update.json + // this example is just showing the usage of "Deployments_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,40 +123,15 @@ public async Task Delete_DeploymentsDelete() NginxDeploymentResource nginxDeployment = client.GetNginxDeploymentResource(nginxDeploymentResourceId); // invoke the operation - await nginxDeployment.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNginxDeployments_DeploymentsList() - { - // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_List.json - // this example is just showing the usage of "Deployments_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NginxDeploymentResource item in subscriptionResource.GetNginxDeploymentsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NginxDeploymentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + NginxDeploymentPatch patch = new NginxDeploymentPatch(); + ArmOperation lro = await nginxDeployment.UpdateAsync(WaitUntil.Completed, patch); + NginxDeploymentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NginxDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..3c39a31b4a680 --- /dev/null +++ b/sdk/nginx/Azure.ResourceManager.Nginx/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Nginx.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNginxDeployments_DeploymentsList() + { + // Generated from example definition: specification/nginx/resource-manager/NGINX.NGINXPLUS/preview/2024-06-01-preview/examples/Deployments_List.json + // this example is just showing the usage of "Deployments_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NginxDeploymentResource item in subscriptionResource.GetNginxDeploymentsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NginxDeploymentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubAuthorizationRuleCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubAuthorizationRuleCollection.cs index c9905acb90235..5007bf62923c9 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubAuthorizationRuleCollection.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubAuthorizationRuleCollection.cs @@ -42,12 +42,9 @@ public async Task CreateOrUpdate_NotificationHubsCreateOrUpdateAuthorizationRule // invoke the operation string authorizationRuleName = "MyManageSharedAccessKey"; - NotificationHubAuthorizationRuleData data = new NotificationHubAuthorizationRuleData(new AzureLocation("placeholder")) + NotificationHubAuthorizationRuleData data = new NotificationHubAuthorizationRuleData(default) { - AccessRights = -{ -AuthorizationRuleAccessRightExt.Listen,AuthorizationRuleAccessRightExt.Send -}, + AccessRights = { AuthorizationRuleAccessRightExt.Listen, AuthorizationRuleAccessRightExt.Send }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); NotificationHubAuthorizationRuleResource result = lro.Value; @@ -96,10 +93,10 @@ public async Task Get_NotificationHubsGetAuthorizationRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NotificationHubsGetAuthorizationRule() + public async Task GetAll_NotificationHubsListAuthorizationRules() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleGet.json - // this example is just showing the usage of "NotificationHubs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleList.json + // this example is just showing the usage of "NotificationHubs_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +115,22 @@ public async Task Exists_NotificationHubsGetAuthorizationRule() // get the collection of this NotificationHubAuthorizationRuleResource NotificationHubAuthorizationRuleCollection collection = notificationHub.GetNotificationHubAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "DefaultListenSharedAccessSignature"; - bool result = await collection.ExistsAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (NotificationHubAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationHubAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NotificationHubsGetAuthorizationRule() + public async Task Exists_NotificationHubsGetAuthorizationRule() { // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleGet.json // this example is just showing the usage of "NotificationHubs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. @@ -151,29 +154,17 @@ public async Task GetIfExists_NotificationHubsGetAuthorizationRule() // invoke the operation string authorizationRuleName = "DefaultListenSharedAccessSignature"; - NullableResponse response = await collection.GetIfExistsAsync(authorizationRuleName); - NotificationHubAuthorizationRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(authorizationRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationHubAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NotificationHubsListAuthorizationRules() + public async Task GetIfExists_NotificationHubsGetAuthorizationRule() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleList.json - // this example is just showing the usage of "NotificationHubs_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleGet.json + // this example is just showing the usage of "NotificationHubs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,17 +183,23 @@ public async Task GetAll_NotificationHubsListAuthorizationRules() // get the collection of this NotificationHubAuthorizationRuleResource NotificationHubAuthorizationRuleCollection collection = notificationHub.GetNotificationHubAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (NotificationHubAuthorizationRuleResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationRuleName = "DefaultListenSharedAccessSignature"; + NullableResponse response = await collection.GetIfExistsAsync(authorizationRuleName); + NotificationHubAuthorizationRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NotificationHubAuthorizationRuleData resourceData = item.Data; + NotificationHubAuthorizationRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubAuthorizationRuleResource.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubAuthorizationRuleResource.cs index 3ee523db0e548..2f89f0de6421c 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubAuthorizationRuleResource.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubAuthorizationRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_NotificationHubAuthorizationRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NotificationHubsCreateOrUpdateAuthorizationRule() + public async Task Get_NotificationHubsGetAuthorizationRule() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleCreateOrUpdate.json - // this example is just showing the usage of "NotificationHubs_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleGet.json + // this example is just showing the usage of "NotificationHubs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,20 +34,12 @@ public async Task Update_NotificationHubsCreateOrUpdateAuthorizationRule() string resourceGroupName = "5ktrial"; string namespaceName = "nh-sdk-ns"; string notificationHubName = "nh-sdk-hub"; - string authorizationRuleName = "MyManageSharedAccessKey"; + string authorizationRuleName = "DefaultListenSharedAccessSignature"; ResourceIdentifier notificationHubAuthorizationRuleResourceId = NotificationHubAuthorizationRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName); NotificationHubAuthorizationRuleResource notificationHubAuthorizationRule = client.GetNotificationHubAuthorizationRuleResource(notificationHubAuthorizationRuleResourceId); // invoke the operation - NotificationHubAuthorizationRuleData data = new NotificationHubAuthorizationRuleData(new AzureLocation("placeholder")) - { - AccessRights = -{ -AuthorizationRuleAccessRightExt.Listen,AuthorizationRuleAccessRightExt.Send -}, - }; - ArmOperation lro = await notificationHubAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); - NotificationHubAuthorizationRuleResource result = lro.Value; + NotificationHubAuthorizationRuleResource result = await notificationHubAuthorizationRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,10 +78,10 @@ public async Task Delete_NotificationHubsDeleteAuthorizationRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NotificationHubsGetAuthorizationRule() + public async Task Update_NotificationHubsCreateOrUpdateAuthorizationRule() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleGet.json - // this example is just showing the usage of "NotificationHubs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/AuthorizationRuleCreateOrUpdate.json + // this example is just showing the usage of "NotificationHubs_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,12 +94,17 @@ public async Task Get_NotificationHubsGetAuthorizationRule() string resourceGroupName = "5ktrial"; string namespaceName = "nh-sdk-ns"; string notificationHubName = "nh-sdk-hub"; - string authorizationRuleName = "DefaultListenSharedAccessSignature"; + string authorizationRuleName = "MyManageSharedAccessKey"; ResourceIdentifier notificationHubAuthorizationRuleResourceId = NotificationHubAuthorizationRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, notificationHubName, authorizationRuleName); NotificationHubAuthorizationRuleResource notificationHubAuthorizationRule = client.GetNotificationHubAuthorizationRuleResource(notificationHubAuthorizationRuleResourceId); // invoke the operation - NotificationHubAuthorizationRuleResource result = await notificationHubAuthorizationRule.GetAsync(); + NotificationHubAuthorizationRuleData data = new NotificationHubAuthorizationRuleData(default) + { + AccessRights = { AuthorizationRuleAccessRightExt.Listen, AuthorizationRuleAccessRightExt.Send }, + }; + ArmOperation lro = await notificationHubAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); + NotificationHubAuthorizationRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubCollection.cs index 84016d84d3403..6b477bb5818ca 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubCollection.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NotificationHubCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NotificationHubsGet() + public async Task CreateOrUpdate_NotificationHubsCreateOrUpdate() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Get.json - // this example is just showing the usage of "NotificationHubs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/CreateOrUpdate.json + // this example is just showing the usage of "NotificationHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,9 @@ public async Task Get_NotificationHubsGet() // invoke the operation string notificationHubName = "nh-sdk-hub"; - NotificationHubResource result = await collection.GetAsync(notificationHubName); + NotificationHubData data = new NotificationHubData(new AzureLocation("eastus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, notificationHubName, data); + NotificationHubResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_NotificationHubsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NotificationHubsGet() + public async Task Get_NotificationHubsGet() { // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Get.json // this example is just showing the usage of "NotificationHubs_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +76,21 @@ public async Task Exists_NotificationHubsGet() // invoke the operation string notificationHubName = "nh-sdk-hub"; - bool result = await collection.ExistsAsync(notificationHubName); + NotificationHubResource result = await collection.GetAsync(notificationHubName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NotificationHubsGet() + public async Task GetAll_NotificationHubsList() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Get.json - // this example is just showing the usage of "NotificationHubs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/List.json + // this example is just showing the usage of "NotificationHubs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +108,25 @@ public async Task GetIfExists_NotificationHubsGet() // get the collection of this NotificationHubResource NotificationHubCollection collection = notificationHubNamespace.GetNotificationHubs(); - // invoke the operation - string notificationHubName = "nh-sdk-hub"; - NullableResponse response = await collection.GetIfExistsAsync(notificationHubName); - NotificationHubResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NotificationHubResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NotificationHubData resourceData = result.Data; + NotificationHubData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NotificationHubsCreateOrUpdate() + public async Task Exists_NotificationHubsGet() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/CreateOrUpdate.json - // this example is just showing the usage of "NotificationHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Get.json + // this example is just showing the usage of "NotificationHubs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,23 +146,17 @@ public async Task CreateOrUpdate_NotificationHubsCreateOrUpdate() // invoke the operation string notificationHubName = "nh-sdk-hub"; - NotificationHubData data = new NotificationHubData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, notificationHubName, data); - NotificationHubResource result = lro.Value; + bool result = await collection.ExistsAsync(notificationHubName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NotificationHubsList() + public async Task GetIfExists_NotificationHubsGet() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/List.json - // this example is just showing the usage of "NotificationHubs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Get.json + // this example is just showing the usage of "NotificationHubs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_NotificationHubsList() // get the collection of this NotificationHubResource NotificationHubCollection collection = notificationHubNamespace.GetNotificationHubs(); - // invoke the operation and iterate over the result - await foreach (NotificationHubResource item in collection.GetAllAsync()) + // invoke the operation + string notificationHubName = "nh-sdk-hub"; + NullableResponse response = await collection.GetIfExistsAsync(notificationHubName); + NotificationHubResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NotificationHubData resourceData = item.Data; + NotificationHubData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceAuthorizationRuleCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceAuthorizationRuleCollection.cs index a374b048392e0..8e3bfc3df313f 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceAuthorizationRuleCollection.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceAuthorizationRuleCollection.cs @@ -41,12 +41,9 @@ public async Task CreateOrUpdate_NamespacesCreateOrUpdateAuthorizationRule() // invoke the operation string authorizationRuleName = "sdk-AuthRules-1788"; - NotificationHubAuthorizationRuleData data = new NotificationHubAuthorizationRuleData(new AzureLocation("placeholder")) + NotificationHubAuthorizationRuleData data = new NotificationHubAuthorizationRuleData(default) { - AccessRights = -{ -AuthorizationRuleAccessRightExt.Listen,AuthorizationRuleAccessRightExt.Send -}, + AccessRights = { AuthorizationRuleAccessRightExt.Listen, AuthorizationRuleAccessRightExt.Send }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); NotificationHubNamespaceAuthorizationRuleResource result = lro.Value; @@ -94,10 +91,10 @@ public async Task Get_NamespacesGetAuthorizationRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NamespacesGetAuthorizationRule() + public async Task GetAll_NamespacesListAuthorizationRules() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleGet.json - // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleList.json + // this example is just showing the usage of "Namespaces_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +112,22 @@ public async Task Exists_NamespacesGetAuthorizationRule() // get the collection of this NotificationHubNamespaceAuthorizationRuleResource NotificationHubNamespaceAuthorizationRuleCollection collection = notificationHubNamespace.GetNotificationHubNamespaceAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "RootManageSharedAccessKey"; - bool result = await collection.ExistsAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (NotificationHubNamespaceAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationHubAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NamespacesGetAuthorizationRule() + public async Task Exists_NamespacesGetAuthorizationRule() { // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleGet.json // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. @@ -147,29 +150,17 @@ public async Task GetIfExists_NamespacesGetAuthorizationRule() // invoke the operation string authorizationRuleName = "RootManageSharedAccessKey"; - NullableResponse response = await collection.GetIfExistsAsync(authorizationRuleName); - NotificationHubNamespaceAuthorizationRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(authorizationRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationHubAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NamespacesListAuthorizationRules() + public async Task GetIfExists_NamespacesGetAuthorizationRule() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleList.json - // this example is just showing the usage of "Namespaces_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleGet.json + // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +178,23 @@ public async Task GetAll_NamespacesListAuthorizationRules() // get the collection of this NotificationHubNamespaceAuthorizationRuleResource NotificationHubNamespaceAuthorizationRuleCollection collection = notificationHubNamespace.GetNotificationHubNamespaceAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (NotificationHubNamespaceAuthorizationRuleResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationRuleName = "RootManageSharedAccessKey"; + NullableResponse response = await collection.GetIfExistsAsync(authorizationRuleName); + NotificationHubNamespaceAuthorizationRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NotificationHubAuthorizationRuleData resourceData = item.Data; + NotificationHubAuthorizationRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceAuthorizationRuleResource.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceAuthorizationRuleResource.cs index 6b0fd3d504dae..0112bbfa5c12c 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceAuthorizationRuleResource.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceAuthorizationRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_NotificationHubNamespaceAuthorizationRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NamespacesCreateOrUpdateAuthorizationRule() + public async Task Get_NamespacesGetAuthorizationRule() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleCreateOrUpdate.json - // this example is just showing the usage of "Namespaces_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleGet.json + // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,20 +33,12 @@ public async Task Update_NamespacesCreateOrUpdateAuthorizationRule() string subscriptionId = "29cfa613-cbbc-4512-b1d6-1b3a92c7fa40"; string resourceGroupName = "5ktrial"; string namespaceName = "nh-sdk-ns"; - string authorizationRuleName = "sdk-AuthRules-1788"; + string authorizationRuleName = "RootManageSharedAccessKey"; ResourceIdentifier notificationHubNamespaceAuthorizationRuleResourceId = NotificationHubNamespaceAuthorizationRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName); NotificationHubNamespaceAuthorizationRuleResource notificationHubNamespaceAuthorizationRule = client.GetNotificationHubNamespaceAuthorizationRuleResource(notificationHubNamespaceAuthorizationRuleResourceId); // invoke the operation - NotificationHubAuthorizationRuleData data = new NotificationHubAuthorizationRuleData(new AzureLocation("placeholder")) - { - AccessRights = -{ -AuthorizationRuleAccessRightExt.Listen,AuthorizationRuleAccessRightExt.Send -}, - }; - ArmOperation lro = await notificationHubNamespaceAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); - NotificationHubNamespaceAuthorizationRuleResource result = lro.Value; + NotificationHubNamespaceAuthorizationRuleResource result = await notificationHubNamespaceAuthorizationRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -84,10 +76,10 @@ public async Task Delete_NamespacesDeleteAuthorizationRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NamespacesGetAuthorizationRule() + public async Task Update_NamespacesCreateOrUpdateAuthorizationRule() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleGet.json - // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/AuthorizationRuleCreateOrUpdate.json + // this example is just showing the usage of "Namespaces_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,12 +91,17 @@ public async Task Get_NamespacesGetAuthorizationRule() string subscriptionId = "29cfa613-cbbc-4512-b1d6-1b3a92c7fa40"; string resourceGroupName = "5ktrial"; string namespaceName = "nh-sdk-ns"; - string authorizationRuleName = "RootManageSharedAccessKey"; + string authorizationRuleName = "sdk-AuthRules-1788"; ResourceIdentifier notificationHubNamespaceAuthorizationRuleResourceId = NotificationHubNamespaceAuthorizationRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, authorizationRuleName); NotificationHubNamespaceAuthorizationRuleResource notificationHubNamespaceAuthorizationRule = client.GetNotificationHubNamespaceAuthorizationRuleResource(notificationHubNamespaceAuthorizationRuleResourceId); // invoke the operation - NotificationHubNamespaceAuthorizationRuleResource result = await notificationHubNamespaceAuthorizationRule.GetAsync(); + NotificationHubAuthorizationRuleData data = new NotificationHubAuthorizationRuleData(default) + { + AccessRights = { AuthorizationRuleAccessRightExt.Listen, AuthorizationRuleAccessRightExt.Send }, + }; + ArmOperation lro = await notificationHubNamespaceAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); + NotificationHubNamespaceAuthorizationRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceCollection.cs index d69095cfb3a9f..b1ccf434e5314 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceCollection.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NotificationHubNamespaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NamespacesGet() + public async Task CreateOrUpdate_NamespacesCreateOrUpdate() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Get.json - // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/CreateOrUpdate.json + // this example is just showing the usage of "Namespaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,25 @@ public async Task Get_NamespacesGet() // invoke the operation string namespaceName = "nh-sdk-ns"; - NotificationHubNamespaceResource result = await collection.GetAsync(namespaceName); + NotificationHubNamespaceData data = new NotificationHubNamespaceData(new AzureLocation("South Central US"), new NotificationHubSku(NotificationHubSkuName.Standard) + { + Tier = "Standard", + }) + { + ZoneRedundancy = ZoneRedundancyPreference.Enabled, + NetworkAcls = new NotificationHubNetworkAcls + { + IPRules = { new NotificationHubIPRule("185.48.100.00/24", new AuthorizationRuleAccessRightExt[] { AuthorizationRuleAccessRightExt.Manage, AuthorizationRuleAccessRightExt.Send, AuthorizationRuleAccessRightExt.Listen }) }, + PublicNetworkRuleAccessRights = { AuthorizationRuleAccessRightExt.Listen }, + }, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, data); + NotificationHubNamespaceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +70,7 @@ public async Task Get_NamespacesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NamespacesGet() + public async Task Get_NamespacesGet() { // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Get.json // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +92,21 @@ public async Task Exists_NamespacesGet() // invoke the operation string namespaceName = "nh-sdk-ns"; - bool result = await collection.ExistsAsync(namespaceName); + NotificationHubNamespaceResource result = await collection.GetAsync(namespaceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationHubNamespaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NamespacesGet() + public async Task GetAll_NamespacesList() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Get.json - // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/ListByResourceGroup.json + // this example is just showing the usage of "Namespaces_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +123,25 @@ public async Task GetIfExists_NamespacesGet() // get the collection of this NotificationHubNamespaceResource NotificationHubNamespaceCollection collection = resourceGroupResource.GetNotificationHubNamespaces(); - // invoke the operation - string namespaceName = "nh-sdk-ns"; - NullableResponse response = await collection.GetIfExistsAsync(namespaceName); - NotificationHubNamespaceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NotificationHubNamespaceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NotificationHubNamespaceData resourceData = result.Data; + NotificationHubNamespaceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NamespacesCreateOrUpdate() + public async Task Exists_NamespacesGet() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/CreateOrUpdate.json - // this example is just showing the usage of "Namespaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Get.json + // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,48 +160,17 @@ public async Task CreateOrUpdate_NamespacesCreateOrUpdate() // invoke the operation string namespaceName = "nh-sdk-ns"; - NotificationHubNamespaceData data = new NotificationHubNamespaceData(new AzureLocation("South Central US"), new NotificationHubSku(NotificationHubSkuName.Standard) - { - Tier = "Standard", - }) - { - ZoneRedundancy = ZoneRedundancyPreference.Enabled, - NetworkAcls = new NotificationHubNetworkAcls() - { - IPRules = -{ -new NotificationHubIPRule("185.48.100.00/24",new AuthorizationRuleAccessRightExt[] -{ -AuthorizationRuleAccessRightExt.Manage,AuthorizationRuleAccessRightExt.Send,AuthorizationRuleAccessRightExt.Listen -}) -}, - PublicNetworkRuleAccessRights = -{ -AuthorizationRuleAccessRightExt.Listen -}, - }, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, data); - NotificationHubNamespaceResource result = lro.Value; + bool result = await collection.ExistsAsync(namespaceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationHubNamespaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NamespacesList() + public async Task GetIfExists_NamespacesGet() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/ListByResourceGroup.json - // this example is just showing the usage of "Namespaces_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Get.json + // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -202,17 +187,23 @@ public async Task GetAll_NamespacesList() // get the collection of this NotificationHubNamespaceResource NotificationHubNamespaceCollection collection = resourceGroupResource.GetNotificationHubNamespaces(); - // invoke the operation and iterate over the result - await foreach (NotificationHubNamespaceResource item in collection.GetAllAsync()) + // invoke the operation + string namespaceName = "nh-sdk-ns"; + NullableResponse response = await collection.GetIfExistsAsync(namespaceName); + NotificationHubNamespaceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NotificationHubNamespaceData resourceData = item.Data; + NotificationHubNamespaceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceResource.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceResource.cs index a46ee36ac6a72..6c5c5f2092d3a 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceResource.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubNamespaceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NotificationHubs.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NotificationHubs.Samples @@ -19,10 +18,10 @@ public partial class Sample_NotificationHubNamespaceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CheckNotificationHubAvailability_NotificationHubsCheckNotificationHubAvailability() + public async Task Get_NamespacesGet() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/CheckAvailability.json - // this example is just showing the usage of "NotificationHubs_CheckNotificationHubAvailability" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Get.json + // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,48 +32,26 @@ public async Task CheckNotificationHubAvailability_NotificationHubsCheckNotifica // for more information of creating NotificationHubNamespaceResource, please refer to the document of NotificationHubNamespaceResource string subscriptionId = "29cfa613-cbbc-4512-b1d6-1b3a92c7fa40"; string resourceGroupName = "5ktrial"; - string namespaceName = "locp-newns"; + string namespaceName = "nh-sdk-ns"; ResourceIdentifier notificationHubNamespaceResourceId = NotificationHubNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); NotificationHubNamespaceResource notificationHubNamespace = client.GetNotificationHubNamespaceResource(notificationHubNamespaceResourceId); // invoke the operation - NotificationHubAvailabilityContent content = new NotificationHubAvailabilityContent(new AzureLocation("West Europe")); - NotificationHubAvailabilityResult result = await notificationHubNamespace.CheckNotificationHubAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckNotificationHubNamespaceAvailability_NamespacesCheckAvailability() - { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/CheckAvailability.json - // this example is just showing the usage of "Namespaces_CheckAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "29cfa613-cbbc-4512-b1d6-1b3a92c7fa40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - NotificationHubAvailabilityContent content = new NotificationHubAvailabilityContent(new AzureLocation("placeholder")); - NotificationHubAvailabilityResult result = await subscriptionResource.CheckNotificationHubNamespaceAvailabilityAsync(content); + NotificationHubNamespaceResource result = await notificationHubNamespace.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationHubNamespaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NamespacesGet() + public async Task Delete_NamespacesDelete() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Get.json - // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Delete.json + // this example is just showing the usage of "Namespaces_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -90,13 +67,9 @@ public async Task Get_NamespacesGet() NotificationHubNamespaceResource notificationHubNamespace = client.GetNotificationHubNamespaceResource(notificationHubNamespaceResourceId); // invoke the operation - NotificationHubNamespaceResource result = await notificationHubNamespace.GetAsync(); + await notificationHubNamespace.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationHubNamespaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -120,12 +93,12 @@ public async Task Update_NamespacesUpdate() NotificationHubNamespaceResource notificationHubNamespace = client.GetNotificationHubNamespaceResource(notificationHubNamespaceResourceId); // invoke the operation - NotificationHubNamespacePatch patch = new NotificationHubNamespacePatch() + NotificationHubNamespacePatch patch = new NotificationHubNamespacePatch { Sku = new NotificationHubSku(NotificationHubSkuName.Free), - Properties = new NotificationHubNamespaceProperties() + Properties = new NotificationHubNamespaceProperties { - PnsCredentials = new PnsCredentials() + PnsCredentials = new PnsCredentials { GcmCredential = new NotificationHubGcmCredential("#############################") { @@ -135,7 +108,7 @@ public async Task Update_NamespacesUpdate() }, Tags = { -["tag1"] = "value3", +["tag1"] = "value3" }, }; NotificationHubNamespaceResource result = await notificationHubNamespace.UpdateAsync(patch); @@ -149,10 +122,10 @@ public async Task Update_NamespacesUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NamespacesDelete() + public async Task CheckNotificationHubAvailability_NotificationHubsCheckNotificationHubAvailability() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/Delete.json - // this example is just showing the usage of "Namespaces_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/CheckAvailability.json + // this example is just showing the usage of "NotificationHubs_CheckNotificationHubAvailability" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -163,45 +136,15 @@ public async Task Delete_NamespacesDelete() // for more information of creating NotificationHubNamespaceResource, please refer to the document of NotificationHubNamespaceResource string subscriptionId = "29cfa613-cbbc-4512-b1d6-1b3a92c7fa40"; string resourceGroupName = "5ktrial"; - string namespaceName = "nh-sdk-ns"; + string namespaceName = "locp-newns"; ResourceIdentifier notificationHubNamespaceResourceId = NotificationHubNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); NotificationHubNamespaceResource notificationHubNamespace = client.GetNotificationHubNamespaceResource(notificationHubNamespaceResourceId); // invoke the operation - await notificationHubNamespace.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNotificationHubNamespaces_NamespacesListAll() - { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/ListBySubscription.json - // this example is just showing the usage of "Namespaces_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "29cfa613-cbbc-4512-b1d6-1b3a92c7fa40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NotificationHubNamespaceResource item in subscriptionResource.GetNotificationHubNamespacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationHubNamespaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + NotificationHubAvailabilityContent content = new NotificationHubAvailabilityContent(new AzureLocation("West Europe")); + NotificationHubAvailabilityResult result = await notificationHubNamespace.CheckNotificationHubAvailabilityAsync(content); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubPrivateEndpointConnectionCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubPrivateEndpointConnectionCollection.cs index 52c62c9671dd7..8146f2472d6ec 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubPrivateEndpointConnectionCollection.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubPrivateEndpointConnectionCollection.cs @@ -41,11 +41,11 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() // invoke the operation string privateEndpointConnectionName = "nh-sdk-ns.1fa229cd-bf3f-47f0-8c49-afb36723997e"; - NotificationHubPrivateEndpointConnectionData data = new NotificationHubPrivateEndpointConnectionData() + NotificationHubPrivateEndpointConnectionData data = new NotificationHubPrivateEndpointConnectionData { - Properties = new NotificationHubPrivateEndpointConnectionProperties() + Properties = new NotificationHubPrivateEndpointConnectionProperties { - ConnectionState = new RemotePrivateLinkServiceConnectionState() + ConnectionState = new RemotePrivateLinkServiceConnectionState { Status = NotificationHubPrivateLinkConnectionStatus.Approved, }, @@ -97,10 +97,10 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGet() + public async Task GetAll_PrivateEndpointConnectionsList() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionList.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +118,22 @@ public async Task Exists_PrivateEndpointConnectionsGet() // get the collection of this NotificationHubPrivateEndpointConnectionResource NotificationHubPrivateEndpointConnectionCollection collection = notificationHubNamespace.GetNotificationHubPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "nh-sdk-ns.1fa229cd-bf3f-47f0-8c49-afb36723997e"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (NotificationHubPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationHubPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGet() + public async Task Exists_PrivateEndpointConnectionsGet() { // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -150,29 +156,17 @@ public async Task GetIfExists_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "nh-sdk-ns.1fa229cd-bf3f-47f0-8c49-afb36723997e"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - NotificationHubPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationHubPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsList() + public async Task GetIfExists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionList.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +184,23 @@ public async Task GetAll_PrivateEndpointConnectionsList() // get the collection of this NotificationHubPrivateEndpointConnectionResource NotificationHubPrivateEndpointConnectionCollection collection = notificationHubNamespace.GetNotificationHubPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (NotificationHubPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "nh-sdk-ns.1fa229cd-bf3f-47f0-8c49-afb36723997e"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + NotificationHubPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NotificationHubPrivateEndpointConnectionData resourceData = item.Data; + NotificationHubPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubPrivateEndpointConnectionResource.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubPrivateEndpointConnectionResource.cs index 638dab95ec8e8..e0bec1c5669c9 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubPrivateEndpointConnectionResource.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_NotificationHubPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsUpdate() + public async Task Get_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,18 +38,7 @@ public async Task Update_PrivateEndpointConnectionsUpdate() NotificationHubPrivateEndpointConnectionResource notificationHubPrivateEndpointConnection = client.GetNotificationHubPrivateEndpointConnectionResource(notificationHubPrivateEndpointConnectionResourceId); // invoke the operation - NotificationHubPrivateEndpointConnectionData data = new NotificationHubPrivateEndpointConnectionData() - { - Properties = new NotificationHubPrivateEndpointConnectionProperties() - { - ConnectionState = new RemotePrivateLinkServiceConnectionState() - { - Status = NotificationHubPrivateLinkConnectionStatus.Approved, - }, - }, - }; - ArmOperation lro = await notificationHubPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - NotificationHubPrivateEndpointConnectionResource result = lro.Value; + NotificationHubPrivateEndpointConnectionResource result = await notificationHubPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,10 +76,10 @@ public async Task Delete_PrivateEndpointConnectionsDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGet() + public async Task Update_PrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,7 +96,18 @@ public async Task Get_PrivateEndpointConnectionsGet() NotificationHubPrivateEndpointConnectionResource notificationHubPrivateEndpointConnection = client.GetNotificationHubPrivateEndpointConnectionResource(notificationHubPrivateEndpointConnectionResourceId); // invoke the operation - NotificationHubPrivateEndpointConnectionResource result = await notificationHubPrivateEndpointConnection.GetAsync(); + NotificationHubPrivateEndpointConnectionData data = new NotificationHubPrivateEndpointConnectionData + { + Properties = new NotificationHubPrivateEndpointConnectionProperties + { + ConnectionState = new RemotePrivateLinkServiceConnectionState + { + Status = NotificationHubPrivateLinkConnectionStatus.Approved, + }, + }, + }; + ArmOperation lro = await notificationHubPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + NotificationHubPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubResource.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubResource.cs index 32fc7b455b8a3..19ffa4639e8ec 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubResource.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubResource.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NotificationHubs.Models; @@ -49,10 +50,10 @@ public async Task Get_NotificationHubsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NotificationHubsUpdate() + public async Task Delete_NotificationHubsDelete() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Update.json - // this example is just showing the usage of "NotificationHubs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Delete.json + // this example is just showing the usage of "NotificationHubs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,36 +63,24 @@ public async Task Update_NotificationHubsUpdate() // this example assumes you already have this NotificationHubResource created on azure // for more information of creating NotificationHubResource, please refer to the document of NotificationHubResource string subscriptionId = "29cfa613-cbbc-4512-b1d6-1b3a92c7fa40"; - string resourceGroupName = "sdkresourceGroup"; + string resourceGroupName = "5ktrial"; string namespaceName = "nh-sdk-ns"; - string notificationHubName = "sdk-notificationHubs-8708"; + string notificationHubName = "nh-sdk-hub"; ResourceIdentifier notificationHubResourceId = NotificationHubResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, notificationHubName); NotificationHubResource notificationHub = client.GetNotificationHubResource(notificationHubResourceId); // invoke the operation - NotificationHubPatch patch = new NotificationHubPatch(new AzureLocation("placeholder")) - { - RegistrationTtl = TimeSpan.Parse("10675199.02:48:05.4775807"), - GcmCredential = new NotificationHubGcmCredential("###################################") - { - GcmEndpoint = new Uri("https://fcm.googleapis.com/fcm/send"), - }, - }; - NotificationHubResource result = await notificationHub.UpdateAsync(patch); + await notificationHub.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NotificationHubsDelete() + public async Task Update_NotificationHubsUpdate() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Delete.json - // this example is just showing the usage of "NotificationHubs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/NotificationHubs/Update.json + // this example is just showing the usage of "NotificationHubs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,16 +90,28 @@ public async Task Delete_NotificationHubsDelete() // this example assumes you already have this NotificationHubResource created on azure // for more information of creating NotificationHubResource, please refer to the document of NotificationHubResource string subscriptionId = "29cfa613-cbbc-4512-b1d6-1b3a92c7fa40"; - string resourceGroupName = "5ktrial"; + string resourceGroupName = "sdkresourceGroup"; string namespaceName = "nh-sdk-ns"; - string notificationHubName = "nh-sdk-hub"; + string notificationHubName = "sdk-notificationHubs-8708"; ResourceIdentifier notificationHubResourceId = NotificationHubResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, notificationHubName); NotificationHubResource notificationHub = client.GetNotificationHubResource(notificationHubResourceId); // invoke the operation - await notificationHub.DeleteAsync(WaitUntil.Completed); + NotificationHubPatch patch = new NotificationHubPatch((AzureLocation)default) + { + RegistrationTtl = XmlConvert.ToTimeSpan("10675199.02:48:05.4775807"), + GcmCredential = new NotificationHubGcmCredential("###################################") + { + GcmEndpoint = new Uri("https://fcm.googleapis.com/fcm/send"), + }, + }; + NotificationHubResource result = await notificationHub.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubsPrivateLinkResourceCollection.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubsPrivateLinkResourceCollection.cs index 9334629e894ce..65a9629eb94ca 100644 --- a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubsPrivateLinkResourceCollection.cs +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_NotificationHubsPrivateLinkResourceCollection.cs @@ -51,10 +51,10 @@ public async Task Get_PrivateEndpointConnectionsGetGroupId() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGetGroupId() + public async Task GetAll_PrivateEndpointConnectionsListGroupIds() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateLinkResourceGet.json - // this example is just showing the usage of "PrivateEndpointConnections_GetGroupId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateLinkResourceList.json + // this example is just showing the usage of "PrivateEndpointConnections_ListGroupIds" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_PrivateEndpointConnectionsGetGroupId() // get the collection of this NotificationHubsPrivateLinkResource NotificationHubsPrivateLinkResourceCollection collection = notificationHubNamespace.GetNotificationHubsPrivateLinkResources(); - // invoke the operation - string subResourceName = "namespace"; - bool result = await collection.ExistsAsync(subResourceName); + // invoke the operation and iterate over the result + await foreach (NotificationHubsPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationHubsPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGetGroupId() + public async Task Exists_PrivateEndpointConnectionsGetGroupId() { // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateLinkResourceGet.json // this example is just showing the usage of "PrivateEndpointConnections_GetGroupId" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_PrivateEndpointConnectionsGetGroupId() // invoke the operation string subResourceName = "namespace"; - NullableResponse response = await collection.GetIfExistsAsync(subResourceName); - NotificationHubsPrivateLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(subResourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationHubsPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsListGroupIds() + public async Task GetIfExists_PrivateEndpointConnectionsGetGroupId() { - // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateLinkResourceList.json - // this example is just showing the usage of "PrivateEndpointConnections_ListGroupIds" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/PrivateLinkResourceGet.json + // this example is just showing the usage of "PrivateEndpointConnections_GetGroupId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_PrivateEndpointConnectionsListGroupIds() // get the collection of this NotificationHubsPrivateLinkResource NotificationHubsPrivateLinkResourceCollection collection = notificationHubNamespace.GetNotificationHubsPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (NotificationHubsPrivateLinkResource item in collection.GetAllAsync()) + // invoke the operation + string subResourceName = "namespace"; + NullableResponse response = await collection.GetIfExistsAsync(subResourceName); + NotificationHubsPrivateLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NotificationHubsPrivateLinkResourceData resourceData = item.Data; + NotificationHubsPrivateLinkResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..6a32b20569551 --- /dev/null +++ b/sdk/notificationhubs/Azure.ResourceManager.NotificationHubs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.NotificationHubs.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.NotificationHubs.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckNotificationHubNamespaceAvailability_NamespacesCheckAvailability() + { + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/CheckAvailability.json + // this example is just showing the usage of "Namespaces_CheckAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "29cfa613-cbbc-4512-b1d6-1b3a92c7fa40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + NotificationHubAvailabilityContent content = new NotificationHubAvailabilityContent(default); + NotificationHubAvailabilityResult result = await subscriptionResource.CheckNotificationHubNamespaceAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNotificationHubNamespaces_NamespacesListAll() + { + // Generated from example definition: specification/notificationhubs/resource-manager/Microsoft.NotificationHubs/preview/2023-10-01-preview/examples/Namespaces/ListBySubscription.json + // this example is just showing the usage of "Namespaces_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "29cfa613-cbbc-4512-b1d6-1b3a92c7fa40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NotificationHubNamespaceResource item in subscriptionResource.GetNotificationHubNamespacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationHubNamespaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryCollection.cs index 6cc99c82f9b65..ef79ba0ee031b 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LogAnalyticsQueryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QueryList() + public async Task CreateOrUpdate_QueryPut() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesList.json - // this example is just showing the usage of "Queries_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesPut.json + // this example is just showing the usage of "Queries_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,18 +39,31 @@ public async Task GetAll_QueryList() // get the collection of this LogAnalyticsQueryResource LogAnalyticsQueryCollection collection = logAnalyticsQueryPack.GetLogAnalyticsQueries(); - // invoke the operation and iterate over the result - bool? includeBody = true; - await foreach (LogAnalyticsQueryResource item in collection.GetAllAsync(includeBody: includeBody)) + // invoke the operation + string id = "a449f8af-8e64-4b3a-9b16-5a7165ff98c4"; + LogAnalyticsQueryData data = new LogAnalyticsQueryData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogAnalyticsQueryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "Exceptions - New in the last 24 hours", + Description = "my description", + Body = "let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n", + Related = new LogAnalyticsQueryRelatedMetadata + { + Categories = { "analytics" }, + }, + Tags = +{ +["my-label"] = {"label1"}, +["my-other-label"] = {"label2"} +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); + LogAnalyticsQueryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogAnalyticsQueryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +102,10 @@ public async Task Get_QueryGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QueryGet() + public async Task GetAll_QueryList() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesGet.json - // this example is just showing the usage of "Queries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesList.json + // this example is just showing the usage of "Queries_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +123,23 @@ public async Task Exists_QueryGet() // get the collection of this LogAnalyticsQueryResource LogAnalyticsQueryCollection collection = logAnalyticsQueryPack.GetLogAnalyticsQueries(); - // invoke the operation - string id = "a449f8af-8e64-4b3a-9b16-5a7165ff98c4"; - bool result = await collection.ExistsAsync(id); + // invoke the operation and iterate over the result + bool? includeBody = true; + await foreach (LogAnalyticsQueryResource item in collection.GetAllAsync(includeBody: includeBody)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogAnalyticsQueryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QueryGet() + public async Task Exists_QueryGet() { // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesGet.json // this example is just showing the usage of "Queries_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +162,17 @@ public async Task GetIfExists_QueryGet() // invoke the operation string id = "a449f8af-8e64-4b3a-9b16-5a7165ff98c4"; - NullableResponse response = await collection.GetIfExistsAsync(id); - LogAnalyticsQueryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(id); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogAnalyticsQueryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_QueryPut() + public async Task GetIfExists_QueryGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesPut.json - // this example is just showing the usage of "Queries_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesGet.json + // this example is just showing the usage of "Queries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,38 +192,21 @@ public async Task CreateOrUpdate_QueryPut() // invoke the operation string id = "a449f8af-8e64-4b3a-9b16-5a7165ff98c4"; - LogAnalyticsQueryData data = new LogAnalyticsQueryData() - { - DisplayName = "Exceptions - New in the last 24 hours", - Description = "my description", - Body = "let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n", - Related = new LogAnalyticsQueryRelatedMetadata() - { - Categories = -{ -"analytics" -}, - }, - Tags = -{ -["my-label"] = new string[] -{ -"label1" -}, -["my-other-label"] = new string[] -{ -"label2" -}, -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); - LogAnalyticsQueryResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(id); + LogAnalyticsQueryResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogAnalyticsQueryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogAnalyticsQueryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryPackCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryPackCollection.cs index e7caf8cc9342d..d888299c5a234 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryPackCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryPackCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LogAnalyticsQueryPackCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QueryPackListByResourceGroup() + public async Task CreateOrUpdate_QueryPackCreate() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksListByResourceGroup.json - // this example is just showing the usage of "QueryPacks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksCreate.json + // this example is just showing the usage of "QueryPacks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,25 @@ public async Task GetAll_QueryPackListByResourceGroup() // get the collection of this LogAnalyticsQueryPackResource LogAnalyticsQueryPackCollection collection = resourceGroupResource.GetLogAnalyticsQueryPacks(); - // invoke the operation and iterate over the result - await foreach (LogAnalyticsQueryPackResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogAnalyticsQueryPackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string queryPackName = "my-querypack"; + LogAnalyticsQueryPackData data = new LogAnalyticsQueryPackData(new AzureLocation("South Central US")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, queryPackName, data); + LogAnalyticsQueryPackResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogAnalyticsQueryPackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QueryPackGet() + public async Task CreateOrUpdate_QueryPackUpdate() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksGet.json - // this example is just showing the usage of "QueryPacks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksUpdate.json + // this example is just showing the usage of "QueryPacks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,7 +75,15 @@ public async Task Get_QueryPackGet() // invoke the operation string queryPackName = "my-querypack"; - LogAnalyticsQueryPackResource result = await collection.GetAsync(queryPackName); + LogAnalyticsQueryPackData data = new LogAnalyticsQueryPackData(new AzureLocation("South Central US")) + { + Tags = +{ +["Tag1"] = "Value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, queryPackName, data); + LogAnalyticsQueryPackResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,7 +94,7 @@ public async Task Get_QueryPackGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QueryPackGet() + public async Task Get_QueryPackGet() { // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksGet.json // this example is just showing the usage of "QueryPacks_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,17 +116,21 @@ public async Task Exists_QueryPackGet() // invoke the operation string queryPackName = "my-querypack"; - bool result = await collection.ExistsAsync(queryPackName); + LogAnalyticsQueryPackResource result = await collection.GetAsync(queryPackName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogAnalyticsQueryPackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QueryPackGet() + public async Task GetAll_QueryPackListByResourceGroup() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksGet.json - // this example is just showing the usage of "QueryPacks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksListByResourceGroup.json + // this example is just showing the usage of "QueryPacks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,31 +147,25 @@ public async Task GetIfExists_QueryPackGet() // get the collection of this LogAnalyticsQueryPackResource LogAnalyticsQueryPackCollection collection = resourceGroupResource.GetLogAnalyticsQueryPacks(); - // invoke the operation - string queryPackName = "my-querypack"; - NullableResponse response = await collection.GetIfExistsAsync(queryPackName); - LogAnalyticsQueryPackResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (LogAnalyticsQueryPackResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LogAnalyticsQueryPackData resourceData = result.Data; + LogAnalyticsQueryPackData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_QueryPackCreate() + public async Task Exists_QueryPackGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksCreate.json - // this example is just showing the usage of "QueryPacks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksGet.json + // this example is just showing the usage of "QueryPacks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,23 +184,17 @@ public async Task CreateOrUpdate_QueryPackCreate() // invoke the operation string queryPackName = "my-querypack"; - LogAnalyticsQueryPackData data = new LogAnalyticsQueryPackData(new AzureLocation("South Central US")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, queryPackName, data); - LogAnalyticsQueryPackResource result = lro.Value; + bool result = await collection.ExistsAsync(queryPackName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogAnalyticsQueryPackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_QueryPackUpdate() + public async Task GetIfExists_QueryPackGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksUpdate.json - // this example is just showing the usage of "QueryPacks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksGet.json + // this example is just showing the usage of "QueryPacks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,21 +213,21 @@ public async Task CreateOrUpdate_QueryPackUpdate() // invoke the operation string queryPackName = "my-querypack"; - LogAnalyticsQueryPackData data = new LogAnalyticsQueryPackData(new AzureLocation("South Central US")) - { - Tags = -{ -["Tag1"] = "Value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, queryPackName, data); - LogAnalyticsQueryPackResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(queryPackName); + LogAnalyticsQueryPackResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogAnalyticsQueryPackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogAnalyticsQueryPackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryPackResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryPackResource.cs index d41f804cd9057..d1d03832d1c77 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryPackResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryPackResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.OperationalInsights.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.OperationalInsights.Samples @@ -19,93 +18,26 @@ public partial class Sample_LogAnalyticsQueryPackResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLogAnalyticsQueryPacks_QueryPacksList() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksList.json - // this example is just showing the usage of "QueryPacks_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (LogAnalyticsQueryPackResource item in subscriptionResource.GetLogAnalyticsQueryPacksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogAnalyticsQueryPackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdateWithoutNameQueryPack_QueryPackCreateNoName() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksCreateNoName.json - // this example is just showing the usage of "QueryPacks_CreateOrUpdateWithoutName" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; - string resourceGroupName = "my-resource-group"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation - LogAnalyticsQueryPackData data = new LogAnalyticsQueryPackData(new AzureLocation("South Central US")); - LogAnalyticsQueryPackResource result = await resourceGroupResource.CreateOrUpdateWithoutNameQueryPackAsync(data); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogAnalyticsQueryPackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdateWithoutNameQueryPack_QueryPackUpdateNoName() + public async Task Get_QueryPackGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackUpdateNoName.json - // this example is just showing the usage of "QueryPacks_CreateOrUpdateWithoutName" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksGet.json + // this example is just showing the usage of "QueryPacks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + // this example assumes you already have this LogAnalyticsQueryPackResource created on azure + // for more information of creating LogAnalyticsQueryPackResource, please refer to the document of LogAnalyticsQueryPackResource string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; string resourceGroupName = "my-resource-group"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + string queryPackName = "my-querypack"; + ResourceIdentifier logAnalyticsQueryPackResourceId = LogAnalyticsQueryPackResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, queryPackName); + LogAnalyticsQueryPackResource logAnalyticsQueryPack = client.GetLogAnalyticsQueryPackResource(logAnalyticsQueryPackResourceId); // invoke the operation - LogAnalyticsQueryPackData data = new LogAnalyticsQueryPackData(new AzureLocation("South Central US")) - { - Tags = -{ -["Tag1"] = "Value1", -}, - }; - LogAnalyticsQueryPackResource result = await resourceGroupResource.CreateOrUpdateWithoutNameQueryPackAsync(data); + LogAnalyticsQueryPackResource result = await logAnalyticsQueryPack.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -140,36 +72,6 @@ public async Task Delete_QueryPacksDelete() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_QueryPackGet() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksGet.json - // this example is just showing the usage of "QueryPacks_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this LogAnalyticsQueryPackResource created on azure - // for more information of creating LogAnalyticsQueryPackResource, please refer to the document of LogAnalyticsQueryPackResource - string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; - string resourceGroupName = "my-resource-group"; - string queryPackName = "my-querypack"; - ResourceIdentifier logAnalyticsQueryPackResourceId = LogAnalyticsQueryPackResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, queryPackName); - LogAnalyticsQueryPackResource logAnalyticsQueryPack = client.GetLogAnalyticsQueryPackResource(logAnalyticsQueryPackResourceId); - - // invoke the operation - LogAnalyticsQueryPackResource result = await logAnalyticsQueryPack.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogAnalyticsQueryPackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Update_QueryPackUpdateTagsOnly() @@ -191,12 +93,12 @@ public async Task Update_QueryPackUpdateTagsOnly() LogAnalyticsQueryPackResource logAnalyticsQueryPack = client.GetLogAnalyticsQueryPackResource(logAnalyticsQueryPackResourceId); // invoke the operation - LogAnalyticsQueryPackPatch patch = new LogAnalyticsQueryPackPatch() + LogAnalyticsQueryPackPatch patch = new LogAnalyticsQueryPackPatch { Tags = { ["Tag1"] = "Value1", -["Tag2"] = "Value2", +["Tag2"] = "Value2" }, }; LogAnalyticsQueryPackResource result = await logAnalyticsQueryPack.UpdateAsync(patch); @@ -229,21 +131,15 @@ public async Task SearchQueries_QuerySearch() LogAnalyticsQueryPackResource logAnalyticsQueryPack = client.GetLogAnalyticsQueryPackResource(logAnalyticsQueryPackResourceId); // invoke the operation and iterate over the result - LogAnalyticsQuerySearchProperties querySearchProperties = new LogAnalyticsQuerySearchProperties() + LogAnalyticsQuerySearchProperties querySearchProperties = new LogAnalyticsQuerySearchProperties { - Related = new LogAnalyticsQuerySearchRelatedMetadata() + Related = new LogAnalyticsQuerySearchRelatedMetadata { - Categories = -{ -"other","analytics" -}, + Categories = { "other", "analytics" }, }, Tags = { -["my-label"] = new string[] -{ -"label1" -}, +["my-label"] = {"label1"} }, }; long? top = 3L; diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryResource.cs index 1ed3608a6bf02..a15bd07f10a7d 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_LogAnalyticsQueryResource.cs @@ -49,10 +49,10 @@ public async Task Get_QueryGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_QueryPatch() + public async Task Delete_QueryDelete() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesUpdate.json - // this example is just showing the usage of "Queries_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesDelete.json + // this example is just showing the usage of "Queries_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,45 +69,17 @@ public async Task Update_QueryPatch() LogAnalyticsQueryResource logAnalyticsQuery = client.GetLogAnalyticsQueryResource(logAnalyticsQueryResourceId); // invoke the operation - LogAnalyticsQueryData data = new LogAnalyticsQueryData() - { - DisplayName = "Exceptions - New in the last 24 hours", - Description = "my description", - Body = "let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n", - Related = new LogAnalyticsQueryRelatedMetadata() - { - Categories = -{ -"analytics" -}, - }, - Tags = -{ -["my-label"] = new string[] -{ -"label1" -}, -["my-other-label"] = new string[] -{ -"label2" -}, -}, - }; - LogAnalyticsQueryResource result = await logAnalyticsQuery.UpdateAsync(data); + await logAnalyticsQuery.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogAnalyticsQueryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_QueryDelete() + public async Task Update_QueryPatch() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesDelete.json - // this example is just showing the usage of "Queries_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackQueriesUpdate.json + // this example is just showing the usage of "Queries_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -124,9 +96,28 @@ public async Task Delete_QueryDelete() LogAnalyticsQueryResource logAnalyticsQuery = client.GetLogAnalyticsQueryResource(logAnalyticsQueryResourceId); // invoke the operation - await logAnalyticsQuery.DeleteAsync(WaitUntil.Completed); + LogAnalyticsQueryData data = new LogAnalyticsQueryData + { + DisplayName = "Exceptions - New in the last 24 hours", + Description = "my description", + Body = "let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n", + Related = new LogAnalyticsQueryRelatedMetadata + { + Categories = { "analytics" }, + }, + Tags = +{ +["my-label"] = {"label1"}, +["my-other-label"] = {"label2"} +}, + }; + LogAnalyticsQueryResource result = await logAnalyticsQuery.UpdateAsync(data); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogAnalyticsQueryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsClusterCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsClusterCollection.cs index b26a286398636..1240626fe7855 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsClusterCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsClusterCollection.cs @@ -17,41 +17,6 @@ namespace Azure.ResourceManager.OperationalInsights.Samples { public partial class Sample_OperationalInsightsClusterCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ClustersGet() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersListByResourceGroup.json - // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - string resourceGroupName = "oiautorest6685"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this OperationalInsightsClusterResource - OperationalInsightsClusterCollection collection = resourceGroupResource.GetOperationalInsightsClusters(); - - // invoke the operation and iterate over the result - await foreach (OperationalInsightsClusterResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_ClustersCreate() @@ -78,14 +43,14 @@ public async Task CreateOrUpdate_ClustersCreate() string clusterName = "oiautorest6685"; OperationalInsightsClusterData data = new OperationalInsightsClusterData(new AzureLocation("australiasoutheast")) { - Sku = new OperationalInsightsClusterSku() + Sku = new OperationalInsightsClusterSku { Capacity = OperationalInsightsClusterCapacity.TenHundred, Name = OperationalInsightsClusterSkuName.CapacityReservation, }, Tags = { -["tag1"] = "val1", +["tag1"] = "val1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); @@ -131,6 +96,41 @@ public async Task Get_ClustersGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ClustersGet() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersListByResourceGroup.json + // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + string resourceGroupName = "oiautorest6685"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this OperationalInsightsClusterResource + OperationalInsightsClusterCollection collection = resourceGroupResource.GetOperationalInsightsClusters(); + + // invoke the operation and iterate over the result + await foreach (OperationalInsightsClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_ClustersGet() diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsClusterResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsClusterResource.cs index 7dde19debe7ad..1b7da6683fe44 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsClusterResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsClusterResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.OperationalInsights.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.OperationalInsights.Samples @@ -20,41 +19,10 @@ public partial class Sample_OperationalInsightsClusterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetOperationalInsightsClusters_ClustersSubscriptionList() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersSubscriptionList.json - // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (OperationalInsightsClusterResource item in subscriptionResource.GetOperationalInsightsClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ClustersDelete() + public async Task Get_ClustersGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersDelete.json - // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersGet.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,17 +38,21 @@ public async Task Delete_ClustersDelete() OperationalInsightsClusterResource operationalInsightsCluster = client.GetOperationalInsightsClusterResource(operationalInsightsClusterResourceId); // invoke the operation - await operationalInsightsCluster.DeleteAsync(WaitUntil.Completed); + OperationalInsightsClusterResource result = await operationalInsightsCluster.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ClustersGet() + public async Task Delete_ClustersDelete() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersGet.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersDelete.json + // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,13 +68,9 @@ public async Task Get_ClustersGet() OperationalInsightsClusterResource operationalInsightsCluster = client.GetOperationalInsightsClusterResource(operationalInsightsClusterResourceId); // invoke the operation - OperationalInsightsClusterResource result = await operationalInsightsCluster.GetAsync(); + await operationalInsightsCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -126,25 +94,25 @@ public async Task Update_ClustersPatch() OperationalInsightsClusterResource operationalInsightsCluster = client.GetOperationalInsightsClusterResource(operationalInsightsClusterResourceId); // invoke the operation - OperationalInsightsClusterPatch patch = new OperationalInsightsClusterPatch() + OperationalInsightsClusterPatch patch = new OperationalInsightsClusterPatch { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourcegroups/oiautorest6685/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myidentity")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourcegroups/oiautorest6685/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myidentity")] = new UserAssignedIdentity() }, }, - Sku = new OperationalInsightsClusterSku() + Sku = new OperationalInsightsClusterSku { Capacity = OperationalInsightsClusterCapacity.TenHundred, Name = OperationalInsightsClusterSkuName.CapacityReservation, }, Tags = { -["tag1"] = "val1", +["tag1"] = "val1" }, - KeyVaultProperties = new OperationalInsightsKeyVaultProperties() + KeyVaultProperties = new OperationalInsightsKeyVaultProperties { KeyVaultUri = new Uri("https://aztest2170.vault.azure.net"), KeyName = "aztest2170cert", diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataExportCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataExportCollection.cs index 45b6a318c5738..ddf7d7ae0c3e5 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataExportCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataExportCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_OperationalInsightsDataExportCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DataExportGet() + public async Task CreateOrUpdate_DataExportCreate() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportListByWorkspace.json - // this example is just showing the usage of "DataExports_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportCreateOrUpdate.json + // this example is just showing the usage of "DataExports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,29 @@ public async Task GetAll_DataExportGet() // get the collection of this OperationalInsightsDataExportResource OperationalInsightsDataExportCollection collection = operationalInsightsWorkspace.GetOperationalInsightsDataExports(); - // invoke the operation and iterate over the result - await foreach (OperationalInsightsDataExportResource item in collection.GetAllAsync()) + // invoke the operation + string dataExportName = "export1"; + OperationalInsightsDataExportData data = new OperationalInsightsDataExportData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsDataExportData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TableNames = { "Heartbeat" }, + ResourceId = new ResourceIdentifier("/subscriptions/192b9f85-a39a-4276-b96d-d5cd351703f9/resourceGroups/OIAutoRest1234/providers/Microsoft.EventHub/namespaces/test"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataExportName, data); + OperationalInsightsDataExportResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsDataExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataExportCreate() + public async Task Get_DataExportGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportCreateOrUpdate.json - // this example is just showing the usage of "DataExports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportGet.json + // this example is just showing the usage of "DataExports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,16 +80,7 @@ public async Task CreateOrUpdate_DataExportCreate() // invoke the operation string dataExportName = "export1"; - OperationalInsightsDataExportData data = new OperationalInsightsDataExportData() - { - TableNames = -{ -"Heartbeat" -}, - ResourceId = new ResourceIdentifier("/subscriptions/192b9f85-a39a-4276-b96d-d5cd351703f9/resourceGroups/OIAutoRest1234/providers/Microsoft.EventHub/namespaces/test"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataExportName, data); - OperationalInsightsDataExportResource result = lro.Value; + OperationalInsightsDataExportResource result = await collection.GetAsync(dataExportName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -96,10 +91,10 @@ public async Task CreateOrUpdate_DataExportCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataExportGet() + public async Task GetAll_DataExportGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportGet.json - // this example is just showing the usage of "DataExports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportListByWorkspace.json + // this example is just showing the usage of "DataExports_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,15 +112,17 @@ public async Task Get_DataExportGet() // get the collection of this OperationalInsightsDataExportResource OperationalInsightsDataExportCollection collection = operationalInsightsWorkspace.GetOperationalInsightsDataExports(); - // invoke the operation - string dataExportName = "export1"; - OperationalInsightsDataExportResource result = await collection.GetAsync(dataExportName); + // invoke the operation and iterate over the result + await foreach (OperationalInsightsDataExportResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsDataExportData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsDataExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataExportResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataExportResource.cs index e5a47ad2370f8..bfe748ff1c189 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataExportResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataExportResource.cs @@ -17,10 +17,10 @@ public partial class Sample_OperationalInsightsDataExportResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DataExportCreate() + public async Task Get_DataExportGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportCreateOrUpdate.json - // this example is just showing the usage of "DataExports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportGet.json + // this example is just showing the usage of "DataExports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,16 +37,7 @@ public async Task Update_DataExportCreate() OperationalInsightsDataExportResource operationalInsightsDataExport = client.GetOperationalInsightsDataExportResource(operationalInsightsDataExportResourceId); // invoke the operation - OperationalInsightsDataExportData data = new OperationalInsightsDataExportData() - { - TableNames = -{ -"Heartbeat" -}, - ResourceId = new ResourceIdentifier("/subscriptions/192b9f85-a39a-4276-b96d-d5cd351703f9/resourceGroups/OIAutoRest1234/providers/Microsoft.EventHub/namespaces/test"), - }; - ArmOperation lro = await operationalInsightsDataExport.UpdateAsync(WaitUntil.Completed, data); - OperationalInsightsDataExportResource result = lro.Value; + OperationalInsightsDataExportResource result = await operationalInsightsDataExport.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +48,10 @@ public async Task Update_DataExportCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataExportGet() + public async Task Delete_DataExportDelete() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportGet.json - // this example is just showing the usage of "DataExports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportDelete.json + // this example is just showing the usage of "DataExports_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,21 +68,17 @@ public async Task Get_DataExportGet() OperationalInsightsDataExportResource operationalInsightsDataExport = client.GetOperationalInsightsDataExportResource(operationalInsightsDataExportResourceId); // invoke the operation - OperationalInsightsDataExportResource result = await operationalInsightsDataExport.GetAsync(); + await operationalInsightsDataExport.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsDataExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DataExportDelete() + public async Task Update_DataExportCreate() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportDelete.json - // this example is just showing the usage of "DataExports_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataExportCreateOrUpdate.json + // this example is just showing the usage of "DataExports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +95,19 @@ public async Task Delete_DataExportDelete() OperationalInsightsDataExportResource operationalInsightsDataExport = client.GetOperationalInsightsDataExportResource(operationalInsightsDataExportResourceId); // invoke the operation - await operationalInsightsDataExport.DeleteAsync(WaitUntil.Completed); + OperationalInsightsDataExportData data = new OperationalInsightsDataExportData + { + TableNames = { "Heartbeat" }, + ResourceId = new ResourceIdentifier("/subscriptions/192b9f85-a39a-4276-b96d-d5cd351703f9/resourceGroups/OIAutoRest1234/providers/Microsoft.EventHub/namespaces/test"), + }; + ArmOperation lro = await operationalInsightsDataExport.UpdateAsync(WaitUntil.Completed, data); + OperationalInsightsDataExportResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsDataExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataSourceCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataSourceCollection.cs index 7aeec51d1c756..3a9ef066ef4c9 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataSourceCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataSourceCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -42,9 +41,9 @@ public async Task CreateOrUpdate_DataSourcesCreate() // invoke the operation string dataSourceName = "AzTestDS774"; - OperationalInsightsDataSourceData data = new OperationalInsightsDataSourceData(BinaryData.FromObjectAsJson(new Dictionary() + OperationalInsightsDataSourceData data = new OperationalInsightsDataSourceData(BinaryData.FromObjectAsJson(new { - ["LinkedResourceId"] = "/subscriptions/00000000-0000-0000-0000-00000000000/providers/microsoft.insights/eventtypes/management" + LinkedResourceId = "/subscriptions/00000000-0000-0000-0000-00000000000/providers/microsoft.insights/eventtypes/management", }), OperationalInsightsDataSourceKind.AzureActivityLog); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSourceName, data); OperationalInsightsDataSourceResource result = lro.Value; @@ -92,10 +91,10 @@ public async Task Get_DataSourcesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DataSourcesGet() + public async Task GetAll_DataSourcesListByWorkspace() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesGet.json - // this example is just showing the usage of "DataSources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesListByWorkspace.json + // this example is just showing the usage of "DataSources_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +112,23 @@ public async Task Exists_DataSourcesGet() // get the collection of this OperationalInsightsDataSourceResource OperationalInsightsDataSourceCollection collection = operationalInsightsWorkspace.GetOperationalInsightsDataSources(); - // invoke the operation - string dataSourceName = "AzTestDS774"; - bool result = await collection.ExistsAsync(dataSourceName); + // invoke the operation and iterate over the result + string filter = "kind='WindowsEvent'"; + await foreach (OperationalInsightsDataSourceResource item in collection.GetAllAsync(filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsDataSourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DataSourcesGet() + public async Task Exists_DataSourcesGet() { // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesGet.json // this example is just showing the usage of "DataSources_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +151,17 @@ public async Task GetIfExists_DataSourcesGet() // invoke the operation string dataSourceName = "AzTestDS774"; - NullableResponse response = await collection.GetIfExistsAsync(dataSourceName); - OperationalInsightsDataSourceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataSourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsDataSourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DataSourcesListByWorkspace() + public async Task GetIfExists_DataSourcesGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesListByWorkspace.json - // this example is just showing the usage of "DataSources_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesGet.json + // this example is just showing the usage of "DataSources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,18 +179,23 @@ public async Task GetAll_DataSourcesListByWorkspace() // get the collection of this OperationalInsightsDataSourceResource OperationalInsightsDataSourceCollection collection = operationalInsightsWorkspace.GetOperationalInsightsDataSources(); - // invoke the operation and iterate over the result - string filter = "kind='WindowsEvent'"; - await foreach (OperationalInsightsDataSourceResource item in collection.GetAllAsync(filter)) + // invoke the operation + string dataSourceName = "AzTestDS774"; + NullableResponse response = await collection.GetIfExistsAsync(dataSourceName); + OperationalInsightsDataSourceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - OperationalInsightsDataSourceData resourceData = item.Data; + OperationalInsightsDataSourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataSourceResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataSourceResource.cs index 2ac1bd0c15f74..38bf2b17ef35c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataSourceResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsDataSourceResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_OperationalInsightsDataSourceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DataSourcesCreate() + public async Task Get_DataSourcesGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesCreate.json - // this example is just showing the usage of "DataSources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesGet.json + // this example is just showing the usage of "DataSources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,12 +38,7 @@ public async Task Update_DataSourcesCreate() OperationalInsightsDataSourceResource operationalInsightsDataSource = client.GetOperationalInsightsDataSourceResource(operationalInsightsDataSourceResourceId); // invoke the operation - OperationalInsightsDataSourceData data = new OperationalInsightsDataSourceData(BinaryData.FromObjectAsJson(new Dictionary() - { - ["LinkedResourceId"] = "/subscriptions/00000000-0000-0000-0000-00000000000/providers/microsoft.insights/eventtypes/management" - }), OperationalInsightsDataSourceKind.AzureActivityLog); - ArmOperation lro = await operationalInsightsDataSource.UpdateAsync(WaitUntil.Completed, data); - OperationalInsightsDataSourceResource result = lro.Value; + OperationalInsightsDataSourceResource result = await operationalInsightsDataSource.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -82,10 +76,10 @@ public async Task Delete_DataSourcesDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataSourcesGet() + public async Task Update_DataSourcesCreate() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesGet.json - // this example is just showing the usage of "DataSources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/DataSourcesCreate.json + // this example is just showing the usage of "DataSources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,7 +96,12 @@ public async Task Get_DataSourcesGet() OperationalInsightsDataSourceResource operationalInsightsDataSource = client.GetOperationalInsightsDataSourceResource(operationalInsightsDataSourceResourceId); // invoke the operation - OperationalInsightsDataSourceResource result = await operationalInsightsDataSource.GetAsync(); + OperationalInsightsDataSourceData data = new OperationalInsightsDataSourceData(BinaryData.FromObjectAsJson(new + { + LinkedResourceId = "/subscriptions/00000000-0000-0000-0000-00000000000/providers/microsoft.insights/eventtypes/management", + }), OperationalInsightsDataSourceKind.AzureActivityLog); + ArmOperation lro = await operationalInsightsDataSource.UpdateAsync(WaitUntil.Completed, data); + OperationalInsightsDataSourceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedServiceCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedServiceCollection.cs index 15b2de6b80fd2..6f7ae302c3c17 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedServiceCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedServiceCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_LinkedServicesCreate() // invoke the operation string linkedServiceName = "Cluster"; - OperationalInsightsLinkedServiceData data = new OperationalInsightsLinkedServiceData() + OperationalInsightsLinkedServiceData data = new OperationalInsightsLinkedServiceData { WriteAccessResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.OperationalInsights/clusters/testcluster"), }; @@ -90,10 +90,10 @@ public async Task Get_LinkedServicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LinkedServicesGet() + public async Task GetAll_LinkedServicesListByWorkspace() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesGet.json - // this example is just showing the usage of "LinkedServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesListByWorkspace.json + // this example is just showing the usage of "LinkedServices_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +111,22 @@ public async Task Exists_LinkedServicesGet() // get the collection of this OperationalInsightsLinkedServiceResource OperationalInsightsLinkedServiceCollection collection = operationalInsightsWorkspace.GetOperationalInsightsLinkedServices(); - // invoke the operation - string linkedServiceName = "Cluster"; - bool result = await collection.ExistsAsync(linkedServiceName); + // invoke the operation and iterate over the result + await foreach (OperationalInsightsLinkedServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsLinkedServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LinkedServicesGet() + public async Task Exists_LinkedServicesGet() { // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesGet.json // this example is just showing the usage of "LinkedServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,29 +149,17 @@ public async Task GetIfExists_LinkedServicesGet() // invoke the operation string linkedServiceName = "Cluster"; - NullableResponse response = await collection.GetIfExistsAsync(linkedServiceName); - OperationalInsightsLinkedServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(linkedServiceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsLinkedServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LinkedServicesListByWorkspace() + public async Task GetIfExists_LinkedServicesGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesListByWorkspace.json - // this example is just showing the usage of "LinkedServices_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesGet.json + // this example is just showing the usage of "LinkedServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_LinkedServicesListByWorkspace() // get the collection of this OperationalInsightsLinkedServiceResource OperationalInsightsLinkedServiceCollection collection = operationalInsightsWorkspace.GetOperationalInsightsLinkedServices(); - // invoke the operation and iterate over the result - await foreach (OperationalInsightsLinkedServiceResource item in collection.GetAllAsync()) + // invoke the operation + string linkedServiceName = "Cluster"; + NullableResponse response = await collection.GetIfExistsAsync(linkedServiceName); + OperationalInsightsLinkedServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - OperationalInsightsLinkedServiceData resourceData = item.Data; + OperationalInsightsLinkedServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedServiceResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedServiceResource.cs index 28ad1c8ddc937..5f06a0c09b3d1 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedServiceResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedServiceResource.cs @@ -17,10 +17,10 @@ public partial class Sample_OperationalInsightsLinkedServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_LinkedServicesCreate() + public async Task Get_LinkedServicesGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesCreate.json - // this example is just showing the usage of "LinkedServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesGet.json + // this example is just showing the usage of "LinkedServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,12 +37,7 @@ public async Task Update_LinkedServicesCreate() OperationalInsightsLinkedServiceResource operationalInsightsLinkedService = client.GetOperationalInsightsLinkedServiceResource(operationalInsightsLinkedServiceResourceId); // invoke the operation - OperationalInsightsLinkedServiceData data = new OperationalInsightsLinkedServiceData() - { - WriteAccessResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.OperationalInsights/clusters/testcluster"), - }; - ArmOperation lro = await operationalInsightsLinkedService.UpdateAsync(WaitUntil.Completed, data); - OperationalInsightsLinkedServiceResource result = lro.Value; + OperationalInsightsLinkedServiceResource result = await operationalInsightsLinkedService.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,10 +80,10 @@ public async Task Delete_LinkedServicesDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LinkedServicesGet() + public async Task Update_LinkedServicesCreate() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesGet.json - // this example is just showing the usage of "LinkedServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedServicesCreate.json + // this example is just showing the usage of "LinkedServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,7 +100,12 @@ public async Task Get_LinkedServicesGet() OperationalInsightsLinkedServiceResource operationalInsightsLinkedService = client.GetOperationalInsightsLinkedServiceResource(operationalInsightsLinkedServiceResourceId); // invoke the operation - OperationalInsightsLinkedServiceResource result = await operationalInsightsLinkedService.GetAsync(); + OperationalInsightsLinkedServiceData data = new OperationalInsightsLinkedServiceData + { + WriteAccessResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.OperationalInsights/clusters/testcluster"), + }; + ArmOperation lro = await operationalInsightsLinkedService.UpdateAsync(WaitUntil.Completed, data); + OperationalInsightsLinkedServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedStorageAccountsCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedStorageAccountsCollection.cs index dff6b7a0e0ca1..7d95a0b5c2f84 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedStorageAccountsCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedStorageAccountsCollection.cs @@ -41,12 +41,9 @@ public async Task CreateOrUpdate_LinkedStorageAccountsCreate() // invoke the operation OperationalInsightsDataSourceType dataSourceType = OperationalInsightsDataSourceType.CustomLogs; - OperationalInsightsLinkedStorageAccountsData data = new OperationalInsightsLinkedStorageAccountsData() + OperationalInsightsLinkedStorageAccountsData data = new OperationalInsightsLinkedStorageAccountsData { - StorageAccountIds = -{ -new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.Storage/storageAccounts/testStorageA"),new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.Storage/storageAccounts/testStorageB") -}, + StorageAccountIds = { new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.Storage/storageAccounts/testStorageA"), new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.Storage/storageAccounts/testStorageB") }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSourceType, data); OperationalInsightsLinkedStorageAccountsResource result = lro.Value; @@ -94,10 +91,10 @@ public async Task Get_LinkedStorageAccountsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LinkedStorageAccountsGet() + public async Task GetAll_GetsListOfLinkedStorageAccountsOnAWorkspace() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsGet.json - // this example is just showing the usage of "LinkedStorageAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsListByWorkspace.json + // this example is just showing the usage of "LinkedStorageAccounts_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +112,22 @@ public async Task Exists_LinkedStorageAccountsGet() // get the collection of this OperationalInsightsLinkedStorageAccountsResource OperationalInsightsLinkedStorageAccountsCollection collection = operationalInsightsWorkspace.GetAllOperationalInsightsLinkedStorageAccounts(); - // invoke the operation - OperationalInsightsDataSourceType dataSourceType = OperationalInsightsDataSourceType.CustomLogs; - bool result = await collection.ExistsAsync(dataSourceType); + // invoke the operation and iterate over the result + await foreach (OperationalInsightsLinkedStorageAccountsResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsLinkedStorageAccountsData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LinkedStorageAccountsGet() + public async Task Exists_LinkedStorageAccountsGet() { // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsGet.json // this example is just showing the usage of "LinkedStorageAccounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,29 +150,17 @@ public async Task GetIfExists_LinkedStorageAccountsGet() // invoke the operation OperationalInsightsDataSourceType dataSourceType = OperationalInsightsDataSourceType.CustomLogs; - NullableResponse response = await collection.GetIfExistsAsync(dataSourceType); - OperationalInsightsLinkedStorageAccountsResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataSourceType); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsLinkedStorageAccountsData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfLinkedStorageAccountsOnAWorkspace() + public async Task GetIfExists_LinkedStorageAccountsGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsListByWorkspace.json - // this example is just showing the usage of "LinkedStorageAccounts_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsGet.json + // this example is just showing the usage of "LinkedStorageAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +178,23 @@ public async Task GetAll_GetsListOfLinkedStorageAccountsOnAWorkspace() // get the collection of this OperationalInsightsLinkedStorageAccountsResource OperationalInsightsLinkedStorageAccountsCollection collection = operationalInsightsWorkspace.GetAllOperationalInsightsLinkedStorageAccounts(); - // invoke the operation and iterate over the result - await foreach (OperationalInsightsLinkedStorageAccountsResource item in collection.GetAllAsync()) + // invoke the operation + OperationalInsightsDataSourceType dataSourceType = OperationalInsightsDataSourceType.CustomLogs; + NullableResponse response = await collection.GetIfExistsAsync(dataSourceType); + OperationalInsightsLinkedStorageAccountsResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - OperationalInsightsLinkedStorageAccountsData resourceData = item.Data; + OperationalInsightsLinkedStorageAccountsData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedStorageAccountsResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedStorageAccountsResource.cs index 8581f38fec8b7..353b8b9dc9ecd 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedStorageAccountsResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsLinkedStorageAccountsResource.cs @@ -18,10 +18,10 @@ public partial class Sample_OperationalInsightsLinkedStorageAccountsResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_LinkedStorageAccountsCreate() + public async Task Get_LinkedStorageAccountsGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsCreate.json - // this example is just showing the usage of "LinkedStorageAccounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsGet.json + // this example is just showing the usage of "LinkedStorageAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_LinkedStorageAccountsCreate() OperationalInsightsLinkedStorageAccountsResource operationalInsightsLinkedStorageAccounts = client.GetOperationalInsightsLinkedStorageAccountsResource(operationalInsightsLinkedStorageAccountsResourceId); // invoke the operation - OperationalInsightsLinkedStorageAccountsData data = new OperationalInsightsLinkedStorageAccountsData() - { - StorageAccountIds = -{ -new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.Storage/storageAccounts/testStorageA"),new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.Storage/storageAccounts/testStorageB") -}, - }; - ArmOperation lro = await operationalInsightsLinkedStorageAccounts.UpdateAsync(WaitUntil.Completed, data); - OperationalInsightsLinkedStorageAccountsResource result = lro.Value; + OperationalInsightsLinkedStorageAccountsResource result = await operationalInsightsLinkedStorageAccounts.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -84,10 +76,10 @@ public async Task Delete_LinkedStorageAccountsDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LinkedStorageAccountsGet() + public async Task Update_LinkedStorageAccountsCreate() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsGet.json - // this example is just showing the usage of "LinkedStorageAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/LinkedStorageAccountsCreate.json + // this example is just showing the usage of "LinkedStorageAccounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,7 +96,12 @@ public async Task Get_LinkedStorageAccountsGet() OperationalInsightsLinkedStorageAccountsResource operationalInsightsLinkedStorageAccounts = client.GetOperationalInsightsLinkedStorageAccountsResource(operationalInsightsLinkedStorageAccountsResourceId); // invoke the operation - OperationalInsightsLinkedStorageAccountsResource result = await operationalInsightsLinkedStorageAccounts.GetAsync(); + OperationalInsightsLinkedStorageAccountsData data = new OperationalInsightsLinkedStorageAccountsData + { + StorageAccountIds = { new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.Storage/storageAccounts/testStorageA"), new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000000/resourceGroups/mms-eus/providers/Microsoft.Storage/storageAccounts/testStorageB") }, + }; + ArmOperation lro = await operationalInsightsLinkedStorageAccounts.UpdateAsync(WaitUntil.Completed, data); + OperationalInsightsLinkedStorageAccountsResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsSavedSearchCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsSavedSearchCollection.cs index 84f37e1976df0..30dbf54e430a9 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsSavedSearchCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsSavedSearchCollection.cs @@ -46,10 +46,7 @@ public async Task CreateOrUpdate_SavedSearchCreateOrUpdate() FunctionAlias = "heartbeat_func", FunctionParameters = "a:int=1", Version = 2L, - Tags = -{ -new OperationalInsightsTag("Group","Computer") -}, + Tags = { new OperationalInsightsTag("Group", "Computer") }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, savedSearchId, data); OperationalInsightsSavedSearchResource result = lro.Value; @@ -97,10 +94,10 @@ public async Task Get_SavedSearchesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SavedSearchesGet() + public async Task GetAll_SavedSearchesList() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesGet.json - // this example is just showing the usage of "SavedSearches_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesListByWorkspace.json + // this example is just showing the usage of "SavedSearches_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +115,22 @@ public async Task Exists_SavedSearchesGet() // get the collection of this OperationalInsightsSavedSearchResource OperationalInsightsSavedSearchCollection collection = operationalInsightsWorkspace.GetOperationalInsightsSavedSearches(); - // invoke the operation - string savedSearchId = "00000000-0000-0000-0000-00000000000"; - bool result = await collection.ExistsAsync(savedSearchId); + // invoke the operation and iterate over the result + await foreach (OperationalInsightsSavedSearchResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsSavedSearchData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SavedSearchesGet() + public async Task Exists_SavedSearchesGet() { // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesGet.json // this example is just showing the usage of "SavedSearches_Get" operation, for the dependent resources, they will have to be created separately. @@ -150,29 +153,17 @@ public async Task GetIfExists_SavedSearchesGet() // invoke the operation string savedSearchId = "00000000-0000-0000-0000-00000000000"; - NullableResponse response = await collection.GetIfExistsAsync(savedSearchId); - OperationalInsightsSavedSearchResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(savedSearchId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsSavedSearchData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SavedSearchesList() + public async Task GetIfExists_SavedSearchesGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/SavedSearchesListByWorkspace.json - // this example is just showing the usage of "SavedSearches_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesGet.json + // this example is just showing the usage of "SavedSearches_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +181,23 @@ public async Task GetAll_SavedSearchesList() // get the collection of this OperationalInsightsSavedSearchResource OperationalInsightsSavedSearchCollection collection = operationalInsightsWorkspace.GetOperationalInsightsSavedSearches(); - // invoke the operation and iterate over the result - await foreach (OperationalInsightsSavedSearchResource item in collection.GetAllAsync()) + // invoke the operation + string savedSearchId = "00000000-0000-0000-0000-00000000000"; + NullableResponse response = await collection.GetIfExistsAsync(savedSearchId); + OperationalInsightsSavedSearchResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - OperationalInsightsSavedSearchData resourceData = item.Data; + OperationalInsightsSavedSearchData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsSavedSearchResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsSavedSearchResource.cs index f36e1ff4cf310..c9763c81dddc7 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsSavedSearchResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsSavedSearchResource.cs @@ -18,10 +18,10 @@ public partial class Sample_OperationalInsightsSavedSearchResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SavedSearchesDelete() + public async Task Get_SavedSearchesGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesDeleteSavedSearches.json - // this example is just showing the usage of "SavedSearches_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesGet.json + // this example is just showing the usage of "SavedSearches_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_SavedSearchesDelete() OperationalInsightsSavedSearchResource operationalInsightsSavedSearch = client.GetOperationalInsightsSavedSearchResource(operationalInsightsSavedSearchResourceId); // invoke the operation - await operationalInsightsSavedSearch.DeleteAsync(WaitUntil.Completed); + OperationalInsightsSavedSearchResource result = await operationalInsightsSavedSearch.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsSavedSearchData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SavedSearchCreateOrUpdate() + public async Task Delete_SavedSearchesDelete() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesCreateOrUpdate.json - // this example is just showing the usage of "SavedSearches_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesDeleteSavedSearches.json + // this example is just showing the usage of "SavedSearches_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,32 +69,17 @@ public async Task Update_SavedSearchCreateOrUpdate() OperationalInsightsSavedSearchResource operationalInsightsSavedSearch = client.GetOperationalInsightsSavedSearchResource(operationalInsightsSavedSearchResourceId); // invoke the operation - OperationalInsightsSavedSearchData data = new OperationalInsightsSavedSearchData("Saved Search Test Category", "Create or Update Saved Search Test", "Heartbeat | summarize Count() by Computer | take a") - { - FunctionAlias = "heartbeat_func", - FunctionParameters = "a:int=1", - Version = 2L, - Tags = -{ -new OperationalInsightsTag("Group","Computer") -}, - }; - ArmOperation lro = await operationalInsightsSavedSearch.UpdateAsync(WaitUntil.Completed, data); - OperationalInsightsSavedSearchResource result = lro.Value; + await operationalInsightsSavedSearch.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsSavedSearchData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SavedSearchesGet() + public async Task Update_SavedSearchCreateOrUpdate() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesGet.json - // this example is just showing the usage of "SavedSearches_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/WorkspacesSavedSearchesCreateOrUpdate.json + // this example is just showing the usage of "SavedSearches_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,7 +96,15 @@ public async Task Get_SavedSearchesGet() OperationalInsightsSavedSearchResource operationalInsightsSavedSearch = client.GetOperationalInsightsSavedSearchResource(operationalInsightsSavedSearchResourceId); // invoke the operation - OperationalInsightsSavedSearchResource result = await operationalInsightsSavedSearch.GetAsync(); + OperationalInsightsSavedSearchData data = new OperationalInsightsSavedSearchData("Saved Search Test Category", "Create or Update Saved Search Test", "Heartbeat | summarize Count() by Computer | take a") + { + FunctionAlias = "heartbeat_func", + FunctionParameters = "a:int=1", + Version = 2L, + Tags = { new OperationalInsightsTag("Group", "Computer") }, + }; + ArmOperation lro = await operationalInsightsSavedSearch.UpdateAsync(WaitUntil.Completed, data); + OperationalInsightsSavedSearchResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsTableCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsTableCollection.cs index 3b54d740527cf..a50a9c8d5f5e6 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsTableCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsTableCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.OperationalInsights.Samples { public partial class Sample_OperationalInsightsTableCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_TablesListByWorkspace() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/TablesList.json - // this example is just showing the usage of "Tables_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this OperationalInsightsWorkspaceResource created on azure - // for more information of creating OperationalInsightsWorkspaceResource, please refer to the document of OperationalInsightsWorkspaceResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - string resourceGroupName = "oiautorest6685"; - string workspaceName = "oiautorest6685"; - ResourceIdentifier operationalInsightsWorkspaceResourceId = OperationalInsightsWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); - OperationalInsightsWorkspaceResource operationalInsightsWorkspace = client.GetOperationalInsightsWorkspaceResource(operationalInsightsWorkspaceResourceId); - - // get the collection of this OperationalInsightsTableResource - OperationalInsightsTableCollection collection = operationalInsightsWorkspace.GetOperationalInsightsTables(); - - // invoke the operation and iterate over the result - await foreach (OperationalInsightsTableResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsTableData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_TablesUpsert() @@ -77,21 +41,18 @@ public async Task CreateOrUpdate_TablesUpsert() // invoke the operation string tableName = "AzureNetworkFlow"; - OperationalInsightsTableData data = new OperationalInsightsTableData() + OperationalInsightsTableData data = new OperationalInsightsTableData { RetentionInDays = 45, TotalRetentionInDays = 70, - Schema = new OperationalInsightsSchema() + Schema = new OperationalInsightsSchema { Name = "AzureNetworkFlow", - Columns = -{ -new OperationalInsightsColumn() + Columns = {new OperationalInsightsColumn { Name = "MyNewColumn", ColumnType = OperationalInsightsColumnType.Guid, -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tableName, data); @@ -138,6 +99,42 @@ public async Task Get_TablesGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_TablesListByWorkspace() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/TablesList.json + // this example is just showing the usage of "Tables_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this OperationalInsightsWorkspaceResource created on azure + // for more information of creating OperationalInsightsWorkspaceResource, please refer to the document of OperationalInsightsWorkspaceResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + string resourceGroupName = "oiautorest6685"; + string workspaceName = "oiautorest6685"; + ResourceIdentifier operationalInsightsWorkspaceResourceId = OperationalInsightsWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); + OperationalInsightsWorkspaceResource operationalInsightsWorkspace = client.GetOperationalInsightsWorkspaceResource(operationalInsightsWorkspaceResourceId); + + // get the collection of this OperationalInsightsTableResource + OperationalInsightsTableCollection collection = operationalInsightsWorkspace.GetOperationalInsightsTables(); + + // invoke the operation and iterate over the result + await foreach (OperationalInsightsTableResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsTableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_TablesGet() diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsTableResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsTableResource.cs index f20fc2480463d..9982d4df30114 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsTableResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsTableResource.cs @@ -18,10 +18,10 @@ public partial class Sample_OperationalInsightsTableResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TablesUpsert() + public async Task Get_TablesGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/TablesUpsert.json - // this example is just showing the usage of "Tables_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/TablesGet.json + // this example is just showing the usage of "Tables_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,30 +33,12 @@ public async Task Update_TablesUpsert() string subscriptionId = "00000000-0000-0000-0000-00000000000"; string resourceGroupName = "oiautorest6685"; string workspaceName = "oiautorest6685"; - string tableName = "AzureNetworkFlow"; + string tableName = "table1_SRCH"; ResourceIdentifier operationalInsightsTableResourceId = OperationalInsightsTableResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, tableName); OperationalInsightsTableResource operationalInsightsTable = client.GetOperationalInsightsTableResource(operationalInsightsTableResourceId); // invoke the operation - OperationalInsightsTableData data = new OperationalInsightsTableData() - { - RetentionInDays = 45, - TotalRetentionInDays = 70, - Schema = new OperationalInsightsSchema() - { - Name = "AzureNetworkFlow", - Columns = -{ -new OperationalInsightsColumn() -{ -Name = "MyNewColumn", -ColumnType = OperationalInsightsColumnType.Guid, -} -}, - }, - }; - ArmOperation lro = await operationalInsightsTable.UpdateAsync(WaitUntil.Completed, data); - OperationalInsightsTableResource result = lro.Value; + OperationalInsightsTableResource result = await operationalInsightsTable.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -67,10 +49,10 @@ public async Task Update_TablesUpsert() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TablesGet() + public async Task Delete_TablesDelete() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/TablesGet.json - // this example is just showing the usage of "Tables_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/TablesDelete.json + // this example is just showing the usage of "Tables_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -82,26 +64,22 @@ public async Task Get_TablesGet() string subscriptionId = "00000000-0000-0000-0000-00000000000"; string resourceGroupName = "oiautorest6685"; string workspaceName = "oiautorest6685"; - string tableName = "table1_SRCH"; + string tableName = "table1_CL"; ResourceIdentifier operationalInsightsTableResourceId = OperationalInsightsTableResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, tableName); OperationalInsightsTableResource operationalInsightsTable = client.GetOperationalInsightsTableResource(operationalInsightsTableResourceId); // invoke the operation - OperationalInsightsTableResource result = await operationalInsightsTable.GetAsync(); + await operationalInsightsTable.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_TablesDelete() + public async Task Update_TablesUpsert() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/TablesDelete.json - // this example is just showing the usage of "Tables_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/TablesUpsert.json + // this example is just showing the usage of "Tables_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,14 +91,33 @@ public async Task Delete_TablesDelete() string subscriptionId = "00000000-0000-0000-0000-00000000000"; string resourceGroupName = "oiautorest6685"; string workspaceName = "oiautorest6685"; - string tableName = "table1_CL"; + string tableName = "AzureNetworkFlow"; ResourceIdentifier operationalInsightsTableResourceId = OperationalInsightsTableResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, tableName); OperationalInsightsTableResource operationalInsightsTable = client.GetOperationalInsightsTableResource(operationalInsightsTableResourceId); // invoke the operation - await operationalInsightsTable.DeleteAsync(WaitUntil.Completed); + OperationalInsightsTableData data = new OperationalInsightsTableData + { + RetentionInDays = 45, + TotalRetentionInDays = 70, + Schema = new OperationalInsightsSchema + { + Name = "AzureNetworkFlow", + Columns = {new OperationalInsightsColumn +{ +Name = "MyNewColumn", +ColumnType = OperationalInsightsColumnType.Guid, +}}, + }, + }; + ArmOperation lro = await operationalInsightsTable.UpdateAsync(WaitUntil.Completed, data); + OperationalInsightsTableResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsWorkspaceCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsWorkspaceCollection.cs index 7ed47064fb11c..aa3ac70d76fed 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsWorkspaceCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsWorkspaceCollection.cs @@ -17,41 +17,6 @@ namespace Azure.ResourceManager.OperationalInsights.Samples { public partial class Sample_OperationalInsightsWorkspaceCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkspacesGet() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/WorkspacesListByResourceGroup.json - // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - string resourceGroupName = "oiautorest6685"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this OperationalInsightsWorkspaceResource - OperationalInsightsWorkspaceCollection collection = resourceGroupResource.GetOperationalInsightsWorkspaces(); - - // invoke the operation and iterate over the result - await foreach (OperationalInsightsWorkspaceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_WorkspacesCreate() @@ -82,7 +47,7 @@ public async Task CreateOrUpdate_WorkspacesCreate() RetentionInDays = 30, Tags = { -["tag1"] = "val1", +["tag1"] = "val1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); @@ -128,6 +93,41 @@ public async Task Get_WorkspaceGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_WorkspacesGet() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/WorkspacesListByResourceGroup.json + // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + string resourceGroupName = "oiautorest6685"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this OperationalInsightsWorkspaceResource + OperationalInsightsWorkspaceCollection collection = resourceGroupResource.GetOperationalInsightsWorkspaces(); + + // invoke the operation and iterate over the result + await foreach (OperationalInsightsWorkspaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_WorkspaceGet() diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsWorkspaceResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsWorkspaceResource.cs index 76865df40ead7..dd6196945dc43 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsWorkspaceResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_OperationalInsightsWorkspaceResource.cs @@ -10,13 +10,107 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.OperationalInsights.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.OperationalInsights.Samples { public partial class Sample_OperationalInsightsWorkspaceResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_WorkspaceGet() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/WorkspacesGet.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this OperationalInsightsWorkspaceResource created on azure + // for more information of creating OperationalInsightsWorkspaceResource, please refer to the document of OperationalInsightsWorkspaceResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + string resourceGroupName = "oiautorest6685"; + string workspaceName = "oiautorest6685"; + ResourceIdentifier operationalInsightsWorkspaceResourceId = OperationalInsightsWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); + OperationalInsightsWorkspaceResource operationalInsightsWorkspace = client.GetOperationalInsightsWorkspaceResource(operationalInsightsWorkspaceResourceId); + + // invoke the operation + OperationalInsightsWorkspaceResource result = await operationalInsightsWorkspace.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_WorkspacesDelete() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/WorkspacesDelete.json + // this example is just showing the usage of "Workspaces_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this OperationalInsightsWorkspaceResource created on azure + // for more information of creating OperationalInsightsWorkspaceResource, please refer to the document of OperationalInsightsWorkspaceResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + string resourceGroupName = "oiautorest6685"; + string workspaceName = "oiautorest6685"; + ResourceIdentifier operationalInsightsWorkspaceResourceId = OperationalInsightsWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); + OperationalInsightsWorkspaceResource operationalInsightsWorkspace = client.GetOperationalInsightsWorkspaceResource(operationalInsightsWorkspaceResourceId); + + // invoke the operation + await operationalInsightsWorkspace.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_WorkspacesPatch() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/WorkspacesUpdate.json + // this example is just showing the usage of "Workspaces_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this OperationalInsightsWorkspaceResource created on azure + // for more information of creating OperationalInsightsWorkspaceResource, please refer to the document of OperationalInsightsWorkspaceResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + string resourceGroupName = "oiautorest6685"; + string workspaceName = "oiautorest6685"; + ResourceIdentifier operationalInsightsWorkspaceResourceId = OperationalInsightsWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); + OperationalInsightsWorkspaceResource operationalInsightsWorkspace = client.GetOperationalInsightsWorkspaceResource(operationalInsightsWorkspaceResourceId); + + // invoke the operation + OperationalInsightsWorkspacePatch patch = new OperationalInsightsWorkspacePatch + { + Sku = new OperationalInsightsWorkspaceSku(OperationalInsightsWorkspaceSkuName.PerGB2018), + RetentionInDays = 30, + WorkspaceCapping = new OperationalInsightsWorkspaceCapping + { + DailyQuotaInGB = -1, + }, + }; + OperationalInsightsWorkspaceResource result = await operationalInsightsWorkspace.UpdateAsync(patch); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task DisableIntelligencePack_IntelligencePacksDisable() @@ -318,11 +412,11 @@ public async Task Purge_WorkspacePurge() // invoke the operation OperationalInsightsWorkspacePurgeContent content = new OperationalInsightsWorkspacePurgeContent("Heartbeat", new OperationalInsightsWorkspacePurgeFilter[] { -new OperationalInsightsWorkspacePurgeFilter() +new OperationalInsightsWorkspacePurgeFilter { Column = "TimeGenerated", Operator = ">", -Value = BinaryData.FromString("\"2017-09-01T00:00:00\""), +Value = BinaryData.FromObjectAsJson("2017-09-01T00:00:00"), } }); OperationalInsightsWorkspacePurgeResult result = await operationalInsightsWorkspace.PurgeAsync(content); @@ -353,11 +447,11 @@ public async Task Purge_WorkspacePurgeResourceId() // invoke the operation OperationalInsightsWorkspacePurgeContent content = new OperationalInsightsWorkspacePurgeContent("Heartbeat", new OperationalInsightsWorkspacePurgeFilter[] { -new OperationalInsightsWorkspacePurgeFilter() +new OperationalInsightsWorkspacePurgeFilter { Column = "_ResourceId", Operator = "==", -Value = BinaryData.FromString("\"/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/SomeResourceGroup/providers/microsoft.insights/components/AppInsightResource\""), +Value = BinaryData.FromObjectAsJson("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/SomeResourceGroup/providers/microsoft.insights/components/AppInsightResource"), } }); OperationalInsightsWorkspacePurgeResult result = await operationalInsightsWorkspace.PurgeAsync(content); @@ -391,131 +485,5 @@ public async Task GetPurgeStatus_WorkspacePurgeOperation() Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetOperationalInsightsWorkspaces_WorkspacesSubscriptionList() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/WorkspacesSubscriptionList.json - // this example is just showing the usage of "Workspaces_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (OperationalInsightsWorkspaceResource item in subscriptionResource.GetOperationalInsightsWorkspacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_WorkspacesDelete() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/WorkspacesDelete.json - // this example is just showing the usage of "Workspaces_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this OperationalInsightsWorkspaceResource created on azure - // for more information of creating OperationalInsightsWorkspaceResource, please refer to the document of OperationalInsightsWorkspaceResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - string resourceGroupName = "oiautorest6685"; - string workspaceName = "oiautorest6685"; - ResourceIdentifier operationalInsightsWorkspaceResourceId = OperationalInsightsWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); - OperationalInsightsWorkspaceResource operationalInsightsWorkspace = client.GetOperationalInsightsWorkspaceResource(operationalInsightsWorkspaceResourceId); - - // invoke the operation - await operationalInsightsWorkspace.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_WorkspaceGet() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/WorkspacesGet.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this OperationalInsightsWorkspaceResource created on azure - // for more information of creating OperationalInsightsWorkspaceResource, please refer to the document of OperationalInsightsWorkspaceResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - string resourceGroupName = "oiautorest6685"; - string workspaceName = "oiautorest6685"; - ResourceIdentifier operationalInsightsWorkspaceResourceId = OperationalInsightsWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); - OperationalInsightsWorkspaceResource operationalInsightsWorkspace = client.GetOperationalInsightsWorkspaceResource(operationalInsightsWorkspaceResourceId); - - // invoke the operation - OperationalInsightsWorkspaceResource result = await operationalInsightsWorkspace.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_WorkspacesPatch() - { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/WorkspacesUpdate.json - // this example is just showing the usage of "Workspaces_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this OperationalInsightsWorkspaceResource created on azure - // for more information of creating OperationalInsightsWorkspaceResource, please refer to the document of OperationalInsightsWorkspaceResource - string subscriptionId = "00000000-0000-0000-0000-00000000000"; - string resourceGroupName = "oiautorest6685"; - string workspaceName = "oiautorest6685"; - ResourceIdentifier operationalInsightsWorkspaceResourceId = OperationalInsightsWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); - OperationalInsightsWorkspaceResource operationalInsightsWorkspace = client.GetOperationalInsightsWorkspaceResource(operationalInsightsWorkspaceResourceId); - - // invoke the operation - OperationalInsightsWorkspacePatch patch = new OperationalInsightsWorkspacePatch() - { - Sku = new OperationalInsightsWorkspaceSku(OperationalInsightsWorkspaceSkuName.PerGB2018), - RetentionInDays = 30, - WorkspaceCapping = new OperationalInsightsWorkspaceCapping() - { - DailyQuotaInGB = -1, - }, - }; - OperationalInsightsWorkspaceResource result = await operationalInsightsWorkspace.UpdateAsync(patch); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalInsightsWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index ac792283ac4ac..d05240e544c82 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -16,6 +16,72 @@ namespace Azure.ResourceManager.OperationalInsights.Samples { public partial class Sample_ResourceGroupResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdateWithoutNameQueryPack_QueryPackCreateNoName() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksCreateNoName.json + // this example is just showing the usage of "QueryPacks_CreateOrUpdateWithoutName" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; + string resourceGroupName = "my-resource-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation + LogAnalyticsQueryPackData data = new LogAnalyticsQueryPackData(new AzureLocation("South Central US")); + LogAnalyticsQueryPackResource result = await resourceGroupResource.CreateOrUpdateWithoutNameQueryPackAsync(data); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogAnalyticsQueryPackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdateWithoutNameQueryPack_QueryPackUpdateNoName() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPackUpdateNoName.json + // this example is just showing the usage of "QueryPacks_CreateOrUpdateWithoutName" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; + string resourceGroupName = "my-resource-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation + LogAnalyticsQueryPackData data = new LogAnalyticsQueryPackData(new AzureLocation("South Central US")) + { + Tags = +{ +["Tag1"] = "Value1" +}, + }; + LogAnalyticsQueryPackResource result = await resourceGroupResource.CreateOrUpdateWithoutNameQueryPackAsync(data); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogAnalyticsQueryPackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetDeletedWorkspaces_WorkspacesGet() diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_StorageInsightCollection.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_StorageInsightCollection.cs index 5f424fd2e06db..40a1f971aa40c 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_StorageInsightCollection.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_StorageInsightCollection.cs @@ -41,16 +41,10 @@ public async Task CreateOrUpdate_StorageInsightsCreate() // invoke the operation string storageInsightName = "AzTestSI1110"; - StorageInsightData data = new StorageInsightData() + StorageInsightData data = new StorageInsightData { - Containers = -{ -"wad-iis-logfiles" -}, - Tables = -{ -"WADWindowsEventLogsTable","LinuxSyslogVer2v0" -}, + Containers = { "wad-iis-logfiles" }, + Tables = { "WADWindowsEventLogsTable", "LinuxSyslogVer2v0" }, StorageAccount = new OperationalInsightsStorageAccount(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000005/resourcegroups/OIAutoRest6987/providers/microsoft.storage/storageaccounts/AzTestFakeSA9945"), "1234"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageInsightName, data); @@ -99,10 +93,10 @@ public async Task Get_StorageInsightsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageInsightsGet() + public async Task GetAll_StorageInsightsList() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsGet.json - // this example is just showing the usage of "StorageInsightConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsListByWorkspace.json + // this example is just showing the usage of "StorageInsightConfigs_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,16 +114,22 @@ public async Task Exists_StorageInsightsGet() // get the collection of this StorageInsightResource StorageInsightCollection collection = operationalInsightsWorkspace.GetStorageInsights(); - // invoke the operation - string storageInsightName = "AzTestSI1110"; - bool result = await collection.ExistsAsync(storageInsightName); + // invoke the operation and iterate over the result + await foreach (StorageInsightResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageInsightData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageInsightsGet() + public async Task Exists_StorageInsightsGet() { // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsGet.json // this example is just showing the usage of "StorageInsightConfigs_Get" operation, for the dependent resources, they will have to be created separately. @@ -152,29 +152,17 @@ public async Task GetIfExists_StorageInsightsGet() // invoke the operation string storageInsightName = "AzTestSI1110"; - NullableResponse response = await collection.GetIfExistsAsync(storageInsightName); - StorageInsightResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(storageInsightName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageInsightData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StorageInsightsList() + public async Task GetIfExists_StorageInsightsGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsListByWorkspace.json - // this example is just showing the usage of "StorageInsightConfigs_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsGet.json + // this example is just showing the usage of "StorageInsightConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,17 +180,23 @@ public async Task GetAll_StorageInsightsList() // get the collection of this StorageInsightResource StorageInsightCollection collection = operationalInsightsWorkspace.GetStorageInsights(); - // invoke the operation and iterate over the result - await foreach (StorageInsightResource item in collection.GetAllAsync()) + // invoke the operation + string storageInsightName = "AzTestSI1110"; + NullableResponse response = await collection.GetIfExistsAsync(storageInsightName); + StorageInsightResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageInsightData resourceData = item.Data; + StorageInsightData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_StorageInsightResource.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_StorageInsightResource.cs index aab231fad6092..2cca8ffc674ca 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_StorageInsightResource.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_StorageInsightResource.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageInsightResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_StorageInsightsCreate() + public async Task Get_StorageInsightsGet() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsCreateOrUpdate.json - // this example is just showing the usage of "StorageInsightConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsGet.json + // this example is just showing the usage of "StorageInsightConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,20 +38,7 @@ public async Task Update_StorageInsightsCreate() StorageInsightResource storageInsight = client.GetStorageInsightResource(storageInsightResourceId); // invoke the operation - StorageInsightData data = new StorageInsightData() - { - Containers = -{ -"wad-iis-logfiles" -}, - Tables = -{ -"WADWindowsEventLogsTable","LinuxSyslogVer2v0" -}, - StorageAccount = new OperationalInsightsStorageAccount(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000005/resourcegroups/OIAutoRest6987/providers/microsoft.storage/storageaccounts/AzTestFakeSA9945"), "1234"), - }; - ArmOperation lro = await storageInsight.UpdateAsync(WaitUntil.Completed, data); - StorageInsightResource result = lro.Value; + StorageInsightResource result = await storageInsight.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -62,10 +49,10 @@ public async Task Update_StorageInsightsCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageInsightsGet() + public async Task Delete_StorageInsightsDelete() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsGet.json - // this example is just showing the usage of "StorageInsightConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsDelete.json + // this example is just showing the usage of "StorageInsightConfigs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -82,21 +69,17 @@ public async Task Get_StorageInsightsGet() StorageInsightResource storageInsight = client.GetStorageInsightResource(storageInsightResourceId); // invoke the operation - StorageInsightResource result = await storageInsight.GetAsync(); + await storageInsight.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageInsightData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_StorageInsightsDelete() + public async Task Update_StorageInsightsCreate() { - // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsDelete.json - // this example is just showing the usage of "StorageInsightConfigs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2020-08-01/examples/StorageInsightsCreateOrUpdate.json + // this example is just showing the usage of "StorageInsightConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,9 +96,20 @@ public async Task Delete_StorageInsightsDelete() StorageInsightResource storageInsight = client.GetStorageInsightResource(storageInsightResourceId); // invoke the operation - await storageInsight.DeleteAsync(WaitUntil.Completed); + StorageInsightData data = new StorageInsightData + { + Containers = { "wad-iis-logfiles" }, + Tables = { "WADWindowsEventLogsTable", "LinuxSyslogVer2v0" }, + StorageAccount = new OperationalInsightsStorageAccount(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000005/resourcegroups/OIAutoRest6987/providers/microsoft.storage/storageaccounts/AzTestFakeSA9945"), "1234"), + }; + ArmOperation lro = await storageInsight.UpdateAsync(WaitUntil.Completed, data); + StorageInsightResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageInsightData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index c6cb0400b3b3a..2c9b6006d4581 100644 --- a/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/operationalinsights/Azure.ResourceManager.OperationalInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -16,6 +16,99 @@ namespace Azure.ResourceManager.OperationalInsights.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetLogAnalyticsQueryPacks_QueryPacksList() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2019-09-01/examples/QueryPacksList.json + // this example is just showing the usage of "QueryPacks_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (LogAnalyticsQueryPackResource item in subscriptionResource.GetLogAnalyticsQueryPacksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogAnalyticsQueryPackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetOperationalInsightsClusters_ClustersSubscriptionList() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2021-06-01/examples/ClustersSubscriptionList.json + // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (OperationalInsightsClusterResource item in subscriptionResource.GetOperationalInsightsClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetOperationalInsightsWorkspaces_WorkspacesSubscriptionList() + { + // Generated from example definition: specification/operationalinsights/resource-manager/Microsoft.OperationalInsights/stable/2022-10-01/examples/WorkspacesSubscriptionList.json + // this example is just showing the usage of "Workspaces_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-00000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (OperationalInsightsWorkspaceResource item in subscriptionResource.GetOperationalInsightsWorkspacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalInsightsWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetDeletedWorkspaces_WorkspacesSubscriptionList() diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDBVersionCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDBVersionCollection.cs index e3de9206b8c86..df91b65929ec2 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDBVersionCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDBVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutonomousDBVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAnAutonomousVersionsByLocation() + public async Task Get_GetAnAutonomousVersion() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseVersion_listByLocation.json - // this example is just showing the usage of "AutonomousDatabaseVersions_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseVersion_get.json + // this example is just showing the usage of "AutonomousDatabaseVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListAnAutonomousVersionsByLocation() AzureLocation location = new AzureLocation("eastus"); AutonomousDBVersionCollection collection = subscriptionResource.GetAutonomousDBVersions(location); - // invoke the operation and iterate over the result - await foreach (AutonomousDBVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDBVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string autonomousdbversionsname = "18.4.0.0"; + AutonomousDBVersionResource result = await collection.GetAsync(autonomousdbversionsname); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDBVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAutonomousVersion() + public async Task GetAll_ListAnAutonomousVersionsByLocation() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseVersion_get.json - // this example is just showing the usage of "AutonomousDatabaseVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseVersion_listByLocation.json + // this example is just showing the usage of "AutonomousDatabaseVersions_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetAnAutonomousVersion() AzureLocation location = new AzureLocation("eastus"); AutonomousDBVersionCollection collection = subscriptionResource.GetAutonomousDBVersions(location); - // invoke the operation - string autonomousdbversionsname = "18.4.0.0"; - AutonomousDBVersionResource result = await collection.GetAsync(autonomousdbversionsname); + // invoke the operation and iterate over the result + await foreach (AutonomousDBVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDBVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDBVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseBackupCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseBackupCollection.cs index 4d7aabed70b0e..e432c8e9a7b72 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseBackupCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseBackupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutonomousDatabaseBackupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AutonomousDatabaseBackupsListByAutonomousDatabase() + public async Task CreateOrUpdate_AutonomousDatabaseBackupsCreateOrUpdate() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_listByParent.json - // this example is just showing the usage of "AutonomousDatabaseBackups_ListByAutonomousDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_create.json + // this example is just showing the usage of "AutonomousDatabaseBackups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,32 @@ public async Task GetAll_AutonomousDatabaseBackupsListByAutonomousDatabase() // get the collection of this AutonomousDatabaseBackupResource AutonomousDatabaseBackupCollection collection = autonomousDatabase.GetAutonomousDatabaseBackups(); - // invoke the operation and iterate over the result - await foreach (AutonomousDatabaseBackupResource item in collection.GetAllAsync()) + // invoke the operation + string adbbackupid = "1711644130"; + AutonomousDatabaseBackupData data = new AutonomousDatabaseBackupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseBackupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AutonomousDatabaseBackupProperties + { + DisplayName = "Nightly Backup", + RetentionPeriodInDays = 365, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, adbbackupid, data); + AutonomousDatabaseBackupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAutonomousDatabaseBackupsByAutonomousDatabase() + public async Task CreateOrUpdate_CreateAutonomousDatabaseBackup() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_listByParent.json - // this example is just showing the usage of "AutonomousDatabaseBackups_ListByAutonomousDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_create.json + // this example is just showing the usage of "AutonomousDatabaseBackups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +82,24 @@ public async Task GetAll_ListAutonomousDatabaseBackupsByAutonomousDatabase() // get the collection of this AutonomousDatabaseBackupResource AutonomousDatabaseBackupCollection collection = autonomousDatabase.GetAutonomousDatabaseBackups(); - // invoke the operation and iterate over the result - await foreach (AutonomousDatabaseBackupResource item in collection.GetAllAsync()) + // invoke the operation + string adbbackupid = "1711644130"; + AutonomousDatabaseBackupData data = new AutonomousDatabaseBackupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseBackupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AutonomousDatabaseBackupProperties + { + DisplayName = "Nightly Backup", + RetentionPeriodInDays = 365, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, adbbackupid, data); + AutonomousDatabaseBackupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -124,7 +138,7 @@ public async Task Get_AutonomousDatabaseBackupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AutonomousDatabaseBackupsGet() + public async Task Get_GetAutonomousDatabaseBackup() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_get.json // this example is just showing the usage of "AutonomousDatabaseBackups_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,17 +161,21 @@ public async Task Exists_AutonomousDatabaseBackupsGet() // invoke the operation string adbbackupid = "1711644130"; - bool result = await collection.ExistsAsync(adbbackupid); + AutonomousDatabaseBackupResource result = await collection.GetAsync(adbbackupid); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AutonomousDatabaseBackupsGet() + public async Task GetAll_AutonomousDatabaseBackupsListByAutonomousDatabase() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_get.json - // this example is just showing the usage of "AutonomousDatabaseBackups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_listByParent.json + // this example is just showing the usage of "AutonomousDatabaseBackups_ListByAutonomousDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -175,31 +193,25 @@ public async Task GetIfExists_AutonomousDatabaseBackupsGet() // get the collection of this AutonomousDatabaseBackupResource AutonomousDatabaseBackupCollection collection = autonomousDatabase.GetAutonomousDatabaseBackups(); - // invoke the operation - string adbbackupid = "1711644130"; - NullableResponse response = await collection.GetIfExistsAsync(adbbackupid); - AutonomousDatabaseBackupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutonomousDatabaseBackupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutonomousDatabaseBackupData resourceData = result.Data; + AutonomousDatabaseBackupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAutonomousDatabaseBackup() + public async Task GetAll_ListAutonomousDatabaseBackupsByAutonomousDatabase() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_get.json - // this example is just showing the usage of "AutonomousDatabaseBackups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_listByParent.json + // this example is just showing the usage of "AutonomousDatabaseBackups_ListByAutonomousDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,20 +229,22 @@ public async Task Get_GetAutonomousDatabaseBackup() // get the collection of this AutonomousDatabaseBackupResource AutonomousDatabaseBackupCollection collection = autonomousDatabase.GetAutonomousDatabaseBackups(); - // invoke the operation - string adbbackupid = "1711644130"; - AutonomousDatabaseBackupResource result = await collection.GetAsync(adbbackupid); + // invoke the operation and iterate over the result + await foreach (AutonomousDatabaseBackupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseBackupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAutonomousDatabaseBackup() + public async Task Exists_AutonomousDatabaseBackupsGet() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_get.json // this example is just showing the usage of "AutonomousDatabaseBackups_Get" operation, for the dependent resources, they will have to be created separately. @@ -260,7 +274,7 @@ public async Task Exists_GetAutonomousDatabaseBackup() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAutonomousDatabaseBackup() + public async Task Exists_GetAutonomousDatabaseBackup() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_get.json // this example is just showing the usage of "AutonomousDatabaseBackups_Get" operation, for the dependent resources, they will have to be created separately. @@ -283,29 +297,17 @@ public async Task GetIfExists_GetAutonomousDatabaseBackup() // invoke the operation string adbbackupid = "1711644130"; - NullableResponse response = await collection.GetIfExistsAsync(adbbackupid); - AutonomousDatabaseBackupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(adbbackupid); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AutonomousDatabaseBackupsCreateOrUpdate() + public async Task GetIfExists_AutonomousDatabaseBackupsGet() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_create.json - // this example is just showing the usage of "AutonomousDatabaseBackups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_get.json + // this example is just showing the usage of "AutonomousDatabaseBackups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -325,30 +327,29 @@ public async Task CreateOrUpdate_AutonomousDatabaseBackupsCreateOrUpdate() // invoke the operation string adbbackupid = "1711644130"; - AutonomousDatabaseBackupData data = new AutonomousDatabaseBackupData() - { - Properties = new AutonomousDatabaseBackupProperties() - { - DisplayName = "Nightly Backup", - RetentionPeriodInDays = 365, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, adbbackupid, data); - AutonomousDatabaseBackupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(adbbackupid); + AutonomousDatabaseBackupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAutonomousDatabaseBackup() + public async Task GetIfExists_GetAutonomousDatabaseBackup() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_create.json - // this example is just showing the usage of "AutonomousDatabaseBackups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_get.json + // this example is just showing the usage of "AutonomousDatabaseBackups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -368,22 +369,21 @@ public async Task CreateOrUpdate_CreateAutonomousDatabaseBackup() // invoke the operation string adbbackupid = "1711644130"; - AutonomousDatabaseBackupData data = new AutonomousDatabaseBackupData() - { - Properties = new AutonomousDatabaseBackupProperties() - { - DisplayName = "Nightly Backup", - RetentionPeriodInDays = 365, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, adbbackupid, data); - AutonomousDatabaseBackupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(adbbackupid); + AutonomousDatabaseBackupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseBackupResource.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseBackupResource.cs index f0c166c9abe18..7c8abf7762488 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseBackupResource.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseBackupResource.cs @@ -80,10 +80,10 @@ public async Task Get_GetAutonomousDatabaseBackup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AutonomousDatabaseBackupsUpdate() + public async Task Delete_AutonomousDatabaseBackupsDelete() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_patch.json - // this example is just showing the usage of "AutonomousDatabaseBackups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_delete.json + // this example is just showing the usage of "AutonomousDatabaseBackups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,23 +100,17 @@ public async Task Update_AutonomousDatabaseBackupsUpdate() AutonomousDatabaseBackupResource autonomousDatabaseBackup = client.GetAutonomousDatabaseBackupResource(autonomousDatabaseBackupResourceId); // invoke the operation - AutonomousDatabaseBackupPatch patch = new AutonomousDatabaseBackupPatch(); - ArmOperation lro = await autonomousDatabaseBackup.UpdateAsync(WaitUntil.Completed, patch); - AutonomousDatabaseBackupResource result = lro.Value; + await autonomousDatabaseBackup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAutonomousDatabaseBackup() + public async Task Delete_DeleteAutonomousDatabaseBackup() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_patch.json - // this example is just showing the usage of "AutonomousDatabaseBackups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_delete.json + // this example is just showing the usage of "AutonomousDatabaseBackups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,23 +127,17 @@ public async Task Update_PatchAutonomousDatabaseBackup() AutonomousDatabaseBackupResource autonomousDatabaseBackup = client.GetAutonomousDatabaseBackupResource(autonomousDatabaseBackupResourceId); // invoke the operation - AutonomousDatabaseBackupPatch patch = new AutonomousDatabaseBackupPatch(); - ArmOperation lro = await autonomousDatabaseBackup.UpdateAsync(WaitUntil.Completed, patch); - AutonomousDatabaseBackupResource result = lro.Value; + await autonomousDatabaseBackup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AutonomousDatabaseBackupsDelete() + public async Task Update_AutonomousDatabaseBackupsUpdate() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_delete.json - // this example is just showing the usage of "AutonomousDatabaseBackups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_patch.json + // this example is just showing the usage of "AutonomousDatabaseBackups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -166,17 +154,23 @@ public async Task Delete_AutonomousDatabaseBackupsDelete() AutonomousDatabaseBackupResource autonomousDatabaseBackup = client.GetAutonomousDatabaseBackupResource(autonomousDatabaseBackupResourceId); // invoke the operation - await autonomousDatabaseBackup.DeleteAsync(WaitUntil.Completed); + AutonomousDatabaseBackupPatch patch = new AutonomousDatabaseBackupPatch(); + ArmOperation lro = await autonomousDatabaseBackup.UpdateAsync(WaitUntil.Completed, patch); + AutonomousDatabaseBackupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAutonomousDatabaseBackup() + public async Task Update_PatchAutonomousDatabaseBackup() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_delete.json - // this example is just showing the usage of "AutonomousDatabaseBackups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseBackup_patch.json + // this example is just showing the usage of "AutonomousDatabaseBackups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,9 +187,15 @@ public async Task Delete_DeleteAutonomousDatabaseBackup() AutonomousDatabaseBackupResource autonomousDatabaseBackup = client.GetAutonomousDatabaseBackupResource(autonomousDatabaseBackupResourceId); // invoke the operation - await autonomousDatabaseBackup.DeleteAsync(WaitUntil.Completed); + AutonomousDatabaseBackupPatch patch = new AutonomousDatabaseBackupPatch(); + ArmOperation lro = await autonomousDatabaseBackup.UpdateAsync(WaitUntil.Completed, patch); + AutonomousDatabaseBackupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseCharacterSetCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseCharacterSetCollection.cs index af466af5ce409..1a919c543c088 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseCharacterSetCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseCharacterSetCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutonomousDatabaseCharacterSetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAutonomousDbCharacterSetsByLocation() + public async Task Get_GetAutonomousDbCharacterSet() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseCharacterSet_listByLocation.json - // this example is just showing the usage of "AutonomousDatabaseCharacterSets_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseCharacterSet_get.json + // this example is just showing the usage of "AutonomousDatabaseCharacterSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListAutonomousDbCharacterSetsByLocation() AzureLocation location = new AzureLocation("eastus"); AutonomousDatabaseCharacterSetCollection collection = subscriptionResource.GetAutonomousDatabaseCharacterSets(location); - // invoke the operation and iterate over the result - await foreach (AutonomousDatabaseCharacterSetResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseCharacterSetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string adbscharsetname = "DATABASE"; + AutonomousDatabaseCharacterSetResource result = await collection.GetAsync(adbscharsetname); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseCharacterSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAutonomousDbCharacterSet() + public async Task GetAll_ListAutonomousDbCharacterSetsByLocation() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseCharacterSet_get.json - // this example is just showing the usage of "AutonomousDatabaseCharacterSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseCharacterSet_listByLocation.json + // this example is just showing the usage of "AutonomousDatabaseCharacterSets_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetAutonomousDbCharacterSet() AzureLocation location = new AzureLocation("eastus"); AutonomousDatabaseCharacterSetCollection collection = subscriptionResource.GetAutonomousDatabaseCharacterSets(location); - // invoke the operation - string adbscharsetname = "DATABASE"; - AutonomousDatabaseCharacterSetResource result = await collection.GetAsync(adbscharsetname); + // invoke the operation and iterate over the result + await foreach (AutonomousDatabaseCharacterSetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseCharacterSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseCharacterSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseCollection.cs index 748ac1f8dcce0..1f2c1fd273516 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AutonomousDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAutonomousDatabaseByResourceGroup() + public async Task CreateOrUpdate_AutonomousDatabasesCreateOrUpdate() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_listByResourceGroup.json - // this example is just showing the usage of "AutonomousDatabases_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_create.json + // this example is just showing the usage of "AutonomousDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,44 @@ public async Task GetAll_ListAutonomousDatabaseByResourceGroup() // get the collection of this AutonomousDatabaseResource AutonomousDatabaseCollection collection = resourceGroupResource.GetAutonomousDatabases(); - // invoke the operation and iterate over the result - await foreach (AutonomousDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string autonomousdatabasename = "databasedb1"; + AutonomousDatabaseData data = new AutonomousDatabaseData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AutonomousDatabaseProperties + { + AdminPassword = "********", + CharacterSet = "AL32UTF8", + ComputeCount = 2, + ComputeModel = AutonomousDatabaseComputeModel.Ecpu, + DataStorageSizeInTbs = 1, + DBVersion = "18.4.0.0", + DisplayName = "example_autonomous_databasedb1", + NcharacterSet = "AL16UTF16", + SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), + VnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1"), + }, + Tags = +{ +["tagK1"] = "tagV1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autonomousdatabasename, data); + AutonomousDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AutonomousDatabasesGet() + public async Task CreateOrUpdate_AutonomousDatabasesCreateOrUpdateClone() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_get.json - // this example is just showing the usage of "AutonomousDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseClone_create.json + // this example is just showing the usage of "AutonomousDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +95,27 @@ public async Task Get_AutonomousDatabasesGet() // invoke the operation string autonomousdatabasename = "databasedb1"; - AutonomousDatabaseResource result = await collection.GetAsync(autonomousdatabasename); + AutonomousDatabaseData data = new AutonomousDatabaseData(new AzureLocation("eastus")) + { + Properties = new AutonomousDatabaseCloneProperties(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Oracle.Database/autonomousDatabases/databasedb1"), AutonomousDatabaseCloneType.Full) + { + AdminPassword = "********", + CharacterSet = "AL32UTF8", + ComputeCount = 2, + ComputeModel = AutonomousDatabaseComputeModel.Ecpu, + DataStorageSizeInTbs = 1, + DisplayName = "example_autonomous_databasedb1_clone", + NcharacterSet = "AL16UTF16", + SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), + VnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1"), + }, + Tags = +{ +["tagK1"] = "tagV1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autonomousdatabasename, data); + AutonomousDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,10 +126,10 @@ public async Task Get_AutonomousDatabasesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AutonomousDatabasesGet() + public async Task CreateOrUpdate_CreateAutonomousDatabase() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_get.json - // this example is just showing the usage of "AutonomousDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_create.json + // this example is just showing the usage of "AutonomousDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,17 +148,42 @@ public async Task Exists_AutonomousDatabasesGet() // invoke the operation string autonomousdatabasename = "databasedb1"; - bool result = await collection.ExistsAsync(autonomousdatabasename); + AutonomousDatabaseData data = new AutonomousDatabaseData(new AzureLocation("eastus")) + { + Properties = new AutonomousDatabaseProperties + { + AdminPassword = "********", + CharacterSet = "AL32UTF8", + ComputeCount = 2, + ComputeModel = AutonomousDatabaseComputeModel.Ecpu, + DataStorageSizeInTbs = 1, + DBVersion = "18.4.0.0", + DisplayName = "example_autonomous_databasedb1", + NcharacterSet = "AL16UTF16", + SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), + VnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1"), + }, + Tags = +{ +["tagK1"] = "tagV1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autonomousdatabasename, data); + AutonomousDatabaseResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AutonomousDatabasesGet() + public async Task CreateOrUpdate_CreateCloneAutonomousDatabase() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_get.json - // this example is just showing the usage of "AutonomousDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseClone_create.json + // this example is just showing the usage of "AutonomousDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,26 +202,38 @@ public async Task GetIfExists_AutonomousDatabasesGet() // invoke the operation string autonomousdatabasename = "databasedb1"; - NullableResponse response = await collection.GetIfExistsAsync(autonomousdatabasename); - AutonomousDatabaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + AutonomousDatabaseData data = new AutonomousDatabaseData(new AzureLocation("eastus")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AutonomousDatabaseCloneProperties(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Oracle.Database/autonomousDatabases/databasedb1"), AutonomousDatabaseCloneType.Full) + { + AdminPassword = "********", + CharacterSet = "AL32UTF8", + ComputeCount = 2, + ComputeModel = AutonomousDatabaseComputeModel.Ecpu, + DataStorageSizeInTbs = 1, + DisplayName = "example_autonomous_databasedb1_clone", + NcharacterSet = "AL16UTF16", + SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), + VnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1"), + }, + Tags = +{ +["tagK1"] = "tagV1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autonomousdatabasename, data); + AutonomousDatabaseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAutonomousDatabase() + public async Task Get_AutonomousDatabasesGet() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_get.json // this example is just showing the usage of "AutonomousDatabases_Get" operation, for the dependent resources, they will have to be created separately. @@ -190,7 +266,7 @@ public async Task Get_GetAutonomousDatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAutonomousDatabase() + public async Task Get_GetAutonomousDatabase() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_get.json // this example is just showing the usage of "AutonomousDatabases_Get" operation, for the dependent resources, they will have to be created separately. @@ -212,17 +288,21 @@ public async Task Exists_GetAutonomousDatabase() // invoke the operation string autonomousdatabasename = "databasedb1"; - bool result = await collection.ExistsAsync(autonomousdatabasename); + AutonomousDatabaseResource result = await collection.GetAsync(autonomousdatabasename); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAutonomousDatabase() + public async Task GetAll_ListAutonomousDatabaseByResourceGroup() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_get.json - // this example is just showing the usage of "AutonomousDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_listByResourceGroup.json + // this example is just showing the usage of "AutonomousDatabases_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -239,31 +319,25 @@ public async Task GetIfExists_GetAutonomousDatabase() // get the collection of this AutonomousDatabaseResource AutonomousDatabaseCollection collection = resourceGroupResource.GetAutonomousDatabases(); - // invoke the operation - string autonomousdatabasename = "databasedb1"; - NullableResponse response = await collection.GetIfExistsAsync(autonomousdatabasename); - AutonomousDatabaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutonomousDatabaseResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutonomousDatabaseData resourceData = result.Data; + AutonomousDatabaseData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AutonomousDatabasesCreateOrUpdate() + public async Task Exists_AutonomousDatabasesGet() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_create.json - // this example is just showing the usage of "AutonomousDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_get.json + // this example is just showing the usage of "AutonomousDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -282,42 +356,17 @@ public async Task CreateOrUpdate_AutonomousDatabasesCreateOrUpdate() // invoke the operation string autonomousdatabasename = "databasedb1"; - AutonomousDatabaseData data = new AutonomousDatabaseData(new AzureLocation("eastus")) - { - Properties = new AutonomousDatabaseProperties() - { - AdminPassword = "********", - CharacterSet = "AL32UTF8", - ComputeCount = 2, - ComputeModel = AutonomousDatabaseComputeModel.Ecpu, - DataStorageSizeInTbs = 1, - DBVersion = "18.4.0.0", - DisplayName = "example_autonomous_databasedb1", - NcharacterSet = "AL16UTF16", - SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), - VnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1"), - }, - Tags = -{ -["tagK1"] = "tagV1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autonomousdatabasename, data); - AutonomousDatabaseResource result = lro.Value; + bool result = await collection.ExistsAsync(autonomousdatabasename); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AutonomousDatabasesCreateOrUpdateClone() + public async Task Exists_GetAutonomousDatabase() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseClone_create.json - // this example is just showing the usage of "AutonomousDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_get.json + // this example is just showing the usage of "AutonomousDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -336,41 +385,17 @@ public async Task CreateOrUpdate_AutonomousDatabasesCreateOrUpdateClone() // invoke the operation string autonomousdatabasename = "databasedb1"; - AutonomousDatabaseData data = new AutonomousDatabaseData(new AzureLocation("eastus")) - { - Properties = new AutonomousDatabaseCloneProperties(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Oracle.Database/autonomousDatabases/databasedb1"), AutonomousDatabaseCloneType.Full) - { - AdminPassword = "********", - CharacterSet = "AL32UTF8", - ComputeCount = 2, - ComputeModel = AutonomousDatabaseComputeModel.Ecpu, - DataStorageSizeInTbs = 1, - DisplayName = "example_autonomous_databasedb1_clone", - NcharacterSet = "AL16UTF16", - SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), - VnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1"), - }, - Tags = -{ -["tagK1"] = "tagV1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autonomousdatabasename, data); - AutonomousDatabaseResource result = lro.Value; + bool result = await collection.ExistsAsync(autonomousdatabasename); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAutonomousDatabase() + public async Task GetIfExists_AutonomousDatabasesGet() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_create.json - // this example is just showing the usage of "AutonomousDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_get.json + // this example is just showing the usage of "AutonomousDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -389,42 +414,29 @@ public async Task CreateOrUpdate_CreateAutonomousDatabase() // invoke the operation string autonomousdatabasename = "databasedb1"; - AutonomousDatabaseData data = new AutonomousDatabaseData(new AzureLocation("eastus")) - { - Properties = new AutonomousDatabaseProperties() - { - AdminPassword = "********", - CharacterSet = "AL32UTF8", - ComputeCount = 2, - ComputeModel = AutonomousDatabaseComputeModel.Ecpu, - DataStorageSizeInTbs = 1, - DBVersion = "18.4.0.0", - DisplayName = "example_autonomous_databasedb1", - NcharacterSet = "AL16UTF16", - SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), - VnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1"), - }, - Tags = -{ -["tagK1"] = "tagV1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autonomousdatabasename, data); - AutonomousDatabaseResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(autonomousdatabasename); + AutonomousDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCloneAutonomousDatabase() + public async Task GetIfExists_GetAutonomousDatabase() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseClone_create.json - // this example is just showing the usage of "AutonomousDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_get.json + // this example is just showing the usage of "AutonomousDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -443,33 +455,21 @@ public async Task CreateOrUpdate_CreateCloneAutonomousDatabase() // invoke the operation string autonomousdatabasename = "databasedb1"; - AutonomousDatabaseData data = new AutonomousDatabaseData(new AzureLocation("eastus")) - { - Properties = new AutonomousDatabaseCloneProperties(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Oracle.Database/autonomousDatabases/databasedb1"), AutonomousDatabaseCloneType.Full) - { - AdminPassword = "********", - CharacterSet = "AL32UTF8", - ComputeCount = 2, - ComputeModel = AutonomousDatabaseComputeModel.Ecpu, - DataStorageSizeInTbs = 1, - DisplayName = "example_autonomous_databasedb1_clone", - NcharacterSet = "AL16UTF16", - SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), - VnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1"), - }, - Tags = -{ -["tagK1"] = "tagV1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autonomousdatabasename, data); - AutonomousDatabaseResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(autonomousdatabasename); + AutonomousDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseNationalCharacterSetCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseNationalCharacterSetCollection.cs index 3ed8a763dff50..1af02f84b336c 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseNationalCharacterSetCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseNationalCharacterSetCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutonomousDatabaseNationalCharacterSetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAutonomousDbNationalCharacterSetsByLocation() + public async Task Get_GetAutonomousDbNationalCharacterSet() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseNationalCharacterSet_listByLocation.json - // this example is just showing the usage of "AutonomousDatabaseNationalCharacterSets_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseNationalCharacterSet_get.json + // this example is just showing the usage of "AutonomousDatabaseNationalCharacterSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListAutonomousDbNationalCharacterSetsByLocation() AzureLocation location = new AzureLocation("eastus"); AutonomousDatabaseNationalCharacterSetCollection collection = subscriptionResource.GetAutonomousDatabaseNationalCharacterSets(location); - // invoke the operation and iterate over the result - await foreach (AutonomousDatabaseNationalCharacterSetResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseNationalCharacterSetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string adbsncharsetname = "NATIONAL"; + AutonomousDatabaseNationalCharacterSetResource result = await collection.GetAsync(adbsncharsetname); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseNationalCharacterSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAutonomousDbNationalCharacterSet() + public async Task GetAll_ListAutonomousDbNationalCharacterSetsByLocation() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseNationalCharacterSet_get.json - // this example is just showing the usage of "AutonomousDatabaseNationalCharacterSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabaseNationalCharacterSet_listByLocation.json + // this example is just showing the usage of "AutonomousDatabaseNationalCharacterSets_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetAutonomousDbNationalCharacterSet() AzureLocation location = new AzureLocation("eastus"); AutonomousDatabaseNationalCharacterSetCollection collection = subscriptionResource.GetAutonomousDatabaseNationalCharacterSets(location); - // invoke the operation - string adbsncharsetname = "NATIONAL"; - AutonomousDatabaseNationalCharacterSetResource result = await collection.GetAsync(adbsncharsetname); + // invoke the operation and iterate over the result + await foreach (AutonomousDatabaseNationalCharacterSetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseNationalCharacterSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseNationalCharacterSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseResource.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseResource.cs index 2724721b72a03..35c1cdf0dc91b 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseResource.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_AutonomousDatabaseResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.OracleDatabase.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.OracleDatabase.Samples { public partial class Sample_AutonomousDatabaseResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAutonomousDatabases_ListAutonomousDatabaseBySubscription() - { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_listBySubscription.json - // this example is just showing the usage of "AutonomousDatabases_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AutonomousDatabaseResource item in subscriptionResource.GetAutonomousDatabasesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_AutonomousDatabasesGet() @@ -110,10 +78,10 @@ public async Task Get_GetAutonomousDatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAutonomousDatabase() + public async Task Delete_DeleteAutonomousDatabase() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_patch.json - // this example is just showing the usage of "AutonomousDatabases_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_delete.json + // this example is just showing the usage of "AutonomousDatabases_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,23 +97,17 @@ public async Task Update_PatchAutonomousDatabase() AutonomousDatabaseResource autonomousDatabase = client.GetAutonomousDatabaseResource(autonomousDatabaseResourceId); // invoke the operation - AutonomousDatabasePatch patch = new AutonomousDatabasePatch(); - ArmOperation lro = await autonomousDatabase.UpdateAsync(WaitUntil.Completed, patch); - AutonomousDatabaseResource result = lro.Value; + await autonomousDatabase.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutonomousDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAutonomousDatabase() + public async Task Update_PatchAutonomousDatabase() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_delete.json - // this example is just showing the usage of "AutonomousDatabases_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_patch.json + // this example is just showing the usage of "AutonomousDatabases_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -161,9 +123,15 @@ public async Task Delete_DeleteAutonomousDatabase() AutonomousDatabaseResource autonomousDatabase = client.GetAutonomousDatabaseResource(autonomousDatabaseResourceId); // invoke the operation - await autonomousDatabase.DeleteAsync(WaitUntil.Completed); + AutonomousDatabasePatch patch = new AutonomousDatabasePatch(); + ArmOperation lro = await autonomousDatabase.UpdateAsync(WaitUntil.Completed, patch); + AutonomousDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -187,7 +155,7 @@ public async Task Failover_AutonomousDatabasesFailover() AutonomousDatabaseResource autonomousDatabase = client.GetAutonomousDatabaseResource(autonomousDatabaseResourceId); // invoke the operation - AutonomousDatabaseActionContent content = new AutonomousDatabaseActionContent() + AutonomousDatabaseActionContent content = new AutonomousDatabaseActionContent { PeerDBId = "peerDbId", }; @@ -222,7 +190,7 @@ public async Task Failover_PerformFailoverActionOnAutonomousDatabase() AutonomousDatabaseResource autonomousDatabase = client.GetAutonomousDatabaseResource(autonomousDatabaseResourceId); // invoke the operation - AutonomousDatabaseActionContent content = new AutonomousDatabaseActionContent() + AutonomousDatabaseActionContent content = new AutonomousDatabaseActionContent { PeerDBId = "peerDbId", }; @@ -383,7 +351,7 @@ public async Task Switchover_AutonomousDatabasesSwitchover() AutonomousDatabaseResource autonomousDatabase = client.GetAutonomousDatabaseResource(autonomousDatabaseResourceId); // invoke the operation - AutonomousDatabaseActionContent content = new AutonomousDatabaseActionContent() + AutonomousDatabaseActionContent content = new AutonomousDatabaseActionContent { PeerDBId = "peerDbId", }; @@ -418,7 +386,7 @@ public async Task Switchover_PerformSwitchoverActionOnAutonomousDatabase() AutonomousDatabaseResource autonomousDatabase = client.GetAutonomousDatabaseResource(autonomousDatabaseResourceId); // invoke the operation - AutonomousDatabaseActionContent content = new AutonomousDatabaseActionContent() + AutonomousDatabaseActionContent content = new AutonomousDatabaseActionContent { PeerDBId = "peerDbId", }; diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudExadataInfrastructureCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudExadataInfrastructureCollection.cs index af79b632d3582..0b49b074b022b 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudExadataInfrastructureCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudExadataInfrastructureCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_CloudExadataInfrastructureCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExadataInfrastructureByResourceGroup() + public async Task CreateOrUpdate_CreateExadataInfrastructure() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_listByResourceGroup.json - // this example is just showing the usage of "CloudExadataInfrastructures_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_create.json + // this example is just showing the usage of "CloudExadataInfrastructures_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,28 @@ public async Task GetAll_ListExadataInfrastructureByResourceGroup() // get the collection of this CloudExadataInfrastructureResource CloudExadataInfrastructureCollection collection = resourceGroupResource.GetCloudExadataInfrastructures(); - // invoke the operation and iterate over the result - await foreach (CloudExadataInfrastructureResource item in collection.GetAllAsync()) + // invoke the operation + string cloudexadatainfrastructurename = "infra1"; + CloudExadataInfrastructureData data = new CloudExadataInfrastructureData(new AzureLocation("eastus"), new string[] { "1" }) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudExadataInfrastructureData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new CloudExadataInfrastructureProperties("EXADATA.X9M", "infra 1") + { + ComputeCount = 100, + StorageCount = 10, + }, + Tags = +{ +["tagK1"] = "tagV1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudexadatainfrastructurename, data); + CloudExadataInfrastructureResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudExadataInfrastructureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +98,10 @@ public async Task Get_GetExadataInfrastructure() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetExadataInfrastructure() + public async Task GetAll_ListExadataInfrastructureByResourceGroup() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_get.json - // this example is just showing the usage of "CloudExadataInfrastructures_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_listByResourceGroup.json + // this example is just showing the usage of "CloudExadataInfrastructures_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +118,22 @@ public async Task Exists_GetExadataInfrastructure() // get the collection of this CloudExadataInfrastructureResource CloudExadataInfrastructureCollection collection = resourceGroupResource.GetCloudExadataInfrastructures(); - // invoke the operation - string cloudexadatainfrastructurename = "infra1"; - bool result = await collection.ExistsAsync(cloudexadatainfrastructurename); + // invoke the operation and iterate over the result + await foreach (CloudExadataInfrastructureResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudExadataInfrastructureData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetExadataInfrastructure() + public async Task Exists_GetExadataInfrastructure() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_get.json // this example is just showing the usage of "CloudExadataInfrastructures_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +155,17 @@ public async Task GetIfExists_GetExadataInfrastructure() // invoke the operation string cloudexadatainfrastructurename = "infra1"; - NullableResponse response = await collection.GetIfExistsAsync(cloudexadatainfrastructurename); - CloudExadataInfrastructureResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(cloudexadatainfrastructurename); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudExadataInfrastructureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateExadataInfrastructure() + public async Task GetIfExists_GetExadataInfrastructure() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_create.json - // this example is just showing the usage of "CloudExadataInfrastructures_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_get.json + // this example is just showing the usage of "CloudExadataInfrastructures_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,29 +184,21 @@ public async Task CreateOrUpdate_CreateExadataInfrastructure() // invoke the operation string cloudexadatainfrastructurename = "infra1"; - CloudExadataInfrastructureData data = new CloudExadataInfrastructureData(new AzureLocation("eastus"), new string[] + NullableResponse response = await collection.GetIfExistsAsync(cloudexadatainfrastructurename); + CloudExadataInfrastructureResource result = response.HasValue ? response.Value : null; + + if (result == null) { -"1" - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Properties = new CloudExadataInfrastructureProperties("EXADATA.X9M", "infra 1") - { - ComputeCount = 100, - StorageCount = 10, - }, - Tags = -{ -["tagK1"] = "tagV1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudexadatainfrastructurename, data); - CloudExadataInfrastructureResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudExadataInfrastructureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudExadataInfrastructureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudExadataInfrastructureResource.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudExadataInfrastructureResource.cs index 094e44cf24d37..6d729811d7a64 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudExadataInfrastructureResource.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudExadataInfrastructureResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.OracleDatabase.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.OracleDatabase.Samples { public partial class Sample_CloudExadataInfrastructureResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCloudExadataInfrastructures_ListExadataInfrastructureBySubscription() - { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_listBySubscription.json - // this example is just showing the usage of "CloudExadataInfrastructures_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CloudExadataInfrastructureResource item in subscriptionResource.GetCloudExadataInfrastructuresAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudExadataInfrastructureData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetExadataInfrastructure() @@ -80,10 +48,10 @@ public async Task Get_GetExadataInfrastructure() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchExadataInfrastructure() + public async Task Delete_DeleteExadataInfrastructure() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_patch.json - // this example is just showing the usage of "CloudExadataInfrastructures_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_delete.json + // this example is just showing the usage of "CloudExadataInfrastructures_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,23 +67,17 @@ public async Task Update_PatchExadataInfrastructure() CloudExadataInfrastructureResource cloudExadataInfrastructure = client.GetCloudExadataInfrastructureResource(cloudExadataInfrastructureResourceId); // invoke the operation - CloudExadataInfrastructurePatch patch = new CloudExadataInfrastructurePatch(); - ArmOperation lro = await cloudExadataInfrastructure.UpdateAsync(WaitUntil.Completed, patch); - CloudExadataInfrastructureResource result = lro.Value; + await cloudExadataInfrastructure.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudExadataInfrastructureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteExadataInfrastructure() + public async Task Update_PatchExadataInfrastructure() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_delete.json - // this example is just showing the usage of "CloudExadataInfrastructures_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_patch.json + // this example is just showing the usage of "CloudExadataInfrastructures_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,9 +93,15 @@ public async Task Delete_DeleteExadataInfrastructure() CloudExadataInfrastructureResource cloudExadataInfrastructure = client.GetCloudExadataInfrastructureResource(cloudExadataInfrastructureResourceId); // invoke the operation - await cloudExadataInfrastructure.DeleteAsync(WaitUntil.Completed); + CloudExadataInfrastructurePatch patch = new CloudExadataInfrastructurePatch(); + ArmOperation lro = await cloudExadataInfrastructure.UpdateAsync(WaitUntil.Completed, patch); + CloudExadataInfrastructureResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudExadataInfrastructureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterCollection.cs index ec85b942f81d6..ecdf28d949a13 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_CloudVmClusterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVMClustersByResourceGroup() + public async Task CreateOrUpdate_CreateVMCluster() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_listByResourceGroup.json - // this example is just showing the usage of "CloudVmClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_create.json + // this example is just showing the usage of "CloudVmClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,59 @@ public async Task GetAll_ListVMClustersByResourceGroup() // get the collection of this CloudVmClusterResource CloudVmClusterCollection collection = resourceGroupResource.GetCloudVmClusters(); - // invoke the operation and iterate over the result - await foreach (CloudVmClusterResource item in collection.GetAllAsync()) + // invoke the operation + string cloudvmclustername = "cluster1"; + CloudVmClusterData data = new CloudVmClusterData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new CloudVmClusterProperties( + "hostname1", + 2, + new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Oracle.Database/cloudExadataInfrastructures/infra1"), + new string[] { "ssh-key 1" }, + new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1"), + "19.0.0.0", + new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), + "cluster 1") + { + DataStorageSizeInTbs = 1000, + DBNodeStorageSizeInGbs = 1000, + MemorySizeInGbs = 1000, + TimeZone = "UTC", + Domain = "domain1", + OcpuCount = 3, + ClusterName = "cluster1", + DataStoragePercentage = 100, + IsLocalBackupEnabled = false, + IsSparseDiskgroupEnabled = false, + LicenseModel = OracleLicenseModel.LicenseIncluded, + ScanListenerPortTcp = 1050, + ScanListenerPortTcpSsl = 1025, + BackupSubnetCidr = "172.17.5.0/24", + NsgCidrs = {new CloudVmClusterNsgCidr("10.0.0.0/16") +{ +DestinationPortRange = new CloudVmClusterPortRange(1520, 1522), +}, new CloudVmClusterNsgCidr("10.10.0.0/24")}, + DataCollectionOptions = new DiagnosticCollectionConfig + { + IsDiagnosticsEventsEnabled = false, + IsHealthMonitoringEnabled = false, + IsIncidentLogsEnabled = false, + }, + DBServers = { new ResourceIdentifier("ocid1..aaaa") }, + }, + Tags = +{ +["tagK1"] = "tagV1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudvmclustername, data); + CloudVmClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +129,10 @@ public async Task Get_GetVMCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVMCluster() + public async Task GetAll_ListVMClustersByResourceGroup() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_get.json - // this example is just showing the usage of "CloudVmClusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_listByResourceGroup.json + // this example is just showing the usage of "CloudVmClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +149,22 @@ public async Task Exists_GetVMCluster() // get the collection of this CloudVmClusterResource CloudVmClusterCollection collection = resourceGroupResource.GetCloudVmClusters(); - // invoke the operation - string cloudvmclustername = "cluster1"; - bool result = await collection.ExistsAsync(cloudvmclustername); + // invoke the operation and iterate over the result + await foreach (CloudVmClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVMCluster() + public async Task Exists_GetVMCluster() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_get.json // this example is just showing the usage of "CloudVmClusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +186,17 @@ public async Task GetIfExists_GetVMCluster() // invoke the operation string cloudvmclustername = "cluster1"; - NullableResponse response = await collection.GetIfExistsAsync(cloudvmclustername); - CloudVmClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(cloudvmclustername); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVMCluster() + public async Task GetIfExists_GetVMCluster() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_create.json - // this example is just showing the usage of "CloudVmClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_get.json + // this example is just showing the usage of "CloudVmClusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,58 +215,21 @@ public async Task CreateOrUpdate_CreateVMCluster() // invoke the operation string cloudvmclustername = "cluster1"; - CloudVmClusterData data = new CloudVmClusterData(new AzureLocation("eastus")) + NullableResponse response = await collection.GetIfExistsAsync(cloudvmclustername); + CloudVmClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Properties = new CloudVmClusterProperties("hostname1", 2, new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Oracle.Database/cloudExadataInfrastructures/infra1"), new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"ssh-key 1" - }, new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1"), "19.0.0.0", new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg000/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), "cluster 1") - { - DataStorageSizeInTbs = 1000, - DBNodeStorageSizeInGbs = 1000, - MemorySizeInGbs = 1000, - TimeZone = "UTC", - Domain = "domain1", - OcpuCount = 3, - ClusterName = "cluster1", - DataStoragePercentage = 100, - IsLocalBackupEnabled = false, - IsSparseDiskgroupEnabled = false, - LicenseModel = OracleLicenseModel.LicenseIncluded, - ScanListenerPortTcp = 1050, - ScanListenerPortTcpSsl = 1025, - BackupSubnetCidr = "172.17.5.0/24", - NsgCidrs = -{ -new CloudVmClusterNsgCidr("10.0.0.0/16") -{ -DestinationPortRange = new CloudVmClusterPortRange(1520,1522), -},new CloudVmClusterNsgCidr("10.10.0.0/24") -}, - DataCollectionOptions = new DiagnosticCollectionConfig() - { - IsDiagnosticsEventsEnabled = false, - IsHealthMonitoringEnabled = false, - IsIncidentLogsEnabled = false, - }, - DBServers = -{ -new ResourceIdentifier("ocid1..aaaa") -}, - }, - Tags = -{ -["tagK1"] = "tagV1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudvmclustername, data); - CloudVmClusterResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterDBNodeCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterDBNodeCollection.cs index a1f1c1dd4b085..e5e5c24a0e90c 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterDBNodeCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterDBNodeCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CloudVmClusterDBNodeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDbNodesByVMCluster() + public async Task Get_GetDbNode() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbNodes_listByParent.json - // this example is just showing the usage of "DbNodes_ListByCloudVmCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbNodes_get.json + // this example is just showing the usage of "DbNodes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListDbNodesByVMCluster() // get the collection of this CloudVmClusterDBNodeResource CloudVmClusterDBNodeCollection collection = cloudVmCluster.GetCloudVmClusterDBNodes(); - // invoke the operation and iterate over the result - await foreach (CloudVmClusterDBNodeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterDBNodeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string dbnodeocid = "ocid1....aaaaaa"; + CloudVmClusterDBNodeResource result = await collection.GetAsync(dbnodeocid); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterDBNodeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDbNode() + public async Task GetAll_ListDbNodesByVMCluster() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbNodes_get.json - // this example is just showing the usage of "DbNodes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbNodes_listByParent.json + // this example is just showing the usage of "DbNodes_ListByCloudVmCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetDbNode() // get the collection of this CloudVmClusterDBNodeResource CloudVmClusterDBNodeCollection collection = cloudVmCluster.GetCloudVmClusterDBNodes(); - // invoke the operation - string dbnodeocid = "ocid1....aaaaaa"; - CloudVmClusterDBNodeResource result = await collection.GetAsync(dbnodeocid); + // invoke the operation and iterate over the result + await foreach (CloudVmClusterDBNodeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterDBNodeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterDBNodeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterResource.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterResource.cs index 5ff530a6f22d5..607731f20e289 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterResource.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.OracleDatabase.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.OracleDatabase.Samples { public partial class Sample_CloudVmClusterResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCloudVmClusters_ListVMClustersBySubscription() - { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_listBySubscription.json - // this example is just showing the usage of "CloudVmClusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CloudVmClusterResource item in subscriptionResource.GetCloudVmClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetVMCluster() @@ -80,10 +48,10 @@ public async Task Get_GetVMCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchVMCluster() + public async Task Delete_DeleteVMCluster() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_patch.json - // this example is just showing the usage of "CloudVmClusters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_delete.json + // this example is just showing the usage of "CloudVmClusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,23 +67,17 @@ public async Task Update_PatchVMCluster() CloudVmClusterResource cloudVmCluster = client.GetCloudVmClusterResource(cloudVmClusterResourceId); // invoke the operation - CloudVmClusterPatch patch = new CloudVmClusterPatch(); - ArmOperation lro = await cloudVmCluster.UpdateAsync(WaitUntil.Completed, patch); - CloudVmClusterResource result = lro.Value; + await cloudVmCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVMCluster() + public async Task Update_PatchVMCluster() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_delete.json - // this example is just showing the usage of "CloudVmClusters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_patch.json + // this example is just showing the usage of "CloudVmClusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,9 +93,15 @@ public async Task Delete_DeleteVMCluster() CloudVmClusterResource cloudVmCluster = client.GetCloudVmClusterResource(cloudVmClusterResourceId); // invoke the operation - await cloudVmCluster.DeleteAsync(WaitUntil.Completed); + CloudVmClusterPatch patch = new CloudVmClusterPatch(); + ArmOperation lro = await cloudVmCluster.UpdateAsync(WaitUntil.Completed, patch); + CloudVmClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -157,10 +125,7 @@ public async Task AddVms_AddVMsToVMCluster() CloudVmClusterResource cloudVmCluster = client.GetCloudVmClusterResource(cloudVmClusterResourceId); // invoke the operation - CloudVmClusterDBNodeContent content = new CloudVmClusterDBNodeContent(new ResourceIdentifier[] - { -new ResourceIdentifier("ocid1..aaaa"),new ResourceIdentifier("ocid1..aaaaaa") - }); + CloudVmClusterDBNodeContent content = new CloudVmClusterDBNodeContent(new ResourceIdentifier[] { new ResourceIdentifier("ocid1..aaaa"), new ResourceIdentifier("ocid1..aaaaaa") }); ArmOperation lro = await cloudVmCluster.AddVmsAsync(WaitUntil.Completed, content); CloudVmClusterResource result = lro.Value; @@ -222,10 +187,7 @@ public async Task RemoveVms_RemoveVMsFromVMCluster() CloudVmClusterResource cloudVmCluster = client.GetCloudVmClusterResource(cloudVmClusterResourceId); // invoke the operation - CloudVmClusterDBNodeContent content = new CloudVmClusterDBNodeContent(new ResourceIdentifier[] - { -new ResourceIdentifier("ocid1..aaaa") - }); + CloudVmClusterDBNodeContent content = new CloudVmClusterDBNodeContent(new ResourceIdentifier[] { new ResourceIdentifier("ocid1..aaaa") }); ArmOperation lro = await cloudVmCluster.RemoveVmsAsync(WaitUntil.Completed, content); CloudVmClusterResource result = lro.Value; diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterVirtualNetworkAddressCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterVirtualNetworkAddressCollection.cs index 78eeaf7500cbf..181e2a5cfa369 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterVirtualNetworkAddressCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterVirtualNetworkAddressCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CloudVmClusterVirtualNetworkAddressCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworkAddressesByVMCluster() + public async Task CreateOrUpdate_CreateVirtualNetworkAddress() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_listByParent.json - // this example is just showing the usage of "VirtualNetworkAddresses_ListByCloudVmCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_create.json + // this example is just showing the usage of "VirtualNetworkAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_ListVirtualNetworkAddressesByVMCluster() // get the collection of this CloudVmClusterVirtualNetworkAddressResource CloudVmClusterVirtualNetworkAddressCollection collection = cloudVmCluster.GetCloudVmClusterVirtualNetworkAddresses(); - // invoke the operation and iterate over the result - await foreach (CloudVmClusterVirtualNetworkAddressResource item in collection.GetAllAsync()) + // invoke the operation + string virtualnetworkaddressname = "hostname1"; + CloudVmClusterVirtualNetworkAddressData data = new CloudVmClusterVirtualNetworkAddressData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterVirtualNetworkAddressData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new CloudVmClusterVirtualNetworkAddressProperties + { + IPAddress = "192.168.0.1", + VmOcid = new ResourceIdentifier("ocid1..aaaa"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualnetworkaddressname, data); + CloudVmClusterVirtualNetworkAddressResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterVirtualNetworkAddressData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_GetVirtualNetworkAddress() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetworkAddress() + public async Task GetAll_ListVirtualNetworkAddressesByVMCluster() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_get.json - // this example is just showing the usage of "VirtualNetworkAddresses_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_listByParent.json + // this example is just showing the usage of "VirtualNetworkAddresses_ListByCloudVmCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_GetVirtualNetworkAddress() // get the collection of this CloudVmClusterVirtualNetworkAddressResource CloudVmClusterVirtualNetworkAddressCollection collection = cloudVmCluster.GetCloudVmClusterVirtualNetworkAddresses(); - // invoke the operation - string virtualnetworkaddressname = "hostname1"; - bool result = await collection.ExistsAsync(virtualnetworkaddressname); + // invoke the operation and iterate over the result + await foreach (CloudVmClusterVirtualNetworkAddressResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterVirtualNetworkAddressData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetworkAddress() + public async Task Exists_GetVirtualNetworkAddress() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_get.json // this example is just showing the usage of "VirtualNetworkAddresses_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_GetVirtualNetworkAddress() // invoke the operation string virtualnetworkaddressname = "hostname1"; - NullableResponse response = await collection.GetIfExistsAsync(virtualnetworkaddressname); - CloudVmClusterVirtualNetworkAddressResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(virtualnetworkaddressname); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterVirtualNetworkAddressData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkAddress() + public async Task GetIfExists_GetVirtualNetworkAddress() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_create.json - // this example is just showing the usage of "VirtualNetworkAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_get.json + // this example is just showing the usage of "VirtualNetworkAddresses_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_CreateVirtualNetworkAddress() // invoke the operation string virtualnetworkaddressname = "hostname1"; - CloudVmClusterVirtualNetworkAddressData data = new CloudVmClusterVirtualNetworkAddressData() - { - Properties = new CloudVmClusterVirtualNetworkAddressProperties() - { - IPAddress = "192.168.0.1", - VmOcid = new ResourceIdentifier("ocid1..aaaa"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualnetworkaddressname, data); - CloudVmClusterVirtualNetworkAddressResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(virtualnetworkaddressname); + CloudVmClusterVirtualNetworkAddressResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterVirtualNetworkAddressData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterVirtualNetworkAddressData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterVirtualNetworkAddressResource.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterVirtualNetworkAddressResource.cs index f65280cd8e0ce..9a1722e7c9027 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterVirtualNetworkAddressResource.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_CloudVmClusterVirtualNetworkAddressResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetVirtualNetworkAddress() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateVirtualNetworkAddress() + public async Task Delete_DeleteVirtualNetworkAddress() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_create.json - // this example is just showing the usage of "VirtualNetworkAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_delete.json + // this example is just showing the usage of "VirtualNetworkAddresses_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_CreateVirtualNetworkAddress() CloudVmClusterVirtualNetworkAddressResource cloudVmClusterVirtualNetworkAddress = client.GetCloudVmClusterVirtualNetworkAddressResource(cloudVmClusterVirtualNetworkAddressResourceId); // invoke the operation - CloudVmClusterVirtualNetworkAddressData data = new CloudVmClusterVirtualNetworkAddressData() - { - Properties = new CloudVmClusterVirtualNetworkAddressProperties() - { - IPAddress = "192.168.0.1", - VmOcid = new ResourceIdentifier("ocid1..aaaa"), - }, - }; - ArmOperation lro = await cloudVmClusterVirtualNetworkAddress.UpdateAsync(WaitUntil.Completed, data); - CloudVmClusterVirtualNetworkAddressResource result = lro.Value; + await cloudVmClusterVirtualNetworkAddress.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudVmClusterVirtualNetworkAddressData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualNetworkAddress() + public async Task Update_CreateVirtualNetworkAddress() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_delete.json - // this example is just showing the usage of "VirtualNetworkAddresses_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/virtualNetworkAddresses_create.json + // this example is just showing the usage of "VirtualNetworkAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_DeleteVirtualNetworkAddress() CloudVmClusterVirtualNetworkAddressResource cloudVmClusterVirtualNetworkAddress = client.GetCloudVmClusterVirtualNetworkAddressResource(cloudVmClusterVirtualNetworkAddressResourceId); // invoke the operation - await cloudVmClusterVirtualNetworkAddress.DeleteAsync(WaitUntil.Completed); + CloudVmClusterVirtualNetworkAddressData data = new CloudVmClusterVirtualNetworkAddressData + { + Properties = new CloudVmClusterVirtualNetworkAddressProperties + { + IPAddress = "192.168.0.1", + VmOcid = new ResourceIdentifier("ocid1..aaaa"), + }, + }; + ArmOperation lro = await cloudVmClusterVirtualNetworkAddress.UpdateAsync(WaitUntil.Completed, data); + CloudVmClusterVirtualNetworkAddressResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterVirtualNetworkAddressData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDBServerCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDBServerCollection.cs index 0cf6913f905ac..9117d4574f23e 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDBServerCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDBServerCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_OracleDBServerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDbServersByExadataInfrastructure() + public async Task Get_GetDbServerByParent() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbServers_listByParent.json - // this example is just showing the usage of "DbServers_ListByCloudExadataInfrastructure" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbServers_get.json + // this example is just showing the usage of "DbServers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListDbServersByExadataInfrastructure() // get the collection of this OracleDBServerResource OracleDBServerCollection collection = cloudExadataInfrastructure.GetOracleDBServers(); - // invoke the operation and iterate over the result - await foreach (OracleDBServerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleDBServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string dbserverocid = "ocid1....aaaaaa"; + OracleDBServerResource result = await collection.GetAsync(dbserverocid); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleDBServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDbServerByParent() + public async Task GetAll_ListDbServersByExadataInfrastructure() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbServers_get.json - // this example is just showing the usage of "DbServers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbServers_listByParent.json + // this example is just showing the usage of "DbServers_ListByCloudExadataInfrastructure" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetDbServerByParent() // get the collection of this OracleDBServerResource OracleDBServerCollection collection = cloudExadataInfrastructure.GetOracleDBServers(); - // invoke the operation - string dbserverocid = "ocid1....aaaaaa"; - OracleDBServerResource result = await collection.GetAsync(dbserverocid); + // invoke the operation and iterate over the result + await foreach (OracleDBServerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleDBServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleDBServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDBSystemShapeCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDBSystemShapeCollection.cs index 4d09b62541f66..877072caccda1 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDBSystemShapeCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDBSystemShapeCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_OracleDBSystemShapeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDbSystemShapesByLocation() + public async Task Get_GetADbSystemShapeByName() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbSystemShapes_listByLocation.json - // this example is just showing the usage of "DbSystemShapes_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbSystemShapes_get.json + // this example is just showing the usage of "DbSystemShapes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListDbSystemShapesByLocation() AzureLocation location = new AzureLocation("eastus"); OracleDBSystemShapeCollection collection = subscriptionResource.GetOracleDBSystemShapes(location); - // invoke the operation and iterate over the result - await foreach (OracleDBSystemShapeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleDBSystemShapeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string dbsystemshapename = "EXADATA.X9M"; + OracleDBSystemShapeResource result = await collection.GetAsync(dbsystemshapename); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleDBSystemShapeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADbSystemShapeByName() + public async Task GetAll_ListDbSystemShapesByLocation() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbSystemShapes_get.json - // this example is just showing the usage of "DbSystemShapes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dbSystemShapes_listByLocation.json + // this example is just showing the usage of "DbSystemShapes_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetADbSystemShapeByName() AzureLocation location = new AzureLocation("eastus"); OracleDBSystemShapeCollection collection = subscriptionResource.GetOracleDBSystemShapes(location); - // invoke the operation - string dbsystemshapename = "EXADATA.X9M"; - OracleDBSystemShapeResource result = await collection.GetAsync(dbsystemshapename); + // invoke the operation and iterate over the result + await foreach (OracleDBSystemShapeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleDBSystemShapeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleDBSystemShapeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDnsPrivateViewCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDnsPrivateViewCollection.cs index e363813bdf9b6..fa29a753d3f19 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDnsPrivateViewCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDnsPrivateViewCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_OracleDnsPrivateViewCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDnsPrivateViewsByLocation() + public async Task Get_GetADnsPrivateViewByName() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dnsPrivateViews_listByLocation.json - // this example is just showing the usage of "DnsPrivateViews_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dnsPrivateViews_get.json + // this example is just showing the usage of "DnsPrivateViews_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListDnsPrivateViewsByLocation() AzureLocation location = new AzureLocation("eastus"); OracleDnsPrivateViewCollection collection = subscriptionResource.GetOracleDnsPrivateViews(location); - // invoke the operation and iterate over the result - await foreach (OracleDnsPrivateViewResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleDnsPrivateViewData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string dnsprivateviewocid = "ocid1....aaaaaa"; + OracleDnsPrivateViewResource result = await collection.GetAsync(dnsprivateviewocid); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleDnsPrivateViewData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADnsPrivateViewByName() + public async Task GetAll_ListDnsPrivateViewsByLocation() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dnsPrivateViews_get.json - // this example is just showing the usage of "DnsPrivateViews_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dnsPrivateViews_listByLocation.json + // this example is just showing the usage of "DnsPrivateViews_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetADnsPrivateViewByName() AzureLocation location = new AzureLocation("eastus"); OracleDnsPrivateViewCollection collection = subscriptionResource.GetOracleDnsPrivateViews(location); - // invoke the operation - string dnsprivateviewocid = "ocid1....aaaaaa"; - OracleDnsPrivateViewResource result = await collection.GetAsync(dnsprivateviewocid); + // invoke the operation and iterate over the result + await foreach (OracleDnsPrivateViewResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleDnsPrivateViewData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleDnsPrivateViewData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDnsPrivateZoneCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDnsPrivateZoneCollection.cs index f4dead2b04c34..930b452fb00ae 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDnsPrivateZoneCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleDnsPrivateZoneCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_OracleDnsPrivateZoneCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDnsPrivateZonesByLocation() + public async Task Get_GetADnsPrivateZoneByName() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dnsPrivateZones_listByLocation.json - // this example is just showing the usage of "DnsPrivateZones_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dnsPrivateZones_get.json + // this example is just showing the usage of "DnsPrivateZones_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListDnsPrivateZonesByLocation() AzureLocation location = new AzureLocation("eastus"); OracleDnsPrivateZoneCollection collection = subscriptionResource.GetOracleDnsPrivateZones(location); - // invoke the operation and iterate over the result - await foreach (OracleDnsPrivateZoneResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleDnsPrivateZoneData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string dnsprivatezonename = "example-dns-private-zone"; + OracleDnsPrivateZoneResource result = await collection.GetAsync(dnsprivatezonename); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleDnsPrivateZoneData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADnsPrivateZoneByName() + public async Task GetAll_ListDnsPrivateZonesByLocation() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dnsPrivateZones_get.json - // this example is just showing the usage of "DnsPrivateZones_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/dnsPrivateZones_listByLocation.json + // this example is just showing the usage of "DnsPrivateZones_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetADnsPrivateZoneByName() AzureLocation location = new AzureLocation("eastus"); OracleDnsPrivateZoneCollection collection = subscriptionResource.GetOracleDnsPrivateZones(location); - // invoke the operation - string dnsprivatezonename = "example-dns-private-zone"; - OracleDnsPrivateZoneResource result = await collection.GetAsync(dnsprivatezonename); + // invoke the operation and iterate over the result + await foreach (OracleDnsPrivateZoneResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleDnsPrivateZoneData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleDnsPrivateZoneData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleGIVersionCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleGIVersionCollection.cs index e64d6e1320b92..fd8eb969d731e 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleGIVersionCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleGIVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_OracleGIVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGiVersionsByLocation() + public async Task Get_GetAGiVersionByName() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/giVersions_listByLocation.json - // this example is just showing the usage of "GiVersions_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/giVersions_get.json + // this example is just showing the usage of "GiVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListGiVersionsByLocation() AzureLocation location = new AzureLocation("eastus"); OracleGIVersionCollection collection = subscriptionResource.GetOracleGIVersions(location); - // invoke the operation and iterate over the result - await foreach (OracleGIVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleGIVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string giversionname = "19.0.0.0"; + OracleGIVersionResource result = await collection.GetAsync(giversionname); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleGIVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGiVersionByName() + public async Task GetAll_ListGiVersionsByLocation() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/giVersions_get.json - // this example is just showing the usage of "GiVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/giVersions_listByLocation.json + // this example is just showing the usage of "GiVersions_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetAGiVersionByName() AzureLocation location = new AzureLocation("eastus"); OracleGIVersionCollection collection = subscriptionResource.GetOracleGIVersions(location); - // invoke the operation - string giversionname = "19.0.0.0"; - OracleGIVersionResource result = await collection.GetAsync(giversionname); + // invoke the operation and iterate over the result + await foreach (OracleGIVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleGIVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleGIVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleSubscriptionResource.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleSubscriptionResource.cs index c24d95d60fef1..60bc41c70b99f 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleSubscriptionResource.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleSubscriptionResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetOracleSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateOracleSubscription() + public async Task Delete_DeleteOracleSubscription() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/oracleSubscriptions_create.json - // this example is just showing the usage of "OracleSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/oracleSubscriptions_delete.json + // this example is just showing the usage of "OracleSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,23 +64,9 @@ public async Task CreateOrUpdate_CreateOrUpdateOracleSubscription() OracleSubscriptionResource oracleSubscription = client.GetOracleSubscriptionResource(oracleSubscriptionResourceId); // invoke the operation - OracleSubscriptionData data = new OracleSubscriptionData() - { - Properties = new OracleSubscriptionProperties(), - Plan = new ArmPlan("plan1", "publisher1", "product1") - { - PromotionCode = "none", - Version = "alpha", - }, - }; - ArmOperation lro = await oracleSubscription.CreateOrUpdateAsync(WaitUntil.Completed, data); - OracleSubscriptionResource result = lro.Value; + await oracleSubscription.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -115,10 +101,10 @@ public async Task Update_PatchOracleSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteOracleSubscription() + public async Task CreateOrUpdate_CreateOrUpdateOracleSubscription() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/oracleSubscriptions_delete.json - // this example is just showing the usage of "OracleSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/oracleSubscriptions_create.json + // this example is just showing the usage of "OracleSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,9 +118,23 @@ public async Task Delete_DeleteOracleSubscription() OracleSubscriptionResource oracleSubscription = client.GetOracleSubscriptionResource(oracleSubscriptionResourceId); // invoke the operation - await oracleSubscription.DeleteAsync(WaitUntil.Completed); + OracleSubscriptionData data = new OracleSubscriptionData + { + Properties = new OracleSubscriptionProperties(), + Plan = new ArmPlan("plan1", "publisher1", "product1") + { + PromotionCode = "none", + Version = "alpha", + }, + }; + ArmOperation lro = await oracleSubscription.CreateOrUpdateAsync(WaitUntil.Completed, data); + OracleSubscriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleSystemVersionCollection.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleSystemVersionCollection.cs index b8d91f8bd4f0d..60f08ead9fd3d 100644 --- a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleSystemVersionCollection.cs +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_OracleSystemVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_OracleSystemVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExadataSystemVersionsByTheProvidedFilter() + public async Task Get_GetExadataSystemVersion() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_listByLocation.json - // this example is just showing the usage of "SystemVersions_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_get.json + // this example is just showing the usage of "SystemVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListExadataSystemVersionsByTheProvidedFilter() AzureLocation location = new AzureLocation("eastus"); OracleSystemVersionCollection collection = subscriptionResource.GetOracleSystemVersions(location); - // invoke the operation and iterate over the result - await foreach (OracleSystemVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleSystemVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string systemversionname = "22.x"; + OracleSystemVersionResource result = await collection.GetAsync(systemversionname); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleSystemVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SystemVersionsListByLocation() + public async Task Get_SystemVersionsListSystemVersions() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_listByLocation.json - // this example is just showing the usage of "SystemVersions_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_get.json + // this example is just showing the usage of "SystemVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,25 +71,23 @@ public async Task GetAll_SystemVersionsListByLocation() AzureLocation location = new AzureLocation("eastus"); OracleSystemVersionCollection collection = subscriptionResource.GetOracleSystemVersions(location); - // invoke the operation and iterate over the result - await foreach (OracleSystemVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleSystemVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string systemversionname = "22.x"; + OracleSystemVersionResource result = await collection.GetAsync(systemversionname); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleSystemVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExadataSystemVersion() + public async Task GetAll_ListExadataSystemVersionsByTheProvidedFilter() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_get.json - // this example is just showing the usage of "SystemVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_listByLocation.json + // this example is just showing the usage of "SystemVersions_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,23 +104,25 @@ public async Task Get_GetExadataSystemVersion() AzureLocation location = new AzureLocation("eastus"); OracleSystemVersionCollection collection = subscriptionResource.GetOracleSystemVersions(location); - // invoke the operation - string systemversionname = "22.x"; - OracleSystemVersionResource result = await collection.GetAsync(systemversionname); + // invoke the operation and iterate over the result + await foreach (OracleSystemVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleSystemVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleSystemVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetExadataSystemVersion() + public async Task GetAll_SystemVersionsListByLocation() { - // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_get.json - // this example is just showing the usage of "SystemVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_listByLocation.json + // this example is just showing the usage of "SystemVersions_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,16 +139,22 @@ public async Task Exists_GetExadataSystemVersion() AzureLocation location = new AzureLocation("eastus"); OracleSystemVersionCollection collection = subscriptionResource.GetOracleSystemVersions(location); - // invoke the operation - string systemversionname = "22.x"; - bool result = await collection.ExistsAsync(systemversionname); + // invoke the operation and iterate over the result + await foreach (OracleSystemVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleSystemVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetExadataSystemVersion() + public async Task Exists_GetExadataSystemVersion() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_get.json // this example is just showing the usage of "SystemVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -172,26 +176,14 @@ public async Task GetIfExists_GetExadataSystemVersion() // invoke the operation string systemversionname = "22.x"; - NullableResponse response = await collection.GetIfExistsAsync(systemversionname); - OracleSystemVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(systemversionname); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleSystemVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SystemVersionsListSystemVersions() + public async Task Exists_SystemVersionsListSystemVersions() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_get.json // this example is just showing the usage of "SystemVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -213,18 +205,14 @@ public async Task Get_SystemVersionsListSystemVersions() // invoke the operation string systemversionname = "22.x"; - OracleSystemVersionResource result = await collection.GetAsync(systemversionname); + bool result = await collection.ExistsAsync(systemversionname); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OracleSystemVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SystemVersionsListSystemVersions() + public async Task GetIfExists_GetExadataSystemVersion() { // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/systemVersions_get.json // this example is just showing the usage of "SystemVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -246,9 +234,21 @@ public async Task Exists_SystemVersionsListSystemVersions() // invoke the operation string systemversionname = "22.x"; - bool result = await collection.ExistsAsync(systemversionname); + NullableResponse response = await collection.GetIfExistsAsync(systemversionname); + OracleSystemVersionResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OracleSystemVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..1db88b434f91f --- /dev/null +++ b/sdk/oracle/Azure.ResourceManager.OracleDatabase/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.OracleDatabase.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAutonomousDatabases_ListAutonomousDatabaseBySubscription() + { + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/autonomousDatabase_listBySubscription.json + // this example is just showing the usage of "AutonomousDatabases_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AutonomousDatabaseResource item in subscriptionResource.GetAutonomousDatabasesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutonomousDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCloudExadataInfrastructures_ListExadataInfrastructureBySubscription() + { + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/exaInfra_listBySubscription.json + // this example is just showing the usage of "CloudExadataInfrastructures_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CloudExadataInfrastructureResource item in subscriptionResource.GetCloudExadataInfrastructuresAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudExadataInfrastructureData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCloudVmClusters_ListVMClustersBySubscription() + { + // Generated from example definition: specification/oracle/resource-manager/Oracle.Database/stable/2023-09-01/examples/vmClusters_listBySubscription.json + // this example is just showing the usage of "CloudVmClusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CloudVmClusterResource item in subscriptionResource.GetCloudVmClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudVmClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_AvailableGroundStationCollection.cs b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_AvailableGroundStationCollection.cs index e885f38402445..792320e17fd6f 100644 --- a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_AvailableGroundStationCollection.cs +++ b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_AvailableGroundStationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AvailableGroundStationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfGroundStationsByCapability() + public async Task Get_GetGroundStation() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/AvailableGroundStationsByCapabilityList.json - // this example is just showing the usage of "AvailableGroundStations_ListByCapability" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/AvailableGroundStationGet.json + // this example is just showing the usage of "AvailableGroundStations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,26 +38,23 @@ public async Task GetAll_ListOfGroundStationsByCapability() // get the collection of this AvailableGroundStationResource AvailableGroundStationCollection collection = subscriptionResource.GetAvailableGroundStations(); - // invoke the operation and iterate over the result - GroundStationCapability capability = GroundStationCapability.EarthObservation; - await foreach (AvailableGroundStationResource item in collection.GetAllAsync(capability)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvailableGroundStationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groundStationName = "EASTUS2_0"; + AvailableGroundStationResource result = await collection.GetAsync(groundStationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvailableGroundStationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetGroundStation() + public async Task GetAll_ListOfGroundStationsByCapability() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/AvailableGroundStationGet.json - // this example is just showing the usage of "AvailableGroundStations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/AvailableGroundStationsByCapabilityList.json + // this example is just showing the usage of "AvailableGroundStations_ListByCapability" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +70,18 @@ public async Task Get_GetGroundStation() // get the collection of this AvailableGroundStationResource AvailableGroundStationCollection collection = subscriptionResource.GetAvailableGroundStations(); - // invoke the operation - string groundStationName = "EASTUS2_0"; - AvailableGroundStationResource result = await collection.GetAsync(groundStationName); + // invoke the operation and iterate over the result + GroundStationCapability capability = GroundStationCapability.EarthObservation; + await foreach (AvailableGroundStationResource item in collection.GetAllAsync(capability)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvailableGroundStationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvailableGroundStationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactCollection.cs b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactCollection.cs index ccaa17b78a1a8..64ced90b97969 100644 --- a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactCollection.cs +++ b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_OrbitalContactCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfSpacecraft() + public async Task CreateOrUpdate_CreateAContact() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactsBySpacecraftNameList.json - // this example is just showing the usage of "Contacts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactCreate.json + // this example is just showing the usage of "Contacts_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,23 @@ public async Task GetAll_ListOfSpacecraft() // get the collection of this OrbitalContactResource OrbitalContactCollection collection = orbitalSpacecraft.GetOrbitalContacts(); - // invoke the operation and iterate over the result - await foreach (OrbitalContactResource item in collection.GetAllAsync()) + // invoke the operation + string contactName = "contact1"; + OrbitalContactData data = new OrbitalContactData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OrbitalContactData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ReservationStartOn = DateTimeOffset.Parse("2022-03-02T10:58:30Z"), + ReservationEndOn = DateTimeOffset.Parse("2022-03-02T11:10:45Z"), + GroundStationName = "EASTUS2_0", + ContactProfileId = new ResourceIdentifier("/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Orbital/contactProfiles/CONTOSO-CP"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contactName, data); + OrbitalContactResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OrbitalContactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +93,10 @@ public async Task Get_GetContact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetContact() + public async Task GetAll_ListOfSpacecraft() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactGet.json - // this example is just showing the usage of "Contacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactsBySpacecraftNameList.json + // this example is just showing the usage of "Contacts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +114,22 @@ public async Task Exists_GetContact() // get the collection of this OrbitalContactResource OrbitalContactCollection collection = orbitalSpacecraft.GetOrbitalContacts(); - // invoke the operation - string contactName = "contact1"; - bool result = await collection.ExistsAsync(contactName); + // invoke the operation and iterate over the result + await foreach (OrbitalContactResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OrbitalContactData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetContact() + public async Task Exists_GetContact() { // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactGet.json // this example is just showing the usage of "Contacts_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +152,17 @@ public async Task GetIfExists_GetContact() // invoke the operation string contactName = "contact1"; - NullableResponse response = await collection.GetIfExistsAsync(contactName); - OrbitalContactResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(contactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OrbitalContactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAContact() + public async Task GetIfExists_GetContact() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactCreate.json - // this example is just showing the usage of "Contacts_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactGet.json + // this example is just showing the usage of "Contacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,21 +182,21 @@ public async Task CreateOrUpdate_CreateAContact() // invoke the operation string contactName = "contact1"; - OrbitalContactData data = new OrbitalContactData() - { - ReservationStartOn = DateTimeOffset.Parse("2022-03-02T10:58:30Z"), - ReservationEndOn = DateTimeOffset.Parse("2022-03-02T11:10:45Z"), - GroundStationName = "EASTUS2_0", - ContactProfileId = new ResourceIdentifier("/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Orbital/contactProfiles/CONTOSO-CP"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contactName, data); - OrbitalContactResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(contactName); + OrbitalContactResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OrbitalContactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OrbitalContactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactProfileCollection.cs b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactProfileCollection.cs index e96d6d11dd499..b3a78ee825029 100644 --- a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactProfileCollection.cs +++ b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactProfileCollection.cs @@ -21,10 +21,10 @@ public partial class Sample_OrbitalContactProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAContactProfile() + public async Task CreateOrUpdate_CreateAContactProfile() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfileGet.json - // this example is just showing the usage of "ContactProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfileCreate.json + // this example is just showing the usage of "ContactProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,7 +43,31 @@ public async Task Get_GetAContactProfile() // invoke the operation string contactProfileName = "CONTOSO-CP"; - OrbitalContactProfileResource result = await collection.GetAsync(contactProfileName); + OrbitalContactProfileData data = new OrbitalContactProfileData(new AzureLocation("eastus2")) + { + MinimumViableContactDuration = XmlConvert.ToTimeSpan("PT1M"), + MinimumElevationDegrees = 5, + AutoTrackingConfiguration = AutoTrackingConfiguration.Disabled, + EventHubUri = new Uri("/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.EventHub/namespaces/contosoHub/eventhubs/contosoHub"), + NetworkSubnetId = new ResourceIdentifier("/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Network/virtualNetworks/contoso-vnet/subnets/orbital-delegated-subnet"), + Links = {new OrbitalContactProfileLink("contoso-uplink", OrbitalLinkPolarization.Lhcp, OrbitalLinkDirection.Uplink, new OrbitalContactProfileLinkChannel[] +{ +new OrbitalContactProfileLinkChannel("contoso-uplink-channel", 2250, 2, new OrbitalContactEndpoint(IPAddress.Parse("10.1.0.4"), "ContosoTest_Uplink", "50000", OrbitalContactProtocol.Tcp)) +}) +{ +GainOverTemperature = 0, +EirpdBW = 45, +}, new OrbitalContactProfileLink("contoso-downlink", OrbitalLinkPolarization.Rhcp, OrbitalLinkDirection.Downlink, new OrbitalContactProfileLinkChannel[] +{ +new OrbitalContactProfileLinkChannel("contoso-downlink-channel", 8160, 15, new OrbitalContactEndpoint(IPAddress.Parse("10.1.0.5"), "ContosoTest_Downlink", "50001", OrbitalContactProtocol.Udp)) +}) +{ +GainOverTemperature = 25, +EirpdBW = 0, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contactProfileName, data); + OrbitalContactProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,7 +78,7 @@ public async Task Get_GetAContactProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAContactProfile() + public async Task Get_GetAContactProfile() { // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfileGet.json // this example is just showing the usage of "ContactProfiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +100,21 @@ public async Task Exists_GetAContactProfile() // invoke the operation string contactProfileName = "CONTOSO-CP"; - bool result = await collection.ExistsAsync(contactProfileName); + OrbitalContactProfileResource result = await collection.GetAsync(contactProfileName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OrbitalContactProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAContactProfile() + public async Task GetAll_ListOfContactProfilesByResourceGroup() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfileGet.json - // this example is just showing the usage of "ContactProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfilesByResourceGroupList.json + // this example is just showing the usage of "ContactProfiles_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +131,25 @@ public async Task GetIfExists_GetAContactProfile() // get the collection of this OrbitalContactProfileResource OrbitalContactProfileCollection collection = resourceGroupResource.GetOrbitalContactProfiles(); - // invoke the operation - string contactProfileName = "CONTOSO-CP"; - NullableResponse response = await collection.GetIfExistsAsync(contactProfileName); - OrbitalContactProfileResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (OrbitalContactProfileResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - OrbitalContactProfileData resourceData = result.Data; + OrbitalContactProfileData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAContactProfile() + public async Task Exists_GetAContactProfile() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfileCreate.json - // this example is just showing the usage of "ContactProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfileGet.json + // this example is just showing the usage of "ContactProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,48 +168,17 @@ public async Task CreateOrUpdate_CreateAContactProfile() // invoke the operation string contactProfileName = "CONTOSO-CP"; - OrbitalContactProfileData data = new OrbitalContactProfileData(new AzureLocation("eastus2")) - { - MinimumViableContactDuration = XmlConvert.ToTimeSpan("PT1M"), - MinimumElevationDegrees = 5, - AutoTrackingConfiguration = AutoTrackingConfiguration.Disabled, - EventHubUri = new Uri("/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.EventHub/namespaces/contosoHub/eventhubs/contosoHub"), - NetworkSubnetId = new ResourceIdentifier("/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Network/virtualNetworks/contoso-vnet/subnets/orbital-delegated-subnet"), - Links = -{ -new OrbitalContactProfileLink("contoso-uplink",OrbitalLinkPolarization.Lhcp,OrbitalLinkDirection.Uplink,new OrbitalContactProfileLinkChannel[] -{ -new OrbitalContactProfileLinkChannel("contoso-uplink-channel",2250,2,new OrbitalContactEndpoint(IPAddress.Parse("10.1.0.4"),"ContosoTest_Uplink","50000",OrbitalContactProtocol.Tcp)) -}) -{ -GainOverTemperature = 0, -EirpdBW = 45, -},new OrbitalContactProfileLink("contoso-downlink",OrbitalLinkPolarization.Rhcp,OrbitalLinkDirection.Downlink,new OrbitalContactProfileLinkChannel[] -{ -new OrbitalContactProfileLinkChannel("contoso-downlink-channel",8160,15,new OrbitalContactEndpoint(IPAddress.Parse("10.1.0.5"),"ContosoTest_Downlink","50001",OrbitalContactProtocol.Udp)) -}) -{ -GainOverTemperature = 25, -EirpdBW = 0, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contactProfileName, data); - OrbitalContactProfileResource result = lro.Value; + bool result = await collection.ExistsAsync(contactProfileName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OrbitalContactProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfContactProfilesByResourceGroup() + public async Task GetIfExists_GetAContactProfile() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfilesByResourceGroupList.json - // this example is just showing the usage of "ContactProfiles_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfileGet.json + // this example is just showing the usage of "ContactProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,17 +195,23 @@ public async Task GetAll_ListOfContactProfilesByResourceGroup() // get the collection of this OrbitalContactProfileResource OrbitalContactProfileCollection collection = resourceGroupResource.GetOrbitalContactProfiles(); - // invoke the operation and iterate over the result - await foreach (OrbitalContactProfileResource item in collection.GetAllAsync()) + // invoke the operation + string contactProfileName = "CONTOSO-CP"; + NullableResponse response = await collection.GetIfExistsAsync(contactProfileName); + OrbitalContactProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - OrbitalContactProfileData resourceData = item.Data; + OrbitalContactProfileData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactProfileResource.cs b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactProfileResource.cs index f5ffc69c834a6..30be244f4cb8f 100644 --- a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactProfileResource.cs +++ b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactProfileResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Orbital.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Orbital.Samples @@ -94,12 +93,12 @@ public async Task Update_UpdateContactProfileTags() OrbitalContactProfileResource orbitalContactProfile = client.GetOrbitalContactProfileResource(orbitalContactProfileResourceId); // invoke the operation - OrbitalSpacecraftTags orbitalSpacecraftTags = new OrbitalSpacecraftTags() + OrbitalSpacecraftTags orbitalSpacecraftTags = new OrbitalSpacecraftTags { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await orbitalContactProfile.UpdateAsync(WaitUntil.Completed, orbitalSpacecraftTags); @@ -111,36 +110,5 @@ public async Task Update_UpdateContactProfileTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetOrbitalContactProfiles_ListOfContactProfiles() - { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfilesBySubscriptionList.json - // this example is just showing the usage of "ContactProfiles_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "c1be1141-a7c9-4aac-9608-3c2e2f1152c3"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (OrbitalContactProfileResource item in subscriptionResource.GetOrbitalContactProfilesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OrbitalContactProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactResource.cs b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactResource.cs index 9537346e28858..1e4470d2281d4 100644 --- a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactResource.cs +++ b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalContactResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetContact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAContact() + public async Task Delete_DeleteContact() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactCreate.json - // this example is just showing the usage of "Contacts_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactDelete.json + // this example is just showing the usage of "Contacts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +68,17 @@ public async Task Update_CreateAContact() OrbitalContactResource orbitalContact = client.GetOrbitalContactResource(orbitalContactResourceId); // invoke the operation - OrbitalContactData data = new OrbitalContactData() - { - ReservationStartOn = DateTimeOffset.Parse("2022-03-02T10:58:30Z"), - ReservationEndOn = DateTimeOffset.Parse("2022-03-02T11:10:45Z"), - GroundStationName = "EASTUS2_0", - ContactProfileId = new ResourceIdentifier("/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Orbital/contactProfiles/CONTOSO-CP"), - }; - ArmOperation lro = await orbitalContact.UpdateAsync(WaitUntil.Completed, data); - OrbitalContactResource result = lro.Value; + await orbitalContact.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OrbitalContactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteContact() + public async Task Update_CreateAContact() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactDelete.json - // this example is just showing the usage of "Contacts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactCreate.json + // this example is just showing the usage of "Contacts_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +95,21 @@ public async Task Delete_DeleteContact() OrbitalContactResource orbitalContact = client.GetOrbitalContactResource(orbitalContactResourceId); // invoke the operation - await orbitalContact.DeleteAsync(WaitUntil.Completed); + OrbitalContactData data = new OrbitalContactData + { + ReservationStartOn = DateTimeOffset.Parse("2022-03-02T10:58:30Z"), + ReservationEndOn = DateTimeOffset.Parse("2022-03-02T11:10:45Z"), + GroundStationName = "EASTUS2_0", + ContactProfileId = new ResourceIdentifier("/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Orbital/contactProfiles/CONTOSO-CP"), + }; + ArmOperation lro = await orbitalContact.UpdateAsync(WaitUntil.Completed, data); + OrbitalContactResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OrbitalContactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalSpacecraftCollection.cs b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalSpacecraftCollection.cs index 324e3018c578b..b6be595e4ac50 100644 --- a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalSpacecraftCollection.cs +++ b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalSpacecraftCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_OrbitalSpacecraftCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfSpacecraftByResourceGroup() + public async Task CreateOrUpdate_CreateASpacecraft() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/SpacecraftsByResourceGroupList.json - // this example is just showing the usage of "Spacecrafts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/SpacecraftCreate.json + // this example is just showing the usage of "Spacecrafts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_ListOfSpacecraftByResourceGroup() // get the collection of this OrbitalSpacecraftResource OrbitalSpacecraftCollection collection = resourceGroupResource.GetOrbitalSpacecrafts(); - // invoke the operation and iterate over the result - await foreach (OrbitalSpacecraftResource item in collection.GetAllAsync()) + // invoke the operation + string spacecraftName = "CONTOSO_SAT"; + OrbitalSpacecraftData data = new OrbitalSpacecraftData(new AzureLocation("eastus2")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OrbitalSpacecraftData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + NoradId = "36411", + TitleLine = "CONTOSO_SAT", + TleLine1 = "1 27424U 02022A 22167.05119303 .00000638 00000+0 15103-3 0 9994", + TleLine2 = "2 27424 98.2477 108.9546 0000928 92.9194 327.0802 14.57300770 69982", + Links = { new OrbitalSpacecraftLink("uplink_lhcp1", 2250, 2, OrbitalLinkDirection.Uplink, OrbitalLinkPolarization.Lhcp), new OrbitalSpacecraftLink("downlink_rhcp1", 8160, 15, OrbitalLinkDirection.Downlink, OrbitalLinkPolarization.Rhcp) }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, spacecraftName, data); + OrbitalSpacecraftResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OrbitalSpacecraftData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +94,10 @@ public async Task Get_GetSpacecraft() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSpacecraft() + public async Task GetAll_ListOfSpacecraftByResourceGroup() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/SpacecraftGet.json - // this example is just showing the usage of "Spacecrafts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/SpacecraftsByResourceGroupList.json + // this example is just showing the usage of "Spacecrafts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +114,22 @@ public async Task Exists_GetSpacecraft() // get the collection of this OrbitalSpacecraftResource OrbitalSpacecraftCollection collection = resourceGroupResource.GetOrbitalSpacecrafts(); - // invoke the operation - string spacecraftName = "CONTOSO_SAT"; - bool result = await collection.ExistsAsync(spacecraftName); + // invoke the operation and iterate over the result + await foreach (OrbitalSpacecraftResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OrbitalSpacecraftData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSpacecraft() + public async Task Exists_GetSpacecraft() { // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/SpacecraftGet.json // this example is just showing the usage of "Spacecrafts_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +151,17 @@ public async Task GetIfExists_GetSpacecraft() // invoke the operation string spacecraftName = "CONTOSO_SAT"; - NullableResponse response = await collection.GetIfExistsAsync(spacecraftName); - OrbitalSpacecraftResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(spacecraftName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OrbitalSpacecraftData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASpacecraft() + public async Task GetIfExists_GetSpacecraft() { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/SpacecraftCreate.json - // this example is just showing the usage of "Spacecrafts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/SpacecraftGet.json + // this example is just showing the usage of "Spacecrafts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,25 +180,21 @@ public async Task CreateOrUpdate_CreateASpacecraft() // invoke the operation string spacecraftName = "CONTOSO_SAT"; - OrbitalSpacecraftData data = new OrbitalSpacecraftData(new AzureLocation("eastus2")) - { - NoradId = "36411", - TitleLine = "CONTOSO_SAT", - TleLine1 = "1 27424U 02022A 22167.05119303 .00000638 00000+0 15103-3 0 9994", - TleLine2 = "2 27424 98.2477 108.9546 0000928 92.9194 327.0802 14.57300770 69982", - Links = -{ -new OrbitalSpacecraftLink("uplink_lhcp1",2250,2,OrbitalLinkDirection.Uplink,OrbitalLinkPolarization.Lhcp),new OrbitalSpacecraftLink("downlink_rhcp1",8160,15,OrbitalLinkDirection.Downlink,OrbitalLinkPolarization.Rhcp) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, spacecraftName, data); - OrbitalSpacecraftResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(spacecraftName); + OrbitalSpacecraftResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OrbitalSpacecraftData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OrbitalSpacecraftData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalSpacecraftResource.cs b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalSpacecraftResource.cs index 27e384942bd83..fab43c5623a2d 100644 --- a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalSpacecraftResource.cs +++ b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_OrbitalSpacecraftResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Orbital.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using NUnit.Framework; @@ -18,37 +17,6 @@ namespace Azure.ResourceManager.Orbital.Samples { public partial class Sample_OrbitalSpacecraftResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetOrbitalSpacecrafts_ListOfSpacecraftBySubscription() - { - // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/SpacecraftsBySubscriptionList.json - // this example is just showing the usage of "Spacecrafts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "c1be1141-a7c9-4aac-9608-3c2e2f1152c3"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (OrbitalSpacecraftResource item in subscriptionResource.GetOrbitalSpacecraftsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OrbitalSpacecraftData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetSpacecraft() @@ -126,12 +94,12 @@ public async Task Update_UpdateSpacecraftTags() OrbitalSpacecraftResource orbitalSpacecraft = client.GetOrbitalSpacecraftResource(orbitalSpacecraftResourceId); // invoke the operation - OrbitalSpacecraftTags orbitalSpacecraftTags = new OrbitalSpacecraftTags() + OrbitalSpacecraftTags orbitalSpacecraftTags = new OrbitalSpacecraftTags { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await orbitalSpacecraft.UpdateAsync(WaitUntil.Completed, orbitalSpacecraftTags); @@ -165,7 +133,7 @@ public async Task GetAllAvailableContacts_ListOfContact() OrbitalSpacecraftResource orbitalSpacecraft = client.GetOrbitalSpacecraftResource(orbitalSpacecraftResourceId); // invoke the operation - OrbitalAvailableContactsContent content = new OrbitalAvailableContactsContent(new WritableSubResource() + OrbitalAvailableContactsContent content = new OrbitalAvailableContactsContent(new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/c1be1141-a7c9-4aac-9608-3c2e2f1152c3/resourceGroups/contoso-Rgp/providers/Microsoft.Orbital/contactProfiles/CONTOSO-CP"), }, "EASTUS2_0", DateTimeOffset.Parse("2022-03-01T11:30:00Z"), DateTimeOffset.Parse("2022-03-02T11:30:00Z")); diff --git a/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..1ddec88f19d7f --- /dev/null +++ b/sdk/orbital/Azure.ResourceManager.Orbital/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Orbital.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetOrbitalSpacecrafts_ListOfSpacecraftBySubscription() + { + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/SpacecraftsBySubscriptionList.json + // this example is just showing the usage of "Spacecrafts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "c1be1141-a7c9-4aac-9608-3c2e2f1152c3"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (OrbitalSpacecraftResource item in subscriptionResource.GetOrbitalSpacecraftsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OrbitalSpacecraftData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetOrbitalContactProfiles_ListOfContactProfiles() + { + // Generated from example definition: specification/orbital/resource-manager/Microsoft.Orbital/stable/2022-03-01/examples/ContactProfilesBySubscriptionList.json + // this example is just showing the usage of "ContactProfiles_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "c1be1141-a7c9-4aac-9608-3c2e2f1152c3"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (OrbitalContactProfileResource item in subscriptionResource.GetOrbitalContactProfilesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OrbitalContactProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCertificateObjectCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCertificateObjectCollection.cs index f22c61d61d4f8..a1af066bde495 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCertificateObjectCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCertificateObjectCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_GlobalRulestackCertificateObjectCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CertificateObjectGlobalRulestackListMaximumSetGen() + public async Task CreateOrUpdate_CertificateObjectGlobalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_List_MaximumSet_Gen.json - // this example is just showing the usage of "CertificateObjectGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "CertificateObjectGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,31 @@ public async Task GetAll_CertificateObjectGlobalRulestackListMaximumSetGen() // get the collection of this GlobalRulestackCertificateObjectResource GlobalRulestackCertificateObjectCollection collection = globalRulestack.GetGlobalRulestackCertificateObjects(); - // invoke the operation and iterate over the result - await foreach (GlobalRulestackCertificateObjectResource item in collection.GetAllAsync()) + // invoke the operation + string name = "armid1"; + GlobalRulestackCertificateObjectData data = new GlobalRulestackCertificateObjectData(FirewallBooleanType.True) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackCertificateObjectData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CertificateSignerResourceId = "", + AuditComment = "comment", + Description = "description", + ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + GlobalRulestackCertificateObjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CertificateObjectGlobalRulestackListMinimumSetGen() + public async Task CreateOrUpdate_CertificateObjectGlobalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_List_MinimumSet_Gen.json - // this example is just showing the usage of "CertificateObjectGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "CertificateObjectGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,17 +77,17 @@ public async Task GetAll_CertificateObjectGlobalRulestackListMinimumSetGen() // get the collection of this GlobalRulestackCertificateObjectResource GlobalRulestackCertificateObjectCollection collection = globalRulestack.GetGlobalRulestackCertificateObjects(); - // invoke the operation and iterate over the result - await foreach (GlobalRulestackCertificateObjectResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackCertificateObjectData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "armid1"; + GlobalRulestackCertificateObjectData data = new GlobalRulestackCertificateObjectData(FirewallBooleanType.True); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + GlobalRulestackCertificateObjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -118,9 +124,9 @@ public async Task Get_CertificateObjectGlobalRulestackGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CertificateObjectGlobalRulestackGetMaximumSetGen() + public async Task Get_CertificateObjectGlobalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "CertificateObjectGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -139,17 +145,21 @@ public async Task Exists_CertificateObjectGlobalRulestackGetMaximumSetGen() // invoke the operation string name = "armid1"; - bool result = await collection.ExistsAsync(name); + GlobalRulestackCertificateObjectResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CertificateObjectGlobalRulestackGetMaximumSetGen() + public async Task GetAll_CertificateObjectGlobalRulestackListMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Get_MaximumSet_Gen.json - // this example is just showing the usage of "CertificateObjectGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_List_MaximumSet_Gen.json + // this example is just showing the usage of "CertificateObjectGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,31 +175,25 @@ public async Task GetIfExists_CertificateObjectGlobalRulestackGetMaximumSetGen() // get the collection of this GlobalRulestackCertificateObjectResource GlobalRulestackCertificateObjectCollection collection = globalRulestack.GetGlobalRulestackCertificateObjects(); - // invoke the operation - string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - GlobalRulestackCertificateObjectResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (GlobalRulestackCertificateObjectResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GlobalRulestackCertificateObjectData resourceData = result.Data; + GlobalRulestackCertificateObjectData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CertificateObjectGlobalRulestackGetMinimumSetGen() + public async Task GetAll_CertificateObjectGlobalRulestackListMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Get_MinimumSet_Gen.json - // this example is just showing the usage of "CertificateObjectGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_List_MinimumSet_Gen.json + // this example is just showing the usage of "CertificateObjectGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -205,22 +209,24 @@ public async Task Get_CertificateObjectGlobalRulestackGetMinimumSetGen() // get the collection of this GlobalRulestackCertificateObjectResource GlobalRulestackCertificateObjectCollection collection = globalRulestack.GetGlobalRulestackCertificateObjects(); - // invoke the operation - string name = "armid1"; - GlobalRulestackCertificateObjectResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (GlobalRulestackCertificateObjectResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackCertificateObjectData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CertificateObjectGlobalRulestackGetMinimumSetGen() + public async Task Exists_CertificateObjectGlobalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Get_MaximumSet_Gen.json // this example is just showing the usage of "CertificateObjectGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -246,7 +252,7 @@ public async Task Exists_CertificateObjectGlobalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CertificateObjectGlobalRulestackGetMinimumSetGen() + public async Task Exists_CertificateObjectGlobalRulestackGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "CertificateObjectGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. @@ -267,29 +273,17 @@ public async Task GetIfExists_CertificateObjectGlobalRulestackGetMinimumSetGen() // invoke the operation string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - GlobalRulestackCertificateObjectResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CertificateObjectGlobalRulestackCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_CertificateObjectGlobalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "CertificateObjectGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Get_MaximumSet_Gen.json + // this example is just showing the usage of "CertificateObjectGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -307,29 +301,29 @@ public async Task CreateOrUpdate_CertificateObjectGlobalRulestackCreateOrUpdateM // invoke the operation string name = "armid1"; - GlobalRulestackCertificateObjectData data = new GlobalRulestackCertificateObjectData(FirewallBooleanType.True) - { - CertificateSignerResourceId = "", - AuditComment = "comment", - Description = "description", - ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - GlobalRulestackCertificateObjectResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + GlobalRulestackCertificateObjectResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CertificateObjectGlobalRulestackCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_CertificateObjectGlobalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "CertificateObjectGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Get_MinimumSet_Gen.json + // this example is just showing the usage of "CertificateObjectGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -347,15 +341,21 @@ public async Task CreateOrUpdate_CertificateObjectGlobalRulestackCreateOrUpdateM // invoke the operation string name = "armid1"; - GlobalRulestackCertificateObjectData data = new GlobalRulestackCertificateObjectData(FirewallBooleanType.True); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - GlobalRulestackCertificateObjectResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + GlobalRulestackCertificateObjectResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCertificateObjectResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCertificateObjectResource.cs index 85c08e6b27016..58bf31705ce1e 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCertificateObjectResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCertificateObjectResource.cs @@ -76,10 +76,10 @@ public async Task Get_CertificateObjectGlobalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CertificateObjectGlobalRulestackCreateOrUpdateMaximumSetGen() + public async Task Delete_CertificateObjectGlobalRulestackDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "CertificateObjectGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "CertificateObjectGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,29 +94,17 @@ public async Task Update_CertificateObjectGlobalRulestackCreateOrUpdateMaximumSe GlobalRulestackCertificateObjectResource globalRulestackCertificateObject = client.GetGlobalRulestackCertificateObjectResource(globalRulestackCertificateObjectResourceId); // invoke the operation - GlobalRulestackCertificateObjectData data = new GlobalRulestackCertificateObjectData(FirewallBooleanType.True) - { - CertificateSignerResourceId = "", - AuditComment = "comment", - Description = "description", - ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), - }; - ArmOperation lro = await globalRulestackCertificateObject.UpdateAsync(WaitUntil.Completed, data); - GlobalRulestackCertificateObjectResource result = lro.Value; + await globalRulestackCertificateObject.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CertificateObjectGlobalRulestackCreateOrUpdateMinimumSetGen() + public async Task Delete_CertificateObjectGlobalRulestackDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "CertificateObjectGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "CertificateObjectGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,23 +119,17 @@ public async Task Update_CertificateObjectGlobalRulestackCreateOrUpdateMinimumSe GlobalRulestackCertificateObjectResource globalRulestackCertificateObject = client.GetGlobalRulestackCertificateObjectResource(globalRulestackCertificateObjectResourceId); // invoke the operation - GlobalRulestackCertificateObjectData data = new GlobalRulestackCertificateObjectData(FirewallBooleanType.True); - ArmOperation lro = await globalRulestackCertificateObject.UpdateAsync(WaitUntil.Completed, data); - GlobalRulestackCertificateObjectResource result = lro.Value; + await globalRulestackCertificateObject.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CertificateObjectGlobalRulestackDeleteMaximumSetGen() + public async Task Update_CertificateObjectGlobalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "CertificateObjectGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "CertificateObjectGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -162,17 +144,29 @@ public async Task Delete_CertificateObjectGlobalRulestackDeleteMaximumSetGen() GlobalRulestackCertificateObjectResource globalRulestackCertificateObject = client.GetGlobalRulestackCertificateObjectResource(globalRulestackCertificateObjectResourceId); // invoke the operation - await globalRulestackCertificateObject.DeleteAsync(WaitUntil.Completed); + GlobalRulestackCertificateObjectData data = new GlobalRulestackCertificateObjectData(FirewallBooleanType.True) + { + CertificateSignerResourceId = "", + AuditComment = "comment", + Description = "description", + ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), + }; + ArmOperation lro = await globalRulestackCertificateObject.UpdateAsync(WaitUntil.Completed, data); + GlobalRulestackCertificateObjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CertificateObjectGlobalRulestackDeleteMinimumSetGen() + public async Task Update_CertificateObjectGlobalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "CertificateObjectGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "CertificateObjectGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,9 +181,15 @@ public async Task Delete_CertificateObjectGlobalRulestackDeleteMinimumSetGen() GlobalRulestackCertificateObjectResource globalRulestackCertificateObject = client.GetGlobalRulestackCertificateObjectResource(globalRulestackCertificateObjectResourceId); // invoke the operation - await globalRulestackCertificateObject.DeleteAsync(WaitUntil.Completed); + GlobalRulestackCertificateObjectData data = new GlobalRulestackCertificateObjectData(FirewallBooleanType.True); + ArmOperation lro = await globalRulestackCertificateObject.UpdateAsync(WaitUntil.Completed, data); + GlobalRulestackCertificateObjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCollection.cs index 49d6785dc7118..6065a3b42e96a 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackCollection.cs @@ -11,6 +11,7 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.PaloAltoNetworks.Ngfw.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.PaloAltoNetworks.Ngfw.Samples @@ -19,66 +20,89 @@ public partial class Sample_GlobalRulestackCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GlobalRulestackListMaximumSetGen() + public async Task CreateOrUpdate_GlobalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_List_MaximumSet_Gen.json - // this example is just showing the usage of "GlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "GlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this GlobalRulestackResource GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); - // invoke the operation and iterate over the result - await foreach (GlobalRulestackResource item in collection.GetAllAsync()) + // invoke the operation + string globalRulestackName = "praval"; + GlobalRulestackData data = new GlobalRulestackData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("key16")] = new UserAssignedIdentity() +}, + }, + PanETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c12"), + PanLocation = new AzureLocation("eastus"), + Scope = RulestackScopeType.Global, + AssociatedSubscriptions = { "2bf4a339-294d-4c25-b0b2-ef649e9f5c27" }, + Description = "global rulestacks", + DefaultMode = RuleCreationDefaultMode.IPS, + MinAppIdVersion = "8.5.3", + SecurityServices = new RulestackSecurityServices + { + VulnerabilityProfile = "default", + AntiSpywareProfile = "default", + AntiVirusProfile = "default", + UrlFilteringProfile = "default", + FileBlockingProfile = "default", + DnsSubscription = "default", + OutboundUnTrustCertificate = "default", + OutboundTrustCertificate = "default", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, globalRulestackName, data); + GlobalRulestackResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GlobalRulestackListMinimumSetGen() + public async Task CreateOrUpdate_GlobalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_List_MinimumSet_Gen.json - // this example is just showing the usage of "GlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "GlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this GlobalRulestackResource GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); - // invoke the operation and iterate over the result - await foreach (GlobalRulestackResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string globalRulestackName = "praval"; + GlobalRulestackData data = new GlobalRulestackData(new AzureLocation("eastus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, globalRulestackName, data); + GlobalRulestackResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -93,9 +117,7 @@ public async Task Get_GlobalRulestackGetMaximumSetGen() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this GlobalRulestackResource GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); @@ -113,9 +135,9 @@ public async Task Get_GlobalRulestackGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GlobalRulestackGetMaximumSetGen() + public async Task Get_GlobalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "GlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -123,63 +145,87 @@ public async Task Exists_GlobalRulestackGetMaximumSetGen() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this GlobalRulestackResource GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); // invoke the operation string globalRulestackName = "praval"; - bool result = await collection.ExistsAsync(globalRulestackName); + GlobalRulestackResource result = await collection.GetAsync(globalRulestackName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GlobalRulestackGetMaximumSetGen() + public async Task GetAll_GlobalRulestackListMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Get_MaximumSet_Gen.json - // this example is just showing the usage of "GlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_List_MaximumSet_Gen.json + // this example is just showing the usage of "GlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this GlobalRulestackResource GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); - // invoke the operation - string globalRulestackName = "praval"; - NullableResponse response = await collection.GetIfExistsAsync(globalRulestackName); - GlobalRulestackResource result = response.HasValue ? response.Value : null; - - if (result == null) + // invoke the operation and iterate over the result + await foreach (GlobalRulestackResource item in collection.GetAllAsync()) { - Console.WriteLine("Succeeded with null as result"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - else + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GlobalRulestackListMinimumSetGen() + { + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_List_MinimumSet_Gen.json + // this example is just showing the usage of "GlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this GlobalRulestackResource + GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); + + // invoke the operation and iterate over the result + await foreach (GlobalRulestackResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GlobalRulestackData resourceData = result.Data; + GlobalRulestackData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GlobalRulestackGetMinimumSetGen() + public async Task Exists_GlobalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Get_MaximumSet_Gen.json // this example is just showing the usage of "GlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -187,22 +233,16 @@ public async Task Get_GlobalRulestackGetMinimumSetGen() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this GlobalRulestackResource GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); // invoke the operation string globalRulestackName = "praval"; - GlobalRulestackResource result = await collection.GetAsync(globalRulestackName); + bool result = await collection.ExistsAsync(globalRulestackName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -217,9 +257,7 @@ public async Task Exists_GlobalRulestackGetMinimumSetGen() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this GlobalRulestackResource GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); @@ -233,9 +271,9 @@ public async Task Exists_GlobalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GlobalRulestackGetMinimumSetGen() + public async Task GetIfExists_GlobalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Get_MaximumSet_Gen.json // this example is just showing the usage of "GlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -243,9 +281,7 @@ public async Task GetIfExists_GlobalRulestackGetMinimumSetGen() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this GlobalRulestackResource GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); @@ -271,96 +307,38 @@ public async Task GetIfExists_GlobalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GlobalRulestackCreateOrUpdateMaximumSetGen() - { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "GlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this GlobalRulestackResource - GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); - - // invoke the operation - string globalRulestackName = "praval"; - GlobalRulestackData data = new GlobalRulestackData(new AzureLocation("eastus")) - { - Identity = new ManagedServiceIdentity("None") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("key16")] = new UserAssignedIdentity(), -}, - }, - PanETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c12"), - PanLocation = new AzureLocation("eastus"), - Scope = RulestackScopeType.Global, - AssociatedSubscriptions = -{ -"2bf4a339-294d-4c25-b0b2-ef649e9f5c27" -}, - Description = "global rulestacks", - DefaultMode = RuleCreationDefaultMode.IPS, - MinAppIdVersion = "8.5.3", - SecurityServices = new RulestackSecurityServices() - { - VulnerabilityProfile = "default", - AntiSpywareProfile = "default", - AntiVirusProfile = "default", - UrlFilteringProfile = "default", - FileBlockingProfile = "default", - DnsSubscription = "default", - OutboundUnTrustCertificate = "default", - OutboundTrustCertificate = "default", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, globalRulestackName, data); - GlobalRulestackResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GlobalRulestackCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_GlobalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "GlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Get_MinimumSet_Gen.json + // this example is just showing the usage of "GlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this GlobalRulestackResource GlobalRulestackCollection collection = tenantResource.GetGlobalRulestacks(); // invoke the operation string globalRulestackName = "praval"; - GlobalRulestackData data = new GlobalRulestackData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, globalRulestackName, data); - GlobalRulestackResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(globalRulestackName); + GlobalRulestackResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackFqdnCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackFqdnCollection.cs index 46972781b734d..2375471ab0e01 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackFqdnCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackFqdnCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_GlobalRulestackFqdnCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FqdnListGlobalRulestackListMaximumSetGen() + public async Task CreateOrUpdate_FqdnListGlobalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_List_MaximumSet_Gen.json - // this example is just showing the usage of "FqdnListGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "FqdnListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,25 +36,30 @@ public async Task GetAll_FqdnListGlobalRulestackListMaximumSetGen() // get the collection of this GlobalRulestackFqdnResource GlobalRulestackFqdnCollection collection = globalRulestack.GetGlobalRulestackFqdns(); - // invoke the operation and iterate over the result - await foreach (GlobalRulestackFqdnResource item in collection.GetAllAsync()) + // invoke the operation + string name = "armid1"; + GlobalRulestackFqdnData data = new GlobalRulestackFqdnData(new string[] { "string1", "string2" }) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackFqdnData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + ETag = new ETag("aaaaaaaaaaaaaaaaaa"), + AuditComment = "string", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + GlobalRulestackFqdnResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FqdnListGlobalRulestackListMinimumSetGen() + public async Task CreateOrUpdate_FqdnListGlobalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_List_MinimumSet_Gen.json - // this example is just showing the usage of "FqdnListGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "FqdnListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,17 +75,17 @@ public async Task GetAll_FqdnListGlobalRulestackListMinimumSetGen() // get the collection of this GlobalRulestackFqdnResource GlobalRulestackFqdnCollection collection = globalRulestack.GetGlobalRulestackFqdns(); - // invoke the operation and iterate over the result - await foreach (GlobalRulestackFqdnResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackFqdnData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "armid1"; + GlobalRulestackFqdnData data = new GlobalRulestackFqdnData(new string[] { "string1", "string2" }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + GlobalRulestackFqdnResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -117,9 +122,9 @@ public async Task Get_FqdnListGlobalRulestackGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FqdnListGlobalRulestackGetMaximumSetGen() + public async Task Get_FqdnListGlobalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "FqdnListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -138,17 +143,21 @@ public async Task Exists_FqdnListGlobalRulestackGetMaximumSetGen() // invoke the operation string name = "armid1"; - bool result = await collection.ExistsAsync(name); + GlobalRulestackFqdnResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FqdnListGlobalRulestackGetMaximumSetGen() + public async Task GetAll_FqdnListGlobalRulestackListMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Get_MaximumSet_Gen.json - // this example is just showing the usage of "FqdnListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_List_MaximumSet_Gen.json + // this example is just showing the usage of "FqdnListGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -164,31 +173,25 @@ public async Task GetIfExists_FqdnListGlobalRulestackGetMaximumSetGen() // get the collection of this GlobalRulestackFqdnResource GlobalRulestackFqdnCollection collection = globalRulestack.GetGlobalRulestackFqdns(); - // invoke the operation - string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - GlobalRulestackFqdnResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (GlobalRulestackFqdnResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GlobalRulestackFqdnData resourceData = result.Data; + GlobalRulestackFqdnData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FqdnListGlobalRulestackGetMinimumSetGen() + public async Task GetAll_FqdnListGlobalRulestackListMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Get_MinimumSet_Gen.json - // this example is just showing the usage of "FqdnListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_List_MinimumSet_Gen.json + // this example is just showing the usage of "FqdnListGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,22 +207,24 @@ public async Task Get_FqdnListGlobalRulestackGetMinimumSetGen() // get the collection of this GlobalRulestackFqdnResource GlobalRulestackFqdnCollection collection = globalRulestack.GetGlobalRulestackFqdns(); - // invoke the operation - string name = "armid1"; - GlobalRulestackFqdnResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (GlobalRulestackFqdnResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackFqdnData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FqdnListGlobalRulestackGetMinimumSetGen() + public async Task Exists_FqdnListGlobalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Get_MaximumSet_Gen.json // this example is just showing the usage of "FqdnListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -245,7 +250,7 @@ public async Task Exists_FqdnListGlobalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FqdnListGlobalRulestackGetMinimumSetGen() + public async Task Exists_FqdnListGlobalRulestackGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "FqdnListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. @@ -266,29 +271,17 @@ public async Task GetIfExists_FqdnListGlobalRulestackGetMinimumSetGen() // invoke the operation string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - GlobalRulestackFqdnResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FqdnListGlobalRulestackCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_FqdnListGlobalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "FqdnListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Get_MaximumSet_Gen.json + // this example is just showing the usage of "FqdnListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -306,31 +299,29 @@ public async Task CreateOrUpdate_FqdnListGlobalRulestackCreateOrUpdateMaximumSet // invoke the operation string name = "armid1"; - GlobalRulestackFqdnData data = new GlobalRulestackFqdnData(new string[] + NullableResponse response = await collection.GetIfExistsAsync(name); + GlobalRulestackFqdnResource result = response.HasValue ? response.Value : null; + + if (result == null) { -"string1","string2" - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "string", - ETag = new ETag("aaaaaaaaaaaaaaaaaa"), - AuditComment = "string", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - GlobalRulestackFqdnResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FqdnListGlobalRulestackCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_FqdnListGlobalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "FqdnListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Get_MinimumSet_Gen.json + // this example is just showing the usage of "FqdnListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -348,18 +339,21 @@ public async Task CreateOrUpdate_FqdnListGlobalRulestackCreateOrUpdateMinimumSet // invoke the operation string name = "armid1"; - GlobalRulestackFqdnData data = new GlobalRulestackFqdnData(new string[] - { -"string1","string2" - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - GlobalRulestackFqdnResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + GlobalRulestackFqdnResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackFqdnResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackFqdnResource.cs index 0b37b509125bf..7628971688739 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackFqdnResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackFqdnResource.cs @@ -75,10 +75,10 @@ public async Task Get_FqdnListGlobalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FqdnListGlobalRulestackCreateOrUpdateMaximumSetGen() + public async Task Delete_FqdnListGlobalRulestackDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "FqdnListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "FqdnListGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,31 +93,17 @@ public async Task Update_FqdnListGlobalRulestackCreateOrUpdateMaximumSetGen() GlobalRulestackFqdnResource globalRulestackFqdn = client.GetGlobalRulestackFqdnResource(globalRulestackFqdnResourceId); // invoke the operation - GlobalRulestackFqdnData data = new GlobalRulestackFqdnData(new string[] - { -"string1","string2" - }) - { - Description = "string", - ETag = new ETag("aaaaaaaaaaaaaaaaaa"), - AuditComment = "string", - }; - ArmOperation lro = await globalRulestackFqdn.UpdateAsync(WaitUntil.Completed, data); - GlobalRulestackFqdnResource result = lro.Value; + await globalRulestackFqdn.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FqdnListGlobalRulestackCreateOrUpdateMinimumSetGen() + public async Task Delete_FqdnListGlobalRulestackDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "FqdnListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "FqdnListGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,26 +118,17 @@ public async Task Update_FqdnListGlobalRulestackCreateOrUpdateMinimumSetGen() GlobalRulestackFqdnResource globalRulestackFqdn = client.GetGlobalRulestackFqdnResource(globalRulestackFqdnResourceId); // invoke the operation - GlobalRulestackFqdnData data = new GlobalRulestackFqdnData(new string[] - { -"string1","string2" - }); - ArmOperation lro = await globalRulestackFqdn.UpdateAsync(WaitUntil.Completed, data); - GlobalRulestackFqdnResource result = lro.Value; + await globalRulestackFqdn.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_FqdnListGlobalRulestackDeleteMaximumSetGen() + public async Task Update_FqdnListGlobalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "FqdnListGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "FqdnListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -166,17 +143,28 @@ public async Task Delete_FqdnListGlobalRulestackDeleteMaximumSetGen() GlobalRulestackFqdnResource globalRulestackFqdn = client.GetGlobalRulestackFqdnResource(globalRulestackFqdnResourceId); // invoke the operation - await globalRulestackFqdn.DeleteAsync(WaitUntil.Completed); + GlobalRulestackFqdnData data = new GlobalRulestackFqdnData(new string[] { "string1", "string2" }) + { + Description = "string", + ETag = new ETag("aaaaaaaaaaaaaaaaaa"), + AuditComment = "string", + }; + ArmOperation lro = await globalRulestackFqdn.UpdateAsync(WaitUntil.Completed, data); + GlobalRulestackFqdnResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_FqdnListGlobalRulestackDeleteMinimumSetGen() + public async Task Update_FqdnListGlobalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "FqdnListGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "FqdnListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,9 +179,15 @@ public async Task Delete_FqdnListGlobalRulestackDeleteMinimumSetGen() GlobalRulestackFqdnResource globalRulestackFqdn = client.GetGlobalRulestackFqdnResource(globalRulestackFqdnResourceId); // invoke the operation - await globalRulestackFqdn.DeleteAsync(WaitUntil.Completed); + GlobalRulestackFqdnData data = new GlobalRulestackFqdnData(new string[] { "string1", "string2" }); + ArmOperation lro = await globalRulestackFqdn.UpdateAsync(WaitUntil.Completed, data); + GlobalRulestackFqdnResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackPrefixCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackPrefixCollection.cs index 677fa3441f775..f2d56eb5ee323 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackPrefixCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackPrefixCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_GlobalRulestackPrefixCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrefixListGlobalRulestackListMaximumSetGen() + public async Task CreateOrUpdate_PrefixListGlobalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_List_MaximumSet_Gen.json - // this example is just showing the usage of "PrefixListGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "PrefixListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,25 +36,30 @@ public async Task GetAll_PrefixListGlobalRulestackListMaximumSetGen() // get the collection of this GlobalRulestackPrefixResource GlobalRulestackPrefixCollection collection = globalRulestack.GetGlobalRulestackPrefixes(); - // invoke the operation and iterate over the result - await foreach (GlobalRulestackPrefixResource item in collection.GetAllAsync()) + // invoke the operation + string name = "armid1"; + GlobalRulestackPrefixData data = new GlobalRulestackPrefixData(new string[] { "1.0.0.0/24" }) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackPrefixData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), + AuditComment = "comment", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + GlobalRulestackPrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrefixListGlobalRulestackListMinimumSetGen() + public async Task CreateOrUpdate_PrefixListGlobalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_List_MinimumSet_Gen.json - // this example is just showing the usage of "PrefixListGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "PrefixListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,17 +75,17 @@ public async Task GetAll_PrefixListGlobalRulestackListMinimumSetGen() // get the collection of this GlobalRulestackPrefixResource GlobalRulestackPrefixCollection collection = globalRulestack.GetGlobalRulestackPrefixes(); - // invoke the operation and iterate over the result - await foreach (GlobalRulestackPrefixResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackPrefixData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "armid1"; + GlobalRulestackPrefixData data = new GlobalRulestackPrefixData(new string[] { "1.0.0.0/24" }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + GlobalRulestackPrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -117,9 +122,9 @@ public async Task Get_PrefixListGlobalRulestackGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrefixListGlobalRulestackGetMaximumSetGen() + public async Task Get_PrefixListGlobalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "PrefixListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -138,17 +143,21 @@ public async Task Exists_PrefixListGlobalRulestackGetMaximumSetGen() // invoke the operation string name = "armid1"; - bool result = await collection.ExistsAsync(name); + GlobalRulestackPrefixResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrefixListGlobalRulestackGetMaximumSetGen() + public async Task GetAll_PrefixListGlobalRulestackListMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Get_MaximumSet_Gen.json - // this example is just showing the usage of "PrefixListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_List_MaximumSet_Gen.json + // this example is just showing the usage of "PrefixListGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -164,31 +173,25 @@ public async Task GetIfExists_PrefixListGlobalRulestackGetMaximumSetGen() // get the collection of this GlobalRulestackPrefixResource GlobalRulestackPrefixCollection collection = globalRulestack.GetGlobalRulestackPrefixes(); - // invoke the operation - string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - GlobalRulestackPrefixResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (GlobalRulestackPrefixResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GlobalRulestackPrefixData resourceData = result.Data; + GlobalRulestackPrefixData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrefixListGlobalRulestackGetMinimumSetGen() + public async Task GetAll_PrefixListGlobalRulestackListMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Get_MinimumSet_Gen.json - // this example is just showing the usage of "PrefixListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_List_MinimumSet_Gen.json + // this example is just showing the usage of "PrefixListGlobalRulestack_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,22 +207,24 @@ public async Task Get_PrefixListGlobalRulestackGetMinimumSetGen() // get the collection of this GlobalRulestackPrefixResource GlobalRulestackPrefixCollection collection = globalRulestack.GetGlobalRulestackPrefixes(); - // invoke the operation - string name = "armid1"; - GlobalRulestackPrefixResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (GlobalRulestackPrefixResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackPrefixData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrefixListGlobalRulestackGetMinimumSetGen() + public async Task Exists_PrefixListGlobalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Get_MaximumSet_Gen.json // this example is just showing the usage of "PrefixListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -245,7 +250,7 @@ public async Task Exists_PrefixListGlobalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrefixListGlobalRulestackGetMinimumSetGen() + public async Task Exists_PrefixListGlobalRulestackGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "PrefixListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. @@ -266,29 +271,17 @@ public async Task GetIfExists_PrefixListGlobalRulestackGetMinimumSetGen() // invoke the operation string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - GlobalRulestackPrefixResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrefixListGlobalRulestackCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_PrefixListGlobalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "PrefixListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PrefixListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -306,31 +299,29 @@ public async Task CreateOrUpdate_PrefixListGlobalRulestackCreateOrUpdateMaximumS // invoke the operation string name = "armid1"; - GlobalRulestackPrefixData data = new GlobalRulestackPrefixData(new string[] + NullableResponse response = await collection.GetIfExistsAsync(name); + GlobalRulestackPrefixResource result = response.HasValue ? response.Value : null; + + if (result == null) { -"1.0.0.0/24" - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "string", - ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), - AuditComment = "comment", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - GlobalRulestackPrefixResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrefixListGlobalRulestackCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_PrefixListGlobalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "PrefixListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Get_MinimumSet_Gen.json + // this example is just showing the usage of "PrefixListGlobalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -348,18 +339,21 @@ public async Task CreateOrUpdate_PrefixListGlobalRulestackCreateOrUpdateMinimumS // invoke the operation string name = "armid1"; - GlobalRulestackPrefixData data = new GlobalRulestackPrefixData(new string[] - { -"1.0.0.0/24" - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - GlobalRulestackPrefixResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + GlobalRulestackPrefixResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackPrefixResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackPrefixResource.cs index a4c503d0c1246..9ec438fccf296 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackPrefixResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackPrefixResource.cs @@ -75,10 +75,10 @@ public async Task Get_PrefixListGlobalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrefixListGlobalRulestackCreateOrUpdateMaximumSetGen() + public async Task Delete_PrefixListGlobalRulestackDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "PrefixListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "PrefixListGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,31 +93,17 @@ public async Task Update_PrefixListGlobalRulestackCreateOrUpdateMaximumSetGen() GlobalRulestackPrefixResource globalRulestackPrefix = client.GetGlobalRulestackPrefixResource(globalRulestackPrefixResourceId); // invoke the operation - GlobalRulestackPrefixData data = new GlobalRulestackPrefixData(new string[] - { -"1.0.0.0/24" - }) - { - Description = "string", - ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), - AuditComment = "comment", - }; - ArmOperation lro = await globalRulestackPrefix.UpdateAsync(WaitUntil.Completed, data); - GlobalRulestackPrefixResource result = lro.Value; + await globalRulestackPrefix.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrefixListGlobalRulestackCreateOrUpdateMinimumSetGen() + public async Task Delete_PrefixListGlobalRulestackDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "PrefixListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "PrefixListGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,26 +118,17 @@ public async Task Update_PrefixListGlobalRulestackCreateOrUpdateMinimumSetGen() GlobalRulestackPrefixResource globalRulestackPrefix = client.GetGlobalRulestackPrefixResource(globalRulestackPrefixResourceId); // invoke the operation - GlobalRulestackPrefixData data = new GlobalRulestackPrefixData(new string[] - { -"1.0.0.0/24" - }); - ArmOperation lro = await globalRulestackPrefix.UpdateAsync(WaitUntil.Completed, data); - GlobalRulestackPrefixResource result = lro.Value; + await globalRulestackPrefix.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrefixListGlobalRulestackDeleteMaximumSetGen() + public async Task Update_PrefixListGlobalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "PrefixListGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "PrefixListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -166,17 +143,28 @@ public async Task Delete_PrefixListGlobalRulestackDeleteMaximumSetGen() GlobalRulestackPrefixResource globalRulestackPrefix = client.GetGlobalRulestackPrefixResource(globalRulestackPrefixResourceId); // invoke the operation - await globalRulestackPrefix.DeleteAsync(WaitUntil.Completed); + GlobalRulestackPrefixData data = new GlobalRulestackPrefixData(new string[] { "1.0.0.0/24" }) + { + Description = "string", + ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), + AuditComment = "comment", + }; + ArmOperation lro = await globalRulestackPrefix.UpdateAsync(WaitUntil.Completed, data); + GlobalRulestackPrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrefixListGlobalRulestackDeleteMinimumSetGen() + public async Task Update_PrefixListGlobalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "PrefixListGlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListGlobalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "PrefixListGlobalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,9 +179,15 @@ public async Task Delete_PrefixListGlobalRulestackDeleteMinimumSetGen() GlobalRulestackPrefixResource globalRulestackPrefix = client.GetGlobalRulestackPrefixResource(globalRulestackPrefixResourceId); // invoke the operation - await globalRulestackPrefix.DeleteAsync(WaitUntil.Completed); + GlobalRulestackPrefixData data = new GlobalRulestackPrefixData(new string[] { "1.0.0.0/24" }); + ArmOperation lro = await globalRulestackPrefix.UpdateAsync(WaitUntil.Completed, data); + GlobalRulestackPrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackResource.cs index c86e66395055b..a22865a282d62 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_GlobalRulestackResource.cs @@ -73,6 +73,54 @@ public async Task Get_GlobalRulestackGetMinimumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_GlobalRulestackDeleteMaximumSetGen() + { + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "GlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this GlobalRulestackResource created on azure + // for more information of creating GlobalRulestackResource, please refer to the document of GlobalRulestackResource + string globalRulestackName = "praval"; + ResourceIdentifier globalRulestackResourceId = GlobalRulestackResource.CreateResourceIdentifier(globalRulestackName); + GlobalRulestackResource globalRulestack = client.GetGlobalRulestackResource(globalRulestackResourceId); + + // invoke the operation + await globalRulestack.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_GlobalRulestackDeleteMinimumSetGen() + { + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "GlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this GlobalRulestackResource created on azure + // for more information of creating GlobalRulestackResource, please refer to the document of GlobalRulestackResource + string globalRulestackName = "praval"; + ResourceIdentifier globalRulestackResourceId = GlobalRulestackResource.CreateResourceIdentifier(globalRulestackName); + GlobalRulestackResource globalRulestack = client.GetGlobalRulestackResource(globalRulestackResourceId); + + // invoke the operation + await globalRulestack.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_GlobalRulestackUpdateMaximumSetGen() @@ -92,29 +140,26 @@ public async Task Update_GlobalRulestackUpdateMaximumSetGen() GlobalRulestackResource globalRulestack = client.GetGlobalRulestackResource(globalRulestackResourceId); // invoke the operation - GlobalRulestackPatch patch = new GlobalRulestackPatch() + GlobalRulestackPatch patch = new GlobalRulestackPatch { Location = new AzureLocation("eastus"), Identity = new ManagedServiceIdentity("None") { UserAssignedIdentities = { -[new ResourceIdentifier("key16")] = new UserAssignedIdentity(), +[new ResourceIdentifier("key16")] = new UserAssignedIdentity() }, }, - Properties = new GlobalRulestackUpdateProperties() + Properties = new GlobalRulestackUpdateProperties { PanETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c12"), PanLocation = new AzureLocation("eastus"), Scope = RulestackScopeType.Global, - AssociatedSubscriptions = -{ -"2bf4a339-294d-4c25-b0b2-ef649e9f5c27" -}, + AssociatedSubscriptions = { "2bf4a339-294d-4c25-b0b2-ef649e9f5c27" }, Description = "global rulestacks", DefaultMode = RuleCreationDefaultMode.IPS, MinAppIdVersion = "8.5.3", - SecurityServices = new RulestackSecurityServices() + SecurityServices = new RulestackSecurityServices { VulnerabilityProfile = "default", AntiSpywareProfile = "default", @@ -165,54 +210,6 @@ public async Task Update_GlobalRulestackUpdateMinimumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_GlobalRulestackDeleteMaximumSetGen() - { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "GlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this GlobalRulestackResource created on azure - // for more information of creating GlobalRulestackResource, please refer to the document of GlobalRulestackResource - string globalRulestackName = "praval"; - ResourceIdentifier globalRulestackResourceId = GlobalRulestackResource.CreateResourceIdentifier(globalRulestackName); - GlobalRulestackResource globalRulestack = client.GetGlobalRulestackResource(globalRulestackResourceId); - - // invoke the operation - await globalRulestack.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_GlobalRulestackDeleteMinimumSetGen() - { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/GlobalRulestack_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "GlobalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this GlobalRulestackResource created on azure - // for more information of creating GlobalRulestackResource, please refer to the document of GlobalRulestackResource - string globalRulestackName = "praval"; - ResourceIdentifier globalRulestackResourceId = GlobalRulestackResource.CreateResourceIdentifier(globalRulestackName); - GlobalRulestackResource globalRulestack = client.GetGlobalRulestackResource(globalRulestackResourceId); - - // invoke the operation - await globalRulestack.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Commit_GlobalRulestackCommitMaximumSetGen() diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCertificateObjectCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCertificateObjectCollection.cs index 35174ebd534ce..d3b82d92d51d8 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCertificateObjectCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCertificateObjectCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LocalRulestackCertificateObjectCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CertificateObjectLocalRulestackListByLocalRulestacksMaximumSetGen() + public async Task CreateOrUpdate_CertificateObjectLocalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_ListByLocalRulestacks_MaximumSet_Gen.json - // this example is just showing the usage of "CertificateObjectLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "CertificateObjectLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,31 @@ public async Task GetAll_CertificateObjectLocalRulestackListByLocalRulestacksMax // get the collection of this LocalRulestackCertificateObjectResource LocalRulestackCertificateObjectCollection collection = localRulestack.GetLocalRulestackCertificateObjects(); - // invoke the operation and iterate over the result - await foreach (LocalRulestackCertificateObjectResource item in collection.GetAllAsync()) + // invoke the operation + string name = "armid1"; + LocalRulestackCertificateObjectData data = new LocalRulestackCertificateObjectData(FirewallBooleanType.True) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackCertificateObjectData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CertificateSignerResourceId = "", + AuditComment = "comment", + Description = "description", + ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + LocalRulestackCertificateObjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CertificateObjectLocalRulestackListByLocalRulestacksMinimumSetGen() + public async Task CreateOrUpdate_CertificateObjectLocalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_ListByLocalRulestacks_MinimumSet_Gen.json - // this example is just showing the usage of "CertificateObjectLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "CertificateObjectLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +81,17 @@ public async Task GetAll_CertificateObjectLocalRulestackListByLocalRulestacksMin // get the collection of this LocalRulestackCertificateObjectResource LocalRulestackCertificateObjectCollection collection = localRulestack.GetLocalRulestackCertificateObjects(); - // invoke the operation and iterate over the result - await foreach (LocalRulestackCertificateObjectResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackCertificateObjectData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "armid1"; + LocalRulestackCertificateObjectData data = new LocalRulestackCertificateObjectData(FirewallBooleanType.True); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + LocalRulestackCertificateObjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -124,9 +130,9 @@ public async Task Get_CertificateObjectLocalRulestackGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CertificateObjectLocalRulestackGetMaximumSetGen() + public async Task Get_CertificateObjectLocalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "CertificateObjectLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -147,17 +153,21 @@ public async Task Exists_CertificateObjectLocalRulestackGetMaximumSetGen() // invoke the operation string name = "armid1"; - bool result = await collection.ExistsAsync(name); + LocalRulestackCertificateObjectResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CertificateObjectLocalRulestackGetMaximumSetGen() + public async Task GetAll_CertificateObjectLocalRulestackListByLocalRulestacksMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Get_MaximumSet_Gen.json - // this example is just showing the usage of "CertificateObjectLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_ListByLocalRulestacks_MaximumSet_Gen.json + // this example is just showing the usage of "CertificateObjectLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -175,31 +185,25 @@ public async Task GetIfExists_CertificateObjectLocalRulestackGetMaximumSetGen() // get the collection of this LocalRulestackCertificateObjectResource LocalRulestackCertificateObjectCollection collection = localRulestack.GetLocalRulestackCertificateObjects(); - // invoke the operation - string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - LocalRulestackCertificateObjectResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (LocalRulestackCertificateObjectResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LocalRulestackCertificateObjectData resourceData = result.Data; + LocalRulestackCertificateObjectData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CertificateObjectLocalRulestackGetMinimumSetGen() + public async Task GetAll_CertificateObjectLocalRulestackListByLocalRulestacksMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Get_MinimumSet_Gen.json - // this example is just showing the usage of "CertificateObjectLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_ListByLocalRulestacks_MinimumSet_Gen.json + // this example is just showing the usage of "CertificateObjectLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,22 +221,24 @@ public async Task Get_CertificateObjectLocalRulestackGetMinimumSetGen() // get the collection of this LocalRulestackCertificateObjectResource LocalRulestackCertificateObjectCollection collection = localRulestack.GetLocalRulestackCertificateObjects(); - // invoke the operation - string name = "armid1"; - LocalRulestackCertificateObjectResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (LocalRulestackCertificateObjectResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackCertificateObjectData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CertificateObjectLocalRulestackGetMinimumSetGen() + public async Task Exists_CertificateObjectLocalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Get_MaximumSet_Gen.json // this example is just showing the usage of "CertificateObjectLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -260,7 +266,7 @@ public async Task Exists_CertificateObjectLocalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CertificateObjectLocalRulestackGetMinimumSetGen() + public async Task Exists_CertificateObjectLocalRulestackGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "CertificateObjectLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. @@ -283,29 +289,17 @@ public async Task GetIfExists_CertificateObjectLocalRulestackGetMinimumSetGen() // invoke the operation string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - LocalRulestackCertificateObjectResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CertificateObjectLocalRulestackCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_CertificateObjectLocalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "CertificateObjectLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Get_MaximumSet_Gen.json + // this example is just showing the usage of "CertificateObjectLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -325,29 +319,29 @@ public async Task CreateOrUpdate_CertificateObjectLocalRulestackCreateOrUpdateMa // invoke the operation string name = "armid1"; - LocalRulestackCertificateObjectData data = new LocalRulestackCertificateObjectData(FirewallBooleanType.True) - { - CertificateSignerResourceId = "", - AuditComment = "comment", - Description = "description", - ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - LocalRulestackCertificateObjectResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + LocalRulestackCertificateObjectResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CertificateObjectLocalRulestackCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_CertificateObjectLocalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "CertificateObjectLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Get_MinimumSet_Gen.json + // this example is just showing the usage of "CertificateObjectLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -367,15 +361,21 @@ public async Task CreateOrUpdate_CertificateObjectLocalRulestackCreateOrUpdateMi // invoke the operation string name = "armid1"; - LocalRulestackCertificateObjectData data = new LocalRulestackCertificateObjectData(FirewallBooleanType.True); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - LocalRulestackCertificateObjectResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + LocalRulestackCertificateObjectResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCertificateObjectResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCertificateObjectResource.cs index ae134661dbdca..b1ffcedd4eeb8 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCertificateObjectResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCertificateObjectResource.cs @@ -80,10 +80,10 @@ public async Task Get_CertificateObjectLocalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CertificateObjectLocalRulestackCreateOrUpdateMaximumSetGen() + public async Task Delete_CertificateObjectLocalRulestackDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "CertificateObjectLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "CertificateObjectLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,29 +100,17 @@ public async Task Update_CertificateObjectLocalRulestackCreateOrUpdateMaximumSet LocalRulestackCertificateObjectResource localRulestackCertificateObject = client.GetLocalRulestackCertificateObjectResource(localRulestackCertificateObjectResourceId); // invoke the operation - LocalRulestackCertificateObjectData data = new LocalRulestackCertificateObjectData(FirewallBooleanType.True) - { - CertificateSignerResourceId = "", - AuditComment = "comment", - Description = "description", - ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), - }; - ArmOperation lro = await localRulestackCertificateObject.UpdateAsync(WaitUntil.Completed, data); - LocalRulestackCertificateObjectResource result = lro.Value; + await localRulestackCertificateObject.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CertificateObjectLocalRulestackCreateOrUpdateMinimumSetGen() + public async Task Delete_CertificateObjectLocalRulestackDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "CertificateObjectLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "CertificateObjectLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,23 +127,17 @@ public async Task Update_CertificateObjectLocalRulestackCreateOrUpdateMinimumSet LocalRulestackCertificateObjectResource localRulestackCertificateObject = client.GetLocalRulestackCertificateObjectResource(localRulestackCertificateObjectResourceId); // invoke the operation - LocalRulestackCertificateObjectData data = new LocalRulestackCertificateObjectData(FirewallBooleanType.True); - ArmOperation lro = await localRulestackCertificateObject.UpdateAsync(WaitUntil.Completed, data); - LocalRulestackCertificateObjectResource result = lro.Value; + await localRulestackCertificateObject.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackCertificateObjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CertificateObjectLocalRulestackDeleteMaximumSetGen() + public async Task Update_CertificateObjectLocalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "CertificateObjectLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "CertificateObjectLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,17 +154,29 @@ public async Task Delete_CertificateObjectLocalRulestackDeleteMaximumSetGen() LocalRulestackCertificateObjectResource localRulestackCertificateObject = client.GetLocalRulestackCertificateObjectResource(localRulestackCertificateObjectResourceId); // invoke the operation - await localRulestackCertificateObject.DeleteAsync(WaitUntil.Completed); + LocalRulestackCertificateObjectData data = new LocalRulestackCertificateObjectData(FirewallBooleanType.True) + { + CertificateSignerResourceId = "", + AuditComment = "comment", + Description = "description", + ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), + }; + ArmOperation lro = await localRulestackCertificateObject.UpdateAsync(WaitUntil.Completed, data); + LocalRulestackCertificateObjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CertificateObjectLocalRulestackDeleteMinimumSetGen() + public async Task Update_CertificateObjectLocalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "CertificateObjectLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/CertificateObjectLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "CertificateObjectLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,9 +193,15 @@ public async Task Delete_CertificateObjectLocalRulestackDeleteMinimumSetGen() LocalRulestackCertificateObjectResource localRulestackCertificateObject = client.GetLocalRulestackCertificateObjectResource(localRulestackCertificateObjectResourceId); // invoke the operation - await localRulestackCertificateObject.DeleteAsync(WaitUntil.Completed); + LocalRulestackCertificateObjectData data = new LocalRulestackCertificateObjectData(FirewallBooleanType.True); + ArmOperation lro = await localRulestackCertificateObject.UpdateAsync(WaitUntil.Completed, data); + LocalRulestackCertificateObjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackCertificateObjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCollection.cs index ca3f7be29b5ca..bbe7221c0d389 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_LocalRulestackCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LocalRulestacksListByResourceGroupMaximumSetGen() + public async Task CreateOrUpdate_LocalRulestacksCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,56 @@ public async Task GetAll_LocalRulestacksListByResourceGroupMaximumSetGen() // get the collection of this LocalRulestackResource LocalRulestackCollection collection = resourceGroupResource.GetLocalRulestacks(); - // invoke the operation and iterate over the result - await foreach (LocalRulestackResource item in collection.GetAllAsync()) + // invoke the operation + string localRulestackName = "lrs1"; + LocalRulestackData data = new LocalRulestackData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("key16")] = new UserAssignedIdentity() +}, + }, + PanETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c12"), + PanLocation = new AzureLocation("eastus"), + Scope = RulestackScopeType.Local, + AssociatedSubscriptions = { "2bf4a339-294d-4c25-b0b2-ef649e9f5c27" }, + Description = "local rulestacks", + DefaultMode = RuleCreationDefaultMode.IPS, + MinAppIdVersion = "8.5.3", + SecurityServices = new RulestackSecurityServices + { + VulnerabilityProfile = "default", + AntiSpywareProfile = "default", + AntiVirusProfile = "default", + UrlFilteringProfile = "default", + FileBlockingProfile = "default", + DnsSubscription = "default", + OutboundUnTrustCertificate = "default", + OutboundTrustCertificate = "default", + }, + Tags = +{ +["tagName"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, localRulestackName, data); + LocalRulestackResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LocalRulestacksListByResourceGroupMinimumSetGen() + public async Task CreateOrUpdate_LocalRulestacksCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +106,17 @@ public async Task GetAll_LocalRulestacksListByResourceGroupMinimumSetGen() // get the collection of this LocalRulestackResource LocalRulestackCollection collection = resourceGroupResource.GetLocalRulestacks(); - // invoke the operation and iterate over the result - await foreach (LocalRulestackResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string localRulestackName = "lrs1"; + LocalRulestackData data = new LocalRulestackData(new AzureLocation("eastus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, localRulestackName, data); + LocalRulestackResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -123,9 +154,9 @@ public async Task Get_LocalRulestacksGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LocalRulestacksGetMaximumSetGen() + public async Task Get_LocalRulestacksGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MinimumSet_Gen.json // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -145,17 +176,21 @@ public async Task Exists_LocalRulestacksGetMaximumSetGen() // invoke the operation string localRulestackName = "lrs1"; - bool result = await collection.ExistsAsync(localRulestackName); + LocalRulestackResource result = await collection.GetAsync(localRulestackName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LocalRulestacksGetMaximumSetGen() + public async Task GetAll_LocalRulestacksListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,31 +207,25 @@ public async Task GetIfExists_LocalRulestacksGetMaximumSetGen() // get the collection of this LocalRulestackResource LocalRulestackCollection collection = resourceGroupResource.GetLocalRulestacks(); - // invoke the operation - string localRulestackName = "lrs1"; - NullableResponse response = await collection.GetIfExistsAsync(localRulestackName); - LocalRulestackResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (LocalRulestackResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = result.Data; + LocalRulestackData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LocalRulestacksGetMinimumSetGen() + public async Task GetAll_LocalRulestacksListByResourceGroupMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,22 +242,24 @@ public async Task Get_LocalRulestacksGetMinimumSetGen() // get the collection of this LocalRulestackResource LocalRulestackCollection collection = resourceGroupResource.GetLocalRulestacks(); - // invoke the operation - string localRulestackName = "lrs1"; - LocalRulestackResource result = await collection.GetAsync(localRulestackName); + // invoke the operation and iterate over the result + await foreach (LocalRulestackResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LocalRulestacksGetMinimumSetGen() + public async Task Exists_LocalRulestacksGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MaximumSet_Gen.json // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -255,7 +286,7 @@ public async Task Exists_LocalRulestacksGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LocalRulestacksGetMinimumSetGen() + public async Task Exists_LocalRulestacksGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MinimumSet_Gen.json // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. @@ -277,29 +308,17 @@ public async Task GetIfExists_LocalRulestacksGetMinimumSetGen() // invoke the operation string localRulestackName = "lrs1"; - NullableResponse response = await collection.GetIfExistsAsync(localRulestackName); - LocalRulestackResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(localRulestackName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LocalRulestacksCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_LocalRulestacksGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -318,57 +337,29 @@ public async Task CreateOrUpdate_LocalRulestacksCreateOrUpdateMaximumSetGen() // invoke the operation string localRulestackName = "lrs1"; - LocalRulestackData data = new LocalRulestackData(new AzureLocation("eastus")) - { - Identity = new ManagedServiceIdentity("None") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("key16")] = new UserAssignedIdentity(), -}, - }, - PanETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c12"), - PanLocation = new AzureLocation("eastus"), - Scope = RulestackScopeType.Local, - AssociatedSubscriptions = -{ -"2bf4a339-294d-4c25-b0b2-ef649e9f5c27" -}, - Description = "local rulestacks", - DefaultMode = RuleCreationDefaultMode.IPS, - MinAppIdVersion = "8.5.3", - SecurityServices = new RulestackSecurityServices() - { - VulnerabilityProfile = "default", - AntiSpywareProfile = "default", - AntiVirusProfile = "default", - UrlFilteringProfile = "default", - FileBlockingProfile = "default", - DnsSubscription = "default", - OutboundUnTrustCertificate = "default", - OutboundTrustCertificate = "default", - }, - Tags = -{ -["tagName"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, localRulestackName, data); - LocalRulestackResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(localRulestackName); + LocalRulestackResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LocalRulestacksCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_LocalRulestacksGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -387,15 +378,21 @@ public async Task CreateOrUpdate_LocalRulestacksCreateOrUpdateMinimumSetGen() // invoke the operation string localRulestackName = "lrs1"; - LocalRulestackData data = new LocalRulestackData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, localRulestackName, data); - LocalRulestackResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(localRulestackName); + LocalRulestackResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackFqdnCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackFqdnCollection.cs index c718d88962f86..2bdded4f29cfb 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackFqdnCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackFqdnCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LocalRulestackFqdnCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FqdnListLocalRulestackListByLocalRulestacksMaximumSetGen() + public async Task CreateOrUpdate_FqdnListLocalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_ListByLocalRulestacks_MaximumSet_Gen.json - // this example is just showing the usage of "FqdnListLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "FqdnListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,30 @@ public async Task GetAll_FqdnListLocalRulestackListByLocalRulestacksMaximumSetGe // get the collection of this LocalRulestackFqdnResource LocalRulestackFqdnCollection collection = localRulestack.GetLocalRulestackFqdns(); - // invoke the operation and iterate over the result - await foreach (LocalRulestackFqdnResource item in collection.GetAllAsync()) + // invoke the operation + string name = "armid1"; + LocalRulestackFqdnData data = new LocalRulestackFqdnData(new string[] { "string1", "string2" }) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackFqdnData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + ETag = new ETag("aaaaaaaaaaaaaaaaaa"), + AuditComment = "string", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + LocalRulestackFqdnResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FqdnListLocalRulestackListByLocalRulestacksMinimumSetGen() + public async Task CreateOrUpdate_FqdnListLocalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_ListByLocalRulestacks_MinimumSet_Gen.json - // this example is just showing the usage of "FqdnListLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "FqdnListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,17 +79,17 @@ public async Task GetAll_FqdnListLocalRulestackListByLocalRulestacksMinimumSetGe // get the collection of this LocalRulestackFqdnResource LocalRulestackFqdnCollection collection = localRulestack.GetLocalRulestackFqdns(); - // invoke the operation and iterate over the result - await foreach (LocalRulestackFqdnResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackFqdnData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "armid1"; + LocalRulestackFqdnData data = new LocalRulestackFqdnData(new string[] { "string1", "string2" }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + LocalRulestackFqdnResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -123,9 +128,9 @@ public async Task Get_FqdnListLocalRulestackGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FqdnListLocalRulestackGetMaximumSetGen() + public async Task Get_FqdnListLocalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "FqdnListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -146,17 +151,21 @@ public async Task Exists_FqdnListLocalRulestackGetMaximumSetGen() // invoke the operation string name = "armid1"; - bool result = await collection.ExistsAsync(name); + LocalRulestackFqdnResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FqdnListLocalRulestackGetMaximumSetGen() + public async Task GetAll_FqdnListLocalRulestackListByLocalRulestacksMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Get_MaximumSet_Gen.json - // this example is just showing the usage of "FqdnListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_ListByLocalRulestacks_MaximumSet_Gen.json + // this example is just showing the usage of "FqdnListLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,31 +183,25 @@ public async Task GetIfExists_FqdnListLocalRulestackGetMaximumSetGen() // get the collection of this LocalRulestackFqdnResource LocalRulestackFqdnCollection collection = localRulestack.GetLocalRulestackFqdns(); - // invoke the operation - string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - LocalRulestackFqdnResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (LocalRulestackFqdnResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LocalRulestackFqdnData resourceData = result.Data; + LocalRulestackFqdnData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FqdnListLocalRulestackGetMinimumSetGen() + public async Task GetAll_FqdnListLocalRulestackListByLocalRulestacksMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Get_MinimumSet_Gen.json - // this example is just showing the usage of "FqdnListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_ListByLocalRulestacks_MinimumSet_Gen.json + // this example is just showing the usage of "FqdnListLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -216,22 +219,24 @@ public async Task Get_FqdnListLocalRulestackGetMinimumSetGen() // get the collection of this LocalRulestackFqdnResource LocalRulestackFqdnCollection collection = localRulestack.GetLocalRulestackFqdns(); - // invoke the operation - string name = "armid1"; - LocalRulestackFqdnResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (LocalRulestackFqdnResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackFqdnData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FqdnListLocalRulestackGetMinimumSetGen() + public async Task Exists_FqdnListLocalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Get_MaximumSet_Gen.json // this example is just showing the usage of "FqdnListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -259,7 +264,7 @@ public async Task Exists_FqdnListLocalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FqdnListLocalRulestackGetMinimumSetGen() + public async Task Exists_FqdnListLocalRulestackGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "FqdnListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. @@ -282,29 +287,17 @@ public async Task GetIfExists_FqdnListLocalRulestackGetMinimumSetGen() // invoke the operation string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - LocalRulestackFqdnResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FqdnListLocalRulestackCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_FqdnListLocalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "FqdnListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Get_MaximumSet_Gen.json + // this example is just showing the usage of "FqdnListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -324,31 +317,29 @@ public async Task CreateOrUpdate_FqdnListLocalRulestackCreateOrUpdateMaximumSetG // invoke the operation string name = "armid1"; - LocalRulestackFqdnData data = new LocalRulestackFqdnData(new string[] + NullableResponse response = await collection.GetIfExistsAsync(name); + LocalRulestackFqdnResource result = response.HasValue ? response.Value : null; + + if (result == null) { -"string1","string2" - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "string", - ETag = new ETag("aaaaaaaaaaaaaaaaaa"), - AuditComment = "string", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - LocalRulestackFqdnResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FqdnListLocalRulestackCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_FqdnListLocalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "FqdnListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Get_MinimumSet_Gen.json + // this example is just showing the usage of "FqdnListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -368,18 +359,21 @@ public async Task CreateOrUpdate_FqdnListLocalRulestackCreateOrUpdateMinimumSetG // invoke the operation string name = "armid1"; - LocalRulestackFqdnData data = new LocalRulestackFqdnData(new string[] - { -"string1","string2" - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - LocalRulestackFqdnResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + LocalRulestackFqdnResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackFqdnResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackFqdnResource.cs index 5f192f78daeff..c947fe0d53d65 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackFqdnResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackFqdnResource.cs @@ -79,10 +79,10 @@ public async Task Get_FqdnListLocalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FqdnListLocalRulestackCreateOrUpdateMaximumSetGen() + public async Task Delete_FqdnListLocalRulestackDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "FqdnListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "FqdnListLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,31 +99,17 @@ public async Task Update_FqdnListLocalRulestackCreateOrUpdateMaximumSetGen() LocalRulestackFqdnResource localRulestackFqdn = client.GetLocalRulestackFqdnResource(localRulestackFqdnResourceId); // invoke the operation - LocalRulestackFqdnData data = new LocalRulestackFqdnData(new string[] - { -"string1","string2" - }) - { - Description = "string", - ETag = new ETag("aaaaaaaaaaaaaaaaaa"), - AuditComment = "string", - }; - ArmOperation lro = await localRulestackFqdn.UpdateAsync(WaitUntil.Completed, data); - LocalRulestackFqdnResource result = lro.Value; + await localRulestackFqdn.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FqdnListLocalRulestackCreateOrUpdateMinimumSetGen() + public async Task Delete_FqdnListLocalRulestackDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "FqdnListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "FqdnListLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,26 +126,17 @@ public async Task Update_FqdnListLocalRulestackCreateOrUpdateMinimumSetGen() LocalRulestackFqdnResource localRulestackFqdn = client.GetLocalRulestackFqdnResource(localRulestackFqdnResourceId); // invoke the operation - LocalRulestackFqdnData data = new LocalRulestackFqdnData(new string[] - { -"string1","string2" - }); - ArmOperation lro = await localRulestackFqdn.UpdateAsync(WaitUntil.Completed, data); - LocalRulestackFqdnResource result = lro.Value; + await localRulestackFqdn.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackFqdnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_FqdnListLocalRulestackDeleteMaximumSetGen() + public async Task Update_FqdnListLocalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "FqdnListLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "FqdnListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,17 +153,28 @@ public async Task Delete_FqdnListLocalRulestackDeleteMaximumSetGen() LocalRulestackFqdnResource localRulestackFqdn = client.GetLocalRulestackFqdnResource(localRulestackFqdnResourceId); // invoke the operation - await localRulestackFqdn.DeleteAsync(WaitUntil.Completed); + LocalRulestackFqdnData data = new LocalRulestackFqdnData(new string[] { "string1", "string2" }) + { + Description = "string", + ETag = new ETag("aaaaaaaaaaaaaaaaaa"), + AuditComment = "string", + }; + ArmOperation lro = await localRulestackFqdn.UpdateAsync(WaitUntil.Completed, data); + LocalRulestackFqdnResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_FqdnListLocalRulestackDeleteMinimumSetGen() + public async Task Update_FqdnListLocalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "FqdnListLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/FqdnListLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "FqdnListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -203,9 +191,15 @@ public async Task Delete_FqdnListLocalRulestackDeleteMinimumSetGen() LocalRulestackFqdnResource localRulestackFqdn = client.GetLocalRulestackFqdnResource(localRulestackFqdnResourceId); // invoke the operation - await localRulestackFqdn.DeleteAsync(WaitUntil.Completed); + LocalRulestackFqdnData data = new LocalRulestackFqdnData(new string[] { "string1", "string2" }); + ArmOperation lro = await localRulestackFqdn.UpdateAsync(WaitUntil.Completed, data); + LocalRulestackFqdnResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackFqdnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackPrefixCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackPrefixCollection.cs index ca1c9e41fa103..0ff150c45969c 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackPrefixCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackPrefixCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LocalRulestackPrefixCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrefixListLocalRulestackListByLocalRulestacksMaximumSetGen() + public async Task CreateOrUpdate_PrefixListLocalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_ListByLocalRulestacks_MaximumSet_Gen.json - // this example is just showing the usage of "PrefixListLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "PrefixListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,30 @@ public async Task GetAll_PrefixListLocalRulestackListByLocalRulestacksMaximumSet // get the collection of this LocalRulestackPrefixResource LocalRulestackPrefixCollection collection = localRulestack.GetLocalRulestackPrefixes(); - // invoke the operation and iterate over the result - await foreach (LocalRulestackPrefixResource item in collection.GetAllAsync()) + // invoke the operation + string name = "armid1"; + LocalRulestackPrefixData data = new LocalRulestackPrefixData(new string[] { "1.0.0.0/24" }) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackPrefixData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), + AuditComment = "comment", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + LocalRulestackPrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrefixListLocalRulestackListByLocalRulestacksMinimumSetGen() + public async Task CreateOrUpdate_PrefixListLocalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_ListByLocalRulestacks_MinimumSet_Gen.json - // this example is just showing the usage of "PrefixListLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "PrefixListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,17 +79,17 @@ public async Task GetAll_PrefixListLocalRulestackListByLocalRulestacksMinimumSet // get the collection of this LocalRulestackPrefixResource LocalRulestackPrefixCollection collection = localRulestack.GetLocalRulestackPrefixes(); - // invoke the operation and iterate over the result - await foreach (LocalRulestackPrefixResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackPrefixData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "armid1"; + LocalRulestackPrefixData data = new LocalRulestackPrefixData(new string[] { "1.0.0.0/24" }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + LocalRulestackPrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -123,9 +128,9 @@ public async Task Get_PrefixListLocalRulestackGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrefixListLocalRulestackGetMaximumSetGen() + public async Task Get_PrefixListLocalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "PrefixListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -146,17 +151,21 @@ public async Task Exists_PrefixListLocalRulestackGetMaximumSetGen() // invoke the operation string name = "armid1"; - bool result = await collection.ExistsAsync(name); + LocalRulestackPrefixResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrefixListLocalRulestackGetMaximumSetGen() + public async Task GetAll_PrefixListLocalRulestackListByLocalRulestacksMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Get_MaximumSet_Gen.json - // this example is just showing the usage of "PrefixListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_ListByLocalRulestacks_MaximumSet_Gen.json + // this example is just showing the usage of "PrefixListLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,31 +183,25 @@ public async Task GetIfExists_PrefixListLocalRulestackGetMaximumSetGen() // get the collection of this LocalRulestackPrefixResource LocalRulestackPrefixCollection collection = localRulestack.GetLocalRulestackPrefixes(); - // invoke the operation - string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - LocalRulestackPrefixResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (LocalRulestackPrefixResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LocalRulestackPrefixData resourceData = result.Data; + LocalRulestackPrefixData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrefixListLocalRulestackGetMinimumSetGen() + public async Task GetAll_PrefixListLocalRulestackListByLocalRulestacksMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Get_MinimumSet_Gen.json - // this example is just showing the usage of "PrefixListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_ListByLocalRulestacks_MinimumSet_Gen.json + // this example is just showing the usage of "PrefixListLocalRulestack_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -216,22 +219,24 @@ public async Task Get_PrefixListLocalRulestackGetMinimumSetGen() // get the collection of this LocalRulestackPrefixResource LocalRulestackPrefixCollection collection = localRulestack.GetLocalRulestackPrefixes(); - // invoke the operation - string name = "armid1"; - LocalRulestackPrefixResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (LocalRulestackPrefixResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackPrefixData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrefixListLocalRulestackGetMinimumSetGen() + public async Task Exists_PrefixListLocalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Get_MaximumSet_Gen.json // this example is just showing the usage of "PrefixListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -259,7 +264,7 @@ public async Task Exists_PrefixListLocalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrefixListLocalRulestackGetMinimumSetGen() + public async Task Exists_PrefixListLocalRulestackGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Get_MinimumSet_Gen.json // this example is just showing the usage of "PrefixListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. @@ -282,29 +287,17 @@ public async Task GetIfExists_PrefixListLocalRulestackGetMinimumSetGen() // invoke the operation string name = "armid1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - LocalRulestackPrefixResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrefixListLocalRulestackCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_PrefixListLocalRulestackGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "PrefixListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PrefixListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -324,31 +317,29 @@ public async Task CreateOrUpdate_PrefixListLocalRulestackCreateOrUpdateMaximumSe // invoke the operation string name = "armid1"; - LocalRulestackPrefixData data = new LocalRulestackPrefixData(new string[] + NullableResponse response = await collection.GetIfExistsAsync(name); + LocalRulestackPrefixResource result = response.HasValue ? response.Value : null; + + if (result == null) { -"1.0.0.0/24" - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "string", - ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), - AuditComment = "comment", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - LocalRulestackPrefixResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrefixListLocalRulestackCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_PrefixListLocalRulestackGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "PrefixListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Get_MinimumSet_Gen.json + // this example is just showing the usage of "PrefixListLocalRulestack_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -368,18 +359,21 @@ public async Task CreateOrUpdate_PrefixListLocalRulestackCreateOrUpdateMinimumSe // invoke the operation string name = "armid1"; - LocalRulestackPrefixData data = new LocalRulestackPrefixData(new string[] - { -"1.0.0.0/24" - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - LocalRulestackPrefixResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + LocalRulestackPrefixResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackPrefixResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackPrefixResource.cs index c85901f346288..2231ebb50bce8 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackPrefixResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackPrefixResource.cs @@ -79,10 +79,10 @@ public async Task Get_PrefixListLocalRulestackGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrefixListLocalRulestackCreateOrUpdateMaximumSetGen() + public async Task Delete_PrefixListLocalRulestackDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "PrefixListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "PrefixListLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,31 +99,17 @@ public async Task Update_PrefixListLocalRulestackCreateOrUpdateMaximumSetGen() LocalRulestackPrefixResource localRulestackPrefix = client.GetLocalRulestackPrefixResource(localRulestackPrefixResourceId); // invoke the operation - LocalRulestackPrefixData data = new LocalRulestackPrefixData(new string[] - { -"1.0.0.0/24" - }) - { - Description = "string", - ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), - AuditComment = "comment", - }; - ArmOperation lro = await localRulestackPrefix.UpdateAsync(WaitUntil.Completed, data); - LocalRulestackPrefixResource result = lro.Value; + await localRulestackPrefix.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrefixListLocalRulestackCreateOrUpdateMinimumSetGen() + public async Task Delete_PrefixListLocalRulestackDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "PrefixListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "PrefixListLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,26 +126,17 @@ public async Task Update_PrefixListLocalRulestackCreateOrUpdateMinimumSetGen() LocalRulestackPrefixResource localRulestackPrefix = client.GetLocalRulestackPrefixResource(localRulestackPrefixResourceId); // invoke the operation - LocalRulestackPrefixData data = new LocalRulestackPrefixData(new string[] - { -"1.0.0.0/24" - }); - ArmOperation lro = await localRulestackPrefix.UpdateAsync(WaitUntil.Completed, data); - LocalRulestackPrefixResource result = lro.Value; + await localRulestackPrefix.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrefixListLocalRulestackDeleteMaximumSetGen() + public async Task Update_PrefixListLocalRulestackCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "PrefixListLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "PrefixListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,17 +153,28 @@ public async Task Delete_PrefixListLocalRulestackDeleteMaximumSetGen() LocalRulestackPrefixResource localRulestackPrefix = client.GetLocalRulestackPrefixResource(localRulestackPrefixResourceId); // invoke the operation - await localRulestackPrefix.DeleteAsync(WaitUntil.Completed); + LocalRulestackPrefixData data = new LocalRulestackPrefixData(new string[] { "1.0.0.0/24" }) + { + Description = "string", + ETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c27"), + AuditComment = "comment", + }; + ArmOperation lro = await localRulestackPrefix.UpdateAsync(WaitUntil.Completed, data); + LocalRulestackPrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrefixListLocalRulestackDeleteMinimumSetGen() + public async Task Update_PrefixListLocalRulestackCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "PrefixListLocalRulestack_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PrefixListLocalRulestack_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "PrefixListLocalRulestack_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -203,9 +191,15 @@ public async Task Delete_PrefixListLocalRulestackDeleteMinimumSetGen() LocalRulestackPrefixResource localRulestackPrefix = client.GetLocalRulestackPrefixResource(localRulestackPrefixResourceId); // invoke the operation - await localRulestackPrefix.DeleteAsync(WaitUntil.Completed); + LocalRulestackPrefixData data = new LocalRulestackPrefixData(new string[] { "1.0.0.0/24" }); + ArmOperation lro = await localRulestackPrefix.UpdateAsync(WaitUntil.Completed, data); + LocalRulestackPrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackResource.cs index c8e91a03068f5..8a54a78026486 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.PaloAltoNetworks.Ngfw.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.PaloAltoNetworks.Ngfw.Samples @@ -20,72 +19,70 @@ public partial class Sample_LocalRulestackResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLocalRulestacks_LocalRulestacksListBySubscriptionMaximumSetGen() + public async Task Get_LocalRulestacksGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this LocalRulestackResource created on azure + // for more information of creating LocalRulestackResource, please refer to the document of LocalRulestackResource string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rgopenapi"; + string localRulestackName = "lrs1"; + ResourceIdentifier localRulestackResourceId = LocalRulestackResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, localRulestackName); + LocalRulestackResource localRulestack = client.GetLocalRulestackResource(localRulestackResourceId); - // invoke the operation and iterate over the result - await foreach (LocalRulestackResource item in subscriptionResource.GetLocalRulestacksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + LocalRulestackResource result = await localRulestack.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLocalRulestacks_LocalRulestacksListBySubscriptionMinimumSetGen() + public async Task Get_LocalRulestacksGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this LocalRulestackResource created on azure + // for more information of creating LocalRulestackResource, please refer to the document of LocalRulestackResource string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rgopenapi"; + string localRulestackName = "lrs1"; + ResourceIdentifier localRulestackResourceId = LocalRulestackResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, localRulestackName); + LocalRulestackResource localRulestack = client.GetLocalRulestackResource(localRulestackResourceId); - // invoke the operation and iterate over the result - await foreach (LocalRulestackResource item in subscriptionResource.GetLocalRulestacksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + LocalRulestackResource result = await localRulestack.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LocalRulestacksGetMaximumSetGen() + public async Task Delete_LocalRulestacksDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,21 +98,17 @@ public async Task Get_LocalRulestacksGetMaximumSetGen() LocalRulestackResource localRulestack = client.GetLocalRulestackResource(localRulestackResourceId); // invoke the operation - LocalRulestackResource result = await localRulestack.GetAsync(); + await localRulestack.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LocalRulestacksGetMinimumSetGen() + public async Task Delete_LocalRulestacksDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Get_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,13 +124,9 @@ public async Task Get_LocalRulestacksGetMinimumSetGen() LocalRulestackResource localRulestack = client.GetLocalRulestackResource(localRulestackResourceId); // invoke the operation - LocalRulestackResource result = await localRulestack.GetAsync(); + await localRulestack.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -161,32 +150,29 @@ public async Task Update_LocalRulestacksUpdateMaximumSetGen() LocalRulestackResource localRulestack = client.GetLocalRulestackResource(localRulestackResourceId); // invoke the operation - LocalRulestackPatch patch = new LocalRulestackPatch() + LocalRulestackPatch patch = new LocalRulestackPatch { Identity = new ManagedServiceIdentity("None") { UserAssignedIdentities = { -[new ResourceIdentifier("key16")] = new UserAssignedIdentity(), +[new ResourceIdentifier("key16")] = new UserAssignedIdentity() }, }, Tags = { -["tagName"] = "value", +["tagName"] = "value" }, - Properties = new LocalRulestackUpdateProperties() + Properties = new LocalRulestackUpdateProperties { PanETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c12"), PanLocation = new AzureLocation("eastus"), Scope = RulestackScopeType.Local, - AssociatedSubscriptions = -{ -"2bf4a339-294d-4c25-b0b2-ef649e9f5c27" -}, + AssociatedSubscriptions = { "2bf4a339-294d-4c25-b0b2-ef649e9f5c27" }, Description = "local rulestacks", DefaultMode = RuleCreationDefaultMode.IPS, MinAppIdVersion = "8.5.3", - SecurityServices = new RulestackSecurityServices() + SecurityServices = new RulestackSecurityServices { VulnerabilityProfile = "default", AntiSpywareProfile = "default", @@ -239,58 +225,6 @@ public async Task Update_LocalRulestacksUpdateMinimumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_LocalRulestacksDeleteMaximumSetGen() - { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this LocalRulestackResource created on azure - // for more information of creating LocalRulestackResource, please refer to the document of LocalRulestackResource - string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; - string resourceGroupName = "rgopenapi"; - string localRulestackName = "lrs1"; - ResourceIdentifier localRulestackResourceId = LocalRulestackResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, localRulestackName); - LocalRulestackResource localRulestack = client.GetLocalRulestackResource(localRulestackResourceId); - - // invoke the operation - await localRulestack.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_LocalRulestacksDeleteMinimumSetGen() - { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRulestacks_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this LocalRulestackResource created on azure - // for more information of creating LocalRulestackResource, please refer to the document of LocalRulestackResource - string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; - string resourceGroupName = "rgopenapi"; - string localRulestackName = "lrs1"; - ResourceIdentifier localRulestackResourceId = LocalRulestackResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, localRulestackName); - LocalRulestackResource localRulestack = client.GetLocalRulestackResource(localRulestackResourceId); - - // invoke the operation - await localRulestack.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Commit_LocalRulestacksCommitMaximumSetGen() diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackRuleCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackRuleCollection.cs index ef335e970f72d..2aad8075e3b33 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackRuleCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LocalRulestackRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LocalRulesListByLocalRulestacksMaximumSetGen() + public async Task CreateOrUpdate_LocalRulesCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_ListByLocalRulestacks_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRules_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,57 @@ public async Task GetAll_LocalRulesListByLocalRulestacksMaximumSetGen() // get the collection of this LocalRulestackRuleResource LocalRulestackRuleCollection collection = localRulestack.GetLocalRulestackRules(); - // invoke the operation and iterate over the result - await foreach (LocalRulestackRuleResource item in collection.GetAllAsync()) + // invoke the operation + string priority = "1"; + LocalRulestackRuleData data = new LocalRulestackRuleData("localRule1") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), + Description = "description of local rule", + RuleState = RulestackStateType.Disabled, + Source = new SourceAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + }, + NegateSource = FirewallBooleanType.True, + Destination = new DestinationAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + FqdnLists = { "FQDN1" }, + }, + NegateDestination = FirewallBooleanType.True, + Applications = { "app1" }, + Category = new EdlMatchCategory(new string[] { "https://microsoft.com" }, new string[] { "feed" }), + Protocol = "HTTP", + ProtocolPortList = { "80" }, + InboundInspectionCertificate = "cert1", + AuditComment = "example comment", + ActionType = RulestackActionType.Allow, + EnableLogging = RulestackStateType.Disabled, + DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, + Tags = { new RulestackTagInfo("keyName", "value") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); + LocalRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LocalRulesListByLocalRulestacksMinimumSetGen() + public async Task CreateOrUpdate_LocalRulesCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_ListByLocalRulestacks_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRules_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +107,17 @@ public async Task GetAll_LocalRulesListByLocalRulestacksMinimumSetGen() // get the collection of this LocalRulestackRuleResource LocalRulestackRuleCollection collection = localRulestack.GetLocalRulestackRules(); - // invoke the operation and iterate over the result - await foreach (LocalRulestackRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string priority = "1"; + LocalRulestackRuleData data = new LocalRulestackRuleData("localRule1"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); + LocalRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -124,9 +156,9 @@ public async Task Get_LocalRulesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LocalRulesGetMaximumSetGen() + public async Task Get_LocalRulesGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Get_MinimumSet_Gen.json // this example is just showing the usage of "LocalRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -147,17 +179,21 @@ public async Task Exists_LocalRulesGetMaximumSetGen() // invoke the operation string priority = "1"; - bool result = await collection.ExistsAsync(priority); + LocalRulestackRuleResource result = await collection.GetAsync(priority); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LocalRulesGetMaximumSetGen() + public async Task GetAll_LocalRulesListByLocalRulestacksMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Get_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_ListByLocalRulestacks_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRules_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -175,31 +211,25 @@ public async Task GetIfExists_LocalRulesGetMaximumSetGen() // get the collection of this LocalRulestackRuleResource LocalRulestackRuleCollection collection = localRulestack.GetLocalRulestackRules(); - // invoke the operation - string priority = "1"; - NullableResponse response = await collection.GetIfExistsAsync(priority); - LocalRulestackRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (LocalRulestackRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LocalRulestackRuleData resourceData = result.Data; + LocalRulestackRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LocalRulesGetMinimumSetGen() + public async Task GetAll_LocalRulesListByLocalRulestacksMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Get_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_ListByLocalRulestacks_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRules_ListByLocalRulestacks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,22 +247,24 @@ public async Task Get_LocalRulesGetMinimumSetGen() // get the collection of this LocalRulestackRuleResource LocalRulestackRuleCollection collection = localRulestack.GetLocalRulestackRules(); - // invoke the operation - string priority = "1"; - LocalRulestackRuleResource result = await collection.GetAsync(priority); + // invoke the operation and iterate over the result + await foreach (LocalRulestackRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LocalRulesGetMinimumSetGen() + public async Task Exists_LocalRulesGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Get_MaximumSet_Gen.json // this example is just showing the usage of "LocalRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -260,7 +292,7 @@ public async Task Exists_LocalRulesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LocalRulesGetMinimumSetGen() + public async Task Exists_LocalRulesGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Get_MinimumSet_Gen.json // this example is just showing the usage of "LocalRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -283,29 +315,17 @@ public async Task GetIfExists_LocalRulesGetMinimumSetGen() // invoke the operation string priority = "1"; - NullableResponse response = await collection.GetIfExistsAsync(priority); - LocalRulestackRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(priority); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LocalRulesCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_LocalRulesGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Get_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -325,97 +345,29 @@ public async Task CreateOrUpdate_LocalRulesCreateOrUpdateMaximumSetGen() // invoke the operation string priority = "1"; - LocalRulestackRuleData data = new LocalRulestackRuleData("localRule1") - { - ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), - Description = "description of local rule", - RuleState = RulestackStateType.Disabled, - Source = new SourceAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - }, - NegateSource = FirewallBooleanType.True, - Destination = new DestinationAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - FqdnLists = -{ -"FQDN1" -}, - }, - NegateDestination = FirewallBooleanType.True, - Applications = -{ -"app1" -}, - Category = new EdlMatchCategory(new string[] + NullableResponse response = await collection.GetIfExistsAsync(priority); + LocalRulestackRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { -"https://microsoft.com" - }, new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"feed" - }), - Protocol = "HTTP", - ProtocolPortList = -{ -"80" -}, - InboundInspectionCertificate = "cert1", - AuditComment = "example comment", - ActionType = RulestackActionType.Allow, - EnableLogging = RulestackStateType.Disabled, - DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, - Tags = -{ -new RulestackTagInfo("keyName","value") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); - LocalRulestackRuleResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LocalRulesCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_LocalRulesGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Get_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -435,15 +387,21 @@ public async Task CreateOrUpdate_LocalRulesCreateOrUpdateMinimumSetGen() // invoke the operation string priority = "1"; - LocalRulestackRuleData data = new LocalRulestackRuleData("localRule1"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); - LocalRulestackRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(priority); + LocalRulestackRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackRuleResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackRuleResource.cs index e450b5b196b62..9d17eba74ceac 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackRuleResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_LocalRulestackRuleResource.cs @@ -80,10 +80,10 @@ public async Task Get_LocalRulesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_LocalRulesCreateOrUpdateMaximumSetGen() + public async Task Delete_LocalRulesDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,97 +100,17 @@ public async Task Update_LocalRulesCreateOrUpdateMaximumSetGen() LocalRulestackRuleResource localRulestackRule = client.GetLocalRulestackRuleResource(localRulestackRuleResourceId); // invoke the operation - LocalRulestackRuleData data = new LocalRulestackRuleData("localRule1") - { - ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), - Description = "description of local rule", - RuleState = RulestackStateType.Disabled, - Source = new SourceAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - }, - NegateSource = FirewallBooleanType.True, - Destination = new DestinationAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - FqdnLists = -{ -"FQDN1" -}, - }, - NegateDestination = FirewallBooleanType.True, - Applications = -{ -"app1" -}, - Category = new EdlMatchCategory(new string[] - { -"https://microsoft.com" - }, new string[] - { -"feed" - }), - Protocol = "HTTP", - ProtocolPortList = -{ -"80" -}, - InboundInspectionCertificate = "cert1", - AuditComment = "example comment", - ActionType = RulestackActionType.Allow, - EnableLogging = RulestackStateType.Disabled, - DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, - Tags = -{ -new RulestackTagInfo("keyName","value") -}, - }; - ArmOperation lro = await localRulestackRule.UpdateAsync(WaitUntil.Completed, data); - LocalRulestackRuleResource result = lro.Value; + await localRulestackRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_LocalRulesCreateOrUpdateMinimumSetGen() + public async Task Delete_LocalRulesDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -207,23 +127,17 @@ public async Task Update_LocalRulesCreateOrUpdateMinimumSetGen() LocalRulestackRuleResource localRulestackRule = client.GetLocalRulestackRuleResource(localRulestackRuleResourceId); // invoke the operation - LocalRulestackRuleData data = new LocalRulestackRuleData("localRule1"); - ArmOperation lro = await localRulestackRule.UpdateAsync(WaitUntil.Completed, data); - LocalRulestackRuleResource result = lro.Value; + await localRulestackRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_LocalRulesDeleteMaximumSetGen() + public async Task Update_LocalRulesCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "LocalRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -240,17 +154,55 @@ public async Task Delete_LocalRulesDeleteMaximumSetGen() LocalRulestackRuleResource localRulestackRule = client.GetLocalRulestackRuleResource(localRulestackRuleResourceId); // invoke the operation - await localRulestackRule.DeleteAsync(WaitUntil.Completed); + LocalRulestackRuleData data = new LocalRulestackRuleData("localRule1") + { + ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), + Description = "description of local rule", + RuleState = RulestackStateType.Disabled, + Source = new SourceAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + }, + NegateSource = FirewallBooleanType.True, + Destination = new DestinationAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + FqdnLists = { "FQDN1" }, + }, + NegateDestination = FirewallBooleanType.True, + Applications = { "app1" }, + Category = new EdlMatchCategory(new string[] { "https://microsoft.com" }, new string[] { "feed" }), + Protocol = "HTTP", + ProtocolPortList = { "80" }, + InboundInspectionCertificate = "cert1", + AuditComment = "example comment", + ActionType = RulestackActionType.Allow, + EnableLogging = RulestackStateType.Disabled, + DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, + Tags = { new RulestackTagInfo("keyName", "value") }, + }; + ArmOperation lro = await localRulestackRule.UpdateAsync(WaitUntil.Completed, data); + LocalRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_LocalRulesDeleteMinimumSetGen() + public async Task Update_LocalRulesCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "LocalRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRules_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -267,9 +219,15 @@ public async Task Delete_LocalRulesDeleteMinimumSetGen() LocalRulestackRuleResource localRulestackRule = client.GetLocalRulestackRuleResource(localRulestackRuleResourceId); // invoke the operation - await localRulestackRule.DeleteAsync(WaitUntil.Completed); + LocalRulestackRuleData data = new LocalRulestackRuleData("localRule1"); + ArmOperation lro = await localRulestackRule.UpdateAsync(WaitUntil.Completed, data); + LocalRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PaloAltoNetworksFirewallCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PaloAltoNetworksFirewallCollection.cs index 2f82520c03860..b630389705160 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PaloAltoNetworksFirewallCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PaloAltoNetworksFirewallCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_PaloAltoNetworksFirewallCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FirewallsListByResourceGroupMaximumSetGen() + public async Task CreateOrUpdate_FirewallsCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "Firewalls_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "Firewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,129 @@ public async Task GetAll_FirewallsListByResourceGroupMaximumSetGen() // get the collection of this PaloAltoNetworksFirewallResource PaloAltoNetworksFirewallCollection collection = resourceGroupResource.GetPaloAltoNetworksFirewalls(); - // invoke the operation and iterate over the result - await foreach (PaloAltoNetworksFirewallResource item in collection.GetAllAsync()) + // invoke the operation + string firewallName = "firewall1"; + PaloAltoNetworksFirewallData data = new PaloAltoNetworksFirewallData(new AzureLocation("eastus"), new FirewallNetworkProfile(FirewallNetworkType.Vnet, new IPAddressInfo[] { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } +new IPAddressInfo +{ +ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-PublicIp1"), +Address = "20.22.92.11", +} + }, AllowEgressNatType.Enabled) + { + VnetConfiguration = new FirewallVnetConfiguration(new IPAddressSpaceInfo + { + ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet"), + AddressSpace = "10.1.0.0/16", + }, new IPAddressSpaceInfo + { + ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet"), + AddressSpace = "10.1.1.0/24", + }, new IPAddressSpaceInfo + { + ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), + AddressSpace = "10.1.1.0/24", + }) + { + IPOfTrustSubnetForUdr = new IPAddressInfo + { + ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), + Address = "10.1.1.0/24", + }, + }, + VwanConfiguration = new FirewallVwanConfiguration(new IPAddressSpaceInfo + { + ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), + AddressSpace = "10.1.1.0/24", + }) + { + NetworkVirtualApplianceId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", + TrustSubnet = new IPAddressSpaceInfo + { + ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet"), + AddressSpace = "10.1.1.0/24", + }, + UnTrustSubnet = new IPAddressSpaceInfo + { + ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), + AddressSpace = "10.1.1.0/24", + }, + IPOfTrustSubnetForUdr = new IPAddressInfo + { + ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), + Address = "10.1.1.0/24", + }, + }, + EgressNatIP = {new IPAddressInfo +{ +ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1"), +Address = "20.22.92.111", +}}, + TrustedRanges = { "20.22.92.11" }, + }, new FirewallDnsSettings + { + EnableDnsProxy = AllowDnsProxyType.Disabled, + EnabledDnsType = EnabledDnsType.Custom, + DnsServers = {new IPAddressInfo +{ +ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1"), +Address = "20.22.92.111", +}}, + }, new FirewallBillingPlanInfo(FirewallBillingCycle.Monthly, "liftrpantestplan") + { + UsageType = FirewallBillingPlanUsageType.Payg, + }, new PanFirewallMarketplaceDetails("liftr-pan-ame-test", "isvtestuklegacy") + { + MarketplaceSubscriptionStatus = MarketplaceSubscriptionStatus.PendingFulfillmentStart, + }) + { + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("key16")] = new UserAssignedIdentity() +}, + }, + PanETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c12"), + IsPanoramaManaged = FirewallBooleanType.True, + PanoramaConfig = new FirewallPanoramaConfiguration("bas64EncodedString"), + AssociatedRulestack = new RulestackDetails + { + ResourceId = new ResourceIdentifier("lrs1"), + RulestackId = "PANRSID", + Location = new AzureLocation("eastus"), + }, + FrontEndSettings = {new FirewallFrontendSetting("frontendsetting11", FirewallProtocolType.Tcp, new FirewallEndpointConfiguration("80", new IPAddressInfo +{ +ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp1"), +Address = "20.22.91.251", +}), new FirewallEndpointConfiguration("80", new IPAddressInfo +{ +ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp2"), +Address = "20.22.32.136", +}))}, + Tags = +{ +["tagName"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallName, data); + PaloAltoNetworksFirewallResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PaloAltoNetworksFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FirewallsListByResourceGroupMinimumSetGen() + public async Task CreateOrUpdate_FirewallsCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "Firewalls_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "Firewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +179,24 @@ public async Task GetAll_FirewallsListByResourceGroupMinimumSetGen() // get the collection of this PaloAltoNetworksFirewallResource PaloAltoNetworksFirewallCollection collection = resourceGroupResource.GetPaloAltoNetworksFirewalls(); - // invoke the operation and iterate over the result - await foreach (PaloAltoNetworksFirewallResource item in collection.GetAllAsync()) + // invoke the operation + string firewallName = "firewall1"; + PaloAltoNetworksFirewallData data = new PaloAltoNetworksFirewallData(new AzureLocation("eastus"), new FirewallNetworkProfile(FirewallNetworkType.Vnet, new IPAddressInfo[] { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } +new IPAddressInfo +{ +ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-PublicIp1"), +Address = "20.22.92.11", +} + }, AllowEgressNatType.Enabled), new FirewallDnsSettings(), new FirewallBillingPlanInfo(FirewallBillingCycle.Monthly, "liftrpantestplan"), new PanFirewallMarketplaceDetails("liftr-pan-ame-test", "isvtestuklegacy")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallName, data); + PaloAltoNetworksFirewallResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PaloAltoNetworksFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -123,9 +234,9 @@ public async Task Get_FirewallsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FirewallsGetMaximumSetGen() + public async Task Get_FirewallsGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MinimumSet_Gen.json // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -145,17 +256,21 @@ public async Task Exists_FirewallsGetMaximumSetGen() // invoke the operation string firewallName = "firewall1"; - bool result = await collection.ExistsAsync(firewallName); + PaloAltoNetworksFirewallResource result = await collection.GetAsync(firewallName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PaloAltoNetworksFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FirewallsGetMaximumSetGen() + public async Task GetAll_FirewallsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "Firewalls_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,31 +287,25 @@ public async Task GetIfExists_FirewallsGetMaximumSetGen() // get the collection of this PaloAltoNetworksFirewallResource PaloAltoNetworksFirewallCollection collection = resourceGroupResource.GetPaloAltoNetworksFirewalls(); - // invoke the operation - string firewallName = "firewall1"; - NullableResponse response = await collection.GetIfExistsAsync(firewallName); - PaloAltoNetworksFirewallResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PaloAltoNetworksFirewallResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = result.Data; + PaloAltoNetworksFirewallData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FirewallsGetMinimumSetGen() + public async Task GetAll_FirewallsListByResourceGroupMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MinimumSet_Gen.json - // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "Firewalls_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,22 +322,24 @@ public async Task Get_FirewallsGetMinimumSetGen() // get the collection of this PaloAltoNetworksFirewallResource PaloAltoNetworksFirewallCollection collection = resourceGroupResource.GetPaloAltoNetworksFirewalls(); - // invoke the operation - string firewallName = "firewall1"; - PaloAltoNetworksFirewallResource result = await collection.GetAsync(firewallName); + // invoke the operation and iterate over the result + await foreach (PaloAltoNetworksFirewallResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PaloAltoNetworksFirewallData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FirewallsGetMinimumSetGen() + public async Task Exists_FirewallsGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MaximumSet_Gen.json // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -255,7 +366,7 @@ public async Task Exists_FirewallsGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FirewallsGetMinimumSetGen() + public async Task Exists_FirewallsGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MinimumSet_Gen.json // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. @@ -277,29 +388,17 @@ public async Task GetIfExists_FirewallsGetMinimumSetGen() // invoke the operation string firewallName = "firewall1"; - NullableResponse response = await collection.GetIfExistsAsync(firewallName); - PaloAltoNetworksFirewallResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(firewallName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FirewallsCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_FirewallsGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "Firewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -318,139 +417,29 @@ public async Task CreateOrUpdate_FirewallsCreateOrUpdateMaximumSetGen() // invoke the operation string firewallName = "firewall1"; - PaloAltoNetworksFirewallData data = new PaloAltoNetworksFirewallData(new AzureLocation("eastus"), new FirewallNetworkProfile(FirewallNetworkType.Vnet, new IPAddressInfo[] - { -new IPAddressInfo() -{ -ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-PublicIp1"), -Address = "20.22.92.11", -} - }, AllowEgressNatType.Enabled) - { - VnetConfiguration = new FirewallVnetConfiguration(new IPAddressSpaceInfo() - { - ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet"), - AddressSpace = "10.1.0.0/16", - }, new IPAddressSpaceInfo() - { - ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet"), - AddressSpace = "10.1.1.0/24", - }, new IPAddressSpaceInfo() - { - ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), - AddressSpace = "10.1.1.0/24", - }) - { - IPOfTrustSubnetForUdr = new IPAddressInfo() - { - ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), - Address = "10.1.1.0/24", - }, - }, - VwanConfiguration = new FirewallVwanConfiguration(new IPAddressSpaceInfo() - { - ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), - AddressSpace = "10.1.1.0/24", - }) - { - NetworkVirtualApplianceId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", - TrustSubnet = new IPAddressSpaceInfo() - { - ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet"), - AddressSpace = "10.1.1.0/24", - }, - UnTrustSubnet = new IPAddressSpaceInfo() - { - ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), - AddressSpace = "10.1.1.0/24", - }, - IPOfTrustSubnetForUdr = new IPAddressInfo() - { - ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), - Address = "10.1.1.0/24", - }, - }, - EgressNatIP = -{ -new IPAddressInfo() -{ -ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1"), -Address = "20.22.92.111", -} -}, - TrustedRanges = -{ -"20.22.92.11" -}, - }, new FirewallDnsSettings() - { - EnableDnsProxy = AllowDnsProxyType.Disabled, - EnabledDnsType = EnabledDnsType.Custom, - DnsServers = -{ -new IPAddressInfo() -{ -ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1"), -Address = "20.22.92.111", -} -}, - }, new FirewallBillingPlanInfo(FirewallBillingCycle.Monthly, "liftrpantestplan") - { - UsageType = FirewallBillingPlanUsageType.Payg, - }, new PanFirewallMarketplaceDetails("liftr-pan-ame-test", "isvtestuklegacy") + NullableResponse response = await collection.GetIfExistsAsync(firewallName); + PaloAltoNetworksFirewallResource result = response.HasValue ? response.Value : null; + + if (result == null) { - MarketplaceSubscriptionStatus = MarketplaceSubscriptionStatus.PendingFulfillmentStart, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Identity = new ManagedServiceIdentity("None") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("key16")] = new UserAssignedIdentity(), -}, - }, - PanETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c12"), - IsPanoramaManaged = FirewallBooleanType.True, - PanoramaConfig = new FirewallPanoramaConfiguration("bas64EncodedString"), - AssociatedRulestack = new RulestackDetails() - { - ResourceId = new ResourceIdentifier("lrs1"), - RulestackId = "PANRSID", - Location = new AzureLocation("eastus"), - }, - FrontEndSettings = -{ -new FirewallFrontendSetting("frontendsetting11",FirewallProtocolType.Tcp,new FirewallEndpointConfiguration("80",new IPAddressInfo() -{ -ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp1"), -Address = "20.22.91.251", -}),new FirewallEndpointConfiguration("80",new IPAddressInfo() -{ -ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp2"), -Address = "20.22.32.136", -})) -}, - Tags = -{ -["tagName"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallName, data); - PaloAltoNetworksFirewallResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PaloAltoNetworksFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FirewallsCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_FirewallsGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "Firewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MinimumSet_Gen.json + // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -469,22 +458,21 @@ public async Task CreateOrUpdate_FirewallsCreateOrUpdateMinimumSetGen() // invoke the operation string firewallName = "firewall1"; - PaloAltoNetworksFirewallData data = new PaloAltoNetworksFirewallData(new AzureLocation("eastus"), new FirewallNetworkProfile(FirewallNetworkType.Vnet, new IPAddressInfo[] - { -new IPAddressInfo() -{ -ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-PublicIp1"), -Address = "20.22.92.11", -} - }, AllowEgressNatType.Enabled), new FirewallDnsSettings(), new FirewallBillingPlanInfo(FirewallBillingCycle.Monthly, "liftrpantestplan"), new PanFirewallMarketplaceDetails("liftr-pan-ame-test", "isvtestuklegacy")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallName, data); - PaloAltoNetworksFirewallResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(firewallName); + PaloAltoNetworksFirewallResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PaloAltoNetworksFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PaloAltoNetworksFirewallResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PaloAltoNetworksFirewallResource.cs index 3552af5277a0f..48a7f717bff53 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PaloAltoNetworksFirewallResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PaloAltoNetworksFirewallResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.PaloAltoNetworks.Ngfw.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.PaloAltoNetworks.Ngfw.Samples @@ -20,72 +19,70 @@ public partial class Sample_PaloAltoNetworksFirewallResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetPaloAltoNetworksFirewalls_FirewallsListBySubscriptionMaximumSetGen() + public async Task Get_FirewallsGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "Firewalls_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this PaloAltoNetworksFirewallResource created on azure + // for more information of creating PaloAltoNetworksFirewallResource, please refer to the document of PaloAltoNetworksFirewallResource string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "firewall-rg"; + string firewallName = "firewall1"; + ResourceIdentifier paloAltoNetworksFirewallResourceId = PaloAltoNetworksFirewallResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallName); + PaloAltoNetworksFirewallResource paloAltoNetworksFirewall = client.GetPaloAltoNetworksFirewallResource(paloAltoNetworksFirewallResourceId); - // invoke the operation and iterate over the result - await foreach (PaloAltoNetworksFirewallResource item in subscriptionResource.GetPaloAltoNetworksFirewallsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + PaloAltoNetworksFirewallResource result = await paloAltoNetworksFirewall.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PaloAltoNetworksFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetPaloAltoNetworksFirewalls_FirewallsListBySubscriptionMinimumSetGen() + public async Task Get_FirewallsGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "Firewalls_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MinimumSet_Gen.json + // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this PaloAltoNetworksFirewallResource created on azure + // for more information of creating PaloAltoNetworksFirewallResource, please refer to the document of PaloAltoNetworksFirewallResource string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "firewall-rg"; + string firewallName = "firewall1"; + ResourceIdentifier paloAltoNetworksFirewallResourceId = PaloAltoNetworksFirewallResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallName); + PaloAltoNetworksFirewallResource paloAltoNetworksFirewall = client.GetPaloAltoNetworksFirewallResource(paloAltoNetworksFirewallResourceId); - // invoke the operation and iterate over the result - await foreach (PaloAltoNetworksFirewallResource item in subscriptionResource.GetPaloAltoNetworksFirewallsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + PaloAltoNetworksFirewallResource result = await paloAltoNetworksFirewall.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PaloAltoNetworksFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FirewallsGetMaximumSetGen() + public async Task Delete_FirewallsDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "Firewalls_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,21 +98,17 @@ public async Task Get_FirewallsGetMaximumSetGen() PaloAltoNetworksFirewallResource paloAltoNetworksFirewall = client.GetPaloAltoNetworksFirewallResource(paloAltoNetworksFirewallResourceId); // invoke the operation - PaloAltoNetworksFirewallResource result = await paloAltoNetworksFirewall.GetAsync(); + await paloAltoNetworksFirewall.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FirewallsGetMinimumSetGen() + public async Task Delete_FirewallsDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Get_MinimumSet_Gen.json - // this example is just showing the usage of "Firewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "Firewalls_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,13 +124,9 @@ public async Task Get_FirewallsGetMinimumSetGen() PaloAltoNetworksFirewallResource paloAltoNetworksFirewall = client.GetPaloAltoNetworksFirewallResource(paloAltoNetworksFirewallResourceId); // invoke the operation - PaloAltoNetworksFirewallResource result = await paloAltoNetworksFirewall.GetAsync(); + await paloAltoNetworksFirewall.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PaloAltoNetworksFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -161,120 +150,108 @@ public async Task Update_FirewallsUpdateMaximumSetGen() PaloAltoNetworksFirewallResource paloAltoNetworksFirewall = client.GetPaloAltoNetworksFirewallResource(paloAltoNetworksFirewallResourceId); // invoke the operation - PaloAltoNetworksFirewallPatch patch = new PaloAltoNetworksFirewallPatch() + PaloAltoNetworksFirewallPatch patch = new PaloAltoNetworksFirewallPatch { Identity = new ManagedServiceIdentity("None") { UserAssignedIdentities = { -[new ResourceIdentifier("key16")] = new UserAssignedIdentity(), +[new ResourceIdentifier("key16")] = new UserAssignedIdentity() }, }, Tags = { -["tagName"] = "value", +["tagName"] = "value" }, - Properties = new FirewallUpdateProperties() + Properties = new FirewallUpdateProperties { PanETag = new ETag("2bf4a339-294d-4c25-b0b2-ef649e9f5c12"), NetworkProfile = new FirewallNetworkProfile(FirewallNetworkType.Vnet, new IPAddressInfo[] { -new IPAddressInfo() +new IPAddressInfo { ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-PublicIp1"), Address = "20.22.92.11", } }, AllowEgressNatType.Enabled) { - VnetConfiguration = new FirewallVnetConfiguration(new IPAddressSpaceInfo() + VnetConfiguration = new FirewallVnetConfiguration(new IPAddressSpaceInfo { ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet"), AddressSpace = "10.1.0.0/16", - }, new IPAddressSpaceInfo() + }, new IPAddressSpaceInfo { ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet"), AddressSpace = "10.1.1.0/24", - }, new IPAddressSpaceInfo() + }, new IPAddressSpaceInfo { ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), AddressSpace = "10.1.1.0/24", }) { - IPOfTrustSubnetForUdr = new IPAddressInfo() + IPOfTrustSubnetForUdr = new IPAddressInfo { ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), Address = "10.1.1.0/24", }, }, - VwanConfiguration = new FirewallVwanConfiguration(new IPAddressSpaceInfo() + VwanConfiguration = new FirewallVwanConfiguration(new IPAddressSpaceInfo { ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), AddressSpace = "10.1.1.0/24", }) { NetworkVirtualApplianceId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c12", - TrustSubnet = new IPAddressSpaceInfo() + TrustSubnet = new IPAddressSpaceInfo { ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-trust-subnet"), AddressSpace = "10.1.1.0/24", }, - UnTrustSubnet = new IPAddressSpaceInfo() + UnTrustSubnet = new IPAddressSpaceInfo { ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), AddressSpace = "10.1.1.0/24", }, - IPOfTrustSubnetForUdr = new IPAddressInfo() + IPOfTrustSubnetForUdr = new IPAddressInfo { ResourceId = new ResourceIdentifier("/subscriptions/2bf4a339-294d-4c25-b0b2-ef649e9f5c27/resourceGroups/os-liftr-integration/providers/Microsoft.Network/virtualNetworks/os-liftr-integration-vnet/subnets/os-liftr-integration-untrust-subnet"), Address = "10.1.1.0/24", }, }, - EgressNatIP = -{ -new IPAddressInfo() + EgressNatIP = {new IPAddressInfo { ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1"), Address = "20.22.92.111", -} -}, - TrustedRanges = -{ -"20.22.92.11" -}, +}}, + TrustedRanges = { "20.22.92.11" }, }, IsPanoramaManaged = FirewallBooleanType.True, PanoramaConfig = new FirewallPanoramaConfiguration("bas64EncodedString"), - AssociatedRulestack = new RulestackDetails() + AssociatedRulestack = new RulestackDetails { ResourceId = new ResourceIdentifier("aaaaaaaaaa"), RulestackId = "aaaaaaaaaaaaaaaa", Location = new AzureLocation("eastus"), }, - DnsSettings = new FirewallDnsSettings() + DnsSettings = new FirewallDnsSettings { EnableDnsProxy = AllowDnsProxyType.Disabled, EnabledDnsType = EnabledDnsType.Custom, - DnsServers = -{ -new IPAddressInfo() + DnsServers = {new IPAddressInfo { ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-egressNatIp1"), Address = "20.22.92.111", -} -}, +}}, }, - FrontEndSettings = -{ -new FirewallFrontendSetting("frontendsetting11",FirewallProtocolType.Tcp,new FirewallEndpointConfiguration("80",new IPAddressInfo() + FrontEndSettings = {new FirewallFrontendSetting("frontendsetting11", FirewallProtocolType.Tcp, new FirewallEndpointConfiguration("80", new IPAddressInfo { ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp1"), Address = "20.22.91.251", -}),new FirewallEndpointConfiguration("80",new IPAddressInfo() +}), new FirewallEndpointConfiguration("80", new IPAddressInfo { ResourceId = new ResourceIdentifier("/subscriptions/01c7d41f-afaf-464e-8a8b-5c6f9f98cee8/resourceGroups/mj-liftr-integration/providers/Microsoft.Network/publicIPAddresses/mj-liftr-integration-frontendSettingIp2"), Address = "20.22.32.136", -})) -}, +}))}, PlanData = new FirewallBillingPlanInfo(FirewallBillingCycle.Weekly, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") { UsageType = FirewallBillingPlanUsageType.Payg, @@ -325,58 +302,6 @@ public async Task Update_FirewallsUpdateMinimumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_FirewallsDeleteMaximumSetGen() - { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "Firewalls_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PaloAltoNetworksFirewallResource created on azure - // for more information of creating PaloAltoNetworksFirewallResource, please refer to the document of PaloAltoNetworksFirewallResource - string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; - string resourceGroupName = "firewall-rg"; - string firewallName = "firewall1"; - ResourceIdentifier paloAltoNetworksFirewallResourceId = PaloAltoNetworksFirewallResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallName); - PaloAltoNetworksFirewallResource paloAltoNetworksFirewall = client.GetPaloAltoNetworksFirewallResource(paloAltoNetworksFirewallResourceId); - - // invoke the operation - await paloAltoNetworksFirewall.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_FirewallsDeleteMinimumSetGen() - { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "Firewalls_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PaloAltoNetworksFirewallResource created on azure - // for more information of creating PaloAltoNetworksFirewallResource, please refer to the document of PaloAltoNetworksFirewallResource - string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; - string resourceGroupName = "firewall-rg"; - string firewallName = "firewall1"; - ResourceIdentifier paloAltoNetworksFirewallResourceId = PaloAltoNetworksFirewallResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallName); - PaloAltoNetworksFirewallResource paloAltoNetworksFirewall = client.GetPaloAltoNetworksFirewallResource(paloAltoNetworksFirewallResourceId); - - // invoke the operation - await paloAltoNetworksFirewall.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetGlobalRulestack_FirewallsGetGlobalRulestackMaximumSetGen() @@ -555,24 +480,24 @@ public async Task SaveLogProfile_FirewallsSaveLogProfileMaximumSetGen() PaloAltoNetworksFirewallResource paloAltoNetworksFirewall = client.GetPaloAltoNetworksFirewallResource(paloAltoNetworksFirewallResourceId); // invoke the operation - FirewallLogSettings logSettings = new FirewallLogSettings() + FirewallLogSettings logSettings = new FirewallLogSettings { LogType = FirewallLogType.Traffic, LogOption = FirewallLogOption.SameDestination, - ApplicationInsights = new FirewallApplicationInsights() + ApplicationInsights = new FirewallApplicationInsights { Id = "aaaaaaaaaaaaaaaa", Key = "aaaaaaaaaaaaa", }, - CommonDestination = new FirewallLogDestination() + CommonDestination = new FirewallLogDestination { - StorageConfiguration = new StorageAccountConfiguration() + StorageConfiguration = new StorageAccountConfiguration { Id = new ResourceIdentifier("aaaaaaaaaaaaaaa"), SubscriptionId = "aaaaaaaaa", AccountName = "aaaaaaaaaaaaaaaaaaaaaaa", }, - EventHubConfiguration = new EventHubConfiguration() + EventHubConfiguration = new EventHubConfiguration { Id = new ResourceIdentifier("aaaaaaaaaa"), SubscriptionId = "aaaaaaaaaa", @@ -580,7 +505,7 @@ public async Task SaveLogProfile_FirewallsSaveLogProfileMaximumSetGen() NameSpace = "aaaaaaaaaaaaaaaaaaaaa", PolicyName = "aaaaaaaaaaaa", }, - MonitorConfiguration = new MonitorLogConfiguration() + MonitorConfiguration = new MonitorLogConfiguration { Id = new ResourceIdentifier("aaaaaaaaaaaaaaaaaaa"), SubscriptionId = "aaaaaaaaaaaaa", @@ -589,15 +514,15 @@ public async Task SaveLogProfile_FirewallsSaveLogProfileMaximumSetGen() SecondaryKey = "a", }, }, - TrafficLogDestination = new FirewallLogDestination() + TrafficLogDestination = new FirewallLogDestination { - StorageConfiguration = new StorageAccountConfiguration() + StorageConfiguration = new StorageAccountConfiguration { Id = new ResourceIdentifier("aaaaaaaaaaaaaaa"), SubscriptionId = "aaaaaaaaa", AccountName = "aaaaaaaaaaaaaaaaaaaaaaa", }, - EventHubConfiguration = new EventHubConfiguration() + EventHubConfiguration = new EventHubConfiguration { Id = new ResourceIdentifier("aaaaaaaaaa"), SubscriptionId = "aaaaaaaaaa", @@ -605,7 +530,7 @@ public async Task SaveLogProfile_FirewallsSaveLogProfileMaximumSetGen() NameSpace = "aaaaaaaaaaaaaaaaaaaaa", PolicyName = "aaaaaaaaaaaa", }, - MonitorConfiguration = new MonitorLogConfiguration() + MonitorConfiguration = new MonitorLogConfiguration { Id = new ResourceIdentifier("aaaaaaaaaaaaaaaaaaa"), SubscriptionId = "aaaaaaaaaaaaa", @@ -614,15 +539,15 @@ public async Task SaveLogProfile_FirewallsSaveLogProfileMaximumSetGen() SecondaryKey = "a", }, }, - ThreatLogDestination = new FirewallLogDestination() + ThreatLogDestination = new FirewallLogDestination { - StorageConfiguration = new StorageAccountConfiguration() + StorageConfiguration = new StorageAccountConfiguration { Id = new ResourceIdentifier("aaaaaaaaaaaaaaa"), SubscriptionId = "aaaaaaaaa", AccountName = "aaaaaaaaaaaaaaaaaaaaaaa", }, - EventHubConfiguration = new EventHubConfiguration() + EventHubConfiguration = new EventHubConfiguration { Id = new ResourceIdentifier("aaaaaaaaaa"), SubscriptionId = "aaaaaaaaaa", @@ -630,7 +555,7 @@ public async Task SaveLogProfile_FirewallsSaveLogProfileMaximumSetGen() NameSpace = "aaaaaaaaaaaaaaaaaaaaa", PolicyName = "aaaaaaaaaaaa", }, - MonitorConfiguration = new MonitorLogConfiguration() + MonitorConfiguration = new MonitorLogConfiguration { Id = new ResourceIdentifier("aaaaaaaaaaaaaaaaaaa"), SubscriptionId = "aaaaaaaaaaaaa", @@ -639,15 +564,15 @@ public async Task SaveLogProfile_FirewallsSaveLogProfileMaximumSetGen() SecondaryKey = "a", }, }, - DecryptLogDestination = new FirewallLogDestination() + DecryptLogDestination = new FirewallLogDestination { - StorageConfiguration = new StorageAccountConfiguration() + StorageConfiguration = new StorageAccountConfiguration { Id = new ResourceIdentifier("aaaaaaaaaaaaaaa"), SubscriptionId = "aaaaaaaaa", AccountName = "aaaaaaaaaaaaaaaaaaaaaaa", }, - EventHubConfiguration = new EventHubConfiguration() + EventHubConfiguration = new EventHubConfiguration { Id = new ResourceIdentifier("aaaaaaaaaa"), SubscriptionId = "aaaaaaaaaa", @@ -655,7 +580,7 @@ public async Task SaveLogProfile_FirewallsSaveLogProfileMaximumSetGen() NameSpace = "aaaaaaaaaaaaaaaaaaaaa", PolicyName = "aaaaaaaaaaaa", }, - MonitorConfiguration = new MonitorLogConfiguration() + MonitorConfiguration = new MonitorLogConfiguration { Id = new ResourceIdentifier("aaaaaaaaaaaaaaaaaaa"), SubscriptionId = "aaaaaaaaaaaaa", diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PostRulestackRuleCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PostRulestackRuleCollection.cs index 51060e686e948..a08b11a60c09a 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PostRulestackRuleCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PostRulestackRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PostRulestackRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PostRulesListMaximumSetGen() + public async Task CreateOrUpdate_PostRulesCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_List_MaximumSet_Gen.json - // this example is just showing the usage of "PostRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "PostRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,57 @@ public async Task GetAll_PostRulesListMaximumSetGen() // get the collection of this PostRulestackRuleResource PostRulestackRuleCollection collection = globalRulestack.GetPostRulestackRules(); - // invoke the operation and iterate over the result - await foreach (PostRulestackRuleResource item in collection.GetAllAsync()) + // invoke the operation + string priority = "1"; + PostRulestackRuleData data = new PostRulestackRuleData("postRule1") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostRulestackRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), + Description = "description of post rule", + RuleState = RulestackStateType.Disabled, + Source = new SourceAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + }, + NegateSource = FirewallBooleanType.True, + Destination = new DestinationAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + FqdnLists = { "FQDN1" }, + }, + NegateDestination = FirewallBooleanType.True, + Applications = { "app1" }, + Category = new EdlMatchCategory(new string[] { "https://microsoft.com" }, new string[] { "feed" }), + Protocol = "HTTP", + ProtocolPortList = { "80" }, + InboundInspectionCertificate = "cert1", + AuditComment = "example comment", + ActionType = RulestackActionType.Allow, + EnableLogging = RulestackStateType.Disabled, + DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, + Tags = { new RulestackTagInfo("keyName", "value") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); + PostRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PostRulesListMinimumSetGen() + public async Task CreateOrUpdate_PostRulesCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_List_MinimumSet_Gen.json - // this example is just showing the usage of "PostRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "PostRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,17 +103,17 @@ public async Task GetAll_PostRulesListMinimumSetGen() // get the collection of this PostRulestackRuleResource PostRulestackRuleCollection collection = globalRulestack.GetPostRulestackRules(); - // invoke the operation and iterate over the result - await foreach (PostRulestackRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostRulestackRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string priority = "1"; + PostRulestackRuleData data = new PostRulestackRuleData("postRule1"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); + PostRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -118,9 +150,9 @@ public async Task Get_PostRulesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PostRulesGetMaximumSetGen() + public async Task Get_PostRulesGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Get_MinimumSet_Gen.json // this example is just showing the usage of "PostRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -139,17 +171,21 @@ public async Task Exists_PostRulesGetMaximumSetGen() // invoke the operation string priority = "1"; - bool result = await collection.ExistsAsync(priority); + PostRulestackRuleResource result = await collection.GetAsync(priority); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PostRulesGetMaximumSetGen() + public async Task GetAll_PostRulesListMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Get_MaximumSet_Gen.json - // this example is just showing the usage of "PostRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_List_MaximumSet_Gen.json + // this example is just showing the usage of "PostRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,31 +201,25 @@ public async Task GetIfExists_PostRulesGetMaximumSetGen() // get the collection of this PostRulestackRuleResource PostRulestackRuleCollection collection = globalRulestack.GetPostRulestackRules(); - // invoke the operation - string priority = "1"; - NullableResponse response = await collection.GetIfExistsAsync(priority); - PostRulestackRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PostRulestackRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostRulestackRuleData resourceData = result.Data; + PostRulestackRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PostRulesGetMinimumSetGen() + public async Task GetAll_PostRulesListMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Get_MinimumSet_Gen.json - // this example is just showing the usage of "PostRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_List_MinimumSet_Gen.json + // this example is just showing the usage of "PostRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -205,22 +235,24 @@ public async Task Get_PostRulesGetMinimumSetGen() // get the collection of this PostRulestackRuleResource PostRulestackRuleCollection collection = globalRulestack.GetPostRulestackRules(); - // invoke the operation - string priority = "1"; - PostRulestackRuleResource result = await collection.GetAsync(priority); + // invoke the operation and iterate over the result + await foreach (PostRulestackRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostRulestackRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PostRulesGetMinimumSetGen() + public async Task Exists_PostRulesGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Get_MaximumSet_Gen.json // this example is just showing the usage of "PostRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -246,7 +278,7 @@ public async Task Exists_PostRulesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PostRulesGetMinimumSetGen() + public async Task Exists_PostRulesGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Get_MinimumSet_Gen.json // this example is just showing the usage of "PostRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -267,29 +299,17 @@ public async Task GetIfExists_PostRulesGetMinimumSetGen() // invoke the operation string priority = "1"; - NullableResponse response = await collection.GetIfExistsAsync(priority); - PostRulestackRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(priority); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PostRulesCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_PostRulesGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "PostRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PostRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -307,97 +327,29 @@ public async Task CreateOrUpdate_PostRulesCreateOrUpdateMaximumSetGen() // invoke the operation string priority = "1"; - PostRulestackRuleData data = new PostRulestackRuleData("postRule1") - { - ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), - Description = "description of post rule", - RuleState = RulestackStateType.Disabled, - Source = new SourceAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - }, - NegateSource = FirewallBooleanType.True, - Destination = new DestinationAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - FqdnLists = -{ -"FQDN1" -}, - }, - NegateDestination = FirewallBooleanType.True, - Applications = -{ -"app1" -}, - Category = new EdlMatchCategory(new string[] + NullableResponse response = await collection.GetIfExistsAsync(priority); + PostRulestackRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { -"https://microsoft.com" - }, new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"feed" - }), - Protocol = "HTTP", - ProtocolPortList = -{ -"80" -}, - InboundInspectionCertificate = "cert1", - AuditComment = "example comment", - ActionType = RulestackActionType.Allow, - EnableLogging = RulestackStateType.Disabled, - DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, - Tags = -{ -new RulestackTagInfo("keyName","value") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); - PostRulestackRuleResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PostRulesCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_PostRulesGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "PostRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Get_MinimumSet_Gen.json + // this example is just showing the usage of "PostRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -415,15 +367,21 @@ public async Task CreateOrUpdate_PostRulesCreateOrUpdateMinimumSetGen() // invoke the operation string priority = "1"; - PostRulestackRuleData data = new PostRulestackRuleData("postRule1"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); - PostRulestackRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(priority); + PostRulestackRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PostRulestackRuleResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PostRulestackRuleResource.cs index 3b32f784a2cea..6f5f357e1aebe 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PostRulestackRuleResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PostRulestackRuleResource.cs @@ -76,10 +76,10 @@ public async Task Get_PostRulesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PostRulesCreateOrUpdateMaximumSetGen() + public async Task Delete_PostRulesDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "PostRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "PostRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,97 +94,17 @@ public async Task Update_PostRulesCreateOrUpdateMaximumSetGen() PostRulestackRuleResource postRulestackRule = client.GetPostRulestackRuleResource(postRulestackRuleResourceId); // invoke the operation - PostRulestackRuleData data = new PostRulestackRuleData("postRule1") - { - ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), - Description = "description of post rule", - RuleState = RulestackStateType.Disabled, - Source = new SourceAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - }, - NegateSource = FirewallBooleanType.True, - Destination = new DestinationAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - FqdnLists = -{ -"FQDN1" -}, - }, - NegateDestination = FirewallBooleanType.True, - Applications = -{ -"app1" -}, - Category = new EdlMatchCategory(new string[] - { -"https://microsoft.com" - }, new string[] - { -"feed" - }), - Protocol = "HTTP", - ProtocolPortList = -{ -"80" -}, - InboundInspectionCertificate = "cert1", - AuditComment = "example comment", - ActionType = RulestackActionType.Allow, - EnableLogging = RulestackStateType.Disabled, - DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, - Tags = -{ -new RulestackTagInfo("keyName","value") -}, - }; - ArmOperation lro = await postRulestackRule.UpdateAsync(WaitUntil.Completed, data); - PostRulestackRuleResource result = lro.Value; + await postRulestackRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PostRulesCreateOrUpdateMinimumSetGen() + public async Task Delete_PostRulesDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "PostRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "PostRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,23 +119,17 @@ public async Task Update_PostRulesCreateOrUpdateMinimumSetGen() PostRulestackRuleResource postRulestackRule = client.GetPostRulestackRuleResource(postRulestackRuleResourceId); // invoke the operation - PostRulestackRuleData data = new PostRulestackRuleData("postRule1"); - ArmOperation lro = await postRulestackRule.UpdateAsync(WaitUntil.Completed, data); - PostRulestackRuleResource result = lro.Value; + await postRulestackRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PostRulesDeleteMaximumSetGen() + public async Task Update_PostRulesCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "PostRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "PostRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -230,17 +144,55 @@ public async Task Delete_PostRulesDeleteMaximumSetGen() PostRulestackRuleResource postRulestackRule = client.GetPostRulestackRuleResource(postRulestackRuleResourceId); // invoke the operation - await postRulestackRule.DeleteAsync(WaitUntil.Completed); + PostRulestackRuleData data = new PostRulestackRuleData("postRule1") + { + ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), + Description = "description of post rule", + RuleState = RulestackStateType.Disabled, + Source = new SourceAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + }, + NegateSource = FirewallBooleanType.True, + Destination = new DestinationAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + FqdnLists = { "FQDN1" }, + }, + NegateDestination = FirewallBooleanType.True, + Applications = { "app1" }, + Category = new EdlMatchCategory(new string[] { "https://microsoft.com" }, new string[] { "feed" }), + Protocol = "HTTP", + ProtocolPortList = { "80" }, + InboundInspectionCertificate = "cert1", + AuditComment = "example comment", + ActionType = RulestackActionType.Allow, + EnableLogging = RulestackStateType.Disabled, + DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, + Tags = { new RulestackTagInfo("keyName", "value") }, + }; + ArmOperation lro = await postRulestackRule.UpdateAsync(WaitUntil.Completed, data); + PostRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PostRulesDeleteMinimumSetGen() + public async Task Update_PostRulesCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "PostRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PostRules_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "PostRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -255,9 +207,15 @@ public async Task Delete_PostRulesDeleteMinimumSetGen() PostRulestackRuleResource postRulestackRule = client.GetPostRulestackRuleResource(postRulestackRuleResourceId); // invoke the operation - await postRulestackRule.DeleteAsync(WaitUntil.Completed); + PostRulestackRuleData data = new PostRulestackRuleData("postRule1"); + ArmOperation lro = await postRulestackRule.UpdateAsync(WaitUntil.Completed, data); + PostRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PreRulestackRuleCollection.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PreRulestackRuleCollection.cs index c3a6b05955403..3ee37d0c8378b 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PreRulestackRuleCollection.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PreRulestackRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PreRulestackRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PreRulesListMaximumSetGen() + public async Task CreateOrUpdate_PreRulesCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_List_MaximumSet_Gen.json - // this example is just showing the usage of "PreRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "PreRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,57 @@ public async Task GetAll_PreRulesListMaximumSetGen() // get the collection of this PreRulestackRuleResource PreRulestackRuleCollection collection = globalRulestack.GetPreRulestackRules(); - // invoke the operation and iterate over the result - await foreach (PreRulestackRuleResource item in collection.GetAllAsync()) + // invoke the operation + string priority = "1"; + PreRulestackRuleData data = new PreRulestackRuleData("preRule1") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PreRulestackRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), + Description = "description of pre rule", + RuleState = RulestackStateType.Disabled, + Source = new SourceAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + }, + NegateSource = FirewallBooleanType.True, + Destination = new DestinationAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + FqdnLists = { "FQDN1" }, + }, + NegateDestination = FirewallBooleanType.True, + Applications = { "app1" }, + Category = new EdlMatchCategory(new string[] { "https://microsoft.com" }, new string[] { "feed" }), + Protocol = "HTTP", + ProtocolPortList = { "80" }, + InboundInspectionCertificate = "cert1", + AuditComment = "example comment", + ActionType = RulestackActionType.Allow, + EnableLogging = RulestackStateType.Disabled, + DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, + Tags = { new RulestackTagInfo("keyName", "value") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); + PreRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PreRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PreRulesListMinimumSetGen() + public async Task CreateOrUpdate_PreRulesCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_List_MinimumSet_Gen.json - // this example is just showing the usage of "PreRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "PreRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,17 +103,17 @@ public async Task GetAll_PreRulesListMinimumSetGen() // get the collection of this PreRulestackRuleResource PreRulestackRuleCollection collection = globalRulestack.GetPreRulestackRules(); - // invoke the operation and iterate over the result - await foreach (PreRulestackRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PreRulestackRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string priority = "1"; + PreRulestackRuleData data = new PreRulestackRuleData("preRule1"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); + PreRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PreRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -118,9 +150,9 @@ public async Task Get_PreRulesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PreRulesGetMaximumSetGen() + public async Task Get_PreRulesGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Get_MaximumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Get_MinimumSet_Gen.json // this example is just showing the usage of "PreRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -139,17 +171,21 @@ public async Task Exists_PreRulesGetMaximumSetGen() // invoke the operation string priority = "1"; - bool result = await collection.ExistsAsync(priority); + PreRulestackRuleResource result = await collection.GetAsync(priority); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PreRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PreRulesGetMaximumSetGen() + public async Task GetAll_PreRulesListMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Get_MaximumSet_Gen.json - // this example is just showing the usage of "PreRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_List_MaximumSet_Gen.json + // this example is just showing the usage of "PreRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,31 +201,25 @@ public async Task GetIfExists_PreRulesGetMaximumSetGen() // get the collection of this PreRulestackRuleResource PreRulestackRuleCollection collection = globalRulestack.GetPreRulestackRules(); - // invoke the operation - string priority = "1"; - NullableResponse response = await collection.GetIfExistsAsync(priority); - PreRulestackRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PreRulestackRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PreRulestackRuleData resourceData = result.Data; + PreRulestackRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PreRulesGetMinimumSetGen() + public async Task GetAll_PreRulesListMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Get_MinimumSet_Gen.json - // this example is just showing the usage of "PreRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_List_MinimumSet_Gen.json + // this example is just showing the usage of "PreRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -205,22 +235,24 @@ public async Task Get_PreRulesGetMinimumSetGen() // get the collection of this PreRulestackRuleResource PreRulestackRuleCollection collection = globalRulestack.GetPreRulestackRules(); - // invoke the operation - string priority = "1"; - PreRulestackRuleResource result = await collection.GetAsync(priority); + // invoke the operation and iterate over the result + await foreach (PreRulestackRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PreRulestackRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PreRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PreRulesGetMinimumSetGen() + public async Task Exists_PreRulesGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Get_MinimumSet_Gen.json + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Get_MaximumSet_Gen.json // this example is just showing the usage of "PreRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -246,7 +278,7 @@ public async Task Exists_PreRulesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PreRulesGetMinimumSetGen() + public async Task Exists_PreRulesGetMinimumSetGen() { // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Get_MinimumSet_Gen.json // this example is just showing the usage of "PreRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -267,29 +299,17 @@ public async Task GetIfExists_PreRulesGetMinimumSetGen() // invoke the operation string priority = "1"; - NullableResponse response = await collection.GetIfExistsAsync(priority); - PreRulestackRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(priority); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PreRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PreRulesCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_PreRulesGetMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "PreRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PreRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -307,97 +327,29 @@ public async Task CreateOrUpdate_PreRulesCreateOrUpdateMaximumSetGen() // invoke the operation string priority = "1"; - PreRulestackRuleData data = new PreRulestackRuleData("preRule1") - { - ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), - Description = "description of pre rule", - RuleState = RulestackStateType.Disabled, - Source = new SourceAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - }, - NegateSource = FirewallBooleanType.True, - Destination = new DestinationAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - FqdnLists = -{ -"FQDN1" -}, - }, - NegateDestination = FirewallBooleanType.True, - Applications = -{ -"app1" -}, - Category = new EdlMatchCategory(new string[] + NullableResponse response = await collection.GetIfExistsAsync(priority); + PreRulestackRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { -"https://microsoft.com" - }, new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"feed" - }), - Protocol = "HTTP", - ProtocolPortList = -{ -"80" -}, - InboundInspectionCertificate = "cert1", - AuditComment = "example comment", - ActionType = RulestackActionType.Allow, - EnableLogging = RulestackStateType.Disabled, - DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, - Tags = -{ -new RulestackTagInfo("keyName","value") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); - PreRulestackRuleResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PreRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PreRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PreRulesCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_PreRulesGetMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "PreRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Get_MinimumSet_Gen.json + // this example is just showing the usage of "PreRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -415,15 +367,21 @@ public async Task CreateOrUpdate_PreRulesCreateOrUpdateMinimumSetGen() // invoke the operation string priority = "1"; - PreRulestackRuleData data = new PreRulestackRuleData("preRule1"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, priority, data); - PreRulestackRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(priority); + PreRulestackRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PreRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PreRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PreRulestackRuleResource.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PreRulestackRuleResource.cs index cba637b2bfb28..9da06f2559855 100644 --- a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PreRulestackRuleResource.cs +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_PreRulestackRuleResource.cs @@ -76,10 +76,10 @@ public async Task Get_PreRulesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PreRulesCreateOrUpdateMaximumSetGen() + public async Task Delete_PreRulesDeleteMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "PreRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "PreRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,97 +94,17 @@ public async Task Update_PreRulesCreateOrUpdateMaximumSetGen() PreRulestackRuleResource preRulestackRule = client.GetPreRulestackRuleResource(preRulestackRuleResourceId); // invoke the operation - PreRulestackRuleData data = new PreRulestackRuleData("preRule1") - { - ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), - Description = "description of pre rule", - RuleState = RulestackStateType.Disabled, - Source = new SourceAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - }, - NegateSource = FirewallBooleanType.True, - Destination = new DestinationAddressInfo() - { - Cidrs = -{ -"1.0.0.1/10" -}, - Countries = -{ -"India" -}, - Feeds = -{ -"feed" -}, - PrefixLists = -{ -"PL1" -}, - FqdnLists = -{ -"FQDN1" -}, - }, - NegateDestination = FirewallBooleanType.True, - Applications = -{ -"app1" -}, - Category = new EdlMatchCategory(new string[] - { -"https://microsoft.com" - }, new string[] - { -"feed" - }), - Protocol = "HTTP", - ProtocolPortList = -{ -"80" -}, - InboundInspectionCertificate = "cert1", - AuditComment = "example comment", - ActionType = RulestackActionType.Allow, - EnableLogging = RulestackStateType.Disabled, - DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, - Tags = -{ -new RulestackTagInfo("keyName","value") -}, - }; - ArmOperation lro = await preRulestackRule.UpdateAsync(WaitUntil.Completed, data); - PreRulestackRuleResource result = lro.Value; + await preRulestackRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PreRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PreRulesCreateOrUpdateMinimumSetGen() + public async Task Delete_PreRulesDeleteMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "PreRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "PreRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,23 +119,17 @@ public async Task Update_PreRulesCreateOrUpdateMinimumSetGen() PreRulestackRuleResource preRulestackRule = client.GetPreRulestackRuleResource(preRulestackRuleResourceId); // invoke the operation - PreRulestackRuleData data = new PreRulestackRuleData("preRule1"); - ArmOperation lro = await preRulestackRule.UpdateAsync(WaitUntil.Completed, data); - PreRulestackRuleResource result = lro.Value; + await preRulestackRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PreRulestackRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PreRulesDeleteMaximumSetGen() + public async Task Update_PreRulesCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "PreRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "PreRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -230,17 +144,55 @@ public async Task Delete_PreRulesDeleteMaximumSetGen() PreRulestackRuleResource preRulestackRule = client.GetPreRulestackRuleResource(preRulestackRuleResourceId); // invoke the operation - await preRulestackRule.DeleteAsync(WaitUntil.Completed); + PreRulestackRuleData data = new PreRulestackRuleData("preRule1") + { + ETag = new ETag("c18e6eef-ba3e-49ee-8a85-2b36c863a9d0"), + Description = "description of pre rule", + RuleState = RulestackStateType.Disabled, + Source = new SourceAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + }, + NegateSource = FirewallBooleanType.True, + Destination = new DestinationAddressInfo + { + Cidrs = { "1.0.0.1/10" }, + Countries = { "India" }, + Feeds = { "feed" }, + PrefixLists = { "PL1" }, + FqdnLists = { "FQDN1" }, + }, + NegateDestination = FirewallBooleanType.True, + Applications = { "app1" }, + Category = new EdlMatchCategory(new string[] { "https://microsoft.com" }, new string[] { "feed" }), + Protocol = "HTTP", + ProtocolPortList = { "80" }, + InboundInspectionCertificate = "cert1", + AuditComment = "example comment", + ActionType = RulestackActionType.Allow, + EnableLogging = RulestackStateType.Disabled, + DecryptionRuleType = DecryptionRuleType.SslOutboundInspection, + Tags = { new RulestackTagInfo("keyName", "value") }, + }; + ArmOperation lro = await preRulestackRule.UpdateAsync(WaitUntil.Completed, data); + PreRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PreRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PreRulesDeleteMinimumSetGen() + public async Task Update_PreRulesCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "PreRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/PreRules_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "PreRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -255,9 +207,15 @@ public async Task Delete_PreRulesDeleteMinimumSetGen() PreRulestackRuleResource preRulestackRule = client.GetPreRulestackRuleResource(preRulestackRuleResourceId); // invoke the operation - await preRulestackRule.DeleteAsync(WaitUntil.Completed); + PreRulestackRuleData data = new PreRulestackRuleData("preRule1"); + ArmOperation lro = await preRulestackRule.UpdateAsync(WaitUntil.Completed, data); + PreRulestackRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PreRulestackRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..a8fd47244b2cc --- /dev/null +++ b/sdk/paloaltonetworks.ngfw/Azure.ResourceManager.PaloAltoNetworks.Ngfw/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.PaloAltoNetworks.Ngfw.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPaloAltoNetworksFirewalls_FirewallsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "Firewalls_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PaloAltoNetworksFirewallResource item in subscriptionResource.GetPaloAltoNetworksFirewallsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PaloAltoNetworksFirewallData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPaloAltoNetworksFirewalls_FirewallsListBySubscriptionMinimumSetGen() + { + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/Firewalls_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "Firewalls_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PaloAltoNetworksFirewallResource item in subscriptionResource.GetPaloAltoNetworksFirewallsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PaloAltoNetworksFirewallData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetLocalRulestacks_LocalRulestacksListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (LocalRulestackResource item in subscriptionResource.GetLocalRulestacksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetLocalRulestacks_LocalRulestacksListBySubscriptionMinimumSetGen() + { + // Generated from example definition: specification/paloaltonetworks/resource-manager/PaloAltoNetworks.Cloudngfw/stable/2023-09-01/examples/LocalRulestacks_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "LocalRulestacks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "2bf4a339-294d-4c25-b0b2-ef649e9f5c27"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (LocalRulestackResource item in subscriptionResource.GetLocalRulestacksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalRulestackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_ConnectionMonitorTestCollection.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_ConnectionMonitorTestCollection.cs index 419b55ec8889d..bb75855f9e69c 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_ConnectionMonitorTestCollection.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_ConnectionMonitorTestCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ConnectionMonitorTestCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetConnectionMonitorTest() + public async Task CreateOrUpdate_CreateOrUpdateConnectionMonitorTest() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetConnectionMonitorTest.json - // this example is just showing the usage of "ConnectionMonitorTests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateOrUpdateConnectionMonitorTest.json + // this example is just showing the usage of "ConnectionMonitorTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,15 @@ public async Task Get_GetConnectionMonitorTest() // invoke the operation string connectionMonitorTestName = "connectionMonitorTestName"; - ConnectionMonitorTestResource result = await collection.GetAsync(connectionMonitorTestName); + ConnectionMonitorTestData data = new ConnectionMonitorTestData + { + SourceAgent = "Example Source Agent", + Destination = "Example Destination", + DestinationPort = 443, + TestFrequencyInSec = 30, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionMonitorTestName, data); + ConnectionMonitorTestResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +59,7 @@ public async Task Get_GetConnectionMonitorTest() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetConnectionMonitorTest() + public async Task Get_GetConnectionMonitorTest() { // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetConnectionMonitorTest.json // this example is just showing the usage of "ConnectionMonitorTests_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +82,21 @@ public async Task Exists_GetConnectionMonitorTest() // invoke the operation string connectionMonitorTestName = "connectionMonitorTestName"; - bool result = await collection.ExistsAsync(connectionMonitorTestName); + ConnectionMonitorTestResource result = await collection.GetAsync(connectionMonitorTestName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectionMonitorTestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetConnectionMonitorTest() + public async Task GetAll_ListAllConnectionMonitorTestsAssociatedWithThePeeringService() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetConnectionMonitorTest.json - // this example is just showing the usage of "ConnectionMonitorTests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListConnectionMonitorTestsByPeeringService.json + // this example is just showing the usage of "ConnectionMonitorTests_ListByPeeringService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +114,25 @@ public async Task GetIfExists_GetConnectionMonitorTest() // get the collection of this ConnectionMonitorTestResource ConnectionMonitorTestCollection collection = peeringService.GetConnectionMonitorTests(); - // invoke the operation - string connectionMonitorTestName = "connectionMonitorTestName"; - NullableResponse response = await collection.GetIfExistsAsync(connectionMonitorTestName); - ConnectionMonitorTestResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ConnectionMonitorTestResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectionMonitorTestData resourceData = result.Data; + ConnectionMonitorTestData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateConnectionMonitorTest() + public async Task Exists_GetConnectionMonitorTest() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateOrUpdateConnectionMonitorTest.json - // this example is just showing the usage of "ConnectionMonitorTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetConnectionMonitorTest.json + // this example is just showing the usage of "ConnectionMonitorTests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,29 +152,17 @@ public async Task CreateOrUpdate_CreateOrUpdateConnectionMonitorTest() // invoke the operation string connectionMonitorTestName = "connectionMonitorTestName"; - ConnectionMonitorTestData data = new ConnectionMonitorTestData() - { - SourceAgent = "Example Source Agent", - Destination = "Example Destination", - DestinationPort = 443, - TestFrequencyInSec = 30, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionMonitorTestName, data); - ConnectionMonitorTestResource result = lro.Value; + bool result = await collection.ExistsAsync(connectionMonitorTestName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectionMonitorTestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllConnectionMonitorTestsAssociatedWithThePeeringService() + public async Task GetIfExists_GetConnectionMonitorTest() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListConnectionMonitorTestsByPeeringService.json - // this example is just showing the usage of "ConnectionMonitorTests_ListByPeeringService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetConnectionMonitorTest.json + // this example is just showing the usage of "ConnectionMonitorTests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_ListAllConnectionMonitorTestsAssociatedWithThePeeringSe // get the collection of this ConnectionMonitorTestResource ConnectionMonitorTestCollection collection = peeringService.GetConnectionMonitorTests(); - // invoke the operation and iterate over the result - await foreach (ConnectionMonitorTestResource item in collection.GetAllAsync()) + // invoke the operation + string connectionMonitorTestName = "connectionMonitorTestName"; + NullableResponse response = await collection.GetIfExistsAsync(connectionMonitorTestName); + ConnectionMonitorTestResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectionMonitorTestData resourceData = item.Data; + ConnectionMonitorTestData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_ConnectionMonitorTestResource.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_ConnectionMonitorTestResource.cs index 82b279145f43f..8c8a4fd981810 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_ConnectionMonitorTestResource.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_ConnectionMonitorTestResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetConnectionMonitorTest() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateConnectionMonitorTest() + public async Task Delete_DeleteConnectionMonitorTest() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateOrUpdateConnectionMonitorTest.json - // this example is just showing the usage of "ConnectionMonitorTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/DeleteConnectionMonitorTest.json + // this example is just showing the usage of "ConnectionMonitorTests_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +68,17 @@ public async Task Update_CreateOrUpdateConnectionMonitorTest() ConnectionMonitorTestResource connectionMonitorTest = client.GetConnectionMonitorTestResource(connectionMonitorTestResourceId); // invoke the operation - ConnectionMonitorTestData data = new ConnectionMonitorTestData() - { - SourceAgent = "Example Source Agent", - Destination = "Example Destination", - DestinationPort = 443, - TestFrequencyInSec = 30, - }; - ArmOperation lro = await connectionMonitorTest.UpdateAsync(WaitUntil.Completed, data); - ConnectionMonitorTestResource result = lro.Value; + await connectionMonitorTest.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectionMonitorTestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteConnectionMonitorTest() + public async Task Update_CreateOrUpdateConnectionMonitorTest() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/DeleteConnectionMonitorTest.json - // this example is just showing the usage of "ConnectionMonitorTests_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateOrUpdateConnectionMonitorTest.json + // this example is just showing the usage of "ConnectionMonitorTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +95,21 @@ public async Task Delete_DeleteConnectionMonitorTest() ConnectionMonitorTestResource connectionMonitorTest = client.GetConnectionMonitorTestResource(connectionMonitorTestResourceId); // invoke the operation - await connectionMonitorTest.DeleteAsync(WaitUntil.Completed); + ConnectionMonitorTestData data = new ConnectionMonitorTestData + { + SourceAgent = "Example Source Agent", + Destination = "Example Destination", + DestinationPort = 443, + TestFrequencyInSec = 30, + }; + ArmOperation lro = await connectionMonitorTest.UpdateAsync(WaitUntil.Completed, data); + ConnectionMonitorTestResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectionMonitorTestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeerAsnCollection.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeerAsnCollection.cs index bb1d8dcbb6475..eea0130502900 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeerAsnCollection.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeerAsnCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_PeerAsnCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPeerASN() + public async Task CreateOrUpdate_CreateAPeerASN() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeerAsn.json - // this example is just showing the usage of "PeerAsns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreatePeerAsn.json + // this example is just showing the usage of "PeerAsns_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,29 @@ public async Task Get_GetAPeerASN() // invoke the operation string peerAsnName = "peerAsnName"; - PeerAsnResource result = await collection.GetAsync(peerAsnName); + PeerAsnData data = new PeerAsnData + { + PeerAsn = 65000, + PeerContactDetail = {new PeerAsnContactDetail +{ +Role = PeeringRole.Noc, +Email = "noc@contoso.com", +Phone = "+1 (234) 567-8999", +}, new PeerAsnContactDetail +{ +Role = PeeringRole.Policy, +Email = "abc@contoso.com", +Phone = "+1 (234) 567-8900", +}, new PeerAsnContactDetail +{ +Role = PeeringRole.Technical, +Email = "xyz@contoso.com", +Phone = "+1 (234) 567-8900", +}}, + PeerName = "Contoso", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peerAsnName, data); + PeerAsnResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +73,7 @@ public async Task Get_GetAPeerASN() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPeerASN() + public async Task Get_GetAPeerASN() { // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeerAsn.json // this example is just showing the usage of "PeerAsns_Get" operation, for the dependent resources, they will have to be created separately. @@ -72,17 +94,21 @@ public async Task Exists_GetAPeerASN() // invoke the operation string peerAsnName = "peerAsnName"; - bool result = await collection.ExistsAsync(peerAsnName); + PeerAsnResource result = await collection.GetAsync(peerAsnName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeerAsnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPeerASN() + public async Task GetAll_ListPeerASNsInASubscription() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeerAsn.json - // this example is just showing the usage of "PeerAsns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListPeerAsnsBySubscription.json + // this example is just showing the usage of "PeerAsns_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,31 +124,25 @@ public async Task GetIfExists_GetAPeerASN() // get the collection of this PeerAsnResource PeerAsnCollection collection = subscriptionResource.GetPeerAsns(); - // invoke the operation - string peerAsnName = "peerAsnName"; - NullableResponse response = await collection.GetIfExistsAsync(peerAsnName); - PeerAsnResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PeerAsnResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeerAsnData resourceData = result.Data; + PeerAsnData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAPeerASN() + public async Task Exists_GetAPeerASN() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreatePeerAsn.json - // this example is just showing the usage of "PeerAsns_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeerAsn.json + // this example is just showing the usage of "PeerAsns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,46 +160,17 @@ public async Task CreateOrUpdate_CreateAPeerASN() // invoke the operation string peerAsnName = "peerAsnName"; - PeerAsnData data = new PeerAsnData() - { - PeerAsn = 65000, - PeerContactDetail = -{ -new PeerAsnContactDetail() -{ -Role = PeeringRole.Noc, -Email = "noc@contoso.com", -Phone = "+1 (234) 567-8999", -},new PeerAsnContactDetail() -{ -Role = PeeringRole.Policy, -Email = "abc@contoso.com", -Phone = "+1 (234) 567-8900", -},new PeerAsnContactDetail() -{ -Role = PeeringRole.Technical, -Email = "xyz@contoso.com", -Phone = "+1 (234) 567-8900", -} -}, - PeerName = "Contoso", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peerAsnName, data); - PeerAsnResource result = lro.Value; + bool result = await collection.ExistsAsync(peerAsnName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeerAsnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPeerASNsInASubscription() + public async Task GetIfExists_GetAPeerASN() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListPeerAsnsBySubscription.json - // this example is just showing the usage of "PeerAsns_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeerAsn.json + // this example is just showing the usage of "PeerAsns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,17 +186,23 @@ public async Task GetAll_ListPeerASNsInASubscription() // get the collection of this PeerAsnResource PeerAsnCollection collection = subscriptionResource.GetPeerAsns(); - // invoke the operation and iterate over the result - await foreach (PeerAsnResource item in collection.GetAllAsync()) + // invoke the operation + string peerAsnName = "peerAsnName"; + NullableResponse response = await collection.GetIfExistsAsync(peerAsnName); + PeerAsnResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeerAsnData resourceData = item.Data; + PeerAsnData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeerAsnResource.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeerAsnResource.cs index 411a37722d702..fe3e576c1d35a 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeerAsnResource.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeerAsnResource.cs @@ -45,6 +45,31 @@ public async Task Get_GetAPeerASN() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAPeerASN() + { + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/DeletePeerAsn.json + // this example is just showing the usage of "PeerAsns_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PeerAsnResource created on azure + // for more information of creating PeerAsnResource, please refer to the document of PeerAsnResource + string subscriptionId = "subId"; + string peerAsnName = "peerAsnName"; + ResourceIdentifier peerAsnResourceId = PeerAsnResource.CreateResourceIdentifier(subscriptionId, peerAsnName); + PeerAsnResource peerAsn = client.GetPeerAsnResource(peerAsnResourceId); + + // invoke the operation + await peerAsn.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateAPeerASN() @@ -65,28 +90,25 @@ public async Task Update_CreateAPeerASN() PeerAsnResource peerAsn = client.GetPeerAsnResource(peerAsnResourceId); // invoke the operation - PeerAsnData data = new PeerAsnData() + PeerAsnData data = new PeerAsnData { PeerAsn = 65000, - PeerContactDetail = -{ -new PeerAsnContactDetail() + PeerContactDetail = {new PeerAsnContactDetail { Role = PeeringRole.Noc, Email = "noc@contoso.com", Phone = "+1 (234) 567-8999", -},new PeerAsnContactDetail() +}, new PeerAsnContactDetail { Role = PeeringRole.Policy, Email = "abc@contoso.com", Phone = "+1 (234) 567-8900", -},new PeerAsnContactDetail() +}, new PeerAsnContactDetail { Role = PeeringRole.Technical, Email = "xyz@contoso.com", Phone = "+1 (234) 567-8900", -} -}, +}}, PeerName = "Contoso", }; ArmOperation lro = await peerAsn.UpdateAsync(WaitUntil.Completed, data); @@ -98,30 +120,5 @@ public async Task Update_CreateAPeerASN() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPeerASN() - { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/DeletePeerAsn.json - // this example is just showing the usage of "PeerAsns_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PeerAsnResource created on azure - // for more information of creating PeerAsnResource, please refer to the document of PeerAsnResource - string subscriptionId = "subId"; - string peerAsnName = "peerAsnName"; - ResourceIdentifier peerAsnResourceId = PeerAsnResource.CreateResourceIdentifier(subscriptionId, peerAsnName); - PeerAsnResource peerAsn = client.GetPeerAsnResource(peerAsnResourceId); - - // invoke the operation - await peerAsn.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringCollection.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringCollection.cs index 4e3bb0966c8c0..5a6784e161dc0 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringCollection.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringCollection.cs @@ -18,109 +18,6 @@ namespace Azure.ResourceManager.Peering.Samples { public partial class Sample_PeeringCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPeering() - { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeering.json - // this example is just showing the usage of "Peerings_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subId"; - string resourceGroupName = "rgName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PeeringResource - PeeringCollection collection = resourceGroupResource.GetPeerings(); - - // invoke the operation - string peeringName = "peeringName"; - PeeringResource result = await collection.GetAsync(peeringName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPeering() - { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeering.json - // this example is just showing the usage of "Peerings_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subId"; - string resourceGroupName = "rgName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PeeringResource - PeeringCollection collection = resourceGroupResource.GetPeerings(); - - // invoke the operation - string peeringName = "peeringName"; - bool result = await collection.ExistsAsync(peeringName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPeering() - { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeering.json - // this example is just showing the usage of "Peerings_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subId"; - string resourceGroupName = "rgName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PeeringResource - PeeringCollection collection = resourceGroupResource.GetPeerings(); - - // invoke the operation - string peeringName = "peeringName"; - NullableResponse response = await collection.GetIfExistsAsync(peeringName); - PeeringResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateADirectPeering() @@ -145,22 +42,20 @@ public async Task CreateOrUpdate_CreateADirectPeering() // invoke the operation string peeringName = "peeringName"; - PeeringData data = new PeeringData(new AzureLocation("eastus"), new PeeringSku() + PeeringData data = new PeeringData(new AzureLocation("eastus"), new PeeringSku { Name = "Basic_Direct_Free", }, PeeringKind.Direct) { - Direct = new DirectPeeringProperties() + Direct = new DirectPeeringProperties { - Connections = -{ -new PeeringDirectConnection() + Connections = {new PeeringDirectConnection { BandwidthInMbps = 10000, SessionAddressProvider = PeeringSessionAddressProvider.Peer, UseForPeeringService = false, PeeringDBFacilityId = 99999, -BgpSession = new PeeringBgpSession() +BgpSession = new PeeringBgpSession { SessionPrefixV4 = "192.168.0.0/31", SessionPrefixV6 = "fd00::0/127", @@ -169,15 +64,14 @@ public async Task CreateOrUpdate_CreateADirectPeering() Md5AuthenticationKey = "test-md5-auth-key", }, ConnectionIdentifier = "5F4CB5C7-6B43-4444-9338-9ABC72606C16", -},new PeeringDirectConnection() +}, new PeeringDirectConnection { BandwidthInMbps = 10000, SessionAddressProvider = PeeringSessionAddressProvider.Microsoft, UseForPeeringService = true, PeeringDBFacilityId = 99999, ConnectionIdentifier = "8AB00818-D533-4504-A25A-03A17F61201C", -} -}, +}}, PeerAsnId = new ResourceIdentifier("/subscriptions/subId/providers/Microsoft.Peering/peerAsns/myAsn1"), DirectPeeringType = DirectPeeringType.Edge, }, @@ -217,22 +111,20 @@ public async Task CreateOrUpdate_CreateAPeeringWithExchangeRouteServer() // invoke the operation string peeringName = "peeringName"; - PeeringData data = new PeeringData(new AzureLocation("eastus"), new PeeringSku() + PeeringData data = new PeeringData(new AzureLocation("eastus"), new PeeringSku { Name = "Premium_Direct_Free", }, PeeringKind.Direct) { - Direct = new DirectPeeringProperties() + Direct = new DirectPeeringProperties { - Connections = -{ -new PeeringDirectConnection() + Connections = {new PeeringDirectConnection { BandwidthInMbps = 10000, SessionAddressProvider = PeeringSessionAddressProvider.Peer, UseForPeeringService = true, PeeringDBFacilityId = 99999, -BgpSession = new PeeringBgpSession() +BgpSession = new PeeringBgpSession { SessionPrefixV4 = "192.168.0.0/24", MicrosoftSessionIPv4Address = IPAddress.Parse("192.168.0.123"), @@ -241,8 +133,7 @@ public async Task CreateOrUpdate_CreateAPeeringWithExchangeRouteServer() MaxPrefixesAdvertisedV6 = 100, }, ConnectionIdentifier = "5F4CB5C7-6B43-4444-9338-9ABC72606C16", -} -}, +}}, PeerAsnId = new ResourceIdentifier("/subscriptions/subId/providers/Microsoft.Peering/peerAsns/myAsn1"), DirectPeeringType = DirectPeeringType.IxRs, }, @@ -282,19 +173,17 @@ public async Task CreateOrUpdate_CreateAnExchangePeering() // invoke the operation string peeringName = "peeringName"; - PeeringData data = new PeeringData(new AzureLocation("eastus"), new PeeringSku() + PeeringData data = new PeeringData(new AzureLocation("eastus"), new PeeringSku { Name = "Basic_Exchange_Free", }, PeeringKind.Exchange) { - Exchange = new ExchangePeeringProperties() + Exchange = new ExchangePeeringProperties { - Connections = -{ -new PeeringExchangeConnection() + Connections = {new PeeringExchangeConnection { PeeringDBFacilityId = 99999, -BgpSession = new PeeringBgpSession() +BgpSession = new PeeringBgpSession { PeerSessionIPv4Address = IPAddress.Parse("192.168.2.1"), PeerSessionIPv6Address = IPAddress.Parse("fd00::1"), @@ -303,10 +192,10 @@ public async Task CreateOrUpdate_CreateAnExchangePeering() Md5AuthenticationKey = "test-md5-auth-key", }, ConnectionIdentifier = Guid.Parse("CE495334-0E94-4E51-8164-8116D6CD284D"), -},new PeeringExchangeConnection() +}, new PeeringExchangeConnection { PeeringDBFacilityId = 99999, -BgpSession = new PeeringBgpSession() +BgpSession = new PeeringBgpSession { PeerSessionIPv4Address = IPAddress.Parse("192.168.2.2"), PeerSessionIPv6Address = IPAddress.Parse("fd00::2"), @@ -315,8 +204,7 @@ public async Task CreateOrUpdate_CreateAnExchangePeering() Md5AuthenticationKey = "test-md5-auth-key", }, ConnectionIdentifier = Guid.Parse("CDD8E673-CB07-47E6-84DE-3739F778762B"), -} -}, +}}, PeerAsnId = new ResourceIdentifier("/subscriptions/subId/providers/Microsoft.Peering/peerAsns/myAsn1"), }, PeeringLocation = "peeringLocation0", @@ -331,6 +219,39 @@ public async Task CreateOrUpdate_CreateAnExchangePeering() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAPeering() + { + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeering.json + // this example is just showing the usage of "Peerings_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subId"; + string resourceGroupName = "rgName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PeeringResource + PeeringCollection collection = resourceGroupResource.GetPeerings(); + + // invoke the operation + string peeringName = "peeringName"; + PeeringResource result = await collection.GetAsync(peeringName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListPeeringsInAResourceGroup() @@ -365,5 +286,75 @@ public async Task GetAll_ListPeeringsInAResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetAPeering() + { + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeering.json + // this example is just showing the usage of "Peerings_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subId"; + string resourceGroupName = "rgName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PeeringResource + PeeringCollection collection = resourceGroupResource.GetPeerings(); + + // invoke the operation + string peeringName = "peeringName"; + bool result = await collection.ExistsAsync(peeringName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetAPeering() + { + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeering.json + // this example is just showing the usage of "Peerings_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subId"; + string resourceGroupName = "rgName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PeeringResource + PeeringCollection collection = resourceGroupResource.GetPeerings(); + + // invoke the operation + string peeringName = "peeringName"; + NullableResponse response = await collection.GetIfExistsAsync(peeringName); + PeeringResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredAsnCollection.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredAsnCollection.cs index 29699e2258418..23a4b98ebcd68 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredAsnCollection.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredAsnCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_PeeringRegisteredAsnCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARegisteredASNAssociatedWithThePeering() + public async Task CreateOrUpdate_CreateOrUpdateARegisteredASNForThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetRegisteredAsn.json - // this example is just showing the usage of "RegisteredAsns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateRegisteredAsn.json + // this example is just showing the usage of "RegisteredAsns_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,13 @@ public async Task Get_GetARegisteredASNAssociatedWithThePeering() PeeringRegisteredAsnCollection collection = peering.GetPeeringRegisteredAsns(); // invoke the operation - string registeredAsnName = "registeredAsnName0"; - PeeringRegisteredAsnResource result = await collection.GetAsync(registeredAsnName); + string registeredAsnName = "registeredAsnName"; + PeeringRegisteredAsnData data = new PeeringRegisteredAsnData + { + Asn = 65000, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registeredAsnName, data); + PeeringRegisteredAsnResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetARegisteredASNAssociatedWithThePeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetARegisteredASNAssociatedWithThePeering() + public async Task Get_GetARegisteredASNAssociatedWithThePeering() { // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetRegisteredAsn.json // this example is just showing the usage of "RegisteredAsns_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +79,21 @@ public async Task Exists_GetARegisteredASNAssociatedWithThePeering() // invoke the operation string registeredAsnName = "registeredAsnName0"; - bool result = await collection.ExistsAsync(registeredAsnName); + PeeringRegisteredAsnResource result = await collection.GetAsync(registeredAsnName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringRegisteredAsnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetARegisteredASNAssociatedWithThePeering() + public async Task GetAll_ListAllTheRegisteredASNsAssociatedWithThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetRegisteredAsn.json - // this example is just showing the usage of "RegisteredAsns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListRegisteredAsnsByPeering.json + // this example is just showing the usage of "RegisteredAsns_ListByPeering" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +111,25 @@ public async Task GetIfExists_GetARegisteredASNAssociatedWithThePeering() // get the collection of this PeeringRegisteredAsnResource PeeringRegisteredAsnCollection collection = peering.GetPeeringRegisteredAsns(); - // invoke the operation - string registeredAsnName = "registeredAsnName0"; - NullableResponse response = await collection.GetIfExistsAsync(registeredAsnName); - PeeringRegisteredAsnResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PeeringRegisteredAsnResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeeringRegisteredAsnData resourceData = result.Data; + PeeringRegisteredAsnData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateARegisteredASNForThePeering() + public async Task Exists_GetARegisteredASNAssociatedWithThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateRegisteredAsn.json - // this example is just showing the usage of "RegisteredAsns_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetRegisteredAsn.json + // this example is just showing the usage of "RegisteredAsns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,27 +148,18 @@ public async Task CreateOrUpdate_CreateOrUpdateARegisteredASNForThePeering() PeeringRegisteredAsnCollection collection = peering.GetPeeringRegisteredAsns(); // invoke the operation - string registeredAsnName = "registeredAsnName"; - PeeringRegisteredAsnData data = new PeeringRegisteredAsnData() - { - Asn = 65000, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registeredAsnName, data); - PeeringRegisteredAsnResource result = lro.Value; + string registeredAsnName = "registeredAsnName0"; + bool result = await collection.ExistsAsync(registeredAsnName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringRegisteredAsnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllTheRegisteredASNsAssociatedWithThePeering() + public async Task GetIfExists_GetARegisteredASNAssociatedWithThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListRegisteredAsnsByPeering.json - // this example is just showing the usage of "RegisteredAsns_ListByPeering" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetRegisteredAsn.json + // this example is just showing the usage of "RegisteredAsns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_ListAllTheRegisteredASNsAssociatedWithThePeering() // get the collection of this PeeringRegisteredAsnResource PeeringRegisteredAsnCollection collection = peering.GetPeeringRegisteredAsns(); - // invoke the operation and iterate over the result - await foreach (PeeringRegisteredAsnResource item in collection.GetAllAsync()) + // invoke the operation + string registeredAsnName = "registeredAsnName0"; + NullableResponse response = await collection.GetIfExistsAsync(registeredAsnName); + PeeringRegisteredAsnResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeeringRegisteredAsnData resourceData = item.Data; + PeeringRegisteredAsnData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredAsnResource.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredAsnResource.cs index 4c69d679167d1..072635b986238 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredAsnResource.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredAsnResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetARegisteredASNAssociatedWithThePeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateARegisteredASNForThePeering() + public async Task Delete_DeletesARegisteredASNAssociatedWithThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateRegisteredAsn.json - // this example is just showing the usage of "RegisteredAsns_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/DeleteRegisteredAsn.json + // this example is just showing the usage of "RegisteredAsns_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_CreateOrUpdateARegisteredASNForThePeering() PeeringRegisteredAsnResource peeringRegisteredAsn = client.GetPeeringRegisteredAsnResource(peeringRegisteredAsnResourceId); // invoke the operation - PeeringRegisteredAsnData data = new PeeringRegisteredAsnData() - { - Asn = 65000, - }; - ArmOperation lro = await peeringRegisteredAsn.UpdateAsync(WaitUntil.Completed, data); - PeeringRegisteredAsnResource result = lro.Value; + await peeringRegisteredAsn.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringRegisteredAsnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesARegisteredASNAssociatedWithThePeering() + public async Task Update_CreateOrUpdateARegisteredASNForThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/DeleteRegisteredAsn.json - // this example is just showing the usage of "RegisteredAsns_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateRegisteredAsn.json + // this example is just showing the usage of "RegisteredAsns_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,18 @@ public async Task Delete_DeletesARegisteredASNAssociatedWithThePeering() PeeringRegisteredAsnResource peeringRegisteredAsn = client.GetPeeringRegisteredAsnResource(peeringRegisteredAsnResourceId); // invoke the operation - await peeringRegisteredAsn.DeleteAsync(WaitUntil.Completed); + PeeringRegisteredAsnData data = new PeeringRegisteredAsnData + { + Asn = 65000, + }; + ArmOperation lro = await peeringRegisteredAsn.UpdateAsync(WaitUntil.Completed, data); + PeeringRegisteredAsnResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringRegisteredAsnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredPrefixCollection.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredPrefixCollection.cs index 0ab244e949d52..eb8f1a5f51ca8 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredPrefixCollection.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredPrefixCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_PeeringRegisteredPrefixCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARegisteredPrefixAssociatedWithThePeering() + public async Task CreateOrUpdate_CreateOrUpdateARegisteredPrefixForThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetRegisteredPrefix.json - // this example is just showing the usage of "RegisteredPrefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateRegisteredPrefix.json + // this example is just showing the usage of "RegisteredPrefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetARegisteredPrefixAssociatedWithThePeering() // invoke the operation string registeredPrefixName = "registeredPrefixName"; - PeeringRegisteredPrefixResource result = await collection.GetAsync(registeredPrefixName); + PeeringRegisteredPrefixData data = new PeeringRegisteredPrefixData + { + Prefix = "10.22.20.0/24", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registeredPrefixName, data); + PeeringRegisteredPrefixResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetARegisteredPrefixAssociatedWithThePeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetARegisteredPrefixAssociatedWithThePeering() + public async Task Get_GetARegisteredPrefixAssociatedWithThePeering() { // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetRegisteredPrefix.json // this example is just showing the usage of "RegisteredPrefixes_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +79,21 @@ public async Task Exists_GetARegisteredPrefixAssociatedWithThePeering() // invoke the operation string registeredPrefixName = "registeredPrefixName"; - bool result = await collection.ExistsAsync(registeredPrefixName); + PeeringRegisteredPrefixResource result = await collection.GetAsync(registeredPrefixName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringRegisteredPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetARegisteredPrefixAssociatedWithThePeering() + public async Task GetAll_ListAllTheRegisteredPrefixesAssociatedWithThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetRegisteredPrefix.json - // this example is just showing the usage of "RegisteredPrefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListRegisteredPrefixesByPeering.json + // this example is just showing the usage of "RegisteredPrefixes_ListByPeering" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +111,25 @@ public async Task GetIfExists_GetARegisteredPrefixAssociatedWithThePeering() // get the collection of this PeeringRegisteredPrefixResource PeeringRegisteredPrefixCollection collection = peering.GetPeeringRegisteredPrefixes(); - // invoke the operation - string registeredPrefixName = "registeredPrefixName"; - NullableResponse response = await collection.GetIfExistsAsync(registeredPrefixName); - PeeringRegisteredPrefixResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PeeringRegisteredPrefixResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeeringRegisteredPrefixData resourceData = result.Data; + PeeringRegisteredPrefixData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateARegisteredPrefixForThePeering() + public async Task Exists_GetARegisteredPrefixAssociatedWithThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateRegisteredPrefix.json - // this example is just showing the usage of "RegisteredPrefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetRegisteredPrefix.json + // this example is just showing the usage of "RegisteredPrefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,26 +149,17 @@ public async Task CreateOrUpdate_CreateOrUpdateARegisteredPrefixForThePeering() // invoke the operation string registeredPrefixName = "registeredPrefixName"; - PeeringRegisteredPrefixData data = new PeeringRegisteredPrefixData() - { - Prefix = "10.22.20.0/24", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registeredPrefixName, data); - PeeringRegisteredPrefixResource result = lro.Value; + bool result = await collection.ExistsAsync(registeredPrefixName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringRegisteredPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllTheRegisteredPrefixesAssociatedWithThePeering() + public async Task GetIfExists_GetARegisteredPrefixAssociatedWithThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListRegisteredPrefixesByPeering.json - // this example is just showing the usage of "RegisteredPrefixes_ListByPeering" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetRegisteredPrefix.json + // this example is just showing the usage of "RegisteredPrefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_ListAllTheRegisteredPrefixesAssociatedWithThePeering() // get the collection of this PeeringRegisteredPrefixResource PeeringRegisteredPrefixCollection collection = peering.GetPeeringRegisteredPrefixes(); - // invoke the operation and iterate over the result - await foreach (PeeringRegisteredPrefixResource item in collection.GetAllAsync()) + // invoke the operation + string registeredPrefixName = "registeredPrefixName"; + NullableResponse response = await collection.GetIfExistsAsync(registeredPrefixName); + PeeringRegisteredPrefixResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeeringRegisteredPrefixData resourceData = item.Data; + PeeringRegisteredPrefixData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredPrefixResource.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredPrefixResource.cs index d548e191986f1..f0e29aba2666b 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredPrefixResource.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringRegisteredPrefixResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetARegisteredPrefixAssociatedWithThePeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateARegisteredPrefixForThePeering() + public async Task Delete_DeletesARegisteredPrefixAssociatedWithThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateRegisteredPrefix.json - // this example is just showing the usage of "RegisteredPrefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/DeleteRegisteredPrefix.json + // this example is just showing the usage of "RegisteredPrefixes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_CreateOrUpdateARegisteredPrefixForThePeering() PeeringRegisteredPrefixResource peeringRegisteredPrefix = client.GetPeeringRegisteredPrefixResource(peeringRegisteredPrefixResourceId); // invoke the operation - PeeringRegisteredPrefixData data = new PeeringRegisteredPrefixData() - { - Prefix = "10.22.20.0/24", - }; - ArmOperation lro = await peeringRegisteredPrefix.UpdateAsync(WaitUntil.Completed, data); - PeeringRegisteredPrefixResource result = lro.Value; + await peeringRegisteredPrefix.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringRegisteredPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesARegisteredPrefixAssociatedWithThePeering() + public async Task Update_CreateOrUpdateARegisteredPrefixForThePeering() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/DeleteRegisteredPrefix.json - // this example is just showing the usage of "RegisteredPrefixes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreateRegisteredPrefix.json + // this example is just showing the usage of "RegisteredPrefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,18 @@ public async Task Delete_DeletesARegisteredPrefixAssociatedWithThePeering() PeeringRegisteredPrefixResource peeringRegisteredPrefix = client.GetPeeringRegisteredPrefixResource(peeringRegisteredPrefixResourceId); // invoke the operation - await peeringRegisteredPrefix.DeleteAsync(WaitUntil.Completed); + PeeringRegisteredPrefixData data = new PeeringRegisteredPrefixData + { + Prefix = "10.22.20.0/24", + }; + ArmOperation lro = await peeringRegisteredPrefix.UpdateAsync(WaitUntil.Completed, data); + PeeringRegisteredPrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringRegisteredPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringResource.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringResource.cs index 357634785220d..187fe1c5ed511 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringResource.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Peering.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Peering.Samples @@ -94,12 +93,12 @@ public async Task Update_UpdatePeeringTags() PeeringResource peering = client.GetPeeringResource(peeringResourceId); // invoke the operation - PeeringPatch patch = new PeeringPatch() + PeeringPatch patch = new PeeringPatch { Tags = { ["tag0"] = "value0", -["tag1"] = "value1", +["tag1"] = "value1" }, }; PeeringResource result = await peering.UpdateAsync(patch); @@ -111,37 +110,6 @@ public async Task Update_UpdatePeeringTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPeerings_ListPeeringsInASubscription() - { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListPeeringsBySubscription.json - // this example is just showing the usage of "Peerings_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subId"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PeeringResource item in subscriptionResource.GetPeeringsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetReceivedRoutes_ListsThePrefixesReceivedOverTheSpecifiedPeeringUnderTheGivenSubscriptionAndResourceGroup() diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServiceCollection.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServiceCollection.cs index 4832a4f44938d..17e90647aa279 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServiceCollection.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServiceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PeeringServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPeeringService() + public async Task CreateOrUpdate_CreateAPeeringService() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeeringService.json - // this example is just showing the usage of "PeeringServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreatePeeringService.json + // this example is just showing the usage of "PeeringServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,15 @@ public async Task Get_GetAPeeringService() // invoke the operation string peeringServiceName = "peeringServiceName"; - PeeringServiceResource result = await collection.GetAsync(peeringServiceName); + PeeringServiceData data = new PeeringServiceData(new AzureLocation("eastus")) + { + PeeringServiceLocation = "state1", + PeeringServiceProvider = "serviceProvider1", + ProviderPrimaryPeeringLocation = "peeringLocation1", + ProviderBackupPeeringLocation = "peeringLocation2", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peeringServiceName, data); + PeeringServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +59,7 @@ public async Task Get_GetAPeeringService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPeeringService() + public async Task Get_GetAPeeringService() { // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeeringService.json // this example is just showing the usage of "PeeringServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +81,21 @@ public async Task Exists_GetAPeeringService() // invoke the operation string peeringServiceName = "peeringServiceName"; - bool result = await collection.ExistsAsync(peeringServiceName); + PeeringServiceResource result = await collection.GetAsync(peeringServiceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPeeringService() + public async Task GetAll_ListPeeringServicesInAResourceGroup() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeeringService.json - // this example is just showing the usage of "PeeringServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListPeeringServicesByResourceGroup.json + // this example is just showing the usage of "PeeringServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +112,25 @@ public async Task GetIfExists_GetAPeeringService() // get the collection of this PeeringServiceResource PeeringServiceCollection collection = resourceGroupResource.GetPeeringServices(); - // invoke the operation - string peeringServiceName = "peeringServiceName"; - NullableResponse response = await collection.GetIfExistsAsync(peeringServiceName); - PeeringServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PeeringServiceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeeringServiceData resourceData = result.Data; + PeeringServiceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAPeeringService() + public async Task Exists_GetAPeeringService() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreatePeeringService.json - // this example is just showing the usage of "PeeringServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeeringService.json + // this example is just showing the usage of "PeeringServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,29 +149,17 @@ public async Task CreateOrUpdate_CreateAPeeringService() // invoke the operation string peeringServiceName = "peeringServiceName"; - PeeringServiceData data = new PeeringServiceData(new AzureLocation("eastus")) - { - PeeringServiceLocation = "state1", - PeeringServiceProvider = "serviceProvider1", - ProviderPrimaryPeeringLocation = "peeringLocation1", - ProviderBackupPeeringLocation = "peeringLocation2", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peeringServiceName, data); - PeeringServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(peeringServiceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPeeringServicesInAResourceGroup() + public async Task GetIfExists_GetAPeeringService() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListPeeringServicesByResourceGroup.json - // this example is just showing the usage of "PeeringServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeeringService.json + // this example is just showing the usage of "PeeringServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,17 +176,23 @@ public async Task GetAll_ListPeeringServicesInAResourceGroup() // get the collection of this PeeringServiceResource PeeringServiceCollection collection = resourceGroupResource.GetPeeringServices(); - // invoke the operation and iterate over the result - await foreach (PeeringServiceResource item in collection.GetAllAsync()) + // invoke the operation + string peeringServiceName = "peeringServiceName"; + NullableResponse response = await collection.GetIfExistsAsync(peeringServiceName); + PeeringServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeeringServiceData resourceData = item.Data; + PeeringServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServicePrefixCollection.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServicePrefixCollection.cs index 8b1b02eeebf7b..fa70801d8b5a6 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServicePrefixCollection.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServicePrefixCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_PeeringServicePrefixCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPrefixAssociatedWithThePeeringService() + public async Task CreateOrUpdate_CreateOrUpdateAPrefixForThePeeringService() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeeringServicePrefix.json - // this example is just showing the usage of "Prefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreatePeeringServicePrefix.json + // this example is just showing the usage of "Prefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,13 @@ public async Task Get_GetAPrefixAssociatedWithThePeeringService() // invoke the operation string prefixName = "peeringServicePrefixName"; - PeeringServicePrefixResource result = await collection.GetAsync(prefixName); + PeeringServicePrefixData data = new PeeringServicePrefixData + { + Prefix = "192.168.1.0/24", + PeeringServicePrefixKey = "00000000-0000-0000-0000-000000000000", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, prefixName, data); + PeeringServicePrefixResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +57,7 @@ public async Task Get_GetAPrefixAssociatedWithThePeeringService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPrefixAssociatedWithThePeeringService() + public async Task Get_GetAPrefixAssociatedWithThePeeringService() { // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeeringServicePrefix.json // this example is just showing the usage of "Prefixes_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +80,21 @@ public async Task Exists_GetAPrefixAssociatedWithThePeeringService() // invoke the operation string prefixName = "peeringServicePrefixName"; - bool result = await collection.ExistsAsync(prefixName); + PeeringServicePrefixResource result = await collection.GetAsync(prefixName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringServicePrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPrefixAssociatedWithThePeeringService() + public async Task GetAll_ListAllThePrefixesAssociatedWithThePeeringService() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeeringServicePrefix.json - // this example is just showing the usage of "Prefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListPrefixesByPeeringService.json + // this example is just showing the usage of "Prefixes_ListByPeeringService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +112,25 @@ public async Task GetIfExists_GetAPrefixAssociatedWithThePeeringService() // get the collection of this PeeringServicePrefixResource PeeringServicePrefixCollection collection = peeringService.GetPeeringServicePrefixes(); - // invoke the operation - string prefixName = "peeringServicePrefixName"; - NullableResponse response = await collection.GetIfExistsAsync(prefixName); - PeeringServicePrefixResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PeeringServicePrefixResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeeringServicePrefixData resourceData = result.Data; + PeeringServicePrefixData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAPrefixForThePeeringService() + public async Task Exists_GetAPrefixAssociatedWithThePeeringService() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreatePeeringServicePrefix.json - // this example is just showing the usage of "Prefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeeringServicePrefix.json + // this example is just showing the usage of "Prefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,27 +150,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAPrefixForThePeeringService() // invoke the operation string prefixName = "peeringServicePrefixName"; - PeeringServicePrefixData data = new PeeringServicePrefixData() - { - Prefix = "192.168.1.0/24", - PeeringServicePrefixKey = "00000000-0000-0000-0000-000000000000", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, prefixName, data); - PeeringServicePrefixResource result = lro.Value; + bool result = await collection.ExistsAsync(prefixName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringServicePrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllThePrefixesAssociatedWithThePeeringService() + public async Task GetIfExists_GetAPrefixAssociatedWithThePeeringService() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListPrefixesByPeeringService.json - // this example is just showing the usage of "Prefixes_ListByPeeringService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/GetPeeringServicePrefix.json + // this example is just showing the usage of "Prefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListAllThePrefixesAssociatedWithThePeeringService() // get the collection of this PeeringServicePrefixResource PeeringServicePrefixCollection collection = peeringService.GetPeeringServicePrefixes(); - // invoke the operation and iterate over the result - await foreach (PeeringServicePrefixResource item in collection.GetAllAsync()) + // invoke the operation + string prefixName = "peeringServicePrefixName"; + NullableResponse response = await collection.GetIfExistsAsync(prefixName); + PeeringServicePrefixResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeeringServicePrefixData resourceData = item.Data; + PeeringServicePrefixData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServicePrefixResource.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServicePrefixResource.cs index a3f1f6cfec5d8..9e19d314f21b4 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServicePrefixResource.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServicePrefixResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetAPrefixAssociatedWithThePeeringService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAPrefixForThePeeringService() + public async Task Delete_DeleteAPrefixAssociatedWithThePeeringService() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreatePeeringServicePrefix.json - // this example is just showing the usage of "Prefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/DeletePeeringServicePrefix.json + // this example is just showing the usage of "Prefixes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,27 +68,17 @@ public async Task Update_CreateOrUpdateAPrefixForThePeeringService() PeeringServicePrefixResource peeringServicePrefix = client.GetPeeringServicePrefixResource(peeringServicePrefixResourceId); // invoke the operation - PeeringServicePrefixData data = new PeeringServicePrefixData() - { - Prefix = "192.168.1.0/24", - PeeringServicePrefixKey = "00000000-0000-0000-0000-000000000000", - }; - ArmOperation lro = await peeringServicePrefix.UpdateAsync(WaitUntil.Completed, data); - PeeringServicePrefixResource result = lro.Value; + await peeringServicePrefix.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringServicePrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPrefixAssociatedWithThePeeringService() + public async Task Update_CreateOrUpdateAPrefixForThePeeringService() { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/DeletePeeringServicePrefix.json - // this example is just showing the usage of "Prefixes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/CreatePeeringServicePrefix.json + // this example is just showing the usage of "Prefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +95,19 @@ public async Task Delete_DeleteAPrefixAssociatedWithThePeeringService() PeeringServicePrefixResource peeringServicePrefix = client.GetPeeringServicePrefixResource(peeringServicePrefixResourceId); // invoke the operation - await peeringServicePrefix.DeleteAsync(WaitUntil.Completed); + PeeringServicePrefixData data = new PeeringServicePrefixData + { + Prefix = "192.168.1.0/24", + PeeringServicePrefixKey = "00000000-0000-0000-0000-000000000000", + }; + ArmOperation lro = await peeringServicePrefix.UpdateAsync(WaitUntil.Completed, data); + PeeringServicePrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringServicePrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServiceResource.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServiceResource.cs index 70b9d68e32e29..0892da9ea09d5 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServiceResource.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_PeeringServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Peering.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Peering.Samples @@ -94,12 +93,12 @@ public async Task Update_UpdatePeeringServiceTags() PeeringServiceResource peeringService = client.GetPeeringServiceResource(peeringServiceResourceId); // invoke the operation - PeeringServicePatch patch = new PeeringServicePatch() + PeeringServicePatch patch = new PeeringServicePatch { Tags = { ["tag0"] = "value0", -["tag1"] = "value1", +["tag1"] = "value1" }, }; PeeringServiceResource result = await peeringService.UpdateAsync(patch); @@ -110,60 +109,5 @@ public async Task Update_UpdatePeeringServiceTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPeeringServices_ListPeeringServicesInASubscription() - { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListPeeringServicesBySubscription.json - // this example is just showing the usage of "PeeringServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subId"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PeeringServiceResource item in subscriptionResource.GetPeeringServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeeringServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task InitializePeeringServiceConnectionMonitor_InitializePeeringServiceForConnectionMonitorFunctionality() - { - // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/InitializeConnectionMonitor.json - // this example is just showing the usage of "PeeringServices_InitializeConnectionMonitor" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subId"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - await subscriptionResource.InitializePeeringServiceConnectionMonitorAsync(); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index b8c86b96cccbe..a5b7e0f4cd5d9 100644 --- a/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/peering/Azure.ResourceManager.Peering/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -64,7 +64,7 @@ public async Task CheckPeeringServiceProviderAvailability_CheckIfPeeringServiceP SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - CheckPeeringServiceProviderAvailabilityContent content = new CheckPeeringServiceProviderAvailabilityContent() + CheckPeeringServiceProviderAvailabilityContent content = new CheckPeeringServiceProviderAvailabilityContent { PeeringServiceLocation = "peeringServiceLocation1", PeeringServiceProvider = "peeringServiceProvider1", @@ -192,6 +192,37 @@ public async Task GetPeeringLocations_ListExchangePeeringLocations() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPeerings_ListPeeringsInASubscription() + { + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListPeeringsBySubscription.json + // this example is just showing the usage of "Peerings_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PeeringResource item in subscriptionResource.GetPeeringsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetPeeringServiceCountries_ListPeeringServiceCountries() @@ -272,5 +303,60 @@ public async Task GetPeeringServiceProviders_ListPeeringServiceProviders() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPeeringServices_ListPeeringServicesInASubscription() + { + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/ListPeeringServicesBySubscription.json + // this example is just showing the usage of "PeeringServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PeeringServiceResource item in subscriptionResource.GetPeeringServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeeringServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task InitializePeeringServiceConnectionMonitor_InitializePeeringServiceForConnectionMonitorFunctionality() + { + // Generated from example definition: specification/peering/resource-manager/Microsoft.Peering/stable/2022-10-01/examples/InitializeConnectionMonitor.json + // this example is just showing the usage of "PeeringServices_InitializeConnectionMonitor" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + await subscriptionResource.InitializePeeringServiceConnectionMonitorAsync(); + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingAccountCollection.cs b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingAccountCollection.cs index 7f4425a88943b..b8d39fa590114 100644 --- a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingAccountCollection.cs +++ b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingAccountCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_PlaywrightTestingAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AccountsListByResourceGroup() + public async Task CreateOrUpdate_AccountsCreateOrUpdate() { - // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_ListByResourceGroup.json - // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_CreateOrUpdate.json + // this example is just showing the usage of "Accounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_AccountsListByResourceGroup() // get the collection of this PlaywrightTestingAccountResource PlaywrightTestingAccountCollection collection = resourceGroupResource.GetPlaywrightTestingAccounts(); - // invoke the operation and iterate over the result - await foreach (PlaywrightTestingAccountResource item in collection.GetAllAsync()) + // invoke the operation + string name = "myPlaywrightAccount"; + PlaywrightTestingAccountData data = new PlaywrightTestingAccountData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlaywrightTestingAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + RegionalAffinity = EnablementStatus.Enabled, + Tags = +{ +["Team"] = "Dev Exp" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + PlaywrightTestingAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlaywrightTestingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +94,10 @@ public async Task Get_AccountsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AccountsGet() + public async Task GetAll_AccountsListByResourceGroup() { - // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_Get.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_ListByResourceGroup.json + // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +114,22 @@ public async Task Exists_AccountsGet() // get the collection of this PlaywrightTestingAccountResource PlaywrightTestingAccountCollection collection = resourceGroupResource.GetPlaywrightTestingAccounts(); - // invoke the operation - string name = "myPlaywrightAccount"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (PlaywrightTestingAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlaywrightTestingAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AccountsGet() + public async Task Exists_AccountsGet() { // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_Get.json // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +151,17 @@ public async Task GetIfExists_AccountsGet() // invoke the operation string name = "myPlaywrightAccount"; - NullableResponse response = await collection.GetIfExistsAsync(name); - PlaywrightTestingAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlaywrightTestingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AccountsCreateOrUpdate() + public async Task GetIfExists_AccountsGet() { - // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_CreateOrUpdate.json - // this example is just showing the usage of "Accounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_Get.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,22 +180,21 @@ public async Task CreateOrUpdate_AccountsCreateOrUpdate() // invoke the operation string name = "myPlaywrightAccount"; - PlaywrightTestingAccountData data = new PlaywrightTestingAccountData(new AzureLocation("westus")) - { - RegionalAffinity = EnablementStatus.Enabled, - Tags = -{ -["Team"] = "Dev Exp", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - PlaywrightTestingAccountResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + PlaywrightTestingAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlaywrightTestingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlaywrightTestingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingAccountResource.cs b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingAccountResource.cs index c6541e40bcfcb..7f4a0091fd0d5 100644 --- a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingAccountResource.cs +++ b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingAccountResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.PlaywrightTesting.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.PlaywrightTesting.Samples { public partial class Sample_PlaywrightTestingAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPlaywrightTestingAccounts_AccountsListBySubscription() - { - // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_ListBySubscription.json - // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PlaywrightTestingAccountResource item in subscriptionResource.GetPlaywrightTestingAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlaywrightTestingAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_AccountsGet() @@ -80,10 +48,10 @@ public async Task Get_AccountsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AccountsUpdate() + public async Task Delete_AccountsDelete() { - // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_Update.json - // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_Delete.json + // this example is just showing the usage of "Accounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,30 +67,17 @@ public async Task Update_AccountsUpdate() PlaywrightTestingAccountResource playwrightTestingAccount = client.GetPlaywrightTestingAccountResource(playwrightTestingAccountResourceId); // invoke the operation - PlaywrightTestingAccountPatch patch = new PlaywrightTestingAccountPatch() - { - Tags = -{ -["Division"] = "LT", -["Team"] = "Dev Exp", -}, - RegionalAffinity = EnablementStatus.Enabled, - }; - PlaywrightTestingAccountResource result = await playwrightTestingAccount.UpdateAsync(patch); + await playwrightTestingAccount.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlaywrightTestingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AccountsDelete() + public async Task Update_AccountsUpdate() { - // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_Delete.json - // this example is just showing the usage of "Accounts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_Update.json + // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,9 +93,22 @@ public async Task Delete_AccountsDelete() PlaywrightTestingAccountResource playwrightTestingAccount = client.GetPlaywrightTestingAccountResource(playwrightTestingAccountResourceId); // invoke the operation - await playwrightTestingAccount.DeleteAsync(WaitUntil.Completed); + PlaywrightTestingAccountPatch patch = new PlaywrightTestingAccountPatch + { + Tags = +{ +["Division"] = "LT", +["Team"] = "Dev Exp" +}, + RegionalAffinity = EnablementStatus.Enabled, + }; + PlaywrightTestingAccountResource result = await playwrightTestingAccount.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlaywrightTestingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingQuotaCollection.cs b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingQuotaCollection.cs index 948ca1b2e0053..f17ae04b5e1c0 100644 --- a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingQuotaCollection.cs +++ b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_PlaywrightTestingQuotaCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_PlaywrightTestingQuotaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QuotasListBySubscription() + public async Task Get_QuotasGet() { - // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Quotas_ListBySubscription.json - // this example is just showing the usage of "Quotas_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Quotas_Get.json + // this example is just showing the usage of "Quotas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_QuotasListBySubscription() AzureLocation location = new AzureLocation("eastus"); PlaywrightTestingQuotaCollection collection = subscriptionResource.GetAllPlaywrightTestingQuota(location); - // invoke the operation and iterate over the result - await foreach (PlaywrightTestingQuotaResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlaywrightTestingQuotaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + PlaywrightTestingQuotaName name = PlaywrightTestingQuotaName.ScalableExecution; + PlaywrightTestingQuotaResource result = await collection.GetAsync(name); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlaywrightTestingQuotaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QuotasGet() + public async Task GetAll_QuotasListBySubscription() { - // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Quotas_Get.json - // this example is just showing the usage of "Quotas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Quotas_ListBySubscription.json + // this example is just showing the usage of "Quotas_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_QuotasGet() AzureLocation location = new AzureLocation("eastus"); PlaywrightTestingQuotaCollection collection = subscriptionResource.GetAllPlaywrightTestingQuota(location); - // invoke the operation - PlaywrightTestingQuotaName name = PlaywrightTestingQuotaName.ScalableExecution; - PlaywrightTestingQuotaResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (PlaywrightTestingQuotaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlaywrightTestingQuotaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlaywrightTestingQuotaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..d3357cd6bd93c --- /dev/null +++ b/sdk/playwrighttesting/Azure.ResourceManager.PlaywrightTesting/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.PlaywrightTesting.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPlaywrightTestingAccounts_AccountsListBySubscription() + { + // Generated from example definition: specification/playwrighttesting/resource-manager/Microsoft.AzurePlaywrightService/preview/2023-10-01-preview/examples/Accounts_ListBySubscription.json + // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PlaywrightTestingAccountResource item in subscriptionResource.GetPlaywrightTestingAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlaywrightTestingAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ManagementGroupResourceExtensions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ManagementGroupResourceExtensions.cs index 87ca228800f42..127cbe9f0467e 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ManagementGroupResourceExtensions.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ManagementGroupResourceExtensions.cs @@ -232,12 +232,9 @@ public async Task CheckPolicyRestrictions_CheckPolicyRestrictionsAtManagementGro ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); // invoke the operation - CheckManagementGroupPolicyRestrictionsContent content = new CheckManagementGroupPolicyRestrictionsContent() + CheckManagementGroupPolicyRestrictionsContent content = new CheckManagementGroupPolicyRestrictionsContent { - PendingFields = -{ -new PendingField("type") -}, + PendingFields = { new PendingField("type") }, }; CheckPolicyRestrictionsResult result = await managementGroupResource.CheckPolicyRestrictionsAsync(content); diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyAttestationCollection.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyAttestationCollection.cs index 38fd10e63f328..4d0902c8b40d3 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyAttestationCollection.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyAttestationCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -17,72 +16,6 @@ namespace Azure.ResourceManager.PolicyInsights.Samples { public partial class Sample_PolicyAttestationCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAttestationsAtIndividualResourceScope() - { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope.json - // this example is just showing the usage of "Attestations_ListForResource" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAttestationResource - string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyAttestationCollection collection = client.GetPolicyAttestations(scopeId); - - // invoke the operation and iterate over the result - await foreach (PolicyAttestationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyAttestationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAttestationsAtIndividualResourceScopeWithQueryParameters() - { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope_WithQuery.json - // this example is just showing the usage of "Attestations_ListForResource" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this PolicyAttestationResource - string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyAttestationCollection collection = client.GetPolicyAttestations(scopeId); - - // invoke the operation and iterate over the result - await foreach (PolicyAttestationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyAttestationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateAttestationAtIndividualResourceScope() @@ -95,13 +28,9 @@ public async Task CreateOrUpdate_CreateAttestationAtIndividualResourceScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAttestationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyAttestationCollection collection = client.GetPolicyAttestations(scopeId); + PolicyAttestationCollection collection = client.GetPolicyAttestations(new ResourceIdentifier(resourceId)); // invoke the operation string attestationName = "790996e6-9871-4b1f-9cd9-ec42cd6ced1e"; @@ -112,18 +41,15 @@ public async Task CreateOrUpdate_CreateAttestationAtIndividualResourceScope() ExpireOn = DateTimeOffset.Parse("2021-06-15T00:00:00Z"), Owner = "55a32e28-3aa5-4eea-9b5a-4cd85153b966", Comments = "This subscription has passed a security audit.", - Evidence = -{ -new AttestationEvidence() + Evidence = {new AttestationEvidence { Description = "The results of the security audit.", SourceUri = new Uri("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), -} -}, +}}, AssessOn = DateTimeOffset.Parse("2021-06-10T00:00:00Z"), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["departmentId"] = "NYC-MARKETING-1" + departmentId = "NYC-MARKETING-1", }), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attestationName, data); @@ -148,13 +74,9 @@ public async Task Get_GetAttestationAtIndividualResourceScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAttestationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyAttestationCollection collection = client.GetPolicyAttestations(scopeId); + PolicyAttestationCollection collection = client.GetPolicyAttestations(new ResourceIdentifier(resourceId)); // invoke the operation string attestationName = "790996e6-9871-4b1f-9cd9-ec42cd6ced1e"; @@ -167,6 +89,64 @@ public async Task Get_GetAttestationAtIndividualResourceScope() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAttestationsAtIndividualResourceScope() + { + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope.json + // this example is just showing the usage of "Attestations_ListForResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this PolicyAttestationResource + string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM"; + PolicyAttestationCollection collection = client.GetPolicyAttestations(new ResourceIdentifier(resourceId)); + + // invoke the operation and iterate over the result + await foreach (PolicyAttestationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyAttestationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAttestationsAtIndividualResourceScopeWithQueryParameters() + { + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_ListResourceScope_WithQuery.json + // this example is just showing the usage of "Attestations_ListForResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this PolicyAttestationResource + string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM"; + PolicyAttestationCollection collection = client.GetPolicyAttestations(new ResourceIdentifier(resourceId)); + + // invoke the operation and iterate over the result + await foreach (PolicyAttestationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyAttestationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAttestationAtIndividualResourceScope() @@ -179,13 +159,9 @@ public async Task Exists_GetAttestationAtIndividualResourceScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAttestationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyAttestationCollection collection = client.GetPolicyAttestations(scopeId); + PolicyAttestationCollection collection = client.GetPolicyAttestations(new ResourceIdentifier(resourceId)); // invoke the operation string attestationName = "790996e6-9871-4b1f-9cd9-ec42cd6ced1e"; @@ -206,13 +182,9 @@ public async Task GetIfExists_GetAttestationAtIndividualResourceScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAttestationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myrg/providers/microsoft.compute/virtualMachines/devVM"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyAttestationCollection collection = client.GetPolicyAttestations(scopeId); + PolicyAttestationCollection collection = client.GetPolicyAttestations(new ResourceIdentifier(resourceId)); // invoke the operation string attestationName = "790996e6-9871-4b1f-9cd9-ec42cd6ced1e"; diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyAttestationResource.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyAttestationResource.cs index 7fbb375c993ec..253e3e97b2233 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyAttestationResource.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyAttestationResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_PolicyAttestationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAttestationAtIndividualResourceScope() + public async Task Get_GetAttestationAtIndividualResourceScope() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_CreateResourceScope.json - // this example is just showing the usage of "Attestations_CreateOrUpdateAtResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_GetResourceScope.json + // this example is just showing the usage of "Attestations_GetAtResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,29 +36,7 @@ public async Task Update_CreateAttestationAtIndividualResourceScope() PolicyAttestationResource policyAttestation = client.GetPolicyAttestationResource(policyAttestationResourceId); // invoke the operation - PolicyAttestationData data = new PolicyAttestationData(new ResourceIdentifier("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5")) - { - PolicyDefinitionReferenceId = "0b158b46-ff42-4799-8e39-08a5c23b4551", - ComplianceState = PolicyComplianceState.Compliant, - ExpireOn = DateTimeOffset.Parse("2021-06-15T00:00:00Z"), - Owner = "55a32e28-3aa5-4eea-9b5a-4cd85153b966", - Comments = "This subscription has passed a security audit.", - Evidence = -{ -new AttestationEvidence() -{ -Description = "The results of the security audit.", -SourceUri = new Uri("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), -} -}, - AssessOn = DateTimeOffset.Parse("2021-06-10T00:00:00Z"), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["departmentId"] = "NYC-MARKETING-1" - }), - }; - ArmOperation lro = await policyAttestation.UpdateAsync(WaitUntil.Completed, data); - PolicyAttestationResource result = lro.Value; + PolicyAttestationResource result = await policyAttestation.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -70,10 +47,10 @@ public async Task Update_CreateAttestationAtIndividualResourceScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAttestationAtIndividualResourceScope() + public async Task Delete_DeleteAttestationAtIndividualResourceScope() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_GetResourceScope.json - // this example is just showing the usage of "Attestations_GetAtResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_DeleteResourceScope.json + // this example is just showing the usage of "Attestations_DeleteAtResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -88,21 +65,17 @@ public async Task Get_GetAttestationAtIndividualResourceScope() PolicyAttestationResource policyAttestation = client.GetPolicyAttestationResource(policyAttestationResourceId); // invoke the operation - PolicyAttestationResource result = await policyAttestation.GetAsync(); + await policyAttestation.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyAttestationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAttestationAtIndividualResourceScope() + public async Task Update_CreateAttestationAtIndividualResourceScope() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_DeleteResourceScope.json - // this example is just showing the usage of "Attestations_DeleteAtResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2022-09-01/examples/Attestations_CreateResourceScope.json + // this example is just showing the usage of "Attestations_CreateOrUpdateAtResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,9 +90,32 @@ public async Task Delete_DeleteAttestationAtIndividualResourceScope() PolicyAttestationResource policyAttestation = client.GetPolicyAttestationResource(policyAttestationResourceId); // invoke the operation - await policyAttestation.DeleteAsync(WaitUntil.Completed); + PolicyAttestationData data = new PolicyAttestationData(new ResourceIdentifier("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5")) + { + PolicyDefinitionReferenceId = "0b158b46-ff42-4799-8e39-08a5c23b4551", + ComplianceState = PolicyComplianceState.Compliant, + ExpireOn = DateTimeOffset.Parse("2021-06-15T00:00:00Z"), + Owner = "55a32e28-3aa5-4eea-9b5a-4cd85153b966", + Comments = "This subscription has passed a security audit.", + Evidence = {new AttestationEvidence +{ +Description = "The results of the security audit.", +SourceUri = new Uri("https://gist.github.com/contoso/9573e238762c60166c090ae16b814011"), +}}, + AssessOn = DateTimeOffset.Parse("2021-06-10T00:00:00Z"), + Metadata = BinaryData.FromObjectAsJson(new + { + departmentId = "NYC-MARKETING-1", + }), + }; + ArmOperation lro = await policyAttestation.UpdateAsync(WaitUntil.Completed, data); + PolicyAttestationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyAttestationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyMetadataCollection.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyMetadataCollection.cs index 558580ee06372..a7d91c9b3cc44 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyMetadataCollection.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyMetadataCollection.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.PolicyInsights.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.PolicyInsights.Samples @@ -28,9 +29,7 @@ public async Task Get_GetASinglePolicyMetadataResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PolicyMetadataResource PolicyMetadataCollection collection = tenantResource.GetAllPolicyMetadata(); @@ -48,122 +47,114 @@ public async Task Get_GetASinglePolicyMetadataResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASinglePolicyMetadataResource() + public async Task GetAll_GetCollectionOfPolicyMetadataResources() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_GetResource.json - // this example is just showing the usage of "PolicyMetadata_GetResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json + // this example is just showing the usage of "PolicyMetadata_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PolicyMetadataResource PolicyMetadataCollection collection = tenantResource.GetAllPolicyMetadata(); - // invoke the operation - string resourceName = "NIST_SP_800-53_R4_AC-2"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (SlimPolicyMetadata item in collection.GetAllAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASinglePolicyMetadataResource() + public async Task GetAll_GetCollectionOfPolicyMetadataResourcesUsingTopQueryParameter() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_GetResource.json - // this example is just showing the usage of "PolicyMetadata_GetResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List_WithTop.json + // this example is just showing the usage of "PolicyMetadata_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PolicyMetadataResource PolicyMetadataCollection collection = tenantResource.GetAllPolicyMetadata(); - // invoke the operation - string resourceName = "NIST_SP_800-53_R4_AC-2"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - PolicyMetadataResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SlimPolicyMetadata item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyMetadataData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {item}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetCollectionOfPolicyMetadataResources() + public async Task Exists_GetASinglePolicyMetadataResource() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List.json - // this example is just showing the usage of "PolicyMetadata_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_GetResource.json + // this example is just showing the usage of "PolicyMetadata_GetResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PolicyMetadataResource PolicyMetadataCollection collection = tenantResource.GetAllPolicyMetadata(); - // invoke the operation and iterate over the result - await foreach (SlimPolicyMetadata item in collection.GetAllAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + string resourceName = "NIST_SP_800-53_R4_AC-2"; + bool result = await collection.ExistsAsync(resourceName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetCollectionOfPolicyMetadataResourcesUsingTopQueryParameter() + public async Task GetIfExists_GetASinglePolicyMetadataResource() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_List_WithTop.json - // this example is just showing the usage of "PolicyMetadata_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2019-10-01/examples/PolicyMetadata_GetResource.json + // this example is just showing the usage of "PolicyMetadata_GetResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PolicyMetadataResource PolicyMetadataCollection collection = tenantResource.GetAllPolicyMetadata(); - // invoke the operation and iterate over the result - await foreach (SlimPolicyMetadata item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "NIST_SP_800-53_R4_AC-2"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + PolicyMetadataResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Console.WriteLine($"Succeeded: {item}"); + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyMetadataData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyRemediationCollection.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyRemediationCollection.cs index 96290e0f52dc3..add1524fef86a 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyRemediationCollection.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyRemediationCollection.cs @@ -17,135 +17,119 @@ public partial class Sample_PolicyRemediationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRemediationsAtIndividualResourceScope() + public async Task CreateOrUpdate_CreateRemediationAtIndividualResourceScope() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceScope.json - // this example is just showing the usage of "Remediations_ListForResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateResourceScope.json + // this example is just showing the usage of "Remediations_CreateOrUpdateAtResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyRemediationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyRemediationCollection collection = client.GetPolicyRemediations(scopeId); + PolicyRemediationCollection collection = client.GetPolicyRemediations(new ResourceIdentifier(resourceId)); - // invoke the operation and iterate over the result - await foreach (PolicyRemediationResource item in collection.GetAllAsync()) + // invoke the operation + string remediationName = "storageRemediation"; + PolicyRemediationData data = new PolicyRemediationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyRemediationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PolicyAssignmentId = new ResourceIdentifier("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, remediationName, data); + PolicyRemediationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyRemediationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRemediationsAtIndividualResourceScopeWithQueryParameters() + public async Task Get_GetRemediationAtIndividualResourceScope() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceScope_WithQuery.json - // this example is just showing the usage of "Remediations_ListForResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetResourceScope.json + // this example is just showing the usage of "Remediations_GetAtResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyRemediationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyRemediationCollection collection = client.GetPolicyRemediations(scopeId); + PolicyRemediationCollection collection = client.GetPolicyRemediations(new ResourceIdentifier(resourceId)); - // invoke the operation and iterate over the result - await foreach (PolicyRemediationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyRemediationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string remediationName = "storageRemediation"; + PolicyRemediationResource result = await collection.GetAsync(remediationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyRemediationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateRemediationAtIndividualResourceScope() + public async Task GetAll_ListRemediationsAtIndividualResourceScope() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CreateResourceScope.json - // this example is just showing the usage of "Remediations_CreateOrUpdateAtResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceScope.json + // this example is just showing the usage of "Remediations_ListForResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyRemediationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyRemediationCollection collection = client.GetPolicyRemediations(scopeId); + PolicyRemediationCollection collection = client.GetPolicyRemediations(new ResourceIdentifier(resourceId)); - // invoke the operation - string remediationName = "storageRemediation"; - PolicyRemediationData data = new PolicyRemediationData() + // invoke the operation and iterate over the result + await foreach (PolicyRemediationResource item in collection.GetAllAsync()) { - PolicyAssignmentId = new ResourceIdentifier("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, remediationName, data); - PolicyRemediationResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyRemediationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyRemediationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRemediationAtIndividualResourceScope() + public async Task GetAll_ListRemediationsAtIndividualResourceScopeWithQueryParameters() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetResourceScope.json - // this example is just showing the usage of "Remediations_GetAtResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListResourceScope_WithQuery.json + // this example is just showing the usage of "Remediations_ListForResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyRemediationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyRemediationCollection collection = client.GetPolicyRemediations(scopeId); + PolicyRemediationCollection collection = client.GetPolicyRemediations(new ResourceIdentifier(resourceId)); - // invoke the operation - string remediationName = "storageRemediation"; - PolicyRemediationResource result = await collection.GetAsync(remediationName); + // invoke the operation and iterate over the result + await foreach (PolicyRemediationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyRemediationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyRemediationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -160,13 +144,9 @@ public async Task Exists_GetRemediationAtIndividualResourceScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyRemediationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyRemediationCollection collection = client.GetPolicyRemediations(scopeId); + PolicyRemediationCollection collection = client.GetPolicyRemediations(new ResourceIdentifier(resourceId)); // invoke the operation string remediationName = "storageRemediation"; @@ -187,13 +167,9 @@ public async Task GetIfExists_GetRemediationAtIndividualResourceScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyRemediationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - PolicyRemediationCollection collection = client.GetPolicyRemediations(scopeId); + PolicyRemediationCollection collection = client.GetPolicyRemediations(new ResourceIdentifier(resourceId)); // invoke the operation string remediationName = "storageRemediation"; diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyRemediationResource.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyRemediationResource.cs index 180ca304769f3..1cc9119db85b7 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyRemediationResource.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_PolicyRemediationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_PolicyRemediationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDeployments_ListDeploymentsForARemediationAtIndividualResourceScope() + public async Task Get_GetRemediationAtIndividualResourceScope() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsResourceScope.json - // this example is just showing the usage of "Remediations_ListDeploymentsAtResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetResourceScope.json + // this example is just showing the usage of "Remediations_GetAtResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,25 +31,26 @@ public async Task GetDeployments_ListDeploymentsForARemediationAtIndividualResou // this example assumes you already have this PolicyRemediationResource created on azure // for more information of creating PolicyRemediationResource, please refer to the document of PolicyRemediationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"; - string remediationName = "myRemediation"; + string remediationName = "storageRemediation"; ResourceIdentifier policyRemediationResourceId = PolicyRemediationResource.CreateResourceIdentifier(resourceId, remediationName); PolicyRemediationResource policyRemediation = client.GetPolicyRemediationResource(policyRemediationResourceId); - // invoke the operation and iterate over the result - await foreach (RemediationDeployment item in policyRemediation.GetDeploymentsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + PolicyRemediationResource result = await policyRemediation.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyRemediationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Cancel_CancelARemediationAtIndividualResourceScope() + public async Task Delete_DeleteRemediationAtIndividualResourceScope() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelResourceScope.json - // this example is just showing the usage of "Remediations_CancelAtResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteResourceScope.json + // this example is just showing the usage of "Remediations_DeleteAtResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,12 +60,13 @@ public async Task Cancel_CancelARemediationAtIndividualResourceScope() // this example assumes you already have this PolicyRemediationResource created on azure // for more information of creating PolicyRemediationResource, please refer to the document of PolicyRemediationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"; - string remediationName = "myRemediation"; + string remediationName = "storageRemediation"; ResourceIdentifier policyRemediationResourceId = PolicyRemediationResource.CreateResourceIdentifier(resourceId, remediationName); PolicyRemediationResource policyRemediation = client.GetPolicyRemediationResource(policyRemediationResourceId); // invoke the operation - PolicyRemediationResource result = await policyRemediation.CancelAsync(); + ArmOperation lro = await policyRemediation.DeleteAsync(WaitUntil.Completed); + PolicyRemediationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -93,7 +95,7 @@ public async Task Update_CreateRemediationAtIndividualResourceScope() PolicyRemediationResource policyRemediation = client.GetPolicyRemediationResource(policyRemediationResourceId); // invoke the operation - PolicyRemediationData data = new PolicyRemediationData() + PolicyRemediationData data = new PolicyRemediationData { PolicyAssignmentId = new ResourceIdentifier("/subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourceGroups/myResourceGroup/providers/microsoft.authorization/policyassignments/b101830944f246d8a14088c5"), }; @@ -109,10 +111,10 @@ public async Task Update_CreateRemediationAtIndividualResourceScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRemediationAtIndividualResourceScope() + public async Task GetDeployments_ListDeploymentsForARemediationAtIndividualResourceScope() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_GetResourceScope.json - // this example is just showing the usage of "Remediations_GetAtResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_ListDeploymentsResourceScope.json + // this example is just showing the usage of "Remediations_ListDeploymentsAtResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,26 +124,25 @@ public async Task Get_GetRemediationAtIndividualResourceScope() // this example assumes you already have this PolicyRemediationResource created on azure // for more information of creating PolicyRemediationResource, please refer to the document of PolicyRemediationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"; - string remediationName = "storageRemediation"; + string remediationName = "myRemediation"; ResourceIdentifier policyRemediationResourceId = PolicyRemediationResource.CreateResourceIdentifier(resourceId, remediationName); PolicyRemediationResource policyRemediation = client.GetPolicyRemediationResource(policyRemediationResourceId); - // invoke the operation - PolicyRemediationResource result = await policyRemediation.GetAsync(); + // invoke the operation and iterate over the result + await foreach (RemediationDeployment item in policyRemediation.GetDeploymentsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyRemediationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRemediationAtIndividualResourceScope() + public async Task Cancel_CancelARemediationAtIndividualResourceScope() { - // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_DeleteResourceScope.json - // this example is just showing the usage of "Remediations_DeleteAtResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/policyinsights/resource-manager/Microsoft.PolicyInsights/stable/2021-10-01/examples/Remediations_CancelResourceScope.json + // this example is just showing the usage of "Remediations_CancelAtResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,13 +152,12 @@ public async Task Delete_DeleteRemediationAtIndividualResourceScope() // this example assumes you already have this PolicyRemediationResource created on azure // for more information of creating PolicyRemediationResource, please refer to the document of PolicyRemediationResource string resourceId = "subscriptions/35ee058e-5fa0-414c-8145-3ebb8d09b6e2/resourcegroups/myResourceGroup/providers/microsoft.storage/storageaccounts/storAc1"; - string remediationName = "storageRemediation"; + string remediationName = "myRemediation"; ResourceIdentifier policyRemediationResourceId = PolicyRemediationResource.CreateResourceIdentifier(resourceId, remediationName); PolicyRemediationResource policyRemediation = client.GetPolicyRemediationResource(policyRemediationResourceId); // invoke the operation - ArmOperation lro = await policyRemediation.DeleteAsync(WaitUntil.Completed); - PolicyRemediationResource result = lro.Value; + PolicyRemediationResource result = await policyRemediation.CancelAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index ad6109536a83d..5f47748f61fdc 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -266,34 +265,25 @@ public async Task CheckPolicyRestrictions_CheckPolicyRestrictionsAtResourceGroup ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // invoke the operation - CheckPolicyRestrictionsContent content = new CheckPolicyRestrictionsContent(new CheckRestrictionsResourceDetails(BinaryData.FromObjectAsJson(new Dictionary() + CheckPolicyRestrictionsContent content = new CheckPolicyRestrictionsContent(new CheckRestrictionsResourceDetails(BinaryData.FromObjectAsJson(new { - ["type"] = "Microsoft.Compute/virtualMachines", - ["properties"] = new Dictionary() + type = "Microsoft.Compute/virtualMachines", + properties = new { - ["priority"] = "Spot" - } + priority = "Spot", + }, })) { ApiVersion = "2019-12-01", }) { - PendingFields = + PendingFields = {new PendingField("name") { -new PendingField("name") +Values = {"myVMName"}, +}, new PendingField("location") { -Values = -{ -"myVMName" -}, -},new PendingField("location") -{ -Values = -{ -"eastus","westus","westus2","westeurope" -}, -},new PendingField("tags") -}, +Values = {"eastus", "westus", "westus2", "westeurope"}, +}, new PendingField("tags")}, }; CheckPolicyRestrictionsResult result = await resourceGroupResource.CheckPolicyRestrictionsAsync(content); diff --git a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 3d2455300c846..1fcfe4ae73ad9 100644 --- a/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/policyinsights/Azure.ResourceManager.PolicyInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -565,34 +564,25 @@ public async Task CheckPolicyRestrictions_CheckPolicyRestrictionsAtSubscriptionS SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - CheckPolicyRestrictionsContent content = new CheckPolicyRestrictionsContent(new CheckRestrictionsResourceDetails(BinaryData.FromObjectAsJson(new Dictionary() + CheckPolicyRestrictionsContent content = new CheckPolicyRestrictionsContent(new CheckRestrictionsResourceDetails(BinaryData.FromObjectAsJson(new { - ["type"] = "Microsoft.Compute/virtualMachines", - ["properties"] = new Dictionary() + type = "Microsoft.Compute/virtualMachines", + properties = new { - ["priority"] = "Spot" - } + priority = "Spot", + }, })) { ApiVersion = "2019-12-01", }) { - PendingFields = + PendingFields = {new PendingField("name") { -new PendingField("name") +Values = {"myVMName"}, +}, new PendingField("location") { -Values = -{ -"myVMName" -}, -},new PendingField("location") -{ -Values = -{ -"eastus","westus","westus2","westeurope" -}, -},new PendingField("tags") -}, +Values = {"eastus", "westus", "westus2", "westeurope"}, +}, new PendingField("tags")}, }; CheckPolicyRestrictionsResult result = await subscriptionResource.CheckPolicyRestrictionsAsync(content); diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationCollection.cs index 258b0c8754297..983b530892cad 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_ConfigurationCreateOrUpdate() // invoke the operation string configurationName = "array_nulls"; - PostgreSqlConfigurationData data = new PostgreSqlConfigurationData() + PostgreSqlConfigurationData data = new PostgreSqlConfigurationData { Value = "off", Source = "user-override", @@ -91,10 +91,10 @@ public async Task Get_ConfigurationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConfigurationGet() + public async Task GetAll_ConfigurationList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationGet.json - // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationListByServer.json + // this example is just showing the usage of "Configurations_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_ConfigurationGet() // get the collection of this PostgreSqlConfigurationResource PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); - // invoke the operation - string configurationName = "array_nulls"; - bool result = await collection.ExistsAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConfigurationGet() + public async Task Exists_ConfigurationGet() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationGet.json // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_ConfigurationGet() // invoke the operation string configurationName = "array_nulls"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - PostgreSqlConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConfigurationList() + public async Task GetIfExists_ConfigurationGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationListByServer.json - // this example is just showing the usage of "Configurations_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationGet.json + // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ConfigurationList() // get the collection of this PostgreSqlConfigurationResource PostgreSqlConfigurationCollection collection = postgreSqlServer.GetPostgreSqlConfigurations(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string configurationName = "array_nulls"; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + PostgreSqlConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlConfigurationData resourceData = item.Data; + PostgreSqlConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationResource.cs index 52303a2069fb0..dc3330eeee423 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlConfigurationResource.cs @@ -17,10 +17,10 @@ public partial class Sample_PostgreSqlConfigurationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConfigurationCreateOrUpdate() + public async Task Get_ConfigurationGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationCreateOrUpdate.json - // this example is just showing the usage of "Configurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationGet.json + // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,13 +37,7 @@ public async Task Update_ConfigurationCreateOrUpdate() PostgreSqlConfigurationResource postgreSqlConfiguration = client.GetPostgreSqlConfigurationResource(postgreSqlConfigurationResourceId); // invoke the operation - PostgreSqlConfigurationData data = new PostgreSqlConfigurationData() - { - Value = "off", - Source = "user-override", - }; - ArmOperation lro = await postgreSqlConfiguration.UpdateAsync(WaitUntil.Completed, data); - PostgreSqlConfigurationResource result = lro.Value; + PostgreSqlConfigurationResource result = await postgreSqlConfiguration.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +48,10 @@ public async Task Update_ConfigurationCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConfigurationGet() + public async Task Update_ConfigurationCreateOrUpdate() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationGet.json - // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ConfigurationCreateOrUpdate.json + // this example is just showing the usage of "Configurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,7 +68,13 @@ public async Task Get_ConfigurationGet() PostgreSqlConfigurationResource postgreSqlConfiguration = client.GetPostgreSqlConfigurationResource(postgreSqlConfigurationResourceId); // invoke the operation - PostgreSqlConfigurationResource result = await postgreSqlConfiguration.GetAsync(); + PostgreSqlConfigurationData data = new PostgreSqlConfigurationData + { + Value = "off", + Source = "user-override", + }; + ArmOperation lro = await postgreSqlConfiguration.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseCollection.cs index e08bdc5e2ed21..4befdc9520e25 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_DatabaseCreate() // invoke the operation string databaseName = "db1"; - PostgreSqlDatabaseData data = new PostgreSqlDatabaseData() + PostgreSqlDatabaseData data = new PostgreSqlDatabaseData { Charset = "UTF8", Collation = "English_United States.1252", @@ -91,10 +91,10 @@ public async Task Get_DatabaseGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DatabaseGet() + public async Task GetAll_DatabaseList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseListByServer.json + // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_DatabaseGet() // get the collection of this PostgreSqlDatabaseResource PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); - // invoke the operation - string databaseName = "db1"; - bool result = await collection.ExistsAsync(databaseName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DatabaseGet() + public async Task Exists_DatabaseGet() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseGet.json // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_DatabaseGet() // invoke the operation string databaseName = "db1"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - PostgreSqlDatabaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(databaseName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DatabaseList() + public async Task GetIfExists_DatabaseGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseListByServer.json - // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_DatabaseList() // get the collection of this PostgreSqlDatabaseResource PostgreSqlDatabaseCollection collection = postgreSqlServer.GetPostgreSqlDatabases(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "db1"; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + PostgreSqlDatabaseResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlDatabaseData resourceData = item.Data; + PostgreSqlDatabaseData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseResource.cs index 87b1446349110..10a790c69aacb 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlDatabaseResource.cs @@ -17,10 +17,10 @@ public partial class Sample_PostgreSqlDatabaseResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DatabaseCreate() + public async Task Get_DatabaseGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseCreate.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,13 +37,7 @@ public async Task Update_DatabaseCreate() PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); // invoke the operation - PostgreSqlDatabaseData data = new PostgreSqlDatabaseData() - { - Charset = "UTF8", - Collation = "English_United States.1252", - }; - ArmOperation lro = await postgreSqlDatabase.UpdateAsync(WaitUntil.Completed, data); - PostgreSqlDatabaseResource result = lro.Value; + PostgreSqlDatabaseResource result = await postgreSqlDatabase.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +75,10 @@ public async Task Delete_DatabaseDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DatabaseGet() + public async Task Update_DatabaseCreate() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/DatabaseCreate.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +95,13 @@ public async Task Get_DatabaseGet() PostgreSqlDatabaseResource postgreSqlDatabase = client.GetPostgreSqlDatabaseResource(postgreSqlDatabaseResourceId); // invoke the operation - PostgreSqlDatabaseResource result = await postgreSqlDatabase.GetAsync(); + PostgreSqlDatabaseData data = new PostgreSqlDatabaseData + { + Charset = "UTF8", + Collation = "English_United States.1252", + }; + ArmOperation lro = await postgreSqlDatabase.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs index e4e2a6e7716f9..4c352107d25ae 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleCollection.cs @@ -88,10 +88,10 @@ public async Task Get_FirewallRuleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FirewallRuleGet() + public async Task GetAll_FirewallRuleList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/FirewallRuleListByServer.json + // this example is just showing the usage of "FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_FirewallRuleGet() // get the collection of this PostgreSqlFirewallRuleResource PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); - // invoke the operation - string firewallRuleName = "rule1"; - bool result = await collection.ExistsAsync(firewallRuleName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlFirewallRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFirewallRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FirewallRuleGet() + public async Task Exists_FirewallRuleGet() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/FirewallRuleGet.json // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_FirewallRuleGet() // invoke the operation string firewallRuleName = "rule1"; - NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); - PostgreSqlFirewallRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(firewallRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FirewallRuleList() + public async Task GetIfExists_FirewallRuleGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/FirewallRuleListByServer.json - // this example is just showing the usage of "FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_FirewallRuleList() // get the collection of this PostgreSqlFirewallRuleResource PostgreSqlFirewallRuleCollection collection = postgreSqlServer.GetPostgreSqlFirewallRules(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFirewallRuleResource item in collection.GetAllAsync()) + // invoke the operation + string firewallRuleName = "rule1"; + NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); + PostgreSqlFirewallRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlFirewallRuleData resourceData = item.Data; + PostgreSqlFirewallRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleResource.cs index e208ddf12da38..8c2741049a234 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFirewallRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_PostgreSqlFirewallRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FirewallRuleCreate() + public async Task Get_FirewallRuleGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/FirewallRuleCreate.json - // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Update_FirewallRuleCreate() PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); // invoke the operation - PostgreSqlFirewallRuleData data = new PostgreSqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); - ArmOperation lro = await postgreSqlFirewallRule.UpdateAsync(WaitUntil.Completed, data); - PostgreSqlFirewallRuleResource result = lro.Value; + PostgreSqlFirewallRuleResource result = await postgreSqlFirewallRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -78,10 +76,10 @@ public async Task Delete_FirewallRuleDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FirewallRuleGet() + public async Task Update_FirewallRuleCreate() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/FirewallRuleCreate.json + // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,7 +96,9 @@ public async Task Get_FirewallRuleGet() PostgreSqlFirewallRuleResource postgreSqlFirewallRule = client.GetPostgreSqlFirewallRuleResource(postgreSqlFirewallRuleResourceId); // invoke the operation - PostgreSqlFirewallRuleResource result = await postgreSqlFirewallRule.GetAsync(); + PostgreSqlFirewallRuleData data = new PostgreSqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await postgreSqlFirewallRule.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlFirewallRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs index 307280a6ff0f3..a53f30a5f79e4 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_AddsAnActiveDIrectoryAdministratorForTheServer( // invoke the operation string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; - PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent content = new PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent() + PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent content = new PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent { PrincipalType = PostgreSqlFlexibleServerPrincipalType.User, PrincipalName = "testuser1@microsoft.com", @@ -93,10 +93,10 @@ public async Task Get_ServerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServerGet() + public async Task GetAll_AdministratorsListByServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/AdministratorGet.json - // this example is just showing the usage of "Administrators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/AdministratorsListByServer.json + // this example is just showing the usage of "Administrators_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +114,22 @@ public async Task Exists_ServerGet() // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); - // invoke the operation - string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; - bool result = await collection.ExistsAsync(objectId); + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServerActiveDirectoryAdministratorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerActiveDirectoryAdministratorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServerGet() + public async Task Exists_ServerGet() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/AdministratorGet.json // this example is just showing the usage of "Administrators_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +152,17 @@ public async Task GetIfExists_ServerGet() // invoke the operation string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; - NullableResponse response = await collection.GetIfExistsAsync(objectId); - PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(objectId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerActiveDirectoryAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AdministratorsListByServer() + public async Task GetIfExists_ServerGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/AdministratorsListByServer.json - // this example is just showing the usage of "Administrators_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/AdministratorGet.json + // this example is just showing the usage of "Administrators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_AdministratorsListByServer() // get the collection of this PostgreSqlFlexibleServerActiveDirectoryAdministratorResource PostgreSqlFlexibleServerActiveDirectoryAdministratorCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerActiveDirectoryAdministrators(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServerActiveDirectoryAdministratorResource item in collection.GetAllAsync()) + // invoke the operation + string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; + NullableResponse response = await collection.GetIfExistsAsync(objectId); + PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerActiveDirectoryAdministratorData resourceData = item.Data; + PostgreSqlFlexibleServerActiveDirectoryAdministratorData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.cs index 5cd7790f2bf1c..70bf20dc0b5a6 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.cs @@ -18,10 +18,10 @@ public partial class Sample_PostgreSqlFlexibleServerActiveDirectoryAdministrator { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AddsAnActiveDIrectoryAdministratorForTheServer() + public async Task Get_ServerGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/AdministratorAdd.json - // this example is just showing the usage of "Administrators_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/AdministratorGet.json + // this example is just showing the usage of "Administrators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,20 +32,13 @@ public async Task Update_AddsAnActiveDIrectoryAdministratorForTheServer() // for more information of creating PostgreSqlFlexibleServerActiveDirectoryAdministratorResource, please refer to the document of PostgreSqlFlexibleServerActiveDirectoryAdministratorResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "testrg"; - string serverName = "testserver"; + string serverName = "pgtestsvc1"; string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; ResourceIdentifier postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId = PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, objectId); PostgreSqlFlexibleServerActiveDirectoryAdministratorResource postgreSqlFlexibleServerActiveDirectoryAdministrator = client.GetPostgreSqlFlexibleServerActiveDirectoryAdministratorResource(postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId); // invoke the operation - PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent content = new PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent() - { - PrincipalType = PostgreSqlFlexibleServerPrincipalType.User, - PrincipalName = "testuser1@microsoft.com", - TenantId = Guid.Parse("tttttttt-tttt-tttt-tttt-tttttttttttt"), - }; - ArmOperation lro = await postgreSqlFlexibleServerActiveDirectoryAdministrator.UpdateAsync(WaitUntil.Completed, content); - PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = lro.Value; + PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = await postgreSqlFlexibleServerActiveDirectoryAdministrator.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -83,10 +76,10 @@ public async Task Delete_AdministratorDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ServerGet() + public async Task Update_AddsAnActiveDIrectoryAdministratorForTheServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/AdministratorGet.json - // this example is just showing the usage of "Administrators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/AdministratorAdd.json + // this example is just showing the usage of "Administrators_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,13 +90,20 @@ public async Task Get_ServerGet() // for more information of creating PostgreSqlFlexibleServerActiveDirectoryAdministratorResource, please refer to the document of PostgreSqlFlexibleServerActiveDirectoryAdministratorResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "testrg"; - string serverName = "pgtestsvc1"; + string serverName = "testserver"; string objectId = "oooooooo-oooo-oooo-oooo-oooooooooooo"; ResourceIdentifier postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId = PostgreSqlFlexibleServerActiveDirectoryAdministratorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, objectId); PostgreSqlFlexibleServerActiveDirectoryAdministratorResource postgreSqlFlexibleServerActiveDirectoryAdministrator = client.GetPostgreSqlFlexibleServerActiveDirectoryAdministratorResource(postgreSqlFlexibleServerActiveDirectoryAdministratorResourceId); // invoke the operation - PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = await postgreSqlFlexibleServerActiveDirectoryAdministrator.GetAsync(); + PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent content = new PostgreSqlFlexibleServerActiveDirectoryAdministratorCreateOrUpdateContent + { + PrincipalType = PostgreSqlFlexibleServerPrincipalType.User, + PrincipalName = "testuser1@microsoft.com", + TenantId = Guid.Parse("tttttttt-tttt-tttt-tttt-tttttttttttt"), + }; + ArmOperation lro = await postgreSqlFlexibleServerActiveDirectoryAdministrator.UpdateAsync(WaitUntil.Completed, content); + PostgreSqlFlexibleServerActiveDirectoryAdministratorResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupCollection.cs index 1c56a902b0c49..add1d4a2f0c68 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupCollection.cs @@ -86,10 +86,10 @@ public async Task Get_GetABackupForAServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetABackupForAServer() + public async Task GetAll_ListBackupsForAServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/BackupGet.json - // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/BackupListByServer.json + // this example is just showing the usage of "Backups_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +107,22 @@ public async Task Exists_GetABackupForAServer() // get the collection of this PostgreSqlFlexibleServerBackupResource PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); - // invoke the operation - string backupName = "daily_20210615T160516"; - bool result = await collection.ExistsAsync(backupName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServerBackupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerBackupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetABackupForAServer() + public async Task Exists_GetABackupForAServer() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/BackupGet.json // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +145,17 @@ public async Task GetIfExists_GetABackupForAServer() // invoke the operation string backupName = "daily_20210615T160516"; - NullableResponse response = await collection.GetIfExistsAsync(backupName); - PostgreSqlFlexibleServerBackupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(backupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBackupsForAServer() + public async Task GetIfExists_GetABackupForAServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/BackupListByServer.json - // this example is just showing the usage of "Backups_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/BackupGet.json + // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_ListBackupsForAServer() // get the collection of this PostgreSqlFlexibleServerBackupResource PostgreSqlFlexibleServerBackupCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerBackups(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServerBackupResource item in collection.GetAllAsync()) + // invoke the operation + string backupName = "daily_20210615T160516"; + NullableResponse response = await collection.GetIfExistsAsync(backupName); + PostgreSqlFlexibleServerBackupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerBackupData resourceData = item.Data; + PostgreSqlFlexibleServerBackupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupResource.cs index 50021efe0f498..40a0b4b4fef5e 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerBackupResource.cs @@ -17,10 +17,10 @@ public partial class Sample_PostgreSqlFlexibleServerBackupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateANewBackupForAFlexibleServer() + public async Task Get_GetABackupForAServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/BackupCreate.json - // this example is just showing the usage of "Backups_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/BackupGet.json + // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,13 +32,12 @@ public async Task Update_CreateANewBackupForAFlexibleServer() string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "TestGroup"; string serverName = "postgresqltestserver"; - string backupName = "backup_20210615T160516"; + string backupName = "daily_20210615T160516"; ResourceIdentifier postgreSqlFlexibleServerBackupResourceId = PostgreSqlFlexibleServerBackupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); PostgreSqlFlexibleServerBackupResource postgreSqlFlexibleServerBackup = client.GetPostgreSqlFlexibleServerBackupResource(postgreSqlFlexibleServerBackupResourceId); // invoke the operation - ArmOperation lro = await postgreSqlFlexibleServerBackup.UpdateAsync(WaitUntil.Completed); - PostgreSqlFlexibleServerBackupResource result = lro.Value; + PostgreSqlFlexibleServerBackupResource result = await postgreSqlFlexibleServerBackup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -76,10 +75,10 @@ public async Task Delete_DeleteASpecificBackup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetABackupForAServer() + public async Task Update_CreateANewBackupForAFlexibleServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/BackupGet.json - // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/BackupCreate.json + // this example is just showing the usage of "Backups_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,12 +90,13 @@ public async Task Get_GetABackupForAServer() string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "TestGroup"; string serverName = "postgresqltestserver"; - string backupName = "daily_20210615T160516"; + string backupName = "backup_20210615T160516"; ResourceIdentifier postgreSqlFlexibleServerBackupResourceId = PostgreSqlFlexibleServerBackupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); PostgreSqlFlexibleServerBackupResource postgreSqlFlexibleServerBackup = client.GetPostgreSqlFlexibleServerBackupResource(postgreSqlFlexibleServerBackupResourceId); // invoke the operation - PostgreSqlFlexibleServerBackupResource result = await postgreSqlFlexibleServerBackup.GetAsync(); + ArmOperation lro = await postgreSqlFlexibleServerBackup.UpdateAsync(WaitUntil.Completed); + PostgreSqlFlexibleServerBackupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs index 251b05890adbd..49f00432c084d 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerCollection.cs @@ -49,10 +49,10 @@ public async Task CreateOrUpdate_CreateADatabaseAsAGeoRestoreInGeoPairedLocation UserAssignedIdentities = { ["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity"] = new UserAssignedIdentity(), -["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), +["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity() }, }, - DataEncryption = new PostgreSqlFlexibleServerDataEncryption() + DataEncryption = new PostgreSqlFlexibleServerDataEncryption { PrimaryKeyUri = new Uri("https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787"), PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"), @@ -144,23 +144,23 @@ public async Task CreateOrUpdate_CreateANewServer() AdministratorLogin = "cloudsa", AdministratorLoginPassword = "password", Version = PostgreSqlFlexibleServerVersion.Ver12, - Storage = new PostgreSqlFlexibleServerStorage() + Storage = new PostgreSqlFlexibleServerStorage { StorageSizeInGB = 512, AutoGrow = StorageAutoGrow.Disabled, Tier = PostgreSqlManagedDiskPerformanceTier.P20, }, - Backup = new PostgreSqlFlexibleServerBackupProperties() + Backup = new PostgreSqlFlexibleServerBackupProperties { BackupRetentionDays = 7, GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, }, - Network = new PostgreSqlFlexibleServerNetwork() + Network = new PostgreSqlFlexibleServerNetwork { DelegatedSubnetResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"), PrivateDnsZoneArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"), }, - HighAvailability = new PostgreSqlFlexibleServerHighAvailability() + HighAvailability = new PostgreSqlFlexibleServerHighAvailability { Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, }, @@ -168,7 +168,7 @@ public async Task CreateOrUpdate_CreateANewServer() CreateMode = PostgreSqlFlexibleServerCreateMode.Create, Tags = { -["ElasticServer"] = "1", +["ElasticServer"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); @@ -211,33 +211,33 @@ public async Task CreateOrUpdate_CreateANewServerWithActiveDirectoryAuthenticati AdministratorLogin = "cloudsa", AdministratorLoginPassword = "password", Version = PostgreSqlFlexibleServerVersion.Ver12, - Storage = new PostgreSqlFlexibleServerStorage() + Storage = new PostgreSqlFlexibleServerStorage { StorageSizeInGB = 512, AutoGrow = StorageAutoGrow.Disabled, Tier = PostgreSqlManagedDiskPerformanceTier.P20, }, - AuthConfig = new PostgreSqlFlexibleServerAuthConfig() + AuthConfig = new PostgreSqlFlexibleServerAuthConfig { ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, TenantId = Guid.Parse("tttttt-tttt-tttt-tttt-tttttttttttt"), }, - DataEncryption = new PostgreSqlFlexibleServerDataEncryption() + DataEncryption = new PostgreSqlFlexibleServerDataEncryption { KeyType = PostgreSqlFlexibleServerKeyType.SystemManaged, }, - Backup = new PostgreSqlFlexibleServerBackupProperties() + Backup = new PostgreSqlFlexibleServerBackupProperties { BackupRetentionDays = 7, GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, }, - Network = new PostgreSqlFlexibleServerNetwork() + Network = new PostgreSqlFlexibleServerNetwork { DelegatedSubnetResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"), PrivateDnsZoneArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"), }, - HighAvailability = new PostgreSqlFlexibleServerHighAvailability() + HighAvailability = new PostgreSqlFlexibleServerHighAvailability { Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, }, @@ -245,7 +245,7 @@ public async Task CreateOrUpdate_CreateANewServerWithActiveDirectoryAuthenticati CreateMode = PostgreSqlFlexibleServerCreateMode.Create, Tags = { -["ElasticServer"] = "1", +["ElasticServer"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); @@ -288,10 +288,10 @@ public async Task CreateOrUpdate_ServerCreateReplica() { UserAssignedIdentities = { -["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), +["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity() }, }, - DataEncryption = new PostgreSqlFlexibleServerDataEncryption() + DataEncryption = new PostgreSqlFlexibleServerDataEncryption { PrimaryKeyUri = new Uri("https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787"), PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"), @@ -384,18 +384,18 @@ public async Task CreateOrUpdate_ServerCreateWithDataEncryptionEnabled() { UserAssignedIdentities = { -["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), +["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity() }, }, AdministratorLogin = "cloudsa", AdministratorLoginPassword = "password", Version = PostgreSqlFlexibleServerVersion.Ver12, - Storage = new PostgreSqlFlexibleServerStorage() + Storage = new PostgreSqlFlexibleServerStorage { StorageSizeInGB = 512, AutoGrow = StorageAutoGrow.Disabled, }, - DataEncryption = new PostgreSqlFlexibleServerDataEncryption() + DataEncryption = new PostgreSqlFlexibleServerDataEncryption { PrimaryKeyUri = new Uri("https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787"), PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"), @@ -403,17 +403,17 @@ public async Task CreateOrUpdate_ServerCreateWithDataEncryptionEnabled() GeoBackupUserAssignedIdentityId = "", KeyType = PostgreSqlFlexibleServerKeyType.AzureKeyVault, }, - Backup = new PostgreSqlFlexibleServerBackupProperties() + Backup = new PostgreSqlFlexibleServerBackupProperties { BackupRetentionDays = 7, GeoRedundantBackup = PostgreSqlFlexibleServerGeoRedundantBackupEnum.Disabled, }, - Network = new PostgreSqlFlexibleServerNetwork() + Network = new PostgreSqlFlexibleServerNetwork { DelegatedSubnetResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/test-vnet-subnet"), PrivateDnsZoneArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourcegroups/testrg/providers/Microsoft.Network/privateDnsZones/test-private-dns-zone.postgres.database.azure.com"), }, - HighAvailability = new PostgreSqlFlexibleServerHighAvailability() + HighAvailability = new PostgreSqlFlexibleServerHighAvailability { Mode = PostgreSqlFlexibleServerHighAvailabilityMode.ZoneRedundant, }, @@ -421,7 +421,7 @@ public async Task CreateOrUpdate_ServerCreateWithDataEncryptionEnabled() CreateMode = PostgreSqlFlexibleServerCreateMode.Create, Tags = { -["ElasticServer"] = "1", +["ElasticServer"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); @@ -469,9 +469,9 @@ public async Task Get_ServerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServerGet() + public async Task Get_ServerGetWithPrivateEndpoints() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGet.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithPrivateEndpoints.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -490,17 +490,21 @@ public async Task Exists_ServerGet() PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); // invoke the operation - string serverName = "pgtestsvc1"; - bool result = await collection.ExistsAsync(serverName); + string serverName = "pgtestsvc2"; + PostgreSqlFlexibleServerResource result = await collection.GetAsync(serverName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServerGet() + public async Task Get_ServerGetWithVnet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGet.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithVnet.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -519,30 +523,22 @@ public async Task GetIfExists_ServerGet() PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); // invoke the operation - string serverName = "pgtestsvc1"; - NullableResponse response = await collection.GetIfExistsAsync(serverName); - PostgreSqlFlexibleServerResource result = response.HasValue ? response.Value : null; + string serverName = "pgtestsvc4"; + PostgreSqlFlexibleServerResource result = await collection.GetAsync(serverName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ServerGetWithPrivateEndpoints() + public async Task GetAll_ServerListByResourceGroup() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithPrivateEndpoints.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerListByResourceGroup.json + // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -559,23 +555,25 @@ public async Task Get_ServerGetWithPrivateEndpoints() // get the collection of this PostgreSqlFlexibleServerResource PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - // invoke the operation - string serverName = "pgtestsvc2"; - PostgreSqlFlexibleServerResource result = await collection.GetAsync(serverName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServerGetWithPrivateEndpoints() + public async Task GetReplicas_ReplicasListByServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithPrivateEndpoints.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ReplicasListByServer.json + // this example is just showing the usage of "Replicas_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -592,18 +590,25 @@ public async Task Exists_ServerGetWithPrivateEndpoints() // get the collection of this PostgreSqlFlexibleServerResource PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - // invoke the operation - string serverName = "pgtestsvc2"; - bool result = await collection.ExistsAsync(serverName); + // invoke the operation and iterate over the result + string serverName = "sourcepgservername"; + await foreach (PostgreSqlFlexibleServerResource item in collection.GetReplicasAsync(serverName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServerGetWithPrivateEndpoints() + public async Task Exists_ServerGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithPrivateEndpoints.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGet.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -622,29 +627,17 @@ public async Task GetIfExists_ServerGetWithPrivateEndpoints() PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); // invoke the operation - string serverName = "pgtestsvc2"; - NullableResponse response = await collection.GetIfExistsAsync(serverName); - PostgreSqlFlexibleServerResource result = response.HasValue ? response.Value : null; + string serverName = "pgtestsvc1"; + bool result = await collection.ExistsAsync(serverName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ServerGetWithVnet() + public async Task Exists_ServerGetWithPrivateEndpoints() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithVnet.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithPrivateEndpoints.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -663,14 +656,10 @@ public async Task Get_ServerGetWithVnet() PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); // invoke the operation - string serverName = "pgtestsvc4"; - PostgreSqlFlexibleServerResource result = await collection.GetAsync(serverName); + string serverName = "pgtestsvc2"; + bool result = await collection.ExistsAsync(serverName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -704,9 +693,9 @@ public async Task Exists_ServerGetWithVnet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServerGetWithVnet() + public async Task GetIfExists_ServerGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithVnet.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGet.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -725,7 +714,7 @@ public async Task GetIfExists_ServerGetWithVnet() PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); // invoke the operation - string serverName = "pgtestsvc4"; + string serverName = "pgtestsvc1"; NullableResponse response = await collection.GetIfExistsAsync(serverName); PostgreSqlFlexibleServerResource result = response.HasValue ? response.Value : null; @@ -745,10 +734,10 @@ public async Task GetIfExists_ServerGetWithVnet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServerListByResourceGroup() + public async Task GetIfExists_ServerGetWithPrivateEndpoints() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerListByResourceGroup.json - // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithPrivateEndpoints.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -765,25 +754,31 @@ public async Task GetAll_ServerListByResourceGroup() // get the collection of this PostgreSqlFlexibleServerResource PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServerResource item in collection.GetAllAsync()) + // invoke the operation + string serverName = "pgtestsvc2"; + NullableResponse response = await collection.GetIfExistsAsync(serverName); + PostgreSqlFlexibleServerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerData resourceData = item.Data; + PostgreSqlFlexibleServerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetReplicas_ReplicasListByServer() + public async Task GetIfExists_ServerGetWithVnet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ReplicasListByServer.json - // this example is just showing the usage of "Replicas_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithVnet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -800,18 +795,23 @@ public async Task GetReplicas_ReplicasListByServer() // get the collection of this PostgreSqlFlexibleServerResource PostgreSqlFlexibleServerCollection collection = resourceGroupResource.GetPostgreSqlFlexibleServers(); - // invoke the operation and iterate over the result - string serverName = "sourcepgservername"; - await foreach (PostgreSqlFlexibleServerResource item in collection.GetReplicasAsync(serverName)) + // invoke the operation + string serverName = "pgtestsvc4"; + NullableResponse response = await collection.GetIfExistsAsync(serverName); + PostgreSqlFlexibleServerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerData resourceData = item.Data; + PostgreSqlFlexibleServerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationCollection.cs index 7a3246f1512c3..d4535b43fb2b2 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_PostgreSqlFlexibleServerConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConfigurationList() + public async Task CreateOrUpdate_UpdateAUserConfiguration() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ConfigurationListByServer.json - // this example is just showing the usage of "Configurations_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ConfigurationUpdate.json + // this example is just showing the usage of "Configurations_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_ConfigurationList() // get the collection of this PostgreSqlFlexibleServerConfigurationResource PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServerConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string configurationName = "event_scheduler"; + PostgreSqlFlexibleServerConfigurationData data = new PostgreSqlFlexibleServerConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = "on", + Source = "user-override", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + PostgreSqlFlexibleServerConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_ConfigurationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConfigurationGet() + public async Task GetAll_ConfigurationList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ConfigurationGet.json - // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ConfigurationListByServer.json + // this example is just showing the usage of "Configurations_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_ConfigurationGet() // get the collection of this PostgreSqlFlexibleServerConfigurationResource PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); - // invoke the operation - string configurationName = "array_nulls"; - bool result = await collection.ExistsAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServerConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConfigurationGet() + public async Task Exists_ConfigurationGet() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ConfigurationGet.json // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_ConfigurationGet() // invoke the operation string configurationName = "array_nulls"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - PostgreSqlFlexibleServerConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAUserConfiguration() + public async Task GetIfExists_ConfigurationGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ConfigurationUpdate.json - // this example is just showing the usage of "Configurations_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ConfigurationGet.json + // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,20 +179,22 @@ public async Task CreateOrUpdate_UpdateAUserConfiguration() PostgreSqlFlexibleServerConfigurationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerConfigurations(); // invoke the operation - string configurationName = "event_scheduler"; - PostgreSqlFlexibleServerConfigurationData data = new PostgreSqlFlexibleServerConfigurationData() - { - Value = "on", - Source = "user-override", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - PostgreSqlFlexibleServerConfigurationResource result = lro.Value; + string configurationName = "array_nulls"; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + PostgreSqlFlexibleServerConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationResource.cs index acab8d8ad9180..65718f35d3392 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerConfigurationResource.cs @@ -68,7 +68,7 @@ public async Task Update_UpdateAUserConfiguration() PostgreSqlFlexibleServerConfigurationResource postgreSqlFlexibleServerConfiguration = client.GetPostgreSqlFlexibleServerConfigurationResource(postgreSqlFlexibleServerConfigurationResourceId); // invoke the operation - PostgreSqlFlexibleServerConfigurationData data = new PostgreSqlFlexibleServerConfigurationData() + PostgreSqlFlexibleServerConfigurationData data = new PostgreSqlFlexibleServerConfigurationData { Value = "on", Source = "user-override", diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs index 608acc10f9dad..afb1f6d4016da 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_CreateADatabase() // invoke the operation string databaseName = "db1"; - PostgreSqlFlexibleServerDatabaseData data = new PostgreSqlFlexibleServerDatabaseData() + PostgreSqlFlexibleServerDatabaseData data = new PostgreSqlFlexibleServerDatabaseData { Charset = "utf8", Collation = "en_US.utf8", @@ -91,10 +91,10 @@ public async Task Get_GetADatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADatabase() + public async Task GetAll_ListDatabasesInAServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/DatabaseGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/DatabasesListByServer.json + // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_GetADatabase() // get the collection of this PostgreSqlFlexibleServerDatabaseResource PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); - // invoke the operation - string databaseName = "db1"; - bool result = await collection.ExistsAsync(databaseName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServerDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADatabase() + public async Task Exists_GetADatabase() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/DatabaseGet.json // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_GetADatabase() // invoke the operation string databaseName = "db1"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - PostgreSqlFlexibleServerDatabaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(databaseName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDatabasesInAServer() + public async Task GetIfExists_GetADatabase() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/DatabasesListByServer.json - // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/DatabaseGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListDatabasesInAServer() // get the collection of this PostgreSqlFlexibleServerDatabaseResource PostgreSqlFlexibleServerDatabaseCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerDatabases(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServerDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "db1"; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + PostgreSqlFlexibleServerDatabaseResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerDatabaseData resourceData = item.Data; + PostgreSqlFlexibleServerDatabaseData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseResource.cs index 9fb7602b37e5b..04d8aa5bbdeec 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerDatabaseResource.cs @@ -17,10 +17,10 @@ public partial class Sample_PostgreSqlFlexibleServerDatabaseResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateADatabase() + public async Task Get_GetADatabase() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/DatabaseCreate.json - // this example is just showing the usage of "Databases_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/DatabaseGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,13 +37,7 @@ public async Task Update_CreateADatabase() PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); // invoke the operation - PostgreSqlFlexibleServerDatabaseData data = new PostgreSqlFlexibleServerDatabaseData() - { - Charset = "utf8", - Collation = "en_US.utf8", - }; - ArmOperation lro = await postgreSqlFlexibleServerDatabase.UpdateAsync(WaitUntil.Completed, data); - PostgreSqlFlexibleServerDatabaseResource result = lro.Value; + PostgreSqlFlexibleServerDatabaseResource result = await postgreSqlFlexibleServerDatabase.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +75,10 @@ public async Task Delete_DeleteADatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabase() + public async Task Update_CreateADatabase() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/DatabaseGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/DatabaseCreate.json + // this example is just showing the usage of "Databases_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +95,13 @@ public async Task Get_GetADatabase() PostgreSqlFlexibleServerDatabaseResource postgreSqlFlexibleServerDatabase = client.GetPostgreSqlFlexibleServerDatabaseResource(postgreSqlFlexibleServerDatabaseResourceId); // invoke the operation - PostgreSqlFlexibleServerDatabaseResource result = await postgreSqlFlexibleServerDatabase.GetAsync(); + PostgreSqlFlexibleServerDatabaseData data = new PostgreSqlFlexibleServerDatabaseData + { + Charset = "utf8", + Collation = "en_US.utf8", + }; + ArmOperation lro = await postgreSqlFlexibleServerDatabase.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlFlexibleServerDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs index 5b1fba3ee4b99..f7017925f2cc1 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleCollection.cs @@ -88,10 +88,10 @@ public async Task Get_FirewallRuleList() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FirewallRuleList() + public async Task GetAll_FirewallRuleList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/FirewallRuleListByServer.json + // this example is just showing the usage of "FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_FirewallRuleList() // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); - // invoke the operation - string firewallRuleName = "rule1"; - bool result = await collection.ExistsAsync(firewallRuleName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServerFirewallRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerFirewallRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FirewallRuleList() + public async Task Exists_FirewallRuleList() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/FirewallRuleGet.json // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_FirewallRuleList() // invoke the operation string firewallRuleName = "rule1"; - NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); - PostgreSqlFlexibleServerFirewallRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(firewallRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FirewallRuleList() + public async Task GetIfExists_FirewallRuleList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/FirewallRuleListByServer.json - // this example is just showing the usage of "FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_FirewallRuleList() // get the collection of this PostgreSqlFlexibleServerFirewallRuleResource PostgreSqlFlexibleServerFirewallRuleCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServerFirewallRules(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServerFirewallRuleResource item in collection.GetAllAsync()) + // invoke the operation + string firewallRuleName = "rule1"; + NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); + PostgreSqlFlexibleServerFirewallRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerFirewallRuleData resourceData = item.Data; + PostgreSqlFlexibleServerFirewallRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleResource.cs index 9a8428c868c19..36fc59e1801f9 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerFirewallRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_PostgreSqlFlexibleServerFirewallRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FirewallRuleCreate() + public async Task Get_FirewallRuleList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/FirewallRuleCreate.json - // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Update_FirewallRuleCreate() PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); // invoke the operation - PostgreSqlFlexibleServerFirewallRuleData data = new PostgreSqlFlexibleServerFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); - ArmOperation lro = await postgreSqlFlexibleServerFirewallRule.UpdateAsync(WaitUntil.Completed, data); - PostgreSqlFlexibleServerFirewallRuleResource result = lro.Value; + PostgreSqlFlexibleServerFirewallRuleResource result = await postgreSqlFlexibleServerFirewallRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -78,10 +76,10 @@ public async Task Delete_FirewallRuleDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FirewallRuleList() + public async Task Update_FirewallRuleCreate() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/FirewallRuleCreate.json + // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,7 +96,9 @@ public async Task Get_FirewallRuleList() PostgreSqlFlexibleServerFirewallRuleResource postgreSqlFlexibleServerFirewallRule = client.GetPostgreSqlFlexibleServerFirewallRuleResource(postgreSqlFlexibleServerFirewallRuleResourceId); // invoke the operation - PostgreSqlFlexibleServerFirewallRuleResource result = await postgreSqlFlexibleServerFirewallRule.GetAsync(); + PostgreSqlFlexibleServerFirewallRuleData data = new PostgreSqlFlexibleServerFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await postgreSqlFlexibleServerFirewallRule.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlFlexibleServerFirewallRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs index 9b1d4090eb1fb..e61133464075a 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServerResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.PostgreSql.FlexibleServers.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples @@ -20,10 +19,70 @@ public partial class Sample_PostgreSqlFlexibleServerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetServerCapabilities_ServerCapabilitiesList() + public async Task Get_ServerGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerCapabilities.json - // this example is just showing the usage of "ServerCapabilities_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerResource created on azure + // for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc1"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerResource result = await postgreSqlFlexibleServer.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_ServerGetWithPrivateEndpoints() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithPrivateEndpoints.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerResource created on azure + // for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "pgtestsvc2"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + PostgreSqlFlexibleServerResource result = await postgreSqlFlexibleServer.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_ServerGetWithVnet() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithVnet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,11 +97,38 @@ public async Task GetServerCapabilities_ServerCapabilitiesList() ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServerCapabilityProperties item in postgreSqlFlexibleServer.GetServerCapabilitiesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + PostgreSqlFlexibleServerResource result = await postgreSqlFlexibleServer.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ServerDelete() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerDelete.json + // this example is just showing the usage of "Servers_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PostgreSqlFlexibleServerResource created on azure + // for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; + ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); + PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); + + // invoke the operation + await postgreSqlFlexibleServer.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } @@ -68,9 +154,9 @@ public async Task Update_PromoteAReplicaServerAsAStandaloneServerAsForcedIEItWil PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch { - Replica = new PostgreSqlFlexibleServersReplica() + Replica = new PostgreSqlFlexibleServersReplica { PromoteMode = ReadReplicaPromoteMode.Standalone, PromoteOption = ReplicationPromoteOption.Forced, @@ -107,9 +193,9 @@ public async Task Update_PromoteAReplicaServerAsAStandaloneServerAsPlannedIEItWi PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch { - Replica = new PostgreSqlFlexibleServersReplica() + Replica = new PostgreSqlFlexibleServersReplica { PromoteMode = ReadReplicaPromoteMode.Standalone, PromoteOption = ReplicationPromoteOption.Planned, @@ -146,17 +232,17 @@ public async Task Update_ServerUpdate() PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch { Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), AdministratorLoginPassword = "newpassword", - Storage = new PostgreSqlFlexibleServerStorage() + Storage = new PostgreSqlFlexibleServerStorage { StorageSizeInGB = 1024, AutoGrow = StorageAutoGrow.Enabled, Tier = PostgreSqlManagedDiskPerformanceTier.P30, }, - Backup = new PostgreSqlFlexibleServerBackupProperties() + Backup = new PostgreSqlFlexibleServerBackupProperties { BackupRetentionDays = 20, }, @@ -193,21 +279,21 @@ public async Task Update_ServerUpdateWithAadAuthEnabled() PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch { Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), AdministratorLoginPassword = "newpassword", - Storage = new PostgreSqlFlexibleServerStorage() + Storage = new PostgreSqlFlexibleServerStorage { StorageSizeInGB = 1024, AutoGrow = StorageAutoGrow.Disabled, Tier = PostgreSqlManagedDiskPerformanceTier.P30, }, - Backup = new PostgreSqlFlexibleServerBackupProperties() + Backup = new PostgreSqlFlexibleServerBackupProperties { BackupRetentionDays = 20, }, - AuthConfig = new PostgreSqlFlexibleServerAuthConfig() + AuthConfig = new PostgreSqlFlexibleServerAuthConfig { ActiveDirectoryAuth = PostgreSqlFlexibleServerActiveDirectoryAuthEnum.Enabled, PasswordAuth = PostgreSqlFlexibleServerPasswordAuthEnum.Enabled, @@ -246,9 +332,9 @@ public async Task Update_ServerUpdateWithCustomerMaintenanceWindow() PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch { - MaintenanceWindow = new PostgreSqlFlexibleServerMaintenanceWindow() + MaintenanceWindow = new PostgreSqlFlexibleServerMaintenanceWindow { CustomWindow = "Enabled", StartHour = 8, @@ -288,7 +374,7 @@ public async Task Update_ServerUpdateWithDataEncryptionEnabled() PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch { Sku = new PostgreSqlFlexibleServerSku("Standard_D8s_v3", PostgreSqlFlexibleServerSkuTier.GeneralPurpose), Identity = new PostgreSqlFlexibleServerUserAssignedIdentity(PostgreSqlFlexibleServerIdentityType.UserAssigned) @@ -296,15 +382,15 @@ public async Task Update_ServerUpdateWithDataEncryptionEnabled() UserAssignedIdentities = { ["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-geo-usermanagedidentity"] = new UserAssignedIdentity(), -["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity(), +["/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"] = new UserAssignedIdentity() }, }, AdministratorLoginPassword = "newpassword", - Backup = new PostgreSqlFlexibleServerBackupProperties() + Backup = new PostgreSqlFlexibleServerBackupProperties { BackupRetentionDays = 20, }, - DataEncryption = new PostgreSqlFlexibleServerDataEncryption() + DataEncryption = new PostgreSqlFlexibleServerDataEncryption { PrimaryKeyUri = new Uri("https://test-kv.vault.azure.net/keys/test-key1/77f57315bab34b0189daa113fbc78787"), PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testresourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-usermanagedidentity"), @@ -345,7 +431,7 @@ public async Task Update_ServerUpdateWithMajorVersionUpgrade() PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch { Version = PostgreSqlFlexibleServerVersion.Ver14, CreateMode = PostgreSqlFlexibleServerCreateModeForUpdate.Update, @@ -381,9 +467,9 @@ public async Task Update_SwitchOverAReplicaServerAsForcedIEItWillReplicaAsPrimar PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch { - Replica = new PostgreSqlFlexibleServersReplica() + Replica = new PostgreSqlFlexibleServersReplica { PromoteMode = ReadReplicaPromoteMode.Switchover, PromoteOption = ReplicationPromoteOption.Forced, @@ -420,9 +506,9 @@ public async Task Update_SwitchOverAReplicaServerAsPlannedIEItWillWaitForReplica PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch() + PostgreSqlFlexibleServerPatch patch = new PostgreSqlFlexibleServerPatch { - Replica = new PostgreSqlFlexibleServersReplica() + Replica = new PostgreSqlFlexibleServersReplica { PromoteMode = ReadReplicaPromoteMode.Switchover, PromoteOption = ReplicationPromoteOption.Planned, @@ -440,96 +526,10 @@ public async Task Update_SwitchOverAReplicaServerAsPlannedIEItWillWaitForReplica [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ServerDelete() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerDelete.json - // this example is just showing the usage of "Servers_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerResource created on azure - // for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - await postgreSqlFlexibleServer.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ServerGet() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerResource created on azure - // for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "pgtestsvc1"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerResource result = await postgreSqlFlexibleServer.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ServerGetWithPrivateEndpoints() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithPrivateEndpoints.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PostgreSqlFlexibleServerResource created on azure - // for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "pgtestsvc2"; - ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); - PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - - // invoke the operation - PostgreSqlFlexibleServerResource result = await postgreSqlFlexibleServer.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ServerGetWithVnet() + public async Task GetServerCapabilities_ServerCapabilitiesList() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerGetWithVnet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerCapabilities.json + // this example is just showing the usage of "ServerCapabilities_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -544,42 +544,10 @@ public async Task Get_ServerGetWithVnet() ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); - // invoke the operation - PostgreSqlFlexibleServerResource result = await postgreSqlFlexibleServer.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPostgreSqlFlexibleServers_ServerList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerList.json - // this example is just showing the usage of "Servers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServerResource item in subscriptionResource.GetPostgreSqlFlexibleServersAsync()) + await foreach (PostgreSqlFlexibleServerCapabilityProperties item in postgreSqlFlexibleServer.GetServerCapabilitiesAsync()) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {item}"); } Console.WriteLine("Succeeded"); @@ -632,7 +600,7 @@ public async Task Restart_ServerRestartWithFailover() PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerRestartParameter postgreSqlFlexibleServerRestartParameter = new PostgreSqlFlexibleServerRestartParameter() + PostgreSqlFlexibleServerRestartParameter postgreSqlFlexibleServerRestartParameter = new PostgreSqlFlexibleServerRestartParameter { RestartWithFailover = true, FailoverMode = PostgreSqlFlexibleServerFailoverMode.ForcedFailover, @@ -742,10 +710,7 @@ public async Task StartLtrBackupFlexibleServer_SampleExecuteBackup() PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // invoke the operation - PostgreSqlFlexibleServerLtrBackupContent content = new PostgreSqlFlexibleServerLtrBackupContent(new PostgreSqlFlexibleServerBackupSettings("backup1"), new PostgreSqlFlexibleServerBackupStoreDetails(new string[] - { -"sasuri" - })); + PostgreSqlFlexibleServerLtrBackupContent content = new PostgreSqlFlexibleServerLtrBackupContent(new PostgreSqlFlexibleServerBackupSettings("backup1"), new PostgreSqlFlexibleServerBackupStoreDetails(new string[] { "sasuri" })); ArmOperation lro = await postgreSqlFlexibleServer.StartLtrBackupFlexibleServerAsync(WaitUntil.Completed, content); PostgreSqlFlexibleServerLtrBackupResult result = lro.Value; diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateEndpointConnectionCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateEndpointConnectionCollection.cs index aeeb946a802c5..f31d616c0ab84 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateEndpointConnectionCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PostgreSqlFlexibleServersPrivateEndpointConnectionCo { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateEndpointConnection() + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnection_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name.1fa229cd-bf3f-47f0-8c49-afb36723997e"; - PostgreSqlFlexibleServersPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + PostgreSqlFlexibleServersPrivateEndpointConnectionData data = new PostgreSqlFlexibleServersPrivateEndpointConnectionData + { + ConnectionState = new PostgreSqlFlexibleServersPrivateLinkServiceConnectionState + { + Status = PostgreSqlFlexibleServersPrivateEndpointServiceConnectionStatus.Approved, + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + PostgreSqlFlexibleServersPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task Get_GetsPrivateEndpointConnection() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +84,21 @@ public async Task Exists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name.1fa229cd-bf3f-47f0-8c49-afb36723997e"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + PostgreSqlFlexibleServersPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServersPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionList.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +116,25 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // get the collection of this PostgreSqlFlexibleServersPrivateEndpointConnectionResource PostgreSqlFlexibleServersPrivateEndpointConnectionCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServersPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name.1fa229cd-bf3f-47f0-8c49-afb36723997e"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - PostgreSqlFlexibleServersPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServersPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServersPrivateEndpointConnectionData resourceData = result.Data; + PostgreSqlFlexibleServersPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() + public async Task Exists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionList.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,25 +152,19 @@ public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() // get the collection of this PostgreSqlFlexibleServersPrivateEndpointConnectionResource PostgreSqlFlexibleServersPrivateEndpointConnectionCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServersPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServersPrivateEndpointConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServersPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name.1fa229cd-bf3f-47f0-8c49-afb36723997e"; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnection_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name.1fa229cd-bf3f-47f0-8c49-afb36723997e"; - PostgreSqlFlexibleServersPrivateEndpointConnectionData data = new PostgreSqlFlexibleServersPrivateEndpointConnectionData() - { - ConnectionState = new PostgreSqlFlexibleServersPrivateLinkServiceConnectionState() - { - Status = PostgreSqlFlexibleServersPrivateEndpointServiceConnectionStatus.Approved, - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - PostgreSqlFlexibleServersPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + PostgreSqlFlexibleServersPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServersPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServersPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateEndpointConnectionResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateEndpointConnectionResource.cs index 248d80f9e8511..b1463efe4bd18 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateEndpointConnectionResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnection_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionDelete.json + // this example is just showing the usage of "PrivateEndpointConnection_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName PostgreSqlFlexibleServersPrivateEndpointConnectionResource postgreSqlFlexibleServersPrivateEndpointConnection = client.GetPostgreSqlFlexibleServersPrivateEndpointConnectionResource(postgreSqlFlexibleServersPrivateEndpointConnectionResourceId); // invoke the operation - PostgreSqlFlexibleServersPrivateEndpointConnectionData data = new PostgreSqlFlexibleServersPrivateEndpointConnectionData() - { - ConnectionState = new PostgreSqlFlexibleServersPrivateLinkServiceConnectionState() - { - Status = PostgreSqlFlexibleServersPrivateEndpointServiceConnectionStatus.Approved, - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await postgreSqlFlexibleServersPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - PostgreSqlFlexibleServersPrivateEndpointConnectionResource result = lro.Value; + await postgreSqlFlexibleServersPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServersPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionDelete.json - // this example is just showing the usage of "PrivateEndpointConnection_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnection_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() PostgreSqlFlexibleServersPrivateEndpointConnectionResource postgreSqlFlexibleServersPrivateEndpointConnection = client.GetPostgreSqlFlexibleServersPrivateEndpointConnectionResource(postgreSqlFlexibleServersPrivateEndpointConnectionResourceId); // invoke the operation - await postgreSqlFlexibleServersPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + PostgreSqlFlexibleServersPrivateEndpointConnectionData data = new PostgreSqlFlexibleServersPrivateEndpointConnectionData + { + ConnectionState = new PostgreSqlFlexibleServersPrivateLinkServiceConnectionState + { + Status = PostgreSqlFlexibleServersPrivateEndpointServiceConnectionStatus.Approved, + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await postgreSqlFlexibleServersPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlFlexibleServersPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServersPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateLinkResourceCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateLinkResourceCollection.cs index 44e06e4034ec5..c86b5ee4f9ac4 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateLinkResourceCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlFlexibleServersPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_PostgreSqlFlexibleServersPrivateLinkResourceCollecti { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() + public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateLinkResourcesList.json - // this example is just showing the usage of "PrivateLinkResources_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateLinkResourcesGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() // get the collection of this PostgreSqlFlexibleServersPrivateLinkResource PostgreSqlFlexibleServersPrivateLinkResourceCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServersPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlFlexibleServersPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServersPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "plr"; + PostgreSqlFlexibleServersPrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServersPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() + public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateLinkResourcesGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/PrivateLinkResourcesList.json + // this example is just showing the usage of "PrivateLinkResources_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() // get the collection of this PostgreSqlFlexibleServersPrivateLinkResource PostgreSqlFlexibleServersPrivateLinkResourceCollection collection = postgreSqlFlexibleServer.GetPostgreSqlFlexibleServersPrivateLinkResources(); - // invoke the operation - string groupName = "plr"; - PostgreSqlFlexibleServersPrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServersPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServersPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlFlexibleServersPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlLtrServerBackupOperationCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlLtrServerBackupOperationCollection.cs index 866b2a0da4e5b..8eaf6a3a89911 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlLtrServerBackupOperationCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlLtrServerBackupOperationCollection.cs @@ -51,10 +51,10 @@ public async Task Get_Sample() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_Sample() + public async Task GetAll_SampleListOfLongTernRetentionOperationsByFlexibleServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/LongTermRetentionOperationGet.json - // this example is just showing the usage of "ltrBackupOperations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/LongTermRetentionOperationListByServer.json + // this example is just showing the usage of "ltrBackupOperations_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_Sample() // get the collection of this PostgreSqlLtrServerBackupOperationResource PostgreSqlLtrServerBackupOperationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlLtrServerBackupOperations(); - // invoke the operation - string backupName = "backup1"; - bool result = await collection.ExistsAsync(backupName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlLtrServerBackupOperationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlLtrServerBackupOperationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_Sample() + public async Task Exists_Sample() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/LongTermRetentionOperationGet.json // this example is just showing the usage of "ltrBackupOperations_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_Sample() // invoke the operation string backupName = "backup1"; - NullableResponse response = await collection.GetIfExistsAsync(backupName); - PostgreSqlLtrServerBackupOperationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(backupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlLtrServerBackupOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SampleListOfLongTernRetentionOperationsByFlexibleServer() + public async Task GetIfExists_Sample() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/LongTermRetentionOperationListByServer.json - // this example is just showing the usage of "ltrBackupOperations_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/LongTermRetentionOperationGet.json + // this example is just showing the usage of "ltrBackupOperations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_SampleListOfLongTernRetentionOperationsByFlexibleServer // get the collection of this PostgreSqlLtrServerBackupOperationResource PostgreSqlLtrServerBackupOperationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlLtrServerBackupOperations(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlLtrServerBackupOperationResource item in collection.GetAllAsync()) + // invoke the operation + string backupName = "backup1"; + NullableResponse response = await collection.GetIfExistsAsync(backupName); + PostgreSqlLtrServerBackupOperationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlLtrServerBackupOperationData resourceData = item.Data; + PostgreSqlLtrServerBackupOperationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationCollection.cs index aeabc1b1e0db3..f778886fd46de 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationCollection.cs @@ -49,10 +49,7 @@ public async Task CreateOrUpdate_CreateMigrationWithOtherSourceTypesForValidateA SslMode = PostgreSqlFlexibleServersSslMode.Prefer, SourceDbServerResourceId = new ResourceIdentifier("testsource:5432@pguser"), SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")), - DbsToMigrate = -{ -"db1","db2","db3","db4" -}, + DbsToMigrate = { "db1", "db2", "db3", "db4" }, OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); @@ -96,10 +93,7 @@ public async Task CreateOrUpdate_CreatePreMigrationValidation() MigrationOption = MigrationOption.Validate, SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"), SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")), - DbsToMigrate = -{ -"db1","db2","db3","db4" -}, + DbsToMigrate = { "db1", "db2", "db3", "db4" }, OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); @@ -146,10 +140,7 @@ public async Task CreateOrUpdate_MigrationsCreateByPassingUserNames() SourceServerUsername = "newadmin@testsource", TargetServerUsername = "targetadmin", }, - DbsToMigrate = -{ -"db1","db2","db3","db4" -}, + DbsToMigrate = { "db1", "db2", "db3", "db4" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); PostgreSqlMigrationResource result = lro.Value; @@ -192,10 +183,7 @@ public async Task CreateOrUpdate_MigrationsCreateWithPrivateEndpoint() MigrationMode = PostgreSqlMigrationMode.Offline, SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"), SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")), - DbsToMigrate = -{ -"db1","db2","db3","db4" -}, + DbsToMigrate = { "db1", "db2", "db3", "db4" }, OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); @@ -238,10 +226,7 @@ public async Task CreateOrUpdate_MigrationsCreateWithRoles() MigrationMode = PostgreSqlMigrationMode.Offline, SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"), SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")), - DbsToMigrate = -{ -"db1","db2","db3","db4" -}, + DbsToMigrate = { "db1", "db2", "db3", "db4" }, OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True, MigrateRoles = MigrateRolesEnum.True, }; @@ -286,10 +271,7 @@ public async Task CreateOrUpdate_MigrationsCreate() MigrationMode = PostgreSqlMigrationMode.Offline, SourceDbServerResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.DBForPostgreSql/servers/testsource"), SecretParameters = new PostgreSqlMigrationSecretParameters(new PostgreSqlMigrationAdminCredentials("xxxxxxxx", "xxxxxxxx")), - DbsToMigrate = -{ -"db1","db2","db3","db4" -}, + DbsToMigrate = { "db1", "db2", "db3", "db4" }, OverwriteDbsInTarget = PostgreSqlMigrationOverwriteDbsInTarget.True, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationName, data); @@ -338,9 +320,9 @@ public async Task Get_MigrationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MigrationsGet() + public async Task Get_MigrationsGetMigrationWithSuccessfulValidationAndMigration() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Get.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationAndMigration.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -360,17 +342,21 @@ public async Task Exists_MigrationsGet() PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigration"; - bool result = await collection.ExistsAsync(migrationName); + string migrationName = "testmigrationwithsuccessfulvalidationandmigration"; + PostgreSqlMigrationResource result = await collection.GetAsync(migrationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MigrationsGet() + public async Task Get_MigrationsGetMigrationWithSuccessfulValidationButMigrationFailure() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Get.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationButMigrationFailure.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -390,29 +376,21 @@ public async Task GetIfExists_MigrationsGet() PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigration"; - NullableResponse response = await collection.GetIfExistsAsync(migrationName); - PostgreSqlMigrationResource result = response.HasValue ? response.Value : null; + string migrationName = "testmigrationwithsuccessfulvalidationbutmigrationfailure"; + PostgreSqlMigrationResource result = await collection.GetAsync(migrationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlMigrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MigrationsGetMigrationWithSuccessfulValidationAndMigration() + public async Task Get_MigrationsGetMigrationWithSuccessfulValidationOnly() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationAndMigration.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationOnly.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -432,7 +410,7 @@ public async Task Get_MigrationsGetMigrationWithSuccessfulValidationAndMigration PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigrationwithsuccessfulvalidationandmigration"; + string migrationName = "testmigrationwithsuccessfulvalidationonly"; PostgreSqlMigrationResource result = await collection.GetAsync(migrationName); // the variable result is a resource, you could call other operations on this instance as well @@ -444,9 +422,9 @@ public async Task Get_MigrationsGetMigrationWithSuccessfulValidationAndMigration [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationAndMigration() + public async Task Get_MigrationsGetMigrationWithValidationFailures() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationAndMigration.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithValidationFailures.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -466,18 +444,22 @@ public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationAndMigrat PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigrationwithsuccessfulvalidationandmigration"; - bool result = await collection.ExistsAsync(migrationName); + string migrationName = "testmigrationwithvalidationfailure"; + PostgreSqlMigrationResource result = await collection.GetAsync(migrationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MigrationsGetMigrationWithSuccessfulValidationAndMigration() + public async Task GetAll_MigrationsListByTargetServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationAndMigration.json - // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_ListByTargetServer.json + // this example is just showing the usage of "Migrations_ListByTargetServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -495,30 +477,25 @@ public async Task GetIfExists_MigrationsGetMigrationWithSuccessfulValidationAndM // get the collection of this PostgreSqlMigrationResource PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); - // invoke the operation - string migrationName = "testmigrationwithsuccessfulvalidationandmigration"; - NullableResponse response = await collection.GetIfExistsAsync(migrationName); - PostgreSqlMigrationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + PostgreSqlMigrationListFilter? migrationListFilter = PostgreSqlMigrationListFilter.All; + await foreach (PostgreSqlMigrationResource item in collection.GetAllAsync(migrationListFilter: migrationListFilter)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlMigrationData resourceData = result.Data; + PostgreSqlMigrationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MigrationsGetMigrationWithSuccessfulValidationButMigrationFailure() + public async Task Exists_MigrationsGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationButMigrationFailure.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Get.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -538,21 +515,17 @@ public async Task Get_MigrationsGetMigrationWithSuccessfulValidationButMigration PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigrationwithsuccessfulvalidationbutmigrationfailure"; - PostgreSqlMigrationResource result = await collection.GetAsync(migrationName); + string migrationName = "testmigration"; + bool result = await collection.ExistsAsync(migrationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlMigrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationButMigrationFailure() + public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationAndMigration() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationButMigrationFailure.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationAndMigration.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -572,7 +545,7 @@ public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationButMigrat PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigrationwithsuccessfulvalidationbutmigrationfailure"; + string migrationName = "testmigrationwithsuccessfulvalidationandmigration"; bool result = await collection.ExistsAsync(migrationName); Console.WriteLine($"Succeeded: {result}"); @@ -580,7 +553,7 @@ public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationButMigrat [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MigrationsGetMigrationWithSuccessfulValidationButMigrationFailure() + public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationButMigrationFailure() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationButMigrationFailure.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. @@ -603,26 +576,14 @@ public async Task GetIfExists_MigrationsGetMigrationWithSuccessfulValidationButM // invoke the operation string migrationName = "testmigrationwithsuccessfulvalidationbutmigrationfailure"; - NullableResponse response = await collection.GetIfExistsAsync(migrationName); - PostgreSqlMigrationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(migrationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlMigrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MigrationsGetMigrationWithSuccessfulValidationOnly() + public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationOnly() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationOnly.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. @@ -645,20 +606,16 @@ public async Task Get_MigrationsGetMigrationWithSuccessfulValidationOnly() // invoke the operation string migrationName = "testmigrationwithsuccessfulvalidationonly"; - PostgreSqlMigrationResource result = await collection.GetAsync(migrationName); + bool result = await collection.ExistsAsync(migrationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlMigrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationOnly() + public async Task Exists_MigrationsGetMigrationWithValidationFailures() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationOnly.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithValidationFailures.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -678,7 +635,7 @@ public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationOnly() PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigrationwithsuccessfulvalidationonly"; + string migrationName = "testmigrationwithvalidationfailure"; bool result = await collection.ExistsAsync(migrationName); Console.WriteLine($"Succeeded: {result}"); @@ -686,9 +643,9 @@ public async Task Exists_MigrationsGetMigrationWithSuccessfulValidationOnly() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MigrationsGetMigrationWithSuccessfulValidationOnly() + public async Task GetIfExists_MigrationsGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationOnly.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Get.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -708,7 +665,7 @@ public async Task GetIfExists_MigrationsGetMigrationWithSuccessfulValidationOnly PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigrationwithsuccessfulvalidationonly"; + string migrationName = "testmigration"; NullableResponse response = await collection.GetIfExistsAsync(migrationName); PostgreSqlMigrationResource result = response.HasValue ? response.Value : null; @@ -728,9 +685,9 @@ public async Task GetIfExists_MigrationsGetMigrationWithSuccessfulValidationOnly [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MigrationsGetMigrationWithValidationFailures() + public async Task GetIfExists_MigrationsGetMigrationWithSuccessfulValidationAndMigration() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithValidationFailures.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationAndMigration.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -750,21 +707,29 @@ public async Task Get_MigrationsGetMigrationWithValidationFailures() PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigrationwithvalidationfailure"; - PostgreSqlMigrationResource result = await collection.GetAsync(migrationName); + string migrationName = "testmigrationwithsuccessfulvalidationandmigration"; + NullableResponse response = await collection.GetIfExistsAsync(migrationName); + PostgreSqlMigrationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlMigrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MigrationsGetMigrationWithValidationFailures() + public async Task GetIfExists_MigrationsGetMigrationWithSuccessfulValidationButMigrationFailure() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithValidationFailures.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationButMigrationFailure.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -784,17 +749,29 @@ public async Task Exists_MigrationsGetMigrationWithValidationFailures() PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigrationwithvalidationfailure"; - bool result = await collection.ExistsAsync(migrationName); + string migrationName = "testmigrationwithsuccessfulvalidationbutmigrationfailure"; + NullableResponse response = await collection.GetIfExistsAsync(migrationName); + PostgreSqlMigrationResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MigrationsGetMigrationWithValidationFailures() + public async Task GetIfExists_MigrationsGetMigrationWithSuccessfulValidationOnly() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithValidationFailures.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithSuccessfulValidationOnly.json // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -814,7 +791,7 @@ public async Task GetIfExists_MigrationsGetMigrationWithValidationFailures() PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); // invoke the operation - string migrationName = "testmigrationwithvalidationfailure"; + string migrationName = "testmigrationwithsuccessfulvalidationonly"; NullableResponse response = await collection.GetIfExistsAsync(migrationName); PostgreSqlMigrationResource result = response.HasValue ? response.Value : null; @@ -834,10 +811,10 @@ public async Task GetIfExists_MigrationsGetMigrationWithValidationFailures() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MigrationsListByTargetServer() + public async Task GetIfExists_MigrationsGetMigrationWithValidationFailures() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_ListByTargetServer.json - // this example is just showing the usage of "Migrations_ListByTargetServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_GetMigrationWithValidationFailures.json + // this example is just showing the usage of "Migrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -855,18 +832,23 @@ public async Task GetAll_MigrationsListByTargetServer() // get the collection of this PostgreSqlMigrationResource PostgreSqlMigrationCollection collection = postgreSqlFlexibleServer.GetPostgreSqlMigrations(); - // invoke the operation and iterate over the result - PostgreSqlMigrationListFilter? migrationListFilter = PostgreSqlMigrationListFilter.All; - await foreach (PostgreSqlMigrationResource item in collection.GetAllAsync(migrationListFilter: migrationListFilter)) + // invoke the operation + string migrationName = "testmigrationwithvalidationfailure"; + NullableResponse response = await collection.GetIfExistsAsync(migrationName); + PostgreSqlMigrationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlMigrationData resourceData = item.Data; + PostgreSqlMigrationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationResource.cs index 3cb6e6c253459..219424d1ee6b7 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlMigrationResource.cs @@ -173,10 +173,10 @@ public async Task Get_MigrationsGetMigrationWithValidationFailures() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CancelMigration() + public async Task Delete_MigrationsDelete() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Cancel.json - // this example is just showing the usage of "Migrations_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Delete.json + // this example is just showing the usage of "Migrations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,24 +193,16 @@ public async Task Update_CancelMigration() PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); // invoke the operation - PostgreSqlMigrationPatch patch = new PostgreSqlMigrationPatch() - { - Cancel = PostgreSqlMigrationCancel.True, - }; - PostgreSqlMigrationResource result = await postgreSqlMigration.UpdateAsync(patch); + await postgreSqlMigration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlMigrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MigrationsUpdate() + public async Task Update_CancelMigration() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Update.json + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Cancel.json // this example is just showing the usage of "Migrations_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -228,9 +220,9 @@ public async Task Update_MigrationsUpdate() PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); // invoke the operation - PostgreSqlMigrationPatch patch = new PostgreSqlMigrationPatch() + PostgreSqlMigrationPatch patch = new PostgreSqlMigrationPatch { - SetupLogicalReplicationOnSourceDbIfNeeded = PostgreSqlMigrationLogicalReplicationOnSourceDb.True, + Cancel = PostgreSqlMigrationCancel.True, }; PostgreSqlMigrationResource result = await postgreSqlMigration.UpdateAsync(patch); @@ -243,10 +235,10 @@ public async Task Update_MigrationsUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_MigrationsDelete() + public async Task Update_MigrationsUpdate() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Delete.json - // this example is just showing the usage of "Migrations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/Migrations_Update.json + // this example is just showing the usage of "Migrations_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -263,9 +255,17 @@ public async Task Delete_MigrationsDelete() PostgreSqlMigrationResource postgreSqlMigration = client.GetPostgreSqlMigrationResource(postgreSqlMigrationResourceId); // invoke the operation - await postgreSqlMigration.DeleteAsync(WaitUntil.Completed); + PostgreSqlMigrationPatch patch = new PostgreSqlMigrationPatch + { + SetupLogicalReplicationOnSourceDbIfNeeded = PostgreSqlMigrationLogicalReplicationOnSourceDb.True, + }; + PostgreSqlMigrationResource result = await postgreSqlMigration.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionCollection.cs index 5f76cd45304cf..7ea990bed9de7 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PostgreSqlPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateEndpointConnection() + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - PostgreSqlPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionData data = new PostgreSqlPrivateEndpointConnectionData + { + ConnectionState = new PostgreSqlPrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + PostgreSqlPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task Get_GetsPrivateEndpointConnection() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionList.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // get the collection of this PostgreSqlPrivateEndpointConnectionResource PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - PostgreSqlPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PostgreSqlPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlPrivateEndpointConnectionData resourceData = result.Data; + PostgreSqlPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Exists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - PostgreSqlPrivateEndpointConnectionData data = new PostgreSqlPrivateEndpointConnectionData() - { - ConnectionState = new PostgreSqlPrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - PostgreSqlPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionList.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() // get the collection of this PostgreSqlPrivateEndpointConnectionResource PostgreSqlPrivateEndpointConnectionCollection collection = postgreSqlServer.GetPostgreSqlPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + PostgreSqlPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlPrivateEndpointConnectionData resourceData = item.Data; + PostgreSqlPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionResource.cs index aa386f3e033f3..3725acea5a813 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateEndpointConnectionResource.cs @@ -96,13 +96,13 @@ public async Task Update_UpdatePrivateEndpointConnectionTags() PostgreSqlPrivateEndpointConnectionResource postgreSqlPrivateEndpointConnection = client.GetPostgreSqlPrivateEndpointConnectionResource(postgreSqlPrivateEndpointConnectionResourceId); // invoke the operation - PostgreSqlPrivateEndpointConnectionPatch patch = new PostgreSqlPrivateEndpointConnectionPatch() + PostgreSqlPrivateEndpointConnectionPatch patch = new PostgreSqlPrivateEndpointConnectionPatch { Tags = { ["key1"] = "val1", ["key2"] = "val2", -["key3"] = "val3", +["key3"] = "val3" }, }; ArmOperation lro = await postgreSqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateLinkResourceCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateLinkResourceCollection.cs index 587d2d1ef051f..d0b06e02372d9 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateLinkResourceCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_PostgreSqlPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() + public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateLinkResourcesList.json - // this example is just showing the usage of "PrivateLinkResources_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateLinkResourcesGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() // get the collection of this PostgreSqlPrivateLinkResource PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "plr"; + PostgreSqlPrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() + public async Task GetAll_GetsPrivateLinkResourcesForPostgreSQL() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateLinkResourcesGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2018-06-01/examples/PrivateLinkResourcesList.json + // this example is just showing the usage of "PrivateLinkResources_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsAPrivateLinkResourceForPostgreSQL() // get the collection of this PostgreSqlPrivateLinkResource PostgreSqlPrivateLinkResourceCollection collection = postgreSqlServer.GetPostgreSqlPrivateLinkResources(); - // invoke the operation - string groupName = "plr"; - PostgreSqlPrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerAdministratorResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerAdministratorResource.cs index 6098595cb5505..2de3cd92de864 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerAdministratorResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerAdministratorResource.cs @@ -48,10 +48,10 @@ public async Task Get_ServerAdministratorGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServerAdministratorCreate() + public async Task Delete_ServerAdministratorsDelete() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerAdminCreateUpdate.json - // this example is just showing the usage of "ServerAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerAdminDelete.json + // this example is just showing the usage of "ServerAdministrators_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,29 +67,17 @@ public async Task CreateOrUpdate_ServerAdministratorCreate() PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); // invoke the operation - PostgreSqlServerAdministratorData data = new PostgreSqlServerAdministratorData() - { - AdministratorType = PostgreSqlAdministratorType.ActiveDirectory, - LoginAccountName = "bob@contoso.com", - SecureId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - }; - ArmOperation lro = await postgreSqlServerAdministrator.CreateOrUpdateAsync(WaitUntil.Completed, data); - PostgreSqlServerAdministratorResource result = lro.Value; + await postgreSqlServerAdministrator.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlServerAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ServerAdministratorsDelete() + public async Task CreateOrUpdate_ServerAdministratorCreate() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerAdminDelete.json - // this example is just showing the usage of "ServerAdministrators_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerAdminCreateUpdate.json + // this example is just showing the usage of "ServerAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +93,21 @@ public async Task Delete_ServerAdministratorsDelete() PostgreSqlServerAdministratorResource postgreSqlServerAdministrator = client.GetPostgreSqlServerAdministratorResource(postgreSqlServerAdministratorResourceId); // invoke the operation - await postgreSqlServerAdministrator.DeleteAsync(WaitUntil.Completed); + PostgreSqlServerAdministratorData data = new PostgreSqlServerAdministratorData + { + AdministratorType = PostgreSqlAdministratorType.ActiveDirectory, + LoginAccountName = "bob@contoso.com", + SecureId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + }; + ArmOperation lro = await postgreSqlServerAdministrator.CreateOrUpdateAsync(WaitUntil.Completed, data); + PostgreSqlServerAdministratorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlServerAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerCollection.cs index a1e72fd133cce..27b5d3ff3fad0 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerCollection.cs @@ -51,7 +51,7 @@ public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() }, Tags = { -["ElasticServer"] = "1", +["ElasticServer"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); @@ -92,7 +92,7 @@ public async Task CreateOrUpdate_CreateANewServer() { SslEnforcement = PostgreSqlSslEnforcementEnum.Enabled, MinimalTlsVersion = PostgreSqlMinimalTlsVersionEnum.Tls1_2, - StorageProfile = new PostgreSqlStorageProfile() + StorageProfile = new PostgreSqlStorageProfile { BackupRetentionDays = 7, GeoRedundantBackup = PostgreSqlGeoRedundantBackup.Disabled, @@ -108,7 +108,7 @@ public async Task CreateOrUpdate_CreateANewServer() }, Tags = { -["ElasticServer"] = "1", +["ElasticServer"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); @@ -198,7 +198,7 @@ public async Task CreateOrUpdate_CreateAServerAsAGeoRestore() }, Tags = { -["ElasticServer"] = "1", +["ElasticServer"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); @@ -246,10 +246,10 @@ public async Task Get_ServerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServerGet() + public async Task GetAll_ServerListByResourceGroup() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerListByResourceGroup.json + // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -259,26 +259,32 @@ public async Task Exists_ServerGet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; + string resourceGroupName = "TestGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this PostgreSqlServerResource PostgreSqlServerCollection collection = resourceGroupResource.GetPostgreSqlServers(); - // invoke the operation - string serverName = "pgtestsvc1"; - bool result = await collection.ExistsAsync(serverName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlServerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServerGet() + public async Task GetReplicas_ReplicasListByServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ReplicasListByServer.json + // this example is just showing the usage of "Replicas_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -288,38 +294,33 @@ public async Task GetIfExists_ServerGet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; + string resourceGroupName = "TestGroup_WestCentralUS"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this PostgreSqlServerResource PostgreSqlServerCollection collection = resourceGroupResource.GetPostgreSqlServers(); - // invoke the operation - string serverName = "pgtestsvc1"; - NullableResponse response = await collection.GetIfExistsAsync(serverName); - PostgreSqlServerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string serverName = "testserver-master"; + await foreach (PostgreSqlServerResource item in collection.GetReplicasAsync(serverName)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlServerData resourceData = result.Data; + PostgreSqlServerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServerListByResourceGroup() + public async Task Exists_ServerGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerListByResourceGroup.json - // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -329,32 +330,26 @@ public async Task GetAll_ServerListByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; + string resourceGroupName = "testrg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this PostgreSqlServerResource PostgreSqlServerCollection collection = resourceGroupResource.GetPostgreSqlServers(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlServerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string serverName = "pgtestsvc1"; + bool result = await collection.ExistsAsync(serverName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetReplicas_ReplicasListByServer() + public async Task GetIfExists_ServerGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ReplicasListByServer.json - // this example is just showing the usage of "Replicas_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -364,25 +359,30 @@ public async Task GetReplicas_ReplicasListByServer() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup_WestCentralUS"; + string resourceGroupName = "testrg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this PostgreSqlServerResource PostgreSqlServerCollection collection = resourceGroupResource.GetPostgreSqlServers(); - // invoke the operation and iterate over the result - string serverName = "testserver-master"; - await foreach (PostgreSqlServerResource item in collection.GetReplicasAsync(serverName)) + // invoke the operation + string serverName = "pgtestsvc1"; + NullableResponse response = await collection.GetIfExistsAsync(serverName); + PostgreSqlServerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlServerData resourceData = item.Data; + PostgreSqlServerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyCollection.cs index 79979ca10475d..665a05d8d28ec 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PostgreSqlServerKeyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheKeysForAPostgreSQLServer() + public async Task CreateOrUpdate_CreatesOrUpdatesAPostgreSQLServerKey() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyList.json - // this example is just showing the usage of "ServerKeys_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyCreateOrUpdate.json + // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ListTheKeysForAPostgreSQLServer() // get the collection of this PostgreSqlServerKeyResource PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlServerKeyResource item in collection.GetAllAsync()) + // invoke the operation + string keyName = "someVault_someKey_01234567890123456789012345678901"; + PostgreSqlServerKeyData data = new PostgreSqlServerKeyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlServerKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServerKeyType = PostgreSqlServerKeyType.AzureKeyVault, + Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, data); + PostgreSqlServerKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlServerKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_GetThePostgreSQLServerKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetThePostgreSQLServerKey() + public async Task GetAll_ListTheKeysForAPostgreSQLServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyGet.json - // this example is just showing the usage of "ServerKeys_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyList.json + // this example is just showing the usage of "ServerKeys_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +113,22 @@ public async Task Exists_GetThePostgreSQLServerKey() // get the collection of this PostgreSqlServerKeyResource PostgreSqlServerKeyCollection collection = postgreSqlServer.GetPostgreSqlServerKeys(); - // invoke the operation - string keyName = "someVault_someKey_01234567890123456789012345678901"; - bool result = await collection.ExistsAsync(keyName); + // invoke the operation and iterate over the result + await foreach (PostgreSqlServerKeyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlServerKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetThePostgreSQLServerKey() + public async Task Exists_GetThePostgreSQLServerKey() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyGet.json // this example is just showing the usage of "ServerKeys_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_GetThePostgreSQLServerKey() // invoke the operation string keyName = "someVault_someKey_01234567890123456789012345678901"; - NullableResponse response = await collection.GetIfExistsAsync(keyName); - PostgreSqlServerKeyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(keyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlServerKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesAPostgreSQLServerKey() + public async Task GetIfExists_GetThePostgreSQLServerKey() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyCreateOrUpdate.json - // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyGet.json + // this example is just showing the usage of "ServerKeys_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,19 +181,21 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAPostgreSQLServerKey() // invoke the operation string keyName = "someVault_someKey_01234567890123456789012345678901"; - PostgreSqlServerKeyData data = new PostgreSqlServerKeyData() - { - ServerKeyType = PostgreSqlServerKeyType.AzureKeyVault, - Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, data); - PostgreSqlServerKeyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(keyName); + PostgreSqlServerKeyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlServerKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlServerKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyResource.cs index 38d325bb3de99..ae074b772be9e 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerKeyResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetThePostgreSQLServerKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesAPostgreSQLServerKey() + public async Task Delete_DeleteThePostgreSQLServerKey() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyCreateOrUpdate.json - // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyDelete.json + // this example is just showing the usage of "ServerKeys_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,27 +69,17 @@ public async Task Update_CreatesOrUpdatesAPostgreSQLServerKey() PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); // invoke the operation - PostgreSqlServerKeyData data = new PostgreSqlServerKeyData() - { - ServerKeyType = PostgreSqlServerKeyType.AzureKeyVault, - Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), - }; - ArmOperation lro = await postgreSqlServerKey.UpdateAsync(WaitUntil.Completed, data); - PostgreSqlServerKeyResource result = lro.Value; + await postgreSqlServerKey.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlServerKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteThePostgreSQLServerKey() + public async Task Update_CreatesOrUpdatesAPostgreSQLServerKey() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyDelete.json - // this example is just showing the usage of "ServerKeys_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2020-01-01/examples/ServerKeyCreateOrUpdate.json + // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +96,19 @@ public async Task Delete_DeleteThePostgreSQLServerKey() PostgreSqlServerKeyResource postgreSqlServerKey = client.GetPostgreSqlServerKeyResource(postgreSqlServerKeyResourceId); // invoke the operation - await postgreSqlServerKey.DeleteAsync(WaitUntil.Completed); + PostgreSqlServerKeyData data = new PostgreSqlServerKeyData + { + ServerKeyType = PostgreSqlServerKeyType.AzureKeyVault, + Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + }; + ArmOperation lro = await postgreSqlServerKey.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlServerKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlServerKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerResource.cs index 730ee24eb5b31..d45eb0c313252 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.PostgreSql.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.PostgreSql.Samples @@ -19,10 +18,10 @@ public partial class Sample_PostgreSqlServerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ServerUpdate() + public async Task Get_ServerGet() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerUpdate.json - // this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,19 +32,12 @@ public async Task Update_ServerUpdate() // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "testrg"; - string serverName = "pgtestsvc4"; + string serverName = "pgtestsvc1"; ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); // invoke the operation - PostgreSqlServerPatch patch = new PostgreSqlServerPatch() - { - AdministratorLoginPassword = "", - SslEnforcement = PostgreSqlSslEnforcementEnum.Enabled, - MinimalTlsVersion = PostgreSqlMinimalTlsVersionEnum.Tls1_2, - }; - ArmOperation lro = await postgreSqlServer.UpdateAsync(WaitUntil.Completed, patch); - PostgreSqlServerResource result = lro.Value; + PostgreSqlServerResource result = await postgreSqlServer.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -82,10 +74,10 @@ public async Task Delete_ServerDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ServerGet() + public async Task Update_ServerUpdate() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerUpdate.json + // this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,12 +88,19 @@ public async Task Get_ServerGet() // for more information of creating PostgreSqlServerResource, please refer to the document of PostgreSqlServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "testrg"; - string serverName = "pgtestsvc1"; + string serverName = "pgtestsvc4"; ResourceIdentifier postgreSqlServerResourceId = PostgreSqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); PostgreSqlServerResource postgreSqlServer = client.GetPostgreSqlServerResource(postgreSqlServerResourceId); // invoke the operation - PostgreSqlServerResource result = await postgreSqlServer.GetAsync(); + PostgreSqlServerPatch patch = new PostgreSqlServerPatch + { + AdministratorLoginPassword = "", + SslEnforcement = PostgreSqlSslEnforcementEnum.Enabled, + MinimalTlsVersion = PostgreSqlMinimalTlsVersionEnum.Tls1_2, + }; + ArmOperation lro = await postgreSqlServer.UpdateAsync(WaitUntil.Completed, patch); + PostgreSqlServerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -110,37 +109,6 @@ public async Task Get_ServerGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPostgreSqlServers_ServerList() - { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerList.json - // this example is just showing the usage of "Servers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PostgreSqlServerResource item in subscriptionResource.GetPostgreSqlServersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Restart_ServerRestart() diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyCollection.cs index 25878db459962..80b5ce34fd116 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PostgreSqlServerSecurityAlertPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsGet.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsCreateMax.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_GetAServerSThreatDetectionPolicy() // invoke the operation PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - PostgreSqlServerSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData + { + State = PostgreSqlServerSecurityAlertPolicyState.Enabled, + DisabledAlerts = { "Access_Anomaly", "Usage_Anomaly" }, + EmailAddresses = { "testSecurityAlert@microsoft.com" }, + SendToEmailAccountAdmins = true, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + RetentionDays = 5, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + PostgreSqlServerSecurityAlertPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +63,10 @@ public async Task Get_GetAServerSThreatDetectionPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsGet.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsCreateMin.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +86,24 @@ public async Task Exists_GetAServerSThreatDetectionPolicy() // invoke the operation PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - bool result = await collection.ExistsAsync(securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData + { + State = PostgreSqlServerSecurityAlertPolicyState.Disabled, + SendToEmailAccountAdmins = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + PostgreSqlServerSecurityAlertPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerSThreatDetectionPolicy() + public async Task Get_GetAServerSThreatDetectionPolicy() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsGet.json // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +126,21 @@ public async Task GetIfExists_GetAServerSThreatDetectionPolicy() // invoke the operation PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); - PostgreSqlServerSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + PostgreSqlServerSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() + public async Task GetAll_ListTheServerSThreatDetectionPolicies() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsCreateMax.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsListByServer.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,40 +158,25 @@ public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParam // get the collection of this PostgreSqlServerSecurityAlertPolicyResource PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); - // invoke the operation - PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData() + // invoke the operation and iterate over the result + await foreach (PostgreSqlServerSecurityAlertPolicyResource item in collection.GetAllAsync()) { - State = PostgreSqlServerSecurityAlertPolicyState.Enabled, - DisabledAlerts = -{ -"Access_Anomaly","Usage_Anomaly" -}, - EmailAddresses = -{ -"testSecurityAlert@microsoft.com" -}, - SendToEmailAccountAdmins = true, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - RetentionDays = 5, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - PostgreSqlServerSecurityAlertPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlServerSecurityAlertPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() + public async Task Exists_GetAServerSThreatDetectionPolicy() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsCreateMin.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsGet.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,27 +196,17 @@ public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalP // invoke the operation PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; - PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData() - { - State = PostgreSqlServerSecurityAlertPolicyState.Disabled, - SendToEmailAccountAdmins = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - PostgreSqlServerSecurityAlertPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(securityAlertPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheServerSThreatDetectionPolicies() + public async Task GetIfExists_GetAServerSThreatDetectionPolicy() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsListByServer.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerSecurityAlertsGet.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,17 +224,23 @@ public async Task GetAll_ListTheServerSThreatDetectionPolicies() // get the collection of this PostgreSqlServerSecurityAlertPolicyResource PostgreSqlServerSecurityAlertPolicyCollection collection = postgreSqlServer.GetPostgreSqlServerSecurityAlertPolicies(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlServerSecurityAlertPolicyResource item in collection.GetAllAsync()) + // invoke the operation + PostgreSqlSecurityAlertPolicyName securityAlertPolicyName = PostgreSqlSecurityAlertPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); + PostgreSqlServerSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlServerSecurityAlertPolicyData resourceData = item.Data; + PostgreSqlServerSecurityAlertPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyResource.cs index 57df4ae23ce9d..a52b8571f4227 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlServerSecurityAlertPolicyResource.cs @@ -69,17 +69,11 @@ public async Task Update_UpdateAServerSThreatDetectionPolicyWithAllParameters() PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); // invoke the operation - PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData() + PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData { State = PostgreSqlServerSecurityAlertPolicyState.Enabled, - DisabledAlerts = -{ -"Access_Anomaly","Usage_Anomaly" -}, - EmailAddresses = -{ -"testSecurityAlert@microsoft.com" -}, + DisabledAlerts = { "Access_Anomaly", "Usage_Anomaly" }, + EmailAddresses = { "testSecurityAlert@microsoft.com" }, SendToEmailAccountAdmins = true, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", @@ -117,7 +111,7 @@ public async Task Update_UpdateAServerSThreatDetectionPolicyWithMinimalParameter PostgreSqlServerSecurityAlertPolicyResource postgreSqlServerSecurityAlertPolicy = client.GetPostgreSqlServerSecurityAlertPolicyResource(postgreSqlServerSecurityAlertPolicyResourceId); // invoke the operation - PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData() + PostgreSqlServerSecurityAlertPolicyData data = new PostgreSqlServerSecurityAlertPolicyData { State = PostgreSqlServerSecurityAlertPolicyState.Disabled, SendToEmailAccountAdmins = true, diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs index f50746be9c153..a58472f3887ea 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_PostgreSqlVirtualNetworkRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAVirtualNetworkRule() + public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesGet.json - // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesCreateOrUpdate.json + // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,13 @@ public async Task Get_GetsAVirtualNetworkRule() // invoke the operation string virtualNetworkRuleName = "vnet-firewall-rule"; - PostgreSqlVirtualNetworkRuleResource result = await collection.GetAsync(virtualNetworkRuleName); + PostgreSqlVirtualNetworkRuleData data = new PostgreSqlVirtualNetworkRuleData + { + VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + IgnoreMissingVnetServiceEndpoint = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkRuleName, data); + PostgreSqlVirtualNetworkRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +57,7 @@ public async Task Get_GetsAVirtualNetworkRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAVirtualNetworkRule() + public async Task Get_GetsAVirtualNetworkRule() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesGet.json // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +80,21 @@ public async Task Exists_GetsAVirtualNetworkRule() // invoke the operation string virtualNetworkRuleName = "vnet-firewall-rule"; - bool result = await collection.ExistsAsync(virtualNetworkRuleName); + PostgreSqlVirtualNetworkRuleResource result = await collection.GetAsync(virtualNetworkRuleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlVirtualNetworkRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAVirtualNetworkRule() + public async Task GetAll_ListVirtualNetworkRules() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesGet.json - // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesList.json + // this example is just showing the usage of "VirtualNetworkRules_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +112,25 @@ public async Task GetIfExists_GetsAVirtualNetworkRule() // get the collection of this PostgreSqlVirtualNetworkRuleResource PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); - // invoke the operation - string virtualNetworkRuleName = "vnet-firewall-rule"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkRuleName); - PostgreSqlVirtualNetworkRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PostgreSqlVirtualNetworkRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlVirtualNetworkRuleData resourceData = result.Data; + PostgreSqlVirtualNetworkRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() + public async Task Exists_GetsAVirtualNetworkRule() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesCreateOrUpdate.json - // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesGet.json + // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,27 +150,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() // invoke the operation string virtualNetworkRuleName = "vnet-firewall-rule"; - PostgreSqlVirtualNetworkRuleData data = new PostgreSqlVirtualNetworkRuleData() - { - VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), - IgnoreMissingVnetServiceEndpoint = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkRuleName, data); - PostgreSqlVirtualNetworkRuleResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualNetworkRuleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlVirtualNetworkRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworkRules() + public async Task GetIfExists_GetsAVirtualNetworkRule() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesList.json - // this example is just showing the usage of "VirtualNetworkRules_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesGet.json + // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListVirtualNetworkRules() // get the collection of this PostgreSqlVirtualNetworkRuleResource PostgreSqlVirtualNetworkRuleCollection collection = postgreSqlServer.GetPostgreSqlVirtualNetworkRules(); - // invoke the operation and iterate over the result - await foreach (PostgreSqlVirtualNetworkRuleResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkRuleName = "vnet-firewall-rule"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkRuleName); + PostgreSqlVirtualNetworkRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PostgreSqlVirtualNetworkRuleData resourceData = item.Data; + PostgreSqlVirtualNetworkRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleResource.cs index 437d2de31854c..9d8d51e870452 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_PostgreSqlVirtualNetworkRuleResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetsAVirtualNetworkRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAVirtualNetworkRule() + public async Task Delete_DeleteAVirtualNetworkRule() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesCreateOrUpdate.json - // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesDelete.json + // this example is just showing the usage of "VirtualNetworkRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,27 +68,17 @@ public async Task Update_CreateOrUpdateAVirtualNetworkRule() PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); // invoke the operation - PostgreSqlVirtualNetworkRuleData data = new PostgreSqlVirtualNetworkRuleData() - { - VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), - IgnoreMissingVnetServiceEndpoint = false, - }; - ArmOperation lro = await postgreSqlVirtualNetworkRule.UpdateAsync(WaitUntil.Completed, data); - PostgreSqlVirtualNetworkRuleResource result = lro.Value; + await postgreSqlVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PostgreSqlVirtualNetworkRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAVirtualNetworkRule() + public async Task Update_CreateOrUpdateAVirtualNetworkRule() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesDelete.json - // this example is just showing the usage of "VirtualNetworkRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/VirtualNetworkRulesCreateOrUpdate.json + // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +95,19 @@ public async Task Delete_DeleteAVirtualNetworkRule() PostgreSqlVirtualNetworkRuleResource postgreSqlVirtualNetworkRule = client.GetPostgreSqlVirtualNetworkRuleResource(postgreSqlVirtualNetworkRuleResourceId); // invoke the operation - await postgreSqlVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); + PostgreSqlVirtualNetworkRuleData data = new PostgreSqlVirtualNetworkRuleData + { + VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + IgnoreMissingVnetServiceEndpoint = false, + }; + ArmOperation lro = await postgreSqlVirtualNetworkRule.UpdateAsync(WaitUntil.Completed, data); + PostgreSqlVirtualNetworkRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlVirtualNetworkRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_ServerThreatProtectionSettingsModelCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_ServerThreatProtectionSettingsModelCollection.cs index 3fc46f16c6af9..1901054d105b7 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_ServerThreatProtectionSettingsModelCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_ServerThreatProtectionSettingsModelCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServerThreatProtectionSettingsModelCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAServerSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_UpdateAServerSThreatProtectionSettings() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerThreatProtectionSettingsListByServer.json - // this example is just showing the usage of "ServerThreatProtectionSettings_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerThreatProtectionSettingsCreateOrUpdate.json + // this example is just showing the usage of "ServerThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,25 +31,28 @@ public async Task GetAll_GetAServerSAdvancedThreatProtectionSettings() // this example assumes you already have this PostgreSqlFlexibleServerResource created on azure // for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-6852"; - string serverName = "threatprotection-2080"; + string resourceGroupName = "threatprotection-4799"; + string serverName = "threatprotection-6440"; ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); // get the collection of this ServerThreatProtectionSettingsModelResource ServerThreatProtectionSettingsModelCollection collection = postgreSqlFlexibleServer.GetServerThreatProtectionSettingsModels(); - // invoke the operation and iterate over the result - await foreach (ServerThreatProtectionSettingsModelResource item in collection.GetAllAsync()) + // invoke the operation + ThreatProtectionName threatProtectionName = ThreatProtectionName.Default; + ServerThreatProtectionSettingsModelData data = new ServerThreatProtectionSettingsModelData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerThreatProtectionSettingsModelData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + State = ThreatProtectionState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, threatProtectionName, data); + ServerThreatProtectionSettingsModelResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerThreatProtectionSettingsModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_GetAServerSThreatProtectionSettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerSThreatProtectionSettings() + public async Task GetAll_GetAServerSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerThreatProtectionSettingsGet.json - // this example is just showing the usage of "ServerThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerThreatProtectionSettingsListByServer.json + // this example is just showing the usage of "ServerThreatProtectionSettings_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_GetAServerSThreatProtectionSettings() // get the collection of this ServerThreatProtectionSettingsModelResource ServerThreatProtectionSettingsModelCollection collection = postgreSqlFlexibleServer.GetServerThreatProtectionSettingsModels(); - // invoke the operation - ThreatProtectionName threatProtectionName = ThreatProtectionName.Default; - bool result = await collection.ExistsAsync(threatProtectionName); + // invoke the operation and iterate over the result + await foreach (ServerThreatProtectionSettingsModelResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerThreatProtectionSettingsModelData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerSThreatProtectionSettings() + public async Task Exists_GetAServerSThreatProtectionSettings() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerThreatProtectionSettingsGet.json // this example is just showing the usage of "ServerThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_GetAServerSThreatProtectionSettings() // invoke the operation ThreatProtectionName threatProtectionName = ThreatProtectionName.Default; - NullableResponse response = await collection.GetIfExistsAsync(threatProtectionName); - ServerThreatProtectionSettingsModelResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(threatProtectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerThreatProtectionSettingsModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSThreatProtectionSettings() + public async Task GetIfExists_GetAServerSThreatProtectionSettings() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerThreatProtectionSettingsCreateOrUpdate.json - // this example is just showing the usage of "ServerThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerThreatProtectionSettingsGet.json + // this example is just showing the usage of "ServerThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,8 +170,8 @@ public async Task CreateOrUpdate_UpdateAServerSThreatProtectionSettings() // this example assumes you already have this PostgreSqlFlexibleServerResource created on azure // for more information of creating PostgreSqlFlexibleServerResource, please refer to the document of PostgreSqlFlexibleServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-4799"; - string serverName = "threatprotection-6440"; + string resourceGroupName = "threatprotection-6852"; + string serverName = "threatprotection-2080"; ResourceIdentifier postgreSqlFlexibleServerResourceId = PostgreSqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); PostgreSqlFlexibleServerResource postgreSqlFlexibleServer = client.GetPostgreSqlFlexibleServerResource(postgreSqlFlexibleServerResourceId); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_UpdateAServerSThreatProtectionSettings() // invoke the operation ThreatProtectionName threatProtectionName = ThreatProtectionName.Default; - ServerThreatProtectionSettingsModelData data = new ServerThreatProtectionSettingsModelData() - { - State = ThreatProtectionState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, threatProtectionName, data); - ServerThreatProtectionSettingsModelResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(threatProtectionName); + ServerThreatProtectionSettingsModelResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerThreatProtectionSettingsModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerThreatProtectionSettingsModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_ServerThreatProtectionSettingsModelResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_ServerThreatProtectionSettingsModelResource.cs index 8cc6f32d3ceca..1ca7502a5c058 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_ServerThreatProtectionSettingsModelResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_ServerThreatProtectionSettingsModelResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdateAServerSThreatProtectionSettings() ServerThreatProtectionSettingsModelResource serverThreatProtectionSettingsModel = client.GetServerThreatProtectionSettingsModelResource(serverThreatProtectionSettingsModelResourceId); // invoke the operation - ServerThreatProtectionSettingsModelData data = new ServerThreatProtectionSettingsModelData() + ServerThreatProtectionSettingsModelData data = new ServerThreatProtectionSettingsModelData { State = ThreatProtectionState.Enabled, }; diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index a4ccb27c53194..2b518437f9075 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -102,6 +102,37 @@ public async Task CheckPostgreSqlFlexibleServerNameAvailabilityWithLocation_Name Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPostgreSqlFlexibleServers_ServerList() + { + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/ServerList.json + // this example is just showing the usage of "Servers_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PostgreSqlFlexibleServerResource item in subscriptionResource.GetPostgreSqlFlexibleServersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PostgreSqlFlexibleServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task ExecuteVirtualNetworkSubnetUsage_VirtualNetworkSubnetUsageList() @@ -122,7 +153,7 @@ public async Task ExecuteVirtualNetworkSubnetUsage_VirtualNetworkSubnetUsageList // invoke the operation AzureLocation locationName = new AzureLocation("westus"); - PostgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter postgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter = new PostgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter() + PostgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter postgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter = new PostgreSqlFlexibleServerVirtualNetworkSubnetUsageParameter { VirtualNetworkArmResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/testvnet"), }; diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index cc72a9eb52c3d..8b19cb604f57a 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.PostgreSql.FlexibleServers.Samples @@ -27,9 +28,7 @@ public async Task ExecuteGetPrivateDnsZoneSuffix_GetPrivateDnsZoneSuffix() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string result = await tenantResource.ExecuteGetPrivateDnsZoneSuffixAsync(); diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_VirtualEndpointResource.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_VirtualEndpointResource.cs index f41d6ba6b29db..6ab26f1adafb5 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_VirtualEndpointResource.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_VirtualEndpointResource.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualEndpointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAVirtualEndpointForAServerToUpdateThe() + public async Task Get_GetAVirtualEndpoint() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/VirtualEndpointUpdate.json - // this example is just showing the usage of "VirtualEndpoints_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/VirtualEndpointsGet.json + // this example is just showing the usage of "VirtualEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,7 @@ public async Task Update_UpdateAVirtualEndpointForAServerToUpdateThe() VirtualEndpointResource virtualEndpointResource = client.GetVirtualEndpointResource(virtualEndpointResourceId); // invoke the operation - VirtualEndpointResourcePatch patch = new VirtualEndpointResourcePatch() - { - EndpointType = VirtualEndpointType.ReadWrite, - Members = -{ -"testReplica1" -}, - }; - ArmOperation lro = await virtualEndpointResource.UpdateAsync(WaitUntil.Completed, patch); - VirtualEndpointResource result = lro.Value; + VirtualEndpointResource result = await virtualEndpointResource.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,10 +76,10 @@ public async Task Delete_DeleteAVirtualEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVirtualEndpoint() + public async Task Update_UpdateAVirtualEndpointForAServerToUpdateThe() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/VirtualEndpointsGet.json - // this example is just showing the usage of "VirtualEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/VirtualEndpointUpdate.json + // this example is just showing the usage of "VirtualEndpoints_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,7 +96,13 @@ public async Task Get_GetAVirtualEndpoint() VirtualEndpointResource virtualEndpointResource = client.GetVirtualEndpointResource(virtualEndpointResourceId); // invoke the operation - VirtualEndpointResource result = await virtualEndpointResource.GetAsync(); + VirtualEndpointResourcePatch patch = new VirtualEndpointResourcePatch + { + EndpointType = VirtualEndpointType.ReadWrite, + Members = { "testReplica1" }, + }; + ArmOperation lro = await virtualEndpointResource.UpdateAsync(WaitUntil.Completed, patch); + VirtualEndpointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_VirtualEndpointResourceCollection.cs b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_VirtualEndpointResourceCollection.cs index 16aec41d00ef9..a0a1f1867ee4b 100644 --- a/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_VirtualEndpointResourceCollection.cs +++ b/sdk/postgresql/Azure.ResourceManager.PostgreSql/samples/Generated/Samples/Sample_VirtualEndpointResourceCollection.cs @@ -41,13 +41,10 @@ public async Task CreateOrUpdate_CreateANewVirtualEndpointForAFlexibleServer() // invoke the operation string virtualEndpointName = "pgVirtualEndpoint1"; - VirtualEndpointResourceData data = new VirtualEndpointResourceData() + VirtualEndpointResourceData data = new VirtualEndpointResourceData { EndpointType = VirtualEndpointType.ReadWrite, - Members = -{ -"testPrimary1" -}, + Members = { "testPrimary1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualEndpointName, data); VirtualEndpointResource result = lro.Value; @@ -95,10 +92,10 @@ public async Task Get_GetAVirtualEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAVirtualEndpoint() + public async Task GetAll_VirtualEndpointListByServer() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/VirtualEndpointsGet.json - // this example is just showing the usage of "VirtualEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/VirtualEndpointsListByServer.json + // this example is just showing the usage of "VirtualEndpoints_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,16 +113,22 @@ public async Task Exists_GetAVirtualEndpoint() // get the collection of this VirtualEndpointResource VirtualEndpointResourceCollection collection = postgreSqlFlexibleServer.GetVirtualEndpointResources(); - // invoke the operation - string virtualEndpointName = "pgVirtualEndpoint1"; - bool result = await collection.ExistsAsync(virtualEndpointName); + // invoke the operation and iterate over the result + await foreach (VirtualEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualEndpointResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAVirtualEndpoint() + public async Task Exists_GetAVirtualEndpoint() { // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/VirtualEndpointsGet.json // this example is just showing the usage of "VirtualEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +151,17 @@ public async Task GetIfExists_GetAVirtualEndpoint() // invoke the operation string virtualEndpointName = "pgVirtualEndpoint1"; - NullableResponse response = await collection.GetIfExistsAsync(virtualEndpointName); - VirtualEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(virtualEndpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualEndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualEndpointListByServer() + public async Task GetIfExists_GetAVirtualEndpoint() { - // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/VirtualEndpointsListByServer.json - // this example is just showing the usage of "VirtualEndpoints_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2024-08-01/examples/VirtualEndpointsGet.json + // this example is just showing the usage of "VirtualEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +179,23 @@ public async Task GetAll_VirtualEndpointListByServer() // get the collection of this VirtualEndpointResource VirtualEndpointResourceCollection collection = postgreSqlFlexibleServer.GetVirtualEndpointResources(); - // invoke the operation and iterate over the result - await foreach (VirtualEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string virtualEndpointName = "pgVirtualEndpoint1"; + NullableResponse response = await collection.GetIfExistsAsync(virtualEndpointName); + VirtualEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualEndpointResourceData resourceData = item.Data; + VirtualEndpointResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_AutoScaleVCoreCollection.cs b/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_AutoScaleVCoreCollection.cs index 1b3c471a04f63..2489c230b4e96 100644 --- a/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_AutoScaleVCoreCollection.cs +++ b/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_AutoScaleVCoreCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AutoScaleVCoreCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDetailsOfAnAutoScaleVCore() + public async Task CreateOrUpdate_CreateAutoScaleVCore() { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/getAutoScaleVCore.json - // this example is just showing the usage of "AutoScaleVCores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/createAutoScaleVCore.json + // this example is just showing the usage of "AutoScaleVCores_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,21 @@ public async Task Get_GetDetailsOfAnAutoScaleVCore() // invoke the operation string vcoreName = "testvcore"; - AutoScaleVCoreResource result = await collection.GetAsync(vcoreName); + AutoScaleVCoreData data = new AutoScaleVCoreData(new AzureLocation("West US"), new AutoScaleVCoreSku("AutoScale") + { + Tier = VCoreSkuTier.AutoScale, + Capacity = 0, + }) + { + CapacityLimit = 10, + CapacityObjectId = "a28f00bd-5330-4572-88f1-fa883e074785", + Tags = +{ +["testKey"] = "testValue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vcoreName, data); + AutoScaleVCoreResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +66,7 @@ public async Task Get_GetDetailsOfAnAutoScaleVCore() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfAnAutoScaleVCore() + public async Task Get_GetDetailsOfAnAutoScaleVCore() { // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/getAutoScaleVCore.json // this example is just showing the usage of "AutoScaleVCores_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +88,21 @@ public async Task Exists_GetDetailsOfAnAutoScaleVCore() // invoke the operation string vcoreName = "testvcore"; - bool result = await collection.ExistsAsync(vcoreName); + AutoScaleVCoreResource result = await collection.GetAsync(vcoreName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoScaleVCoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfAnAutoScaleVCore() + public async Task GetAll_ListAutoScaleVCoresInResourceGroup() { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/getAutoScaleVCore.json - // this example is just showing the usage of "AutoScaleVCores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/listAutoScaleVCoresInResourceGroup.json + // this example is just showing the usage of "AutoScaleVCores_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +119,25 @@ public async Task GetIfExists_GetDetailsOfAnAutoScaleVCore() // get the collection of this AutoScaleVCoreResource AutoScaleVCoreCollection collection = resourceGroupResource.GetAutoScaleVCores(); - // invoke the operation - string vcoreName = "testvcore"; - NullableResponse response = await collection.GetIfExistsAsync(vcoreName); - AutoScaleVCoreResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutoScaleVCoreResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutoScaleVCoreData resourceData = result.Data; + AutoScaleVCoreData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAutoScaleVCore() + public async Task Exists_GetDetailsOfAnAutoScaleVCore() { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/createAutoScaleVCore.json - // this example is just showing the usage of "AutoScaleVCores_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/getAutoScaleVCore.json + // this example is just showing the usage of "AutoScaleVCores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,35 +156,17 @@ public async Task CreateOrUpdate_CreateAutoScaleVCore() // invoke the operation string vcoreName = "testvcore"; - AutoScaleVCoreData data = new AutoScaleVCoreData(new AzureLocation("West US"), new AutoScaleVCoreSku("AutoScale") - { - Tier = VCoreSkuTier.AutoScale, - Capacity = 0, - }) - { - CapacityLimit = 10, - CapacityObjectId = "a28f00bd-5330-4572-88f1-fa883e074785", - Tags = -{ -["testKey"] = "testValue", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vcoreName, data); - AutoScaleVCoreResource result = lro.Value; + bool result = await collection.ExistsAsync(vcoreName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoScaleVCoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAutoScaleVCoresInResourceGroup() + public async Task GetIfExists_GetDetailsOfAnAutoScaleVCore() { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/listAutoScaleVCoresInResourceGroup.json - // this example is just showing the usage of "AutoScaleVCores_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/getAutoScaleVCore.json + // this example is just showing the usage of "AutoScaleVCores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_ListAutoScaleVCoresInResourceGroup() // get the collection of this AutoScaleVCoreResource AutoScaleVCoreCollection collection = resourceGroupResource.GetAutoScaleVCores(); - // invoke the operation and iterate over the result - await foreach (AutoScaleVCoreResource item in collection.GetAllAsync()) + // invoke the operation + string vcoreName = "testvcore"; + NullableResponse response = await collection.GetIfExistsAsync(vcoreName); + AutoScaleVCoreResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutoScaleVCoreData resourceData = item.Data; + AutoScaleVCoreData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_AutoScaleVCoreResource.cs b/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_AutoScaleVCoreResource.cs index b862041851006..3a42a69d76ef2 100644 --- a/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_AutoScaleVCoreResource.cs +++ b/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_AutoScaleVCoreResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.PowerBIDedicated.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.PowerBIDedicated.Samples @@ -94,7 +93,7 @@ public async Task Update_UpdateAutoScaleVCoreParameters() AutoScaleVCoreResource autoScaleVCore = client.GetAutoScaleVCoreResource(autoScaleVCoreResourceId); // invoke the operation - AutoScaleVCorePatch patch = new AutoScaleVCorePatch() + AutoScaleVCorePatch patch = new AutoScaleVCorePatch { Sku = new AutoScaleVCoreSku("AutoScale") { @@ -103,7 +102,7 @@ public async Task Update_UpdateAutoScaleVCoreParameters() }, Tags = { -["testKey"] = "testValue", +["testKey"] = "testValue" }, CapacityLimit = 20, }; @@ -115,36 +114,5 @@ public async Task Update_UpdateAutoScaleVCoreParameters() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAutoScaleVCores_ListAutoScaleVCoresInSubscription() - { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/listAutoScaleVCoresInSubscription.json - // this example is just showing the usage of "AutoScaleVCores_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "613192d7-503f-477a-9cfe-4efc3ee2bd60"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AutoScaleVCoreResource item in subscriptionResource.GetAutoScaleVCoresAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoScaleVCoreData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_DedicatedCapacityCollection.cs b/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_DedicatedCapacityCollection.cs index e91ff5c2f8208..51174ab8a0ba9 100644 --- a/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_DedicatedCapacityCollection.cs +++ b/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_DedicatedCapacityCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DedicatedCapacityCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDetailsOfACapacity() + public async Task CreateOrUpdate_CreateCapacity() { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/getCapacity.json - // this example is just showing the usage of "Capacities_GetDetails" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/createCapacity.json + // this example is just showing the usage of "Capacities_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,19 @@ public async Task Get_GetDetailsOfACapacity() // invoke the operation string dedicatedCapacityName = "azsdktest"; - DedicatedCapacityResource result = await collection.GetAsync(dedicatedCapacityName); + DedicatedCapacityData data = new DedicatedCapacityData(new AzureLocation("West US"), new CapacitySku("A1") + { + Tier = CapacitySkuTier.PbieAzure, + }) + { + AdministrationMembers = { "azsdktest@microsoft.com", "azsdktest2@microsoft.com" }, + Tags = +{ +["testKey"] = "testValue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dedicatedCapacityName, data); + DedicatedCapacityResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +64,7 @@ public async Task Get_GetDetailsOfACapacity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfACapacity() + public async Task Get_GetDetailsOfACapacity() { // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/getCapacity.json // this example is just showing the usage of "Capacities_GetDetails" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +86,21 @@ public async Task Exists_GetDetailsOfACapacity() // invoke the operation string dedicatedCapacityName = "azsdktest"; - bool result = await collection.ExistsAsync(dedicatedCapacityName); + DedicatedCapacityResource result = await collection.GetAsync(dedicatedCapacityName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedCapacityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfACapacity() + public async Task GetAll_ListCapacitiesInResourceGroup() { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/getCapacity.json - // this example is just showing the usage of "Capacities_GetDetails" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/listCapacitiesInResourceGroup.json + // this example is just showing the usage of "Capacities_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +117,25 @@ public async Task GetIfExists_GetDetailsOfACapacity() // get the collection of this DedicatedCapacityResource DedicatedCapacityCollection collection = resourceGroupResource.GetDedicatedCapacities(); - // invoke the operation - string dedicatedCapacityName = "azsdktest"; - NullableResponse response = await collection.GetIfExistsAsync(dedicatedCapacityName); - DedicatedCapacityResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DedicatedCapacityResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DedicatedCapacityData resourceData = result.Data; + DedicatedCapacityData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCapacity() + public async Task Exists_GetDetailsOfACapacity() { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/createCapacity.json - // this example is just showing the usage of "Capacities_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/getCapacity.json + // this example is just showing the usage of "Capacities_GetDetails" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,36 +154,17 @@ public async Task CreateOrUpdate_CreateCapacity() // invoke the operation string dedicatedCapacityName = "azsdktest"; - DedicatedCapacityData data = new DedicatedCapacityData(new AzureLocation("West US"), new CapacitySku("A1") - { - Tier = CapacitySkuTier.PbieAzure, - }) - { - AdministrationMembers = -{ -"azsdktest@microsoft.com","azsdktest2@microsoft.com" -}, - Tags = -{ -["testKey"] = "testValue", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dedicatedCapacityName, data); - DedicatedCapacityResource result = lro.Value; + bool result = await collection.ExistsAsync(dedicatedCapacityName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedCapacityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCapacitiesInResourceGroup() + public async Task GetIfExists_GetDetailsOfACapacity() { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/listCapacitiesInResourceGroup.json - // this example is just showing the usage of "Capacities_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/getCapacity.json + // this example is just showing the usage of "Capacities_GetDetails" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +181,23 @@ public async Task GetAll_ListCapacitiesInResourceGroup() // get the collection of this DedicatedCapacityResource DedicatedCapacityCollection collection = resourceGroupResource.GetDedicatedCapacities(); - // invoke the operation and iterate over the result - await foreach (DedicatedCapacityResource item in collection.GetAllAsync()) + // invoke the operation + string dedicatedCapacityName = "azsdktest"; + NullableResponse response = await collection.GetIfExistsAsync(dedicatedCapacityName); + DedicatedCapacityResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DedicatedCapacityData resourceData = item.Data; + DedicatedCapacityData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_DedicatedCapacityResource.cs b/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_DedicatedCapacityResource.cs index b821003df0949..55c257c9624b9 100644 --- a/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_DedicatedCapacityResource.cs +++ b/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_DedicatedCapacityResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.PowerBIDedicated.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.PowerBIDedicated.Samples @@ -94,7 +93,7 @@ public async Task Update_UpdateCapacityParameters() DedicatedCapacityResource dedicatedCapacity = client.GetDedicatedCapacityResource(dedicatedCapacityResourceId); // invoke the operation - DedicatedCapacityPatch patch = new DedicatedCapacityPatch() + DedicatedCapacityPatch patch = new DedicatedCapacityPatch { Sku = new CapacitySku("A1") { @@ -102,12 +101,9 @@ public async Task Update_UpdateCapacityParameters() }, Tags = { -["testKey"] = "testValue", -}, - AdministrationMembers = -{ -"azsdktest@microsoft.com","azsdktest2@microsoft.com" +["testKey"] = "testValue" }, + AdministrationMembers = { "azsdktest@microsoft.com", "azsdktest2@microsoft.com" }, }; ArmOperation lro = await dedicatedCapacity.UpdateAsync(WaitUntil.Completed, patch); DedicatedCapacityResource result = lro.Value; @@ -140,7 +136,7 @@ public async Task Update_UpdateCapacityToGeneration2() DedicatedCapacityResource dedicatedCapacity = client.GetDedicatedCapacityResource(dedicatedCapacityResourceId); // invoke the operation - DedicatedCapacityPatch patch = new DedicatedCapacityPatch() + DedicatedCapacityPatch patch = new DedicatedCapacityPatch { Sku = new CapacitySku("A1") { @@ -148,7 +144,7 @@ public async Task Update_UpdateCapacityToGeneration2() }, Tags = { -["testKey"] = "testValue", +["testKey"] = "testValue" }, Mode = Mode.Gen2, }; @@ -214,64 +210,6 @@ public async Task Resume_GetDetailsOfACapacity() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDedicatedCapacities_GetDetailsOfACapacity() - { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/listCapacitiesInSubscription.json - // this example is just showing the usage of "Capacities_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "613192d7-503f-477a-9cfe-4efc3ee2bd60"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DedicatedCapacityResource item in subscriptionResource.GetDedicatedCapacitiesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedCapacityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSkusCapacities_ListEligibleSKUsForANewCapacity() - { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/listSKUsForNew.json - // this example is just showing the usage of "Capacities_ListSkus" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "613192d7-503f-477a-9cfe-4efc3ee2bd60"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CapacitySku item in subscriptionResource.GetSkusCapacitiesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSkusForCapacity_ListEligibleSKUsForAnExistingCapacity() @@ -300,35 +238,5 @@ public async Task GetSkusForCapacity_ListEligibleSKUsForAnExistingCapacity() Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckNameAvailabilityCapacity_CheckNameAvailabilityOfACapacity() - { - // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/checkNameAvailability.json - // this example is just showing the usage of "Capacities_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "613192d7-503f-477a-9cfe-4efc3ee2bd60"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("West US"); - CheckCapacityNameAvailabilityContent content = new CheckCapacityNameAvailabilityContent() - { - Name = "azsdktest", - ResourceType = "Microsoft.PowerBIDedicated/capacities", - }; - CheckCapacityNameAvailabilityResult result = await subscriptionResource.CheckNameAvailabilityCapacityAsync(location, content); - - Console.WriteLine($"Succeeded: {result}"); - } } } diff --git a/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..42dedc875ad70 --- /dev/null +++ b/sdk/powerbidedicated/Azure.ResourceManager.PowerBIDedicated/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,139 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.PowerBIDedicated.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.PowerBIDedicated.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDedicatedCapacities_GetDetailsOfACapacity() + { + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/listCapacitiesInSubscription.json + // this example is just showing the usage of "Capacities_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "613192d7-503f-477a-9cfe-4efc3ee2bd60"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DedicatedCapacityResource item in subscriptionResource.GetDedicatedCapacitiesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedCapacityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSkusCapacities_ListEligibleSKUsForANewCapacity() + { + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/listSKUsForNew.json + // this example is just showing the usage of "Capacities_ListSkus" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "613192d7-503f-477a-9cfe-4efc3ee2bd60"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CapacitySku item in subscriptionResource.GetSkusCapacitiesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckNameAvailabilityCapacity_CheckNameAvailabilityOfACapacity() + { + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/checkNameAvailability.json + // this example is just showing the usage of "Capacities_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "613192d7-503f-477a-9cfe-4efc3ee2bd60"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("West US"); + CheckCapacityNameAvailabilityContent content = new CheckCapacityNameAvailabilityContent + { + Name = "azsdktest", + ResourceType = "Microsoft.PowerBIDedicated/capacities", + }; + CheckCapacityNameAvailabilityResult result = await subscriptionResource.CheckNameAvailabilityCapacityAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAutoScaleVCores_ListAutoScaleVCoresInSubscription() + { + // Generated from example definition: specification/powerbidedicated/resource-manager/Microsoft.PowerBIdedicated/stable/2021-01-01/examples/listAutoScaleVCoresInSubscription.json + // this example is just showing the usage of "AutoScaleVCores_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "613192d7-503f-477a-9cfe-4efc3ee2bd60"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AutoScaleVCoreResource item in subscriptionResource.GetAutoScaleVCoresAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoScaleVCoreData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_CustomRolloutCollection.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_CustomRolloutCollection.cs index 41ceb90dbafd6..ba1e8a1d84c7e 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_CustomRolloutCollection.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_CustomRolloutCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CustomRolloutCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CustomRolloutsGet() + public async Task CreateOrUpdate_CustomRolloutsCreateOrUpdate() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CustomRollouts_Get.json - // this example is just showing the usage of "CustomRollouts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CustomRollouts_CreateOrUpdate.json + // this example is just showing the usage of "CustomRollouts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,13 @@ public async Task Get_CustomRolloutsGet() CustomRolloutCollection collection = providerRegistration.GetCustomRollouts(); // invoke the operation - string rolloutName = "canaryTesting99"; - CustomRolloutResource result = await collection.GetAsync(rolloutName); + string rolloutName = "brazilUsShoeBoxTesting"; + CustomRolloutData data = new CustomRolloutData(new CustomRolloutProperties(new CustomRolloutSpecification(new TrafficRegions + { + Regions = { new AzureLocation("brazilus") }, + }))); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, rolloutName, data); + CustomRolloutResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_CustomRolloutsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CustomRolloutsGet() + public async Task Get_CustomRolloutsGet() { // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CustomRollouts_Get.json // this example is just showing the usage of "CustomRollouts_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +78,21 @@ public async Task Exists_CustomRolloutsGet() // invoke the operation string rolloutName = "canaryTesting99"; - bool result = await collection.ExistsAsync(rolloutName); + CustomRolloutResource result = await collection.GetAsync(rolloutName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomRolloutData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CustomRolloutsGet() + public async Task GetAll_CustomRolloutsListByProviderRegistration() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CustomRollouts_Get.json - // this example is just showing the usage of "CustomRollouts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CustomRollouts_ListByProviderRegistration.json + // this example is just showing the usage of "CustomRollouts_ListByProviderRegistration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +109,25 @@ public async Task GetIfExists_CustomRolloutsGet() // get the collection of this CustomRolloutResource CustomRolloutCollection collection = providerRegistration.GetCustomRollouts(); - // invoke the operation - string rolloutName = "canaryTesting99"; - NullableResponse response = await collection.GetIfExistsAsync(rolloutName); - CustomRolloutResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CustomRolloutResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CustomRolloutData resourceData = result.Data; + CustomRolloutData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CustomRolloutsCreateOrUpdate() + public async Task Exists_CustomRolloutsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CustomRollouts_CreateOrUpdate.json - // this example is just showing the usage of "CustomRollouts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CustomRollouts_Get.json + // this example is just showing the usage of "CustomRollouts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,30 +145,18 @@ public async Task CreateOrUpdate_CustomRolloutsCreateOrUpdate() CustomRolloutCollection collection = providerRegistration.GetCustomRollouts(); // invoke the operation - string rolloutName = "brazilUsShoeBoxTesting"; - CustomRolloutData data = new CustomRolloutData(new CustomRolloutProperties(new CustomRolloutSpecification(new TrafficRegions() - { - Regions = -{ -new AzureLocation("brazilus") -}, - }))); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, rolloutName, data); - CustomRolloutResource result = lro.Value; + string rolloutName = "canaryTesting99"; + bool result = await collection.ExistsAsync(rolloutName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomRolloutData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CustomRolloutsListByProviderRegistration() + public async Task GetIfExists_CustomRolloutsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CustomRollouts_ListByProviderRegistration.json - // this example is just showing the usage of "CustomRollouts_ListByProviderRegistration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CustomRollouts_Get.json + // this example is just showing the usage of "CustomRollouts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,17 +173,23 @@ public async Task GetAll_CustomRolloutsListByProviderRegistration() // get the collection of this CustomRolloutResource CustomRolloutCollection collection = providerRegistration.GetCustomRollouts(); - // invoke the operation and iterate over the result - await foreach (CustomRolloutResource item in collection.GetAllAsync()) + // invoke the operation + string rolloutName = "canaryTesting99"; + NullableResponse response = await collection.GetIfExistsAsync(rolloutName); + CustomRolloutResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CustomRolloutData resourceData = item.Data; + CustomRolloutData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_CustomRolloutResource.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_CustomRolloutResource.cs index 737c3221f8903..1736a7cf21ae0 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_CustomRolloutResource.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_CustomRolloutResource.cs @@ -67,12 +67,9 @@ public async Task Update_CustomRolloutsCreateOrUpdate() CustomRolloutResource customRollout = client.GetCustomRolloutResource(customRolloutResourceId); // invoke the operation - CustomRolloutData data = new CustomRolloutData(new CustomRolloutProperties(new CustomRolloutSpecification(new TrafficRegions() + CustomRolloutData data = new CustomRolloutData(new CustomRolloutProperties(new CustomRolloutSpecification(new TrafficRegions { - Regions = -{ -new AzureLocation("brazilus") -}, + Regions = { new AzureLocation("brazilus") }, }))); ArmOperation lro = await customRollout.UpdateAsync(WaitUntil.Completed, data); CustomRolloutResource result = lro.Value; diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_DefaultRolloutCollection.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_DefaultRolloutCollection.cs index 405bc60cdfabd..3da20ed0365cc 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_DefaultRolloutCollection.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_DefaultRolloutCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DefaultRolloutCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DefaultRolloutsGet() + public async Task CreateOrUpdate_DefaultRolloutsCreateOrUpdate() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/DefaultRollouts_Get.json - // this example is just showing the usage of "DefaultRollouts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/DefaultRollouts_CreateOrUpdate.json + // this example is just showing the usage of "DefaultRollouts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,25 @@ public async Task Get_DefaultRolloutsGet() // invoke the operation string rolloutName = "2020week10"; - DefaultRolloutResource result = await collection.GetAsync(rolloutName); + DefaultRolloutData data = new DefaultRolloutData + { + Properties = new DefaultRolloutProperties + { + Specification = new DefaultRolloutSpecification + { + Canary = new CanaryTrafficRegionRolloutConfiguration + { + SkipRegions = { new AzureLocation("eastus2euap") }, + }, + RestOfTheWorldGroupTwo = new TrafficRegionRolloutConfiguration + { + WaitDuration = XmlConvert.ToTimeSpan("PT4H"), + }, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, rolloutName, data); + DefaultRolloutResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +70,7 @@ public async Task Get_DefaultRolloutsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DefaultRolloutsGet() + public async Task Get_DefaultRolloutsGet() { // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/DefaultRollouts_Get.json // this example is just showing the usage of "DefaultRollouts_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +92,21 @@ public async Task Exists_DefaultRolloutsGet() // invoke the operation string rolloutName = "2020week10"; - bool result = await collection.ExistsAsync(rolloutName); + DefaultRolloutResource result = await collection.GetAsync(rolloutName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DefaultRolloutData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DefaultRolloutsGet() + public async Task GetAll_DefaultRolloutsListByProviderRegistration() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/DefaultRollouts_Get.json - // this example is just showing the usage of "DefaultRollouts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/DefaultRollouts_ListByProviderRegistration.json + // this example is just showing the usage of "DefaultRollouts_ListByProviderRegistration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +123,25 @@ public async Task GetIfExists_DefaultRolloutsGet() // get the collection of this DefaultRolloutResource DefaultRolloutCollection collection = providerRegistration.GetDefaultRollouts(); - // invoke the operation - string rolloutName = "2020week10"; - NullableResponse response = await collection.GetIfExistsAsync(rolloutName); - DefaultRolloutResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DefaultRolloutResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DefaultRolloutData resourceData = result.Data; + DefaultRolloutData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DefaultRolloutsCreateOrUpdate() + public async Task Exists_DefaultRolloutsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/DefaultRollouts_CreateOrUpdate.json - // this example is just showing the usage of "DefaultRollouts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/DefaultRollouts_Get.json + // this example is just showing the usage of "DefaultRollouts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,42 +160,17 @@ public async Task CreateOrUpdate_DefaultRolloutsCreateOrUpdate() // invoke the operation string rolloutName = "2020week10"; - DefaultRolloutData data = new DefaultRolloutData() - { - Properties = new DefaultRolloutProperties() - { - Specification = new DefaultRolloutSpecification() - { - Canary = new CanaryTrafficRegionRolloutConfiguration() - { - SkipRegions = -{ -new AzureLocation("eastus2euap") -}, - }, - RestOfTheWorldGroupTwo = new TrafficRegionRolloutConfiguration() - { - WaitDuration = XmlConvert.ToTimeSpan("PT4H"), - }, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, rolloutName, data); - DefaultRolloutResource result = lro.Value; + bool result = await collection.ExistsAsync(rolloutName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DefaultRolloutData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DefaultRolloutsListByProviderRegistration() + public async Task GetIfExists_DefaultRolloutsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/DefaultRollouts_ListByProviderRegistration.json - // this example is just showing the usage of "DefaultRollouts_ListByProviderRegistration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/DefaultRollouts_Get.json + // this example is just showing the usage of "DefaultRollouts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,17 +187,23 @@ public async Task GetAll_DefaultRolloutsListByProviderRegistration() // get the collection of this DefaultRolloutResource DefaultRolloutCollection collection = providerRegistration.GetDefaultRollouts(); - // invoke the operation and iterate over the result - await foreach (DefaultRolloutResource item in collection.GetAllAsync()) + // invoke the operation + string rolloutName = "2020week10"; + NullableResponse response = await collection.GetIfExistsAsync(rolloutName); + DefaultRolloutResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DefaultRolloutData resourceData = item.Data; + DefaultRolloutData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_DefaultRolloutResource.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_DefaultRolloutResource.cs index 935db93ff133f..d6eb507cd4fb6 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_DefaultRolloutResource.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_DefaultRolloutResource.cs @@ -94,20 +94,17 @@ public async Task Update_DefaultRolloutsCreateOrUpdate() DefaultRolloutResource defaultRollout = client.GetDefaultRolloutResource(defaultRolloutResourceId); // invoke the operation - DefaultRolloutData data = new DefaultRolloutData() + DefaultRolloutData data = new DefaultRolloutData { - Properties = new DefaultRolloutProperties() + Properties = new DefaultRolloutProperties { - Specification = new DefaultRolloutSpecification() + Specification = new DefaultRolloutSpecification { - Canary = new CanaryTrafficRegionRolloutConfiguration() + Canary = new CanaryTrafficRegionRolloutConfiguration { - SkipRegions = -{ -new AzureLocation("eastus2euap") -}, + SkipRegions = { new AzureLocation("eastus2euap") }, }, - RestOfTheWorldGroupTwo = new TrafficRegionRolloutConfiguration() + RestOfTheWorldGroupTwo = new TrafficRegionRolloutConfiguration { WaitDuration = XmlConvert.ToTimeSpan("PT4H"), }, diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeFirstSkuCollection.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeFirstSkuCollection.cs index f4e7ff375cb31..a3417b5e69711 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeFirstSkuCollection.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeFirstSkuCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NestedResourceTypeFirstSkuCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SkusGetNestedResourceTypeFirst() + public async Task CreateOrUpdate_SkusCreateOrUpdateNestedResourceTypeFirst() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeFirst.json - // this example is just showing the usage of "Skus_GetNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeFirst.json + // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,25 @@ public async Task Get_SkusGetNestedResourceTypeFirst() // invoke the operation string sku = "testSku"; - NestedResourceTypeFirstSkuResource result = await collection.GetAsync(sku); + ResourceTypeSkuData data = new ResourceTypeSkuData + { + Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] + { +new ResourceTypeSkuSetting("freeSku") +{ +Tier = "Tier1", +Kind = "Standard", +}, +new ResourceTypeSkuSetting("premiumSku") +{ +Tier = "Tier2", +Kind = "Premium", +Costs = {new ResourceTypeSkuCost("xxx")}, +} + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sku, data); + NestedResourceTypeFirstSkuResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +71,7 @@ public async Task Get_SkusGetNestedResourceTypeFirst() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SkusGetNestedResourceTypeFirst() + public async Task Get_SkusGetNestedResourceTypeFirst() { // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeFirst.json // this example is just showing the usage of "Skus_GetNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +95,21 @@ public async Task Exists_SkusGetNestedResourceTypeFirst() // invoke the operation string sku = "testSku"; - bool result = await collection.ExistsAsync(sku); + NestedResourceTypeFirstSkuResource result = await collection.GetAsync(sku); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceTypeSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SkusGetNestedResourceTypeFirst() + public async Task GetAll_SkusListByResourceTypeRegistrationsNestedResourceTypeFirst() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeFirst.json - // this example is just showing the usage of "Skus_GetNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_ListByResourceTypeRegistrationsNestedResourceTypeFirst.json + // this example is just showing the usage of "Skus_ListByResourceTypeRegistrationsNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +128,25 @@ public async Task GetIfExists_SkusGetNestedResourceTypeFirst() string nestedResourceTypeFirst = "nestedResourceTypeFirst"; NestedResourceTypeFirstSkuCollection collection = resourceTypeRegistration.GetNestedResourceTypeFirstSkus(nestedResourceTypeFirst); - // invoke the operation - string sku = "testSku"; - NullableResponse response = await collection.GetIfExistsAsync(sku); - NestedResourceTypeFirstSkuResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NestedResourceTypeFirstSkuResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; + ResourceTypeSkuData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SkusCreateOrUpdateNestedResourceTypeFirst() + public async Task Exists_SkusGetNestedResourceTypeFirst() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeFirst.json - // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeFirst.json + // this example is just showing the usage of "Skus_GetNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,41 +167,17 @@ public async Task CreateOrUpdate_SkusCreateOrUpdateNestedResourceTypeFirst() // invoke the operation string sku = "testSku"; - ResourceTypeSkuData data = new ResourceTypeSkuData() - { - Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] - { -new ResourceTypeSkuSetting("freeSku") -{ -Tier = "Tier1", -Kind = "Standard", -},new ResourceTypeSkuSetting("premiumSku") -{ -Tier = "Tier2", -Kind = "Premium", -Costs = -{ -new ResourceTypeSkuCost("xxx") -}, -} - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sku, data); - NestedResourceTypeFirstSkuResource result = lro.Value; + bool result = await collection.ExistsAsync(sku); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SkusListByResourceTypeRegistrationsNestedResourceTypeFirst() + public async Task GetIfExists_SkusGetNestedResourceTypeFirst() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_ListByResourceTypeRegistrationsNestedResourceTypeFirst.json - // this example is just showing the usage of "Skus_ListByResourceTypeRegistrationsNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeFirst.json + // this example is just showing the usage of "Skus_GetNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,17 +196,23 @@ public async Task GetAll_SkusListByResourceTypeRegistrationsNestedResourceTypeFi string nestedResourceTypeFirst = "nestedResourceTypeFirst"; NestedResourceTypeFirstSkuCollection collection = resourceTypeRegistration.GetNestedResourceTypeFirstSkus(nestedResourceTypeFirst); - // invoke the operation and iterate over the result - await foreach (NestedResourceTypeFirstSkuResource item in collection.GetAllAsync()) + // invoke the operation + string sku = "testSku"; + NullableResponse response = await collection.GetIfExistsAsync(sku); + NestedResourceTypeFirstSkuResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = item.Data; + ResourceTypeSkuData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeFirstSkuResource.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeFirstSkuResource.cs index 4cdd5a18eda97..ebfe7a80d1cf1 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeFirstSkuResource.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeFirstSkuResource.cs @@ -50,10 +50,10 @@ public async Task Get_SkusGetNestedResourceTypeFirst() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SkusCreateOrUpdateNestedResourceTypeFirst() + public async Task Delete_SkusDeleteNestedResourceTypeFirst() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeFirst.json - // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_DeleteNestedResourceTypeFirst.json + // this example is just showing the usage of "Skus_DeleteNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,41 +71,17 @@ public async Task Update_SkusCreateOrUpdateNestedResourceTypeFirst() NestedResourceTypeFirstSkuResource nestedResourceTypeFirstSku = client.GetNestedResourceTypeFirstSkuResource(nestedResourceTypeFirstSkuResourceId); // invoke the operation - ResourceTypeSkuData data = new ResourceTypeSkuData() - { - Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] - { -new ResourceTypeSkuSetting("freeSku") -{ -Tier = "Tier1", -Kind = "Standard", -},new ResourceTypeSkuSetting("premiumSku") -{ -Tier = "Tier2", -Kind = "Premium", -Costs = -{ -new ResourceTypeSkuCost("xxx") -}, -} - }), - }; - ArmOperation lro = await nestedResourceTypeFirstSku.UpdateAsync(WaitUntil.Completed, data); - NestedResourceTypeFirstSkuResource result = lro.Value; + await nestedResourceTypeFirstSku.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SkusDeleteNestedResourceTypeFirst() + public async Task Update_SkusCreateOrUpdateNestedResourceTypeFirst() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_DeleteNestedResourceTypeFirst.json - // this example is just showing the usage of "Skus_DeleteNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeFirst.json + // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeFirst" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -123,9 +99,31 @@ public async Task Delete_SkusDeleteNestedResourceTypeFirst() NestedResourceTypeFirstSkuResource nestedResourceTypeFirstSku = client.GetNestedResourceTypeFirstSkuResource(nestedResourceTypeFirstSkuResourceId); // invoke the operation - await nestedResourceTypeFirstSku.DeleteAsync(WaitUntil.Completed); + ResourceTypeSkuData data = new ResourceTypeSkuData + { + Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] + { +new ResourceTypeSkuSetting("freeSku") +{ +Tier = "Tier1", +Kind = "Standard", +}, +new ResourceTypeSkuSetting("premiumSku") +{ +Tier = "Tier2", +Kind = "Premium", +Costs = {new ResourceTypeSkuCost("xxx")}, +} + }), + }; + ArmOperation lro = await nestedResourceTypeFirstSku.UpdateAsync(WaitUntil.Completed, data); + NestedResourceTypeFirstSkuResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceTypeSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeSecondSkuCollection.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeSecondSkuCollection.cs index fe329fa8b9506..d5ab00dcf0ddb 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeSecondSkuCollection.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeSecondSkuCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NestedResourceTypeSecondSkuCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SkusGetNestedResourceTypeSecond() + public async Task CreateOrUpdate_SkusCreateOrUpdateNestedResourceTypeSecond() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeSecond.json - // this example is just showing the usage of "Skus_GetNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeSecond.json + // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,7 +43,25 @@ public async Task Get_SkusGetNestedResourceTypeSecond() // invoke the operation string sku = "testSku"; - NestedResourceTypeSecondSkuResource result = await collection.GetAsync(sku); + ResourceTypeSkuData data = new ResourceTypeSkuData + { + Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] + { +new ResourceTypeSkuSetting("freeSku") +{ +Tier = "Tier1", +Kind = "Standard", +}, +new ResourceTypeSkuSetting("premiumSku") +{ +Tier = "Tier2", +Kind = "Premium", +Costs = {new ResourceTypeSkuCost("xxx")}, +} + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sku, data); + NestedResourceTypeSecondSkuResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,7 +72,7 @@ public async Task Get_SkusGetNestedResourceTypeSecond() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SkusGetNestedResourceTypeSecond() + public async Task Get_SkusGetNestedResourceTypeSecond() { // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeSecond.json // this example is just showing the usage of "Skus_GetNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. @@ -79,17 +97,21 @@ public async Task Exists_SkusGetNestedResourceTypeSecond() // invoke the operation string sku = "testSku"; - bool result = await collection.ExistsAsync(sku); + NestedResourceTypeSecondSkuResource result = await collection.GetAsync(sku); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceTypeSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SkusGetNestedResourceTypeSecond() + public async Task GetAll_SkusListByResourceTypeRegistrationsNestedResourceTypeSecond() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeSecond.json - // this example is just showing the usage of "Skus_GetNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_ListByResourceTypeRegistrationsNestedResourceTypeSecond.json + // this example is just showing the usage of "Skus_ListByResourceTypeRegistrationsNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,31 +131,25 @@ public async Task GetIfExists_SkusGetNestedResourceTypeSecond() string nestedResourceTypeSecond = "nestedResourceTypeSecond"; NestedResourceTypeSecondSkuCollection collection = resourceTypeRegistration.GetNestedResourceTypeSecondSkus(nestedResourceTypeFirst, nestedResourceTypeSecond); - // invoke the operation - string sku = "testSku"; - NullableResponse response = await collection.GetIfExistsAsync(sku); - NestedResourceTypeSecondSkuResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NestedResourceTypeSecondSkuResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; + ResourceTypeSkuData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SkusCreateOrUpdateNestedResourceTypeSecond() + public async Task Exists_SkusGetNestedResourceTypeSecond() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeSecond.json - // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeSecond.json + // this example is just showing the usage of "Skus_GetNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -155,41 +171,17 @@ public async Task CreateOrUpdate_SkusCreateOrUpdateNestedResourceTypeSecond() // invoke the operation string sku = "testSku"; - ResourceTypeSkuData data = new ResourceTypeSkuData() - { - Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] - { -new ResourceTypeSkuSetting("freeSku") -{ -Tier = "Tier1", -Kind = "Standard", -},new ResourceTypeSkuSetting("premiumSku") -{ -Tier = "Tier2", -Kind = "Premium", -Costs = -{ -new ResourceTypeSkuCost("xxx") -}, -} - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sku, data); - NestedResourceTypeSecondSkuResource result = lro.Value; + bool result = await collection.ExistsAsync(sku); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SkusListByResourceTypeRegistrationsNestedResourceTypeSecond() + public async Task GetIfExists_SkusGetNestedResourceTypeSecond() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_ListByResourceTypeRegistrationsNestedResourceTypeSecond.json - // this example is just showing the usage of "Skus_ListByResourceTypeRegistrationsNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeSecond.json + // this example is just showing the usage of "Skus_GetNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -209,17 +201,23 @@ public async Task GetAll_SkusListByResourceTypeRegistrationsNestedResourceTypeSe string nestedResourceTypeSecond = "nestedResourceTypeSecond"; NestedResourceTypeSecondSkuCollection collection = resourceTypeRegistration.GetNestedResourceTypeSecondSkus(nestedResourceTypeFirst, nestedResourceTypeSecond); - // invoke the operation and iterate over the result - await foreach (NestedResourceTypeSecondSkuResource item in collection.GetAllAsync()) + // invoke the operation + string sku = "testSku"; + NullableResponse response = await collection.GetIfExistsAsync(sku); + NestedResourceTypeSecondSkuResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = item.Data; + ResourceTypeSkuData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeSecondSkuResource.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeSecondSkuResource.cs index 10bba74d4dfdc..47c0ce46dfed1 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeSecondSkuResource.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeSecondSkuResource.cs @@ -51,10 +51,10 @@ public async Task Get_SkusGetNestedResourceTypeSecond() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SkusCreateOrUpdateNestedResourceTypeSecond() + public async Task Delete_SkusDeleteNestedResourceTypeSecond() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeSecond.json - // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_DeleteNestedResourceTypeSecond.json + // this example is just showing the usage of "Skus_DeleteNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,41 +73,17 @@ public async Task Update_SkusCreateOrUpdateNestedResourceTypeSecond() NestedResourceTypeSecondSkuResource nestedResourceTypeSecondSku = client.GetNestedResourceTypeSecondSkuResource(nestedResourceTypeSecondSkuResourceId); // invoke the operation - ResourceTypeSkuData data = new ResourceTypeSkuData() - { - Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] - { -new ResourceTypeSkuSetting("freeSku") -{ -Tier = "Tier1", -Kind = "Standard", -},new ResourceTypeSkuSetting("premiumSku") -{ -Tier = "Tier2", -Kind = "Premium", -Costs = -{ -new ResourceTypeSkuCost("xxx") -}, -} - }), - }; - ArmOperation lro = await nestedResourceTypeSecondSku.UpdateAsync(WaitUntil.Completed, data); - NestedResourceTypeSecondSkuResource result = lro.Value; + await nestedResourceTypeSecondSku.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SkusDeleteNestedResourceTypeSecond() + public async Task Update_SkusCreateOrUpdateNestedResourceTypeSecond() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_DeleteNestedResourceTypeSecond.json - // this example is just showing the usage of "Skus_DeleteNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeSecond.json + // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeSecond" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -126,9 +102,31 @@ public async Task Delete_SkusDeleteNestedResourceTypeSecond() NestedResourceTypeSecondSkuResource nestedResourceTypeSecondSku = client.GetNestedResourceTypeSecondSkuResource(nestedResourceTypeSecondSkuResourceId); // invoke the operation - await nestedResourceTypeSecondSku.DeleteAsync(WaitUntil.Completed); + ResourceTypeSkuData data = new ResourceTypeSkuData + { + Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] + { +new ResourceTypeSkuSetting("freeSku") +{ +Tier = "Tier1", +Kind = "Standard", +}, +new ResourceTypeSkuSetting("premiumSku") +{ +Tier = "Tier2", +Kind = "Premium", +Costs = {new ResourceTypeSkuCost("xxx")}, +} + }), + }; + ArmOperation lro = await nestedResourceTypeSecondSku.UpdateAsync(WaitUntil.Completed, data); + NestedResourceTypeSecondSkuResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceTypeSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeThirdSkuCollection.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeThirdSkuCollection.cs index 7ca47eb7df2ea..5334c3d283db8 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeThirdSkuCollection.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeThirdSkuCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NestedResourceTypeThirdSkuCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SkusGetNestedResourceTypeThird() + public async Task CreateOrUpdate_SkusCreateOrUpdateNestedResourceTypeThird() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeThird.json - // this example is just showing the usage of "Skus_GetNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeThird.json + // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -44,7 +44,25 @@ public async Task Get_SkusGetNestedResourceTypeThird() // invoke the operation string sku = "testSku"; - NestedResourceTypeThirdSkuResource result = await collection.GetAsync(sku); + ResourceTypeSkuData data = new ResourceTypeSkuData + { + Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] + { +new ResourceTypeSkuSetting("freeSku") +{ +Tier = "Tier1", +Kind = "Standard", +}, +new ResourceTypeSkuSetting("premiumSku") +{ +Tier = "Tier2", +Kind = "Premium", +Costs = {new ResourceTypeSkuCost("xxx")}, +} + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sku, data); + NestedResourceTypeThirdSkuResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,7 +73,7 @@ public async Task Get_SkusGetNestedResourceTypeThird() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SkusGetNestedResourceTypeThird() + public async Task Get_SkusGetNestedResourceTypeThird() { // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeThird.json // this example is just showing the usage of "Skus_GetNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. @@ -81,17 +99,21 @@ public async Task Exists_SkusGetNestedResourceTypeThird() // invoke the operation string sku = "testSku"; - bool result = await collection.ExistsAsync(sku); + NestedResourceTypeThirdSkuResource result = await collection.GetAsync(sku); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceTypeSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SkusGetNestedResourceTypeThird() + public async Task GetAll_SkusListByResourceTypeRegistrationsNestedResourceTypeThird() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeThird.json - // this example is just showing the usage of "Skus_GetNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_ListByResourceTypeRegistrationsNestedResourceTypeThird.json + // this example is just showing the usage of "Skus_ListByResourceTypeRegistrationsNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,31 +134,25 @@ public async Task GetIfExists_SkusGetNestedResourceTypeThird() string nestedResourceTypeThird = "nestedResourceTypeThird"; NestedResourceTypeThirdSkuCollection collection = resourceTypeRegistration.GetNestedResourceTypeThirdSkus(nestedResourceTypeFirst, nestedResourceTypeSecond, nestedResourceTypeThird); - // invoke the operation - string sku = "testSku"; - NullableResponse response = await collection.GetIfExistsAsync(sku); - NestedResourceTypeThirdSkuResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NestedResourceTypeThirdSkuResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; + ResourceTypeSkuData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SkusCreateOrUpdateNestedResourceTypeThird() + public async Task Exists_SkusGetNestedResourceTypeThird() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeThird.json - // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeThird.json + // this example is just showing the usage of "Skus_GetNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -159,41 +175,17 @@ public async Task CreateOrUpdate_SkusCreateOrUpdateNestedResourceTypeThird() // invoke the operation string sku = "testSku"; - ResourceTypeSkuData data = new ResourceTypeSkuData() - { - Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] - { -new ResourceTypeSkuSetting("freeSku") -{ -Tier = "Tier1", -Kind = "Standard", -},new ResourceTypeSkuSetting("premiumSku") -{ -Tier = "Tier2", -Kind = "Premium", -Costs = -{ -new ResourceTypeSkuCost("xxx") -}, -} - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sku, data); - NestedResourceTypeThirdSkuResource result = lro.Value; + bool result = await collection.ExistsAsync(sku); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SkusListByResourceTypeRegistrationsNestedResourceTypeThird() + public async Task GetIfExists_SkusGetNestedResourceTypeThird() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_ListByResourceTypeRegistrationsNestedResourceTypeThird.json - // this example is just showing the usage of "Skus_ListByResourceTypeRegistrationsNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_GetNestedResourceTypeThird.json + // this example is just showing the usage of "Skus_GetNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -214,17 +206,23 @@ public async Task GetAll_SkusListByResourceTypeRegistrationsNestedResourceTypeTh string nestedResourceTypeThird = "nestedResourceTypeThird"; NestedResourceTypeThirdSkuCollection collection = resourceTypeRegistration.GetNestedResourceTypeThirdSkus(nestedResourceTypeFirst, nestedResourceTypeSecond, nestedResourceTypeThird); - // invoke the operation and iterate over the result - await foreach (NestedResourceTypeThirdSkuResource item in collection.GetAllAsync()) + // invoke the operation + string sku = "testSku"; + NullableResponse response = await collection.GetIfExistsAsync(sku); + NestedResourceTypeThirdSkuResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = item.Data; + ResourceTypeSkuData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeThirdSkuResource.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeThirdSkuResource.cs index 27366d432f111..4e790b5b6432b 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeThirdSkuResource.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NestedResourceTypeThirdSkuResource.cs @@ -52,10 +52,10 @@ public async Task Get_SkusGetNestedResourceTypeThird() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SkusCreateOrUpdateNestedResourceTypeThird() + public async Task Delete_SkusDeleteNestedResourceTypeThird() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeThird.json - // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_DeleteNestedResourceTypeThird.json + // this example is just showing the usage of "Skus_DeleteNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,41 +75,17 @@ public async Task Update_SkusCreateOrUpdateNestedResourceTypeThird() NestedResourceTypeThirdSkuResource nestedResourceTypeThirdSku = client.GetNestedResourceTypeThirdSkuResource(nestedResourceTypeThirdSkuResourceId); // invoke the operation - ResourceTypeSkuData data = new ResourceTypeSkuData() - { - Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] - { -new ResourceTypeSkuSetting("freeSku") -{ -Tier = "Tier1", -Kind = "Standard", -},new ResourceTypeSkuSetting("premiumSku") -{ -Tier = "Tier2", -Kind = "Premium", -Costs = -{ -new ResourceTypeSkuCost("xxx") -}, -} - }), - }; - ArmOperation lro = await nestedResourceTypeThirdSku.UpdateAsync(WaitUntil.Completed, data); - NestedResourceTypeThirdSkuResource result = lro.Value; + await nestedResourceTypeThirdSku.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SkusDeleteNestedResourceTypeThird() + public async Task Update_SkusCreateOrUpdateNestedResourceTypeThird() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_DeleteNestedResourceTypeThird.json - // this example is just showing the usage of "Skus_DeleteNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdateNestedResourceTypeThird.json + // this example is just showing the usage of "Skus_CreateOrUpdateNestedResourceTypeThird" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,9 +105,31 @@ public async Task Delete_SkusDeleteNestedResourceTypeThird() NestedResourceTypeThirdSkuResource nestedResourceTypeThirdSku = client.GetNestedResourceTypeThirdSkuResource(nestedResourceTypeThirdSkuResourceId); // invoke the operation - await nestedResourceTypeThirdSku.DeleteAsync(WaitUntil.Completed); + ResourceTypeSkuData data = new ResourceTypeSkuData + { + Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] + { +new ResourceTypeSkuSetting("freeSku") +{ +Tier = "Tier1", +Kind = "Standard", +}, +new ResourceTypeSkuSetting("premiumSku") +{ +Tier = "Tier2", +Kind = "Premium", +Costs = {new ResourceTypeSkuCost("xxx")}, +} + }), + }; + ArmOperation lro = await nestedResourceTypeThirdSku.UpdateAsync(WaitUntil.Completed, data); + NestedResourceTypeThirdSkuResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceTypeSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NotificationRegistrationCollection.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NotificationRegistrationCollection.cs index 959402eb11fd1..92929f5eff9a7 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NotificationRegistrationCollection.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NotificationRegistrationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NotificationRegistrationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NotificationRegistrationsGet() + public async Task CreateOrUpdate_NotificationRegistrationsCreateOrUpdate() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_Get.json - // this example is just showing the usage of "NotificationRegistrations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_CreateOrUpdate.json + // this example is just showing the usage of "NotificationRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,26 @@ public async Task Get_NotificationRegistrationsGet() // invoke the operation string notificationRegistrationName = "fooNotificationRegistration"; - NotificationRegistrationResource result = await collection.GetAsync(notificationRegistrationName); + NotificationRegistrationData data = new NotificationRegistrationData + { + Properties = new NotificationRegistrationProperties + { + NotificationMode = NotificationMode.EventHub, + MessageScope = MessageScope.RegisteredSubscriptions, + IncludedEvents = { "*/write", "Microsoft.Contoso/employees/delete" }, + NotificationEndpoints = {new NotificationEndpoint +{ +NotificationDestination = new ResourceIdentifier("/subscriptions/ac6bcfb5-3dc1-491f-95a6-646b89bf3e88/resourceGroups/mgmtexp-eastus/providers/Microsoft.EventHub/namespaces/unitedstates-mgmtexpint/eventhubs/armlinkednotifications"), +Locations = {new AzureLocation(""), new AzureLocation("East US")}, +}, new NotificationEndpoint +{ +NotificationDestination = new ResourceIdentifier("/subscriptions/ac6bcfb5-3dc1-491f-95a6-646b89bf3e88/resourceGroups/mgmtexp-northeurope/providers/Microsoft.EventHub/namespaces/europe-mgmtexpint/eventhubs/armlinkednotifications"), +Locations = {new AzureLocation("North Europe")}, +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, notificationRegistrationName, data); + NotificationRegistrationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +70,7 @@ public async Task Get_NotificationRegistrationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NotificationRegistrationsGet() + public async Task Get_NotificationRegistrationsGet() { // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_Get.json // this example is just showing the usage of "NotificationRegistrations_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +92,21 @@ public async Task Exists_NotificationRegistrationsGet() // invoke the operation string notificationRegistrationName = "fooNotificationRegistration"; - bool result = await collection.ExistsAsync(notificationRegistrationName); + NotificationRegistrationResource result = await collection.GetAsync(notificationRegistrationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationRegistrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NotificationRegistrationsGet() + public async Task GetAll_NotificationRegistrationsListByProviderRegistration() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_Get.json - // this example is just showing the usage of "NotificationRegistrations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_ListByProviderRegistration.json + // this example is just showing the usage of "NotificationRegistrations_ListByProviderRegistration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +123,25 @@ public async Task GetIfExists_NotificationRegistrationsGet() // get the collection of this NotificationRegistrationResource NotificationRegistrationCollection collection = providerRegistration.GetNotificationRegistrations(); - // invoke the operation - string notificationRegistrationName = "fooNotificationRegistration"; - NullableResponse response = await collection.GetIfExistsAsync(notificationRegistrationName); - NotificationRegistrationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NotificationRegistrationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NotificationRegistrationData resourceData = result.Data; + NotificationRegistrationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NotificationRegistrationsCreateOrUpdate() + public async Task Exists_NotificationRegistrationsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_CreateOrUpdate.json - // this example is just showing the usage of "NotificationRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_Get.json + // this example is just showing the usage of "NotificationRegistrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,52 +160,17 @@ public async Task CreateOrUpdate_NotificationRegistrationsCreateOrUpdate() // invoke the operation string notificationRegistrationName = "fooNotificationRegistration"; - NotificationRegistrationData data = new NotificationRegistrationData() - { - Properties = new NotificationRegistrationProperties() - { - NotificationMode = NotificationMode.EventHub, - MessageScope = MessageScope.RegisteredSubscriptions, - IncludedEvents = -{ -"*/write","Microsoft.Contoso/employees/delete" -}, - NotificationEndpoints = -{ -new NotificationEndpoint() -{ -NotificationDestination = new ResourceIdentifier("/subscriptions/ac6bcfb5-3dc1-491f-95a6-646b89bf3e88/resourceGroups/mgmtexp-eastus/providers/Microsoft.EventHub/namespaces/unitedstates-mgmtexpint/eventhubs/armlinkednotifications"), -Locations = -{ -new AzureLocation(""),new AzureLocation("East US") -}, -},new NotificationEndpoint() -{ -NotificationDestination = new ResourceIdentifier("/subscriptions/ac6bcfb5-3dc1-491f-95a6-646b89bf3e88/resourceGroups/mgmtexp-northeurope/providers/Microsoft.EventHub/namespaces/europe-mgmtexpint/eventhubs/armlinkednotifications"), -Locations = -{ -new AzureLocation("North Europe") -}, -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, notificationRegistrationName, data); - NotificationRegistrationResource result = lro.Value; + bool result = await collection.ExistsAsync(notificationRegistrationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationRegistrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NotificationRegistrationsListByProviderRegistration() + public async Task GetIfExists_NotificationRegistrationsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_ListByProviderRegistration.json - // this example is just showing the usage of "NotificationRegistrations_ListByProviderRegistration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_Get.json + // this example is just showing the usage of "NotificationRegistrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -205,17 +187,23 @@ public async Task GetAll_NotificationRegistrationsListByProviderRegistration() // get the collection of this NotificationRegistrationResource NotificationRegistrationCollection collection = providerRegistration.GetNotificationRegistrations(); - // invoke the operation and iterate over the result - await foreach (NotificationRegistrationResource item in collection.GetAllAsync()) + // invoke the operation + string notificationRegistrationName = "fooNotificationRegistration"; + NullableResponse response = await collection.GetIfExistsAsync(notificationRegistrationName); + NotificationRegistrationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NotificationRegistrationData resourceData = item.Data; + NotificationRegistrationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NotificationRegistrationResource.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NotificationRegistrationResource.cs index dd46744be3041..80888b3c3de2c 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NotificationRegistrationResource.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_NotificationRegistrationResource.cs @@ -48,10 +48,10 @@ public async Task Get_NotificationRegistrationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NotificationRegistrationsCreateOrUpdate() + public async Task Delete_NotificationRegistrationsDelete() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_CreateOrUpdate.json - // this example is just showing the usage of "NotificationRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_Delete.json + // this example is just showing the usage of "NotificationRegistrations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,52 +67,17 @@ public async Task Update_NotificationRegistrationsCreateOrUpdate() NotificationRegistrationResource notificationRegistration = client.GetNotificationRegistrationResource(notificationRegistrationResourceId); // invoke the operation - NotificationRegistrationData data = new NotificationRegistrationData() - { - Properties = new NotificationRegistrationProperties() - { - NotificationMode = NotificationMode.EventHub, - MessageScope = MessageScope.RegisteredSubscriptions, - IncludedEvents = -{ -"*/write","Microsoft.Contoso/employees/delete" -}, - NotificationEndpoints = -{ -new NotificationEndpoint() -{ -NotificationDestination = new ResourceIdentifier("/subscriptions/ac6bcfb5-3dc1-491f-95a6-646b89bf3e88/resourceGroups/mgmtexp-eastus/providers/Microsoft.EventHub/namespaces/unitedstates-mgmtexpint/eventhubs/armlinkednotifications"), -Locations = -{ -new AzureLocation(""),new AzureLocation("East US") -}, -},new NotificationEndpoint() -{ -NotificationDestination = new ResourceIdentifier("/subscriptions/ac6bcfb5-3dc1-491f-95a6-646b89bf3e88/resourceGroups/mgmtexp-northeurope/providers/Microsoft.EventHub/namespaces/europe-mgmtexpint/eventhubs/armlinkednotifications"), -Locations = -{ -new AzureLocation("North Europe") -}, -} -}, - }, - }; - ArmOperation lro = await notificationRegistration.UpdateAsync(WaitUntil.Completed, data); - NotificationRegistrationResource result = lro.Value; + await notificationRegistration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NotificationRegistrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NotificationRegistrationsDelete() + public async Task Update_NotificationRegistrationsCreateOrUpdate() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_Delete.json - // this example is just showing the usage of "NotificationRegistrations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/NotificationRegistrations_CreateOrUpdate.json + // this example is just showing the usage of "NotificationRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -128,9 +93,32 @@ public async Task Delete_NotificationRegistrationsDelete() NotificationRegistrationResource notificationRegistration = client.GetNotificationRegistrationResource(notificationRegistrationResourceId); // invoke the operation - await notificationRegistration.DeleteAsync(WaitUntil.Completed); + NotificationRegistrationData data = new NotificationRegistrationData + { + Properties = new NotificationRegistrationProperties + { + NotificationMode = NotificationMode.EventHub, + MessageScope = MessageScope.RegisteredSubscriptions, + IncludedEvents = { "*/write", "Microsoft.Contoso/employees/delete" }, + NotificationEndpoints = {new NotificationEndpoint +{ +NotificationDestination = new ResourceIdentifier("/subscriptions/ac6bcfb5-3dc1-491f-95a6-646b89bf3e88/resourceGroups/mgmtexp-eastus/providers/Microsoft.EventHub/namespaces/unitedstates-mgmtexpint/eventhubs/armlinkednotifications"), +Locations = {new AzureLocation(""), new AzureLocation("East US")}, +}, new NotificationEndpoint +{ +NotificationDestination = new ResourceIdentifier("/subscriptions/ac6bcfb5-3dc1-491f-95a6-646b89bf3e88/resourceGroups/mgmtexp-northeurope/providers/Microsoft.EventHub/namespaces/europe-mgmtexpint/eventhubs/armlinkednotifications"), +Locations = {new AzureLocation("North Europe")}, +}}, + }, + }; + ArmOperation lro = await notificationRegistration.UpdateAsync(WaitUntil.Completed, data); + NotificationRegistrationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NotificationRegistrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ProviderRegistrationCollection.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ProviderRegistrationCollection.cs index 29cafebd79077..a64945bc83edc 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ProviderRegistrationCollection.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ProviderRegistrationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ProviderRegistrationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProviderRegistrationsGet() + public async Task CreateOrUpdate_ProviderRegistrationsCreateOrUpdate() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_Get.json - // this example is just showing the usage of "ProviderRegistrations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_CreateOrUpdate.json + // this example is just showing the usage of "ProviderRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,23 @@ public async Task Get_ProviderRegistrationsGet() // invoke the operation string providerNamespace = "Microsoft.Contoso"; - ProviderRegistrationResource result = await collection.GetAsync(providerNamespace); + ProviderRegistrationData data = new ProviderRegistrationData + { + Properties = new ProviderRegistrationProperties + { + ProviderVersion = "2.0", + ProviderType = ResourceProviderType.Internal, + Management = new ResourceProviderManagement + { + IncidentRoutingService = "Contoso Resource Provider", + IncidentRoutingTeam = "Contoso Triage", + IncidentContactEmail = "helpme@contoso.com", + }, + Capabilities = { new ResourceProviderCapabilities("CSP_2015-05-01", ResourceProviderCapabilitiesEffect.Allow), new ResourceProviderCapabilities("CSP_MG_2017-12-01", ResourceProviderCapabilitiesEffect.Allow) }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerNamespace, data); + ProviderRegistrationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +67,7 @@ public async Task Get_ProviderRegistrationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProviderRegistrationsGet() + public async Task Get_ProviderRegistrationsGet() { // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_Get.json // this example is just showing the usage of "ProviderRegistrations_Get" operation, for the dependent resources, they will have to be created separately. @@ -72,17 +88,21 @@ public async Task Exists_ProviderRegistrationsGet() // invoke the operation string providerNamespace = "Microsoft.Contoso"; - bool result = await collection.ExistsAsync(providerNamespace); + ProviderRegistrationResource result = await collection.GetAsync(providerNamespace); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProviderRegistrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProviderRegistrationsGet() + public async Task GetAll_ProviderRegistrationsList() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_Get.json - // this example is just showing the usage of "ProviderRegistrations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_List.json + // this example is just showing the usage of "ProviderRegistrations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,31 +118,25 @@ public async Task GetIfExists_ProviderRegistrationsGet() // get the collection of this ProviderRegistrationResource ProviderRegistrationCollection collection = subscriptionResource.GetProviderRegistrations(); - // invoke the operation - string providerNamespace = "Microsoft.Contoso"; - NullableResponse response = await collection.GetIfExistsAsync(providerNamespace); - ProviderRegistrationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ProviderRegistrationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ProviderRegistrationData resourceData = result.Data; + ProviderRegistrationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProviderRegistrationsCreateOrUpdate() + public async Task Exists_ProviderRegistrationsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_CreateOrUpdate.json - // this example is just showing the usage of "ProviderRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_Get.json + // this example is just showing the usage of "ProviderRegistrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,40 +154,17 @@ public async Task CreateOrUpdate_ProviderRegistrationsCreateOrUpdate() // invoke the operation string providerNamespace = "Microsoft.Contoso"; - ProviderRegistrationData data = new ProviderRegistrationData() - { - Properties = new ProviderRegistrationProperties() - { - ProviderVersion = "2.0", - ProviderType = ResourceProviderType.Internal, - Management = new ResourceProviderManagement() - { - IncidentRoutingService = "Contoso Resource Provider", - IncidentRoutingTeam = "Contoso Triage", - IncidentContactEmail = "helpme@contoso.com", - }, - Capabilities = -{ -new ResourceProviderCapabilities("CSP_2015-05-01",ResourceProviderCapabilitiesEffect.Allow),new ResourceProviderCapabilities("CSP_MG_2017-12-01",ResourceProviderCapabilitiesEffect.Allow) -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerNamespace, data); - ProviderRegistrationResource result = lro.Value; + bool result = await collection.ExistsAsync(providerNamespace); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProviderRegistrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProviderRegistrationsList() + public async Task GetIfExists_ProviderRegistrationsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_List.json - // this example is just showing the usage of "ProviderRegistrations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_Get.json + // this example is just showing the usage of "ProviderRegistrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +180,23 @@ public async Task GetAll_ProviderRegistrationsList() // get the collection of this ProviderRegistrationResource ProviderRegistrationCollection collection = subscriptionResource.GetProviderRegistrations(); - // invoke the operation and iterate over the result - await foreach (ProviderRegistrationResource item in collection.GetAllAsync()) + // invoke the operation + string providerNamespace = "Microsoft.Contoso"; + NullableResponse response = await collection.GetIfExistsAsync(providerNamespace); + ProviderRegistrationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ProviderRegistrationData resourceData = item.Data; + ProviderRegistrationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ProviderRegistrationResource.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ProviderRegistrationResource.cs index 55dda942b44bf..ce4a25f02d5a8 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ProviderRegistrationResource.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ProviderRegistrationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ProviderRegistrationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GenerateManifest_GenerateManifest() + public async Task Get_ProviderRegistrationsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/GenerateManifest.json - // this example is just showing the usage of "GenerateManifest" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_Get.json + // this example is just showing the usage of "ProviderRegistrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,17 +36,21 @@ public async Task GenerateManifest_GenerateManifest() ProviderRegistrationResource providerRegistration = client.GetProviderRegistrationResource(providerRegistrationResourceId); // invoke the operation - ResourceProviderManifest result = await providerRegistration.GenerateManifestAsync(); + ProviderRegistrationResource result = await providerRegistration.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProviderRegistrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CheckinManifest_CheckinManifest() + public async Task Delete_ProviderRegistrationsDelete() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CheckinManifest.json - // this example is just showing the usage of "CheckinManifest" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_Delete.json + // this example is just showing the usage of "ProviderRegistrations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,18 +65,17 @@ public async Task CheckinManifest_CheckinManifest() ProviderRegistrationResource providerRegistration = client.GetProviderRegistrationResource(providerRegistrationResourceId); // invoke the operation - CheckinManifestContent content = new CheckinManifestContent("Prod", new AzureLocation("EastUS2EUAP")); - CheckinManifestInfo result = await providerRegistration.CheckinManifestAsync(content); + await providerRegistration.DeleteAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProviderRegistrationsGet() + public async Task Update_ProviderRegistrationsCreateOrUpdate() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_Get.json - // this example is just showing the usage of "ProviderRegistrations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_CreateOrUpdate.json + // this example is just showing the usage of "ProviderRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -87,7 +90,23 @@ public async Task Get_ProviderRegistrationsGet() ProviderRegistrationResource providerRegistration = client.GetProviderRegistrationResource(providerRegistrationResourceId); // invoke the operation - ProviderRegistrationResource result = await providerRegistration.GetAsync(); + ProviderRegistrationData data = new ProviderRegistrationData + { + Properties = new ProviderRegistrationProperties + { + ProviderVersion = "2.0", + ProviderType = ResourceProviderType.Internal, + Management = new ResourceProviderManagement + { + IncidentRoutingService = "Contoso Resource Provider", + IncidentRoutingTeam = "Contoso Triage", + IncidentContactEmail = "helpme@contoso.com", + }, + Capabilities = { new ResourceProviderCapabilities("CSP_2015-05-01", ResourceProviderCapabilitiesEffect.Allow), new ResourceProviderCapabilities("CSP_MG_2017-12-01", ResourceProviderCapabilitiesEffect.Allow) }, + }, + }; + ArmOperation lro = await providerRegistration.UpdateAsync(WaitUntil.Completed, data); + ProviderRegistrationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -98,10 +117,10 @@ public async Task Get_ProviderRegistrationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ProviderRegistrationsCreateOrUpdate() + public async Task GenerateManifest_GenerateManifest() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_CreateOrUpdate.json - // this example is just showing the usage of "ProviderRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/GenerateManifest.json + // this example is just showing the usage of "GenerateManifest" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,40 +135,17 @@ public async Task Update_ProviderRegistrationsCreateOrUpdate() ProviderRegistrationResource providerRegistration = client.GetProviderRegistrationResource(providerRegistrationResourceId); // invoke the operation - ProviderRegistrationData data = new ProviderRegistrationData() - { - Properties = new ProviderRegistrationProperties() - { - ProviderVersion = "2.0", - ProviderType = ResourceProviderType.Internal, - Management = new ResourceProviderManagement() - { - IncidentRoutingService = "Contoso Resource Provider", - IncidentRoutingTeam = "Contoso Triage", - IncidentContactEmail = "helpme@contoso.com", - }, - Capabilities = -{ -new ResourceProviderCapabilities("CSP_2015-05-01",ResourceProviderCapabilitiesEffect.Allow),new ResourceProviderCapabilities("CSP_MG_2017-12-01",ResourceProviderCapabilitiesEffect.Allow) -}, - }, - }; - ArmOperation lro = await providerRegistration.UpdateAsync(WaitUntil.Completed, data); - ProviderRegistrationResource result = lro.Value; + ResourceProviderManifest result = await providerRegistration.GenerateManifestAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProviderRegistrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ProviderRegistrationsDelete() + public async Task CheckinManifest_CheckinManifest() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ProviderRegistrations_Delete.json - // this example is just showing the usage of "ProviderRegistrations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/CheckinManifest.json + // this example is just showing the usage of "CheckinManifest" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -164,9 +160,10 @@ public async Task Delete_ProviderRegistrationsDelete() ProviderRegistrationResource providerRegistration = client.GetProviderRegistrationResource(providerRegistrationResourceId); // invoke the operation - await providerRegistration.DeleteAsync(WaitUntil.Completed); + CheckinManifestContent content = new CheckinManifestContent("Prod", new AzureLocation("EastUS2EUAP")); + CheckinManifestInfo result = await providerRegistration.CheckinManifestAsync(content); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeRegistrationCollection.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeRegistrationCollection.cs index 0d00479bf38cf..e062bc99ae648 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeRegistrationCollection.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeRegistrationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ResourceTypeRegistrationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ResourceTypeRegistrationsGet() + public async Task CreateOrUpdate_ResourceTypeRegistrationsCreateOrUpdate() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_Get.json - // this example is just showing the usage of "ResourceTypeRegistrations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_CreateOrUpdate.json + // this example is just showing the usage of "ResourceTypeRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,27 @@ public async Task Get_ResourceTypeRegistrationsGet() // invoke the operation string resourceType = "employees"; - ResourceTypeRegistrationResource result = await collection.GetAsync(resourceType); + ResourceTypeRegistrationData data = new ResourceTypeRegistrationData + { + Properties = new ResourceTypeRegistrationProperties + { + RoutingType = ResourceRoutingType.Default, + Regionality = ResourceTypeRegistrationRegionality.Regional, + Endpoints = {new ResourceTypeEndpoint +{ +ApiVersions = {"2020-06-01-preview"}, +Locations = {new AzureLocation("West US"), new AzureLocation("East US"), new AzureLocation("North Europe")}, +RequiredFeatures = {""}, +}}, + SwaggerSpecifications = {new SwaggerSpecification +{ +ApiVersions = {"2020-06-01-preview"}, +SwaggerSpecFolderUri = new Uri("https://github.com/Azure/azure-rest-api-specs/blob/feature/azure/contoso/specification/contoso/resource-manager/Microsoft.SampleRP/"), +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceType, data); + ResourceTypeRegistrationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +71,7 @@ public async Task Get_ResourceTypeRegistrationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ResourceTypeRegistrationsGet() + public async Task Get_ResourceTypeRegistrationsGet() { // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_Get.json // this example is just showing the usage of "ResourceTypeRegistrations_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +93,21 @@ public async Task Exists_ResourceTypeRegistrationsGet() // invoke the operation string resourceType = "employees"; - bool result = await collection.ExistsAsync(resourceType); + ResourceTypeRegistrationResource result = await collection.GetAsync(resourceType); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceTypeRegistrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ResourceTypeRegistrationsGet() + public async Task GetAll_ResourceTypeRegistrationsListByProviderRegistration() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_Get.json - // this example is just showing the usage of "ResourceTypeRegistrations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_ListByProviderRegistration.json + // this example is just showing the usage of "ResourceTypeRegistrations_ListByProviderRegistration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +124,25 @@ public async Task GetIfExists_ResourceTypeRegistrationsGet() // get the collection of this ResourceTypeRegistrationResource ResourceTypeRegistrationCollection collection = providerRegistration.GetResourceTypeRegistrations(); - // invoke the operation - string resourceType = "employees"; - NullableResponse response = await collection.GetIfExistsAsync(resourceType); - ResourceTypeRegistrationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ResourceTypeRegistrationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ResourceTypeRegistrationData resourceData = result.Data; + ResourceTypeRegistrationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ResourceTypeRegistrationsCreateOrUpdate() + public async Task Exists_ResourceTypeRegistrationsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_CreateOrUpdate.json - // this example is just showing the usage of "ResourceTypeRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_Get.json + // this example is just showing the usage of "ResourceTypeRegistrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,59 +161,17 @@ public async Task CreateOrUpdate_ResourceTypeRegistrationsCreateOrUpdate() // invoke the operation string resourceType = "employees"; - ResourceTypeRegistrationData data = new ResourceTypeRegistrationData() - { - Properties = new ResourceTypeRegistrationProperties() - { - RoutingType = ResourceRoutingType.Default, - Regionality = ResourceTypeRegistrationRegionality.Regional, - Endpoints = -{ -new ResourceTypeEndpoint() -{ -ApiVersions = -{ -"2020-06-01-preview" -}, -Locations = -{ -new AzureLocation("West US"),new AzureLocation("East US"),new AzureLocation("North Europe") -}, -RequiredFeatures = -{ -"" -}, -} -}, - SwaggerSpecifications = -{ -new SwaggerSpecification() -{ -ApiVersions = -{ -"2020-06-01-preview" -}, -SwaggerSpecFolderUri = new Uri("https://github.com/Azure/azure-rest-api-specs/blob/feature/azure/contoso/specification/contoso/resource-manager/Microsoft.SampleRP/"), -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceType, data); - ResourceTypeRegistrationResource result = lro.Value; + bool result = await collection.ExistsAsync(resourceType); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceTypeRegistrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ResourceTypeRegistrationsListByProviderRegistration() + public async Task GetIfExists_ResourceTypeRegistrationsGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_ListByProviderRegistration.json - // this example is just showing the usage of "ResourceTypeRegistrations_ListByProviderRegistration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_Get.json + // this example is just showing the usage of "ResourceTypeRegistrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -212,17 +188,23 @@ public async Task GetAll_ResourceTypeRegistrationsListByProviderRegistration() // get the collection of this ResourceTypeRegistrationResource ResourceTypeRegistrationCollection collection = providerRegistration.GetResourceTypeRegistrations(); - // invoke the operation and iterate over the result - await foreach (ResourceTypeRegistrationResource item in collection.GetAllAsync()) + // invoke the operation + string resourceType = "employees"; + NullableResponse response = await collection.GetIfExistsAsync(resourceType); + ResourceTypeRegistrationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ResourceTypeRegistrationData resourceData = item.Data; + ResourceTypeRegistrationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeRegistrationResource.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeRegistrationResource.cs index 445c59dd81b97..f4af002a9de78 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeRegistrationResource.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeRegistrationResource.cs @@ -48,10 +48,10 @@ public async Task Get_ResourceTypeRegistrationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ResourceTypeRegistrationsCreateOrUpdate() + public async Task Delete_ResourceTypeRegistrationsDelete() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_CreateOrUpdate.json - // this example is just showing the usage of "ResourceTypeRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_Delete.json + // this example is just showing the usage of "ResourceTypeRegistrations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,64 +62,22 @@ public async Task Update_ResourceTypeRegistrationsCreateOrUpdate() // for more information of creating ResourceTypeRegistrationResource, please refer to the document of ResourceTypeRegistrationResource string subscriptionId = "ab7a8701-f7ef-471a-a2f4-d0ebbf494f77"; string providerNamespace = "Microsoft.Contoso"; - string resourceType = "employees"; + string resourceType = "testResourceType"; ResourceIdentifier resourceTypeRegistrationResourceId = ResourceTypeRegistrationResource.CreateResourceIdentifier(subscriptionId, providerNamespace, resourceType); ResourceTypeRegistrationResource resourceTypeRegistration = client.GetResourceTypeRegistrationResource(resourceTypeRegistrationResourceId); // invoke the operation - ResourceTypeRegistrationData data = new ResourceTypeRegistrationData() - { - Properties = new ResourceTypeRegistrationProperties() - { - RoutingType = ResourceRoutingType.Default, - Regionality = ResourceTypeRegistrationRegionality.Regional, - Endpoints = -{ -new ResourceTypeEndpoint() -{ -ApiVersions = -{ -"2020-06-01-preview" -}, -Locations = -{ -new AzureLocation("West US"),new AzureLocation("East US"),new AzureLocation("North Europe") -}, -RequiredFeatures = -{ -"" -}, -} -}, - SwaggerSpecifications = -{ -new SwaggerSpecification() -{ -ApiVersions = -{ -"2020-06-01-preview" -}, -SwaggerSpecFolderUri = new Uri("https://github.com/Azure/azure-rest-api-specs/blob/feature/azure/contoso/specification/contoso/resource-manager/Microsoft.SampleRP/"), -} -}, - }, - }; - ArmOperation lro = await resourceTypeRegistration.UpdateAsync(WaitUntil.Completed, data); - ResourceTypeRegistrationResource result = lro.Value; + await resourceTypeRegistration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceTypeRegistrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ResourceTypeRegistrationsDelete() + public async Task Update_ResourceTypeRegistrationsCreateOrUpdate() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_Delete.json - // this example is just showing the usage of "ResourceTypeRegistrations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/ResourceTypeRegistrations_CreateOrUpdate.json + // this example is just showing the usage of "ResourceTypeRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,14 +88,38 @@ public async Task Delete_ResourceTypeRegistrationsDelete() // for more information of creating ResourceTypeRegistrationResource, please refer to the document of ResourceTypeRegistrationResource string subscriptionId = "ab7a8701-f7ef-471a-a2f4-d0ebbf494f77"; string providerNamespace = "Microsoft.Contoso"; - string resourceType = "testResourceType"; + string resourceType = "employees"; ResourceIdentifier resourceTypeRegistrationResourceId = ResourceTypeRegistrationResource.CreateResourceIdentifier(subscriptionId, providerNamespace, resourceType); ResourceTypeRegistrationResource resourceTypeRegistration = client.GetResourceTypeRegistrationResource(resourceTypeRegistrationResourceId); // invoke the operation - await resourceTypeRegistration.DeleteAsync(WaitUntil.Completed); + ResourceTypeRegistrationData data = new ResourceTypeRegistrationData + { + Properties = new ResourceTypeRegistrationProperties + { + RoutingType = ResourceRoutingType.Default, + Regionality = ResourceTypeRegistrationRegionality.Regional, + Endpoints = {new ResourceTypeEndpoint +{ +ApiVersions = {"2020-06-01-preview"}, +Locations = {new AzureLocation("West US"), new AzureLocation("East US"), new AzureLocation("North Europe")}, +RequiredFeatures = {""}, +}}, + SwaggerSpecifications = {new SwaggerSpecification +{ +ApiVersions = {"2020-06-01-preview"}, +SwaggerSpecFolderUri = new Uri("https://github.com/Azure/azure-rest-api-specs/blob/feature/azure/contoso/specification/contoso/resource-manager/Microsoft.SampleRP/"), +}}, + }, + }; + ArmOperation lro = await resourceTypeRegistration.UpdateAsync(WaitUntil.Completed, data); + ResourceTypeRegistrationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceTypeRegistrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeSkuCollection.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeSkuCollection.cs index 297531f10acf7..0cd372c21ecf4 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeSkuCollection.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeSkuCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ResourceTypeSkuCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SkusGet() + public async Task CreateOrUpdate_SkusCreateOrUpdate() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_Get.json - // this example is just showing the usage of "Skus_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdate.json + // this example is just showing the usage of "Skus_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,25 @@ public async Task Get_SkusGet() // invoke the operation string sku = "testSku"; - ResourceTypeSkuResource result = await collection.GetAsync(sku); + ResourceTypeSkuData data = new ResourceTypeSkuData + { + Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] + { +new ResourceTypeSkuSetting("freeSku") +{ +Tier = "Tier1", +Kind = "Standard", +}, +new ResourceTypeSkuSetting("premiumSku") +{ +Tier = "Tier2", +Kind = "Premium", +Costs = {new ResourceTypeSkuCost("xxx")}, +} + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sku, data); + ResourceTypeSkuResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +70,7 @@ public async Task Get_SkusGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SkusGet() + public async Task Get_SkusGet() { // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_Get.json // this example is just showing the usage of "Skus_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +93,21 @@ public async Task Exists_SkusGet() // invoke the operation string sku = "testSku"; - bool result = await collection.ExistsAsync(sku); + ResourceTypeSkuResource result = await collection.GetAsync(sku); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceTypeSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SkusGet() + public async Task GetAll_SkusListByResourceTypeRegistrations() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_Get.json - // this example is just showing the usage of "Skus_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_ListByResourceTypeRegistrations.json + // this example is just showing the usage of "Skus_ListByResourceTypeRegistrations" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +125,25 @@ public async Task GetIfExists_SkusGet() // get the collection of this ResourceTypeSkuResource ResourceTypeSkuCollection collection = resourceTypeRegistration.GetResourceTypeSkus(); - // invoke the operation - string sku = "testSku"; - NullableResponse response = await collection.GetIfExistsAsync(sku); - ResourceTypeSkuResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ResourceTypeSkuResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; + ResourceTypeSkuData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SkusCreateOrUpdate() + public async Task Exists_SkusGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_CreateOrUpdate.json - // this example is just showing the usage of "Skus_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_Get.json + // this example is just showing the usage of "Skus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,41 +163,17 @@ public async Task CreateOrUpdate_SkusCreateOrUpdate() // invoke the operation string sku = "testSku"; - ResourceTypeSkuData data = new ResourceTypeSkuData() - { - Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] - { -new ResourceTypeSkuSetting("freeSku") -{ -Tier = "Tier1", -Kind = "Standard", -},new ResourceTypeSkuSetting("premiumSku") -{ -Tier = "Tier2", -Kind = "Premium", -Costs = -{ -new ResourceTypeSkuCost("xxx") -}, -} - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sku, data); - ResourceTypeSkuResource result = lro.Value; + bool result = await collection.ExistsAsync(sku); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SkusListByResourceTypeRegistrations() + public async Task GetIfExists_SkusGet() { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_ListByResourceTypeRegistrations.json - // this example is just showing the usage of "Skus_ListByResourceTypeRegistrations" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_Get.json + // this example is just showing the usage of "Skus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,17 +191,23 @@ public async Task GetAll_SkusListByResourceTypeRegistrations() // get the collection of this ResourceTypeSkuResource ResourceTypeSkuCollection collection = resourceTypeRegistration.GetResourceTypeSkus(); - // invoke the operation and iterate over the result - await foreach (ResourceTypeSkuResource item in collection.GetAllAsync()) + // invoke the operation + string sku = "testSku"; + NullableResponse response = await collection.GetIfExistsAsync(sku); + ResourceTypeSkuResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ResourceTypeSkuData resourceData = item.Data; + ResourceTypeSkuData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeSkuResource.cs b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeSkuResource.cs index b8240dab390f7..44c40a4258727 100644 --- a/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeSkuResource.cs +++ b/sdk/providerhub/Azure.ResourceManager.ProviderHub/samples/Generated/Samples/Sample_ResourceTypeSkuResource.cs @@ -47,6 +47,33 @@ public async Task Get_SkusGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_SkusDelete() + { + // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_Delete.json + // this example is just showing the usage of "Skus_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceTypeSkuResource created on azure + // for more information of creating ResourceTypeSkuResource, please refer to the document of ResourceTypeSkuResource + string subscriptionId = "ab7a8701-f7ef-471a-a2f4-d0ebbf494f77"; + string providerNamespace = "Microsoft.Contoso"; + string resourceType = "testResourceType"; + string sku = "testSku"; + ResourceIdentifier resourceTypeSkuResourceId = ResourceTypeSkuResource.CreateResourceIdentifier(subscriptionId, providerNamespace, resourceType, sku); + ResourceTypeSkuResource resourceTypeSku = client.GetResourceTypeSkuResource(resourceTypeSkuResourceId); + + // invoke the operation + await resourceTypeSku.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_SkusCreateOrUpdate() @@ -69,7 +96,7 @@ public async Task Update_SkusCreateOrUpdate() ResourceTypeSkuResource resourceTypeSku = client.GetResourceTypeSkuResource(resourceTypeSkuResourceId); // invoke the operation - ResourceTypeSkuData data = new ResourceTypeSkuData() + ResourceTypeSkuData data = new ResourceTypeSkuData { Properties = new ResourceTypeSkuProperties(new ResourceTypeSkuSetting[] { @@ -77,14 +104,12 @@ public async Task Update_SkusCreateOrUpdate() { Tier = "Tier1", Kind = "Standard", -},new ResourceTypeSkuSetting("premiumSku") +}, +new ResourceTypeSkuSetting("premiumSku") { Tier = "Tier2", Kind = "Premium", -Costs = -{ -new ResourceTypeSkuCost("xxx") -}, +Costs = {new ResourceTypeSkuCost("xxx")}, } }), }; @@ -97,32 +122,5 @@ public async Task Update_SkusCreateOrUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_SkusDelete() - { - // Generated from example definition: specification/providerhub/resource-manager/Microsoft.ProviderHub/stable/2020-11-20/examples/Skus_Delete.json - // this example is just showing the usage of "Skus_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceTypeSkuResource created on azure - // for more information of creating ResourceTypeSkuResource, please refer to the document of ResourceTypeSkuResource - string subscriptionId = "ab7a8701-f7ef-471a-a2f4-d0ebbf494f77"; - string providerNamespace = "Microsoft.Contoso"; - string resourceType = "testResourceType"; - string sku = "testSku"; - ResourceIdentifier resourceTypeSkuResourceId = ResourceTypeSkuResource.CreateResourceIdentifier(subscriptionId, providerNamespace, resourceType, sku); - ResourceTypeSkuResource resourceTypeSku = client.GetResourceTypeSkuResource(resourceTypeSkuResourceId); - - // invoke the operation - await resourceTypeSku.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } From 021884fc3fa92a199d1cc5b3e1ba99fe84a0671c Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 03:53:49 +0000 Subject: [PATCH 04/11] Update SDK code de_ex_3 --- ...ple_DeviceProvisioningServiceCollection.cs | 106 +- ...ample_DeviceProvisioningServiceResource.cs | 99 +- ...ovisioningServicesCertificateCollection.cs | 96 +- ...ProvisioningServicesCertificateResource.cs | 57 +- ...icesPrivateEndpointConnectionCollection.cs | 92 +- ...rvicesPrivateEndpointConnectionResource.cs | 18 +- ...ngServicesPrivateLinkResourceCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 76 + .../Sample_DeviceRegistryAssetCollection.cs | 462 +++-- ...eRegistryAssetEndpointProfileCollection.cs | 106 +- ...iceRegistryAssetEndpointProfileResource.cs | 70 +- .../Sample_DeviceRegistryAssetResource.cs | 72 +- .../Sample_SubscriptionResourceExtensions.cs | 81 + .../Sample_DeviceUpdateAccountCollection.cs | 118 +- .../Sample_DeviceUpdateAccountResource.cs | 36 +- .../Sample_DeviceUpdateInstanceCollection.cs | 109 +- .../Sample_DeviceUpdateInstanceResource.cs | 4 +- ...datePrivateEndpointConnectionCollection.cs | 98 +- ...rivateEndpointConnectionProxyCollection.cs | 141 +- ...ePrivateEndpointConnectionProxyResource.cs | 152 +- ...UpdatePrivateEndpointConnectionResource.cs | 40 +- ...ample_DeviceUpdatePrivateLinkCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 35 +- .../Samples/Sample_DevOpsPoolCollection.cs | 114 +- .../Samples/Sample_DevOpsPoolResource.cs | 64 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Samples/Sample_ControllerCollection.cs | 98 +- .../Samples/Sample_ControllerResource.cs | 36 +- .../Sample_ResourceGroupResourceExtensions.cs | 2 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Sample_DevTestLabArmTemplateCollection.cs | 48 +- .../Sample_DevTestLabArtifactCollection.cs | 48 +- .../Sample_DevTestLabArtifactResource.cs | 2 +- ...mple_DevTestLabArtifactSourceCollection.cs | 118 +- ...Sample_DevTestLabArtifactSourceResource.cs | 4 +- .../Samples/Sample_DevTestLabCollection.cs | 104 +- .../Sample_DevTestLabCostCollection.cs | 157 +- .../Samples/Sample_DevTestLabCostResource.cs | 19 +- .../Sample_DevTestLabCustomImageCollection.cs | 114 +- .../Sample_DevTestLabCustomImageResource.cs | 4 +- .../Sample_DevTestLabDiskCollection.cs | 104 +- .../Samples/Sample_DevTestLabDiskResource.cs | 8 +- .../Sample_DevTestLabEnvironmentCollection.cs | 106 +- .../Sample_DevTestLabEnvironmentResource.cs | 4 +- .../Sample_DevTestLabFormulaCollection.cs | 172 +- .../Sample_DevTestLabFormulaResource.cs | 4 +- ...mple_DevTestLabGlobalScheduleCollection.cs | 113 +- ...Sample_DevTestLabGlobalScheduleResource.cs | 38 +- ...DevTestLabNotificationChannelCollection.cs | 113 +- ...e_DevTestLabNotificationChannelResource.cs | 2 +- .../Sample_DevTestLabPolicyCollection.cs | 114 +- .../Sample_DevTestLabPolicyResource.cs | 4 +- .../Samples/Sample_DevTestLabResource.cs | 53 +- .../Sample_DevTestLabScheduleCollection.cs | 159 +- .../Sample_DevTestLabScheduleResource.cs | 4 +- .../Sample_DevTestLabSecretCollection.cs | 96 +- .../Sample_DevTestLabSecretResource.cs | 4 +- ...ample_DevTestLabServiceFabricCollection.cs | 106 +- .../Sample_DevTestLabServiceFabricResource.cs | 4 +- ...vTestLabServiceFabricScheduleCollection.cs | 143 +- ...DevTestLabServiceFabricScheduleResource.cs | 4 +- ...ample_DevTestLabServiceRunnerCollection.cs | 92 +- .../Sample_DevTestLabServiceRunnerResource.cs | 58 +- .../Sample_DevTestLabUserCollection.cs | 128 +- .../Samples/Sample_DevTestLabUserResource.cs | 4 +- ...mple_DevTestLabVirtualNetworkCollection.cs | 102 +- ...Sample_DevTestLabVirtualNetworkResource.cs | 4 +- .../Samples/Sample_DevTestLabVmCollection.cs | 134 +- .../Samples/Sample_DevTestLabVmResource.cs | 17 +- .../Sample_DevTestLabVmScheduleCollection.cs | 143 +- .../Sample_DevTestLabVmScheduleResource.cs | 4 +- .../Sample_SubscriptionResourceExtensions.cs | 81 + ...ample_DigitalTwinsDescriptionCollection.cs | 260 +-- .../Sample_DigitalTwinsDescriptionResource.cs | 120 +- .../Sample_DigitalTwinsEndpointResource.cs | 86 +- ..._DigitalTwinsEndpointResourceCollection.cs | 268 +-- ...winsPrivateEndpointConnectionCollection.cs | 96 +- ...lTwinsPrivateEndpointConnectionResource.cs | 2 +- ...gitalTwinsPrivateLinkResourceCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 77 + ..._TimeSeriesDatabaseConnectionCollection.cs | 164 +- ...le_TimeSeriesDatabaseConnectionResource.cs | 68 +- .../Sample_EdgeOrderAddressCollection.cs | 119 +- .../Sample_EdgeOrderAddressResource.cs | 41 +- .../Samples/Sample_EdgeOrderItemCollection.cs | 153 +- .../Samples/Sample_EdgeOrderItemResource.cs | 43 +- .../Sample_SubscriptionResourceExtensions.cs | 81 +- .../Samples/Sample_ExtendedZoneCollection.cs | 48 +- .../Samples/Sample_ElasticMonitorResource.cs | 64 +- ...Sample_ElasticMonitorResourceCollection.cs | 92 +- ...MonitoredSubscriptionPropertyCollection.cs | 92 +- ...e_MonitoredSubscriptionPropertyResource.cs | 32 +- .../Sample_MonitoringTagRuleCollection.cs | 60 +- .../Sample_MonitoringTagRuleResource.cs | 40 +- ...mple_OpenAIIntegrationRPModelCollection.cs | 92 +- ...Sample_OpenAIIntegrationRPModelResource.cs | 32 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Samples/Sample_ElasticSanCollection.cs | 199 +- ...cSanPrivateEndpointConnectionCollection.cs | 137 +- ...ticSanPrivateEndpointConnectionResource.cs | 99 +- .../Samples/Sample_ElasticSanResource.cs | 135 +- .../Sample_ElasticSanSnapshotCollection.cs | 166 +- .../Sample_ElasticSanSnapshotResource.cs | 40 +- .../Sample_ElasticSanVolumeCollection.cs | 132 +- .../Sample_ElasticSanVolumeGroupCollection.cs | 209 ++- .../Sample_ElasticSanVolumeGroupResource.cs | 95 +- .../Sample_ElasticSanVolumeResource.cs | 46 +- .../Sample_SubscriptionResourceExtensions.cs | 62 + .../Samples/Sample_CaCertificateCollection.cs | 96 +- .../Samples/Sample_CaCertificateResource.cs | 40 +- ...ample_DomainEventSubscriptionCollection.cs | 112 +- .../Sample_DomainEventSubscriptionResource.cs | 71 +- ...ecurityPerimeterConfigurationCollection.cs | 62 +- .../Samples/Sample_DomainTopicCollection.cs | 90 +- ..._DomainTopicEventSubscriptionCollection.cs | 112 +- ...le_DomainTopicEventSubscriptionResource.cs | 73 +- .../Samples/Sample_DomainTopicResource.cs | 30 +- .../Sample_EventGridDomainCollection.cs | 125 +- ...mainPrivateEndpointConnectionCollection.cs | 100 +- ...DomainPrivateEndpointConnectionResource.cs | 48 +- ...GridDomainPrivateLinkResourceCollection.cs | 62 +- .../Samples/Sample_EventGridDomainResource.cs | 45 +- ...mple_EventGridNamespaceClientCollection.cs | 121 +- ...EventGridNamespaceClientGroupCollection.cs | 96 +- ...e_EventGridNamespaceClientGroupResource.cs | 40 +- ...Sample_EventGridNamespaceClientResource.cs | 65 +- .../Sample_EventGridNamespaceCollection.cs | 108 +- ...ridNamespacePermissionBindingCollection.cs | 98 +- ...tGridNamespacePermissionBindingResource.cs | 42 +- .../Sample_EventGridNamespaceResource.cs | 36 +- ...pacePrivateEndpointConnectionCollection.cs | 100 +- ...espacePrivateEndpointConnectionResource.cs | 48 +- .../Sample_EventGridTopicCollection.cs | 181 +- ...opicPrivateEndpointConnectionCollection.cs | 100 +- ...dTopicPrivateEndpointConnectionResource.cs | 48 +- ...tGridTopicPrivateLinkResourceCollection.cs | 62 +- .../Samples/Sample_EventGridTopicResource.cs | 45 +- .../Sample_EventSubscriptionCollection.cs | 1634 ++++++++--------- .../Sample_EventSubscriptionResource.cs | 168 +- .../Sample_NamespaceTopicCollection.cs | 102 +- ...mespaceTopicEventSubscriptionCollection.cs | 114 +- ...NamespaceTopicEventSubscriptionResource.cs | 6 +- .../Samples/Sample_NamespaceTopicResource.cs | 2 +- .../Sample_PartnerConfigurationResource.cs | 109 +- .../Sample_PartnerDestinationCollection.cs | 98 +- .../Sample_PartnerDestinationResource.cs | 36 +- ...ample_PartnerNamespaceChannelCollection.cs | 108 +- .../Sample_PartnerNamespaceChannelResource.cs | 2 +- .../Sample_PartnerNamespaceCollection.cs | 100 +- ...rNamespacePrivateLinkResourceCollection.cs | 62 +- .../Sample_PartnerNamespaceResource.cs | 36 +- .../Sample_PartnerRegistrationCollection.cs | 100 +- .../Sample_PartnerRegistrationResource.cs | 36 +- .../Samples/Sample_PartnerTopicCollection.cs | 98 +- ...PartnerTopicEventSubscriptionCollection.cs | 112 +- ...e_PartnerTopicEventSubscriptionResource.cs | 11 +- .../Samples/Sample_PartnerTopicResource.cs | 36 +- .../Sample_SubscriptionResourceExtensions.cs | 298 +++ .../Samples/Sample_SystemTopicCollection.cs | 106 +- ..._SystemTopicEventSubscriptionCollection.cs | 112 +- ...le_SystemTopicEventSubscriptionResource.cs | 71 +- .../Samples/Sample_SystemTopicResource.cs | 36 +- ...Sample_TopicEventSubscriptionCollection.cs | 112 +- .../Sample_TopicEventSubscriptionResource.cs | 71 +- ...ecurityPerimeterConfigurationCollection.cs | 62 +- .../Samples/Sample_TopicSpaceCollection.cs | 97 +- .../Samples/Sample_TopicSpaceResource.cs | 41 +- .../Samples/Sample_TopicTypeCollection.cs | 65 +- .../Sample_VerifiedPartnerCollection.cs | 75 +- ...ple_EventHubAuthorizationRuleCollection.cs | 67 +- ...ample_EventHubAuthorizationRuleResource.cs | 49 +- .../Samples/Sample_EventHubCollection.cs | 82 +- .../Samples/Sample_EventHubResource.cs | 92 +- ...ple_EventHubsApplicationGroupCollection.cs | 71 +- ...ample_EventHubsApplicationGroupResource.cs | 33 +- .../Sample_EventHubsClusterCollection.cs | 112 +- .../Sample_EventHubsClusterResource.cs | 107 +- ...Sample_EventHubsConsumerGroupCollection.cs | 64 +- .../Sample_EventHubsConsumerGroupResource.cs | 26 +- ...sterRecoveryAuthorizationRuleCollection.cs | 52 +- ...ple_EventHubsDisasterRecoveryCollection.cs | 64 +- ...ample_EventHubsDisasterRecoveryResource.cs | 26 +- ...ubsNamespaceAuthorizationRuleCollection.cs | 67 +- ...tHubsNamespaceAuthorizationRuleResource.cs | 29 +- .../Sample_EventHubsNamespaceCollection.cs | 81 +- .../Sample_EventHubsNamespaceResource.cs | 87 +- .../Sample_EventHubsNetworkRuleSetResource.cs | 88 +- ...HubsPrivateEndpointConnectionCollection.cs | 76 +- ...ntHubsPrivateEndpointConnectionResource.cs | 46 +- .../Sample_EventHubsSchemaGroupCollection.cs | 70 +- .../Sample_EventHubsSchemaGroupResource.cs | 32 +- .../Sample_SubscriptionResourceExtensions.cs | 134 ++ .../Sample_CustomLocationCollection.cs | 117 +- .../Samples/Sample_CustomLocationResource.cs | 41 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + 195 files changed, 8350 insertions(+), 8613 deletions(-) create mode 100644 sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServiceCollection.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServiceCollection.cs index 82b4212402af2..7941208790690 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServiceCollection.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServiceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DeviceProvisioningServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DPSGet() + public async Task CreateOrUpdate_DPSCreate() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGet.json - // this example is just showing the usage of "IotDpsResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreate.json + // this example is just showing the usage of "IotDpsResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,19 @@ public async Task Get_DPSGet() // invoke the operation string provisioningServiceName = "myFirstProvisioningService"; - DeviceProvisioningServiceResource result = await collection.GetAsync(provisioningServiceName); + DeviceProvisioningServiceData data = new DeviceProvisioningServiceData(new AzureLocation("East US"), new DeviceProvisioningServiceProperties + { + IsDataResidencyEnabled = false, + }, new DeviceProvisioningServicesSkuInfo + { + Name = DeviceProvisioningServicesSku.S1, + Capacity = 1L, + }) + { + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, provisioningServiceName, data); + DeviceProvisioningServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +64,7 @@ public async Task Get_DPSGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DPSGet() + public async Task Get_DPSGet() { // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGet.json // this example is just showing the usage of "IotDpsResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +86,21 @@ public async Task Exists_DPSGet() // invoke the operation string provisioningServiceName = "myFirstProvisioningService"; - bool result = await collection.ExistsAsync(provisioningServiceName); + DeviceProvisioningServiceResource result = await collection.GetAsync(provisioningServiceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceProvisioningServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DPSGet() + public async Task GetAll_DPSListByResourceGroup() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGet.json - // this example is just showing the usage of "IotDpsResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListByResourceGroup.json + // this example is just showing the usage of "IotDpsResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +117,25 @@ public async Task GetIfExists_DPSGet() // get the collection of this DeviceProvisioningServiceResource DeviceProvisioningServiceCollection collection = resourceGroupResource.GetDeviceProvisioningServices(); - // invoke the operation - string provisioningServiceName = "myFirstProvisioningService"; - NullableResponse response = await collection.GetIfExistsAsync(provisioningServiceName); - DeviceProvisioningServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DeviceProvisioningServiceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DeviceProvisioningServiceData resourceData = result.Data; + DeviceProvisioningServiceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DPSCreate() + public async Task Exists_DPSGet() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreate.json - // this example is just showing the usage of "IotDpsResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGet.json + // this example is just showing the usage of "IotDpsResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,35 +154,17 @@ public async Task CreateOrUpdate_DPSCreate() // invoke the operation string provisioningServiceName = "myFirstProvisioningService"; - DeviceProvisioningServiceData data = new DeviceProvisioningServiceData(new AzureLocation("East US"), new DeviceProvisioningServiceProperties() - { - IsDataResidencyEnabled = false, - }, new DeviceProvisioningServicesSkuInfo() - { - Name = DeviceProvisioningServicesSku.S1, - Capacity = 1L, - }) - { - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, provisioningServiceName, data); - DeviceProvisioningServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(provisioningServiceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceProvisioningServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DPSListByResourceGroup() + public async Task GetIfExists_DPSGet() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListByResourceGroup.json - // this example is just showing the usage of "IotDpsResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGet.json + // this example is just showing the usage of "IotDpsResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +181,23 @@ public async Task GetAll_DPSListByResourceGroup() // get the collection of this DeviceProvisioningServiceResource DeviceProvisioningServiceCollection collection = resourceGroupResource.GetDeviceProvisioningServices(); - // invoke the operation and iterate over the result - await foreach (DeviceProvisioningServiceResource item in collection.GetAllAsync()) + // invoke the operation + string provisioningServiceName = "myFirstProvisioningService"; + NullableResponse response = await collection.GetIfExistsAsync(provisioningServiceName); + DeviceProvisioningServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DeviceProvisioningServiceData resourceData = item.Data; + DeviceProvisioningServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServiceResource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServiceResource.cs index 52de0e089e507..de9df70f84871 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServiceResource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DeviceProvisioningServices.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DeviceProvisioningServices.Samples @@ -49,10 +48,10 @@ public async Task Get_DPSGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DPSPatch() + public async Task Delete_DPSDelete() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSPatch.json - // this example is just showing the usage of "IotDpsResource_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDelete.json + // this example is just showing the usage of "IotDpsResource_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_DPSPatch() DeviceProvisioningServiceResource deviceProvisioningService = client.GetDeviceProvisioningServiceResource(deviceProvisioningServiceResourceId); // invoke the operation - DeviceProvisioningServicePatch patch = new DeviceProvisioningServicePatch() - { - Tags = -{ -["foo"] = "bar", -}, - }; - ArmOperation lro = await deviceProvisioningService.UpdateAsync(WaitUntil.Completed, patch); - DeviceProvisioningServiceResource result = lro.Value; + await deviceProvisioningService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceProvisioningServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DPSDelete() + public async Task Update_DPSPatch() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDelete.json - // this example is just showing the usage of "IotDpsResource_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSPatch.json + // this example is just showing the usage of "IotDpsResource_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_DPSDelete() DeviceProvisioningServiceResource deviceProvisioningService = client.GetDeviceProvisioningServiceResource(deviceProvisioningServiceResourceId); // invoke the operation - await deviceProvisioningService.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeviceProvisioningServices_DPSListBySubscription() - { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListBySubscription.json - // this example is just showing the usage of "IotDpsResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeviceProvisioningServiceResource item in subscriptionResource.GetDeviceProvisioningServicesAsync()) + DeviceProvisioningServicePatch patch = new DeviceProvisioningServicePatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceProvisioningServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["foo"] = "bar" +}, + }; + ArmOperation lro = await deviceProvisioningService.UpdateAsync(WaitUntil.Completed, patch); + DeviceProvisioningServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceProvisioningServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -171,31 +139,6 @@ public async Task GetValidSkus_DPSGetValidSku() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckDeviceProvisioningServicesNameAvailability_DPSCheckName() - { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCheckNameAvailability.json - // this example is just showing the usage of "IotDpsResource_CheckProvisioningServiceNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - DeviceProvisioningServicesNameAvailabilityContent content = new DeviceProvisioningServicesNameAvailabilityContent("test213123"); - DeviceProvisioningServicesNameAvailabilityResult result = await subscriptionResource.CheckDeviceProvisioningServicesNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetKeys_DPSListKeys() diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesCertificateCollection.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesCertificateCollection.cs index 700fc54b17238..08c9225f6d353 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesCertificateCollection.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesCertificateCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DeviceProvisioningServicesCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DPSGetCertificate() + public async Task CreateOrUpdate_DPSCreateOrUpdateCertificate() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificate.json - // this example is just showing the usage of "DpsCertificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCertificateCreateOrUpdate.json + // this example is just showing the usage of "DpsCertificate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_DPSGetCertificate() // invoke the operation string certificateName = "cert"; - DeviceProvisioningServicesCertificateResource result = await collection.GetAsync(certificateName); + DeviceProvisioningServicesCertificateData data = new DeviceProvisioningServicesCertificateData + { + Properties = new DeviceProvisioningServicesCertificateProperties + { + Certificate = BinaryData.FromObjectAsJson("############################################"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); + DeviceProvisioningServicesCertificateResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_DPSGetCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DPSGetCertificate() + public async Task Get_DPSGetCertificate() { // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificate.json // this example is just showing the usage of "DpsCertificate_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +83,21 @@ public async Task Exists_DPSGetCertificate() // invoke the operation string certificateName = "cert"; - bool result = await collection.ExistsAsync(certificateName); + DeviceProvisioningServicesCertificateResource result = await collection.GetAsync(certificateName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceProvisioningServicesCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DPSGetCertificate() + public async Task GetAll_DPSGetCertificates() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificate.json - // this example is just showing the usage of "DpsCertificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificates.json + // this example is just showing the usage of "DpsCertificate_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +115,25 @@ public async Task GetIfExists_DPSGetCertificate() // get the collection of this DeviceProvisioningServicesCertificateResource DeviceProvisioningServicesCertificateCollection collection = deviceProvisioningService.GetDeviceProvisioningServicesCertificates(); - // invoke the operation - string certificateName = "cert"; - NullableResponse response = await collection.GetIfExistsAsync(certificateName); - DeviceProvisioningServicesCertificateResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DeviceProvisioningServicesCertificateResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DeviceProvisioningServicesCertificateData resourceData = result.Data; + DeviceProvisioningServicesCertificateData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DPSCreateOrUpdateCertificate() + public async Task Exists_DPSGetCertificate() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCertificateCreateOrUpdate.json - // this example is just showing the usage of "DpsCertificate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificate.json + // this example is just showing the usage of "DpsCertificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,29 +153,17 @@ public async Task CreateOrUpdate_DPSCreateOrUpdateCertificate() // invoke the operation string certificateName = "cert"; - DeviceProvisioningServicesCertificateData data = new DeviceProvisioningServicesCertificateData() - { - Properties = new DeviceProvisioningServicesCertificateProperties() - { - Certificate = BinaryData.FromString("\"############################################\""), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); - DeviceProvisioningServicesCertificateResource result = lro.Value; + bool result = await collection.ExistsAsync(certificateName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceProvisioningServicesCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DPSGetCertificates() + public async Task GetIfExists_DPSGetCertificate() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificates.json - // this example is just showing the usage of "DpsCertificate_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificate.json + // this example is just showing the usage of "DpsCertificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +181,23 @@ public async Task GetAll_DPSGetCertificates() // get the collection of this DeviceProvisioningServicesCertificateResource DeviceProvisioningServicesCertificateCollection collection = deviceProvisioningService.GetDeviceProvisioningServicesCertificates(); - // invoke the operation and iterate over the result - await foreach (DeviceProvisioningServicesCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string certificateName = "cert"; + NullableResponse response = await collection.GetIfExistsAsync(certificateName); + DeviceProvisioningServicesCertificateResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DeviceProvisioningServicesCertificateData resourceData = item.Data; + DeviceProvisioningServicesCertificateData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesCertificateResource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesCertificateResource.cs index 098f874c7b28c..f213c5d84a7ba 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesCertificateResource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesCertificateResource.cs @@ -49,10 +49,10 @@ public async Task Get_DPSGetCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DPSCreateOrUpdateCertificate() + public async Task Delete_DPSDeleteCertificate() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCertificateCreateOrUpdate.json - // this example is just showing the usage of "DpsCertificate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDeleteCertificate.json + // this example is just showing the usage of "DpsCertificate_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,19 @@ public async Task Update_DPSCreateOrUpdateCertificate() DeviceProvisioningServicesCertificateResource deviceProvisioningServicesCertificate = client.GetDeviceProvisioningServicesCertificateResource(deviceProvisioningServicesCertificateResourceId); // invoke the operation - DeviceProvisioningServicesCertificateData data = new DeviceProvisioningServicesCertificateData() - { - Properties = new DeviceProvisioningServicesCertificateProperties() - { - Certificate = BinaryData.FromString("\"############################################\""), - }, - }; - ArmOperation lro = await deviceProvisioningServicesCertificate.UpdateAsync(WaitUntil.Completed, data); - DeviceProvisioningServicesCertificateResource result = lro.Value; + string ifMatch = "AAAAAAAADGk="; + DeviceProvisioningServicesCertificateResourceDeleteOptions options = new DeviceProvisioningServicesCertificateResourceDeleteOptions(ifMatch); + await deviceProvisioningServicesCertificate.DeleteAsync(WaitUntil.Completed, options); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceProvisioningServicesCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DPSDeleteCertificate() + public async Task Update_DPSCreateOrUpdateCertificate() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDeleteCertificate.json - // this example is just showing the usage of "DpsCertificate_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCertificateCreateOrUpdate.json + // this example is just showing the usage of "DpsCertificate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,10 +98,21 @@ public async Task Delete_DPSDeleteCertificate() DeviceProvisioningServicesCertificateResource deviceProvisioningServicesCertificate = client.GetDeviceProvisioningServicesCertificateResource(deviceProvisioningServicesCertificateResourceId); // invoke the operation - DeviceProvisioningServicesCertificateResourceDeleteOptions options = new DeviceProvisioningServicesCertificateResourceDeleteOptions(ifMatch: "AAAAAAAADGk=") { }; - await deviceProvisioningServicesCertificate.DeleteAsync(WaitUntil.Completed, options); + DeviceProvisioningServicesCertificateData data = new DeviceProvisioningServicesCertificateData + { + Properties = new DeviceProvisioningServicesCertificateProperties + { + Certificate = BinaryData.FromObjectAsJson("############################################"), + }, + }; + ArmOperation lro = await deviceProvisioningServicesCertificate.UpdateAsync(WaitUntil.Completed, data); + DeviceProvisioningServicesCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceProvisioningServicesCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -136,7 +137,8 @@ public async Task GenerateVerificationCode_DPSGenerateVerificationCode() DeviceProvisioningServicesCertificateResource deviceProvisioningServicesCertificate = client.GetDeviceProvisioningServicesCertificateResource(deviceProvisioningServicesCertificateResourceId); // invoke the operation - DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions options = new DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions(ifMatch: "AAAAAAAADGk=") { }; + string ifMatch = "AAAAAAAADGk="; + DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions options = new DeviceProvisioningServicesCertificateResourceGenerateVerificationCodeOptions(ifMatch); CertificateVerificationCodeResult result = await deviceProvisioningServicesCertificate.GenerateVerificationCodeAsync(options); Console.WriteLine($"Succeeded: {result}"); @@ -164,11 +166,12 @@ public async Task VerifyCertificate_DPSVerifyCertificate() DeviceProvisioningServicesCertificateResource deviceProvisioningServicesCertificate = client.GetDeviceProvisioningServicesCertificateResource(deviceProvisioningServicesCertificateResourceId); // invoke the operation - DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions options = new DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions(ifMatch: "AAAAAAAADGk=", content: new CertificateVerificationCodeContent() + string ifMatch = "AAAAAAAADGk="; + CertificateVerificationCodeContent content = new CertificateVerificationCodeContent { Certificate = "#####################################", - }) - { }; + }; + DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions options = new DeviceProvisioningServicesCertificateResourceVerifyCertificateOptions(ifMatch, content); DeviceProvisioningServicesCertificateResource result = await deviceProvisioningServicesCertificate.VerifyCertificateAsync(options); // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateEndpointConnectionCollection.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateEndpointConnectionCollection.cs index 5bc41e9d14fa9..1a26016af9df9 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateEndpointConnectionCollection.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DeviceProvisioningServicesPrivateEndpointConnectionC { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsList() + public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListPrivateEndpointConnections.json - // this example is just showing the usage of "IotDpsResource_ListPrivateEndpointConnections" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreateOrUpdatePrivateEndpointConnection.json + // this example is just showing the usage of "IotDpsResource_CreateOrUpdatePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,17 @@ public async Task GetAll_PrivateEndpointConnectionsList() // get the collection of this DeviceProvisioningServicesPrivateEndpointConnectionResource DeviceProvisioningServicesPrivateEndpointConnectionCollection collection = deviceProvisioningService.GetDeviceProvisioningServicesPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (DeviceProvisioningServicesPrivateEndpointConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceProvisioningServicesPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateEndpointConnectionName = "myPrivateEndpointConnection"; + DeviceProvisioningServicesPrivateEndpointConnectionData data = new DeviceProvisioningServicesPrivateEndpointConnectionData(new DeviceProvisioningServicesPrivateEndpointConnectionProperties(new DeviceProvisioningServicesPrivateLinkServiceConnectionState(DeviceProvisioningServicesPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"))); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + DeviceProvisioningServicesPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceProvisioningServicesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +88,10 @@ public async Task Get_PrivateEndpointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionGet() + public async Task GetAll_PrivateEndpointConnectionsList() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetPrivateEndpointConnection.json - // this example is just showing the usage of "IotDpsResource_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListPrivateEndpointConnections.json + // this example is just showing the usage of "IotDpsResource_ListPrivateEndpointConnections" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_PrivateEndpointConnectionGet() // get the collection of this DeviceProvisioningServicesPrivateEndpointConnectionResource DeviceProvisioningServicesPrivateEndpointConnectionCollection collection = deviceProvisioningService.GetDeviceProvisioningServicesPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "myPrivateEndpointConnection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (DeviceProvisioningServicesPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceProvisioningServicesPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionGet() + public async Task Exists_PrivateEndpointConnectionGet() { // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetPrivateEndpointConnection.json // this example is just showing the usage of "IotDpsResource_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_PrivateEndpointConnectionGet() // invoke the operation string privateEndpointConnectionName = "myPrivateEndpointConnection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - DeviceProvisioningServicesPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceProvisioningServicesPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() + public async Task GetIfExists_PrivateEndpointConnectionGet() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreateOrUpdatePrivateEndpointConnection.json - // this example is just showing the usage of "IotDpsResource_CreateOrUpdatePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetPrivateEndpointConnection.json + // this example is just showing the usage of "IotDpsResource_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,15 +177,21 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() // invoke the operation string privateEndpointConnectionName = "myPrivateEndpointConnection"; - DeviceProvisioningServicesPrivateEndpointConnectionData data = new DeviceProvisioningServicesPrivateEndpointConnectionData(new DeviceProvisioningServicesPrivateEndpointConnectionProperties(new DeviceProvisioningServicesPrivateLinkServiceConnectionState(DeviceProvisioningServicesPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"))); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - DeviceProvisioningServicesPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + DeviceProvisioningServicesPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceProvisioningServicesPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceProvisioningServicesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateEndpointConnectionResource.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateEndpointConnectionResource.cs index e389b028d1c37..6aa044db5a8c9 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateEndpointConnectionResource.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionCreateOrUpdate() + public async Task Delete_PrivateEndpointConnectionDelete() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreateOrUpdatePrivateEndpointConnection.json - // this example is just showing the usage of "IotDpsResource_CreateOrUpdatePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDeletePrivateEndpointConnection.json + // this example is just showing the usage of "IotDpsResource_DeletePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,8 +69,7 @@ public async Task Update_PrivateEndpointConnectionCreateOrUpdate() DeviceProvisioningServicesPrivateEndpointConnectionResource deviceProvisioningServicesPrivateEndpointConnection = client.GetDeviceProvisioningServicesPrivateEndpointConnectionResource(deviceProvisioningServicesPrivateEndpointConnectionResourceId); // invoke the operation - DeviceProvisioningServicesPrivateEndpointConnectionData data = new DeviceProvisioningServicesPrivateEndpointConnectionData(new DeviceProvisioningServicesPrivateEndpointConnectionProperties(new DeviceProvisioningServicesPrivateLinkServiceConnectionState(DeviceProvisioningServicesPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"))); - ArmOperation lro = await deviceProvisioningServicesPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await deviceProvisioningServicesPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); DeviceProvisioningServicesPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -82,10 +81,10 @@ public async Task Update_PrivateEndpointConnectionCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionDelete() + public async Task Update_PrivateEndpointConnectionCreateOrUpdate() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDeletePrivateEndpointConnection.json - // this example is just showing the usage of "IotDpsResource_DeletePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreateOrUpdatePrivateEndpointConnection.json + // this example is just showing the usage of "IotDpsResource_CreateOrUpdatePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,7 +101,8 @@ public async Task Delete_PrivateEndpointConnectionDelete() DeviceProvisioningServicesPrivateEndpointConnectionResource deviceProvisioningServicesPrivateEndpointConnection = client.GetDeviceProvisioningServicesPrivateEndpointConnectionResource(deviceProvisioningServicesPrivateEndpointConnectionResourceId); // invoke the operation - ArmOperation lro = await deviceProvisioningServicesPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + DeviceProvisioningServicesPrivateEndpointConnectionData data = new DeviceProvisioningServicesPrivateEndpointConnectionData(new DeviceProvisioningServicesPrivateEndpointConnectionProperties(new DeviceProvisioningServicesPrivateLinkServiceConnectionState(DeviceProvisioningServicesPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"))); + ArmOperation lro = await deviceProvisioningServicesPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); DeviceProvisioningServicesPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateLinkResourceCollection.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateLinkResourceCollection.cs index e7f32fbb5ff16..94ba9d0375f39 100644 --- a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateLinkResourceCollection.cs +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_DeviceProvisioningServicesPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DeviceProvisioningServicesPrivateLinkResourceCollect { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesList() + public async Task Get_PrivateLinkResourcesList() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListPrivateLinkResources.json - // this example is just showing the usage of "IotDpsResource_ListPrivateLinkResources" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetPrivateLinkResources.json + // this example is just showing the usage of "IotDpsResource_GetPrivateLinkResources" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_PrivateLinkResourcesList() // get the collection of this DeviceProvisioningServicesPrivateLinkResource DeviceProvisioningServicesPrivateLinkResourceCollection collection = deviceProvisioningService.GetDeviceProvisioningServicesPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (DeviceProvisioningServicesPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceProvisioningServicesPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupId = "iotDps"; + DeviceProvisioningServicesPrivateLinkResource result = await collection.GetAsync(groupId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceProvisioningServicesPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkResourcesList() + public async Task GetAll_PrivateLinkResourcesList() { - // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetPrivateLinkResources.json - // this example is just showing the usage of "IotDpsResource_GetPrivateLinkResources" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListPrivateLinkResources.json + // this example is just showing the usage of "IotDpsResource_ListPrivateLinkResources" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_PrivateLinkResourcesList() // get the collection of this DeviceProvisioningServicesPrivateLinkResource DeviceProvisioningServicesPrivateLinkResourceCollection collection = deviceProvisioningService.GetDeviceProvisioningServicesPrivateLinkResources(); - // invoke the operation - string groupId = "iotDps"; - DeviceProvisioningServicesPrivateLinkResource result = await collection.GetAsync(groupId); + // invoke the operation and iterate over the result + await foreach (DeviceProvisioningServicesPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceProvisioningServicesPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceProvisioningServicesPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..81b122567b44e --- /dev/null +++ b/sdk/deviceprovisioningservices/Azure.ResourceManager.DeviceProvisioningServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.DeviceProvisioningServices.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.DeviceProvisioningServices.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeviceProvisioningServices_DPSListBySubscription() + { + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListBySubscription.json + // this example is just showing the usage of "IotDpsResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeviceProvisioningServiceResource item in subscriptionResource.GetDeviceProvisioningServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceProvisioningServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckDeviceProvisioningServicesNameAvailability_DPSCheckName() + { + // Generated from example definition: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCheckNameAvailability.json + // this example is just showing the usage of "IotDpsResource_CheckProvisioningServiceNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + DeviceProvisioningServicesNameAvailabilityContent content = new DeviceProvisioningServicesNameAvailabilityContent("test213123"); + DeviceProvisioningServicesNameAvailabilityResult result = await subscriptionResource.CheckDeviceProvisioningServicesNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetCollection.cs b/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetCollection.cs index 35b0cbb16210c..c4fb4d2166936 100644 --- a/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetCollection.cs +++ b/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DeviceRegistryAssetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAssetsInAResourceGroup() + public async Task CreateOrUpdate_CreateAnAssetWithExternalAssetId() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_ResourceGroup.json - // this example is just showing the usage of "Assets_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_With_ExternalAssetId.json + // this example is just showing the usage of "Assets_CreateOrReplace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,69 @@ public async Task GetAll_ListAssetsInAResourceGroup() // get the collection of this DeviceRegistryAssetResource DeviceRegistryAssetCollection collection = resourceGroupResource.GetDeviceRegistryAssets(); - // invoke the operation and iterate over the result - await foreach (DeviceRegistryAssetResource item in collection.GetAllAsync()) + // invoke the operation + string assetName = "my-asset"; + DeviceRegistryAssetData data = new DeviceRegistryAssetData(new AzureLocation("West Europe"), new DeviceRegistryExtendedLocation("CustomLocation", "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AssetType = "MyAssetType", + Enabled = true, + ExternalAssetId = "8ZBA6LRHU0A458969", + DisplayName = "AssetDisplayName", + Description = "This is a sample Asset", + AssetEndpointProfileUri = new Uri("https://www.example.com/myAssetEndpointProfile"), + Manufacturer = "Contoso", + ManufacturerUri = new Uri("https://www.contoso.com/manufacturerUri"), + Model = "ContosoModel", + ProductCode = "SA34VDG", + HardwareRevision = "1.0", + SoftwareRevision = "2.0", + DocumentationUri = new Uri("https://www.example.com/manual"), + SerialNumber = "64-103816-519918-8", + DefaultDataPointsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", + DefaultEventsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", + DataPoints = {new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1") +{ +CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", +ObservabilityMode = DataPointsObservabilityMode.Counter, +DataPointConfiguration = "{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}", +}, new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2") +{ +CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", +ObservabilityMode = DataPointsObservabilityMode.None, +DataPointConfiguration = "{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}", +}}, + Events = {new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3") +{ +CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", +ObservabilityMode = EventsObservabilityMode.None, +EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}", +}, new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4") +{ +CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", +ObservabilityMode = EventsObservabilityMode.Log, +EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}", +}}, + Tags = +{ +["site"] = "building-1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetName, data); + DeviceRegistryAssetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAsset() + public async Task CreateOrUpdate_CreateAnAssetWithoutDisplayName() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json - // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_DisplayName.json + // this example is just showing the usage of "Assets_CreateOrReplace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +120,52 @@ public async Task Get_GetAnAsset() // invoke the operation string assetName = "my-asset"; - DeviceRegistryAssetResource result = await collection.GetAsync(assetName); + DeviceRegistryAssetData data = new DeviceRegistryAssetData(new AzureLocation("West Europe"), new DeviceRegistryExtendedLocation("CustomLocation", "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1")) + { + AssetType = "MyAssetType", + Enabled = true, + ExternalAssetId = "8ZBA6LRHU0A458969", + Description = "This is a sample Asset", + AssetEndpointProfileUri = new Uri("https://www.example.com/myAssetEndpointProfile"), + Manufacturer = "Contoso", + ManufacturerUri = new Uri("https://www.contoso.com/manufacturerUri"), + Model = "ContosoModel", + ProductCode = "SA34VDG", + HardwareRevision = "1.0", + SoftwareRevision = "2.0", + DocumentationUri = new Uri("https://www.example.com/manual"), + SerialNumber = "64-103816-519918-8", + DefaultDataPointsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", + DefaultEventsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", + DataPoints = {new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1") +{ +CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", +ObservabilityMode = DataPointsObservabilityMode.Counter, +DataPointConfiguration = "{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}", +}, new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2") +{ +CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", +ObservabilityMode = DataPointsObservabilityMode.None, +DataPointConfiguration = "{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}", +}}, + Events = {new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3") +{ +CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", +ObservabilityMode = EventsObservabilityMode.None, +EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}", +}, new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4") +{ +CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", +ObservabilityMode = EventsObservabilityMode.Log, +EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}", +}}, + Tags = +{ +["site"] = "building-1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetName, data); + DeviceRegistryAssetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,10 +176,10 @@ public async Task Get_GetAnAsset() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAsset() + public async Task CreateOrUpdate_CreateAnAssetWithoutExternalAssetId() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json - // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_ExternalAssetId.json + // this example is just showing the usage of "Assets_CreateOrReplace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,14 +198,63 @@ public async Task Exists_GetAnAsset() // invoke the operation string assetName = "my-asset"; - bool result = await collection.ExistsAsync(assetName); + DeviceRegistryAssetData data = new DeviceRegistryAssetData(new AzureLocation("West Europe"), new DeviceRegistryExtendedLocation("CustomLocation", "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1")) + { + AssetType = "MyAssetType", + Enabled = true, + DisplayName = "AssetDisplayName", + Description = "This is a sample Asset", + AssetEndpointProfileUri = new Uri("https://www.example.com/myAssetEndpointProfile"), + Manufacturer = "Contoso", + ManufacturerUri = new Uri("https://www.contoso.com/manufacturerUri"), + Model = "ContosoModel", + ProductCode = "SA34VDG", + HardwareRevision = "1.0", + SoftwareRevision = "2.0", + DocumentationUri = new Uri("https://www.example.com/manual"), + SerialNumber = "64-103816-519918-8", + DefaultDataPointsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", + DefaultEventsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", + DataPoints = {new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1") +{ +CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", +ObservabilityMode = DataPointsObservabilityMode.Counter, +DataPointConfiguration = "{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}", +}, new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2") +{ +CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", +ObservabilityMode = DataPointsObservabilityMode.None, +DataPointConfiguration = "{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}", +}}, + Events = {new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3") +{ +CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", +ObservabilityMode = EventsObservabilityMode.None, +EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}", +}, new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4") +{ +CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", +ObservabilityMode = EventsObservabilityMode.Log, +EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}", +}}, + Tags = +{ +["site"] = "building-1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetName, data); + DeviceRegistryAssetResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAsset() + public async Task Get_GetAnAsset() { // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,21 +276,13 @@ public async Task GetIfExists_GetAnAsset() // invoke the operation string assetName = "my-asset"; - NullableResponse response = await collection.GetIfExistsAsync(assetName); - DeviceRegistryAssetResource result = response.HasValue ? response.Value : null; + DeviceRegistryAssetResource result = await collection.GetAsync(assetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -190,10 +320,10 @@ public async Task Get_GetAnAssetWithSyncStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAssetWithSyncStatus() + public async Task GetAll_ListAssetsInAResourceGroup() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset_With_SyncStatus.json - // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_ResourceGroup.json + // this example is just showing the usage of "Assets_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -210,18 +340,24 @@ public async Task Exists_GetAnAssetWithSyncStatus() // get the collection of this DeviceRegistryAssetResource DeviceRegistryAssetCollection collection = resourceGroupResource.GetDeviceRegistryAssets(); - // invoke the operation - string assetName = "my-asset"; - bool result = await collection.ExistsAsync(assetName); + // invoke the operation and iterate over the result + await foreach (DeviceRegistryAssetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAssetWithSyncStatus() + public async Task Exists_GetAnAsset() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset_With_SyncStatus.json + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -241,29 +377,17 @@ public async Task GetIfExists_GetAnAssetWithSyncStatus() // invoke the operation string assetName = "my-asset"; - NullableResponse response = await collection.GetIfExistsAsync(assetName); - DeviceRegistryAssetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(assetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAssetWithExternalAssetId() + public async Task Exists_GetAnAssetWithSyncStatus() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_With_ExternalAssetId.json - // this example is just showing the usage of "Assets_CreateOrReplace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset_With_SyncStatus.json + // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -282,73 +406,17 @@ public async Task CreateOrUpdate_CreateAnAssetWithExternalAssetId() // invoke the operation string assetName = "my-asset"; - DeviceRegistryAssetData data = new DeviceRegistryAssetData(new AzureLocation("West Europe"), new DeviceRegistryExtendedLocation("CustomLocation", "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1")) - { - AssetType = "MyAssetType", - Enabled = true, - ExternalAssetId = "8ZBA6LRHU0A458969", - DisplayName = "AssetDisplayName", - Description = "This is a sample Asset", - AssetEndpointProfileUri = new Uri("https://www.example.com/myAssetEndpointProfile"), - Manufacturer = "Contoso", - ManufacturerUri = new Uri("https://www.contoso.com/manufacturerUri"), - Model = "ContosoModel", - ProductCode = "SA34VDG", - HardwareRevision = "1.0", - SoftwareRevision = "2.0", - DocumentationUri = new Uri("https://www.example.com/manual"), - SerialNumber = "64-103816-519918-8", - DefaultDataPointsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", - DefaultEventsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", - DataPoints = -{ -new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1") -{ -CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", -ObservabilityMode = DataPointsObservabilityMode.Counter, -DataPointConfiguration = "{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}", -},new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2") -{ -CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", -ObservabilityMode = DataPointsObservabilityMode.None, -DataPointConfiguration = "{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}", -} -}, - Events = -{ -new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3") -{ -CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", -ObservabilityMode = EventsObservabilityMode.None, -EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}", -},new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4") -{ -CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", -ObservabilityMode = EventsObservabilityMode.Log, -EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}", -} -}, - Tags = -{ -["site"] = "building-1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetName, data); - DeviceRegistryAssetResource result = lro.Value; + bool result = await collection.ExistsAsync(assetName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAssetWithoutDisplayName() + public async Task GetIfExists_GetAnAsset() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_DisplayName.json - // this example is just showing the usage of "Assets_CreateOrReplace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset.json + // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -367,72 +435,29 @@ public async Task CreateOrUpdate_CreateAnAssetWithoutDisplayName() // invoke the operation string assetName = "my-asset"; - DeviceRegistryAssetData data = new DeviceRegistryAssetData(new AzureLocation("West Europe"), new DeviceRegistryExtendedLocation("CustomLocation", "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1")) - { - AssetType = "MyAssetType", - Enabled = true, - ExternalAssetId = "8ZBA6LRHU0A458969", - Description = "This is a sample Asset", - AssetEndpointProfileUri = new Uri("https://www.example.com/myAssetEndpointProfile"), - Manufacturer = "Contoso", - ManufacturerUri = new Uri("https://www.contoso.com/manufacturerUri"), - Model = "ContosoModel", - ProductCode = "SA34VDG", - HardwareRevision = "1.0", - SoftwareRevision = "2.0", - DocumentationUri = new Uri("https://www.example.com/manual"), - SerialNumber = "64-103816-519918-8", - DefaultDataPointsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", - DefaultEventsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", - DataPoints = -{ -new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1") -{ -CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", -ObservabilityMode = DataPointsObservabilityMode.Counter, -DataPointConfiguration = "{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}", -},new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2") -{ -CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", -ObservabilityMode = DataPointsObservabilityMode.None, -DataPointConfiguration = "{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}", -} -}, - Events = -{ -new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3") -{ -CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", -ObservabilityMode = EventsObservabilityMode.None, -EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}", -},new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4") -{ -CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", -ObservabilityMode = EventsObservabilityMode.Log, -EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}", -} -}, - Tags = -{ -["site"] = "building-1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetName, data); - DeviceRegistryAssetResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(assetName); + DeviceRegistryAssetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAssetWithoutExternalAssetId() + public async Task GetIfExists_GetAnAssetWithSyncStatus() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_Asset_Without_ExternalAssetId.json - // this example is just showing the usage of "Assets_CreateOrReplace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_Asset_With_SyncStatus.json + // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -451,64 +476,21 @@ public async Task CreateOrUpdate_CreateAnAssetWithoutExternalAssetId() // invoke the operation string assetName = "my-asset"; - DeviceRegistryAssetData data = new DeviceRegistryAssetData(new AzureLocation("West Europe"), new DeviceRegistryExtendedLocation("CustomLocation", "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1")) - { - AssetType = "MyAssetType", - Enabled = true, - DisplayName = "AssetDisplayName", - Description = "This is a sample Asset", - AssetEndpointProfileUri = new Uri("https://www.example.com/myAssetEndpointProfile"), - Manufacturer = "Contoso", - ManufacturerUri = new Uri("https://www.contoso.com/manufacturerUri"), - Model = "ContosoModel", - ProductCode = "SA34VDG", - HardwareRevision = "1.0", - SoftwareRevision = "2.0", - DocumentationUri = new Uri("https://www.example.com/manual"), - SerialNumber = "64-103816-519918-8", - DefaultDataPointsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", - DefaultEventsConfiguration = "{\"publishingInterval\":10,\"samplingInterval\":15,\"queueSize\":20}", - DataPoints = -{ -new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt1") -{ -CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", -ObservabilityMode = DataPointsObservabilityMode.Counter, -DataPointConfiguration = "{\"publishingInterval\":8,\"samplingInterval\":8,\"queueSize\":4}", -},new DataPoint("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt2") -{ -CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", -ObservabilityMode = DataPointsObservabilityMode.None, -DataPointConfiguration = "{\"publishingInterval\":4,\"samplingInterval\":4,\"queueSize\":7}", -} -}, - Events = -{ -new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt3") -{ -CapabilityId = "dtmi:com:example:Thermostat:__temperature;1", -ObservabilityMode = EventsObservabilityMode.None, -EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":1,\"queueSize\":8}", -},new AssetEvent("nsu=http://microsoft.com/Opc/OpcPlc/;s=FastUInt4") -{ -CapabilityId = "dtmi:com:example:Thermostat:__pressure;1", -ObservabilityMode = EventsObservabilityMode.Log, -EventConfiguration = "{\"publishingInterval\":7,\"samplingInterval\":8,\"queueSize\":4}", -} -}, - Tags = -{ -["site"] = "building-1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetName, data); - DeviceRegistryAssetResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(assetName); + DeviceRegistryAssetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetEndpointProfileCollection.cs b/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetEndpointProfileCollection.cs index 769fddd89ab0a..ff327927f96ed 100644 --- a/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetEndpointProfileCollection.cs +++ b/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetEndpointProfileCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DeviceRegistryAssetEndpointProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAssetEndpointProfilesInAResourceGroup() + public async Task CreateOrUpdate_CreateAnAssetEndpointProfile() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_ResourceGroup.json - // this example is just showing the usage of "AssetEndpointProfiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_AssetEndpointProfile.json + // this example is just showing the usage of "AssetEndpointProfiles_CreateOrReplace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ListAssetEndpointProfilesInAResourceGroup() // get the collection of this DeviceRegistryAssetEndpointProfileResource DeviceRegistryAssetEndpointProfileCollection collection = resourceGroupResource.GetDeviceRegistryAssetEndpointProfiles(); - // invoke the operation and iterate over the result - await foreach (DeviceRegistryAssetEndpointProfileResource item in collection.GetAllAsync()) + // invoke the operation + string assetEndpointProfileName = "my-assetendpointprofile"; + DeviceRegistryAssetEndpointProfileData data = new DeviceRegistryAssetEndpointProfileData(new AzureLocation("West Europe"), new DeviceRegistryExtendedLocation("CustomLocation", "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetEndpointProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TargetAddress = new Uri("https://www.example.com/myTargetAddress"), + UserAuthentication = new UserAuthentication(UserAuthenticationMode.Anonymous), + Tags = +{ +["site"] = "building-1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetEndpointProfileName, data); + DeviceRegistryAssetEndpointProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetEndpointProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +95,10 @@ public async Task Get_GetAnAssetEndpointProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAssetEndpointProfile() + public async Task GetAll_ListAssetEndpointProfilesInAResourceGroup() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_AssetEndpointProfile.json - // this example is just showing the usage of "AssetEndpointProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_ResourceGroup.json + // this example is just showing the usage of "AssetEndpointProfiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +115,22 @@ public async Task Exists_GetAnAssetEndpointProfile() // get the collection of this DeviceRegistryAssetEndpointProfileResource DeviceRegistryAssetEndpointProfileCollection collection = resourceGroupResource.GetDeviceRegistryAssetEndpointProfiles(); - // invoke the operation - string assetEndpointProfileName = "my-assetendpointprofile"; - bool result = await collection.ExistsAsync(assetEndpointProfileName); + // invoke the operation and iterate over the result + await foreach (DeviceRegistryAssetEndpointProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetEndpointProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAssetEndpointProfile() + public async Task Exists_GetAnAssetEndpointProfile() { // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_AssetEndpointProfile.json // this example is just showing the usage of "AssetEndpointProfiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +152,17 @@ public async Task GetIfExists_GetAnAssetEndpointProfile() // invoke the operation string assetEndpointProfileName = "my-assetendpointprofile"; - NullableResponse response = await collection.GetIfExistsAsync(assetEndpointProfileName); - DeviceRegistryAssetEndpointProfileResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(assetEndpointProfileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetEndpointProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAssetEndpointProfile() + public async Task GetIfExists_GetAnAssetEndpointProfile() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Create_AssetEndpointProfile.json - // this example is just showing the usage of "AssetEndpointProfiles_CreateOrReplace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Get_AssetEndpointProfile.json + // this example is just showing the usage of "AssetEndpointProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,23 +181,21 @@ public async Task CreateOrUpdate_CreateAnAssetEndpointProfile() // invoke the operation string assetEndpointProfileName = "my-assetendpointprofile"; - DeviceRegistryAssetEndpointProfileData data = new DeviceRegistryAssetEndpointProfileData(new AzureLocation("West Europe"), new DeviceRegistryExtendedLocation("CustomLocation", "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/location1")) - { - TargetAddress = new Uri("https://www.example.com/myTargetAddress"), - UserAuthentication = new UserAuthentication(UserAuthenticationMode.Anonymous), - Tags = -{ -["site"] = "building-1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetEndpointProfileName, data); - DeviceRegistryAssetEndpointProfileResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(assetEndpointProfileName); + DeviceRegistryAssetEndpointProfileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetEndpointProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetEndpointProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetEndpointProfileResource.cs b/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetEndpointProfileResource.cs index 116d2eae95d09..b5b6afe3628ac 100644 --- a/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetEndpointProfileResource.cs +++ b/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetEndpointProfileResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DeviceRegistry.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DeviceRegistry.Samples { public partial class Sample_DeviceRegistryAssetEndpointProfileResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeviceRegistryAssetEndpointProfiles_ListAssetEndpointProfilesInASubscription() - { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_Subscription.json - // this example is just showing the usage of "AssetEndpointProfiles_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeviceRegistryAssetEndpointProfileResource item in subscriptionResource.GetDeviceRegistryAssetEndpointProfilesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetEndpointProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAnAssetEndpointProfile() @@ -80,10 +48,10 @@ public async Task Get_GetAnAssetEndpointProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAnAssetEndpointProfile() + public async Task Delete_DeleteAnAssetEndpointProfile() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_AssetEndpointProfile.json - // this example is just showing the usage of "AssetEndpointProfiles_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_AssetEndpointProfile.json + // this example is just showing the usage of "AssetEndpointProfiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,26 +67,17 @@ public async Task Update_PatchAnAssetEndpointProfile() DeviceRegistryAssetEndpointProfileResource deviceRegistryAssetEndpointProfile = client.GetDeviceRegistryAssetEndpointProfileResource(deviceRegistryAssetEndpointProfileResourceId); // invoke the operation - DeviceRegistryAssetEndpointProfilePatch patch = new DeviceRegistryAssetEndpointProfilePatch() - { - TargetAddress = new Uri("https://www.example.com/myTargetAddress"), - }; - ArmOperation lro = await deviceRegistryAssetEndpointProfile.UpdateAsync(WaitUntil.Completed, patch); - DeviceRegistryAssetEndpointProfileResource result = lro.Value; + await deviceRegistryAssetEndpointProfile.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetEndpointProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnAssetEndpointProfile() + public async Task Update_PatchAnAssetEndpointProfile() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_AssetEndpointProfile.json - // this example is just showing the usage of "AssetEndpointProfiles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_AssetEndpointProfile.json + // this example is just showing the usage of "AssetEndpointProfiles_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,9 +93,18 @@ public async Task Delete_DeleteAnAssetEndpointProfile() DeviceRegistryAssetEndpointProfileResource deviceRegistryAssetEndpointProfile = client.GetDeviceRegistryAssetEndpointProfileResource(deviceRegistryAssetEndpointProfileResourceId); // invoke the operation - await deviceRegistryAssetEndpointProfile.DeleteAsync(WaitUntil.Completed); + DeviceRegistryAssetEndpointProfilePatch patch = new DeviceRegistryAssetEndpointProfilePatch + { + TargetAddress = new Uri("https://www.example.com/myTargetAddress"), + }; + ArmOperation lro = await deviceRegistryAssetEndpointProfile.UpdateAsync(WaitUntil.Completed, patch); + DeviceRegistryAssetEndpointProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetEndpointProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetResource.cs b/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetResource.cs index 7c85dad0e7f1b..d876ee4ffa39a 100644 --- a/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetResource.cs +++ b/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_DeviceRegistryAssetResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DeviceRegistry.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DeviceRegistry.Samples { public partial class Sample_DeviceRegistryAssetResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeviceRegistryAssets_ListAssetsInASubscription() - { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_Subscription.json - // this example is just showing the usage of "Assets_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeviceRegistryAssetResource item in subscriptionResource.GetDeviceRegistryAssetsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAnAsset() @@ -110,10 +78,10 @@ public async Task Get_GetAnAssetWithSyncStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAnAsset() + public async Task Delete_DeleteAnAsset() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_Asset.json - // this example is just showing the usage of "Assets_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_Asset.json + // this example is just showing the usage of "Assets_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,27 +97,17 @@ public async Task Update_PatchAnAsset() DeviceRegistryAssetResource deviceRegistryAsset = client.GetDeviceRegistryAssetResource(deviceRegistryAssetResourceId); // invoke the operation - DeviceRegistryAssetPatch patch = new DeviceRegistryAssetPatch() - { - Enabled = false, - DisplayName = "NewAssetDisplayName", - }; - ArmOperation lro = await deviceRegistryAsset.UpdateAsync(WaitUntil.Completed, patch); - DeviceRegistryAssetResource result = lro.Value; + await deviceRegistryAsset.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceRegistryAssetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnAsset() + public async Task Update_PatchAnAsset() { - // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Delete_Asset.json - // this example is just showing the usage of "Assets_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/Update_Asset.json + // this example is just showing the usage of "Assets_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,9 +123,19 @@ public async Task Delete_DeleteAnAsset() DeviceRegistryAssetResource deviceRegistryAsset = client.GetDeviceRegistryAssetResource(deviceRegistryAssetResourceId); // invoke the operation - await deviceRegistryAsset.DeleteAsync(WaitUntil.Completed); + DeviceRegistryAssetPatch patch = new DeviceRegistryAssetPatch + { + Enabled = false, + DisplayName = "NewAssetDisplayName", + }; + ArmOperation lro = await deviceRegistryAsset.UpdateAsync(WaitUntil.Completed, patch); + DeviceRegistryAssetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..ea2b8e92496c7 --- /dev/null +++ b/sdk/deviceregistry/Azure.ResourceManager.DeviceRegistry/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.DeviceRegistry.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeviceRegistryAssetEndpointProfiles_ListAssetEndpointProfilesInASubscription() + { + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_AssetEndpointProfiles_Subscription.json + // this example is just showing the usage of "AssetEndpointProfiles_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeviceRegistryAssetEndpointProfileResource item in subscriptionResource.GetDeviceRegistryAssetEndpointProfilesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetEndpointProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeviceRegistryAssets_ListAssetsInASubscription() + { + // Generated from example definition: specification/deviceregistry/resource-manager/Microsoft.DeviceRegistry/preview/2023-11-01-preview/examples/List_Assets_Subscription.json + // this example is just showing the usage of "Assets_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeviceRegistryAssetResource item in subscriptionResource.GetDeviceRegistryAssetsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceRegistryAssetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateAccountCollection.cs b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateAccountCollection.cs index c9109e736fd97..86db0389ed4b1 100644 --- a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateAccountCollection.cs +++ b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateAccountCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_DeviceUpdateAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfAccounts() + public async Task CreateOrUpdate_CreatesOrUpdatesAccount() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_List.json - // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Create.json + // this example is just showing the usage of "Accounts_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,31 @@ public async Task GetAll_GetsListOfAccounts() // get the collection of this DeviceUpdateAccountResource DeviceUpdateAccountCollection collection = resourceGroupResource.GetDeviceUpdateAccounts(); - // invoke the operation and iterate over the result - await foreach (DeviceUpdateAccountResource item in collection.GetAllAsync()) + // invoke the operation + string accountName = "contoso"; + DeviceUpdateAccountData data = new DeviceUpdateAccountData(new AzureLocation("westus2")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdateAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() +}, + }, + Encryption = new DeviceUpdateEncryption + { + KeyVaultKeyUri = new Uri("https://contoso.vault.azure.net/keys/contoso"), + UserAssignedIdentity = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + DeviceUpdateAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdateAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +102,10 @@ public async Task Get_GetsAccountDetails() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAccountDetails() + public async Task GetAll_GetsListOfAccounts() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Get.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_List.json + // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +122,22 @@ public async Task Exists_GetsAccountDetails() // get the collection of this DeviceUpdateAccountResource DeviceUpdateAccountCollection collection = resourceGroupResource.GetDeviceUpdateAccounts(); - // invoke the operation - string accountName = "contoso"; - bool result = await collection.ExistsAsync(accountName); + // invoke the operation and iterate over the result + await foreach (DeviceUpdateAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdateAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAccountDetails() + public async Task Exists_GetsAccountDetails() { // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Get.json // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +159,17 @@ public async Task GetIfExists_GetsAccountDetails() // invoke the operation string accountName = "contoso"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - DeviceUpdateAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdateAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesAccount() + public async Task GetIfExists_GetsAccountDetails() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Create.json - // this example is just showing the usage of "Accounts_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Get.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,29 +188,21 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAccount() // invoke the operation string accountName = "contoso"; - DeviceUpdateAccountData data = new DeviceUpdateAccountData(new AzureLocation("westus2")) - { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), -}, - }, - Encryption = new DeviceUpdateEncryption() - { - KeyVaultKeyUri = new Uri("https://contoso.vault.azure.net/keys/contoso"), - UserAssignedIdentity = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); - DeviceUpdateAccountResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + DeviceUpdateAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdateAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdateAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateAccountResource.cs b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateAccountResource.cs index a82e569248775..f214239182f8a 100644 --- a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateAccountResource.cs +++ b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateAccountResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DeviceUpdate.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DeviceUpdate.Samples { public partial class Sample_DeviceUpdateAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeviceUpdateAccounts_GetListOfAccounts() - { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_List.json - // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeviceUpdateAccountResource item in subscriptionResource.GetDeviceUpdateAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdateAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetsAccountDetails() @@ -125,11 +93,11 @@ public async Task Update_UpdatesAccount() DeviceUpdateAccountResource deviceUpdateAccount = client.GetDeviceUpdateAccountResource(deviceUpdateAccountResourceId); // invoke the operation - DeviceUpdateAccountPatch patch = new DeviceUpdateAccountPatch() + DeviceUpdateAccountPatch patch = new DeviceUpdateAccountPatch { Tags = { -["tagKey"] = "tagValue", +["tagKey"] = "tagValue" }, }; ArmOperation lro = await deviceUpdateAccount.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateInstanceCollection.cs b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateInstanceCollection.cs index f83635bb2214c..2ac703f63bc46 100644 --- a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateInstanceCollection.cs +++ b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateInstanceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DeviceUpdateInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfInstancesByAccount() + public async Task CreateOrUpdate_CreatesOrUpdatesInstance() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_ListByAccount.json - // this example is just showing the usage of "Instances_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Create.json + // this example is just showing the usage of "Instances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_GetsListOfInstancesByAccount() // get the collection of this DeviceUpdateInstanceResource DeviceUpdateInstanceCollection collection = deviceUpdateAccount.GetDeviceUpdateInstances(); - // invoke the operation and iterate over the result - await foreach (DeviceUpdateInstanceResource item in collection.GetAllAsync()) + // invoke the operation + string instanceName = "blue"; + DeviceUpdateInstanceData data = new DeviceUpdateInstanceData(new AzureLocation("westus2")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdateInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IotHubs = { new DeviceUpdateIotHubSettings(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Devices/IotHubs/blue-contoso-hub")) }, + EnableDiagnostics = false, + DiagnosticStorageProperties = new DiagnosticStorageProperties(DiagnosticStorageAuthenticationType.KeyBased, new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/adu-resource-group/providers/Microsoft.Storage/storageAccounts/testAccount")) + { + ConnectionString = "string", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, instanceName, data); + DeviceUpdateInstanceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdateInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetsListOfInstances() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsListOfInstances() + public async Task GetAll_GetsListOfInstancesByAccount() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Get.json - // this example is just showing the usage of "Instances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_ListByAccount.json + // this example is just showing the usage of "Instances_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetsListOfInstances() // get the collection of this DeviceUpdateInstanceResource DeviceUpdateInstanceCollection collection = deviceUpdateAccount.GetDeviceUpdateInstances(); - // invoke the operation - string instanceName = "blue"; - bool result = await collection.ExistsAsync(instanceName); + // invoke the operation and iterate over the result + await foreach (DeviceUpdateInstanceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdateInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsListOfInstances() + public async Task Exists_GetsListOfInstances() { // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Get.json // this example is just showing the usage of "Instances_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetsListOfInstances() // invoke the operation string instanceName = "blue"; - NullableResponse response = await collection.GetIfExistsAsync(instanceName); - DeviceUpdateInstanceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(instanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdateInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesInstance() + public async Task GetIfExists_GetsListOfInstances() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Create.json - // this example is just showing the usage of "Instances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Get.json + // this example is just showing the usage of "Instances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +185,21 @@ public async Task CreateOrUpdate_CreatesOrUpdatesInstance() // invoke the operation string instanceName = "blue"; - DeviceUpdateInstanceData data = new DeviceUpdateInstanceData(new AzureLocation("westus2")) - { - IotHubs = -{ -new DeviceUpdateIotHubSettings(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Devices/IotHubs/blue-contoso-hub")) -}, - EnableDiagnostics = false, - DiagnosticStorageProperties = new DiagnosticStorageProperties(DiagnosticStorageAuthenticationType.KeyBased, new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/adu-resource-group/providers/Microsoft.Storage/storageAccounts/testAccount")) - { - ConnectionString = "string", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, instanceName, data); - DeviceUpdateInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(instanceName); + DeviceUpdateInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdateInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdateInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateInstanceResource.cs b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateInstanceResource.cs index 8e7796bd09ddb..9e8c69ee51108 100644 --- a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateInstanceResource.cs +++ b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdateInstanceResource.cs @@ -96,11 +96,11 @@ public async Task Update_UpdatesInstance() DeviceUpdateInstanceResource deviceUpdateInstance = client.GetDeviceUpdateInstanceResource(deviceUpdateInstanceResourceId); // invoke the operation - DeviceUpdateInstancePatch patch = new DeviceUpdateInstancePatch() + DeviceUpdateInstancePatch patch = new DeviceUpdateInstancePatch { Tags = { -["tagKey"] = "tagValue", +["tagKey"] = "tagValue" }, }; DeviceUpdateInstanceResource result = await deviceUpdateInstance.UpdateAsync(patch); diff --git a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionCollection.cs b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionCollection.cs index e37258ab17593..72bcfcd183c4f 100644 --- a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionCollection.cs +++ b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DeviceUpdatePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionList() + public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_ListByAccount.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_CreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_PrivateEndpointConnectionList() // get the collection of this DeviceUpdatePrivateEndpointConnectionResource DeviceUpdatePrivateEndpointConnectionCollection collection = deviceUpdateAccount.GetDeviceUpdatePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (DeviceUpdatePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "peexample01"; + DeviceUpdatePrivateEndpointConnectionData data = new DeviceUpdatePrivateEndpointConnectionData(new DeviceUpdatePrivateLinkServiceConnectionState { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdatePrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Status = DeviceUpdatePrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + DeviceUpdatePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdatePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_PrivateEndpointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionGet() + public async Task GetAll_PrivateEndpointConnectionList() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_ListByAccount.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +113,22 @@ public async Task Exists_PrivateEndpointConnectionGet() // get the collection of this DeviceUpdatePrivateEndpointConnectionResource DeviceUpdatePrivateEndpointConnectionCollection collection = deviceUpdateAccount.GetDeviceUpdatePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "peexample01"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (DeviceUpdatePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdatePrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionGet() + public async Task Exists_PrivateEndpointConnectionGet() { // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_PrivateEndpointConnectionGet() // invoke the operation string privateEndpointConnectionName = "peexample01"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - DeviceUpdatePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdatePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() + public async Task GetIfExists_PrivateEndpointConnectionGet() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_CreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,19 +181,21 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() // invoke the operation string privateEndpointConnectionName = "peexample01"; - DeviceUpdatePrivateEndpointConnectionData data = new DeviceUpdatePrivateEndpointConnectionData(new DeviceUpdatePrivateLinkServiceConnectionState() - { - Status = DeviceUpdatePrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - DeviceUpdatePrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + DeviceUpdatePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdatePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdatePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionProxyCollection.cs b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionProxyCollection.cs index e6be7cac1d881..564c163703c4a 100644 --- a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionProxyCollection.cs +++ b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionProxyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DeviceUpdatePrivateEndpointConnectionProxyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionProxyList() + public async Task CreateOrUpdate_PrivateEndpointConnectionProxyCreateOrUpdate() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_ListByAccount.json - // this example is just showing the usage of "PrivateEndpointConnectionProxies_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_CreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnectionProxies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,37 @@ public async Task GetAll_PrivateEndpointConnectionProxyList() // get the collection of this DeviceUpdatePrivateEndpointConnectionProxyResource DeviceUpdatePrivateEndpointConnectionProxyCollection collection = deviceUpdateAccount.GetDeviceUpdatePrivateEndpointConnectionProxies(); - // invoke the operation and iterate over the result - await foreach (DeviceUpdatePrivateEndpointConnectionProxyResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionProxyId = "peexample01"; + DeviceUpdatePrivateEndpointConnectionProxyData data = new DeviceUpdatePrivateEndpointConnectionProxyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdatePrivateEndpointConnectionProxyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + RemotePrivateEndpoint = new DeviceUpdateRemotePrivateEndpoint + { + Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + Location = new AzureLocation("westus2"), + ImmutableSubscriptionId = "00000000-0000-0000-0000-000000000000", + ImmutableResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + ManualPrivateLinkServiceConnections = {new DeviceUpdatePrivateLinkServiceConnection +{ +Name = "{privateEndpointConnectionProxyId}", +GroupIds = {"DeviceUpdate"}, +RequestMessage = "Please approve my connection, thanks.", +}}, + PrivateLinkServiceProxies = {new DeviceUpdatePrivateLinkServiceProxy +{ +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{privateEndpointConnectionProxyId}/privateLinkServiceProxies/{privateEndpointConnectionProxyId}"), +GroupConnectivityInformation = {}, +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionProxyId, data); + DeviceUpdatePrivateEndpointConnectionProxyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdatePrivateEndpointConnectionProxyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +108,10 @@ public async Task Get_PrivateEndpointConnectionProxyGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionProxyGet() + public async Task GetAll_PrivateEndpointConnectionProxyList() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Get.json - // this example is just showing the usage of "PrivateEndpointConnectionProxies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_ListByAccount.json + // this example is just showing the usage of "PrivateEndpointConnectionProxies_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +129,22 @@ public async Task Exists_PrivateEndpointConnectionProxyGet() // get the collection of this DeviceUpdatePrivateEndpointConnectionProxyResource DeviceUpdatePrivateEndpointConnectionProxyCollection collection = deviceUpdateAccount.GetDeviceUpdatePrivateEndpointConnectionProxies(); - // invoke the operation - string privateEndpointConnectionProxyId = "peexample01"; - bool result = await collection.ExistsAsync(privateEndpointConnectionProxyId); + // invoke the operation and iterate over the result + await foreach (DeviceUpdatePrivateEndpointConnectionProxyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdatePrivateEndpointConnectionProxyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionProxyGet() + public async Task Exists_PrivateEndpointConnectionProxyGet() { // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Get.json // this example is just showing the usage of "PrivateEndpointConnectionProxies_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +167,17 @@ public async Task GetIfExists_PrivateEndpointConnectionProxyGet() // invoke the operation string privateEndpointConnectionProxyId = "peexample01"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionProxyId); - DeviceUpdatePrivateEndpointConnectionProxyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionProxyId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdatePrivateEndpointConnectionProxyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionProxyCreateOrUpdate() + public async Task GetIfExists_PrivateEndpointConnectionProxyGet() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_CreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnectionProxies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Get.json + // this example is just showing the usage of "PrivateEndpointConnectionProxies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,46 +197,21 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionProxyCreateOrUpdate() // invoke the operation string privateEndpointConnectionProxyId = "peexample01"; - DeviceUpdatePrivateEndpointConnectionProxyData data = new DeviceUpdatePrivateEndpointConnectionProxyData() - { - RemotePrivateEndpoint = new DeviceUpdateRemotePrivateEndpoint() - { - Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), - Location = new AzureLocation("westus2"), - ImmutableSubscriptionId = "00000000-0000-0000-0000-000000000000", - ImmutableResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), - ManualPrivateLinkServiceConnections = -{ -new DeviceUpdatePrivateLinkServiceConnection() -{ -Name = "{privateEndpointConnectionProxyId}", -GroupIds = -{ -"DeviceUpdate" -}, -RequestMessage = "Please approve my connection, thanks.", -} -}, - PrivateLinkServiceProxies = -{ -new DeviceUpdatePrivateLinkServiceProxy() -{ -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{privateEndpointConnectionProxyId}/privateLinkServiceProxies/{privateEndpointConnectionProxyId}"), -GroupConnectivityInformation = -{ -}, -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionProxyId, data); - DeviceUpdatePrivateEndpointConnectionProxyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionProxyId); + DeviceUpdatePrivateEndpointConnectionProxyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdatePrivateEndpointConnectionProxyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdatePrivateEndpointConnectionProxyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionProxyResource.cs b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionProxyResource.cs index d789b3c10637d..d403fefa6614d 100644 --- a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionProxyResource.cs +++ b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionProxyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DeviceUpdatePrivateEndpointConnectionProxyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Validate_PrivateEndpointConnectionProxyValidate() + public async Task Get_PrivateEndpointConnectionProxyGet() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Validate.json - // this example is just showing the usage of "PrivateEndpointConnectionProxies_Validate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Get.json + // this example is just showing the usage of "PrivateEndpointConnectionProxies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,49 +38,21 @@ public async Task Validate_PrivateEndpointConnectionProxyValidate() DeviceUpdatePrivateEndpointConnectionProxyResource deviceUpdatePrivateEndpointConnectionProxy = client.GetDeviceUpdatePrivateEndpointConnectionProxyResource(deviceUpdatePrivateEndpointConnectionProxyResourceId); // invoke the operation - DeviceUpdatePrivateEndpointConnectionProxyData data = new DeviceUpdatePrivateEndpointConnectionProxyData() - { - RemotePrivateEndpoint = new DeviceUpdateRemotePrivateEndpoint() - { - Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{privateEndpointConnectionProxyId}"), - Location = new AzureLocation("westus2"), - ImmutableSubscriptionId = "00000000-0000-0000-0000-000000000000", - ImmutableResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), - ManualPrivateLinkServiceConnections = -{ -new DeviceUpdatePrivateLinkServiceConnection() -{ -Name = "{privateEndpointConnectionProxyId}", -GroupIds = -{ -"DeviceUpdate" -}, -RequestMessage = "Please approve my connection, thanks.", -} -}, - PrivateLinkServiceProxies = -{ -new DeviceUpdatePrivateLinkServiceProxy() -{ -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{privateEndpointConnectionProxyId}/privateLinkServiceProxies/{privateEndpointConnectionProxyId}"), -GroupConnectivityInformation = -{ -}, -} -}, - }, - }; - await deviceUpdatePrivateEndpointConnectionProxy.ValidateAsync(data); + DeviceUpdatePrivateEndpointConnectionProxyResource result = await deviceUpdatePrivateEndpointConnectionProxy.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdatePrivateEndpointConnectionProxyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task UpdatePrivateEndpointProperties_PrivateEndpointConnectionProxyPrivateEndpointUpdate() + public async Task Delete_PrivateEndpointConnectionProxyDelete() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_PrivateEndpointUpdate.json - // this example is just showing the usage of "PrivateEndpointConnectionProxies_UpdatePrivateEndpointProperties" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Delete.json + // this example is just showing the usage of "PrivateEndpointConnectionProxies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,25 +69,17 @@ public async Task UpdatePrivateEndpointProperties_PrivateEndpointConnectionProxy DeviceUpdatePrivateEndpointConnectionProxyResource deviceUpdatePrivateEndpointConnectionProxy = client.GetDeviceUpdatePrivateEndpointConnectionProxyResource(deviceUpdatePrivateEndpointConnectionProxyResourceId); // invoke the operation - DeviceUpdatePrivateEndpointUpdate privateEndpointUpdate = new DeviceUpdatePrivateEndpointUpdate() - { - Id = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), - Location = new AzureLocation("westus2"), - ImmutableSubscriptionId = "00000000-0000-0000-0000-000000000000", - ImmutableResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), - VnetTrafficTag = "12345678", - }; - await deviceUpdatePrivateEndpointConnectionProxy.UpdatePrivateEndpointPropertiesAsync(privateEndpointUpdate); + await deviceUpdatePrivateEndpointConnectionProxy.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionProxyGet() + public async Task Update_PrivateEndpointConnectionProxyCreateOrUpdate() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Get.json - // this example is just showing the usage of "PrivateEndpointConnectionProxies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_CreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnectionProxies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,7 +96,29 @@ public async Task Get_PrivateEndpointConnectionProxyGet() DeviceUpdatePrivateEndpointConnectionProxyResource deviceUpdatePrivateEndpointConnectionProxy = client.GetDeviceUpdatePrivateEndpointConnectionProxyResource(deviceUpdatePrivateEndpointConnectionProxyResourceId); // invoke the operation - DeviceUpdatePrivateEndpointConnectionProxyResource result = await deviceUpdatePrivateEndpointConnectionProxy.GetAsync(); + DeviceUpdatePrivateEndpointConnectionProxyData data = new DeviceUpdatePrivateEndpointConnectionProxyData + { + RemotePrivateEndpoint = new DeviceUpdateRemotePrivateEndpoint + { + Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + Location = new AzureLocation("westus2"), + ImmutableSubscriptionId = "00000000-0000-0000-0000-000000000000", + ImmutableResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + ManualPrivateLinkServiceConnections = {new DeviceUpdatePrivateLinkServiceConnection +{ +Name = "{privateEndpointConnectionProxyId}", +GroupIds = {"DeviceUpdate"}, +RequestMessage = "Please approve my connection, thanks.", +}}, + PrivateLinkServiceProxies = {new DeviceUpdatePrivateLinkServiceProxy +{ +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{privateEndpointConnectionProxyId}/privateLinkServiceProxies/{privateEndpointConnectionProxyId}"), +GroupConnectivityInformation = {}, +}}, + }, + }; + ArmOperation lro = await deviceUpdatePrivateEndpointConnectionProxy.UpdateAsync(WaitUntil.Completed, data); + DeviceUpdatePrivateEndpointConnectionProxyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -143,10 +129,10 @@ public async Task Get_PrivateEndpointConnectionProxyGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionProxyCreateOrUpdate() + public async Task Validate_PrivateEndpointConnectionProxyValidate() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_CreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnectionProxies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Validate.json + // this example is just showing the usage of "PrivateEndpointConnectionProxies_Validate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -163,54 +149,38 @@ public async Task Update_PrivateEndpointConnectionProxyCreateOrUpdate() DeviceUpdatePrivateEndpointConnectionProxyResource deviceUpdatePrivateEndpointConnectionProxy = client.GetDeviceUpdatePrivateEndpointConnectionProxyResource(deviceUpdatePrivateEndpointConnectionProxyResourceId); // invoke the operation - DeviceUpdatePrivateEndpointConnectionProxyData data = new DeviceUpdatePrivateEndpointConnectionProxyData() + DeviceUpdatePrivateEndpointConnectionProxyData data = new DeviceUpdatePrivateEndpointConnectionProxyData { - RemotePrivateEndpoint = new DeviceUpdateRemotePrivateEndpoint() + RemotePrivateEndpoint = new DeviceUpdateRemotePrivateEndpoint { - Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{privateEndpointConnectionProxyId}"), Location = new AzureLocation("westus2"), ImmutableSubscriptionId = "00000000-0000-0000-0000-000000000000", ImmutableResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), - ManualPrivateLinkServiceConnections = -{ -new DeviceUpdatePrivateLinkServiceConnection() + ManualPrivateLinkServiceConnections = {new DeviceUpdatePrivateLinkServiceConnection { Name = "{privateEndpointConnectionProxyId}", -GroupIds = -{ -"DeviceUpdate" -}, +GroupIds = {"DeviceUpdate"}, RequestMessage = "Please approve my connection, thanks.", -} -}, - PrivateLinkServiceProxies = -{ -new DeviceUpdatePrivateLinkServiceProxy() +}}, + PrivateLinkServiceProxies = {new DeviceUpdatePrivateLinkServiceProxy { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{privateEndpointConnectionProxyId}/privateLinkServiceProxies/{privateEndpointConnectionProxyId}"), -GroupConnectivityInformation = -{ -}, -} -}, +GroupConnectivityInformation = {}, +}}, }, }; - ArmOperation lro = await deviceUpdatePrivateEndpointConnectionProxy.UpdateAsync(WaitUntil.Completed, data); - DeviceUpdatePrivateEndpointConnectionProxyResource result = lro.Value; + await deviceUpdatePrivateEndpointConnectionProxy.ValidateAsync(data); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdatePrivateEndpointConnectionProxyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionProxyDelete() + public async Task UpdatePrivateEndpointProperties_PrivateEndpointConnectionProxyPrivateEndpointUpdate() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Delete.json - // this example is just showing the usage of "PrivateEndpointConnectionProxies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_PrivateEndpointUpdate.json + // this example is just showing the usage of "PrivateEndpointConnectionProxies_UpdatePrivateEndpointProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -227,7 +197,15 @@ public async Task Delete_PrivateEndpointConnectionProxyDelete() DeviceUpdatePrivateEndpointConnectionProxyResource deviceUpdatePrivateEndpointConnectionProxy = client.GetDeviceUpdatePrivateEndpointConnectionProxyResource(deviceUpdatePrivateEndpointConnectionProxyResourceId); // invoke the operation - await deviceUpdatePrivateEndpointConnectionProxy.DeleteAsync(WaitUntil.Completed); + DeviceUpdatePrivateEndpointUpdate privateEndpointUpdate = new DeviceUpdatePrivateEndpointUpdate + { + Id = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + Location = new AzureLocation("westus2"), + ImmutableSubscriptionId = "00000000-0000-0000-0000-000000000000", + ImmutableResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Network/privateEndpoints/{peName}"), + VnetTrafficTag = "12345678", + }; + await deviceUpdatePrivateEndpointConnectionProxy.UpdatePrivateEndpointPropertiesAsync(privateEndpointUpdate); Console.WriteLine("Succeeded"); } diff --git a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionResource.cs b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionResource.cs index fff0de3dd631a..ce8b156d54e46 100644 --- a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionResource.cs +++ b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionCreateOrUpdate() + public async Task Delete_PrivateEndpointConnectionDelete() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_CreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,27 +69,17 @@ public async Task Update_PrivateEndpointConnectionCreateOrUpdate() DeviceUpdatePrivateEndpointConnectionResource deviceUpdatePrivateEndpointConnection = client.GetDeviceUpdatePrivateEndpointConnectionResource(deviceUpdatePrivateEndpointConnectionResourceId); // invoke the operation - DeviceUpdatePrivateEndpointConnectionData data = new DeviceUpdatePrivateEndpointConnectionData(new DeviceUpdatePrivateLinkServiceConnectionState() - { - Status = DeviceUpdatePrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }); - ArmOperation lro = await deviceUpdatePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - DeviceUpdatePrivateEndpointConnectionResource result = lro.Value; + await deviceUpdatePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdatePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionDelete() + public async Task Update_PrivateEndpointConnectionCreateOrUpdate() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_CreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +96,19 @@ public async Task Delete_PrivateEndpointConnectionDelete() DeviceUpdatePrivateEndpointConnectionResource deviceUpdatePrivateEndpointConnection = client.GetDeviceUpdatePrivateEndpointConnectionResource(deviceUpdatePrivateEndpointConnectionResourceId); // invoke the operation - await deviceUpdatePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + DeviceUpdatePrivateEndpointConnectionData data = new DeviceUpdatePrivateEndpointConnectionData(new DeviceUpdatePrivateLinkServiceConnectionState + { + Status = DeviceUpdatePrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }); + ArmOperation lro = await deviceUpdatePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + DeviceUpdatePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdatePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateLinkCollection.cs b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateLinkCollection.cs index 7f38d0dec69ae..ca9382a3a862a 100644 --- a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateLinkCollection.cs +++ b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_DeviceUpdatePrivateLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DeviceUpdatePrivateLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesList() + public async Task Get_PrivateLinkResourcesGet() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateLinkResources/PrivateLinkResources_ListByAccount.json - // this example is just showing the usage of "PrivateLinkResources_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateLinkResources/PrivateLinkResources_Get.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_PrivateLinkResourcesList() // get the collection of this DeviceUpdatePrivateLinkResource DeviceUpdatePrivateLinkCollection collection = deviceUpdateAccount.GetDeviceUpdatePrivateLinks(); - // invoke the operation and iterate over the result - await foreach (DeviceUpdatePrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdatePrivateLinkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupId = "adu"; + DeviceUpdatePrivateLinkResource result = await collection.GetAsync(groupId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdatePrivateLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkResourcesGet() + public async Task GetAll_PrivateLinkResourcesList() { - // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateLinkResources/PrivateLinkResources_Get.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateLinkResources/PrivateLinkResources_ListByAccount.json + // this example is just showing the usage of "PrivateLinkResources_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_PrivateLinkResourcesGet() // get the collection of this DeviceUpdatePrivateLinkResource DeviceUpdatePrivateLinkCollection collection = deviceUpdateAccount.GetDeviceUpdatePrivateLinks(); - // invoke the operation - string groupId = "adu"; - DeviceUpdatePrivateLinkResource result = await collection.GetAsync(groupId); + // invoke the operation and iterate over the result + await foreach (DeviceUpdatePrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdatePrivateLinkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceUpdatePrivateLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index c52bab110acfc..c25fb0693405e 100644 --- a/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/deviceupdate/Azure.ResourceManager.DeviceUpdate/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -36,7 +36,7 @@ public async Task CheckDeviceUpdateNameAvailability_CheckNameAvailabilityAlready SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - DeviceUpdateAvailabilityContent content = new DeviceUpdateAvailabilityContent() + DeviceUpdateAvailabilityContent content = new DeviceUpdateAvailabilityContent { Name = "contoso", CheckNameAvailabilityRequestType = new ResourceType("Microsoft.DeviceUpdate/accounts"), @@ -65,7 +65,7 @@ public async Task CheckDeviceUpdateNameAvailability_CheckNameAvailabilityAvailab SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - DeviceUpdateAvailabilityContent content = new DeviceUpdateAvailabilityContent() + DeviceUpdateAvailabilityContent content = new DeviceUpdateAvailabilityContent { Name = "contoso", CheckNameAvailabilityRequestType = new ResourceType("Microsoft.DeviceUpdate/accounts"), @@ -74,5 +74,36 @@ public async Task CheckDeviceUpdateNameAvailability_CheckNameAvailabilityAvailab Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeviceUpdateAccounts_GetListOfAccounts() + { + // Generated from example definition: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_List.json + // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeviceUpdateAccountResource item in subscriptionResource.GetDeviceUpdateAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceUpdateAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_DevOpsPoolCollection.cs b/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_DevOpsPoolCollection.cs index e623cb5200d67..c380856cbc2a1 100644 --- a/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_DevOpsPoolCollection.cs +++ b/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_DevOpsPoolCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DevOpsPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PoolsGet() + public async Task CreateOrUpdate_PoolsCreateOrUpdate() { - // Generated from example definition: 2024-10-19/GetPool.json - // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-10-19/CreateOrUpdatePool.json + // this example is just showing the usage of "Pool_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,24 @@ public async Task Get_PoolsGet() // invoke the operation string poolName = "pool"; - DevOpsPoolResource result = await collection.GetAsync(poolName); + DevOpsPoolData data = new DevOpsPoolData(new AzureLocation("eastus")) + { + Properties = new DevOpsPoolProperties(10, new DevOpsAzureOrganizationProfile(new DevOpsOrganization[] + { +new DevOpsOrganization(new Uri("https://mseng.visualstudio.com")) + }), new DevOpsStatelessAgentProfile(), new DevOpsVmssFabricProfile(new DevOpsAzureSku("Standard_D4ads_v5"), new DevOpsPoolVmImage[] + { +new DevOpsPoolVmImage +{ +ResourceId = "/MicrosoftWindowsServer/WindowsServer/2019-Datacenter/latest", +} + }), "/subscriptions/222e81d0-cf38-4dab-baa5-289bf16baaa4/resourceGroups/rg-1es-devcenter/providers/Microsoft.DevCenter/projects/1ES") + { + ProvisioningState = DevOpsInfrastructureProvisioningState.Succeeded, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data); + DevOpsPoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +69,7 @@ public async Task Get_PoolsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PoolsGet() + public async Task Get_PoolsGet() { // Generated from example definition: 2024-10-19/GetPool.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +91,21 @@ public async Task Exists_PoolsGet() // invoke the operation string poolName = "pool"; - bool result = await collection.ExistsAsync(poolName); + DevOpsPoolResource result = await collection.GetAsync(poolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PoolsGet() + public async Task GetAll_PoolsListByResourceGroup() { - // Generated from example definition: 2024-10-19/GetPool.json - // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-10-19/ListPoolsBySubscriptionAndResourceGroup.json + // this example is just showing the usage of "Pool_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +122,25 @@ public async Task GetIfExists_PoolsGet() // get the collection of this DevOpsPoolResource DevOpsPoolCollection collection = resourceGroupResource.GetDevOpsPools(); - // invoke the operation - string poolName = "pool"; - NullableResponse response = await collection.GetIfExistsAsync(poolName); - DevOpsPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DevOpsPoolResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DevOpsPoolData resourceData = result.Data; + DevOpsPoolData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PoolsCreateOrUpdate() + public async Task Exists_PoolsGet() { - // Generated from example definition: 2024-10-19/CreateOrUpdatePool.json - // this example is just showing the usage of "Pool_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-10-19/GetPool.json + // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,38 +159,17 @@ public async Task CreateOrUpdate_PoolsCreateOrUpdate() // invoke the operation string poolName = "pool"; - DevOpsPoolData data = new DevOpsPoolData(new AzureLocation("eastus")) - { - Properties = new DevOpsPoolProperties(10, new DevOpsAzureOrganizationProfile(new DevOpsOrganization[] - { -new DevOpsOrganization(new Uri("https://mseng.visualstudio.com")) - }), new DevOpsStatelessAgentProfile(), new DevOpsVmssFabricProfile(new DevOpsAzureSku("Standard_D4ads_v5"), new DevOpsPoolVmImage[] - { -new DevOpsPoolVmImage() -{ -ResourceId = "/MicrosoftWindowsServer/WindowsServer/2019-Datacenter/latest", -} - }), "/subscriptions/222e81d0-cf38-4dab-baa5-289bf16baaa4/resourceGroups/rg-1es-devcenter/providers/Microsoft.DevCenter/projects/1ES") - { - ProvisioningState = DevOpsInfrastructureProvisioningState.Succeeded, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data); - DevOpsPoolResource result = lro.Value; + bool result = await collection.ExistsAsync(poolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PoolsListByResourceGroup() + public async Task GetIfExists_PoolsGet() { - // Generated from example definition: 2024-10-19/ListPoolsBySubscriptionAndResourceGroup.json - // this example is just showing the usage of "Pool_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-10-19/GetPool.json + // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,17 +186,23 @@ public async Task GetAll_PoolsListByResourceGroup() // get the collection of this DevOpsPoolResource DevOpsPoolCollection collection = resourceGroupResource.GetDevOpsPools(); - // invoke the operation and iterate over the result - await foreach (DevOpsPoolResource item in collection.GetAllAsync()) + // invoke the operation + string poolName = "pool"; + NullableResponse response = await collection.GetIfExistsAsync(poolName); + DevOpsPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DevOpsPoolData resourceData = item.Data; + DevOpsPoolData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_DevOpsPoolResource.cs b/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_DevOpsPoolResource.cs index 7ceea60a8e4b3..a4b685804527a 100644 --- a/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_DevOpsPoolResource.cs +++ b/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_DevOpsPoolResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DevOpsInfrastructure.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DevOpsInfrastructure.Samples @@ -49,10 +48,10 @@ public async Task Get_PoolsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PoolsUpdate() + public async Task Delete_PoolsDelete() { - // Generated from example definition: 2024-10-19/UpdatePool.json - // this example is just showing the usage of "Pool_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-10-19/DeletePool.json + // this example is just showing the usage of "Pool_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,23 +67,17 @@ public async Task Update_PoolsUpdate() DevOpsPoolResource devOpsPool = client.GetDevOpsPoolResource(devOpsPoolResourceId); // invoke the operation - DevOpsPoolPatch patch = new DevOpsPoolPatch(); - ArmOperation lro = await devOpsPool.UpdateAsync(WaitUntil.Completed, patch); - DevOpsPoolResource result = lro.Value; + await devOpsPool.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PoolsDelete() + public async Task Update_PoolsUpdate() { - // Generated from example definition: 2024-10-19/DeletePool.json - // this example is just showing the usage of "Pool_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-10-19/UpdatePool.json + // this example is just showing the usage of "Pool_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,40 +93,15 @@ public async Task Delete_PoolsDelete() DevOpsPoolResource devOpsPool = client.GetDevOpsPoolResource(devOpsPoolResourceId); // invoke the operation - await devOpsPool.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDevOpsPools_PoolsListBySubscription() - { - // Generated from example definition: 2024-10-19/ListPoolsBySubscription.json - // this example is just showing the usage of "Pool_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "a2e95d27-c161-4b61-bda4-11512c14c2c2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DevOpsPoolResource item in subscriptionResource.GetDevOpsPoolsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DevOpsPoolPatch patch = new DevOpsPoolPatch(); + ArmOperation lro = await devOpsPool.UpdateAsync(WaitUntil.Completed, patch); + DevOpsPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index b2e44d0d2eaa6..97546467a4f79 100644 --- a/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/devopsinfrastructure/Azure.ResourceManager.DevOpsInfrastructure/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.DevOpsInfrastructure.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDevOpsPools_PoolsListBySubscription() + { + // Generated from example definition: 2024-10-19/ListPoolsBySubscription.json + // this example is just showing the usage of "Pool_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "a2e95d27-c161-4b61-bda4-11512c14c2c2"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DevOpsPoolResource item in subscriptionResource.GetDevOpsPoolsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetSkusByLocation_SkuListByLocation() diff --git a/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ControllerCollection.cs b/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ControllerCollection.cs index 6106d1ae12059..553dfbf8dd423 100644 --- a/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ControllerCollection.cs +++ b/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ControllerCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ControllerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ControllersGet() + public async Task CreateOrUpdate_ControllersCreate() { - // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersGet_example.json - // this example is just showing the usage of "Controllers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersCreate_example.json + // this example is just showing the usage of "Controllers_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_ControllersGet() // invoke the operation string name = "myControllerResource"; - ControllerResource result = await collection.GetAsync(name); + ControllerData data = new ControllerData(new AzureLocation("eastus"), new DevSpacesSku(DevSpacesSkuName.S1) + { + Tier = DevSpacesSkuTier.Standard, + }, "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myCluster", "QmFzZTY0IEVuY29kZWQgVmFsdWUK") + { + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + ControllerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_ControllersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ControllersGet() + public async Task Get_ControllersGet() { // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersGet_example.json // this example is just showing the usage of "Controllers_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +82,21 @@ public async Task Exists_ControllersGet() // invoke the operation string name = "myControllerResource"; - bool result = await collection.ExistsAsync(name); + ControllerResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ControllerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ControllersGet() + public async Task GetAll_ControllersListByResourceGroup() { - // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersGet_example.json - // this example is just showing the usage of "Controllers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersListByResourceGroup_example.json + // this example is just showing the usage of "Controllers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +113,25 @@ public async Task GetIfExists_ControllersGet() // get the collection of this ControllerResource ControllerCollection collection = resourceGroupResource.GetControllers(); - // invoke the operation - string name = "myControllerResource"; - NullableResponse response = await collection.GetIfExistsAsync(name); - ControllerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ControllerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ControllerData resourceData = result.Data; + ControllerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ControllersCreate() + public async Task Exists_ControllersGet() { - // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersCreate_example.json - // this example is just showing the usage of "Controllers_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersGet_example.json + // this example is just showing the usage of "Controllers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,31 +150,17 @@ public async Task CreateOrUpdate_ControllersCreate() // invoke the operation string name = "myControllerResource"; - ControllerData data = new ControllerData(new AzureLocation("eastus"), new DevSpacesSku(DevSpacesSkuName.S1) - { - Tier = DevSpacesSkuTier.Standard, - }, "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myCluster", "QmFzZTY0IEVuY29kZWQgVmFsdWUK") - { - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - ControllerResource result = lro.Value; + bool result = await collection.ExistsAsync(name); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ControllerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ControllersListByResourceGroup() + public async Task GetIfExists_ControllersGet() { - // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersListByResourceGroup_example.json - // this example is just showing the usage of "Controllers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersGet_example.json + // this example is just showing the usage of "Controllers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +177,23 @@ public async Task GetAll_ControllersListByResourceGroup() // get the collection of this ControllerResource ControllerCollection collection = resourceGroupResource.GetControllers(); - // invoke the operation and iterate over the result - await foreach (ControllerResource item in collection.GetAllAsync()) + // invoke the operation + string name = "myControllerResource"; + NullableResponse response = await collection.GetIfExistsAsync(name); + ControllerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ControllerData resourceData = item.Data; + ControllerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ControllerResource.cs b/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ControllerResource.cs index 640d5995316c1..7c634abf0607d 100644 --- a/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ControllerResource.cs +++ b/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ControllerResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DevSpaces.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DevSpaces.Samples @@ -94,11 +93,11 @@ public async Task Update_ControllersUpdate() ControllerResource controller = client.GetControllerResource(controllerResourceId); // invoke the operation - ControllerPatch patch = new ControllerPatch() + ControllerPatch patch = new ControllerPatch { Tags = { -["key"] = "value", +["key"] = "value" }, TargetContainerHostCredentialsBase64 = "QmFzZTY0IEVuY29kZWQgVmFsdWUK", }; @@ -111,37 +110,6 @@ public async Task Update_ControllersUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetControllers_ControllersList() - { - // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersList_example.json - // this example is just showing the usage of "Controllers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ControllerResource item in subscriptionResource.GetControllersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ControllerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetConnectionDetails_ControllersListConnectionDetails() diff --git a/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index 9dc4f2e003ff1..6c7a6b5b22674 100644 --- a/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -38,7 +38,7 @@ public async Task GetContainerHostMappingContainerHostMapping_ContainerHostMappi // invoke the operation AzureLocation location = new AzureLocation("eastus"); - ContainerHostMapping containerHostMapping = new ContainerHostMapping() + ContainerHostMapping containerHostMapping = new ContainerHostMapping { ContainerHostResourceId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerService/managedClusters/myCluster", }; diff --git a/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..56318e714cd4f --- /dev/null +++ b/sdk/devspaces/Azure.ResourceManager.DevSpaces/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.DevSpaces.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetControllers_ControllersList() + { + // Generated from example definition: specification/devspaces/resource-manager/Microsoft.DevSpaces/stable/2019-04-01/examples/ControllersList_example.json + // this example is just showing the usage of "Controllers_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ControllerResource item in subscriptionResource.GetControllersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ControllerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArmTemplateCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArmTemplateCollection.cs index 809afe4f8be28..b7422574dbcff 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArmTemplateCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArmTemplateCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DevTestLabArmTemplateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ArmTemplatesList() + public async Task Get_ArmTemplatesGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArmTemplates_List.json - // this example is just showing the usage of "ArmTemplates_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArmTemplates_Get.json + // this example is just showing the usage of "ArmTemplates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ArmTemplatesList() // get the collection of this DevTestLabArmTemplateResource DevTestLabArmTemplateCollection collection = devTestLabArtifactSource.GetDevTestLabArmTemplates(); - // invoke the operation and iterate over the result - await foreach (DevTestLabArmTemplateResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabArmTemplateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "{armTemplateName}"; + DevTestLabArmTemplateResource result = await collection.GetAsync(name); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabArmTemplateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ArmTemplatesGet() + public async Task GetAll_ArmTemplatesList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArmTemplates_Get.json - // this example is just showing the usage of "ArmTemplates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArmTemplates_List.json + // this example is just showing the usage of "ArmTemplates_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_ArmTemplatesGet() // get the collection of this DevTestLabArmTemplateResource DevTestLabArmTemplateCollection collection = devTestLabArtifactSource.GetDevTestLabArmTemplates(); - // invoke the operation - string name = "{armTemplateName}"; - DevTestLabArmTemplateResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabArmTemplateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabArmTemplateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabArmTemplateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactCollection.cs index 4a18de24cc413..bf7acbf564b38 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DevTestLabArtifactCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ArtifactsList() + public async Task Get_ArtifactsGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Artifacts_List.json - // this example is just showing the usage of "Artifacts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Artifacts_Get.json + // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ArtifactsList() // get the collection of this DevTestLabArtifactResource DevTestLabArtifactCollection collection = devTestLabArtifactSource.GetDevTestLabArtifacts(); - // invoke the operation and iterate over the result - await foreach (DevTestLabArtifactResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabArtifactData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "{artifactName}"; + DevTestLabArtifactResource result = await collection.GetAsync(name); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ArtifactsGet() + public async Task GetAll_ArtifactsList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Artifacts_Get.json - // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Artifacts_List.json + // this example is just showing the usage of "Artifacts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_ArtifactsGet() // get the collection of this DevTestLabArtifactResource DevTestLabArtifactCollection collection = devTestLabArtifactSource.GetDevTestLabArtifacts(); - // invoke the operation - string name = "{artifactName}"; - DevTestLabArtifactResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabArtifactResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabArtifactData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactResource.cs index 4510c79af37bc..4ebdeae344f30 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactResource.cs @@ -71,7 +71,7 @@ public async Task GenerateArmTemplate_ArtifactsGenerateArmTemplate() DevTestLabArtifactResource devTestLabArtifact = client.GetDevTestLabArtifactResource(devTestLabArtifactResourceId); // invoke the operation - DevTestLabArtifactGenerateArmTemplateContent content = new DevTestLabArtifactGenerateArmTemplateContent() + DevTestLabArtifactGenerateArmTemplateContent content = new DevTestLabArtifactGenerateArmTemplateContent { VmName = "{vmName}", Location = new AzureLocation("{location}"), diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactSourceCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactSourceCollection.cs index 57f3414ff3187..6936fcb6e2914 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactSourceCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactSourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabArtifactSourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ArtifactSourcesList() + public async Task CreateOrUpdate_ArtifactSourcesCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_List.json - // this example is just showing the usage of "ArtifactSources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_CreateOrUpdate.json + // this example is just showing the usage of "ArtifactSources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,31 @@ public async Task GetAll_ArtifactSourcesList() // get the collection of this DevTestLabArtifactSourceResource DevTestLabArtifactSourceCollection collection = devTestLab.GetDevTestLabArtifactSources(); - // invoke the operation and iterate over the result - await foreach (DevTestLabArtifactSourceResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{artifactSourceName}"; + DevTestLabArtifactSourceData data = new DevTestLabArtifactSourceData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabArtifactSourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "{displayName}", + Uri = new Uri("{artifactSourceUri}"), + SourceType = new DevTestLabSourceControlType("{VsoGit|GitHub|StorageAccount}"), + FolderPath = "{folderPath}", + ArmTemplateFolderPath = "{armTemplateFolderPath}", + BranchRef = "{branchRef}", + SecurityToken = "{securityToken}", + Status = new DevTestLabEnableStatus("{Enabled|Disabled}"), + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabArtifactSourceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabArtifactSourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +102,10 @@ public async Task Get_ArtifactSourcesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ArtifactSourcesGet() + public async Task GetAll_ArtifactSourcesList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_Get.json - // this example is just showing the usage of "ArtifactSources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_List.json + // this example is just showing the usage of "ArtifactSources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +123,22 @@ public async Task Exists_ArtifactSourcesGet() // get the collection of this DevTestLabArtifactSourceResource DevTestLabArtifactSourceCollection collection = devTestLab.GetDevTestLabArtifactSources(); - // invoke the operation - string name = "{artifactSourceName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabArtifactSourceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabArtifactSourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ArtifactSourcesGet() + public async Task Exists_ArtifactSourcesGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_Get.json // this example is just showing the usage of "ArtifactSources_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +161,17 @@ public async Task GetIfExists_ArtifactSourcesGet() // invoke the operation string name = "{artifactSourceName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabArtifactSourceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabArtifactSourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ArtifactSourcesCreateOrUpdate() + public async Task GetIfExists_ArtifactSourcesGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_CreateOrUpdate.json - // this example is just showing the usage of "ArtifactSources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ArtifactSources_Get.json + // this example is just showing the usage of "ArtifactSources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,29 +191,21 @@ public async Task CreateOrUpdate_ArtifactSourcesCreateOrUpdate() // invoke the operation string name = "{artifactSourceName}"; - DevTestLabArtifactSourceData data = new DevTestLabArtifactSourceData(new AzureLocation("placeholder")) - { - DisplayName = "{displayName}", - Uri = new Uri("{artifactSourceUri}"), - SourceType = new DevTestLabSourceControlType("{VsoGit|GitHub|StorageAccount}"), - FolderPath = "{folderPath}", - ArmTemplateFolderPath = "{armTemplateFolderPath}", - BranchRef = "{branchRef}", - SecurityToken = "{securityToken}", - Status = new DevTestLabEnableStatus("{Enabled|Disabled}"), - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabArtifactSourceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabArtifactSourceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabArtifactSourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabArtifactSourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactSourceResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactSourceResource.cs index 9b5fb51f37279..6a6f059245587 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactSourceResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabArtifactSourceResource.cs @@ -96,11 +96,11 @@ public async Task Update_ArtifactSourcesUpdate() DevTestLabArtifactSourceResource devTestLabArtifactSource = client.GetDevTestLabArtifactSourceResource(devTestLabArtifactSourceResourceId); // invoke the operation - DevTestLabArtifactSourcePatch patch = new DevTestLabArtifactSourcePatch() + DevTestLabArtifactSourcePatch patch = new DevTestLabArtifactSourcePatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabArtifactSourceResource result = await devTestLabArtifactSource.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCollection.cs index 6e6e30efc3c66..a369ddf3b72a0 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DevTestLabCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LabsListByResourceGroup() + public async Task CreateOrUpdate_LabsCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ListByResourceGroup.json - // this example is just showing the usage of "Labs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_CreateOrUpdate.json + // this example is just showing the usage of "Labs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_LabsListByResourceGroup() // get the collection of this DevTestLabResource DevTestLabCollection collection = resourceGroupResource.GetDevTestLabs(); - // invoke the operation and iterate over the result - await foreach (DevTestLabResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{labName}"; + DevTestLabData data = new DevTestLabData(new AzureLocation("{location}")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + LabStorageType = new DevTestLabStorageType("{Standard|Premium}"), + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +94,10 @@ public async Task Get_LabsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LabsGet() + public async Task GetAll_LabsListByResourceGroup() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_Get.json - // this example is just showing the usage of "Labs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ListByResourceGroup.json + // this example is just showing the usage of "Labs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +114,22 @@ public async Task Exists_LabsGet() // get the collection of this DevTestLabResource DevTestLabCollection collection = resourceGroupResource.GetDevTestLabs(); - // invoke the operation - string name = "{labName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LabsGet() + public async Task Exists_LabsGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_Get.json // this example is just showing the usage of "Labs_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +151,17 @@ public async Task GetIfExists_LabsGet() // invoke the operation string name = "{labName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LabsCreateOrUpdate() + public async Task GetIfExists_LabsGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_CreateOrUpdate.json - // this example is just showing the usage of "Labs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_Get.json + // this example is just showing the usage of "Labs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,22 +180,21 @@ public async Task CreateOrUpdate_LabsCreateOrUpdate() // invoke the operation string name = "{labName}"; - DevTestLabData data = new DevTestLabData(new AzureLocation("{location}")) - { - LabStorageType = new DevTestLabStorageType("{Standard|Premium}"), - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCostCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCostCollection.cs index be109d73d07f8..43bd66491ff37 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCostCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCostCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabCostCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CostsGet() + public async Task CreateOrUpdate_CostsCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Costs_Get.json - // this example is just showing the usage of "Costs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Costs_CreateOrUpdate.json + // this example is just showing the usage of "Costs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,53 @@ public async Task Get_CostsGet() // invoke the operation string name = "targetCost"; - DevTestLabCostResource result = await collection.GetAsync(name); + DevTestLabCostData data = new DevTestLabCostData(default) + { + TargetCost = new DevTestLabTargetCost + { + Status = DevTestLabTargetCostStatus.Enabled, + Target = 100, + CostThresholds = {new DevTestLabCostThreshold +{ +ThresholdId = "00000000-0000-0000-0000-000000000001", +ThresholdValue = 25, +DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, +SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, +}, new DevTestLabCostThreshold +{ +ThresholdId = "00000000-0000-0000-0000-000000000002", +ThresholdValue = 50, +DisplayOnChart = DevTestLabCostThresholdStatus.Enabled, +SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Enabled, +}, new DevTestLabCostThreshold +{ +ThresholdId = "00000000-0000-0000-0000-000000000003", +ThresholdValue = 75, +DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, +SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, +}, new DevTestLabCostThreshold +{ +ThresholdId = "00000000-0000-0000-0000-000000000004", +ThresholdValue = 100, +DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, +SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, +}, new DevTestLabCostThreshold +{ +ThresholdId = "00000000-0000-0000-0000-000000000005", +ThresholdValue = 125, +DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, +SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, +}}, + CycleStartOn = DateTimeOffset.Parse("2020-12-01T00:00:00.000Z"), + CycleEndOn = DateTimeOffset.Parse("2020-12-31T00:00:00.000Z"), + CycleType = DevTestLabReportingCycleType.CalendarMonth, + }, + CurrencyCode = "USD", + StartOn = DateTimeOffset.Parse("2020-12-01T00:00:00Z"), + EndOn = DateTimeOffset.Parse("2020-12-31T23:59:59Z"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabCostResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +98,7 @@ public async Task Get_CostsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CostsGet() + public async Task Get_CostsGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Costs_Get.json // this example is just showing the usage of "Costs_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,14 +121,18 @@ public async Task Exists_CostsGet() // invoke the operation string name = "targetCost"; - bool result = await collection.ExistsAsync(name); + DevTestLabCostResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabCostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CostsGet() + public async Task Exists_CostsGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Costs_Get.json // this example is just showing the usage of "Costs_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +155,17 @@ public async Task GetIfExists_CostsGet() // invoke the operation string name = "targetCost"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabCostResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabCostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CostsCreateOrUpdate() + public async Task GetIfExists_CostsGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Costs_CreateOrUpdate.json - // this example is just showing the usage of "Costs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Costs_Get.json + // this example is just showing the usage of "Costs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,62 +185,21 @@ public async Task CreateOrUpdate_CostsCreateOrUpdate() // invoke the operation string name = "targetCost"; - DevTestLabCostData data = new DevTestLabCostData(new AzureLocation("placeholder")) - { - TargetCost = new DevTestLabTargetCost() - { - Status = DevTestLabTargetCostStatus.Enabled, - Target = 100, - CostThresholds = -{ -new DevTestLabCostThreshold() -{ -ThresholdId = "00000000-0000-0000-0000-000000000001", -ThresholdValue = 25, -DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, -SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, -},new DevTestLabCostThreshold() -{ -ThresholdId = "00000000-0000-0000-0000-000000000002", -ThresholdValue = 50, -DisplayOnChart = DevTestLabCostThresholdStatus.Enabled, -SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Enabled, -},new DevTestLabCostThreshold() -{ -ThresholdId = "00000000-0000-0000-0000-000000000003", -ThresholdValue = 75, -DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, -SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, -},new DevTestLabCostThreshold() -{ -ThresholdId = "00000000-0000-0000-0000-000000000004", -ThresholdValue = 100, -DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, -SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, -},new DevTestLabCostThreshold() -{ -ThresholdId = "00000000-0000-0000-0000-000000000005", -ThresholdValue = 125, -DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, -SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, -} -}, - CycleStartOn = DateTimeOffset.Parse("2020-12-01T00:00:00.000Z"), - CycleEndOn = DateTimeOffset.Parse("2020-12-31T00:00:00.000Z"), - CycleType = DevTestLabReportingCycleType.CalendarMonth, - }, - CurrencyCode = "USD", - StartOn = DateTimeOffset.Parse("2020-12-01T00:00:00Z"), - EndOn = DateTimeOffset.Parse("2020-12-31T23:59:59Z"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabCostResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabCostResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabCostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabCostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCostResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCostResource.cs index 77812ab15ef41..f56a9e3a73126 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCostResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCostResource.cs @@ -69,46 +69,43 @@ public async Task Update_CostsCreateOrUpdate() DevTestLabCostResource devTestLabCost = client.GetDevTestLabCostResource(devTestLabCostResourceId); // invoke the operation - DevTestLabCostData data = new DevTestLabCostData(new AzureLocation("placeholder")) + DevTestLabCostData data = new DevTestLabCostData(default) { - TargetCost = new DevTestLabTargetCost() + TargetCost = new DevTestLabTargetCost { Status = DevTestLabTargetCostStatus.Enabled, Target = 100, - CostThresholds = -{ -new DevTestLabCostThreshold() + CostThresholds = {new DevTestLabCostThreshold { ThresholdId = "00000000-0000-0000-0000-000000000001", ThresholdValue = 25, DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, -},new DevTestLabCostThreshold() +}, new DevTestLabCostThreshold { ThresholdId = "00000000-0000-0000-0000-000000000002", ThresholdValue = 50, DisplayOnChart = DevTestLabCostThresholdStatus.Enabled, SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Enabled, -},new DevTestLabCostThreshold() +}, new DevTestLabCostThreshold { ThresholdId = "00000000-0000-0000-0000-000000000003", ThresholdValue = 75, DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, -},new DevTestLabCostThreshold() +}, new DevTestLabCostThreshold { ThresholdId = "00000000-0000-0000-0000-000000000004", ThresholdValue = 100, DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, -},new DevTestLabCostThreshold() +}, new DevTestLabCostThreshold { ThresholdId = "00000000-0000-0000-0000-000000000005", ThresholdValue = 125, DisplayOnChart = DevTestLabCostThresholdStatus.Disabled, SendNotificationWhenExceeded = DevTestLabCostThresholdStatus.Disabled, -} -}, +}}, CycleStartOn = DateTimeOffset.Parse("2020-12-01T00:00:00.000Z"), CycleEndOn = DateTimeOffset.Parse("2020-12-31T00:00:00.000Z"), CycleType = DevTestLabReportingCycleType.CalendarMonth, diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCustomImageCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCustomImageCollection.cs index 408300c166bef..561a27cbb93b3 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCustomImageCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCustomImageCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabCustomImageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CustomImagesList() + public async Task CreateOrUpdate_CustomImagesCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_List.json - // this example is just showing the usage of "CustomImages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_CreateOrUpdate.json + // this example is just showing the usage of "CustomImages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,29 @@ public async Task GetAll_CustomImagesList() // get the collection of this DevTestLabCustomImageResource DevTestLabCustomImageCollection collection = devTestLab.GetDevTestLabCustomImages(); - // invoke the operation and iterate over the result - await foreach (DevTestLabCustomImageResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{customImageName}"; + DevTestLabCustomImageData data = new DevTestLabCustomImageData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabCustomImageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Vm = new DevTestLabCustomImageVm + { + SourceVmId = "/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}", + LinuxOSState = DevTestLabLinuxOSState.NonDeprovisioned, + }, + Description = "My Custom Image", + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabCustomImageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabCustomImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +100,10 @@ public async Task Get_CustomImagesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CustomImagesGet() + public async Task GetAll_CustomImagesList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_Get.json - // this example is just showing the usage of "CustomImages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_List.json + // this example is just showing the usage of "CustomImages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +121,22 @@ public async Task Exists_CustomImagesGet() // get the collection of this DevTestLabCustomImageResource DevTestLabCustomImageCollection collection = devTestLab.GetDevTestLabCustomImages(); - // invoke the operation - string name = "{customImageName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabCustomImageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabCustomImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CustomImagesGet() + public async Task Exists_CustomImagesGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_Get.json // this example is just showing the usage of "CustomImages_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +159,17 @@ public async Task GetIfExists_CustomImagesGet() // invoke the operation string name = "{customImageName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabCustomImageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabCustomImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CustomImagesCreateOrUpdate() + public async Task GetIfExists_CustomImagesGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_CreateOrUpdate.json - // this example is just showing the usage of "CustomImages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/CustomImages_Get.json + // this example is just showing the usage of "CustomImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,27 +189,21 @@ public async Task CreateOrUpdate_CustomImagesCreateOrUpdate() // invoke the operation string name = "{customImageName}"; - DevTestLabCustomImageData data = new DevTestLabCustomImageData(new AzureLocation("placeholder")) - { - Vm = new DevTestLabCustomImageVm() - { - SourceVmId = "/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}", - LinuxOSState = DevTestLabLinuxOSState.NonDeprovisioned, - }, - Description = "My Custom Image", - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabCustomImageResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabCustomImageResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabCustomImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabCustomImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCustomImageResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCustomImageResource.cs index 4933225012bab..0ec9c1e88ccaf 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCustomImageResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabCustomImageResource.cs @@ -96,11 +96,11 @@ public async Task Update_CustomImagesUpdate() DevTestLabCustomImageResource devTestLabCustomImage = client.GetDevTestLabCustomImageResource(devTestLabCustomImageResourceId); // invoke the operation - DevTestLabCustomImagePatch patch = new DevTestLabCustomImagePatch() + DevTestLabCustomImagePatch patch = new DevTestLabCustomImagePatch { Tags = { -["tagName1"] = "tagValue2", +["tagName1"] = "tagValue2" }, }; DevTestLabCustomImageResource result = await devTestLabCustomImage.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabDiskCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabDiskCollection.cs index 02ce8a75fdee6..6b58e2b8e6c71 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabDiskCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabDiskCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabDiskCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DisksList() + public async Task CreateOrUpdate_DisksCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_List.json - // this example is just showing the usage of "Disks_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_CreateOrUpdate.json + // this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,24 +33,29 @@ public async Task GetAll_DisksList() string subscriptionId = "{subscriptionId}"; string resourceGroupName = "resourceGroupName"; string labName = "{labName}"; - string userName = "@me"; + string userName = "{userId}"; ResourceIdentifier devTestLabUserResourceId = DevTestLabUserResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, labName, userName); DevTestLabUserResource devTestLabUser = client.GetDevTestLabUserResource(devTestLabUserResourceId); // get the collection of this DevTestLabDiskResource DevTestLabDiskCollection collection = devTestLabUser.GetDevTestLabDisks(); - // invoke the operation and iterate over the result - await foreach (DevTestLabDiskResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{diskName}"; + DevTestLabDiskData data = new DevTestLabDiskData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabDiskData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DiskType = DevTestLabStorageType.Standard, + DiskSizeGiB = 1023, + LeasedByLabVmId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/vmName"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabDiskResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabDiskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +95,10 @@ public async Task Get_DisksGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DisksGet() + public async Task GetAll_DisksList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Get.json - // this example is just showing the usage of "Disks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_List.json + // this example is just showing the usage of "Disks_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +117,22 @@ public async Task Exists_DisksGet() // get the collection of this DevTestLabDiskResource DevTestLabDiskCollection collection = devTestLabUser.GetDevTestLabDisks(); - // invoke the operation - string name = "{diskName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabDiskResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabDiskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DisksGet() + public async Task Exists_DisksGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Get.json // this example is just showing the usage of "Disks_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +156,17 @@ public async Task GetIfExists_DisksGet() // invoke the operation string name = "{diskName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabDiskResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabDiskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DisksCreateOrUpdate() + public async Task GetIfExists_DisksGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_CreateOrUpdate.json - // this example is just showing the usage of "Disks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Disks_Get.json + // this example is just showing the usage of "Disks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,7 +178,7 @@ public async Task CreateOrUpdate_DisksCreateOrUpdate() string subscriptionId = "{subscriptionId}"; string resourceGroupName = "resourceGroupName"; string labName = "{labName}"; - string userName = "{userId}"; + string userName = "@me"; ResourceIdentifier devTestLabUserResourceId = DevTestLabUserResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, labName, userName); DevTestLabUserResource devTestLabUser = client.GetDevTestLabUserResource(devTestLabUserResourceId); @@ -188,20 +187,21 @@ public async Task CreateOrUpdate_DisksCreateOrUpdate() // invoke the operation string name = "{diskName}"; - DevTestLabDiskData data = new DevTestLabDiskData(new AzureLocation("placeholder")) - { - DiskType = DevTestLabStorageType.Standard, - DiskSizeGiB = 1023, - LeasedByLabVmId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/vmName"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabDiskResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabDiskResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabDiskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabDiskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabDiskResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabDiskResource.cs index ed5e6da53baaf..4c1fbbad487d5 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabDiskResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabDiskResource.cs @@ -99,11 +99,11 @@ public async Task Update_DisksUpdate() DevTestLabDiskResource devTestLabDisk = client.GetDevTestLabDiskResource(devTestLabDiskResourceId); // invoke the operation - DevTestLabDiskPatch patch = new DevTestLabDiskPatch() + DevTestLabDiskPatch patch = new DevTestLabDiskPatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabDiskResource result = await devTestLabDisk.UpdateAsync(patch); @@ -138,7 +138,7 @@ public async Task Attach_DisksAttach() DevTestLabDiskResource devTestLabDisk = client.GetDevTestLabDiskResource(devTestLabDiskResourceId); // invoke the operation - DevTestLabDiskAttachContent content = new DevTestLabDiskAttachContent() + DevTestLabDiskAttachContent content = new DevTestLabDiskAttachContent { LeasedByLabVmId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), }; @@ -170,7 +170,7 @@ public async Task Detach_DisksDetach() DevTestLabDiskResource devTestLabDisk = client.GetDevTestLabDiskResource(devTestLabDiskResourceId); // invoke the operation - DevTestLabDiskDetachContent content = new DevTestLabDiskDetachContent() + DevTestLabDiskDetachContent content = new DevTestLabDiskDetachContent { LeasedByLabVmId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourcegroups/myResourceGroup/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{vmName}"), }; diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabEnvironmentCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabEnvironmentCollection.cs index e1a388ba1089e..1d9e0210fd0e4 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabEnvironmentCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabEnvironmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabEnvironmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EnvironmentsList() + public async Task CreateOrUpdate_EnvironmentsCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_List.json - // this example is just showing the usage of "Environments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_CreateOrUpdate.json + // this example is just showing the usage of "Environments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,24 @@ public async Task GetAll_EnvironmentsList() // get the collection of this DevTestLabEnvironmentResource DevTestLabEnvironmentCollection collection = devTestLabUser.GetDevTestLabEnvironments(); - // invoke the operation and iterate over the result - await foreach (DevTestLabEnvironmentResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{environmentName}"; + DevTestLabEnvironmentData data = new DevTestLabEnvironmentData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DeploymentProperties = new DevTestLabEnvironmentDeployment + { + ArmTemplateId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/{artifactSourceName}/armTemplates/{armTemplateName}"), + Parameters = { }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabEnvironmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +97,10 @@ public async Task Get_EnvironmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EnvironmentsGet() + public async Task GetAll_EnvironmentsList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_Get.json - // this example is just showing the usage of "Environments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_List.json + // this example is just showing the usage of "Environments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +119,22 @@ public async Task Exists_EnvironmentsGet() // get the collection of this DevTestLabEnvironmentResource DevTestLabEnvironmentCollection collection = devTestLabUser.GetDevTestLabEnvironments(); - // invoke the operation - string name = "{environmentName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabEnvironmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EnvironmentsGet() + public async Task Exists_EnvironmentsGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_Get.json // this example is just showing the usage of "Environments_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +158,17 @@ public async Task GetIfExists_EnvironmentsGet() // invoke the operation string name = "{environmentName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabEnvironmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EnvironmentsCreateOrUpdate() + public async Task GetIfExists_EnvironmentsGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_CreateOrUpdate.json - // this example is just showing the usage of "Environments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Environments_Get.json + // this example is just showing the usage of "Environments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,24 +189,21 @@ public async Task CreateOrUpdate_EnvironmentsCreateOrUpdate() // invoke the operation string name = "{environmentName}"; - DevTestLabEnvironmentData data = new DevTestLabEnvironmentData(new AzureLocation("placeholder")) - { - DeploymentProperties = new DevTestLabEnvironmentDeployment() - { - ArmTemplateId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/{artifactSourceName}/armTemplates/{armTemplateName}"), - Parameters = -{ -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabEnvironmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabEnvironmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabEnvironmentResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabEnvironmentResource.cs index 5d2c3d6453829..20953ca93ba4e 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabEnvironmentResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabEnvironmentResource.cs @@ -99,11 +99,11 @@ public async Task Update_EnvironmentsUpdate() DevTestLabEnvironmentResource devTestLabEnvironment = client.GetDevTestLabEnvironmentResource(devTestLabEnvironmentResourceId); // invoke the operation - DevTestLabEnvironmentPatch patch = new DevTestLabEnvironmentPatch() + DevTestLabEnvironmentPatch patch = new DevTestLabEnvironmentPatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabEnvironmentResource result = await devTestLabEnvironment.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabFormulaCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabFormulaCollection.cs index 4495fd702ebe9..388d897c95108 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabFormulaCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabFormulaCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabFormulaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FormulasList() + public async Task CreateOrUpdate_FormulasCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_List.json - // this example is just showing the usage of "Formulas_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_CreateOrUpdate.json + // this example is just showing the usage of "Formulas_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,54 @@ public async Task GetAll_FormulasList() // get the collection of this DevTestLabFormulaResource DevTestLabFormulaCollection collection = devTestLab.GetDevTestLabFormulas(); - // invoke the operation and iterate over the result - await foreach (DevTestLabFormulaResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{formulaName}"; + DevTestLabFormulaData data = new DevTestLabFormulaData(new AzureLocation("{location}")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabFormulaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "Formula using a Linux base", + FormulaContent = new DevTestLabVmCreationContent + { + Location = new AzureLocation("{location}"), + Notes = "Ubuntu Server 20.10", + Size = "Standard_B1ms", + UserName = "user", + IsAuthenticationWithSshKey = false, + LabSubnetName = "Dtl{labName}Subnet", + LabVirtualNetworkId = new ResourceIdentifier("/virtualnetworks/dtl{labName}"), + DisallowPublicIPAddress = true, + Artifacts = {new DevTestLabArtifactInstallInfo +{ +ArtifactId = "/artifactsources/{artifactSourceName}/artifacts/linux-install-nodejs", +Parameters = {}, +}}, + GalleryImageReference = new DevTestLabGalleryImageReference + { + Offer = "0001-com-ubuntu-server-groovy", + Publisher = "canonical", + Sku = "20_10", + OSType = "Linux", + Version = "latest", + }, + NetworkInterface = new DevTestLabNetworkInterface + { + SharedPublicIPAddressInboundNatRules = {new DevTestLabInboundNatRule +{ +TransportProtocol = DevTestLabTransportProtocol.Tcp, +BackendPort = 22, +}}, + }, + AllowClaim = false, + StorageType = "Standard", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabFormulaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabFormulaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +125,10 @@ public async Task Get_FormulasGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FormulasGet() + public async Task GetAll_FormulasList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_Get.json - // this example is just showing the usage of "Formulas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_List.json + // this example is just showing the usage of "Formulas_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +146,22 @@ public async Task Exists_FormulasGet() // get the collection of this DevTestLabFormulaResource DevTestLabFormulaCollection collection = devTestLab.GetDevTestLabFormulas(); - // invoke the operation - string name = "{formulaName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabFormulaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabFormulaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FormulasGet() + public async Task Exists_FormulasGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_Get.json // this example is just showing the usage of "Formulas_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +184,17 @@ public async Task GetIfExists_FormulasGet() // invoke the operation string name = "{formulaName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabFormulaResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabFormulaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FormulasCreateOrUpdate() + public async Task GetIfExists_FormulasGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_CreateOrUpdate.json - // this example is just showing the usage of "Formulas_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Formulas_Get.json + // this example is just showing the usage of "Formulas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,60 +214,21 @@ public async Task CreateOrUpdate_FormulasCreateOrUpdate() // invoke the operation string name = "{formulaName}"; - DevTestLabFormulaData data = new DevTestLabFormulaData(new AzureLocation("{location}")) - { - Description = "Formula using a Linux base", - FormulaContent = new DevTestLabVmCreationContent() - { - Location = new AzureLocation("{location}"), - Notes = "Ubuntu Server 20.10", - Size = "Standard_B1ms", - UserName = "user", - IsAuthenticationWithSshKey = false, - LabSubnetName = "Dtl{labName}Subnet", - LabVirtualNetworkId = new ResourceIdentifier("/virtualnetworks/dtl{labName}"), - DisallowPublicIPAddress = true, - Artifacts = -{ -new DevTestLabArtifactInstallInfo() -{ -ArtifactId = "/artifactsources/{artifactSourceName}/artifacts/linux-install-nodejs", -Parameters = -{ -}, -} -}, - GalleryImageReference = new DevTestLabGalleryImageReference() - { - Offer = "0001-com-ubuntu-server-groovy", - Publisher = "canonical", - Sku = "20_10", - OSType = "Linux", - Version = "latest", - }, - NetworkInterface = new DevTestLabNetworkInterface() - { - SharedPublicIPAddressInboundNatRules = -{ -new DevTestLabInboundNatRule() -{ -TransportProtocol = DevTestLabTransportProtocol.Tcp, -BackendPort = 22, -} -}, - }, - AllowClaim = false, - StorageType = "Standard", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabFormulaResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabFormulaResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabFormulaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabFormulaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabFormulaResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabFormulaResource.cs index 5c3ee22728c0c..347defaa51744 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabFormulaResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabFormulaResource.cs @@ -96,11 +96,11 @@ public async Task Update_FormulasUpdate() DevTestLabFormulaResource devTestLabFormula = client.GetDevTestLabFormulaResource(devTestLabFormulaResourceId); // invoke the operation - DevTestLabFormulaPatch patch = new DevTestLabFormulaPatch() + DevTestLabFormulaPatch patch = new DevTestLabFormulaPatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabFormulaResource result = await devTestLabFormula.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabGlobalScheduleCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabGlobalScheduleCollection.cs index c8a20b26348b1..8b9d734555586 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabGlobalScheduleCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabGlobalScheduleCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DevTestLabGlobalScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GlobalSchedulesListByResourceGroup() + public async Task CreateOrUpdate_GlobalSchedulesCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_ListByResourceGroup.json - // this example is just showing the usage of "GlobalSchedules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_CreateOrUpdate.json + // this example is just showing the usage of "GlobalSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,27 @@ public async Task GetAll_GlobalSchedulesListByResourceGroup() // get the collection of this DevTestLabGlobalScheduleResource DevTestLabGlobalScheduleCollection collection = resourceGroupResource.GetDevTestLabGlobalSchedules(); - // invoke the operation and iterate over the result - await foreach (DevTestLabGlobalScheduleResource item in collection.GetAllAsync()) + // invoke the operation + string name = "labvmautostart"; + DevTestLabScheduleData data = new DevTestLabScheduleData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Status = DevTestLabEnableStatus.Enabled, + TaskType = "LabVmsStartupTask", + WeeklyRecurrence = new DevTestLabWeekDetails + { + Weekdays = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }, + Time = "0700", + }, + TimeZoneId = "Hawaiian Standard Time", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabGlobalScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +97,10 @@ public async Task Get_GlobalSchedulesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GlobalSchedulesGet() + public async Task GetAll_GlobalSchedulesListByResourceGroup() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Get.json - // this example is just showing the usage of "GlobalSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_ListByResourceGroup.json + // this example is just showing the usage of "GlobalSchedules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +117,22 @@ public async Task Exists_GlobalSchedulesGet() // get the collection of this DevTestLabGlobalScheduleResource DevTestLabGlobalScheduleCollection collection = resourceGroupResource.GetDevTestLabGlobalSchedules(); - // invoke the operation - string name = "labvmautostart"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabGlobalScheduleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GlobalSchedulesGet() + public async Task Exists_GlobalSchedulesGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Get.json // this example is just showing the usage of "GlobalSchedules_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +154,17 @@ public async Task GetIfExists_GlobalSchedulesGet() // invoke the operation string name = "labvmautostart"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabGlobalScheduleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GlobalSchedulesCreateOrUpdate() + public async Task GetIfExists_GlobalSchedulesGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_CreateOrUpdate.json - // this example is just showing the usage of "GlobalSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_Get.json + // this example is just showing the usage of "GlobalSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,28 +183,21 @@ public async Task CreateOrUpdate_GlobalSchedulesCreateOrUpdate() // invoke the operation string name = "labvmautostart"; - DevTestLabScheduleData data = new DevTestLabScheduleData(new AzureLocation("placeholder")) - { - Status = DevTestLabEnableStatus.Enabled, - TaskType = "LabVmsStartupTask", - WeeklyRecurrence = new DevTestLabWeekDetails() - { - Weekdays = -{ -"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday" -}, - Time = "0700", - }, - TimeZoneId = "Hawaiian Standard Time", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabGlobalScheduleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabGlobalScheduleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabGlobalScheduleResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabGlobalScheduleResource.cs index 662a5f89200c2..0f81f8daac1af 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabGlobalScheduleResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabGlobalScheduleResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DevTestLabs.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DevTestLabs.Samples { public partial class Sample_DevTestLabGlobalScheduleResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDevTestLabGlobalSchedules_GlobalSchedulesListBySubscription() - { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_ListBySubscription.json - // this example is just showing the usage of "GlobalSchedules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscriptionId}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DevTestLabGlobalScheduleResource item in subscriptionResource.GetDevTestLabGlobalSchedulesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GlobalSchedulesGet() @@ -125,11 +93,11 @@ public async Task Update_GlobalSchedulesUpdate() DevTestLabGlobalScheduleResource devTestLabGlobalSchedule = client.GetDevTestLabGlobalScheduleResource(devTestLabGlobalScheduleResourceId); // invoke the operation - DevTestLabSchedulePatch patch = new DevTestLabSchedulePatch() + DevTestLabSchedulePatch patch = new DevTestLabSchedulePatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabGlobalScheduleResource result = await devTestLabGlobalSchedule.UpdateAsync(patch); @@ -188,7 +156,7 @@ public async Task Retarget_GlobalSchedulesRetarget() DevTestLabGlobalScheduleResource devTestLabGlobalSchedule = client.GetDevTestLabGlobalScheduleResource(devTestLabGlobalScheduleResourceId); // invoke the operation - DevTestLabGlobalScheduleRetargetContent content = new DevTestLabGlobalScheduleRetargetContent() + DevTestLabGlobalScheduleRetargetContent content = new DevTestLabGlobalScheduleRetargetContent { CurrentResourceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{targetLab}"), TargetResourceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{currentLab}"), diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabNotificationChannelCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabNotificationChannelCollection.cs index cb9722ad4e8ea..fb196aff40910 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabNotificationChannelCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabNotificationChannelCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabNotificationChannelCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NotificationChannelsList() + public async Task CreateOrUpdate_NotificationChannelsCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_List.json - // this example is just showing the usage of "NotificationChannels_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_CreateOrUpdate.json + // this example is just showing the usage of "NotificationChannels_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,27 @@ public async Task GetAll_NotificationChannelsList() // get the collection of this DevTestLabNotificationChannelResource DevTestLabNotificationChannelCollection collection = devTestLab.GetDevTestLabNotificationChannels(); - // invoke the operation and iterate over the result - await foreach (DevTestLabNotificationChannelResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{notificationChannelName}"; + DevTestLabNotificationChannelData data = new DevTestLabNotificationChannelData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabNotificationChannelData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + WebHookUri = new Uri("{webhookUrl}"), + EmailRecipient = "{email}", + NotificationLocale = "en", + Description = "Integration configured for auto-shutdown", + Events = {new DevTestLabNotificationChannelEvent +{ +EventName = DevTestLabNotificationChannelEventType.AutoShutdown, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabNotificationChannelResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabNotificationChannelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +98,10 @@ public async Task Get_NotificationChannelsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NotificationChannelsGet() + public async Task GetAll_NotificationChannelsList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Get.json - // this example is just showing the usage of "NotificationChannels_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_List.json + // this example is just showing the usage of "NotificationChannels_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +119,22 @@ public async Task Exists_NotificationChannelsGet() // get the collection of this DevTestLabNotificationChannelResource DevTestLabNotificationChannelCollection collection = devTestLab.GetDevTestLabNotificationChannels(); - // invoke the operation - string name = "{notificationChannelName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabNotificationChannelResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabNotificationChannelData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NotificationChannelsGet() + public async Task Exists_NotificationChannelsGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Get.json // this example is just showing the usage of "NotificationChannels_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +157,17 @@ public async Task GetIfExists_NotificationChannelsGet() // invoke the operation string name = "{notificationChannelName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabNotificationChannelResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabNotificationChannelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NotificationChannelsCreateOrUpdate() + public async Task GetIfExists_NotificationChannelsGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_CreateOrUpdate.json - // this example is just showing the usage of "NotificationChannels_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/NotificationChannels_Get.json + // this example is just showing the usage of "NotificationChannels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,28 +187,21 @@ public async Task CreateOrUpdate_NotificationChannelsCreateOrUpdate() // invoke the operation string name = "{notificationChannelName}"; - DevTestLabNotificationChannelData data = new DevTestLabNotificationChannelData(new AzureLocation("placeholder")) - { - WebHookUri = new Uri("{webhookUrl}"), - EmailRecipient = "{email}", - NotificationLocale = "en", - Description = "Integration configured for auto-shutdown", - Events = -{ -new DevTestLabNotificationChannelEvent() -{ -EventName = DevTestLabNotificationChannelEventType.AutoShutdown, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabNotificationChannelResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabNotificationChannelResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabNotificationChannelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabNotificationChannelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabNotificationChannelResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabNotificationChannelResource.cs index 05aa8e6b08ddd..2176f18ab66d7 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabNotificationChannelResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabNotificationChannelResource.cs @@ -128,7 +128,7 @@ public async Task Notify_NotificationChannelsNotify() DevTestLabNotificationChannelResource devTestLabNotificationChannel = client.GetDevTestLabNotificationChannelResource(devTestLabNotificationChannelResourceId); // invoke the operation - DevTestLabNotificationChannelNotifyContent content = new DevTestLabNotificationChannelNotifyContent() + DevTestLabNotificationChannelNotifyContent content = new DevTestLabNotificationChannelNotifyContent { EventName = DevTestLabNotificationChannelEventType.AutoShutdown, JsonPayload = "{\"eventType\":\"AutoShutdown\",\"subscriptionId\":\"{subscriptionId}\",\"resourceGroupName\":\"resourceGroupName\",\"labName\":\"{labName}\"}", diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabPolicyCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabPolicyCollection.cs index 4970af76ebe8a..1e3e980dac4ee 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabPolicyCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PoliciesList() + public async Task CreateOrUpdate_PoliciesCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_List.json - // this example is just showing the usage of "Policies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_CreateOrUpdate.json + // this example is just showing the usage of "Policies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,29 @@ public async Task GetAll_PoliciesList() string policySetName = "{policySetName}"; DevTestLabPolicyCollection collection = devTestLab.GetDevTestLabPolicies(policySetName); - // invoke the operation and iterate over the result - await foreach (DevTestLabPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{policyName}"; + DevTestLabPolicyData data = new DevTestLabPolicyData(new AzureLocation("{location}")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "{policyDescription}", + Status = new DevTestLabPolicyStatus("{policyStatus}"), + FactName = new DevTestLabPolicyFactName("{policyFactName}"), + FactData = "{policyFactData}", + Threshold = "{policyThreshold}", + EvaluatorType = new DevTestLabPolicyEvaluatorType("{policyEvaluatorType}"), + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +102,10 @@ public async Task Get_PoliciesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PoliciesGet() + public async Task GetAll_PoliciesList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_Get.json - // this example is just showing the usage of "Policies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_List.json + // this example is just showing the usage of "Policies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +124,22 @@ public async Task Exists_PoliciesGet() string policySetName = "{policySetName}"; DevTestLabPolicyCollection collection = devTestLab.GetDevTestLabPolicies(policySetName); - // invoke the operation - string name = "{policyName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PoliciesGet() + public async Task Exists_PoliciesGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_Get.json // this example is just showing the usage of "Policies_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +163,17 @@ public async Task GetIfExists_PoliciesGet() // invoke the operation string name = "{policyName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PoliciesCreateOrUpdate() + public async Task GetIfExists_PoliciesGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_CreateOrUpdate.json - // this example is just showing the usage of "Policies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Policies_Get.json + // this example is just showing the usage of "Policies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,27 +194,21 @@ public async Task CreateOrUpdate_PoliciesCreateOrUpdate() // invoke the operation string name = "{policyName}"; - DevTestLabPolicyData data = new DevTestLabPolicyData(new AzureLocation("{location}")) - { - Description = "{policyDescription}", - Status = new DevTestLabPolicyStatus("{policyStatus}"), - FactName = new DevTestLabPolicyFactName("{policyFactName}"), - FactData = "{policyFactData}", - Threshold = "{policyThreshold}", - EvaluatorType = new DevTestLabPolicyEvaluatorType("{policyEvaluatorType}"), - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabPolicyResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabPolicyResource.cs index b2130d148d2ae..e4c7067066690 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabPolicyResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabPolicyResource.cs @@ -99,11 +99,11 @@ public async Task Update_PoliciesUpdate() DevTestLabPolicyResource devTestLabPolicy = client.GetDevTestLabPolicyResource(devTestLabPolicyResourceId); // invoke the operation - DevTestLabPolicyPatch patch = new DevTestLabPolicyPatch() + DevTestLabPolicyPatch patch = new DevTestLabPolicyPatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabPolicyResource result = await devTestLabPolicy.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabResource.cs index ed5c4b4135045..baee226c9e2f8 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DevTestLabs.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using NUnit.Framework; @@ -18,37 +17,6 @@ namespace Azure.ResourceManager.DevTestLabs.Samples { public partial class Sample_DevTestLabResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDevTestLabs_LabsListBySubscription() - { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ListBySubscription.json - // this example is just showing the usage of "Labs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscriptionId}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DevTestLabResource item in subscriptionResource.GetDevTestLabsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_LabsGet() @@ -183,13 +151,13 @@ public async Task CreateEnvironment_LabsCreateEnvironment() DevTestLabResource devTestLab = client.GetDevTestLabResource(devTestLabResourceId); // invoke the operation - DevTestLabVmCreationContent content = new DevTestLabVmCreationContent() + DevTestLabVmCreationContent content = new DevTestLabVmCreationContent { Name = "{vmName}", Location = new AzureLocation("{location}"), Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, Size = "Standard_A2_v2", UserName = "{userName}", @@ -197,7 +165,7 @@ public async Task CreateEnvironment_LabsCreateEnvironment() LabSubnetName = "{virtualnetwork-subnet-name}", LabVirtualNetworkId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), DisallowPublicIPAddress = true, - GalleryImageReference = new DevTestLabGalleryImageReference() + GalleryImageReference = new DevTestLabGalleryImageReference { Offer = "UbuntuServer", Publisher = "Canonical", @@ -234,7 +202,7 @@ public async Task ExportResourceUsage_LabsExportResourceUsage() DevTestLabResource devTestLab = client.GetDevTestLabResource(devTestLabResourceId); // invoke the operation - DevTestLabExportResourceUsageContent content = new DevTestLabExportResourceUsageContent() + DevTestLabExportResourceUsageContent content = new DevTestLabExportResourceUsageContent { BlobStorageAbsoluteSasUri = new Uri("https://invalid.blob.core.windows.net/export.blob?sv=2015-07-08&sig={sas}&sp=rcw"), UsageStartOn = DateTimeOffset.Parse("2020-12-01T00:00:00Z"), @@ -265,7 +233,7 @@ public async Task GenerateUploadUri_LabsGenerateUploadUri() DevTestLabResource devTestLab = client.GetDevTestLabResource(devTestLabResourceId); // invoke the operation - DevTestLabGenerateUploadUriContent content = new DevTestLabGenerateUploadUriContent() + DevTestLabGenerateUploadUriContent content = new DevTestLabGenerateUploadUriContent { BlobName = "{blob-name}", }; @@ -295,7 +263,7 @@ public async Task ImportVm_LabsImportVirtualMachine() DevTestLabResource devTestLab = client.GetDevTestLabResource(devTestLabResourceId); // invoke the operation - DevTestLabImportVmContent content = new DevTestLabImportVmContent() + DevTestLabImportVmContent content = new DevTestLabImportVmContent { SourceVmResourceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{otherResourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"), DestinationVmName = "{vmName}", @@ -385,16 +353,13 @@ public async Task EvaluatePolicies_PolicySetsEvaluatePolicies() // invoke the operation string name = "{policySetName}"; - DevTestLabEvaluatePoliciesContent content = new DevTestLabEvaluatePoliciesContent() + DevTestLabEvaluatePoliciesContent content = new DevTestLabEvaluatePoliciesContent { - Policies = -{ -new DevTestLabEvaluatePolicy() + Policies = {new DevTestLabEvaluatePolicy { FactName = "LabVmCount", ValueOffset = "1", -} -}, +}}, }; DevTestLabEvaluatePoliciesResult result = await devTestLab.EvaluatePoliciesAsync(name, content); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabScheduleCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabScheduleCollection.cs index cc2bde5055f98..c6bd82cd87730 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabScheduleCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabScheduleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SchedulesList() + public async Task CreateOrUpdate_SchedulesCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_List.json - // this example is just showing the usage of "Schedules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_CreateOrUpdate.json + // this example is just showing the usage of "Schedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,42 @@ public async Task GetAll_SchedulesList() // get the collection of this DevTestLabScheduleResource DevTestLabScheduleCollection collection = devTestLab.GetDevTestLabSchedules(); - // invoke the operation and iterate over the result - await foreach (DevTestLabScheduleResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{scheduleName}"; + DevTestLabScheduleData data = new DevTestLabScheduleData(new AzureLocation("{location}")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Status = new DevTestLabEnableStatus("{Enabled|Disabled}"), + TaskType = "{myLabVmTaskType}", + WeeklyRecurrence = new DevTestLabWeekDetails + { + Weekdays = { "Monday", "Wednesday", "Friday" }, + Time = "{timeOfTheDayTheScheduleWillOccurOnThoseDays}", + }, + DailyRecurrenceTime = "{timeOfTheDayTheScheduleWillOccurEveryDay}", + HourlyRecurrenceMinute = 30, + TimeZoneId = "Pacific Standard Time", + NotificationSettings = new DevTestLabNotificationSettings + { + Status = new DevTestLabEnableStatus("{Enabled|Disabled}"), + TimeInMinutes = 15, + WebhookUri = new Uri("{webhookUrl}"), + EmailRecipient = "{email}", + NotificationLocale = "EN", + }, + TargetResourceId = "/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}", + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +113,10 @@ public async Task Get_SchedulesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SchedulesGet() + public async Task GetAll_SchedulesList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Get.json - // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_List.json + // this example is just showing the usage of "Schedules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,19 +134,25 @@ public async Task Exists_SchedulesGet() // get the collection of this DevTestLabScheduleResource DevTestLabScheduleCollection collection = devTestLab.GetDevTestLabSchedules(); - // invoke the operation - string name = "{scheduleName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabScheduleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SchedulesGet() + public async Task GetApplicable_SchedulesListApplicable() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Get.json - // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_ListApplicable.json + // this example is just showing the usage of "Schedules_ListApplicable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +170,26 @@ public async Task GetIfExists_SchedulesGet() // get the collection of this DevTestLabScheduleResource DevTestLabScheduleCollection collection = devTestLab.GetDevTestLabSchedules(); - // invoke the operation + // invoke the operation and iterate over the result string name = "{scheduleName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabScheduleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + await foreach (DevTestLabScheduleResource item in collection.GetApplicableAsync(name)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = result.Data; + DevTestLabScheduleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SchedulesCreateOrUpdate() + public async Task Exists_SchedulesGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_CreateOrUpdate.json - // this example is just showing the usage of "Schedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Get.json + // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,51 +209,17 @@ public async Task CreateOrUpdate_SchedulesCreateOrUpdate() // invoke the operation string name = "{scheduleName}"; - DevTestLabScheduleData data = new DevTestLabScheduleData(new AzureLocation("{location}")) - { - Status = new DevTestLabEnableStatus("{Enabled|Disabled}"), - TaskType = "{myLabVmTaskType}", - WeeklyRecurrence = new DevTestLabWeekDetails() - { - Weekdays = -{ -"Monday","Wednesday","Friday" -}, - Time = "{timeOfTheDayTheScheduleWillOccurOnThoseDays}", - }, - DailyRecurrenceTime = "{timeOfTheDayTheScheduleWillOccurEveryDay}", - HourlyRecurrenceMinute = 30, - TimeZoneId = "Pacific Standard Time", - NotificationSettings = new DevTestLabNotificationSettings() - { - Status = new DevTestLabEnableStatus("{Enabled|Disabled}"), - TimeInMinutes = 15, - WebhookUri = new Uri("{webhookUrl}"), - EmailRecipient = "{email}", - NotificationLocale = "EN", - }, - TargetResourceId = "/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}", - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabScheduleResource result = lro.Value; + bool result = await collection.ExistsAsync(name); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetApplicable_SchedulesListApplicable() + public async Task GetIfExists_SchedulesGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_ListApplicable.json - // this example is just showing the usage of "Schedules_ListApplicable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Schedules_Get.json + // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -245,18 +237,23 @@ public async Task GetApplicable_SchedulesListApplicable() // get the collection of this DevTestLabScheduleResource DevTestLabScheduleCollection collection = devTestLab.GetDevTestLabSchedules(); - // invoke the operation and iterate over the result + // invoke the operation string name = "{scheduleName}"; - await foreach (DevTestLabScheduleResource item in collection.GetApplicableAsync(name)) + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabScheduleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = item.Data; + DevTestLabScheduleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabScheduleResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabScheduleResource.cs index a6cb39fd17f7d..5e1cddfb7fcce 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabScheduleResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabScheduleResource.cs @@ -96,11 +96,11 @@ public async Task Update_SchedulesUpdate() DevTestLabScheduleResource devTestLabSchedule = client.GetDevTestLabScheduleResource(devTestLabScheduleResourceId); // invoke the operation - DevTestLabSchedulePatch patch = new DevTestLabSchedulePatch() + DevTestLabSchedulePatch patch = new DevTestLabSchedulePatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabScheduleResource result = await devTestLabSchedule.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabSecretCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabSecretCollection.cs index 29f04969d7640..07a25deeeb0a0 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabSecretCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabSecretCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DevTestLabSecretCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SecretsList() + public async Task CreateOrUpdate_SecretsCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_List.json - // this example is just showing the usage of "Secrets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_CreateOrUpdate.json + // this example is just showing the usage of "Secrets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_SecretsList() // get the collection of this DevTestLabSecretResource DevTestLabSecretCollection collection = devTestLabUser.GetDevTestLabSecrets(); - // invoke the operation and iterate over the result - await foreach (DevTestLabSecretResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{secretName}"; + DevTestLabSecretData data = new DevTestLabSecretData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabSecretData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = "{secret}", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabSecretResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabSecretData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_SecretsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SecretsGet() + public async Task GetAll_SecretsList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_Get.json - // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_List.json + // this example is just showing the usage of "Secrets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +114,22 @@ public async Task Exists_SecretsGet() // get the collection of this DevTestLabSecretResource DevTestLabSecretCollection collection = devTestLabUser.GetDevTestLabSecrets(); - // invoke the operation - string name = "{secretName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabSecretResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabSecretData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SecretsGet() + public async Task Exists_SecretsGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_Get.json // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +153,17 @@ public async Task GetIfExists_SecretsGet() // invoke the operation string name = "{secretName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabSecretResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabSecretData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SecretsCreateOrUpdate() + public async Task GetIfExists_SecretsGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_CreateOrUpdate.json - // this example is just showing the usage of "Secrets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Secrets_Get.json + // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +184,21 @@ public async Task CreateOrUpdate_SecretsCreateOrUpdate() // invoke the operation string name = "{secretName}"; - DevTestLabSecretData data = new DevTestLabSecretData(new AzureLocation("placeholder")) - { - Value = "{secret}", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabSecretResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabSecretResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabSecretData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabSecretData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabSecretResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabSecretResource.cs index 5af0b8f53e5bf..a99bdaffae16d 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabSecretResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabSecretResource.cs @@ -99,11 +99,11 @@ public async Task Update_SecretsUpdate() DevTestLabSecretResource devTestLabSecret = client.GetDevTestLabSecretResource(devTestLabSecretResourceId); // invoke the operation - DevTestLabSecretPatch patch = new DevTestLabSecretPatch() + DevTestLabSecretPatch patch = new DevTestLabSecretPatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabSecretResource result = await devTestLabSecret.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricCollection.cs index cdd6d0b8bfbed..5925daf97003c 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DevTestLabServiceFabricCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServiceFabricsList() + public async Task CreateOrUpdate_ServiceFabricsCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_List.json - // this example is just showing the usage of "ServiceFabrics_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_CreateOrUpdate.json + // this example is just showing the usage of "ServiceFabrics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ServiceFabricsList() // get the collection of this DevTestLabServiceFabricResource DevTestLabServiceFabricCollection collection = devTestLabUser.GetDevTestLabServiceFabrics(); - // invoke the operation and iterate over the result - await foreach (DevTestLabServiceFabricResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{serviceFabricName}"; + DevTestLabServiceFabricData data = new DevTestLabServiceFabricData(new AzureLocation("{location}")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabServiceFabricData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ExternalServiceFabricId = "{serviceFabricId}", + EnvironmentId = "{environmentId}", + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabServiceFabricResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabServiceFabricData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +97,10 @@ public async Task Get_ServiceFabricsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServiceFabricsGet() + public async Task GetAll_ServiceFabricsList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Get.json - // this example is just showing the usage of "ServiceFabrics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_List.json + // this example is just showing the usage of "ServiceFabrics_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +119,22 @@ public async Task Exists_ServiceFabricsGet() // get the collection of this DevTestLabServiceFabricResource DevTestLabServiceFabricCollection collection = devTestLabUser.GetDevTestLabServiceFabrics(); - // invoke the operation - string name = "{serviceFabricName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabServiceFabricResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabServiceFabricData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServiceFabricsGet() + public async Task Exists_ServiceFabricsGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Get.json // this example is just showing the usage of "ServiceFabrics_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +158,17 @@ public async Task GetIfExists_ServiceFabricsGet() // invoke the operation string name = "{serviceFabricName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabServiceFabricResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabServiceFabricData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServiceFabricsCreateOrUpdate() + public async Task GetIfExists_ServiceFabricsGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_CreateOrUpdate.json - // this example is just showing the usage of "ServiceFabrics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabrics_Get.json + // this example is just showing the usage of "ServiceFabrics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,23 +189,21 @@ public async Task CreateOrUpdate_ServiceFabricsCreateOrUpdate() // invoke the operation string name = "{serviceFabricName}"; - DevTestLabServiceFabricData data = new DevTestLabServiceFabricData(new AzureLocation("{location}")) - { - ExternalServiceFabricId = "{serviceFabricId}", - EnvironmentId = "{environmentId}", - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabServiceFabricResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabServiceFabricResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabServiceFabricData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabServiceFabricData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricResource.cs index 20ba13d41ba85..544464bd91a6d 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricResource.cs @@ -99,11 +99,11 @@ public async Task Update_ServiceFabricsUpdate() DevTestLabServiceFabricResource devTestLabServiceFabric = client.GetDevTestLabServiceFabricResource(devTestLabServiceFabricResourceId); // invoke the operation - DevTestLabServiceFabricPatch patch = new DevTestLabServiceFabricPatch() + DevTestLabServiceFabricPatch patch = new DevTestLabServiceFabricPatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabServiceFabricResource result = await devTestLabServiceFabric.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricScheduleCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricScheduleCollection.cs index 6ded5ab3a4761..d72270785d44e 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricScheduleCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricScheduleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabServiceFabricScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServiceFabricSchedulesList() + public async Task CreateOrUpdate_ServiceFabricSchedulesCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_List.json - // this example is just showing the usage of "ServiceFabricSchedules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_CreateOrUpdate.json + // this example is just showing the usage of "ServiceFabricSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,42 @@ public async Task GetAll_ServiceFabricSchedulesList() // get the collection of this DevTestLabServiceFabricScheduleResource DevTestLabServiceFabricScheduleCollection collection = devTestLabServiceFabric.GetDevTestLabServiceFabricSchedules(); - // invoke the operation and iterate over the result - await foreach (DevTestLabServiceFabricScheduleResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{scheduleName}"; + DevTestLabScheduleData data = new DevTestLabScheduleData(new AzureLocation("{location}")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Status = new DevTestLabEnableStatus("{Enabled|Disabled}"), + TaskType = "{Unknown|LabVmsShutdownTask|LabVmsStartupTask|LabVmReclamationTask|ComputeVmShutdownTask}", + WeeklyRecurrence = new DevTestLabWeekDetails + { + Weekdays = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" }, + Time = "19:00", + }, + DailyRecurrenceTime = "19:00", + HourlyRecurrenceMinute = 0, + TimeZoneId = "Pacific Standard Time", + NotificationSettings = new DevTestLabNotificationSettings + { + Status = new DevTestLabEnableStatus("{Enabled|Disabled}"), + TimeInMinutes = 15, + WebhookUri = new Uri("{webhoolUrl}"), + EmailRecipient = "{email}", + NotificationLocale = "EN", + }, + TargetResourceId = "/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}", + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabServiceFabricScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +117,10 @@ public async Task Get_ServiceFabricSchedulesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServiceFabricSchedulesGet() + public async Task GetAll_ServiceFabricSchedulesList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Get.json - // this example is just showing the usage of "ServiceFabricSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_List.json + // this example is just showing the usage of "ServiceFabricSchedules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +140,22 @@ public async Task Exists_ServiceFabricSchedulesGet() // get the collection of this DevTestLabServiceFabricScheduleResource DevTestLabServiceFabricScheduleCollection collection = devTestLabServiceFabric.GetDevTestLabServiceFabricSchedules(); - // invoke the operation - string name = "{scheduleName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabServiceFabricScheduleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServiceFabricSchedulesGet() + public async Task Exists_ServiceFabricSchedulesGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Get.json // this example is just showing the usage of "ServiceFabricSchedules_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +180,17 @@ public async Task GetIfExists_ServiceFabricSchedulesGet() // invoke the operation string name = "{scheduleName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabServiceFabricScheduleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServiceFabricSchedulesCreateOrUpdate() + public async Task GetIfExists_ServiceFabricSchedulesGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_CreateOrUpdate.json - // this example is just showing the usage of "ServiceFabricSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceFabricSchedules_Get.json + // this example is just showing the usage of "ServiceFabricSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,43 +212,21 @@ public async Task CreateOrUpdate_ServiceFabricSchedulesCreateOrUpdate() // invoke the operation string name = "{scheduleName}"; - DevTestLabScheduleData data = new DevTestLabScheduleData(new AzureLocation("{location}")) - { - Status = new DevTestLabEnableStatus("{Enabled|Disabled}"), - TaskType = "{Unknown|LabVmsShutdownTask|LabVmsStartupTask|LabVmReclamationTask|ComputeVmShutdownTask}", - WeeklyRecurrence = new DevTestLabWeekDetails() - { - Weekdays = -{ -"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday" -}, - Time = "19:00", - }, - DailyRecurrenceTime = "19:00", - HourlyRecurrenceMinute = 0, - TimeZoneId = "Pacific Standard Time", - NotificationSettings = new DevTestLabNotificationSettings() - { - Status = new DevTestLabEnableStatus("{Enabled|Disabled}"), - TimeInMinutes = 15, - WebhookUri = new Uri("{webhoolUrl}"), - EmailRecipient = "{email}", - NotificationLocale = "EN", - }, - TargetResourceId = "/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/users/{uniqueIdentifier}/servicefabrics/{serviceFrabicName}", - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabServiceFabricScheduleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabServiceFabricScheduleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricScheduleResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricScheduleResource.cs index dae9267130de7..5827b3c093f86 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricScheduleResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceFabricScheduleResource.cs @@ -102,11 +102,11 @@ public async Task Update_ServiceFabricSchedulesUpdate() DevTestLabServiceFabricScheduleResource devTestLabServiceFabricSchedule = client.GetDevTestLabServiceFabricScheduleResource(devTestLabServiceFabricScheduleResourceId); // invoke the operation - DevTestLabSchedulePatch patch = new DevTestLabSchedulePatch() + DevTestLabSchedulePatch patch = new DevTestLabSchedulePatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabServiceFabricScheduleResource result = await devTestLabServiceFabricSchedule.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceRunnerCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceRunnerCollection.cs index 110f3fd6bab3f..aad7c3c2ad442 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceRunnerCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceRunnerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabServiceRunnerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ServiceRunnersGet() + public async Task CreateOrUpdate_ServiceRunnersCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_Get.json - // this example is just showing the usage of "ServiceRunners_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_CreateOrUpdate.json + // this example is just showing the usage of "ServiceRunners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,22 @@ public async Task Get_ServiceRunnersGet() // invoke the operation string name = "{servicerunnerName}"; - DevTestLabServiceRunnerResource result = await collection.GetAsync(name); + DevTestLabServiceRunnerData data = new DevTestLabServiceRunnerData(new AzureLocation("{location}")) + { + Identity = new DevTestLabManagedIdentity + { + ManagedIdentityType = "{identityType}", + PrincipalId = Guid.Parse("{identityPrincipalId}"), + TenantId = Guid.Parse("{identityTenantId}"), + ClientSecretUri = new Uri("{identityClientSecretUrl}"), + }, + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabServiceRunnerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +67,7 @@ public async Task Get_ServiceRunnersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServiceRunnersGet() + public async Task Get_ServiceRunnersGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_Get.json // this example is just showing the usage of "ServiceRunners_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,14 +90,18 @@ public async Task Exists_ServiceRunnersGet() // invoke the operation string name = "{servicerunnerName}"; - bool result = await collection.ExistsAsync(name); + DevTestLabServiceRunnerResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabServiceRunnerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServiceRunnersGet() + public async Task Exists_ServiceRunnersGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_Get.json // this example is just showing the usage of "ServiceRunners_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +124,17 @@ public async Task GetIfExists_ServiceRunnersGet() // invoke the operation string name = "{servicerunnerName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabServiceRunnerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabServiceRunnerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServiceRunnersCreateOrUpdate() + public async Task GetIfExists_ServiceRunnersGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_CreateOrUpdate.json - // this example is just showing the usage of "ServiceRunners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_Get.json + // this example is just showing the usage of "ServiceRunners_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,28 +154,21 @@ public async Task CreateOrUpdate_ServiceRunnersCreateOrUpdate() // invoke the operation string name = "{servicerunnerName}"; - DevTestLabServiceRunnerData data = new DevTestLabServiceRunnerData(new AzureLocation("{location}")) - { - Identity = new DevTestLabManagedIdentity() - { - ManagedIdentityType = "{identityType}", - PrincipalId = Guid.Parse("{identityPrincipalId}"), - TenantId = Guid.Parse("{identityTenantId}"), - ClientSecretUri = new Uri("{identityClientSecretUrl}"), - }, - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabServiceRunnerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabServiceRunnerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabServiceRunnerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabServiceRunnerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceRunnerResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceRunnerResource.cs index f14df789314b3..ead81ce17c4f7 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceRunnerResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabServiceRunnerResource.cs @@ -49,10 +49,10 @@ public async Task Get_ServiceRunnersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ServiceRunnersCreateOrUpdate() + public async Task Delete_ServiceRunnersDelete() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_CreateOrUpdate.json - // this example is just showing the usage of "ServiceRunners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_Delete.json + // this example is just showing the usage of "ServiceRunners_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,36 +69,17 @@ public async Task Update_ServiceRunnersCreateOrUpdate() DevTestLabServiceRunnerResource devTestLabServiceRunner = client.GetDevTestLabServiceRunnerResource(devTestLabServiceRunnerResourceId); // invoke the operation - DevTestLabServiceRunnerData data = new DevTestLabServiceRunnerData(new AzureLocation("{location}")) - { - Identity = new DevTestLabManagedIdentity() - { - ManagedIdentityType = "{identityType}", - PrincipalId = Guid.Parse("{identityPrincipalId}"), - TenantId = Guid.Parse("{identityTenantId}"), - ClientSecretUri = new Uri("{identityClientSecretUrl}"), - }, - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await devTestLabServiceRunner.UpdateAsync(WaitUntil.Completed, data); - DevTestLabServiceRunnerResource result = lro.Value; + await devTestLabServiceRunner.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabServiceRunnerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ServiceRunnersDelete() + public async Task Update_ServiceRunnersCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_Delete.json - // this example is just showing the usage of "ServiceRunners_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/ServiceRunners_CreateOrUpdate.json + // this example is just showing the usage of "ServiceRunners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,9 +96,28 @@ public async Task Delete_ServiceRunnersDelete() DevTestLabServiceRunnerResource devTestLabServiceRunner = client.GetDevTestLabServiceRunnerResource(devTestLabServiceRunnerResourceId); // invoke the operation - await devTestLabServiceRunner.DeleteAsync(WaitUntil.Completed); + DevTestLabServiceRunnerData data = new DevTestLabServiceRunnerData(new AzureLocation("{location}")) + { + Identity = new DevTestLabManagedIdentity + { + ManagedIdentityType = "{identityType}", + PrincipalId = Guid.Parse("{identityPrincipalId}"), + TenantId = Guid.Parse("{identityTenantId}"), + ClientSecretUri = new Uri("{identityClientSecretUrl}"), + }, + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await devTestLabServiceRunner.UpdateAsync(WaitUntil.Completed, data); + DevTestLabServiceRunnerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabServiceRunnerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabUserCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabUserCollection.cs index 2b6a15645334e..28940a417305a 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabUserCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabUserCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabUserCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_UsersList() + public async Task CreateOrUpdate_UsersCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_List.json - // this example is just showing the usage of "Users_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_CreateOrUpdate.json + // this example is just showing the usage of "Users_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,36 @@ public async Task GetAll_UsersList() // get the collection of this DevTestLabUserResource DevTestLabUserCollection collection = devTestLab.GetDevTestLabUsers(); - // invoke the operation and iterate over the result - await foreach (DevTestLabUserResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{userName}"; + DevTestLabUserData data = new DevTestLabUserData(new AzureLocation("{location}")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabUserData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new DevTestLabUserIdentity + { + PrincipalName = "{principalName}", + PrincipalId = "{principalId}", + TenantId = Guid.Parse("{tenantId}"), + ObjectId = "{objectId}", + AppId = "{appId}", + }, + SecretStore = new DevTestLabUserSecretStore + { + KeyVaultUri = new Uri("{keyVaultUri}"), + KeyVaultId = new ResourceIdentifier("{keyVaultId}"), + }, + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabUserResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +107,10 @@ public async Task Get_UsersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_UsersGet() + public async Task GetAll_UsersList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_Get.json - // this example is just showing the usage of "Users_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_List.json + // this example is just showing the usage of "Users_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +128,22 @@ public async Task Exists_UsersGet() // get the collection of this DevTestLabUserResource DevTestLabUserCollection collection = devTestLab.GetDevTestLabUsers(); - // invoke the operation - string name = "{userName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabUserResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabUserData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_UsersGet() + public async Task Exists_UsersGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_Get.json // this example is just showing the usage of "Users_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +166,17 @@ public async Task GetIfExists_UsersGet() // invoke the operation string name = "{userName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabUserResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UsersCreateOrUpdate() + public async Task GetIfExists_UsersGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_CreateOrUpdate.json - // this example is just showing the usage of "Users_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Users_Get.json + // this example is just showing the usage of "Users_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,34 +196,21 @@ public async Task CreateOrUpdate_UsersCreateOrUpdate() // invoke the operation string name = "{userName}"; - DevTestLabUserData data = new DevTestLabUserData(new AzureLocation("{location}")) - { - Identity = new DevTestLabUserIdentity() - { - PrincipalName = "{principalName}", - PrincipalId = "{principalId}", - TenantId = Guid.Parse("{tenantId}"), - ObjectId = "{objectId}", - AppId = "{appId}", - }, - SecretStore = new DevTestLabUserSecretStore() - { - KeyVaultUri = new Uri("{keyVaultUri}"), - KeyVaultId = new ResourceIdentifier("{keyVaultId}"), - }, - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabUserResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabUserResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabUserResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabUserResource.cs index 6bafd36ac57d3..28ed12749b90f 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabUserResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabUserResource.cs @@ -96,11 +96,11 @@ public async Task Update_UsersUpdate() DevTestLabUserResource devTestLabUser = client.GetDevTestLabUserResource(devTestLabUserResourceId); // invoke the operation - DevTestLabUserPatch patch = new DevTestLabUserPatch() + DevTestLabUserPatch patch = new DevTestLabUserPatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabUserResource result = await devTestLabUser.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVirtualNetworkCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVirtualNetworkCollection.cs index a648e6e738e45..f70011bbacb9b 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVirtualNetworkCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVirtualNetworkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DevTestLabVirtualNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualNetworksList() + public async Task CreateOrUpdate_VirtualNetworksCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_List.json - // this example is just showing the usage of "VirtualNetworks_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_CreateOrUpdate.json + // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,23 @@ public async Task GetAll_VirtualNetworksList() // get the collection of this DevTestLabVirtualNetworkResource DevTestLabVirtualNetworkCollection collection = devTestLab.GetDevTestLabVirtualNetworks(); - // invoke the operation and iterate over the result - await foreach (DevTestLabVirtualNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{virtualNetworkName}"; + DevTestLabVirtualNetworkData data = new DevTestLabVirtualNetworkData(new AzureLocation("{location}")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabVirtualNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabVirtualNetworkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabVirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +93,10 @@ public async Task Get_VirtualNetworksGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualNetworksGet() + public async Task GetAll_VirtualNetworksList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_Get.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_List.json + // this example is just showing the usage of "VirtualNetworks_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +114,22 @@ public async Task Exists_VirtualNetworksGet() // get the collection of this DevTestLabVirtualNetworkResource DevTestLabVirtualNetworkCollection collection = devTestLab.GetDevTestLabVirtualNetworks(); - // invoke the operation - string name = "{virtualNetworkName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabVirtualNetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabVirtualNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualNetworksGet() + public async Task Exists_VirtualNetworksGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_Get.json // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +152,17 @@ public async Task GetIfExists_VirtualNetworksGet() // invoke the operation string name = "{virtualNetworkName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabVirtualNetworkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabVirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VirtualNetworksCreateOrUpdate() + public async Task GetIfExists_VirtualNetworksGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_CreateOrUpdate.json - // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualNetworks_Get.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,21 +182,21 @@ public async Task CreateOrUpdate_VirtualNetworksCreateOrUpdate() // invoke the operation string name = "{virtualNetworkName}"; - DevTestLabVirtualNetworkData data = new DevTestLabVirtualNetworkData(new AzureLocation("{location}")) - { - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabVirtualNetworkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabVirtualNetworkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabVirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabVirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVirtualNetworkResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVirtualNetworkResource.cs index 68b155a81d652..8595c3d017958 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVirtualNetworkResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVirtualNetworkResource.cs @@ -96,11 +96,11 @@ public async Task Update_VirtualNetworksUpdate() DevTestLabVirtualNetworkResource devTestLabVirtualNetwork = client.GetDevTestLabVirtualNetworkResource(devTestLabVirtualNetworkResourceId); // invoke the operation - DevTestLabVirtualNetworkPatch patch = new DevTestLabVirtualNetworkPatch() + DevTestLabVirtualNetworkPatch patch = new DevTestLabVirtualNetworkPatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabVirtualNetworkResource result = await devTestLabVirtualNetwork.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmCollection.cs index 4b55a0f51de53..92816b5df17d2 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabVmCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachinesList() + public async Task CreateOrUpdate_VirtualMachinesCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_List.json - // this example is just showing the usage of "VirtualMachines_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_CreateOrUpdate.json + // this example is just showing the usage of "VirtualMachines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,39 @@ public async Task GetAll_VirtualMachinesList() // get the collection of this DevTestLabVmResource DevTestLabVmCollection collection = devTestLab.GetDevTestLabVms(); - // invoke the operation and iterate over the result - await foreach (DevTestLabVmResource item in collection.GetAllAsync()) + // invoke the operation + string name = "{vmName}"; + DevTestLabVmData data = new DevTestLabVmData(new AzureLocation("{location}")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabVmData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Size = "Standard_A2_v2", + UserName = "{userName}", + Password = "{userPassword}", + LabSubnetName = "{virtualNetworkName}Subnet", + LabVirtualNetworkId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), + DisallowPublicIPAddress = true, + GalleryImageReference = new DevTestLabGalleryImageReference + { + Offer = "UbuntuServer", + Publisher = "Canonical", + Sku = "16.04-LTS", + OSType = "Linux", + Version = "Latest", + }, + AllowClaim = true, + StorageType = "Standard", + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabVmResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +110,10 @@ public async Task Get_VirtualMachinesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualMachinesGet() + public async Task GetAll_VirtualMachinesList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Get.json - // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_List.json + // this example is just showing the usage of "VirtualMachines_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +131,22 @@ public async Task Exists_VirtualMachinesGet() // get the collection of this DevTestLabVmResource DevTestLabVmCollection collection = devTestLab.GetDevTestLabVms(); - // invoke the operation - string name = "{vmName}"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabVmResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabVmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualMachinesGet() + public async Task Exists_VirtualMachinesGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Get.json // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +169,17 @@ public async Task GetIfExists_VirtualMachinesGet() // invoke the operation string name = "{vmName}"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabVmResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VirtualMachinesCreateOrUpdate() + public async Task GetIfExists_VirtualMachinesGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_CreateOrUpdate.json - // this example is just showing the usage of "VirtualMachines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachines_Get.json + // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,37 +199,21 @@ public async Task CreateOrUpdate_VirtualMachinesCreateOrUpdate() // invoke the operation string name = "{vmName}"; - DevTestLabVmData data = new DevTestLabVmData(new AzureLocation("{location}")) - { - Size = "Standard_A2_v2", - UserName = "{userName}", - Password = "{userPassword}", - LabSubnetName = "{virtualNetworkName}Subnet", - LabVirtualNetworkId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualnetworks/{virtualNetworkName}"), - DisallowPublicIPAddress = true, - GalleryImageReference = new DevTestLabGalleryImageReference() - { - Offer = "UbuntuServer", - Publisher = "Canonical", - Sku = "16.04-LTS", - OSType = "Linux", - Version = "Latest", - }, - AllowClaim = true, - StorageType = "Standard", - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabVmResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabVmResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmResource.cs index 5523e1b3fbb9f..aa8814d37cb8e 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmResource.cs @@ -128,9 +128,9 @@ public async Task AddDataDisk_VirtualMachinesAddDataDisk() DevTestLabVmResource devTestLabVm = client.GetDevTestLabVmResource(devTestLabVmResourceId); // invoke the operation - DevTestLabDataDiskProperties dataDiskProperties = new DevTestLabDataDiskProperties() + DevTestLabDataDiskProperties dataDiskProperties = new DevTestLabDataDiskProperties { - AttachNewDataDiskOptions = new AttachNewDataDiskDetails() + AttachNewDataDiskOptions = new AttachNewDataDiskDetails { DiskSizeGiB = 127, DiskName = "{diskName}", @@ -164,15 +164,12 @@ public async Task ApplyArtifacts_VirtualMachinesApplyArtifacts() DevTestLabVmResource devTestLabVm = client.GetDevTestLabVmResource(devTestLabVmResourceId); // invoke the operation - DevTestLabVmApplyArtifactsContent content = new DevTestLabVmApplyArtifactsContent() + DevTestLabVmApplyArtifactsContent content = new DevTestLabVmApplyArtifactsContent { - Artifacts = -{ -new DevTestLabArtifactInstallInfo() + Artifacts = {new DevTestLabArtifactInstallInfo { ArtifactId = "/subscriptions/{subscriptionId}/resourceGroups/resourceGroupName/providers/Microsoft.DevTestLab/labs/{labName}/artifactSources/public repo/artifacts/windows-restart", -} -}, +}}, }; await devTestLabVm.ApplyArtifactsAsync(WaitUntil.Completed, content); @@ -228,7 +225,7 @@ public async Task DetachDataDisk_VirtualMachinesDetachDataDisk() DevTestLabVmResource devTestLabVm = client.GetDevTestLabVmResource(devTestLabVmResourceId); // invoke the operation - DevTestLabVmDetachDataDiskContent content = new DevTestLabVmDetachDataDiskContent() + DevTestLabVmDetachDataDiskContent content = new DevTestLabVmDetachDataDiskContent { ExistingLabDiskId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualmachines/{virtualMachineName}"), }; @@ -340,7 +337,7 @@ public async Task Resize_VirtualMachinesResize() DevTestLabVmResource devTestLabVm = client.GetDevTestLabVmResource(devTestLabVmResourceId); // invoke the operation - DevTestLabVmResizeContent content = new DevTestLabVmResizeContent() + DevTestLabVmResizeContent content = new DevTestLabVmResizeContent { Size = "Standard_A4_v2", }; diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmScheduleCollection.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmScheduleCollection.cs index 8d7bd8a3148b8..24b97285bae68 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmScheduleCollection.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmScheduleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevTestLabVmScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachineSchedulesList() + public async Task CreateOrUpdate_VirtualMachineSchedulesCreateOrUpdate() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_List.json - // this example is just showing the usage of "VirtualMachineSchedules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_CreateOrUpdate.json + // this example is just showing the usage of "VirtualMachineSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,42 @@ public async Task GetAll_VirtualMachineSchedulesList() // get the collection of this DevTestLabVmScheduleResource DevTestLabVmScheduleCollection collection = devTestLabVm.GetDevTestLabVmSchedules(); - // invoke the operation and iterate over the result - await foreach (DevTestLabVmScheduleResource item in collection.GetAllAsync()) + // invoke the operation + string name = "LabVmsShutdown"; + DevTestLabScheduleData data = new DevTestLabScheduleData(new AzureLocation("{location}")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Status = DevTestLabEnableStatus.Enabled, + TaskType = "LabVmsShutdownTask", + WeeklyRecurrence = new DevTestLabWeekDetails + { + Weekdays = { "Friday", "Saturday", "Sunday" }, + Time = "1700", + }, + DailyRecurrenceTime = "1900", + HourlyRecurrenceMinute = 30, + TimeZoneId = "Pacific Standard Time", + NotificationSettings = new DevTestLabNotificationSettings + { + Status = DevTestLabEnableStatus.Enabled, + TimeInMinutes = 30, + WebhookUri = new Uri("{webhookUrl}"), + EmailRecipient = "{email}", + NotificationLocale = "EN", + }, + TargetResourceId = "/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}", + Tags = +{ +["tagName1"] = "tagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DevTestLabVmScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +115,10 @@ public async Task Get_VirtualMachineSchedulesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualMachineSchedulesGet() + public async Task GetAll_VirtualMachineSchedulesList() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Get.json - // this example is just showing the usage of "VirtualMachineSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_List.json + // this example is just showing the usage of "VirtualMachineSchedules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +137,22 @@ public async Task Exists_VirtualMachineSchedulesGet() // get the collection of this DevTestLabVmScheduleResource DevTestLabVmScheduleCollection collection = devTestLabVm.GetDevTestLabVmSchedules(); - // invoke the operation - string name = "LabVmsShutdown"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DevTestLabVmScheduleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualMachineSchedulesGet() + public async Task Exists_VirtualMachineSchedulesGet() { // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Get.json // this example is just showing the usage of "VirtualMachineSchedules_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +176,17 @@ public async Task GetIfExists_VirtualMachineSchedulesGet() // invoke the operation string name = "LabVmsShutdown"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DevTestLabVmScheduleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VirtualMachineSchedulesCreateOrUpdate() + public async Task GetIfExists_VirtualMachineSchedulesGet() { - // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_CreateOrUpdate.json - // this example is just showing the usage of "VirtualMachineSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/VirtualMachineSchedules_Get.json + // this example is just showing the usage of "VirtualMachineSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,43 +207,21 @@ public async Task CreateOrUpdate_VirtualMachineSchedulesCreateOrUpdate() // invoke the operation string name = "LabVmsShutdown"; - DevTestLabScheduleData data = new DevTestLabScheduleData(new AzureLocation("{location}")) - { - Status = DevTestLabEnableStatus.Enabled, - TaskType = "LabVmsShutdownTask", - WeeklyRecurrence = new DevTestLabWeekDetails() - { - Weekdays = -{ -"Friday","Saturday","Sunday" -}, - Time = "1700", - }, - DailyRecurrenceTime = "1900", - HourlyRecurrenceMinute = 30, - TimeZoneId = "Pacific Standard Time", - NotificationSettings = new DevTestLabNotificationSettings() - { - Status = DevTestLabEnableStatus.Enabled, - TimeInMinutes = 30, - WebhookUri = new Uri("{webhookUrl}"), - EmailRecipient = "{email}", - NotificationLocale = "EN", - }, - TargetResourceId = "/subscriptions/{subscriptionId}/resourcegroups/resourceGroupName/providers/microsoft.devtestlab/labs/{labName}/virtualMachines/{vmName}", - Tags = -{ -["tagName1"] = "tagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DevTestLabVmScheduleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DevTestLabVmScheduleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevTestLabScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmScheduleResource.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmScheduleResource.cs index 201a4cff79d18..7859ebf15d7c8 100644 --- a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmScheduleResource.cs +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_DevTestLabVmScheduleResource.cs @@ -99,11 +99,11 @@ public async Task Update_VirtualMachineSchedulesUpdate() DevTestLabVmScheduleResource devTestLabVmSchedule = client.GetDevTestLabVmScheduleResource(devTestLabVmScheduleResourceId); // invoke the operation - DevTestLabSchedulePatch patch = new DevTestLabSchedulePatch() + DevTestLabSchedulePatch patch = new DevTestLabSchedulePatch { Tags = { -["tagName1"] = "tagValue1", +["tagName1"] = "tagValue1" }, }; DevTestLabVmScheduleResource result = await devTestLabVmSchedule.UpdateAsync(patch); diff --git a/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..552600faf499b --- /dev/null +++ b/sdk/devtestlabs/Azure.ResourceManager.DevTestLabs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.DevTestLabs.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDevTestLabs_LabsListBySubscription() + { + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/Labs_ListBySubscription.json + // this example is just showing the usage of "Labs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscriptionId}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DevTestLabResource item in subscriptionResource.GetDevTestLabsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDevTestLabGlobalSchedules_GlobalSchedulesListBySubscription() + { + // Generated from example definition: specification/devtestlabs/resource-manager/Microsoft.DevTestLab/stable/2018-09-15/examples/GlobalSchedules_ListBySubscription.json + // this example is just showing the usage of "GlobalSchedules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscriptionId}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DevTestLabGlobalScheduleResource item in subscriptionResource.GetDevTestLabGlobalSchedulesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevTestLabScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsDescriptionCollection.cs b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsDescriptionCollection.cs index 5296ce6eab08f..f772bfbd86a3f 100644 --- a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsDescriptionCollection.cs +++ b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsDescriptionCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_DigitalTwinsDescriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADigitalTwinsInstanceResource() + public async Task CreateOrUpdate_PutADigitalTwinsInstanceResource() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_example.json - // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPut_example.json + // this example is just showing the usage of "DigitalTwins_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,9 @@ public async Task Get_GetADigitalTwinsInstanceResource() // invoke the operation string resourceName = "myDigitalTwinsService"; - DigitalTwinsDescriptionResource result = await collection.GetAsync(resourceName); + DigitalTwinsDescriptionData data = new DigitalTwinsDescriptionData(new AzureLocation("WestUS2")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + DigitalTwinsDescriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +55,10 @@ public async Task Get_GetADigitalTwinsInstanceResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADigitalTwinsInstanceResource() + public async Task CreateOrUpdate_PutADigitalTwinsInstanceResourceWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_example.json - // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPut_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwins_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +77,32 @@ public async Task Exists_GetADigitalTwinsInstanceResource() // invoke the operation string resourceName = "myDigitalTwinsService"; - bool result = await collection.ExistsAsync(resourceName); + DigitalTwinsDescriptionData data = new DigitalTwinsDescriptionData(new AzureLocation("WestUS2")) + { + Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/50016170-c839-41ba-a724-51e9df440b9e/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity")] = new UserAssignedIdentity() +}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + DigitalTwinsDescriptionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADigitalTwinsInstanceResource() + public async Task CreateOrUpdate_PutADigitalTwinsInstanceResourceWithPublicNetworkAccessProperty() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_example.json - // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPut_WithPublicNetworkAccess.json + // this example is just showing the usage of "DigitalTwins_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,28 +121,25 @@ public async Task GetIfExists_GetADigitalTwinsInstanceResource() // invoke the operation string resourceName = "myDigitalTwinsService"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - DigitalTwinsDescriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + DigitalTwinsDescriptionData data = new DigitalTwinsDescriptionData(new AzureLocation("WestUS2")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PublicNetworkAccess = DigitalTwinsPublicNetworkAccess.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + DigitalTwinsDescriptionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADigitalTwinsInstanceResourceWithAPrivateEndpointConnection() + public async Task Get_GetADigitalTwinsInstanceResource() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithPrivateEndpointConnection_example.json + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_example.json // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -156,7 +170,7 @@ public async Task Get_GetADigitalTwinsInstanceResourceWithAPrivateEndpointConnec [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADigitalTwinsInstanceResourceWithAPrivateEndpointConnection() + public async Task Get_GetADigitalTwinsInstanceResourceWithAPrivateEndpointConnection() { // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithPrivateEndpointConnection_example.json // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. @@ -178,16 +192,20 @@ public async Task Exists_GetADigitalTwinsInstanceResourceWithAPrivateEndpointCon // invoke the operation string resourceName = "myDigitalTwinsService"; - bool result = await collection.ExistsAsync(resourceName); + DigitalTwinsDescriptionResource result = await collection.GetAsync(resourceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADigitalTwinsInstanceResourceWithAPrivateEndpointConnection() + public async Task Get_GetADigitalTwinsInstanceResourceWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithPrivateEndpointConnection_example.json + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithIdentity_example.json // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -207,29 +225,21 @@ public async Task GetIfExists_GetADigitalTwinsInstanceResourceWithAPrivateEndpoi // invoke the operation string resourceName = "myDigitalTwinsService"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - DigitalTwinsDescriptionResource result = response.HasValue ? response.Value : null; + DigitalTwinsDescriptionResource result = await collection.GetAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADigitalTwinsInstanceResourceWithIdentity() + public async Task GetAll_GetDigitalTwinsInstanceResourcesByResourceGroup() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithIdentity_example.json - // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsListByResourceGroup_example.json + // this example is just showing the usage of "DigitalTwins_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -246,22 +256,24 @@ public async Task Get_GetADigitalTwinsInstanceResourceWithIdentity() // get the collection of this DigitalTwinsDescriptionResource DigitalTwinsDescriptionCollection collection = resourceGroupResource.GetDigitalTwinsDescriptions(); - // invoke the operation - string resourceName = "myDigitalTwinsService"; - DigitalTwinsDescriptionResource result = await collection.GetAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (DigitalTwinsDescriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsDescriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADigitalTwinsInstanceResourceWithIdentity() + public async Task Exists_GetADigitalTwinsInstanceResource() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithIdentity_example.json + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_example.json // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -288,9 +300,9 @@ public async Task Exists_GetADigitalTwinsInstanceResourceWithIdentity() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADigitalTwinsInstanceResourceWithIdentity() + public async Task Exists_GetADigitalTwinsInstanceResourceWithAPrivateEndpointConnection() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithIdentity_example.json + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithPrivateEndpointConnection_example.json // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -310,29 +322,17 @@ public async Task GetIfExists_GetADigitalTwinsInstanceResourceWithIdentity() // invoke the operation string resourceName = "myDigitalTwinsService"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - DigitalTwinsDescriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutADigitalTwinsInstanceResource() + public async Task Exists_GetADigitalTwinsInstanceResourceWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPut_example.json - // this example is just showing the usage of "DigitalTwins_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -351,23 +351,17 @@ public async Task CreateOrUpdate_PutADigitalTwinsInstanceResource() // invoke the operation string resourceName = "myDigitalTwinsService"; - DigitalTwinsDescriptionData data = new DigitalTwinsDescriptionData(new AzureLocation("WestUS2")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - DigitalTwinsDescriptionResource result = lro.Value; + bool result = await collection.ExistsAsync(resourceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutADigitalTwinsInstanceResourceWithIdentity() + public async Task GetIfExists_GetADigitalTwinsInstanceResource() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPut_WithIdentity_example.json - // this example is just showing the usage of "DigitalTwins_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_example.json + // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -386,32 +380,29 @@ public async Task CreateOrUpdate_PutADigitalTwinsInstanceResourceWithIdentity() // invoke the operation string resourceName = "myDigitalTwinsService"; - DigitalTwinsDescriptionData data = new DigitalTwinsDescriptionData(new AzureLocation("WestUS2")) - { - Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/50016170-c839-41ba-a724-51e9df440b9e/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity")] = new UserAssignedIdentity(), -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - DigitalTwinsDescriptionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + DigitalTwinsDescriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutADigitalTwinsInstanceResourceWithPublicNetworkAccessProperty() + public async Task GetIfExists_GetADigitalTwinsInstanceResourceWithAPrivateEndpointConnection() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPut_WithPublicNetworkAccess.json - // this example is just showing the usage of "DigitalTwins_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithPrivateEndpointConnection_example.json + // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -430,26 +421,29 @@ public async Task CreateOrUpdate_PutADigitalTwinsInstanceResourceWithPublicNetwo // invoke the operation string resourceName = "myDigitalTwinsService"; - DigitalTwinsDescriptionData data = new DigitalTwinsDescriptionData(new AzureLocation("WestUS2")) - { - PublicNetworkAccess = DigitalTwinsPublicNetworkAccess.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - DigitalTwinsDescriptionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + DigitalTwinsDescriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetDigitalTwinsInstanceResourcesByResourceGroup() + public async Task GetIfExists_GetADigitalTwinsInstanceResourceWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsListByResourceGroup_example.json - // this example is just showing the usage of "DigitalTwins_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsGet_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwins_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -466,17 +460,23 @@ public async Task GetAll_GetDigitalTwinsInstanceResourcesByResourceGroup() // get the collection of this DigitalTwinsDescriptionResource DigitalTwinsDescriptionCollection collection = resourceGroupResource.GetDigitalTwinsDescriptions(); - // invoke the operation and iterate over the result - await foreach (DigitalTwinsDescriptionResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "myDigitalTwinsService"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + DigitalTwinsDescriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DigitalTwinsDescriptionData resourceData = item.Data; + DigitalTwinsDescriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsDescriptionResource.cs b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsDescriptionResource.cs index 3645addcfb598..38179f697dc5c 100644 --- a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsDescriptionResource.cs +++ b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsDescriptionResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.DigitalTwins.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DigitalTwins.Samples @@ -110,10 +109,10 @@ public async Task Get_GetADigitalTwinsInstanceResourceWithIdentity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchADigitalTwinsInstanceResource() + public async Task Delete_DeleteADigitalTwinsInstanceResource() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPatch_example.json - // this example is just showing the usage of "DigitalTwins_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsDelete_example.json + // this example is just showing the usage of "DigitalTwins_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,14 +128,7 @@ public async Task Update_PatchADigitalTwinsInstanceResource() DigitalTwinsDescriptionResource digitalTwinsDescription = client.GetDigitalTwinsDescriptionResource(digitalTwinsDescriptionResourceId); // invoke the operation - DigitalTwinsDescriptionPatch patch = new DigitalTwinsDescriptionPatch() - { - Tags = -{ -["purpose"] = "dev", -}, - }; - ArmOperation lro = await digitalTwinsDescription.UpdateAsync(WaitUntil.Completed, patch); + ArmOperation lro = await digitalTwinsDescription.DeleteAsync(WaitUntil.Completed); DigitalTwinsDescriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -148,10 +140,10 @@ public async Task Update_PatchADigitalTwinsInstanceResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchADigitalTwinsInstanceResourceWithIdentity() + public async Task Delete_DeleteADigitalTwinsInstanceResourceWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPatch_WithIdentity_example.json - // this example is just showing the usage of "DigitalTwins_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsDelete_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwins_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -167,11 +159,7 @@ public async Task Update_PatchADigitalTwinsInstanceResourceWithIdentity() DigitalTwinsDescriptionResource digitalTwinsDescription = client.GetDigitalTwinsDescriptionResource(digitalTwinsDescriptionResourceId); // invoke the operation - DigitalTwinsDescriptionPatch patch = new DigitalTwinsDescriptionPatch() - { - Identity = new ManagedServiceIdentity("None"), - }; - ArmOperation lro = await digitalTwinsDescription.UpdateAsync(WaitUntil.Completed, patch); + ArmOperation lro = await digitalTwinsDescription.DeleteAsync(WaitUntil.Completed); DigitalTwinsDescriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -183,9 +171,9 @@ public async Task Update_PatchADigitalTwinsInstanceResourceWithIdentity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchADigitalTwinsInstanceResourceWithPublicNetworkAccessProperty() + public async Task Update_PatchADigitalTwinsInstanceResource() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPatch_WithPublicNetworkAccess.json + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPatch_example.json // this example is just showing the usage of "DigitalTwins_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -202,9 +190,12 @@ public async Task Update_PatchADigitalTwinsInstanceResourceWithPublicNetworkAcce DigitalTwinsDescriptionResource digitalTwinsDescription = client.GetDigitalTwinsDescriptionResource(digitalTwinsDescriptionResourceId); // invoke the operation - DigitalTwinsDescriptionPatch patch = new DigitalTwinsDescriptionPatch() + DigitalTwinsDescriptionPatch patch = new DigitalTwinsDescriptionPatch { - DigitalTwinsPatchPublicNetworkAccess = DigitalTwinsPublicNetworkAccess.Disabled, + Tags = +{ +["purpose"] = "dev" +}, }; ArmOperation lro = await digitalTwinsDescription.UpdateAsync(WaitUntil.Completed, patch); DigitalTwinsDescriptionResource result = lro.Value; @@ -218,10 +209,10 @@ public async Task Update_PatchADigitalTwinsInstanceResourceWithPublicNetworkAcce [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteADigitalTwinsInstanceResource() + public async Task Update_PatchADigitalTwinsInstanceResourceWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsDelete_example.json - // this example is just showing the usage of "DigitalTwins_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPatch_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwins_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -237,7 +228,11 @@ public async Task Delete_DeleteADigitalTwinsInstanceResource() DigitalTwinsDescriptionResource digitalTwinsDescription = client.GetDigitalTwinsDescriptionResource(digitalTwinsDescriptionResourceId); // invoke the operation - ArmOperation lro = await digitalTwinsDescription.DeleteAsync(WaitUntil.Completed); + DigitalTwinsDescriptionPatch patch = new DigitalTwinsDescriptionPatch + { + Identity = new ManagedServiceIdentity("None"), + }; + ArmOperation lro = await digitalTwinsDescription.UpdateAsync(WaitUntil.Completed, patch); DigitalTwinsDescriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -249,10 +244,10 @@ public async Task Delete_DeleteADigitalTwinsInstanceResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteADigitalTwinsInstanceResourceWithIdentity() + public async Task Update_PatchADigitalTwinsInstanceResourceWithPublicNetworkAccessProperty() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsDelete_WithIdentity_example.json - // this example is just showing the usage of "DigitalTwins_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsPatch_WithPublicNetworkAccess.json + // this example is just showing the usage of "DigitalTwins_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -268,7 +263,11 @@ public async Task Delete_DeleteADigitalTwinsInstanceResourceWithIdentity() DigitalTwinsDescriptionResource digitalTwinsDescription = client.GetDigitalTwinsDescriptionResource(digitalTwinsDescriptionResourceId); // invoke the operation - ArmOperation lro = await digitalTwinsDescription.DeleteAsync(WaitUntil.Completed); + DigitalTwinsDescriptionPatch patch = new DigitalTwinsDescriptionPatch + { + DigitalTwinsPatchPublicNetworkAccess = DigitalTwinsPublicNetworkAccess.Disabled, + }; + ArmOperation lro = await digitalTwinsDescription.UpdateAsync(WaitUntil.Completed, patch); DigitalTwinsDescriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -277,62 +276,5 @@ public async Task Delete_DeleteADigitalTwinsInstanceResourceWithIdentity() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDigitalTwinsDescriptions_GetDigitalTwinsInstanceResourcesBySubscription() - { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsList_example.json - // this example is just showing the usage of "DigitalTwins_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "50016170-c839-41ba-a724-51e9df440b9e"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DigitalTwinsDescriptionResource item in subscriptionResource.GetDigitalTwinsDescriptionsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsDescriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckDigitalTwinsNameAvailability_CheckNameAvailability() - { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsCheckNameAvailability_example.json - // this example is just showing the usage of "DigitalTwins_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "50016170-c839-41ba-a724-51e9df440b9e"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("WestUS2"); - DigitalTwinsNameContent content = new DigitalTwinsNameContent("myadtinstance"); - DigitalTwinsNameResult result = await subscriptionResource.CheckDigitalTwinsNameAvailabilityAsync(location, content); - - Console.WriteLine($"Succeeded: {result}"); - } } } diff --git a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsEndpointResource.cs b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsEndpointResource.cs index 664d5d312589c..2643d945cd940 100644 --- a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsEndpointResource.cs +++ b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsEndpointResource.cs @@ -80,10 +80,10 @@ public async Task Get_GetADigitalTwinsInstanceEndpointWithIdentity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutADigitalTwinsEndpointResource() + public async Task Delete_DeleteADigitalTwinsInstanceEndpoint() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointDelete_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,18 +95,12 @@ public async Task Update_PutADigitalTwinsEndpointResource() string subscriptionId = "50016170-c839-41ba-a724-51e9df440b9e"; string resourceGroupName = "resRg"; string resourceName = "myDigitalTwinsService"; - string endpointName = "myServiceBus"; + string endpointName = "myendpoint"; ResourceIdentifier digitalTwinsEndpointResourceId = DigitalTwinsEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, endpointName); DigitalTwinsEndpointResource digitalTwinsEndpointResource = client.GetDigitalTwinsEndpointResource(digitalTwinsEndpointResourceId); // invoke the operation - DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties() - { - PrimaryConnectionString = "Endpoint=sb://mysb.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xyzxyzoX4=;EntityPath=abcabc", - SecondaryConnectionString = "Endpoint=sb://mysb.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xyzxyzoX4=;EntityPath=abcabc", - AuthenticationType = DigitalTwinsAuthenticationType.KeyBased, - }); - ArmOperation lro = await digitalTwinsEndpointResource.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await digitalTwinsEndpointResource.DeleteAsync(WaitUntil.Completed); DigitalTwinsEndpointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -118,10 +112,10 @@ public async Task Update_PutADigitalTwinsEndpointResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutADigitalTwinsEndpointResourceWithIdentity() + public async Task Delete_DeleteADigitalTwinsInstanceEndpointWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_WithIdentity_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointDelete_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,18 +127,12 @@ public async Task Update_PutADigitalTwinsEndpointResourceWithIdentity() string subscriptionId = "50016170-c839-41ba-a724-51e9df440b9e"; string resourceGroupName = "resRg"; string resourceName = "myDigitalTwinsService"; - string endpointName = "myServiceBus"; + string endpointName = "myendpoint"; ResourceIdentifier digitalTwinsEndpointResourceId = DigitalTwinsEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, endpointName); DigitalTwinsEndpointResource digitalTwinsEndpointResource = client.GetDigitalTwinsEndpointResource(digitalTwinsEndpointResourceId); // invoke the operation - DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties() - { - EndpointUri = new Uri("sb://mysb.servicebus.windows.net/"), - EntityPath = "mysbtopic", - AuthenticationType = DigitalTwinsAuthenticationType.IdentityBased, - }); - ArmOperation lro = await digitalTwinsEndpointResource.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await digitalTwinsEndpointResource.DeleteAsync(WaitUntil.Completed); DigitalTwinsEndpointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -156,9 +144,9 @@ public async Task Update_PutADigitalTwinsEndpointResourceWithIdentity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutADigitalTwinsEndpointResourceWithUserAssignedIdentity() + public async Task Update_PutADigitalTwinsEndpointResource() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_WithUserIdentity_example.json + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_example.json // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -176,16 +164,11 @@ public async Task Update_PutADigitalTwinsEndpointResourceWithUserAssignedIdentit DigitalTwinsEndpointResource digitalTwinsEndpointResource = client.GetDigitalTwinsEndpointResource(digitalTwinsEndpointResourceId); // invoke the operation - DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties() + DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties { - EndpointUri = new Uri("sb://mysb.servicebus.windows.net/"), - EntityPath = "mysbtopic", - AuthenticationType = DigitalTwinsAuthenticationType.IdentityBased, - Identity = new DigitalTwinsManagedIdentityReference() - { - IdentityType = DigitalTwinsManagedIdentityType.UserAssigned, - UserAssignedIdentity = "/subscriptions/50016170-c839-41ba-a724-51e9df440b9e/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity", - }, + PrimaryConnectionString = "Endpoint=sb://mysb.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xyzxyzoX4=;EntityPath=abcabc", + SecondaryConnectionString = "Endpoint=sb://mysb.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xyzxyzoX4=;EntityPath=abcabc", + AuthenticationType = DigitalTwinsAuthenticationType.KeyBased, }); ArmOperation lro = await digitalTwinsEndpointResource.UpdateAsync(WaitUntil.Completed, data); DigitalTwinsEndpointResource result = lro.Value; @@ -199,10 +182,10 @@ public async Task Update_PutADigitalTwinsEndpointResourceWithUserAssignedIdentit [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteADigitalTwinsInstanceEndpoint() + public async Task Update_PutADigitalTwinsEndpointResourceWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointDelete_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -214,12 +197,18 @@ public async Task Delete_DeleteADigitalTwinsInstanceEndpoint() string subscriptionId = "50016170-c839-41ba-a724-51e9df440b9e"; string resourceGroupName = "resRg"; string resourceName = "myDigitalTwinsService"; - string endpointName = "myendpoint"; + string endpointName = "myServiceBus"; ResourceIdentifier digitalTwinsEndpointResourceId = DigitalTwinsEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, endpointName); DigitalTwinsEndpointResource digitalTwinsEndpointResource = client.GetDigitalTwinsEndpointResource(digitalTwinsEndpointResourceId); // invoke the operation - ArmOperation lro = await digitalTwinsEndpointResource.DeleteAsync(WaitUntil.Completed); + DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties + { + EndpointUri = new Uri("sb://mysb.servicebus.windows.net/"), + EntityPath = "mysbtopic", + AuthenticationType = DigitalTwinsAuthenticationType.IdentityBased, + }); + ArmOperation lro = await digitalTwinsEndpointResource.UpdateAsync(WaitUntil.Completed, data); DigitalTwinsEndpointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -231,10 +220,10 @@ public async Task Delete_DeleteADigitalTwinsInstanceEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteADigitalTwinsInstanceEndpointWithIdentity() + public async Task Update_PutADigitalTwinsEndpointResourceWithUserAssignedIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointDelete_WithIdentity_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_WithUserIdentity_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -246,12 +235,23 @@ public async Task Delete_DeleteADigitalTwinsInstanceEndpointWithIdentity() string subscriptionId = "50016170-c839-41ba-a724-51e9df440b9e"; string resourceGroupName = "resRg"; string resourceName = "myDigitalTwinsService"; - string endpointName = "myendpoint"; + string endpointName = "myServiceBus"; ResourceIdentifier digitalTwinsEndpointResourceId = DigitalTwinsEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, endpointName); DigitalTwinsEndpointResource digitalTwinsEndpointResource = client.GetDigitalTwinsEndpointResource(digitalTwinsEndpointResourceId); // invoke the operation - ArmOperation lro = await digitalTwinsEndpointResource.DeleteAsync(WaitUntil.Completed); + DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties + { + EndpointUri = new Uri("sb://mysb.servicebus.windows.net/"), + EntityPath = "mysbtopic", + AuthenticationType = DigitalTwinsAuthenticationType.IdentityBased, + Identity = new DigitalTwinsManagedIdentityReference + { + IdentityType = DigitalTwinsManagedIdentityType.UserAssigned, + UserAssignedIdentity = "/subscriptions/50016170-c839-41ba-a724-51e9df440b9e/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity", + }, + }); + ArmOperation lro = await digitalTwinsEndpointResource.UpdateAsync(WaitUntil.Completed, data); DigitalTwinsEndpointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsEndpointResourceCollection.cs b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsEndpointResourceCollection.cs index 183b32bb49daf..3647bc40ba19b 100644 --- a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsEndpointResourceCollection.cs +++ b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsEndpointResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DigitalTwinsEndpointResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetADigitalTwinsInstanceEndpoints() + public async Task CreateOrUpdate_PutADigitalTwinsEndpointResource() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointsGet_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,30 @@ public async Task GetAll_GetADigitalTwinsInstanceEndpoints() // get the collection of this DigitalTwinsEndpointResource DigitalTwinsEndpointResourceCollection collection = digitalTwinsDescription.GetDigitalTwinsEndpointResources(); - // invoke the operation and iterate over the result - await foreach (DigitalTwinsEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string endpointName = "myServiceBus"; + DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsEndpointResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrimaryConnectionString = "Endpoint=sb://mysb.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xyzxyzoX4=;EntityPath=abcabc", + SecondaryConnectionString = "Endpoint=sb://mysb.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xyzxyzoX4=;EntityPath=abcabc", + AuthenticationType = DigitalTwinsAuthenticationType.KeyBased, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); + DigitalTwinsEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetADigitalTwinsInstanceEndpointsWithIdentity() + public async Task CreateOrUpdate_PutADigitalTwinsEndpointResourceWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointsGet_WithIdentity_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,25 +80,30 @@ public async Task GetAll_GetADigitalTwinsInstanceEndpointsWithIdentity() // get the collection of this DigitalTwinsEndpointResource DigitalTwinsEndpointResourceCollection collection = digitalTwinsDescription.GetDigitalTwinsEndpointResources(); - // invoke the operation and iterate over the result - await foreach (DigitalTwinsEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string endpointName = "myServiceBus"; + DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsEndpointResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EndpointUri = new Uri("sb://mysb.servicebus.windows.net/"), + EntityPath = "mysbtopic", + AuthenticationType = DigitalTwinsAuthenticationType.IdentityBased, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); + DigitalTwinsEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADigitalTwinsInstanceEndpoint() + public async Task CreateOrUpdate_PutADigitalTwinsEndpointResourceWithUserAssignedIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_WithUserIdentity_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,7 +123,19 @@ public async Task Get_GetADigitalTwinsInstanceEndpoint() // invoke the operation string endpointName = "myServiceBus"; - DigitalTwinsEndpointResource result = await collection.GetAsync(endpointName); + DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties + { + EndpointUri = new Uri("sb://mysb.servicebus.windows.net/"), + EntityPath = "mysbtopic", + AuthenticationType = DigitalTwinsAuthenticationType.IdentityBased, + Identity = new DigitalTwinsManagedIdentityReference + { + IdentityType = DigitalTwinsManagedIdentityType.UserAssigned, + UserAssignedIdentity = "/subscriptions/50016170-c839-41ba-a724-51e9df440b9e/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity", + }, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); + DigitalTwinsEndpointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -124,7 +146,7 @@ public async Task Get_GetADigitalTwinsInstanceEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADigitalTwinsInstanceEndpoint() + public async Task Get_GetADigitalTwinsInstanceEndpoint() { // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_example.json // this example is just showing the usage of "DigitalTwinsEndpoint_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,16 +169,20 @@ public async Task Exists_GetADigitalTwinsInstanceEndpoint() // invoke the operation string endpointName = "myServiceBus"; - bool result = await collection.ExistsAsync(endpointName); + DigitalTwinsEndpointResource result = await collection.GetAsync(endpointName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADigitalTwinsInstanceEndpoint() + public async Task Get_GetADigitalTwinsInstanceEndpointWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_example.json + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_WithIdentity_example.json // this example is just showing the usage of "DigitalTwinsEndpoint_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -177,29 +203,21 @@ public async Task GetIfExists_GetADigitalTwinsInstanceEndpoint() // invoke the operation string endpointName = "myServiceBus"; - NullableResponse response = await collection.GetIfExistsAsync(endpointName); - DigitalTwinsEndpointResource result = response.HasValue ? response.Value : null; + DigitalTwinsEndpointResource result = await collection.GetAsync(endpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsEndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADigitalTwinsInstanceEndpointWithIdentity() + public async Task GetAll_GetADigitalTwinsInstanceEndpoints() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_WithIdentity_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointsGet_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,23 +235,25 @@ public async Task Get_GetADigitalTwinsInstanceEndpointWithIdentity() // get the collection of this DigitalTwinsEndpointResource DigitalTwinsEndpointResourceCollection collection = digitalTwinsDescription.GetDigitalTwinsEndpointResources(); - // invoke the operation - string endpointName = "myServiceBus"; - DigitalTwinsEndpointResource result = await collection.GetAsync(endpointName); + // invoke the operation and iterate over the result + await foreach (DigitalTwinsEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsEndpointResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsEndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADigitalTwinsInstanceEndpointWithIdentity() + public async Task GetAll_GetADigitalTwinsInstanceEndpointsWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_WithIdentity_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointsGet_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -251,18 +271,24 @@ public async Task Exists_GetADigitalTwinsInstanceEndpointWithIdentity() // get the collection of this DigitalTwinsEndpointResource DigitalTwinsEndpointResourceCollection collection = digitalTwinsDescription.GetDigitalTwinsEndpointResources(); - // invoke the operation - string endpointName = "myServiceBus"; - bool result = await collection.ExistsAsync(endpointName); + // invoke the operation and iterate over the result + await foreach (DigitalTwinsEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsEndpointResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADigitalTwinsInstanceEndpointWithIdentity() + public async Task Exists_GetADigitalTwinsInstanceEndpoint() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_WithIdentity_example.json + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_example.json // this example is just showing the usage of "DigitalTwinsEndpoint_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -283,29 +309,17 @@ public async Task GetIfExists_GetADigitalTwinsInstanceEndpointWithIdentity() // invoke the operation string endpointName = "myServiceBus"; - NullableResponse response = await collection.GetIfExistsAsync(endpointName); - DigitalTwinsEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(endpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsEndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutADigitalTwinsEndpointResource() + public async Task Exists_GetADigitalTwinsInstanceEndpointWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -325,28 +339,17 @@ public async Task CreateOrUpdate_PutADigitalTwinsEndpointResource() // invoke the operation string endpointName = "myServiceBus"; - DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties() - { - PrimaryConnectionString = "Endpoint=sb://mysb.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xyzxyzoX4=;EntityPath=abcabc", - SecondaryConnectionString = "Endpoint=sb://mysb.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=xyzxyzoX4=;EntityPath=abcabc", - AuthenticationType = DigitalTwinsAuthenticationType.KeyBased, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); - DigitalTwinsEndpointResource result = lro.Value; + bool result = await collection.ExistsAsync(endpointName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsEndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutADigitalTwinsEndpointResourceWithIdentity() + public async Task GetIfExists_GetADigitalTwinsInstanceEndpoint() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_WithIdentity_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -366,28 +369,29 @@ public async Task CreateOrUpdate_PutADigitalTwinsEndpointResourceWithIdentity() // invoke the operation string endpointName = "myServiceBus"; - DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties() - { - EndpointUri = new Uri("sb://mysb.servicebus.windows.net/"), - EntityPath = "mysbtopic", - AuthenticationType = DigitalTwinsAuthenticationType.IdentityBased, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); - DigitalTwinsEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(endpointName); + DigitalTwinsEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsEndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutADigitalTwinsEndpointResourceWithUserAssignedIdentity() + public async Task GetIfExists_GetADigitalTwinsInstanceEndpointWithIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointPut_WithUserIdentity_example.json - // this example is just showing the usage of "DigitalTwinsEndpoint_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsEndpointGet_WithIdentity_example.json + // this example is just showing the usage of "DigitalTwinsEndpoint_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -407,25 +411,21 @@ public async Task CreateOrUpdate_PutADigitalTwinsEndpointResourceWithUserAssigne // invoke the operation string endpointName = "myServiceBus"; - DigitalTwinsEndpointResourceData data = new DigitalTwinsEndpointResourceData(new DigitalTwinsServiceBusProperties() - { - EndpointUri = new Uri("sb://mysb.servicebus.windows.net/"), - EntityPath = "mysbtopic", - AuthenticationType = DigitalTwinsAuthenticationType.IdentityBased, - Identity = new DigitalTwinsManagedIdentityReference() - { - IdentityType = DigitalTwinsManagedIdentityType.UserAssigned, - UserAssignedIdentity = "/subscriptions/50016170-c839-41ba-a724-51e9df440b9e/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity", - }, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); - DigitalTwinsEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(endpointName); + DigitalTwinsEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsEndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsEndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateEndpointConnectionCollection.cs b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateEndpointConnectionCollection.cs index 2117b162c23bd..389c926c95ef1 100644 --- a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateEndpointConnectionCollection.cs +++ b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DigitalTwinsPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateEndpointConnectionProperties() + public async Task CreateOrUpdate_UpdateTheStatusOfAPrivateEndpointConnectionWithTheGivenName() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateEndpointConnectionsList_example.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateEndpointConnectionPut_example.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ListPrivateEndpointConnectionProperties() // get the collection of this DigitalTwinsPrivateEndpointConnectionResource DigitalTwinsPrivateEndpointConnectionCollection collection = digitalTwinsDescription.GetDigitalTwinsPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (DigitalTwinsPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "myPrivateConnection"; + DigitalTwinsPrivateEndpointConnectionData data = new DigitalTwinsPrivateEndpointConnectionData(new DigitalTwinsPrivateEndpointConnectionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrivateLinkServiceConnectionState = new DigitalTwinsPrivateLinkServiceConnectionState(DigitalTwinsPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@company.com."), + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + DigitalTwinsPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_GetPrivateEndpointConnectionPropertiesForTheGivenPrivateEn [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateEndpointConnectionPropertiesForTheGivenPrivateEndpoint() + public async Task GetAll_ListPrivateEndpointConnectionProperties() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateEndpointConnectionByConnectionName_example.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateEndpointConnectionsList_example.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_GetPrivateEndpointConnectionPropertiesForTheGivenPrivat // get the collection of this DigitalTwinsPrivateEndpointConnectionResource DigitalTwinsPrivateEndpointConnectionCollection collection = digitalTwinsDescription.GetDigitalTwinsPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "myPrivateConnection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (DigitalTwinsPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateEndpointConnectionPropertiesForTheGivenPrivateEndpoint() + public async Task Exists_GetPrivateEndpointConnectionPropertiesForTheGivenPrivateEndpoint() { // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateEndpointConnectionByConnectionName_example.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_GetPrivateEndpointConnectionPropertiesForTheGivenP // invoke the operation string privateEndpointConnectionName = "myPrivateConnection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - DigitalTwinsPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTheStatusOfAPrivateEndpointConnectionWithTheGivenName() + public async Task GetIfExists_GetPrivateEndpointConnectionPropertiesForTheGivenPrivateEndpoint() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateEndpointConnectionPut_example.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateEndpointConnectionByConnectionName_example.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_UpdateTheStatusOfAPrivateEndpointConnectionWith // invoke the operation string privateEndpointConnectionName = "myPrivateConnection"; - DigitalTwinsPrivateEndpointConnectionData data = new DigitalTwinsPrivateEndpointConnectionData(new DigitalTwinsPrivateEndpointConnectionProperties() - { - PrivateLinkServiceConnectionState = new DigitalTwinsPrivateLinkServiceConnectionState(DigitalTwinsPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@company.com."), - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - DigitalTwinsPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + DigitalTwinsPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateEndpointConnectionResource.cs b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateEndpointConnectionResource.cs index 2ebce7d3049d2..065ffea047663 100644 --- a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateEndpointConnectionResource.cs +++ b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateEndpointConnectionResource.cs @@ -96,7 +96,7 @@ public async Task Update_UpdateTheStatusOfAPrivateEndpointConnectionWithTheGiven DigitalTwinsPrivateEndpointConnectionResource digitalTwinsPrivateEndpointConnection = client.GetDigitalTwinsPrivateEndpointConnectionResource(digitalTwinsPrivateEndpointConnectionResourceId); // invoke the operation - DigitalTwinsPrivateEndpointConnectionData data = new DigitalTwinsPrivateEndpointConnectionData(new DigitalTwinsPrivateEndpointConnectionProperties() + DigitalTwinsPrivateEndpointConnectionData data = new DigitalTwinsPrivateEndpointConnectionData(new DigitalTwinsPrivateEndpointConnectionProperties { PrivateLinkServiceConnectionState = new DigitalTwinsPrivateLinkServiceConnectionState(DigitalTwinsPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@company.com."), }); diff --git a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateLinkResourceCollection.cs b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateLinkResourceCollection.cs index 0c66490737ea5..05bccb2fb1efb 100644 --- a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateLinkResourceCollection.cs +++ b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_DigitalTwinsPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DigitalTwinsPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateLinkResourcesForGivenDigitalTwin() + public async Task Get_GetTheSpecifiedPrivateLinkResourceForTheGivenDigitalTwin() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateLinkResourcesList_example.json - // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateLinkResourcesByGroupId_example.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListPrivateLinkResourcesForGivenDigitalTwin() // get the collection of this DigitalTwinsPrivateLinkResource DigitalTwinsPrivateLinkResourceCollection collection = digitalTwinsDescription.GetDigitalTwinsPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (DigitalTwinsPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string resourceId = "subResource"; + DigitalTwinsPrivateLinkResource result = await collection.GetAsync(resourceId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheSpecifiedPrivateLinkResourceForTheGivenDigitalTwin() + public async Task GetAll_ListPrivateLinkResourcesForGivenDigitalTwin() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateLinkResourcesByGroupId_example.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/PrivateLinkResourcesList_example.json + // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetTheSpecifiedPrivateLinkResourceForTheGivenDigitalTwin() // get the collection of this DigitalTwinsPrivateLinkResource DigitalTwinsPrivateLinkResourceCollection collection = digitalTwinsDescription.GetDigitalTwinsPrivateLinkResources(); - // invoke the operation - string resourceId = "subResource"; - DigitalTwinsPrivateLinkResource result = await collection.GetAsync(resourceId); + // invoke the operation and iterate over the result + await foreach (DigitalTwinsPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DigitalTwinsPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..b553e9f263a34 --- /dev/null +++ b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.DigitalTwins.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.DigitalTwins.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDigitalTwinsDescriptions_GetDigitalTwinsInstanceResourcesBySubscription() + { + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsList_example.json + // this example is just showing the usage of "DigitalTwins_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "50016170-c839-41ba-a724-51e9df440b9e"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DigitalTwinsDescriptionResource item in subscriptionResource.GetDigitalTwinsDescriptionsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DigitalTwinsDescriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckDigitalTwinsNameAvailability_CheckNameAvailability() + { + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/DigitalTwinsCheckNameAvailability_example.json + // this example is just showing the usage of "DigitalTwins_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "50016170-c839-41ba-a724-51e9df440b9e"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("WestUS2"); + DigitalTwinsNameContent content = new DigitalTwinsNameContent("myadtinstance"); + DigitalTwinsNameResult result = await subscriptionResource.CheckDigitalTwinsNameAvailabilityAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_TimeSeriesDatabaseConnectionCollection.cs b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_TimeSeriesDatabaseConnectionCollection.cs index ffc9c19fd0354..b6670e0f4bce9 100644 --- a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_TimeSeriesDatabaseConnectionCollection.cs +++ b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_TimeSeriesDatabaseConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_TimeSeriesDatabaseConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTimeSeriesDatabaseConnectionsForADigitalTwinsInstance() + public async Task CreateOrUpdate_CreateOrReplaceATimeSeriesDatabaseConnectionForADigitalTwinsInstanceWithUserAssignedIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsList_example.json - // this example is just showing the usage of "TimeSeriesDatabaseConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsPut_WithUserIdentity_example.json + // this example is just showing the usage of "TimeSeriesDatabaseConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,42 @@ public async Task GetAll_ListTimeSeriesDatabaseConnectionsForADigitalTwinsInstan // get the collection of this TimeSeriesDatabaseConnectionResource TimeSeriesDatabaseConnectionCollection collection = digitalTwinsDescription.GetTimeSeriesDatabaseConnections(); - // invoke the operation and iterate over the result - await foreach (TimeSeriesDatabaseConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string timeSeriesDatabaseConnectionName = "myConnection"; + TimeSeriesDatabaseConnectionData data = new TimeSeriesDatabaseConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TimeSeriesDatabaseConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new DataExplorerConnectionProperties( + new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.Kusto/clusters/mycluster"), + new Uri("https://mycluster.kusto.windows.net"), + "myDatabase", + new Uri("sb://myeh.servicebus.windows.net/"), + "myeh", + new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.EventHub/namespaces/myeh")) + { + AdxTableName = "myTable", + Identity = new DigitalTwinsManagedIdentityReference + { + IdentityType = DigitalTwinsManagedIdentityType.UserAssigned, + UserAssignedIdentity = "/subscriptions/50016170-c839-41ba-a724-51e9df440b9e/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity", + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, timeSeriesDatabaseConnectionName, data); + TimeSeriesDatabaseConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TimeSeriesDatabaseConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTimeSeriesDatabaseConnectionForADigitalTwinsInstance() + public async Task CreateOrUpdate_CreateOrReplaceATimeSeriesDatabaseConnectionForADigitalTwinsInstance() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsGet_example.json - // this example is just showing the usage of "TimeSeriesDatabaseConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsPut_example.json + // this example is just showing the usage of "TimeSeriesDatabaseConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +94,24 @@ public async Task Get_GetTimeSeriesDatabaseConnectionForADigitalTwinsInstance() // invoke the operation string timeSeriesDatabaseConnectionName = "myConnection"; - TimeSeriesDatabaseConnectionResource result = await collection.GetAsync(timeSeriesDatabaseConnectionName); + TimeSeriesDatabaseConnectionData data = new TimeSeriesDatabaseConnectionData + { + Properties = new DataExplorerConnectionProperties( + new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.Kusto/clusters/mycluster"), + new Uri("https://mycluster.kusto.windows.net"), + "myDatabase", + new Uri("sb://myeh.servicebus.windows.net/"), + "myeh", + new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.EventHub/namespaces/myeh")) + { + AdxTableName = "myPropertyUpdatesTable", + AdxTwinLifecycleEventsTableName = "myTwinLifecycleEventsTable", + AdxRelationshipLifecycleEventsTableName = "myRelationshipLifecycleEventsTable", + RecordPropertyAndItemRemovals = RecordPropertyAndItemRemoval.True, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, timeSeriesDatabaseConnectionName, data); + TimeSeriesDatabaseConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +122,7 @@ public async Task Get_GetTimeSeriesDatabaseConnectionForADigitalTwinsInstance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTimeSeriesDatabaseConnectionForADigitalTwinsInstance() + public async Task Get_GetTimeSeriesDatabaseConnectionForADigitalTwinsInstance() { // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsGet_example.json // this example is just showing the usage of "TimeSeriesDatabaseConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +145,21 @@ public async Task Exists_GetTimeSeriesDatabaseConnectionForADigitalTwinsInstance // invoke the operation string timeSeriesDatabaseConnectionName = "myConnection"; - bool result = await collection.ExistsAsync(timeSeriesDatabaseConnectionName); + TimeSeriesDatabaseConnectionResource result = await collection.GetAsync(timeSeriesDatabaseConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TimeSeriesDatabaseConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTimeSeriesDatabaseConnectionForADigitalTwinsInstance() + public async Task GetAll_ListTimeSeriesDatabaseConnectionsForADigitalTwinsInstance() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsGet_example.json - // this example is just showing the usage of "TimeSeriesDatabaseConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsList_example.json + // this example is just showing the usage of "TimeSeriesDatabaseConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +177,25 @@ public async Task GetIfExists_GetTimeSeriesDatabaseConnectionForADigitalTwinsIns // get the collection of this TimeSeriesDatabaseConnectionResource TimeSeriesDatabaseConnectionCollection collection = digitalTwinsDescription.GetTimeSeriesDatabaseConnections(); - // invoke the operation - string timeSeriesDatabaseConnectionName = "myConnection"; - NullableResponse response = await collection.GetIfExistsAsync(timeSeriesDatabaseConnectionName); - TimeSeriesDatabaseConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (TimeSeriesDatabaseConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - TimeSeriesDatabaseConnectionData resourceData = result.Data; + TimeSeriesDatabaseConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrReplaceATimeSeriesDatabaseConnectionForADigitalTwinsInstanceWithUserAssignedIdentity() + public async Task Exists_GetTimeSeriesDatabaseConnectionForADigitalTwinsInstance() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsPut_WithUserIdentity_example.json - // this example is just showing the usage of "TimeSeriesDatabaseConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsGet_example.json + // this example is just showing the usage of "TimeSeriesDatabaseConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,34 +215,17 @@ public async Task CreateOrUpdate_CreateOrReplaceATimeSeriesDatabaseConnectionFor // invoke the operation string timeSeriesDatabaseConnectionName = "myConnection"; - TimeSeriesDatabaseConnectionData data = new TimeSeriesDatabaseConnectionData() - { - Properties = new DataExplorerConnectionProperties(new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.Kusto/clusters/mycluster"), new Uri("https://mycluster.kusto.windows.net"), "myDatabase", new Uri("sb://myeh.servicebus.windows.net/"), "myeh", new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.EventHub/namespaces/myeh")) - { - AdxTableName = "myTable", - Identity = new DigitalTwinsManagedIdentityReference() - { - IdentityType = DigitalTwinsManagedIdentityType.UserAssigned, - UserAssignedIdentity = "/subscriptions/50016170-c839-41ba-a724-51e9df440b9e/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity", - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, timeSeriesDatabaseConnectionName, data); - TimeSeriesDatabaseConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(timeSeriesDatabaseConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TimeSeriesDatabaseConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrReplaceATimeSeriesDatabaseConnectionForADigitalTwinsInstance() + public async Task GetIfExists_GetTimeSeriesDatabaseConnectionForADigitalTwinsInstance() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsPut_example.json - // this example is just showing the usage of "TimeSeriesDatabaseConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsGet_example.json + // this example is just showing the usage of "TimeSeriesDatabaseConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -230,24 +245,21 @@ public async Task CreateOrUpdate_CreateOrReplaceATimeSeriesDatabaseConnectionFor // invoke the operation string timeSeriesDatabaseConnectionName = "myConnection"; - TimeSeriesDatabaseConnectionData data = new TimeSeriesDatabaseConnectionData() - { - Properties = new DataExplorerConnectionProperties(new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.Kusto/clusters/mycluster"), new Uri("https://mycluster.kusto.windows.net"), "myDatabase", new Uri("sb://myeh.servicebus.windows.net/"), "myeh", new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.EventHub/namespaces/myeh")) - { - AdxTableName = "myPropertyUpdatesTable", - AdxTwinLifecycleEventsTableName = "myTwinLifecycleEventsTable", - AdxRelationshipLifecycleEventsTableName = "myRelationshipLifecycleEventsTable", - RecordPropertyAndItemRemovals = RecordPropertyAndItemRemoval.True, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, timeSeriesDatabaseConnectionName, data); - TimeSeriesDatabaseConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(timeSeriesDatabaseConnectionName); + TimeSeriesDatabaseConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TimeSeriesDatabaseConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TimeSeriesDatabaseConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_TimeSeriesDatabaseConnectionResource.cs b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_TimeSeriesDatabaseConnectionResource.cs index 3b22e90a81b48..863366fa5719a 100644 --- a/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_TimeSeriesDatabaseConnectionResource.cs +++ b/sdk/digitaltwins/Azure.ResourceManager.DigitalTwins/samples/Generated/Samples/Sample_TimeSeriesDatabaseConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetTimeSeriesDatabaseConnectionForADigitalTwinsInstance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrReplaceATimeSeriesDatabaseConnectionForADigitalTwinsInstanceWithUserAssignedIdentity() + public async Task Delete_DeleteATimeSeriesDatabaseConnectionForADigitalTwinsInstance() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsPut_WithUserIdentity_example.json - // this example is just showing the usage of "TimeSeriesDatabaseConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsDelete_example.json + // this example is just showing the usage of "TimeSeriesDatabaseConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,19 +69,7 @@ public async Task Update_CreateOrReplaceATimeSeriesDatabaseConnectionForADigital TimeSeriesDatabaseConnectionResource timeSeriesDatabaseConnection = client.GetTimeSeriesDatabaseConnectionResource(timeSeriesDatabaseConnectionResourceId); // invoke the operation - TimeSeriesDatabaseConnectionData data = new TimeSeriesDatabaseConnectionData() - { - Properties = new DataExplorerConnectionProperties(new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.Kusto/clusters/mycluster"), new Uri("https://mycluster.kusto.windows.net"), "myDatabase", new Uri("sb://myeh.servicebus.windows.net/"), "myeh", new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.EventHub/namespaces/myeh")) - { - AdxTableName = "myTable", - Identity = new DigitalTwinsManagedIdentityReference() - { - IdentityType = DigitalTwinsManagedIdentityType.UserAssigned, - UserAssignedIdentity = "/subscriptions/50016170-c839-41ba-a724-51e9df440b9e/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity", - }, - }, - }; - ArmOperation lro = await timeSeriesDatabaseConnection.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await timeSeriesDatabaseConnection.DeleteAsync(WaitUntil.Completed); TimeSeriesDatabaseConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -93,9 +81,9 @@ public async Task Update_CreateOrReplaceATimeSeriesDatabaseConnectionForADigital [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrReplaceATimeSeriesDatabaseConnectionForADigitalTwinsInstance() + public async Task Update_CreateOrReplaceATimeSeriesDatabaseConnectionForADigitalTwinsInstanceWithUserAssignedIdentity() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsPut_example.json + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsPut_WithUserIdentity_example.json // this example is just showing the usage of "TimeSeriesDatabaseConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -113,14 +101,22 @@ public async Task Update_CreateOrReplaceATimeSeriesDatabaseConnectionForADigital TimeSeriesDatabaseConnectionResource timeSeriesDatabaseConnection = client.GetTimeSeriesDatabaseConnectionResource(timeSeriesDatabaseConnectionResourceId); // invoke the operation - TimeSeriesDatabaseConnectionData data = new TimeSeriesDatabaseConnectionData() + TimeSeriesDatabaseConnectionData data = new TimeSeriesDatabaseConnectionData { - Properties = new DataExplorerConnectionProperties(new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.Kusto/clusters/mycluster"), new Uri("https://mycluster.kusto.windows.net"), "myDatabase", new Uri("sb://myeh.servicebus.windows.net/"), "myeh", new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.EventHub/namespaces/myeh")) + Properties = new DataExplorerConnectionProperties( + new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.Kusto/clusters/mycluster"), + new Uri("https://mycluster.kusto.windows.net"), + "myDatabase", + new Uri("sb://myeh.servicebus.windows.net/"), + "myeh", + new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.EventHub/namespaces/myeh")) { - AdxTableName = "myPropertyUpdatesTable", - AdxTwinLifecycleEventsTableName = "myTwinLifecycleEventsTable", - AdxRelationshipLifecycleEventsTableName = "myRelationshipLifecycleEventsTable", - RecordPropertyAndItemRemovals = RecordPropertyAndItemRemoval.True, + AdxTableName = "myTable", + Identity = new DigitalTwinsManagedIdentityReference + { + IdentityType = DigitalTwinsManagedIdentityType.UserAssigned, + UserAssignedIdentity = "/subscriptions/50016170-c839-41ba-a724-51e9df440b9e/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity", + }, }, }; ArmOperation lro = await timeSeriesDatabaseConnection.UpdateAsync(WaitUntil.Completed, data); @@ -135,10 +131,10 @@ public async Task Update_CreateOrReplaceATimeSeriesDatabaseConnectionForADigital [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteATimeSeriesDatabaseConnectionForADigitalTwinsInstance() + public async Task Update_CreateOrReplaceATimeSeriesDatabaseConnectionForADigitalTwinsInstance() { - // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsDelete_example.json - // this example is just showing the usage of "TimeSeriesDatabaseConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/digitaltwins/resource-manager/Microsoft.DigitalTwins/stable/2023-01-31/examples/TimeSeriesDatabaseConnectionsPut_example.json + // this example is just showing the usage of "TimeSeriesDatabaseConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -155,7 +151,23 @@ public async Task Delete_DeleteATimeSeriesDatabaseConnectionForADigitalTwinsInst TimeSeriesDatabaseConnectionResource timeSeriesDatabaseConnection = client.GetTimeSeriesDatabaseConnectionResource(timeSeriesDatabaseConnectionResourceId); // invoke the operation - ArmOperation lro = await timeSeriesDatabaseConnection.DeleteAsync(WaitUntil.Completed); + TimeSeriesDatabaseConnectionData data = new TimeSeriesDatabaseConnectionData + { + Properties = new DataExplorerConnectionProperties( + new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.Kusto/clusters/mycluster"), + new Uri("https://mycluster.kusto.windows.net"), + "myDatabase", + new Uri("sb://myeh.servicebus.windows.net/"), + "myeh", + new ResourceIdentifier("/subscriptions/c493073e-2460-45ba-a403-f3e0df1e9feg/resourceGroups/testrg/providers/Microsoft.EventHub/namespaces/myeh")) + { + AdxTableName = "myPropertyUpdatesTable", + AdxTwinLifecycleEventsTableName = "myTwinLifecycleEventsTable", + AdxRelationshipLifecycleEventsTableName = "myRelationshipLifecycleEventsTable", + RecordPropertyAndItemRemovals = RecordPropertyAndItemRemoval.True, + }, + }; + ArmOperation lro = await timeSeriesDatabaseConnection.UpdateAsync(WaitUntil.Completed, data); TimeSeriesDatabaseConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderAddressCollection.cs b/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderAddressCollection.cs index 4fb90746f2848..ab2d668462e95 100644 --- a/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderAddressCollection.cs +++ b/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderAddressCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_EdgeOrderAddressCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAddressesAtResourceGroupLevel() + public async Task CreateOrUpdate_CreateAddress() { - // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListAddressesAtResourceGroupLevel.json - // this example is just showing the usage of "ListAddressesAtResourceGroupLevel" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/CreateAddress.json + // this example is just showing the usage of "CreateAddress" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,31 @@ public async Task GetAll_ListAddressesAtResourceGroupLevel() // get the collection of this EdgeOrderAddressResource EdgeOrderAddressCollection collection = resourceGroupResource.GetEdgeOrderAddresses(); - // invoke the operation and iterate over the result - await foreach (EdgeOrderAddressResource item in collection.GetAllAsync()) + // invoke the operation + string addressName = "TestMSAddressName"; + EdgeOrderAddressData data = new EdgeOrderAddressData(new AzureLocation("westus"), new EdgeOrderAddressContactDetails("Petr Cech", "1234567890", new string[] { "testemail@microsoft.com" }) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EdgeOrderAddressData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PhoneExtension = "", + }) + { + ShippingAddress = new EdgeOrderShippingAddress("16 TOWNSEND ST", "US") + { + StreetAddress2 = "UNIT 1", + City = "San Francisco", + StateOrProvince = "CA", + PostalCode = "94107", + CompanyName = "Microsoft", + AddressType = EdgeOrderAddressType.None, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addressName, data); + EdgeOrderAddressResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EdgeOrderAddressData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +101,10 @@ public async Task Get_GetAddressByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAddressByName() + public async Task GetAll_ListAddressesAtResourceGroupLevel() { - // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetAddressByName.json - // this example is just showing the usage of "GetAddressByName" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListAddressesAtResourceGroupLevel.json + // this example is just showing the usage of "ListAddressesAtResourceGroupLevel" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +121,22 @@ public async Task Exists_GetAddressByName() // get the collection of this EdgeOrderAddressResource EdgeOrderAddressCollection collection = resourceGroupResource.GetEdgeOrderAddresses(); - // invoke the operation - string addressName = "TestMSAddressName"; - bool result = await collection.ExistsAsync(addressName); + // invoke the operation and iterate over the result + await foreach (EdgeOrderAddressResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EdgeOrderAddressData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAddressByName() + public async Task Exists_GetAddressByName() { // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetAddressByName.json // this example is just showing the usage of "GetAddressByName" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +158,17 @@ public async Task GetIfExists_GetAddressByName() // invoke the operation string addressName = "TestMSAddressName"; - NullableResponse response = await collection.GetIfExistsAsync(addressName); - EdgeOrderAddressResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(addressName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EdgeOrderAddressData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAddress() + public async Task GetIfExists_GetAddressByName() { - // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/CreateAddress.json - // this example is just showing the usage of "CreateAddress" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetAddressByName.json + // this example is just showing the usage of "GetAddressByName" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,32 +187,21 @@ public async Task CreateOrUpdate_CreateAddress() // invoke the operation string addressName = "TestMSAddressName"; - EdgeOrderAddressData data = new EdgeOrderAddressData(new AzureLocation("westus"), new EdgeOrderAddressContactDetails("Petr Cech", "1234567890", new string[] - { -"testemail@microsoft.com" - }) + NullableResponse response = await collection.GetIfExistsAsync(addressName); + EdgeOrderAddressResource result = response.HasValue ? response.Value : null; + + if (result == null) { - PhoneExtension = "", - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - ShippingAddress = new EdgeOrderShippingAddress("16 TOWNSEND ST", "US") - { - StreetAddress2 = "UNIT 1", - City = "San Francisco", - StateOrProvince = "CA", - PostalCode = "94107", - CompanyName = "Microsoft", - AddressType = EdgeOrderAddressType.None, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addressName, data); - EdgeOrderAddressResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EdgeOrderAddressData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EdgeOrderAddressData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderAddressResource.cs b/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderAddressResource.cs index 3e0a50479ef58..f6d2bebf3fa44 100644 --- a/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderAddressResource.cs +++ b/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderAddressResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EdgeOrder.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EdgeOrder.Samples { public partial class Sample_EdgeOrderAddressResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEdgeOrderAddresses_ListAddressesAtSubscriptionLevel() - { - // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListAddressesAtSubscriptionLevel.json - // this example is just showing the usage of "ListAddressesAtSubscriptionLevel" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fa68082f-8ff7-4a25-95c7-ce9da541242f"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (EdgeOrderAddressResource item in subscriptionResource.GetEdgeOrderAddressesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EdgeOrderAddressData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAddressByName() @@ -125,14 +93,14 @@ public async Task Update_UpdateAddress() EdgeOrderAddressResource edgeOrderAddress = client.GetEdgeOrderAddressResource(edgeOrderAddressResourceId); // invoke the operation - EdgeOrderAddressPatch patch = new EdgeOrderAddressPatch() + EdgeOrderAddressPatch patch = new EdgeOrderAddressPatch { Tags = { ["Hobby"] = "Web Series Added", ["Name"] = "Smile-Updated", ["WhatElse"] = "Web Series Added", -["Work"] = "Engineering", +["Work"] = "Engineering" }, ShippingAddress = new EdgeOrderShippingAddress("16 TOWNSEND STT", "US") { @@ -143,10 +111,7 @@ public async Task Update_UpdateAddress() CompanyName = "Microsoft", AddressType = EdgeOrderAddressType.None, }, - ContactDetails = new EdgeOrderAddressContactDetails("Petr Cech", "1234567890", new string[] - { -"ssemcr@microsoft.com" - }) + ContactDetails = new EdgeOrderAddressContactDetails("Petr Cech", "1234567890", new string[] { "ssemcr@microsoft.com" }) { PhoneExtension = "", }, diff --git a/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderItemCollection.cs b/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderItemCollection.cs index 55f3624c32cef..8d41016bc287c 100644 --- a/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderItemCollection.cs +++ b/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderItemCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_EdgeOrderItemCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOrderItemsAtResourceGroupLevel() + public async Task CreateOrUpdate_CreateOrderItem() { - // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderItemsAtResourceGroupLevel.json - // this example is just showing the usage of "ListOrderItemsAtResourceGroupLevel" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/CreateOrderItem.json + // this example is just showing the usage of "CreateOrderItem" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,48 @@ public async Task GetAll_ListOrderItemsAtResourceGroupLevel() // get the collection of this EdgeOrderItemResource EdgeOrderItemCollection collection = resourceGroupResource.GetEdgeOrderItems(); - // invoke the operation and iterate over the result - await foreach (EdgeOrderItemResource item in collection.GetAllAsync()) + // invoke the operation + string orderItemName = "TestOrderItemName01"; + EdgeOrderItemData data = new EdgeOrderItemData(new AzureLocation("westus"), new EdgeOrderItemDetails(new ProductDetails(new HierarchyInformation { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EdgeOrderItemData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProductFamilyName = "AzureStackEdge", + ProductLineName = "AzureStackEdge", + ProductName = "AzureStackEdgeGPU", + ConfigurationName = "AzureStackEdgeGPU", + }), OrderItemType.Purchase) + { + Preferences = new OrderItemPreferences + { + TransportPreferencesPreferredShipmentType = TransportShipmentType.MicrosoftManaged, + }, + }, new EdgeOrderItemAddressDetails(new EdgeOrderItemAddressProperties(new EdgeOrderAddressContactDetails("164 TOWNSEND ST", "3213131190", new string[] { "ssemmail@microsoft.com", "vishwamdir@microsoft.com" })) + { + ShippingAddress = new EdgeOrderShippingAddress("16 TOWNSEND ST", "US") + { + StreetAddress2 = "UNIT 1", + City = "San Francisco", + StateOrProvince = "CA", + PostalCode = "94107", + ZipExtendedCode = "1", + CompanyName = "Microsoft", + AddressType = EdgeOrderAddressType.Residential, + }, + }), new ResourceIdentifier("/subscriptions/fa68082f-8ff7-4a25-95c7-ce9da541242f/resourceGroups/TestRG/providers/Microsoft.EdgeOrder/locations/westus/orders/TestOrderItemName01")) + { + Tags = +{ +["carrot"] = "vegetable", +["mango"] = "fruit" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, orderItemName, data); + EdgeOrderItemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EdgeOrderItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +118,10 @@ public async Task Get_GetOrderItemByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetOrderItemByName() + public async Task GetAll_ListOrderItemsAtResourceGroupLevel() { - // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetOrderItemByName.json - // this example is just showing the usage of "GetOrderItemByName" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderItemsAtResourceGroupLevel.json + // this example is just showing the usage of "ListOrderItemsAtResourceGroupLevel" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +138,22 @@ public async Task Exists_GetOrderItemByName() // get the collection of this EdgeOrderItemResource EdgeOrderItemCollection collection = resourceGroupResource.GetEdgeOrderItems(); - // invoke the operation - string orderItemName = "TestOrderItemName01"; - bool result = await collection.ExistsAsync(orderItemName); + // invoke the operation and iterate over the result + await foreach (EdgeOrderItemResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EdgeOrderItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetOrderItemByName() + public async Task Exists_GetOrderItemByName() { // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetOrderItemByName.json // this example is just showing the usage of "GetOrderItemByName" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +175,17 @@ public async Task GetIfExists_GetOrderItemByName() // invoke the operation string orderItemName = "TestOrderItemName01"; - NullableResponse response = await collection.GetIfExistsAsync(orderItemName); - EdgeOrderItemResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(orderItemName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EdgeOrderItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrderItem() + public async Task GetIfExists_GetOrderItemByName() { - // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/CreateOrderItem.json - // this example is just showing the usage of "CreateOrderItem" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/GetOrderItemByName.json + // this example is just showing the usage of "GetOrderItemByName" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,49 +204,21 @@ public async Task CreateOrUpdate_CreateOrderItem() // invoke the operation string orderItemName = "TestOrderItemName01"; - EdgeOrderItemData data = new EdgeOrderItemData(new AzureLocation("westus"), new EdgeOrderItemDetails(new ProductDetails(new HierarchyInformation() - { - ProductFamilyName = "AzureStackEdge", - ProductLineName = "AzureStackEdge", - ProductName = "AzureStackEdgeGPU", - ConfigurationName = "AzureStackEdgeGPU", - }), OrderItemType.Purchase) - { - Preferences = new OrderItemPreferences() - { - TransportPreferencesPreferredShipmentType = TransportShipmentType.MicrosoftManaged, - }, - }, new EdgeOrderItemAddressDetails(new EdgeOrderItemAddressProperties(new EdgeOrderAddressContactDetails("164 TOWNSEND ST", "3213131190", new string[] - { -"ssemmail@microsoft.com","vishwamdir@microsoft.com" - })) + NullableResponse response = await collection.GetIfExistsAsync(orderItemName); + EdgeOrderItemResource result = response.HasValue ? response.Value : null; + + if (result == null) { - ShippingAddress = new EdgeOrderShippingAddress("16 TOWNSEND ST", "US") - { - StreetAddress2 = "UNIT 1", - City = "San Francisco", - StateOrProvince = "CA", - PostalCode = "94107", - ZipExtendedCode = "1", - CompanyName = "Microsoft", - AddressType = EdgeOrderAddressType.Residential, - }, - }), new ResourceIdentifier("/subscriptions/fa68082f-8ff7-4a25-95c7-ce9da541242f/resourceGroups/TestRG/providers/Microsoft.EdgeOrder/locations/westus/orders/TestOrderItemName01")) + Console.WriteLine("Succeeded with null as result"); + } + else { - Tags = -{ -["carrot"] = "vegetable", -["mango"] = "fruit", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, orderItemName, data); - EdgeOrderItemResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EdgeOrderItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EdgeOrderItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderItemResource.cs b/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderItemResource.cs index b98533dab0115..a77049e4b3296 100644 --- a/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderItemResource.cs +++ b/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_EdgeOrderItemResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EdgeOrder.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EdgeOrder.Samples { public partial class Sample_EdgeOrderItemResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEdgeOrderItems_ListOrderItemsAtSubscriptionLevel() - { - // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderItemsAtSubscriptionLevel.json - // this example is just showing the usage of "ListOrderItemsAtSubscriptionLevel" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fa68082f-8ff7-4a25-95c7-ce9da541242f"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (EdgeOrderItemResource item in subscriptionResource.GetEdgeOrderItemsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EdgeOrderItemData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetOrderItemByName() @@ -125,19 +93,16 @@ public async Task Update_UpdateOrderItem() EdgeOrderItemResource edgeOrderItem = client.GetEdgeOrderItemResource(edgeOrderItemResourceId); // invoke the operation - EdgeOrderItemPatch patch = new EdgeOrderItemPatch() + EdgeOrderItemPatch patch = new EdgeOrderItemPatch { Tags = { ["ant"] = "insect", ["pigeon"] = "bird", -["tiger"] = "animal", +["tiger"] = "animal" }, - ForwardAddress = new EdgeOrderItemAddressProperties(new EdgeOrderAddressContactDetails("Updated contact name", "2222200000", new string[] - { -"testemail@microsoft.com" - })), - Preferences = new OrderItemPreferences() + ForwardAddress = new EdgeOrderItemAddressProperties(new EdgeOrderAddressContactDetails("Updated contact name", "2222200000", new string[] { "testemail@microsoft.com" })), + Preferences = new OrderItemPreferences { TransportPreferencesPreferredShipmentType = TransportShipmentType.CustomerManaged, }, diff --git a/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 656a5e9919bdf..afe8473e72e2b 100644 --- a/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/edgeorder/Azure.ResourceManager.EdgeOrder/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -18,6 +18,37 @@ namespace Azure.ResourceManager.EdgeOrder.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEdgeOrderAddresses_ListAddressesAtSubscriptionLevel() + { + // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListAddressesAtSubscriptionLevel.json + // this example is just showing the usage of "ListAddressesAtSubscriptionLevel" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fa68082f-8ff7-4a25-95c7-ce9da541242f"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EdgeOrderAddressResource item in subscriptionResource.GetEdgeOrderAddressesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EdgeOrderAddressData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetProductFamilies_ListProductFamilies() @@ -37,15 +68,12 @@ public async Task GetProductFamilies_ListProductFamilies() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - ProductFamiliesContent content = new ProductFamiliesContent(new Dictionary>() + ProductFamiliesContent content = new ProductFamiliesContent(new Dictionary> { ["azurestackedge"] = new FilterableProperty[] { -new FilterableProperty(SupportedFilterType.ShipToCountries,new string[] -{ -"US" -}) - }, +new FilterableProperty(SupportedFilterType.ShipToCountries, new string[]{"US"}) + } }); await foreach (ProductFamily item in subscriptionResource.GetProductFamiliesAsync(content)) { @@ -76,20 +104,14 @@ public async Task GetConfigurations_ListConfigurations() // invoke the operation and iterate over the result ConfigurationsContent content = new ConfigurationsContent(new ConfigurationFilters[] { -new ConfigurationFilters(new HierarchyInformation() +new ConfigurationFilters(new HierarchyInformation { ProductFamilyName = "AzureStackEdge", ProductLineName = "AzureStackEdge", ProductName = "AzureStackEdgeGPU", }) { -FilterableProperty = -{ -new FilterableProperty(SupportedFilterType.ShipToCountries,new string[] -{ -"US" -}) -}, +FilterableProperty = {new FilterableProperty(SupportedFilterType.ShipToCountries, new string[]{"US"})}, } }); await foreach (ProductConfiguration item in subscriptionResource.GetConfigurationsAsync(content)) @@ -157,5 +179,36 @@ public async Task GetEdgeOrders_ListOrderAtSubscriptionLevel() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEdgeOrderItems_ListOrderItemsAtSubscriptionLevel() + { + // Generated from example definition: specification/edgeorder/resource-manager/Microsoft.EdgeOrder/stable/2021-12-01/examples/ListOrderItemsAtSubscriptionLevel.json + // this example is just showing the usage of "ListOrderItemsAtSubscriptionLevel" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fa68082f-8ff7-4a25-95c7-ce9da541242f"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EdgeOrderItemResource item in subscriptionResource.GetEdgeOrderItemsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EdgeOrderItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/edgezones/Azure.ResourceManager.EdgeZones/samples/Generated/Samples/Sample_ExtendedZoneCollection.cs b/sdk/edgezones/Azure.ResourceManager.EdgeZones/samples/Generated/Samples/Sample_ExtendedZoneCollection.cs index 66c48a5f7b86e..35fd1efc1cfc9 100644 --- a/sdk/edgezones/Azure.ResourceManager.EdgeZones/samples/Generated/Samples/Sample_ExtendedZoneCollection.cs +++ b/sdk/edgezones/Azure.ResourceManager.EdgeZones/samples/Generated/Samples/Sample_ExtendedZoneCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ExtendedZoneCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExtendedZones() + public async Task Get_GetExtendedZone() { - // Generated from example definition: specification/edgezones/resource-manager/Microsoft.EdgeZones/preview/2024-04-01-preview/examples/ExtendedZones_ListBySubscription.json - // this example is just showing the usage of "ExtendedZones_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/edgezones/resource-manager/Microsoft.EdgeZones/preview/2024-04-01-preview/examples/ExtendedZones_Get.json + // this example is just showing the usage of "ExtendedZones_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_ListExtendedZones() // get the collection of this ExtendedZoneResource ExtendedZoneCollection collection = subscriptionResource.GetExtendedZones(); - // invoke the operation and iterate over the result - await foreach (ExtendedZoneResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedZoneData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string extendedZoneName = "losangeles"; + ExtendedZoneResource result = await collection.GetAsync(extendedZoneName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedZoneData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExtendedZone() + public async Task GetAll_ListExtendedZones() { - // Generated from example definition: specification/edgezones/resource-manager/Microsoft.EdgeZones/preview/2024-04-01-preview/examples/ExtendedZones_Get.json - // this example is just showing the usage of "ExtendedZones_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/edgezones/resource-manager/Microsoft.EdgeZones/preview/2024-04-01-preview/examples/ExtendedZones_ListBySubscription.json + // this example is just showing the usage of "ExtendedZones_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +69,17 @@ public async Task Get_GetExtendedZone() // get the collection of this ExtendedZoneResource ExtendedZoneCollection collection = subscriptionResource.GetExtendedZones(); - // invoke the operation - string extendedZoneName = "losangeles"; - ExtendedZoneResource result = await collection.GetAsync(extendedZoneName); + // invoke the operation and iterate over the result + await foreach (ExtendedZoneResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedZoneData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedZoneData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_ElasticMonitorResource.cs b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_ElasticMonitorResource.cs index 84c96bf1ef04c..1894896a262ec 100644 --- a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_ElasticMonitorResource.cs +++ b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_ElasticMonitorResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Elastic.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Elastic.Samples { public partial class Sample_ElasticMonitorResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetElasticMonitorResources_MonitorsList() - { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_List.json - // this example is just showing the usage of "Monitors_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ElasticMonitorResource item in subscriptionResource.GetElasticMonitorResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticMonitorResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_MonitorsGet() @@ -80,10 +48,10 @@ public async Task Get_MonitorsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MonitorsUpdate() + public async Task Delete_MonitorsDelete() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_Update.json - // this example is just showing the usage of "Monitors_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_Delete.json + // this example is just showing the usage of "Monitors_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,23 +67,17 @@ public async Task Update_MonitorsUpdate() ElasticMonitorResource elasticMonitorResource = client.GetElasticMonitorResource(elasticMonitorResourceId); // invoke the operation - ElasticMonitorResourcePatch patch = new ElasticMonitorResourcePatch(); - ArmOperation lro = await elasticMonitorResource.UpdateAsync(WaitUntil.Completed, patch); - ElasticMonitorResource result = lro.Value; + await elasticMonitorResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticMonitorResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_MonitorsDelete() + public async Task Update_MonitorsUpdate() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_Delete.json - // this example is just showing the usage of "Monitors_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_Update.json + // this example is just showing the usage of "Monitors_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,9 +93,15 @@ public async Task Delete_MonitorsDelete() ElasticMonitorResource elasticMonitorResource = client.GetElasticMonitorResource(elasticMonitorResourceId); // invoke the operation - await elasticMonitorResource.DeleteAsync(WaitUntil.Completed); + ElasticMonitorResourcePatch patch = new ElasticMonitorResourcePatch(); + ArmOperation lro = await elasticMonitorResource.UpdateAsync(WaitUntil.Completed, patch); + ElasticMonitorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticMonitorResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_ElasticMonitorResourceCollection.cs b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_ElasticMonitorResourceCollection.cs index 595b17c770402..fe918e7c73de3 100644 --- a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_ElasticMonitorResourceCollection.cs +++ b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_ElasticMonitorResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ElasticMonitorResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MonitorsListByResourceGroup() + public async Task CreateOrUpdate_MonitorsCreate() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_ListByResourceGroup.json - // this example is just showing the usage of "Monitors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_Create.json + // this example is just showing the usage of "Monitors_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_MonitorsListByResourceGroup() // get the collection of this ElasticMonitorResource ElasticMonitorResourceCollection collection = resourceGroupResource.GetElasticMonitorResources(); - // invoke the operation and iterate over the result - await foreach (ElasticMonitorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticMonitorResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string monitorName = "myMonitor"; + ElasticMonitorResourceData data = new ElasticMonitorResourceData(default); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, monitorName, data); + ElasticMonitorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticMonitorResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +86,10 @@ public async Task Get_MonitorsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MonitorsGet() + public async Task GetAll_MonitorsListByResourceGroup() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_Get.json - // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_ListByResourceGroup.json + // this example is just showing the usage of "Monitors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +106,22 @@ public async Task Exists_MonitorsGet() // get the collection of this ElasticMonitorResource ElasticMonitorResourceCollection collection = resourceGroupResource.GetElasticMonitorResources(); - // invoke the operation - string monitorName = "myMonitor"; - bool result = await collection.ExistsAsync(monitorName); + // invoke the operation and iterate over the result + await foreach (ElasticMonitorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticMonitorResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MonitorsGet() + public async Task Exists_MonitorsGet() { // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_Get.json // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +143,17 @@ public async Task GetIfExists_MonitorsGet() // invoke the operation string monitorName = "myMonitor"; - NullableResponse response = await collection.GetIfExistsAsync(monitorName); - ElasticMonitorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(monitorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticMonitorResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_MonitorsCreate() + public async Task GetIfExists_MonitorsGet() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_Create.json - // this example is just showing the usage of "Monitors_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_Get.json + // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,15 +172,21 @@ public async Task CreateOrUpdate_MonitorsCreate() // invoke the operation string monitorName = "myMonitor"; - ElasticMonitorResourceData data = new ElasticMonitorResourceData(new AzureLocation("placeholder")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, monitorName, data); - ElasticMonitorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(monitorName); + ElasticMonitorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticMonitorResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticMonitorResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoredSubscriptionPropertyCollection.cs b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoredSubscriptionPropertyCollection.cs index 60d633ef97cf8..6f1a24968ebbc 100644 --- a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoredSubscriptionPropertyCollection.cs +++ b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoredSubscriptionPropertyCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MonitoredSubscriptionPropertyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MonitorsGetMonitoredSubscriptions() + public async Task CreateOrUpdate_MonitorsAddMonitoredSubscriptions() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_List.json - // this example is just showing the usage of "MonitoredSubscriptions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_CreateorUpdate.json + // this example is just showing the usage of "MonitoredSubscriptions_CreateorUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_MonitorsGetMonitoredSubscriptions() // get the collection of this MonitoredSubscriptionPropertyResource MonitoredSubscriptionPropertyCollection collection = elasticMonitorResource.GetMonitoredSubscriptionProperties(); - // invoke the operation and iterate over the result - await foreach (MonitoredSubscriptionPropertyResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitoredSubscriptionPropertyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string configurationName = "default"; + MonitoredSubscriptionPropertyData data = new MonitoredSubscriptionPropertyData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + MonitoredSubscriptionPropertyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitoredSubscriptionPropertyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_MonitorsGetMonitoredSubscriptions() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MonitorsGetMonitoredSubscriptions() + public async Task GetAll_MonitorsGetMonitoredSubscriptions() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_Get.json - // this example is just showing the usage of "MonitoredSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_List.json + // this example is just showing the usage of "MonitoredSubscriptions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_MonitorsGetMonitoredSubscriptions() // get the collection of this MonitoredSubscriptionPropertyResource MonitoredSubscriptionPropertyCollection collection = elasticMonitorResource.GetMonitoredSubscriptionProperties(); - // invoke the operation - string configurationName = "default"; - bool result = await collection.ExistsAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (MonitoredSubscriptionPropertyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitoredSubscriptionPropertyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MonitorsGetMonitoredSubscriptions() + public async Task Exists_MonitorsGetMonitoredSubscriptions() { // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_Get.json // this example is just showing the usage of "MonitoredSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_MonitorsGetMonitoredSubscriptions() // invoke the operation string configurationName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - MonitoredSubscriptionPropertyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitoredSubscriptionPropertyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_MonitorsAddMonitoredSubscriptions() + public async Task GetIfExists_MonitorsGetMonitoredSubscriptions() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_CreateorUpdate.json - // this example is just showing the usage of "MonitoredSubscriptions_CreateorUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_Get.json + // this example is just showing the usage of "MonitoredSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_MonitorsAddMonitoredSubscriptions() // invoke the operation string configurationName = "default"; - MonitoredSubscriptionPropertyData data = new MonitoredSubscriptionPropertyData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - MonitoredSubscriptionPropertyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + MonitoredSubscriptionPropertyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitoredSubscriptionPropertyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitoredSubscriptionPropertyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoredSubscriptionPropertyResource.cs b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoredSubscriptionPropertyResource.cs index 6cb68accf91f8..55257d40c4d41 100644 --- a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoredSubscriptionPropertyResource.cs +++ b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoredSubscriptionPropertyResource.cs @@ -48,10 +48,10 @@ public async Task Get_MonitorsGetMonitoredSubscriptions() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MonitorsUpdateMonitoredSubscriptions() + public async Task Delete_MonitorsDeleteMonitoredSubscriptions() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_Update.json - // this example is just showing the usage of "MonitoredSubscriptions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_Delete.json + // this example is just showing the usage of "MonitoredSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,23 +68,17 @@ public async Task Update_MonitorsUpdateMonitoredSubscriptions() MonitoredSubscriptionPropertyResource monitoredSubscriptionProperty = client.GetMonitoredSubscriptionPropertyResource(monitoredSubscriptionPropertyResourceId); // invoke the operation - MonitoredSubscriptionPropertyData data = new MonitoredSubscriptionPropertyData(); - ArmOperation lro = await monitoredSubscriptionProperty.UpdateAsync(WaitUntil.Completed, data); - MonitoredSubscriptionPropertyResource result = lro.Value; + await monitoredSubscriptionProperty.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitoredSubscriptionPropertyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_MonitorsDeleteMonitoredSubscriptions() + public async Task Update_MonitorsUpdateMonitoredSubscriptions() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_Delete.json - // this example is just showing the usage of "MonitoredSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/MonitoredSubscriptions_Update.json + // this example is just showing the usage of "MonitoredSubscriptions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +95,15 @@ public async Task Delete_MonitorsDeleteMonitoredSubscriptions() MonitoredSubscriptionPropertyResource monitoredSubscriptionProperty = client.GetMonitoredSubscriptionPropertyResource(monitoredSubscriptionPropertyResourceId); // invoke the operation - await monitoredSubscriptionProperty.DeleteAsync(WaitUntil.Completed); + MonitoredSubscriptionPropertyData data = new MonitoredSubscriptionPropertyData(); + ArmOperation lro = await monitoredSubscriptionProperty.UpdateAsync(WaitUntil.Completed, data); + MonitoredSubscriptionPropertyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitoredSubscriptionPropertyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoringTagRuleCollection.cs b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoringTagRuleCollection.cs index a7dc7f1c4aff5..c9c8a0bad510f 100644 --- a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoringTagRuleCollection.cs +++ b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoringTagRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MonitoringTagRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TagRulesList() + public async Task CreateOrUpdate_TagRulesCreateOrUpdate() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_List.json - // this example is just showing the usage of "TagRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_CreateOrUpdate.json + // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,25 @@ public async Task GetAll_TagRulesList() // get the collection of this MonitoringTagRuleResource MonitoringTagRuleCollection collection = elasticMonitorResource.GetMonitoringTagRules(); - // invoke the operation and iterate over the result - await foreach (MonitoringTagRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitoringTagRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string ruleSetName = "default"; + MonitoringTagRuleData data = new MonitoringTagRuleData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName, data); + MonitoringTagRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitoringTagRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TagRulesCreateOrUpdate() + public async Task Get_TagRulesGet() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_CreateOrUpdate.json - // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_Get.json + // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,9 +76,7 @@ public async Task CreateOrUpdate_TagRulesCreateOrUpdate() // invoke the operation string ruleSetName = "default"; - MonitoringTagRuleData data = new MonitoringTagRuleData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName, data); - MonitoringTagRuleResource result = lro.Value; + MonitoringTagRuleResource result = await collection.GetAsync(ruleSetName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +87,10 @@ public async Task CreateOrUpdate_TagRulesCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TagRulesGet() + public async Task GetAll_TagRulesList() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_Get.json - // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_List.json + // this example is just showing the usage of "TagRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,15 +108,17 @@ public async Task Get_TagRulesGet() // get the collection of this MonitoringTagRuleResource MonitoringTagRuleCollection collection = elasticMonitorResource.GetMonitoringTagRules(); - // invoke the operation - string ruleSetName = "default"; - MonitoringTagRuleResource result = await collection.GetAsync(ruleSetName); + // invoke the operation and iterate over the result + await foreach (MonitoringTagRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitoringTagRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitoringTagRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoringTagRuleResource.cs b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoringTagRuleResource.cs index 272ac5890b545..ec6c42f5989fe 100644 --- a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoringTagRuleResource.cs +++ b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_MonitoringTagRuleResource.cs @@ -17,10 +17,10 @@ public partial class Sample_MonitoringTagRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TagRulesCreateOrUpdate() + public async Task Get_TagRulesGet() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_CreateOrUpdate.json - // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_Get.json + // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,9 +37,7 @@ public async Task Update_TagRulesCreateOrUpdate() MonitoringTagRuleResource monitoringTagRule = client.GetMonitoringTagRuleResource(monitoringTagRuleResourceId); // invoke the operation - MonitoringTagRuleData data = new MonitoringTagRuleData(); - ArmOperation lro = await monitoringTagRule.UpdateAsync(WaitUntil.Completed, data); - MonitoringTagRuleResource result = lro.Value; + MonitoringTagRuleResource result = await monitoringTagRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,10 +48,10 @@ public async Task Update_TagRulesCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TagRulesGet() + public async Task Delete_TagRulesDelete() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_Get.json - // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_Delete.json + // this example is just showing the usage of "TagRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,21 +68,17 @@ public async Task Get_TagRulesGet() MonitoringTagRuleResource monitoringTagRule = client.GetMonitoringTagRuleResource(monitoringTagRuleResourceId); // invoke the operation - MonitoringTagRuleResource result = await monitoringTagRule.GetAsync(); + await monitoringTagRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitoringTagRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_TagRulesDelete() + public async Task Update_TagRulesCreateOrUpdate() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_Delete.json - // this example is just showing the usage of "TagRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/TagRules_CreateOrUpdate.json + // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +95,15 @@ public async Task Delete_TagRulesDelete() MonitoringTagRuleResource monitoringTagRule = client.GetMonitoringTagRuleResource(monitoringTagRuleResourceId); // invoke the operation - await monitoringTagRule.DeleteAsync(WaitUntil.Completed); + MonitoringTagRuleData data = new MonitoringTagRuleData(); + ArmOperation lro = await monitoringTagRule.UpdateAsync(WaitUntil.Completed, data); + MonitoringTagRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitoringTagRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_OpenAIIntegrationRPModelCollection.cs b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_OpenAIIntegrationRPModelCollection.cs index cc58c1791aa0b..4093a611fd8c0 100644 --- a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_OpenAIIntegrationRPModelCollection.cs +++ b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_OpenAIIntegrationRPModelCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_OpenAIIntegrationRPModelCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_OpenAIList() + public async Task CreateOrUpdate_OpenAICreateOrUpdate() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_List.json - // this example is just showing the usage of "OpenAI_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_CreateOrUpdate.json + // this example is just showing the usage of "OpenAI_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_OpenAIList() // get the collection of this OpenAIIntegrationRPModelResource OpenAIIntegrationRPModelCollection collection = elasticMonitorResource.GetOpenAIIntegrationRPModels(); - // invoke the operation and iterate over the result - await foreach (OpenAIIntegrationRPModelResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OpenAIIntegrationRPModelData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string integrationName = "default"; + OpenAIIntegrationRPModelData data = new OpenAIIntegrationRPModelData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, integrationName, data); + OpenAIIntegrationRPModelResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OpenAIIntegrationRPModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_OpenAIGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_OpenAIGet() + public async Task GetAll_OpenAIList() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_Get.json - // this example is just showing the usage of "OpenAI_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_List.json + // this example is just showing the usage of "OpenAI_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_OpenAIGet() // get the collection of this OpenAIIntegrationRPModelResource OpenAIIntegrationRPModelCollection collection = elasticMonitorResource.GetOpenAIIntegrationRPModels(); - // invoke the operation - string integrationName = "default"; - bool result = await collection.ExistsAsync(integrationName); + // invoke the operation and iterate over the result + await foreach (OpenAIIntegrationRPModelResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OpenAIIntegrationRPModelData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_OpenAIGet() + public async Task Exists_OpenAIGet() { // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_Get.json // this example is just showing the usage of "OpenAI_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_OpenAIGet() // invoke the operation string integrationName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(integrationName); - OpenAIIntegrationRPModelResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(integrationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OpenAIIntegrationRPModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_OpenAICreateOrUpdate() + public async Task GetIfExists_OpenAIGet() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_CreateOrUpdate.json - // this example is just showing the usage of "OpenAI_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_Get.json + // this example is just showing the usage of "OpenAI_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_OpenAICreateOrUpdate() // invoke the operation string integrationName = "default"; - OpenAIIntegrationRPModelData data = new OpenAIIntegrationRPModelData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, integrationName, data); - OpenAIIntegrationRPModelResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(integrationName); + OpenAIIntegrationRPModelResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OpenAIIntegrationRPModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OpenAIIntegrationRPModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_OpenAIIntegrationRPModelResource.cs b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_OpenAIIntegrationRPModelResource.cs index 86821b26cd7f9..5204f04216a88 100644 --- a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_OpenAIIntegrationRPModelResource.cs +++ b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_OpenAIIntegrationRPModelResource.cs @@ -49,10 +49,10 @@ public async Task Get_OpenAIGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_OpenAICreateOrUpdate() + public async Task Delete_OpenAIDelete() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_CreateOrUpdate.json - // this example is just showing the usage of "OpenAI_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_Delete.json + // this example is just showing the usage of "OpenAI_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,23 +69,17 @@ public async Task Update_OpenAICreateOrUpdate() OpenAIIntegrationRPModelResource openAIIntegrationRPModel = client.GetOpenAIIntegrationRPModelResource(openAIIntegrationRPModelResourceId); // invoke the operation - OpenAIIntegrationRPModelData data = new OpenAIIntegrationRPModelData(); - ArmOperation lro = await openAIIntegrationRPModel.UpdateAsync(WaitUntil.Completed, data); - OpenAIIntegrationRPModelResource result = lro.Value; + await openAIIntegrationRPModel.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OpenAIIntegrationRPModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_OpenAIDelete() + public async Task Update_OpenAICreateOrUpdate() { - // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_Delete.json - // this example is just showing the usage of "OpenAI_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/OpenAI_CreateOrUpdate.json + // this example is just showing the usage of "OpenAI_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_OpenAIDelete() OpenAIIntegrationRPModelResource openAIIntegrationRPModel = client.GetOpenAIIntegrationRPModelResource(openAIIntegrationRPModelResourceId); // invoke the operation - await openAIIntegrationRPModel.DeleteAsync(WaitUntil.Completed); + OpenAIIntegrationRPModelData data = new OpenAIIntegrationRPModelData(); + ArmOperation lro = await openAIIntegrationRPModel.UpdateAsync(WaitUntil.Completed, data); + OpenAIIntegrationRPModelResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OpenAIIntegrationRPModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 404ee74d01da7..1b171499bc2da 100644 --- a/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/elastic/Azure.ResourceManager.Elastic/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.Elastic.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetElasticMonitorResources_MonitorsList() + { + // Generated from example definition: specification/elastic/resource-manager/Microsoft.Elastic/preview/2024-06-15-preview/examples/Monitors_List.json + // this example is just showing the usage of "Monitors_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ElasticMonitorResource item in subscriptionResource.GetElasticMonitorResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticMonitorResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetElasticVersions_ElasticVersionsList() diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanCollection.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanCollection.cs index 9ffd5ab5ea95a..f6d06b70388d8 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanCollection.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanCollection.cs @@ -17,76 +17,6 @@ namespace Azure.ResourceManager.ElasticSan.Samples { public partial class Sample_ElasticSanCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ElasticSansListByResourceGroupMaximumSetGen() - { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "ElasticSans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subscriptionid"; - string resourceGroupName = "resourcegroupname"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ElasticSanResource - ElasticSanCollection collection = resourceGroupResource.GetElasticSans(); - - // invoke the operation and iterate over the result - await foreach (ElasticSanResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ElasticSansListByResourceGroupMinimumSetGen() - { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "ElasticSans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subscriptionid"; - string resourceGroupName = "resourcegroupname"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ElasticSanResource - ElasticSanCollection collection = resourceGroupResource.GetElasticSans(); - - // invoke the operation and iterate over the result - await foreach (ElasticSanResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_ElasticSansCreateMaximumSetGen() @@ -116,12 +46,9 @@ public async Task CreateOrUpdate_ElasticSansCreateMaximumSetGen() Tier = ElasticSanSkuTier.Premium, }, 1L, 3L) { - AvailabilityZones = -{ -"xoz" -}, + AvailabilityZones = { "xoz" }, PublicNetworkAccess = ElasticSanPublicNetworkAccess.Enabled, - ScaleUpProperties = new ScaleUpProperties() + ScaleUpProperties = new ScaleUpProperties { UnusedSizeTiB = 24L, IncreaseCapacityUnitByTiB = 4L, @@ -130,7 +57,7 @@ public async Task CreateOrUpdate_ElasticSansCreateMaximumSetGen() }, Tags = { -["key9706"] = "haitqqakcntcpalkzqmjmcnifnhd", +["key9706"] = "haitqqakcntcpalkzqmjmcnifnhd" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticSanName, data); @@ -213,9 +140,9 @@ public async Task Get_ElasticSansGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ElasticSansGetMaximumSetGen() + public async Task Get_ElasticSansGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Get_MaximumSet_Gen.json + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Get_MinimumSet_Gen.json // this example is just showing the usage of "ElasticSans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -235,17 +162,21 @@ public async Task Exists_ElasticSansGetMaximumSetGen() // invoke the operation string elasticSanName = "elasticsanname"; - bool result = await collection.ExistsAsync(elasticSanName); + ElasticSanResource result = await collection.GetAsync(elasticSanName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ElasticSansGetMaximumSetGen() + public async Task GetAll_ElasticSansListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Get_MaximumSet_Gen.json - // this example is just showing the usage of "ElasticSans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "ElasticSans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -262,30 +193,59 @@ public async Task GetIfExists_ElasticSansGetMaximumSetGen() // get the collection of this ElasticSanResource ElasticSanCollection collection = resourceGroupResource.GetElasticSans(); - // invoke the operation - string elasticSanName = "elasticsanname"; - NullableResponse response = await collection.GetIfExistsAsync(elasticSanName); - ElasticSanResource result = response.HasValue ? response.Value : null; - - if (result == null) + // invoke the operation and iterate over the result + await foreach (ElasticSanResource item in collection.GetAllAsync()) { - Console.WriteLine("Succeeded with null as result"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - else + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ElasticSansListByResourceGroupMinimumSetGen() + { + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "ElasticSans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subscriptionid"; + string resourceGroupName = "resourcegroupname"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ElasticSanResource + ElasticSanCollection collection = resourceGroupResource.GetElasticSans(); + + // invoke the operation and iterate over the result + await foreach (ElasticSanResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ElasticSanData resourceData = result.Data; + ElasticSanData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ElasticSansGetMinimumSetGen() + public async Task Exists_ElasticSansGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Get_MinimumSet_Gen.json + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Get_MaximumSet_Gen.json // this example is just showing the usage of "ElasticSans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -305,13 +265,9 @@ public async Task Get_ElasticSansGetMinimumSetGen() // invoke the operation string elasticSanName = "elasticsanname"; - ElasticSanResource result = await collection.GetAsync(elasticSanName); + bool result = await collection.ExistsAsync(elasticSanName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -343,6 +299,47 @@ public async Task Exists_ElasticSansGetMinimumSetGen() Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_ElasticSansGetMaximumSetGen() + { + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Get_MaximumSet_Gen.json + // this example is just showing the usage of "ElasticSans_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subscriptionid"; + string resourceGroupName = "resourcegroupname"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ElasticSanResource + ElasticSanCollection collection = resourceGroupResource.GetElasticSans(); + + // invoke the operation + string elasticSanName = "elasticsanname"; + NullableResponse response = await collection.GetIfExistsAsync(elasticSanName); + ElasticSanResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetIfExists_ElasticSansGetMinimumSetGen() diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanPrivateEndpointConnectionCollection.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanPrivateEndpointConnectionCollection.cs index 118ed5f2b4154..40bf68254fb51 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanPrivateEndpointConnectionCollection.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanPrivateEndpointConnectionCollection.cs @@ -41,17 +41,14 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsCreateMaximumSetGen() // invoke the operation string privateEndpointConnectionName = "privateendpointconnectionname"; - ElasticSanPrivateEndpointConnectionData data = new ElasticSanPrivateEndpointConnectionData(new ElasticSanPrivateLinkServiceConnectionState() + ElasticSanPrivateEndpointConnectionData data = new ElasticSanPrivateEndpointConnectionData(new ElasticSanPrivateLinkServiceConnectionState { Status = ElasticSanPrivateEndpointServiceConnectionStatus.Pending, Description = "dxl", ActionsRequired = "jhjdpwvyzipggtn", }) { - GroupIds = -{ -"jdwrzpemdjrpiwzvy" -}, + GroupIds = { "jdwrzpemdjrpiwzvy" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); ElasticSanPrivateEndpointConnectionResource result = lro.Value; @@ -135,9 +132,9 @@ public async Task Get_PrivateEndpointConnectionsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGetMaximumSetGen() + public async Task Get_PrivateEndpointConnectionsGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MaximumSet_Gen.json + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MinimumSet_Gen.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -158,17 +155,21 @@ public async Task Exists_PrivateEndpointConnectionsGetMaximumSetGen() // invoke the operation string privateEndpointConnectionName = "privateendpointconnectionname"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + ElasticSanPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGetMaximumSetGen() + public async Task GetAll_PrivateEndpointConnectionsListMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_List_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,31 +187,25 @@ public async Task GetIfExists_PrivateEndpointConnectionsGetMaximumSetGen() // get the collection of this ElasticSanPrivateEndpointConnectionResource ElasticSanPrivateEndpointConnectionCollection collection = elasticSan.GetElasticSanPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "privateendpointconnectionname"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - ElasticSanPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ElasticSanPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ElasticSanPrivateEndpointConnectionData resourceData = result.Data; + ElasticSanPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGetMinimumSetGen() + public async Task GetAll_PrivateEndpointConnectionsListMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MinimumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_List_MinimumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -228,22 +223,24 @@ public async Task Get_PrivateEndpointConnectionsGetMinimumSetGen() // get the collection of this ElasticSanPrivateEndpointConnectionResource ElasticSanPrivateEndpointConnectionCollection collection = elasticSan.GetElasticSanPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "privateendpointconnectionname"; - ElasticSanPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (ElasticSanPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGetMinimumSetGen() + public async Task Exists_PrivateEndpointConnectionsGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MinimumSet_Gen.json + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MaximumSet_Gen.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -271,7 +268,7 @@ public async Task Exists_PrivateEndpointConnectionsGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGetMinimumSetGen() + public async Task Exists_PrivateEndpointConnectionsGetMinimumSetGen() { // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MinimumSet_Gen.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -294,29 +291,17 @@ public async Task GetIfExists_PrivateEndpointConnectionsGetMinimumSetGen() // invoke the operation string privateEndpointConnectionName = "privateendpointconnectionname"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - ElasticSanPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsListMaximumSetGen() + public async Task GetIfExists_PrivateEndpointConnectionsGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_List_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -334,25 +319,31 @@ public async Task GetAll_PrivateEndpointConnectionsListMaximumSetGen() // get the collection of this ElasticSanPrivateEndpointConnectionResource ElasticSanPrivateEndpointConnectionCollection collection = elasticSan.GetElasticSanPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (ElasticSanPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "privateendpointconnectionname"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + ElasticSanPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ElasticSanPrivateEndpointConnectionData resourceData = item.Data; + ElasticSanPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsListMinimumSetGen() + public async Task GetIfExists_PrivateEndpointConnectionsGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_List_MinimumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MinimumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -370,17 +361,23 @@ public async Task GetAll_PrivateEndpointConnectionsListMinimumSetGen() // get the collection of this ElasticSanPrivateEndpointConnectionResource ElasticSanPrivateEndpointConnectionCollection collection = elasticSan.GetElasticSanPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (ElasticSanPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "privateendpointconnectionname"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + ElasticSanPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ElasticSanPrivateEndpointConnectionData resourceData = item.Data; + ElasticSanPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanPrivateEndpointConnectionResource.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanPrivateEndpointConnectionResource.cs index c82c6a6f7b938..4eaae7282e61a 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanPrivateEndpointConnectionResource.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ElasticSanPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsCreateMaximumSetGen() + public async Task Get_PrivateEndpointConnectionsGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Create_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,20 +38,7 @@ public async Task Update_PrivateEndpointConnectionsCreateMaximumSetGen() ElasticSanPrivateEndpointConnectionResource elasticSanPrivateEndpointConnection = client.GetElasticSanPrivateEndpointConnectionResource(elasticSanPrivateEndpointConnectionResourceId); // invoke the operation - ElasticSanPrivateEndpointConnectionData data = new ElasticSanPrivateEndpointConnectionData(new ElasticSanPrivateLinkServiceConnectionState() - { - Status = ElasticSanPrivateEndpointServiceConnectionStatus.Pending, - Description = "dxl", - ActionsRequired = "jhjdpwvyzipggtn", - }) - { - GroupIds = -{ -"jdwrzpemdjrpiwzvy" -}, - }; - ArmOperation lro = await elasticSanPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - ElasticSanPrivateEndpointConnectionResource result = lro.Value; + ElasticSanPrivateEndpointConnectionResource result = await elasticSanPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -62,10 +49,10 @@ public async Task Update_PrivateEndpointConnectionsCreateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsCreateMinimumSetGen() + public async Task Get_PrivateEndpointConnectionsGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Create_MinimumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MinimumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -82,9 +69,7 @@ public async Task Update_PrivateEndpointConnectionsCreateMinimumSetGen() ElasticSanPrivateEndpointConnectionResource elasticSanPrivateEndpointConnection = client.GetElasticSanPrivateEndpointConnectionResource(elasticSanPrivateEndpointConnectionResourceId); // invoke the operation - ElasticSanPrivateEndpointConnectionData data = new ElasticSanPrivateEndpointConnectionData(new ElasticSanPrivateLinkServiceConnectionState()); - ArmOperation lro = await elasticSanPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - ElasticSanPrivateEndpointConnectionResource result = lro.Value; + ElasticSanPrivateEndpointConnectionResource result = await elasticSanPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -95,10 +80,10 @@ public async Task Update_PrivateEndpointConnectionsCreateMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGetMaximumSetGen() + public async Task Delete_PrivateEndpointConnectionsDeleteMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,21 +100,17 @@ public async Task Get_PrivateEndpointConnectionsGetMaximumSetGen() ElasticSanPrivateEndpointConnectionResource elasticSanPrivateEndpointConnection = client.GetElasticSanPrivateEndpointConnectionResource(elasticSanPrivateEndpointConnectionResourceId); // invoke the operation - ElasticSanPrivateEndpointConnectionResource result = await elasticSanPrivateEndpointConnection.GetAsync(); + await elasticSanPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGetMinimumSetGen() + public async Task Delete_PrivateEndpointConnectionsDeleteMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get_MinimumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,21 +127,17 @@ public async Task Get_PrivateEndpointConnectionsGetMinimumSetGen() ElasticSanPrivateEndpointConnectionResource elasticSanPrivateEndpointConnection = client.GetElasticSanPrivateEndpointConnectionResource(elasticSanPrivateEndpointConnectionResourceId); // invoke the operation - ElasticSanPrivateEndpointConnectionResource result = await elasticSanPrivateEndpointConnection.GetAsync(); + await elasticSanPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDeleteMaximumSetGen() + public async Task Update_PrivateEndpointConnectionsCreateMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Create_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,17 +154,31 @@ public async Task Delete_PrivateEndpointConnectionsDeleteMaximumSetGen() ElasticSanPrivateEndpointConnectionResource elasticSanPrivateEndpointConnection = client.GetElasticSanPrivateEndpointConnectionResource(elasticSanPrivateEndpointConnectionResourceId); // invoke the operation - await elasticSanPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + ElasticSanPrivateEndpointConnectionData data = new ElasticSanPrivateEndpointConnectionData(new ElasticSanPrivateLinkServiceConnectionState + { + Status = ElasticSanPrivateEndpointServiceConnectionStatus.Pending, + Description = "dxl", + ActionsRequired = "jhjdpwvyzipggtn", + }) + { + GroupIds = { "jdwrzpemdjrpiwzvy" }, + }; + ArmOperation lro = await elasticSanPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ElasticSanPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDeleteMinimumSetGen() + public async Task Update_PrivateEndpointConnectionsCreateMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Create_MinimumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,9 +195,15 @@ public async Task Delete_PrivateEndpointConnectionsDeleteMinimumSetGen() ElasticSanPrivateEndpointConnectionResource elasticSanPrivateEndpointConnection = client.GetElasticSanPrivateEndpointConnectionResource(elasticSanPrivateEndpointConnectionResourceId); // invoke the operation - await elasticSanPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + ElasticSanPrivateEndpointConnectionData data = new ElasticSanPrivateEndpointConnectionData(new ElasticSanPrivateLinkServiceConnectionState()); + ArmOperation lro = await elasticSanPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ElasticSanPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanResource.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanResource.cs index 15dbeb534d987..36acc98335301 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanResource.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ElasticSan.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ElasticSan.Samples @@ -19,72 +18,10 @@ public partial class Sample_ElasticSanResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetElasticSans_ElasticSansListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "ElasticSans_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subscriptionid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ElasticSanResource item in subscriptionResource.GetElasticSansAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetElasticSans_ElasticSansListBySubscriptionMinimumSetGen() - { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "ElasticSans_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subscriptionid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ElasticSanResource item in subscriptionResource.GetElasticSansAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_ElasticSansUpdateMaximumSetGen() + public async Task Get_ElasticSansGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Update_MaximumSet_Gen.json - // this example is just showing the usage of "ElasticSans_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Get_MaximumSet_Gen.json + // this example is just showing the usage of "ElasticSans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,25 +37,7 @@ public async Task Update_ElasticSansUpdateMaximumSetGen() ElasticSanResource elasticSan = client.GetElasticSanResource(elasticSanResourceId); // invoke the operation - ElasticSanPatch patch = new ElasticSanPatch() - { - Tags = -{ -["key5945"] = "eufqmxresekerilkgvfzddolxzas", -}, - BaseSizeTiB = 21L, - ExtendedCapacitySizeTiB = 10L, - PublicNetworkAccess = ElasticSanPublicNetworkAccess.Enabled, - ScaleUpProperties = new ScaleUpProperties() - { - UnusedSizeTiB = 24L, - IncreaseCapacityUnitByTiB = 4L, - CapacityUnitScaleUpLimitTiB = 17L, - AutoScalePolicyEnforcement = AutoScalePolicyEnforcement.None, - }, - }; - ArmOperation lro = await elasticSan.UpdateAsync(WaitUntil.Completed, patch); - ElasticSanResource result = lro.Value; + ElasticSanResource result = await elasticSan.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -129,10 +48,10 @@ public async Task Update_ElasticSansUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ElasticSansUpdateMinimumSetGen() + public async Task Get_ElasticSansGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Update_MinimumSet_Gen.json - // this example is just showing the usage of "ElasticSans_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Get_MinimumSet_Gen.json + // this example is just showing the usage of "ElasticSans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,9 +67,7 @@ public async Task Update_ElasticSansUpdateMinimumSetGen() ElasticSanResource elasticSan = client.GetElasticSanResource(elasticSanResourceId); // invoke the operation - ElasticSanPatch patch = new ElasticSanPatch(); - ArmOperation lro = await elasticSan.UpdateAsync(WaitUntil.Completed, patch); - ElasticSanResource result = lro.Value; + ElasticSanResource result = await elasticSan.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -213,10 +130,10 @@ public async Task Delete_ElasticSansDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ElasticSansGetMaximumSetGen() + public async Task Update_ElasticSansUpdateMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Get_MaximumSet_Gen.json - // this example is just showing the usage of "ElasticSans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Update_MaximumSet_Gen.json + // this example is just showing the usage of "ElasticSans_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -232,7 +149,25 @@ public async Task Get_ElasticSansGetMaximumSetGen() ElasticSanResource elasticSan = client.GetElasticSanResource(elasticSanResourceId); // invoke the operation - ElasticSanResource result = await elasticSan.GetAsync(); + ElasticSanPatch patch = new ElasticSanPatch + { + Tags = +{ +["key5945"] = "eufqmxresekerilkgvfzddolxzas" +}, + BaseSizeTiB = 21L, + ExtendedCapacitySizeTiB = 10L, + PublicNetworkAccess = ElasticSanPublicNetworkAccess.Enabled, + ScaleUpProperties = new ScaleUpProperties + { + UnusedSizeTiB = 24L, + IncreaseCapacityUnitByTiB = 4L, + CapacityUnitScaleUpLimitTiB = 17L, + AutoScalePolicyEnforcement = AutoScalePolicyEnforcement.None, + }, + }; + ArmOperation lro = await elasticSan.UpdateAsync(WaitUntil.Completed, patch); + ElasticSanResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -243,10 +178,10 @@ public async Task Get_ElasticSansGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ElasticSansGetMinimumSetGen() + public async Task Update_ElasticSansUpdateMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Get_MinimumSet_Gen.json - // this example is just showing the usage of "ElasticSans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_Update_MinimumSet_Gen.json + // this example is just showing the usage of "ElasticSans_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -262,7 +197,9 @@ public async Task Get_ElasticSansGetMinimumSetGen() ElasticSanResource elasticSan = client.GetElasticSanResource(elasticSanResourceId); // invoke the operation - ElasticSanResource result = await elasticSan.GetAsync(); + ElasticSanPatch patch = new ElasticSanPatch(); + ArmOperation lro = await elasticSan.UpdateAsync(WaitUntil.Completed, patch); + ElasticSanResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanSnapshotCollection.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanSnapshotCollection.cs index e0727aa2817e1..86b9fee35ae85 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanSnapshotCollection.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanSnapshotCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ElasticSanSnapshotCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VolumeSnapshotsListByVolumeGroupMaximumSetGen() + public async Task CreateOrUpdate_VolumeSnapshotsCreateMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_ListByVolumeGroup_MaximumSet_Gen.json - // this example is just showing the usage of "VolumeSnapshots_ListByVolumeGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Create_MaximumSet_Gen.json + // this example is just showing the usage of "VolumeSnapshots_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,26 +40,25 @@ public async Task GetAll_VolumeSnapshotsListByVolumeGroupMaximumSetGen() // get the collection of this ElasticSanSnapshotResource ElasticSanSnapshotCollection collection = elasticSanVolumeGroup.GetElasticSanSnapshots(); - // invoke the operation and iterate over the result - string filter = "volumeName eq "; - await foreach (ElasticSanSnapshotResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanSnapshotData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string snapshotName = "snapshotname"; + ElasticSanSnapshotData data = new ElasticSanSnapshotData(new SnapshotCreationInfo(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"))); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, snapshotName, data); + ElasticSanSnapshotResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VolumeSnapshotsListByVolumeGroupMinimumSetGen() + public async Task CreateOrUpdate_VolumeSnapshotsCreateMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_ListByVolumeGroup_MinimumSet_Gen.json - // this example is just showing the usage of "VolumeSnapshots_ListByVolumeGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Create_MinimumSet_Gen.json + // this example is just showing the usage of "VolumeSnapshots_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,25 +77,25 @@ public async Task GetAll_VolumeSnapshotsListByVolumeGroupMinimumSetGen() // get the collection of this ElasticSanSnapshotResource ElasticSanSnapshotCollection collection = elasticSanVolumeGroup.GetElasticSanSnapshots(); - // invoke the operation and iterate over the result - await foreach (ElasticSanSnapshotResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanSnapshotData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string snapshotName = "snapshotname"; + ElasticSanSnapshotData data = new ElasticSanSnapshotData(new SnapshotCreationInfo(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"))); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, snapshotName, data); + ElasticSanSnapshotResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VolumeSnapshotsCreateMaximumSetGen() + public async Task Get_VolumeSnapshotsGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Create_MaximumSet_Gen.json - // this example is just showing the usage of "VolumeSnapshots_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MaximumSet_Gen.json + // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,9 +116,7 @@ public async Task CreateOrUpdate_VolumeSnapshotsCreateMaximumSetGen() // invoke the operation string snapshotName = "snapshotname"; - ElasticSanSnapshotData data = new ElasticSanSnapshotData(new SnapshotCreationInfo(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"))); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, snapshotName, data); - ElasticSanSnapshotResource result = lro.Value; + ElasticSanSnapshotResource result = await collection.GetAsync(snapshotName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -130,10 +127,10 @@ public async Task CreateOrUpdate_VolumeSnapshotsCreateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VolumeSnapshotsCreateMinimumSetGen() + public async Task Get_VolumeSnapshotsGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Create_MinimumSet_Gen.json - // this example is just showing the usage of "VolumeSnapshots_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MinimumSet_Gen.json + // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -154,9 +151,7 @@ public async Task CreateOrUpdate_VolumeSnapshotsCreateMinimumSetGen() // invoke the operation string snapshotName = "snapshotname"; - ElasticSanSnapshotData data = new ElasticSanSnapshotData(new SnapshotCreationInfo(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"))); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, snapshotName, data); - ElasticSanSnapshotResource result = lro.Value; + ElasticSanSnapshotResource result = await collection.GetAsync(snapshotName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -167,10 +162,10 @@ public async Task CreateOrUpdate_VolumeSnapshotsCreateMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VolumeSnapshotsGetMaximumSetGen() + public async Task GetAll_VolumeSnapshotsListByVolumeGroupMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MaximumSet_Gen.json - // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_ListByVolumeGroup_MaximumSet_Gen.json + // this example is just showing the usage of "VolumeSnapshots_ListByVolumeGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,23 +184,26 @@ public async Task Get_VolumeSnapshotsGetMaximumSetGen() // get the collection of this ElasticSanSnapshotResource ElasticSanSnapshotCollection collection = elasticSanVolumeGroup.GetElasticSanSnapshots(); - // invoke the operation - string snapshotName = "snapshotname"; - ElasticSanSnapshotResource result = await collection.GetAsync(snapshotName); + // invoke the operation and iterate over the result + string filter = "volumeName eq "; + await foreach (ElasticSanSnapshotResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanSnapshotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanSnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VolumeSnapshotsGetMaximumSetGen() + public async Task GetAll_VolumeSnapshotsListByVolumeGroupMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MaximumSet_Gen.json - // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_ListByVolumeGroup_MinimumSet_Gen.json + // this example is just showing the usage of "VolumeSnapshots_ListByVolumeGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -224,16 +222,22 @@ public async Task Exists_VolumeSnapshotsGetMaximumSetGen() // get the collection of this ElasticSanSnapshotResource ElasticSanSnapshotCollection collection = elasticSanVolumeGroup.GetElasticSanSnapshots(); - // invoke the operation - string snapshotName = "snapshotname"; - bool result = await collection.ExistsAsync(snapshotName); + // invoke the operation and iterate over the result + await foreach (ElasticSanSnapshotResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanSnapshotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VolumeSnapshotsGetMaximumSetGen() + public async Task Exists_VolumeSnapshotsGetMaximumSetGen() { // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MaximumSet_Gen.json // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. @@ -257,26 +261,14 @@ public async Task GetIfExists_VolumeSnapshotsGetMaximumSetGen() // invoke the operation string snapshotName = "snapshotname"; - NullableResponse response = await collection.GetIfExistsAsync(snapshotName); - ElasticSanSnapshotResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(snapshotName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanSnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VolumeSnapshotsGetMinimumSetGen() + public async Task Exists_VolumeSnapshotsGetMinimumSetGen() { // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MinimumSet_Gen.json // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. @@ -300,20 +292,16 @@ public async Task Get_VolumeSnapshotsGetMinimumSetGen() // invoke the operation string snapshotName = "snapshotname"; - ElasticSanSnapshotResource result = await collection.GetAsync(snapshotName); + bool result = await collection.ExistsAsync(snapshotName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanSnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VolumeSnapshotsGetMinimumSetGen() + public async Task GetIfExists_VolumeSnapshotsGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MinimumSet_Gen.json + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MaximumSet_Gen.json // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -335,9 +323,21 @@ public async Task Exists_VolumeSnapshotsGetMinimumSetGen() // invoke the operation string snapshotName = "snapshotname"; - bool result = await collection.ExistsAsync(snapshotName); + NullableResponse response = await collection.GetIfExistsAsync(snapshotName); + ElasticSanSnapshotResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanSnapshotResource.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanSnapshotResource.cs index 487ae18566b93..d1fccc8e90ef6 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanSnapshotResource.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanSnapshotResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ElasticSanSnapshotResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VolumeSnapshotsCreateMaximumSetGen() + public async Task Get_VolumeSnapshotsGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Create_MaximumSet_Gen.json - // this example is just showing the usage of "VolumeSnapshots_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MaximumSet_Gen.json + // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,9 +39,7 @@ public async Task Update_VolumeSnapshotsCreateMaximumSetGen() ElasticSanSnapshotResource elasticSanSnapshot = client.GetElasticSanSnapshotResource(elasticSanSnapshotResourceId); // invoke the operation - ElasticSanSnapshotData data = new ElasticSanSnapshotData(new SnapshotCreationInfo(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"))); - ArmOperation lro = await elasticSanSnapshot.UpdateAsync(WaitUntil.Completed, data); - ElasticSanSnapshotResource result = lro.Value; + ElasticSanSnapshotResource result = await elasticSanSnapshot.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +50,10 @@ public async Task Update_VolumeSnapshotsCreateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VolumeSnapshotsCreateMinimumSetGen() + public async Task Get_VolumeSnapshotsGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Create_MinimumSet_Gen.json - // this example is just showing the usage of "VolumeSnapshots_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MinimumSet_Gen.json + // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,9 +71,7 @@ public async Task Update_VolumeSnapshotsCreateMinimumSetGen() ElasticSanSnapshotResource elasticSanSnapshot = client.GetElasticSanSnapshotResource(elasticSanSnapshotResourceId); // invoke the operation - ElasticSanSnapshotData data = new ElasticSanSnapshotData(new SnapshotCreationInfo(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"))); - ArmOperation lro = await elasticSanSnapshot.UpdateAsync(WaitUntil.Completed, data); - ElasticSanSnapshotResource result = lro.Value; + ElasticSanSnapshotResource result = await elasticSanSnapshot.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -142,10 +138,10 @@ public async Task Delete_VolumeSnapshotsDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VolumeSnapshotsGetMaximumSetGen() + public async Task Update_VolumeSnapshotsCreateMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MaximumSet_Gen.json - // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Create_MaximumSet_Gen.json + // this example is just showing the usage of "VolumeSnapshots_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -163,7 +159,9 @@ public async Task Get_VolumeSnapshotsGetMaximumSetGen() ElasticSanSnapshotResource elasticSanSnapshot = client.GetElasticSanSnapshotResource(elasticSanSnapshotResourceId); // invoke the operation - ElasticSanSnapshotResource result = await elasticSanSnapshot.GetAsync(); + ElasticSanSnapshotData data = new ElasticSanSnapshotData(new SnapshotCreationInfo(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"))); + ArmOperation lro = await elasticSanSnapshot.UpdateAsync(WaitUntil.Completed, data); + ElasticSanSnapshotResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -174,10 +172,10 @@ public async Task Get_VolumeSnapshotsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VolumeSnapshotsGetMinimumSetGen() + public async Task Update_VolumeSnapshotsCreateMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Get_MinimumSet_Gen.json - // this example is just showing the usage of "VolumeSnapshots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeSnapshots_Create_MinimumSet_Gen.json + // this example is just showing the usage of "VolumeSnapshots_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,7 +193,9 @@ public async Task Get_VolumeSnapshotsGetMinimumSetGen() ElasticSanSnapshotResource elasticSanSnapshot = client.GetElasticSanSnapshotResource(elasticSanSnapshotResourceId); // invoke the operation - ElasticSanSnapshotResource result = await elasticSanSnapshot.GetAsync(); + ElasticSanSnapshotData data = new ElasticSanSnapshotData(new SnapshotCreationInfo(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ElasticSan/elasticSans/{elasticSanName}/volumegroups/{volumeGroupName}/volumes/{volumeName}"))); + ArmOperation lro = await elasticSanSnapshot.UpdateAsync(WaitUntil.Completed, data); + ElasticSanSnapshotResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeCollection.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeCollection.cs index 8e150c4966cde..2b56a96b94600 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeCollection.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeCollection.cs @@ -44,7 +44,7 @@ public async Task CreateOrUpdate_VolumesCreateMaximumSetGen() string volumeName = "volumename"; ElasticSanVolumeData data = new ElasticSanVolumeData(9L) { - CreationData = new ElasticSanVolumeDataSourceInfo() + CreationData = new ElasticSanVolumeDataSourceInfo { CreateSource = ElasticSanVolumeCreateOption.None, SourceId = new ResourceIdentifier("ARM Id of Resource"), @@ -135,9 +135,9 @@ public async Task Get_VolumesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VolumesGetMaximumSetGen() + public async Task Get_VolumesGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MaximumSet_Gen.json + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MinimumSet_Gen.json // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -159,17 +159,21 @@ public async Task Exists_VolumesGetMaximumSetGen() // invoke the operation string volumeName = "volumename"; - bool result = await collection.ExistsAsync(volumeName); + ElasticSanVolumeResource result = await collection.GetAsync(volumeName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanVolumeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VolumesGetMaximumSetGen() + public async Task GetAll_VolumesListByVolumeGroupMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_ListByVolumeGroup_MaximumSet_Gen.json + // this example is just showing the usage of "Volumes_ListByVolumeGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,31 +192,25 @@ public async Task GetIfExists_VolumesGetMaximumSetGen() // get the collection of this ElasticSanVolumeResource ElasticSanVolumeCollection collection = elasticSanVolumeGroup.GetElasticSanVolumes(); - // invoke the operation - string volumeName = "volumename"; - NullableResponse response = await collection.GetIfExistsAsync(volumeName); - ElasticSanVolumeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ElasticSanVolumeResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ElasticSanVolumeData resourceData = result.Data; + ElasticSanVolumeData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VolumesGetMinimumSetGen() + public async Task GetAll_VolumesListByVolumeGroupMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MinimumSet_Gen.json - // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_ListByVolumeGroup_MinimumSet_Gen.json + // this example is just showing the usage of "Volumes_ListByVolumeGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -231,22 +229,24 @@ public async Task Get_VolumesGetMinimumSetGen() // get the collection of this ElasticSanVolumeResource ElasticSanVolumeCollection collection = elasticSanVolumeGroup.GetElasticSanVolumes(); - // invoke the operation - string volumeName = "volumename"; - ElasticSanVolumeResource result = await collection.GetAsync(volumeName); + // invoke the operation and iterate over the result + await foreach (ElasticSanVolumeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanVolumeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanVolumeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VolumesGetMinimumSetGen() + public async Task Exists_VolumesGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MinimumSet_Gen.json + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MaximumSet_Gen.json // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -275,7 +275,7 @@ public async Task Exists_VolumesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VolumesGetMinimumSetGen() + public async Task Exists_VolumesGetMinimumSetGen() { // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MinimumSet_Gen.json // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. @@ -299,29 +299,17 @@ public async Task GetIfExists_VolumesGetMinimumSetGen() // invoke the operation string volumeName = "volumename"; - NullableResponse response = await collection.GetIfExistsAsync(volumeName); - ElasticSanVolumeResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(volumeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanVolumeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VolumesListByVolumeGroupMaximumSetGen() + public async Task GetIfExists_VolumesGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_ListByVolumeGroup_MaximumSet_Gen.json - // this example is just showing the usage of "Volumes_ListByVolumeGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -340,25 +328,31 @@ public async Task GetAll_VolumesListByVolumeGroupMaximumSetGen() // get the collection of this ElasticSanVolumeResource ElasticSanVolumeCollection collection = elasticSanVolumeGroup.GetElasticSanVolumes(); - // invoke the operation and iterate over the result - await foreach (ElasticSanVolumeResource item in collection.GetAllAsync()) + // invoke the operation + string volumeName = "volumename"; + NullableResponse response = await collection.GetIfExistsAsync(volumeName); + ElasticSanVolumeResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ElasticSanVolumeData resourceData = item.Data; + ElasticSanVolumeData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VolumesListByVolumeGroupMinimumSetGen() + public async Task GetIfExists_VolumesGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_ListByVolumeGroup_MinimumSet_Gen.json - // this example is just showing the usage of "Volumes_ListByVolumeGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MinimumSet_Gen.json + // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -377,17 +371,23 @@ public async Task GetAll_VolumesListByVolumeGroupMinimumSetGen() // get the collection of this ElasticSanVolumeResource ElasticSanVolumeCollection collection = elasticSanVolumeGroup.GetElasticSanVolumes(); - // invoke the operation and iterate over the result - await foreach (ElasticSanVolumeResource item in collection.GetAllAsync()) + // invoke the operation + string volumeName = "volumename"; + NullableResponse response = await collection.GetIfExistsAsync(volumeName); + ElasticSanVolumeResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ElasticSanVolumeData resourceData = item.Data; + ElasticSanVolumeData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeGroupCollection.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeGroupCollection.cs index ba8843cf874f5..d81c2b6519c98 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeGroupCollection.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeGroupCollection.cs @@ -17,78 +17,6 @@ namespace Azure.ResourceManager.ElasticSan.Samples { public partial class Sample_ElasticSanVolumeGroupCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_VolumeGroupsListByElasticSanMaximumSetGen() - { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_ListByElasticSan_MaximumSet_Gen.json - // this example is just showing the usage of "VolumeGroups_ListByElasticSan" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ElasticSanResource created on azure - // for more information of creating ElasticSanResource, please refer to the document of ElasticSanResource - string subscriptionId = "subscriptionid"; - string resourceGroupName = "resourcegroupname"; - string elasticSanName = "elasticsanname"; - ResourceIdentifier elasticSanResourceId = ElasticSanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, elasticSanName); - ElasticSanResource elasticSan = client.GetElasticSanResource(elasticSanResourceId); - - // get the collection of this ElasticSanVolumeGroupResource - ElasticSanVolumeGroupCollection collection = elasticSan.GetElasticSanVolumeGroups(); - - // invoke the operation and iterate over the result - await foreach (ElasticSanVolumeGroupResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanVolumeGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_VolumeGroupsListByElasticSanMinimumSetGen() - { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_ListByElasticSan_MinimumSet_Gen.json - // this example is just showing the usage of "VolumeGroups_ListByElasticSan" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ElasticSanResource created on azure - // for more information of creating ElasticSanResource, please refer to the document of ElasticSanResource - string subscriptionId = "subscriptionid"; - string resourceGroupName = "resourcegroupname"; - string elasticSanName = "elasticsanname"; - ResourceIdentifier elasticSanResourceId = ElasticSanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, elasticSanName); - ElasticSanResource elasticSan = client.GetElasticSanResource(elasticSanResourceId); - - // get the collection of this ElasticSanVolumeGroupResource - ElasticSanVolumeGroupCollection collection = elasticSan.GetElasticSanVolumeGroups(); - - // invoke the operation and iterate over the result - await foreach (ElasticSanVolumeGroupResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanVolumeGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_VolumeGroupsCreateMaximumSetGen() @@ -114,20 +42,20 @@ public async Task CreateOrUpdate_VolumeGroupsCreateMaximumSetGen() // invoke the operation string volumeGroupName = "volumegroupname"; - ElasticSanVolumeGroupData data = new ElasticSanVolumeGroupData() + ElasticSanVolumeGroupData data = new ElasticSanVolumeGroupData { Identity = new ManagedServiceIdentity("None") { UserAssignedIdentities = { -[new ResourceIdentifier("key1006")] = new UserAssignedIdentity(), +[new ResourceIdentifier("key1006")] = new UserAssignedIdentity() }, }, ProtocolType = ElasticSanStorageTargetType.Iscsi, Encryption = ElasticSanEncryptionType.EncryptionAtRestWithPlatformKey, - EncryptionProperties = new ElasticSanEncryptionProperties() + EncryptionProperties = new ElasticSanEncryptionProperties { - KeyVaultProperties = new ElasticSanKeyVaultProperties() + KeyVaultProperties = new ElasticSanKeyVaultProperties { KeyName = "lunpapamzeimppgobraxjt", KeyVersion = "oemygbnfmqhijmonkqfqmy", @@ -135,13 +63,10 @@ public async Task CreateOrUpdate_VolumeGroupsCreateMaximumSetGen() }, EncryptionUserAssignedIdentity = new ResourceIdentifier("gfhkfbozahmmwluqndfgxunssafa"), }, - VirtualNetworkRules = -{ -new ElasticSanVirtualNetworkRule(new ResourceIdentifier("bkhwaiqvvaguymsmnzzbzz")) + VirtualNetworkRules = {new ElasticSanVirtualNetworkRule(new ResourceIdentifier("bkhwaiqvvaguymsmnzzbzz")) { Action = ElasticSanVirtualNetworkRuleAction.Allow, -} -}, +}}, EnforceDataIntegrityCheckForIscsi = true, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, volumeGroupName, data); @@ -226,9 +151,9 @@ public async Task Get_VolumeGroupsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VolumeGroupsGetMaximumSetGen() + public async Task Get_VolumeGroupsGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Get_MaximumSet_Gen.json + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Get_MinimumSet_Gen.json // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -249,17 +174,21 @@ public async Task Exists_VolumeGroupsGetMaximumSetGen() // invoke the operation string volumeGroupName = "volumegroupname"; - bool result = await collection.ExistsAsync(volumeGroupName); + ElasticSanVolumeGroupResource result = await collection.GetAsync(volumeGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanVolumeGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VolumeGroupsGetMaximumSetGen() + public async Task GetAll_VolumeGroupsListByElasticSanMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Get_MaximumSet_Gen.json - // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_ListByElasticSan_MaximumSet_Gen.json + // this example is just showing the usage of "VolumeGroups_ListByElasticSan" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -277,30 +206,60 @@ public async Task GetIfExists_VolumeGroupsGetMaximumSetGen() // get the collection of this ElasticSanVolumeGroupResource ElasticSanVolumeGroupCollection collection = elasticSan.GetElasticSanVolumeGroups(); - // invoke the operation - string volumeGroupName = "volumegroupname"; - NullableResponse response = await collection.GetIfExistsAsync(volumeGroupName); - ElasticSanVolumeGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) + // invoke the operation and iterate over the result + await foreach (ElasticSanVolumeGroupResource item in collection.GetAllAsync()) { - Console.WriteLine("Succeeded with null as result"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanVolumeGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - else + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_VolumeGroupsListByElasticSanMinimumSetGen() + { + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_ListByElasticSan_MinimumSet_Gen.json + // this example is just showing the usage of "VolumeGroups_ListByElasticSan" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ElasticSanResource created on azure + // for more information of creating ElasticSanResource, please refer to the document of ElasticSanResource + string subscriptionId = "subscriptionid"; + string resourceGroupName = "resourcegroupname"; + string elasticSanName = "elasticsanname"; + ResourceIdentifier elasticSanResourceId = ElasticSanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, elasticSanName); + ElasticSanResource elasticSan = client.GetElasticSanResource(elasticSanResourceId); + + // get the collection of this ElasticSanVolumeGroupResource + ElasticSanVolumeGroupCollection collection = elasticSan.GetElasticSanVolumeGroups(); + + // invoke the operation and iterate over the result + await foreach (ElasticSanVolumeGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ElasticSanVolumeGroupData resourceData = result.Data; + ElasticSanVolumeGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VolumeGroupsGetMinimumSetGen() + public async Task Exists_VolumeGroupsGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Get_MinimumSet_Gen.json + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Get_MaximumSet_Gen.json // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -321,13 +280,9 @@ public async Task Get_VolumeGroupsGetMinimumSetGen() // invoke the operation string volumeGroupName = "volumegroupname"; - ElasticSanVolumeGroupResource result = await collection.GetAsync(volumeGroupName); + bool result = await collection.ExistsAsync(volumeGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticSanVolumeGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -360,6 +315,48 @@ public async Task Exists_VolumeGroupsGetMinimumSetGen() Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_VolumeGroupsGetMaximumSetGen() + { + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Get_MaximumSet_Gen.json + // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ElasticSanResource created on azure + // for more information of creating ElasticSanResource, please refer to the document of ElasticSanResource + string subscriptionId = "subscriptionid"; + string resourceGroupName = "resourcegroupname"; + string elasticSanName = "elasticsanname"; + ResourceIdentifier elasticSanResourceId = ElasticSanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, elasticSanName); + ElasticSanResource elasticSan = client.GetElasticSanResource(elasticSanResourceId); + + // get the collection of this ElasticSanVolumeGroupResource + ElasticSanVolumeGroupCollection collection = elasticSan.GetElasticSanVolumeGroups(); + + // invoke the operation + string volumeGroupName = "volumegroupname"; + NullableResponse response = await collection.GetIfExistsAsync(volumeGroupName); + ElasticSanVolumeGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanVolumeGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetIfExists_VolumeGroupsGetMinimumSetGen() diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeGroupResource.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeGroupResource.cs index feb93d28a0b44..cc928b7c294a4 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeGroupResource.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeGroupResource.cs @@ -19,10 +19,10 @@ public partial class Sample_ElasticSanVolumeGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VolumeGroupsUpdateMaximumSetGen() + public async Task Get_VolumeGroupsGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Update_MaximumSet_Gen.json - // this example is just showing the usage of "VolumeGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Get_MaximumSet_Gen.json + // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,38 +39,7 @@ public async Task Update_VolumeGroupsUpdateMaximumSetGen() ElasticSanVolumeGroupResource elasticSanVolumeGroup = client.GetElasticSanVolumeGroupResource(elasticSanVolumeGroupResourceId); // invoke the operation - ElasticSanVolumeGroupPatch patch = new ElasticSanVolumeGroupPatch() - { - Identity = new ManagedServiceIdentity("None") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("key1006")] = new UserAssignedIdentity(), -}, - }, - ProtocolType = ElasticSanStorageTargetType.Iscsi, - Encryption = ElasticSanEncryptionType.EncryptionAtRestWithPlatformKey, - EncryptionProperties = new ElasticSanEncryptionProperties() - { - KeyVaultProperties = new ElasticSanKeyVaultProperties() - { - KeyName = "lunpapamzeimppgobraxjt", - KeyVersion = "oemygbnfmqhijmonkqfqmy", - KeyVaultUri = new Uri("https://microsoft.com/a"), - }, - EncryptionUserAssignedIdentity = new ResourceIdentifier("gfhkfbozahmmwluqndfgxunssafa"), - }, - VirtualNetworkRules = -{ -new ElasticSanVirtualNetworkRule(new ResourceIdentifier("bkhwaiqvvaguymsmnzzbzz")) -{ -Action = ElasticSanVirtualNetworkRuleAction.Allow, -} -}, - EnforceDataIntegrityCheckForIscsi = true, - }; - ArmOperation lro = await elasticSanVolumeGroup.UpdateAsync(WaitUntil.Completed, patch); - ElasticSanVolumeGroupResource result = lro.Value; + ElasticSanVolumeGroupResource result = await elasticSanVolumeGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +50,10 @@ public async Task Update_VolumeGroupsUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VolumeGroupsUpdateMinimumSetGen() + public async Task Get_VolumeGroupsGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Update_MinimumSet_Gen.json - // this example is just showing the usage of "VolumeGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Get_MinimumSet_Gen.json + // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +70,7 @@ public async Task Update_VolumeGroupsUpdateMinimumSetGen() ElasticSanVolumeGroupResource elasticSanVolumeGroup = client.GetElasticSanVolumeGroupResource(elasticSanVolumeGroupResourceId); // invoke the operation - ElasticSanVolumeGroupPatch patch = new ElasticSanVolumeGroupPatch(); - ArmOperation lro = await elasticSanVolumeGroup.UpdateAsync(WaitUntil.Completed, patch); - ElasticSanVolumeGroupResource result = lro.Value; + ElasticSanVolumeGroupResource result = await elasticSanVolumeGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -168,10 +135,10 @@ public async Task Delete_VolumeGroupsDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VolumeGroupsGetMaximumSetGen() + public async Task Update_VolumeGroupsUpdateMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Get_MaximumSet_Gen.json - // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Update_MaximumSet_Gen.json + // this example is just showing the usage of "VolumeGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,7 +155,35 @@ public async Task Get_VolumeGroupsGetMaximumSetGen() ElasticSanVolumeGroupResource elasticSanVolumeGroup = client.GetElasticSanVolumeGroupResource(elasticSanVolumeGroupResourceId); // invoke the operation - ElasticSanVolumeGroupResource result = await elasticSanVolumeGroup.GetAsync(); + ElasticSanVolumeGroupPatch patch = new ElasticSanVolumeGroupPatch + { + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("key1006")] = new UserAssignedIdentity() +}, + }, + ProtocolType = ElasticSanStorageTargetType.Iscsi, + Encryption = ElasticSanEncryptionType.EncryptionAtRestWithPlatformKey, + EncryptionProperties = new ElasticSanEncryptionProperties + { + KeyVaultProperties = new ElasticSanKeyVaultProperties + { + KeyName = "lunpapamzeimppgobraxjt", + KeyVersion = "oemygbnfmqhijmonkqfqmy", + KeyVaultUri = new Uri("https://microsoft.com/a"), + }, + EncryptionUserAssignedIdentity = new ResourceIdentifier("gfhkfbozahmmwluqndfgxunssafa"), + }, + VirtualNetworkRules = {new ElasticSanVirtualNetworkRule(new ResourceIdentifier("bkhwaiqvvaguymsmnzzbzz")) +{ +Action = ElasticSanVirtualNetworkRuleAction.Allow, +}}, + EnforceDataIntegrityCheckForIscsi = true, + }; + ArmOperation lro = await elasticSanVolumeGroup.UpdateAsync(WaitUntil.Completed, patch); + ElasticSanVolumeGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -199,10 +194,10 @@ public async Task Get_VolumeGroupsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VolumeGroupsGetMinimumSetGen() + public async Task Update_VolumeGroupsUpdateMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Get_MinimumSet_Gen.json - // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/VolumeGroups_Update_MinimumSet_Gen.json + // this example is just showing the usage of "VolumeGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -219,7 +214,9 @@ public async Task Get_VolumeGroupsGetMinimumSetGen() ElasticSanVolumeGroupResource elasticSanVolumeGroup = client.GetElasticSanVolumeGroupResource(elasticSanVolumeGroupResourceId); // invoke the operation - ElasticSanVolumeGroupResource result = await elasticSanVolumeGroup.GetAsync(); + ElasticSanVolumeGroupPatch patch = new ElasticSanVolumeGroupPatch(); + ArmOperation lro = await elasticSanVolumeGroup.UpdateAsync(WaitUntil.Completed, patch); + ElasticSanVolumeGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeResource.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeResource.cs index 98dd8eb55b2a5..934adbb100ac8 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeResource.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_ElasticSanVolumeResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ElasticSanVolumeResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VolumesUpdateMaximumSetGen() + public async Task Get_VolumesGetMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Update_MaximumSet_Gen.json - // this example is just showing the usage of "Volumes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,12 +39,7 @@ public async Task Update_VolumesUpdateMaximumSetGen() ElasticSanVolumeResource elasticSanVolume = client.GetElasticSanVolumeResource(elasticSanVolumeResourceId); // invoke the operation - ElasticSanVolumePatch patch = new ElasticSanVolumePatch() - { - SizeGiB = 11L, - }; - ArmOperation lro = await elasticSanVolume.UpdateAsync(WaitUntil.Completed, patch); - ElasticSanVolumeResource result = lro.Value; + ElasticSanVolumeResource result = await elasticSanVolume.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +50,10 @@ public async Task Update_VolumesUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VolumesUpdateMinimumSetGen() + public async Task Get_VolumesGetMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Update_MinimumSet_Gen.json - // this example is just showing the usage of "Volumes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MinimumSet_Gen.json + // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,9 +71,7 @@ public async Task Update_VolumesUpdateMinimumSetGen() ElasticSanVolumeResource elasticSanVolume = client.GetElasticSanVolumeResource(elasticSanVolumeResourceId); // invoke the operation - ElasticSanVolumePatch patch = new ElasticSanVolumePatch(); - ArmOperation lro = await elasticSanVolume.UpdateAsync(WaitUntil.Completed, patch); - ElasticSanVolumeResource result = lro.Value; + ElasticSanVolumeResource result = await elasticSanVolume.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -147,10 +140,10 @@ public async Task Delete_VolumesDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VolumesGetMaximumSetGen() + public async Task Update_VolumesUpdateMaximumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Update_MaximumSet_Gen.json + // this example is just showing the usage of "Volumes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -168,7 +161,12 @@ public async Task Get_VolumesGetMaximumSetGen() ElasticSanVolumeResource elasticSanVolume = client.GetElasticSanVolumeResource(elasticSanVolumeResourceId); // invoke the operation - ElasticSanVolumeResource result = await elasticSanVolume.GetAsync(); + ElasticSanVolumePatch patch = new ElasticSanVolumePatch + { + SizeGiB = 11L, + }; + ArmOperation lro = await elasticSanVolume.UpdateAsync(WaitUntil.Completed, patch); + ElasticSanVolumeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -179,10 +177,10 @@ public async Task Get_VolumesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VolumesGetMinimumSetGen() + public async Task Update_VolumesUpdateMinimumSetGen() { - // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Get_MinimumSet_Gen.json - // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/Volumes_Update_MinimumSet_Gen.json + // this example is just showing the usage of "Volumes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -200,7 +198,9 @@ public async Task Get_VolumesGetMinimumSetGen() ElasticSanVolumeResource elasticSanVolume = client.GetElasticSanVolumeResource(elasticSanVolumeResourceId); // invoke the operation - ElasticSanVolumeResource result = await elasticSanVolume.GetAsync(); + ElasticSanVolumePatch patch = new ElasticSanVolumePatch(); + ArmOperation lro = await elasticSanVolume.UpdateAsync(WaitUntil.Completed, patch); + ElasticSanVolumeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 670686d3e4251..c3ec638ac68e7 100644 --- a/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/elasticsan/Azure.ResourceManager.ElasticSan/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -71,5 +71,67 @@ public async Task GetSkus_SkusListMinimumSetGen() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetElasticSans_ElasticSansListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "ElasticSans_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subscriptionid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ElasticSanResource item in subscriptionResource.GetElasticSansAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetElasticSans_ElasticSansListBySubscriptionMinimumSetGen() + { + // Generated from example definition: specification/elasticsan/resource-manager/Microsoft.ElasticSan/preview/2024-06-01-preview/examples/ElasticSans_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "ElasticSans_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subscriptionid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ElasticSanResource item in subscriptionResource.GetElasticSansAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticSanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_CaCertificateCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_CaCertificateCollection.cs index ea804cf56ffaa..f45041206ed0d 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_CaCertificateCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_CaCertificateCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CaCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CaCertificatesGet() + public async Task CreateOrUpdate_CaCertificatesCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_Get.json - // this example is just showing the usage of "CaCertificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_CreateOrUpdate.json + // this example is just showing the usage of "CaCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,13 @@ public async Task Get_CaCertificatesGet() // invoke the operation string caCertificateName = "exampleCACertificateName1"; - CaCertificateResource result = await collection.GetAsync(caCertificateName); + CaCertificateData data = new CaCertificateData + { + Description = "This is a test certificate", + EncodedCertificate = "base64EncodePemFormattedCertificateString", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, caCertificateName, data); + CaCertificateResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +57,7 @@ public async Task Get_CaCertificatesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CaCertificatesGet() + public async Task Get_CaCertificatesGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_Get.json // this example is just showing the usage of "CaCertificates_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +80,21 @@ public async Task Exists_CaCertificatesGet() // invoke the operation string caCertificateName = "exampleCACertificateName1"; - bool result = await collection.ExistsAsync(caCertificateName); + CaCertificateResource result = await collection.GetAsync(caCertificateName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CaCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CaCertificatesGet() + public async Task GetAll_CaCertificatesListByNamespace() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_Get.json - // this example is just showing the usage of "CaCertificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_ListByNamespace.json + // this example is just showing the usage of "CaCertificates_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,38 +105,32 @@ public async Task GetIfExists_CaCertificatesGet() // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string namespaceName = "exampleNamespaceName1"; + string namespaceName = "namespace123"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // get the collection of this CaCertificateResource CaCertificateCollection collection = eventGridNamespace.GetCaCertificates(); - // invoke the operation - string caCertificateName = "exampleCACertificateName1"; - NullableResponse response = await collection.GetIfExistsAsync(caCertificateName); - CaCertificateResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CaCertificateResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CaCertificateData resourceData = result.Data; + CaCertificateData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CaCertificatesCreateOrUpdate() + public async Task Exists_CaCertificatesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_CreateOrUpdate.json - // this example is just showing the usage of "CaCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_Get.json + // this example is just showing the usage of "CaCertificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,27 +150,17 @@ public async Task CreateOrUpdate_CaCertificatesCreateOrUpdate() // invoke the operation string caCertificateName = "exampleCACertificateName1"; - CaCertificateData data = new CaCertificateData() - { - Description = "This is a test certificate", - EncodedCertificate = "base64EncodePemFormattedCertificateString", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, caCertificateName, data); - CaCertificateResource result = lro.Value; + bool result = await collection.ExistsAsync(caCertificateName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CaCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CaCertificatesListByNamespace() + public async Task GetIfExists_CaCertificatesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_ListByNamespace.json - // this example is just showing the usage of "CaCertificates_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_Get.json + // this example is just showing the usage of "CaCertificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,24 +171,30 @@ public async Task GetAll_CaCertificatesListByNamespace() // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string namespaceName = "namespace123"; + string namespaceName = "exampleNamespaceName1"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // get the collection of this CaCertificateResource CaCertificateCollection collection = eventGridNamespace.GetCaCertificates(); - // invoke the operation and iterate over the result - await foreach (CaCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string caCertificateName = "exampleCACertificateName1"; + NullableResponse response = await collection.GetIfExistsAsync(caCertificateName); + CaCertificateResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CaCertificateData resourceData = item.Data; + CaCertificateData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_CaCertificateResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_CaCertificateResource.cs index 1aec8b026544d..db0f6b6072257 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_CaCertificateResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_CaCertificateResource.cs @@ -48,10 +48,10 @@ public async Task Get_CaCertificatesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CaCertificatesCreateOrUpdate() + public async Task Delete_CaCertificatesDelete() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_CreateOrUpdate.json - // this example is just showing the usage of "CaCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_Delete.json + // this example is just showing the usage of "CaCertificates_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,27 +68,17 @@ public async Task Update_CaCertificatesCreateOrUpdate() CaCertificateResource caCertificate = client.GetCaCertificateResource(caCertificateResourceId); // invoke the operation - CaCertificateData data = new CaCertificateData() - { - Description = "This is a test certificate", - EncodedCertificate = "base64EncodePemFormattedCertificateString", - }; - ArmOperation lro = await caCertificate.UpdateAsync(WaitUntil.Completed, data); - CaCertificateResource result = lro.Value; + await caCertificate.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CaCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CaCertificatesDelete() + public async Task Update_CaCertificatesCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_Delete.json - // this example is just showing the usage of "CaCertificates_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/CaCertificates_CreateOrUpdate.json + // this example is just showing the usage of "CaCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +95,19 @@ public async Task Delete_CaCertificatesDelete() CaCertificateResource caCertificate = client.GetCaCertificateResource(caCertificateResourceId); // invoke the operation - await caCertificate.DeleteAsync(WaitUntil.Completed); + CaCertificateData data = new CaCertificateData + { + Description = "This is a test certificate", + EncodedCertificate = "base64EncodePemFormattedCertificateString", + }; + ArmOperation lro = await caCertificate.UpdateAsync(WaitUntil.Completed, data); + CaCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CaCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainEventSubscriptionCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainEventSubscriptionCollection.cs index feb7b5624f3fb..69cb4aea0bd38 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainEventSubscriptionCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainEventSubscriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DomainEventSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DomainEventSubscriptionsGet() + public async Task CreateOrUpdate_DomainEventSubscriptionsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_Get.json - // this example is just showing the usage of "DomainEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_CreateOrUpdate.json + // this example is just showing the usage of "DomainEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,22 @@ public async Task Get_DomainEventSubscriptionsGet() DomainEventSubscriptionCollection collection = eventGridDomain.GetDomainEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - DomainEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + string eventSubscriptionName = "exampleEventSubscriptionName1"; + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new WebHookEventSubscriptionDestination + { + Endpoint = new Uri("https://requestb.in/15ksip71"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + DomainEventSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +66,7 @@ public async Task Get_DomainEventSubscriptionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DomainEventSubscriptionsGet() + public async Task Get_DomainEventSubscriptionsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_Get.json // this example is just showing the usage of "DomainEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +89,21 @@ public async Task Exists_DomainEventSubscriptionsGet() // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + DomainEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DomainEventSubscriptionsGet() + public async Task GetAll_DomainEventSubscriptionsList() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_Get.json - // this example is just showing the usage of "DomainEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_List.json + // this example is just showing the usage of "DomainEventSubscriptions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +121,25 @@ public async Task GetIfExists_DomainEventSubscriptionsGet() // get the collection of this DomainEventSubscriptionResource DomainEventSubscriptionCollection collection = eventGridDomain.GetDomainEventSubscriptions(); - // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - DomainEventSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DomainEventSubscriptionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; + EventGridSubscriptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DomainEventSubscriptionsCreateOrUpdate() + public async Task Exists_DomainEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_CreateOrUpdate.json - // this example is just showing the usage of "DomainEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_Get.json + // this example is just showing the usage of "DomainEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,36 +158,18 @@ public async Task CreateOrUpdate_DomainEventSubscriptionsCreateOrUpdate() DomainEventSubscriptionCollection collection = eventGridDomain.GetDomainEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "exampleEventSubscriptionName1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new WebHookEventSubscriptionDestination() - { - Endpoint = new Uri("https://requestb.in/15ksip71"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - DomainEventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplesubscription1"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DomainEventSubscriptionsList() + public async Task GetIfExists_DomainEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_List.json - // this example is just showing the usage of "DomainEventSubscriptions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_Get.json + // this example is just showing the usage of "DomainEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +187,23 @@ public async Task GetAll_DomainEventSubscriptionsList() // get the collection of this DomainEventSubscriptionResource DomainEventSubscriptionCollection collection = eventGridDomain.GetDomainEventSubscriptions(); - // invoke the operation and iterate over the result - await foreach (DomainEventSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + DomainEventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = item.Data; + EventGridSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainEventSubscriptionResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainEventSubscriptionResource.cs index 043f0d6226fa6..a5aca913e9f88 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainEventSubscriptionResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainEventSubscriptionResource.cs @@ -16,36 +16,6 @@ namespace Azure.ResourceManager.EventGrid.Samples { public partial class Sample_DomainEventSubscriptionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeliveryAttributes_DomainEventSubscriptionsGetDeliveryAttributes() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_GetDeliveryAttributes.json - // this example is just showing the usage of "DomainEventSubscriptions_GetDeliveryAttributes" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DomainEventSubscriptionResource created on azure - // for more information of creating DomainEventSubscriptionResource, please refer to the document of DomainEventSubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - string resourceGroupName = "examplerg"; - string domainName = "exampleDomain1"; - string eventSubscriptionName = "examplesubscription1"; - ResourceIdentifier domainEventSubscriptionResourceId = DomainEventSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, domainName, eventSubscriptionName); - DomainEventSubscriptionResource domainEventSubscription = client.GetDomainEventSubscriptionResource(domainEventSubscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeliveryAttributeMapping item in domainEventSubscription.GetDeliveryAttributesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_DomainEventSubscriptionsGet() @@ -126,22 +96,19 @@ public async Task Update_DomainEventSubscriptionsUpdate() DomainEventSubscriptionResource domainEventSubscription = client.GetDomainEventSubscriptionResource(domainEventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new WebHookEventSubscriptionDestination() + Destination = new WebHookEventSubscriptionDestination { Endpoint = new Uri("https://requestb.in/15ksip71"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await domainEventSubscription.UpdateAsync(WaitUntil.Completed, patch); DomainEventSubscriptionResource result = lro.Value; @@ -153,6 +120,36 @@ public async Task Update_DomainEventSubscriptionsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeliveryAttributes_DomainEventSubscriptionsGetDeliveryAttributes() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainEventSubscriptions_GetDeliveryAttributes.json + // this example is just showing the usage of "DomainEventSubscriptions_GetDeliveryAttributes" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DomainEventSubscriptionResource created on azure + // for more information of creating DomainEventSubscriptionResource, please refer to the document of DomainEventSubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + string resourceGroupName = "examplerg"; + string domainName = "exampleDomain1"; + string eventSubscriptionName = "examplesubscription1"; + ResourceIdentifier domainEventSubscriptionResourceId = DomainEventSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, domainName, eventSubscriptionName); + DomainEventSubscriptionResource domainEventSubscription = client.GetDomainEventSubscriptionResource(domainEventSubscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeliveryAttributeMapping item in domainEventSubscription.GetDeliveryAttributesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetFullUri_DomainEventSubscriptionsGetFullUrl() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainNetworkSecurityPerimeterConfigurationCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainNetworkSecurityPerimeterConfigurationCollection.cs index 500c9826a6f63..b897167cef108 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainNetworkSecurityPerimeterConfigurationCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainNetworkSecurityPerimeterConfigurationCollection.cs @@ -52,10 +52,10 @@ public async Task Get_NetworkSecurityPerimeterConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkSecurityPerimeterConfigurationsGet() + public async Task GetAll_NetworkSecurityPerimeterConfigurationsList() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurations_Get.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurations_List.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,17 +73,19 @@ public async Task Exists_NetworkSecurityPerimeterConfigurationsGet() // get the collection of this DomainNetworkSecurityPerimeterConfigurationResource DomainNetworkSecurityPerimeterConfigurationCollection collection = eventGridDomain.GetDomainNetworkSecurityPerimeterConfigurations(); - // invoke the operation - string perimeterGuid = "8f6b6269-84f2-4d09-9e31-1127efcd1e40perimeter"; - string associationName = "someAssociation"; - bool result = await collection.ExistsAsync(perimeterGuid, associationName); + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterConfigurationData item in collection.GetAllAsync()) + { + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {item.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkSecurityPerimeterConfigurationsGet() + public async Task Exists_NetworkSecurityPerimeterConfigurationsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurations_Get.json // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +109,17 @@ public async Task GetIfExists_NetworkSecurityPerimeterConfigurationsGet() // invoke the operation string perimeterGuid = "8f6b6269-84f2-4d09-9e31-1127efcd1e40perimeter"; string associationName = "someAssociation"; - NullableResponse response = await collection.GetIfExistsAsync(perimeterGuid, associationName); - DomainNetworkSecurityPerimeterConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(perimeterGuid, associationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkSecurityPerimeterConfigurationsList() + public async Task GetIfExists_NetworkSecurityPerimeterConfigurationsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurations_List.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurations_Get.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,14 +137,24 @@ public async Task GetAll_NetworkSecurityPerimeterConfigurationsList() // get the collection of this DomainNetworkSecurityPerimeterConfigurationResource DomainNetworkSecurityPerimeterConfigurationCollection collection = eventGridDomain.GetDomainNetworkSecurityPerimeterConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkSecurityPerimeterConfigurationData item in collection.GetAllAsync()) + // invoke the operation + string perimeterGuid = "8f6b6269-84f2-4d09-9e31-1127efcd1e40perimeter"; + string associationName = "someAssociation"; + NullableResponse response = await collection.GetIfExistsAsync(perimeterGuid, associationName); + DomainNetworkSecurityPerimeterConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {item.Id}"); + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicCollection.cs index 12e268efd0bc7..78b7fd3d43719 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DomainTopicCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DomainTopicsGet() + public async Task CreateOrUpdate_DomainTopicsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_Get.json - // this example is just showing the usage of "DomainTopics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_CreateOrUpdate.json + // this example is just showing the usage of "DomainTopics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task Get_DomainTopicsGet() // for more information of creating EventGridDomainResource, please refer to the document of EventGridDomainResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string domainName = "exampledomain2"; + string domainName = "exampledomain1"; ResourceIdentifier eventGridDomainResourceId = EventGridDomainResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, domainName); EventGridDomainResource eventGridDomain = client.GetEventGridDomainResource(eventGridDomainResourceId); @@ -39,8 +39,9 @@ public async Task Get_DomainTopicsGet() DomainTopicCollection collection = eventGridDomain.GetDomainTopics(); // invoke the operation - string domainTopicName = "topic1"; - DomainTopicResource result = await collection.GetAsync(domainTopicName); + string domainTopicName = "exampledomaintopic1"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainTopicName); + DomainTopicResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +52,7 @@ public async Task Get_DomainTopicsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DomainTopicsGet() + public async Task Get_DomainTopicsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_Get.json // this example is just showing the usage of "DomainTopics_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +75,21 @@ public async Task Exists_DomainTopicsGet() // invoke the operation string domainTopicName = "topic1"; - bool result = await collection.ExistsAsync(domainTopicName); + DomainTopicResource result = await collection.GetAsync(domainTopicName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DomainTopicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DomainTopicsGet() + public async Task GetAll_DomainTopicsListByDomain() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_Get.json - // this example is just showing the usage of "DomainTopics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_ListByDomain.json + // this example is just showing the usage of "DomainTopics_ListByDomain" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +107,25 @@ public async Task GetIfExists_DomainTopicsGet() // get the collection of this DomainTopicResource DomainTopicCollection collection = eventGridDomain.GetDomainTopics(); - // invoke the operation - string domainTopicName = "topic1"; - NullableResponse response = await collection.GetIfExistsAsync(domainTopicName); - DomainTopicResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DomainTopicResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DomainTopicData resourceData = result.Data; + DomainTopicData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DomainTopicsCreateOrUpdate() + public async Task Exists_DomainTopicsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_CreateOrUpdate.json - // this example is just showing the usage of "DomainTopics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_Get.json + // this example is just showing the usage of "DomainTopics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,7 +136,7 @@ public async Task CreateOrUpdate_DomainTopicsCreateOrUpdate() // for more information of creating EventGridDomainResource, please refer to the document of EventGridDomainResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string domainName = "exampledomain1"; + string domainName = "exampledomain2"; ResourceIdentifier eventGridDomainResourceId = EventGridDomainResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, domainName); EventGridDomainResource eventGridDomain = client.GetEventGridDomainResource(eventGridDomainResourceId); @@ -145,23 +144,18 @@ public async Task CreateOrUpdate_DomainTopicsCreateOrUpdate() DomainTopicCollection collection = eventGridDomain.GetDomainTopics(); // invoke the operation - string domainTopicName = "exampledomaintopic1"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainTopicName); - DomainTopicResource result = lro.Value; + string domainTopicName = "topic1"; + bool result = await collection.ExistsAsync(domainTopicName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DomainTopicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DomainTopicsListByDomain() + public async Task GetIfExists_DomainTopicsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_ListByDomain.json - // this example is just showing the usage of "DomainTopics_ListByDomain" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_Get.json + // this example is just showing the usage of "DomainTopics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_DomainTopicsListByDomain() // get the collection of this DomainTopicResource DomainTopicCollection collection = eventGridDomain.GetDomainTopics(); - // invoke the operation and iterate over the result - await foreach (DomainTopicResource item in collection.GetAllAsync()) + // invoke the operation + string domainTopicName = "topic1"; + NullableResponse response = await collection.GetIfExistsAsync(domainTopicName); + DomainTopicResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DomainTopicData resourceData = item.Data; + DomainTopicData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicEventSubscriptionCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicEventSubscriptionCollection.cs index 5b2d9dcb86c56..7dc4df40dea96 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicEventSubscriptionCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicEventSubscriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DomainTopicEventSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DomainTopicEventSubscriptionsGet() + public async Task CreateOrUpdate_DomainTopicEventSubscriptionsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_Get.json - // this example is just showing the usage of "DomainTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_CreateOrUpdate.json + // this example is just showing the usage of "DomainTopicEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,8 +41,22 @@ public async Task Get_DomainTopicEventSubscriptionsGet() DomainTopicEventSubscriptionCollection collection = domainTopic.GetDomainTopicEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - DomainTopicEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + string eventSubscriptionName = "exampleEventSubscriptionName1"; + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new WebHookEventSubscriptionDestination + { + Endpoint = new Uri("https://requestb.in/15ksip71"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + DomainTopicEventSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +67,7 @@ public async Task Get_DomainTopicEventSubscriptionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DomainTopicEventSubscriptionsGet() + public async Task Get_DomainTopicEventSubscriptionsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_Get.json // this example is just showing the usage of "DomainTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +91,21 @@ public async Task Exists_DomainTopicEventSubscriptionsGet() // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + DomainTopicEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DomainTopicEventSubscriptionsGet() + public async Task GetAll_DomainTopicEventSubscriptionsList() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_Get.json - // this example is just showing the usage of "DomainTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_List.json + // this example is just showing the usage of "DomainTopicEventSubscriptions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +124,25 @@ public async Task GetIfExists_DomainTopicEventSubscriptionsGet() // get the collection of this DomainTopicEventSubscriptionResource DomainTopicEventSubscriptionCollection collection = domainTopic.GetDomainTopicEventSubscriptions(); - // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - DomainTopicEventSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DomainTopicEventSubscriptionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; + EventGridSubscriptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DomainTopicEventSubscriptionsCreateOrUpdate() + public async Task Exists_DomainTopicEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_CreateOrUpdate.json - // this example is just showing the usage of "DomainTopicEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_Get.json + // this example is just showing the usage of "DomainTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,36 +162,18 @@ public async Task CreateOrUpdate_DomainTopicEventSubscriptionsCreateOrUpdate() DomainTopicEventSubscriptionCollection collection = domainTopic.GetDomainTopicEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "exampleEventSubscriptionName1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new WebHookEventSubscriptionDestination() - { - Endpoint = new Uri("https://requestb.in/15ksip71"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - DomainTopicEventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplesubscription1"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DomainTopicEventSubscriptionsList() + public async Task GetIfExists_DomainTopicEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_List.json - // this example is just showing the usage of "DomainTopicEventSubscriptions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_Get.json + // this example is just showing the usage of "DomainTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,17 +192,23 @@ public async Task GetAll_DomainTopicEventSubscriptionsList() // get the collection of this DomainTopicEventSubscriptionResource DomainTopicEventSubscriptionCollection collection = domainTopic.GetDomainTopicEventSubscriptions(); - // invoke the operation and iterate over the result - await foreach (DomainTopicEventSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + DomainTopicEventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = item.Data; + EventGridSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicEventSubscriptionResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicEventSubscriptionResource.cs index a2f43acd031fc..ff41ba2f7607e 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicEventSubscriptionResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicEventSubscriptionResource.cs @@ -16,37 +16,6 @@ namespace Azure.ResourceManager.EventGrid.Samples { public partial class Sample_DomainTopicEventSubscriptionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeliveryAttributes_DomainTopicEventSubscriptionsGetDeliveryAttributes() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_GetDeliveryAttributes.json - // this example is just showing the usage of "DomainTopicEventSubscriptions_GetDeliveryAttributes" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DomainTopicEventSubscriptionResource created on azure - // for more information of creating DomainTopicEventSubscriptionResource, please refer to the document of DomainTopicEventSubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - string resourceGroupName = "examplerg"; - string domainName = "exampleDomain1"; - string topicName = "exampleDomainTopic1"; - string eventSubscriptionName = "examplesubscription1"; - ResourceIdentifier domainTopicEventSubscriptionResourceId = DomainTopicEventSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, domainName, topicName, eventSubscriptionName); - DomainTopicEventSubscriptionResource domainTopicEventSubscription = client.GetDomainTopicEventSubscriptionResource(domainTopicEventSubscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeliveryAttributeMapping item in domainTopicEventSubscription.GetDeliveryAttributesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_DomainTopicEventSubscriptionsGet() @@ -130,22 +99,19 @@ public async Task Update_DomainTopicEventSubscriptionsUpdate() DomainTopicEventSubscriptionResource domainTopicEventSubscription = client.GetDomainTopicEventSubscriptionResource(domainTopicEventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new WebHookEventSubscriptionDestination() + Destination = new WebHookEventSubscriptionDestination { Endpoint = new Uri("https://requestb.in/15ksip71"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await domainTopicEventSubscription.UpdateAsync(WaitUntil.Completed, patch); DomainTopicEventSubscriptionResource result = lro.Value; @@ -157,6 +123,37 @@ public async Task Update_DomainTopicEventSubscriptionsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeliveryAttributes_DomainTopicEventSubscriptionsGetDeliveryAttributes() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopicEventSubscriptions_GetDeliveryAttributes.json + // this example is just showing the usage of "DomainTopicEventSubscriptions_GetDeliveryAttributes" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DomainTopicEventSubscriptionResource created on azure + // for more information of creating DomainTopicEventSubscriptionResource, please refer to the document of DomainTopicEventSubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + string resourceGroupName = "examplerg"; + string domainName = "exampleDomain1"; + string topicName = "exampleDomainTopic1"; + string eventSubscriptionName = "examplesubscription1"; + ResourceIdentifier domainTopicEventSubscriptionResourceId = DomainTopicEventSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, domainName, topicName, eventSubscriptionName); + DomainTopicEventSubscriptionResource domainTopicEventSubscription = client.GetDomainTopicEventSubscriptionResource(domainTopicEventSubscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeliveryAttributeMapping item in domainTopicEventSubscription.GetDeliveryAttributesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetFullUri_DomainTopicEventSubscriptionsGetFullUrl() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicResource.cs index d7e8972f5eceb..c54f9542c4155 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_DomainTopicResource.cs @@ -48,10 +48,10 @@ public async Task Get_DomainTopicsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DomainTopicsCreateOrUpdate() + public async Task Delete_DomainTopicsDelete() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_CreateOrUpdate.json - // this example is just showing the usage of "DomainTopics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_Delete.json + // this example is just showing the usage of "DomainTopics_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,22 +68,17 @@ public async Task Update_DomainTopicsCreateOrUpdate() DomainTopicResource domainTopic = client.GetDomainTopicResource(domainTopicResourceId); // invoke the operation - ArmOperation lro = await domainTopic.UpdateAsync(WaitUntil.Completed); - DomainTopicResource result = lro.Value; + await domainTopic.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DomainTopicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DomainTopicsDelete() + public async Task Update_DomainTopicsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_Delete.json - // this example is just showing the usage of "DomainTopics_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/DomainTopics_CreateOrUpdate.json + // this example is just showing the usage of "DomainTopics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,9 +95,14 @@ public async Task Delete_DomainTopicsDelete() DomainTopicResource domainTopic = client.GetDomainTopicResource(domainTopicResourceId); // invoke the operation - await domainTopic.DeleteAsync(WaitUntil.Completed); + ArmOperation lro = await domainTopic.UpdateAsync(WaitUntil.Completed); + DomainTopicResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DomainTopicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainCollection.cs index 7a605e2a76d26..9cdffa21894e9 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_EventGridDomainCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DomainsGet() + public async Task CreateOrUpdate_DomainsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_Get.json - // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_CreateOrUpdate.json + // this example is just showing the usage of "Domains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,27 @@ public async Task Get_DomainsGet() EventGridDomainCollection collection = resourceGroupResource.GetEventGridDomains(); // invoke the operation - string domainName = "exampledomain2"; - EventGridDomainResource result = await collection.GetAsync(domainName); + string domainName = "exampledomain1"; + EventGridDomainData data = new EventGridDomainData(new AzureLocation("westus2")) + { + PublicNetworkAccess = EventGridPublicNetworkAccess.Enabled, + InboundIPRules = {new EventGridInboundIPRule +{ +IPMask = "12.18.30.15", +Action = EventGridIPActionType.Allow, +}, new EventGridInboundIPRule +{ +IPMask = "12.18.176.1", +Action = EventGridIPActionType.Allow, +}}, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); + EventGridDomainResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +71,7 @@ public async Task Get_DomainsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DomainsGet() + public async Task Get_DomainsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_Get.json // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +93,21 @@ public async Task Exists_DomainsGet() // invoke the operation string domainName = "exampledomain2"; - bool result = await collection.ExistsAsync(domainName); + EventGridDomainResource result = await collection.GetAsync(domainName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DomainsGet() + public async Task GetAll_DomainsListByResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_Get.json - // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_ListByResourceGroup.json + // this example is just showing the usage of "Domains_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +124,25 @@ public async Task GetIfExists_DomainsGet() // get the collection of this EventGridDomainResource EventGridDomainCollection collection = resourceGroupResource.GetEventGridDomains(); - // invoke the operation - string domainName = "exampledomain2"; - NullableResponse response = await collection.GetIfExistsAsync(domainName); - EventGridDomainResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EventGridDomainResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridDomainData resourceData = result.Data; + EventGridDomainData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DomainsCreateOrUpdate() + public async Task Exists_DomainsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_CreateOrUpdate.json - // this example is just showing the usage of "Domains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_Get.json + // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,44 +160,18 @@ public async Task CreateOrUpdate_DomainsCreateOrUpdate() EventGridDomainCollection collection = resourceGroupResource.GetEventGridDomains(); // invoke the operation - string domainName = "exampledomain1"; - EventGridDomainData data = new EventGridDomainData(new AzureLocation("westus2")) - { - PublicNetworkAccess = EventGridPublicNetworkAccess.Enabled, - InboundIPRules = -{ -new EventGridInboundIPRule() -{ -IPMask = "12.18.30.15", -Action = EventGridIPActionType.Allow, -},new EventGridInboundIPRule() -{ -IPMask = "12.18.176.1", -Action = EventGridIPActionType.Allow, -} -}, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); - EventGridDomainResource result = lro.Value; + string domainName = "exampledomain2"; + bool result = await collection.ExistsAsync(domainName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DomainsListByResourceGroup() + public async Task GetIfExists_DomainsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_ListByResourceGroup.json - // this example is just showing the usage of "Domains_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_Get.json + // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -197,17 +188,23 @@ public async Task GetAll_DomainsListByResourceGroup() // get the collection of this EventGridDomainResource EventGridDomainCollection collection = resourceGroupResource.GetEventGridDomains(); - // invoke the operation and iterate over the result - await foreach (EventGridDomainResource item in collection.GetAllAsync()) + // invoke the operation + string domainName = "exampledomain2"; + NullableResponse response = await collection.GetIfExistsAsync(domainName); + EventGridDomainResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridDomainData resourceData = item.Data; + EventGridDomainData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateEndpointConnectionCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateEndpointConnectionCollection.cs index 211e6de92d223..863f509e036f0 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateEndpointConnectionCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EventGridDomainPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGet() + public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - EventGridDomainPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData + { + ConnectionState = new EventGridPrivateEndpointConnectionState + { + Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, + Description = "approving connection", + ActionsRequired = "None", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + EventGridDomainPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +62,7 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGet() + public async Task Get_PrivateEndpointConnectionsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +85,21 @@ public async Task Exists_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + EventGridDomainPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGet() + public async Task GetAll_PrivateEndpointConnectionsListByResource() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_ListByResource.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +117,25 @@ public async Task GetIfExists_PrivateEndpointConnectionsGet() // get the collection of this EventGridDomainPrivateEndpointConnectionResource EventGridDomainPrivateEndpointConnectionCollection collection = eventGridDomain.GetEventGridDomainPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - EventGridDomainPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EventGridDomainPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = result.Data; + EventGridPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() + public async Task Exists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,31 +155,17 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() // invoke the operation string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData() - { - ConnectionState = new EventGridPrivateEndpointConnectionState() - { - Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, - Description = "approving connection", - ActionsRequired = "None", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - EventGridDomainPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsListByResource() + public async Task GetIfExists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_ListByResource.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_PrivateEndpointConnectionsListByResource() // get the collection of this EventGridDomainPrivateEndpointConnectionResource EventGridDomainPrivateEndpointConnectionCollection collection = eventGridDomain.GetEventGridDomainPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (EventGridDomainPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + EventGridDomainPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = item.Data; + EventGridPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateEndpointConnectionResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateEndpointConnectionResource.cs index d7ac7fa759e6e..f32b4b19d2f3e 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateEndpointConnectionResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsUpdate() + public async Task Delete_PrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,17 @@ public async Task Update_PrivateEndpointConnectionsUpdate() EventGridDomainPrivateEndpointConnectionResource eventGridDomainPrivateEndpointConnection = client.GetEventGridDomainPrivateEndpointConnectionResource(eventGridDomainPrivateEndpointConnectionResourceId); // invoke the operation - EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData() - { - ConnectionState = new EventGridPrivateEndpointConnectionState() - { - Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, - Description = "approving connection", - ActionsRequired = "None", - }, - }; - ArmOperation lro = await eventGridDomainPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - EventGridDomainPrivateEndpointConnectionResource result = lro.Value; + await eventGridDomainPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDelete() + public async Task Update_PrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +96,23 @@ public async Task Delete_PrivateEndpointConnectionsDelete() EventGridDomainPrivateEndpointConnectionResource eventGridDomainPrivateEndpointConnection = client.GetEventGridDomainPrivateEndpointConnectionResource(eventGridDomainPrivateEndpointConnectionResourceId); // invoke the operation - await eventGridDomainPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData + { + ConnectionState = new EventGridPrivateEndpointConnectionState + { + Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, + Description = "approving connection", + ActionsRequired = "None", + }, + }; + ArmOperation lro = await eventGridDomainPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + EventGridDomainPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateLinkResourceCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateLinkResourceCollection.cs index 00357a1c14b5d..8cefe3aaa39e9 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateLinkResourceCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainPrivateLinkResourceCollection.cs @@ -51,10 +51,10 @@ public async Task Get_PrivateLinkResourcesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateLinkResourcesGet() + public async Task GetAll_PrivateLinkResourcesListByResource() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_Get.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_ListByResource.json + // this example is just showing the usage of "PrivateLinkResources_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_PrivateLinkResourcesGet() // get the collection of this EventGridDomainPrivateLinkResource EventGridDomainPrivateLinkResourceCollection collection = eventGridDomain.GetEventGridDomainPrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "topic"; - bool result = await collection.ExistsAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (EventGridDomainPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateLinkResourcesGet() + public async Task Exists_PrivateLinkResourcesGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_Get.json // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_PrivateLinkResourcesGet() // invoke the operation string privateLinkResourceName = "topic"; - NullableResponse response = await collection.GetIfExistsAsync(privateLinkResourceName); - EventGridDomainPrivateLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateLinkResourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesListByResource() + public async Task GetIfExists_PrivateLinkResourcesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_ListByResource.json - // this example is just showing the usage of "PrivateLinkResources_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_Get.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_PrivateLinkResourcesListByResource() // get the collection of this EventGridDomainPrivateLinkResource EventGridDomainPrivateLinkResourceCollection collection = eventGridDomain.GetEventGridDomainPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (EventGridDomainPrivateLinkResource item in collection.GetAllAsync()) + // invoke the operation + string privateLinkResourceName = "topic"; + NullableResponse response = await collection.GetIfExistsAsync(privateLinkResourceName); + EventGridDomainPrivateLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridPrivateLinkResourceData resourceData = item.Data; + EventGridPrivateLinkResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainResource.cs index c942b807b6e26..1d81d0e370f41 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridDomainResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EventGrid.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -94,63 +93,29 @@ public async Task Update_DomainsUpdate() EventGridDomainResource eventGridDomain = client.GetEventGridDomainResource(eventGridDomainResourceId); // invoke the operation - EventGridDomainPatch patch = new EventGridDomainPatch() + EventGridDomainPatch patch = new EventGridDomainPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, PublicNetworkAccess = EventGridPublicNetworkAccess.Enabled, - InboundIPRules = -{ -new EventGridInboundIPRule() + InboundIPRules = {new EventGridInboundIPRule { IPMask = "12.18.30.15", Action = EventGridIPActionType.Allow, -},new EventGridInboundIPRule() +}, new EventGridInboundIPRule { IPMask = "12.18.176.1", Action = EventGridIPActionType.Allow, -} -}, +}}, }; await eventGridDomain.UpdateAsync(WaitUntil.Completed, patch); Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEventGridDomains_DomainsListBySubscription() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_ListBySubscription.json - // this example is just showing the usage of "Domains_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (EventGridDomainResource item in subscriptionResource.GetEventGridDomainsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridDomainData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSharedAccessKeys_DomainsListSharedAccessKeys() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientCollection.cs index fbf349c087bff..313828cdc6722 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EventGridNamespaceClientCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ClientsGet() + public async Task CreateOrUpdate_ClientsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_Get.json - // this example is just showing the usage of "Clients_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_CreateOrUpdate.json + // this example is just showing the usage of "Clients_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,28 @@ public async Task Get_ClientsGet() // invoke the operation string clientName = "exampleClientName1"; - EventGridNamespaceClientResource result = await collection.GetAsync(clientName); + EventGridNamespaceClientData data = new EventGridNamespaceClientData + { + Description = "This is a test client", + ClientCertificateAuthentication = new ClientCertificateAuthentication + { + ValidationScheme = ClientCertificateValidationScheme.SubjectMatchesAuthenticationName, + }, + State = EventGridNamespaceClientState.Enabled, + Attributes = +{ +["deviceTypes"] = BinaryData.FromObjectAsJson(new object[] +{ +"Fan", +"Light", +"AC" +}), +["floor"] = BinaryData.FromObjectAsJson("3"), +["room"] = BinaryData.FromObjectAsJson("345") +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clientName, data); + EventGridNamespaceClientResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +73,7 @@ public async Task Get_ClientsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ClientsGet() + public async Task Get_ClientsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_Get.json // this example is just showing the usage of "Clients_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +96,21 @@ public async Task Exists_ClientsGet() // invoke the operation string clientName = "exampleClientName1"; - bool result = await collection.ExistsAsync(clientName); + EventGridNamespaceClientResource result = await collection.GetAsync(clientName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridNamespaceClientData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ClientsGet() + public async Task GetAll_ClientsListByNamespace() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_Get.json - // this example is just showing the usage of "Clients_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_ListByNamespace.json + // this example is just showing the usage of "Clients_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,38 +121,32 @@ public async Task GetIfExists_ClientsGet() // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string namespaceName = "exampleNamespaceName1"; + string namespaceName = "namespace123"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // get the collection of this EventGridNamespaceClientResource EventGridNamespaceClientCollection collection = eventGridNamespace.GetEventGridNamespaceClients(); - // invoke the operation - string clientName = "exampleClientName1"; - NullableResponse response = await collection.GetIfExistsAsync(clientName); - EventGridNamespaceClientResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EventGridNamespaceClientResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridNamespaceClientData resourceData = result.Data; + EventGridNamespaceClientData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ClientsCreateOrUpdate() + public async Task Exists_ClientsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_CreateOrUpdate.json - // this example is just showing the usage of "Clients_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_Get.json + // this example is just showing the usage of "Clients_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,37 +166,17 @@ public async Task CreateOrUpdate_ClientsCreateOrUpdate() // invoke the operation string clientName = "exampleClientName1"; - EventGridNamespaceClientData data = new EventGridNamespaceClientData() - { - Description = "This is a test client", - ClientCertificateAuthentication = new ClientCertificateAuthentication() - { - ValidationScheme = ClientCertificateValidationScheme.SubjectMatchesAuthenticationName, - }, - State = EventGridNamespaceClientState.Enabled, - Attributes = -{ -["deviceTypes"] = BinaryData.FromObjectAsJson(new object[] { "Fan", "Light", "AC" }), -["floor"] = BinaryData.FromString("\"3\""), -["room"] = BinaryData.FromString("\"345\""), -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clientName, data); - EventGridNamespaceClientResource result = lro.Value; + bool result = await collection.ExistsAsync(clientName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridNamespaceClientData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ClientsListByNamespace() + public async Task GetIfExists_ClientsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_ListByNamespace.json - // this example is just showing the usage of "Clients_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_Get.json + // this example is just showing the usage of "Clients_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,24 +187,30 @@ public async Task GetAll_ClientsListByNamespace() // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string namespaceName = "namespace123"; + string namespaceName = "exampleNamespaceName1"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // get the collection of this EventGridNamespaceClientResource EventGridNamespaceClientCollection collection = eventGridNamespace.GetEventGridNamespaceClients(); - // invoke the operation and iterate over the result - await foreach (EventGridNamespaceClientResource item in collection.GetAllAsync()) + // invoke the operation + string clientName = "exampleClientName1"; + NullableResponse response = await collection.GetIfExistsAsync(clientName); + EventGridNamespaceClientResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridNamespaceClientData resourceData = item.Data; + EventGridNamespaceClientData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientGroupCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientGroupCollection.cs index 6fe8813994cef..6bf0c4a4d04fd 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientGroupCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientGroupCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_EventGridNamespaceClientGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ClientGroupsGet() + public async Task CreateOrUpdate_ClientGroupsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_Get.json - // this example is just showing the usage of "ClientGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_CreateOrUpdate.json + // this example is just showing the usage of "ClientGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,13 @@ public async Task Get_ClientGroupsGet() // invoke the operation string clientGroupName = "exampleClientGroupName1"; - EventGridNamespaceClientGroupResource result = await collection.GetAsync(clientGroupName); + EventGridNamespaceClientGroupData data = new EventGridNamespaceClientGroupData + { + Description = "This is a test client group", + Query = "attributes.b IN ['a', 'b', 'c']", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clientGroupName, data); + EventGridNamespaceClientGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +57,7 @@ public async Task Get_ClientGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ClientGroupsGet() + public async Task Get_ClientGroupsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_Get.json // this example is just showing the usage of "ClientGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +80,21 @@ public async Task Exists_ClientGroupsGet() // invoke the operation string clientGroupName = "exampleClientGroupName1"; - bool result = await collection.ExistsAsync(clientGroupName); + EventGridNamespaceClientGroupResource result = await collection.GetAsync(clientGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridNamespaceClientGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ClientGroupsGet() + public async Task GetAll_ClientGroupsListByNamespace() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_Get.json - // this example is just showing the usage of "ClientGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_ListByNamespace.json + // this example is just showing the usage of "ClientGroups_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,38 +105,32 @@ public async Task GetIfExists_ClientGroupsGet() // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string namespaceName = "exampleNamespaceName1"; + string namespaceName = "namespace123"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // get the collection of this EventGridNamespaceClientGroupResource EventGridNamespaceClientGroupCollection collection = eventGridNamespace.GetEventGridNamespaceClientGroups(); - // invoke the operation - string clientGroupName = "exampleClientGroupName1"; - NullableResponse response = await collection.GetIfExistsAsync(clientGroupName); - EventGridNamespaceClientGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EventGridNamespaceClientGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridNamespaceClientGroupData resourceData = result.Data; + EventGridNamespaceClientGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ClientGroupsCreateOrUpdate() + public async Task Exists_ClientGroupsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_CreateOrUpdate.json - // this example is just showing the usage of "ClientGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_Get.json + // this example is just showing the usage of "ClientGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,27 +150,17 @@ public async Task CreateOrUpdate_ClientGroupsCreateOrUpdate() // invoke the operation string clientGroupName = "exampleClientGroupName1"; - EventGridNamespaceClientGroupData data = new EventGridNamespaceClientGroupData() - { - Description = "This is a test client group", - Query = "attributes.b IN ['a', 'b', 'c']", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clientGroupName, data); - EventGridNamespaceClientGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(clientGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridNamespaceClientGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ClientGroupsListByNamespace() + public async Task GetIfExists_ClientGroupsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_ListByNamespace.json - // this example is just showing the usage of "ClientGroups_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_Get.json + // this example is just showing the usage of "ClientGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,24 +171,30 @@ public async Task GetAll_ClientGroupsListByNamespace() // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string namespaceName = "namespace123"; + string namespaceName = "exampleNamespaceName1"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // get the collection of this EventGridNamespaceClientGroupResource EventGridNamespaceClientGroupCollection collection = eventGridNamespace.GetEventGridNamespaceClientGroups(); - // invoke the operation and iterate over the result - await foreach (EventGridNamespaceClientGroupResource item in collection.GetAllAsync()) + // invoke the operation + string clientGroupName = "exampleClientGroupName1"; + NullableResponse response = await collection.GetIfExistsAsync(clientGroupName); + EventGridNamespaceClientGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridNamespaceClientGroupData resourceData = item.Data; + EventGridNamespaceClientGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientGroupResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientGroupResource.cs index 0f7b0eb01c585..c68abac10a707 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientGroupResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientGroupResource.cs @@ -48,10 +48,10 @@ public async Task Get_ClientGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ClientGroupsCreateOrUpdate() + public async Task Delete_ClientGroupsDelete() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_CreateOrUpdate.json - // this example is just showing the usage of "ClientGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_Delete.json + // this example is just showing the usage of "ClientGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,27 +68,17 @@ public async Task Update_ClientGroupsCreateOrUpdate() EventGridNamespaceClientGroupResource eventGridNamespaceClientGroup = client.GetEventGridNamespaceClientGroupResource(eventGridNamespaceClientGroupResourceId); // invoke the operation - EventGridNamespaceClientGroupData data = new EventGridNamespaceClientGroupData() - { - Description = "This is a test client group", - Query = "attributes.b IN ['a', 'b', 'c']", - }; - ArmOperation lro = await eventGridNamespaceClientGroup.UpdateAsync(WaitUntil.Completed, data); - EventGridNamespaceClientGroupResource result = lro.Value; + await eventGridNamespaceClientGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridNamespaceClientGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ClientGroupsDelete() + public async Task Update_ClientGroupsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_Delete.json - // this example is just showing the usage of "ClientGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/ClientGroups_CreateOrUpdate.json + // this example is just showing the usage of "ClientGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +95,19 @@ public async Task Delete_ClientGroupsDelete() EventGridNamespaceClientGroupResource eventGridNamespaceClientGroup = client.GetEventGridNamespaceClientGroupResource(eventGridNamespaceClientGroupResourceId); // invoke the operation - await eventGridNamespaceClientGroup.DeleteAsync(WaitUntil.Completed); + EventGridNamespaceClientGroupData data = new EventGridNamespaceClientGroupData + { + Description = "This is a test client group", + Query = "attributes.b IN ['a', 'b', 'c']", + }; + ArmOperation lro = await eventGridNamespaceClientGroup.UpdateAsync(WaitUntil.Completed, data); + EventGridNamespaceClientGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridNamespaceClientGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientResource.cs index b34afb6a1f5eb..fecb3bd870b00 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceClientResource.cs @@ -49,10 +49,10 @@ public async Task Get_ClientsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ClientsCreateOrUpdate() + public async Task Delete_ClientsDelete() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_CreateOrUpdate.json - // this example is just showing the usage of "Clients_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_Delete.json + // this example is just showing the usage of "Clients_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,37 +69,17 @@ public async Task Update_ClientsCreateOrUpdate() EventGridNamespaceClientResource eventGridNamespaceClient = client.GetEventGridNamespaceClientResource(eventGridNamespaceClientResourceId); // invoke the operation - EventGridNamespaceClientData data = new EventGridNamespaceClientData() - { - Description = "This is a test client", - ClientCertificateAuthentication = new ClientCertificateAuthentication() - { - ValidationScheme = ClientCertificateValidationScheme.SubjectMatchesAuthenticationName, - }, - State = EventGridNamespaceClientState.Enabled, - Attributes = -{ -["deviceTypes"] = BinaryData.FromObjectAsJson(new object[] { "Fan", "Light", "AC" }), -["floor"] = BinaryData.FromString("\"3\""), -["room"] = BinaryData.FromString("\"345\""), -}, - }; - ArmOperation lro = await eventGridNamespaceClient.UpdateAsync(WaitUntil.Completed, data); - EventGridNamespaceClientResource result = lro.Value; + await eventGridNamespaceClient.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridNamespaceClientData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ClientsDelete() + public async Task Update_ClientsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_Delete.json - // this example is just showing the usage of "Clients_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Clients_CreateOrUpdate.json + // this example is just showing the usage of "Clients_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,9 +96,34 @@ public async Task Delete_ClientsDelete() EventGridNamespaceClientResource eventGridNamespaceClient = client.GetEventGridNamespaceClientResource(eventGridNamespaceClientResourceId); // invoke the operation - await eventGridNamespaceClient.DeleteAsync(WaitUntil.Completed); + EventGridNamespaceClientData data = new EventGridNamespaceClientData + { + Description = "This is a test client", + ClientCertificateAuthentication = new ClientCertificateAuthentication + { + ValidationScheme = ClientCertificateValidationScheme.SubjectMatchesAuthenticationName, + }, + State = EventGridNamespaceClientState.Enabled, + Attributes = +{ +["deviceTypes"] = BinaryData.FromObjectAsJson(new object[] +{ +"Fan", +"Light", +"AC" +}), +["floor"] = BinaryData.FromObjectAsJson("3"), +["room"] = BinaryData.FromObjectAsJson("345") +}, + }; + ArmOperation lro = await eventGridNamespaceClient.UpdateAsync(WaitUntil.Completed, data); + EventGridNamespaceClientResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridNamespaceClientData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceCollection.cs index 93c1adc59eb58..5b9ee86965c67 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_EventGridNamespaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NamespacesGet() + public async Task CreateOrUpdate_NamespacesCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_Get.json - // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_CreateOrUpdate.json + // this example is just showing the usage of "Namespaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,21 @@ public async Task Get_NamespacesGet() // invoke the operation string namespaceName = "exampleNamespaceName1"; - EventGridNamespaceResource result = await collection.GetAsync(namespaceName); + EventGridNamespaceData data = new EventGridNamespaceData(new AzureLocation("westus")) + { + TopicSpacesConfiguration = new TopicSpacesConfiguration + { + State = TopicSpacesConfigurationState.Enabled, + RouteTopicResourceId = "/subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampleTopic1", + }, + Tags = +{ +["tag1"] = "value11", +["tag2"] = "value22" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, data); + EventGridNamespaceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +66,7 @@ public async Task Get_NamespacesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NamespacesGet() + public async Task Get_NamespacesGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_Get.json // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +88,21 @@ public async Task Exists_NamespacesGet() // invoke the operation string namespaceName = "exampleNamespaceName1"; - bool result = await collection.ExistsAsync(namespaceName); + EventGridNamespaceResource result = await collection.GetAsync(namespaceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridNamespaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NamespacesGet() + public async Task GetAll_NamespacesListByResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_Get.json - // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_ListByResourceGroup.json + // this example is just showing the usage of "Namespaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +119,25 @@ public async Task GetIfExists_NamespacesGet() // get the collection of this EventGridNamespaceResource EventGridNamespaceCollection collection = resourceGroupResource.GetEventGridNamespaces(); - // invoke the operation - string namespaceName = "exampleNamespaceName1"; - NullableResponse response = await collection.GetIfExistsAsync(namespaceName); - EventGridNamespaceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EventGridNamespaceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridNamespaceData resourceData = result.Data; + EventGridNamespaceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NamespacesCreateOrUpdate() + public async Task Exists_NamespacesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_CreateOrUpdate.json - // this example is just showing the usage of "Namespaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_Get.json + // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,35 +156,17 @@ public async Task CreateOrUpdate_NamespacesCreateOrUpdate() // invoke the operation string namespaceName = "exampleNamespaceName1"; - EventGridNamespaceData data = new EventGridNamespaceData(new AzureLocation("westus")) - { - TopicSpacesConfiguration = new TopicSpacesConfiguration() - { - State = TopicSpacesConfigurationState.Enabled, - RouteTopicResourceId = "/subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampleTopic1", - }, - Tags = -{ -["tag1"] = "value11", -["tag2"] = "value22", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, data); - EventGridNamespaceResource result = lro.Value; + bool result = await collection.ExistsAsync(namespaceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridNamespaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NamespacesListByResourceGroup() + public async Task GetIfExists_NamespacesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_ListByResourceGroup.json - // this example is just showing the usage of "Namespaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_Get.json + // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_NamespacesListByResourceGroup() // get the collection of this EventGridNamespaceResource EventGridNamespaceCollection collection = resourceGroupResource.GetEventGridNamespaces(); - // invoke the operation and iterate over the result - await foreach (EventGridNamespaceResource item in collection.GetAllAsync()) + // invoke the operation + string namespaceName = "exampleNamespaceName1"; + NullableResponse response = await collection.GetIfExistsAsync(namespaceName); + EventGridNamespaceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridNamespaceData resourceData = item.Data; + EventGridNamespaceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespacePermissionBindingCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespacePermissionBindingCollection.cs index e20f19f724d88..1c7947b2aff8e 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespacePermissionBindingCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespacePermissionBindingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EventGridNamespacePermissionBindingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PermissionBindingsGet() + public async Task CreateOrUpdate_PermissionBindingsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_Get.json - // this example is just showing the usage of "PermissionBindings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_CreateOrUpdate.json + // this example is just showing the usage of "PermissionBindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,14 @@ public async Task Get_PermissionBindingsGet() // invoke the operation string permissionBindingName = "examplePermissionBindingName1"; - EventGridNamespacePermissionBindingResource result = await collection.GetAsync(permissionBindingName); + EventGridNamespacePermissionBindingData data = new EventGridNamespacePermissionBindingData + { + TopicSpaceName = "exampleTopicSpaceName1", + Permission = PermissionType.Publisher, + ClientGroupName = "exampleClientGroupName1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, permissionBindingName, data); + EventGridNamespacePermissionBindingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +59,7 @@ public async Task Get_PermissionBindingsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PermissionBindingsGet() + public async Task Get_PermissionBindingsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_Get.json // this example is just showing the usage of "PermissionBindings_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +82,21 @@ public async Task Exists_PermissionBindingsGet() // invoke the operation string permissionBindingName = "examplePermissionBindingName1"; - bool result = await collection.ExistsAsync(permissionBindingName); + EventGridNamespacePermissionBindingResource result = await collection.GetAsync(permissionBindingName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridNamespacePermissionBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PermissionBindingsGet() + public async Task GetAll_PermissionBindingsListByNamespace() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_Get.json - // this example is just showing the usage of "PermissionBindings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_ListByNamespace.json + // this example is just showing the usage of "PermissionBindings_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,38 +107,32 @@ public async Task GetIfExists_PermissionBindingsGet() // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string namespaceName = "exampleNamespaceName1"; + string namespaceName = "namespace123"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // get the collection of this EventGridNamespacePermissionBindingResource EventGridNamespacePermissionBindingCollection collection = eventGridNamespace.GetEventGridNamespacePermissionBindings(); - // invoke the operation - string permissionBindingName = "examplePermissionBindingName1"; - NullableResponse response = await collection.GetIfExistsAsync(permissionBindingName); - EventGridNamespacePermissionBindingResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EventGridNamespacePermissionBindingResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridNamespacePermissionBindingData resourceData = result.Data; + EventGridNamespacePermissionBindingData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PermissionBindingsCreateOrUpdate() + public async Task Exists_PermissionBindingsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_CreateOrUpdate.json - // this example is just showing the usage of "PermissionBindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_Get.json + // this example is just showing the usage of "PermissionBindings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,28 +152,17 @@ public async Task CreateOrUpdate_PermissionBindingsCreateOrUpdate() // invoke the operation string permissionBindingName = "examplePermissionBindingName1"; - EventGridNamespacePermissionBindingData data = new EventGridNamespacePermissionBindingData() - { - TopicSpaceName = "exampleTopicSpaceName1", - Permission = PermissionType.Publisher, - ClientGroupName = "exampleClientGroupName1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, permissionBindingName, data); - EventGridNamespacePermissionBindingResource result = lro.Value; + bool result = await collection.ExistsAsync(permissionBindingName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridNamespacePermissionBindingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PermissionBindingsListByNamespace() + public async Task GetIfExists_PermissionBindingsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_ListByNamespace.json - // this example is just showing the usage of "PermissionBindings_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_Get.json + // this example is just showing the usage of "PermissionBindings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,24 +173,30 @@ public async Task GetAll_PermissionBindingsListByNamespace() // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string namespaceName = "namespace123"; + string namespaceName = "exampleNamespaceName1"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // get the collection of this EventGridNamespacePermissionBindingResource EventGridNamespacePermissionBindingCollection collection = eventGridNamespace.GetEventGridNamespacePermissionBindings(); - // invoke the operation and iterate over the result - await foreach (EventGridNamespacePermissionBindingResource item in collection.GetAllAsync()) + // invoke the operation + string permissionBindingName = "examplePermissionBindingName1"; + NullableResponse response = await collection.GetIfExistsAsync(permissionBindingName); + EventGridNamespacePermissionBindingResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridNamespacePermissionBindingData resourceData = item.Data; + EventGridNamespacePermissionBindingData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespacePermissionBindingResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespacePermissionBindingResource.cs index cbe84c52a2fdf..ac41df1d09430 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespacePermissionBindingResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespacePermissionBindingResource.cs @@ -49,10 +49,10 @@ public async Task Get_PermissionBindingsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PermissionBindingsCreateOrUpdate() + public async Task Delete_PermissionBindingsDelete() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_CreateOrUpdate.json - // this example is just showing the usage of "PermissionBindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_Delete.json + // this example is just showing the usage of "PermissionBindings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,28 +69,17 @@ public async Task Update_PermissionBindingsCreateOrUpdate() EventGridNamespacePermissionBindingResource eventGridNamespacePermissionBinding = client.GetEventGridNamespacePermissionBindingResource(eventGridNamespacePermissionBindingResourceId); // invoke the operation - EventGridNamespacePermissionBindingData data = new EventGridNamespacePermissionBindingData() - { - TopicSpaceName = "exampleTopicSpaceName1", - Permission = PermissionType.Publisher, - ClientGroupName = "exampleClientGroupName1", - }; - ArmOperation lro = await eventGridNamespacePermissionBinding.UpdateAsync(WaitUntil.Completed, data); - EventGridNamespacePermissionBindingResource result = lro.Value; + await eventGridNamespacePermissionBinding.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridNamespacePermissionBindingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PermissionBindingsDelete() + public async Task Update_PermissionBindingsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_Delete.json - // this example is just showing the usage of "PermissionBindings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PermissionBindings_CreateOrUpdate.json + // this example is just showing the usage of "PermissionBindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +96,20 @@ public async Task Delete_PermissionBindingsDelete() EventGridNamespacePermissionBindingResource eventGridNamespacePermissionBinding = client.GetEventGridNamespacePermissionBindingResource(eventGridNamespacePermissionBindingResourceId); // invoke the operation - await eventGridNamespacePermissionBinding.DeleteAsync(WaitUntil.Completed); + EventGridNamespacePermissionBindingData data = new EventGridNamespacePermissionBindingData + { + TopicSpaceName = "exampleTopicSpaceName1", + Permission = PermissionType.Publisher, + ClientGroupName = "exampleClientGroupName1", + }; + ArmOperation lro = await eventGridNamespacePermissionBinding.UpdateAsync(WaitUntil.Completed, data); + EventGridNamespacePermissionBindingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridNamespacePermissionBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceResource.cs index f0e8492fd75f1..eb699d3e41268 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridNamespaceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EventGrid.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -94,11 +93,11 @@ public async Task Update_NamespacesUpdate() EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // invoke the operation - EventGridNamespacePatch patch = new EventGridNamespacePatch() + EventGridNamespacePatch patch = new EventGridNamespacePatch { Tags = { -["tag1"] = "value1Updated", +["tag1"] = "value1Updated" }, }; ArmOperation lro = await eventGridNamespace.UpdateAsync(WaitUntil.Completed, patch); @@ -111,37 +110,6 @@ public async Task Update_NamespacesUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEventGridNamespaces_NamespacesListBySubscription() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_ListBySubscription.json - // this example is just showing the usage of "Namespaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (EventGridNamespaceResource item in subscriptionResource.GetEventGridNamespacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridNamespaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSharedAccessKeys_NamespacesListSharedAccessKeys() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridPartnerNamespacePrivateEndpointConnectionCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridPartnerNamespacePrivateEndpointConnectionCollection.cs index 0b1d6226827f9..713d4565f8764 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridPartnerNamespacePrivateEndpointConnectionCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridPartnerNamespacePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EventGridPartnerNamespacePrivateEndpointConnectionCo { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGet() + public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - EventGridPartnerNamespacePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData + { + ConnectionState = new EventGridPrivateEndpointConnectionState + { + Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, + Description = "approving connection", + ActionsRequired = "None", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + EventGridPartnerNamespacePrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +62,7 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGet() + public async Task Get_PrivateEndpointConnectionsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +85,21 @@ public async Task Exists_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + EventGridPartnerNamespacePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGet() + public async Task GetAll_PrivateEndpointConnectionsListByResource() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_ListByResource.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +117,25 @@ public async Task GetIfExists_PrivateEndpointConnectionsGet() // get the collection of this EventGridPartnerNamespacePrivateEndpointConnectionResource EventGridPartnerNamespacePrivateEndpointConnectionCollection collection = partnerNamespace.GetEventGridPartnerNamespacePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - EventGridPartnerNamespacePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EventGridPartnerNamespacePrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = result.Data; + EventGridPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() + public async Task Exists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,31 +155,17 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() // invoke the operation string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData() - { - ConnectionState = new EventGridPrivateEndpointConnectionState() - { - Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, - Description = "approving connection", - ActionsRequired = "None", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - EventGridPartnerNamespacePrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsListByResource() + public async Task GetIfExists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_ListByResource.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_PrivateEndpointConnectionsListByResource() // get the collection of this EventGridPartnerNamespacePrivateEndpointConnectionResource EventGridPartnerNamespacePrivateEndpointConnectionCollection collection = partnerNamespace.GetEventGridPartnerNamespacePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (EventGridPartnerNamespacePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + EventGridPartnerNamespacePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = item.Data; + EventGridPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridPartnerNamespacePrivateEndpointConnectionResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridPartnerNamespacePrivateEndpointConnectionResource.cs index 3d55d73ac16df..8d883e376f553 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridPartnerNamespacePrivateEndpointConnectionResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridPartnerNamespacePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsUpdate() + public async Task Delete_PrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,17 @@ public async Task Update_PrivateEndpointConnectionsUpdate() EventGridPartnerNamespacePrivateEndpointConnectionResource eventGridPartnerNamespacePrivateEndpointConnection = client.GetEventGridPartnerNamespacePrivateEndpointConnectionResource(eventGridPartnerNamespacePrivateEndpointConnectionResourceId); // invoke the operation - EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData() - { - ConnectionState = new EventGridPrivateEndpointConnectionState() - { - Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, - Description = "approving connection", - ActionsRequired = "None", - }, - }; - ArmOperation lro = await eventGridPartnerNamespacePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - EventGridPartnerNamespacePrivateEndpointConnectionResource result = lro.Value; + await eventGridPartnerNamespacePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDelete() + public async Task Update_PrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +96,23 @@ public async Task Delete_PrivateEndpointConnectionsDelete() EventGridPartnerNamespacePrivateEndpointConnectionResource eventGridPartnerNamespacePrivateEndpointConnection = client.GetEventGridPartnerNamespacePrivateEndpointConnectionResource(eventGridPartnerNamespacePrivateEndpointConnectionResourceId); // invoke the operation - await eventGridPartnerNamespacePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData + { + ConnectionState = new EventGridPrivateEndpointConnectionState + { + Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, + Description = "approving connection", + ActionsRequired = "None", + }, + }; + ArmOperation lro = await eventGridPartnerNamespacePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + EventGridPartnerNamespacePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicCollection.cs index 4b1e2472b61bf..2e55944681ce9 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_EventGridTopicCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TopicsGet() + public async Task CreateOrUpdate_TopicsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_Get.json - // this example is just showing the usage of "Topics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_CreateOrUpdate.json + // this example is just showing the usage of "Topics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,8 +41,27 @@ public async Task Get_TopicsGet() EventGridTopicCollection collection = resourceGroupResource.GetEventGridTopics(); // invoke the operation - string topicName = "exampletopic2"; - EventGridTopicResource result = await collection.GetAsync(topicName); + string topicName = "exampletopic1"; + EventGridTopicData data = new EventGridTopicData(new AzureLocation("westus2")) + { + PublicNetworkAccess = EventGridPublicNetworkAccess.Enabled, + InboundIPRules = {new EventGridInboundIPRule +{ +IPMask = "12.18.30.15", +Action = EventGridIPActionType.Allow, +}, new EventGridInboundIPRule +{ +IPMask = "12.18.176.1", +Action = EventGridIPActionType.Allow, +}}, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, topicName, data); + EventGridTopicResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +72,10 @@ public async Task Get_TopicsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TopicsGet() + public async Task CreateOrUpdate_TopicsCreateOrUpdateForAzureArc() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_Get.json - // this example is just showing the usage of "Topics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_CreateOrUpdateForAzureArc.json + // this example is just showing the usage of "Topics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +93,34 @@ public async Task Exists_TopicsGet() EventGridTopicCollection collection = resourceGroupResource.GetEventGridTopics(); // invoke the operation - string topicName = "exampletopic2"; - bool result = await collection.ExistsAsync(topicName); + string topicName = "exampletopic1"; + EventGridTopicData data = new EventGridTopicData(new AzureLocation("westus2")) + { + Kind = ResourceKind.AzureArc, + ExtendedLocation = new ExtendedLocation + { + Name = "/subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourcegroups/examplerg/providers/Microsoft.ExtendedLocation/CustomLocations/exampleCustomLocation", + }, + InputSchema = EventGridInputSchema.CloudEventSchemaV1_0, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, topicName, data); + EventGridTopicResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridTopicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TopicsGet() + public async Task Get_TopicsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_Get.json // this example is just showing the usage of "Topics_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +142,21 @@ public async Task GetIfExists_TopicsGet() // invoke the operation string topicName = "exampletopic2"; - NullableResponse response = await collection.GetIfExistsAsync(topicName); - EventGridTopicResource result = response.HasValue ? response.Value : null; + EventGridTopicResource result = await collection.GetAsync(topicName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridTopicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridTopicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TopicsCreateOrUpdate() + public async Task GetAll_TopicsListByResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_CreateOrUpdate.json - // this example is just showing the usage of "Topics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_ListByResourceGroup.json + // this example is just showing the usage of "Topics_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,45 +173,25 @@ public async Task CreateOrUpdate_TopicsCreateOrUpdate() // get the collection of this EventGridTopicResource EventGridTopicCollection collection = resourceGroupResource.GetEventGridTopics(); - // invoke the operation - string topicName = "exampletopic1"; - EventGridTopicData data = new EventGridTopicData(new AzureLocation("westus2")) + // invoke the operation and iterate over the result + await foreach (EventGridTopicResource item in collection.GetAllAsync()) { - PublicNetworkAccess = EventGridPublicNetworkAccess.Enabled, - InboundIPRules = -{ -new EventGridInboundIPRule() -{ -IPMask = "12.18.30.15", -Action = EventGridIPActionType.Allow, -},new EventGridInboundIPRule() -{ -IPMask = "12.18.176.1", -Action = EventGridIPActionType.Allow, -} -}, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, topicName, data); - EventGridTopicResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridTopicData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridTopicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TopicsCreateOrUpdateForAzureArc() + public async Task Exists_TopicsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_CreateOrUpdateForAzureArc.json - // this example is just showing the usage of "Topics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_Get.json + // this example is just showing the usage of "Topics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,37 +209,18 @@ public async Task CreateOrUpdate_TopicsCreateOrUpdateForAzureArc() EventGridTopicCollection collection = resourceGroupResource.GetEventGridTopics(); // invoke the operation - string topicName = "exampletopic1"; - EventGridTopicData data = new EventGridTopicData(new AzureLocation("westus2")) - { - Kind = ResourceKind.AzureArc, - ExtendedLocation = new ExtendedLocation() - { - Name = "/subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourcegroups/examplerg/providers/Microsoft.ExtendedLocation/CustomLocations/exampleCustomLocation", - }, - InputSchema = EventGridInputSchema.CloudEventSchemaV1_0, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, topicName, data); - EventGridTopicResource result = lro.Value; + string topicName = "exampletopic2"; + bool result = await collection.ExistsAsync(topicName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridTopicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TopicsListByResourceGroup() + public async Task GetIfExists_TopicsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_ListByResourceGroup.json - // this example is just showing the usage of "Topics_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_Get.json + // this example is just showing the usage of "Topics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -246,17 +237,23 @@ public async Task GetAll_TopicsListByResourceGroup() // get the collection of this EventGridTopicResource EventGridTopicCollection collection = resourceGroupResource.GetEventGridTopics(); - // invoke the operation and iterate over the result - await foreach (EventGridTopicResource item in collection.GetAllAsync()) + // invoke the operation + string topicName = "exampletopic2"; + NullableResponse response = await collection.GetIfExistsAsync(topicName); + EventGridTopicResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridTopicData resourceData = item.Data; + EventGridTopicData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateEndpointConnectionCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateEndpointConnectionCollection.cs index e01aaf290f4c8..daee8054932dc 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateEndpointConnectionCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EventGridTopicPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGet() + public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - EventGridTopicPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData + { + ConnectionState = new EventGridPrivateEndpointConnectionState + { + Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, + Description = "approving connection", + ActionsRequired = "None", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + EventGridTopicPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +62,7 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGet() + public async Task Get_PrivateEndpointConnectionsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +85,21 @@ public async Task Exists_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + EventGridTopicPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGet() + public async Task GetAll_PrivateEndpointConnectionsListByResource() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_ListByResource.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +117,25 @@ public async Task GetIfExists_PrivateEndpointConnectionsGet() // get the collection of this EventGridTopicPrivateEndpointConnectionResource EventGridTopicPrivateEndpointConnectionCollection collection = eventGridTopic.GetEventGridTopicPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - EventGridTopicPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EventGridTopicPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = result.Data; + EventGridPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() + public async Task Exists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,31 +155,17 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() // invoke the operation string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; - EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData() - { - ConnectionState = new EventGridPrivateEndpointConnectionState() - { - Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, - Description = "approving connection", - ActionsRequired = "None", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - EventGridTopicPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsListByResource() + public async Task GetIfExists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_ListByResource.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_PrivateEndpointConnectionsListByResource() // get the collection of this EventGridTopicPrivateEndpointConnectionResource EventGridTopicPrivateEndpointConnectionCollection collection = eventGridTopic.GetEventGridTopicPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (EventGridTopicPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "BMTPE5.8A30D251-4C61-489D-A1AA-B37C4A329B8B"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + EventGridTopicPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = item.Data; + EventGridPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateEndpointConnectionResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateEndpointConnectionResource.cs index b03978930ac21..67c8699c5f30c 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateEndpointConnectionResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsUpdate() + public async Task Delete_PrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,17 @@ public async Task Update_PrivateEndpointConnectionsUpdate() EventGridTopicPrivateEndpointConnectionResource eventGridTopicPrivateEndpointConnection = client.GetEventGridTopicPrivateEndpointConnectionResource(eventGridTopicPrivateEndpointConnectionResourceId); // invoke the operation - EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData() - { - ConnectionState = new EventGridPrivateEndpointConnectionState() - { - Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, - Description = "approving connection", - ActionsRequired = "None", - }, - }; - ArmOperation lro = await eventGridTopicPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - EventGridTopicPrivateEndpointConnectionResource result = lro.Value; + await eventGridTopicPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDelete() + public async Task Update_PrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateEndpointConnections_Update.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +96,23 @@ public async Task Delete_PrivateEndpointConnectionsDelete() EventGridTopicPrivateEndpointConnectionResource eventGridTopicPrivateEndpointConnection = client.GetEventGridTopicPrivateEndpointConnectionResource(eventGridTopicPrivateEndpointConnectionResourceId); // invoke the operation - await eventGridTopicPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + EventGridPrivateEndpointConnectionData data = new EventGridPrivateEndpointConnectionData + { + ConnectionState = new EventGridPrivateEndpointConnectionState + { + Status = EventGridPrivateEndpointPersistedConnectionStatus.Approved, + Description = "approving connection", + ActionsRequired = "None", + }, + }; + ArmOperation lro = await eventGridTopicPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + EventGridTopicPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateLinkResourceCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateLinkResourceCollection.cs index 05ca7e7ede019..9d82a0aa00ae0 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateLinkResourceCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicPrivateLinkResourceCollection.cs @@ -51,10 +51,10 @@ public async Task Get_PrivateLinkResourcesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateLinkResourcesGet() + public async Task GetAll_PrivateLinkResourcesListByResource() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_Get.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_ListByResource.json + // this example is just showing the usage of "PrivateLinkResources_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_PrivateLinkResourcesGet() // get the collection of this EventGridTopicPrivateLinkResource EventGridTopicPrivateLinkResourceCollection collection = eventGridTopic.GetEventGridTopicPrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "topic"; - bool result = await collection.ExistsAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (EventGridTopicPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateLinkResourcesGet() + public async Task Exists_PrivateLinkResourcesGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_Get.json // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_PrivateLinkResourcesGet() // invoke the operation string privateLinkResourceName = "topic"; - NullableResponse response = await collection.GetIfExistsAsync(privateLinkResourceName); - EventGridTopicPrivateLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateLinkResourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesListByResource() + public async Task GetIfExists_PrivateLinkResourcesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_ListByResource.json - // this example is just showing the usage of "PrivateLinkResources_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_Get.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_PrivateLinkResourcesListByResource() // get the collection of this EventGridTopicPrivateLinkResource EventGridTopicPrivateLinkResourceCollection collection = eventGridTopic.GetEventGridTopicPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (EventGridTopicPrivateLinkResource item in collection.GetAllAsync()) + // invoke the operation + string privateLinkResourceName = "topic"; + NullableResponse response = await collection.GetIfExistsAsync(privateLinkResourceName); + EventGridTopicPrivateLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridPrivateLinkResourceData resourceData = item.Data; + EventGridPrivateLinkResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicResource.cs index 8bc160f26d735..5182949d772e4 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventGridTopicResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EventGrid.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -94,63 +93,29 @@ public async Task Update_TopicsUpdate() EventGridTopicResource eventGridTopic = client.GetEventGridTopicResource(eventGridTopicResourceId); // invoke the operation - EventGridTopicPatch patch = new EventGridTopicPatch() + EventGridTopicPatch patch = new EventGridTopicPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, PublicNetworkAccess = EventGridPublicNetworkAccess.Enabled, - InboundIPRules = -{ -new EventGridInboundIPRule() + InboundIPRules = {new EventGridInboundIPRule { IPMask = "12.18.30.15", Action = EventGridIPActionType.Allow, -},new EventGridInboundIPRule() +}, new EventGridInboundIPRule { IPMask = "12.18.176.1", Action = EventGridIPActionType.Allow, -} -}, +}}, }; await eventGridTopic.UpdateAsync(WaitUntil.Completed, patch); Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEventGridTopics_TopicsListBySubscription() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_ListBySubscription.json - // this example is just showing the usage of "Topics_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (EventGridTopicResource item in subscriptionResource.GetEventGridTopicsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridTopicData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSharedAccessKeys_TopicsListSharedAccessKeys() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventSubscriptionCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventSubscriptionCollection.cs index e97c5ee9afaba..c6ea10c01354e 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventSubscriptionCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventSubscriptionCollection.cs @@ -18,27 +18,37 @@ public partial class Sample_EventSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForCustomTopic() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopic() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new EventHubEventSubscriptionDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace/eventhubs/EH1"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,93 +59,134 @@ public async Task Get_EventSubscriptionsGetForCustomTopic() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForCustomTopic() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicAzureFunctionDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_AzureFunctionDestination.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new AzureFunctionEventSubscriptionDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Web/sites/ContosoSite/funtions/ContosoFunc"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + DeadLetterDestination = new StorageBlobDeadLetterDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), + BlobContainerName = "contosocontainer", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForCustomTopic() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicEventHubDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_EventHubDestination.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + EventGridSubscriptionData data = new EventGridSubscriptionData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Destination = new EventHubEventSubscriptionDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace/eventhubs/EH1"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + DeadLetterDestination = new StorageBlobDeadLetterDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), + BlobContainerName = "contosocontainer", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForCustomTopicAzureFunctionDestination() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicHybridConnectionDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_AzureFunctionDestination.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_HybridConnectionDestination.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new HybridConnectionEventSubscriptionDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/d33c5f7a-02ea-40f4-bf52-07f17e84d6a8/resourceGroups/TestRG/providers/Microsoft.Relay/namespaces/ContosoNamespace/hybridConnections/HC1"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + DeadLetterDestination = new StorageBlobDeadLetterDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), + BlobContainerName = "contosocontainer", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -146,93 +197,136 @@ public async Task Get_EventSubscriptionsGetForCustomTopicAzureFunctionDestinatio [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForCustomTopicAzureFunctionDestination() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicServiceBusQueueDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_AzureFunctionDestination.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_ServiceBusQueueDestination.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new ServiceBusQueueEventSubscriptionDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.ServiceBus/namespaces/ContosoNamespace/queues/SBQ"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + DeadLetterDestination = new StorageBlobDeadLetterDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), + BlobContainerName = "contosocontainer", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForCustomTopicAzureFunctionDestination() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicServiceBusTopicDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_AzureFunctionDestination.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_ServiceBusTopicDestination.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + EventGridSubscriptionData data = new EventGridSubscriptionData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Destination = new ServiceBusTopicEventSubscriptionDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.ServiceBus/namespaces/ContosoNamespace/topics/SBT"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + DeadLetterDestination = new StorageBlobDeadLetterDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), + BlobContainerName = "contosocontainer", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForCustomTopicEventHubDestination() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicStorageQueueDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_EventHubDestination.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_StorageQueueDestination.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new StorageQueueEventSubscriptionDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/d33c5f7a-02ea-40f4-bf52-07f17e84d6a8/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), + QueueName = "queue1", + QueueMessageTimeToLiveInSeconds = 300L, + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + DeadLetterDestination = new StorageBlobDeadLetterDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), + BlobContainerName = "contosocontainer", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -243,93 +337,119 @@ public async Task Get_EventSubscriptionsGetForCustomTopicEventHubDestination() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForCustomTopicEventHubDestination() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicWebhookDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_EventHubDestination.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_WebhookDestination.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new EventHubEventSubscriptionDestination + { + ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace/eventhubs/EH1"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForCustomTopicEventHubDestination() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForResource() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_EventHubDestination.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForResource.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string eventSubscriptionName = "examplesubscription10"; + EventGridSubscriptionData data = new EventGridSubscriptionData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Destination = new WebHookEventSubscriptionDestination + { + Endpoint = new Uri("https://requestb.in/15ksip71"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForCustomTopicHybridConnectionDestination() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_HybridConnectionDestination.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForResourceGroup.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + string eventSubscriptionName = "examplesubscription2"; + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new WebHookEventSubscriptionDestination + { + Endpoint = new Uri("https://requestb.in/15ksip71"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -340,36 +460,48 @@ public async Task Get_EventSubscriptionsGetForCustomTopicHybridConnectionDestina [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForCustomTopicHybridConnectionDestination() + public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForSubscription() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_HybridConnectionDestination.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForSubscription.json + // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + string eventSubscriptionName = "examplesubscription3"; + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new WebHookEventSubscriptionDestination + { + Endpoint = new Uri("https://requestb.in/15ksip71"), + }, + Filter = new EventSubscriptionFilter + { + IsSubjectCaseSensitive = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + EventSubscriptionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForCustomTopicHybridConnectionDestination() + public async Task Get_EventSubscriptionsGetForCustomTopic() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_HybridConnectionDestination.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -377,38 +509,26 @@ public async Task GetIfExists_EventSubscriptionsGetForCustomTopicHybridConnectio // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; + EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForCustomTopicServiceBusQueueDestination() + public async Task Get_EventSubscriptionsGetForCustomTopicAzureFunctionDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusQueueDestination.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_AzureFunctionDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -416,13 +536,9 @@ public async Task Get_EventSubscriptionsGetForCustomTopicServiceBusQueueDestinat // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; @@ -437,9 +553,9 @@ public async Task Get_EventSubscriptionsGetForCustomTopicServiceBusQueueDestinat [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForCustomTopicServiceBusQueueDestination() + public async Task Get_EventSubscriptionsGetForCustomTopicEventHubDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusQueueDestination.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_EventHubDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -447,26 +563,26 @@ public async Task Exists_EventSubscriptionsGetForCustomTopicServiceBusQueueDesti // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForCustomTopicServiceBusQueueDestination() + public async Task Get_EventSubscriptionsGetForCustomTopicHybridConnectionDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusQueueDestination.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_HybridConnectionDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -474,38 +590,26 @@ public async Task GetIfExists_EventSubscriptionsGetForCustomTopicServiceBusQueue // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; + EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForCustomTopicServiceBusTopicDestination() + public async Task Get_EventSubscriptionsGetForCustomTopicServiceBusQueueDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusTopicDestination.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusQueueDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -513,13 +617,9 @@ public async Task Get_EventSubscriptionsGetForCustomTopicServiceBusTopicDestinat // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; @@ -534,7 +634,7 @@ public async Task Get_EventSubscriptionsGetForCustomTopicServiceBusTopicDestinat [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForCustomTopicServiceBusTopicDestination() + public async Task Get_EventSubscriptionsGetForCustomTopicServiceBusTopicDestination() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusTopicDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -544,26 +644,26 @@ public async Task Exists_EventSubscriptionsGetForCustomTopicServiceBusTopicDesti // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForCustomTopicServiceBusTopicDestination() + public async Task Get_EventSubscriptionsGetForCustomTopicStorageQueueDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusTopicDestination.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_StorageQueueDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -571,38 +671,26 @@ public async Task GetIfExists_EventSubscriptionsGetForCustomTopicServiceBusTopic // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; + EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForCustomTopicStorageQueueDestination() + public async Task Get_EventSubscriptionsGetForCustomTopicWebhookDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_StorageQueueDestination.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_WebhookDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -610,13 +698,9 @@ public async Task Get_EventSubscriptionsGetForCustomTopicStorageQueueDestination // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; @@ -631,9 +715,9 @@ public async Task Get_EventSubscriptionsGetForCustomTopicStorageQueueDestination [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForCustomTopicStorageQueueDestination() + public async Task Get_EventSubscriptionsGetForResource() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_StorageQueueDestination.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResource.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -641,26 +725,26 @@ public async Task Exists_EventSubscriptionsGetForCustomTopicStorageQueueDestinat // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForCustomTopicStorageQueueDestination() + public async Task Get_EventSubscriptionsGetForResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_StorageQueueDestination.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResourceGroup.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -668,38 +752,26 @@ public async Task GetIfExists_EventSubscriptionsGetForCustomTopicStorageQueueDes // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; + string eventSubscriptionName = "examplesubscription2"; + EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForCustomTopicWebhookDestination() + public async Task Get_EventSubscriptionsGetForSubscription() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_WebhookDestination.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForSubscription.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -707,16 +779,12 @@ public async Task Get_EventSubscriptionsGetForCustomTopicWebhookDestination() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; + string eventSubscriptionName = "examplesubscription3"; EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); // the variable result is a resource, you could call other operations on this instance as well @@ -728,106 +796,137 @@ public async Task Get_EventSubscriptionsGetForCustomTopicWebhookDestination() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForCustomTopicWebhookDestination() + public async Task GetAll_EventSubscriptionsListGlobalBySubscription() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_WebhookDestination.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_ListGlobalBySubscription.json + // this example is just showing the usage of "EventSubscriptions_ListGlobalBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + string scope = $"/subscriptions/{subscriptionId}"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); - // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + // invoke the operation and iterate over the result + await foreach (EventSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForCustomTopicWebhookDestination() + public async Task GetAll_EventSubscriptionsListGlobalByResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_WebhookDestination.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_ListGlobalByResourceGroup.json + // this example is just showing the usage of "EventSubscriptions_ListGlobalByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); - - // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + string resourceGroupName = "examplerg"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); - if (result == null) + // invoke the operation and iterate over the result + await foreach (EventSubscriptionResource item in collection.GetAllAsync()) { - Console.WriteLine("Succeeded with null as result"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - else + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_EventSubscriptionsListByResource() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_ListByResource.json + // this example is just showing the usage of "EventSubscriptions_ListByResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this EventSubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + string resourceGroupName = "examplerg"; + string providerNamespace = "Microsoft.EventGrid"; + string resourceTypeName = "topics"; + string resourceName = "exampletopic2"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{providerNamespace}/{resourceTypeName}/{resourceName}"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (EventSubscriptionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; + EventGridSubscriptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForResource() + public async Task GetAll_EventSubscriptionsListByDomainTopic() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResource.json - // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_ListByDomainTopic.json + // this example is just showing the usage of "EventSubscriptions_ListByDomainTopic" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + string resourceGroupName = "examplerg"; + string domainName = "domain1"; + string topicName = "topic1"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventGrid/domains/{domainName}/topics/{topicName}"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); - // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + // invoke the operation and iterate over the result + await foreach (EventSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForResource() + public async Task Exists_EventSubscriptionsGetForCustomTopic() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResource.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -835,13 +934,9 @@ public async Task Exists_EventSubscriptionsGetForResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; @@ -852,9 +947,9 @@ public async Task Exists_EventSubscriptionsGetForResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForResource() + public async Task Exists_EventSubscriptionsGetForCustomTopicAzureFunctionDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResource.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_AzureFunctionDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -862,38 +957,22 @@ public async Task GetIfExists_EventSubscriptionsGetForResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(eventSubscriptionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForResourceGroup() + public async Task Exists_EventSubscriptionsGetForCustomTopicEventHubDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResourceGroup.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_EventHubDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -901,30 +980,22 @@ public async Task Get_EventSubscriptionsGetForResourceGroup() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription2"; - EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + string eventSubscriptionName = "examplesubscription1"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForResourceGroup() + public async Task Exists_EventSubscriptionsGetForCustomTopicHybridConnectionDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResourceGroup.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_HybridConnectionDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -932,16 +1003,12 @@ public async Task Exists_EventSubscriptionsGetForResourceGroup() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription2"; + string eventSubscriptionName = "examplesubscription1"; bool result = await collection.ExistsAsync(eventSubscriptionName); Console.WriteLine($"Succeeded: {result}"); @@ -949,9 +1016,9 @@ public async Task Exists_EventSubscriptionsGetForResourceGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForResourceGroup() + public async Task Exists_EventSubscriptionsGetForCustomTopicServiceBusQueueDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResourceGroup.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusQueueDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -959,38 +1026,22 @@ public async Task GetIfExists_EventSubscriptionsGetForResourceGroup() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription2"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; + string eventSubscriptionName = "examplesubscription1"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventSubscriptionsGetForSubscription() + public async Task Exists_EventSubscriptionsGetForCustomTopicServiceBusTopicDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForSubscription.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusTopicDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -998,30 +1049,22 @@ public async Task Get_EventSubscriptionsGetForSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription3"; - EventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + string eventSubscriptionName = "examplesubscription1"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventSubscriptionsGetForSubscription() + public async Task Exists_EventSubscriptionsGetForCustomTopicStorageQueueDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForSubscription.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_StorageQueueDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1029,16 +1072,12 @@ public async Task Exists_EventSubscriptionsGetForSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription3"; + string eventSubscriptionName = "examplesubscription1"; bool result = await collection.ExistsAsync(eventSubscriptionName); Console.WriteLine($"Succeeded: {result}"); @@ -1046,9 +1085,9 @@ public async Task Exists_EventSubscriptionsGetForSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventSubscriptionsGetForSubscription() + public async Task Exists_EventSubscriptionsGetForCustomTopicWebhookDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForSubscription.json + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_WebhookDestination.json // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1056,696 +1095,469 @@ public async Task GetIfExists_EventSubscriptionsGetForSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription3"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - EventSubscriptionResource result = response.HasValue ? response.Value : null; + string eventSubscriptionName = "examplesubscription1"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopic() + public async Task Exists_EventSubscriptionsGetForResource() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResource.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new EventHubEventSubscriptionDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace/eventhubs/EH1"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicAzureFunctionDestination() + public async Task Exists_EventSubscriptionsGetForResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_AzureFunctionDestination.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResourceGroup.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new AzureFunctionEventSubscriptionDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Web/sites/ContosoSite/funtions/ContosoFunc"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - DeadLetterDestination = new StorageBlobDeadLetterDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), - BlobContainerName = "contosocontainer", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplesubscription2"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicEventHubDestination() + public async Task Exists_EventSubscriptionsGetForSubscription() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_EventHubDestination.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForSubscription.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new EventHubEventSubscriptionDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace/eventhubs/EH1"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - DeadLetterDestination = new StorageBlobDeadLetterDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), - BlobContainerName = "contosocontainer", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplesubscription3"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicHybridConnectionDestination() + public async Task GetIfExists_EventSubscriptionsGetForCustomTopic() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_HybridConnectionDestination.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new HybridConnectionEventSubscriptionDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/d33c5f7a-02ea-40f4-bf52-07f17e84d6a8/resourceGroups/TestRG/providers/Microsoft.Relay/namespaces/ContosoNamespace/hybridConnections/HC1"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - DeadLetterDestination = new StorageBlobDeadLetterDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), - BlobContainerName = "contosocontainer", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicServiceBusQueueDestination() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_ServiceBusQueueDestination.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; - // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() + if (result == null) { - Destination = new ServiceBusQueueEventSubscriptionDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.ServiceBus/namespaces/ContosoNamespace/queues/SBQ"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - DeadLetterDestination = new StorageBlobDeadLetterDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), - BlobContainerName = "contosocontainer", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicServiceBusTopicDestination() + public async Task GetIfExists_EventSubscriptionsGetForCustomTopicAzureFunctionDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_ServiceBusTopicDestination.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_AzureFunctionDestination.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new ServiceBusTopicEventSubscriptionDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.ServiceBus/namespaces/ContosoNamespace/topics/SBT"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - DeadLetterDestination = new StorageBlobDeadLetterDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), - BlobContainerName = "contosocontainer", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicStorageQueueDestination() + public async Task GetIfExists_EventSubscriptionsGetForCustomTopicEventHubDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_StorageQueueDestination.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_EventHubDestination.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation string eventSubscriptionName = "examplesubscription1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new StorageQueueEventSubscriptionDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/d33c5f7a-02ea-40f4-bf52-07f17e84d6a8/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), - QueueName = "queue1", - QueueMessageTimeToLiveInSeconds = 300L, - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - DeadLetterDestination = new StorageBlobDeadLetterDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), - BlobContainerName = "contosocontainer", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForCustomTopicWebhookDestination() + public async Task GetIfExists_EventSubscriptionsGetForCustomTopicHybridConnectionDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForCustomTopic_WebhookDestination.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_HybridConnectionDestination.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new EventHubEventSubscriptionDestination() - { - ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace/eventhubs/EH1"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForResource() + public async Task GetIfExists_EventSubscriptionsGetForCustomTopicServiceBusQueueDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForResource.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusQueueDestination.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription10"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new WebHookEventSubscriptionDestination() - { - Endpoint = new Uri("https://requestb.in/15ksip71"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForResourceGroup() + public async Task GetIfExists_EventSubscriptionsGetForCustomTopicServiceBusTopicDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForResourceGroup.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_ServiceBusTopicDestination.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription2"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new WebHookEventSubscriptionDestination() - { - Endpoint = new Uri("https://requestb.in/15ksip71"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventSubscriptionsCreateOrUpdateForSubscription() + public async Task GetIfExists_EventSubscriptionsGetForCustomTopicStorageQueueDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_CreateOrUpdateForSubscription.json - // this example is just showing the usage of "EventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_StorageQueueDestination.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); // invoke the operation - string eventSubscriptionName = "examplesubscription3"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new WebHookEventSubscriptionDestination() - { - Endpoint = new Uri("https://requestb.in/15ksip71"), - }, - Filter = new EventSubscriptionFilter() - { - IsSubjectCaseSensitive = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - EventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EventSubscriptionsListGlobalBySubscription() + public async Task GetIfExists_EventSubscriptionsGetForCustomTopicWebhookDestination() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_ListGlobalBySubscription.json - // this example is just showing the usage of "EventSubscriptions_ListGlobalBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForCustomTopic_WebhookDestination.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}", subscriptionId)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (EventSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = item.Data; + EventGridSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EventSubscriptionsListGlobalByResourceGroup() + public async Task GetIfExists_EventSubscriptionsGetForResource() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_ListGlobalByResourceGroup.json - // this example is just showing the usage of "EventSubscriptions_ListGlobalByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResource.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - string resourceGroupName = "examplerg"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}", subscriptionId, resourceGroupName)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventHub/namespaces/examplenamespace1"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (EventSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = item.Data; + EventGridSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EventSubscriptionsListByResource() + public async Task GetIfExists_EventSubscriptionsGetForResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_ListByResource.json - // this example is just showing the usage of "EventSubscriptions_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForResourceGroup.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - string resourceGroupName = "examplerg"; - string providerNamespace = "Microsoft.EventGrid"; - string resourceTypeName = "topics"; - string resourceName = "exampletopic2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/{2}/{3}/{4}", subscriptionId, resourceGroupName, providerNamespace, resourceTypeName, resourceName)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (EventSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string eventSubscriptionName = "examplesubscription2"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = item.Data; + EventGridSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EventSubscriptionsListByDomainTopic() + public async Task GetIfExists_EventSubscriptionsGetForSubscription() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_ListByDomainTopic.json - // this example is just showing the usage of "EventSubscriptions_ListByDomainTopic" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetForSubscription.json + // this example is just showing the usage of "EventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EventSubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - string resourceGroupName = "examplerg"; - string domainName = "domain1"; - string topicName = "topic1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.EventGrid/domains/{2}/topics/{3}", subscriptionId, resourceGroupName, domainName, topicName)); - EventSubscriptionCollection collection = client.GetEventSubscriptions(scopeId); + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + EventSubscriptionCollection collection = client.GetEventSubscriptions(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (EventSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string eventSubscriptionName = "examplesubscription3"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + EventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = item.Data; + EventGridSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventSubscriptionResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventSubscriptionResource.cs index d56611383a679..6f59089634287 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventSubscriptionResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_EventSubscriptionResource.cs @@ -16,34 +16,6 @@ namespace Azure.ResourceManager.EventGrid.Samples { public partial class Sample_EventSubscriptionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeliveryAttributes_EventSubscriptionsGetDeliveryAttributes() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetDeliveryAttributes.json - // this example is just showing the usage of "EventSubscriptions_GetDeliveryAttributes" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this EventSubscriptionResource created on azure - // for more information of creating EventSubscriptionResource, please refer to the document of EventSubscriptionResource - string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; - string eventSubscriptionName = "examplesubscription1"; - ResourceIdentifier eventSubscriptionResourceId = EventSubscriptionResource.CreateResourceIdentifier(scope, eventSubscriptionName); - EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeliveryAttributeMapping item in eventSubscription.GetDeliveryAttributesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_EventSubscriptionsGetForCustomTopic() @@ -483,22 +455,19 @@ public async Task Update_EventSubscriptionsUpdateForCustomTopic() EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new WebHookEventSubscriptionDestination() + Destination = new WebHookEventSubscriptionDestination { Endpoint = new Uri("https://requestb.in/15ksip71"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await eventSubscription.UpdateAsync(WaitUntil.Completed, patch); EventSubscriptionResource result = lro.Value; @@ -530,19 +499,19 @@ public async Task Update_EventSubscriptionsUpdateForCustomTopicAzureFunctionDest EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new AzureFunctionEventSubscriptionDestination() + Destination = new AzureFunctionEventSubscriptionDestination { ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Web/sites/ContosoSite/funtions/ContosoFunc"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "ExamplePrefix", SubjectEndsWith = "ExampleSuffix", IsSubjectCaseSensitive = false, }, - DeadLetterDestination = new StorageBlobDeadLetterDestination() + DeadLetterDestination = new StorageBlobDeadLetterDestination { ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), BlobContainerName = "contosocontainer", @@ -578,22 +547,19 @@ public async Task Update_EventSubscriptionsUpdateForCustomTopicEventHubDestinati EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new EventHubEventSubscriptionDestination() + Destination = new EventHubEventSubscriptionDestination { ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace/eventhubs/EH1"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await eventSubscription.UpdateAsync(WaitUntil.Completed, patch); EventSubscriptionResource result = lro.Value; @@ -625,22 +591,19 @@ public async Task Update_EventSubscriptionsUpdateForCustomTopicHybridConnectionD EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new HybridConnectionEventSubscriptionDestination() + Destination = new HybridConnectionEventSubscriptionDestination { ResourceId = new ResourceIdentifier("/subscriptions/d33c5f7a-02ea-40f4-bf52-07f17e84d6a8/resourceGroups/TestRG/providers/Microsoft.Relay/namespaces/ContosoNamespace/hybridConnections/HC1"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await eventSubscription.UpdateAsync(WaitUntil.Completed, patch); EventSubscriptionResource result = lro.Value; @@ -672,19 +635,19 @@ public async Task Update_EventSubscriptionsUpdateForCustomTopicServiceBusQueueDe EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new ServiceBusQueueEventSubscriptionDestination() + Destination = new ServiceBusQueueEventSubscriptionDestination { ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.ServiceBus/namespaces/ContosoNamespace/queues/SBQ"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "ExamplePrefix", SubjectEndsWith = "ExampleSuffix", IsSubjectCaseSensitive = false, }, - DeadLetterDestination = new StorageBlobDeadLetterDestination() + DeadLetterDestination = new StorageBlobDeadLetterDestination { ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), BlobContainerName = "contosocontainer", @@ -720,22 +683,19 @@ public async Task Update_EventSubscriptionsUpdateForCustomTopicServiceBusTopicDe EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new ServiceBusTopicEventSubscriptionDestination() + Destination = new ServiceBusTopicEventSubscriptionDestination { ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.ServiceBus/namespaces/ContosoNamespace/topics/SBT"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await eventSubscription.UpdateAsync(WaitUntil.Completed, patch); EventSubscriptionResource result = lro.Value; @@ -767,21 +727,21 @@ public async Task Update_EventSubscriptionsUpdateForCustomTopicStorageQueueDesti EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new StorageQueueEventSubscriptionDestination() + Destination = new StorageQueueEventSubscriptionDestination { ResourceId = new ResourceIdentifier("/subscriptions/d33c5f7a-02ea-40f4-bf52-07f17e84d6a8/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), QueueName = "queue1", QueueMessageTimeToLiveInSeconds = 300L, }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "ExamplePrefix", SubjectEndsWith = "ExampleSuffix", IsSubjectCaseSensitive = false, }, - DeadLetterDestination = new StorageBlobDeadLetterDestination() + DeadLetterDestination = new StorageBlobDeadLetterDestination { ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.Storage/storageAccounts/contosostg"), BlobContainerName = "contosocontainer", @@ -817,22 +777,19 @@ public async Task Update_EventSubscriptionsUpdateForCustomTopicWebhookDestinatio EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new WebHookEventSubscriptionDestination() + Destination = new WebHookEventSubscriptionDestination { Endpoint = new Uri("https://requestb.in/15ksip71"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await eventSubscription.UpdateAsync(WaitUntil.Completed, patch); EventSubscriptionResource result = lro.Value; @@ -864,22 +821,19 @@ public async Task Update_EventSubscriptionsUpdateForResource() EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new WebHookEventSubscriptionDestination() + Destination = new WebHookEventSubscriptionDestination { Endpoint = new Uri("https://requestb.in/15ksip71"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await eventSubscription.UpdateAsync(WaitUntil.Completed, patch); EventSubscriptionResource result = lro.Value; @@ -911,22 +865,19 @@ public async Task Update_EventSubscriptionsUpdateForResourceGroup() EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new EventHubEventSubscriptionDestination() + Destination = new EventHubEventSubscriptionDestination { ResourceId = new ResourceIdentifier("/subscriptions/55f3dcd4-cac7-43b4-990b-a139d62a1eb2/resourceGroups/TestRG/providers/Microsoft.EventHub/namespaces/ContosoNamespace/eventhubs/EH1"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await eventSubscription.UpdateAsync(WaitUntil.Completed, patch); EventSubscriptionResource result = lro.Value; @@ -958,22 +909,19 @@ public async Task Update_EventSubscriptionsUpdateForSubscription() EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new WebHookEventSubscriptionDestination() + Destination = new WebHookEventSubscriptionDestination { Endpoint = new Uri("https://requestb.in/15ksip71"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await eventSubscription.UpdateAsync(WaitUntil.Completed, patch); EventSubscriptionResource result = lro.Value; @@ -985,6 +933,34 @@ public async Task Update_EventSubscriptionsUpdateForSubscription() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeliveryAttributes_EventSubscriptionsGetDeliveryAttributes() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/EventSubscriptions_GetDeliveryAttributes.json + // this example is just showing the usage of "EventSubscriptions_GetDeliveryAttributes" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EventSubscriptionResource created on azure + // for more information of creating EventSubscriptionResource, please refer to the document of EventSubscriptionResource + string scope = "subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/topics/exampletopic2"; + string eventSubscriptionName = "examplesubscription1"; + ResourceIdentifier eventSubscriptionResourceId = EventSubscriptionResource.CreateResourceIdentifier(scope, eventSubscriptionName); + EventSubscriptionResource eventSubscription = client.GetEventSubscriptionResource(eventSubscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeliveryAttributeMapping item in eventSubscription.GetDeliveryAttributesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetFullUri_EventSubscriptionsGetFullUrlForCustomTopic() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicCollection.cs index b1bef4eafa945..978addb04fa07 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NamespaceTopicCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NamespaceTopicsGet() + public async Task CreateOrUpdate_NamespaceTopicsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopics_Get.json - // this example is just showing the usage of "NamespaceTopics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopics_CreateOrUpdate.json + // this example is just showing the usage of "NamespaceTopics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task Get_NamespaceTopicsGet() // this example assumes you already have this EventGridNamespaceResource created on azure // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e41"; + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; string namespaceName = "examplenamespace2"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); @@ -41,7 +41,14 @@ public async Task Get_NamespaceTopicsGet() // invoke the operation string topicName = "examplenamespacetopic2"; - NamespaceTopicResource result = await collection.GetAsync(topicName); + NamespaceTopicData data = new NamespaceTopicData + { + PublisherType = PublisherType.Custom, + InputSchema = EventInputSchema.CloudEventSchemaV10, + EventRetentionInDays = 1, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, topicName, data); + NamespaceTopicResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +59,7 @@ public async Task Get_NamespaceTopicsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NamespaceTopicsGet() + public async Task Get_NamespaceTopicsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopics_Get.json // this example is just showing the usage of "NamespaceTopics_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +82,21 @@ public async Task Exists_NamespaceTopicsGet() // invoke the operation string topicName = "examplenamespacetopic2"; - bool result = await collection.ExistsAsync(topicName); + NamespaceTopicResource result = await collection.GetAsync(topicName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NamespaceTopicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NamespaceTopicsGet() + public async Task GetAll_NamespaceTopicsListByNamespace() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopics_Get.json - // this example is just showing the usage of "NamespaceTopics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopics_ListByNamespace.json + // this example is just showing the usage of "NamespaceTopics_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,7 +105,7 @@ public async Task GetIfExists_NamespaceTopicsGet() // this example assumes you already have this EventGridNamespaceResource created on azure // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e41"; + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; string namespaceName = "examplenamespace2"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); @@ -103,31 +114,25 @@ public async Task GetIfExists_NamespaceTopicsGet() // get the collection of this NamespaceTopicResource NamespaceTopicCollection collection = eventGridNamespace.GetNamespaceTopics(); - // invoke the operation - string topicName = "examplenamespacetopic2"; - NullableResponse response = await collection.GetIfExistsAsync(topicName); - NamespaceTopicResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NamespaceTopicResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NamespaceTopicData resourceData = result.Data; + NamespaceTopicData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NamespaceTopicsCreateOrUpdate() + public async Task Exists_NamespaceTopicsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopics_CreateOrUpdate.json - // this example is just showing the usage of "NamespaceTopics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopics_Get.json + // this example is just showing the usage of "NamespaceTopics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,7 +141,7 @@ public async Task CreateOrUpdate_NamespaceTopicsCreateOrUpdate() // this example assumes you already have this EventGridNamespaceResource created on azure // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e41"; string resourceGroupName = "examplerg"; string namespaceName = "examplenamespace2"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); @@ -147,28 +152,17 @@ public async Task CreateOrUpdate_NamespaceTopicsCreateOrUpdate() // invoke the operation string topicName = "examplenamespacetopic2"; - NamespaceTopicData data = new NamespaceTopicData() - { - PublisherType = PublisherType.Custom, - InputSchema = EventInputSchema.CloudEventSchemaV10, - EventRetentionInDays = 1, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, topicName, data); - NamespaceTopicResource result = lro.Value; + bool result = await collection.ExistsAsync(topicName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NamespaceTopicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NamespaceTopicsListByNamespace() + public async Task GetIfExists_NamespaceTopicsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopics_ListByNamespace.json - // this example is just showing the usage of "NamespaceTopics_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopics_Get.json + // this example is just showing the usage of "NamespaceTopics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,7 +171,7 @@ public async Task GetAll_NamespaceTopicsListByNamespace() // this example assumes you already have this EventGridNamespaceResource created on azure // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e41"; string resourceGroupName = "examplerg"; string namespaceName = "examplenamespace2"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); @@ -186,17 +180,23 @@ public async Task GetAll_NamespaceTopicsListByNamespace() // get the collection of this NamespaceTopicResource NamespaceTopicCollection collection = eventGridNamespace.GetNamespaceTopics(); - // invoke the operation and iterate over the result - await foreach (NamespaceTopicResource item in collection.GetAllAsync()) + // invoke the operation + string topicName = "examplenamespacetopic2"; + NullableResponse response = await collection.GetIfExistsAsync(topicName); + NamespaceTopicResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NamespaceTopicData resourceData = item.Data; + NamespaceTopicData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicEventSubscriptionCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicEventSubscriptionCollection.cs index ad7e63408c939..4e3641faae0b2 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicEventSubscriptionCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicEventSubscriptionCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NamespaceTopicEventSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NamespaceTopicEventSubscriptionsGet() + public async Task CreateOrUpdate_NamespaceTopicEventSubscriptionsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopicEventSubscriptions_Get.json - // this example is just showing the usage of "NamespaceTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopicEventSubscriptions_CreateOrUpdate.json + // this example is just showing the usage of "NamespaceTopicEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,8 +42,23 @@ public async Task Get_NamespaceTopicEventSubscriptionsGet() NamespaceTopicEventSubscriptionCollection collection = namespaceTopic.GetNamespaceTopicEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "examplenamespacetopicEventSub1"; - NamespaceTopicEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + string eventSubscriptionName = "examplenamespacetopicEventSub2"; + NamespaceTopicEventSubscriptionData data = new NamespaceTopicEventSubscriptionData + { + DeliveryConfiguration = new DeliveryConfiguration + { + DeliveryMode = DeliveryMode.Queue, + Queue = new QueueInfo + { + ReceiveLockDurationInSeconds = 60, + MaxDeliveryCount = 4, + EventTimeToLive = XmlConvert.ToTimeSpan("P1D"), + }, + }, + EventDeliverySchema = DeliverySchema.CloudEventSchemaV10, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + NamespaceTopicEventSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,7 +69,7 @@ public async Task Get_NamespaceTopicEventSubscriptionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NamespaceTopicEventSubscriptionsGet() + public async Task Get_NamespaceTopicEventSubscriptionsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopicEventSubscriptions_Get.json // this example is just showing the usage of "NamespaceTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -78,17 +93,21 @@ public async Task Exists_NamespaceTopicEventSubscriptionsGet() // invoke the operation string eventSubscriptionName = "examplenamespacetopicEventSub1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + NamespaceTopicEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NamespaceTopicEventSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NamespaceTopicEventSubscriptionsGet() + public async Task GetAll_NamespaceTopicEventSubscriptionsListByNamespaceTopic() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopicEventSubscriptions_Get.json - // this example is just showing the usage of "NamespaceTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopicEventSubscriptions_ListByNamespaceTopic.json + // this example is just showing the usage of "NamespaceTopicEventSubscriptions_ListByNamespaceTopic" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,31 +126,25 @@ public async Task GetIfExists_NamespaceTopicEventSubscriptionsGet() // get the collection of this NamespaceTopicEventSubscriptionResource NamespaceTopicEventSubscriptionCollection collection = namespaceTopic.GetNamespaceTopicEventSubscriptions(); - // invoke the operation - string eventSubscriptionName = "examplenamespacetopicEventSub1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - NamespaceTopicEventSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NamespaceTopicEventSubscriptionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NamespaceTopicEventSubscriptionData resourceData = result.Data; + NamespaceTopicEventSubscriptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NamespaceTopicEventSubscriptionsCreateOrUpdate() + public async Task Exists_NamespaceTopicEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopicEventSubscriptions_CreateOrUpdate.json - // this example is just showing the usage of "NamespaceTopicEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopicEventSubscriptions_Get.json + // this example is just showing the usage of "NamespaceTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,37 +164,18 @@ public async Task CreateOrUpdate_NamespaceTopicEventSubscriptionsCreateOrUpdate( NamespaceTopicEventSubscriptionCollection collection = namespaceTopic.GetNamespaceTopicEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "examplenamespacetopicEventSub2"; - NamespaceTopicEventSubscriptionData data = new NamespaceTopicEventSubscriptionData() - { - DeliveryConfiguration = new DeliveryConfiguration() - { - DeliveryMode = DeliveryMode.Queue, - Queue = new QueueInfo() - { - ReceiveLockDurationInSeconds = 60, - MaxDeliveryCount = 4, - EventTimeToLive = XmlConvert.ToTimeSpan("P1D"), - }, - }, - EventDeliverySchema = DeliverySchema.CloudEventSchemaV10, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - NamespaceTopicEventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplenamespacetopicEventSub1"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NamespaceTopicEventSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NamespaceTopicEventSubscriptionsListByNamespaceTopic() + public async Task GetIfExists_NamespaceTopicEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopicEventSubscriptions_ListByNamespaceTopic.json - // this example is just showing the usage of "NamespaceTopicEventSubscriptions_ListByNamespaceTopic" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NamespaceTopicEventSubscriptions_Get.json + // this example is just showing the usage of "NamespaceTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -200,17 +194,23 @@ public async Task GetAll_NamespaceTopicEventSubscriptionsListByNamespaceTopic() // get the collection of this NamespaceTopicEventSubscriptionResource NamespaceTopicEventSubscriptionCollection collection = namespaceTopic.GetNamespaceTopicEventSubscriptions(); - // invoke the operation and iterate over the result - await foreach (NamespaceTopicEventSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string eventSubscriptionName = "examplenamespacetopicEventSub1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + NamespaceTopicEventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NamespaceTopicEventSubscriptionData resourceData = item.Data; + NamespaceTopicEventSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicEventSubscriptionResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicEventSubscriptionResource.cs index 8f8f25cf6e07d..6da768a13c046 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicEventSubscriptionResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicEventSubscriptionResource.cs @@ -100,12 +100,12 @@ public async Task Update_NamespaceTopicEventSubscriptionsUpdate() NamespaceTopicEventSubscriptionResource namespaceTopicEventSubscription = client.GetNamespaceTopicEventSubscriptionResource(namespaceTopicEventSubscriptionResourceId); // invoke the operation - NamespaceTopicEventSubscriptionPatch patch = new NamespaceTopicEventSubscriptionPatch() + NamespaceTopicEventSubscriptionPatch patch = new NamespaceTopicEventSubscriptionPatch { - DeliveryConfiguration = new DeliveryConfiguration() + DeliveryConfiguration = new DeliveryConfiguration { DeliveryMode = DeliveryMode.Queue, - Queue = new QueueInfo() + Queue = new QueueInfo { ReceiveLockDurationInSeconds = 60, MaxDeliveryCount = 3, diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicResource.cs index 2c3bc816b8ba6..55de337edda35 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_NamespaceTopicResource.cs @@ -96,7 +96,7 @@ public async Task Update_NamespaceTopicsUpdate() NamespaceTopicResource namespaceTopic = client.GetNamespaceTopicResource(namespaceTopicResourceId); // invoke the operation - NamespaceTopicPatch patch = new NamespaceTopicPatch() + NamespaceTopicPatch patch = new NamespaceTopicPatch { EventRetentionInDays = 1, }; diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerConfigurationResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerConfigurationResource.cs index 771f6cccc6df0..b8dfd8c8c7430 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerConfigurationResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerConfigurationResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EventGrid.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -46,57 +45,6 @@ public async Task Get_PartnerConfigurationsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PartnerConfigurationsCreateOrUpdate() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerConfigurations_CreateOrUpdate.json - // this example is just showing the usage of "PartnerConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PartnerConfigurationResource created on azure - // for more information of creating PartnerConfigurationResource, please refer to the document of PartnerConfigurationResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - string resourceGroupName = "examplerg"; - ResourceIdentifier partnerConfigurationResourceId = PartnerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - PartnerConfigurationResource partnerConfiguration = client.GetPartnerConfigurationResource(partnerConfigurationResourceId); - - // invoke the operation - PartnerConfigurationData data = new PartnerConfigurationData(new AzureLocation("placeholder")) - { - PartnerAuthorization = new PartnerAuthorization() - { - DefaultMaximumExpirationTimeInDays = 10, - AuthorizedPartnersList = -{ -new EventGridPartnerContent() -{ -PartnerRegistrationImmutableId = Guid.Parse("941892bc-f5d0-4d1c-8fb5-477570fc2b71"), -PartnerName = "Contoso.Finance", -AuthorizationExpireOn = DateTimeOffset.Parse("2022-01-28T01:20:55.142Z"), -},new EventGridPartnerContent() -{ -PartnerRegistrationImmutableId = Guid.Parse("5362bdb6-ce3e-4d0d-9a5b-3eb92c8aab38"), -PartnerName = "fabrikam.HR", -AuthorizationExpireOn = DateTimeOffset.Parse("2022-02-20T01:00:00.142Z"), -} -}, - }, - }; - ArmOperation lro = await partnerConfiguration.CreateOrUpdateAsync(WaitUntil.Completed, data); - PartnerConfigurationResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Delete_PartnerConfigurationsDelete() @@ -142,12 +90,12 @@ public async Task Update_PartnerConfigurationsUpdate() PartnerConfigurationResource partnerConfiguration = client.GetPartnerConfigurationResource(partnerConfigurationResourceId); // invoke the operation - PartnerConfigurationPatch patch = new PartnerConfigurationPatch() + PartnerConfigurationPatch patch = new PartnerConfigurationPatch { Tags = { ["tag1"] = "value11", -["tag2"] = "value22", +["tag2"] = "value22" }, DefaultMaximumExpirationTimeInDays = 100, }; @@ -163,33 +111,50 @@ public async Task Update_PartnerConfigurationsUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetPartnerConfigurations_PartnerConfigurationsListBySubscription() + public async Task CreateOrUpdate_PartnerConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerConfigurations_ListBySubscription.json - // this example is just showing the usage of "PartnerConfigurations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerConfigurations_CreateOrUpdate.json + // this example is just showing the usage of "PartnerConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this PartnerConfigurationResource created on azure + // for more information of creating PartnerConfigurationResource, please refer to the document of PartnerConfigurationResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "examplerg"; + ResourceIdentifier partnerConfigurationResourceId = PartnerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + PartnerConfigurationResource partnerConfiguration = client.GetPartnerConfigurationResource(partnerConfigurationResourceId); - // invoke the operation and iterate over the result - await foreach (PartnerConfigurationResource item in subscriptionResource.GetPartnerConfigurationsAsync()) + // invoke the operation + PartnerConfigurationData data = new PartnerConfigurationData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PartnerAuthorization = new PartnerAuthorization + { + DefaultMaximumExpirationTimeInDays = 10, + AuthorizedPartnersList = {new EventGridPartnerContent +{ +PartnerRegistrationImmutableId = Guid.Parse("941892bc-f5d0-4d1c-8fb5-477570fc2b71"), +PartnerName = "Contoso.Finance", +AuthorizationExpireOn = DateTimeOffset.Parse("2022-01-28T01:20:55.142Z"), +}, new EventGridPartnerContent +{ +PartnerRegistrationImmutableId = Guid.Parse("5362bdb6-ce3e-4d0d-9a5b-3eb92c8aab38"), +PartnerName = "fabrikam.HR", +AuthorizationExpireOn = DateTimeOffset.Parse("2022-02-20T01:00:00.142Z"), +}}, + }, + }; + ArmOperation lro = await partnerConfiguration.CreateOrUpdateAsync(WaitUntil.Completed, data); + PartnerConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -212,7 +177,7 @@ public async Task AuthorizePartner_PartnerConfigurationsAuthorizePartner() PartnerConfigurationResource partnerConfiguration = client.GetPartnerConfigurationResource(partnerConfigurationResourceId); // invoke the operation - EventGridPartnerContent content = new EventGridPartnerContent() + EventGridPartnerContent content = new EventGridPartnerContent { PartnerRegistrationImmutableId = Guid.Parse("941892bc-f5d0-4d1c-8fb5-477570fc2b71"), PartnerName = "Contoso.Finance", @@ -247,7 +212,7 @@ public async Task UnauthorizePartner_PartnerConfigurationsUnauthorizePartner() PartnerConfigurationResource partnerConfiguration = client.GetPartnerConfigurationResource(partnerConfigurationResourceId); // invoke the operation - EventGridPartnerContent content = new EventGridPartnerContent() + EventGridPartnerContent content = new EventGridPartnerContent { PartnerRegistrationImmutableId = Guid.Parse("941892bc-f5d0-4d1c-8fb5-477570fc2b71"), PartnerName = "Contoso.Finance", diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerDestinationCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerDestinationCollection.cs index 1b505a5ef51c1..81692c34d057d 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerDestinationCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerDestinationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PartnerDestinationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PartnerDestinationsGet() + public async Task CreateOrUpdate_PartnerDestinationsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_Get.json - // this example is just showing the usage of "PartnerDestinations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_CreateOrUpdate.json + // this example is just showing the usage of "PartnerDestinations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,16 @@ public async Task Get_PartnerDestinationsGet() // invoke the operation string partnerDestinationName = "examplePartnerDestinationName1"; - PartnerDestinationResource result = await collection.GetAsync(partnerDestinationName); + PartnerDestinationData data = new PartnerDestinationData(new AzureLocation("westus2")) + { + PartnerRegistrationImmutableId = Guid.Parse("0bd70ee2-7d95-447e-ab1f-c4f320019404"), + EndpointServiceContext = "This is an example", + ExpirationTimeIfNotActivatedUtc = DateTimeOffset.Parse("2022-03-14T19:33:43.430Z"), + EndpointBaseUri = new Uri("https://www.example/endpoint"), + MessageForActivation = "Sample Activation message", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerDestinationName, data); + PartnerDestinationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +60,7 @@ public async Task Get_PartnerDestinationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PartnerDestinationsGet() + public async Task Get_PartnerDestinationsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_Get.json // this example is just showing the usage of "PartnerDestinations_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +82,21 @@ public async Task Exists_PartnerDestinationsGet() // invoke the operation string partnerDestinationName = "examplePartnerDestinationName1"; - bool result = await collection.ExistsAsync(partnerDestinationName); + PartnerDestinationResource result = await collection.GetAsync(partnerDestinationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerDestinationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PartnerDestinationsGet() + public async Task GetAll_PartnerDestinationsListByResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_Get.json - // this example is just showing the usage of "PartnerDestinations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_ListByResourceGroup.json + // this example is just showing the usage of "PartnerDestinations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +113,25 @@ public async Task GetIfExists_PartnerDestinationsGet() // get the collection of this PartnerDestinationResource PartnerDestinationCollection collection = resourceGroupResource.GetPartnerDestinations(); - // invoke the operation - string partnerDestinationName = "examplePartnerDestinationName1"; - NullableResponse response = await collection.GetIfExistsAsync(partnerDestinationName); - PartnerDestinationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PartnerDestinationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerDestinationData resourceData = result.Data; + PartnerDestinationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PartnerDestinationsCreateOrUpdate() + public async Task Exists_PartnerDestinationsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_CreateOrUpdate.json - // this example is just showing the usage of "PartnerDestinations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_Get.json + // this example is just showing the usage of "PartnerDestinations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,30 +150,17 @@ public async Task CreateOrUpdate_PartnerDestinationsCreateOrUpdate() // invoke the operation string partnerDestinationName = "examplePartnerDestinationName1"; - PartnerDestinationData data = new PartnerDestinationData(new AzureLocation("westus2")) - { - PartnerRegistrationImmutableId = Guid.Parse("0bd70ee2-7d95-447e-ab1f-c4f320019404"), - EndpointServiceContext = "This is an example", - ExpirationTimeIfNotActivatedUtc = DateTimeOffset.Parse("2022-03-14T19:33:43.430Z"), - EndpointBaseUri = new Uri("https://www.example/endpoint"), - MessageForActivation = "Sample Activation message", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerDestinationName, data); - PartnerDestinationResource result = lro.Value; + bool result = await collection.ExistsAsync(partnerDestinationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerDestinationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PartnerDestinationsListByResourceGroup() + public async Task GetIfExists_PartnerDestinationsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_ListByResourceGroup.json - // this example is just showing the usage of "PartnerDestinations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_Get.json + // this example is just showing the usage of "PartnerDestinations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_PartnerDestinationsListByResourceGroup() // get the collection of this PartnerDestinationResource PartnerDestinationCollection collection = resourceGroupResource.GetPartnerDestinations(); - // invoke the operation and iterate over the result - await foreach (PartnerDestinationResource item in collection.GetAllAsync()) + // invoke the operation + string partnerDestinationName = "examplePartnerDestinationName1"; + NullableResponse response = await collection.GetIfExistsAsync(partnerDestinationName); + PartnerDestinationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerDestinationData resourceData = item.Data; + PartnerDestinationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerDestinationResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerDestinationResource.cs index 5086718449680..6efed0a4382eb 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerDestinationResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerDestinationResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EventGrid.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -94,12 +93,12 @@ public async Task Update_PartnerDestinationsUpdate() PartnerDestinationResource partnerDestination = client.GetPartnerDestinationResource(partnerDestinationResourceId); // invoke the operation - PartnerDestinationPatch patch = new PartnerDestinationPatch() + PartnerDestinationPatch patch = new PartnerDestinationPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await partnerDestination.UpdateAsync(WaitUntil.Completed, patch); @@ -112,37 +111,6 @@ public async Task Update_PartnerDestinationsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPartnerDestinations_PartnerDestinationsListBySubscription() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_ListBySubscription.json - // this example is just showing the usage of "PartnerDestinations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PartnerDestinationResource item in subscriptionResource.GetPartnerDestinationsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerDestinationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Activate_PartnerDestinationsActivate() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceChannelCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceChannelCollection.cs index 98d1953be6f41..d001809ce924e 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceChannelCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceChannelCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PartnerNamespaceChannelCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ChannelsGet() + public async Task CreateOrUpdate_ChannelsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Channels_Get.json - // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Channels_CreateOrUpdate.json + // this example is just showing the usage of "Channels_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,21 @@ public async Task Get_ChannelsGet() // invoke the operation string channelName = "exampleChannelName1"; - PartnerNamespaceChannelResource result = await collection.GetAsync(channelName); + PartnerNamespaceChannelData data = new PartnerNamespaceChannelData + { + ChannelType = PartnerNamespaceChannelType.PartnerTopic, + PartnerTopicInfo = new PartnerTopicInfo + { + AzureSubscriptionId = Guid.Parse("8f6b6269-84f2-4d09-9e31-1127efcd1e40"), + ResourceGroupName = "examplerg2", + Name = "examplePartnerTopic1", + Source = "ContosoCorp.Accounts.User1", + }, + MessageForActivation = "Example message to approver", + ExpireOnIfNotActivated = DateTimeOffset.Parse("2021-10-21T22:50:25.410433Z"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, channelName, data); + PartnerNamespaceChannelResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +66,7 @@ public async Task Get_ChannelsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ChannelsGet() + public async Task Get_ChannelsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Channels_Get.json // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +89,21 @@ public async Task Exists_ChannelsGet() // invoke the operation string channelName = "exampleChannelName1"; - bool result = await collection.ExistsAsync(channelName); + PartnerNamespaceChannelResource result = await collection.GetAsync(channelName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerNamespaceChannelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ChannelsGet() + public async Task GetAll_ChannelsListByPartnerNamespace() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Channels_Get.json - // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Channels_ListByPartnerNamespace.json + // this example is just showing the usage of "Channels_ListByPartnerNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +121,25 @@ public async Task GetIfExists_ChannelsGet() // get the collection of this PartnerNamespaceChannelResource PartnerNamespaceChannelCollection collection = partnerNamespace.GetPartnerNamespaceChannels(); - // invoke the operation - string channelName = "exampleChannelName1"; - NullableResponse response = await collection.GetIfExistsAsync(channelName); - PartnerNamespaceChannelResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PartnerNamespaceChannelResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerNamespaceChannelData resourceData = result.Data; + PartnerNamespaceChannelData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ChannelsCreateOrUpdate() + public async Task Exists_ChannelsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Channels_CreateOrUpdate.json - // this example is just showing the usage of "Channels_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Channels_Get.json + // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,35 +159,17 @@ public async Task CreateOrUpdate_ChannelsCreateOrUpdate() // invoke the operation string channelName = "exampleChannelName1"; - PartnerNamespaceChannelData data = new PartnerNamespaceChannelData() - { - ChannelType = PartnerNamespaceChannelType.PartnerTopic, - PartnerTopicInfo = new PartnerTopicInfo() - { - AzureSubscriptionId = Guid.Parse("8f6b6269-84f2-4d09-9e31-1127efcd1e40"), - ResourceGroupName = "examplerg2", - Name = "examplePartnerTopic1", - Source = "ContosoCorp.Accounts.User1", - }, - MessageForActivation = "Example message to approver", - ExpireOnIfNotActivated = DateTimeOffset.Parse("2021-10-21T22:50:25.410433Z"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, channelName, data); - PartnerNamespaceChannelResource result = lro.Value; + bool result = await collection.ExistsAsync(channelName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerNamespaceChannelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ChannelsListByPartnerNamespace() + public async Task GetIfExists_ChannelsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Channels_ListByPartnerNamespace.json - // this example is just showing the usage of "Channels_ListByPartnerNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Channels_Get.json + // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +187,23 @@ public async Task GetAll_ChannelsListByPartnerNamespace() // get the collection of this PartnerNamespaceChannelResource PartnerNamespaceChannelCollection collection = partnerNamespace.GetPartnerNamespaceChannels(); - // invoke the operation and iterate over the result - await foreach (PartnerNamespaceChannelResource item in collection.GetAllAsync()) + // invoke the operation + string channelName = "exampleChannelName1"; + NullableResponse response = await collection.GetIfExistsAsync(channelName); + PartnerNamespaceChannelResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerNamespaceChannelData resourceData = item.Data; + PartnerNamespaceChannelData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceChannelResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceChannelResource.cs index 7488087da7a88..57053f24dfd3f 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceChannelResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceChannelResource.cs @@ -96,7 +96,7 @@ public async Task Update_ChannelsUpdate() PartnerNamespaceChannelResource partnerNamespaceChannel = client.GetPartnerNamespaceChannelResource(partnerNamespaceChannelResourceId); // invoke the operation - PartnerNamespaceChannelPatch patch = new PartnerNamespaceChannelPatch() + PartnerNamespaceChannelPatch patch = new PartnerNamespaceChannelPatch { ExpireOnIfNotActivated = DateTimeOffset.Parse("2022-03-23T23:06:11.785Z"), }; diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceCollection.cs index 4c34deca91cba..76fec63430c24 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PartnerNamespaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PartnerNamespacesGet() + public async Task CreateOrUpdate_PartnerNamespacesCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_Get.json - // this example is just showing the usage of "PartnerNamespaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_CreateOrUpdate.json + // this example is just showing the usage of "PartnerNamespaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,17 @@ public async Task Get_PartnerNamespacesGet() // invoke the operation string partnerNamespaceName = "examplePartnerNamespaceName1"; - PartnerNamespaceResource result = await collection.GetAsync(partnerNamespaceName); + PartnerNamespaceData data = new PartnerNamespaceData(new AzureLocation("westus")) + { + PartnerRegistrationFullyQualifiedId = new ResourceIdentifier("/subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/partnerRegistrations/ContosoCorpAccount1"), + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerNamespaceName, data); + PartnerNamespaceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +61,7 @@ public async Task Get_PartnerNamespacesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PartnerNamespacesGet() + public async Task Get_PartnerNamespacesGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_Get.json // this example is just showing the usage of "PartnerNamespaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +83,21 @@ public async Task Exists_PartnerNamespacesGet() // invoke the operation string partnerNamespaceName = "examplePartnerNamespaceName1"; - bool result = await collection.ExistsAsync(partnerNamespaceName); + PartnerNamespaceResource result = await collection.GetAsync(partnerNamespaceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerNamespaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PartnerNamespacesGet() + public async Task GetAll_PartnerNamespacesListByResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_Get.json - // this example is just showing the usage of "PartnerNamespaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_ListByResourceGroup.json + // this example is just showing the usage of "PartnerNamespaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +114,25 @@ public async Task GetIfExists_PartnerNamespacesGet() // get the collection of this PartnerNamespaceResource PartnerNamespaceCollection collection = resourceGroupResource.GetPartnerNamespaces(); - // invoke the operation - string partnerNamespaceName = "examplePartnerNamespaceName1"; - NullableResponse response = await collection.GetIfExistsAsync(partnerNamespaceName); - PartnerNamespaceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PartnerNamespaceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerNamespaceData resourceData = result.Data; + PartnerNamespaceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PartnerNamespacesCreateOrUpdate() + public async Task Exists_PartnerNamespacesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_CreateOrUpdate.json - // this example is just showing the usage of "PartnerNamespaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_Get.json + // this example is just showing the usage of "PartnerNamespaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +151,17 @@ public async Task CreateOrUpdate_PartnerNamespacesCreateOrUpdate() // invoke the operation string partnerNamespaceName = "examplePartnerNamespaceName1"; - PartnerNamespaceData data = new PartnerNamespaceData(new AzureLocation("westus")) - { - PartnerRegistrationFullyQualifiedId = new ResourceIdentifier("/subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/examplerg/providers/Microsoft.EventGrid/partnerRegistrations/ContosoCorpAccount1"), - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerNamespaceName, data); - PartnerNamespaceResource result = lro.Value; + bool result = await collection.ExistsAsync(partnerNamespaceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerNamespaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PartnerNamespacesListByResourceGroup() + public async Task GetIfExists_PartnerNamespacesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_ListByResourceGroup.json - // this example is just showing the usage of "PartnerNamespaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_Get.json + // this example is just showing the usage of "PartnerNamespaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_PartnerNamespacesListByResourceGroup() // get the collection of this PartnerNamespaceResource PartnerNamespaceCollection collection = resourceGroupResource.GetPartnerNamespaces(); - // invoke the operation and iterate over the result - await foreach (PartnerNamespaceResource item in collection.GetAllAsync()) + // invoke the operation + string partnerNamespaceName = "examplePartnerNamespaceName1"; + NullableResponse response = await collection.GetIfExistsAsync(partnerNamespaceName); + PartnerNamespaceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerNamespaceData resourceData = item.Data; + PartnerNamespaceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespacePrivateLinkResourceCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespacePrivateLinkResourceCollection.cs index 03f21cbdeded3..ecdeaaecd80d7 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespacePrivateLinkResourceCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespacePrivateLinkResourceCollection.cs @@ -51,10 +51,10 @@ public async Task Get_PrivateLinkResourcesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateLinkResourcesGet() + public async Task GetAll_PrivateLinkResourcesListByResource() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_Get.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_ListByResource.json + // this example is just showing the usage of "PrivateLinkResources_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_PrivateLinkResourcesGet() // get the collection of this PartnerNamespacePrivateLinkResource PartnerNamespacePrivateLinkResourceCollection collection = partnerNamespace.GetPartnerNamespacePrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "topic"; - bool result = await collection.ExistsAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (PartnerNamespacePrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateLinkResourcesGet() + public async Task Exists_PrivateLinkResourcesGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_Get.json // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_PrivateLinkResourcesGet() // invoke the operation string privateLinkResourceName = "topic"; - NullableResponse response = await collection.GetIfExistsAsync(privateLinkResourceName); - PartnerNamespacePrivateLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateLinkResourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesListByResource() + public async Task GetIfExists_PrivateLinkResourcesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_ListByResource.json - // this example is just showing the usage of "PrivateLinkResources_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PrivateLinkResources_Get.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_PrivateLinkResourcesListByResource() // get the collection of this PartnerNamespacePrivateLinkResource PartnerNamespacePrivateLinkResourceCollection collection = partnerNamespace.GetPartnerNamespacePrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (PartnerNamespacePrivateLinkResource item in collection.GetAllAsync()) + // invoke the operation + string privateLinkResourceName = "topic"; + NullableResponse response = await collection.GetIfExistsAsync(privateLinkResourceName); + PartnerNamespacePrivateLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridPrivateLinkResourceData resourceData = item.Data; + EventGridPrivateLinkResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceResource.cs index 59a0e856dcb76..9f0348d06e0e2 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerNamespaceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EventGrid.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -94,11 +93,11 @@ public async Task Update_PartnerNamespacesUpdate() PartnerNamespaceResource partnerNamespace = client.GetPartnerNamespaceResource(partnerNamespaceResourceId); // invoke the operation - PartnerNamespacePatch patch = new PartnerNamespacePatch() + PartnerNamespacePatch patch = new PartnerNamespacePatch { Tags = { -["tag1"] = "value1", +["tag1"] = "value1" }, }; await partnerNamespace.UpdateAsync(WaitUntil.Completed, patch); @@ -106,37 +105,6 @@ public async Task Update_PartnerNamespacesUpdate() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPartnerNamespaces_PartnerNamespacesListBySubscription() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_ListBySubscription.json - // this example is just showing the usage of "PartnerNamespaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PartnerNamespaceResource item in subscriptionResource.GetPartnerNamespacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerNamespaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSharedAccessKeys_PartnerNamespacesListSharedAccessKeys() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerRegistrationCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerRegistrationCollection.cs index e9e2f666e5ba6..21e66a30a861b 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerRegistrationCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerRegistrationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PartnerRegistrationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PartnerRegistrationsGet() + public async Task CreateOrUpdate_PartnerRegistrationsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_Get.json - // this example is just showing the usage of "PartnerRegistrations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_CreateOrUpdate.json + // this example is just showing the usage of "PartnerRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,17 @@ public async Task Get_PartnerRegistrationsGet() // invoke the operation string partnerRegistrationName = "examplePartnerRegistrationName1"; - PartnerRegistrationResource result = await collection.GetAsync(partnerRegistrationName); + PartnerRegistrationData data = new PartnerRegistrationData(new AzureLocation("global")) + { + Tags = +{ +["key1"] = "value1", +["key2"] = "Value2", +["key3"] = "Value3" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerRegistrationName, data); + PartnerRegistrationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +61,7 @@ public async Task Get_PartnerRegistrationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PartnerRegistrationsGet() + public async Task Get_PartnerRegistrationsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_Get.json // this example is just showing the usage of "PartnerRegistrations_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +83,21 @@ public async Task Exists_PartnerRegistrationsGet() // invoke the operation string partnerRegistrationName = "examplePartnerRegistrationName1"; - bool result = await collection.ExistsAsync(partnerRegistrationName); + PartnerRegistrationResource result = await collection.GetAsync(partnerRegistrationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerRegistrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PartnerRegistrationsGet() + public async Task GetAll_PartnerRegistrationsListByResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_Get.json - // this example is just showing the usage of "PartnerRegistrations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_ListByResourceGroup.json + // this example is just showing the usage of "PartnerRegistrations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +114,25 @@ public async Task GetIfExists_PartnerRegistrationsGet() // get the collection of this PartnerRegistrationResource PartnerRegistrationCollection collection = resourceGroupResource.GetPartnerRegistrations(); - // invoke the operation - string partnerRegistrationName = "examplePartnerRegistrationName1"; - NullableResponse response = await collection.GetIfExistsAsync(partnerRegistrationName); - PartnerRegistrationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PartnerRegistrationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerRegistrationData resourceData = result.Data; + PartnerRegistrationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PartnerRegistrationsCreateOrUpdate() + public async Task Exists_PartnerRegistrationsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_CreateOrUpdate.json - // this example is just showing the usage of "PartnerRegistrations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_Get.json + // this example is just showing the usage of "PartnerRegistrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +151,17 @@ public async Task CreateOrUpdate_PartnerRegistrationsCreateOrUpdate() // invoke the operation string partnerRegistrationName = "examplePartnerRegistrationName1"; - PartnerRegistrationData data = new PartnerRegistrationData(new AzureLocation("global")) - { - Tags = -{ -["key1"] = "value1", -["key2"] = "Value2", -["key3"] = "Value3", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerRegistrationName, data); - PartnerRegistrationResource result = lro.Value; + bool result = await collection.ExistsAsync(partnerRegistrationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerRegistrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PartnerRegistrationsListByResourceGroup() + public async Task GetIfExists_PartnerRegistrationsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_ListByResourceGroup.json - // this example is just showing the usage of "PartnerRegistrations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_Get.json + // this example is just showing the usage of "PartnerRegistrations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_PartnerRegistrationsListByResourceGroup() // get the collection of this PartnerRegistrationResource PartnerRegistrationCollection collection = resourceGroupResource.GetPartnerRegistrations(); - // invoke the operation and iterate over the result - await foreach (PartnerRegistrationResource item in collection.GetAllAsync()) + // invoke the operation + string partnerRegistrationName = "examplePartnerRegistrationName1"; + NullableResponse response = await collection.GetIfExistsAsync(partnerRegistrationName); + PartnerRegistrationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerRegistrationData resourceData = item.Data; + PartnerRegistrationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerRegistrationResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerRegistrationResource.cs index 7dd6f559b2d9e..162d0dfac4b5e 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerRegistrationResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerRegistrationResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EventGrid.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -94,47 +93,16 @@ public async Task Update_PartnerRegistrationsUpdate() PartnerRegistrationResource partnerRegistration = client.GetPartnerRegistrationResource(partnerRegistrationResourceId); // invoke the operation - PartnerRegistrationPatch patch = new PartnerRegistrationPatch() + PartnerRegistrationPatch patch = new PartnerRegistrationPatch { Tags = { -["NewKey"] = "NewValue", +["NewKey"] = "NewValue" }, }; await partnerRegistration.UpdateAsync(WaitUntil.Completed, patch); Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPartnerRegistrations_PartnerRegistrationsListBySubscription() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_ListBySubscription.json - // this example is just showing the usage of "PartnerRegistrations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PartnerRegistrationResource item in subscriptionResource.GetPartnerRegistrationsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerRegistrationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicCollection.cs index bf718e706b507..cbda6e73ef8a6 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PartnerTopicCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PartnerTopicsGet() + public async Task CreateOrUpdate_PartnerTopicsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_Get.json - // this example is just showing the usage of "PartnerTopics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_CreateOrUpdate.json + // this example is just showing the usage of "PartnerTopics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,16 @@ public async Task Get_PartnerTopicsGet() // invoke the operation string partnerTopicName = "examplePartnerTopicName1"; - PartnerTopicResource result = await collection.GetAsync(partnerTopicName); + PartnerTopicData data = new PartnerTopicData(new AzureLocation("westus2")) + { + PartnerRegistrationImmutableId = Guid.Parse("6f541064-031d-4cc8-9ec3-a3b4fc0f7185"), + Source = "ContosoCorp.Accounts.User1", + ExpireOnIfNotActivated = DateTimeOffset.Parse("2022-03-23T23:06:13.109Z"), + PartnerTopicFriendlyDescription = "Example description", + MessageForActivation = "Example message for activation", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerTopicName, data); + PartnerTopicResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +60,7 @@ public async Task Get_PartnerTopicsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PartnerTopicsGet() + public async Task Get_PartnerTopicsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_Get.json // this example is just showing the usage of "PartnerTopics_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +82,21 @@ public async Task Exists_PartnerTopicsGet() // invoke the operation string partnerTopicName = "examplePartnerTopicName1"; - bool result = await collection.ExistsAsync(partnerTopicName); + PartnerTopicResource result = await collection.GetAsync(partnerTopicName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerTopicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PartnerTopicsGet() + public async Task GetAll_PartnerTopicsListByResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_Get.json - // this example is just showing the usage of "PartnerTopics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_ListByResourceGroup.json + // this example is just showing the usage of "PartnerTopics_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +113,25 @@ public async Task GetIfExists_PartnerTopicsGet() // get the collection of this PartnerTopicResource PartnerTopicCollection collection = resourceGroupResource.GetPartnerTopics(); - // invoke the operation - string partnerTopicName = "examplePartnerTopicName1"; - NullableResponse response = await collection.GetIfExistsAsync(partnerTopicName); - PartnerTopicResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PartnerTopicResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerTopicData resourceData = result.Data; + PartnerTopicData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PartnerTopicsCreateOrUpdate() + public async Task Exists_PartnerTopicsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_CreateOrUpdate.json - // this example is just showing the usage of "PartnerTopics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_Get.json + // this example is just showing the usage of "PartnerTopics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,30 +150,17 @@ public async Task CreateOrUpdate_PartnerTopicsCreateOrUpdate() // invoke the operation string partnerTopicName = "examplePartnerTopicName1"; - PartnerTopicData data = new PartnerTopicData(new AzureLocation("westus2")) - { - PartnerRegistrationImmutableId = Guid.Parse("6f541064-031d-4cc8-9ec3-a3b4fc0f7185"), - Source = "ContosoCorp.Accounts.User1", - ExpireOnIfNotActivated = DateTimeOffset.Parse("2022-03-23T23:06:13.109Z"), - PartnerTopicFriendlyDescription = "Example description", - MessageForActivation = "Example message for activation", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerTopicName, data); - PartnerTopicResource result = lro.Value; + bool result = await collection.ExistsAsync(partnerTopicName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerTopicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PartnerTopicsListByResourceGroup() + public async Task GetIfExists_PartnerTopicsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_ListByResourceGroup.json - // this example is just showing the usage of "PartnerTopics_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_Get.json + // this example is just showing the usage of "PartnerTopics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_PartnerTopicsListByResourceGroup() // get the collection of this PartnerTopicResource PartnerTopicCollection collection = resourceGroupResource.GetPartnerTopics(); - // invoke the operation and iterate over the result - await foreach (PartnerTopicResource item in collection.GetAllAsync()) + // invoke the operation + string partnerTopicName = "examplePartnerTopicName1"; + NullableResponse response = await collection.GetIfExistsAsync(partnerTopicName); + PartnerTopicResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerTopicData resourceData = item.Data; + PartnerTopicData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicEventSubscriptionCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicEventSubscriptionCollection.cs index 43d53b05a255f..a469ac0d19a5a 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicEventSubscriptionCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicEventSubscriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PartnerTopicEventSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PartnerTopicEventSubscriptionsGet() + public async Task CreateOrUpdate_PartnerTopicEventSubscriptionsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopicEventSubscriptions_Get.json - // this example is just showing the usage of "PartnerTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopicEventSubscriptions_CreateOrUpdate.json + // this example is just showing the usage of "PartnerTopicEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,22 @@ public async Task Get_PartnerTopicEventSubscriptionsGet() PartnerTopicEventSubscriptionCollection collection = partnerTopic.GetPartnerTopicEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - PartnerTopicEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + string eventSubscriptionName = "exampleEventSubscriptionName1"; + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new WebHookEventSubscriptionDestination + { + Endpoint = new Uri("https://requestb.in/15ksip71"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + PartnerTopicEventSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +66,7 @@ public async Task Get_PartnerTopicEventSubscriptionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PartnerTopicEventSubscriptionsGet() + public async Task Get_PartnerTopicEventSubscriptionsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopicEventSubscriptions_Get.json // this example is just showing the usage of "PartnerTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +89,21 @@ public async Task Exists_PartnerTopicEventSubscriptionsGet() // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + PartnerTopicEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PartnerTopicEventSubscriptionsGet() + public async Task GetAll_PartnerTopicEventSubscriptionsListByPartnerTopic() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopicEventSubscriptions_Get.json - // this example is just showing the usage of "PartnerTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopicEventSubscriptions_ListByPartnerTopic.json + // this example is just showing the usage of "PartnerTopicEventSubscriptions_ListByPartnerTopic" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +121,25 @@ public async Task GetIfExists_PartnerTopicEventSubscriptionsGet() // get the collection of this PartnerTopicEventSubscriptionResource PartnerTopicEventSubscriptionCollection collection = partnerTopic.GetPartnerTopicEventSubscriptions(); - // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - PartnerTopicEventSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PartnerTopicEventSubscriptionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; + EventGridSubscriptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PartnerTopicEventSubscriptionsCreateOrUpdate() + public async Task Exists_PartnerTopicEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopicEventSubscriptions_CreateOrUpdate.json - // this example is just showing the usage of "PartnerTopicEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopicEventSubscriptions_Get.json + // this example is just showing the usage of "PartnerTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,36 +158,18 @@ public async Task CreateOrUpdate_PartnerTopicEventSubscriptionsCreateOrUpdate() PartnerTopicEventSubscriptionCollection collection = partnerTopic.GetPartnerTopicEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "exampleEventSubscriptionName1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new WebHookEventSubscriptionDestination() - { - Endpoint = new Uri("https://requestb.in/15ksip71"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - PartnerTopicEventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplesubscription1"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PartnerTopicEventSubscriptionsListByPartnerTopic() + public async Task GetIfExists_PartnerTopicEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopicEventSubscriptions_ListByPartnerTopic.json - // this example is just showing the usage of "PartnerTopicEventSubscriptions_ListByPartnerTopic" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopicEventSubscriptions_Get.json + // this example is just showing the usage of "PartnerTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +187,23 @@ public async Task GetAll_PartnerTopicEventSubscriptionsListByPartnerTopic() // get the collection of this PartnerTopicEventSubscriptionResource PartnerTopicEventSubscriptionCollection collection = partnerTopic.GetPartnerTopicEventSubscriptions(); - // invoke the operation and iterate over the result - await foreach (PartnerTopicEventSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + PartnerTopicEventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = item.Data; + EventGridSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicEventSubscriptionResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicEventSubscriptionResource.cs index bb9003c67397a..03658d3e8daf3 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicEventSubscriptionResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicEventSubscriptionResource.cs @@ -96,22 +96,19 @@ public async Task Update_PartnerTopicEventSubscriptionsUpdate() PartnerTopicEventSubscriptionResource partnerTopicEventSubscription = client.GetPartnerTopicEventSubscriptionResource(partnerTopicEventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new WebHookEventSubscriptionDestination() + Destination = new WebHookEventSubscriptionDestination { Endpoint = new Uri("https://requestb.in/15ksip71"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await partnerTopicEventSubscription.UpdateAsync(WaitUntil.Completed, patch); PartnerTopicEventSubscriptionResource result = lro.Value; diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicResource.cs index b15e096a9a854..bd547f7859435 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_PartnerTopicResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EventGrid.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -94,12 +93,12 @@ public async Task Update_PartnerTopicsUpdate() PartnerTopicResource partnerTopic = client.GetPartnerTopicResource(partnerTopicResourceId); // invoke the operation - PartnerTopicPatch patch = new PartnerTopicPatch() + PartnerTopicPatch patch = new PartnerTopicPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; PartnerTopicResource result = await partnerTopic.UpdateAsync(patch); @@ -111,37 +110,6 @@ public async Task Update_PartnerTopicsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPartnerTopics_PartnerTopicsListBySubscription() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_ListBySubscription.json - // this example is just showing the usage of "PartnerTopics_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PartnerTopicResource item in subscriptionResource.GetPartnerTopicsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerTopicData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Activate_PartnerTopicsActivate() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..3d77ae698bc1f --- /dev/null +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,298 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.EventGrid.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEventGridDomains_DomainsListBySubscription() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Domains_ListBySubscription.json + // this example is just showing the usage of "Domains_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EventGridDomainResource item in subscriptionResource.GetEventGridDomainsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridDomainData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEventGridNamespaces_NamespacesListBySubscription() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Namespaces_ListBySubscription.json + // this example is just showing the usage of "Namespaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EventGridNamespaceResource item in subscriptionResource.GetEventGridNamespacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridNamespaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPartnerConfigurations_PartnerConfigurationsListBySubscription() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerConfigurations_ListBySubscription.json + // this example is just showing the usage of "PartnerConfigurations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PartnerConfigurationResource item in subscriptionResource.GetPartnerConfigurationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPartnerDestinations_PartnerDestinationsListBySubscription() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerDestinations_ListBySubscription.json + // this example is just showing the usage of "PartnerDestinations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PartnerDestinationResource item in subscriptionResource.GetPartnerDestinationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerDestinationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPartnerNamespaces_PartnerNamespacesListBySubscription() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerNamespaces_ListBySubscription.json + // this example is just showing the usage of "PartnerNamespaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PartnerNamespaceResource item in subscriptionResource.GetPartnerNamespacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerNamespaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPartnerRegistrations_PartnerRegistrationsListBySubscription() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerRegistrations_ListBySubscription.json + // this example is just showing the usage of "PartnerRegistrations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PartnerRegistrationResource item in subscriptionResource.GetPartnerRegistrationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerRegistrationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPartnerTopics_PartnerTopicsListBySubscription() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/PartnerTopics_ListBySubscription.json + // this example is just showing the usage of "PartnerTopics_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PartnerTopicResource item in subscriptionResource.GetPartnerTopicsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerTopicData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSystemTopics_SystemTopicsListBySubscription() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_ListBySubscription.json + // this example is just showing the usage of "SystemTopics_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SystemTopicResource item in subscriptionResource.GetSystemTopicsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SystemTopicData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEventGridTopics_TopicsListBySubscription() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/Topics_ListBySubscription.json + // this example is just showing the usage of "Topics_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EventGridTopicResource item in subscriptionResource.GetEventGridTopicsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridTopicData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicCollection.cs index 26f393eb2f3ff..0e0bd1c076508 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SystemTopicCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SystemTopicsGet() + public async Task CreateOrUpdate_SystemTopicsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_Get.json - // this example is just showing the usage of "SystemTopics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_CreateOrUpdate.json + // this example is just showing the usage of "SystemTopics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,19 @@ public async Task Get_SystemTopicsGet() SystemTopicCollection collection = resourceGroupResource.GetSystemTopics(); // invoke the operation - string systemTopicName = "exampleSystemTopic2"; - SystemTopicResource result = await collection.GetAsync(systemTopicName); + string systemTopicName = "exampleSystemTopic1"; + SystemTopicData data = new SystemTopicData(new AzureLocation("westus2")) + { + Source = new ResourceIdentifier("/subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/azureeventgridrunnerrgcentraluseuap/providers/microsoft.storage/storageaccounts/pubstgrunnerb71cd29e"), + TopicType = "microsoft.storage.storageaccounts", + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, systemTopicName, data); + SystemTopicResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +62,7 @@ public async Task Get_SystemTopicsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SystemTopicsGet() + public async Task Get_SystemTopicsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_Get.json // this example is just showing the usage of "SystemTopics_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +84,21 @@ public async Task Exists_SystemTopicsGet() // invoke the operation string systemTopicName = "exampleSystemTopic2"; - bool result = await collection.ExistsAsync(systemTopicName); + SystemTopicResource result = await collection.GetAsync(systemTopicName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SystemTopicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SystemTopicsGet() + public async Task GetAll_SystemTopicsListByResourceGroup() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_Get.json - // this example is just showing the usage of "SystemTopics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_ListByResourceGroup.json + // this example is just showing the usage of "SystemTopics_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +115,25 @@ public async Task GetIfExists_SystemTopicsGet() // get the collection of this SystemTopicResource SystemTopicCollection collection = resourceGroupResource.GetSystemTopics(); - // invoke the operation - string systemTopicName = "exampleSystemTopic2"; - NullableResponse response = await collection.GetIfExistsAsync(systemTopicName); - SystemTopicResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SystemTopicResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SystemTopicData resourceData = result.Data; + SystemTopicData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SystemTopicsCreateOrUpdate() + public async Task Exists_SystemTopicsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_CreateOrUpdate.json - // this example is just showing the usage of "SystemTopics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_Get.json + // this example is just showing the usage of "SystemTopics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,33 +151,18 @@ public async Task CreateOrUpdate_SystemTopicsCreateOrUpdate() SystemTopicCollection collection = resourceGroupResource.GetSystemTopics(); // invoke the operation - string systemTopicName = "exampleSystemTopic1"; - SystemTopicData data = new SystemTopicData(new AzureLocation("westus2")) - { - Source = new ResourceIdentifier("/subscriptions/8f6b6269-84f2-4d09-9e31-1127efcd1e40/resourceGroups/azureeventgridrunnerrgcentraluseuap/providers/microsoft.storage/storageaccounts/pubstgrunnerb71cd29e"), - TopicType = "microsoft.storage.storageaccounts", - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, systemTopicName, data); - SystemTopicResource result = lro.Value; + string systemTopicName = "exampleSystemTopic2"; + bool result = await collection.ExistsAsync(systemTopicName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SystemTopicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SystemTopicsListByResourceGroup() + public async Task GetIfExists_SystemTopicsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_ListByResourceGroup.json - // this example is just showing the usage of "SystemTopics_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_Get.json + // this example is just showing the usage of "SystemTopics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_SystemTopicsListByResourceGroup() // get the collection of this SystemTopicResource SystemTopicCollection collection = resourceGroupResource.GetSystemTopics(); - // invoke the operation and iterate over the result - await foreach (SystemTopicResource item in collection.GetAllAsync()) + // invoke the operation + string systemTopicName = "exampleSystemTopic2"; + NullableResponse response = await collection.GetIfExistsAsync(systemTopicName); + SystemTopicResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SystemTopicData resourceData = item.Data; + SystemTopicData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicEventSubscriptionCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicEventSubscriptionCollection.cs index 740db8700524f..7197059f3c079 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicEventSubscriptionCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicEventSubscriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SystemTopicEventSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SystemTopicEventSubscriptionsGet() + public async Task CreateOrUpdate_SystemTopicEventSubscriptionsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_Get.json - // this example is just showing the usage of "SystemTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_CreateOrUpdate.json + // this example is just showing the usage of "SystemTopicEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,22 @@ public async Task Get_SystemTopicEventSubscriptionsGet() SystemTopicEventSubscriptionCollection collection = systemTopic.GetSystemTopicEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - SystemTopicEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + string eventSubscriptionName = "exampleEventSubscriptionName1"; + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new WebHookEventSubscriptionDestination + { + Endpoint = new Uri("https://requestb.in/15ksip71"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + SystemTopicEventSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +66,7 @@ public async Task Get_SystemTopicEventSubscriptionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SystemTopicEventSubscriptionsGet() + public async Task Get_SystemTopicEventSubscriptionsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_Get.json // this example is just showing the usage of "SystemTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +89,21 @@ public async Task Exists_SystemTopicEventSubscriptionsGet() // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + SystemTopicEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SystemTopicEventSubscriptionsGet() + public async Task GetAll_SystemTopicEventSubscriptionsListBySystemTopic() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_Get.json - // this example is just showing the usage of "SystemTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_ListBySystemTopic.json + // this example is just showing the usage of "SystemTopicEventSubscriptions_ListBySystemTopic" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +121,25 @@ public async Task GetIfExists_SystemTopicEventSubscriptionsGet() // get the collection of this SystemTopicEventSubscriptionResource SystemTopicEventSubscriptionCollection collection = systemTopic.GetSystemTopicEventSubscriptions(); - // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - SystemTopicEventSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SystemTopicEventSubscriptionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; + EventGridSubscriptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SystemTopicEventSubscriptionsCreateOrUpdate() + public async Task Exists_SystemTopicEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_CreateOrUpdate.json - // this example is just showing the usage of "SystemTopicEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_Get.json + // this example is just showing the usage of "SystemTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,36 +158,18 @@ public async Task CreateOrUpdate_SystemTopicEventSubscriptionsCreateOrUpdate() SystemTopicEventSubscriptionCollection collection = systemTopic.GetSystemTopicEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "exampleEventSubscriptionName1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new WebHookEventSubscriptionDestination() - { - Endpoint = new Uri("https://requestb.in/15ksip71"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - SystemTopicEventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplesubscription1"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SystemTopicEventSubscriptionsListBySystemTopic() + public async Task GetIfExists_SystemTopicEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_ListBySystemTopic.json - // this example is just showing the usage of "SystemTopicEventSubscriptions_ListBySystemTopic" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_Get.json + // this example is just showing the usage of "SystemTopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +187,23 @@ public async Task GetAll_SystemTopicEventSubscriptionsListBySystemTopic() // get the collection of this SystemTopicEventSubscriptionResource SystemTopicEventSubscriptionCollection collection = systemTopic.GetSystemTopicEventSubscriptions(); - // invoke the operation and iterate over the result - await foreach (SystemTopicEventSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + SystemTopicEventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = item.Data; + EventGridSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicEventSubscriptionResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicEventSubscriptionResource.cs index 07d4db4c0f1cf..8c71b49a75141 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicEventSubscriptionResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicEventSubscriptionResource.cs @@ -16,36 +16,6 @@ namespace Azure.ResourceManager.EventGrid.Samples { public partial class Sample_SystemTopicEventSubscriptionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeliveryAttributes_SystemTopicEventSubscriptionsGetDeliveryAttributes() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_GetDeliveryAttributes.json - // this example is just showing the usage of "SystemTopicEventSubscriptions_GetDeliveryAttributes" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SystemTopicEventSubscriptionResource created on azure - // for more information of creating SystemTopicEventSubscriptionResource, please refer to the document of SystemTopicEventSubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - string resourceGroupName = "examplerg"; - string systemTopicName = "exampleSystemTopic1"; - string eventSubscriptionName = "examplesubscription1"; - ResourceIdentifier systemTopicEventSubscriptionResourceId = SystemTopicEventSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, systemTopicName, eventSubscriptionName); - SystemTopicEventSubscriptionResource systemTopicEventSubscription = client.GetSystemTopicEventSubscriptionResource(systemTopicEventSubscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeliveryAttributeMapping item in systemTopicEventSubscription.GetDeliveryAttributesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_SystemTopicEventSubscriptionsGet() @@ -126,22 +96,19 @@ public async Task Update_SystemTopicEventSubscriptionsUpdate() SystemTopicEventSubscriptionResource systemTopicEventSubscription = client.GetSystemTopicEventSubscriptionResource(systemTopicEventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new WebHookEventSubscriptionDestination() + Destination = new WebHookEventSubscriptionDestination { Endpoint = new Uri("https://requestb.in/15ksip71"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await systemTopicEventSubscription.UpdateAsync(WaitUntil.Completed, patch); SystemTopicEventSubscriptionResource result = lro.Value; @@ -153,6 +120,36 @@ public async Task Update_SystemTopicEventSubscriptionsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeliveryAttributes_SystemTopicEventSubscriptionsGetDeliveryAttributes() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopicEventSubscriptions_GetDeliveryAttributes.json + // this example is just showing the usage of "SystemTopicEventSubscriptions_GetDeliveryAttributes" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SystemTopicEventSubscriptionResource created on azure + // for more information of creating SystemTopicEventSubscriptionResource, please refer to the document of SystemTopicEventSubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + string resourceGroupName = "examplerg"; + string systemTopicName = "exampleSystemTopic1"; + string eventSubscriptionName = "examplesubscription1"; + ResourceIdentifier systemTopicEventSubscriptionResourceId = SystemTopicEventSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, systemTopicName, eventSubscriptionName); + SystemTopicEventSubscriptionResource systemTopicEventSubscription = client.GetSystemTopicEventSubscriptionResource(systemTopicEventSubscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeliveryAttributeMapping item in systemTopicEventSubscription.GetDeliveryAttributesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetFullUri_SystemTopicEventSubscriptionsGetFullUrl() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicResource.cs index 2f5a31168950f..1f7aaaa3bcbce 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_SystemTopicResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EventGrid.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -94,12 +93,12 @@ public async Task Update_SystemTopicsUpdate() SystemTopicResource systemTopic = client.GetSystemTopicResource(systemTopicResourceId); // invoke the operation - SystemTopicPatch patch = new SystemTopicPatch() + SystemTopicPatch patch = new SystemTopicPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await systemTopic.UpdateAsync(WaitUntil.Completed, patch); @@ -111,36 +110,5 @@ public async Task Update_SystemTopicsUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSystemTopics_SystemTopicsListBySubscription() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/SystemTopics_ListBySubscription.json - // this example is just showing the usage of "SystemTopics_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SystemTopicResource item in subscriptionResource.GetSystemTopicsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SystemTopicData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicEventSubscriptionCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicEventSubscriptionCollection.cs index 810eff5f77cd3..761170ab37c5d 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicEventSubscriptionCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicEventSubscriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_TopicEventSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TopicEventSubscriptionsGet() + public async Task CreateOrUpdate_TopicEventSubscriptionsCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_Get.json - // this example is just showing the usage of "TopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_CreateOrUpdate.json + // this example is just showing the usage of "TopicEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,22 @@ public async Task Get_TopicEventSubscriptionsGet() TopicEventSubscriptionCollection collection = eventGridTopic.GetTopicEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - TopicEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); + string eventSubscriptionName = "exampleEventSubscriptionName1"; + EventGridSubscriptionData data = new EventGridSubscriptionData + { + Destination = new WebHookEventSubscriptionDestination + { + Endpoint = new Uri("https://requestb.in/15ksip71"), + }, + Filter = new EventSubscriptionFilter + { + SubjectBeginsWith = "ExamplePrefix", + SubjectEndsWith = "ExampleSuffix", + IsSubjectCaseSensitive = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); + TopicEventSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +66,7 @@ public async Task Get_TopicEventSubscriptionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TopicEventSubscriptionsGet() + public async Task Get_TopicEventSubscriptionsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_Get.json // this example is just showing the usage of "TopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +89,21 @@ public async Task Exists_TopicEventSubscriptionsGet() // invoke the operation string eventSubscriptionName = "examplesubscription1"; - bool result = await collection.ExistsAsync(eventSubscriptionName); + TopicEventSubscriptionResource result = await collection.GetAsync(eventSubscriptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventGridSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TopicEventSubscriptionsGet() + public async Task GetAll_TopicEventSubscriptionsList() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_Get.json - // this example is just showing the usage of "TopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_List.json + // this example is just showing the usage of "TopicEventSubscriptions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +121,25 @@ public async Task GetIfExists_TopicEventSubscriptionsGet() // get the collection of this TopicEventSubscriptionResource TopicEventSubscriptionCollection collection = eventGridTopic.GetTopicEventSubscriptions(); - // invoke the operation - string eventSubscriptionName = "examplesubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); - TopicEventSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (TopicEventSubscriptionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; + EventGridSubscriptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TopicEventSubscriptionsCreateOrUpdate() + public async Task Exists_TopicEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_CreateOrUpdate.json - // this example is just showing the usage of "TopicEventSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_Get.json + // this example is just showing the usage of "TopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,36 +158,18 @@ public async Task CreateOrUpdate_TopicEventSubscriptionsCreateOrUpdate() TopicEventSubscriptionCollection collection = eventGridTopic.GetTopicEventSubscriptions(); // invoke the operation - string eventSubscriptionName = "exampleEventSubscriptionName1"; - EventGridSubscriptionData data = new EventGridSubscriptionData() - { - Destination = new WebHookEventSubscriptionDestination() - { - Endpoint = new Uri("https://requestb.in/15ksip71"), - }, - Filter = new EventSubscriptionFilter() - { - SubjectBeginsWith = "ExamplePrefix", - SubjectEndsWith = "ExampleSuffix", - IsSubjectCaseSensitive = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, eventSubscriptionName, data); - TopicEventSubscriptionResource result = lro.Value; + string eventSubscriptionName = "examplesubscription1"; + bool result = await collection.ExistsAsync(eventSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TopicEventSubscriptionsList() + public async Task GetIfExists_TopicEventSubscriptionsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_List.json - // this example is just showing the usage of "TopicEventSubscriptions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_Get.json + // this example is just showing the usage of "TopicEventSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +187,23 @@ public async Task GetAll_TopicEventSubscriptionsList() // get the collection of this TopicEventSubscriptionResource TopicEventSubscriptionCollection collection = eventGridTopic.GetTopicEventSubscriptions(); - // invoke the operation and iterate over the result - await foreach (TopicEventSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string eventSubscriptionName = "examplesubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(eventSubscriptionName); + TopicEventSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventGridSubscriptionData resourceData = item.Data; + EventGridSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicEventSubscriptionResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicEventSubscriptionResource.cs index e0c319c807dbc..0826001945713 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicEventSubscriptionResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicEventSubscriptionResource.cs @@ -16,36 +16,6 @@ namespace Azure.ResourceManager.EventGrid.Samples { public partial class Sample_TopicEventSubscriptionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeliveryAttributes_TopicEventSubscriptionsGetDeliveryAttributes() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_GetDeliveryAttributes.json - // this example is just showing the usage of "TopicEventSubscriptions_GetDeliveryAttributes" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TopicEventSubscriptionResource created on azure - // for more information of creating TopicEventSubscriptionResource, please refer to the document of TopicEventSubscriptionResource - string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; - string resourceGroupName = "examplerg"; - string topicName = "exampleTopic1"; - string eventSubscriptionName = "examplesubscription1"; - ResourceIdentifier topicEventSubscriptionResourceId = TopicEventSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, topicName, eventSubscriptionName); - TopicEventSubscriptionResource topicEventSubscription = client.GetTopicEventSubscriptionResource(topicEventSubscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeliveryAttributeMapping item in topicEventSubscription.GetDeliveryAttributesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_TopicEventSubscriptionsGet() @@ -126,22 +96,19 @@ public async Task Update_TopicEventSubscriptionsUpdate() TopicEventSubscriptionResource topicEventSubscription = client.GetTopicEventSubscriptionResource(topicEventSubscriptionResourceId); // invoke the operation - EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch() + EventGridSubscriptionPatch patch = new EventGridSubscriptionPatch { - Destination = new WebHookEventSubscriptionDestination() + Destination = new WebHookEventSubscriptionDestination { Endpoint = new Uri("https://requestb.in/15ksip71"), }, - Filter = new EventSubscriptionFilter() + Filter = new EventSubscriptionFilter { SubjectBeginsWith = "existingPrefix", SubjectEndsWith = "newSuffix", IsSubjectCaseSensitive = true, }, - Labels = -{ -"label1","label2" -}, + Labels = { "label1", "label2" }, }; ArmOperation lro = await topicEventSubscription.UpdateAsync(WaitUntil.Completed, patch); TopicEventSubscriptionResource result = lro.Value; @@ -153,6 +120,36 @@ public async Task Update_TopicEventSubscriptionsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeliveryAttributes_TopicEventSubscriptionsGetDeliveryAttributes() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicEventSubscriptions_GetDeliveryAttributes.json + // this example is just showing the usage of "TopicEventSubscriptions_GetDeliveryAttributes" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TopicEventSubscriptionResource created on azure + // for more information of creating TopicEventSubscriptionResource, please refer to the document of TopicEventSubscriptionResource + string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; + string resourceGroupName = "examplerg"; + string topicName = "exampleTopic1"; + string eventSubscriptionName = "examplesubscription1"; + ResourceIdentifier topicEventSubscriptionResourceId = TopicEventSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, topicName, eventSubscriptionName); + TopicEventSubscriptionResource topicEventSubscription = client.GetTopicEventSubscriptionResource(topicEventSubscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeliveryAttributeMapping item in topicEventSubscription.GetDeliveryAttributesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetFullUri_TopicEventSubscriptionsGetFullUrl() diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicNetworkSecurityPerimeterConfigurationCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicNetworkSecurityPerimeterConfigurationCollection.cs index e42e77679bd0f..c816f666cbb89 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicNetworkSecurityPerimeterConfigurationCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicNetworkSecurityPerimeterConfigurationCollection.cs @@ -52,10 +52,10 @@ public async Task Get_NetworkSecurityPerimeterConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkSecurityPerimeterConfigurationsGet() + public async Task GetAll_NetworkSecurityPerimeterConfigurationsList() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurations_Get.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurations_List.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,17 +73,19 @@ public async Task Exists_NetworkSecurityPerimeterConfigurationsGet() // get the collection of this TopicNetworkSecurityPerimeterConfigurationResource TopicNetworkSecurityPerimeterConfigurationCollection collection = eventGridTopic.GetTopicNetworkSecurityPerimeterConfigurations(); - // invoke the operation - string perimeterGuid = "8f6b6269-84f2-4d09-9e31-1127efcd1e40perimeter"; - string associationName = "someAssociation"; - bool result = await collection.ExistsAsync(perimeterGuid, associationName); + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterConfigurationData item in collection.GetAllAsync()) + { + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {item.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkSecurityPerimeterConfigurationsGet() + public async Task Exists_NetworkSecurityPerimeterConfigurationsGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurations_Get.json // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +109,17 @@ public async Task GetIfExists_NetworkSecurityPerimeterConfigurationsGet() // invoke the operation string perimeterGuid = "8f6b6269-84f2-4d09-9e31-1127efcd1e40perimeter"; string associationName = "someAssociation"; - NullableResponse response = await collection.GetIfExistsAsync(perimeterGuid, associationName); - TopicNetworkSecurityPerimeterConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(perimeterGuid, associationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkSecurityPerimeterConfigurationsList() + public async Task GetIfExists_NetworkSecurityPerimeterConfigurationsGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurations_List.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurations_Get.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,14 +137,24 @@ public async Task GetAll_NetworkSecurityPerimeterConfigurationsList() // get the collection of this TopicNetworkSecurityPerimeterConfigurationResource TopicNetworkSecurityPerimeterConfigurationCollection collection = eventGridTopic.GetTopicNetworkSecurityPerimeterConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkSecurityPerimeterConfigurationData item in collection.GetAllAsync()) + // invoke the operation + string perimeterGuid = "8f6b6269-84f2-4d09-9e31-1127efcd1e40perimeter"; + string associationName = "someAssociation"; + NullableResponse response = await collection.GetIfExistsAsync(perimeterGuid, associationName); + TopicNetworkSecurityPerimeterConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {item.Id}"); + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicSpaceCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicSpaceCollection.cs index abdb10c85cd22..14ba450377ef0 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicSpaceCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicSpaceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_TopicSpaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TopicSpacesGet() + public async Task CreateOrUpdate_TopicSpacesCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_Get.json - // this example is just showing the usage of "TopicSpaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_CreateOrUpdate.json + // this example is just showing the usage of "TopicSpaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_TopicSpacesGet() // invoke the operation string topicSpaceName = "exampleTopicSpaceName1"; - TopicSpaceResource result = await collection.GetAsync(topicSpaceName); + TopicSpaceData data = new TopicSpaceData + { + TopicTemplates = { "filter1", "filter2" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, topicSpaceName, data); + TopicSpaceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_TopicSpacesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TopicSpacesGet() + public async Task Get_TopicSpacesGet() { // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_Get.json // this example is just showing the usage of "TopicSpaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +79,21 @@ public async Task Exists_TopicSpacesGet() // invoke the operation string topicSpaceName = "exampleTopicSpaceName1"; - bool result = await collection.ExistsAsync(topicSpaceName); + TopicSpaceResource result = await collection.GetAsync(topicSpaceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TopicSpaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TopicSpacesGet() + public async Task GetAll_TopicSpacesListByNamespace() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_Get.json - // this example is just showing the usage of "TopicSpaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_ListByNamespace.json + // this example is just showing the usage of "TopicSpaces_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,38 +104,32 @@ public async Task GetIfExists_TopicSpacesGet() // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string namespaceName = "exampleNamespaceName1"; + string namespaceName = "namespace123"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // get the collection of this TopicSpaceResource TopicSpaceCollection collection = eventGridNamespace.GetTopicSpaces(); - // invoke the operation - string topicSpaceName = "exampleTopicSpaceName1"; - NullableResponse response = await collection.GetIfExistsAsync(topicSpaceName); - TopicSpaceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (TopicSpaceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - TopicSpaceData resourceData = result.Data; + TopicSpaceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TopicSpacesCreateOrUpdate() + public async Task Exists_TopicSpacesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_CreateOrUpdate.json - // this example is just showing the usage of "TopicSpaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_Get.json + // this example is just showing the usage of "TopicSpaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,29 +149,17 @@ public async Task CreateOrUpdate_TopicSpacesCreateOrUpdate() // invoke the operation string topicSpaceName = "exampleTopicSpaceName1"; - TopicSpaceData data = new TopicSpaceData() - { - TopicTemplates = -{ -"filter1","filter2" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, topicSpaceName, data); - TopicSpaceResource result = lro.Value; + bool result = await collection.ExistsAsync(topicSpaceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TopicSpaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TopicSpacesListByNamespace() + public async Task GetIfExists_TopicSpacesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_ListByNamespace.json - // this example is just showing the usage of "TopicSpaces_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_Get.json + // this example is just showing the usage of "TopicSpaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,24 +170,30 @@ public async Task GetAll_TopicSpacesListByNamespace() // for more information of creating EventGridNamespaceResource, please refer to the document of EventGridNamespaceResource string subscriptionId = "8f6b6269-84f2-4d09-9e31-1127efcd1e40"; string resourceGroupName = "examplerg"; - string namespaceName = "namespace123"; + string namespaceName = "exampleNamespaceName1"; ResourceIdentifier eventGridNamespaceResourceId = EventGridNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); EventGridNamespaceResource eventGridNamespace = client.GetEventGridNamespaceResource(eventGridNamespaceResourceId); // get the collection of this TopicSpaceResource TopicSpaceCollection collection = eventGridNamespace.GetTopicSpaces(); - // invoke the operation and iterate over the result - await foreach (TopicSpaceResource item in collection.GetAllAsync()) + // invoke the operation + string topicSpaceName = "exampleTopicSpaceName1"; + NullableResponse response = await collection.GetIfExistsAsync(topicSpaceName); + TopicSpaceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - TopicSpaceData resourceData = item.Data; + TopicSpaceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicSpaceResource.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicSpaceResource.cs index 5c77d8b30c1fd..29840b30fca27 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicSpaceResource.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicSpaceResource.cs @@ -48,10 +48,10 @@ public async Task Get_TopicSpacesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TopicSpacesCreateOrUpdate() + public async Task Delete_TopicSpacesDelete() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_CreateOrUpdate.json - // this example is just showing the usage of "TopicSpaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_Delete.json + // this example is just showing the usage of "TopicSpaces_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +68,17 @@ public async Task Update_TopicSpacesCreateOrUpdate() TopicSpaceResource topicSpace = client.GetTopicSpaceResource(topicSpaceResourceId); // invoke the operation - TopicSpaceData data = new TopicSpaceData() - { - TopicTemplates = -{ -"filter1","filter2" -}, - }; - ArmOperation lro = await topicSpace.UpdateAsync(WaitUntil.Completed, data); - TopicSpaceResource result = lro.Value; + await topicSpace.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TopicSpaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_TopicSpacesDelete() + public async Task Update_TopicSpacesCreateOrUpdate() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_Delete.json - // this example is just showing the usage of "TopicSpaces_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicSpaces_CreateOrUpdate.json + // this example is just showing the usage of "TopicSpaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +95,18 @@ public async Task Delete_TopicSpacesDelete() TopicSpaceResource topicSpace = client.GetTopicSpaceResource(topicSpaceResourceId); // invoke the operation - await topicSpace.DeleteAsync(WaitUntil.Completed); + TopicSpaceData data = new TopicSpaceData + { + TopicTemplates = { "filter1", "filter2" }, + }; + ArmOperation lro = await topicSpace.UpdateAsync(WaitUntil.Completed, data); + TopicSpaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TopicSpaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicTypeCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicTypeCollection.cs index b531d5304596d..31a7de1566741 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicTypeCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_TopicTypeCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -17,64 +18,60 @@ public partial class Sample_TopicTypeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TopicTypesList() + public async Task Get_TopicTypesGet() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicTypes_List.json - // this example is just showing the usage of "TopicTypes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicTypes_Get.json + // this example is just showing the usage of "TopicTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TopicTypeResource TopicTypeCollection collection = tenantResource.GetTopicTypes(); - // invoke the operation and iterate over the result - await foreach (TopicTypeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TopicTypeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string topicTypeName = "Microsoft.Storage.StorageAccounts"; + TopicTypeResource result = await collection.GetAsync(topicTypeName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TopicTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TopicTypesGet() + public async Task GetAll_TopicTypesList() { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicTypes_Get.json - // this example is just showing the usage of "TopicTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/TopicTypes_List.json + // this example is just showing the usage of "TopicTypes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TopicTypeResource TopicTypeCollection collection = tenantResource.GetTopicTypes(); - // invoke the operation - string topicTypeName = "Microsoft.Storage.StorageAccounts"; - TopicTypeResource result = await collection.GetAsync(topicTypeName); + // invoke the operation and iterate over the result + await foreach (TopicTypeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TopicTypeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TopicTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -89,9 +86,7 @@ public async Task Exists_TopicTypesGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TopicTypeResource TopicTypeCollection collection = tenantResource.GetTopicTypes(); @@ -115,9 +110,7 @@ public async Task GetIfExists_TopicTypesGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TopicTypeResource TopicTypeCollection collection = tenantResource.GetTopicTypes(); diff --git a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_VerifiedPartnerCollection.cs b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_VerifiedPartnerCollection.cs index 0c6efb469e916..b4477e6e871dd 100644 --- a/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_VerifiedPartnerCollection.cs +++ b/sdk/eventgrid/Azure.ResourceManager.EventGrid/samples/Generated/Samples/Sample_VerifiedPartnerCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventGrid.Samples @@ -27,9 +28,7 @@ public async Task Get_VerifiedPartnersGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this VerifiedPartnerResource VerifiedPartnerCollection collection = tenantResource.GetVerifiedPartners(); @@ -45,6 +44,36 @@ public async Task Get_VerifiedPartnersGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_VerifiedPartnersList() + { + // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/VerifiedPartners_List.json + // this example is just showing the usage of "VerifiedPartners_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this VerifiedPartnerResource + VerifiedPartnerCollection collection = tenantResource.GetVerifiedPartners(); + + // invoke the operation and iterate over the result + await foreach (VerifiedPartnerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VerifiedPartnerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_VerifiedPartnersGet() @@ -57,9 +86,7 @@ public async Task Exists_VerifiedPartnersGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this VerifiedPartnerResource VerifiedPartnerCollection collection = tenantResource.GetVerifiedPartners(); @@ -83,9 +110,7 @@ public async Task GetIfExists_VerifiedPartnersGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this VerifiedPartnerResource VerifiedPartnerCollection collection = tenantResource.GetVerifiedPartners(); @@ -108,37 +133,5 @@ public async Task GetIfExists_VerifiedPartnersGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_VerifiedPartnersList() - { - // Generated from example definition: specification/eventgrid/resource-manager/Microsoft.EventGrid/preview/2024-06-01-preview/examples/VerifiedPartners_List.json - // this example is just showing the usage of "VerifiedPartners_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this VerifiedPartnerResource - VerifiedPartnerCollection collection = tenantResource.GetVerifiedPartners(); - - // invoke the operation and iterate over the result - await foreach (VerifiedPartnerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VerifiedPartnerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubAuthorizationRuleCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubAuthorizationRuleCollection.cs index f947e174b2898..0e1b9d0406937 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubAuthorizationRuleCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubAuthorizationRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubAuthorizationRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EventHubAuthorizationRuleListAll() + public async Task CreateOrUpdate_EventHubAuthorizationRuleCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleListAll.json - // this example is just showing the usage of "EventHubs_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleCreate.json + // this example is just showing the usage of "EventHubs_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,28 @@ public async Task GetAll_EventHubAuthorizationRuleListAll() // get the collection of this EventHubAuthorizationRuleResource EventHubAuthorizationRuleCollection collection = eventHub.GetEventHubAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (EventHubAuthorizationRuleResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationRuleName = "sdk-Authrules-2513"; + EventHubsAuthorizationRuleData data = new EventHubsAuthorizationRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsAuthorizationRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Rights = { EventHubsAccessRight.Listen, EventHubsAccessRight.Send }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); + EventHubAuthorizationRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EventHubAuthorizationRuleCreate() + public async Task Get_EventHubAuthorizationRuleGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleCreate.json - // this example is just showing the usage of "EventHubs_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleGet.json + // this example is just showing the usage of "EventHubs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +82,7 @@ public async Task CreateOrUpdate_EventHubAuthorizationRuleCreate() // invoke the operation string authorizationRuleName = "sdk-Authrules-2513"; - EventHubsAuthorizationRuleData data = new EventHubsAuthorizationRuleData() - { - Rights = -{ -EventHubsAccessRight.Listen,EventHubsAccessRight.Send -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); - EventHubAuthorizationRuleResource result = lro.Value; + EventHubAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -98,10 +93,10 @@ public async Task CreateOrUpdate_EventHubAuthorizationRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventHubAuthorizationRuleGet() + public async Task GetAll_EventHubAuthorizationRuleListAll() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleGet.json - // this example is just showing the usage of "EventHubs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleListAll.json + // this example is just showing the usage of "EventHubs_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,15 +115,17 @@ public async Task Get_EventHubAuthorizationRuleGet() // get the collection of this EventHubAuthorizationRuleResource EventHubAuthorizationRuleCollection collection = eventHub.GetEventHubAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "sdk-Authrules-2513"; - EventHubAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (EventHubAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubAuthorizationRuleResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubAuthorizationRuleResource.cs index b3695c83ddacd..cdd8aa1678938 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubAuthorizationRuleResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubAuthorizationRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubAuthorizationRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_EventHubAuthorizationRuleCreate() + public async Task Get_EventHubAuthorizationRuleGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleCreate.json - // this example is just showing the usage of "EventHubs_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleGet.json + // this example is just showing the usage of "EventHubs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,15 +39,7 @@ public async Task Update_EventHubAuthorizationRuleCreate() EventHubAuthorizationRuleResource eventHubAuthorizationRule = client.GetEventHubAuthorizationRuleResource(eventHubAuthorizationRuleResourceId); // invoke the operation - EventHubsAuthorizationRuleData data = new EventHubsAuthorizationRuleData() - { - Rights = -{ -EventHubsAccessRight.Listen,EventHubsAccessRight.Send -}, - }; - ArmOperation lro = await eventHubAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); - EventHubAuthorizationRuleResource result = lro.Value; + EventHubAuthorizationRuleResource result = await eventHubAuthorizationRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +50,10 @@ public async Task Update_EventHubAuthorizationRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventHubAuthorizationRuleGet() + public async Task Delete_EventHubAuthorizationRuleDelete() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleGet.json - // this example is just showing the usage of "EventHubs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleDelete.json + // this example is just showing the usage of "EventHubs_DeleteAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,21 +71,17 @@ public async Task Get_EventHubAuthorizationRuleGet() EventHubAuthorizationRuleResource eventHubAuthorizationRule = client.GetEventHubAuthorizationRuleResource(eventHubAuthorizationRuleResourceId); // invoke the operation - EventHubAuthorizationRuleResource result = await eventHubAuthorizationRule.GetAsync(); + await eventHubAuthorizationRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_EventHubAuthorizationRuleDelete() + public async Task Update_EventHubAuthorizationRuleCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleDelete.json - // this example is just showing the usage of "EventHubs_DeleteAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubAuthorizationRuleCreate.json + // this example is just showing the usage of "EventHubs_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +99,18 @@ public async Task Delete_EventHubAuthorizationRuleDelete() EventHubAuthorizationRuleResource eventHubAuthorizationRule = client.GetEventHubAuthorizationRuleResource(eventHubAuthorizationRuleResourceId); // invoke the operation - await eventHubAuthorizationRule.DeleteAsync(WaitUntil.Completed); + EventHubsAuthorizationRuleData data = new EventHubsAuthorizationRuleData + { + Rights = { EventHubsAccessRight.Listen, EventHubsAccessRight.Send }, + }; + ArmOperation lro = await eventHubAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); + EventHubAuthorizationRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubCollection.cs index 63f6e809e4033..52f6ffb663ad9 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.EventHubs.Samples { public partial class Sample_EventHubCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_EventHubsListAll() - { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubListByNameSpace.json - // this example is just showing the usage of "EventHubs_ListByNamespace" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this EventHubsNamespaceResource created on azure - // for more information of creating EventHubsNamespaceResource, please refer to the document of EventHubsNamespaceResource - string subscriptionId = "e2f361f0-3b27-4503-a9cc-21cfba380093"; - string resourceGroupName = "Default-NotificationHubs-AustraliaEast"; - string namespaceName = "sdk-Namespace-5357"; - ResourceIdentifier eventHubsNamespaceResourceId = EventHubsNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); - EventHubsNamespaceResource eventHubsNamespace = client.GetEventHubsNamespaceResource(eventHubsNamespaceResourceId); - - // get the collection of this EventHubResource - EventHubCollection collection = eventHubsNamespace.GetEventHubs(); - - // invoke the operation and iterate over the result - await foreach (EventHubResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_EventHubCreate() @@ -77,21 +41,21 @@ public async Task CreateOrUpdate_EventHubCreate() // invoke the operation string eventHubName = "sdk-EventHub-6547"; - EventHubData data = new EventHubData() + EventHubData data = new EventHubData { PartitionCount = 4L, Status = EventHubEntityStatus.Active, UserMetadata = "key", - CaptureDescription = new CaptureDescription() + CaptureDescription = new CaptureDescription { Enabled = true, Encoding = EncodingCaptureDescription.Avro, IntervalInSeconds = 120, SizeLimitInBytes = 10485763, - Destination = new EventHubDestination() + Destination = new EventHubDestination { Name = "EventHubArchive.AzureBlockBlob", - Identity = new EventHubsCaptureIdentity() + Identity = new EventHubsCaptureIdentity { IdentityType = EventHubsCaptureIdentityType.UserAssigned, UserAssignedIdentity = "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud2", @@ -101,7 +65,7 @@ public async Task CreateOrUpdate_EventHubCreate() ArchiveNameFormat = "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}", }, }, - RetentionDescription = new RetentionDescription() + RetentionDescription = new RetentionDescription { CleanupPolicy = CleanupPolicyRetentionDescription.Compaction, RetentionTimeInHours = 96L, @@ -152,6 +116,42 @@ public async Task Get_EventHubGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_EventHubsListAll() + { + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubListByNameSpace.json + // this example is just showing the usage of "EventHubs_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EventHubsNamespaceResource created on azure + // for more information of creating EventHubsNamespaceResource, please refer to the document of EventHubsNamespaceResource + string subscriptionId = "e2f361f0-3b27-4503-a9cc-21cfba380093"; + string resourceGroupName = "Default-NotificationHubs-AustraliaEast"; + string namespaceName = "sdk-Namespace-5357"; + ResourceIdentifier eventHubsNamespaceResourceId = EventHubsNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); + EventHubsNamespaceResource eventHubsNamespace = client.GetEventHubsNamespaceResource(eventHubsNamespaceResourceId); + + // get the collection of this EventHubResource + EventHubCollection collection = eventHubsNamespace.GetEventHubs(); + + // invoke the operation and iterate over the result + await foreach (EventHubResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_EventHubGet() diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubResource.cs index 1e490d2728e7d..68e3a5a976c37 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubResource.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_EventHubCreate() + public async Task Get_EventHubGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubCreate.json - // this example is just showing the usage of "EventHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubGet.json + // this example is just showing the usage of "EventHubs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,47 +30,15 @@ public async Task Update_EventHubCreate() // this example assumes you already have this EventHubResource created on azure // for more information of creating EventHubResource, please refer to the document of EventHubResource - string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + string subscriptionId = "e2f361f0-3b27-4503-a9cc-21cfba380093"; string resourceGroupName = "Default-NotificationHubs-AustraliaEast"; - string namespaceName = "sdk-Namespace-5357"; - string eventHubName = "sdk-EventHub-6547"; + string namespaceName = "sdk-Namespace-716"; + string eventHubName = "sdk-EventHub-10"; ResourceIdentifier eventHubResourceId = EventHubResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, eventHubName); EventHubResource eventHub = client.GetEventHubResource(eventHubResourceId); // invoke the operation - EventHubData data = new EventHubData() - { - PartitionCount = 4L, - Status = EventHubEntityStatus.Active, - UserMetadata = "key", - CaptureDescription = new CaptureDescription() - { - Enabled = true, - Encoding = EncodingCaptureDescription.Avro, - IntervalInSeconds = 120, - SizeLimitInBytes = 10485763, - Destination = new EventHubDestination() - { - Name = "EventHubArchive.AzureBlockBlob", - Identity = new EventHubsCaptureIdentity() - { - IdentityType = EventHubsCaptureIdentityType.UserAssigned, - UserAssignedIdentity = "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud2", - }, - StorageAccountResourceId = new ResourceIdentifier("/subscriptions/e2f361f0-3b27-4503-a9cc-21cfba380093/resourceGroups/Default-Storage-SouthCentralUS/providers/Microsoft.ClassicStorage/storageAccounts/arjunteststorage"), - BlobContainer = "container", - ArchiveNameFormat = "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}", - }, - }, - RetentionDescription = new RetentionDescription() - { - CleanupPolicy = CleanupPolicyRetentionDescription.Compaction, - RetentionTimeInHours = 96L, - TombstoneRetentionTimeInHours = 1, - }, - }; - ArmOperation lro = await eventHub.UpdateAsync(WaitUntil.Completed, data); - EventHubResource result = lro.Value; + EventHubResource result = await eventHub.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -108,10 +76,10 @@ public async Task Delete_EventHubDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventHubGet() + public async Task Update_EventHubCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubGet.json - // this example is just showing the usage of "EventHubs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/EventHubs/EHEventHubCreate.json + // this example is just showing the usage of "EventHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,15 +88,47 @@ public async Task Get_EventHubGet() // this example assumes you already have this EventHubResource created on azure // for more information of creating EventHubResource, please refer to the document of EventHubResource - string subscriptionId = "e2f361f0-3b27-4503-a9cc-21cfba380093"; + string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; string resourceGroupName = "Default-NotificationHubs-AustraliaEast"; - string namespaceName = "sdk-Namespace-716"; - string eventHubName = "sdk-EventHub-10"; + string namespaceName = "sdk-Namespace-5357"; + string eventHubName = "sdk-EventHub-6547"; ResourceIdentifier eventHubResourceId = EventHubResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, eventHubName); EventHubResource eventHub = client.GetEventHubResource(eventHubResourceId); // invoke the operation - EventHubResource result = await eventHub.GetAsync(); + EventHubData data = new EventHubData + { + PartitionCount = 4L, + Status = EventHubEntityStatus.Active, + UserMetadata = "key", + CaptureDescription = new CaptureDescription + { + Enabled = true, + Encoding = EncodingCaptureDescription.Avro, + IntervalInSeconds = 120, + SizeLimitInBytes = 10485763, + Destination = new EventHubDestination + { + Name = "EventHubArchive.AzureBlockBlob", + Identity = new EventHubsCaptureIdentity + { + IdentityType = EventHubsCaptureIdentityType.UserAssigned, + UserAssignedIdentity = "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud2", + }, + StorageAccountResourceId = new ResourceIdentifier("/subscriptions/e2f361f0-3b27-4503-a9cc-21cfba380093/resourceGroups/Default-Storage-SouthCentralUS/providers/Microsoft.ClassicStorage/storageAccounts/arjunteststorage"), + BlobContainer = "container", + ArchiveNameFormat = "{Namespace}/{EventHub}/{PartitionId}/{Year}/{Month}/{Day}/{Hour}/{Minute}/{Second}", + }, + }, + RetentionDescription = new RetentionDescription + { + CleanupPolicy = CleanupPolicyRetentionDescription.Compaction, + RetentionTimeInHours = 96L, + TombstoneRetentionTimeInHours = 1, + }, + }; + ArmOperation lro = await eventHub.UpdateAsync(WaitUntil.Completed, data); + EventHubResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsApplicationGroupCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsApplicationGroupCollection.cs index 15cfba11b7bfa..6d6202f764ccd 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsApplicationGroupCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsApplicationGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubsApplicationGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListApplicationGroups() + public async Task CreateOrUpdate_ApplicationGroupCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ApplicationGroup/ApplicationGroupListByNamespace.json - // this example is just showing the usage of "ApplicationGroup_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ApplicationGroup/ApplicationGroupCreate.json + // this example is just showing the usage of "ApplicationGroup_CreateOrUpdateApplicationGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,30 @@ public async Task GetAll_ListApplicationGroups() // get the collection of this EventHubsApplicationGroupResource EventHubsApplicationGroupCollection collection = eventHubsNamespace.GetEventHubsApplicationGroups(); - // invoke the operation and iterate over the result - await foreach (EventHubsApplicationGroupResource item in collection.GetAllAsync()) + // invoke the operation + string applicationGroupName = "appGroup1"; + EventHubsApplicationGroupData data = new EventHubsApplicationGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsApplicationGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsEnabled = true, + ClientAppGroupIdentifier = "SASKeyName=KeyName", + Policies = { new EventHubsThrottlingPolicy("ThrottlingPolicy1", 7912L, EventHubsMetricId.IncomingMessages), new EventHubsThrottlingPolicy("ThrottlingPolicy2", 3951729L, EventHubsMetricId.IncomingBytes), new EventHubsThrottlingPolicy("ThrottlingPolicy3", 245175L, EventHubsMetricId.OutgoingBytes) }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationGroupName, data); + EventHubsApplicationGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsApplicationGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApplicationGroupCreate() + public async Task Get_ApplicationGroupGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ApplicationGroup/ApplicationGroupCreate.json - // this example is just showing the usage of "ApplicationGroup_CreateOrUpdateApplicationGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ApplicationGroup/ApplicationGroupGet.json + // this example is just showing the usage of "ApplicationGroup_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,17 +82,7 @@ public async Task CreateOrUpdate_ApplicationGroupCreate() // invoke the operation string applicationGroupName = "appGroup1"; - EventHubsApplicationGroupData data = new EventHubsApplicationGroupData() - { - IsEnabled = true, - ClientAppGroupIdentifier = "SASKeyName=KeyName", - Policies = -{ -new EventHubsThrottlingPolicy("ThrottlingPolicy1",7912L,EventHubsMetricId.IncomingMessages),new EventHubsThrottlingPolicy("ThrottlingPolicy2",3951729L,EventHubsMetricId.IncomingBytes),new EventHubsThrottlingPolicy("ThrottlingPolicy3",245175L,EventHubsMetricId.OutgoingBytes) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationGroupName, data); - EventHubsApplicationGroupResource result = lro.Value; + EventHubsApplicationGroupResource result = await collection.GetAsync(applicationGroupName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -98,10 +93,10 @@ public async Task CreateOrUpdate_ApplicationGroupCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApplicationGroupGet() + public async Task GetAll_ListApplicationGroups() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ApplicationGroup/ApplicationGroupGet.json - // this example is just showing the usage of "ApplicationGroup_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ApplicationGroup/ApplicationGroupListByNamespace.json + // this example is just showing the usage of "ApplicationGroup_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -119,15 +114,17 @@ public async Task Get_ApplicationGroupGet() // get the collection of this EventHubsApplicationGroupResource EventHubsApplicationGroupCollection collection = eventHubsNamespace.GetEventHubsApplicationGroups(); - // invoke the operation - string applicationGroupName = "appGroup1"; - EventHubsApplicationGroupResource result = await collection.GetAsync(applicationGroupName); + // invoke the operation and iterate over the result + await foreach (EventHubsApplicationGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsApplicationGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsApplicationGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsApplicationGroupResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsApplicationGroupResource.cs index 07ad3442b9185..418febcb9c207 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsApplicationGroupResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsApplicationGroupResource.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubsApplicationGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApplicationGroupCreate() + public async Task Get_ApplicationGroupGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ApplicationGroup/ApplicationGroupCreate.json - // this example is just showing the usage of "ApplicationGroup_CreateOrUpdateApplicationGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ApplicationGroup/ApplicationGroupGet.json + // this example is just showing the usage of "ApplicationGroup_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,7 @@ public async Task Update_ApplicationGroupCreate() EventHubsApplicationGroupResource eventHubsApplicationGroup = client.GetEventHubsApplicationGroupResource(eventHubsApplicationGroupResourceId); // invoke the operation - EventHubsApplicationGroupData data = new EventHubsApplicationGroupData() - { - IsEnabled = true, - ClientAppGroupIdentifier = "SASKeyName=KeyName", - Policies = -{ -new EventHubsThrottlingPolicy("ThrottlingPolicy1",7912L,EventHubsMetricId.IncomingMessages),new EventHubsThrottlingPolicy("ThrottlingPolicy2",3951729L,EventHubsMetricId.IncomingBytes),new EventHubsThrottlingPolicy("ThrottlingPolicy3",245175L,EventHubsMetricId.OutgoingBytes) -}, - }; - ArmOperation lro = await eventHubsApplicationGroup.UpdateAsync(WaitUntil.Completed, data); - EventHubsApplicationGroupResource result = lro.Value; + EventHubsApplicationGroupResource result = await eventHubsApplicationGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,10 +76,10 @@ public async Task Delete_ApplicationGroupDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApplicationGroupGet() + public async Task Update_ApplicationGroupCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ApplicationGroup/ApplicationGroupGet.json - // this example is just showing the usage of "ApplicationGroup_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ApplicationGroup/ApplicationGroupCreate.json + // this example is just showing the usage of "ApplicationGroup_CreateOrUpdateApplicationGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,7 +96,14 @@ public async Task Get_ApplicationGroupGet() EventHubsApplicationGroupResource eventHubsApplicationGroup = client.GetEventHubsApplicationGroupResource(eventHubsApplicationGroupResourceId); // invoke the operation - EventHubsApplicationGroupResource result = await eventHubsApplicationGroup.GetAsync(); + EventHubsApplicationGroupData data = new EventHubsApplicationGroupData + { + IsEnabled = true, + ClientAppGroupIdentifier = "SASKeyName=KeyName", + Policies = { new EventHubsThrottlingPolicy("ThrottlingPolicy1", 7912L, EventHubsMetricId.IncomingMessages), new EventHubsThrottlingPolicy("ThrottlingPolicy2", 3951729L, EventHubsMetricId.IncomingBytes), new EventHubsThrottlingPolicy("ThrottlingPolicy3", 245175L, EventHubsMetricId.OutgoingBytes) }, + }; + ArmOperation lro = await eventHubsApplicationGroup.UpdateAsync(WaitUntil.Completed, data); + EventHubsApplicationGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsClusterCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsClusterCollection.cs index 0bc45cef5ff05..813c7fb2eb440 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsClusterCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsClusterCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_EventHubsClusterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ClustersListByResourceGroup() + public async Task CreateOrUpdate_ClusterPut() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClustersListByResourceGroup.json - // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClusterPut.json + // this example is just showing the usage of "Clusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,28 @@ public async Task GetAll_ClustersListByResourceGroup() // get the collection of this EventHubsClusterResource EventHubsClusterCollection collection = resourceGroupResource.GetEventHubsClusters(); - // invoke the operation and iterate over the result - await foreach (EventHubsClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "testCluster"; + EventHubsClusterData data = new EventHubsClusterData(new AzureLocation("South Central US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new EventHubsClusterSku(EventHubsClusterSkuName.Dedicated) + { + Capacity = 1, + }, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); + EventHubsClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +98,10 @@ public async Task Get_ClusterGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ClusterGet() + public async Task GetAll_ClustersListByResourceGroup() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClusterGet.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClustersListByResourceGroup.json + // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +118,22 @@ public async Task Exists_ClusterGet() // get the collection of this EventHubsClusterResource EventHubsClusterCollection collection = resourceGroupResource.GetEventHubsClusters(); - // invoke the operation - string clusterName = "testCluster"; - bool result = await collection.ExistsAsync(clusterName); + // invoke the operation and iterate over the result + await foreach (EventHubsClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ClusterGet() + public async Task Exists_ClusterGet() { // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClusterGet.json // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +155,17 @@ public async Task GetIfExists_ClusterGet() // invoke the operation string clusterName = "testCluster"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - EventHubsClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ClusterPut() + public async Task GetIfExists_ClusterGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClusterPut.json - // this example is just showing the usage of "Clusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClusterGet.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,26 +184,21 @@ public async Task CreateOrUpdate_ClusterPut() // invoke the operation string clusterName = "testCluster"; - EventHubsClusterData data = new EventHubsClusterData(new AzureLocation("South Central US")) - { - Sku = new EventHubsClusterSku(EventHubsClusterSkuName.Dedicated) - { - Capacity = 1, - }, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); - EventHubsClusterResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + EventHubsClusterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsClusterResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsClusterResource.cs index 8b4bdf2222bc9..e14beb8dca222 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsClusterResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsClusterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.EventHubs.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using NUnit.Framework; @@ -20,68 +19,40 @@ public partial class Sample_EventHubsClusterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAvailableClusterRegionClusters_ListAvailableClusters() - { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ListAvailableClustersGet.json - // this example is just showing the usage of "Clusters_ListAvailableClusterRegion" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AvailableCluster item in subscriptionResource.GetAvailableClusterRegionClustersAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEventHubsClusters_ClustersListBySubscription() + public async Task Get_ClusterGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClustersListBySubscription.json - // this example is just showing the usage of "Clusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClusterGet.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this EventHubsClusterResource created on azure + // for more information of creating EventHubsClusterResource, please refer to the document of EventHubsClusterResource string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "myResourceGroup"; + string clusterName = "testCluster"; + ResourceIdentifier eventHubsClusterResourceId = EventHubsClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + EventHubsClusterResource eventHubsCluster = client.GetEventHubsClusterResource(eventHubsClusterResourceId); - // invoke the operation and iterate over the result - await foreach (EventHubsClusterResource item in subscriptionResource.GetEventHubsClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + EventHubsClusterResource result = await eventHubsCluster.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ClusterGet() + public async Task Delete_ClusterDelete() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClusterGet.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClusterDelete.json + // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,13 +68,9 @@ public async Task Get_ClusterGet() EventHubsClusterResource eventHubsCluster = client.GetEventHubsClusterResource(eventHubsClusterResourceId); // invoke the operation - EventHubsClusterResource result = await eventHubsCluster.GetAsync(); + await eventHubsCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -132,7 +99,7 @@ public async Task Update_ClusterPatch() Tags = { ["tag3"] = "value3", -["tag4"] = "value4", +["tag4"] = "value4" }, }; ArmOperation lro = await eventHubsCluster.UpdateAsync(WaitUntil.Completed, data); @@ -145,32 +112,6 @@ public async Task Update_ClusterPatch() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ClusterDelete() - { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClusterDelete.json - // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this EventHubsClusterResource created on azure - // for more information of creating EventHubsClusterResource, please refer to the document of EventHubsClusterResource - string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - string resourceGroupName = "myResourceGroup"; - string clusterName = "testCluster"; - ResourceIdentifier eventHubsClusterResourceId = EventHubsClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - EventHubsClusterResource eventHubsCluster = client.GetEventHubsClusterResource(eventHubsClusterResourceId); - - // invoke the operation - await eventHubsCluster.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetNamespaces_ListNamespacesInCluster() @@ -221,12 +162,12 @@ public async Task PatchConfiguration_ClustersQuotasConfigurationPatch() EventHubsClusterResource eventHubsCluster = client.GetEventHubsClusterResource(eventHubsClusterResourceId); // invoke the operation - ClusterQuotaConfigurationProperties clusterQuotaConfigurationProperties = new ClusterQuotaConfigurationProperties() + ClusterQuotaConfigurationProperties clusterQuotaConfigurationProperties = new ClusterQuotaConfigurationProperties { Settings = { ["eventhub-per-namespace-quota"] = "20", -["namespaces-per-cluster-quota"] = "200", +["namespaces-per-cluster-quota"] = "200" }, }; ClusterQuotaConfigurationProperties result = await eventHubsCluster.PatchConfigurationAsync(clusterQuotaConfigurationProperties); diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsConsumerGroupCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsConsumerGroupCollection.cs index 028bae2aee496..4c1cbda897721 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsConsumerGroupCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsConsumerGroupCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_ConsumerGroupCreate() // invoke the operation string consumerGroupName = "sdk-ConsumerGroup-5563"; - EventHubsConsumerGroupData data = new EventHubsConsumerGroupData() + EventHubsConsumerGroupData data = new EventHubsConsumerGroupData { UserMetadata = "New consumergroup", }; @@ -92,10 +92,10 @@ public async Task Get_ConsumerGroupGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConsumerGroupGet() + public async Task GetAll_ConsumerGroupsListAll() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ConsumerGroup/EHConsumerGroupGet.json - // this example is just showing the usage of "ConsumerGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ConsumerGroup/EHConsumerGroupListByEventHub.json + // this example is just showing the usage of "ConsumerGroups_ListByEventHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +114,22 @@ public async Task Exists_ConsumerGroupGet() // get the collection of this EventHubsConsumerGroupResource EventHubsConsumerGroupCollection collection = eventHub.GetEventHubsConsumerGroups(); - // invoke the operation - string consumerGroupName = "sdk-ConsumerGroup-5563"; - bool result = await collection.ExistsAsync(consumerGroupName); + // invoke the operation and iterate over the result + await foreach (EventHubsConsumerGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsConsumerGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConsumerGroupGet() + public async Task Exists_ConsumerGroupGet() { // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ConsumerGroup/EHConsumerGroupGet.json // this example is just showing the usage of "ConsumerGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,29 +153,17 @@ public async Task GetIfExists_ConsumerGroupGet() // invoke the operation string consumerGroupName = "sdk-ConsumerGroup-5563"; - NullableResponse response = await collection.GetIfExistsAsync(consumerGroupName); - EventHubsConsumerGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(consumerGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsConsumerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConsumerGroupsListAll() + public async Task GetIfExists_ConsumerGroupGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ConsumerGroup/EHConsumerGroupListByEventHub.json - // this example is just showing the usage of "ConsumerGroups_ListByEventHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ConsumerGroup/EHConsumerGroupGet.json + // this example is just showing the usage of "ConsumerGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_ConsumerGroupsListAll() // get the collection of this EventHubsConsumerGroupResource EventHubsConsumerGroupCollection collection = eventHub.GetEventHubsConsumerGroups(); - // invoke the operation and iterate over the result - await foreach (EventHubsConsumerGroupResource item in collection.GetAllAsync()) + // invoke the operation + string consumerGroupName = "sdk-ConsumerGroup-5563"; + NullableResponse response = await collection.GetIfExistsAsync(consumerGroupName); + EventHubsConsumerGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EventHubsConsumerGroupData resourceData = item.Data; + EventHubsConsumerGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsConsumerGroupResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsConsumerGroupResource.cs index e8b2d23ec9729..41bdf2ba393da 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsConsumerGroupResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsConsumerGroupResource.cs @@ -17,10 +17,10 @@ public partial class Sample_EventHubsConsumerGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConsumerGroupCreate() + public async Task Get_ConsumerGroupGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ConsumerGroup/EHConsumerGroupCreate.json - // this example is just showing the usage of "ConsumerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ConsumerGroup/EHConsumerGroupGet.json + // this example is just showing the usage of "ConsumerGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,12 +38,7 @@ public async Task Update_ConsumerGroupCreate() EventHubsConsumerGroupResource eventHubsConsumerGroup = client.GetEventHubsConsumerGroupResource(eventHubsConsumerGroupResourceId); // invoke the operation - EventHubsConsumerGroupData data = new EventHubsConsumerGroupData() - { - UserMetadata = "New consumergroup", - }; - ArmOperation lro = await eventHubsConsumerGroup.UpdateAsync(WaitUntil.Completed, data); - EventHubsConsumerGroupResource result = lro.Value; + EventHubsConsumerGroupResource result = await eventHubsConsumerGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -82,10 +77,10 @@ public async Task Delete_ConsumerGroupDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConsumerGroupGet() + public async Task Update_ConsumerGroupCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ConsumerGroup/EHConsumerGroupGet.json - // this example is just showing the usage of "ConsumerGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/ConsumerGroup/EHConsumerGroupCreate.json + // this example is just showing the usage of "ConsumerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,7 +98,12 @@ public async Task Get_ConsumerGroupGet() EventHubsConsumerGroupResource eventHubsConsumerGroup = client.GetEventHubsConsumerGroupResource(eventHubsConsumerGroupResourceId); // invoke the operation - EventHubsConsumerGroupResource result = await eventHubsConsumerGroup.GetAsync(); + EventHubsConsumerGroupData data = new EventHubsConsumerGroupData + { + UserMetadata = "New consumergroup", + }; + ArmOperation lro = await eventHubsConsumerGroup.UpdateAsync(WaitUntil.Completed, data); + EventHubsConsumerGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryAuthorizationRuleCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryAuthorizationRuleCollection.cs index d12981f93b3cc..fbc24230f72f4 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryAuthorizationRuleCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryAuthorizationRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_EventHubsDisasterRecoveryAuthorizationRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAuthorizationRules() + public async Task Get_NameSpaceAuthorizationRuleGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListAll.json - // this example is just showing the usage of "DisasterRecoveryConfigs_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleGet.json + // this example is just showing the usage of "DisasterRecoveryConfigs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,32 +32,30 @@ public async Task GetAll_ListAuthorizationRules() string subscriptionId = "exampleSubscriptionId"; string resourceGroupName = "exampleResourceGroup"; string namespaceName = "sdk-Namespace-9080"; - string @alias = "sdk-DisasterRecovery-4047"; + string @alias = "sdk-DisasterRecovery-4879"; ResourceIdentifier eventHubsDisasterRecoveryResourceId = EventHubsDisasterRecoveryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, @alias); EventHubsDisasterRecoveryResource eventHubsDisasterRecovery = client.GetEventHubsDisasterRecoveryResource(eventHubsDisasterRecoveryResourceId); // get the collection of this EventHubsDisasterRecoveryAuthorizationRuleResource EventHubsDisasterRecoveryAuthorizationRuleCollection collection = eventHubsDisasterRecovery.GetEventHubsDisasterRecoveryAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (EventHubsDisasterRecoveryAuthorizationRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsAuthorizationRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string authorizationRuleName = "sdk-Authrules-4879"; + EventHubsDisasterRecoveryAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpaceAuthorizationRuleGet() + public async Task GetAll_ListAuthorizationRules() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleGet.json - // this example is just showing the usage of "DisasterRecoveryConfigs_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasAuthorizationRuleListAll.json + // this example is just showing the usage of "DisasterRecoveryConfigs_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,22 +67,24 @@ public async Task Get_NameSpaceAuthorizationRuleGet() string subscriptionId = "exampleSubscriptionId"; string resourceGroupName = "exampleResourceGroup"; string namespaceName = "sdk-Namespace-9080"; - string @alias = "sdk-DisasterRecovery-4879"; + string @alias = "sdk-DisasterRecovery-4047"; ResourceIdentifier eventHubsDisasterRecoveryResourceId = EventHubsDisasterRecoveryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, @alias); EventHubsDisasterRecoveryResource eventHubsDisasterRecovery = client.GetEventHubsDisasterRecoveryResource(eventHubsDisasterRecoveryResourceId); // get the collection of this EventHubsDisasterRecoveryAuthorizationRuleResource EventHubsDisasterRecoveryAuthorizationRuleCollection collection = eventHubsDisasterRecovery.GetEventHubsDisasterRecoveryAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "sdk-Authrules-4879"; - EventHubsDisasterRecoveryAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (EventHubsDisasterRecoveryAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryCollection.cs index 165c6911556f4..efde233623e68 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_EventHubsDisasterRecoveryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EHAliasList() + public async Task CreateOrUpdate_EHAliasCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasList.json - // this example is just showing the usage of "DisasterRecoveryConfigs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasCreate.json + // this example is just showing the usage of "DisasterRecoveryConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,28 @@ public async Task GetAll_EHAliasList() // get the collection of this EventHubsDisasterRecoveryResource EventHubsDisasterRecoveryCollection collection = eventHubsNamespace.GetEventHubsDisasterRecoveries(); - // invoke the operation and iterate over the result - await foreach (EventHubsDisasterRecoveryResource item in collection.GetAllAsync()) + // invoke the operation + string @alias = "sdk-DisasterRecovery-3814"; + EventHubsDisasterRecoveryData data = new EventHubsDisasterRecoveryData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsDisasterRecoveryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PartnerNamespace = "sdk-Namespace-37", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, @alias, data); + EventHubsDisasterRecoveryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsDisasterRecoveryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EHAliasCreate() + public async Task Get_EHAliasGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasCreate.json - // this example is just showing the usage of "DisasterRecoveryConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasGet.json + // this example is just showing the usage of "DisasterRecoveryConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,12 +79,7 @@ public async Task CreateOrUpdate_EHAliasCreate() // invoke the operation string @alias = "sdk-DisasterRecovery-3814"; - EventHubsDisasterRecoveryData data = new EventHubsDisasterRecoveryData() - { - PartnerNamespace = "sdk-Namespace-37", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, @alias, data); - EventHubsDisasterRecoveryResource result = lro.Value; + EventHubsDisasterRecoveryResource result = await collection.GetAsync(@alias); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +90,10 @@ public async Task CreateOrUpdate_EHAliasCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EHAliasGet() + public async Task GetAll_EHAliasList() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasGet.json - // this example is just showing the usage of "DisasterRecoveryConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasList.json + // this example is just showing the usage of "DisasterRecoveryConfigs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,15 +111,17 @@ public async Task Get_EHAliasGet() // get the collection of this EventHubsDisasterRecoveryResource EventHubsDisasterRecoveryCollection collection = eventHubsNamespace.GetEventHubsDisasterRecoveries(); - // invoke the operation - string @alias = "sdk-DisasterRecovery-3814"; - EventHubsDisasterRecoveryResource result = await collection.GetAsync(@alias); + // invoke the operation and iterate over the result + await foreach (EventHubsDisasterRecoveryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsDisasterRecoveryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsDisasterRecoveryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryResource.cs index 00e1c276636ca..b087b898e25ac 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsDisasterRecoveryResource.cs @@ -17,10 +17,10 @@ public partial class Sample_EventHubsDisasterRecoveryResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_EHAliasCreate() + public async Task Get_EHAliasGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasCreate.json - // this example is just showing the usage of "DisasterRecoveryConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasGet.json + // this example is just showing the usage of "DisasterRecoveryConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,12 +37,7 @@ public async Task Update_EHAliasCreate() EventHubsDisasterRecoveryResource eventHubsDisasterRecovery = client.GetEventHubsDisasterRecoveryResource(eventHubsDisasterRecoveryResourceId); // invoke the operation - EventHubsDisasterRecoveryData data = new EventHubsDisasterRecoveryData() - { - PartnerNamespace = "sdk-Namespace-37", - }; - ArmOperation lro = await eventHubsDisasterRecovery.UpdateAsync(WaitUntil.Completed, data); - EventHubsDisasterRecoveryResource result = lro.Value; + EventHubsDisasterRecoveryResource result = await eventHubsDisasterRecovery.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -80,10 +75,10 @@ public async Task Delete_EHAliasDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EHAliasGet() + public async Task Update_EHAliasCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasGet.json - // this example is just showing the usage of "DisasterRecoveryConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/disasterRecoveryConfigs/EHAliasCreate.json + // this example is just showing the usage of "DisasterRecoveryConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +95,12 @@ public async Task Get_EHAliasGet() EventHubsDisasterRecoveryResource eventHubsDisasterRecovery = client.GetEventHubsDisasterRecoveryResource(eventHubsDisasterRecoveryResourceId); // invoke the operation - EventHubsDisasterRecoveryResource result = await eventHubsDisasterRecovery.GetAsync(); + EventHubsDisasterRecoveryData data = new EventHubsDisasterRecoveryData + { + PartnerNamespace = "sdk-Namespace-37", + }; + ArmOperation lro = await eventHubsDisasterRecovery.UpdateAsync(WaitUntil.Completed, data); + EventHubsDisasterRecoveryResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceAuthorizationRuleCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceAuthorizationRuleCollection.cs index b0c72d4302ee5..32005f7219c1c 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceAuthorizationRuleCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceAuthorizationRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubsNamespaceAuthorizationRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAuthorizationRules() + public async Task CreateOrUpdate_NameSpaceAuthorizationRuleCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListAll.json - // this example is just showing the usage of "Namespaces_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleCreate.json + // this example is just showing the usage of "Namespaces_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_ListAuthorizationRules() // get the collection of this EventHubsNamespaceAuthorizationRuleResource EventHubsNamespaceAuthorizationRuleCollection collection = eventHubsNamespace.GetEventHubsNamespaceAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (EventHubsNamespaceAuthorizationRuleResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationRuleName = "sdk-Authrules-1746"; + EventHubsAuthorizationRuleData data = new EventHubsAuthorizationRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsAuthorizationRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Rights = { EventHubsAccessRight.Listen, EventHubsAccessRight.Send }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); + EventHubsNamespaceAuthorizationRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NameSpaceAuthorizationRuleCreate() + public async Task Get_NameSpaceAuthorizationRuleGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleCreate.json - // this example is just showing the usage of "Namespaces_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleGet.json + // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +80,7 @@ public async Task CreateOrUpdate_NameSpaceAuthorizationRuleCreate() // invoke the operation string authorizationRuleName = "sdk-Authrules-1746"; - EventHubsAuthorizationRuleData data = new EventHubsAuthorizationRuleData() - { - Rights = -{ -EventHubsAccessRight.Listen,EventHubsAccessRight.Send -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); - EventHubsNamespaceAuthorizationRuleResource result = lro.Value; + EventHubsNamespaceAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -96,10 +91,10 @@ public async Task CreateOrUpdate_NameSpaceAuthorizationRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpaceAuthorizationRuleGet() + public async Task GetAll_ListAuthorizationRules() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleGet.json - // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleListAll.json + // this example is just showing the usage of "Namespaces_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,15 +112,17 @@ public async Task Get_NameSpaceAuthorizationRuleGet() // get the collection of this EventHubsNamespaceAuthorizationRuleResource EventHubsNamespaceAuthorizationRuleCollection collection = eventHubsNamespace.GetEventHubsNamespaceAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "sdk-Authrules-1746"; - EventHubsNamespaceAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (EventHubsNamespaceAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceAuthorizationRuleResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceAuthorizationRuleResource.cs index 5165889457355..4852815cf0dc9 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceAuthorizationRuleResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceAuthorizationRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubsNamespaceAuthorizationRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NameSpaceAuthorizationRuleCreate() + public async Task Get_NameSpaceAuthorizationRuleGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleCreate.json - // this example is just showing the usage of "Namespaces_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleGet.json + // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_NameSpaceAuthorizationRuleCreate() EventHubsNamespaceAuthorizationRuleResource eventHubsNamespaceAuthorizationRule = client.GetEventHubsNamespaceAuthorizationRuleResource(eventHubsNamespaceAuthorizationRuleResourceId); // invoke the operation - EventHubsAuthorizationRuleData data = new EventHubsAuthorizationRuleData() - { - Rights = -{ -EventHubsAccessRight.Listen,EventHubsAccessRight.Send -}, - }; - ArmOperation lro = await eventHubsNamespaceAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); - EventHubsNamespaceAuthorizationRuleResource result = lro.Value; + EventHubsNamespaceAuthorizationRuleResource result = await eventHubsNamespaceAuthorizationRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -84,10 +76,10 @@ public async Task Delete_NameSpaceAuthorizationRuleDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpaceAuthorizationRuleGet() + public async Task Update_NameSpaceAuthorizationRuleCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleGet.json - // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceAuthorizationRuleCreate.json + // this example is just showing the usage of "Namespaces_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,7 +96,12 @@ public async Task Get_NameSpaceAuthorizationRuleGet() EventHubsNamespaceAuthorizationRuleResource eventHubsNamespaceAuthorizationRule = client.GetEventHubsNamespaceAuthorizationRuleResource(eventHubsNamespaceAuthorizationRuleResourceId); // invoke the operation - EventHubsNamespaceAuthorizationRuleResource result = await eventHubsNamespaceAuthorizationRule.GetAsync(); + EventHubsAuthorizationRuleData data = new EventHubsAuthorizationRuleData + { + Rights = { EventHubsAccessRight.Listen, EventHubsAccessRight.Send }, + }; + ArmOperation lro = await eventHubsNamespaceAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); + EventHubsNamespaceAuthorizationRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceCollection.cs index 28cdc313563b1..9d9569a44ccb7 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceCollection.cs @@ -18,41 +18,6 @@ namespace Azure.ResourceManager.EventHubs.Samples { public partial class Sample_EventHubsNamespaceCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_NamespaceListByResourceGroup() - { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceListByResourceGroup.json - // this example is just showing the usage of "Namespaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "SampleSubscription"; - string resourceGroupName = "ResurceGroupSample"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this EventHubsNamespaceResource - EventHubsNamespaceCollection collection = resourceGroupResource.GetEventHubsNamespaces(); - - // invoke the operation and iterate over the result - await foreach (EventHubsNamespaceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsNamespaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_NamespaceCreate() @@ -84,21 +49,18 @@ public async Task CreateOrUpdate_NamespaceCreate() UserAssignedIdentities = { [new ResourceIdentifier("/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud1")] = new UserAssignedIdentity(), -[new ResourceIdentifier("/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud2")] = new UserAssignedIdentity() }, }, ClusterArmId = new ResourceIdentifier("/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.EventHub/clusters/enc-test"), - Encryption = new EventHubsEncryption() + Encryption = new EventHubsEncryption { - KeyVaultProperties = -{ -new EventHubsKeyVaultProperties() + KeyVaultProperties = {new EventHubsKeyVaultProperties { KeyName = "Samplekey", KeyVaultUri = new Uri("https://aprao-keyvault-user.vault-int.azure-int.net/"), UserAssignedIdentity = "/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud1", -} -}, +}}, KeySource = EventHubsKeySource.MicrosoftKeyVault, }, }; @@ -145,6 +107,41 @@ public async Task Get_NameSpaceGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_NamespaceListByResourceGroup() + { + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceListByResourceGroup.json + // this example is just showing the usage of "Namespaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "SampleSubscription"; + string resourceGroupName = "ResurceGroupSample"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this EventHubsNamespaceResource + EventHubsNamespaceCollection collection = resourceGroupResource.GetEventHubsNamespaces(); + + // invoke the operation and iterate over the result + await foreach (EventHubsNamespaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsNamespaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_NameSpaceGet() diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceResource.cs index 0243dd09bb414..6ddb0ccd2b1b9 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNamespaceResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.EventHubs.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.EventHubs.Samples @@ -20,41 +19,10 @@ public partial class Sample_EventHubsNamespaceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEventHubsNamespaces_NamespacesListBySubscription() - { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceList.json - // this example is just showing the usage of "Namespaces_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "SampleSubscription"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (EventHubsNamespaceResource item in subscriptionResource.GetEventHubsNamespacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsNamespaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_NameSpaceDelete() + public async Task Get_NameSpaceGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceDelete.json - // this example is just showing the usage of "Namespaces_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceGet.json + // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,17 +38,21 @@ public async Task Delete_NameSpaceDelete() EventHubsNamespaceResource eventHubsNamespace = client.GetEventHubsNamespaceResource(eventHubsNamespaceResourceId); // invoke the operation - await eventHubsNamespace.DeleteAsync(WaitUntil.Completed); + EventHubsNamespaceResource result = await eventHubsNamespace.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsNamespaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpaceGet() + public async Task Delete_NameSpaceDelete() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceGet.json - // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceDelete.json + // this example is just showing the usage of "Namespaces_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,13 +68,9 @@ public async Task Get_NameSpaceGet() EventHubsNamespaceResource eventHubsNamespace = client.GetEventHubsNamespaceResource(eventHubsNamespaceResourceId); // invoke the operation - EventHubsNamespaceResource result = await eventHubsNamespace.GetAsync(); + await eventHubsNamespace.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsNamespaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -132,7 +100,7 @@ public async Task Update_NamespacesUpdate() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud2")] = null, +[new ResourceIdentifier("/subscriptions/SampleSubscription/resourceGroups/ResurceGroupSample/providers/Microsoft.ManagedIdentity/userAssignedIdentities/ud2")] = new UserAssignedIdentity() }, }, }; @@ -145,31 +113,6 @@ [new ResourceIdentifier("/subscriptions/SampleSubscription/resourceGroups/Resurc Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckEventHubsNamespaceNameAvailability_NamespacesCheckNameAvailability() - { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceCheckNameAvailability.json - // this example is just showing the usage of "Namespaces_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - EventHubsNameAvailabilityContent content = new EventHubsNameAvailabilityContent("sdk-Namespace-8458"); - EventHubsNameAvailabilityResult result = await subscriptionResource.CheckEventHubsNamespaceNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetPrivateLinkResources_NameSpacePrivateLinkResourcesGet() diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNetworkRuleSetResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNetworkRuleSetResource.cs index 7e5f23f3155c3..0393d622e2152 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNetworkRuleSetResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsNetworkRuleSetResource.cs @@ -16,6 +16,36 @@ namespace Azure.ResourceManager.EventHubs.Samples { public partial class Sample_EventHubsNetworkRuleSetResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NameSpaceNetworkRuleSetGet() + { + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetGet.json + // this example is just showing the usage of "Namespaces_GetNetworkRuleSet" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EventHubsNetworkRuleSetResource created on azure + // for more information of creating EventHubsNetworkRuleSetResource, please refer to the document of EventHubsNetworkRuleSetResource + string subscriptionId = "Subscription"; + string resourceGroupName = "ResourceGroup"; + string namespaceName = "sdk-Namespace-6019"; + ResourceIdentifier eventHubsNetworkRuleSetResourceId = EventHubsNetworkRuleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); + EventHubsNetworkRuleSetResource eventHubsNetworkRuleSet = client.GetEventHubsNetworkRuleSetResource(eventHubsNetworkRuleSetResourceId); + + // invoke the operation + EventHubsNetworkRuleSetResource result = await eventHubsNetworkRuleSet.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsNetworkRuleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_NameSpaceNetworkRuleSetCreate() @@ -37,49 +67,43 @@ public async Task CreateOrUpdate_NameSpaceNetworkRuleSetCreate() EventHubsNetworkRuleSetResource eventHubsNetworkRuleSet = client.GetEventHubsNetworkRuleSetResource(eventHubsNetworkRuleSetResourceId); // invoke the operation - EventHubsNetworkRuleSetData data = new EventHubsNetworkRuleSetData() + EventHubsNetworkRuleSetData data = new EventHubsNetworkRuleSetData { DefaultAction = EventHubsNetworkRuleSetDefaultAction.Deny, - VirtualNetworkRules = -{ -new EventHubsNetworkRuleSetVirtualNetworkRules() + VirtualNetworkRules = {new EventHubsNetworkRuleSetVirtualNetworkRules { SubnetId = new ResourceIdentifier("/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet2"), IgnoreMissingVnetServiceEndpoint = true, -},new EventHubsNetworkRuleSetVirtualNetworkRules() +}, new EventHubsNetworkRuleSetVirtualNetworkRules { SubnetId = new ResourceIdentifier("/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet3"), IgnoreMissingVnetServiceEndpoint = false, -},new EventHubsNetworkRuleSetVirtualNetworkRules() +}, new EventHubsNetworkRuleSetVirtualNetworkRules { SubnetId = new ResourceIdentifier("/subscriptions/subscriptionid/resourcegroups/resourcegroupid/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet6"), IgnoreMissingVnetServiceEndpoint = false, -} -}, - IPRules = -{ -new EventHubsNetworkRuleSetIPRules() +}}, + IPRules = {new EventHubsNetworkRuleSetIPRules { IPMask = "1.1.1.1", Action = EventHubsNetworkRuleIPAction.Allow, -},new EventHubsNetworkRuleSetIPRules() +}, new EventHubsNetworkRuleSetIPRules { IPMask = "1.1.1.2", Action = EventHubsNetworkRuleIPAction.Allow, -},new EventHubsNetworkRuleSetIPRules() +}, new EventHubsNetworkRuleSetIPRules { IPMask = "1.1.1.3", Action = EventHubsNetworkRuleIPAction.Allow, -},new EventHubsNetworkRuleSetIPRules() +}, new EventHubsNetworkRuleSetIPRules { IPMask = "1.1.1.4", Action = EventHubsNetworkRuleIPAction.Allow, -},new EventHubsNetworkRuleSetIPRules() +}, new EventHubsNetworkRuleSetIPRules { IPMask = "1.1.1.5", Action = EventHubsNetworkRuleIPAction.Allow, -} -}, +}}, }; ArmOperation lro = await eventHubsNetworkRuleSet.CreateOrUpdateAsync(WaitUntil.Completed, data); EventHubsNetworkRuleSetResource result = lro.Value; @@ -90,35 +114,5 @@ public async Task CreateOrUpdate_NameSpaceNetworkRuleSetCreate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpaceNetworkRuleSetGet() - { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/VirtualNetworkRule/EHNetworkRuleSetGet.json - // this example is just showing the usage of "Namespaces_GetNetworkRuleSet" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this EventHubsNetworkRuleSetResource created on azure - // for more information of creating EventHubsNetworkRuleSetResource, please refer to the document of EventHubsNetworkRuleSetResource - string subscriptionId = "Subscription"; - string resourceGroupName = "ResourceGroup"; - string namespaceName = "sdk-Namespace-6019"; - ResourceIdentifier eventHubsNetworkRuleSetResourceId = EventHubsNetworkRuleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); - EventHubsNetworkRuleSetResource eventHubsNetworkRuleSet = client.GetEventHubsNetworkRuleSetResource(eventHubsNetworkRuleSetResourceId); - - // invoke the operation - EventHubsNetworkRuleSetResource result = await eventHubsNetworkRuleSet.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsNetworkRuleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsPrivateEndpointConnectionCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsPrivateEndpointConnectionCollection.cs index ffaa35c6894e8..8d13423c5ee4e 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsPrivateEndpointConnectionCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsPrivateEndpointConnectionCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.EventHubs.Samples { public partial class Sample_EventHubsPrivateEndpointConnectionCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndPointConnectionList() - { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/PrivateEndPointConnectionList.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this EventHubsNamespaceResource created on azure - // for more information of creating EventHubsNamespaceResource, please refer to the document of EventHubsNamespaceResource - string subscriptionId = "subID"; - string resourceGroupName = "SDK-EventHub-4794"; - string namespaceName = "sdk-Namespace-5828"; - ResourceIdentifier eventHubsNamespaceResourceId = EventHubsNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); - EventHubsNamespaceResource eventHubsNamespace = client.GetEventHubsNamespaceResource(eventHubsNamespaceResourceId); - - // get the collection of this EventHubsPrivateEndpointConnectionResource - EventHubsPrivateEndpointConnectionCollection collection = eventHubsNamespace.GetEventHubsPrivateEndpointConnections(); - - // invoke the operation and iterate over the result - await foreach (EventHubsPrivateEndpointConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_NameSpacePrivateEndPointConnectionCreate() @@ -77,10 +41,10 @@ public async Task CreateOrUpdate_NameSpacePrivateEndPointConnectionCreate() // invoke the operation string privateEndpointConnectionName = "privateEndpointConnectionName"; - EventHubsPrivateEndpointConnectionData data = new EventHubsPrivateEndpointConnectionData() + EventHubsPrivateEndpointConnectionData data = new EventHubsPrivateEndpointConnectionData { PrivateEndpointId = new ResourceIdentifier("/subscriptions/dbedb4e0-40e6-4145-81f3-f1314c150774/resourceGroups/SDK-EventHub-8396/providers/Microsoft.Network/privateEndpoints/sdk-Namespace-2847"), - ConnectionState = new EventHubsPrivateLinkServiceConnectionState() + ConnectionState = new EventHubsPrivateLinkServiceConnectionState { Status = EventHubsPrivateLinkConnectionStatus.Rejected, Description = "testing", @@ -131,6 +95,42 @@ public async Task Get_NameSpacePrivateEndPointConnectionGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_PrivateEndPointConnectionList() + { + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/PrivateEndPointConnectionList.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this EventHubsNamespaceResource created on azure + // for more information of creating EventHubsNamespaceResource, please refer to the document of EventHubsNamespaceResource + string subscriptionId = "subID"; + string resourceGroupName = "SDK-EventHub-4794"; + string namespaceName = "sdk-Namespace-5828"; + ResourceIdentifier eventHubsNamespaceResourceId = EventHubsNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); + EventHubsNamespaceResource eventHubsNamespace = client.GetEventHubsNamespaceResource(eventHubsNamespaceResourceId); + + // get the collection of this EventHubsPrivateEndpointConnectionResource + EventHubsPrivateEndpointConnectionCollection collection = eventHubsNamespace.GetEventHubsPrivateEndpointConnections(); + + // invoke the operation and iterate over the result + await foreach (EventHubsPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_NameSpacePrivateEndPointConnectionGet() diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsPrivateEndpointConnectionResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsPrivateEndpointConnectionResource.cs index 70c07e3f5e847..3efa8e8e5bfee 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsPrivateEndpointConnectionResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubsPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NameSpacePrivateEndPointConnectionCreate() + public async Task Get_NameSpacePrivateEndPointConnectionGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/PrivateEndPointConnectionCreate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/PrivateEndPointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,25 +31,14 @@ public async Task Update_NameSpacePrivateEndPointConnectionCreate() // this example assumes you already have this EventHubsPrivateEndpointConnectionResource created on azure // for more information of creating EventHubsPrivateEndpointConnectionResource, please refer to the document of EventHubsPrivateEndpointConnectionResource string subscriptionId = "subID"; - string resourceGroupName = "ArunMonocle"; - string namespaceName = "sdk-Namespace-2924"; + string resourceGroupName = "SDK-EventHub-4794"; + string namespaceName = "sdk-Namespace-5828"; string privateEndpointConnectionName = "privateEndpointConnectionName"; ResourceIdentifier eventHubsPrivateEndpointConnectionResourceId = EventHubsPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName); EventHubsPrivateEndpointConnectionResource eventHubsPrivateEndpointConnection = client.GetEventHubsPrivateEndpointConnectionResource(eventHubsPrivateEndpointConnectionResourceId); // invoke the operation - EventHubsPrivateEndpointConnectionData data = new EventHubsPrivateEndpointConnectionData() - { - PrivateEndpointId = new ResourceIdentifier("/subscriptions/dbedb4e0-40e6-4145-81f3-f1314c150774/resourceGroups/SDK-EventHub-8396/providers/Microsoft.Network/privateEndpoints/sdk-Namespace-2847"), - ConnectionState = new EventHubsPrivateLinkServiceConnectionState() - { - Status = EventHubsPrivateLinkConnectionStatus.Rejected, - Description = "testing", - }, - ProvisioningState = EventHubsPrivateEndpointConnectionProvisioningState.Succeeded, - }; - ArmOperation lro = await eventHubsPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - EventHubsPrivateEndpointConnectionResource result = lro.Value; + EventHubsPrivateEndpointConnectionResource result = await eventHubsPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,10 +76,10 @@ public async Task Delete_NameSpacePrivateEndPointConnectionDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpacePrivateEndPointConnectionGet() + public async Task Update_NameSpacePrivateEndPointConnectionCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/PrivateEndPointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/PrivateEndPointConnectionCreate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,14 +89,25 @@ public async Task Get_NameSpacePrivateEndPointConnectionGet() // this example assumes you already have this EventHubsPrivateEndpointConnectionResource created on azure // for more information of creating EventHubsPrivateEndpointConnectionResource, please refer to the document of EventHubsPrivateEndpointConnectionResource string subscriptionId = "subID"; - string resourceGroupName = "SDK-EventHub-4794"; - string namespaceName = "sdk-Namespace-5828"; + string resourceGroupName = "ArunMonocle"; + string namespaceName = "sdk-Namespace-2924"; string privateEndpointConnectionName = "privateEndpointConnectionName"; ResourceIdentifier eventHubsPrivateEndpointConnectionResourceId = EventHubsPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName); EventHubsPrivateEndpointConnectionResource eventHubsPrivateEndpointConnection = client.GetEventHubsPrivateEndpointConnectionResource(eventHubsPrivateEndpointConnectionResourceId); // invoke the operation - EventHubsPrivateEndpointConnectionResource result = await eventHubsPrivateEndpointConnection.GetAsync(); + EventHubsPrivateEndpointConnectionData data = new EventHubsPrivateEndpointConnectionData + { + PrivateEndpointId = new ResourceIdentifier("/subscriptions/dbedb4e0-40e6-4145-81f3-f1314c150774/resourceGroups/SDK-EventHub-8396/providers/Microsoft.Network/privateEndpoints/sdk-Namespace-2847"), + ConnectionState = new EventHubsPrivateLinkServiceConnectionState + { + Status = EventHubsPrivateLinkConnectionStatus.Rejected, + Description = "testing", + }, + ProvisioningState = EventHubsPrivateEndpointConnectionProvisioningState.Succeeded, + }; + ArmOperation lro = await eventHubsPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + EventHubsPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsSchemaGroupCollection.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsSchemaGroupCollection.cs index 574b9c226132f..86aa348f82fa7 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsSchemaGroupCollection.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsSchemaGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubsSchemaGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SchemaRegistryListAll() + public async Task CreateOrUpdate_SchemaRegistryCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/SchemaRegistry/SchemaRegistryListByNamespace.json - // this example is just showing the usage of "SchemaRegistry_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/SchemaRegistry/SchemaRegistryCreate.json + // this example is just showing the usage of "SchemaRegistry_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,30 @@ public async Task GetAll_SchemaRegistryListAll() // get the collection of this EventHubsSchemaGroupResource EventHubsSchemaGroupCollection collection = eventHubsNamespace.GetEventHubsSchemaGroups(); - // invoke the operation and iterate over the result - await foreach (EventHubsSchemaGroupResource item in collection.GetAllAsync()) + // invoke the operation + string schemaGroupName = "testSchemaGroup1"; + EventHubsSchemaGroupData data = new EventHubsSchemaGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsSchemaGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + GroupProperties = { }, + SchemaCompatibility = EventHubsSchemaCompatibility.Forward, + SchemaType = EventHubsSchemaType.Avro, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaGroupName, data); + EventHubsSchemaGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsSchemaGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SchemaRegistryCreate() + public async Task Get_SchemaRegistryGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/SchemaRegistry/SchemaRegistryCreate.json - // this example is just showing the usage of "SchemaRegistry_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/SchemaRegistry/SchemaRegistryGet.json + // this example is just showing the usage of "SchemaRegistry_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,16 +82,7 @@ public async Task CreateOrUpdate_SchemaRegistryCreate() // invoke the operation string schemaGroupName = "testSchemaGroup1"; - EventHubsSchemaGroupData data = new EventHubsSchemaGroupData() - { - GroupProperties = -{ -}, - SchemaCompatibility = EventHubsSchemaCompatibility.Forward, - SchemaType = EventHubsSchemaType.Avro, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaGroupName, data); - EventHubsSchemaGroupResource result = lro.Value; + EventHubsSchemaGroupResource result = await collection.GetAsync(schemaGroupName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -97,10 +93,10 @@ public async Task CreateOrUpdate_SchemaRegistryCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SchemaRegistryGet() + public async Task GetAll_SchemaRegistryListAll() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/SchemaRegistry/SchemaRegistryGet.json - // this example is just showing the usage of "SchemaRegistry_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/SchemaRegistry/SchemaRegistryListByNamespace.json + // this example is just showing the usage of "SchemaRegistry_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,15 +114,17 @@ public async Task Get_SchemaRegistryGet() // get the collection of this EventHubsSchemaGroupResource EventHubsSchemaGroupCollection collection = eventHubsNamespace.GetEventHubsSchemaGroups(); - // invoke the operation - string schemaGroupName = "testSchemaGroup1"; - EventHubsSchemaGroupResource result = await collection.GetAsync(schemaGroupName); + // invoke the operation and iterate over the result + await foreach (EventHubsSchemaGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsSchemaGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubsSchemaGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsSchemaGroupResource.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsSchemaGroupResource.cs index e4b926d546962..7755b9ae8c13c 100644 --- a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsSchemaGroupResource.cs +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_EventHubsSchemaGroupResource.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubsSchemaGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SchemaRegistryCreate() + public async Task Get_SchemaRegistryGet() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/SchemaRegistry/SchemaRegistryCreate.json - // this example is just showing the usage of "SchemaRegistry_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/SchemaRegistry/SchemaRegistryGet.json + // this example is just showing the usage of "SchemaRegistry_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,7 @@ public async Task Update_SchemaRegistryCreate() EventHubsSchemaGroupResource eventHubsSchemaGroup = client.GetEventHubsSchemaGroupResource(eventHubsSchemaGroupResourceId); // invoke the operation - EventHubsSchemaGroupData data = new EventHubsSchemaGroupData() - { - GroupProperties = -{ -}, - SchemaCompatibility = EventHubsSchemaCompatibility.Forward, - SchemaType = EventHubsSchemaType.Avro, - }; - ArmOperation lro = await eventHubsSchemaGroup.UpdateAsync(WaitUntil.Completed, data); - EventHubsSchemaGroupResource result = lro.Value; + EventHubsSchemaGroupResource result = await eventHubsSchemaGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,10 +76,10 @@ public async Task Delete_SchemaRegistryDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SchemaRegistryGet() + public async Task Update_SchemaRegistryCreate() { - // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/SchemaRegistry/SchemaRegistryGet.json - // this example is just showing the usage of "SchemaRegistry_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/SchemaRegistry/SchemaRegistryCreate.json + // this example is just showing the usage of "SchemaRegistry_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,7 +96,14 @@ public async Task Get_SchemaRegistryGet() EventHubsSchemaGroupResource eventHubsSchemaGroup = client.GetEventHubsSchemaGroupResource(eventHubsSchemaGroupResourceId); // invoke the operation - EventHubsSchemaGroupResource result = await eventHubsSchemaGroup.GetAsync(); + EventHubsSchemaGroupData data = new EventHubsSchemaGroupData + { + GroupProperties = { }, + SchemaCompatibility = EventHubsSchemaCompatibility.Forward, + SchemaType = EventHubsSchemaType.Avro, + }; + ArmOperation lro = await eventHubsSchemaGroup.UpdateAsync(WaitUntil.Completed, data); + EventHubsSchemaGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..3336ac3189d74 --- /dev/null +++ b/sdk/eventhub/Azure.ResourceManager.EventHubs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.EventHubs.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.EventHubs.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAvailableClusterRegionClusters_ListAvailableClusters() + { + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ListAvailableClustersGet.json + // this example is just showing the usage of "Clusters_ListAvailableClusterRegion" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AvailableCluster item in subscriptionResource.GetAvailableClusterRegionClustersAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEventHubsClusters_ClustersListBySubscription() + { + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/Clusters/ClustersListBySubscription.json + // this example is just showing the usage of "Clusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EventHubsClusterResource item in subscriptionResource.GetEventHubsClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEventHubsNamespaces_NamespacesListBySubscription() + { + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceList.json + // this example is just showing the usage of "Namespaces_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "SampleSubscription"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EventHubsNamespaceResource item in subscriptionResource.GetEventHubsNamespacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubsNamespaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckEventHubsNamespaceNameAvailability_NamespacesCheckNameAvailability() + { + // Generated from example definition: specification/eventhub/resource-manager/Microsoft.EventHub/stable/2024-01-01/examples/NameSpaces/EHNameSpaceCheckNameAvailability.json + // this example is just showing the usage of "Namespaces_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + EventHubsNameAvailabilityContent content = new EventHubsNameAvailabilityContent("sdk-Namespace-8458"); + EventHubsNameAvailabilityResult result = await subscriptionResource.CheckEventHubsNamespaceNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationCollection.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationCollection.cs index dadc47cf2d4e8..99748144a8447 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationCollection.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_CustomLocationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCustomLocationsByResourceGroup() + public async Task CreateOrUpdate_CreateUpdateCustomLocation() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsListByResourceGroup.json - // this example is just showing the usage of "CustomLocations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsCreate_Update.json + // this example is just showing the usage of "CustomLocations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,29 @@ public async Task GetAll_ListCustomLocationsByResourceGroup() // get the collection of this CustomLocationResource CustomLocationCollection collection = resourceGroupResource.GetCustomLocations(); - // invoke the operation and iterate over the result - await foreach (CustomLocationResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "customLocation01"; + CustomLocationData data = new CustomLocationData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomLocationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("SystemAssigned"), + Authentication = new CustomLocationAuthentication + { + CustomLocationPropertiesAuthenticationType = "KubeConfig", + Value = "", + }, + ClusterExtensionIds = { new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedCluster/someCluster/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension") }, + DisplayName = "customLocationLocation01", + HostResourceId = new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), + Namespace = "namespace01", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + CustomLocationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomLocationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +100,10 @@ public async Task Get_GetCustomLocation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCustomLocation() + public async Task GetAll_ListCustomLocationsByResourceGroup() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsGet.json - // this example is just showing the usage of "CustomLocations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsListByResourceGroup.json + // this example is just showing the usage of "CustomLocations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +120,22 @@ public async Task Exists_GetCustomLocation() // get the collection of this CustomLocationResource CustomLocationCollection collection = resourceGroupResource.GetCustomLocations(); - // invoke the operation - string resourceName = "customLocation01"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (CustomLocationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomLocationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCustomLocation() + public async Task Exists_GetCustomLocation() { // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsGet.json // this example is just showing the usage of "CustomLocations_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +157,17 @@ public async Task GetIfExists_GetCustomLocation() // invoke the operation string resourceName = "customLocation01"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - CustomLocationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomLocationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateUpdateCustomLocation() + public async Task GetIfExists_GetCustomLocation() { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsCreate_Update.json - // this example is just showing the usage of "CustomLocations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsGet.json + // this example is just showing the usage of "CustomLocations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,30 +186,21 @@ public async Task CreateOrUpdate_CreateUpdateCustomLocation() // invoke the operation string resourceName = "customLocation01"; - CustomLocationData data = new CustomLocationData(new AzureLocation("West US")) - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - Authentication = new CustomLocationAuthentication() - { - CustomLocationPropertiesAuthenticationType = "KubeConfig", - Value = "", - }, - ClusterExtensionIds = -{ -new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Kubernetes/connectedCluster/someCluster/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension") -}, - DisplayName = "customLocationLocation01", - HostResourceId = new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01"), - Namespace = "namespace01", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - CustomLocationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + CustomLocationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomLocationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomLocationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationResource.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationResource.cs index 0f9816213d8ef..c74e8ba2a4e47 100644 --- a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationResource.cs +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_CustomLocationResource.cs @@ -11,44 +11,12 @@ using Azure.Identity; using Azure.ResourceManager.ExtendedLocations.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ExtendedLocations.Samples { public partial class Sample_CustomLocationResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCustomLocations_ListCustomLocationsBySubscription() - { - // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsListBySubscription.json - // this example is just showing the usage of "CustomLocations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "11111111-2222-3333-4444-555555555555"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CustomLocationResource item in subscriptionResource.GetCustomLocationsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomLocationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetCustomLocation() @@ -126,18 +94,15 @@ public async Task Update_UpdateCustomLocation() CustomLocationResource customLocation = client.GetCustomLocationResource(customLocationResourceId); // invoke the operation - CustomLocationPatch patch = new CustomLocationPatch() + CustomLocationPatch patch = new CustomLocationPatch { Identity = new ManagedServiceIdentity("SystemAssigned"), Tags = { ["archv3"] = "", -["tier"] = "testing", -}, - ClusterExtensionIds = -{ -new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension"),new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/barExtension") +["tier"] = "testing" }, + ClusterExtensionIds = { new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/fooExtension"), new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/testresourcegroup/providers/Microsoft.ContainerService/managedClusters/cluster01/Microsoft.KubernetesConfiguration/clusterExtensions/barExtension") }, }; CustomLocationResource result = await customLocation.UpdateAsync(patch); diff --git a/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..8326fe5dd005f --- /dev/null +++ b/sdk/extendedlocation/Azure.ResourceManager.ExtendedLocations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ExtendedLocations.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCustomLocations_ListCustomLocationsBySubscription() + { + // Generated from example definition: specification/extendedlocation/resource-manager/Microsoft.ExtendedLocation/stable/2021-08-15/examples/CustomLocationsListBySubscription.json + // this example is just showing the usage of "CustomLocations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CustomLocationResource item in subscriptionResource.GetCustomLocationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomLocationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} From 2d73356cd1a7ed6cbaf64ddb36ba740fa816ac1e Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 03:55:26 +0000 Subject: [PATCH 05/11] Update SDK code pr_sc_7 --- .../Sample_PurviewAccountCollection.cs | 102 +- .../Samples/Sample_PurviewAccountResource.cs | 76 +- ...ple_PurviewKafkaConfigurationCollection.cs | 118 +- ...ample_PurviewKafkaConfigurationResource.cs | 58 +- ...viewPrivateEndpointConnectionCollection.cs | 108 +- ...urviewPrivateEndpointConnectionResource.cs | 46 +- ...le_PurviewPrivateLinkResourceCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 67 +- .../Sample_TenantResourceExtensions.cs | 15 +- .../Sample_QuantumWorkspaceCollection.cs | 119 +- .../Sample_QuantumWorkspaceResource.cs | 81 +- .../Sample_SubscriptionResourceExtensions.cs | 33 +- .../Sample_QumuloFileSystemResource.cs | 164 +- ...mple_QumuloFileSystemResourceCollection.cs | 275 +-- .../Sample_SubscriptionResourceExtensions.cs | 81 + .../Sample_CurrentQuotaLimitBaseCollection.cs | 430 ++--- .../Sample_CurrentQuotaLimitBaseResource.cs | 12 +- .../Sample_CurrentUsagesBaseCollection.cs | 238 +-- .../Sample_GroupQuotaEnforcementCollection.cs | 70 +- .../Sample_GroupQuotaEnforcementResource.cs | 32 +- .../Sample_GroupQuotaEntityCollection.cs | 68 +- .../Sample_GroupQuotaEntityResource.cs | 70 +- .../Sample_GroupQuotaLimitCollection.cs | 62 +- ...Sample_GroupQuotaSubscriptionCollection.cs | 62 +- ...uotaSubscriptionRequestStatusCollection.cs | 48 +- .../Sample_GroupQuotaSubscriptionResource.cs | 18 +- ...ample_ManagementGroupResourceExtensions.cs | 137 ++ ...le_QuotaAllocationRequestStatusResource.cs | 119 -- .../Sample_QuotaRequestDetailCollection.cs | 208 +-- ...e_SubscriptionQuotaAllocationCollection.cs | 48 +- .../Sample_TenantResourceExtensions.cs | 5 +- .../Samples/Sample_BackupEngineCollection.cs | 48 +- .../Samples/Sample_BackupJobCollection.cs | 62 +- ...ckupPrivateEndpointConnectionCollection.cs | 95 +- ...BackupPrivateEndpointConnectionResource.cs | 61 +- .../Sample_BackupProtectedItemCollection.cs | 190 +- .../Sample_BackupProtectedItemResource.cs | 75 +- ...ple_BackupProtectionContainerCollection.cs | 92 +- ...ample_BackupProtectionContainerResource.cs | 88 +- ...Sample_BackupProtectionIntentCollection.cs | 84 +- .../Sample_BackupProtectionIntentResource.cs | 81 +- ...Sample_BackupProtectionPolicyCollection.cs | 1646 +++++++---------- .../Sample_BackupProtectionPolicyResource.cs | 674 +++---- .../Sample_BackupRecoveryPointCollection.cs | 48 +- .../Sample_BackupRecoveryPointResource.cs | 118 +- .../Sample_BackupResourceConfigCollection.cs | 80 +- .../Sample_BackupResourceConfigResource.cs | 4 +- ...ourceEncryptionConfigExtendedCollection.cs | 78 +- ...esourceEncryptionConfigExtendedResource.cs | 4 +- ...ple_BackupResourceVaultConfigCollection.cs | 80 +- ...ample_BackupResourceVaultConfigResource.cs | 4 +- .../Sample_ResourceGroupResourceExtensions.cs | 35 +- .../Sample_ResourceGuardProxyCollection.cs | 96 +- .../Sample_ResourceGuardProxyResource.cs | 45 +- .../Sample_SubscriptionResourceExtensions.cs | 36 +- .../Sample_DataReplicationDraCollection.cs | 84 +- .../Sample_DataReplicationDraResource.cs | 32 +- ...ReplicationEmailConfigurationCollection.cs | 95 +- ...taReplicationEmailConfigurationResource.cs | 5 +- .../Sample_DataReplicationEventCollection.cs | 66 +- .../Sample_DataReplicationFabricCollection.cs | 98 +- .../Sample_DataReplicationFabricResource.cs | 77 +- .../Sample_DataReplicationPolicyCollection.cs | 88 +- .../Sample_DataReplicationPolicyResource.cs | 36 +- ..._DataReplicationProtectedItemCollection.cs | 84 +- ...le_DataReplicationProtectedItemResource.cs | 34 +- ..._DataReplicationRecoveryPointCollection.cs | 62 +- ...plicationReplicationExtensionCollection.cs | 84 +- ...ReplicationReplicationExtensionResource.cs | 32 +- .../Sample_DataReplicationVaultCollection.cs | 106 +- .../Sample_DataReplicationVaultResource.cs | 83 +- ...ample_DataReplicationWorkflowCollection.cs | 66 +- .../Sample_ResourceGroupResourceExtensions.cs | 9 +- .../Sample_SubscriptionResourceExtensions.cs | 66 +- ...Sample_MigrationRecoveryPointCollection.cs | 48 +- ...le_ProtectionContainerMappingCollection.cs | 48 +- ...mple_ProtectionContainerMappingResource.cs | 38 +- ..._ReplicationEligibilityResultCollection.cs | 50 +- ...mple_ReplicationProtectedItemCollection.cs | 106 +- ...Sample_ReplicationProtectedItemResource.cs | 101 +- ...e_ReplicationProtectionIntentCollection.cs | 106 +- ...ple_ReplicationProtectionIntentResource.cs | 10 +- .../Sample_ResourceGroupResourceExtensions.cs | 330 ++++ .../Sample_SiteRecoveryAlertCollection.cs | 109 +- .../Sample_SiteRecoveryAlertResource.cs | 9 +- .../Sample_SiteRecoveryEventCollection.cs | 48 +- .../Sample_SiteRecoveryFabricCollection.cs | 48 +- .../Sample_SiteRecoveryFabricResource.cs | 11 +- .../Sample_SiteRecoveryJobCollection.cs | 48 +- .../Samples/Sample_SiteRecoveryJobResource.cs | 2 +- ...le_SiteRecoveryLogicalNetworkCollection.cs | 48 +- ...ple_SiteRecoveryMigrationItemCollection.cs | 102 +- ...ample_SiteRecoveryMigrationItemResource.cs | 40 +- .../Sample_SiteRecoveryNetworkCollection.cs | 48 +- ...le_SiteRecoveryNetworkMappingCollection.cs | 98 +- ...mple_SiteRecoveryNetworkMappingResource.cs | 38 +- .../Sample_SiteRecoveryNetworkResource.cs | 34 - .../Sample_SiteRecoveryPointCollection.cs | 48 +- .../Sample_SiteRecoveryPolicyCollection.cs | 96 +- .../Sample_SiteRecoveryPolicyResource.cs | 2 +- ...e_SiteRecoveryProtectableItemCollection.cs | 48 +- ...teRecoveryProtectionContainerCollection.cs | 48 +- ...SiteRecoveryProtectionContainerResource.cs | 42 +- ...mple_SiteRecoveryRecoveryPlanCollection.cs | 125 +- ...Sample_SiteRecoveryRecoveryPlanResource.cs | 86 +- ..._SiteRecoveryServicesProviderCollection.cs | 108 +- ...le_SiteRecoveryServicesProviderResource.cs | 34 - .../Sample_SiteRecoveryVCenterCollection.cs | 110 +- .../Sample_SiteRecoveryVCenterResource.cs | 38 +- ...mple_SiteRecoveryVaultSettingCollection.cs | 96 +- ...Sample_SiteRecoveryVaultSettingResource.cs | 2 +- .../Sample_StorageClassificationCollection.cs | 48 +- ..._StorageClassificationMappingCollection.cs | 96 +- ...le_StorageClassificationMappingResource.cs | 70 +- .../Sample_StorageClassificationResource.cs | 34 - ...ryServicesPrivateLinkResourceCollection.cs | 48 +- .../Sample_RecoveryServicesVaultCollection.cs | 272 +-- ...coveryServicesVaultExtendedInfoResource.cs | 14 +- .../Sample_RecoveryServicesVaultResource.cs | 265 ++- .../Sample_ResourceGroupResourceExtensions.cs | 4 +- .../Sample_SubscriptionResourceExtensions.cs | 40 +- ...isCacheAccessPolicyAssignmentCollection.cs | 64 +- ...edisCacheAccessPolicyAssignmentResource.cs | 30 +- ...Sample_RedisCacheAccessPolicyCollection.cs | 64 +- .../Sample_RedisCacheAccessPolicyResource.cs | 26 +- .../Samples/Sample_RedisCollection.cs | 83 +- .../Sample_RedisFirewallRuleCollection.cs | 60 +- .../Sample_RedisFirewallRuleResource.cs | 40 +- ...RedisLinkedServerWithPropertyCollection.cs | 62 +- ...e_RedisLinkedServerWithPropertyResource.cs | 20 +- .../Sample_RedisPatchScheduleCollection.cs | 77 +- .../Sample_RedisPatchScheduleResource.cs | 33 +- ...edisPrivateEndpointConnectionCollection.cs | 104 +- ..._RedisPrivateEndpointConnectionResource.cs | 46 +- .../Generated/Samples/Sample_RedisResource.cs | 121 +- .../Sample_SubscriptionResourceExtensions.cs | 56 + ...Sample_AccessPolicyAssignmentCollection.cs | 64 +- .../Sample_AccessPolicyAssignmentResource.cs | 52 +- ...Sample_RedisEnterpriseClusterCollection.cs | 75 +- .../Sample_RedisEnterpriseClusterResource.cs | 74 +- ...ample_RedisEnterpriseDatabaseCollection.cs | 98 +- .../Sample_RedisEnterpriseDatabaseResource.cs | 86 +- ...risePrivateEndpointConnectionCollection.cs | 104 +- ...rprisePrivateEndpointConnectionResource.cs | 46 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + ...idConnectionAuthorizationRuleCollection.cs | 67 +- ...bridConnectionAuthorizationRuleResource.cs | 29 +- .../Sample_RelayHybridConnectionCollection.cs | 64 +- .../Sample_RelayHybridConnectionResource.cs | 26 +- ...layNamespaceAuthorizationRuleCollection.cs | 67 +- ...RelayNamespaceAuthorizationRuleResource.cs | 29 +- .../Sample_RelayNamespaceCollection.cs | 72 +- .../Samples/Sample_RelayNamespaceResource.cs | 91 +- .../Sample_RelayNetworkRuleSetResource.cs | 71 +- ...elayPrivateEndpointConnectionCollection.cs | 76 +- ..._RelayPrivateEndpointConnectionResource.cs | 40 +- ...mple_RelayPrivateLinkResourceCollection.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 76 + ...ple_WcfRelayAuthorizationRuleCollection.cs | 71 +- ...ample_WcfRelayAuthorizationRuleResource.cs | 29 +- .../Samples/Sample_WcfRelayCollection.cs | 72 +- .../Samples/Sample_WcfRelayResource.cs | 30 +- .../Sample_QuotaRequestDetailCollection.cs | 144 +- .../Sample_ReservationDetailCollection.cs | 92 +- .../Sample_ReservationDetailResource.cs | 85 +- .../Sample_ReservationOrderCollection.cs | 153 +- .../Sample_ReservationOrderResource.cs | 152 +- .../Sample_ReservationQuotaCollection.cs | 230 +-- .../Sample_ReservationQuotaResource.cs | 6 +- .../Sample_SubscriptionResourceExtensions.cs | 2 +- .../Sample_TenantResourceExtensions.cs | 106 +- ...le_ResourceConnectorApplianceCollection.cs | 98 +- ...mple_ResourceConnectorApplianceResource.cs | 60 +- .../Sample_SubscriptionResourceExtensions.cs | 75 + .../Sample_TenantResourceExtensions.cs | 152 +- .../Samples/Sample_ArmClientExtensions.cs | 148 ++ .../Sample_ResourceHealthEventCollection.cs | 56 +- ...ceHealthEventImpactedResourceCollection.cs | 50 +- .../Sample_ResourceHealthEventResource.cs | 48 +- ..._ResourceHealthMetadataEntityCollection.cs | 65 +- .../Sample_ServiceEmergingIssueCollection.cs | 65 +- ...ple_TenantResourceHealthEventCollection.cs | 73 +- ...ceHealthEventImpactedResourceCollection.cs | 50 +- ...ample_TenantResourceHealthEventResource.cs | 48 +- .../Sample_DataPolicyManifestCollection.cs | 110 +- .../Samples/Sample_FeatureCollection.cs | 48 +- .../Sample_ManagementGroupCollection.cs | 448 ++--- ...nagementGroupPolicyDefinitionCollection.cs | 94 +- ...ManagementGroupPolicyDefinitionResource.cs | 110 +- ...ementGroupPolicySetDefinitionCollection.cs | 152 +- ...agementGroupPolicySetDefinitionResource.cs | 198 +- .../Samples/Sample_ManagementGroupResource.cs | 42 +- ...e_ManagementGroupSubscriptionCollection.cs | 64 +- ...ple_ManagementGroupSubscriptionResource.cs | 18 +- .../Sample_ManagementLockCollection.cs | 86 +- .../Samples/Sample_ManagementLockResource.cs | 20 +- .../Sample_PolicyAssignmentCollection.cs | 631 +++---- .../Sample_PolicyAssignmentResource.cs | 86 +- .../Samples/Sample_ResourceGroupResource.cs | 14 +- .../Sample_ResourceProviderCollection.cs | 48 +- .../Sample_ResourceProviderResource.cs | 42 +- .../Samples/Sample_SubscriptionCollection.cs | 74 +- ..._SubscriptionPolicyDefinitionCollection.cs | 151 +- ...le_SubscriptionPolicyDefinitionResource.cs | 197 +- ...bscriptionPolicySetDefinitionCollection.cs | 160 +- ...SubscriptionPolicySetDefinitionResource.cs | 206 +-- .../Samples/Sample_SubscriptionResource.cs | 50 +- .../Generated/Samples/Sample_TagResource.cs | 164 +- ...Sample_TenantPolicyDefinitionCollection.cs | 74 +- ...ple_TenantPolicySetDefinitionCollection.cs | 74 +- .../Samples/Sample_TenantResource.cs | 4 +- .../Generated/Samples/Sample_MoverResource.cs | 62 +- .../Samples/Sample_MoverResourceCollection.cs | 88 +- .../Sample_MoverResourceSetCollection.cs | 64 +- .../Sample_MoverResourceSetResource.cs | 91 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Sample_TenantResourceExtensions.cs | 5 +- .../Sample_ArmApplicationCollection.cs | 92 +- ...mple_ArmApplicationDefinitionCollection.cs | 99 +- ...Sample_ArmApplicationDefinitionResource.cs | 5 +- .../Samples/Sample_ArmApplicationResource.cs | 2 +- .../Samples/Sample_ArmDeploymentCollection.cs | 9 +- .../Samples/Sample_ArmDeploymentResource.cs | 93 +- .../Sample_ArmDeploymentScriptCollection.cs | 100 +- .../Sample_ArmDeploymentScriptResource.cs | 71 +- .../Samples/Sample_DataBoundaryCollection.cs | 18 +- .../Sample_SubscriptionResourceExtensions.cs | 62 + .../Samples/Sample_TemplateSpecCollection.cs | 62 +- .../Samples/Sample_TemplateSpecResource.cs | 75 +- .../Sample_TemplateSpecVersionCollection.cs | 70 +- .../Sample_TemplateSpecVersionResource.cs | 50 +- .../Sample_TenantDataBoundaryCollection.cs | 20 +- .../Sample_TenantDataBoundaryResource.cs | 32 +- .../Sample_TenantResourceExtensions.cs | 82 + 234 files changed, 9743 insertions(+), 10713 deletions(-) create mode 100644 sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_ManagementGroupResourceExtensions.cs create mode 100644 sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ArmClientExtensions.cs create mode 100644 sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantResourceExtensions.cs diff --git a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewAccountCollection.cs b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewAccountCollection.cs index 94b09499eed61..95303125d74f7 100644 --- a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewAccountCollection.cs +++ b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewAccountCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_PurviewAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AccountsListByResourceGroup() + public async Task CreateOrUpdate_AccountsCreateOrUpdate() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_ListByResourceGroup.json - // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_CreateOrUpdate.json + // this example is just showing the usage of "Accounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_AccountsListByResourceGroup() // get the collection of this PurviewAccountResource PurviewAccountCollection collection = resourceGroupResource.GetPurviewAccounts(); - // invoke the operation and iterate over the result - await foreach (PurviewAccountResource item in collection.GetAllAsync()) + // invoke the operation + string accountName = "account1"; + PurviewAccountData data = new PurviewAccountData(new AzureLocation("West US 2")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ManagedResourceGroupName = "custom-rgname", + ManagedResourcesPublicNetworkAccess = ManagedResourcesPublicNetworkAccess.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + PurviewAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_AccountsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AccountsGet() + public async Task GetAll_AccountsListByResourceGroup() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_Get.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_ListByResourceGroup.json + // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,7 +103,7 @@ public async Task Exists_AccountsGet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "12345678-1234-1234-12345678abc"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "SampleResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -107,16 +111,22 @@ public async Task Exists_AccountsGet() // get the collection of this PurviewAccountResource PurviewAccountCollection collection = resourceGroupResource.GetPurviewAccounts(); - // invoke the operation - string accountName = "account1"; - bool result = await collection.ExistsAsync(accountName); + // invoke the operation and iterate over the result + await foreach (PurviewAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AccountsGet() + public async Task Exists_AccountsGet() { // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_Get.json // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +148,17 @@ public async Task GetIfExists_AccountsGet() // invoke the operation string accountName = "account1"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - PurviewAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AccountsCreateOrUpdate() + public async Task GetIfExists_AccountsGet() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_CreateOrUpdate.json - // this example is just showing the usage of "Accounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_Get.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -169,7 +167,7 @@ public async Task CreateOrUpdate_AccountsCreateOrUpdate() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = "12345678-1234-1234-12345678abc"; string resourceGroupName = "SampleResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -179,19 +177,21 @@ public async Task CreateOrUpdate_AccountsCreateOrUpdate() // invoke the operation string accountName = "account1"; - PurviewAccountData data = new PurviewAccountData(new AzureLocation("West US 2")) - { - ManagedResourceGroupName = "custom-rgname", - ManagedResourcesPublicNetworkAccess = ManagedResourcesPublicNetworkAccess.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); - PurviewAccountResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + PurviewAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewAccountResource.cs b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewAccountResource.cs index b063521600319..6950f778a9135 100644 --- a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewAccountResource.cs +++ b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewAccountResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Purview.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Purview.Samples { public partial class Sample_PurviewAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPurviewAccounts_AccountsListBySubscription() - { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_ListBySubscription.json - // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PurviewAccountResource item in subscriptionResource.GetPurviewAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_AccountsGet() @@ -125,11 +93,11 @@ public async Task Update_AccountsUpdate() PurviewAccountResource purviewAccount = client.GetPurviewAccountResource(purviewAccountResourceId); // invoke the operation - PurviewAccountPatch patch = new PurviewAccountPatch() + PurviewAccountPatch patch = new PurviewAccountPatch { Tags = { -["newTag"] = "New tag value.", +["newTag"] = "New tag value." }, }; ArmOperation lro = await purviewAccount.UpdateAsync(WaitUntil.Completed, patch); @@ -163,7 +131,7 @@ public async Task AddRootCollectionAdmin_AccountsAddRootCollectionAdmin() PurviewAccountResource purviewAccount = client.GetPurviewAccountResource(purviewAccountResourceId); // invoke the operation - CollectionAdminUpdateContent content = new CollectionAdminUpdateContent() + CollectionAdminUpdateContent content = new CollectionAdminUpdateContent { AdminObjectId = "7e8de0e7-2bfc-4e1f-9659-2a5785e4356f", }; @@ -198,35 +166,6 @@ public async Task GetKeys_AccountsListKeys() Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckPurviewAccountNameAvailability_AccountsCheckNameAvailability() - { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_CheckNameAvailability.json - // this example is just showing the usage of "Accounts_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - PurviewAccountNameAvailabilityContent content = new PurviewAccountNameAvailabilityContent() - { - Name = "account1", - ResourceType = "Microsoft.Purview/accounts", - }; - PurviewAccountNameAvailabilityResult result = await subscriptionResource.CheckPurviewAccountNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task AccountGetFeature_FeaturesAccountGet() @@ -248,12 +187,9 @@ public async Task AccountGetFeature_FeaturesAccountGet() PurviewAccountResource purviewAccount = client.GetPurviewAccountResource(purviewAccountResourceId); // invoke the operation - PurviewBatchFeatureContent content = new PurviewBatchFeatureContent() + PurviewBatchFeatureContent content = new PurviewBatchFeatureContent { - Features = -{ -"Feature1","Feature2","FeatureThatDoesntExist" -}, + Features = { "Feature1", "Feature2", "FeatureThatDoesntExist" }, }; PurviewBatchFeatureStatus result = await purviewAccount.AccountGetFeatureAsync(content); @@ -314,7 +250,7 @@ public async Task UpdateStatusIngestionPrivateEndpointConnection_IngestionPrivat PurviewAccountResource purviewAccount = client.GetPurviewAccountResource(purviewAccountResourceId); // invoke the operation - PrivateEndpointConnectionStatusUpdateContent content = new PrivateEndpointConnectionStatusUpdateContent() + PrivateEndpointConnectionStatusUpdateContent content = new PrivateEndpointConnectionStatusUpdateContent { PrivateEndpointId = "/subscriptions/12345678-1234-1234-12345678abc/resourceGroups/SampleResourceGroup/providers/Microsoft.Purview/accounts/account1/privateEndpointConnections/privateEndpointConnection1", Status = "Approved", diff --git a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewKafkaConfigurationCollection.cs b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewKafkaConfigurationCollection.cs index 3eef5157f6097..2929a754cca8b 100644 --- a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewKafkaConfigurationCollection.cs +++ b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewKafkaConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PurviewKafkaConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KafkaConfigurationsListByAccount() + public async Task CreateOrUpdate_KafkaConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_ListByAccount.json - // this example is just showing the usage of "KafkaConfigurations_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_CreateOrUpdate.json + // this example is just showing the usage of "KafkaConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,18 +39,30 @@ public async Task GetAll_KafkaConfigurationsListByAccount() // get the collection of this PurviewKafkaConfigurationResource PurviewKafkaConfigurationCollection collection = purviewAccount.GetPurviewKafkaConfigurations(); - // invoke the operation and iterate over the result - string skipToken = "token"; - await foreach (PurviewKafkaConfigurationResource item in collection.GetAllAsync(skipToken: skipToken)) + // invoke the operation + string kafkaConfigurationName = "kafkaConfigName"; + PurviewKafkaConfigurationData data = new PurviewKafkaConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewKafkaConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConsumerGroup = "consumerGroup", + Credentials = new PurviewCredentials + { + IdentityId = "/subscriptions/47e8596d-ee73-4eb2-b6b4-cc13c2b87ssd/resourceGroups/testRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testId", + CredentialsType = PurviewCredentialsType.UserAssigned, + }, + EventHubPartitionId = "partitionId", + EventHubResourceId = new ResourceIdentifier("/subscriptions/225be6fe-ec1c-4d51-a368-f69348d2e6c5/resourceGroups/testRG/providers/Microsoft.EventHub/namespaces/eventHubNameSpaceName"), + EventHubType = PurviewKafkaEventHubType.Notification, + EventStreamingState = PurviewEventStreamingState.Enabled, + EventStreamingType = PurviewEventStreamingType.Azure, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, kafkaConfigurationName, data); + PurviewKafkaConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewKafkaConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +101,10 @@ public async Task Get_KafkaConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KafkaConfigurationsGet() + public async Task GetAll_KafkaConfigurationsListByAccount() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_Get.json - // this example is just showing the usage of "KafkaConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_ListByAccount.json + // this example is just showing the usage of "KafkaConfigurations_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +122,23 @@ public async Task Exists_KafkaConfigurationsGet() // get the collection of this PurviewKafkaConfigurationResource PurviewKafkaConfigurationCollection collection = purviewAccount.GetPurviewKafkaConfigurations(); - // invoke the operation - string kafkaConfigurationName = "kafkaConfigName"; - bool result = await collection.ExistsAsync(kafkaConfigurationName); + // invoke the operation and iterate over the result + string skipToken = "token"; + await foreach (PurviewKafkaConfigurationResource item in collection.GetAllAsync(skipToken: skipToken)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewKafkaConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KafkaConfigurationsGet() + public async Task Exists_KafkaConfigurationsGet() { // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_Get.json // this example is just showing the usage of "KafkaConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +161,17 @@ public async Task GetIfExists_KafkaConfigurationsGet() // invoke the operation string kafkaConfigurationName = "kafkaConfigName"; - NullableResponse response = await collection.GetIfExistsAsync(kafkaConfigurationName); - PurviewKafkaConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(kafkaConfigurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewKafkaConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KafkaConfigurationsCreateOrUpdate() + public async Task GetIfExists_KafkaConfigurationsGet() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_CreateOrUpdate.json - // this example is just showing the usage of "KafkaConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_Get.json + // this example is just showing the usage of "KafkaConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,28 +191,21 @@ public async Task CreateOrUpdate_KafkaConfigurationsCreateOrUpdate() // invoke the operation string kafkaConfigurationName = "kafkaConfigName"; - PurviewKafkaConfigurationData data = new PurviewKafkaConfigurationData() - { - ConsumerGroup = "consumerGroup", - Credentials = new PurviewCredentials() - { - IdentityId = "/subscriptions/47e8596d-ee73-4eb2-b6b4-cc13c2b87ssd/resourceGroups/testRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testId", - CredentialsType = PurviewCredentialsType.UserAssigned, - }, - EventHubPartitionId = "partitionId", - EventHubResourceId = new ResourceIdentifier("/subscriptions/225be6fe-ec1c-4d51-a368-f69348d2e6c5/resourceGroups/testRG/providers/Microsoft.EventHub/namespaces/eventHubNameSpaceName"), - EventHubType = PurviewKafkaEventHubType.Notification, - EventStreamingState = PurviewEventStreamingState.Enabled, - EventStreamingType = PurviewEventStreamingType.Azure, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, kafkaConfigurationName, data); - PurviewKafkaConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(kafkaConfigurationName); + PurviewKafkaConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewKafkaConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewKafkaConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewKafkaConfigurationResource.cs b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewKafkaConfigurationResource.cs index aa24b53ee7611..9f7a8e687d0a3 100644 --- a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewKafkaConfigurationResource.cs +++ b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewKafkaConfigurationResource.cs @@ -49,10 +49,10 @@ public async Task Get_KafkaConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KafkaConfigurationsCreateOrUpdate() + public async Task Delete_KafkaConfigurationsDelete() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_CreateOrUpdate.json - // this example is just showing the usage of "KafkaConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_Delete.json + // this example is just showing the usage of "KafkaConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,36 +69,17 @@ public async Task Update_KafkaConfigurationsCreateOrUpdate() PurviewKafkaConfigurationResource purviewKafkaConfiguration = client.GetPurviewKafkaConfigurationResource(purviewKafkaConfigurationResourceId); // invoke the operation - PurviewKafkaConfigurationData data = new PurviewKafkaConfigurationData() - { - ConsumerGroup = "consumerGroup", - Credentials = new PurviewCredentials() - { - IdentityId = "/subscriptions/47e8596d-ee73-4eb2-b6b4-cc13c2b87ssd/resourceGroups/testRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testId", - CredentialsType = PurviewCredentialsType.UserAssigned, - }, - EventHubPartitionId = "partitionId", - EventHubResourceId = new ResourceIdentifier("/subscriptions/225be6fe-ec1c-4d51-a368-f69348d2e6c5/resourceGroups/testRG/providers/Microsoft.EventHub/namespaces/eventHubNameSpaceName"), - EventHubType = PurviewKafkaEventHubType.Notification, - EventStreamingState = PurviewEventStreamingState.Enabled, - EventStreamingType = PurviewEventStreamingType.Azure, - }; - ArmOperation lro = await purviewKafkaConfiguration.UpdateAsync(WaitUntil.Completed, data); - PurviewKafkaConfigurationResource result = lro.Value; + await purviewKafkaConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewKafkaConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KafkaConfigurationsDelete() + public async Task Update_KafkaConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_Delete.json - // this example is just showing the usage of "KafkaConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/KafkaConfigurations_CreateOrUpdate.json + // this example is just showing the usage of "KafkaConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,9 +96,28 @@ public async Task Delete_KafkaConfigurationsDelete() PurviewKafkaConfigurationResource purviewKafkaConfiguration = client.GetPurviewKafkaConfigurationResource(purviewKafkaConfigurationResourceId); // invoke the operation - await purviewKafkaConfiguration.DeleteAsync(WaitUntil.Completed); + PurviewKafkaConfigurationData data = new PurviewKafkaConfigurationData + { + ConsumerGroup = "consumerGroup", + Credentials = new PurviewCredentials + { + IdentityId = "/subscriptions/47e8596d-ee73-4eb2-b6b4-cc13c2b87ssd/resourceGroups/testRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testId", + CredentialsType = PurviewCredentialsType.UserAssigned, + }, + EventHubPartitionId = "partitionId", + EventHubResourceId = new ResourceIdentifier("/subscriptions/225be6fe-ec1c-4d51-a368-f69348d2e6c5/resourceGroups/testRG/providers/Microsoft.EventHub/namespaces/eventHubNameSpaceName"), + EventHubType = PurviewKafkaEventHubType.Notification, + EventStreamingState = PurviewEventStreamingState.Enabled, + EventStreamingType = PurviewEventStreamingType.Azure, + }; + ArmOperation lro = await purviewKafkaConfiguration.UpdateAsync(WaitUntil.Completed, data); + PurviewKafkaConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewKafkaConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateEndpointConnectionCollection.cs b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateEndpointConnectionCollection.cs index 4125a7a05719d..e07411d3bc8ee 100644 --- a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateEndpointConnectionCollection.cs +++ b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PurviewPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsListByAccount() + public async Task CreateOrUpdate_PrivateEndpointConnectionsCreateOrUpdate() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_ListByAccount.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_CreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task GetAll_PrivateEndpointConnectionsListByAccount() // this example assumes you already have this PurviewAccountResource created on azure // for more information of creating PurviewAccountResource, please refer to the document of PurviewAccountResource - string subscriptionId = "12345678-1234-1234-12345678abc"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "SampleResourceGroup"; string accountName = "account1"; ResourceIdentifier purviewAccountResourceId = PurviewAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); @@ -39,17 +39,24 @@ public async Task GetAll_PrivateEndpointConnectionsListByAccount() // get the collection of this PurviewPrivateEndpointConnectionResource PurviewPrivateEndpointConnectionCollection collection = purviewAccount.GetPurviewPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (PurviewPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "privateEndpointConnection1"; + PurviewPrivateEndpointConnectionData data = new PurviewPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new PurviewPrivateLinkServiceConnectionState + { + Description = "Approved by johndoe@company.com", + Status = PurviewPrivateLinkServiceStatus.Approved, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + PurviewPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGet() + public async Task GetAll_PrivateEndpointConnectionsListByAccount() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_ListByAccount.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_PrivateEndpointConnectionsGet() // get the collection of this PurviewPrivateEndpointConnectionResource PurviewPrivateEndpointConnectionCollection collection = purviewAccount.GetPurviewPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "privateEndpointConnection1"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (PurviewPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGet() + public async Task Exists_PrivateEndpointConnectionsGet() { // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_Get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "privateEndpointConnection1"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - PurviewPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionsCreateOrUpdate() + public async Task GetIfExists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_CreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,7 +173,7 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsCreateOrUpdate() // this example assumes you already have this PurviewAccountResource created on azure // for more information of creating PurviewAccountResource, please refer to the document of PurviewAccountResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = "12345678-1234-1234-12345678abc"; string resourceGroupName = "SampleResourceGroup"; string accountName = "account1"; ResourceIdentifier purviewAccountResourceId = PurviewAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsCreateOrUpdate() // invoke the operation string privateEndpointConnectionName = "privateEndpointConnection1"; - PurviewPrivateEndpointConnectionData data = new PurviewPrivateEndpointConnectionData() - { - ConnectionState = new PurviewPrivateLinkServiceConnectionState() - { - Description = "Approved by johndoe@company.com", - Status = PurviewPrivateLinkServiceStatus.Approved, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - PurviewPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + PurviewPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateEndpointConnectionResource.cs b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateEndpointConnectionResource.cs index ae2a3415a2c50..3a10f02125b3f 100644 --- a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateEndpointConnectionResource.cs +++ b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsCreateOrUpdate() + public async Task Delete_PrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_CreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_Delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_PrivateEndpointConnectionsCreateOrUpdate() PurviewPrivateEndpointConnectionResource purviewPrivateEndpointConnection = client.GetPurviewPrivateEndpointConnectionResource(purviewPrivateEndpointConnectionResourceId); // invoke the operation - PurviewPrivateEndpointConnectionData data = new PurviewPrivateEndpointConnectionData() - { - ConnectionState = new PurviewPrivateLinkServiceConnectionState() - { - Description = "Approved by johndoe@company.com", - Status = PurviewPrivateLinkServiceStatus.Approved, - }, - }; - ArmOperation lro = await purviewPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - PurviewPrivateEndpointConnectionResource result = lro.Value; + await purviewPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDelete() + public async Task Update_PrivateEndpointConnectionsCreateOrUpdate() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_Delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateEndpointConnections_CreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_PrivateEndpointConnectionsDelete() PurviewPrivateEndpointConnectionResource purviewPrivateEndpointConnection = client.GetPurviewPrivateEndpointConnectionResource(purviewPrivateEndpointConnectionResourceId); // invoke the operation - await purviewPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + PurviewPrivateEndpointConnectionData data = new PurviewPrivateEndpointConnectionData + { + ConnectionState = new PurviewPrivateLinkServiceConnectionState + { + Description = "Approved by johndoe@company.com", + Status = PurviewPrivateLinkServiceStatus.Approved, + }, + }; + ArmOperation lro = await purviewPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + PurviewPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateLinkResourceCollection.cs b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateLinkResourceCollection.cs index 389dd6ecc4681..7d963bcd6f235 100644 --- a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateLinkResourceCollection.cs +++ b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_PurviewPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_PurviewPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesListByAccount() + public async Task Get_PrivateLinkResourcesGetByGroupId() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateLinkResources_ListByAccount.json - // this example is just showing the usage of "PrivateLinkResources_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateLinkResources_GetByGroupId.json + // this example is just showing the usage of "PrivateLinkResources_GetByGroupId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_PrivateLinkResourcesListByAccount() // get the collection of this PurviewPrivateLinkResource PurviewPrivateLinkResourceCollection collection = purviewAccount.GetPurviewPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (PurviewPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupId = "group1"; + PurviewPrivateLinkResource result = await collection.GetAsync(groupId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkResourcesGetByGroupId() + public async Task GetAll_PrivateLinkResourcesListByAccount() { - // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateLinkResources_GetByGroupId.json - // this example is just showing the usage of "PrivateLinkResources_GetByGroupId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/PrivateLinkResources_ListByAccount.json + // this example is just showing the usage of "PrivateLinkResources_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_PrivateLinkResourcesGetByGroupId() // get the collection of this PurviewPrivateLinkResource PurviewPrivateLinkResourceCollection collection = purviewAccount.GetPurviewPrivateLinkResources(); - // invoke the operation - string groupId = "group1"; - PurviewPrivateLinkResource result = await collection.GetAsync(groupId); + // invoke the operation and iterate over the result + await foreach (PurviewPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PurviewPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 9868f6da73c6f..5c04d9849e2cf 100644 --- a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,66 @@ namespace Azure.ResourceManager.Purview.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPurviewAccounts_AccountsListBySubscription() + { + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_ListBySubscription.json + // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PurviewAccountResource item in subscriptionResource.GetPurviewAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PurviewAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckPurviewAccountNameAvailability_AccountsCheckNameAvailability() + { + // Generated from example definition: specification/purview/resource-manager/Microsoft.Purview/preview/2023-05-01-preview/examples/Accounts_CheckNameAvailability.json + // this example is just showing the usage of "Accounts_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + PurviewAccountNameAvailabilityContent content = new PurviewAccountNameAvailabilityContent + { + Name = "account1", + ResourceType = "Microsoft.Purview/accounts", + }; + PurviewAccountNameAvailabilityResult result = await subscriptionResource.CheckPurviewAccountNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task SubscriptionGetFeature_FeaturesSubscriptionGet() @@ -37,12 +97,9 @@ public async Task SubscriptionGetFeature_FeaturesSubscriptionGet() // invoke the operation string locations = "eastus"; - PurviewBatchFeatureContent content = new PurviewBatchFeatureContent() + PurviewBatchFeatureContent content = new PurviewBatchFeatureContent { - Features = -{ -"Feature1","Feature2","FeatureThatDoesntExist" -}, + Features = { "Feature1", "Feature2", "FeatureThatDoesntExist" }, }; PurviewBatchFeatureStatus result = await subscriptionResource.SubscriptionGetFeatureAsync(locations, content); diff --git a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index 04e11ed53a177..1581b08021324 100644 --- a/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/purview/Azure.ResourceManager.Purview/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Purview.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Purview.Samples @@ -28,9 +29,7 @@ public async Task GetDefaultAccount_DefaultAccountsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation Guid scopeTenantId = Guid.Parse("ee85a74c-405e-4adc-bb47-ffa8ca0c9f31"); @@ -53,9 +52,7 @@ public async Task RemoveDefaultAccount_DefaultAccountsRemove() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation Guid scopeTenantId = Guid.Parse("ee85a74c-405e-4adc-bb47-ffa8ca0c9f31"); @@ -78,12 +75,10 @@ public async Task SetDefaultAccount_DefaultAccountsSet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation - DefaultPurviewAccountPayload defaultAccountPayload = new DefaultPurviewAccountPayload() + DefaultPurviewAccountPayload defaultAccountPayload = new DefaultPurviewAccountPayload { AccountName = "myDefaultAccount", ResourceGroupName = "rg-1", diff --git a/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_QuantumWorkspaceCollection.cs b/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_QuantumWorkspaceCollection.cs index b12175968104a..99f7972063d6b 100644 --- a/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_QuantumWorkspaceCollection.cs +++ b/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_QuantumWorkspaceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_QuantumWorkspaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QuantumWorkspacesGet() + public async Task CreateOrUpdate_QuantumWorkspacesPut() { - // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesGet.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesPut.json + // this example is just showing the usage of "Workspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,25 @@ public async Task Get_QuantumWorkspacesGet() // invoke the operation string workspaceName = "quantumworkspace1"; - QuantumWorkspaceResource result = await collection.GetAsync(workspaceName); + QuantumWorkspaceData data = new QuantumWorkspaceData(new AzureLocation("West US")) + { + Providers = {new QuantumProvider +{ +ProviderId = "Honeywell", +ProviderSku = "Basic", +}, new QuantumProvider +{ +ProviderId = "IonQ", +ProviderSku = "Basic", +}, new QuantumProvider +{ +ProviderId = "OneQBit", +ProviderSku = "Basic", +}}, + StorageAccount = "/subscriptions/1C4B2828-7D49-494F-933D-061373BE28C2/resourceGroups/quantumResourcegroup/providers/Microsoft.Storage/storageAccounts/testStorageAccount", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); + QuantumWorkspaceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +70,7 @@ public async Task Get_QuantumWorkspacesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QuantumWorkspacesGet() + public async Task Get_QuantumWorkspacesGet() { // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesGet.json // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +92,21 @@ public async Task Exists_QuantumWorkspacesGet() // invoke the operation string workspaceName = "quantumworkspace1"; - bool result = await collection.ExistsAsync(workspaceName); + QuantumWorkspaceResource result = await collection.GetAsync(workspaceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuantumWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuantumWorkspacesGet() + public async Task GetAll_QuantumWorkspacesListByResourceGroup() { - // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesGet.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesListResourceGroup.json + // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +123,25 @@ public async Task GetIfExists_QuantumWorkspacesGet() // get the collection of this QuantumWorkspaceResource QuantumWorkspaceCollection collection = resourceGroupResource.GetQuantumWorkspaces(); - // invoke the operation - string workspaceName = "quantumworkspace1"; - NullableResponse response = await collection.GetIfExistsAsync(workspaceName); - QuantumWorkspaceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (QuantumWorkspaceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - QuantumWorkspaceData resourceData = result.Data; + QuantumWorkspaceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_QuantumWorkspacesPut() + public async Task Exists_QuantumWorkspacesGet() { - // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesPut.json - // this example is just showing the usage of "Workspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesGet.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,42 +160,17 @@ public async Task CreateOrUpdate_QuantumWorkspacesPut() // invoke the operation string workspaceName = "quantumworkspace1"; - QuantumWorkspaceData data = new QuantumWorkspaceData(new AzureLocation("West US")) - { - Providers = -{ -new QuantumProvider() -{ -ProviderId = "Honeywell", -ProviderSku = "Basic", -},new QuantumProvider() -{ -ProviderId = "IonQ", -ProviderSku = "Basic", -},new QuantumProvider() -{ -ProviderId = "OneQBit", -ProviderSku = "Basic", -} -}, - StorageAccount = "/subscriptions/1C4B2828-7D49-494F-933D-061373BE28C2/resourceGroups/quantumResourcegroup/providers/Microsoft.Storage/storageAccounts/testStorageAccount", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); - QuantumWorkspaceResource result = lro.Value; + bool result = await collection.ExistsAsync(workspaceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuantumWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QuantumWorkspacesListByResourceGroup() + public async Task GetIfExists_QuantumWorkspacesGet() { - // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesListResourceGroup.json - // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesGet.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,17 +187,23 @@ public async Task GetAll_QuantumWorkspacesListByResourceGroup() // get the collection of this QuantumWorkspaceResource QuantumWorkspaceCollection collection = resourceGroupResource.GetQuantumWorkspaces(); - // invoke the operation and iterate over the result - await foreach (QuantumWorkspaceResource item in collection.GetAllAsync()) + // invoke the operation + string workspaceName = "quantumworkspace1"; + NullableResponse response = await collection.GetIfExistsAsync(workspaceName); + QuantumWorkspaceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - QuantumWorkspaceData resourceData = item.Data; + QuantumWorkspaceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_QuantumWorkspaceResource.cs b/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_QuantumWorkspaceResource.cs index df9fbfce711f5..0ab6ae619eacf 100644 --- a/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_QuantumWorkspaceResource.cs +++ b/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_QuantumWorkspaceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Quantum.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Quantum.Samples @@ -49,10 +48,10 @@ public async Task Get_QuantumWorkspacesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_QuantumWorkspacesPatchTags() + public async Task Delete_QuantumWorkspacesDelete() { - // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesPatch.json - // this example is just showing the usage of "Workspaces_UpdateTags" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesDelete.json + // this example is just showing the usage of "Workspaces_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_QuantumWorkspacesPatchTags() QuantumWorkspaceResource quantumWorkspace = client.GetQuantumWorkspaceResource(quantumWorkspaceResourceId); // invoke the operation - QuantumWorkspacePatch patch = new QuantumWorkspacePatch() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - QuantumWorkspaceResource result = await quantumWorkspace.UpdateAsync(patch); + await quantumWorkspace.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuantumWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_QuantumWorkspacesDelete() + public async Task Update_QuantumWorkspacesPatchTags() { - // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesDelete.json - // this example is just showing the usage of "Workspaces_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesPatch.json + // this example is just showing the usage of "Workspaces_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_QuantumWorkspacesDelete() QuantumWorkspaceResource quantumWorkspace = client.GetQuantumWorkspaceResource(quantumWorkspaceResourceId); // invoke the operation - await quantumWorkspace.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetQuantumWorkspaces_QuantumWorkspacesListBySubscription() - { - // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesListSubscription.json - // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (QuantumWorkspaceResource item in subscriptionResource.GetQuantumWorkspacesAsync()) + QuantumWorkspacePatch patch = new QuantumWorkspacePatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuantumWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + QuantumWorkspaceResource result = await quantumWorkspace.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuantumWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -189,12 +157,9 @@ public async Task RegenerateKeysWorkspace_RegenerateKey() QuantumWorkspaceResource quantumWorkspace = client.GetQuantumWorkspaceResource(quantumWorkspaceResourceId); // invoke the operation - WorkspaceApiKeys keySpecification = new WorkspaceApiKeys() + WorkspaceApiKeys keySpecification = new WorkspaceApiKeys { - Keys = -{ -WorkspaceKeyType.Primary,WorkspaceKeyType.Secondary -}, + Keys = { WorkspaceKeyType.Primary, WorkspaceKeyType.Secondary }, }; await quantumWorkspace.RegenerateKeysWorkspaceAsync(keySpecification); diff --git a/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 6859303971ff4..efd438c322618 100644 --- a/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/quantum/Azure.ResourceManager.Quantum/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.Quantum.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetQuantumWorkspaces_QuantumWorkspacesListBySubscription() + { + // Generated from example definition: specification/quantum/resource-manager/Microsoft.Quantum/preview/2023-11-13-preview/examples/quantumWorkspacesListSubscription.json + // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (QuantumWorkspaceResource item in subscriptionResource.GetQuantumWorkspacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuantumWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetOfferings_OfferingsList() @@ -65,7 +96,7 @@ public async Task CheckWorkspaceNameAvailability_QuantumWorkspacesCheckNameAvail // invoke the operation string locationName = "westus2"; - WorkspaceNameAvailabilityContent content = new WorkspaceNameAvailabilityContent() + WorkspaceNameAvailabilityContent content = new WorkspaceNameAvailabilityContent { Name = "sample-workspace-name", ResourceType = new ResourceType("Microsoft.Quantum/Workspaces"), diff --git a/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_QumuloFileSystemResource.cs b/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_QumuloFileSystemResource.cs index 49fe2da29b387..6e73a5cf91dba 100644 --- a/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_QumuloFileSystemResource.cs +++ b/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_QumuloFileSystemResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.Qumulo.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Qumulo.Samples @@ -20,72 +19,70 @@ public partial class Sample_QumuloFileSystemResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetQumuloFileSystemResources_FileSystemsListBySubscriptionMaximumSetGen() + public async Task Get_FileSystemsGetMaximumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "FileSystems_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MaximumSet_Gen.json + // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this QumuloFileSystemResource created on azure + // for more information of creating QumuloFileSystemResource, please refer to the document of QumuloFileSystemResource string subscriptionId = "ulseeqylxb"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rgQumulo"; + string fileSystemName = "nauwwbfoqehgbhdsmkewoboyxeqg"; + ResourceIdentifier qumuloFileSystemResourceId = QumuloFileSystemResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fileSystemName); + QumuloFileSystemResource qumuloFileSystemResource = client.GetQumuloFileSystemResource(qumuloFileSystemResourceId); - // invoke the operation and iterate over the result - await foreach (QumuloFileSystemResource item in subscriptionResource.GetQumuloFileSystemResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + QumuloFileSystemResource result = await qumuloFileSystemResource.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QumuloFileSystemResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetQumuloFileSystemResources_FileSystemsListBySubscriptionMinimumSetGen() + public async Task Get_FileSystemsGetMinimumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "FileSystems_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MinimumSet_Gen.json + // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this QumuloFileSystemResource created on azure + // for more information of creating QumuloFileSystemResource, please refer to the document of QumuloFileSystemResource string subscriptionId = "aaaaaaa"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rgQumulo"; + string fileSystemName = "aaaaaaaaaaaaaaaaa"; + ResourceIdentifier qumuloFileSystemResourceId = QumuloFileSystemResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fileSystemName); + QumuloFileSystemResource qumuloFileSystemResource = client.GetQumuloFileSystemResource(qumuloFileSystemResourceId); - // invoke the operation and iterate over the result - await foreach (QumuloFileSystemResource item in subscriptionResource.GetQumuloFileSystemResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + QumuloFileSystemResource result = await qumuloFileSystemResource.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QumuloFileSystemResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FileSystemsGetMaximumSetGen() + public async Task Delete_FileSystemsDeleteMaximumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MaximumSet_Gen.json - // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "FileSystems_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,21 +98,17 @@ public async Task Get_FileSystemsGetMaximumSetGen() QumuloFileSystemResource qumuloFileSystemResource = client.GetQumuloFileSystemResource(qumuloFileSystemResourceId); // invoke the operation - QumuloFileSystemResource result = await qumuloFileSystemResource.GetAsync(); + await qumuloFileSystemResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FileSystemsGetMinimumSetGen() + public async Task Delete_FileSystemsDeleteMinimumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MinimumSet_Gen.json - // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "FileSystems_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -124,20 +117,16 @@ public async Task Get_FileSystemsGetMinimumSetGen() // this example assumes you already have this QumuloFileSystemResource created on azure // for more information of creating QumuloFileSystemResource, please refer to the document of QumuloFileSystemResource - string subscriptionId = "aaaaaaa"; + string subscriptionId = "ulseeqylxb"; string resourceGroupName = "rgQumulo"; - string fileSystemName = "aaaaaaaaaaaaaaaaa"; + string fileSystemName = "nauwwbfoqehgbhdsmkewoboyxeqg"; ResourceIdentifier qumuloFileSystemResourceId = QumuloFileSystemResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fileSystemName); QumuloFileSystemResource qumuloFileSystemResource = client.GetQumuloFileSystemResource(qumuloFileSystemResourceId); // invoke the operation - QumuloFileSystemResource result = await qumuloFileSystemResource.GetAsync(); + await qumuloFileSystemResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -161,20 +150,20 @@ public async Task Update_FileSystemsUpdateMaximumSetGen() QumuloFileSystemResource qumuloFileSystemResource = client.GetQumuloFileSystemResource(qumuloFileSystemResourceId); // invoke the operation - QumuloFileSystemResourcePatch patch = new QumuloFileSystemResourcePatch() + QumuloFileSystemResourcePatch patch = new QumuloFileSystemResourcePatch { Identity = new ManagedServiceIdentity("None") { UserAssignedIdentities = { -[new ResourceIdentifier("key4522")] = new UserAssignedIdentity(), +[new ResourceIdentifier("key4522")] = new UserAssignedIdentity() }, }, Tags = { -["key7534"] = "jsgqvqbagquvxowbrkanyhzvo", +["key7534"] = "jsgqvqbagquvxowbrkanyhzvo" }, - Properties = new FileSystemResourceUpdateProperties() + Properties = new FileSystemResourceUpdateProperties { MarketplaceDetails = new MarketplaceDetails("x", "eiyhbmpwgezcmzrrfoiskuxlcvwojf", "wfmokfdjbwpjhz") { @@ -183,10 +172,7 @@ public async Task Update_FileSystemsUpdateMaximumSetGen() UserDetailsEmail = "aa", DelegatedSubnetId = new ResourceIdentifier("vjfirtaljehawmflyfianw"), ClusterLoginUri = new Uri("adabmuthwrbjshzfbo"), - PrivateIPs = -{ -"eugjqbaoucgjsopzfrq" -}, + PrivateIPs = { "eugjqbaoucgjsopzfrq" }, }, }; QumuloFileSystemResource result = await qumuloFileSystemResource.UpdateAsync(patch); @@ -228,57 +214,5 @@ public async Task Update_FileSystemsUpdateMinimumSetGen() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_FileSystemsDeleteMaximumSetGen() - { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "FileSystems_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this QumuloFileSystemResource created on azure - // for more information of creating QumuloFileSystemResource, please refer to the document of QumuloFileSystemResource - string subscriptionId = "ulseeqylxb"; - string resourceGroupName = "rgQumulo"; - string fileSystemName = "nauwwbfoqehgbhdsmkewoboyxeqg"; - ResourceIdentifier qumuloFileSystemResourceId = QumuloFileSystemResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fileSystemName); - QumuloFileSystemResource qumuloFileSystemResource = client.GetQumuloFileSystemResource(qumuloFileSystemResourceId); - - // invoke the operation - await qumuloFileSystemResource.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_FileSystemsDeleteMinimumSetGen() - { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "FileSystems_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this QumuloFileSystemResource created on azure - // for more information of creating QumuloFileSystemResource, please refer to the document of QumuloFileSystemResource - string subscriptionId = "ulseeqylxb"; - string resourceGroupName = "rgQumulo"; - string fileSystemName = "nauwwbfoqehgbhdsmkewoboyxeqg"; - ResourceIdentifier qumuloFileSystemResourceId = QumuloFileSystemResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fileSystemName); - QumuloFileSystemResource qumuloFileSystemResource = client.GetQumuloFileSystemResource(qumuloFileSystemResourceId); - - // invoke the operation - await qumuloFileSystemResource.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_QumuloFileSystemResourceCollection.cs b/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_QumuloFileSystemResourceCollection.cs index f9695015ac681..0e49c84dfdebd 100644 --- a/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_QumuloFileSystemResourceCollection.cs +++ b/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_QumuloFileSystemResourceCollection.cs @@ -21,10 +21,10 @@ public partial class Sample_QumuloFileSystemResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FileSystemsListByResourceGroupMaximumSetGen() + public async Task CreateOrUpdate_FileSystemsCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "FileSystems_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "FileSystems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,54 @@ public async Task GetAll_FileSystemsListByResourceGroupMaximumSetGen() // get the collection of this QumuloFileSystemResource QumuloFileSystemResourceCollection collection = resourceGroupResource.GetQumuloFileSystemResources(); - // invoke the operation and iterate over the result - await foreach (QumuloFileSystemResource item in collection.GetAllAsync()) + // invoke the operation + string fileSystemName = "nauwwbfoqehgbhdsmkewoboyxeqg"; + QumuloFileSystemResourceData data = new QumuloFileSystemResourceData( + new AzureLocation("przdlsmlzsszphnixq"), + new MarketplaceDetails("x", "eiyhbmpwgezcmzrrfoiskuxlcvwojf", "wfmokfdjbwpjhz") + { + MarketplaceSubscriptionId = "ujrcqvxfnhxxheoth", + }, + StorageSku.Standard, + new QumuloUserDetails + { + Email = "viptslwulnpaupfljvnjeq", + }, + "neqctctqdmjezfgt", + "ekceujoecaashtjlsgcymnrdozk", + 9) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("key4522")] = new UserAssignedIdentity() +}, + }, + ClusterLoginUri = new Uri("jjqhgevy"), + PrivateIPs = { IPAddress.Parse("kslguxrwbwkrj") }, + AvailabilityZone = "maseyqhlnhoiwbabcqabtedbjpip", + Tags = +{ +["key6565"] = "cgdhmupta" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileSystemName, data); + QumuloFileSystemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QumuloFileSystemResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FileSystemsListByResourceGroupMinimumSetGen() + public async Task CreateOrUpdate_FileSystemsCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "FileSystems_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "FileSystems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,25 +97,38 @@ public async Task GetAll_FileSystemsListByResourceGroupMinimumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "aaaaaaa"; - string resourceGroupName = "rgQumulo"; + string subscriptionId = "aaaaaaaaaaaaaaaaaaaaaaaa"; + string resourceGroupName = "rgopenapi"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this QumuloFileSystemResource QumuloFileSystemResourceCollection collection = resourceGroupResource.GetQumuloFileSystemResources(); - // invoke the operation and iterate over the result - await foreach (QumuloFileSystemResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string fileSystemName = "aaaaaaaa"; + QumuloFileSystemResourceData data = new QumuloFileSystemResourceData( + new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaaaa"), + new MarketplaceDetails("aaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa", "aa") + { + MarketplaceSubscriptionId = "aaaaaaaaaaaaa", + }, + StorageSku.Standard, + new QumuloUserDetails + { + Email = "viptslwulnpaupfljvnjeq", + }, + "aaaaaaaaaa", + "ekceujoecaashtjlsgcymnrdozk", + 9); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileSystemName, data); + QumuloFileSystemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QumuloFileSystemResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -124,9 +166,9 @@ public async Task Get_FileSystemsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FileSystemsGetMaximumSetGen() + public async Task Get_FileSystemsGetMinimumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MaximumSet_Gen.json + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MinimumSet_Gen.json // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -136,7 +178,7 @@ public async Task Exists_FileSystemsGetMaximumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "ulseeqylxb"; + string subscriptionId = "aaaaaaa"; string resourceGroupName = "rgQumulo"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -145,18 +187,22 @@ public async Task Exists_FileSystemsGetMaximumSetGen() QumuloFileSystemResourceCollection collection = resourceGroupResource.GetQumuloFileSystemResources(); // invoke the operation - string fileSystemName = "nauwwbfoqehgbhdsmkewoboyxeqg"; - bool result = await collection.ExistsAsync(fileSystemName); + string fileSystemName = "aaaaaaaaaaaaaaaaa"; + QumuloFileSystemResource result = await collection.GetAsync(fileSystemName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QumuloFileSystemResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FileSystemsGetMaximumSetGen() + public async Task GetAll_FileSystemsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MaximumSet_Gen.json - // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "FileSystems_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,31 +219,25 @@ public async Task GetIfExists_FileSystemsGetMaximumSetGen() // get the collection of this QumuloFileSystemResource QumuloFileSystemResourceCollection collection = resourceGroupResource.GetQumuloFileSystemResources(); - // invoke the operation - string fileSystemName = "nauwwbfoqehgbhdsmkewoboyxeqg"; - NullableResponse response = await collection.GetIfExistsAsync(fileSystemName); - QumuloFileSystemResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (QumuloFileSystemResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = result.Data; + QumuloFileSystemResourceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FileSystemsGetMinimumSetGen() + public async Task GetAll_FileSystemsListByResourceGroupMinimumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MinimumSet_Gen.json - // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "FileSystems_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -214,22 +254,24 @@ public async Task Get_FileSystemsGetMinimumSetGen() // get the collection of this QumuloFileSystemResource QumuloFileSystemResourceCollection collection = resourceGroupResource.GetQumuloFileSystemResources(); - // invoke the operation - string fileSystemName = "aaaaaaaaaaaaaaaaa"; - QumuloFileSystemResource result = await collection.GetAsync(fileSystemName); + // invoke the operation and iterate over the result + await foreach (QumuloFileSystemResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QumuloFileSystemResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FileSystemsGetMinimumSetGen() + public async Task Exists_FileSystemsGetMaximumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MinimumSet_Gen.json + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MaximumSet_Gen.json // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -239,7 +281,7 @@ public async Task Exists_FileSystemsGetMinimumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "aaaaaaa"; + string subscriptionId = "ulseeqylxb"; string resourceGroupName = "rgQumulo"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -248,7 +290,7 @@ public async Task Exists_FileSystemsGetMinimumSetGen() QumuloFileSystemResourceCollection collection = resourceGroupResource.GetQumuloFileSystemResources(); // invoke the operation - string fileSystemName = "aaaaaaaaaaaaaaaaa"; + string fileSystemName = "nauwwbfoqehgbhdsmkewoboyxeqg"; bool result = await collection.ExistsAsync(fileSystemName); Console.WriteLine($"Succeeded: {result}"); @@ -256,7 +298,7 @@ public async Task Exists_FileSystemsGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FileSystemsGetMinimumSetGen() + public async Task Exists_FileSystemsGetMinimumSetGen() { // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MinimumSet_Gen.json // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. @@ -278,29 +320,17 @@ public async Task GetIfExists_FileSystemsGetMinimumSetGen() // invoke the operation string fileSystemName = "aaaaaaaaaaaaaaaaa"; - NullableResponse response = await collection.GetIfExistsAsync(fileSystemName); - QumuloFileSystemResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(fileSystemName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FileSystemsCreateOrUpdateMaximumSetGen() + public async Task GetIfExists_FileSystemsGetMaximumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "FileSystems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MaximumSet_Gen.json + // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -319,48 +349,29 @@ public async Task CreateOrUpdate_FileSystemsCreateOrUpdateMaximumSetGen() // invoke the operation string fileSystemName = "nauwwbfoqehgbhdsmkewoboyxeqg"; - QumuloFileSystemResourceData data = new QumuloFileSystemResourceData(new AzureLocation("przdlsmlzsszphnixq"), new MarketplaceDetails("x", "eiyhbmpwgezcmzrrfoiskuxlcvwojf", "wfmokfdjbwpjhz") - { - MarketplaceSubscriptionId = "ujrcqvxfnhxxheoth", - }, StorageSku.Standard, new QumuloUserDetails() + NullableResponse response = await collection.GetIfExistsAsync(fileSystemName); + QumuloFileSystemResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Email = "viptslwulnpaupfljvnjeq", - }, "neqctctqdmjezfgt", "ekceujoecaashtjlsgcymnrdozk", 9) + Console.WriteLine("Succeeded with null as result"); + } + else { - Identity = new ManagedServiceIdentity("None") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("key4522")] = new UserAssignedIdentity(), -}, - }, - ClusterLoginUri = new Uri("jjqhgevy"), - PrivateIPs = -{ -IPAddress.Parse("kslguxrwbwkrj") -}, - AvailabilityZone = "maseyqhlnhoiwbabcqabtedbjpip", - Tags = -{ -["key6565"] = "cgdhmupta", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileSystemName, data); - QumuloFileSystemResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QumuloFileSystemResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FileSystemsCreateOrUpdateMinimumSetGen() + public async Task GetIfExists_FileSystemsGetMinimumSetGen() { - // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "FileSystems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_Get_MinimumSet_Gen.json + // this example is just showing the usage of "FileSystems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -369,8 +380,8 @@ public async Task CreateOrUpdate_FileSystemsCreateOrUpdateMinimumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "aaaaaaaaaaaaaaaaaaaaaaaa"; - string resourceGroupName = "rgopenapi"; + string subscriptionId = "aaaaaaa"; + string resourceGroupName = "rgQumulo"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -378,22 +389,22 @@ public async Task CreateOrUpdate_FileSystemsCreateOrUpdateMinimumSetGen() QumuloFileSystemResourceCollection collection = resourceGroupResource.GetQumuloFileSystemResources(); // invoke the operation - string fileSystemName = "aaaaaaaa"; - QumuloFileSystemResourceData data = new QumuloFileSystemResourceData(new AzureLocation("aaaaaaaaaaaaaaaaaaaaaaaaa"), new MarketplaceDetails("aaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaa", "aa") + string fileSystemName = "aaaaaaaaaaaaaaaaa"; + NullableResponse response = await collection.GetIfExistsAsync(fileSystemName); + QumuloFileSystemResource result = response.HasValue ? response.Value : null; + + if (result == null) { - MarketplaceSubscriptionId = "aaaaaaaaaaaaa", - }, StorageSku.Standard, new QumuloUserDetails() + Console.WriteLine("Succeeded with null as result"); + } + else { - Email = "viptslwulnpaupfljvnjeq", - }, "aaaaaaaaaa", "ekceujoecaashtjlsgcymnrdozk", 9); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileSystemName, data); - QumuloFileSystemResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QumuloFileSystemResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QumuloFileSystemResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..3ffea527e6668 --- /dev/null +++ b/sdk/qumulo/Azure.ResourceManager.Qumulo/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Qumulo.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetQumuloFileSystemResources_FileSystemsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "FileSystems_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ulseeqylxb"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (QumuloFileSystemResource item in subscriptionResource.GetQumuloFileSystemResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QumuloFileSystemResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetQumuloFileSystemResources_FileSystemsListBySubscriptionMinimumSetGen() + { + // Generated from example definition: specification/liftrqumulo/resource-manager/Qumulo.Storage/stable/2022-10-12/examples/FileSystems_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "FileSystems_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "aaaaaaa"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (QumuloFileSystemResource item in subscriptionResource.GetQumuloFileSystemResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QumuloFileSystemResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentQuotaLimitBaseCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentQuotaLimitBaseCollection.cs index 4e246a1f949f4..5fdc0d4716a41 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentQuotaLimitBaseCollection.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentQuotaLimitBaseCollection.cs @@ -16,200 +16,6 @@ namespace Azure.ResourceManager.Quota.Samples { public partial class Sample_CurrentQuotaLimitBaseCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_QuotasGetRequestForCompute() - { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuQuotaLimit.json - // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this CurrentQuotaLimitBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); - - // invoke the operation - string resourceName = "standardNDSFamily"; - CurrentQuotaLimitBaseResource result = await collection.GetAsync(resourceName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CurrentQuotaLimitBaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotasGetRequestForCompute() - { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuQuotaLimit.json - // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this CurrentQuotaLimitBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); - - // invoke the operation - string resourceName = "standardNDSFamily"; - bool result = await collection.ExistsAsync(resourceName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotasGetRequestForCompute() - { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuQuotaLimit.json - // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this CurrentQuotaLimitBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); - - // invoke the operation - string resourceName = "standardNDSFamily"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - CurrentQuotaLimitBaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CurrentQuotaLimitBaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_QuotasUsagesRequestForNetwork() - { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuQuotaLimit.json - // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this CurrentQuotaLimitBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); - - // invoke the operation - string resourceName = "MinPublicIpInterNetworkPrefixLength"; - CurrentQuotaLimitBaseResource result = await collection.GetAsync(resourceName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CurrentQuotaLimitBaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotasUsagesRequestForNetwork() - { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuQuotaLimit.json - // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this CurrentQuotaLimitBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); - - // invoke the operation - string resourceName = "MinPublicIpInterNetworkPrefixLength"; - bool result = await collection.ExistsAsync(resourceName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotasUsagesRequestForNetwork() - { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuQuotaLimit.json - // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this CurrentQuotaLimitBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); - - // invoke the operation - string resourceName = "MinPublicIpInterNetworkPrefixLength"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - CurrentQuotaLimitBaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CurrentQuotaLimitBaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_QuotasPutRequestForNetwork() @@ -222,22 +28,18 @@ public async Task CreateOrUpdate_QuotasPutRequestForNetwork() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentQuotaLimitBaseResource string scope = "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Network/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); // invoke the operation string resourceName = "MinPublicIpInterNetworkPrefixLength"; - CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData() + CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData { - Properties = new QuotaProperties() + Properties = new QuotaProperties { Limit = new QuotaLimitObject(10), - Name = new QuotaRequestResourceName() + Name = new QuotaRequestResourceName { Value = "MinPublicIpInterNetworkPrefixLength", }, @@ -266,22 +68,18 @@ public async Task CreateOrUpdate_QuotasPutRequestForNetworkStandardSkuPublicIpAd // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentQuotaLimitBaseResource string scope = "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Network/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); // invoke the operation string resourceName = "StandardSkuPublicIpAddresses"; - CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData() + CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData { - Properties = new QuotaProperties() + Properties = new QuotaProperties { Limit = new QuotaLimitObject(10), - Name = new QuotaRequestResourceName() + Name = new QuotaRequestResourceName { Value = "StandardSkuPublicIpAddresses", }, @@ -310,22 +108,18 @@ public async Task CreateOrUpdate_QuotasPutRequestForCompute() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentQuotaLimitBaseResource string scope = "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); // invoke the operation string resourceName = "standardFSv2Family"; - CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData() + CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData { - Properties = new QuotaProperties() + Properties = new QuotaProperties { Limit = new QuotaLimitObject(10), - Name = new QuotaRequestResourceName() + Name = new QuotaRequestResourceName { Value = "standardFSv2Family", }, @@ -353,22 +147,18 @@ public async Task CreateOrUpdate_QuotasRequestForMachineLearningServicesLowPrior // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentQuotaLimitBaseResource string scope = "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.MachineLearningServices/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); // invoke the operation string resourceName = "TotalLowPriorityCores"; - CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData() + CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData { - Properties = new QuotaProperties() + Properties = new QuotaProperties { Limit = new QuotaLimitObject(10), - Name = new QuotaRequestResourceName() + Name = new QuotaRequestResourceName { Value = "TotalLowPriorityCores", }, @@ -385,6 +175,60 @@ public async Task CreateOrUpdate_QuotasRequestForMachineLearningServicesLowPrior Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_QuotasGetRequestForCompute() + { + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuQuotaLimit.json + // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this CurrentQuotaLimitBaseResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); + + // invoke the operation + string resourceName = "standardNDSFamily"; + CurrentQuotaLimitBaseResource result = await collection.GetAsync(resourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CurrentQuotaLimitBaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_QuotasUsagesRequestForNetwork() + { + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuQuotaLimit.json + // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this CurrentQuotaLimitBaseResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); + + // invoke the operation + string resourceName = "MinPublicIpInterNetworkPrefixLength"; + CurrentQuotaLimitBaseResource result = await collection.GetAsync(resourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CurrentQuotaLimitBaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_QuotasListQuotaLimitsForCompute() @@ -397,13 +241,9 @@ public async Task GetAll_QuotasListQuotaLimitsForCompute() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentQuotaLimitBaseResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (CurrentQuotaLimitBaseResource item in collection.GetAllAsync()) @@ -430,13 +270,9 @@ public async Task GetAll_QuotasListQuotaLimitsForNetwork() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentQuotaLimitBaseResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (CurrentQuotaLimitBaseResource item in collection.GetAllAsync()) @@ -463,13 +299,9 @@ public async Task GetAll_QuotasListQuotaLimitsMachineLearningServices() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentQuotaLimitBaseResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.MachineLearningServices/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(scopeId); + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (CurrentQuotaLimitBaseResource item in collection.GetAllAsync()) @@ -483,5 +315,121 @@ public async Task GetAll_QuotasListQuotaLimitsMachineLearningServices() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_QuotasGetRequestForCompute() + { + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuQuotaLimit.json + // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this CurrentQuotaLimitBaseResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); + + // invoke the operation + string resourceName = "standardNDSFamily"; + bool result = await collection.ExistsAsync(resourceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_QuotasUsagesRequestForNetwork() + { + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuQuotaLimit.json + // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this CurrentQuotaLimitBaseResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); + + // invoke the operation + string resourceName = "MinPublicIpInterNetworkPrefixLength"; + bool result = await collection.ExistsAsync(resourceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_QuotasGetRequestForCompute() + { + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuQuotaLimit.json + // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this CurrentQuotaLimitBaseResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); + + // invoke the operation + string resourceName = "standardNDSFamily"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + CurrentQuotaLimitBaseResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CurrentQuotaLimitBaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_QuotasUsagesRequestForNetwork() + { + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuQuotaLimit.json + // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this CurrentQuotaLimitBaseResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; + CurrentQuotaLimitBaseCollection collection = client.GetCurrentQuotaLimitBases(new ResourceIdentifier(scope)); + + // invoke the operation + string resourceName = "MinPublicIpInterNetworkPrefixLength"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + CurrentQuotaLimitBaseResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CurrentQuotaLimitBaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentQuotaLimitBaseResource.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentQuotaLimitBaseResource.cs index 5f242fe385546..777f8d3c5f6d2 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentQuotaLimitBaseResource.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentQuotaLimitBaseResource.cs @@ -94,12 +94,12 @@ public async Task Update_QuotasRequestPatchForCompute() CurrentQuotaLimitBaseResource currentQuotaLimitBase = client.GetCurrentQuotaLimitBaseResource(currentQuotaLimitBaseResourceId); // invoke the operation - CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData() + CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData { - Properties = new QuotaProperties() + Properties = new QuotaProperties { Limit = new QuotaLimitObject(10), - Name = new QuotaRequestResourceName() + Name = new QuotaRequestResourceName { Value = "standardFSv2Family", }, @@ -135,12 +135,12 @@ public async Task Update_QuotasRequestPatchForNetwork() CurrentQuotaLimitBaseResource currentQuotaLimitBase = client.GetCurrentQuotaLimitBaseResource(currentQuotaLimitBaseResourceId); // invoke the operation - CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData() + CurrentQuotaLimitBaseData data = new CurrentQuotaLimitBaseData { - Properties = new QuotaProperties() + Properties = new QuotaProperties { Limit = new QuotaLimitObject(10), - Name = new QuotaRequestResourceName() + Name = new QuotaRequestResourceName { Value = "MinPublicIpInterNetworkPrefixLength", }, diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentUsagesBaseCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentUsagesBaseCollection.cs index f419d74eaa83f..38e438f7e722d 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentUsagesBaseCollection.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_CurrentUsagesBaseCollection.cs @@ -27,13 +27,9 @@ public async Task Get_QuotasUsagesRequestForCompute() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentUsagesBaseResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(scopeId); + CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(new ResourceIdentifier(scope)); // invoke the operation string resourceName = "standardNDSFamily"; @@ -48,9 +44,9 @@ public async Task Get_QuotasUsagesRequestForCompute() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotasUsagesRequestForCompute() + public async Task Get_QuotasUsagesRequestForNetwork() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuUsages.json + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuUsages.json // this example is just showing the usage of "Usages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -58,123 +54,113 @@ public async Task Exists_QuotasUsagesRequestForCompute() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentUsagesBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; + CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(new ResourceIdentifier(scope)); // invoke the operation - string resourceName = "standardNDSFamily"; - bool result = await collection.ExistsAsync(resourceName); + string resourceName = "MinPublicIpInterNetworkPrefixLength"; + CurrentUsagesBaseResource result = await collection.GetAsync(resourceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CurrentUsagesBaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotasUsagesRequestForCompute() + public async Task GetAll_QuotasListUsagesForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuUsages.json - // this example is just showing the usage of "Usages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeUsages.json + // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentUsagesBaseResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(scopeId); + CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(new ResourceIdentifier(scope)); - // invoke the operation - string resourceName = "standardNDSFamily"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - CurrentUsagesBaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CurrentUsagesBaseResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CurrentUsagesBaseData resourceData = result.Data; + CurrentUsagesBaseData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QuotasUsagesRequestForNetwork() + public async Task GetAll_QuotasListUsagesForNetwork() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuUsages.json - // this example is just showing the usage of "Usages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkUsages.json + // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentUsagesBaseResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(scopeId); + CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(new ResourceIdentifier(scope)); - // invoke the operation - string resourceName = "MinPublicIpInterNetworkPrefixLength"; - CurrentUsagesBaseResource result = await collection.GetAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (CurrentUsagesBaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CurrentUsagesBaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CurrentUsagesBaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotasUsagesRequestForNetwork() + public async Task GetAll_QuotasListUsagesMachineLearningServices() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuUsages.json - // this example is just showing the usage of "Usages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getMachineLearningServicesUsages.json + // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentUsagesBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.MachineLearningServices/locations/eastus"; + CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(new ResourceIdentifier(scope)); - // invoke the operation - string resourceName = "MinPublicIpInterNetworkPrefixLength"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (CurrentUsagesBaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CurrentUsagesBaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotasUsagesRequestForNetwork() + public async Task Exists_QuotasUsagesRequestForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuUsages.json + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuUsages.json // this example is just showing the usage of "Usages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -182,130 +168,108 @@ public async Task GetIfExists_QuotasUsagesRequestForNetwork() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentUsagesBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; + CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(new ResourceIdentifier(scope)); // invoke the operation - string resourceName = "MinPublicIpInterNetworkPrefixLength"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - CurrentUsagesBaseResource result = response.HasValue ? response.Value : null; + string resourceName = "standardNDSFamily"; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CurrentUsagesBaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QuotasListUsagesForCompute() + public async Task Exists_QuotasUsagesRequestForNetwork() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeUsages.json - // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuUsages.json + // this example is just showing the usage of "Usages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentUsagesBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; + CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (CurrentUsagesBaseResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CurrentUsagesBaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string resourceName = "MinPublicIpInterNetworkPrefixLength"; + bool result = await collection.ExistsAsync(resourceName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QuotasListUsagesForNetwork() + public async Task GetIfExists_QuotasUsagesRequestForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkUsages.json - // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getComputeOneSkuUsages.json + // this example is just showing the usage of "Usages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentUsagesBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; + CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (CurrentUsagesBaseResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "standardNDSFamily"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + CurrentUsagesBaseResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CurrentUsagesBaseData resourceData = item.Data; + CurrentUsagesBaseData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QuotasListUsagesMachineLearningServices() + public async Task GetIfExists_QuotasUsagesRequestForNetwork() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getMachineLearningServicesUsages.json - // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getNetworkOneSkuUsages.json + // this example is just showing the usage of "Usages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CurrentUsagesBaseResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.MachineLearningServices/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Network/locations/eastus"; + CurrentUsagesBaseCollection collection = client.GetCurrentUsagesBases(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (CurrentUsagesBaseResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "MinPublicIpInterNetworkPrefixLength"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + CurrentUsagesBaseResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CurrentUsagesBaseData resourceData = item.Data; + CurrentUsagesBaseData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEnforcementCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEnforcementCollection.cs index 094f19b3c3910..714035a40cfd4 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEnforcementCollection.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEnforcementCollection.cs @@ -41,9 +41,9 @@ public async Task CreateOrUpdate_GroupQuotaLocationSettingsCreateOrUpdate() // invoke the operation AzureLocation location = new AzureLocation("eastus"); - GroupQuotaEnforcementData data = new GroupQuotaEnforcementData() + GroupQuotaEnforcementData data = new GroupQuotaEnforcementData { - Properties = new GroupQuotaEnforcementProperties() + Properties = new GroupQuotaEnforcementProperties { EnforcementEnabled = GroupQuotaEnforcementState.Enabled, }, @@ -83,9 +83,9 @@ public async Task CreateOrUpdate_GroupQuotaLocationSettingsCreateOrUpdateFailed( // invoke the operation AzureLocation location = new AzureLocation("eastus"); - GroupQuotaEnforcementData data = new GroupQuotaEnforcementData() + GroupQuotaEnforcementData data = new GroupQuotaEnforcementData { - Properties = new GroupQuotaEnforcementProperties() + Properties = new GroupQuotaEnforcementProperties { EnforcementEnabled = GroupQuotaEnforcementState.Enabled, }, @@ -136,10 +136,10 @@ public async Task Get_GroupQuotasEnforcementGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GroupQuotasEnforcementGet() + public async Task GetAll_GroupQuotaEnforcementList() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/GetGroupQuotaEnforcement.json - // this example is just showing the usage of "GroupQuotaLocationSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/ListGroupQuotaEnforcement.json + // this example is just showing the usage of "GroupQuotaLocationSettings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -157,16 +157,22 @@ public async Task Exists_GroupQuotasEnforcementGet() string resourceProviderName = "Microsoft.Compute"; GroupQuotaEnforcementCollection collection = groupQuotaEntity.GetGroupQuotaEnforcements(resourceProviderName); - // invoke the operation - AzureLocation location = new AzureLocation("eastus"); - bool result = await collection.ExistsAsync(location); + // invoke the operation and iterate over the result + await foreach (GroupQuotaEnforcementResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GroupQuotaEnforcementData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GroupQuotasEnforcementGet() + public async Task Exists_GroupQuotasEnforcementGet() { // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/GetGroupQuotaEnforcement.json // this example is just showing the usage of "GroupQuotaLocationSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -189,29 +195,17 @@ public async Task GetIfExists_GroupQuotasEnforcementGet() // invoke the operation AzureLocation location = new AzureLocation("eastus"); - NullableResponse response = await collection.GetIfExistsAsync(location); - GroupQuotaEnforcementResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(location); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GroupQuotaEnforcementData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GroupQuotaEnforcementList() + public async Task GetIfExists_GroupQuotasEnforcementGet() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/ListGroupQuotaEnforcement.json - // this example is just showing the usage of "GroupQuotaLocationSettings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/GetGroupQuotaEnforcement.json + // this example is just showing the usage of "GroupQuotaLocationSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -229,17 +223,23 @@ public async Task GetAll_GroupQuotaEnforcementList() string resourceProviderName = "Microsoft.Compute"; GroupQuotaEnforcementCollection collection = groupQuotaEntity.GetGroupQuotaEnforcements(resourceProviderName); - // invoke the operation and iterate over the result - await foreach (GroupQuotaEnforcementResource item in collection.GetAllAsync()) + // invoke the operation + AzureLocation location = new AzureLocation("eastus"); + NullableResponse response = await collection.GetIfExistsAsync(location); + GroupQuotaEnforcementResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GroupQuotaEnforcementData resourceData = item.Data; + GroupQuotaEnforcementData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEnforcementResource.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEnforcementResource.cs index 68633643d1219..e36d94c6d1d15 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEnforcementResource.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEnforcementResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GroupQuotaEnforcementResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GroupQuotaLocationSettingsPatch() + public async Task Get_GroupQuotasEnforcementGet() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/PatchGroupQuotaEnforcement.json - // this example is just showing the usage of "GroupQuotaLocationSettings_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/GetGroupQuotaEnforcement.json + // this example is just showing the usage of "GroupQuotaLocationSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_GroupQuotaLocationSettingsPatch() GroupQuotaEnforcementResource groupQuotaEnforcement = client.GetGroupQuotaEnforcementResource(groupQuotaEnforcementResourceId); // invoke the operation - GroupQuotaEnforcementData data = new GroupQuotaEnforcementData() - { - Properties = new GroupQuotaEnforcementProperties() - { - EnforcementEnabled = GroupQuotaEnforcementState.Enabled, - }, - }; - ArmOperation lro = await groupQuotaEnforcement.UpdateAsync(WaitUntil.Completed, data); - GroupQuotaEnforcementResource result = lro.Value; + GroupQuotaEnforcementResource result = await groupQuotaEnforcement.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +49,10 @@ public async Task Update_GroupQuotaLocationSettingsPatch() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GroupQuotasEnforcementGet() + public async Task Update_GroupQuotaLocationSettingsPatch() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/GetGroupQuotaEnforcement.json - // this example is just showing the usage of "GroupQuotaLocationSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasEnforcement/PatchGroupQuotaEnforcement.json + // this example is just showing the usage of "GroupQuotaLocationSettings_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +69,15 @@ public async Task Get_GroupQuotasEnforcementGet() GroupQuotaEnforcementResource groupQuotaEnforcement = client.GetGroupQuotaEnforcementResource(groupQuotaEnforcementResourceId); // invoke the operation - GroupQuotaEnforcementResource result = await groupQuotaEnforcement.GetAsync(); + GroupQuotaEnforcementData data = new GroupQuotaEnforcementData + { + Properties = new GroupQuotaEnforcementProperties + { + EnforcementEnabled = GroupQuotaEnforcementState.Enabled, + }, + }; + ArmOperation lro = await groupQuotaEnforcement.UpdateAsync(WaitUntil.Completed, data); + GroupQuotaEnforcementResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEntityCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEntityCollection.cs index ae5ce513787db..32dea99cf1181 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEntityCollection.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEntityCollection.cs @@ -40,12 +40,12 @@ public async Task CreateOrUpdate_GroupQuotasPutRequestForCompute() // invoke the operation string groupQuotaName = "groupquota1"; - GroupQuotaEntityData data = new GroupQuotaEntityData() + GroupQuotaEntityData data = new GroupQuotaEntityData { - Properties = new GroupQuotaEntityBase() + Properties = new GroupQuotaEntityBase { DisplayName = "GroupQuota1", - AdditionalAttributes = new GroupQuotaAdditionalAttributes(new GroupQuotaGroupingId() + AdditionalAttributes = new GroupQuotaAdditionalAttributes(new GroupQuotaGroupingId { GroupingIdType = GroupQuotaGroupingIdType.ServiceTreeId, Value = "yourServiceTreeIdHere", @@ -99,10 +99,10 @@ public async Task Get_GroupQuotasGetRequestForCompute() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GroupQuotasGetRequestForCompute() + public async Task GetAll_GroupQuotasListRequestForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/GetGroupQuotas.json - // this example is just showing the usage of "GroupQuotas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/GetGroupQuotasList.json + // this example is just showing the usage of "GroupQuotas_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +118,22 @@ public async Task Exists_GroupQuotasGetRequestForCompute() // get the collection of this GroupQuotaEntityResource GroupQuotaEntityCollection collection = managementGroupResource.GetGroupQuotaEntities(); - // invoke the operation - string groupQuotaName = "groupquota1"; - bool result = await collection.ExistsAsync(groupQuotaName); + // invoke the operation and iterate over the result + await foreach (GroupQuotaEntityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GroupQuotaEntityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GroupQuotasGetRequestForCompute() + public async Task Exists_GroupQuotasGetRequestForCompute() { // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/GetGroupQuotas.json // this example is just showing the usage of "GroupQuotas_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +154,17 @@ public async Task GetIfExists_GroupQuotasGetRequestForCompute() // invoke the operation string groupQuotaName = "groupquota1"; - NullableResponse response = await collection.GetIfExistsAsync(groupQuotaName); - GroupQuotaEntityResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(groupQuotaName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GroupQuotaEntityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GroupQuotasListRequestForCompute() + public async Task GetIfExists_GroupQuotasGetRequestForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/GetGroupQuotasList.json - // this example is just showing the usage of "GroupQuotas_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/GetGroupQuotas.json + // this example is just showing the usage of "GroupQuotas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_GroupQuotasListRequestForCompute() // get the collection of this GroupQuotaEntityResource GroupQuotaEntityCollection collection = managementGroupResource.GetGroupQuotaEntities(); - // invoke the operation and iterate over the result - await foreach (GroupQuotaEntityResource item in collection.GetAllAsync()) + // invoke the operation + string groupQuotaName = "groupquota1"; + NullableResponse response = await collection.GetIfExistsAsync(groupQuotaName); + GroupQuotaEntityResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GroupQuotaEntityData resourceData = item.Data; + GroupQuotaEntityData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEntityResource.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEntityResource.cs index da00fa0eb6813..c7bc5789c4883 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEntityResource.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaEntityResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GroupQuotaEntityResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GroupQuotasPatchRequestForCompute() + public async Task Get_GroupQuotasGetRequestForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/PatchGroupQuotas.json - // this example is just showing the usage of "GroupQuotas_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/GetGroupQuotas.json + // this example is just showing the usage of "GroupQuotas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,24 +36,7 @@ public async Task Update_GroupQuotasPatchRequestForCompute() GroupQuotaEntityResource groupQuotaEntity = client.GetGroupQuotaEntityResource(groupQuotaEntityResourceId); // invoke the operation - GroupQuotaEntityPatch patch = new GroupQuotaEntityPatch() - { - Properties = new GroupQuotasEntityBasePatch() - { - DisplayName = "UpdatedGroupQuota1", - AdditionalAttributes = new GroupQuotaAdditionalAttributesPatch() - { - GroupId = new GroupQuotaGroupingId() - { - GroupingIdType = GroupQuotaGroupingIdType.ServiceTreeId, - Value = "UpdatedServiceTreeIdHere", - }, - Environment = GroupQuotaEnvironmentType.Production, - }, - }, - }; - ArmOperation lro = await groupQuotaEntity.UpdateAsync(WaitUntil.Completed, patch); - GroupQuotaEntityResource result = lro.Value; + GroupQuotaEntityResource result = await groupQuotaEntity.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -64,10 +47,10 @@ public async Task Update_GroupQuotasPatchRequestForCompute() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GroupQuotasGetRequestForCompute() + public async Task Delete_GroupQuotasDeleteRequestForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/GetGroupQuotas.json - // this example is just showing the usage of "GroupQuotas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/DeleteGroupQuotas.json + // this example is just showing the usage of "GroupQuotas_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -82,21 +65,17 @@ public async Task Get_GroupQuotasGetRequestForCompute() GroupQuotaEntityResource groupQuotaEntity = client.GetGroupQuotaEntityResource(groupQuotaEntityResourceId); // invoke the operation - GroupQuotaEntityResource result = await groupQuotaEntity.GetAsync(); + await groupQuotaEntity.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GroupQuotaEntityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_GroupQuotasDeleteRequestForCompute() + public async Task Update_GroupQuotasPatchRequestForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/DeleteGroupQuotas.json - // this example is just showing the usage of "GroupQuotas_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotas/PatchGroupQuotas.json + // this example is just showing the usage of "GroupQuotas_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +90,30 @@ public async Task Delete_GroupQuotasDeleteRequestForCompute() GroupQuotaEntityResource groupQuotaEntity = client.GetGroupQuotaEntityResource(groupQuotaEntityResourceId); // invoke the operation - await groupQuotaEntity.DeleteAsync(WaitUntil.Completed); + GroupQuotaEntityPatch patch = new GroupQuotaEntityPatch + { + Properties = new GroupQuotasEntityBasePatch + { + DisplayName = "UpdatedGroupQuota1", + AdditionalAttributes = new GroupQuotaAdditionalAttributesPatch + { + GroupId = new GroupQuotaGroupingId + { + GroupingIdType = GroupQuotaGroupingIdType.ServiceTreeId, + Value = "UpdatedServiceTreeIdHere", + }, + Environment = GroupQuotaEnvironmentType.Production, + }, + }, + }; + ArmOperation lro = await groupQuotaEntity.UpdateAsync(WaitUntil.Completed, patch); + GroupQuotaEntityResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GroupQuotaEntityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaLimitCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaLimitCollection.cs index aee9997d163b7..50f15fc7be046 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaLimitCollection.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaLimitCollection.cs @@ -52,10 +52,10 @@ public async Task Get_GroupQuotaLimitsGetRequestForCompute() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GroupQuotaLimitsGetRequestForCompute() + public async Task GetAll_GroupQuotaLimitsListRequestForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimits/GetGroupQuotaLimits-Compute.json - // this example is just showing the usage of "GroupQuotaLimits_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimits/ListGroupQuotaLimits-Compute.json + // this example is just showing the usage of "GroupQuotaLimits_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,17 +73,23 @@ public async Task Exists_GroupQuotaLimitsGetRequestForCompute() string resourceProviderName = "Microsoft.Compute"; GroupQuotaLimitCollection collection = groupQuotaEntity.GetGroupQuotaLimits(resourceProviderName); - // invoke the operation - string resourceName = "cores"; + // invoke the operation and iterate over the result string filter = "location eq westus"; - bool result = await collection.ExistsAsync(resourceName, filter); + await foreach (GroupQuotaLimitResource item in collection.GetAllAsync(filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GroupQuotaLimitData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GroupQuotaLimitsGetRequestForCompute() + public async Task Exists_GroupQuotaLimitsGetRequestForCompute() { // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimits/GetGroupQuotaLimits-Compute.json // this example is just showing the usage of "GroupQuotaLimits_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +113,17 @@ public async Task GetIfExists_GroupQuotaLimitsGetRequestForCompute() // invoke the operation string resourceName = "cores"; string filter = "location eq westus"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName, filter); - GroupQuotaLimitResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName, filter); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GroupQuotaLimitData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GroupQuotaLimitsListRequestForCompute() + public async Task GetIfExists_GroupQuotaLimitsGetRequestForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimits/ListGroupQuotaLimits-Compute.json - // this example is just showing the usage of "GroupQuotaLimits_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotaLimits/GetGroupQuotaLimits-Compute.json + // this example is just showing the usage of "GroupQuotaLimits_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,18 +141,24 @@ public async Task GetAll_GroupQuotaLimitsListRequestForCompute() string resourceProviderName = "Microsoft.Compute"; GroupQuotaLimitCollection collection = groupQuotaEntity.GetGroupQuotaLimits(resourceProviderName); - // invoke the operation and iterate over the result + // invoke the operation + string resourceName = "cores"; string filter = "location eq westus"; - await foreach (GroupQuotaLimitResource item in collection.GetAllAsync(filter)) + NullableResponse response = await collection.GetIfExistsAsync(resourceName, filter); + GroupQuotaLimitResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GroupQuotaLimitData resourceData = item.Data; + GroupQuotaLimitData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionCollection.cs index fb18d84265584..7809d35f9e846 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionCollection.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionCollection.cs @@ -84,10 +84,10 @@ public async Task Get_GroupQuotaSubscriptionsGetSubscriptions() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GroupQuotaSubscriptionsGetSubscriptions() + public async Task GetAll_GroupQuotaSubscriptionsListSubscriptions() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/GetGroupQuotaSubscriptions.json - // this example is just showing the usage of "GroupQuotaSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/ListGroupQuotaSubscriptions.json + // this example is just showing the usage of "GroupQuotaSubscriptions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,16 +104,22 @@ public async Task Exists_GroupQuotaSubscriptionsGetSubscriptions() // get the collection of this GroupQuotaSubscriptionResource GroupQuotaSubscriptionCollection collection = groupQuotaEntity.GetGroupQuotaSubscriptions(); - // invoke the operation - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - bool result = await collection.ExistsAsync(subscriptionId); + // invoke the operation and iterate over the result + await foreach (GroupQuotaSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GroupQuotaSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GroupQuotaSubscriptionsGetSubscriptions() + public async Task Exists_GroupQuotaSubscriptionsGetSubscriptions() { // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/GetGroupQuotaSubscriptions.json // this example is just showing the usage of "GroupQuotaSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -135,29 +141,17 @@ public async Task GetIfExists_GroupQuotaSubscriptionsGetSubscriptions() // invoke the operation string subscriptionId = "00000000-0000-0000-0000-000000000000"; - NullableResponse response = await collection.GetIfExistsAsync(subscriptionId); - GroupQuotaSubscriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(subscriptionId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GroupQuotaSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GroupQuotaSubscriptionsListSubscriptions() + public async Task GetIfExists_GroupQuotaSubscriptionsGetSubscriptions() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/ListGroupQuotaSubscriptions.json - // this example is just showing the usage of "GroupQuotaSubscriptions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/GetGroupQuotaSubscriptions.json + // this example is just showing the usage of "GroupQuotaSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,17 +168,23 @@ public async Task GetAll_GroupQuotaSubscriptionsListSubscriptions() // get the collection of this GroupQuotaSubscriptionResource GroupQuotaSubscriptionCollection collection = groupQuotaEntity.GetGroupQuotaSubscriptions(); - // invoke the operation and iterate over the result - await foreach (GroupQuotaSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + NullableResponse response = await collection.GetIfExistsAsync(subscriptionId); + GroupQuotaSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GroupQuotaSubscriptionData resourceData = item.Data; + GroupQuotaSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionRequestStatusCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionRequestStatusCollection.cs index 22880347656d4..c1d15ee5eedff 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionRequestStatusCollection.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionRequestStatusCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_GroupQuotaSubscriptionRequestStatusCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GroupQuotaSubscriptionRequestsList() + public async Task Get_GroupQuotaSubscriptionRequestsGet() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionRequests/SubscriptionRequests_List.json - // this example is just showing the usage of "GroupQuotaSubscriptionRequests_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionRequests/SubscriptionRequests_Get.json + // this example is just showing the usage of "GroupQuotaSubscriptionRequests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_GroupQuotaSubscriptionRequestsList() // get the collection of this GroupQuotaSubscriptionRequestStatusResource GroupQuotaSubscriptionRequestStatusCollection collection = groupQuotaEntity.GetGroupQuotaSubscriptionRequestStatuses(); - // invoke the operation and iterate over the result - await foreach (GroupQuotaSubscriptionRequestStatusResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GroupQuotaSubscriptionRequestStatusData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string requestId = "00000000-0000-0000-0000-000000000000"; + GroupQuotaSubscriptionRequestStatusResource result = await collection.GetAsync(requestId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GroupQuotaSubscriptionRequestStatusData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GroupQuotaSubscriptionRequestsGet() + public async Task GetAll_GroupQuotaSubscriptionRequestsList() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionRequests/SubscriptionRequests_Get.json - // this example is just showing the usage of "GroupQuotaSubscriptionRequests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionRequests/SubscriptionRequests_List.json + // this example is just showing the usage of "GroupQuotaSubscriptionRequests_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +70,17 @@ public async Task Get_GroupQuotaSubscriptionRequestsGet() // get the collection of this GroupQuotaSubscriptionRequestStatusResource GroupQuotaSubscriptionRequestStatusCollection collection = groupQuotaEntity.GetGroupQuotaSubscriptionRequestStatuses(); - // invoke the operation - string requestId = "00000000-0000-0000-0000-000000000000"; - GroupQuotaSubscriptionRequestStatusResource result = await collection.GetAsync(requestId); + // invoke the operation and iterate over the result + await foreach (GroupQuotaSubscriptionRequestStatusResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GroupQuotaSubscriptionRequestStatusData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GroupQuotaSubscriptionRequestStatusData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionResource.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionResource.cs index c514f274d7951..8189117256255 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionResource.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_GroupQuotaSubscriptionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_GroupQuotaSubscriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GroupQuotaSubscriptionsPatchSubscriptions() + public async Task Get_GroupQuotaSubscriptionsGetSubscriptions() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/PatchGroupQuotasSubscription.json - // this example is just showing the usage of "GroupQuotaSubscriptions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/GetGroupQuotaSubscriptions.json + // this example is just showing the usage of "GroupQuotaSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,8 +36,7 @@ public async Task Update_GroupQuotaSubscriptionsPatchSubscriptions() GroupQuotaSubscriptionResource groupQuotaSubscription = client.GetGroupQuotaSubscriptionResource(groupQuotaSubscriptionResourceId); // invoke the operation - ArmOperation lro = await groupQuotaSubscription.UpdateAsync(WaitUntil.Completed); - GroupQuotaSubscriptionResource result = lro.Value; + GroupQuotaSubscriptionResource result = await groupQuotaSubscription.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -74,10 +73,10 @@ public async Task Delete_GroupQuotaSubscriptionsDeleteSubscriptions() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GroupQuotaSubscriptionsGetSubscriptions() + public async Task Update_GroupQuotaSubscriptionsPatchSubscriptions() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/GetGroupQuotaSubscriptions.json - // this example is just showing the usage of "GroupQuotaSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/GroupQuotasSubscriptions/PatchGroupQuotasSubscription.json + // this example is just showing the usage of "GroupQuotaSubscriptions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,7 +92,8 @@ public async Task Get_GroupQuotaSubscriptionsGetSubscriptions() GroupQuotaSubscriptionResource groupQuotaSubscription = client.GetGroupQuotaSubscriptionResource(groupQuotaSubscriptionResourceId); // invoke the operation - GroupQuotaSubscriptionResource result = await groupQuotaSubscription.GetAsync(); + ArmOperation lro = await groupQuotaSubscription.UpdateAsync(WaitUntil.Completed); + GroupQuotaSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_ManagementGroupResourceExtensions.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_ManagementGroupResourceExtensions.cs new file mode 100644 index 0000000000000..9041a31fb8dc0 --- /dev/null +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_ManagementGroupResourceExtensions.cs @@ -0,0 +1,137 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ManagementGroups; +using Azure.ResourceManager.Quota.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Quota.Samples +{ + public partial class Sample_ManagementGroupResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetQuotaAllocationRequestStatusesByResourceProvider_SubscriptionQuotaAllocationListRequestForCompute() + { + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocationRequests/SubscriptionQuotaAllocationRequests_List-Compute.json + // this example is just showing the usage of "GroupQuotaSubscriptionAllocationRequest_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagementGroupResource created on azure + // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource + string managementGroupId = "E7EC67B3-7657-4966-BFFC-41EFD36BAA09"; + ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); + ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); + + // invoke the operation and iterate over the result + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string groupQuotaName = "groupquota1"; + string resourceProviderName = "Microsoft.Compute"; + string filter = "location eq westus"; + await foreach (QuotaAllocationRequestStatusResource item in managementGroupResource.GetQuotaAllocationRequestStatusesByResourceProviderAsync(subscriptionId, groupQuotaName, resourceProviderName, filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaAllocationRequestStatusData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdateGroupQuotaSubscriptionAllocationRequest_SubscriptionQuotaAllocationPutRequestForCompute() + { + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocationRequests/PutSubscriptionQuotaAllocationRequest-Compute.json + // this example is just showing the usage of "GroupQuotaSubscriptionAllocationRequest_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagementGroupResource created on azure + // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource + string managementGroupId = "E7EC67B3-7657-4966-BFFC-41EFD36BAA09"; + ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); + ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); + + // invoke the operation + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string groupQuotaName = "groupquota1"; + string resourceProviderName = "Microsoft.Compute"; + string resourceName = "standardav2family"; + QuotaAllocationRequestStatusData data = new QuotaAllocationRequestStatusData + { + RequestedResource = new QuotaAllocationRequestBase + { + Limit = 10L, + Region = "westus", + }, + }; + ArmOperation lro = await managementGroupResource.CreateOrUpdateGroupQuotaSubscriptionAllocationRequestAsync(WaitUntil.Completed, subscriptionId, groupQuotaName, resourceProviderName, resourceName, data); + QuotaAllocationRequestStatusResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaAllocationRequestStatusData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task UpdateGroupQuotaSubscriptionAllocationRequest_SubscriptionQuotaAllocationPatchRequestForCompute() + { + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocationRequests/PatchSubscriptionQuotaAllocationRequest-Compute.json + // this example is just showing the usage of "GroupQuotaSubscriptionAllocationRequest_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagementGroupResource created on azure + // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource + string managementGroupId = "E7EC67B3-7657-4966-BFFC-41EFD36BAA09"; + ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); + ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); + + // invoke the operation + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string groupQuotaName = "groupquota1"; + string resourceProviderName = "Microsoft.Compute"; + string resourceName = "standardav2family"; + QuotaAllocationRequestStatusData data = new QuotaAllocationRequestStatusData + { + RequestedResource = new QuotaAllocationRequestBase + { + Limit = 10L, + Region = "westus", + }, + }; + ArmOperation lro = await managementGroupResource.UpdateGroupQuotaSubscriptionAllocationRequestAsync(WaitUntil.Completed, subscriptionId, groupQuotaName, resourceProviderName, resourceName, data); + QuotaAllocationRequestStatusResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaAllocationRequestStatusData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_QuotaAllocationRequestStatusResource.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_QuotaAllocationRequestStatusResource.cs index ea7d956e3dd56..0a54311a09d3b 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_QuotaAllocationRequestStatusResource.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_QuotaAllocationRequestStatusResource.cs @@ -9,8 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.ManagementGroups; -using Azure.ResourceManager.Quota.Models; using NUnit.Framework; namespace Azure.ResourceManager.Quota.Samples @@ -47,122 +45,5 @@ public async Task Get_SubscriptionQuotaAllocationRequestsGetRequestForCompute() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetQuotaAllocationRequestStatusesByResourceProvider_SubscriptionQuotaAllocationListRequestForCompute() - { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocationRequests/SubscriptionQuotaAllocationRequests_List-Compute.json - // this example is just showing the usage of "GroupQuotaSubscriptionAllocationRequest_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "E7EC67B3-7657-4966-BFFC-41EFD36BAA09"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation and iterate over the result - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string groupQuotaName = "groupquota1"; - string resourceProviderName = "Microsoft.Compute"; - string filter = "location eq westus"; - await foreach (QuotaAllocationRequestStatusResource item in managementGroupResource.GetQuotaAllocationRequestStatusesByResourceProviderAsync(subscriptionId, groupQuotaName, resourceProviderName, filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaAllocationRequestStatusData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdateGroupQuotaSubscriptionAllocationRequest_SubscriptionQuotaAllocationPutRequestForCompute() - { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocationRequests/PutSubscriptionQuotaAllocationRequest-Compute.json - // this example is just showing the usage of "GroupQuotaSubscriptionAllocationRequest_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "E7EC67B3-7657-4966-BFFC-41EFD36BAA09"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string groupQuotaName = "groupquota1"; - string resourceProviderName = "Microsoft.Compute"; - string resourceName = "standardav2family"; - QuotaAllocationRequestStatusData data = new QuotaAllocationRequestStatusData() - { - RequestedResource = new QuotaAllocationRequestBase() - { - Limit = 10L, - Region = "westus", - }, - }; - ArmOperation lro = await managementGroupResource.CreateOrUpdateGroupQuotaSubscriptionAllocationRequestAsync(WaitUntil.Completed, subscriptionId, groupQuotaName, resourceProviderName, resourceName, data); - QuotaAllocationRequestStatusResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaAllocationRequestStatusData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task UpdateGroupQuotaSubscriptionAllocationRequest_SubscriptionQuotaAllocationPatchRequestForCompute() - { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocationRequests/PatchSubscriptionQuotaAllocationRequest-Compute.json - // this example is just showing the usage of "GroupQuotaSubscriptionAllocationRequest_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagementGroupResource created on azure - // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string managementGroupId = "E7EC67B3-7657-4966-BFFC-41EFD36BAA09"; - ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(managementGroupId); - ManagementGroupResource managementGroupResource = client.GetManagementGroupResource(managementGroupResourceId); - - // invoke the operation - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string groupQuotaName = "groupquota1"; - string resourceProviderName = "Microsoft.Compute"; - string resourceName = "standardav2family"; - QuotaAllocationRequestStatusData data = new QuotaAllocationRequestStatusData() - { - RequestedResource = new QuotaAllocationRequestBase() - { - Limit = 10L, - Region = "westus", - }, - }; - ArmOperation lro = await managementGroupResource.UpdateGroupQuotaSubscriptionAllocationRequestAsync(WaitUntil.Completed, subscriptionId, groupQuotaName, resourceProviderName, resourceName, data); - QuotaAllocationRequestStatusResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaAllocationRequestStatusData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_QuotaRequestDetailCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_QuotaRequestDetailCollection.cs index db77f3008ec69..1a6a30c148862 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_QuotaRequestDetailCollection.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_QuotaRequestDetailCollection.cs @@ -27,13 +27,9 @@ public async Task Get_QuotaRequestFailed() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this QuotaRequestDetailResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(scopeId); + QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(new ResourceIdentifier(scope)); // invoke the operation string id = "2B5C8515-37D8-4B6A-879B-CD641A2CF605"; @@ -48,9 +44,9 @@ public async Task Get_QuotaRequestFailed() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotaRequestFailed() + public async Task Get_QuotaRequestInProgress() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusFailed.json + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusInProgress.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -58,26 +54,26 @@ public async Task Exists_QuotaRequestFailed() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this QuotaRequestDetailResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(scopeId); + QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(new ResourceIdentifier(scope)); // invoke the operation string id = "2B5C8515-37D8-4B6A-879B-CD641A2CF605"; - bool result = await collection.ExistsAsync(id); + QuotaRequestDetailResource result = await collection.GetAsync(id); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaRequestDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotaRequestFailed() + public async Task Get_QuotaRequestStatus() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusFailed.json + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusById.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -85,69 +81,55 @@ public async Task GetIfExists_QuotaRequestFailed() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this QuotaRequestDetailResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(scopeId); + string scope = "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Compute/locations/eastus"; + QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(new ResourceIdentifier(scope)); // invoke the operation string id = "2B5C8515-37D8-4B6A-879B-CD641A2CF605"; - NullableResponse response = await collection.GetIfExistsAsync(id); - QuotaRequestDetailResource result = response.HasValue ? response.Value : null; + QuotaRequestDetailResource result = await collection.GetAsync(id); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaRequestDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaRequestDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QuotaRequestInProgress() + public async Task GetAll_QuotaRequestHistory() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusInProgress.json - // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestsHistory.json + // this example is just showing the usage of "QuotaRequestStatus_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this QuotaRequestDetailResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(scopeId); + string scope = "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Compute/locations/eastus"; + QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(new ResourceIdentifier(scope)); - // invoke the operation - string id = "2B5C8515-37D8-4B6A-879B-CD641A2CF605"; - QuotaRequestDetailResource result = await collection.GetAsync(id); + // invoke the operation and iterate over the result + await foreach (QuotaRequestDetailResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaRequestDetailData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaRequestDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotaRequestInProgress() + public async Task Exists_QuotaRequestFailed() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusInProgress.json + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusFailed.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -155,13 +137,9 @@ public async Task Exists_QuotaRequestInProgress() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this QuotaRequestDetailResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(scopeId); + QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(new ResourceIdentifier(scope)); // invoke the operation string id = "2B5C8515-37D8-4B6A-879B-CD641A2CF605"; @@ -172,7 +150,7 @@ public async Task Exists_QuotaRequestInProgress() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotaRequestInProgress() + public async Task Exists_QuotaRequestInProgress() { // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusInProgress.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. @@ -182,36 +160,20 @@ public async Task GetIfExists_QuotaRequestInProgress() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this QuotaRequestDetailResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(scopeId); + QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(new ResourceIdentifier(scope)); // invoke the operation string id = "2B5C8515-37D8-4B6A-879B-CD641A2CF605"; - NullableResponse response = await collection.GetIfExistsAsync(id); - QuotaRequestDetailResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(id); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaRequestDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QuotaRequestStatus() + public async Task Exists_QuotaRequestStatus() { // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusById.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. @@ -221,30 +183,22 @@ public async Task Get_QuotaRequestStatus() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this QuotaRequestDetailResource string scope = "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(scopeId); + QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(new ResourceIdentifier(scope)); // invoke the operation string id = "2B5C8515-37D8-4B6A-879B-CD641A2CF605"; - QuotaRequestDetailResource result = await collection.GetAsync(id); + bool result = await collection.ExistsAsync(id); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaRequestDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotaRequestStatus() + public async Task GetIfExists_QuotaRequestFailed() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusById.json + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusFailed.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -252,26 +206,34 @@ public async Task Exists_QuotaRequestStatus() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this QuotaRequestDetailResource - string scope = "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; + QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(new ResourceIdentifier(scope)); // invoke the operation string id = "2B5C8515-37D8-4B6A-879B-CD641A2CF605"; - bool result = await collection.ExistsAsync(id); + NullableResponse response = await collection.GetIfExistsAsync(id); + QuotaRequestDetailResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaRequestDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotaRequestStatus() + public async Task GetIfExists_QuotaRequestInProgress() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusById.json + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusInProgress.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -279,13 +241,9 @@ public async Task GetIfExists_QuotaRequestStatus() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this QuotaRequestDetailResource - string scope = "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/eastus"; + QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(new ResourceIdentifier(scope)); // invoke the operation string id = "2B5C8515-37D8-4B6A-879B-CD641A2CF605"; @@ -308,35 +266,37 @@ public async Task GetIfExists_QuotaRequestStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QuotaRequestHistory() + public async Task GetIfExists_QuotaRequestStatus() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestsHistory.json - // this example is just showing the usage of "QuotaRequestStatus_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/getQuotaRequestStatusById.json + // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this QuotaRequestDetailResource string scope = "subscriptions/D7EC67B3-7657-4966-BFFC-41EFD36BAAB3/providers/Microsoft.Compute/locations/eastus"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(scopeId); + QuotaRequestDetailCollection collection = client.GetQuotaRequestDetails(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (QuotaRequestDetailResource item in collection.GetAllAsync()) + // invoke the operation + string id = "2B5C8515-37D8-4B6A-879B-CD641A2CF605"; + NullableResponse response = await collection.GetIfExistsAsync(id); + QuotaRequestDetailResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - QuotaRequestDetailData resourceData = item.Data; + QuotaRequestDetailData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_SubscriptionQuotaAllocationCollection.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_SubscriptionQuotaAllocationCollection.cs index 40f0f3869f37d..ad1012f141211 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_SubscriptionQuotaAllocationCollection.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_SubscriptionQuotaAllocationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SubscriptionQuotaAllocationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SubscriptionQuotaAllocationListForCompute() + public async Task Get_SubscriptionQuotaAllocationGetRequestForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocation/SubscriptionQuotaAllocation_List-Compute.json - // this example is just showing the usage of "GroupQuotaSubscriptionAllocation_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocation/SubscriptionQuotaAllocation_Get-Compute.json + // this example is just showing the usage of "GroupQuotaSubscriptionAllocation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,26 +39,24 @@ public async Task GetAll_SubscriptionQuotaAllocationListForCompute() string groupQuotaName = "groupquota1"; SubscriptionQuotaAllocationCollection collection = managementGroupResource.GetSubscriptionQuotaAllocations(subscriptionId, groupQuotaName); - // invoke the operation and iterate over the result + // invoke the operation + string resourceName = "standardav2family"; string filter = "provider eq Microsoft.Compute & location eq westus"; - await foreach (SubscriptionQuotaAllocationResource item in collection.GetAllAsync(filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionQuotaAllocationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SubscriptionQuotaAllocationResource result = await collection.GetAsync(resourceName, filter); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionQuotaAllocationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubscriptionQuotaAllocationGetRequestForCompute() + public async Task GetAll_SubscriptionQuotaAllocationListForCompute() { - // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocation/SubscriptionQuotaAllocation_Get-Compute.json - // this example is just showing the usage of "GroupQuotaSubscriptionAllocation_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/quota/resource-manager/Microsoft.Quota/preview/2023-06-01-preview/examples/SubscriptionQuotaAllocation/SubscriptionQuotaAllocation_List-Compute.json + // this example is just showing the usage of "GroupQuotaSubscriptionAllocation_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,16 +74,18 @@ public async Task Get_SubscriptionQuotaAllocationGetRequestForCompute() string groupQuotaName = "groupquota1"; SubscriptionQuotaAllocationCollection collection = managementGroupResource.GetSubscriptionQuotaAllocations(subscriptionId, groupQuotaName); - // invoke the operation - string resourceName = "standardav2family"; + // invoke the operation and iterate over the result string filter = "provider eq Microsoft.Compute & location eq westus"; - SubscriptionQuotaAllocationResource result = await collection.GetAsync(resourceName, filter); + await foreach (SubscriptionQuotaAllocationResource item in collection.GetAllAsync(filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionQuotaAllocationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionQuotaAllocationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index 32122e6753839..cd1af5edc1d3b 100644 --- a/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/quota/Azure.ResourceManager.Quota/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Quota.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Quota.Samples @@ -28,9 +29,7 @@ public async Task GetQuotaOperations_GetOperations() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (QuotaOperationResult item in tenantResource.GetQuotaOperationsAsync()) diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupEngineCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupEngineCollection.cs index 1fce2b802ea52..c453f4bd5f2cb 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupEngineCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupEngineCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BackupEngineCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDpmAzureBackupServerLajollaBackupEngines() + public async Task Get_GetDpmAzureBackupServerLajollaBackupEngineDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Dpm/BackupEngines_List.json - // this example is just showing the usage of "BackupEngines_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Dpm/BackupEngines_Get.json + // this example is just showing the usage of "BackupEngines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListDpmAzureBackupServerLajollaBackupEngines() string vaultName = "testVault"; BackupEngineCollection collection = resourceGroupResource.GetBackupEngines(vaultName); - // invoke the operation and iterate over the result - await foreach (BackupEngineResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupEngineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string backupEngineName = "testServer"; + BackupEngineResource result = await collection.GetAsync(backupEngineName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupEngineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDpmAzureBackupServerLajollaBackupEngineDetails() + public async Task GetAll_ListDpmAzureBackupServerLajollaBackupEngines() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Dpm/BackupEngines_Get.json - // this example is just showing the usage of "BackupEngines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Dpm/BackupEngines_List.json + // this example is just showing the usage of "BackupEngines_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,15 +73,17 @@ public async Task Get_GetDpmAzureBackupServerLajollaBackupEngineDetails() string vaultName = "testVault"; BackupEngineCollection collection = resourceGroupResource.GetBackupEngines(vaultName); - // invoke the operation - string backupEngineName = "testServer"; - BackupEngineResource result = await collection.GetAsync(backupEngineName); + // invoke the operation and iterate over the result + await foreach (BackupEngineResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupEngineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupEngineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupJobCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupJobCollection.cs index 5b6a342cdc888..e0feb1a33700a 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupJobCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupJobCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BackupJobCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllJobs() + public async Task Get_GetJobDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/ListJobs.json - // this example is just showing the usage of "BackupJobs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/GetJobDetails.json + // this example is just showing the usage of "JobDetails_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,24 +39,22 @@ public async Task GetAll_ListAllJobs() string vaultName = "NetSDKTestRsVault"; BackupJobCollection collection = resourceGroupResource.GetBackupJobs(vaultName); - // invoke the operation and iterate over the result - await foreach (BackupJobResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string jobName = "00000000-0000-0000-0000-000000000000"; + BackupJobResource result = await collection.GetAsync(jobName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListJobsWithFilters() + public async Task GetAll_ListAllJobs() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/ListJobsWithAllSupportedFilters.json + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/ListJobs.json // this example is just showing the usage of "BackupJobs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -76,8 +74,7 @@ public async Task GetAll_ListJobsWithFilters() BackupJobCollection collection = resourceGroupResource.GetBackupJobs(vaultName); // invoke the operation and iterate over the result - string filter = "startTime eq '2016-01-01 00:00:00 AM' and endTime eq '2017-11-29 00:00:00 AM' and operation eq 'Backup' and backupManagementType eq 'AzureIaasVM' and status eq 'InProgress'"; - await foreach (BackupJobResource item in collection.GetAllAsync(filter: filter)) + await foreach (BackupJobResource item in collection.GetAllAsync()) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -91,9 +88,9 @@ public async Task GetAll_ListJobsWithFilters() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListJobsWithTimeFilter() + public async Task GetAll_ListJobsWithFilters() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/ListJobsWithStartTimeAndEndTimeFilters.json + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/ListJobsWithAllSupportedFilters.json // this example is just showing the usage of "BackupJobs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -113,7 +110,7 @@ public async Task GetAll_ListJobsWithTimeFilter() BackupJobCollection collection = resourceGroupResource.GetBackupJobs(vaultName); // invoke the operation and iterate over the result - string filter = "startTime eq '2016-01-01 00:00:00 AM' and endTime eq '2017-11-29 00:00:00 AM'"; + string filter = "startTime eq '2016-01-01 00:00:00 AM' and endTime eq '2017-11-29 00:00:00 AM' and operation eq 'Backup' and backupManagementType eq 'AzureIaasVM' and status eq 'InProgress'"; await foreach (BackupJobResource item in collection.GetAllAsync(filter: filter)) { // the variable item is a resource, you could call other operations on this instance as well @@ -128,10 +125,10 @@ public async Task GetAll_ListJobsWithTimeFilter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetJobDetails() + public async Task GetAll_ListJobsWithTimeFilter() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/GetJobDetails.json - // this example is just showing the usage of "JobDetails_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/ListJobsWithStartTimeAndEndTimeFilters.json + // this example is just showing the usage of "BackupJobs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,15 +146,18 @@ public async Task Get_GetJobDetails() string vaultName = "NetSDKTestRsVault"; BackupJobCollection collection = resourceGroupResource.GetBackupJobs(vaultName); - // invoke the operation - string jobName = "00000000-0000-0000-0000-000000000000"; - BackupJobResource result = await collection.GetAsync(jobName); + // invoke the operation and iterate over the result + string filter = "startTime eq '2016-01-01 00:00:00 AM' and endTime eq '2017-11-29 00:00:00 AM'"; + await foreach (BackupJobResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupPrivateEndpointConnectionCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupPrivateEndpointConnectionCollection.cs index 4631a84cca58c..007f376cc0994 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupPrivateEndpointConnectionCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupPrivateEndpointConnectionCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_BackupPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndpointConnection() + public async Task CreateOrUpdate_UpdatePrivateEndpointConnection() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/PrivateEndpointConnection/GetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/PrivateEndpointConnection/PutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,22 @@ public async Task Get_GetPrivateEndpointConnection() // invoke the operation string vaultName = "gaallavaultbvtd2msi"; string privateEndpointConnectionName = "gaallatestpe2.5704c932-249a-490b-a142-1396838cd3b"; - BackupPrivateEndpointConnectionResource result = await collection.GetAsync(vaultName, privateEndpointConnectionName); + BackupPrivateEndpointConnectionData data = new BackupPrivateEndpointConnectionData(default) + { + Properties = new BackupPrivateEndpointConnectionProperties + { + ProvisioningState = BackupPrivateEndpointConnectionProvisioningState.Succeeded, + PrivateEndpointId = new ResourceIdentifier("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/gaallaRG/providers/Microsoft.Network/privateEndpoints/gaallatestpe3"), + GroupIds = { VaultSubResourceType.AzureBackupSecondary }, + PrivateLinkServiceConnectionState = new RecoveryServicesBackupPrivateLinkServiceConnectionState + { + Status = PrivateEndpointConnectionStatus.Approved, + Description = "Approved by johndoe@company.com", + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, privateEndpointConnectionName, data); + BackupPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +68,7 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateEndpointConnection() + public async Task Get_GetPrivateEndpointConnection() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/PrivateEndpointConnection/GetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnection_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,14 +91,18 @@ public async Task Exists_GetPrivateEndpointConnection() // invoke the operation string vaultName = "gaallavaultbvtd2msi"; string privateEndpointConnectionName = "gaallatestpe2.5704c932-249a-490b-a142-1396838cd3b"; - bool result = await collection.ExistsAsync(vaultName, privateEndpointConnectionName); + BackupPrivateEndpointConnectionResource result = await collection.GetAsync(vaultName, privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateEndpointConnection() + public async Task Exists_GetPrivateEndpointConnection() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/PrivateEndpointConnection/GetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnection_Get" operation, for the dependent resources, they will have to be created separately. @@ -106,29 +125,17 @@ public async Task GetIfExists_GetPrivateEndpointConnection() // invoke the operation string vaultName = "gaallavaultbvtd2msi"; string privateEndpointConnectionName = "gaallatestpe2.5704c932-249a-490b-a142-1396838cd3b"; - NullableResponse response = await collection.GetIfExistsAsync(vaultName, privateEndpointConnectionName); - BackupPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vaultName, privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatePrivateEndpointConnection() + public async Task GetIfExists_GetPrivateEndpointConnection() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/PrivateEndpointConnection/PutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/PrivateEndpointConnection/GetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,31 +155,21 @@ public async Task CreateOrUpdate_UpdatePrivateEndpointConnection() // invoke the operation string vaultName = "gaallavaultbvtd2msi"; string privateEndpointConnectionName = "gaallatestpe2.5704c932-249a-490b-a142-1396838cd3b"; - BackupPrivateEndpointConnectionData data = new BackupPrivateEndpointConnectionData(new AzureLocation("placeholder")) - { - Properties = new BackupPrivateEndpointConnectionProperties() - { - ProvisioningState = BackupPrivateEndpointConnectionProvisioningState.Succeeded, - PrivateEndpointId = new ResourceIdentifier("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/gaallaRG/providers/Microsoft.Network/privateEndpoints/gaallatestpe3"), - GroupIds = -{ -VaultSubResourceType.AzureBackupSecondary -}, - PrivateLinkServiceConnectionState = new RecoveryServicesBackupPrivateLinkServiceConnectionState() - { - Status = PrivateEndpointConnectionStatus.Approved, - Description = "Approved by johndoe@company.com", - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, privateEndpointConnectionName, data); - BackupPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(vaultName, privateEndpointConnectionName); + BackupPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupPrivateEndpointConnectionResource.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupPrivateEndpointConnectionResource.cs index 22a07ee21ceca..654c19055fc4c 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupPrivateEndpointConnectionResource.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatePrivateEndpointConnection() + public async Task Delete_DeletePrivateEndpointConnection() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/PrivateEndpointConnection/PutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/PrivateEndpointConnection/DeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,39 +69,17 @@ public async Task Update_UpdatePrivateEndpointConnection() BackupPrivateEndpointConnectionResource backupPrivateEndpointConnection = client.GetBackupPrivateEndpointConnectionResource(backupPrivateEndpointConnectionResourceId); // invoke the operation - BackupPrivateEndpointConnectionData data = new BackupPrivateEndpointConnectionData(new AzureLocation("placeholder")) - { - Properties = new BackupPrivateEndpointConnectionProperties() - { - ProvisioningState = BackupPrivateEndpointConnectionProvisioningState.Succeeded, - PrivateEndpointId = new ResourceIdentifier("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/gaallaRG/providers/Microsoft.Network/privateEndpoints/gaallatestpe3"), - GroupIds = -{ -VaultSubResourceType.AzureBackupSecondary -}, - PrivateLinkServiceConnectionState = new RecoveryServicesBackupPrivateLinkServiceConnectionState() - { - Status = PrivateEndpointConnectionStatus.Approved, - Description = "Approved by johndoe@company.com", - }, - }, - }; - ArmOperation lro = await backupPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - BackupPrivateEndpointConnectionResource result = lro.Value; + await backupPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateEndpointConnection() + public async Task Update_UpdatePrivateEndpointConnection() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/PrivateEndpointConnection/DeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/PrivateEndpointConnection/PutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,9 +96,28 @@ public async Task Delete_DeletePrivateEndpointConnection() BackupPrivateEndpointConnectionResource backupPrivateEndpointConnection = client.GetBackupPrivateEndpointConnectionResource(backupPrivateEndpointConnectionResourceId); // invoke the operation - await backupPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + BackupPrivateEndpointConnectionData data = new BackupPrivateEndpointConnectionData(default) + { + Properties = new BackupPrivateEndpointConnectionProperties + { + ProvisioningState = BackupPrivateEndpointConnectionProvisioningState.Succeeded, + PrivateEndpointId = new ResourceIdentifier("/subscriptions/04cf684a-d41f-4550-9f70-7708a3a2283b/resourceGroups/gaallaRG/providers/Microsoft.Network/privateEndpoints/gaallatestpe3"), + GroupIds = { VaultSubResourceType.AzureBackupSecondary }, + PrivateLinkServiceConnectionState = new RecoveryServicesBackupPrivateLinkServiceConnectionState + { + Status = PrivateEndpointConnectionStatus.Approved, + Description = "Approved by johndoe@company.com", + }, + }, + }; + ArmOperation lro = await backupPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + BackupPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectedItemCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectedItemCollection.cs index 0809f25bafd2c..437bd8ca4043a 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectedItemCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectedItemCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BackupProtectedItemCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetProtectedClassicVirtualMachineDetails() + public async Task CreateOrUpdate_EnableProtectionOnAzureIaasVm() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ClassicCompute_ProtectedItem_Get.json - // this example is just showing the usage of "ProtectedItems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ConfigureProtection.json + // this example is just showing the usage of "ProtectedItems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,10 +31,10 @@ public async Task Get_GetProtectedClassicVirtualMachineDetails() // this example assumes you already have this BackupProtectionContainerResource created on azure // for more information of creating BackupProtectionContainerResource, please refer to the document of BackupProtectionContainerResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "PythonSDKBackupTestRg"; - string vaultName = "PySDKBackupTestRsVault"; + string resourceGroupName = "SwaggerTestRg"; + string vaultName = "NetSDKTestRsVault"; string fabricName = "Azure"; - string containerName = "iaasvmcontainer;iaasvmcontainer;iaasvm-rg;iaasvm-1"; + string containerName = "IaasVMContainer;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; ResourceIdentifier backupProtectionContainerResourceId = BackupProtectionContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName); BackupProtectionContainerResource backupProtectionContainer = client.GetBackupProtectionContainerResource(backupProtectionContainerResourceId); @@ -42,8 +42,17 @@ public async Task Get_GetProtectedClassicVirtualMachineDetails() BackupProtectedItemCollection collection = backupProtectionContainer.GetBackupProtectedItems(); // invoke the operation - string protectedItemName = "vm;iaasvmcontainer;iaasvm-rg;iaasvm-1"; - BackupProtectedItemResource result = await collection.GetAsync(protectedItemName); + string protectedItemName = "VM;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; + BackupProtectedItemData data = new BackupProtectedItemData(default) + { + Properties = new IaasComputeVmProtectedItem + { + SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/netsdktestrg/providers/Microsoft.Compute/virtualMachines/netvmtestv2vm1"), + PolicyId = new ResourceIdentifier("/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/DefaultPolicy"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, protectedItemName, data); + BackupProtectedItemResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +63,10 @@ public async Task Get_GetProtectedClassicVirtualMachineDetails() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetProtectedClassicVirtualMachineDetails() + public async Task CreateOrUpdate_StopProtectionWithRetainDataOnAzureIaasVm() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ClassicCompute_ProtectedItem_Get.json - // this example is just showing the usage of "ProtectedItems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/StopProtection.json + // this example is just showing the usage of "ProtectedItems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,10 +76,10 @@ public async Task Exists_GetProtectedClassicVirtualMachineDetails() // this example assumes you already have this BackupProtectionContainerResource created on azure // for more information of creating BackupProtectionContainerResource, please refer to the document of BackupProtectionContainerResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "PythonSDKBackupTestRg"; - string vaultName = "PySDKBackupTestRsVault"; + string resourceGroupName = "SwaggerTestRg"; + string vaultName = "NetSDKTestRsVault"; string fabricName = "Azure"; - string containerName = "iaasvmcontainer;iaasvmcontainer;iaasvm-rg;iaasvm-1"; + string containerName = "IaasVMContainer;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; ResourceIdentifier backupProtectionContainerResourceId = BackupProtectionContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName); BackupProtectionContainerResource backupProtectionContainer = client.GetBackupProtectionContainerResource(backupProtectionContainerResourceId); @@ -78,15 +87,28 @@ public async Task Exists_GetProtectedClassicVirtualMachineDetails() BackupProtectedItemCollection collection = backupProtectionContainer.GetBackupProtectedItems(); // invoke the operation - string protectedItemName = "vm;iaasvmcontainer;iaasvm-rg;iaasvm-1"; - bool result = await collection.ExistsAsync(protectedItemName); + string protectedItemName = "VM;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; + BackupProtectedItemData data = new BackupProtectedItemData(default) + { + Properties = new IaasComputeVmProtectedItem + { + ProtectionState = BackupProtectionState.ProtectionStopped, + SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/netsdktestrg/providers/Microsoft.Compute/virtualMachines/netvmtestv2vm1"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, protectedItemName, data); + BackupProtectedItemResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectedItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetProtectedClassicVirtualMachineDetails() + public async Task Get_GetProtectedClassicVirtualMachineDetails() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ClassicCompute_ProtectedItem_Get.json // this example is just showing the usage of "ProtectedItems_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,21 +133,13 @@ public async Task GetIfExists_GetProtectedClassicVirtualMachineDetails() // invoke the operation string protectedItemName = "vm;iaasvmcontainer;iaasvm-rg;iaasvm-1"; - NullableResponse response = await collection.GetIfExistsAsync(protectedItemName); - BackupProtectedItemResource result = response.HasValue ? response.Value : null; + BackupProtectedItemResource result = await collection.GetAsync(protectedItemName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectedItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectedItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -166,9 +180,9 @@ public async Task Get_GetProtectedVirtualMachineDetails() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetProtectedVirtualMachineDetails() + public async Task Exists_GetProtectedClassicVirtualMachineDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/Compute_ProtectedItem_Get.json + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ClassicCompute_ProtectedItem_Get.json // this example is just showing the usage of "ProtectedItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -182,7 +196,7 @@ public async Task Exists_GetProtectedVirtualMachineDetails() string resourceGroupName = "PythonSDKBackupTestRg"; string vaultName = "PySDKBackupTestRsVault"; string fabricName = "Azure"; - string containerName = "iaasvmcontainer;iaasvmcontainerv2;iaasvm-rg;iaasvm-1"; + string containerName = "iaasvmcontainer;iaasvmcontainer;iaasvm-rg;iaasvm-1"; ResourceIdentifier backupProtectionContainerResourceId = BackupProtectionContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName); BackupProtectionContainerResource backupProtectionContainer = client.GetBackupProtectionContainerResource(backupProtectionContainerResourceId); @@ -190,7 +204,7 @@ public async Task Exists_GetProtectedVirtualMachineDetails() BackupProtectedItemCollection collection = backupProtectionContainer.GetBackupProtectedItems(); // invoke the operation - string protectedItemName = "vm;iaasvmcontainerv2;iaasvm-rg;iaasvm-1"; + string protectedItemName = "vm;iaasvmcontainer;iaasvm-rg;iaasvm-1"; bool result = await collection.ExistsAsync(protectedItemName); Console.WriteLine($"Succeeded: {result}"); @@ -198,7 +212,7 @@ public async Task Exists_GetProtectedVirtualMachineDetails() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetProtectedVirtualMachineDetails() + public async Task Exists_GetProtectedVirtualMachineDetails() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/Compute_ProtectedItem_Get.json // this example is just showing the usage of "ProtectedItems_Get" operation, for the dependent resources, they will have to be created separately. @@ -223,29 +237,17 @@ public async Task GetIfExists_GetProtectedVirtualMachineDetails() // invoke the operation string protectedItemName = "vm;iaasvmcontainerv2;iaasvm-rg;iaasvm-1"; - NullableResponse response = await collection.GetIfExistsAsync(protectedItemName); - BackupProtectedItemResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(protectedItemName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectedItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EnableProtectionOnAzureIaasVm() + public async Task GetIfExists_GetProtectedClassicVirtualMachineDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ConfigureProtection.json - // this example is just showing the usage of "ProtectedItems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ClassicCompute_ProtectedItem_Get.json + // this example is just showing the usage of "ProtectedItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -255,10 +257,10 @@ public async Task CreateOrUpdate_EnableProtectionOnAzureIaasVm() // this example assumes you already have this BackupProtectionContainerResource created on azure // for more information of creating BackupProtectionContainerResource, please refer to the document of BackupProtectionContainerResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "SwaggerTestRg"; - string vaultName = "NetSDKTestRsVault"; + string resourceGroupName = "PythonSDKBackupTestRg"; + string vaultName = "PySDKBackupTestRsVault"; string fabricName = "Azure"; - string containerName = "IaasVMContainer;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; + string containerName = "iaasvmcontainer;iaasvmcontainer;iaasvm-rg;iaasvm-1"; ResourceIdentifier backupProtectionContainerResourceId = BackupProtectionContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName); BackupProtectionContainerResource backupProtectionContainer = client.GetBackupProtectionContainerResource(backupProtectionContainerResourceId); @@ -266,31 +268,30 @@ public async Task CreateOrUpdate_EnableProtectionOnAzureIaasVm() BackupProtectedItemCollection collection = backupProtectionContainer.GetBackupProtectedItems(); // invoke the operation - string protectedItemName = "VM;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; - BackupProtectedItemData data = new BackupProtectedItemData(new AzureLocation("placeholder")) - { - Properties = new IaasComputeVmProtectedItem() - { - SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/netsdktestrg/providers/Microsoft.Compute/virtualMachines/netvmtestv2vm1"), - PolicyId = new ResourceIdentifier("/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/DefaultPolicy"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, protectedItemName, data); - BackupProtectedItemResource result = lro.Value; + string protectedItemName = "vm;iaasvmcontainer;iaasvm-rg;iaasvm-1"; + NullableResponse response = await collection.GetIfExistsAsync(protectedItemName); + BackupProtectedItemResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectedItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectedItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StopProtectionWithRetainDataOnAzureIaasVm() + public async Task GetIfExists_GetProtectedVirtualMachineDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/StopProtection.json - // this example is just showing the usage of "ProtectedItems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/Compute_ProtectedItem_Get.json + // this example is just showing the usage of "ProtectedItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -300,10 +301,10 @@ public async Task CreateOrUpdate_StopProtectionWithRetainDataOnAzureIaasVm() // this example assumes you already have this BackupProtectionContainerResource created on azure // for more information of creating BackupProtectionContainerResource, please refer to the document of BackupProtectionContainerResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "SwaggerTestRg"; - string vaultName = "NetSDKTestRsVault"; + string resourceGroupName = "PythonSDKBackupTestRg"; + string vaultName = "PySDKBackupTestRsVault"; string fabricName = "Azure"; - string containerName = "IaasVMContainer;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; + string containerName = "iaasvmcontainer;iaasvmcontainerv2;iaasvm-rg;iaasvm-1"; ResourceIdentifier backupProtectionContainerResourceId = BackupProtectionContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName); BackupProtectionContainerResource backupProtectionContainer = client.GetBackupProtectionContainerResource(backupProtectionContainerResourceId); @@ -311,23 +312,22 @@ public async Task CreateOrUpdate_StopProtectionWithRetainDataOnAzureIaasVm() BackupProtectedItemCollection collection = backupProtectionContainer.GetBackupProtectedItems(); // invoke the operation - string protectedItemName = "VM;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; - BackupProtectedItemData data = new BackupProtectedItemData(new AzureLocation("placeholder")) - { - Properties = new IaasComputeVmProtectedItem() - { - ProtectionState = BackupProtectionState.ProtectionStopped, - SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/netsdktestrg/providers/Microsoft.Compute/virtualMachines/netvmtestv2vm1"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, protectedItemName, data); - BackupProtectedItemResource result = lro.Value; + string protectedItemName = "vm;iaasvmcontainerv2;iaasvm-rg;iaasvm-1"; + NullableResponse response = await collection.GetIfExistsAsync(protectedItemName); + BackupProtectedItemResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectedItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectedItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectedItemResource.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectedItemResource.cs index 49bc38bb00d1f..e5d07076cad70 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectedItemResource.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectedItemResource.cs @@ -82,6 +82,35 @@ public async Task Get_GetProtectedVirtualMachineDetails() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteProtectionFromAzureVirtualMachine() + { + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/ProtectedItem_Delete.json + // this example is just showing the usage of "ProtectedItems_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BackupProtectedItemResource created on azure + // for more information of creating BackupProtectedItemResource, please refer to the document of BackupProtectedItemResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "PythonSDKBackupTestRg"; + string vaultName = "PySDKBackupTestRsVault"; + string fabricName = "Azure"; + string containerName = "iaasvmcontainer;iaasvmcontainerv2;pysdktestrg;pysdktestv2vm1"; + string protectedItemName = "vm;iaasvmcontainerv2;pysdktestrg;pysdktestv2vm1"; + ResourceIdentifier backupProtectedItemResourceId = BackupProtectedItemResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName, protectedItemName); + BackupProtectedItemResource backupProtectedItem = client.GetBackupProtectedItemResource(backupProtectedItemResourceId); + + // invoke the operation + await backupProtectedItem.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_EnableProtectionOnAzureIaasVm() @@ -106,9 +135,9 @@ public async Task Update_EnableProtectionOnAzureIaasVm() BackupProtectedItemResource backupProtectedItem = client.GetBackupProtectedItemResource(backupProtectedItemResourceId); // invoke the operation - BackupProtectedItemData data = new BackupProtectedItemData(new AzureLocation("placeholder")) + BackupProtectedItemData data = new BackupProtectedItemData(default) { - Properties = new IaasComputeVmProtectedItem() + Properties = new IaasComputeVmProtectedItem { SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/netsdktestrg/providers/Microsoft.Compute/virtualMachines/netvmtestv2vm1"), PolicyId = new ResourceIdentifier("/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SwaggerTestRg/providers/Microsoft.RecoveryServices/vaults/NetSDKTestRsVault/backupPolicies/DefaultPolicy"), @@ -148,9 +177,9 @@ public async Task Update_StopProtectionWithRetainDataOnAzureIaasVm() BackupProtectedItemResource backupProtectedItem = client.GetBackupProtectedItemResource(backupProtectedItemResourceId); // invoke the operation - BackupProtectedItemData data = new BackupProtectedItemData(new AzureLocation("placeholder")) + BackupProtectedItemData data = new BackupProtectedItemData(default) { - Properties = new IaasComputeVmProtectedItem() + Properties = new IaasComputeVmProtectedItem { ProtectionState = BackupProtectionState.ProtectionStopped, SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/netsdktestrg/providers/Microsoft.Compute/virtualMachines/netvmtestv2vm1"), @@ -166,35 +195,6 @@ public async Task Update_StopProtectionWithRetainDataOnAzureIaasVm() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteProtectionFromAzureVirtualMachine() - { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/ProtectedItem_Delete.json - // this example is just showing the usage of "ProtectedItems_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BackupProtectedItemResource created on azure - // for more information of creating BackupProtectedItemResource, please refer to the document of BackupProtectedItemResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "PythonSDKBackupTestRg"; - string vaultName = "PySDKBackupTestRsVault"; - string fabricName = "Azure"; - string containerName = "iaasvmcontainer;iaasvmcontainerv2;pysdktestrg;pysdktestv2vm1"; - string protectedItemName = "vm;iaasvmcontainerv2;pysdktestrg;pysdktestv2vm1"; - ResourceIdentifier backupProtectedItemResourceId = BackupProtectedItemResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName, protectedItemName); - BackupProtectedItemResource backupProtectedItem = client.GetBackupProtectedItemResource(backupProtectedItemResourceId); - - // invoke the operation - await backupProtectedItem.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task TriggerBackup_TriggerBackup() @@ -219,7 +219,7 @@ public async Task TriggerBackup_TriggerBackup() BackupProtectedItemResource backupProtectedItem = client.GetBackupProtectedItemResource(backupProtectedItemResourceId); // invoke the operation - TriggerBackupContent content = new TriggerBackupContent(new AzureLocation("placeholder")) + TriggerBackupContent content = new TriggerBackupContent(default) { Properties = new IaasVmBackupContent(), }; @@ -252,13 +252,10 @@ public async Task GetRecoveryPointsRecommendedForMove_GetProtectedAzureVmRecover BackupProtectedItemResource backupProtectedItem = client.GetBackupProtectedItemResource(backupProtectedItemResourceId); // invoke the operation and iterate over the result - RecoveryPointsRecommendedForMoveContent content = new RecoveryPointsRecommendedForMoveContent() + RecoveryPointsRecommendedForMoveContent content = new RecoveryPointsRecommendedForMoveContent { ObjectType = "ListRecoveryPointsRecommendedForMoveRequest", - ExcludedRPList = -{ -"348916168024334","348916168024335" -}, + ExcludedRPList = { "348916168024334", "348916168024335" }, }; await foreach (BackupRecoveryPointResource item in backupProtectedItem.GetRecoveryPointsRecommendedForMoveAsync(content)) { diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionContainerCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionContainerCollection.cs index fd5cd4110abc4..2f0fad2f61683 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionContainerCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionContainerCollection.cs @@ -17,6 +17,52 @@ namespace Azure.ResourceManager.RecoveryServicesBackup.Samples { public partial class Sample_BackupProtectionContainerCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_RegisterAzureStorageProtectionContainers() + { + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureStorage/ProtectionContainers_Register.json + // this example is just showing the usage of "ProtectionContainers_Register" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "SwaggerTestRg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this BackupProtectionContainerResource + BackupProtectionContainerCollection collection = resourceGroupResource.GetBackupProtectionContainers(); + + // invoke the operation + string vaultName = "swaggertestvault"; + string fabricName = "Azure"; + string containerName = "StorageContainer;Storage;SwaggerTestRg;swaggertestsa"; + BackupProtectionContainerData data = new BackupProtectionContainerData(default) + { + Properties = new StorageContainer + { + SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/SwaggerTestRg/providers/Microsoft.Storage/storageAccounts/swaggertestsa"), + AcquireStorageAccountLock = AcquireStorageAccountLock.Acquire, + FriendlyName = "swaggertestsa", + BackupManagementType = BackupManagementType.AzureStorage, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, fabricName, containerName, data); + BackupProtectionContainerResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetProtectionContainerDetails() @@ -125,51 +171,5 @@ public async Task GetIfExists_GetProtectionContainerDetails() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RegisterAzureStorageProtectionContainers() - { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureStorage/ProtectionContainers_Register.json - // this example is just showing the usage of "ProtectionContainers_Register" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "SwaggerTestRg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this BackupProtectionContainerResource - BackupProtectionContainerCollection collection = resourceGroupResource.GetBackupProtectionContainers(); - - // invoke the operation - string vaultName = "swaggertestvault"; - string fabricName = "Azure"; - string containerName = "StorageContainer;Storage;SwaggerTestRg;swaggertestsa"; - BackupProtectionContainerData data = new BackupProtectionContainerData(new AzureLocation("placeholder")) - { - Properties = new StorageContainer() - { - SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/SwaggerTestRg/providers/Microsoft.Storage/storageAccounts/swaggertestsa"), - AcquireStorageAccountLock = AcquireStorageAccountLock.Acquire, - FriendlyName = "swaggertestsa", - BackupManagementType = BackupManagementType.AzureStorage, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, fabricName, containerName, data); - BackupProtectionContainerResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionContainerResource.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionContainerResource.cs index 22e0bbbd35b50..08a7712765a7b 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionContainerResource.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionContainerResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesBackup.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesBackup.Samples @@ -49,6 +48,34 @@ public async Task Get_GetProtectionContainerDetails() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_UnregisterProtectionContainer() + { + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/ProtectionContainers_Unregister.json + // this example is just showing the usage of "ProtectionContainers_Unregister" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BackupProtectionContainerResource created on azure + // for more information of creating BackupProtectionContainerResource, please refer to the document of BackupProtectionContainerResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "testRg"; + string vaultName = "testVault"; + string fabricName = "Azure"; + string containerName = "storagecontainer;Storage;test-rg;teststorage"; + ResourceIdentifier backupProtectionContainerResourceId = BackupProtectionContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName); + BackupProtectionContainerResource backupProtectionContainer = client.GetBackupProtectionContainerResource(backupProtectionContainerResourceId); + + // invoke the operation + await backupProtectionContainer.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_RegisterAzureStorageProtectionContainers() @@ -72,9 +99,9 @@ public async Task Update_RegisterAzureStorageProtectionContainers() BackupProtectionContainerResource backupProtectionContainer = client.GetBackupProtectionContainerResource(backupProtectionContainerResourceId); // invoke the operation - BackupProtectionContainerData data = new BackupProtectionContainerData(new AzureLocation("placeholder")) + BackupProtectionContainerData data = new BackupProtectionContainerData(default) { - Properties = new StorageContainer() + Properties = new StorageContainer { SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/SwaggerTestRg/providers/Microsoft.Storage/storageAccounts/swaggertestsa"), AcquireStorageAccountLock = AcquireStorageAccountLock.Acquire, @@ -92,34 +119,6 @@ public async Task Update_RegisterAzureStorageProtectionContainers() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_UnregisterProtectionContainer() - { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/ProtectionContainers_Unregister.json - // this example is just showing the usage of "ProtectionContainers_Unregister" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BackupProtectionContainerResource created on azure - // for more information of creating BackupProtectionContainerResource, please refer to the document of BackupProtectionContainerResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "testRg"; - string vaultName = "testVault"; - string fabricName = "Azure"; - string containerName = "storagecontainer;Storage;test-rg;teststorage"; - ResourceIdentifier backupProtectionContainerResourceId = BackupProtectionContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName); - BackupProtectionContainerResource backupProtectionContainer = client.GetBackupProtectionContainerResource(backupProtectionContainerResourceId); - - // invoke the operation - await backupProtectionContainer.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Inquire_InquireAzureStorageProtectionContainers() @@ -148,33 +147,6 @@ public async Task Inquire_InquireAzureStorageProtectionContainers() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task RefreshProtectionContainer_TriggerAzureVmDiscovery() - { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/RefreshContainers.json - // this example is just showing the usage of "ProtectionContainers_Refresh" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "SwaggerTestRg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation - string vaultName = "NetSDKTestRsVault"; - string fabricName = "Azure"; - await resourceGroupResource.RefreshProtectionContainerAsync(vaultName, fabricName); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetBackupWorkloadItems_ListWorkloadItemsInContainer() diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionIntentCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionIntentCollection.cs index 00c29bdbead99..8ead089c03a38 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionIntentCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionIntentCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_BackupProtectionIntentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetProtectionIntentForAnItem() + public async Task CreateOrUpdate_CreateOrUpdateAzureVmProtectionIntent() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/BackupProtectionIntent_Get.json - // this example is just showing the usage of "ProtectionIntent_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionIntent_CreateOrUpdate.json + // this example is just showing the usage of "ProtectionIntent_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,8 +42,17 @@ public async Task Get_GetProtectionIntentForAnItem() // invoke the operation string vaultName = "myVault"; string fabricName = "Azure"; - string intentObjectName = "249D9B07-D2EF-4202-AA64-65F35418564E"; - BackupProtectionIntentResource result = await collection.GetAsync(vaultName, fabricName, intentObjectName); + string intentObjectName = "vm;iaasvmcontainerv2;chamsrgtest;chamscandel"; + BackupProtectionIntentData data = new BackupProtectionIntentData(default) + { + Properties = new ResourceProtectionIntent + { + SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/chamsrgtest/providers/Microsoft.Compute/virtualMachines/chamscandel"), + PolicyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.RecoveryServices/vaults/myVault/backupPolicies/myPolicy"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, fabricName, intentObjectName, data); + BackupProtectionIntentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,7 +63,7 @@ public async Task Get_GetProtectionIntentForAnItem() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetProtectionIntentForAnItem() + public async Task Get_GetProtectionIntentForAnItem() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/BackupProtectionIntent_Get.json // this example is just showing the usage of "ProtectionIntent_Get" operation, for the dependent resources, they will have to be created separately. @@ -78,14 +87,18 @@ public async Task Exists_GetProtectionIntentForAnItem() string vaultName = "myVault"; string fabricName = "Azure"; string intentObjectName = "249D9B07-D2EF-4202-AA64-65F35418564E"; - bool result = await collection.ExistsAsync(vaultName, fabricName, intentObjectName); + BackupProtectionIntentResource result = await collection.GetAsync(vaultName, fabricName, intentObjectName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionIntentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetProtectionIntentForAnItem() + public async Task Exists_GetProtectionIntentForAnItem() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/BackupProtectionIntent_Get.json // this example is just showing the usage of "ProtectionIntent_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,29 +122,17 @@ public async Task GetIfExists_GetProtectionIntentForAnItem() string vaultName = "myVault"; string fabricName = "Azure"; string intentObjectName = "249D9B07-D2EF-4202-AA64-65F35418564E"; - NullableResponse response = await collection.GetIfExistsAsync(vaultName, fabricName, intentObjectName); - BackupProtectionIntentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vaultName, fabricName, intentObjectName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionIntentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAzureVmProtectionIntent() + public async Task GetIfExists_GetProtectionIntentForAnItem() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionIntent_CreateOrUpdate.json - // this example is just showing the usage of "ProtectionIntent_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/BackupProtectionIntent_Get.json + // this example is just showing the usage of "ProtectionIntent_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,23 +152,22 @@ public async Task CreateOrUpdate_CreateOrUpdateAzureVmProtectionIntent() // invoke the operation string vaultName = "myVault"; string fabricName = "Azure"; - string intentObjectName = "vm;iaasvmcontainerv2;chamsrgtest;chamscandel"; - BackupProtectionIntentData data = new BackupProtectionIntentData(new AzureLocation("placeholder")) - { - Properties = new ResourceProtectionIntent() - { - SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/chamsrgtest/providers/Microsoft.Compute/virtualMachines/chamscandel"), - PolicyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.RecoveryServices/vaults/myVault/backupPolicies/myPolicy"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, fabricName, intentObjectName, data); - BackupProtectionIntentResource result = lro.Value; + string intentObjectName = "249D9B07-D2EF-4202-AA64-65F35418564E"; + NullableResponse response = await collection.GetIfExistsAsync(vaultName, fabricName, intentObjectName); + BackupProtectionIntentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionIntentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionIntentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionIntentResource.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionIntentResource.cs index 5256dc474c564..2a7cc20477a6b 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionIntentResource.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionIntentResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesBackup.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesBackup.Samples @@ -19,42 +18,42 @@ public partial class Sample_BackupProtectionIntentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateProtectionIntent_ValidateEnableProtectionOnAzureVm() + public async Task Get_GetProtectionIntentForAnItem() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionIntent_Validate.json - // this example is just showing the usage of "ProtectionIntent_Validate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/BackupProtectionIntent_Get.json + // this example is just showing the usage of "ProtectionIntent_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this BackupProtectionIntentResource created on azure + // for more information of creating BackupProtectionIntentResource, please refer to the document of BackupProtectionIntentResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "myRG"; + string vaultName = "myVault"; + string fabricName = "Azure"; + string intentObjectName = "249D9B07-D2EF-4202-AA64-65F35418564E"; + ResourceIdentifier backupProtectionIntentResourceId = BackupProtectionIntentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, intentObjectName); + BackupProtectionIntentResource backupProtectionIntent = client.GetBackupProtectionIntentResource(backupProtectionIntentResourceId); // invoke the operation - AzureLocation location = new AzureLocation("southeastasia"); - PreValidateEnableBackupContent content = new PreValidateEnableBackupContent() - { - ResourceType = BackupDataSourceType.Vm, - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/arunaupgrade/providers/Microsoft.Compute/VirtualMachines/upgrade1"), - VaultId = new ResourceIdentifier("/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.RecoveryServices/Vaults/myVault"), - Properties = "", - }; - PreValidateEnableBackupResult result = await subscriptionResource.ValidateProtectionIntentAsync(location, content); + BackupProtectionIntentResource result = await backupProtectionIntent.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionIntentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetProtectionIntentForAnItem() + public async Task Delete_DeleteProtectionIntentFromItem() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/BackupProtectionIntent_Get.json - // this example is just showing the usage of "ProtectionIntent_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/BackupProtectionIntent_Delete.json + // this example is just showing the usage of "ProtectionIntent_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,13 +71,9 @@ public async Task Get_GetProtectionIntentForAnItem() BackupProtectionIntentResource backupProtectionIntent = client.GetBackupProtectionIntentResource(backupProtectionIntentResourceId); // invoke the operation - BackupProtectionIntentResource result = await backupProtectionIntent.GetAsync(); + await backupProtectionIntent.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionIntentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -104,9 +99,9 @@ public async Task Update_CreateOrUpdateAzureVmProtectionIntent() BackupProtectionIntentResource backupProtectionIntent = client.GetBackupProtectionIntentResource(backupProtectionIntentResourceId); // invoke the operation - BackupProtectionIntentData data = new BackupProtectionIntentData(new AzureLocation("placeholder")) + BackupProtectionIntentData data = new BackupProtectionIntentData(default) { - Properties = new ResourceProtectionIntent() + Properties = new ResourceProtectionIntent { SourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/chamsrgtest/providers/Microsoft.Compute/virtualMachines/chamscandel"), PolicyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.RecoveryServices/vaults/myVault/backupPolicies/myPolicy"), @@ -121,33 +116,5 @@ public async Task Update_CreateOrUpdateAzureVmProtectionIntent() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteProtectionIntentFromItem() - { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/BackupProtectionIntent_Delete.json - // this example is just showing the usage of "ProtectionIntent_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BackupProtectionIntentResource created on azure - // for more information of creating BackupProtectionIntentResource, please refer to the document of BackupProtectionIntentResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myRG"; - string vaultName = "myVault"; - string fabricName = "Azure"; - string intentObjectName = "249D9B07-D2EF-4202-AA64-65F35418564E"; - ResourceIdentifier backupProtectionIntentResourceId = BackupProtectionIntentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, intentObjectName); - BackupProtectionIntentResource backupProtectionIntent = client.GetBackupProtectionIntentResource(backupProtectionIntentResourceId); - - // invoke the operation - await backupProtectionIntent.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionPolicyCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionPolicyCollection.cs index d186b3ff8f66c..c13199adb5b33 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionPolicyCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionPolicyCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_BackupProtectionPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListProtectionPoliciesWithBackupManagementTypeFilterAsAzureIaasVm() + public async Task CreateOrUpdate_CreateOrUpdateAzureStorageVaultStandardProtectionPolicy() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/BackupPolicies_List.json - // this example is just showing the usage of "BackupPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hardened.json + // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,29 +37,93 @@ public async Task GetAll_ListProtectionPoliciesWithBackupManagementTypeFilterAsA ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this BackupProtectionPolicyResource - string vaultName = "NetSDKTestRsVault"; + string vaultName = "swaggertestvault"; BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); - // invoke the operation and iterate over the result - string filter = "backupManagementType eq 'AzureIaasVM'"; - await foreach (BackupProtectionPolicyResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string policyName = "newPolicyV2"; + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new FileShareProtectionPolicy + { + WorkLoadType = BackupWorkloadType.AzureFileShare, + SchedulePolicy = new SimpleSchedulePolicy + { + ScheduleRunFrequency = ScheduleRunType.Daily, + ScheduleRunTimes = { default }, + }, + VaultRetentionPolicy = new VaultRetentionPolicy(new LongTermRetentionPolicy + { + DailySchedule = new DailyRetentionSchedule + { + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 30, + DurationType = RetentionDurationType.Days, + }, + }, + WeeklySchedule = new WeeklyRetentionSchedule + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 12, + DurationType = RetentionDurationType.Weeks, + }, + }, + MonthlySchedule = new MonthlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, + }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 60, + DurationType = RetentionDurationType.Months, + }, + }, + YearlySchedule = new YearlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + MonthsOfYear = { BackupMonthOfYear.January }, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, + }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 10, + DurationType = RetentionDurationType.Years, + }, + }, + }, 5), + TimeZone = "UTC", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + BackupProtectionPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListProtectionPoliciesWithBackupManagementTypeFilterAsAzureIaasVmWithBothV1AndV2Policies() + public async Task CreateOrUpdate_CreateOrUpdateDailyAzureStorageProtectionPolicy() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/v2-List-Policies.json - // this example is just showing the usage of "BackupPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureStorage/ProtectionPolicies_CreateOrUpdate_Daily.json + // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,29 +138,93 @@ public async Task GetAll_ListProtectionPoliciesWithBackupManagementTypeFilterAsA ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this BackupProtectionPolicyResource - string vaultName = "NetSDKTestRsVault"; + string vaultName = "swaggertestvault"; BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); - // invoke the operation and iterate over the result - string filter = "backupManagementType eq 'AzureIaasVM'"; - await foreach (BackupProtectionPolicyResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string policyName = "dailyPolicy2"; + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new FileShareProtectionPolicy + { + WorkLoadType = BackupWorkloadType.AzureFileShare, + SchedulePolicy = new SimpleSchedulePolicy + { + ScheduleRunFrequency = ScheduleRunType.Daily, + ScheduleRunTimes = { default }, + }, + RetentionPolicy = new LongTermRetentionPolicy + { + DailySchedule = new DailyRetentionSchedule + { + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 5, + DurationType = RetentionDurationType.Days, + }, + }, + WeeklySchedule = new WeeklyRetentionSchedule + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 12, + DurationType = RetentionDurationType.Weeks, + }, + }, + MonthlySchedule = new MonthlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, + }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 60, + DurationType = RetentionDurationType.Months, + }, + }, + YearlySchedule = new YearlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + MonthsOfYear = { BackupMonthOfYear.January }, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, + }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 10, + DurationType = RetentionDurationType.Years, + }, + }, + }, + TimeZone = "UTC", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + BackupProtectionPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListProtectionPoliciesWithBackupManagementTypeFilterAsAzureWorkload() + public async Task CreateOrUpdate_CreateOrUpdateEnhancedAzureVmProtectionPolicyWithHourlyBackup() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/BackupPolicies_List.json - // this example is just showing the usage of "BackupPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/IaaS_v2_hourly.json + // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,26 +242,96 @@ public async Task GetAll_ListProtectionPoliciesWithBackupManagementTypeFilterAsA string vaultName = "NetSDKTestRsVault"; BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); - // invoke the operation and iterate over the result - string filter = "backupManagementType eq 'AzureWorkload'"; - await foreach (BackupProtectionPolicyResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string policyName = "v2-daily-sample"; + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new IaasVmProtectionPolicy + { + SchedulePolicy = new SimpleSchedulePolicyV2 + { + ScheduleRunFrequency = ScheduleRunType.Hourly, + HourlySchedule = new BackupHourlySchedule + { + Interval = 4, + ScheduleWindowStartOn = DateTimeOffset.Parse("2021-12-17T08:00:00Z"), + ScheduleWindowDuration = 16, + }, + }, + RetentionPolicy = new LongTermRetentionPolicy + { + DailySchedule = new DailyRetentionSchedule + { + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 180, + DurationType = RetentionDurationType.Days, + }, + }, + WeeklySchedule = new WeeklyRetentionSchedule + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 12, + DurationType = RetentionDurationType.Weeks, + }, + }, + MonthlySchedule = new MonthlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, + }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 60, + DurationType = RetentionDurationType.Months, + }, + }, + YearlySchedule = new YearlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + MonthsOfYear = { BackupMonthOfYear.January }, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, + }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 10, + DurationType = RetentionDurationType.Years, + }, + }, + }, + InstantRPRetentionRangeInDays = 30, + TimeZone = "India Standard Time", + PolicyType = IaasVmPolicyType.V2, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + BackupProtectionPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureIaasVmEnhancedProtectionPolicyDetails() + public async Task CreateOrUpdate_CreateOrUpdateEnhancedAzureVmProtectionPolicyWithDailyBackup() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/v2-Get-Policy.json - // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/IaaS_v2_daily.json + // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -153,7 +351,75 @@ public async Task Get_GetAzureIaasVmEnhancedProtectionPolicyDetails() // invoke the operation string policyName = "v2-daily-sample"; - BackupProtectionPolicyResource result = await collection.GetAsync(policyName); + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) + { + Properties = new IaasVmProtectionPolicy + { + SchedulePolicy = new SimpleSchedulePolicyV2 + { + ScheduleRunFrequency = ScheduleRunType.Daily, + ScheduleRunTimes = { default }, + }, + RetentionPolicy = new LongTermRetentionPolicy + { + DailySchedule = new DailyRetentionSchedule + { + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 180, + DurationType = RetentionDurationType.Days, + }, + }, + WeeklySchedule = new WeeklyRetentionSchedule + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 12, + DurationType = RetentionDurationType.Weeks, + }, + }, + MonthlySchedule = new MonthlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, + }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 60, + DurationType = RetentionDurationType.Months, + }, + }, + YearlySchedule = new YearlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + MonthsOfYear = { BackupMonthOfYear.January }, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, + }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 10, + DurationType = RetentionDurationType.Years, + }, + }, + }, + InstantRPRetentionRangeInDays = 30, + TimeZone = "India Standard Time", + PolicyType = IaasVmPolicyType.V2, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + BackupProtectionPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -164,10 +430,10 @@ public async Task Get_GetAzureIaasVmEnhancedProtectionPolicyDetails() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureIaasVmEnhancedProtectionPolicyDetails() + public async Task CreateOrUpdate_CreateOrUpdateFullAzureVmProtectionPolicy() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/v2-Get-Policy.json - // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Complex.json + // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,18 +452,80 @@ public async Task Exists_GetAzureIaasVmEnhancedProtectionPolicyDetails() BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); // invoke the operation - string policyName = "v2-daily-sample"; - bool result = await collection.ExistsAsync(policyName); + string policyName = "testPolicy1"; + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) + { + Properties = new IaasVmProtectionPolicy + { + SchedulePolicy = new SimpleSchedulePolicy + { + ScheduleRunFrequency = ScheduleRunType.Weekly, + ScheduleRunDays = { BackupDayOfWeek.Monday, BackupDayOfWeek.Wednesday, BackupDayOfWeek.Thursday }, + ScheduleRunTimes = { default }, + }, + RetentionPolicy = new LongTermRetentionPolicy + { + WeeklySchedule = new WeeklyRetentionSchedule + { + DaysOfTheWeek = { BackupDayOfWeek.Monday, BackupDayOfWeek.Wednesday, BackupDayOfWeek.Thursday }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 1, + DurationType = RetentionDurationType.Weeks, + }, + }, + MonthlySchedule = new MonthlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Wednesday, BackupDayOfWeek.Thursday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First, BackupWeekOfMonth.Third }, + }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 2, + DurationType = RetentionDurationType.Months, + }, + }, + YearlySchedule = new YearlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + MonthsOfYear = { BackupMonthOfYear.February, BackupMonthOfYear.November }, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Monday, BackupDayOfWeek.Thursday }, + WeeksOfTheMonth = { BackupWeekOfMonth.Fourth }, + }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 4, + DurationType = RetentionDurationType.Years, + }, + }, + }, + TimeZone = "Pacific Standard Time", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + BackupProtectionPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureIaasVmEnhancedProtectionPolicyDetails() + public async Task CreateOrUpdate_CreateOrUpdateFullAzureWorkloadProtectionPolicy() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/v2-Get-Policy.json - // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/ProtectionPolicies_CreateOrUpdate_Complex.json + // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -216,30 +544,121 @@ public async Task GetIfExists_GetAzureIaasVmEnhancedProtectionPolicyDetails() BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); // invoke the operation - string policyName = "v2-daily-sample"; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - BackupProtectionPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string policyName = "testPolicy1"; + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new VmWorkloadProtectionPolicy + { + WorkLoadType = BackupWorkloadType.SqlDatabase, + Settings = new BackupCommonSettings + { + TimeZone = "Pacific Standard Time", + IsSqlCompression = false, + }, + SubProtectionPolicy = {new SubProtectionPolicy +{ +PolicyType = SubProtectionPolicyType.Full, +SchedulePolicy = new SimpleSchedulePolicy +{ +ScheduleRunFrequency = ScheduleRunType.Weekly, +ScheduleRunDays = {BackupDayOfWeek.Sunday, BackupDayOfWeek.Tuesday}, +ScheduleRunTimes = {default}, +}, +RetentionPolicy = new LongTermRetentionPolicy +{ +WeeklySchedule = new WeeklyRetentionSchedule +{ +DaysOfTheWeek = {BackupDayOfWeek.Sunday, BackupDayOfWeek.Tuesday}, +RetentionTimes = {default}, +RetentionDuration = new RetentionDuration +{ +Count = 2, +DurationType = RetentionDurationType.Weeks, +}, +}, +MonthlySchedule = new MonthlyRetentionSchedule +{ +RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, +RetentionScheduleWeekly = new WeeklyRetentionFormat +{ +DaysOfTheWeek = {BackupDayOfWeek.Sunday}, +WeeksOfTheMonth = {BackupWeekOfMonth.Second}, +}, +RetentionTimes = {default}, +RetentionDuration = new RetentionDuration +{ +Count = 1, +DurationType = RetentionDurationType.Months, +}, +}, +YearlySchedule = new YearlyRetentionSchedule +{ +RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, +MonthsOfYear = {BackupMonthOfYear.January, BackupMonthOfYear.June, BackupMonthOfYear.December}, +RetentionScheduleWeekly = new WeeklyRetentionFormat +{ +DaysOfTheWeek = {BackupDayOfWeek.Sunday}, +WeeksOfTheMonth = {BackupWeekOfMonth.Last}, +}, +RetentionTimes = {default}, +RetentionDuration = new RetentionDuration +{ +Count = 1, +DurationType = RetentionDurationType.Years, +}, +}, +}, +}, new SubProtectionPolicy +{ +PolicyType = SubProtectionPolicyType.Differential, +SchedulePolicy = new SimpleSchedulePolicy +{ +ScheduleRunFrequency = ScheduleRunType.Weekly, +ScheduleRunDays = {BackupDayOfWeek.Friday}, +ScheduleRunTimes = {default}, +}, +RetentionPolicy = new SimpleRetentionPolicy +{ +RetentionDuration = new RetentionDuration +{ +Count = 8, +DurationType = RetentionDurationType.Days, +}, +}, +}, new SubProtectionPolicy +{ +PolicyType = SubProtectionPolicyType.Log, +SchedulePolicy = new LogSchedulePolicy +{ +ScheduleFrequencyInMins = 60, +}, +RetentionPolicy = new SimpleRetentionPolicy +{ +RetentionDuration = new RetentionDuration +{ +Count = 7, +DurationType = RetentionDurationType.Days, +}, +}, +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + BackupProtectionPolicyResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureIaasVmProtectionPolicyDetails() + public async Task CreateOrUpdate_CreateOrUpdateHourlyAzureStorageProtectionPolicy() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_Get.json - // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hourly.json + // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -254,12 +673,84 @@ public async Task Get_GetAzureIaasVmProtectionPolicyDetails() ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this BackupProtectionPolicyResource - string vaultName = "NetSDKTestRsVault"; + string vaultName = "swaggertestvault"; BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); // invoke the operation - string policyName = "testPolicy1"; - BackupProtectionPolicyResource result = await collection.GetAsync(policyName); + string policyName = "newPolicy2"; + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) + { + Properties = new FileShareProtectionPolicy + { + WorkLoadType = BackupWorkloadType.AzureFileShare, + SchedulePolicy = new SimpleSchedulePolicy + { + ScheduleRunFrequency = ScheduleRunType.Hourly, + HourlySchedule = new BackupHourlySchedule + { + Interval = 4, + ScheduleWindowStartOn = DateTimeOffset.Parse("2021-09-29T08:00:00.000Z"), + ScheduleWindowDuration = 12, + }, + }, + RetentionPolicy = new LongTermRetentionPolicy + { + DailySchedule = new DailyRetentionSchedule + { + RetentionTimes = { }, + RetentionDuration = new RetentionDuration + { + Count = 5, + DurationType = RetentionDurationType.Days, + }, + }, + WeeklySchedule = new WeeklyRetentionSchedule + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + RetentionTimes = { }, + RetentionDuration = new RetentionDuration + { + Count = 12, + DurationType = RetentionDurationType.Weeks, + }, + }, + MonthlySchedule = new MonthlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, + }, + RetentionTimes = { }, + RetentionDuration = new RetentionDuration + { + Count = 60, + DurationType = RetentionDurationType.Months, + }, + }, + YearlySchedule = new YearlyRetentionSchedule + { + RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, + MonthsOfYear = { BackupMonthOfYear.January }, + RetentionScheduleWeekly = new WeeklyRetentionFormat + { + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, + }, + RetentionTimes = { }, + RetentionDuration = new RetentionDuration + { + Count = 10, + DurationType = RetentionDurationType.Years, + }, + }, + }, + TimeZone = "UTC", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + BackupProtectionPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -270,10 +761,10 @@ public async Task Get_GetAzureIaasVmProtectionPolicyDetails() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureIaasVmProtectionPolicyDetails() + public async Task CreateOrUpdate_CreateOrUpdateSimpleAzureVmProtectionPolicy() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_Get.json - // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Simple.json + // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -293,16 +784,45 @@ public async Task Exists_GetAzureIaasVmProtectionPolicyDetails() // invoke the operation string policyName = "testPolicy1"; - bool result = await collection.ExistsAsync(policyName); + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) + { + Properties = new IaasVmProtectionPolicy + { + SchedulePolicy = new SimpleSchedulePolicy + { + ScheduleRunFrequency = ScheduleRunType.Daily, + ScheduleRunTimes = { default }, + }, + RetentionPolicy = new LongTermRetentionPolicy + { + DailySchedule = new DailyRetentionSchedule + { + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration + { + Count = 1, + DurationType = RetentionDurationType.Days, + }, + }, + }, + TimeZone = "Pacific Standard Time", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + BackupProtectionPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureIaasVmProtectionPolicyDetails() + public async Task Get_GetAzureIaasVmEnhancedProtectionPolicyDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_Get.json + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/v2-Get-Policy.json // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -322,30 +842,22 @@ public async Task GetIfExists_GetAzureIaasVmProtectionPolicyDetails() BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); // invoke the operation - string policyName = "testPolicy1"; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - BackupProtectionPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } + string policyName = "v2-daily-sample"; + BackupProtectionPolicyResource result = await collection.GetAsync(policyName); - [Test] + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAzureStorageVaultStandardProtectionPolicy() + public async Task Get_GetAzureIaasVmProtectionPolicyDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hardened.json - // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_Get.json + // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -360,112 +872,12 @@ public async Task CreateOrUpdate_CreateOrUpdateAzureStorageVaultStandardProtecti ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this BackupProtectionPolicyResource - string vaultName = "swaggertestvault"; + string vaultName = "NetSDKTestRsVault"; BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); // invoke the operation - string policyName = "newPolicyV2"; - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) - { - Properties = new FileShareProtectionPolicy() - { - WorkLoadType = BackupWorkloadType.AzureFileShare, - SchedulePolicy = new SimpleSchedulePolicy() - { - ScheduleRunFrequency = ScheduleRunType.Daily, - ScheduleRunTimes = -{ -DateTimeOffset.Parse("2023-07-18T09:30:00.000Z") -}, - }, - VaultRetentionPolicy = new VaultRetentionPolicy(new LongTermRetentionPolicy() - { - DailySchedule = new DailyRetentionSchedule() - { - RetentionTimes = -{ -DateTimeOffset.Parse("2023-07-18T09:30:00.000Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 30, - DurationType = RetentionDurationType.Days, - }, - }, - WeeklySchedule = new WeeklyRetentionSchedule() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - RetentionTimes = -{ -DateTimeOffset.Parse("2023-07-18T09:30:00.000Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 12, - DurationType = RetentionDurationType.Weeks, - }, - }, - MonthlySchedule = new MonthlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, - }, - RetentionTimes = -{ -DateTimeOffset.Parse("2023-07-18T09:30:00.000Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 60, - DurationType = RetentionDurationType.Months, - }, - }, - YearlySchedule = new YearlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.January -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, - }, - RetentionTimes = -{ -DateTimeOffset.Parse("2023-07-18T09:30:00.000Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 10, - DurationType = RetentionDurationType.Years, - }, - }, - }, 5), - TimeZone = "UTC", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - BackupProtectionPolicyResource result = lro.Value; + string policyName = "testPolicy1"; + BackupProtectionPolicyResource result = await collection.GetAsync(policyName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -476,10 +888,10 @@ public async Task CreateOrUpdate_CreateOrUpdateAzureStorageVaultStandardProtecti [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDailyAzureStorageProtectionPolicy() + public async Task GetAll_ListProtectionPoliciesWithBackupManagementTypeFilterAsAzureIaasVm() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureStorage/ProtectionPolicies_CreateOrUpdate_Daily.json - // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/BackupPolicies_List.json + // this example is just showing the usage of "BackupPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -494,126 +906,29 @@ public async Task CreateOrUpdate_CreateOrUpdateDailyAzureStorageProtectionPolicy ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this BackupProtectionPolicyResource - string vaultName = "swaggertestvault"; + string vaultName = "NetSDKTestRsVault"; BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); - // invoke the operation - string policyName = "dailyPolicy2"; - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + // invoke the operation and iterate over the result + string filter = "backupManagementType eq 'AzureIaasVM'"; + await foreach (BackupProtectionPolicyResource item in collection.GetAllAsync(filter: filter)) { - Properties = new FileShareProtectionPolicy() - { - WorkLoadType = BackupWorkloadType.AzureFileShare, - SchedulePolicy = new SimpleSchedulePolicy() - { - ScheduleRunFrequency = ScheduleRunType.Daily, - ScheduleRunTimes = -{ -DateTimeOffset.Parse("2021-09-29T08:00:00.000Z") -}, - }, - RetentionPolicy = new LongTermRetentionPolicy() - { - DailySchedule = new DailyRetentionSchedule() - { - RetentionTimes = -{ -DateTimeOffset.Parse("2021-09-29T08:00:00.000Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 5, - DurationType = RetentionDurationType.Days, - }, - }, - WeeklySchedule = new WeeklyRetentionSchedule() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-09-29T08:00:00.000Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 12, - DurationType = RetentionDurationType.Weeks, - }, - }, - MonthlySchedule = new MonthlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, - }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-09-29T08:00:00.000Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 60, - DurationType = RetentionDurationType.Months, - }, - }, - YearlySchedule = new YearlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.January -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, - }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-09-29T08:00:00.000Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 10, - DurationType = RetentionDurationType.Years, - }, - }, - }, - TimeZone = "UTC", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - BackupProtectionPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateEnhancedAzureVmProtectionPolicyWithHourlyBackup() + public async Task GetAll_ListProtectionPoliciesWithBackupManagementTypeFilterAsAzureIaasVmWithBothV1AndV2Policies() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/IaaS_v2_hourly.json - // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/v2-List-Policies.json + // this example is just showing the usage of "BackupPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -631,126 +946,26 @@ public async Task CreateOrUpdate_CreateOrUpdateEnhancedAzureVmProtectionPolicyWi string vaultName = "NetSDKTestRsVault"; BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); - // invoke the operation - string policyName = "v2-daily-sample"; - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + // invoke the operation and iterate over the result + string filter = "backupManagementType eq 'AzureIaasVM'"; + await foreach (BackupProtectionPolicyResource item in collection.GetAllAsync(filter: filter)) { - Properties = new IaasVmProtectionPolicy() - { - SchedulePolicy = new SimpleSchedulePolicyV2() - { - ScheduleRunFrequency = ScheduleRunType.Hourly, - HourlySchedule = new BackupHourlySchedule() - { - Interval = 4, - ScheduleWindowStartOn = DateTimeOffset.Parse("2021-12-17T08:00:00Z"), - ScheduleWindowDuration = 16, - }, - }, - RetentionPolicy = new LongTermRetentionPolicy() - { - DailySchedule = new DailyRetentionSchedule() - { - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() - { - Count = 180, - DurationType = RetentionDurationType.Days, - }, - }, - WeeklySchedule = new WeeklyRetentionSchedule() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() - { - Count = 12, - DurationType = RetentionDurationType.Weeks, - }, - }, - MonthlySchedule = new MonthlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, - }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() - { - Count = 60, - DurationType = RetentionDurationType.Months, - }, - }, - YearlySchedule = new YearlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.January -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, - }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() - { - Count = 10, - DurationType = RetentionDurationType.Years, - }, - }, - }, - InstantRPRetentionRangeInDays = 30, - TimeZone = "India Standard Time", - PolicyType = IaasVmPolicyType.V2, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - BackupProtectionPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateEnhancedAzureVmProtectionPolicyWithDailyBackup() + public async Task GetAll_ListProtectionPoliciesWithBackupManagementTypeFilterAsAzureWorkload() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/IaaS_v2_daily.json - // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/BackupPolicies_List.json + // this example is just showing the usage of "BackupPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -768,124 +983,26 @@ public async Task CreateOrUpdate_CreateOrUpdateEnhancedAzureVmProtectionPolicyWi string vaultName = "NetSDKTestRsVault"; BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); - // invoke the operation - string policyName = "v2-daily-sample"; - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + // invoke the operation and iterate over the result + string filter = "backupManagementType eq 'AzureWorkload'"; + await foreach (BackupProtectionPolicyResource item in collection.GetAllAsync(filter: filter)) { - Properties = new IaasVmProtectionPolicy() - { - SchedulePolicy = new SimpleSchedulePolicyV2() - { - ScheduleRunFrequency = ScheduleRunType.Daily, - ScheduleRunTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, - }, - RetentionPolicy = new LongTermRetentionPolicy() - { - DailySchedule = new DailyRetentionSchedule() - { - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() - { - Count = 180, - DurationType = RetentionDurationType.Days, - }, - }, - WeeklySchedule = new WeeklyRetentionSchedule() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() - { - Count = 12, - DurationType = RetentionDurationType.Weeks, - }, - }, - MonthlySchedule = new MonthlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, - }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() - { - Count = 60, - DurationType = RetentionDurationType.Months, - }, - }, - YearlySchedule = new YearlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.January -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, - }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() - { - Count = 10, - DurationType = RetentionDurationType.Years, - }, - }, - }, - InstantRPRetentionRangeInDays = 30, - TimeZone = "India Standard Time", - PolicyType = IaasVmPolicyType.V2, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - BackupProtectionPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateFullAzureVmProtectionPolicy() + public async Task Exists_GetAzureIaasVmEnhancedProtectionPolicyDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Complex.json - // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/v2-Get-Policy.json + // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -904,113 +1021,18 @@ public async Task CreateOrUpdate_CreateOrUpdateFullAzureVmProtectionPolicy() BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); // invoke the operation - string policyName = "testPolicy1"; - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) - { - Properties = new IaasVmProtectionPolicy() - { - SchedulePolicy = new SimpleSchedulePolicy() - { - ScheduleRunFrequency = ScheduleRunType.Weekly, - ScheduleRunDays = -{ -BackupDayOfWeek.Monday,BackupDayOfWeek.Wednesday,BackupDayOfWeek.Thursday -}, - ScheduleRunTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, - }, - RetentionPolicy = new LongTermRetentionPolicy() - { - WeeklySchedule = new WeeklyRetentionSchedule() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Monday,BackupDayOfWeek.Wednesday,BackupDayOfWeek.Thursday -}, - RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 1, - DurationType = RetentionDurationType.Weeks, - }, - }, - MonthlySchedule = new MonthlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Wednesday,BackupDayOfWeek.Thursday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First,BackupWeekOfMonth.Third -}, - }, - RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 2, - DurationType = RetentionDurationType.Months, - }, - }, - YearlySchedule = new YearlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.February,BackupMonthOfYear.November -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Monday,BackupDayOfWeek.Thursday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.Fourth -}, - }, - RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 4, - DurationType = RetentionDurationType.Years, - }, - }, - }, - TimeZone = "Pacific Standard Time", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - BackupProtectionPolicyResource result = lro.Value; + string policyName = "v2-daily-sample"; + bool result = await collection.ExistsAsync(policyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateFullAzureWorkloadProtectionPolicy() + public async Task Exists_GetAzureIaasVmProtectionPolicyDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureWorkload/ProtectionPolicies_CreateOrUpdate_Complex.json - // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_Get.json + // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1030,162 +1052,17 @@ public async Task CreateOrUpdate_CreateOrUpdateFullAzureWorkloadProtectionPolicy // invoke the operation string policyName = "testPolicy1"; - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) - { - Properties = new VmWorkloadProtectionPolicy() - { - WorkLoadType = BackupWorkloadType.SqlDatabase, - Settings = new BackupCommonSettings() - { - TimeZone = "Pacific Standard Time", - IsSqlCompression = false, - }, - SubProtectionPolicy = -{ -new SubProtectionPolicy() -{ -PolicyType = SubProtectionPolicyType.Full, -SchedulePolicy = new SimpleSchedulePolicy() -{ -ScheduleRunFrequency = ScheduleRunType.Weekly, -ScheduleRunDays = -{ -BackupDayOfWeek.Sunday,BackupDayOfWeek.Tuesday -}, -ScheduleRunTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, -}, -RetentionPolicy = new LongTermRetentionPolicy() -{ -WeeklySchedule = new WeeklyRetentionSchedule() -{ -DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday,BackupDayOfWeek.Tuesday -}, -RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, -RetentionDuration = new RetentionDuration() -{ -Count = 2, -DurationType = RetentionDurationType.Weeks, -}, -}, -MonthlySchedule = new MonthlyRetentionSchedule() -{ -RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, -RetentionScheduleWeekly = new WeeklyRetentionFormat() -{ -DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, -WeeksOfTheMonth = -{ -BackupWeekOfMonth.Second -}, -}, -RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, -RetentionDuration = new RetentionDuration() -{ -Count = 1, -DurationType = RetentionDurationType.Months, -}, -}, -YearlySchedule = new YearlyRetentionSchedule() -{ -RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, -MonthsOfYear = -{ -BackupMonthOfYear.January,BackupMonthOfYear.June,BackupMonthOfYear.December -}, -RetentionScheduleWeekly = new WeeklyRetentionFormat() -{ -DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, -WeeksOfTheMonth = -{ -BackupWeekOfMonth.Last -}, -}, -RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, -RetentionDuration = new RetentionDuration() -{ -Count = 1, -DurationType = RetentionDurationType.Years, -}, -}, -}, -},new SubProtectionPolicy() -{ -PolicyType = SubProtectionPolicyType.Differential, -SchedulePolicy = new SimpleSchedulePolicy() -{ -ScheduleRunFrequency = ScheduleRunType.Weekly, -ScheduleRunDays = -{ -BackupDayOfWeek.Friday -}, -ScheduleRunTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, -}, -RetentionPolicy = new SimpleRetentionPolicy() -{ -RetentionDuration = new RetentionDuration() -{ -Count = 8, -DurationType = RetentionDurationType.Days, -}, -}, -},new SubProtectionPolicy() -{ -PolicyType = SubProtectionPolicyType.Log, -SchedulePolicy = new LogSchedulePolicy() -{ -ScheduleFrequencyInMins = 60, -}, -RetentionPolicy = new SimpleRetentionPolicy() -{ -RetentionDuration = new RetentionDuration() -{ -Count = 7, -DurationType = RetentionDurationType.Days, -}, -}, -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - BackupProtectionPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(policyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateHourlyAzureStorageProtectionPolicy() + public async Task GetIfExists_GetAzureIaasVmEnhancedProtectionPolicyDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureStorage/ProtectionPolicies_CreateOrUpdate_Hourly.json - // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/V2Policy/v2-Get-Policy.json + // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1200,124 +1077,34 @@ public async Task CreateOrUpdate_CreateOrUpdateHourlyAzureStorageProtectionPolic ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this BackupProtectionPolicyResource - string vaultName = "swaggertestvault"; + string vaultName = "NetSDKTestRsVault"; BackupProtectionPolicyCollection collection = resourceGroupResource.GetBackupProtectionPolicies(vaultName); // invoke the operation - string policyName = "newPolicy2"; - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) - { - Properties = new FileShareProtectionPolicy() - { - WorkLoadType = BackupWorkloadType.AzureFileShare, - SchedulePolicy = new SimpleSchedulePolicy() - { - ScheduleRunFrequency = ScheduleRunType.Hourly, - HourlySchedule = new BackupHourlySchedule() - { - Interval = 4, - ScheduleWindowStartOn = DateTimeOffset.Parse("2021-09-29T08:00:00.000Z"), - ScheduleWindowDuration = 12, - }, - }, - RetentionPolicy = new LongTermRetentionPolicy() - { - DailySchedule = new DailyRetentionSchedule() - { - RetentionTimes = -{ -}, - RetentionDuration = new RetentionDuration() - { - Count = 5, - DurationType = RetentionDurationType.Days, - }, - }, - WeeklySchedule = new WeeklyRetentionSchedule() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - RetentionTimes = -{ -}, - RetentionDuration = new RetentionDuration() - { - Count = 12, - DurationType = RetentionDurationType.Weeks, - }, - }, - MonthlySchedule = new MonthlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, - }, - RetentionTimes = -{ -}, - RetentionDuration = new RetentionDuration() - { - Count = 60, - DurationType = RetentionDurationType.Months, - }, - }, - YearlySchedule = new YearlyRetentionSchedule() - { - RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.January -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() - { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, - }, - RetentionTimes = -{ -}, - RetentionDuration = new RetentionDuration() - { - Count = 10, - DurationType = RetentionDurationType.Years, - }, - }, - }, - TimeZone = "UTC", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - BackupProtectionPolicyResource result = lro.Value; + string policyName = "v2-daily-sample"; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + BackupProtectionPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateSimpleAzureVmProtectionPolicy() + public async Task GetIfExists_GetAzureIaasVmProtectionPolicyDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_CreateOrUpdate_Simple.json - // this example is just showing the usage of "ProtectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_Get.json + // this example is just showing the usage of "ProtectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1337,44 +1124,21 @@ public async Task CreateOrUpdate_CreateOrUpdateSimpleAzureVmProtectionPolicy() // invoke the operation string policyName = "testPolicy1"; - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) - { - Properties = new IaasVmProtectionPolicy() - { - SchedulePolicy = new SimpleSchedulePolicy() - { - ScheduleRunFrequency = ScheduleRunType.Daily, - ScheduleRunTimes = -{ -DateTimeOffset.Parse("2018-01-24T02:00:00Z") -}, - }, - RetentionPolicy = new LongTermRetentionPolicy() - { - DailySchedule = new DailyRetentionSchedule() - { - RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T02:00:00Z") -}, - RetentionDuration = new RetentionDuration() - { - Count = 1, - DurationType = RetentionDurationType.Days, - }, - }, - }, - TimeZone = "Pacific Standard Time", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - BackupProtectionPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + BackupProtectionPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupProtectionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupProtectionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionPolicyResource.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionPolicyResource.cs index 51e8509eebad7..b0f8f66f26112 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionPolicyResource.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupProtectionPolicyResource.cs @@ -78,6 +78,33 @@ public async Task Get_GetAzureIaasVmProtectionPolicyDetails() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAzureVmProtectionPolicy() + { + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_Delete.json + // this example is just showing the usage of "ProtectionPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BackupProtectionPolicyResource created on azure + // for more information of creating BackupProtectionPolicyResource, please refer to the document of BackupProtectionPolicyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "SwaggerTestRg"; + string vaultName = "NetSDKTestRsVault"; + string policyName = "testPolicy1"; + ResourceIdentifier backupProtectionPolicyResourceId = BackupProtectionPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, policyName); + BackupProtectionPolicyResource backupProtectionPolicy = client.GetBackupProtectionPolicyResource(backupProtectionPolicyResourceId); + + // invoke the operation + await backupProtectionPolicy.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateAzureStorageVaultStandardProtectionPolicy() @@ -100,96 +127,63 @@ public async Task Update_CreateOrUpdateAzureStorageVaultStandardProtectionPolicy BackupProtectionPolicyResource backupProtectionPolicy = client.GetBackupProtectionPolicyResource(backupProtectionPolicyResourceId); // invoke the operation - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - Properties = new FileShareProtectionPolicy() + Properties = new FileShareProtectionPolicy { WorkLoadType = BackupWorkloadType.AzureFileShare, - SchedulePolicy = new SimpleSchedulePolicy() + SchedulePolicy = new SimpleSchedulePolicy { ScheduleRunFrequency = ScheduleRunType.Daily, - ScheduleRunTimes = -{ -DateTimeOffset.Parse("2023-07-18T09:30:00.000Z") -}, + ScheduleRunTimes = { default }, }, - VaultRetentionPolicy = new VaultRetentionPolicy(new LongTermRetentionPolicy() + VaultRetentionPolicy = new VaultRetentionPolicy(new LongTermRetentionPolicy { - DailySchedule = new DailyRetentionSchedule() + DailySchedule = new DailyRetentionSchedule { - RetentionTimes = -{ -DateTimeOffset.Parse("2023-07-18T09:30:00.000Z") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 30, DurationType = RetentionDurationType.Days, }, }, - WeeklySchedule = new WeeklyRetentionSchedule() + WeeklySchedule = new WeeklyRetentionSchedule { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - RetentionTimes = -{ -DateTimeOffset.Parse("2023-07-18T09:30:00.000Z") -}, - RetentionDuration = new RetentionDuration() + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 12, DurationType = RetentionDurationType.Weeks, }, }, - MonthlySchedule = new MonthlyRetentionSchedule() + MonthlySchedule = new MonthlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, }, - RetentionTimes = -{ -DateTimeOffset.Parse("2023-07-18T09:30:00.000Z") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 60, DurationType = RetentionDurationType.Months, }, }, - YearlySchedule = new YearlyRetentionSchedule() + YearlySchedule = new YearlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.January -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + MonthsOfYear = { BackupMonthOfYear.January }, + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, }, - RetentionTimes = -{ -DateTimeOffset.Parse("2023-07-18T09:30:00.000Z") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 10, DurationType = RetentionDurationType.Years, @@ -231,96 +225,63 @@ public async Task Update_CreateOrUpdateDailyAzureStorageProtectionPolicy() BackupProtectionPolicyResource backupProtectionPolicy = client.GetBackupProtectionPolicyResource(backupProtectionPolicyResourceId); // invoke the operation - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - Properties = new FileShareProtectionPolicy() + Properties = new FileShareProtectionPolicy { WorkLoadType = BackupWorkloadType.AzureFileShare, - SchedulePolicy = new SimpleSchedulePolicy() + SchedulePolicy = new SimpleSchedulePolicy { ScheduleRunFrequency = ScheduleRunType.Daily, - ScheduleRunTimes = -{ -DateTimeOffset.Parse("2021-09-29T08:00:00.000Z") -}, + ScheduleRunTimes = { default }, }, - RetentionPolicy = new LongTermRetentionPolicy() + RetentionPolicy = new LongTermRetentionPolicy { - DailySchedule = new DailyRetentionSchedule() + DailySchedule = new DailyRetentionSchedule { - RetentionTimes = -{ -DateTimeOffset.Parse("2021-09-29T08:00:00.000Z") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 5, DurationType = RetentionDurationType.Days, }, }, - WeeklySchedule = new WeeklyRetentionSchedule() + WeeklySchedule = new WeeklyRetentionSchedule { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-09-29T08:00:00.000Z") -}, - RetentionDuration = new RetentionDuration() + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 12, DurationType = RetentionDurationType.Weeks, }, }, - MonthlySchedule = new MonthlyRetentionSchedule() + MonthlySchedule = new MonthlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-09-29T08:00:00.000Z") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 60, DurationType = RetentionDurationType.Months, }, }, - YearlySchedule = new YearlyRetentionSchedule() + YearlySchedule = new YearlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.January -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + MonthsOfYear = { BackupMonthOfYear.January }, + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-09-29T08:00:00.000Z") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 10, DurationType = RetentionDurationType.Years, @@ -362,97 +323,67 @@ public async Task Update_CreateOrUpdateEnhancedAzureVmProtectionPolicyWithHourly BackupProtectionPolicyResource backupProtectionPolicy = client.GetBackupProtectionPolicyResource(backupProtectionPolicyResourceId); // invoke the operation - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - Properties = new IaasVmProtectionPolicy() + Properties = new IaasVmProtectionPolicy { - SchedulePolicy = new SimpleSchedulePolicyV2() + SchedulePolicy = new SimpleSchedulePolicyV2 { ScheduleRunFrequency = ScheduleRunType.Hourly, - HourlySchedule = new BackupHourlySchedule() + HourlySchedule = new BackupHourlySchedule { Interval = 4, ScheduleWindowStartOn = DateTimeOffset.Parse("2021-12-17T08:00:00Z"), ScheduleWindowDuration = 16, }, }, - RetentionPolicy = new LongTermRetentionPolicy() + RetentionPolicy = new LongTermRetentionPolicy { - DailySchedule = new DailyRetentionSchedule() + DailySchedule = new DailyRetentionSchedule { - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 180, DurationType = RetentionDurationType.Days, }, }, - WeeklySchedule = new WeeklyRetentionSchedule() + WeeklySchedule = new WeeklyRetentionSchedule { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 12, DurationType = RetentionDurationType.Weeks, }, }, - MonthlySchedule = new MonthlyRetentionSchedule() + MonthlySchedule = new MonthlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 60, DurationType = RetentionDurationType.Months, }, }, - YearlySchedule = new YearlyRetentionSchedule() + YearlySchedule = new YearlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.January -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + MonthsOfYear = { BackupMonthOfYear.January }, + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 10, DurationType = RetentionDurationType.Years, @@ -496,95 +427,62 @@ public async Task Update_CreateOrUpdateEnhancedAzureVmProtectionPolicyWithDailyB BackupProtectionPolicyResource backupProtectionPolicy = client.GetBackupProtectionPolicyResource(backupProtectionPolicyResourceId); // invoke the operation - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - Properties = new IaasVmProtectionPolicy() + Properties = new IaasVmProtectionPolicy { - SchedulePolicy = new SimpleSchedulePolicyV2() + SchedulePolicy = new SimpleSchedulePolicyV2 { ScheduleRunFrequency = ScheduleRunType.Daily, - ScheduleRunTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, + ScheduleRunTimes = { default }, }, - RetentionPolicy = new LongTermRetentionPolicy() + RetentionPolicy = new LongTermRetentionPolicy { - DailySchedule = new DailyRetentionSchedule() + DailySchedule = new DailyRetentionSchedule { - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 180, DurationType = RetentionDurationType.Days, }, }, - WeeklySchedule = new WeeklyRetentionSchedule() + WeeklySchedule = new WeeklyRetentionSchedule { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 12, DurationType = RetentionDurationType.Weeks, }, }, - MonthlySchedule = new MonthlyRetentionSchedule() + MonthlySchedule = new MonthlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 60, DurationType = RetentionDurationType.Months, }, }, - YearlySchedule = new YearlyRetentionSchedule() + YearlySchedule = new YearlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.January -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + MonthsOfYear = { BackupMonthOfYear.January }, + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, }, - RetentionTimes = -{ -DateTimeOffset.Parse("2021-12-17T08:00:00+00:00") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 10, DurationType = RetentionDurationType.Years, @@ -628,87 +526,54 @@ public async Task Update_CreateOrUpdateFullAzureVmProtectionPolicy() BackupProtectionPolicyResource backupProtectionPolicy = client.GetBackupProtectionPolicyResource(backupProtectionPolicyResourceId); // invoke the operation - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - Properties = new IaasVmProtectionPolicy() + Properties = new IaasVmProtectionPolicy { - SchedulePolicy = new SimpleSchedulePolicy() + SchedulePolicy = new SimpleSchedulePolicy { ScheduleRunFrequency = ScheduleRunType.Weekly, - ScheduleRunDays = -{ -BackupDayOfWeek.Monday,BackupDayOfWeek.Wednesday,BackupDayOfWeek.Thursday -}, - ScheduleRunTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, + ScheduleRunDays = { BackupDayOfWeek.Monday, BackupDayOfWeek.Wednesday, BackupDayOfWeek.Thursday }, + ScheduleRunTimes = { default }, }, - RetentionPolicy = new LongTermRetentionPolicy() + RetentionPolicy = new LongTermRetentionPolicy { - WeeklySchedule = new WeeklyRetentionSchedule() + WeeklySchedule = new WeeklyRetentionSchedule { - DaysOfTheWeek = -{ -BackupDayOfWeek.Monday,BackupDayOfWeek.Wednesday,BackupDayOfWeek.Thursday -}, - RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, - RetentionDuration = new RetentionDuration() + DaysOfTheWeek = { BackupDayOfWeek.Monday, BackupDayOfWeek.Wednesday, BackupDayOfWeek.Thursday }, + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 1, DurationType = RetentionDurationType.Weeks, }, }, - MonthlySchedule = new MonthlyRetentionSchedule() + MonthlySchedule = new MonthlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Wednesday,BackupDayOfWeek.Thursday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First,BackupWeekOfMonth.Third -}, + DaysOfTheWeek = { BackupDayOfWeek.Wednesday, BackupDayOfWeek.Thursday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First, BackupWeekOfMonth.Third }, }, - RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 2, DurationType = RetentionDurationType.Months, }, }, - YearlySchedule = new YearlyRetentionSchedule() + YearlySchedule = new YearlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.February,BackupMonthOfYear.November -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + MonthsOfYear = { BackupMonthOfYear.February, BackupMonthOfYear.November }, + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Monday,BackupDayOfWeek.Thursday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.Fourth -}, + DaysOfTheWeek = { BackupDayOfWeek.Monday, BackupDayOfWeek.Thursday }, + WeeksOfTheMonth = { BackupWeekOfMonth.Fourth }, }, - RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 4, DurationType = RetentionDurationType.Years, @@ -750,144 +615,102 @@ public async Task Update_CreateOrUpdateFullAzureWorkloadProtectionPolicy() BackupProtectionPolicyResource backupProtectionPolicy = client.GetBackupProtectionPolicyResource(backupProtectionPolicyResourceId); // invoke the operation - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - Properties = new VmWorkloadProtectionPolicy() + Properties = new VmWorkloadProtectionPolicy { WorkLoadType = BackupWorkloadType.SqlDatabase, - Settings = new BackupCommonSettings() + Settings = new BackupCommonSettings { TimeZone = "Pacific Standard Time", IsSqlCompression = false, }, - SubProtectionPolicy = -{ -new SubProtectionPolicy() + SubProtectionPolicy = {new SubProtectionPolicy { PolicyType = SubProtectionPolicyType.Full, -SchedulePolicy = new SimpleSchedulePolicy() +SchedulePolicy = new SimpleSchedulePolicy { ScheduleRunFrequency = ScheduleRunType.Weekly, -ScheduleRunDays = -{ -BackupDayOfWeek.Sunday,BackupDayOfWeek.Tuesday -}, -ScheduleRunTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") +ScheduleRunDays = {BackupDayOfWeek.Sunday, BackupDayOfWeek.Tuesday}, +ScheduleRunTimes = {default}, }, -}, -RetentionPolicy = new LongTermRetentionPolicy() -{ -WeeklySchedule = new WeeklyRetentionSchedule() -{ -DaysOfTheWeek = +RetentionPolicy = new LongTermRetentionPolicy { -BackupDayOfWeek.Sunday,BackupDayOfWeek.Tuesday -}, -RetentionTimes = +WeeklySchedule = new WeeklyRetentionSchedule { -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, -RetentionDuration = new RetentionDuration() +DaysOfTheWeek = {BackupDayOfWeek.Sunday, BackupDayOfWeek.Tuesday}, +RetentionTimes = {default}, +RetentionDuration = new RetentionDuration { Count = 2, DurationType = RetentionDurationType.Weeks, }, }, -MonthlySchedule = new MonthlyRetentionSchedule() +MonthlySchedule = new MonthlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, -RetentionScheduleWeekly = new WeeklyRetentionFormat() +RetentionScheduleWeekly = new WeeklyRetentionFormat { -DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday +DaysOfTheWeek = {BackupDayOfWeek.Sunday}, +WeeksOfTheMonth = {BackupWeekOfMonth.Second}, }, -WeeksOfTheMonth = -{ -BackupWeekOfMonth.Second -}, -}, -RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, -RetentionDuration = new RetentionDuration() +RetentionTimes = {default}, +RetentionDuration = new RetentionDuration { Count = 1, DurationType = RetentionDurationType.Months, }, }, -YearlySchedule = new YearlyRetentionSchedule() +YearlySchedule = new YearlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, -MonthsOfYear = -{ -BackupMonthOfYear.January,BackupMonthOfYear.June,BackupMonthOfYear.December -}, -RetentionScheduleWeekly = new WeeklyRetentionFormat() -{ -DaysOfTheWeek = +MonthsOfYear = {BackupMonthOfYear.January, BackupMonthOfYear.June, BackupMonthOfYear.December}, +RetentionScheduleWeekly = new WeeklyRetentionFormat { -BackupDayOfWeek.Sunday -}, -WeeksOfTheMonth = -{ -BackupWeekOfMonth.Last -}, +DaysOfTheWeek = {BackupDayOfWeek.Sunday}, +WeeksOfTheMonth = {BackupWeekOfMonth.Last}, }, -RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, -RetentionDuration = new RetentionDuration() +RetentionTimes = {default}, +RetentionDuration = new RetentionDuration { Count = 1, DurationType = RetentionDurationType.Years, }, }, }, -},new SubProtectionPolicy() +}, new SubProtectionPolicy { PolicyType = SubProtectionPolicyType.Differential, -SchedulePolicy = new SimpleSchedulePolicy() +SchedulePolicy = new SimpleSchedulePolicy { ScheduleRunFrequency = ScheduleRunType.Weekly, -ScheduleRunDays = -{ -BackupDayOfWeek.Friday -}, -ScheduleRunTimes = -{ -DateTimeOffset.Parse("2018-01-24T10:00:00Z") -}, +ScheduleRunDays = {BackupDayOfWeek.Friday}, +ScheduleRunTimes = {default}, }, -RetentionPolicy = new SimpleRetentionPolicy() +RetentionPolicy = new SimpleRetentionPolicy { -RetentionDuration = new RetentionDuration() +RetentionDuration = new RetentionDuration { Count = 8, DurationType = RetentionDurationType.Days, }, }, -},new SubProtectionPolicy() +}, new SubProtectionPolicy { PolicyType = SubProtectionPolicyType.Log, -SchedulePolicy = new LogSchedulePolicy() +SchedulePolicy = new LogSchedulePolicy { ScheduleFrequencyInMins = 60, }, -RetentionPolicy = new SimpleRetentionPolicy() +RetentionPolicy = new SimpleRetentionPolicy { -RetentionDuration = new RetentionDuration() +RetentionDuration = new RetentionDuration { Count = 7, DurationType = RetentionDurationType.Days, }, }, -} -}, +}}, }, }; ArmOperation lro = await backupProtectionPolicy.UpdateAsync(WaitUntil.Completed, data); @@ -922,94 +745,68 @@ public async Task Update_CreateOrUpdateHourlyAzureStorageProtectionPolicy() BackupProtectionPolicyResource backupProtectionPolicy = client.GetBackupProtectionPolicyResource(backupProtectionPolicyResourceId); // invoke the operation - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - Properties = new FileShareProtectionPolicy() + Properties = new FileShareProtectionPolicy { WorkLoadType = BackupWorkloadType.AzureFileShare, - SchedulePolicy = new SimpleSchedulePolicy() + SchedulePolicy = new SimpleSchedulePolicy { ScheduleRunFrequency = ScheduleRunType.Hourly, - HourlySchedule = new BackupHourlySchedule() + HourlySchedule = new BackupHourlySchedule { Interval = 4, ScheduleWindowStartOn = DateTimeOffset.Parse("2021-09-29T08:00:00.000Z"), ScheduleWindowDuration = 12, }, }, - RetentionPolicy = new LongTermRetentionPolicy() + RetentionPolicy = new LongTermRetentionPolicy { - DailySchedule = new DailyRetentionSchedule() + DailySchedule = new DailyRetentionSchedule { - RetentionTimes = -{ -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { }, + RetentionDuration = new RetentionDuration { Count = 5, DurationType = RetentionDurationType.Days, }, }, - WeeklySchedule = new WeeklyRetentionSchedule() + WeeklySchedule = new WeeklyRetentionSchedule { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - RetentionTimes = -{ -}, - RetentionDuration = new RetentionDuration() + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + RetentionTimes = { }, + RetentionDuration = new RetentionDuration { Count = 12, DurationType = RetentionDurationType.Weeks, }, }, - MonthlySchedule = new MonthlyRetentionSchedule() + MonthlySchedule = new MonthlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, }, - RetentionTimes = -{ -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { }, + RetentionDuration = new RetentionDuration { Count = 60, DurationType = RetentionDurationType.Months, }, }, - YearlySchedule = new YearlyRetentionSchedule() + YearlySchedule = new YearlyRetentionSchedule { RetentionScheduleFormatType = RetentionScheduleFormat.Weekly, - MonthsOfYear = -{ -BackupMonthOfYear.January -}, - RetentionScheduleWeekly = new WeeklyRetentionFormat() + MonthsOfYear = { BackupMonthOfYear.January }, + RetentionScheduleWeekly = new WeeklyRetentionFormat { - DaysOfTheWeek = -{ -BackupDayOfWeek.Sunday -}, - WeeksOfTheMonth = -{ -BackupWeekOfMonth.First -}, + DaysOfTheWeek = { BackupDayOfWeek.Sunday }, + WeeksOfTheMonth = { BackupWeekOfMonth.First }, }, - RetentionTimes = -{ -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { }, + RetentionDuration = new RetentionDuration { Count = 10, DurationType = RetentionDurationType.Years, @@ -1051,27 +848,21 @@ public async Task Update_CreateOrUpdateSimpleAzureVmProtectionPolicy() BackupProtectionPolicyResource backupProtectionPolicy = client.GetBackupProtectionPolicyResource(backupProtectionPolicyResourceId); // invoke the operation - BackupProtectionPolicyData data = new BackupProtectionPolicyData(new AzureLocation("placeholder")) + BackupProtectionPolicyData data = new BackupProtectionPolicyData(default) { - Properties = new IaasVmProtectionPolicy() + Properties = new IaasVmProtectionPolicy { - SchedulePolicy = new SimpleSchedulePolicy() + SchedulePolicy = new SimpleSchedulePolicy { ScheduleRunFrequency = ScheduleRunType.Daily, - ScheduleRunTimes = -{ -DateTimeOffset.Parse("2018-01-24T02:00:00Z") -}, + ScheduleRunTimes = { default }, }, - RetentionPolicy = new LongTermRetentionPolicy() + RetentionPolicy = new LongTermRetentionPolicy { - DailySchedule = new DailyRetentionSchedule() + DailySchedule = new DailyRetentionSchedule { - RetentionTimes = -{ -DateTimeOffset.Parse("2018-01-24T02:00:00Z") -}, - RetentionDuration = new RetentionDuration() + RetentionTimes = { default }, + RetentionDuration = new RetentionDuration { Count = 1, DurationType = RetentionDurationType.Days, @@ -1090,32 +881,5 @@ public async Task Update_CreateOrUpdateSimpleAzureVmProtectionPolicy() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAzureVmProtectionPolicy() - { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionPolicies_Delete.json - // this example is just showing the usage of "ProtectionPolicies_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BackupProtectionPolicyResource created on azure - // for more information of creating BackupProtectionPolicyResource, please refer to the document of BackupProtectionPolicyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "SwaggerTestRg"; - string vaultName = "NetSDKTestRsVault"; - string policyName = "testPolicy1"; - ResourceIdentifier backupProtectionPolicyResourceId = BackupProtectionPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, policyName); - BackupProtectionPolicyResource backupProtectionPolicy = client.GetBackupProtectionPolicyResource(backupProtectionPolicyResourceId); - - // invoke the operation - await backupProtectionPolicy.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupRecoveryPointCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupRecoveryPointCollection.cs index 0677000be9c75..ea7dafd4da2bd 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupRecoveryPointCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupRecoveryPointCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_BackupRecoveryPointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetProtectedAzureVmRecoveryPoints() + public async Task Get_GetAzureVmRecoveryPointDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/RecoveryPoints_List.json - // this example is just showing the usage of "RecoveryPoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/RecoveryPoints_Get.json + // this example is just showing the usage of "RecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_GetProtectedAzureVmRecoveryPoints() // get the collection of this BackupRecoveryPointResource BackupRecoveryPointCollection collection = backupProtectedItem.GetBackupRecoveryPoints(); - // invoke the operation and iterate over the result - await foreach (BackupRecoveryPointResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupRecoveryPointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string recoveryPointId = "26083826328862"; + BackupRecoveryPointResource result = await collection.GetAsync(recoveryPointId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupRecoveryPointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureVmRecoveryPointDetails() + public async Task GetAll_GetProtectedAzureVmRecoveryPoints() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/RecoveryPoints_Get.json - // this example is just showing the usage of "RecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/RecoveryPoints_List.json + // this example is just showing the usage of "RecoveryPoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +78,17 @@ public async Task Get_GetAzureVmRecoveryPointDetails() // get the collection of this BackupRecoveryPointResource BackupRecoveryPointCollection collection = backupProtectedItem.GetBackupRecoveryPoints(); - // invoke the operation - string recoveryPointId = "26083826328862"; - BackupRecoveryPointResource result = await collection.GetAsync(recoveryPointId); + // invoke the operation and iterate over the result + await foreach (BackupRecoveryPointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupRecoveryPointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupRecoveryPointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupRecoveryPointResource.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupRecoveryPointResource.cs index da0e87782ecdc..bb07df5f7ebb9 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupRecoveryPointResource.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupRecoveryPointResource.cs @@ -19,10 +19,10 @@ public partial class Sample_BackupRecoveryPointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task MoveRecoveryPoint_TriggerRPMoveOperation() + public async Task Get_GetAzureVmRecoveryPointDetails() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/TriggerRecoveryPointMove_Post.json - // this example is just showing the usage of "MoveRecoveryPoint" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/RecoveryPoints_Get.json + // this example is just showing the usage of "RecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,33 +32,31 @@ public async Task MoveRecoveryPoint_TriggerRPMoveOperation() // this example assumes you already have this BackupRecoveryPointResource created on azure // for more information of creating BackupRecoveryPointResource, please refer to the document of BackupRecoveryPointResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "netsdktestrg"; - string vaultName = "testVault"; + string resourceGroupName = "rshhtestmdvmrg"; + string vaultName = "rshvault"; string fabricName = "Azure"; - string containerName = "IaasVMContainer;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; - string protectedItemName = "VM;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; - string recoveryPointId = "348916168024334"; + string containerName = "IaasVMContainer;iaasvmcontainerv2;rshhtestmdvmrg;rshmdvmsmall"; + string protectedItemName = "VM;iaasvmcontainerv2;rshhtestmdvmrg;rshmdvmsmall"; + string recoveryPointId = "26083826328862"; ResourceIdentifier backupRecoveryPointResourceId = BackupRecoveryPointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName, protectedItemName, recoveryPointId); BackupRecoveryPointResource backupRecoveryPoint = client.GetBackupRecoveryPointResource(backupRecoveryPointResourceId); // invoke the operation - MoveRPAcrossTiersContent content = new MoveRPAcrossTiersContent() - { - ObjectType = "MoveRPAcrossTiersRequest", - SourceTierType = RecoveryPointTierType.HardenedRP, - TargetTierType = RecoveryPointTierType.ArchivedRP, - }; - await backupRecoveryPoint.MoveRecoveryPointAsync(WaitUntil.Completed, content); + BackupRecoveryPointResource result = await backupRecoveryPoint.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupRecoveryPointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureVmRecoveryPointDetails() + public async Task MoveRecoveryPoint_TriggerRPMoveOperation() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/RecoveryPoints_Get.json - // this example is just showing the usage of "RecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/TriggerRecoveryPointMove_Post.json + // this example is just showing the usage of "MoveRecoveryPoint" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,23 +66,25 @@ public async Task Get_GetAzureVmRecoveryPointDetails() // this example assumes you already have this BackupRecoveryPointResource created on azure // for more information of creating BackupRecoveryPointResource, please refer to the document of BackupRecoveryPointResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rshhtestmdvmrg"; - string vaultName = "rshvault"; + string resourceGroupName = "netsdktestrg"; + string vaultName = "testVault"; string fabricName = "Azure"; - string containerName = "IaasVMContainer;iaasvmcontainerv2;rshhtestmdvmrg;rshmdvmsmall"; - string protectedItemName = "VM;iaasvmcontainerv2;rshhtestmdvmrg;rshmdvmsmall"; - string recoveryPointId = "26083826328862"; + string containerName = "IaasVMContainer;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; + string protectedItemName = "VM;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1"; + string recoveryPointId = "348916168024334"; ResourceIdentifier backupRecoveryPointResourceId = BackupRecoveryPointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, fabricName, containerName, protectedItemName, recoveryPointId); BackupRecoveryPointResource backupRecoveryPoint = client.GetBackupRecoveryPointResource(backupRecoveryPointResourceId); // invoke the operation - BackupRecoveryPointResource result = await backupRecoveryPoint.GetAsync(); + MoveRPAcrossTiersContent content = new MoveRPAcrossTiersContent + { + ObjectType = "MoveRPAcrossTiersRequest", + SourceTierType = RecoveryPointTierType.HardenedRP, + TargetTierType = RecoveryPointTierType.ArchivedRP, + }; + await backupRecoveryPoint.MoveRecoveryPointAsync(WaitUntil.Completed, content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupRecoveryPointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -112,9 +112,9 @@ public async Task TriggerRestore_RestoreDisksWithIaasVMRestoreRequest() BackupRecoveryPointResource backupRecoveryPoint = client.GetBackupRecoveryPointResource(backupRecoveryPointResourceId); // invoke the operation - TriggerRestoreContent content = new TriggerRestoreContent(new AzureLocation("placeholder")) + TriggerRestoreContent content = new TriggerRestoreContent(default) { - Properties = new IaasVmRestoreContent() + Properties = new IaasVmRestoreContent { RecoveryPointId = "348916168024334", RecoveryType = FileShareRecoveryType.RestoreDisks, @@ -123,16 +123,16 @@ public async Task TriggerRestore_RestoreDisksWithIaasVMRestoreRequest() Region = new AzureLocation("southeastasia"), DoesCreateNewCloudService = true, OriginalStorageAccountOption = false, - EncryptionDetails = new VmEncryptionDetails() + EncryptionDetails = new VmEncryptionDetails { IsEncryptionEnabled = false, }, - IdentityInfo = new BackupIdentityInfo() + IdentityInfo = new BackupIdentityInfo { IsSystemAssignedIdentity = false, ManagedIdentityResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asmaskarRG1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asmaskartestmsi"), }, - TargetDiskNetworkAccessSettings = new BackupTargetDiskNetworkAccessSettings() + TargetDiskNetworkAccessSettings = new BackupTargetDiskNetworkAccessSettings { TargetDiskNetworkAccessOption = BackupTargetDiskNetworkAccessOption.EnablePrivateAccessForAllDisks, TargetDiskAccessId = new ResourceIdentifier("/subscriptions/e7a191f5-713c-4bdb-b5e4-cf3dd90230ef/resourceGroups/arpja/providers/Microsoft.Compute/diskAccesses/arpja-diskaccess-ccy"), @@ -169,9 +169,9 @@ public async Task TriggerRestore_RestoreDisksWithIaasVMRestoreRequestWithIdentit BackupRecoveryPointResource backupRecoveryPoint = client.GetBackupRecoveryPointResource(backupRecoveryPointResourceId); // invoke the operation - TriggerRestoreContent content = new TriggerRestoreContent(new AzureLocation("placeholder")) + TriggerRestoreContent content = new TriggerRestoreContent(default) { - Properties = new IaasVmRestoreContent() + Properties = new IaasVmRestoreContent { RecoveryPointId = "348916168024334", RecoveryType = FileShareRecoveryType.RestoreDisks, @@ -179,16 +179,16 @@ public async Task TriggerRestore_RestoreDisksWithIaasVMRestoreRequestWithIdentit Region = new AzureLocation("southeastasia"), DoesCreateNewCloudService = true, OriginalStorageAccountOption = false, - EncryptionDetails = new VmEncryptionDetails() + EncryptionDetails = new VmEncryptionDetails { IsEncryptionEnabled = false, }, - IdentityInfo = new BackupIdentityInfo() + IdentityInfo = new BackupIdentityInfo { IsSystemAssignedIdentity = false, ManagedIdentityResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/asmaskarRG1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/asmaskartestmsi"), }, - IdentityBasedRestoreDetails = new IdentityBasedRestoreDetails() + IdentityBasedRestoreDetails = new IdentityBasedRestoreDetails { TargetStorageAccountId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testingRg/providers/Microsoft.Storage/storageAccounts/testAccount"), }, @@ -224,11 +224,11 @@ public async Task TriggerRestore_RestoreDisksWithIaasVMRestoreWithRehydrationReq BackupRecoveryPointResource backupRecoveryPoint = client.GetBackupRecoveryPointResource(backupRecoveryPointResourceId); // invoke the operation - TriggerRestoreContent content = new TriggerRestoreContent(new AzureLocation("placeholder")) + TriggerRestoreContent content = new TriggerRestoreContent(default) { - Properties = new IaasVmRestoreWithRehydrationContent() + Properties = new IaasVmRestoreWithRehydrationContent { - RecoveryPointRehydrationInfo = new RecoveryPointRehydrationInfo() + RecoveryPointRehydrationInfo = new RecoveryPointRehydrationInfo { RehydrationRetentionDuration = XmlConvert.ToTimeSpan("P7D"), RehydrationPriority = RehydrationPriority.Standard, @@ -240,7 +240,7 @@ public async Task TriggerRestore_RestoreDisksWithIaasVMRestoreWithRehydrationReq Region = new AzureLocation("southeastasia"), DoesCreateNewCloudService = true, OriginalStorageAccountOption = false, - EncryptionDetails = new VmEncryptionDetails() + EncryptionDetails = new VmEncryptionDetails { IsEncryptionEnabled = false, }, @@ -276,9 +276,9 @@ public async Task TriggerRestore_RestoreToNewAzureIaasVmWithIaasVMRestoreRequest BackupRecoveryPointResource backupRecoveryPoint = client.GetBackupRecoveryPointResource(backupRecoveryPointResourceId); // invoke the operation - TriggerRestoreContent content = new TriggerRestoreContent(new AzureLocation("placeholder")) + TriggerRestoreContent content = new TriggerRestoreContent(default) { - Properties = new IaasVmRestoreContent() + Properties = new IaasVmRestoreContent { RecoveryPointId = "348916168024334", RecoveryType = FileShareRecoveryType.AlternateLocation, @@ -291,11 +291,11 @@ public async Task TriggerRestore_RestoreToNewAzureIaasVmWithIaasVMRestoreRequest Region = new AzureLocation("southeastasia"), DoesCreateNewCloudService = false, OriginalStorageAccountOption = false, - EncryptionDetails = new VmEncryptionDetails() + EncryptionDetails = new VmEncryptionDetails { IsEncryptionEnabled = false, }, - IdentityInfo = new BackupIdentityInfo() + IdentityInfo = new BackupIdentityInfo { IsSystemAssignedIdentity = true, }, @@ -331,9 +331,9 @@ public async Task TriggerRestore_RestoreToNewAzureIaasVmWithIaasVMRestoreRequest BackupRecoveryPointResource backupRecoveryPoint = client.GetBackupRecoveryPointResource(backupRecoveryPointResourceId); // invoke the operation - TriggerRestoreContent content = new TriggerRestoreContent(new AzureLocation("placeholder")) + TriggerRestoreContent content = new TriggerRestoreContent(default) { - Properties = new IaasVmRestoreContent() + Properties = new IaasVmRestoreContent { RecoveryPointId = "348916168024334", RecoveryType = FileShareRecoveryType.AlternateLocation, @@ -345,15 +345,15 @@ public async Task TriggerRestore_RestoreToNewAzureIaasVmWithIaasVMRestoreRequest Region = new AzureLocation("southeastasia"), DoesCreateNewCloudService = false, OriginalStorageAccountOption = false, - EncryptionDetails = new VmEncryptionDetails() + EncryptionDetails = new VmEncryptionDetails { IsEncryptionEnabled = false, }, - IdentityInfo = new BackupIdentityInfo() + IdentityInfo = new BackupIdentityInfo { IsSystemAssignedIdentity = true, }, - IdentityBasedRestoreDetails = new IdentityBasedRestoreDetails() + IdentityBasedRestoreDetails = new IdentityBasedRestoreDetails { TargetStorageAccountId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testRg/providers/Microsoft.Storage/storageAccounts/testingAccount"), }, @@ -389,11 +389,11 @@ public async Task TriggerRestore_RestoreToNewAzureIaasVmWithIaasVMRestoreWithReh BackupRecoveryPointResource backupRecoveryPoint = client.GetBackupRecoveryPointResource(backupRecoveryPointResourceId); // invoke the operation - TriggerRestoreContent content = new TriggerRestoreContent(new AzureLocation("placeholder")) + TriggerRestoreContent content = new TriggerRestoreContent(default) { - Properties = new IaasVmRestoreWithRehydrationContent() + Properties = new IaasVmRestoreWithRehydrationContent { - RecoveryPointRehydrationInfo = new RecoveryPointRehydrationInfo() + RecoveryPointRehydrationInfo = new RecoveryPointRehydrationInfo { RehydrationRetentionDuration = XmlConvert.ToTimeSpan("P7D"), RehydrationPriority = RehydrationPriority.High, @@ -409,7 +409,7 @@ public async Task TriggerRestore_RestoreToNewAzureIaasVmWithIaasVMRestoreWithReh Region = new AzureLocation("southeastasia"), DoesCreateNewCloudService = false, OriginalStorageAccountOption = false, - EncryptionDetails = new VmEncryptionDetails() + EncryptionDetails = new VmEncryptionDetails { IsEncryptionEnabled = false, }, @@ -445,9 +445,9 @@ public async Task ProvisionItemLevelRecoveryConnection_ProvisionInstantItemLevel BackupRecoveryPointResource backupRecoveryPoint = client.GetBackupRecoveryPointResource(backupRecoveryPointResourceId); // invoke the operation - ProvisionIlrConnectionContent content = new ProvisionIlrConnectionContent(new AzureLocation("placeholder")) + ProvisionIlrConnectionContent content = new ProvisionIlrConnectionContent(default) { - Properties = new IaasVmIlrRegistrationContent() + Properties = new IaasVmIlrRegistrationContent { RecoveryPointId = "38823086363464", VirtualMachineId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/pysdktestrg/providers/Microsoft.Compute/virtualMachines/pysdktestv2vm1"), diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceConfigCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceConfigCollection.cs index e12b97008e7db..4a1d82d445ded 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceConfigCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceConfigCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_BackupResourceConfigCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVaultStorageConfiguration() + public async Task CreateOrUpdate_UpdateVaultStorageConfiguration() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupStorageConfig_Get.json - // this example is just showing the usage of "BackupResourceStorageConfigsNonCRR_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupStorageConfig_Put.json + // this example is just showing the usage of "BackupResourceStorageConfigsNonCRR_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_GetVaultStorageConfiguration() // invoke the operation string vaultName = "PySDKBackupTestRsVault"; - BackupResourceConfigResource result = await collection.GetAsync(vaultName); + BackupResourceConfigData data = new BackupResourceConfigData(default) + { + Properties = new BackupResourceConfigProperties + { + StorageType = BackupStorageType.LocallyRedundant, + StorageTypeState = BackupStorageTypeState.Unlocked, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); + BackupResourceConfigResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_GetVaultStorageConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVaultStorageConfiguration() + public async Task Get_GetVaultStorageConfiguration() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupStorageConfig_Get.json // this example is just showing the usage of "BackupResourceStorageConfigsNonCRR_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,14 +83,18 @@ public async Task Exists_GetVaultStorageConfiguration() // invoke the operation string vaultName = "PySDKBackupTestRsVault"; - bool result = await collection.ExistsAsync(vaultName); + BackupResourceConfigResource result = await collection.GetAsync(vaultName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupResourceConfigData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVaultStorageConfiguration() + public async Task Exists_GetVaultStorageConfiguration() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupStorageConfig_Get.json // this example is just showing the usage of "BackupResourceStorageConfigsNonCRR_Get" operation, for the dependent resources, they will have to be created separately. @@ -103,29 +116,17 @@ public async Task GetIfExists_GetVaultStorageConfiguration() // invoke the operation string vaultName = "PySDKBackupTestRsVault"; - NullableResponse response = await collection.GetIfExistsAsync(vaultName); - BackupResourceConfigResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vaultName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupResourceConfigData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateVaultStorageConfiguration() + public async Task GetIfExists_GetVaultStorageConfiguration() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupStorageConfig_Put.json - // this example is just showing the usage of "BackupResourceStorageConfigsNonCRR_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupStorageConfig_Get.json + // this example is just showing the usage of "BackupResourceStorageConfigsNonCRR_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,22 +145,21 @@ public async Task CreateOrUpdate_UpdateVaultStorageConfiguration() // invoke the operation string vaultName = "PySDKBackupTestRsVault"; - BackupResourceConfigData data = new BackupResourceConfigData(new AzureLocation("placeholder")) - { - Properties = new BackupResourceConfigProperties() - { - StorageType = BackupStorageType.LocallyRedundant, - StorageTypeState = BackupStorageTypeState.Unlocked, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); - BackupResourceConfigResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(vaultName); + BackupResourceConfigResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupResourceConfigData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupResourceConfigData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceConfigResource.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceConfigResource.cs index a62258517e3df..fe3dbdd3523e6 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceConfigResource.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceConfigResource.cs @@ -67,9 +67,9 @@ public async Task Update_UpdateVaultStorageConfiguration() BackupResourceConfigResource backupResourceConfig = client.GetBackupResourceConfigResource(backupResourceConfigResourceId); // invoke the operation - BackupResourceConfigData data = new BackupResourceConfigData(new AzureLocation("placeholder")) + BackupResourceConfigData data = new BackupResourceConfigData(default) { - Properties = new BackupResourceConfigProperties() + Properties = new BackupResourceConfigProperties { StorageType = BackupStorageType.LocallyRedundant, StorageTypeState = BackupStorageTypeState.Unlocked, diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceEncryptionConfigExtendedCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceEncryptionConfigExtendedCollection.cs index 72ff79a66d772..6421edc870df0 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceEncryptionConfigExtendedCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceEncryptionConfigExtendedCollection.cs @@ -17,6 +17,45 @@ namespace Azure.ResourceManager.RecoveryServicesBackup.Samples { public partial class Sample_BackupResourceEncryptionConfigExtendedCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_UpdateVaultEncryptionConfiguration() + { + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/BackupResourceEncryptionConfig_Put.json + // this example is just showing the usage of "BackupResourceEncryptionConfigs_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "test-rg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this BackupResourceEncryptionConfigExtendedResource + BackupResourceEncryptionConfigExtendedCollection collection = resourceGroupResource.GetBackupResourceEncryptionConfigExtendeds(); + + // invoke the operation + string vaultName = "source-rsv"; + BackupResourceEncryptionConfigExtendedCreateOrUpdateContent content = new BackupResourceEncryptionConfigExtendedCreateOrUpdateContent(default) + { + Properties = new BackupResourceEncryptionConfig + { + EncryptionAtRestType = BackupEncryptionAtRestType.CustomerManaged, + KeyUri = new Uri("https://gktestkv1.vault.azure.net/keys/Test1/ed2e8cdc7f86477ebf0c6462b504a9ed"), + SubscriptionId = "1a2311d9-66f5-47d3-a9fb-7a37da63934b", + InfrastructureEncryptionState = new InfrastructureEncryptionState("true"), + }, + }; + await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, content); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetVaultEncryptionConfiguration() @@ -119,44 +158,5 @@ public async Task GetIfExists_GetVaultEncryptionConfiguration() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateVaultEncryptionConfiguration() - { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/BackupResourceEncryptionConfig_Put.json - // this example is just showing the usage of "BackupResourceEncryptionConfigs_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "test-rg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this BackupResourceEncryptionConfigExtendedResource - BackupResourceEncryptionConfigExtendedCollection collection = resourceGroupResource.GetBackupResourceEncryptionConfigExtendeds(); - - // invoke the operation - string vaultName = "source-rsv"; - BackupResourceEncryptionConfigExtendedCreateOrUpdateContent content = new BackupResourceEncryptionConfigExtendedCreateOrUpdateContent(new AzureLocation("placeholder")) - { - Properties = new BackupResourceEncryptionConfig() - { - EncryptionAtRestType = BackupEncryptionAtRestType.CustomerManaged, - KeyUri = new Uri("https://gktestkv1.vault.azure.net/keys/Test1/ed2e8cdc7f86477ebf0c6462b504a9ed"), - SubscriptionId = "1a2311d9-66f5-47d3-a9fb-7a37da63934b", - InfrastructureEncryptionState = new InfrastructureEncryptionState("true"), - }, - }; - await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, content); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceEncryptionConfigExtendedResource.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceEncryptionConfigExtendedResource.cs index e3d5c2922718b..2f48003e9d556 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceEncryptionConfigExtendedResource.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceEncryptionConfigExtendedResource.cs @@ -67,9 +67,9 @@ public async Task Update_UpdateVaultEncryptionConfiguration() BackupResourceEncryptionConfigExtendedResource backupResourceEncryptionConfigExtended = client.GetBackupResourceEncryptionConfigExtendedResource(backupResourceEncryptionConfigExtendedResourceId); // invoke the operation - BackupResourceEncryptionConfigExtendedCreateOrUpdateContent content = new BackupResourceEncryptionConfigExtendedCreateOrUpdateContent(new AzureLocation("placeholder")) + BackupResourceEncryptionConfigExtendedCreateOrUpdateContent content = new BackupResourceEncryptionConfigExtendedCreateOrUpdateContent(default) { - Properties = new BackupResourceEncryptionConfig() + Properties = new BackupResourceEncryptionConfig { EncryptionAtRestType = BackupEncryptionAtRestType.CustomerManaged, KeyUri = new Uri("https://gktestkv1.vault.azure.net/keys/Test1/ed2e8cdc7f86477ebf0c6462b504a9ed"), diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceVaultConfigCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceVaultConfigCollection.cs index eb609951f431c..e74334e01849a 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceVaultConfigCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceVaultConfigCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_BackupResourceVaultConfigCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVaultSecurityConfig() + public async Task CreateOrUpdate_UpdateVaultSecurityConfig() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupResourceVaultConfigs_Get.json - // this example is just showing the usage of "BackupResourceVaultConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupResourceVaultConfigs_Put.json + // this example is just showing the usage of "BackupResourceVaultConfigs_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_GetVaultSecurityConfig() // invoke the operation string vaultName = "SwaggerTest"; - BackupResourceVaultConfigResource result = await collection.GetAsync(vaultName); + BackupResourceVaultConfigData data = new BackupResourceVaultConfigData(default) + { + Properties = new BackupResourceVaultConfigProperties + { + EnhancedSecurityState = EnhancedSecurityState.Enabled, + SoftDeleteFeatureState = SoftDeleteFeatureState.Enabled, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); + BackupResourceVaultConfigResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_GetVaultSecurityConfig() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVaultSecurityConfig() + public async Task Get_GetVaultSecurityConfig() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupResourceVaultConfigs_Get.json // this example is just showing the usage of "BackupResourceVaultConfigs_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,14 +83,18 @@ public async Task Exists_GetVaultSecurityConfig() // invoke the operation string vaultName = "SwaggerTest"; - bool result = await collection.ExistsAsync(vaultName); + BackupResourceVaultConfigResource result = await collection.GetAsync(vaultName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupResourceVaultConfigData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVaultSecurityConfig() + public async Task Exists_GetVaultSecurityConfig() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupResourceVaultConfigs_Get.json // this example is just showing the usage of "BackupResourceVaultConfigs_Get" operation, for the dependent resources, they will have to be created separately. @@ -103,29 +116,17 @@ public async Task GetIfExists_GetVaultSecurityConfig() // invoke the operation string vaultName = "SwaggerTest"; - NullableResponse response = await collection.GetIfExistsAsync(vaultName); - BackupResourceVaultConfigResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vaultName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupResourceVaultConfigData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateVaultSecurityConfig() + public async Task GetIfExists_GetVaultSecurityConfig() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupResourceVaultConfigs_Put.json - // this example is just showing the usage of "BackupResourceVaultConfigs_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/BackupResourceVaultConfigs_Get.json + // this example is just showing the usage of "BackupResourceVaultConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,22 +145,21 @@ public async Task CreateOrUpdate_UpdateVaultSecurityConfig() // invoke the operation string vaultName = "SwaggerTest"; - BackupResourceVaultConfigData data = new BackupResourceVaultConfigData(new AzureLocation("placeholder")) - { - Properties = new BackupResourceVaultConfigProperties() - { - EnhancedSecurityState = EnhancedSecurityState.Enabled, - SoftDeleteFeatureState = SoftDeleteFeatureState.Enabled, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); - BackupResourceVaultConfigResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(vaultName); + BackupResourceVaultConfigResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupResourceVaultConfigData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupResourceVaultConfigData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceVaultConfigResource.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceVaultConfigResource.cs index 7a5f012e82a37..4464b8cd144cc 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceVaultConfigResource.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_BackupResourceVaultConfigResource.cs @@ -67,9 +67,9 @@ public async Task Update_UpdateVaultSecurityConfig() BackupResourceVaultConfigResource backupResourceVaultConfig = client.GetBackupResourceVaultConfigResource(backupResourceVaultConfigResourceId); // invoke the operation - BackupResourceVaultConfigData data = new BackupResourceVaultConfigData(new AzureLocation("placeholder")) + BackupResourceVaultConfigData data = new BackupResourceVaultConfigData(default) { - Properties = new BackupResourceVaultConfigProperties() + Properties = new BackupResourceVaultConfigProperties { EnhancedSecurityState = EnhancedSecurityState.Enabled, }, diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index 77e24a7ddd447..e423e344b6fac 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -201,6 +201,33 @@ public async Task GetProtectableContainers_ListProtectableItemsWithBackupManagem Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task RefreshProtectionContainer_TriggerAzureVmDiscovery() + { + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/Common/RefreshContainers.json + // this example is just showing the usage of "ProtectionContainers_Refresh" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "SwaggerTestRg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation + string vaultName = "NetSDKTestRsVault"; + string fabricName = "Azure"; + await resourceGroupResource.RefreshProtectionContainerAsync(vaultName, fabricName); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetBackupProtectableItems_ListProtectableItemsWithBackupManagementTypeFilterAsAzureIaasVm() @@ -346,7 +373,13 @@ public async Task PostFetchTieringCost_GetTheRehydrationCostForRecoveryPoint() // invoke the operation string vaultName = "testVault"; - FetchTieringCostInfoContent content = new FetchTieringCostInfoForRehydrationContent(RecoveryPointTierType.ArchivedRP, RecoveryPointTierType.HardenedRP, "IaasVMContainer;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1", "VM;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1", "1222343434", RehydrationPriority.High); + FetchTieringCostInfoContent content = new FetchTieringCostInfoForRehydrationContent( + RecoveryPointTierType.ArchivedRP, + RecoveryPointTierType.HardenedRP, + "IaasVMContainer;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1", + "VM;iaasvmcontainerv2;netsdktestrg;netvmtestv2vm1", + "1222343434", + RehydrationPriority.High); ArmOperation lro = await resourceGroupResource.PostFetchTieringCostAsync(WaitUntil.Completed, vaultName, content); TieringCostInfo result = lro.Value; diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGuardProxyCollection.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGuardProxyCollection.cs index 3277127f28360..0901f8b971a2a 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGuardProxyCollection.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGuardProxyCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ResourceGuardProxyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetVaultGuardProxies() + public async Task CreateOrUpdate_CreateResourceGuardProxy() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/ListResourceGuardProxy.json - // this example is just showing the usage of "ResourceGuardProxy_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/PutResourceGuardProxy.json + // this example is just showing the usage of "ResourceGuardProxy_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_GetVaultGuardProxies() string vaultName = "sampleVault"; ResourceGuardProxyCollection collection = resourceGroupResource.GetResourceGuardProxies(vaultName); - // invoke the operation and iterate over the result - await foreach (ResourceGuardProxyResource item in collection.GetAllAsync()) + // invoke the operation + string resourceGuardProxyName = "swaggerExample"; + ResourceGuardProxyData data = new ResourceGuardProxyData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceGuardProxyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new ResourceGuardProxyProperties(new ResourceIdentifier("/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew")), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceGuardProxyName, data); + ResourceGuardProxyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceGuardProxyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_GetResourceGuardProxy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetResourceGuardProxy() + public async Task GetAll_GetVaultGuardProxies() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/GetResourceGuardProxy.json - // this example is just showing the usage of "ResourceGuardProxy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/ListResourceGuardProxy.json + // this example is just showing the usage of "ResourceGuardProxy_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +113,22 @@ public async Task Exists_GetResourceGuardProxy() string vaultName = "sampleVault"; ResourceGuardProxyCollection collection = resourceGroupResource.GetResourceGuardProxies(vaultName); - // invoke the operation - string resourceGuardProxyName = "swaggerExample"; - bool result = await collection.ExistsAsync(resourceGuardProxyName); + // invoke the operation and iterate over the result + await foreach (ResourceGuardProxyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceGuardProxyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetResourceGuardProxy() + public async Task Exists_GetResourceGuardProxy() { // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/GetResourceGuardProxy.json // this example is just showing the usage of "ResourceGuardProxy_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +151,17 @@ public async Task GetIfExists_GetResourceGuardProxy() // invoke the operation string resourceGuardProxyName = "swaggerExample"; - NullableResponse response = await collection.GetIfExistsAsync(resourceGuardProxyName); - ResourceGuardProxyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceGuardProxyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceGuardProxyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateResourceGuardProxy() + public async Task GetIfExists_GetResourceGuardProxy() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/PutResourceGuardProxy.json - // this example is just showing the usage of "ResourceGuardProxy_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/GetResourceGuardProxy.json + // this example is just showing the usage of "ResourceGuardProxy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,18 +181,21 @@ public async Task CreateOrUpdate_CreateResourceGuardProxy() // invoke the operation string resourceGuardProxyName = "swaggerExample"; - ResourceGuardProxyData data = new ResourceGuardProxyData(new AzureLocation("placeholder")) - { - Properties = new ResourceGuardProxyProperties(new ResourceIdentifier("/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew")), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceGuardProxyName, data); - ResourceGuardProxyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceGuardProxyName); + ResourceGuardProxyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceGuardProxyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceGuardProxyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGuardProxyResource.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGuardProxyResource.cs index 184fee87ead48..94ba195a1ba3a 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGuardProxyResource.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_ResourceGuardProxyResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetResourceGuardProxy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateResourceGuardProxy() + public async Task Delete_DeleteResourceGuardProxy() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/PutResourceGuardProxy.json - // this example is just showing the usage of "ResourceGuardProxy_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/DeleteResourceGuardProxy.json + // this example is just showing the usage of "ResourceGuardProxy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_CreateResourceGuardProxy() ResourceGuardProxyResource resourceGuardProxy = client.GetResourceGuardProxyResource(resourceGuardProxyResourceId); // invoke the operation - ResourceGuardProxyData data = new ResourceGuardProxyData(new AzureLocation("placeholder")) - { - Properties = new ResourceGuardProxyProperties(new ResourceIdentifier("/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew")), - }; - ArmOperation lro = await resourceGuardProxy.UpdateAsync(WaitUntil.Completed, data); - ResourceGuardProxyResource result = lro.Value; + await resourceGuardProxy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceGuardProxyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteResourceGuardProxy() + public async Task Update_CreateResourceGuardProxy() { - // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/DeleteResourceGuardProxy.json - // this example is just showing the usage of "ResourceGuardProxy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/ResourceGuardProxyCRUD/PutResourceGuardProxy.json + // this example is just showing the usage of "ResourceGuardProxy_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeleteResourceGuardProxy() ResourceGuardProxyResource resourceGuardProxy = client.GetResourceGuardProxyResource(resourceGuardProxyResourceId); // invoke the operation - await resourceGuardProxy.DeleteAsync(WaitUntil.Completed); + ResourceGuardProxyData data = new ResourceGuardProxyData(default) + { + Properties = new ResourceGuardProxyProperties(new ResourceIdentifier("/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew")), + }; + ArmOperation lro = await resourceGuardProxy.UpdateAsync(WaitUntil.Completed, data); + ResourceGuardProxyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceGuardProxyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -132,12 +132,9 @@ public async Task UnlockDelete_UnlockDeleteResourceGuardProxy() ResourceGuardProxyResource resourceGuardProxy = client.GetResourceGuardProxyResource(resourceGuardProxyResourceId); // invoke the operation - UnlockDeleteContent content = new UnlockDeleteContent() + UnlockDeleteContent content = new UnlockDeleteContent { - ResourceGuardOperationRequests = -{ -"/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew/deleteProtectedItemRequests/default" -}, + ResourceGuardOperationRequests = { "/subscriptions/c999d45b-944f-418c-a0d8-c3fcfd1802c8/resourceGroups/vaultguardRGNew/providers/Microsoft.DataProtection/resourceGuards/VaultGuardTestNew/deleteProtectedItemRequests/default" }, ResourceToBeDeleted = "/subscriptions/62b829ee-7936-40c9-a1c9-47a93f9f3965/resourceGroups/gaallarg/providers/Microsoft.RecoveryServices/vaults/MercuryCrrVault/backupFabrics/Azure/protectionContainers/VMAppContainer;compute;crrtestrg;crrtestvm/protectedItems/SQLDataBase;mssqlserver;testdb", }; UnlockDeleteResult result = await resourceGuardProxy.UnlockDeleteAsync(content); diff --git a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 2c9f48fa00e0b..8ce03fd7f7401 100644 --- a/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/recoveryservices-backup/Azure.ResourceManager.RecoveryServicesBackup/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,38 @@ namespace Azure.ResourceManager.RecoveryServicesBackup.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task ValidateProtectionIntent_ValidateEnableProtectionOnAzureVm() + { + // Generated from example definition: specification/recoveryservicesbackup/resource-manager/Microsoft.RecoveryServices/stable/2023-06-01/examples/AzureIaasVm/ProtectionIntent_Validate.json + // this example is just showing the usage of "ProtectionIntent_Validate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("southeastasia"); + PreValidateEnableBackupContent content = new PreValidateEnableBackupContent + { + ResourceType = BackupDataSourceType.Vm, + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/arunaupgrade/providers/Microsoft.Compute/VirtualMachines/upgrade1"), + VaultId = new ResourceIdentifier("/Subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myRG/providers/Microsoft.RecoveryServices/Vaults/myVault"), + Properties = "", + }; + PreValidateEnableBackupResult result = await subscriptionResource.ValidateProtectionIntentAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetBackupStatus_GetAzureVirtualMachineBackupStatus() @@ -37,7 +69,7 @@ public async Task GetBackupStatus_GetAzureVirtualMachineBackupStatus() // invoke the operation AzureLocation location = new AzureLocation("southeastasia"); - BackupStatusContent content = new BackupStatusContent() + BackupStatusContent content = new BackupStatusContent { ResourceType = BackupDataSourceType.Vm, ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testRg/providers/Microsoft.Compute/VirtualMachines/testVm"), @@ -67,7 +99,7 @@ public async Task ValidateFeatureSupport_CheckAzureVmBackupFeatureSupport() // invoke the operation AzureLocation location = new AzureLocation("southeastasia"); - FeatureSupportContent content = new VmResourceFeatureSupportContent() + FeatureSupportContent content = new VmResourceFeatureSupportContent { VmSize = "Basic_A0", VmSku = "Premium", diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationDraCollection.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationDraCollection.cs index 265701b27abe8..145b48764334b 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationDraCollection.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationDraCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataReplicationDraCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DraGet() + public async Task CreateOrUpdate_DraCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Get.json - // this example is just showing the usage of "Dra_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Create.json + // this example is just showing the usage of "Dra_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,9 @@ public async Task Get_DraGet() // invoke the operation string fabricAgentName = "M"; - DataReplicationDraResource result = await collection.GetAsync(fabricAgentName); + DataReplicationDraData data = new DataReplicationDraData(new DataReplicationDraProperties("envzcoijbqhtrpncbjbhk", "y", new DataReplicationIdentity(Guid.Parse("joclkkdovixwapephhxaqtefubhhmq"), "cwktzrwajuvfyyymfstpey", "khsiaqfbpuhp", "dkjobanyqgzenivyxhvavottpc", "bubwwbowfhdmujrt"), new DataReplicationIdentity(Guid.Parse("joclkkdovixwapephhxaqtefubhhmq"), "cwktzrwajuvfyyymfstpey", "khsiaqfbpuhp", "dkjobanyqgzenivyxhvavottpc", "bubwwbowfhdmujrt"), new GeneralDraModelCustomProperties())); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fabricAgentName, data); + DataReplicationDraResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +54,7 @@ public async Task Get_DraGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DraGet() + public async Task Get_DraGet() { // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Get.json // this example is just showing the usage of "Dra_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +77,21 @@ public async Task Exists_DraGet() // invoke the operation string fabricAgentName = "M"; - bool result = await collection.ExistsAsync(fabricAgentName); + DataReplicationDraResource result = await collection.GetAsync(fabricAgentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationDraData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DraGet() + public async Task GetAll_DraList() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Get.json - // this example is just showing the usage of "Dra_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_List.json + // this example is just showing the usage of "Dra_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +109,25 @@ public async Task GetIfExists_DraGet() // get the collection of this DataReplicationDraResource DataReplicationDraCollection collection = dataReplicationFabric.GetDataReplicationDras(); - // invoke the operation - string fabricAgentName = "M"; - NullableResponse response = await collection.GetIfExistsAsync(fabricAgentName); - DataReplicationDraResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataReplicationDraResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationDraData resourceData = result.Data; + DataReplicationDraData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DraCreate() + public async Task Exists_DraGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Create.json - // this example is just showing the usage of "Dra_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Get.json + // this example is just showing the usage of "Dra_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,23 +147,17 @@ public async Task CreateOrUpdate_DraCreate() // invoke the operation string fabricAgentName = "M"; - DataReplicationDraData data = new DataReplicationDraData(new DataReplicationDraProperties("envzcoijbqhtrpncbjbhk", "y", new DataReplicationIdentity(Guid.Parse("joclkkdovixwapephhxaqtefubhhmq"), "cwktzrwajuvfyyymfstpey", "khsiaqfbpuhp", "dkjobanyqgzenivyxhvavottpc", "bubwwbowfhdmujrt"), new DataReplicationIdentity(Guid.Parse("joclkkdovixwapephhxaqtefubhhmq"), "cwktzrwajuvfyyymfstpey", "khsiaqfbpuhp", "dkjobanyqgzenivyxhvavottpc", "bubwwbowfhdmujrt"), new GeneralDraModelCustomProperties())); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fabricAgentName, data); - DataReplicationDraResource result = lro.Value; + bool result = await collection.ExistsAsync(fabricAgentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationDraData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DraList() + public async Task GetIfExists_DraGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_List.json - // this example is just showing the usage of "Dra_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Get.json + // this example is just showing the usage of "Dra_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_DraList() // get the collection of this DataReplicationDraResource DataReplicationDraCollection collection = dataReplicationFabric.GetDataReplicationDras(); - // invoke the operation and iterate over the result - await foreach (DataReplicationDraResource item in collection.GetAllAsync()) + // invoke the operation + string fabricAgentName = "M"; + NullableResponse response = await collection.GetIfExistsAsync(fabricAgentName); + DataReplicationDraResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationDraData resourceData = item.Data; + DataReplicationDraData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationDraResource.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationDraResource.cs index 081974329eebe..27bbf0fa7ae9c 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationDraResource.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationDraResource.cs @@ -49,10 +49,10 @@ public async Task Get_DraGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DraCreate() + public async Task Delete_DraDelete() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Create.json - // this example is just showing the usage of "Dra_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Delete.json + // this example is just showing the usage of "Dra_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,23 +69,17 @@ public async Task Update_DraCreate() DataReplicationDraResource dataReplicationDra = client.GetDataReplicationDraResource(dataReplicationDraResourceId); // invoke the operation - DataReplicationDraData data = new DataReplicationDraData(new DataReplicationDraProperties("envzcoijbqhtrpncbjbhk", "y", new DataReplicationIdentity(Guid.Parse("joclkkdovixwapephhxaqtefubhhmq"), "cwktzrwajuvfyyymfstpey", "khsiaqfbpuhp", "dkjobanyqgzenivyxhvavottpc", "bubwwbowfhdmujrt"), new DataReplicationIdentity(Guid.Parse("joclkkdovixwapephhxaqtefubhhmq"), "cwktzrwajuvfyyymfstpey", "khsiaqfbpuhp", "dkjobanyqgzenivyxhvavottpc", "bubwwbowfhdmujrt"), new GeneralDraModelCustomProperties())); - ArmOperation lro = await dataReplicationDra.UpdateAsync(WaitUntil.Completed, data); - DataReplicationDraResource result = lro.Value; + await dataReplicationDra.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationDraData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DraDelete() + public async Task Update_DraCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Delete.json - // this example is just showing the usage of "Dra_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Dra_Create.json + // this example is just showing the usage of "Dra_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_DraDelete() DataReplicationDraResource dataReplicationDra = client.GetDataReplicationDraResource(dataReplicationDraResourceId); // invoke the operation - await dataReplicationDra.DeleteAsync(WaitUntil.Completed); + DataReplicationDraData data = new DataReplicationDraData(new DataReplicationDraProperties("envzcoijbqhtrpncbjbhk", "y", new DataReplicationIdentity(Guid.Parse("joclkkdovixwapephhxaqtefubhhmq"), "cwktzrwajuvfyyymfstpey", "khsiaqfbpuhp", "dkjobanyqgzenivyxhvavottpc", "bubwwbowfhdmujrt"), new DataReplicationIdentity(Guid.Parse("joclkkdovixwapephhxaqtefubhhmq"), "cwktzrwajuvfyyymfstpey", "khsiaqfbpuhp", "dkjobanyqgzenivyxhvavottpc", "bubwwbowfhdmujrt"), new GeneralDraModelCustomProperties())); + ArmOperation lro = await dataReplicationDra.UpdateAsync(WaitUntil.Completed, data); + DataReplicationDraResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationDraData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEmailConfigurationCollection.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEmailConfigurationCollection.cs index ad117410f1f2e..3ea11f2e975d7 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEmailConfigurationCollection.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEmailConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataReplicationEmailConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EmailConfigurationGet() + public async Task CreateOrUpdate_EmailConfigurationCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_Get.json - // this example is just showing the usage of "EmailConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_Create.json + // this example is just showing the usage of "EmailConfiguration_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,13 @@ public async Task Get_EmailConfigurationGet() // invoke the operation string emailConfigurationName = "0"; - DataReplicationEmailConfigurationResource result = await collection.GetAsync(emailConfigurationName); + DataReplicationEmailConfigurationData data = new DataReplicationEmailConfigurationData(new DataReplicationEmailConfigurationProperties(true) + { + CustomEmailAddresses = { "ketvbducyailcny" }, + Locale = "vpnjxjvdqtebnucyxiyrjiko", + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, emailConfigurationName, data); + DataReplicationEmailConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +58,7 @@ public async Task Get_EmailConfigurationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EmailConfigurationGet() + public async Task Get_EmailConfigurationGet() { // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_Get.json // this example is just showing the usage of "EmailConfiguration_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +81,21 @@ public async Task Exists_EmailConfigurationGet() // invoke the operation string emailConfigurationName = "0"; - bool result = await collection.ExistsAsync(emailConfigurationName); + DataReplicationEmailConfigurationResource result = await collection.GetAsync(emailConfigurationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationEmailConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EmailConfigurationGet() + public async Task GetAll_EmailConfigurationList() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_Get.json - // this example is just showing the usage of "EmailConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_List.json + // this example is just showing the usage of "EmailConfiguration_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +113,25 @@ public async Task GetIfExists_EmailConfigurationGet() // get the collection of this DataReplicationEmailConfigurationResource DataReplicationEmailConfigurationCollection collection = dataReplicationVault.GetDataReplicationEmailConfigurations(); - // invoke the operation - string emailConfigurationName = "0"; - NullableResponse response = await collection.GetIfExistsAsync(emailConfigurationName); - DataReplicationEmailConfigurationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataReplicationEmailConfigurationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationEmailConfigurationData resourceData = result.Data; + DataReplicationEmailConfigurationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EmailConfigurationCreate() + public async Task Exists_EmailConfigurationGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_Create.json - // this example is just showing the usage of "EmailConfiguration_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_Get.json + // this example is just showing the usage of "EmailConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,30 +151,17 @@ public async Task CreateOrUpdate_EmailConfigurationCreate() // invoke the operation string emailConfigurationName = "0"; - DataReplicationEmailConfigurationData data = new DataReplicationEmailConfigurationData(new DataReplicationEmailConfigurationProperties(true) - { - CustomEmailAddresses = -{ -"ketvbducyailcny" -}, - Locale = "vpnjxjvdqtebnucyxiyrjiko", - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, emailConfigurationName, data); - DataReplicationEmailConfigurationResource result = lro.Value; + bool result = await collection.ExistsAsync(emailConfigurationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationEmailConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EmailConfigurationList() + public async Task GetIfExists_EmailConfigurationGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_List.json - // this example is just showing the usage of "EmailConfiguration_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/EmailConfiguration_Get.json + // this example is just showing the usage of "EmailConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +179,23 @@ public async Task GetAll_EmailConfigurationList() // get the collection of this DataReplicationEmailConfigurationResource DataReplicationEmailConfigurationCollection collection = dataReplicationVault.GetDataReplicationEmailConfigurations(); - // invoke the operation and iterate over the result - await foreach (DataReplicationEmailConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string emailConfigurationName = "0"; + NullableResponse response = await collection.GetIfExistsAsync(emailConfigurationName); + DataReplicationEmailConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationEmailConfigurationData resourceData = item.Data; + DataReplicationEmailConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEmailConfigurationResource.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEmailConfigurationResource.cs index 21b727d5c872f..d7c5d9a7f8f70 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEmailConfigurationResource.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEmailConfigurationResource.cs @@ -71,10 +71,7 @@ public async Task Update_EmailConfigurationCreate() // invoke the operation DataReplicationEmailConfigurationData data = new DataReplicationEmailConfigurationData(new DataReplicationEmailConfigurationProperties(true) { - CustomEmailAddresses = -{ -"ketvbducyailcny" -}, + CustomEmailAddresses = { "ketvbducyailcny" }, Locale = "vpnjxjvdqtebnucyxiyrjiko", }); ArmOperation lro = await dataReplicationEmailConfiguration.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEventCollection.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEventCollection.cs index f935c409e5e69..5c320a6c99a4f 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEventCollection.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationEventCollection.cs @@ -51,10 +51,10 @@ public async Task Get_EventGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EventGet() + public async Task GetAll_EventList() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Event_Get.json - // this example is just showing the usage of "Event_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Event_List.json + // this example is just showing the usage of "Event_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,24 @@ public async Task Exists_EventGet() // get the collection of this DataReplicationEventResource DataReplicationEventCollection collection = dataReplicationVault.GetDataReplicationEvents(); - // invoke the operation - string eventName = "231CIG"; - bool result = await collection.ExistsAsync(eventName); + // invoke the operation and iterate over the result + string filter = "wbglupjzvkirtgnnyasxom"; + string continuationToken = "cxtufi"; + await foreach (DataReplicationEventResource item in collection.GetAllAsync(filter: filter, continuationToken: continuationToken)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationEventData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EventGet() + public async Task Exists_EventGet() { // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Event_Get.json // this example is just showing the usage of "Event_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +112,17 @@ public async Task GetIfExists_EventGet() // invoke the operation string eventName = "231CIG"; - NullableResponse response = await collection.GetIfExistsAsync(eventName); - DataReplicationEventResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(eventName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationEventData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EventList() + public async Task GetIfExists_EventGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Event_List.json - // this example is just showing the usage of "Event_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Event_Get.json + // this example is just showing the usage of "Event_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,19 +140,23 @@ public async Task GetAll_EventList() // get the collection of this DataReplicationEventResource DataReplicationEventCollection collection = dataReplicationVault.GetDataReplicationEvents(); - // invoke the operation and iterate over the result - string filter = "wbglupjzvkirtgnnyasxom"; - string continuationToken = "cxtufi"; - await foreach (DataReplicationEventResource item in collection.GetAllAsync(filter: filter, continuationToken: continuationToken)) + // invoke the operation + string eventName = "231CIG"; + NullableResponse response = await collection.GetIfExistsAsync(eventName); + DataReplicationEventResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationEventData resourceData = item.Data; + DataReplicationEventData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationFabricCollection.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationFabricCollection.cs index ab309473ee642..fc1808f3ce4fa 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationFabricCollection.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationFabricCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DataReplicationFabricCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FabricGet() + public async Task CreateOrUpdate_FabricCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Get.json - // this example is just showing the usage of "Fabric_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Create.json + // this example is just showing the usage of "Fabric_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_FabricGet() // invoke the operation string fabricName = "wPR"; - DataReplicationFabricResource result = await collection.GetAsync(fabricName); + DataReplicationFabricData data = new DataReplicationFabricData(new AzureLocation("tqygutlpob"), new DataReplicationFabricProperties(new GeneralFabricModelCustomProperties())) + { + Tags = +{ +["key3917"] = "vgralu" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fabricName, data); + DataReplicationFabricResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_FabricGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FabricGet() + public async Task Get_FabricGet() { // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Get.json // this example is just showing the usage of "Fabric_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +82,21 @@ public async Task Exists_FabricGet() // invoke the operation string fabricName = "wPR"; - bool result = await collection.ExistsAsync(fabricName); + DataReplicationFabricResource result = await collection.GetAsync(fabricName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationFabricData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FabricGet() + public async Task GetAll_FabricList() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Get.json - // this example is just showing the usage of "Fabric_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_List.json + // this example is just showing the usage of "Fabric_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +113,26 @@ public async Task GetIfExists_FabricGet() // get the collection of this DataReplicationFabricResource DataReplicationFabricCollection collection = resourceGroupResource.GetDataReplicationFabrics(); - // invoke the operation - string fabricName = "wPR"; - NullableResponse response = await collection.GetIfExistsAsync(fabricName); - DataReplicationFabricResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string continuationToken = "mjzsxwwmtvd"; + await foreach (DataReplicationFabricResource item in collection.GetAllAsync(continuationToken: continuationToken)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationFabricData resourceData = result.Data; + DataReplicationFabricData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FabricCreate() + public async Task Exists_FabricGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Create.json - // this example is just showing the usage of "Fabric_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Get.json + // this example is just showing the usage of "Fabric_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,29 +151,17 @@ public async Task CreateOrUpdate_FabricCreate() // invoke the operation string fabricName = "wPR"; - DataReplicationFabricData data = new DataReplicationFabricData(new AzureLocation("tqygutlpob"), new DataReplicationFabricProperties(new GeneralFabricModelCustomProperties())) - { - Tags = -{ -["key3917"] = "vgralu", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fabricName, data); - DataReplicationFabricResource result = lro.Value; + bool result = await collection.ExistsAsync(fabricName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationFabricData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FabricList() + public async Task GetIfExists_FabricGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_List.json - // this example is just showing the usage of "Fabric_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Get.json + // this example is just showing the usage of "Fabric_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +178,23 @@ public async Task GetAll_FabricList() // get the collection of this DataReplicationFabricResource DataReplicationFabricCollection collection = resourceGroupResource.GetDataReplicationFabrics(); - // invoke the operation and iterate over the result - string continuationToken = "mjzsxwwmtvd"; - await foreach (DataReplicationFabricResource item in collection.GetAllAsync(continuationToken: continuationToken)) + // invoke the operation + string fabricName = "wPR"; + NullableResponse response = await collection.GetIfExistsAsync(fabricName); + DataReplicationFabricResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationFabricData resourceData = item.Data; + DataReplicationFabricData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationFabricResource.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationFabricResource.cs index 1c0b44739968f..8304c10dc00cc 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationFabricResource.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationFabricResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesDataReplication.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesDataReplication.Samples @@ -49,10 +48,10 @@ public async Task Get_FabricGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FabricUpdate() + public async Task Delete_FabricDelete() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Update.json - // this example is just showing the usage of "Fabric_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Delete.json + // this example is just showing the usage of "Fabric_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,30 +67,17 @@ public async Task Update_FabricUpdate() DataReplicationFabricResource dataReplicationFabric = client.GetDataReplicationFabricResource(dataReplicationFabricResourceId); // invoke the operation - DataReplicationFabricPatch patch = new DataReplicationFabricPatch() - { - Tags = -{ -["key6664"] = "def", -}, - Properties = new DataReplicationFabricProperties(new GeneralFabricModelCustomProperties()), - }; - ArmOperation lro = await dataReplicationFabric.UpdateAsync(WaitUntil.Completed, patch); - DataReplicationFabricResource result = lro.Value; + await dataReplicationFabric.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationFabricData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_FabricDelete() + public async Task Update_FabricUpdate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Delete.json - // this example is just showing the usage of "Fabric_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_Update.json + // this example is just showing the usage of "Fabric_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,41 +93,22 @@ public async Task Delete_FabricDelete() DataReplicationFabricResource dataReplicationFabric = client.GetDataReplicationFabricResource(dataReplicationFabricResourceId); // invoke the operation - await dataReplicationFabric.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDataReplicationFabrics_FabricListBySubscription() - { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_ListBySubscription.json - // this example is just showing the usage of "Fabric_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "930CEC23-4430-4513-B855-DBA237E2F3BF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string continuationToken = "rmgqrpzucsizbyjscxzockbiyg"; - await foreach (DataReplicationFabricResource item in subscriptionResource.GetDataReplicationFabricsAsync(continuationToken: continuationToken)) + DataReplicationFabricPatch patch = new DataReplicationFabricPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationFabricData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key6664"] = "def" +}, + Properties = new DataReplicationFabricProperties(new GeneralFabricModelCustomProperties()), + }; + ArmOperation lro = await dataReplicationFabric.UpdateAsync(WaitUntil.Completed, patch); + DataReplicationFabricResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationFabricData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationPolicyCollection.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationPolicyCollection.cs index 866a0ecd6c55d..f2ebea20810a0 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationPolicyCollection.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataReplicationPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PolicyGet() + public async Task CreateOrUpdate_PolicyCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Get.json - // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Create.json + // this example is just showing the usage of "Policy_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,10 @@ public async Task Get_PolicyGet() DataReplicationPolicyCollection collection = dataReplicationVault.GetDataReplicationPolicies(); // invoke the operation - string policyName = "wdqsacasc"; - DataReplicationPolicyResource result = await collection.GetAsync(policyName); + string policyName = "fafqwc"; + DataReplicationPolicyData data = new DataReplicationPolicyData(new DataReplicationPolicyProperties(new GeneralPolicyModelCustomProperties())); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + DataReplicationPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +54,7 @@ public async Task Get_PolicyGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PolicyGet() + public async Task Get_PolicyGet() { // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Get.json // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +77,21 @@ public async Task Exists_PolicyGet() // invoke the operation string policyName = "wdqsacasc"; - bool result = await collection.ExistsAsync(policyName); + DataReplicationPolicyResource result = await collection.GetAsync(policyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PolicyGet() + public async Task GetAll_PolicyList() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Get.json - // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_List.json + // this example is just showing the usage of "Policy_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +109,25 @@ public async Task GetIfExists_PolicyGet() // get the collection of this DataReplicationPolicyResource DataReplicationPolicyCollection collection = dataReplicationVault.GetDataReplicationPolicies(); - // invoke the operation - string policyName = "wdqsacasc"; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - DataReplicationPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataReplicationPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationPolicyData resourceData = result.Data; + DataReplicationPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PolicyCreate() + public async Task Exists_PolicyGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Create.json - // this example is just showing the usage of "Policy_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Get.json + // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,24 +146,18 @@ public async Task CreateOrUpdate_PolicyCreate() DataReplicationPolicyCollection collection = dataReplicationVault.GetDataReplicationPolicies(); // invoke the operation - string policyName = "fafqwc"; - DataReplicationPolicyData data = new DataReplicationPolicyData(new DataReplicationPolicyProperties(new GeneralPolicyModelCustomProperties())); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - DataReplicationPolicyResource result = lro.Value; + string policyName = "wdqsacasc"; + bool result = await collection.ExistsAsync(policyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PolicyList() + public async Task GetIfExists_PolicyGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_List.json - // this example is just showing the usage of "Policy_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Get.json + // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_PolicyList() // get the collection of this DataReplicationPolicyResource DataReplicationPolicyCollection collection = dataReplicationVault.GetDataReplicationPolicies(); - // invoke the operation and iterate over the result - await foreach (DataReplicationPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string policyName = "wdqsacasc"; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + DataReplicationPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationPolicyData resourceData = item.Data; + DataReplicationPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationPolicyResource.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationPolicyResource.cs index 8540e68a68d3e..c7f12b798c790 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationPolicyResource.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationPolicyResource.cs @@ -49,10 +49,10 @@ public async Task Get_PolicyGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PolicyCreate() + public async Task Delete_PolicyDelete() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Create.json - // this example is just showing the usage of "Policy_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Delete.json + // this example is just showing the usage of "Policy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,28 +64,22 @@ public async Task Update_PolicyCreate() string subscriptionId = "930CEC23-4430-4513-B855-DBA237E2F3BF"; string resourceGroupName = "rgrecoveryservicesdatareplication"; string vaultName = "4"; - string policyName = "fafqwc"; + string policyName = "wqfscsdv"; ResourceIdentifier dataReplicationPolicyResourceId = DataReplicationPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, policyName); DataReplicationPolicyResource dataReplicationPolicy = client.GetDataReplicationPolicyResource(dataReplicationPolicyResourceId); // invoke the operation - DataReplicationPolicyData data = new DataReplicationPolicyData(new DataReplicationPolicyProperties(new GeneralPolicyModelCustomProperties())); - ArmOperation lro = await dataReplicationPolicy.UpdateAsync(WaitUntil.Completed, data); - DataReplicationPolicyResource result = lro.Value; + await dataReplicationPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PolicyDelete() + public async Task Update_PolicyCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Delete.json - // this example is just showing the usage of "Policy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Policy_Create.json + // this example is just showing the usage of "Policy_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,14 +91,20 @@ public async Task Delete_PolicyDelete() string subscriptionId = "930CEC23-4430-4513-B855-DBA237E2F3BF"; string resourceGroupName = "rgrecoveryservicesdatareplication"; string vaultName = "4"; - string policyName = "wqfscsdv"; + string policyName = "fafqwc"; ResourceIdentifier dataReplicationPolicyResourceId = DataReplicationPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName, policyName); DataReplicationPolicyResource dataReplicationPolicy = client.GetDataReplicationPolicyResource(dataReplicationPolicyResourceId); // invoke the operation - await dataReplicationPolicy.DeleteAsync(WaitUntil.Completed); + DataReplicationPolicyData data = new DataReplicationPolicyData(new DataReplicationPolicyProperties(new GeneralPolicyModelCustomProperties())); + ArmOperation lro = await dataReplicationPolicy.UpdateAsync(WaitUntil.Completed, data); + DataReplicationPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationProtectedItemCollection.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationProtectedItemCollection.cs index 52113b0a8c3b2..118d9d18d1e84 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationProtectedItemCollection.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationProtectedItemCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataReplicationProtectedItemCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProtectedItemGet() + public async Task CreateOrUpdate_ProtectedItemCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Get.json - // this example is just showing the usage of "ProtectedItem_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Create.json + // this example is just showing the usage of "ProtectedItem_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,9 @@ public async Task Get_ProtectedItemGet() // invoke the operation string protectedItemName = "d"; - DataReplicationProtectedItemResource result = await collection.GetAsync(protectedItemName); + DataReplicationProtectedItemData data = new DataReplicationProtectedItemData(new DataReplicationProtectedItemProperties("tjoeiynplt", "jwxdo", new GeneralProtectedItemModelCustomProperties())); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, protectedItemName, data); + DataReplicationProtectedItemResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +54,7 @@ public async Task Get_ProtectedItemGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProtectedItemGet() + public async Task Get_ProtectedItemGet() { // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Get.json // this example is just showing the usage of "ProtectedItem_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +77,21 @@ public async Task Exists_ProtectedItemGet() // invoke the operation string protectedItemName = "d"; - bool result = await collection.ExistsAsync(protectedItemName); + DataReplicationProtectedItemResource result = await collection.GetAsync(protectedItemName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationProtectedItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProtectedItemGet() + public async Task GetAll_ProtectedItemList() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Get.json - // this example is just showing the usage of "ProtectedItem_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_List.json + // this example is just showing the usage of "ProtectedItem_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +109,25 @@ public async Task GetIfExists_ProtectedItemGet() // get the collection of this DataReplicationProtectedItemResource DataReplicationProtectedItemCollection collection = dataReplicationVault.GetDataReplicationProtectedItems(); - // invoke the operation - string protectedItemName = "d"; - NullableResponse response = await collection.GetIfExistsAsync(protectedItemName); - DataReplicationProtectedItemResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataReplicationProtectedItemResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationProtectedItemData resourceData = result.Data; + DataReplicationProtectedItemData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProtectedItemCreate() + public async Task Exists_ProtectedItemGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Create.json - // this example is just showing the usage of "ProtectedItem_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Get.json + // this example is just showing the usage of "ProtectedItem_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,23 +147,17 @@ public async Task CreateOrUpdate_ProtectedItemCreate() // invoke the operation string protectedItemName = "d"; - DataReplicationProtectedItemData data = new DataReplicationProtectedItemData(new DataReplicationProtectedItemProperties("tjoeiynplt", "jwxdo", new GeneralProtectedItemModelCustomProperties())); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, protectedItemName, data); - DataReplicationProtectedItemResource result = lro.Value; + bool result = await collection.ExistsAsync(protectedItemName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationProtectedItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProtectedItemList() + public async Task GetIfExists_ProtectedItemGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_List.json - // this example is just showing the usage of "ProtectedItem_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Get.json + // this example is just showing the usage of "ProtectedItem_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_ProtectedItemList() // get the collection of this DataReplicationProtectedItemResource DataReplicationProtectedItemCollection collection = dataReplicationVault.GetDataReplicationProtectedItems(); - // invoke the operation and iterate over the result - await foreach (DataReplicationProtectedItemResource item in collection.GetAllAsync()) + // invoke the operation + string protectedItemName = "d"; + NullableResponse response = await collection.GetIfExistsAsync(protectedItemName); + DataReplicationProtectedItemResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationProtectedItemData resourceData = item.Data; + DataReplicationProtectedItemData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationProtectedItemResource.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationProtectedItemResource.cs index 7136c4a619ba3..b7a57612d9b44 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationProtectedItemResource.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationProtectedItemResource.cs @@ -49,10 +49,10 @@ public async Task Get_ProtectedItemGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ProtectedItemCreate() + public async Task Delete_ProtectedItemDelete() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Create.json - // this example is just showing the usage of "ProtectedItem_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Delete.json + // this example is just showing the usage of "ProtectedItem_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,23 +69,18 @@ public async Task Update_ProtectedItemCreate() DataReplicationProtectedItemResource dataReplicationProtectedItem = client.GetDataReplicationProtectedItemResource(dataReplicationProtectedItemResourceId); // invoke the operation - DataReplicationProtectedItemData data = new DataReplicationProtectedItemData(new DataReplicationProtectedItemProperties("tjoeiynplt", "jwxdo", new GeneralProtectedItemModelCustomProperties())); - ArmOperation lro = await dataReplicationProtectedItem.UpdateAsync(WaitUntil.Completed, data); - DataReplicationProtectedItemResource result = lro.Value; + bool? forceDelete = true; + await dataReplicationProtectedItem.DeleteAsync(WaitUntil.Completed, forceDelete: forceDelete); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationProtectedItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ProtectedItemDelete() + public async Task Update_ProtectedItemCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Delete.json - // this example is just showing the usage of "ProtectedItem_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ProtectedItem_Create.json + // this example is just showing the usage of "ProtectedItem_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,10 +97,15 @@ public async Task Delete_ProtectedItemDelete() DataReplicationProtectedItemResource dataReplicationProtectedItem = client.GetDataReplicationProtectedItemResource(dataReplicationProtectedItemResourceId); // invoke the operation - bool? forceDelete = true; - await dataReplicationProtectedItem.DeleteAsync(WaitUntil.Completed, forceDelete: forceDelete); + DataReplicationProtectedItemData data = new DataReplicationProtectedItemData(new DataReplicationProtectedItemProperties("tjoeiynplt", "jwxdo", new GeneralProtectedItemModelCustomProperties())); + ArmOperation lro = await dataReplicationProtectedItem.UpdateAsync(WaitUntil.Completed, data); + DataReplicationProtectedItemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationProtectedItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationRecoveryPointCollection.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationRecoveryPointCollection.cs index 3e40a9160ad1f..69679012e99cd 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationRecoveryPointCollection.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationRecoveryPointCollection.cs @@ -52,10 +52,10 @@ public async Task Get_RecoveryPointsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RecoveryPointsGet() + public async Task GetAll_RecoveryPointsList() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/RecoveryPoints_Get.json - // this example is just showing the usage of "RecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/RecoveryPoints_List.json + // this example is just showing the usage of "RecoveryPoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,16 +74,22 @@ public async Task Exists_RecoveryPointsGet() // get the collection of this DataReplicationRecoveryPointResource DataReplicationRecoveryPointCollection collection = dataReplicationProtectedItem.GetDataReplicationRecoveryPoints(); - // invoke the operation - string recoveryPointName = "1X"; - bool result = await collection.ExistsAsync(recoveryPointName); + // invoke the operation and iterate over the result + await foreach (DataReplicationRecoveryPointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationRecoveryPointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RecoveryPointsGet() + public async Task Exists_RecoveryPointsGet() { // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/RecoveryPoints_Get.json // this example is just showing the usage of "RecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +113,17 @@ public async Task GetIfExists_RecoveryPointsGet() // invoke the operation string recoveryPointName = "1X"; - NullableResponse response = await collection.GetIfExistsAsync(recoveryPointName); - DataReplicationRecoveryPointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(recoveryPointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationRecoveryPointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RecoveryPointsList() + public async Task GetIfExists_RecoveryPointsGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/RecoveryPoints_List.json - // this example is just showing the usage of "RecoveryPoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/RecoveryPoints_Get.json + // this example is just showing the usage of "RecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,17 +142,23 @@ public async Task GetAll_RecoveryPointsList() // get the collection of this DataReplicationRecoveryPointResource DataReplicationRecoveryPointCollection collection = dataReplicationProtectedItem.GetDataReplicationRecoveryPoints(); - // invoke the operation and iterate over the result - await foreach (DataReplicationRecoveryPointResource item in collection.GetAllAsync()) + // invoke the operation + string recoveryPointName = "1X"; + NullableResponse response = await collection.GetIfExistsAsync(recoveryPointName); + DataReplicationRecoveryPointResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationRecoveryPointData resourceData = item.Data; + DataReplicationRecoveryPointData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationReplicationExtensionCollection.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationReplicationExtensionCollection.cs index b04307c4c5671..554af6c50cb8c 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationReplicationExtensionCollection.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationReplicationExtensionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataReplicationReplicationExtensionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ReplicationExtensionGet() + public async Task CreateOrUpdate_ReplicationExtensionCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Get.json - // this example is just showing the usage of "ReplicationExtension_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Create.json + // this example is just showing the usage of "ReplicationExtension_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,9 @@ public async Task Get_ReplicationExtensionGet() // invoke the operation string replicationExtensionName = "g16yjJ"; - DataReplicationReplicationExtensionResource result = await collection.GetAsync(replicationExtensionName); + DataReplicationReplicationExtensionData data = new DataReplicationReplicationExtensionData(new DataReplicationReplicationExtensionProperties(new GeneralReplicationExtensionModelCustomProperties())); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, replicationExtensionName, data); + DataReplicationReplicationExtensionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +54,7 @@ public async Task Get_ReplicationExtensionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ReplicationExtensionGet() + public async Task Get_ReplicationExtensionGet() { // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Get.json // this example is just showing the usage of "ReplicationExtension_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +77,21 @@ public async Task Exists_ReplicationExtensionGet() // invoke the operation string replicationExtensionName = "g16yjJ"; - bool result = await collection.ExistsAsync(replicationExtensionName); + DataReplicationReplicationExtensionResource result = await collection.GetAsync(replicationExtensionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationReplicationExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ReplicationExtensionGet() + public async Task GetAll_ReplicationExtensionList() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Get.json - // this example is just showing the usage of "ReplicationExtension_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_List.json + // this example is just showing the usage of "ReplicationExtension_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +109,25 @@ public async Task GetIfExists_ReplicationExtensionGet() // get the collection of this DataReplicationReplicationExtensionResource DataReplicationReplicationExtensionCollection collection = dataReplicationVault.GetDataReplicationReplicationExtensions(); - // invoke the operation - string replicationExtensionName = "g16yjJ"; - NullableResponse response = await collection.GetIfExistsAsync(replicationExtensionName); - DataReplicationReplicationExtensionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataReplicationReplicationExtensionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationReplicationExtensionData resourceData = result.Data; + DataReplicationReplicationExtensionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ReplicationExtensionCreate() + public async Task Exists_ReplicationExtensionGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Create.json - // this example is just showing the usage of "ReplicationExtension_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Get.json + // this example is just showing the usage of "ReplicationExtension_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,23 +147,17 @@ public async Task CreateOrUpdate_ReplicationExtensionCreate() // invoke the operation string replicationExtensionName = "g16yjJ"; - DataReplicationReplicationExtensionData data = new DataReplicationReplicationExtensionData(new DataReplicationReplicationExtensionProperties(new GeneralReplicationExtensionModelCustomProperties())); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, replicationExtensionName, data); - DataReplicationReplicationExtensionResource result = lro.Value; + bool result = await collection.ExistsAsync(replicationExtensionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationReplicationExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ReplicationExtensionList() + public async Task GetIfExists_ReplicationExtensionGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_List.json - // this example is just showing the usage of "ReplicationExtension_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Get.json + // this example is just showing the usage of "ReplicationExtension_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_ReplicationExtensionList() // get the collection of this DataReplicationReplicationExtensionResource DataReplicationReplicationExtensionCollection collection = dataReplicationVault.GetDataReplicationReplicationExtensions(); - // invoke the operation and iterate over the result - await foreach (DataReplicationReplicationExtensionResource item in collection.GetAllAsync()) + // invoke the operation + string replicationExtensionName = "g16yjJ"; + NullableResponse response = await collection.GetIfExistsAsync(replicationExtensionName); + DataReplicationReplicationExtensionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationReplicationExtensionData resourceData = item.Data; + DataReplicationReplicationExtensionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationReplicationExtensionResource.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationReplicationExtensionResource.cs index 79f2b3dee3bed..69b9f5ea6d978 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationReplicationExtensionResource.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationReplicationExtensionResource.cs @@ -49,10 +49,10 @@ public async Task Get_ReplicationExtensionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ReplicationExtensionCreate() + public async Task Delete_ReplicationExtensionDelete() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Create.json - // this example is just showing the usage of "ReplicationExtension_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Delete.json + // this example is just showing the usage of "ReplicationExtension_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,23 +69,17 @@ public async Task Update_ReplicationExtensionCreate() DataReplicationReplicationExtensionResource dataReplicationReplicationExtension = client.GetDataReplicationReplicationExtensionResource(dataReplicationReplicationExtensionResourceId); // invoke the operation - DataReplicationReplicationExtensionData data = new DataReplicationReplicationExtensionData(new DataReplicationReplicationExtensionProperties(new GeneralReplicationExtensionModelCustomProperties())); - ArmOperation lro = await dataReplicationReplicationExtension.UpdateAsync(WaitUntil.Completed, data); - DataReplicationReplicationExtensionResource result = lro.Value; + await dataReplicationReplicationExtension.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationReplicationExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ReplicationExtensionDelete() + public async Task Update_ReplicationExtensionCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Delete.json - // this example is just showing the usage of "ReplicationExtension_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/ReplicationExtension_Create.json + // this example is just showing the usage of "ReplicationExtension_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_ReplicationExtensionDelete() DataReplicationReplicationExtensionResource dataReplicationReplicationExtension = client.GetDataReplicationReplicationExtensionResource(dataReplicationReplicationExtensionResourceId); // invoke the operation - await dataReplicationReplicationExtension.DeleteAsync(WaitUntil.Completed); + DataReplicationReplicationExtensionData data = new DataReplicationReplicationExtensionData(new DataReplicationReplicationExtensionProperties(new GeneralReplicationExtensionModelCustomProperties())); + ArmOperation lro = await dataReplicationReplicationExtension.UpdateAsync(WaitUntil.Completed, data); + DataReplicationReplicationExtensionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationReplicationExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationVaultCollection.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationVaultCollection.cs index 315f9c44d173d..b95f2434ecb96 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationVaultCollection.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationVaultCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DataReplicationVaultCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VaultGet() + public async Task CreateOrUpdate_VaultCreate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Get.json - // this example is just showing the usage of "Vault_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Create.json + // this example is just showing the usage of "Vault_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,19 @@ public async Task Get_VaultGet() // invoke the operation string vaultName = "4"; - DataReplicationVaultResource result = await collection.GetAsync(vaultName); + DataReplicationVaultData data = new DataReplicationVaultData(new AzureLocation("eck")) + { + Properties = new DataReplicationVaultProperties + { + VaultType = DataReplicationReplicationVaultType.DisasterRecovery, + }, + Tags = +{ +["key5359"] = "ljfilxolxzuxrauopwtyxghrp" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); + DataReplicationVaultResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +64,7 @@ public async Task Get_VaultGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VaultGet() + public async Task Get_VaultGet() { // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Get.json // this example is just showing the usage of "Vault_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +86,21 @@ public async Task Exists_VaultGet() // invoke the operation string vaultName = "4"; - bool result = await collection.ExistsAsync(vaultName); + DataReplicationVaultResource result = await collection.GetAsync(vaultName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationVaultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VaultGet() + public async Task GetAll_VaultList() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Get.json - // this example is just showing the usage of "Vault_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_List.json + // this example is just showing the usage of "Vault_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +117,26 @@ public async Task GetIfExists_VaultGet() // get the collection of this DataReplicationVaultResource DataReplicationVaultCollection collection = resourceGroupResource.GetDataReplicationVaults(); - // invoke the operation - string vaultName = "4"; - NullableResponse response = await collection.GetIfExistsAsync(vaultName); - DataReplicationVaultResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string continuationToken = "mwculdaqndp"; + await foreach (DataReplicationVaultResource item in collection.GetAllAsync(continuationToken: continuationToken)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationVaultData resourceData = result.Data; + DataReplicationVaultData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VaultCreate() + public async Task Exists_VaultGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Create.json - // this example is just showing the usage of "Vault_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Get.json + // this example is just showing the usage of "Vault_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,33 +155,17 @@ public async Task CreateOrUpdate_VaultCreate() // invoke the operation string vaultName = "4"; - DataReplicationVaultData data = new DataReplicationVaultData(new AzureLocation("eck")) - { - Properties = new DataReplicationVaultProperties() - { - VaultType = DataReplicationReplicationVaultType.DisasterRecovery, - }, - Tags = -{ -["key5359"] = "ljfilxolxzuxrauopwtyxghrp", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); - DataReplicationVaultResource result = lro.Value; + bool result = await collection.ExistsAsync(vaultName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationVaultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VaultList() + public async Task GetIfExists_VaultGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_List.json - // this example is just showing the usage of "Vault_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Get.json + // this example is just showing the usage of "Vault_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +182,23 @@ public async Task GetAll_VaultList() // get the collection of this DataReplicationVaultResource DataReplicationVaultCollection collection = resourceGroupResource.GetDataReplicationVaults(); - // invoke the operation and iterate over the result - string continuationToken = "mwculdaqndp"; - await foreach (DataReplicationVaultResource item in collection.GetAllAsync(continuationToken: continuationToken)) + // invoke the operation + string vaultName = "4"; + NullableResponse response = await collection.GetIfExistsAsync(vaultName); + DataReplicationVaultResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationVaultData resourceData = item.Data; + DataReplicationVaultData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationVaultResource.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationVaultResource.cs index 693568bfd0a93..dc15ad274f34a 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationVaultResource.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationVaultResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesDataReplication.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesDataReplication.Samples @@ -49,10 +48,10 @@ public async Task Get_VaultGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VaultUpdate() + public async Task Delete_VaultDelete() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Update.json - // this example is just showing the usage of "Vault_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Delete.json + // this example is just showing the usage of "Vault_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,33 +67,17 @@ public async Task Update_VaultUpdate() DataReplicationVaultResource dataReplicationVault = client.GetDataReplicationVaultResource(dataReplicationVaultResourceId); // invoke the operation - DataReplicationVaultPatch patch = new DataReplicationVaultPatch() - { - Tags = -{ -["key8872"] = "pvtc", -}, - Properties = new DataReplicationVaultProperties() - { - VaultType = DataReplicationReplicationVaultType.DisasterRecovery, - }, - }; - ArmOperation lro = await dataReplicationVault.UpdateAsync(WaitUntil.Completed, patch); - DataReplicationVaultResource result = lro.Value; + await dataReplicationVault.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationVaultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VaultDelete() + public async Task Update_VaultUpdate() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Delete.json - // this example is just showing the usage of "Vault_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_Update.json + // this example is just showing the usage of "Vault_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,41 +93,25 @@ public async Task Delete_VaultDelete() DataReplicationVaultResource dataReplicationVault = client.GetDataReplicationVaultResource(dataReplicationVaultResourceId); // invoke the operation - await dataReplicationVault.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDataReplicationVaults_VaultListBySubscription() - { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_ListBySubscription.json - // this example is just showing the usage of "Vault_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "930CEC23-4430-4513-B855-DBA237E2F3BF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string continuationToken = "dqsjhseyugyexxrlrln"; - await foreach (DataReplicationVaultResource item in subscriptionResource.GetDataReplicationVaultsAsync(continuationToken: continuationToken)) + DataReplicationVaultPatch patch = new DataReplicationVaultPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationVaultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key8872"] = "pvtc" +}, + Properties = new DataReplicationVaultProperties + { + VaultType = DataReplicationReplicationVaultType.DisasterRecovery, + }, + }; + ArmOperation lro = await dataReplicationVault.UpdateAsync(WaitUntil.Completed, patch); + DataReplicationVaultResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationVaultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationWorkflowCollection.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationWorkflowCollection.cs index e318100c14e57..1d84f9b8458e6 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationWorkflowCollection.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_DataReplicationWorkflowCollection.cs @@ -51,10 +51,10 @@ public async Task Get_WorkflowGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkflowGet() + public async Task GetAll_WorkflowList() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Workflow_Get.json - // this example is just showing the usage of "Workflow_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Workflow_List.json + // this example is just showing the usage of "Workflow_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,24 @@ public async Task Exists_WorkflowGet() // get the collection of this DataReplicationWorkflowResource DataReplicationWorkflowCollection collection = dataReplicationVault.GetDataReplicationWorkflows(); - // invoke the operation - string jobName = "ZGH4y"; - bool result = await collection.ExistsAsync(jobName); + // invoke the operation and iterate over the result + string filter = "mnebpgmjcitjleipnttx"; + string continuationToken = "rdavrzbethhslmkqgajontnxsue"; + await foreach (DataReplicationWorkflowResource item in collection.GetAllAsync(filter: filter, continuationToken: continuationToken)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationWorkflowData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkflowGet() + public async Task Exists_WorkflowGet() { // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Workflow_Get.json // this example is just showing the usage of "Workflow_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +112,17 @@ public async Task GetIfExists_WorkflowGet() // invoke the operation string jobName = "ZGH4y"; - NullableResponse response = await collection.GetIfExistsAsync(jobName); - DataReplicationWorkflowResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(jobName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataReplicationWorkflowData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkflowList() + public async Task GetIfExists_WorkflowGet() { - // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Workflow_List.json - // this example is just showing the usage of "Workflow_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Workflow_Get.json + // this example is just showing the usage of "Workflow_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,19 +140,23 @@ public async Task GetAll_WorkflowList() // get the collection of this DataReplicationWorkflowResource DataReplicationWorkflowCollection collection = dataReplicationVault.GetDataReplicationWorkflows(); - // invoke the operation and iterate over the result - string filter = "mnebpgmjcitjleipnttx"; - string continuationToken = "rdavrzbethhslmkqgajontnxsue"; - await foreach (DataReplicationWorkflowResource item in collection.GetAllAsync(filter: filter, continuationToken: continuationToken)) + // invoke the operation + string jobName = "ZGH4y"; + NullableResponse response = await collection.GetIfExistsAsync(jobName); + DataReplicationWorkflowResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataReplicationWorkflowData resourceData = item.Data; + DataReplicationWorkflowData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index d33309cca1392..9afdb84873c34 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -38,18 +38,15 @@ public async Task DeploymentPreflight_DeploymentPreflight() // invoke the operation string deploymentId = "kjoiahxljomjcmvabaobumg"; - DeploymentPreflightModel body = new DeploymentPreflightModel() + DeploymentPreflightModel body = new DeploymentPreflightModel { - Resources = -{ -new DeploymentPreflightResourceInfo() + Resources = {new DeploymentPreflightResourceInfo { Name = "xtgugoflfc", DeploymentPreflightResourceType = new ResourceType("nsnaptduolqcxsikrewvgjbxqpt"), Location = new AzureLocation("cbsgtxkjdzwbyp"), ApiVersion = "otihymhvzblycdoxo", -} -}, +}}, }; DeploymentPreflightModel result = await resourceGroupResource.DeploymentPreflightAsync(deploymentId, body: body); diff --git a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index a0091b1456841..3b4ef6270194e 100644 --- a/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/recoveryservices-datareplication/Azure.ResourceManager.RecoveryServicesDataReplication/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,38 @@ namespace Azure.ResourceManager.RecoveryServicesDataReplication.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataReplicationFabrics_FabricListBySubscription() + { + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Fabric_ListBySubscription.json + // this example is just showing the usage of "Fabric_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "930CEC23-4430-4513-B855-DBA237E2F3BF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string continuationToken = "rmgqrpzucsizbyjscxzockbiyg"; + await foreach (DataReplicationFabricResource item in subscriptionResource.GetDataReplicationFabricsAsync(continuationToken: continuationToken)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationFabricData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CheckDataReplicationNameAvailability_CheckNameAvailability() @@ -37,7 +69,7 @@ public async Task CheckDataReplicationNameAvailability_CheckNameAvailability() // invoke the operation AzureLocation location = new AzureLocation("trfqtbtmusswpibw"); - DataReplicationNameAvailabilityContent content = new DataReplicationNameAvailabilityContent() + DataReplicationNameAvailabilityContent content = new DataReplicationNameAvailabilityContent { Name = "updkdcixs", ResourceType = new ResourceType("gngmcancdauwhdixjjvqnfkvqc"), @@ -46,5 +78,37 @@ public async Task CheckDataReplicationNameAvailability_CheckNameAvailability() Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataReplicationVaults_VaultListBySubscription() + { + // Generated from example definition: specification/recoveryservicesdatareplication/resource-manager/Microsoft.DataReplication/preview/2021-02-16-preview/examples/Vault_ListBySubscription.json + // this example is just showing the usage of "Vault_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "930CEC23-4430-4513-B855-DBA237E2F3BF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string continuationToken = "dqsjhseyugyexxrlrln"; + await foreach (DataReplicationVaultResource item in subscriptionResource.GetDataReplicationVaultsAsync(continuationToken: continuationToken)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataReplicationVaultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_MigrationRecoveryPointCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_MigrationRecoveryPointCollection.cs index 66135de4c734d..15a6f89435564 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_MigrationRecoveryPointCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_MigrationRecoveryPointCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MigrationRecoveryPointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheRecoveryPointsForAMigrationItem() + public async Task Get_GetsARecoveryPointForAMigrationItem() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/MigrationRecoveryPoints_ListByReplicationMigrationItems.json - // this example is just showing the usage of "MigrationRecoveryPoints_ListByReplicationMigrationItems" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/MigrationRecoveryPoints_Get.json + // this example is just showing the usage of "MigrationRecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_GetsTheRecoveryPointsForAMigrationItem() // get the collection of this MigrationRecoveryPointResource MigrationRecoveryPointCollection collection = siteRecoveryMigrationItem.GetMigrationRecoveryPoints(); - // invoke the operation and iterate over the result - await foreach (MigrationRecoveryPointResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MigrationRecoveryPointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string migrationRecoveryPointName = "b22134ea-620c-474b-9fa5-3c1cb47708e3"; + MigrationRecoveryPointResource result = await collection.GetAsync(migrationRecoveryPointName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MigrationRecoveryPointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsARecoveryPointForAMigrationItem() + public async Task GetAll_GetsTheRecoveryPointsForAMigrationItem() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/MigrationRecoveryPoints_Get.json - // this example is just showing the usage of "MigrationRecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/MigrationRecoveryPoints_ListByReplicationMigrationItems.json + // this example is just showing the usage of "MigrationRecoveryPoints_ListByReplicationMigrationItems" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +78,17 @@ public async Task Get_GetsARecoveryPointForAMigrationItem() // get the collection of this MigrationRecoveryPointResource MigrationRecoveryPointCollection collection = siteRecoveryMigrationItem.GetMigrationRecoveryPoints(); - // invoke the operation - string migrationRecoveryPointName = "b22134ea-620c-474b-9fa5-3c1cb47708e3"; - MigrationRecoveryPointResource result = await collection.GetAsync(migrationRecoveryPointName); + // invoke the operation and iterate over the result + await foreach (MigrationRecoveryPointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MigrationRecoveryPointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MigrationRecoveryPointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ProtectionContainerMappingCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ProtectionContainerMappingCollection.cs index 4ca3df28c54e1..946e7223a407e 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ProtectionContainerMappingCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ProtectionContainerMappingCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ProtectionContainerMappingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfProtectionContainerMappingsForAProtectionContainer() + public async Task Get_GetsAProtectionContainerMapping() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainerMappings_ListByReplicationProtectionContainers.json - // this example is just showing the usage of "ReplicationProtectionContainerMappings_ListByReplicationProtectionContainers" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainerMappings_Get.json + // this example is just showing the usage of "ReplicationProtectionContainerMappings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_GetsTheListOfProtectionContainerMappingsForAProtectionC // get the collection of this ProtectionContainerMappingResource ProtectionContainerMappingCollection collection = siteRecoveryProtectionContainer.GetProtectionContainerMappings(); - // invoke the operation and iterate over the result - await foreach (ProtectionContainerMappingResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProtectionContainerMappingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string mappingName = "cloud1protectionprofile1"; + ProtectionContainerMappingResource result = await collection.GetAsync(mappingName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProtectionContainerMappingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAProtectionContainerMapping() + public async Task GetAll_GetsTheListOfProtectionContainerMappingsForAProtectionContainer() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainerMappings_Get.json - // this example is just showing the usage of "ReplicationProtectionContainerMappings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainerMappings_ListByReplicationProtectionContainers.json + // this example is just showing the usage of "ReplicationProtectionContainerMappings_ListByReplicationProtectionContainers" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetsAProtectionContainerMapping() // get the collection of this ProtectionContainerMappingResource ProtectionContainerMappingCollection collection = siteRecoveryProtectionContainer.GetProtectionContainerMappings(); - // invoke the operation - string mappingName = "cloud1protectionprofile1"; - ProtectionContainerMappingResource result = await collection.GetAsync(mappingName); + // invoke the operation and iterate over the result + await foreach (ProtectionContainerMappingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProtectionContainerMappingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProtectionContainerMappingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ProtectionContainerMappingResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ProtectionContainerMappingResource.cs index 9da517c954e44..1506a350acd5d 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ProtectionContainerMappingResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ProtectionContainerMappingResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesSiteRecovery.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Samples @@ -103,9 +102,9 @@ public async Task Update_UpdateProtectionContainerMapping() ProtectionContainerMappingResource protectionContainerMapping = client.GetProtectionContainerMappingResource(protectionContainerMappingResourceId); // invoke the operation - ProtectionContainerMappingPatch patch = new ProtectionContainerMappingPatch() + ProtectionContainerMappingPatch patch = new ProtectionContainerMappingPatch { - ProviderSpecificContent = new A2AUpdateContainerMappingContent() + ProviderSpecificContent = new A2AUpdateContainerMappingContent { AgentAutoUpdateStatus = SiteRecoveryAgentAutoUpdateStatus.Enabled, AutomationAccountArmId = new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/automationrg1/providers/Microsoft.Automation/automationAccounts/automationaccount1"), @@ -150,38 +149,5 @@ public async Task Delete_RemoveProtectionContainerMapping() Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetProtectionContainerMappings_GetsTheListOfAllProtectionContainerMappingsInAVault() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainerMappings_List.json - // this example is just showing the usage of "ReplicationProtectionContainerMappings_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "c183865e-6077-46f2-a3b1-deb0f4f4650a"; - string resourceGroupName = "resourceGroupPS1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - string resourceName = "vault1"; - await foreach (ProtectionContainerMappingResource item in resourceGroupResource.GetProtectionContainerMappingsAsync(resourceName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProtectionContainerMappingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationEligibilityResultCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationEligibilityResultCollection.cs index ecc752facd344..e3a585b1305fd 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationEligibilityResultCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationEligibilityResultCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ReplicationEligibilityResultCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheValidationErrorsInCaseTheVMIsUnsuitableForProtection() + public async Task Get_GetsTheValidationErrorsInCaseTheVMIsUnsuitableForProtection() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationEligibilityResults_List.json - // this example is just showing the usage of "ReplicationEligibilityResults_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationEligibilityResults_Get.json + // this example is just showing the usage of "ReplicationEligibilityResults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,28 +36,25 @@ public async Task GetAll_GetsTheValidationErrorsInCaseTheVMIsUnsuitableForProtec ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this ReplicationEligibilityResultResource - string virtualMachineName = "testVm2"; + string virtualMachineName = "testVm1"; ReplicationEligibilityResultCollection collection = resourceGroupResource.GetReplicationEligibilityResults(virtualMachineName); - // invoke the operation and iterate over the result - await foreach (ReplicationEligibilityResultResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReplicationEligibilityResultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + ReplicationEligibilityResultResource result = await collection.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReplicationEligibilityResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheValidationErrorsInCaseTheVMIsUnsuitableForProtection() + public async Task GetAll_GetsTheValidationErrorsInCaseTheVMIsUnsuitableForProtection() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationEligibilityResults_Get.json - // this example is just showing the usage of "ReplicationEligibilityResults_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationEligibilityResults_List.json + // this example is just showing the usage of "ReplicationEligibilityResults_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,17 +69,20 @@ public async Task Get_GetsTheValidationErrorsInCaseTheVMIsUnsuitableForProtectio ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this ReplicationEligibilityResultResource - string virtualMachineName = "testVm1"; + string virtualMachineName = "testVm2"; ReplicationEligibilityResultCollection collection = resourceGroupResource.GetReplicationEligibilityResults(virtualMachineName); - // invoke the operation - ReplicationEligibilityResultResource result = await collection.GetAsync(); + // invoke the operation and iterate over the result + await foreach (ReplicationEligibilityResultResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReplicationEligibilityResultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReplicationEligibilityResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectedItemCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectedItemCollection.cs index 5524016588296..a87f31eee7354 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectedItemCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectedItemCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ReplicationProtectedItemCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfReplicationProtectedItems() + public async Task CreateOrUpdate_EnablesProtection() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectedItems_ListByReplicationProtectionContainers.json - // this example is just showing the usage of "ReplicationProtectedItems_ListByReplicationProtectionContainers" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectedItems_Create.json + // this example is just showing the usage of "ReplicationProtectedItems_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,25 @@ public async Task GetAll_GetsTheListOfReplicationProtectedItems() // get the collection of this ReplicationProtectedItemResource ReplicationProtectedItemCollection collection = siteRecoveryProtectionContainer.GetReplicationProtectedItems(); - // invoke the operation and iterate over the result - await foreach (ReplicationProtectedItemResource item in collection.GetAllAsync()) + // invoke the operation + string replicatedProtectedItemName = "f8491e4f-817a-40dd-a90c-af773978c75b"; + ReplicationProtectedItemCreateOrUpdateContent content = new ReplicationProtectedItemCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReplicationProtectedItemData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new EnableProtectionProperties + { + PolicyId = new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationPolicies/protectionprofile1"), + ProtectableItemId = new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/cloud1/replicationProtectionContainers/cloud_6d224fc6-f326-5d35-96de-fbf51efb3179/replicationProtectableItems/f8491e4f-817a-40dd-a90c-af773978c75b"), + ProviderSpecificDetails = new HyperVReplicaAzureEnableProtectionContent(), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, replicatedProtectedItemName, content); + ReplicationProtectedItemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReplicationProtectedItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +100,10 @@ public async Task Get_GetsTheDetailsOfAReplicationProtectedItem() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheDetailsOfAReplicationProtectedItem() + public async Task GetAll_GetsTheListOfReplicationProtectedItems() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectedItems_Get.json - // this example is just showing the usage of "ReplicationProtectedItems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectedItems_ListByReplicationProtectionContainers.json + // this example is just showing the usage of "ReplicationProtectedItems_ListByReplicationProtectionContainers" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +123,22 @@ public async Task Exists_GetsTheDetailsOfAReplicationProtectedItem() // get the collection of this ReplicationProtectedItemResource ReplicationProtectedItemCollection collection = siteRecoveryProtectionContainer.GetReplicationProtectedItems(); - // invoke the operation - string replicatedProtectedItemName = "f8491e4f-817a-40dd-a90c-af773978c75b"; - bool result = await collection.ExistsAsync(replicatedProtectedItemName); + // invoke the operation and iterate over the result + await foreach (ReplicationProtectedItemResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReplicationProtectedItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheDetailsOfAReplicationProtectedItem() + public async Task Exists_GetsTheDetailsOfAReplicationProtectedItem() { // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectedItems_Get.json // this example is just showing the usage of "ReplicationProtectedItems_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +163,17 @@ public async Task GetIfExists_GetsTheDetailsOfAReplicationProtectedItem() // invoke the operation string replicatedProtectedItemName = "f8491e4f-817a-40dd-a90c-af773978c75b"; - NullableResponse response = await collection.GetIfExistsAsync(replicatedProtectedItemName); - ReplicationProtectedItemResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(replicatedProtectedItemName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReplicationProtectedItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EnablesProtection() + public async Task GetIfExists_GetsTheDetailsOfAReplicationProtectedItem() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectedItems_Create.json - // this example is just showing the usage of "ReplicationProtectedItems_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectedItems_Get.json + // this example is just showing the usage of "ReplicationProtectedItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,23 +195,21 @@ public async Task CreateOrUpdate_EnablesProtection() // invoke the operation string replicatedProtectedItemName = "f8491e4f-817a-40dd-a90c-af773978c75b"; - ReplicationProtectedItemCreateOrUpdateContent content = new ReplicationProtectedItemCreateOrUpdateContent() - { - Properties = new EnableProtectionProperties() - { - PolicyId = new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationPolicies/protectionprofile1"), - ProtectableItemId = new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/cloud1/replicationProtectionContainers/cloud_6d224fc6-f326-5d35-96de-fbf51efb3179/replicationProtectableItems/f8491e4f-817a-40dd-a90c-af773978c75b"), - ProviderSpecificDetails = new HyperVReplicaAzureEnableProtectionContent(), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, replicatedProtectedItemName, content); - ReplicationProtectedItemResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(replicatedProtectedItemName); + ReplicationProtectedItemResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReplicationProtectedItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReplicationProtectedItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectedItemResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectedItemResource.cs index 0254adc8e120c..79d0cc0546ae8 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectedItemResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectedItemResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesSiteRecovery.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Samples @@ -104,31 +103,25 @@ public async Task Update_UpdatesTheReplicationProtectedItemSettings() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - ReplicationProtectedItemPatch patch = new ReplicationProtectedItemPatch() + ReplicationProtectedItemPatch patch = new ReplicationProtectedItemPatch { - Properties = new UpdateReplicationProtectedItemProperties() + Properties = new UpdateReplicationProtectedItemProperties { RecoveryAzureVmName = "vm1", RecoveryAzureVmSize = "Basic_A0", SelectedRecoveryAzureNetworkId = new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/siterecoveryProd1/providers/Microsoft.Network/virtualNetworks/vnetavrai"), - VmNics = -{ -new VmNicContentDetails() + VmNics = {new VmNicContentDetails { NicId = "TWljcm9zb2Z0OkY4NDkxRTRGLTgxN0EtNDBERC1BOTBDLUFGNzczOTc4Qzc1Qlw3NjAwMzMxRS03NDk4LTQ0QTQtQjdDNy0xQjY1NkJDREQ1MkQ=", -IPConfigs = -{ -new HyperVFailoverIPConfigDetails() +IPConfigs = {new HyperVFailoverIPConfigDetails { IPConfigName = "ipconfig1", IsPrimary = true, RecoverySubnetName = "subnet1", RecoveryStaticIPAddress = IPAddress.Parse("10.0.2.46"), -} -}, +}}, SelectionType = "SelectedByUser", -} -}, +}}, LicenseType = SiteRecoveryLicenseType.WindowsServer, ProviderSpecificDetails = new HyperVReplicaAzureUpdateReplicationProtectedItemContent(), }, @@ -167,14 +160,11 @@ public async Task AddDisks_AddDiskSForProtection() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - SiteRecoveryAddDisksContent content = new SiteRecoveryAddDisksContent() + SiteRecoveryAddDisksContent content = new SiteRecoveryAddDisksContent { - SiteRecoveryAddDisksProviderSpecificDetails = new A2AAddDisksContent() + SiteRecoveryAddDisksProviderSpecificDetails = new A2AAddDisksContent { - VmDisks = -{ -new A2AVmDiskDetails(new Uri("https://vmstorage.blob.core.windows.net/vhds/datadisk1.vhd"),new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourcegroups/recoveryResource/providers/Microsoft.Storage/storageAccounts/recoverystorage"),new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourcegroups/primaryResource/providers/Microsoft.Storage/storageAccounts/vmcachestorage")) -}, + VmDisks = { new A2AVmDiskDetails(new Uri("https://vmstorage.blob.core.windows.net/vhds/datadisk1.vhd"), new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourcegroups/recoveryResource/providers/Microsoft.Storage/storageAccounts/recoverystorage"), new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourcegroups/primaryResource/providers/Microsoft.Storage/storageAccounts/vmcachestorage")) }, }, }; ArmOperation lro = await replicationProtectedItem.AddDisksAsync(WaitUntil.Completed, content); @@ -317,9 +307,9 @@ public async Task PlannedFailover_ExecutePlannedFailover() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - PlannedFailoverContent content = new PlannedFailoverContent() + PlannedFailoverContent content = new PlannedFailoverContent { - Properties = new PlannedFailoverProperties() + Properties = new PlannedFailoverProperties { FailoverDirection = "PrimaryToRecovery", ProviderSpecificDetails = new HyperVReplicaAzurePlannedFailoverProviderContent(), @@ -359,14 +349,11 @@ public async Task RemoveDisks_RemovesDiskS() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - RemoveDisksContent content = new RemoveDisksContent() + RemoveDisksContent content = new RemoveDisksContent { - RemoveDisksContentProviderSpecificDetails = new A2ARemoveDisksContent() + RemoveDisksContentProviderSpecificDetails = new A2ARemoveDisksContent { - VmDisksUris = -{ -new Uri("https://vmstorage.blob.core.windows.net/vhds/datadisk1.vhd") -}, + VmDisksUris = { new Uri("https://vmstorage.blob.core.windows.net/vhds/datadisk1.vhd") }, }, }; ArmOperation lro = await replicationProtectedItem.RemoveDisksAsync(WaitUntil.Completed, content); @@ -437,9 +424,9 @@ public async Task Reprotect_ExecuteReverseReplicationReprotect() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - ReverseReplicationContent content = new ReverseReplicationContent() + ReverseReplicationContent content = new ReverseReplicationContent { - Properties = new ReverseReplicationProperties() + Properties = new ReverseReplicationProperties { FailoverDirection = "PrimaryToRecovery", ProviderSpecificDetails = new HyperVReplicaAzureReprotectContent(), @@ -479,15 +466,12 @@ public async Task ResolveHealthErrors_ResolveHealthErrors() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - ResolveHealthContent content = new ResolveHealthContent() + ResolveHealthContent content = new ResolveHealthContent { - ResolveHealthErrors = -{ -new ResolveHealthError() + ResolveHealthErrors = {new ResolveHealthError { HealthErrorId = "3:8020", -} -}, +}}, }; ArmOperation lro = await replicationProtectedItem.ResolveHealthErrorsAsync(WaitUntil.Completed, content); ReplicationProtectedItemResource result = lro.Value; @@ -523,9 +507,9 @@ public async Task SwitchProvider_ExecuteSwitchProvider() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - SwitchProviderContent content = new SwitchProviderContent() + SwitchProviderContent content = new SwitchProviderContent { - Properties = new SwitchProviderProperties() + Properties = new SwitchProviderProperties { TargetInstanceType = "InMageRcm", ProviderSpecificDetails = new InMageAzureV2SwitchProviderContent(new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault2"), new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/cloud2"), "5efaa202-e958-435e-8171-706bf735fcc4"), @@ -565,7 +549,7 @@ public async Task TestFailover_ExecuteTestFailover() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - TestFailoverContent content = new TestFailoverContent(new TestFailoverProperties() + TestFailoverContent content = new TestFailoverContent(new TestFailoverProperties { FailoverDirection = "PrimaryToRecovery", NetworkType = "VmNetworkAsInput", @@ -606,7 +590,7 @@ public async Task TestFailoverCleanup_ExecuteTestFailoverCleanup() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - TestFailoverCleanupContent content = new TestFailoverCleanupContent(new TestFailoverCleanupProperties() + TestFailoverCleanupContent content = new TestFailoverCleanupContent(new TestFailoverCleanupProperties { Comments = "Test Failover Cleanup", }); @@ -644,7 +628,7 @@ public async Task UnplannedFailover_ExecuteUnplannedFailover() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - UnplannedFailoverContent content = new UnplannedFailoverContent(new UnplannedFailoverProperties() + UnplannedFailoverContent content = new UnplannedFailoverContent(new UnplannedFailoverProperties { FailoverDirection = "PrimaryToRecovery", SourceSiteOperations = "NotRequired", @@ -684,7 +668,7 @@ public async Task UpdateAppliance_UpdatesApplianceForReplicationProtectedItem() ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - UpdateApplianceForReplicationProtectedItemContent content = new UpdateApplianceForReplicationProtectedItemContent(new UpdateApplianceForReplicationProtectedItemProperties("", new InMageRcmUpdateApplianceForReplicationProtectedItemContent() + UpdateApplianceForReplicationProtectedItemContent content = new UpdateApplianceForReplicationProtectedItemContent(new UpdateApplianceForReplicationProtectedItemProperties("", new InMageRcmUpdateApplianceForReplicationProtectedItemContent { RunAsAccountId = "", })); @@ -722,7 +706,7 @@ public async Task UpdateMobilityService_UpdateTheMobilityServiceOnAProtectedItem ReplicationProtectedItemResource replicationProtectedItem = client.GetReplicationProtectedItemResource(replicationProtectedItemResourceId); // invoke the operation - UpdateMobilityServiceContent content = new UpdateMobilityServiceContent() + UpdateMobilityServiceContent content = new UpdateMobilityServiceContent { UpdateMobilityServiceRequestRunAsAccountId = "2", }; @@ -736,39 +720,6 @@ public async Task UpdateMobilityService_UpdateTheMobilityServiceOnAProtectedItem Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetReplicationProtectedItems_GetsTheListOfReplicationProtectedItems() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectedItems_List.json - // this example is just showing the usage of "ReplicationProtectedItems_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "c183865e-6077-46f2-a3b1-deb0f4f4650a"; - string resourceGroupName = "resourceGroupPS1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - string resourceName = "vault1"; - await foreach (ReplicationProtectedItemResource item in resourceGroupResource.GetReplicationProtectedItemsAsync(resourceName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReplicationProtectedItemData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetTargetComputeSizesByReplicationProtectedItems_GetsTheListOfTargetComputeSizesForTheReplicationProtectedItem() diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectionIntentCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectionIntentCollection.cs index cec500ab44b31..44122877793f9 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectionIntentCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectionIntentCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ReplicationProtectionIntentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfReplicationProtectionIntentObjects() + public async Task CreateOrUpdate_CreateProtectionIntentResource() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionIntents_List.json - // this example is just showing the usage of "ReplicationProtectionIntents_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionIntents_Create.json + // this example is just showing the usage of "ReplicationProtectionIntents_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,20 +37,29 @@ public async Task GetAll_GetsTheListOfReplicationProtectionIntentObjects() ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this ReplicationProtectionIntentResource - string resourceName = "2007vttp"; + string resourceName = "vault1"; ReplicationProtectionIntentCollection collection = resourceGroupResource.GetReplicationProtectionIntents(resourceName); - // invoke the operation and iterate over the result - await foreach (ReplicationProtectionIntentResource item in collection.GetAllAsync()) + // invoke the operation + string intentObjectName = "vm1"; + ReplicationProtectionIntentCreateOrUpdateContent content = new ReplicationProtectionIntentCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReplicationProtectionIntentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SiteRecoveryCreateProtectionIntentProviderSpecificDetails = new A2ACreateProtectionIntentContent( + new ResourceIdentifier("/subscriptions/509099b2-9d2c-4636-b43e-bd5cafb6be69/resourceGroups/removeOne/providers/Microsoft.Compute/virtualMachines/vmPpgAv5"), + new AzureLocation("eastUs2"), + new AzureLocation("westus2"), + "ed5bcdf6-d61e-47bd-8ea9-f2bd379a2640", + A2ARecoveryAvailabilityType.Single, + new ResourceIdentifier("/subscriptions/509099b2-9d2c-4636-b43e-bd5cafb6be69/resourceGroups/removeOne-asr")), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, intentObjectName, content); + ReplicationProtectionIntentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReplicationProtectionIntentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +98,10 @@ public async Task Get_GetsTheDetailsOfAReplicationProtectionIntentItem() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheDetailsOfAReplicationProtectionIntentItem() + public async Task GetAll_GetsTheListOfReplicationProtectionIntentObjects() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionIntents_Get.json - // this example is just showing the usage of "ReplicationProtectionIntents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionIntents_List.json + // this example is just showing the usage of "ReplicationProtectionIntents_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,19 +116,25 @@ public async Task Exists_GetsTheDetailsOfAReplicationProtectionIntentItem() ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this ReplicationProtectionIntentResource - string resourceName = "vault1"; + string resourceName = "2007vttp"; ReplicationProtectionIntentCollection collection = resourceGroupResource.GetReplicationProtectionIntents(resourceName); - // invoke the operation - string intentObjectName = "vm1"; - bool result = await collection.ExistsAsync(intentObjectName); + // invoke the operation and iterate over the result + await foreach (ReplicationProtectionIntentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReplicationProtectionIntentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheDetailsOfAReplicationProtectionIntentItem() + public async Task Exists_GetsTheDetailsOfAReplicationProtectionIntentItem() { // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionIntents_Get.json // this example is just showing the usage of "ReplicationProtectionIntents_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +157,17 @@ public async Task GetIfExists_GetsTheDetailsOfAReplicationProtectionIntentItem() // invoke the operation string intentObjectName = "vm1"; - NullableResponse response = await collection.GetIfExistsAsync(intentObjectName); - ReplicationProtectionIntentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(intentObjectName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReplicationProtectionIntentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateProtectionIntentResource() + public async Task GetIfExists_GetsTheDetailsOfAReplicationProtectionIntentItem() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionIntents_Create.json - // this example is just showing the usage of "ReplicationProtectionIntents_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionIntents_Get.json + // this example is just showing the usage of "ReplicationProtectionIntents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,18 +187,21 @@ public async Task CreateOrUpdate_CreateProtectionIntentResource() // invoke the operation string intentObjectName = "vm1"; - ReplicationProtectionIntentCreateOrUpdateContent content = new ReplicationProtectionIntentCreateOrUpdateContent() - { - SiteRecoveryCreateProtectionIntentProviderSpecificDetails = new A2ACreateProtectionIntentContent(new ResourceIdentifier("/subscriptions/509099b2-9d2c-4636-b43e-bd5cafb6be69/resourceGroups/removeOne/providers/Microsoft.Compute/virtualMachines/vmPpgAv5"), new AzureLocation("eastUs2"), new AzureLocation("westus2"), "ed5bcdf6-d61e-47bd-8ea9-f2bd379a2640", A2ARecoveryAvailabilityType.Single, new ResourceIdentifier("/subscriptions/509099b2-9d2c-4636-b43e-bd5cafb6be69/resourceGroups/removeOne-asr")), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, intentObjectName, content); - ReplicationProtectionIntentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(intentObjectName); + ReplicationProtectionIntentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReplicationProtectionIntentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReplicationProtectionIntentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectionIntentResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectionIntentResource.cs index 3887a123b0839..01cb73c630d60 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectionIntentResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ReplicationProtectionIntentResource.cs @@ -69,9 +69,15 @@ public async Task Update_CreateProtectionIntentResource() ReplicationProtectionIntentResource replicationProtectionIntent = client.GetReplicationProtectionIntentResource(replicationProtectionIntentResourceId); // invoke the operation - ReplicationProtectionIntentCreateOrUpdateContent content = new ReplicationProtectionIntentCreateOrUpdateContent() + ReplicationProtectionIntentCreateOrUpdateContent content = new ReplicationProtectionIntentCreateOrUpdateContent { - SiteRecoveryCreateProtectionIntentProviderSpecificDetails = new A2ACreateProtectionIntentContent(new ResourceIdentifier("/subscriptions/509099b2-9d2c-4636-b43e-bd5cafb6be69/resourceGroups/removeOne/providers/Microsoft.Compute/virtualMachines/vmPpgAv5"), new AzureLocation("eastUs2"), new AzureLocation("westus2"), "ed5bcdf6-d61e-47bd-8ea9-f2bd379a2640", A2ARecoveryAvailabilityType.Single, new ResourceIdentifier("/subscriptions/509099b2-9d2c-4636-b43e-bd5cafb6be69/resourceGroups/removeOne-asr")), + SiteRecoveryCreateProtectionIntentProviderSpecificDetails = new A2ACreateProtectionIntentContent( + new ResourceIdentifier("/subscriptions/509099b2-9d2c-4636-b43e-bd5cafb6be69/resourceGroups/removeOne/providers/Microsoft.Compute/virtualMachines/vmPpgAv5"), + new AzureLocation("eastUs2"), + new AzureLocation("westus2"), + "ed5bcdf6-d61e-47bd-8ea9-f2bd379a2640", + A2ARecoveryAvailabilityType.Single, + new ResourceIdentifier("/subscriptions/509099b2-9d2c-4636-b43e-bd5cafb6be69/resourceGroups/removeOne-asr")), }; ArmOperation lro = await replicationProtectionIntent.UpdateAsync(WaitUntil.Completed, content); ReplicationProtectionIntentResource result = lro.Value; diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index 7da19b8c489e6..a3a1d55c16b07 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -46,6 +46,336 @@ public async Task GetReplicationAppliances_GetsTheListOfAppliances() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSiteRecoveryNetworks_GetsTheListOfNetworksViewOnlyAPI() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworks_List.json + // this example is just showing the usage of "ReplicationNetworks_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "9112a37f-0f3e-46ec-9c00-060c6edca071"; + string resourceGroupName = "srcBvte2a14C27"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + string resourceName = "srce2avaultbvtaC27"; + await foreach (SiteRecoveryNetworkResource item in resourceGroupResource.GetSiteRecoveryNetworksAsync(resourceName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSiteRecoveryNetworkMappings_GetsAllTheNetworkMappingsUnderAVault() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworkMappings_List.json + // this example is just showing the usage of "ReplicationNetworkMappings_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "9112a37f-0f3e-46ec-9c00-060c6edca071"; + string resourceGroupName = "srcBvte2a14C27"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + string resourceName = "srce2avaultbvtaC27"; + await foreach (SiteRecoveryNetworkMappingResource item in resourceGroupResource.GetSiteRecoveryNetworkMappingsAsync(resourceName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryNetworkMappingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSiteRecoveryProtectionContainers_GetsTheListOfAllProtectionContainersInAVault() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainers_List.json + // this example is just showing the usage of "ReplicationProtectionContainers_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "c183865e-6077-46f2-a3b1-deb0f4f4650a"; + string resourceGroupName = "resourceGroupPS1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + string resourceName = "vault1"; + await foreach (SiteRecoveryProtectionContainerResource item in resourceGroupResource.GetSiteRecoveryProtectionContainersAsync(resourceName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryProtectionContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSiteRecoveryMigrationItems_GetsTheListOfMigrationItemsInTheVault() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationMigrationItems_List.json + // this example is just showing the usage of "ReplicationMigrationItems_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "cb53d0c3-bd59-4721-89bc-06916a9147ef"; + string resourceGroupName = "resourcegroup1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + string resourceName = "migrationvault"; + await foreach (SiteRecoveryMigrationItemResource item in resourceGroupResource.GetSiteRecoveryMigrationItemsAsync(resourceName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryMigrationItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetReplicationProtectedItems_GetsTheListOfReplicationProtectedItems() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectedItems_List.json + // this example is just showing the usage of "ReplicationProtectedItems_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "c183865e-6077-46f2-a3b1-deb0f4f4650a"; + string resourceGroupName = "resourceGroupPS1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + string resourceName = "vault1"; + await foreach (ReplicationProtectedItemResource item in resourceGroupResource.GetReplicationProtectedItemsAsync(resourceName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReplicationProtectedItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetProtectionContainerMappings_GetsTheListOfAllProtectionContainerMappingsInAVault() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainerMappings_List.json + // this example is just showing the usage of "ReplicationProtectionContainerMappings_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "c183865e-6077-46f2-a3b1-deb0f4f4650a"; + string resourceGroupName = "resourceGroupPS1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + string resourceName = "vault1"; + await foreach (ProtectionContainerMappingResource item in resourceGroupResource.GetProtectionContainerMappingsAsync(resourceName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProtectionContainerMappingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSiteRecoveryServicesProviders_GetsTheListOfRegisteredRecoveryServicesProvidersInTheVaultThisIsAViewOnlyApi() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryServicesProviders_List.json + // this example is just showing the usage of "ReplicationRecoveryServicesProviders_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "c183865e-6077-46f2-a3b1-deb0f4f4650a"; + string resourceGroupName = "resourceGroupPS1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + string resourceName = "vault1"; + await foreach (SiteRecoveryServicesProviderResource item in resourceGroupResource.GetSiteRecoveryServicesProvidersAsync(resourceName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryServicesProviderData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStorageClassifications_GetsTheListOfStorageClassificationObjectsUnderAVault() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassifications_List.json + // this example is just showing the usage of "ReplicationStorageClassifications_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "9112a37f-0f3e-46ec-9c00-060c6edca071"; + string resourceGroupName = "resourceGroupPS1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + string resourceName = "vault1"; + await foreach (StorageClassificationResource item in resourceGroupResource.GetStorageClassificationsAsync(resourceName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageClassificationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStorageClassificationMappings_GetsTheListOfStorageClassificationMappingsObjectsUnderAVault() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_List.json + // this example is just showing the usage of "ReplicationStorageClassificationMappings_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "9112a37f-0f3e-46ec-9c00-060c6edca071"; + string resourceGroupName = "resourceGroupPS1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + string resourceName = "vault1"; + await foreach (StorageClassificationMappingResource item in resourceGroupResource.GetStorageClassificationMappingsAsync(resourceName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageClassificationMappingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSiteRecoveryVCenters_GetsTheListOfVCenterRegisteredUnderTheVault() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationvCenters_List.json + // this example is just showing the usage of "ReplicationvCenters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "7c943c1b-5122-4097-90c8-861411bdd574"; + string resourceGroupName = "MadhaviVRG"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + string resourceName = "MadhaviVault"; + await foreach (SiteRecoveryVCenterResource item in resourceGroupResource.GetSiteRecoveryVCentersAsync(resourceName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryVCenterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetSupportedOperatingSystem_GetsTheDataOfSupportedOperatingSystemsBySRS() diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryAlertCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryAlertCollection.cs index 0066040f1df35..46f7c67ffb72e 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryAlertCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryAlertCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SiteRecoveryAlertCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfConfiguredEmailNotificationAlertConfigurations() + public async Task CreateOrUpdate_ConfiguresEmailNotificationsForThisVault() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationAlertSettings_List.json - // this example is just showing the usage of "ReplicationAlertSettings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationAlertSettings_Create.json + // this example is just showing the usage of "ReplicationAlertSettings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,25 @@ public async Task GetAll_GetsTheListOfConfiguredEmailNotificationAlertConfigurat string resourceName = "vault1"; SiteRecoveryAlertCollection collection = resourceGroupResource.GetSiteRecoveryAlerts(resourceName); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryAlertResource item in collection.GetAllAsync()) + // invoke the operation + string alertSettingName = "defaultAlertSetting"; + SiteRecoveryAlertCreateOrUpdateContent content = new SiteRecoveryAlertCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryAlertData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new SiteRecoveryConfigureAlertProperties + { + SendToOwners = "false", + CustomEmailAddresses = { "ronehr@microsoft.com" }, + Locale = "", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertSettingName, content); + SiteRecoveryAlertResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +97,10 @@ public async Task Get_GetsAnEmailNotificationAlertConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAnEmailNotificationAlertConfiguration() + public async Task GetAll_GetsTheListOfConfiguredEmailNotificationAlertConfigurations() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationAlertSettings_Get.json - // this example is just showing the usage of "ReplicationAlertSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationAlertSettings_List.json + // this example is just showing the usage of "ReplicationAlertSettings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +118,22 @@ public async Task Exists_GetsAnEmailNotificationAlertConfiguration() string resourceName = "vault1"; SiteRecoveryAlertCollection collection = resourceGroupResource.GetSiteRecoveryAlerts(resourceName); - // invoke the operation - string alertSettingName = "defaultAlertSetting"; - bool result = await collection.ExistsAsync(alertSettingName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryAlertResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryAlertData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAnEmailNotificationAlertConfiguration() + public async Task Exists_GetsAnEmailNotificationAlertConfiguration() { // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationAlertSettings_Get.json // this example is just showing the usage of "ReplicationAlertSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +156,17 @@ public async Task GetIfExists_GetsAnEmailNotificationAlertConfiguration() // invoke the operation string alertSettingName = "defaultAlertSetting"; - NullableResponse response = await collection.GetIfExistsAsync(alertSettingName); - SiteRecoveryAlertResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(alertSettingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConfiguresEmailNotificationsForThisVault() + public async Task GetIfExists_GetsAnEmailNotificationAlertConfiguration() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationAlertSettings_Create.json - // this example is just showing the usage of "ReplicationAlertSettings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationAlertSettings_Get.json + // this example is just showing the usage of "ReplicationAlertSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,26 +186,21 @@ public async Task CreateOrUpdate_ConfiguresEmailNotificationsForThisVault() // invoke the operation string alertSettingName = "defaultAlertSetting"; - SiteRecoveryAlertCreateOrUpdateContent content = new SiteRecoveryAlertCreateOrUpdateContent() - { - Properties = new SiteRecoveryConfigureAlertProperties() - { - SendToOwners = "false", - CustomEmailAddresses = -{ -"ronehr@microsoft.com" -}, - Locale = "", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertSettingName, content); - SiteRecoveryAlertResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(alertSettingName); + SiteRecoveryAlertResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryAlertResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryAlertResource.cs index e6362155f3843..e62551456ecdc 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryAlertResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryAlertResource.cs @@ -69,15 +69,12 @@ public async Task Update_ConfiguresEmailNotificationsForThisVault() SiteRecoveryAlertResource siteRecoveryAlert = client.GetSiteRecoveryAlertResource(siteRecoveryAlertResourceId); // invoke the operation - SiteRecoveryAlertCreateOrUpdateContent content = new SiteRecoveryAlertCreateOrUpdateContent() + SiteRecoveryAlertCreateOrUpdateContent content = new SiteRecoveryAlertCreateOrUpdateContent { - Properties = new SiteRecoveryConfigureAlertProperties() + Properties = new SiteRecoveryConfigureAlertProperties { SendToOwners = "false", - CustomEmailAddresses = -{ -"ronehr@microsoft.com" -}, + CustomEmailAddresses = { "ronehr@microsoft.com" }, Locale = "", }, }; diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryEventCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryEventCollection.cs index 67afb4bdd2c70..6f7c8ce6f06e6 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryEventCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryEventCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SiteRecoveryEventCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfAzureSiteRecoveryEvents() + public async Task Get_GetTheDetailsOfAnAzureSiteRecoveryEvent() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationEvents_List.json - // this example is just showing the usage of "ReplicationEvents_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationEvents_Get.json + // this example is just showing the usage of "ReplicationEvents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetsTheListOfAzureSiteRecoveryEvents() string resourceName = "vault1"; SiteRecoveryEventCollection collection = resourceGroupResource.GetSiteRecoveryEvents(resourceName); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryEventResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryEventData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string eventName = "654b71d0-b2ce-4e6e-a861-98528d4bd375"; + SiteRecoveryEventResource result = await collection.GetAsync(eventName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryEventData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheDetailsOfAnAzureSiteRecoveryEvent() + public async Task GetAll_GetsTheListOfAzureSiteRecoveryEvents() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationEvents_Get.json - // this example is just showing the usage of "ReplicationEvents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationEvents_List.json + // this example is just showing the usage of "ReplicationEvents_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,15 +73,17 @@ public async Task Get_GetTheDetailsOfAnAzureSiteRecoveryEvent() string resourceName = "vault1"; SiteRecoveryEventCollection collection = resourceGroupResource.GetSiteRecoveryEvents(resourceName); - // invoke the operation - string eventName = "654b71d0-b2ce-4e6e-a861-98528d4bd375"; - SiteRecoveryEventResource result = await collection.GetAsync(eventName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryEventResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryEventData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryEventData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryFabricCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryFabricCollection.cs index ca7aac7d8aa53..264c61b40a4cd 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryFabricCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryFabricCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SiteRecoveryFabricCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfASRFabrics() + public async Task Get_GetsTheDetailsOfAnASRFabric() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationFabrics_List.json - // this example is just showing the usage of "ReplicationFabrics_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationFabrics_Get.json + // this example is just showing the usage of "ReplicationFabrics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetsTheListOfASRFabrics() string resourceName = "vault1"; SiteRecoveryFabricCollection collection = resourceGroupResource.GetSiteRecoveryFabrics(resourceName); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryFabricResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryFabricData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string fabricName = "cloud1"; + SiteRecoveryFabricResource result = await collection.GetAsync(fabricName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryFabricData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheDetailsOfAnASRFabric() + public async Task GetAll_GetsTheListOfASRFabrics() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationFabrics_Get.json - // this example is just showing the usage of "ReplicationFabrics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationFabrics_List.json + // this example is just showing the usage of "ReplicationFabrics_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,15 +73,17 @@ public async Task Get_GetsTheDetailsOfAnASRFabric() string resourceName = "vault1"; SiteRecoveryFabricCollection collection = resourceGroupResource.GetSiteRecoveryFabrics(resourceName); - // invoke the operation - string fabricName = "cloud1"; - SiteRecoveryFabricResource result = await collection.GetAsync(fabricName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryFabricResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryFabricData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryFabricData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryFabricResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryFabricResource.cs index 3776802d042d3..cc20e5524090d 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryFabricResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryFabricResource.cs @@ -128,17 +128,14 @@ public async Task ReassociateGateway_PerformFailoverOfTheProcessServer() SiteRecoveryFabricResource siteRecoveryFabric = client.GetSiteRecoveryFabricResource(siteRecoveryFabricResourceId); // invoke the operation - FailoverProcessServerContent content = new FailoverProcessServerContent() + FailoverProcessServerContent content = new FailoverProcessServerContent { - Properties = new FailoverProcessServerProperties() + Properties = new FailoverProcessServerProperties { ContainerName = "cloud_1f3c15af-2256-4568-9e06-e1ef4f728f75", SourceProcessServerId = Guid.Parse("AFA0EC54-1894-4E44-9CAB02DB8854B117"), TargetProcessServerId = Guid.Parse("5D3ED340-85AE-C646-B338641E015DA405"), - VmsToMigrate = -{ -"Vm1","Vm2" -}, + VmsToMigrate = { "Vm1", "Vm2" }, UpdateType = "ServerLevel", }, }; @@ -201,7 +198,7 @@ public async Task RenewCertificate_RenewsCertificateForTheFabric() SiteRecoveryFabricResource siteRecoveryFabric = client.GetSiteRecoveryFabricResource(siteRecoveryFabricResourceId); // invoke the operation - RenewCertificateContent content = new RenewCertificateContent() + RenewCertificateContent content = new RenewCertificateContent { RenewCertificateType = "Cloud", }; diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryJobCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryJobCollection.cs index 0c62ee0be056f..83cae466b8c03 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryJobCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryJobCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SiteRecoveryJobCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfJobs() + public async Task Get_GetsTheJobDetails() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationJobs_List.json - // this example is just showing the usage of "ReplicationJobs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationJobs_Get.json + // this example is just showing the usage of "ReplicationJobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetsTheListOfJobs() string resourceName = "vault1"; SiteRecoveryJobCollection collection = resourceGroupResource.GetSiteRecoveryJobs(resourceName); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryJobResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string jobName = "58776d0b-3141-48b2-a377-9ad863eb160d"; + SiteRecoveryJobResource result = await collection.GetAsync(jobName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheJobDetails() + public async Task GetAll_GetsTheListOfJobs() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationJobs_Get.json - // this example is just showing the usage of "ReplicationJobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationJobs_List.json + // this example is just showing the usage of "ReplicationJobs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,15 +73,17 @@ public async Task Get_GetsTheJobDetails() string resourceName = "vault1"; SiteRecoveryJobCollection collection = resourceGroupResource.GetSiteRecoveryJobs(resourceName); - // invoke the operation - string jobName = "58776d0b-3141-48b2-a377-9ad863eb160d"; - SiteRecoveryJobResource result = await collection.GetAsync(jobName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryJobResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryJobResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryJobResource.cs index 9530b99d22787..1f9684776e97c 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryJobResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryJobResource.cs @@ -133,7 +133,7 @@ public async Task Resume_ResumesTheSpecifiedJob() SiteRecoveryJobResource siteRecoveryJob = client.GetSiteRecoveryJobResource(siteRecoveryJobResourceId); // invoke the operation - ReplicationResumeJobContent content = new ReplicationResumeJobContent() + ReplicationResumeJobContent content = new ReplicationResumeJobContent { ReplicationResumeJobComments = " ", }; diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryLogicalNetworkCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryLogicalNetworkCollection.cs index 5febcfe4affb1..38884b66192ce 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryLogicalNetworkCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryLogicalNetworkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteRecoveryLogicalNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfLogicalNetworksUnderAFabric() + public async Task Get_GetsALogicalNetworkWithSpecifiedServerIdAndLogicalNetworkName() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationLogicalNetworks_ListByReplicationFabrics.json - // this example is just showing the usage of "ReplicationLogicalNetworks_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationLogicalNetworks_Get.json + // this example is just showing the usage of "ReplicationLogicalNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetsTheListOfLogicalNetworksUnderAFabric() // get the collection of this SiteRecoveryLogicalNetworkResource SiteRecoveryLogicalNetworkCollection collection = siteRecoveryFabric.GetSiteRecoveryLogicalNetworks(); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryLogicalNetworkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryLogicalNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string logicalNetworkName = "87ab394f-165f-4aa9-bd84-b018500b4509"; + SiteRecoveryLogicalNetworkResource result = await collection.GetAsync(logicalNetworkName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryLogicalNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsALogicalNetworkWithSpecifiedServerIdAndLogicalNetworkName() + public async Task GetAll_GetsTheListOfLogicalNetworksUnderAFabric() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationLogicalNetworks_Get.json - // this example is just showing the usage of "ReplicationLogicalNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationLogicalNetworks_ListByReplicationFabrics.json + // this example is just showing the usage of "ReplicationLogicalNetworks_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetsALogicalNetworkWithSpecifiedServerIdAndLogicalNetworkN // get the collection of this SiteRecoveryLogicalNetworkResource SiteRecoveryLogicalNetworkCollection collection = siteRecoveryFabric.GetSiteRecoveryLogicalNetworks(); - // invoke the operation - string logicalNetworkName = "87ab394f-165f-4aa9-bd84-b018500b4509"; - SiteRecoveryLogicalNetworkResource result = await collection.GetAsync(logicalNetworkName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryLogicalNetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryLogicalNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryLogicalNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryMigrationItemCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryMigrationItemCollection.cs index 6de07734c9326..058fd0a237771 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryMigrationItemCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryMigrationItemCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SiteRecoveryMigrationItemCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfMigrationItemsInTheProtectionContainer() + public async Task CreateOrUpdate_EnablesMigration() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationMigrationItems_ListByReplicationProtectionContainers.json - // this example is just showing the usage of "ReplicationMigrationItems_ListByReplicationProtectionContainers" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationMigrationItems_Create.json + // this example is just showing the usage of "ReplicationMigrationItems_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,26 @@ public async Task GetAll_GetsTheListOfMigrationItemsInTheProtectionContainer() // get the collection of this SiteRecoveryMigrationItemResource SiteRecoveryMigrationItemCollection collection = siteRecoveryProtectionContainer.GetSiteRecoveryMigrationItems(); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryMigrationItemResource item in collection.GetAllAsync()) + // invoke the operation + string migrationItemName = "virtualmachine1"; + SiteRecoveryMigrationItemCreateOrUpdateContent content = new SiteRecoveryMigrationItemCreateOrUpdateContent(new EnableMigrationProperties(new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.RecoveryServices/vaults/migrationvault/replicationPolicies/vmwarepolicy1"), new VMwareCbtEnableMigrationContent( + new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.OffAzure/VMwareSites/vmwaresite1/machines/virtualmachine1"), + new VMwareCbtDiskContent[] { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryMigrationItemData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } +new VMwareCbtDiskContent("disk1", "true", new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.Storage/storageAccounts/logStorageAccount1"), "logStorageSas") + }, + new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.OffAzure/VMwareSites/vmwaresite1/runasaccounts/dataMoverRunAsAccount1"), + new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.OffAzure/VMwareSites/vmwaresite1/runasaccounts/snapshotRunAsAccount1"), + new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1"), + new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.Network/virtualNetworks/virtualNetwork1")))); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationItemName, content); + SiteRecoveryMigrationItemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryMigrationItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +101,10 @@ public async Task Get_GetsTheDetailsOfAMigrationItem() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheDetailsOfAMigrationItem() + public async Task GetAll_GetsTheListOfMigrationItemsInTheProtectionContainer() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationMigrationItems_Get.json - // this example is just showing the usage of "ReplicationMigrationItems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationMigrationItems_ListByReplicationProtectionContainers.json + // this example is just showing the usage of "ReplicationMigrationItems_ListByReplicationProtectionContainers" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +124,22 @@ public async Task Exists_GetsTheDetailsOfAMigrationItem() // get the collection of this SiteRecoveryMigrationItemResource SiteRecoveryMigrationItemCollection collection = siteRecoveryProtectionContainer.GetSiteRecoveryMigrationItems(); - // invoke the operation - string migrationItemName = "virtualmachine1"; - bool result = await collection.ExistsAsync(migrationItemName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryMigrationItemResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryMigrationItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheDetailsOfAMigrationItem() + public async Task Exists_GetsTheDetailsOfAMigrationItem() { // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationMigrationItems_Get.json // this example is just showing the usage of "ReplicationMigrationItems_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +164,17 @@ public async Task GetIfExists_GetsTheDetailsOfAMigrationItem() // invoke the operation string migrationItemName = "virtualmachine1"; - NullableResponse response = await collection.GetIfExistsAsync(migrationItemName); - SiteRecoveryMigrationItemResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(migrationItemName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryMigrationItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EnablesMigration() + public async Task GetIfExists_GetsTheDetailsOfAMigrationItem() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationMigrationItems_Create.json - // this example is just showing the usage of "ReplicationMigrationItems_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationMigrationItems_Get.json + // this example is just showing the usage of "ReplicationMigrationItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,18 +196,21 @@ public async Task CreateOrUpdate_EnablesMigration() // invoke the operation string migrationItemName = "virtualmachine1"; - SiteRecoveryMigrationItemCreateOrUpdateContent content = new SiteRecoveryMigrationItemCreateOrUpdateContent(new EnableMigrationProperties(new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.RecoveryServices/vaults/migrationvault/replicationPolicies/vmwarepolicy1"), new VMwareCbtEnableMigrationContent(new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.OffAzure/VMwareSites/vmwaresite1/machines/virtualmachine1"), new VMwareCbtDiskContent[] - { -new VMwareCbtDiskContent("disk1","true",new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.Storage/storageAccounts/logStorageAccount1"),"logStorageSas") - }, new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.OffAzure/VMwareSites/vmwaresite1/runasaccounts/dataMoverRunAsAccount1"), new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.OffAzure/VMwareSites/vmwaresite1/runasaccounts/snapshotRunAsAccount1"), new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1"), new ResourceIdentifier("/Subscriptions/cb53d0c3-bd59-4721-89bc-06916a9147ef/resourceGroups/resourcegroup1/providers/Microsoft.Network/virtualNetworks/virtualNetwork1")))); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, migrationItemName, content); - SiteRecoveryMigrationItemResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(migrationItemName); + SiteRecoveryMigrationItemResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryMigrationItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryMigrationItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryMigrationItemResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryMigrationItemResource.cs index 15442a76a2e55..c25117eeb604d 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryMigrationItemResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryMigrationItemResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesSiteRecovery.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Samples @@ -103,7 +102,7 @@ public async Task Update_UpdatesMigrationItem() SiteRecoveryMigrationItemResource siteRecoveryMigrationItem = client.GetSiteRecoveryMigrationItemResource(siteRecoveryMigrationItemResourceId); // invoke the operation - SiteRecoveryMigrationItemPatch patch = new SiteRecoveryMigrationItemPatch() + SiteRecoveryMigrationItemPatch patch = new SiteRecoveryMigrationItemPatch { UpdateMigrationItemProviderSpecificDetails = new VMwareCbtUpdateMigrationItemContent(), }; @@ -211,7 +210,7 @@ public async Task ResumeReplication_ResumeReplication() SiteRecoveryMigrationItemResource siteRecoveryMigrationItem = client.GetSiteRecoveryMigrationItemResource(siteRecoveryMigrationItemResourceId); // invoke the operation - ResumeReplicationContent content = new ResumeReplicationContent(new ResumeReplicationProperties(new VMwareCbtResumeReplicationContent() + ResumeReplicationContent content = new ResumeReplicationContent(new ResumeReplicationProperties(new VMwareCbtResumeReplicationContent { DeleteMigrationResources = "false", })); @@ -319,7 +318,7 @@ public async Task TestMigrateCleanup_TestMigrateCleanup() SiteRecoveryMigrationItemResource siteRecoveryMigrationItem = client.GetSiteRecoveryMigrationItemResource(siteRecoveryMigrationItemResourceId); // invoke the operation - TestMigrateCleanupContent content = new TestMigrateCleanupContent(new TestMigrateCleanupProperties() + TestMigrateCleanupContent content = new TestMigrateCleanupContent(new TestMigrateCleanupProperties { Comments = "Test Failover Cleanup", }); @@ -332,38 +331,5 @@ public async Task TestMigrateCleanup_TestMigrateCleanup() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSiteRecoveryMigrationItems_GetsTheListOfMigrationItemsInTheVault() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationMigrationItems_List.json - // this example is just showing the usage of "ReplicationMigrationItems_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "cb53d0c3-bd59-4721-89bc-06916a9147ef"; - string resourceGroupName = "resourcegroup1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - string resourceName = "migrationvault"; - await foreach (SiteRecoveryMigrationItemResource item in resourceGroupResource.GetSiteRecoveryMigrationItemsAsync(resourceName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryMigrationItemData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkCollection.cs index 401ab3cae4541..33604a3de2526 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteRecoveryNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfNetworksUnderAFabric() + public async Task Get_GetsANetworkWithSpecifiedServerIdAndNetworkName() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworks_ListByReplicationFabrics.json - // this example is just showing the usage of "ReplicationNetworks_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworks_Get.json + // this example is just showing the usage of "ReplicationNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetsTheListOfNetworksUnderAFabric() // get the collection of this SiteRecoveryNetworkResource SiteRecoveryNetworkCollection collection = siteRecoveryFabric.GetSiteRecoveryNetworks(); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryNetworkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string networkName = "93ce99d7-1219-4914-aa61-73fe5023988e"; + SiteRecoveryNetworkResource result = await collection.GetAsync(networkName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsANetworkWithSpecifiedServerIdAndNetworkName() + public async Task GetAll_GetsTheListOfNetworksUnderAFabric() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworks_Get.json - // this example is just showing the usage of "ReplicationNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworks_ListByReplicationFabrics.json + // this example is just showing the usage of "ReplicationNetworks_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetsANetworkWithSpecifiedServerIdAndNetworkName() // get the collection of this SiteRecoveryNetworkResource SiteRecoveryNetworkCollection collection = siteRecoveryFabric.GetSiteRecoveryNetworks(); - // invoke the operation - string networkName = "93ce99d7-1219-4914-aa61-73fe5023988e"; - SiteRecoveryNetworkResource result = await collection.GetAsync(networkName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryNetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkMappingCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkMappingCollection.cs index 1c7b5a6ba35e2..a1d0a5cd0aae5 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkMappingCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkMappingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SiteRecoveryNetworkMappingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAllTheNetworkMappingsUnderANetwork() + public async Task CreateOrUpdate_CreatesNetworkMapping() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworkMappings_ListByReplicationNetworks.json - // this example is just showing the usage of "ReplicationNetworkMappings_ListByReplicationNetworks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworkMappings_Create.json + // this example is just showing the usage of "ReplicationNetworkMappings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,21 @@ public async Task GetAll_GetsAllTheNetworkMappingsUnderANetwork() // get the collection of this SiteRecoveryNetworkMappingResource SiteRecoveryNetworkMappingCollection collection = siteRecoveryNetwork.GetSiteRecoveryNetworkMappings(); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryNetworkMappingResource item in collection.GetAllAsync()) + // invoke the operation + string networkMappingName = "corpe2amap"; + SiteRecoveryNetworkMappingCreateOrUpdateContent content = new SiteRecoveryNetworkMappingCreateOrUpdateContent(new SiteRecoveryCreateReplicationNetworkMappingProperties(new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/siterecoveryProd1/providers/Microsoft.Network/virtualNetworks/vnetavrai")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryNetworkMappingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + RecoveryFabricName = "Microsoft Azure", + FabricSpecificDetails = new VmmToAzureCreateNetworkMappingContent(), + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkMappingName, content); + SiteRecoveryNetworkMappingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryNetworkMappingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +96,10 @@ public async Task Get_GetsNetworkMappingByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsNetworkMappingByName() + public async Task GetAll_GetsAllTheNetworkMappingsUnderANetwork() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworkMappings_Get.json - // this example is just showing the usage of "ReplicationNetworkMappings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworkMappings_ListByReplicationNetworks.json + // this example is just showing the usage of "ReplicationNetworkMappings_ListByReplicationNetworks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +119,22 @@ public async Task Exists_GetsNetworkMappingByName() // get the collection of this SiteRecoveryNetworkMappingResource SiteRecoveryNetworkMappingCollection collection = siteRecoveryNetwork.GetSiteRecoveryNetworkMappings(); - // invoke the operation - string networkMappingName = "corpe2amap"; - bool result = await collection.ExistsAsync(networkMappingName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryNetworkMappingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryNetworkMappingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsNetworkMappingByName() + public async Task Exists_GetsNetworkMappingByName() { // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworkMappings_Get.json // this example is just showing the usage of "ReplicationNetworkMappings_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +159,17 @@ public async Task GetIfExists_GetsNetworkMappingByName() // invoke the operation string networkMappingName = "corpe2amap"; - NullableResponse response = await collection.GetIfExistsAsync(networkMappingName); - SiteRecoveryNetworkMappingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkMappingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryNetworkMappingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesNetworkMapping() + public async Task GetIfExists_GetsNetworkMappingByName() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworkMappings_Create.json - // this example is just showing the usage of "ReplicationNetworkMappings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworkMappings_Get.json + // this example is just showing the usage of "ReplicationNetworkMappings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,19 +191,21 @@ public async Task CreateOrUpdate_CreatesNetworkMapping() // invoke the operation string networkMappingName = "corpe2amap"; - SiteRecoveryNetworkMappingCreateOrUpdateContent content = new SiteRecoveryNetworkMappingCreateOrUpdateContent(new SiteRecoveryCreateReplicationNetworkMappingProperties(new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/siterecoveryProd1/providers/Microsoft.Network/virtualNetworks/vnetavrai")) - { - RecoveryFabricName = "Microsoft Azure", - FabricSpecificDetails = new VmmToAzureCreateNetworkMappingContent(), - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkMappingName, content); - SiteRecoveryNetworkMappingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(networkMappingName); + SiteRecoveryNetworkMappingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryNetworkMappingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryNetworkMappingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkMappingResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkMappingResource.cs index 37299c533a70a..560ed7d2f262e 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkMappingResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkMappingResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesSiteRecovery.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Samples @@ -103,9 +102,9 @@ public async Task Update_UpdatesNetworkMapping() SiteRecoveryNetworkMappingResource siteRecoveryNetworkMapping = client.GetSiteRecoveryNetworkMappingResource(siteRecoveryNetworkMappingResourceId); // invoke the operation - SiteRecoveryNetworkMappingPatch patch = new SiteRecoveryNetworkMappingPatch() + SiteRecoveryNetworkMappingPatch patch = new SiteRecoveryNetworkMappingPatch { - Properties = new UpdateNetworkMappingProperties() + Properties = new UpdateNetworkMappingProperties { RecoveryFabricName = "Microsoft Azure", RecoveryNetworkId = new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/siterecoveryProd1/providers/Microsoft.Network/virtualNetworks/vnetavrai2"), @@ -121,38 +120,5 @@ public async Task Update_UpdatesNetworkMapping() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSiteRecoveryNetworkMappings_GetsAllTheNetworkMappingsUnderAVault() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworkMappings_List.json - // this example is just showing the usage of "ReplicationNetworkMappings_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "9112a37f-0f3e-46ec-9c00-060c6edca071"; - string resourceGroupName = "srcBvte2a14C27"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - string resourceName = "srce2avaultbvtaC27"; - await foreach (SiteRecoveryNetworkMappingResource item in resourceGroupResource.GetSiteRecoveryNetworkMappingsAsync(resourceName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryNetworkMappingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkResource.cs index da9ec0c005c56..64ed3e42080c0 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryNetworkResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Samples @@ -47,38 +46,5 @@ public async Task Get_GetsANetworkWithSpecifiedServerIdAndNetworkName() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSiteRecoveryNetworks_GetsTheListOfNetworksViewOnlyAPI() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationNetworks_List.json - // this example is just showing the usage of "ReplicationNetworks_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "9112a37f-0f3e-46ec-9c00-060c6edca071"; - string resourceGroupName = "srcBvte2a14C27"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - string resourceName = "srce2avaultbvtaC27"; - await foreach (SiteRecoveryNetworkResource item in resourceGroupResource.GetSiteRecoveryNetworksAsync(resourceName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPointCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPointCollection.cs index 188dbb99655be..8562905b6c2d2 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPointCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPointCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteRecoveryPointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfRecoveryPointsForAReplicationProtectedItem() + public async Task Get_GetsARecoveryPoint() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/RecoveryPoints_ListByReplicationProtectedItems.json - // this example is just showing the usage of "RecoveryPoints_ListByReplicationProtectedItems" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/RecoveryPoints_Get.json + // this example is just showing the usage of "RecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_GetsTheListOfRecoveryPointsForAReplicationProtectedItem // get the collection of this SiteRecoveryPointResource SiteRecoveryPointCollection collection = replicationProtectedItem.GetSiteRecoveryPoints(); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryPointResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryPointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string recoveryPointName = "b22134ea-620c-474b-9fa5-3c1cb47708e3"; + SiteRecoveryPointResource result = await collection.GetAsync(recoveryPointName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryPointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsARecoveryPoint() + public async Task GetAll_GetsTheListOfRecoveryPointsForAReplicationProtectedItem() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/RecoveryPoints_Get.json - // this example is just showing the usage of "RecoveryPoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/RecoveryPoints_ListByReplicationProtectedItems.json + // this example is just showing the usage of "RecoveryPoints_ListByReplicationProtectedItems" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +78,17 @@ public async Task Get_GetsARecoveryPoint() // get the collection of this SiteRecoveryPointResource SiteRecoveryPointCollection collection = replicationProtectedItem.GetSiteRecoveryPoints(); - // invoke the operation - string recoveryPointName = "b22134ea-620c-474b-9fa5-3c1cb47708e3"; - SiteRecoveryPointResource result = await collection.GetAsync(recoveryPointName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryPointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryPointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryPointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPolicyCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPolicyCollection.cs index f0c15db8a8650..981c4931f78f4 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPolicyCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPolicyCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SiteRecoveryPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfReplicationPolicies() + public async Task CreateOrUpdate_CreatesThePolicy() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationPolicies_List.json - // this example is just showing the usage of "ReplicationPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationPolicies_Create.json + // this example is just showing the usage of "ReplicationPolicies_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_GetsTheListOfReplicationPolicies() string resourceName = "vault1"; SiteRecoveryPolicyCollection collection = resourceGroupResource.GetSiteRecoveryPolicies(resourceName); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string policyName = "protectionprofile1"; + SiteRecoveryPolicyCreateOrUpdateContent content = new SiteRecoveryPolicyCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SiteRecoveryCreateProviderSpecificContent = new HyperVReplicaAzurePolicyContent(), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, content); + SiteRecoveryPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_GetsTheRequestedPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheRequestedPolicy() + public async Task GetAll_GetsTheListOfReplicationPolicies() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationPolicies_Get.json - // this example is just showing the usage of "ReplicationPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationPolicies_List.json + // this example is just showing the usage of "ReplicationPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +113,22 @@ public async Task Exists_GetsTheRequestedPolicy() string resourceName = "vault1"; SiteRecoveryPolicyCollection collection = resourceGroupResource.GetSiteRecoveryPolicies(resourceName); - // invoke the operation - string policyName = "protectionprofile1"; - bool result = await collection.ExistsAsync(policyName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheRequestedPolicy() + public async Task Exists_GetsTheRequestedPolicy() { // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationPolicies_Get.json // this example is just showing the usage of "ReplicationPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +151,17 @@ public async Task GetIfExists_GetsTheRequestedPolicy() // invoke the operation string policyName = "protectionprofile1"; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - SiteRecoveryPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesThePolicy() + public async Task GetIfExists_GetsTheRequestedPolicy() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationPolicies_Create.json - // this example is just showing the usage of "ReplicationPolicies_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationPolicies_Get.json + // this example is just showing the usage of "ReplicationPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,18 +181,21 @@ public async Task CreateOrUpdate_CreatesThePolicy() // invoke the operation string policyName = "protectionprofile1"; - SiteRecoveryPolicyCreateOrUpdateContent content = new SiteRecoveryPolicyCreateOrUpdateContent() - { - SiteRecoveryCreateProviderSpecificContent = new HyperVReplicaAzurePolicyContent(), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, content); - SiteRecoveryPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + SiteRecoveryPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPolicyResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPolicyResource.cs index a3198553be9c7..2874507e89ee7 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPolicyResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryPolicyResource.cs @@ -96,7 +96,7 @@ public async Task Update_UpdatesThePolicy() SiteRecoveryPolicyResource siteRecoveryPolicy = client.GetSiteRecoveryPolicyResource(siteRecoveryPolicyResourceId); // invoke the operation - SiteRecoveryPolicyPatch patch = new SiteRecoveryPolicyPatch() + SiteRecoveryPolicyPatch patch = new SiteRecoveryPolicyPatch { UpdatePolicyContentReplicationProviderSettings = new HyperVReplicaAzurePolicyContent(), }; diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectableItemCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectableItemCollection.cs index 7518ec45c64d0..360e47e19663a 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectableItemCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectableItemCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteRecoveryProtectableItemCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfProtectableItems() + public async Task Get_GetsTheDetailsOfAProtectableItem() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectableItems_ListByReplicationProtectionContainers.json - // this example is just showing the usage of "ReplicationProtectableItems_ListByReplicationProtectionContainers" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectableItems_Get.json + // this example is just showing the usage of "ReplicationProtectableItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_GetsTheListOfProtectableItems() // get the collection of this SiteRecoveryProtectableItemResource SiteRecoveryProtectableItemCollection collection = siteRecoveryProtectionContainer.GetSiteRecoveryProtectableItems(); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryProtectableItemResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryProtectableItemData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string protectableItemName = "c0c14913-3d7a-48ea-9531-cc99e0e686e6"; + SiteRecoveryProtectableItemResource result = await collection.GetAsync(protectableItemName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryProtectableItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheDetailsOfAProtectableItem() + public async Task GetAll_GetsTheListOfProtectableItems() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectableItems_Get.json - // this example is just showing the usage of "ReplicationProtectableItems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectableItems_ListByReplicationProtectionContainers.json + // this example is just showing the usage of "ReplicationProtectableItems_ListByReplicationProtectionContainers" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetsTheDetailsOfAProtectableItem() // get the collection of this SiteRecoveryProtectableItemResource SiteRecoveryProtectableItemCollection collection = siteRecoveryProtectionContainer.GetSiteRecoveryProtectableItems(); - // invoke the operation - string protectableItemName = "c0c14913-3d7a-48ea-9531-cc99e0e686e6"; - SiteRecoveryProtectableItemResource result = await collection.GetAsync(protectableItemName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryProtectableItemResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryProtectableItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryProtectableItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectionContainerCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectionContainerCollection.cs index 1c61627bf9d15..8279e1c6466e6 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectionContainerCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectionContainerCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteRecoveryProtectionContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfProtectionContainerForAFabric() + public async Task Get_GetsTheProtectionContainerDetails() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainers_ListByReplicationFabrics.json - // this example is just showing the usage of "ReplicationProtectionContainers_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainers_Get.json + // this example is just showing the usage of "ReplicationProtectionContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetsTheListOfProtectionContainerForAFabric() // get the collection of this SiteRecoveryProtectionContainerResource SiteRecoveryProtectionContainerCollection collection = siteRecoveryFabric.GetSiteRecoveryProtectionContainers(); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryProtectionContainerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryProtectionContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string protectionContainerName = "cloud_6d224fc6-f326-5d35-96de-fbf51efb3179"; + SiteRecoveryProtectionContainerResource result = await collection.GetAsync(protectionContainerName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryProtectionContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheProtectionContainerDetails() + public async Task GetAll_GetsTheListOfProtectionContainerForAFabric() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainers_Get.json - // this example is just showing the usage of "ReplicationProtectionContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainers_ListByReplicationFabrics.json + // this example is just showing the usage of "ReplicationProtectionContainers_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetsTheProtectionContainerDetails() // get the collection of this SiteRecoveryProtectionContainerResource SiteRecoveryProtectionContainerCollection collection = siteRecoveryFabric.GetSiteRecoveryProtectionContainers(); - // invoke the operation - string protectionContainerName = "cloud_6d224fc6-f326-5d35-96de-fbf51efb3179"; - SiteRecoveryProtectionContainerResource result = await collection.GetAsync(protectionContainerName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryProtectionContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryProtectionContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryProtectionContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectionContainerResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectionContainerResource.cs index 684a21cf13c01..9ac2f70c0a8b3 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectionContainerResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryProtectionContainerResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesSiteRecovery.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Samples @@ -73,9 +72,9 @@ public async Task DiscoverProtectableItem_AddsAProtectableItemToTheReplicationPr SiteRecoveryProtectionContainerResource siteRecoveryProtectionContainer = client.GetSiteRecoveryProtectionContainerResource(siteRecoveryProtectionContainerResourceId); // invoke the operation - DiscoverProtectableItemContent content = new DiscoverProtectableItemContent() + DiscoverProtectableItemContent content = new DiscoverProtectableItemContent { - Properties = new DiscoverProtectableItemProperties() + Properties = new DiscoverProtectableItemProperties { FriendlyName = "Test", IPAddress = IPAddress.Parse("10.150.2.3"), @@ -143,9 +142,9 @@ public async Task SwitchProtection_SwitchesProtectionFromOneContainerToAnotherOr SiteRecoveryProtectionContainerResource siteRecoveryProtectionContainer = client.GetSiteRecoveryProtectionContainerResource(siteRecoveryProtectionContainerResourceId); // invoke the operation - SwitchProtectionContent content = new SwitchProtectionContent() + SwitchProtectionContent content = new SwitchProtectionContent { - Properties = new SwitchProtectionProperties() + Properties = new SwitchProtectionProperties { ReplicationProtectedItemName = "a2aSwapOsVm", ProviderSpecificDetails = new A2ASwitchProtectionContent(), @@ -160,38 +159,5 @@ public async Task SwitchProtection_SwitchesProtectionFromOneContainerToAnotherOr // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSiteRecoveryProtectionContainers_GetsTheListOfAllProtectionContainersInAVault() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationProtectionContainers_List.json - // this example is just showing the usage of "ReplicationProtectionContainers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "c183865e-6077-46f2-a3b1-deb0f4f4650a"; - string resourceGroupName = "resourceGroupPS1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - string resourceName = "vault1"; - await foreach (SiteRecoveryProtectionContainerResource item in resourceGroupResource.GetSiteRecoveryProtectionContainersAsync(resourceName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryProtectionContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryRecoveryPlanCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryRecoveryPlanCollection.cs index 0d94277123d8b..5be2f5e885906 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryRecoveryPlanCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryRecoveryPlanCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SiteRecoveryRecoveryPlanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfRecoveryPlans() + public async Task CreateOrUpdate_CreatesARecoveryPlanWithTheGivenDetails() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryPlans_List.json - // this example is just showing the usage of "ReplicationRecoveryPlans_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryPlans_Create.json + // this example is just showing the usage of "ReplicationRecoveryPlans_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,32 @@ public async Task GetAll_GetsTheListOfRecoveryPlans() string resourceName = "vault1"; SiteRecoveryRecoveryPlanCollection collection = resourceGroupResource.GetSiteRecoveryRecoveryPlans(resourceName); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryRecoveryPlanResource item in collection.GetAllAsync()) + // invoke the operation + string recoveryPlanName = "RPtest1"; + SiteRecoveryRecoveryPlanCreateOrUpdateContent content = new SiteRecoveryRecoveryPlanCreateOrUpdateContent(new SiteRecoveryCreateRecoveryPlanProperties(new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/cloud1"), new ResourceIdentifier("Microsoft Azure"), new SiteRecoveryPlanGroup[] { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryRecoveryPlanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } +new SiteRecoveryPlanGroup(RecoveryPlanGroupType.Boot) +{ +ReplicationProtectedItems = {new RecoveryPlanProtectedItem +{ +Id = new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/cloud1/replicationProtectionContainers/cloud_6d224fc6-f326-5d35-96de-fbf51efb3179/replicationProtectedItems/f8491e4f-817a-40dd-a90c-af773978c75b"), +VirtualMachineId = "f8491e4f-817a-40dd-a90c-af773978c75b", +}}, +StartGroupActions = {}, +EndGroupActions = {}, +} + }) + { + FailoverDeploymentModel = FailoverDeploymentModel.ResourceManager, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, recoveryPlanName, content); + SiteRecoveryRecoveryPlanResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryRecoveryPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +104,10 @@ public async Task Get_GetsTheRequestedRecoveryPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheRequestedRecoveryPlan() + public async Task GetAll_GetsTheListOfRecoveryPlans() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryPlans_Get.json - // this example is just showing the usage of "ReplicationRecoveryPlans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryPlans_List.json + // this example is just showing the usage of "ReplicationRecoveryPlans_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +125,22 @@ public async Task Exists_GetsTheRequestedRecoveryPlan() string resourceName = "vault1"; SiteRecoveryRecoveryPlanCollection collection = resourceGroupResource.GetSiteRecoveryRecoveryPlans(resourceName); - // invoke the operation - string recoveryPlanName = "RPtest1"; - bool result = await collection.ExistsAsync(recoveryPlanName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryRecoveryPlanResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryRecoveryPlanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheRequestedRecoveryPlan() + public async Task Exists_GetsTheRequestedRecoveryPlan() { // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryPlans_Get.json // this example is just showing the usage of "ReplicationRecoveryPlans_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +163,17 @@ public async Task GetIfExists_GetsTheRequestedRecoveryPlan() // invoke the operation string recoveryPlanName = "RPtest1"; - NullableResponse response = await collection.GetIfExistsAsync(recoveryPlanName); - SiteRecoveryRecoveryPlanResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(recoveryPlanName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryRecoveryPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesARecoveryPlanWithTheGivenDetails() + public async Task GetIfExists_GetsTheRequestedRecoveryPlan() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryPlans_Create.json - // this example is just showing the usage of "ReplicationRecoveryPlans_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryPlans_Get.json + // this example is just showing the usage of "ReplicationRecoveryPlans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,37 +193,21 @@ public async Task CreateOrUpdate_CreatesARecoveryPlanWithTheGivenDetails() // invoke the operation string recoveryPlanName = "RPtest1"; - SiteRecoveryRecoveryPlanCreateOrUpdateContent content = new SiteRecoveryRecoveryPlanCreateOrUpdateContent(new SiteRecoveryCreateRecoveryPlanProperties(new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/cloud1"), new ResourceIdentifier("Microsoft Azure"), new SiteRecoveryPlanGroup[] + NullableResponse response = await collection.GetIfExistsAsync(recoveryPlanName); + SiteRecoveryRecoveryPlanResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new SiteRecoveryPlanGroup(RecoveryPlanGroupType.Boot) -{ -ReplicationProtectedItems = -{ -new RecoveryPlanProtectedItem() -{ -Id = new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/cloud1/replicationProtectionContainers/cloud_6d224fc6-f326-5d35-96de-fbf51efb3179/replicationProtectedItems/f8491e4f-817a-40dd-a90c-af773978c75b"), -VirtualMachineId = "f8491e4f-817a-40dd-a90c-af773978c75b", -} -}, -StartGroupActions = -{ -}, -EndGroupActions = -{ -}, -} - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - FailoverDeploymentModel = FailoverDeploymentModel.ResourceManager, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, recoveryPlanName, content); - SiteRecoveryRecoveryPlanResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryRecoveryPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryRecoveryPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryRecoveryPlanResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryRecoveryPlanResource.cs index 1e8626af27966..133e29ebbb960 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryRecoveryPlanResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryRecoveryPlanResource.cs @@ -96,66 +96,37 @@ public async Task Update_UpdatesTheGivenRecoveryPlan() SiteRecoveryRecoveryPlanResource siteRecoveryRecoveryPlan = client.GetSiteRecoveryRecoveryPlanResource(siteRecoveryRecoveryPlanResourceId); // invoke the operation - SiteRecoveryRecoveryPlanPatch patch = new SiteRecoveryRecoveryPlanPatch() + SiteRecoveryRecoveryPlanPatch patch = new SiteRecoveryRecoveryPlanPatch { - UpdateRecoveryPlanContentGroups = + UpdateRecoveryPlanContentGroups = {new SiteRecoveryPlanGroup(RecoveryPlanGroupType.Shutdown) { -new SiteRecoveryPlanGroup(RecoveryPlanGroupType.Shutdown) +ReplicationProtectedItems = {}, +StartGroupActions = {}, +EndGroupActions = {}, +}, new SiteRecoveryPlanGroup(RecoveryPlanGroupType.Failover) { -ReplicationProtectedItems = +ReplicationProtectedItems = {}, +StartGroupActions = {}, +EndGroupActions = {}, +}, new SiteRecoveryPlanGroup(RecoveryPlanGroupType.Boot) { -}, -StartGroupActions = -{ -}, -EndGroupActions = -{ -}, -},new SiteRecoveryPlanGroup(RecoveryPlanGroupType.Failover) -{ -ReplicationProtectedItems = -{ -}, -StartGroupActions = -{ -}, -EndGroupActions = -{ -}, -},new SiteRecoveryPlanGroup(RecoveryPlanGroupType.Boot) -{ -ReplicationProtectedItems = -{ -new RecoveryPlanProtectedItem() +ReplicationProtectedItems = {new RecoveryPlanProtectedItem { Id = new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/cloud1/replicationProtectionContainers/cloud_6d224fc6-f326-5d35-96de-fbf51efb3179/replicationProtectedItems/f8491e4f-817a-40dd-a90c-af773978c75b"), VirtualMachineId = "f8491e4f-817a-40dd-a90c-af773978c75b", -} -}, -StartGroupActions = -{ -}, -EndGroupActions = +}}, +StartGroupActions = {}, +EndGroupActions = {}, +}, new SiteRecoveryPlanGroup(RecoveryPlanGroupType.Boot) { -}, -},new SiteRecoveryPlanGroup(RecoveryPlanGroupType.Boot) -{ -ReplicationProtectedItems = -{ -new RecoveryPlanProtectedItem() +ReplicationProtectedItems = {new RecoveryPlanProtectedItem { Id = new ResourceIdentifier("/Subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/cloud1/replicationProtectionContainers/cloud_6d224fc6-f326-5d35-96de-fbf51efb3179/replicationProtectedItems/c0c14913-3d7a-48ea-9531-cc99e0e686e6"), VirtualMachineId = "c0c14913-3d7a-48ea-9531-cc99e0e686e6", -} -}, -StartGroupActions = -{ -}, -EndGroupActions = -{ -}, -} -}, +}}, +StartGroupActions = {}, +EndGroupActions = {}, +}}, }; ArmOperation lro = await siteRecoveryRecoveryPlan.UpdateAsync(WaitUntil.Completed, patch); SiteRecoveryRecoveryPlanResource result = lro.Value; @@ -255,10 +226,7 @@ public async Task PlannedFailover_ExecutePlannedFailoverOfTheRecoveryPlan() // invoke the operation RecoveryPlanPlannedFailoverContent content = new RecoveryPlanPlannedFailoverContent(new RecoveryPlanPlannedFailoverProperties(PossibleOperationsDirection.PrimaryToRecovery) { - ProviderSpecificDetails = -{ -new RecoveryPlanHyperVReplicaAzureFailoverContent() -}, + ProviderSpecificDetails = { new RecoveryPlanHyperVReplicaAzureFailoverContent() }, }); ArmOperation lro = await siteRecoveryRecoveryPlan.PlannedFailoverAsync(WaitUntil.Completed, content); SiteRecoveryRecoveryPlanResource result = lro.Value; @@ -327,10 +295,7 @@ public async Task TestFailover_ExecuteTestFailoverOfTheRecoveryPlan() RecoveryPlanTestFailoverContent content = new RecoveryPlanTestFailoverContent(new RecoveryPlanTestFailoverProperties(PossibleOperationsDirection.PrimaryToRecovery, "VmNetworkAsInput") { NetworkId = new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/siterecoveryProd1/providers/Microsoft.Network/virtualNetworks/vnetavrai"), - ProviderSpecificDetails = -{ -new RecoveryPlanHyperVReplicaAzureFailoverContent() -}, + ProviderSpecificDetails = { new RecoveryPlanHyperVReplicaAzureFailoverContent() }, }); ArmOperation lro = await siteRecoveryRecoveryPlan.TestFailoverAsync(WaitUntil.Completed, content); SiteRecoveryRecoveryPlanResource result = lro.Value; @@ -364,7 +329,7 @@ public async Task TestFailoverCleanup_ExecuteTestFailoverCleanupOfTheRecoveryPla SiteRecoveryRecoveryPlanResource siteRecoveryRecoveryPlan = client.GetSiteRecoveryRecoveryPlanResource(siteRecoveryRecoveryPlanResourceId); // invoke the operation - RecoveryPlanTestFailoverCleanupContent content = new RecoveryPlanTestFailoverCleanupContent(new RecoveryPlanTestFailoverCleanupProperties() + RecoveryPlanTestFailoverCleanupContent content = new RecoveryPlanTestFailoverCleanupContent(new RecoveryPlanTestFailoverCleanupProperties { Comments = "Test Failover Cleanup", }); @@ -402,10 +367,7 @@ public async Task UnplannedFailover_ExecuteUnplannedFailoverOfTheRecoveryPlan() // invoke the operation RecoveryPlanUnplannedFailoverContent content = new RecoveryPlanUnplannedFailoverContent(new RecoveryPlanUnplannedFailoverProperties(PossibleOperationsDirection.PrimaryToRecovery, SourceSiteOperation.Required) { - ProviderSpecificDetails = -{ -new RecoveryPlanHyperVReplicaAzureFailoverContent() -}, + ProviderSpecificDetails = { new RecoveryPlanHyperVReplicaAzureFailoverContent() }, }); ArmOperation lro = await siteRecoveryRecoveryPlan.UnplannedFailoverAsync(WaitUntil.Completed, content); SiteRecoveryRecoveryPlanResource result = lro.Value; diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryServicesProviderCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryServicesProviderCollection.cs index 686849788893a..b46954da0526a 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryServicesProviderCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryServicesProviderCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SiteRecoveryServicesProviderCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfRegisteredRecoveryServicesProvidersForTheFabric() + public async Task CreateOrUpdate_AddsARecoveryServicesProvider() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryServicesProviders_ListByReplicationFabrics.json - // this example is just showing the usage of "ReplicationRecoveryServicesProviders_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryServicesProviders_Create.json + // this example is just showing the usage of "ReplicationRecoveryServicesProviders_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,27 +30,27 @@ public async Task GetAll_GetsTheListOfRegisteredRecoveryServicesProvidersForTheF // this example assumes you already have this SiteRecoveryFabricResource created on azure // for more information of creating SiteRecoveryFabricResource, please refer to the document of SiteRecoveryFabricResource - string subscriptionId = "c183865e-6077-46f2-a3b1-deb0f4f4650a"; - string resourceGroupName = "resourceGroupPS1"; - string resourceName = "vault1"; - string fabricName = "cloud1"; + string subscriptionId = "cb53d0c3-bd59-4721-89bc-06916a9147ef"; + string resourceGroupName = "resourcegroup1"; + string resourceName = "migrationvault"; + string fabricName = "vmwarefabric1"; ResourceIdentifier siteRecoveryFabricResourceId = SiteRecoveryFabricResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, fabricName); SiteRecoveryFabricResource siteRecoveryFabric = client.GetSiteRecoveryFabricResource(siteRecoveryFabricResourceId); // get the collection of this SiteRecoveryServicesProviderResource SiteRecoveryServicesProviderCollection collection = siteRecoveryFabric.GetSiteRecoveryServicesProviders(); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryServicesProviderResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryServicesProviderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string providerName = "vmwareprovider1"; + SiteRecoveryServicesProviderCreateOrUpdateContent content = new SiteRecoveryServicesProviderCreateOrUpdateContent(new SiteRecoveryAddRecoveryServicesProviderProperties("vmwareprovider1", new IdentityProviderContent(Guid.Parse("72f988bf-86f1-41af-91ab-2d7cd011db47"), "f66fce08-c0c6-47a1-beeb-0ede5ea94f90", "141360b8-5686-4240-a027-5e24e6affeba", "https://microsoft.onmicrosoft.com/cf19e349-644c-4c6a-bcae-9c8f35357874", "https://login.microsoftonline.com"), new IdentityProviderContent(Guid.Parse("72f988bf-86f1-41af-91ab-2d7cd011db47"), "f66fce08-c0c6-47a1-beeb-0ede5ea94f90", "141360b8-5686-4240-a027-5e24e6affeba", "https://microsoft.onmicrosoft.com/cf19e349-644c-4c6a-bcae-9c8f35357874", "https://login.microsoftonline.com"))); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerName, content); + SiteRecoveryServicesProviderResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryServicesProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,6 +88,43 @@ public async Task Get_GetsTheDetailsOfARecoveryServicesProvider() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetsTheListOfRegisteredRecoveryServicesProvidersForTheFabric() + { + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryServicesProviders_ListByReplicationFabrics.json + // this example is just showing the usage of "ReplicationRecoveryServicesProviders_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SiteRecoveryFabricResource created on azure + // for more information of creating SiteRecoveryFabricResource, please refer to the document of SiteRecoveryFabricResource + string subscriptionId = "c183865e-6077-46f2-a3b1-deb0f4f4650a"; + string resourceGroupName = "resourceGroupPS1"; + string resourceName = "vault1"; + string fabricName = "cloud1"; + ResourceIdentifier siteRecoveryFabricResourceId = SiteRecoveryFabricResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, fabricName); + SiteRecoveryFabricResource siteRecoveryFabric = client.GetSiteRecoveryFabricResource(siteRecoveryFabricResourceId); + + // get the collection of this SiteRecoveryServicesProviderResource + SiteRecoveryServicesProviderCollection collection = siteRecoveryFabric.GetSiteRecoveryServicesProviders(); + + // invoke the operation and iterate over the result + await foreach (SiteRecoveryServicesProviderResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryServicesProviderData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetsTheDetailsOfARecoveryServicesProvider() @@ -161,42 +198,5 @@ public async Task GetIfExists_GetsTheDetailsOfARecoveryServicesProvider() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddsARecoveryServicesProvider() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryServicesProviders_Create.json - // this example is just showing the usage of "ReplicationRecoveryServicesProviders_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SiteRecoveryFabricResource created on azure - // for more information of creating SiteRecoveryFabricResource, please refer to the document of SiteRecoveryFabricResource - string subscriptionId = "cb53d0c3-bd59-4721-89bc-06916a9147ef"; - string resourceGroupName = "resourcegroup1"; - string resourceName = "migrationvault"; - string fabricName = "vmwarefabric1"; - ResourceIdentifier siteRecoveryFabricResourceId = SiteRecoveryFabricResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, fabricName); - SiteRecoveryFabricResource siteRecoveryFabric = client.GetSiteRecoveryFabricResource(siteRecoveryFabricResourceId); - - // get the collection of this SiteRecoveryServicesProviderResource - SiteRecoveryServicesProviderCollection collection = siteRecoveryFabric.GetSiteRecoveryServicesProviders(); - - // invoke the operation - string providerName = "vmwareprovider1"; - SiteRecoveryServicesProviderCreateOrUpdateContent content = new SiteRecoveryServicesProviderCreateOrUpdateContent(new SiteRecoveryAddRecoveryServicesProviderProperties("vmwareprovider1", new IdentityProviderContent(Guid.Parse("72f988bf-86f1-41af-91ab-2d7cd011db47"), "f66fce08-c0c6-47a1-beeb-0ede5ea94f90", "141360b8-5686-4240-a027-5e24e6affeba", "https://microsoft.onmicrosoft.com/cf19e349-644c-4c6a-bcae-9c8f35357874", "https://login.microsoftonline.com"), new IdentityProviderContent(Guid.Parse("72f988bf-86f1-41af-91ab-2d7cd011db47"), "f66fce08-c0c6-47a1-beeb-0ede5ea94f90", "141360b8-5686-4240-a027-5e24e6affeba", "https://microsoft.onmicrosoft.com/cf19e349-644c-4c6a-bcae-9c8f35357874", "https://login.microsoftonline.com"))); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerName, content); - SiteRecoveryServicesProviderResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryServicesProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryServicesProviderResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryServicesProviderResource.cs index fda3119adc4e8..4584b74c4be18 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryServicesProviderResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryServicesProviderResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesSiteRecovery.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Samples @@ -143,38 +142,5 @@ public async Task Delete_DeletesProviderFromFabricNoteDeletingProviderForAnyFabr Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSiteRecoveryServicesProviders_GetsTheListOfRegisteredRecoveryServicesProvidersInTheVaultThisIsAViewOnlyApi() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationRecoveryServicesProviders_List.json - // this example is just showing the usage of "ReplicationRecoveryServicesProviders_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "c183865e-6077-46f2-a3b1-deb0f4f4650a"; - string resourceGroupName = "resourceGroupPS1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - string resourceName = "vault1"; - await foreach (SiteRecoveryServicesProviderResource item in resourceGroupResource.GetSiteRecoveryServicesProvidersAsync(resourceName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryServicesProviderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVCenterCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVCenterCollection.cs index da1f58970e054..819790a7a642a 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVCenterCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVCenterCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SiteRecoveryVCenterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfVCenterRegisteredUnderAFabric() + public async Task CreateOrUpdate_AddVCenter() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationvCenters_ListByReplicationFabrics.json - // this example is just showing the usage of "ReplicationvCenters_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationvCenters_Create.json + // this example is just showing the usage of "ReplicationvCenters_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,27 @@ public async Task GetAll_GetsTheListOfVCenterRegisteredUnderAFabric() // get the collection of this SiteRecoveryVCenterResource SiteRecoveryVCenterCollection collection = siteRecoveryFabric.GetSiteRecoveryVCenters(); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryVCenterResource item in collection.GetAllAsync()) + // invoke the operation + string vCenterName = "esx-78"; + SiteRecoveryVCenterCreateOrUpdateContent content = new SiteRecoveryVCenterCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryVCenterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new SiteRecoveryAddVCenterProperties + { + FriendlyName = "esx-78", + IPAddress = IPAddress.Parse("inmtest78"), + ProcessServerId = Guid.Parse("5A720CAB-39CB-F445-BD1662B0B33164B5"), + Port = "443", + RunAsAccountId = "2", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vCenterName, content); + SiteRecoveryVCenterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryVCenterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +101,10 @@ public async Task Get_GetsTheDetailsOfAVCenter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheDetailsOfAVCenter() + public async Task GetAll_GetsTheListOfVCenterRegisteredUnderAFabric() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationvCenters_Get.json - // this example is just showing the usage of "ReplicationvCenters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationvCenters_ListByReplicationFabrics.json + // this example is just showing the usage of "ReplicationvCenters_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +123,22 @@ public async Task Exists_GetsTheDetailsOfAVCenter() // get the collection of this SiteRecoveryVCenterResource SiteRecoveryVCenterCollection collection = siteRecoveryFabric.GetSiteRecoveryVCenters(); - // invoke the operation - string vCenterName = "esx-78"; - bool result = await collection.ExistsAsync(vCenterName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryVCenterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryVCenterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheDetailsOfAVCenter() + public async Task Exists_GetsTheDetailsOfAVCenter() { // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationvCenters_Get.json // this example is just showing the usage of "ReplicationvCenters_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +162,17 @@ public async Task GetIfExists_GetsTheDetailsOfAVCenter() // invoke the operation string vCenterName = "esx-78"; - NullableResponse response = await collection.GetIfExistsAsync(vCenterName); - SiteRecoveryVCenterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vCenterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryVCenterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddVCenter() + public async Task GetIfExists_GetsTheDetailsOfAVCenter() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationvCenters_Create.json - // this example is just showing the usage of "ReplicationvCenters_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationvCenters_Get.json + // this example is just showing the usage of "ReplicationvCenters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,25 +193,21 @@ public async Task CreateOrUpdate_AddVCenter() // invoke the operation string vCenterName = "esx-78"; - SiteRecoveryVCenterCreateOrUpdateContent content = new SiteRecoveryVCenterCreateOrUpdateContent() - { - Properties = new SiteRecoveryAddVCenterProperties() - { - FriendlyName = "esx-78", - IPAddress = IPAddress.Parse("inmtest78"), - ProcessServerId = Guid.Parse("5A720CAB-39CB-F445-BD1662B0B33164B5"), - Port = "443", - RunAsAccountId = "2", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vCenterName, content); - SiteRecoveryVCenterResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(vCenterName); + SiteRecoveryVCenterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryVCenterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryVCenterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVCenterResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVCenterResource.cs index aafd8813262a6..4c94af298a12b 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVCenterResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVCenterResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesSiteRecovery.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Samples @@ -101,9 +100,9 @@ public async Task Update_UpdateVCenterOperation() SiteRecoveryVCenterResource siteRecoveryVCenter = client.GetSiteRecoveryVCenterResource(siteRecoveryVCenterResourceId); // invoke the operation - SiteRecoveryVCenterPatch patch = new SiteRecoveryVCenterPatch() + SiteRecoveryVCenterPatch patch = new SiteRecoveryVCenterPatch { - Properties = new SiteRecoveryUpdateVCenterProperties() + Properties = new SiteRecoveryUpdateVCenterProperties { IPAddress = IPAddress.Parse("10.150.109.25"), }, @@ -117,38 +116,5 @@ public async Task Update_UpdateVCenterOperation() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSiteRecoveryVCenters_GetsTheListOfVCenterRegisteredUnderTheVault() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationvCenters_List.json - // this example is just showing the usage of "ReplicationvCenters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "7c943c1b-5122-4097-90c8-861411bdd574"; - string resourceGroupName = "MadhaviVRG"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - string resourceName = "MadhaviVault"; - await foreach (SiteRecoveryVCenterResource item in resourceGroupResource.GetSiteRecoveryVCentersAsync(resourceName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryVCenterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVaultSettingCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVaultSettingCollection.cs index cebc39b21dc37..08a94531a9b4f 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVaultSettingCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVaultSettingCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SiteRecoveryVaultSettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfVaultSetting() + public async Task CreateOrUpdate_UpdatesVaultSettingAVaultSettingObjectIsASingletonPerVaultAndItIsAlwaysPresentByDefault() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationVaultSetting_List.json - // this example is just showing the usage of "ReplicationVaultSetting_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationVaultSetting_Create.json + // this example is just showing the usage of "ReplicationVaultSetting_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_GetsTheListOfVaultSetting() string resourceName = "vault1"; SiteRecoveryVaultSettingCollection collection = resourceGroupResource.GetSiteRecoveryVaultSettings(resourceName); - // invoke the operation and iterate over the result - await foreach (SiteRecoveryVaultSettingResource item in collection.GetAllAsync()) + // invoke the operation + string vaultSettingName = "default"; + SiteRecoveryVaultSettingCreateOrUpdateContent content = new SiteRecoveryVaultSettingCreateOrUpdateContent(new VaultSettingCreationProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryVaultSettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + MigrationSolutionId = new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.Migrate/MigrateProjects/resourceGroupPS1-MigrateProject/Solutions/Servers-Migration-ServerMigration"), + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultSettingName, content); + SiteRecoveryVaultSettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryVaultSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_GetsTheVaultSetting() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheVaultSetting() + public async Task GetAll_GetsTheListOfVaultSetting() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationVaultSetting_Get.json - // this example is just showing the usage of "ReplicationVaultSetting_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationVaultSetting_List.json + // this example is just showing the usage of "ReplicationVaultSetting_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +113,22 @@ public async Task Exists_GetsTheVaultSetting() string resourceName = "vault1"; SiteRecoveryVaultSettingCollection collection = resourceGroupResource.GetSiteRecoveryVaultSettings(resourceName); - // invoke the operation - string vaultSettingName = "default"; - bool result = await collection.ExistsAsync(vaultSettingName); + // invoke the operation and iterate over the result + await foreach (SiteRecoveryVaultSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryVaultSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheVaultSetting() + public async Task Exists_GetsTheVaultSetting() { // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationVaultSetting_Get.json // this example is just showing the usage of "ReplicationVaultSetting_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +151,17 @@ public async Task GetIfExists_GetsTheVaultSetting() // invoke the operation string vaultSettingName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(vaultSettingName); - SiteRecoveryVaultSettingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vaultSettingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryVaultSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatesVaultSettingAVaultSettingObjectIsASingletonPerVaultAndItIsAlwaysPresentByDefault() + public async Task GetIfExists_GetsTheVaultSetting() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationVaultSetting_Create.json - // this example is just showing the usage of "ReplicationVaultSetting_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationVaultSetting_Get.json + // this example is just showing the usage of "ReplicationVaultSetting_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,18 +181,21 @@ public async Task CreateOrUpdate_UpdatesVaultSettingAVaultSettingObjectIsASingle // invoke the operation string vaultSettingName = "default"; - SiteRecoveryVaultSettingCreateOrUpdateContent content = new SiteRecoveryVaultSettingCreateOrUpdateContent(new VaultSettingCreationProperties() - { - MigrationSolutionId = new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.Migrate/MigrateProjects/resourceGroupPS1-MigrateProject/Solutions/Servers-Migration-ServerMigration"), - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultSettingName, content); - SiteRecoveryVaultSettingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(vaultSettingName); + SiteRecoveryVaultSettingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteRecoveryVaultSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteRecoveryVaultSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVaultSettingResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVaultSettingResource.cs index 24c9efb3d179f..c0b3347046490 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVaultSettingResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_SiteRecoveryVaultSettingResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdatesVaultSettingAVaultSettingObjectIsASingletonPerVa SiteRecoveryVaultSettingResource siteRecoveryVaultSetting = client.GetSiteRecoveryVaultSettingResource(siteRecoveryVaultSettingResourceId); // invoke the operation - SiteRecoveryVaultSettingCreateOrUpdateContent content = new SiteRecoveryVaultSettingCreateOrUpdateContent(new VaultSettingCreationProperties() + SiteRecoveryVaultSettingCreateOrUpdateContent content = new SiteRecoveryVaultSettingCreateOrUpdateContent(new VaultSettingCreationProperties { MigrationSolutionId = new ResourceIdentifier("/subscriptions/c183865e-6077-46f2-a3b1-deb0f4f4650a/resourceGroups/resourceGroupPS1/providers/Microsoft.Migrate/MigrateProjects/resourceGroupPS1-MigrateProject/Solutions/Servers-Migration-ServerMigration"), }); diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationCollection.cs index 1aa231315b238..6bbc82ff31c8a 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_StorageClassificationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfStorageClassificationObjectsUnderAFabric() + public async Task Get_GetsTheDetailsOfAStorageClassification() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassifications_ListByReplicationFabrics.json - // this example is just showing the usage of "ReplicationStorageClassifications_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassifications_Get.json + // this example is just showing the usage of "ReplicationStorageClassifications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetsTheListOfStorageClassificationObjectsUnderAFabric() // get the collection of this StorageClassificationResource StorageClassificationCollection collection = siteRecoveryFabric.GetStorageClassifications(); - // invoke the operation and iterate over the result - await foreach (StorageClassificationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageClassificationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string storageClassificationName = "8891569e-aaef-4a46-a4a0-78c14f2d7b09"; + StorageClassificationResource result = await collection.GetAsync(storageClassificationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageClassificationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheDetailsOfAStorageClassification() + public async Task GetAll_GetsTheListOfStorageClassificationObjectsUnderAFabric() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassifications_Get.json - // this example is just showing the usage of "ReplicationStorageClassifications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassifications_ListByReplicationFabrics.json + // this example is just showing the usage of "ReplicationStorageClassifications_ListByReplicationFabrics" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetsTheDetailsOfAStorageClassification() // get the collection of this StorageClassificationResource StorageClassificationCollection collection = siteRecoveryFabric.GetStorageClassifications(); - // invoke the operation - string storageClassificationName = "8891569e-aaef-4a46-a4a0-78c14f2d7b09"; - StorageClassificationResource result = await collection.GetAsync(storageClassificationName); + // invoke the operation and iterate over the result + await foreach (StorageClassificationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageClassificationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageClassificationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationMappingCollection.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationMappingCollection.cs index 2de6c03bb2ecf..9af19abc40815 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationMappingCollection.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationMappingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageClassificationMappingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfStorageClassificationMappingsObjectsUnderAStorage() + public async Task CreateOrUpdate_CreateStorageClassificationMapping() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_ListByReplicationStorageClassifications.json - // this example is just showing the usage of "ReplicationStorageClassificationMappings_ListByReplicationStorageClassifications" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_Create.json + // this example is just showing the usage of "ReplicationStorageClassificationMappings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,20 @@ public async Task GetAll_GetsTheListOfStorageClassificationMappingsObjectsUnderA // get the collection of this StorageClassificationMappingResource StorageClassificationMappingCollection collection = storageClassification.GetStorageClassificationMappings(); - // invoke the operation and iterate over the result - await foreach (StorageClassificationMappingResource item in collection.GetAllAsync()) + // invoke the operation + string storageClassificationMappingName = "testStorageMapping"; + StorageClassificationMappingCreateOrUpdateContent content = new StorageClassificationMappingCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageClassificationMappingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TargetStorageClassificationId = new ResourceIdentifier("/Subscriptions/9112a37f-0f3e-46ec-9c00-060c6edca071/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/2a48e3770ac08aa2be8bfbd94fcfb1cbf2dcc487b78fb9d3bd778304441b06a0/replicationStorageClassifications/8891569e-aaef-4a46-a4a0-78c14f2d7b09"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageClassificationMappingName, content); + StorageClassificationMappingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageClassificationMappingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +95,10 @@ public async Task Get_GetsTheDetailsOfAStorageClassificationMapping() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheDetailsOfAStorageClassificationMapping() + public async Task GetAll_GetsTheListOfStorageClassificationMappingsObjectsUnderAStorage() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_Get.json - // this example is just showing the usage of "ReplicationStorageClassificationMappings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_ListByReplicationStorageClassifications.json + // this example is just showing the usage of "ReplicationStorageClassificationMappings_ListByReplicationStorageClassifications" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +118,22 @@ public async Task Exists_GetsTheDetailsOfAStorageClassificationMapping() // get the collection of this StorageClassificationMappingResource StorageClassificationMappingCollection collection = storageClassification.GetStorageClassificationMappings(); - // invoke the operation - string storageClassificationMappingName = "testStorageMapping"; - bool result = await collection.ExistsAsync(storageClassificationMappingName); + // invoke the operation and iterate over the result + await foreach (StorageClassificationMappingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageClassificationMappingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheDetailsOfAStorageClassificationMapping() + public async Task Exists_GetsTheDetailsOfAStorageClassificationMapping() { // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_Get.json // this example is just showing the usage of "ReplicationStorageClassificationMappings_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +158,17 @@ public async Task GetIfExists_GetsTheDetailsOfAStorageClassificationMapping() // invoke the operation string storageClassificationMappingName = "testStorageMapping"; - NullableResponse response = await collection.GetIfExistsAsync(storageClassificationMappingName); - StorageClassificationMappingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(storageClassificationMappingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageClassificationMappingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateStorageClassificationMapping() + public async Task GetIfExists_GetsTheDetailsOfAStorageClassificationMapping() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_Create.json - // this example is just showing the usage of "ReplicationStorageClassificationMappings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_Get.json + // this example is just showing the usage of "ReplicationStorageClassificationMappings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,18 +190,21 @@ public async Task CreateOrUpdate_CreateStorageClassificationMapping() // invoke the operation string storageClassificationMappingName = "testStorageMapping"; - StorageClassificationMappingCreateOrUpdateContent content = new StorageClassificationMappingCreateOrUpdateContent() - { - TargetStorageClassificationId = new ResourceIdentifier("/Subscriptions/9112a37f-0f3e-46ec-9c00-060c6edca071/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/2a48e3770ac08aa2be8bfbd94fcfb1cbf2dcc487b78fb9d3bd778304441b06a0/replicationStorageClassifications/8891569e-aaef-4a46-a4a0-78c14f2d7b09"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageClassificationMappingName, content); - StorageClassificationMappingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(storageClassificationMappingName); + StorageClassificationMappingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageClassificationMappingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageClassificationMappingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationMappingResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationMappingResource.cs index 9169220d5559b..a3c93980b2fba 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationMappingResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationMappingResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RecoveryServicesSiteRecovery.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Samples @@ -52,10 +51,10 @@ public async Task Get_GetsTheDetailsOfAStorageClassificationMapping() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateStorageClassificationMapping() + public async Task Delete_DeleteAStorageClassificationMapping() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_Create.json - // this example is just showing the usage of "ReplicationStorageClassificationMappings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_Delete.json + // this example is just showing the usage of "ReplicationStorageClassificationMappings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,26 +73,17 @@ public async Task Update_CreateStorageClassificationMapping() StorageClassificationMappingResource storageClassificationMapping = client.GetStorageClassificationMappingResource(storageClassificationMappingResourceId); // invoke the operation - StorageClassificationMappingCreateOrUpdateContent content = new StorageClassificationMappingCreateOrUpdateContent() - { - TargetStorageClassificationId = new ResourceIdentifier("/Subscriptions/9112a37f-0f3e-46ec-9c00-060c6edca071/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/2a48e3770ac08aa2be8bfbd94fcfb1cbf2dcc487b78fb9d3bd778304441b06a0/replicationStorageClassifications/8891569e-aaef-4a46-a4a0-78c14f2d7b09"), - }; - ArmOperation lro = await storageClassificationMapping.UpdateAsync(WaitUntil.Completed, content); - StorageClassificationMappingResource result = lro.Value; + await storageClassificationMapping.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageClassificationMappingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAStorageClassificationMapping() + public async Task Update_CreateStorageClassificationMapping() { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_Delete.json - // this example is just showing the usage of "ReplicationStorageClassificationMappings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_Create.json + // this example is just showing the usage of "ReplicationStorageClassificationMappings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,42 +102,18 @@ public async Task Delete_DeleteAStorageClassificationMapping() StorageClassificationMappingResource storageClassificationMapping = client.GetStorageClassificationMappingResource(storageClassificationMappingResourceId); // invoke the operation - await storageClassificationMapping.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetStorageClassificationMappings_GetsTheListOfStorageClassificationMappingsObjectsUnderAVault() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassificationMappings_List.json - // this example is just showing the usage of "ReplicationStorageClassificationMappings_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "9112a37f-0f3e-46ec-9c00-060c6edca071"; - string resourceGroupName = "resourceGroupPS1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - string resourceName = "vault1"; - await foreach (StorageClassificationMappingResource item in resourceGroupResource.GetStorageClassificationMappingsAsync(resourceName)) + StorageClassificationMappingCreateOrUpdateContent content = new StorageClassificationMappingCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageClassificationMappingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TargetStorageClassificationId = new ResourceIdentifier("/Subscriptions/9112a37f-0f3e-46ec-9c00-060c6edca071/resourceGroups/resourceGroupPS1/providers/Microsoft.RecoveryServices/vaults/vault1/replicationFabrics/2a48e3770ac08aa2be8bfbd94fcfb1cbf2dcc487b78fb9d3bd778304441b06a0/replicationStorageClassifications/8891569e-aaef-4a46-a4a0-78c14f2d7b09"), + }; + ArmOperation lro = await storageClassificationMapping.UpdateAsync(WaitUntil.Completed, content); + StorageClassificationMappingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageClassificationMappingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationResource.cs b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationResource.cs index 1c70a08601eae..cffeec0d09166 100644 --- a/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationResource.cs +++ b/sdk/recoveryservices-siterecovery/Azure.ResourceManager.RecoveryServicesSiteRecovery/samples/Generated/Samples/Sample_StorageClassificationResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServicesSiteRecovery.Samples @@ -47,38 +46,5 @@ public async Task Get_GetsTheDetailsOfAStorageClassification() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetStorageClassifications_GetsTheListOfStorageClassificationObjectsUnderAVault() - { - // Generated from example definition: specification/recoveryservicessiterecovery/resource-manager/Microsoft.RecoveryServices/stable/2023-08-01/examples/ReplicationStorageClassifications_List.json - // this example is just showing the usage of "ReplicationStorageClassifications_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "9112a37f-0f3e-46ec-9c00-060c6edca071"; - string resourceGroupName = "resourceGroupPS1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - string resourceName = "vault1"; - await foreach (StorageClassificationResource item in resourceGroupResource.GetStorageClassificationsAsync(resourceName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageClassificationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesPrivateLinkResourceCollection.cs b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesPrivateLinkResourceCollection.cs index 16e53091c1d49..6770e4278bb40 100644 --- a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesPrivateLinkResourceCollection.cs +++ b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RecoveryServicesPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateLinkResources() + public async Task Get_GetPrivateLinkResource() { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/ListPrivateLinkResources.json - // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/GetPrivateLinkResources.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListPrivateLinkResources() // get the collection of this RecoveryServicesPrivateLinkResource RecoveryServicesPrivateLinkResourceCollection collection = recoveryServicesVault.GetRecoveryServicesPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (RecoveryServicesPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoveryServicesPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateLinkResourceName = "backupResource"; + RecoveryServicesPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoveryServicesPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateLinkResource() + public async Task GetAll_ListPrivateLinkResources() { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/GetPrivateLinkResources.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/ListPrivateLinkResources.json + // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetPrivateLinkResource() // get the collection of this RecoveryServicesPrivateLinkResource RecoveryServicesPrivateLinkResourceCollection collection = recoveryServicesVault.GetRecoveryServicesPrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "backupResource"; - RecoveryServicesPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (RecoveryServicesPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoveryServicesPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoveryServicesPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultCollection.cs b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultCollection.cs index c384d5ef17b98..acefbe01c0c59 100644 --- a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultCollection.cs +++ b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_RecoveryServicesVaultCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfRecoveryServicesResourcesInResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateRecoveryServicesVault() { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/ListResources.json - // this example is just showing the usage of "Vaults_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/PUTVault.json + // this example is just showing the usage of "Vaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,33 @@ public async Task GetAll_ListOfRecoveryServicesResourcesInResourceGroup() // get the collection of this RecoveryServicesVaultResource RecoveryServicesVaultCollection collection = resourceGroupResource.GetRecoveryServicesVaults(); - // invoke the operation and iterate over the result - await foreach (RecoveryServicesVaultResource item in collection.GetAllAsync()) + // invoke the operation + string vaultName = "swaggerExample"; + RecoveryServicesVaultData data = new RecoveryServicesVaultData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoveryServicesVaultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("SystemAssigned"), + Properties = new RecoveryServicesVaultProperties + { + PublicNetworkAccess = VaultPublicNetworkAccess.Enabled, + }, + Sku = new RecoveryServicesSku(RecoveryServicesSkuName.Standard), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); + RecoveryServicesVaultResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoveryServicesVaultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRecoveryServicesResource() + public async Task CreateOrUpdate_CreateOrUpdateVaultWithMonitoringSetting() { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/GETVault.json - // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/PUTVault_WithMonitoringSettings.json + // this example is just showing the usage of "Vaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +85,22 @@ public async Task Get_GetRecoveryServicesResource() // invoke the operation string vaultName = "swaggerExample"; - RecoveryServicesVaultResource result = await collection.GetAsync(vaultName); + RecoveryServicesVaultData data = new RecoveryServicesVaultData(new AzureLocation("West US")) + { + Identity = new ManagedServiceIdentity("SystemAssigned"), + Properties = new RecoveryServicesVaultProperties + { + PublicNetworkAccess = VaultPublicNetworkAccess.Enabled, + MonitoringSettings = new VaultMonitoringSettings + { + AzureMonitorAlertAlertsForAllJobFailures = RecoveryServicesAlertsState.Enabled, + ClassicAlertAlertsForCriticalOperations = RecoveryServicesAlertsState.Disabled, + }, + }, + Sku = new RecoveryServicesSku(RecoveryServicesSkuName.Standard), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); + RecoveryServicesVaultResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +111,10 @@ public async Task Get_GetRecoveryServicesResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRecoveryServicesResource() + public async Task CreateOrUpdate_CreateOrUpdateVaultWithCustomerManagedKeys() { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/GETVault.json - // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/PUTVault_WithCMK.json + // this example is just showing the usage of "Vaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,17 +133,46 @@ public async Task Exists_GetRecoveryServicesResource() // invoke the operation string vaultName = "swaggerExample"; - bool result = await collection.ExistsAsync(vaultName); + RecoveryServicesVaultData data = new RecoveryServicesVaultData(new AzureLocation("West US")) + { + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi")] = new UserAssignedIdentity() +}, + }, + Properties = new RecoveryServicesVaultProperties + { + Encryption = new VaultPropertiesEncryption + { + KeyUri = new Uri("https://cmk2xkv.vault.azure.net/keys/Key1/0767b348bb1a4c07baa6c4ec0055d2b3"), + KekIdentity = new CmkKekIdentity + { + UserAssignedIdentity = new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi"), + }, + InfrastructureEncryption = InfrastructureEncryptionState.Enabled, + }, + PublicNetworkAccess = VaultPublicNetworkAccess.Enabled, + }, + Sku = new RecoveryServicesSku(RecoveryServicesSkuName.Standard), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); + RecoveryServicesVaultResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoveryServicesVaultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRecoveryServicesResource() + public async Task CreateOrUpdate_CreateOrUpdateVaultWithUserAssignedIdentity() { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/GETVault.json - // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/PUTVault_WithUserAssignedIdentity.json + // this example is just showing the usage of "Vaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,29 +191,37 @@ public async Task GetIfExists_GetRecoveryServicesResource() // invoke the operation string vaultName = "swaggerExample"; - NullableResponse response = await collection.GetIfExistsAsync(vaultName); - RecoveryServicesVaultResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + RecoveryServicesVaultData data = new RecoveryServicesVaultData(new AzureLocation("West US")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoveryServicesVaultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi")] = new UserAssignedIdentity() +}, + }, + Properties = new RecoveryServicesVaultProperties + { + PublicNetworkAccess = VaultPublicNetworkAccess.Enabled, + }, + Sku = new RecoveryServicesSku(RecoveryServicesSkuName.Standard), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); + RecoveryServicesVaultResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoveryServicesVaultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRecoveryServicesVault() + public async Task Get_GetRecoveryServicesResource() { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/PUTVault.json - // this example is just showing the usage of "Vaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/GETVault.json + // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +240,7 @@ public async Task CreateOrUpdate_CreateOrUpdateRecoveryServicesVault() // invoke the operation string vaultName = "swaggerExample"; - RecoveryServicesVaultData data = new RecoveryServicesVaultData(new AzureLocation("West US")) - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - Properties = new RecoveryServicesVaultProperties() - { - PublicNetworkAccess = VaultPublicNetworkAccess.Enabled, - }, - Sku = new RecoveryServicesSku(RecoveryServicesSkuName.Standard), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); - RecoveryServicesVaultResource result = lro.Value; + RecoveryServicesVaultResource result = await collection.GetAsync(vaultName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -201,10 +251,10 @@ public async Task CreateOrUpdate_CreateOrUpdateRecoveryServicesVault() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateVaultWithMonitoringSetting() + public async Task GetAll_ListOfRecoveryServicesResourcesInResourceGroup() { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/PUTVault_WithMonitoringSettings.json - // this example is just showing the usage of "Vaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/ListResources.json + // this example is just showing the usage of "Vaults_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -221,38 +271,25 @@ public async Task CreateOrUpdate_CreateOrUpdateVaultWithMonitoringSetting() // get the collection of this RecoveryServicesVaultResource RecoveryServicesVaultCollection collection = resourceGroupResource.GetRecoveryServicesVaults(); - // invoke the operation - string vaultName = "swaggerExample"; - RecoveryServicesVaultData data = new RecoveryServicesVaultData(new AzureLocation("West US")) + // invoke the operation and iterate over the result + await foreach (RecoveryServicesVaultResource item in collection.GetAllAsync()) { - Identity = new ManagedServiceIdentity("SystemAssigned"), - Properties = new RecoveryServicesVaultProperties() - { - PublicNetworkAccess = VaultPublicNetworkAccess.Enabled, - MonitoringSettings = new VaultMonitoringSettings() - { - AzureMonitorAlertAlertsForAllJobFailures = RecoveryServicesAlertsState.Enabled, - ClassicAlertAlertsForCriticalOperations = RecoveryServicesAlertsState.Disabled, - }, - }, - Sku = new RecoveryServicesSku(RecoveryServicesSkuName.Standard), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); - RecoveryServicesVaultResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoveryServicesVaultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoveryServicesVaultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateVaultWithCustomerManagedKeys() + public async Task Exists_GetRecoveryServicesResource() { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/PUTVault_WithCMK.json - // this example is just showing the usage of "Vaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/GETVault.json + // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -271,46 +308,17 @@ public async Task CreateOrUpdate_CreateOrUpdateVaultWithCustomerManagedKeys() // invoke the operation string vaultName = "swaggerExample"; - RecoveryServicesVaultData data = new RecoveryServicesVaultData(new AzureLocation("West US")) - { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi")] = new UserAssignedIdentity(), -}, - }, - Properties = new RecoveryServicesVaultProperties() - { - Encryption = new VaultPropertiesEncryption() - { - KeyUri = new Uri("https://cmk2xkv.vault.azure.net/keys/Key1/0767b348bb1a4c07baa6c4ec0055d2b3"), - KekIdentity = new CmkKekIdentity() - { - UserAssignedIdentity = new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi"), - }, - InfrastructureEncryption = InfrastructureEncryptionState.Enabled, - }, - PublicNetworkAccess = VaultPublicNetworkAccess.Enabled, - }, - Sku = new RecoveryServicesSku(RecoveryServicesSkuName.Standard), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); - RecoveryServicesVaultResource result = lro.Value; + bool result = await collection.ExistsAsync(vaultName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoveryServicesVaultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateVaultWithUserAssignedIdentity() + public async Task GetIfExists_GetRecoveryServicesResource() { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/PUTVault_WithUserAssignedIdentity.json - // this example is just showing the usage of "Vaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/GETVault.json + // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -329,29 +337,21 @@ public async Task CreateOrUpdate_CreateOrUpdateVaultWithUserAssignedIdentity() // invoke the operation string vaultName = "swaggerExample"; - RecoveryServicesVaultData data = new RecoveryServicesVaultData(new AzureLocation("West US")) - { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi")] = new UserAssignedIdentity(), -}, - }, - Properties = new RecoveryServicesVaultProperties() - { - PublicNetworkAccess = VaultPublicNetworkAccess.Enabled, - }, - Sku = new RecoveryServicesSku(RecoveryServicesSkuName.Standard), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, data); - RecoveryServicesVaultResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(vaultName); + RecoveryServicesVaultResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoveryServicesVaultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoveryServicesVaultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultExtendedInfoResource.cs b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultExtendedInfoResource.cs index 67fafdc0d37d6..6d6045c535c25 100644 --- a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultExtendedInfoResource.cs +++ b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultExtendedInfoResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetExtendedInfoOfResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutExtendedInfoOfResource() + public async Task Update_PATCHExtendedInfoOfResource() { // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/UpdateVaultExtendedInfo.json - // this example is just showing the usage of "VaultExtendedInfo_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // this example is just showing the usage of "VaultExtendedInfo_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,8 +67,7 @@ public async Task CreateOrUpdate_PutExtendedInfoOfResource() // invoke the operation RecoveryServicesVaultExtendedInfoData info = new RecoveryServicesVaultExtendedInfoData(); - ArmOperation lro = await recoveryServicesVaultExtendedInfo.CreateOrUpdateAsync(WaitUntil.Completed, info); - RecoveryServicesVaultExtendedInfoResource result = lro.Value; + RecoveryServicesVaultExtendedInfoResource result = await recoveryServicesVaultExtendedInfo.UpdateAsync(info); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -79,10 +78,10 @@ public async Task CreateOrUpdate_PutExtendedInfoOfResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PATCHExtendedInfoOfResource() + public async Task CreateOrUpdate_PutExtendedInfoOfResource() { // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/UpdateVaultExtendedInfo.json - // this example is just showing the usage of "VaultExtendedInfo_Update" operation, for the dependent resources, they will have to be created separately. + // this example is just showing the usage of "VaultExtendedInfo_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,7 +98,8 @@ public async Task Update_PATCHExtendedInfoOfResource() // invoke the operation RecoveryServicesVaultExtendedInfoData info = new RecoveryServicesVaultExtendedInfoData(); - RecoveryServicesVaultExtendedInfoResource result = await recoveryServicesVaultExtendedInfo.UpdateAsync(info); + ArmOperation lro = await recoveryServicesVaultExtendedInfo.CreateOrUpdateAsync(WaitUntil.Completed, info); + RecoveryServicesVaultExtendedInfoResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultResource.cs b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultResource.cs index 6558ee9fba876..fae92e65dca7e 100644 --- a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultResource.cs +++ b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_RecoveryServicesVaultResource.cs @@ -6,140 +6,18 @@ #nullable disable using System; +using System.Text; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.RecoveryServices.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RecoveryServices.Samples { public partial class Sample_RecoveryServicesVaultResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateVaultCertificate_DownloadVaultCredentialFile() - { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/PUTVaultCred.json - // this example is just showing the usage of "VaultCertificates_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this RecoveryServicesVaultResource created on azure - // for more information of creating RecoveryServicesVaultResource, please refer to the document of RecoveryServicesVaultResource - string subscriptionId = "77777777-d41f-4550-9f70-7708a3a2283b"; - string resourceGroupName = "BCDRIbzRG"; - string vaultName = "BCDRIbzVault"; - ResourceIdentifier recoveryServicesVaultResourceId = RecoveryServicesVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); - RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); - - // invoke the operation - string certificateName = "BCDRIbzVault77777777-d41f-4550-9f70-7708a3a2283b-12-18-2017-vaultcredentials"; - RecoveryServicesCertificateContent content = new RecoveryServicesCertificateContent() - { - Properties = new RawCertificateData() - { - AuthType = RecoveryServicesAuthType.Aad, - Certificate = Convert.FromBase64String("TUlJRE5EQ0NBaHlnQXdJQkFnSVFDYUxFKzVTSlNVeWdncDM0VS9HUm9qQU5CZ2txaGtpRzl3MEJBUXNGQURBWE1SVXdFd1lEVlFRREV3eGhiV05vWVc1a2JpNWpiMjB3SGhjTk1qSXhNREkwTVRJd05qRTRXaGNOTWpNeE1ESTBNVEl4TmpFNFdqQVhNUlV3RXdZRFZRUURFd3hoYldOb1lXNWtiaTVqYjIwd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUUN4cFpwS293a2p4VU9VWkpLT2JvdGdPWXkzaW9UVkxMMmZyaW9nZVN1Qm5IMWw3aVdQWW9kUHRoWS8yVmh6ZFVUckNXL25pNUh3b0JHYzZMMHF6UGlBWXpHek94RmpMQjZjdFNkbm9nL1A4eEV2OGE0cnJWZlBZdS9INStoTGx3N0RubXlTNWs4TU9sSVhUemVWNkxZV2I2RWlpTFppc0k1R3lLU1liemNaQmJKdnhLTVdGdHRCV08xZUwzUWNUejlpb1VGQzVnRlFKQzg3YXFkeDR1Wk9WYzRLM3Ixb09sTFBKdmRLN25YU3VWci9ZOC80ZHhCdDJZUTRia0hjM2EzcUNBbTZrV0QzamRiajhCZmhlWWNVNjFFZ3llVFV2MlI4dzRubWJqVXZxRW05cDZtTG4xMTdEWWpQTHNFODVTL0FpQmF0dkNhQ3hCZ0lxb1N1blBOUkFnTUJBQUdqZkRCNk1BNEdBMVVkRHdFQi93UUVBd0lGb0RBSkJnTlZIUk1FQWpBQU1CMEdBMVVkSlFRV01CUUdDQ3NHQVFVRkJ3TUJCZ2dyQmdFRkJRY0RBakFmQmdOVkhTTUVHREFXZ0JRR1NZcDJMUTJwOE5wMHUzRThJZDdRUjRTQXBqQWRCZ05WSFE0RUZnUVVCa21LZGkwTnFmRGFkTHR4UENIZTBFZUVnS1l3RFFZSktvWklodmNOQVFFTEJRQURnZ0VCQUp2ZG9yRmJ4cExZaUhYRHpnR001WmxMWTRDZE1LYW5BdzVDZDNFVnhDbkhtT05ISnpLRmpzdHZjdUN1TDZ2S1ptci9abm5ENXNLUnE0d0xnTXV6dlNXNGtQTXlWeENrYzdVYnNZSWJCSXNIUDl3cUNmcUY5aG5LSE9YZFJJV2tBVXhnbmYxSlpLZjR1NlpTSzZ3dExaME9VT0c5Mmd3SlB2eW5PVmJoeWpqczdQTVpONEw1djZyeHJkRWp0WG5sYzIvRDlnS0NOTFhFZHdRM0dzS05ZTGZvYy9DT3JmbEIrRHVPSThrVzM0WmxzYlFHelgyQ3ArWVVlSDNrQlBjY3RpUWNURHFQcW5YS0NNMTJ6MGZDTjVpNXRkRlUrM0VzemZBQkpiOEZpU2ZCWFF1UUZRRDNDTDkraVdjZXhrMmxQako2akZIbHZtak9XbTdjQllHZlc4ST0="), - }, - }; - VaultCertificateResult result = await recoveryServicesVault.CreateVaultCertificateAsync(certificateName, content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task DeleteRegisteredIdentity_DeleteRegisteredIdentity() - { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/DeleteRegisteredIdentities.json - // this example is just showing the usage of "RegisteredIdentities_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this RecoveryServicesVaultResource created on azure - // for more information of creating RecoveryServicesVaultResource, please refer to the document of RecoveryServicesVaultResource - string subscriptionId = "77777777-d41f-4550-9f70-7708a3a2283b"; - string resourceGroupName = "BCDRIbzRG"; - string vaultName = "BCDRIbzVault"; - ResourceIdentifier recoveryServicesVaultResourceId = RecoveryServicesVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); - RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); - - // invoke the operation - string identityName = "dpmcontainer01"; - await recoveryServicesVault.DeleteRegisteredIdentityAsync(identityName); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetReplicationUsages_GetsReplicationUsagesOfVault() - { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/ListReplicationUsages.json - // this example is just showing the usage of "ReplicationUsages_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this RecoveryServicesVaultResource created on azure - // for more information of creating RecoveryServicesVaultResource, please refer to the document of RecoveryServicesVaultResource - string subscriptionId = "6808dbbc-98c7-431f-a1b1-9580902423b7"; - string resourceGroupName = "avrai7517RG1"; - string vaultName = "avrai7517Vault1"; - ResourceIdentifier recoveryServicesVaultResourceId = RecoveryServicesVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); - RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); - - // invoke the operation and iterate over the result - await foreach (ReplicationUsage item in recoveryServicesVault.GetReplicationUsagesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetRecoveryServicesVaults_ListOfRecoveryServicesResourcesInSubscriptionId() - { - // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/ListBySubscriptionIds.json - // this example is just showing the usage of "Vaults_ListBySubscriptionId" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "77777777-b0c6-47a2-b37c-d8e65a629c18"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (RecoveryServicesVaultResource item in subscriptionResource.GetRecoveryServicesVaultsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoveryServicesVaultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetRecoveryServicesResource() @@ -217,11 +95,11 @@ public async Task Update_UpdateResource() RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); // invoke the operation - RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(new AzureLocation("placeholder")) + RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(default) { Tags = { -["PatchKey"] = "PatchKeyUpdated", +["PatchKey"] = "PatchKeyUpdated" }, }; ArmOperation lro = await recoveryServicesVault.UpdateAsync(WaitUntil.Completed, patch); @@ -255,14 +133,14 @@ public async Task Update_UpdateResourceWithCustomerManagedKeys() RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); // invoke the operation - RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(new AzureLocation("placeholder")) + RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(default) { - Properties = new RecoveryServicesVaultProperties() + Properties = new RecoveryServicesVaultProperties { - Encryption = new VaultPropertiesEncryption() + Encryption = new VaultPropertiesEncryption { KeyUri = new Uri("https://cmk2xkv.vault.azure.net/keys/Key1/0767b348bb1a4c07baa6c4ec0055d2b3"), - KekIdentity = new CmkKekIdentity() + KekIdentity = new CmkKekIdentity { UserAssignedIdentity = new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi"), }, @@ -273,12 +151,12 @@ public async Task Update_UpdateResourceWithCustomerManagedKeys() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi")] = new UserAssignedIdentity() }, }, Tags = { -["PatchKey"] = "PatchKeyUpdated", +["PatchKey"] = "PatchKeyUpdated" }, }; ArmOperation lro = await recoveryServicesVault.UpdateAsync(WaitUntil.Completed, patch); @@ -312,13 +190,13 @@ public async Task Update_UpdateResourceWithCustomerManagedKeys2() RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); // invoke the operation - RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(new AzureLocation("placeholder")) + RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(default) { - Properties = new RecoveryServicesVaultProperties() + Properties = new RecoveryServicesVaultProperties { - Encryption = new VaultPropertiesEncryption() + Encryption = new VaultPropertiesEncryption { - KekIdentity = new CmkKekIdentity() + KekIdentity = new CmkKekIdentity { UseSystemAssignedIdentity = true, }, @@ -327,7 +205,7 @@ public async Task Update_UpdateResourceWithCustomerManagedKeys2() Identity = new ManagedServiceIdentity("SystemAssigned"), Tags = { -["PatchKey"] = "PatchKeyUpdated", +["PatchKey"] = "PatchKeyUpdated" }, }; ArmOperation lro = await recoveryServicesVault.UpdateAsync(WaitUntil.Completed, patch); @@ -361,11 +239,11 @@ public async Task Update_UpdateResourceWithCustomerManagedKeys3() RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); // invoke the operation - RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(new AzureLocation("placeholder")) + RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(default) { - Properties = new RecoveryServicesVaultProperties() + Properties = new RecoveryServicesVaultProperties { - Encryption = new VaultPropertiesEncryption() + Encryption = new VaultPropertiesEncryption { KeyUri = new Uri("https://cmk2xkv.vault.azure.net/keys/Key1/0767b348bb1a4c07baa6c4ec0055d2b3"), }, @@ -374,12 +252,12 @@ public async Task Update_UpdateResourceWithCustomerManagedKeys3() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi")] = new UserAssignedIdentity() }, }, Tags = { -["PatchKey"] = "PatchKeyUpdated", +["PatchKey"] = "PatchKeyUpdated" }, }; ArmOperation lro = await recoveryServicesVault.UpdateAsync(WaitUntil.Completed, patch); @@ -413,18 +291,18 @@ public async Task Update_UpdateResourceWithUserAssignedIdentity() RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); // invoke the operation - RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(new AzureLocation("placeholder")) + RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(default) { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/85bf5e8c-3084-4f42-add2-746ebb7e97b2/resourcegroups/defaultrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/examplemsi")] = new UserAssignedIdentity() }, }, Tags = { -["PatchKey"] = "PatchKeyUpdated", +["PatchKey"] = "PatchKeyUpdated" }, }; ArmOperation lro = await recoveryServicesVault.UpdateAsync(WaitUntil.Completed, patch); @@ -458,11 +336,11 @@ public async Task Update_UpdateVaultWithMonitoringSetting() RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); // invoke the operation - RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(new AzureLocation("placeholder")) + RecoveryServicesVaultPatch patch = new RecoveryServicesVaultPatch(default) { - Properties = new RecoveryServicesVaultProperties() + Properties = new RecoveryServicesVaultProperties { - MonitoringSettings = new VaultMonitoringSettings() + MonitoringSettings = new VaultMonitoringSettings { AzureMonitorAlertAlertsForAllJobFailures = RecoveryServicesAlertsState.Enabled, ClassicAlertAlertsForCriticalOperations = RecoveryServicesAlertsState.Disabled, @@ -470,7 +348,7 @@ public async Task Update_UpdateVaultWithMonitoringSetting() }, Tags = { -["PatchKey"] = "PatchKeyUpdated", +["PatchKey"] = "PatchKeyUpdated" }, }; ArmOperation lro = await recoveryServicesVault.UpdateAsync(WaitUntil.Completed, patch); @@ -483,6 +361,97 @@ public async Task Update_UpdateVaultWithMonitoringSetting() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateVaultCertificate_DownloadVaultCredentialFile() + { + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/PUTVaultCred.json + // this example is just showing the usage of "VaultCertificates_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this RecoveryServicesVaultResource created on azure + // for more information of creating RecoveryServicesVaultResource, please refer to the document of RecoveryServicesVaultResource + string subscriptionId = "77777777-d41f-4550-9f70-7708a3a2283b"; + string resourceGroupName = "BCDRIbzRG"; + string vaultName = "BCDRIbzVault"; + ResourceIdentifier recoveryServicesVaultResourceId = RecoveryServicesVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); + RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); + + // invoke the operation + string certificateName = "BCDRIbzVault77777777-d41f-4550-9f70-7708a3a2283b-12-18-2017-vaultcredentials"; + RecoveryServicesCertificateContent content = new RecoveryServicesCertificateContent + { + Properties = new RawCertificateData + { + AuthType = RecoveryServicesAuthType.Aad, + Certificate = Encoding.UTF8.GetBytes("TUlJRE5EQ0NBaHlnQXdJQkFnSVFDYUxFKzVTSlNVeWdncDM0VS9HUm9qQU5CZ2txaGtpRzl3MEJBUXNGQURBWE1SVXdFd1lEVlFRREV3eGhiV05vWVc1a2JpNWpiMjB3SGhjTk1qSXhNREkwTVRJd05qRTRXaGNOTWpNeE1ESTBNVEl4TmpFNFdqQVhNUlV3RXdZRFZRUURFd3hoYldOb1lXNWtiaTVqYjIwd2dnRWlNQTBHQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dFS0FvSUJBUUN4cFpwS293a2p4VU9VWkpLT2JvdGdPWXkzaW9UVkxMMmZyaW9nZVN1Qm5IMWw3aVdQWW9kUHRoWS8yVmh6ZFVUckNXL25pNUh3b0JHYzZMMHF6UGlBWXpHek94RmpMQjZjdFNkbm9nL1A4eEV2OGE0cnJWZlBZdS9INStoTGx3N0RubXlTNWs4TU9sSVhUemVWNkxZV2I2RWlpTFppc0k1R3lLU1liemNaQmJKdnhLTVdGdHRCV08xZUwzUWNUejlpb1VGQzVnRlFKQzg3YXFkeDR1Wk9WYzRLM3Ixb09sTFBKdmRLN25YU3VWci9ZOC80ZHhCdDJZUTRia0hjM2EzcUNBbTZrV0QzamRiajhCZmhlWWNVNjFFZ3llVFV2MlI4dzRubWJqVXZxRW05cDZtTG4xMTdEWWpQTHNFODVTL0FpQmF0dkNhQ3hCZ0lxb1N1blBOUkFnTUJBQUdqZkRCNk1BNEdBMVVkRHdFQi93UUVBd0lGb0RBSkJnTlZIUk1FQWpBQU1CMEdBMVVkSlFRV01CUUdDQ3NHQVFVRkJ3TUJCZ2dyQmdFRkJRY0RBakFmQmdOVkhTTUVHREFXZ0JRR1NZcDJMUTJwOE5wMHUzRThJZDdRUjRTQXBqQWRCZ05WSFE0RUZnUVVCa21LZGkwTnFmRGFkTHR4UENIZTBFZUVnS1l3RFFZSktvWklodmNOQVFFTEJRQURnZ0VCQUp2ZG9yRmJ4cExZaUhYRHpnR001WmxMWTRDZE1LYW5BdzVDZDNFVnhDbkhtT05ISnpLRmpzdHZjdUN1TDZ2S1ptci9abm5ENXNLUnE0d0xnTXV6dlNXNGtQTXlWeENrYzdVYnNZSWJCSXNIUDl3cUNmcUY5aG5LSE9YZFJJV2tBVXhnbmYxSlpLZjR1NlpTSzZ3dExaME9VT0c5Mmd3SlB2eW5PVmJoeWpqczdQTVpONEw1djZyeHJkRWp0WG5sYzIvRDlnS0NOTFhFZHdRM0dzS05ZTGZvYy9DT3JmbEIrRHVPSThrVzM0WmxzYlFHelgyQ3ArWVVlSDNrQlBjY3RpUWNURHFQcW5YS0NNMTJ6MGZDTjVpNXRkRlUrM0VzemZBQkpiOEZpU2ZCWFF1UUZRRDNDTDkraVdjZXhrMmxQako2akZIbHZtak9XbTdjQllHZlc4ST0="), + }, + }; + VaultCertificateResult result = await recoveryServicesVault.CreateVaultCertificateAsync(certificateName, content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task DeleteRegisteredIdentity_DeleteRegisteredIdentity() + { + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/DeleteRegisteredIdentities.json + // this example is just showing the usage of "RegisteredIdentities_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this RecoveryServicesVaultResource created on azure + // for more information of creating RecoveryServicesVaultResource, please refer to the document of RecoveryServicesVaultResource + string subscriptionId = "77777777-d41f-4550-9f70-7708a3a2283b"; + string resourceGroupName = "BCDRIbzRG"; + string vaultName = "BCDRIbzVault"; + ResourceIdentifier recoveryServicesVaultResourceId = RecoveryServicesVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); + RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); + + // invoke the operation + string identityName = "dpmcontainer01"; + await recoveryServicesVault.DeleteRegisteredIdentityAsync(identityName); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetReplicationUsages_GetsReplicationUsagesOfVault() + { + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/ListReplicationUsages.json + // this example is just showing the usage of "ReplicationUsages_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this RecoveryServicesVaultResource created on azure + // for more information of creating RecoveryServicesVaultResource, please refer to the document of RecoveryServicesVaultResource + string subscriptionId = "6808dbbc-98c7-431f-a1b1-9580902423b7"; + string resourceGroupName = "avrai7517RG1"; + string vaultName = "avrai7517Vault1"; + ResourceIdentifier recoveryServicesVaultResourceId = RecoveryServicesVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vaultName); + RecoveryServicesVaultResource recoveryServicesVault = client.GetRecoveryServicesVaultResource(recoveryServicesVaultResourceId); + + // invoke the operation and iterate over the result + await foreach (ReplicationUsage item in recoveryServicesVault.GetReplicationUsagesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetUsagesByVaults_GetsVaultUsages() diff --git a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index aab781d0d7e3e..3dde81e4ac29a 100644 --- a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -38,7 +38,7 @@ public async Task CheckRecoveryServicesNameAvailability_AvailabilityStatusOfReso // invoke the operation AzureLocation location = new AzureLocation("westus"); - RecoveryServicesNameAvailabilityContent content = new RecoveryServicesNameAvailabilityContent() + RecoveryServicesNameAvailabilityContent content = new RecoveryServicesNameAvailabilityContent { ResourceType = new ResourceType("Microsoft.RecoveryServices/Vaults"), Name = "swaggerExample", @@ -69,7 +69,7 @@ public async Task CheckRecoveryServicesNameAvailability_AvailabilityStatusOfReso // invoke the operation AzureLocation location = new AzureLocation("westus"); - RecoveryServicesNameAvailabilityContent content = new RecoveryServicesNameAvailabilityContent() + RecoveryServicesNameAvailabilityContent content = new RecoveryServicesNameAvailabilityContent { ResourceType = new ResourceType("Microsoft.RecoveryServices/Vaults"), Name = "swaggerExample2", diff --git a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 6a8ec75b43a15..4dab5fd95b4c3 100644 --- a/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/recoveryservices/Azure.ResourceManager.RecoveryServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -39,20 +39,48 @@ public async Task GetRecoveryServiceCapabilities_CapabilitiesForMicrosoftRecover AzureLocation location = new AzureLocation("westus"); ResourceCapabilities input = new ResourceCapabilities(new ResourceType("Microsoft.RecoveryServices/Vaults")) { - CapabilitiesDnsZones = -{ -new DnsZone() + CapabilitiesDnsZones = {new DnsZone { SubResource = VaultSubResourceType.AzureBackup, -},new DnsZone() +}, new DnsZone { SubResource = VaultSubResourceType.AzureSiteRecovery, -} -}, +}}, }; CapabilitiesResult result = await subscriptionResource.GetRecoveryServiceCapabilitiesAsync(location, input); Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetRecoveryServicesVaults_ListOfRecoveryServicesResourcesInSubscriptionId() + { + // Generated from example definition: specification/recoveryservices/resource-manager/Microsoft.RecoveryServices/stable/2023-04-01/examples/ListBySubscriptionIds.json + // this example is just showing the usage of "Vaults_ListBySubscriptionId" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "77777777-b0c6-47a2-b37c-d8e65a629c18"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (RecoveryServicesVaultResource item in subscriptionResource.GetRecoveryServicesVaultsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoveryServicesVaultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyAssignmentCollection.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyAssignmentCollection.cs index e8d21acb31cfb..8136fcb2fd0cd 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyAssignmentCollection.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyAssignmentCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_RedisCacheAccessPolicyAssignmentCreateUpdate() // invoke the operation string accessPolicyAssignmentName = "accessPolicyAssignmentName1"; - RedisCacheAccessPolicyAssignmentData data = new RedisCacheAccessPolicyAssignmentData() + RedisCacheAccessPolicyAssignmentData data = new RedisCacheAccessPolicyAssignmentData { ObjectId = Guid.Parse("6497c918-11ad-41e7-1b0f-7c518a87d0b0"), ObjectIdAlias = "TestAADAppRedis", @@ -92,10 +92,10 @@ public async Task Get_RedisCacheAccessPolicyAssignmentGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RedisCacheAccessPolicyAssignmentGet() + public async Task GetAll_RedisCacheAccessPolicyAssignmentList() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyAssignmentGet.json - // this example is just showing the usage of "AccessPolicyAssignment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyAssignmentList.json + // this example is just showing the usage of "AccessPolicyAssignment_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +113,22 @@ public async Task Exists_RedisCacheAccessPolicyAssignmentGet() // get the collection of this RedisCacheAccessPolicyAssignmentResource RedisCacheAccessPolicyAssignmentCollection collection = redis.GetRedisCacheAccessPolicyAssignments(); - // invoke the operation - string accessPolicyAssignmentName = "accessPolicyAssignmentName1"; - bool result = await collection.ExistsAsync(accessPolicyAssignmentName); + // invoke the operation and iterate over the result + await foreach (RedisCacheAccessPolicyAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisCacheAccessPolicyAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RedisCacheAccessPolicyAssignmentGet() + public async Task Exists_RedisCacheAccessPolicyAssignmentGet() { // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyAssignmentGet.json // this example is just showing the usage of "AccessPolicyAssignment_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +151,17 @@ public async Task GetIfExists_RedisCacheAccessPolicyAssignmentGet() // invoke the operation string accessPolicyAssignmentName = "accessPolicyAssignmentName1"; - NullableResponse response = await collection.GetIfExistsAsync(accessPolicyAssignmentName); - RedisCacheAccessPolicyAssignmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accessPolicyAssignmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisCacheAccessPolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RedisCacheAccessPolicyAssignmentList() + public async Task GetIfExists_RedisCacheAccessPolicyAssignmentGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyAssignmentList.json - // this example is just showing the usage of "AccessPolicyAssignment_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyAssignmentGet.json + // this example is just showing the usage of "AccessPolicyAssignment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_RedisCacheAccessPolicyAssignmentList() // get the collection of this RedisCacheAccessPolicyAssignmentResource RedisCacheAccessPolicyAssignmentCollection collection = redis.GetRedisCacheAccessPolicyAssignments(); - // invoke the operation and iterate over the result - await foreach (RedisCacheAccessPolicyAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string accessPolicyAssignmentName = "accessPolicyAssignmentName1"; + NullableResponse response = await collection.GetIfExistsAsync(accessPolicyAssignmentName); + RedisCacheAccessPolicyAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RedisCacheAccessPolicyAssignmentData resourceData = item.Data; + RedisCacheAccessPolicyAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyAssignmentResource.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyAssignmentResource.cs index 5c249dde516a1..107beeb2e8637 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyAssignmentResource.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyAssignmentResource.cs @@ -17,10 +17,10 @@ public partial class Sample_RedisCacheAccessPolicyAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RedisCacheAccessPolicyAssignmentCreateUpdate() + public async Task Get_RedisCacheAccessPolicyAssignmentGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyAssignmentCreateUpdate.json - // this example is just showing the usage of "AccessPolicyAssignment_CreateUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyAssignmentGet.json + // this example is just showing the usage of "AccessPolicyAssignment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,14 +37,7 @@ public async Task Update_RedisCacheAccessPolicyAssignmentCreateUpdate() RedisCacheAccessPolicyAssignmentResource redisCacheAccessPolicyAssignment = client.GetRedisCacheAccessPolicyAssignmentResource(redisCacheAccessPolicyAssignmentResourceId); // invoke the operation - RedisCacheAccessPolicyAssignmentData data = new RedisCacheAccessPolicyAssignmentData() - { - ObjectId = Guid.Parse("6497c918-11ad-41e7-1b0f-7c518a87d0b0"), - ObjectIdAlias = "TestAADAppRedis", - AccessPolicyName = "accessPolicy1", - }; - ArmOperation lro = await redisCacheAccessPolicyAssignment.UpdateAsync(WaitUntil.Completed, data); - RedisCacheAccessPolicyAssignmentResource result = lro.Value; + RedisCacheAccessPolicyAssignmentResource result = await redisCacheAccessPolicyAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -82,10 +75,10 @@ public async Task Delete_RedisCacheAccessPolicyAssignmentDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RedisCacheAccessPolicyAssignmentGet() + public async Task Update_RedisCacheAccessPolicyAssignmentCreateUpdate() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyAssignmentGet.json - // this example is just showing the usage of "AccessPolicyAssignment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyAssignmentCreateUpdate.json + // this example is just showing the usage of "AccessPolicyAssignment_CreateUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,7 +95,14 @@ public async Task Get_RedisCacheAccessPolicyAssignmentGet() RedisCacheAccessPolicyAssignmentResource redisCacheAccessPolicyAssignment = client.GetRedisCacheAccessPolicyAssignmentResource(redisCacheAccessPolicyAssignmentResourceId); // invoke the operation - RedisCacheAccessPolicyAssignmentResource result = await redisCacheAccessPolicyAssignment.GetAsync(); + RedisCacheAccessPolicyAssignmentData data = new RedisCacheAccessPolicyAssignmentData + { + ObjectId = Guid.Parse("6497c918-11ad-41e7-1b0f-7c518a87d0b0"), + ObjectIdAlias = "TestAADAppRedis", + AccessPolicyName = "accessPolicy1", + }; + ArmOperation lro = await redisCacheAccessPolicyAssignment.UpdateAsync(WaitUntil.Completed, data); + RedisCacheAccessPolicyAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyCollection.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyCollection.cs index 427120fcbbb50..a747d2488a80a 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyCollection.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_RedisCacheAccessPolicyCreateUpdate() // invoke the operation string accessPolicyName = "accessPolicy1"; - RedisCacheAccessPolicyData data = new RedisCacheAccessPolicyData() + RedisCacheAccessPolicyData data = new RedisCacheAccessPolicyData { Permissions = "+get +hget", }; @@ -90,10 +90,10 @@ public async Task Get_RedisCacheAccessPolicyGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RedisCacheAccessPolicyGet() + public async Task GetAll_RedisCacheAccessPolicyList() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyGet.json - // this example is just showing the usage of "AccessPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyList.json + // this example is just showing the usage of "AccessPolicy_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +111,22 @@ public async Task Exists_RedisCacheAccessPolicyGet() // get the collection of this RedisCacheAccessPolicyResource RedisCacheAccessPolicyCollection collection = redis.GetRedisCacheAccessPolicies(); - // invoke the operation - string accessPolicyName = "accessPolicy1"; - bool result = await collection.ExistsAsync(accessPolicyName); + // invoke the operation and iterate over the result + await foreach (RedisCacheAccessPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisCacheAccessPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RedisCacheAccessPolicyGet() + public async Task Exists_RedisCacheAccessPolicyGet() { // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyGet.json // this example is just showing the usage of "AccessPolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,29 +149,17 @@ public async Task GetIfExists_RedisCacheAccessPolicyGet() // invoke the operation string accessPolicyName = "accessPolicy1"; - NullableResponse response = await collection.GetIfExistsAsync(accessPolicyName); - RedisCacheAccessPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accessPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisCacheAccessPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RedisCacheAccessPolicyList() + public async Task GetIfExists_RedisCacheAccessPolicyGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyList.json - // this example is just showing the usage of "AccessPolicy_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyGet.json + // this example is just showing the usage of "AccessPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_RedisCacheAccessPolicyList() // get the collection of this RedisCacheAccessPolicyResource RedisCacheAccessPolicyCollection collection = redis.GetRedisCacheAccessPolicies(); - // invoke the operation and iterate over the result - await foreach (RedisCacheAccessPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string accessPolicyName = "accessPolicy1"; + NullableResponse response = await collection.GetIfExistsAsync(accessPolicyName); + RedisCacheAccessPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RedisCacheAccessPolicyData resourceData = item.Data; + RedisCacheAccessPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyResource.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyResource.cs index 1aa2f99a38026..f970bb58d76f2 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyResource.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCacheAccessPolicyResource.cs @@ -17,10 +17,10 @@ public partial class Sample_RedisCacheAccessPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RedisCacheAccessPolicyCreateUpdate() + public async Task Get_RedisCacheAccessPolicyGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyCreateUpdate.json - // this example is just showing the usage of "AccessPolicy_CreateUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyGet.json + // this example is just showing the usage of "AccessPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,12 +37,7 @@ public async Task Update_RedisCacheAccessPolicyCreateUpdate() RedisCacheAccessPolicyResource redisCacheAccessPolicy = client.GetRedisCacheAccessPolicyResource(redisCacheAccessPolicyResourceId); // invoke the operation - RedisCacheAccessPolicyData data = new RedisCacheAccessPolicyData() - { - Permissions = "+get +hget", - }; - ArmOperation lro = await redisCacheAccessPolicy.UpdateAsync(WaitUntil.Completed, data); - RedisCacheAccessPolicyResource result = lro.Value; + RedisCacheAccessPolicyResource result = await redisCacheAccessPolicy.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -80,10 +75,10 @@ public async Task Delete_RedisCacheAccessPolicyDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RedisCacheAccessPolicyGet() + public async Task Update_RedisCacheAccessPolicyCreateUpdate() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyGet.json - // this example is just showing the usage of "AccessPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheAccessPolicyCreateUpdate.json + // this example is just showing the usage of "AccessPolicy_CreateUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +95,12 @@ public async Task Get_RedisCacheAccessPolicyGet() RedisCacheAccessPolicyResource redisCacheAccessPolicy = client.GetRedisCacheAccessPolicyResource(redisCacheAccessPolicyResourceId); // invoke the operation - RedisCacheAccessPolicyResource result = await redisCacheAccessPolicy.GetAsync(); + RedisCacheAccessPolicyData data = new RedisCacheAccessPolicyData + { + Permissions = "+get +hget", + }; + ArmOperation lro = await redisCacheAccessPolicy.UpdateAsync(WaitUntil.Completed, data); + RedisCacheAccessPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCollection.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCollection.cs index 595e4d954a17e..26c9f9f7521b4 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCollection.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisCollection.cs @@ -44,11 +44,8 @@ public async Task CreateOrUpdate_RedisCacheCreate() string name = "cache1"; RedisCreateOrUpdateContent content = new RedisCreateOrUpdateContent(new AzureLocation("West US"), new RedisSku(RedisSkuName.Premium, RedisSkuFamily.Premium, 1)) { - Zones = -{ -"1" -}, - RedisConfiguration = new RedisCommonConfiguration() + Zones = { "1" }, + RedisConfiguration = new RedisCommonConfiguration { MaxMemoryPolicy = "allkeys-lru", }, @@ -96,11 +93,8 @@ public async Task CreateOrUpdate_RedisCacheCreateDefaultVersion() string name = "cache1"; RedisCreateOrUpdateContent content = new RedisCreateOrUpdateContent(new AzureLocation("West US"), new RedisSku(RedisSkuName.Premium, RedisSkuFamily.Premium, 1)) { - Zones = -{ -"1" -}, - RedisConfiguration = new RedisCommonConfiguration() + Zones = { "1" }, + RedisConfiguration = new RedisCommonConfiguration { MaxMemoryPolicy = "allkeys-lru", }, @@ -147,11 +141,8 @@ public async Task CreateOrUpdate_RedisCacheCreateLatestVersion() string name = "cache1"; RedisCreateOrUpdateContent content = new RedisCreateOrUpdateContent(new AzureLocation("West US"), new RedisSku(RedisSkuName.Premium, RedisSkuFamily.Premium, 1)) { - Zones = -{ -"1" -}, - RedisConfiguration = new RedisCommonConfiguration() + Zones = { "1" }, + RedisConfiguration = new RedisCommonConfiguration { MaxMemoryPolicy = "allkeys-lru", }, @@ -208,10 +199,10 @@ public async Task Get_RedisCacheGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RedisCacheGet() + public async Task GetAll_RedisCacheListByResourceGroup() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheGet.json - // this example is just showing the usage of "Redis_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheListByResourceGroup.json + // this example is just showing the usage of "Redis_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -228,16 +219,22 @@ public async Task Exists_RedisCacheGet() // get the collection of this RedisResource RedisCollection collection = resourceGroupResource.GetAllRedis(); - // invoke the operation - string name = "cache1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (RedisResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RedisCacheGet() + public async Task Exists_RedisCacheGet() { // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheGet.json // this example is just showing the usage of "Redis_Get" operation, for the dependent resources, they will have to be created separately. @@ -259,29 +256,17 @@ public async Task GetIfExists_RedisCacheGet() // invoke the operation string name = "cache1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - RedisResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RedisCacheListByResourceGroup() + public async Task GetIfExists_RedisCacheGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheListByResourceGroup.json - // this example is just showing the usage of "Redis_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheGet.json + // this example is just showing the usage of "Redis_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -298,17 +283,23 @@ public async Task GetAll_RedisCacheListByResourceGroup() // get the collection of this RedisResource RedisCollection collection = resourceGroupResource.GetAllRedis(); - // invoke the operation and iterate over the result - await foreach (RedisResource item in collection.GetAllAsync()) + // invoke the operation + string name = "cache1"; + NullableResponse response = await collection.GetIfExistsAsync(name); + RedisResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RedisData resourceData = item.Data; + RedisData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisFirewallRuleCollection.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisFirewallRuleCollection.cs index d4cc120036d34..85113b993f496 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisFirewallRuleCollection.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisFirewallRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RedisFirewallRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RedisCacheFirewallRulesList() + public async Task CreateOrUpdate_RedisCacheFirewallRuleCreate() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRulesList.json - // this example is just showing the usage of "FirewallRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRuleCreate.json + // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,25 @@ public async Task GetAll_RedisCacheFirewallRulesList() // get the collection of this RedisFirewallRuleResource RedisFirewallRuleCollection collection = redis.GetRedisFirewallRules(); - // invoke the operation and iterate over the result - await foreach (RedisFirewallRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisFirewallRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string ruleName = "rule1"; + RedisFirewallRuleData data = new RedisFirewallRuleData(IPAddress.Parse("192.168.1.1"), IPAddress.Parse("192.168.1.4")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + RedisFirewallRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RedisCacheFirewallRuleCreate() + public async Task Get_RedisCacheFirewallRuleGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRuleCreate.json - // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,9 +77,7 @@ public async Task CreateOrUpdate_RedisCacheFirewallRuleCreate() // invoke the operation string ruleName = "rule1"; - RedisFirewallRuleData data = new RedisFirewallRuleData(IPAddress.Parse("192.168.1.1"), IPAddress.Parse("192.168.1.4")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - RedisFirewallRuleResource result = lro.Value; + RedisFirewallRuleResource result = await collection.GetAsync(ruleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,10 +88,10 @@ public async Task CreateOrUpdate_RedisCacheFirewallRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RedisCacheFirewallRuleGet() + public async Task GetAll_RedisCacheFirewallRulesList() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRulesList.json + // this example is just showing the usage of "FirewallRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,15 +109,17 @@ public async Task Get_RedisCacheFirewallRuleGet() // get the collection of this RedisFirewallRuleResource RedisFirewallRuleCollection collection = redis.GetRedisFirewallRules(); - // invoke the operation - string ruleName = "rule1"; - RedisFirewallRuleResource result = await collection.GetAsync(ruleName); + // invoke the operation and iterate over the result + await foreach (RedisFirewallRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisFirewallRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisFirewallRuleResource.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisFirewallRuleResource.cs index ef22d5d4e74e1..6ba2391377f1e 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisFirewallRuleResource.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisFirewallRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RedisFirewallRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RedisCacheFirewallRuleCreate() + public async Task Get_RedisCacheFirewallRuleGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRuleCreate.json - // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Update_RedisCacheFirewallRuleCreate() RedisFirewallRuleResource redisFirewallRule = client.GetRedisFirewallRuleResource(redisFirewallRuleResourceId); // invoke the operation - RedisFirewallRuleData data = new RedisFirewallRuleData(IPAddress.Parse("192.168.1.1"), IPAddress.Parse("192.168.1.4")); - ArmOperation lro = await redisFirewallRule.UpdateAsync(WaitUntil.Completed, data); - RedisFirewallRuleResource result = lro.Value; + RedisFirewallRuleResource result = await redisFirewallRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +49,10 @@ public async Task Update_RedisCacheFirewallRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RedisCacheFirewallRuleGet() + public async Task Delete_RedisCacheFirewallRuleDelete() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRuleDelete.json + // this example is just showing the usage of "FirewallRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,21 +69,17 @@ public async Task Get_RedisCacheFirewallRuleGet() RedisFirewallRuleResource redisFirewallRule = client.GetRedisFirewallRuleResource(redisFirewallRuleResourceId); // invoke the operation - RedisFirewallRuleResource result = await redisFirewallRule.GetAsync(); + await redisFirewallRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RedisCacheFirewallRuleDelete() + public async Task Update_RedisCacheFirewallRuleCreate() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRuleDelete.json - // this example is just showing the usage of "FirewallRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheFirewallRuleCreate.json + // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_RedisCacheFirewallRuleDelete() RedisFirewallRuleResource redisFirewallRule = client.GetRedisFirewallRuleResource(redisFirewallRuleResourceId); // invoke the operation - await redisFirewallRule.DeleteAsync(WaitUntil.Completed); + RedisFirewallRuleData data = new RedisFirewallRuleData(IPAddress.Parse("192.168.1.1"), IPAddress.Parse("192.168.1.4")); + ArmOperation lro = await redisFirewallRule.UpdateAsync(WaitUntil.Completed, data); + RedisFirewallRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisLinkedServerWithPropertyCollection.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisLinkedServerWithPropertyCollection.cs index 75c953bd6da2b..c9da194390d7b 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisLinkedServerWithPropertyCollection.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisLinkedServerWithPropertyCollection.cs @@ -88,10 +88,10 @@ public async Task Get_LinkedServerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LinkedServerGet() + public async Task GetAll_LinkedServerList() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheLinkedServer_Get.json - // this example is just showing the usage of "LinkedServer_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheLinkedServer_List.json + // this example is just showing the usage of "LinkedServer_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_LinkedServerGet() // get the collection of this RedisLinkedServerWithPropertyResource RedisLinkedServerWithPropertyCollection collection = redis.GetRedisLinkedServerWithProperties(); - // invoke the operation - string linkedServerName = "cache2"; - bool result = await collection.ExistsAsync(linkedServerName); + // invoke the operation and iterate over the result + await foreach (RedisLinkedServerWithPropertyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisLinkedServerWithPropertyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LinkedServerGet() + public async Task Exists_LinkedServerGet() { // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheLinkedServer_Get.json // this example is just showing the usage of "LinkedServer_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_LinkedServerGet() // invoke the operation string linkedServerName = "cache2"; - NullableResponse response = await collection.GetIfExistsAsync(linkedServerName); - RedisLinkedServerWithPropertyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(linkedServerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisLinkedServerWithPropertyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LinkedServerList() + public async Task GetIfExists_LinkedServerGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheLinkedServer_List.json - // this example is just showing the usage of "LinkedServer_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheLinkedServer_Get.json + // this example is just showing the usage of "LinkedServer_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_LinkedServerList() // get the collection of this RedisLinkedServerWithPropertyResource RedisLinkedServerWithPropertyCollection collection = redis.GetRedisLinkedServerWithProperties(); - // invoke the operation and iterate over the result - await foreach (RedisLinkedServerWithPropertyResource item in collection.GetAllAsync()) + // invoke the operation + string linkedServerName = "cache2"; + NullableResponse response = await collection.GetIfExistsAsync(linkedServerName); + RedisLinkedServerWithPropertyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RedisLinkedServerWithPropertyData resourceData = item.Data; + RedisLinkedServerWithPropertyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisLinkedServerWithPropertyResource.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisLinkedServerWithPropertyResource.cs index 09454db143388..a2d361faed58e 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisLinkedServerWithPropertyResource.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisLinkedServerWithPropertyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RedisLinkedServerWithPropertyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_LinkedServerCreate() + public async Task Get_LinkedServerGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheLinkedServer_Create.json - // this example is just showing the usage of "LinkedServer_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheLinkedServer_Get.json + // this example is just showing the usage of "LinkedServer_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Update_LinkedServerCreate() RedisLinkedServerWithPropertyResource redisLinkedServerWithProperty = client.GetRedisLinkedServerWithPropertyResource(redisLinkedServerWithPropertyResourceId); // invoke the operation - RedisLinkedServerWithPropertyCreateOrUpdateContent content = new RedisLinkedServerWithPropertyCreateOrUpdateContent(new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache2"), new AzureLocation("West US"), RedisLinkedServerRole.Secondary); - ArmOperation lro = await redisLinkedServerWithProperty.UpdateAsync(WaitUntil.Completed, content); - RedisLinkedServerWithPropertyResource result = lro.Value; + RedisLinkedServerWithPropertyResource result = await redisLinkedServerWithProperty.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -78,10 +76,10 @@ public async Task Delete_LinkedServerDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LinkedServerGet() + public async Task Update_LinkedServerCreate() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheLinkedServer_Get.json - // this example is just showing the usage of "LinkedServer_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheLinkedServer_Create.json + // this example is just showing the usage of "LinkedServer_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,7 +96,9 @@ public async Task Get_LinkedServerGet() RedisLinkedServerWithPropertyResource redisLinkedServerWithProperty = client.GetRedisLinkedServerWithPropertyResource(redisLinkedServerWithPropertyResourceId); // invoke the operation - RedisLinkedServerWithPropertyResource result = await redisLinkedServerWithProperty.GetAsync(); + RedisLinkedServerWithPropertyCreateOrUpdateContent content = new RedisLinkedServerWithPropertyCreateOrUpdateContent(new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Cache/Redis/cache2"), new AzureLocation("West US"), RedisLinkedServerRole.Secondary); + ArmOperation lro = await redisLinkedServerWithProperty.UpdateAsync(WaitUntil.Completed, content); + RedisLinkedServerWithPropertyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPatchScheduleCollection.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPatchScheduleCollection.cs index 2f7020354aafa..87d459f0f7905 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPatchScheduleCollection.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPatchScheduleCollection.cs @@ -17,42 +17,6 @@ namespace Azure.ResourceManager.Redis.Samples { public partial class Sample_RedisPatchScheduleCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_RedisCachePatchSchedulesList() - { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCachePatchSchedulesList.json - // this example is just showing the usage of "PatchSchedules_ListByRedisResource" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this RedisResource created on azure - // for more information of creating RedisResource, please refer to the document of RedisResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string cacheName = "cache1"; - ResourceIdentifier redisResourceId = RedisResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cacheName); - RedisResource redis = client.GetRedisResource(redisResourceId); - - // get the collection of this RedisPatchScheduleResource - RedisPatchScheduleCollection collection = redis.GetRedisPatchSchedules(); - - // invoke the operation and iterate over the result - await foreach (RedisPatchScheduleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisPatchScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_RedisCachePatchSchedulesCreateOrUpdate() @@ -80,10 +44,11 @@ public async Task CreateOrUpdate_RedisCachePatchSchedulesCreateOrUpdate() RedisPatchScheduleDefaultName defaultName = RedisPatchScheduleDefaultName.Default; RedisPatchScheduleData data = new RedisPatchScheduleData(new RedisPatchScheduleSetting[] { -new RedisPatchScheduleSetting(RedisDayOfWeek.Monday,12) +new RedisPatchScheduleSetting(RedisDayOfWeek.Monday, 12) { MaintenanceWindow = XmlConvert.ToTimeSpan("PT5H"), -},new RedisPatchScheduleSetting(RedisDayOfWeek.Tuesday,12) +}, +new RedisPatchScheduleSetting(RedisDayOfWeek.Tuesday, 12) }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, defaultName, data); RedisPatchScheduleResource result = lro.Value; @@ -129,6 +94,42 @@ public async Task Get_RedisCachePatchSchedulesGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_RedisCachePatchSchedulesList() + { + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCachePatchSchedulesList.json + // this example is just showing the usage of "PatchSchedules_ListByRedisResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this RedisResource created on azure + // for more information of creating RedisResource, please refer to the document of RedisResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string cacheName = "cache1"; + ResourceIdentifier redisResourceId = RedisResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cacheName); + RedisResource redis = client.GetRedisResource(redisResourceId); + + // get the collection of this RedisPatchScheduleResource + RedisPatchScheduleCollection collection = redis.GetRedisPatchSchedules(); + + // invoke the operation and iterate over the result + await foreach (RedisPatchScheduleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisPatchScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_RedisCachePatchSchedulesGet() diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPatchScheduleResource.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPatchScheduleResource.cs index fc549f3f3de8a..2e806a78eec31 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPatchScheduleResource.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPatchScheduleResource.cs @@ -19,10 +19,10 @@ public partial class Sample_RedisPatchScheduleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RedisCachePatchSchedulesCreateOrUpdate() + public async Task Get_RedisCachePatchSchedulesGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCachePatchSchedulesCreateOrUpdate.json - // this example is just showing the usage of "PatchSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCachePatchSchedulesGet.json + // this example is just showing the usage of "PatchSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,15 +39,7 @@ public async Task Update_RedisCachePatchSchedulesCreateOrUpdate() RedisPatchScheduleResource redisPatchSchedule = client.GetRedisPatchScheduleResource(redisPatchScheduleResourceId); // invoke the operation - RedisPatchScheduleData data = new RedisPatchScheduleData(new RedisPatchScheduleSetting[] - { -new RedisPatchScheduleSetting(RedisDayOfWeek.Monday,12) -{ -MaintenanceWindow = XmlConvert.ToTimeSpan("PT5H"), -},new RedisPatchScheduleSetting(RedisDayOfWeek.Tuesday,12) - }); - ArmOperation lro = await redisPatchSchedule.UpdateAsync(WaitUntil.Completed, data); - RedisPatchScheduleResource result = lro.Value; + RedisPatchScheduleResource result = await redisPatchSchedule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,10 +77,10 @@ public async Task Delete_RedisCachePatchSchedulesDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RedisCachePatchSchedulesGet() + public async Task Update_RedisCachePatchSchedulesCreateOrUpdate() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCachePatchSchedulesGet.json - // this example is just showing the usage of "PatchSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCachePatchSchedulesCreateOrUpdate.json + // this example is just showing the usage of "PatchSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,7 +97,16 @@ public async Task Get_RedisCachePatchSchedulesGet() RedisPatchScheduleResource redisPatchSchedule = client.GetRedisPatchScheduleResource(redisPatchScheduleResourceId); // invoke the operation - RedisPatchScheduleResource result = await redisPatchSchedule.GetAsync(); + RedisPatchScheduleData data = new RedisPatchScheduleData(new RedisPatchScheduleSetting[] + { +new RedisPatchScheduleSetting(RedisDayOfWeek.Monday, 12) +{ +MaintenanceWindow = XmlConvert.ToTimeSpan("PT5H"), +}, +new RedisPatchScheduleSetting(RedisDayOfWeek.Tuesday, 12) + }); + ArmOperation lro = await redisPatchSchedule.UpdateAsync(WaitUntil.Completed, data); + RedisPatchScheduleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPrivateEndpointConnectionCollection.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPrivateEndpointConnectionCollection.cs index 54a48ab048234..3ff512e79e23b 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPrivateEndpointConnectionCollection.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RedisPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RedisCacheListPrivateEndpointConnection() + public async Task CreateOrUpdate_RedisCachePutPrivateEndpointConnection() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheListPrivateEndpointConnections.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCachePutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_RedisCacheListPrivateEndpointConnection() // get the collection of this RedisPrivateEndpointConnectionResource RedisPrivateEndpointConnectionCollection collection = redis.GetRedisPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (RedisPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "pectest01"; + RedisPrivateEndpointConnectionData data = new RedisPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + RedisPrivateLinkServiceConnectionState = new RedisPrivateLinkServiceConnectionState + { + Status = RedisPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + RedisPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_RedisCacheGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RedisCacheGetPrivateEndpointConnection() + public async Task GetAll_RedisCacheListPrivateEndpointConnection() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheGetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheListPrivateEndpointConnections.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_RedisCacheGetPrivateEndpointConnection() // get the collection of this RedisPrivateEndpointConnectionResource RedisPrivateEndpointConnectionCollection collection = redis.GetRedisPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "pectest01"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (RedisPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RedisCacheGetPrivateEndpointConnection() + public async Task Exists_RedisCacheGetPrivateEndpointConnection() { // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheGetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_RedisCacheGetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "pectest01"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - RedisPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RedisCachePutPrivateEndpointConnection() + public async Task GetIfExists_RedisCacheGetPrivateEndpointConnection() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCachePutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheGetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_RedisCachePutPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "pectest01"; - RedisPrivateEndpointConnectionData data = new RedisPrivateEndpointConnectionData() - { - RedisPrivateLinkServiceConnectionState = new RedisPrivateLinkServiceConnectionState() - { - Status = RedisPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - RedisPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + RedisPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPrivateEndpointConnectionResource.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPrivateEndpointConnectionResource.cs index 2ade74b9a6ee3..0220526db1f16 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPrivateEndpointConnectionResource.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_RedisCacheGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RedisCachePutPrivateEndpointConnection() + public async Task Delete_RedisCacheDeletePrivateEndpointConnection() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCachePutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheDeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_RedisCachePutPrivateEndpointConnection() RedisPrivateEndpointConnectionResource redisPrivateEndpointConnection = client.GetRedisPrivateEndpointConnectionResource(redisPrivateEndpointConnectionResourceId); // invoke the operation - RedisPrivateEndpointConnectionData data = new RedisPrivateEndpointConnectionData() - { - RedisPrivateLinkServiceConnectionState = new RedisPrivateLinkServiceConnectionState() - { - Status = RedisPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await redisPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - RedisPrivateEndpointConnectionResource result = lro.Value; + await redisPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RedisCacheDeletePrivateEndpointConnection() + public async Task Update_RedisCachePutPrivateEndpointConnection() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheDeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCachePutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_RedisCacheDeletePrivateEndpointConnection() RedisPrivateEndpointConnectionResource redisPrivateEndpointConnection = client.GetRedisPrivateEndpointConnectionResource(redisPrivateEndpointConnectionResourceId); // invoke the operation - await redisPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + RedisPrivateEndpointConnectionData data = new RedisPrivateEndpointConnectionData + { + RedisPrivateLinkServiceConnectionState = new RedisPrivateLinkServiceConnectionState + { + Status = RedisPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await redisPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + RedisPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisResource.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisResource.cs index 2ab3b2921c2ba..46b10e68d6b31 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisResource.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_RedisResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.Redis.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Redis.Samples @@ -20,65 +19,10 @@ public partial class Sample_RedisResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CheckRedisNameAvailability_RedisCacheCheckNameAvailability() - { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheCheckNameAvailability.json - // this example is just showing the usage of "Redis_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - RedisNameAvailabilityContent content = new RedisNameAvailabilityContent("cacheName", new ResourceType("Microsoft.Cache/Redis")); - await subscriptionResource.CheckRedisNameAvailabilityAsync(content); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetUpgradeNotifications_RedisCacheListUpgradeNotifications() - { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheListUpgradeNotifications.json - // this example is just showing the usage of "Redis_ListUpgradeNotifications" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this RedisResource created on azure - // for more information of creating RedisResource, please refer to the document of RedisResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string name = "cache1"; - ResourceIdentifier redisResourceId = RedisResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); - RedisResource redis = client.GetRedisResource(redisResourceId); - - // invoke the operation and iterate over the result - double history = 5000; - await foreach (RedisUpgradeNotification item in redis.GetUpgradeNotificationsAsync(history)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_RedisCacheUpdate() + public async Task Get_RedisCacheGet() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheUpdate.json - // this example is just showing the usage of "Redis_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheGet.json + // this example is just showing the usage of "Redis_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,13 +38,7 @@ public async Task Update_RedisCacheUpdate() RedisResource redis = client.GetRedisResource(redisResourceId); // invoke the operation - RedisPatch patch = new RedisPatch() - { - EnableNonSslPort = true, - ReplicasPerPrimary = 2, - }; - ArmOperation lro = await redis.UpdateAsync(WaitUntil.Completed, patch); - RedisResource result = lro.Value; + RedisResource result = await redis.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -137,10 +75,10 @@ public async Task Delete_RedisCacheDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RedisCacheGet() + public async Task Update_RedisCacheUpdate() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheGet.json - // this example is just showing the usage of "Redis_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheUpdate.json + // this example is just showing the usage of "Redis_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -156,7 +94,13 @@ public async Task Get_RedisCacheGet() RedisResource redis = client.GetRedisResource(redisResourceId); // invoke the operation - RedisResource result = await redis.GetAsync(); + RedisPatch patch = new RedisPatch + { + EnableNonSslPort = true, + ReplicasPerPrimary = 2, + }; + ArmOperation lro = await redis.UpdateAsync(WaitUntil.Completed, patch); + RedisResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -167,30 +111,29 @@ public async Task Get_RedisCacheGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAllRedis_RedisCacheList() + public async Task GetUpgradeNotifications_RedisCacheListUpgradeNotifications() { - // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheList.json - // this example is just showing the usage of "Redis_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheListUpgradeNotifications.json + // this example is just showing the usage of "Redis_ListUpgradeNotifications" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this RedisResource created on azure + // for more information of creating RedisResource, please refer to the document of RedisResource string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rg1"; + string name = "cache1"; + ResourceIdentifier redisResourceId = RedisResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); + RedisResource redis = client.GetRedisResource(redisResourceId); // invoke the operation and iterate over the result - await foreach (RedisResource item in subscriptionResource.GetAllRedisAsync()) + double history = 5000; + await foreach (RedisUpgradeNotification item in redis.GetUpgradeNotificationsAsync(history)) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {item}"); } Console.WriteLine("Succeeded"); @@ -270,14 +213,11 @@ public async Task ForceReboot_RedisCacheForceReboot() RedisResource redis = client.GetRedisResource(redisResourceId); // invoke the operation - RedisRebootContent content = new RedisRebootContent() + RedisRebootContent content = new RedisRebootContent { RebootType = RedisRebootType.AllNodes, ShardId = 0, - Ports = -{ -13000,15001 -}, + Ports = { 13000, 15001 }, }; RedisForceRebootResult result = await redis.ForceRebootAsync(content); @@ -305,10 +245,7 @@ public async Task ImportData_RedisCacheImport() RedisResource redis = client.GetRedisResource(redisResourceId); // invoke the operation - ImportRdbContent content = new ImportRdbContent(new string[] - { -"http://fileuris.contoso.com/pathtofile1" - }) + ImportRdbContent content = new ImportRdbContent(new string[] { "http://fileuris.contoso.com/pathtofile1" }) { Format = "RDB", StorageSubscriptionId = "storageSubId", diff --git a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 9c43c9eac65d7..160092cc27446 100644 --- a/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/redis/Azure.ResourceManager.Redis/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,62 @@ namespace Azure.ResourceManager.Redis.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckRedisNameAvailability_RedisCacheCheckNameAvailability() + { + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheCheckNameAvailability.json + // this example is just showing the usage of "Redis_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + RedisNameAvailabilityContent content = new RedisNameAvailabilityContent("cacheName", new ResourceType("Microsoft.Cache/Redis")); + await subscriptionResource.CheckRedisNameAvailabilityAsync(content); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAllRedis_RedisCacheList() + { + // Generated from example definition: specification/redis/resource-manager/Microsoft.Cache/stable/2024-03-01/examples/RedisCacheList.json + // this example is just showing the usage of "Redis_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (RedisResource item in subscriptionResource.GetAllRedisAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAsyncOperationStatus_RedisCacheAsyncOperationStatus() diff --git a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_AccessPolicyAssignmentCollection.cs b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_AccessPolicyAssignmentCollection.cs index ac889a486428c..f121285404452 100644 --- a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_AccessPolicyAssignmentCollection.cs +++ b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_AccessPolicyAssignmentCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_RedisEnterpriseAccessPolicyAssignmentCreateUpda // invoke the operation string accessPolicyAssignmentName = "defaultTestEntraApp1"; - AccessPolicyAssignmentData data = new AccessPolicyAssignmentData() + AccessPolicyAssignmentData data = new AccessPolicyAssignmentData { AccessPolicyName = "default", UserObjectId = Guid.Parse("6497c918-11ad-41e7-1b0f-7c518a87d0b0"), @@ -93,10 +93,10 @@ public async Task Get_RedisEnterpriseAccessPolicyAssignmentGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RedisEnterpriseAccessPolicyAssignmentGet() + public async Task GetAll_RedisEnterpriseAccessPolicyAssignmentList() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentGet.json - // this example is just showing the usage of "AccessPolicyAssignment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentsList.json + // this example is just showing the usage of "AccessPolicyAssignment_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +115,22 @@ public async Task Exists_RedisEnterpriseAccessPolicyAssignmentGet() // get the collection of this AccessPolicyAssignmentResource AccessPolicyAssignmentCollection collection = redisEnterpriseDatabase.GetAccessPolicyAssignments(); - // invoke the operation - string accessPolicyAssignmentName = "accessPolicyAssignmentName1"; - bool result = await collection.ExistsAsync(accessPolicyAssignmentName); + // invoke the operation and iterate over the result + await foreach (AccessPolicyAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AccessPolicyAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RedisEnterpriseAccessPolicyAssignmentGet() + public async Task Exists_RedisEnterpriseAccessPolicyAssignmentGet() { // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentGet.json // this example is just showing the usage of "AccessPolicyAssignment_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +154,17 @@ public async Task GetIfExists_RedisEnterpriseAccessPolicyAssignmentGet() // invoke the operation string accessPolicyAssignmentName = "accessPolicyAssignmentName1"; - NullableResponse response = await collection.GetIfExistsAsync(accessPolicyAssignmentName); - AccessPolicyAssignmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accessPolicyAssignmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AccessPolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RedisEnterpriseAccessPolicyAssignmentList() + public async Task GetIfExists_RedisEnterpriseAccessPolicyAssignmentGet() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentsList.json - // this example is just showing the usage of "AccessPolicyAssignment_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentGet.json + // this example is just showing the usage of "AccessPolicyAssignment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_RedisEnterpriseAccessPolicyAssignmentList() // get the collection of this AccessPolicyAssignmentResource AccessPolicyAssignmentCollection collection = redisEnterpriseDatabase.GetAccessPolicyAssignments(); - // invoke the operation and iterate over the result - await foreach (AccessPolicyAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string accessPolicyAssignmentName = "accessPolicyAssignmentName1"; + NullableResponse response = await collection.GetIfExistsAsync(accessPolicyAssignmentName); + AccessPolicyAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AccessPolicyAssignmentData resourceData = item.Data; + AccessPolicyAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_AccessPolicyAssignmentResource.cs b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_AccessPolicyAssignmentResource.cs index ce056a2d5721d..0095ea7e99a07 100644 --- a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_AccessPolicyAssignmentResource.cs +++ b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_AccessPolicyAssignmentResource.cs @@ -17,10 +17,10 @@ public partial class Sample_AccessPolicyAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RedisEnterpriseAccessPolicyAssignmentCreateUpdate() + public async Task Get_RedisEnterpriseAccessPolicyAssignmentGet() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentCreateUpdate.json - // this example is just showing the usage of "AccessPolicyAssignment_CreateUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentGet.json + // this example is just showing the usage of "AccessPolicyAssignment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,18 +33,12 @@ public async Task Update_RedisEnterpriseAccessPolicyAssignmentCreateUpdate() string resourceGroupName = "rg1"; string clusterName = "cache1"; string databaseName = "default"; - string accessPolicyAssignmentName = "defaultTestEntraApp1"; + string accessPolicyAssignmentName = "accessPolicyAssignmentName1"; ResourceIdentifier accessPolicyAssignmentResourceId = AccessPolicyAssignmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName, accessPolicyAssignmentName); AccessPolicyAssignmentResource accessPolicyAssignment = client.GetAccessPolicyAssignmentResource(accessPolicyAssignmentResourceId); // invoke the operation - AccessPolicyAssignmentData data = new AccessPolicyAssignmentData() - { - AccessPolicyName = "default", - UserObjectId = Guid.Parse("6497c918-11ad-41e7-1b0f-7c518a87d0b0"), - }; - ArmOperation lro = await accessPolicyAssignment.UpdateAsync(WaitUntil.Completed, data); - AccessPolicyAssignmentResource result = lro.Value; + AccessPolicyAssignmentResource result = await accessPolicyAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +49,10 @@ public async Task Update_RedisEnterpriseAccessPolicyAssignmentCreateUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RedisEnterpriseAccessPolicyAssignmentGet() + public async Task Delete_RedisEnterpriseAccessPolicyAssignmentDelete() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentGet.json - // this example is just showing the usage of "AccessPolicyAssignment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentDelete.json + // this example is just showing the usage of "AccessPolicyAssignment_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,26 +65,22 @@ public async Task Get_RedisEnterpriseAccessPolicyAssignmentGet() string resourceGroupName = "rg1"; string clusterName = "cache1"; string databaseName = "default"; - string accessPolicyAssignmentName = "accessPolicyAssignmentName1"; + string accessPolicyAssignmentName = "defaultTestEntraApp1"; ResourceIdentifier accessPolicyAssignmentResourceId = AccessPolicyAssignmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName, accessPolicyAssignmentName); AccessPolicyAssignmentResource accessPolicyAssignment = client.GetAccessPolicyAssignmentResource(accessPolicyAssignmentResourceId); // invoke the operation - AccessPolicyAssignmentResource result = await accessPolicyAssignment.GetAsync(); + await accessPolicyAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AccessPolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RedisEnterpriseAccessPolicyAssignmentDelete() + public async Task Update_RedisEnterpriseAccessPolicyAssignmentCreateUpdate() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentDelete.json - // this example is just showing the usage of "AccessPolicyAssignment_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseAccessPolicyAssignmentCreateUpdate.json + // this example is just showing the usage of "AccessPolicyAssignment_CreateUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +98,19 @@ public async Task Delete_RedisEnterpriseAccessPolicyAssignmentDelete() AccessPolicyAssignmentResource accessPolicyAssignment = client.GetAccessPolicyAssignmentResource(accessPolicyAssignmentResourceId); // invoke the operation - await accessPolicyAssignment.DeleteAsync(WaitUntil.Completed); + AccessPolicyAssignmentData data = new AccessPolicyAssignmentData + { + AccessPolicyName = "default", + UserObjectId = Guid.Parse("6497c918-11ad-41e7-1b0f-7c518a87d0b0"), + }; + ArmOperation lro = await accessPolicyAssignment.UpdateAsync(WaitUntil.Completed, data); + AccessPolicyAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AccessPolicyAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseClusterCollection.cs b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseClusterCollection.cs index 011e7e1aba017..92b79b7c9b3f7 100644 --- a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseClusterCollection.cs +++ b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseClusterCollection.cs @@ -47,21 +47,18 @@ public async Task CreateOrUpdate_RedisEnterpriseCreate() Capacity = 3, }) { - Zones = -{ -"1","2","3" -}, + Zones = { "1", "2", "3" }, Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/your-subscription/resourceGroups/your-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/your-identity")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/your-subscription/resourceGroups/your-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/your-identity")] = new UserAssignedIdentity() }, }, MinimumTlsVersion = RedisEnterpriseTlsVersion.Tls1_2, - CustomerManagedKeyEncryption = new RedisEnterpriseCustomerManagedKeyEncryption() + CustomerManagedKeyEncryption = new RedisEnterpriseCustomerManagedKeyEncryption { - KeyEncryptionKeyIdentity = new RedisEnterpriseCustomerManagedKeyEncryptionKeyIdentity() + KeyEncryptionKeyIdentity = new RedisEnterpriseCustomerManagedKeyEncryptionKeyIdentity { UserAssignedIdentityResourceId = new ResourceIdentifier("/subscriptions/your-subscription/resourceGroups/your-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/your-identity"), IdentityType = RedisEnterpriseCustomerManagedKeyIdentityType.UserAssignedIdentity, @@ -70,7 +67,7 @@ public async Task CreateOrUpdate_RedisEnterpriseCreate() }, Tags = { -["tag1"] = "value1", +["tag1"] = "value1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); @@ -118,10 +115,10 @@ public async Task Get_RedisEnterpriseGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RedisEnterpriseGet() + public async Task GetAll_RedisEnterpriseListByResourceGroup() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseGet.json - // this example is just showing the usage of "RedisEnterprise_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseListByResourceGroup.json + // this example is just showing the usage of "RedisEnterprise_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,16 +135,22 @@ public async Task Exists_RedisEnterpriseGet() // get the collection of this RedisEnterpriseClusterResource RedisEnterpriseClusterCollection collection = resourceGroupResource.GetRedisEnterpriseClusters(); - // invoke the operation - string clusterName = "cache1"; - bool result = await collection.ExistsAsync(clusterName); + // invoke the operation and iterate over the result + await foreach (RedisEnterpriseClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisEnterpriseClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RedisEnterpriseGet() + public async Task Exists_RedisEnterpriseGet() { // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseGet.json // this example is just showing the usage of "RedisEnterprise_Get" operation, for the dependent resources, they will have to be created separately. @@ -169,29 +172,17 @@ public async Task GetIfExists_RedisEnterpriseGet() // invoke the operation string clusterName = "cache1"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - RedisEnterpriseClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisEnterpriseClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RedisEnterpriseListByResourceGroup() + public async Task GetIfExists_RedisEnterpriseGet() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseListByResourceGroup.json - // this example is just showing the usage of "RedisEnterprise_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseGet.json + // this example is just showing the usage of "RedisEnterprise_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -208,17 +199,23 @@ public async Task GetAll_RedisEnterpriseListByResourceGroup() // get the collection of this RedisEnterpriseClusterResource RedisEnterpriseClusterCollection collection = resourceGroupResource.GetRedisEnterpriseClusters(); - // invoke the operation and iterate over the result - await foreach (RedisEnterpriseClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "cache1"; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + RedisEnterpriseClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RedisEnterpriseClusterData resourceData = item.Data; + RedisEnterpriseClusterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseClusterResource.cs b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseClusterResource.cs index 5e1d288cb3591..88fae71694823 100644 --- a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseClusterResource.cs +++ b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseClusterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.RedisEnterprise.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.RedisEnterprise.Samples @@ -19,10 +18,10 @@ public partial class Sample_RedisEnterpriseClusterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RedisEnterpriseUpdate() + public async Task Get_RedisEnterpriseGet() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseUpdate.json - // this example is just showing the usage of "RedisEnterprise_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseGet.json + // this example is just showing the usage of "RedisEnterprise_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,20 +37,7 @@ public async Task Update_RedisEnterpriseUpdate() RedisEnterpriseClusterResource redisEnterpriseCluster = client.GetRedisEnterpriseClusterResource(redisEnterpriseClusterResourceId); // invoke the operation - RedisEnterpriseClusterPatch patch = new RedisEnterpriseClusterPatch() - { - Sku = new RedisEnterpriseSku(RedisEnterpriseSkuName.EnterpriseFlashF300) - { - Capacity = 9, - }, - Tags = -{ -["tag1"] = "value1", -}, - MinimumTlsVersion = RedisEnterpriseTlsVersion.Tls1_2, - }; - ArmOperation lro = await redisEnterpriseCluster.UpdateAsync(WaitUntil.Completed, patch); - RedisEnterpriseClusterResource result = lro.Value; + RedisEnterpriseClusterResource result = await redisEnterpriseCluster.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +74,10 @@ public async Task Delete_RedisEnterpriseDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RedisEnterpriseGet() + public async Task Update_RedisEnterpriseUpdate() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseGet.json - // this example is just showing the usage of "RedisEnterprise_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseUpdate.json + // this example is just showing the usage of "RedisEnterprise_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,7 +93,20 @@ public async Task Get_RedisEnterpriseGet() RedisEnterpriseClusterResource redisEnterpriseCluster = client.GetRedisEnterpriseClusterResource(redisEnterpriseClusterResourceId); // invoke the operation - RedisEnterpriseClusterResource result = await redisEnterpriseCluster.GetAsync(); + RedisEnterpriseClusterPatch patch = new RedisEnterpriseClusterPatch + { + Sku = new RedisEnterpriseSku(RedisEnterpriseSkuName.EnterpriseFlashF300) + { + Capacity = 9, + }, + Tags = +{ +["tag1"] = "value1" +}, + MinimumTlsVersion = RedisEnterpriseTlsVersion.Tls1_2, + }; + ArmOperation lro = await redisEnterpriseCluster.UpdateAsync(WaitUntil.Completed, patch); + RedisEnterpriseClusterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -116,37 +115,6 @@ public async Task Get_RedisEnterpriseGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetRedisEnterpriseClusters_RedisEnterpriseList() - { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseList.json - // this example is just showing the usage of "RedisEnterprise_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (RedisEnterpriseClusterResource item in subscriptionResource.GetRedisEnterpriseClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisEnterpriseClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetPrivateLinkResourcesByCluster_RedisEnterpriseListPrivateLinkResources() diff --git a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseDatabaseCollection.cs b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseDatabaseCollection.cs index cf8ba67aa7bb0..cd96fa9b53e08 100644 --- a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseDatabaseCollection.cs +++ b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseDatabaseCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.RedisEnterprise.Samples { public partial class Sample_RedisEnterpriseDatabaseCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_RedisEnterpriseDatabasesListByCluster() - { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesListByCluster.json - // this example is just showing the usage of "Databases_ListByCluster" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this RedisEnterpriseClusterResource created on azure - // for more information of creating RedisEnterpriseClusterResource, please refer to the document of RedisEnterpriseClusterResource - string subscriptionId = "e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f"; - string resourceGroupName = "rg1"; - string clusterName = "cache1"; - ResourceIdentifier redisEnterpriseClusterResourceId = RedisEnterpriseClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - RedisEnterpriseClusterResource redisEnterpriseCluster = client.GetRedisEnterpriseClusterResource(redisEnterpriseClusterResourceId); - - // get the collection of this RedisEnterpriseDatabaseResource - RedisEnterpriseDatabaseCollection collection = redisEnterpriseCluster.GetRedisEnterpriseDatabases(); - - // invoke the operation and iterate over the result - await foreach (RedisEnterpriseDatabaseResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisEnterpriseDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_RedisEnterpriseDatabasesCreate() @@ -77,27 +41,24 @@ public async Task CreateOrUpdate_RedisEnterpriseDatabasesCreate() // invoke the operation string databaseName = "default"; - RedisEnterpriseDatabaseData data = new RedisEnterpriseDatabaseData() + RedisEnterpriseDatabaseData data = new RedisEnterpriseDatabaseData { ClientProtocol = RedisEnterpriseClientProtocol.Encrypted, Port = 10000, ClusteringPolicy = RedisEnterpriseClusteringPolicy.EnterpriseCluster, EvictionPolicy = RedisEnterpriseEvictionPolicy.AllKeysLru, - Persistence = new RedisPersistenceSettings() + Persistence = new RedisPersistenceSettings { IsAofEnabled = true, AofFrequency = PersistenceSettingAofFrequency.OneSecond, }, - Modules = -{ -new RedisEnterpriseModule("RedisBloom") + Modules = {new RedisEnterpriseModule("RedisBloom") { Args = "ERROR_RATE 0.00 INITIAL_SIZE 400", -},new RedisEnterpriseModule("RedisTimeSeries") +}, new RedisEnterpriseModule("RedisTimeSeries") { Args = "RETENTION_POLICY 20", -},new RedisEnterpriseModule("RediSearch") -}, +}, new RedisEnterpriseModule("RediSearch")}, DeferUpgrade = DeferUpgradeSetting.NotDeferred, AccessKeysAuthentication = AccessKeysAuthentication.Enabled, }; @@ -136,25 +97,22 @@ public async Task CreateOrUpdate_RedisEnterpriseDatabasesCreateWithActiveGeoRepl // invoke the operation string databaseName = "default"; - RedisEnterpriseDatabaseData data = new RedisEnterpriseDatabaseData() + RedisEnterpriseDatabaseData data = new RedisEnterpriseDatabaseData { ClientProtocol = RedisEnterpriseClientProtocol.Encrypted, Port = 10000, ClusteringPolicy = RedisEnterpriseClusteringPolicy.EnterpriseCluster, EvictionPolicy = RedisEnterpriseEvictionPolicy.NoEviction, - GeoReplication = new RedisEnterpriseDatabaseGeoReplication() + GeoReplication = new RedisEnterpriseDatabaseGeoReplication { GroupNickname = "groupName", - LinkedDatabases = -{ -new RedisEnterpriseLinkedDatabase() + LinkedDatabases = {new RedisEnterpriseLinkedDatabase { Id = new ResourceIdentifier("/subscriptions/e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f/resourceGroups/rg1/providers/Microsoft.Cache/redisEnterprise/cache1/databases/default"), -},new RedisEnterpriseLinkedDatabase() +}, new RedisEnterpriseLinkedDatabase { Id = new ResourceIdentifier("/subscriptions/e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8e/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default"), -} -}, +}}, }, AccessKeysAuthentication = AccessKeysAuthentication.Enabled, }; @@ -202,6 +160,42 @@ public async Task Get_RedisEnterpriseDatabasesGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_RedisEnterpriseDatabasesListByCluster() + { + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesListByCluster.json + // this example is just showing the usage of "Databases_ListByCluster" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this RedisEnterpriseClusterResource created on azure + // for more information of creating RedisEnterpriseClusterResource, please refer to the document of RedisEnterpriseClusterResource + string subscriptionId = "e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f"; + string resourceGroupName = "rg1"; + string clusterName = "cache1"; + ResourceIdentifier redisEnterpriseClusterResourceId = RedisEnterpriseClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + RedisEnterpriseClusterResource redisEnterpriseCluster = client.GetRedisEnterpriseClusterResource(redisEnterpriseClusterResourceId); + + // get the collection of this RedisEnterpriseDatabaseResource + RedisEnterpriseDatabaseCollection collection = redisEnterpriseCluster.GetRedisEnterpriseDatabases(); + + // invoke the operation and iterate over the result + await foreach (RedisEnterpriseDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisEnterpriseDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_RedisEnterpriseDatabasesGet() diff --git a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseDatabaseResource.cs b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseDatabaseResource.cs index b0acf4a5fb4c9..5ce63722dcf71 100644 --- a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseDatabaseResource.cs +++ b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterpriseDatabaseResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RedisEnterpriseDatabaseResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RedisEnterpriseDatabasesUpdate() + public async Task Get_RedisEnterpriseDatabasesGet() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesUpdate.json - // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,19 +38,7 @@ public async Task Update_RedisEnterpriseDatabasesUpdate() RedisEnterpriseDatabaseResource redisEnterpriseDatabase = client.GetRedisEnterpriseDatabaseResource(redisEnterpriseDatabaseResourceId); // invoke the operation - RedisEnterpriseDatabasePatch patch = new RedisEnterpriseDatabasePatch() - { - ClientProtocol = RedisEnterpriseClientProtocol.Encrypted, - EvictionPolicy = RedisEnterpriseEvictionPolicy.AllKeysLru, - Persistence = new RedisPersistenceSettings() - { - IsRdbEnabled = true, - RdbFrequency = PersistenceSettingRdbFrequency.TwelveHours, - }, - AccessKeysAuthentication = AccessKeysAuthentication.Enabled, - }; - ArmOperation lro = await redisEnterpriseDatabase.UpdateAsync(WaitUntil.Completed, patch); - RedisEnterpriseDatabaseResource result = lro.Value; + RedisEnterpriseDatabaseResource result = await redisEnterpriseDatabase.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -61,10 +49,10 @@ public async Task Update_RedisEnterpriseDatabasesUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RedisEnterpriseDatabasesGet() + public async Task Delete_RedisEnterpriseDatabasesDelete() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesDelete.json + // this example is just showing the usage of "Databases_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,26 +64,22 @@ public async Task Get_RedisEnterpriseDatabasesGet() string subscriptionId = "e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f"; string resourceGroupName = "rg1"; string clusterName = "cache1"; - string databaseName = "default"; + string databaseName = "db1"; ResourceIdentifier redisEnterpriseDatabaseResourceId = RedisEnterpriseDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName); RedisEnterpriseDatabaseResource redisEnterpriseDatabase = client.GetRedisEnterpriseDatabaseResource(redisEnterpriseDatabaseResourceId); // invoke the operation - RedisEnterpriseDatabaseResource result = await redisEnterpriseDatabase.GetAsync(); + await redisEnterpriseDatabase.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisEnterpriseDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RedisEnterpriseDatabasesDelete() + public async Task Update_RedisEnterpriseDatabasesUpdate() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesDelete.json - // this example is just showing the usage of "Databases_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDatabasesUpdate.json + // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,14 +91,30 @@ public async Task Delete_RedisEnterpriseDatabasesDelete() string subscriptionId = "e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f"; string resourceGroupName = "rg1"; string clusterName = "cache1"; - string databaseName = "db1"; + string databaseName = "default"; ResourceIdentifier redisEnterpriseDatabaseResourceId = RedisEnterpriseDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName); RedisEnterpriseDatabaseResource redisEnterpriseDatabase = client.GetRedisEnterpriseDatabaseResource(redisEnterpriseDatabaseResourceId); // invoke the operation - await redisEnterpriseDatabase.DeleteAsync(WaitUntil.Completed); + RedisEnterpriseDatabasePatch patch = new RedisEnterpriseDatabasePatch + { + ClientProtocol = RedisEnterpriseClientProtocol.Encrypted, + EvictionPolicy = RedisEnterpriseEvictionPolicy.AllKeysLru, + Persistence = new RedisPersistenceSettings + { + IsRdbEnabled = true, + RdbFrequency = PersistenceSettingRdbFrequency.TwelveHours, + }, + AccessKeysAuthentication = AccessKeysAuthentication.Enabled, + }; + ArmOperation lro = await redisEnterpriseDatabase.UpdateAsync(WaitUntil.Completed, patch); + RedisEnterpriseDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisEnterpriseDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -195,10 +195,7 @@ public async Task Import_RedisEnterpriseDatabasesImport() RedisEnterpriseDatabaseResource redisEnterpriseDatabase = client.GetRedisEnterpriseDatabaseResource(redisEnterpriseDatabaseResourceId); // invoke the operation - ImportRedisEnterpriseDatabaseContent content = new ImportRedisEnterpriseDatabaseContent(new Uri[] - { -new Uri("https://contosostorage.blob.core.window.net/urltoBlobFile1?sasKeyParameters"),new Uri("https://contosostorage.blob.core.window.net/urltoBlobFile2?sasKeyParameters") - }); + ImportRedisEnterpriseDatabaseContent content = new ImportRedisEnterpriseDatabaseContent(new Uri[] { new Uri("https://contosostorage.blob.core.window.net/urltoBlobFile1?sasKeyParameters"), new Uri("https://contosostorage.blob.core.window.net/urltoBlobFile2?sasKeyParameters") }); await redisEnterpriseDatabase.ImportAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); @@ -254,10 +251,7 @@ public async Task ForceUnlink_HowToUnlinkADatabaseDuringARegionalOutage() RedisEnterpriseDatabaseResource redisEnterpriseDatabase = client.GetRedisEnterpriseDatabaseResource(redisEnterpriseDatabaseResourceId); // invoke the operation - ForceUnlinkRedisEnterpriseDatabaseContent content = new ForceUnlinkRedisEnterpriseDatabaseContent(new ResourceIdentifier[] - { -new ResourceIdentifier("/subscriptions/e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f2/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default") - }); + ForceUnlinkRedisEnterpriseDatabaseContent content = new ForceUnlinkRedisEnterpriseDatabaseContent(new ResourceIdentifier[] { new ResourceIdentifier("/subscriptions/e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f2/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default") }); await redisEnterpriseDatabase.ForceUnlinkAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); @@ -287,10 +281,11 @@ public async Task ForceLinkToReplicationGroup_HowToRelinkADatabaseAfterARegional // invoke the operation ForceLinkContent content = new ForceLinkContent("groupName", new RedisEnterpriseLinkedDatabase[] { -new RedisEnterpriseLinkedDatabase() +new RedisEnterpriseLinkedDatabase { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Cache/redisEnterprise/cache1/databases/default"), -},new RedisEnterpriseLinkedDatabase() +}, +new RedisEnterpriseLinkedDatabase { Id = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default"), } @@ -322,12 +317,9 @@ public async Task Flush_HowToFlushAllTheKeysInTheDatabase() RedisEnterpriseDatabaseResource redisEnterpriseDatabase = client.GetRedisEnterpriseDatabaseResource(redisEnterpriseDatabaseResourceId); // invoke the operation - FlushRedisEnterpriseDatabaseContent content = new FlushRedisEnterpriseDatabaseContent() + FlushRedisEnterpriseDatabaseContent content = new FlushRedisEnterpriseDatabaseContent { - Ids = -{ -new ResourceIdentifier("/subscriptions/e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f2/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default") -}, + Ids = { new ResourceIdentifier("/subscriptions/e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f2/resourceGroups/rg2/providers/Microsoft.Cache/redisEnterprise/cache2/databases/default") }, }; await redisEnterpriseDatabase.FlushAsync(WaitUntil.Completed, content); diff --git a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterprisePrivateEndpointConnectionCollection.cs b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterprisePrivateEndpointConnectionCollection.cs index 41056191cfce7..97d54a176a233 100644 --- a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterprisePrivateEndpointConnectionCollection.cs +++ b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterprisePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RedisEnterprisePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RedisEnterpriseListPrivateEndpointConnections() + public async Task CreateOrUpdate_RedisEnterprisePutPrivateEndpointConnection() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseListPrivateEndpointConnections.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterprisePutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_RedisEnterpriseListPrivateEndpointConnections() // get the collection of this RedisEnterprisePrivateEndpointConnectionResource RedisEnterprisePrivateEndpointConnectionCollection collection = redisEnterpriseCluster.GetRedisEnterprisePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (RedisEnterprisePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "pectest01"; + RedisEnterprisePrivateEndpointConnectionData data = new RedisEnterprisePrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisEnterprisePrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new RedisEnterprisePrivateLinkServiceConnectionState + { + Status = RedisEnterprisePrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + RedisEnterprisePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisEnterprisePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_RedisEnterpriseGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RedisEnterpriseGetPrivateEndpointConnection() + public async Task GetAll_RedisEnterpriseListPrivateEndpointConnections() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseGetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseListPrivateEndpointConnections.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_RedisEnterpriseGetPrivateEndpointConnection() // get the collection of this RedisEnterprisePrivateEndpointConnectionResource RedisEnterprisePrivateEndpointConnectionCollection collection = redisEnterpriseCluster.GetRedisEnterprisePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "pectest01"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (RedisEnterprisePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisEnterprisePrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RedisEnterpriseGetPrivateEndpointConnection() + public async Task Exists_RedisEnterpriseGetPrivateEndpointConnection() { // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseGetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_RedisEnterpriseGetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "pectest01"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - RedisEnterprisePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisEnterprisePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RedisEnterprisePutPrivateEndpointConnection() + public async Task GetIfExists_RedisEnterpriseGetPrivateEndpointConnection() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterprisePutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseGetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_RedisEnterprisePutPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "pectest01"; - RedisEnterprisePrivateEndpointConnectionData data = new RedisEnterprisePrivateEndpointConnectionData() - { - ConnectionState = new RedisEnterprisePrivateLinkServiceConnectionState() - { - Status = RedisEnterprisePrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - RedisEnterprisePrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + RedisEnterprisePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisEnterprisePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisEnterprisePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterprisePrivateEndpointConnectionResource.cs b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterprisePrivateEndpointConnectionResource.cs index fa0d9fff4d64d..1f240718e40bf 100644 --- a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterprisePrivateEndpointConnectionResource.cs +++ b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_RedisEnterprisePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_RedisEnterpriseGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RedisEnterprisePutPrivateEndpointConnection() + public async Task Delete_RedisEnterpriseDeletePrivateEndpointConnection() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterprisePutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_RedisEnterprisePutPrivateEndpointConnection() RedisEnterprisePrivateEndpointConnectionResource redisEnterprisePrivateEndpointConnection = client.GetRedisEnterprisePrivateEndpointConnectionResource(redisEnterprisePrivateEndpointConnectionResourceId); // invoke the operation - RedisEnterprisePrivateEndpointConnectionData data = new RedisEnterprisePrivateEndpointConnectionData() - { - ConnectionState = new RedisEnterprisePrivateLinkServiceConnectionState() - { - Status = RedisEnterprisePrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await redisEnterprisePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - RedisEnterprisePrivateEndpointConnectionResource result = lro.Value; + await redisEnterprisePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RedisEnterprisePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RedisEnterpriseDeletePrivateEndpointConnection() + public async Task Update_RedisEnterprisePutPrivateEndpointConnection() { - // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseDeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterprisePutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_RedisEnterpriseDeletePrivateEndpointConnection() RedisEnterprisePrivateEndpointConnectionResource redisEnterprisePrivateEndpointConnection = client.GetRedisEnterprisePrivateEndpointConnectionResource(redisEnterprisePrivateEndpointConnectionResourceId); // invoke the operation - await redisEnterprisePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + RedisEnterprisePrivateEndpointConnectionData data = new RedisEnterprisePrivateEndpointConnectionData + { + ConnectionState = new RedisEnterprisePrivateLinkServiceConnectionState + { + Status = RedisEnterprisePrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await redisEnterprisePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + RedisEnterprisePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisEnterprisePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 8d90afa45c96f..91f60a57619c9 100644 --- a/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/redisenterprise/Azure.ResourceManager.RedisEnterprise/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -42,5 +42,36 @@ public async Task GetRedisEnterpriseOperationsStatus_OperationsStatusGet() Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetRedisEnterpriseClusters_RedisEnterpriseList() + { + // Generated from example definition: specification/redisenterprise/resource-manager/Microsoft.Cache/preview/2024-09-01-preview/examples/RedisEnterpriseList.json + // this example is just showing the usage of "RedisEnterprise_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "e7b5a9d2-6b6a-4d2f-9143-20d9a10f5b8f"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (RedisEnterpriseClusterResource item in subscriptionResource.GetRedisEnterpriseClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RedisEnterpriseClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionAuthorizationRuleCollection.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionAuthorizationRuleCollection.cs index f7142e1a8b07f..7ed3244b634e3 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionAuthorizationRuleCollection.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionAuthorizationRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RelayHybridConnectionAuthorizationRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RelayHybridConnectionAuthorizationRuleListAll() + public async Task CreateOrUpdate_RelayHybridConnectionAuthorizationRuleCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleListAll.json - // this example is just showing the usage of "HybridConnections_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleCreate.json + // this example is just showing the usage of "HybridConnections_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,28 @@ public async Task GetAll_RelayHybridConnectionAuthorizationRuleListAll() // get the collection of this RelayHybridConnectionAuthorizationRuleResource RelayHybridConnectionAuthorizationRuleCollection collection = relayHybridConnection.GetRelayHybridConnectionAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (RelayHybridConnectionAuthorizationRuleResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationRuleName = "example-RelayAuthRules-01"; + RelayAuthorizationRuleData data = new RelayAuthorizationRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayAuthorizationRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Rights = { RelayAccessRight.Listen, RelayAccessRight.Send }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); + RelayHybridConnectionAuthorizationRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RelayHybridConnectionAuthorizationRuleCreate() + public async Task Get_RelayHybridConnectionAuthorizationRuleGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleCreate.json - // this example is just showing the usage of "HybridConnections_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleGet.json + // this example is just showing the usage of "HybridConnections_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +82,7 @@ public async Task CreateOrUpdate_RelayHybridConnectionAuthorizationRuleCreate() // invoke the operation string authorizationRuleName = "example-RelayAuthRules-01"; - RelayAuthorizationRuleData data = new RelayAuthorizationRuleData() - { - Rights = -{ -RelayAccessRight.Listen,RelayAccessRight.Send -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); - RelayHybridConnectionAuthorizationRuleResource result = lro.Value; + RelayHybridConnectionAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -98,10 +93,10 @@ public async Task CreateOrUpdate_RelayHybridConnectionAuthorizationRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelayHybridConnectionAuthorizationRuleGet() + public async Task GetAll_RelayHybridConnectionAuthorizationRuleListAll() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleGet.json - // this example is just showing the usage of "HybridConnections_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleListAll.json + // this example is just showing the usage of "HybridConnections_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,15 +115,17 @@ public async Task Get_RelayHybridConnectionAuthorizationRuleGet() // get the collection of this RelayHybridConnectionAuthorizationRuleResource RelayHybridConnectionAuthorizationRuleCollection collection = relayHybridConnection.GetRelayHybridConnectionAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "example-RelayAuthRules-01"; - RelayHybridConnectionAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (RelayHybridConnectionAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionAuthorizationRuleResource.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionAuthorizationRuleResource.cs index 97287596152b7..5d1eff9fab2e2 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionAuthorizationRuleResource.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionAuthorizationRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RelayHybridConnectionAuthorizationRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RelayHybridConnectionAuthorizationRuleCreate() + public async Task Get_RelayHybridConnectionAuthorizationRuleGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleCreate.json - // this example is just showing the usage of "HybridConnections_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleGet.json + // this example is just showing the usage of "HybridConnections_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,15 +39,7 @@ public async Task Update_RelayHybridConnectionAuthorizationRuleCreate() RelayHybridConnectionAuthorizationRuleResource relayHybridConnectionAuthorizationRule = client.GetRelayHybridConnectionAuthorizationRuleResource(relayHybridConnectionAuthorizationRuleResourceId); // invoke the operation - RelayAuthorizationRuleData data = new RelayAuthorizationRuleData() - { - Rights = -{ -RelayAccessRight.Listen,RelayAccessRight.Send -}, - }; - ArmOperation lro = await relayHybridConnectionAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); - RelayHybridConnectionAuthorizationRuleResource result = lro.Value; + RelayHybridConnectionAuthorizationRuleResource result = await relayHybridConnectionAuthorizationRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,10 +78,10 @@ public async Task Delete_RelayHybridConnectionAuthorizationRuleDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelayHybridConnectionAuthorizationRuleGet() + public async Task Update_RelayHybridConnectionAuthorizationRuleCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleGet.json - // this example is just showing the usage of "HybridConnections_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionAuthorizationRuleCreate.json + // this example is just showing the usage of "HybridConnections_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,7 +99,12 @@ public async Task Get_RelayHybridConnectionAuthorizationRuleGet() RelayHybridConnectionAuthorizationRuleResource relayHybridConnectionAuthorizationRule = client.GetRelayHybridConnectionAuthorizationRuleResource(relayHybridConnectionAuthorizationRuleResourceId); // invoke the operation - RelayHybridConnectionAuthorizationRuleResource result = await relayHybridConnectionAuthorizationRule.GetAsync(); + RelayAuthorizationRuleData data = new RelayAuthorizationRuleData + { + Rights = { RelayAccessRight.Listen, RelayAccessRight.Send }, + }; + ArmOperation lro = await relayHybridConnectionAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); + RelayHybridConnectionAuthorizationRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionCollection.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionCollection.cs index 78846f8bc22c1..c2c33ff962823 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionCollection.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RelayHybridConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RelayHybridConnectionListAll() + public async Task CreateOrUpdate_RelayHybridConnectionCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionListAll.json - // this example is just showing the usage of "HybridConnections_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionCreate.json + // this example is just showing the usage of "HybridConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,28 @@ public async Task GetAll_RelayHybridConnectionListAll() // get the collection of this RelayHybridConnectionResource RelayHybridConnectionCollection collection = relayNamespace.GetRelayHybridConnections(); - // invoke the operation and iterate over the result - await foreach (RelayHybridConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string hybridConnectionName = "example-Relay-Hybrid-01"; + RelayHybridConnectionData data = new RelayHybridConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayHybridConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsClientAuthorizationRequired = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hybridConnectionName, data); + RelayHybridConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayHybridConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RelayHybridConnectionCreate() + public async Task Get_RelayHybridConnectionGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionCreate.json - // this example is just showing the usage of "HybridConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionGet.json + // this example is just showing the usage of "HybridConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,12 +79,7 @@ public async Task CreateOrUpdate_RelayHybridConnectionCreate() // invoke the operation string hybridConnectionName = "example-Relay-Hybrid-01"; - RelayHybridConnectionData data = new RelayHybridConnectionData() - { - IsClientAuthorizationRequired = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hybridConnectionName, data); - RelayHybridConnectionResource result = lro.Value; + RelayHybridConnectionResource result = await collection.GetAsync(hybridConnectionName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +90,10 @@ public async Task CreateOrUpdate_RelayHybridConnectionCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelayHybridConnectionGet() + public async Task GetAll_RelayHybridConnectionListAll() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionGet.json - // this example is just showing the usage of "HybridConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionListAll.json + // this example is just showing the usage of "HybridConnections_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,15 +111,17 @@ public async Task Get_RelayHybridConnectionGet() // get the collection of this RelayHybridConnectionResource RelayHybridConnectionCollection collection = relayNamespace.GetRelayHybridConnections(); - // invoke the operation - string hybridConnectionName = "example-Relay-Hybrid-01"; - RelayHybridConnectionResource result = await collection.GetAsync(hybridConnectionName); + // invoke the operation and iterate over the result + await foreach (RelayHybridConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayHybridConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayHybridConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionResource.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionResource.cs index 881a84dc9c822..c6fc07be68d6a 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionResource.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayHybridConnectionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_RelayHybridConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RelayHybridConnectionCreate() + public async Task Get_RelayHybridConnectionGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionCreate.json - // this example is just showing the usage of "HybridConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionGet.json + // this example is just showing the usage of "HybridConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,12 +37,7 @@ public async Task Update_RelayHybridConnectionCreate() RelayHybridConnectionResource relayHybridConnection = client.GetRelayHybridConnectionResource(relayHybridConnectionResourceId); // invoke the operation - RelayHybridConnectionData data = new RelayHybridConnectionData() - { - IsClientAuthorizationRequired = true, - }; - ArmOperation lro = await relayHybridConnection.UpdateAsync(WaitUntil.Completed, data); - RelayHybridConnectionResource result = lro.Value; + RelayHybridConnectionResource result = await relayHybridConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -80,10 +75,10 @@ public async Task Delete_RelayHybridconnectionDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelayHybridConnectionGet() + public async Task Update_RelayHybridConnectionCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionGet.json - // this example is just showing the usage of "HybridConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/HybridConnection/RelayHybridConnectionCreate.json + // this example is just showing the usage of "HybridConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +95,12 @@ public async Task Get_RelayHybridConnectionGet() RelayHybridConnectionResource relayHybridConnection = client.GetRelayHybridConnectionResource(relayHybridConnectionResourceId); // invoke the operation - RelayHybridConnectionResource result = await relayHybridConnection.GetAsync(); + RelayHybridConnectionData data = new RelayHybridConnectionData + { + IsClientAuthorizationRequired = true, + }; + ArmOperation lro = await relayHybridConnection.UpdateAsync(WaitUntil.Completed, data); + RelayHybridConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceAuthorizationRuleCollection.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceAuthorizationRuleCollection.cs index 90e8b55bd9fe7..550af8f42ed87 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceAuthorizationRuleCollection.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceAuthorizationRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RelayNamespaceAuthorizationRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RelayNameSpaceAuthorizationRuleListAll() + public async Task CreateOrUpdate_RelayNameSpaceAuthorizationRuleCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceAuthorizationRuleListAll.json - // this example is just showing the usage of "Namespaces_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceAuthorizationRuleCreate.json + // this example is just showing the usage of "Namespaces_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_RelayNameSpaceAuthorizationRuleListAll() // get the collection of this RelayNamespaceAuthorizationRuleResource RelayNamespaceAuthorizationRuleCollection collection = relayNamespace.GetRelayNamespaceAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (RelayNamespaceAuthorizationRuleResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationRuleName = "example-RelayAuthRules-01"; + RelayAuthorizationRuleData data = new RelayAuthorizationRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayAuthorizationRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Rights = { RelayAccessRight.Listen, RelayAccessRight.Send }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); + RelayNamespaceAuthorizationRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RelayNameSpaceAuthorizationRuleCreate() + public async Task Get_RelayNameSpaceAuthorizationRuleGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceAuthorizationRuleCreate.json - // this example is just showing the usage of "Namespaces_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceAuthorizationRuleGet.json + // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +80,7 @@ public async Task CreateOrUpdate_RelayNameSpaceAuthorizationRuleCreate() // invoke the operation string authorizationRuleName = "example-RelayAuthRules-01"; - RelayAuthorizationRuleData data = new RelayAuthorizationRuleData() - { - Rights = -{ -RelayAccessRight.Listen,RelayAccessRight.Send -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); - RelayNamespaceAuthorizationRuleResource result = lro.Value; + RelayNamespaceAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -96,10 +91,10 @@ public async Task CreateOrUpdate_RelayNameSpaceAuthorizationRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelayNameSpaceAuthorizationRuleGet() + public async Task GetAll_RelayNameSpaceAuthorizationRuleListAll() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceAuthorizationRuleGet.json - // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceAuthorizationRuleListAll.json + // this example is just showing the usage of "Namespaces_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,15 +112,17 @@ public async Task Get_RelayNameSpaceAuthorizationRuleGet() // get the collection of this RelayNamespaceAuthorizationRuleResource RelayNamespaceAuthorizationRuleCollection collection = relayNamespace.GetRelayNamespaceAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "example-RelayAuthRules-01"; - RelayNamespaceAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (RelayNamespaceAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceAuthorizationRuleResource.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceAuthorizationRuleResource.cs index 8432d53df9c3e..425f0c21fd441 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceAuthorizationRuleResource.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceAuthorizationRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RelayNamespaceAuthorizationRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RelayNameSpaceAuthorizationRuleCreate() + public async Task Get_RelayNameSpaceAuthorizationRuleGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceAuthorizationRuleCreate.json - // this example is just showing the usage of "Namespaces_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceAuthorizationRuleGet.json + // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_RelayNameSpaceAuthorizationRuleCreate() RelayNamespaceAuthorizationRuleResource relayNamespaceAuthorizationRule = client.GetRelayNamespaceAuthorizationRuleResource(relayNamespaceAuthorizationRuleResourceId); // invoke the operation - RelayAuthorizationRuleData data = new RelayAuthorizationRuleData() - { - Rights = -{ -RelayAccessRight.Listen,RelayAccessRight.Send -}, - }; - ArmOperation lro = await relayNamespaceAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); - RelayNamespaceAuthorizationRuleResource result = lro.Value; + RelayNamespaceAuthorizationRuleResource result = await relayNamespaceAuthorizationRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -84,10 +76,10 @@ public async Task Delete_RelayNameSpaceAuthorizationRuleDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelayNameSpaceAuthorizationRuleGet() + public async Task Update_RelayNameSpaceAuthorizationRuleCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceAuthorizationRuleGet.json - // this example is just showing the usage of "Namespaces_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceAuthorizationRuleCreate.json + // this example is just showing the usage of "Namespaces_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,7 +96,12 @@ public async Task Get_RelayNameSpaceAuthorizationRuleGet() RelayNamespaceAuthorizationRuleResource relayNamespaceAuthorizationRule = client.GetRelayNamespaceAuthorizationRuleResource(relayNamespaceAuthorizationRuleResourceId); // invoke the operation - RelayNamespaceAuthorizationRuleResource result = await relayNamespaceAuthorizationRule.GetAsync(); + RelayAuthorizationRuleData data = new RelayAuthorizationRuleData + { + Rights = { RelayAccessRight.Listen, RelayAccessRight.Send }, + }; + ArmOperation lro = await relayNamespaceAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); + RelayNamespaceAuthorizationRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceCollection.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceCollection.cs index b1b873d86b212..c69629340c7d2 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceCollection.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceCollection.cs @@ -17,41 +17,6 @@ namespace Azure.ResourceManager.Relay.Samples { public partial class Sample_RelayNamespaceCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_RelayNameSpaceListByResourceGroup() - { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceListByResourceGroup.json - // this example is just showing the usage of "Namespaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "resourcegroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this RelayNamespaceResource - RelayNamespaceCollection collection = resourceGroupResource.GetRelayNamespaces(); - - // invoke the operation and iterate over the result - await foreach (RelayNamespaceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayNamespaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_RelayNamespaceCreate() @@ -85,7 +50,7 @@ public async Task CreateOrUpdate_RelayNamespaceCreate() Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, data); @@ -131,6 +96,41 @@ public async Task Get_RelayNameSpaceGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_RelayNameSpaceListByResourceGroup() + { + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceListByResourceGroup.json + // this example is just showing the usage of "Namespaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "resourcegroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this RelayNamespaceResource + RelayNamespaceCollection collection = resourceGroupResource.GetRelayNamespaces(); + + // invoke the operation and iterate over the result + await foreach (RelayNamespaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayNamespaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_RelayNameSpaceGet() diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceResource.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceResource.cs index 3a57c6b48c934..d9e847662b1a0 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceResource.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNamespaceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Relay.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Relay.Samples @@ -19,58 +18,32 @@ public partial class Sample_RelayNamespaceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CheckRelayNamespaceNameAvailability_RelayCheckNameAvailability() + public async Task Get_RelayNameSpaceGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceCheckNameAvailability.json - // this example is just showing the usage of "Namespaces_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceGet.json + // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this RelayNamespaceResource created on azure + // for more information of creating RelayNamespaceResource, please refer to the document of RelayNamespaceResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "RG-eg"; + string namespaceName = "example-RelayRelayNamespace-01"; + ResourceIdentifier relayNamespaceResourceId = RelayNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); + RelayNamespaceResource relayNamespace = client.GetRelayNamespaceResource(relayNamespaceResourceId); // invoke the operation - RelayNameAvailabilityContent content = new RelayNameAvailabilityContent("example-RelayNamespace1321"); - RelayNameAvailabilityResult result = await subscriptionResource.CheckRelayNamespaceNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetRelayNamespaces_RelayNameSpaceListBySubscription() - { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceListBySubscription.json - // this example is just showing the usage of "Namespaces_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (RelayNamespaceResource item in subscriptionResource.GetRelayNamespacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayNamespaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + RelayNamespaceResource result = await relayNamespace.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayNamespaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -99,36 +72,6 @@ public async Task Delete_RelayNameSpaceDelete() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_RelayNameSpaceGet() - { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceGet.json - // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this RelayNamespaceResource created on azure - // for more information of creating RelayNamespaceResource, please refer to the document of RelayNamespaceResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "RG-eg"; - string namespaceName = "example-RelayRelayNamespace-01"; - ResourceIdentifier relayNamespaceResourceId = RelayNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); - RelayNamespaceResource relayNamespace = client.GetRelayNamespaceResource(relayNamespaceResourceId); - - // invoke the operation - RelayNamespaceResource result = await relayNamespace.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayNamespaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Update_RelayNameSpaceUpdate() @@ -150,14 +93,14 @@ public async Task Update_RelayNameSpaceUpdate() RelayNamespaceResource relayNamespace = client.GetRelayNamespaceResource(relayNamespaceResourceId); // invoke the operation - RelayNamespacePatch patch = new RelayNamespacePatch() + RelayNamespacePatch patch = new RelayNamespacePatch { Tags = { ["tag3"] = "value3", ["tag4"] = "value4", ["tag5"] = "value5", -["tag6"] = "value6", +["tag6"] = "value6" }, }; RelayNamespaceResource result = await relayNamespace.UpdateAsync(patch); diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNetworkRuleSetResource.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNetworkRuleSetResource.cs index 2a3f9fbbf00ea..ab81bc502ce4d 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNetworkRuleSetResource.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayNetworkRuleSetResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RelayNetworkRuleSetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NameSpaceNetworkRuleSetCreate() + public async Task Get_NameSpaceNetworkRuleSetGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/VirtualNetworkRules/RelayNetworkRuleSetCreate.json - // this example is just showing the usage of "Namespaces_CreateOrUpdateNetworkRuleSet" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/VirtualNetworkRules/RelayNetworkRuleSetGet.json + // this example is just showing the usage of "Namespaces_GetNetworkRuleSet" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,36 +37,7 @@ public async Task CreateOrUpdate_NameSpaceNetworkRuleSetCreate() RelayNetworkRuleSetResource relayNetworkRuleSet = client.GetRelayNetworkRuleSetResource(relayNetworkRuleSetResourceId); // invoke the operation - RelayNetworkRuleSetData data = new RelayNetworkRuleSetData() - { - DefaultAction = RelayNetworkRuleSetDefaultAction.Deny, - IPRules = -{ -new RelayNetworkRuleSetIPRule() -{ -IPMask = "1.1.1.1", -Action = RelayNetworkRuleIPAction.Allow, -},new RelayNetworkRuleSetIPRule() -{ -IPMask = "1.1.1.2", -Action = RelayNetworkRuleIPAction.Allow, -},new RelayNetworkRuleSetIPRule() -{ -IPMask = "1.1.1.3", -Action = RelayNetworkRuleIPAction.Allow, -},new RelayNetworkRuleSetIPRule() -{ -IPMask = "1.1.1.4", -Action = RelayNetworkRuleIPAction.Allow, -},new RelayNetworkRuleSetIPRule() -{ -IPMask = "1.1.1.5", -Action = RelayNetworkRuleIPAction.Allow, -} -}, - }; - ArmOperation lro = await relayNetworkRuleSet.CreateOrUpdateAsync(WaitUntil.Completed, data); - RelayNetworkRuleSetResource result = lro.Value; + RelayNetworkRuleSetResource result = await relayNetworkRuleSet.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -77,10 +48,10 @@ public async Task CreateOrUpdate_NameSpaceNetworkRuleSetCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpaceNetworkRuleSetGet() + public async Task CreateOrUpdate_NameSpaceNetworkRuleSetCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/VirtualNetworkRules/RelayNetworkRuleSetGet.json - // this example is just showing the usage of "Namespaces_GetNetworkRuleSet" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/VirtualNetworkRules/RelayNetworkRuleSetCreate.json + // this example is just showing the usage of "Namespaces_CreateOrUpdateNetworkRuleSet" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,7 +67,33 @@ public async Task Get_NameSpaceNetworkRuleSetGet() RelayNetworkRuleSetResource relayNetworkRuleSet = client.GetRelayNetworkRuleSetResource(relayNetworkRuleSetResourceId); // invoke the operation - RelayNetworkRuleSetResource result = await relayNetworkRuleSet.GetAsync(); + RelayNetworkRuleSetData data = new RelayNetworkRuleSetData + { + DefaultAction = RelayNetworkRuleSetDefaultAction.Deny, + IPRules = {new RelayNetworkRuleSetIPRule +{ +IPMask = "1.1.1.1", +Action = RelayNetworkRuleIPAction.Allow, +}, new RelayNetworkRuleSetIPRule +{ +IPMask = "1.1.1.2", +Action = RelayNetworkRuleIPAction.Allow, +}, new RelayNetworkRuleSetIPRule +{ +IPMask = "1.1.1.3", +Action = RelayNetworkRuleIPAction.Allow, +}, new RelayNetworkRuleSetIPRule +{ +IPMask = "1.1.1.4", +Action = RelayNetworkRuleIPAction.Allow, +}, new RelayNetworkRuleSetIPRule +{ +IPMask = "1.1.1.5", +Action = RelayNetworkRuleIPAction.Allow, +}}, + }; + ArmOperation lro = await relayNetworkRuleSet.CreateOrUpdateAsync(WaitUntil.Completed, data); + RelayNetworkRuleSetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateEndpointConnectionCollection.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateEndpointConnectionCollection.cs index 1614c898f48be..03d84e81cff27 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateEndpointConnectionCollection.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateEndpointConnectionCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.Relay.Samples { public partial class Sample_RelayPrivateEndpointConnectionCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsList() - { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateEndpointConnectionsList.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this RelayNamespaceResource created on azure - // for more information of creating RelayNamespaceResource, please refer to the document of RelayNamespaceResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "myResourceGroup"; - string namespaceName = "example-RelayNamespace-5849"; - ResourceIdentifier relayNamespaceResourceId = RelayNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); - RelayNamespaceResource relayNamespace = client.GetRelayNamespaceResource(relayNamespaceResourceId); - - // get the collection of this RelayPrivateEndpointConnectionResource - RelayPrivateEndpointConnectionCollection collection = relayNamespace.GetRelayPrivateEndpointConnections(); - - // invoke the operation and iterate over the result - await foreach (RelayPrivateEndpointConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_NameSpacePrivateEndPointConnectionCreate() @@ -77,10 +41,10 @@ public async Task CreateOrUpdate_NameSpacePrivateEndPointConnectionCreate() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnection name}"; - RelayPrivateEndpointConnectionData data = new RelayPrivateEndpointConnectionData() + RelayPrivateEndpointConnectionData data = new RelayPrivateEndpointConnectionData { PrivateEndpointId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/resourcegroup/providers/Microsoft.Network/privateEndpoints/ali-relay-pve-1"), - ConnectionState = new RelayPrivateLinkServiceConnectionState() + ConnectionState = new RelayPrivateLinkServiceConnectionState { Status = RelayPrivateLinkConnectionStatus.Approved, Description = "You may pass", @@ -130,6 +94,42 @@ public async Task Get_NameSpacePrivateEndPointConnectionGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_PrivateEndpointConnectionsList() + { + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateEndpointConnectionsList.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this RelayNamespaceResource created on azure + // for more information of creating RelayNamespaceResource, please refer to the document of RelayNamespaceResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "myResourceGroup"; + string namespaceName = "example-RelayNamespace-5849"; + ResourceIdentifier relayNamespaceResourceId = RelayNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); + RelayNamespaceResource relayNamespace = client.GetRelayNamespaceResource(relayNamespaceResourceId); + + // get the collection of this RelayPrivateEndpointConnectionResource + RelayPrivateEndpointConnectionCollection collection = relayNamespace.GetRelayPrivateEndpointConnections(); + + // invoke the operation and iterate over the result + await foreach (RelayPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_NameSpacePrivateEndPointConnectionGet() diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateEndpointConnectionResource.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateEndpointConnectionResource.cs index 33fd1dae41f9c..b2b81fe52b95c 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateEndpointConnectionResource.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RelayPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NameSpacePrivateEndPointConnectionCreate() + public async Task Get_NameSpacePrivateEndPointConnectionGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateEndpointConnectionsCreate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateEndpointConnectionsGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,24 +31,14 @@ public async Task Update_NameSpacePrivateEndPointConnectionCreate() // this example assumes you already have this RelayPrivateEndpointConnectionResource created on azure // for more information of creating RelayPrivateEndpointConnectionResource, please refer to the document of RelayPrivateEndpointConnectionResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "resourcegroup"; + string resourceGroupName = "myResourceGroup"; string namespaceName = "example-RelayNamespace-5849"; string privateEndpointConnectionName = "{privateEndpointConnection name}"; ResourceIdentifier relayPrivateEndpointConnectionResourceId = RelayPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName); RelayPrivateEndpointConnectionResource relayPrivateEndpointConnection = client.GetRelayPrivateEndpointConnectionResource(relayPrivateEndpointConnectionResourceId); // invoke the operation - RelayPrivateEndpointConnectionData data = new RelayPrivateEndpointConnectionData() - { - PrivateEndpointId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/resourcegroup/providers/Microsoft.Network/privateEndpoints/ali-relay-pve-1"), - ConnectionState = new RelayPrivateLinkServiceConnectionState() - { - Status = RelayPrivateLinkConnectionStatus.Approved, - Description = "You may pass", - }, - }; - ArmOperation lro = await relayPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - RelayPrivateEndpointConnectionResource result = lro.Value; + RelayPrivateEndpointConnectionResource result = await relayPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,10 +76,10 @@ public async Task Delete_NameSpacePrivateEndPointConnectionDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpacePrivateEndPointConnectionGet() + public async Task Update_NameSpacePrivateEndPointConnectionCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateEndpointConnectionsGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateEndpointConnectionsCreate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,14 +89,24 @@ public async Task Get_NameSpacePrivateEndPointConnectionGet() // this example assumes you already have this RelayPrivateEndpointConnectionResource created on azure // for more information of creating RelayPrivateEndpointConnectionResource, please refer to the document of RelayPrivateEndpointConnectionResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "myResourceGroup"; + string resourceGroupName = "resourcegroup"; string namespaceName = "example-RelayNamespace-5849"; string privateEndpointConnectionName = "{privateEndpointConnection name}"; ResourceIdentifier relayPrivateEndpointConnectionResourceId = RelayPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName); RelayPrivateEndpointConnectionResource relayPrivateEndpointConnection = client.GetRelayPrivateEndpointConnectionResource(relayPrivateEndpointConnectionResourceId); // invoke the operation - RelayPrivateEndpointConnectionResource result = await relayPrivateEndpointConnection.GetAsync(); + RelayPrivateEndpointConnectionData data = new RelayPrivateEndpointConnectionData + { + PrivateEndpointId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/resourcegroup/providers/Microsoft.Network/privateEndpoints/ali-relay-pve-1"), + ConnectionState = new RelayPrivateLinkServiceConnectionState + { + Status = RelayPrivateLinkConnectionStatus.Approved, + Description = "You may pass", + }, + }; + ArmOperation lro = await relayPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + RelayPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateLinkResourceCollection.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateLinkResourceCollection.cs index 8fa12ddeae49f..37d5714a1ca7b 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateLinkResourceCollection.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_RelayPrivateLinkResourceCollection.cs @@ -51,10 +51,10 @@ public async Task Get_NameSpacePrivateEndPointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NameSpacePrivateEndPointConnectionGet() + public async Task GetAll_NameSpacePrivateLinkResourcesGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateLinkResourcesGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateLinkResourcesList.json + // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_NameSpacePrivateEndPointConnectionGet() // get the collection of this RelayPrivateLinkResource RelayPrivateLinkResourceCollection collection = relayNamespace.GetRelayPrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "{PrivateLinkResource name}"; - bool result = await collection.ExistsAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (RelayPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NameSpacePrivateEndPointConnectionGet() + public async Task Exists_NameSpacePrivateEndPointConnectionGet() { // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateLinkResourcesGet.json // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_NameSpacePrivateEndPointConnectionGet() // invoke the operation string privateLinkResourceName = "{PrivateLinkResource name}"; - NullableResponse response = await collection.GetIfExistsAsync(privateLinkResourceName); - RelayPrivateLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateLinkResourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NameSpacePrivateLinkResourcesGet() + public async Task GetIfExists_NameSpacePrivateEndPointConnectionGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateLinkResourcesList.json - // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/PrivateEndpointConnections/PrivateLinkResourcesGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_NameSpacePrivateLinkResourcesGet() // get the collection of this RelayPrivateLinkResource RelayPrivateLinkResourceCollection collection = relayNamespace.GetRelayPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (RelayPrivateLinkResource item in collection.GetAllAsync()) + // invoke the operation + string privateLinkResourceName = "{PrivateLinkResource name}"; + NullableResponse response = await collection.GetIfExistsAsync(privateLinkResourceName); + RelayPrivateLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RelayPrivateLinkResourceData resourceData = item.Data; + RelayPrivateLinkResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..1fa6f3f1625cc --- /dev/null +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Relay.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Relay.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckRelayNamespaceNameAvailability_RelayCheckNameAvailability() + { + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceCheckNameAvailability.json + // this example is just showing the usage of "Namespaces_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + RelayNameAvailabilityContent content = new RelayNameAvailabilityContent("example-RelayNamespace1321"); + RelayNameAvailabilityResult result = await subscriptionResource.CheckRelayNamespaceNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetRelayNamespaces_RelayNameSpaceListBySubscription() + { + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/NameSpaces/RelayNameSpaceListBySubscription.json + // this example is just showing the usage of "Namespaces_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (RelayNamespaceResource item in subscriptionResource.GetRelayNamespacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayNamespaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayAuthorizationRuleCollection.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayAuthorizationRuleCollection.cs index 099a25c320ec7..83deb610a9653 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayAuthorizationRuleCollection.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayAuthorizationRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_WcfRelayAuthorizationRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RelayAuthorizationRuleListAll() + public async Task CreateOrUpdate_RelayAuthorizationRuleCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayAuthorizationRuleListAll.json - // this example is just showing the usage of "WCFRelays_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayAuthorizationRuleCreate.json + // this example is just showing the usage of "WCFRelays_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,32 +33,35 @@ public async Task GetAll_RelayAuthorizationRuleListAll() string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "resourcegroup"; string namespaceName = "example-RelayNamespace-01"; - string relayName = "example-Relay-Wcf-01"; + string relayName = "example-Relay-wcf-01"; ResourceIdentifier wcfRelayResourceId = WcfRelayResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, relayName); WcfRelayResource wcfRelay = client.GetWcfRelayResource(wcfRelayResourceId); // get the collection of this WcfRelayAuthorizationRuleResource WcfRelayAuthorizationRuleCollection collection = wcfRelay.GetWcfRelayAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (WcfRelayAuthorizationRuleResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationRuleName = "example-RelayAuthRules-01"; + RelayAuthorizationRuleData data = new RelayAuthorizationRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayAuthorizationRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Rights = { RelayAccessRight.Listen, RelayAccessRight.Send }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); + WcfRelayAuthorizationRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RelayAuthorizationRuleCreate() + public async Task Get_RelayAuthorizationRuleGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayAuthorizationRuleCreate.json - // this example is just showing the usage of "WCFRelays_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayAuthorizationRuleGet.json + // this example is just showing the usage of "WCFRelays_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +82,7 @@ public async Task CreateOrUpdate_RelayAuthorizationRuleCreate() // invoke the operation string authorizationRuleName = "example-RelayAuthRules-01"; - RelayAuthorizationRuleData data = new RelayAuthorizationRuleData() - { - Rights = -{ -RelayAccessRight.Listen,RelayAccessRight.Send -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); - WcfRelayAuthorizationRuleResource result = lro.Value; + WcfRelayAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -98,10 +93,10 @@ public async Task CreateOrUpdate_RelayAuthorizationRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelayAuthorizationRuleGet() + public async Task GetAll_RelayAuthorizationRuleListAll() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayAuthorizationRuleGet.json - // this example is just showing the usage of "WCFRelays_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayAuthorizationRuleListAll.json + // this example is just showing the usage of "WCFRelays_ListAuthorizationRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,22 +108,24 @@ public async Task Get_RelayAuthorizationRuleGet() string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "resourcegroup"; string namespaceName = "example-RelayNamespace-01"; - string relayName = "example-Relay-wcf-01"; + string relayName = "example-Relay-Wcf-01"; ResourceIdentifier wcfRelayResourceId = WcfRelayResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, relayName); WcfRelayResource wcfRelay = client.GetWcfRelayResource(wcfRelayResourceId); // get the collection of this WcfRelayAuthorizationRuleResource WcfRelayAuthorizationRuleCollection collection = wcfRelay.GetWcfRelayAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "example-RelayAuthRules-01"; - WcfRelayAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (WcfRelayAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelayAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelayAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayAuthorizationRuleResource.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayAuthorizationRuleResource.cs index f60115d653a87..7a05a269c3b8d 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayAuthorizationRuleResource.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayAuthorizationRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_WcfRelayAuthorizationRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RelayAuthorizationRuleCreate() + public async Task Get_RelayAuthorizationRuleGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayAuthorizationRuleCreate.json - // this example is just showing the usage of "WCFRelays_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayAuthorizationRuleGet.json + // this example is just showing the usage of "WCFRelays_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,15 +39,7 @@ public async Task Update_RelayAuthorizationRuleCreate() WcfRelayAuthorizationRuleResource wcfRelayAuthorizationRule = client.GetWcfRelayAuthorizationRuleResource(wcfRelayAuthorizationRuleResourceId); // invoke the operation - RelayAuthorizationRuleData data = new RelayAuthorizationRuleData() - { - Rights = -{ -RelayAccessRight.Listen,RelayAccessRight.Send -}, - }; - ArmOperation lro = await wcfRelayAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); - WcfRelayAuthorizationRuleResource result = lro.Value; + WcfRelayAuthorizationRuleResource result = await wcfRelayAuthorizationRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,10 +78,10 @@ public async Task Delete_RelayAuthorizationRuleDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelayAuthorizationRuleGet() + public async Task Update_RelayAuthorizationRuleCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayAuthorizationRuleGet.json - // this example is just showing the usage of "WCFRelays_GetAuthorizationRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayAuthorizationRuleCreate.json + // this example is just showing the usage of "WCFRelays_CreateOrUpdateAuthorizationRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,7 +99,12 @@ public async Task Get_RelayAuthorizationRuleGet() WcfRelayAuthorizationRuleResource wcfRelayAuthorizationRule = client.GetWcfRelayAuthorizationRuleResource(wcfRelayAuthorizationRuleResourceId); // invoke the operation - WcfRelayAuthorizationRuleResource result = await wcfRelayAuthorizationRule.GetAsync(); + RelayAuthorizationRuleData data = new RelayAuthorizationRuleData + { + Rights = { RelayAccessRight.Listen, RelayAccessRight.Send }, + }; + ArmOperation lro = await wcfRelayAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); + WcfRelayAuthorizationRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayCollection.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayCollection.cs index 28000280156aa..ca6bdd7755d2d 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayCollection.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_WcfRelayCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RelayListAll() + public async Task CreateOrUpdate_RelayCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayListAll.json - // this example is just showing the usage of "WCFRelays_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayCreate.json + // this example is just showing the usage of "WCFRelays_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,32 +32,37 @@ public async Task GetAll_RelayListAll() // for more information of creating RelayNamespaceResource, please refer to the document of RelayNamespaceResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "resourcegroup"; - string namespaceName = "example-RelayNamespace-01"; + string namespaceName = "example-RelayNamespace-9953"; ResourceIdentifier relayNamespaceResourceId = RelayNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); RelayNamespaceResource relayNamespace = client.GetRelayNamespaceResource(relayNamespaceResourceId); // get the collection of this WcfRelayResource WcfRelayCollection collection = relayNamespace.GetWcfRelays(); - // invoke the operation and iterate over the result - await foreach (WcfRelayResource item in collection.GetAllAsync()) + // invoke the operation + string relayName = "example-Relay-Wcf-1194"; + WcfRelayData data = new WcfRelayData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WcfRelayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + RelayType = RelayType.NetTcp, + IsClientAuthorizationRequired = true, + IsTransportSecurityRequired = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, relayName, data); + WcfRelayResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WcfRelayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RelayCreate() + public async Task Get_RelayGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayCreate.json - // this example is just showing the usage of "WCFRelays_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayGet.json + // this example is just showing the usage of "WCFRelays_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,14 +82,7 @@ public async Task CreateOrUpdate_RelayCreate() // invoke the operation string relayName = "example-Relay-Wcf-1194"; - WcfRelayData data = new WcfRelayData() - { - RelayType = RelayType.NetTcp, - IsClientAuthorizationRequired = true, - IsTransportSecurityRequired = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, relayName, data); - WcfRelayResource result = lro.Value; + WcfRelayResource result = await collection.GetAsync(relayName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -95,10 +93,10 @@ public async Task CreateOrUpdate_RelayCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelayGet() + public async Task GetAll_RelayListAll() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayGet.json - // this example is just showing the usage of "WCFRelays_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayListAll.json + // this example is just showing the usage of "WCFRelays_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,22 +107,24 @@ public async Task Get_RelayGet() // for more information of creating RelayNamespaceResource, please refer to the document of RelayNamespaceResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "resourcegroup"; - string namespaceName = "example-RelayNamespace-9953"; + string namespaceName = "example-RelayNamespace-01"; ResourceIdentifier relayNamespaceResourceId = RelayNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); RelayNamespaceResource relayNamespace = client.GetRelayNamespaceResource(relayNamespaceResourceId); // get the collection of this WcfRelayResource WcfRelayCollection collection = relayNamespace.GetWcfRelays(); - // invoke the operation - string relayName = "example-Relay-Wcf-1194"; - WcfRelayResource result = await collection.GetAsync(relayName); + // invoke the operation and iterate over the result + await foreach (WcfRelayResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WcfRelayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WcfRelayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayResource.cs b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayResource.cs index 0c7768ad0ff87..612f85e2f12a0 100644 --- a/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayResource.cs +++ b/sdk/relay/Azure.ResourceManager.Relay/samples/Generated/Samples/Sample_WcfRelayResource.cs @@ -18,10 +18,10 @@ public partial class Sample_WcfRelayResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RelayCreate() + public async Task Get_RelayGet() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayCreate.json - // this example is just showing the usage of "WCFRelays_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayGet.json + // this example is just showing the usage of "WCFRelays_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,14 +38,7 @@ public async Task Update_RelayCreate() WcfRelayResource wcfRelay = client.GetWcfRelayResource(wcfRelayResourceId); // invoke the operation - WcfRelayData data = new WcfRelayData() - { - RelayType = RelayType.NetTcp, - IsClientAuthorizationRequired = true, - IsTransportSecurityRequired = true, - }; - ArmOperation lro = await wcfRelay.UpdateAsync(WaitUntil.Completed, data); - WcfRelayResource result = lro.Value; + WcfRelayResource result = await wcfRelay.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -83,10 +76,10 @@ public async Task Delete_RelayDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelayGet() + public async Task Update_RelayCreate() { - // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayGet.json - // this example is just showing the usage of "WCFRelays_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/relay/resource-manager/Microsoft.Relay/stable/2021-11-01/examples/Relay/RelayCreate.json + // this example is just showing the usage of "WCFRelays_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,7 +96,14 @@ public async Task Get_RelayGet() WcfRelayResource wcfRelay = client.GetWcfRelayResource(wcfRelayResourceId); // invoke the operation - WcfRelayResource result = await wcfRelay.GetAsync(); + WcfRelayData data = new WcfRelayData + { + RelayType = RelayType.NetTcp, + IsClientAuthorizationRequired = true, + IsTransportSecurityRequired = true, + }; + ArmOperation lro = await wcfRelay.UpdateAsync(WaitUntil.Completed, data); + WcfRelayResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_QuotaRequestDetailCollection.cs b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_QuotaRequestDetailCollection.cs index d6af6be229bf6..29d5f715a6706 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_QuotaRequestDetailCollection.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_QuotaRequestDetailCollection.cs @@ -52,9 +52,9 @@ public async Task Get_QuotaRequestFailed() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotaRequestFailed() + public async Task Get_QuotaRequestInProgress() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusFailed.json + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusInProgress.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -75,16 +75,20 @@ public async Task Exists_QuotaRequestFailed() // invoke the operation Guid id = Guid.Parse("2B5C8515-37D8-4B6A-879B-CD641A2CF605"); - bool result = await collection.ExistsAsync(id); + QuotaRequestDetailResource result = await collection.GetAsync(id); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaRequestDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotaRequestFailed() + public async Task Get_QuotaRequestStatus() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusFailed.json + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusById.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -105,29 +109,21 @@ public async Task GetIfExists_QuotaRequestFailed() // invoke the operation Guid id = Guid.Parse("2B5C8515-37D8-4B6A-879B-CD641A2CF605"); - NullableResponse response = await collection.GetIfExistsAsync(id); - QuotaRequestDetailResource result = response.HasValue ? response.Value : null; + QuotaRequestDetailResource result = await collection.GetAsync(id); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaRequestDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaRequestDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QuotaRequestInProgress() + public async Task GetAll_QuotaRequestHistory() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusInProgress.json - // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestsHistory.json + // this example is just showing the usage of "QuotaRequestStatus_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,7 +132,7 @@ public async Task Get_QuotaRequestInProgress() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "3f75fdf7-977e-44ad-990d-99f14f0f299f"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); @@ -145,22 +141,24 @@ public async Task Get_QuotaRequestInProgress() AzureLocation location = new AzureLocation("eastus"); QuotaRequestDetailCollection collection = subscriptionResource.GetQuotaRequestDetails(providerId, location); - // invoke the operation - Guid id = Guid.Parse("2B5C8515-37D8-4B6A-879B-CD641A2CF605"); - QuotaRequestDetailResource result = await collection.GetAsync(id); + // invoke the operation and iterate over the result + await foreach (QuotaRequestDetailResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaRequestDetailData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaRequestDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotaRequestInProgress() + public async Task Exists_QuotaRequestFailed() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusInProgress.json + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusFailed.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -188,7 +186,7 @@ public async Task Exists_QuotaRequestInProgress() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotaRequestInProgress() + public async Task Exists_QuotaRequestInProgress() { // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusInProgress.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. @@ -211,26 +209,14 @@ public async Task GetIfExists_QuotaRequestInProgress() // invoke the operation Guid id = Guid.Parse("2B5C8515-37D8-4B6A-879B-CD641A2CF605"); - NullableResponse response = await collection.GetIfExistsAsync(id); - QuotaRequestDetailResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(id); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaRequestDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QuotaRequestStatus() + public async Task Exists_QuotaRequestStatus() { // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusById.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. @@ -253,20 +239,16 @@ public async Task Get_QuotaRequestStatus() // invoke the operation Guid id = Guid.Parse("2B5C8515-37D8-4B6A-879B-CD641A2CF605"); - QuotaRequestDetailResource result = await collection.GetAsync(id); + bool result = await collection.ExistsAsync(id); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - QuotaRequestDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotaRequestStatus() + public async Task GetIfExists_QuotaRequestFailed() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusById.json + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusFailed.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -287,16 +269,28 @@ public async Task Exists_QuotaRequestStatus() // invoke the operation Guid id = Guid.Parse("2B5C8515-37D8-4B6A-879B-CD641A2CF605"); - bool result = await collection.ExistsAsync(id); + NullableResponse response = await collection.GetIfExistsAsync(id); + QuotaRequestDetailResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + QuotaRequestDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotaRequestStatus() + public async Task GetIfExists_QuotaRequestInProgress() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusById.json + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusInProgress.json // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -336,10 +330,10 @@ public async Task GetIfExists_QuotaRequestStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QuotaRequestHistory() + public async Task GetIfExists_QuotaRequestStatus() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestsHistory.json - // this example is just showing the usage of "QuotaRequestStatus_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getQuotaRequestStatusById.json + // this example is just showing the usage of "QuotaRequestStatus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -348,7 +342,7 @@ public async Task GetAll_QuotaRequestHistory() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "3f75fdf7-977e-44ad-990d-99f14f0f299f"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); @@ -357,17 +351,23 @@ public async Task GetAll_QuotaRequestHistory() AzureLocation location = new AzureLocation("eastus"); QuotaRequestDetailCollection collection = subscriptionResource.GetQuotaRequestDetails(providerId, location); - // invoke the operation and iterate over the result - await foreach (QuotaRequestDetailResource item in collection.GetAllAsync()) + // invoke the operation + Guid id = Guid.Parse("2B5C8515-37D8-4B6A-879B-CD641A2CF605"); + NullableResponse response = await collection.GetIfExistsAsync(id); + QuotaRequestDetailResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - QuotaRequestDetailData resourceData = item.Data; + QuotaRequestDetailData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationDetailCollection.cs b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationDetailCollection.cs index ce91f6d948418..4b65b25df9b24 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationDetailCollection.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationDetailCollection.cs @@ -15,6 +15,39 @@ namespace Azure.ResourceManager.Reservations.Samples { public partial class Sample_ReservationDetailCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetReservation() + { + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationDetails.json + // this example is just showing the usage of "Reservation_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ReservationOrderResource created on azure + // for more information of creating ReservationOrderResource, please refer to the document of ReservationOrderResource + Guid reservationOrderId = Guid.Parse("276e7ae4-84d0-4da6-ab4b-d6b94f3557da"); + ResourceIdentifier reservationOrderResourceId = ReservationOrderResource.CreateResourceIdentifier(reservationOrderId); + ReservationOrderResource reservationOrder = client.GetReservationOrderResource(reservationOrderResourceId); + + // get the collection of this ReservationDetailResource + ReservationDetailCollection collection = reservationOrder.GetReservationDetails(); + + // invoke the operation + Guid reservationId = Guid.Parse("6ef59113-3482-40da-8d79-787f823e34bc"); + string expand = "renewProperties"; + ReservationDetailResource result = await collection.GetAsync(reservationId, expand: expand); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReservationDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ReservationList() @@ -51,10 +84,10 @@ public async Task GetAll_ReservationList() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetReservation() + public async Task GetRevisions_ReservationRevisions() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationDetails.json - // this example is just showing the usage of "Reservation_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationRevisions.json + // this example is just showing the usage of "Reservation_ListRevisions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,16 +103,18 @@ public async Task Get_GetReservation() // get the collection of this ReservationDetailResource ReservationDetailCollection collection = reservationOrder.GetReservationDetails(); - // invoke the operation + // invoke the operation and iterate over the result Guid reservationId = Guid.Parse("6ef59113-3482-40da-8d79-787f823e34bc"); - string expand = "renewProperties"; - ReservationDetailResource result = await collection.GetAsync(reservationId, expand: expand); + await foreach (ReservationDetailResource item in collection.GetRevisionsAsync(reservationId)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReservationDetailData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReservationDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -151,40 +186,5 @@ public async Task GetIfExists_GetReservation() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetRevisions_ReservationRevisions() - { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationRevisions.json - // this example is just showing the usage of "Reservation_ListRevisions" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ReservationOrderResource created on azure - // for more information of creating ReservationOrderResource, please refer to the document of ReservationOrderResource - Guid reservationOrderId = Guid.Parse("276e7ae4-84d0-4da6-ab4b-d6b94f3557da"); - ResourceIdentifier reservationOrderResourceId = ReservationOrderResource.CreateResourceIdentifier(reservationOrderId); - ReservationOrderResource reservationOrder = client.GetReservationOrderResource(reservationOrderResourceId); - - // get the collection of this ReservationDetailResource - ReservationDetailCollection collection = reservationOrder.GetReservationDetails(); - - // invoke the operation and iterate over the result - Guid reservationId = Guid.Parse("6ef59113-3482-40da-8d79-787f823e34bc"); - await foreach (ReservationDetailResource item in collection.GetRevisionsAsync(reservationId)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReservationDetailData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationDetailResource.cs b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationDetailResource.cs index 2f7d275a50800..37a4b74ec4f22 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationDetailResource.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationDetailResource.cs @@ -16,39 +16,6 @@ namespace Azure.ResourceManager.Reservations.Samples { public partial class Sample_ReservationDetailResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAvailableScopes_AvailableScopes() - { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetAvailableScope.json - // this example is just showing the usage of "Reservation_AvailableScopes" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ReservationDetailResource created on azure - // for more information of creating ReservationDetailResource, please refer to the document of ReservationDetailResource - Guid reservationOrderId = Guid.Parse("276e7ae4-84d0-4da6-ab4b-d6b94f3557da"); - Guid reservationId = Guid.Parse("356e7ae4-84d0-4da6-ab4b-d6b94f3557da"); - ResourceIdentifier reservationDetailResourceId = ReservationDetailResource.CreateResourceIdentifier(reservationOrderId, reservationId); - ReservationDetailResource reservationDetail = client.GetReservationDetailResource(reservationDetailResourceId); - - // invoke the operation - AvailableScopesContent content = new AvailableScopesContent() - { - Scopes = -{ -"/subscriptions/efc7c997-7700-4a74-b731-55aec16c15e9" -}, - }; - ArmOperation lro = await reservationDetail.GetAvailableScopesAsync(WaitUntil.Completed, content); - AvailableScopesProperties result = lro.Value; - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetReservation() @@ -99,7 +66,7 @@ public async Task Update_PatchReservation() ReservationDetailResource reservationDetail = client.GetReservationDetailResource(reservationDetailResourceId); // invoke the operation - ReservationDetailPatch patch = new ReservationDetailPatch() + ReservationDetailPatch patch = new ReservationDetailPatch { AppliedScopeType = AppliedScopeType.Shared, InstanceFlexibility = InstanceFlexibility.Off, @@ -116,10 +83,10 @@ public async Task Update_PatchReservation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Archive_Archive() + public async Task GetAvailableScopes_AvailableScopes() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/Archive.json - // this example is just showing the usage of "Reservation_Archive" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetAvailableScope.json + // this example is just showing the usage of "Reservation_AvailableScopes" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,17 +101,22 @@ public async Task Archive_Archive() ReservationDetailResource reservationDetail = client.GetReservationDetailResource(reservationDetailResourceId); // invoke the operation - await reservationDetail.ArchiveAsync(); + AvailableScopesContent content = new AvailableScopesContent + { + Scopes = { "/subscriptions/efc7c997-7700-4a74-b731-55aec16c15e9" }, + }; + ArmOperation lro = await reservationDetail.GetAvailableScopesAsync(WaitUntil.Completed, content); + AvailableScopesProperties result = lro.Value; - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Unarchive_Unarchive() + public async Task Archive_Archive() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/Unarchive.json - // this example is just showing the usage of "Reservation_Unarchive" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/Archive.json + // this example is just showing the usage of "Reservation_Archive" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -159,37 +131,32 @@ public async Task Unarchive_Unarchive() ReservationDetailResource reservationDetail = client.GetReservationDetailResource(reservationDetailResourceId); // invoke the operation - await reservationDetail.UnarchiveAsync(); + await reservationDetail.ArchiveAsync(); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetReservationDetails_ReservationListAll() + public async Task Unarchive_Unarchive() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservations.json - // this example is just showing the usage of "Reservation_ListAll" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/Unarchive.json + // this example is just showing the usage of "Reservation_Unarchive" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + // this example assumes you already have this ReservationDetailResource created on azure + // for more information of creating ReservationDetailResource, please refer to the document of ReservationDetailResource + Guid reservationOrderId = Guid.Parse("276e7ae4-84d0-4da6-ab4b-d6b94f3557da"); + Guid reservationId = Guid.Parse("356e7ae4-84d0-4da6-ab4b-d6b94f3557da"); + ResourceIdentifier reservationDetailResourceId = ReservationDetailResource.CreateResourceIdentifier(reservationOrderId, reservationId); + ReservationDetailResource reservationDetail = client.GetReservationDetailResource(reservationDetailResourceId); - // invoke the operation and iterate over the result - TenantResourceGetReservationDetailsOptions options = new TenantResourceGetReservationDetailsOptions() { Filter = "(properties%2farchived+eq+false)", Orderby = "properties/displayName asc", Skiptoken = 50, Take = 1 }; - await foreach (ReservationDetailResource item in tenantResource.GetReservationDetailsAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReservationDetailData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + await reservationDetail.UnarchiveAsync(); Console.WriteLine("Succeeded"); } diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationOrderCollection.cs b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationOrderCollection.cs index 91b8823e01717..5215943ca0e05 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationOrderCollection.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationOrderCollection.cs @@ -10,44 +10,13 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Reservations.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Reservations.Samples { public partial class Sample_ReservationOrderCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ReservationOrderList() - { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrders.json - // this example is just showing the usage of "ReservationOrder_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this ReservationOrderResource - ReservationOrderCollection collection = tenantResource.GetReservationOrders(); - - // invoke the operation and iterate over the result - await foreach (ReservationOrderResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReservationOrderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_Purchase() @@ -60,16 +29,14 @@ public async Task CreateOrUpdate_Purchase() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ReservationOrderResource ReservationOrderCollection collection = tenantResource.GetReservationOrders(); // invoke the operation Guid reservationOrderId = Guid.Parse("a075419f-44cc-497f-b68a-14ee811d48b9"); - ReservationPurchaseContent content = new ReservationPurchaseContent() + ReservationPurchaseContent content = new ReservationPurchaseContent { SkuName = "standard_D1", Location = new AzureLocation("westus"), @@ -80,9 +47,7 @@ public async Task CreateOrUpdate_Purchase() Quantity = 1, DisplayName = "TestReservationOrder", AppliedScopeType = AppliedScopeType.Shared, - AppliedScopes = -{ -}, + AppliedScopes = { }, IsRenewEnabled = false, ReservedResourceInstanceFlexibility = InstanceFlexibility.On, }; @@ -108,9 +73,7 @@ public async Task Get_GetReservationOrder() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ReservationOrderResource ReservationOrderCollection collection = tenantResource.GetReservationOrders(); @@ -128,9 +91,9 @@ public async Task Get_GetReservationOrder() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetReservationOrder() + public async Task Get_GetReservationWithExpandPayments() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetails.json + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetailsWithExpandPlanInformation.json // this example is just showing the usage of "ReservationOrder_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -138,63 +101,58 @@ public async Task Exists_GetReservationOrder() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ReservationOrderResource ReservationOrderCollection collection = tenantResource.GetReservationOrders(); // invoke the operation Guid reservationOrderId = Guid.Parse("a075419f-44cc-497f-b68a-14ee811d48b9"); - bool result = await collection.ExistsAsync(reservationOrderId); + string expand = "schedule"; + ReservationOrderResource result = await collection.GetAsync(reservationOrderId, expand: expand); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReservationOrderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetReservationOrder() + public async Task GetAll_ReservationOrderList() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetails.json - // this example is just showing the usage of "ReservationOrder_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrders.json + // this example is just showing the usage of "ReservationOrder_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ReservationOrderResource ReservationOrderCollection collection = tenantResource.GetReservationOrders(); - // invoke the operation - Guid reservationOrderId = Guid.Parse("a075419f-44cc-497f-b68a-14ee811d48b9"); - NullableResponse response = await collection.GetIfExistsAsync(reservationOrderId); - ReservationOrderResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ReservationOrderResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ReservationOrderData resourceData = result.Data; + ReservationOrderData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetReservationWithExpandPayments() + public async Task Exists_GetReservationOrder() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetailsWithExpandPlanInformation.json + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetails.json // this example is just showing the usage of "ReservationOrder_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -202,23 +160,16 @@ public async Task Get_GetReservationWithExpandPayments() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ReservationOrderResource ReservationOrderCollection collection = tenantResource.GetReservationOrders(); // invoke the operation Guid reservationOrderId = Guid.Parse("a075419f-44cc-497f-b68a-14ee811d48b9"); - string expand = "schedule"; - ReservationOrderResource result = await collection.GetAsync(reservationOrderId, expand: expand); + bool result = await collection.ExistsAsync(reservationOrderId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReservationOrderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -233,9 +184,7 @@ public async Task Exists_GetReservationWithExpandPayments() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ReservationOrderResource ReservationOrderCollection collection = tenantResource.GetReservationOrders(); @@ -248,6 +197,42 @@ public async Task Exists_GetReservationWithExpandPayments() Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetReservationOrder() + { + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetails.json + // this example is just showing the usage of "ReservationOrder_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this ReservationOrderResource + ReservationOrderCollection collection = tenantResource.GetReservationOrders(); + + // invoke the operation + Guid reservationOrderId = Guid.Parse("a075419f-44cc-497f-b68a-14ee811d48b9"); + NullableResponse response = await collection.GetIfExistsAsync(reservationOrderId); + ReservationOrderResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReservationOrderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetIfExists_GetReservationWithExpandPayments() @@ -260,9 +245,7 @@ public async Task GetIfExists_GetReservationWithExpandPayments() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ReservationOrderResource ReservationOrderCollection collection = tenantResource.GetReservationOrders(); diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationOrderResource.cs b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationOrderResource.cs index b90eda4262e77..975709c0b7697 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationOrderResource.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationOrderResource.cs @@ -19,10 +19,10 @@ public partial class Sample_ReservationOrderResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task SplitReservation_Split() + public async Task Get_GetReservationOrder() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/SplitReservation.json - // this example is just showing the usage of "Reservation_Split" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetails.json + // this example is just showing the usage of "ReservationOrder_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,31 +31,26 @@ public async Task SplitReservation_Split() // this example assumes you already have this ReservationOrderResource created on azure // for more information of creating ReservationOrderResource, please refer to the document of ReservationOrderResource - Guid reservationOrderId = Guid.Parse("276e7ae4-84d0-4da6-ab4b-d6b94f3557da"); + Guid reservationOrderId = Guid.Parse("a075419f-44cc-497f-b68a-14ee811d48b9"); ResourceIdentifier reservationOrderResourceId = ReservationOrderResource.CreateResourceIdentifier(reservationOrderId); ReservationOrderResource reservationOrder = client.GetReservationOrderResource(reservationOrderResourceId); // invoke the operation - SplitContent content = new SplitContent() - { - Quantities = -{ -1,2 -}, - ReservationId = new ResourceIdentifier("/providers/Microsoft.Capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), - }; - ArmOperation> lro = await reservationOrder.SplitReservationAsync(WaitUntil.Completed, content); - IList result = lro.Value; + ReservationOrderResource result = await reservationOrder.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReservationOrderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task MergeReservation_Merge() + public async Task Get_GetReservationWithExpandPayments() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/MergeReservations.json - // this example is just showing the usage of "Reservation_Merge" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetailsWithExpandPlanInformation.json + // this example is just showing the usage of "ReservationOrder_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,60 +59,19 @@ public async Task MergeReservation_Merge() // this example assumes you already have this ReservationOrderResource created on azure // for more information of creating ReservationOrderResource, please refer to the document of ReservationOrderResource - Guid reservationOrderId = Guid.Parse("276e7ae4-84d0-4da6-ab4b-d6b94f3557da"); + Guid reservationOrderId = Guid.Parse("a075419f-44cc-497f-b68a-14ee811d48b9"); ResourceIdentifier reservationOrderResourceId = ReservationOrderResource.CreateResourceIdentifier(reservationOrderId); ReservationOrderResource reservationOrder = client.GetReservationOrderResource(reservationOrderResourceId); // invoke the operation - MergeContent content = new MergeContent() - { - Sources = -{ -"/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77-b07b-5e6d66718e1c/reservations/cea04232-932e-47db-acb5-e29a945ecc73","/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77-b07b-5e6d66718e1c/reservations/5bf54dc7-dacd-4f46-a16b-7b78f4a59799" -}, - }; - ArmOperation> lro = await reservationOrder.MergeReservationAsync(WaitUntil.Completed, content); - IList result = lro.Value; - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CalculateReservationOrder_CalculatePrice() - { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/CalculateReservationOrder.json - // this example is just showing the usage of "ReservationOrder_Calculate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - ReservationPurchaseContent content = new ReservationPurchaseContent() - { - SkuName = "standard_D1", - Location = new AzureLocation("westus"), - ReservedResourceType = ReservedResourceType.VirtualMachines, - BillingScopeId = new ResourceIdentifier("/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83"), - Term = ReservationTerm.P1Y, - BillingPlan = ReservationBillingPlan.Monthly, - Quantity = 1, - DisplayName = "TestReservationOrder", - AppliedScopeType = AppliedScopeType.Shared, - AppliedScopes = -{ -}, - ReservedResourceInstanceFlexibility = InstanceFlexibility.On, - }; - CalculatePriceResult result = await tenantResource.CalculateReservationOrderAsync(content); + string expand = "schedule"; + ReservationOrderResource result = await reservationOrder.GetAsync(expand: expand); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReservationOrderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -139,7 +93,7 @@ public async Task Update_Purchase() ReservationOrderResource reservationOrder = client.GetReservationOrderResource(reservationOrderResourceId); // invoke the operation - ReservationPurchaseContent content = new ReservationPurchaseContent() + ReservationPurchaseContent content = new ReservationPurchaseContent { SkuName = "standard_D1", Location = new AzureLocation("westus"), @@ -150,9 +104,7 @@ public async Task Update_Purchase() Quantity = 1, DisplayName = "TestReservationOrder", AppliedScopeType = AppliedScopeType.Shared, - AppliedScopes = -{ -}, + AppliedScopes = { }, IsRenewEnabled = false, ReservedResourceInstanceFlexibility = InstanceFlexibility.On, }; @@ -168,10 +120,10 @@ public async Task Update_Purchase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetReservationOrder() + public async Task SplitReservation_Split() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetails.json - // this example is just showing the usage of "ReservationOrder_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/SplitReservation.json + // this example is just showing the usage of "Reservation_Split" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,26 +132,28 @@ public async Task Get_GetReservationOrder() // this example assumes you already have this ReservationOrderResource created on azure // for more information of creating ReservationOrderResource, please refer to the document of ReservationOrderResource - Guid reservationOrderId = Guid.Parse("a075419f-44cc-497f-b68a-14ee811d48b9"); + Guid reservationOrderId = Guid.Parse("276e7ae4-84d0-4da6-ab4b-d6b94f3557da"); ResourceIdentifier reservationOrderResourceId = ReservationOrderResource.CreateResourceIdentifier(reservationOrderId); ReservationOrderResource reservationOrder = client.GetReservationOrderResource(reservationOrderResourceId); // invoke the operation - ReservationOrderResource result = await reservationOrder.GetAsync(); + SplitContent content = new SplitContent + { + Quantities = { 1, 2 }, + ReservationId = new ResourceIdentifier("/providers/Microsoft.Capacity/reservationOrders/276e7ae4-84d0-4da6-ab4b-d6b94f3557da/reservations/bcae77cd-3119-4766-919f-b50d36c75c7a"), + }; + ArmOperation> lro = await reservationOrder.SplitReservationAsync(WaitUntil.Completed, content); + IList result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReservationOrderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetReservationWithExpandPayments() + public async Task MergeReservation_Merge() { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservationOrderDetailsWithExpandPlanInformation.json - // this example is just showing the usage of "ReservationOrder_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/MergeReservations.json + // this example is just showing the usage of "Reservation_Merge" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -208,19 +162,19 @@ public async Task Get_GetReservationWithExpandPayments() // this example assumes you already have this ReservationOrderResource created on azure // for more information of creating ReservationOrderResource, please refer to the document of ReservationOrderResource - Guid reservationOrderId = Guid.Parse("a075419f-44cc-497f-b68a-14ee811d48b9"); + Guid reservationOrderId = Guid.Parse("276e7ae4-84d0-4da6-ab4b-d6b94f3557da"); ResourceIdentifier reservationOrderResourceId = ReservationOrderResource.CreateResourceIdentifier(reservationOrderId); ReservationOrderResource reservationOrder = client.GetReservationOrderResource(reservationOrderResourceId); // invoke the operation - string expand = "schedule"; - ReservationOrderResource result = await reservationOrder.GetAsync(expand: expand); + MergeContent content = new MergeContent + { + Sources = { "/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77-b07b-5e6d66718e1c/reservations/cea04232-932e-47db-acb5-e29a945ecc73", "/providers/Microsoft.Capacity/reservationOrders/c0565a8a-4491-4e77-b07b-5e6d66718e1c/reservations/5bf54dc7-dacd-4f46-a16b-7b78f4a59799" }, + }; + ArmOperation> lro = await reservationOrder.MergeReservationAsync(WaitUntil.Completed, content); + IList result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReservationOrderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -242,7 +196,7 @@ public async Task ChangeDirectory_ChangeDirectory() ReservationOrderResource reservationOrder = client.GetReservationOrderResource(reservationOrderResourceId); // invoke the operation - ChangeDirectoryContent content = new ChangeDirectoryContent() + ChangeDirectoryContent content = new ChangeDirectoryContent { DestinationTenantId = Guid.Parse("906655ea-30be-4587-9d12-b50e077b0f32"), }; @@ -270,13 +224,13 @@ public async Task CalculateRefund_CalculateRefund() ReservationOrderResource reservationOrder = client.GetReservationOrderResource(reservationOrderResourceId); // invoke the operation - ReservationCalculateRefundContent content = new ReservationCalculateRefundContent() + ReservationCalculateRefundContent content = new ReservationCalculateRefundContent { Id = "/providers/microsoft.capacity/reservationOrders/50000000-aaaa-bbbb-cccc-100000000004", - Properties = new ReservationCalculateRefundRequestProperties() + Properties = new ReservationCalculateRefundRequestProperties { Scope = "Reservation", - ReservationToReturn = new ReservationToReturn() + ReservationToReturn = new ReservationToReturn { ReservationId = new ResourceIdentifier("/providers/microsoft.capacity/reservationOrders/50000000-aaaa-bbbb-cccc-100000000004/reservations/40000000-aaaa-bbbb-cccc-100000000000"), Quantity = 1, @@ -307,13 +261,13 @@ public async Task Return_ReturnAReservation() ReservationOrderResource reservationOrder = client.GetReservationOrderResource(reservationOrderResourceId); // invoke the operation - ReservationRefundContent content = new ReservationRefundContent() + ReservationRefundContent content = new ReservationRefundContent { - Properties = new ReservationRefundRequestProperties() + Properties = new ReservationRefundRequestProperties { SessionId = Guid.Parse("10000000-aaaa-bbbb-cccc-200000000000"), Scope = "Reservation", - ReservationToReturn = new ReservationToReturn() + ReservationToReturn = new ReservationToReturn { ReservationId = new ResourceIdentifier("/providers/microsoft.capacity/reservationOrders/50000000-aaaa-bbbb-cccc-100000000004/reservations/40000000-aaaa-bbbb-cccc-100000000000"), Quantity = 1, diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationQuotaCollection.cs b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationQuotaCollection.cs index 3860059b4177c..480ea1d860ebf 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationQuotaCollection.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationQuotaCollection.cs @@ -17,112 +17,6 @@ namespace Azure.ResourceManager.Reservations.Samples { public partial class Sample_ReservationQuotaCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_QuotasRequestForCompute() - { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getComputeOneSkuUsages.json - // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this ReservationQuotaResource - string providerId = "Microsoft.Compute"; - AzureLocation location = new AzureLocation("eastus"); - ReservationQuotaCollection collection = subscriptionResource.GetAllReservationQuota(providerId, location); - - // invoke the operation - string resourceName = "standardNDSFamily"; - ReservationQuotaResource result = await collection.GetAsync(resourceName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReservationQuotaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_QuotasRequestForCompute() - { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getComputeOneSkuUsages.json - // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this ReservationQuotaResource - string providerId = "Microsoft.Compute"; - AzureLocation location = new AzureLocation("eastus"); - ReservationQuotaCollection collection = subscriptionResource.GetAllReservationQuota(providerId, location); - - // invoke the operation - string resourceName = "standardNDSFamily"; - bool result = await collection.ExistsAsync(resourceName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QuotasRequestForCompute() - { - // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getComputeOneSkuUsages.json - // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this ReservationQuotaResource - string providerId = "Microsoft.Compute"; - AzureLocation location = new AzureLocation("eastus"); - ReservationQuotaCollection collection = subscriptionResource.GetAllReservationQuota(providerId, location); - - // invoke the operation - string resourceName = "standardNDSFamily"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - ReservationQuotaResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ReservationQuotaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_QuotasRequestPutForCompute() @@ -148,13 +42,13 @@ public async Task CreateOrUpdate_QuotasRequestPutForCompute() // invoke the operation string resourceName = "standardFSv2Family"; - ReservationQuotaData data = new ReservationQuotaData() + ReservationQuotaData data = new ReservationQuotaData { - Properties = new QuotaProperties() + Properties = new QuotaProperties { Limit = 200, Unit = "Count", - ResourceName = new ReservationResourceName() + ResourceName = new ReservationResourceName { Value = "standardFSv2Family", }, @@ -195,13 +89,13 @@ public async Task CreateOrUpdate_QuotasRequestPutForMachineLearningServicesDedic // invoke the operation string resourceName = "StandardDv2Family"; - ReservationQuotaData data = new ReservationQuotaData() + ReservationQuotaData data = new ReservationQuotaData { - Properties = new QuotaProperties() + Properties = new QuotaProperties { Limit = 200, Unit = "Count", - ResourceName = new ReservationResourceName() + ResourceName = new ReservationResourceName { Value = "StandardDv2Family", }, @@ -243,13 +137,13 @@ public async Task CreateOrUpdate_QuotasRequestPutForMachineLearningServicesLowPr // invoke the operation string resourceName = "TotalLowPriorityCores"; - ReservationQuotaData data = new ReservationQuotaData() + ReservationQuotaData data = new ReservationQuotaData { - Properties = new QuotaProperties() + Properties = new QuotaProperties { Limit = 200, Unit = "Count", - ResourceName = new ReservationResourceName() + ResourceName = new ReservationResourceName { Value = "TotalLowPriorityCores", }, @@ -266,6 +160,40 @@ public async Task CreateOrUpdate_QuotasRequestPutForMachineLearningServicesLowPr Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_QuotasRequestForCompute() + { + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getComputeOneSkuUsages.json + // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this ReservationQuotaResource + string providerId = "Microsoft.Compute"; + AzureLocation location = new AzureLocation("eastus"); + ReservationQuotaCollection collection = subscriptionResource.GetAllReservationQuota(providerId, location); + + // invoke the operation + string resourceName = "standardNDSFamily"; + ReservationQuotaResource result = await collection.GetAsync(resourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReservationQuotaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_QuotasListUsagesForCompute() @@ -337,5 +265,77 @@ public async Task GetAll_QuotasListUsagesMachineLearningServices() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_QuotasRequestForCompute() + { + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getComputeOneSkuUsages.json + // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this ReservationQuotaResource + string providerId = "Microsoft.Compute"; + AzureLocation location = new AzureLocation("eastus"); + ReservationQuotaCollection collection = subscriptionResource.GetAllReservationQuota(providerId, location); + + // invoke the operation + string resourceName = "standardNDSFamily"; + bool result = await collection.ExistsAsync(resourceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_QuotasRequestForCompute() + { + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2020-10-25/examples/getComputeOneSkuUsages.json + // this example is just showing the usage of "Quota_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this ReservationQuotaResource + string providerId = "Microsoft.Compute"; + AzureLocation location = new AzureLocation("eastus"); + ReservationQuotaCollection collection = subscriptionResource.GetAllReservationQuota(providerId, location); + + // invoke the operation + string resourceName = "standardNDSFamily"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + ReservationQuotaResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReservationQuotaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationQuotaResource.cs b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationQuotaResource.cs index d9b19c669f913..51159ac578836 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationQuotaResource.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_ReservationQuotaResource.cs @@ -69,13 +69,13 @@ public async Task Update_QuotasRequestPatchForCompute() ReservationQuotaResource reservationQuota = client.GetReservationQuotaResource(reservationQuotaResourceId); // invoke the operation - ReservationQuotaData data = new ReservationQuotaData() + ReservationQuotaData data = new ReservationQuotaData { - Properties = new QuotaProperties() + Properties = new QuotaProperties { Limit = 200, Unit = "Count", - ResourceName = new ReservationResourceName() + ResourceName = new ReservationResourceName { Value = "standardFSv2Family", }, diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index a2f4ed60b1674..a30ce76856bba 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -36,7 +36,7 @@ public async Task GetCatalog_Catalog() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - SubscriptionResourceGetCatalogOptions options = new SubscriptionResourceGetCatalogOptions() { ReservedResourceType = "VirtualMachines", Location = new AzureLocation("eastus") }; + SubscriptionResourceGetCatalogOptions options = new SubscriptionResourceGetCatalogOptions { ReservedResourceType = "VirtualMachines", Location = new AzureLocation("eastus") }; await foreach (ReservationCatalog item in subscriptionResource.GetCatalogAsync(options)) { Console.WriteLine($"Succeeded: {item}"); diff --git a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index 2dcf818dc57ad..65618aca702bf 100644 --- a/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/reservations/Azure.ResourceManager.Reservations/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,12 +10,75 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Reservations.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Reservations.Samples { public partial class Sample_TenantResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetReservationDetails_ReservationListAll() + { + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/GetReservations.json + // this example is just showing the usage of "Reservation_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation and iterate over the result + TenantResourceGetReservationDetailsOptions options = new TenantResourceGetReservationDetailsOptions { Filter = "(properties%2farchived+eq+false)", Orderby = "properties/displayName asc", Skiptoken = 50, Take = 1 }; + await foreach (ReservationDetailResource item in tenantResource.GetReservationDetailsAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ReservationDetailData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CalculateReservationOrder_CalculatePrice() + { + // Generated from example definition: specification/reservations/resource-manager/Microsoft.Capacity/stable/2022-11-01/examples/CalculateReservationOrder.json + // this example is just showing the usage of "ReservationOrder_Calculate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation + ReservationPurchaseContent content = new ReservationPurchaseContent + { + SkuName = "standard_D1", + Location = new AzureLocation("westus"), + ReservedResourceType = ReservedResourceType.VirtualMachines, + BillingScopeId = new ResourceIdentifier("/subscriptions/ed3a1871-612d-abcd-a849-c2542a68be83"), + Term = ReservationTerm.P1Y, + BillingPlan = ReservationBillingPlan.Monthly, + Quantity = 1, + DisplayName = "TestReservationOrder", + AppliedScopeType = AppliedScopeType.Shared, + AppliedScopes = { }, + ReservedResourceInstanceFlexibility = InstanceFlexibility.On, + }; + CalculatePriceResult result = await tenantResource.CalculateReservationOrderAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CalculateReservationExchange_CalculateExchange() @@ -28,18 +91,14 @@ public async Task CalculateReservationExchange_CalculateExchange() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation - CalculateExchangeContent content = new CalculateExchangeContent() + CalculateExchangeContent content = new CalculateExchangeContent { - Properties = new CalculateExchangeContentProperties() + Properties = new CalculateExchangeContentProperties { - ReservationsToPurchase = -{ -new ReservationPurchaseContent() + ReservationsToPurchase = {new ReservationPurchaseContent { SkuName = "Standard_B1ls", Location = new AzureLocation("westus"), @@ -50,42 +109,33 @@ public async Task CalculateReservationExchange_CalculateExchange() Quantity = 1, DisplayName = "testDisplayName", AppliedScopeType = AppliedScopeType.Shared, -AppliedScopes = -{ -}, +AppliedScopes = {}, IsRenewEnabled = false, ReservedResourceInstanceFlexibility = InstanceFlexibility.On, -} -}, - SavingsPlansToPurchase = -{ -new SavingsPlanPurchase() +}}, + SavingsPlansToPurchase = {new SavingsPlanPurchase { SkuName = "Compute_Savings_Plan", DisplayName = "ComputeSavingsPlan", BillingScopeId = new ResourceIdentifier("/subscriptions/10000000-0000-0000-0000-000000000000"), Term = SavingsPlanTerm.P1Y, AppliedScopeType = AppliedScopeType.Single, -AppliedScopeProperties = new AppliedScopeProperties() +AppliedScopeProperties = new AppliedScopeProperties { ResourceGroupId = new ResourceIdentifier("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/testrg"), }, -Commitment = new BenefitsCommitment() +Commitment = new BenefitsCommitment { Grain = BenefitsCommitmentGrain.Hourly, CurrencyCode = "USD", Amount = 15.23, }, -} -}, - ReservationsToExchange = -{ -new ReservationToReturn() +}}, + ReservationsToExchange = {new ReservationToReturn { ReservationId = new ResourceIdentifier("/providers/microsoft.capacity/reservationOrders/1f14354c-dc12-4c8d-8090-6f295a3a34aa/reservations/c8c926bd-fc5d-4e29-9d43-b68340ac23a6"), Quantity = 1, -} -}, +}}, }, }; ArmOperation lro = await tenantResource.CalculateReservationExchangeAsync(WaitUntil.Completed, content); @@ -106,12 +156,10 @@ public async Task Exchange_Exchange() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation - ExchangeContent content = new ExchangeContent() + ExchangeContent content = new ExchangeContent { ExchangeRequestSessionId = Guid.Parse("66e2ac8f-439e-4345-8235-6fef07608081"), }; diff --git a/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_ResourceConnectorApplianceCollection.cs b/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_ResourceConnectorApplianceCollection.cs index 433f2325558a1..e8c7ae52276dd 100644 --- a/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_ResourceConnectorApplianceCollection.cs +++ b/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_ResourceConnectorApplianceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ResourceConnectorApplianceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppliancesByResourceGroup() + public async Task CreateOrUpdate_CreateUpdateAppliance() { - // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/AppliancesListByResourceGroup.json - // this example is just showing the usage of "Appliances_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/AppliancesCreate_Update.json + // this example is just showing the usage of "Appliances_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ListAppliancesByResourceGroup() // get the collection of this ResourceConnectorApplianceResource ResourceConnectorApplianceCollection collection = resourceGroupResource.GetResourceConnectorAppliances(); - // invoke the operation and iterate over the result - await foreach (ResourceConnectorApplianceResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "appliance01"; + ResourceConnectorApplianceData data = new ResourceConnectorApplianceData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceConnectorApplianceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Distro = ResourceConnectorDistro.AksEdge, + InfrastructureConfigProvider = ApplianceProvider.VMware, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ResourceConnectorApplianceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceConnectorApplianceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_GetAppliance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppliance() + public async Task GetAll_ListAppliancesByResourceGroup() { - // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/AppliancesGet.json - // this example is just showing the usage of "Appliances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/AppliancesListByResourceGroup.json + // this example is just showing the usage of "Appliances_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +111,22 @@ public async Task Exists_GetAppliance() // get the collection of this ResourceConnectorApplianceResource ResourceConnectorApplianceCollection collection = resourceGroupResource.GetResourceConnectorAppliances(); - // invoke the operation - string resourceName = "appliance01"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (ResourceConnectorApplianceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceConnectorApplianceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppliance() + public async Task Exists_GetAppliance() { // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/AppliancesGet.json // this example is just showing the usage of "Appliances_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +148,17 @@ public async Task GetIfExists_GetAppliance() // invoke the operation string resourceName = "appliance01"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - ResourceConnectorApplianceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceConnectorApplianceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateUpdateAppliance() + public async Task GetIfExists_GetAppliance() { - // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/AppliancesCreate_Update.json - // this example is just showing the usage of "Appliances_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/AppliancesGet.json + // this example is just showing the usage of "Appliances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,19 +177,21 @@ public async Task CreateOrUpdate_CreateUpdateAppliance() // invoke the operation string resourceName = "appliance01"; - ResourceConnectorApplianceData data = new ResourceConnectorApplianceData(new AzureLocation("West US")) - { - Distro = ResourceConnectorDistro.AksEdge, - InfrastructureConfigProvider = ApplianceProvider.VMware, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - ResourceConnectorApplianceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + ResourceConnectorApplianceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceConnectorApplianceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceConnectorApplianceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_ResourceConnectorApplianceResource.cs b/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_ResourceConnectorApplianceResource.cs index 2ab3d7e9c5e84..f30a0b682495c 100644 --- a/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_ResourceConnectorApplianceResource.cs +++ b/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_ResourceConnectorApplianceResource.cs @@ -10,68 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ResourceConnector.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ResourceConnector.Samples { public partial class Sample_ResourceConnectorApplianceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetResourceConnectorAppliances_ListAppliancesBySubscription() - { - // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/AppliancesListBySubscription.json - // this example is just showing the usage of "Appliances_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "11111111-2222-3333-4444-555555555555"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ResourceConnectorApplianceResource item in subscriptionResource.GetResourceConnectorAppliancesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceConnectorApplianceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetTelemetryConfigAppliance_GetTelemetryConfigAppliance() - { - // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/TelemetryConfig.json - // this example is just showing the usage of "Appliances_GetTelemetryConfig" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "11111111-2222-3333-4444-555555555555"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - ApplianceTelemetryConfigResult result = await subscriptionResource.GetTelemetryConfigApplianceAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAppliance() @@ -149,11 +93,11 @@ public async Task Update_UpdateAppliance() ResourceConnectorApplianceResource resourceConnectorAppliance = client.GetResourceConnectorApplianceResource(resourceConnectorApplianceResourceId); // invoke the operation - ResourceConnectorAppliancePatch patch = new ResourceConnectorAppliancePatch() + ResourceConnectorAppliancePatch patch = new ResourceConnectorAppliancePatch { Tags = { -["key"] = "value", +["key"] = "value" }, }; ResourceConnectorApplianceResource result = await resourceConnectorAppliance.UpdateAsync(patch); diff --git a/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..4ff756b15126d --- /dev/null +++ b/sdk/resourceconnector/Azure.ResourceManager.ResourceConnector/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ResourceConnector.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ResourceConnector.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetResourceConnectorAppliances_ListAppliancesBySubscription() + { + // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/AppliancesListBySubscription.json + // this example is just showing the usage of "Appliances_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ResourceConnectorApplianceResource item in subscriptionResource.GetResourceConnectorAppliancesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceConnectorApplianceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetTelemetryConfigAppliance_GetTelemetryConfigAppliance() + { + // Generated from example definition: specification/resourceconnector/resource-manager/Microsoft.ResourceConnector/stable/2022-10-27/examples/TelemetryConfig.json + // this example is just showing the usage of "Appliances_GetTelemetryConfig" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + ApplianceTelemetryConfigResult result = await subscriptionResource.GetTelemetryConfigApplianceAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/resourcegraph/Azure.ResourceManager.ResourceGraph/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/resourcegraph/Azure.ResourceManager.ResourceGraph/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index b7c0dbe67995b..9b8d9a67842d6 100644 --- a/sdk/resourcegraph/Azure.ResourceManager.ResourceGraph/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/resourcegraph/Azure.ResourceManager.ResourceGraph/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ResourceGraph.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ResourceGraph.Samples @@ -28,17 +29,12 @@ public async Task GetResources_AccessAPropertiesField() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by tostring(properties.storageProfile.osDisk.osType)") { - Subscriptions = -{ -"cfbbd179-59d2-4052-aa06-9270a38aa9d6" -}, + Subscriptions = { "cfbbd179-59d2-4052-aa06-9270a38aa9d6" }, }; ResourceQueryResult result = await tenantResource.GetResourcesAsync(content); @@ -57,17 +53,12 @@ public async Task GetResources_BasicManagementGroupQuery() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | project id, name, type, location, tags | limit 3") { - ManagementGroups = -{ -"e927f598-c1d4-4f72-8541-95d83a6a4ac8","ProductionMG" -}, + ManagementGroups = { "e927f598-c1d4-4f72-8541-95d83a6a4ac8", "ProductionMG" }, }; ResourceQueryResult result = await tenantResource.GetResourcesAsync(content); @@ -86,17 +77,12 @@ public async Task GetResources_BasicQuery() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | project id, name, type, location, tags | limit 3") { - Subscriptions = -{ -"cfbbd179-59d2-4052-aa06-9270a38aa9d6" -}, + Subscriptions = { "cfbbd179-59d2-4052-aa06-9270a38aa9d6" }, }; ResourceQueryResult result = await tenantResource.GetResourcesAsync(content); @@ -115,9 +101,7 @@ public async Task GetResources_BasicTenantQuery() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | project id, name, type, location, tags | limit 3"); @@ -138,17 +122,12 @@ public async Task GetResources_ComplexQuery() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | project id, name, type, location | where type =~ 'Microsoft.Compute/virtualMachines' | summarize count() by location | top 3 by count_") { - Subscriptions = -{ -"cfbbd179-59d2-4052-aa06-9270a38aa9d6" -}, + Subscriptions = { "cfbbd179-59d2-4052-aa06-9270a38aa9d6" }, }; ResourceQueryResult result = await tenantResource.GetResourcesAsync(content); @@ -167,17 +146,12 @@ public async Task GetResources_FilterResources() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | project id, name, type, location | where type =~ 'Microsoft.Compute/virtualMachines' | limit 3") { - Subscriptions = -{ -"cfbbd179-59d2-4052-aa06-9270a38aa9d6" -}, + Subscriptions = { "cfbbd179-59d2-4052-aa06-9270a38aa9d6" }, }; ResourceQueryResult result = await tenantResource.GetResourcesAsync(content); @@ -196,18 +170,13 @@ public async Task GetResources_FirstPageQuery() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | where name contains 'test' | project id, name, type, location") { - Subscriptions = -{ -"cfbbd179-59d2-4052-aa06-9270a38aa9d6" -}, - Options = new ResourceQueryRequestOptions() + Subscriptions = { "cfbbd179-59d2-4052-aa06-9270a38aa9d6" }, + Options = new ResourceQueryRequestOptions { Top = 3, Skip = 0, @@ -230,18 +199,13 @@ public async Task GetResources_NextPageQuery() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | where name contains 'test' | project id, name, type, location") { - Subscriptions = -{ -"cfbbd179-59d2-4052-aa06-9270a38aa9d6" -}, - Options = new ResourceQueryRequestOptions() + Subscriptions = { "cfbbd179-59d2-4052-aa06-9270a38aa9d6" }, + Options = new ResourceQueryRequestOptions { SkipToken = "eyAibm8iOiAibHVjayIsICJidXQiOiAibmljZSIsICJ0cnkiOiAiISIgfQ==", }, @@ -263,57 +227,49 @@ public async Task GetResources_QueryWithAFacetRequest() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | where type =~ 'Microsoft.Compute/virtualMachines' | project id, name, location, resourceGroup, properties.storageProfile.osDisk.osType | limit 5") { - Subscriptions = + Subscriptions = { "cfbbd179-59d2-4052-aa06-9270a38aa9d6" }, + Facets = {new FacetRequest("location") { -"cfbbd179-59d2-4052-aa06-9270a38aa9d6" -}, - Facets = -{ -new FacetRequest("location") -{ -Options = new FacetRequestOptions() +Options = new FacetRequestOptions { SortOrder = FacetSortOrder.Desc, Top = 3, }, -},new FacetRequest("properties.storageProfile.osDisk.osType") +}, new FacetRequest("properties.storageProfile.osDisk.osType") { -Options = new FacetRequestOptions() +Options = new FacetRequestOptions { SortOrder = FacetSortOrder.Desc, Top = 3, }, -},new FacetRequest("nonExistingColumn") +}, new FacetRequest("nonExistingColumn") { -Options = new FacetRequestOptions() +Options = new FacetRequestOptions { SortOrder = FacetSortOrder.Desc, Top = 3, }, -},new FacetRequest("resourceGroup") +}, new FacetRequest("resourceGroup") { -Options = new FacetRequestOptions() +Options = new FacetRequestOptions { SortBy = "tolower(resourceGroup)", SortOrder = FacetSortOrder.Asc, Top = 3, }, -},new FacetRequest("resourceGroup") +}, new FacetRequest("resourceGroup") { -Options = new FacetRequestOptions() +Options = new FacetRequestOptions { Filter = "resourceGroup contains 'test'", Top = 3, }, -} -}, +}}, }; ResourceQueryResult result = await tenantResource.GetResourcesAsync(content); @@ -332,18 +288,13 @@ public async Task GetResources_RandomPageQuery() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | where name contains 'test' | project id, name, type, location") { - Subscriptions = -{ -"cfbbd179-59d2-4052-aa06-9270a38aa9d6" -}, - Options = new ResourceQueryRequestOptions() + Subscriptions = { "cfbbd179-59d2-4052-aa06-9270a38aa9d6" }, + Options = new ResourceQueryRequestOptions { Top = 2, Skip = 10, @@ -366,17 +317,12 @@ public async Task GetResources_SummarizeResourcesByLocation() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ResourceQueryContent content = new ResourceQueryContent("Resources | project id, name, type, location | summarize by location") { - Subscriptions = -{ -"cfbbd179-59d2-4052-aa06-9270a38aa9d6" -}, + Subscriptions = { "cfbbd179-59d2-4052-aa06-9270a38aa9d6" }, }; ResourceQueryResult result = await tenantResource.GetResourcesAsync(content); @@ -395,22 +341,17 @@ public async Task GetResourceHistory_ResourceHistoryManagementGroupScopeQuery() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation - ResourcesHistoryContent content = new ResourcesHistoryContent() + ResourcesHistoryContent content = new ResourcesHistoryContent { Query = "where name =~ 'cpu-utilization' | project id, name, properties", - Options = new ResourcesHistoryRequestOptions() + Options = new ResourcesHistoryRequestOptions { Interval = new DateTimeInterval(DateTimeOffset.Parse("2020-11-12T01:00:00.0000000Z"), DateTimeOffset.Parse("2020-11-12T01:25:00.0000000Z")), }, - ManagementGroups = -{ -"e927f598-c1d4-4f72-8541-95d83a6a4ac8","ProductionMG" -}, + ManagementGroups = { "e927f598-c1d4-4f72-8541-95d83a6a4ac8", "ProductionMG" }, }; BinaryData result = await tenantResource.GetResourceHistoryAsync(content); @@ -429,19 +370,14 @@ public async Task GetResourceHistory_ResourceHistoryQuery() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation - ResourcesHistoryContent content = new ResourcesHistoryContent() + ResourcesHistoryContent content = new ResourcesHistoryContent { - Subscriptions = -{ -"a7f33fdb-e646-4f15-89aa-3a360210861e" -}, + Subscriptions = { "a7f33fdb-e646-4f15-89aa-3a360210861e" }, Query = "where name =~ 'cpu-utilization' | project id, name, properties", - Options = new ResourcesHistoryRequestOptions() + Options = new ResourcesHistoryRequestOptions { Interval = new DateTimeInterval(DateTimeOffset.Parse("2020-11-12T01:00:00.0000000Z"), DateTimeOffset.Parse("2020-11-12T01:25:00.0000000Z")), }, diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ArmClientExtensions.cs b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ArmClientExtensions.cs new file mode 100644 index 0000000000000..064615ed4c0f6 --- /dev/null +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ArmClientExtensions.cs @@ -0,0 +1,148 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ResourceHealth.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.ResourceHealth.Samples +{ + public partial class Sample_ArmClientExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAvailabilityStatus_GetCurrentHealthByResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/AvailabilityStatus_GetByResource.json + // this example is just showing the usage of "AvailabilityStatuses_GetByResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation + ResourceIdentifier scope = null; + string expand = "recommendedactions"; + ResourceHealthAvailabilityStatus result = await client.GetAvailabilityStatusAsync(scope, expand: expand); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAvailabilityStatuses_GetHealthHistoryByResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/AvailabilityStatuses_List.json + // this example is just showing the usage of "AvailabilityStatuses_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation and iterate over the result + ResourceIdentifier scope = null; + await foreach (ResourceHealthAvailabilityStatus item in client.GetAvailabilityStatusesAsync(scope)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHealthEventsOfSingleResource_ListEventsBySingleResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Events_ListBySingleResource.json + // this example is just showing the usage of "Events_ListBySingleResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation and iterate over the result + ResourceIdentifier scope = null; + await foreach (ResourceHealthEventData item in client.GetHealthEventsOfSingleResourceAsync(scope)) + { + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {item.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAvailabilityStatusOfChildResource_GetChildCurrentHealthByResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ChildAvailabilityStatus_GetByResource.json + // this example is just showing the usage of "ChildAvailabilityStatuses_GetByResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation + ResourceIdentifier scope = null; + string expand = "recommendedactions"; + ResourceHealthAvailabilityStatus result = await client.GetAvailabilityStatusOfChildResourceAsync(scope, expand: expand); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHistoricalAvailabilityStatusesOfChildResource_GetChildHealthHistoryByResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ChildAvailabilityStatuses_List.json + // this example is just showing the usage of "ChildAvailabilityStatuses_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation and iterate over the result + ResourceIdentifier scope = null; + await foreach (ResourceHealthAvailabilityStatus item in client.GetHistoricalAvailabilityStatusesOfChildResourceAsync(scope)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAvailabilityStatusOfChildResources_GetCurrentChildHealthByResource() + { + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ChildResources_List.json + // this example is just showing the usage of "ChildResources_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation and iterate over the result + ResourceIdentifier scope = null; + await foreach (ResourceHealthAvailabilityStatus item in client.GetAvailabilityStatusOfChildResourcesAsync(scope)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventCollection.cs b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventCollection.cs index 55035c7a2c586..1c98d17eb9850 100644 --- a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventCollection.cs +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ResourceHealthEventCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEventsBySubscriptionId() + public async Task Get_SecurityAdvisoriesEventBySubscriptionIdAndTrackingId() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Events_ListBySubscriptionId.json - // this example is just showing the usage of "Events_ListBySubscriptionId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Event_GetBySubscriptionIdAndTrackingId.json + // this example is just showing the usage of "Event_GetBySubscriptionIdAndTrackingId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,27 +37,25 @@ public async Task GetAll_ListEventsBySubscriptionId() // get the collection of this ResourceHealthEventResource ResourceHealthEventCollection collection = subscriptionResource.GetResourceHealthEvents(); - // invoke the operation and iterate over the result - string filter = "service eq 'Virtual Machines' or region eq 'West US'"; - string queryStartTime = "7/24/2020"; - await foreach (ResourceHealthEventResource item in collection.GetAllAsync(filter: filter, queryStartTime: queryStartTime)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthEventData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string eventTrackingId = "eventTrackingId"; + string filter = "properties/status eq 'Active'"; + string queryStartTime = "7/10/2022"; + ResourceHealthEventResource result = await collection.GetAsync(eventTrackingId, filter: filter, queryStartTime: queryStartTime); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthEventData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SecurityAdvisoriesEventBySubscriptionIdAndTrackingId() + public async Task GetAll_ListEventsBySubscriptionId() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Event_GetBySubscriptionIdAndTrackingId.json - // this example is just showing the usage of "Event_GetBySubscriptionIdAndTrackingId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Events_ListBySubscriptionId.json + // this example is just showing the usage of "Events_ListBySubscriptionId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,17 +71,19 @@ public async Task Get_SecurityAdvisoriesEventBySubscriptionIdAndTrackingId() // get the collection of this ResourceHealthEventResource ResourceHealthEventCollection collection = subscriptionResource.GetResourceHealthEvents(); - // invoke the operation - string eventTrackingId = "eventTrackingId"; - string filter = "properties/status eq 'Active'"; - string queryStartTime = "7/10/2022"; - ResourceHealthEventResource result = await collection.GetAsync(eventTrackingId, filter: filter, queryStartTime: queryStartTime); + // invoke the operation and iterate over the result + string filter = "service eq 'Virtual Machines' or region eq 'West US'"; + string queryStartTime = "7/24/2020"; + await foreach (ResourceHealthEventResource item in collection.GetAllAsync(filter: filter, queryStartTime: queryStartTime)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthEventData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthEventData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventImpactedResourceCollection.cs b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventImpactedResourceCollection.cs index f2a82debe9c94..b373f192143b1 100644 --- a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventImpactedResourceCollection.cs +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventImpactedResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ResourceHealthEventImpactedResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListImpactedResourcesBySubscriptionId() + public async Task Get_ImpactedResourcesGet() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ImpactedResources_ListBySubscriptionId_ListByEventId.json - // this example is just showing the usage of "ImpactedResources_ListBySubscriptionIdAndEventId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ImpactedResources_Get.json + // this example is just showing the usage of "ImpactedResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,26 +37,23 @@ public async Task GetAll_ListImpactedResourcesBySubscriptionId() // get the collection of this ResourceHealthEventImpactedResource ResourceHealthEventImpactedResourceCollection collection = resourceHealthEvent.GetResourceHealthEventImpactedResources(); - // invoke the operation and iterate over the result - string filter = "targetRegion eq 'westus'"; - await foreach (ResourceHealthEventImpactedResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthEventImpactedResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string impactedResourceName = "abc-123-ghj-456"; + ResourceHealthEventImpactedResource result = await collection.GetAsync(impactedResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthEventImpactedResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ImpactedResourcesGet() + public async Task GetAll_ListImpactedResourcesBySubscriptionId() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ImpactedResources_Get.json - // this example is just showing the usage of "ImpactedResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ImpactedResources_ListBySubscriptionId_ListByEventId.json + // this example is just showing the usage of "ImpactedResources_ListBySubscriptionIdAndEventId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +70,18 @@ public async Task Get_ImpactedResourcesGet() // get the collection of this ResourceHealthEventImpactedResource ResourceHealthEventImpactedResourceCollection collection = resourceHealthEvent.GetResourceHealthEventImpactedResources(); - // invoke the operation - string impactedResourceName = "abc-123-ghj-456"; - ResourceHealthEventImpactedResource result = await collection.GetAsync(impactedResourceName); + // invoke the operation and iterate over the result + string filter = "targetRegion eq 'westus'"; + await foreach (ResourceHealthEventImpactedResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthEventImpactedResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthEventImpactedResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventResource.cs b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventResource.cs index 3fe84ad8f375f..26a2688383816 100644 --- a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventResource.cs +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthEventResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ResourceHealthEventResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSecurityAdvisoryImpactedResourcesBySubscriptionIdAndEventId_ListSecurityAdvisoryImpactedResourcesBySubscriptionId() + public async Task Get_SecurityAdvisoriesEventBySubscriptionIdAndTrackingId() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/SecurityAdvisoryImpactedResources_ListBySubscriptionId_ListByEventId.json - // this example is just showing the usage of "SecurityAdvisoryImpactedResources_ListBySubscriptionIdAndEventId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Event_GetBySubscriptionIdAndTrackingId.json + // this example is just showing the usage of "Event_GetBySubscriptionIdAndTrackingId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,26 +30,28 @@ public async Task GetSecurityAdvisoryImpactedResourcesBySubscriptionIdAndEventId // this example assumes you already have this ResourceHealthEventResource created on azure // for more information of creating ResourceHealthEventResource, please refer to the document of ResourceHealthEventResource string subscriptionId = "subscriptionId"; - string eventTrackingId = "BC_1-FXZ"; + string eventTrackingId = "eventTrackingId"; ResourceIdentifier resourceHealthEventResourceId = ResourceHealthEventResource.CreateResourceIdentifier(subscriptionId, eventTrackingId); ResourceHealthEventResource resourceHealthEvent = client.GetResourceHealthEventResource(resourceHealthEventResourceId); - // invoke the operation and iterate over the result - await foreach (ResourceHealthEventImpactedResourceData item in resourceHealthEvent.GetSecurityAdvisoryImpactedResourcesBySubscriptionIdAndEventIdAsync()) - { - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {item.Id}"); - } + // invoke the operation + string filter = "properties/status eq 'Active'"; + string queryStartTime = "7/10/2022"; + ResourceHealthEventResource result = await resourceHealthEvent.GetAsync(filter: filter, queryStartTime: queryStartTime); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthEventData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SecurityAdvisoriesEventBySubscriptionIdAndTrackingId() + public async Task GetSecurityAdvisoryImpactedResourcesBySubscriptionIdAndEventId_ListSecurityAdvisoryImpactedResourcesBySubscriptionId() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Event_GetBySubscriptionIdAndTrackingId.json - // this example is just showing the usage of "Event_GetBySubscriptionIdAndTrackingId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/SecurityAdvisoryImpactedResources_ListBySubscriptionId_ListByEventId.json + // this example is just showing the usage of "SecurityAdvisoryImpactedResources_ListBySubscriptionIdAndEventId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,20 +61,18 @@ public async Task Get_SecurityAdvisoriesEventBySubscriptionIdAndTrackingId() // this example assumes you already have this ResourceHealthEventResource created on azure // for more information of creating ResourceHealthEventResource, please refer to the document of ResourceHealthEventResource string subscriptionId = "subscriptionId"; - string eventTrackingId = "eventTrackingId"; + string eventTrackingId = "BC_1-FXZ"; ResourceIdentifier resourceHealthEventResourceId = ResourceHealthEventResource.CreateResourceIdentifier(subscriptionId, eventTrackingId); ResourceHealthEventResource resourceHealthEvent = client.GetResourceHealthEventResource(resourceHealthEventResourceId); - // invoke the operation - string filter = "properties/status eq 'Active'"; - string queryStartTime = "7/10/2022"; - ResourceHealthEventResource result = await resourceHealthEvent.GetAsync(filter: filter, queryStartTime: queryStartTime); + // invoke the operation and iterate over the result + await foreach (ResourceHealthEventImpactedResourceData item in resourceHealthEvent.GetSecurityAdvisoryImpactedResourcesBySubscriptionIdAndEventIdAsync()) + { + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {item.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthEventData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthMetadataEntityCollection.cs b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthMetadataEntityCollection.cs index 4487a48ca98f4..62c28c0695cd6 100644 --- a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthMetadataEntityCollection.cs +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ResourceHealthMetadataEntityCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ResourceHealth.Samples @@ -17,64 +18,60 @@ public partial class Sample_ResourceHealthMetadataEntityCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetMetadata() + public async Task Get_GetMetadata() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Metadata_List.json - // this example is just showing the usage of "Metadata_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Metadata_GetEntity.json + // this example is just showing the usage of "Metadata_GetEntity" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ResourceHealthMetadataEntityResource ResourceHealthMetadataEntityCollection collection = tenantResource.GetResourceHealthMetadataEntities(); - // invoke the operation and iterate over the result - await foreach (ResourceHealthMetadataEntityResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthMetadataEntityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "status"; + ResourceHealthMetadataEntityResource result = await collection.GetAsync(name); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthMetadataEntityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMetadata() + public async Task GetAll_GetMetadata() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Metadata_GetEntity.json - // this example is just showing the usage of "Metadata_GetEntity" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Metadata_List.json + // this example is just showing the usage of "Metadata_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ResourceHealthMetadataEntityResource ResourceHealthMetadataEntityCollection collection = tenantResource.GetResourceHealthMetadataEntities(); - // invoke the operation - string name = "status"; - ResourceHealthMetadataEntityResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (ResourceHealthMetadataEntityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthMetadataEntityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthMetadataEntityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -89,9 +86,7 @@ public async Task Exists_GetMetadata() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ResourceHealthMetadataEntityResource ResourceHealthMetadataEntityCollection collection = tenantResource.GetResourceHealthMetadataEntities(); @@ -115,9 +110,7 @@ public async Task GetIfExists_GetMetadata() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ResourceHealthMetadataEntityResource ResourceHealthMetadataEntityCollection collection = tenantResource.GetResourceHealthMetadataEntities(); diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ServiceEmergingIssueCollection.cs b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ServiceEmergingIssueCollection.cs index 8bd79b63cc5da..6a18faa5b2082 100644 --- a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ServiceEmergingIssueCollection.cs +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_ServiceEmergingIssueCollection.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ResourceHealth.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ResourceHealth.Samples @@ -18,64 +19,60 @@ public partial class Sample_ServiceEmergingIssueCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetEmergingIssues() + public async Task Get_GetEmergingIssues() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/EmergingIssues_List.json - // this example is just showing the usage of "EmergingIssues_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/EmergingIssues_Get.json + // this example is just showing the usage of "EmergingIssues_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ServiceEmergingIssueResource ServiceEmergingIssueCollection collection = tenantResource.GetServiceEmergingIssues(); - // invoke the operation and iterate over the result - await foreach (ServiceEmergingIssueResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceEmergingIssueData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + EmergingIssueNameContent issueName = EmergingIssueNameContent.Default; + ServiceEmergingIssueResource result = await collection.GetAsync(issueName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceEmergingIssueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetEmergingIssues() + public async Task GetAll_GetEmergingIssues() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/EmergingIssues_Get.json - // this example is just showing the usage of "EmergingIssues_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/EmergingIssues_List.json + // this example is just showing the usage of "EmergingIssues_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ServiceEmergingIssueResource ServiceEmergingIssueCollection collection = tenantResource.GetServiceEmergingIssues(); - // invoke the operation - EmergingIssueNameContent issueName = EmergingIssueNameContent.Default; - ServiceEmergingIssueResource result = await collection.GetAsync(issueName); + // invoke the operation and iterate over the result + await foreach (ServiceEmergingIssueResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceEmergingIssueData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceEmergingIssueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -90,9 +87,7 @@ public async Task Exists_GetEmergingIssues() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ServiceEmergingIssueResource ServiceEmergingIssueCollection collection = tenantResource.GetServiceEmergingIssues(); @@ -116,9 +111,7 @@ public async Task GetIfExists_GetEmergingIssues() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ServiceEmergingIssueResource ServiceEmergingIssueCollection collection = tenantResource.GetServiceEmergingIssues(); diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventCollection.cs b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventCollection.cs index 3a69b32994a39..7a497a6233fa2 100644 --- a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventCollection.cs +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ResourceHealth.Samples @@ -17,68 +18,64 @@ public partial class Sample_TenantResourceHealthEventCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEventsByTenantId() + public async Task Get_EventByTenantIdAndTrackingId() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Events_ListByTenantId.json - // this example is just showing the usage of "Events_ListByTenantId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Event_GetByTenantIdAndTrackingId.json + // this example is just showing the usage of "Event_GetByTenantIdAndTrackingId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantResourceHealthEventResource TenantResourceHealthEventCollection collection = tenantResource.GetTenantResourceHealthEvents(); - // invoke the operation and iterate over the result - string filter = "service eq 'Virtual Machines' or region eq 'West US'"; - string queryStartTime = "7/24/2020"; - await foreach (TenantResourceHealthEventResource item in collection.GetAllAsync(filter: filter, queryStartTime: queryStartTime)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthEventData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string eventTrackingId = "eventTrackingId"; + string filter = "properties/status eq 'Active'"; + string queryStartTime = "7/10/2022"; + TenantResourceHealthEventResource result = await collection.GetAsync(eventTrackingId, filter: filter, queryStartTime: queryStartTime); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthEventData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventByTenantIdAndTrackingId() + public async Task GetAll_ListEventsByTenantId() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Event_GetByTenantIdAndTrackingId.json - // this example is just showing the usage of "Event_GetByTenantIdAndTrackingId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Events_ListByTenantId.json + // this example is just showing the usage of "Events_ListByTenantId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantResourceHealthEventResource TenantResourceHealthEventCollection collection = tenantResource.GetTenantResourceHealthEvents(); - // invoke the operation - string eventTrackingId = "eventTrackingId"; - string filter = "properties/status eq 'Active'"; - string queryStartTime = "7/10/2022"; - TenantResourceHealthEventResource result = await collection.GetAsync(eventTrackingId, filter: filter, queryStartTime: queryStartTime); + // invoke the operation and iterate over the result + string filter = "service eq 'Virtual Machines' or region eq 'West US'"; + string queryStartTime = "7/24/2020"; + await foreach (TenantResourceHealthEventResource item in collection.GetAllAsync(filter: filter, queryStartTime: queryStartTime)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthEventData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthEventData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -93,9 +90,7 @@ public async Task Exists_EventByTenantIdAndTrackingId() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantResourceHealthEventResource TenantResourceHealthEventCollection collection = tenantResource.GetTenantResourceHealthEvents(); @@ -121,9 +116,7 @@ public async Task GetIfExists_EventByTenantIdAndTrackingId() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantResourceHealthEventResource TenantResourceHealthEventCollection collection = tenantResource.GetTenantResourceHealthEvents(); diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventImpactedResourceCollection.cs b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventImpactedResourceCollection.cs index f2fa5621ef46f..78b9e1d836eef 100644 --- a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventImpactedResourceCollection.cs +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventImpactedResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_TenantResourceHealthEventImpactedResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEventsByTenantId() + public async Task Get_ImpactedResourcesGet() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ImpactedResources_ListByTenantId_ListByEventId.json - // this example is just showing the usage of "ImpactedResources_ListByTenantIdAndEventId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ImpactedResources_GetByTenantId.json + // this example is just showing the usage of "ImpactedResources_GetByTenantId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,26 +36,23 @@ public async Task GetAll_ListEventsByTenantId() // get the collection of this TenantResourceHealthEventImpactedResource TenantResourceHealthEventImpactedResourceCollection collection = tenantResourceHealthEvent.GetTenantResourceHealthEventImpactedResources(); - // invoke the operation and iterate over the result - string filter = "targetRegion eq 'westus'"; - await foreach (TenantResourceHealthEventImpactedResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthEventImpactedResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string impactedResourceName = "abc-123-ghj-456"; + TenantResourceHealthEventImpactedResource result = await collection.GetAsync(impactedResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthEventImpactedResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ImpactedResourcesGet() + public async Task GetAll_ListEventsByTenantId() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ImpactedResources_GetByTenantId.json - // this example is just showing the usage of "ImpactedResources_GetByTenantId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/ImpactedResources_ListByTenantId_ListByEventId.json + // this example is just showing the usage of "ImpactedResources_ListByTenantIdAndEventId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +68,18 @@ public async Task Get_ImpactedResourcesGet() // get the collection of this TenantResourceHealthEventImpactedResource TenantResourceHealthEventImpactedResourceCollection collection = tenantResourceHealthEvent.GetTenantResourceHealthEventImpactedResources(); - // invoke the operation - string impactedResourceName = "abc-123-ghj-456"; - TenantResourceHealthEventImpactedResource result = await collection.GetAsync(impactedResourceName); + // invoke the operation and iterate over the result + string filter = "targetRegion eq 'westus'"; + await foreach (TenantResourceHealthEventImpactedResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthEventImpactedResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthEventImpactedResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventResource.cs b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventResource.cs index 00108368b107a..d9c97092bc80a 100644 --- a/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventResource.cs +++ b/sdk/resourcehealth/Azure.ResourceManager.ResourceHealth/samples/Generated/Samples/Sample_TenantResourceHealthEventResource.cs @@ -17,10 +17,10 @@ public partial class Sample_TenantResourceHealthEventResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSecurityAdvisoryImpactedResourcesByTenantIdAndEventId_ListSecurityAdvisoryImpactedResourcesByTenantId() + public async Task Get_EventByTenantIdAndTrackingId() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/SecurityAdvisoryImpactedResources_ListByTenantId_ListByEventId.json - // this example is just showing the usage of "SecurityAdvisoryImpactedResources_ListByTenantIdAndEventId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Event_GetByTenantIdAndTrackingId.json + // this example is just showing the usage of "Event_GetByTenantIdAndTrackingId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -29,26 +29,28 @@ public async Task GetSecurityAdvisoryImpactedResourcesByTenantIdAndEventId_ListS // this example assumes you already have this TenantResourceHealthEventResource created on azure // for more information of creating TenantResourceHealthEventResource, please refer to the document of TenantResourceHealthEventResource - string eventTrackingId = "BC_1-FXZ"; + string eventTrackingId = "eventTrackingId"; ResourceIdentifier tenantResourceHealthEventResourceId = TenantResourceHealthEventResource.CreateResourceIdentifier(eventTrackingId); TenantResourceHealthEventResource tenantResourceHealthEvent = client.GetTenantResourceHealthEventResource(tenantResourceHealthEventResourceId); - // invoke the operation and iterate over the result - await foreach (ResourceHealthEventImpactedResourceData item in tenantResourceHealthEvent.GetSecurityAdvisoryImpactedResourcesByTenantIdAndEventIdAsync()) - { - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {item.Id}"); - } + // invoke the operation + string filter = "properties/status eq 'Active'"; + string queryStartTime = "7/10/2022"; + TenantResourceHealthEventResource result = await tenantResourceHealthEvent.GetAsync(filter: filter, queryStartTime: queryStartTime); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceHealthEventData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EventByTenantIdAndTrackingId() + public async Task GetSecurityAdvisoryImpactedResourcesByTenantIdAndEventId_ListSecurityAdvisoryImpactedResourcesByTenantId() { - // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/Event_GetByTenantIdAndTrackingId.json - // this example is just showing the usage of "Event_GetByTenantIdAndTrackingId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcehealth/resource-manager/Microsoft.ResourceHealth/preview/2023-10-01-preview/examples/SecurityAdvisoryImpactedResources_ListByTenantId_ListByEventId.json + // this example is just showing the usage of "SecurityAdvisoryImpactedResources_ListByTenantIdAndEventId" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -57,20 +59,18 @@ public async Task Get_EventByTenantIdAndTrackingId() // this example assumes you already have this TenantResourceHealthEventResource created on azure // for more information of creating TenantResourceHealthEventResource, please refer to the document of TenantResourceHealthEventResource - string eventTrackingId = "eventTrackingId"; + string eventTrackingId = "BC_1-FXZ"; ResourceIdentifier tenantResourceHealthEventResourceId = TenantResourceHealthEventResource.CreateResourceIdentifier(eventTrackingId); TenantResourceHealthEventResource tenantResourceHealthEvent = client.GetTenantResourceHealthEventResource(tenantResourceHealthEventResourceId); - // invoke the operation - string filter = "properties/status eq 'Active'"; - string queryStartTime = "7/10/2022"; - TenantResourceHealthEventResource result = await tenantResourceHealthEvent.GetAsync(filter: filter, queryStartTime: queryStartTime); + // invoke the operation and iterate over the result + await foreach (ResourceHealthEventImpactedResourceData item in tenantResourceHealthEvent.GetSecurityAdvisoryImpactedResourcesByTenantIdAndEventIdAsync()) + { + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {item.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceHealthEventData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_DataPolicyManifestCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_DataPolicyManifestCollection.cs index 738219b3d809a..115c1c0c4bcee 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_DataPolicyManifestCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_DataPolicyManifestCollection.cs @@ -27,9 +27,7 @@ public async Task Get_RetrieveADataPolicyManifestByPolicyMode() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DataPolicyManifestResource DataPolicyManifestCollection collection = tenant.GetDataPolicyManifests(); @@ -47,131 +45,123 @@ public async Task Get_RetrieveADataPolicyManifestByPolicyMode() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveADataPolicyManifestByPolicyMode() + public async Task GetAll_ListDataPolicyManifests() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json - // this example is just showing the usage of "DataPolicyManifests_GetByPolicyMode" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json + // this example is just showing the usage of "DataPolicyManifests_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DataPolicyManifestResource DataPolicyManifestCollection collection = tenant.GetDataPolicyManifests(); - // invoke the operation - string policyMode = "Microsoft.KeyVault.Data"; - bool result = await collection.ExistsAsync(policyMode); + // invoke the operation and iterate over the result + await foreach (DataPolicyManifestResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataPolicyManifestData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveADataPolicyManifestByPolicyMode() + public async Task GetAll_ListDataPolicyManifestsWithNamespaceFilter() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json - // this example is just showing the usage of "DataPolicyManifests_GetByPolicyMode" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifestsNamespaceFilter.json + // this example is just showing the usage of "DataPolicyManifests_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DataPolicyManifestResource DataPolicyManifestCollection collection = tenant.GetDataPolicyManifests(); - // invoke the operation - string policyMode = "Microsoft.KeyVault.Data"; - NullableResponse response = await collection.GetIfExistsAsync(policyMode); - DataPolicyManifestResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string filter = "namespace eq 'Microsoft.KeyVault'"; + await foreach (DataPolicyManifestResource item in collection.GetAllAsync(filter: filter)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataPolicyManifestData resourceData = result.Data; + DataPolicyManifestData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDataPolicyManifests() + public async Task Exists_RetrieveADataPolicyManifestByPolicyMode() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifests.json - // this example is just showing the usage of "DataPolicyManifests_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json + // this example is just showing the usage of "DataPolicyManifests_GetByPolicyMode" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DataPolicyManifestResource DataPolicyManifestCollection collection = tenant.GetDataPolicyManifests(); - // invoke the operation and iterate over the result - await foreach (DataPolicyManifestResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataPolicyManifestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string policyMode = "Microsoft.KeyVault.Data"; + bool result = await collection.ExistsAsync(policyMode); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDataPolicyManifestsWithNamespaceFilter() + public async Task GetIfExists_RetrieveADataPolicyManifestByPolicyMode() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/listDataPolicyManifestsNamespaceFilter.json - // this example is just showing the usage of "DataPolicyManifests_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-09-01/examples/getDataPolicyManifest.json + // this example is just showing the usage of "DataPolicyManifests_GetByPolicyMode" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DataPolicyManifestResource DataPolicyManifestCollection collection = tenant.GetDataPolicyManifests(); - // invoke the operation and iterate over the result - string filter = "namespace eq 'Microsoft.KeyVault'"; - await foreach (DataPolicyManifestResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string policyMode = "Microsoft.KeyVault.Data"; + NullableResponse response = await collection.GetIfExistsAsync(policyMode); + DataPolicyManifestResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataPolicyManifestData resourceData = item.Data; + DataPolicyManifestData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_FeatureCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_FeatureCollection.cs index b85fd512b9b45..48f1619fa9071 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_FeatureCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_FeatureCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_FeatureCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListProviderFeatures() + public async Task Get_GetFeature() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listProviderFeatures.json - // this example is just showing the usage of "Features_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json + // this example is just showing the usage of "Features_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_ListProviderFeatures() // get the collection of this FeatureResource FeatureCollection collection = resourceProvider.GetFeatures(); - // invoke the operation and iterate over the result - await foreach (FeatureResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FeatureData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string featureName = "feature"; + FeatureResource result = await collection.GetAsync(featureName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FeatureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFeature() + public async Task GetAll_ListProviderFeatures() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/getFeature.json - // this example is just showing the usage of "Features_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Features/stable/2021-07-01/examples/listProviderFeatures.json + // this example is just showing the usage of "Features_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +70,17 @@ public async Task Get_GetFeature() // get the collection of this FeatureResource FeatureCollection collection = resourceProvider.GetFeatures(); - // invoke the operation - string featureName = "feature"; - FeatureResource result = await collection.GetAsync(featureName); + // invoke the operation and iterate over the result + await foreach (FeatureResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FeatureData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FeatureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs index 06164d5d029be..d0d1f7e10da1b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupCollection.cs @@ -19,35 +19,43 @@ public partial class Sample_ManagementGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagementGroups() + public async Task CreateOrUpdate_PutManagementGroup() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/ListManagementGroups.json - // this example is just showing the usage of "ManagementGroups_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PutManagementGroup.json + // this example is just showing the usage of "ManagementGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - // invoke the operation and iterate over the result - string cacheControl = "no-cache"; - await foreach (ManagementGroupResource item in collection.GetAllAsync(cacheControl: cacheControl)) + // invoke the operation + string groupId = "ChildGroup"; + ManagementGroupCreateOrUpdateContent content = new ManagementGroupCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "ChildGroup", + Details = new CreateManagementGroupDetails + { + Parent = new ManagementGroupParentCreateOptions + { + Id = "/providers/Microsoft.Management/managementGroups/RootGroup", + }, + }, + }; + string cacheControl = "no-cache"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content, cacheControl: cacheControl); + ManagementGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -62,9 +70,7 @@ public async Task Get_GetManagementGroup() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); @@ -83,9 +89,9 @@ public async Task Get_GetManagementGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagementGroup() + public async Task Get_GetManagementGroupWithAncestors() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroup.json + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -93,26 +99,29 @@ public async Task Exists_GetManagementGroup() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; + string groupId = "20000000-0001-0000-0000-00000000000"; + ManagementGroupExpandType? expand = ManagementGroupExpandType.Ancestors; string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(groupId, cacheControl: cacheControl); + ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, cacheControl: cacheControl); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagementGroup() + public async Task Get_GetManagementGroupWithExpand() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroup.json + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -120,38 +129,29 @@ public async Task GetIfExists_GetManagementGroup() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation string groupId = "20000000-0001-0000-0000-000000000000"; + ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(groupId, cacheControl: cacheControl); - ManagementGroupResource result = response.HasValue ? response.Value : null; + ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, cacheControl: cacheControl); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagementGroupWithAncestors() + public async Task Get_GetManagementGroupWithPath() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -159,16 +159,14 @@ public async Task Get_GetManagementGroupWithAncestors() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation - string groupId = "20000000-0001-0000-0000-00000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Ancestors; + string groupId = "20000000-0001-0000-0000-000000000000"; + ManagementGroupExpandType? expand = ManagementGroupExpandType.Path; string cacheControl = "no-cache"; ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, cacheControl: cacheControl); @@ -181,9 +179,9 @@ public async Task Get_GetManagementGroupWithAncestors() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagementGroupWithAncestors() + public async Task Get_GetManagementGroupsWithExpandAndRecurse() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -191,127 +189,116 @@ public async Task Exists_GetManagementGroupWithAncestors() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation - string groupId = "20000000-0001-0000-0000-00000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Ancestors; + string groupId = "20000000-0001-0000-0000-000000000000"; + ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; + bool? recurse = true; string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(groupId, expand: expand, cacheControl: cacheControl); + ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, recurse: recurse, cacheControl: cacheControl); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagementGroupWithAncestors() + public async Task GetAll_ListManagementGroups() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json - // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/ListManagementGroups.json + // this example is just showing the usage of "ManagementGroups_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - // invoke the operation - string groupId = "20000000-0001-0000-0000-00000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Ancestors; + // invoke the operation and iterate over the result string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - ManagementGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + await foreach (ManagementGroupResource item in collection.GetAllAsync(cacheControl: cacheControl)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagementGroupData resourceData = result.Data; + ManagementGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagementGroupWithExpand() + public async Task CheckNameAvailability_CheckManagementGroupNameAvailability() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json - // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/CheckManagementGroupNameAvailability.json + // this example is just showing the usage of "ManagementGroups_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - string cacheControl = "no-cache"; - ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, cacheControl: cacheControl); + ManagementGroupNameAvailabilityContent content = new ManagementGroupNameAvailabilityContent + { + Name = "nameTocheck", + ResourceType = new ResourceType("Microsoft.Management/managementGroups"), + }; + ManagementGroupNameAvailabilityResult result = await collection.CheckNameAvailabilityAsync(content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagementGroupWithExpand() + public async Task GetEntities_GetEntities() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json - // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetEntities.json + // this example is just showing the usage of "Entities_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(groupId, expand: expand, cacheControl: cacheControl); + // invoke the operation and iterate over the result + ManagementGroupCollectionGetEntitiesOptions options = new ManagementGroupCollectionGetEntitiesOptions(); + await foreach (EntityData item in collection.GetEntitiesAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagementGroupWithExpand() + public async Task Exists_GetManagementGroup() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroup.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -319,39 +306,24 @@ public async Task GetIfExists_GetManagementGroupWithExpand() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - ManagementGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(groupId, cacheControl: cacheControl); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagementGroupWithPath() + public async Task Exists_GetManagementGroupWithAncestors() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -359,31 +331,25 @@ public async Task Get_GetManagementGroupWithPath() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Path; + string groupId = "20000000-0001-0000-0000-00000000000"; + ManagementGroupExpandType? expand = ManagementGroupExpandType.Ancestors; string cacheControl = "no-cache"; - ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, cacheControl: cacheControl); + bool result = await collection.ExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagementGroupWithPath() + public async Task Exists_GetManagementGroupWithExpand() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -391,16 +357,14 @@ public async Task Exists_GetManagementGroupWithPath() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Path; + ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; string cacheControl = "no-cache"; bool result = await collection.ExistsAsync(groupId, expand: expand, cacheControl: cacheControl); @@ -409,7 +373,7 @@ public async Task Exists_GetManagementGroupWithPath() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagementGroupWithPath() + public async Task Exists_GetManagementGroupWithPath() { // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -419,9 +383,7 @@ public async Task GetIfExists_GetManagementGroupWithPath() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); @@ -430,26 +392,14 @@ public async Task GetIfExists_GetManagementGroupWithPath() string groupId = "20000000-0001-0000-0000-000000000000"; ManagementGroupExpandType? expand = ManagementGroupExpandType.Path; string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - ManagementGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(groupId, expand: expand, cacheControl: cacheControl); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagementGroupsWithExpandAndRecurse() + public async Task Exists_GetManagementGroupsWithExpandAndRecurse() { // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -459,9 +409,7 @@ public async Task Get_GetManagementGroupsWithExpandAndRecurse() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); @@ -471,20 +419,16 @@ public async Task Get_GetManagementGroupsWithExpandAndRecurse() ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; bool? recurse = true; string cacheControl = "no-cache"; - ManagementGroupResource result = await collection.GetAsync(groupId, expand: expand, recurse: recurse, cacheControl: cacheControl); + bool result = await collection.ExistsAsync(groupId, expand: expand, recurse: recurse, cacheControl: cacheControl); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagementGroupsWithExpandAndRecurse() + public async Task GetIfExists_GetManagementGroup() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroup.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -492,28 +436,36 @@ public async Task Exists_GetManagementGroupsWithExpandAndRecurse() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - bool? recurse = true; string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(groupId, expand: expand, recurse: recurse, cacheControl: cacheControl); + NullableResponse response = await collection.GetIfExistsAsync(groupId, cacheControl: cacheControl); + ManagementGroupResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagementGroupsWithExpandAndRecurse() + public async Task GetIfExists_GetManagementGroupWithAncestors() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithAncestors.json // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -521,19 +473,16 @@ public async Task GetIfExists_GetManagementGroupsWithExpandAndRecurse() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation - string groupId = "20000000-0001-0000-0000-000000000000"; - ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; - bool? recurse = true; + string groupId = "20000000-0001-0000-0000-00000000000"; + ManagementGroupExpandType? expand = ManagementGroupExpandType.Ancestors; string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, recurse: recurse, cacheControl: cacheControl); + NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, cacheControl: cacheControl); ManagementGroupResource result = response.HasValue ? response.Value : null; if (result == null) @@ -552,104 +501,117 @@ public async Task GetIfExists_GetManagementGroupsWithExpandAndRecurse() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutManagementGroup() + public async Task GetIfExists_GetManagementGroupWithExpand() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PutManagementGroup.json - // this example is just showing the usage of "ManagementGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpand.json + // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation - string groupId = "ChildGroup"; - ManagementGroupCreateOrUpdateContent content = new ManagementGroupCreateOrUpdateContent() - { - DisplayName = "ChildGroup", - Details = new CreateManagementGroupDetails() - { - Parent = new ManagementGroupParentCreateOptions() - { - Id = "/providers/Microsoft.Management/managementGroups/RootGroup", - }, - }, - }; + string groupId = "20000000-0001-0000-0000-000000000000"; + ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; string cacheControl = "no-cache"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content, cacheControl: cacheControl); - ManagementGroupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, cacheControl: cacheControl); + ManagementGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CheckNameAvailability_CheckManagementGroupNameAvailability() + public async Task GetIfExists_GetManagementGroupWithPath() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/CheckManagementGroupNameAvailability.json - // this example is just showing the usage of "ManagementGroups_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithPath.json + // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); // invoke the operation - ManagementGroupNameAvailabilityContent content = new ManagementGroupNameAvailabilityContent() - { - Name = "nameTocheck", - ResourceType = new ResourceType("Microsoft.Management/managementGroups"), - }; - ManagementGroupNameAvailabilityResult result = await collection.CheckNameAvailabilityAsync(content); + string groupId = "20000000-0001-0000-0000-000000000000"; + ManagementGroupExpandType? expand = ManagementGroupExpandType.Path; + string cacheControl = "no-cache"; + NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, cacheControl: cacheControl); + ManagementGroupResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntities_GetEntities() + public async Task GetIfExists_GetManagementGroupsWithExpandAndRecurse() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetEntities.json - // this example is just showing the usage of "Entities_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetManagementGroupWithExpandAndRecurse.json + // this example is just showing the usage of "ManagementGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this ManagementGroupResource ManagementGroupCollection collection = tenantResource.GetManagementGroups(); - // invoke the operation and iterate over the result - ManagementGroupCollectionGetEntitiesOptions options = new ManagementGroupCollectionGetEntitiesOptions() { }; - await foreach (EntityData item in collection.GetEntitiesAsync(options)) + // invoke the operation + string groupId = "20000000-0001-0000-0000-000000000000"; + ManagementGroupExpandType? expand = ManagementGroupExpandType.Children; + bool? recurse = true; + string cacheControl = "no-cache"; + NullableResponse response = await collection.GetIfExistsAsync(groupId, expand: expand, recurse: recurse, cacheControl: cacheControl); + ManagementGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Console.WriteLine($"Succeeded: {item}"); + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionCollection.cs index 280fb6326a96f..dac6a41304ea6 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionCollection.cs @@ -41,50 +41,50 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyDefinitionAtManagementGrou // invoke the operation string policyDefinitionName = "ResourceNaming"; - PolicyDefinitionData data = new PolicyDefinitionData() + PolicyDefinitionData data = new PolicyDefinitionData { Mode = "All", DisplayName = "Enforce resource naming convention", Description = "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() + PolicyRule = BinaryData.FromObjectAsJson(new Dictionary { - ["if"] = new Dictionary() + ["if"] = new { - ["not"] = new Dictionary() + not = new { - ["field"] = "name", - ["like"] = "[concat(parameters('prefix'), '*', parameters('suffix'))]" - } + field = "name", + like = "[concat(parameters('prefix'), '*', parameters('suffix'))]", + }, }, - ["then"] = new Dictionary() + ["then"] = new { - ["effect"] = "deny" + effect = "deny", } }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Naming" + category = "Naming", }), Parameters = { -["prefix"] = new ArmPolicyParameter() +["prefix"] = new ArmPolicyParameter { ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() +Metadata = new ParameterDefinitionsValueMetadata { DisplayName = "Prefix", Description = "Resource name prefix", }, }, -["suffix"] = new ArmPolicyParameter() +["suffix"] = new ArmPolicyParameter { ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() +Metadata = new ParameterDefinitionsValueMetadata { DisplayName = "Suffix", Description = "Resource name suffix", }, -}, +} }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyDefinitionName, data); @@ -131,10 +131,10 @@ public async Task Get_RetrieveAPolicyDefinitionAtManagementGroupLevel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveAPolicyDefinitionAtManagementGroupLevel() + public async Task GetAll_ListPolicyDefinitionsByManagementGroup() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_GetAtManagementGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitionsByManagementGroup.json + // this example is just showing the usage of "PolicyDefinitions_ListByManagementGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,16 +150,22 @@ public async Task Exists_RetrieveAPolicyDefinitionAtManagementGroupLevel() // get the collection of this ManagementGroupPolicyDefinitionResource ManagementGroupPolicyDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicyDefinitions(); - // invoke the operation - string policyDefinitionName = "ResourceNaming"; - bool result = await collection.ExistsAsync(policyDefinitionName); + // invoke the operation and iterate over the result + await foreach (ManagementGroupPolicyDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAPolicyDefinitionAtManagementGroupLevel() + public async Task Exists_RetrieveAPolicyDefinitionAtManagementGroupLevel() { // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json // this example is just showing the usage of "PolicyDefinitions_GetAtManagementGroup" operation, for the dependent resources, they will have to be created separately. @@ -180,29 +186,17 @@ public async Task GetIfExists_RetrieveAPolicyDefinitionAtManagementGroupLevel() // invoke the operation string policyDefinitionName = "ResourceNaming"; - NullableResponse response = await collection.GetIfExistsAsync(policyDefinitionName); - ManagementGroupPolicyDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPolicyDefinitionsByManagementGroup() + public async Task GetIfExists_RetrieveAPolicyDefinitionAtManagementGroupLevel() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitionsByManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_ListByManagementGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json + // this example is just showing the usage of "PolicyDefinitions_GetAtManagementGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -218,17 +212,23 @@ public async Task GetAll_ListPolicyDefinitionsByManagementGroup() // get the collection of this ManagementGroupPolicyDefinitionResource ManagementGroupPolicyDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicyDefinitions(); - // invoke the operation and iterate over the result - await foreach (ManagementGroupPolicyDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string policyDefinitionName = "ResourceNaming"; + NullableResponse response = await collection.GetIfExistsAsync(policyDefinitionName); + ManagementGroupPolicyDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyDefinitionData resourceData = item.Data; + PolicyDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionResource.cs index dd90844cfc338..ed02214b700c3 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicyDefinitionResource.cs @@ -19,10 +19,10 @@ public partial class Sample_ManagementGroupPolicyDefinitionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAPolicyDefinitionAtManagementGroupLevel() + public async Task Get_RetrieveAPolicyDefinitionAtManagementGroupLevel() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_CreateOrUpdateAtManagementGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json + // this example is just showing the usage of "PolicyDefinitions_GetAtManagementGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,54 +37,7 @@ public async Task Update_CreateOrUpdateAPolicyDefinitionAtManagementGroupLevel() ManagementGroupPolicyDefinitionResource managementGroupPolicyDefinition = client.GetManagementGroupPolicyDefinitionResource(managementGroupPolicyDefinitionResourceId); // invoke the operation - PolicyDefinitionData data = new PolicyDefinitionData() - { - Mode = "All", - DisplayName = "Enforce resource naming convention", - Description = "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() - { - ["if"] = new Dictionary() - { - ["not"] = new Dictionary() - { - ["field"] = "name", - ["like"] = "[concat(parameters('prefix'), '*', parameters('suffix'))]" - } - }, - ["then"] = new Dictionary() - { - ["effect"] = "deny" - } - }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - ["category"] = "Naming" - }), - Parameters = -{ -["prefix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Prefix", -Description = "Resource name prefix", -}, -}, -["suffix"] = new ArmPolicyParameter() -{ -ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() -{ -DisplayName = "Suffix", -Description = "Resource name suffix", -}, -}, -}, - }; - ArmOperation lro = await managementGroupPolicyDefinition.UpdateAsync(WaitUntil.Completed, data); - ManagementGroupPolicyDefinitionResource result = lro.Value; + ManagementGroupPolicyDefinitionResource result = await managementGroupPolicyDefinition.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -120,10 +73,10 @@ public async Task Delete_DeleteAPolicyDefinitionAtManagementGroupLevel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyDefinitionAtManagementGroupLevel() + public async Task Update_CreateOrUpdateAPolicyDefinitionAtManagementGroupLevel() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicyDefinitions_GetAtManagementGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/createOrUpdatePolicyDefinitionAtManagementGroup.json + // this example is just showing the usage of "PolicyDefinitions_CreateOrUpdateAtManagementGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,7 +91,54 @@ public async Task Get_RetrieveAPolicyDefinitionAtManagementGroupLevel() ManagementGroupPolicyDefinitionResource managementGroupPolicyDefinition = client.GetManagementGroupPolicyDefinitionResource(managementGroupPolicyDefinitionResourceId); // invoke the operation - ManagementGroupPolicyDefinitionResource result = await managementGroupPolicyDefinition.GetAsync(); + PolicyDefinitionData data = new PolicyDefinitionData + { + Mode = "All", + DisplayName = "Enforce resource naming convention", + Description = "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", + PolicyRule = BinaryData.FromObjectAsJson(new Dictionary + { + ["if"] = new + { + not = new + { + field = "name", + like = "[concat(parameters('prefix'), '*', parameters('suffix'))]", + }, + }, + ["then"] = new + { + effect = "deny", + } + }), + Metadata = BinaryData.FromObjectAsJson(new + { + category = "Naming", + }), + Parameters = +{ +["prefix"] = new ArmPolicyParameter +{ +ParameterType = ArmPolicyParameterType.String, +Metadata = new ParameterDefinitionsValueMetadata +{ +DisplayName = "Prefix", +Description = "Resource name prefix", +}, +}, +["suffix"] = new ArmPolicyParameter +{ +ParameterType = ArmPolicyParameterType.String, +Metadata = new ParameterDefinitionsValueMetadata +{ +DisplayName = "Suffix", +Description = "Resource name suffix", +}, +} +}, + }; + ArmOperation lro = await managementGroupPolicyDefinition.UpdateAsync(WaitUntil.Completed, data); + ManagementGroupPolicyDefinitionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionCollection.cs index caea7caccdff4..1fd9bb4e3fbca 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -41,42 +40,43 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicySetDefinitionAtManagementG // invoke the operation string policySetDefinitionName = "CostManagement"; - PolicySetDefinitionData data = new PolicySetDefinitionData() + PolicySetDefinitionData data = new PolicySetDefinitionData { DisplayName = "Cost Management", Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Cost Management" + category = "Cost Management", }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + PolicyDefinitions = {new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") { Parameters = { -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() +["listOfAllowedSKUs"] = new ArmPolicyParameterValue { -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, +Value = BinaryData.FromObjectAsJson(new object[] +{ +"Standard_GRS", +"Standard_LRS" +}), +} }, PolicyDefinitionReferenceId = "Limit_Skus", -},new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") +}, new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") { Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"DeptA\""), +Value = BinaryData.FromObjectAsJson("DeptA"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", +Value = BinaryData.FromObjectAsJson("-LC"), } }, +PolicyDefinitionReferenceId = "Resource_Naming", +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policySetDefinitionName, data); ManagementGroupPolicySetDefinitionResource result = lro.Value; @@ -111,62 +111,54 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicySetDefinitionWithGroupsAtM // invoke the operation string policySetDefinitionName = "CostManagement"; - PolicySetDefinitionData data = new PolicySetDefinitionData() + PolicySetDefinitionData data = new PolicySetDefinitionData { DisplayName = "Cost Management", Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Cost Management" + category = "Cost Management", }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + PolicyDefinitions = {new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") { Parameters = { -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() +["listOfAllowedSKUs"] = new ArmPolicyParameterValue { -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -GroupNames = +Value = BinaryData.FromObjectAsJson(new object[] { -"CostSaving" +"Standard_GRS", +"Standard_LRS" +}), +} }, -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") +PolicyDefinitionReferenceId = "Limit_Skus", +GroupNames = {"CostSaving"}, +}, new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") { Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"DeptA\""), +Value = BinaryData.FromObjectAsJson("DeptA"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -GroupNames = -{ -"Organizational" -}, +Value = BinaryData.FromObjectAsJson("-LC"), } }, - PolicyDefinitionGroups = -{ -new PolicyDefinitionGroup("CostSaving") +PolicyDefinitionReferenceId = "Resource_Naming", +GroupNames = {"Organizational"}, +}}, + PolicyDefinitionGroups = {new PolicyDefinitionGroup("CostSaving") { DisplayName = "Cost Management Policies", Description = "Policies designed to control spend within a subscription.", -},new PolicyDefinitionGroup("Organizational") +}, new PolicyDefinitionGroup("Organizational") { DisplayName = "Organizational Policies", Description = "Policies that help enforce resource organization standards within a subscription.", -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policySetDefinitionName, data); ManagementGroupPolicySetDefinitionResource result = lro.Value; @@ -212,10 +204,10 @@ public async Task Get_RetrieveAPolicySetDefinitionAtManagementGroupLevel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveAPolicySetDefinitionAtManagementGroupLevel() + public async Task GetAll_ListPolicySetDefinitionsAtManagementGroupLevel() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_GetAtManagementGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitionsByManagementGroup.json + // this example is just showing the usage of "PolicySetDefinitions_ListByManagementGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -231,16 +223,22 @@ public async Task Exists_RetrieveAPolicySetDefinitionAtManagementGroupLevel() // get the collection of this ManagementGroupPolicySetDefinitionResource ManagementGroupPolicySetDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicySetDefinitions(); - // invoke the operation - string policySetDefinitionName = "CostManagement"; - bool result = await collection.ExistsAsync(policySetDefinitionName); + // invoke the operation and iterate over the result + await foreach (ManagementGroupPolicySetDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicySetDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAPolicySetDefinitionAtManagementGroupLevel() + public async Task Exists_RetrieveAPolicySetDefinitionAtManagementGroupLevel() { // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json // this example is just showing the usage of "PolicySetDefinitions_GetAtManagementGroup" operation, for the dependent resources, they will have to be created separately. @@ -261,29 +259,17 @@ public async Task GetIfExists_RetrieveAPolicySetDefinitionAtManagementGroupLevel // invoke the operation string policySetDefinitionName = "CostManagement"; - NullableResponse response = await collection.GetIfExistsAsync(policySetDefinitionName); - ManagementGroupPolicySetDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policySetDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPolicySetDefinitionsAtManagementGroupLevel() + public async Task GetIfExists_RetrieveAPolicySetDefinitionAtManagementGroupLevel() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitionsByManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_ListByManagementGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json + // this example is just showing the usage of "PolicySetDefinitions_GetAtManagementGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -299,17 +285,23 @@ public async Task GetAll_ListPolicySetDefinitionsAtManagementGroupLevel() // get the collection of this ManagementGroupPolicySetDefinitionResource ManagementGroupPolicySetDefinitionCollection collection = managementGroupResource.GetManagementGroupPolicySetDefinitions(); - // invoke the operation and iterate over the result - await foreach (ManagementGroupPolicySetDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string policySetDefinitionName = "CostManagement"; + NullableResponse response = await collection.GetIfExistsAsync(policySetDefinitionName); + ManagementGroupPolicySetDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicySetDefinitionData resourceData = item.Data; + PolicySetDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionResource.cs index d266d26ffd5c3..5740485f638ed 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupPolicySetDefinitionResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -17,6 +16,60 @@ namespace Azure.ResourceManager.Resources.Samples { public partial class Sample_ManagementGroupPolicySetDefinitionResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_RetrieveAPolicySetDefinitionAtManagementGroupLevel() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json + // this example is just showing the usage of "PolicySetDefinitions_GetAtManagementGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagementGroupPolicySetDefinitionResource created on azure + // for more information of creating ManagementGroupPolicySetDefinitionResource, please refer to the document of ManagementGroupPolicySetDefinitionResource + string managementGroupId = "MyManagementGroup"; + string policySetDefinitionName = "CostManagement"; + ResourceIdentifier managementGroupPolicySetDefinitionResourceId = ManagementGroupPolicySetDefinitionResource.CreateResourceIdentifier(managementGroupId, policySetDefinitionName); + ManagementGroupPolicySetDefinitionResource managementGroupPolicySetDefinition = client.GetManagementGroupPolicySetDefinitionResource(managementGroupPolicySetDefinitionResourceId); + + // invoke the operation + ManagementGroupPolicySetDefinitionResource result = await managementGroupPolicySetDefinition.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicySetDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAPolicySetDefinitionAtManagementGroupLevel() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinitionAtManagementGroup.json + // this example is just showing the usage of "PolicySetDefinitions_DeleteAtManagementGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagementGroupPolicySetDefinitionResource created on azure + // for more information of creating ManagementGroupPolicySetDefinitionResource, please refer to the document of ManagementGroupPolicySetDefinitionResource + string managementGroupId = "MyManagementGroup"; + string policySetDefinitionName = "CostManagement"; + ResourceIdentifier managementGroupPolicySetDefinitionResourceId = ManagementGroupPolicySetDefinitionResource.CreateResourceIdentifier(managementGroupId, policySetDefinitionName); + ManagementGroupPolicySetDefinitionResource managementGroupPolicySetDefinition = client.GetManagementGroupPolicySetDefinitionResource(managementGroupPolicySetDefinitionResourceId); + + // invoke the operation + await managementGroupPolicySetDefinition.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateAPolicySetDefinitionAtManagementGroupLevel() @@ -37,42 +90,43 @@ public async Task Update_CreateOrUpdateAPolicySetDefinitionAtManagementGroupLeve ManagementGroupPolicySetDefinitionResource managementGroupPolicySetDefinition = client.GetManagementGroupPolicySetDefinitionResource(managementGroupPolicySetDefinitionResourceId); // invoke the operation - PolicySetDefinitionData data = new PolicySetDefinitionData() + PolicySetDefinitionData data = new PolicySetDefinitionData { DisplayName = "Cost Management", Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Cost Management" + category = "Cost Management", }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + PolicyDefinitions = {new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") { Parameters = { -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() +["listOfAllowedSKUs"] = new ArmPolicyParameterValue { -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, +Value = BinaryData.FromObjectAsJson(new object[] +{ +"Standard_GRS", +"Standard_LRS" +}), +} }, PolicyDefinitionReferenceId = "Limit_Skus", -},new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") +}, new PolicyDefinitionReference("/providers/Microsoft.Management/managementgroups/MyManagementGroup/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") { Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"DeptA\""), +Value = BinaryData.FromObjectAsJson("DeptA"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", +Value = BinaryData.FromObjectAsJson("-LC"), } }, +PolicyDefinitionReferenceId = "Resource_Naming", +}}, }; ArmOperation lro = await managementGroupPolicySetDefinition.UpdateAsync(WaitUntil.Completed, data); ManagementGroupPolicySetDefinitionResource result = lro.Value; @@ -104,62 +158,54 @@ public async Task Update_CreateOrUpdateAPolicySetDefinitionWithGroupsAtManagemen ManagementGroupPolicySetDefinitionResource managementGroupPolicySetDefinition = client.GetManagementGroupPolicySetDefinitionResource(managementGroupPolicySetDefinitionResourceId); // invoke the operation - PolicySetDefinitionData data = new PolicySetDefinitionData() + PolicySetDefinitionData data = new PolicySetDefinitionData { DisplayName = "Cost Management", Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Cost Management" + category = "Cost Management", }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + PolicyDefinitions = {new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") { Parameters = { -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() +["listOfAllowedSKUs"] = new ArmPolicyParameterValue { -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -GroupNames = +Value = BinaryData.FromObjectAsJson(new object[] { -"CostSaving" +"Standard_GRS", +"Standard_LRS" +}), +} }, -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") +PolicyDefinitionReferenceId = "Limit_Skus", +GroupNames = {"CostSaving"}, +}, new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") { Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"DeptA\""), +Value = BinaryData.FromObjectAsJson("DeptA"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -GroupNames = -{ -"Organizational" -}, +Value = BinaryData.FromObjectAsJson("-LC"), } }, - PolicyDefinitionGroups = -{ -new PolicyDefinitionGroup("CostSaving") +PolicyDefinitionReferenceId = "Resource_Naming", +GroupNames = {"Organizational"}, +}}, + PolicyDefinitionGroups = {new PolicyDefinitionGroup("CostSaving") { DisplayName = "Cost Management Policies", Description = "Policies designed to control spend within a subscription.", -},new PolicyDefinitionGroup("Organizational") +}, new PolicyDefinitionGroup("Organizational") { DisplayName = "Organizational Policies", Description = "Policies that help enforce resource organization standards within a subscription.", -} -}, +}}, }; ArmOperation lro = await managementGroupPolicySetDefinition.UpdateAsync(WaitUntil.Completed, data); ManagementGroupPolicySetDefinitionResource result = lro.Value; @@ -170,59 +216,5 @@ public async Task Update_CreateOrUpdateAPolicySetDefinitionWithGroupsAtManagemen // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPolicySetDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_DeleteAtManagementGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagementGroupPolicySetDefinitionResource created on azure - // for more information of creating ManagementGroupPolicySetDefinitionResource, please refer to the document of ManagementGroupPolicySetDefinitionResource - string managementGroupId = "MyManagementGroup"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier managementGroupPolicySetDefinitionResourceId = ManagementGroupPolicySetDefinitionResource.CreateResourceIdentifier(managementGroupId, policySetDefinitionName); - ManagementGroupPolicySetDefinitionResource managementGroupPolicySetDefinition = client.GetManagementGroupPolicySetDefinitionResource(managementGroupPolicySetDefinitionResourceId); - - // invoke the operation - await managementGroupPolicySetDefinition.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicySetDefinitionAtManagementGroupLevel() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinitionAtManagementGroup.json - // this example is just showing the usage of "PolicySetDefinitions_GetAtManagementGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagementGroupPolicySetDefinitionResource created on azure - // for more information of creating ManagementGroupPolicySetDefinitionResource, please refer to the document of ManagementGroupPolicySetDefinitionResource - string managementGroupId = "MyManagementGroup"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier managementGroupPolicySetDefinitionResourceId = ManagementGroupPolicySetDefinitionResource.CreateResourceIdentifier(managementGroupId, policySetDefinitionName); - ManagementGroupPolicySetDefinitionResource managementGroupPolicySetDefinition = client.GetManagementGroupPolicySetDefinitionResource(managementGroupPolicySetDefinitionResourceId); - - // invoke the operation - ManagementGroupPolicySetDefinitionResource result = await managementGroupPolicySetDefinition.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupResource.cs index 696829806e7f0..6867f1a5e2da2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupResource.cs @@ -168,10 +168,10 @@ public async Task Get_GetManagementGroupsWithExpandAndRecurse() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchManagementGroup() + public async Task Delete_DeleteManagementGroup() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PatchManagementGroup.json - // this example is just showing the usage of "ManagementGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/DeleteManagementGroup.json + // this example is just showing the usage of "ManagementGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,32 +180,23 @@ public async Task Update_PatchManagementGroup() // this example assumes you already have this ManagementGroupResource created on azure // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "ChildGroup"; + string groupId = "GroupToDelete"; ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); // invoke the operation - ManagementGroupPatch patch = new ManagementGroupPatch() - { - DisplayName = "AlternateDisplayName", - ParentGroupId = "/providers/Microsoft.Management/managementGroups/AlternateRootGroup", - }; string cacheControl = "no-cache"; - ManagementGroupResource result = await managementGroup.UpdateAsync(patch, cacheControl: cacheControl); + await managementGroup.DeleteAsync(WaitUntil.Completed, cacheControl: cacheControl); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteManagementGroup() + public async Task Update_PatchManagementGroup() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/DeleteManagementGroup.json - // this example is just showing the usage of "ManagementGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/PatchManagementGroup.json + // this example is just showing the usage of "ManagementGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -214,15 +205,24 @@ public async Task Delete_DeleteManagementGroup() // this example assumes you already have this ManagementGroupResource created on azure // for more information of creating ManagementGroupResource, please refer to the document of ManagementGroupResource - string groupId = "GroupToDelete"; + string groupId = "ChildGroup"; ResourceIdentifier managementGroupResourceId = ManagementGroupResource.CreateResourceIdentifier(groupId); ManagementGroupResource managementGroup = client.GetManagementGroupResource(managementGroupResourceId); // invoke the operation + ManagementGroupPatch patch = new ManagementGroupPatch + { + DisplayName = "AlternateDisplayName", + ParentGroupId = "/providers/Microsoft.Management/managementGroups/AlternateRootGroup", + }; string cacheControl = "no-cache"; - await managementGroup.DeleteAsync(WaitUntil.Completed, cacheControl: cacheControl); + ManagementGroupResource result = await managementGroup.UpdateAsync(patch, cacheControl: cacheControl); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionCollection.cs index d8c90be2f3338..b6b95ffb01fed 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionCollection.cs @@ -84,10 +84,10 @@ public async Task Get_GetSubscriptionFromManagementGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSubscriptionFromManagementGroup() + public async Task GetAll_GetAllSubscriptionsFromManagementGroup() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json - // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetAllSubscriptionsFromManagementGroup.json + // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscriptionsUnderManagementGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,17 +103,22 @@ public async Task Exists_GetSubscriptionFromManagementGroup() // get the collection of this ManagementGroupSubscriptionResource ManagementGroupSubscriptionCollection collection = managementGroup.GetManagementGroupSubscriptions(); - // invoke the operation - string subscriptionId = "728bcbe4-8d56-4510-86c2-4921b8beefbc"; - string cacheControl = "no-cache"; - bool result = await collection.ExistsAsync(subscriptionId, cacheControl: cacheControl); + // invoke the operation and iterate over the result + await foreach (ManagementGroupSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementGroupSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSubscriptionFromManagementGroup() + public async Task Exists_GetSubscriptionFromManagementGroup() { // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscription" operation, for the dependent resources, they will have to be created separately. @@ -135,29 +140,17 @@ public async Task GetIfExists_GetSubscriptionFromManagementGroup() // invoke the operation string subscriptionId = "728bcbe4-8d56-4510-86c2-4921b8beefbc"; string cacheControl = "no-cache"; - NullableResponse response = await collection.GetIfExistsAsync(subscriptionId, cacheControl: cacheControl); - ManagementGroupSubscriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(subscriptionId, cacheControl: cacheControl); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementGroupSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllSubscriptionsFromManagementGroup() + public async Task GetIfExists_GetSubscriptionFromManagementGroup() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetAllSubscriptionsFromManagementGroup.json - // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscriptionsUnderManagementGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json + // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,17 +166,24 @@ public async Task GetAll_GetAllSubscriptionsFromManagementGroup() // get the collection of this ManagementGroupSubscriptionResource ManagementGroupSubscriptionCollection collection = managementGroup.GetManagementGroupSubscriptions(); - // invoke the operation and iterate over the result - await foreach (ManagementGroupSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string subscriptionId = "728bcbe4-8d56-4510-86c2-4921b8beefbc"; + string cacheControl = "no-cache"; + NullableResponse response = await collection.GetIfExistsAsync(subscriptionId, cacheControl: cacheControl); + ManagementGroupSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagementGroupSubscriptionData resourceData = item.Data; + ManagementGroupSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionResource.cs index b1dd6db682f09..fad0a81daa699 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementGroupSubscriptionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ManagementGroupSubscriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AddSubscriptionToManagementGroup() + public async Task Get_GetSubscriptionFromManagementGroup() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/AddManagementGroupSubscription.json - // this example is just showing the usage of "ManagementGroupSubscriptions_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json + // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,8 +36,7 @@ public async Task Update_AddSubscriptionToManagementGroup() // invoke the operation string cacheControl = "no-cache"; - ArmOperation lro = await managementGroupSubscription.UpdateAsync(WaitUntil.Completed, cacheControl: cacheControl); - ManagementGroupSubscriptionResource result = lro.Value; + ManagementGroupSubscriptionResource result = await managementGroupSubscription.GetAsync(cacheControl: cacheControl); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -74,10 +73,10 @@ public async Task Delete_DeleteSubscriptionFromManagementGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSubscriptionFromManagementGroup() + public async Task Update_AddSubscriptionToManagementGroup() { - // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/GetSubscriptionFromManagementGroup.json - // this example is just showing the usage of "ManagementGroupSubscriptions_GetSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementgroups/resource-manager/Microsoft.Management/stable/2021-04-01/examples/AddManagementGroupSubscription.json + // this example is just showing the usage of "ManagementGroupSubscriptions_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,7 +92,8 @@ public async Task Get_GetSubscriptionFromManagementGroup() // invoke the operation string cacheControl = "no-cache"; - ManagementGroupSubscriptionResource result = await managementGroupSubscription.GetAsync(cacheControl: cacheControl); + ArmOperation lro = await managementGroupSubscription.UpdateAsync(WaitUntil.Completed, cacheControl: cacheControl); + ManagementGroupSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockCollection.cs index 59d19ed765348..553bee56c0d4a 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockCollection.cs @@ -28,13 +28,9 @@ public async Task CreateOrUpdate_CreateManagementLockAtScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagementLockResource string scope = "subscriptions/subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks(); + ManagementLockCollection collection = client.GetManagementLocks(new ResourceIdentifier(scope)); // invoke the operation string lockName = "testlock"; @@ -61,13 +57,9 @@ public async Task Get_GetManagementLockAtScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagementLockResource string scope = "subscriptions/subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks(); + ManagementLockCollection collection = client.GetManagementLocks(new ResourceIdentifier(scope)); // invoke the operation string lockName = "testlock"; @@ -80,6 +72,35 @@ public async Task Get_GetManagementLockAtScope() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListManagementLocksAtScope() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json + // this example is just showing the usage of "ManagementLocks_ListByScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ManagementLockResource + string scope = "subscriptions/subscriptionId"; + ManagementLockCollection collection = client.GetManagementLocks(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (ManagementLockResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagementLockData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetManagementLockAtScope() @@ -92,13 +113,9 @@ public async Task Exists_GetManagementLockAtScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagementLockResource string scope = "subscriptions/subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks(); + ManagementLockCollection collection = client.GetManagementLocks(new ResourceIdentifier(scope)); // invoke the operation string lockName = "testlock"; @@ -119,13 +136,9 @@ public async Task GetIfExists_GetManagementLockAtScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagementLockResource string scope = "subscriptions/subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks(); + ManagementLockCollection collection = client.GetManagementLocks(new ResourceIdentifier(scope)); // invoke the operation string lockName = "testlock"; @@ -145,38 +158,5 @@ public async Task GetIfExists_GetManagementLockAtScope() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagementLocksAtScope() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_ListAtScope.json - // this example is just showing the usage of "ManagementLocks_ListByScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ManagementLockResource - string scope = "subscriptions/subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagementLockCollection collection = client.GetGenericResource(scopeId).GetManagementLocks(); - - // invoke the operation and iterate over the result - await foreach (ManagementLockResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagementLockData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockResource.cs index 33de02ed4bbb8..433717bb0b0df 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ManagementLockResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagementLockResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateManagementLockAtScope() + public async Task Get_GetManagementLockAtScope() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json - // this example is just showing the usage of "ManagementLocks_CreateOrUpdateByScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json + // this example is just showing the usage of "ManagementLocks_GetByScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,9 +36,7 @@ public async Task Update_CreateManagementLockAtScope() ManagementLockResource managementLock = client.GetManagementLockResource(managementLockResourceId); // invoke the operation - ManagementLockData data = new ManagementLockData(ManagementLockLevel.ReadOnly); - ArmOperation lro = await managementLock.UpdateAsync(WaitUntil.Completed, data); - ManagementLockResource result = lro.Value; + ManagementLockResource result = await managementLock.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -74,10 +72,10 @@ public async Task Delete_DeleteManagementLockAtScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagementLockAtScope() + public async Task Update_CreateManagementLockAtScope() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_GetAtScope.json - // this example is just showing the usage of "ManagementLocks_GetByScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2020-05-01/examples/ManagementLocks_CreateOrUpdateAtScope.json + // this example is just showing the usage of "ManagementLocks_CreateOrUpdateByScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,7 +90,9 @@ public async Task Get_GetManagementLockAtScope() ManagementLockResource managementLock = client.GetManagementLockResource(managementLockResourceId); // invoke the operation - ManagementLockResource result = await managementLock.GetAsync(); + ManagementLockData data = new ManagementLockData(ManagementLockLevel.ReadOnly); + ArmOperation lro = await managementLock.UpdateAsync(WaitUntil.Completed, data); + ManagementLockResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentCollection.cs index d8bb82a7a10d1..c5617bb2b094b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -30,40 +29,33 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentData data = new PolicyAssignmentData() + PolicyAssignmentData data = new PolicyAssignmentData { DisplayName = "Enforce resource naming rules", PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"DeptA\""), +Value = BinaryData.FromObjectAsJson("DeptA"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, +Value = BinaryData.FromObjectAsJson("-LC"), +} }, Description = "Force resource names to begin with given DeptA and end with -LC", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["assignedBy"] = "Special Someone" + assignedBy = "Special Someone", }), - NonComplianceMessages = -{ -new NonComplianceMessage("Resource names must start with 'DeptA' and end with '-LC'.") -}, + NonComplianceMessages = { new NonComplianceMessage("Resource names must start with 'DeptA' and end with '-LC'.") }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); PolicyAssignmentResource result = lro.Value; @@ -87,17 +79,13 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithASystemAssig // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentData data = new PolicyAssignmentData() + PolicyAssignmentData data = new PolicyAssignmentData { Location = new AzureLocation("eastus"), ManagedIdentity = new ManagedServiceIdentity("SystemAssigned"), @@ -105,19 +93,19 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithASystemAssig PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"DeptA\""), +Value = BinaryData.FromObjectAsJson("DeptA"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, +Value = BinaryData.FromObjectAsJson("-LC"), +} }, Description = "Force resource names to begin with given DeptA and end with -LC", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["assignedBy"] = "Foo Bar" + assignedBy = "Foo Bar", }), EnforcementMode = EnforcementMode.Default, }; @@ -143,43 +131,39 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithAUserAssigne // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentData data = new PolicyAssignmentData() + PolicyAssignmentData data = new PolicyAssignmentData { Location = new AzureLocation("eastus"), ManagedIdentity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity() }, }, DisplayName = "Enforce resource naming rules", PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"DeptA\""), +Value = BinaryData.FromObjectAsJson("DeptA"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, +Value = BinaryData.FromObjectAsJson("-LC"), +} }, Description = "Force resource names to begin with given DeptA and end with -LC", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["assignedBy"] = "Foo Bar" + assignedBy = "Foo Bar", }), EnforcementMode = EnforcementMode.Default, }; @@ -205,30 +189,23 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithMultipleNonC // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "securityInitAssignment"; - PolicyAssignmentData data = new PolicyAssignmentData() + PolicyAssignmentData data = new PolicyAssignmentData { DisplayName = "Enforce security policies", PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/securityInitiative", - NonComplianceMessages = -{ -new NonComplianceMessage("Resources must comply with all internal security policies. See for more info."),new NonComplianceMessage("Resource names must start with 'DeptA' and end with '-LC'.") + NonComplianceMessages = {new NonComplianceMessage("Resources must comply with all internal security policies. See for more info."), new NonComplianceMessage("Resource names must start with 'DeptA' and end with '-LC'.") { PolicyDefinitionReferenceId = "10420126870854049575", -},new NonComplianceMessage("Storage accounts must have firewall rules configured.") +}, new NonComplianceMessage("Storage accounts must have firewall rules configured.") { PolicyDefinitionReferenceId = "8572513655450389710", -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); PolicyAssignmentResource result = lro.Value; @@ -252,44 +229,31 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithOverrides() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "CostManagement"; - PolicyAssignmentData data = new PolicyAssignmentData() + PolicyAssignmentData data = new PolicyAssignmentData { DisplayName = "Limit the resource location and resource SKU", PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", Description = "Limit the resource location and resource SKU", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["assignedBy"] = "Special Someone" + assignedBy = "Special Someone", }), - Overrides = -{ -new PolicyOverride() + Overrides = {new PolicyOverride { Kind = PolicyOverrideKind.PolicyEffect, Value = "Audit", -Selectors = -{ -new ResourceSelectorExpression() +Selectors = {new ResourceSelectorExpression { Kind = ResourceSelectorKind.PolicyDefinitionReferenceId, -In = -{ -"Limit_Skus","Limit_Locations" -}, -} -}, -} -}, +In = {"Limit_Skus", "Limit_Locations"}, +}}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); PolicyAssignmentResource result = lro.Value; @@ -313,43 +277,30 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithResourceSele // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "CostManagement"; - PolicyAssignmentData data = new PolicyAssignmentData() + PolicyAssignmentData data = new PolicyAssignmentData { DisplayName = "Limit the resource location and resource SKU", PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policySetDefinitions/CostManagement", Description = "Limit the resource location and resource SKU", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["assignedBy"] = "Special Someone" + assignedBy = "Special Someone", }), - ResourceSelectors = -{ -new ResourceSelector() + ResourceSelectors = {new ResourceSelector { Name = "SDPRegions", -Selectors = -{ -new ResourceSelectorExpression() +Selectors = {new ResourceSelectorExpression { Kind = ResourceSelectorKind.ResourceLocation, -In = -{ -"eastus2euap","centraluseuap" -}, -} -}, -} -}, +In = {"eastus2euap", "centraluseuap"}, +}}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyAssignmentName, data); PolicyAssignmentResource result = lro.Value; @@ -373,35 +324,31 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyAssignmentWithoutEnforcing // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentData data = new PolicyAssignmentData() + PolicyAssignmentData data = new PolicyAssignmentData { DisplayName = "Enforce resource naming rules", PolicyDefinitionId = "/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming", Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"DeptA\""), +Value = BinaryData.FromObjectAsJson("DeptA"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, +Value = BinaryData.FromObjectAsJson("-LC"), +} }, Description = "Force resource names to begin with given DeptA and end with -LC", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["assignedBy"] = "Special Someone" + assignedBy = "Special Someone", }), EnforcementMode = EnforcementMode.DoNotEnforce, }; @@ -427,13 +374,9 @@ public async Task Get_RetrieveAPolicyAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "EnforceNaming"; @@ -448,9 +391,9 @@ public async Task Get_RetrieveAPolicyAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveAPolicyAssignment() + public async Task Get_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -458,26 +401,26 @@ public async Task Exists_RetrieveAPolicyAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "EnforceNaming"; - bool result = await collection.ExistsAsync(policyAssignmentName); + PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAPolicyAssignment() + public async Task Get_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -485,38 +428,26 @@ public async Task GetIfExists_RetrieveAPolicyAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "EnforceNaming"; - NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); - PolicyAssignmentResource result = response.HasValue ? response.Value : null; + PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() + public async Task Get_RetrieveAPolicyAssignmentWithOverrides() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -524,16 +455,12 @@ public async Task Get_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation - string policyAssignmentName = "EnforceNaming"; + string policyAssignmentName = "CostManagement"; PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); // the variable result is a resource, you could call other operations on this instance as well @@ -545,9 +472,9 @@ public async Task Get_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() + public async Task Get_RetrieveAPolicyAssignmentWithResourceSelectors() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -555,162 +482,155 @@ public async Task Exists_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation - string policyAssignmentName = "EnforceNaming"; - bool result = await collection.ExistsAsync(policyAssignmentName); + string policyAssignmentName = "CostManagement"; + PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() + public async Task GetAll_ListPolicyAssignmentsThatApplyToAResourceGroup() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json - // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForResourceGroup.json + // this example is just showing the usage of "PolicyAssignments_ListForResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); - PolicyAssignmentResource result = response.HasValue ? response.Value : null; + string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + string resourceGroupName = "TestResourceGroup"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}"; + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string filter = "atScope()"; + await foreach (PolicyAssignmentResource item in collection.GetAllAsync(filter: filter)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = result.Data; + PolicyAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() + public async Task GetAll_ListAllPolicyAssignmentsThatApplyToAResource() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json - // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForResource.json + // this example is just showing the usage of "PolicyAssignments_ListForResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + string resourceGroupName = "TestResourceGroup"; + string resourceProviderNamespace = "Microsoft.Compute"; + string parentResourcePath = "virtualMachines/MyTestVm"; + string resourceType = "domainNames"; + string resourceName = "MyTestComputer.cloudapp.net"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}"; + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); + // invoke the operation and iterate over the result + await foreach (PolicyAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() + public async Task GetAll_ListPolicyAssignmentsThatApplyToAManagementGroup() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json - // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForManagementGroup.json + // this example is just showing the usage of "PolicyAssignments_ListForManagementGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + string managementGroupId = "TestManagementGroup"; + string scope = $"/providers/Microsoft.Management/managementGroups/{managementGroupId}"; + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - bool result = await collection.ExistsAsync(policyAssignmentName); + // invoke the operation and iterate over the result + string filter = "atScope()"; + await foreach (PolicyAssignmentResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() + public async Task GetAll_ListPolicyAssignmentsThatApplyToASubscription() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json - // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignments.json + // this example is just showing the usage of "PolicyAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource - string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); - - // invoke the operation - string policyAssignmentName = "EnforceNaming"; - NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); - PolicyAssignmentResource result = response.HasValue ? response.Value : null; + string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + string scope = $"/subscriptions/{subscriptionId}"; + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string filter = "atScope()"; + await foreach (PolicyAssignmentResource item in collection.GetAllAsync(filter: filter)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = result.Data; + PolicyAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyAssignmentWithOverrides() + public async Task Exists_RetrieveAPolicyAssignment() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -718,30 +638,22 @@ public async Task Get_RetrieveAPolicyAssignmentWithOverrides() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation - string policyAssignmentName = "CostManagement"; - PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); + string policyAssignmentName = "EnforceNaming"; + bool result = await collection.ExistsAsync(policyAssignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveAPolicyAssignmentWithOverrides() + public async Task Exists_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -749,16 +661,12 @@ public async Task Exists_RetrieveAPolicyAssignmentWithOverrides() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation - string policyAssignmentName = "CostManagement"; + string policyAssignmentName = "EnforceNaming"; bool result = await collection.ExistsAsync(policyAssignmentName); Console.WriteLine($"Succeeded: {result}"); @@ -766,9 +674,9 @@ public async Task Exists_RetrieveAPolicyAssignmentWithOverrides() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAPolicyAssignmentWithOverrides() + public async Task Exists_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -776,38 +684,22 @@ public async Task GetIfExists_RetrieveAPolicyAssignmentWithOverrides() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation - string policyAssignmentName = "CostManagement"; - NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); - PolicyAssignmentResource result = response.HasValue ? response.Value : null; + string policyAssignmentName = "EnforceNaming"; + bool result = await collection.ExistsAsync(policyAssignmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyAssignmentWithResourceSelectors() + public async Task Exists_RetrieveAPolicyAssignmentWithOverrides() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -815,23 +707,15 @@ public async Task Get_RetrieveAPolicyAssignmentWithResourceSelectors() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "CostManagement"; - PolicyAssignmentResource result = await collection.GetAsync(policyAssignmentName); + bool result = await collection.ExistsAsync(policyAssignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -846,13 +730,9 @@ public async Task Exists_RetrieveAPolicyAssignmentWithResourceSelectors() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string policyAssignmentName = "CostManagement"; @@ -863,9 +743,9 @@ public async Task Exists_RetrieveAPolicyAssignmentWithResourceSelectors() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAPolicyAssignmentWithResourceSelectors() + public async Task GetIfExists_RetrieveAPolicyAssignment() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -873,16 +753,12 @@ public async Task GetIfExists_RetrieveAPolicyAssignmentWithResourceSelectors() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation - string policyAssignmentName = "CostManagement"; + string policyAssignmentName = "EnforceNaming"; NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); PolicyAssignmentResource result = response.HasValue ? response.Value : null; @@ -902,143 +778,142 @@ public async Task GetIfExists_RetrieveAPolicyAssignmentWithResourceSelectors() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPolicyAssignmentsThatApplyToAResourceGroup() + public async Task GetIfExists_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForResourceGroup.json - // this example is just showing the usage of "PolicyAssignments_ListForResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json + // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string resourceGroupName = "TestResourceGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}", subscriptionId, resourceGroupName)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - string filter = "atScope()"; - await foreach (PolicyAssignmentResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string policyAssignmentName = "EnforceNaming"; + NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); + PolicyAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = item.Data; + PolicyAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllPolicyAssignmentsThatApplyToAResource() + public async Task GetIfExists_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForResource.json - // this example is just showing the usage of "PolicyAssignments_ListForResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json + // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string resourceGroupName = "TestResourceGroup"; - string resourceProviderNamespace = "Microsoft.Compute"; - string parentResourcePath = "virtualMachines/MyTestVm"; - string resourceType = "domainNames"; - string resourceName = "MyTestComputer.cloudapp.net"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/{2}/{3}/{4}/{5}", subscriptionId, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (PolicyAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string policyAssignmentName = "EnforceNaming"; + NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); + PolicyAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = item.Data; + PolicyAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPolicyAssignmentsThatApplyToAManagementGroup() + public async Task GetIfExists_RetrieveAPolicyAssignmentWithOverrides() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignmentsForManagementGroup.json - // this example is just showing the usage of "PolicyAssignments_ListForManagementGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json + // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource - string managementGroupId = "TestManagementGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/providers/Microsoft.Management/managementGroups/{0}", managementGroupId)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - string filter = "atScope()"; - await foreach (PolicyAssignmentResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string policyAssignmentName = "CostManagement"; + NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); + PolicyAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = item.Data; + PolicyAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPolicyAssignmentsThatApplyToASubscription() + public async Task GetIfExists_RetrieveAPolicyAssignmentWithResourceSelectors() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/listPolicyAssignments.json - // this example is just showing the usage of "PolicyAssignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json + // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this PolicyAssignmentResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}", subscriptionId)); - PolicyAssignmentCollection collection = client.GetGenericResource(scopeId).GetPolicyAssignments(); + string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + PolicyAssignmentCollection collection = client.GetPolicyAssignments(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - string filter = "atScope()"; - await foreach (PolicyAssignmentResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string policyAssignmentName = "CostManagement"; + NullableResponse response = await collection.GetIfExistsAsync(policyAssignmentName); + PolicyAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyAssignmentData resourceData = item.Data; + PolicyAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentResource.cs index a05d0a94cc31c..d3b4cb0920da8 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_PolicyAssignmentResource.cs @@ -19,10 +19,10 @@ public partial class Sample_PolicyAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPolicyAssignment() + public async Task Get_RetrieveAPolicyAssignment() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/deletePolicyAssignment.json - // this example is just showing the usage of "PolicyAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json + // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,8 +37,7 @@ public async Task Delete_DeleteAPolicyAssignment() PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); // invoke the operation - ArmOperation lro = await policyAssignment.DeleteAsync(WaitUntil.Completed); - PolicyAssignmentResource result = lro.Value; + PolicyAssignmentResource result = await policyAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,9 +48,9 @@ public async Task Delete_DeleteAPolicyAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyAssignment() + public async Task Get_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignment.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -78,9 +77,9 @@ public async Task Get_RetrieveAPolicyAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() + public async Task Get_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithIdentity.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -107,9 +106,9 @@ public async Task Get_RetrieveAPolicyAssignmentWithASystemAssignedIdentity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() + public async Task Get_RetrieveAPolicyAssignmentWithOverrides() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithUserAssignedIdentity.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -120,7 +119,7 @@ public async Task Get_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() // this example assumes you already have this PolicyAssignmentResource created on azure // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "EnforceNaming"; + string policyAssignmentName = "CostManagement"; ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); @@ -136,9 +135,9 @@ public async Task Get_RetrieveAPolicyAssignmentWithAUserAssignedIdentity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyAssignmentWithOverrides() + public async Task Get_RetrieveAPolicyAssignmentWithResourceSelectors() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithOverrides.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -165,10 +164,10 @@ public async Task Get_RetrieveAPolicyAssignmentWithOverrides() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyAssignmentWithResourceSelectors() + public async Task Delete_DeleteAPolicyAssignment() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/getPolicyAssignmentWithResourceSelectors.json - // this example is just showing the usage of "PolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2022-06-01/examples/deletePolicyAssignment.json + // this example is just showing the usage of "PolicyAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,12 +177,13 @@ public async Task Get_RetrieveAPolicyAssignmentWithResourceSelectors() // this example assumes you already have this PolicyAssignmentResource created on azure // for more information of creating PolicyAssignmentResource, please refer to the document of PolicyAssignmentResource string scope = "subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyAssignmentName = "CostManagement"; + string policyAssignmentName = "EnforceNaming"; ResourceIdentifier policyAssignmentResourceId = PolicyAssignmentResource.CreateResourceIdentifier(scope, policyAssignmentName); PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); // invoke the operation - PolicyAssignmentResource result = await policyAssignment.GetAsync(); + ArmOperation lro = await policyAssignment.DeleteAsync(WaitUntil.Completed); + PolicyAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -212,7 +212,7 @@ public async Task Update_UpdateAPolicyAssignmentWithASystemAssignedIdentity() PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); // invoke the operation - PolicyAssignmentPatch patch = new PolicyAssignmentPatch() + PolicyAssignmentPatch patch = new PolicyAssignmentPatch { Location = new AzureLocation("eastus"), Identity = new ManagedServiceIdentity("SystemAssigned"), @@ -246,14 +246,14 @@ public async Task Update_UpdateAPolicyAssignmentWithAUserAssignedIdentity() PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); // invoke the operation - PolicyAssignmentPatch patch = new PolicyAssignmentPatch() + PolicyAssignmentPatch patch = new PolicyAssignmentPatch { Location = new AzureLocation("eastus"), Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/resourceGroups/testResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity() }, }, }; @@ -286,27 +286,18 @@ public async Task Update_UpdateAPolicyAssignmentWithOverrides() PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); // invoke the operation - PolicyAssignmentPatch patch = new PolicyAssignmentPatch() + PolicyAssignmentPatch patch = new PolicyAssignmentPatch { - Overrides = -{ -new PolicyOverride() + Overrides = {new PolicyOverride { Kind = PolicyOverrideKind.PolicyEffect, Value = "Audit", -Selectors = -{ -new ResourceSelectorExpression() +Selectors = {new ResourceSelectorExpression { Kind = ResourceSelectorKind.PolicyDefinitionReferenceId, -In = -{ -"Limit_Skus","Limit_Locations" -}, -} -}, -} -}, +In = {"Limit_Skus", "Limit_Locations"}, +}}, +}}, }; PolicyAssignmentResource result = await policyAssignment.UpdateAsync(patch); @@ -337,26 +328,17 @@ public async Task Update_UpdateAPolicyAssignmentWithResourceSelectors() PolicyAssignmentResource policyAssignment = client.GetPolicyAssignmentResource(policyAssignmentResourceId); // invoke the operation - PolicyAssignmentPatch patch = new PolicyAssignmentPatch() + PolicyAssignmentPatch patch = new PolicyAssignmentPatch { - ResourceSelectors = -{ -new ResourceSelector() + ResourceSelectors = {new ResourceSelector { Name = "SDPRegions", -Selectors = -{ -new ResourceSelectorExpression() +Selectors = {new ResourceSelectorExpression { Kind = ResourceSelectorKind.ResourceLocation, -In = -{ -"eastus2euap","centraluseuap" -}, -} -}, -} -}, +In = {"eastus2euap", "centraluseuap"}, +}}, +}}, }; PolicyAssignmentResource result = await policyAssignment.UpdateAsync(patch); diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceGroupResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceGroupResource.cs index 1a2854ea54a34..4bc33ecb36b77 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceGroupResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceGroupResource.cs @@ -88,12 +88,9 @@ public async Task ExportTemplate_ExportAResourceGroup() ResourceGroupResource resourceGroup = client.GetResourceGroupResource(resourceGroupResourceId); // invoke the operation - ExportTemplate exportTemplate = new ExportTemplate() + ExportTemplate exportTemplate = new ExportTemplate { - Resources = -{ -"*" -}, + Resources = { "*" }, Options = "IncludeParameterDefaultValue,IncludeComments", }; ArmOperation lro = await resourceGroup.ExportTemplateAsync(WaitUntil.Completed, exportTemplate); @@ -122,12 +119,9 @@ public async Task ExportTemplate_ExportAResourceGroupWithFiltering() ResourceGroupResource resourceGroup = client.GetResourceGroupResource(resourceGroupResourceId); // invoke the operation - ExportTemplate exportTemplate = new ExportTemplate() + ExportTemplate exportTemplate = new ExportTemplate { - Resources = -{ -"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource" -}, + Resources = { "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/My.RP/myResourceType/myFirstResource" }, Options = "SkipResourceNameParameterization", }; ArmOperation lro = await resourceGroup.ExportTemplateAsync(WaitUntil.Completed, exportTemplate); diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderCollection.cs index 929512c91d758..7627aca74d405 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ResourceProviderCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetProviders() + public async Task Get_GetProvider() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProviders.json - // this example is just showing the usage of "Providers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProvider.json + // this example is just showing the usage of "Providers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,25 +36,23 @@ public async Task GetAll_GetProviders() // get the collection of this ResourceProviderResource ResourceProviderCollection collection = subscription.GetResourceProviders(); - // invoke the operation and iterate over the result - await foreach (ResourceProviderResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceProviderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string resourceProviderNamespace = "Microsoft.TestRP1"; + ResourceProviderResource result = await collection.GetAsync(resourceProviderNamespace); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetProvider() + public async Task GetAll_GetProviders() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProvider.json - // this example is just showing the usage of "Providers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProviders.json + // this example is just showing the usage of "Providers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,15 +68,17 @@ public async Task Get_GetProvider() // get the collection of this ResourceProviderResource ResourceProviderCollection collection = subscription.GetResourceProviders(); - // invoke the operation - string resourceProviderNamespace = "Microsoft.TestRP1"; - ResourceProviderResource result = await collection.GetAsync(resourceProviderNamespace); + // invoke the operation and iterate over the result + await foreach (ResourceProviderResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceProviderData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderResource.cs index cc8cabedbffa6..3dd96bd18cd69 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_ResourceProviderResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ResourceProviderResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task ProviderPermissions_GetProviderResourceTypes() + public async Task Get_GetProvider() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProviderPermissions.json - // this example is just showing the usage of "Providers_ProviderPermissions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProvider.json + // this example is just showing the usage of "Providers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,25 +31,26 @@ public async Task ProviderPermissions_GetProviderResourceTypes() // this example assumes you already have this ResourceProviderResource created on azure // for more information of creating ResourceProviderResource, please refer to the document of ResourceProviderResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceProviderNamespace = "Microsoft.TestRP"; + string resourceProviderNamespace = "Microsoft.TestRP1"; ResourceIdentifier resourceProviderResourceId = ResourceProviderResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace); ResourceProviderResource resourceProvider = client.GetResourceProviderResource(resourceProviderResourceId); - // invoke the operation and iterate over the result - await foreach (ProviderPermission item in resourceProvider.ProviderPermissionsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + ResourceProviderResource result = await resourceProvider.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetProvider() + public async Task ProviderPermissions_GetProviderResourceTypes() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProvider.json - // this example is just showing the usage of "Providers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetProviderPermissions.json + // this example is just showing the usage of "Providers_ProviderPermissions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,18 +60,17 @@ public async Task Get_GetProvider() // this example assumes you already have this ResourceProviderResource created on azure // for more information of creating ResourceProviderResource, please refer to the document of ResourceProviderResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceProviderNamespace = "Microsoft.TestRP1"; + string resourceProviderNamespace = "Microsoft.TestRP"; ResourceIdentifier resourceProviderResourceId = ResourceProviderResource.CreateResourceIdentifier(subscriptionId, resourceProviderNamespace); ResourceProviderResource resourceProvider = client.GetResourceProviderResource(resourceProviderResourceId); - // invoke the operation - ResourceProviderResource result = await resourceProvider.GetAsync(); + // invoke the operation and iterate over the result + await foreach (ProviderPermission item in resourceProvider.ProviderPermissionsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionCollection.cs index 701adba965fe1..53c68242a205e 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionCollection.cs @@ -27,9 +27,7 @@ public async Task Get_GetASingleSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SubscriptionResource SubscriptionCollection collection = tenant.GetSubscriptions(); @@ -45,6 +43,36 @@ public async Task Get_GetASingleSubscription() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetAllSubscriptions() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscriptions.json + // this example is just showing the usage of "Subscriptions_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this SubscriptionResource + SubscriptionCollection collection = tenant.GetSubscriptions(); + + // invoke the operation and iterate over the result + await foreach (SubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetASingleSubscription() @@ -57,9 +85,7 @@ public async Task Exists_GetASingleSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SubscriptionResource SubscriptionCollection collection = tenant.GetSubscriptions(); @@ -83,9 +109,7 @@ public async Task GetIfExists_GetASingleSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SubscriptionResource SubscriptionCollection collection = tenant.GetSubscriptions(); @@ -108,37 +132,5 @@ public async Task GetIfExists_GetASingleSubscription() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllSubscriptions() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscriptions.json - // this example is just showing the usage of "Subscriptions_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this SubscriptionResource - SubscriptionCollection collection = tenant.GetSubscriptions(); - - // invoke the operation and iterate over the result - await foreach (SubscriptionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionCollection.cs index c7522142fd4d6..57562487b47aa 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionCollection.cs @@ -40,50 +40,50 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyDefinition() // invoke the operation string policyDefinitionName = "ResourceNaming"; - PolicyDefinitionData data = new PolicyDefinitionData() + PolicyDefinitionData data = new PolicyDefinitionData { Mode = "All", DisplayName = "Enforce resource naming convention", Description = "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() + PolicyRule = BinaryData.FromObjectAsJson(new Dictionary { - ["if"] = new Dictionary() + ["if"] = new { - ["not"] = new Dictionary() + not = new { - ["field"] = "name", - ["like"] = "[concat(parameters('prefix'), '*', parameters('suffix'))]" - } + field = "name", + like = "[concat(parameters('prefix'), '*', parameters('suffix'))]", + }, }, - ["then"] = new Dictionary() + ["then"] = new { - ["effect"] = "deny" + effect = "deny", } }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Naming" + category = "Naming", }), Parameters = { -["prefix"] = new ArmPolicyParameter() +["prefix"] = new ArmPolicyParameter { ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() +Metadata = new ParameterDefinitionsValueMetadata { DisplayName = "Prefix", Description = "Resource name prefix", }, }, -["suffix"] = new ArmPolicyParameter() +["suffix"] = new ArmPolicyParameter { ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() +Metadata = new ParameterDefinitionsValueMetadata { DisplayName = "Suffix", Description = "Resource name suffix", }, -}, +} }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyDefinitionName, data); @@ -119,57 +119,60 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicyDefinitionWithAdvancedPara // invoke the operation string policyDefinitionName = "EventHubDiagnosticLogs"; - PolicyDefinitionData data = new PolicyDefinitionData() + PolicyDefinitionData data = new PolicyDefinitionData { Mode = "Indexed", DisplayName = "Event Hubs should have diagnostic logging enabled", Description = "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", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() + PolicyRule = BinaryData.FromObjectAsJson(new Dictionary { - ["if"] = new Dictionary() + ["if"] = new { - ["equals"] = "Microsoft.EventHub/namespaces", - ["field"] = "type" + equals = "Microsoft.EventHub/namespaces", + field = "type", }, - ["then"] = new Dictionary() + ["then"] = new { - ["effect"] = "AuditIfNotExists", - ["details"] = new Dictionary() + effect = "AuditIfNotExists", + details = new { - ["type"] = "Microsoft.Insights/diagnosticSettings", - ["existenceCondition"] = new Dictionary() + type = "Microsoft.Insights/diagnosticSettings", + existenceCondition = new { - ["allOf"] = new object[] { new Dictionary() + allOf = new object[] + { +new { -["equals"] = "true", -["field"] = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled"}, new Dictionary() +equals = "true", +field = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", +}, +new { -["equals"] = "[parameters('requiredRetentionDays')]", -["field"] = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days"} } - } - } +equals = "[parameters('requiredRetentionDays')]", +field = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", +} + }, + }, + }, } }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Event Hub" + category = "Event Hub", }), Parameters = { -["requiredRetentionDays"] = new ArmPolicyParameter() +["requiredRetentionDays"] = new ArmPolicyParameter { ParameterType = ArmPolicyParameterType.Integer, -AllowedValues = -{ -BinaryData.FromString("\"0\""),BinaryData.FromString("\"30\""),BinaryData.FromString("\"90\""),BinaryData.FromString("\"180\""),BinaryData.FromString("\"365\"") -}, -DefaultValue = BinaryData.FromString("\"365\""), -Metadata = new ParameterDefinitionsValueMetadata() +AllowedValues = {BinaryData.FromObjectAsJson("0"), BinaryData.FromObjectAsJson("30"), BinaryData.FromObjectAsJson("90"), BinaryData.FromObjectAsJson("180"), BinaryData.FromObjectAsJson("365")}, +DefaultValue = BinaryData.FromObjectAsJson("365"), +Metadata = new ParameterDefinitionsValueMetadata { DisplayName = "Required retention (days)", Description = "The required diagnostic logs retention in days", }, -}, +} }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyDefinitionName, data); @@ -216,10 +219,10 @@ public async Task Get_RetrieveAPolicyDefinition() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveAPolicyDefinition() + public async Task GetAll_ListPolicyDefinitionsBySubscription() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitions.json + // this example is just showing the usage of "PolicyDefinitions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -235,16 +238,22 @@ public async Task Exists_RetrieveAPolicyDefinition() // get the collection of this SubscriptionPolicyDefinitionResource SubscriptionPolicyDefinitionCollection collection = subscription.GetSubscriptionPolicyDefinitions(); - // invoke the operation - string policyDefinitionName = "ResourceNaming"; - bool result = await collection.ExistsAsync(policyDefinitionName); + // invoke the operation and iterate over the result + await foreach (SubscriptionPolicyDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAPolicyDefinition() + public async Task Exists_RetrieveAPolicyDefinition() { // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json // this example is just showing the usage of "PolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. @@ -265,29 +274,17 @@ public async Task GetIfExists_RetrieveAPolicyDefinition() // invoke the operation string policyDefinitionName = "ResourceNaming"; - NullableResponse response = await collection.GetIfExistsAsync(policyDefinitionName); - SubscriptionPolicyDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPolicyDefinitionsBySubscription() + public async Task GetIfExists_RetrieveAPolicyDefinition() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicyDefinitions.json - // this example is just showing the usage of "PolicyDefinitions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json + // this example is just showing the usage of "PolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -303,17 +300,23 @@ public async Task GetAll_ListPolicyDefinitionsBySubscription() // get the collection of this SubscriptionPolicyDefinitionResource SubscriptionPolicyDefinitionCollection collection = subscription.GetSubscriptionPolicyDefinitions(); - // invoke the operation and iterate over the result - await foreach (SubscriptionPolicyDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string policyDefinitionName = "ResourceNaming"; + NullableResponse response = await collection.GetIfExistsAsync(policyDefinitionName); + SubscriptionPolicyDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyDefinitionData resourceData = item.Data; + PolicyDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionResource.cs index d4c9bae57421c..baad6dbe0568c 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicyDefinitionResource.cs @@ -17,6 +17,60 @@ namespace Azure.ResourceManager.Resources.Samples { public partial class Sample_SubscriptionPolicyDefinitionResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_RetrieveAPolicyDefinition() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json + // this example is just showing the usage of "PolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionPolicyDefinitionResource created on azure + // for more information of creating SubscriptionPolicyDefinitionResource, please refer to the document of SubscriptionPolicyDefinitionResource + string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + string policyDefinitionName = "ResourceNaming"; + ResourceIdentifier subscriptionPolicyDefinitionResourceId = SubscriptionPolicyDefinitionResource.CreateResourceIdentifier(subscriptionId, policyDefinitionName); + SubscriptionPolicyDefinitionResource subscriptionPolicyDefinition = client.GetSubscriptionPolicyDefinitionResource(subscriptionPolicyDefinitionResourceId); + + // invoke the operation + SubscriptionPolicyDefinitionResource result = await subscriptionPolicyDefinition.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAPolicyDefinition() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinition.json + // this example is just showing the usage of "PolicyDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionPolicyDefinitionResource created on azure + // for more information of creating SubscriptionPolicyDefinitionResource, please refer to the document of SubscriptionPolicyDefinitionResource + string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + string policyDefinitionName = "ResourceNaming"; + ResourceIdentifier subscriptionPolicyDefinitionResourceId = SubscriptionPolicyDefinitionResource.CreateResourceIdentifier(subscriptionId, policyDefinitionName); + SubscriptionPolicyDefinitionResource subscriptionPolicyDefinition = client.GetSubscriptionPolicyDefinitionResource(subscriptionPolicyDefinitionResourceId); + + // invoke the operation + await subscriptionPolicyDefinition.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateAPolicyDefinition() @@ -37,50 +91,50 @@ public async Task Update_CreateOrUpdateAPolicyDefinition() SubscriptionPolicyDefinitionResource subscriptionPolicyDefinition = client.GetSubscriptionPolicyDefinitionResource(subscriptionPolicyDefinitionResourceId); // invoke the operation - PolicyDefinitionData data = new PolicyDefinitionData() + PolicyDefinitionData data = new PolicyDefinitionData { Mode = "All", DisplayName = "Enforce resource naming convention", Description = "Force resource names to begin with given 'prefix' and/or end with given 'suffix'", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() + PolicyRule = BinaryData.FromObjectAsJson(new Dictionary { - ["if"] = new Dictionary() + ["if"] = new { - ["not"] = new Dictionary() + not = new { - ["field"] = "name", - ["like"] = "[concat(parameters('prefix'), '*', parameters('suffix'))]" - } + field = "name", + like = "[concat(parameters('prefix'), '*', parameters('suffix'))]", + }, }, - ["then"] = new Dictionary() + ["then"] = new { - ["effect"] = "deny" + effect = "deny", } }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Naming" + category = "Naming", }), Parameters = { -["prefix"] = new ArmPolicyParameter() +["prefix"] = new ArmPolicyParameter { ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() +Metadata = new ParameterDefinitionsValueMetadata { DisplayName = "Prefix", Description = "Resource name prefix", }, }, -["suffix"] = new ArmPolicyParameter() +["suffix"] = new ArmPolicyParameter { ParameterType = ArmPolicyParameterType.String, -Metadata = new ParameterDefinitionsValueMetadata() +Metadata = new ParameterDefinitionsValueMetadata { DisplayName = "Suffix", Description = "Resource name suffix", }, -}, +} }, }; ArmOperation lro = await subscriptionPolicyDefinition.UpdateAsync(WaitUntil.Completed, data); @@ -113,57 +167,60 @@ public async Task Update_CreateOrUpdateAPolicyDefinitionWithAdvancedParameters() SubscriptionPolicyDefinitionResource subscriptionPolicyDefinition = client.GetSubscriptionPolicyDefinitionResource(subscriptionPolicyDefinitionResourceId); // invoke the operation - PolicyDefinitionData data = new PolicyDefinitionData() + PolicyDefinitionData data = new PolicyDefinitionData { Mode = "Indexed", DisplayName = "Event Hubs should have diagnostic logging enabled", Description = "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", - PolicyRule = BinaryData.FromObjectAsJson(new Dictionary() + PolicyRule = BinaryData.FromObjectAsJson(new Dictionary { - ["if"] = new Dictionary() + ["if"] = new { - ["equals"] = "Microsoft.EventHub/namespaces", - ["field"] = "type" + equals = "Microsoft.EventHub/namespaces", + field = "type", }, - ["then"] = new Dictionary() + ["then"] = new { - ["effect"] = "AuditIfNotExists", - ["details"] = new Dictionary() + effect = "AuditIfNotExists", + details = new { - ["type"] = "Microsoft.Insights/diagnosticSettings", - ["existenceCondition"] = new Dictionary() + type = "Microsoft.Insights/diagnosticSettings", + existenceCondition = new { - ["allOf"] = new object[] { new Dictionary() + allOf = new object[] + { +new { -["equals"] = "true", -["field"] = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled"}, new Dictionary() +equals = "true", +field = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.enabled", +}, +new { -["equals"] = "[parameters('requiredRetentionDays')]", -["field"] = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days"} } - } - } +equals = "[parameters('requiredRetentionDays')]", +field = "Microsoft.Insights/diagnosticSettings/logs[*].retentionPolicy.days", +} + }, + }, + }, } }), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Event Hub" + category = "Event Hub", }), Parameters = { -["requiredRetentionDays"] = new ArmPolicyParameter() +["requiredRetentionDays"] = new ArmPolicyParameter { ParameterType = ArmPolicyParameterType.Integer, -AllowedValues = -{ -BinaryData.FromString("\"0\""),BinaryData.FromString("\"30\""),BinaryData.FromString("\"90\""),BinaryData.FromString("\"180\""),BinaryData.FromString("\"365\"") -}, -DefaultValue = BinaryData.FromString("\"365\""), -Metadata = new ParameterDefinitionsValueMetadata() +AllowedValues = {BinaryData.FromObjectAsJson("0"), BinaryData.FromObjectAsJson("30"), BinaryData.FromObjectAsJson("90"), BinaryData.FromObjectAsJson("180"), BinaryData.FromObjectAsJson("365")}, +DefaultValue = BinaryData.FromObjectAsJson("365"), +Metadata = new ParameterDefinitionsValueMetadata { DisplayName = "Required retention (days)", Description = "The required diagnostic logs retention in days", }, -}, +} }, }; ArmOperation lro = await subscriptionPolicyDefinition.UpdateAsync(WaitUntil.Completed, data); @@ -175,59 +232,5 @@ public async Task Update_CreateOrUpdateAPolicyDefinitionWithAdvancedParameters() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionPolicyDefinitionResource created on azure - // for more information of creating SubscriptionPolicyDefinitionResource, please refer to the document of SubscriptionPolicyDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyDefinitionName = "ResourceNaming"; - ResourceIdentifier subscriptionPolicyDefinitionResourceId = SubscriptionPolicyDefinitionResource.CreateResourceIdentifier(subscriptionId, policyDefinitionName); - SubscriptionPolicyDefinitionResource subscriptionPolicyDefinition = client.GetSubscriptionPolicyDefinitionResource(subscriptionPolicyDefinitionResourceId); - - // invoke the operation - await subscriptionPolicyDefinition.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicyDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicyDefinition.json - // this example is just showing the usage of "PolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionPolicyDefinitionResource created on azure - // for more information of creating SubscriptionPolicyDefinitionResource, please refer to the document of SubscriptionPolicyDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policyDefinitionName = "ResourceNaming"; - ResourceIdentifier subscriptionPolicyDefinitionResourceId = SubscriptionPolicyDefinitionResource.CreateResourceIdentifier(subscriptionId, policyDefinitionName); - SubscriptionPolicyDefinitionResource subscriptionPolicyDefinition = client.GetSubscriptionPolicyDefinitionResource(subscriptionPolicyDefinitionResourceId); - - // invoke the operation - SubscriptionPolicyDefinitionResource result = await subscriptionPolicyDefinition.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionCollection.cs index f47ece8defeb5..69f2b604e12aa 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -40,54 +39,55 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicySetDefinition() // invoke the operation string policySetDefinitionName = "CostManagement"; - PolicySetDefinitionData data = new PolicySetDefinitionData() + PolicySetDefinitionData data = new PolicySetDefinitionData { DisplayName = "Cost Management", Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Cost Management" + category = "Cost Management", }), Parameters = { -["namePrefix"] = new ArmPolicyParameter() +["namePrefix"] = new ArmPolicyParameter { ParameterType = ArmPolicyParameterType.String, -DefaultValue = BinaryData.FromString("\"myPrefix\""), -Metadata = new ParameterDefinitionsValueMetadata() +DefaultValue = BinaryData.FromObjectAsJson("myPrefix"), +Metadata = new ParameterDefinitionsValueMetadata { DisplayName = "Prefix to enforce on resource names", }, +} }, -}, - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + PolicyDefinitions = {new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") { Parameters = { -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() +["listOfAllowedSKUs"] = new ArmPolicyParameterValue { -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, +Value = BinaryData.FromObjectAsJson(new object[] +{ +"Standard_GRS", +"Standard_LRS" +}), +} }, PolicyDefinitionReferenceId = "Limit_Skus", -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") +}, new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") { Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"[parameters('namePrefix')]\""), +Value = BinaryData.FromObjectAsJson("[parameters('namePrefix')]"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", +Value = BinaryData.FromObjectAsJson("-LC"), } }, +PolicyDefinitionReferenceId = "Resource_Naming", +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policySetDefinitionName, data); SubscriptionPolicySetDefinitionResource result = lro.Value; @@ -122,62 +122,54 @@ public async Task CreateOrUpdate_CreateOrUpdateAPolicySetDefinitionWithGroups() // invoke the operation string policySetDefinitionName = "CostManagement"; - PolicySetDefinitionData data = new PolicySetDefinitionData() + PolicySetDefinitionData data = new PolicySetDefinitionData { DisplayName = "Cost Management", Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Cost Management" + category = "Cost Management", }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + PolicyDefinitions = {new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") { Parameters = { -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() +["listOfAllowedSKUs"] = new ArmPolicyParameterValue { -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -GroupNames = +Value = BinaryData.FromObjectAsJson(new object[] { -"CostSaving" +"Standard_GRS", +"Standard_LRS" +}), +} }, -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") +PolicyDefinitionReferenceId = "Limit_Skus", +GroupNames = {"CostSaving"}, +}, new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") { Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"DeptA\""), +Value = BinaryData.FromObjectAsJson("DeptA"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -GroupNames = -{ -"Organizational" -}, +Value = BinaryData.FromObjectAsJson("-LC"), } }, - PolicyDefinitionGroups = -{ -new PolicyDefinitionGroup("CostSaving") +PolicyDefinitionReferenceId = "Resource_Naming", +GroupNames = {"Organizational"}, +}}, + PolicyDefinitionGroups = {new PolicyDefinitionGroup("CostSaving") { DisplayName = "Cost Management Policies", Description = "Policies designed to control spend within a subscription.", -},new PolicyDefinitionGroup("Organizational") +}, new PolicyDefinitionGroup("Organizational") { DisplayName = "Organizational Policies", Description = "Policies that help enforce resource organization standards within a subscription.", -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policySetDefinitionName, data); SubscriptionPolicySetDefinitionResource result = lro.Value; @@ -223,10 +215,10 @@ public async Task Get_RetrieveAPolicySetDefinition() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveAPolicySetDefinition() + public async Task GetAll_ListPolicySetDefinitions() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitions.json + // this example is just showing the usage of "PolicySetDefinitions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -242,16 +234,22 @@ public async Task Exists_RetrieveAPolicySetDefinition() // get the collection of this SubscriptionPolicySetDefinitionResource SubscriptionPolicySetDefinitionCollection collection = subscription.GetSubscriptionPolicySetDefinitions(); - // invoke the operation - string policySetDefinitionName = "CostManagement"; - bool result = await collection.ExistsAsync(policySetDefinitionName); + // invoke the operation and iterate over the result + await foreach (SubscriptionPolicySetDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicySetDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAPolicySetDefinition() + public async Task Exists_RetrieveAPolicySetDefinition() { // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json // this example is just showing the usage of "PolicySetDefinitions_Get" operation, for the dependent resources, they will have to be created separately. @@ -272,29 +270,17 @@ public async Task GetIfExists_RetrieveAPolicySetDefinition() // invoke the operation string policySetDefinitionName = "CostManagement"; - NullableResponse response = await collection.GetIfExistsAsync(policySetDefinitionName); - SubscriptionPolicySetDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policySetDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPolicySetDefinitions() + public async Task GetIfExists_RetrieveAPolicySetDefinition() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listPolicySetDefinitions.json - // this example is just showing the usage of "PolicySetDefinitions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json + // this example is just showing the usage of "PolicySetDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -310,17 +296,23 @@ public async Task GetAll_ListPolicySetDefinitions() // get the collection of this SubscriptionPolicySetDefinitionResource SubscriptionPolicySetDefinitionCollection collection = subscription.GetSubscriptionPolicySetDefinitions(); - // invoke the operation and iterate over the result - await foreach (SubscriptionPolicySetDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string policySetDefinitionName = "CostManagement"; + NullableResponse response = await collection.GetIfExistsAsync(policySetDefinitionName); + SubscriptionPolicySetDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicySetDefinitionData resourceData = item.Data; + PolicySetDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionResource.cs index 447038b76ad54..e31331ffd6578 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionPolicySetDefinitionResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -17,6 +16,60 @@ namespace Azure.ResourceManager.Resources.Samples { public partial class Sample_SubscriptionPolicySetDefinitionResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_RetrieveAPolicySetDefinition() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json + // this example is just showing the usage of "PolicySetDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionPolicySetDefinitionResource created on azure + // for more information of creating SubscriptionPolicySetDefinitionResource, please refer to the document of SubscriptionPolicySetDefinitionResource + string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + string policySetDefinitionName = "CostManagement"; + ResourceIdentifier subscriptionPolicySetDefinitionResourceId = SubscriptionPolicySetDefinitionResource.CreateResourceIdentifier(subscriptionId, policySetDefinitionName); + SubscriptionPolicySetDefinitionResource subscriptionPolicySetDefinition = client.GetSubscriptionPolicySetDefinitionResource(subscriptionPolicySetDefinitionResourceId); + + // invoke the operation + SubscriptionPolicySetDefinitionResource result = await subscriptionPolicySetDefinition.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicySetDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAPolicySetDefinition() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinition.json + // this example is just showing the usage of "PolicySetDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionPolicySetDefinitionResource created on azure + // for more information of creating SubscriptionPolicySetDefinitionResource, please refer to the document of SubscriptionPolicySetDefinitionResource + string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; + string policySetDefinitionName = "CostManagement"; + ResourceIdentifier subscriptionPolicySetDefinitionResourceId = SubscriptionPolicySetDefinitionResource.CreateResourceIdentifier(subscriptionId, policySetDefinitionName); + SubscriptionPolicySetDefinitionResource subscriptionPolicySetDefinition = client.GetSubscriptionPolicySetDefinitionResource(subscriptionPolicySetDefinitionResourceId); + + // invoke the operation + await subscriptionPolicySetDefinition.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateAPolicySetDefinition() @@ -37,54 +90,55 @@ public async Task Update_CreateOrUpdateAPolicySetDefinition() SubscriptionPolicySetDefinitionResource subscriptionPolicySetDefinition = client.GetSubscriptionPolicySetDefinitionResource(subscriptionPolicySetDefinitionResourceId); // invoke the operation - PolicySetDefinitionData data = new PolicySetDefinitionData() + PolicySetDefinitionData data = new PolicySetDefinitionData { DisplayName = "Cost Management", Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Cost Management" + category = "Cost Management", }), Parameters = { -["namePrefix"] = new ArmPolicyParameter() +["namePrefix"] = new ArmPolicyParameter { ParameterType = ArmPolicyParameterType.String, -DefaultValue = BinaryData.FromString("\"myPrefix\""), -Metadata = new ParameterDefinitionsValueMetadata() +DefaultValue = BinaryData.FromObjectAsJson("myPrefix"), +Metadata = new ParameterDefinitionsValueMetadata { DisplayName = "Prefix to enforce on resource names", }, +} }, -}, - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + PolicyDefinitions = {new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") { Parameters = { -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() +["listOfAllowedSKUs"] = new ArmPolicyParameterValue { -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, +Value = BinaryData.FromObjectAsJson(new object[] +{ +"Standard_GRS", +"Standard_LRS" +}), +} }, PolicyDefinitionReferenceId = "Limit_Skus", -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") +}, new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") { Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"[parameters('namePrefix')]\""), +Value = BinaryData.FromObjectAsJson("[parameters('namePrefix')]"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", +Value = BinaryData.FromObjectAsJson("-LC"), } }, +PolicyDefinitionReferenceId = "Resource_Naming", +}}, }; ArmOperation lro = await subscriptionPolicySetDefinition.UpdateAsync(WaitUntil.Completed, data); SubscriptionPolicySetDefinitionResource result = lro.Value; @@ -116,62 +170,54 @@ public async Task Update_CreateOrUpdateAPolicySetDefinitionWithGroups() SubscriptionPolicySetDefinitionResource subscriptionPolicySetDefinition = client.GetSubscriptionPolicySetDefinitionResource(subscriptionPolicySetDefinitionResourceId); // invoke the operation - PolicySetDefinitionData data = new PolicySetDefinitionData() + PolicySetDefinitionData data = new PolicySetDefinitionData { DisplayName = "Cost Management", Description = "Policies to enforce low cost storage SKUs", - Metadata = BinaryData.FromObjectAsJson(new Dictionary() + Metadata = BinaryData.FromObjectAsJson(new { - ["category"] = "Cost Management" + category = "Cost Management", }), - PolicyDefinitions = -{ -new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") + PolicyDefinitions = {new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/7433c107-6db4-4ad1-b57a-a76dce0154a1") { Parameters = { -["listOfAllowedSKUs"] = new ArmPolicyParameterValue() +["listOfAllowedSKUs"] = new ArmPolicyParameterValue { -Value = BinaryData.FromObjectAsJson(new object[] { "Standard_GRS", "Standard_LRS" }), -}, -}, -PolicyDefinitionReferenceId = "Limit_Skus", -GroupNames = +Value = BinaryData.FromObjectAsJson(new object[] { -"CostSaving" +"Standard_GRS", +"Standard_LRS" +}), +} }, -},new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") +PolicyDefinitionReferenceId = "Limit_Skus", +GroupNames = {"CostSaving"}, +}, new PolicyDefinitionReference("/subscriptions/ae640e6b-ba3e-4256-9d62-2993eecfa6f2/providers/Microsoft.Authorization/policyDefinitions/ResourceNaming") { Parameters = { -["prefix"] = new ArmPolicyParameterValue() +["prefix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"DeptA\""), +Value = BinaryData.FromObjectAsJson("DeptA"), }, -["suffix"] = new ArmPolicyParameterValue() +["suffix"] = new ArmPolicyParameterValue { -Value = BinaryData.FromString("\"-LC\""), -}, -}, -PolicyDefinitionReferenceId = "Resource_Naming", -GroupNames = -{ -"Organizational" -}, +Value = BinaryData.FromObjectAsJson("-LC"), } }, - PolicyDefinitionGroups = -{ -new PolicyDefinitionGroup("CostSaving") +PolicyDefinitionReferenceId = "Resource_Naming", +GroupNames = {"Organizational"}, +}}, + PolicyDefinitionGroups = {new PolicyDefinitionGroup("CostSaving") { DisplayName = "Cost Management Policies", Description = "Policies designed to control spend within a subscription.", -},new PolicyDefinitionGroup("Organizational") +}, new PolicyDefinitionGroup("Organizational") { DisplayName = "Organizational Policies", Description = "Policies that help enforce resource organization standards within a subscription.", -} -}, +}}, }; ArmOperation lro = await subscriptionPolicySetDefinition.UpdateAsync(WaitUntil.Completed, data); SubscriptionPolicySetDefinitionResource result = lro.Value; @@ -182,59 +228,5 @@ public async Task Update_CreateOrUpdateAPolicySetDefinitionWithGroups() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/deletePolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionPolicySetDefinitionResource created on azure - // for more information of creating SubscriptionPolicySetDefinitionResource, please refer to the document of SubscriptionPolicySetDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier subscriptionPolicySetDefinitionResourceId = SubscriptionPolicySetDefinitionResource.CreateResourceIdentifier(subscriptionId, policySetDefinitionName); - SubscriptionPolicySetDefinitionResource subscriptionPolicySetDefinition = client.GetSubscriptionPolicySetDefinitionResource(subscriptionPolicySetDefinitionResourceId); - - // invoke the operation - await subscriptionPolicySetDefinition.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAPolicySetDefinition() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/getPolicySetDefinition.json - // this example is just showing the usage of "PolicySetDefinitions_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionPolicySetDefinitionResource created on azure - // for more information of creating SubscriptionPolicySetDefinitionResource, please refer to the document of SubscriptionPolicySetDefinitionResource - string subscriptionId = "ae640e6b-ba3e-4256-9d62-2993eecfa6f2"; - string policySetDefinitionName = "CostManagement"; - ResourceIdentifier subscriptionPolicySetDefinitionResourceId = SubscriptionPolicySetDefinitionResource.CreateResourceIdentifier(subscriptionId, policySetDefinitionName); - SubscriptionPolicySetDefinitionResource subscriptionPolicySetDefinition = client.GetSubscriptionPolicySetDefinitionResource(subscriptionPolicySetDefinitionResourceId); - - // invoke the operation - SubscriptionPolicySetDefinitionResource result = await subscriptionPolicySetDefinition.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicySetDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionResource.cs index 064f52c9795c3..16dca86e134bd 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_SubscriptionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SubscriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLocations_GetLocationsWithASubscriptionId() + public async Task Get_GetASingleSubscription() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocations.json - // this example is just showing the usage of "Subscriptions_ListLocations" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json + // this example is just showing the usage of "Subscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,24 +30,25 @@ public async Task GetLocations_GetLocationsWithASubscriptionId() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "a1ffc958-d2c7-493e-9f1e-125a0477f536"; + string subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - // invoke the operation and iterate over the result - await foreach (LocationExpanded item in subscription.GetLocationsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + SubscriptionResource result = await subscription.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLocations_GetLocationsWithExtendedLocations() + public async Task GetLocations_GetLocationsWithASubscriptionId() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocationsWithExtendedLocations.json + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocations.json // this example is just showing the usage of "Subscriptions_ListLocations" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -62,8 +63,7 @@ public async Task GetLocations_GetLocationsWithExtendedLocations() SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - bool? includeExtendedLocations = true; - await foreach (LocationExpanded item in subscription.GetLocationsAsync(includeExtendedLocations: includeExtendedLocations)) + await foreach (LocationExpanded item in subscription.GetLocationsAsync()) { Console.WriteLine($"Succeeded: {item}"); } @@ -73,10 +73,10 @@ public async Task GetLocations_GetLocationsWithExtendedLocations() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASingleSubscription() + public async Task GetLocations_GetLocationsWithExtendedLocations() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetSubscription.json - // this example is just showing the usage of "Subscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-12-01/examples/GetLocationsWithExtendedLocations.json + // this example is just showing the usage of "Subscriptions_ListLocations" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -85,18 +85,18 @@ public async Task Get_GetASingleSubscription() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; + string subscriptionId = "a1ffc958-d2c7-493e-9f1e-125a0477f536"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscription = client.GetSubscriptionResource(subscriptionResourceId); - // invoke the operation - SubscriptionResource result = await subscription.GetAsync(); + // invoke the operation and iterate over the result + bool? includeExtendedLocations = true; + await foreach (LocationExpanded item in subscription.GetLocationsAsync(includeExtendedLocations: includeExtendedLocations)) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TagResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TagResource.cs index a5dd3ba01719b..7aa8f14c85b83 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TagResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TagResource.cs @@ -18,10 +18,10 @@ public partial class Sample_TagResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTagsOnAResource() + public async Task Get_GetTagsOnAResource() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PutTagsResource.json - // this example is just showing the usage of "Tags_CreateOrUpdateAtScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetTagsResource.json + // this example is just showing the usage of "Tags_GetAtScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,16 +35,7 @@ public async Task CreateOrUpdate_UpdateTagsOnAResource() TagResource tagResource = client.GetTagResource(tagResourceId); // invoke the operation - TagResourceData data = new TagResourceData(new Tag() - { - TagValues = -{ -["tagKey1"] = "tag-value-1", -["tagKey2"] = "tag-value-2", -}, - }); - ArmOperation lro = await tagResource.CreateOrUpdateAsync(WaitUntil.Completed, data); - TagResource result = lro.Value; + TagResource result = await tagResource.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +46,10 @@ public async Task CreateOrUpdate_UpdateTagsOnAResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTagsOnASubscription() + public async Task Get_GetTagsOnASubscription() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PutTagsSubscription.json - // this example is just showing the usage of "Tags_CreateOrUpdateAtScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetTagsSubscription.json + // this example is just showing the usage of "Tags_GetAtScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +63,7 @@ public async Task CreateOrUpdate_UpdateTagsOnASubscription() TagResource tagResource = client.GetTagResource(tagResourceId); // invoke the operation - TagResourceData data = new TagResourceData(new Tag() - { - TagValues = -{ -["tagKey1"] = "tag-value-1", -["tagKey2"] = "tag-value-2", -}, - }); - ArmOperation lro = await tagResource.CreateOrUpdateAsync(WaitUntil.Completed, data); - TagResource result = lro.Value; + TagResource result = await tagResource.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +74,10 @@ public async Task CreateOrUpdate_UpdateTagsOnASubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateTagsOnAResource() + public async Task Delete_UpdateTagsOnAResource() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PatchTagsResource.json - // this example is just showing the usage of "Tags_UpdateAtScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/DeleteTagsResource.json + // this example is just showing the usage of "Tags_DeleteAtScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,31 +91,17 @@ public async Task Update_UpdateTagsOnAResource() TagResource tagResource = client.GetTagResource(tagResourceId); // invoke the operation - TagResourcePatch patch = new TagResourcePatch() - { - PatchMode = TagPatchMode.Replace, - TagValues = -{ -["tagKey1"] = "tag-value-1", -["tagKey2"] = "tag-value-2", -}, - }; - ArmOperation lro = await tagResource.UpdateAsync(WaitUntil.Completed, patch); - TagResource result = lro.Value; + await tagResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateTagsOnASubscription() + public async Task Delete_UpdateTagsOnASubscription() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PatchTagsSubscription.json - // this example is just showing the usage of "Tags_UpdateAtScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/DeleteTagsSubscription.json + // this example is just showing the usage of "Tags_DeleteAtScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,31 +115,17 @@ public async Task Update_UpdateTagsOnASubscription() TagResource tagResource = client.GetTagResource(tagResourceId); // invoke the operation - TagResourcePatch patch = new TagResourcePatch() - { - PatchMode = TagPatchMode.Replace, - TagValues = -{ -["tagKey1"] = "tag-value-1", -["tagKey2"] = "tag-value-2", -}, - }; - ArmOperation lro = await tagResource.UpdateAsync(WaitUntil.Completed, patch); - TagResource result = lro.Value; + await tagResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTagsOnAResource() + public async Task Update_UpdateTagsOnAResource() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetTagsResource.json - // this example is just showing the usage of "Tags_GetAtScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PatchTagsResource.json + // this example is just showing the usage of "Tags_UpdateAtScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,7 +139,17 @@ public async Task Get_GetTagsOnAResource() TagResource tagResource = client.GetTagResource(tagResourceId); // invoke the operation - TagResource result = await tagResource.GetAsync(); + TagResourcePatch patch = new TagResourcePatch + { + PatchMode = TagPatchMode.Replace, + TagValues = +{ +["tagKey1"] = "tag-value-1", +["tagKey2"] = "tag-value-2" +}, + }; + ArmOperation lro = await tagResource.UpdateAsync(WaitUntil.Completed, patch); + TagResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -196,10 +160,10 @@ public async Task Get_GetTagsOnAResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTagsOnASubscription() + public async Task Update_UpdateTagsOnASubscription() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/GetTagsSubscription.json - // this example is just showing the usage of "Tags_GetAtScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PatchTagsSubscription.json + // this example is just showing the usage of "Tags_UpdateAtScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,7 +177,17 @@ public async Task Get_GetTagsOnASubscription() TagResource tagResource = client.GetTagResource(tagResourceId); // invoke the operation - TagResource result = await tagResource.GetAsync(); + TagResourcePatch patch = new TagResourcePatch + { + PatchMode = TagPatchMode.Replace, + TagValues = +{ +["tagKey1"] = "tag-value-1", +["tagKey2"] = "tag-value-2" +}, + }; + ArmOperation lro = await tagResource.UpdateAsync(WaitUntil.Completed, patch); + TagResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -224,10 +198,10 @@ public async Task Get_GetTagsOnASubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_UpdateTagsOnAResource() + public async Task CreateOrUpdate_UpdateTagsOnAResource() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/DeleteTagsResource.json - // this example is just showing the usage of "Tags_DeleteAtScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PutTagsResource.json + // this example is just showing the usage of "Tags_CreateOrUpdateAtScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -241,17 +215,30 @@ public async Task Delete_UpdateTagsOnAResource() TagResource tagResource = client.GetTagResource(tagResourceId); // invoke the operation - await tagResource.DeleteAsync(WaitUntil.Completed); + TagResourceData data = new TagResourceData(new Tag + { + TagValues = +{ +["tagKey1"] = "tag-value-1", +["tagKey2"] = "tag-value-2" +}, + }); + ArmOperation lro = await tagResource.CreateOrUpdateAsync(WaitUntil.Completed, data); + TagResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_UpdateTagsOnASubscription() + public async Task CreateOrUpdate_UpdateTagsOnASubscription() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/DeleteTagsSubscription.json - // this example is just showing the usage of "Tags_DeleteAtScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2022-09-01/examples/PutTagsSubscription.json + // this example is just showing the usage of "Tags_CreateOrUpdateAtScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -265,9 +252,22 @@ public async Task Delete_UpdateTagsOnASubscription() TagResource tagResource = client.GetTagResource(tagResourceId); // invoke the operation - await tagResource.DeleteAsync(WaitUntil.Completed); + TagResourceData data = new TagResourceData(new Tag + { + TagValues = +{ +["tagKey1"] = "tag-value-1", +["tagKey2"] = "tag-value-2" +}, + }); + ArmOperation lro = await tagResource.CreateOrUpdateAsync(WaitUntil.Completed, data); + TagResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicyDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicyDefinitionCollection.cs index 16d6bcc86a0cc..7a15ce0c0e1f1 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicyDefinitionCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicyDefinitionCollection.cs @@ -27,9 +27,7 @@ public async Task Get_RetrieveABuiltInPolicyDefinition() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantPolicyDefinitionResource TenantPolicyDefinitionCollection collection = tenant.GetTenantPolicyDefinitions(); @@ -45,6 +43,36 @@ public async Task Get_RetrieveABuiltInPolicyDefinition() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListBuiltInPolicyDefinitions() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicyDefinitions.json + // this example is just showing the usage of "PolicyDefinitions_ListBuiltIn" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this TenantPolicyDefinitionResource + TenantPolicyDefinitionCollection collection = tenant.GetTenantPolicyDefinitions(); + + // invoke the operation and iterate over the result + await foreach (TenantPolicyDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_RetrieveABuiltInPolicyDefinition() @@ -57,9 +85,7 @@ public async Task Exists_RetrieveABuiltInPolicyDefinition() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantPolicyDefinitionResource TenantPolicyDefinitionCollection collection = tenant.GetTenantPolicyDefinitions(); @@ -83,9 +109,7 @@ public async Task GetIfExists_RetrieveABuiltInPolicyDefinition() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantPolicyDefinitionResource TenantPolicyDefinitionCollection collection = tenant.GetTenantPolicyDefinitions(); @@ -108,37 +132,5 @@ public async Task GetIfExists_RetrieveABuiltInPolicyDefinition() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBuiltInPolicyDefinitions() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicyDefinitions.json - // this example is just showing the usage of "PolicyDefinitions_ListBuiltIn" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPolicyDefinitionResource - TenantPolicyDefinitionCollection collection = tenant.GetTenantPolicyDefinitions(); - - // invoke the operation and iterate over the result - await foreach (TenantPolicyDefinitionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicySetDefinitionCollection.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicySetDefinitionCollection.cs index 1fc2a60250692..71febf92e65c2 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicySetDefinitionCollection.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantPolicySetDefinitionCollection.cs @@ -27,9 +27,7 @@ public async Task Get_RetrieveABuiltInPolicySetDefinition() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantPolicySetDefinitionResource TenantPolicySetDefinitionCollection collection = tenant.GetTenantPolicySetDefinitions(); @@ -45,6 +43,36 @@ public async Task Get_RetrieveABuiltInPolicySetDefinition() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListBuiltInPolicySetDefinitions() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicySetDefinitions.json + // this example is just showing the usage of "PolicySetDefinitions_ListBuiltIn" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this TenantPolicySetDefinitionResource + TenantPolicySetDefinitionCollection collection = tenant.GetTenantPolicySetDefinitions(); + + // invoke the operation and iterate over the result + await foreach (TenantPolicySetDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicySetDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_RetrieveABuiltInPolicySetDefinition() @@ -57,9 +85,7 @@ public async Task Exists_RetrieveABuiltInPolicySetDefinition() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantPolicySetDefinitionResource TenantPolicySetDefinitionCollection collection = tenant.GetTenantPolicySetDefinitions(); @@ -83,9 +109,7 @@ public async Task GetIfExists_RetrieveABuiltInPolicySetDefinition() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantPolicySetDefinitionResource TenantPolicySetDefinitionCollection collection = tenant.GetTenantPolicySetDefinitions(); @@ -108,37 +132,5 @@ public async Task GetIfExists_RetrieveABuiltInPolicySetDefinition() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBuiltInPolicySetDefinitions() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Authorization/stable/2021-06-01/examples/listBuiltInPolicySetDefinitions.json - // this example is just showing the usage of "PolicySetDefinitions_ListBuiltIn" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPolicySetDefinitionResource - TenantPolicySetDefinitionCollection collection = tenant.GetTenantPolicySetDefinitions(); - - // invoke the operation and iterate over the result - await foreach (TenantPolicySetDefinitionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicySetDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantResource.cs b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantResource.cs index c2d89849b8d45..dac1fd7a80cc5 100644 --- a/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantResource.cs +++ b/sdk/resourcemanager/Azure.ResourceManager/samples/Generated/Samples/Sample_TenantResource.cs @@ -28,9 +28,7 @@ public async Task GetTenantResourceProvider_GetAResourceProviderAtTenantScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenant = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string resourceProviderNamespace = "Microsoft.Storage"; diff --git a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResource.cs b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResource.cs index 8b0fca002ec48..fcf8916195091 100644 --- a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResource.cs +++ b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MoverResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MoveResourcesCreate() + public async Task Get_MoveResourcesGet() { - // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveResources_Create.json - // this example is just showing the usage of "MoveResources_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveResources_Get.json + // this example is just showing the usage of "MoveResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,33 +38,7 @@ public async Task Update_MoveResourcesCreate() MoverResource moverResource = client.GetMoverResource(moverResourceId); // invoke the operation - MoverResourceData data = new MoverResourceData() - { - Properties = new MoverResourceProperties(new ResourceIdentifier("/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.Compute/virtualMachines/eastusvm1")) - { - ResourceSettings = new VirtualMachineResourceSettings() - { - UserManagedIdentities = -{ -new ResourceIdentifier("/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi1") -}, - TargetAvailabilityZone = MoverTargetAvailabilityZone.Two, - TargetVmSize = null, - TargetAvailabilitySetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.Compute/availabilitySets/avset1"), - TargetResourceName = "westusvm1", - }, - DependsOnOverrides = -{ -new MoverResourceDependencyOverride() -{ -Id = new ResourceIdentifier("/subscriptions/c4488a3f-a7f7-4ad4-aa72-0e1f4d9c0756/resourceGroups/eastusRG/providers/Microsoft.Network/networkInterfaces/eastusvm140"), -TargetId = new ResourceIdentifier("/subscriptions/c4488a3f-a7f7-4ad4-aa72-0e1f4d9c0756/resourceGroups/westusRG/providers/Microsoft.Network/networkInterfaces/eastusvm140"), -} -}, - }, - }; - ArmOperation lro = await moverResource.UpdateAsync(WaitUntil.Completed, data); - MoverResource result = lro.Value; + MoverResource result = await moverResource.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -103,10 +77,10 @@ public async Task Delete_MoveResourcesDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MoveResourcesGet() + public async Task Update_MoveResourcesCreate() { - // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveResources_Get.json - // this example is just showing the usage of "MoveResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveResources_Create.json + // this example is just showing the usage of "MoveResources_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -123,7 +97,27 @@ public async Task Get_MoveResourcesGet() MoverResource moverResource = client.GetMoverResource(moverResourceId); // invoke the operation - MoverResource result = await moverResource.GetAsync(); + MoverResourceData data = new MoverResourceData + { + Properties = new MoverResourceProperties(new ResourceIdentifier("/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.Compute/virtualMachines/eastusvm1")) + { + ResourceSettings = new VirtualMachineResourceSettings + { + UserManagedIdentities = { new ResourceIdentifier("/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi1") }, + TargetAvailabilityZone = MoverTargetAvailabilityZone.Two, + TargetVmSize = null, + TargetAvailabilitySetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.Compute/availabilitySets/avset1"), + TargetResourceName = "westusvm1", + }, + DependsOnOverrides = {new MoverResourceDependencyOverride +{ +Id = new ResourceIdentifier("/subscriptions/c4488a3f-a7f7-4ad4-aa72-0e1f4d9c0756/resourceGroups/eastusRG/providers/Microsoft.Network/networkInterfaces/eastusvm140"), +TargetId = new ResourceIdentifier("/subscriptions/c4488a3f-a7f7-4ad4-aa72-0e1f4d9c0756/resourceGroups/westusRG/providers/Microsoft.Network/networkInterfaces/eastusvm140"), +}}, + }, + }; + ArmOperation lro = await moverResource.UpdateAsync(WaitUntil.Completed, data); + MoverResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceCollection.cs b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceCollection.cs index f763ac424d57c..3ce4ef83dd432 100644 --- a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceCollection.cs +++ b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.ResourceMover.Samples { public partial class Sample_MoverResourceCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_MoveResourcesList() - { - // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveResources_List.json - // this example is just showing the usage of "MoveResources_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MoverResourceSetResource created on azure - // for more information of creating MoverResourceSetResource, please refer to the document of MoverResourceSetResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string moverResourceSetName = "movecollection1"; - ResourceIdentifier moverResourceSetResourceId = MoverResourceSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, moverResourceSetName); - MoverResourceSetResource moverResourceSet = client.GetMoverResourceSetResource(moverResourceSetResourceId); - - // get the collection of this MoverResource - MoverResourceCollection collection = moverResourceSet.GetMoverResources(); - - // invoke the operation and iterate over the result - await foreach (MoverResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MoverResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_MoveResourcesCreate() @@ -77,29 +41,23 @@ public async Task CreateOrUpdate_MoveResourcesCreate() // invoke the operation string moverResourceName = "moveresourcename1"; - MoverResourceData data = new MoverResourceData() + MoverResourceData data = new MoverResourceData { Properties = new MoverResourceProperties(new ResourceIdentifier("/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.Compute/virtualMachines/eastusvm1")) { - ResourceSettings = new VirtualMachineResourceSettings() + ResourceSettings = new VirtualMachineResourceSettings { - UserManagedIdentities = -{ -new ResourceIdentifier("/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi1") -}, + UserManagedIdentities = { new ResourceIdentifier("/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi1") }, TargetAvailabilityZone = MoverTargetAvailabilityZone.Two, TargetVmSize = null, TargetAvailabilitySetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/eastusRG/providers/Microsoft.Compute/availabilitySets/avset1"), TargetResourceName = "westusvm1", }, - DependsOnOverrides = -{ -new MoverResourceDependencyOverride() + DependsOnOverrides = {new MoverResourceDependencyOverride { Id = new ResourceIdentifier("/subscriptions/c4488a3f-a7f7-4ad4-aa72-0e1f4d9c0756/resourceGroups/eastusRG/providers/Microsoft.Network/networkInterfaces/eastusvm140"), TargetId = new ResourceIdentifier("/subscriptions/c4488a3f-a7f7-4ad4-aa72-0e1f4d9c0756/resourceGroups/westusRG/providers/Microsoft.Network/networkInterfaces/eastusvm140"), -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, moverResourceName, data); @@ -146,6 +104,42 @@ public async Task Get_MoveResourcesGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_MoveResourcesList() + { + // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveResources_List.json + // this example is just showing the usage of "MoveResources_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MoverResourceSetResource created on azure + // for more information of creating MoverResourceSetResource, please refer to the document of MoverResourceSetResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string moverResourceSetName = "movecollection1"; + ResourceIdentifier moverResourceSetResourceId = MoverResourceSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, moverResourceSetName); + MoverResourceSetResource moverResourceSet = client.GetMoverResourceSetResource(moverResourceSetResourceId); + + // get the collection of this MoverResource + MoverResourceCollection collection = moverResourceSet.GetMoverResources(); + + // invoke the operation and iterate over the result + await foreach (MoverResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MoverResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_MoveResourcesGet() diff --git a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceSetCollection.cs b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceSetCollection.cs index 3e0e70c39ca3f..513fc16321ef8 100644 --- a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceSetCollection.cs +++ b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceSetCollection.cs @@ -45,7 +45,7 @@ public async Task CreateOrUpdate_MoveCollectionsCreate() MoverResourceSetData data = new MoverResourceSetData(new AzureLocation("eastus2")) { Identity = new ManagedServiceIdentity("SystemAssigned"), - Properties = new MoverResourceSetProperties() + Properties = new MoverResourceSetProperties { SourceLocation = new AzureLocation("eastus"), TargetLocation = new AzureLocation("westus"), @@ -97,10 +97,10 @@ public async Task Get_MoveCollectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MoveCollectionsGet() + public async Task GetAll_MoveCollectionsListMoveCollectionsByResourceGroup() { - // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_Get.json - // this example is just showing the usage of "MoveCollections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_ListMoveCollectionsByResourceGroup.json + // this example is just showing the usage of "MoveCollections_ListMoveCollectionsByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,16 +117,22 @@ public async Task Exists_MoveCollectionsGet() // get the collection of this MoverResourceSetResource MoverResourceSetCollection collection = resourceGroupResource.GetMoverResourceSets(); - // invoke the operation - string moverResourceSetName = "movecollection1"; - bool result = await collection.ExistsAsync(moverResourceSetName); + // invoke the operation and iterate over the result + await foreach (MoverResourceSetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MoverResourceSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MoveCollectionsGet() + public async Task Exists_MoveCollectionsGet() { // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_Get.json // this example is just showing the usage of "MoveCollections_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +154,17 @@ public async Task GetIfExists_MoveCollectionsGet() // invoke the operation string moverResourceSetName = "movecollection1"; - NullableResponse response = await collection.GetIfExistsAsync(moverResourceSetName); - MoverResourceSetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(moverResourceSetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MoverResourceSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MoveCollectionsListMoveCollectionsByResourceGroup() + public async Task GetIfExists_MoveCollectionsGet() { - // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_ListMoveCollectionsByResourceGroup.json - // this example is just showing the usage of "MoveCollections_ListMoveCollectionsByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_Get.json + // this example is just showing the usage of "MoveCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +181,23 @@ public async Task GetAll_MoveCollectionsListMoveCollectionsByResourceGroup() // get the collection of this MoverResourceSetResource MoverResourceSetCollection collection = resourceGroupResource.GetMoverResourceSets(); - // invoke the operation and iterate over the result - await foreach (MoverResourceSetResource item in collection.GetAllAsync()) + // invoke the operation + string moverResourceSetName = "movecollection1"; + NullableResponse response = await collection.GetIfExistsAsync(moverResourceSetName); + MoverResourceSetResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MoverResourceSetData resourceData = item.Data; + MoverResourceSetData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceSetResource.cs b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceSetResource.cs index beb46e039bb9f..94972e5f4d7c6 100644 --- a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceSetResource.cs +++ b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_MoverResourceSetResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.ResourceMover.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ResourceMover.Samples @@ -20,10 +19,10 @@ public partial class Sample_MoverResourceSetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MoveCollectionsUpdate() + public async Task Get_MoveCollectionsGet() { - // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_Update.json - // this example is just showing the usage of "MoveCollections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_Get.json + // this example is just showing the usage of "MoveCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,15 +38,7 @@ public async Task Update_MoveCollectionsUpdate() MoverResourceSetResource moverResourceSet = client.GetMoverResourceSetResource(moverResourceSetResourceId); // invoke the operation - MoverResourceSetPatch patch = new MoverResourceSetPatch() - { - Tags = -{ -["key1"] = "mc1", -}, - Identity = new ManagedServiceIdentity("SystemAssigned"), - }; - MoverResourceSetResource result = await moverResourceSet.UpdateAsync(patch); + MoverResourceSetResource result = await moverResourceSet.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,10 +76,10 @@ public async Task Delete_MoveCollectionsDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MoveCollectionsGet() + public async Task Update_MoveCollectionsUpdate() { - // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_Get.json - // this example is just showing the usage of "MoveCollections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_Update.json + // this example is just showing the usage of "MoveCollections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,7 +95,15 @@ public async Task Get_MoveCollectionsGet() MoverResourceSetResource moverResourceSet = client.GetMoverResourceSetResource(moverResourceSetResourceId); // invoke the operation - MoverResourceSetResource result = await moverResourceSet.GetAsync(); + MoverResourceSetPatch patch = new MoverResourceSetPatch + { + Tags = +{ +["key1"] = "mc1" +}, + Identity = new ManagedServiceIdentity("SystemAssigned"), + }; + MoverResourceSetResource result = await moverResourceSet.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -134,10 +133,7 @@ public async Task Prepare_MoveCollectionsPrepare() MoverResourceSetResource moverResourceSet = client.GetMoverResourceSetResource(moverResourceSetResourceId); // invoke the operation - MoverPrepareContent content = new MoverPrepareContent(new ResourceIdentifier[] - { -new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Migrate/MoveCollections/movecollection1/MoveResources/moveresource1") - }) + MoverPrepareContent content = new MoverPrepareContent(new ResourceIdentifier[] { new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Migrate/MoveCollections/movecollection1/MoveResources/moveresource1") }) { ValidateOnly = false, }; @@ -168,10 +164,7 @@ public async Task InitiateMove_MoveCollectionsInitiateMove() MoverResourceSetResource moverResourceSet = client.GetMoverResourceSetResource(moverResourceSetResourceId); // invoke the operation - MoverResourceMoveContent content = new MoverResourceMoveContent(new ResourceIdentifier[] - { -new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Migrate/MoveCollections/movecollection1/MoveResources/moveresource1") - }) + MoverResourceMoveContent content = new MoverResourceMoveContent(new ResourceIdentifier[] { new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Migrate/MoveCollections/movecollection1/MoveResources/moveresource1") }) { ValidateOnly = false, }; @@ -202,10 +195,7 @@ public async Task Commit_MoveCollectionsCommit() MoverResourceSetResource moverResourceSet = client.GetMoverResourceSetResource(moverResourceSetResourceId); // invoke the operation - MoverCommitContent content = new MoverCommitContent(new ResourceIdentifier[] - { -new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Migrate/MoveCollections/movecollection1/MoveResources/moveresource1") - }) + MoverCommitContent content = new MoverCommitContent(new ResourceIdentifier[] { new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Migrate/MoveCollections/movecollection1/MoveResources/moveresource1") }) { ValidateOnly = false, }; @@ -236,10 +226,7 @@ public async Task Discard_MoveCollectionsDiscard() MoverResourceSetResource moverResourceSet = client.GetMoverResourceSetResource(moverResourceSetResourceId); // invoke the operation - MoverDiscardContent content = new MoverDiscardContent(new ResourceIdentifier[] - { -new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Migrate/MoveCollections/movecollection1/MoveResources/moveresource1") - }) + MoverDiscardContent content = new MoverDiscardContent(new ResourceIdentifier[] { new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Migrate/MoveCollections/movecollection1/MoveResources/moveresource1") }) { ValidateOnly = false, }; @@ -297,13 +284,10 @@ public async Task BulkRemove_MoveCollectionsBulkRemove() MoverResourceSetResource moverResourceSet = client.GetMoverResourceSetResource(moverResourceSetResourceId); // invoke the operation - MoverBulkRemoveContent content = new MoverBulkRemoveContent() + MoverBulkRemoveContent content = new MoverBulkRemoveContent { ValidateOnly = false, - MoverResources = -{ -new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Migrate/MoveCollections/movecollection1/MoveResources/moveresource1") -}, + MoverResources = { new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Migrate/MoveCollections/movecollection1/MoveResources/moveresource1") }, }; ArmOperation lro = await moverResourceSet.BulkRemoveAsync(WaitUntil.Completed, content: content); MoverOperationStatus result = lro.Value; @@ -311,37 +295,6 @@ public async Task BulkRemove_MoveCollectionsBulkRemove() Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMoverResourceSets_MoveCollectionsListMoveCollectionsBySubscription() - { - // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_ListMoveCollectionsBySubscription.json - // this example is just showing the usage of "MoveCollections_ListMoveCollectionsBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MoverResourceSetResource item in subscriptionResource.GetMoverResourceSetsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MoverResourceSetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetRequiredForResources_RequiredForGet() diff --git a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..40bc7fab84f74 --- /dev/null +++ b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ResourceMover.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMoverResourceSets_MoveCollectionsListMoveCollectionsBySubscription() + { + // Generated from example definition: specification/resourcemover/resource-manager/Microsoft.Migrate/stable/2023-08-01/examples/MoveCollections_ListMoveCollectionsBySubscription.json + // this example is just showing the usage of "MoveCollections_ListMoveCollectionsBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MoverResourceSetResource item in subscriptionResource.GetMoverResourceSetsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MoverResourceSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index 2aba24d9820af..eedd196bbb5fa 100644 --- a/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/resourcemover/Azure.ResourceManager.ResourceMover/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ResourceMover.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ResourceMover.Samples @@ -28,9 +29,7 @@ public async Task GetOperationsDiscoveries_OperationsDiscoveryGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (MoverOperationsDiscovery item in tenantResource.GetOperationsDiscoveriesAsync()) diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationCollection.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationCollection.cs index 60bb2f8c33b83..7d749790d2f8b 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationCollection.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ArmApplicationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAManagedApplication() + public async Task CreateOrUpdate_CreateOrUpdateManagedApplication() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/getApplication.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/createOrUpdateApplication.json + // this example is just showing the usage of "Applications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,7 +39,13 @@ public async Task Get_GetAManagedApplication() // invoke the operation string applicationName = "myManagedApplication"; - ArmApplicationResource result = await collection.GetAsync(applicationName); + ArmApplicationData data = new ArmApplicationData(new AzureLocation("East US 2"), "ServiceCatalog") + { + ManagedResourceGroupId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/myManagedRG"), + ApplicationDefinitionId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); + ArmApplicationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,7 +56,7 @@ public async Task Get_GetAManagedApplication() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAManagedApplication() + public async Task Get_GetAManagedApplication() { // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/getApplication.json // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. @@ -72,17 +78,21 @@ public async Task Exists_GetAManagedApplication() // invoke the operation string applicationName = "myManagedApplication"; - bool result = await collection.ExistsAsync(applicationName); + ArmApplicationResource result = await collection.GetAsync(applicationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArmApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAManagedApplication() + public async Task GetAll_ListsApplications() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/getApplication.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/listApplicationsByResourceGroup.json + // this example is just showing the usage of "Applications_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,31 +109,25 @@ public async Task GetIfExists_GetAManagedApplication() // get the collection of this ArmApplicationResource ArmApplicationCollection collection = resourceGroupResource.GetArmApplications(); - // invoke the operation - string applicationName = "myManagedApplication"; - NullableResponse response = await collection.GetIfExistsAsync(applicationName); - ArmApplicationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ArmApplicationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ArmApplicationData resourceData = result.Data; + ArmApplicationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateManagedApplication() + public async Task Exists_GetAManagedApplication() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/createOrUpdateApplication.json - // this example is just showing the usage of "Applications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/getApplication.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,27 +146,17 @@ public async Task CreateOrUpdate_CreateOrUpdateManagedApplication() // invoke the operation string applicationName = "myManagedApplication"; - ArmApplicationData data = new ArmApplicationData(new AzureLocation("East US 2"), "ServiceCatalog") - { - ManagedResourceGroupId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/myManagedRG"), - ApplicationDefinitionId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg/providers/Microsoft.Solutions/applicationDefinitions/myAppDef"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); - ArmApplicationResource result = lro.Value; + bool result = await collection.ExistsAsync(applicationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArmApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsApplications() + public async Task GetIfExists_GetAManagedApplication() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/listApplicationsByResourceGroup.json - // this example is just showing the usage of "Applications_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/getApplication.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_ListsApplications() // get the collection of this ArmApplicationResource ArmApplicationCollection collection = resourceGroupResource.GetArmApplications(); - // invoke the operation and iterate over the result - await foreach (ArmApplicationResource item in collection.GetAllAsync()) + // invoke the operation + string applicationName = "myManagedApplication"; + NullableResponse response = await collection.GetIfExistsAsync(applicationName); + ArmApplicationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ArmApplicationData resourceData = item.Data; + ArmApplicationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationDefinitionCollection.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationDefinitionCollection.cs index 19530b037f88e..55ee2a5c2bb67 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationDefinitionCollection.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationDefinitionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ArmApplicationDefinitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedApplicationDefinition() + public async Task CreateOrUpdate_CreateOrUpdateManagedApplicationDefinition() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/getApplicationDefinition.json - // this example is just showing the usage of "ApplicationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/createOrUpdateApplicationDefinition.json + // this example is just showing the usage of "ApplicationDefinitions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,15 @@ public async Task Get_GetManagedApplicationDefinition() // invoke the operation string applicationDefinitionName = "myManagedApplicationDef"; - ArmApplicationDefinitionResource result = await collection.GetAsync(applicationDefinitionName); + ArmApplicationDefinitionData data = new ArmApplicationDefinitionData(new AzureLocation("East US 2"), ArmApplicationLockLevel.None) + { + DisplayName = "myManagedApplicationDef", + Authorizations = { new ArmApplicationAuthorization(Guid.Parse("validprincipalguid"), "validroleguid") }, + Description = "myManagedApplicationDef description", + PackageFileUri = new Uri("https://path/to/packagezipfile"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationDefinitionName, data); + ArmApplicationDefinitionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +59,7 @@ public async Task Get_GetManagedApplicationDefinition() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagedApplicationDefinition() + public async Task Get_GetManagedApplicationDefinition() { // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/getApplicationDefinition.json // this example is just showing the usage of "ApplicationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +81,21 @@ public async Task Exists_GetManagedApplicationDefinition() // invoke the operation string applicationDefinitionName = "myManagedApplicationDef"; - bool result = await collection.ExistsAsync(applicationDefinitionName); + ArmApplicationDefinitionResource result = await collection.GetAsync(applicationDefinitionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArmApplicationDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagedApplicationDefinition() + public async Task GetAll_ListManagedApplicationDefinitions() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/getApplicationDefinition.json - // this example is just showing the usage of "ApplicationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/listApplicationDefinitionsByResourceGroup.json + // this example is just showing the usage of "ApplicationDefinitions_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +112,25 @@ public async Task GetIfExists_GetManagedApplicationDefinition() // get the collection of this ArmApplicationDefinitionResource ArmApplicationDefinitionCollection collection = resourceGroupResource.GetArmApplicationDefinitions(); - // invoke the operation - string applicationDefinitionName = "myManagedApplicationDef"; - NullableResponse response = await collection.GetIfExistsAsync(applicationDefinitionName); - ArmApplicationDefinitionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ArmApplicationDefinitionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ArmApplicationDefinitionData resourceData = result.Data; + ArmApplicationDefinitionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateManagedApplicationDefinition() + public async Task Exists_GetManagedApplicationDefinition() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/createOrUpdateApplicationDefinition.json - // this example is just showing the usage of "ApplicationDefinitions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/getApplicationDefinition.json + // this example is just showing the usage of "ApplicationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,32 +149,17 @@ public async Task CreateOrUpdate_CreateOrUpdateManagedApplicationDefinition() // invoke the operation string applicationDefinitionName = "myManagedApplicationDef"; - ArmApplicationDefinitionData data = new ArmApplicationDefinitionData(new AzureLocation("East US 2"), ArmApplicationLockLevel.None) - { - DisplayName = "myManagedApplicationDef", - Authorizations = -{ -new ArmApplicationAuthorization(Guid.Parse("validprincipalguid"),"validroleguid") -}, - Description = "myManagedApplicationDef description", - PackageFileUri = new Uri("https://path/to/packagezipfile"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationDefinitionName, data); - ArmApplicationDefinitionResource result = lro.Value; + bool result = await collection.ExistsAsync(applicationDefinitionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArmApplicationDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedApplicationDefinitions() + public async Task GetIfExists_GetManagedApplicationDefinition() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/listApplicationDefinitionsByResourceGroup.json - // this example is just showing the usage of "ApplicationDefinitions_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Solutions/stable/2019-07-01/examples/getApplicationDefinition.json + // this example is just showing the usage of "ApplicationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +176,23 @@ public async Task GetAll_ListManagedApplicationDefinitions() // get the collection of this ArmApplicationDefinitionResource ArmApplicationDefinitionCollection collection = resourceGroupResource.GetArmApplicationDefinitions(); - // invoke the operation and iterate over the result - await foreach (ArmApplicationDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string applicationDefinitionName = "myManagedApplicationDef"; + NullableResponse response = await collection.GetIfExistsAsync(applicationDefinitionName); + ArmApplicationDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ArmApplicationDefinitionData resourceData = item.Data; + ArmApplicationDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationDefinitionResource.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationDefinitionResource.cs index 85f0a4667bbb4..e499540edc600 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationDefinitionResource.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationDefinitionResource.cs @@ -70,10 +70,7 @@ public async Task Update_CreateOrUpdateManagedApplicationDefinition() ArmApplicationDefinitionData data = new ArmApplicationDefinitionData(new AzureLocation("East US 2"), ArmApplicationLockLevel.None) { DisplayName = "myManagedApplicationDef", - Authorizations = -{ -new ArmApplicationAuthorization(Guid.Parse("validprincipalguid"),"validroleguid") -}, + Authorizations = { new ArmApplicationAuthorization(Guid.Parse("validprincipalguid"), "validroleguid") }, Description = "myManagedApplicationDef description", PackageFileUri = new Uri("https://path/to/packagezipfile"), }; diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationResource.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationResource.cs index c4b246f98b955..a327820d6fc90 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationResource.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmApplicationResource.cs @@ -67,7 +67,7 @@ public async Task Update_CreateOrUpdateManagedApplication() ArmApplicationResource armApplication = client.GetArmApplicationResource(armApplicationResourceId); // invoke the operation - ArmApplicationPatch patch = new ArmApplicationPatch(new AzureLocation("placeholder")) + ArmApplicationPatch patch = new ArmApplicationPatch(default) { Kind = "ServiceCatalog", ManagedResourceGroupId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/myManagedRG"), diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentCollection.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentCollection.cs index 915672464fa06..246ee4707c5bc 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentCollection.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -42,20 +41,18 @@ public async Task CreateOrUpdate_CreateDeploymentAtAGivenScope() string deploymentName = "my-deployment"; ArmDeploymentContent content = new ArmDeploymentContent(new ArmDeploymentProperties(ArmDeploymentMode.Incremental) { - TemplateLink = new ArmDeploymentTemplateLink() + TemplateLink = new ArmDeploymentTemplateLink { Uri = new Uri("https://example.com/exampleTemplate.json"), }, - Parameters = BinaryData.FromObjectAsJson(new Dictionary() - { - }), + Parameters = BinaryData.FromObjectAsJson(new object()), }) { Location = new AzureLocation("eastus"), Tags = { ["tagKey1"] = "tag-value-1", -["tagKey2"] = "tag-value-2", +["tagKey2"] = "tag-value-2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, content); diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentResource.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentResource.cs index c0f56ffa62ec6..099a7337d38c8 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentResource.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -39,20 +38,18 @@ public async Task Update_CreateDeploymentAtAGivenScope() // invoke the operation ArmDeploymentContent content = new ArmDeploymentContent(new ArmDeploymentProperties(ArmDeploymentMode.Incremental) { - TemplateLink = new ArmDeploymentTemplateLink() + TemplateLink = new ArmDeploymentTemplateLink { Uri = new Uri("https://example.com/exampleTemplate.json"), }, - Parameters = BinaryData.FromObjectAsJson(new Dictionary() - { - }), + Parameters = BinaryData.FromObjectAsJson(new object()), }) { Location = new AzureLocation("eastus"), Tags = { ["tagKey1"] = "tag-value-1", -["tagKey2"] = "tag-value-2", +["tagKey2"] = "tag-value-2" }, }; ArmOperation lro = await armDeployment.UpdateAsync(WaitUntil.Completed, content); @@ -87,13 +84,11 @@ public async Task WhatIf_PredictTemplateChangesAtManagementGroupScope() // invoke the operation ArmDeploymentWhatIfContent content = new ArmDeploymentWhatIfContent(new ArmDeploymentWhatIfProperties(ArmDeploymentMode.Incremental) { - TemplateLink = new ArmDeploymentTemplateLink() + TemplateLink = new ArmDeploymentTemplateLink { Uri = new Uri("https://example.com/exampleTemplate.json"), }, - Parameters = BinaryData.FromObjectAsJson(new Dictionary() - { - }), + Parameters = BinaryData.FromObjectAsJson(new object()), }) { Location = new AzureLocation("eastus"), @@ -106,7 +101,7 @@ public async Task WhatIf_PredictTemplateChangesAtManagementGroupScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task WhatIf_PredictTemplateChangesAtManagementGroupScope1() + public async Task WhatIf_PredictTemplateChangesAtManagementGroupScope() { // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/examples/PostDeploymentWhatIfOnManagementGroup.json // this example is just showing the usage of "Deployments_WhatIfAtManagementGroupScope" operation, for the dependent resources, they will have to be created separately. @@ -127,13 +122,11 @@ public async Task WhatIf_PredictTemplateChangesAtManagementGroupScope1() // invoke the operation ArmDeploymentWhatIfContent content = new ArmDeploymentWhatIfContent(new ArmDeploymentWhatIfProperties(ArmDeploymentMode.Incremental) { - TemplateLink = new ArmDeploymentTemplateLink() + TemplateLink = new ArmDeploymentTemplateLink { Uri = new Uri("https://example.com/exampleTemplate.json"), }, - Parameters = BinaryData.FromObjectAsJson(new Dictionary() - { - }), + Parameters = BinaryData.FromObjectAsJson(new object()), }) { Location = new AzureLocation("eastus"), @@ -167,13 +160,11 @@ public async Task WhatIf_PredictTemplateChangesAtSubscriptionScope() // invoke the operation ArmDeploymentWhatIfContent content = new ArmDeploymentWhatIfContent(new ArmDeploymentWhatIfProperties(ArmDeploymentMode.Incremental) { - TemplateLink = new ArmDeploymentTemplateLink() + TemplateLink = new ArmDeploymentTemplateLink { Uri = new Uri("https://example.com/exampleTemplate.json"), }, - Parameters = BinaryData.FromObjectAsJson(new Dictionary() - { - }), + Parameters = BinaryData.FromObjectAsJson(new object()), }) { Location = new AzureLocation("westus"), @@ -208,76 +199,16 @@ public async Task WhatIf_PredictTemplateChangesAtResourceGroupScope() // invoke the operation ArmDeploymentWhatIfContent content = new ArmDeploymentWhatIfContent(new ArmDeploymentWhatIfProperties(ArmDeploymentMode.Incremental) { - TemplateLink = new ArmDeploymentTemplateLink() + TemplateLink = new ArmDeploymentTemplateLink { Uri = new Uri("https://example.com/exampleTemplate.json"), }, - Parameters = BinaryData.FromObjectAsJson(new Dictionary() - { - }), + Parameters = BinaryData.FromObjectAsJson(new object()), }); ArmOperation lro = await armDeployment.WhatIfAsync(WaitUntil.Completed, content); WhatIfOperationResult result = lro.Value; Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CalculateDeploymentTemplateHash_CalculateTemplateHash() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/examples/CalculateTemplateHash.json - // this example is just showing the usage of "Deployments_CalculateTemplateHash" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - BinaryData template = BinaryData.FromObjectAsJson(new Dictionary() - { - ["$schema"] = "http://schemas.management.azure.com/deploymentTemplate?api-version=2014-04-01-preview", - ["contentVersion"] = "1.0.0.0", - ["outputs"] = new Dictionary() - { - ["string"] = new Dictionary() - { - ["type"] = "string", - ["value"] = "myvalue" - } - }, - ["parameters"] = new Dictionary() - { - ["string"] = new Dictionary() - { - ["type"] = "string" - } - }, - ["resources"] = new object[] { }, - ["variables"] = new Dictionary() - { - ["array"] = new object[] { "1", "2", "3", "4" }, - ["bool"] = "true", - ["int"] = "42", - ["object"] = new Dictionary() - { - ["object"] = new Dictionary() - { - ["location"] = "West US", - ["vmSize"] = "Large" - } - }, - ["string"] = "string" - } - }); - TemplateHashResult result = await tenantResource.CalculateDeploymentTemplateHashAsync(template); - - Console.WriteLine($"Succeeded: {result}"); - } } } diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentScriptCollection.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentScriptCollection.cs index 8c1c5f98c6bae..1d13807481437 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentScriptCollection.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentScriptCollection.cs @@ -45,19 +45,16 @@ public async Task CreateOrUpdate_DeploymentScriptsCreate() ArmDeploymentScriptData data = new AzurePowerShellScript(new AzureLocation("westus"), XmlConvert.ToTimeSpan("PT7D"), "1.7.0") { CleanupPreference = ScriptCleanupOptions.Always, - SupportingScriptUris = -{ -new Uri("https://uri1.to.supporting.script"),new Uri("https://uri2.to.supporting.script") -}, + SupportingScriptUris = { new Uri("https://uri1.to.supporting.script"), new Uri("https://uri2.to.supporting.script") }, ScriptContent = "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name", Arguments = "-Location 'westus' -Name \"*rg2\"", Timeout = XmlConvert.ToTimeSpan("PT1H"), - Identity = new ArmDeploymentScriptManagedIdentity() + Identity = new ArmDeploymentScriptManagedIdentity { IdentityType = ArmDeploymentScriptManagedIdentityType.UserAssigned, UserAssignedIdentities = { -["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity(), +["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity() }, }, }; @@ -98,10 +95,7 @@ public async Task CreateOrUpdate_DeploymentScriptsCreateNoUserManagedIdentity() ArmDeploymentScriptData data = new AzurePowerShellScript(new AzureLocation("westus"), XmlConvert.ToTimeSpan("PT7D"), "1.7.0") { CleanupPreference = ScriptCleanupOptions.Always, - SupportingScriptUris = -{ -new Uri("https://uri1.to.supporting.script"),new Uri("https://uri2.to.supporting.script") -}, + SupportingScriptUris = { new Uri("https://uri1.to.supporting.script"), new Uri("https://uri2.to.supporting.script") }, ScriptContent = "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name", Arguments = "-Location 'westus' -Name \"*rg2\"", Timeout = XmlConvert.ToTimeSpan("PT1H"), @@ -144,12 +138,12 @@ public async Task CreateOrUpdate_DeploymentScriptsCreateMinCreate() { ScriptContent = "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name", Arguments = "-Location 'westus' -Name \"*rg2\"", - Identity = new ArmDeploymentScriptManagedIdentity() + Identity = new ArmDeploymentScriptManagedIdentity { IdentityType = ArmDeploymentScriptManagedIdentityType.UserAssigned, UserAssignedIdentities = { -["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity(), +["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity() }, }, }; @@ -191,19 +185,16 @@ public async Task CreateOrUpdate_DeploymentScriptsCreateUsingCustomACIName() { ContainerGroupName = "contoso-aci", CleanupPreference = ScriptCleanupOptions.Always, - SupportingScriptUris = -{ -new Uri("https://uri1.to.supporting.script"),new Uri("https://uri2.to.supporting.script") -}, + SupportingScriptUris = { new Uri("https://uri1.to.supporting.script"), new Uri("https://uri2.to.supporting.script") }, ScriptContent = "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name", Arguments = "-Location 'westus' -Name \"*rg2\"", Timeout = XmlConvert.ToTimeSpan("PT1H"), - Identity = new ArmDeploymentScriptManagedIdentity() + Identity = new ArmDeploymentScriptManagedIdentity { IdentityType = ArmDeploymentScriptManagedIdentityType.UserAssigned, UserAssignedIdentities = { -["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity(), +["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity() }, }, }; @@ -243,25 +234,22 @@ public async Task CreateOrUpdate_DeploymentScriptsCreateUsingExistingStorageAcco string scriptName = "MyDeploymentScript"; ArmDeploymentScriptData data = new AzurePowerShellScript(new AzureLocation("westus"), XmlConvert.ToTimeSpan("PT7D"), "1.7.0") { - StorageAccountSettings = new ScriptStorageConfiguration() + StorageAccountSettings = new ScriptStorageConfiguration { StorageAccountName = "contosostorage", StorageAccountKey = "contosostoragekey", }, CleanupPreference = ScriptCleanupOptions.Always, - SupportingScriptUris = -{ -new Uri("https://uri1.to.supporting.script"),new Uri("https://uri2.to.supporting.script") -}, + SupportingScriptUris = { new Uri("https://uri1.to.supporting.script"), new Uri("https://uri2.to.supporting.script") }, ScriptContent = "Param([string]$Location,[string]$Name) $deploymentScriptOutputs['test'] = 'value' Get-AzResourceGroup -Location $Location -Name $Name", Arguments = "-Location 'westus' -Name \"*rg2\"", Timeout = XmlConvert.ToTimeSpan("PT1H"), - Identity = new ArmDeploymentScriptManagedIdentity() + Identity = new ArmDeploymentScriptManagedIdentity { IdentityType = ArmDeploymentScriptManagedIdentityType.UserAssigned, UserAssignedIdentities = { -["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity(), +["/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scriptRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uai"] = new UserAssignedIdentity() }, }, }; @@ -310,10 +298,10 @@ public async Task Get_DeploymentScriptsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DeploymentScriptsGet() + public async Task GetAll_DeploymentScriptsList() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Get.json - // this example is just showing the usage of "DeploymentScripts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_ListByResourceGroup.json + // this example is just showing the usage of "DeploymentScripts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -330,16 +318,22 @@ public async Task Exists_DeploymentScriptsGet() // get the collection of this ArmDeploymentScriptResource ArmDeploymentScriptCollection collection = resourceGroupResource.GetArmDeploymentScripts(); - // invoke the operation - string scriptName = "MyDeploymentScript"; - bool result = await collection.ExistsAsync(scriptName); + // invoke the operation and iterate over the result + await foreach (ArmDeploymentScriptResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArmDeploymentScriptData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DeploymentScriptsGet() + public async Task Exists_DeploymentScriptsGet() { // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Get.json // this example is just showing the usage of "DeploymentScripts_Get" operation, for the dependent resources, they will have to be created separately. @@ -361,29 +355,17 @@ public async Task GetIfExists_DeploymentScriptsGet() // invoke the operation string scriptName = "MyDeploymentScript"; - NullableResponse response = await collection.GetIfExistsAsync(scriptName); - ArmDeploymentScriptResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(scriptName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArmDeploymentScriptData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DeploymentScriptsList() + public async Task GetIfExists_DeploymentScriptsGet() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_ListByResourceGroup.json - // this example is just showing the usage of "DeploymentScripts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Get.json + // this example is just showing the usage of "DeploymentScripts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -400,17 +382,23 @@ public async Task GetAll_DeploymentScriptsList() // get the collection of this ArmDeploymentScriptResource ArmDeploymentScriptCollection collection = resourceGroupResource.GetArmDeploymentScripts(); - // invoke the operation and iterate over the result - await foreach (ArmDeploymentScriptResource item in collection.GetAllAsync()) + // invoke the operation + string scriptName = "MyDeploymentScript"; + NullableResponse response = await collection.GetIfExistsAsync(scriptName); + ArmDeploymentScriptResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ArmDeploymentScriptData resourceData = item.Data; + ArmDeploymentScriptData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentScriptResource.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentScriptResource.cs index 599205f94c7b6..80834ced2defb 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentScriptResource.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_ArmDeploymentScriptResource.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.Resources.Samples { public partial class Sample_ArmDeploymentScriptResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_DeploymentScriptsUpdate() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Update.json - // this example is just showing the usage of "DeploymentScripts_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmDeploymentScriptResource created on azure - // for more information of creating ArmDeploymentScriptResource, please refer to the document of ArmDeploymentScriptResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "script-rg"; - string scriptName = "MyDeploymentScript"; - ResourceIdentifier armDeploymentScriptResourceId = ArmDeploymentScriptResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, scriptName); - ArmDeploymentScriptResource armDeploymentScript = client.GetArmDeploymentScriptResource(armDeploymentScriptResourceId); - - // invoke the operation - ArmDeploymentScriptPatch patch = new ArmDeploymentScriptPatch() - { - Tags = -{ -}, - }; - ArmDeploymentScriptResource result = await armDeploymentScript.UpdateAsync(patch); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArmDeploymentScriptData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_DeploymentScriptsGet() @@ -110,33 +74,36 @@ public async Task Delete_DeploymentScriptsDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetArmDeploymentScripts_DeploymentScriptsListBySubscription() + public async Task Update_DeploymentScriptsUpdate() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_ListBySubscription.json - // this example is just showing the usage of "DeploymentScripts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_Update.json + // this example is just showing the usage of "DeploymentScripts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this ArmDeploymentScriptResource created on azure + // for more information of creating ArmDeploymentScriptResource, please refer to the document of ArmDeploymentScriptResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "script-rg"; + string scriptName = "MyDeploymentScript"; + ResourceIdentifier armDeploymentScriptResourceId = ArmDeploymentScriptResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, scriptName); + ArmDeploymentScriptResource armDeploymentScript = client.GetArmDeploymentScriptResource(armDeploymentScriptResourceId); - // invoke the operation and iterate over the result - await foreach (ArmDeploymentScriptResource item in subscriptionResource.GetArmDeploymentScriptsAsync()) + // invoke the operation + ArmDeploymentScriptPatch patch = new ArmDeploymentScriptPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArmDeploymentScriptData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = { }, + }; + ArmDeploymentScriptResource result = await armDeploymentScript.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArmDeploymentScriptData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_DataBoundaryCollection.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_DataBoundaryCollection.cs index fcacaeb4c36e3..b9f2b0e382390 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_DataBoundaryCollection.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_DataBoundaryCollection.cs @@ -28,13 +28,9 @@ public async Task Get_GetDataBoundaryAtScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DataBoundaryResource string scope = "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - DataBoundaryCollection collection = client.GetDataBoundaries(scopeId); + DataBoundaryCollection collection = client.GetDataBoundaries(new ResourceIdentifier(scope)); // invoke the operation DataBoundaryName name = DataBoundaryName.Default; @@ -59,13 +55,9 @@ public async Task Exists_GetDataBoundaryAtScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DataBoundaryResource string scope = "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - DataBoundaryCollection collection = client.GetDataBoundaries(scopeId); + DataBoundaryCollection collection = client.GetDataBoundaries(new ResourceIdentifier(scope)); // invoke the operation DataBoundaryName name = DataBoundaryName.Default; @@ -86,13 +78,9 @@ public async Task GetIfExists_GetDataBoundaryAtScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DataBoundaryResource string scope = "subscriptions/11111111-1111-1111-1111-111111111111/resourcegroups/my-resource-group"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - DataBoundaryCollection collection = client.GetDataBoundaries(scopeId); + DataBoundaryCollection collection = client.GetDataBoundaries(new ResourceIdentifier(scope)); // invoke the operation DataBoundaryName name = DataBoundaryName.Default; diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 19744339dfc1f..415b352059aae 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -16,6 +16,68 @@ namespace Azure.ResourceManager.Resources.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetTemplateSpecs_TemplatesSpecsListBySubscription() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListBySubscription.json + // this example is just showing the usage of "TemplateSpecs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (TemplateSpecResource item in subscriptionResource.GetTemplateSpecsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TemplateSpecData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetArmDeploymentScripts_DeploymentScriptsListBySubscription() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2020-10-01/examples/DeploymentScripts_ListBySubscription.json + // this example is just showing the usage of "DeploymentScripts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ArmDeploymentScriptResource item in subscriptionResource.GetArmDeploymentScriptsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArmDeploymentScriptData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task BicepDecompile_DecompileAnARMJsonTemplateIntoABicepFile() diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecCollection.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecCollection.cs index f2a081f91a076..cc8daf75c10ac 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecCollection.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecCollection.cs @@ -88,10 +88,10 @@ public async Task Get_TemplateSpecsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TemplateSpecsGet() + public async Task GetAll_TemplateSpecsListByResourceGroup() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsGet.json - // this example is just showing the usage of "TemplateSpecs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListByResourceGroup.json + // this example is just showing the usage of "TemplateSpecs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_TemplateSpecsGet() // get the collection of this TemplateSpecResource TemplateSpecCollection collection = resourceGroupResource.GetTemplateSpecs(); - // invoke the operation - string templateSpecName = "simpleTemplateSpec"; - bool result = await collection.ExistsAsync(templateSpecName); + // invoke the operation and iterate over the result + await foreach (TemplateSpecResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TemplateSpecData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TemplateSpecsGet() + public async Task Exists_TemplateSpecsGet() { // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsGet.json // this example is just showing the usage of "TemplateSpecs_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +145,17 @@ public async Task GetIfExists_TemplateSpecsGet() // invoke the operation string templateSpecName = "simpleTemplateSpec"; - NullableResponse response = await collection.GetIfExistsAsync(templateSpecName); - TemplateSpecResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(templateSpecName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TemplateSpecData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TemplateSpecsListByResourceGroup() + public async Task GetIfExists_TemplateSpecsGet() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListByResourceGroup.json - // this example is just showing the usage of "TemplateSpecs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsGet.json + // this example is just showing the usage of "TemplateSpecs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,17 +172,23 @@ public async Task GetAll_TemplateSpecsListByResourceGroup() // get the collection of this TemplateSpecResource TemplateSpecCollection collection = resourceGroupResource.GetTemplateSpecs(); - // invoke the operation and iterate over the result - await foreach (TemplateSpecResource item in collection.GetAllAsync()) + // invoke the operation + string templateSpecName = "simpleTemplateSpec"; + NullableResponse response = await collection.GetIfExistsAsync(templateSpecName); + TemplateSpecResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - TemplateSpecData resourceData = item.Data; + TemplateSpecData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecResource.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecResource.cs index e2223194e12ff..b2eb2e2fd4aeb 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecResource.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecResource.cs @@ -16,43 +16,6 @@ namespace Azure.ResourceManager.Resources.Samples { public partial class Sample_TemplateSpecResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_TemplateSpecsPatch() - { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsPatch.json - // this example is just showing the usage of "TemplateSpecs_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TemplateSpecResource created on azure - // for more information of creating TemplateSpecResource, please refer to the document of TemplateSpecResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "templateSpecRG"; - string templateSpecName = "simpleTemplateSpec"; - ResourceIdentifier templateSpecResourceId = TemplateSpecResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, templateSpecName); - TemplateSpecResource templateSpec = client.GetTemplateSpecResource(templateSpecResourceId); - - // invoke the operation - TemplateSpecPatch patch = new TemplateSpecPatch() - { - Tags = -{ -["myTag"] = "My Value", -}, - }; - TemplateSpecResource result = await templateSpec.UpdateAsync(patch); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TemplateSpecData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_TemplateSpecsGet() @@ -111,33 +74,39 @@ public async Task Delete_TemplateSpecsDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetTemplateSpecs_TemplatesSpecsListBySubscription() + public async Task Update_TemplateSpecsPatch() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsListBySubscription.json - // this example is just showing the usage of "TemplateSpecs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecsPatch.json + // this example is just showing the usage of "TemplateSpecs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this TemplateSpecResource created on azure + // for more information of creating TemplateSpecResource, please refer to the document of TemplateSpecResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "templateSpecRG"; + string templateSpecName = "simpleTemplateSpec"; + ResourceIdentifier templateSpecResourceId = TemplateSpecResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, templateSpecName); + TemplateSpecResource templateSpec = client.GetTemplateSpecResource(templateSpecResourceId); - // invoke the operation and iterate over the result - await foreach (TemplateSpecResource item in subscriptionResource.GetTemplateSpecsAsync()) + // invoke the operation + TemplateSpecPatch patch = new TemplateSpecPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TemplateSpecData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["myTag"] = "My Value" +}, + }; + TemplateSpecResource result = await templateSpec.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TemplateSpecData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecVersionCollection.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecVersionCollection.cs index 91ca28695877b..02e1b21e72939 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecVersionCollection.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecVersionCollection.cs @@ -44,14 +44,12 @@ public async Task CreateOrUpdate_TemplateSpecVersionsCreateUpdate() TemplateSpecVersionData data = new TemplateSpecVersionData(new AzureLocation("eastus")) { Description = "This is version v1.0 of our template content", - MainTemplate = BinaryData.FromObjectAsJson(new Dictionary() + MainTemplate = BinaryData.FromObjectAsJson(new Dictionary { ["$schema"] = "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", ["contentVersion"] = "1.0.0.0", - ["parameters"] = new Dictionary() - { - }, - ["resources"] = new object[] { } + ["parameters"] = new object(), + ["resources"] = Array.Empty() }), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, templateSpecVersion, data); @@ -100,10 +98,10 @@ public async Task Get_TemplateSpecVersionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TemplateSpecVersionsGet() + public async Task GetAll_TemplateSpecVersionsList() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json - // this example is just showing the usage of "TemplateSpecVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsList.json + // this example is just showing the usage of "TemplateSpecVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,16 +119,22 @@ public async Task Exists_TemplateSpecVersionsGet() // get the collection of this TemplateSpecVersionResource TemplateSpecVersionCollection collection = templateSpec.GetTemplateSpecVersions(); - // invoke the operation - string templateSpecVersion = "v1.0"; - bool result = await collection.ExistsAsync(templateSpecVersion); + // invoke the operation and iterate over the result + await foreach (TemplateSpecVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TemplateSpecVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TemplateSpecVersionsGet() + public async Task Exists_TemplateSpecVersionsGet() { // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json // this example is just showing the usage of "TemplateSpecVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -153,29 +157,17 @@ public async Task GetIfExists_TemplateSpecVersionsGet() // invoke the operation string templateSpecVersion = "v1.0"; - NullableResponse response = await collection.GetIfExistsAsync(templateSpecVersion); - TemplateSpecVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(templateSpecVersion); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TemplateSpecVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TemplateSpecVersionsList() + public async Task GetIfExists_TemplateSpecVersionsGet() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsList.json - // this example is just showing the usage of "TemplateSpecVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json + // this example is just showing the usage of "TemplateSpecVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +185,23 @@ public async Task GetAll_TemplateSpecVersionsList() // get the collection of this TemplateSpecVersionResource TemplateSpecVersionCollection collection = templateSpec.GetTemplateSpecVersions(); - // invoke the operation and iterate over the result - await foreach (TemplateSpecVersionResource item in collection.GetAllAsync()) + // invoke the operation + string templateSpecVersion = "v1.0"; + NullableResponse response = await collection.GetIfExistsAsync(templateSpecVersion); + TemplateSpecVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - TemplateSpecVersionData resourceData = item.Data; + TemplateSpecVersionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecVersionResource.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecVersionResource.cs index a96fb0ed37930..b55e4a958786d 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecVersionResource.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TemplateSpecVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_TemplateSpecVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TemplateSpecsPatch() + public async Task Get_TemplateSpecVersionsGet() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsPatch.json - // this example is just showing the usage of "TemplateSpecVersions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json + // this example is just showing the usage of "TemplateSpecVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,14 +38,7 @@ public async Task Update_TemplateSpecsPatch() TemplateSpecVersionResource templateSpecVersion0 = client.GetTemplateSpecVersionResource(templateSpecVersionResourceId); // invoke the operation - TemplateSpecVersionPatch patch = new TemplateSpecVersionPatch() - { - Tags = -{ -["myTag"] = "My Value", -}, - }; - TemplateSpecVersionResource result = await templateSpecVersion0.UpdateAsync(patch); + TemplateSpecVersionResource result = await templateSpecVersion0.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -56,10 +49,10 @@ public async Task Update_TemplateSpecsPatch() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TemplateSpecVersionsGet() + public async Task Delete_TemplateSpecVersionsDelete() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsGet.json - // this example is just showing the usage of "TemplateSpecVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsDelete.json + // this example is just showing the usage of "TemplateSpecVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,21 +69,17 @@ public async Task Get_TemplateSpecVersionsGet() TemplateSpecVersionResource templateSpecVersion0 = client.GetTemplateSpecVersionResource(templateSpecVersionResourceId); // invoke the operation - TemplateSpecVersionResource result = await templateSpecVersion0.GetAsync(); + await templateSpecVersion0.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TemplateSpecVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_TemplateSpecVersionsDelete() + public async Task Update_TemplateSpecsPatch() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsDelete.json - // this example is just showing the usage of "TemplateSpecVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2021-05-01/examples/TemplateSpecVersionsPatch.json + // this example is just showing the usage of "TemplateSpecVersions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +96,20 @@ public async Task Delete_TemplateSpecVersionsDelete() TemplateSpecVersionResource templateSpecVersion0 = client.GetTemplateSpecVersionResource(templateSpecVersionResourceId); // invoke the operation - await templateSpecVersion0.DeleteAsync(WaitUntil.Completed); + TemplateSpecVersionPatch patch = new TemplateSpecVersionPatch + { + Tags = +{ +["myTag"] = "My Value" +}, + }; + TemplateSpecVersionResource result = await templateSpecVersion0.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TemplateSpecVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantDataBoundaryCollection.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantDataBoundaryCollection.cs index 7b51b0394e35d..a900754df6d05 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantDataBoundaryCollection.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantDataBoundaryCollection.cs @@ -28,18 +28,16 @@ public async Task CreateOrUpdate_OptInToDataBoundary() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantDataBoundaryResource TenantDataBoundaryCollection collection = tenantResource.GetTenantDataBoundaries(); // invoke the operation DataBoundaryName name = DataBoundaryName.Default; - DataBoundaryData data = new DataBoundaryData() + DataBoundaryData data = new DataBoundaryData { - Properties = new DataBoundaryProperties() + Properties = new DataBoundaryProperties { DataBoundary = DataBoundaryRegion.EU, }, @@ -66,9 +64,7 @@ public async Task Get_GetDataBoundaryForTenant() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantDataBoundaryResource TenantDataBoundaryCollection collection = tenantResource.GetTenantDataBoundaries(); @@ -96,9 +92,7 @@ public async Task Exists_GetDataBoundaryForTenant() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantDataBoundaryResource TenantDataBoundaryCollection collection = tenantResource.GetTenantDataBoundaries(); @@ -122,9 +116,7 @@ public async Task GetIfExists_GetDataBoundaryForTenant() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantDataBoundaryResource TenantDataBoundaryCollection collection = tenantResource.GetTenantDataBoundaries(); diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantDataBoundaryResource.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantDataBoundaryResource.cs index cea0d42a04a10..7570c284a74a9 100644 --- a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantDataBoundaryResource.cs +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantDataBoundaryResource.cs @@ -18,10 +18,10 @@ public partial class Sample_TenantDataBoundaryResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_OptInToDataBoundary() + public async Task Get_GetDataBoundaryForTenant() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/PutDataBoundary.json - // this example is just showing the usage of "DataBoundaries_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetTenantDataBoundary.json + // this example is just showing the usage of "DataBoundaries_GetTenant" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,15 +35,7 @@ public async Task Update_OptInToDataBoundary() TenantDataBoundaryResource tenantDataBoundary = client.GetTenantDataBoundaryResource(tenantDataBoundaryResourceId); // invoke the operation - DataBoundaryData data = new DataBoundaryData() - { - Properties = new DataBoundaryProperties() - { - DataBoundary = DataBoundaryRegion.EU, - }, - }; - ArmOperation lro = await tenantDataBoundary.UpdateAsync(WaitUntil.Completed, data); - TenantDataBoundaryResource result = lro.Value; + TenantDataBoundaryResource result = await tenantDataBoundary.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +46,10 @@ public async Task Update_OptInToDataBoundary() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDataBoundaryForTenant() + public async Task Update_OptInToDataBoundary() { - // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/GetTenantDataBoundary.json - // this example is just showing the usage of "DataBoundaries_GetTenant" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2024-08-01/examples/PutDataBoundary.json + // this example is just showing the usage of "DataBoundaries_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,7 +63,15 @@ public async Task Get_GetDataBoundaryForTenant() TenantDataBoundaryResource tenantDataBoundary = client.GetTenantDataBoundaryResource(tenantDataBoundaryResourceId); // invoke the operation - TenantDataBoundaryResource result = await tenantDataBoundary.GetAsync(); + DataBoundaryData data = new DataBoundaryData + { + Properties = new DataBoundaryProperties + { + DataBoundary = DataBoundaryRegion.EU, + }, + }; + ArmOperation lro = await tenantDataBoundary.UpdateAsync(WaitUntil.Completed, data); + TenantDataBoundaryResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantResourceExtensions.cs new file mode 100644 index 0000000000000..1792b4ccb0967 --- /dev/null +++ b/sdk/resources/Azure.ResourceManager.Resources/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Resources.Samples +{ + public partial class Sample_TenantResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CalculateDeploymentTemplateHash_CalculateTemplateHash() + { + // Generated from example definition: specification/resources/resource-manager/Microsoft.Resources/stable/2024-03-01/examples/CalculateTemplateHash.json + // this example is just showing the usage of "Deployments_CalculateTemplateHash" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation + BinaryData template = BinaryData.FromObjectAsJson(new Dictionary + { + ["$schema"] = "http://schemas.management.azure.com/deploymentTemplate?api-version=2014-04-01-preview", + ["contentVersion"] = "1.0.0.0", + ["outputs"] = new Dictionary + { + ["string"] = new + { + type = "string", + value = "myvalue", + } + }, + ["parameters"] = new Dictionary + { + ["string"] = new + { + type = "string", + } + }, + ["resources"] = Array.Empty(), + ["variables"] = new Dictionary + { + ["array"] = new object[] + { +"1", +"2", +"3", +"4" + }, + ["bool"] = "true", + ["int"] = "42", + ["object"] = new Dictionary + { + ["object"] = new + { + location = "West US", + vmSize = "Large", + } + }, + ["string"] = "string" + } + }); + TemplateHashResult result = await tenantResource.CalculateDeploymentTemplateHashAsync(template); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} From 2503fd2e5d14910e35693e922c61d841a294f412 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 03:56:22 +0000 Subject: [PATCH 06/11] Update SDK code ex_ku_4 --- .../Sample_FabricCapacityCollection.cs | 87 +- .../Samples/Sample_FabricCapacityResource.cs | 138 +--- .../Sample_SubscriptionResourceExtensions.cs | 108 +++ .../Sample_AutoUpgradeProfileCollection.cs | 96 +-- .../Sample_AutoUpgradeProfileResource.cs | 42 +- .../Sample_ContainerServiceFleetCollection.cs | 120 +-- ...e_ContainerServiceFleetMemberCollection.cs | 96 +-- ...ple_ContainerServiceFleetMemberResource.cs | 38 +- .../Sample_ContainerServiceFleetResource.cs | 78 +- ...ontainerServiceFleetUpdateRunCollection.cs | 126 ++- ..._ContainerServiceFleetUpdateRunResource.cs | 71 +- .../Sample_FleetUpdateStrategyCollection.cs | 112 ++- .../Sample_FleetUpdateStrategyResource.cs | 60 +- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ .../Sample_FluidRelayContainerCollection.cs | 62 +- .../Sample_FluidRelayServerCollection.cs | 220 ++--- .../Sample_FluidRelayServerResource.cs | 74 +- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ .../Samples/Sample_FrontDoorCollection.cs | 303 ++++--- .../Sample_FrontDoorExperimentCollection.cs | 118 +-- .../Sample_FrontDoorExperimentResource.cs | 46 +- ...tDoorNetworkExperimentProfileCollection.cs | 96 +-- ...ontDoorNetworkExperimentProfileResource.cs | 78 +- .../Samples/Sample_FrontDoorResource.cs | 152 ++-- .../Sample_FrontDoorRulesEngineCollection.cs | 226 +++--- .../Sample_FrontDoorRulesEngineResource.cs | 118 +-- ...rWebApplicationFirewallPolicyCollection.cs | 237 +++--- ...oorWebApplicationFirewallPolicyResource.cs | 78 +- .../Sample_FrontendEndpointCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 93 +++ .../Sample_TenantResourceExtensions.cs | 5 +- ...fanaPrivateEndpointConnectionCollection.cs | 84 +- ...rafanaPrivateEndpointConnectionResource.cs | 32 +- ...le_GrafanaPrivateLinkResourceCollection.cs | 48 +- .../Sample_ManagedGrafanaCollection.cs | 173 ++-- .../Samples/Sample_ManagedGrafanaResource.cs | 93 +-- ...e_ManagedPrivateEndpointModelCollection.cs | 107 ++- ...ple_ManagedPrivateEndpointModelResource.cs | 44 +- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ .../Sample_GraphServicesAccountResource.cs | 80 +- ..._GraphServicesAccountResourceCollection.cs | 94 +-- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ ...stConfigurationHcrpAssignmentCollection.cs | 108 ++- ...uestConfigurationHcrpAssignmentResource.cs | 89 +- ...rationVMwarevSphereAssignmentCollection.cs | 108 ++- ...gurationVMwarevSphereAssignmentResource.cs | 89 +- ...uestConfigurationVmAssignmentCollection.cs | 108 ++- ..._GuestConfigurationVmAssignmentResource.cs | 91 +-- ...stConfigurationVmssAssignmentCollection.cs | 108 ++- ...uestConfigurationVmssAssignmentResource.cs | 79 +- .../Sample_CloudHsmClusterCollection.cs | 68 +- ...sterPrivateEndpointConnectionCollection.cs | 66 +- ...lusterPrivateEndpointConnectionResource.cs | 34 +- .../Samples/Sample_CloudHsmClusterResource.cs | 96 +-- .../Samples/Sample_DedicatedHsmCollection.cs | 218 +++-- .../Samples/Sample_DedicatedHsmResource.cs | 163 ++-- .../Sample_SubscriptionResourceExtensions.cs | 112 +++ .../Sample_HDInsightApplicationCollection.cs | 173 ++-- .../Sample_HDInsightApplicationResource.cs | 95 +-- .../Sample_HDInsightClusterCollection.cs | 759 +++++++----------- .../Sample_HDInsightClusterResource.cs | 163 ++-- ...ightPrivateEndpointConnectionCollection.cs | 66 +- ...nsightPrivateEndpointConnectionResource.cs | 48 +- ..._HDInsightPrivateLinkResourceCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 111 +-- .../Sample_HDInsightClusterCollection.cs | 448 +++++------ .../Sample_HDInsightClusterPoolCollection.cs | 207 +++-- .../Sample_HDInsightClusterPoolResource.cs | 82 +- .../Sample_HDInsightClusterResource.cs | 331 ++++---- .../Sample_SubscriptionResourceExtensions.cs | 33 +- .../Samples/Sample_HealthBotCollection.cs | 72 +- .../Samples/Sample_HealthBotResource.cs | 66 +- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ .../Samples/Sample_DicomServiceCollection.cs | 106 +-- .../Samples/Sample_DicomServiceResource.cs | 44 +- .../Samples/Sample_FhirServiceCollection.cs | 219 +++-- .../Samples/Sample_FhirServiceResource.cs | 44 +- ...le_HealthcareApisIotConnectorCollection.cs | 166 ++-- ...mple_HealthcareApisIotConnectorResource.cs | 50 +- ...lthcareApisIotFhirDestinationCollection.cs | 153 ++-- ...ealthcareApisIotFhirDestinationResource.cs | 97 ++- .../Sample_HealthcareApisServiceCollection.cs | 357 ++++---- ...vicePrivateEndpointConnectionCollection.cs | 104 +-- ...ervicePrivateEndpointConnectionResource.cs | 46 +- ...pisServicePrivateLinkResourceCollection.cs | 48 +- .../Sample_HealthcareApisServiceResource.cs | 101 +-- ...ample_HealthcareApisWorkspaceCollection.cs | 96 +-- ...pacePrivateEndpointConnectionCollection.cs | 104 +-- ...kspacePrivateEndpointConnectionResource.cs | 46 +- ...sWorkspacePrivateLinkResourceCollection.cs | 48 +- .../Sample_HealthcareApisWorkspaceResource.cs | 76 +- .../Sample_SubscriptionResourceExtensions.cs | 107 +++ .../Samples/Sample_DeidServiceCollection.cs | 118 ++- .../Samples/Sample_DeidServiceResource.cs | 62 +- ...rvicesPrivateEndpointConnectionResource.cs | 48 +- ...ateEndpointConnectionResourceCollection.cs | 100 +-- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ ...bridContainerServiceAgentPoolCollection.cs | 109 ++- ...HybridContainerServiceAgentPoolResource.cs | 57 +- ...ontainerServiceVirtualNetworkCollection.cs | 153 ++-- ...dContainerServiceVirtualNetworkResource.cs | 36 +- ...ple_HybridContainerServiceVmSkuResource.cs | 46 +- .../Sample_HybridIdentityMetadataResource.cs | 48 +- ...Sample_KubernetesVersionProfileResource.cs | 46 +- .../Sample_ProvisionedClusterResource.cs | 84 +- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ ...e_HybridComputeExtensionValueCollection.cs | 62 +- .../Sample_HybridComputeLicenseCollection.cs | 64 +- ...ple_HybridComputeLicenseProfileResource.cs | 102 ++- .../Sample_HybridComputeLicenseResource.cs | 129 +-- .../Sample_HybridComputeMachineCollection.cs | 90 +-- ...HybridComputeMachineExtensionCollection.cs | 66 +- ...e_HybridComputeMachineExtensionResource.cs | 40 +- .../Sample_HybridComputeMachineResource.cs | 139 ++-- ...putePrivateEndpointConnectionCollection.cs | 96 +-- ...omputePrivateEndpointConnectionResource.cs | 44 +- ...ridComputePrivateLinkResourceCollection.cs | 48 +- ...HybridComputePrivateLinkScopeCollection.cs | 126 +-- ...e_HybridComputePrivateLinkScopeResource.cs | 90 +-- ...ecurityPerimeterConfigurationCollection.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 180 +++++ .../Samples/Sample_EndpointResource.cs | 38 +- .../Sample_EndpointResourceCollection.cs | 236 +++--- ...ConnectivityInventoryResourceCollection.cs | 52 +- .../Sample_PublicCloudConnectorCollection.cs | 113 ++- .../Sample_PublicCloudConnectorResource.cs | 79 +- .../Sample_ServiceConfigurationResource.cs | 36 +- ..._ServiceConfigurationResourceCollection.cs | 192 ++--- .../Sample_SolutionConfigurationCollection.cs | 124 ++- .../Sample_SolutionConfigurationResource.cs | 50 +- .../Samples/Sample_SolutionTypeResource.cs | 32 - .../Sample_SolutionTypeResourceCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 73 +- .../Sample_ConnectedClusterCollection.cs | 70 +- .../Sample_ConnectedClusterResource.cs | 84 +- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ .../Sample_ArtifactManifestCollection.cs | 85 +- .../Sample_ArtifactManifestResource.cs | 34 +- .../Samples/Sample_ArtifactStoreCollection.cs | 76 +- .../Samples/Sample_ArtifactStoreResource.cs | 38 +- .../Samples/Sample_ComponentCollection.cs | 62 +- ...mple_ConfigurationGroupSchemaCollection.cs | 72 +- ...Sample_ConfigurationGroupSchemaResource.cs | 34 +- ...ample_ConfigurationGroupValueCollection.cs | 188 ++--- .../Sample_ConfigurationGroupValueResource.cs | 64 +- .../Sample_NetworkFunctionCollection.cs | 415 +++++----- ...etworkFunctionDefinitionGroupCollection.cs | 60 +- ..._NetworkFunctionDefinitionGroupResource.cs | 32 +- ...workFunctionDefinitionVersionCollection.cs | 305 +++---- ...etworkFunctionDefinitionVersionResource.cs | 90 +-- .../Samples/Sample_NetworkFunctionResource.cs | 120 +-- ...ple_NetworkServiceDesignGroupCollection.cs | 60 +- ...ample_NetworkServiceDesignGroupResource.cs | 32 +- ...e_NetworkServiceDesignVersionCollection.cs | 85 +- ...ple_NetworkServiceDesignVersionResource.cs | 34 +- .../Samples/Sample_PublisherCollection.cs | 102 +-- .../Samples/Sample_PublisherResource.cs | 64 +- .../Samples/Sample_SiteCollection.cs | 123 ++- .../Sample_SiteNetworkServiceCollection.cs | 184 ++--- .../Sample_SiteNetworkServiceResource.cs | 64 +- .../Generated/Samples/Sample_SiteResource.cs | 64 +- .../Sample_SubscriptionResourceExtensions.cs | 174 ++++ ...ample_InformaticaOrganizationCollection.cs | 218 ++--- .../Sample_InformaticaOrganizationResource.cs | 118 +-- ..._InformaticaServerlessRuntimeCollection.cs | 244 +++--- ...le_InformaticaServerlessRuntimeResource.cs | 52 +- ...ample_FirmwareAnalysisSummaryCollection.cs | 140 ++-- ...ple_FirmwareAnalysisWorkspaceCollection.cs | 186 ++--- ...ample_FirmwareAnalysisWorkspaceResource.cs | 117 +-- .../Samples/Sample_IotFirmwareCollection.cs | 191 +++-- .../Samples/Sample_IotFirmwareResource.cs | 345 ++++---- .../Sample_SubscriptionResourceExtensions.cs | 81 ++ .../Samples/Sample_IotCentralAppCollection.cs | 96 +-- .../Samples/Sample_IotCentralAppResource.cs | 137 +--- ...tralPrivateEndpointConnectionCollection.cs | 100 +-- ...entralPrivateEndpointConnectionResource.cs | 48 +- ...IotCentralPrivateLinkResourceCollection.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 134 ++++ ...ple_EventHubConsumerGroupInfoCollection.cs | 92 +-- ...ample_EventHubConsumerGroupInfoResource.cs | 32 +- ..._IotHubCertificateDescriptionCollection.cs | 106 +-- ...le_IotHubCertificateDescriptionResource.cs | 54 +- .../Sample_IotHubDescriptionCollection.cs | 333 ++++---- .../Sample_IotHubDescriptionResource.cs | 110 +-- ...tHubPrivateEndpointConnectionCollection.cs | 92 +-- ...IotHubPrivateEndpointConnectionResource.cs | 18 +- ...ivateEndpointGroupInformationCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 56 ++ .../Samples/Sample_KeyVaultCollection.cs | 102 +-- ...aultPrivateEndpointConnectionCollection.cs | 100 +-- ...yVaultPrivateEndpointConnectionResource.cs | 34 +- .../Samples/Sample_KeyVaultResource.cs | 139 +--- .../Sample_KeyVaultSecretCollection.cs | 64 +- .../Samples/Sample_KeyVaultSecretResource.cs | 30 +- .../Samples/Sample_ManagedHsmCollection.cs | 71 +- ...dHsmPrivateEndpointConnectionCollection.cs | 104 +-- ...gedHsmPrivateEndpointConnectionResource.cs | 32 +- .../Samples/Sample_ManagedHsmResource.cs | 93 +-- .../Sample_SubscriptionResourceExtensions.cs | 114 +++ ...le_KubernetesClusterExtensionCollection.cs | 92 +-- ...mple_KubernetesClusterExtensionResource.cs | 6 +- ...e_KubernetesFluxConfigurationCollection.cs | 260 +++--- ...ple_KubernetesFluxConfigurationResource.cs | 74 +- ...tesSourceControlConfigurationCollection.cs | 122 +-- ...netesSourceControlConfigurationResource.cs | 64 +- 205 files changed, 10367 insertions(+), 11009 deletions(-) create mode 100644 sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs diff --git a/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_FabricCapacityCollection.cs b/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_FabricCapacityCollection.cs index a644931d27b4f..b1c27d0f1b410 100644 --- a/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_FabricCapacityCollection.cs +++ b/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_FabricCapacityCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_FabricCapacityCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACapacity() + public async Task CreateOrUpdate_CreateOrUpdateACapacity() { - // Generated from example definition: 2023-11-01/FabricCapacities_Get.json - // this example is just showing the usage of "FabricCapacity_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2023-11-01/FabricCapacities_CreateOrUpdate.json + // this example is just showing the usage of "FabricCapacity_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,9 @@ public async Task Get_GetACapacity() // invoke the operation string capacityName = "azsdktest"; - FabricCapacityResource result = await collection.GetAsync(capacityName); + FabricCapacityData data = new FabricCapacityData(new AzureLocation("westcentralus"), new FabricCapacityProperties(new FabricCapacityAdministration(new string[] { "azsdktest@microsoft.com", "azsdktest2@microsoft.com" })), new FabricSku("F2", FabricSkuTier.Fabric)); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, capacityName, data); + FabricCapacityResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +54,7 @@ public async Task Get_GetACapacity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACapacity() + public async Task Get_GetACapacity() { // Generated from example definition: 2023-11-01/FabricCapacities_Get.json // this example is just showing the usage of "FabricCapacity_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +76,21 @@ public async Task Exists_GetACapacity() // invoke the operation string capacityName = "azsdktest"; - bool result = await collection.ExistsAsync(capacityName); + FabricCapacityResource result = await collection.GetAsync(capacityName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FabricCapacityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACapacity() + public async Task GetAll_ListCapacitiesByResourceGroup() { - // Generated from example definition: 2023-11-01/FabricCapacities_Get.json - // this example is just showing the usage of "FabricCapacity_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2023-11-01/FabricCapacities_ListByResourceGroup.json + // this example is just showing the usage of "FabricCapacity_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +107,25 @@ public async Task GetIfExists_GetACapacity() // get the collection of this FabricCapacityResource FabricCapacityCollection collection = resourceGroupResource.GetFabricCapacities(); - // invoke the operation - string capacityName = "azsdktest"; - NullableResponse response = await collection.GetIfExistsAsync(capacityName); - FabricCapacityResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (FabricCapacityResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FabricCapacityData resourceData = result.Data; + FabricCapacityData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateACapacity() + public async Task Exists_GetACapacity() { - // Generated from example definition: 2023-11-01/FabricCapacities_CreateOrUpdate.json - // this example is just showing the usage of "FabricCapacity_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2023-11-01/FabricCapacities_Get.json + // this example is just showing the usage of "FabricCapacity_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,26 +144,17 @@ public async Task CreateOrUpdate_CreateOrUpdateACapacity() // invoke the operation string capacityName = "azsdktest"; - FabricCapacityData data = new FabricCapacityData(new AzureLocation("westcentralus"), new FabricCapacityProperties(new FabricCapacityAdministration(new string[] - { -"azsdktest@microsoft.com","azsdktest2@microsoft.com" - })), new FabricSku("F2", FabricSkuTier.Fabric)); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, capacityName, data); - FabricCapacityResource result = lro.Value; + bool result = await collection.ExistsAsync(capacityName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FabricCapacityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCapacitiesByResourceGroup() + public async Task GetIfExists_GetACapacity() { - // Generated from example definition: 2023-11-01/FabricCapacities_ListByResourceGroup.json - // this example is just showing the usage of "FabricCapacity_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2023-11-01/FabricCapacities_Get.json + // this example is just showing the usage of "FabricCapacity_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +171,23 @@ public async Task GetAll_ListCapacitiesByResourceGroup() // get the collection of this FabricCapacityResource FabricCapacityCollection collection = resourceGroupResource.GetFabricCapacities(); - // invoke the operation and iterate over the result - await foreach (FabricCapacityResource item in collection.GetAllAsync()) + // invoke the operation + string capacityName = "azsdktest"; + NullableResponse response = await collection.GetIfExistsAsync(capacityName); + FabricCapacityResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FabricCapacityData resourceData = item.Data; + FabricCapacityData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_FabricCapacityResource.cs b/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_FabricCapacityResource.cs index da01eb30667a2..5e2c7ab6aeead 100644 --- a/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_FabricCapacityResource.cs +++ b/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_FabricCapacityResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Fabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Fabric.Samples @@ -49,10 +48,10 @@ public async Task Get_GetACapacity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateCapacityProperties() + public async Task Delete_DeleteACapacity() { - // Generated from example definition: 2023-11-01/FabricCapacities_Update.json - // this example is just showing the usage of "FabricCapacity_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2023-11-01/FabricCapacities_Delete.json + // this example is just showing the usage of "FabricCapacity_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,34 +67,17 @@ public async Task Update_UpdateCapacityProperties() FabricCapacityResource fabricCapacity = client.GetFabricCapacityResource(fabricCapacityResourceId); // invoke the operation - FabricCapacityPatch patch = new FabricCapacityPatch() - { - Sku = new FabricSku("F8", FabricSkuTier.Fabric), - Tags = -{ -["testKey"] = "testValue", -}, - AdministrationMembers = -{ -"azsdktest2@microsoft.com" -}, - }; - ArmOperation lro = await fabricCapacity.UpdateAsync(WaitUntil.Completed, patch); - FabricCapacityResource result = lro.Value; + await fabricCapacity.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FabricCapacityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACapacity() + public async Task Update_UpdateCapacityProperties() { - // Generated from example definition: 2023-11-01/FabricCapacities_Delete.json - // this example is just showing the usage of "FabricCapacity_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2023-11-01/FabricCapacities_Update.json + // this example is just showing the usage of "FabricCapacity_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,40 +93,23 @@ public async Task Delete_DeleteACapacity() FabricCapacityResource fabricCapacity = client.GetFabricCapacityResource(fabricCapacityResourceId); // invoke the operation - await fabricCapacity.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetFabricCapacities_ListCapacitiesBySubscription() - { - // Generated from example definition: 2023-11-01/FabricCapacities_ListBySubscription.json - // this example is just showing the usage of "FabricCapacity_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "548B7FB7-3B2A-4F46-BB02-66473F1FC22C"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (FabricCapacityResource item in subscriptionResource.GetFabricCapacitiesAsync()) + FabricCapacityPatch patch = new FabricCapacityPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FabricCapacityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new FabricSku("F8", FabricSkuTier.Fabric), + Tags = +{ +["testKey"] = "testValue" +}, + AdministrationMembers = { "azsdktest2@microsoft.com" }, + }; + ArmOperation lro = await fabricCapacity.UpdateAsync(WaitUntil.Completed, patch); + FabricCapacityResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FabricCapacityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -199,36 +164,6 @@ public async Task Suspend_SuspendCapacity() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckFabricCapacityNameAvailability_CheckNameAvailabilityOfACapacity() - { - // Generated from example definition: 2023-11-01/FabricCapacities_CheckNameAvailability.json - // this example is just showing the usage of "FabricCapacities_CheckFabricCapacityNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "548B7FB7-3B2A-4F46-BB02-66473F1FC22C"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("westcentralus"); - FabricNameAvailabilityContent content = new FabricNameAvailabilityContent() - { - Name = "azsdktest", - ResourceType = "Microsoft.Fabric/capacities", - }; - FabricNameAvailabilityResult result = await subscriptionResource.CheckFabricCapacityNameAvailabilityAsync(location, content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSkusForCapacity_ListEligibleSKUsForAnExistingCapacity() @@ -257,32 +192,5 @@ public async Task GetSkusForCapacity_ListEligibleSKUsForAnExistingCapacity() Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSkusFabricCapacities_ListEligibleSKUsForANewCapacity() - { - // Generated from example definition: 2023-11-01/FabricCapacities_ListSkus.json - // this example is just showing the usage of "FabricCapacities_ListSkus" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "548B7FB7-3B2A-4F46-BB02-66473F1FC22C"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (FabricSkuDetailsForNewCapacity item in subscriptionResource.GetSkusFabricCapacitiesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..e7a09ad2cfeaf --- /dev/null +++ b/sdk/fabric/Azure.ResourceManager.Fabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Fabric.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Fabric.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetFabricCapacities_ListCapacitiesBySubscription() + { + // Generated from example definition: 2023-11-01/FabricCapacities_ListBySubscription.json + // this example is just showing the usage of "FabricCapacity_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "548B7FB7-3B2A-4F46-BB02-66473F1FC22C"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (FabricCapacityResource item in subscriptionResource.GetFabricCapacitiesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FabricCapacityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckFabricCapacityNameAvailability_CheckNameAvailabilityOfACapacity() + { + // Generated from example definition: 2023-11-01/FabricCapacities_CheckNameAvailability.json + // this example is just showing the usage of "FabricCapacities_CheckFabricCapacityNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "548B7FB7-3B2A-4F46-BB02-66473F1FC22C"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("westcentralus"); + FabricNameAvailabilityContent content = new FabricNameAvailabilityContent + { + Name = "azsdktest", + ResourceType = "Microsoft.Fabric/capacities", + }; + FabricNameAvailabilityResult result = await subscriptionResource.CheckFabricCapacityNameAvailabilityAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSkusFabricCapacities_ListEligibleSKUsForANewCapacity() + { + // Generated from example definition: 2023-11-01/FabricCapacities_ListSkus.json + // this example is just showing the usage of "FabricCapacities_ListSkus" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "548B7FB7-3B2A-4F46-BB02-66473F1FC22C"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (FabricSkuDetailsForNewCapacity item in subscriptionResource.GetSkusFabricCapacitiesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_AutoUpgradeProfileCollection.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_AutoUpgradeProfileCollection.cs index cedf4a6880dcd..34b4de9575609 100644 --- a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_AutoUpgradeProfileCollection.cs +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_AutoUpgradeProfileCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutoUpgradeProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheAutoUpgradeProfileResourcesByFleet() + public async Task CreateOrUpdate_CreateAnAutoUpgradeProfile() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_ListByFleet.json - // this example is just showing the usage of "AutoUpgradeProfiles_ListByFleet" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_CreateOrUpdate.json + // this example is just showing the usage of "AutoUpgradeProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ListsTheAutoUpgradeProfileResourcesByFleet() // get the collection of this AutoUpgradeProfileResource AutoUpgradeProfileCollection collection = containerServiceFleet.GetAutoUpgradeProfiles(); - // invoke the operation and iterate over the result - await foreach (AutoUpgradeProfileResource item in collection.GetAllAsync()) + // invoke the operation + string autoUpgradeProfileName = "autoupgradeprofile1"; + AutoUpgradeProfileData data = new AutoUpgradeProfileData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoUpgradeProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Channel = ContainerServiceFleetUpgradeChannel.Stable, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autoUpgradeProfileName, data); + AutoUpgradeProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoUpgradeProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_GetsAnAutoUpgradeProfileResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAnAutoUpgradeProfileResource() + public async Task GetAll_ListsTheAutoUpgradeProfileResourcesByFleet() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_Get.json - // this example is just showing the usage of "AutoUpgradeProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_ListByFleet.json + // this example is just showing the usage of "AutoUpgradeProfiles_ListByFleet" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_GetsAnAutoUpgradeProfileResource() // get the collection of this AutoUpgradeProfileResource AutoUpgradeProfileCollection collection = containerServiceFleet.GetAutoUpgradeProfiles(); - // invoke the operation - string autoUpgradeProfileName = "autoupgradeprofile1"; - bool result = await collection.ExistsAsync(autoUpgradeProfileName); + // invoke the operation and iterate over the result + await foreach (AutoUpgradeProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoUpgradeProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAnAutoUpgradeProfileResource() + public async Task Exists_GetsAnAutoUpgradeProfileResource() { // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_Get.json // this example is just showing the usage of "AutoUpgradeProfiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_GetsAnAutoUpgradeProfileResource() // invoke the operation string autoUpgradeProfileName = "autoupgradeprofile1"; - NullableResponse response = await collection.GetIfExistsAsync(autoUpgradeProfileName); - AutoUpgradeProfileResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(autoUpgradeProfileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoUpgradeProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAutoUpgradeProfile() + public async Task GetIfExists_GetsAnAutoUpgradeProfileResource() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_CreateOrUpdate.json - // this example is just showing the usage of "AutoUpgradeProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_Get.json + // this example is just showing the usage of "AutoUpgradeProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_CreateAnAutoUpgradeProfile() // invoke the operation string autoUpgradeProfileName = "autoupgradeprofile1"; - AutoUpgradeProfileData data = new AutoUpgradeProfileData() - { - Channel = ContainerServiceFleetUpgradeChannel.Stable, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autoUpgradeProfileName, data); - AutoUpgradeProfileResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(autoUpgradeProfileName); + AutoUpgradeProfileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoUpgradeProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoUpgradeProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_AutoUpgradeProfileResource.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_AutoUpgradeProfileResource.cs index 111b96f27ef1c..dc50623bd2471 100644 --- a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_AutoUpgradeProfileResource.cs +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_AutoUpgradeProfileResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsAnAutoUpgradeProfileResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAnAutoUpgradeProfile() + public async Task Delete_DeleteAnAutoUpgradeProfileResource() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_CreateOrUpdate.json - // this example is just showing the usage of "AutoUpgradeProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_Delete.json + // this example is just showing the usage of "AutoUpgradeProfiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,7 +61,7 @@ public async Task Update_CreateAnAutoUpgradeProfile() // this example assumes you already have this AutoUpgradeProfileResource created on azure // for more information of creating AutoUpgradeProfileResource, please refer to the document of AutoUpgradeProfileResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "subid1"; string resourceGroupName = "rg1"; string fleetName = "fleet1"; string autoUpgradeProfileName = "autoupgradeprofile1"; @@ -69,26 +69,17 @@ public async Task Update_CreateAnAutoUpgradeProfile() AutoUpgradeProfileResource autoUpgradeProfile = client.GetAutoUpgradeProfileResource(autoUpgradeProfileResourceId); // invoke the operation - AutoUpgradeProfileData data = new AutoUpgradeProfileData() - { - Channel = ContainerServiceFleetUpgradeChannel.Stable, - }; - ArmOperation lro = await autoUpgradeProfile.UpdateAsync(WaitUntil.Completed, data); - AutoUpgradeProfileResource result = lro.Value; + await autoUpgradeProfile.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoUpgradeProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnAutoUpgradeProfileResource() + public async Task Update_CreateAnAutoUpgradeProfile() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_Delete.json - // this example is just showing the usage of "AutoUpgradeProfiles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/AutoUpgradeProfiles_CreateOrUpdate.json + // this example is just showing the usage of "AutoUpgradeProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,7 +88,7 @@ public async Task Delete_DeleteAnAutoUpgradeProfileResource() // this example assumes you already have this AutoUpgradeProfileResource created on azure // for more information of creating AutoUpgradeProfileResource, please refer to the document of AutoUpgradeProfileResource - string subscriptionId = "subid1"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string fleetName = "fleet1"; string autoUpgradeProfileName = "autoupgradeprofile1"; @@ -105,9 +96,18 @@ public async Task Delete_DeleteAnAutoUpgradeProfileResource() AutoUpgradeProfileResource autoUpgradeProfile = client.GetAutoUpgradeProfileResource(autoUpgradeProfileResourceId); // invoke the operation - await autoUpgradeProfile.DeleteAsync(WaitUntil.Completed); + AutoUpgradeProfileData data = new AutoUpgradeProfileData + { + Channel = ContainerServiceFleetUpgradeChannel.Stable, + }; + ArmOperation lro = await autoUpgradeProfile.UpdateAsync(WaitUntil.Completed, data); + AutoUpgradeProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoUpgradeProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetCollection.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetCollection.cs index b1bda518ae64b..4954efbf6ecff 100644 --- a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetCollection.cs +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ContainerServiceFleetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheFleetResourcesInAResourceGroup() + public async Task CreateOrUpdate_CreatesAFleetResourceWithALongRunningOperation() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_ListByResourceGroup.json - // this example is just showing the usage of "Fleets_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_CreateOrUpdate.json + // this example is just showing the usage of "Fleets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,32 @@ public async Task GetAll_ListsTheFleetResourcesInAResourceGroup() // get the collection of this ContainerServiceFleetResource ContainerServiceFleetCollection collection = resourceGroupResource.GetContainerServiceFleets(); - // invoke the operation and iterate over the result - await foreach (ContainerServiceFleetResource item in collection.GetAllAsync()) + // invoke the operation + string fleetName = "fleet1"; + ContainerServiceFleetData data = new ContainerServiceFleetData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HubProfile = new FleetHubProfile + { + DnsPrefix = "dnsprefix1", + AgentProfile = new ContainerServiceFleetAgentProfile + { + VmSize = "Standard_DS1", + }, + }, + Tags = +{ +["archv2"] = "", +["tier"] = "production" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fleetName, data); + ContainerServiceFleetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +102,10 @@ public async Task Get_GetsAFleetResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAFleetResource() + public async Task GetAll_ListsTheFleetResourcesInAResourceGroup() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_Get.json - // this example is just showing the usage of "Fleets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_ListByResourceGroup.json + // this example is just showing the usage of "Fleets_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +122,22 @@ public async Task Exists_GetsAFleetResource() // get the collection of this ContainerServiceFleetResource ContainerServiceFleetCollection collection = resourceGroupResource.GetContainerServiceFleets(); - // invoke the operation - string fleetName = "fleet1"; - bool result = await collection.ExistsAsync(fleetName); + // invoke the operation and iterate over the result + await foreach (ContainerServiceFleetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAFleetResource() + public async Task Exists_GetsAFleetResource() { // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_Get.json // this example is just showing the usage of "Fleets_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +159,17 @@ public async Task GetIfExists_GetsAFleetResource() // invoke the operation string fleetName = "fleet1"; - NullableResponse response = await collection.GetIfExistsAsync(fleetName); - ContainerServiceFleetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(fleetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAFleetResourceWithALongRunningOperation() + public async Task GetIfExists_GetsAFleetResource() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_CreateOrUpdate.json - // this example is just showing the usage of "Fleets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_Get.json + // this example is just showing the usage of "Fleets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,30 +188,21 @@ public async Task CreateOrUpdate_CreatesAFleetResourceWithALongRunningOperation( // invoke the operation string fleetName = "fleet1"; - ContainerServiceFleetData data = new ContainerServiceFleetData(new AzureLocation("East US")) - { - HubProfile = new FleetHubProfile() - { - DnsPrefix = "dnsprefix1", - AgentProfile = new ContainerServiceFleetAgentProfile() - { - VmSize = "Standard_DS1", - }, - }, - Tags = -{ -["archv2"] = "", -["tier"] = "production", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fleetName, data); - ContainerServiceFleetResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(fleetName); + ContainerServiceFleetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetMemberCollection.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetMemberCollection.cs index f3235546127b9..de23acee82774 100644 --- a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetMemberCollection.cs +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetMemberCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerServiceFleetMemberCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheMembersOfAFleet() + public async Task CreateOrUpdate_CreatesAFleetMemberResourceWithALongRunningOperation() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_ListByFleet.json - // this example is just showing the usage of "FleetMembers_ListByFleet" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_Create.json + // this example is just showing the usage of "FleetMembers_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ListsTheMembersOfAFleet() // get the collection of this ContainerServiceFleetMemberResource ContainerServiceFleetMemberCollection collection = containerServiceFleet.GetContainerServiceFleetMembers(); - // invoke the operation and iterate over the result - await foreach (ContainerServiceFleetMemberResource item in collection.GetAllAsync()) + // invoke the operation + string fleetMemberName = "member-1"; + ContainerServiceFleetMemberData data = new ContainerServiceFleetMemberData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetMemberData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ClusterResourceId = new ResourceIdentifier("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster-1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fleetMemberName, data); + ContainerServiceFleetMemberResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetMemberData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetsAFleetMemberResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAFleetMemberResource() + public async Task GetAll_ListsTheMembersOfAFleet() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_Get.json - // this example is just showing the usage of "FleetMembers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_ListByFleet.json + // this example is just showing the usage of "FleetMembers_ListByFleet" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_GetsAFleetMemberResource() // get the collection of this ContainerServiceFleetMemberResource ContainerServiceFleetMemberCollection collection = containerServiceFleet.GetContainerServiceFleetMembers(); - // invoke the operation - string fleetMemberName = "member-1"; - bool result = await collection.ExistsAsync(fleetMemberName); + // invoke the operation and iterate over the result + await foreach (ContainerServiceFleetMemberResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetMemberData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAFleetMemberResource() + public async Task Exists_GetsAFleetMemberResource() { // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_Get.json // this example is just showing the usage of "FleetMembers_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_GetsAFleetMemberResource() // invoke the operation string fleetMemberName = "member-1"; - NullableResponse response = await collection.GetIfExistsAsync(fleetMemberName); - ContainerServiceFleetMemberResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(fleetMemberName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetMemberData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAFleetMemberResourceWithALongRunningOperation() + public async Task GetIfExists_GetsAFleetMemberResource() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_Create.json - // this example is just showing the usage of "FleetMembers_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_Get.json + // this example is just showing the usage of "FleetMembers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_CreatesAFleetMemberResourceWithALongRunningOper // invoke the operation string fleetMemberName = "member-1"; - ContainerServiceFleetMemberData data = new ContainerServiceFleetMemberData() - { - ClusterResourceId = new ResourceIdentifier("/subscriptions/subid1/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster-1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fleetMemberName, data); - ContainerServiceFleetMemberResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(fleetMemberName); + ContainerServiceFleetMemberResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetMemberData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetMemberData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetMemberResource.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetMemberResource.cs index 26d92621adba9..2d8d2e247cdea 100644 --- a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetMemberResource.cs +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetMemberResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsAFleetMemberResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesAFleetMemberResourceSynchronously() + public async Task Delete_DeletesAFleetMemberResourceAsynchronouslyWithALongRunningOperation() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_Update.json - // this example is just showing the usage of "FleetMembers_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_Delete.json + // this example is just showing the usage of "FleetMembers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_UpdatesAFleetMemberResourceSynchronously() ContainerServiceFleetMemberResource containerServiceFleetMember = client.GetContainerServiceFleetMemberResource(containerServiceFleetMemberResourceId); // invoke the operation - ContainerServiceFleetMemberPatch patch = new ContainerServiceFleetMemberPatch() - { - Group = "staging", - }; - ArmOperation lro = await containerServiceFleetMember.UpdateAsync(WaitUntil.Completed, patch); - ContainerServiceFleetMemberResource result = lro.Value; + await containerServiceFleetMember.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetMemberData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAFleetMemberResourceAsynchronouslyWithALongRunningOperation() + public async Task Update_UpdatesAFleetMemberResourceSynchronously() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_Delete.json - // this example is just showing the usage of "FleetMembers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/FleetMembers_Update.json + // this example is just showing the usage of "FleetMembers_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeletesAFleetMemberResourceAsynchronouslyWithALongRunni ContainerServiceFleetMemberResource containerServiceFleetMember = client.GetContainerServiceFleetMemberResource(containerServiceFleetMemberResourceId); // invoke the operation - await containerServiceFleetMember.DeleteAsync(WaitUntil.Completed); + ContainerServiceFleetMemberPatch patch = new ContainerServiceFleetMemberPatch + { + Group = "staging", + }; + ArmOperation lro = await containerServiceFleetMember.UpdateAsync(WaitUntil.Completed, patch); + ContainerServiceFleetMemberResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetMemberData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetResource.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetResource.cs index 4a13c9e2c093f..895927c3677c2 100644 --- a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetResource.cs +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ContainerServiceFleet.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ContainerServiceFleet.Samples @@ -19,41 +18,40 @@ public partial class Sample_ContainerServiceFleetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetContainerServiceFleets_ListsTheFleetResourcesInASubscription() + public async Task Get_GetsAFleetResource() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_ListBySub.json - // this example is just showing the usage of "Fleets_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_Get.json + // this example is just showing the usage of "Fleets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this ContainerServiceFleetResource created on azure + // for more information of creating ContainerServiceFleetResource, please refer to the document of ContainerServiceFleetResource string subscriptionId = "subid1"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rg1"; + string fleetName = "fleet1"; + ResourceIdentifier containerServiceFleetResourceId = ContainerServiceFleetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fleetName); + ContainerServiceFleetResource containerServiceFleet = client.GetContainerServiceFleetResource(containerServiceFleetResourceId); - // invoke the operation and iterate over the result - await foreach (ContainerServiceFleetResource item in subscriptionResource.GetContainerServiceFleetsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + ContainerServiceFleetResource result = await containerServiceFleet.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAFleetResource() + public async Task Delete_DeletesAFleetResourceAsynchronouslyWithALongRunningOperation() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_Get.json - // this example is just showing the usage of "Fleets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_Delete.json + // this example is just showing the usage of "Fleets_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,13 +67,9 @@ public async Task Get_GetsAFleetResource() ContainerServiceFleetResource containerServiceFleet = client.GetContainerServiceFleetResource(containerServiceFleetResourceId); // invoke the operation - ContainerServiceFleetResource result = await containerServiceFleet.GetAsync(); + await containerServiceFleet.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,12 +93,12 @@ public async Task Update_UpdateAFleet() ContainerServiceFleetResource containerServiceFleet = client.GetContainerServiceFleetResource(containerServiceFleetResourceId); // invoke the operation - ContainerServiceFleetPatch patch = new ContainerServiceFleetPatch() + ContainerServiceFleetPatch patch = new ContainerServiceFleetPatch { Tags = { ["env"] = "prod", -["tier"] = "secure", +["tier"] = "secure" }, }; string ifMatch = "dfjkwelr7384"; @@ -118,32 +112,6 @@ public async Task Update_UpdateAFleet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAFleetResourceAsynchronouslyWithALongRunningOperation() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_Delete.json - // this example is just showing the usage of "Fleets_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerServiceFleetResource created on azure - // for more information of creating ContainerServiceFleetResource, please refer to the document of ContainerServiceFleetResource - string subscriptionId = "subid1"; - string resourceGroupName = "rg1"; - string fleetName = "fleet1"; - ResourceIdentifier containerServiceFleetResourceId = ContainerServiceFleetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fleetName); - ContainerServiceFleetResource containerServiceFleet = client.GetContainerServiceFleetResource(containerServiceFleetResourceId); - - // invoke the operation - await containerServiceFleet.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetCredentials_ListsTheUserCredentialsOfAFleet() diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetUpdateRunCollection.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetUpdateRunCollection.cs index caef50dc78f02..2e2d9cbbb5429 100644 --- a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetUpdateRunCollection.cs +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetUpdateRunCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerServiceFleetUpdateRunCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheUpdateRunResourcesByFleet() + public async Task CreateOrUpdate_CreateAnUpdateRun() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateRuns_ListByFleet.json - // this example is just showing the usage of "UpdateRuns_ListByFleet" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateRuns_CreateOrUpdate.json + // this example is just showing the usage of "UpdateRuns_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,32 @@ public async Task GetAll_ListsTheUpdateRunResourcesByFleet() // get the collection of this ContainerServiceFleetUpdateRunResource ContainerServiceFleetUpdateRunCollection collection = containerServiceFleet.GetContainerServiceFleetUpdateRuns(); - // invoke the operation and iterate over the result - await foreach (ContainerServiceFleetUpdateRunResource item in collection.GetAllAsync()) + // invoke the operation + string updateRunName = "run1"; + ContainerServiceFleetUpdateRunData data = new ContainerServiceFleetUpdateRunData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetUpdateRunData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + UpdateStrategyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateStrategies/strategy1"), + StrategyStages = {new ContainerServiceFleetUpdateStage("stage1") +{ +Groups = {new ContainerServiceFleetUpdateGroup("group-a")}, +AfterStageWaitInSeconds = 3600, +}}, + ManagedClusterUpdate = new ContainerServiceFleetManagedClusterUpdate(new ContainerServiceFleetManagedClusterUpgradeSpec(ContainerServiceFleetManagedClusterUpgradeType.Full) + { + KubernetesVersion = "1.26.1", + }) + { + NodeImageSelection = new NodeImageSelection(NodeImageSelectionType.Latest), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, updateRunName, data); + ContainerServiceFleetUpdateRunResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetUpdateRunData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +103,10 @@ public async Task Get_GetsAnUpdateRunResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAnUpdateRunResource() + public async Task GetAll_ListsTheUpdateRunResourcesByFleet() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateRuns_Get.json - // this example is just showing the usage of "UpdateRuns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateRuns_ListByFleet.json + // this example is just showing the usage of "UpdateRuns_ListByFleet" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +124,22 @@ public async Task Exists_GetsAnUpdateRunResource() // get the collection of this ContainerServiceFleetUpdateRunResource ContainerServiceFleetUpdateRunCollection collection = containerServiceFleet.GetContainerServiceFleetUpdateRuns(); - // invoke the operation - string updateRunName = "run1"; - bool result = await collection.ExistsAsync(updateRunName); + // invoke the operation and iterate over the result + await foreach (ContainerServiceFleetUpdateRunResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetUpdateRunData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAnUpdateRunResource() + public async Task Exists_GetsAnUpdateRunResource() { // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateRuns_Get.json // this example is just showing the usage of "UpdateRuns_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +162,17 @@ public async Task GetIfExists_GetsAnUpdateRunResource() // invoke the operation string updateRunName = "run1"; - NullableResponse response = await collection.GetIfExistsAsync(updateRunName); - ContainerServiceFleetUpdateRunResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(updateRunName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetUpdateRunData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnUpdateRun() + public async Task GetIfExists_GetsAnUpdateRunResource() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateRuns_CreateOrUpdate.json - // this example is just showing the usage of "UpdateRuns_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateRuns_Get.json + // this example is just showing the usage of "UpdateRuns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,36 +192,21 @@ public async Task CreateOrUpdate_CreateAnUpdateRun() // invoke the operation string updateRunName = "run1"; - ContainerServiceFleetUpdateRunData data = new ContainerServiceFleetUpdateRunData() - { - UpdateStrategyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateStrategies/strategy1"), - StrategyStages = -{ -new ContainerServiceFleetUpdateStage("stage1") -{ -Groups = -{ -new ContainerServiceFleetUpdateGroup("group-a") -}, -AfterStageWaitInSeconds = 3600, -} -}, - ManagedClusterUpdate = new ContainerServiceFleetManagedClusterUpdate(new ContainerServiceFleetManagedClusterUpgradeSpec(ContainerServiceFleetManagedClusterUpgradeType.Full) - { - KubernetesVersion = "1.26.1", - }) - { - NodeImageSelection = new NodeImageSelection(NodeImageSelectionType.Latest), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, updateRunName, data); - ContainerServiceFleetUpdateRunResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(updateRunName); + ContainerServiceFleetUpdateRunResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceFleetUpdateRunData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetUpdateRunData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetUpdateRunResource.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetUpdateRunResource.cs index c468a3cb00058..f221983e75814 100644 --- a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetUpdateRunResource.cs +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_ContainerServiceFleetUpdateRunResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetsAnUpdateRunResource() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAnUpdateRunResource() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateRuns_Delete.json + // this example is just showing the usage of "UpdateRuns_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceFleetUpdateRunResource created on azure + // for more information of creating ContainerServiceFleetUpdateRunResource, please refer to the document of ContainerServiceFleetUpdateRunResource + string subscriptionId = "subid1"; + string resourceGroupName = "rg1"; + string fleetName = "fleet1"; + string updateRunName = "run1"; + ResourceIdentifier containerServiceFleetUpdateRunResourceId = ContainerServiceFleetUpdateRunResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fleetName, updateRunName); + ContainerServiceFleetUpdateRunResource containerServiceFleetUpdateRun = client.GetContainerServiceFleetUpdateRunResource(containerServiceFleetUpdateRunResourceId); + + // invoke the operation + await containerServiceFleetUpdateRun.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateAnUpdateRun() @@ -69,20 +96,14 @@ public async Task Update_CreateAnUpdateRun() ContainerServiceFleetUpdateRunResource containerServiceFleetUpdateRun = client.GetContainerServiceFleetUpdateRunResource(containerServiceFleetUpdateRunResourceId); // invoke the operation - ContainerServiceFleetUpdateRunData data = new ContainerServiceFleetUpdateRunData() + ContainerServiceFleetUpdateRunData data = new ContainerServiceFleetUpdateRunData { UpdateStrategyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ContainerService/fleets/myFleet/updateStrategies/strategy1"), - StrategyStages = -{ -new ContainerServiceFleetUpdateStage("stage1") -{ -Groups = + StrategyStages = {new ContainerServiceFleetUpdateStage("stage1") { -new ContainerServiceFleetUpdateGroup("group-a") -}, +Groups = {new ContainerServiceFleetUpdateGroup("group-a")}, AfterStageWaitInSeconds = 3600, -} -}, +}}, ManagedClusterUpdate = new ContainerServiceFleetManagedClusterUpdate(new ContainerServiceFleetManagedClusterUpgradeSpec(ContainerServiceFleetManagedClusterUpgradeType.Full) { KubernetesVersion = "1.26.1", @@ -101,33 +122,6 @@ public async Task Update_CreateAnUpdateRun() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnUpdateRunResource() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateRuns_Delete.json - // this example is just showing the usage of "UpdateRuns_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerServiceFleetUpdateRunResource created on azure - // for more information of creating ContainerServiceFleetUpdateRunResource, please refer to the document of ContainerServiceFleetUpdateRunResource - string subscriptionId = "subid1"; - string resourceGroupName = "rg1"; - string fleetName = "fleet1"; - string updateRunName = "run1"; - ResourceIdentifier containerServiceFleetUpdateRunResourceId = ContainerServiceFleetUpdateRunResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fleetName, updateRunName); - ContainerServiceFleetUpdateRunResource containerServiceFleetUpdateRun = client.GetContainerServiceFleetUpdateRunResource(containerServiceFleetUpdateRunResourceId); - - // invoke the operation - await containerServiceFleetUpdateRun.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Skip_SkipsOneOrMoreMemberGroupStageAfterStageWaitSOfAnUpdateRun() @@ -152,7 +146,8 @@ public async Task Skip_SkipsOneOrMoreMemberGroupStageAfterStageWaitSOfAnUpdateRu // invoke the operation ContainerServiceFleetSkipProperties body = new ContainerServiceFleetSkipProperties(new ContainerServiceFleetSkipTarget[] { -new ContainerServiceFleetSkipTarget(ContainerServiceFleetTargetType.Member,"member-one"),new ContainerServiceFleetSkipTarget(ContainerServiceFleetTargetType.AfterStageWait,"stage1") +new ContainerServiceFleetSkipTarget(ContainerServiceFleetTargetType.Member, "member-one"), +new ContainerServiceFleetSkipTarget(ContainerServiceFleetTargetType.AfterStageWait, "stage1") }); ArmOperation lro = await containerServiceFleetUpdateRun.SkipAsync(WaitUntil.Completed, body); ContainerServiceFleetUpdateRunResource result = lro.Value; diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_FleetUpdateStrategyCollection.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_FleetUpdateStrategyCollection.cs index 045a9ff19d3e3..e7a5d0afcfe0e 100644 --- a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_FleetUpdateStrategyCollection.cs +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_FleetUpdateStrategyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FleetUpdateStrategyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheFleetUpdateStrategyResourcesByFleet() + public async Task CreateOrUpdate_CreateAFleetUpdateStrategy() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_ListByFleet.json - // this example is just showing the usage of "FleetUpdateStrategies_ListByFleet" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_CreateOrUpdate.json + // this example is just showing the usage of "FleetUpdateStrategies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_ListTheFleetUpdateStrategyResourcesByFleet() // get the collection of this FleetUpdateStrategyResource FleetUpdateStrategyCollection collection = containerServiceFleet.GetFleetUpdateStrategies(); - // invoke the operation and iterate over the result - await foreach (FleetUpdateStrategyResource item in collection.GetAllAsync()) + // invoke the operation + string updateStrategyName = "strartegy1"; + FleetUpdateStrategyData data = new FleetUpdateStrategyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FleetUpdateStrategyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StrategyStages = {new ContainerServiceFleetUpdateStage("stage1") +{ +Groups = {new ContainerServiceFleetUpdateGroup("group-a")}, +AfterStageWaitInSeconds = 3600, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, updateStrategyName, data); + FleetUpdateStrategyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FleetUpdateStrategyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_GetAFleetUpdateStrategyResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAFleetUpdateStrategyResource() + public async Task GetAll_ListTheFleetUpdateStrategyResourcesByFleet() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_Get.json - // this example is just showing the usage of "FleetUpdateStrategies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_ListByFleet.json + // this example is just showing the usage of "FleetUpdateStrategies_ListByFleet" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_GetAFleetUpdateStrategyResource() // get the collection of this FleetUpdateStrategyResource FleetUpdateStrategyCollection collection = containerServiceFleet.GetFleetUpdateStrategies(); - // invoke the operation - string updateStrategyName = "strategy1"; - bool result = await collection.ExistsAsync(updateStrategyName); + // invoke the operation and iterate over the result + await foreach (FleetUpdateStrategyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FleetUpdateStrategyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAFleetUpdateStrategyResource() + public async Task Exists_GetAFleetUpdateStrategyResource() { // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_Get.json // this example is just showing the usage of "FleetUpdateStrategies_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_GetAFleetUpdateStrategyResource() // invoke the operation string updateStrategyName = "strategy1"; - NullableResponse response = await collection.GetIfExistsAsync(updateStrategyName); - FleetUpdateStrategyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(updateStrategyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FleetUpdateStrategyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAFleetUpdateStrategy() + public async Task GetIfExists_GetAFleetUpdateStrategyResource() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_CreateOrUpdate.json - // this example is just showing the usage of "FleetUpdateStrategies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_Get.json + // this example is just showing the usage of "FleetUpdateStrategies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,29 +183,22 @@ public async Task CreateOrUpdate_CreateAFleetUpdateStrategy() FleetUpdateStrategyCollection collection = containerServiceFleet.GetFleetUpdateStrategies(); // invoke the operation - string updateStrategyName = "strartegy1"; - FleetUpdateStrategyData data = new FleetUpdateStrategyData() - { - StrategyStages = -{ -new ContainerServiceFleetUpdateStage("stage1") -{ -Groups = -{ -new ContainerServiceFleetUpdateGroup("group-a") -}, -AfterStageWaitInSeconds = 3600, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, updateStrategyName, data); - FleetUpdateStrategyResource result = lro.Value; + string updateStrategyName = "strategy1"; + NullableResponse response = await collection.GetIfExistsAsync(updateStrategyName); + FleetUpdateStrategyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FleetUpdateStrategyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FleetUpdateStrategyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_FleetUpdateStrategyResource.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_FleetUpdateStrategyResource.cs index d485bcd8913bf..3b264e4059e41 100644 --- a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_FleetUpdateStrategyResource.cs +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_FleetUpdateStrategyResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAFleetUpdateStrategyResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAFleetUpdateStrategy() + public async Task Delete_DeleteAFleetUpdateStrategyResource() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_CreateOrUpdate.json - // this example is just showing the usage of "FleetUpdateStrategies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_Delete.json + // this example is just showing the usage of "FleetUpdateStrategies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,44 +61,25 @@ public async Task Update_CreateAFleetUpdateStrategy() // this example assumes you already have this FleetUpdateStrategyResource created on azure // for more information of creating FleetUpdateStrategyResource, please refer to the document of FleetUpdateStrategyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "subid1"; string resourceGroupName = "rg1"; string fleetName = "fleet1"; - string updateStrategyName = "strartegy1"; + string updateStrategyName = "strategy1"; ResourceIdentifier fleetUpdateStrategyResourceId = FleetUpdateStrategyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fleetName, updateStrategyName); FleetUpdateStrategyResource fleetUpdateStrategy = client.GetFleetUpdateStrategyResource(fleetUpdateStrategyResourceId); // invoke the operation - FleetUpdateStrategyData data = new FleetUpdateStrategyData() - { - StrategyStages = -{ -new ContainerServiceFleetUpdateStage("stage1") -{ -Groups = -{ -new ContainerServiceFleetUpdateGroup("group-a") -}, -AfterStageWaitInSeconds = 3600, -} -}, - }; - ArmOperation lro = await fleetUpdateStrategy.UpdateAsync(WaitUntil.Completed, data); - FleetUpdateStrategyResource result = lro.Value; + await fleetUpdateStrategy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FleetUpdateStrategyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAFleetUpdateStrategyResource() + public async Task Update_CreateAFleetUpdateStrategy() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_Delete.json - // this example is just showing the usage of "FleetUpdateStrategies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/UpdateStrategies_CreateOrUpdate.json + // this example is just showing the usage of "FleetUpdateStrategies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,17 +88,30 @@ public async Task Delete_DeleteAFleetUpdateStrategyResource() // this example assumes you already have this FleetUpdateStrategyResource created on azure // for more information of creating FleetUpdateStrategyResource, please refer to the document of FleetUpdateStrategyResource - string subscriptionId = "subid1"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string fleetName = "fleet1"; - string updateStrategyName = "strategy1"; + string updateStrategyName = "strartegy1"; ResourceIdentifier fleetUpdateStrategyResourceId = FleetUpdateStrategyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fleetName, updateStrategyName); FleetUpdateStrategyResource fleetUpdateStrategy = client.GetFleetUpdateStrategyResource(fleetUpdateStrategyResourceId); // invoke the operation - await fleetUpdateStrategy.DeleteAsync(WaitUntil.Completed); + FleetUpdateStrategyData data = new FleetUpdateStrategyData + { + StrategyStages = {new ContainerServiceFleetUpdateStage("stage1") +{ +Groups = {new ContainerServiceFleetUpdateGroup("group-a")}, +AfterStageWaitInSeconds = 3600, +}}, + }; + ArmOperation lro = await fleetUpdateStrategy.UpdateAsync(WaitUntil.Completed, data); + FleetUpdateStrategyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FleetUpdateStrategyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..b007779d187f7 --- /dev/null +++ b/sdk/fleet/Azure.ResourceManager.ContainerServiceFleet/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ContainerServiceFleet.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetContainerServiceFleets_ListsTheFleetResourcesInASubscription() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/fleet/preview/2024-05-02-preview/examples/Fleets_ListBySub.json + // this example is just showing the usage of "Fleets_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid1"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceFleetResource item in subscriptionResource.GetContainerServiceFleetsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceFleetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayContainerCollection.cs b/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayContainerCollection.cs index 9165c30b2aaa5..d2747f1ed10fd 100644 --- a/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayContainerCollection.cs +++ b/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayContainerCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetFluidRelayContainerDetails() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFluidRelayContainerDetails() + public async Task GetAll_ListAllFluidRelayContainersInAFluidRelayServer() { - // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_Get.json - // this example is just showing the usage of "FluidRelayContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_ListByFluidRelayServer.json + // this example is just showing the usage of "FluidRelayContainers_ListByFluidRelayServers" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetFluidRelayContainerDetails() // get the collection of this FluidRelayContainerResource FluidRelayContainerCollection collection = fluidRelayServer.GetFluidRelayContainers(); - // invoke the operation - string fluidRelayContainerName = "myFluidRelayContainer"; - bool result = await collection.ExistsAsync(fluidRelayContainerName); + // invoke the operation and iterate over the result + await foreach (FluidRelayContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FluidRelayContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFluidRelayContainerDetails() + public async Task Exists_GetFluidRelayContainerDetails() { // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_Get.json // this example is just showing the usage of "FluidRelayContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetFluidRelayContainerDetails() // invoke the operation string fluidRelayContainerName = "myFluidRelayContainer"; - NullableResponse response = await collection.GetIfExistsAsync(fluidRelayContainerName); - FluidRelayContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(fluidRelayContainerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FluidRelayContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllFluidRelayContainersInAFluidRelayServer() + public async Task GetIfExists_GetFluidRelayContainerDetails() { - // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_ListByFluidRelayServer.json - // this example is just showing the usage of "FluidRelayContainers_ListByFluidRelayServers" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayContainers_Get.json + // this example is just showing the usage of "FluidRelayContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ListAllFluidRelayContainersInAFluidRelayServer() // get the collection of this FluidRelayContainerResource FluidRelayContainerCollection collection = fluidRelayServer.GetFluidRelayContainers(); - // invoke the operation and iterate over the result - await foreach (FluidRelayContainerResource item in collection.GetAllAsync()) + // invoke the operation + string fluidRelayContainerName = "myFluidRelayContainer"; + NullableResponse response = await collection.GetIfExistsAsync(fluidRelayContainerName); + FluidRelayContainerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FluidRelayContainerData resourceData = item.Data; + FluidRelayContainerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayServerCollection.cs b/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayServerCollection.cs index 1dec27a5dc6f1..f6687919a6ec9 100644 --- a/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayServerCollection.cs +++ b/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayServerCollection.cs @@ -18,109 +18,6 @@ namespace Azure.ResourceManager.FluidRelay.Samples { public partial class Sample_FluidRelayServerCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetFluidRelayServerDetails() - { - // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Get.json - // this example is just showing the usage of "FluidRelayServers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "xxxx-xxxx-xxxx-xxxx"; - string resourceGroup = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroup); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this FluidRelayServerResource - FluidRelayServerCollection collection = resourceGroupResource.GetFluidRelayServers(); - - // invoke the operation - string fluidRelayServerName = "myFluidRelayServer"; - FluidRelayServerResource result = await collection.GetAsync(fluidRelayServerName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FluidRelayServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFluidRelayServerDetails() - { - // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Get.json - // this example is just showing the usage of "FluidRelayServers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "xxxx-xxxx-xxxx-xxxx"; - string resourceGroup = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroup); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this FluidRelayServerResource - FluidRelayServerCollection collection = resourceGroupResource.GetFluidRelayServers(); - - // invoke the operation - string fluidRelayServerName = "myFluidRelayServer"; - bool result = await collection.ExistsAsync(fluidRelayServerName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFluidRelayServerDetails() - { - // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Get.json - // this example is just showing the usage of "FluidRelayServers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "xxxx-xxxx-xxxx-xxxx"; - string resourceGroup = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroup); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this FluidRelayServerResource - FluidRelayServerCollection collection = resourceGroupResource.GetFluidRelayServers(); - - // invoke the operation - string fluidRelayServerName = "myFluidRelayServer"; - NullableResponse response = await collection.GetIfExistsAsync(fluidRelayServerName); - FluidRelayServerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FluidRelayServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateAFluidRelayServer() @@ -151,7 +48,7 @@ public async Task CreateOrUpdate_CreateAFluidRelayServer() StorageSku = FluidRelayStorageSku.Basic, Tags = { -["Category"] = "sales", +["Category"] = "sales" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fluidRelayServerName, data); @@ -195,13 +92,13 @@ public async Task CreateOrUpdate_CreateAFluidRelayServerWithAMI() UserAssignedIdentities = { [new ResourceIdentifier("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), -[new ResourceIdentifier("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity() }, }, StorageSku = FluidRelayStorageSku.Basic, Tags = { -["Category"] = "sales", +["Category"] = "sales" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fluidRelayServerName, data); @@ -244,12 +141,12 @@ public async Task CreateOrUpdate_CreateAFluidRelayServerWithCMK() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityForCMK")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityForCMK")] = new UserAssignedIdentity() }, }, - CustomerManagedKeyEncryption = new CmkEncryptionProperties() + CustomerManagedKeyEncryption = new CmkEncryptionProperties { - KeyEncryptionKeyIdentity = new CmkIdentity() + KeyEncryptionKeyIdentity = new CmkIdentity { IdentityType = CmkIdentityType.UserAssigned, UserAssignedIdentityResourceId = new ResourceIdentifier("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityForCMK"), @@ -259,7 +156,7 @@ public async Task CreateOrUpdate_CreateAFluidRelayServerWithCMK() StorageSku = FluidRelayStorageSku.Basic, Tags = { -["Category"] = "sales", +["Category"] = "sales" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fluidRelayServerName, data); @@ -272,6 +169,39 @@ public async Task CreateOrUpdate_CreateAFluidRelayServerWithCMK() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetFluidRelayServerDetails() + { + // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Get.json + // this example is just showing the usage of "FluidRelayServers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "xxxx-xxxx-xxxx-xxxx"; + string resourceGroup = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroup); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this FluidRelayServerResource + FluidRelayServerCollection collection = resourceGroupResource.GetFluidRelayServers(); + + // invoke the operation + string fluidRelayServerName = "myFluidRelayServer"; + FluidRelayServerResource result = await collection.GetAsync(fluidRelayServerName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FluidRelayServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListAllFluidRelayServersInAResourceGroup() @@ -306,5 +236,75 @@ public async Task GetAll_ListAllFluidRelayServersInAResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetFluidRelayServerDetails() + { + // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Get.json + // this example is just showing the usage of "FluidRelayServers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "xxxx-xxxx-xxxx-xxxx"; + string resourceGroup = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroup); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this FluidRelayServerResource + FluidRelayServerCollection collection = resourceGroupResource.GetFluidRelayServers(); + + // invoke the operation + string fluidRelayServerName = "myFluidRelayServer"; + bool result = await collection.ExistsAsync(fluidRelayServerName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetFluidRelayServerDetails() + { + // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Get.json + // this example is just showing the usage of "FluidRelayServers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "xxxx-xxxx-xxxx-xxxx"; + string resourceGroup = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroup); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this FluidRelayServerResource + FluidRelayServerCollection collection = resourceGroupResource.GetFluidRelayServers(); + + // invoke the operation + string fluidRelayServerName = "myFluidRelayServer"; + NullableResponse response = await collection.GetIfExistsAsync(fluidRelayServerName); + FluidRelayServerResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FluidRelayServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayServerResource.cs b/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayServerResource.cs index bf5df64adfbee..39ca733fff0db 100644 --- a/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayServerResource.cs +++ b/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_FluidRelayServerResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.FluidRelay.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.FluidRelay.Samples @@ -49,10 +48,10 @@ public async Task Get_GetFluidRelayServerDetails() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAFluidRelayServer() + public async Task Delete_DeleteAFluidRelayServer() { - // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Update.json - // this example is just showing the usage of "FluidRelayServers_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Delete.json + // this example is just showing the usage of "FluidRelayServers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,28 +67,17 @@ public async Task Update_UpdateAFluidRelayServer() FluidRelayServerResource fluidRelayServer = client.GetFluidRelayServerResource(fluidRelayServerResourceId); // invoke the operation - FluidRelayServerPatch patch = new FluidRelayServerPatch() - { - Tags = -{ -["Category"] = "sales", -}, - }; - FluidRelayServerResource result = await fluidRelayServer.UpdateAsync(patch); + await fluidRelayServer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FluidRelayServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAFluidRelayServer() + public async Task Update_UpdateAFluidRelayServer() { - // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Delete.json - // this example is just showing the usage of "FluidRelayServers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_Update.json + // this example is just showing the usage of "FluidRelayServers_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +93,20 @@ public async Task Delete_DeleteAFluidRelayServer() FluidRelayServerResource fluidRelayServer = client.GetFluidRelayServerResource(fluidRelayServerResourceId); // invoke the operation - await fluidRelayServer.DeleteAsync(WaitUntil.Completed); + FluidRelayServerPatch patch = new FluidRelayServerPatch + { + Tags = +{ +["Category"] = "sales" +}, + }; + FluidRelayServerResource result = await fluidRelayServer.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FluidRelayServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -162,36 +161,5 @@ public async Task GetKeys_GetKeysForAFluidRelayServer() Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetFluidRelayServers_ListAllFluidRelayServersInASubscription() - { - // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_ListBySubscription.json - // this example is just showing the usage of "FluidRelayServers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "xxxx-xxxx-xxxx-xxxx"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (FluidRelayServerResource item in subscriptionResource.GetFluidRelayServersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FluidRelayServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..051bffa5371f5 --- /dev/null +++ b/sdk/fluidrelay/Azure.ResourceManager.FluidRelay/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.FluidRelay.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetFluidRelayServers_ListAllFluidRelayServersInASubscription() + { + // Generated from example definition: specification/fluidrelay/resource-manager/Microsoft.FluidRelay/stable/2022-06-01/examples/FluidRelayServers_ListBySubscription.json + // this example is just showing the usage of "FluidRelayServers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "xxxx-xxxx-xxxx-xxxx"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (FluidRelayServerResource item in subscriptionResource.GetFluidRelayServersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FluidRelayServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorCollection.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorCollection.cs index 07c9b5505b7e5..ba18014cce39d 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorCollection.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_FrontDoorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFrontDoorsInAResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateSpecificFrontDoor() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorList.json - // this example is just showing the usage of "FrontDoors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorCreate.json + // this example is just showing the usage of "FrontDoors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,110 @@ public async Task GetAll_ListFrontDoorsInAResourceGroup() // get the collection of this FrontDoorResource FrontDoorCollection collection = resourceGroupResource.GetFrontDoors(); - // invoke the operation and iterate over the result - await foreach (FrontDoorResource item in collection.GetAllAsync()) + // invoke the operation + string frontDoorName = "frontDoor1"; + FrontDoorData data = new FrontDoorData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + RoutingRules = {new RoutingRuleData +{ +FrontendEndpoints = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), +}}, +AcceptedProtocols = {FrontDoorProtocol.Http}, +PatternsToMatch = {"/*"}, +EnabledState = RoutingRuleEnabledState.Enabled, +RouteConfiguration = new ForwardingConfiguration +{ +BackendPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), +}, +RulesEngineId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), +WebApplicationFirewallPolicyLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), +Name = "routingRule1", +}}, + LoadBalancingSettings = {new FrontDoorLoadBalancingSettingsData +{ +SampleSize = 4, +SuccessfulSamplesRequired = 2, +Name = "loadBalancingSettings1", +}}, + HealthProbeSettings = {new FrontDoorHealthProbeSettingsData +{ +Path = "/", +Protocol = FrontDoorProtocol.Http, +IntervalInSeconds = 120, +HealthProbeMethod = FrontDoorHealthProbeMethod.Head, +EnabledState = HealthProbeEnabled.Enabled, +Name = "healthProbeSettings1", +}}, + BackendPools = {new FrontDoorBackendPool +{ +Backends = {new FrontDoorBackend +{ +Address = "w3.contoso.com", +HttpPort = 80, +HttpsPort = 443, +Priority = 2, +Weight = 1, +}, new FrontDoorBackend +{ +Address = "contoso.com.website-us-west-2.othercloud.net", +PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), +PrivateLinkLocation = new AzureLocation("eastus"), +PrivateLinkApprovalMessage = "Please approve the connection request for this Private Link", +HttpPort = 80, +HttpsPort = 443, +Priority = 1, +Weight = 2, +}, new FrontDoorBackend +{ +Address = "10.0.1.5", +PrivateLinkAlias = "APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice", +PrivateLinkApprovalMessage = "Please approve this request to connect to the Private Link", +HttpPort = 80, +HttpsPort = 443, +Priority = 1, +Weight = 1, +}}, +LoadBalancingSettingsId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/loadBalancingSettings/loadBalancingSettings1"), +HealthProbeSettingsId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/healthProbeSettings/healthProbeSettings1"), +Name = "backendPool1", +}}, + FrontendEndpoints = {new FrontendEndpointData +{ +HostName = "www.contoso.com", +SessionAffinityEnabledState = SessionAffinityEnabledState.Enabled, +SessionAffinityTtlInSeconds = 60, +WebApplicationFirewallPolicyLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), +Name = "frontendEndpoint1", +}, new FrontendEndpointData +{ +HostName = "frontDoor1.azurefd.net", +Name = "default", +}}, + BackendPoolsSettings = new BackendPoolsSettings + { + EnforceCertificateNameCheck = EnforceCertificateNameCheckEnabledState.Enabled, + SendRecvTimeoutInSeconds = 60, + }, + EnabledState = FrontDoorEnabledState.Enabled, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, frontDoorName, data); + FrontDoorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +181,10 @@ public async Task Get_GetFrontDoor() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFrontDoor() + public async Task GetAll_ListFrontDoorsInAResourceGroup() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorGet.json - // this example is just showing the usage of "FrontDoors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorList.json + // this example is just showing the usage of "FrontDoors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +201,22 @@ public async Task Exists_GetFrontDoor() // get the collection of this FrontDoorResource FrontDoorCollection collection = resourceGroupResource.GetFrontDoors(); - // invoke the operation - string frontDoorName = "frontDoor1"; - bool result = await collection.ExistsAsync(frontDoorName); + // invoke the operation and iterate over the result + await foreach (FrontDoorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFrontDoor() + public async Task Exists_GetFrontDoor() { // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorGet.json // this example is just showing the usage of "FrontDoors_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +238,17 @@ public async Task GetIfExists_GetFrontDoor() // invoke the operation string frontDoorName = "frontDoor1"; - NullableResponse response = await collection.GetIfExistsAsync(frontDoorName); - FrontDoorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(frontDoorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateSpecificFrontDoor() + public async Task GetIfExists_GetFrontDoor() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorCreate.json - // this example is just showing the usage of "FrontDoors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorGet.json + // this example is just showing the usage of "FrontDoors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,135 +267,21 @@ public async Task CreateOrUpdate_CreateOrUpdateSpecificFrontDoor() // invoke the operation string frontDoorName = "frontDoor1"; - FrontDoorData data = new FrontDoorData(new AzureLocation("westus")) - { - RoutingRules = -{ -new RoutingRuleData() -{ -FrontendEndpoints = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), -} -}, -AcceptedProtocols = -{ -FrontDoorProtocol.Http -}, -PatternsToMatch = -{ -"/*" -}, -EnabledState = RoutingRuleEnabledState.Enabled, -RouteConfiguration = new ForwardingConfiguration() -{ -BackendPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), -}, -RulesEngineId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), -WebApplicationFirewallPolicyLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), -Name = "routingRule1", -} -}, - LoadBalancingSettings = -{ -new FrontDoorLoadBalancingSettingsData() -{ -SampleSize = 4, -SuccessfulSamplesRequired = 2, -Name = "loadBalancingSettings1", -} -}, - HealthProbeSettings = -{ -new FrontDoorHealthProbeSettingsData() -{ -Path = "/", -Protocol = FrontDoorProtocol.Http, -IntervalInSeconds = 120, -HealthProbeMethod = FrontDoorHealthProbeMethod.Head, -EnabledState = HealthProbeEnabled.Enabled, -Name = "healthProbeSettings1", -} -}, - BackendPools = -{ -new FrontDoorBackendPool() -{ -Backends = -{ -new FrontDoorBackend() -{ -Address = "w3.contoso.com", -HttpPort = 80, -HttpsPort = 443, -Priority = 2, -Weight = 1, -},new FrontDoorBackend() -{ -Address = "contoso.com.website-us-west-2.othercloud.net", -PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), -PrivateLinkLocation = new AzureLocation("eastus"), -PrivateLinkApprovalMessage = "Please approve the connection request for this Private Link", -HttpPort = 80, -HttpsPort = 443, -Priority = 1, -Weight = 2, -},new FrontDoorBackend() -{ -Address = "10.0.1.5", -PrivateLinkAlias = "APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice", -PrivateLinkApprovalMessage = "Please approve this request to connect to the Private Link", -HttpPort = 80, -HttpsPort = 443, -Priority = 1, -Weight = 1, -} -}, -LoadBalancingSettingsId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/loadBalancingSettings/loadBalancingSettings1"), -HealthProbeSettingsId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/healthProbeSettings/healthProbeSettings1"), -Name = "backendPool1", -} -}, - FrontendEndpoints = -{ -new FrontendEndpointData() -{ -HostName = "www.contoso.com", -SessionAffinityEnabledState = SessionAffinityEnabledState.Enabled, -SessionAffinityTtlInSeconds = 60, -WebApplicationFirewallPolicyLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), -Name = "frontendEndpoint1", -},new FrontendEndpointData() -{ -HostName = "frontDoor1.azurefd.net", -Name = "default", -} -}, - BackendPoolsSettings = new BackendPoolsSettings() - { - EnforceCertificateNameCheck = EnforceCertificateNameCheckEnabledState.Enabled, - SendRecvTimeoutInSeconds = 60, - }, - EnabledState = FrontDoorEnabledState.Enabled, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, frontDoorName, data); - FrontDoorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(frontDoorName); + FrontDoorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorExperimentCollection.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorExperimentCollection.cs index c697cd7e1e6ac..67722052d271b 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorExperimentCollection.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorExperimentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FrontDoorExperimentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfExperiments() + public async Task CreateOrUpdate_CreatesAnExperiment() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListExperiments.json - // this example is just showing the usage of "Experiments_ListByProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentCreateExperiment.json + // this example is just showing the usage of "Experiments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,31 @@ public async Task GetAll_GetsAListOfExperiments() // get the collection of this FrontDoorExperimentResource FrontDoorExperimentCollection collection = frontDoorNetworkExperimentProfile.GetFrontDoorExperiments(); - // invoke the operation and iterate over the result - await foreach (FrontDoorExperimentResource item in collection.GetAllAsync()) + // invoke the operation + string experimentName = "MyExperiment"; + FrontDoorExperimentData data = new FrontDoorExperimentData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorExperimentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "this is my first experiment!", + ExperimentEndpointA = new FrontDoorExperimentEndpointProperties + { + Name = "endpoint A", + Endpoint = "endpointA.net", + }, + ExperimentEndpointB = new FrontDoorExperimentEndpointProperties + { + Name = "endpoint B", + Endpoint = "endpointB.net", + }, + EnabledState = FrontDoorExperimentState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, experimentName, data); + FrontDoorExperimentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorExperimentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +102,10 @@ public async Task Get_GetsAnExperimentByExperimentName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAnExperimentByExperimentName() + public async Task GetAll_GetsAListOfExperiments() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetExperiment.json - // this example is just showing the usage of "Experiments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListExperiments.json + // this example is just showing the usage of "Experiments_ListByProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +123,22 @@ public async Task Exists_GetsAnExperimentByExperimentName() // get the collection of this FrontDoorExperimentResource FrontDoorExperimentCollection collection = frontDoorNetworkExperimentProfile.GetFrontDoorExperiments(); - // invoke the operation - string experimentName = "MyExperiment"; - bool result = await collection.ExistsAsync(experimentName); + // invoke the operation and iterate over the result + await foreach (FrontDoorExperimentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorExperimentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAnExperimentByExperimentName() + public async Task Exists_GetsAnExperimentByExperimentName() { // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetExperiment.json // this example is just showing the usage of "Experiments_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +161,17 @@ public async Task GetIfExists_GetsAnExperimentByExperimentName() // invoke the operation string experimentName = "MyExperiment"; - NullableResponse response = await collection.GetIfExistsAsync(experimentName); - FrontDoorExperimentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(experimentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorExperimentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAnExperiment() + public async Task GetIfExists_GetsAnExperimentByExperimentName() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentCreateExperiment.json - // this example is just showing the usage of "Experiments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetExperiment.json + // this example is just showing the usage of "Experiments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,29 +191,21 @@ public async Task CreateOrUpdate_CreatesAnExperiment() // invoke the operation string experimentName = "MyExperiment"; - FrontDoorExperimentData data = new FrontDoorExperimentData(new AzureLocation("placeholder")) - { - Description = "this is my first experiment!", - ExperimentEndpointA = new FrontDoorExperimentEndpointProperties() - { - Name = "endpoint A", - Endpoint = "endpointA.net", - }, - ExperimentEndpointB = new FrontDoorExperimentEndpointProperties() - { - Name = "endpoint B", - Endpoint = "endpointB.net", - }, - EnabledState = FrontDoorExperimentState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, experimentName, data); - FrontDoorExperimentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(experimentName); + FrontDoorExperimentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorExperimentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorExperimentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorExperimentResource.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorExperimentResource.cs index e4a30f3e1ac2c..4064cc68ed0d8 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorExperimentResource.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorExperimentResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsAnExperimentByExperimentName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesAnExperiment() + public async Task Delete_DeletesAnExperiment() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentUpdateExperiment.json - // this example is just showing the usage of "Experiments_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentDeleteExperiment.json + // this example is just showing the usage of "Experiments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,27 +69,17 @@ public async Task Update_UpdatesAnExperiment() FrontDoorExperimentResource frontDoorExperiment = client.GetFrontDoorExperimentResource(frontDoorExperimentResourceId); // invoke the operation - FrontDoorExperimentPatch patch = new FrontDoorExperimentPatch() - { - Description = "string", - EnabledState = FrontDoorExperimentState.Enabled, - }; - ArmOperation lro = await frontDoorExperiment.UpdateAsync(WaitUntil.Completed, patch); - FrontDoorExperimentResource result = lro.Value; + await frontDoorExperiment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorExperimentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAnExperiment() + public async Task Update_UpdatesAnExperiment() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentDeleteExperiment.json - // this example is just showing the usage of "Experiments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentUpdateExperiment.json + // this example is just showing the usage of "Experiments_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +96,19 @@ public async Task Delete_DeletesAnExperiment() FrontDoorExperimentResource frontDoorExperiment = client.GetFrontDoorExperimentResource(frontDoorExperimentResourceId); // invoke the operation - await frontDoorExperiment.DeleteAsync(WaitUntil.Completed); + FrontDoorExperimentPatch patch = new FrontDoorExperimentPatch + { + Description = "string", + EnabledState = FrontDoorExperimentState.Enabled, + }; + ArmOperation lro = await frontDoorExperiment.UpdateAsync(WaitUntil.Completed, patch); + FrontDoorExperimentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorExperimentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -161,7 +161,11 @@ public async Task GetTimeSeriesReport_GetsATimeseriesForAGivenExperiment() FrontDoorExperimentResource frontDoorExperiment = client.GetFrontDoorExperimentResource(frontDoorExperimentResourceId); // invoke the operation - FrontDoorExperimentResourceGetTimeSeriesReportOptions options = new FrontDoorExperimentResourceGetTimeSeriesReportOptions(startOn: DateTimeOffset.Parse("2019-07-21T17:32:28Z"), endOn: DateTimeOffset.Parse("2019-09-21T17:32:28Z"), aggregationInterval: FrontDoorTimeSeriesAggregationInterval.Hourly, timeSeriesType: FrontDoorTimeSeriesType.MeasurementCounts) { }; + DateTimeOffset startOn = DateTimeOffset.Parse("2019-07-21T17:32:28Z"); + DateTimeOffset endOn = DateTimeOffset.Parse("2019-09-21T17:32:28Z"); + FrontDoorTimeSeriesAggregationInterval aggregationInterval = FrontDoorTimeSeriesAggregationInterval.Hourly; + FrontDoorTimeSeriesType timeSeriesType = FrontDoorTimeSeriesType.MeasurementCounts; + FrontDoorExperimentResourceGetTimeSeriesReportOptions options = new FrontDoorExperimentResourceGetTimeSeriesReportOptions(startOn, endOn, aggregationInterval, timeSeriesType); FrontDoorTimeSeriesInfo result = await frontDoorExperiment.GetTimeSeriesReportAsync(options); Console.WriteLine($"Succeeded: {result}"); diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorNetworkExperimentProfileCollection.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorNetworkExperimentProfileCollection.cs index da292ddf2982e..128bdb52ae0af 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorNetworkExperimentProfileCollection.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorNetworkExperimentProfileCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_FrontDoorNetworkExperimentProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNetworkExperimentProfilesInAResourceGroup() + public async Task CreateOrUpdate_CreatesAnNetworkExperimentProfileInAResourceGroup() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListProfiles.json - // this example is just showing the usage of "NetworkExperimentProfiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentCreateProfile.json + // this example is just showing the usage of "NetworkExperimentProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ListNetworkExperimentProfilesInAResourceGroup() // get the collection of this FrontDoorNetworkExperimentProfileResource FrontDoorNetworkExperimentProfileCollection collection = resourceGroupResource.GetFrontDoorNetworkExperimentProfiles(); - // invoke the operation and iterate over the result - await foreach (FrontDoorNetworkExperimentProfileResource item in collection.GetAllAsync()) + // invoke the operation + string profileName = "MyProfile"; + FrontDoorNetworkExperimentProfileData data = new FrontDoorNetworkExperimentProfileData(new AzureLocation("WestUs")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorNetworkExperimentProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EnabledState = FrontDoorExperimentState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + FrontDoorNetworkExperimentProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorNetworkExperimentProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetsAnNetworkExperimentProfileByProfileId() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAnNetworkExperimentProfileByProfileId() + public async Task GetAll_ListNetworkExperimentProfilesInAResourceGroup() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetProfile.json - // this example is just showing the usage of "NetworkExperimentProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListProfiles.json + // this example is just showing the usage of "NetworkExperimentProfiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +110,22 @@ public async Task Exists_GetsAnNetworkExperimentProfileByProfileId() // get the collection of this FrontDoorNetworkExperimentProfileResource FrontDoorNetworkExperimentProfileCollection collection = resourceGroupResource.GetFrontDoorNetworkExperimentProfiles(); - // invoke the operation - string profileName = "MyProfile"; - bool result = await collection.ExistsAsync(profileName); + // invoke the operation and iterate over the result + await foreach (FrontDoorNetworkExperimentProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorNetworkExperimentProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAnNetworkExperimentProfileByProfileId() + public async Task Exists_GetsAnNetworkExperimentProfileByProfileId() { // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetProfile.json // this example is just showing the usage of "NetworkExperimentProfiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +147,17 @@ public async Task GetIfExists_GetsAnNetworkExperimentProfileByProfileId() // invoke the operation string profileName = "MyProfile"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - FrontDoorNetworkExperimentProfileResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(profileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorNetworkExperimentProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAnNetworkExperimentProfileInAResourceGroup() + public async Task GetIfExists_GetsAnNetworkExperimentProfileByProfileId() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentCreateProfile.json - // this example is just showing the usage of "NetworkExperimentProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetProfile.json + // this example is just showing the usage of "NetworkExperimentProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,18 +176,21 @@ public async Task CreateOrUpdate_CreatesAnNetworkExperimentProfileInAResourceGro // invoke the operation string profileName = "MyProfile"; - FrontDoorNetworkExperimentProfileData data = new FrontDoorNetworkExperimentProfileData(new AzureLocation("WestUs")) - { - EnabledState = FrontDoorExperimentState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - FrontDoorNetworkExperimentProfileResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(profileName); + FrontDoorNetworkExperimentProfileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorNetworkExperimentProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorNetworkExperimentProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorNetworkExperimentProfileResource.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorNetworkExperimentProfileResource.cs index c4618f1b5b9ae..24c8b547928d6 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorNetworkExperimentProfileResource.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorNetworkExperimentProfileResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.FrontDoor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.FrontDoor.Samples @@ -19,41 +18,40 @@ public partial class Sample_FrontDoorNetworkExperimentProfileResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetFrontDoorNetworkExperimentProfiles_ListNetworkExperimentProfilesInAResourceGroup() + public async Task Get_GetsAnNetworkExperimentProfileByProfileId() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListProfiles.json - // this example is just showing the usage of "NetworkExperimentProfiles_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetProfile.json + // this example is just showing the usage of "NetworkExperimentProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this FrontDoorNetworkExperimentProfileResource created on azure + // for more information of creating FrontDoorNetworkExperimentProfileResource, please refer to the document of FrontDoorNetworkExperimentProfileResource string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "MyResourceGroup"; + string profileName = "MyProfile"; + ResourceIdentifier frontDoorNetworkExperimentProfileResourceId = FrontDoorNetworkExperimentProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); + FrontDoorNetworkExperimentProfileResource frontDoorNetworkExperimentProfile = client.GetFrontDoorNetworkExperimentProfileResource(frontDoorNetworkExperimentProfileResourceId); - // invoke the operation and iterate over the result - await foreach (FrontDoorNetworkExperimentProfileResource item in subscriptionResource.GetFrontDoorNetworkExperimentProfilesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorNetworkExperimentProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + FrontDoorNetworkExperimentProfileResource result = await frontDoorNetworkExperimentProfile.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorNetworkExperimentProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAnNetworkExperimentProfileByProfileId() + public async Task Delete_DeletesAnNetworkExperimentProfileByProfileName() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentGetProfile.json - // this example is just showing the usage of "NetworkExperimentProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentDeleteProfile.json + // this example is just showing the usage of "NetworkExperimentProfiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,13 +67,9 @@ public async Task Get_GetsAnNetworkExperimentProfileByProfileId() FrontDoorNetworkExperimentProfileResource frontDoorNetworkExperimentProfile = client.GetFrontDoorNetworkExperimentProfileResource(frontDoorNetworkExperimentProfileResourceId); // invoke the operation - FrontDoorNetworkExperimentProfileResource result = await frontDoorNetworkExperimentProfile.GetAsync(); + await frontDoorNetworkExperimentProfile.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorNetworkExperimentProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,12 +93,12 @@ public async Task Update_UpdatesAnExperiment() FrontDoorNetworkExperimentProfileResource frontDoorNetworkExperimentProfile = client.GetFrontDoorNetworkExperimentProfileResource(frontDoorNetworkExperimentProfileResourceId); // invoke the operation - FrontDoorNetworkExperimentProfilePatch patch = new FrontDoorNetworkExperimentProfilePatch() + FrontDoorNetworkExperimentProfilePatch patch = new FrontDoorNetworkExperimentProfilePatch { Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, EnabledState = FrontDoorExperimentState.Enabled, }; @@ -118,32 +112,6 @@ public async Task Update_UpdatesAnExperiment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAnNetworkExperimentProfileByProfileName() - { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentDeleteProfile.json - // this example is just showing the usage of "NetworkExperimentProfiles_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this FrontDoorNetworkExperimentProfileResource created on azure - // for more information of creating FrontDoorNetworkExperimentProfileResource, please refer to the document of FrontDoorNetworkExperimentProfileResource - string subscriptionId = "subid"; - string resourceGroupName = "MyResourceGroup"; - string profileName = "MyProfile"; - ResourceIdentifier frontDoorNetworkExperimentProfileResourceId = FrontDoorNetworkExperimentProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - FrontDoorNetworkExperimentProfileResource frontDoorNetworkExperimentProfile = client.GetFrontDoorNetworkExperimentProfileResource(frontDoorNetworkExperimentProfileResourceId); - - // invoke the operation - await frontDoorNetworkExperimentProfile.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetPreconfiguredEndpoints_GetsAListOfPreconfiguredEndpoints() diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorResource.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorResource.cs index efc517eb8c708..a0e062351ed12 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorResource.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.FrontDoor.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using NUnit.Framework; @@ -20,41 +19,40 @@ public partial class Sample_FrontDoorResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetFrontDoors_ListAllFrontDoors() + public async Task Get_GetFrontDoor() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorListAll.json - // this example is just showing the usage of "FrontDoors_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorGet.json + // this example is just showing the usage of "FrontDoors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this FrontDoorResource created on azure + // for more information of creating FrontDoorResource, please refer to the document of FrontDoorResource string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rg1"; + string frontDoorName = "frontDoor1"; + ResourceIdentifier frontDoorResourceId = FrontDoorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, frontDoorName); + FrontDoorResource frontDoor = client.GetFrontDoorResource(frontDoorResourceId); - // invoke the operation and iterate over the result - await foreach (FrontDoorResource item in subscriptionResource.GetFrontDoorsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + FrontDoorResource result = await frontDoor.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFrontDoor() + public async Task Delete_DeleteFrontDoor() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorGet.json - // this example is just showing the usage of "FrontDoors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorDelete.json + // this example is just showing the usage of "FrontDoors_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,13 +68,9 @@ public async Task Get_GetFrontDoor() FrontDoorResource frontDoor = client.GetFrontDoorResource(frontDoorResourceId); // invoke the operation - FrontDoorResource result = await frontDoor.GetAsync(); + await frontDoor.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -102,50 +96,33 @@ public async Task Update_CreateOrUpdateSpecificFrontDoor() // invoke the operation FrontDoorData data = new FrontDoorData(new AzureLocation("westus")) { - RoutingRules = + RoutingRules = {new RoutingRuleData { -new RoutingRuleData() -{ -FrontendEndpoints = -{ -new WritableSubResource() +FrontendEndpoints = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/frontendEndpoint1"), -},new WritableSubResource() +}, new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/frontendEndpoints/default"), -} -}, -AcceptedProtocols = -{ -FrontDoorProtocol.Http -}, -PatternsToMatch = -{ -"/*" -}, +}}, +AcceptedProtocols = {FrontDoorProtocol.Http}, +PatternsToMatch = {"/*"}, EnabledState = RoutingRuleEnabledState.Enabled, -RouteConfiguration = new ForwardingConfiguration() +RouteConfiguration = new ForwardingConfiguration { BackendPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), }, RulesEngineId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/rulesEngines/rulesEngine1"), WebApplicationFirewallPolicyLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), Name = "routingRule1", -} -}, - LoadBalancingSettings = -{ -new FrontDoorLoadBalancingSettingsData() +}}, + LoadBalancingSettings = {new FrontDoorLoadBalancingSettingsData { SampleSize = 4, SuccessfulSamplesRequired = 2, Name = "loadBalancingSettings1", -} -}, - HealthProbeSettings = -{ -new FrontDoorHealthProbeSettingsData() +}}, + HealthProbeSettings = {new FrontDoorHealthProbeSettingsData { Path = "/", Protocol = FrontDoorProtocol.Http, @@ -153,22 +130,17 @@ public async Task Update_CreateOrUpdateSpecificFrontDoor() HealthProbeMethod = FrontDoorHealthProbeMethod.Head, EnabledState = HealthProbeEnabled.Enabled, Name = "healthProbeSettings1", -} -}, - BackendPools = +}}, + BackendPools = {new FrontDoorBackendPool { -new FrontDoorBackendPool() -{ -Backends = -{ -new FrontDoorBackend() +Backends = {new FrontDoorBackend { Address = "w3.contoso.com", HttpPort = 80, HttpsPort = 443, Priority = 2, Weight = 1, -},new FrontDoorBackend() +}, new FrontDoorBackend { Address = "contoso.com.website-us-west-2.othercloud.net", PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), @@ -178,7 +150,7 @@ public async Task Update_CreateOrUpdateSpecificFrontDoor() HttpsPort = 443, Priority = 1, Weight = 2, -},new FrontDoorBackend() +}, new FrontDoorBackend { Address = "10.0.1.5", PrivateLinkAlias = "APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice", @@ -187,29 +159,24 @@ public async Task Update_CreateOrUpdateSpecificFrontDoor() HttpsPort = 443, Priority = 1, Weight = 1, -} -}, +}}, LoadBalancingSettingsId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/loadBalancingSettings/loadBalancingSettings1"), HealthProbeSettingsId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/healthProbeSettings/healthProbeSettings1"), Name = "backendPool1", -} -}, - FrontendEndpoints = -{ -new FrontendEndpointData() +}}, + FrontendEndpoints = {new FrontendEndpointData { HostName = "www.contoso.com", SessionAffinityEnabledState = SessionAffinityEnabledState.Enabled, SessionAffinityTtlInSeconds = 60, WebApplicationFirewallPolicyLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoorWebApplicationFirewallPolicies/policy1"), Name = "frontendEndpoint1", -},new FrontendEndpointData() +}, new FrontendEndpointData { HostName = "frontDoor1.azurefd.net", Name = "default", -} -}, - BackendPoolsSettings = new BackendPoolsSettings() +}}, + BackendPoolsSettings = new BackendPoolsSettings { EnforceCertificateNameCheck = EnforceCertificateNameCheckEnabledState.Enabled, SendRecvTimeoutInSeconds = 60, @@ -218,7 +185,7 @@ public async Task Update_CreateOrUpdateSpecificFrontDoor() Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await frontDoor.UpdateAsync(WaitUntil.Completed, data); @@ -231,32 +198,6 @@ public async Task Update_CreateOrUpdateSpecificFrontDoor() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteFrontDoor() - { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorDelete.json - // this example is just showing the usage of "FrontDoors_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this FrontDoorResource created on azure - // for more information of creating FrontDoorResource, please refer to the document of FrontDoorResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string frontDoorName = "frontDoor1"; - ResourceIdentifier frontDoorResourceId = FrontDoorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, frontDoorName); - FrontDoorResource frontDoor = client.GetFrontDoorResource(frontDoorResourceId); - - // invoke the operation - await frontDoor.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task ValidateCustomDomain_FrontDoorValidateCustomDomain() @@ -305,10 +246,7 @@ public async Task PurgeContent_PurgeContentFromFrontDoor() FrontDoorResource frontDoor = client.GetFrontDoorResource(frontDoorResourceId); // invoke the operation - FrontDoorEndpointPurgeContent content = new FrontDoorEndpointPurgeContent(new string[] - { -"/pictures.aspx","/pictures/*" - }); + FrontDoorEndpointPurgeContent content = new FrontDoorEndpointPurgeContent(new string[] { "/pictures.aspx", "/pictures/*" }); await frontDoor.PurgeContentAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorRulesEngineCollection.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorRulesEngineCollection.cs index 748bef2d3be3a..fde4a3219dc8b 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorRulesEngineCollection.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorRulesEngineCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_FrontDoorRulesEngineCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRulesEngineConfigurationsInAFrontDoor() + public async Task CreateOrUpdate_CreateOrUpdateASpecificRulesEngineConfiguration() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorRulesEngineList.json - // this example is just showing the usage of "RulesEngines_ListByFrontDoor" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorRulesEngineCreate.json + // this example is just showing the usage of "RulesEngines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,70 @@ public async Task GetAll_ListRulesEngineConfigurationsInAFrontDoor() // get the collection of this FrontDoorRulesEngineResource FrontDoorRulesEngineCollection collection = frontDoor.GetFrontDoorRulesEngines(); - // invoke the operation and iterate over the result - await foreach (FrontDoorRulesEngineResource item in collection.GetAllAsync()) + // invoke the operation + string rulesEngineName = "rulesEngine1"; + FrontDoorRulesEngineData data = new FrontDoorRulesEngineData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRulesEngineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Rules = {new RulesEngineRule("Rule1", 1, new RulesEngineAction +{ +RouteConfigurationOverride = new RedirectConfiguration +{ +RedirectType = FrontDoorRedirectType.Moved, +RedirectProtocol = FrontDoorRedirectProtocol.HttpsOnly, +CustomHost = "www.bing.com", +CustomPath = "/api", +CustomFragment = "fragment", +CustomQueryString = "a=b", +}, +}) +{ +MatchConditions = {new RulesEngineMatchCondition(RulesEngineMatchVariable.RemoteAddr, RulesEngineOperator.GeoMatch, new string[]{"CH"})}, +MatchProcessingBehavior = MatchProcessingBehavior.Stop, +}, new RulesEngineRule("Rule2", 2, new RulesEngineAction +{ +ResponseHeaderActions = {new RulesEngineHeaderAction(RulesEngineHeaderActionType.Overwrite, "Cache-Control") +{ +Value = "public, max-age=31536000", +}}, +}) +{ +MatchConditions = {new RulesEngineMatchCondition(RulesEngineMatchVariable.RequestFilenameExtension, RulesEngineOperator.Equal, new string[]{"jpg"}) +{ +Transforms = {RulesEngineMatchTransform.Lowercase}, +}}, +}, new RulesEngineRule("Rule3", 3, new RulesEngineAction +{ +RouteConfigurationOverride = new ForwardingConfiguration +{ +CustomForwardingPath = null, +ForwardingProtocol = FrontDoorForwardingProtocol.HttpsOnly, +CacheConfiguration = new FrontDoorCacheConfiguration +{ +QueryParameterStripDirective = FrontDoorQuery.StripOnly, +QueryParameters = "a=b,p=q", +DynamicCompression = DynamicCompressionEnabled.Disabled, +CacheDuration = XmlConvert.ToTimeSpan("P1DT12H20M30S"), +}, +BackendPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), +}, +}) +{ +MatchConditions = {new RulesEngineMatchCondition(RulesEngineMatchVariable.RequestHeader, RulesEngineOperator.Equal, new string[]{"allowoverride"}) +{ +Selector = "Rules-Engine-Route-Forward", +IsNegateCondition = false, +Transforms = {RulesEngineMatchTransform.Lowercase}, +}}, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, rulesEngineName, data); + FrontDoorRulesEngineResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRulesEngineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +142,10 @@ public async Task Get_GetRulesEngineConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRulesEngineConfiguration() + public async Task GetAll_ListRulesEngineConfigurationsInAFrontDoor() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorRulesEngineGet.json - // this example is just showing the usage of "RulesEngines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorRulesEngineList.json + // this example is just showing the usage of "RulesEngines_ListByFrontDoor" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +163,22 @@ public async Task Exists_GetRulesEngineConfiguration() // get the collection of this FrontDoorRulesEngineResource FrontDoorRulesEngineCollection collection = frontDoor.GetFrontDoorRulesEngines(); - // invoke the operation - string rulesEngineName = "rulesEngine1"; - bool result = await collection.ExistsAsync(rulesEngineName); + // invoke the operation and iterate over the result + await foreach (FrontDoorRulesEngineResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRulesEngineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRulesEngineConfiguration() + public async Task Exists_GetRulesEngineConfiguration() { // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorRulesEngineGet.json // this example is just showing the usage of "RulesEngines_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +201,17 @@ public async Task GetIfExists_GetRulesEngineConfiguration() // invoke the operation string rulesEngineName = "rulesEngine1"; - NullableResponse response = await collection.GetIfExistsAsync(rulesEngineName); - FrontDoorRulesEngineResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(rulesEngineName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRulesEngineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateASpecificRulesEngineConfiguration() + public async Task GetIfExists_GetRulesEngineConfiguration() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorRulesEngineCreate.json - // this example is just showing the usage of "RulesEngines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorRulesEngineGet.json + // this example is just showing the usage of "RulesEngines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,98 +231,21 @@ public async Task CreateOrUpdate_CreateOrUpdateASpecificRulesEngineConfiguration // invoke the operation string rulesEngineName = "rulesEngine1"; - FrontDoorRulesEngineData data = new FrontDoorRulesEngineData() - { - Rules = -{ -new RulesEngineRule("Rule1",1,new RulesEngineAction() -{ -RouteConfigurationOverride = new RedirectConfiguration() -{ -RedirectType = FrontDoorRedirectType.Moved, -RedirectProtocol = FrontDoorRedirectProtocol.HttpsOnly, -CustomHost = "www.bing.com", -CustomPath = "/api", -CustomFragment = "fragment", -CustomQueryString = "a=b", -}, -}) -{ -MatchConditions = -{ -new RulesEngineMatchCondition(RulesEngineMatchVariable.RemoteAddr,RulesEngineOperator.GeoMatch,new string[] -{ -"CH" -}) -}, -MatchProcessingBehavior = MatchProcessingBehavior.Stop, -},new RulesEngineRule("Rule2",2,new RulesEngineAction() -{ -ResponseHeaderActions = -{ -new RulesEngineHeaderAction(RulesEngineHeaderActionType.Overwrite,"Cache-Control") -{ -Value = "public, max-age=31536000", -} -}, -}) -{ -MatchConditions = -{ -new RulesEngineMatchCondition(RulesEngineMatchVariable.RequestFilenameExtension,RulesEngineOperator.Equal,new string[] -{ -"jpg" -}) -{ -Transforms = -{ -RulesEngineMatchTransform.Lowercase -}, -} -}, -},new RulesEngineRule("Rule3",3,new RulesEngineAction() -{ -RouteConfigurationOverride = new ForwardingConfiguration() -{ -CustomForwardingPath = null, -ForwardingProtocol = FrontDoorForwardingProtocol.HttpsOnly, -CacheConfiguration = new FrontDoorCacheConfiguration() -{ -QueryParameterStripDirective = FrontDoorQuery.StripOnly, -QueryParameters = "a=b,p=q", -DynamicCompression = DynamicCompressionEnabled.Disabled, -CacheDuration = XmlConvert.ToTimeSpan("P1DT12H20M30S"), -}, -BackendPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/frontDoors/frontDoor1/backendPools/backendPool1"), -}, -}) -{ -MatchConditions = -{ -new RulesEngineMatchCondition(RulesEngineMatchVariable.RequestHeader,RulesEngineOperator.Equal,new string[] -{ -"allowoverride" -}) -{ -Selector = "Rules-Engine-Route-Forward", -IsNegateCondition = false, -Transforms = -{ -RulesEngineMatchTransform.Lowercase -}, -} -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, rulesEngineName, data); - FrontDoorRulesEngineResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(rulesEngineName); + FrontDoorRulesEngineResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRulesEngineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRulesEngineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorRulesEngineResource.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorRulesEngineResource.cs index bfde5b0825705..0b9a410d37e28 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorRulesEngineResource.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorRulesEngineResource.cs @@ -48,6 +48,33 @@ public async Task Get_GetRulesEngineConfiguration() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteRulesEngineConfiguration() + { + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorRulesEngineDelete.json + // this example is just showing the usage of "RulesEngines_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this FrontDoorRulesEngineResource created on azure + // for more information of creating FrontDoorRulesEngineResource, please refer to the document of FrontDoorRulesEngineResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string frontDoorName = "frontDoor1"; + string rulesEngineName = "rulesEngine1"; + ResourceIdentifier frontDoorRulesEngineResourceId = FrontDoorRulesEngineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, frontDoorName, rulesEngineName); + FrontDoorRulesEngineResource frontDoorRulesEngine = client.GetFrontDoorRulesEngineResource(frontDoorRulesEngineResourceId); + + // invoke the operation + await frontDoorRulesEngine.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateASpecificRulesEngineConfiguration() @@ -70,13 +97,11 @@ public async Task Update_CreateOrUpdateASpecificRulesEngineConfiguration() FrontDoorRulesEngineResource frontDoorRulesEngine = client.GetFrontDoorRulesEngineResource(frontDoorRulesEngineResourceId); // invoke the operation - FrontDoorRulesEngineData data = new FrontDoorRulesEngineData() + FrontDoorRulesEngineData data = new FrontDoorRulesEngineData { - Rules = -{ -new RulesEngineRule("Rule1",1,new RulesEngineAction() + Rules = {new RulesEngineRule("Rule1", 1, new RulesEngineAction { -RouteConfigurationOverride = new RedirectConfiguration() +RouteConfigurationOverride = new RedirectConfiguration { RedirectType = FrontDoorRedirectType.Moved, RedirectProtocol = FrontDoorRedirectProtocol.HttpsOnly, @@ -87,45 +112,27 @@ public async Task Update_CreateOrUpdateASpecificRulesEngineConfiguration() }, }) { -MatchConditions = -{ -new RulesEngineMatchCondition(RulesEngineMatchVariable.RemoteAddr,RulesEngineOperator.GeoMatch,new string[] -{ -"CH" -}) -}, +MatchConditions = {new RulesEngineMatchCondition(RulesEngineMatchVariable.RemoteAddr, RulesEngineOperator.GeoMatch, new string[]{"CH"})}, MatchProcessingBehavior = MatchProcessingBehavior.Stop, -},new RulesEngineRule("Rule2",2,new RulesEngineAction() -{ -ResponseHeaderActions = +}, new RulesEngineRule("Rule2", 2, new RulesEngineAction { -new RulesEngineHeaderAction(RulesEngineHeaderActionType.Overwrite,"Cache-Control") +ResponseHeaderActions = {new RulesEngineHeaderAction(RulesEngineHeaderActionType.Overwrite, "Cache-Control") { Value = "public, max-age=31536000", -} -}, -}) -{ -MatchConditions = -{ -new RulesEngineMatchCondition(RulesEngineMatchVariable.RequestFilenameExtension,RulesEngineOperator.Equal,new string[] -{ -"jpg" +}}, }) { -Transforms = +MatchConditions = {new RulesEngineMatchCondition(RulesEngineMatchVariable.RequestFilenameExtension, RulesEngineOperator.Equal, new string[]{"jpg"}) { -RulesEngineMatchTransform.Lowercase -}, -} -}, -},new RulesEngineRule("Rule3",3,new RulesEngineAction() +Transforms = {RulesEngineMatchTransform.Lowercase}, +}}, +}, new RulesEngineRule("Rule3", 3, new RulesEngineAction { -RouteConfigurationOverride = new ForwardingConfiguration() +RouteConfigurationOverride = new ForwardingConfiguration { CustomForwardingPath = null, ForwardingProtocol = FrontDoorForwardingProtocol.HttpsOnly, -CacheConfiguration = new FrontDoorCacheConfiguration() +CacheConfiguration = new FrontDoorCacheConfiguration { QueryParameterStripDirective = FrontDoorQuery.StripOnly, QueryParameters = "a=b,p=q", @@ -136,23 +143,13 @@ public async Task Update_CreateOrUpdateASpecificRulesEngineConfiguration() }, }) { -MatchConditions = -{ -new RulesEngineMatchCondition(RulesEngineMatchVariable.RequestHeader,RulesEngineOperator.Equal,new string[] -{ -"allowoverride" -}) +MatchConditions = {new RulesEngineMatchCondition(RulesEngineMatchVariable.RequestHeader, RulesEngineOperator.Equal, new string[]{"allowoverride"}) { Selector = "Rules-Engine-Route-Forward", IsNegateCondition = false, -Transforms = -{ -RulesEngineMatchTransform.Lowercase -}, -} -}, -} -}, +Transforms = {RulesEngineMatchTransform.Lowercase}, +}}, +}}, }; ArmOperation lro = await frontDoorRulesEngine.UpdateAsync(WaitUntil.Completed, data); FrontDoorRulesEngineResource result = lro.Value; @@ -163,32 +160,5 @@ public async Task Update_CreateOrUpdateASpecificRulesEngineConfiguration() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRulesEngineConfiguration() - { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorRulesEngineDelete.json - // this example is just showing the usage of "RulesEngines_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this FrontDoorRulesEngineResource created on azure - // for more information of creating FrontDoorRulesEngineResource, please refer to the document of FrontDoorRulesEngineResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string frontDoorName = "frontDoor1"; - string rulesEngineName = "rulesEngine1"; - ResourceIdentifier frontDoorRulesEngineResourceId = FrontDoorRulesEngineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, frontDoorName, rulesEngineName); - FrontDoorRulesEngineResource frontDoorRulesEngine = client.GetFrontDoorRulesEngineResource(frontDoorRulesEngineResourceId); - - // invoke the operation - await frontDoorRulesEngine.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorWebApplicationFirewallPolicyCollection.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorWebApplicationFirewallPolicyCollection.cs index d59c7d2b71693..c064ec6559e53 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorWebApplicationFirewallPolicyCollection.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorWebApplicationFirewallPolicyCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_FrontDoorWebApplicationFirewallPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllPoliciesInAResourceGroup() + public async Task CreateOrUpdate_CreatesSpecificPolicy() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafListPolicies.json - // this example is just showing the usage of "Policies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyCreateOrUpdate.json + // this example is just showing the usage of "Policies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,73 @@ public async Task GetAll_GetAllPoliciesInAResourceGroup() // get the collection of this FrontDoorWebApplicationFirewallPolicyResource FrontDoorWebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetFrontDoorWebApplicationFirewallPolicies(); - // invoke the operation and iterate over the result - await foreach (FrontDoorWebApplicationFirewallPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string policyName = "Policy1"; + FrontDoorWebApplicationFirewallPolicyData data = new FrontDoorWebApplicationFirewallPolicyData(new AzureLocation("WestUs")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorWebApplicationFirewallPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SkuName = FrontDoorSkuName.PremiumAzureFrontDoor, + PolicySettings = new FrontDoorWebApplicationFirewallPolicySettings + { + EnabledState = PolicyEnabledState.Enabled, + Mode = FrontDoorWebApplicationFirewallPolicyMode.Prevention, + RedirectUri = new Uri("http://www.bing.com"), + CustomBlockResponseStatusCode = 429, + CustomBlockResponseBody = "PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg==", + RequestBodyCheck = PolicyRequestBodyCheck.Disabled, + JavascriptChallengeExpirationInMinutes = 30, + State = WebApplicationFirewallScrubbingState.Enabled, + ScrubbingRules = {new WebApplicationFirewallScrubbingRules(ScrubbingRuleEntryMatchVariable.RequestIPAddress, ScrubbingRuleEntryMatchOperator.EqualsAny) +{ +Selector = null, +State = ScrubbingRuleEntryState.Enabled, +}}, + }, + Rules = {new WebApplicationCustomRule(1, WebApplicationRuleType.RateLimitRule, new WebApplicationRuleMatchCondition[] +{ +new WebApplicationRuleMatchCondition(WebApplicationRuleMatchVariable.RemoteAddr, WebApplicationRuleMatchOperator.IPMatch, new string[]{"192.168.1.0/24", "10.0.0.0/24"}) +}, RuleMatchActionType.Block) +{ +Name = "Rule1", +RateLimitThreshold = 1000, +}, new WebApplicationCustomRule(2, WebApplicationRuleType.MatchRule, new WebApplicationRuleMatchCondition[] +{ +new WebApplicationRuleMatchCondition(WebApplicationRuleMatchVariable.RemoteAddr, WebApplicationRuleMatchOperator.GeoMatch, new string[]{"CH"}), +new WebApplicationRuleMatchCondition(WebApplicationRuleMatchVariable.RequestHeader, WebApplicationRuleMatchOperator.Contains, new string[]{"windows"}) +{ +Selector = "UserAgent", +Transforms = {WebApplicationRuleMatchTransformType.Lowercase}, +} +}, RuleMatchActionType.Block) +{ +Name = "Rule2", +}}, + ManagedRuleSets = {new ManagedRuleSet("DefaultRuleSet", "1.0") +{ +RuleSetAction = ManagedRuleSetActionType.Block, +Exclusions = {new ManagedRuleExclusion(ManagedRuleExclusionMatchVariable.RequestHeaderNames, ManagedRuleExclusionSelectorMatchOperator.EqualsValue, "User-Agent")}, +RuleGroupOverrides = {new ManagedRuleGroupOverride("SQLI") +{ +Exclusions = {new ManagedRuleExclusion(ManagedRuleExclusionMatchVariable.RequestCookieNames, ManagedRuleExclusionSelectorMatchOperator.StartsWith, "token")}, +Rules = {new ManagedRuleOverride("942100") +{ +EnabledState = ManagedRuleEnabledState.Enabled, +Action = RuleMatchActionType.Redirect, +Exclusions = {new ManagedRuleExclusion(ManagedRuleExclusionMatchVariable.QueryStringArgNames, ManagedRuleExclusionSelectorMatchOperator.EqualsValue, "query")}, +}, new ManagedRuleOverride("942110") +{ +EnabledState = ManagedRuleEnabledState.Disabled, +}}, +}}, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + FrontDoorWebApplicationFirewallPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorWebApplicationFirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +143,10 @@ public async Task Get_GetPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPolicy() + public async Task GetAll_GetAllPoliciesInAResourceGroup() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyGet.json - // this example is just showing the usage of "Policies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafListPolicies.json + // this example is just showing the usage of "Policies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +163,22 @@ public async Task Exists_GetPolicy() // get the collection of this FrontDoorWebApplicationFirewallPolicyResource FrontDoorWebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetFrontDoorWebApplicationFirewallPolicies(); - // invoke the operation - string policyName = "Policy1"; - bool result = await collection.ExistsAsync(policyName); + // invoke the operation and iterate over the result + await foreach (FrontDoorWebApplicationFirewallPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorWebApplicationFirewallPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPolicy() + public async Task Exists_GetPolicy() { // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyGet.json // this example is just showing the usage of "Policies_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +200,17 @@ public async Task GetIfExists_GetPolicy() // invoke the operation string policyName = "Policy1"; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - FrontDoorWebApplicationFirewallPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorWebApplicationFirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesSpecificPolicy() + public async Task GetIfExists_GetPolicy() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyCreateOrUpdate.json - // this example is just showing the usage of "Policies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyGet.json + // this example is just showing the usage of "Policies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,106 +229,21 @@ public async Task CreateOrUpdate_CreatesSpecificPolicy() // invoke the operation string policyName = "Policy1"; - FrontDoorWebApplicationFirewallPolicyData data = new FrontDoorWebApplicationFirewallPolicyData(new AzureLocation("WestUs")) - { - SkuName = FrontDoorSkuName.PremiumAzureFrontDoor, - PolicySettings = new FrontDoorWebApplicationFirewallPolicySettings() - { - EnabledState = PolicyEnabledState.Enabled, - Mode = FrontDoorWebApplicationFirewallPolicyMode.Prevention, - RedirectUri = new Uri("http://www.bing.com"), - CustomBlockResponseStatusCode = 429, - CustomBlockResponseBody = "PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg==", - RequestBodyCheck = PolicyRequestBodyCheck.Disabled, - JavascriptChallengeExpirationInMinutes = 30, - State = WebApplicationFirewallScrubbingState.Enabled, - ScrubbingRules = -{ -new WebApplicationFirewallScrubbingRules(ScrubbingRuleEntryMatchVariable.RequestIPAddress,ScrubbingRuleEntryMatchOperator.EqualsAny) -{ -Selector = null, -State = ScrubbingRuleEntryState.Enabled, -} -}, - }, - Rules = -{ -new WebApplicationCustomRule(1,WebApplicationRuleType.RateLimitRule,new WebApplicationRuleMatchCondition[] -{ -new WebApplicationRuleMatchCondition(WebApplicationRuleMatchVariable.RemoteAddr,WebApplicationRuleMatchOperator.IPMatch,new string[] -{ -"192.168.1.0/24","10.0.0.0/24" -}) -},RuleMatchActionType.Block) -{ -Name = "Rule1", -RateLimitThreshold = 1000, -},new WebApplicationCustomRule(2,WebApplicationRuleType.MatchRule,new WebApplicationRuleMatchCondition[] -{ -new WebApplicationRuleMatchCondition(WebApplicationRuleMatchVariable.RemoteAddr,WebApplicationRuleMatchOperator.GeoMatch,new string[] -{ -"CH" -}),new WebApplicationRuleMatchCondition(WebApplicationRuleMatchVariable.RequestHeader,WebApplicationRuleMatchOperator.Contains,new string[] -{ -"windows" -}) -{ -Selector = "UserAgent", -Transforms = -{ -WebApplicationRuleMatchTransformType.Lowercase -}, -} -},RuleMatchActionType.Block) -{ -Name = "Rule2", -} -}, - ManagedRuleSets = -{ -new ManagedRuleSet("DefaultRuleSet","1.0") -{ -RuleSetAction = ManagedRuleSetActionType.Block, -Exclusions = -{ -new ManagedRuleExclusion(ManagedRuleExclusionMatchVariable.RequestHeaderNames,ManagedRuleExclusionSelectorMatchOperator.EqualsValue,"User-Agent") -}, -RuleGroupOverrides = -{ -new ManagedRuleGroupOverride("SQLI") -{ -Exclusions = -{ -new ManagedRuleExclusion(ManagedRuleExclusionMatchVariable.RequestCookieNames,ManagedRuleExclusionSelectorMatchOperator.StartsWith,"token") -}, -Rules = -{ -new ManagedRuleOverride("942100") -{ -EnabledState = ManagedRuleEnabledState.Enabled, -Action = RuleMatchActionType.Redirect, -Exclusions = -{ -new ManagedRuleExclusion(ManagedRuleExclusionMatchVariable.QueryStringArgNames,ManagedRuleExclusionSelectorMatchOperator.EqualsValue,"query") -}, -},new ManagedRuleOverride("942110") -{ -EnabledState = ManagedRuleEnabledState.Disabled, -} -}, -} -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - FrontDoorWebApplicationFirewallPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + FrontDoorWebApplicationFirewallPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorWebApplicationFirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorWebApplicationFirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorWebApplicationFirewallPolicyResource.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorWebApplicationFirewallPolicyResource.cs index 220c6b0689146..966b0bcf19126 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorWebApplicationFirewallPolicyResource.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontDoorWebApplicationFirewallPolicyResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.FrontDoor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.FrontDoor.Samples { public partial class Sample_FrontDoorWebApplicationFirewallPolicyResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetFrontDoorWebApplicationFirewallPoliciesByFrontDoorWebApplicationFirewallPolicy_GetAllPoliciesInAResourceGroup() - { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafListPoliciesUnderSubscription.json - // this example is just showing the usage of "Policies_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (FrontDoorWebApplicationFirewallPolicyResource item in subscriptionResource.GetFrontDoorWebApplicationFirewallPoliciesByFrontDoorWebApplicationFirewallPolicyAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorWebApplicationFirewallPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetPolicy() @@ -80,10 +48,10 @@ public async Task Get_GetPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchesSpecificPolicy() + public async Task Delete_DeleteProtectionPolicy() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyPatch.json - // this example is just showing the usage of "Policies_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyDelete.json + // this example is just showing the usage of "Policies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,30 +67,17 @@ public async Task Update_PatchesSpecificPolicy() FrontDoorWebApplicationFirewallPolicyResource frontDoorWebApplicationFirewallPolicy = client.GetFrontDoorWebApplicationFirewallPolicyResource(frontDoorWebApplicationFirewallPolicyResourceId); // invoke the operation - FrontDoorWebApplicationFirewallPolicyPatch patch = new FrontDoorWebApplicationFirewallPolicyPatch() - { - Tags = -{ -["key1"] = "value1", -["key2"] = "value2", -}, - }; - ArmOperation lro = await frontDoorWebApplicationFirewallPolicy.UpdateAsync(WaitUntil.Completed, patch); - FrontDoorWebApplicationFirewallPolicyResource result = lro.Value; + await frontDoorWebApplicationFirewallPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorWebApplicationFirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteProtectionPolicy() + public async Task Update_PatchesSpecificPolicy() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyDelete.json - // this example is just showing the usage of "Policies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafPolicyPatch.json + // this example is just showing the usage of "Policies_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,9 +93,22 @@ public async Task Delete_DeleteProtectionPolicy() FrontDoorWebApplicationFirewallPolicyResource frontDoorWebApplicationFirewallPolicy = client.GetFrontDoorWebApplicationFirewallPolicyResource(frontDoorWebApplicationFirewallPolicyResourceId); // invoke the operation - await frontDoorWebApplicationFirewallPolicy.DeleteAsync(WaitUntil.Completed); + FrontDoorWebApplicationFirewallPolicyPatch patch = new FrontDoorWebApplicationFirewallPolicyPatch + { + Tags = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + }; + ArmOperation lro = await frontDoorWebApplicationFirewallPolicy.UpdateAsync(WaitUntil.Completed, patch); + FrontDoorWebApplicationFirewallPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorWebApplicationFirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontendEndpointCollection.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontendEndpointCollection.cs index a2d1ba4fdfbcf..a7ebc2114977f 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontendEndpointCollection.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_FrontendEndpointCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_FrontendEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFrontendEndpointsInAFrontDoor() + public async Task Get_GetFrontendEndpoint() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorFrontendEndpointList.json - // this example is just showing the usage of "FrontendEndpoints_ListByFrontDoor" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorFrontendEndpointGet.json + // this example is just showing the usage of "FrontendEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListFrontendEndpointsInAFrontDoor() // get the collection of this FrontendEndpointResource FrontendEndpointCollection collection = frontDoor.GetFrontendEndpoints(); - // invoke the operation and iterate over the result - await foreach (FrontendEndpointResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontendEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string frontendEndpointName = "frontendEndpoint1"; + FrontendEndpointResource result = await collection.GetAsync(frontendEndpointName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontendEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFrontendEndpoint() + public async Task GetAll_ListFrontendEndpointsInAFrontDoor() { - // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorFrontendEndpointGet.json - // this example is just showing the usage of "FrontendEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorFrontendEndpointList.json + // this example is just showing the usage of "FrontendEndpoints_ListByFrontDoor" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetFrontendEndpoint() // get the collection of this FrontendEndpointResource FrontendEndpointCollection collection = frontDoor.GetFrontendEndpoints(); - // invoke the operation - string frontendEndpointName = "frontendEndpoint1"; - FrontendEndpointResource result = await collection.GetAsync(frontendEndpointName); + // invoke the operation and iterate over the result + await foreach (FrontendEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontendEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontendEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 67b9cdebca35d..685931fce4f0c 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.FrontDoor.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetFrontDoorWebApplicationFirewallPoliciesByFrontDoorWebApplicationFirewallPolicy_GetAllPoliciesInAResourceGroup() + { + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2024-02-01/examples/WafListPoliciesUnderSubscription.json + // this example is just showing the usage of "Policies_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (FrontDoorWebApplicationFirewallPolicyResource item in subscriptionResource.GetFrontDoorWebApplicationFirewallPoliciesByFrontDoorWebApplicationFirewallPolicyAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorWebApplicationFirewallPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetManagedRuleSets_ListPoliciesManagedRuleSetsInAResourceGroup() @@ -68,5 +99,67 @@ public async Task CheckFrontDoorNameAvailability_CheckNameAvailabilityWithSubscr Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetFrontDoors_ListAllFrontDoors() + { + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2021-06-01/examples/FrontdoorListAll.json + // this example is just showing the usage of "FrontDoors_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (FrontDoorResource item in subscriptionResource.GetFrontDoorsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetFrontDoorNetworkExperimentProfiles_ListNetworkExperimentProfilesInAResourceGroup() + { + // Generated from example definition: specification/frontdoor/resource-manager/Microsoft.Network/stable/2019-11-01/examples/NetworkExperimentListProfiles.json + // this example is just showing the usage of "NetworkExperimentProfiles_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (FrontDoorNetworkExperimentProfileResource item in subscriptionResource.GetFrontDoorNetworkExperimentProfilesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorNetworkExperimentProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index 1a9ee6c570688..6e1d2c0eae26e 100644 --- a/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/frontdoor/Azure.ResourceManager.FrontDoor/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.FrontDoor.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.FrontDoor.Samples @@ -28,9 +29,7 @@ public async Task CheckFrontDoorNameAvailability_CheckNameAvailability() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation FrontDoorNameAvailabilityContent content = new FrontDoorNameAvailabilityContent("sampleName", FrontDoorResourceType.MicrosoftNetworkFrontDoors); diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateEndpointConnectionCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateEndpointConnectionCollection.cs index 79060f9a351b8..2ad53dc6d5e50 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateEndpointConnectionCollection.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateEndpointConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_GrafanaPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGet() + public async Task CreateOrUpdate_PrivateEndpointConnectionsApprove() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Approve.json + // this example is just showing the usage of "PrivateEndpointConnections_Approve" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,9 @@ public async Task Get_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "myConnection"; - GrafanaPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + GrafanaPrivateEndpointConnectionData data = new GrafanaPrivateEndpointConnectionData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + GrafanaPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGet() + public async Task Get_PrivateEndpointConnectionsGet() { // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +76,21 @@ public async Task Exists_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "myConnection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + GrafanaPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GrafanaPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGet() + public async Task GetAll_PrivateEndpointConnectionsList() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_List.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +108,25 @@ public async Task GetIfExists_PrivateEndpointConnectionsGet() // get the collection of this GrafanaPrivateEndpointConnectionResource GrafanaPrivateEndpointConnectionCollection collection = managedGrafana.GetGrafanaPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "myConnection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - GrafanaPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (GrafanaPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GrafanaPrivateEndpointConnectionData resourceData = result.Data; + GrafanaPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionsApprove() + public async Task Exists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Approve.json - // this example is just showing the usage of "PrivateEndpointConnections_Approve" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,23 +146,17 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsApprove() // invoke the operation string privateEndpointConnectionName = "myConnection"; - GrafanaPrivateEndpointConnectionData data = new GrafanaPrivateEndpointConnectionData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - GrafanaPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GrafanaPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsList() + public async Task GetIfExists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_List.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_PrivateEndpointConnectionsList() // get the collection of this GrafanaPrivateEndpointConnectionResource GrafanaPrivateEndpointConnectionCollection collection = managedGrafana.GetGrafanaPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (GrafanaPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "myConnection"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + GrafanaPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GrafanaPrivateEndpointConnectionData resourceData = item.Data; + GrafanaPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateEndpointConnectionResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateEndpointConnectionResource.cs index 2f81c0dd98638..2bdd07dc0fbcd 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateEndpointConnectionResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateEndpointConnectionResource.cs @@ -48,10 +48,10 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsApprove() + public async Task Delete_PrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Approve.json - // this example is just showing the usage of "PrivateEndpointConnections_Approve" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,23 +68,17 @@ public async Task Update_PrivateEndpointConnectionsApprove() GrafanaPrivateEndpointConnectionResource grafanaPrivateEndpointConnection = client.GetGrafanaPrivateEndpointConnectionResource(grafanaPrivateEndpointConnectionResourceId); // invoke the operation - GrafanaPrivateEndpointConnectionData data = new GrafanaPrivateEndpointConnectionData(); - ArmOperation lro = await grafanaPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - GrafanaPrivateEndpointConnectionResource result = lro.Value; + await grafanaPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GrafanaPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDelete() + public async Task Update_PrivateEndpointConnectionsApprove() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateEndpointConnections_Approve.json + // this example is just showing the usage of "PrivateEndpointConnections_Approve" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +95,15 @@ public async Task Delete_PrivateEndpointConnectionsDelete() GrafanaPrivateEndpointConnectionResource grafanaPrivateEndpointConnection = client.GetGrafanaPrivateEndpointConnectionResource(grafanaPrivateEndpointConnectionResourceId); // invoke the operation - await grafanaPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + GrafanaPrivateEndpointConnectionData data = new GrafanaPrivateEndpointConnectionData(); + ArmOperation lro = await grafanaPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + GrafanaPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GrafanaPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateLinkResourceCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateLinkResourceCollection.cs index d6790ecbffdf8..dc905c43f3754 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateLinkResourceCollection.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_GrafanaPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_GrafanaPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesList() + public async Task Get_PrivateLinkResourcesGet() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateLinkResources_List.json - // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateLinkResources_Get.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_PrivateLinkResourcesList() // get the collection of this GrafanaPrivateLinkResource GrafanaPrivateLinkResourceCollection collection = managedGrafana.GetGrafanaPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (GrafanaPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GrafanaPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateLinkResourceName = "grafana"; + GrafanaPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GrafanaPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkResourcesGet() + public async Task GetAll_PrivateLinkResourcesList() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateLinkResources_Get.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/PrivateLinkResources_List.json + // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_PrivateLinkResourcesGet() // get the collection of this GrafanaPrivateLinkResource GrafanaPrivateLinkResourceCollection collection = managedGrafana.GetGrafanaPrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "grafana"; - GrafanaPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (GrafanaPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GrafanaPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GrafanaPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedGrafanaCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedGrafanaCollection.cs index 217151111652d..cdbd081b3c666 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedGrafanaCollection.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedGrafanaCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_ManagedGrafanaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GrafanaListByResourceGroup() + public async Task CreateOrUpdate_GrafanaCreate() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_ListByResourceGroup.json - // this example is just showing the usage of "Grafana_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Create.json + // this example is just showing the usage of "Grafana_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,57 @@ public async Task GetAll_GrafanaListByResourceGroup() // get the collection of this ManagedGrafanaResource ManagedGrafanaCollection collection = resourceGroupResource.GetManagedGrafanas(); - // invoke the operation and iterate over the result - await foreach (ManagedGrafanaResource item in collection.GetAllAsync()) + // invoke the operation + string workspaceName = "myWorkspace"; + ManagedGrafanaData data = new ManagedGrafanaData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedGrafanaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SkuName = "Standard", + Properties = new ManagedGrafanaProperties + { + PublicNetworkAccess = GrafanaPublicNetworkAccess.Enabled, + ZoneRedundancy = GrafanaZoneRedundancy.Enabled, + ApiKey = GrafanaApiKey.Enabled, + DeterministicOutboundIP = DeterministicOutboundIP.Enabled, + MonitorWorkspaceIntegrations = {new MonitorWorkspaceIntegration +{ +MonitorWorkspaceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"), +}}, + EnterpriseConfigurations = new EnterpriseConfigurations + { + MarketplacePlanId = "myPlanId", + MarketplaceAutoRenew = MarketplaceAutoRenew.Enabled, + }, + GrafanaConfigurationsSmtp = new Smtp + { + Enabled = true, + Host = "smtp.sendemail.com:587", + User = "username", + Password = "", + FromAddress = "test@sendemail.com", + FromName = "emailsender", + StartTLSPolicy = StartTLSPolicy.OpportunisticStartTLS, + SkipVerify = true, + }, + GrafanaPlugins = +{ +["sample-plugin-id"] = new GrafanaPlugin() +}, + GrafanaMajorVersion = "9", + }, + Identity = new ManagedServiceIdentity("SystemAssigned"), + Tags = +{ +["Environment"] = "Dev" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); + ManagedGrafanaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedGrafanaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +128,10 @@ public async Task Get_GrafanaGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GrafanaGet() + public async Task GetAll_GrafanaListByResourceGroup() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Get.json - // this example is just showing the usage of "Grafana_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_ListByResourceGroup.json + // this example is just showing the usage of "Grafana_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +148,22 @@ public async Task Exists_GrafanaGet() // get the collection of this ManagedGrafanaResource ManagedGrafanaCollection collection = resourceGroupResource.GetManagedGrafanas(); - // invoke the operation - string workspaceName = "myWorkspace"; - bool result = await collection.ExistsAsync(workspaceName); + // invoke the operation and iterate over the result + await foreach (ManagedGrafanaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedGrafanaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GrafanaGet() + public async Task Exists_GrafanaGet() { // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Get.json // this example is just showing the usage of "Grafana_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +185,17 @@ public async Task GetIfExists_GrafanaGet() // invoke the operation string workspaceName = "myWorkspace"; - NullableResponse response = await collection.GetIfExistsAsync(workspaceName); - ManagedGrafanaResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(workspaceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedGrafanaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GrafanaCreate() + public async Task GetIfExists_GrafanaGet() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Create.json - // this example is just showing the usage of "Grafana_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Get.json + // this example is just showing the usage of "Grafana_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,58 +214,21 @@ public async Task CreateOrUpdate_GrafanaCreate() // invoke the operation string workspaceName = "myWorkspace"; - ManagedGrafanaData data = new ManagedGrafanaData(new AzureLocation("West US")) - { - SkuName = "Standard", - Properties = new ManagedGrafanaProperties() - { - PublicNetworkAccess = GrafanaPublicNetworkAccess.Enabled, - ZoneRedundancy = GrafanaZoneRedundancy.Enabled, - ApiKey = GrafanaApiKey.Enabled, - DeterministicOutboundIP = DeterministicOutboundIP.Enabled, - MonitorWorkspaceIntegrations = -{ -new MonitorWorkspaceIntegration() -{ -MonitorWorkspaceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"), -} -}, - EnterpriseConfigurations = new EnterpriseConfigurations() - { - MarketplacePlanId = "myPlanId", - MarketplaceAutoRenew = MarketplaceAutoRenew.Enabled, - }, - GrafanaConfigurationsSmtp = new Smtp() - { - Enabled = true, - Host = "smtp.sendemail.com:587", - User = "username", - Password = "", - FromAddress = "test@sendemail.com", - FromName = "emailsender", - StartTLSPolicy = StartTLSPolicy.OpportunisticStartTLS, - SkipVerify = true, - }, - GrafanaPlugins = -{ -["sample-plugin-id"] = new GrafanaPlugin(), -}, - GrafanaMajorVersion = "9", - }, - Identity = new ManagedServiceIdentity("SystemAssigned"), - Tags = -{ -["Environment"] = "Dev", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); - ManagedGrafanaResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(workspaceName); + ManagedGrafanaResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedGrafanaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedGrafanaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedGrafanaResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedGrafanaResource.cs index c4fc9ffa0e945..5aa4db4673c8c 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedGrafanaResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedGrafanaResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Grafana.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Grafana.Samples @@ -19,41 +18,40 @@ public partial class Sample_ManagedGrafanaResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetManagedGrafanas_GrafanaList() + public async Task Get_GrafanaGet() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_List.json - // this example is just showing the usage of "Grafana_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Get.json + // this example is just showing the usage of "Grafana_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this ManagedGrafanaResource created on azure + // for more information of creating ManagedGrafanaResource, please refer to the document of ManagedGrafanaResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "myResourceGroup"; + string workspaceName = "myWorkspace"; + ResourceIdentifier managedGrafanaResourceId = ManagedGrafanaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); + ManagedGrafanaResource managedGrafana = client.GetManagedGrafanaResource(managedGrafanaResourceId); - // invoke the operation and iterate over the result - await foreach (ManagedGrafanaResource item in subscriptionResource.GetManagedGrafanasAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedGrafanaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + ManagedGrafanaResource result = await managedGrafana.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedGrafanaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GrafanaGet() + public async Task Delete_GrafanaDelete() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Get.json - // this example is just showing the usage of "Grafana_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Delete.json + // this example is just showing the usage of "Grafana_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,13 +67,9 @@ public async Task Get_GrafanaGet() ManagedGrafanaResource managedGrafana = client.GetManagedGrafanaResource(managedGrafanaResourceId); // invoke the operation - ManagedGrafanaResource result = await managedGrafana.GetAsync(); + await managedGrafana.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedGrafanaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,30 +93,27 @@ public async Task Update_GrafanaUpdate() ManagedGrafanaResource managedGrafana = client.GetManagedGrafanaResource(managedGrafanaResourceId); // invoke the operation - ManagedGrafanaPatch patch = new ManagedGrafanaPatch() + ManagedGrafanaPatch patch = new ManagedGrafanaPatch { SkuName = "Standard", Tags = { -["Environment"] = "Dev 2", +["Environment"] = "Dev 2" }, - Properties = new ManagedGrafanaPatchProperties() + Properties = new ManagedGrafanaPatchProperties { ApiKey = GrafanaApiKey.Enabled, DeterministicOutboundIP = DeterministicOutboundIP.Enabled, - MonitorWorkspaceIntegrations = -{ -new MonitorWorkspaceIntegration() + MonitorWorkspaceIntegrations = {new MonitorWorkspaceIntegration { MonitorWorkspaceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.monitor/accounts/myAzureMonitorWorkspace"), -} -}, - EnterpriseConfigurations = new EnterpriseConfigurations() +}}, + EnterpriseConfigurations = new EnterpriseConfigurations { MarketplacePlanId = "myPlanId", MarketplaceAutoRenew = MarketplaceAutoRenew.Enabled, }, - GrafanaConfigurationsSmtp = new Smtp() + GrafanaConfigurationsSmtp = new Smtp { Enabled = true, Host = "smtp.sendemail.com:587", @@ -135,7 +126,7 @@ public async Task Update_GrafanaUpdate() }, GrafanaPlugins = { -["sample-plugin-id"] = new GrafanaPlugin(), +["sample-plugin-id"] = new GrafanaPlugin() }, GrafanaMajorVersion = "9", }, @@ -149,32 +140,6 @@ public async Task Update_GrafanaUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_GrafanaDelete() - { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_Delete.json - // this example is just showing the usage of "Grafana_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedGrafanaResource created on azure - // for more information of creating ManagedGrafanaResource, please refer to the document of ManagedGrafanaResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - string workspaceName = "myWorkspace"; - ResourceIdentifier managedGrafanaResourceId = ManagedGrafanaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); - ManagedGrafanaResource managedGrafana = client.GetManagedGrafanaResource(managedGrafanaResourceId); - - // invoke the operation - await managedGrafana.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CheckEnterpriseDetails_EnterpriseDetailsPost() diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedPrivateEndpointModelCollection.cs b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedPrivateEndpointModelCollection.cs index fcbcaa6d238cd..2185a8a3c9a6e 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedPrivateEndpointModelCollection.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedPrivateEndpointModelCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ManagedPrivateEndpointModelCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ManagedPrivateEndpointList() + public async Task CreateOrUpdate_ManagedPrivateEndpointCreate() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_List.json - // this example is just showing the usage of "ManagedPrivateEndpoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Create.json + // this example is just showing the usage of "ManagedPrivateEndpoints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,24 @@ public async Task GetAll_ManagedPrivateEndpointList() // get the collection of this ManagedPrivateEndpointModelResource ManagedPrivateEndpointModelCollection collection = managedGrafana.GetManagedPrivateEndpointModels(); - // invoke the operation and iterate over the result - await foreach (ManagedPrivateEndpointModelResource item in collection.GetAllAsync()) + // invoke the operation + string managedPrivateEndpointName = "myMPEName"; + ManagedPrivateEndpointModelData data = new ManagedPrivateEndpointModelData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedPrivateEndpointModelData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-000000000000/resourceGroups/xx-rg/providers/Microsoft.Kusto/Clusters/sampleKustoResource"), + PrivateLinkResourceRegion = "West US", + GroupIds = { "grafana" }, + RequestMessage = "Example Request Message", + PrivateLinkServiceUri = new Uri("my-self-hosted-influxdb.westus.mydomain.com"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedPrivateEndpointName, data); + ManagedPrivateEndpointModelResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedPrivateEndpointModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +94,10 @@ public async Task Get_ManagedPrivateEndpointGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ManagedPrivateEndpointGet() + public async Task GetAll_ManagedPrivateEndpointList() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Get.json - // this example is just showing the usage of "ManagedPrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_List.json + // this example is just showing the usage of "ManagedPrivateEndpoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +115,22 @@ public async Task Exists_ManagedPrivateEndpointGet() // get the collection of this ManagedPrivateEndpointModelResource ManagedPrivateEndpointModelCollection collection = managedGrafana.GetManagedPrivateEndpointModels(); - // invoke the operation - string managedPrivateEndpointName = "myMPEName"; - bool result = await collection.ExistsAsync(managedPrivateEndpointName); + // invoke the operation and iterate over the result + await foreach (ManagedPrivateEndpointModelResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedPrivateEndpointModelData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ManagedPrivateEndpointGet() + public async Task Exists_ManagedPrivateEndpointGet() { // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Get.json // this example is just showing the usage of "ManagedPrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +153,17 @@ public async Task GetIfExists_ManagedPrivateEndpointGet() // invoke the operation string managedPrivateEndpointName = "myMPEName"; - NullableResponse response = await collection.GetIfExistsAsync(managedPrivateEndpointName); - ManagedPrivateEndpointModelResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(managedPrivateEndpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedPrivateEndpointModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ManagedPrivateEndpointCreate() + public async Task GetIfExists_ManagedPrivateEndpointGet() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Create.json - // this example is just showing the usage of "ManagedPrivateEndpoints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Get.json + // this example is just showing the usage of "ManagedPrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,25 +183,21 @@ public async Task CreateOrUpdate_ManagedPrivateEndpointCreate() // invoke the operation string managedPrivateEndpointName = "myMPEName"; - ManagedPrivateEndpointModelData data = new ManagedPrivateEndpointModelData(new AzureLocation("West US")) - { - PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-000000000000/resourceGroups/xx-rg/providers/Microsoft.Kusto/Clusters/sampleKustoResource"), - PrivateLinkResourceRegion = "West US", - GroupIds = -{ -"grafana" -}, - RequestMessage = "Example Request Message", - PrivateLinkServiceUri = new Uri("my-self-hosted-influxdb.westus.mydomain.com"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedPrivateEndpointName, data); - ManagedPrivateEndpointModelResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(managedPrivateEndpointName); + ManagedPrivateEndpointModelResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedPrivateEndpointModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedPrivateEndpointModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedPrivateEndpointModelResource.cs b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedPrivateEndpointModelResource.cs index 0c5fb9d83730b..a9f4f4eb0789b 100644 --- a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedPrivateEndpointModelResource.cs +++ b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_ManagedPrivateEndpointModelResource.cs @@ -49,10 +49,10 @@ public async Task Get_ManagedPrivateEndpointGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ManagedPrivateEndpointsPatch() + public async Task Delete_ManagedPrivateEndpointDelete() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Patch.json - // this example is just showing the usage of "ManagedPrivateEndpoints_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Delete.json + // this example is just showing the usage of "ManagedPrivateEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_ManagedPrivateEndpointsPatch() ManagedPrivateEndpointModelResource managedPrivateEndpointModel = client.GetManagedPrivateEndpointModelResource(managedPrivateEndpointModelResourceId); // invoke the operation - ManagedPrivateEndpointModelPatch patch = new ManagedPrivateEndpointModelPatch() - { - Tags = -{ -["Environment"] = "Dev 2", -}, - }; - ArmOperation lro = await managedPrivateEndpointModel.UpdateAsync(WaitUntil.Completed, patch); - ManagedPrivateEndpointModelResource result = lro.Value; + await managedPrivateEndpointModel.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedPrivateEndpointModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ManagedPrivateEndpointDelete() + public async Task Update_ManagedPrivateEndpointsPatch() { - // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Delete.json - // this example is just showing the usage of "ManagedPrivateEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/ManagedPrivateEndpoints_Patch.json + // this example is just showing the usage of "ManagedPrivateEndpoints_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_ManagedPrivateEndpointDelete() ManagedPrivateEndpointModelResource managedPrivateEndpointModel = client.GetManagedPrivateEndpointModelResource(managedPrivateEndpointModelResourceId); // invoke the operation - await managedPrivateEndpointModel.DeleteAsync(WaitUntil.Completed); + ManagedPrivateEndpointModelPatch patch = new ManagedPrivateEndpointModelPatch + { + Tags = +{ +["Environment"] = "Dev 2" +}, + }; + ArmOperation lro = await managedPrivateEndpointModel.UpdateAsync(WaitUntil.Completed, patch); + ManagedPrivateEndpointModelResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedPrivateEndpointModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..0b9bae6fab948 --- /dev/null +++ b/sdk/grafana/Azure.ResourceManager.Grafana/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Grafana.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetManagedGrafanas_GrafanaList() + { + // Generated from example definition: specification/dashboard/resource-manager/Microsoft.Dashboard/stable/2023-09-01/examples/Grafana_List.json + // this example is just showing the usage of "Grafana_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ManagedGrafanaResource item in subscriptionResource.GetManagedGrafanasAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedGrafanaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_GraphServicesAccountResource.cs b/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_GraphServicesAccountResource.cs index 557e68ecdd96f..2563aac3b6484 100644 --- a/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_GraphServicesAccountResource.cs +++ b/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_GraphServicesAccountResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.GraphServices.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.GraphServices.Samples { public partial class Sample_GraphServicesAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetGraphServicesAccountResources_GetListOfAccountsBySubscription() - { - // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_List_Sub.json - // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (GraphServicesAccountResource item in subscriptionResource.GetGraphServicesAccountResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GraphServicesAccountResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAccounts() @@ -80,10 +48,10 @@ public async Task Get_GetAccounts() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAccountResource() + public async Task Delete_DeleteAccountResource() { - // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_Update.json - // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_Delete.json + // this example is just showing the usage of "Accounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,36 +60,24 @@ public async Task Update_UpdateAccountResource() // this example assumes you already have this GraphServicesAccountResource created on azure // for more information of creating GraphServicesAccountResource, please refer to the document of GraphServicesAccountResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "11111111-aaaa-1111-bbbb-111111111111"; string resourceGroupName = "testResourceGroupGRAM"; string resourceName = "11111111-aaaa-1111-bbbb-111111111111"; ResourceIdentifier graphServicesAccountResourceId = GraphServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); GraphServicesAccountResource graphServicesAccountResource = client.GetGraphServicesAccountResource(graphServicesAccountResourceId); // invoke the operation - GraphServicesAccountResourcePatch patch = new GraphServicesAccountResourcePatch() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - GraphServicesAccountResource result = await graphServicesAccountResource.UpdateAsync(patch); + await graphServicesAccountResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GraphServicesAccountResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAccountResource() + public async Task Update_UpdateAccountResource() { - // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_Delete.json - // this example is just showing the usage of "Accounts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_Update.json + // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,16 +86,28 @@ public async Task Delete_DeleteAccountResource() // this example assumes you already have this GraphServicesAccountResource created on azure // for more information of creating GraphServicesAccountResource, please refer to the document of GraphServicesAccountResource - string subscriptionId = "11111111-aaaa-1111-bbbb-111111111111"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "testResourceGroupGRAM"; string resourceName = "11111111-aaaa-1111-bbbb-111111111111"; ResourceIdentifier graphServicesAccountResourceId = GraphServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); GraphServicesAccountResource graphServicesAccountResource = client.GetGraphServicesAccountResource(graphServicesAccountResourceId); // invoke the operation - await graphServicesAccountResource.DeleteAsync(WaitUntil.Completed); + GraphServicesAccountResourcePatch patch = new GraphServicesAccountResourcePatch + { + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + GraphServicesAccountResource result = await graphServicesAccountResource.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GraphServicesAccountResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_GraphServicesAccountResourceCollection.cs b/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_GraphServicesAccountResourceCollection.cs index c2bdbb66798aa..b6eaa26988c94 100644 --- a/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_GraphServicesAccountResourceCollection.cs +++ b/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_GraphServicesAccountResourceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_GraphServicesAccountResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CreateOrUpdateAccountResource() + public async Task CreateOrUpdate_CreateAccountResource() { - // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_List.json - // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_Create.json + // this example is just showing the usage of "Accounts_CreateAndUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,17 @@ public async Task GetAll_CreateOrUpdateAccountResource() // get the collection of this GraphServicesAccountResource GraphServicesAccountResourceCollection collection = resourceGroupResource.GetGraphServicesAccountResources(); - // invoke the operation and iterate over the result - await foreach (GraphServicesAccountResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GraphServicesAccountResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string resourceName = "11111111-aaaa-1111-bbbb-1111111111111"; + GraphServicesAccountResourceData data = new GraphServicesAccountResourceData(default, new GraphServicesAccountResourceProperties("11111111-aaaa-1111-bbbb-111111111111")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + GraphServicesAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GraphServicesAccountResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_GetAccounts() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAccounts() + public async Task GetAll_CreateOrUpdateAccountResource() { - // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_Get.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_List.json + // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +107,22 @@ public async Task Exists_GetAccounts() // get the collection of this GraphServicesAccountResource GraphServicesAccountResourceCollection collection = resourceGroupResource.GetGraphServicesAccountResources(); - // invoke the operation - string resourceName = "11111111-aaaa-1111-bbbb-111111111111"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (GraphServicesAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GraphServicesAccountResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAccounts() + public async Task Exists_GetAccounts() { // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_Get.json // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +144,17 @@ public async Task GetIfExists_GetAccounts() // invoke the operation string resourceName = "11111111-aaaa-1111-bbbb-111111111111"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - GraphServicesAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GraphServicesAccountResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAccountResource() + public async Task GetIfExists_GetAccounts() { - // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_Create.json - // this example is just showing the usage of "Accounts_CreateAndUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_Get.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,16 +172,22 @@ public async Task CreateOrUpdate_CreateAccountResource() GraphServicesAccountResourceCollection collection = resourceGroupResource.GetGraphServicesAccountResources(); // invoke the operation - string resourceName = "11111111-aaaa-1111-bbbb-1111111111111"; - GraphServicesAccountResourceData data = new GraphServicesAccountResourceData(new AzureLocation("placeholder"), new GraphServicesAccountResourceProperties("11111111-aaaa-1111-bbbb-111111111111")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - GraphServicesAccountResource result = lro.Value; + string resourceName = "11111111-aaaa-1111-bbbb-111111111111"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + GraphServicesAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GraphServicesAccountResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GraphServicesAccountResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..af544cc126ca1 --- /dev/null +++ b/sdk/graphservices/Azure.ResourceManager.GraphServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.GraphServices.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetGraphServicesAccountResources_GetListOfAccountsBySubscription() + { + // Generated from example definition: specification/graphservicesprod/resource-manager/Microsoft.GraphServices/stable/2023-04-13/examples/Accounts_List_Sub.json + // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (GraphServicesAccountResource item in subscriptionResource.GetGraphServicesAccountResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GraphServicesAccountResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationHcrpAssignmentCollection.cs b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationHcrpAssignmentCollection.cs index 6fa6bc85b0a92..2af0c1cb87b58 100644 --- a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationHcrpAssignmentCollection.cs +++ b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationHcrpAssignmentCollection.cs @@ -28,37 +28,31 @@ public async Task CreateOrUpdate_CreateOrUpdateGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationHcrpAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string machineName = "myMachineName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridCompute/machines/{2}", subscriptionId, resourceGroupName, machineName)); - GuestConfigurationHcrpAssignmentCollection collection = client.GetGuestConfigurationHcrpAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}"; + GuestConfigurationHcrpAssignmentCollection collection = client.GetGuestConfigurationHcrpAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "NotInstalledApplicationForWindows"; - GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData() + GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData { - Properties = new GuestConfigurationAssignmentProperties() + Properties = new GuestConfigurationAssignmentProperties { - GuestConfiguration = new GuestConfigurationNavigation() + GuestConfiguration = new GuestConfigurationNavigation { Name = "NotInstalledApplicationForWindows", Version = "1.0.0.3", ContentUri = new Uri("https://thisisfake/pacakge"), ContentHash = "123contenthash", AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, - ConfigurationParameters = -{ -new GuestConfigurationParameter() + ConfigurationParameters = {new GuestConfigurationParameter { Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", Value = "NotePad,sql", -} -}, +}}, }, Context = "Azure policy", }, @@ -87,15 +81,12 @@ public async Task Get_GetAGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationHcrpAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string machineName = "myMachineName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridCompute/machines/{2}", subscriptionId, resourceGroupName, machineName)); - GuestConfigurationHcrpAssignmentCollection collection = client.GetGuestConfigurationHcrpAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}"; + GuestConfigurationHcrpAssignmentCollection collection = client.GetGuestConfigurationHcrpAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "SecureProtocol"; @@ -108,6 +99,38 @@ public async Task Get_GetAGuestConfigurationAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAllGuestConfigurationAssignmentsForAVirtualMachine() + { + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/listGuestConfigurationHCRPAssignments.json + // this example is just showing the usage of "GuestConfigurationHCRPAssignments_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this GuestConfigurationHcrpAssignmentResource + string subscriptionId = "mySubscriptionId"; + string resourceGroupName = "myResourceGroupName"; + string machineName = "myMachineName"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}"; + GuestConfigurationHcrpAssignmentCollection collection = client.GetGuestConfigurationHcrpAssignments(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (GuestConfigurationHcrpAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GuestConfigurationAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAGuestConfigurationAssignment() @@ -120,15 +143,12 @@ public async Task Exists_GetAGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationHcrpAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string machineName = "myMachineName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridCompute/machines/{2}", subscriptionId, resourceGroupName, machineName)); - GuestConfigurationHcrpAssignmentCollection collection = client.GetGuestConfigurationHcrpAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}"; + GuestConfigurationHcrpAssignmentCollection collection = client.GetGuestConfigurationHcrpAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "SecureProtocol"; @@ -149,15 +169,12 @@ public async Task GetIfExists_GetAGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationHcrpAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string machineName = "myMachineName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridCompute/machines/{2}", subscriptionId, resourceGroupName, machineName)); - GuestConfigurationHcrpAssignmentCollection collection = client.GetGuestConfigurationHcrpAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}"; + GuestConfigurationHcrpAssignmentCollection collection = client.GetGuestConfigurationHcrpAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "SecureProtocol"; @@ -177,40 +194,5 @@ public async Task GetIfExists_GetAGuestConfigurationAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllGuestConfigurationAssignmentsForAVirtualMachine() - { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/listGuestConfigurationHCRPAssignments.json - // this example is just showing the usage of "GuestConfigurationHCRPAssignments_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this GuestConfigurationHcrpAssignmentResource - string subscriptionId = "mySubscriptionId"; - string resourceGroupName = "myResourceGroupName"; - string machineName = "myMachineName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridCompute/machines/{2}", subscriptionId, resourceGroupName, machineName)); - GuestConfigurationHcrpAssignmentCollection collection = client.GetGuestConfigurationHcrpAssignments(scopeId); - - // invoke the operation and iterate over the result - await foreach (GuestConfigurationHcrpAssignmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GuestConfigurationAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationHcrpAssignmentResource.cs b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationHcrpAssignmentResource.cs index e648c8031cfff..b601b05ab544c 100644 --- a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationHcrpAssignmentResource.cs +++ b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationHcrpAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GuestConfigurationHcrpAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateGuestConfigurationAssignment() + public async Task Get_GetAGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/createOrUpdateGuestConfigurationHCRPAssignment.json - // this example is just showing the usage of "GuestConfigurationHCRPAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/getGuestConfigurationHCRPAssignment.json + // this example is just showing the usage of "GuestConfigurationHCRPAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,38 +33,12 @@ public async Task Update_CreateOrUpdateGuestConfigurationAssignment() string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string machineName = "myMachineName"; - string guestConfigurationAssignmentName = "NotInstalledApplicationForWindows"; + string guestConfigurationAssignmentName = "SecureProtocol"; ResourceIdentifier guestConfigurationHcrpAssignmentResourceId = GuestConfigurationHcrpAssignmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, machineName, guestConfigurationAssignmentName); GuestConfigurationHcrpAssignmentResource guestConfigurationHcrpAssignment = client.GetGuestConfigurationHcrpAssignmentResource(guestConfigurationHcrpAssignmentResourceId); // invoke the operation - GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData() - { - Properties = new GuestConfigurationAssignmentProperties() - { - GuestConfiguration = new GuestConfigurationNavigation() - { - Name = "NotInstalledApplicationForWindows", - Version = "1.0.0.3", - ContentUri = new Uri("https://thisisfake/pacakge"), - ContentHash = "123contenthash", - AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, - ConfigurationParameters = -{ -new GuestConfigurationParameter() -{ -Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", -Value = "NotePad,sql", -} -}, - }, - Context = "Azure policy", - }, - Name = "NotInstalledApplicationForWindows", - Location = new AzureLocation("westcentralus"), - }; - ArmOperation lro = await guestConfigurationHcrpAssignment.UpdateAsync(WaitUntil.Completed, data); - GuestConfigurationHcrpAssignmentResource result = lro.Value; + GuestConfigurationHcrpAssignmentResource result = await guestConfigurationHcrpAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -75,10 +49,10 @@ public async Task Update_CreateOrUpdateGuestConfigurationAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGuestConfigurationAssignment() + public async Task Delete_DeleteAnGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/getGuestConfigurationHCRPAssignment.json - // this example is just showing the usage of "GuestConfigurationHCRPAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/deleteGuestConfigurationHCRPAssignment.json + // this example is just showing the usage of "GuestConfigurationHCRPAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,21 +69,17 @@ public async Task Get_GetAGuestConfigurationAssignment() GuestConfigurationHcrpAssignmentResource guestConfigurationHcrpAssignment = client.GetGuestConfigurationHcrpAssignmentResource(guestConfigurationHcrpAssignmentResourceId); // invoke the operation - GuestConfigurationHcrpAssignmentResource result = await guestConfigurationHcrpAssignment.GetAsync(); + await guestConfigurationHcrpAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GuestConfigurationAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnGuestConfigurationAssignment() + public async Task Update_CreateOrUpdateGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/deleteGuestConfigurationHCRPAssignment.json - // this example is just showing the usage of "GuestConfigurationHCRPAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/createOrUpdateGuestConfigurationHCRPAssignment.json + // this example is just showing the usage of "GuestConfigurationHCRPAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,14 +91,41 @@ public async Task Delete_DeleteAnGuestConfigurationAssignment() string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string machineName = "myMachineName"; - string guestConfigurationAssignmentName = "SecureProtocol"; + string guestConfigurationAssignmentName = "NotInstalledApplicationForWindows"; ResourceIdentifier guestConfigurationHcrpAssignmentResourceId = GuestConfigurationHcrpAssignmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, machineName, guestConfigurationAssignmentName); GuestConfigurationHcrpAssignmentResource guestConfigurationHcrpAssignment = client.GetGuestConfigurationHcrpAssignmentResource(guestConfigurationHcrpAssignmentResourceId); // invoke the operation - await guestConfigurationHcrpAssignment.DeleteAsync(WaitUntil.Completed); + GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData + { + Properties = new GuestConfigurationAssignmentProperties + { + GuestConfiguration = new GuestConfigurationNavigation + { + Name = "NotInstalledApplicationForWindows", + Version = "1.0.0.3", + ContentUri = new Uri("https://thisisfake/pacakge"), + ContentHash = "123contenthash", + AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, + ConfigurationParameters = {new GuestConfigurationParameter +{ +Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", +Value = "NotePad,sql", +}}, + }, + Context = "Azure policy", + }, + Name = "NotInstalledApplicationForWindows", + Location = new AzureLocation("westcentralus"), + }; + ArmOperation lro = await guestConfigurationHcrpAssignment.UpdateAsync(WaitUntil.Completed, data); + GuestConfigurationHcrpAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GuestConfigurationAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVMwarevSphereAssignmentCollection.cs b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVMwarevSphereAssignmentCollection.cs index 0fb0411d6bbc4..05449abd7f464 100644 --- a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVMwarevSphereAssignmentCollection.cs +++ b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVMwarevSphereAssignmentCollection.cs @@ -28,37 +28,31 @@ public async Task CreateOrUpdate_CreateOrUpdateGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVMwarevSphereAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{2}", subscriptionId, resourceGroupName, vmName)); - GuestConfigurationVMwarevSphereAssignmentCollection collection = client.GetGuestConfigurationVMwarevSphereAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}"; + GuestConfigurationVMwarevSphereAssignmentCollection collection = client.GetGuestConfigurationVMwarevSphereAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "NotInstalledApplicationForWindows"; - GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData() + GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData { - Properties = new GuestConfigurationAssignmentProperties() + Properties = new GuestConfigurationAssignmentProperties { - GuestConfiguration = new GuestConfigurationNavigation() + GuestConfiguration = new GuestConfigurationNavigation { Name = "NotInstalledApplicationForWindows", Version = "1.0.0.0", ContentUri = new Uri("https://thisisfake/pacakge"), ContentHash = "123contenthash", AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, - ConfigurationParameters = -{ -new GuestConfigurationParameter() + ConfigurationParameters = {new GuestConfigurationParameter { Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", Value = "NotePad,sql", -} -}, +}}, }, Context = "Azure policy", }, @@ -87,15 +81,12 @@ public async Task Get_GetAGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVMwarevSphereAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{2}", subscriptionId, resourceGroupName, vmName)); - GuestConfigurationVMwarevSphereAssignmentCollection collection = client.GetGuestConfigurationVMwarevSphereAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}"; + GuestConfigurationVMwarevSphereAssignmentCollection collection = client.GetGuestConfigurationVMwarevSphereAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "SecureProtocol"; @@ -108,6 +99,38 @@ public async Task Get_GetAGuestConfigurationAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAllGuestConfigurationAssignmentsForAVirtualMachine() + { + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/listGuestConfigurationConnectedVMwarevSphereAssignments.json + // this example is just showing the usage of "GuestConfigurationConnectedVMwarevSphereAssignments_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this GuestConfigurationVMwarevSphereAssignmentResource + string subscriptionId = "mySubscriptionId"; + string resourceGroupName = "myResourceGroupName"; + string vmName = "myVMName"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}"; + GuestConfigurationVMwarevSphereAssignmentCollection collection = client.GetGuestConfigurationVMwarevSphereAssignments(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (GuestConfigurationVMwarevSphereAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GuestConfigurationAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAGuestConfigurationAssignment() @@ -120,15 +143,12 @@ public async Task Exists_GetAGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVMwarevSphereAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{2}", subscriptionId, resourceGroupName, vmName)); - GuestConfigurationVMwarevSphereAssignmentCollection collection = client.GetGuestConfigurationVMwarevSphereAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}"; + GuestConfigurationVMwarevSphereAssignmentCollection collection = client.GetGuestConfigurationVMwarevSphereAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "SecureProtocol"; @@ -149,15 +169,12 @@ public async Task GetIfExists_GetAGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVMwarevSphereAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{2}", subscriptionId, resourceGroupName, vmName)); - GuestConfigurationVMwarevSphereAssignmentCollection collection = client.GetGuestConfigurationVMwarevSphereAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{vmName}"; + GuestConfigurationVMwarevSphereAssignmentCollection collection = client.GetGuestConfigurationVMwarevSphereAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "SecureProtocol"; @@ -177,40 +194,5 @@ public async Task GetIfExists_GetAGuestConfigurationAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllGuestConfigurationAssignmentsForAVirtualMachine() - { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/listGuestConfigurationConnectedVMwarevSphereAssignments.json - // this example is just showing the usage of "GuestConfigurationConnectedVMwarevSphereAssignments_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this GuestConfigurationVMwarevSphereAssignmentResource - string subscriptionId = "mySubscriptionId"; - string resourceGroupName = "myResourceGroupName"; - string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.ConnectedVMwarevSphere/virtualmachines/{2}", subscriptionId, resourceGroupName, vmName)); - GuestConfigurationVMwarevSphereAssignmentCollection collection = client.GetGuestConfigurationVMwarevSphereAssignments(scopeId); - - // invoke the operation and iterate over the result - await foreach (GuestConfigurationVMwarevSphereAssignmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GuestConfigurationAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVMwarevSphereAssignmentResource.cs b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVMwarevSphereAssignmentResource.cs index d96962e30644c..f44f8c3a8d0ae 100644 --- a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVMwarevSphereAssignmentResource.cs +++ b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVMwarevSphereAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GuestConfigurationVMwarevSphereAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateGuestConfigurationAssignment() + public async Task Get_GetAGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/createOrUpdateGuestConfigurationConnectedVMwarevSphereAssignment.json - // this example is just showing the usage of "GuestConfigurationConnectedVMwarevSphereAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/getGuestConfigurationConnectedVMwarevSphereAssignment.json + // this example is just showing the usage of "GuestConfigurationConnectedVMwarevSphereAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,38 +33,12 @@ public async Task Update_CreateOrUpdateGuestConfigurationAssignment() string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - string guestConfigurationAssignmentName = "NotInstalledApplicationForWindows"; + string guestConfigurationAssignmentName = "SecureProtocol"; ResourceIdentifier guestConfigurationVMwarevSphereAssignmentResourceId = GuestConfigurationVMwarevSphereAssignmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName, guestConfigurationAssignmentName); GuestConfigurationVMwarevSphereAssignmentResource guestConfigurationVMwarevSphereAssignment = client.GetGuestConfigurationVMwarevSphereAssignmentResource(guestConfigurationVMwarevSphereAssignmentResourceId); // invoke the operation - GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData() - { - Properties = new GuestConfigurationAssignmentProperties() - { - GuestConfiguration = new GuestConfigurationNavigation() - { - Name = "NotInstalledApplicationForWindows", - Version = "1.0.0.0", - ContentUri = new Uri("https://thisisfake/pacakge"), - ContentHash = "123contenthash", - AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, - ConfigurationParameters = -{ -new GuestConfigurationParameter() -{ -Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", -Value = "NotePad,sql", -} -}, - }, - Context = "Azure policy", - }, - Name = "NotInstalledApplicationForWindows", - Location = new AzureLocation("westcentralus"), - }; - ArmOperation lro = await guestConfigurationVMwarevSphereAssignment.UpdateAsync(WaitUntil.Completed, data); - GuestConfigurationVMwarevSphereAssignmentResource result = lro.Value; + GuestConfigurationVMwarevSphereAssignmentResource result = await guestConfigurationVMwarevSphereAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -75,10 +49,10 @@ public async Task Update_CreateOrUpdateGuestConfigurationAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGuestConfigurationAssignment() + public async Task Delete_DeleteAnGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/getGuestConfigurationConnectedVMwarevSphereAssignment.json - // this example is just showing the usage of "GuestConfigurationConnectedVMwarevSphereAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/deleteGuestConfigurationConnectedVMwarevSphereAssignment.json + // this example is just showing the usage of "GuestConfigurationConnectedVMwarevSphereAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,21 +69,17 @@ public async Task Get_GetAGuestConfigurationAssignment() GuestConfigurationVMwarevSphereAssignmentResource guestConfigurationVMwarevSphereAssignment = client.GetGuestConfigurationVMwarevSphereAssignmentResource(guestConfigurationVMwarevSphereAssignmentResourceId); // invoke the operation - GuestConfigurationVMwarevSphereAssignmentResource result = await guestConfigurationVMwarevSphereAssignment.GetAsync(); + await guestConfigurationVMwarevSphereAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GuestConfigurationAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnGuestConfigurationAssignment() + public async Task Update_CreateOrUpdateGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/deleteGuestConfigurationConnectedVMwarevSphereAssignment.json - // this example is just showing the usage of "GuestConfigurationConnectedVMwarevSphereAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/createOrUpdateGuestConfigurationConnectedVMwarevSphereAssignment.json + // this example is just showing the usage of "GuestConfigurationConnectedVMwarevSphereAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,14 +91,41 @@ public async Task Delete_DeleteAnGuestConfigurationAssignment() string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - string guestConfigurationAssignmentName = "SecureProtocol"; + string guestConfigurationAssignmentName = "NotInstalledApplicationForWindows"; ResourceIdentifier guestConfigurationVMwarevSphereAssignmentResourceId = GuestConfigurationVMwarevSphereAssignmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName, guestConfigurationAssignmentName); GuestConfigurationVMwarevSphereAssignmentResource guestConfigurationVMwarevSphereAssignment = client.GetGuestConfigurationVMwarevSphereAssignmentResource(guestConfigurationVMwarevSphereAssignmentResourceId); // invoke the operation - await guestConfigurationVMwarevSphereAssignment.DeleteAsync(WaitUntil.Completed); + GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData + { + Properties = new GuestConfigurationAssignmentProperties + { + GuestConfiguration = new GuestConfigurationNavigation + { + Name = "NotInstalledApplicationForWindows", + Version = "1.0.0.0", + ContentUri = new Uri("https://thisisfake/pacakge"), + ContentHash = "123contenthash", + AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, + ConfigurationParameters = {new GuestConfigurationParameter +{ +Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", +Value = "NotePad,sql", +}}, + }, + Context = "Azure policy", + }, + Name = "NotInstalledApplicationForWindows", + Location = new AzureLocation("westcentralus"), + }; + ArmOperation lro = await guestConfigurationVMwarevSphereAssignment.UpdateAsync(WaitUntil.Completed, data); + GuestConfigurationVMwarevSphereAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GuestConfigurationAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmAssignmentCollection.cs b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmAssignmentCollection.cs index 1b9967138161d..40a16d844d316 100644 --- a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmAssignmentCollection.cs +++ b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmAssignmentCollection.cs @@ -28,23 +28,20 @@ public async Task CreateOrUpdate_CreateOrUpdateGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVmAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}", subscriptionId, resourceGroupName, vmName)); - GuestConfigurationVmAssignmentCollection collection = client.GetGuestConfigurationVmAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"; + GuestConfigurationVmAssignmentCollection collection = client.GetGuestConfigurationVmAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "NotInstalledApplicationForWindows"; - GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData() + GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData { - Properties = new GuestConfigurationAssignmentProperties() + Properties = new GuestConfigurationAssignmentProperties { - GuestConfiguration = new GuestConfigurationNavigation() + GuestConfiguration = new GuestConfigurationNavigation { Name = "NotInstalledApplicationForWindows", Version = "1.0.0.3", @@ -52,14 +49,11 @@ public async Task CreateOrUpdate_CreateOrUpdateGuestConfigurationAssignment() ContentHash = "123contenthash", ContentManagedIdentity = "test_identity", AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, - ConfigurationParameters = -{ -new GuestConfigurationParameter() + ConfigurationParameters = {new GuestConfigurationParameter { Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", Value = "NotePad,sql", -} -}, +}}, }, Context = "Azure policy", }, @@ -88,15 +82,12 @@ public async Task Get_GetAGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVmAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}", subscriptionId, resourceGroupName, vmName)); - GuestConfigurationVmAssignmentCollection collection = client.GetGuestConfigurationVmAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"; + GuestConfigurationVmAssignmentCollection collection = client.GetGuestConfigurationVmAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "SecureProtocol"; @@ -109,6 +100,38 @@ public async Task Get_GetAGuestConfigurationAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAllGuestConfigurationAssignmentsForAVirtualMachine() + { + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/listGuestConfigurationAssignments.json + // this example is just showing the usage of "GuestConfigurationAssignments_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this GuestConfigurationVmAssignmentResource + string subscriptionId = "mySubscriptionId"; + string resourceGroupName = "myResourceGroupName"; + string vmName = "myVMName"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"; + GuestConfigurationVmAssignmentCollection collection = client.GetGuestConfigurationVmAssignments(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (GuestConfigurationVmAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GuestConfigurationAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAGuestConfigurationAssignment() @@ -121,15 +144,12 @@ public async Task Exists_GetAGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVmAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}", subscriptionId, resourceGroupName, vmName)); - GuestConfigurationVmAssignmentCollection collection = client.GetGuestConfigurationVmAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"; + GuestConfigurationVmAssignmentCollection collection = client.GetGuestConfigurationVmAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "SecureProtocol"; @@ -150,15 +170,12 @@ public async Task GetIfExists_GetAGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVmAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}", subscriptionId, resourceGroupName, vmName)); - GuestConfigurationVmAssignmentCollection collection = client.GetGuestConfigurationVmAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"; + GuestConfigurationVmAssignmentCollection collection = client.GetGuestConfigurationVmAssignments(new ResourceIdentifier(scope)); // invoke the operation string guestConfigurationAssignmentName = "SecureProtocol"; @@ -178,40 +195,5 @@ public async Task GetIfExists_GetAGuestConfigurationAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllGuestConfigurationAssignmentsForAVirtualMachine() - { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/listGuestConfigurationAssignments.json - // this example is just showing the usage of "GuestConfigurationAssignments_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this GuestConfigurationVmAssignmentResource - string subscriptionId = "mySubscriptionId"; - string resourceGroupName = "myResourceGroupName"; - string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}", subscriptionId, resourceGroupName, vmName)); - GuestConfigurationVmAssignmentCollection collection = client.GetGuestConfigurationVmAssignments(scopeId); - - // invoke the operation and iterate over the result - await foreach (GuestConfigurationVmAssignmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GuestConfigurationAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmAssignmentResource.cs b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmAssignmentResource.cs index 7edb0a01276ac..c913d1b1bc7d6 100644 --- a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmAssignmentResource.cs +++ b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GuestConfigurationVmAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateGuestConfigurationAssignment() + public async Task Get_GetAGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/createOrUpdateGuestConfigurationAssignment.json - // this example is just showing the usage of "GuestConfigurationAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/getGuestConfigurationAssignment.json + // this example is just showing the usage of "GuestConfigurationAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,39 +33,12 @@ public async Task Update_CreateOrUpdateGuestConfigurationAssignment() string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - string guestConfigurationAssignmentName = "NotInstalledApplicationForWindows"; + string guestConfigurationAssignmentName = "SecureProtocol"; ResourceIdentifier guestConfigurationVmAssignmentResourceId = GuestConfigurationVmAssignmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName, guestConfigurationAssignmentName); GuestConfigurationVmAssignmentResource guestConfigurationVmAssignment = client.GetGuestConfigurationVmAssignmentResource(guestConfigurationVmAssignmentResourceId); // invoke the operation - GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData() - { - Properties = new GuestConfigurationAssignmentProperties() - { - GuestConfiguration = new GuestConfigurationNavigation() - { - Name = "NotInstalledApplicationForWindows", - Version = "1.0.0.3", - ContentUri = new Uri("https://thisisfake/pacakge"), - ContentHash = "123contenthash", - ContentManagedIdentity = "test_identity", - AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, - ConfigurationParameters = -{ -new GuestConfigurationParameter() -{ -Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", -Value = "NotePad,sql", -} -}, - }, - Context = "Azure policy", - }, - Name = "NotInstalledApplicationForWindows", - Location = new AzureLocation("westcentralus"), - }; - ArmOperation lro = await guestConfigurationVmAssignment.UpdateAsync(WaitUntil.Completed, data); - GuestConfigurationVmAssignmentResource result = lro.Value; + GuestConfigurationVmAssignmentResource result = await guestConfigurationVmAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -76,10 +49,10 @@ public async Task Update_CreateOrUpdateGuestConfigurationAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGuestConfigurationAssignment() + public async Task Delete_DeleteAnGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/getGuestConfigurationAssignment.json - // this example is just showing the usage of "GuestConfigurationAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/deleteGuestConfigurationAssignment.json + // this example is just showing the usage of "GuestConfigurationAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,21 +69,17 @@ public async Task Get_GetAGuestConfigurationAssignment() GuestConfigurationVmAssignmentResource guestConfigurationVmAssignment = client.GetGuestConfigurationVmAssignmentResource(guestConfigurationVmAssignmentResourceId); // invoke the operation - GuestConfigurationVmAssignmentResource result = await guestConfigurationVmAssignment.GetAsync(); + await guestConfigurationVmAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GuestConfigurationAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnGuestConfigurationAssignment() + public async Task Update_CreateOrUpdateGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/deleteGuestConfigurationAssignment.json - // this example is just showing the usage of "GuestConfigurationAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/createOrUpdateGuestConfigurationAssignment.json + // this example is just showing the usage of "GuestConfigurationAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,14 +91,42 @@ public async Task Delete_DeleteAnGuestConfigurationAssignment() string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - string guestConfigurationAssignmentName = "SecureProtocol"; + string guestConfigurationAssignmentName = "NotInstalledApplicationForWindows"; ResourceIdentifier guestConfigurationVmAssignmentResourceId = GuestConfigurationVmAssignmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmName, guestConfigurationAssignmentName); GuestConfigurationVmAssignmentResource guestConfigurationVmAssignment = client.GetGuestConfigurationVmAssignmentResource(guestConfigurationVmAssignmentResourceId); // invoke the operation - await guestConfigurationVmAssignment.DeleteAsync(WaitUntil.Completed); + GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData + { + Properties = new GuestConfigurationAssignmentProperties + { + GuestConfiguration = new GuestConfigurationNavigation + { + Name = "NotInstalledApplicationForWindows", + Version = "1.0.0.3", + ContentUri = new Uri("https://thisisfake/pacakge"), + ContentHash = "123contenthash", + ContentManagedIdentity = "test_identity", + AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, + ConfigurationParameters = {new GuestConfigurationParameter +{ +Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", +Value = "NotePad,sql", +}}, + }, + Context = "Azure policy", + }, + Name = "NotInstalledApplicationForWindows", + Location = new AzureLocation("westcentralus"), + }; + ArmOperation lro = await guestConfigurationVmAssignment.UpdateAsync(WaitUntil.Completed, data); + GuestConfigurationVmAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GuestConfigurationAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmssAssignmentCollection.cs b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmssAssignmentCollection.cs index cac8528484719..bec92da6c153d 100644 --- a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmssAssignmentCollection.cs +++ b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmssAssignmentCollection.cs @@ -28,23 +28,20 @@ public async Task CreateOrUpdate_CreateOrUpdateGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVmssAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmssName = "myVMSSName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachineScaleSets/{2}", subscriptionId, resourceGroupName, vmssName)); - GuestConfigurationVmssAssignmentCollection collection = client.GetGuestConfigurationVmssAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}"; + GuestConfigurationVmssAssignmentCollection collection = client.GetGuestConfigurationVmssAssignments(new ResourceIdentifier(scope)); // invoke the operation string name = "NotInstalledApplicationForWindows"; - GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData() + GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData { - Properties = new GuestConfigurationAssignmentProperties() + Properties = new GuestConfigurationAssignmentProperties { - GuestConfiguration = new GuestConfigurationNavigation() + GuestConfiguration = new GuestConfigurationNavigation { Name = "NotInstalledApplicationForWindows", Version = "1.0.0.3", @@ -52,14 +49,11 @@ public async Task CreateOrUpdate_CreateOrUpdateGuestConfigurationAssignment() ContentHash = "123contenthash", ContentManagedIdentity = "test_identity", AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, - ConfigurationParameters = -{ -new GuestConfigurationParameter() + ConfigurationParameters = {new GuestConfigurationParameter { Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", Value = "NotePad,sql", -} -}, +}}, }, Context = "Azure policy", }, @@ -88,15 +82,12 @@ public async Task Get_GetAVMSSGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVmssAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmssName = "myVMSSName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachineScaleSets/{2}", subscriptionId, resourceGroupName, vmssName)); - GuestConfigurationVmssAssignmentCollection collection = client.GetGuestConfigurationVmssAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}"; + GuestConfigurationVmssAssignmentCollection collection = client.GetGuestConfigurationVmssAssignments(new ResourceIdentifier(scope)); // invoke the operation string name = "SecureProtocol"; @@ -109,6 +100,38 @@ public async Task Get_GetAVMSSGuestConfigurationAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAllGuestConfigurationAssignmentsForVMSS() + { + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/listVMSSGuestConfigurationAssignments.json + // this example is just showing the usage of "GuestConfigurationAssignmentsVMSS_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this GuestConfigurationVmssAssignmentResource + string subscriptionId = "mySubscriptionId"; + string resourceGroupName = "myResourceGroupName"; + string vmssName = "myVMSSName"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}"; + GuestConfigurationVmssAssignmentCollection collection = client.GetGuestConfigurationVmssAssignments(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (GuestConfigurationVmssAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GuestConfigurationAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAVMSSGuestConfigurationAssignment() @@ -121,15 +144,12 @@ public async Task Exists_GetAVMSSGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVmssAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmssName = "myVMSSName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachineScaleSets/{2}", subscriptionId, resourceGroupName, vmssName)); - GuestConfigurationVmssAssignmentCollection collection = client.GetGuestConfigurationVmssAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}"; + GuestConfigurationVmssAssignmentCollection collection = client.GetGuestConfigurationVmssAssignments(new ResourceIdentifier(scope)); // invoke the operation string name = "SecureProtocol"; @@ -150,15 +170,12 @@ public async Task GetIfExists_GetAVMSSGuestConfigurationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GuestConfigurationVmssAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmssName = "myVMSSName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachineScaleSets/{2}", subscriptionId, resourceGroupName, vmssName)); - GuestConfigurationVmssAssignmentCollection collection = client.GetGuestConfigurationVmssAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}"; + GuestConfigurationVmssAssignmentCollection collection = client.GetGuestConfigurationVmssAssignments(new ResourceIdentifier(scope)); // invoke the operation string name = "SecureProtocol"; @@ -178,40 +195,5 @@ public async Task GetIfExists_GetAVMSSGuestConfigurationAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllGuestConfigurationAssignmentsForVMSS() - { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/listVMSSGuestConfigurationAssignments.json - // this example is just showing the usage of "GuestConfigurationAssignmentsVMSS_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this GuestConfigurationVmssAssignmentResource - string subscriptionId = "mySubscriptionId"; - string resourceGroupName = "myResourceGroupName"; - string vmssName = "myVMSSName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachineScaleSets/{2}", subscriptionId, resourceGroupName, vmssName)); - GuestConfigurationVmssAssignmentCollection collection = client.GetGuestConfigurationVmssAssignments(scopeId); - - // invoke the operation and iterate over the result - await foreach (GuestConfigurationVmssAssignmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GuestConfigurationAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmssAssignmentResource.cs b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmssAssignmentResource.cs index d8215497f1d3a..1f20f70270f45 100644 --- a/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmssAssignmentResource.cs +++ b/sdk/guestconfiguration/Azure.ResourceManager.GuestConfiguration/samples/Generated/Samples/Sample_GuestConfigurationVmssAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GuestConfigurationVmssAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateGuestConfigurationAssignment() + public async Task Get_GetAVMSSGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/createOrUpdateGuestConfigurationVMSSAssignment.json - // this example is just showing the usage of "GuestConfigurationAssignmentsVMSS_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/getVMSSGuestConfigurationAssignment.json + // this example is just showing the usage of "GuestConfigurationAssignmentsVMSS_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,39 +33,12 @@ public async Task Update_CreateOrUpdateGuestConfigurationAssignment() string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmssName = "myVMSSName"; - string name = "NotInstalledApplicationForWindows"; + string name = "SecureProtocol"; ResourceIdentifier guestConfigurationVmssAssignmentResourceId = GuestConfigurationVmssAssignmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmssName, name); GuestConfigurationVmssAssignmentResource guestConfigurationVmssAssignment = client.GetGuestConfigurationVmssAssignmentResource(guestConfigurationVmssAssignmentResourceId); // invoke the operation - GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData() - { - Properties = new GuestConfigurationAssignmentProperties() - { - GuestConfiguration = new GuestConfigurationNavigation() - { - Name = "NotInstalledApplicationForWindows", - Version = "1.0.0.3", - ContentUri = new Uri("https://thisisfake/pacakge"), - ContentHash = "123contenthash", - ContentManagedIdentity = "test_identity", - AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, - ConfigurationParameters = -{ -new GuestConfigurationParameter() -{ -Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", -Value = "NotePad,sql", -} -}, - }, - Context = "Azure policy", - }, - Name = "NotInstalledApplicationForWindows", - Location = new AzureLocation("westcentralus"), - }; - ArmOperation lro = await guestConfigurationVmssAssignment.UpdateAsync(WaitUntil.Completed, data); - GuestConfigurationVmssAssignmentResource result = lro.Value; + GuestConfigurationVmssAssignmentResource result = await guestConfigurationVmssAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -76,10 +49,10 @@ public async Task Update_CreateOrUpdateGuestConfigurationAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVMSSGuestConfigurationAssignment() + public async Task Delete_DeleteAnGuestConfigurationAssignmentForVMSS() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/getVMSSGuestConfigurationAssignment.json - // this example is just showing the usage of "GuestConfigurationAssignmentsVMSS_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/deleteGuestConfigurationVMSSAssignment.json + // this example is just showing the usage of "GuestConfigurationAssignmentsVMSS_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,7 +69,8 @@ public async Task Get_GetAVMSSGuestConfigurationAssignment() GuestConfigurationVmssAssignmentResource guestConfigurationVmssAssignment = client.GetGuestConfigurationVmssAssignmentResource(guestConfigurationVmssAssignmentResourceId); // invoke the operation - GuestConfigurationVmssAssignmentResource result = await guestConfigurationVmssAssignment.GetAsync(); + ArmOperation lro = await guestConfigurationVmssAssignment.DeleteAsync(WaitUntil.Completed); + GuestConfigurationVmssAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -107,10 +81,10 @@ public async Task Get_GetAVMSSGuestConfigurationAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnGuestConfigurationAssignmentForVMSS() + public async Task Update_CreateOrUpdateGuestConfigurationAssignment() { - // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/deleteGuestConfigurationVMSSAssignment.json - // this example is just showing the usage of "GuestConfigurationAssignmentsVMSS_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/guestconfiguration/resource-manager/Microsoft.GuestConfiguration/stable/2024-04-05/examples/createOrUpdateGuestConfigurationVMSSAssignment.json + // this example is just showing the usage of "GuestConfigurationAssignmentsVMSS_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,12 +96,35 @@ public async Task Delete_DeleteAnGuestConfigurationAssignmentForVMSS() string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmssName = "myVMSSName"; - string name = "SecureProtocol"; + string name = "NotInstalledApplicationForWindows"; ResourceIdentifier guestConfigurationVmssAssignmentResourceId = GuestConfigurationVmssAssignmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, vmssName, name); GuestConfigurationVmssAssignmentResource guestConfigurationVmssAssignment = client.GetGuestConfigurationVmssAssignmentResource(guestConfigurationVmssAssignmentResourceId); // invoke the operation - ArmOperation lro = await guestConfigurationVmssAssignment.DeleteAsync(WaitUntil.Completed); + GuestConfigurationAssignmentData data = new GuestConfigurationAssignmentData + { + Properties = new GuestConfigurationAssignmentProperties + { + GuestConfiguration = new GuestConfigurationNavigation + { + Name = "NotInstalledApplicationForWindows", + Version = "1.0.0.3", + ContentUri = new Uri("https://thisisfake/pacakge"), + ContentHash = "123contenthash", + ContentManagedIdentity = "test_identity", + AssignmentType = GuestConfigurationAssignmentType.ApplyAndAutoCorrect, + ConfigurationParameters = {new GuestConfigurationParameter +{ +Name = "[InstalledApplication]NotInstalledApplicationResource1;Name", +Value = "NotePad,sql", +}}, + }, + Context = "Azure policy", + }, + Name = "NotInstalledApplicationForWindows", + Location = new AzureLocation("westcentralus"), + }; + ArmOperation lro = await guestConfigurationVmssAssignment.UpdateAsync(WaitUntil.Completed, data); GuestConfigurationVmssAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterCollection.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterCollection.cs index 6063de695d547..7d674600d4051 100644 --- a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterCollection.cs +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterCollection.cs @@ -44,7 +44,7 @@ public async Task CreateOrUpdate_CloudHsmClusterCreateOrUpdateMaximumSetGen() string cloudHsmClusterName = "chsm1"; CloudHsmClusterData data = new CloudHsmClusterData(new AzureLocation("eastus2")) { - Properties = new CloudHsmClusterProperties() + Properties = new CloudHsmClusterProperties { PublicNetworkAccess = CloudHsmClusterPublicNetworkAccess.Disabled, }, @@ -52,14 +52,14 @@ public async Task CreateOrUpdate_CloudHsmClusterCreateOrUpdateMaximumSetGen() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-1")] = new UserAssignedIdentity() }, }, Sku = new CloudHsmClusterSku(CloudHsmClusterSkuFamily.B, CloudHsmClusterSkuName.StandardB1), Tags = { ["Dept"] = "hsm", -["Environment"] = "dogfood", +["Environment"] = "dogfood" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudHsmClusterName, data); @@ -107,10 +107,10 @@ public async Task Get_CloudHsmClusterGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CloudHsmClusterGetMaximumSetGen() + public async Task GetAll_CloudHsmClusterListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmCluster_Get_MaximumSet_Gen.json - // this example is just showing the usage of "CloudHsmClusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmCluster_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,16 +127,22 @@ public async Task Exists_CloudHsmClusterGetMaximumSetGen() // get the collection of this CloudHsmClusterResource CloudHsmClusterCollection collection = resourceGroupResource.GetCloudHsmClusters(); - // invoke the operation - string cloudHsmClusterName = "chsm1"; - bool result = await collection.ExistsAsync(cloudHsmClusterName); + // invoke the operation and iterate over the result + await foreach (CloudHsmClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudHsmClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CloudHsmClusterGetMaximumSetGen() + public async Task Exists_CloudHsmClusterGetMaximumSetGen() { // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmCluster_Get_MaximumSet_Gen.json // this example is just showing the usage of "CloudHsmClusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -158,29 +164,17 @@ public async Task GetIfExists_CloudHsmClusterGetMaximumSetGen() // invoke the operation string cloudHsmClusterName = "chsm1"; - NullableResponse response = await collection.GetIfExistsAsync(cloudHsmClusterName); - CloudHsmClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(cloudHsmClusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudHsmClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CloudHsmClusterListByResourceGroupMaximumSetGen() + public async Task GetIfExists_CloudHsmClusterGetMaximumSetGen() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmCluster_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "CloudHsmClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmCluster_Get_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -197,17 +191,23 @@ public async Task GetAll_CloudHsmClusterListByResourceGroupMaximumSetGen() // get the collection of this CloudHsmClusterResource CloudHsmClusterCollection collection = resourceGroupResource.GetCloudHsmClusters(); - // invoke the operation and iterate over the result - await foreach (CloudHsmClusterResource item in collection.GetAllAsync()) + // invoke the operation + string cloudHsmClusterName = "chsm1"; + NullableResponse response = await collection.GetIfExistsAsync(cloudHsmClusterName); + CloudHsmClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CloudHsmClusterData resourceData = item.Data; + CloudHsmClusterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterPrivateEndpointConnectionCollection.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterPrivateEndpointConnectionCollection.cs index 3804def0b1a84..f70db6dc246fc 100644 --- a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterPrivateEndpointConnectionCollection.cs +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterPrivateEndpointConnectionCollection.cs @@ -41,9 +41,9 @@ public async Task CreateOrUpdate_CloudHsmClusterPrivateEndpointConnectionCreateM // invoke the operation string peConnectionName = "sample-pec"; - CloudHsmClusterPrivateEndpointConnectionData data = new CloudHsmClusterPrivateEndpointConnectionData() + CloudHsmClusterPrivateEndpointConnectionData data = new CloudHsmClusterPrivateEndpointConnectionData { - Properties = new CloudHsmClusterPrivateEndpointConnectionProperties(new CloudHsmClusterPrivateLinkServiceConnectionState() + Properties = new CloudHsmClusterPrivateEndpointConnectionProperties(new CloudHsmClusterPrivateLinkServiceConnectionState { Status = CloudHsmClusterPrivateEndpointServiceConnectionStatus.Approved, Description = "My name is Joe and I'm approving this.", @@ -95,10 +95,10 @@ public async Task Get_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() + public async Task GetAll_CloudHsmClusterPrivateEndpointConnectionListByResourceMaximumSetGen() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json - // this example is just showing the usage of "CloudHsmClusterPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmClusterPrivateEndpointConnection_ListByCloudHsmCluster_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByCloudHsmCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,16 +116,22 @@ public async Task Exists_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGe // get the collection of this CloudHsmClusterPrivateEndpointConnectionResource CloudHsmClusterPrivateEndpointConnectionCollection collection = cloudHsmCluster.GetCloudHsmClusterPrivateEndpointConnections(); - // invoke the operation - string peConnectionName = "sample-pec"; - bool result = await collection.ExistsAsync(peConnectionName); + // invoke the operation and iterate over the result + await foreach (CloudHsmClusterPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudHsmClusterPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() + public async Task Exists_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() { // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json // this example is just showing the usage of "CloudHsmClusterPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +154,17 @@ public async Task GetIfExists_CloudHsmClusterPrivateEndpointConnectionGetMaximum // invoke the operation string peConnectionName = "sample-pec"; - NullableResponse response = await collection.GetIfExistsAsync(peConnectionName); - CloudHsmClusterPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(peConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudHsmClusterPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CloudHsmClusterPrivateEndpointConnectionListByResourceMaximumSetGen() + public async Task GetIfExists_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmClusterPrivateEndpointConnection_ListByCloudHsmCluster_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByCloudHsmCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusterPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_CloudHsmClusterPrivateEndpointConnectionListByResourceM // get the collection of this CloudHsmClusterPrivateEndpointConnectionResource CloudHsmClusterPrivateEndpointConnectionCollection collection = cloudHsmCluster.GetCloudHsmClusterPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (CloudHsmClusterPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string peConnectionName = "sample-pec"; + NullableResponse response = await collection.GetIfExistsAsync(peConnectionName); + CloudHsmClusterPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CloudHsmClusterPrivateEndpointConnectionData resourceData = item.Data; + CloudHsmClusterPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterPrivateEndpointConnectionResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterPrivateEndpointConnectionResource.cs index fcbaaba2f4912..4d8eabb454e1c 100644 --- a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterPrivateEndpointConnectionResource.cs +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_CloudHsmClusterPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CloudHsmClusterPrivateEndpointConnectionCreateMaximumSetGen() + public async Task Get_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmClusterPrivateEndpointConnection_Create_MaximumSet_Gen.json - // this example is just showing the usage of "CloudHsmClusterPrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusterPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,7 @@ public async Task Update_CloudHsmClusterPrivateEndpointConnectionCreateMaximumSe CloudHsmClusterPrivateEndpointConnectionResource cloudHsmClusterPrivateEndpointConnection = client.GetCloudHsmClusterPrivateEndpointConnectionResource(cloudHsmClusterPrivateEndpointConnectionResourceId); // invoke the operation - CloudHsmClusterPrivateEndpointConnectionData data = new CloudHsmClusterPrivateEndpointConnectionData() - { - Properties = new CloudHsmClusterPrivateEndpointConnectionProperties(new CloudHsmClusterPrivateLinkServiceConnectionState() - { - Status = CloudHsmClusterPrivateEndpointServiceConnectionStatus.Approved, - Description = "My name is Joe and I'm approving this.", - }), - }; - ArmOperation lro = await cloudHsmClusterPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - CloudHsmClusterPrivateEndpointConnectionResource result = lro.Value; + CloudHsmClusterPrivateEndpointConnectionResource result = await cloudHsmClusterPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,10 +76,10 @@ public async Task Delete_CloudHsmClusterPrivateEndpointConnectionDeleteMaximumSe [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() + public async Task Update_CloudHsmClusterPrivateEndpointConnectionCreateMaximumSetGen() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmClusterPrivateEndpointConnection_Get_MaximumSet_Gen.json - // this example is just showing the usage of "CloudHsmClusterPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmClusterPrivateEndpointConnection_Create_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusterPrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,7 +96,16 @@ public async Task Get_CloudHsmClusterPrivateEndpointConnectionGetMaximumSetGen() CloudHsmClusterPrivateEndpointConnectionResource cloudHsmClusterPrivateEndpointConnection = client.GetCloudHsmClusterPrivateEndpointConnectionResource(cloudHsmClusterPrivateEndpointConnectionResourceId); // invoke the operation - CloudHsmClusterPrivateEndpointConnectionResource result = await cloudHsmClusterPrivateEndpointConnection.GetAsync(); + CloudHsmClusterPrivateEndpointConnectionData data = new CloudHsmClusterPrivateEndpointConnectionData + { + Properties = new CloudHsmClusterPrivateEndpointConnectionProperties(new CloudHsmClusterPrivateLinkServiceConnectionState + { + Status = CloudHsmClusterPrivateEndpointServiceConnectionStatus.Approved, + Description = "My name is Joe and I'm approving this.", + }), + }; + ArmOperation lro = await cloudHsmClusterPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + CloudHsmClusterPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterResource.cs index 0164fc67a9218..6f32aa04cc439 100644 --- a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterResource.cs +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_CloudHsmClusterResource.cs @@ -11,60 +11,12 @@ using Azure.Identity; using Azure.ResourceManager.HardwareSecurityModules.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HardwareSecurityModules.Samples { public partial class Sample_CloudHsmClusterResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_CloudHsmClusterUpdateMaximumSetGen() - { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmCluster_Update_MaximumSet_Gen.json - // this example is just showing the usage of "CloudHsmClusters_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CloudHsmClusterResource created on azure - // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rgcloudhsm"; - string cloudHsmClusterName = "chsm1"; - ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); - CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); - - // invoke the operation - CloudHsmClusterPatch patch = new CloudHsmClusterPatch() - { - Tags = -{ -["Dept"] = "hsm", -["Environment"] = "dogfood", -["Slice"] = "A", -}, - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-1")] = new UserAssignedIdentity(), -}, - }, - }; - ArmOperation lro = await cloudHsmCluster.UpdateAsync(WaitUntil.Completed, patch); - CloudHsmClusterResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudHsmClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_CloudHsmClusterGetMaximumSetGen() @@ -123,33 +75,49 @@ public async Task Delete_CloudHsmClusterDeleteMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetCloudHsmClusters_CloudHsmClusterListBySubscriptionMaximumSetGen() + public async Task Update_CloudHsmClusterUpdateMaximumSetGen() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmCluster_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "CloudHsmClusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmCluster_Update_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this CloudHsmClusterResource created on azure + // for more information of creating CloudHsmClusterResource, please refer to the document of CloudHsmClusterResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rgcloudhsm"; + string cloudHsmClusterName = "chsm1"; + ResourceIdentifier cloudHsmClusterResourceId = CloudHsmClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cloudHsmClusterName); + CloudHsmClusterResource cloudHsmCluster = client.GetCloudHsmClusterResource(cloudHsmClusterResourceId); - // invoke the operation and iterate over the result - await foreach (CloudHsmClusterResource item in subscriptionResource.GetCloudHsmClustersAsync()) + // invoke the operation + CloudHsmClusterPatch patch = new CloudHsmClusterPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudHsmClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["Dept"] = "hsm", +["Environment"] = "dogfood", +["Slice"] = "A" +}, + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contoso-resources/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-1")] = new UserAssignedIdentity() +}, + }, + }; + ArmOperation lro = await cloudHsmCluster.UpdateAsync(WaitUntil.Completed, patch); + CloudHsmClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudHsmClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_DedicatedHsmCollection.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_DedicatedHsmCollection.cs index 1ab0acb40c988..70e691a00fa11 100644 --- a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_DedicatedHsmCollection.cs +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_DedicatedHsmCollection.cs @@ -41,21 +41,18 @@ public async Task CreateOrUpdate_CreateANewOrUpdateAnExistingDedicatedHSM() // invoke the operation string name = "hsm1"; - DedicatedHsmData data = new DedicatedHsmData(new AzureLocation("westus"), new DedicatedHsmSku() + DedicatedHsmData data = new DedicatedHsmData(new AzureLocation("westus"), new DedicatedHsmSku { Name = new DedicatedHsmSkuName("SafeNet Luna Network HSM A790"), - }, new DedicatedHsmProperties() + }, new DedicatedHsmProperties { - NetworkProfile = new DedicatedHsmNetworkProfile() + NetworkProfile = new DedicatedHsmNetworkProfile { SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01"), - NetworkInterfaces = -{ -new DedicatedHsmNetworkInterface() + NetworkInterfaces = {new DedicatedHsmNetworkInterface { PrivateIPAddress = "1.0.0.1", -} -}, +}}, }, StampId = "stamp01", }) @@ -63,7 +60,7 @@ public async Task CreateOrUpdate_CreateANewOrUpdateAnExistingDedicatedHSM() Tags = { ["Dept"] = "hsm", -["Environment"] = "dogfood", +["Environment"] = "dogfood" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); @@ -100,21 +97,18 @@ public async Task CreateOrUpdate_CreateANewOrUpdateAnExistingPaymentHSM() // invoke the operation string name = "hsm1"; - DedicatedHsmData data = new DedicatedHsmData(new AzureLocation("westus"), new DedicatedHsmSku() + DedicatedHsmData data = new DedicatedHsmData(new AzureLocation("westus"), new DedicatedHsmSku { Name = DedicatedHsmSkuName.PayShield10KLmk1Cps60, - }, new DedicatedHsmProperties() + }, new DedicatedHsmProperties { - NetworkProfile = new DedicatedHsmNetworkProfile() + NetworkProfile = new DedicatedHsmNetworkProfile { SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01"), - NetworkInterfaces = -{ -new DedicatedHsmNetworkInterface() + NetworkInterfaces = {new DedicatedHsmNetworkInterface { PrivateIPAddress = "1.0.0.1", -} -}, +}}, }, StampId = "stamp01", }) @@ -122,7 +116,7 @@ public async Task CreateOrUpdate_CreateANewOrUpdateAnExistingPaymentHSM() Tags = { ["Dept"] = "hsm", -["Environment"] = "dogfood", +["Environment"] = "dogfood" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); @@ -159,32 +153,26 @@ public async Task CreateOrUpdate_CreateANewOrUpdateAnExistingPaymentHSMWithManag // invoke the operation string name = "hsm1"; - DedicatedHsmData data = new DedicatedHsmData(new AzureLocation("westus"), new DedicatedHsmSku() + DedicatedHsmData data = new DedicatedHsmData(new AzureLocation("westus"), new DedicatedHsmSku { Name = DedicatedHsmSkuName.PayShield10KLmk1Cps60, - }, new DedicatedHsmProperties() + }, new DedicatedHsmProperties { - NetworkProfile = new DedicatedHsmNetworkProfile() + NetworkProfile = new DedicatedHsmNetworkProfile { SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01"), - NetworkInterfaces = -{ -new DedicatedHsmNetworkInterface() + NetworkInterfaces = {new DedicatedHsmNetworkInterface { PrivateIPAddress = "1.0.0.1", -} -}, +}}, }, - ManagementNetworkProfile = new DedicatedHsmNetworkProfile() + ManagementNetworkProfile = new DedicatedHsmNetworkProfile { SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.Network/virtualNetworks/stamp01/subnets/stamp01"), - NetworkInterfaces = -{ -new DedicatedHsmNetworkInterface() + NetworkInterfaces = {new DedicatedHsmNetworkInterface { PrivateIPAddress = "1.0.0.2", -} -}, +}}, }, StampId = "stamp01", }) @@ -192,7 +180,7 @@ public async Task CreateOrUpdate_CreateANewOrUpdateAnExistingPaymentHSMWithManag Tags = { ["Dept"] = "hsm", -["Environment"] = "dogfood", +["Environment"] = "dogfood" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); @@ -240,9 +228,9 @@ public async Task Get_GetADedicatedHSM() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADedicatedHSM() + public async Task Get_GetAPaymentHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_Get.json + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get.json // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -262,16 +250,20 @@ public async Task Exists_GetADedicatedHSM() // invoke the operation string name = "hsm1"; - bool result = await collection.ExistsAsync(name); + DedicatedHsmResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADedicatedHSM() + public async Task Get_GetAPaymentHSMWith20181031PreviewApiVersion() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_Get.json + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get_With_2018-10-31Preview_Version.json // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -291,29 +283,21 @@ public async Task GetIfExists_GetADedicatedHSM() // invoke the operation string name = "hsm1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DedicatedHsmResource result = response.HasValue ? response.Value : null; + DedicatedHsmResource result = await collection.GetAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHsmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPaymentHSM() + public async Task GetAll_ListDedicatedHSMDevicesInAResourceGroup() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get.json - // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_ListByResourceGroup.json + // this example is just showing the usage of "DedicatedHsm_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -330,23 +314,25 @@ public async Task Get_GetAPaymentHSM() // get the collection of this DedicatedHsmResource DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); - // invoke the operation - string name = "hsm1"; - DedicatedHsmResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (DedicatedHsmResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHsmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHsmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPaymentHSM() + public async Task GetAll_ListDedicatedHSMDevicesInAResourceGroupIncludingPaymentHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get.json - // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_ListByResourceGroup.json + // this example is just showing the usage of "DedicatedHsm_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -363,18 +349,24 @@ public async Task Exists_GetAPaymentHSM() // get the collection of this DedicatedHsmResource DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); - // invoke the operation - string name = "hsm1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DedicatedHsmResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHsmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPaymentHSM() + public async Task Exists_GetADedicatedHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get.json + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_Get.json // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -394,28 +386,16 @@ public async Task GetIfExists_GetAPaymentHSM() // invoke the operation string name = "hsm1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DedicatedHsmResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHsmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPaymentHSMWith20181031PreviewApiVersion() + public async Task Exists_GetAPaymentHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get_With_2018-10-31Preview_Version.json + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get.json // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -435,13 +415,9 @@ public async Task Get_GetAPaymentHSMWith20181031PreviewApiVersion() // invoke the operation string name = "hsm1"; - DedicatedHsmResource result = await collection.GetAsync(name); + bool result = await collection.ExistsAsync(name); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHsmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -475,9 +451,9 @@ public async Task Exists_GetAPaymentHSMWith20181031PreviewApiVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPaymentHSMWith20181031PreviewApiVersion() + public async Task GetIfExists_GetADedicatedHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get_With_2018-10-31Preview_Version.json + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_Get.json // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -516,10 +492,10 @@ public async Task GetIfExists_GetAPaymentHSMWith20181031PreviewApiVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDedicatedHSMDevicesInAResourceGroup() + public async Task GetIfExists_GetAPaymentHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_ListByResourceGroup.json - // this example is just showing the usage of "DedicatedHsm_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -536,25 +512,31 @@ public async Task GetAll_ListDedicatedHSMDevicesInAResourceGroup() // get the collection of this DedicatedHsmResource DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); - // invoke the operation and iterate over the result - await foreach (DedicatedHsmResource item in collection.GetAllAsync()) + // invoke the operation + string name = "hsm1"; + NullableResponse response = await collection.GetIfExistsAsync(name); + DedicatedHsmResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DedicatedHsmData resourceData = item.Data; + DedicatedHsmData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDedicatedHSMDevicesInAResourceGroupIncludingPaymentHSM() + public async Task GetIfExists_GetAPaymentHSMWith20181031PreviewApiVersion() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_ListByResourceGroup.json - // this example is just showing the usage of "DedicatedHsm_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get_With_2018-10-31Preview_Version.json + // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -571,17 +553,23 @@ public async Task GetAll_ListDedicatedHSMDevicesInAResourceGroupIncludingPayment // get the collection of this DedicatedHsmResource DedicatedHsmCollection collection = resourceGroupResource.GetDedicatedHsms(); - // invoke the operation and iterate over the result - await foreach (DedicatedHsmResource item in collection.GetAllAsync()) + // invoke the operation + string name = "hsm1"; + NullableResponse response = await collection.GetIfExistsAsync(name); + DedicatedHsmResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DedicatedHsmData resourceData = item.Data; + DedicatedHsmData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_DedicatedHsmResource.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_DedicatedHsmResource.cs index c2ed7a9057b02..9cd16598a0dbb 100644 --- a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_DedicatedHsmResource.cs +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_DedicatedHsmResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HardwareSecurityModules.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HardwareSecurityModules.Samples @@ -19,10 +18,10 @@ public partial class Sample_DedicatedHsmResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnExistingDedicatedHSM() + public async Task Get_GetADedicatedHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_Update.json - // this example is just showing the usage of "DedicatedHsm_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,7 @@ public async Task Update_UpdateAnExistingDedicatedHSM() DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); // invoke the operation - DedicatedHsmPatch patch = new DedicatedHsmPatch() - { - Tags = -{ -["Dept"] = "hsm", -["Environment"] = "dogfood", -["Slice"] = "A", -}, - }; - ArmOperation lro = await dedicatedHsm.UpdateAsync(WaitUntil.Completed, patch); - DedicatedHsmResource result = lro.Value; + DedicatedHsmResource result = await dedicatedHsm.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -59,10 +48,10 @@ public async Task Update_UpdateAnExistingDedicatedHSM() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnExistingPaymentHSM() + public async Task Get_GetAPaymentHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Update.json - // this example is just showing the usage of "DedicatedHsm_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get.json + // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,17 +67,7 @@ public async Task Update_UpdateAnExistingPaymentHSM() DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); // invoke the operation - DedicatedHsmPatch patch = new DedicatedHsmPatch() - { - Tags = -{ -["Dept"] = "hsm", -["Environment"] = "dogfood", -["Slice"] = "A", -}, - }; - ArmOperation lro = await dedicatedHsm.UpdateAsync(WaitUntil.Completed, patch); - DedicatedHsmResource result = lro.Value; + DedicatedHsmResource result = await dedicatedHsm.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -99,10 +78,10 @@ public async Task Update_UpdateAnExistingPaymentHSM() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteADedicatedHSM() + public async Task Get_GetAPaymentHSMWith20181031PreviewApiVersion() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_Delete.json - // this example is just showing the usage of "DedicatedHsm_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get_With_2018-10-31Preview_Version.json + // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,17 +97,21 @@ public async Task Delete_DeleteADedicatedHSM() DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); // invoke the operation - await dedicatedHsm.DeleteAsync(WaitUntil.Completed); + DedicatedHsmResource result = await dedicatedHsm.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHsmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADedicatedHSM() + public async Task Delete_DeleteADedicatedHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_Get.json - // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_Delete.json + // this example is just showing the usage of "DedicatedHsm_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,21 +127,17 @@ public async Task Get_GetADedicatedHSM() DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); // invoke the operation - DedicatedHsmResource result = await dedicatedHsm.GetAsync(); + await dedicatedHsm.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHsmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPaymentHSM() + public async Task Update_UpdateAnExistingDedicatedHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get.json - // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_Update.json + // this example is just showing the usage of "DedicatedHsm_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,7 +153,17 @@ public async Task Get_GetAPaymentHSM() DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); // invoke the operation - DedicatedHsmResource result = await dedicatedHsm.GetAsync(); + DedicatedHsmPatch patch = new DedicatedHsmPatch + { + Tags = +{ +["Dept"] = "hsm", +["Environment"] = "dogfood", +["Slice"] = "A" +}, + }; + ArmOperation lro = await dedicatedHsm.UpdateAsync(WaitUntil.Completed, patch); + DedicatedHsmResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -185,10 +174,10 @@ public async Task Get_GetAPaymentHSM() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPaymentHSMWith20181031PreviewApiVersion() + public async Task Update_UpdateAnExistingPaymentHSM() { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Get_With_2018-10-31Preview_Version.json - // this example is just showing the usage of "DedicatedHsm_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_Update.json + // this example is just showing the usage of "DedicatedHsm_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,7 +193,17 @@ public async Task Get_GetAPaymentHSMWith20181031PreviewApiVersion() DedicatedHsmResource dedicatedHsm = client.GetDedicatedHsmResource(dedicatedHsmResourceId); // invoke the operation - DedicatedHsmResource result = await dedicatedHsm.GetAsync(); + DedicatedHsmPatch patch = new DedicatedHsmPatch + { + Tags = +{ +["Dept"] = "hsm", +["Environment"] = "dogfood", +["Slice"] = "A" +}, + }; + ArmOperation lro = await dedicatedHsm.UpdateAsync(WaitUntil.Completed, patch); + DedicatedHsmResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -213,68 +212,6 @@ public async Task Get_GetAPaymentHSMWith20181031PreviewApiVersion() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDedicatedHsms_ListDedicatedHSMDevicesInASubscription() - { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_ListBySubscription.json - // this example is just showing the usage of "DedicatedHsm_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DedicatedHsmResource item in subscriptionResource.GetDedicatedHsmsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHsmData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDedicatedHsms_ListDedicatedHSMDevicesInASubscriptionIncludingPaymentHSM() - { - // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_ListBySubscription.json - // this example is just showing the usage of "DedicatedHsm_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DedicatedHsmResource item in subscriptionResource.GetDedicatedHsmsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DedicatedHsmData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetOutboundNetworkDependenciesEndpoints_ListOutboundNetworkDependenciesEndpointsByManagedCluster() diff --git a/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..7a6fda5b25bdc --- /dev/null +++ b/sdk/hardwaresecuritymodules/Azure.ResourceManager.HardwareSecurityModules/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.HardwareSecurityModules.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCloudHsmClusters_CloudHsmClusterListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/CloudHsmCluster_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "CloudHsmClusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CloudHsmClusterResource item in subscriptionResource.GetCloudHsmClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudHsmClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDedicatedHsms_ListDedicatedHSMDevicesInASubscription() + { + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/DedicatedHsm_ListBySubscription.json + // this example is just showing the usage of "DedicatedHsm_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DedicatedHsmResource item in subscriptionResource.GetDedicatedHsmsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHsmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDedicatedHsms_ListDedicatedHSMDevicesInASubscriptionIncludingPaymentHSM() + { + // Generated from example definition: specification/hardwaresecuritymodules/resource-manager/Microsoft.HardwareSecurityModules/preview/2024-06-30-preview/examples/PaymentHsm_ListBySubscription.json + // this example is just showing the usage of "DedicatedHsm_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DedicatedHsmResource item in subscriptionResource.GetDedicatedHsmsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DedicatedHsmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightApplicationCollection.cs b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightApplicationCollection.cs index 0db171bf8c145..ab49d28b37cb2 100644 --- a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightApplicationCollection.cs +++ b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightApplicationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HDInsightApplicationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllApplicationsForAnHDInsightCluster() + public async Task CreateOrUpdate_CreateApplication() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetAllApplications.json - // this example is just showing the usage of "Applications_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/CreateApplication.json + // this example is just showing the usage of "Applications_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,41 @@ public async Task GetAll_GetAllApplicationsForAnHDInsightCluster() // get the collection of this HDInsightApplicationResource HDInsightApplicationCollection collection = hdInsightCluster.GetHDInsightApplications(); - // invoke the operation and iterate over the result - await foreach (HDInsightApplicationResource item in collection.GetAllAsync()) + // invoke the operation + string applicationName = "hue"; + HDInsightApplicationData data = new HDInsightApplicationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightApplicationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new HDInsightApplicationProperties + { + ComputeRoles = {new HDInsightClusterRole +{ +Name = "edgenode", +TargetInstanceCount = 1, +HardwareVmSize = "Standard_D12_v2", +}}, + InstallScriptActions = {new RuntimeScriptAction("app-install-app1", new Uri("https://.../install.sh"), new string[]{"edgenode"}) +{ +Parameters = "-version latest -port 20000", +}}, + UninstallScriptActions = { }, + HttpsEndpoints = {new HDInsightApplicationHttpsEndpoint +{ +AccessModes = {"WebPage"}, +DestinationPort = 20000, +SubDomainSuffix = "dss", +}}, + ApplicationType = "CustomApplication", + Errors = { }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); + HDInsightApplicationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,9 +112,9 @@ public async Task Get_GetApplicationOnHDInsightClusterCreationInProgress() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetApplicationOnHDInsightClusterCreationInProgress() + public async Task Get_GetApplicationOnHDInsightClusterSuccessfullyCreated() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetApplicationInProgress.json + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetApplicationCreated.json // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -111,17 +135,21 @@ public async Task Exists_GetApplicationOnHDInsightClusterCreationInProgress() // invoke the operation string applicationName = "app"; - bool result = await collection.ExistsAsync(applicationName); + HDInsightApplicationResource result = await collection.GetAsync(applicationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetApplicationOnHDInsightClusterCreationInProgress() + public async Task GetAll_GetAllApplicationsForAnHDInsightCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetApplicationInProgress.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetAllApplications.json + // this example is just showing the usage of "Applications_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,30 +167,24 @@ public async Task GetIfExists_GetApplicationOnHDInsightClusterCreationInProgress // get the collection of this HDInsightApplicationResource HDInsightApplicationCollection collection = hdInsightCluster.GetHDInsightApplications(); - // invoke the operation - string applicationName = "app"; - NullableResponse response = await collection.GetIfExistsAsync(applicationName); - HDInsightApplicationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HDInsightApplicationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HDInsightApplicationData resourceData = result.Data; + HDInsightApplicationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetApplicationOnHDInsightClusterSuccessfullyCreated() + public async Task Exists_GetApplicationOnHDInsightClusterCreationInProgress() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetApplicationCreated.json + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetApplicationInProgress.json // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -183,13 +205,9 @@ public async Task Get_GetApplicationOnHDInsightClusterSuccessfullyCreated() // invoke the operation string applicationName = "app"; - HDInsightApplicationResource result = await collection.GetAsync(applicationName); + bool result = await collection.ExistsAsync(applicationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -224,9 +242,9 @@ public async Task Exists_GetApplicationOnHDInsightClusterSuccessfullyCreated() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetApplicationOnHDInsightClusterSuccessfullyCreated() + public async Task GetIfExists_GetApplicationOnHDInsightClusterCreationInProgress() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetApplicationCreated.json + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetApplicationInProgress.json // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -266,10 +284,10 @@ public async Task GetIfExists_GetApplicationOnHDInsightClusterSuccessfullyCreate [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateApplication() + public async Task GetIfExists_GetApplicationOnHDInsightClusterSuccessfullyCreated() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/CreateApplication.json - // this example is just showing the usage of "Applications_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetApplicationCreated.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -288,59 +306,22 @@ public async Task CreateOrUpdate_CreateApplication() HDInsightApplicationCollection collection = hdInsightCluster.GetHDInsightApplications(); // invoke the operation - string applicationName = "hue"; - HDInsightApplicationData data = new HDInsightApplicationData() - { - Properties = new HDInsightApplicationProperties() - { - ComputeRoles = -{ -new HDInsightClusterRole() -{ -Name = "edgenode", -TargetInstanceCount = 1, -HardwareVmSize = "Standard_D12_v2", -} -}, - InstallScriptActions = -{ -new RuntimeScriptAction("app-install-app1",new Uri("https://.../install.sh"),new string[] -{ -"edgenode" -}) -{ -Parameters = "-version latest -port 20000", -} -}, - UninstallScriptActions = -{ -}, - HttpsEndpoints = -{ -new HDInsightApplicationHttpsEndpoint() -{ -AccessModes = -{ -"WebPage" -}, -DestinationPort = 20000, -SubDomainSuffix = "dss", -} -}, - ApplicationType = "CustomApplication", - Errors = -{ -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); - HDInsightApplicationResource result = lro.Value; + string applicationName = "app"; + NullableResponse response = await collection.GetIfExistsAsync(applicationName); + HDInsightApplicationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightApplicationResource.cs b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightApplicationResource.cs index e2f8141cfa648..93e87b0a18366 100644 --- a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightApplicationResource.cs +++ b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightApplicationResource.cs @@ -78,6 +78,33 @@ public async Task Get_GetApplicationOnHDInsightClusterSuccessfullyCreated() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteApplicationFromHDInsightCluster() + { + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/DeleteApplication.json + // this example is just showing the usage of "Applications_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HDInsightApplicationResource created on azure + // for more information of creating HDInsightApplicationResource, please refer to the document of HDInsightApplicationResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string clusterName = "cluster1"; + string applicationName = "hue"; + ResourceIdentifier hdInsightApplicationResourceId = HDInsightApplicationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, applicationName); + HDInsightApplicationResource hdInsightApplication = client.GetHDInsightApplicationResource(hdInsightApplicationResourceId); + + // invoke the operation + await hdInsightApplication.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateApplication() @@ -100,48 +127,29 @@ public async Task Update_CreateApplication() HDInsightApplicationResource hdInsightApplication = client.GetHDInsightApplicationResource(hdInsightApplicationResourceId); // invoke the operation - HDInsightApplicationData data = new HDInsightApplicationData() + HDInsightApplicationData data = new HDInsightApplicationData { - Properties = new HDInsightApplicationProperties() + Properties = new HDInsightApplicationProperties { - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "edgenode", TargetInstanceCount = 1, HardwareVmSize = "Standard_D12_v2", -} -}, - InstallScriptActions = -{ -new RuntimeScriptAction("app-install-app1",new Uri("https://.../install.sh"),new string[] -{ -"edgenode" -}) +}}, + InstallScriptActions = {new RuntimeScriptAction("app-install-app1", new Uri("https://.../install.sh"), new string[]{"edgenode"}) { Parameters = "-version latest -port 20000", -} -}, - UninstallScriptActions = +}}, + UninstallScriptActions = { }, + HttpsEndpoints = {new HDInsightApplicationHttpsEndpoint { -}, - HttpsEndpoints = -{ -new HDInsightApplicationHttpsEndpoint() -{ -AccessModes = -{ -"WebPage" -}, +AccessModes = {"WebPage"}, DestinationPort = 20000, SubDomainSuffix = "dss", -} -}, +}}, ApplicationType = "CustomApplication", - Errors = -{ -}, + Errors = { }, }, }; ArmOperation lro = await hdInsightApplication.UpdateAsync(WaitUntil.Completed, data); @@ -154,33 +162,6 @@ public async Task Update_CreateApplication() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteApplicationFromHDInsightCluster() - { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/DeleteApplication.json - // this example is just showing the usage of "Applications_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HDInsightApplicationResource created on azure - // for more information of creating HDInsightApplicationResource, please refer to the document of HDInsightApplicationResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string clusterName = "cluster1"; - string applicationName = "hue"; - ResourceIdentifier hdInsightApplicationResourceId = HDInsightApplicationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, applicationName); - HDInsightApplicationResource hdInsightApplication = client.GetHDInsightApplicationResource(hdInsightApplicationResourceId); - - // invoke the operation - await hdInsightApplication.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetAzureAsyncOperationStatus_GetTheAzureAsyncOperationStatus() diff --git a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightClusterCollection.cs b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightClusterCollection.cs index 75ec00dbe650d..e14a3cc7f16ab 100644 --- a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightClusterCollection.cs +++ b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightClusterCollection.cs @@ -42,122 +42,97 @@ public async Task CreateOrUpdate_CreateHDInsightClusterWithAutoscaleConfiguratio // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.6", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Standard, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "hadoop", ComponentVersion = { -["Hadoop"] = "2.7", +["Hadoop"] = "2.7" }, - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "workernode", TargetInstanceCount = 4, -AutoScaleConfiguration = new HDInsightAutoScaleConfiguration() +AutoScaleConfiguration = new HDInsightAutoScaleConfiguration { -Capacity = null, -Recurrence = new HDInsightAutoScaleRecurrence() +Capacity = default, +Recurrence = new HDInsightAutoScaleRecurrence { TimeZone = "China Standard Time", -Schedule = -{ -new HDInsightAutoScaleSchedule() +Schedule = {new HDInsightAutoScaleSchedule { -Days = -{ -HDInsightDayOfWeek.Monday,HDInsightDayOfWeek.Tuesday,HDInsightDayOfWeek.Wednesday,HDInsightDayOfWeek.Thursday,HDInsightDayOfWeek.Friday -}, -TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity() +Days = {HDInsightDayOfWeek.Monday, HDInsightDayOfWeek.Tuesday, HDInsightDayOfWeek.Wednesday, HDInsightDayOfWeek.Thursday, HDInsightDayOfWeek.Friday}, +TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity { Time = "09:00", MinInstanceCount = 3, MaxInstanceCount = 3, }, -},new HDInsightAutoScaleSchedule() +}, new HDInsightAutoScaleSchedule { -Days = -{ -HDInsightDayOfWeek.Monday,HDInsightDayOfWeek.Tuesday,HDInsightDayOfWeek.Wednesday,HDInsightDayOfWeek.Thursday,HDInsightDayOfWeek.Friday -}, -TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity() +Days = {HDInsightDayOfWeek.Monday, HDInsightDayOfWeek.Tuesday, HDInsightDayOfWeek.Wednesday, HDInsightDayOfWeek.Thursday, HDInsightDayOfWeek.Friday}, +TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity { Time = "18:00", MinInstanceCount = 6, MaxInstanceCount = 6, }, -},new HDInsightAutoScaleSchedule() +}, new HDInsightAutoScaleSchedule { -Days = -{ -HDInsightDayOfWeek.Saturday,HDInsightDayOfWeek.Sunday -}, -TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity() +Days = {HDInsightDayOfWeek.Saturday, HDInsightDayOfWeek.Sunday}, +TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity { Time = "09:00", MinInstanceCount = 2, MaxInstanceCount = 2, }, -},new HDInsightAutoScaleSchedule() +}, new HDInsightAutoScaleSchedule { -Days = -{ -HDInsightDayOfWeek.Saturday,HDInsightDayOfWeek.Sunday -}, -TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity() +Days = {HDInsightDayOfWeek.Saturday, HDInsightDayOfWeek.Sunday}, +TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity { Time = "18:00", MinInstanceCount = 4, MaxInstanceCount = 4, }, -} -}, +}}, }, }, HardwareVmSize = "Standard_D4_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -VirtualNetworkProfile = null, -DataDisksGroups = -{ -}, -ScriptActions = -{ -}, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +VirtualNetworkProfile = default, +DataDisksGroups = {}, +ScriptActions = {}, +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage.blob.core.windows.net", IsDefault = true, Container = "hdinsight-autoscale-tes-2019-06-18t05-49-16-591z", Key = "storagekey", EnableSecureChannel = true, -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content); @@ -194,78 +169,72 @@ public async Task CreateOrUpdate_CreateHadoopClusterWithAzureDataLakeStorageGen2 // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { Tags = { -["key1"] = "val1", +["key1"] = "val1" }, - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.6", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Standard, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "Hadoop", - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", MinInstanceCount = 1, TargetInstanceCount = 2, HardwareVmSize = "Standard_D3_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", MinInstanceCount = 1, TargetInstanceCount = 4, HardwareVmSize = "Standard_D3_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "zookeepernode", MinInstanceCount = 1, TargetInstanceCount = 3, HardwareVmSize = "Small", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage.dfs.core.windows.net", IsDefault = true, FileSystem = "default", Key = "storagekey", EnableSecureChannel = true, -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content); @@ -302,78 +271,72 @@ public async Task CreateOrUpdate_CreateHadoopOnLinuxClusterWithSSHPassword() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { Tags = { -["key1"] = "val1", +["key1"] = "val1" }, - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.5", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Standard, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "Hadoop", - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", MinInstanceCount = 1, TargetInstanceCount = 2, HardwareVmSize = "Standard_D3_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", MinInstanceCount = 1, TargetInstanceCount = 4, HardwareVmSize = "Standard_D3_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "zookeepernode", MinInstanceCount = 1, TargetInstanceCount = 3, HardwareVmSize = "Small", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage.blob.core.windows.net", IsDefault = true, Container = "containername", Key = "storagekey", EnableSecureChannel = true, -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content); @@ -410,84 +373,75 @@ public async Task CreateOrUpdate_CreateHadoopOnLinuxClusterWithSSHPublicKey() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { Tags = { -["key1"] = "val1", +["key1"] = "val1" }, - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.5", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Standard, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "Hadoop", - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", MinInstanceCount = 1, TargetInstanceCount = 2, HardwareVmSize = "Standard_D3_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", -SshPublicKeys = -{ -new HDInsightSshPublicKey() +SshPublicKeys = {new HDInsightSshPublicKey { CertificateData = "**********", -} -}, +}}, }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", MinInstanceCount = 1, TargetInstanceCount = 4, HardwareVmSize = "Standard_D3_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "zookeepernode", MinInstanceCount = 1, TargetInstanceCount = 3, HardwareVmSize = "Small", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage.blob.core.windows.net", IsDefault = true, Container = "containername", Key = "storagekey", EnableSecureChannel = true, -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content); @@ -524,100 +478,91 @@ public async Task CreateOrUpdate_CreateKafkaClusterWithKafkaRestProxy() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "4.0", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Standard, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "kafka", ComponentVersion = { -["Kafka"] = "2.1", +["Kafka"] = "2.1" }, - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - KafkaRestProperties = new KafkaRestProperties() + KafkaRestProperties = new KafkaRestProperties { - ClientGroupInfo = new ClientGroupInfo() + ClientGroupInfo = new ClientGroupInfo { GroupName = "Kafka security group name", GroupId = "00000000-0000-0000-0000-111111111111", }, }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", TargetInstanceCount = 2, HardwareVmSize = "Large", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", TargetInstanceCount = 3, HardwareVmSize = "Large", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -DataDisksGroups = -{ -new HDInsightClusterDataDiskGroup() +DataDisksGroups = {new HDInsightClusterDataDiskGroup { DisksPerNode = 8, -} -}, -},new HDInsightClusterRole() +}}, +}, new HDInsightClusterRole { Name = "zookeepernode", TargetInstanceCount = 3, HardwareVmSize = "Small", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "kafkamanagementnode", TargetInstanceCount = 2, HardwareVmSize = "Standard_D4_v2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "kafkauser", Password = "**********", }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage.blob.core.windows.net", IsDefault = true, Container = "containername", Key = "storagekey", EnableSecureChannel = true, -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content); @@ -654,139 +599,112 @@ public async Task CreateOrUpdate_CreateSecureHadoopCluster() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { Tags = { -["key1"] = "val1", +["key1"] = "val1" }, - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.5", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Premium, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "Hadoop", - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - SecurityProfile = new HDInsightSecurityProfile() + SecurityProfile = new HDInsightSecurityProfile { DirectoryType = AuthenticationDirectoryType.ActiveDirectory, Domain = "DomainName", OrganizationalUnitDN = "OU=Hadoop,DC=hdinsight,DC=test", - LdapUris = -{ -new Uri("ldaps://10.10.0.4:636") -}, + LdapUris = { new Uri("ldaps://10.10.0.4:636") }, DomainUsername = "DomainUsername", DomainUserPassword = "**********", - ClusterUsersGroupDNs = -{ -"hdiusers" -}, + ClusterUsersGroupDNs = { "hdiusers" }, }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", MinInstanceCount = 1, TargetInstanceCount = 2, HardwareVmSize = "Standard_D3_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", -SshPublicKeys = -{ -new HDInsightSshPublicKey() +SshPublicKeys = {new HDInsightSshPublicKey { CertificateData = "**********", -} +}}, }, -}, -VirtualNetworkProfile = new HDInsightVirtualNetworkProfile() +VirtualNetworkProfile = new HDInsightVirtualNetworkProfile { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"), Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet", }, -ScriptActions = -{ -}, -},new HDInsightClusterRole() +ScriptActions = {}, +}, new HDInsightClusterRole { Name = "workernode", MinInstanceCount = 1, TargetInstanceCount = 4, HardwareVmSize = "Standard_D3_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", -SshPublicKeys = -{ -new HDInsightSshPublicKey() +SshPublicKeys = {new HDInsightSshPublicKey { CertificateData = "**********", -} +}}, }, -}, -VirtualNetworkProfile = new HDInsightVirtualNetworkProfile() +VirtualNetworkProfile = new HDInsightVirtualNetworkProfile { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"), Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet", }, -ScriptActions = -{ -}, -},new HDInsightClusterRole() +ScriptActions = {}, +}, new HDInsightClusterRole { Name = "zookeepernode", MinInstanceCount = 1, TargetInstanceCount = 3, HardwareVmSize = "Small", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", -SshPublicKeys = -{ -new HDInsightSshPublicKey() +SshPublicKeys = {new HDInsightSshPublicKey { CertificateData = "**********", -} -}, +}}, }, -VirtualNetworkProfile = new HDInsightVirtualNetworkProfile() +VirtualNetworkProfile = new HDInsightVirtualNetworkProfile { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"), Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet", }, -ScriptActions = -{ -}, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +ScriptActions = {}, +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage.blob.core.windows.net", IsDefault = true, Container = "containername", Key = "storage account key", EnableSecureChannel = true, -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content); @@ -823,71 +741,65 @@ public async Task CreateOrUpdate_CreateSparkOnLinuxClusterWithSSHPassword() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { Tags = { -["key1"] = "val1", +["key1"] = "val1" }, - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.5", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Standard, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "Spark", ComponentVersion = { -["Spark"] = "2.0", +["Spark"] = "2.0" }, - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", MinInstanceCount = 1, TargetInstanceCount = 2, HardwareVmSize = "Standard_D12_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", MinInstanceCount = 1, TargetInstanceCount = 4, HardwareVmSize = "Standard_D4_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage.blob.core.windows.net", IsDefault = true, Container = "containername", Key = "storageapikey*", EnableSecureChannel = true, -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content); @@ -924,71 +836,65 @@ public async Task CreateOrUpdate_CreateClusterWithTLS12() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.6", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Standard, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "Hadoop", - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", TargetInstanceCount = 2, HardwareVmSize = "Large", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", TargetInstanceCount = 3, HardwareVmSize = "Large", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "zookeepernode", TargetInstanceCount = 3, HardwareVmSize = "Small", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage.blob.core.windows.net", IsDefault = true, Container = "default8525", Key = "storagekey", EnableSecureChannel = true, -} -}, +}}, MinSupportedTlsVersion = "1.2", }, }; @@ -1026,60 +932,57 @@ public async Task CreateOrUpdate_CreateClusterWithAvailabilityZones() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { - Zones = -{ -"1" -}, - Properties = new HDInsightClusterCreateOrUpdateProperties() + Zones = { "1" }, + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.6", OSType = HDInsightOSType.Linux, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "hadoop", - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new Dictionary { - ["ambari-conf"] = new Dictionary() + ["ambari-conf"] = new Dictionary { ["database-name"] = "{ambari database name}", ["database-server"] = "{sql server name}.database.windows.net", ["database-user-name"] = "**********", ["database-user-password"] = "**********" }, - ["gateway"] = new Dictionary() + ["gateway"] = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" }, - ["hive-env"] = new Dictionary() + ["hive-env"] = new { - ["hive_database"] = "Existing MSSQL Server database with SQL authentication", - ["hive_database_name"] = "{hive metastore name}", - ["hive_database_type"] = "mssql", - ["hive_existing_mssql_server_database"] = "{hive metastore name}", - ["hive_existing_mssql_server_host"] = "{sql server name}.database.windows.net", - ["hive_hostname"] = "{sql server name}.database.windows.net" + hive_database = "Existing MSSQL Server database with SQL authentication", + hive_database_name = "{hive metastore name}", + hive_database_type = "mssql", + hive_existing_mssql_server_database = "{hive metastore name}", + hive_existing_mssql_server_host = "{sql server name}.database.windows.net", + hive_hostname = "{sql server name}.database.windows.net", }, - ["hive-site"] = new Dictionary() + ["hive-site"] = new Dictionary { ["javax.jdo.option.ConnectionDriverName"] = "com.microsoft.sqlserver.jdbc.SQLServerDriver", ["javax.jdo.option.ConnectionPassword"] = "**********!", ["javax.jdo.option.ConnectionURL"] = "jdbc:sqlserver://{sql server name}.database.windows.net;database={hive metastore name};encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300;sendStringParametersAsUnicode=true;prepareSQL=0", ["javax.jdo.option.ConnectionUserName"] = "**********" }, - ["oozie-env"] = new Dictionary() + ["oozie-env"] = new { - ["oozie_database"] = "Existing MSSQL Server database with SQL authentication", - ["oozie_database_name"] = "{oozie metastore name}", - ["oozie_database_type"] = "mssql", - ["oozie_existing_mssql_server_database"] = "{oozie metastore name}", - ["oozie_existing_mssql_server_host"] = "{sql server name}.database.windows.net", - ["oozie_hostname"] = "{sql server name}.database.windows.net" + oozie_database = "Existing MSSQL Server database with SQL authentication", + oozie_database_name = "{oozie metastore name}", + oozie_database_type = "mssql", + oozie_existing_mssql_server_database = "{oozie metastore name}", + oozie_existing_mssql_server_host = "{sql server name}.database.windows.net", + oozie_hostname = "{sql server name}.database.windows.net", }, - ["oozie-site"] = new Dictionary() + ["oozie-site"] = new Dictionary { ["oozie.db.schema.name"] = "oozie", ["oozie.service.JPAService.jdbc.driver"] = "com.microsoft.sqlserver.jdbc.SQLServerDriver", @@ -1089,65 +992,53 @@ public async Task CreateOrUpdate_CreateClusterWithAvailabilityZones() } }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", TargetInstanceCount = 2, HardwareVmSize = "standard_d3", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", -SshPublicKeys = -{ -new HDInsightSshPublicKey() +SshPublicKeys = {new HDInsightSshPublicKey { CertificateData = "**********", -} +}}, }, -}, -VirtualNetworkProfile = new HDInsightVirtualNetworkProfile() +VirtualNetworkProfile = new HDInsightVirtualNetworkProfile { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"), Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", TargetInstanceCount = 2, HardwareVmSize = "standard_d3", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", -SshPublicKeys = -{ -new HDInsightSshPublicKey() +SshPublicKeys = {new HDInsightSshPublicKey { CertificateData = "**********", -} +}}, }, -}, -VirtualNetworkProfile = new HDInsightVirtualNetworkProfile() +VirtualNetworkProfile = new HDInsightVirtualNetworkProfile { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"), Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet", }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage", IsDefault = true, Container = "containername", Key = "storage account key", EnableSecureChannel = true, -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, content); @@ -1184,75 +1075,63 @@ public async Task CreateOrUpdate_CreateClusterWithComputeIsolationProperties() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.6", OSType = HDInsightOSType.Linux, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "hadoop", - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", TargetInstanceCount = 2, HardwareVmSize = "standard_d3", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", -SshPublicKeys = -{ -new HDInsightSshPublicKey() +SshPublicKeys = {new HDInsightSshPublicKey { CertificateData = "**********", -} +}}, }, -}, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", TargetInstanceCount = 2, HardwareVmSize = "standard_d3", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", -SshPublicKeys = -{ -new HDInsightSshPublicKey() +SshPublicKeys = {new HDInsightSshPublicKey { CertificateData = "**********", -} -}, +}}, }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage", IsDefault = true, Container = "containername", Key = "storage account key", EnableSecureChannel = true, -} -}, - ComputeIsolationProperties = new HDInsightComputeIsolationProperties() +}}, + ComputeIsolationProperties = new HDInsightComputeIsolationProperties { EnableComputeIsolation = true, HostSku = null, @@ -1293,72 +1172,66 @@ public async Task CreateOrUpdate_CreateClusterWithEncryptionAtHost() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.6", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Standard, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "Hadoop", - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", TargetInstanceCount = 2, HardwareVmSize = "Standard_DS14_v2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", TargetInstanceCount = 3, HardwareVmSize = "Standard_DS14_v2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "zookeepernode", TargetInstanceCount = 3, HardwareVmSize = "Standard_DS14_v2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage.blob.core.windows.net", IsDefault = true, Container = "default8525", Key = "storagekey", EnableSecureChannel = true, -} -}, - DiskEncryptionProperties = new HDInsightDiskEncryptionProperties() +}}, + DiskEncryptionProperties = new HDInsightDiskEncryptionProperties { IsEncryptionAtHostEnabled = true, }, @@ -1398,71 +1271,65 @@ public async Task CreateOrUpdate_CreateClusterWithEncryptionInTransit() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.6", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Standard, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "Hadoop", - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", TargetInstanceCount = 2, HardwareVmSize = "Large", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", TargetInstanceCount = 3, HardwareVmSize = "Large", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "zookeepernode", TargetInstanceCount = 3, HardwareVmSize = "Small", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage.blob.core.windows.net", IsDefault = true, Container = "default8525", Key = "storagekey", EnableSecureChannel = true, -} -}, +}}, IsEncryptionInTransitEnabled = true, }, }; @@ -1500,85 +1367,73 @@ public async Task CreateOrUpdate_CreateClusterWithNetworkProperties() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent() + HDInsightClusterCreateOrUpdateContent content = new HDInsightClusterCreateOrUpdateContent { - Properties = new HDInsightClusterCreateOrUpdateProperties() + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "3.6", OSType = HDInsightOSType.Linux, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "hadoop", - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", TargetInstanceCount = 2, HardwareVmSize = "standard_d3", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", -SshPublicKeys = -{ -new HDInsightSshPublicKey() +SshPublicKeys = {new HDInsightSshPublicKey { CertificateData = "**********", -} +}}, }, -}, -VirtualNetworkProfile = new HDInsightVirtualNetworkProfile() +VirtualNetworkProfile = new HDInsightVirtualNetworkProfile { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"), Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet", }, -},new HDInsightClusterRole() +}, new HDInsightClusterRole { Name = "workernode", TargetInstanceCount = 2, HardwareVmSize = "standard_d3", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", -SshPublicKeys = -{ -new HDInsightSshPublicKey() +SshPublicKeys = {new HDInsightSshPublicKey { CertificateData = "**********", -} -}, +}}, }, -VirtualNetworkProfile = new HDInsightVirtualNetworkProfile() +VirtualNetworkProfile = new HDInsightVirtualNetworkProfile { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname"), Subnet = "/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnetname/subnets/vnetsubnet", }, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "mystorage", IsDefault = true, Container = "containername", Key = "storage account key", EnableSecureChannel = true, -} -}, - NetworkProperties = new HDInsightClusterNetworkProperties() +}}, + NetworkProperties = new HDInsightClusterNetworkProperties { ResourceProviderConnection = HDInsightResourceProviderConnection.Outbound, PrivateLink = HDInsightPrivateLinkState.Enabled, @@ -1631,9 +1486,9 @@ public async Task Get_GetHadoopOnLinuxCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetHadoopOnLinuxCluster() + public async Task Get_GetSparkOnLinuxCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxHadoopCluster.json + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxSparkCluster.json // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1653,17 +1508,21 @@ public async Task Exists_GetHadoopOnLinuxCluster() // invoke the operation string clusterName = "cluster1"; - bool result = await collection.ExistsAsync(clusterName); + HDInsightClusterResource result = await collection.GetAsync(clusterName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetHadoopOnLinuxCluster() + public async Task GetAll_GetAllHadoopOnLinuxClustersInAResourceGroup() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxHadoopCluster.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxHadoopAllClustersInResourceGroup.json + // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1680,30 +1539,24 @@ public async Task GetIfExists_GetHadoopOnLinuxCluster() // get the collection of this HDInsightClusterResource HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters(); - // invoke the operation - string clusterName = "cluster1"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - HDInsightClusterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HDInsightClusterResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HDInsightClusterData resourceData = result.Data; + HDInsightClusterData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSparkOnLinuxCluster() + public async Task Exists_GetHadoopOnLinuxCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxSparkCluster.json + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxHadoopCluster.json // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1723,13 +1576,9 @@ public async Task Get_GetSparkOnLinuxCluster() // invoke the operation string clusterName = "cluster1"; - HDInsightClusterResource result = await collection.GetAsync(clusterName); + bool result = await collection.ExistsAsync(clusterName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -1763,9 +1612,9 @@ public async Task Exists_GetSparkOnLinuxCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSparkOnLinuxCluster() + public async Task GetIfExists_GetHadoopOnLinuxCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxSparkCluster.json + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxHadoopCluster.json // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1804,10 +1653,10 @@ public async Task GetIfExists_GetSparkOnLinuxCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllHadoopOnLinuxClustersInAResourceGroup() + public async Task GetIfExists_GetSparkOnLinuxCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxHadoopAllClustersInResourceGroup.json - // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxSparkCluster.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1824,17 +1673,23 @@ public async Task GetAll_GetAllHadoopOnLinuxClustersInAResourceGroup() // get the collection of this HDInsightClusterResource HDInsightClusterCollection collection = resourceGroupResource.GetHDInsightClusters(); - // invoke the operation and iterate over the result - await foreach (HDInsightClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "cluster1"; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + HDInsightClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HDInsightClusterData resourceData = item.Data; + HDInsightClusterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightClusterResource.cs b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightClusterResource.cs index 099bb81be7bee..8761861335303 100644 --- a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightClusterResource.cs +++ b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightClusterResource.cs @@ -12,7 +12,6 @@ using Azure.Identity; using Azure.ResourceManager.HDInsight.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HDInsight.Samples @@ -21,10 +20,10 @@ public partial class Sample_HDInsightClusterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchHDInsightLinuxClusters() + public async Task Get_GetHadoopOnLinuxCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/PatchLinuxHadoopCluster.json - // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxHadoopCluster.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,15 +39,7 @@ public async Task Update_PatchHDInsightLinuxClusters() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterPatch patch = new HDInsightClusterPatch() - { - Tags = -{ -["key1"] = "val1", -["key2"] = "val2", -}, - }; - HDInsightClusterResource result = await hdInsightCluster.UpdateAsync(patch); + HDInsightClusterResource result = await hdInsightCluster.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -59,10 +50,10 @@ public async Task Update_PatchHDInsightLinuxClusters() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchHDInsightLinuxClustersWithSystemAssignedMSI() + public async Task Get_GetSparkOnLinuxCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/PatchLinuxHadoopClusterWithSystemMSI.json - // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxSparkCluster.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,16 +69,7 @@ public async Task Update_PatchHDInsightLinuxClustersWithSystemAssignedMSI() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterPatch patch = new HDInsightClusterPatch() - { - Tags = -{ -["key1"] = "val1", -["key2"] = "val2", -}, - Identity = new ManagedServiceIdentity("SystemAssigned"), - }; - HDInsightClusterResource result = await hdInsightCluster.UpdateAsync(patch); + HDInsightClusterResource result = await hdInsightCluster.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -124,10 +106,10 @@ public async Task Delete_DeleteHadoopOnLinuxCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetHadoopOnLinuxCluster() + public async Task Update_PatchHDInsightLinuxClusters() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxHadoopCluster.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/PatchLinuxHadoopCluster.json + // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,7 +125,15 @@ public async Task Get_GetHadoopOnLinuxCluster() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterResource result = await hdInsightCluster.GetAsync(); + HDInsightClusterPatch patch = new HDInsightClusterPatch + { + Tags = +{ +["key1"] = "val1", +["key2"] = "val2" +}, + }; + HDInsightClusterResource result = await hdInsightCluster.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -154,10 +144,10 @@ public async Task Get_GetHadoopOnLinuxCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSparkOnLinuxCluster() + public async Task Update_PatchHDInsightLinuxClustersWithSystemAssignedMSI() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxSparkCluster.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/PatchLinuxHadoopClusterWithSystemMSI.json + // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,7 +163,16 @@ public async Task Get_GetSparkOnLinuxCluster() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterResource result = await hdInsightCluster.GetAsync(); + HDInsightClusterPatch patch = new HDInsightClusterPatch + { + Tags = +{ +["key1"] = "val1", +["key2"] = "val2" +}, + Identity = new ManagedServiceIdentity("SystemAssigned"), + }; + HDInsightClusterResource result = await hdInsightCluster.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -204,7 +203,7 @@ public async Task Resize_ResizeTheWorkerNodesForAHadoopOnLinuxCluster() // invoke the operation HDInsightRoleName roleName = HDInsightRoleName.Workernode; - HDInsightClusterResizeContent content = new HDInsightClusterResizeContent() + HDInsightClusterResizeContent content = new HDInsightClusterResizeContent { TargetInstanceCount = 10, }; @@ -263,11 +262,11 @@ public async Task UpdateAutoScaleConfiguration_EnableOrUpdateAutoscaleWithTheLoa // invoke the operation HDInsightRoleName roleName = HDInsightRoleName.Workernode; - HDInsightAutoScaleConfigurationUpdateContent content = new HDInsightAutoScaleConfigurationUpdateContent() + HDInsightAutoScaleConfigurationUpdateContent content = new HDInsightAutoScaleConfigurationUpdateContent { - AutoScale = new HDInsightAutoScaleConfiguration() + AutoScale = new HDInsightAutoScaleConfiguration { - Capacity = new HDInsightAutoScaleCapacity() + Capacity = new HDInsightAutoScaleCapacity { MinInstanceCount = 3, MaxInstanceCount = 5, @@ -301,29 +300,23 @@ public async Task UpdateAutoScaleConfiguration_EnableOrUpdateAutoscaleWithTheSch // invoke the operation HDInsightRoleName roleName = HDInsightRoleName.Workernode; - HDInsightAutoScaleConfigurationUpdateContent content = new HDInsightAutoScaleConfigurationUpdateContent() + HDInsightAutoScaleConfigurationUpdateContent content = new HDInsightAutoScaleConfigurationUpdateContent { - AutoScale = new HDInsightAutoScaleConfiguration() + AutoScale = new HDInsightAutoScaleConfiguration { - Recurrence = new HDInsightAutoScaleRecurrence() + Recurrence = new HDInsightAutoScaleRecurrence { TimeZone = "China Standard Time", - Schedule = + Schedule = {new HDInsightAutoScaleSchedule { -new HDInsightAutoScaleSchedule() -{ -Days = -{ -HDInsightDayOfWeek.Thursday -}, -TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity() +Days = {HDInsightDayOfWeek.Thursday}, +TimeAndCapacity = new HDInsightAutoScaleTimeAndCapacity { Time = "16:00", MinInstanceCount = 4, MaxInstanceCount = 4, }, -} -}, +}}, }, }, }; @@ -332,37 +325,6 @@ public async Task UpdateAutoScaleConfiguration_EnableOrUpdateAutoscaleWithTheSch Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetHDInsightClusters_GetAllHadoopOnLinuxClusters() - { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxHadoopAllClusters.json - // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (HDInsightClusterResource item in subscriptionResource.GetHDInsightClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task RotateDiskEncryptionKey_RotateDiskEncryptionKeyOfTheSpecifiedHDInsightCluster() @@ -384,7 +346,7 @@ public async Task RotateDiskEncryptionKey_RotateDiskEncryptionKeyOfTheSpecifiedH HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterDiskEncryptionContent content = new HDInsightClusterDiskEncryptionContent() + HDInsightClusterDiskEncryptionContent content = new HDInsightClusterDiskEncryptionContent { VaultUri = new Uri("https://newkeyvault.vault.azure.net/"), KeyName = "newkeyname", @@ -442,7 +404,7 @@ public async Task UpdateGatewaySettings_EnableHTTPConnectivity() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterUpdateGatewaySettingsContent content = new HDInsightClusterUpdateGatewaySettingsContent() + HDInsightClusterUpdateGatewaySettingsContent content = new HDInsightClusterUpdateGatewaySettingsContent { IsCredentialEnabled = true, UserName = "hadoop", @@ -501,7 +463,7 @@ public async Task UpdateIdentityCertificate_UpdateClusterIdentityCertificate() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterUpdateIdentityCertificateContent content = new HDInsightClusterUpdateIdentityCertificateContent() + HDInsightClusterUpdateIdentityCertificateContent content = new HDInsightClusterUpdateIdentityCertificateContent { ApplicationId = "applicationId", Certificate = "base64encodedcertificate", @@ -535,16 +497,10 @@ public async Task ExecuteScriptActions_ExecuteScriptActionOnHDInsightCluster() // invoke the operation ExecuteScriptActionContent content = new ExecuteScriptActionContent(false) { - ScriptActions = -{ -new RuntimeScriptAction("Test",new Uri("http://testurl.com/install.ssh"),new string[] -{ -"headnode","workernode" -}) + ScriptActions = {new RuntimeScriptAction("Test", new Uri("http://testurl.com/install.ssh"), new string[]{"headnode", "workernode"}) { Parameters = "", -} -}, +}}, }; await hdInsightCluster.ExecuteScriptActionsAsync(WaitUntil.Completed, content); @@ -599,9 +555,9 @@ public async Task UpdateConfiguration_DisableHTTPConnectivity() // invoke the operation string configurationName = "gateway"; - IDictionary clusterConfiguration = new Dictionary() + IDictionary clusterConfiguration = new Dictionary { - ["restAuthCredential.isEnabled"] = "false", + ["restAuthCredential.isEnabled"] = "false" }; await hdInsightCluster.UpdateConfigurationAsync(WaitUntil.Completed, configurationName, clusterConfiguration); @@ -630,11 +586,11 @@ public async Task UpdateConfiguration_EnableHTTPConnectivity() // invoke the operation string configurationName = "gateway"; - IDictionary clusterConfiguration = new Dictionary() + IDictionary clusterConfiguration = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", - ["restAuthCredential.username"] = "hadoop", + ["restAuthCredential.username"] = "hadoop" }; await hdInsightCluster.UpdateConfigurationAsync(WaitUntil.Completed, configurationName, clusterConfiguration); @@ -690,7 +646,7 @@ public async Task EnableClusterMonitoringExtension_EnableClusterMonitoring() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterEnableClusterMonitoringContent content = new HDInsightClusterEnableClusterMonitoringContent() + HDInsightClusterEnableClusterMonitoringContent content = new HDInsightClusterEnableClusterMonitoringContent { WorkspaceId = "a2090ead-8c9f-4fba-b70e-533e3e003163", PrimaryKey = "**********", @@ -773,7 +729,7 @@ public async Task EnableAzureMonitorExtension_EnableAzureMonitor() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightAzureMonitorExtensionEnableContent content = new HDInsightAzureMonitorExtensionEnableContent() + HDInsightAzureMonitorExtensionEnableContent content = new HDInsightAzureMonitorExtensionEnableContent { WorkspaceId = "a2090ead-8c9f-4fba-b70e-533e3e003163", PrimaryKey = "**********", @@ -856,7 +812,7 @@ public async Task EnableAzureMonitorAgentExtension_EnableAzureMonitoringAgent() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightAzureMonitorExtensionEnableContent content = new HDInsightAzureMonitorExtensionEnableContent() + HDInsightAzureMonitorExtensionEnableContent content = new HDInsightAzureMonitorExtensionEnableContent { WorkspaceId = "a2090ead-8c9f-4fba-b70e-533e3e003163", PrimaryKey = "**********", @@ -940,7 +896,7 @@ public async Task CreateExtension_CreateAMonitoringExtensionOnHadoopLinuxCluster // invoke the operation string extensionName = "clustermonitoring"; - HDInsightClusterCreateExtensionContent content = new HDInsightClusterCreateExtensionContent() + HDInsightClusterCreateExtensionContent content = new HDInsightClusterCreateExtensionContent { WorkspaceId = "a2090ead-8c9f-4fba-b70e-533e3e003163", PrimaryKey = "**********", @@ -1248,10 +1204,7 @@ public async Task RestartVirtualMachineHosts_RestartsTheSpecifiedHDInsightCluste HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - IEnumerable content = new string[] - { -"gateway1","gateway3" - }; + IEnumerable content = new string[] { "gateway1", "gateway3" }; await hdInsightCluster.RestartVirtualMachineHostsAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); diff --git a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateEndpointConnectionCollection.cs b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateEndpointConnectionCollection.cs index ddd5ec1e2bb81..f5c88b00c606c 100644 --- a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateEndpointConnectionCollection.cs +++ b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HDInsightPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllPrivateEndpointConnectionsForASpecificHDInsightCluster() + public async Task CreateOrUpdate_ApproveAPrivateEndpointConnectionManually() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetAllPrivateEndpointConnectionsInCluster.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/ApprovePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,29 @@ public async Task GetAll_GetAllPrivateEndpointConnectionsForASpecificHDInsightCl // get the collection of this HDInsightPrivateEndpointConnectionResource HDInsightPrivateEndpointConnectionCollection collection = hdInsightCluster.GetHDInsightPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (HDInsightPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "testprivateep.b3bf5fed-9b12-4560-b7d0-2abe1bba07e2"; + HDInsightPrivateEndpointConnectionData data = new HDInsightPrivateEndpointConnectionData(new HDInsightPrivateLinkServiceConnectionState(HDInsightPrivateLinkServiceConnectionStatus.Approved) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "update it from pending to approved.", + ActionsRequired = "None", + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + HDInsightPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveAPrivateEndpointConnectionManually() + public async Task Get_GetSpecificPrivateEndpointConnectionForASpecificHDInsightCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/ApprovePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,13 +81,7 @@ public async Task CreateOrUpdate_ApproveAPrivateEndpointConnectionManually() // invoke the operation string privateEndpointConnectionName = "testprivateep.b3bf5fed-9b12-4560-b7d0-2abe1bba07e2"; - HDInsightPrivateEndpointConnectionData data = new HDInsightPrivateEndpointConnectionData(new HDInsightPrivateLinkServiceConnectionState(HDInsightPrivateLinkServiceConnectionStatus.Approved) - { - Description = "update it from pending to approved.", - ActionsRequired = "None", - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - HDInsightPrivateEndpointConnectionResource result = lro.Value; + HDInsightPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -94,10 +92,10 @@ public async Task CreateOrUpdate_ApproveAPrivateEndpointConnectionManually() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSpecificPrivateEndpointConnectionForASpecificHDInsightCluster() + public async Task GetAll_GetAllPrivateEndpointConnectionsForASpecificHDInsightCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetAllPrivateEndpointConnectionsInCluster.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,15 +113,17 @@ public async Task Get_GetSpecificPrivateEndpointConnectionForASpecificHDInsightC // get the collection of this HDInsightPrivateEndpointConnectionResource HDInsightPrivateEndpointConnectionCollection collection = hdInsightCluster.GetHDInsightPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "testprivateep.b3bf5fed-9b12-4560-b7d0-2abe1bba07e2"; - HDInsightPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (HDInsightPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateEndpointConnectionResource.cs b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateEndpointConnectionResource.cs index d104932298d3e..8e3698edc13a5 100644 --- a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateEndpointConnectionResource.cs +++ b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_HDInsightPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveAPrivateEndpointConnectionManually() + public async Task Get_GetSpecificPrivateEndpointConnectionForASpecificHDInsightCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/ApprovePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,13 +38,7 @@ public async Task Update_ApproveAPrivateEndpointConnectionManually() HDInsightPrivateEndpointConnectionResource hdInsightPrivateEndpointConnection = client.GetHDInsightPrivateEndpointConnectionResource(hdInsightPrivateEndpointConnectionResourceId); // invoke the operation - HDInsightPrivateEndpointConnectionData data = new HDInsightPrivateEndpointConnectionData(new HDInsightPrivateLinkServiceConnectionState(HDInsightPrivateLinkServiceConnectionStatus.Approved) - { - Description = "update it from pending to approved.", - ActionsRequired = "None", - }); - ArmOperation lro = await hdInsightPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - HDInsightPrivateEndpointConnectionResource result = lro.Value; + HDInsightPrivateEndpointConnectionResource result = await hdInsightPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +49,10 @@ public async Task Update_ApproveAPrivateEndpointConnectionManually() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSpecificPrivateEndpointConnectionForASpecificHDInsightCluster() + public async Task Delete_DeleteSpecificPrivateEndpointConnectionForASpecificHDInsightCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/DeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,21 +69,17 @@ public async Task Get_GetSpecificPrivateEndpointConnectionForASpecificHDInsightC HDInsightPrivateEndpointConnectionResource hdInsightPrivateEndpointConnection = client.GetHDInsightPrivateEndpointConnectionResource(hdInsightPrivateEndpointConnectionResourceId); // invoke the operation - HDInsightPrivateEndpointConnectionResource result = await hdInsightPrivateEndpointConnection.GetAsync(); + await hdInsightPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSpecificPrivateEndpointConnectionForASpecificHDInsightCluster() + public async Task Update_ApproveAPrivateEndpointConnectionManually() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/DeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/ApprovePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +96,19 @@ public async Task Delete_DeleteSpecificPrivateEndpointConnectionForASpecificHDIn HDInsightPrivateEndpointConnectionResource hdInsightPrivateEndpointConnection = client.GetHDInsightPrivateEndpointConnectionResource(hdInsightPrivateEndpointConnectionResourceId); // invoke the operation - await hdInsightPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + HDInsightPrivateEndpointConnectionData data = new HDInsightPrivateEndpointConnectionData(new HDInsightPrivateLinkServiceConnectionState(HDInsightPrivateLinkServiceConnectionStatus.Approved) + { + Description = "update it from pending to approved.", + ActionsRequired = "None", + }); + ArmOperation lro = await hdInsightPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + HDInsightPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateLinkResourceCollection.cs b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateLinkResourceCollection.cs index 1c215862c86e9..55eb92ae78a31 100644 --- a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateLinkResourceCollection.cs +++ b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_HDInsightPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HDInsightPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllPrivateLinkResourcesInASpecificHDInsightCluster() + public async Task Get_GetSpecificPrivateLinkResourceInASpecificHDInsightCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetAllPrivateLinkResourcesInCluster.json - // this example is just showing the usage of "PrivateLinkResources_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetPrivateLinkResource.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetAllPrivateLinkResourcesInASpecificHDInsightCluster() // get the collection of this HDInsightPrivateLinkResource HDInsightPrivateLinkResourceCollection collection = hdInsightCluster.GetHDInsightPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (HDInsightPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateLinkResourceName = "gateway"; + HDInsightPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSpecificPrivateLinkResourceInASpecificHDInsightCluster() + public async Task GetAll_GetAllPrivateLinkResourcesInASpecificHDInsightCluster() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetPrivateLinkResource.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetAllPrivateLinkResourcesInCluster.json + // this example is just showing the usage of "PrivateLinkResources_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetSpecificPrivateLinkResourceInASpecificHDInsightCluster( // get the collection of this HDInsightPrivateLinkResource HDInsightPrivateLinkResourceCollection collection = hdInsightCluster.GetHDInsightPrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "gateway"; - HDInsightPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (HDInsightPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 42cde7779595f..96ef10b25b691 100644 --- a/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/hdinsight/Azure.ResourceManager.HDInsight/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -18,6 +18,37 @@ namespace Azure.ResourceManager.HDInsight.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHDInsightClusters_GetAllHadoopOnLinuxClusters() + { + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/preview/2024-08-01-preview/examples/GetLinuxHadoopAllClusters.json + // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HDInsightClusterResource item in subscriptionResource.GetHDInsightClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetHDInsightCapabilities_GetTheSubscriptionCapabilitiesForSpecificLocation() @@ -116,7 +147,7 @@ public async Task CheckHDInsightNameAvailability_GetTheSubscriptionUsagesForSpec // invoke the operation AzureLocation location = new AzureLocation("westus"); - HDInsightNameAvailabilityContent content = new HDInsightNameAvailabilityContent() + HDInsightNameAvailabilityContent content = new HDInsightNameAvailabilityContent { Name = "test123", ResourceType = new ResourceType("clusters"), @@ -146,101 +177,82 @@ public async Task ValidateHDInsightClusterCreation_GetTheSubscriptionUsagesForSp // invoke the operation AzureLocation location = new AzureLocation("southcentralus"); - HDInsightClusterCreationValidateContent content = new HDInsightClusterCreationValidateContent() + HDInsightClusterCreationValidateContent content = new HDInsightClusterCreationValidateContent { Name = "testclustername", ClusterCreateRequestValidationParametersType = "Microsoft.HDInsight/clusters", TenantId = Guid.Parse("00000000-0000-0000-0000-000000000000"), FetchAaddsResource = false, Location = new AzureLocation("southcentralus"), - Tags = -{ -}, - Properties = new HDInsightClusterCreateOrUpdateProperties() + Tags = { }, + Properties = new HDInsightClusterCreateOrUpdateProperties { ClusterVersion = "4.0", OSType = HDInsightOSType.Linux, Tier = HDInsightTier.Standard, - ClusterDefinition = new HDInsightClusterDefinition() + ClusterDefinition = new HDInsightClusterDefinition { Kind = "spark", ComponentVersion = { -["Spark"] = "2.4", +["Spark"] = "2.4" }, - Configurations = BinaryData.FromObjectAsJson(new Dictionary() + Configurations = BinaryData.FromObjectAsJson(new { - ["gateway"] = new Dictionary() + gateway = new Dictionary { ["restAuthCredential.isEnabled"] = "true", ["restAuthCredential.password"] = "**********", ["restAuthCredential.username"] = "admin" - } + }, }), }, - ComputeRoles = -{ -new HDInsightClusterRole() + ComputeRoles = {new HDInsightClusterRole { Name = "headnode", MinInstanceCount = 1, TargetInstanceCount = 2, -AutoScaleConfiguration = null, +AutoScaleConfiguration = default, HardwareVmSize = "Standard_E8_V3", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "********", }, -VirtualNetworkProfile = null, -DataDisksGroups = -{ -}, -ScriptActions = -{ -}, -},new HDInsightClusterRole() +VirtualNetworkProfile = default, +DataDisksGroups = {}, +ScriptActions = {}, +}, new HDInsightClusterRole { Name = "workernode", TargetInstanceCount = 4, -AutoScaleConfiguration = null, +AutoScaleConfiguration = default, HardwareVmSize = "Standard_E8_V3", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "********", }, -VirtualNetworkProfile = null, -DataDisksGroups = -{ -}, -ScriptActions = -{ -}, -},new HDInsightClusterRole() +VirtualNetworkProfile = default, +DataDisksGroups = {}, +ScriptActions = {}, +}, new HDInsightClusterRole { Name = "zookeepernode", MinInstanceCount = 1, TargetInstanceCount = 3, -AutoScaleConfiguration = null, +AutoScaleConfiguration = default, HardwareVmSize = "Standard_D13_V2", -OSLinuxProfile = new HDInsightLinuxOSProfile() +OSLinuxProfile = new HDInsightLinuxOSProfile { Username = "sshuser", Password = "**********", }, -VirtualNetworkProfile = null, -DataDisksGroups = -{ -}, -ScriptActions = -{ -}, -} -}, - StorageAccounts = -{ -new HDInsightStorageAccountInfo() +VirtualNetworkProfile = default, +DataDisksGroups = {}, +ScriptActions = {}, +}}, + StorageAccounts = {new HDInsightStorageAccountInfo { Name = "storagename.blob.core.windows.net", IsDefault = true, @@ -248,8 +260,7 @@ public async Task ValidateHDInsightClusterCreation_GetTheSubscriptionUsagesForSp Key = "*******", ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/storagename"), EnableSecureChannel = true, -} -}, +}}, MinSupportedTlsVersion = "1.2", }, }; diff --git a/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterCollection.cs b/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterCollection.cs index e0063214bd9ac..99015ca0d39f3 100644 --- a/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterCollection.cs +++ b/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterCollection.cs @@ -16,148 +16,6 @@ namespace Azure.ResourceManager.HDInsight.Containers.Samples { public partial class Sample_HDInsightClusterCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_HDInsightClustersListByClusterPoolName() - { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/ListClustersByClusterPoolName.json - // this example is just showing the usage of "Clusters_ListByClusterPoolName" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HDInsightClusterPoolResource created on azure - // for more information of creating HDInsightClusterPoolResource, please refer to the document of HDInsightClusterPoolResource - string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; - string resourceGroupName = "hiloResourcegroup"; - string clusterPoolName = "clusterpool1"; - ResourceIdentifier hdInsightClusterPoolResourceId = HDInsightClusterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName); - HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); - - // get the collection of this HDInsightClusterResource - HDInsightClusterCollection collection = hdInsightClusterPool.GetHDInsightClusters(); - - // invoke the operation and iterate over the result - await foreach (HDInsightClusterResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_HDInsightClusterGet() - { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetCluster.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HDInsightClusterPoolResource created on azure - // for more information of creating HDInsightClusterPoolResource, please refer to the document of HDInsightClusterPoolResource - string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; - string resourceGroupName = "hiloResourcegroup"; - string clusterPoolName = "clusterpool1"; - ResourceIdentifier hdInsightClusterPoolResourceId = HDInsightClusterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName); - HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); - - // get the collection of this HDInsightClusterResource - HDInsightClusterCollection collection = hdInsightClusterPool.GetHDInsightClusters(); - - // invoke the operation - string clusterName = "cluster1"; - HDInsightClusterResource result = await collection.GetAsync(clusterName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_HDInsightClusterGet() - { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetCluster.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HDInsightClusterPoolResource created on azure - // for more information of creating HDInsightClusterPoolResource, please refer to the document of HDInsightClusterPoolResource - string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; - string resourceGroupName = "hiloResourcegroup"; - string clusterPoolName = "clusterpool1"; - ResourceIdentifier hdInsightClusterPoolResourceId = HDInsightClusterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName); - HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); - - // get the collection of this HDInsightClusterResource - HDInsightClusterCollection collection = hdInsightClusterPool.GetHDInsightClusters(); - - // invoke the operation - string clusterName = "cluster1"; - bool result = await collection.ExistsAsync(clusterName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HDInsightClusterGet() - { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetCluster.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HDInsightClusterPoolResource created on azure - // for more information of creating HDInsightClusterPoolResource, please refer to the document of HDInsightClusterPoolResource - string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; - string resourceGroupName = "hiloResourcegroup"; - string clusterPoolName = "clusterpool1"; - ResourceIdentifier hdInsightClusterPoolResourceId = HDInsightClusterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName); - HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); - - // get the collection of this HDInsightClusterResource - HDInsightClusterCollection collection = hdInsightClusterPool.GetHDInsightClusters(); - - // invoke the operation - string clusterName = "cluster1"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - HDInsightClusterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_HDInsightClusterPut() @@ -187,25 +45,17 @@ public async Task CreateOrUpdate_HDInsightClusterPut() { Properties = new HDInsightClusterProperties("Trino", new ClusterComputeProfile(new ClusterComputeNodeProfile[] { -new ClusterComputeNodeProfile("Head","Standard_E8as_v5",2),new ClusterComputeNodeProfile("Worker","Standard_E8as_v5",3) +new ClusterComputeNodeProfile("Head", "Standard_E8as_v5", 2), +new ClusterComputeNodeProfile("Worker", "Standard_E8as_v5", 3) }) { - AvailabilityZones = -{ -"1","2","3" -}, - }, new ClusterProfile("1.0.6", "0.410.0", new AuthorizationProfile() + AvailabilityZones = { "1", "2", "3" }, + }, new ClusterProfile("1.0.6", "0.410.0", new AuthorizationProfile { - UserIds = -{ -"testuser1","testuser2" -}, + UserIds = { "testuser1", "testuser2" }, }) { - IdentityList = -{ -new HDInsightManagedIdentitySpec(HDInsightManagedIdentityType.Cluster,new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-msi"),"de91f1d8-767f-460a-ac11-3cf103f74b34","40491351-c240-4042-91e0-f644a1d2b441") -}, + IdentityList = { new HDInsightManagedIdentitySpec(HDInsightManagedIdentityType.Cluster, new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-msi"), "de91f1d8-767f-460a-ac11-3cf103f74b34", "40491351-c240-4042-91e0-f644a1d2b441") }, SshProfile = new ClusterSshProfile(2) { VmSize = "Standard_E8as_v5", @@ -216,17 +66,13 @@ public async Task CreateOrUpdate_HDInsightClusterPut() AutoscaleType = ClusterAutoscaleType.ScheduleBased, ScheduleBasedConfig = new ScheduleBasedConfig("Cen. Australia Standard Time", 10, new AutoscaleSchedule[] { -new AutoscaleSchedule("00:00","12:00",20,new AutoscaleScheduleDay[] -{ -AutoscaleScheduleDay.Monday -}),new AutoscaleSchedule("00:00","12:00",25,new AutoscaleScheduleDay[] -{ -AutoscaleScheduleDay.Sunday -}) +new AutoscaleSchedule("00:00", "12:00", 20, new AutoscaleScheduleDay[]{AutoscaleScheduleDay.Monday}), +new AutoscaleSchedule("00:00", "12:00", 25, new AutoscaleScheduleDay[]{AutoscaleScheduleDay.Sunday}) }), LoadBasedConfig = new LoadBasedConfig(10, 20, new ScalingRule[] { -new ScalingRule(ScaleActionType.ScaleUp,3,"cpu",new HDInsightComparisonRule(HDInsightComparisonOperator.GreaterThan,90)),new ScalingRule(ScaleActionType.ScaleDown,3,"cpu",new HDInsightComparisonRule(HDInsightComparisonOperator.LessThan,20)) +new ScalingRule(ScaleActionType.ScaleUp, 3, "cpu", new HDInsightComparisonRule(HDInsightComparisonOperator.GreaterThan, 90)), +new ScalingRule(ScaleActionType.ScaleDown, 3, "cpu", new HDInsightComparisonRule(HDInsightComparisonOperator.LessThan, 20)) }) { PollIntervalInSeconds = 60, @@ -275,45 +121,27 @@ public async Task CreateOrUpdate_HDInsightRangerClusterPut() { Properties = new HDInsightClusterProperties("ranger", new ClusterComputeProfile(new ClusterComputeNodeProfile[] { -new ClusterComputeNodeProfile("head","Standard_D3_v2",2) +new ClusterComputeNodeProfile("head", "Standard_D3_v2", 2) }) { - AvailabilityZones = -{ -"1","2","3" -}, - }, new ClusterProfile("0.0.1", "2.2.3", new AuthorizationProfile() + AvailabilityZones = { "1", "2", "3" }, + }, new ClusterProfile("0.0.1", "2.2.3", new AuthorizationProfile { - UserIds = -{ -"testuser1","testuser2" -}, + UserIds = { "testuser1", "testuser2" }, }) { - IdentityList = -{ -new HDInsightManagedIdentitySpec(HDInsightManagedIdentityType.Cluster,new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-msi"),"de91f1d8-767f-460a-ac11-3cf103f74b34","40491351-c240-4042-91e0-f644a1d2b441") -}, - RangerProfile = new RangerProfile(new RangerAdminSpec(new string[] - { -"testuser1@contoso.com","testuser2@contoso.com" - }, new RangerAdminSpecDatabase("testsqlserver.database.windows.net", "testdb") - { - PasswordSecretRef = "https://testkv.vault.azure.net/secrets/mysecret/5df6584d9c25418c8d900240aa6c3452", - Username = "admin", - }), new RangerUsersyncSpec() - { - IsEnabled = true, - Groups = - { -"0a53828f-36c9-44c3-be3d-99a7fce977ad","13be6971-79db-4f33-9d41-b25589ca25ac" - }, - Mode = RangerUsersyncMode.Automatic, - Users = - { -"testuser1@contoso.com","testuser2@contoso.com" - }, - }) + IdentityList = { new HDInsightManagedIdentitySpec(HDInsightManagedIdentityType.Cluster, new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-msi"), "de91f1d8-767f-460a-ac11-3cf103f74b34", "40491351-c240-4042-91e0-f644a1d2b441") }, + RangerProfile = new RangerProfile(new RangerAdminSpec(new string[] { "testuser1@contoso.com", "testuser2@contoso.com" }, new RangerAdminSpecDatabase("testsqlserver.database.windows.net", "testdb") + { + PasswordSecretRef = "https://testkv.vault.azure.net/secrets/mysecret/5df6584d9c25418c8d900240aa6c3452", + Username = "admin", + }), new RangerUsersyncSpec + { + IsEnabled = true, + Groups = { "0a53828f-36c9-44c3-be3d-99a7fce977ad", "13be6971-79db-4f33-9d41-b25589ca25ac" }, + Mode = RangerUsersyncMode.Automatic, + Users = { "testuser1@contoso.com", "testuser2@contoso.com" }, + }) { RangerAuditStorageAccount = "https://teststorage.blob.core.windows.net/testblob", }, @@ -358,42 +186,31 @@ public async Task CreateOrUpdate_HDInsightSparkClusterPut() { Properties = new HDInsightClusterProperties("spark", new ClusterComputeProfile(new ClusterComputeNodeProfile[] { -new ClusterComputeNodeProfile("worker","Standard_D3_v2",4) +new ClusterComputeNodeProfile("worker", "Standard_D3_v2", 4) }) { - AvailabilityZones = -{ -"1","2","3" -}, - }, new ClusterProfile("0.0.1", "2.2.3", new AuthorizationProfile() + AvailabilityZones = { "1", "2", "3" }, + }, new ClusterProfile("0.0.1", "2.2.3", new AuthorizationProfile { - UserIds = -{ -"testuser1","testuser2" -}, + UserIds = { "testuser1", "testuser2" }, }) { - IdentityList = + IdentityList = { new HDInsightManagedIdentitySpec(HDInsightManagedIdentityType.Cluster, new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-msi"), "de91f1d8-767f-460a-ac11-3cf103f74b34", "40491351-c240-4042-91e0-f644a1d2b441") }, + ServiceConfigsProfiles = {new ClusterServiceConfigsProfile("spark-service", new ClusterServiceConfig[] { -new HDInsightManagedIdentitySpec(HDInsightManagedIdentityType.Cluster,new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-msi"),"de91f1d8-767f-460a-ac11-3cf103f74b34","40491351-c240-4042-91e0-f644a1d2b441") -}, - ServiceConfigsProfiles = -{ -new ClusterServiceConfigsProfile("spark-service",new ClusterServiceConfig[] -{ -new ClusterServiceConfig("spark-config",new ClusterConfigFile[] +new ClusterServiceConfig("spark-config", new ClusterConfigFile[] { new ClusterConfigFile("spark-defaults.conf") { Values = { -["spark.eventLog.enabled"] = "true", +["spark.eventLog.enabled"] = "true" }, } }) -}),new ClusterServiceConfigsProfile("yarn-service",new ClusterServiceConfig[] +}), new ClusterServiceConfigsProfile("yarn-service", new ClusterServiceConfig[] { -new ClusterServiceConfig("yarn-config",new ClusterConfigFile[] +new ClusterServiceConfig("yarn-config", new ClusterConfigFile[] { new ClusterConfigFile("core-site.xml") { @@ -403,18 +220,18 @@ public async Task CreateOrUpdate_HDInsightSparkClusterPut() ["storage.container"] = "testcontainer", ["storage.key"] = "test key", ["storage.name"] = "teststorage", -["storage.protocol"] = "wasb", +["storage.protocol"] = "wasb" +}, }, -},new ClusterConfigFile("yarn-site.xml") +new ClusterConfigFile("yarn-site.xml") { Values = { -["yarn.webapp.ui2.enable"] = "false", +["yarn.webapp.ui2.enable"] = "false" }, } }) -}) -}, +})}, SshProfile = new ClusterSshProfile(2) { VmSize = "Standard_D3_v2", @@ -461,42 +278,31 @@ public async Task CreateOrUpdate_HDInsightSparkClusterPutWithInternalIngress() { Properties = new HDInsightClusterProperties("spark", new ClusterComputeProfile(new ClusterComputeNodeProfile[] { -new ClusterComputeNodeProfile("worker","Standard_D3_v2",4) +new ClusterComputeNodeProfile("worker", "Standard_D3_v2", 4) }) { - AvailabilityZones = -{ -"1","2","3" -}, - }, new ClusterProfile("0.0.1", "2.2.3", new AuthorizationProfile() + AvailabilityZones = { "1", "2", "3" }, + }, new ClusterProfile("0.0.1", "2.2.3", new AuthorizationProfile { - UserIds = -{ -"testuser1","testuser2" -}, + UserIds = { "testuser1", "testuser2" }, }) { - IdentityList = -{ -new HDInsightManagedIdentitySpec(HDInsightManagedIdentityType.Cluster,new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-msi"),"de91f1d8-767f-460a-ac11-3cf103f74b34","40491351-c240-4042-91e0-f644a1d2b441") -}, - ServiceConfigsProfiles = -{ -new ClusterServiceConfigsProfile("spark-service",new ClusterServiceConfig[] + IdentityList = { new HDInsightManagedIdentitySpec(HDInsightManagedIdentityType.Cluster, new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-msi"), "de91f1d8-767f-460a-ac11-3cf103f74b34", "40491351-c240-4042-91e0-f644a1d2b441") }, + ServiceConfigsProfiles = {new ClusterServiceConfigsProfile("spark-service", new ClusterServiceConfig[] { -new ClusterServiceConfig("spark-config",new ClusterConfigFile[] +new ClusterServiceConfig("spark-config", new ClusterConfigFile[] { new ClusterConfigFile("spark-defaults.conf") { Values = { -["spark.eventLog.enabled"] = "true", +["spark.eventLog.enabled"] = "true" }, } }) -}),new ClusterServiceConfigsProfile("yarn-service",new ClusterServiceConfig[] +}), new ClusterServiceConfigsProfile("yarn-service", new ClusterServiceConfig[] { -new ClusterServiceConfig("yarn-config",new ClusterConfigFile[] +new ClusterServiceConfig("yarn-config", new ClusterConfigFile[] { new ClusterConfigFile("core-site.xml") { @@ -506,18 +312,18 @@ public async Task CreateOrUpdate_HDInsightSparkClusterPutWithInternalIngress() ["storage.container"] = "testcontainer", ["storage.key"] = "test key", ["storage.name"] = "teststorage", -["storage.protocol"] = "wasb", +["storage.protocol"] = "wasb" +}, }, -},new ClusterConfigFile("yarn-site.xml") +new ClusterConfigFile("yarn-site.xml") { Values = { -["yarn.webapp.ui2.enable"] = "false", +["yarn.webapp.ui2.enable"] = "false" }, } }) -}) -}, +})}, ClusterAccessProfile = new ClusterAccessProfile(true), SshProfile = new ClusterSshProfile(2) { @@ -535,5 +341,147 @@ public async Task CreateOrUpdate_HDInsightSparkClusterPutWithInternalIngress() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_HDInsightClusterGet() + { + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetCluster.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HDInsightClusterPoolResource created on azure + // for more information of creating HDInsightClusterPoolResource, please refer to the document of HDInsightClusterPoolResource + string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; + string resourceGroupName = "hiloResourcegroup"; + string clusterPoolName = "clusterpool1"; + ResourceIdentifier hdInsightClusterPoolResourceId = HDInsightClusterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName); + HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); + + // get the collection of this HDInsightClusterResource + HDInsightClusterCollection collection = hdInsightClusterPool.GetHDInsightClusters(); + + // invoke the operation + string clusterName = "cluster1"; + HDInsightClusterResource result = await collection.GetAsync(clusterName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_HDInsightClustersListByClusterPoolName() + { + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/ListClustersByClusterPoolName.json + // this example is just showing the usage of "Clusters_ListByClusterPoolName" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HDInsightClusterPoolResource created on azure + // for more information of creating HDInsightClusterPoolResource, please refer to the document of HDInsightClusterPoolResource + string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; + string resourceGroupName = "hiloResourcegroup"; + string clusterPoolName = "clusterpool1"; + ResourceIdentifier hdInsightClusterPoolResourceId = HDInsightClusterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName); + HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); + + // get the collection of this HDInsightClusterResource + HDInsightClusterCollection collection = hdInsightClusterPool.GetHDInsightClusters(); + + // invoke the operation and iterate over the result + await foreach (HDInsightClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_HDInsightClusterGet() + { + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetCluster.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HDInsightClusterPoolResource created on azure + // for more information of creating HDInsightClusterPoolResource, please refer to the document of HDInsightClusterPoolResource + string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; + string resourceGroupName = "hiloResourcegroup"; + string clusterPoolName = "clusterpool1"; + ResourceIdentifier hdInsightClusterPoolResourceId = HDInsightClusterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName); + HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); + + // get the collection of this HDInsightClusterResource + HDInsightClusterCollection collection = hdInsightClusterPool.GetHDInsightClusters(); + + // invoke the operation + string clusterName = "cluster1"; + bool result = await collection.ExistsAsync(clusterName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_HDInsightClusterGet() + { + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetCluster.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HDInsightClusterPoolResource created on azure + // for more information of creating HDInsightClusterPoolResource, please refer to the document of HDInsightClusterPoolResource + string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; + string resourceGroupName = "hiloResourcegroup"; + string clusterPoolName = "clusterpool1"; + ResourceIdentifier hdInsightClusterPoolResourceId = HDInsightClusterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName); + HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); + + // get the collection of this HDInsightClusterResource + HDInsightClusterCollection collection = hdInsightClusterPool.GetHDInsightClusters(); + + // invoke the operation + string clusterName = "cluster1"; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + HDInsightClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterPoolCollection.cs b/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterPoolCollection.cs index 1cd1ec537d306..7722f9ac3e1c5 100644 --- a/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterPoolCollection.cs +++ b/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterPoolCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_HDInsightClusterPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ClusterPoolGet() + public async Task CreateOrUpdate_ClusterPoolPut() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetClusterPool.json - // this example is just showing the usage of "ClusterPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/CreateClusterPool.json + // this example is just showing the usage of "ClusterPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_ClusterPoolGet() // invoke the operation string clusterPoolName = "clusterpool1"; - HDInsightClusterPoolResource result = await collection.GetAsync(clusterPoolName); + HDInsightClusterPoolData data = new HDInsightClusterPoolData(new AzureLocation("West US 2")) + { + Properties = new HDInsightClusterPoolProperties(new ClusterPoolComputeProfile("Standard_D3_v2") + { + AvailabilityZones = { "1", "2", "3" }, + }) + { + ClusterPoolVersion = "1.2", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterPoolName, data); + HDInsightClusterPoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +63,10 @@ public async Task Get_ClusterPoolGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ClusterPoolGet() + public async Task CreateOrUpdate_ClusterPoolPutWithPrivateAks() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetClusterPool.json - // this example is just showing the usage of "ClusterPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/CreateClusterPoolWithPrivateAks.json + // this example is just showing the usage of "ClusterPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,17 +85,36 @@ public async Task Exists_ClusterPoolGet() // invoke the operation string clusterPoolName = "clusterpool1"; - bool result = await collection.ExistsAsync(clusterPoolName); + HDInsightClusterPoolData data = new HDInsightClusterPoolData(new AzureLocation("West US 2")) + { + Properties = new HDInsightClusterPoolProperties(new ClusterPoolComputeProfile("Standard_D3_v2") + { + AvailabilityZones = { "1", "2", "3" }, + }) + { + ClusterPoolVersion = "1.2", + NetworkProfile = new ClusterPoolNetworkProfile(new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1")) + { + IsPrivateApiServerEnabled = true, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterPoolName, data); + HDInsightClusterPoolResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ClusterPoolGet() + public async Task CreateOrUpdate_ClusterPoolPutWithUDRAks() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetClusterPool.json - // this example is just showing the usage of "ClusterPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/CreateClusterPoolWithUDRAks.json + // this example is just showing the usage of "ClusterPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,29 +133,36 @@ public async Task GetIfExists_ClusterPoolGet() // invoke the operation string clusterPoolName = "clusterpool1"; - NullableResponse response = await collection.GetIfExistsAsync(clusterPoolName); - HDInsightClusterPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + HDInsightClusterPoolData data = new HDInsightClusterPoolData(new AzureLocation("West US 2")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new HDInsightClusterPoolProperties(new ClusterPoolComputeProfile("Standard_D3_v2") + { + AvailabilityZones = { "1", "2", "3" }, + }) + { + ClusterPoolVersion = "1.2", + NetworkProfile = new ClusterPoolNetworkProfile(new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1")) + { + OutboundType = OutboundType.UserDefinedRouting, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterPoolName, data); + HDInsightClusterPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ClusterPoolPut() + public async Task Get_ClusterPoolGet() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/CreateClusterPool.json - // this example is just showing the usage of "ClusterPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetClusterPool.json + // this example is just showing the usage of "ClusterPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,21 +181,7 @@ public async Task CreateOrUpdate_ClusterPoolPut() // invoke the operation string clusterPoolName = "clusterpool1"; - HDInsightClusterPoolData data = new HDInsightClusterPoolData(new AzureLocation("West US 2")) - { - Properties = new HDInsightClusterPoolProperties(new ClusterPoolComputeProfile("Standard_D3_v2") - { - AvailabilityZones = -{ -"1","2","3" -}, - }) - { - ClusterPoolVersion = "1.2", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterPoolName, data); - HDInsightClusterPoolResource result = lro.Value; + HDInsightClusterPoolResource result = await collection.GetAsync(clusterPoolName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -169,10 +192,10 @@ public async Task CreateOrUpdate_ClusterPoolPut() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ClusterPoolPutWithPrivateAks() + public async Task GetAll_ClusterPoolsListByResourceGroup() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/CreateClusterPoolWithPrivateAks.json - // this example is just showing the usage of "ClusterPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/ListClusterPools.json + // this example is just showing the usage of "ClusterPools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,41 +212,25 @@ public async Task CreateOrUpdate_ClusterPoolPutWithPrivateAks() // get the collection of this HDInsightClusterPoolResource HDInsightClusterPoolCollection collection = resourceGroupResource.GetHDInsightClusterPools(); - // invoke the operation - string clusterPoolName = "clusterpool1"; - HDInsightClusterPoolData data = new HDInsightClusterPoolData(new AzureLocation("West US 2")) + // invoke the operation and iterate over the result + await foreach (HDInsightClusterPoolResource item in collection.GetAllAsync()) { - Properties = new HDInsightClusterPoolProperties(new ClusterPoolComputeProfile("Standard_D3_v2") - { - AvailabilityZones = -{ -"1","2","3" -}, - }) - { - ClusterPoolVersion = "1.2", - NetworkProfile = new ClusterPoolNetworkProfile(new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1")) - { - IsPrivateApiServerEnabled = true, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterPoolName, data); - HDInsightClusterPoolResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ClusterPoolPutWithUDRAks() + public async Task Exists_ClusterPoolGet() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/CreateClusterPoolWithUDRAks.json - // this example is just showing the usage of "ClusterPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetClusterPool.json + // this example is just showing the usage of "ClusterPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -242,39 +249,17 @@ public async Task CreateOrUpdate_ClusterPoolPutWithUDRAks() // invoke the operation string clusterPoolName = "clusterpool1"; - HDInsightClusterPoolData data = new HDInsightClusterPoolData(new AzureLocation("West US 2")) - { - Properties = new HDInsightClusterPoolProperties(new ClusterPoolComputeProfile("Standard_D3_v2") - { - AvailabilityZones = -{ -"1","2","3" -}, - }) - { - ClusterPoolVersion = "1.2", - NetworkProfile = new ClusterPoolNetworkProfile(new ResourceIdentifier("/subscriptions/subid/resourceGroups/hiloResourcegroup/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1")) - { - OutboundType = OutboundType.UserDefinedRouting, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterPoolName, data); - HDInsightClusterPoolResource result = lro.Value; + bool result = await collection.ExistsAsync(clusterPoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ClusterPoolsListByResourceGroup() + public async Task GetIfExists_ClusterPoolGet() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/ListClusterPools.json - // this example is just showing the usage of "ClusterPools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetClusterPool.json + // this example is just showing the usage of "ClusterPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -291,17 +276,23 @@ public async Task GetAll_ClusterPoolsListByResourceGroup() // get the collection of this HDInsightClusterPoolResource HDInsightClusterPoolCollection collection = resourceGroupResource.GetHDInsightClusterPools(); - // invoke the operation and iterate over the result - await foreach (HDInsightClusterPoolResource item in collection.GetAllAsync()) + // invoke the operation + string clusterPoolName = "clusterpool1"; + NullableResponse response = await collection.GetIfExistsAsync(clusterPoolName); + HDInsightClusterPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HDInsightClusterPoolData resourceData = item.Data; + HDInsightClusterPoolData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterPoolResource.cs b/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterPoolResource.cs index 01c52a342875a..4eb1103b2f090 100644 --- a/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterPoolResource.cs +++ b/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterPoolResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HDInsight.Containers.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HDInsight.Containers.Samples @@ -47,45 +46,6 @@ public async Task Get_ClusterPoolGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_ClusterPoolsPatchTags() - { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/PatchClusterPool.json - // this example is just showing the usage of "ClusterPools_UpdateTags" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HDInsightClusterPoolResource created on azure - // for more information of creating HDInsightClusterPoolResource, please refer to the document of HDInsightClusterPoolResource - string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; - string resourceGroupName = "hiloResourcegroup"; - string clusterPoolName = "clusterpool1"; - ResourceIdentifier hdInsightClusterPoolResourceId = HDInsightClusterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName); - HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); - - // invoke the operation - HDInsightClusterPoolPatch patch = new HDInsightClusterPoolPatch() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await hdInsightClusterPool.UpdateAsync(WaitUntil.Completed, patch); - HDInsightClusterPoolResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Delete_ClusterPoolDelete() @@ -114,33 +74,41 @@ public async Task Delete_ClusterPoolDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetHDInsightClusterPools_ClusterPoolsListBySubscription() + public async Task Update_ClusterPoolsPatchTags() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/ListClusterPoolsSubscription.json - // this example is just showing the usage of "ClusterPools_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/PatchClusterPool.json + // this example is just showing the usage of "ClusterPools_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this HDInsightClusterPoolResource created on azure + // for more information of creating HDInsightClusterPoolResource, please refer to the document of HDInsightClusterPoolResource string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "hiloResourcegroup"; + string clusterPoolName = "clusterpool1"; + ResourceIdentifier hdInsightClusterPoolResourceId = HDInsightClusterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName); + HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); - // invoke the operation and iterate over the result - await foreach (HDInsightClusterPoolResource item in subscriptionResource.GetHDInsightClusterPoolsAsync()) + // invoke the operation + HDInsightClusterPoolPatch patch = new HDInsightClusterPoolPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await hdInsightClusterPool.UpdateAsync(WaitUntil.Completed, patch); + HDInsightClusterPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -164,7 +132,7 @@ public async Task Upgrade_ClusterPoolsUpgradeAKSPatchVersion() HDInsightClusterPoolResource hdInsightClusterPool = client.GetHDInsightClusterPoolResource(hdInsightClusterPoolResourceId); // invoke the operation - ClusterPoolUpgrade clusterPoolUpgradeRequest = new ClusterPoolUpgrade(new ClusterPoolAKSPatchVersionUpgradeProperties() + ClusterPoolUpgrade clusterPoolUpgradeRequest = new ClusterPoolUpgrade(new ClusterPoolAKSPatchVersionUpgradeProperties { UpgradeClusterPool = true, UpgradeAllClusterNodes = false, diff --git a/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterResource.cs b/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterResource.cs index 595aa8f5ddc1c..9841bc6aee5e8 100644 --- a/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterResource.cs +++ b/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_HDInsightClusterResource.cs @@ -18,10 +18,10 @@ public partial class Sample_HDInsightClusterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Upgrade_ClustersUpgradeAKSPatchVersion() + public async Task Get_HDInsightClusterGet() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/UpgradeAKSPatchVersionForCluster.json - // this example is just showing the usage of "Clusters_Upgrade" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetCluster.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Upgrade_ClustersUpgradeAKSPatchVersion() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - ClusterUpgrade clusterUpgradeRequest = new ClusterUpgrade(new ClusterAKSPatchVersionUpgradeProperties()); - ArmOperation lro = await hdInsightCluster.UpgradeAsync(WaitUntil.Completed, clusterUpgradeRequest); - HDInsightClusterResource result = lro.Value; + HDInsightClusterResource result = await hdInsightCluster.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +49,10 @@ public async Task Upgrade_ClustersUpgradeAKSPatchVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Upgrade_ClustersUpgradeHotfix() + public async Task Delete_HDInsightClustersDelete() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/UpgradeHotfixForCluster.json - // this example is just showing the usage of "Clusters_Upgrade" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/DeleteCluster.json + // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,36 +62,24 @@ public async Task Upgrade_ClustersUpgradeHotfix() // this example assumes you already have this HDInsightClusterResource created on azure // for more information of creating HDInsightClusterResource, please refer to the document of HDInsightClusterResource string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; - string resourceGroupName = "hiloResourcegroup"; + string resourceGroupName = "rg1"; string clusterPoolName = "clusterpool1"; string clusterName = "cluster1"; ResourceIdentifier hdInsightClusterResourceId = HDInsightClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName, clusterName); HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - ClusterUpgrade clusterUpgradeRequest = new ClusterUpgrade(new ClusterHotfixUpgradeProperties() - { - TargetOssVersion = "1.16.0", - TargetClusterVersion = "1.0.6", - TargetBuildNumber = "3", - ComponentName = "historyserver", - }); - ArmOperation lro = await hdInsightCluster.UpgradeAsync(WaitUntil.Completed, clusterUpgradeRequest); - HDInsightClusterResource result = lro.Value; + await hdInsightCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HDInsightClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task UpgradeManualRollback_ClusterUpgradeRollback() + public async Task Update_HDInsightClustersPatchTags() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/ClusterUpgradeRollback.json - // this example is just showing the usage of "Clusters_UpgradeManualRollback" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/PatchCluster.json + // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,8 +96,87 @@ public async Task UpgradeManualRollback_ClusterUpgradeRollback() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - ClusterUpgradeRollback clusterRollbackUpgradeRequest = new ClusterUpgradeRollback(new ClusterUpgradeRollbackProperties("/subscriptions/10e32bab-26da-4cc4-a441-52b318f824e6/resourceGroups/hiloResourcegroup/providers/Microsoft.HDInsight/clusterpools/clusterpool1/clusters/cluster1/upgradeHistories/01_11_2024_02_35_03_AM-HotfixUpgrade")); - ArmOperation lro = await hdInsightCluster.UpgradeManualRollbackAsync(WaitUntil.Completed, clusterRollbackUpgradeRequest); + HDInsightClusterPatch patch = new HDInsightClusterPatch + { + ClusterProfile = new UpdatableClusterProfile + { + ServiceConfigsProfiles = {new ClusterServiceConfigsProfile("TestService1", new ClusterServiceConfig[] +{ +new ClusterServiceConfig("TestComp1", new ClusterConfigFile[] +{ +new ClusterConfigFile("TestFile1") +{ +Values = +{ +["Test.config.1"] = "1", +["Test.config.2"] = "2" +}, +}, +new ClusterConfigFile("TestFile2") +{ +Values = +{ +["Test.config.3"] = "3", +["Test.config.4"] = "4" +}, +} +}), +new ClusterServiceConfig("TestComp2", new ClusterConfigFile[] +{ +new ClusterConfigFile("TestFile3") +{ +Content = "TestContent", +Path = "TestPath", +}, +new ClusterConfigFile("TestFile4") +{ +Values = +{ +["Test.config.7"] = "7", +["Test.config.8"] = "8" +}, +} +}) +}), new ClusterServiceConfigsProfile("TestService2", new ClusterServiceConfig[] +{ +new ClusterServiceConfig("TestComp3", new ClusterConfigFile[] +{ +new ClusterConfigFile("TestFile5") +{ +Values = +{ +["Test.config.9"] = "9" +}, +} +}) +})}, + SshProfile = new ClusterSshProfile(2), + AutoscaleProfile = new ClusterAutoscaleProfile(true) + { + GracefulDecommissionTimeout = -1, + AutoscaleType = ClusterAutoscaleType.ScheduleBased, + ScheduleBasedConfig = new ScheduleBasedConfig("Cen. Australia Standard Time", 3, new AutoscaleSchedule[] + { +new AutoscaleSchedule("00:00", "12:00", 3, new AutoscaleScheduleDay[]{new AutoscaleScheduleDay("Monday, Tuesday, Wednesday")}), +new AutoscaleSchedule("00:00", "12:00", 3, new AutoscaleScheduleDay[]{AutoscaleScheduleDay.Sunday}) + }), + }, + AuthorizationProfile = new AuthorizationProfile + { + UserIds = { "Testuser1", "Testuser2" }, + }, + LogAnalyticsProfile = new ClusterLogAnalyticsProfile(true) + { + ApplicationLogs = new ClusterLogAnalyticsApplicationLogs + { + IsStdOutEnabled = true, + IsStdErrorEnabled = true, + }, + IsMetricsEnabled = true, + }, + }, + }; + ArmOperation lro = await hdInsightCluster.UpdateAsync(WaitUntil.Completed, patch); HDInsightClusterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -123,10 +188,10 @@ public async Task UpgradeManualRollback_ClusterUpgradeRollback() [Test] [Ignore("Only validating compilation of examples")] - public async Task Resize_HDInsightClusterResize() + public async Task Update_HDInsightRangerClusterPatchTags() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/ResizeCluster.json - // this example is just showing the usage of "Clusters_Resize" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/PatchRangerCluster.json + // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,11 +208,27 @@ public async Task Resize_HDInsightClusterResize() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - ClusterResizeContent content = new ClusterResizeContent(new AzureLocation("West US 2")) + HDInsightClusterPatch patch = new HDInsightClusterPatch { - ClusterResizeTargetWorkerNodeCount = 5, + ClusterProfile = new UpdatableClusterProfile + { + RangerProfile = new RangerProfile(new RangerAdminSpec(new string[] { "testuser1@contoso.com", "testuser2@contoso.com" }, new RangerAdminSpecDatabase("testsqlserver.database.windows.net", "testdb") + { + PasswordSecretRef = "https://testkv.vault.azure.net/secrets/mysecret/5df6584d9c25418c8d900240aa6c3452", + Username = "admin", + }), new RangerUsersyncSpec + { + IsEnabled = true, + Groups = { "0a53828f-36c9-44c3-be3d-99a7fce977ad", "13be6971-79db-4f33-9d41-b25589ca25ac" }, + Mode = RangerUsersyncMode.Automatic, + Users = { "testuser1@contoso.com", "testuser2@contoso.com" }, + }) + { + RangerAuditStorageAccount = "https://teststorage.blob.core.windows.net/testblob", + }, + }, }; - ArmOperation lro = await hdInsightCluster.ResizeAsync(WaitUntil.Completed, content); + ArmOperation lro = await hdInsightCluster.UpdateAsync(WaitUntil.Completed, patch); HDInsightClusterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -159,10 +240,10 @@ public async Task Resize_HDInsightClusterResize() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_HDInsightClusterGet() + public async Task Upgrade_ClustersUpgradeAKSPatchVersion() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/GetCluster.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/UpgradeAKSPatchVersionForCluster.json + // this example is just showing the usage of "Clusters_Upgrade" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,7 +260,9 @@ public async Task Get_HDInsightClusterGet() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterResource result = await hdInsightCluster.GetAsync(); + ClusterUpgrade clusterUpgradeRequest = new ClusterUpgrade(new ClusterAKSPatchVersionUpgradeProperties()); + ArmOperation lro = await hdInsightCluster.UpgradeAsync(WaitUntil.Completed, clusterUpgradeRequest); + HDInsightClusterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -190,10 +273,10 @@ public async Task Get_HDInsightClusterGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_HDInsightClustersPatchTags() + public async Task Upgrade_ClustersUpgradeHotfix() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/PatchCluster.json - // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/UpgradeHotfixForCluster.json + // this example is just showing the usage of "Clusters_Upgrade" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -210,95 +293,14 @@ public async Task Update_HDInsightClustersPatchTags() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterPatch patch = new HDInsightClusterPatch() - { - ClusterProfile = new UpdatableClusterProfile() - { - ServiceConfigsProfiles = -{ -new ClusterServiceConfigsProfile("TestService1",new ClusterServiceConfig[] -{ -new ClusterServiceConfig("TestComp1",new ClusterConfigFile[] -{ -new ClusterConfigFile("TestFile1") -{ -Values = -{ -["Test.config.1"] = "1", -["Test.config.2"] = "2", -}, -},new ClusterConfigFile("TestFile2") -{ -Values = -{ -["Test.config.3"] = "3", -["Test.config.4"] = "4", -}, -} -}),new ClusterServiceConfig("TestComp2",new ClusterConfigFile[] -{ -new ClusterConfigFile("TestFile3") -{ -Content = "TestContent", -Path = "TestPath", -},new ClusterConfigFile("TestFile4") -{ -Values = -{ -["Test.config.7"] = "7", -["Test.config.8"] = "8", -}, -} -}) -}),new ClusterServiceConfigsProfile("TestService2",new ClusterServiceConfig[] -{ -new ClusterServiceConfig("TestComp3",new ClusterConfigFile[] -{ -new ClusterConfigFile("TestFile5") -{ -Values = -{ -["Test.config.9"] = "9", -}, -} -}) -}) -}, - SshProfile = new ClusterSshProfile(2), - AutoscaleProfile = new ClusterAutoscaleProfile(true) - { - GracefulDecommissionTimeout = -1, - AutoscaleType = ClusterAutoscaleType.ScheduleBased, - ScheduleBasedConfig = new ScheduleBasedConfig("Cen. Australia Standard Time", 3, new AutoscaleSchedule[] + ClusterUpgrade clusterUpgradeRequest = new ClusterUpgrade(new ClusterHotfixUpgradeProperties { -new AutoscaleSchedule("00:00","12:00",3,new AutoscaleScheduleDay[] -{ -new AutoscaleScheduleDay("Monday, Tuesday, Wednesday") -}),new AutoscaleSchedule("00:00","12:00",3,new AutoscaleScheduleDay[] -{ -AutoscaleScheduleDay.Sunday -}) - }), - }, - AuthorizationProfile = new AuthorizationProfile() - { - UserIds = -{ -"Testuser1","Testuser2" -}, - }, - LogAnalyticsProfile = new ClusterLogAnalyticsProfile(true) - { - ApplicationLogs = new ClusterLogAnalyticsApplicationLogs() - { - IsStdOutEnabled = true, - IsStdErrorEnabled = true, - }, - IsMetricsEnabled = true, - }, - }, - }; - ArmOperation lro = await hdInsightCluster.UpdateAsync(WaitUntil.Completed, patch); + TargetOssVersion = "1.16.0", + TargetClusterVersion = "1.0.6", + TargetBuildNumber = "3", + ComponentName = "historyserver", + }); + ArmOperation lro = await hdInsightCluster.UpgradeAsync(WaitUntil.Completed, clusterUpgradeRequest); HDInsightClusterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -310,10 +312,10 @@ public async Task Update_HDInsightClustersPatchTags() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_HDInsightRangerClusterPatchTags() + public async Task UpgradeManualRollback_ClusterUpgradeRollback() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/PatchRangerCluster.json - // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/ClusterUpgradeRollback.json + // this example is just showing the usage of "Clusters_UpgradeManualRollback" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -330,36 +332,8 @@ public async Task Update_HDInsightRangerClusterPatchTags() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - HDInsightClusterPatch patch = new HDInsightClusterPatch() - { - ClusterProfile = new UpdatableClusterProfile() - { - RangerProfile = new RangerProfile(new RangerAdminSpec(new string[] - { -"testuser1@contoso.com","testuser2@contoso.com" - }, new RangerAdminSpecDatabase("testsqlserver.database.windows.net", "testdb") - { - PasswordSecretRef = "https://testkv.vault.azure.net/secrets/mysecret/5df6584d9c25418c8d900240aa6c3452", - Username = "admin", - }), new RangerUsersyncSpec() - { - IsEnabled = true, - Groups = - { -"0a53828f-36c9-44c3-be3d-99a7fce977ad","13be6971-79db-4f33-9d41-b25589ca25ac" - }, - Mode = RangerUsersyncMode.Automatic, - Users = - { -"testuser1@contoso.com","testuser2@contoso.com" - }, - }) - { - RangerAuditStorageAccount = "https://teststorage.blob.core.windows.net/testblob", - }, - }, - }; - ArmOperation lro = await hdInsightCluster.UpdateAsync(WaitUntil.Completed, patch); + ClusterUpgradeRollback clusterRollbackUpgradeRequest = new ClusterUpgradeRollback(new ClusterUpgradeRollbackProperties("/subscriptions/10e32bab-26da-4cc4-a441-52b318f824e6/resourceGroups/hiloResourcegroup/providers/Microsoft.HDInsight/clusterpools/clusterpool1/clusters/cluster1/upgradeHistories/01_11_2024_02_35_03_AM-HotfixUpgrade")); + ArmOperation lro = await hdInsightCluster.UpgradeManualRollbackAsync(WaitUntil.Completed, clusterRollbackUpgradeRequest); HDInsightClusterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -371,10 +345,10 @@ public async Task Update_HDInsightRangerClusterPatchTags() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_HDInsightClustersDelete() + public async Task Resize_HDInsightClusterResize() { - // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/DeleteCluster.json - // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/ResizeCluster.json + // this example is just showing the usage of "Clusters_Resize" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -384,16 +358,25 @@ public async Task Delete_HDInsightClustersDelete() // this example assumes you already have this HDInsightClusterResource created on azure // for more information of creating HDInsightClusterResource, please refer to the document of HDInsightClusterResource string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; - string resourceGroupName = "rg1"; + string resourceGroupName = "hiloResourcegroup"; string clusterPoolName = "clusterpool1"; string clusterName = "cluster1"; ResourceIdentifier hdInsightClusterResourceId = HDInsightClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterPoolName, clusterName); HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - await hdInsightCluster.DeleteAsync(WaitUntil.Completed); + ClusterResizeContent content = new ClusterResizeContent(new AzureLocation("West US 2")) + { + ClusterResizeTargetWorkerNodeCount = 5, + }; + ArmOperation lro = await hdInsightCluster.ResizeAsync(WaitUntil.Completed, content); + HDInsightClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -565,7 +548,7 @@ public async Task RunJobClusterJob_RunClusterJob() HDInsightClusterResource hdInsightCluster = client.GetHDInsightClusterResource(hdInsightClusterResourceId); // invoke the operation - ClusterJob clusterJob = new ClusterJob(new FlinkJobProperties() + ClusterJob clusterJob = new ClusterJob(new FlinkJobProperties { JobName = "flink-job-name", JobJarDirectory = "abfs://flinkjob@hilosa.dfs.core.windows.net/jars", @@ -575,7 +558,7 @@ public async Task RunJobClusterJob_RunClusterJob() FlinkConfiguration = { ["parallelism"] = "1", -["savepoint.directory"] = "abfs://flinkjob@hilosa.dfs.core.windows.net/savepoint", +["savepoint.directory"] = "abfs://flinkjob@hilosa.dfs.core.windows.net/savepoint" }, }); ArmOperation lro = await hdInsightCluster.RunJobClusterJobAsync(WaitUntil.Completed, clusterJob); @@ -704,7 +687,8 @@ public async Task ManageLibrariesClusterLibrary_InstallNewClusterLibraries() { Version = "2.31.0", Remarks = "PyPi packages.", -}),new ClusterLibrary(new ClusterMavenLibraryProperties("org.apache.flink","flink-connector-kafka") +}), +new ClusterLibrary(new ClusterMavenLibraryProperties("org.apache.flink", "flink-connector-kafka") { Version = "3.0.2-1.18", Remarks = "Maven packages.", @@ -739,7 +723,8 @@ public async Task ManageLibrariesClusterLibrary_UninstallExistingClusterLibrarie // invoke the operation ClusterLibraryManagementOperationContent content = new ClusterLibraryManagementOperationContent(new ClusterLibraryManagementOperationProperties(LibraryManagementAction.Uninstall, new ClusterLibrary[] { -new ClusterLibrary(new ClusterPyPILibraryProperties("tensorflow")),new ClusterLibrary(new ClusterMavenLibraryProperties("org.apache.flink","flink-connector-hudi")) +new ClusterLibrary(new ClusterPyPILibraryProperties("tensorflow")), +new ClusterLibrary(new ClusterMavenLibraryProperties("org.apache.flink", "flink-connector-hudi")) })); await hdInsightCluster.ManageLibrariesClusterLibraryAsync(WaitUntil.Completed, content); diff --git a/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 233d41f9c18ee..526d4fac01a00 100644 --- a/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/hdinsightcontainers/Azure.ResourceManager.HDInsight.Containers/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.HDInsight.Containers.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHDInsightClusterPools_ClusterPoolsListBySubscription() + { + // Generated from example definition: specification/hdinsight/resource-manager/Microsoft.HDInsight/HDInsightOnAks/preview/2024-05-01-preview/examples/ListClusterPoolsSubscription.json + // this example is just showing the usage of "ClusterPools_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "10e32bab-26da-4cc4-a441-52b318f824e6"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HDInsightClusterPoolResource item in subscriptionResource.GetHDInsightClusterPoolsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HDInsightClusterPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CheckHDInsightNameAvailability_LocationsNameAvailability() @@ -37,7 +68,7 @@ public async Task CheckHDInsightNameAvailability_LocationsNameAvailability() // invoke the operation AzureLocation location = new AzureLocation("southeastasia"); - HDInsightNameAvailabilityContent content = new HDInsightNameAvailabilityContent() + HDInsightNameAvailabilityContent content = new HDInsightNameAvailabilityContent { Name = "contosemember1", ResourceType = "Microsoft.HDInsight/clusterPools/clusters", diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_HealthBotCollection.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_HealthBotCollection.cs index 8892b64c84989..1581516b06c47 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_HealthBotCollection.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_HealthBotCollection.cs @@ -49,7 +49,7 @@ public async Task CreateOrUpdate_BotCreate() UserAssignedIdentities = { [new ResourceIdentifier("/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi")] = new UserAssignedIdentity(), -[new ResourceIdentifier("/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/subscription-id/resourcegroups/myrg/providers/microsoft.managedidentity/userassignedidentities/my-mi2")] = new UserAssignedIdentity() }, }, }; @@ -98,10 +98,10 @@ public async Task Get_ResourceInfoGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ResourceInfoGet() + public async Task GetAll_ListBotsByResourceGroup() { - // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ResourceInfoGet.json - // this example is just showing the usage of "Bots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ListBotsByResourceGroup.json + // this example is just showing the usage of "Bots_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,24 +110,30 @@ public async Task Exists_ResourceInfoGet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "healthbotClient"; + string subscriptionId = "subscription-id"; + string resourceGroupName = "OneResourceGroupName"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this HealthBotResource HealthBotCollection collection = resourceGroupResource.GetHealthBots(); - // invoke the operation - string botName = "samplebotname"; - bool result = await collection.ExistsAsync(botName); + // invoke the operation and iterate over the result + await foreach (HealthBotResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthBotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ResourceInfoGet() + public async Task Exists_ResourceInfoGet() { // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ResourceInfoGet.json // this example is just showing the usage of "Bots_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +155,17 @@ public async Task GetIfExists_ResourceInfoGet() // invoke the operation string botName = "samplebotname"; - NullableResponse response = await collection.GetIfExistsAsync(botName); - HealthBotResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(botName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthBotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBotsByResourceGroup() + public async Task GetIfExists_ResourceInfoGet() { - // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ListBotsByResourceGroup.json - // this example is just showing the usage of "Bots_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ResourceInfoGet.json + // this example is just showing the usage of "Bots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,25 +174,31 @@ public async Task GetAll_ListBotsByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subscription-id"; - string resourceGroupName = "OneResourceGroupName"; + string subscriptionId = "subid"; + string resourceGroupName = "healthbotClient"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this HealthBotResource HealthBotCollection collection = resourceGroupResource.GetHealthBots(); - // invoke the operation and iterate over the result - await foreach (HealthBotResource item in collection.GetAllAsync()) + // invoke the operation + string botName = "samplebotname"; + NullableResponse response = await collection.GetIfExistsAsync(botName); + HealthBotResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HealthBotData resourceData = item.Data; + HealthBotData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_HealthBotResource.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_HealthBotResource.cs index 760ef53ac75f9..bdcda2d5ce817 100644 --- a/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_HealthBotResource.cs +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_HealthBotResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HealthBot.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HealthBot.Samples @@ -49,10 +48,10 @@ public async Task Get_ResourceInfoGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BotUpdate() + public async Task Delete_BotDelete() { - // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ResourceUpdatePatch.json - // this example is just showing the usage of "Bots_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ResourceDeletionDelete.json + // this example is just showing the usage of "Bots_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,25 +67,17 @@ public async Task Update_BotUpdate() HealthBotResource healthBot = client.GetHealthBotResource(healthBotResourceId); // invoke the operation - HealthBotPatch patch = new HealthBotPatch() - { - SkuName = HealthBotSkuName.F0, - }; - HealthBotResource result = await healthBot.UpdateAsync(patch); + await healthBot.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthBotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BotDelete() + public async Task Update_BotUpdate() { - // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ResourceDeletionDelete.json - // this example is just showing the usage of "Bots_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ResourceUpdatePatch.json + // this example is just showing the usage of "Bots_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,40 +93,17 @@ public async Task Delete_BotDelete() HealthBotResource healthBot = client.GetHealthBotResource(healthBotResourceId); // invoke the operation - await healthBot.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetHealthBots_ListBotsBySubscription() - { - // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ListBotsBySubscription.json - // this example is just showing the usage of "Bots_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subscription-id"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (HealthBotResource item in subscriptionResource.GetHealthBotsAsync()) + HealthBotPatch patch = new HealthBotPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthBotData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SkuName = HealthBotSkuName.F0, + }; + HealthBotResource result = await healthBot.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthBotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..8d15c1d4db91f --- /dev/null +++ b/sdk/healthbot/Azure.ResourceManager.HealthBot/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.HealthBot.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHealthBots_ListBotsBySubscription() + { + // Generated from example definition: specification/healthbot/resource-manager/Microsoft.HealthBot/stable/2021-08-24/examples/ListBotsBySubscription.json + // this example is just showing the usage of "Bots_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subscription-id"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HealthBotResource item in subscriptionResource.GetHealthBotsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthBotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_DicomServiceCollection.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_DicomServiceCollection.cs index 16831a59a20dc..b8cdf766f95c9 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_DicomServiceCollection.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_DicomServiceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DicomServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDicomservices() + public async Task CreateOrUpdate_CreateOrUpdateADicomService() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_List.json - // this example is just showing the usage of "DicomServices_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_Create.json + // this example is just showing the usage of "DicomServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ListDicomservices() // get the collection of this DicomServiceResource DicomServiceCollection collection = healthcareApisWorkspace.GetDicomServices(); - // invoke the operation and iterate over the result - await foreach (DicomServiceResource item in collection.GetAllAsync()) + // invoke the operation + string dicomServiceName = "blue"; + DicomServiceData data = new DicomServiceData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DicomServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StorageConfiguration = new HealthcareApisServiceStorageConfiguration + { + StorageResourceId = new ResourceIdentifier("/subscriptions/ab309d4e-4c2e-4241-be2e-08e1c8dd4246/resourceGroups/rgname/providers/Microsoft.Storage/storageAccounts/accountname"), + FileSystemName = "fileSystemName", + }, + IsDataPartitionsEnabled = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dicomServiceName, data); + DicomServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DicomServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetADicomservice() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADicomservice() + public async Task GetAll_ListDicomservices() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_Get.json - // this example is just showing the usage of "DicomServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_List.json + // this example is just showing the usage of "DicomServices_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetADicomservice() // get the collection of this DicomServiceResource DicomServiceCollection collection = healthcareApisWorkspace.GetDicomServices(); - // invoke the operation - string dicomServiceName = "blue"; - bool result = await collection.ExistsAsync(dicomServiceName); + // invoke the operation and iterate over the result + await foreach (DicomServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DicomServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADicomservice() + public async Task Exists_GetADicomservice() { // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_Get.json // this example is just showing the usage of "DicomServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetADicomservice() // invoke the operation string dicomServiceName = "blue"; - NullableResponse response = await collection.GetIfExistsAsync(dicomServiceName); - DicomServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dicomServiceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DicomServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateADicomService() + public async Task GetIfExists_GetADicomservice() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_Create.json - // this example is just showing the usage of "DicomServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_Get.json + // this example is just showing the usage of "DicomServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateADicomService() // invoke the operation string dicomServiceName = "blue"; - DicomServiceData data = new DicomServiceData(new AzureLocation("westus")) - { - StorageConfiguration = new HealthcareApisServiceStorageConfiguration() - { - StorageResourceId = new ResourceIdentifier("/subscriptions/ab309d4e-4c2e-4241-be2e-08e1c8dd4246/resourceGroups/rgname/providers/Microsoft.Storage/storageAccounts/accountname"), - FileSystemName = "fileSystemName", - }, - IsDataPartitionsEnabled = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dicomServiceName, data); - DicomServiceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dicomServiceName); + DicomServiceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DicomServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DicomServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_DicomServiceResource.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_DicomServiceResource.cs index 95067a48bea27..5fe705a2365c8 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_DicomServiceResource.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_DicomServiceResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetADicomservice() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateADicomservice() + public async Task Delete_DeleteADicomservice() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_Patch.json - // this example is just showing the usage of "DicomServices_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_Delete.json + // this example is just showing the usage of "DicomServices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_UpdateADicomservice() DicomServiceResource dicomService = client.GetDicomServiceResource(dicomServiceResourceId); // invoke the operation - DicomServicePatch patch = new DicomServicePatch() - { - Tags = -{ -["tagKey"] = "tagValue", -}, - }; - ArmOperation lro = await dicomService.UpdateAsync(WaitUntil.Completed, patch); - DicomServiceResource result = lro.Value; + await dicomService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DicomServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteADicomservice() + public async Task Update_UpdateADicomservice() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_Delete.json - // this example is just showing the usage of "DicomServices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/dicomservices/DicomServices_Patch.json + // this example is just showing the usage of "DicomServices_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DeleteADicomservice() DicomServiceResource dicomService = client.GetDicomServiceResource(dicomServiceResourceId); // invoke the operation - await dicomService.DeleteAsync(WaitUntil.Completed); + DicomServicePatch patch = new DicomServicePatch + { + Tags = +{ +["tagKey"] = "tagValue" +}, + }; + ArmOperation lro = await dicomService.UpdateAsync(WaitUntil.Completed, patch); + DicomServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DicomServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_FhirServiceCollection.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_FhirServiceCollection.cs index f6ef704f4d717..1a93780ad9059 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_FhirServiceCollection.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_FhirServiceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_FhirServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFhirservices() + public async Task CreateOrUpdate_CreateOrUpdateAFhirService() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_List.json - // this example is just showing the usage of "FhirServices_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_Create.json + // this example is just showing the usage of "FhirServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,70 @@ public async Task GetAll_ListFhirservices() // get the collection of this FhirServiceResource FhirServiceCollection collection = healthcareApisWorkspace.GetFhirServices(); - // invoke the operation and iterate over the result - await foreach (FhirServiceResource item in collection.GetAllAsync()) + // invoke the operation + string fhirServiceName = "fhirservice1"; + FhirServiceData data = new FhirServiceData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FhirServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Kind = FhirServiceKind.FhirR4, + AcrConfiguration = new FhirServiceAcrConfiguration + { + LoginServers = { "test1.azurecr.io" }, + }, + AuthenticationConfiguration = new FhirServiceAuthenticationConfiguration + { + Authority = "https://login.microsoftonline.com/abfde7b2-df0f-47e6-aabf-2462b07508dc", + Audience = "https://azurehealthcareapis.com", + IsSmartProxyEnabled = true, + SmartIdentityProviders = {new SmartIdentityProviderConfiguration +{ +Authority = "https://login.b2clogin.com/11111111-1111-1111-1111-111111111111/v2.0", +Applications = {new SmartIdentityProviderApplication +{ +ClientId = "22222222-2222-2222-2222-222222222222", +Audience = "22222222-2222-2222-2222-222222222222", +AllowedDataActions = {SmartDataAction.Read}, +}}, +}}, + }, + CorsConfiguration = new FhirServiceCorsConfiguration + { + Origins = { "*" }, + Headers = { "*" }, + Methods = { "DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT" }, + MaxAge = 1440, + AllowCredentials = false, + }, + ExportStorageAccountName = "existingStorageAccount", + ImportConfiguration = new FhirServiceImportConfiguration + { + IntegrationDataStore = "existingStorageAccount", + IsInitialImportMode = false, + IsEnabled = false, + }, + IsUsCoreMissingDataEnabled = false, + KeyEncryptionKeyUri = new Uri("https://mykeyvault.vault.azure.net/keys/myEncryptionKey/myKeyVersion"), + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/subid/resourcegroups/testRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi")] = new UserAssignedIdentity() +}, + }, + Tags = +{ +["additionalProp1"] = "string", +["additionalProp2"] = "string", +["additionalProp3"] = "string" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fhirServiceName, data); + FhirServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FhirServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +142,10 @@ public async Task Get_GetAFhirService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAFhirService() + public async Task GetAll_ListFhirservices() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_Get.json - // this example is just showing the usage of "FhirServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_List.json + // this example is just showing the usage of "FhirServices_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +163,22 @@ public async Task Exists_GetAFhirService() // get the collection of this FhirServiceResource FhirServiceCollection collection = healthcareApisWorkspace.GetFhirServices(); - // invoke the operation - string fhirServiceName = "fhirservices1"; - bool result = await collection.ExistsAsync(fhirServiceName); + // invoke the operation and iterate over the result + await foreach (FhirServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FhirServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAFhirService() + public async Task Exists_GetAFhirService() { // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_Get.json // this example is just showing the usage of "FhirServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +201,17 @@ public async Task GetIfExists_GetAFhirService() // invoke the operation string fhirServiceName = "fhirservices1"; - NullableResponse response = await collection.GetIfExistsAsync(fhirServiceName); - FhirServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(fhirServiceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FhirServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAFhirService() + public async Task GetIfExists_GetAFhirService() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_Create.json - // this example is just showing the usage of "FhirServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_Get.json + // this example is just showing the usage of "FhirServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,90 +230,22 @@ public async Task CreateOrUpdate_CreateOrUpdateAFhirService() FhirServiceCollection collection = healthcareApisWorkspace.GetFhirServices(); // invoke the operation - string fhirServiceName = "fhirservice1"; - FhirServiceData data = new FhirServiceData(new AzureLocation("westus")) - { - Kind = FhirServiceKind.FhirR4, - AcrConfiguration = new FhirServiceAcrConfiguration() - { - LoginServers = -{ -"test1.azurecr.io" -}, - }, - AuthenticationConfiguration = new FhirServiceAuthenticationConfiguration() - { - Authority = "https://login.microsoftonline.com/abfde7b2-df0f-47e6-aabf-2462b07508dc", - Audience = "https://azurehealthcareapis.com", - IsSmartProxyEnabled = true, - SmartIdentityProviders = -{ -new SmartIdentityProviderConfiguration() -{ -Authority = "https://login.b2clogin.com/11111111-1111-1111-1111-111111111111/v2.0", -Applications = -{ -new SmartIdentityProviderApplication() -{ -ClientId = "22222222-2222-2222-2222-222222222222", -Audience = "22222222-2222-2222-2222-222222222222", -AllowedDataActions = -{ -SmartDataAction.Read -}, -} -}, -} -}, - }, - CorsConfiguration = new FhirServiceCorsConfiguration() - { - Origins = -{ -"*" -}, - Headers = -{ -"*" -}, - Methods = -{ -"DELETE","GET","OPTIONS","PATCH","POST","PUT" -}, - MaxAge = 1440, - AllowCredentials = false, - }, - ExportStorageAccountName = "existingStorageAccount", - ImportConfiguration = new FhirServiceImportConfiguration() - { - IntegrationDataStore = "existingStorageAccount", - IsInitialImportMode = false, - IsEnabled = false, - }, - IsUsCoreMissingDataEnabled = false, - KeyEncryptionKeyUri = new Uri("https://mykeyvault.vault.azure.net/keys/myEncryptionKey/myKeyVersion"), - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/subid/resourcegroups/testRG/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-mi")] = new UserAssignedIdentity(), -}, - }, - Tags = -{ -["additionalProp1"] = "string", -["additionalProp2"] = "string", -["additionalProp3"] = "string", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fhirServiceName, data); - FhirServiceResource result = lro.Value; + string fhirServiceName = "fhirservices1"; + NullableResponse response = await collection.GetIfExistsAsync(fhirServiceName); + FhirServiceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FhirServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FhirServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_FhirServiceResource.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_FhirServiceResource.cs index 65cb4c2e422bd..f85e01cc77b8f 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_FhirServiceResource.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_FhirServiceResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAFhirService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAFhirService() + public async Task Delete_DeleteAFhirService() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_Patch.json - // this example is just showing the usage of "FhirServices_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_Delete.json + // this example is just showing the usage of "FhirServices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_UpdateAFhirService() FhirServiceResource fhirService = client.GetFhirServiceResource(fhirServiceResourceId); // invoke the operation - FhirServicePatch patch = new FhirServicePatch() - { - Tags = -{ -["tagKey"] = "tagValue", -}, - }; - ArmOperation lro = await fhirService.UpdateAsync(WaitUntil.Completed, patch); - FhirServiceResource result = lro.Value; + await fhirService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FhirServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAFhirService() + public async Task Update_UpdateAFhirService() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_Delete.json - // this example is just showing the usage of "FhirServices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/fhirservices/FhirServices_Patch.json + // this example is just showing the usage of "FhirServices_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DeleteAFhirService() FhirServiceResource fhirService = client.GetFhirServiceResource(fhirServiceResourceId); // invoke the operation - await fhirService.DeleteAsync(WaitUntil.Completed); + FhirServicePatch patch = new FhirServicePatch + { + Tags = +{ +["tagKey"] = "tagValue" +}, + }; + ArmOperation lro = await fhirService.UpdateAsync(WaitUntil.Completed, patch); + FhirServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FhirServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotConnectorCollection.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotConnectorCollection.cs index fb1d874eb4584..490ced75fb11d 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotConnectorCollection.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotConnectorCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -20,10 +19,10 @@ public partial class Sample_HealthcareApisIotConnectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIotconnectors() + public async Task CreateOrUpdate_CreateAnIoTConnector() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_List.json - // this example is just showing the usage of "IotConnectors_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_Create.json + // this example is just showing the usage of "IotConnectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +40,59 @@ public async Task GetAll_ListIotconnectors() // get the collection of this HealthcareApisIotConnectorResource HealthcareApisIotConnectorCollection collection = healthcareApisWorkspace.GetHealthcareApisIotConnectors(); - // invoke the operation and iterate over the result - await foreach (HealthcareApisIotConnectorResource item in collection.GetAllAsync()) + // invoke the operation + string iotConnectorName = "blue"; + HealthcareApisIotConnectorData data = new HealthcareApisIotConnectorData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisIotConnectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IngestionEndpointConfiguration = new HealthcareApisIotConnectorEventHubIngestionConfiguration + { + EventHubName = "MyEventHubName", + ConsumerGroup = "ConsumerGroupA", + FullyQualifiedEventHubNamespace = "myeventhub.servicesbus.windows.net", + }, + DeviceMappingContent = BinaryData.FromObjectAsJson(new + { + template = new object[] + { +new +{ +template = new +{ +deviceIdExpression = "$.deviceid", +timestampExpression = "$.measurementdatetime", +typeMatchExpression = "$..[?(@heartrate)]", +typeName = "heartrate", +values = new object[] +{ +new +{ +required = "true", +valueExpression = "$.heartrate", +valueName = "hr", +} +}, +}, +templateType = "JsonPathContent", +} + }, + templateType = "CollectionContent", + }), + Identity = new ManagedServiceIdentity("SystemAssigned"), + Tags = +{ +["additionalProp1"] = "string", +["additionalProp2"] = "string", +["additionalProp3"] = "string" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, iotConnectorName, data); + HealthcareApisIotConnectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisIotConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +131,10 @@ public async Task Get_GetAnIoTConnector() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnIoTConnector() + public async Task GetAll_ListIotconnectors() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_Get.json - // this example is just showing the usage of "IotConnectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_List.json + // this example is just showing the usage of "IotConnectors_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +152,22 @@ public async Task Exists_GetAnIoTConnector() // get the collection of this HealthcareApisIotConnectorResource HealthcareApisIotConnectorCollection collection = healthcareApisWorkspace.GetHealthcareApisIotConnectors(); - // invoke the operation - string iotConnectorName = "blue"; - bool result = await collection.ExistsAsync(iotConnectorName); + // invoke the operation and iterate over the result + await foreach (HealthcareApisIotConnectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisIotConnectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnIoTConnector() + public async Task Exists_GetAnIoTConnector() { // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_Get.json // this example is just showing the usage of "IotConnectors_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,29 +190,17 @@ public async Task GetIfExists_GetAnIoTConnector() // invoke the operation string iotConnectorName = "blue"; - NullableResponse response = await collection.GetIfExistsAsync(iotConnectorName); - HealthcareApisIotConnectorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(iotConnectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisIotConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnIoTConnector() + public async Task GetIfExists_GetAnIoTConnector() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_Create.json - // this example is just showing the usage of "IotConnectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_Get.json + // this example is just showing the usage of "IotConnectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,48 +220,21 @@ public async Task CreateOrUpdate_CreateAnIoTConnector() // invoke the operation string iotConnectorName = "blue"; - HealthcareApisIotConnectorData data = new HealthcareApisIotConnectorData(new AzureLocation("westus")) - { - IngestionEndpointConfiguration = new HealthcareApisIotConnectorEventHubIngestionConfiguration() - { - EventHubName = "MyEventHubName", - ConsumerGroup = "ConsumerGroupA", - FullyQualifiedEventHubNamespace = "myeventhub.servicesbus.windows.net", - }, - DeviceMappingContent = BinaryData.FromObjectAsJson(new Dictionary() - { - ["template"] = new object[] { new Dictionary() -{ -["template"] = new Dictionary() -{ -["deviceIdExpression"] = "$.deviceid", -["timestampExpression"] = "$.measurementdatetime", -["typeMatchExpression"] = "$..[?(@heartrate)]", -["typeName"] = "heartrate", -["values"] = new object[] { new Dictionary() -{ -["required"] = "true", -["valueExpression"] = "$.heartrate", -["valueName"] = "hr"} }}, -["templateType"] = "JsonPathContent"} }, - ["templateType"] = "CollectionContent" - }), - Identity = new ManagedServiceIdentity("SystemAssigned"), - Tags = -{ -["additionalProp1"] = "string", -["additionalProp2"] = "string", -["additionalProp3"] = "string", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, iotConnectorName, data); - HealthcareApisIotConnectorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(iotConnectorName); + HealthcareApisIotConnectorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisIotConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisIotConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotConnectorResource.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotConnectorResource.cs index 6b9285a735c3f..bf5bef9bd2fd6 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotConnectorResource.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotConnectorResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetAnIoTConnector() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAnIoTConnector() + public async Task Delete_DeleteAnIoTConnector() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_Patch.json - // this example is just showing the usage of "IotConnectors_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_Delete.json + // this example is just showing the usage of "IotConnectors_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,32 +70,17 @@ public async Task Update_PatchAnIoTConnector() HealthcareApisIotConnectorResource healthcareApisIotConnector = client.GetHealthcareApisIotConnectorResource(healthcareApisIotConnectorResourceId); // invoke the operation - HealthcareApisIotConnectorPatch patch = new HealthcareApisIotConnectorPatch() - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - Tags = -{ -["additionalProp1"] = "string", -["additionalProp2"] = "string", -["additionalProp3"] = "string", -}, - }; - ArmOperation lro = await healthcareApisIotConnector.UpdateAsync(WaitUntil.Completed, patch); - HealthcareApisIotConnectorResource result = lro.Value; + await healthcareApisIotConnector.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisIotConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnIoTConnector() + public async Task Update_PatchAnIoTConnector() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_Delete.json - // this example is just showing the usage of "IotConnectors_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_Patch.json + // this example is just showing the usage of "IotConnectors_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,9 +97,24 @@ public async Task Delete_DeleteAnIoTConnector() HealthcareApisIotConnectorResource healthcareApisIotConnector = client.GetHealthcareApisIotConnectorResource(healthcareApisIotConnectorResourceId); // invoke the operation - await healthcareApisIotConnector.DeleteAsync(WaitUntil.Completed); + HealthcareApisIotConnectorPatch patch = new HealthcareApisIotConnectorPatch + { + Identity = new ManagedServiceIdentity("SystemAssigned"), + Tags = +{ +["additionalProp1"] = "string", +["additionalProp2"] = "string", +["additionalProp3"] = "string" +}, + }; + ArmOperation lro = await healthcareApisIotConnector.UpdateAsync(WaitUntil.Completed, patch); + HealthcareApisIotConnectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisIotConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotFhirDestinationCollection.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotFhirDestinationCollection.cs index 4707493ebd0f0..3fe7c8f2f560d 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotFhirDestinationCollection.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotFhirDestinationCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_HealthcareApisIotFhirDestinationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIoTConnectors() + public async Task CreateOrUpdate_CreateOrUpdateAnIotConnectorFHIRDestination() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_List.json - // this example is just showing the usage of "FhirDestinations_ListByIotConnector" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_Create.json + // this example is just showing the usage of "IotConnectorFhirDestination_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +40,54 @@ public async Task GetAll_ListIoTConnectors() // get the collection of this HealthcareApisIotFhirDestinationResource HealthcareApisIotFhirDestinationCollection collection = healthcareApisIotConnector.GetHealthcareApisIotFhirDestinations(); - // invoke the operation and iterate over the result - await foreach (HealthcareApisIotFhirDestinationResource item in collection.GetAllAsync()) + // invoke the operation + string fhirDestinationName = "dest1"; + HealthcareApisIotFhirDestinationData data = new HealthcareApisIotFhirDestinationData(HealthcareApisIotIdentityResolutionType.Create, new ResourceIdentifier("subscriptions/11111111-2222-3333-4444-555566667777/resourceGroups/myrg/providers/Microsoft.HealthcareApis/workspaces/myworkspace/fhirservices/myfhirservice"), new HealthcareApisIotMappingProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisIotFhirDestinationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Content = BinaryData.FromObjectAsJson(new + { + template = new object[] + { +new +{ +template = new +{ +codes = new object[] +{ +new +{ +code = "8867-4", +display = "Heart rate", +system = "http://loinc.org", +} +}, +periodInterval = "60", +typeName = "heartrate", +value = new +{ +defaultPeriod = "5000", +unit = "count/min", +valueName = "hr", +valueType = "SampledData", +}, +}, +templateType = "CodeValueFhir", +} + }, + templateType = "CollectionFhirTemplate", + }), + }) + { + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fhirDestinationName, data); + HealthcareApisIotFhirDestinationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisIotFhirDestinationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +127,10 @@ public async Task Get_GetAnIoTConnectorDestination() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnIoTConnectorDestination() + public async Task GetAll_ListIoTConnectors() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_Get.json - // this example is just showing the usage of "IotConnectorFhirDestination_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_List.json + // this example is just showing the usage of "FhirDestinations_ListByIotConnector" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +149,22 @@ public async Task Exists_GetAnIoTConnectorDestination() // get the collection of this HealthcareApisIotFhirDestinationResource HealthcareApisIotFhirDestinationCollection collection = healthcareApisIotConnector.GetHealthcareApisIotFhirDestinations(); - // invoke the operation - string fhirDestinationName = "dest1"; - bool result = await collection.ExistsAsync(fhirDestinationName); + // invoke the operation and iterate over the result + await foreach (HealthcareApisIotFhirDestinationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisIotFhirDestinationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnIoTConnectorDestination() + public async Task Exists_GetAnIoTConnectorDestination() { // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_Get.json // this example is just showing the usage of "IotConnectorFhirDestination_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +188,17 @@ public async Task GetIfExists_GetAnIoTConnectorDestination() // invoke the operation string fhirDestinationName = "dest1"; - NullableResponse response = await collection.GetIfExistsAsync(fhirDestinationName); - HealthcareApisIotFhirDestinationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(fhirDestinationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisIotFhirDestinationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnIotConnectorFHIRDestination() + public async Task GetIfExists_GetAnIoTConnectorDestination() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_Create.json - // this example is just showing the usage of "IotConnectorFhirDestination_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_Get.json + // this example is just showing the usage of "IotConnectorFhirDestination_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,42 +219,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAnIotConnectorFHIRDestination() // invoke the operation string fhirDestinationName = "dest1"; - HealthcareApisIotFhirDestinationData data = new HealthcareApisIotFhirDestinationData(HealthcareApisIotIdentityResolutionType.Create, new ResourceIdentifier("subscriptions/11111111-2222-3333-4444-555566667777/resourceGroups/myrg/providers/Microsoft.HealthcareApis/workspaces/myworkspace/fhirservices/myfhirservice"), new HealthcareApisIotMappingProperties() + NullableResponse response = await collection.GetIfExistsAsync(fhirDestinationName); + HealthcareApisIotFhirDestinationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Content = BinaryData.FromObjectAsJson(new Dictionary() - { - ["template"] = new object[] { new Dictionary() -{ -["template"] = new Dictionary() -{ -["codes"] = new object[] { new Dictionary() -{ -["code"] = "8867-4", -["display"] = "Heart rate", -["system"] = "http://loinc.org"} }, -["periodInterval"] = "60", -["typeName"] = "heartrate", -["value"] = new Dictionary() -{ -["defaultPeriod"] = "5000", -["unit"] = "count/min", -["valueName"] = "hr", -["valueType"] = "SampledData"}}, -["templateType"] = "CodeValueFhir"} }, - ["templateType"] = "CollectionFhirTemplate" - }), - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fhirDestinationName, data); - HealthcareApisIotFhirDestinationResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisIotFhirDestinationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisIotFhirDestinationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotFhirDestinationResource.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotFhirDestinationResource.cs index 5eb06879593b4..53e48646e20d2 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotFhirDestinationResource.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisIotFhirDestinationResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -51,10 +50,10 @@ public async Task Get_GetAnIoTConnectorDestination() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAnIotConnectorFHIRDestination() + public async Task Delete_DeleteAnIoTConnectorDestination() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_Create.json - // this example is just showing the usage of "IotConnectorFhirDestination_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_Delete.json + // this example is just showing the usage of "IotConnectorFhirDestination_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,50 +71,17 @@ public async Task Update_CreateOrUpdateAnIotConnectorFHIRDestination() HealthcareApisIotFhirDestinationResource healthcareApisIotFhirDestination = client.GetHealthcareApisIotFhirDestinationResource(healthcareApisIotFhirDestinationResourceId); // invoke the operation - HealthcareApisIotFhirDestinationData data = new HealthcareApisIotFhirDestinationData(HealthcareApisIotIdentityResolutionType.Create, new ResourceIdentifier("subscriptions/11111111-2222-3333-4444-555566667777/resourceGroups/myrg/providers/Microsoft.HealthcareApis/workspaces/myworkspace/fhirservices/myfhirservice"), new HealthcareApisIotMappingProperties() - { - Content = BinaryData.FromObjectAsJson(new Dictionary() - { - ["template"] = new object[] { new Dictionary() -{ -["template"] = new Dictionary() -{ -["codes"] = new object[] { new Dictionary() -{ -["code"] = "8867-4", -["display"] = "Heart rate", -["system"] = "http://loinc.org"} }, -["periodInterval"] = "60", -["typeName"] = "heartrate", -["value"] = new Dictionary() -{ -["defaultPeriod"] = "5000", -["unit"] = "count/min", -["valueName"] = "hr", -["valueType"] = "SampledData"}}, -["templateType"] = "CodeValueFhir"} }, - ["templateType"] = "CollectionFhirTemplate" - }), - }) - { - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await healthcareApisIotFhirDestination.UpdateAsync(WaitUntil.Completed, data); - HealthcareApisIotFhirDestinationResource result = lro.Value; + await healthcareApisIotFhirDestination.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisIotFhirDestinationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnIoTConnectorDestination() + public async Task Update_CreateOrUpdateAnIotConnectorFHIRDestination() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_Delete.json - // this example is just showing the usage of "IotConnectorFhirDestination_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/iotconnectors/iotconnector_fhirdestination_Create.json + // this example is just showing the usage of "IotConnectorFhirDestination_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,9 +99,52 @@ public async Task Delete_DeleteAnIoTConnectorDestination() HealthcareApisIotFhirDestinationResource healthcareApisIotFhirDestination = client.GetHealthcareApisIotFhirDestinationResource(healthcareApisIotFhirDestinationResourceId); // invoke the operation - await healthcareApisIotFhirDestination.DeleteAsync(WaitUntil.Completed); + HealthcareApisIotFhirDestinationData data = new HealthcareApisIotFhirDestinationData(HealthcareApisIotIdentityResolutionType.Create, new ResourceIdentifier("subscriptions/11111111-2222-3333-4444-555566667777/resourceGroups/myrg/providers/Microsoft.HealthcareApis/workspaces/myworkspace/fhirservices/myfhirservice"), new HealthcareApisIotMappingProperties + { + Content = BinaryData.FromObjectAsJson(new + { + template = new object[] + { +new +{ +template = new +{ +codes = new object[] +{ +new +{ +code = "8867-4", +display = "Heart rate", +system = "http://loinc.org", +} +}, +periodInterval = "60", +typeName = "heartrate", +value = new +{ +defaultPeriod = "5000", +unit = "count/min", +valueName = "hr", +valueType = "SampledData", +}, +}, +templateType = "CodeValueFhir", +} + }, + templateType = "CollectionFhirTemplate", + }), + }) + { + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await healthcareApisIotFhirDestination.UpdateAsync(WaitUntil.Completed, data); + HealthcareApisIotFhirDestinationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisIotFhirDestinationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServiceCollection.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServiceCollection.cs index ca3dbbb0aa59e..8690c70288bc8 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServiceCollection.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServiceCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_HealthcareApisServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMetadata() + public async Task CreateOrUpdate_CreateOrUpdateAServiceWithAllParameters() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGet.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceCreate.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,39 @@ public async Task Get_GetMetadata() // invoke the operation string resourceName = "service1"; - HealthcareApisServiceResource result = await collection.GetAsync(resourceName); + HealthcareApisServiceData data = new HealthcareApisServiceData(new AzureLocation("westus2"), HealthcareApisKind.FhirR4) + { + Properties = new HealthcareApisServiceProperties + { + AccessPolicies = { new HealthcareApisServiceAccessPolicyEntry("c487e7d1-3210-41a3-8ccc-e9372b78da47"), new HealthcareApisServiceAccessPolicyEntry("5b307da8-43d4-492b-8b66-b0294ade872f") }, + CosmosDbConfiguration = new HealthcareApisServiceCosmosDbConfiguration + { + OfferThroughput = 1000, + KeyVaultKeyUri = new Uri("https://my-vault.vault.azure.net/keys/my-key"), + }, + AuthenticationConfiguration = new HealthcareApisServiceAuthenticationConfiguration + { + Authority = "https://login.microsoftonline.com/abfde7b2-df0f-47e6-aabf-2462b07508dc", + Audience = "https://azurehealthcareapis.com", + IsSmartProxyEnabled = true, + }, + CorsConfiguration = new HealthcareApisServiceCorsConfiguration + { + Origins = { "*" }, + Headers = { "*" }, + Methods = { "DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT" }, + MaxAge = 1440, + AllowCredentials = false, + }, + ExportStorageAccountName = "existingStorageAccount", + PrivateEndpointConnections = { }, + PublicNetworkAccess = HealthcareApisPublicNetworkAccess.Disabled, + }, + Identity = new ManagedServiceIdentity("SystemAssigned"), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + HealthcareApisServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +85,10 @@ public async Task Get_GetMetadata() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMetadata() + public async Task CreateOrUpdate_CreateOrUpdateAServiceWithAllParametersAndCMKEnabledInADataSovereignRegion() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGet.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceCreateInDataSovereignRegionWithCmkEnabled.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +107,54 @@ public async Task Exists_GetMetadata() // invoke the operation string resourceName = "service1"; - bool result = await collection.ExistsAsync(resourceName); + HealthcareApisServiceData data = new HealthcareApisServiceData(new AzureLocation("Southeast Asia"), HealthcareApisKind.FhirR4) + { + Properties = new HealthcareApisServiceProperties + { + AccessPolicies = { new HealthcareApisServiceAccessPolicyEntry("c487e7d1-3210-41a3-8ccc-e9372b78da47"), new HealthcareApisServiceAccessPolicyEntry("5b307da8-43d4-492b-8b66-b0294ade872f") }, + CosmosDbConfiguration = new HealthcareApisServiceCosmosDbConfiguration + { + OfferThroughput = 1000, + KeyVaultKeyUri = new Uri("https://my-vault.vault.azure.net/keys/my-key"), + CrossTenantCmkApplicationId = Guid.Parse("de3fbeef-8c3a-428e-8b9f-4d229c8a85f4"), + }, + AuthenticationConfiguration = new HealthcareApisServiceAuthenticationConfiguration + { + Authority = "https://login.microsoftonline.com/abfde7b2-df0f-47e6-aabf-2462b07508dc", + Audience = "https://azurehealthcareapis.com", + IsSmartProxyEnabled = true, + }, + CorsConfiguration = new HealthcareApisServiceCorsConfiguration + { + Origins = { "*" }, + Headers = { "*" }, + Methods = { "DELETE", "GET", "OPTIONS", "PATCH", "POST", "PUT" }, + MaxAge = 1440, + AllowCredentials = false, + }, + ExportStorageAccountName = "existingStorageAccount", + PrivateEndpointConnections = { }, + PublicNetworkAccess = HealthcareApisPublicNetworkAccess.Disabled, + }, + Identity = new ManagedServiceIdentity("SystemAssigned"), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + HealthcareApisServiceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMetadata() + public async Task CreateOrUpdate_CreateOrUpdateAServiceWithMinimumParameters() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGet.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceCreateMinimum.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,29 +172,30 @@ public async Task GetIfExists_GetMetadata() HealthcareApisServiceCollection collection = resourceGroupResource.GetHealthcareApisServices(); // invoke the operation - string resourceName = "service1"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - HealthcareApisServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string resourceName = "service2"; + HealthcareApisServiceData data = new HealthcareApisServiceData(new AzureLocation("westus2"), HealthcareApisKind.FhirR4) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new HealthcareApisServiceProperties + { + AccessPolicies = { new HealthcareApisServiceAccessPolicyEntry("c487e7d1-3210-41a3-8ccc-e9372b78da47") }, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + HealthcareApisServiceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMetadataForCMKEnabledServiceInDataSovereignRegion() + public async Task Get_GetMetadata() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGetInDataSovereignRegionWithCmkEnabled.json + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGet.json // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -156,7 +226,7 @@ public async Task Get_GetMetadataForCMKEnabledServiceInDataSovereignRegion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMetadataForCMKEnabledServiceInDataSovereignRegion() + public async Task Get_GetMetadataForCMKEnabledServiceInDataSovereignRegion() { // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGetInDataSovereignRegionWithCmkEnabled.json // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. @@ -178,17 +248,21 @@ public async Task Exists_GetMetadataForCMKEnabledServiceInDataSovereignRegion() // invoke the operation string resourceName = "service1"; - bool result = await collection.ExistsAsync(resourceName); + HealthcareApisServiceResource result = await collection.GetAsync(resourceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMetadataForCMKEnabledServiceInDataSovereignRegion() + public async Task GetAll_ListAllServicesInResourceGroup() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGetInDataSovereignRegionWithCmkEnabled.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceListByResourceGroup.json + // this example is just showing the usage of "Services_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,38 +272,32 @@ public async Task GetIfExists_GetMetadataForCMKEnabledServiceInDataSovereignRegi // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgname"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this HealthcareApisServiceResource HealthcareApisServiceCollection collection = resourceGroupResource.GetHealthcareApisServices(); - // invoke the operation - string resourceName = "service1"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - HealthcareApisServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HealthcareApisServiceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HealthcareApisServiceData resourceData = result.Data; + HealthcareApisServiceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAServiceWithAllParameters() + public async Task Exists_GetMetadata() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceCreate.json - // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGet.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -248,69 +316,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAServiceWithAllParameters() // invoke the operation string resourceName = "service1"; - HealthcareApisServiceData data = new HealthcareApisServiceData(new AzureLocation("westus2"), HealthcareApisKind.FhirR4) - { - Properties = new HealthcareApisServiceProperties() - { - AccessPolicies = -{ -new HealthcareApisServiceAccessPolicyEntry("c487e7d1-3210-41a3-8ccc-e9372b78da47"),new HealthcareApisServiceAccessPolicyEntry("5b307da8-43d4-492b-8b66-b0294ade872f") -}, - CosmosDbConfiguration = new HealthcareApisServiceCosmosDbConfiguration() - { - OfferThroughput = 1000, - KeyVaultKeyUri = new Uri("https://my-vault.vault.azure.net/keys/my-key"), - }, - AuthenticationConfiguration = new HealthcareApisServiceAuthenticationConfiguration() - { - Authority = "https://login.microsoftonline.com/abfde7b2-df0f-47e6-aabf-2462b07508dc", - Audience = "https://azurehealthcareapis.com", - IsSmartProxyEnabled = true, - }, - CorsConfiguration = new HealthcareApisServiceCorsConfiguration() - { - Origins = -{ -"*" -}, - Headers = -{ -"*" -}, - Methods = -{ -"DELETE","GET","OPTIONS","PATCH","POST","PUT" -}, - MaxAge = 1440, - AllowCredentials = false, - }, - ExportStorageAccountName = "existingStorageAccount", - PrivateEndpointConnections = -{ -}, - PublicNetworkAccess = HealthcareApisPublicNetworkAccess.Disabled, - }, - Identity = new ManagedServiceIdentity("SystemAssigned"), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - HealthcareApisServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(resourceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAServiceWithAllParametersAndCMKEnabledInADataSovereignRegion() + public async Task Exists_GetMetadataForCMKEnabledServiceInDataSovereignRegion() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceCreateInDataSovereignRegionWithCmkEnabled.json - // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGetInDataSovereignRegionWithCmkEnabled.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -329,70 +345,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAServiceWithAllParametersAndCMKEn // invoke the operation string resourceName = "service1"; - HealthcareApisServiceData data = new HealthcareApisServiceData(new AzureLocation("Southeast Asia"), HealthcareApisKind.FhirR4) - { - Properties = new HealthcareApisServiceProperties() - { - AccessPolicies = -{ -new HealthcareApisServiceAccessPolicyEntry("c487e7d1-3210-41a3-8ccc-e9372b78da47"),new HealthcareApisServiceAccessPolicyEntry("5b307da8-43d4-492b-8b66-b0294ade872f") -}, - CosmosDbConfiguration = new HealthcareApisServiceCosmosDbConfiguration() - { - OfferThroughput = 1000, - KeyVaultKeyUri = new Uri("https://my-vault.vault.azure.net/keys/my-key"), - CrossTenantCmkApplicationId = Guid.Parse("de3fbeef-8c3a-428e-8b9f-4d229c8a85f4"), - }, - AuthenticationConfiguration = new HealthcareApisServiceAuthenticationConfiguration() - { - Authority = "https://login.microsoftonline.com/abfde7b2-df0f-47e6-aabf-2462b07508dc", - Audience = "https://azurehealthcareapis.com", - IsSmartProxyEnabled = true, - }, - CorsConfiguration = new HealthcareApisServiceCorsConfiguration() - { - Origins = -{ -"*" -}, - Headers = -{ -"*" -}, - Methods = -{ -"DELETE","GET","OPTIONS","PATCH","POST","PUT" -}, - MaxAge = 1440, - AllowCredentials = false, - }, - ExportStorageAccountName = "existingStorageAccount", - PrivateEndpointConnections = -{ -}, - PublicNetworkAccess = HealthcareApisPublicNetworkAccess.Disabled, - }, - Identity = new ManagedServiceIdentity("SystemAssigned"), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - HealthcareApisServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(resourceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAServiceWithMinimumParameters() + public async Task GetIfExists_GetMetadata() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceCreateMinimum.json - // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGet.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -410,36 +373,30 @@ public async Task CreateOrUpdate_CreateOrUpdateAServiceWithMinimumParameters() HealthcareApisServiceCollection collection = resourceGroupResource.GetHealthcareApisServices(); // invoke the operation - string resourceName = "service2"; - HealthcareApisServiceData data = new HealthcareApisServiceData(new AzureLocation("westus2"), HealthcareApisKind.FhirR4) - { - Properties = new HealthcareApisServiceProperties() - { - AccessPolicies = -{ -new HealthcareApisServiceAccessPolicyEntry("c487e7d1-3210-41a3-8ccc-e9372b78da47") -}, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - HealthcareApisServiceResource result = lro.Value; + string resourceName = "service1"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + HealthcareApisServiceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllServicesInResourceGroup() + public async Task GetIfExists_GetMetadataForCMKEnabledServiceInDataSovereignRegion() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceListByResourceGroup.json - // this example is just showing the usage of "Services_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGetInDataSovereignRegionWithCmkEnabled.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -449,24 +406,30 @@ public async Task GetAll_ListAllServicesInResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "subid"; - string resourceGroupName = "rgname"; + string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this HealthcareApisServiceResource HealthcareApisServiceCollection collection = resourceGroupResource.GetHealthcareApisServices(); - // invoke the operation and iterate over the result - await foreach (HealthcareApisServiceResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "service1"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + HealthcareApisServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HealthcareApisServiceData resourceData = item.Data; + HealthcareApisServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateEndpointConnectionCollection.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateEndpointConnectionCollection.cs index dac663cb2ae56..cdf612eae3d5f 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateEndpointConnectionCollection.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HealthcareApisServicePrivateEndpointConnectionCollec { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionList() + public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceListPrivateEndpointConnections.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceCreatePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_PrivateEndpointConnectionList() // get the collection of this HealthcareApisServicePrivateEndpointConnectionResource HealthcareApisServicePrivateEndpointConnectionCollection collection = healthcareApisService.GetHealthcareApisServicePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (HealthcareApisServicePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "myConnection"; + HealthcareApisPrivateEndpointConnectionData data = new HealthcareApisPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new HealthcareApisPrivateLinkServiceConnectionState + { + Status = HealthcareApisPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + HealthcareApisServicePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_PrivateEndpointConnectionGetConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionGetConnection() + public async Task GetAll_PrivateEndpointConnectionList() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceListPrivateEndpointConnections.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_PrivateEndpointConnectionGetConnection() // get the collection of this HealthcareApisServicePrivateEndpointConnectionResource HealthcareApisServicePrivateEndpointConnectionCollection collection = healthcareApisService.GetHealthcareApisServicePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "myConnection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (HealthcareApisServicePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionGetConnection() + public async Task Exists_PrivateEndpointConnectionGetConnection() { // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_PrivateEndpointConnectionGetConnection() // invoke the operation string privateEndpointConnectionName = "myConnection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - HealthcareApisServicePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() + public async Task GetIfExists_PrivateEndpointConnectionGetConnection() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceCreatePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceGetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() // invoke the operation string privateEndpointConnectionName = "myConnection"; - HealthcareApisPrivateEndpointConnectionData data = new HealthcareApisPrivateEndpointConnectionData() - { - ConnectionState = new HealthcareApisPrivateLinkServiceConnectionState() - { - Status = HealthcareApisPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - HealthcareApisServicePrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + HealthcareApisServicePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateEndpointConnectionResource.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateEndpointConnectionResource.cs index 17c8ae9b9347d..11d01e4e2d2f7 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateEndpointConnectionResource.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionGetConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionCreateOrUpdate() + public async Task Delete_PrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceCreatePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceDeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_PrivateEndpointConnectionCreateOrUpdate() HealthcareApisServicePrivateEndpointConnectionResource healthcareApisServicePrivateEndpointConnection = client.GetHealthcareApisServicePrivateEndpointConnectionResource(healthcareApisServicePrivateEndpointConnectionResourceId); // invoke the operation - HealthcareApisPrivateEndpointConnectionData data = new HealthcareApisPrivateEndpointConnectionData() - { - ConnectionState = new HealthcareApisPrivateLinkServiceConnectionState() - { - Status = HealthcareApisPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await healthcareApisServicePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - HealthcareApisServicePrivateEndpointConnectionResource result = lro.Value; + await healthcareApisServicePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDelete() + public async Task Update_PrivateEndpointConnectionCreateOrUpdate() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceDeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceCreatePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_PrivateEndpointConnectionsDelete() HealthcareApisServicePrivateEndpointConnectionResource healthcareApisServicePrivateEndpointConnection = client.GetHealthcareApisServicePrivateEndpointConnectionResource(healthcareApisServicePrivateEndpointConnectionResourceId); // invoke the operation - await healthcareApisServicePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + HealthcareApisPrivateEndpointConnectionData data = new HealthcareApisPrivateEndpointConnectionData + { + ConnectionState = new HealthcareApisPrivateLinkServiceConnectionState + { + Status = HealthcareApisPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await healthcareApisServicePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + HealthcareApisServicePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateLinkResourceCollection.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateLinkResourceCollection.cs index 8fd104a367ee8..129eb93f5663e 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateLinkResourceCollection.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServicePrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HealthcareApisServicePrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesListGroupIds() + public async Task Get_PrivateLinkResourcesGet() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/PrivateLinkResourcesListByService.json - // this example is just showing the usage of "PrivateLinkResources_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/PrivateLinkResourceGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_PrivateLinkResourcesListGroupIds() // get the collection of this HealthcareApisServicePrivateLinkResource HealthcareApisServicePrivateLinkResourceCollection collection = healthcareApisService.GetHealthcareApisServicePrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (HealthcareApisServicePrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "fhir"; + HealthcareApisServicePrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkResourcesGet() + public async Task GetAll_PrivateLinkResourcesListGroupIds() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/PrivateLinkResourceGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/PrivateLinkResourcesListByService.json + // this example is just showing the usage of "PrivateLinkResources_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_PrivateLinkResourcesGet() // get the collection of this HealthcareApisServicePrivateLinkResource HealthcareApisServicePrivateLinkResourceCollection collection = healthcareApisService.GetHealthcareApisServicePrivateLinkResources(); - // invoke the operation - string groupName = "fhir"; - HealthcareApisServicePrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (HealthcareApisServicePrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServiceResource.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServiceResource.cs index 120e76898ab06..7627919231d82 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServiceResource.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HealthcareApis.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HealthcareApis.Samples @@ -79,10 +78,10 @@ public async Task Get_GetMetadataForCMKEnabledServiceInDataSovereignRegion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchService() + public async Task Delete_DeleteService() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServicePatch.json - // this example is just showing the usage of "Services_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceDelete.json + // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,30 +97,17 @@ public async Task Update_PatchService() HealthcareApisServiceResource healthcareApisService = client.GetHealthcareApisServiceResource(healthcareApisServiceResourceId); // invoke the operation - HealthcareApisServicePatch patch = new HealthcareApisServicePatch() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await healthcareApisService.UpdateAsync(WaitUntil.Completed, patch); - HealthcareApisServiceResource result = lro.Value; + await healthcareApisService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteService() + public async Task Update_PatchService() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceDelete.json - // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServicePatch.json + // this example is just showing the usage of "Services_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,65 +123,22 @@ public async Task Delete_DeleteService() HealthcareApisServiceResource healthcareApisService = client.GetHealthcareApisServiceResource(healthcareApisServiceResourceId); // invoke the operation - await healthcareApisService.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetHealthcareApisServices_ListAllServicesInSubscription() - { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceList.json - // this example is just showing the usage of "Services_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (HealthcareApisServiceResource item in subscriptionResource.GetHealthcareApisServicesAsync()) + HealthcareApisServicePatch patch = new HealthcareApisServicePatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckHealthcareApisNameAvailability_CheckNameAvailability() - { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/CheckNameAvailabilityPost.json - // this example is just showing the usage of "Services_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - HealthcareApisNameAvailabilityContent content = new HealthcareApisNameAvailabilityContent("serviceName", new ResourceType("Microsoft.HealthcareApis/services")); - HealthcareApisNameAvailabilityResult result = await subscriptionResource.CheckHealthcareApisNameAvailabilityAsync(content); + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await healthcareApisService.UpdateAsync(WaitUntil.Completed, patch); + HealthcareApisServiceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspaceCollection.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspaceCollection.cs index c32423630729a..531724440e6b2 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspaceCollection.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspaceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_HealthcareApisWorkspaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetWorkspacesByResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateAWorkspace() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_ListByResourceGroup.json - // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_Create.json + // this example is just showing the usage of "Workspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_GetWorkspacesByResourceGroup() // get the collection of this HealthcareApisWorkspaceResource HealthcareApisWorkspaceCollection collection = resourceGroupResource.GetHealthcareApisWorkspaces(); - // invoke the operation and iterate over the result - await foreach (HealthcareApisWorkspaceResource item in collection.GetAllAsync()) + // invoke the operation + string workspaceName = "workspace1"; + HealthcareApisWorkspaceData data = new HealthcareApisWorkspaceData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new HealthcareApisWorkspaceProperties(), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); + HealthcareApisWorkspaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspace() + public async Task GetAll_GetWorkspacesByResourceGroup() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_Get.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_ListByResourceGroup.json + // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +110,22 @@ public async Task Exists_GetWorkspace() // get the collection of this HealthcareApisWorkspaceResource HealthcareApisWorkspaceCollection collection = resourceGroupResource.GetHealthcareApisWorkspaces(); - // invoke the operation - string workspaceName = "workspace1"; - bool result = await collection.ExistsAsync(workspaceName); + // invoke the operation and iterate over the result + await foreach (HealthcareApisWorkspaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspace() + public async Task Exists_GetWorkspace() { // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_Get.json // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +147,17 @@ public async Task GetIfExists_GetWorkspace() // invoke the operation string workspaceName = "workspace1"; - NullableResponse response = await collection.GetIfExistsAsync(workspaceName); - HealthcareApisWorkspaceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(workspaceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAWorkspace() + public async Task GetIfExists_GetWorkspace() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_Create.json - // this example is just showing the usage of "Workspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_Get.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,18 +176,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAWorkspace() // invoke the operation string workspaceName = "workspace1"; - HealthcareApisWorkspaceData data = new HealthcareApisWorkspaceData(new AzureLocation("westus")) - { - Properties = new HealthcareApisWorkspaceProperties(), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); - HealthcareApisWorkspaceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(workspaceName); + HealthcareApisWorkspaceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateEndpointConnectionCollection.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateEndpointConnectionCollection.cs index 09418cf302cdf..4051cb0d5fbe1 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateEndpointConnectionCollection.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HealthcareApisWorkspacePrivateEndpointConnectionColl { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkspacePrivateEndpointConnectionList() + public async Task CreateOrUpdate_WorkspacePrivateEndpointConnectionCreateOrUpdate() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceListPrivateEndpointConnections.json - // this example is just showing the usage of "WorkspacePrivateEndpointConnections_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceCreatePrivateEndpointConnection.json + // this example is just showing the usage of "WorkspacePrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_WorkspacePrivateEndpointConnectionList() // get the collection of this HealthcareApisWorkspacePrivateEndpointConnectionResource HealthcareApisWorkspacePrivateEndpointConnectionCollection collection = healthcareApisWorkspace.GetHealthcareApisWorkspacePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (HealthcareApisWorkspacePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "myConnection"; + HealthcareApisPrivateEndpointConnectionData data = new HealthcareApisPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new HealthcareApisPrivateLinkServiceConnectionState + { + Status = HealthcareApisPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + HealthcareApisWorkspacePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_WorkspacePrivateEndpointConnectionGetConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkspacePrivateEndpointConnectionGetConnection() + public async Task GetAll_WorkspacePrivateEndpointConnectionList() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceGetPrivateEndpointConnection.json - // this example is just showing the usage of "WorkspacePrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceListPrivateEndpointConnections.json + // this example is just showing the usage of "WorkspacePrivateEndpointConnections_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_WorkspacePrivateEndpointConnectionGetConnection() // get the collection of this HealthcareApisWorkspacePrivateEndpointConnectionResource HealthcareApisWorkspacePrivateEndpointConnectionCollection collection = healthcareApisWorkspace.GetHealthcareApisWorkspacePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "myConnection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (HealthcareApisWorkspacePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkspacePrivateEndpointConnectionGetConnection() + public async Task Exists_WorkspacePrivateEndpointConnectionGetConnection() { // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceGetPrivateEndpointConnection.json // this example is just showing the usage of "WorkspacePrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_WorkspacePrivateEndpointConnectionGetConnection() // invoke the operation string privateEndpointConnectionName = "myConnection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - HealthcareApisWorkspacePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkspacePrivateEndpointConnectionCreateOrUpdate() + public async Task GetIfExists_WorkspacePrivateEndpointConnectionGetConnection() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceCreatePrivateEndpointConnection.json - // this example is just showing the usage of "WorkspacePrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceGetPrivateEndpointConnection.json + // this example is just showing the usage of "WorkspacePrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_WorkspacePrivateEndpointConnectionCreateOrUpdat // invoke the operation string privateEndpointConnectionName = "myConnection"; - HealthcareApisPrivateEndpointConnectionData data = new HealthcareApisPrivateEndpointConnectionData() - { - ConnectionState = new HealthcareApisPrivateLinkServiceConnectionState() - { - Status = HealthcareApisPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - HealthcareApisWorkspacePrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + HealthcareApisWorkspacePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateEndpointConnectionResource.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateEndpointConnectionResource.cs index c1aeb4c8fd19a..f16090ee61db5 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateEndpointConnectionResource.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_WorkspacePrivateEndpointConnectionGetConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WorkspacePrivateEndpointConnectionCreateOrUpdate() + public async Task Delete_WorkspacePrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceCreatePrivateEndpointConnection.json - // this example is just showing the usage of "WorkspacePrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceDeletePrivateEndpointConnection.json + // this example is just showing the usage of "WorkspacePrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_WorkspacePrivateEndpointConnectionCreateOrUpdate() HealthcareApisWorkspacePrivateEndpointConnectionResource healthcareApisWorkspacePrivateEndpointConnection = client.GetHealthcareApisWorkspacePrivateEndpointConnectionResource(healthcareApisWorkspacePrivateEndpointConnectionResourceId); // invoke the operation - HealthcareApisPrivateEndpointConnectionData data = new HealthcareApisPrivateEndpointConnectionData() - { - ConnectionState = new HealthcareApisPrivateLinkServiceConnectionState() - { - Status = HealthcareApisPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await healthcareApisWorkspacePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - HealthcareApisWorkspacePrivateEndpointConnectionResource result = lro.Value; + await healthcareApisWorkspacePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WorkspacePrivateEndpointConnectionsDelete() + public async Task Update_WorkspacePrivateEndpointConnectionCreateOrUpdate() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceDeletePrivateEndpointConnection.json - // this example is just showing the usage of "WorkspacePrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspaceCreatePrivateEndpointConnection.json + // this example is just showing the usage of "WorkspacePrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_WorkspacePrivateEndpointConnectionsDelete() HealthcareApisWorkspacePrivateEndpointConnectionResource healthcareApisWorkspacePrivateEndpointConnection = client.GetHealthcareApisWorkspacePrivateEndpointConnectionResource(healthcareApisWorkspacePrivateEndpointConnectionResourceId); // invoke the operation - await healthcareApisWorkspacePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + HealthcareApisPrivateEndpointConnectionData data = new HealthcareApisPrivateEndpointConnectionData + { + ConnectionState = new HealthcareApisPrivateLinkServiceConnectionState + { + Status = HealthcareApisPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await healthcareApisWorkspacePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + HealthcareApisWorkspacePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateLinkResourceCollection.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateLinkResourceCollection.cs index a67fc5a459769..08e20f1c64c2f 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateLinkResourceCollection.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspacePrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HealthcareApisWorkspacePrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkspacePrivateLinkResourcesListGroupIds() + public async Task Get_WorkspacePrivateLinkResourcesGet() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/PrivateLinkResourcesListByWorkspace.json - // this example is just showing the usage of "WorkspacePrivateLinkResources_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspacePrivateLinkResourceGet.json + // this example is just showing the usage of "WorkspacePrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_WorkspacePrivateLinkResourcesListGroupIds() // get the collection of this HealthcareApisWorkspacePrivateLinkResource HealthcareApisWorkspacePrivateLinkResourceCollection collection = healthcareApisWorkspace.GetHealthcareApisWorkspacePrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (HealthcareApisWorkspacePrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "healthcareworkspace"; + HealthcareApisWorkspacePrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkspacePrivateLinkResourcesGet() + public async Task GetAll_WorkspacePrivateLinkResourcesListGroupIds() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/WorkspacePrivateLinkResourceGet.json - // this example is just showing the usage of "WorkspacePrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/privatelink/PrivateLinkResourcesListByWorkspace.json + // this example is just showing the usage of "WorkspacePrivateLinkResources_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_WorkspacePrivateLinkResourcesGet() // get the collection of this HealthcareApisWorkspacePrivateLinkResource HealthcareApisWorkspacePrivateLinkResourceCollection collection = healthcareApisWorkspace.GetHealthcareApisWorkspacePrivateLinkResources(); - // invoke the operation - string groupName = "healthcareworkspace"; - HealthcareApisWorkspacePrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (HealthcareApisWorkspacePrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspaceResource.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspaceResource.cs index 9013b39c38c81..eff838a8b2e18 100644 --- a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspaceResource.cs +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_HealthcareApisWorkspaceResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HealthcareApis.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HealthcareApis.Samples { public partial class Sample_HealthcareApisWorkspaceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetHealthcareApisWorkspaces_GetWorkspacesBySubscription() - { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_ListBySubscription.json - // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (HealthcareApisWorkspaceResource item in subscriptionResource.GetHealthcareApisWorkspacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetWorkspace() @@ -80,10 +48,10 @@ public async Task Get_GetWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAWorkspace() + public async Task Delete_DeleteAWorkspace() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_Patch.json - // this example is just showing the usage of "Workspaces_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_Delete.json + // this example is just showing the usage of "Workspaces_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,29 +67,17 @@ public async Task Update_UpdateAWorkspace() HealthcareApisWorkspaceResource healthcareApisWorkspace = client.GetHealthcareApisWorkspaceResource(healthcareApisWorkspaceResourceId); // invoke the operation - HealthcareApisWorkspacePatch patch = new HealthcareApisWorkspacePatch() - { - Tags = -{ -["tagKey"] = "tagValue", -}, - }; - ArmOperation lro = await healthcareApisWorkspace.UpdateAsync(WaitUntil.Completed, patch); - HealthcareApisWorkspaceResource result = lro.Value; + await healthcareApisWorkspace.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthcareApisWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAWorkspace() + public async Task Update_UpdateAWorkspace() { - // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_Delete.json - // this example is just showing the usage of "Workspaces_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_Patch.json + // this example is just showing the usage of "Workspaces_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,9 +93,21 @@ public async Task Delete_DeleteAWorkspace() HealthcareApisWorkspaceResource healthcareApisWorkspace = client.GetHealthcareApisWorkspaceResource(healthcareApisWorkspaceResourceId); // invoke the operation - await healthcareApisWorkspace.DeleteAsync(WaitUntil.Completed); + HealthcareApisWorkspacePatch patch = new HealthcareApisWorkspacePatch + { + Tags = +{ +["tagKey"] = "tagValue" +}, + }; + ArmOperation lro = await healthcareApisWorkspace.UpdateAsync(WaitUntil.Completed, patch); + HealthcareApisWorkspaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..18f83faa3eae9 --- /dev/null +++ b/sdk/healthcareapis/Azure.ResourceManager.HealthcareApis/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.HealthcareApis.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.HealthcareApis.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHealthcareApisServices_ListAllServicesInSubscription() + { + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/legacy/ServiceList.json + // this example is just showing the usage of "Services_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HealthcareApisServiceResource item in subscriptionResource.GetHealthcareApisServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckHealthcareApisNameAvailability_CheckNameAvailability() + { + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/CheckNameAvailabilityPost.json + // this example is just showing the usage of "Services_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + HealthcareApisNameAvailabilityContent content = new HealthcareApisNameAvailabilityContent("serviceName", new ResourceType("Microsoft.HealthcareApis/services")); + HealthcareApisNameAvailabilityResult result = await subscriptionResource.CheckHealthcareApisNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHealthcareApisWorkspaces_GetWorkspacesBySubscription() + { + // Generated from example definition: specification/healthcareapis/resource-manager/Microsoft.HealthcareApis/stable/2024-03-31/examples/workspaces/Workspaces_ListBySubscription.json + // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HealthcareApisWorkspaceResource item in subscriptionResource.GetHealthcareApisWorkspacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthcareApisWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_DeidServiceCollection.cs b/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_DeidServiceCollection.cs index 54cce2c1dba2c..4195ef6148b7c 100644 --- a/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_DeidServiceCollection.cs +++ b/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_DeidServiceCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_DeidServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DeidServicesGetGeneratedByMaximumSetRuleStable() + public async Task CreateOrUpdate_DeidServicesCreateGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/DeidServices_Get_MaximumSet_Gen.json - // this example is just showing the usage of "DeidService_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/DeidServices_Create_MaximumSet_Gen.json + // this example is just showing the usage of "DeidService_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,20 @@ public async Task Get_DeidServicesGetGeneratedByMaximumSetRuleStable() // invoke the operation string deidServiceName = "deidTest"; - DeidServiceResource result = await collection.GetAsync(deidServiceName); + DeidServiceData data = new DeidServiceData(new AzureLocation("qwyhvdwcsjulggagdqxlmazcl")) + { + Properties = new DeidServiceProperties + { + PublicNetworkAccess = HealthDataAIServicesPublicNetworkAccess.Enabled, + }, + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = { }, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deidServiceName, data); + DeidServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +66,7 @@ public async Task Get_DeidServicesGetGeneratedByMaximumSetRuleStable() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DeidServicesGetGeneratedByMaximumSetRuleStable() + public async Task Get_DeidServicesGetGeneratedByMaximumSetRuleStable() { // Generated from example definition: 2024-09-20/DeidServices_Get_MaximumSet_Gen.json // this example is just showing the usage of "DeidService_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +88,21 @@ public async Task Exists_DeidServicesGetGeneratedByMaximumSetRuleStable() // invoke the operation string deidServiceName = "deidTest"; - bool result = await collection.ExistsAsync(deidServiceName); + DeidServiceResource result = await collection.GetAsync(deidServiceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeidServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DeidServicesGetGeneratedByMaximumSetRuleStable() + public async Task GetAll_DeidServicesListByResourceGroupGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/DeidServices_Get_MaximumSet_Gen.json - // this example is just showing the usage of "DeidService_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/DeidServices_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "DeidService_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +119,25 @@ public async Task GetIfExists_DeidServicesGetGeneratedByMaximumSetRuleStable() // get the collection of this DeidServiceResource DeidServiceCollection collection = resourceGroupResource.GetDeidServices(); - // invoke the operation - string deidServiceName = "deidTest"; - NullableResponse response = await collection.GetIfExistsAsync(deidServiceName); - DeidServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DeidServiceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DeidServiceData resourceData = result.Data; + DeidServiceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DeidServicesListByResourceGroupGeneratedByMaximumSetRuleStable() + public async Task Exists_DeidServicesGetGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/DeidServices_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "DeidService_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/DeidServices_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DeidService_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,25 +154,19 @@ public async Task GetAll_DeidServicesListByResourceGroupGeneratedByMaximumSetRul // get the collection of this DeidServiceResource DeidServiceCollection collection = resourceGroupResource.GetDeidServices(); - // invoke the operation and iterate over the result - await foreach (DeidServiceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeidServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string deidServiceName = "deidTest"; + bool result = await collection.ExistsAsync(deidServiceName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DeidServicesCreateGeneratedByMaximumSetRuleStable() + public async Task GetIfExists_DeidServicesGetGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/DeidServices_Create_MaximumSet_Gen.json - // this example is just showing the usage of "DeidService_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/DeidServices_Get_MaximumSet_Gen.json + // this example is just showing the usage of "DeidService_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,30 +185,21 @@ public async Task CreateOrUpdate_DeidServicesCreateGeneratedByMaximumSetRuleStab // invoke the operation string deidServiceName = "deidTest"; - DeidServiceData data = new DeidServiceData(new AzureLocation("qwyhvdwcsjulggagdqxlmazcl")) - { - Properties = new DeidServiceProperties() - { - PublicNetworkAccess = HealthDataAIServicesPublicNetworkAccess.Enabled, - }, - Identity = new ManagedServiceIdentity("None") - { - UserAssignedIdentities = -{ -}, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deidServiceName, data); - DeidServiceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(deidServiceName); + DeidServiceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeidServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeidServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_DeidServiceResource.cs b/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_DeidServiceResource.cs index 94115d9e78443..d145c5c32b782 100644 --- a/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_DeidServiceResource.cs +++ b/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_DeidServiceResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.HealthDataAIServices.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HealthDataAIServices.Samples @@ -50,31 +49,26 @@ public async Task Get_DeidServicesGetGeneratedByMaximumSetRuleStable() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDeidServices_DeidServicesListBySubscriptionGeneratedByMaximumSetRuleStable() + public async Task Delete_DeidServicesDeleteGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/DeidServices_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "DeidService_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/DeidServices_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "DeidService_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this DeidServiceResource created on azure + // for more information of creating DeidServiceResource, please refer to the document of DeidServiceResource string subscriptionId = "F21BB31B-C214-42C0-ACF0-DACCA05D3011"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rgopenapi"; + string deidServiceName = "deidTest"; + ResourceIdentifier deidServiceResourceId = DeidServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, deidServiceName); + DeidServiceResource deidService = client.GetDeidServiceResource(deidServiceResourceId); - // invoke the operation and iterate over the result - await foreach (DeidServiceResource item in subscriptionResource.GetDeidServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeidServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + await deidService.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } @@ -100,12 +94,10 @@ public async Task Update_DeidServicesUpdateGeneratedByMaximumSetRuleStable() DeidServiceResource deidService = client.GetDeidServiceResource(deidServiceResourceId); // invoke the operation - DeidServicePatch patch = new DeidServicePatch() + DeidServicePatch patch = new DeidServicePatch { - Tags = -{ -}, - Identity = new ManagedServiceIdentity(default), + Tags = { }, + Identity = (ManagedServiceIdentity)null, DeidPropertiesUpdatePublicNetworkAccess = HealthDataAIServicesPublicNetworkAccess.Enabled, }; ArmOperation lro = await deidService.UpdateAsync(WaitUntil.Completed, patch); @@ -118,32 +110,6 @@ public async Task Update_DeidServicesUpdateGeneratedByMaximumSetRuleStable() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeidServicesDeleteGeneratedByMaximumSetRuleStable() - { - // Generated from example definition: 2024-09-20/DeidServices_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "DeidService_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DeidServiceResource created on azure - // for more information of creating DeidServiceResource, please refer to the document of DeidServiceResource - string subscriptionId = "F21BB31B-C214-42C0-ACF0-DACCA05D3011"; - string resourceGroupName = "rgopenapi"; - string deidServiceName = "deidTest"; - ResourceIdentifier deidServiceResourceId = DeidServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, deidServiceName); - DeidServiceResource deidService = client.GetDeidServiceResource(deidServiceResourceId); - - // invoke the operation - await deidService.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetPrivateLinks_PrivateLinksListByDeidServiceGeneratedByMaximumSetRuleStable() diff --git a/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_HealthDataAIServicesPrivateEndpointConnectionResource.cs b/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_HealthDataAIServicesPrivateEndpointConnectionResource.cs index 7225742aeed69..31d79e20f3824 100644 --- a/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_HealthDataAIServicesPrivateEndpointConnectionResource.cs +++ b/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_HealthDataAIServicesPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionsGetGeneratedByMaximumSetRuleStab [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsCreateGeneratedByMaximumSetRuleStable() + public async Task Delete_PrivateEndpointConnectionsDeleteGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Create_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,17 @@ public async Task Update_PrivateEndpointConnectionsCreateGeneratedByMaximumSetRu HealthDataAIServicesPrivateEndpointConnectionResource healthDataAIServicesPrivateEndpointConnectionResource = client.GetHealthDataAIServicesPrivateEndpointConnectionResource(healthDataAIServicesPrivateEndpointConnectionResourceId); // invoke the operation - HealthDataAIServicesPrivateEndpointConnectionResourceData data = new HealthDataAIServicesPrivateEndpointConnectionResourceData() - { - Properties = new PrivateEndpointConnectionProperties(new HealthDataAIServicesPrivateLinkServiceConnectionState() - { - Status = HealthDataAIServicesPrivateEndpointServiceConnectionStatus.Pending, - Description = "xr", - ActionsRequired = "ulb", - }), - }; - ArmOperation lro = await healthDataAIServicesPrivateEndpointConnectionResource.UpdateAsync(WaitUntil.Completed, data); - HealthDataAIServicesPrivateEndpointConnectionResource result = lro.Value; + await healthDataAIServicesPrivateEndpointConnectionResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthDataAIServicesPrivateEndpointConnectionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDeleteGeneratedByMaximumSetRuleStable() + public async Task Update_PrivateEndpointConnectionsCreateGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Create_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +96,23 @@ public async Task Delete_PrivateEndpointConnectionsDeleteGeneratedByMaximumSetRu HealthDataAIServicesPrivateEndpointConnectionResource healthDataAIServicesPrivateEndpointConnectionResource = client.GetHealthDataAIServicesPrivateEndpointConnectionResource(healthDataAIServicesPrivateEndpointConnectionResourceId); // invoke the operation - await healthDataAIServicesPrivateEndpointConnectionResource.DeleteAsync(WaitUntil.Completed); + HealthDataAIServicesPrivateEndpointConnectionResourceData data = new HealthDataAIServicesPrivateEndpointConnectionResourceData + { + Properties = new PrivateEndpointConnectionProperties(new HealthDataAIServicesPrivateLinkServiceConnectionState + { + Status = HealthDataAIServicesPrivateEndpointServiceConnectionStatus.Pending, + Description = "xr", + ActionsRequired = "ulb", + }), + }; + ArmOperation lro = await healthDataAIServicesPrivateEndpointConnectionResource.UpdateAsync(WaitUntil.Completed, data); + HealthDataAIServicesPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthDataAIServicesPrivateEndpointConnectionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_HealthDataAIServicesPrivateEndpointConnectionResourceCollection.cs b/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_HealthDataAIServicesPrivateEndpointConnectionResourceCollection.cs index ae72e8cfe08df..61db6da5fbf59 100644 --- a/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_HealthDataAIServicesPrivateEndpointConnectionResourceCollection.cs +++ b/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_HealthDataAIServicesPrivateEndpointConnectionResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HealthDataAIServicesPrivateEndpointConnectionResourc { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGetGeneratedByMaximumSetRuleStable() + public async Task CreateOrUpdate_PrivateEndpointConnectionsCreateGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Get_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Create_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_PrivateEndpointConnectionsGetGeneratedByMaximumSetRuleStab // invoke the operation string privateEndpointConnectionName = "kgwgrrpabvrsrrvpcgcnfmyfgyrl"; - HealthDataAIServicesPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + HealthDataAIServicesPrivateEndpointConnectionResourceData data = new HealthDataAIServicesPrivateEndpointConnectionResourceData + { + Properties = new PrivateEndpointConnectionProperties(new HealthDataAIServicesPrivateLinkServiceConnectionState + { + Status = HealthDataAIServicesPrivateEndpointServiceConnectionStatus.Pending, + Description = "xr", + ActionsRequired = "ulb", + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + HealthDataAIServicesPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +62,7 @@ public async Task Get_PrivateEndpointConnectionsGetGeneratedByMaximumSetRuleStab [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGetGeneratedByMaximumSetRuleStable() + public async Task Get_PrivateEndpointConnectionsGetGeneratedByMaximumSetRuleStable() { // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Get_MaximumSet_Gen.json // this example is just showing the usage of "PrivateEndpointConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +85,21 @@ public async Task Exists_PrivateEndpointConnectionsGetGeneratedByMaximumSetRuleS // invoke the operation string privateEndpointConnectionName = "kgwgrrpabvrsrrvpcgcnfmyfgyrl"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + HealthDataAIServicesPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthDataAIServicesPrivateEndpointConnectionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGetGeneratedByMaximumSetRuleStable() + public async Task GetAll_PrivateEndpointConnectionsListByDeidServiceGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Get_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/PrivateEndpointConnections_ListByDeidService_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_ListByDeidService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +117,25 @@ public async Task GetIfExists_PrivateEndpointConnectionsGetGeneratedByMaximumSet // get the collection of this HealthDataAIServicesPrivateEndpointConnectionResource HealthDataAIServicesPrivateEndpointConnectionResourceCollection collection = deidService.GetHealthDataAIServicesPrivateEndpointConnectionResources(); - // invoke the operation - string privateEndpointConnectionName = "kgwgrrpabvrsrrvpcgcnfmyfgyrl"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - HealthDataAIServicesPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HealthDataAIServicesPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HealthDataAIServicesPrivateEndpointConnectionResourceData resourceData = result.Data; + HealthDataAIServicesPrivateEndpointConnectionResourceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionsCreateGeneratedByMaximumSetRuleStable() + public async Task Exists_PrivateEndpointConnectionsGetGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Create_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,31 +155,17 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsCreateGeneratedByMaxi // invoke the operation string privateEndpointConnectionName = "kgwgrrpabvrsrrvpcgcnfmyfgyrl"; - HealthDataAIServicesPrivateEndpointConnectionResourceData data = new HealthDataAIServicesPrivateEndpointConnectionResourceData() - { - Properties = new PrivateEndpointConnectionProperties(new HealthDataAIServicesPrivateLinkServiceConnectionState() - { - Status = HealthDataAIServicesPrivateEndpointServiceConnectionStatus.Pending, - Description = "xr", - ActionsRequired = "ulb", - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - HealthDataAIServicesPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthDataAIServicesPrivateEndpointConnectionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsListByDeidServiceGeneratedByMaximumSetRuleStable() + public async Task GetIfExists_PrivateEndpointConnectionsGetGeneratedByMaximumSetRuleStable() { - // Generated from example definition: 2024-09-20/PrivateEndpointConnections_ListByDeidService_MaximumSet_Gen.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_ListByDeidService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-09-20/PrivateEndpointConnections_Get_MaximumSet_Gen.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_PrivateEndpointConnectionsListByDeidServiceGeneratedByM // get the collection of this HealthDataAIServicesPrivateEndpointConnectionResource HealthDataAIServicesPrivateEndpointConnectionResourceCollection collection = deidService.GetHealthDataAIServicesPrivateEndpointConnectionResources(); - // invoke the operation and iterate over the result - await foreach (HealthDataAIServicesPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "kgwgrrpabvrsrrvpcgcnfmyfgyrl"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + HealthDataAIServicesPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HealthDataAIServicesPrivateEndpointConnectionResourceData resourceData = item.Data; + HealthDataAIServicesPrivateEndpointConnectionResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..ce8336d071876 --- /dev/null +++ b/sdk/healthdataaiservices/Azure.ResourceManager.HealthDataAIServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.HealthDataAIServices.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeidServices_DeidServicesListBySubscriptionGeneratedByMaximumSetRuleStable() + { + // Generated from example definition: 2024-09-20/DeidServices_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "DeidService_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "F21BB31B-C214-42C0-ACF0-DACCA05D3011"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeidServiceResource item in subscriptionResource.GetDeidServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeidServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceAgentPoolCollection.cs b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceAgentPoolCollection.cs index 3146b74fa0bb6..ab435ee75554e 100644 --- a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceAgentPoolCollection.cs +++ b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceAgentPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HybridContainerServiceAgentPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAgentPool() + public async Task CreateOrUpdate_PutAgentPool() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetAgentPool.json - // this example is just showing the usage of "agentPool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/PutAgentPool.json + // this example is just showing the usage of "agentPool_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,7 +39,20 @@ public async Task Get_GetAgentPool() // invoke the operation string agentPoolName = "testnodepool"; - HybridContainerServiceAgentPoolResource result = await collection.GetAsync(agentPoolName); + HybridContainerServiceAgentPoolData data = new HybridContainerServiceAgentPoolData + { + OSType = HybridContainerServiceOSType.Linux, + NodeLabels = +{ +["env"] = "dev", +["goal"] = "test" +}, + NodeTaints = { "env=prod:NoSchedule", "sku=gpu:NoSchedule" }, + Count = 1, + VmSize = "Standard_A4_v2", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + HybridContainerServiceAgentPoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,7 +63,7 @@ public async Task Get_GetAgentPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAgentPool() + public async Task Get_GetAgentPool() { // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetAgentPool.json // this example is just showing the usage of "agentPool_Get" operation, for the dependent resources, they will have to be created separately. @@ -71,17 +84,21 @@ public async Task Exists_GetAgentPool() // invoke the operation string agentPoolName = "testnodepool"; - bool result = await collection.ExistsAsync(agentPoolName); + HybridContainerServiceAgentPoolResource result = await collection.GetAsync(agentPoolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAgentPool() + public async Task GetAll_ListAgentPoolByProvisionedClusterInstance() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetAgentPool.json - // this example is just showing the usage of "agentPool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/ListAgentPoolByProvisionedClusterInstance.json + // this example is just showing the usage of "agentPool_ListByProvisionedCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,31 +114,25 @@ public async Task GetIfExists_GetAgentPool() // get the collection of this HybridContainerServiceAgentPoolResource HybridContainerServiceAgentPoolCollection collection = provisionedCluster.GetHybridContainerServiceAgentPools(); - // invoke the operation - string agentPoolName = "testnodepool"; - NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); - HybridContainerServiceAgentPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HybridContainerServiceAgentPoolResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridContainerServiceAgentPoolData resourceData = result.Data; + HybridContainerServiceAgentPoolData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAgentPool() + public async Task Exists_GetAgentPool() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/PutAgentPool.json - // this example is just showing the usage of "agentPool_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetAgentPool.json + // this example is just showing the usage of "agentPool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,37 +150,17 @@ public async Task CreateOrUpdate_PutAgentPool() // invoke the operation string agentPoolName = "testnodepool"; - HybridContainerServiceAgentPoolData data = new HybridContainerServiceAgentPoolData() - { - OSType = HybridContainerServiceOSType.Linux, - NodeLabels = -{ -["env"] = "dev", -["goal"] = "test", -}, - NodeTaints = -{ -"env=prod:NoSchedule","sku=gpu:NoSchedule" -}, - Count = 1, - VmSize = "Standard_A4_v2", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); - HybridContainerServiceAgentPoolResource result = lro.Value; + bool result = await collection.ExistsAsync(agentPoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridContainerServiceAgentPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAgentPoolByProvisionedClusterInstance() + public async Task GetIfExists_GetAgentPool() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/ListAgentPoolByProvisionedClusterInstance.json - // this example is just showing the usage of "agentPool_ListByProvisionedCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetAgentPool.json + // this example is just showing the usage of "agentPool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +176,23 @@ public async Task GetAll_ListAgentPoolByProvisionedClusterInstance() // get the collection of this HybridContainerServiceAgentPoolResource HybridContainerServiceAgentPoolCollection collection = provisionedCluster.GetHybridContainerServiceAgentPools(); - // invoke the operation and iterate over the result - await foreach (HybridContainerServiceAgentPoolResource item in collection.GetAllAsync()) + // invoke the operation + string agentPoolName = "testnodepool"; + NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); + HybridContainerServiceAgentPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridContainerServiceAgentPoolData resourceData = item.Data; + HybridContainerServiceAgentPoolData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceAgentPoolResource.cs b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceAgentPoolResource.cs index 39235f7a2746d..b5e009cd84ae0 100644 --- a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceAgentPoolResource.cs +++ b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceAgentPoolResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetAgentPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutAgentPool() + public async Task Delete_DeleteAgentPool() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/PutAgentPool.json - // this example is just showing the usage of "agentPool_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/DeleteAgentPool.json + // this example is just showing the usage of "agentPool_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,37 +65,17 @@ public async Task Update_PutAgentPool() HybridContainerServiceAgentPoolResource hybridContainerServiceAgentPool = client.GetHybridContainerServiceAgentPoolResource(hybridContainerServiceAgentPoolResourceId); // invoke the operation - HybridContainerServiceAgentPoolData data = new HybridContainerServiceAgentPoolData() - { - OSType = HybridContainerServiceOSType.Linux, - NodeLabels = -{ -["env"] = "dev", -["goal"] = "test", -}, - NodeTaints = -{ -"env=prod:NoSchedule","sku=gpu:NoSchedule" -}, - Count = 1, - VmSize = "Standard_A4_v2", - }; - ArmOperation lro = await hybridContainerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); - HybridContainerServiceAgentPoolResource result = lro.Value; + await hybridContainerServiceAgentPool.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridContainerServiceAgentPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAgentPool() + public async Task Update_PutAgentPool() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/DeleteAgentPool.json - // this example is just showing the usage of "agentPool_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/PutAgentPool.json + // this example is just showing the usage of "agentPool_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +90,26 @@ public async Task Delete_DeleteAgentPool() HybridContainerServiceAgentPoolResource hybridContainerServiceAgentPool = client.GetHybridContainerServiceAgentPoolResource(hybridContainerServiceAgentPoolResourceId); // invoke the operation - await hybridContainerServiceAgentPool.DeleteAsync(WaitUntil.Completed); + HybridContainerServiceAgentPoolData data = new HybridContainerServiceAgentPoolData + { + OSType = HybridContainerServiceOSType.Linux, + NodeLabels = +{ +["env"] = "dev", +["goal"] = "test" +}, + NodeTaints = { "env=prod:NoSchedule", "sku=gpu:NoSchedule" }, + Count = 1, + VmSize = "Standard_A4_v2", + }; + ArmOperation lro = await hybridContainerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); + HybridContainerServiceAgentPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVirtualNetworkCollection.cs b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVirtualNetworkCollection.cs index 8d3f0d4946e44..1ed483fdb623f 100644 --- a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVirtualNetworkCollection.cs +++ b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVirtualNetworkCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_HybridContainerServiceVirtualNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetwork() + public async Task CreateOrUpdate_PutVirtualNetwork() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetVirtualNetwork.json - // this example is just showing the usage of "virtualNetworks_Retrieve" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/PutVirtualNetwork.json + // this example is just showing the usage of "virtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,39 @@ public async Task Get_GetVirtualNetwork() // invoke the operation string virtualNetworkName = "test-vnet-static"; - HybridContainerServiceVirtualNetworkResource result = await collection.GetAsync(virtualNetworkName); + HybridContainerServiceVirtualNetworkData data = new HybridContainerServiceVirtualNetworkData(new AzureLocation("westus")) + { + Properties = new HybridContainerServiceVirtualNetworkProperties + { + InfraVnetHci = new HciInfraVnetProfile + { + MocGroup = "target-group", + MocLocation = "MocLocation", + MocVnetName = "vnet1", + }, + VipPool = {new KubernetesVirtualIPItem +{ +EndIP = "192.168.0.50", +StartIP = "192.168.0.10", +}}, + VmipPool = {new VirtualMachineIPItem +{ +EndIP = "192.168.0.130", +StartIP = "192.168.0.110", +}}, + DnsServers = { "192.168.0.1" }, + Gateway = "192.168.0.1", + IPAddressPrefix = "192.168.0.0/16", + VlanId = 10, + }, + ExtendedLocation = new HybridContainerServiceExtendedLocation + { + ExtendedLocationType = HybridContainerServiceExtendedLocationType.CustomLocation, + Name = "/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourcegroups/test-arcappliance-resgrp/providers/microsoft.extendedlocation/customlocations/testcustomlocation", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); + HybridContainerServiceVirtualNetworkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +84,7 @@ public async Task Get_GetVirtualNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetwork() + public async Task Get_GetVirtualNetwork() { // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetVirtualNetwork.json // this example is just showing the usage of "virtualNetworks_Retrieve" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +106,21 @@ public async Task Exists_GetVirtualNetwork() // invoke the operation string virtualNetworkName = "test-vnet-static"; - bool result = await collection.ExistsAsync(virtualNetworkName); + HybridContainerServiceVirtualNetworkResource result = await collection.GetAsync(virtualNetworkName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridContainerServiceVirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetwork() + public async Task GetAll_ListVirtualNetworkByResourceGroup() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetVirtualNetwork.json - // this example is just showing the usage of "virtualNetworks_Retrieve" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/ListVirtualNetworkByResourceGroup.json + // this example is just showing the usage of "virtualNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +137,25 @@ public async Task GetIfExists_GetVirtualNetwork() // get the collection of this HybridContainerServiceVirtualNetworkResource HybridContainerServiceVirtualNetworkCollection collection = resourceGroupResource.GetHybridContainerServiceVirtualNetworks(); - // invoke the operation - string virtualNetworkName = "test-vnet-static"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); - HybridContainerServiceVirtualNetworkResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HybridContainerServiceVirtualNetworkResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridContainerServiceVirtualNetworkData resourceData = result.Data; + HybridContainerServiceVirtualNetworkData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutVirtualNetwork() + public async Task Exists_GetVirtualNetwork() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/PutVirtualNetwork.json - // this example is just showing the usage of "virtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetVirtualNetwork.json + // this example is just showing the usage of "virtualNetworks_Retrieve" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,62 +174,17 @@ public async Task CreateOrUpdate_PutVirtualNetwork() // invoke the operation string virtualNetworkName = "test-vnet-static"; - HybridContainerServiceVirtualNetworkData data = new HybridContainerServiceVirtualNetworkData(new AzureLocation("westus")) - { - Properties = new HybridContainerServiceVirtualNetworkProperties() - { - InfraVnetHci = new HciInfraVnetProfile() - { - MocGroup = "target-group", - MocLocation = "MocLocation", - MocVnetName = "vnet1", - }, - VipPool = -{ -new KubernetesVirtualIPItem() -{ -EndIP = "192.168.0.50", -StartIP = "192.168.0.10", -} -}, - VmipPool = -{ -new VirtualMachineIPItem() -{ -EndIP = "192.168.0.130", -StartIP = "192.168.0.110", -} -}, - DnsServers = -{ -"192.168.0.1" -}, - Gateway = "192.168.0.1", - IPAddressPrefix = "192.168.0.0/16", - VlanId = 10, - }, - ExtendedLocation = new HybridContainerServiceExtendedLocation() - { - ExtendedLocationType = HybridContainerServiceExtendedLocationType.CustomLocation, - Name = "/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourcegroups/test-arcappliance-resgrp/providers/microsoft.extendedlocation/customlocations/testcustomlocation", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); - HybridContainerServiceVirtualNetworkResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualNetworkName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridContainerServiceVirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworkByResourceGroup() + public async Task GetIfExists_GetVirtualNetwork() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/ListVirtualNetworkByResourceGroup.json - // this example is just showing the usage of "virtualNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetVirtualNetwork.json + // this example is just showing the usage of "virtualNetworks_Retrieve" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -216,17 +201,23 @@ public async Task GetAll_ListVirtualNetworkByResourceGroup() // get the collection of this HybridContainerServiceVirtualNetworkResource HybridContainerServiceVirtualNetworkCollection collection = resourceGroupResource.GetHybridContainerServiceVirtualNetworks(); - // invoke the operation and iterate over the result - await foreach (HybridContainerServiceVirtualNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkName = "test-vnet-static"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); + HybridContainerServiceVirtualNetworkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridContainerServiceVirtualNetworkData resourceData = item.Data; + HybridContainerServiceVirtualNetworkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVirtualNetworkResource.cs b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVirtualNetworkResource.cs index 4c8db37c6e544..87efa1eadf754 100644 --- a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVirtualNetworkResource.cs +++ b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVirtualNetworkResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HybridContainerService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridContainerService.Samples @@ -94,11 +93,11 @@ public async Task Update_UpdateVirtualNetwork() HybridContainerServiceVirtualNetworkResource hybridContainerServiceVirtualNetwork = client.GetHybridContainerServiceVirtualNetworkResource(hybridContainerServiceVirtualNetworkResourceId); // invoke the operation - HybridContainerServiceVirtualNetworkPatch patch = new HybridContainerServiceVirtualNetworkPatch() + HybridContainerServiceVirtualNetworkPatch patch = new HybridContainerServiceVirtualNetworkPatch { Tags = { -["additionalProperties"] = "sample", +["additionalProperties"] = "sample" }, }; ArmOperation lro = await hybridContainerServiceVirtualNetwork.UpdateAsync(WaitUntil.Completed, patch); @@ -110,36 +109,5 @@ public async Task Update_UpdateVirtualNetwork() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetHybridContainerServiceVirtualNetworks_ListVirtualNetworkBySubscription() - { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/ListVirtualNetworkBySubscription.json - // this example is just showing the usage of "virtualNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (HybridContainerServiceVirtualNetworkResource item in subscriptionResource.GetHybridContainerServiceVirtualNetworksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridContainerServiceVirtualNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVmSkuResource.cs b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVmSkuResource.cs index e4f2fb6ad26ae..7dd4337e27fd4 100644 --- a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVmSkuResource.cs +++ b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridContainerServiceVmSkuResource.cs @@ -46,10 +46,10 @@ public async Task Get_GetVMSkus() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutVMSkus() + public async Task Delete_DeleteVMSkus() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/PutVmSkus.json - // this example is just showing the usage of "PutVmSkus" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/DeleteVmSkus.json + // this example is just showing the usage of "DeleteVmSkus" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,30 +63,17 @@ public async Task CreateOrUpdate_PutVMSkus() HybridContainerServiceVmSkuResource hybridContainerServiceVmSku = client.GetHybridContainerServiceVmSkuResource(hybridContainerServiceVmSkuResourceId); // invoke the operation - HybridContainerServiceVmSkuData data = new HybridContainerServiceVmSkuData() - { - ExtendedLocation = new HybridContainerServiceExtendedLocation() - { - ExtendedLocationType = HybridContainerServiceExtendedLocationType.CustomLocation, - Name = "/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourcegroups/test-arcappliance-resgrp/providers/microsoft.extendedlocation/customlocations/testcustomlocation", - }, - }; - ArmOperation lro = await hybridContainerServiceVmSku.CreateOrUpdateAsync(WaitUntil.Completed, data); - HybridContainerServiceVmSkuResource result = lro.Value; + await hybridContainerServiceVmSku.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridContainerServiceVmSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVMSkus() + public async Task CreateOrUpdate_PutVMSkus() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/DeleteVmSkus.json - // this example is just showing the usage of "DeleteVmSkus" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/PutVmSkus.json + // this example is just showing the usage of "PutVmSkus" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,9 +87,22 @@ public async Task Delete_DeleteVMSkus() HybridContainerServiceVmSkuResource hybridContainerServiceVmSku = client.GetHybridContainerServiceVmSkuResource(hybridContainerServiceVmSkuResourceId); // invoke the operation - await hybridContainerServiceVmSku.DeleteAsync(WaitUntil.Completed); + HybridContainerServiceVmSkuData data = new HybridContainerServiceVmSkuData + { + ExtendedLocation = new HybridContainerServiceExtendedLocation + { + ExtendedLocationType = HybridContainerServiceExtendedLocationType.CustomLocation, + Name = "/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourcegroups/test-arcappliance-resgrp/providers/microsoft.extendedlocation/customlocations/testcustomlocation", + }, + }; + ArmOperation lro = await hybridContainerServiceVmSku.CreateOrUpdateAsync(WaitUntil.Completed, data); + HybridContainerServiceVmSkuResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridContainerServiceVmSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridIdentityMetadataResource.cs b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridIdentityMetadataResource.cs index 6aee2bd0fe5cc..798bda30fea4e 100644 --- a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridIdentityMetadataResource.cs +++ b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_HybridIdentityMetadataResource.cs @@ -17,10 +17,10 @@ public partial class Sample_HybridIdentityMetadataResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateHybridIdentityMetadata() + public async Task Get_GetHybridIdentityMetadata() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/CreateHybridIdentityMetadata.json - // this example is just showing the usage of "HybridIdentityMetadata_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetHybridIdentityMetadata.json + // this example is just showing the usage of "HybridIdentityMetadata_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,13 +34,7 @@ public async Task CreateOrUpdate_CreateHybridIdentityMetadata() HybridIdentityMetadataResource hybridIdentityMetadata = client.GetHybridIdentityMetadataResource(hybridIdentityMetadataResourceId); // invoke the operation - HybridIdentityMetadataData data = new HybridIdentityMetadataData() - { - ResourceUid = "f8b82dff-38ef-4220-99ef-d3a3f86ddc6c", - PublicKey = "8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2", - }; - ArmOperation lro = await hybridIdentityMetadata.CreateOrUpdateAsync(WaitUntil.Completed, data); - HybridIdentityMetadataResource result = lro.Value; + HybridIdentityMetadataResource result = await hybridIdentityMetadata.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +45,10 @@ public async Task CreateOrUpdate_CreateHybridIdentityMetadata() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetHybridIdentityMetadata() + public async Task Delete_DeleteHybridIdentityMetadata() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/GetHybridIdentityMetadata.json - // this example is just showing the usage of "HybridIdentityMetadata_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/DeleteHybridIdentityMetadata.json + // this example is just showing the usage of "HybridIdentityMetadata_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,21 +62,17 @@ public async Task Get_GetHybridIdentityMetadata() HybridIdentityMetadataResource hybridIdentityMetadata = client.GetHybridIdentityMetadataResource(hybridIdentityMetadataResourceId); // invoke the operation - HybridIdentityMetadataResource result = await hybridIdentityMetadata.GetAsync(); + await hybridIdentityMetadata.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridIdentityMetadataData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteHybridIdentityMetadata() + public async Task CreateOrUpdate_CreateHybridIdentityMetadata() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/DeleteHybridIdentityMetadata.json - // this example is just showing the usage of "HybridIdentityMetadata_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/CreateHybridIdentityMetadata.json + // this example is just showing the usage of "HybridIdentityMetadata_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,9 +86,19 @@ public async Task Delete_DeleteHybridIdentityMetadata() HybridIdentityMetadataResource hybridIdentityMetadata = client.GetHybridIdentityMetadataResource(hybridIdentityMetadataResourceId); // invoke the operation - await hybridIdentityMetadata.DeleteAsync(WaitUntil.Completed); + HybridIdentityMetadataData data = new HybridIdentityMetadataData + { + ResourceUid = "f8b82dff-38ef-4220-99ef-d3a3f86ddc6c", + PublicKey = "8ec7d60c-9700-40b1-8e6e-e5b2f6f477f2", + }; + ArmOperation lro = await hybridIdentityMetadata.CreateOrUpdateAsync(WaitUntil.Completed, data); + HybridIdentityMetadataResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridIdentityMetadataData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_KubernetesVersionProfileResource.cs b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_KubernetesVersionProfileResource.cs index 03626079bcfce..77e2c5db4a203 100644 --- a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_KubernetesVersionProfileResource.cs +++ b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_KubernetesVersionProfileResource.cs @@ -46,10 +46,10 @@ public async Task Get_GetKubernetesVersions() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutKubernetesVersions() + public async Task Delete_DeleteKubernetesVersions() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/PutKubernetesVersions.json - // this example is just showing the usage of "PutKubernetesVersions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/DeleteKubernetesVersions.json + // this example is just showing the usage of "DeleteKubernetesVersions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,30 +63,17 @@ public async Task CreateOrUpdate_PutKubernetesVersions() KubernetesVersionProfileResource kubernetesVersionProfile = client.GetKubernetesVersionProfileResource(kubernetesVersionProfileResourceId); // invoke the operation - KubernetesVersionProfileData data = new KubernetesVersionProfileData() - { - ExtendedLocation = new HybridContainerServiceExtendedLocation() - { - ExtendedLocationType = HybridContainerServiceExtendedLocationType.CustomLocation, - Name = "/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourcegroups/test-arcappliance-resgrp/providers/microsoft.extendedlocation/customlocations/testcustomlocation", - }, - }; - ArmOperation lro = await kubernetesVersionProfile.CreateOrUpdateAsync(WaitUntil.Completed, data); - KubernetesVersionProfileResource result = lro.Value; + await kubernetesVersionProfile.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KubernetesVersionProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteKubernetesVersions() + public async Task CreateOrUpdate_PutKubernetesVersions() { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/DeleteKubernetesVersions.json - // this example is just showing the usage of "DeleteKubernetesVersions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/PutKubernetesVersions.json + // this example is just showing the usage of "PutKubernetesVersions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,9 +87,22 @@ public async Task Delete_DeleteKubernetesVersions() KubernetesVersionProfileResource kubernetesVersionProfile = client.GetKubernetesVersionProfileResource(kubernetesVersionProfileResourceId); // invoke the operation - await kubernetesVersionProfile.DeleteAsync(WaitUntil.Completed); + KubernetesVersionProfileData data = new KubernetesVersionProfileData + { + ExtendedLocation = new HybridContainerServiceExtendedLocation + { + ExtendedLocationType = HybridContainerServiceExtendedLocationType.CustomLocation, + Name = "/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourcegroups/test-arcappliance-resgrp/providers/microsoft.extendedlocation/customlocations/testcustomlocation", + }, + }; + ArmOperation lro = await kubernetesVersionProfile.CreateOrUpdateAsync(WaitUntil.Completed, data); + KubernetesVersionProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KubernetesVersionProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_ProvisionedClusterResource.cs b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_ProvisionedClusterResource.cs index df9afad671d12..7e8e2c955cfe8 100644 --- a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_ProvisionedClusterResource.cs +++ b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_ProvisionedClusterResource.cs @@ -44,6 +44,30 @@ public async Task Get_GetProvisionedClusterInstance() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteProvisionedClusterInstance() + { + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/DeleteProvisionedClusterInstance.json + // this example is just showing the usage of "provisionedClusterInstances_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ProvisionedClusterResource created on azure + // for more information of creating ProvisionedClusterResource, please refer to the document of ProvisionedClusterResource + string connectedClusterResourceUri = "subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.Kubernetes/connectedClusters/test-hybridakscluster"; + ResourceIdentifier provisionedClusterResourceId = ProvisionedClusterResource.CreateResourceIdentifier(connectedClusterResourceUri); + ProvisionedClusterResource provisionedCluster = client.GetProvisionedClusterResource(provisionedClusterResourceId); + + // invoke the operation + await provisionedCluster.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_PutProvisionedClusterInstance() @@ -63,32 +87,27 @@ public async Task CreateOrUpdate_PutProvisionedClusterInstance() ProvisionedClusterResource provisionedCluster = client.GetProvisionedClusterResource(provisionedClusterResourceId); // invoke the operation - ProvisionedClusterData data = new ProvisionedClusterData() + ProvisionedClusterData data = new ProvisionedClusterData { - Properties = new ProvisionedClusterProperties() + Properties = new ProvisionedClusterProperties { - SshPublicKeys = -{ -new LinuxSshPublicKey() + SshPublicKeys = {new LinuxSshPublicKey { KeyData = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCY.......", -} -}, - ControlPlane = new ProvisionedClusterControlPlaneProfile() +}}, + ControlPlane = new ProvisionedClusterControlPlaneProfile { Count = 1, VmSize = "Standard_A4_v2", }, KubernetesVersion = "v1.20.5", - NetworkProfile = new ProvisionedClusterNetworkProfile() + NetworkProfile = new ProvisionedClusterNetworkProfile { NetworkPolicy = ProvisionedClusterNetworkPolicy.Calico, PodCidr = "10.244.0.0/16", }, ClusterVmAccessAuthorizedIPRanges = "127.0.0.1,127.0.0.2", - AgentPoolProfiles = -{ -new HybridContainerServiceNamedAgentPoolProfile() + AgentPoolProfiles = {new HybridContainerServiceNamedAgentPoolProfile { Count = 1, VmSize = "Standard_A4_v2", @@ -97,21 +116,14 @@ public async Task CreateOrUpdate_PutProvisionedClusterInstance() NodeLabels = { ["env"] = "dev", -["goal"] = "test", -}, -NodeTaints = -{ -"env=prod:NoSchedule","sku=gpu:NoSchedule" -}, -} -}, - InfraNetworkVnetSubnetIds = -{ -new ResourceIdentifier("/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourceGroups/test-arcappliance-resgrp/providers/Microsoft.AzureStackHCI/logicalNetworks/test-vnet-static") +["goal"] = "test" }, +NodeTaints = {"env=prod:NoSchedule", "sku=gpu:NoSchedule"}, +}}, + InfraNetworkVnetSubnetIds = { new ResourceIdentifier("/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourceGroups/test-arcappliance-resgrp/providers/Microsoft.AzureStackHCI/logicalNetworks/test-vnet-static") }, LicenseAzureHybridBenefit = ProvisionedClusterAzureHybridBenefit.NotApplicable, }, - ExtendedLocation = new HybridContainerServiceExtendedLocation() + ExtendedLocation = new HybridContainerServiceExtendedLocation { ExtendedLocationType = HybridContainerServiceExtendedLocationType.CustomLocation, Name = "/subscriptions/a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b/resourcegroups/test-arcappliance-resgrp/providers/microsoft.extendedlocation/customlocations/testcustomlocation", @@ -127,30 +139,6 @@ public async Task CreateOrUpdate_PutProvisionedClusterInstance() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteProvisionedClusterInstance() - { - // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/DeleteProvisionedClusterInstance.json - // this example is just showing the usage of "provisionedClusterInstances_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ProvisionedClusterResource created on azure - // for more information of creating ProvisionedClusterResource, please refer to the document of ProvisionedClusterResource - string connectedClusterResourceUri = "subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.Kubernetes/connectedClusters/test-hybridakscluster"; - ResourceIdentifier provisionedClusterResourceId = ProvisionedClusterResource.CreateResourceIdentifier(connectedClusterResourceUri); - ProvisionedClusterResource provisionedCluster = client.GetProvisionedClusterResource(provisionedClusterResourceId); - - // invoke the operation - await provisionedCluster.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetUserKubeconfig_ListClusterUserCredentials() diff --git a/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..0b11da90deb7a --- /dev/null +++ b/sdk/hybridaks/Azure.ResourceManager.HybridContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.HybridContainerService.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHybridContainerServiceVirtualNetworks_ListVirtualNetworkBySubscription() + { + // Generated from example definition: specification/hybridaks/resource-manager/Microsoft.HybridContainerService/stable/2024-01-01/examples/ListVirtualNetworkBySubscription.json + // this example is just showing the usage of "virtualNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "a3e42606-29b1-4d7d-b1d9-9ff6b9d3c71b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HybridContainerServiceVirtualNetworkResource item in subscriptionResource.GetHybridContainerServiceVirtualNetworksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridContainerServiceVirtualNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeExtensionValueCollection.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeExtensionValueCollection.cs index 83063125c2c54..c169f4638f719 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeExtensionValueCollection.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeExtensionValueCollection.cs @@ -53,10 +53,10 @@ public async Task Get_GETAnExtensionsMetadata() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GETAnExtensionsMetadata() + public async Task GetAll_GETAListOfExtensions() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/ExtensionMetadata_Get.json - // this example is just showing the usage of "ExtensionMetadata_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/ExtensionMetadata_List.json + // this example is just showing the usage of "ExtensionMetadata_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,16 +75,22 @@ public async Task Exists_GETAnExtensionsMetadata() string extensionType = "azuremonitorlinuxagent"; HybridComputeExtensionValueCollection collection = subscriptionResource.GetHybridComputeExtensionValues(location, publisher, extensionType); - // invoke the operation - string version = "1.9.1"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + await foreach (HybridComputeExtensionValueResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputeExtensionValueData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GETAnExtensionsMetadata() + public async Task Exists_GETAnExtensionsMetadata() { // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/ExtensionMetadata_Get.json // this example is just showing the usage of "ExtensionMetadata_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,29 +114,17 @@ public async Task GetIfExists_GETAnExtensionsMetadata() // invoke the operation string version = "1.9.1"; - NullableResponse response = await collection.GetIfExistsAsync(version); - HybridComputeExtensionValueResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputeExtensionValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GETAListOfExtensions() + public async Task GetIfExists_GETAnExtensionsMetadata() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/ExtensionMetadata_List.json - // this example is just showing the usage of "ExtensionMetadata_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/ExtensionMetadata_Get.json + // this example is just showing the usage of "ExtensionMetadata_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,17 +143,23 @@ public async Task GetAll_GETAListOfExtensions() string extensionType = "azuremonitorlinuxagent"; HybridComputeExtensionValueCollection collection = subscriptionResource.GetHybridComputeExtensionValues(location, publisher, extensionType); - // invoke the operation and iterate over the result - await foreach (HybridComputeExtensionValueResource item in collection.GetAllAsync()) + // invoke the operation + string version = "1.9.1"; + NullableResponse response = await collection.GetIfExistsAsync(version); + HybridComputeExtensionValueResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridComputeExtensionValueData resourceData = item.Data; + HybridComputeExtensionValueData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseCollection.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseCollection.cs index 63e67f066686d..2e8c37f1ec146 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseCollection.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseCollection.cs @@ -44,7 +44,7 @@ public async Task CreateOrUpdate_CreateOrUpdateALicense() HybridComputeLicenseData data = new HybridComputeLicenseData(new AzureLocation("eastus2euap")) { LicenseType = HybridComputeLicenseType.Esu, - LicenseDetails = new HybridComputeLicenseDetails() + LicenseDetails = new HybridComputeLicenseDetails { State = HybridComputeLicenseState.Activated, Target = HybridComputeLicenseTarget.WindowsServer2012, @@ -98,10 +98,10 @@ public async Task Get_GetLicense() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetLicense() + public async Task GetAll_GETAllMachineExtensions() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_Get.json - // this example is just showing the usage of "Licenses_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_ListByResourceGroup.json + // this example is just showing the usage of "Licenses_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +118,22 @@ public async Task Exists_GetLicense() // get the collection of this HybridComputeLicenseResource HybridComputeLicenseCollection collection = resourceGroupResource.GetHybridComputeLicenses(); - // invoke the operation - string licenseName = "{licenseName}"; - bool result = await collection.ExistsAsync(licenseName); + // invoke the operation and iterate over the result + await foreach (HybridComputeLicenseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputeLicenseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetLicense() + public async Task Exists_GetLicense() { // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_Get.json // this example is just showing the usage of "Licenses_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +155,17 @@ public async Task GetIfExists_GetLicense() // invoke the operation string licenseName = "{licenseName}"; - NullableResponse response = await collection.GetIfExistsAsync(licenseName); - HybridComputeLicenseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(licenseName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputeLicenseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GETAllMachineExtensions() + public async Task GetIfExists_GetLicense() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_ListByResourceGroup.json - // this example is just showing the usage of "Licenses_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_Get.json + // this example is just showing the usage of "Licenses_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_GETAllMachineExtensions() // get the collection of this HybridComputeLicenseResource HybridComputeLicenseCollection collection = resourceGroupResource.GetHybridComputeLicenses(); - // invoke the operation and iterate over the result - await foreach (HybridComputeLicenseResource item in collection.GetAllAsync()) + // invoke the operation + string licenseName = "{licenseName}"; + NullableResponse response = await collection.GetIfExistsAsync(licenseName); + HybridComputeLicenseResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridComputeLicenseData resourceData = item.Data; + HybridComputeLicenseData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseProfileResource.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseProfileResource.cs index 0d60c067813a5..51766006f5a80 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseProfileResource.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseProfileResource.cs @@ -18,10 +18,10 @@ public partial class Sample_HybridComputeLicenseProfileResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateALicenseProfile() + public async Task Get_GetLicenseProfile() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/licenseProfile/LicenseProfile_CreateOrUpdate.json - // this example is just showing the usage of "LicenseProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/licenseProfile/LicenseProfile_Get.json + // this example is just showing the usage of "LicenseProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,23 +37,7 @@ public async Task CreateOrUpdate_CreateOrUpdateALicenseProfile() HybridComputeLicenseProfileResource hybridComputeLicenseProfile = client.GetHybridComputeLicenseProfileResource(hybridComputeLicenseProfileResourceId); // invoke the operation - HybridComputeLicenseProfileData data = new HybridComputeLicenseProfileData(new AzureLocation("eastus2euap")) - { - SubscriptionStatus = LicenseProfileSubscriptionStatus.Enabled, - ProductType = LicenseProfileProductType.WindowsServer, - ProductFeatures = -{ -new HybridComputeProductFeature() -{ -Name = "Hotpatch", -SubscriptionStatus = LicenseProfileSubscriptionStatus.Enabled, -} -}, - AssignedLicense = "{LicenseResourceId}", - SoftwareAssuranceCustomer = true, - }; - ArmOperation lro = await hybridComputeLicenseProfile.CreateOrUpdateAsync(WaitUntil.Completed, data); - HybridComputeLicenseProfileResource result = lro.Value; + HybridComputeLicenseProfileResource result = await hybridComputeLicenseProfile.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -64,10 +48,10 @@ public async Task CreateOrUpdate_CreateOrUpdateALicenseProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateALicenseProfile() + public async Task Delete_DeleteALicenseProfile() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/licenseProfile/LicenseProfile_Update.json - // this example is just showing the usage of "LicenseProfiles_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/licenseProfile/LicenseProfile_Delete.json + // this example is just showing the usage of "LicenseProfiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -83,37 +67,17 @@ public async Task Update_UpdateALicenseProfile() HybridComputeLicenseProfileResource hybridComputeLicenseProfile = client.GetHybridComputeLicenseProfileResource(hybridComputeLicenseProfileResourceId); // invoke the operation - HybridComputeLicenseProfilePatch patch = new HybridComputeLicenseProfilePatch() - { - SubscriptionStatus = LicenseProfileSubscriptionStatusUpdate.Enable, - ProductType = LicenseProfileProductType.WindowsServer, - ProductFeatures = -{ -new HybridComputeProductFeatureUpdate() -{ -Name = "Hotpatch", -SubscriptionStatus = LicenseProfileSubscriptionStatusUpdate.Enable, -} -}, - AssignedLicense = "{LicenseResourceId}", - SoftwareAssuranceCustomer = true, - }; - ArmOperation lro = await hybridComputeLicenseProfile.UpdateAsync(WaitUntil.Completed, patch); - HybridComputeLicenseProfileResource result = lro.Value; + await hybridComputeLicenseProfile.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputeLicenseProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetLicenseProfile() + public async Task Update_UpdateALicenseProfile() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/licenseProfile/LicenseProfile_Get.json - // this example is just showing the usage of "LicenseProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/licenseProfile/LicenseProfile_Update.json + // this example is just showing the usage of "LicenseProfiles_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,7 +93,20 @@ public async Task Get_GetLicenseProfile() HybridComputeLicenseProfileResource hybridComputeLicenseProfile = client.GetHybridComputeLicenseProfileResource(hybridComputeLicenseProfileResourceId); // invoke the operation - HybridComputeLicenseProfileResource result = await hybridComputeLicenseProfile.GetAsync(); + HybridComputeLicenseProfilePatch patch = new HybridComputeLicenseProfilePatch + { + SubscriptionStatus = LicenseProfileSubscriptionStatusUpdate.Enable, + ProductType = LicenseProfileProductType.WindowsServer, + ProductFeatures = {new HybridComputeProductFeatureUpdate +{ +Name = "Hotpatch", +SubscriptionStatus = LicenseProfileSubscriptionStatusUpdate.Enable, +}}, + AssignedLicense = "{LicenseResourceId}", + SoftwareAssuranceCustomer = true, + }; + ArmOperation lro = await hybridComputeLicenseProfile.UpdateAsync(WaitUntil.Completed, patch); + HybridComputeLicenseProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -140,10 +117,10 @@ public async Task Get_GetLicenseProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteALicenseProfile() + public async Task CreateOrUpdate_CreateOrUpdateALicenseProfile() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/licenseProfile/LicenseProfile_Delete.json - // this example is just showing the usage of "LicenseProfiles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/licenseProfile/LicenseProfile_CreateOrUpdate.json + // this example is just showing the usage of "LicenseProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -159,9 +136,26 @@ public async Task Delete_DeleteALicenseProfile() HybridComputeLicenseProfileResource hybridComputeLicenseProfile = client.GetHybridComputeLicenseProfileResource(hybridComputeLicenseProfileResourceId); // invoke the operation - await hybridComputeLicenseProfile.DeleteAsync(WaitUntil.Completed); + HybridComputeLicenseProfileData data = new HybridComputeLicenseProfileData(new AzureLocation("eastus2euap")) + { + SubscriptionStatus = LicenseProfileSubscriptionStatus.Enabled, + ProductType = LicenseProfileProductType.WindowsServer, + ProductFeatures = {new HybridComputeProductFeature +{ +Name = "Hotpatch", +SubscriptionStatus = LicenseProfileSubscriptionStatus.Enabled, +}}, + AssignedLicense = "{LicenseResourceId}", + SoftwareAssuranceCustomer = true, + }; + ArmOperation lro = await hybridComputeLicenseProfile.CreateOrUpdateAsync(WaitUntil.Completed, data); + HybridComputeLicenseProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputeLicenseProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseResource.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseResource.cs index f2861fed5a55b..d3bbafefbb0a0 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseResource.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeLicenseResource.cs @@ -10,97 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HybridCompute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridCompute.Samples { public partial class Sample_HybridComputeLicenseResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task ValidateLicenseLicense_ValidateALicense() - { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_ValidateLicense.json - // this example is just showing the usage of "Licenses_ValidateLicense" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscriptionId}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - HybridComputeLicenseData data = new HybridComputeLicenseData(new AzureLocation("eastus2euap")) - { - LicenseType = HybridComputeLicenseType.Esu, - LicenseDetails = new HybridComputeLicenseDetails() - { - State = HybridComputeLicenseState.Activated, - Target = HybridComputeLicenseTarget.WindowsServer2012, - Edition = HybridComputeLicenseEdition.DataCenter, - LicenseCoreType = LicenseCoreType.PCore, - Processors = 6, - }, - }; - ArmOperation lro = await subscriptionResource.ValidateLicenseLicenseAsync(WaitUntil.Completed, data); - HybridComputeLicenseResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputeLicenseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateALicense() - { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_CreateOrUpdate.json - // this example is just showing the usage of "Licenses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HybridComputeLicenseResource created on azure - // for more information of creating HybridComputeLicenseResource, please refer to the document of HybridComputeLicenseResource - string subscriptionId = "{subscriptionId}"; - string resourceGroupName = "myResourceGroup"; - string licenseName = "{licenseName}"; - ResourceIdentifier hybridComputeLicenseResourceId = HybridComputeLicenseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, licenseName); - HybridComputeLicenseResource hybridComputeLicense = client.GetHybridComputeLicenseResource(hybridComputeLicenseResourceId); - - // invoke the operation - HybridComputeLicenseData data = new HybridComputeLicenseData(new AzureLocation("eastus2euap")) - { - LicenseType = HybridComputeLicenseType.Esu, - LicenseDetails = new HybridComputeLicenseDetails() - { - State = HybridComputeLicenseState.Activated, - Target = HybridComputeLicenseTarget.WindowsServer2012, - Edition = HybridComputeLicenseEdition.DataCenter, - LicenseCoreType = LicenseCoreType.PCore, - Processors = 6, - }, - }; - ArmOperation lro = await hybridComputeLicense.UpdateAsync(WaitUntil.Completed, data); - HybridComputeLicenseResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputeLicenseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetLicense() @@ -159,33 +74,45 @@ public async Task Delete_DeleteALicense() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetHybridComputeLicenses_ListLicensesBySubscription() + public async Task Update_CreateOrUpdateALicense() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_ListBySubscription.json - // this example is just showing the usage of "Licenses_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_CreateOrUpdate.json + // this example is just showing the usage of "Licenses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this HybridComputeLicenseResource created on azure + // for more information of creating HybridComputeLicenseResource, please refer to the document of HybridComputeLicenseResource string subscriptionId = "{subscriptionId}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "myResourceGroup"; + string licenseName = "{licenseName}"; + ResourceIdentifier hybridComputeLicenseResourceId = HybridComputeLicenseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, licenseName); + HybridComputeLicenseResource hybridComputeLicense = client.GetHybridComputeLicenseResource(hybridComputeLicenseResourceId); - // invoke the operation and iterate over the result - await foreach (HybridComputeLicenseResource item in subscriptionResource.GetHybridComputeLicensesAsync()) + // invoke the operation + HybridComputeLicenseData data = new HybridComputeLicenseData(new AzureLocation("eastus2euap")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputeLicenseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + LicenseType = HybridComputeLicenseType.Esu, + LicenseDetails = new HybridComputeLicenseDetails + { + State = HybridComputeLicenseState.Activated, + Target = HybridComputeLicenseTarget.WindowsServer2012, + Edition = HybridComputeLicenseEdition.DataCenter, + LicenseCoreType = LicenseCoreType.PCore, + Processors = 6, + }, + }; + ArmOperation lro = await hybridComputeLicense.UpdateAsync(WaitUntil.Completed, data); + HybridComputeLicenseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputeLicenseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineCollection.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineCollection.cs index 2ba34b8fdf0d4..fa173821c05eb 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineCollection.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineCollection.cs @@ -46,9 +46,9 @@ public async Task CreateOrUpdate_CreateOrUpdateAMachine() { Identity = new ManagedServiceIdentity("SystemAssigned"), LocationData = new HybridComputeLocation("Redmond"), - OSProfile = new HybridComputeOSProfile() + OSProfile = new HybridComputeOSProfile { - WindowsConfiguration = new HybridComputeWindowsConfiguration() + WindowsConfiguration = new HybridComputeWindowsConfiguration { IsHotpatchingEnabled = true, }, @@ -103,9 +103,9 @@ public async Task Get_GetMachine() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMachine() + public async Task Get_GetMachineWithLicenseProfileInstanceView() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get.json + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get_LicenseProfileInstanceView.json // this example is just showing the usage of "Machines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -125,17 +125,22 @@ public async Task Exists_GetMachine() // invoke the operation string machineName = "myMachine"; - bool result = await collection.ExistsAsync(machineName); + string expand = "instanceView"; + HybridComputeMachineResource result = await collection.GetAsync(machineName, expand: expand); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputeMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMachine() + public async Task GetAll_ListMachinesByResourceGroup() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get.json - // this example is just showing the usage of "Machines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_ListByResourceGroup.json + // this example is just showing the usage of "Machines_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,7 +149,7 @@ public async Task GetIfExists_GetMachine() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscriptionId}"; + string subscriptionId = "{subscription-id}"; string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -152,30 +157,24 @@ public async Task GetIfExists_GetMachine() // get the collection of this HybridComputeMachineResource HybridComputeMachineCollection collection = resourceGroupResource.GetHybridComputeMachines(); - // invoke the operation - string machineName = "myMachine"; - NullableResponse response = await collection.GetIfExistsAsync(machineName); - HybridComputeMachineResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HybridComputeMachineResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridComputeMachineData resourceData = result.Data; + HybridComputeMachineData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMachineWithLicenseProfileInstanceView() + public async Task Exists_GetMachine() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get_LicenseProfileInstanceView.json + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get.json // this example is just showing the usage of "Machines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -195,14 +194,9 @@ public async Task Get_GetMachineWithLicenseProfileInstanceView() // invoke the operation string machineName = "myMachine"; - string expand = "instanceView"; - HybridComputeMachineResource result = await collection.GetAsync(machineName, expand: expand); + bool result = await collection.ExistsAsync(machineName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputeMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -237,9 +231,9 @@ public async Task Exists_GetMachineWithLicenseProfileInstanceView() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMachineWithLicenseProfileInstanceView() + public async Task GetIfExists_GetMachine() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get_LicenseProfileInstanceView.json + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get.json // this example is just showing the usage of "Machines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -259,8 +253,7 @@ public async Task GetIfExists_GetMachineWithLicenseProfileInstanceView() // invoke the operation string machineName = "myMachine"; - string expand = "instanceView"; - NullableResponse response = await collection.GetIfExistsAsync(machineName, expand: expand); + NullableResponse response = await collection.GetIfExistsAsync(machineName); HybridComputeMachineResource result = response.HasValue ? response.Value : null; if (result == null) @@ -279,10 +272,10 @@ public async Task GetIfExists_GetMachineWithLicenseProfileInstanceView() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListMachinesByResourceGroup() + public async Task GetIfExists_GetMachineWithLicenseProfileInstanceView() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_ListByResourceGroup.json - // this example is just showing the usage of "Machines_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get_LicenseProfileInstanceView.json + // this example is just showing the usage of "Machines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -291,7 +284,7 @@ public async Task GetAll_ListMachinesByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; + string subscriptionId = "{subscriptionId}"; string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -299,17 +292,24 @@ public async Task GetAll_ListMachinesByResourceGroup() // get the collection of this HybridComputeMachineResource HybridComputeMachineCollection collection = resourceGroupResource.GetHybridComputeMachines(); - // invoke the operation and iterate over the result - await foreach (HybridComputeMachineResource item in collection.GetAllAsync()) + // invoke the operation + string machineName = "myMachine"; + string expand = "instanceView"; + NullableResponse response = await collection.GetIfExistsAsync(machineName, expand: expand); + HybridComputeMachineResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridComputeMachineData resourceData = item.Data; + HybridComputeMachineData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineExtensionCollection.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineExtensionCollection.cs index b4478e6640f0b..5bd0920162c91 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineExtensionCollection.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineExtensionCollection.cs @@ -43,14 +43,14 @@ public async Task CreateOrUpdate_CreateOrUpdateAMachineExtension() string extensionName = "CustomScriptExtension"; HybridComputeMachineExtensionData data = new HybridComputeMachineExtensionData(new AzureLocation("eastus2euap")) { - Properties = new MachineExtensionProperties() + Properties = new MachineExtensionProperties { Publisher = "Microsoft.Compute", MachineExtensionPropertiesType = "CustomScriptExtension", TypeHandlerVersion = "1.10", Settings = { -["commandToExecute"] = BinaryData.FromString("\"powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\"\""), +["commandToExecute"] = BinaryData.FromObjectAsJson("powershell.exe -c \"Get-Process | Where-Object { $_.CPU -gt 10000 }\"") }, }, }; @@ -100,10 +100,10 @@ public async Task Get_GETMachineExtension() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GETMachineExtension() + public async Task GetAll_GETAllMachineExtensionsList() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/Extension_Get.json - // this example is just showing the usage of "MachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/Extension_List.json + // this example is just showing the usage of "MachineExtensions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,16 +121,22 @@ public async Task Exists_GETMachineExtension() // get the collection of this HybridComputeMachineExtensionResource HybridComputeMachineExtensionCollection collection = hybridComputeMachine.GetHybridComputeMachineExtensions(); - // invoke the operation - string extensionName = "CustomScriptExtension"; - bool result = await collection.ExistsAsync(extensionName); + // invoke the operation and iterate over the result + await foreach (HybridComputeMachineExtensionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputeMachineExtensionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GETMachineExtension() + public async Task Exists_GETMachineExtension() { // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/Extension_Get.json // this example is just showing the usage of "MachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. @@ -153,29 +159,17 @@ public async Task GetIfExists_GETMachineExtension() // invoke the operation string extensionName = "CustomScriptExtension"; - NullableResponse response = await collection.GetIfExistsAsync(extensionName); - HybridComputeMachineExtensionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(extensionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputeMachineExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GETAllMachineExtensionsList() + public async Task GetIfExists_GETMachineExtension() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/Extension_List.json - // this example is just showing the usage of "MachineExtensions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/Extension_Get.json + // this example is just showing the usage of "MachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +187,23 @@ public async Task GetAll_GETAllMachineExtensionsList() // get the collection of this HybridComputeMachineExtensionResource HybridComputeMachineExtensionCollection collection = hybridComputeMachine.GetHybridComputeMachineExtensions(); - // invoke the operation and iterate over the result - await foreach (HybridComputeMachineExtensionResource item in collection.GetAllAsync()) + // invoke the operation + string extensionName = "CustomScriptExtension"; + NullableResponse response = await collection.GetIfExistsAsync(extensionName); + HybridComputeMachineExtensionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridComputeMachineExtensionData resourceData = item.Data; + HybridComputeMachineExtensionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineExtensionResource.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineExtensionResource.cs index 09be1291b895c..a077628f57687 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineExtensionResource.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineExtensionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_HybridComputeMachineExtensionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAMachineExtension() + public async Task Get_GETMachineExtension() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/Extension_Update.json - // this example is just showing the usage of "MachineExtensions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/Extension_Get.json + // this example is just showing the usage of "MachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,19 +38,7 @@ public async Task Update_CreateOrUpdateAMachineExtension() HybridComputeMachineExtensionResource hybridComputeMachineExtension = client.GetHybridComputeMachineExtensionResource(hybridComputeMachineExtensionResourceId); // invoke the operation - HybridComputeMachineExtensionPatch patch = new HybridComputeMachineExtensionPatch() - { - Publisher = "Microsoft.Compute", - MachineExtensionUpdatePropertiesType = "CustomScriptExtension", - TypeHandlerVersion = "1.10", - EnableAutomaticUpgrade = true, - Settings = -{ -["commandToExecute"] = BinaryData.FromString("\"powershell.exe -c \"Get-Process | Where-Object { $_.CPU -lt 100 }\"\""), -}, - }; - ArmOperation lro = await hybridComputeMachineExtension.UpdateAsync(WaitUntil.Completed, patch); - HybridComputeMachineExtensionResource result = lro.Value; + HybridComputeMachineExtensionResource result = await hybridComputeMachineExtension.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +76,10 @@ public async Task Delete_DeleteAMachineExtension() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GETMachineExtension() + public async Task Update_CreateOrUpdateAMachineExtension() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/Extension_Get.json - // this example is just showing the usage of "MachineExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/extension/Extension_Update.json + // this example is just showing the usage of "MachineExtensions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,7 +96,19 @@ public async Task Get_GETMachineExtension() HybridComputeMachineExtensionResource hybridComputeMachineExtension = client.GetHybridComputeMachineExtensionResource(hybridComputeMachineExtensionResourceId); // invoke the operation - HybridComputeMachineExtensionResource result = await hybridComputeMachineExtension.GetAsync(); + HybridComputeMachineExtensionPatch patch = new HybridComputeMachineExtensionPatch + { + Publisher = "Microsoft.Compute", + MachineExtensionUpdatePropertiesType = "CustomScriptExtension", + TypeHandlerVersion = "1.10", + EnableAutomaticUpgrade = true, + Settings = +{ +["commandToExecute"] = BinaryData.FromObjectAsJson("powershell.exe -c \"Get-Process | Where-Object { $_.CPU -lt 100 }\"") +}, + }; + ArmOperation lro = await hybridComputeMachineExtension.UpdateAsync(WaitUntil.Completed, patch); + HybridComputeMachineExtensionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineResource.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineResource.cs index a62767696c2b7..a3aee38421cef 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineResource.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputeMachineResource.cs @@ -12,7 +12,6 @@ using Azure.Identity; using Azure.ResourceManager.HybridCompute.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridCompute.Samples @@ -21,10 +20,10 @@ public partial class Sample_HybridComputeMachineResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAMachine() + public async Task Get_GetMachine() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Update.json - // this example is just showing the usage of "Machines_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get.json + // this example is just showing the usage of "Machines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,35 +32,14 @@ public async Task Update_UpdateAMachine() // this example assumes you already have this HybridComputeMachineResource created on azure // for more information of creating HybridComputeMachineResource, please refer to the document of HybridComputeMachineResource - string subscriptionId = "{subscription-id}"; + string subscriptionId = "{subscriptionId}"; string resourceGroupName = "myResourceGroup"; string machineName = "myMachine"; ResourceIdentifier hybridComputeMachineResourceId = HybridComputeMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, machineName); HybridComputeMachineResource hybridComputeMachine = client.GetHybridComputeMachineResource(hybridComputeMachineResourceId); // invoke the operation - HybridComputeMachinePatch patch = new HybridComputeMachinePatch() - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - LocationData = new HybridComputeLocation("Redmond"), - OSProfile = new HybridComputeOSProfile() - { - WindowsConfiguration = new HybridComputeWindowsConfiguration() - { - AssessmentMode = AssessmentModeType.ImageDefault, - PatchMode = PatchModeType.AutomaticByPlatform, - IsHotpatchingEnabled = true, - }, - LinuxConfiguration = new HybridComputeLinuxConfiguration() - { - AssessmentMode = AssessmentModeType.ImageDefault, - PatchMode = PatchModeType.Manual, - }, - }, - ParentClusterResourceId = new ResourceIdentifier("{AzureStackHCIResourceId}"), - PrivateLinkScopeResourceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/privateLinkScopes/privateLinkScopeName"), - }; - HybridComputeMachineResource result = await hybridComputeMachine.UpdateAsync(patch); + HybridComputeMachineResource result = await hybridComputeMachine.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -72,10 +50,10 @@ public async Task Update_UpdateAMachine() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAMachine() + public async Task Get_GetMachineWithLicenseProfileInstanceView() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Delete.json - // this example is just showing the usage of "Machines_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get_LicenseProfileInstanceView.json + // this example is just showing the usage of "Machines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,17 +69,22 @@ public async Task Delete_DeleteAMachine() HybridComputeMachineResource hybridComputeMachine = client.GetHybridComputeMachineResource(hybridComputeMachineResourceId); // invoke the operation - await hybridComputeMachine.DeleteAsync(WaitUntil.Completed); + string expand = "instanceView"; + HybridComputeMachineResource result = await hybridComputeMachine.GetAsync(expand: expand); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputeMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMachine() + public async Task Delete_DeleteAMachine() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get.json - // this example is just showing the usage of "Machines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Delete.json + // this example is just showing the usage of "Machines_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,21 +100,17 @@ public async Task Get_GetMachine() HybridComputeMachineResource hybridComputeMachine = client.GetHybridComputeMachineResource(hybridComputeMachineResourceId); // invoke the operation - HybridComputeMachineResource result = await hybridComputeMachine.GetAsync(); + await hybridComputeMachine.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputeMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMachineWithLicenseProfileInstanceView() + public async Task Update_UpdateAMachine() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Get_LicenseProfileInstanceView.json - // this example is just showing the usage of "Machines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_Update.json + // this example is just showing the usage of "Machines_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,15 +119,35 @@ public async Task Get_GetMachineWithLicenseProfileInstanceView() // this example assumes you already have this HybridComputeMachineResource created on azure // for more information of creating HybridComputeMachineResource, please refer to the document of HybridComputeMachineResource - string subscriptionId = "{subscriptionId}"; + string subscriptionId = "{subscription-id}"; string resourceGroupName = "myResourceGroup"; string machineName = "myMachine"; ResourceIdentifier hybridComputeMachineResourceId = HybridComputeMachineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, machineName); HybridComputeMachineResource hybridComputeMachine = client.GetHybridComputeMachineResource(hybridComputeMachineResourceId); // invoke the operation - string expand = "instanceView"; - HybridComputeMachineResource result = await hybridComputeMachine.GetAsync(expand: expand); + HybridComputeMachinePatch patch = new HybridComputeMachinePatch + { + Identity = new ManagedServiceIdentity("SystemAssigned"), + LocationData = new HybridComputeLocation("Redmond"), + OSProfile = new HybridComputeOSProfile + { + WindowsConfiguration = new HybridComputeWindowsConfiguration + { + AssessmentMode = AssessmentModeType.ImageDefault, + PatchMode = PatchModeType.AutomaticByPlatform, + IsHotpatchingEnabled = true, + }, + LinuxConfiguration = new HybridComputeLinuxConfiguration + { + AssessmentMode = AssessmentModeType.ImageDefault, + PatchMode = PatchModeType.Manual, + }, + }, + ParentClusterResourceId = new ResourceIdentifier("{AzureStackHCIResourceId}"), + PrivateLinkScopeResourceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/privateLinkScopes/privateLinkScopeName"), + }; + HybridComputeMachineResource result = await hybridComputeMachine.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -207,12 +206,9 @@ public async Task InstallPatches_InstallPatchStateOfAMachine() // invoke the operation MachineInstallPatchesContent content = new MachineInstallPatchesContent(XmlConvert.ToTimeSpan("PT4H"), VmGuestPatchRebootSetting.IfRequired) { - WindowsParameters = new HybridComputeWindowsParameters() + WindowsParameters = new HybridComputeWindowsParameters { - ClassificationsToInclude = -{ -VmGuestPatchClassificationWindow.Critical,VmGuestPatchClassificationWindow.Security -}, + ClassificationsToInclude = { VmGuestPatchClassificationWindow.Critical, VmGuestPatchClassificationWindow.Security }, MaxPatchPublishOn = DateTimeOffset.Parse("2021-08-19T02:36:43.0539904+00:00"), }, }; @@ -222,37 +218,6 @@ public async Task InstallPatches_InstallPatchStateOfAMachine() Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetHybridComputeMachines_ListMachinesByResourceGroup() - { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_ListBySubscription.json - // this example is just showing the usage of "Machines_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (HybridComputeMachineResource item in subscriptionResource.GetHybridComputeMachinesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputeMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task UpgradeExtensions_UpgradeMachineExtensions() @@ -274,18 +239,18 @@ public async Task UpgradeExtensions_UpgradeMachineExtensions() HybridComputeMachineResource hybridComputeMachine = client.GetHybridComputeMachineResource(hybridComputeMachineResourceId); // invoke the operation - MachineExtensionUpgrade extensionUpgradeParameters = new MachineExtensionUpgrade() + MachineExtensionUpgrade extensionUpgradeParameters = new MachineExtensionUpgrade { ExtensionTargets = { -["Microsoft.Azure.Monitoring"] = new ExtensionTargetProperties() +["Microsoft.Azure.Monitoring"] = new ExtensionTargetProperties { TargetVersion = "2.0", }, -["Microsoft.Compute.CustomScriptExtension"] = new ExtensionTargetProperties() +["Microsoft.Compute.CustomScriptExtension"] = new ExtensionTargetProperties { TargetVersion = "1.10", -}, +} }, }; await hybridComputeMachine.UpgradeExtensionsAsync(WaitUntil.Completed, extensionUpgradeParameters); diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateEndpointConnectionCollection.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateEndpointConnectionCollection.cs index dd379998acda1..ab51a8ab59d55 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateEndpointConnectionCollection.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HybridComputePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateEndpointConnection() + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Update.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - HybridComputePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + HybridComputePrivateEndpointConnectionData data = new HybridComputePrivateEndpointConnectionData + { + Properties = new HybridComputePrivateEndpointConnectionProperties + { + ConnectionState = new HybridComputePrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + HybridComputePrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task Get_GetsPrivateEndpointConnection() { // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +83,21 @@ public async Task Exists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + HybridComputePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAPrivateLinkScope() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_List.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +115,25 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // get the collection of this HybridComputePrivateEndpointConnectionResource HybridComputePrivateEndpointConnectionCollection collection = hybridComputePrivateLinkScope.GetHybridComputePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - HybridComputePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HybridComputePrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridComputePrivateEndpointConnectionData resourceData = result.Data; + HybridComputePrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Exists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Update.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,29 +153,17 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - HybridComputePrivateEndpointConnectionData data = new HybridComputePrivateEndpointConnectionData() - { - Properties = new HybridComputePrivateEndpointConnectionProperties() - { - ConnectionState = new HybridComputePrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - HybridComputePrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAPrivateLinkScope() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_List.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +181,23 @@ public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAPrivateLinkScope // get the collection of this HybridComputePrivateEndpointConnectionResource HybridComputePrivateEndpointConnectionCollection collection = hybridComputePrivateLinkScope.GetHybridComputePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (HybridComputePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + HybridComputePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridComputePrivateEndpointConnectionData resourceData = item.Data; + HybridComputePrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateEndpointConnectionResource.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateEndpointConnectionResource.cs index b9eb7cae2dee1..189620cd8c2d2 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateEndpointConnectionResource.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Update.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName HybridComputePrivateEndpointConnectionResource hybridComputePrivateEndpointConnection = client.GetHybridComputePrivateEndpointConnectionResource(hybridComputePrivateEndpointConnectionResourceId); // invoke the operation - HybridComputePrivateEndpointConnectionData data = new HybridComputePrivateEndpointConnectionData() - { - Properties = new HybridComputePrivateEndpointConnectionProperties() - { - ConnectionState = new HybridComputePrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), - }, - }; - ArmOperation lro = await hybridComputePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - HybridComputePrivateEndpointConnectionResource result = lro.Value; + await hybridComputePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateEndpoint/PrivateEndpointConnection_Update.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() HybridComputePrivateEndpointConnectionResource hybridComputePrivateEndpointConnection = client.GetHybridComputePrivateEndpointConnectionResource(hybridComputePrivateEndpointConnectionResourceId); // invoke the operation - await hybridComputePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + HybridComputePrivateEndpointConnectionData data = new HybridComputePrivateEndpointConnectionData + { + Properties = new HybridComputePrivateEndpointConnectionProperties + { + ConnectionState = new HybridComputePrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), + }, + }; + ArmOperation lro = await hybridComputePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + HybridComputePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkResourceCollection.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkResourceCollection.cs index 0ef6c703d9d06..679b9ed43509a 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkResourceCollection.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HybridComputePrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateEndpointConnection() + public async Task Get_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopePrivateLinkResource_ListGet.json - // this example is just showing the usage of "PrivateLinkResources_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopePrivateLinkResource_Get.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetsPrivateEndpointConnection() // get the collection of this HybridComputePrivateLinkResource HybridComputePrivateLinkResourceCollection collection = hybridComputePrivateLinkScope.GetHybridComputePrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (HybridComputePrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputePrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "hybridcompute"; + HybridComputePrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputePrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateEndpointConnection() + public async Task GetAll_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopePrivateLinkResource_Get.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopePrivateLinkResource_ListGet.json + // this example is just showing the usage of "PrivateLinkResources_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsPrivateEndpointConnection() // get the collection of this HybridComputePrivateLinkResource HybridComputePrivateLinkResourceCollection collection = hybridComputePrivateLinkScope.GetHybridComputePrivateLinkResources(); - // invoke the operation - string groupName = "hybridcompute"; - HybridComputePrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (HybridComputePrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputePrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputePrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkScopeCollection.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkScopeCollection.cs index c20204602f209..3d343d1ae59c0 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkScopeCollection.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkScopeCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HybridComputePrivateLinkScopeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkScopeListByResourceGroup() + public async Task CreateOrUpdate_PrivateLinkScopeCreate() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_ListByResourceGroup.json - // this example is just showing the usage of "PrivateLinkScopes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Create.json + // this example is just showing the usage of "PrivateLinkScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,25 @@ public async Task GetAll_PrivateLinkScopeListByResourceGroup() // get the collection of this HybridComputePrivateLinkScopeResource HybridComputePrivateLinkScopeCollection collection = resourceGroupResource.GetHybridComputePrivateLinkScopes(); - // invoke the operation and iterate over the result - await foreach (HybridComputePrivateLinkScopeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputePrivateLinkScopeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scopeName = "my-privatelinkscope"; + HybridComputePrivateLinkScopeData data = new HybridComputePrivateLinkScopeData(new AzureLocation("westus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeName, data); + HybridComputePrivateLinkScopeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputePrivateLinkScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkScopeGet() + public async Task CreateOrUpdate_PrivateLinkScopeUpdate() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Get.json - // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Update.json + // this example is just showing the usage of "PrivateLinkScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,7 +75,15 @@ public async Task Get_PrivateLinkScopeGet() // invoke the operation string scopeName = "my-privatelinkscope"; - HybridComputePrivateLinkScopeResource result = await collection.GetAsync(scopeName); + HybridComputePrivateLinkScopeData data = new HybridComputePrivateLinkScopeData(new AzureLocation("westus")) + { + Tags = +{ +["Tag1"] = "Value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeName, data); + HybridComputePrivateLinkScopeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,7 +94,7 @@ public async Task Get_PrivateLinkScopeGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateLinkScopeGet() + public async Task Get_PrivateLinkScopeGet() { // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Get.json // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,17 +116,21 @@ public async Task Exists_PrivateLinkScopeGet() // invoke the operation string scopeName = "my-privatelinkscope"; - bool result = await collection.ExistsAsync(scopeName); + HybridComputePrivateLinkScopeResource result = await collection.GetAsync(scopeName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputePrivateLinkScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateLinkScopeGet() + public async Task GetAll_PrivateLinkScopeListByResourceGroup() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Get.json - // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_ListByResourceGroup.json + // this example is just showing the usage of "PrivateLinkScopes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,31 +147,25 @@ public async Task GetIfExists_PrivateLinkScopeGet() // get the collection of this HybridComputePrivateLinkScopeResource HybridComputePrivateLinkScopeCollection collection = resourceGroupResource.GetHybridComputePrivateLinkScopes(); - // invoke the operation - string scopeName = "my-privatelinkscope"; - NullableResponse response = await collection.GetIfExistsAsync(scopeName); - HybridComputePrivateLinkScopeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HybridComputePrivateLinkScopeResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridComputePrivateLinkScopeData resourceData = result.Data; + HybridComputePrivateLinkScopeData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateLinkScopeCreate() + public async Task Exists_PrivateLinkScopeGet() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Create.json - // this example is just showing the usage of "PrivateLinkScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Get.json + // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,23 +184,17 @@ public async Task CreateOrUpdate_PrivateLinkScopeCreate() // invoke the operation string scopeName = "my-privatelinkscope"; - HybridComputePrivateLinkScopeData data = new HybridComputePrivateLinkScopeData(new AzureLocation("westus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeName, data); - HybridComputePrivateLinkScopeResource result = lro.Value; + bool result = await collection.ExistsAsync(scopeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputePrivateLinkScopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateLinkScopeUpdate() + public async Task GetIfExists_PrivateLinkScopeGet() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Update.json - // this example is just showing the usage of "PrivateLinkScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Get.json + // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,21 +213,21 @@ public async Task CreateOrUpdate_PrivateLinkScopeUpdate() // invoke the operation string scopeName = "my-privatelinkscope"; - HybridComputePrivateLinkScopeData data = new HybridComputePrivateLinkScopeData(new AzureLocation("westus")) - { - Tags = -{ -["Tag1"] = "Value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeName, data); - HybridComputePrivateLinkScopeResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(scopeName); + HybridComputePrivateLinkScopeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputePrivateLinkScopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputePrivateLinkScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkScopeResource.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkScopeResource.cs index 2ff92af0646a1..25b9e48ea2a53 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkScopeResource.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_HybridComputePrivateLinkScopeResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HybridCompute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridCompute.Samples @@ -19,41 +18,10 @@ public partial class Sample_HybridComputePrivateLinkScopeResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetHybridComputePrivateLinkScopes_PrivateLinkScopesListJson() - { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_List.json - // this example is just showing the usage of "PrivateLinkScopes_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (HybridComputePrivateLinkScopeResource item in subscriptionResource.GetHybridComputePrivateLinkScopesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputePrivateLinkScopeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateLinkScopesDelete() + public async Task Get_PrivateLinkScopeGet() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Delete.json - // this example is just showing the usage of "PrivateLinkScopes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Get.json + // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,17 +37,21 @@ public async Task Delete_PrivateLinkScopesDelete() HybridComputePrivateLinkScopeResource hybridComputePrivateLinkScope = client.GetHybridComputePrivateLinkScopeResource(hybridComputePrivateLinkScopeResourceId); // invoke the operation - await hybridComputePrivateLinkScope.DeleteAsync(WaitUntil.Completed); + HybridComputePrivateLinkScopeResource result = await hybridComputePrivateLinkScope.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputePrivateLinkScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkScopeGet() + public async Task Delete_PrivateLinkScopesDelete() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Get.json - // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_Delete.json + // this example is just showing the usage of "PrivateLinkScopes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,13 +67,9 @@ public async Task Get_PrivateLinkScopeGet() HybridComputePrivateLinkScopeResource hybridComputePrivateLinkScope = client.GetHybridComputePrivateLinkScopeResource(hybridComputePrivateLinkScopeResourceId); // invoke the operation - HybridComputePrivateLinkScopeResource result = await hybridComputePrivateLinkScope.GetAsync(); + await hybridComputePrivateLinkScope.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridComputePrivateLinkScopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -125,12 +93,12 @@ public async Task Update_PrivateLinkScopeUpdateTagsOnly() HybridComputePrivateLinkScopeResource hybridComputePrivateLinkScope = client.GetHybridComputePrivateLinkScopeResource(hybridComputePrivateLinkScopeResourceId); // invoke the operation - HybridComputePrivateLinkScopePatch patch = new HybridComputePrivateLinkScopePatch() + HybridComputePrivateLinkScopePatch patch = new HybridComputePrivateLinkScopePatch { Tags = { ["Tag1"] = "Value1", -["Tag2"] = "Value2", +["Tag2"] = "Value2" }, }; HybridComputePrivateLinkScopeResource result = await hybridComputePrivateLinkScope.UpdateAsync(patch); @@ -141,31 +109,5 @@ public async Task Update_PrivateLinkScopeUpdateTagsOnly() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetValidationDetailsPrivateLinkScope_PrivateLinkScopeGet() - { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_GetValidation.json - // this example is just showing the usage of "PrivateLinkScopes_GetValidationDetails" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("wus2"); - string privateLinkScopeId = "f5dc51d3-92ed-4d7e-947a-775ea79b4919"; - PrivateLinkScopeValidationDetails result = await subscriptionResource.GetValidationDetailsPrivateLinkScopeAsync(location, privateLinkScopeId); - - Console.WriteLine($"Succeeded: {result}"); - } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs index b9fe91b62b223..af2f33e395c5a 100644 --- a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetsTheNetworkSecurityPerimeterConfigurationOfThePrivateLi [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheNetworkSecurityPerimeterConfigurationOfThePrivateLinkScope() + public async Task GetAll_GetsTheListOfNetworkSecurityPerimeterConfigurationsOfThePrivateLinkScope() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/networkSecurityPerimeterConfiguration/NetworkSecurityPerimeterConfigurationGet.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_GetByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/networkSecurityPerimeterConfiguration/NetworkSecurityPerimeterConfigurationList.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetsTheNetworkSecurityPerimeterConfigurationOfThePrivat // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = hybridComputePrivateLinkScope.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation - string perimeterName = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee.myAssociation"; - bool result = await collection.ExistsAsync(perimeterName); + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheNetworkSecurityPerimeterConfigurationOfThePrivateLinkScope() + public async Task Exists_GetsTheNetworkSecurityPerimeterConfigurationOfThePrivateLinkScope() { // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/networkSecurityPerimeterConfiguration/NetworkSecurityPerimeterConfigurationGet.json // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_GetByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetsTheNetworkSecurityPerimeterConfigurationOfTheP // invoke the operation string perimeterName = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee.myAssociation"; - NullableResponse response = await collection.GetIfExistsAsync(perimeterName); - NetworkSecurityPerimeterConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(perimeterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfNetworkSecurityPerimeterConfigurationsOfThePrivateLinkScope() + public async Task GetIfExists_GetsTheNetworkSecurityPerimeterConfigurationOfThePrivateLinkScope() { - // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/networkSecurityPerimeterConfiguration/NetworkSecurityPerimeterConfigurationList.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/networkSecurityPerimeterConfiguration/NetworkSecurityPerimeterConfigurationGet.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_GetByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_GetsTheListOfNetworkSecurityPerimeterConfigurationsOfTh // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = hybridComputePrivateLinkScope.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string perimeterName = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee.myAssociation"; + NullableResponse response = await collection.GetIfExistsAsync(perimeterName); + NetworkSecurityPerimeterConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = item.Data; + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..7c90db3d83433 --- /dev/null +++ b/sdk/hybridcompute/Azure.ResourceManager.HybridCompute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,180 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.HybridCompute.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.HybridCompute.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task ValidateLicenseLicense_ValidateALicense() + { + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_ValidateLicense.json + // this example is just showing the usage of "Licenses_ValidateLicense" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscriptionId}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + HybridComputeLicenseData data = new HybridComputeLicenseData(new AzureLocation("eastus2euap")) + { + LicenseType = HybridComputeLicenseType.Esu, + LicenseDetails = new HybridComputeLicenseDetails + { + State = HybridComputeLicenseState.Activated, + Target = HybridComputeLicenseTarget.WindowsServer2012, + Edition = HybridComputeLicenseEdition.DataCenter, + LicenseCoreType = LicenseCoreType.PCore, + Processors = 6, + }, + }; + ArmOperation lro = await subscriptionResource.ValidateLicenseLicenseAsync(WaitUntil.Completed, data); + HybridComputeLicenseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputeLicenseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHybridComputeLicenses_ListLicensesBySubscription() + { + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/license/License_ListBySubscription.json + // this example is just showing the usage of "Licenses_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscriptionId}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HybridComputeLicenseResource item in subscriptionResource.GetHybridComputeLicensesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputeLicenseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHybridComputeMachines_ListMachinesByResourceGroup() + { + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/machine/Machines_ListBySubscription.json + // this example is just showing the usage of "Machines_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HybridComputeMachineResource item in subscriptionResource.GetHybridComputeMachinesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputeMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHybridComputePrivateLinkScopes_PrivateLinkScopesListJson() + { + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_List.json + // this example is just showing the usage of "PrivateLinkScopes_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HybridComputePrivateLinkScopeResource item in subscriptionResource.GetHybridComputePrivateLinkScopesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridComputePrivateLinkScopeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetValidationDetailsPrivateLinkScope_PrivateLinkScopeGet() + { + // Generated from example definition: specification/hybridcompute/resource-manager/Microsoft.HybridCompute/stable/2024-07-10/examples/privateLinkScope/PrivateLinkScopes_GetValidation.json + // this example is just showing the usage of "PrivateLinkScopes_GetValidationDetails" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("wus2"); + string privateLinkScopeId = "f5dc51d3-92ed-4d7e-947a-775ea79b4919"; + PrivateLinkScopeValidationDetails result = await subscriptionResource.GetValidationDetailsPrivateLinkScopeAsync(location, privateLinkScopeId); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_EndpointResource.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_EndpointResource.cs index 930dc9edbedca..a78670f79e889 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_EndpointResource.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_EndpointResource.cs @@ -76,10 +76,10 @@ public async Task Get_HybridConnectivityEndpointsGetDefault() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_HybridConnectivityEndpointsPatchDefault() + public async Task Delete_HybridConnectivityEndpointsDeleteDefault() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsPatchDefault.json - // this example is just showing the usage of "Endpoints_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsDeleteDefault.json + // this example is just showing the usage of "Endpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,25 +94,17 @@ public async Task Update_HybridConnectivityEndpointsPatchDefault() EndpointResource endpointResource = client.GetEndpointResource(endpointResourceId); // invoke the operation - EndpointResourceData data = new EndpointResourceData() - { - Properties = new HybridConnectivityEndpointProperties(EndpointType.Default), - }; - EndpointResource result = await endpointResource.UpdateAsync(data); + await endpointResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_HybridConnectivityEndpointsDeleteDefault() + public async Task Update_HybridConnectivityEndpointsPatchDefault() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsDeleteDefault.json - // this example is just showing the usage of "Endpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsPatchDefault.json + // this example is just showing the usage of "Endpoints_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,9 +119,17 @@ public async Task Delete_HybridConnectivityEndpointsDeleteDefault() EndpointResource endpointResource = client.GetEndpointResource(endpointResourceId); // invoke the operation - await endpointResource.DeleteAsync(WaitUntil.Completed); + EndpointResourceData data = new EndpointResourceData + { + Properties = new HybridConnectivityEndpointProperties(EndpointType.Default), + }; + EndpointResource result = await endpointResource.UpdateAsync(data); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -152,7 +152,7 @@ public async Task GetCredentials_HybridConnectivityEndpointsPostListCredentials( EndpointResource endpointResource = client.GetEndpointResource(endpointResourceId); // invoke the operation - ListCredentialsContent content = new ListCredentialsContent() + ListCredentialsContent content = new ListCredentialsContent { ServiceName = HybridConnectivityServiceName.SSH, }; diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_EndpointResourceCollection.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_EndpointResourceCollection.cs index 4b885bc400319..6c709780b2c0a 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_EndpointResourceCollection.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_EndpointResourceCollection.cs @@ -18,35 +18,69 @@ public partial class Sample_EndpointResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_HybridConnectivityEndpointsGet() + public async Task CreateOrUpdate_HybridConnectivityEndpointsPutCustom() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsList.json - // this example is just showing the usage of "Endpoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsPutCustom.json + // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource + // get the collection of this EndpointResource + string scope = "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"; + EndpointResourceCollection collection = client.GetEndpointResources(new ResourceIdentifier(scope)); + + // invoke the operation + string endpointName = "custom"; + EndpointResourceData data = new EndpointResourceData + { + Properties = new HybridConnectivityEndpointProperties(EndpointType.Custom) + { + ResourceId = new ResourceIdentifier("/subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.Relay/namespaces/custom-relay-namespace"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); + EndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_HybridConnectivityEndpointsPutDefault() + { + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsPutDefault.json + // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); // get the collection of this EndpointResource string scope = "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EndpointResourceCollection collection = client.GetEndpointResources(scopeId); + EndpointResourceCollection collection = client.GetEndpointResources(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (EndpointResource item in collection.GetAllAsync()) + // invoke the operation + string endpointName = "default"; + EndpointResourceData data = new EndpointResourceData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EndpointResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new HybridConnectivityEndpointProperties(EndpointType.Default), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); + EndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -61,13 +95,9 @@ public async Task Get_HybridConnectivityEndpointsGetCustom() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EndpointResource string scope = "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EndpointResourceCollection collection = client.GetEndpointResources(scopeId); + EndpointResourceCollection collection = client.GetEndpointResources(new ResourceIdentifier(scope)); // invoke the operation string endpointName = "custom"; @@ -82,9 +112,9 @@ public async Task Get_HybridConnectivityEndpointsGetCustom() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_HybridConnectivityEndpointsGetCustom() + public async Task Get_HybridConnectivityEndpointsGetDefault() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsGetCustom.json + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsGetDefault.json // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -92,65 +122,55 @@ public async Task Exists_HybridConnectivityEndpointsGetCustom() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EndpointResource string scope = "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EndpointResourceCollection collection = client.GetEndpointResources(scopeId); + EndpointResourceCollection collection = client.GetEndpointResources(new ResourceIdentifier(scope)); // invoke the operation - string endpointName = "custom"; - bool result = await collection.ExistsAsync(endpointName); + string endpointName = "default"; + EndpointResource result = await collection.GetAsync(endpointName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HybridConnectivityEndpointsGetCustom() + public async Task GetAll_HybridConnectivityEndpointsGet() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsGetCustom.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsList.json + // this example is just showing the usage of "Endpoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EndpointResource string scope = "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EndpointResourceCollection collection = client.GetEndpointResources(scopeId); + EndpointResourceCollection collection = client.GetEndpointResources(new ResourceIdentifier(scope)); - // invoke the operation - string endpointName = "custom"; - NullableResponse response = await collection.GetIfExistsAsync(endpointName); - EndpointResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EndpointResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EndpointResourceData resourceData = result.Data; + EndpointResourceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_HybridConnectivityEndpointsGetDefault() + public async Task Exists_HybridConnectivityEndpointsGetCustom() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsGetDefault.json + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsGetCustom.json // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -158,23 +178,15 @@ public async Task Get_HybridConnectivityEndpointsGetDefault() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EndpointResource string scope = "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EndpointResourceCollection collection = client.GetEndpointResources(scopeId); + EndpointResourceCollection collection = client.GetEndpointResources(new ResourceIdentifier(scope)); // invoke the operation - string endpointName = "default"; - EndpointResource result = await collection.GetAsync(endpointName); + string endpointName = "custom"; + bool result = await collection.ExistsAsync(endpointName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -189,13 +201,9 @@ public async Task Exists_HybridConnectivityEndpointsGetDefault() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EndpointResource string scope = "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EndpointResourceCollection collection = client.GetEndpointResources(scopeId); + EndpointResourceCollection collection = client.GetEndpointResources(new ResourceIdentifier(scope)); // invoke the operation string endpointName = "default"; @@ -206,9 +214,9 @@ public async Task Exists_HybridConnectivityEndpointsGetDefault() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HybridConnectivityEndpointsGetDefault() + public async Task GetIfExists_HybridConnectivityEndpointsGetCustom() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsGetDefault.json + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsGetCustom.json // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -216,16 +224,12 @@ public async Task GetIfExists_HybridConnectivityEndpointsGetDefault() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EndpointResource string scope = "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EndpointResourceCollection collection = client.GetEndpointResources(scopeId); + EndpointResourceCollection collection = client.GetEndpointResources(new ResourceIdentifier(scope)); // invoke the operation - string endpointName = "default"; + string endpointName = "custom"; NullableResponse response = await collection.GetIfExistsAsync(endpointName); EndpointResource result = response.HasValue ? response.Value : null; @@ -245,77 +249,37 @@ public async Task GetIfExists_HybridConnectivityEndpointsGetDefault() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_HybridConnectivityEndpointsPutCustom() - { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsPutCustom.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this EndpointResource - string scope = "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EndpointResourceCollection collection = client.GetEndpointResources(scopeId); - - // invoke the operation - string endpointName = "custom"; - EndpointResourceData data = new EndpointResourceData() - { - Properties = new HybridConnectivityEndpointProperties(EndpointType.Custom) - { - ResourceId = new ResourceIdentifier("/subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.Relay/namespaces/custom-relay-namespace"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); - EndpointResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_HybridConnectivityEndpointsPutDefault() + public async Task GetIfExists_HybridConnectivityEndpointsGetDefault() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsPutDefault.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/EndpointsGetDefault.json + // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this EndpointResource string scope = "subscriptions/f5bcc1d9-23af-4ae9-aca1-041d0f593a63/resourceGroups/hybridRG/providers/Microsoft.HybridCompute/machines/testMachine"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - EndpointResourceCollection collection = client.GetEndpointResources(scopeId); + EndpointResourceCollection collection = client.GetEndpointResources(new ResourceIdentifier(scope)); // invoke the operation string endpointName = "default"; - EndpointResourceData data = new EndpointResourceData() - { - Properties = new HybridConnectivityEndpointProperties(EndpointType.Default), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); - EndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(endpointName); + EndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EndpointResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EndpointResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_HybridConnectivityInventoryResourceCollection.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_HybridConnectivityInventoryResourceCollection.cs index 052005a08fec7..95132618b6d7e 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_HybridConnectivityInventoryResourceCollection.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_HybridConnectivityInventoryResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HybridConnectivityInventoryResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InventoryListBySolutionConfiguration() + public async Task Get_InventoryGet() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/Inventory_ListBySolutionConfiguration.json - // this example is just showing the usage of "Inventory_ListBySolutionConfiguration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/Inventory_Get.json + // this example is just showing the usage of "Inventory_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,32 +30,30 @@ public async Task GetAll_InventoryListBySolutionConfiguration() // this example assumes you already have this SolutionConfigurationResource created on azure // for more information of creating SolutionConfigurationResource, please refer to the document of SolutionConfigurationResource string resourceUri = "ymuj"; - string solutionConfiguration = "wsxt"; + string solutionConfiguration = "zarfsraogroxlaqjjnwixtn"; ResourceIdentifier solutionConfigurationResourceId = SolutionConfigurationResource.CreateResourceIdentifier(resourceUri, solutionConfiguration); SolutionConfigurationResource solutionConfiguration0 = client.GetSolutionConfigurationResource(solutionConfigurationResourceId); // get the collection of this HybridConnectivityInventoryResource HybridConnectivityInventoryResourceCollection collection = solutionConfiguration0.GetHybridConnectivityInventoryResources(); - // invoke the operation and iterate over the result - await foreach (HybridConnectivityInventoryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridConnectivityInventoryResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string inventoryId = "xofprmcboosrbd"; + HybridConnectivityInventoryResource result = await collection.GetAsync(inventoryId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridConnectivityInventoryResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_InventoryGet() + public async Task GetAll_InventoryListBySolutionConfiguration() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/Inventory_Get.json - // this example is just showing the usage of "Inventory_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/Inventory_ListBySolutionConfiguration.json + // this example is just showing the usage of "Inventory_ListBySolutionConfiguration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,22 +63,24 @@ public async Task Get_InventoryGet() // this example assumes you already have this SolutionConfigurationResource created on azure // for more information of creating SolutionConfigurationResource, please refer to the document of SolutionConfigurationResource string resourceUri = "ymuj"; - string solutionConfiguration = "zarfsraogroxlaqjjnwixtn"; + string solutionConfiguration = "wsxt"; ResourceIdentifier solutionConfigurationResourceId = SolutionConfigurationResource.CreateResourceIdentifier(resourceUri, solutionConfiguration); SolutionConfigurationResource solutionConfiguration0 = client.GetSolutionConfigurationResource(solutionConfigurationResourceId); // get the collection of this HybridConnectivityInventoryResource HybridConnectivityInventoryResourceCollection collection = solutionConfiguration0.GetHybridConnectivityInventoryResources(); - // invoke the operation - string inventoryId = "xofprmcboosrbd"; - HybridConnectivityInventoryResource result = await collection.GetAsync(inventoryId); + // invoke the operation and iterate over the result + await foreach (HybridConnectivityInventoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridConnectivityInventoryResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridConnectivityInventoryResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_PublicCloudConnectorCollection.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_PublicCloudConnectorCollection.cs index a6377c1c7e363..8cb03786a95f3 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_PublicCloudConnectorCollection.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_PublicCloudConnectorCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_PublicCloudConnectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PublicCloudConnectorsListByResourceGroup() + public async Task CreateOrUpdate_PublicCloudConnectorsCreateOrUpdate() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_ListByResourceGroup.json - // this example is just showing the usage of "PublicCloudConnectors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_CreateOrUpdate.json + // this example is just showing the usage of "PublicCloudConnectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_PublicCloudConnectorsListByResourceGroup() // get the collection of this PublicCloudConnectorResource PublicCloudConnectorCollection collection = resourceGroupResource.GetPublicCloudConnectors(); - // invoke the operation and iterate over the result - await foreach (PublicCloudConnectorResource item in collection.GetAllAsync()) + // invoke the operation + string publicCloudConnector = "advjwoakdusalamomg"; + PublicCloudConnectorData data = new PublicCloudConnectorData(new AzureLocation("jpiglusfxynfcewcjwvvnn")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicCloudConnectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new PublicCloudConnectorProperties(new AwsCloudProfile("snbnuxckevyqpm") + { + ExcludedAccounts = { "rwgqpukglvbqmogqcliqolucp" }, + IsOrganizationalAccount = true, + }, HybridConnectivityHostType.AWS), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicCloudConnector, data); + PublicCloudConnectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicCloudConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +95,10 @@ public async Task Get_PublicCloudConnectorsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PublicCloudConnectorsGet() + public async Task GetAll_PublicCloudConnectorsListByResourceGroup() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_Get.json - // this example is just showing the usage of "PublicCloudConnectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_ListByResourceGroup.json + // this example is just showing the usage of "PublicCloudConnectors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +115,22 @@ public async Task Exists_PublicCloudConnectorsGet() // get the collection of this PublicCloudConnectorResource PublicCloudConnectorCollection collection = resourceGroupResource.GetPublicCloudConnectors(); - // invoke the operation - string publicCloudConnector = "rzygvnpsnrdylwzdbsscjazvamyxmh"; - bool result = await collection.ExistsAsync(publicCloudConnector); + // invoke the operation and iterate over the result + await foreach (PublicCloudConnectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicCloudConnectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PublicCloudConnectorsGet() + public async Task Exists_PublicCloudConnectorsGet() { // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_Get.json // this example is just showing the usage of "PublicCloudConnectors_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +152,17 @@ public async Task GetIfExists_PublicCloudConnectorsGet() // invoke the operation string publicCloudConnector = "rzygvnpsnrdylwzdbsscjazvamyxmh"; - NullableResponse response = await collection.GetIfExistsAsync(publicCloudConnector); - PublicCloudConnectorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(publicCloudConnector); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicCloudConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PublicCloudConnectorsCreateOrUpdate() + public async Task GetIfExists_PublicCloudConnectorsGet() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_CreateOrUpdate.json - // this example is just showing the usage of "PublicCloudConnectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_Get.json + // this example is just showing the usage of "PublicCloudConnectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,29 +180,22 @@ public async Task CreateOrUpdate_PublicCloudConnectorsCreateOrUpdate() PublicCloudConnectorCollection collection = resourceGroupResource.GetPublicCloudConnectors(); // invoke the operation - string publicCloudConnector = "advjwoakdusalamomg"; - PublicCloudConnectorData data = new PublicCloudConnectorData(new AzureLocation("jpiglusfxynfcewcjwvvnn")) - { - Properties = new PublicCloudConnectorProperties(new AwsCloudProfile("snbnuxckevyqpm") - { - ExcludedAccounts = -{ -"rwgqpukglvbqmogqcliqolucp" -}, - IsOrganizationalAccount = true, - }, HybridConnectivityHostType.AWS), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicCloudConnector, data); - PublicCloudConnectorResource result = lro.Value; + string publicCloudConnector = "rzygvnpsnrdylwzdbsscjazvamyxmh"; + NullableResponse response = await collection.GetIfExistsAsync(publicCloudConnector); + PublicCloudConnectorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicCloudConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicCloudConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_PublicCloudConnectorResource.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_PublicCloudConnectorResource.cs index 57d788522afe3..97c5fe970122d 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_PublicCloudConnectorResource.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_PublicCloudConnectorResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HybridConnectivity.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridConnectivity.Samples { public partial class Sample_PublicCloudConnectorResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPublicCloudConnectors_PublicCloudConnectorsListBySubscription() - { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_ListBySubscription.json - // this example is just showing the usage of "PublicCloudConnectors_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5ACC4579-DB34-4C2F-8F8C-25061168F342"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PublicCloudConnectorResource item in subscriptionResource.GetPublicCloudConnectorsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicCloudConnectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_PublicCloudConnectorsGet() @@ -80,10 +48,10 @@ public async Task Get_PublicCloudConnectorsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PublicCloudConnectorsUpdate() + public async Task Delete_PublicCloudConnectorsDelete() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_Update.json - // this example is just showing the usage of "PublicCloudConnectors_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_Delete.json + // this example is just showing the usage of "PublicCloudConnectors_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,36 +62,22 @@ public async Task Update_PublicCloudConnectorsUpdate() // for more information of creating PublicCloudConnectorResource, please refer to the document of PublicCloudConnectorResource string subscriptionId = "5ACC4579-DB34-4C2F-8F8C-25061168F342"; string resourceGroupName = "rgpublicCloud"; - string publicCloudConnector = "svtirlbyqpepbzyessjenlueeznhg"; + string publicCloudConnector = "skcfyjvflkhibdywjay"; ResourceIdentifier publicCloudConnectorResourceId = PublicCloudConnectorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publicCloudConnector); PublicCloudConnectorResource publicCloudConnector0 = client.GetPublicCloudConnectorResource(publicCloudConnectorResourceId); // invoke the operation - PublicCloudConnectorPatch patch = new PublicCloudConnectorPatch() - { - AwsCloudExcludedAccounts = -{ -"zrbtd" -}, - Tags = -{ -}, - }; - PublicCloudConnectorResource result = await publicCloudConnector0.UpdateAsync(patch); + await publicCloudConnector0.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicCloudConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PublicCloudConnectorsDelete() + public async Task Update_PublicCloudConnectorsUpdate() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_Delete.json - // this example is just showing the usage of "PublicCloudConnectors_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_Update.json + // this example is just showing the usage of "PublicCloudConnectors_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,14 +88,23 @@ public async Task Delete_PublicCloudConnectorsDelete() // for more information of creating PublicCloudConnectorResource, please refer to the document of PublicCloudConnectorResource string subscriptionId = "5ACC4579-DB34-4C2F-8F8C-25061168F342"; string resourceGroupName = "rgpublicCloud"; - string publicCloudConnector = "skcfyjvflkhibdywjay"; + string publicCloudConnector = "svtirlbyqpepbzyessjenlueeznhg"; ResourceIdentifier publicCloudConnectorResourceId = PublicCloudConnectorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publicCloudConnector); PublicCloudConnectorResource publicCloudConnector0 = client.GetPublicCloudConnectorResource(publicCloudConnectorResourceId); // invoke the operation - await publicCloudConnector0.DeleteAsync(WaitUntil.Completed); + PublicCloudConnectorPatch patch = new PublicCloudConnectorPatch + { + AwsCloudExcludedAccounts = { "zrbtd" }, + Tags = { }, + }; + PublicCloudConnectorResource result = await publicCloudConnector0.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicCloudConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_ServiceConfigurationResource.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_ServiceConfigurationResource.cs index d6ed0eb5b9e96..f72c76f64a9f2 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_ServiceConfigurationResource.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_ServiceConfigurationResource.cs @@ -78,10 +78,10 @@ public async Task Get_HybridConnectivityEndpointsServiceconfigurationsGetWAC() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ServiceConfigurationsPatchSSH() + public async Task Delete_ServiceConfigurationsDeleteSSH() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsPatchSSH.json - // this example is just showing the usage of "ServiceConfigurations_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsDeleteSSH.json + // this example is just showing the usage of "ServiceConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,25 +97,17 @@ public async Task Update_ServiceConfigurationsPatchSSH() ServiceConfigurationResource serviceConfigurationResource = client.GetServiceConfigurationResource(serviceConfigurationResourceId); // invoke the operation - ServiceConfigurationResourcePatch patch = new ServiceConfigurationResourcePatch() - { - Port = 22L, - }; - ServiceConfigurationResource result = await serviceConfigurationResource.UpdateAsync(patch); + await serviceConfigurationResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceConfigurationResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ServiceConfigurationsDeleteSSH() + public async Task Update_ServiceConfigurationsPatchSSH() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsDeleteSSH.json - // this example is just showing the usage of "ServiceConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsPatchSSH.json + // this example is just showing the usage of "ServiceConfigurations_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,9 +123,17 @@ public async Task Delete_ServiceConfigurationsDeleteSSH() ServiceConfigurationResource serviceConfigurationResource = client.GetServiceConfigurationResource(serviceConfigurationResourceId); // invoke the operation - await serviceConfigurationResource.DeleteAsync(WaitUntil.Completed); + ServiceConfigurationResourcePatch patch = new ServiceConfigurationResourcePatch + { + Port = 22L, + }; + ServiceConfigurationResource result = await serviceConfigurationResource.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceConfigurationResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_ServiceConfigurationResourceCollection.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_ServiceConfigurationResourceCollection.cs index 6b89abbd4c539..a4535c7ed9a32 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_ServiceConfigurationResourceCollection.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_ServiceConfigurationResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceConfigurationResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetClustersExample() + public async Task CreateOrUpdate_ServiceConfigurationsPutSSH() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsList.json - // this example is just showing the usage of "ServiceConfigurations_ListByEndpointResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsPutSSH.json + // this example is just showing the usage of "ServiceConfigurations_CreateOrupdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,29 @@ public async Task GetAll_GetClustersExample() // get the collection of this ServiceConfigurationResource ServiceConfigurationResourceCollection collection = endpointResource.GetServiceConfigurationResources(); - // invoke the operation and iterate over the result - await foreach (ServiceConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string serviceConfigurationName = "SSH"; + ServiceConfigurationResourceData data = new ServiceConfigurationResourceData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceConfigurationResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServiceName = HybridConnectivityServiceName.SSH, + Port = 22L, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceConfigurationName, data); + ServiceConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceConfigurationResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_HybridConnectivityEndpointsServiceconfigurationsGetSSH() + public async Task CreateOrUpdate_ServiceConfigurationsPutWAC() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsGetSSH.json - // this example is just showing the usage of "ServiceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsPutWAC.json + // this example is just showing the usage of "ServiceConfigurations_CreateOrupdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,8 +78,14 @@ public async Task Get_HybridConnectivityEndpointsServiceconfigurationsGetSSH() ServiceConfigurationResourceCollection collection = endpointResource.GetServiceConfigurationResources(); // invoke the operation - string serviceConfigurationName = "SSH"; - ServiceConfigurationResource result = await collection.GetAsync(serviceConfigurationName); + string serviceConfigurationName = "WAC"; + ServiceConfigurationResourceData data = new ServiceConfigurationResourceData + { + ServiceName = HybridConnectivityServiceName.WAC, + Port = 6516L, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceConfigurationName, data); + ServiceConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,7 +96,7 @@ public async Task Get_HybridConnectivityEndpointsServiceconfigurationsGetSSH() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_HybridConnectivityEndpointsServiceconfigurationsGetSSH() + public async Task Get_HybridConnectivityEndpointsServiceconfigurationsGetSSH() { // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsGetSSH.json // this example is just showing the usage of "ServiceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,16 +118,20 @@ public async Task Exists_HybridConnectivityEndpointsServiceconfigurationsGetSSH( // invoke the operation string serviceConfigurationName = "SSH"; - bool result = await collection.ExistsAsync(serviceConfigurationName); + ServiceConfigurationResource result = await collection.GetAsync(serviceConfigurationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceConfigurationResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HybridConnectivityEndpointsServiceconfigurationsGetSSH() + public async Task Get_HybridConnectivityEndpointsServiceconfigurationsGetWAC() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsGetSSH.json + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsGetWAC.json // this example is just showing the usage of "ServiceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -136,30 +150,22 @@ public async Task GetIfExists_HybridConnectivityEndpointsServiceconfigurationsGe ServiceConfigurationResourceCollection collection = endpointResource.GetServiceConfigurationResources(); // invoke the operation - string serviceConfigurationName = "SSH"; - NullableResponse response = await collection.GetIfExistsAsync(serviceConfigurationName); - ServiceConfigurationResource result = response.HasValue ? response.Value : null; + string serviceConfigurationName = "WAC"; + ServiceConfigurationResource result = await collection.GetAsync(serviceConfigurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceConfigurationResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceConfigurationResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_HybridConnectivityEndpointsServiceconfigurationsGetWAC() + public async Task GetAll_GetClustersExample() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsGetWAC.json - // this example is just showing the usage of "ServiceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsList.json + // this example is just showing the usage of "ServiceConfigurations_ListByEndpointResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,22 +182,24 @@ public async Task Get_HybridConnectivityEndpointsServiceconfigurationsGetWAC() // get the collection of this ServiceConfigurationResource ServiceConfigurationResourceCollection collection = endpointResource.GetServiceConfigurationResources(); - // invoke the operation - string serviceConfigurationName = "WAC"; - ServiceConfigurationResource result = await collection.GetAsync(serviceConfigurationName); + // invoke the operation and iterate over the result + await foreach (ServiceConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceConfigurationResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceConfigurationResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_HybridConnectivityEndpointsServiceconfigurationsGetWAC() + public async Task Exists_HybridConnectivityEndpointsServiceconfigurationsGetSSH() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsGetWAC.json + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsGetSSH.json // this example is just showing the usage of "ServiceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -210,7 +218,7 @@ public async Task Exists_HybridConnectivityEndpointsServiceconfigurationsGetWAC( ServiceConfigurationResourceCollection collection = endpointResource.GetServiceConfigurationResources(); // invoke the operation - string serviceConfigurationName = "WAC"; + string serviceConfigurationName = "SSH"; bool result = await collection.ExistsAsync(serviceConfigurationName); Console.WriteLine($"Succeeded: {result}"); @@ -218,7 +226,7 @@ public async Task Exists_HybridConnectivityEndpointsServiceconfigurationsGetWAC( [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HybridConnectivityEndpointsServiceconfigurationsGetWAC() + public async Task Exists_HybridConnectivityEndpointsServiceconfigurationsGetWAC() { // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsGetWAC.json // this example is just showing the usage of "ServiceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -240,29 +248,17 @@ public async Task GetIfExists_HybridConnectivityEndpointsServiceconfigurationsGe // invoke the operation string serviceConfigurationName = "WAC"; - NullableResponse response = await collection.GetIfExistsAsync(serviceConfigurationName); - ServiceConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serviceConfigurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceConfigurationResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServiceConfigurationsPutSSH() + public async Task GetIfExists_HybridConnectivityEndpointsServiceconfigurationsGetSSH() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsPutSSH.json - // this example is just showing the usage of "ServiceConfigurations_CreateOrupdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsGetSSH.json + // this example is just showing the usage of "ServiceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -281,27 +277,29 @@ public async Task CreateOrUpdate_ServiceConfigurationsPutSSH() // invoke the operation string serviceConfigurationName = "SSH"; - ServiceConfigurationResourceData data = new ServiceConfigurationResourceData() - { - ServiceName = HybridConnectivityServiceName.SSH, - Port = 22L, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceConfigurationName, data); - ServiceConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(serviceConfigurationName); + ServiceConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceConfigurationResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceConfigurationResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServiceConfigurationsPutWAC() + public async Task GetIfExists_HybridConnectivityEndpointsServiceconfigurationsGetWAC() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsPutWAC.json - // this example is just showing the usage of "ServiceConfigurations_CreateOrupdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/stable/2024-12-01/examples/ServiceConfigurationsGetWAC.json + // this example is just showing the usage of "ServiceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -320,19 +318,21 @@ public async Task CreateOrUpdate_ServiceConfigurationsPutWAC() // invoke the operation string serviceConfigurationName = "WAC"; - ServiceConfigurationResourceData data = new ServiceConfigurationResourceData() - { - ServiceName = HybridConnectivityServiceName.WAC, - Port = 6516L, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceConfigurationName, data); - ServiceConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(serviceConfigurationName); + ServiceConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceConfigurationResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceConfigurationResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionConfigurationCollection.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionConfigurationCollection.cs index bbec2dadc3d13..dbe64ae9d7ba1 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionConfigurationCollection.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionConfigurationCollection.cs @@ -18,35 +18,37 @@ public partial class Sample_SolutionConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SolutionConfigurationsList() + public async Task CreateOrUpdate_SolutionConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionConfigurations_List.json - // this example is just showing the usage of "SolutionConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionConfigurations_CreateOrUpdate.json + // this example is just showing the usage of "SolutionConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SolutionConfigurationResource string resourceUri = "ymuj"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - SolutionConfigurationCollection collection = client.GetSolutionConfigurations(scopeId); + SolutionConfigurationCollection collection = client.GetSolutionConfigurations(new ResourceIdentifier(resourceUri)); - // invoke the operation and iterate over the result - await foreach (SolutionConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string solutionConfiguration = "keebwujt"; + SolutionConfigurationData data = new SolutionConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SolutionConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new SolutionConfigurationProperties("nmtqllkyohwtsthxaimsye") + { + SolutionSettings = { }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, solutionConfiguration, data); + SolutionConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SolutionConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -61,13 +63,9 @@ public async Task Get_SolutionConfigurationsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SolutionConfigurationResource string resourceUri = "ymuj"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - SolutionConfigurationCollection collection = client.GetSolutionConfigurations(scopeId); + SolutionConfigurationCollection collection = client.GetSolutionConfigurations(new ResourceIdentifier(resourceUri)); // invoke the operation string solutionConfiguration = "tks"; @@ -80,6 +78,35 @@ public async Task Get_SolutionConfigurationsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_SolutionConfigurationsList() + { + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionConfigurations_List.json + // this example is just showing the usage of "SolutionConfigurations_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this SolutionConfigurationResource + string resourceUri = "ymuj"; + SolutionConfigurationCollection collection = client.GetSolutionConfigurations(new ResourceIdentifier(resourceUri)); + + // invoke the operation and iterate over the result + await foreach (SolutionConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SolutionConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_SolutionConfigurationsGet() @@ -92,13 +119,9 @@ public async Task Exists_SolutionConfigurationsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SolutionConfigurationResource string resourceUri = "ymuj"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - SolutionConfigurationCollection collection = client.GetSolutionConfigurations(scopeId); + SolutionConfigurationCollection collection = client.GetSolutionConfigurations(new ResourceIdentifier(resourceUri)); // invoke the operation string solutionConfiguration = "tks"; @@ -119,13 +142,9 @@ public async Task GetIfExists_SolutionConfigurationsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SolutionConfigurationResource string resourceUri = "ymuj"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - SolutionConfigurationCollection collection = client.GetSolutionConfigurations(scopeId); + SolutionConfigurationCollection collection = client.GetSolutionConfigurations(new ResourceIdentifier(resourceUri)); // invoke the operation string solutionConfiguration = "tks"; @@ -145,46 +164,5 @@ public async Task GetIfExists_SolutionConfigurationsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SolutionConfigurationsCreateOrUpdate() - { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionConfigurations_CreateOrUpdate.json - // this example is just showing the usage of "SolutionConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this SolutionConfigurationResource - string resourceUri = "ymuj"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - SolutionConfigurationCollection collection = client.GetSolutionConfigurations(scopeId); - - // invoke the operation - string solutionConfiguration = "keebwujt"; - SolutionConfigurationData data = new SolutionConfigurationData() - { - Properties = new SolutionConfigurationProperties("nmtqllkyohwtsthxaimsye") - { - SolutionSettings = -{ -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, solutionConfiguration, data); - SolutionConfigurationResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SolutionConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionConfigurationResource.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionConfigurationResource.cs index 76d9eaa5eb6e7..4d9ec97be1921 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionConfigurationResource.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionConfigurationResource.cs @@ -47,10 +47,10 @@ public async Task Get_SolutionConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SolutionConfigurationsUpdate() + public async Task Delete_SolutionConfigurationsDelete() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionConfigurations_Update.json - // this example is just showing the usage of "SolutionConfigurations_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionConfigurations_Delete.json + // this example is just showing the usage of "SolutionConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,36 +60,22 @@ public async Task Update_SolutionConfigurationsUpdate() // this example assumes you already have this SolutionConfigurationResource created on azure // for more information of creating SolutionConfigurationResource, please refer to the document of SolutionConfigurationResource string resourceUri = "ymuj"; - string solutionConfiguration = "dxt"; + string solutionConfiguration = "stu"; ResourceIdentifier solutionConfigurationResourceId = SolutionConfigurationResource.CreateResourceIdentifier(resourceUri, solutionConfiguration); SolutionConfigurationResource solutionConfiguration0 = client.GetSolutionConfigurationResource(solutionConfigurationResourceId); // invoke the operation - SolutionConfigurationPatch patch = new SolutionConfigurationPatch() - { - Properties = new SolutionConfigurationPropertiesUpdate() - { - SolutionType = "myzljlstvmgkp", - SolutionSettings = -{ -}, - }, - }; - SolutionConfigurationResource result = await solutionConfiguration0.UpdateAsync(patch); + await solutionConfiguration0.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SolutionConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SolutionConfigurationsDelete() + public async Task Update_SolutionConfigurationsUpdate() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionConfigurations_Delete.json - // this example is just showing the usage of "SolutionConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionConfigurations_Update.json + // this example is just showing the usage of "SolutionConfigurations_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,14 +85,26 @@ public async Task Delete_SolutionConfigurationsDelete() // this example assumes you already have this SolutionConfigurationResource created on azure // for more information of creating SolutionConfigurationResource, please refer to the document of SolutionConfigurationResource string resourceUri = "ymuj"; - string solutionConfiguration = "stu"; + string solutionConfiguration = "dxt"; ResourceIdentifier solutionConfigurationResourceId = SolutionConfigurationResource.CreateResourceIdentifier(resourceUri, solutionConfiguration); SolutionConfigurationResource solutionConfiguration0 = client.GetSolutionConfigurationResource(solutionConfigurationResourceId); // invoke the operation - await solutionConfiguration0.DeleteAsync(WaitUntil.Completed); + SolutionConfigurationPatch patch = new SolutionConfigurationPatch + { + Properties = new SolutionConfigurationPropertiesUpdate + { + SolutionType = "myzljlstvmgkp", + SolutionSettings = { }, + }, + }; + SolutionConfigurationResource result = await solutionConfiguration0.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SolutionConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionTypeResource.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionTypeResource.cs index 66e204ebfaf00..7065bddc27001 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionTypeResource.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionTypeResource.cs @@ -9,44 +9,12 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridConnectivity.Samples { public partial class Sample_SolutionTypeResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSolutionTypeResources_SolutionTypesListBySubscription() - { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionTypes_ListBySubscription.json - // this example is just showing the usage of "SolutionTypes_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5ACC4579-DB34-4C2F-8F8C-25061168F342"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SolutionTypeResource item in subscriptionResource.GetSolutionTypeResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SolutionTypeResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_SolutionTypesGet() diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionTypeResourceCollection.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionTypeResourceCollection.cs index 51116b68f9d0e..a18c0abfad166 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionTypeResourceCollection.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SolutionTypeResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SolutionTypeResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SolutionTypesListByResourceGroup() + public async Task Get_SolutionTypesGet() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionTypes_ListByResourceGroup.json - // this example is just showing the usage of "SolutionTypes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionTypes_Get.json + // this example is just showing the usage of "SolutionTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_SolutionTypesListByResourceGroup() // get the collection of this SolutionTypeResource SolutionTypeResourceCollection collection = resourceGroupResource.GetSolutionTypeResources(); - // invoke the operation and iterate over the result - await foreach (SolutionTypeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SolutionTypeResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string solutionType = "lulzqllpu"; + SolutionTypeResource result = await collection.GetAsync(solutionType); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SolutionTypeResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SolutionTypesGet() + public async Task GetAll_SolutionTypesListByResourceGroup() { - // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionTypes_Get.json - // this example is just showing the usage of "SolutionTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionTypes_ListByResourceGroup.json + // this example is just showing the usage of "SolutionTypes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_SolutionTypesGet() // get the collection of this SolutionTypeResource SolutionTypeResourceCollection collection = resourceGroupResource.GetSolutionTypeResources(); - // invoke the operation - string solutionType = "lulzqllpu"; - SolutionTypeResource result = await collection.GetAsync(solutionType); + // invoke the operation and iterate over the result + await foreach (SolutionTypeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SolutionTypeResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SolutionTypeResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 0b6d561e9e2bc..e1f5848226e1d 100644 --- a/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/hybridconnectivity/Azure.ResourceManager.HybridConnectivity/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -38,19 +38,76 @@ public async Task PostGenerateAwsTemplate_GenerateAwsTemplatePost() // invoke the operation GenerateAwsTemplateContent content = new GenerateAwsTemplateContent(new ResourceIdentifier("pnxcfjidglabnwxit")) { - SolutionTypes = + SolutionTypes = {new SolutionTypeSettings("hjyownzpfxwiufmd") { -new SolutionTypeSettings("hjyownzpfxwiufmd") -{ -SolutionSettings = -{ -}, -} -}, +SolutionSettings = {}, +}}, }; BinaryData result = await subscriptionResource.PostGenerateAwsTemplateAsync(content); Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPublicCloudConnectors_PublicCloudConnectorsListBySubscription() + { + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/PublicCloudConnectors_ListBySubscription.json + // this example is just showing the usage of "PublicCloudConnectors_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5ACC4579-DB34-4C2F-8F8C-25061168F342"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PublicCloudConnectorResource item in subscriptionResource.GetPublicCloudConnectorsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicCloudConnectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSolutionTypeResources_SolutionTypesListBySubscription() + { + // Generated from example definition: specification/hybridconnectivity/resource-manager/Microsoft.HybridConnectivity/PublicCloud/stable/2024-12-01/examples/SolutionTypes_ListBySubscription.json + // this example is just showing the usage of "SolutionTypes_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5ACC4579-DB34-4C2F-8F8C-25061168F342"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SolutionTypeResource item in subscriptionResource.GetSolutionTypeResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SolutionTypeResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_ConnectedClusterCollection.cs b/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_ConnectedClusterCollection.cs index 34623a11628fb..99dbcf98ef736 100644 --- a/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_ConnectedClusterCollection.cs +++ b/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_ConnectedClusterCollection.cs @@ -44,9 +44,7 @@ public async Task CreateOrUpdate_CreateClusterExample() string clusterName = "testCluster"; ConnectedClusterData data = new ConnectedClusterData(new AzureLocation("East US"), new ManagedServiceIdentity("SystemAssigned"), "MIICYzCCAcygAwIBAgIBADANBgkqhkiG9w0BAQUFADAuMQswCQYDVQQGEwJVUzEMMAoGA1UEChMDSUJNMREwDwYDVQQLEwhMb2NhbCBDQTAeFw05OTEyMjIwNTAwMDBaFw0wMDEyMjMwNDU5NTlaMC4xCzAJBgNVBAYTAlVTMQwwCgYDVQQKEwNJQk0xETAPBgNVBAsTCExvY2FsIENBMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQD2bZEo7xGaX2/0GHkrNFZvlxBou9v1Jmt/PDiTMPve8r9FeJAQ0QdvFST/0JPQYD20rH0bimdDLgNdNynmyRoS2S/IInfpmf69iyc2G0TPyRvmHIiOZbdCd+YBHQi1adkj17NDcWj6S14tVurFX73zx0sNoMS79q3tuXKrDsxeuwIDAQABo4GQMIGNMEsGCVUdDwGG+EIBDQQ+EzxHZW5lcmF0ZWQgYnkgdGhlIFNlY3VyZVdheSBTZWN1cml0eSBTZXJ2ZXIgZm9yIE9TLzM5MCAoUkFDRikwDgYDVR0PAQH/BAQDAgAGMA8GA1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFJ3+ocRyCTJw067dLSwr/nalx6YMMA0GCSqGSIb3DQEBBQUAA4GBAMaQzt+zaj1GU77yzlr8iiMBXgdQrwsZZWJo5exnAucJAEYQZmOfyLiM D6oYq+ZnfvM0n8G/Y79q8nhwvuxpYOnRSAXFp6xSkrIOeZtJMY1h00LKp/JX3Ng1svZ2agE126JHsQ0bhzN5TKsYfbwfTwfjdWAGy6Vf1nYi/rO+ryMO") { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); ConnectedClusterResource result = lro.Value; @@ -86,9 +84,7 @@ public async Task CreateOrUpdate_CreateClusterPrivateLinkExample() { PrivateLinkState = PrivateLinkState.Enabled, PrivateLinkScopeResourceId = "/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/privateLinkScopes/privateLinkScopeName", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); ConnectedClusterResource result = lro.Value; @@ -135,10 +131,10 @@ public async Task Get_GetClusterExample() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetClusterExample() + public async Task GetAll_GetClustersExample() { - // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/GetClusterExample.json - // this example is just showing the usage of "ConnectedCluster_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/GetClustersByResourceGroupExample.json + // this example is just showing the usage of "ConnectedCluster_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -155,16 +151,22 @@ public async Task Exists_GetClusterExample() // get the collection of this ConnectedClusterResource ConnectedClusterCollection collection = resourceGroupResource.GetConnectedClusters(); - // invoke the operation - string clusterName = "testCluster"; - bool result = await collection.ExistsAsync(clusterName); + // invoke the operation and iterate over the result + await foreach (ConnectedClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetClusterExample() + public async Task Exists_GetClusterExample() { // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/GetClusterExample.json // this example is just showing the usage of "ConnectedCluster_Get" operation, for the dependent resources, they will have to be created separately. @@ -186,29 +188,17 @@ public async Task GetIfExists_GetClusterExample() // invoke the operation string clusterName = "testCluster"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - ConnectedClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetClustersExample() + public async Task GetIfExists_GetClusterExample() { - // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/GetClustersByResourceGroupExample.json - // this example is just showing the usage of "ConnectedCluster_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/GetClusterExample.json + // this example is just showing the usage of "ConnectedCluster_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -225,17 +215,23 @@ public async Task GetAll_GetClustersExample() // get the collection of this ConnectedClusterResource ConnectedClusterCollection collection = resourceGroupResource.GetConnectedClusters(); - // invoke the operation and iterate over the result - await foreach (ConnectedClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "testCluster"; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + ConnectedClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectedClusterData resourceData = item.Data; + ConnectedClusterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_ConnectedClusterResource.cs b/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_ConnectedClusterResource.cs index 1d7104f3ea9b0..fec288bb08cba 100644 --- a/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_ConnectedClusterResource.cs +++ b/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_ConnectedClusterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Kubernetes.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Kubernetes.Samples @@ -19,10 +18,10 @@ public partial class Sample_ConnectedClusterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateClusterExample() + public async Task Get_GetClusterExample() { - // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/UpdateClusterExample.json - // this example is just showing the usage of "ConnectedCluster_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/GetClusterExample.json + // this example is just showing the usage of "ConnectedCluster_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +37,7 @@ public async Task Update_UpdateClusterExample() ConnectedClusterResource connectedCluster = client.GetConnectedClusterResource(connectedClusterResourceId); // invoke the operation - ConnectedClusterPatch patch = new ConnectedClusterPatch() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ConnectedClusterResource result = await connectedCluster.UpdateAsync(patch); + ConnectedClusterResource result = await connectedCluster.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +48,10 @@ public async Task Update_UpdateClusterExample() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetClusterExample() + public async Task Delete_DeleteClusterExample() { - // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/GetClusterExample.json - // this example is just showing the usage of "ConnectedCluster_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/DeleteClusterExample.json + // this example is just showing the usage of "ConnectedCluster_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,21 +67,17 @@ public async Task Get_GetClusterExample() ConnectedClusterResource connectedCluster = client.GetConnectedClusterResource(connectedClusterResourceId); // invoke the operation - ConnectedClusterResource result = await connectedCluster.GetAsync(); + await connectedCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteClusterExample() + public async Task Update_UpdateClusterExample() { - // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/DeleteClusterExample.json - // this example is just showing the usage of "ConnectedCluster_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/UpdateClusterExample.json + // this example is just showing the usage of "ConnectedCluster_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +93,21 @@ public async Task Delete_DeleteClusterExample() ConnectedClusterResource connectedCluster = client.GetConnectedClusterResource(connectedClusterResourceId); // invoke the operation - await connectedCluster.DeleteAsync(WaitUntil.Completed); + ConnectedClusterPatch patch = new ConnectedClusterPatch + { + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ConnectedClusterResource result = await connectedCluster.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -218,36 +217,5 @@ public async Task GetClusterUserCredential_ListClusterUserCredentialNonAadExampl Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetConnectedClusters_GetClustersExample() - { - // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/GetClustersBySubscriptionExample.json - // this example is just showing the usage of "ConnectedCluster_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1bfbb5d0-917e-4346-9026-1d3b344417f5"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ConnectedClusterResource item in subscriptionResource.GetConnectedClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..c340cb11dc829 --- /dev/null +++ b/sdk/hybridkubernetes/Azure.ResourceManager.Kubernetes/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Kubernetes.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetConnectedClusters_GetClustersExample() + { + // Generated from example definition: specification/hybridkubernetes/resource-manager/Microsoft.Kubernetes/preview/2022-05-01-preview/examples/GetClustersBySubscriptionExample.json + // this example is just showing the usage of "ConnectedCluster_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1bfbb5d0-917e-4346-9026-1d3b344417f5"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ConnectedClusterResource item in subscriptionResource.GetConnectedClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactManifestCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactManifestCollection.cs index 9010dc2d053ee..663b980dfeaa4 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactManifestCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactManifestCollection.cs @@ -16,43 +16,6 @@ namespace Azure.ResourceManager.HybridNetwork.Samples { public partial class Sample_ArtifactManifestCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetArtifactManifestListResource() - { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactManifestListByArtifactStore.json - // this example is just showing the usage of "ArtifactManifests_ListByArtifactStore" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArtifactStoreResource created on azure - // for more information of creating ArtifactStoreResource, please refer to the document of ArtifactStoreResource - string subscriptionId = "subid"; - string resourceGroupName = "rg"; - string publisherName = "TestPublisher"; - string artifactStoreName = "TestArtifactStore"; - ResourceIdentifier artifactStoreResourceId = ArtifactStoreResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publisherName, artifactStoreName); - ArtifactStoreResource artifactStore = client.GetArtifactStoreResource(artifactStoreResourceId); - - // get the collection of this ArtifactManifestResource - ArtifactManifestCollection collection = artifactStore.GetArtifactManifests(); - - // invoke the operation and iterate over the result - await foreach (ArtifactManifestResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactManifestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateTheArtifactManifestResource() @@ -81,22 +44,19 @@ public async Task CreateOrUpdate_CreateOrUpdateTheArtifactManifestResource() string artifactManifestName = "TestManifest"; ArtifactManifestData data = new ArtifactManifestData(new AzureLocation("eastus")) { - Properties = new ArtifactManifestPropertiesFormat() + Properties = new ArtifactManifestPropertiesFormat { - Artifacts = -{ -new ManifestArtifactFormat() + Artifacts = {new ManifestArtifactFormat { ArtifactName = "fed-rbac", ArtifactType = ArtifactType.OCIArtifact, ArtifactVersion = "1.0.0", -},new ManifestArtifactFormat() +}, new ManifestArtifactFormat { ArtifactName = "nginx", ArtifactType = ArtifactType.OCIArtifact, ArtifactVersion = "v1", -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, artifactManifestName, data); @@ -144,6 +104,43 @@ public async Task Get_GetAArtifactManifestResource() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetArtifactManifestListResource() + { + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactManifestListByArtifactStore.json + // this example is just showing the usage of "ArtifactManifests_ListByArtifactStore" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ArtifactStoreResource created on azure + // for more information of creating ArtifactStoreResource, please refer to the document of ArtifactStoreResource + string subscriptionId = "subid"; + string resourceGroupName = "rg"; + string publisherName = "TestPublisher"; + string artifactStoreName = "TestArtifactStore"; + ResourceIdentifier artifactStoreResourceId = ArtifactStoreResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publisherName, artifactStoreName); + ArtifactStoreResource artifactStore = client.GetArtifactStoreResource(artifactStoreResourceId); + + // get the collection of this ArtifactManifestResource + ArtifactManifestCollection collection = artifactStore.GetArtifactManifests(); + + // invoke the operation and iterate over the result + await foreach (ArtifactManifestResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactManifestData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAArtifactManifestResource() diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactManifestResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactManifestResource.cs index f61eec4cec4ee..9d0b85a9c32af 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactManifestResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactManifestResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ArtifactManifestResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAArtifactManifestResource() + public async Task Get_GetAArtifactManifestResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactManifestDelete.json - // this example is just showing the usage of "ArtifactManifests_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactManifestGet.json + // this example is just showing the usage of "ArtifactManifests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteAArtifactManifestResource() ArtifactManifestResource artifactManifest = client.GetArtifactManifestResource(artifactManifestResourceId); // invoke the operation - await artifactManifest.DeleteAsync(WaitUntil.Completed); + ArtifactManifestResource result = await artifactManifest.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactManifestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAArtifactManifestResource() + public async Task Delete_DeleteAArtifactManifestResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactManifestGet.json - // this example is just showing the usage of "ArtifactManifests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactManifestDelete.json + // this example is just showing the usage of "ArtifactManifests_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetAArtifactManifestResource() ArtifactManifestResource artifactManifest = client.GetArtifactManifestResource(artifactManifestResourceId); // invoke the operation - ArtifactManifestResource result = await artifactManifest.GetAsync(); + await artifactManifest.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactManifestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,12 +99,12 @@ public async Task Update_UpdateAArtifactManifestResourceTags() ArtifactManifestResource artifactManifest = client.GetArtifactManifestResource(artifactManifestResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArtifactManifestResource result = await artifactManifest.UpdateAsync(tagsObject); @@ -167,7 +167,7 @@ public async Task UpdateState_UpdateArtifactManifestState() ArtifactManifestResource artifactManifest = client.GetArtifactManifestResource(artifactManifestResourceId); // invoke the operation - ArtifactManifestUpdateState artifactManifestUpdateState = new ArtifactManifestUpdateState() + ArtifactManifestUpdateState artifactManifestUpdateState = new ArtifactManifestUpdateState { ArtifactManifestState = ArtifactManifestState.Uploaded, }; diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactStoreCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactStoreCollection.cs index 59ceed6a5e9f6..88536c9d8095b 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactStoreCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactStoreCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.HybridNetwork.Samples { public partial class Sample_ArtifactStoreCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetApplicationGroupsUnderAPublisherResource() - { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactStoresListByPublisherName.json - // this example is just showing the usage of "ArtifactStores_ListByPublisher" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PublisherResource created on azure - // for more information of creating PublisherResource, please refer to the document of PublisherResource - string subscriptionId = "subid"; - string resourceGroupName = "rg"; - string publisherName = "TestPublisher"; - ResourceIdentifier publisherResourceId = PublisherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publisherName); - PublisherResource publisher = client.GetPublisherResource(publisherResourceId); - - // get the collection of this ArtifactStoreResource - ArtifactStoreCollection collection = publisher.GetArtifactStores(); - - // invoke the operation and iterate over the result - await foreach (ArtifactStoreResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactStoreData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateAnArtifactStoreOfPublisherResource() @@ -79,11 +43,11 @@ public async Task CreateOrUpdate_CreateOrUpdateAnArtifactStoreOfPublisherResourc string artifactStoreName = "TestArtifactStore"; ArtifactStoreData data = new ArtifactStoreData(new AzureLocation("eastus")) { - Properties = new ArtifactStorePropertiesFormat() + Properties = new ArtifactStorePropertiesFormat { StoreType = ArtifactStoreType.AzureContainerRegistry, ReplicationStrategy = ArtifactReplicationStrategy.SingleReplication, - ManagedResourceGroupConfiguration = new ArtifactStorePropertiesFormatManagedResourceGroupConfiguration() + ManagedResourceGroupConfiguration = new ArtifactStorePropertiesFormatManagedResourceGroupConfiguration { Name = "testRg", Location = new AzureLocation("eastus"), @@ -134,6 +98,42 @@ public async Task Get_GetAArtifactStoreResource() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetApplicationGroupsUnderAPublisherResource() + { + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactStoresListByPublisherName.json + // this example is just showing the usage of "ArtifactStores_ListByPublisher" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PublisherResource created on azure + // for more information of creating PublisherResource, please refer to the document of PublisherResource + string subscriptionId = "subid"; + string resourceGroupName = "rg"; + string publisherName = "TestPublisher"; + ResourceIdentifier publisherResourceId = PublisherResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publisherName); + PublisherResource publisher = client.GetPublisherResource(publisherResourceId); + + // get the collection of this ArtifactStoreResource + ArtifactStoreCollection collection = publisher.GetArtifactStores(); + + // invoke the operation and iterate over the result + await foreach (ArtifactStoreResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactStoreData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAArtifactStoreResource() diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactStoreResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactStoreResource.cs index be7849d215d19..194486bd78d98 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactStoreResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ArtifactStoreResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ArtifactStoreResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAArtifactStoreOfPublisherResource() + public async Task Get_GetAArtifactStoreResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactStoreDelete.json - // this example is just showing the usage of "ArtifactStores_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactStoreGet.json + // this example is just showing the usage of "ArtifactStores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +33,26 @@ public async Task Delete_DeleteAArtifactStoreOfPublisherResource() string subscriptionId = "subid"; string resourceGroupName = "rg"; string publisherName = "TestPublisher"; - string artifactStoreName = "TestArtifactStore"; + string artifactStoreName = "TestArtifactStoreName"; ResourceIdentifier artifactStoreResourceId = ArtifactStoreResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publisherName, artifactStoreName); ArtifactStoreResource artifactStore = client.GetArtifactStoreResource(artifactStoreResourceId); // invoke the operation - await artifactStore.DeleteAsync(WaitUntil.Completed); + ArtifactStoreResource result = await artifactStore.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactStoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAArtifactStoreResource() + public async Task Delete_DeleteAArtifactStoreOfPublisherResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactStoreGet.json - // this example is just showing the usage of "ArtifactStores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ArtifactStoreDelete.json + // this example is just showing the usage of "ArtifactStores_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,14 @@ public async Task Get_GetAArtifactStoreResource() string subscriptionId = "subid"; string resourceGroupName = "rg"; string publisherName = "TestPublisher"; - string artifactStoreName = "TestArtifactStoreName"; + string artifactStoreName = "TestArtifactStore"; ResourceIdentifier artifactStoreResourceId = ArtifactStoreResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publisherName, artifactStoreName); ArtifactStoreResource artifactStore = client.GetArtifactStoreResource(artifactStoreResourceId); // invoke the operation - ArtifactStoreResource result = await artifactStore.GetAsync(); + await artifactStore.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactStoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_UpdateArtifactStoreResourceTags() ArtifactStoreResource artifactStore = client.GetArtifactStoreResource(artifactStoreResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArtifactStoreResource result = await artifactStore.UpdateAsync(tagsObject); @@ -198,7 +198,7 @@ public async Task UpdateStateProxyArtifact_UpdateAnArtifactState() // invoke the operation string artifactVersionName = "1.0.0"; string artifactName = "fedrbac"; - ArtifactChangeState artifactChangeState = new ArtifactChangeState() + ArtifactChangeState artifactChangeState = new ArtifactChangeState { ArtifactState = ArtifactState.Deprecated, }; diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ComponentCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ComponentCollection.cs index 0dd4179eb96c8..661a29aa95313 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ComponentCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ComponentCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetComponentResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetComponentResource() + public async Task GetAll_ListComponentsInNetworkFunction() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ComponentGet.json - // this example is just showing the usage of "Components_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ComponentListByNetworkFunction.json + // this example is just showing the usage of "Components_ListByNetworkFunction" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetComponentResource() // get the collection of this ComponentResource ComponentCollection collection = networkFunction.GetComponents(); - // invoke the operation - string componentName = "testComponent"; - bool result = await collection.ExistsAsync(componentName); + // invoke the operation and iterate over the result + await foreach (ComponentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ComponentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetComponentResource() + public async Task Exists_GetComponentResource() { // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ComponentGet.json // this example is just showing the usage of "Components_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetComponentResource() // invoke the operation string componentName = "testComponent"; - NullableResponse response = await collection.GetIfExistsAsync(componentName); - ComponentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(componentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListComponentsInNetworkFunction() + public async Task GetIfExists_GetComponentResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ComponentListByNetworkFunction.json - // this example is just showing the usage of "Components_ListByNetworkFunction" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ComponentGet.json + // this example is just showing the usage of "Components_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ListComponentsInNetworkFunction() // get the collection of this ComponentResource ComponentCollection collection = networkFunction.GetComponents(); - // invoke the operation and iterate over the result - await foreach (ComponentResource item in collection.GetAllAsync()) + // invoke the operation + string componentName = "testComponent"; + NullableResponse response = await collection.GetIfExistsAsync(componentName); + ComponentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ComponentData resourceData = item.Data; + ComponentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupSchemaCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupSchemaCollection.cs index f45d136c02f3c..519fba22eb531 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupSchemaCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupSchemaCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ConfigurationGroupSchemaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetNetworkFunctionDefinitionGroupsUnderPublisherResource() + public async Task CreateOrUpdate_CreateOrUpdateTheNetworkFunctionDefinitionGroup() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupSchemaListByPublisherName.json - // this example is just showing the usage of "ConfigurationGroupSchemas_ListByPublisher" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupSchemaCreate.json + // this example is just showing the usage of "ConfigurationGroupSchemas_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,32 @@ public async Task GetAll_GetNetworkFunctionDefinitionGroupsUnderPublisherResourc // get the collection of this ConfigurationGroupSchemaResource ConfigurationGroupSchemaCollection collection = publisher.GetConfigurationGroupSchemas(); - // invoke the operation and iterate over the result - await foreach (ConfigurationGroupSchemaResource item in collection.GetAllAsync()) + // invoke the operation + string configurationGroupSchemaName = "testConfigurationGroupSchema"; + ConfigurationGroupSchemaData data = new ConfigurationGroupSchemaData(new AzureLocation("westUs2")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfigurationGroupSchemaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new ConfigurationGroupSchemaPropertiesFormat + { + Description = "Schema with no secrets", + SchemaDefinition = "{\"type\":\"object\",\"properties\":{\"interconnect-groups\":{\"type\":\"object\",\"properties\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"international-interconnects\":{\"type\":\"array\",\"item\":{\"type\":\"string\"}},\"domestic-interconnects\":{\"type\":\"array\",\"item\":{\"type\":\"string\"}}}}},\"interconnect-group-assignments\":{\"type\":\"object\",\"properties\":{\"type\":\"object\",\"properties\":{\"ssc\":{\"type\":\"string\"},\"interconnects-interconnects\":{\"type\":\"string\"}}}}},\"required\":[\"interconnect-groups\",\"interconnect-group-assignments\"]}", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationGroupSchemaName, data); + ConfigurationGroupSchemaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfigurationGroupSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateTheNetworkFunctionDefinitionGroup() + public async Task Get_GetANetworkFunctionDefinitionGroupResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupSchemaCreate.json - // this example is just showing the usage of "ConfigurationGroupSchemas_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupSchemaGet.json + // this example is just showing the usage of "ConfigurationGroupSchemas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,16 +84,7 @@ public async Task CreateOrUpdate_CreateOrUpdateTheNetworkFunctionDefinitionGroup // invoke the operation string configurationGroupSchemaName = "testConfigurationGroupSchema"; - ConfigurationGroupSchemaData data = new ConfigurationGroupSchemaData(new AzureLocation("westUs2")) - { - Properties = new ConfigurationGroupSchemaPropertiesFormat() - { - Description = "Schema with no secrets", - SchemaDefinition = "{\"type\":\"object\",\"properties\":{\"interconnect-groups\":{\"type\":\"object\",\"properties\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"international-interconnects\":{\"type\":\"array\",\"item\":{\"type\":\"string\"}},\"domestic-interconnects\":{\"type\":\"array\",\"item\":{\"type\":\"string\"}}}}},\"interconnect-group-assignments\":{\"type\":\"object\",\"properties\":{\"type\":\"object\",\"properties\":{\"ssc\":{\"type\":\"string\"},\"interconnects-interconnects\":{\"type\":\"string\"}}}}},\"required\":[\"interconnect-groups\",\"interconnect-group-assignments\"]}", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationGroupSchemaName, data); - ConfigurationGroupSchemaResource result = lro.Value; + ConfigurationGroupSchemaResource result = await collection.GetAsync(configurationGroupSchemaName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -97,10 +95,10 @@ public async Task CreateOrUpdate_CreateOrUpdateTheNetworkFunctionDefinitionGroup [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetANetworkFunctionDefinitionGroupResource() + public async Task GetAll_GetNetworkFunctionDefinitionGroupsUnderPublisherResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupSchemaGet.json - // this example is just showing the usage of "ConfigurationGroupSchemas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupSchemaListByPublisherName.json + // this example is just showing the usage of "ConfigurationGroupSchemas_ListByPublisher" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,15 +116,17 @@ public async Task Get_GetANetworkFunctionDefinitionGroupResource() // get the collection of this ConfigurationGroupSchemaResource ConfigurationGroupSchemaCollection collection = publisher.GetConfigurationGroupSchemas(); - // invoke the operation - string configurationGroupSchemaName = "testConfigurationGroupSchema"; - ConfigurationGroupSchemaResource result = await collection.GetAsync(configurationGroupSchemaName); + // invoke the operation and iterate over the result + await foreach (ConfigurationGroupSchemaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfigurationGroupSchemaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfigurationGroupSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupSchemaResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupSchemaResource.cs index ed3c9e822356f..5cd3f471c01bf 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupSchemaResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupSchemaResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ConfigurationGroupSchemaResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteANetworkFunctionGroupResource() + public async Task Get_GetANetworkFunctionDefinitionGroupResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupSchemaDelete.json - // this example is just showing the usage of "ConfigurationGroupSchemas_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupSchemaGet.json + // this example is just showing the usage of "ConfigurationGroupSchemas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteANetworkFunctionGroupResource() ConfigurationGroupSchemaResource configurationGroupSchema = client.GetConfigurationGroupSchemaResource(configurationGroupSchemaResourceId); // invoke the operation - await configurationGroupSchema.DeleteAsync(WaitUntil.Completed); + ConfigurationGroupSchemaResource result = await configurationGroupSchema.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfigurationGroupSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetANetworkFunctionDefinitionGroupResource() + public async Task Delete_DeleteANetworkFunctionGroupResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupSchemaGet.json - // this example is just showing the usage of "ConfigurationGroupSchemas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupSchemaDelete.json + // this example is just showing the usage of "ConfigurationGroupSchemas_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetANetworkFunctionDefinitionGroupResource() ConfigurationGroupSchemaResource configurationGroupSchema = client.GetConfigurationGroupSchemaResource(configurationGroupSchemaResourceId); // invoke the operation - ConfigurationGroupSchemaResource result = await configurationGroupSchema.GetAsync(); + await configurationGroupSchema.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfigurationGroupSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_CreateOrUpdateTheConfigurationGroupSchemaResource() ConfigurationGroupSchemaResource configurationGroupSchema = client.GetConfigurationGroupSchemaResource(configurationGroupSchemaResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ConfigurationGroupSchemaResource result = await configurationGroupSchema.UpdateAsync(tagsObject); @@ -135,7 +135,7 @@ public async Task UpdateState_UpdateNetworkServiceDesignVersionState() ConfigurationGroupSchemaResource configurationGroupSchema = client.GetConfigurationGroupSchemaResource(configurationGroupSchemaResourceId); // invoke the operation - ConfigurationGroupSchemaVersionUpdateState configurationGroupSchemaVersionUpdateState = new ConfigurationGroupSchemaVersionUpdateState() + ConfigurationGroupSchemaVersionUpdateState configurationGroupSchemaVersionUpdateState = new ConfigurationGroupSchemaVersionUpdateState { VersionState = VersionState.Active, }; diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupValueCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupValueCollection.cs index 77f311509dc30..8e8c16bf48a91 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupValueCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupValueCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ConfigurationGroupValueCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetHybridConfigurationGroup() + public async Task CreateOrUpdate_CreateOrUpdateConfigurationGroupValue() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueGet.json - // this example is just showing the usage of "ConfigurationGroupValues_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueCreate.json + // this example is just showing the usage of "ConfigurationGroupValues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,19 @@ public async Task Get_GetHybridConfigurationGroup() // invoke the operation string configurationGroupValueName = "testConfigurationGroupValue"; - ConfigurationGroupValueResource result = await collection.GetAsync(configurationGroupValueName); + ConfigurationGroupValueData data = new ConfigurationGroupValueData(new AzureLocation("eastus")) + { + Properties = new ConfigurationValueWithoutSecrets + { + ConfigurationValue = "{\"interconnect-groups\":{\"stripe-one\":{\"name\":\"Stripe one\",\"international-interconnects\":[\"france\",\"germany\"],\"domestic-interconnects\":[\"birmingham\",\"edinburgh\"]},\"stripe-two\":{\"name\":\"Stripe two\",\"international-interconnects\":[\"germany\",\"italy\"],\"domestic-interconnects\":[\"edinburgh\",\"london\"]}},\"interconnect-group-assignments\":{\"ssc-one\":{\"ssc\":\"SSC 1\",\"interconnects\":\"stripe-one\"},\"ssc-two\":{\"ssc\":\"SSC 2\",\"interconnects\":\"stripe-two\"}}}", + ConfigurationGroupSchemaResourceReference = new OpenDeploymentResourceReference + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/testRG/providers/microsoft.hybridnetwork/publishers/testPublisher/configurationGroupSchemas/testConfigurationGroupSchemaName"), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationGroupValueName, data); + ConfigurationGroupValueResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +64,10 @@ public async Task Get_GetHybridConfigurationGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetHybridConfigurationGroup() + public async Task CreateOrUpdate_CreateOrUpdateConfigurationGroupValueWithSecrets() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueGet.json - // this example is just showing the usage of "ConfigurationGroupValues_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueCreateSecret.json + // this example is just showing the usage of "ConfigurationGroupValues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,17 +86,33 @@ public async Task Exists_GetHybridConfigurationGroup() // invoke the operation string configurationGroupValueName = "testConfigurationGroupValue"; - bool result = await collection.ExistsAsync(configurationGroupValueName); + ConfigurationGroupValueData data = new ConfigurationGroupValueData(new AzureLocation("eastus")) + { + Properties = new ConfigurationValueWithSecrets + { + SecretConfigurationValue = "{\"interconnect-groups\":{\"stripe-one\":{\"name\":\"Stripe one\",\"international-interconnects\":[\"france\",\"germany\"],\"domestic-interconnects\":[\"birmingham\",\"edinburgh\"]},\"stripe-two\":{\"name\":\"Stripe two\",\"international-interconnects\":[\"germany\",\"italy\"],\"domestic-interconnects\":[\"edinburgh\",\"london\"]}},\"interconnect-group-assignments\":{\"ssc-one\":{\"ssc\":\"SSC 1\",\"interconnects\":\"stripe-one\"},\"ssc-two\":{\"ssc\":\"SSC 2\",\"interconnects\":\"stripe-two\"}}}", + ConfigurationGroupSchemaResourceReference = new OpenDeploymentResourceReference + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/testRG/providers/microsoft.hybridnetwork/publishers/testPublisher/configurationGroupSchemas/testConfigurationGroupSchemaName"), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationGroupValueName, data); + ConfigurationGroupValueResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfigurationGroupValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetHybridConfigurationGroup() + public async Task CreateOrUpdate_CreateOrUpdateFirstPartyConfigurationGroupValue() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueGet.json - // this example is just showing the usage of "ConfigurationGroupValues_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueFirstPartyCreate.json + // this example is just showing the usage of "ConfigurationGroupValues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,29 +131,33 @@ public async Task GetIfExists_GetHybridConfigurationGroup() // invoke the operation string configurationGroupValueName = "testConfigurationGroupValue"; - NullableResponse response = await collection.GetIfExistsAsync(configurationGroupValueName); - ConfigurationGroupValueResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + ConfigurationGroupValueData data = new ConfigurationGroupValueData(new AzureLocation("eastus")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfigurationGroupValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new ConfigurationValueWithoutSecrets + { + ConfigurationValue = "{\"interconnect-groups\":{\"stripe-one\":{\"name\":\"Stripe one\",\"international-interconnects\":[\"france\",\"germany\"],\"domestic-interconnects\":[\"birmingham\",\"edinburgh\"]},\"stripe-two\":{\"name\":\"Stripe two\",\"international-interconnects\":[\"germany\",\"italy\"],\"domestic-interconnects\":[\"edinburgh\",\"london\"]}},\"interconnect-group-assignments\":{\"ssc-one\":{\"ssc\":\"SSC 1\",\"interconnects\":\"stripe-one\"},\"ssc-two\":{\"ssc\":\"SSC 2\",\"interconnects\":\"stripe-two\"}}}", + ConfigurationGroupSchemaResourceReference = new SecretDeploymentResourceReference + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/testRG/providers/microsoft.hybridnetwork/publishers/testPublisher/configurationGroupSchemas/testConfigurationGroupSchemaName"), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationGroupValueName, data); + ConfigurationGroupValueResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfigurationGroupValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateConfigurationGroupValue() + public async Task Get_GetHybridConfigurationGroup() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueCreate.json - // this example is just showing the usage of "ConfigurationGroupValues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueGet.json + // this example is just showing the usage of "ConfigurationGroupValues_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,19 +176,7 @@ public async Task CreateOrUpdate_CreateOrUpdateConfigurationGroupValue() // invoke the operation string configurationGroupValueName = "testConfigurationGroupValue"; - ConfigurationGroupValueData data = new ConfigurationGroupValueData(new AzureLocation("eastus")) - { - Properties = new ConfigurationValueWithoutSecrets() - { - ConfigurationValue = "{\"interconnect-groups\":{\"stripe-one\":{\"name\":\"Stripe one\",\"international-interconnects\":[\"france\",\"germany\"],\"domestic-interconnects\":[\"birmingham\",\"edinburgh\"]},\"stripe-two\":{\"name\":\"Stripe two\",\"international-interconnects\":[\"germany\",\"italy\"],\"domestic-interconnects\":[\"edinburgh\",\"london\"]}},\"interconnect-group-assignments\":{\"ssc-one\":{\"ssc\":\"SSC 1\",\"interconnects\":\"stripe-one\"},\"ssc-two\":{\"ssc\":\"SSC 2\",\"interconnects\":\"stripe-two\"}}}", - ConfigurationGroupSchemaResourceReference = new OpenDeploymentResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/testRG/providers/microsoft.hybridnetwork/publishers/testPublisher/configurationGroupSchemas/testConfigurationGroupSchemaName"), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationGroupValueName, data); - ConfigurationGroupValueResource result = lro.Value; + ConfigurationGroupValueResource result = await collection.GetAsync(configurationGroupValueName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -167,10 +187,10 @@ public async Task CreateOrUpdate_CreateOrUpdateConfigurationGroupValue() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateConfigurationGroupValueWithSecrets() + public async Task GetAll_ListAllHybridNetworkConfigurationGroupValuesInASubscription() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueCreateSecret.json - // this example is just showing the usage of "ConfigurationGroupValues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueListByResourceGroup.json + // this example is just showing the usage of "ConfigurationGroupValues_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,35 +207,25 @@ public async Task CreateOrUpdate_CreateOrUpdateConfigurationGroupValueWithSecret // get the collection of this ConfigurationGroupValueResource ConfigurationGroupValueCollection collection = resourceGroupResource.GetConfigurationGroupValues(); - // invoke the operation - string configurationGroupValueName = "testConfigurationGroupValue"; - ConfigurationGroupValueData data = new ConfigurationGroupValueData(new AzureLocation("eastus")) + // invoke the operation and iterate over the result + await foreach (ConfigurationGroupValueResource item in collection.GetAllAsync()) { - Properties = new ConfigurationValueWithSecrets() - { - SecretConfigurationValue = "{\"interconnect-groups\":{\"stripe-one\":{\"name\":\"Stripe one\",\"international-interconnects\":[\"france\",\"germany\"],\"domestic-interconnects\":[\"birmingham\",\"edinburgh\"]},\"stripe-two\":{\"name\":\"Stripe two\",\"international-interconnects\":[\"germany\",\"italy\"],\"domestic-interconnects\":[\"edinburgh\",\"london\"]}},\"interconnect-group-assignments\":{\"ssc-one\":{\"ssc\":\"SSC 1\",\"interconnects\":\"stripe-one\"},\"ssc-two\":{\"ssc\":\"SSC 2\",\"interconnects\":\"stripe-two\"}}}", - ConfigurationGroupSchemaResourceReference = new OpenDeploymentResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/testRG/providers/microsoft.hybridnetwork/publishers/testPublisher/configurationGroupSchemas/testConfigurationGroupSchemaName"), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationGroupValueName, data); - ConfigurationGroupValueResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfigurationGroupValueData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfigurationGroupValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateFirstPartyConfigurationGroupValue() + public async Task Exists_GetHybridConfigurationGroup() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueFirstPartyCreate.json - // this example is just showing the usage of "ConfigurationGroupValues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueGet.json + // this example is just showing the usage of "ConfigurationGroupValues_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -234,33 +244,17 @@ public async Task CreateOrUpdate_CreateOrUpdateFirstPartyConfigurationGroupValue // invoke the operation string configurationGroupValueName = "testConfigurationGroupValue"; - ConfigurationGroupValueData data = new ConfigurationGroupValueData(new AzureLocation("eastus")) - { - Properties = new ConfigurationValueWithoutSecrets() - { - ConfigurationValue = "{\"interconnect-groups\":{\"stripe-one\":{\"name\":\"Stripe one\",\"international-interconnects\":[\"france\",\"germany\"],\"domestic-interconnects\":[\"birmingham\",\"edinburgh\"]},\"stripe-two\":{\"name\":\"Stripe two\",\"international-interconnects\":[\"germany\",\"italy\"],\"domestic-interconnects\":[\"edinburgh\",\"london\"]}},\"interconnect-group-assignments\":{\"ssc-one\":{\"ssc\":\"SSC 1\",\"interconnects\":\"stripe-one\"},\"ssc-two\":{\"ssc\":\"SSC 2\",\"interconnects\":\"stripe-two\"}}}", - ConfigurationGroupSchemaResourceReference = new SecretDeploymentResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/testRG/providers/microsoft.hybridnetwork/publishers/testPublisher/configurationGroupSchemas/testConfigurationGroupSchemaName"), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationGroupValueName, data); - ConfigurationGroupValueResource result = lro.Value; + bool result = await collection.ExistsAsync(configurationGroupValueName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfigurationGroupValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllHybridNetworkConfigurationGroupValuesInASubscription() + public async Task GetIfExists_GetHybridConfigurationGroup() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueListByResourceGroup.json - // this example is just showing the usage of "ConfigurationGroupValues_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueGet.json + // this example is just showing the usage of "ConfigurationGroupValues_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -277,17 +271,23 @@ public async Task GetAll_ListAllHybridNetworkConfigurationGroupValuesInASubscrip // get the collection of this ConfigurationGroupValueResource ConfigurationGroupValueCollection collection = resourceGroupResource.GetConfigurationGroupValues(); - // invoke the operation and iterate over the result - await foreach (ConfigurationGroupValueResource item in collection.GetAllAsync()) + // invoke the operation + string configurationGroupValueName = "testConfigurationGroupValue"; + NullableResponse response = await collection.GetIfExistsAsync(configurationGroupValueName); + ConfigurationGroupValueResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConfigurationGroupValueData resourceData = item.Data; + ConfigurationGroupValueData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupValueResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupValueResource.cs index a3f26ef2406a1..e7d69b4c13d13 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupValueResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_ConfigurationGroupValueResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HybridNetwork.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridNetwork.Samples @@ -19,10 +18,10 @@ public partial class Sample_ConfigurationGroupValueResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteHybridConfigurationGroupResource() + public async Task Get_GetHybridConfigurationGroup() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueDelete.json - // this example is just showing the usage of "ConfigurationGroupValues_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueGet.json + // this example is just showing the usage of "ConfigurationGroupValues_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteHybridConfigurationGroupResource() ConfigurationGroupValueResource configurationGroupValue = client.GetConfigurationGroupValueResource(configurationGroupValueResourceId); // invoke the operation - await configurationGroupValue.DeleteAsync(WaitUntil.Completed); + ConfigurationGroupValueResource result = await configurationGroupValue.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfigurationGroupValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetHybridConfigurationGroup() + public async Task Delete_DeleteHybridConfigurationGroupResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueGet.json - // this example is just showing the usage of "ConfigurationGroupValues_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueDelete.json + // this example is just showing the usage of "ConfigurationGroupValues_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetHybridConfigurationGroup() ConfigurationGroupValueResource configurationGroupValue = client.GetConfigurationGroupValueResource(configurationGroupValueResourceId); // invoke the operation - ConfigurationGroupValueResource result = await configurationGroupValue.GetAsync(); + await configurationGroupValue.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfigurationGroupValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateHybridConfigurationGroupTags() ConfigurationGroupValueResource configurationGroupValue = client.GetConfigurationGroupValueResource(configurationGroupValueResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ConfigurationGroupValueResource result = await configurationGroupValue.UpdateAsync(tagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdateHybridConfigurationGroupTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetConfigurationGroupValues_ListAllHybridNetworkSitesInASubscription() - { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueListBySubscription.json - // this example is just showing the usage of "ConfigurationGroupValues_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ConfigurationGroupValueResource item in subscriptionResource.GetConfigurationGroupValuesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfigurationGroupValueData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionCollection.cs index 6c047c5db8757..e559838458394 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkFunctionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkFunctionResource() + public async Task CreateOrUpdate_CreateFirstPartyNetworkFunctionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionGet.json - // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionFirstPartyCreate.json + // this example is just showing the usage of "NetworkFunctions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,23 @@ public async Task Get_GetNetworkFunctionResource() // invoke the operation string networkFunctionName = "testNf"; - NetworkFunctionResource result = await collection.GetAsync(networkFunctionName); + NetworkFunctionData data = new NetworkFunctionData(new AzureLocation("eastus")) + { + Properties = new NetworkFunctionValueWithoutSecrets + { + DeploymentValues = "{\"releaseName\":\"testReleaseName\",\"namespace\":\"testNamespace\"}", + NetworkFunctionDefinitionVersionResourceReference = new SecretDeploymentResourceReference + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/testVendor/networkFunctionDefinitionGroups/testnetworkFunctionDefinitionGroupName/networkFunctionDefinitionVersions/1.0.1"), + }, + NfviType = NfviType.AzureArcKubernetes, + NfviId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation"), + AllowSoftwareUpdate = false, + RoleOverrideValues = { "{\"name\":\"testRoleOne\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"helmPackageVersion\":\"2.1.3\",\"values\":\"{\\\"roleOneParam\\\":\\\"roleOneOverrideValue\\\"}\"}}}", "{\"name\":\"testRoleTwo\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"releaseName\":\"overrideReleaseName\",\"releaseNamespace\":\"overrideNamespace\",\"values\":\"{\\\"roleTwoParam\\\":\\\"roleTwoOverrideValue\\\"}\"}}}" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionName, data); + NetworkFunctionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +68,10 @@ public async Task Get_GetNetworkFunctionResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkFunctionResource() + public async Task CreateOrUpdate_CreateNetworkFunctionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionGet.json - // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionCreate.json + // this example is just showing the usage of "NetworkFunctions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,17 +90,37 @@ public async Task Exists_GetNetworkFunctionResource() // invoke the operation string networkFunctionName = "testNf"; - bool result = await collection.ExistsAsync(networkFunctionName); + NetworkFunctionData data = new NetworkFunctionData(new AzureLocation("eastus")) + { + Properties = new NetworkFunctionValueWithoutSecrets + { + DeploymentValues = "{\"releaseName\":\"testReleaseName\",\"namespace\":\"testNamespace\"}", + NetworkFunctionDefinitionVersionResourceReference = new OpenDeploymentResourceReference + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/testVendor/networkFunctionDefinitionGroups/testnetworkFunctionDefinitionGroupName/networkFunctionDefinitionVersions/1.0.1"), + }, + NfviType = NfviType.AzureArcKubernetes, + NfviId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation"), + AllowSoftwareUpdate = false, + RoleOverrideValues = { "{\"name\":\"testRoleOne\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"helmPackageVersion\":\"2.1.3\",\"values\":\"{\\\"roleOneParam\\\":\\\"roleOneOverrideValue\\\"}\"}}}", "{\"name\":\"testRoleTwo\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"releaseName\":\"overrideReleaseName\",\"releaseNamespace\":\"overrideNamespace\",\"values\":\"{\\\"roleTwoParam\\\":\\\"roleTwoOverrideValue\\\"}\"}}}" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionName, data); + NetworkFunctionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkFunctionResource() + public async Task CreateOrUpdate_CreateNetworkFunctionResourceWithSecrets() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionGet.json - // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionCreateSecret.json + // this example is just showing the usage of "NetworkFunctions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,29 +139,37 @@ public async Task GetIfExists_GetNetworkFunctionResource() // invoke the operation string networkFunctionName = "testNf"; - NullableResponse response = await collection.GetIfExistsAsync(networkFunctionName); - NetworkFunctionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + NetworkFunctionData data = new NetworkFunctionData(new AzureLocation("eastus")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new NetworkFunctionValueWithSecrets + { + SecretDeploymentValues = "{\"adminPassword\":\"password1\",\"userPassword\":\"password2\"}", + NetworkFunctionDefinitionVersionResourceReference = new OpenDeploymentResourceReference + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/testVendor/networkFunctionDefinitionGroups/testnetworkFunctionDefinitionGroupName/networkFunctionDefinitionVersions/1.0.1"), + }, + NfviType = NfviType.AzureArcKubernetes, + NfviId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation"), + AllowSoftwareUpdate = false, + RoleOverrideValues = { "{\"name\":\"testRoleOne\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"helmPackageVersion\":\"2.1.3\",\"values\":\"{\\\"roleOneParam\\\":\\\"roleOneOverrideValue\\\"}\"}}}", "{\"name\":\"testRoleTwo\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"releaseName\":\"overrideReleaseName\",\"releaseNamespace\":\"overrideNamespace\",\"values\":\"{\\\"roleTwoParam\\\":\\\"roleTwoOverrideValue\\\"}\"}}}" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionName, data); + NetworkFunctionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkFunctionResourceOnAzureCore() + public async Task CreateOrUpdate_CreateVirtualNetworkFunctionResourceOnAzureCore() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionGet.json - // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionCreate.json + // this example is just showing the usage of "NetworkFunctions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,7 +188,22 @@ public async Task Get_GetVirtualNetworkFunctionResourceOnAzureCore() // invoke the operation string networkFunctionName = "testNf"; - NetworkFunctionResource result = await collection.GetAsync(networkFunctionName); + NetworkFunctionData data = new NetworkFunctionData(new AzureLocation("eastus")) + { + Properties = new NetworkFunctionValueWithoutSecrets + { + DeploymentValues = "{\"virtualMachineName\":\"test-VM\",\"cpuCores\":4,\"memorySizeGB\":8,\"cloudServicesNetworkAttachment\":{\"attachedNetworkId\":\"test-csnet\",\"ipAllocationMethod\":\"Dynamic\",\"networkAttachmentName\":\"test-cs-vlan\"},\"networkAttachments\":[{\"attachedNetworkId\":\"test-l3vlan\",\"defaultGateway\":\"True\",\"ipAllocationMethod\":\"Dynamic\",\"networkAttachmentName\":\"test-vlan\"}],\"sshPublicKeys\":[{\"keyData\":\"ssh-rsa CMIIIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0TqlveKKlc2MFvEmuXJiLGBsY1t4ML4uiRADGSZlnc+7Ugv3h+MCjkkwOKiOdsNo8k4KSBIG5GcQfKYOOd17AJvqCL6cGQbaLuqv0a64jeDm8oO8/xN/IM0oKw7rMr/2oAJOgIsfeXPkRxWWic9AVIS++H5Qi2r7bUFX+cqFsyUCAwEBBQ==\"}],\"storageProfile\":{\"osDisk\":{\"createOption\":\"Ephemeral\",\"deleteOption\":\"Delete\",\"diskSizeGB\":10}},\"userData\":\"testUserData\",\"adminUsername\":\"testUser\",\"virtioInterface\":\"Transitional\",\"isolateEmulatorThread\":\"False\",\"bootMethod\":\"BIOS\",\"placementHints\":[]}", + NetworkFunctionDefinitionVersionResourceReference = new OpenDeploymentResourceReference + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/testVendor/networkFunctionDefinitionGroups/testnetworkFunctionDefinitionGroupName/networkFunctionDefinitionVersions/1.0.1"), + }, + NfviType = NfviType.AzureCore, + NfviId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testResourceGroup"), + AllowSoftwareUpdate = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionName, data); + NetworkFunctionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -155,10 +214,10 @@ public async Task Get_GetVirtualNetworkFunctionResourceOnAzureCore() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetworkFunctionResourceOnAzureCore() + public async Task CreateOrUpdate_CreateVirtualNetworkFunctionResourceOnAzureOperatorNexus() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionGet.json - // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionCreate.json + // this example is just showing the usage of "NetworkFunctions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,16 +236,35 @@ public async Task Exists_GetVirtualNetworkFunctionResourceOnAzureCore() // invoke the operation string networkFunctionName = "testNf"; - bool result = await collection.ExistsAsync(networkFunctionName); + NetworkFunctionData data = new NetworkFunctionData(new AzureLocation("eastus")) + { + Properties = new NetworkFunctionValueWithoutSecrets + { + DeploymentValues = "{\"virtualMachineName\":\"test-VM\",\"extendedLocationName\":\"test-cluster\",\"cpuCores\":4,\"memorySizeGB\":8,\"cloudServicesNetworkAttachment\":{\"attachedNetworkId\":\"test-csnet\",\"ipAllocationMethod\":\"Dynamic\",\"networkAttachmentName\":\"test-cs-vlan\"},\"networkAttachments\":[{\"attachedNetworkId\":\"test-l3vlan\",\"defaultGateway\":\"True\",\"ipAllocationMethod\":\"Dynamic\",\"networkAttachmentName\":\"test-vlan\"}],\"sshPublicKeys\":[{\"keyData\":\"ssh-rsa CMIIIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0TqlveKKlc2MFvEmuXJiLGBsY1t4ML4uiRADGSZlnc+7Ugv3h+MCjkkwOKiOdsNo8k4KSBIG5GcQfKYOOd17AJvqCL6cGQbaLuqv0a64jeDm8oO8/xN/IM0oKw7rMr/2oAJOgIsfeXPkRxWWic9AVIS++H5Qi2r7bUFX+cqFsyUCAwEBBQ==\"}],\"storageProfile\":{\"osDisk\":{\"createOption\":\"Ephemeral\",\"deleteOption\":\"Delete\",\"diskSizeGB\":10}},\"userData\":\"testUserData\",\"adminUsername\":\"testUser\",\"virtioInterface\":\"Transitional\",\"isolateEmulatorThread\":\"False\",\"bootMethod\":\"BIOS\",\"placementHints\":[]}", + NetworkFunctionDefinitionVersionResourceReference = new OpenDeploymentResourceReference + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/testVendor/networkFunctionDefinitionGroups/testnetworkFunctionDefinitionGroupName/networkFunctionDefinitionVersions/1.0.1"), + }, + NfviType = NfviType.AzureOperatorNexus, + NfviId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation"), + AllowSoftwareUpdate = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionName, data); + NetworkFunctionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetworkFunctionResourceOnAzureCore() + public async Task Get_GetNetworkFunctionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionGet.json + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionGet.json // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -206,28 +284,20 @@ public async Task GetIfExists_GetVirtualNetworkFunctionResourceOnAzureCore() // invoke the operation string networkFunctionName = "testNf"; - NullableResponse response = await collection.GetIfExistsAsync(networkFunctionName); - NetworkFunctionResource result = response.HasValue ? response.Value : null; + NetworkFunctionResource result = await collection.GetAsync(networkFunctionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() + public async Task Get_GetVirtualNetworkFunctionResourceOnAzureCore() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionGet.json + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionGet.json // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -258,7 +328,7 @@ public async Task Get_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() + public async Task Get_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() { // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionGet.json // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. @@ -280,17 +350,21 @@ public async Task Exists_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() // invoke the operation string networkFunctionName = "testNf"; - bool result = await collection.ExistsAsync(networkFunctionName); + NetworkFunctionResource result = await collection.GetAsync(networkFunctionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() + public async Task GetAll_ListNetworkFunctionInResourceGroup() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionGet.json - // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionListByResourceGroup.json + // this example is just showing the usage of "NetworkFunctions_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -307,31 +381,25 @@ public async Task GetIfExists_GetVirtualNetworkFunctionResourceOnAzureOperatorNe // get the collection of this NetworkFunctionResource NetworkFunctionCollection collection = resourceGroupResource.GetNetworkFunctions(); - // invoke the operation - string networkFunctionName = "testNf"; - NullableResponse response = await collection.GetIfExistsAsync(networkFunctionName); - NetworkFunctionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NetworkFunctionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; + NetworkFunctionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFirstPartyNetworkFunctionResource() + public async Task Exists_GetNetworkFunctionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionFirstPartyCreate.json - // this example is just showing the usage of "NetworkFunctions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionGet.json + // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -350,40 +418,17 @@ public async Task CreateOrUpdate_CreateFirstPartyNetworkFunctionResource() // invoke the operation string networkFunctionName = "testNf"; - NetworkFunctionData data = new NetworkFunctionData(new AzureLocation("eastus")) - { - Properties = new NetworkFunctionValueWithoutSecrets() - { - DeploymentValues = "{\"releaseName\":\"testReleaseName\",\"namespace\":\"testNamespace\"}", - NetworkFunctionDefinitionVersionResourceReference = new SecretDeploymentResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/testVendor/networkFunctionDefinitionGroups/testnetworkFunctionDefinitionGroupName/networkFunctionDefinitionVersions/1.0.1"), - }, - NfviType = NfviType.AzureArcKubernetes, - NfviId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation"), - AllowSoftwareUpdate = false, - RoleOverrideValues = -{ -"{\"name\":\"testRoleOne\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"helmPackageVersion\":\"2.1.3\",\"values\":\"{\\\"roleOneParam\\\":\\\"roleOneOverrideValue\\\"}\"}}}","{\"name\":\"testRoleTwo\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"releaseName\":\"overrideReleaseName\",\"releaseNamespace\":\"overrideNamespace\",\"values\":\"{\\\"roleTwoParam\\\":\\\"roleTwoOverrideValue\\\"}\"}}}" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionName, data); - NetworkFunctionResource result = lro.Value; + bool result = await collection.ExistsAsync(networkFunctionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkFunctionResource() + public async Task Exists_GetVirtualNetworkFunctionResourceOnAzureCore() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionCreate.json - // this example is just showing the usage of "NetworkFunctions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionGet.json + // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -402,40 +447,17 @@ public async Task CreateOrUpdate_CreateNetworkFunctionResource() // invoke the operation string networkFunctionName = "testNf"; - NetworkFunctionData data = new NetworkFunctionData(new AzureLocation("eastus")) - { - Properties = new NetworkFunctionValueWithoutSecrets() - { - DeploymentValues = "{\"releaseName\":\"testReleaseName\",\"namespace\":\"testNamespace\"}", - NetworkFunctionDefinitionVersionResourceReference = new OpenDeploymentResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/testVendor/networkFunctionDefinitionGroups/testnetworkFunctionDefinitionGroupName/networkFunctionDefinitionVersions/1.0.1"), - }, - NfviType = NfviType.AzureArcKubernetes, - NfviId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation"), - AllowSoftwareUpdate = false, - RoleOverrideValues = -{ -"{\"name\":\"testRoleOne\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"helmPackageVersion\":\"2.1.3\",\"values\":\"{\\\"roleOneParam\\\":\\\"roleOneOverrideValue\\\"}\"}}}","{\"name\":\"testRoleTwo\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"releaseName\":\"overrideReleaseName\",\"releaseNamespace\":\"overrideNamespace\",\"values\":\"{\\\"roleTwoParam\\\":\\\"roleTwoOverrideValue\\\"}\"}}}" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionName, data); - NetworkFunctionResource result = lro.Value; + bool result = await collection.ExistsAsync(networkFunctionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkFunctionResourceWithSecrets() + public async Task Exists_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionCreateSecret.json - // this example is just showing the usage of "NetworkFunctions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionGet.json + // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -454,40 +476,17 @@ public async Task CreateOrUpdate_CreateNetworkFunctionResourceWithSecrets() // invoke the operation string networkFunctionName = "testNf"; - NetworkFunctionData data = new NetworkFunctionData(new AzureLocation("eastus")) - { - Properties = new NetworkFunctionValueWithSecrets() - { - SecretDeploymentValues = "{\"adminPassword\":\"password1\",\"userPassword\":\"password2\"}", - NetworkFunctionDefinitionVersionResourceReference = new OpenDeploymentResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/testVendor/networkFunctionDefinitionGroups/testnetworkFunctionDefinitionGroupName/networkFunctionDefinitionVersions/1.0.1"), - }, - NfviType = NfviType.AzureArcKubernetes, - NfviId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation"), - AllowSoftwareUpdate = false, - RoleOverrideValues = -{ -"{\"name\":\"testRoleOne\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"helmPackageVersion\":\"2.1.3\",\"values\":\"{\\\"roleOneParam\\\":\\\"roleOneOverrideValue\\\"}\"}}}","{\"name\":\"testRoleTwo\",\"deployParametersMappingRuleProfile\":{\"helmMappingRuleProfile\":{\"releaseName\":\"overrideReleaseName\",\"releaseNamespace\":\"overrideNamespace\",\"values\":\"{\\\"roleTwoParam\\\":\\\"roleTwoOverrideValue\\\"}\"}}}" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionName, data); - NetworkFunctionResource result = lro.Value; + bool result = await collection.ExistsAsync(networkFunctionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkFunctionResourceOnAzureCore() + public async Task GetIfExists_GetNetworkFunctionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionCreate.json - // this example is just showing the usage of "NetworkFunctions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionGet.json + // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -506,36 +505,29 @@ public async Task CreateOrUpdate_CreateVirtualNetworkFunctionResourceOnAzureCore // invoke the operation string networkFunctionName = "testNf"; - NetworkFunctionData data = new NetworkFunctionData(new AzureLocation("eastus")) - { - Properties = new NetworkFunctionValueWithoutSecrets() - { - DeploymentValues = "{\"virtualMachineName\":\"test-VM\",\"cpuCores\":4,\"memorySizeGB\":8,\"cloudServicesNetworkAttachment\":{\"attachedNetworkId\":\"test-csnet\",\"ipAllocationMethod\":\"Dynamic\",\"networkAttachmentName\":\"test-cs-vlan\"},\"networkAttachments\":[{\"attachedNetworkId\":\"test-l3vlan\",\"defaultGateway\":\"True\",\"ipAllocationMethod\":\"Dynamic\",\"networkAttachmentName\":\"test-vlan\"}],\"sshPublicKeys\":[{\"keyData\":\"ssh-rsa CMIIIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0TqlveKKlc2MFvEmuXJiLGBsY1t4ML4uiRADGSZlnc+7Ugv3h+MCjkkwOKiOdsNo8k4KSBIG5GcQfKYOOd17AJvqCL6cGQbaLuqv0a64jeDm8oO8/xN/IM0oKw7rMr/2oAJOgIsfeXPkRxWWic9AVIS++H5Qi2r7bUFX+cqFsyUCAwEBBQ==\"}],\"storageProfile\":{\"osDisk\":{\"createOption\":\"Ephemeral\",\"deleteOption\":\"Delete\",\"diskSizeGB\":10}},\"userData\":\"testUserData\",\"adminUsername\":\"testUser\",\"virtioInterface\":\"Transitional\",\"isolateEmulatorThread\":\"False\",\"bootMethod\":\"BIOS\",\"placementHints\":[]}", - NetworkFunctionDefinitionVersionResourceReference = new OpenDeploymentResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/testVendor/networkFunctionDefinitionGroups/testnetworkFunctionDefinitionGroupName/networkFunctionDefinitionVersions/1.0.1"), - }, - NfviType = NfviType.AzureCore, - NfviId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testResourceGroup"), - AllowSoftwareUpdate = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionName, data); - NetworkFunctionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(networkFunctionName); + NetworkFunctionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkFunctionResourceOnAzureOperatorNexus() + public async Task GetIfExists_GetVirtualNetworkFunctionResourceOnAzureCore() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionCreate.json - // this example is just showing the usage of "NetworkFunctions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionGet.json + // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -554,36 +546,29 @@ public async Task CreateOrUpdate_CreateVirtualNetworkFunctionResourceOnAzureOper // invoke the operation string networkFunctionName = "testNf"; - NetworkFunctionData data = new NetworkFunctionData(new AzureLocation("eastus")) - { - Properties = new NetworkFunctionValueWithoutSecrets() - { - DeploymentValues = "{\"virtualMachineName\":\"test-VM\",\"extendedLocationName\":\"test-cluster\",\"cpuCores\":4,\"memorySizeGB\":8,\"cloudServicesNetworkAttachment\":{\"attachedNetworkId\":\"test-csnet\",\"ipAllocationMethod\":\"Dynamic\",\"networkAttachmentName\":\"test-cs-vlan\"},\"networkAttachments\":[{\"attachedNetworkId\":\"test-l3vlan\",\"defaultGateway\":\"True\",\"ipAllocationMethod\":\"Dynamic\",\"networkAttachmentName\":\"test-vlan\"}],\"sshPublicKeys\":[{\"keyData\":\"ssh-rsa CMIIIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0TqlveKKlc2MFvEmuXJiLGBsY1t4ML4uiRADGSZlnc+7Ugv3h+MCjkkwOKiOdsNo8k4KSBIG5GcQfKYOOd17AJvqCL6cGQbaLuqv0a64jeDm8oO8/xN/IM0oKw7rMr/2oAJOgIsfeXPkRxWWic9AVIS++H5Qi2r7bUFX+cqFsyUCAwEBBQ==\"}],\"storageProfile\":{\"osDisk\":{\"createOption\":\"Ephemeral\",\"deleteOption\":\"Delete\",\"diskSizeGB\":10}},\"userData\":\"testUserData\",\"adminUsername\":\"testUser\",\"virtioInterface\":\"Transitional\",\"isolateEmulatorThread\":\"False\",\"bootMethod\":\"BIOS\",\"placementHints\":[]}", - NetworkFunctionDefinitionVersionResourceReference = new OpenDeploymentResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/testVendor/networkFunctionDefinitionGroups/testnetworkFunctionDefinitionGroupName/networkFunctionDefinitionVersions/1.0.1"), - }, - NfviType = NfviType.AzureOperatorNexus, - NfviId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation"), - AllowSoftwareUpdate = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionName, data); - NetworkFunctionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(networkFunctionName); + NetworkFunctionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNetworkFunctionInResourceGroup() + public async Task GetIfExists_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionListByResourceGroup.json - // this example is just showing the usage of "NetworkFunctions_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionGet.json + // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -600,17 +585,23 @@ public async Task GetAll_ListNetworkFunctionInResourceGroup() // get the collection of this NetworkFunctionResource NetworkFunctionCollection collection = resourceGroupResource.GetNetworkFunctions(); - // invoke the operation and iterate over the result - await foreach (NetworkFunctionResource item in collection.GetAllAsync()) + // invoke the operation + string networkFunctionName = "testNf"; + NullableResponse response = await collection.GetIfExistsAsync(networkFunctionName); + NetworkFunctionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = item.Data; + NetworkFunctionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionGroupCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionGroupCollection.cs index 20691cf928341..d87323c5fb7f9 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionGroupCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionGroupCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkFunctionDefinitionGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetNetworkFunctionDefinitionGroupsUnderPublisherResource() + public async Task CreateOrUpdate_CreateOrUpdateTheNetworkFunctionDefinitionGroup() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionGroupsListByPublisherName.json - // this example is just showing the usage of "NetworkFunctionDefinitionGroups_ListByPublisher" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionGroupCreate.json + // this example is just showing the usage of "NetworkFunctionDefinitionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,25 @@ public async Task GetAll_GetNetworkFunctionDefinitionGroupsUnderPublisherResourc // get the collection of this NetworkFunctionDefinitionGroupResource NetworkFunctionDefinitionGroupCollection collection = publisher.GetNetworkFunctionDefinitionGroups(); - // invoke the operation and iterate over the result - await foreach (NetworkFunctionDefinitionGroupResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string networkFunctionDefinitionGroupName = "TestNetworkFunctionDefinitionGroupName"; + NetworkFunctionDefinitionGroupData data = new NetworkFunctionDefinitionGroupData(new AzureLocation("eastus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionDefinitionGroupName, data); + NetworkFunctionDefinitionGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionDefinitionGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateTheNetworkFunctionDefinitionGroup() + public async Task Get_GetANetworkFunctionDefinitionGroupResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionGroupCreate.json - // this example is just showing the usage of "NetworkFunctionDefinitionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionGroupGet.json + // this example is just showing the usage of "NetworkFunctionDefinitionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,9 +76,7 @@ public async Task CreateOrUpdate_CreateOrUpdateTheNetworkFunctionDefinitionGroup // invoke the operation string networkFunctionDefinitionGroupName = "TestNetworkFunctionDefinitionGroupName"; - NetworkFunctionDefinitionGroupData data = new NetworkFunctionDefinitionGroupData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFunctionDefinitionGroupName, data); - NetworkFunctionDefinitionGroupResource result = lro.Value; + NetworkFunctionDefinitionGroupResource result = await collection.GetAsync(networkFunctionDefinitionGroupName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +87,10 @@ public async Task CreateOrUpdate_CreateOrUpdateTheNetworkFunctionDefinitionGroup [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetANetworkFunctionDefinitionGroupResource() + public async Task GetAll_GetNetworkFunctionDefinitionGroupsUnderPublisherResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionGroupGet.json - // this example is just showing the usage of "NetworkFunctionDefinitionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionGroupsListByPublisherName.json + // this example is just showing the usage of "NetworkFunctionDefinitionGroups_ListByPublisher" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,15 +108,17 @@ public async Task Get_GetANetworkFunctionDefinitionGroupResource() // get the collection of this NetworkFunctionDefinitionGroupResource NetworkFunctionDefinitionGroupCollection collection = publisher.GetNetworkFunctionDefinitionGroups(); - // invoke the operation - string networkFunctionDefinitionGroupName = "TestNetworkFunctionDefinitionGroupName"; - NetworkFunctionDefinitionGroupResource result = await collection.GetAsync(networkFunctionDefinitionGroupName); + // invoke the operation and iterate over the result + await foreach (NetworkFunctionDefinitionGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionDefinitionGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionGroupResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionGroupResource.cs index a85463b46e698..32fa65ca8132c 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionGroupResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionGroupResource.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkFunctionDefinitionGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteANetworkFunctionGroupResource() + public async Task Get_GetANetworkFunctionDefinitionGroupResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionGroupDelete.json - // this example is just showing the usage of "NetworkFunctionDefinitionGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionGroupGet.json + // this example is just showing the usage of "NetworkFunctionDefinitionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteANetworkFunctionGroupResource() NetworkFunctionDefinitionGroupResource networkFunctionDefinitionGroup = client.GetNetworkFunctionDefinitionGroupResource(networkFunctionDefinitionGroupResourceId); // invoke the operation - await networkFunctionDefinitionGroup.DeleteAsync(WaitUntil.Completed); + NetworkFunctionDefinitionGroupResource result = await networkFunctionDefinitionGroup.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionDefinitionGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetANetworkFunctionDefinitionGroupResource() + public async Task Delete_DeleteANetworkFunctionGroupResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionGroupGet.json - // this example is just showing the usage of "NetworkFunctionDefinitionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionGroupDelete.json + // this example is just showing the usage of "NetworkFunctionDefinitionGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetANetworkFunctionDefinitionGroupResource() NetworkFunctionDefinitionGroupResource networkFunctionDefinitionGroup = client.GetNetworkFunctionDefinitionGroupResource(networkFunctionDefinitionGroupResourceId); // invoke the operation - NetworkFunctionDefinitionGroupResource result = await networkFunctionDefinitionGroup.GetAsync(); + await networkFunctionDefinitionGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_CreateOrUpdateTheNetworkFunctionDefinitionGroupResource NetworkFunctionDefinitionGroupResource networkFunctionDefinitionGroup = client.GetNetworkFunctionDefinitionGroupResource(networkFunctionDefinitionGroupResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NetworkFunctionDefinitionGroupResource result = await networkFunctionDefinitionGroup.UpdateAsync(tagsObject); diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionVersionCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionVersionCollection.cs index 761fa5ad21d2b..84b0929b70549 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionVersionCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionVersionCollection.cs @@ -44,48 +44,40 @@ public async Task CreateOrUpdate_CreateOrUpdateANetworkFunctionDefinitionVersion string networkFunctionDefinitionVersionName = "1.0.0"; NetworkFunctionDefinitionVersionData data = new NetworkFunctionDefinitionVersionData(new AzureLocation("eastus")) { - Properties = new ContainerizedNetworkFunctionDefinitionVersion() + Properties = new ContainerizedNetworkFunctionDefinitionVersion { - NetworkFunctionTemplate = new AzureArcKubernetesNetworkFunctionTemplate() + NetworkFunctionTemplate = new AzureArcKubernetesNetworkFunctionTemplate { - NetworkFunctionApplications = + NetworkFunctionApplications = {new AzureArcKubernetesHelmApplication { -new AzureArcKubernetesHelmApplication() +ArtifactProfile = new AzureArcKubernetesArtifactProfile { -ArtifactProfile = new AzureArcKubernetesArtifactProfile() -{ -HelmArtifactProfile = new HelmArtifactProfile() +HelmArtifactProfile = new HelmArtifactProfile { HelmPackageName = "fed-rbac", HelmPackageVersionRange = "~2.1.3", -RegistryValuesPaths = -{ -"global.registry.docker.repoPath" -}, -ImagePullSecretsValuesPaths = -{ -"global.imagePullSecrets" -}, +RegistryValuesPaths = {"global.registry.docker.repoPath"}, +ImagePullSecretsValuesPaths = {"global.imagePullSecrets"}, }, ArtifactStoreId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/microsoft.hybridnetwork/publishers/TestPublisher/artifactStores/testArtifactStore"), }, -DeployParametersMappingRuleProfile = new AzureArcKubernetesDeployMappingRuleProfile() +DeployParametersMappingRuleProfile = new AzureArcKubernetesDeployMappingRuleProfile { -HelmMappingRuleProfile = new HelmMappingRuleProfile() +HelmMappingRuleProfile = new HelmMappingRuleProfile { ReleaseNamespace = "{deployParameters.namesapce}", ReleaseName = "{deployParameters.releaseName}", HelmPackageVersion = "2.1.3", Values = "", -Options = new HelmMappingRuleProfileConfig() +Options = new HelmMappingRuleProfileConfig { -InstallOptions = new HelmInstallConfig() +InstallOptions = new HelmInstallConfig { Atomic = "true", Wait = "waitValue", Timeout = "30", }, -UpgradeOptions = new HelmUpgradeConfig() +UpgradeOptions = new HelmUpgradeConfig { Atomic = "true", Wait = "waitValue", @@ -96,20 +88,13 @@ public async Task CreateOrUpdate_CreateOrUpdateANetworkFunctionDefinitionVersion ApplicationEnablement = ApplicationEnablement.Enabled, }, Name = "fedrbac", -DependsOnProfile = new DependsOnProfile() -{ -InstallDependsOn = +DependsOnProfile = new DependsOnProfile { +InstallDependsOn = {}, +UninstallDependsOn = {}, +UpdateDependsOn = {}, }, -UninstallDependsOn = -{ -}, -UpdateDependsOn = -{ -}, -}, -} -}, +}}, }, DeployParameters = "{\"type\":\"object\",\"properties\":{\"releaseName\":{\"type\":\"string\"},\"namespace\":{\"type\":\"string\"}}}", }, @@ -152,75 +137,57 @@ public async Task CreateOrUpdate_CreateOrUpdateANetworkFunctionDefinitionVersion string networkFunctionDefinitionVersionName = "1.0.0"; NetworkFunctionDefinitionVersionData data = new NetworkFunctionDefinitionVersionData(new AzureLocation("eastus")) { - Properties = new VirtualNetworkFunctionDefinitionVersion() + Properties = new VirtualNetworkFunctionDefinitionVersion { - NetworkFunctionTemplate = new AzureCoreNetworkFunctionTemplate() + NetworkFunctionTemplate = new AzureCoreNetworkFunctionTemplate { - NetworkFunctionApplications = -{ -new AzureCoreNetworkFunctionVhdApplication() + NetworkFunctionApplications = {new AzureCoreNetworkFunctionVhdApplication { -ArtifactProfile = new AzureCoreVhdImageArtifactProfile() +ArtifactProfile = new AzureCoreVhdImageArtifactProfile { -VhdArtifactProfile = new VhdImageArtifactProfile() +VhdArtifactProfile = new VhdImageArtifactProfile { VhdName = "test-image", VhdVersion = "1-0-0", }, ArtifactStoreId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg/providers/microsoft.hybridnetwork/publishers/TestPublisher/artifactStores/TestArtifactStore"), }, -DeployParametersMappingRuleProfile = new AzureCoreVhdImageDeployMappingRuleProfile() +DeployParametersMappingRuleProfile = new AzureCoreVhdImageDeployMappingRuleProfile { VhdImageMappingRuleUserConfiguration = "", ApplicationEnablement = ApplicationEnablement.Unknown, }, Name = "testImageRole", -DependsOnProfile = new DependsOnProfile() -{ -InstallDependsOn = -{ -}, -UninstallDependsOn = -{ -}, -UpdateDependsOn = +DependsOnProfile = new DependsOnProfile { +InstallDependsOn = {}, +UninstallDependsOn = {}, +UpdateDependsOn = {}, }, -}, -},new AzureCoreNetworkFunctionArmTemplateApplication() +}, new AzureCoreNetworkFunctionArmTemplateApplication { -ArtifactProfile = new AzureCoreArmTemplateArtifactProfile() +ArtifactProfile = new AzureCoreArmTemplateArtifactProfile { -TemplateArtifactProfile = new ArmTemplateArtifactProfile() +TemplateArtifactProfile = new ArmTemplateArtifactProfile { TemplateName = "test-template", TemplateVersion = "1.0.0", }, ArtifactStoreId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg/providers/microsoft.hybridnetwork/publishers/TestPublisher/artifactStores/TestArtifactStore"), }, -DeployParametersMappingRuleProfile = new AzureCoreArmTemplateDeployMappingRuleProfile() +DeployParametersMappingRuleProfile = new AzureCoreArmTemplateDeployMappingRuleProfile { TemplateParameters = "{\"virtualMachineName\":\"{deployParameters.virtualMachineName}\",\"cpuCores\":\"{deployParameters.cpuCores}\",\"memorySizeGB\":\"{deployParameters.memorySizeGB}\",\"cloudServicesNetworkAttachment\":\"{deployParameters.cloudServicesNetworkAttachment}\",\"networkAttachments\":\"{deployParameters.networkAttachments}\",\"sshPublicKeys\":\"{deployParameters.sshPublicKeys}\",\"storageProfile\":\"{deployParameters.storageProfile}\",\"isolateEmulatorThread\":\"{deployParameters.isolateEmulatorThread}\",\"virtioInterface\":\"{deployParameters.virtioInterface}\",\"userData\":\"{deployParameters.userData}\",\"adminUsername\":\"{deployParameters.adminUsername}\",\"bootMethod\":\"{deployParameters.bootMethod}\",\"placementHints\":\"{deployParameters.placementHints}\"}", ApplicationEnablement = ApplicationEnablement.Unknown, }, Name = "testTemplateRole", -DependsOnProfile = new DependsOnProfile() -{ -InstallDependsOn = +DependsOnProfile = new DependsOnProfile { -"testImageRole" -}, -UninstallDependsOn = -{ -"testImageRole" -}, -UpdateDependsOn = -{ -"testImageRole" -}, -}, -} +InstallDependsOn = {"testImageRole"}, +UninstallDependsOn = {"testImageRole"}, +UpdateDependsOn = {"testImageRole"}, }, +}}, }, Description = "test NFDV for AzureCore", DeployParameters = "{\"virtualMachineName\":{\"type\":\"string\"},\"cpuCores\":{\"type\":\"int\"},\"memorySizeGB\":{\"type\":\"int\"},\"cloudServicesNetworkAttachment\":{\"type\":\"object\",\"properties\":{\"networkAttachmentName\":{\"type\":\"string\"},\"attachedNetworkId\":{\"type\":\"string\"},\"ipAllocationMethod\":{\"type\":\"string\"},\"ipv4Address\":{\"type\":\"string\"},\"ipv6Address\":{\"type\":\"string\"},\"defaultGateway\":{\"type\":\"string\"}},\"required\":[\"attachedNetworkId\",\"ipAllocationMethod\"]},\"networkAttachments\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"networkAttachmentName\":{\"type\":\"string\"},\"attachedNetworkId\":{\"type\":\"string\"},\"ipAllocationMethod\":{\"type\":\"string\"},\"ipv4Address\":{\"type\":\"string\"},\"ipv6Address\":{\"type\":\"string\"},\"defaultGateway\":{\"type\":\"string\"}},\"required\":[\"attachedNetworkId\",\"ipAllocationMethod\"]}},\"storageProfile\":{\"type\":\"object\",\"properties\":{\"osDisk\":{\"type\":\"object\",\"properties\":{\"createOption\":{\"type\":\"string\"},\"deleteOption\":{\"type\":\"string\"},\"diskSizeGB\":{\"type\":\"integer\"}},\"required\":[\"diskSizeGB\"]}},\"required\":[\"osDisk\"]},\"sshPublicKeys\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"keyData\":{\"type\":\"string\"}},\"required\":[\"keyData\"]}},\"userData\":{\"type\":\"string\"},\"adminUsername\":{\"type\":\"string\"},\"bootMethod\":{\"type\":\"string\",\"default\":\"UEFI\",\"enum\":[\"UEFI\",\"BIOS\"]},\"isolateEmulatorThread\":{\"type\":\"string\"},\"virtioInterface\":{\"type\":\"string\"},\"placementHints\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"hintType\":{\"type\":\"string\",\"enum\":[\"Affinity\",\"AntiAffinity\"]},\"resourceId\":{\"type\":\"string\"},\"schedulingExecution\":{\"type\":\"string\",\"enum\":[\"Soft\",\"Hard\"]},\"scope\":{\"type\":\"string\"}},\"required\":[\"hintType\",\"schedulingExecution\",\"resourceId\",\"scope\"]}}}", @@ -264,75 +231,57 @@ public async Task CreateOrUpdate_CreateOrUpdateANetworkFunctionDefinitionVersion string networkFunctionDefinitionVersionName = "1.0.0"; NetworkFunctionDefinitionVersionData data = new NetworkFunctionDefinitionVersionData(new AzureLocation("eastus")) { - Properties = new VirtualNetworkFunctionDefinitionVersion() + Properties = new VirtualNetworkFunctionDefinitionVersion { - NetworkFunctionTemplate = new AzureOperatorNexusNetworkFunctionTemplate() + NetworkFunctionTemplate = new AzureOperatorNexusNetworkFunctionTemplate { - NetworkFunctionApplications = -{ -new AzureOperatorNexusNetworkFunctionImageApplication() + NetworkFunctionApplications = {new AzureOperatorNexusNetworkFunctionImageApplication { -ArtifactProfile = new AzureOperatorNexusImageArtifactProfile() +ArtifactProfile = new AzureOperatorNexusImageArtifactProfile { -ImageArtifactProfile = new ImageArtifactProfile() +ImageArtifactProfile = new ImageArtifactProfile { ImageName = "test-image", ImageVersion = "1.0.0", }, ArtifactStoreId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg/providers/microsoft.hybridnetwork/publishers/TestPublisher/artifactStores/TestArtifactStore"), }, -DeployParametersMappingRuleProfile = new AzureOperatorNexusImageDeployMappingRuleProfile() +DeployParametersMappingRuleProfile = new AzureOperatorNexusImageDeployMappingRuleProfile { ImageMappingRuleUserConfiguration = "", ApplicationEnablement = ApplicationEnablement.Unknown, }, Name = "testImageRole", -DependsOnProfile = new DependsOnProfile() -{ -InstallDependsOn = +DependsOnProfile = new DependsOnProfile { +InstallDependsOn = {}, +UninstallDependsOn = {}, +UpdateDependsOn = {}, }, -UninstallDependsOn = +}, new AzureOperatorNexusNetworkFunctionArmTemplateApplication { -}, -UpdateDependsOn = -{ -}, -}, -},new AzureOperatorNexusNetworkFunctionArmTemplateApplication() -{ -ArtifactProfile = new AzureOperatorNexusArmTemplateArtifactProfile() +ArtifactProfile = new AzureOperatorNexusArmTemplateArtifactProfile { -TemplateArtifactProfile = new ArmTemplateArtifactProfile() +TemplateArtifactProfile = new ArmTemplateArtifactProfile { TemplateName = "test-template", TemplateVersion = "1.0.0", }, ArtifactStoreId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg/providers/microsoft.hybridnetwork/publishers/TestPublisher/artifactStores/TestArtifactStore"), }, -DeployParametersMappingRuleProfile = new AzureOperatorNexusArmTemplateDeployMappingRuleProfile() +DeployParametersMappingRuleProfile = new AzureOperatorNexusArmTemplateDeployMappingRuleProfile { TemplateParameters = "{\"virtualMachineName\":\"{deployParameters.virtualMachineName}\",\"extendedLocationName\":\"{deployParameters.extendedLocationName}\",\"cpuCores\":\"{deployParameters.cpuCores}\",\"memorySizeGB\":\"{deployParameters.memorySizeGB}\",\"cloudServicesNetworkAttachment\":\"{deployParameters.cloudServicesNetworkAttachment}\",\"networkAttachments\":\"{deployParameters.networkAttachments}\",\"sshPublicKeys\":\"{deployParameters.sshPublicKeys}\",\"storageProfile\":\"{deployParameters.storageProfile}\",\"isolateEmulatorThread\":\"{deployParameters.isolateEmulatorThread}\",\"virtioInterface\":\"{deployParameters.virtioInterface}\",\"userData\":\"{deployParameters.userData}\",\"adminUsername\":\"{deployParameters.adminUsername}\",\"bootMethod\":\"{deployParameters.bootMethod}\",\"placementHints\":\"{deployParameters.placementHints}\"}", ApplicationEnablement = ApplicationEnablement.Unknown, }, Name = "testTemplateRole", -DependsOnProfile = new DependsOnProfile() -{ -InstallDependsOn = +DependsOnProfile = new DependsOnProfile { -"testImageRole" -}, -UninstallDependsOn = -{ -"testImageRole" -}, -UpdateDependsOn = -{ -"testImageRole" -}, -}, -} +InstallDependsOn = {"testImageRole"}, +UninstallDependsOn = {"testImageRole"}, +UpdateDependsOn = {"testImageRole"}, }, +}}, }, Description = "test NFDV for AzureOperatorNexus", DeployParameters = "{\"virtualMachineName\":{\"type\":\"string\"},\"extendedLocationName\":{\"type\":\"string\"},\"cpuCores\":{\"type\":\"int\"},\"memorySizeGB\":{\"type\":\"int\"},\"cloudServicesNetworkAttachment\":{\"type\":\"object\",\"properties\":{\"networkAttachmentName\":{\"type\":\"string\"},\"attachedNetworkId\":{\"type\":\"string\"},\"ipAllocationMethod\":{\"type\":\"string\"},\"ipv4Address\":{\"type\":\"string\"},\"ipv6Address\":{\"type\":\"string\"},\"defaultGateway\":{\"type\":\"string\"}},\"required\":[\"attachedNetworkId\",\"ipAllocationMethod\"]},\"networkAttachments\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"networkAttachmentName\":{\"type\":\"string\"},\"attachedNetworkId\":{\"type\":\"string\"},\"ipAllocationMethod\":{\"type\":\"string\"},\"ipv4Address\":{\"type\":\"string\"},\"ipv6Address\":{\"type\":\"string\"},\"defaultGateway\":{\"type\":\"string\"}},\"required\":[\"attachedNetworkId\",\"ipAllocationMethod\"]}},\"storageProfile\":{\"type\":\"object\",\"properties\":{\"osDisk\":{\"type\":\"object\",\"properties\":{\"createOption\":{\"type\":\"string\"},\"deleteOption\":{\"type\":\"string\"},\"diskSizeGB\":{\"type\":\"integer\"}},\"required\":[\"diskSizeGB\"]}},\"required\":[\"osDisk\"]},\"sshPublicKeys\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"keyData\":{\"type\":\"string\"}},\"required\":[\"keyData\"]}},\"userData\":{\"type\":\"string\"},\"adminUsername\":{\"type\":\"string\"},\"bootMethod\":{\"type\":\"string\",\"default\":\"UEFI\",\"enum\":[\"UEFI\",\"BIOS\"]},\"isolateEmulatorThread\":{\"type\":\"string\"},\"virtioInterface\":{\"type\":\"string\"},\"placementHints\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"hintType\":{\"type\":\"string\",\"enum\":[\"Affinity\",\"AntiAffinity\"]},\"resourceId\":{\"type\":\"string\"},\"schedulingExecution\":{\"type\":\"string\",\"enum\":[\"Soft\",\"Hard\"]},\"scope\":{\"type\":\"string\"}},\"required\":[\"hintType\",\"schedulingExecution\",\"resourceId\",\"scope\"]}}}", @@ -385,9 +334,9 @@ public async Task Get_GetANetworkFunctionDefinitionVersionResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetANetworkFunctionDefinitionVersionResource() + public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureCoreVNF() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionVersionGet.json + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDefinitionVersionGet.json // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -409,16 +358,20 @@ public async Task Exists_GetANetworkFunctionDefinitionVersionResource() // invoke the operation string networkFunctionDefinitionVersionName = "1.0.0"; - bool result = await collection.ExistsAsync(networkFunctionDefinitionVersionName); + NetworkFunctionDefinitionVersionResource result = await collection.GetAsync(networkFunctionDefinitionVersionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionDefinitionVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetANetworkFunctionDefinitionVersionResource() + public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureOperatorNexusVNF() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionVersionGet.json + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDefinitionVersionGet.json // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -440,29 +393,21 @@ public async Task GetIfExists_GetANetworkFunctionDefinitionVersionResource() // invoke the operation string networkFunctionDefinitionVersionName = "1.0.0"; - NullableResponse response = await collection.GetIfExistsAsync(networkFunctionDefinitionVersionName); - NetworkFunctionDefinitionVersionResource result = response.HasValue ? response.Value : null; + NetworkFunctionDefinitionVersionResource result = await collection.GetAsync(networkFunctionDefinitionVersionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionDefinitionVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureCoreVNF() + public async Task GetAll_GetPublisherResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDefinitionVersionGet.json - // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionVersionListByNetworkFunctionDefinitionGroup.json + // this example is just showing the usage of "NetworkFunctionDefinitionVersions_ListByNetworkFunctionDefinitionGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -474,29 +419,31 @@ public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureCoreVNF string subscriptionId = "subid"; string resourceGroupName = "rg"; string publisherName = "TestPublisher"; - string networkFunctionDefinitionGroupName = "TestNetworkFunctionDefinitionGroupName"; + string networkFunctionDefinitionGroupName = "TestNetworkFunctionDefinitionGroupNameName"; ResourceIdentifier networkFunctionDefinitionGroupResourceId = NetworkFunctionDefinitionGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publisherName, networkFunctionDefinitionGroupName); NetworkFunctionDefinitionGroupResource networkFunctionDefinitionGroup = client.GetNetworkFunctionDefinitionGroupResource(networkFunctionDefinitionGroupResourceId); // get the collection of this NetworkFunctionDefinitionVersionResource NetworkFunctionDefinitionVersionCollection collection = networkFunctionDefinitionGroup.GetNetworkFunctionDefinitionVersions(); - // invoke the operation - string networkFunctionDefinitionVersionName = "1.0.0"; - NetworkFunctionDefinitionVersionResource result = await collection.GetAsync(networkFunctionDefinitionVersionName); + // invoke the operation and iterate over the result + await foreach (NetworkFunctionDefinitionVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionDefinitionVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkFunctionDefinitionVersionResourceForAzureCoreVNF() + public async Task Exists_GetANetworkFunctionDefinitionVersionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDefinitionVersionGet.json + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionVersionGet.json // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -525,7 +472,7 @@ public async Task Exists_GetNetworkFunctionDefinitionVersionResourceForAzureCore [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkFunctionDefinitionVersionResourceForAzureCoreVNF() + public async Task Exists_GetNetworkFunctionDefinitionVersionResourceForAzureCoreVNF() { // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDefinitionVersionGet.json // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -549,26 +496,14 @@ public async Task GetIfExists_GetNetworkFunctionDefinitionVersionResourceForAzur // invoke the operation string networkFunctionDefinitionVersionName = "1.0.0"; - NullableResponse response = await collection.GetIfExistsAsync(networkFunctionDefinitionVersionName); - NetworkFunctionDefinitionVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkFunctionDefinitionVersionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureOperatorNexusVNF() + public async Task Exists_GetNetworkFunctionDefinitionVersionResourceForAzureOperatorNexusVNF() { // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDefinitionVersionGet.json // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -592,20 +527,16 @@ public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureOperato // invoke the operation string networkFunctionDefinitionVersionName = "1.0.0"; - NetworkFunctionDefinitionVersionResource result = await collection.GetAsync(networkFunctionDefinitionVersionName); + bool result = await collection.ExistsAsync(networkFunctionDefinitionVersionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkFunctionDefinitionVersionResourceForAzureOperatorNexusVNF() + public async Task GetIfExists_GetANetworkFunctionDefinitionVersionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDefinitionVersionGet.json + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionVersionGet.json // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -627,16 +558,28 @@ public async Task Exists_GetNetworkFunctionDefinitionVersionResourceForAzureOper // invoke the operation string networkFunctionDefinitionVersionName = "1.0.0"; - bool result = await collection.ExistsAsync(networkFunctionDefinitionVersionName); + NullableResponse response = await collection.GetIfExistsAsync(networkFunctionDefinitionVersionName); + NetworkFunctionDefinitionVersionResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionDefinitionVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkFunctionDefinitionVersionResourceForAzureOperatorNexusVNF() + public async Task GetIfExists_GetNetworkFunctionDefinitionVersionResourceForAzureCoreVNF() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDefinitionVersionGet.json + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDefinitionVersionGet.json // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -677,10 +620,10 @@ public async Task GetIfExists_GetNetworkFunctionDefinitionVersionResourceForAzur [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetPublisherResource() + public async Task GetIfExists_GetNetworkFunctionDefinitionVersionResourceForAzureOperatorNexusVNF() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionVersionListByNetworkFunctionDefinitionGroup.json - // this example is just showing the usage of "NetworkFunctionDefinitionVersions_ListByNetworkFunctionDefinitionGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDefinitionVersionGet.json + // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -692,24 +635,30 @@ public async Task GetAll_GetPublisherResource() string subscriptionId = "subid"; string resourceGroupName = "rg"; string publisherName = "TestPublisher"; - string networkFunctionDefinitionGroupName = "TestNetworkFunctionDefinitionGroupNameName"; + string networkFunctionDefinitionGroupName = "TestNetworkFunctionDefinitionGroupName"; ResourceIdentifier networkFunctionDefinitionGroupResourceId = NetworkFunctionDefinitionGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publisherName, networkFunctionDefinitionGroupName); NetworkFunctionDefinitionGroupResource networkFunctionDefinitionGroup = client.GetNetworkFunctionDefinitionGroupResource(networkFunctionDefinitionGroupResourceId); // get the collection of this NetworkFunctionDefinitionVersionResource NetworkFunctionDefinitionVersionCollection collection = networkFunctionDefinitionGroup.GetNetworkFunctionDefinitionVersions(); - // invoke the operation and iterate over the result - await foreach (NetworkFunctionDefinitionVersionResource item in collection.GetAllAsync()) + // invoke the operation + string networkFunctionDefinitionVersionName = "1.0.0"; + NullableResponse response = await collection.GetIfExistsAsync(networkFunctionDefinitionVersionName); + NetworkFunctionDefinitionVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionVersionData resourceData = item.Data; + NetworkFunctionDefinitionVersionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionVersionResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionVersionResource.cs index e56fa18f863d9..e215a6018cdad 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionVersionResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionDefinitionVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkFunctionDefinitionVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteANetworkFunctionDefinitionVersion() + public async Task Get_GetANetworkFunctionDefinitionVersionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionVersionDelete.json - // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionVersionGet.json + // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteANetworkFunctionDefinitionVersion() NetworkFunctionDefinitionVersionResource networkFunctionDefinitionVersion = client.GetNetworkFunctionDefinitionVersionResource(networkFunctionDefinitionVersionResourceId); // invoke the operation - await networkFunctionDefinitionVersion.DeleteAsync(WaitUntil.Completed); + NetworkFunctionDefinitionVersionResource result = await networkFunctionDefinitionVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionDefinitionVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteANetworkFunctionDefinitionVersionForAzureCoreVNF() + public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureCoreVNF() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDefinitionVersionDelete.json - // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDefinitionVersionGet.json + // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,17 +71,21 @@ public async Task Delete_DeleteANetworkFunctionDefinitionVersionForAzureCoreVNF( NetworkFunctionDefinitionVersionResource networkFunctionDefinitionVersion = client.GetNetworkFunctionDefinitionVersionResource(networkFunctionDefinitionVersionResourceId); // invoke the operation - await networkFunctionDefinitionVersion.DeleteAsync(WaitUntil.Completed); + NetworkFunctionDefinitionVersionResource result = await networkFunctionDefinitionVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionDefinitionVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteANetworkFunctionDefinitionVersionForAzureOperatorNexusVNF() + public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureOperatorNexusVNF() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDefinitionVersionDelete.json - // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDefinitionVersionGet.json + // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,17 +103,21 @@ public async Task Delete_DeleteANetworkFunctionDefinitionVersionForAzureOperator NetworkFunctionDefinitionVersionResource networkFunctionDefinitionVersion = client.GetNetworkFunctionDefinitionVersionResource(networkFunctionDefinitionVersionResourceId); // invoke the operation - await networkFunctionDefinitionVersion.DeleteAsync(WaitUntil.Completed); + NetworkFunctionDefinitionVersionResource result = await networkFunctionDefinitionVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionDefinitionVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetANetworkFunctionDefinitionVersionResource() + public async Task Delete_DeleteANetworkFunctionDefinitionVersion() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionVersionGet.json - // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDefinitionVersionDelete.json + // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -123,21 +135,17 @@ public async Task Get_GetANetworkFunctionDefinitionVersionResource() NetworkFunctionDefinitionVersionResource networkFunctionDefinitionVersion = client.GetNetworkFunctionDefinitionVersionResource(networkFunctionDefinitionVersionResourceId); // invoke the operation - NetworkFunctionDefinitionVersionResource result = await networkFunctionDefinitionVersion.GetAsync(); + await networkFunctionDefinitionVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureCoreVNF() + public async Task Delete_DeleteANetworkFunctionDefinitionVersionForAzureCoreVNF() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDefinitionVersionGet.json - // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDefinitionVersionDelete.json + // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -155,21 +163,17 @@ public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureCoreVNF NetworkFunctionDefinitionVersionResource networkFunctionDefinitionVersion = client.GetNetworkFunctionDefinitionVersionResource(networkFunctionDefinitionVersionResourceId); // invoke the operation - NetworkFunctionDefinitionVersionResource result = await networkFunctionDefinitionVersion.GetAsync(); + await networkFunctionDefinitionVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureOperatorNexusVNF() + public async Task Delete_DeleteANetworkFunctionDefinitionVersionForAzureOperatorNexusVNF() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDefinitionVersionGet.json - // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDefinitionVersionDelete.json + // this example is just showing the usage of "NetworkFunctionDefinitionVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,13 +191,9 @@ public async Task Get_GetNetworkFunctionDefinitionVersionResourceForAzureOperato NetworkFunctionDefinitionVersionResource networkFunctionDefinitionVersion = client.GetNetworkFunctionDefinitionVersionResource(networkFunctionDefinitionVersionResourceId); // invoke the operation - NetworkFunctionDefinitionVersionResource result = await networkFunctionDefinitionVersion.GetAsync(); + await networkFunctionDefinitionVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionDefinitionVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -219,12 +219,12 @@ public async Task Update_UpdateTheNetworkFunctionDefinitionVersionTags() NetworkFunctionDefinitionVersionResource networkFunctionDefinitionVersion = client.GetNetworkFunctionDefinitionVersionResource(networkFunctionDefinitionVersionResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NetworkFunctionDefinitionVersionResource result = await networkFunctionDefinitionVersion.UpdateAsync(tagsObject); @@ -259,7 +259,7 @@ public async Task UpdateState_UpdateNetworkFunctionDefinitionVersionState() NetworkFunctionDefinitionVersionResource networkFunctionDefinitionVersion = client.GetNetworkFunctionDefinitionVersionResource(networkFunctionDefinitionVersionResourceId); // invoke the operation - NetworkFunctionDefinitionVersionUpdateState networkFunctionDefinitionVersionUpdateState = new NetworkFunctionDefinitionVersionUpdateState() + NetworkFunctionDefinitionVersionUpdateState networkFunctionDefinitionVersionUpdateState = new NetworkFunctionDefinitionVersionUpdateState { VersionState = VersionState.Active, }; diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionResource.cs index 8fa92b4ae154d..48290a201ace9 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkFunctionResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HybridNetwork.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridNetwork.Samples @@ -19,10 +18,10 @@ public partial class Sample_NetworkFunctionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkFunctionResource() + public async Task Get_GetNetworkFunctionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDelete.json - // this example is just showing the usage of "NetworkFunctions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionGet.json + // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteNetworkFunctionResource() NetworkFunctionResource networkFunction = client.GetNetworkFunctionResource(networkFunctionResourceId); // invoke the operation - await networkFunction.DeleteAsync(WaitUntil.Completed); + NetworkFunctionResource result = await networkFunction.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualNetworkFunctionResourceOnAzureCore() + public async Task Get_GetVirtualNetworkFunctionResourceOnAzureCore() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDelete.json - // this example is just showing the usage of "NetworkFunctions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionGet.json + // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,17 +67,21 @@ public async Task Delete_DeleteVirtualNetworkFunctionResourceOnAzureCore() NetworkFunctionResource networkFunction = client.GetNetworkFunctionResource(networkFunctionResourceId); // invoke the operation - await networkFunction.DeleteAsync(WaitUntil.Completed); + NetworkFunctionResource result = await networkFunction.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualNetworkFunctionResourceOnAzureOperatorNexus() + public async Task Get_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDelete.json - // this example is just showing the usage of "NetworkFunctions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionGet.json + // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -90,17 +97,21 @@ public async Task Delete_DeleteVirtualNetworkFunctionResourceOnAzureOperatorNexu NetworkFunctionResource networkFunction = client.GetNetworkFunctionResource(networkFunctionResourceId); // invoke the operation - await networkFunction.DeleteAsync(WaitUntil.Completed); + NetworkFunctionResource result = await networkFunction.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkFunctionResource() + public async Task Delete_DeleteNetworkFunctionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionGet.json - // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionDelete.json + // this example is just showing the usage of "NetworkFunctions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,21 +127,17 @@ public async Task Get_GetNetworkFunctionResource() NetworkFunctionResource networkFunction = client.GetNetworkFunctionResource(networkFunctionResourceId); // invoke the operation - NetworkFunctionResource result = await networkFunction.GetAsync(); + await networkFunction.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkFunctionResourceOnAzureCore() + public async Task Delete_DeleteVirtualNetworkFunctionResourceOnAzureCore() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionGet.json - // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureCore/VirtualNetworkFunctionDelete.json + // this example is just showing the usage of "NetworkFunctions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,21 +153,17 @@ public async Task Get_GetVirtualNetworkFunctionResourceOnAzureCore() NetworkFunctionResource networkFunction = client.GetNetworkFunctionResource(networkFunctionResourceId); // invoke the operation - NetworkFunctionResource result = await networkFunction.GetAsync(); + await networkFunction.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() + public async Task Delete_DeleteVirtualNetworkFunctionResourceOnAzureOperatorNexus() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionGet.json - // this example is just showing the usage of "NetworkFunctions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/AzureOperatorNexus/VirtualNetworkFunctionDelete.json + // this example is just showing the usage of "NetworkFunctions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,13 +179,9 @@ public async Task Get_GetVirtualNetworkFunctionResourceOnAzureOperatorNexus() NetworkFunctionResource networkFunction = client.GetNetworkFunctionResource(networkFunctionResourceId); // invoke the operation - NetworkFunctionResource result = await networkFunction.GetAsync(); + await networkFunction.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -206,12 +205,12 @@ public async Task Update_UpdateTagsForNetworkFunctionResource() NetworkFunctionResource networkFunction = client.GetNetworkFunctionResource(networkFunctionResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NetworkFunctionResource result = await networkFunction.UpdateAsync(tagsObject); @@ -223,37 +222,6 @@ public async Task Update_UpdateTagsForNetworkFunctionResource() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFunctions_ListAllNetworkFunctionResourcesInSubscription() - { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionListBySubscription.json - // this example is just showing the usage of "NetworkFunctions_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFunctionResource item in subscriptionResource.GetNetworkFunctionsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFunctionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task ExecuteRequest_SendRequestToNetworkFunctionServices() diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignGroupCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignGroupCollection.cs index 6876448ce6a40..9deb6564cd299 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignGroupCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignGroupCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkServiceDesignGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetNetworkServiceDesignGroupsUnderPublisherResource() + public async Task CreateOrUpdate_CreateOrUpdateTheNetworkServiceDesignGroup() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignGroupsListByPublisherName.json - // this example is just showing the usage of "NetworkServiceDesignGroups_ListByPublisher" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignGroupCreate.json + // this example is just showing the usage of "NetworkServiceDesignGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,25 @@ public async Task GetAll_GetNetworkServiceDesignGroupsUnderPublisherResource() // get the collection of this NetworkServiceDesignGroupResource NetworkServiceDesignGroupCollection collection = publisher.GetNetworkServiceDesignGroups(); - // invoke the operation and iterate over the result - await foreach (NetworkServiceDesignGroupResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkServiceDesignGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string networkServiceDesignGroupName = "TestNetworkServiceDesignGroupName"; + NetworkServiceDesignGroupData data = new NetworkServiceDesignGroupData(new AzureLocation("eastus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkServiceDesignGroupName, data); + NetworkServiceDesignGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkServiceDesignGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateTheNetworkServiceDesignGroup() + public async Task Get_GetANetworkServiceDesignGroupResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignGroupCreate.json - // this example is just showing the usage of "NetworkServiceDesignGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignGroupGet.json + // this example is just showing the usage of "NetworkServiceDesignGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,9 +76,7 @@ public async Task CreateOrUpdate_CreateOrUpdateTheNetworkServiceDesignGroup() // invoke the operation string networkServiceDesignGroupName = "TestNetworkServiceDesignGroupName"; - NetworkServiceDesignGroupData data = new NetworkServiceDesignGroupData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkServiceDesignGroupName, data); - NetworkServiceDesignGroupResource result = lro.Value; + NetworkServiceDesignGroupResource result = await collection.GetAsync(networkServiceDesignGroupName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +87,10 @@ public async Task CreateOrUpdate_CreateOrUpdateTheNetworkServiceDesignGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetANetworkServiceDesignGroupResource() + public async Task GetAll_GetNetworkServiceDesignGroupsUnderPublisherResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignGroupGet.json - // this example is just showing the usage of "NetworkServiceDesignGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignGroupsListByPublisherName.json + // this example is just showing the usage of "NetworkServiceDesignGroups_ListByPublisher" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,15 +108,17 @@ public async Task Get_GetANetworkServiceDesignGroupResource() // get the collection of this NetworkServiceDesignGroupResource NetworkServiceDesignGroupCollection collection = publisher.GetNetworkServiceDesignGroups(); - // invoke the operation - string networkServiceDesignGroupName = "TestNetworkServiceDesignGroupName"; - NetworkServiceDesignGroupResource result = await collection.GetAsync(networkServiceDesignGroupName); + // invoke the operation and iterate over the result + await foreach (NetworkServiceDesignGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkServiceDesignGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkServiceDesignGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignGroupResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignGroupResource.cs index f706b69c253f5..bdf68b3e620bf 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignGroupResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignGroupResource.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkServiceDesignGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteANetworkFunctionGroupResource() + public async Task Get_GetANetworkServiceDesignGroupResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignGroupDelete.json - // this example is just showing the usage of "NetworkServiceDesignGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignGroupGet.json + // this example is just showing the usage of "NetworkServiceDesignGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteANetworkFunctionGroupResource() NetworkServiceDesignGroupResource networkServiceDesignGroup = client.GetNetworkServiceDesignGroupResource(networkServiceDesignGroupResourceId); // invoke the operation - await networkServiceDesignGroup.DeleteAsync(WaitUntil.Completed); + NetworkServiceDesignGroupResource result = await networkServiceDesignGroup.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkServiceDesignGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetANetworkServiceDesignGroupResource() + public async Task Delete_DeleteANetworkFunctionGroupResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignGroupGet.json - // this example is just showing the usage of "NetworkServiceDesignGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignGroupDelete.json + // this example is just showing the usage of "NetworkServiceDesignGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetANetworkServiceDesignGroupResource() NetworkServiceDesignGroupResource networkServiceDesignGroup = client.GetNetworkServiceDesignGroupResource(networkServiceDesignGroupResourceId); // invoke the operation - NetworkServiceDesignGroupResource result = await networkServiceDesignGroup.GetAsync(); + await networkServiceDesignGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkServiceDesignGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_CreateOrUpdateTheNetworkServiceDesignGroupResource() NetworkServiceDesignGroupResource networkServiceDesignGroup = client.GetNetworkServiceDesignGroupResource(networkServiceDesignGroupResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NetworkServiceDesignGroupResource result = await networkServiceDesignGroup.UpdateAsync(tagsObject); diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignVersionCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignVersionCollection.cs index 1fedaa148d0e5..d1a289dd7c8de 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignVersionCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignVersionCollection.cs @@ -45,24 +45,22 @@ public async Task CreateOrUpdate_CreateOrUpdateANetworkServiceDesignVersionResou string networkServiceDesignVersionName = "1.0.0"; NetworkServiceDesignVersionData data = new NetworkServiceDesignVersionData(new AzureLocation("eastus")) { - Properties = new NetworkServiceDesignVersionPropertiesFormat() + Properties = new NetworkServiceDesignVersionPropertiesFormat { ConfigurationGroupSchemaReferences = { -["MyVM_Configuration"] = new WritableSubResource() +["MyVM_Configuration"] = new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/contosorg1/providers/microsoft.hybridnetwork/publishers/contosoGroup/networkServiceDesignGroups/NSD_contoso/configurationGroupSchemas/MyVM_Configuration_Schema"), +} }, -}, - ResourceElementTemplates = -{ -new ArmResourceDefinitionResourceElementTemplateDetails() + ResourceElementTemplates = {new ArmResourceDefinitionResourceElementTemplateDetails { -Configuration = new ArmResourceDefinitionResourceElementTemplate() +Configuration = new ArmResourceDefinitionResourceElementTemplate { TemplateType = TemplateType.ArmTemplate, ParameterValues = "{\"publisherName\":\"{configurationparameters('MyVM_Configuration').publisherName}\",\"skuGroupName\":\"{configurationparameters('MyVM_Configuration').skuGroupName}\",\"skuVersion\":\"{configurationparameters('MyVM_Configuration').skuVersion}\",\"skuOfferingLocation\":\"{configurationparameters('MyVM_Configuration').skuOfferingLocation}\",\"nfviType\":\"{nfvis().nfvisFromSitePerNfviType.AzureCore.nfviAlias1.nfviType}\",\"nfviId\":\"{nfvis().nfvisFromSitePerNfviType.AzureCore.nfviAlias1.nfviId}\",\"allowSoftwareUpdates\":\"{configurationparameters('MyVM_Configuration').allowSoftwareUpdates}\",\"virtualNetworkName\":\"{configurationparameters('MyVM_Configuration').vnetName}\",\"subnetName\":\"{configurationparameters('MyVM_Configuration').subnetName}\",\"subnetAddressPrefix\":\"{configurationparameters('MyVM_Configuration').subnetAddressPrefix}\",\"managedResourceGroup\":\"{configurationparameters('SNSSelf').managedResourceGroupName}\",\"adminPassword\":\"{secretparameters('MyVM_Configuration').adminPassword}\"}", -ArtifactProfile = new NSDArtifactProfile() +ArtifactProfile = new NSDArtifactProfile { ArtifactStoreReferenceId = new ResourceIdentifier("/subscriptions/subid/providers/Microsoft.HybridNetwork/publishers/contosoGroup/artifactStoreReference/store1"), ArtifactName = "MyVMArmTemplate", @@ -70,14 +68,11 @@ public async Task CreateOrUpdate_CreateOrUpdateANetworkServiceDesignVersionResou }, }, Name = "MyVM", -DependsOnProfile = new DependsOnProfile() +DependsOnProfile = new DependsOnProfile { -InstallDependsOn = -{ -}, -}, -} +InstallDependsOn = {}, }, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkServiceDesignVersionName, data); @@ -127,10 +122,10 @@ public async Task Get_GetANetworkServiceDesignVersionResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetANetworkServiceDesignVersionResource() + public async Task GetAll_GetPublisherResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignVersionGet.json - // this example is just showing the usage of "NetworkServiceDesignVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignVersionListByNetworkServiceDesignGroup.json + // this example is just showing the usage of "NetworkServiceDesignVersions_ListByNetworkServiceDesignGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,16 +144,22 @@ public async Task Exists_GetANetworkServiceDesignVersionResource() // get the collection of this NetworkServiceDesignVersionResource NetworkServiceDesignVersionCollection collection = networkServiceDesignGroup.GetNetworkServiceDesignVersions(); - // invoke the operation - string networkServiceDesignVersionName = "1.0.0"; - bool result = await collection.ExistsAsync(networkServiceDesignVersionName); + // invoke the operation and iterate over the result + await foreach (NetworkServiceDesignVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkServiceDesignVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetANetworkServiceDesignVersionResource() + public async Task Exists_GetANetworkServiceDesignVersionResource() { // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignVersionGet.json // this example is just showing the usage of "NetworkServiceDesignVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -182,29 +183,17 @@ public async Task GetIfExists_GetANetworkServiceDesignVersionResource() // invoke the operation string networkServiceDesignVersionName = "1.0.0"; - NullableResponse response = await collection.GetIfExistsAsync(networkServiceDesignVersionName); - NetworkServiceDesignVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkServiceDesignVersionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkServiceDesignVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetPublisherResource() + public async Task GetIfExists_GetANetworkServiceDesignVersionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignVersionListByNetworkServiceDesignGroup.json - // this example is just showing the usage of "NetworkServiceDesignVersions_ListByNetworkServiceDesignGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignVersionGet.json + // this example is just showing the usage of "NetworkServiceDesignVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -223,17 +212,23 @@ public async Task GetAll_GetPublisherResource() // get the collection of this NetworkServiceDesignVersionResource NetworkServiceDesignVersionCollection collection = networkServiceDesignGroup.GetNetworkServiceDesignVersions(); - // invoke the operation and iterate over the result - await foreach (NetworkServiceDesignVersionResource item in collection.GetAllAsync()) + // invoke the operation + string networkServiceDesignVersionName = "1.0.0"; + NullableResponse response = await collection.GetIfExistsAsync(networkServiceDesignVersionName); + NetworkServiceDesignVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkServiceDesignVersionData resourceData = item.Data; + NetworkServiceDesignVersionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignVersionResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignVersionResource.cs index 74491fc4d9e3e..d63c30f4c0f51 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignVersionResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_NetworkServiceDesignVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkServiceDesignVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteANetworkServiceDesignVersion() + public async Task Get_GetANetworkServiceDesignVersionResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignVersionDelete.json - // this example is just showing the usage of "NetworkServiceDesignVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignVersionGet.json + // this example is just showing the usage of "NetworkServiceDesignVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteANetworkServiceDesignVersion() NetworkServiceDesignVersionResource networkServiceDesignVersion = client.GetNetworkServiceDesignVersionResource(networkServiceDesignVersionResourceId); // invoke the operation - await networkServiceDesignVersion.DeleteAsync(WaitUntil.Completed); + NetworkServiceDesignVersionResource result = await networkServiceDesignVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkServiceDesignVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetANetworkServiceDesignVersionResource() + public async Task Delete_DeleteANetworkServiceDesignVersion() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignVersionGet.json - // this example is just showing the usage of "NetworkServiceDesignVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkServiceDesignVersionDelete.json + // this example is just showing the usage of "NetworkServiceDesignVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetANetworkServiceDesignVersionResource() NetworkServiceDesignVersionResource networkServiceDesignVersion = client.GetNetworkServiceDesignVersionResource(networkServiceDesignVersionResourceId); // invoke the operation - NetworkServiceDesignVersionResource result = await networkServiceDesignVersion.GetAsync(); + await networkServiceDesignVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkServiceDesignVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,12 +99,12 @@ public async Task Update_UpdateTheNetworkServiceDesignVersionTags() NetworkServiceDesignVersionResource networkServiceDesignVersion = client.GetNetworkServiceDesignVersionResource(networkServiceDesignVersionResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NetworkServiceDesignVersionResource result = await networkServiceDesignVersion.UpdateAsync(tagsObject); @@ -139,7 +139,7 @@ public async Task UpdateState_UpdateNetworkServiceDesignVersionState() NetworkServiceDesignVersionResource networkServiceDesignVersion = client.GetNetworkServiceDesignVersionResource(networkServiceDesignVersionResourceId); // invoke the operation - NetworkServiceDesignVersionUpdateState networkServiceDesignVersionUpdateState = new NetworkServiceDesignVersionUpdateState() + NetworkServiceDesignVersionUpdateState networkServiceDesignVersionUpdateState = new NetworkServiceDesignVersionUpdateState { VersionState = VersionState.Active, }; diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_PublisherCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_PublisherCollection.cs index cc4d879df801a..6a38f76edf8d6 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_PublisherCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_PublisherCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_PublisherCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllPublisherResourcesInAResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateAPublisherResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherListByResourceGroup.json - // this example is just showing the usage of "Publishers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherCreate.json + // this example is just showing the usage of "Publishers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_ListAllPublisherResourcesInAResourceGroup() // get the collection of this PublisherResource PublisherCollection collection = resourceGroupResource.GetPublishers(); - // invoke the operation and iterate over the result - await foreach (PublisherResource item in collection.GetAllAsync()) + // invoke the operation + string publisherName = "TestPublisher"; + PublisherData data = new PublisherData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublisherData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new PublisherPropertiesFormat + { + Scope = new PublisherScope("Public"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publisherName, data); + PublisherResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublisherData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +93,10 @@ public async Task Get_GetAPublisherResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPublisherResource() + public async Task GetAll_ListAllPublisherResourcesInAResourceGroup() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherGet.json - // this example is just showing the usage of "Publishers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherListByResourceGroup.json + // this example is just showing the usage of "Publishers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +113,22 @@ public async Task Exists_GetAPublisherResource() // get the collection of this PublisherResource PublisherCollection collection = resourceGroupResource.GetPublishers(); - // invoke the operation - string publisherName = "TestPublisher"; - bool result = await collection.ExistsAsync(publisherName); + // invoke the operation and iterate over the result + await foreach (PublisherResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublisherData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPublisherResource() + public async Task Exists_GetAPublisherResource() { // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherGet.json // this example is just showing the usage of "Publishers_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +150,17 @@ public async Task GetIfExists_GetAPublisherResource() // invoke the operation string publisherName = "TestPublisher"; - NullableResponse response = await collection.GetIfExistsAsync(publisherName); - PublisherResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(publisherName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublisherData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAPublisherResource() + public async Task GetIfExists_GetAPublisherResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherCreate.json - // this example is just showing the usage of "Publishers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherGet.json + // this example is just showing the usage of "Publishers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,21 +179,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAPublisherResource() // invoke the operation string publisherName = "TestPublisher"; - PublisherData data = new PublisherData(new AzureLocation("eastus")) - { - Properties = new PublisherPropertiesFormat() - { - Scope = new PublisherScope("Public"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publisherName, data); - PublisherResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(publisherName); + PublisherResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublisherData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublisherData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_PublisherResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_PublisherResource.cs index 8af0e25f332e3..831ce1dba3ea8 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_PublisherResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_PublisherResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HybridNetwork.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridNetwork.Samples @@ -19,41 +18,10 @@ public partial class Sample_PublisherResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetPublishers_ListAllPublisherResourcesInASubscription() - { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherListBySubscription.json - // this example is just showing the usage of "Publishers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PublisherResource item in subscriptionResource.GetPublishersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublisherData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPublisherResource() + public async Task Get_GetAPublisherResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherDelete.json - // this example is just showing the usage of "Publishers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherGet.json + // this example is just showing the usage of "Publishers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,17 +37,21 @@ public async Task Delete_DeleteAPublisherResource() PublisherResource publisher = client.GetPublisherResource(publisherResourceId); // invoke the operation - await publisher.DeleteAsync(WaitUntil.Completed); + PublisherResource result = await publisher.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublisherData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPublisherResource() + public async Task Delete_DeleteAPublisherResource() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherGet.json - // this example is just showing the usage of "Publishers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherDelete.json + // this example is just showing the usage of "Publishers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,13 +67,9 @@ public async Task Get_GetAPublisherResource() PublisherResource publisher = client.GetPublisherResource(publisherResourceId); // invoke the operation - PublisherResource result = await publisher.GetAsync(); + await publisher.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublisherData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -125,12 +93,12 @@ public async Task Update_UpdateAPublisherTags() PublisherResource publisher = client.GetPublisherResource(publisherResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; PublisherResource result = await publisher.UpdateAsync(tagsObject); diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteCollection.cs index a0ba8f58fca9a..422831981444a 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SiteCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSite() + public async Task CreateOrUpdate_CreateNetworkSite() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteGet.json - // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteCreate.json + // this example is just showing the usage of "Sites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,27 @@ public async Task Get_GetNetworkSite() // invoke the operation string siteName = "testSite"; - SiteResource result = await collection.GetAsync(siteName); + SiteData data = new SiteData(new AzureLocation("westUs2")) + { + Properties = new SitePropertiesFormat + { + Nfvis = {new AzureCoreNfviDetails +{ +Location = new AzureLocation("westUs2"), +Name = "nfvi1", +}, new AzureArcK8SClusterNfviDetails +{ +CustomLocationReferenceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation1"), +Name = "nfvi2", +}, new AzureOperatorNexusClusterNfviDetails +{ +CustomLocationReferenceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation2"), +Name = "nfvi3", +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, siteName, data); + SiteResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +72,7 @@ public async Task Get_GetNetworkSite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkSite() + public async Task Get_GetNetworkSite() { // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteGet.json // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +94,21 @@ public async Task Exists_GetNetworkSite() // invoke the operation string siteName = "testSite"; - bool result = await collection.ExistsAsync(siteName); + SiteResource result = await collection.GetAsync(siteName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkSite() + public async Task GetAll_ListAllNetworkSites() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteGet.json - // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteListByResourceGroup.json + // this example is just showing the usage of "Sites_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +125,25 @@ public async Task GetIfExists_GetNetworkSite() // get the collection of this SiteResource SiteCollection collection = resourceGroupResource.GetSites(); - // invoke the operation - string siteName = "testSite"; - NullableResponse response = await collection.GetIfExistsAsync(siteName); - SiteResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SiteResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SiteData resourceData = result.Data; + SiteData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkSite() + public async Task Exists_GetNetworkSite() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteCreate.json - // this example is just showing the usage of "Sites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteGet.json + // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,44 +162,17 @@ public async Task CreateOrUpdate_CreateNetworkSite() // invoke the operation string siteName = "testSite"; - SiteData data = new SiteData(new AzureLocation("westUs2")) - { - Properties = new SitePropertiesFormat() - { - Nfvis = -{ -new AzureCoreNfviDetails() -{ -Location = new AzureLocation("westUs2"), -Name = "nfvi1", -},new AzureArcK8SClusterNfviDetails() -{ -CustomLocationReferenceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation1"), -Name = "nfvi2", -},new AzureOperatorNexusClusterNfviDetails() -{ -CustomLocationReferenceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testResourceGroup/providers/Microsoft.ExtendedLocation/customLocations/testCustomLocation2"), -Name = "nfvi3", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, siteName, data); - SiteResource result = lro.Value; + bool result = await collection.ExistsAsync(siteName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllNetworkSites() + public async Task GetIfExists_GetNetworkSite() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteListByResourceGroup.json - // this example is just showing the usage of "Sites_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteGet.json + // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,17 +189,23 @@ public async Task GetAll_ListAllNetworkSites() // get the collection of this SiteResource SiteCollection collection = resourceGroupResource.GetSites(); - // invoke the operation and iterate over the result - await foreach (SiteResource item in collection.GetAllAsync()) + // invoke the operation + string siteName = "testSite"; + NullableResponse response = await collection.GetIfExistsAsync(siteName); + SiteResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SiteData resourceData = item.Data; + SiteData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteNetworkServiceCollection.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteNetworkServiceCollection.cs index 59b74d2d7c69c..b919076b2575d 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteNetworkServiceCollection.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteNetworkServiceCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_SiteNetworkServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSite() + public async Task CreateOrUpdate_CreateFirstPartySiteNetworkService() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceGet.json - // this example is just showing the usage of "SiteNetworkServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceFirstPartyCreate.json + // this example is just showing the usage of "SiteNetworkServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,27 @@ public async Task Get_GetNetworkSite() // invoke the operation string siteNetworkServiceName = "testSiteNetworkServiceName"; - SiteNetworkServiceResource result = await collection.GetAsync(siteNetworkServiceName); + SiteNetworkServiceData data = new SiteNetworkServiceData(new AzureLocation("westUs2")) + { + Properties = new SiteNetworkServicePropertiesFormat + { + SiteReferenceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/contosorg1/providers/microsoft.hybridnetwork/sites/testSite"), + NetworkServiceDesignVersionResourceReference = new SecretDeploymentResourceReference + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/TestPublisher/networkServiceDesignGroups/TestNetworkServiceDesignGroupName/networkServiceDesignVersions/1.0.0"), + }, + DesiredStateConfigurationGroupValueReferences = +{ +["MyVM_Configuration"] = new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/contosorg1/providers/microsoft.hybridnetwork/configurationgroupvalues/MyVM_Configuration1"), +} +}, + }, + Sku = new HybridNetworkSku(HybridNetworkSkuName.Standard), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, siteNetworkServiceName, data); + SiteNetworkServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +73,10 @@ public async Task Get_GetNetworkSite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkSite() + public async Task CreateOrUpdate_CreateSiteNetworkService() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceGet.json - // this example is just showing the usage of "SiteNetworkServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceCreate.json + // this example is just showing the usage of "SiteNetworkServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +95,38 @@ public async Task Exists_GetNetworkSite() // invoke the operation string siteNetworkServiceName = "testSiteNetworkServiceName"; - bool result = await collection.ExistsAsync(siteNetworkServiceName); + SiteNetworkServiceData data = new SiteNetworkServiceData(new AzureLocation("westUs2")) + { + Properties = new SiteNetworkServicePropertiesFormat + { + SiteReferenceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/contosorg1/providers/microsoft.hybridnetwork/sites/testSite"), + NetworkServiceDesignVersionResourceReference = new OpenDeploymentResourceReference + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/TestPublisher/networkServiceDesignGroups/TestNetworkServiceDesignGroupName/networkServiceDesignVersions/1.0.0"), + }, + DesiredStateConfigurationGroupValueReferences = +{ +["MyVM_Configuration"] = new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/contosorg1/providers/microsoft.hybridnetwork/configurationgroupvalues/MyVM_Configuration1"), +} +}, + }, + Sku = new HybridNetworkSku(HybridNetworkSkuName.Standard), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, siteNetworkServiceName, data); + SiteNetworkServiceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteNetworkServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkSite() + public async Task Get_GetNetworkSite() { // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceGet.json // this example is just showing the usage of "SiteNetworkServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +148,21 @@ public async Task GetIfExists_GetNetworkSite() // invoke the operation string siteNetworkServiceName = "testSiteNetworkServiceName"; - NullableResponse response = await collection.GetIfExistsAsync(siteNetworkServiceName); - SiteNetworkServiceResource result = response.HasValue ? response.Value : null; + SiteNetworkServiceResource result = await collection.GetAsync(siteNetworkServiceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteNetworkServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteNetworkServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFirstPartySiteNetworkService() + public async Task GetAll_ListAllNetworkSites() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceFirstPartyCreate.json - // this example is just showing the usage of "SiteNetworkServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceListByResourceGroup.json + // this example is just showing the usage of "SiteNetworkServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,43 +179,25 @@ public async Task CreateOrUpdate_CreateFirstPartySiteNetworkService() // get the collection of this SiteNetworkServiceResource SiteNetworkServiceCollection collection = resourceGroupResource.GetSiteNetworkServices(); - // invoke the operation - string siteNetworkServiceName = "testSiteNetworkServiceName"; - SiteNetworkServiceData data = new SiteNetworkServiceData(new AzureLocation("westUs2")) + // invoke the operation and iterate over the result + await foreach (SiteNetworkServiceResource item in collection.GetAllAsync()) { - Properties = new SiteNetworkServicePropertiesFormat() - { - SiteReferenceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/contosorg1/providers/microsoft.hybridnetwork/sites/testSite"), - NetworkServiceDesignVersionResourceReference = new SecretDeploymentResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/TestPublisher/networkServiceDesignGroups/TestNetworkServiceDesignGroupName/networkServiceDesignVersions/1.0.0"), - }, - DesiredStateConfigurationGroupValueReferences = -{ -["MyVM_Configuration"] = new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/contosorg1/providers/microsoft.hybridnetwork/configurationgroupvalues/MyVM_Configuration1"), -}, -}, - }, - Sku = new HybridNetworkSku(HybridNetworkSkuName.Standard), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, siteNetworkServiceName, data); - SiteNetworkServiceResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteNetworkServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteNetworkServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSiteNetworkService() + public async Task Exists_GetNetworkSite() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceCreate.json - // this example is just showing the usage of "SiteNetworkServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceGet.json + // this example is just showing the usage of "SiteNetworkServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,41 +216,17 @@ public async Task CreateOrUpdate_CreateSiteNetworkService() // invoke the operation string siteNetworkServiceName = "testSiteNetworkServiceName"; - SiteNetworkServiceData data = new SiteNetworkServiceData(new AzureLocation("westUs2")) - { - Properties = new SiteNetworkServicePropertiesFormat() - { - SiteReferenceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/contosorg1/providers/microsoft.hybridnetwork/sites/testSite"), - NetworkServiceDesignVersionResourceReference = new OpenDeploymentResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg/providers/Microsoft.HybridNetwork/publishers/TestPublisher/networkServiceDesignGroups/TestNetworkServiceDesignGroupName/networkServiceDesignVersions/1.0.0"), - }, - DesiredStateConfigurationGroupValueReferences = -{ -["MyVM_Configuration"] = new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/contosorg1/providers/microsoft.hybridnetwork/configurationgroupvalues/MyVM_Configuration1"), -}, -}, - }, - Sku = new HybridNetworkSku(HybridNetworkSkuName.Standard), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, siteNetworkServiceName, data); - SiteNetworkServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(siteNetworkServiceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteNetworkServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllNetworkSites() + public async Task GetIfExists_GetNetworkSite() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceListByResourceGroup.json - // this example is just showing the usage of "SiteNetworkServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceGet.json + // this example is just showing the usage of "SiteNetworkServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -249,17 +243,23 @@ public async Task GetAll_ListAllNetworkSites() // get the collection of this SiteNetworkServiceResource SiteNetworkServiceCollection collection = resourceGroupResource.GetSiteNetworkServices(); - // invoke the operation and iterate over the result - await foreach (SiteNetworkServiceResource item in collection.GetAllAsync()) + // invoke the operation + string siteNetworkServiceName = "testSiteNetworkServiceName"; + NullableResponse response = await collection.GetIfExistsAsync(siteNetworkServiceName); + SiteNetworkServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SiteNetworkServiceData resourceData = item.Data; + SiteNetworkServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteNetworkServiceResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteNetworkServiceResource.cs index 87d7d8f42bb3a..94da9c88b5c63 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteNetworkServiceResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteNetworkServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HybridNetwork.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridNetwork.Samples @@ -19,10 +18,10 @@ public partial class Sample_SiteNetworkServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkSite() + public async Task Get_GetNetworkSite() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceDelete.json - // this example is just showing the usage of "SiteNetworkServices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceGet.json + // this example is just showing the usage of "SiteNetworkServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteNetworkSite() SiteNetworkServiceResource siteNetworkService = client.GetSiteNetworkServiceResource(siteNetworkServiceResourceId); // invoke the operation - await siteNetworkService.DeleteAsync(WaitUntil.Completed); + SiteNetworkServiceResource result = await siteNetworkService.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteNetworkServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSite() + public async Task Delete_DeleteNetworkSite() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceGet.json - // this example is just showing the usage of "SiteNetworkServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceDelete.json + // this example is just showing the usage of "SiteNetworkServices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetNetworkSite() SiteNetworkServiceResource siteNetworkService = client.GetSiteNetworkServiceResource(siteNetworkServiceResourceId); // invoke the operation - SiteNetworkServiceResource result = await siteNetworkService.GetAsync(); + await siteNetworkService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteNetworkServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateNetworkSiteTags() SiteNetworkServiceResource siteNetworkService = client.GetSiteNetworkServiceResource(siteNetworkServiceResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; SiteNetworkServiceResource result = await siteNetworkService.UpdateAsync(tagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdateNetworkSiteTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSiteNetworkServices_ListAllHybridNetworkSitesInASubscription() - { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceListBySubscription.json - // this example is just showing the usage of "SiteNetworkServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SiteNetworkServiceResource item in subscriptionResource.GetSiteNetworkServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteNetworkServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteResource.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteResource.cs index 7b1248f747e1a..84c9d4d2842f5 100644 --- a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteResource.cs +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SiteResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.HybridNetwork.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.HybridNetwork.Samples @@ -19,10 +18,10 @@ public partial class Sample_SiteResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkSite() + public async Task Get_GetNetworkSite() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteDelete.json - // this example is just showing the usage of "Sites_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteGet.json + // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteNetworkSite() SiteResource site = client.GetSiteResource(siteResourceId); // invoke the operation - await site.DeleteAsync(WaitUntil.Completed); + SiteResource result = await site.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSite() + public async Task Delete_DeleteNetworkSite() { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteGet.json - // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteDelete.json + // this example is just showing the usage of "Sites_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetNetworkSite() SiteResource site = client.GetSiteResource(siteResourceId); // invoke the operation - SiteResource result = await site.GetAsync(); + await site.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateNetworkSiteTags() SiteResource site = client.GetSiteResource(siteResourceId); // invoke the operation - TagsObject tagsObject = new TagsObject() + TagsObject tagsObject = new TagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; SiteResource result = await site.UpdateAsync(tagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdateNetworkSiteTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSites_ListAllHybridNetworkSitesInASubscription() - { - // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteListBySubscription.json - // this example is just showing the usage of "Sites_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SiteResource item in subscriptionResource.GetSitesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..3a618b926f480 --- /dev/null +++ b/sdk/hybridnetwork/Azure.ResourceManager.HybridNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.HybridNetwork.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetConfigurationGroupValues_ListAllHybridNetworkSitesInASubscription() + { + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/ConfigurationGroupValueListBySubscription.json + // this example is just showing the usage of "ConfigurationGroupValues_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ConfigurationGroupValueResource item in subscriptionResource.GetConfigurationGroupValuesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfigurationGroupValueData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFunctions_ListAllNetworkFunctionResourcesInSubscription() + { + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/NetworkFunctionListBySubscription.json + // this example is just showing the usage of "NetworkFunctions_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFunctionResource item in subscriptionResource.GetNetworkFunctionsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFunctionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPublishers_ListAllPublisherResourcesInASubscription() + { + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/PublisherListBySubscription.json + // this example is just showing the usage of "Publishers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PublisherResource item in subscriptionResource.GetPublishersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublisherData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSites_ListAllHybridNetworkSitesInASubscription() + { + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteListBySubscription.json + // this example is just showing the usage of "Sites_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SiteResource item in subscriptionResource.GetSitesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSiteNetworkServices_ListAllHybridNetworkSitesInASubscription() + { + // Generated from example definition: specification/hybridnetwork/resource-manager/Microsoft.HybridNetwork/stable/2023-09-01/examples/SiteNetworkServiceListBySubscription.json + // this example is just showing the usage of "SiteNetworkServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SiteNetworkServiceResource item in subscriptionResource.GetSiteNetworkServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SiteNetworkServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaOrganizationCollection.cs b/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaOrganizationCollection.cs index 9d515065b0bb6..efa29a7025c38 100644 --- a/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaOrganizationCollection.cs +++ b/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaOrganizationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_InformaticaOrganizationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_OrganizationsGet() + public async Task CreateOrUpdate_OrganizationsCreateOrUpdate() { - // Generated from example definition: 2024-05-08/Organizations_Get_MaximumSet_Gen.json - // this example is just showing the usage of "InformaticaOrganizationResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-05-08/Organizations_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "InformaticaOrganizationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,51 @@ public async Task Get_OrganizationsGet() InformaticaOrganizationCollection collection = resourceGroupResource.GetInformaticaOrganizations(); // invoke the operation - string organizationName = "Sg"; - InformaticaOrganizationResource result = await collection.GetAsync(organizationName); + string organizationName = "C"; + InformaticaOrganizationData data = new InformaticaOrganizationData(new AzureLocation("pamjoudtssthlbhrnfjidr")) + { + Properties = new InformaticaOrganizationProperties + { + InformaticaProperties = new InformaticaProperties + { + OrganizationId = "wtdmhlwhkvgqdumaehgfgiqcxgnqpx", + OrganizationName = "nomzbvwe", + InformaticaRegion = "zfqodqpbeflhedypiijdkc", + SingleSignOnUri = new Uri("https://contoso.com/singlesignon"), + }, + MarketplaceDetails = new InformaticaMarketplaceDetails(new InformaticaOfferDetails("zajxpfacudwongxjvnnuhhpygmnydchgowjccyuzsjonegmqxcqqpnzafanggowfqdixnnutyfvmvwrkx", "cwswcfwmzhjcoksmueukegwaptvpcmbfyvixfhvgwnjyblqivqdkkwkunkgimiopwwkvgnwclmajhuty", "jfnemevyivtlxhectiutdavdgfyidolivuojumdzckp", "iaoxgaitteuoqgujkgxbdgryaobtkjjecuvchwutntrvmuorikrbqqegmelenbewhakiysprrnovjixyxrikscaptrbapbdspu", "tcvvsxdjnjlfmjhmvwklptdmxetnzydxyuhfqchoubmtoeqbchnfxoxqzezlgpxdnzyvzgkynjxzzgetkqccxvpzahxattluqdipvbdktqmndfefitzuifqjpschzlbvixnvznkmmgjwvkplfhemnapsewgqxggdzdokryhv") + { + TermUnit = "gjwmgevrblbosuogsvfspsgspetbnxaygkbelvadpgwiywl", + }) + { + MarketplaceSubscriptionId = "ovenlecocg", + }, + UserDetails = new InformaticaUserDetails + { + FirstName = "appvdclawzfjntdfdftjevlhvzropnxqtnypid", + LastName = "nzirbvzmkxtbrlamyatlcszebxgcyncxoascojsmacwvjsjvn", + EmailAddress = "7_-46@13D--3.m-4x-.11.c-9-.DHLYFc", + Upn = "undljch", + PhoneNumber = "fvcjylxlmhdnshsgywnzlyvshu", + }, + CompanyDetails = new InformaticaCompanyDetails + { + CompanyName = "xszcggknokhw", + OfficeAddress = "sbttzwyajgdbsvipuiclbzvkcvwyil", + Country = "gwkcpnwyaqc", + Domain = "utcxetzzpmbvwmjrvphqngvp", + Business = "pucosrtjv", + NumberOfEmployees = 25, + }, + LinkOrganizationToken = "jjfouhoqpumjvrdsfbimgcy", + }, + Tags = +{ +["key8430"] = "cagshqtjlxtqqhdwtchokvxszybp" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, organizationName, data); + InformaticaOrganizationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +95,10 @@ public async Task Get_OrganizationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_OrganizationsGet() + public async Task CreateOrUpdate_OrganizationsCreateOrUpdateMin() { - // Generated from example definition: 2024-05-08/Organizations_Get_MaximumSet_Gen.json - // this example is just showing the usage of "InformaticaOrganizationResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-05-08/Organizations_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "InformaticaOrganizationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +116,21 @@ public async Task Exists_OrganizationsGet() InformaticaOrganizationCollection collection = resourceGroupResource.GetInformaticaOrganizations(); // invoke the operation - string organizationName = "Sg"; - bool result = await collection.ExistsAsync(organizationName); + string organizationName = "n6v"; + InformaticaOrganizationData data = new InformaticaOrganizationData(new AzureLocation("pamjoudtssthlbhrnfjidr")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, organizationName, data); + InformaticaOrganizationResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InformaticaOrganizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_OrganizationsGet() + public async Task Get_OrganizationsGet() { // Generated from example definition: 2024-05-08/Organizations_Get_MaximumSet_Gen.json // this example is just showing the usage of "InformaticaOrganizationResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -103,21 +152,13 @@ public async Task GetIfExists_OrganizationsGet() // invoke the operation string organizationName = "Sg"; - NullableResponse response = await collection.GetIfExistsAsync(organizationName); - InformaticaOrganizationResource result = response.HasValue ? response.Value : null; + InformaticaOrganizationResource result = await collection.GetAsync(organizationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InformaticaOrganizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InformaticaOrganizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -155,9 +196,9 @@ public async Task Get_OrganizationsGetMin() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_OrganizationsGetMin() + public async Task Exists_OrganizationsGet() { - // Generated from example definition: 2024-05-08/Organizations_Get_MinimumSet_Gen.json + // Generated from example definition: 2024-05-08/Organizations_Get_MaximumSet_Gen.json // this example is just showing the usage of "InformaticaOrganizationResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -176,7 +217,7 @@ public async Task Exists_OrganizationsGetMin() InformaticaOrganizationCollection collection = resourceGroupResource.GetInformaticaOrganizations(); // invoke the operation - string organizationName = "q"; + string organizationName = "Sg"; bool result = await collection.ExistsAsync(organizationName); Console.WriteLine($"Succeeded: {result}"); @@ -184,7 +225,7 @@ public async Task Exists_OrganizationsGetMin() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_OrganizationsGetMin() + public async Task Exists_OrganizationsGetMin() { // Generated from example definition: 2024-05-08/Organizations_Get_MinimumSet_Gen.json // this example is just showing the usage of "InformaticaOrganizationResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -206,29 +247,17 @@ public async Task GetIfExists_OrganizationsGetMin() // invoke the operation string organizationName = "q"; - NullableResponse response = await collection.GetIfExistsAsync(organizationName); - InformaticaOrganizationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(organizationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InformaticaOrganizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_OrganizationsCreateOrUpdate() + public async Task GetIfExists_OrganizationsGet() { - // Generated from example definition: 2024-05-08/Organizations_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "InformaticaOrganizationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-05-08/Organizations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "InformaticaOrganizationResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -246,65 +275,30 @@ public async Task CreateOrUpdate_OrganizationsCreateOrUpdate() InformaticaOrganizationCollection collection = resourceGroupResource.GetInformaticaOrganizations(); // invoke the operation - string organizationName = "C"; - InformaticaOrganizationData data = new InformaticaOrganizationData(new AzureLocation("pamjoudtssthlbhrnfjidr")) - { - Properties = new InformaticaOrganizationProperties() - { - InformaticaProperties = new InformaticaProperties() - { - OrganizationId = "wtdmhlwhkvgqdumaehgfgiqcxgnqpx", - OrganizationName = "nomzbvwe", - InformaticaRegion = "zfqodqpbeflhedypiijdkc", - SingleSignOnUri = new Uri("https://contoso.com/singlesignon"), - }, - MarketplaceDetails = new InformaticaMarketplaceDetails(new InformaticaOfferDetails("zajxpfacudwongxjvnnuhhpygmnydchgowjccyuzsjonegmqxcqqpnzafanggowfqdixnnutyfvmvwrkx", "cwswcfwmzhjcoksmueukegwaptvpcmbfyvixfhvgwnjyblqivqdkkwkunkgimiopwwkvgnwclmajhuty", "jfnemevyivtlxhectiutdavdgfyidolivuojumdzckp", "iaoxgaitteuoqgujkgxbdgryaobtkjjecuvchwutntrvmuorikrbqqegmelenbewhakiysprrnovjixyxrikscaptrbapbdspu", "tcvvsxdjnjlfmjhmvwklptdmxetnzydxyuhfqchoubmtoeqbchnfxoxqzezlgpxdnzyvzgkynjxzzgetkqccxvpzahxattluqdipvbdktqmndfefitzuifqjpschzlbvixnvznkmmgjwvkplfhemnapsewgqxggdzdokryhv") - { - TermUnit = "gjwmgevrblbosuogsvfspsgspetbnxaygkbelvadpgwiywl", - }) - { - MarketplaceSubscriptionId = "ovenlecocg", - }, - UserDetails = new InformaticaUserDetails() - { - FirstName = "appvdclawzfjntdfdftjevlhvzropnxqtnypid", - LastName = "nzirbvzmkxtbrlamyatlcszebxgcyncxoascojsmacwvjsjvn", - EmailAddress = "7_-46@13D--3.m-4x-.11.c-9-.DHLYFc", - Upn = "undljch", - PhoneNumber = "fvcjylxlmhdnshsgywnzlyvshu", - }, - CompanyDetails = new InformaticaCompanyDetails() - { - CompanyName = "xszcggknokhw", - OfficeAddress = "sbttzwyajgdbsvipuiclbzvkcvwyil", - Country = "gwkcpnwyaqc", - Domain = "utcxetzzpmbvwmjrvphqngvp", - Business = "pucosrtjv", - NumberOfEmployees = 25, - }, - LinkOrganizationToken = "jjfouhoqpumjvrdsfbimgcy", - }, - Tags = -{ -["key8430"] = "cagshqtjlxtqqhdwtchokvxszybp", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, organizationName, data); - InformaticaOrganizationResource result = lro.Value; + string organizationName = "Sg"; + NullableResponse response = await collection.GetIfExistsAsync(organizationName); + InformaticaOrganizationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InformaticaOrganizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InformaticaOrganizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_OrganizationsCreateOrUpdateMin() + public async Task GetIfExists_OrganizationsGetMin() { - // Generated from example definition: 2024-05-08/Organizations_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "InformaticaOrganizationResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-05-08/Organizations_Get_MinimumSet_Gen.json + // this example is just showing the usage of "InformaticaOrganizationResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -322,16 +316,22 @@ public async Task CreateOrUpdate_OrganizationsCreateOrUpdateMin() InformaticaOrganizationCollection collection = resourceGroupResource.GetInformaticaOrganizations(); // invoke the operation - string organizationName = "n6v"; - InformaticaOrganizationData data = new InformaticaOrganizationData(new AzureLocation("pamjoudtssthlbhrnfjidr")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, organizationName, data); - InformaticaOrganizationResource result = lro.Value; + string organizationName = "q"; + NullableResponse response = await collection.GetIfExistsAsync(organizationName); + InformaticaOrganizationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InformaticaOrganizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InformaticaOrganizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaOrganizationResource.cs b/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaOrganizationResource.cs index 5d983aff53295..a55580355ac21 100644 --- a/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaOrganizationResource.cs +++ b/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaOrganizationResource.cs @@ -76,6 +76,58 @@ public async Task Get_OrganizationsGetMin() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_OrganizationsDelete() + { + // Generated from example definition: 2024-05-08/Organizations_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "InformaticaOrganizationResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this InformaticaOrganizationResource created on azure + // for more information of creating InformaticaOrganizationResource, please refer to the document of InformaticaOrganizationResource + string subscriptionId = "3599DA28-E346-4D9F-811E-189C0445F0FE"; + string resourceGroupName = "rgopenapi"; + string organizationName = "_"; + ResourceIdentifier informaticaOrganizationResourceId = InformaticaOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); + InformaticaOrganizationResource informaticaOrganization = client.GetInformaticaOrganizationResource(informaticaOrganizationResourceId); + + // invoke the operation + await informaticaOrganization.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_OrganizationsDeleteMin() + { + // Generated from example definition: 2024-05-08/Organizations_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "InformaticaOrganizationResource_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this InformaticaOrganizationResource created on azure + // for more information of creating InformaticaOrganizationResource, please refer to the document of InformaticaOrganizationResource + string subscriptionId = "3599DA28-E346-4D9F-811E-189C0445F0FE"; + string resourceGroupName = "rgopenapi"; + string organizationName = "_-"; + ResourceIdentifier informaticaOrganizationResourceId = InformaticaOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); + InformaticaOrganizationResource informaticaOrganization = client.GetInformaticaOrganizationResource(informaticaOrganizationResourceId); + + // invoke the operation + await informaticaOrganization.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_OrganizationsUpdate() @@ -97,18 +149,18 @@ public async Task Update_OrganizationsUpdate() InformaticaOrganizationResource informaticaOrganization = client.GetInformaticaOrganizationResource(informaticaOrganizationResourceId); // invoke the operation - InformaticaOrganizationPatch patch = new InformaticaOrganizationPatch() + InformaticaOrganizationPatch patch = new InformaticaOrganizationPatch { Tags = { -["key1918"] = "fbjvtuvzsghpl", +["key1918"] = "fbjvtuvzsghpl" }, - Properties = new InformaticaOrganizationPropertiesUpdate() + Properties = new InformaticaOrganizationPropertiesUpdate { - MarketplaceDetails = new InformaticaMarketplaceDetailsUpdate() + MarketplaceDetails = new InformaticaMarketplaceDetailsUpdate { MarketplaceSubscriptionId = "szhyxzgjtssjmlguivepc", - OfferDetails = new InformaticaOfferDetailsUpdate() + OfferDetails = new InformaticaOfferDetailsUpdate { PublisherId = "ktzfghsyjqbsswhltoaemgotmnorhdogvkaxplutbjjqzuepxizliynyakersobagvpwvpzwjtjjxigsqgcyqaahaxdijghnexliofhfjlqzjmmbvrhcvjxdodnexxizbgfhjopbwzjojxsluasnwwsgcajefglbcvzpaeblanhmurcculndtfwnfjyxol", OfferId = "idaxbflabvjsippplyenvrpgeydsjxcmyubgukffkcdvlvrtwpdhnvdblxjsldiuswrchsibk", @@ -118,7 +170,7 @@ public async Task Update_OrganizationsUpdate() TermId = "eolmwogtgpdncqoigqcdomupwummaicwvdxgbskpdsmjizdfbdgbxbuekcpwmenqzbhqxpdnjtup", }, }, - UserDetails = new InformaticaUserDetailsUpdate() + UserDetails = new InformaticaUserDetailsUpdate { FirstName = "qguqrmanyupoi", LastName = "ugzg", @@ -126,7 +178,7 @@ public async Task Update_OrganizationsUpdate() Upn = "viwjrkn", PhoneNumber = "uxa", }, - CompanyDetails = new InformaticaCompanyDetailsUpdate() + CompanyDetails = new InformaticaCompanyDetailsUpdate { CompanyName = "xkrvbozrjcvappqeeyt", OfficeAddress = "sfcx", @@ -178,58 +230,6 @@ public async Task Update_OrganizationsUpdateMin() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_OrganizationsDelete() - { - // Generated from example definition: 2024-05-08/Organizations_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "InformaticaOrganizationResource_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this InformaticaOrganizationResource created on azure - // for more information of creating InformaticaOrganizationResource, please refer to the document of InformaticaOrganizationResource - string subscriptionId = "3599DA28-E346-4D9F-811E-189C0445F0FE"; - string resourceGroupName = "rgopenapi"; - string organizationName = "_"; - ResourceIdentifier informaticaOrganizationResourceId = InformaticaOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); - InformaticaOrganizationResource informaticaOrganization = client.GetInformaticaOrganizationResource(informaticaOrganizationResourceId); - - // invoke the operation - await informaticaOrganization.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_OrganizationsDeleteMin() - { - // Generated from example definition: 2024-05-08/Organizations_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "InformaticaOrganizationResource_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this InformaticaOrganizationResource created on azure - // for more information of creating InformaticaOrganizationResource, please refer to the document of InformaticaOrganizationResource - string subscriptionId = "3599DA28-E346-4D9F-811E-189C0445F0FE"; - string resourceGroupName = "rgopenapi"; - string organizationName = "_-"; - ResourceIdentifier informaticaOrganizationResourceId = InformaticaOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); - InformaticaOrganizationResource informaticaOrganization = client.GetInformaticaOrganizationResource(informaticaOrganizationResourceId); - - // invoke the operation - await informaticaOrganization.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetServerlessMetadata_OrganizationsGetServerlessMetadata() diff --git a/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaServerlessRuntimeCollection.cs b/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaServerlessRuntimeCollection.cs index 2f12d50ee9ed8..24c28db2de4d4 100644 --- a/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaServerlessRuntimeCollection.cs +++ b/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaServerlessRuntimeCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_InformaticaServerlessRuntimeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ServerlessRuntimesGet() + public async Task CreateOrUpdate_ServerlessRuntimesCreateOrUpdate() { - // Generated from example definition: 2024-05-08/ServerlessRuntimes_Get_MaximumSet_Gen.json - // this example is just showing the usage of "InformaticaServerlessRuntimeResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-05-08/ServerlessRuntimes_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "InformaticaServerlessRuntimeResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task Get_ServerlessRuntimesGet() // for more information of creating InformaticaOrganizationResource, please refer to the document of InformaticaOrganizationResource string subscriptionId = "3599DA28-E346-4D9F-811E-189C0445F0FE"; string resourceGroupName = "rgopenapi"; - string organizationName = "e3Y"; + string organizationName = "__C"; ResourceIdentifier informaticaOrganizationResourceId = InformaticaOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); InformaticaOrganizationResource informaticaOrganization = client.GetInformaticaOrganizationResource(informaticaOrganizationResourceId); @@ -40,8 +40,59 @@ public async Task Get_ServerlessRuntimesGet() InformaticaServerlessRuntimeCollection collection = informaticaOrganization.GetInformaticaServerlessRuntimes(); // invoke the operation - string serverlessRuntimeName = "48-"; - InformaticaServerlessRuntimeResource result = await collection.GetAsync(serverlessRuntimeName); + string serverlessRuntimeName = "0j-__"; + InformaticaServerlessRuntimeData data = new InformaticaServerlessRuntimeData + { + Properties = new InformaticaServerlessRuntimeProperties("bkxdfopapbqucyhduewrubjpaei") + { + Description = "mqkaenjmxakvzrwmirelmhgiedto", + Platform = InformaticaPlatformType.Azure, + ApplicationType = InformaticaApplicationType.Cdi, + ComputeUnits = "bsctukmndvowse", + ExecutionTimeout = "ruiougpypny", + NetworkInterfaceConfiguration = new InformaticaNetworkInterfaceConfiguration(new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/HypernetVnet1"), new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/subnet1")) + { + VnetResourceGuid = "5328d299-1462-4be0-bef1-303a28e556a0", + }, + AdvancedCustomProperties = {new AdvancedCustomProperties +{ +Key = "qcmc", +Value = "unraxmnohdmvutt", +}}, + SupplementaryFileLocation = "zmlqtkncwgqhhupsnqluumz", + ServerlessRuntimeConfig = new ServerlessRuntimeConfigProperties + { + CdiConfigProps = {new CdiConfigProperties("hngsdqvtjdhwqlbqfotipaiwjuys", "zlrlbg", new InformaticaApplicationConfigs[] +{ +new InformaticaApplicationConfigs( + "lw", + "upfvjrqcrwwedfujkmsodeinw", + "mozgsetpwjmtyl", + "dixfyeobngivyvf", + "j", + "zvgkqwmi") +})}, + CdieConfigProps = {new CdiConfigProperties("hngsdqvtjdhwqlbqfotipaiwjuys", "zlrlbg", new InformaticaApplicationConfigs[] +{ +new InformaticaApplicationConfigs( + "lw", + "upfvjrqcrwwedfujkmsodeinw", + "mozgsetpwjmtyl", + "dixfyeobngivyvf", + "j", + "zvgkqwmi") +})}, + }, + ServerlessRuntimeTags = {new ServerlessRuntimeTag +{ +Name = "korveuycuwhs", +Value = "uyiuegxnkgp", +}}, + UserContextToken = "oludf", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverlessRuntimeName, data); + InformaticaServerlessRuntimeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +103,10 @@ public async Task Get_ServerlessRuntimesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServerlessRuntimesGet() + public async Task CreateOrUpdate_ServerlessRuntimesCreateOrUpdateMin() { - // Generated from example definition: 2024-05-08/ServerlessRuntimes_Get_MaximumSet_Gen.json - // this example is just showing the usage of "InformaticaServerlessRuntimeResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-05-08/ServerlessRuntimes_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "InformaticaServerlessRuntimeResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,7 +117,7 @@ public async Task Exists_ServerlessRuntimesGet() // for more information of creating InformaticaOrganizationResource, please refer to the document of InformaticaOrganizationResource string subscriptionId = "3599DA28-E346-4D9F-811E-189C0445F0FE"; string resourceGroupName = "rgopenapi"; - string organizationName = "e3Y"; + string organizationName = "-4Z__7"; ResourceIdentifier informaticaOrganizationResourceId = InformaticaOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); InformaticaOrganizationResource informaticaOrganization = client.GetInformaticaOrganizationResource(informaticaOrganizationResourceId); @@ -74,15 +125,21 @@ public async Task Exists_ServerlessRuntimesGet() InformaticaServerlessRuntimeCollection collection = informaticaOrganization.GetInformaticaServerlessRuntimes(); // invoke the operation - string serverlessRuntimeName = "48-"; - bool result = await collection.ExistsAsync(serverlessRuntimeName); + string serverlessRuntimeName = "J"; + InformaticaServerlessRuntimeData data = new InformaticaServerlessRuntimeData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverlessRuntimeName, data); + InformaticaServerlessRuntimeResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InformaticaServerlessRuntimeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServerlessRuntimesGet() + public async Task Get_ServerlessRuntimesGet() { // Generated from example definition: 2024-05-08/ServerlessRuntimes_Get_MaximumSet_Gen.json // this example is just showing the usage of "InformaticaServerlessRuntimeResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,21 +162,13 @@ public async Task GetIfExists_ServerlessRuntimesGet() // invoke the operation string serverlessRuntimeName = "48-"; - NullableResponse response = await collection.GetIfExistsAsync(serverlessRuntimeName); - InformaticaServerlessRuntimeResource result = response.HasValue ? response.Value : null; + InformaticaServerlessRuntimeResource result = await collection.GetAsync(serverlessRuntimeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InformaticaServerlessRuntimeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InformaticaServerlessRuntimeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -158,9 +207,9 @@ public async Task Get_ServerlessRuntimesGetMin() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServerlessRuntimesGetMin() + public async Task Exists_ServerlessRuntimesGet() { - // Generated from example definition: 2024-05-08/ServerlessRuntimes_Get_MinimumSet_Gen.json + // Generated from example definition: 2024-05-08/ServerlessRuntimes_Get_MaximumSet_Gen.json // this example is just showing the usage of "InformaticaServerlessRuntimeResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -172,7 +221,7 @@ public async Task Exists_ServerlessRuntimesGetMin() // for more information of creating InformaticaOrganizationResource, please refer to the document of InformaticaOrganizationResource string subscriptionId = "3599DA28-E346-4D9F-811E-189C0445F0FE"; string resourceGroupName = "rgopenapi"; - string organizationName = "YC"; + string organizationName = "e3Y"; ResourceIdentifier informaticaOrganizationResourceId = InformaticaOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); InformaticaOrganizationResource informaticaOrganization = client.GetInformaticaOrganizationResource(informaticaOrganizationResourceId); @@ -180,7 +229,7 @@ public async Task Exists_ServerlessRuntimesGetMin() InformaticaServerlessRuntimeCollection collection = informaticaOrganization.GetInformaticaServerlessRuntimes(); // invoke the operation - string serverlessRuntimeName = "___"; + string serverlessRuntimeName = "48-"; bool result = await collection.ExistsAsync(serverlessRuntimeName); Console.WriteLine($"Succeeded: {result}"); @@ -188,7 +237,7 @@ public async Task Exists_ServerlessRuntimesGetMin() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServerlessRuntimesGetMin() + public async Task Exists_ServerlessRuntimesGetMin() { // Generated from example definition: 2024-05-08/ServerlessRuntimes_Get_MinimumSet_Gen.json // this example is just showing the usage of "InformaticaServerlessRuntimeResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -211,29 +260,17 @@ public async Task GetIfExists_ServerlessRuntimesGetMin() // invoke the operation string serverlessRuntimeName = "___"; - NullableResponse response = await collection.GetIfExistsAsync(serverlessRuntimeName); - InformaticaServerlessRuntimeResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serverlessRuntimeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InformaticaServerlessRuntimeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServerlessRuntimesCreateOrUpdate() + public async Task GetIfExists_ServerlessRuntimesGet() { - // Generated from example definition: 2024-05-08/ServerlessRuntimes_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "InformaticaServerlessRuntimeResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-05-08/ServerlessRuntimes_Get_MaximumSet_Gen.json + // this example is just showing the usage of "InformaticaServerlessRuntimeResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -244,7 +281,7 @@ public async Task CreateOrUpdate_ServerlessRuntimesCreateOrUpdate() // for more information of creating InformaticaOrganizationResource, please refer to the document of InformaticaOrganizationResource string subscriptionId = "3599DA28-E346-4D9F-811E-189C0445F0FE"; string resourceGroupName = "rgopenapi"; - string organizationName = "__C"; + string organizationName = "e3Y"; ResourceIdentifier informaticaOrganizationResourceId = InformaticaOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); InformaticaOrganizationResource informaticaOrganization = client.GetInformaticaOrganizationResource(informaticaOrganizationResourceId); @@ -252,73 +289,30 @@ public async Task CreateOrUpdate_ServerlessRuntimesCreateOrUpdate() InformaticaServerlessRuntimeCollection collection = informaticaOrganization.GetInformaticaServerlessRuntimes(); // invoke the operation - string serverlessRuntimeName = "0j-__"; - InformaticaServerlessRuntimeData data = new InformaticaServerlessRuntimeData() - { - Properties = new InformaticaServerlessRuntimeProperties("bkxdfopapbqucyhduewrubjpaei") - { - Description = "mqkaenjmxakvzrwmirelmhgiedto", - Platform = InformaticaPlatformType.Azure, - ApplicationType = InformaticaApplicationType.Cdi, - ComputeUnits = "bsctukmndvowse", - ExecutionTimeout = "ruiougpypny", - NetworkInterfaceConfiguration = new InformaticaNetworkInterfaceConfiguration(new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/HypernetVnet1"), new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/subnet1")) - { - VnetResourceGuid = "5328d299-1462-4be0-bef1-303a28e556a0", - }, - AdvancedCustomProperties = -{ -new AdvancedCustomProperties() -{ -Key = "qcmc", -Value = "unraxmnohdmvutt", -} -}, - SupplementaryFileLocation = "zmlqtkncwgqhhupsnqluumz", - ServerlessRuntimeConfig = new ServerlessRuntimeConfigProperties() - { - CdiConfigProps = -{ -new CdiConfigProperties("hngsdqvtjdhwqlbqfotipaiwjuys","zlrlbg",new InformaticaApplicationConfigs[] -{ -new InformaticaApplicationConfigs("lw","upfvjrqcrwwedfujkmsodeinw","mozgsetpwjmtyl","dixfyeobngivyvf","j","zvgkqwmi") -}) -}, - CdieConfigProps = -{ -new CdiConfigProperties("hngsdqvtjdhwqlbqfotipaiwjuys","zlrlbg",new InformaticaApplicationConfigs[] -{ -new InformaticaApplicationConfigs("lw","upfvjrqcrwwedfujkmsodeinw","mozgsetpwjmtyl","dixfyeobngivyvf","j","zvgkqwmi") -}) -}, - }, - ServerlessRuntimeTags = -{ -new ServerlessRuntimeTag() -{ -Name = "korveuycuwhs", -Value = "uyiuegxnkgp", -} -}, - UserContextToken = "oludf", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverlessRuntimeName, data); - InformaticaServerlessRuntimeResource result = lro.Value; + string serverlessRuntimeName = "48-"; + NullableResponse response = await collection.GetIfExistsAsync(serverlessRuntimeName); + InformaticaServerlessRuntimeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InformaticaServerlessRuntimeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InformaticaServerlessRuntimeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServerlessRuntimesCreateOrUpdateMin() + public async Task GetIfExists_ServerlessRuntimesGetMin() { - // Generated from example definition: 2024-05-08/ServerlessRuntimes_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "InformaticaServerlessRuntimeResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-05-08/ServerlessRuntimes_Get_MinimumSet_Gen.json + // this example is just showing the usage of "InformaticaServerlessRuntimeResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -329,7 +323,7 @@ public async Task CreateOrUpdate_ServerlessRuntimesCreateOrUpdateMin() // for more information of creating InformaticaOrganizationResource, please refer to the document of InformaticaOrganizationResource string subscriptionId = "3599DA28-E346-4D9F-811E-189C0445F0FE"; string resourceGroupName = "rgopenapi"; - string organizationName = "-4Z__7"; + string organizationName = "YC"; ResourceIdentifier informaticaOrganizationResourceId = InformaticaOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); InformaticaOrganizationResource informaticaOrganization = client.GetInformaticaOrganizationResource(informaticaOrganizationResourceId); @@ -337,16 +331,22 @@ public async Task CreateOrUpdate_ServerlessRuntimesCreateOrUpdateMin() InformaticaServerlessRuntimeCollection collection = informaticaOrganization.GetInformaticaServerlessRuntimes(); // invoke the operation - string serverlessRuntimeName = "J"; - InformaticaServerlessRuntimeData data = new InformaticaServerlessRuntimeData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverlessRuntimeName, data); - InformaticaServerlessRuntimeResource result = lro.Value; + string serverlessRuntimeName = "___"; + NullableResponse response = await collection.GetIfExistsAsync(serverlessRuntimeName); + InformaticaServerlessRuntimeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InformaticaServerlessRuntimeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InformaticaServerlessRuntimeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaServerlessRuntimeResource.cs b/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaServerlessRuntimeResource.cs index 975874309ef68..100bb274170f8 100644 --- a/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaServerlessRuntimeResource.cs +++ b/sdk/informaticadatamanagement/Azure.ResourceManager.InformaticaDataManagement/samples/Generated/Samples/Sample_InformaticaServerlessRuntimeResource.cs @@ -127,9 +127,9 @@ public async Task Update_ServerlessRuntimesUpdate() InformaticaServerlessRuntimeResource informaticaServerlessRuntime = client.GetInformaticaServerlessRuntimeResource(informaticaServerlessRuntimeResourceId); // invoke the operation - InformaticaServerlessRuntimePatch patch = new InformaticaServerlessRuntimePatch() + InformaticaServerlessRuntimePatch patch = new InformaticaServerlessRuntimePatch { - Properties = new ServerlessRuntimePropertiesUpdate() + Properties = new ServerlessRuntimePropertiesUpdate { Description = "ocprslpljoikxyduackzqnkuhyzrh", Platform = InformaticaPlatformType.Azure, @@ -137,46 +137,46 @@ public async Task Update_ServerlessRuntimesUpdate() ComputeUnits = "uncwbpu", ExecutionTimeout = "tjyfytuywriabt", ServerlessAccountLocation = "goaugkyfanqfnvcmntreibqrswfpis", - NetworkInterfaceConfiguration = new InformaticaNetworkInterfaceConfigurationUpdate() + NetworkInterfaceConfiguration = new InformaticaNetworkInterfaceConfigurationUpdate { VnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/HypernetVnet1"), SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/subnet1"), VnetResourceGuid = "5328d299-1462-4be0-bef1-303a28e556a0", }, - AdvancedCustomProperties = -{ -new AdvancedCustomProperties() + AdvancedCustomProperties = {new AdvancedCustomProperties { Key = "qcmc", Value = "unraxmnohdmvutt", -} -}, +}}, SupplementaryFileLocation = "csxaqzpxu", - ServerlessRuntimeConfig = new ServerlessRuntimeConfigPropertiesUpdate() + ServerlessRuntimeConfig = new ServerlessRuntimeConfigPropertiesUpdate { - CdiConfigProps = -{ -new CdiConfigProperties("hngsdqvtjdhwqlbqfotipaiwjuys","zlrlbg",new InformaticaApplicationConfigs[] + CdiConfigProps = {new CdiConfigProperties("hngsdqvtjdhwqlbqfotipaiwjuys", "zlrlbg", new InformaticaApplicationConfigs[] { -new InformaticaApplicationConfigs("lw","upfvjrqcrwwedfujkmsodeinw","mozgsetpwjmtyl","dixfyeobngivyvf","j","zvgkqwmi") -}) -}, - CdieConfigProps = +new InformaticaApplicationConfigs( + "lw", + "upfvjrqcrwwedfujkmsodeinw", + "mozgsetpwjmtyl", + "dixfyeobngivyvf", + "j", + "zvgkqwmi") +})}, + CdieConfigProps = {new CdiConfigProperties("hngsdqvtjdhwqlbqfotipaiwjuys", "zlrlbg", new InformaticaApplicationConfigs[] { -new CdiConfigProperties("hngsdqvtjdhwqlbqfotipaiwjuys","zlrlbg",new InformaticaApplicationConfigs[] -{ -new InformaticaApplicationConfigs("lw","upfvjrqcrwwedfujkmsodeinw","mozgsetpwjmtyl","dixfyeobngivyvf","j","zvgkqwmi") -}) -}, +new InformaticaApplicationConfigs( + "lw", + "upfvjrqcrwwedfujkmsodeinw", + "mozgsetpwjmtyl", + "dixfyeobngivyvf", + "j", + "zvgkqwmi") +})}, }, - ServerlessRuntimeTags = -{ -new ServerlessRuntimeTag() + ServerlessRuntimeTags = {new ServerlessRuntimeTag { Name = "korveuycuwhs", Value = "uyiuegxnkgp", -} -}, +}}, UserContextToken = "ctgebtvjhwh", }, }; diff --git a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisSummaryCollection.cs b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisSummaryCollection.cs index bf11c1fbae715..802c2bc807b32 100644 --- a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisSummaryCollection.cs +++ b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisSummaryCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FirmwareAnalysisSummaryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SummariesListByFirmwareMaximumSetGen() + public async Task Get_SummariesGetMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_ListByFirmware_MaximumSet_Gen.json - // this example is just showing the usage of "Summaries_ListByFirmware" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_SummariesListByFirmwareMaximumSetGen() // get the collection of this FirmwareAnalysisSummaryResource FirmwareAnalysisSummaryCollection collection = iotFirmware.GetFirmwareAnalysisSummaries(); - // invoke the operation and iterate over the result - await foreach (FirmwareAnalysisSummaryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisSummaryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + FirmwareAnalysisSummaryName summaryName = FirmwareAnalysisSummaryName.Firmware; + FirmwareAnalysisSummaryResource result = await collection.GetAsync(summaryName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisSummaryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SummariesListByFirmwareMinimumSetGen() + public async Task Get_SummariesGetMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_ListByFirmware_MinimumSet_Gen.json - // this example is just showing the usage of "Summaries_ListByFirmware" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_Get_MinimumSet_Gen.json + // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,25 +75,23 @@ public async Task GetAll_SummariesListByFirmwareMinimumSetGen() // get the collection of this FirmwareAnalysisSummaryResource FirmwareAnalysisSummaryCollection collection = iotFirmware.GetFirmwareAnalysisSummaries(); - // invoke the operation and iterate over the result - await foreach (FirmwareAnalysisSummaryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisSummaryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + FirmwareAnalysisSummaryName summaryName = FirmwareAnalysisSummaryName.Firmware; + FirmwareAnalysisSummaryResource result = await collection.GetAsync(summaryName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisSummaryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SummariesGetMaximumSetGen() + public async Task GetAll_SummariesListByFirmwareMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_ListByFirmware_MaximumSet_Gen.json + // this example is just showing the usage of "Summaries_ListByFirmware" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,23 +110,25 @@ public async Task Get_SummariesGetMaximumSetGen() // get the collection of this FirmwareAnalysisSummaryResource FirmwareAnalysisSummaryCollection collection = iotFirmware.GetFirmwareAnalysisSummaries(); - // invoke the operation - FirmwareAnalysisSummaryName summaryName = FirmwareAnalysisSummaryName.Firmware; - FirmwareAnalysisSummaryResource result = await collection.GetAsync(summaryName); + // invoke the operation and iterate over the result + await foreach (FirmwareAnalysisSummaryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisSummaryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisSummaryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SummariesGetMaximumSetGen() + public async Task GetAll_SummariesListByFirmwareMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_ListByFirmware_MinimumSet_Gen.json + // this example is just showing the usage of "Summaries_ListByFirmware" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,16 +147,22 @@ public async Task Exists_SummariesGetMaximumSetGen() // get the collection of this FirmwareAnalysisSummaryResource FirmwareAnalysisSummaryCollection collection = iotFirmware.GetFirmwareAnalysisSummaries(); - // invoke the operation - FirmwareAnalysisSummaryName summaryName = FirmwareAnalysisSummaryName.Firmware; - bool result = await collection.ExistsAsync(summaryName); + // invoke the operation and iterate over the result + await foreach (FirmwareAnalysisSummaryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisSummaryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SummariesGetMaximumSetGen() + public async Task Exists_SummariesGetMaximumSetGen() { // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_Get_MaximumSet_Gen.json // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. @@ -182,26 +186,14 @@ public async Task GetIfExists_SummariesGetMaximumSetGen() // invoke the operation FirmwareAnalysisSummaryName summaryName = FirmwareAnalysisSummaryName.Firmware; - NullableResponse response = await collection.GetIfExistsAsync(summaryName); - FirmwareAnalysisSummaryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(summaryName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisSummaryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SummariesGetMinimumSetGen() + public async Task Exists_SummariesGetMinimumSetGen() { // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_Get_MinimumSet_Gen.json // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. @@ -225,20 +217,16 @@ public async Task Get_SummariesGetMinimumSetGen() // invoke the operation FirmwareAnalysisSummaryName summaryName = FirmwareAnalysisSummaryName.Firmware; - FirmwareAnalysisSummaryResource result = await collection.GetAsync(summaryName); + bool result = await collection.ExistsAsync(summaryName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisSummaryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SummariesGetMinimumSetGen() + public async Task GetIfExists_SummariesGetMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_Get_MinimumSet_Gen.json + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Summaries_Get_MaximumSet_Gen.json // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -260,9 +248,21 @@ public async Task Exists_SummariesGetMinimumSetGen() // invoke the operation FirmwareAnalysisSummaryName summaryName = FirmwareAnalysisSummaryName.Firmware; - bool result = await collection.ExistsAsync(summaryName); + NullableResponse response = await collection.GetIfExistsAsync(summaryName); + FirmwareAnalysisSummaryResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisSummaryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisWorkspaceCollection.cs b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisWorkspaceCollection.cs index 554e6e7e22ef6..1891e06eaa003 100644 --- a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisWorkspaceCollection.cs +++ b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisWorkspaceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FirmwareAnalysisWorkspaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkspacesListByResourceGroupMaximumSetGen() + public async Task CreateOrUpdate_WorkspacesCreateMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Create_MaximumSet_Gen.json + // this example is just showing the usage of "Workspaces_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,31 @@ public async Task GetAll_WorkspacesListByResourceGroupMaximumSetGen() // get the collection of this FirmwareAnalysisWorkspaceResource FirmwareAnalysisWorkspaceCollection collection = resourceGroupResource.GetFirmwareAnalysisWorkspaces(); - // invoke the operation and iterate over the result - await foreach (FirmwareAnalysisWorkspaceResource item in collection.GetAllAsync()) + // invoke the operation + string workspaceName = "E___-3"; + FirmwareAnalysisWorkspaceData data = new FirmwareAnalysisWorkspaceData(new AzureLocation("jjwbseilitjgdrhbvvkwviqj")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key450"] = "rzqqumbpfsbibnpirsm" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); + FirmwareAnalysisWorkspaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkspacesListByResourceGroupMinimumSetGen() + public async Task CreateOrUpdate_WorkspacesCreateMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Create_MinimumSet_Gen.json + // this example is just showing the usage of "Workspaces_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,25 +79,25 @@ public async Task GetAll_WorkspacesListByResourceGroupMinimumSetGen() // get the collection of this FirmwareAnalysisWorkspaceResource FirmwareAnalysisWorkspaceCollection collection = resourceGroupResource.GetFirmwareAnalysisWorkspaces(); - // invoke the operation and iterate over the result - await foreach (FirmwareAnalysisWorkspaceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string workspaceName = "E___-3"; + FirmwareAnalysisWorkspaceData data = new FirmwareAnalysisWorkspaceData(new AzureLocation("jjwbseilitjgdrhbvvkwviqj")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); + FirmwareAnalysisWorkspaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkspacesCreateMaximumSetGen() + public async Task Get_WorkspacesGetMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Create_MaximumSet_Gen.json - // this example is just showing the usage of "Workspaces_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +106,7 @@ public async Task CreateOrUpdate_WorkspacesCreateMaximumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; + string subscriptionId = "9781B4B5-0922-472A-80F0-B743D0596694"; string resourceGroupName = "rgworkspaces"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -109,16 +115,8 @@ public async Task CreateOrUpdate_WorkspacesCreateMaximumSetGen() FirmwareAnalysisWorkspaceCollection collection = resourceGroupResource.GetFirmwareAnalysisWorkspaces(); // invoke the operation - string workspaceName = "E___-3"; - FirmwareAnalysisWorkspaceData data = new FirmwareAnalysisWorkspaceData(new AzureLocation("jjwbseilitjgdrhbvvkwviqj")) - { - Tags = -{ -["key450"] = "rzqqumbpfsbibnpirsm", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); - FirmwareAnalysisWorkspaceResource result = lro.Value; + string workspaceName = "E_US"; + FirmwareAnalysisWorkspaceResource result = await collection.GetAsync(workspaceName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -129,10 +127,10 @@ public async Task CreateOrUpdate_WorkspacesCreateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkspacesCreateMinimumSetGen() + public async Task Get_WorkspacesGetMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Create_MinimumSet_Gen.json - // this example is just showing the usage of "Workspaces_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MinimumSet_Gen.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,7 +139,7 @@ public async Task CreateOrUpdate_WorkspacesCreateMinimumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; + string subscriptionId = "9781B4B5-0922-472A-80F0-B743D0596694"; string resourceGroupName = "rgworkspaces"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -150,10 +148,8 @@ public async Task CreateOrUpdate_WorkspacesCreateMinimumSetGen() FirmwareAnalysisWorkspaceCollection collection = resourceGroupResource.GetFirmwareAnalysisWorkspaces(); // invoke the operation - string workspaceName = "E___-3"; - FirmwareAnalysisWorkspaceData data = new FirmwareAnalysisWorkspaceData(new AzureLocation("jjwbseilitjgdrhbvvkwviqj")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); - FirmwareAnalysisWorkspaceResource result = lro.Value; + string workspaceName = "E_US"; + FirmwareAnalysisWorkspaceResource result = await collection.GetAsync(workspaceName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -164,10 +160,10 @@ public async Task CreateOrUpdate_WorkspacesCreateMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkspacesGetMaximumSetGen() + public async Task GetAll_WorkspacesListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,7 +172,7 @@ public async Task Get_WorkspacesGetMaximumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "9781B4B5-0922-472A-80F0-B743D0596694"; + string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; string resourceGroupName = "rgworkspaces"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -184,23 +180,25 @@ public async Task Get_WorkspacesGetMaximumSetGen() // get the collection of this FirmwareAnalysisWorkspaceResource FirmwareAnalysisWorkspaceCollection collection = resourceGroupResource.GetFirmwareAnalysisWorkspaces(); - // invoke the operation - string workspaceName = "E_US"; - FirmwareAnalysisWorkspaceResource result = await collection.GetAsync(workspaceName); + // invoke the operation and iterate over the result + await foreach (FirmwareAnalysisWorkspaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkspacesGetMaximumSetGen() + public async Task GetAll_WorkspacesListByResourceGroupMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -209,7 +207,7 @@ public async Task Exists_WorkspacesGetMaximumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "9781B4B5-0922-472A-80F0-B743D0596694"; + string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; string resourceGroupName = "rgworkspaces"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -217,16 +215,22 @@ public async Task Exists_WorkspacesGetMaximumSetGen() // get the collection of this FirmwareAnalysisWorkspaceResource FirmwareAnalysisWorkspaceCollection collection = resourceGroupResource.GetFirmwareAnalysisWorkspaces(); - // invoke the operation - string workspaceName = "E_US"; - bool result = await collection.ExistsAsync(workspaceName); + // invoke the operation and iterate over the result + await foreach (FirmwareAnalysisWorkspaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkspacesGetMaximumSetGen() + public async Task Exists_WorkspacesGetMaximumSetGen() { // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MaximumSet_Gen.json // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -248,26 +252,14 @@ public async Task GetIfExists_WorkspacesGetMaximumSetGen() // invoke the operation string workspaceName = "E_US"; - NullableResponse response = await collection.GetIfExistsAsync(workspaceName); - FirmwareAnalysisWorkspaceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(workspaceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkspacesGetMinimumSetGen() + public async Task Exists_WorkspacesGetMinimumSetGen() { // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MinimumSet_Gen.json // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -289,20 +281,16 @@ public async Task Get_WorkspacesGetMinimumSetGen() // invoke the operation string workspaceName = "E_US"; - FirmwareAnalysisWorkspaceResource result = await collection.GetAsync(workspaceName); + bool result = await collection.ExistsAsync(workspaceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkspacesGetMinimumSetGen() + public async Task GetIfExists_WorkspacesGetMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MinimumSet_Gen.json + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MaximumSet_Gen.json // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -322,9 +310,21 @@ public async Task Exists_WorkspacesGetMinimumSetGen() // invoke the operation string workspaceName = "E_US"; - bool result = await collection.ExistsAsync(workspaceName); + NullableResponse response = await collection.GetIfExistsAsync(workspaceName); + FirmwareAnalysisWorkspaceResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisWorkspaceResource.cs b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisWorkspaceResource.cs index 1f37abf8d3939..3d43c8a8739ad 100644 --- a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisWorkspaceResource.cs +++ b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_FirmwareAnalysisWorkspaceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.IotFirmwareDefense.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.IotFirmwareDefense.Samples @@ -19,72 +18,10 @@ public partial class Sample_FirmwareAnalysisWorkspaceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetFirmwareAnalysisWorkspaces_WorkspacesListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (FirmwareAnalysisWorkspaceResource item in subscriptionResource.GetFirmwareAnalysisWorkspacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetFirmwareAnalysisWorkspaces_WorkspacesListBySubscriptionMinimumSetGen() - { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (FirmwareAnalysisWorkspaceResource item in subscriptionResource.GetFirmwareAnalysisWorkspacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirmwareAnalysisWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_WorkspacesUpdateMaximumSetGen() + public async Task Get_WorkspacesGetMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Update_MaximumSet_Gen.json - // this example is just showing the usage of "Workspaces_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,15 +30,14 @@ public async Task Update_WorkspacesUpdateMaximumSetGen() // this example assumes you already have this FirmwareAnalysisWorkspaceResource created on azure // for more information of creating FirmwareAnalysisWorkspaceResource, please refer to the document of FirmwareAnalysisWorkspaceResource - string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; + string subscriptionId = "9781B4B5-0922-472A-80F0-B743D0596694"; string resourceGroupName = "rgworkspaces"; - string workspaceName = "E___-3"; + string workspaceName = "E_US"; ResourceIdentifier firmwareAnalysisWorkspaceResourceId = FirmwareAnalysisWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); FirmwareAnalysisWorkspaceResource firmwareAnalysisWorkspace = client.GetFirmwareAnalysisWorkspaceResource(firmwareAnalysisWorkspaceResourceId); // invoke the operation - FirmwareAnalysisWorkspacePatch patch = new FirmwareAnalysisWorkspacePatch(); - FirmwareAnalysisWorkspaceResource result = await firmwareAnalysisWorkspace.UpdateAsync(patch); + FirmwareAnalysisWorkspaceResource result = await firmwareAnalysisWorkspace.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -112,10 +48,10 @@ public async Task Update_WorkspacesUpdateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WorkspacesUpdateMinimumSetGen() + public async Task Get_WorkspacesGetMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Update_MinimumSet_Gen.json - // this example is just showing the usage of "Workspaces_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MinimumSet_Gen.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -124,15 +60,14 @@ public async Task Update_WorkspacesUpdateMinimumSetGen() // this example assumes you already have this FirmwareAnalysisWorkspaceResource created on azure // for more information of creating FirmwareAnalysisWorkspaceResource, please refer to the document of FirmwareAnalysisWorkspaceResource - string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; + string subscriptionId = "9781B4B5-0922-472A-80F0-B743D0596694"; string resourceGroupName = "rgworkspaces"; - string workspaceName = "E___-3"; + string workspaceName = "E_US"; ResourceIdentifier firmwareAnalysisWorkspaceResourceId = FirmwareAnalysisWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); FirmwareAnalysisWorkspaceResource firmwareAnalysisWorkspace = client.GetFirmwareAnalysisWorkspaceResource(firmwareAnalysisWorkspaceResourceId); // invoke the operation - FirmwareAnalysisWorkspacePatch patch = new FirmwareAnalysisWorkspacePatch(); - FirmwareAnalysisWorkspaceResource result = await firmwareAnalysisWorkspace.UpdateAsync(patch); + FirmwareAnalysisWorkspaceResource result = await firmwareAnalysisWorkspace.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -195,10 +130,10 @@ public async Task Delete_WorkspacesDeleteMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkspacesGetMaximumSetGen() + public async Task Update_WorkspacesUpdateMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Update_MaximumSet_Gen.json + // this example is just showing the usage of "Workspaces_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -207,14 +142,15 @@ public async Task Get_WorkspacesGetMaximumSetGen() // this example assumes you already have this FirmwareAnalysisWorkspaceResource created on azure // for more information of creating FirmwareAnalysisWorkspaceResource, please refer to the document of FirmwareAnalysisWorkspaceResource - string subscriptionId = "9781B4B5-0922-472A-80F0-B743D0596694"; + string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; string resourceGroupName = "rgworkspaces"; - string workspaceName = "E_US"; + string workspaceName = "E___-3"; ResourceIdentifier firmwareAnalysisWorkspaceResourceId = FirmwareAnalysisWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); FirmwareAnalysisWorkspaceResource firmwareAnalysisWorkspace = client.GetFirmwareAnalysisWorkspaceResource(firmwareAnalysisWorkspaceResourceId); // invoke the operation - FirmwareAnalysisWorkspaceResource result = await firmwareAnalysisWorkspace.GetAsync(); + FirmwareAnalysisWorkspacePatch patch = new FirmwareAnalysisWorkspacePatch(); + FirmwareAnalysisWorkspaceResource result = await firmwareAnalysisWorkspace.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -225,10 +161,10 @@ public async Task Get_WorkspacesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkspacesGetMinimumSetGen() + public async Task Update_WorkspacesUpdateMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Get_MinimumSet_Gen.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_Update_MinimumSet_Gen.json + // this example is just showing the usage of "Workspaces_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -237,14 +173,15 @@ public async Task Get_WorkspacesGetMinimumSetGen() // this example assumes you already have this FirmwareAnalysisWorkspaceResource created on azure // for more information of creating FirmwareAnalysisWorkspaceResource, please refer to the document of FirmwareAnalysisWorkspaceResource - string subscriptionId = "9781B4B5-0922-472A-80F0-B743D0596694"; + string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; string resourceGroupName = "rgworkspaces"; - string workspaceName = "E_US"; + string workspaceName = "E___-3"; ResourceIdentifier firmwareAnalysisWorkspaceResourceId = FirmwareAnalysisWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); FirmwareAnalysisWorkspaceResource firmwareAnalysisWorkspace = client.GetFirmwareAnalysisWorkspaceResource(firmwareAnalysisWorkspaceResourceId); // invoke the operation - FirmwareAnalysisWorkspaceResource result = await firmwareAnalysisWorkspace.GetAsync(); + FirmwareAnalysisWorkspacePatch patch = new FirmwareAnalysisWorkspacePatch(); + FirmwareAnalysisWorkspaceResource result = await firmwareAnalysisWorkspace.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -274,7 +211,7 @@ public async Task GenerateUploadUri_WorkspacesGenerateUploadUrlMaximumSetGen() FirmwareAnalysisWorkspaceResource firmwareAnalysisWorkspace = client.GetFirmwareAnalysisWorkspaceResource(firmwareAnalysisWorkspaceResourceId); // invoke the operation - FirmwareUploadUriContent content = new FirmwareUploadUriContent() + FirmwareUploadUriContent content = new FirmwareUploadUriContent { FirmwareId = "ytsfprbywi", }; diff --git a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_IotFirmwareCollection.cs b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_IotFirmwareCollection.cs index d5bc7c10b4670..9df1b7a31f13f 100644 --- a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_IotFirmwareCollection.cs +++ b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_IotFirmwareCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_IotFirmwareCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FirmwaresListByWorkspaceMaximumSetGen() + public async Task CreateOrUpdate_FirmwaresCreateMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_ListByWorkspace_MaximumSet_Gen.json - // this example is just showing the usage of "Firmwares_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Create_MaximumSet_Gen.json + // this example is just showing the usage of "Firmwares_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,38 @@ public async Task GetAll_FirmwaresListByWorkspaceMaximumSetGen() // get the collection of this IotFirmwareResource IotFirmwareCollection collection = firmwareAnalysisWorkspace.GetIotFirmwares(); - // invoke the operation and iterate over the result - await foreach (IotFirmwareResource item in collection.GetAllAsync()) + // invoke the operation + string firmwareId = "umrkdttp"; + IotFirmwareData data = new IotFirmwareData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotFirmwareData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + FileName = "wresexxulcdsdd", + Vendor = "vycmdhgtmepcptyoubztiuudpkcpd", + Model = "f", + Version = "s", + Description = "uz", + FileSize = 17L, + Status = FirmwareAnalysisStatus.Pending, + StatusMessages = {new FirmwareAnalysisStatusMessage +{ +Message = "ulvhmhokezathzzauiitu", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firmwareId, data); + IotFirmwareResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotFirmwareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FirmwaresListByWorkspaceMinimumSetGen() + public async Task CreateOrUpdate_FirmwaresCreateMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_ListByWorkspace_MinimumSet_Gen.json - // this example is just showing the usage of "Firmwares_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Create_MinimumSet_Gen.json + // this example is just showing the usage of "Firmwares_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,25 +88,25 @@ public async Task GetAll_FirmwaresListByWorkspaceMinimumSetGen() // get the collection of this IotFirmwareResource IotFirmwareCollection collection = firmwareAnalysisWorkspace.GetIotFirmwares(); - // invoke the operation and iterate over the result - await foreach (IotFirmwareResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotFirmwareData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string firmwareId = "umrkdttp"; + IotFirmwareData data = new IotFirmwareData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firmwareId, data); + IotFirmwareResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotFirmwareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FirmwaresCreateMaximumSetGen() + public async Task Get_FirmwaresGetMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Create_MaximumSet_Gen.json - // this example is just showing the usage of "Firmwares_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,25 +126,7 @@ public async Task CreateOrUpdate_FirmwaresCreateMaximumSetGen() // invoke the operation string firmwareId = "umrkdttp"; - IotFirmwareData data = new IotFirmwareData() - { - FileName = "wresexxulcdsdd", - Vendor = "vycmdhgtmepcptyoubztiuudpkcpd", - Model = "f", - Version = "s", - Description = "uz", - FileSize = 17L, - Status = FirmwareAnalysisStatus.Pending, - StatusMessages = -{ -new FirmwareAnalysisStatusMessage() -{ -Message = "ulvhmhokezathzzauiitu", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firmwareId, data); - IotFirmwareResource result = lro.Value; + IotFirmwareResource result = await collection.GetAsync(firmwareId); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -142,10 +137,10 @@ public async Task CreateOrUpdate_FirmwaresCreateMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FirmwaresCreateMinimumSetGen() + public async Task Get_FirmwaresGetMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Create_MinimumSet_Gen.json - // this example is just showing the usage of "Firmwares_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MinimumSet_Gen.json + // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,9 +160,7 @@ public async Task CreateOrUpdate_FirmwaresCreateMinimumSetGen() // invoke the operation string firmwareId = "umrkdttp"; - IotFirmwareData data = new IotFirmwareData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firmwareId, data); - IotFirmwareResource result = lro.Value; + IotFirmwareResource result = await collection.GetAsync(firmwareId); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -178,10 +171,10 @@ public async Task CreateOrUpdate_FirmwaresCreateMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FirmwaresGetMaximumSetGen() + public async Task GetAll_FirmwaresListByWorkspaceMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_ListByWorkspace_MaximumSet_Gen.json + // this example is just showing the usage of "Firmwares_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,23 +192,25 @@ public async Task Get_FirmwaresGetMaximumSetGen() // get the collection of this IotFirmwareResource IotFirmwareCollection collection = firmwareAnalysisWorkspace.GetIotFirmwares(); - // invoke the operation - string firmwareId = "umrkdttp"; - IotFirmwareResource result = await collection.GetAsync(firmwareId); + // invoke the operation and iterate over the result + await foreach (IotFirmwareResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotFirmwareData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotFirmwareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FirmwaresGetMaximumSetGen() + public async Task GetAll_FirmwaresListByWorkspaceMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_ListByWorkspace_MinimumSet_Gen.json + // this example is just showing the usage of "Firmwares_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -233,16 +228,22 @@ public async Task Exists_FirmwaresGetMaximumSetGen() // get the collection of this IotFirmwareResource IotFirmwareCollection collection = firmwareAnalysisWorkspace.GetIotFirmwares(); - // invoke the operation - string firmwareId = "umrkdttp"; - bool result = await collection.ExistsAsync(firmwareId); + // invoke the operation and iterate over the result + await foreach (IotFirmwareResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotFirmwareData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FirmwaresGetMaximumSetGen() + public async Task Exists_FirmwaresGetMaximumSetGen() { // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MaximumSet_Gen.json // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. @@ -265,26 +266,14 @@ public async Task GetIfExists_FirmwaresGetMaximumSetGen() // invoke the operation string firmwareId = "umrkdttp"; - NullableResponse response = await collection.GetIfExistsAsync(firmwareId); - IotFirmwareResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(firmwareId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotFirmwareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FirmwaresGetMinimumSetGen() + public async Task Exists_FirmwaresGetMinimumSetGen() { // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MinimumSet_Gen.json // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. @@ -307,20 +296,16 @@ public async Task Get_FirmwaresGetMinimumSetGen() // invoke the operation string firmwareId = "umrkdttp"; - IotFirmwareResource result = await collection.GetAsync(firmwareId); + bool result = await collection.ExistsAsync(firmwareId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotFirmwareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FirmwaresGetMinimumSetGen() + public async Task GetIfExists_FirmwaresGetMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MinimumSet_Gen.json + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MaximumSet_Gen.json // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -341,9 +326,21 @@ public async Task Exists_FirmwaresGetMinimumSetGen() // invoke the operation string firmwareId = "umrkdttp"; - bool result = await collection.ExistsAsync(firmwareId); + NullableResponse response = await collection.GetIfExistsAsync(firmwareId); + IotFirmwareResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotFirmwareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_IotFirmwareResource.cs b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_IotFirmwareResource.cs index cb6658a7b92f9..c42221ac7fa41 100644 --- a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_IotFirmwareResource.cs +++ b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_IotFirmwareResource.cs @@ -18,10 +18,10 @@ public partial class Sample_IotFirmwareResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetBinaryHardeningResults_BinaryHardeningListByFirmwareMaximumSetGen() + public async Task Get_FirmwaresGetMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/BinaryHardening_ListByFirmware_MaximumSet_Gen.json - // this example is just showing the usage of "BinaryHardening_ListByFirmware" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,28 +30,29 @@ public async Task GetBinaryHardeningResults_BinaryHardeningListByFirmwareMaximum // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "FirmwareAnalysisRG"; - string workspaceName = "default"; - string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; + string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; + string resourceGroupName = "rgworkspaces-firmwares"; + string workspaceName = "A7"; + string firmwareId = "umrkdttp"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation and iterate over the result - await foreach (BinaryHardeningResult item in iotFirmware.GetBinaryHardeningResultsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + IotFirmwareResource result = await iotFirmware.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotFirmwareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetBinaryHardeningResults_BinaryHardeningListByFirmwareMinimumSetGen() + public async Task Get_FirmwaresGetMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/BinaryHardening_ListByFirmware_MinimumSet_Gen.json - // this example is just showing the usage of "BinaryHardening_ListByFirmware" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MinimumSet_Gen.json + // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,28 +61,29 @@ public async Task GetBinaryHardeningResults_BinaryHardeningListByFirmwareMinimum // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "FirmwareAnalysisRG"; - string workspaceName = "default"; - string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; + string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; + string resourceGroupName = "rgworkspaces-firmwares"; + string workspaceName = "A7"; + string firmwareId = "umrkdttp"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation and iterate over the result - await foreach (BinaryHardeningResult item in iotFirmware.GetBinaryHardeningResultsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + IotFirmwareResource result = await iotFirmware.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotFirmwareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetCryptoCertificates_CryptoCertificatesListByFirmwareMaximumSetGen() + public async Task Delete_FirmwaresDeleteMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/CryptoCertificates_ListByFirmware_MaximumSet_Gen.json - // this example is just showing the usage of "CryptoCertificates_ListByFirmware" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "Firmwares_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -90,28 +92,25 @@ public async Task GetCryptoCertificates_CryptoCertificatesListByFirmwareMaximumS // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "FirmwareAnalysisRG"; - string workspaceName = "default"; - string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; + string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; + string resourceGroupName = "rgworkspaces-firmwares"; + string workspaceName = "A7"; + string firmwareId = "umrkdttp"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation and iterate over the result - await foreach (CryptoCertificateResult item in iotFirmware.GetCryptoCertificatesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + await iotFirmware.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetCryptoCertificates_CryptoCertificatesListByFirmwareMinimumSetGen() + public async Task Delete_FirmwaresDeleteMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/CryptoCertificates_ListByFirmware_MinimumSet_Gen.json - // this example is just showing the usage of "CryptoCertificates_ListByFirmware" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Delete_MinimumSet_Gen.json + // this example is just showing the usage of "Firmwares_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,28 +119,25 @@ public async Task GetCryptoCertificates_CryptoCertificatesListByFirmwareMinimumS // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "FirmwareAnalysisRG"; - string workspaceName = "default"; - string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; + string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; + string resourceGroupName = "rgworkspaces-firmwares"; + string workspaceName = "A7"; + string firmwareId = "umrkdttp"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation and iterate over the result - await foreach (CryptoCertificateResult item in iotFirmware.GetCryptoCertificatesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + await iotFirmware.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetCryptoKeys_CryptoKeysListByFirmwareMaximumSetGen() + public async Task Update_FirmwaresUpdateMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/CryptoKeys_ListByFirmware_MaximumSet_Gen.json - // this example is just showing the usage of "CryptoKeys_ListByFirmware" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Update_MaximumSet_Gen.json + // this example is just showing the usage of "Firmwares_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,28 +146,43 @@ public async Task GetCryptoKeys_CryptoKeysListByFirmwareMaximumSetGen() // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "FirmwareAnalysisRG"; - string workspaceName = "default"; - string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; + string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; + string resourceGroupName = "rgworkspaces-firmwares"; + string workspaceName = "A7"; + string firmwareId = "umrkdttp"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation and iterate over the result - await foreach (CryptoKeyResult item in iotFirmware.GetCryptoKeysAsync()) + // invoke the operation + IotFirmwarePatch patch = new IotFirmwarePatch { - Console.WriteLine($"Succeeded: {item}"); - } + FileName = "wresexxulcdsdd", + Vendor = "vycmdhgtmepcptyoubztiuudpkcpd", + Model = "f", + Version = "s", + Description = "uz", + FileSize = 17L, + Status = FirmwareAnalysisStatus.Pending, + StatusMessages = {new FirmwareAnalysisStatusMessage +{ +Message = "ulvhmhokezathzzauiitu", +}}, + }; + IotFirmwareResource result = await iotFirmware.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotFirmwareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetCryptoKeys_CryptoKeysListByFirmwareMinimumSetGen() + public async Task Update_FirmwaresUpdateMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/CryptoKeys_ListByFirmware_MinimumSet_Gen.json - // this example is just showing the usage of "CryptoKeys_ListByFirmware" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Update_MinimumSet_Gen.json + // this example is just showing the usage of "Firmwares_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,28 +191,30 @@ public async Task GetCryptoKeys_CryptoKeysListByFirmwareMinimumSetGen() // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "FirmwareAnalysisRG"; - string workspaceName = "default"; - string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; + string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; + string resourceGroupName = "rgworkspaces-firmwares"; + string workspaceName = "A7"; + string firmwareId = "umrkdttp"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation and iterate over the result - await foreach (CryptoKeyResult item in iotFirmware.GetCryptoKeysAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + IotFirmwarePatch patch = new IotFirmwarePatch(); + IotFirmwareResource result = await iotFirmware.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotFirmwareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetCves_CvesListByFirmwareMaximumSetGen() + public async Task GetBinaryHardeningResults_BinaryHardeningListByFirmwareMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Cves_ListByFirmware_MaximumSet_Gen.json - // this example is just showing the usage of "Cves_ListByFirmware" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/BinaryHardening_ListByFirmware_MaximumSet_Gen.json + // this example is just showing the usage of "BinaryHardening_ListByFirmware" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -218,7 +231,7 @@ public async Task GetCves_CvesListByFirmwareMaximumSetGen() IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); // invoke the operation and iterate over the result - await foreach (CveResult item in iotFirmware.GetCvesAsync()) + await foreach (BinaryHardeningResult item in iotFirmware.GetBinaryHardeningResultsAsync()) { Console.WriteLine($"Succeeded: {item}"); } @@ -228,10 +241,10 @@ public async Task GetCves_CvesListByFirmwareMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetCves_CvesListByFirmwareMinimumSetGen() + public async Task GetBinaryHardeningResults_BinaryHardeningListByFirmwareMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Cves_ListByFirmware_MinimumSet_Gen.json - // this example is just showing the usage of "Cves_ListByFirmware" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/BinaryHardening_ListByFirmware_MinimumSet_Gen.json + // this example is just showing the usage of "BinaryHardening_ListByFirmware" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -248,7 +261,7 @@ public async Task GetCves_CvesListByFirmwareMinimumSetGen() IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); // invoke the operation and iterate over the result - await foreach (CveResult item in iotFirmware.GetCvesAsync()) + await foreach (BinaryHardeningResult item in iotFirmware.GetBinaryHardeningResultsAsync()) { Console.WriteLine($"Succeeded: {item}"); } @@ -258,10 +271,10 @@ public async Task GetCves_CvesListByFirmwareMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FirmwaresUpdateMaximumSetGen() + public async Task GetCryptoCertificates_CryptoCertificatesListByFirmwareMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Update_MaximumSet_Gen.json - // this example is just showing the usage of "Firmwares_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/CryptoCertificates_ListByFirmware_MaximumSet_Gen.json + // this example is just showing the usage of "CryptoCertificates_ListByFirmware" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -270,46 +283,28 @@ public async Task Update_FirmwaresUpdateMaximumSetGen() // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; - string resourceGroupName = "rgworkspaces-firmwares"; - string workspaceName = "A7"; - string firmwareId = "umrkdttp"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "FirmwareAnalysisRG"; + string workspaceName = "default"; + string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation - IotFirmwarePatch patch = new IotFirmwarePatch() + // invoke the operation and iterate over the result + await foreach (CryptoCertificateResult item in iotFirmware.GetCryptoCertificatesAsync()) { - FileName = "wresexxulcdsdd", - Vendor = "vycmdhgtmepcptyoubztiuudpkcpd", - Model = "f", - Version = "s", - Description = "uz", - FileSize = 17L, - Status = FirmwareAnalysisStatus.Pending, - StatusMessages = -{ -new FirmwareAnalysisStatusMessage() -{ -Message = "ulvhmhokezathzzauiitu", -} -}, - }; - IotFirmwareResource result = await iotFirmware.UpdateAsync(patch); + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotFirmwareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FirmwaresUpdateMinimumSetGen() + public async Task GetCryptoCertificates_CryptoCertificatesListByFirmwareMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Update_MinimumSet_Gen.json - // this example is just showing the usage of "Firmwares_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/CryptoCertificates_ListByFirmware_MinimumSet_Gen.json + // this example is just showing the usage of "CryptoCertificates_ListByFirmware" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -318,30 +313,28 @@ public async Task Update_FirmwaresUpdateMinimumSetGen() // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; - string resourceGroupName = "rgworkspaces-firmwares"; - string workspaceName = "A7"; - string firmwareId = "umrkdttp"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "FirmwareAnalysisRG"; + string workspaceName = "default"; + string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation - IotFirmwarePatch patch = new IotFirmwarePatch(); - IotFirmwareResource result = await iotFirmware.UpdateAsync(patch); + // invoke the operation and iterate over the result + await foreach (CryptoCertificateResult item in iotFirmware.GetCryptoCertificatesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotFirmwareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_FirmwaresDeleteMaximumSetGen() + public async Task GetCryptoKeys_CryptoKeysListByFirmwareMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "Firmwares_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/CryptoKeys_ListByFirmware_MaximumSet_Gen.json + // this example is just showing the usage of "CryptoKeys_ListByFirmware" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -350,25 +343,28 @@ public async Task Delete_FirmwaresDeleteMaximumSetGen() // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; - string resourceGroupName = "rgworkspaces-firmwares"; - string workspaceName = "A7"; - string firmwareId = "umrkdttp"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "FirmwareAnalysisRG"; + string workspaceName = "default"; + string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation - await iotFirmware.DeleteAsync(WaitUntil.Completed); + // invoke the operation and iterate over the result + await foreach (CryptoKeyResult item in iotFirmware.GetCryptoKeysAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_FirmwaresDeleteMinimumSetGen() + public async Task GetCryptoKeys_CryptoKeysListByFirmwareMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Delete_MinimumSet_Gen.json - // this example is just showing the usage of "Firmwares_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/CryptoKeys_ListByFirmware_MinimumSet_Gen.json + // this example is just showing the usage of "CryptoKeys_ListByFirmware" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -377,25 +373,28 @@ public async Task Delete_FirmwaresDeleteMinimumSetGen() // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; - string resourceGroupName = "rgworkspaces-firmwares"; - string workspaceName = "A7"; - string firmwareId = "umrkdttp"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "FirmwareAnalysisRG"; + string workspaceName = "default"; + string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation - await iotFirmware.DeleteAsync(WaitUntil.Completed); + // invoke the operation and iterate over the result + await foreach (CryptoKeyResult item in iotFirmware.GetCryptoKeysAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FirmwaresGetMaximumSetGen() + public async Task GetCves_CvesListByFirmwareMaximumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Cves_ListByFirmware_MaximumSet_Gen.json + // this example is just showing the usage of "Cves_ListByFirmware" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -404,29 +403,28 @@ public async Task Get_FirmwaresGetMaximumSetGen() // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; - string resourceGroupName = "rgworkspaces-firmwares"; - string workspaceName = "A7"; - string firmwareId = "umrkdttp"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "FirmwareAnalysisRG"; + string workspaceName = "default"; + string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation - IotFirmwareResource result = await iotFirmware.GetAsync(); + // invoke the operation and iterate over the result + await foreach (CveResult item in iotFirmware.GetCvesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotFirmwareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FirmwaresGetMinimumSetGen() + public async Task GetCves_CvesListByFirmwareMinimumSetGen() { - // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Firmwares_Get_MinimumSet_Gen.json - // this example is just showing the usage of "Firmwares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Cves_ListByFirmware_MinimumSet_Gen.json + // this example is just showing the usage of "Cves_ListByFirmware" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -435,21 +433,20 @@ public async Task Get_FirmwaresGetMinimumSetGen() // this example assumes you already have this IotFirmwareResource created on azure // for more information of creating IotFirmwareResource, please refer to the document of IotFirmwareResource - string subscriptionId = "685C0C6F-9867-4B1C-A534-AA3A05B54BCE"; - string resourceGroupName = "rgworkspaces-firmwares"; - string workspaceName = "A7"; - string firmwareId = "umrkdttp"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "FirmwareAnalysisRG"; + string workspaceName = "default"; + string firmwareId = "109a9886-50bf-85a8-9d75-000000000000"; ResourceIdentifier iotFirmwareResourceId = IotFirmwareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, firmwareId); IotFirmwareResource iotFirmware = client.GetIotFirmwareResource(iotFirmwareResourceId); - // invoke the operation - IotFirmwareResource result = await iotFirmware.GetAsync(); + // invoke the operation and iterate over the result + await foreach (CveResult item in iotFirmware.GetCvesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotFirmwareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..89da8161556e6 --- /dev/null +++ b/sdk/iot/Azure.ResourceManager.IotFirmwareDefense/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotFirmwareDefense.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetFirmwareAnalysisWorkspaces_WorkspacesListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (FirmwareAnalysisWorkspaceResource item in subscriptionResource.GetFirmwareAnalysisWorkspacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetFirmwareAnalysisWorkspaces_WorkspacesListBySubscriptionMinimumSetGen() + { + // Generated from example definition: specification/fist/resource-manager/Microsoft.IoTFirmwareDefense/stable/2024-01-10/examples/Workspaces_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5443A01A-5242-4950-AC1A-2DD362180254"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (FirmwareAnalysisWorkspaceResource item in subscriptionResource.GetFirmwareAnalysisWorkspacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirmwareAnalysisWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralAppCollection.cs b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralAppCollection.cs index 0a7bdd7f84b19..1ae208927bed5 100644 --- a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralAppCollection.cs +++ b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralAppCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_IotCentralAppCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AppsGet() + public async Task CreateOrUpdate_AppsCreateOrUpdate() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Get.json - // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_CreateOrUpdate.json + // this example is just showing the usage of "Apps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,15 @@ public async Task Get_AppsGet() // invoke the operation string resourceName = "myIoTCentralApp"; - IotCentralAppResource result = await collection.GetAsync(resourceName); + IotCentralAppData data = new IotCentralAppData(new AzureLocation("westus"), new IotCentralAppSkuInfo(IotCentralAppSku.ST2)) + { + Identity = new ManagedServiceIdentity("SystemAssigned"), + DisplayName = "My IoT Central App", + Subdomain = "my-iot-central-app", + Template = "iotc-pnp-preview@1.0.0", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + IotCentralAppResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +61,7 @@ public async Task Get_AppsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AppsGet() + public async Task Get_AppsGet() { // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Get.json // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +83,21 @@ public async Task Exists_AppsGet() // invoke the operation string resourceName = "myIoTCentralApp"; - bool result = await collection.ExistsAsync(resourceName); + IotCentralAppResource result = await collection.GetAsync(resourceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotCentralAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AppsGet() + public async Task GetAll_AppsListByResourceGroup() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Get.json - // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_ListByResourceGroup.json + // this example is just showing the usage of "Apps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +114,25 @@ public async Task GetIfExists_AppsGet() // get the collection of this IotCentralAppResource IotCentralAppCollection collection = resourceGroupResource.GetIotCentralApps(); - // invoke the operation - string resourceName = "myIoTCentralApp"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - IotCentralAppResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (IotCentralAppResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IotCentralAppData resourceData = result.Data; + IotCentralAppData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AppsCreateOrUpdate() + public async Task Exists_AppsGet() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_CreateOrUpdate.json - // this example is just showing the usage of "Apps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Get.json + // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,29 +151,17 @@ public async Task CreateOrUpdate_AppsCreateOrUpdate() // invoke the operation string resourceName = "myIoTCentralApp"; - IotCentralAppData data = new IotCentralAppData(new AzureLocation("westus"), new IotCentralAppSkuInfo(IotCentralAppSku.ST2)) - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - DisplayName = "My IoT Central App", - Subdomain = "my-iot-central-app", - Template = "iotc-pnp-preview@1.0.0", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - IotCentralAppResource result = lro.Value; + bool result = await collection.ExistsAsync(resourceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotCentralAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AppsListByResourceGroup() + public async Task GetIfExists_AppsGet() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_ListByResourceGroup.json - // this example is just showing the usage of "Apps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Get.json + // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_AppsListByResourceGroup() // get the collection of this IotCentralAppResource IotCentralAppCollection collection = resourceGroupResource.GetIotCentralApps(); - // invoke the operation and iterate over the result - await foreach (IotCentralAppResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "myIoTCentralApp"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + IotCentralAppResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IotCentralAppData resourceData = item.Data; + IotCentralAppData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralAppResource.cs b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralAppResource.cs index aeaeeea29e3ce..fd37cec0a0bee 100644 --- a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralAppResource.cs +++ b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralAppResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.IotCentral.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.IotCentral.Samples @@ -50,10 +49,10 @@ public async Task Get_AppsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AppsUpdate() + public async Task Delete_AppsDelete() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Update.json - // this example is just showing the usage of "Apps_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Delete.json + // this example is just showing the usage of "Apps_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,22 +68,17 @@ public async Task Update_AppsUpdate() IotCentralAppResource iotCentralApp = client.GetIotCentralAppResource(iotCentralAppResourceId); // invoke the operation - IotCentralAppPatch patch = new IotCentralAppPatch() - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - DisplayName = "My IoT Central App 2", - }; - await iotCentralApp.UpdateAsync(WaitUntil.Completed, patch); + await iotCentralApp.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AppsDelete() + public async Task Update_AppsUpdate() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Delete.json - // this example is just showing the usage of "Apps_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Update.json + // this example is just showing the usage of "Apps_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,121 +94,12 @@ public async Task Delete_AppsDelete() IotCentralAppResource iotCentralApp = client.GetIotCentralAppResource(iotCentralAppResourceId); // invoke the operation - await iotCentralApp.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIotCentralApps_AppsListBySubscription() - { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_ListBySubscription.json - // this example is just showing the usage of "Apps_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (IotCentralAppResource item in subscriptionResource.GetIotCentralAppsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotCentralAppData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckIotCentralAppNameAvailability_AppsCheckNameAvailability() - { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_CheckNameAvailability.json - // this example is just showing the usage of "Apps_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - IotCentralAppNameAvailabilityContent content = new IotCentralAppNameAvailabilityContent("myiotcentralapp") + IotCentralAppPatch patch = new IotCentralAppPatch { - ResourceType = "IoTApps", - }; - IotCentralAppNameAvailabilityResponse result = await subscriptionResource.CheckIotCentralAppNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckIotCentralAppSubdomainAvailability_AppsSubdomainAvailability() - { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_CheckSubdomainAvailability.json - // this example is just showing the usage of "Apps_CheckSubdomainAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - IotCentralAppNameAvailabilityContent content = new IotCentralAppNameAvailabilityContent("myiotcentralapp") - { - ResourceType = "IoTApps", + Identity = new ManagedServiceIdentity("SystemAssigned"), + DisplayName = "My IoT Central App 2", }; - IotCentralAppNameAvailabilityResponse result = await subscriptionResource.CheckIotCentralAppSubdomainAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetTemplatesApps_AppsListTemplates() - { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Templates.json - // this example is just showing the usage of "Apps_ListTemplates" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (IotCentralAppTemplate item in subscriptionResource.GetTemplatesAppsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + await iotCentralApp.UpdateAsync(WaitUntil.Completed, patch); Console.WriteLine("Succeeded"); } diff --git a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateEndpointConnectionCollection.cs b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateEndpointConnectionCollection.cs index 9f3c4acbbe614..fc32e81f0a58a 100644 --- a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateEndpointConnectionCollection.cs +++ b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_IotCentralPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGet() + public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Update.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "myIoTCentralAppEndpoint"; - IotCentralPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + IotCentralPrivateEndpointConnectionData data = new IotCentralPrivateEndpointConnectionData + { + ConnectionState = new IotCentralPrivateLinkServiceConnectionState + { + Status = IotCentralPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-approved", + ActionsRequired = "None", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + IotCentralPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +62,7 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGet() + public async Task Get_PrivateEndpointConnectionsGet() { // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +85,21 @@ public async Task Exists_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "myIoTCentralAppEndpoint"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + IotCentralPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotCentralPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGet() + public async Task GetAll_PrivateEndpointConnectionsList() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_List.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +117,25 @@ public async Task GetIfExists_PrivateEndpointConnectionsGet() // get the collection of this IotCentralPrivateEndpointConnectionResource IotCentralPrivateEndpointConnectionCollection collection = iotCentralApp.GetIotCentralPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "myIoTCentralAppEndpoint"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - IotCentralPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (IotCentralPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IotCentralPrivateEndpointConnectionData resourceData = result.Data; + IotCentralPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() + public async Task Exists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Update.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,31 +155,17 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsUpdate() // invoke the operation string privateEndpointConnectionName = "myIoTCentralAppEndpoint"; - IotCentralPrivateEndpointConnectionData data = new IotCentralPrivateEndpointConnectionData() - { - ConnectionState = new IotCentralPrivateLinkServiceConnectionState() - { - Status = IotCentralPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-approved", - ActionsRequired = "None", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - IotCentralPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotCentralPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsList() + public async Task GetIfExists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_List.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_PrivateEndpointConnectionsList() // get the collection of this IotCentralPrivateEndpointConnectionResource IotCentralPrivateEndpointConnectionCollection collection = iotCentralApp.GetIotCentralPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (IotCentralPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "myIoTCentralAppEndpoint"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + IotCentralPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IotCentralPrivateEndpointConnectionData resourceData = item.Data; + IotCentralPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateEndpointConnectionResource.cs b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateEndpointConnectionResource.cs index b5fea9d08ad92..7933a3bbf18fc 100644 --- a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateEndpointConnectionResource.cs +++ b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsUpdate() + public async Task Delete_PrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Update.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,17 @@ public async Task Update_PrivateEndpointConnectionsUpdate() IotCentralPrivateEndpointConnectionResource iotCentralPrivateEndpointConnection = client.GetIotCentralPrivateEndpointConnectionResource(iotCentralPrivateEndpointConnectionResourceId); // invoke the operation - IotCentralPrivateEndpointConnectionData data = new IotCentralPrivateEndpointConnectionData() - { - ConnectionState = new IotCentralPrivateLinkServiceConnectionState() - { - Status = IotCentralPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-approved", - ActionsRequired = "None", - }, - }; - ArmOperation lro = await iotCentralPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - IotCentralPrivateEndpointConnectionResource result = lro.Value; + await iotCentralPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotCentralPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDelete() + public async Task Update_PrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateEndpointConnections_Update.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +96,23 @@ public async Task Delete_PrivateEndpointConnectionsDelete() IotCentralPrivateEndpointConnectionResource iotCentralPrivateEndpointConnection = client.GetIotCentralPrivateEndpointConnectionResource(iotCentralPrivateEndpointConnectionResourceId); // invoke the operation - await iotCentralPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + IotCentralPrivateEndpointConnectionData data = new IotCentralPrivateEndpointConnectionData + { + ConnectionState = new IotCentralPrivateLinkServiceConnectionState + { + Status = IotCentralPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-approved", + ActionsRequired = "None", + }, + }; + ArmOperation lro = await iotCentralPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + IotCentralPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotCentralPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateLinkResourceCollection.cs b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateLinkResourceCollection.cs index 19180483ceb10..a3fbbe43806cd 100644 --- a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateLinkResourceCollection.cs +++ b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_IotCentralPrivateLinkResourceCollection.cs @@ -51,10 +51,10 @@ public async Task Get_PrivateLinksGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateLinksGet() + public async Task GetAll_PrivateLinksList() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateLinks_Get.json - // this example is just showing the usage of "PrivateLinks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateLinks_List.json + // this example is just showing the usage of "PrivateLinks_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_PrivateLinksGet() // get the collection of this IotCentralPrivateLinkResource IotCentralPrivateLinkResourceCollection collection = iotCentralApp.GetIotCentralPrivateLinkResources(); - // invoke the operation - string groupId = "iotApp"; - bool result = await collection.ExistsAsync(groupId); + // invoke the operation and iterate over the result + await foreach (IotCentralPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotCentralPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateLinksGet() + public async Task Exists_PrivateLinksGet() { // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateLinks_Get.json // this example is just showing the usage of "PrivateLinks_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_PrivateLinksGet() // invoke the operation string groupId = "iotApp"; - NullableResponse response = await collection.GetIfExistsAsync(groupId); - IotCentralPrivateLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(groupId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotCentralPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinksList() + public async Task GetIfExists_PrivateLinksGet() { - // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateLinks_List.json - // this example is just showing the usage of "PrivateLinks_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/PrivateLinks_Get.json + // this example is just showing the usage of "PrivateLinks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_PrivateLinksList() // get the collection of this IotCentralPrivateLinkResource IotCentralPrivateLinkResourceCollection collection = iotCentralApp.GetIotCentralPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (IotCentralPrivateLinkResource item in collection.GetAllAsync()) + // invoke the operation + string groupId = "iotApp"; + NullableResponse response = await collection.GetIfExistsAsync(groupId); + IotCentralPrivateLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IotCentralPrivateLinkResourceData resourceData = item.Data; + IotCentralPrivateLinkResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..3cca5dedce323 --- /dev/null +++ b/sdk/iotcentral/Azure.ResourceManager.IotCentral/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,134 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.IotCentral.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.IotCentral.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIotCentralApps_AppsListBySubscription() + { + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_ListBySubscription.json + // this example is just showing the usage of "Apps_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (IotCentralAppResource item in subscriptionResource.GetIotCentralAppsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotCentralAppData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckIotCentralAppNameAvailability_AppsCheckNameAvailability() + { + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_CheckNameAvailability.json + // this example is just showing the usage of "Apps_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + IotCentralAppNameAvailabilityContent content = new IotCentralAppNameAvailabilityContent("myiotcentralapp") + { + ResourceType = "IoTApps", + }; + IotCentralAppNameAvailabilityResponse result = await subscriptionResource.CheckIotCentralAppNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckIotCentralAppSubdomainAvailability_AppsSubdomainAvailability() + { + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_CheckSubdomainAvailability.json + // this example is just showing the usage of "Apps_CheckSubdomainAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + IotCentralAppNameAvailabilityContent content = new IotCentralAppNameAvailabilityContent("myiotcentralapp") + { + ResourceType = "IoTApps", + }; + IotCentralAppNameAvailabilityResponse result = await subscriptionResource.CheckIotCentralAppSubdomainAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetTemplatesApps_AppsListTemplates() + { + // Generated from example definition: specification/iotcentral/resource-manager/Microsoft.IoTCentral/preview/2021-11-01-preview/examples/Apps_Templates.json + // this example is just showing the usage of "Apps_ListTemplates" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (IotCentralAppTemplate item in subscriptionResource.GetTemplatesAppsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_EventHubConsumerGroupInfoCollection.cs b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_EventHubConsumerGroupInfoCollection.cs index 0acd88bbd1844..e892ef9ff7394 100644 --- a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_EventHubConsumerGroupInfoCollection.cs +++ b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_EventHubConsumerGroupInfoCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EventHubConsumerGroupInfoCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_IotHubResourceListEventHubConsumerGroups() + public async Task CreateOrUpdate_IotHubResourceCreateEventHubConsumerGroup() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listehgroups.json - // this example is just showing the usage of "IotHubResource_ListEventHubConsumerGroups" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_createconsumergroup.json + // this example is just showing the usage of "IotHubResource_CreateEventHubConsumerGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,17 @@ public async Task GetAll_IotHubResourceListEventHubConsumerGroups() string eventHubEndpointName = "events"; EventHubConsumerGroupInfoCollection collection = iotHubDescription.GetEventHubConsumerGroupInfos(eventHubEndpointName); - // invoke the operation and iterate over the result - await foreach (EventHubConsumerGroupInfoResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubConsumerGroupInfoData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "test"; + EventHubConsumerGroupInfoCreateOrUpdateContent content = new EventHubConsumerGroupInfoCreateOrUpdateContent("test"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, content); + EventHubConsumerGroupInfoResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubConsumerGroupInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +90,10 @@ public async Task Get_IotHubResourceListEventHubConsumerGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_IotHubResourceListEventHubConsumerGroups() + public async Task GetAll_IotHubResourceListEventHubConsumerGroups() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getconsumergroup.json - // this example is just showing the usage of "IotHubResource_GetEventHubConsumerGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listehgroups.json + // this example is just showing the usage of "IotHubResource_ListEventHubConsumerGroups" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_IotHubResourceListEventHubConsumerGroups() string eventHubEndpointName = "events"; EventHubConsumerGroupInfoCollection collection = iotHubDescription.GetEventHubConsumerGroupInfos(eventHubEndpointName); - // invoke the operation - string name = "test"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (EventHubConsumerGroupInfoResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubConsumerGroupInfoData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_IotHubResourceListEventHubConsumerGroups() + public async Task Exists_IotHubResourceListEventHubConsumerGroups() { // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getconsumergroup.json // this example is just showing the usage of "IotHubResource_GetEventHubConsumerGroup" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +151,17 @@ public async Task GetIfExists_IotHubResourceListEventHubConsumerGroups() // invoke the operation string name = "test"; - NullableResponse response = await collection.GetIfExistsAsync(name); - EventHubConsumerGroupInfoResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubConsumerGroupInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_IotHubResourceCreateEventHubConsumerGroup() + public async Task GetIfExists_IotHubResourceListEventHubConsumerGroups() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_createconsumergroup.json - // this example is just showing the usage of "IotHubResource_CreateEventHubConsumerGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getconsumergroup.json + // this example is just showing the usage of "IotHubResource_GetEventHubConsumerGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,15 +182,21 @@ public async Task CreateOrUpdate_IotHubResourceCreateEventHubConsumerGroup() // invoke the operation string name = "test"; - EventHubConsumerGroupInfoCreateOrUpdateContent content = new EventHubConsumerGroupInfoCreateOrUpdateContent("test"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, content); - EventHubConsumerGroupInfoResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + EventHubConsumerGroupInfoResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubConsumerGroupInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubConsumerGroupInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_EventHubConsumerGroupInfoResource.cs b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_EventHubConsumerGroupInfoResource.cs index 811d22dbaae55..773ddc9c80951 100644 --- a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_EventHubConsumerGroupInfoResource.cs +++ b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_EventHubConsumerGroupInfoResource.cs @@ -50,10 +50,10 @@ public async Task Get_IotHubResourceListEventHubConsumerGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_IotHubResourceCreateEventHubConsumerGroup() + public async Task Delete_IotHubResourceDeleteEventHubConsumerGroup() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_createconsumergroup.json - // this example is just showing the usage of "IotHubResource_CreateEventHubConsumerGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_deleteconsumergroup.json + // this example is just showing the usage of "IotHubResource_DeleteEventHubConsumerGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,23 +71,17 @@ public async Task Update_IotHubResourceCreateEventHubConsumerGroup() EventHubConsumerGroupInfoResource eventHubConsumerGroupInfo = client.GetEventHubConsumerGroupInfoResource(eventHubConsumerGroupInfoResourceId); // invoke the operation - EventHubConsumerGroupInfoCreateOrUpdateContent content = new EventHubConsumerGroupInfoCreateOrUpdateContent("test"); - ArmOperation lro = await eventHubConsumerGroupInfo.UpdateAsync(WaitUntil.Completed, content); - EventHubConsumerGroupInfoResource result = lro.Value; + await eventHubConsumerGroupInfo.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EventHubConsumerGroupInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_IotHubResourceDeleteEventHubConsumerGroup() + public async Task Update_IotHubResourceCreateEventHubConsumerGroup() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_deleteconsumergroup.json - // this example is just showing the usage of "IotHubResource_DeleteEventHubConsumerGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_createconsumergroup.json + // this example is just showing the usage of "IotHubResource_CreateEventHubConsumerGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +99,15 @@ public async Task Delete_IotHubResourceDeleteEventHubConsumerGroup() EventHubConsumerGroupInfoResource eventHubConsumerGroupInfo = client.GetEventHubConsumerGroupInfoResource(eventHubConsumerGroupInfoResourceId); // invoke the operation - await eventHubConsumerGroupInfo.DeleteAsync(WaitUntil.Completed); + EventHubConsumerGroupInfoCreateOrUpdateContent content = new EventHubConsumerGroupInfoCreateOrUpdateContent("test"); + ArmOperation lro = await eventHubConsumerGroupInfo.UpdateAsync(WaitUntil.Completed, content); + EventHubConsumerGroupInfoResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EventHubConsumerGroupInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubCertificateDescriptionCollection.cs b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubCertificateDescriptionCollection.cs index 9f99552ba14cc..58e318cfc8ac8 100644 --- a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubCertificateDescriptionCollection.cs +++ b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubCertificateDescriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_IotHubCertificateDescriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CertificatesListByIotHub() + public async Task CreateOrUpdate_CertificatesCreateOrUpdate() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listcertificates.json - // this example is just showing the usage of "Certificates_ListByIotHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certificatescreateorupdate.json + // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,30 @@ public async Task GetAll_CertificatesListByIotHub() // for more information of creating IotHubDescriptionResource, please refer to the document of IotHubDescriptionResource string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; string resourceGroupName = "myResourceGroup"; - string resourceName = "testhub"; + string resourceName = "iothub"; ResourceIdentifier iotHubDescriptionResourceId = IotHubDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); IotHubDescriptionResource iotHubDescription = client.GetIotHubDescriptionResource(iotHubDescriptionResourceId); // get the collection of this IotHubCertificateDescriptionResource IotHubCertificateDescriptionCollection collection = iotHubDescription.GetIotHubCertificateDescriptions(); - // invoke the operation and iterate over the result - await foreach (IotHubCertificateDescriptionResource item in collection.GetAllAsync()) + // invoke the operation + string certificateName = "cert"; + IotHubCertificateDescriptionData data = new IotHubCertificateDescriptionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubCertificateDescriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new IotHubCertificateProperties + { + Certificate = BinaryData.FromObjectAsJson("############################################"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); + IotHubCertificateDescriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubCertificateDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +94,10 @@ public async Task Get_CertificatesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CertificatesGet() + public async Task GetAll_CertificatesListByIotHub() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getcertificate.json - // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listcertificates.json + // this example is just showing the usage of "Certificates_ListByIotHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +115,22 @@ public async Task Exists_CertificatesGet() // get the collection of this IotHubCertificateDescriptionResource IotHubCertificateDescriptionCollection collection = iotHubDescription.GetIotHubCertificateDescriptions(); - // invoke the operation - string certificateName = "cert"; - bool result = await collection.ExistsAsync(certificateName); + // invoke the operation and iterate over the result + await foreach (IotHubCertificateDescriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubCertificateDescriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CertificatesGet() + public async Task Exists_CertificatesGet() { // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getcertificate.json // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +153,17 @@ public async Task GetIfExists_CertificatesGet() // invoke the operation string certificateName = "cert"; - NullableResponse response = await collection.GetIfExistsAsync(certificateName); - IotHubCertificateDescriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(certificateName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubCertificateDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CertificatesCreateOrUpdate() + public async Task GetIfExists_CertificatesGet() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certificatescreateorupdate.json - // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getcertificate.json + // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,7 +174,7 @@ public async Task CreateOrUpdate_CertificatesCreateOrUpdate() // for more information of creating IotHubDescriptionResource, please refer to the document of IotHubDescriptionResource string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; string resourceGroupName = "myResourceGroup"; - string resourceName = "iothub"; + string resourceName = "testhub"; ResourceIdentifier iotHubDescriptionResourceId = IotHubDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); IotHubDescriptionResource iotHubDescription = client.GetIotHubDescriptionResource(iotHubDescriptionResourceId); @@ -183,21 +183,21 @@ public async Task CreateOrUpdate_CertificatesCreateOrUpdate() // invoke the operation string certificateName = "cert"; - IotHubCertificateDescriptionData data = new IotHubCertificateDescriptionData() - { - Properties = new IotHubCertificateProperties() - { - Certificate = BinaryData.FromString("\"############################################\""), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); - IotHubCertificateDescriptionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(certificateName); + IotHubCertificateDescriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubCertificateDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubCertificateDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubCertificateDescriptionResource.cs b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubCertificateDescriptionResource.cs index be06debb0fbf5..71773a267d0eb 100644 --- a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubCertificateDescriptionResource.cs +++ b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubCertificateDescriptionResource.cs @@ -49,10 +49,10 @@ public async Task Get_CertificatesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CertificatesCreateOrUpdate() + public async Task Delete_CertificatesDelete() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certificatescreateorupdate.json - // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certificatesdelete.json + // this example is just showing the usage of "Certificates_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,35 +63,24 @@ public async Task Update_CertificatesCreateOrUpdate() // for more information of creating IotHubCertificateDescriptionResource, please refer to the document of IotHubCertificateDescriptionResource string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; string resourceGroupName = "myResourceGroup"; - string resourceName = "iothub"; + string resourceName = "myhub"; string certificateName = "cert"; ResourceIdentifier iotHubCertificateDescriptionResourceId = IotHubCertificateDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, certificateName); IotHubCertificateDescriptionResource iotHubCertificateDescription = client.GetIotHubCertificateDescriptionResource(iotHubCertificateDescriptionResourceId); // invoke the operation - IotHubCertificateDescriptionData data = new IotHubCertificateDescriptionData() - { - Properties = new IotHubCertificateProperties() - { - Certificate = BinaryData.FromString("\"############################################\""), - }, - }; - ArmOperation lro = await iotHubCertificateDescription.UpdateAsync(WaitUntil.Completed, data); - IotHubCertificateDescriptionResource result = lro.Value; + string ifMatch = "AAAAAAAADGk="; + await iotHubCertificateDescription.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubCertificateDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CertificatesDelete() + public async Task Update_CertificatesCreateOrUpdate() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certificatesdelete.json - // this example is just showing the usage of "Certificates_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_certificatescreateorupdate.json + // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,16 +91,27 @@ public async Task Delete_CertificatesDelete() // for more information of creating IotHubCertificateDescriptionResource, please refer to the document of IotHubCertificateDescriptionResource string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; string resourceGroupName = "myResourceGroup"; - string resourceName = "myhub"; + string resourceName = "iothub"; string certificateName = "cert"; ResourceIdentifier iotHubCertificateDescriptionResourceId = IotHubCertificateDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, certificateName); IotHubCertificateDescriptionResource iotHubCertificateDescription = client.GetIotHubCertificateDescriptionResource(iotHubCertificateDescriptionResourceId); // invoke the operation - string ifMatch = "AAAAAAAADGk="; - await iotHubCertificateDescription.DeleteAsync(WaitUntil.Completed, ifMatch); + IotHubCertificateDescriptionData data = new IotHubCertificateDescriptionData + { + Properties = new IotHubCertificateProperties + { + Certificate = BinaryData.FromObjectAsJson("############################################"), + }, + }; + ArmOperation lro = await iotHubCertificateDescription.UpdateAsync(WaitUntil.Completed, data); + IotHubCertificateDescriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubCertificateDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -165,9 +165,9 @@ public async Task Verify_CertificatesVerify() // invoke the operation string ifMatch = "AAAAAAAADGk="; - IotHubCertificateVerificationContent content = new IotHubCertificateVerificationContent() + IotHubCertificateVerificationContent content = new IotHubCertificateVerificationContent { - Certificate = BinaryData.FromString("\"#####################################\""), + Certificate = BinaryData.FromObjectAsJson("#####################################"), }; IotHubCertificateDescriptionResource result = await iotHubCertificateDescription.VerifyAsync(ifMatch, content); diff --git a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubDescriptionCollection.cs b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubDescriptionCollection.cs index d0b8d85297b79..cb148495f72e5 100644 --- a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubDescriptionCollection.cs +++ b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubDescriptionCollection.cs @@ -18,109 +18,6 @@ namespace Azure.ResourceManager.IotHub.Samples { public partial class Sample_IotHubDescriptionCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_IotHubResourceGet() - { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_get.json - // this example is just showing the usage of "IotHubResource_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this IotHubDescriptionResource - IotHubDescriptionCollection collection = resourceGroupResource.GetIotHubDescriptions(); - - // invoke the operation - string resourceName = "testHub"; - IotHubDescriptionResource result = await collection.GetAsync(resourceName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_IotHubResourceGet() - { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_get.json - // this example is just showing the usage of "IotHubResource_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this IotHubDescriptionResource - IotHubDescriptionCollection collection = resourceGroupResource.GetIotHubDescriptions(); - - // invoke the operation - string resourceName = "testHub"; - bool result = await collection.ExistsAsync(resourceName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_IotHubResourceGet() - { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_get.json - // this example is just showing the usage of "IotHubResource_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this IotHubDescriptionResource - IotHubDescriptionCollection collection = resourceGroupResource.GetIotHubDescriptions(); - - // invoke the operation - string resourceName = "testHub"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - IotHubDescriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_IotHubResourceAddCosmosDbEndpoint() @@ -151,17 +48,16 @@ public async Task CreateOrUpdate_IotHubResourceAddCosmosDbEndpoint() }) { ETag = new ETag("AAAAAAFD6M4="), - Properties = new IotHubProperties() + Properties = new IotHubProperties { - IPFilterRules = -{ -}, + IPFilterRules = { }, NetworkRuleSets = new IotHubNetworkRuleSetProperties(true, new IotHubNetworkRuleSetIPRule[] { -new IotHubNetworkRuleSetIPRule("rule1","131.117.159.53") +new IotHubNetworkRuleSetIPRule("rule1", "131.117.159.53") { Action = IotHubNetworkRuleIPAction.Allow, -},new IotHubNetworkRuleSetIPRule("rule2","157.55.59.128/25") +}, +new IotHubNetworkRuleSetIPRule("rule2", "157.55.59.128/25") { Action = IotHubNetworkRuleIPAction.Allow, } @@ -172,31 +68,21 @@ public async Task CreateOrUpdate_IotHubResourceAddCosmosDbEndpoint() MinTlsVersion = "1.2", EventHubEndpoints = { -["events"] = new EventHubCompatibleEndpointProperties() +["events"] = new EventHubCompatibleEndpointProperties { RetentionTimeInDays = 1L, PartitionCount = 2, +} }, -}, - Routing = new IotHubRoutingProperties() + Routing = new IotHubRoutingProperties { - Endpoints = new RoutingEndpoints() + Endpoints = new RoutingEndpoints { - ServiceBusQueues = -{ -}, - ServiceBusTopics = -{ -}, - EventHubs = -{ -}, - StorageContainers = -{ -}, - CosmosDBSqlContainers = -{ -new RoutingCosmosDBSqlApiProperties("endpointcosmos",new Uri("https://test-systemstore-test2.documents.azure.com"),"systemstore","test") + ServiceBusQueues = { }, + ServiceBusTopics = { }, + EventHubs = { }, + StorageContainers = { }, + CosmosDBSqlContainers = {new RoutingCosmosDBSqlApiProperties("endpointcosmos", new Uri("https://test-systemstore-test2.documents.azure.com"), "systemstore", "test") { SubscriptionId = "", ResourceGroup = "rg-test", @@ -205,16 +91,10 @@ public async Task CreateOrUpdate_IotHubResourceAddCosmosDbEndpoint() SecondaryKey = "", PartitionKeyName = "keystamped", PartitionKeyTemplate = "{deviceid}-{YYYY}-{MM}", -} -}, +}}, }, - Routes = -{ -}, - FallbackRoute = new IotHubFallbackRouteProperties(IotHubRoutingSource.DeviceMessages, new string[] - { -"events" - }, true) + Routes = { }, + FallbackRoute = new IotHubFallbackRouteProperties(IotHubRoutingSource.DeviceMessages, new string[] { "events" }, true) { Name = "$fallback", Condition = "true", @@ -222,26 +102,26 @@ public async Task CreateOrUpdate_IotHubResourceAddCosmosDbEndpoint() }, StorageEndpoints = { -["$default"] = new IotHubStorageEndpointProperties("","") +["$default"] = new IotHubStorageEndpointProperties("", "") { SasTtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"), -}, +} }, MessagingEndpoints = { -["fileNotifications"] = new MessagingEndpointProperties() +["fileNotifications"] = new MessagingEndpointProperties { LockDurationAsIso8601 = XmlConvert.ToTimeSpan("PT1M"), TtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"), MaxDeliveryCount = 10, -}, +} }, EnableFileUploadNotifications = false, - CloudToDevice = new CloudToDeviceProperties() + CloudToDevice = new CloudToDeviceProperties { MaxDeliveryCount = 10, DefaultTtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"), - Feedback = new CloudToDeviceFeedbackQueueProperties() + Feedback = new CloudToDeviceFeedbackQueueProperties { LockDurationAsIso8601 = XmlConvert.ToTimeSpan("PT1M"), TtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"), @@ -251,9 +131,7 @@ public async Task CreateOrUpdate_IotHubResourceAddCosmosDbEndpoint() Features = IotHubCapability.None, EnableDataResidency = false, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); IotHubDescriptionResource result = lro.Value; @@ -295,17 +173,16 @@ public async Task CreateOrUpdate_IotHubResourceCreateOrUpdate() }) { ETag = new ETag("AAAAAAFD6M4="), - Properties = new IotHubProperties() + Properties = new IotHubProperties { - IPFilterRules = -{ -}, + IPFilterRules = { }, NetworkRuleSets = new IotHubNetworkRuleSetProperties(true, new IotHubNetworkRuleSetIPRule[] { -new IotHubNetworkRuleSetIPRule("rule1","131.117.159.53") +new IotHubNetworkRuleSetIPRule("rule1", "131.117.159.53") { Action = IotHubNetworkRuleIPAction.Allow, -},new IotHubNetworkRuleSetIPRule("rule2","157.55.59.128/25") +}, +new IotHubNetworkRuleSetIPRule("rule2", "157.55.59.128/25") { Action = IotHubNetworkRuleIPAction.Allow, } @@ -316,36 +193,23 @@ public async Task CreateOrUpdate_IotHubResourceCreateOrUpdate() MinTlsVersion = "1.2", EventHubEndpoints = { -["events"] = new EventHubCompatibleEndpointProperties() +["events"] = new EventHubCompatibleEndpointProperties { RetentionTimeInDays = 1L, PartitionCount = 2, +} }, -}, - Routing = new IotHubRoutingProperties() + Routing = new IotHubRoutingProperties { - Endpoints = new RoutingEndpoints() + Endpoints = new RoutingEndpoints { - ServiceBusQueues = -{ -}, - ServiceBusTopics = -{ -}, - EventHubs = -{ -}, - StorageContainers = -{ -}, + ServiceBusQueues = { }, + ServiceBusTopics = { }, + EventHubs = { }, + StorageContainers = { }, }, - Routes = -{ -}, - FallbackRoute = new IotHubFallbackRouteProperties(IotHubRoutingSource.DeviceMessages, new string[] - { -"events" - }, true) + Routes = { }, + FallbackRoute = new IotHubFallbackRouteProperties(IotHubRoutingSource.DeviceMessages, new string[] { "events" }, true) { Name = "$fallback", Condition = "true", @@ -353,26 +217,26 @@ public async Task CreateOrUpdate_IotHubResourceCreateOrUpdate() }, StorageEndpoints = { -["$default"] = new IotHubStorageEndpointProperties("","") +["$default"] = new IotHubStorageEndpointProperties("", "") { SasTtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"), -}, +} }, MessagingEndpoints = { -["fileNotifications"] = new MessagingEndpointProperties() +["fileNotifications"] = new MessagingEndpointProperties { LockDurationAsIso8601 = XmlConvert.ToTimeSpan("PT1M"), TtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"), MaxDeliveryCount = 10, -}, +} }, EnableFileUploadNotifications = false, - CloudToDevice = new CloudToDeviceProperties() + CloudToDevice = new CloudToDeviceProperties { MaxDeliveryCount = 10, DefaultTtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"), - Feedback = new CloudToDeviceFeedbackQueueProperties() + Feedback = new CloudToDeviceFeedbackQueueProperties { LockDurationAsIso8601 = XmlConvert.ToTimeSpan("PT1M"), TtlAsIso8601 = XmlConvert.ToTimeSpan("PT1H"), @@ -382,9 +246,7 @@ public async Task CreateOrUpdate_IotHubResourceCreateOrUpdate() Features = IotHubCapability.None, EnableDataResidency = false, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); IotHubDescriptionResource result = lro.Value; @@ -396,6 +258,39 @@ public async Task CreateOrUpdate_IotHubResourceCreateOrUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_IotHubResourceGet() + { + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_get.json + // this example is just showing the usage of "IotHubResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this IotHubDescriptionResource + IotHubDescriptionCollection collection = resourceGroupResource.GetIotHubDescriptions(); + + // invoke the operation + string resourceName = "testHub"; + IotHubDescriptionResource result = await collection.GetAsync(resourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_IotHubResourceListByResourceGroup() @@ -430,5 +325,75 @@ public async Task GetAll_IotHubResourceListByResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_IotHubResourceGet() + { + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_get.json + // this example is just showing the usage of "IotHubResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this IotHubDescriptionResource + IotHubDescriptionCollection collection = resourceGroupResource.GetIotHubDescriptions(); + + // invoke the operation + string resourceName = "testHub"; + bool result = await collection.ExistsAsync(resourceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_IotHubResourceGet() + { + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_get.json + // this example is just showing the usage of "IotHubResource_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this IotHubDescriptionResource + IotHubDescriptionCollection collection = resourceGroupResource.GetIotHubDescriptions(); + + // invoke the operation + string resourceName = "testHub"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + IotHubDescriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubDescriptionResource.cs b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubDescriptionResource.cs index 73380798b7d62..d39e1e479eaa6 100644 --- a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubDescriptionResource.cs +++ b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubDescriptionResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.IotHub.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.IotHub.Samples @@ -49,10 +48,10 @@ public async Task Get_IotHubResourceGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_IotHubResourceUpdate() + public async Task Delete_IotHubResourceDelete() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_patch.json - // this example is just showing the usage of "IotHubResource_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_delete.json + // this example is just showing the usage of "IotHubResource_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,19 +62,12 @@ public async Task Update_IotHubResourceUpdate() // for more information of creating IotHubDescriptionResource, please refer to the document of IotHubDescriptionResource string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; string resourceGroupName = "myResourceGroup"; - string resourceName = "myHub"; + string resourceName = "testHub"; ResourceIdentifier iotHubDescriptionResourceId = IotHubDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); IotHubDescriptionResource iotHubDescription = client.GetIotHubDescriptionResource(iotHubDescriptionResourceId); // invoke the operation - IotHubDescriptionPatch patch = new IotHubDescriptionPatch() - { - Tags = -{ -["foo"] = "bar", -}, - }; - ArmOperation lro = await iotHubDescription.UpdateAsync(WaitUntil.Completed, patch); + ArmOperation lro = await iotHubDescription.DeleteAsync(WaitUntil.Completed); IotHubDescriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -87,10 +79,10 @@ public async Task Update_IotHubResourceUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_IotHubResourceDelete() + public async Task Update_IotHubResourceUpdate() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_delete.json - // this example is just showing the usage of "IotHubResource_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_patch.json + // this example is just showing the usage of "IotHubResource_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,12 +93,19 @@ public async Task Delete_IotHubResourceDelete() // for more information of creating IotHubDescriptionResource, please refer to the document of IotHubDescriptionResource string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; string resourceGroupName = "myResourceGroup"; - string resourceName = "testHub"; + string resourceName = "myHub"; ResourceIdentifier iotHubDescriptionResourceId = IotHubDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); IotHubDescriptionResource iotHubDescription = client.GetIotHubDescriptionResource(iotHubDescriptionResourceId); // invoke the operation - ArmOperation lro = await iotHubDescription.DeleteAsync(WaitUntil.Completed); + IotHubDescriptionPatch patch = new IotHubDescriptionPatch + { + Tags = +{ +["foo"] = "bar" +}, + }; + ArmOperation lro = await iotHubDescription.UpdateAsync(WaitUntil.Completed, patch); IotHubDescriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -116,37 +115,6 @@ public async Task Delete_IotHubResourceDelete() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIotHubDescriptions_IotHubResourceListBySubscription() - { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listbysubscription.json - // this example is just showing the usage of "IotHubResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (IotHubDescriptionResource item in subscriptionResource.GetIotHubDescriptionsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubDescriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetStats_IotHubResourceGetStats() @@ -316,31 +284,6 @@ public async Task GetEndpointHealth_IotHubResourceGetEndpointHealth() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckIotHubNameAvailability_IotHubResourceCheckNameAvailability() - { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/checkNameAvailability.json - // this example is just showing the usage of "IotHubResource_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - IotHubNameAvailabilityContent content = new IotHubNameAvailabilityContent("test-request"); - IotHubNameAvailabilityResponse result = await subscriptionResource.CheckIotHubNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task TestAllRoutes_IotHubResourceTestAllRoutes() @@ -362,19 +305,19 @@ public async Task TestAllRoutes_IotHubResourceTestAllRoutes() IotHubDescriptionResource iotHubDescription = client.GetIotHubDescriptionResource(iotHubDescriptionResourceId); // invoke the operation - IotHubTestAllRoutesContent content = new IotHubTestAllRoutesContent() + IotHubTestAllRoutesContent content = new IotHubTestAllRoutesContent { RoutingSource = IotHubRoutingSource.DeviceMessages, - Message = new RoutingMessage() + Message = new RoutingMessage { Body = "Body of message", AppProperties = { -["key1"] = "value1", +["key1"] = "value1" }, SystemProperties = { -["key1"] = "value1", +["key1"] = "value1" }, }, }; @@ -404,21 +347,18 @@ public async Task TestRoute_IotHubResourceTestRoute() IotHubDescriptionResource iotHubDescription = client.GetIotHubDescriptionResource(iotHubDescriptionResourceId); // invoke the operation - IotHubTestRouteContent content = new IotHubTestRouteContent(new RoutingRuleProperties("Routeid", IotHubRoutingSource.DeviceMessages, new string[] - { -"id1" - }, true)) + IotHubTestRouteContent content = new IotHubTestRouteContent(new RoutingRuleProperties("Routeid", IotHubRoutingSource.DeviceMessages, new string[] { "id1" }, true)) { - Message = new RoutingMessage() + Message = new RoutingMessage { Body = "Body of message", AppProperties = { -["key1"] = "value1", +["key1"] = "value1" }, SystemProperties = { -["key1"] = "value1", +["key1"] = "value1" }, }, }; diff --git a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointConnectionCollection.cs b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointConnectionCollection.cs index ffd2d511d1271..65626480d5704 100644 --- a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointConnectionCollection.cs +++ b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_IotHubPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsList() + public async Task CreateOrUpdate_PrivateEndpointConnectionUpdate() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listprivateendpointconnections.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_updateprivateendpointconnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,17 @@ public async Task GetAll_PrivateEndpointConnectionsList() // get the collection of this IotHubPrivateEndpointConnectionResource IotHubPrivateEndpointConnectionCollection collection = iotHubDescription.GetIotHubPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (IotHubPrivateEndpointConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateEndpointConnectionName = "myPrivateEndpointConnection"; + IotHubPrivateEndpointConnectionData data = new IotHubPrivateEndpointConnectionData(new IotHubPrivateEndpointConnectionProperties(new IotHubPrivateLinkServiceConnectionState(IotHubPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"))); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + IotHubPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +88,10 @@ public async Task Get_PrivateEndpointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionGet() + public async Task GetAll_PrivateEndpointConnectionsList() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getprivateendpointconnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listprivateendpointconnections.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_PrivateEndpointConnectionGet() // get the collection of this IotHubPrivateEndpointConnectionResource IotHubPrivateEndpointConnectionCollection collection = iotHubDescription.GetIotHubPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "myPrivateEndpointConnection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (IotHubPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionGet() + public async Task Exists_PrivateEndpointConnectionGet() { // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getprivateendpointconnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_PrivateEndpointConnectionGet() // invoke the operation string privateEndpointConnectionName = "myPrivateEndpointConnection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - IotHubPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionUpdate() + public async Task GetIfExists_PrivateEndpointConnectionGet() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_updateprivateendpointconnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getprivateendpointconnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,15 +177,21 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionUpdate() // invoke the operation string privateEndpointConnectionName = "myPrivateEndpointConnection"; - IotHubPrivateEndpointConnectionData data = new IotHubPrivateEndpointConnectionData(new IotHubPrivateEndpointConnectionProperties(new IotHubPrivateLinkServiceConnectionState(IotHubPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"))); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - IotHubPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + IotHubPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointConnectionResource.cs b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointConnectionResource.cs index 9d147b9f9b987..87aef24672290 100644 --- a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointConnectionResource.cs +++ b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionUpdate() + public async Task Delete_PrivateEndpointConnectionDelete() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_updateprivateendpointconnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_deleteprivateendpointconnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,8 +69,7 @@ public async Task Update_PrivateEndpointConnectionUpdate() IotHubPrivateEndpointConnectionResource iotHubPrivateEndpointConnection = client.GetIotHubPrivateEndpointConnectionResource(iotHubPrivateEndpointConnectionResourceId); // invoke the operation - IotHubPrivateEndpointConnectionData data = new IotHubPrivateEndpointConnectionData(new IotHubPrivateEndpointConnectionProperties(new IotHubPrivateLinkServiceConnectionState(IotHubPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"))); - ArmOperation lro = await iotHubPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await iotHubPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); IotHubPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -82,10 +81,10 @@ public async Task Update_PrivateEndpointConnectionUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionDelete() + public async Task Update_PrivateEndpointConnectionUpdate() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_deleteprivateendpointconnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_updateprivateendpointconnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,7 +101,8 @@ public async Task Delete_PrivateEndpointConnectionDelete() IotHubPrivateEndpointConnectionResource iotHubPrivateEndpointConnection = client.GetIotHubPrivateEndpointConnectionResource(iotHubPrivateEndpointConnectionResourceId); // invoke the operation - ArmOperation lro = await iotHubPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + IotHubPrivateEndpointConnectionData data = new IotHubPrivateEndpointConnectionData(new IotHubPrivateEndpointConnectionProperties(new IotHubPrivateLinkServiceConnectionState(IotHubPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"))); + ArmOperation lro = await iotHubPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); IotHubPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointGroupInformationCollection.cs b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointGroupInformationCollection.cs index 5e09046340e41..c041445abcec3 100644 --- a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointGroupInformationCollection.cs +++ b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_IotHubPrivateEndpointGroupInformationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_IotHubPrivateEndpointGroupInformationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesList() + public async Task Get_PrivateLinkResourcesList() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listprivatelinkresources.json - // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getprivatelinkresources.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_PrivateLinkResourcesList() // get the collection of this IotHubPrivateEndpointGroupInformationResource IotHubPrivateEndpointGroupInformationCollection collection = iotHubDescription.GetAllIotHubPrivateEndpointGroupInformation(); - // invoke the operation and iterate over the result - await foreach (IotHubPrivateEndpointGroupInformationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubPrivateEndpointGroupInformationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupId = "iotHub"; + IotHubPrivateEndpointGroupInformationResource result = await collection.GetAsync(groupId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubPrivateEndpointGroupInformationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkResourcesList() + public async Task GetAll_PrivateLinkResourcesList() { - // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_getprivatelinkresources.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listprivatelinkresources.json + // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_PrivateLinkResourcesList() // get the collection of this IotHubPrivateEndpointGroupInformationResource IotHubPrivateEndpointGroupInformationCollection collection = iotHubDescription.GetAllIotHubPrivateEndpointGroupInformation(); - // invoke the operation - string groupId = "iotHub"; - IotHubPrivateEndpointGroupInformationResource result = await collection.GetAsync(groupId); + // invoke the operation and iterate over the result + await foreach (IotHubPrivateEndpointGroupInformationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubPrivateEndpointGroupInformationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotHubPrivateEndpointGroupInformationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 9ed11b52b8671..882ddd7e02654 100644 --- a/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/iothub/Azure.ResourceManager.IotHub/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,62 @@ namespace Azure.ResourceManager.IotHub.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIotHubDescriptions_IotHubResourceListBySubscription() + { + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/iothub_listbysubscription.json + // this example is just showing the usage of "IotHubResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (IotHubDescriptionResource item in subscriptionResource.GetIotHubDescriptionsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotHubDescriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckIotHubNameAvailability_IotHubResourceCheckNameAvailability() + { + // Generated from example definition: specification/iothub/resource-manager/Microsoft.Devices/stable/2023-06-30/examples/checkNameAvailability.json + // this example is just showing the usage of "IotHubResource_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "91d12660-3dec-467a-be2a-213b5544ddc0"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + IotHubNameAvailabilityContent content = new IotHubNameAvailabilityContent("test-request"); + IotHubNameAvailabilityResponse result = await subscriptionResource.CheckIotHubNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetIotHubUserSubscriptionQuota_ResourceProviderCommonGetSubscriptionQuota() diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultCollection.cs index cedcaf994d4a4..393176e269734 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultCollection.cs @@ -43,24 +43,12 @@ public async Task CreateOrUpdate_CreateANewVaultOrUpdateAnExistingVault() string vaultName = "sample-vault"; KeyVaultCreateOrUpdateContent content = new KeyVaultCreateOrUpdateContent(new AzureLocation("westus"), new KeyVaultProperties(Guid.Parse("00000000-0000-0000-0000-000000000000"), new KeyVaultSku(KeyVaultSkuFamily.A, KeyVaultSkuName.Standard)) { - AccessPolicies = + AccessPolicies = {new KeyVaultAccessPolicy(Guid.Parse("00000000-0000-0000-0000-000000000000"), "00000000-0000-0000-0000-000000000000", new IdentityAccessPermissions { -new KeyVaultAccessPolicy(Guid.Parse("00000000-0000-0000-0000-000000000000"),"00000000-0000-0000-0000-000000000000",new IdentityAccessPermissions() -{ -Keys = -{ -IdentityAccessKeyPermission.Encrypt,IdentityAccessKeyPermission.Decrypt,IdentityAccessKeyPermission.WrapKey,IdentityAccessKeyPermission.UnwrapKey,IdentityAccessKeyPermission.Sign,IdentityAccessKeyPermission.Verify,IdentityAccessKeyPermission.Get,IdentityAccessKeyPermission.List,IdentityAccessKeyPermission.Create,IdentityAccessKeyPermission.Update,IdentityAccessKeyPermission.Import,IdentityAccessKeyPermission.Delete,IdentityAccessKeyPermission.Backup,IdentityAccessKeyPermission.Restore,IdentityAccessKeyPermission.Recover,IdentityAccessKeyPermission.Purge -}, -Secrets = -{ -IdentityAccessSecretPermission.Get,IdentityAccessSecretPermission.List,IdentityAccessSecretPermission.Set,IdentityAccessSecretPermission.Delete,IdentityAccessSecretPermission.Backup,IdentityAccessSecretPermission.Restore,IdentityAccessSecretPermission.Recover,IdentityAccessSecretPermission.Purge -}, -Certificates = -{ -IdentityAccessCertificatePermission.Get,IdentityAccessCertificatePermission.List,IdentityAccessCertificatePermission.Delete,IdentityAccessCertificatePermission.Create,IdentityAccessCertificatePermission.Import,IdentityAccessCertificatePermission.Update,IdentityAccessCertificatePermission.ManageContacts,IdentityAccessCertificatePermission.GetIssuers,IdentityAccessCertificatePermission.ListIssuers,IdentityAccessCertificatePermission.SetIssuers,IdentityAccessCertificatePermission.DeleteIssuers,IdentityAccessCertificatePermission.ManageIssuers,IdentityAccessCertificatePermission.Recover,IdentityAccessCertificatePermission.Purge -}, -}) -}, +Keys = {IdentityAccessKeyPermission.Encrypt, IdentityAccessKeyPermission.Decrypt, IdentityAccessKeyPermission.WrapKey, IdentityAccessKeyPermission.UnwrapKey, IdentityAccessKeyPermission.Sign, IdentityAccessKeyPermission.Verify, IdentityAccessKeyPermission.Get, IdentityAccessKeyPermission.List, IdentityAccessKeyPermission.Create, IdentityAccessKeyPermission.Update, IdentityAccessKeyPermission.Import, IdentityAccessKeyPermission.Delete, IdentityAccessKeyPermission.Backup, IdentityAccessKeyPermission.Restore, IdentityAccessKeyPermission.Recover, IdentityAccessKeyPermission.Purge}, +Secrets = {IdentityAccessSecretPermission.Get, IdentityAccessSecretPermission.List, IdentityAccessSecretPermission.Set, IdentityAccessSecretPermission.Delete, IdentityAccessSecretPermission.Backup, IdentityAccessSecretPermission.Restore, IdentityAccessSecretPermission.Recover, IdentityAccessSecretPermission.Purge}, +Certificates = {IdentityAccessCertificatePermission.Get, IdentityAccessCertificatePermission.List, IdentityAccessCertificatePermission.Delete, IdentityAccessCertificatePermission.Create, IdentityAccessCertificatePermission.Import, IdentityAccessCertificatePermission.Update, IdentityAccessCertificatePermission.ManageContacts, IdentityAccessCertificatePermission.GetIssuers, IdentityAccessCertificatePermission.ListIssuers, IdentityAccessCertificatePermission.SetIssuers, IdentityAccessCertificatePermission.DeleteIssuers, IdentityAccessCertificatePermission.ManageIssuers, IdentityAccessCertificatePermission.Recover, IdentityAccessCertificatePermission.Purge}, +})}, EnabledForDeployment = true, EnabledForDiskEncryption = true, EnabledForTemplateDeployment = true, @@ -105,18 +93,12 @@ public async Task CreateOrUpdate_CreateOrUpdateAVaultWithNetworkAcls() EnabledForDeployment = true, EnabledForDiskEncryption = true, EnabledForTemplateDeployment = true, - NetworkRuleSet = new KeyVaultNetworkRuleSet() + NetworkRuleSet = new KeyVaultNetworkRuleSet { Bypass = KeyVaultNetworkRuleBypassOption.AzureServices, DefaultAction = KeyVaultNetworkRuleAction.Deny, - IPRules = -{ -new KeyVaultIPRule("124.56.78.91"),new KeyVaultIPRule("'10.91.4.0/24'") -}, - VirtualNetworkRules = -{ -new KeyVaultVirtualNetworkRule("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1") -}, + IPRules = { new KeyVaultIPRule("124.56.78.91"), new KeyVaultIPRule("'10.91.4.0/24'") }, + VirtualNetworkRules = { new KeyVaultVirtualNetworkRule("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/subnet1") }, }, }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vaultName, content); @@ -164,10 +146,10 @@ public async Task Get_RetrieveAVault() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveAVault() + public async Task GetAll_ListVaultsInTheSpecifiedResourceGroup() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getVault.json - // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listVaultByResourceGroup.json + // this example is just showing the usage of "Vaults_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,23 +159,30 @@ public async Task Exists_RetrieveAVault() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-resource-group"; + string resourceGroupName = "sample-group"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this KeyVaultResource KeyVaultCollection collection = resourceGroupResource.GetKeyVaults(); - // invoke the operation - string vaultName = "sample-vault"; - bool result = await collection.ExistsAsync(vaultName); + // invoke the operation and iterate over the result + int? top = 1; + await foreach (KeyVaultResource item in collection.GetAllAsync(top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyVaultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAVault() + public async Task Exists_RetrieveAVault() { // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getVault.json // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. @@ -215,29 +204,17 @@ public async Task GetIfExists_RetrieveAVault() // invoke the operation string vaultName = "sample-vault"; - NullableResponse response = await collection.GetIfExistsAsync(vaultName); - KeyVaultResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vaultName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVaultsInTheSpecifiedResourceGroup() + public async Task GetIfExists_RetrieveAVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listVaultByResourceGroup.json - // this example is just showing the usage of "Vaults_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getVault.json + // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -247,25 +224,30 @@ public async Task GetAll_ListVaultsInTheSpecifiedResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "sample-group"; + string resourceGroupName = "sample-resource-group"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this KeyVaultResource KeyVaultCollection collection = resourceGroupResource.GetKeyVaults(); - // invoke the operation and iterate over the result - int? top = 1; - await foreach (KeyVaultResource item in collection.GetAllAsync(top: top)) + // invoke the operation + string vaultName = "sample-vault"; + NullableResponse response = await collection.GetIfExistsAsync(vaultName); + KeyVaultResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyVaultData resourceData = item.Data; + KeyVaultData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionCollection.cs index d8c503b2440fd..3bb0cefc3c207 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_KeyVaultPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KeyVaultGetPrivateEndpointConnection() + public async Task CreateOrUpdate_KeyVaultPutPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/putPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_KeyVaultGetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "sample-pec"; - KeyVaultPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + KeyVaultPrivateEndpointConnectionData data = new KeyVaultPrivateEndpointConnectionData + { + ETag = new ETag(""), + ConnectionState = new KeyVaultPrivateLinkServiceConnectionState + { + Status = KeyVaultPrivateEndpointServiceConnectionStatus.Approved, + Description = "My name is Joe and I'm approving this.", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + KeyVaultPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +62,7 @@ public async Task Get_KeyVaultGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KeyVaultGetPrivateEndpointConnection() + public async Task Get_KeyVaultGetPrivateEndpointConnection() { // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +85,21 @@ public async Task Exists_KeyVaultGetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "sample-pec"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + KeyVaultPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyVaultPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KeyVaultGetPrivateEndpointConnection() + public async Task GetAll_KeyVaultListPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +117,25 @@ public async Task GetIfExists_KeyVaultGetPrivateEndpointConnection() // get the collection of this KeyVaultPrivateEndpointConnectionResource KeyVaultPrivateEndpointConnectionCollection collection = keyVault.GetKeyVaultPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "sample-pec"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - KeyVaultPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (KeyVaultPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyVaultPrivateEndpointConnectionData resourceData = result.Data; + KeyVaultPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KeyVaultPutPrivateEndpointConnection() + public async Task Exists_KeyVaultGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/putPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,31 +155,17 @@ public async Task CreateOrUpdate_KeyVaultPutPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "sample-pec"; - KeyVaultPrivateEndpointConnectionData data = new KeyVaultPrivateEndpointConnectionData() - { - ETag = new ETag(""), - ConnectionState = new KeyVaultPrivateLinkServiceConnectionState() - { - Status = KeyVaultPrivateEndpointServiceConnectionStatus.Approved, - Description = "My name is Joe and I'm approving this.", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - KeyVaultPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KeyVaultListPrivateEndpointConnection() + public async Task GetIfExists_KeyVaultGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_KeyVaultListPrivateEndpointConnection() // get the collection of this KeyVaultPrivateEndpointConnectionResource KeyVaultPrivateEndpointConnectionCollection collection = keyVault.GetKeyVaultPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (KeyVaultPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "sample-pec"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + KeyVaultPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyVaultPrivateEndpointConnectionData resourceData = item.Data; + KeyVaultPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionResource.cs index c6fa3433775cb..9faf9c46f0427 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_KeyVaultGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KeyVaultPutPrivateEndpointConnection() + public async Task Delete_KeyVaultDeletePrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/putPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/deletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +69,7 @@ public async Task Update_KeyVaultPutPrivateEndpointConnection() KeyVaultPrivateEndpointConnectionResource keyVaultPrivateEndpointConnection = client.GetKeyVaultPrivateEndpointConnectionResource(keyVaultPrivateEndpointConnectionResourceId); // invoke the operation - KeyVaultPrivateEndpointConnectionData data = new KeyVaultPrivateEndpointConnectionData() - { - ETag = new ETag(""), - ConnectionState = new KeyVaultPrivateLinkServiceConnectionState() - { - Status = KeyVaultPrivateEndpointServiceConnectionStatus.Approved, - Description = "My name is Joe and I'm approving this.", - }, - }; - ArmOperation lro = await keyVaultPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await keyVaultPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); KeyVaultPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -90,10 +81,10 @@ public async Task Update_KeyVaultPutPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KeyVaultDeletePrivateEndpointConnection() + public async Task Update_KeyVaultPutPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/deletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/putPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,7 +101,16 @@ public async Task Delete_KeyVaultDeletePrivateEndpointConnection() KeyVaultPrivateEndpointConnectionResource keyVaultPrivateEndpointConnection = client.GetKeyVaultPrivateEndpointConnectionResource(keyVaultPrivateEndpointConnectionResourceId); // invoke the operation - ArmOperation lro = await keyVaultPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + KeyVaultPrivateEndpointConnectionData data = new KeyVaultPrivateEndpointConnectionData + { + ETag = new ETag(""), + ConnectionState = new KeyVaultPrivateLinkServiceConnectionState + { + Status = KeyVaultPrivateEndpointServiceConnectionStatus.Approved, + Description = "My name is Joe and I'm approving this.", + }, + }; + ArmOperation lro = await keyVaultPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); KeyVaultPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultResource.cs index 1e83cd3c88898..0e6d89c57a8c3 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.KeyVault.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.KeyVault.Samples @@ -19,10 +18,10 @@ public partial class Sample_KeyVaultResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnExistingVault() + public async Task Get_RetrieveAVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/updateVault.json - // this example is just showing the usage of "Vaults_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getVault.json + // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,37 +37,7 @@ public async Task Update_UpdateAnExistingVault() KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); // invoke the operation - KeyVaultPatch patch = new KeyVaultPatch() - { - Properties = new KeyVaultPatchProperties() - { - TenantId = Guid.Parse("00000000-0000-0000-0000-000000000000"), - Sku = new KeyVaultSku(KeyVaultSkuFamily.A, KeyVaultSkuName.Standard), - AccessPolicies = -{ -new KeyVaultAccessPolicy(Guid.Parse("00000000-0000-0000-0000-000000000000"),"00000000-0000-0000-0000-000000000000",new IdentityAccessPermissions() -{ -Keys = -{ -IdentityAccessKeyPermission.Encrypt,IdentityAccessKeyPermission.Decrypt,IdentityAccessKeyPermission.WrapKey,IdentityAccessKeyPermission.UnwrapKey,IdentityAccessKeyPermission.Sign,IdentityAccessKeyPermission.Verify,IdentityAccessKeyPermission.Get,IdentityAccessKeyPermission.List,IdentityAccessKeyPermission.Create,IdentityAccessKeyPermission.Update,IdentityAccessKeyPermission.Import,IdentityAccessKeyPermission.Delete,IdentityAccessKeyPermission.Backup,IdentityAccessKeyPermission.Restore,IdentityAccessKeyPermission.Recover,IdentityAccessKeyPermission.Purge -}, -Secrets = -{ -IdentityAccessSecretPermission.Get,IdentityAccessSecretPermission.List,IdentityAccessSecretPermission.Set,IdentityAccessSecretPermission.Delete,IdentityAccessSecretPermission.Backup,IdentityAccessSecretPermission.Restore,IdentityAccessSecretPermission.Recover,IdentityAccessSecretPermission.Purge -}, -Certificates = -{ -IdentityAccessCertificatePermission.Get,IdentityAccessCertificatePermission.List,IdentityAccessCertificatePermission.Delete,IdentityAccessCertificatePermission.Create,IdentityAccessCertificatePermission.Import,IdentityAccessCertificatePermission.Update,IdentityAccessCertificatePermission.ManageContacts,IdentityAccessCertificatePermission.GetIssuers,IdentityAccessCertificatePermission.ListIssuers,IdentityAccessCertificatePermission.SetIssuers,IdentityAccessCertificatePermission.DeleteIssuers,IdentityAccessCertificatePermission.ManageIssuers,IdentityAccessCertificatePermission.Recover,IdentityAccessCertificatePermission.Purge -}, -}) -}, - EnabledForDeployment = true, - EnabledForDiskEncryption = true, - EnabledForTemplateDeployment = true, - PublicNetworkAccess = "Enabled", - }, - }; - KeyVaultResource result = await keyVault.UpdateAsync(patch); + KeyVaultResource result = await keyVault.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -105,10 +74,10 @@ public async Task Delete_DeleteAVault() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAVault() + public async Task Update_UpdateAnExistingVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getVault.json - // this example is just showing the usage of "Vaults_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/updateVault.json + // this example is just showing the usage of "Vaults_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -124,7 +93,25 @@ public async Task Get_RetrieveAVault() KeyVaultResource keyVault = client.GetKeyVaultResource(keyVaultResourceId); // invoke the operation - KeyVaultResource result = await keyVault.GetAsync(); + KeyVaultPatch patch = new KeyVaultPatch + { + Properties = new KeyVaultPatchProperties + { + TenantId = Guid.Parse("00000000-0000-0000-0000-000000000000"), + Sku = new KeyVaultSku(KeyVaultSkuFamily.A, KeyVaultSkuName.Standard), + AccessPolicies = {new KeyVaultAccessPolicy(Guid.Parse("00000000-0000-0000-0000-000000000000"), "00000000-0000-0000-0000-000000000000", new IdentityAccessPermissions +{ +Keys = {IdentityAccessKeyPermission.Encrypt, IdentityAccessKeyPermission.Decrypt, IdentityAccessKeyPermission.WrapKey, IdentityAccessKeyPermission.UnwrapKey, IdentityAccessKeyPermission.Sign, IdentityAccessKeyPermission.Verify, IdentityAccessKeyPermission.Get, IdentityAccessKeyPermission.List, IdentityAccessKeyPermission.Create, IdentityAccessKeyPermission.Update, IdentityAccessKeyPermission.Import, IdentityAccessKeyPermission.Delete, IdentityAccessKeyPermission.Backup, IdentityAccessKeyPermission.Restore, IdentityAccessKeyPermission.Recover, IdentityAccessKeyPermission.Purge}, +Secrets = {IdentityAccessSecretPermission.Get, IdentityAccessSecretPermission.List, IdentityAccessSecretPermission.Set, IdentityAccessSecretPermission.Delete, IdentityAccessSecretPermission.Backup, IdentityAccessSecretPermission.Restore, IdentityAccessSecretPermission.Recover, IdentityAccessSecretPermission.Purge}, +Certificates = {IdentityAccessCertificatePermission.Get, IdentityAccessCertificatePermission.List, IdentityAccessCertificatePermission.Delete, IdentityAccessCertificatePermission.Create, IdentityAccessCertificatePermission.Import, IdentityAccessCertificatePermission.Update, IdentityAccessCertificatePermission.ManageContacts, IdentityAccessCertificatePermission.GetIssuers, IdentityAccessCertificatePermission.ListIssuers, IdentityAccessCertificatePermission.SetIssuers, IdentityAccessCertificatePermission.DeleteIssuers, IdentityAccessCertificatePermission.ManageIssuers, IdentityAccessCertificatePermission.Recover, IdentityAccessCertificatePermission.Purge}, +})}, + EnabledForDeployment = true, + EnabledForDiskEncryption = true, + EnabledForTemplateDeployment = true, + PublicNetworkAccess = "Enabled", + }, + }; + KeyVaultResource result = await keyVault.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -157,20 +144,11 @@ public async Task UpdateAccessPolicy_AddAnAccessPolicyOrUpdateAnAccessPolicyWith AccessPolicyUpdateKind operationKind = AccessPolicyUpdateKind.Add; KeyVaultAccessPolicyParameters keyVaultAccessPolicyParameters = new KeyVaultAccessPolicyParameters(new KeyVaultAccessPolicyProperties(new KeyVaultAccessPolicy[] { -new KeyVaultAccessPolicy(Guid.Parse("00000000-0000-0000-0000-000000000000"),"00000000-0000-0000-0000-000000000000",new IdentityAccessPermissions() -{ -Keys = -{ -IdentityAccessKeyPermission.Encrypt -}, -Secrets = +new KeyVaultAccessPolicy(Guid.Parse("00000000-0000-0000-0000-000000000000"), "00000000-0000-0000-0000-000000000000", new IdentityAccessPermissions { -IdentityAccessSecretPermission.Get -}, -Certificates = -{ -IdentityAccessCertificatePermission.Get -}, +Keys = {IdentityAccessKeyPermission.Encrypt}, +Secrets = {IdentityAccessSecretPermission.Get}, +Certificates = {IdentityAccessCertificatePermission.Get}, }) })); KeyVaultAccessPolicyParameters result = await keyVault.UpdateAccessPolicyAsync(operationKind, keyVaultAccessPolicyParameters); @@ -178,63 +156,6 @@ public async Task UpdateAccessPolicy_AddAnAccessPolicyOrUpdateAnAccessPolicyWith Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetKeyVaults_ListVaultsInTheSpecifiedSubscription() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listVaultBySubscription.json - // this example is just showing the usage of "Vaults_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - int? top = 1; - await foreach (KeyVaultResource item in subscriptionResource.GetKeyVaultsAsync(top: top)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckKeyVaultNameAvailability_ValidateAVaultName() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/checkVaultNameAvailability.json - // this example is just showing the usage of "Vaults_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - KeyVaultNameAvailabilityContent content = new KeyVaultNameAvailabilityContent("sample-vault"); - KeyVaultNameAvailabilityResult result = await subscriptionResource.CheckKeyVaultNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetPrivateLinkResources_KeyVaultListPrivateLinkResources() diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretCollection.cs index 5d023746b3ba8..b910dd73da4e8 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_CreateASecret() // invoke the operation string secretName = "secret-name"; - KeyVaultSecretCreateOrUpdateContent content = new KeyVaultSecretCreateOrUpdateContent(new SecretProperties() + KeyVaultSecretCreateOrUpdateContent content = new KeyVaultSecretCreateOrUpdateContent(new SecretProperties { Value = "secret-value", }); @@ -91,10 +91,10 @@ public async Task Get_GetASecret() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASecret() + public async Task GetAll_ListSecretsInTheVault() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getSecret.json - // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listSecrets.json + // this example is just showing the usage of "Secrets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_GetASecret() // get the collection of this KeyVaultSecretResource KeyVaultSecretCollection collection = keyVault.GetKeyVaultSecrets(); - // invoke the operation - string secretName = "secret-name"; - bool result = await collection.ExistsAsync(secretName); + // invoke the operation and iterate over the result + await foreach (KeyVaultSecretResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyVaultSecretData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASecret() + public async Task Exists_GetASecret() { // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getSecret.json // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_GetASecret() // invoke the operation string secretName = "secret-name"; - NullableResponse response = await collection.GetIfExistsAsync(secretName); - KeyVaultSecretResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(secretName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KeyVaultSecretData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecretsInTheVault() + public async Task GetIfExists_GetASecret() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listSecrets.json - // this example is just showing the usage of "Secrets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getSecret.json + // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListSecretsInTheVault() // get the collection of this KeyVaultSecretResource KeyVaultSecretCollection collection = keyVault.GetKeyVaultSecrets(); - // invoke the operation and iterate over the result - await foreach (KeyVaultSecretResource item in collection.GetAllAsync()) + // invoke the operation + string secretName = "secret-name"; + NullableResponse response = await collection.GetIfExistsAsync(secretName); + KeyVaultSecretResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KeyVaultSecretData resourceData = item.Data; + KeyVaultSecretData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretResource.cs index 8621105237228..0fd20ab6e0306 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_KeyVaultSecretResource.cs @@ -18,10 +18,10 @@ public partial class Sample_KeyVaultSecretResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASecret() + public async Task Get_GetASecret() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/updateSecret.json - // this example is just showing the usage of "Secrets_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getSecret.json + // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,14 +38,7 @@ public async Task Update_UpdateASecret() KeyVaultSecretResource keyVaultSecret = client.GetKeyVaultSecretResource(keyVaultSecretResourceId); // invoke the operation - KeyVaultSecretPatch patch = new KeyVaultSecretPatch() - { - Properties = new SecretPatchProperties() - { - Value = "secret-value2", - }, - }; - KeyVaultSecretResource result = await keyVaultSecret.UpdateAsync(patch); + KeyVaultSecretResource result = await keyVaultSecret.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -56,10 +49,10 @@ public async Task Update_UpdateASecret() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASecret() + public async Task Update_UpdateASecret() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/getSecret.json - // this example is just showing the usage of "Secrets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/updateSecret.json + // this example is just showing the usage of "Secrets_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +69,14 @@ public async Task Get_GetASecret() KeyVaultSecretResource keyVaultSecret = client.GetKeyVaultSecretResource(keyVaultSecretResourceId); // invoke the operation - KeyVaultSecretResource result = await keyVaultSecret.GetAsync(); + KeyVaultSecretPatch patch = new KeyVaultSecretPatch + { + Properties = new SecretPatchProperties + { + Value = "secret-value2", + }, + }; + KeyVaultSecretResource result = await keyVaultSecret.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmCollection.cs index df3e43e02aa64..218ffec7291a6 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmCollection.cs @@ -43,13 +43,10 @@ public async Task CreateOrUpdate_CreateANewManagedHSMPoolOrUpdateAnExistingManag string name = "hsm1"; ManagedHsmData data = new ManagedHsmData(new AzureLocation("westus")) { - Properties = new ManagedHsmProperties() + Properties = new ManagedHsmProperties { TenantId = Guid.Parse("00000000-0000-0000-0000-000000000000"), - InitialAdminObjectIds = -{ -"00000000-0000-0000-0000-000000000000" -}, + InitialAdminObjectIds = { "00000000-0000-0000-0000-000000000000" }, EnableSoftDelete = true, SoftDeleteRetentionInDays = 90, EnablePurgeProtection = false, @@ -58,7 +55,7 @@ public async Task CreateOrUpdate_CreateANewManagedHSMPoolOrUpdateAnExistingManag Tags = { ["Dept"] = "hsm", -["Environment"] = "dogfood", +["Environment"] = "dogfood" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); @@ -106,10 +103,10 @@ public async Task Get_RetrieveAManagedHSMPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveAManagedHSMPool() + public async Task GetAll_ListManagedHSMPoolsInAResourceGroup() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Get.json - // this example is just showing the usage of "ManagedHsms_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_ListByResourceGroup.json + // this example is just showing the usage of "ManagedHsms_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -126,16 +123,22 @@ public async Task Exists_RetrieveAManagedHSMPool() // get the collection of this ManagedHsmResource ManagedHsmCollection collection = resourceGroupResource.GetManagedHsms(); - // invoke the operation - string name = "hsm1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (ManagedHsmResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveAManagedHSMPool() + public async Task Exists_RetrieveAManagedHSMPool() { // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Get.json // this example is just showing the usage of "ManagedHsms_Get" operation, for the dependent resources, they will have to be created separately. @@ -157,29 +160,17 @@ public async Task GetIfExists_RetrieveAManagedHSMPool() // invoke the operation string name = "hsm1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - ManagedHsmResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedHSMPoolsInAResourceGroup() + public async Task GetIfExists_RetrieveAManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_ListByResourceGroup.json - // this example is just showing the usage of "ManagedHsms_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Get.json + // this example is just showing the usage of "ManagedHsms_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,17 +187,23 @@ public async Task GetAll_ListManagedHSMPoolsInAResourceGroup() // get the collection of this ManagedHsmResource ManagedHsmCollection collection = resourceGroupResource.GetManagedHsms(); - // invoke the operation and iterate over the result - await foreach (ManagedHsmResource item in collection.GetAllAsync()) + // invoke the operation + string name = "hsm1"; + NullableResponse response = await collection.GetIfExistsAsync(name); + ManagedHsmResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedHsmData resourceData = item.Data; + ManagedHsmData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionCollection.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionCollection.cs index 9334efbf642e8..32f5f25df8149 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionCollection.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedHsmPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedHSMPoolsInASubscription() + public async Task CreateOrUpdate_ManagedHsmPutPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json - // this example is just showing the usage of "MHSMPrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_putPrivateEndpointConnection.json + // this example is just showing the usage of "MHSMPrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_ListManagedHSMPoolsInASubscription() // get the collection of this ManagedHsmPrivateEndpointConnectionResource ManagedHsmPrivateEndpointConnectionCollection collection = managedHsm.GetManagedHsmPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (ManagedHsmPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "sample-pec"; + ManagedHsmPrivateEndpointConnectionData data = new ManagedHsmPrivateEndpointConnectionData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrivateLinkServiceConnectionState = new ManagedHsmPrivateLinkServiceConnectionState + { + Status = ManagedHsmPrivateEndpointServiceConnectionStatus.Approved, + Description = "My name is Joe and I'm approving this.", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + ManagedHsmPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_ManagedHsmGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ManagedHsmGetPrivateEndpointConnection() + public async Task GetAll_ListManagedHSMPoolsInASubscription() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_getPrivateEndpointConnection.json - // this example is just showing the usage of "MHSMPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_ListPrivateEndpointConnectionsByResource.json + // this example is just showing the usage of "MHSMPrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_ManagedHsmGetPrivateEndpointConnection() // get the collection of this ManagedHsmPrivateEndpointConnectionResource ManagedHsmPrivateEndpointConnectionCollection collection = managedHsm.GetManagedHsmPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "sample-pec"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (ManagedHsmPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ManagedHsmGetPrivateEndpointConnection() + public async Task Exists_ManagedHsmGetPrivateEndpointConnection() { // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_getPrivateEndpointConnection.json // this example is just showing the usage of "MHSMPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_ManagedHsmGetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "sample-pec"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - ManagedHsmPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ManagedHsmPutPrivateEndpointConnection() + public async Task GetIfExists_ManagedHsmGetPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_putPrivateEndpointConnection.json - // this example is just showing the usage of "MHSMPrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_getPrivateEndpointConnection.json + // this example is just showing the usage of "MHSMPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_ManagedHsmPutPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "sample-pec"; - ManagedHsmPrivateEndpointConnectionData data = new ManagedHsmPrivateEndpointConnectionData(new AzureLocation("placeholder")) - { - PrivateLinkServiceConnectionState = new ManagedHsmPrivateLinkServiceConnectionState() - { - Status = ManagedHsmPrivateEndpointServiceConnectionStatus.Approved, - Description = "My name is Joe and I'm approving this.", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - ManagedHsmPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + ManagedHsmPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionResource.cs index 81d3edb538711..1ae4787074525 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_ManagedHsmGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ManagedHsmPutPrivateEndpointConnection() + public async Task Delete_ManagedHsmDeletePrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_putPrivateEndpointConnection.json - // this example is just showing the usage of "MHSMPrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_deletePrivateEndpointConnection.json + // this example is just showing the usage of "MHSMPrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,15 +69,7 @@ public async Task Update_ManagedHsmPutPrivateEndpointConnection() ManagedHsmPrivateEndpointConnectionResource managedHsmPrivateEndpointConnection = client.GetManagedHsmPrivateEndpointConnectionResource(managedHsmPrivateEndpointConnectionResourceId); // invoke the operation - ManagedHsmPrivateEndpointConnectionData data = new ManagedHsmPrivateEndpointConnectionData(new AzureLocation("placeholder")) - { - PrivateLinkServiceConnectionState = new ManagedHsmPrivateLinkServiceConnectionState() - { - Status = ManagedHsmPrivateEndpointServiceConnectionStatus.Approved, - Description = "My name is Joe and I'm approving this.", - }, - }; - ArmOperation lro = await managedHsmPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await managedHsmPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); ManagedHsmPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -89,10 +81,10 @@ public async Task Update_ManagedHsmPutPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ManagedHsmDeletePrivateEndpointConnection() + public async Task Update_ManagedHsmPutPrivateEndpointConnection() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_deletePrivateEndpointConnection.json - // this example is just showing the usage of "MHSMPrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_putPrivateEndpointConnection.json + // this example is just showing the usage of "MHSMPrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,7 +101,15 @@ public async Task Delete_ManagedHsmDeletePrivateEndpointConnection() ManagedHsmPrivateEndpointConnectionResource managedHsmPrivateEndpointConnection = client.GetManagedHsmPrivateEndpointConnectionResource(managedHsmPrivateEndpointConnectionResourceId); // invoke the operation - ArmOperation lro = await managedHsmPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + ManagedHsmPrivateEndpointConnectionData data = new ManagedHsmPrivateEndpointConnectionData(default) + { + PrivateLinkServiceConnectionState = new ManagedHsmPrivateLinkServiceConnectionState + { + Status = ManagedHsmPrivateEndpointServiceConnectionStatus.Approved, + Description = "My name is Joe and I'm approving this.", + }, + }; + ArmOperation lro = await managedHsmPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); ManagedHsmPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmResource.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmResource.cs index b0989c061a773..020d2c1091604 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmResource.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_ManagedHsmResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.KeyVault.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.KeyVault.Samples @@ -19,10 +18,10 @@ public partial class Sample_ManagedHsmResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnExistingManagedHSMPool() + public async Task Get_RetrieveAManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Update.json - // this example is just showing the usage of "ManagedHsms_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Get.json + // this example is just showing the usage of "ManagedHsms_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,7 @@ public async Task Update_UpdateAnExistingManagedHSMPool() ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); // invoke the operation - ManagedHsmData data = new ManagedHsmData(new AzureLocation("placeholder")) - { - Tags = -{ -["Dept"] = "hsm", -["Environment"] = "dogfood", -["Slice"] = "A", -}, - }; - ArmOperation lro = await managedHsm.UpdateAsync(WaitUntil.Completed, data); - ManagedHsmResource result = lro.Value; + ManagedHsmResource result = await managedHsm.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,10 +74,10 @@ public async Task Delete_DeleteAManagedHSMPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveAManagedHSMPool() + public async Task Update_UpdateAnExistingManagedHSMPool() { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Get.json - // this example is just showing the usage of "ManagedHsms_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_Update.json + // this example is just showing the usage of "ManagedHsms_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,7 +93,17 @@ public async Task Get_RetrieveAManagedHSMPool() ManagedHsmResource managedHsm = client.GetManagedHsmResource(managedHsmResourceId); // invoke the operation - ManagedHsmResource result = await managedHsm.GetAsync(); + ManagedHsmData data = new ManagedHsmData(default) + { + Tags = +{ +["Dept"] = "hsm", +["Environment"] = "dogfood", +["Slice"] = "A" +}, + }; + ArmOperation lro = await managedHsm.UpdateAsync(WaitUntil.Completed, data); + ManagedHsmResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -113,62 +112,6 @@ public async Task Get_RetrieveAManagedHSMPool() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetManagedHsms_ListManagedHSMPoolsInASubscription() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_ListBySubscription.json - // this example is just showing the usage of "ManagedHsms_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ManagedHsmResource item in subscriptionResource.GetManagedHsmsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedHsmData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckManagedHsmNameAvailability_ValidateAManagedHsmName() - { - // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_checkMhsmNameAvailability.json - // this example is just showing the usage of "ManagedHsms_CheckManagedHsmNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - ManagedHsmNameAvailabilityContent content = new ManagedHsmNameAvailabilityContent("sample-mhsm"); - ManagedHsmNameAvailabilityResult result = await subscriptionResource.CheckManagedHsmNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetMHSMPrivateLinkResourcesByManagedHsmResource_KeyVaultListPrivateLinkResources() diff --git a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 5c8b18496b7bc..c312e821476ae 100644 --- a/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/keyvault/Azure.ResourceManager.KeyVault/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.KeyVault.Models; using Azure.ResourceManager.Resources; using NUnit.Framework; @@ -16,6 +17,38 @@ namespace Azure.ResourceManager.KeyVault.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetKeyVaults_ListVaultsInTheSpecifiedSubscription() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/listVaultBySubscription.json + // this example is just showing the usage of "Vaults_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + int? top = 1; + await foreach (KeyVaultResource item in subscriptionResource.GetKeyVaultsAsync(top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KeyVaultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetDeletedKeyVaults_ListDeletedVaultsInTheSpecifiedSubscription() @@ -47,6 +80,62 @@ public async Task GetDeletedKeyVaults_ListDeletedVaultsInTheSpecifiedSubscriptio Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckKeyVaultNameAvailability_ValidateAVaultName() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/checkVaultNameAvailability.json + // this example is just showing the usage of "Vaults_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + KeyVaultNameAvailabilityContent content = new KeyVaultNameAvailabilityContent("sample-vault"); + KeyVaultNameAvailabilityResult result = await subscriptionResource.CheckKeyVaultNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetManagedHsms_ListManagedHSMPoolsInASubscription() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_ListBySubscription.json + // this example is just showing the usage of "ManagedHsms_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ManagedHsmResource item in subscriptionResource.GetManagedHsmsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedHsmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetDeletedManagedHsms_ListDeletedManagedHSMsInTheSpecifiedSubscription() @@ -77,5 +166,30 @@ public async Task GetDeletedManagedHsms_ListDeletedManagedHSMsInTheSpecifiedSubs Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckManagedHsmNameAvailability_ValidateAManagedHsmName() + { + // Generated from example definition: specification/keyvault/resource-manager/Microsoft.KeyVault/stable/2023-07-01/examples/ManagedHsm_checkMhsmNameAvailability.json + // this example is just showing the usage of "ManagedHsms_CheckManagedHsmNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + ManagedHsmNameAvailabilityContent content = new ManagedHsmNameAvailabilityContent("sample-mhsm"); + ManagedHsmNameAvailabilityResult result = await subscriptionResource.CheckManagedHsmNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesClusterExtensionCollection.cs b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesClusterExtensionCollection.cs index f44e68149cad5..5d4f1fc374153 100644 --- a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesClusterExtensionCollection.cs +++ b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesClusterExtensionCollection.cs @@ -45,23 +45,23 @@ public async Task CreateOrUpdate_CreateExtension() // invoke the operation string extensionName = "ClusterMonitor"; - KubernetesClusterExtensionData data = new KubernetesClusterExtensionData() + KubernetesClusterExtensionData data = new KubernetesClusterExtensionData { ExtensionType = "azuremonitor-containers", AutoUpgradeMinorVersion = true, ReleaseTrain = "Preview", - Scope = new KubernetesClusterExtensionScope() + Scope = new KubernetesClusterExtensionScope { ClusterReleaseNamespace = "kube-system", }, ConfigurationSettings = { ["omsagent.env.clusterName"] = "clusterName1", -["omsagent.secret.wsid"] = "a38cef99-5a89-52ed-b6db-22095c23664b", +["omsagent.secret.wsid"] = "a38cef99-5a89-52ed-b6db-22095c23664b" }, ConfigurationProtectedSettings = { -["omsagent.secret.key"] = "secretKeyValue01", +["omsagent.secret.key"] = "secretKeyValue01" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, extensionName, data); @@ -101,7 +101,7 @@ public async Task CreateOrUpdate_CreateExtensionWithPlan() // invoke the operation string extensionName = "azureVote"; - KubernetesClusterExtensionData data = new KubernetesClusterExtensionData() + KubernetesClusterExtensionData data = new KubernetesClusterExtensionData { Plan = new ArmPlan("azure-vote-standard", "Microsoft", "azure-vote-standard-offer-id"), ExtensionType = "azure-vote", @@ -156,9 +156,9 @@ public async Task Get_GetExtension() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetExtension() + public async Task Get_GetExtensionWithPlan() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtension.json + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtensionWithPlan.json // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -180,18 +180,22 @@ public async Task Exists_GetExtension() KubernetesClusterExtensionCollection collection = resourceGroupResource.GetKubernetesClusterExtensions(clusterRp, clusterResourceName, clusterName); // invoke the operation - string extensionName = "ClusterMonitor"; - bool result = await collection.ExistsAsync(extensionName); + string extensionName = "azureVote"; + KubernetesClusterExtensionResource result = await collection.GetAsync(extensionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KubernetesClusterExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetExtension() + public async Task GetAll_ListExtensions() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtension.json - // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/ListExtensions.json + // this example is just showing the usage of "Extensions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -211,30 +215,24 @@ public async Task GetIfExists_GetExtension() string clusterName = "clusterName1"; KubernetesClusterExtensionCollection collection = resourceGroupResource.GetKubernetesClusterExtensions(clusterRp, clusterResourceName, clusterName); - // invoke the operation - string extensionName = "ClusterMonitor"; - NullableResponse response = await collection.GetIfExistsAsync(extensionName); - KubernetesClusterExtensionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (KubernetesClusterExtensionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KubernetesClusterExtensionData resourceData = result.Data; + KubernetesClusterExtensionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExtensionWithPlan() + public async Task Exists_GetExtension() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtensionWithPlan.json + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtension.json // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -256,14 +254,10 @@ public async Task Get_GetExtensionWithPlan() KubernetesClusterExtensionCollection collection = resourceGroupResource.GetKubernetesClusterExtensions(clusterRp, clusterResourceName, clusterName); // invoke the operation - string extensionName = "azureVote"; - KubernetesClusterExtensionResource result = await collection.GetAsync(extensionName); + string extensionName = "ClusterMonitor"; + bool result = await collection.ExistsAsync(extensionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KubernetesClusterExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -300,9 +294,9 @@ public async Task Exists_GetExtensionWithPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetExtensionWithPlan() + public async Task GetIfExists_GetExtension() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtensionWithPlan.json + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtension.json // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -324,7 +318,7 @@ public async Task GetIfExists_GetExtensionWithPlan() KubernetesClusterExtensionCollection collection = resourceGroupResource.GetKubernetesClusterExtensions(clusterRp, clusterResourceName, clusterName); // invoke the operation - string extensionName = "azureVote"; + string extensionName = "ClusterMonitor"; NullableResponse response = await collection.GetIfExistsAsync(extensionName); KubernetesClusterExtensionResource result = response.HasValue ? response.Value : null; @@ -344,10 +338,10 @@ public async Task GetIfExists_GetExtensionWithPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExtensions() + public async Task GetIfExists_GetExtensionWithPlan() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/ListExtensions.json - // this example is just showing the usage of "Extensions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetExtensionWithPlan.json + // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -367,17 +361,23 @@ public async Task GetAll_ListExtensions() string clusterName = "clusterName1"; KubernetesClusterExtensionCollection collection = resourceGroupResource.GetKubernetesClusterExtensions(clusterRp, clusterResourceName, clusterName); - // invoke the operation and iterate over the result - await foreach (KubernetesClusterExtensionResource item in collection.GetAllAsync()) + // invoke the operation + string extensionName = "azureVote"; + NullableResponse response = await collection.GetIfExistsAsync(extensionName); + KubernetesClusterExtensionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KubernetesClusterExtensionData resourceData = item.Data; + KubernetesClusterExtensionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesClusterExtensionResource.cs b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesClusterExtensionResource.cs index b30c31fe0feeb..a1f152fab8b2c 100644 --- a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesClusterExtensionResource.cs +++ b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesClusterExtensionResource.cs @@ -135,18 +135,18 @@ public async Task Update_UpdateExtension() KubernetesClusterExtensionResource kubernetesClusterExtension = client.GetKubernetesClusterExtensionResource(kubernetesClusterExtensionResourceId); // invoke the operation - KubernetesClusterExtensionPatch patch = new KubernetesClusterExtensionPatch() + KubernetesClusterExtensionPatch patch = new KubernetesClusterExtensionPatch { AutoUpgradeMinorVersion = true, ReleaseTrain = "Preview", ConfigurationSettings = { ["omsagent.env.clusterName"] = "clusterName1", -["omsagent.secret.wsid"] = "a38cef99-5a89-52ed-b6db-22095c23664b", +["omsagent.secret.wsid"] = "a38cef99-5a89-52ed-b6db-22095c23664b" }, ConfigurationProtectedSettings = { -["omsagent.secret.key"] = "secretKeyValue01", +["omsagent.secret.key"] = "secretKeyValue01" }, }; ArmOperation lro = await kubernetesClusterExtension.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesFluxConfigurationCollection.cs b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesFluxConfigurationCollection.cs index 9cbf66cca6b95..282fd48b1be1c 100644 --- a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesFluxConfigurationCollection.cs +++ b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesFluxConfigurationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_KubernetesFluxConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFluxConfiguration() + public async Task CreateOrUpdate_CreateFluxConfiguration() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetFluxConfiguration.json - // this example is just showing the usage of "FluxConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateFluxConfiguration.json + // this example is just showing the usage of "FluxConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -44,7 +44,45 @@ public async Task Get_GetFluxConfiguration() // invoke the operation string fluxConfigurationName = "srs-fluxconfig"; - KubernetesFluxConfigurationResource result = await collection.GetAsync(fluxConfigurationName); + KubernetesFluxConfigurationData data = new KubernetesFluxConfigurationData + { + Scope = KubernetesConfigurationScope.Cluster, + Namespace = "srs-namespace", + SourceKind = KubernetesConfigurationSourceKind.GitRepository, + IsReconciliationSuspended = false, + GitRepository = new KubernetesGitRepository + { + Uri = new Uri("https://github.com/Azure/arc-k8s-demo"), + TimeoutInSeconds = 600L, + SyncIntervalInSeconds = 600L, + RepositoryRef = new KubernetesGitRepositoryRef + { + Branch = "master", + }, + HttpsCACert = "ZXhhbXBsZWNlcnRpZmljYXRl", + }, + Kustomizations = +{ +["srs-kustomization1"] = new Kustomization +{ +Path = "./test/path", +DependsOn = {}, +TimeoutInSeconds = 600L, +SyncIntervalInSeconds = 600L, +}, +["srs-kustomization2"] = new Kustomization +{ +Path = "./other/test/path", +DependsOn = {"srs-kustomization1"}, +TimeoutInSeconds = 600L, +SyncIntervalInSeconds = 600L, +RetryIntervalInSeconds = 600L, +Prune = false, +} +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fluxConfigurationName, data); + KubernetesFluxConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +93,10 @@ public async Task Get_GetFluxConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFluxConfiguration() + public async Task CreateOrUpdate_CreateFluxConfigurationWithBucketSourceKind() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetFluxConfiguration.json - // this example is just showing the usage of "FluxConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateFluxConfigurationWithBucket.json + // this example is just showing the usage of "FluxConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,14 +118,53 @@ public async Task Exists_GetFluxConfiguration() // invoke the operation string fluxConfigurationName = "srs-fluxconfig"; - bool result = await collection.ExistsAsync(fluxConfigurationName); + KubernetesFluxConfigurationData data = new KubernetesFluxConfigurationData + { + Scope = KubernetesConfigurationScope.Cluster, + Namespace = "srs-namespace", + SourceKind = KubernetesConfigurationSourceKind.Bucket, + IsReconciliationSuspended = false, + Bucket = new KubernetesBucket + { + Uri = new Uri("https://fluxminiotest.az.minio.io"), + BucketName = "flux", + TimeoutInSeconds = 1000L, + SyncIntervalInSeconds = 1000L, + AccessKey = "fluxminiotest", + }, + Kustomizations = +{ +["srs-kustomization1"] = new Kustomization +{ +Path = "./test/path", +DependsOn = {}, +TimeoutInSeconds = 600L, +SyncIntervalInSeconds = 600L, +}, +["srs-kustomization2"] = new Kustomization +{ +Path = "./other/test/path", +DependsOn = {"srs-kustomization1"}, +TimeoutInSeconds = 600L, +SyncIntervalInSeconds = 600L, +RetryIntervalInSeconds = 600L, +Prune = false, +} +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fluxConfigurationName, data); + KubernetesFluxConfigurationResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KubernetesFluxConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFluxConfiguration() + public async Task Get_GetFluxConfiguration() { // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetFluxConfiguration.json // this example is just showing the usage of "FluxConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -112,29 +189,21 @@ public async Task GetIfExists_GetFluxConfiguration() // invoke the operation string fluxConfigurationName = "srs-fluxconfig"; - NullableResponse response = await collection.GetIfExistsAsync(fluxConfigurationName); - KubernetesFluxConfigurationResource result = response.HasValue ? response.Value : null; + KubernetesFluxConfigurationResource result = await collection.GetAsync(fluxConfigurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KubernetesFluxConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KubernetesFluxConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFluxConfiguration() + public async Task GetAll_ListFluxConfiguration() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateFluxConfiguration.json - // this example is just showing the usage of "FluxConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/ListFluxConfigurations.json + // this example is just showing the usage of "FluxConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -154,66 +223,25 @@ public async Task CreateOrUpdate_CreateFluxConfiguration() string clusterName = "clusterName1"; KubernetesFluxConfigurationCollection collection = resourceGroupResource.GetKubernetesFluxConfigurations(clusterRp, clusterResourceName, clusterName); - // invoke the operation - string fluxConfigurationName = "srs-fluxconfig"; - KubernetesFluxConfigurationData data = new KubernetesFluxConfigurationData() + // invoke the operation and iterate over the result + await foreach (KubernetesFluxConfigurationResource item in collection.GetAllAsync()) { - Scope = KubernetesConfigurationScope.Cluster, - Namespace = "srs-namespace", - SourceKind = KubernetesConfigurationSourceKind.GitRepository, - IsReconciliationSuspended = false, - GitRepository = new KubernetesGitRepository() - { - Uri = new Uri("https://github.com/Azure/arc-k8s-demo"), - TimeoutInSeconds = 600L, - SyncIntervalInSeconds = 600L, - RepositoryRef = new KubernetesGitRepositoryRef() - { - Branch = "master", - }, - HttpsCACert = "ZXhhbXBsZWNlcnRpZmljYXRl", - }, - Kustomizations = -{ -["srs-kustomization1"] = new Kustomization() -{ -Path = "./test/path", -DependsOn = -{ -}, -TimeoutInSeconds = 600L, -SyncIntervalInSeconds = 600L, -}, -["srs-kustomization2"] = new Kustomization() -{ -Path = "./other/test/path", -DependsOn = -{ -"srs-kustomization1" -}, -TimeoutInSeconds = 600L, -SyncIntervalInSeconds = 600L, -RetryIntervalInSeconds = 600L, -Prune = false, -}, -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fluxConfigurationName, data); - KubernetesFluxConfigurationResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KubernetesFluxConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KubernetesFluxConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFluxConfigurationWithBucketSourceKind() + public async Task Exists_GetFluxConfiguration() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateFluxConfigurationWithBucket.json - // this example is just showing the usage of "FluxConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetFluxConfiguration.json + // this example is just showing the usage of "FluxConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -235,61 +263,17 @@ public async Task CreateOrUpdate_CreateFluxConfigurationWithBucketSourceKind() // invoke the operation string fluxConfigurationName = "srs-fluxconfig"; - KubernetesFluxConfigurationData data = new KubernetesFluxConfigurationData() - { - Scope = KubernetesConfigurationScope.Cluster, - Namespace = "srs-namespace", - SourceKind = KubernetesConfigurationSourceKind.Bucket, - IsReconciliationSuspended = false, - Bucket = new KubernetesBucket() - { - Uri = new Uri("https://fluxminiotest.az.minio.io"), - BucketName = "flux", - TimeoutInSeconds = 1000L, - SyncIntervalInSeconds = 1000L, - AccessKey = "fluxminiotest", - }, - Kustomizations = -{ -["srs-kustomization1"] = new Kustomization() -{ -Path = "./test/path", -DependsOn = -{ -}, -TimeoutInSeconds = 600L, -SyncIntervalInSeconds = 600L, -}, -["srs-kustomization2"] = new Kustomization() -{ -Path = "./other/test/path", -DependsOn = -{ -"srs-kustomization1" -}, -TimeoutInSeconds = 600L, -SyncIntervalInSeconds = 600L, -RetryIntervalInSeconds = 600L, -Prune = false, -}, -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fluxConfigurationName, data); - KubernetesFluxConfigurationResource result = lro.Value; + bool result = await collection.ExistsAsync(fluxConfigurationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KubernetesFluxConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFluxConfiguration() + public async Task GetIfExists_GetFluxConfiguration() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/ListFluxConfigurations.json - // this example is just showing the usage of "FluxConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetFluxConfiguration.json + // this example is just showing the usage of "FluxConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -309,17 +293,23 @@ public async Task GetAll_ListFluxConfiguration() string clusterName = "clusterName1"; KubernetesFluxConfigurationCollection collection = resourceGroupResource.GetKubernetesFluxConfigurations(clusterRp, clusterResourceName, clusterName); - // invoke the operation and iterate over the result - await foreach (KubernetesFluxConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string fluxConfigurationName = "srs-fluxconfig"; + NullableResponse response = await collection.GetIfExistsAsync(fluxConfigurationName); + KubernetesFluxConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KubernetesFluxConfigurationData resourceData = item.Data; + KubernetesFluxConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesFluxConfigurationResource.cs b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesFluxConfigurationResource.cs index 5357f6de488d8..d931eb29e8c2c 100644 --- a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesFluxConfigurationResource.cs +++ b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesFluxConfigurationResource.cs @@ -49,6 +49,35 @@ public async Task Get_GetFluxConfiguration() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteFluxConfiguration() + { + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/DeleteFluxConfiguration.json + // this example is just showing the usage of "FluxConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this KubernetesFluxConfigurationResource created on azure + // for more information of creating KubernetesFluxConfigurationResource, please refer to the document of KubernetesFluxConfigurationResource + string subscriptionId = "subId1"; + string resourceGroupName = "rg1"; + string clusterRp = "Microsoft.Kubernetes"; + string clusterResourceName = "connectedClusters"; + string clusterName = "clusterName1"; + string fluxConfigurationName = "srs-fluxconfig"; + ResourceIdentifier kubernetesFluxConfigurationResourceId = KubernetesFluxConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName); + KubernetesFluxConfigurationResource kubernetesFluxConfiguration = client.GetKubernetesFluxConfigurationResource(kubernetesFluxConfigurationResourceId); + + // invoke the operation + await kubernetesFluxConfiguration.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_PatchFluxConfiguration() @@ -73,29 +102,27 @@ public async Task Update_PatchFluxConfiguration() KubernetesFluxConfigurationResource kubernetesFluxConfiguration = client.GetKubernetesFluxConfigurationResource(kubernetesFluxConfigurationResourceId); // invoke the operation - KubernetesFluxConfigurationPatch patch = new KubernetesFluxConfigurationPatch() + KubernetesFluxConfigurationPatch patch = new KubernetesFluxConfigurationPatch { Suspend = true, - GitRepository = new KubernetesGitRepositoryUpdateContent() + GitRepository = new KubernetesGitRepositoryUpdateContent { Uri = new Uri("https://github.com/jonathan-innis/flux2-kustomize-helm-example.git"), }, Kustomizations = { -["srs-kustomization1"] = null, -["srs-kustomization2"] = new KustomizationUpdateContent() +["srs-kustomization1"] = default, +["srs-kustomization2"] = new KustomizationUpdateContent { Path = "./test/alt-path", -DependsOn = -{ -}, +DependsOn = {}, SyncIntervalInSeconds = 300L, }, -["srs-kustomization3"] = new KustomizationUpdateContent() +["srs-kustomization3"] = new KustomizationUpdateContent { Path = "./test/another-path", SyncIntervalInSeconds = 300L, -}, +} }, }; ArmOperation lro = await kubernetesFluxConfiguration.UpdateAsync(WaitUntil.Completed, patch); @@ -107,34 +134,5 @@ public async Task Update_PatchFluxConfiguration() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteFluxConfiguration() - { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/DeleteFluxConfiguration.json - // this example is just showing the usage of "FluxConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this KubernetesFluxConfigurationResource created on azure - // for more information of creating KubernetesFluxConfigurationResource, please refer to the document of KubernetesFluxConfigurationResource - string subscriptionId = "subId1"; - string resourceGroupName = "rg1"; - string clusterRp = "Microsoft.Kubernetes"; - string clusterResourceName = "connectedClusters"; - string clusterName = "clusterName1"; - string fluxConfigurationName = "srs-fluxconfig"; - ResourceIdentifier kubernetesFluxConfigurationResourceId = KubernetesFluxConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterRp, clusterResourceName, clusterName, fluxConfigurationName); - KubernetesFluxConfigurationResource kubernetesFluxConfiguration = client.GetKubernetesFluxConfigurationResource(kubernetesFluxConfigurationResourceId); - - // invoke the operation - await kubernetesFluxConfiguration.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesSourceControlConfigurationCollection.cs b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesSourceControlConfigurationCollection.cs index 7b07b85d407ee..c60c3eb7ac7a2 100644 --- a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesSourceControlConfigurationCollection.cs +++ b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesSourceControlConfigurationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_KubernetesSourceControlConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSourceControlConfiguration() + public async Task CreateOrUpdate_CreateSourceControlConfiguration() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetSourceControlConfiguration.json - // this example is just showing the usage of "SourceControlConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateSourceControlConfiguration.json + // this example is just showing the usage of "SourceControlConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -44,7 +44,28 @@ public async Task Get_GetSourceControlConfiguration() // invoke the operation string sourceControlConfigurationName = "SRS_GitHubConfig"; - KubernetesSourceControlConfigurationResource result = await collection.GetAsync(sourceControlConfigurationName); + KubernetesSourceControlConfigurationData data = new KubernetesSourceControlConfigurationData + { + RepositoryUri = new Uri("git@github.com:k8sdeveloper425/flux-get-started"), + OperatorNamespace = "SRS_Namespace", + OperatorInstanceName = "SRSGitHubFluxOp-01", + OperatorType = KubernetesOperator.Flux, + OperatorParams = "--git-email=xyzgituser@users.srs.github.com", + ConfigurationProtectedSettings = +{ +["protectedSetting1Key"] = "protectedSetting1Value" +}, + OperatorScope = KubernetesOperatorScope.Namespace, + SshKnownHostsContents = "c3NoLmRldi5henVyZS5jb20gc3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFCQVFDN0hyMW9UV3FOcU9sekdKT2ZHSjROYWtWeUl6ZjFyWFlkNGQ3d282akJsa0x2Q0E0b2RCbEwwbURVeVowL1FVZlRUcWV1K3RtMjJnT3N2K1ZyVlRNazZ2d1JVNzVnWS95OXV0NU1iM2JSNUJWNThkS1h5cTlBOVVlQjVDYWtlaG41WmdtNngxbUtvVnlmK0ZGbjI2aVlxWEpSZ3pJWlpjWjVWNmhyRTBRZzM5a1ptNGF6NDhvMEFVYmY2U3A0U0xkdm51TWEyc1ZOd0hCYm9TN0VKa201N1hRUFZVMy9RcHlOTEhiV0Rkend0cmxTK2V6MzBTM0FkWWhMS0VPeEFHOHdlT255cnRMSkFVZW45bVRrb2w4b0lJMWVkZjdtV1diV1ZmMG5CbWx5MjErblpjbUNUSVNRQnRkY3lQYUVubzdmRlFNREQyNi9zMGxmS29iNEt3OEg=", + IsHelmOperatorEnabled = true, + HelmOperatorProperties = new HelmOperatorProperties + { + ChartVersion = "0.3.0", + ChartValues = "--set git.ssh.secretName=flux-git-deploy --set tillerNamespace=kube-system", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sourceControlConfigurationName, data); + KubernetesSourceControlConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,7 +76,7 @@ public async Task Get_GetSourceControlConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSourceControlConfiguration() + public async Task Get_GetSourceControlConfiguration() { // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetSourceControlConfiguration.json // this example is just showing the usage of "SourceControlConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -80,17 +101,21 @@ public async Task Exists_GetSourceControlConfiguration() // invoke the operation string sourceControlConfigurationName = "SRS_GitHubConfig"; - bool result = await collection.ExistsAsync(sourceControlConfigurationName); + KubernetesSourceControlConfigurationResource result = await collection.GetAsync(sourceControlConfigurationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KubernetesSourceControlConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSourceControlConfiguration() + public async Task GetAll_ListSourceControlConfiguration() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetSourceControlConfiguration.json - // this example is just showing the usage of "SourceControlConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/ListSourceControlConfiguration.json + // this example is just showing the usage of "SourceControlConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,31 +135,25 @@ public async Task GetIfExists_GetSourceControlConfiguration() string clusterName = "clusterName1"; KubernetesSourceControlConfigurationCollection collection = resourceGroupResource.GetKubernetesSourceControlConfigurations(clusterRp, clusterResourceName, clusterName); - // invoke the operation - string sourceControlConfigurationName = "SRS_GitHubConfig"; - NullableResponse response = await collection.GetIfExistsAsync(sourceControlConfigurationName); - KubernetesSourceControlConfigurationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (KubernetesSourceControlConfigurationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KubernetesSourceControlConfigurationData resourceData = result.Data; + KubernetesSourceControlConfigurationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSourceControlConfiguration() + public async Task Exists_GetSourceControlConfiguration() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/CreateSourceControlConfiguration.json - // this example is just showing the usage of "SourceControlConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetSourceControlConfiguration.json + // this example is just showing the usage of "SourceControlConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -156,42 +175,17 @@ public async Task CreateOrUpdate_CreateSourceControlConfiguration() // invoke the operation string sourceControlConfigurationName = "SRS_GitHubConfig"; - KubernetesSourceControlConfigurationData data = new KubernetesSourceControlConfigurationData() - { - RepositoryUri = new Uri("git@github.com:k8sdeveloper425/flux-get-started"), - OperatorNamespace = "SRS_Namespace", - OperatorInstanceName = "SRSGitHubFluxOp-01", - OperatorType = KubernetesOperator.Flux, - OperatorParams = "--git-email=xyzgituser@users.srs.github.com", - ConfigurationProtectedSettings = -{ -["protectedSetting1Key"] = "protectedSetting1Value", -}, - OperatorScope = KubernetesOperatorScope.Namespace, - SshKnownHostsContents = "c3NoLmRldi5henVyZS5jb20gc3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFCQVFDN0hyMW9UV3FOcU9sekdKT2ZHSjROYWtWeUl6ZjFyWFlkNGQ3d282akJsa0x2Q0E0b2RCbEwwbURVeVowL1FVZlRUcWV1K3RtMjJnT3N2K1ZyVlRNazZ2d1JVNzVnWS95OXV0NU1iM2JSNUJWNThkS1h5cTlBOVVlQjVDYWtlaG41WmdtNngxbUtvVnlmK0ZGbjI2aVlxWEpSZ3pJWlpjWjVWNmhyRTBRZzM5a1ptNGF6NDhvMEFVYmY2U3A0U0xkdm51TWEyc1ZOd0hCYm9TN0VKa201N1hRUFZVMy9RcHlOTEhiV0Rkend0cmxTK2V6MzBTM0FkWWhMS0VPeEFHOHdlT255cnRMSkFVZW45bVRrb2w4b0lJMWVkZjdtV1diV1ZmMG5CbWx5MjErblpjbUNUSVNRQnRkY3lQYUVubzdmRlFNREQyNi9zMGxmS29iNEt3OEg=", - IsHelmOperatorEnabled = true, - HelmOperatorProperties = new HelmOperatorProperties() - { - ChartVersion = "0.3.0", - ChartValues = "--set git.ssh.secretName=flux-git-deploy --set tillerNamespace=kube-system", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sourceControlConfigurationName, data); - KubernetesSourceControlConfigurationResource result = lro.Value; + bool result = await collection.ExistsAsync(sourceControlConfigurationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KubernetesSourceControlConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSourceControlConfiguration() + public async Task GetIfExists_GetSourceControlConfiguration() { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/ListSourceControlConfiguration.json - // this example is just showing the usage of "SourceControlConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/GetSourceControlConfiguration.json + // this example is just showing the usage of "SourceControlConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -211,17 +205,23 @@ public async Task GetAll_ListSourceControlConfiguration() string clusterName = "clusterName1"; KubernetesSourceControlConfigurationCollection collection = resourceGroupResource.GetKubernetesSourceControlConfigurations(clusterRp, clusterResourceName, clusterName); - // invoke the operation and iterate over the result - await foreach (KubernetesSourceControlConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string sourceControlConfigurationName = "SRS_GitHubConfig"; + NullableResponse response = await collection.GetIfExistsAsync(sourceControlConfigurationName); + KubernetesSourceControlConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KubernetesSourceControlConfigurationData resourceData = item.Data; + KubernetesSourceControlConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesSourceControlConfigurationResource.cs b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesSourceControlConfigurationResource.cs index c9ad997a1e1c6..a4a1a709e8113 100644 --- a/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesSourceControlConfigurationResource.cs +++ b/sdk/kubernetesconfiguration/Azure.ResourceManager.KubernetesConfiguration/samples/Generated/Samples/Sample_KubernetesSourceControlConfigurationResource.cs @@ -49,6 +49,35 @@ public async Task Get_GetSourceControlConfiguration() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteSourceControlConfiguration() + { + // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/DeleteSourceControlConfiguration.json + // this example is just showing the usage of "SourceControlConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this KubernetesSourceControlConfigurationResource created on azure + // for more information of creating KubernetesSourceControlConfigurationResource, please refer to the document of KubernetesSourceControlConfigurationResource + string subscriptionId = "subId1"; + string resourceGroupName = "rg1"; + string clusterRp = "Microsoft.Kubernetes"; + string clusterResourceName = "connectedClusters"; + string clusterName = "clusterName1"; + string sourceControlConfigurationName = "SRS_GitHubConfig"; + ResourceIdentifier kubernetesSourceControlConfigurationResourceId = KubernetesSourceControlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterRp, clusterResourceName, clusterName, sourceControlConfigurationName); + KubernetesSourceControlConfigurationResource kubernetesSourceControlConfiguration = client.GetKubernetesSourceControlConfigurationResource(kubernetesSourceControlConfigurationResourceId); + + // invoke the operation + await kubernetesSourceControlConfiguration.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateSourceControlConfiguration() @@ -73,7 +102,7 @@ public async Task Update_CreateSourceControlConfiguration() KubernetesSourceControlConfigurationResource kubernetesSourceControlConfiguration = client.GetKubernetesSourceControlConfigurationResource(kubernetesSourceControlConfigurationResourceId); // invoke the operation - KubernetesSourceControlConfigurationData data = new KubernetesSourceControlConfigurationData() + KubernetesSourceControlConfigurationData data = new KubernetesSourceControlConfigurationData { RepositoryUri = new Uri("git@github.com:k8sdeveloper425/flux-get-started"), OperatorNamespace = "SRS_Namespace", @@ -82,12 +111,12 @@ public async Task Update_CreateSourceControlConfiguration() OperatorParams = "--git-email=xyzgituser@users.srs.github.com", ConfigurationProtectedSettings = { -["protectedSetting1Key"] = "protectedSetting1Value", +["protectedSetting1Key"] = "protectedSetting1Value" }, OperatorScope = KubernetesOperatorScope.Namespace, SshKnownHostsContents = "c3NoLmRldi5henVyZS5jb20gc3NoLXJzYSBBQUFBQjNOemFDMXljMkVBQUFBREFRQUJBQUFCQVFDN0hyMW9UV3FOcU9sekdKT2ZHSjROYWtWeUl6ZjFyWFlkNGQ3d282akJsa0x2Q0E0b2RCbEwwbURVeVowL1FVZlRUcWV1K3RtMjJnT3N2K1ZyVlRNazZ2d1JVNzVnWS95OXV0NU1iM2JSNUJWNThkS1h5cTlBOVVlQjVDYWtlaG41WmdtNngxbUtvVnlmK0ZGbjI2aVlxWEpSZ3pJWlpjWjVWNmhyRTBRZzM5a1ptNGF6NDhvMEFVYmY2U3A0U0xkdm51TWEyc1ZOd0hCYm9TN0VKa201N1hRUFZVMy9RcHlOTEhiV0Rkend0cmxTK2V6MzBTM0FkWWhMS0VPeEFHOHdlT255cnRMSkFVZW45bVRrb2w4b0lJMWVkZjdtV1diV1ZmMG5CbWx5MjErblpjbUNUSVNRQnRkY3lQYUVubzdmRlFNREQyNi9zMGxmS29iNEt3OEg=", IsHelmOperatorEnabled = true, - HelmOperatorProperties = new HelmOperatorProperties() + HelmOperatorProperties = new HelmOperatorProperties { ChartVersion = "0.3.0", ChartValues = "--set git.ssh.secretName=flux-git-deploy --set tillerNamespace=kube-system", @@ -102,34 +131,5 @@ public async Task Update_CreateSourceControlConfiguration() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSourceControlConfiguration() - { - // Generated from example definition: specification/kubernetesconfiguration/resource-manager/Microsoft.KubernetesConfiguration/stable/2022-11-01/examples/DeleteSourceControlConfiguration.json - // this example is just showing the usage of "SourceControlConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this KubernetesSourceControlConfigurationResource created on azure - // for more information of creating KubernetesSourceControlConfigurationResource, please refer to the document of KubernetesSourceControlConfigurationResource - string subscriptionId = "subId1"; - string resourceGroupName = "rg1"; - string clusterRp = "Microsoft.Kubernetes"; - string clusterResourceName = "connectedClusters"; - string clusterName = "clusterName1"; - string sourceControlConfigurationName = "SRS_GitHubConfig"; - ResourceIdentifier kubernetesSourceControlConfigurationResourceId = KubernetesSourceControlConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterRp, clusterResourceName, clusterName, sourceControlConfigurationName); - KubernetesSourceControlConfigurationResource kubernetesSourceControlConfiguration = client.GetKubernetesSourceControlConfigurationResource(kubernetesSourceControlConfigurationResourceId); - - // invoke the operation - await kubernetesSourceControlConfiguration.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } From 02cdb56c060c1e09118b5d0e8a1c9c2f3a093035 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 03:59:51 +0000 Subject: [PATCH 07/11] Update SDK code st_wo_9 --- .../Samples/Sample_DiskPoolCollection.cs | 86 +- .../Sample_DiskPoolIscsiTargetCollection.cs | 69 +- .../Sample_DiskPoolIscsiTargetResource.cs | 37 +- .../Samples/Sample_DiskPoolResource.cs | 89 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Samples/Sample_CloudEndpointCollection.cs | 64 +- .../Samples/Sample_CloudEndpointResource.cs | 88 +- .../Sample_StorageSyncGroupCollection.cs | 67 +- .../Sample_StorageSyncGroupResource.cs | 49 +- ...SyncPrivateEndpointConnectionCollection.cs | 102 +- ...geSyncPrivateEndpointConnectionResource.cs | 50 +- ...e_StorageSyncRegisteredServerCollection.cs | 106 +- ...ple_StorageSyncRegisteredServerResource.cs | 56 +- ...ple_StorageSyncServerEndpointCollection.cs | 64 +- ...ample_StorageSyncServerEndpointResource.cs | 56 +- .../Sample_StorageSyncServiceCollection.cs | 66 +- .../Sample_StorageSyncServiceResource.cs | 130 +- .../Sample_StorageSyncWorkflowCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 103 ++ ...Sample_StreamAnalyticsClusterCollection.cs | 66 +- .../Sample_StreamAnalyticsClusterResource.cs | 78 +- ...treamAnalyticsPrivateEndpointCollection.cs | 78 +- ..._StreamAnalyticsPrivateEndpointResource.cs | 66 +- .../Samples/Sample_StreamingJobCollection.cs | 199 ++- .../Sample_StreamingJobFunctionCollection.cs | 180 +-- .../Sample_StreamingJobFunctionResource.cs | 74 +- .../Sample_StreamingJobInputCollection.cs | 335 ++--- .../Sample_StreamingJobInputResource.cs | 176 +-- .../Sample_StreamingJobOutputCollection.cs | 706 +++++---- .../Sample_StreamingJobOutputResource.cs | 380 ++--- .../Samples/Sample_StreamingJobResource.cs | 134 +- ...le_StreamingJobTransformationCollection.cs | 2 +- ...mple_StreamingJobTransformationResource.cs | 24 +- .../Sample_SubscriptionResourceExtensions.cs | 187 ++- .../Sample_BillingAccountPolicyCollection.cs | 13 +- .../Sample_SubscriptionAliasCollection.cs | 85 +- .../Sample_SubscriptionAliasResource.cs | 76 +- .../Sample_SubscriptionResourceExtensions.cs | 2 +- .../Samples/Sample_TenantPolicyResource.cs | 33 +- .../Sample_TenantResourceExtensions.cs | 13 +- .../Sample_ProblemClassificationCollection.cs | 48 +- ...ple_SubscriptionFileWorkspaceCollection.cs | 64 +- .../Sample_SubscriptionResourceExtensions.cs | 45 + ...ple_SubscriptionSupportTicketCollection.cs | 1100 ++++++++------ ...ample_SubscriptionSupportTicketResource.cs | 41 +- .../Sample_SupportAzureServiceCollection.cs | 65 +- ...e_SupportTicketChatTranscriptCollection.cs | 48 +- ...le_SupportTicketCommunicationCollection.cs | 136 +- .../Sample_SupportTicketFileCollection.cs | 100 +- .../Sample_SupportTicketFileResource.cs | 4 +- ...portTicketNoSubChatTranscriptCollection.cs | 48 +- ...pportTicketNoSubCommunicationCollection.cs | 134 +- ...Sample_SupportTicketNoSubFileCollection.cs | 100 +- .../Sample_SupportTicketNoSubFileResource.cs | 4 +- .../Sample_TenantFileWorkspaceCollection.cs | 73 +- .../Sample_TenantResourceExtensions.cs | 41 + .../Sample_TenantSupportTicketCollection.cs | 362 ++--- .../Sample_TenantSupportTicketResource.cs | 38 +- .../Sample_SubscriptionResourceExtensions.cs | 135 ++ ..._SynapseAadOnlyAuthenticationCollection.cs | 90 +- ...le_SynapseAadOnlyAuthenticationResource.cs | 2 +- ...AttachedDatabaseConfigurationCollection.cs | 138 +- ...seAttachedDatabaseConfigurationResource.cs | 80 +- ...Sample_SynapseBigDataPoolInfoCollection.cs | 142 +- .../Sample_SynapseBigDataPoolInfoResource.cs | 44 +- ...pseClusterPrincipalAssignmentCollection.cs | 102 +- ...napseClusterPrincipalAssignmentResource.cs | 44 +- .../Sample_SynapseDataConnectionCollection.cs | 100 +- .../Sample_SynapseDataConnectionResource.cs | 46 +- ...Sample_SynapseDataMaskingPolicyResource.cs | 34 +- ...Sample_SynapseDataMaskingRuleCollection.cs | 70 +- .../Sample_SynapseDataMaskingRuleResource.cs | 68 +- .../Sample_SynapseDatabaseCollection.cs | 98 +- ...seDatabasePrincipalAssignmentCollection.cs | 102 +- ...apseDatabasePrincipalAssignmentResource.cs | 44 +- .../Samples/Sample_SynapseDatabaseResource.cs | 40 +- ...DedicatedSqlMinimalTlsSettingCollection.cs | 62 +- ...le_SynapseEncryptionProtectorCollection.cs | 128 +- ...mple_SynapseEncryptionProtectorResource.cs | 4 +- ...endedServerBlobAuditingPolicyCollection.cs | 147 +- ...xtendedServerBlobAuditingPolicyResource.cs | 9 +- ...tendedSqlPoolBlobAuditingPolicyResource.cs | 11 +- ...Sample_SynapseGeoBackupPolicyCollection.cs | 68 +- .../Sample_SynapseGeoBackupPolicyResource.cs | 28 +- ...ple_SynapseIPFirewallRuleInfoCollection.cs | 66 +- ...ample_SynapseIPFirewallRuleInfoResource.cs | 28 +- ...ple_SynapseIntegrationRuntimeCollection.cs | 90 +- ...ample_SynapseIntegrationRuntimeResource.cs | 52 +- .../Samples/Sample_SynapseKeyCollection.cs | 102 +- .../Samples/Sample_SynapseKeyResource.cs | 26 +- .../Sample_SynapseKustoPoolCollection.cs | 108 +- .../Sample_SynapseKustoPoolResource.cs | 122 +- .../Sample_SynapseLibraryCollection.cs | 62 +- ...Sample_SynapseMaintenanceWindowResource.cs | 11 +- ...anagedIdentitySqlControlSettingResource.cs | 4 +- ...ynapseMetadataSyncConfigurationResource.cs | 2 +- ...apsePrivateEndpointConnectionCollection.cs | 98 +- ...ntConnectionForPrivateLinkHubCollection.cs | 48 +- ...ynapsePrivateEndpointConnectionResource.cs | 46 +- .../Sample_SynapsePrivateLinkHubCollection.cs | 102 +- .../Sample_SynapsePrivateLinkHubResource.cs | 72 +- ...le_SynapsePrivateLinkResourceCollection.cs | 48 +- ...ple_SynapseRecoverableSqlPoolCollection.cs | 48 +- ...Sample_SynapseReplicationLinkCollection.cs | 48 +- ...napseRestorableDroppedSqlPoolCollection.cs | 70 +- .../Sample_SynapseRestorePointCollection.cs | 56 +- ...napseServerBlobAuditingPolicyCollection.cs | 147 +- ...SynapseServerBlobAuditingPolicyResource.cs | 9 +- ...apseServerSecurityAlertPolicyCollection.cs | 148 +- ...ynapseServerSecurityAlertPolicyResource.cs | 14 +- ...ServerVulnerabilityAssessmentCollection.cs | 169 ++- ...seServerVulnerabilityAssessmentResource.cs | 67 +- ...ple_SynapseSparkConfigurationCollection.cs | 62 +- ...ynapseSqlPoolBlobAuditingPolicyResource.cs | 9 +- .../Sample_SynapseSqlPoolCollection.cs | 168 ++- .../Sample_SynapseSqlPoolColumnCollection.cs | 48 +- .../Sample_SynapseSqlPoolColumnResource.cs | 48 +- .../Samples/Sample_SynapseSqlPoolResource.cs | 90 +- .../Sample_SynapseSqlPoolSchemaCollection.cs | 48 +- ...pseSqlPoolSecurityAlertPolicyCollection.cs | 158 +- ...napseSqlPoolSecurityAlertPolicyResource.cs | 14 +- .../Sample_SynapseSqlPoolTableCollection.cs | 48 +- ...qlPoolVulnerabilityAssessmentCollection.cs | 181 ++- ...eSqlPoolVulnerabilityAssessmentResource.cs | 69 +- ...abilityAssessmentRuleBaselineCollection.cs | 16 +- ...erabilityAssessmentRuleBaselineResource.cs | 50 +- ...apseTransparentDataEncryptionCollection.cs | 90 +- ...ynapseTransparentDataEncryptionResource.cs | 2 +- ...erabilityAssessmentScanRecordCollection.cs | 48 +- ...lnerabilityAssessmentScanRecordResource.cs | 50 +- ...ple_SynapseWorkloadClassifierCollection.cs | 140 +- ...ample_SynapseWorkloadClassifierResource.cs | 54 +- .../Sample_SynapseWorkloadGroupCollection.cs | 138 +- .../Sample_SynapseWorkloadGroupResource.cs | 58 +- ...e_SynapseWorkspaceAdministratorResource.cs | 44 +- .../Sample_SynapseWorkspaceCollection.cs | 207 ++- ...eWorkspacePrivateLinkResourceCollection.cs | 48 +- .../Sample_SynapseWorkspaceResource.cs | 157 +- ...ynapseWorkspaceSqlAdministratorResource.cs | 44 +- .../Sample_SubscriptionResourceExtensions.cs | 109 ++ .../Sample_TenantResourceExtensions.cs | 70 + ...Sample_TrafficManagerEndpointCollection.cs | 405 +++-- .../Sample_TrafficManagerEndpointResource.cs | 78 +- .../Sample_TrafficManagerHeatMapCollection.cs | 138 +- .../Sample_TrafficManagerHeatMapResource.cs | 10 +- .../Sample_TrafficManagerProfileCollection.cs | 772 +++++----- .../Sample_TrafficManagerProfileResource.cs | 157 +- ...ample_TrafficManagerUserMetricsResource.cs | 30 +- .../Sample_SubscriptionResourceExtensions.cs | 76 + .../Sample_TrustedSigningAccountCollection.cs | 96 +- .../Sample_TrustedSigningAccountResource.cs | 101 +- ...stedSigningCertificateProfileCollection.cs | 102 +- ...rustedSigningCertificateProfileResource.cs | 44 +- .../Sample_SubscriptionResourceExtensions.cs | 33 +- ...ServicesCommunicationsGatewayCollection.cs | 151 +- ...ceServicesCommunicationsGatewayResource.cs | 32 - .../Sample_VoiceServicesTestLineCollection.cs | 98 +- .../Sample_SubscriptionResourceExtensions.cs | 57 + .../Samples/Sample_WebPubSubCollection.cs | 172 +-- .../Samples/Sample_WebPubSubHubCollection.cs | 120 +- .../Samples/Sample_WebPubSubHubResource.cs | 62 +- ...bSubPrivateEndpointConnectionCollection.cs | 106 +- ...PubSubPrivateEndpointConnectionResource.cs | 48 +- .../Samples/Sample_WebPubSubResource.cs | 92 +- ...le_WebPubSubSharedPrivateLinkCollection.cs | 100 +- ...mple_WebPubSubSharedPrivateLinkResource.cs | 42 +- .../Sample_AppCertificateCollection.cs | 101 +- .../Samples/Sample_AppCertificateResource.cs | 34 +- .../Sample_AppServiceCertificateCollection.cs | 98 +- ...le_AppServiceCertificateOrderCollection.cs | 130 +- ...mple_AppServiceCertificateOrderResource.cs | 48 +- .../Sample_AppServiceCertificateResource.cs | 2 +- .../Sample_AppServiceDomainCollection.cs | 185 ++- .../Sample_AppServiceDomainResource.cs | 41 +- .../Sample_AppServiceEnvironmentCollection.cs | 98 +- .../Sample_AppServiceEnvironmentResource.cs | 34 +- .../Sample_AppServicePlanCollection.cs | 112 +- .../Samples/Sample_AppServicePlanResource.cs | 34 +- ...le_AseV3NetworkingConfigurationResource.cs | 2 +- ...mple_CertificateOrderDetectorCollection.cs | 48 +- ...le_CustomDnsSuffixConfigurationResource.cs | 44 +- .../Samples/Sample_DeletedSiteResource.cs | 63 - ...ple_DomainOwnershipIdentifierCollection.cs | 96 +- ...ample_DomainOwnershipIdentifierResource.cs | 2 +- ...le_HostingEnvironmentDetectorCollection.cs | 48 +- ...HostingEnvironmentMultiRolePoolResource.cs | 18 +- ...mentPrivateEndpointConnectionCollection.cs | 104 +- ...onmentPrivateEndpointConnectionResource.cs | 48 +- ..._HostingEnvironmentWorkerPoolCollection.cs | 100 +- ...le_HostingEnvironmentWorkerPoolResource.cs | 2 +- .../Sample_KubeEnvironmentCollection.cs | 102 +- .../Samples/Sample_KubeEnvironmentResource.cs | 34 +- ...asicPublishingCredentialsPolicyResource.cs | 2 +- ...asicPublishingCredentialsPolicyResource.cs | 2 +- .../Samples/Sample_SiteBackupCollection.cs | 48 +- .../Samples/Sample_SiteBackupResource.cs | 22 +- .../Sample_SiteConfigAppsettingCollection.cs | 48 +- .../Samples/Sample_SiteDetectorCollection.cs | 140 +- ...Sample_SiteDiagnosticAnalysisCollection.cs | 140 +- .../Sample_SiteDiagnosticCollection.cs | 140 +- ...Sample_SiteDiagnosticDetectorCollection.cs | 140 +- ...SitePrivateEndpointConnectionCollection.cs | 82 +- ...e_SitePrivateEndpointConnectionResource.cs | 50 +- .../Sample_SiteSlotDetectorCollection.cs | 140 +- ...le_SiteSlotDiagnosticAnalysisCollection.cs | 144 +- .../Sample_SiteSlotDiagnosticCollection.cs | 144 +- ...le_SiteSlotDiagnosticDetectorCollection.cs | 144 +- ...SlotPrivateEndpointConnectionCollection.cs | 82 +- ...teSlotPrivateEndpointConnectionResource.cs | 50 +- .../Sample_SiteSlotWorkflowCollection.cs | 48 +- .../Samples/Sample_SiteWorkflowCollection.cs | 48 +- ...e_StaticSiteBasicAuthPropertyCollection.cs | 104 +- ...ple_StaticSiteBasicAuthPropertyResource.cs | 6 +- .../Sample_StaticSiteBuildCollection.cs | 48 +- ...icSiteBuildDatabaseConnectionCollection.cs | 102 +- ..._StaticSiteBuildLinkedBackendCollection.cs | 98 +- ...le_StaticSiteBuildLinkedBackendResource.cs | 52 +- .../Samples/Sample_StaticSiteBuildResource.cs | 10 +- ...eBuildUserProvidedFunctionAppCollection.cs | 100 +- ...iteBuildUserProvidedFunctionAppResource.cs | 46 +- .../Samples/Sample_StaticSiteCollection.cs | 122 +- ...taticSiteCustomDomainOverviewCollection.cs | 92 +- ..._StaticSiteCustomDomainOverviewResource.cs | 32 +- ..._StaticSiteDatabaseConnectionCollection.cs | 102 +- ...ample_StaticSiteLinkedBackendCollection.cs | 98 +- .../Sample_StaticSiteLinkedBackendResource.cs | 48 +- ...SitePrivateEndpointConnectionCollection.cs | 110 +- ...icSitePrivateEndpointConnectionResource.cs | 50 +- .../Samples/Sample_StaticSiteResource.cs | 48 +- ...icSiteUserProvidedFunctionAppCollection.cs | 100 +- ...aticSiteUserProvidedFunctionAppResource.cs | 42 +- .../Sample_SubscriptionResourceExtensions.cs | 326 ++++- .../Sample_TenantResourceExtensions.cs | 29 +- .../Sample_TopLevelDomainCollection.cs | 48 +- .../Samples/Sample_TopLevelDomainResource.cs | 2 +- .../Sample_WebAppRequestHistoryCollection.cs | 48 +- .../Samples/Sample_WebSiteCollection.cs | 327 ++--- .../Samples/Sample_WebSiteConfigResource.cs | 18 +- ...eFtpPublishingCredentialsPolicyResource.cs | 2 +- .../Samples/Sample_WebSiteResource.cs | 209 +-- .../Samples/Sample_WebSiteSlotCollection.cs | 154 +- ...e_WebSiteSlotConfigAppSettingCollection.cs | 48 +- ...tFtpPublishingCredentialsPolicyResource.cs | 2 +- .../Samples/Sample_WebSiteSlotResource.cs | 76 +- .../Sample_WorkflowRunActionCollection.cs | 48 +- ...e_WorkflowRunActionRepetitionCollection.cs | 48 +- ...kflowRunActionScopeRepetitionCollection.cs | 48 +- .../Samples/Sample_WorkflowRunCollection.cs | 48 +- .../Sample_WorkflowTriggerCollection.cs | 48 +- ...Sample_WorkflowTriggerHistoryCollection.cs | 48 +- .../Sample_WorkflowVersionCollection.cs | 48 +- .../Samples/Sample_HealthMonitorCollection.cs | 152 +- ...mple_HealthMonitorStateChangeCollection.cs | 164 +-- ..._SapApplicationServerInstanceCollection.cs | 128 +- ...le_SapApplicationServerInstanceResource.cs | 48 +- ...mple_SapCentralServerInstanceCollection.cs | 128 +- ...Sample_SapCentralServerInstanceResource.cs | 48 +- .../Sample_SapDatabaseInstanceCollection.cs | 128 +- .../Sample_SapDatabaseInstanceResource.cs | 48 +- .../Sample_SapLandscapeMonitorResource.cs | 134 +- .../Samples/Sample_SapMonitorCollection.cs | 116 +- .../Samples/Sample_SapMonitorResource.cs | 32 - .../Sample_SapProviderInstanceCollection.cs | 888 ++++++----- .../Sample_SapProviderInstanceResource.cs | 114 +- .../Sample_SapVirtualInstanceCollection.cs | 1304 +++++++---------- .../Sample_SapVirtualInstanceResource.cs | 34 +- .../Sample_SubscriptionResourceExtensions.cs | 62 + 267 files changed, 12554 insertions(+), 13059 deletions(-) create mode 100644 sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantResourceExtensions.cs create mode 100644 sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TenantResourceExtensions.cs create mode 100644 sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs diff --git a/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolCollection.cs b/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolCollection.cs index bf0ca94676734..5feae39049d30 100644 --- a/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolCollection.cs +++ b/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolCollection.cs @@ -18,41 +18,6 @@ namespace Azure.ResourceManager.StoragePool.Samples { public partial class Sample_DiskPoolCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDiskPools() - { - // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/DiskPools_ListByResourceGroup.json - // this example is just showing the usage of "DiskPools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this DiskPoolResource - DiskPoolCollection collection = resourceGroupResource.GetDiskPools(); - - // invoke the operation and iterate over the result - await foreach (DiskPoolResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateDiskPool() @@ -84,22 +49,16 @@ public async Task CreateOrUpdate_CreateOrUpdateDiskPool() { Tags = { -["key"] = "value", -}, - AvailabilityZones = -{ -"1" +["key"] = "value" }, - Disks = -{ -new WritableSubResource() + AvailabilityZones = { "1" }, + Disks = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_0"), -},new WritableSubResource() +}, new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1"), -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diskPoolName, content); DiskPoolResource result = lro.Value; @@ -144,6 +103,41 @@ public async Task Get_GetDiskPool() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListDiskPools() + { + // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/DiskPools_ListByResourceGroup.json + // this example is just showing the usage of "DiskPools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DiskPoolResource + DiskPoolCollection collection = resourceGroupResource.GetDiskPools(); + + // invoke the operation and iterate over the result + await foreach (DiskPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetDiskPool() diff --git a/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolIscsiTargetCollection.cs b/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolIscsiTargetCollection.cs index 20c5f1730d00a..54f2163cd1a89 100644 --- a/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolIscsiTargetCollection.cs +++ b/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolIscsiTargetCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DiskPoolIscsiTargetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDiskPoolsByResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateISCSITarget() { - // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/IscsiTargets_ListByDiskPool.json - // this example is just showing the usage of "IscsiTargets_ListByDiskPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/IscsiTargets_Put.json + // this example is just showing the usage of "IscsiTargets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,29 @@ public async Task GetAll_ListDiskPoolsByResourceGroup() // get the collection of this DiskPoolIscsiTargetResource DiskPoolIscsiTargetCollection collection = diskPool.GetDiskPoolIscsiTargets(); - // invoke the operation and iterate over the result - await foreach (DiskPoolIscsiTargetResource item in collection.GetAllAsync()) + // invoke the operation + string iscsiTargetName = "myIscsiTarget"; + DiskPoolIscsiTargetCreateOrUpdateContent content = new DiskPoolIscsiTargetCreateOrUpdateContent(DiskPoolIscsiTargetAclMode.Dynamic) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskPoolIscsiTargetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TargetIqn = "iqn.2005-03.org.iscsi:server1", + Luns = { new ManagedDiskIscsiLun("lun0", new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1")) }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, iscsiTargetName, content); + DiskPoolIscsiTargetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskPoolIscsiTargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateISCSITarget() + public async Task Get_GetISCSITarget() { - // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/IscsiTargets_Put.json - // this example is just showing the usage of "IscsiTargets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/IscsiTargets_Get.json + // this example is just showing the usage of "IscsiTargets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,16 +81,7 @@ public async Task CreateOrUpdate_CreateOrUpdateISCSITarget() // invoke the operation string iscsiTargetName = "myIscsiTarget"; - DiskPoolIscsiTargetCreateOrUpdateContent content = new DiskPoolIscsiTargetCreateOrUpdateContent(DiskPoolIscsiTargetAclMode.Dynamic) - { - TargetIqn = "iqn.2005-03.org.iscsi:server1", - Luns = -{ -new ManagedDiskIscsiLun("lun0",new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1")) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, iscsiTargetName, content); - DiskPoolIscsiTargetResource result = lro.Value; + DiskPoolIscsiTargetResource result = await collection.GetAsync(iscsiTargetName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -97,10 +92,10 @@ public async Task CreateOrUpdate_CreateOrUpdateISCSITarget() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetISCSITarget() + public async Task GetAll_ListDiskPoolsByResourceGroup() { - // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/IscsiTargets_Get.json - // this example is just showing the usage of "IscsiTargets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/IscsiTargets_ListByDiskPool.json + // this example is just showing the usage of "IscsiTargets_ListByDiskPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,15 +113,17 @@ public async Task Get_GetISCSITarget() // get the collection of this DiskPoolIscsiTargetResource DiskPoolIscsiTargetCollection collection = diskPool.GetDiskPoolIscsiTargets(); - // invoke the operation - string iscsiTargetName = "myIscsiTarget"; - DiskPoolIscsiTargetResource result = await collection.GetAsync(iscsiTargetName); + // invoke the operation and iterate over the result + await foreach (DiskPoolIscsiTargetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskPoolIscsiTargetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskPoolIscsiTargetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolIscsiTargetResource.cs b/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolIscsiTargetResource.cs index 640890280c7ef..00e4951798491 100644 --- a/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolIscsiTargetResource.cs +++ b/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolIscsiTargetResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DiskPoolIscsiTargetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateISCSITarget() + public async Task Get_GetISCSITarget() { - // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/IscsiTargets_Patch.json - // this example is just showing the usage of "IscsiTargets_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/IscsiTargets_Get.json + // this example is just showing the usage of "IscsiTargets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,22 +38,7 @@ public async Task Update_UpdateISCSITarget() DiskPoolIscsiTargetResource diskPoolIscsiTarget = client.GetDiskPoolIscsiTargetResource(diskPoolIscsiTargetResourceId); // invoke the operation - DiskPoolIscsiTargetPatch patch = new DiskPoolIscsiTargetPatch() - { - StaticAcls = -{ -new DiskPoolIscsiTargetPortalGroupAcl("iqn.2005-03.org.iscsi:client",new string[] -{ -"lun0" -}) -}, - Luns = -{ -new ManagedDiskIscsiLun("lun0",new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1")) -}, - }; - ArmOperation lro = await diskPoolIscsiTarget.UpdateAsync(WaitUntil.Completed, patch); - DiskPoolIscsiTargetResource result = lro.Value; + DiskPoolIscsiTargetResource result = await diskPoolIscsiTarget.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -91,10 +76,10 @@ public async Task Delete_DeleteISCSITarget() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetISCSITarget() + public async Task Update_UpdateISCSITarget() { - // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/IscsiTargets_Get.json - // this example is just showing the usage of "IscsiTargets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/IscsiTargets_Patch.json + // this example is just showing the usage of "IscsiTargets_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,7 +96,13 @@ public async Task Get_GetISCSITarget() DiskPoolIscsiTargetResource diskPoolIscsiTarget = client.GetDiskPoolIscsiTargetResource(diskPoolIscsiTargetResourceId); // invoke the operation - DiskPoolIscsiTargetResource result = await diskPoolIscsiTarget.GetAsync(); + DiskPoolIscsiTargetPatch patch = new DiskPoolIscsiTargetPatch + { + StaticAcls = { new DiskPoolIscsiTargetPortalGroupAcl("iqn.2005-03.org.iscsi:client", new string[] { "lun0" }) }, + Luns = { new ManagedDiskIscsiLun("lun0", new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1")) }, + }; + ArmOperation lro = await diskPoolIscsiTarget.UpdateAsync(WaitUntil.Completed, patch); + DiskPoolIscsiTargetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolResource.cs b/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolResource.cs index 24fe3f661468c..6798b072e3a29 100644 --- a/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolResource.cs +++ b/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_DiskPoolResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.StoragePool.Models; using NUnit.Framework; @@ -20,41 +19,10 @@ public partial class Sample_DiskPoolResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDiskPools_ListDiskPoolsBySubscription() - { - // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/DiskPools_ListBySubscription.json - // this example is just showing the usage of "DiskPools_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DiskPoolResource item in subscriptionResource.GetDiskPoolsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiskPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateDiskPool() + public async Task Get_GetDiskPool() { - // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/DiskPools_Patch.json - // this example is just showing the usage of "DiskPools_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/DiskPools_Get.json + // this example is just showing the usage of "DiskPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,29 +38,7 @@ public async Task Update_UpdateDiskPool() DiskPoolResource diskPool = client.GetDiskPoolResource(diskPoolResourceId); // invoke the operation - DiskPoolPatch patch = new DiskPoolPatch() - { - Sku = new StoragePoolSku("Basic_B1") - { - Tier = "Basic", - }, - Tags = -{ -["key"] = "value", -}, - Disks = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_0"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1"), -} -}, - }; - ArmOperation lro = await diskPool.UpdateAsync(WaitUntil.Completed, patch); - DiskPoolResource result = lro.Value; + DiskPoolResource result = await diskPool.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -129,10 +75,10 @@ public async Task Delete_DeleteDiskPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDiskPool() + public async Task Update_UpdateDiskPool() { - // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/DiskPools_Get.json - // this example is just showing the usage of "DiskPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/DiskPools_Patch.json + // this example is just showing the usage of "DiskPools_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,7 +94,26 @@ public async Task Get_GetDiskPool() DiskPoolResource diskPool = client.GetDiskPoolResource(diskPoolResourceId); // invoke the operation - DiskPoolResource result = await diskPool.GetAsync(); + DiskPoolPatch patch = new DiskPoolPatch + { + Sku = new StoragePoolSku("Basic_B1") + { + Tier = "Basic", + }, + Tags = +{ +["key"] = "value" +}, + Disks = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_0"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/vm-name_DataDisk_1"), +}}, + }; + ArmOperation lro = await diskPool.UpdateAsync(WaitUntil.Completed, patch); + DiskPoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index b387a031845d0..ef5c7155d0284 100644 --- a/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/storagepool/Azure.ResourceManager.StoragePool/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.StoragePool.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDiskPools_ListDiskPoolsBySubscription() + { + // Generated from example definition: specification/storagepool/resource-manager/Microsoft.StoragePool/stable/2021-08-01/examples/DiskPools_ListBySubscription.json + // this example is just showing the usage of "DiskPools_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DiskPoolResource item in subscriptionResource.GetDiskPoolsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiskPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetDiskPoolZones_ListDiskPoolZones() diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_CloudEndpointCollection.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_CloudEndpointCollection.cs index 66ce744fcc0de..b933114e4c514 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_CloudEndpointCollection.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_CloudEndpointCollection.cs @@ -42,7 +42,7 @@ public async Task CreateOrUpdate_CloudEndpointsCreate() // invoke the operation string cloudEndpointName = "SampleCloudEndpoint_1"; - CloudEndpointCreateOrUpdateContent content = new CloudEndpointCreateOrUpdateContent() + CloudEndpointCreateOrUpdateContent content = new CloudEndpointCreateOrUpdateContent { StorageAccountResourceId = new ResourceIdentifier("/subscriptions/744f4d70-6d17-4921-8970-a765d14f763f/resourceGroups/tminienv59svc/providers/Microsoft.Storage/storageAccounts/tminienv59storage"), AzureFileShareName = "cvcloud-afscv-0719-058-a94a1354-a1fd-4e9a-9a50-919fad8c4ba4", @@ -96,10 +96,10 @@ public async Task Get_CloudEndpointsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CloudEndpointsGet() + public async Task GetAll_CloudEndpointsListBySyncGroup() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_Get.json - // this example is just showing the usage of "CloudEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_ListBySyncGroup.json + // this example is just showing the usage of "CloudEndpoints_ListBySyncGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +118,22 @@ public async Task Exists_CloudEndpointsGet() // get the collection of this CloudEndpointResource CloudEndpointCollection collection = storageSyncGroup.GetCloudEndpoints(); - // invoke the operation - string cloudEndpointName = "SampleCloudEndpoint_1"; - bool result = await collection.ExistsAsync(cloudEndpointName); + // invoke the operation and iterate over the result + await foreach (CloudEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CloudEndpointsGet() + public async Task Exists_CloudEndpointsGet() { // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_Get.json // this example is just showing the usage of "CloudEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -151,29 +157,17 @@ public async Task GetIfExists_CloudEndpointsGet() // invoke the operation string cloudEndpointName = "SampleCloudEndpoint_1"; - NullableResponse response = await collection.GetIfExistsAsync(cloudEndpointName); - CloudEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(cloudEndpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CloudEndpointsListBySyncGroup() + public async Task GetIfExists_CloudEndpointsGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_ListBySyncGroup.json - // this example is just showing the usage of "CloudEndpoints_ListBySyncGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_Get.json + // this example is just showing the usage of "CloudEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,17 +186,23 @@ public async Task GetAll_CloudEndpointsListBySyncGroup() // get the collection of this CloudEndpointResource CloudEndpointCollection collection = storageSyncGroup.GetCloudEndpoints(); - // invoke the operation and iterate over the result - await foreach (CloudEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string cloudEndpointName = "SampleCloudEndpoint_1"; + NullableResponse response = await collection.GetIfExistsAsync(cloudEndpointName); + CloudEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CloudEndpointData resourceData = item.Data; + CloudEndpointData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_CloudEndpointResource.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_CloudEndpointResource.cs index 9869660eea46b..95198eee6d798 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_CloudEndpointResource.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_CloudEndpointResource.cs @@ -18,10 +18,10 @@ public partial class Sample_CloudEndpointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CloudEndpointsCreate() + public async Task Get_CloudEndpointsGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_Create.json - // this example is just showing the usage of "CloudEndpoints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_Get.json + // this example is just showing the usage of "CloudEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,15 +39,7 @@ public async Task Update_CloudEndpointsCreate() CloudEndpointResource cloudEndpoint = client.GetCloudEndpointResource(cloudEndpointResourceId); // invoke the operation - CloudEndpointCreateOrUpdateContent content = new CloudEndpointCreateOrUpdateContent() - { - StorageAccountResourceId = new ResourceIdentifier("/subscriptions/744f4d70-6d17-4921-8970-a765d14f763f/resourceGroups/tminienv59svc/providers/Microsoft.Storage/storageAccounts/tminienv59storage"), - AzureFileShareName = "cvcloud-afscv-0719-058-a94a1354-a1fd-4e9a-9a50-919fad8c4ba4", - StorageAccountTenantId = Guid.Parse("\"72f988bf-86f1-41af-91ab-2d7cd011db47\""), - FriendlyName = "ankushbsubscriptionmgmtmab", - }; - ArmOperation lro = await cloudEndpoint.UpdateAsync(WaitUntil.Completed, content); - CloudEndpointResource result = lro.Value; + CloudEndpointResource result = await cloudEndpoint.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +50,10 @@ public async Task Update_CloudEndpointsCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CloudEndpointsGet() + public async Task Delete_CloudEndpointsDelete() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_Get.json - // this example is just showing the usage of "CloudEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_Delete.json + // this example is just showing the usage of "CloudEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,21 +71,17 @@ public async Task Get_CloudEndpointsGet() CloudEndpointResource cloudEndpoint = client.GetCloudEndpointResource(cloudEndpointResourceId); // invoke the operation - CloudEndpointResource result = await cloudEndpoint.GetAsync(); + await cloudEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CloudEndpointsDelete() + public async Task Update_CloudEndpointsCreate() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_Delete.json - // this example is just showing the usage of "CloudEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/CloudEndpoints_Create.json + // this example is just showing the usage of "CloudEndpoints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +99,21 @@ public async Task Delete_CloudEndpointsDelete() CloudEndpointResource cloudEndpoint = client.GetCloudEndpointResource(cloudEndpointResourceId); // invoke the operation - await cloudEndpoint.DeleteAsync(WaitUntil.Completed); + CloudEndpointCreateOrUpdateContent content = new CloudEndpointCreateOrUpdateContent + { + StorageAccountResourceId = new ResourceIdentifier("/subscriptions/744f4d70-6d17-4921-8970-a765d14f763f/resourceGroups/tminienv59svc/providers/Microsoft.Storage/storageAccounts/tminienv59storage"), + AzureFileShareName = "cvcloud-afscv-0719-058-a94a1354-a1fd-4e9a-9a50-919fad8c4ba4", + StorageAccountTenantId = Guid.Parse("\"72f988bf-86f1-41af-91ab-2d7cd011db47\""), + FriendlyName = "ankushbsubscriptionmgmtmab", + }; + ArmOperation lro = await cloudEndpoint.UpdateAsync(WaitUntil.Completed, content); + CloudEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -139,7 +139,7 @@ public async Task PreBackup_CloudEndpointsPreBackup() CloudEndpointResource cloudEndpoint = client.GetCloudEndpointResource(cloudEndpointResourceId); // invoke the operation - CloudEndpointBackupContent content = new CloudEndpointBackupContent() + CloudEndpointBackupContent content = new CloudEndpointBackupContent { AzureFileShare = "https://sampleserver.file.core.test-cint.azure-test.net/sampleFileShare", }; @@ -171,7 +171,7 @@ public async Task PostBackup_CloudEndpointsPostBackup() CloudEndpointResource cloudEndpoint = client.GetCloudEndpointResource(cloudEndpointResourceId); // invoke the operation - CloudEndpointBackupContent content = new CloudEndpointBackupContent() + CloudEndpointBackupContent content = new CloudEndpointBackupContent { AzureFileShare = "https://sampleserver.file.core.test-cint.azure-test.net/sampleFileShare", }; @@ -204,29 +204,26 @@ public async Task PreRestore_CloudEndpointsPreRestore() CloudEndpointResource cloudEndpoint = client.GetCloudEndpointResource(cloudEndpointResourceId); // invoke the operation - PreRestoreContent content = new PreRestoreContent() + PreRestoreContent content = new PreRestoreContent { AzureFileShareUri = new Uri("https://hfsazbackupdevintncus2.file.core.test-cint.azure-test.net/sampleFileShare"), - RestoreFileSpec = -{ -new RestoreFileSpec() + RestoreFileSpec = {new RestoreFileSpec { Path = "text1.txt", IsDirectory = false, -},new RestoreFileSpec() +}, new RestoreFileSpec { Path = "MyDir", IsDirectory = true, -},new RestoreFileSpec() +}, new RestoreFileSpec { Path = "MyDir/SubDir", IsDirectory = false, -},new RestoreFileSpec() +}, new RestoreFileSpec { Path = "MyDir/SubDir/File1.pdf", IsDirectory = false, -} -}, +}}, }; await cloudEndpoint.PreRestoreAsync(WaitUntil.Completed, content); @@ -284,31 +281,28 @@ public async Task PostRestore_CloudEndpointsPostRestore() CloudEndpointResource cloudEndpoint = client.GetCloudEndpointResource(cloudEndpointResourceId); // invoke the operation - PostRestoreContent content = new PostRestoreContent() + PostRestoreContent content = new PostRestoreContent { AzureFileShareUri = new Uri("https://hfsazbackupdevintncus2.file.core.test-cint.azure-test.net/sampleFileShare"), Status = "Succeeded", SourceAzureFileShareUri = new Uri("https://hfsazbackupdevintncus2.file.core.test-cint.azure-test.net/sampleFileShare"), - RestoreFileSpec = -{ -new RestoreFileSpec() + RestoreFileSpec = {new RestoreFileSpec { Path = "text1.txt", IsDirectory = false, -},new RestoreFileSpec() +}, new RestoreFileSpec { Path = "MyDir", IsDirectory = true, -},new RestoreFileSpec() +}, new RestoreFileSpec { Path = "MyDir/SubDir", IsDirectory = false, -},new RestoreFileSpec() +}, new RestoreFileSpec { Path = "MyDir/SubDir/File1.pdf", IsDirectory = false, -} -}, +}}, }; await cloudEndpoint.PostRestoreAsync(WaitUntil.Completed, content); @@ -338,7 +332,7 @@ public async Task TriggerChangeDetection_CloudEndpointsTriggerChangeDetection() CloudEndpointResource cloudEndpoint = client.GetCloudEndpointResource(cloudEndpointResourceId); // invoke the operation - TriggerChangeDetectionContent content = new TriggerChangeDetectionContent() + TriggerChangeDetectionContent content = new TriggerChangeDetectionContent { DirectoryPath = "NewDirectory", ChangeDetectionMode = ChangeDetectionMode.Recursive, diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncGroupCollection.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncGroupCollection.cs index 72dd9e257d86f..1a5c6251763df 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncGroupCollection.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncGroupCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_StorageSyncGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SyncGroupsListByStorageSyncService() + public async Task CreateOrUpdate_SyncGroupsCreate() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_ListByStorageSyncService.json - // this example is just showing the usage of "SyncGroups_ListByStorageSyncService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_Create.json + // this example is just showing the usage of "SyncGroups_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +39,28 @@ public async Task GetAll_SyncGroupsListByStorageSyncService() // get the collection of this StorageSyncGroupResource StorageSyncGroupCollection collection = storageSyncService.GetStorageSyncGroups(); - // invoke the operation and iterate over the result - await foreach (StorageSyncGroupResource item in collection.GetAllAsync()) + // invoke the operation + string syncGroupName = "SampleSyncGroup_1"; + StorageSyncGroupCreateOrUpdateContent content = new StorageSyncGroupCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = BinaryData.FromObjectAsJson(new object()), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncGroupName, content); + StorageSyncGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SyncGroupsCreate() + public async Task Get_SyncGroupsGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_Create.json - // this example is just showing the usage of "SyncGroups_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_Get.json + // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,14 +80,7 @@ public async Task CreateOrUpdate_SyncGroupsCreate() // invoke the operation string syncGroupName = "SampleSyncGroup_1"; - StorageSyncGroupCreateOrUpdateContent content = new StorageSyncGroupCreateOrUpdateContent() - { - Properties = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncGroupName, content); - StorageSyncGroupResource result = lro.Value; + StorageSyncGroupResource result = await collection.GetAsync(syncGroupName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -96,10 +91,10 @@ public async Task CreateOrUpdate_SyncGroupsCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SyncGroupsGet() + public async Task GetAll_SyncGroupsListByStorageSyncService() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_Get.json - // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_ListByStorageSyncService.json + // this example is just showing the usage of "SyncGroups_ListByStorageSyncService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,15 +112,17 @@ public async Task Get_SyncGroupsGet() // get the collection of this StorageSyncGroupResource StorageSyncGroupCollection collection = storageSyncService.GetStorageSyncGroups(); - // invoke the operation - string syncGroupName = "SampleSyncGroup_1"; - StorageSyncGroupResource result = await collection.GetAsync(syncGroupName); + // invoke the operation and iterate over the result + await foreach (StorageSyncGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncGroupResource.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncGroupResource.cs index 4a6f73a0be88e..f2b7a487dfd74 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncGroupResource.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncGroupResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_StorageSyncGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SyncGroupsCreate() + public async Task Get_SyncGroupsGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_Create.json - // this example is just showing the usage of "SyncGroups_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_Get.json + // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,14 +38,7 @@ public async Task Update_SyncGroupsCreate() StorageSyncGroupResource storageSyncGroup = client.GetStorageSyncGroupResource(storageSyncGroupResourceId); // invoke the operation - StorageSyncGroupCreateOrUpdateContent content = new StorageSyncGroupCreateOrUpdateContent() - { - Properties = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - }; - ArmOperation lro = await storageSyncGroup.UpdateAsync(WaitUntil.Completed, content); - StorageSyncGroupResource result = lro.Value; + StorageSyncGroupResource result = await storageSyncGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +49,10 @@ public async Task Update_SyncGroupsCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SyncGroupsGet() + public async Task Delete_SyncGroupsDelete() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_Get.json - // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_Delete.json + // this example is just showing the usage of "SyncGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,21 +69,17 @@ public async Task Get_SyncGroupsGet() StorageSyncGroupResource storageSyncGroup = client.GetStorageSyncGroupResource(storageSyncGroupResourceId); // invoke the operation - StorageSyncGroupResource result = await storageSyncGroup.GetAsync(); + await storageSyncGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SyncGroupsDelete() + public async Task Update_SyncGroupsCreate() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_Delete.json - // this example is just showing the usage of "SyncGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/SyncGroups_Create.json + // this example is just showing the usage of "SyncGroups_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,18 @@ public async Task Delete_SyncGroupsDelete() StorageSyncGroupResource storageSyncGroup = client.GetStorageSyncGroupResource(storageSyncGroupResourceId); // invoke the operation - await storageSyncGroup.DeleteAsync(WaitUntil.Completed); + StorageSyncGroupCreateOrUpdateContent content = new StorageSyncGroupCreateOrUpdateContent + { + Properties = BinaryData.FromObjectAsJson(new object()), + }; + ArmOperation lro = await storageSyncGroup.UpdateAsync(WaitUntil.Completed, content); + StorageSyncGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncPrivateEndpointConnectionCollection.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncPrivateEndpointConnectionCollection.cs index 7455d9829a5f8..407a2a18e5720 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncPrivateEndpointConnectionCollection.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageSyncPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGet() + public async Task CreateOrUpdate_PrivateEndpointConnectionsCreate() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Create.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task Get_PrivateEndpointConnectionsGet() // this example assumes you already have this StorageSyncServiceResource created on azure // for more information of creating StorageSyncServiceResource, please refer to the document of StorageSyncServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; + string resourceGroupName = "res7687"; string storageSyncServiceName = "sss2527"; ResourceIdentifier storageSyncServiceResourceId = StorageSyncServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageSyncServiceName); StorageSyncServiceResource storageSyncService = client.GetStorageSyncServiceResource(storageSyncServiceResourceId); @@ -41,7 +41,16 @@ public async Task Get_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - StorageSyncPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + StorageSyncPrivateEndpointConnectionData data = new StorageSyncPrivateEndpointConnectionData + { + ConnectionState = new StorageSyncPrivateLinkServiceConnectionState + { + Status = StorageSyncPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + StorageSyncPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGet() + public async Task Get_PrivateEndpointConnectionsGet() { // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +84,21 @@ public async Task Exists_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + StorageSyncPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGet() + public async Task GetAll_PrivateEndpointConnectionsListByStorageSyncService() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_ListByStorageSyncService.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByStorageSyncService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +116,25 @@ public async Task GetIfExists_PrivateEndpointConnectionsGet() // get the collection of this StorageSyncPrivateEndpointConnectionResource StorageSyncPrivateEndpointConnectionCollection collection = storageSyncService.GetStorageSyncPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - StorageSyncPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (StorageSyncPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageSyncPrivateEndpointConnectionData resourceData = result.Data; + StorageSyncPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionsCreate() + public async Task Exists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Create.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,7 +144,7 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsCreate() // this example assumes you already have this StorageSyncServiceResource created on azure // for more information of creating StorageSyncServiceResource, please refer to the document of StorageSyncServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; + string resourceGroupName = "res6977"; string storageSyncServiceName = "sss2527"; ResourceIdentifier storageSyncServiceResourceId = StorageSyncServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageSyncServiceName); StorageSyncServiceResource storageSyncService = client.GetStorageSyncServiceResource(storageSyncServiceResourceId); @@ -147,30 +154,17 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsCreate() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - StorageSyncPrivateEndpointConnectionData data = new StorageSyncPrivateEndpointConnectionData() - { - ConnectionState = new StorageSyncPrivateLinkServiceConnectionState() - { - Status = StorageSyncPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - StorageSyncPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsListByStorageSyncService() + public async Task GetIfExists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_ListByStorageSyncService.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByStorageSyncService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_PrivateEndpointConnectionsListByStorageSyncService() // get the collection of this StorageSyncPrivateEndpointConnectionResource StorageSyncPrivateEndpointConnectionCollection collection = storageSyncService.GetStorageSyncPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (StorageSyncPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "{privateEndpointConnectionName}"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + StorageSyncPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageSyncPrivateEndpointConnectionData resourceData = item.Data; + StorageSyncPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncPrivateEndpointConnectionResource.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncPrivateEndpointConnectionResource.cs index 635658ad67b7c..e0e56936c5686 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncPrivateEndpointConnectionResource.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsCreate() + public async Task Delete_PrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Create.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,37 +62,24 @@ public async Task Update_PrivateEndpointConnectionsCreate() // this example assumes you already have this StorageSyncPrivateEndpointConnectionResource created on azure // for more information of creating StorageSyncPrivateEndpointConnectionResource, please refer to the document of StorageSyncPrivateEndpointConnectionResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; + string resourceGroupName = "res6977"; string storageSyncServiceName = "sss2527"; string privateEndpointConnectionName = "{privateEndpointConnectionName}"; ResourceIdentifier storageSyncPrivateEndpointConnectionResourceId = StorageSyncPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageSyncServiceName, privateEndpointConnectionName); StorageSyncPrivateEndpointConnectionResource storageSyncPrivateEndpointConnection = client.GetStorageSyncPrivateEndpointConnectionResource(storageSyncPrivateEndpointConnectionResourceId); // invoke the operation - StorageSyncPrivateEndpointConnectionData data = new StorageSyncPrivateEndpointConnectionData() - { - ConnectionState = new StorageSyncPrivateLinkServiceConnectionState() - { - Status = StorageSyncPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await storageSyncPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - StorageSyncPrivateEndpointConnectionResource result = lro.Value; + await storageSyncPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDelete() + public async Task Update_PrivateEndpointConnectionsCreate() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/PrivateEndpointConnections_Create.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,16 +89,29 @@ public async Task Delete_PrivateEndpointConnectionsDelete() // this example assumes you already have this StorageSyncPrivateEndpointConnectionResource created on azure // for more information of creating StorageSyncPrivateEndpointConnectionResource, please refer to the document of StorageSyncPrivateEndpointConnectionResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; + string resourceGroupName = "res7687"; string storageSyncServiceName = "sss2527"; string privateEndpointConnectionName = "{privateEndpointConnectionName}"; ResourceIdentifier storageSyncPrivateEndpointConnectionResourceId = StorageSyncPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageSyncServiceName, privateEndpointConnectionName); StorageSyncPrivateEndpointConnectionResource storageSyncPrivateEndpointConnection = client.GetStorageSyncPrivateEndpointConnectionResource(storageSyncPrivateEndpointConnectionResourceId); // invoke the operation - await storageSyncPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + StorageSyncPrivateEndpointConnectionData data = new StorageSyncPrivateEndpointConnectionData + { + ConnectionState = new StorageSyncPrivateLinkServiceConnectionState + { + Status = StorageSyncPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await storageSyncPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + StorageSyncPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncRegisteredServerCollection.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncRegisteredServerCollection.cs index 1eef068f58804..899567c9a8e5a 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncRegisteredServerCollection.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncRegisteredServerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageSyncRegisteredServerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RegisteredServersListByStorageSyncService() + public async Task CreateOrUpdate_RegisteredServersCreate() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_ListByStorageSyncService.json - // this example is just showing the usage of "RegisteredServers_ListByStorageSyncService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_Create.json + // this example is just showing the usage of "RegisteredServers_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_RegisteredServersListByStorageSyncService() // get the collection of this StorageSyncRegisteredServerResource StorageSyncRegisteredServerCollection collection = storageSyncService.GetStorageSyncRegisteredServers(); - // invoke the operation and iterate over the result - await foreach (StorageSyncRegisteredServerResource item in collection.GetAllAsync()) + // invoke the operation + Guid serverId = Guid.Parse("080d4133-bdb5-40a0-96a0-71a6057bfe9a"); + StorageSyncRegisteredServerCreateOrUpdateContent content = new StorageSyncRegisteredServerCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncRegisteredServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServerCertificate = BinaryData.FromObjectAsJson("MIIDFjCCAf6gAwIBAgIQQS+DS8uhc4VNzUkTw7wbRjANBgkqhkiG9w0BAQ0FADAzMTEwLwYDVQQDEyhhbmt1c2hiLXByb2QzLnJlZG1vbmQuY29ycC5taWNyb3NvZnQuY29tMB4XDTE3MDgwMzE3MDQyNFoXDTE4MDgwNDE3MDQyNFowMzExMC8GA1UEAxMoYW5rdXNoYi1wcm9kMy5yZWRtb25kLmNvcnAubWljcm9zb2Z0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALDRvV4gmsIy6jGDPiHsXmvgVP749NNP7DopdlbHaNhjFmYINHl0uWylyaZmgJrROt2mnxN/zEyJtGnqYHlzUr4xvGq/qV5pqgdB9tag/sw9i22gfe9PRZ0FmSOZnXMbLYgLiDFqLtut5gHcOuWMj03YnkfoBEKlFBxWbagvW2yxz/Sxi9OVSJOKCaXra0RpcIHrO/KFl6ho2eE1/7Ykmfa8hZvSdoPd5gHdLiQcMB/pxq+mWp1fI6c8vFZoDu7Atn+NXTzYPKUxKzaisF12TsaKpohUsJpbB3Wocb0F5frn614D2pg14ERB5otjAMWw1m65csQWPI6dP8KIYe0+QPkCAwEAAaMmMCQwIgYDVR0lAQH/BBgwFgYIKwYBBQUHAwIGCisGAQQBgjcKAwwwDQYJKoZIhvcNAQENBQADggEBAA4RhVIBkw34M1RwakJgHvtjsOFxF1tVQA941NtLokx1l2Z8+GFQkcG4xpZSt+UN6wLerdCbnNhtkCErWUDeaT0jxk4g71Ofex7iM04crT4iHJr8mi96/XnhnkTUs+GDk12VgdeeNEczMZz+8Mxw9dJ5NCnYgTwO0SzGlclRsDvjzkLo8rh2ZG6n/jKrEyNXXo+hOqhupij0QbRP2Tvexdfw201kgN1jdZify8XzJ8Oi0bTS0KpJf2pNPOlooK2bjMUei9ANtEdXwwfVZGWvVh6tJjdv6k14wWWJ1L7zhA1IIVb1J+sQUzJji5iX0DrezjTz1Fg+gAzITaA/WsuujlM="), + AgentVersion = "1.0.277.0", + ServerOSVersion = "10.0.14393.0", + ServerRole = "Standalone", + ServerId = Guid.Parse("080d4133-bdb5-40a0-96a0-71a6057bfe9a"), + FriendlyName = "afscv-2304-139", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverId, content); + StorageSyncRegisteredServerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncRegisteredServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_RegisteredServersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RegisteredServersGet() + public async Task GetAll_RegisteredServersListByStorageSyncService() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_Get.json - // this example is just showing the usage of "RegisteredServers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_ListByStorageSyncService.json + // this example is just showing the usage of "RegisteredServers_ListByStorageSyncService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_RegisteredServersGet() // get the collection of this StorageSyncRegisteredServerResource StorageSyncRegisteredServerCollection collection = storageSyncService.GetStorageSyncRegisteredServers(); - // invoke the operation - Guid serverId = Guid.Parse("080d4133-bdb5-40a0-96a0-71a6057bfe9a"); - bool result = await collection.ExistsAsync(serverId); + // invoke the operation and iterate over the result + await foreach (StorageSyncRegisteredServerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncRegisteredServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RegisteredServersGet() + public async Task Exists_RegisteredServersGet() { // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_Get.json // this example is just showing the usage of "RegisteredServers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_RegisteredServersGet() // invoke the operation Guid serverId = Guid.Parse("080d4133-bdb5-40a0-96a0-71a6057bfe9a"); - NullableResponse response = await collection.GetIfExistsAsync(serverId); - StorageSyncRegisteredServerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serverId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncRegisteredServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RegisteredServersCreate() + public async Task GetIfExists_RegisteredServersGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_Create.json - // this example is just showing the usage of "RegisteredServers_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_Get.json + // this example is just showing the usage of "RegisteredServers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_RegisteredServersCreate() // invoke the operation Guid serverId = Guid.Parse("080d4133-bdb5-40a0-96a0-71a6057bfe9a"); - StorageSyncRegisteredServerCreateOrUpdateContent content = new StorageSyncRegisteredServerCreateOrUpdateContent() - { - ServerCertificate = BinaryData.FromString("\"MIIDFjCCAf6gAwIBAgIQQS+DS8uhc4VNzUkTw7wbRjANBgkqhkiG9w0BAQ0FADAzMTEwLwYDVQQDEyhhbmt1c2hiLXByb2QzLnJlZG1vbmQuY29ycC5taWNyb3NvZnQuY29tMB4XDTE3MDgwMzE3MDQyNFoXDTE4MDgwNDE3MDQyNFowMzExMC8GA1UEAxMoYW5rdXNoYi1wcm9kMy5yZWRtb25kLmNvcnAubWljcm9zb2Z0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALDRvV4gmsIy6jGDPiHsXmvgVP749NNP7DopdlbHaNhjFmYINHl0uWylyaZmgJrROt2mnxN/zEyJtGnqYHlzUr4xvGq/qV5pqgdB9tag/sw9i22gfe9PRZ0FmSOZnXMbLYgLiDFqLtut5gHcOuWMj03YnkfoBEKlFBxWbagvW2yxz/Sxi9OVSJOKCaXra0RpcIHrO/KFl6ho2eE1/7Ykmfa8hZvSdoPd5gHdLiQcMB/pxq+mWp1fI6c8vFZoDu7Atn+NXTzYPKUxKzaisF12TsaKpohUsJpbB3Wocb0F5frn614D2pg14ERB5otjAMWw1m65csQWPI6dP8KIYe0+QPkCAwEAAaMmMCQwIgYDVR0lAQH/BBgwFgYIKwYBBQUHAwIGCisGAQQBgjcKAwwwDQYJKoZIhvcNAQENBQADggEBAA4RhVIBkw34M1RwakJgHvtjsOFxF1tVQA941NtLokx1l2Z8+GFQkcG4xpZSt+UN6wLerdCbnNhtkCErWUDeaT0jxk4g71Ofex7iM04crT4iHJr8mi96/XnhnkTUs+GDk12VgdeeNEczMZz+8Mxw9dJ5NCnYgTwO0SzGlclRsDvjzkLo8rh2ZG6n/jKrEyNXXo+hOqhupij0QbRP2Tvexdfw201kgN1jdZify8XzJ8Oi0bTS0KpJf2pNPOlooK2bjMUei9ANtEdXwwfVZGWvVh6tJjdv6k14wWWJ1L7zhA1IIVb1J+sQUzJji5iX0DrezjTz1Fg+gAzITaA/WsuujlM=\""), - AgentVersion = "1.0.277.0", - ServerOSVersion = "10.0.14393.0", - ServerRole = "Standalone", - ServerId = Guid.Parse("080d4133-bdb5-40a0-96a0-71a6057bfe9a"), - FriendlyName = "afscv-2304-139", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverId, content); - StorageSyncRegisteredServerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(serverId); + StorageSyncRegisteredServerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncRegisteredServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncRegisteredServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncRegisteredServerResource.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncRegisteredServerResource.cs index ee3af389551ff..9fd94cd3714a4 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncRegisteredServerResource.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncRegisteredServerResource.cs @@ -49,10 +49,10 @@ public async Task Get_RegisteredServersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RegisteredServersCreate() + public async Task Delete_RegisteredServersDelete() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_Create.json - // this example is just showing the usage of "RegisteredServers_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_Delete.json + // this example is just showing the usage of "RegisteredServers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,36 +64,22 @@ public async Task Update_RegisteredServersCreate() string subscriptionId = "52b8da2f-61e0-4a1f-8dde-336911f367fb"; string resourceGroupName = "SampleResourceGroup_1"; string storageSyncServiceName = "SampleStorageSyncService_1"; - Guid serverId = Guid.Parse("080d4133-bdb5-40a0-96a0-71a6057bfe9a"); + Guid serverId = Guid.Parse("41166691-ab03-43e9-ab3e-0330eda162ac"); ResourceIdentifier storageSyncRegisteredServerResourceId = StorageSyncRegisteredServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageSyncServiceName, serverId); StorageSyncRegisteredServerResource storageSyncRegisteredServer = client.GetStorageSyncRegisteredServerResource(storageSyncRegisteredServerResourceId); // invoke the operation - StorageSyncRegisteredServerCreateOrUpdateContent content = new StorageSyncRegisteredServerCreateOrUpdateContent() - { - ServerCertificate = BinaryData.FromString("\"MIIDFjCCAf6gAwIBAgIQQS+DS8uhc4VNzUkTw7wbRjANBgkqhkiG9w0BAQ0FADAzMTEwLwYDVQQDEyhhbmt1c2hiLXByb2QzLnJlZG1vbmQuY29ycC5taWNyb3NvZnQuY29tMB4XDTE3MDgwMzE3MDQyNFoXDTE4MDgwNDE3MDQyNFowMzExMC8GA1UEAxMoYW5rdXNoYi1wcm9kMy5yZWRtb25kLmNvcnAubWljcm9zb2Z0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALDRvV4gmsIy6jGDPiHsXmvgVP749NNP7DopdlbHaNhjFmYINHl0uWylyaZmgJrROt2mnxN/zEyJtGnqYHlzUr4xvGq/qV5pqgdB9tag/sw9i22gfe9PRZ0FmSOZnXMbLYgLiDFqLtut5gHcOuWMj03YnkfoBEKlFBxWbagvW2yxz/Sxi9OVSJOKCaXra0RpcIHrO/KFl6ho2eE1/7Ykmfa8hZvSdoPd5gHdLiQcMB/pxq+mWp1fI6c8vFZoDu7Atn+NXTzYPKUxKzaisF12TsaKpohUsJpbB3Wocb0F5frn614D2pg14ERB5otjAMWw1m65csQWPI6dP8KIYe0+QPkCAwEAAaMmMCQwIgYDVR0lAQH/BBgwFgYIKwYBBQUHAwIGCisGAQQBgjcKAwwwDQYJKoZIhvcNAQENBQADggEBAA4RhVIBkw34M1RwakJgHvtjsOFxF1tVQA941NtLokx1l2Z8+GFQkcG4xpZSt+UN6wLerdCbnNhtkCErWUDeaT0jxk4g71Ofex7iM04crT4iHJr8mi96/XnhnkTUs+GDk12VgdeeNEczMZz+8Mxw9dJ5NCnYgTwO0SzGlclRsDvjzkLo8rh2ZG6n/jKrEyNXXo+hOqhupij0QbRP2Tvexdfw201kgN1jdZify8XzJ8Oi0bTS0KpJf2pNPOlooK2bjMUei9ANtEdXwwfVZGWvVh6tJjdv6k14wWWJ1L7zhA1IIVb1J+sQUzJji5iX0DrezjTz1Fg+gAzITaA/WsuujlM=\""), - AgentVersion = "1.0.277.0", - ServerOSVersion = "10.0.14393.0", - ServerRole = "Standalone", - ServerId = Guid.Parse("080d4133-bdb5-40a0-96a0-71a6057bfe9a"), - FriendlyName = "afscv-2304-139", - }; - ArmOperation lro = await storageSyncRegisteredServer.UpdateAsync(WaitUntil.Completed, content); - StorageSyncRegisteredServerResource result = lro.Value; + await storageSyncRegisteredServer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncRegisteredServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RegisteredServersDelete() + public async Task Update_RegisteredServersCreate() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_Delete.json - // this example is just showing the usage of "RegisteredServers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/RegisteredServers_Create.json + // this example is just showing the usage of "RegisteredServers_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,14 +91,28 @@ public async Task Delete_RegisteredServersDelete() string subscriptionId = "52b8da2f-61e0-4a1f-8dde-336911f367fb"; string resourceGroupName = "SampleResourceGroup_1"; string storageSyncServiceName = "SampleStorageSyncService_1"; - Guid serverId = Guid.Parse("41166691-ab03-43e9-ab3e-0330eda162ac"); + Guid serverId = Guid.Parse("080d4133-bdb5-40a0-96a0-71a6057bfe9a"); ResourceIdentifier storageSyncRegisteredServerResourceId = StorageSyncRegisteredServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, storageSyncServiceName, serverId); StorageSyncRegisteredServerResource storageSyncRegisteredServer = client.GetStorageSyncRegisteredServerResource(storageSyncRegisteredServerResourceId); // invoke the operation - await storageSyncRegisteredServer.DeleteAsync(WaitUntil.Completed); + StorageSyncRegisteredServerCreateOrUpdateContent content = new StorageSyncRegisteredServerCreateOrUpdateContent + { + ServerCertificate = BinaryData.FromObjectAsJson("MIIDFjCCAf6gAwIBAgIQQS+DS8uhc4VNzUkTw7wbRjANBgkqhkiG9w0BAQ0FADAzMTEwLwYDVQQDEyhhbmt1c2hiLXByb2QzLnJlZG1vbmQuY29ycC5taWNyb3NvZnQuY29tMB4XDTE3MDgwMzE3MDQyNFoXDTE4MDgwNDE3MDQyNFowMzExMC8GA1UEAxMoYW5rdXNoYi1wcm9kMy5yZWRtb25kLmNvcnAubWljcm9zb2Z0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALDRvV4gmsIy6jGDPiHsXmvgVP749NNP7DopdlbHaNhjFmYINHl0uWylyaZmgJrROt2mnxN/zEyJtGnqYHlzUr4xvGq/qV5pqgdB9tag/sw9i22gfe9PRZ0FmSOZnXMbLYgLiDFqLtut5gHcOuWMj03YnkfoBEKlFBxWbagvW2yxz/Sxi9OVSJOKCaXra0RpcIHrO/KFl6ho2eE1/7Ykmfa8hZvSdoPd5gHdLiQcMB/pxq+mWp1fI6c8vFZoDu7Atn+NXTzYPKUxKzaisF12TsaKpohUsJpbB3Wocb0F5frn614D2pg14ERB5otjAMWw1m65csQWPI6dP8KIYe0+QPkCAwEAAaMmMCQwIgYDVR0lAQH/BBgwFgYIKwYBBQUHAwIGCisGAQQBgjcKAwwwDQYJKoZIhvcNAQENBQADggEBAA4RhVIBkw34M1RwakJgHvtjsOFxF1tVQA941NtLokx1l2Z8+GFQkcG4xpZSt+UN6wLerdCbnNhtkCErWUDeaT0jxk4g71Ofex7iM04crT4iHJr8mi96/XnhnkTUs+GDk12VgdeeNEczMZz+8Mxw9dJ5NCnYgTwO0SzGlclRsDvjzkLo8rh2ZG6n/jKrEyNXXo+hOqhupij0QbRP2Tvexdfw201kgN1jdZify8XzJ8Oi0bTS0KpJf2pNPOlooK2bjMUei9ANtEdXwwfVZGWvVh6tJjdv6k14wWWJ1L7zhA1IIVb1J+sQUzJji5iX0DrezjTz1Fg+gAzITaA/WsuujlM="), + AgentVersion = "1.0.277.0", + ServerOSVersion = "10.0.14393.0", + ServerRole = "Standalone", + ServerId = Guid.Parse("080d4133-bdb5-40a0-96a0-71a6057bfe9a"), + FriendlyName = "afscv-2304-139", + }; + ArmOperation lro = await storageSyncRegisteredServer.UpdateAsync(WaitUntil.Completed, content); + StorageSyncRegisteredServerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncRegisteredServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -137,9 +137,9 @@ public async Task TriggerRollover_RegisteredServersTriggerRollover() StorageSyncRegisteredServerResource storageSyncRegisteredServer = client.GetStorageSyncRegisteredServerResource(storageSyncRegisteredServerResourceId); // invoke the operation - TriggerRolloverContent content = new TriggerRolloverContent() + TriggerRolloverContent content = new TriggerRolloverContent { - ServerCertificate = BinaryData.FromString("\"\"MIIDFjCCAf6gAwIBAgIQQS+DS8uhc4VNzUkTw7wbRjANBgkqhkiG9w0BAQ0FADAzMTEwLwYDVQQDEyhhbmt1c2hiLXByb2QzLnJlZG1vbmQuY29ycC5taWNyb3NvZnQuY29tMB4XDTE3MDgwMzE3MDQyNFoXDTE4MDgwNDE3MDQyNFowMzExMC8GA1UEAxMoYW5rdXNoYi1wcm9kMy5yZWRtb25kLmNvcnAubWljcm9zb2Z0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALDRvV4gmsIy6jGDPiHsXmvgVP749NNP7DopdlbHaNhjFmYINHl0uWylyaZmgJrROt2mnxN/zEyJtGnqYHlzUr4xvGq/qV5pqgdB9tag/sw9i22gfe9PRZ0FmSOZnXMbLYgLiDFqLtut5gHcOuWMj03YnkfoBEKlFBxWbagvW2yxz/Sxi9OVSJOKCaXra0RpcIHrO/KFl6ho2eE1/7Ykmfa8hZvSdoPd5gHdLiQcMB/pxq+mWp1fI6c8vFZoDu7Atn+NXTzYPKUxKzaisF12TsaKpohUsJpbB3Wocb0F5frn614D2pg14ERB5otjAMWw1m65csQWPI6dP8KIYe0+QPkCAwEAAaMmMCQwIgYDVR0lAQH/BBgwFgYIKwYBBQUHAwIGCisGAQQBgjcKAwwwDQYJKoZIhvcNAQENBQADggEBAA4RhVIBkw34M1RwakJgHvtjsOFxF1tVQA941NtLokx1l2Z8+GFQkcG4xpZSt+UN6wLerdCbnNhtkCErWUDeaT0jxk4g71Ofex7iM04crT4iHJr8mi96/XnhnkTUs+GDk12VgdeeNEczMZz+8Mxw9dJ5NCnYgTwO0SzGlclRsDvjzkLo8rh2ZG6n/jKrEyNXXo+hOqhupij0QbRP2Tvexdfw201kgN1jdZify8XzJ8Oi0bTS0KpJf2pNPOlooK2bjMUei9ANtEdXwwfVZGWvVh6tJjdv6k14wWWJ1L7zhA1IIVb1J+sQUzJji5iX0DrezjTz1Fg+gAzITaA/WsuujlM=\"\""), + ServerCertificate = BinaryData.FromObjectAsJson("\"MIIDFjCCAf6gAwIBAgIQQS+DS8uhc4VNzUkTw7wbRjANBgkqhkiG9w0BAQ0FADAzMTEwLwYDVQQDEyhhbmt1c2hiLXByb2QzLnJlZG1vbmQuY29ycC5taWNyb3NvZnQuY29tMB4XDTE3MDgwMzE3MDQyNFoXDTE4MDgwNDE3MDQyNFowMzExMC8GA1UEAxMoYW5rdXNoYi1wcm9kMy5yZWRtb25kLmNvcnAubWljcm9zb2Z0LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALDRvV4gmsIy6jGDPiHsXmvgVP749NNP7DopdlbHaNhjFmYINHl0uWylyaZmgJrROt2mnxN/zEyJtGnqYHlzUr4xvGq/qV5pqgdB9tag/sw9i22gfe9PRZ0FmSOZnXMbLYgLiDFqLtut5gHcOuWMj03YnkfoBEKlFBxWbagvW2yxz/Sxi9OVSJOKCaXra0RpcIHrO/KFl6ho2eE1/7Ykmfa8hZvSdoPd5gHdLiQcMB/pxq+mWp1fI6c8vFZoDu7Atn+NXTzYPKUxKzaisF12TsaKpohUsJpbB3Wocb0F5frn614D2pg14ERB5otjAMWw1m65csQWPI6dP8KIYe0+QPkCAwEAAaMmMCQwIgYDVR0lAQH/BBgwFgYIKwYBBQUHAwIGCisGAQQBgjcKAwwwDQYJKoZIhvcNAQENBQADggEBAA4RhVIBkw34M1RwakJgHvtjsOFxF1tVQA941NtLokx1l2Z8+GFQkcG4xpZSt+UN6wLerdCbnNhtkCErWUDeaT0jxk4g71Ofex7iM04crT4iHJr8mi96/XnhnkTUs+GDk12VgdeeNEczMZz+8Mxw9dJ5NCnYgTwO0SzGlclRsDvjzkLo8rh2ZG6n/jKrEyNXXo+hOqhupij0QbRP2Tvexdfw201kgN1jdZify8XzJ8Oi0bTS0KpJf2pNPOlooK2bjMUei9ANtEdXwwfVZGWvVh6tJjdv6k14wWWJ1L7zhA1IIVb1J+sQUzJji5iX0DrezjTz1Fg+gAzITaA/WsuujlM=\""), }; await storageSyncRegisteredServer.TriggerRolloverAsync(WaitUntil.Completed, content); diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServerEndpointCollection.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServerEndpointCollection.cs index 1407adbf6673e..c38a9ec8557af 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServerEndpointCollection.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServerEndpointCollection.cs @@ -42,7 +42,7 @@ public async Task CreateOrUpdate_ServerEndpointsCreate() // invoke the operation string serverEndpointName = "SampleServerEndpoint_1"; - StorageSyncServerEndpointCreateOrUpdateContent content = new StorageSyncServerEndpointCreateOrUpdateContent() + StorageSyncServerEndpointCreateOrUpdateContent content = new StorageSyncServerEndpointCreateOrUpdateContent { ServerLocalPath = "D:\\SampleServerEndpoint_1", CloudTiering = StorageSyncFeatureStatus.Off, @@ -102,10 +102,10 @@ public async Task Get_ServerEndpointsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServerEndpointsGet() + public async Task GetAll_ServerEndpointsListBySyncGroup() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_Get.json - // this example is just showing the usage of "ServerEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_ListBySyncGroup.json + // this example is just showing the usage of "ServerEndpoints_ListBySyncGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -124,16 +124,22 @@ public async Task Exists_ServerEndpointsGet() // get the collection of this StorageSyncServerEndpointResource StorageSyncServerEndpointCollection collection = storageSyncGroup.GetStorageSyncServerEndpoints(); - // invoke the operation - string serverEndpointName = "SampleServerEndpoint_1"; - bool result = await collection.ExistsAsync(serverEndpointName); + // invoke the operation and iterate over the result + await foreach (StorageSyncServerEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncServerEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServerEndpointsGet() + public async Task Exists_ServerEndpointsGet() { // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_Get.json // this example is just showing the usage of "ServerEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -157,29 +163,17 @@ public async Task GetIfExists_ServerEndpointsGet() // invoke the operation string serverEndpointName = "SampleServerEndpoint_1"; - NullableResponse response = await collection.GetIfExistsAsync(serverEndpointName); - StorageSyncServerEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serverEndpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncServerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServerEndpointsListBySyncGroup() + public async Task GetIfExists_ServerEndpointsGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_ListBySyncGroup.json - // this example is just showing the usage of "ServerEndpoints_ListBySyncGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_Get.json + // this example is just showing the usage of "ServerEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,17 +192,23 @@ public async Task GetAll_ServerEndpointsListBySyncGroup() // get the collection of this StorageSyncServerEndpointResource StorageSyncServerEndpointCollection collection = storageSyncGroup.GetStorageSyncServerEndpoints(); - // invoke the operation and iterate over the result - await foreach (StorageSyncServerEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string serverEndpointName = "SampleServerEndpoint_1"; + NullableResponse response = await collection.GetIfExistsAsync(serverEndpointName); + StorageSyncServerEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageSyncServerEndpointData resourceData = item.Data; + StorageSyncServerEndpointData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServerEndpointResource.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServerEndpointResource.cs index a02ae725914cf..6fb23b5fc6e92 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServerEndpointResource.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServerEndpointResource.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageSyncServerEndpointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ServerEndpointsUpdate() + public async Task Get_ServerEndpointsGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_Update.json - // this example is just showing the usage of "ServerEndpoints_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_Get.json + // this example is just showing the usage of "ServerEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,16 +39,7 @@ public async Task Update_ServerEndpointsUpdate() StorageSyncServerEndpointResource storageSyncServerEndpoint = client.GetStorageSyncServerEndpointResource(storageSyncServerEndpointResourceId); // invoke the operation - StorageSyncServerEndpointPatch patch = new StorageSyncServerEndpointPatch() - { - CloudTiering = StorageSyncFeatureStatus.Off, - VolumeFreeSpacePercent = 100, - TierFilesOlderThanDays = 0, - OfflineDataTransfer = StorageSyncFeatureStatus.Off, - LocalCacheMode = LocalCacheMode.UpdateLocallyCachedFiles, - }; - ArmOperation lro = await storageSyncServerEndpoint.UpdateAsync(WaitUntil.Completed, patch); - StorageSyncServerEndpointResource result = lro.Value; + StorageSyncServerEndpointResource result = await storageSyncServerEndpoint.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -59,10 +50,10 @@ public async Task Update_ServerEndpointsUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ServerEndpointsGet() + public async Task Delete_ServerEndpointsDelete() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_Get.json - // this example is just showing the usage of "ServerEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_Delete.json + // this example is just showing the usage of "ServerEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,21 +71,17 @@ public async Task Get_ServerEndpointsGet() StorageSyncServerEndpointResource storageSyncServerEndpoint = client.GetStorageSyncServerEndpointResource(storageSyncServerEndpointResourceId); // invoke the operation - StorageSyncServerEndpointResource result = await storageSyncServerEndpoint.GetAsync(); + await storageSyncServerEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncServerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ServerEndpointsDelete() + public async Task Update_ServerEndpointsUpdate() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_Delete.json - // this example is just showing the usage of "ServerEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/ServerEndpoints_Update.json + // this example is just showing the usage of "ServerEndpoints_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,9 +99,22 @@ public async Task Delete_ServerEndpointsDelete() StorageSyncServerEndpointResource storageSyncServerEndpoint = client.GetStorageSyncServerEndpointResource(storageSyncServerEndpointResourceId); // invoke the operation - await storageSyncServerEndpoint.DeleteAsync(WaitUntil.Completed); + StorageSyncServerEndpointPatch patch = new StorageSyncServerEndpointPatch + { + CloudTiering = StorageSyncFeatureStatus.Off, + VolumeFreeSpacePercent = 100, + TierFilesOlderThanDays = 0, + OfflineDataTransfer = StorageSyncFeatureStatus.Off, + LocalCacheMode = LocalCacheMode.UpdateLocallyCachedFiles, + }; + ArmOperation lro = await storageSyncServerEndpoint.UpdateAsync(WaitUntil.Completed, patch); + StorageSyncServerEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncServerEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -140,7 +140,7 @@ public async Task RecallAction_ServerEndpointsRecallAction() StorageSyncServerEndpointResource storageSyncServerEndpoint = client.GetStorageSyncServerEndpointResource(storageSyncServerEndpointResourceId); // invoke the operation - RecallActionContent content = new RecallActionContent() + RecallActionContent content = new RecallActionContent { Pattern = "", RecallPath = "", diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServiceCollection.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServiceCollection.cs index 6d9d81c245cf1..26fe7f6363e8f 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServiceCollection.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServiceCollection.cs @@ -43,9 +43,7 @@ public async Task CreateOrUpdate_StorageSyncServicesCreate() string storageSyncServiceName = "SampleStorageSyncService_1"; StorageSyncServiceCreateOrUpdateContent content = new StorageSyncServiceCreateOrUpdateContent(new AzureLocation("WestUS")) { - Tags = -{ -}, + Tags = { }, IncomingTrafficPolicy = IncomingTrafficPolicy.AllowAllTraffic, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageSyncServiceName, content); @@ -93,10 +91,10 @@ public async Task Get_StorageSyncServicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageSyncServicesGet() + public async Task GetAll_StorageSyncServicesListByResourceGroup() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_Get.json - // this example is just showing the usage of "StorageSyncServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_ListByResourceGroup.json + // this example is just showing the usage of "StorageSyncServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +111,22 @@ public async Task Exists_StorageSyncServicesGet() // get the collection of this StorageSyncServiceResource StorageSyncServiceCollection collection = resourceGroupResource.GetStorageSyncServices(); - // invoke the operation - string storageSyncServiceName = "SampleStorageSyncService_1"; - bool result = await collection.ExistsAsync(storageSyncServiceName); + // invoke the operation and iterate over the result + await foreach (StorageSyncServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageSyncServicesGet() + public async Task Exists_StorageSyncServicesGet() { // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_Get.json // this example is just showing the usage of "StorageSyncServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +148,17 @@ public async Task GetIfExists_StorageSyncServicesGet() // invoke the operation string storageSyncServiceName = "SampleStorageSyncService_1"; - NullableResponse response = await collection.GetIfExistsAsync(storageSyncServiceName); - StorageSyncServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(storageSyncServiceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StorageSyncServicesListByResourceGroup() + public async Task GetIfExists_StorageSyncServicesGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_ListByResourceGroup.json - // this example is just showing the usage of "StorageSyncServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_Get.json + // this example is just showing the usage of "StorageSyncServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +175,23 @@ public async Task GetAll_StorageSyncServicesListByResourceGroup() // get the collection of this StorageSyncServiceResource StorageSyncServiceCollection collection = resourceGroupResource.GetStorageSyncServices(); - // invoke the operation and iterate over the result - await foreach (StorageSyncServiceResource item in collection.GetAllAsync()) + // invoke the operation + string storageSyncServiceName = "SampleStorageSyncService_1"; + NullableResponse response = await collection.GetIfExistsAsync(storageSyncServiceName); + StorageSyncServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageSyncServiceData resourceData = item.Data; + StorageSyncServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServiceResource.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServiceResource.cs index 1ed0211181f73..5f12d42c24a9c 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServiceResource.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncServiceResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.StorageSync.Models; using NUnit.Framework; @@ -17,58 +16,6 @@ namespace Azure.ResourceManager.StorageSync.Samples { public partial class Sample_StorageSyncServiceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckStorageSyncNameAvailability_StorageSyncServiceCheckNameAvailabilityAlreadyExists() - { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServiceCheckNameAvailability_AlreadyExists.json - // this example is just showing the usage of "StorageSyncServices_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5c6bc8e1-1eaf-4192-94d8-58ce463ac86c"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - string locationName = "westus"; - StorageSyncNameAvailabilityContent content = new StorageSyncNameAvailabilityContent("newstoragesyncservicename"); - StorageSyncNameAvailabilityResult result = await subscriptionResource.CheckStorageSyncNameAvailabilityAsync(locationName, content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckStorageSyncNameAvailability_StorageSyncServiceCheckNameAvailabilityAvailable() - { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServiceCheckNameAvailability_Available.json - // this example is just showing the usage of "StorageSyncServices_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5c6bc8e1-1eaf-4192-94d8-58ce463ac86c"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - string locationName = "westus"; - StorageSyncNameAvailabilityContent content = new StorageSyncNameAvailabilityContent("newstoragesyncservicename"); - StorageSyncNameAvailabilityResult result = await subscriptionResource.CheckStorageSyncNameAvailabilityAsync(locationName, content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_StorageSyncServicesGet() @@ -101,10 +48,10 @@ public async Task Get_StorageSyncServicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_StorageSyncServicesUpdate() + public async Task Delete_StorageSyncServicesDelete() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_Update.json - // this example is just showing the usage of "StorageSyncServices_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_Delete.json + // this example is just showing the usage of "StorageSyncServices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,31 +67,17 @@ public async Task Update_StorageSyncServicesUpdate() StorageSyncServiceResource storageSyncService = client.GetStorageSyncServiceResource(storageSyncServiceResourceId); // invoke the operation - StorageSyncServicePatch patch = new StorageSyncServicePatch() - { - Tags = -{ -["Dept"] = "IT", -["Environment"] = "Test", -}, - IncomingTrafficPolicy = IncomingTrafficPolicy.AllowAllTraffic, - }; - ArmOperation lro = await storageSyncService.UpdateAsync(WaitUntil.Completed, patch); - StorageSyncServiceResource result = lro.Value; + await storageSyncService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_StorageSyncServicesDelete() + public async Task Update_StorageSyncServicesUpdate() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_Delete.json - // this example is just showing the usage of "StorageSyncServices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_Update.json + // this example is just showing the usage of "StorageSyncServices_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -160,40 +93,23 @@ public async Task Delete_StorageSyncServicesDelete() StorageSyncServiceResource storageSyncService = client.GetStorageSyncServiceResource(storageSyncServiceResourceId); // invoke the operation - await storageSyncService.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetStorageSyncServices_StorageSyncServicesListBySubscription() - { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_ListBySubscription.json - // this example is just showing the usage of "StorageSyncServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "52b8da2f-61e0-4a1f-8dde-336911f367fb"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (StorageSyncServiceResource item in subscriptionResource.GetStorageSyncServicesAsync()) + StorageSyncServicePatch patch = new StorageSyncServicePatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["Dept"] = "IT", +["Environment"] = "Test" +}, + IncomingTrafficPolicy = IncomingTrafficPolicy.AllowAllTraffic, + }; + ArmOperation lro = await storageSyncService.UpdateAsync(WaitUntil.Completed, patch); + StorageSyncServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncWorkflowCollection.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncWorkflowCollection.cs index 30832f0a8a0b8..13dc992c6c098 100644 --- a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncWorkflowCollection.cs +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_StorageSyncWorkflowCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_StorageSyncWorkflowCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkflowsListByStorageSyncService() + public async Task Get_WorkflowsGet() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/Workflows_ListByStorageSyncService.json - // this example is just showing the usage of "Workflows_ListByStorageSyncService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/Workflows_Get.json + // this example is just showing the usage of "Workflows_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_WorkflowsListByStorageSyncService() // get the collection of this StorageSyncWorkflowResource StorageSyncWorkflowCollection collection = storageSyncService.GetStorageSyncWorkflows(); - // invoke the operation and iterate over the result - await foreach (StorageSyncWorkflowResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncWorkflowData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string workflowId = "828219ea-083e-48b5-89ea-8fd9991b2e75"; + StorageSyncWorkflowResource result = await collection.GetAsync(workflowId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncWorkflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkflowsGet() + public async Task GetAll_WorkflowsListByStorageSyncService() { - // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/Workflows_Get.json - // this example is just showing the usage of "Workflows_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/Workflows_ListByStorageSyncService.json + // this example is just showing the usage of "Workflows_ListByStorageSyncService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_WorkflowsGet() // get the collection of this StorageSyncWorkflowResource StorageSyncWorkflowCollection collection = storageSyncService.GetStorageSyncWorkflows(); - // invoke the operation - string workflowId = "828219ea-083e-48b5-89ea-8fd9991b2e75"; - StorageSyncWorkflowResource result = await collection.GetAsync(workflowId); + // invoke the operation and iterate over the result + await foreach (StorageSyncWorkflowResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncWorkflowData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageSyncWorkflowData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..ae39faa293078 --- /dev/null +++ b/sdk/storagesync/Azure.ResourceManager.StorageSync/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,103 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.StorageSync.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.StorageSync.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckStorageSyncNameAvailability_StorageSyncServiceCheckNameAvailabilityAlreadyExists() + { + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServiceCheckNameAvailability_AlreadyExists.json + // this example is just showing the usage of "StorageSyncServices_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5c6bc8e1-1eaf-4192-94d8-58ce463ac86c"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + string locationName = "westus"; + StorageSyncNameAvailabilityContent content = new StorageSyncNameAvailabilityContent("newstoragesyncservicename"); + StorageSyncNameAvailabilityResult result = await subscriptionResource.CheckStorageSyncNameAvailabilityAsync(locationName, content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckStorageSyncNameAvailability_StorageSyncServiceCheckNameAvailabilityAvailable() + { + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServiceCheckNameAvailability_Available.json + // this example is just showing the usage of "StorageSyncServices_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5c6bc8e1-1eaf-4192-94d8-58ce463ac86c"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + string locationName = "westus"; + StorageSyncNameAvailabilityContent content = new StorageSyncNameAvailabilityContent("newstoragesyncservicename"); + StorageSyncNameAvailabilityResult result = await subscriptionResource.CheckStorageSyncNameAvailabilityAsync(locationName, content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStorageSyncServices_StorageSyncServicesListBySubscription() + { + // Generated from example definition: specification/storagesync/resource-manager/Microsoft.StorageSync/stable/2022-06-01/examples/StorageSyncServices_ListBySubscription.json + // this example is just showing the usage of "StorageSyncServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "52b8da2f-61e0-4a1f-8dde-336911f367fb"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (StorageSyncServiceResource item in subscriptionResource.GetStorageSyncServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageSyncServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsClusterCollection.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsClusterCollection.cs index 3b16bb46e8cb8..03fe14d7e7f0a 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsClusterCollection.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsClusterCollection.cs @@ -43,14 +43,14 @@ public async Task CreateOrUpdate_CreateANewCluster() string clusterName = "An Example Cluster"; StreamAnalyticsClusterData data = new StreamAnalyticsClusterData(new AzureLocation("North US")) { - Sku = new StreamAnalyticsClusterSku() + Sku = new StreamAnalyticsClusterSku { Name = StreamAnalyticsClusterSkuName.Default, Capacity = 48, }, Tags = { -["key"] = "value", +["key"] = "value" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); @@ -98,10 +98,10 @@ public async Task Get_GetACluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACluster() + public async Task GetAll_ListClustersInResourceGroup() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/Cluster_Get.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/Cluster_ListByResourceGroup.json + // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +118,22 @@ public async Task Exists_GetACluster() // get the collection of this StreamAnalyticsClusterResource StreamAnalyticsClusterCollection collection = resourceGroupResource.GetStreamAnalyticsClusters(); - // invoke the operation - string clusterName = "testcluster"; - bool result = await collection.ExistsAsync(clusterName); + // invoke the operation and iterate over the result + await foreach (StreamAnalyticsClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamAnalyticsClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACluster() + public async Task Exists_GetACluster() { // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/Cluster_Get.json // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +155,17 @@ public async Task GetIfExists_GetACluster() // invoke the operation string clusterName = "testcluster"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - StreamAnalyticsClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamAnalyticsClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListClustersInResourceGroup() + public async Task GetIfExists_GetACluster() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/Cluster_ListByResourceGroup.json - // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/Cluster_Get.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_ListClustersInResourceGroup() // get the collection of this StreamAnalyticsClusterResource StreamAnalyticsClusterCollection collection = resourceGroupResource.GetStreamAnalyticsClusters(); - // invoke the operation and iterate over the result - await foreach (StreamAnalyticsClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "testcluster"; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + StreamAnalyticsClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamAnalyticsClusterData resourceData = item.Data; + StreamAnalyticsClusterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsClusterResource.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsClusterResource.cs index dd0f26ac9c586..b3de70fead83b 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsClusterResource.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsClusterResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.StreamAnalytics.Models; using NUnit.Framework; @@ -17,44 +16,6 @@ namespace Azure.ResourceManager.StreamAnalytics.Samples { public partial class Sample_StreamAnalyticsClusterResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateACluster() - { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/Cluster_Update.json - // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this StreamAnalyticsClusterResource created on azure - // for more information of creating StreamAnalyticsClusterResource, please refer to the document of StreamAnalyticsClusterResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "sjrg"; - string clusterName = "testcluster"; - ResourceIdentifier streamAnalyticsClusterResourceId = StreamAnalyticsClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - StreamAnalyticsClusterResource streamAnalyticsCluster = client.GetStreamAnalyticsClusterResource(streamAnalyticsClusterResourceId); - - // invoke the operation - StreamAnalyticsClusterData data = new StreamAnalyticsClusterData(new AzureLocation("Central US")) - { - Sku = new StreamAnalyticsClusterSku() - { - Capacity = 96, - }, - }; - ArmOperation lro = await streamAnalyticsCluster.UpdateAsync(WaitUntil.Completed, data); - StreamAnalyticsClusterResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamAnalyticsClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetACluster() @@ -113,33 +74,40 @@ public async Task Delete_DeleteACluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetStreamAnalyticsClusters_ListTheClustersInASubscription() + public async Task Update_UpdateACluster() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/Cluster_ListBySubscription.json - // this example is just showing the usage of "Clusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/Cluster_Update.json + // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this StreamAnalyticsClusterResource created on azure + // for more information of creating StreamAnalyticsClusterResource, please refer to the document of StreamAnalyticsClusterResource string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "sjrg"; + string clusterName = "testcluster"; + ResourceIdentifier streamAnalyticsClusterResourceId = StreamAnalyticsClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + StreamAnalyticsClusterResource streamAnalyticsCluster = client.GetStreamAnalyticsClusterResource(streamAnalyticsClusterResourceId); - // invoke the operation and iterate over the result - await foreach (StreamAnalyticsClusterResource item in subscriptionResource.GetStreamAnalyticsClustersAsync()) + // invoke the operation + StreamAnalyticsClusterData data = new StreamAnalyticsClusterData(new AzureLocation("Central US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamAnalyticsClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new StreamAnalyticsClusterSku + { + Capacity = 96, + }, + }; + ArmOperation lro = await streamAnalyticsCluster.UpdateAsync(WaitUntil.Completed, data); + StreamAnalyticsClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamAnalyticsClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsPrivateEndpointCollection.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsPrivateEndpointCollection.cs index c99e5d64945d2..018dc343e42b6 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsPrivateEndpointCollection.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsPrivateEndpointCollection.cs @@ -41,21 +41,15 @@ public async Task CreateOrUpdate_CreateAPrivateEndpoint() // invoke the operation string privateEndpointName = "testpe"; - StreamAnalyticsPrivateEndpointData data = new StreamAnalyticsPrivateEndpointData() + StreamAnalyticsPrivateEndpointData data = new StreamAnalyticsPrivateEndpointData { - Properties = new StreamAnalyticsPrivateEndpointProperties() + Properties = new StreamAnalyticsPrivateEndpointProperties { - ManualPrivateLinkServiceConnections = -{ -new StreamAnalyticsPrivateLinkServiceConnection() + ManualPrivateLinkServiceConnections = {new StreamAnalyticsPrivateLinkServiceConnection { PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), -GroupIds = -{ -"groupIdFromResource" -}, -} -}, +GroupIds = {"groupIdFromResource"}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointName, data); @@ -104,10 +98,10 @@ public async Task Get_GetAPrivateEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPrivateEndpoint() + public async Task GetAll_GetThePrivateEndpointsInACluster() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_Get.json - // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_ListByCluster.json + // this example is just showing the usage of "PrivateEndpoints_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,16 +119,22 @@ public async Task Exists_GetAPrivateEndpoint() // get the collection of this StreamAnalyticsPrivateEndpointResource StreamAnalyticsPrivateEndpointCollection collection = streamAnalyticsCluster.GetStreamAnalyticsPrivateEndpoints(); - // invoke the operation - string privateEndpointName = "testpe"; - bool result = await collection.ExistsAsync(privateEndpointName); + // invoke the operation and iterate over the result + await foreach (StreamAnalyticsPrivateEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamAnalyticsPrivateEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPrivateEndpoint() + public async Task Exists_GetAPrivateEndpoint() { // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_Get.json // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -157,29 +157,17 @@ public async Task GetIfExists_GetAPrivateEndpoint() // invoke the operation string privateEndpointName = "testpe"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointName); - StreamAnalyticsPrivateEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamAnalyticsPrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetThePrivateEndpointsInACluster() + public async Task GetIfExists_GetAPrivateEndpoint() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_ListByCluster.json - // this example is just showing the usage of "PrivateEndpoints_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_Get.json + // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -197,17 +185,23 @@ public async Task GetAll_GetThePrivateEndpointsInACluster() // get the collection of this StreamAnalyticsPrivateEndpointResource StreamAnalyticsPrivateEndpointCollection collection = streamAnalyticsCluster.GetStreamAnalyticsPrivateEndpoints(); - // invoke the operation and iterate over the result - await foreach (StreamAnalyticsPrivateEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointName = "testpe"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointName); + StreamAnalyticsPrivateEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamAnalyticsPrivateEndpointData resourceData = item.Data; + StreamAnalyticsPrivateEndpointData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsPrivateEndpointResource.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsPrivateEndpointResource.cs index 484d60eb69177..4747dc49a7bdb 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsPrivateEndpointResource.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamAnalyticsPrivateEndpointResource.cs @@ -18,10 +18,10 @@ public partial class Sample_StreamAnalyticsPrivateEndpointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAPrivateEndpoint() + public async Task Get_GetAPrivateEndpoint() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_Create.json - // this example is just showing the usage of "PrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_Get.json + // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,7 @@ public async Task Update_CreateAPrivateEndpoint() StreamAnalyticsPrivateEndpointResource streamAnalyticsPrivateEndpoint = client.GetStreamAnalyticsPrivateEndpointResource(streamAnalyticsPrivateEndpointResourceId); // invoke the operation - StreamAnalyticsPrivateEndpointData data = new StreamAnalyticsPrivateEndpointData() - { - Properties = new StreamAnalyticsPrivateEndpointProperties() - { - ManualPrivateLinkServiceConnections = -{ -new StreamAnalyticsPrivateLinkServiceConnection() -{ -PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), -GroupIds = -{ -"groupIdFromResource" -}, -} -}, - }, - }; - ArmOperation lro = await streamAnalyticsPrivateEndpoint.UpdateAsync(WaitUntil.Completed, data); - StreamAnalyticsPrivateEndpointResource result = lro.Value; + StreamAnalyticsPrivateEndpointResource result = await streamAnalyticsPrivateEndpoint.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -67,10 +49,10 @@ public async Task Update_CreateAPrivateEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPrivateEndpoint() + public async Task Delete_DeleteAPrivateEndpoint() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_Get.json - // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_Delete.json + // this example is just showing the usage of "PrivateEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -87,21 +69,17 @@ public async Task Get_GetAPrivateEndpoint() StreamAnalyticsPrivateEndpointResource streamAnalyticsPrivateEndpoint = client.GetStreamAnalyticsPrivateEndpointResource(streamAnalyticsPrivateEndpointResourceId); // invoke the operation - StreamAnalyticsPrivateEndpointResource result = await streamAnalyticsPrivateEndpoint.GetAsync(); + await streamAnalyticsPrivateEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamAnalyticsPrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPrivateEndpoint() + public async Task Update_CreateAPrivateEndpoint() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_Delete.json - // this example is just showing the usage of "PrivateEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/PrivateEndpoint_Create.json + // this example is just showing the usage of "PrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,9 +96,25 @@ public async Task Delete_DeleteAPrivateEndpoint() StreamAnalyticsPrivateEndpointResource streamAnalyticsPrivateEndpoint = client.GetStreamAnalyticsPrivateEndpointResource(streamAnalyticsPrivateEndpointResourceId); // invoke the operation - await streamAnalyticsPrivateEndpoint.DeleteAsync(WaitUntil.Completed); + StreamAnalyticsPrivateEndpointData data = new StreamAnalyticsPrivateEndpointData + { + Properties = new StreamAnalyticsPrivateEndpointProperties + { + ManualPrivateLinkServiceConnections = {new StreamAnalyticsPrivateLinkServiceConnection +{ +PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), +GroupIds = {"groupIdFromResource"}, +}}, + }, + }; + ArmOperation lro = await streamAnalyticsPrivateEndpoint.UpdateAsync(WaitUntil.Completed, data); + StreamAnalyticsPrivateEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamAnalyticsPrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobCollection.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobCollection.cs index db6ef4fca04da..ea50323b45905 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobCollection.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobCollection.cs @@ -50,44 +50,36 @@ public async Task CreateOrUpdate_CreateACompleteStreamingJobAStreamingJobWithATr EventsLateArrivalMaxDelayInSeconds = 5, DataLocalion = new AzureLocation("en-US"), CompatibilityLevel = StreamingJobCompatibilityLevel.Level1_0, - Inputs = + Inputs = {new StreamingJobInputData { -new StreamingJobInputData() +Properties = new StreamInputProperties { -Properties = new StreamInputProperties() +Datasource = new BlobStreamInputDataSource { -Datasource = new BlobStreamInputDataSource() -{ -StorageAccounts = -{ -new StreamAnalyticsStorageAccount() +StorageAccounts = {new StreamAnalyticsStorageAccount { AccountName = "yourAccountName", AccountKey = "yourAccountKey==", -} -}, +}}, Container = "containerName", PathPattern = "", }, -Serialization = new JsonFormatSerialization() +Serialization = new JsonFormatSerialization { Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, }, }, Name = "inputtest", -} -}, - Transformation = new StreamingJobTransformationData() +}}, + Transformation = new StreamingJobTransformationData { StreamingUnits = 1, Query = "Select Id, Name from inputtest", Name = "transformationtest", }, - Outputs = -{ -new StreamingJobOutputData() + Outputs = {new StreamingJobOutputData { -Datasource = new SqlDatabaseOutputDataSource() +Datasource = new SqlDatabaseOutputDataSource { Server = "serverName", Database = "databaseName", @@ -96,21 +88,18 @@ public async Task CreateOrUpdate_CreateACompleteStreamingJobAStreamingJobWithATr Table = "tableName", }, Name = "outputtest", -} -}, - Functions = -{ -}, - Externals = new StreamingJobExternal() +}}, + Functions = { }, + Externals = new StreamingJobExternal { - StorageAccount = new StreamAnalyticsStorageAccount() + StorageAccount = new StreamAnalyticsStorageAccount { AccountName = "mystorageaccount", AccountKey = "mykey", }, Container = "mycontainer", Path = "UserCustomCode.zip", - RefreshConfiguration = new StreamingJobRefreshConfiguration() + RefreshConfiguration = new StreamingJobRefreshConfiguration { PathPattern = "{date}\\\\{time}", DateFormat = "yyyy-dd-MM", @@ -123,7 +112,7 @@ public async Task CreateOrUpdate_CreateACompleteStreamingJobAStreamingJobWithATr { ["key1"] = "value1", ["key3"] = "value3", -["randomKey"] = "randomValue", +["randomKey"] = "randomValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); @@ -169,20 +158,14 @@ public async Task CreateOrUpdate_CreateAStreamingJobShellAStreamingJobWithNoInpu EventsLateArrivalMaxDelayInSeconds = 16, DataLocalion = new AzureLocation("en-US"), CompatibilityLevel = StreamingJobCompatibilityLevel.Level1_0, - Inputs = -{ -}, - Outputs = -{ -}, - Functions = -{ -}, + Inputs = { }, + Outputs = { }, + Functions = { }, Tags = { ["key1"] = "value1", ["key3"] = "value3", -["randomKey"] = "randomValue", +["randomKey"] = "randomValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); @@ -230,9 +213,9 @@ public async Task Get_GetAStreamingJobAndDoNotUseTheExpandODataQueryParameter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAStreamingJobAndDoNotUseTheExpandODataQueryParameter() + public async Task Get_GetAStreamingJobAndUseTheExpandODataQueryParameterToExpandInputsOutputsTransformationAndFunctions() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Get_NoExpand.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Get_Expand.json // this example is just showing the usage of "StreamingJobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -243,7 +226,7 @@ public async Task Exists_GetAStreamingJobAndDoNotUseTheExpandODataQueryParameter // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6936"; + string resourceGroupName = "sjrg3276"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -251,18 +234,23 @@ public async Task Exists_GetAStreamingJobAndDoNotUseTheExpandODataQueryParameter StreamingJobCollection collection = resourceGroupResource.GetStreamingJobs(); // invoke the operation - string jobName = "sj59"; - bool result = await collection.ExistsAsync(jobName); + string jobName = "sj7804"; + string expand = "inputs,outputs,transformation,functions"; + StreamingJobResource result = await collection.GetAsync(jobName, expand: expand); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAStreamingJobAndDoNotUseTheExpandODataQueryParameter() + public async Task GetAll_ListAllStreamingJobsInAResourceGroupAndDoNotUseTheExpandODataQueryParameter() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Get_NoExpand.json - // this example is just showing the usage of "StreamingJobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_List_ByResourceGroup_NoExpand.json + // this example is just showing the usage of "StreamingJobs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -279,31 +267,25 @@ public async Task GetIfExists_GetAStreamingJobAndDoNotUseTheExpandODataQueryPara // get the collection of this StreamingJobResource StreamingJobCollection collection = resourceGroupResource.GetStreamingJobs(); - // invoke the operation - string jobName = "sj59"; - NullableResponse response = await collection.GetIfExistsAsync(jobName); - StreamingJobResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (StreamingJobResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamingJobData resourceData = result.Data; + StreamingJobData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAStreamingJobAndUseTheExpandODataQueryParameterToExpandInputsOutputsTransformationAndFunctions() + public async Task GetAll_ListAllStreamingJobsInAResourceGroupAndUseTheExpandODataQueryParameterToExpandInputsOutputsTransformationAndFunctions() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Get_Expand.json - // this example is just showing the usage of "StreamingJobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_List_ByResourceGroup_Expand.json + // this example is just showing the usage of "StreamingJobs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -320,23 +302,25 @@ public async Task Get_GetAStreamingJobAndUseTheExpandODataQueryParameterToExpand // get the collection of this StreamingJobResource StreamingJobCollection collection = resourceGroupResource.GetStreamingJobs(); - // invoke the operation - string jobName = "sj7804"; + // invoke the operation and iterate over the result string expand = "inputs,outputs,transformation,functions"; - StreamingJobResource result = await collection.GetAsync(jobName, expand: expand); + await foreach (StreamingJobResource item in collection.GetAllAsync(expand: expand)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAStreamingJobAndUseTheExpandODataQueryParameterToExpandInputsOutputsTransformationAndFunctions() + public async Task Exists_GetAStreamingJobAndDoNotUseTheExpandODataQueryParameter() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Get_Expand.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Get_NoExpand.json // this example is just showing the usage of "StreamingJobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -347,7 +331,7 @@ public async Task Exists_GetAStreamingJobAndUseTheExpandODataQueryParameterToExp // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg3276"; + string resourceGroupName = "sjrg6936"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -355,16 +339,15 @@ public async Task Exists_GetAStreamingJobAndUseTheExpandODataQueryParameterToExp StreamingJobCollection collection = resourceGroupResource.GetStreamingJobs(); // invoke the operation - string jobName = "sj7804"; - string expand = "inputs,outputs,transformation,functions"; - bool result = await collection.ExistsAsync(jobName, expand: expand); + string jobName = "sj59"; + bool result = await collection.ExistsAsync(jobName); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAStreamingJobAndUseTheExpandODataQueryParameterToExpandInputsOutputsTransformationAndFunctions() + public async Task Exists_GetAStreamingJobAndUseTheExpandODataQueryParameterToExpandInputsOutputsTransformationAndFunctions() { // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Get_Expand.json // this example is just showing the usage of "StreamingJobs_Get" operation, for the dependent resources, they will have to be created separately. @@ -387,29 +370,17 @@ public async Task GetIfExists_GetAStreamingJobAndUseTheExpandODataQueryParameter // invoke the operation string jobName = "sj7804"; string expand = "inputs,outputs,transformation,functions"; - NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); - StreamingJobResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(jobName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllStreamingJobsInAResourceGroupAndDoNotUseTheExpandODataQueryParameter() + public async Task GetIfExists_GetAStreamingJobAndDoNotUseTheExpandODataQueryParameter() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_List_ByResourceGroup_NoExpand.json - // this example is just showing the usage of "StreamingJobs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Get_NoExpand.json + // this example is just showing the usage of "StreamingJobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -426,25 +397,31 @@ public async Task GetAll_ListAllStreamingJobsInAResourceGroupAndDoNotUseTheExpan // get the collection of this StreamingJobResource StreamingJobCollection collection = resourceGroupResource.GetStreamingJobs(); - // invoke the operation and iterate over the result - await foreach (StreamingJobResource item in collection.GetAllAsync()) + // invoke the operation + string jobName = "sj59"; + NullableResponse response = await collection.GetIfExistsAsync(jobName); + StreamingJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamingJobData resourceData = item.Data; + StreamingJobData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllStreamingJobsInAResourceGroupAndUseTheExpandODataQueryParameterToExpandInputsOutputsTransformationAndFunctions() + public async Task GetIfExists_GetAStreamingJobAndUseTheExpandODataQueryParameterToExpandInputsOutputsTransformationAndFunctions() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_List_ByResourceGroup_Expand.json - // this example is just showing the usage of "StreamingJobs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Get_Expand.json + // this example is just showing the usage of "StreamingJobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -461,18 +438,24 @@ public async Task GetAll_ListAllStreamingJobsInAResourceGroupAndUseTheExpandODat // get the collection of this StreamingJobResource StreamingJobCollection collection = resourceGroupResource.GetStreamingJobs(); - // invoke the operation and iterate over the result + // invoke the operation + string jobName = "sj7804"; string expand = "inputs,outputs,transformation,functions"; - await foreach (StreamingJobResource item in collection.GetAllAsync(expand: expand)) + NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); + StreamingJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamingJobData resourceData = item.Data; + StreamingJobData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobFunctionCollection.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobFunctionCollection.cs index 18efa5af42a09..8309eb5f47881 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobFunctionCollection.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobFunctionCollection.cs @@ -41,19 +41,16 @@ public async Task CreateOrUpdate_CreateACLRUdfFunction() // invoke the operation string functionName = "function588"; - StreamingJobFunctionData data = new StreamingJobFunctionData() + StreamingJobFunctionData data = new StreamingJobFunctionData { - Properties = new ScalarFunctionProperties() + Properties = new ScalarFunctionProperties { - Inputs = -{ -new StreamingJobFunctionInput() + Inputs = {new StreamingJobFunctionInput { DataType = "nvarchar(max)", -} -}, +}}, OutputDataType = "nvarchar(max)", - Binding = new CSharpFunctionBinding() + Binding = new CSharpFunctionBinding { DllPath = "ASAEdgeApplication2_CodeBehind", Class = "ASAEdgeUDFDemo.Class1", @@ -97,19 +94,16 @@ public async Task CreateOrUpdate_CreateAJavaScriptFunction() // invoke the operation string functionName = "function8197"; - StreamingJobFunctionData data = new StreamingJobFunctionData() + StreamingJobFunctionData data = new StreamingJobFunctionData { - Properties = new ScalarFunctionProperties() + Properties = new ScalarFunctionProperties { - Inputs = -{ -new StreamingJobFunctionInput() + Inputs = {new StreamingJobFunctionInput { DataType = "Any", -} -}, +}}, OutputDataType = "Any", - Binding = new JavaScriptFunctionBinding() + Binding = new JavaScriptFunctionBinding { Script = "function (x, y) { return x + y; }", }, @@ -150,39 +144,30 @@ public async Task CreateOrUpdate_CreateAnAzureMLServiceFunction() // invoke the operation string functionName = "function588"; - StreamingJobFunctionData data = new StreamingJobFunctionData() + StreamingJobFunctionData data = new StreamingJobFunctionData { - Properties = new ScalarFunctionProperties() + Properties = new ScalarFunctionProperties { - Inputs = -{ -new StreamingJobFunctionInput() + Inputs = {new StreamingJobFunctionInput { DataType = "nvarchar(max)", -} -}, +}}, OutputDataType = "nvarchar(max)", - Binding = new MachineLearningServiceFunctionBinding() + Binding = new MachineLearningServiceFunctionBinding { Endpoint = "someAzureMLEndpointURL", ApiKey = "someApiKey==", - Inputs = -{ -new MachineLearningServiceInputColumn() + Inputs = {new MachineLearningServiceInputColumn { Name = "data", DataType = "array", MapTo = 0, -} -}, - Outputs = -{ -new MachineLearningServiceOutputColumn() +}}, + Outputs = {new MachineLearningServiceOutputColumn { Name = "Sentiment", DataType = "string", -} -}, +}}, BatchSize = 1000, NumberOfParallelRequests = 1, InputRequestName = "Inputs", @@ -225,43 +210,34 @@ public async Task CreateOrUpdate_CreateAnAzureMLFunction() // invoke the operation string functionName = "function588"; - StreamingJobFunctionData data = new StreamingJobFunctionData() + StreamingJobFunctionData data = new StreamingJobFunctionData { - Properties = new ScalarFunctionProperties() + Properties = new ScalarFunctionProperties { - Inputs = -{ -new StreamingJobFunctionInput() + Inputs = {new StreamingJobFunctionInput { DataType = "nvarchar(max)", -} -}, +}}, OutputDataType = "nvarchar(max)", - Binding = new EMachineLearningStudioFunctionBinding() + Binding = new EMachineLearningStudioFunctionBinding { Endpoint = "someAzureMLEndpointURL", ApiKey = "someApiKey==", - Inputs = new MachineLearningStudioInputs() + Inputs = new MachineLearningStudioInputs { Name = "input1", - ColumnNames = -{ -new MachineLearningStudioInputColumn() + ColumnNames = {new MachineLearningStudioInputColumn { Name = "tweet", DataType = "string", MapTo = 0, -} -}, +}}, }, - Outputs = -{ -new MachineLearningStudioOutputColumn() + Outputs = {new MachineLearningStudioOutputColumn { Name = "Sentiment", DataType = "string", -} -}, +}}, BatchSize = 1000, }, }, @@ -312,9 +288,9 @@ public async Task Get_GetAJavaScriptFunction() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAJavaScriptFunction() + public async Task Get_GetAnAzureMLFunction() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_JavaScript.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_AzureML.json // this example is just showing the usage of "Functions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -325,8 +301,8 @@ public async Task Exists_GetAJavaScriptFunction() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg1637"; - string jobName = "sj8653"; + string resourceGroupName = "sjrg7"; + string jobName = "sj9093"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -334,18 +310,22 @@ public async Task Exists_GetAJavaScriptFunction() StreamingJobFunctionCollection collection = streamingJob.GetStreamingJobFunctions(); // invoke the operation - string functionName = "function8197"; - bool result = await collection.ExistsAsync(functionName); + string functionName = "function588"; + StreamingJobFunctionResource result = await collection.GetAsync(functionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAJavaScriptFunction() + public async Task GetAll_ListAllFunctionsInAStreamingJob() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_JavaScript.json - // this example is just showing the usage of "Functions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_ListByStreamingJob.json + // this example is just showing the usage of "Functions_ListByStreamingJob" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -363,30 +343,24 @@ public async Task GetIfExists_GetAJavaScriptFunction() // get the collection of this StreamingJobFunctionResource StreamingJobFunctionCollection collection = streamingJob.GetStreamingJobFunctions(); - // invoke the operation - string functionName = "function8197"; - NullableResponse response = await collection.GetIfExistsAsync(functionName); - StreamingJobFunctionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (StreamingJobFunctionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamingJobFunctionData resourceData = result.Data; + StreamingJobFunctionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureMLFunction() + public async Task Exists_GetAJavaScriptFunction() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_AzureML.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_JavaScript.json // this example is just showing the usage of "Functions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -397,8 +371,8 @@ public async Task Get_GetAnAzureMLFunction() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg7"; - string jobName = "sj9093"; + string resourceGroupName = "sjrg1637"; + string jobName = "sj8653"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -406,14 +380,10 @@ public async Task Get_GetAnAzureMLFunction() StreamingJobFunctionCollection collection = streamingJob.GetStreamingJobFunctions(); // invoke the operation - string functionName = "function588"; - StreamingJobFunctionResource result = await collection.GetAsync(functionName); + string functionName = "function8197"; + bool result = await collection.ExistsAsync(functionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -448,9 +418,9 @@ public async Task Exists_GetAnAzureMLFunction() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAzureMLFunction() + public async Task GetIfExists_GetAJavaScriptFunction() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_AzureML.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_JavaScript.json // this example is just showing the usage of "Functions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -461,8 +431,8 @@ public async Task GetIfExists_GetAnAzureMLFunction() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg7"; - string jobName = "sj9093"; + string resourceGroupName = "sjrg1637"; + string jobName = "sj8653"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -470,7 +440,7 @@ public async Task GetIfExists_GetAnAzureMLFunction() StreamingJobFunctionCollection collection = streamingJob.GetStreamingJobFunctions(); // invoke the operation - string functionName = "function588"; + string functionName = "function8197"; NullableResponse response = await collection.GetIfExistsAsync(functionName); StreamingJobFunctionResource result = response.HasValue ? response.Value : null; @@ -490,10 +460,10 @@ public async Task GetIfExists_GetAnAzureMLFunction() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllFunctionsInAStreamingJob() + public async Task GetIfExists_GetAnAzureMLFunction() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_ListByStreamingJob.json - // this example is just showing the usage of "Functions_ListByStreamingJob" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_AzureML.json + // this example is just showing the usage of "Functions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -503,25 +473,31 @@ public async Task GetAll_ListAllFunctionsInAStreamingJob() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg1637"; - string jobName = "sj8653"; + string resourceGroupName = "sjrg7"; + string jobName = "sj9093"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // get the collection of this StreamingJobFunctionResource StreamingJobFunctionCollection collection = streamingJob.GetStreamingJobFunctions(); - // invoke the operation and iterate over the result - await foreach (StreamingJobFunctionResource item in collection.GetAllAsync()) + // invoke the operation + string functionName = "function588"; + NullableResponse response = await collection.GetIfExistsAsync(functionName); + StreamingJobFunctionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamingJobFunctionData resourceData = item.Data; + StreamingJobFunctionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobFunctionResource.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobFunctionResource.cs index ff2770fd02c4b..de5847b5ddc98 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobFunctionResource.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobFunctionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_StreamingJobFunctionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAJavaScriptFunction() + public async Task Get_GetAJavaScriptFunction() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Update_JavaScript.json - // this example is just showing the usage of "Functions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_JavaScript.json + // this example is just showing the usage of "Functions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,7 @@ public async Task Update_UpdateAJavaScriptFunction() StreamingJobFunctionResource streamingJobFunction = client.GetStreamingJobFunctionResource(streamingJobFunctionResourceId); // invoke the operation - StreamingJobFunctionData data = new StreamingJobFunctionData() - { - Properties = new ScalarFunctionProperties() - { - Binding = new JavaScriptFunctionBinding() - { - Script = "function (a, b) { return a * b; }", - }, - }, - }; - StreamingJobFunctionResource result = await streamingJobFunction.UpdateAsync(data); + StreamingJobFunctionResource result = await streamingJobFunction.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -59,10 +49,10 @@ public async Task Update_UpdateAJavaScriptFunction() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnAzureMLFunction() + public async Task Get_GetAnAzureMLFunction() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Update_AzureML.json - // this example is just showing the usage of "Functions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_AzureML.json + // this example is just showing the usage of "Functions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,17 +69,7 @@ public async Task Update_UpdateAnAzureMLFunction() StreamingJobFunctionResource streamingJobFunction = client.GetStreamingJobFunctionResource(streamingJobFunctionResourceId); // invoke the operation - StreamingJobFunctionData data = new StreamingJobFunctionData() - { - Properties = new ScalarFunctionProperties() - { - Binding = new EMachineLearningStudioFunctionBinding() - { - BatchSize = 5000, - }, - }, - }; - StreamingJobFunctionResource result = await streamingJobFunction.UpdateAsync(data); + StreamingJobFunctionResource result = await streamingJobFunction.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -127,10 +107,10 @@ public async Task Delete_DeleteAFunction() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAJavaScriptFunction() + public async Task Update_UpdateAJavaScriptFunction() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_JavaScript.json - // this example is just showing the usage of "Functions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Update_JavaScript.json + // this example is just showing the usage of "Functions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,7 +127,17 @@ public async Task Get_GetAJavaScriptFunction() StreamingJobFunctionResource streamingJobFunction = client.GetStreamingJobFunctionResource(streamingJobFunctionResourceId); // invoke the operation - StreamingJobFunctionResource result = await streamingJobFunction.GetAsync(); + StreamingJobFunctionData data = new StreamingJobFunctionData + { + Properties = new ScalarFunctionProperties + { + Binding = new JavaScriptFunctionBinding + { + Script = "function (a, b) { return a * b; }", + }, + }, + }; + StreamingJobFunctionResource result = await streamingJobFunction.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -158,10 +148,10 @@ public async Task Get_GetAJavaScriptFunction() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureMLFunction() + public async Task Update_UpdateAnAzureMLFunction() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Get_AzureML.json - // this example is just showing the usage of "Functions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Function_Update_AzureML.json + // this example is just showing the usage of "Functions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,7 +168,17 @@ public async Task Get_GetAnAzureMLFunction() StreamingJobFunctionResource streamingJobFunction = client.GetStreamingJobFunctionResource(streamingJobFunctionResourceId); // invoke the operation - StreamingJobFunctionResource result = await streamingJobFunction.GetAsync(); + StreamingJobFunctionData data = new StreamingJobFunctionData + { + Properties = new ScalarFunctionProperties + { + Binding = new EMachineLearningStudioFunctionBinding + { + BatchSize = 5000, + }, + }, + }; + StreamingJobFunctionResource result = await streamingJobFunction.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -265,7 +265,7 @@ public async Task RetrieveDefaultDefinition_RetrieveTheDefaultDefinitionForAnAzu StreamingJobFunctionResource streamingJobFunction = client.GetStreamingJobFunctionResource(streamingJobFunctionResourceId); // invoke the operation - FunctionRetrieveDefaultDefinitionContent content = new MachineLearningStudioFunctionRetrieveDefaultDefinitionContent() + FunctionRetrieveDefaultDefinitionContent content = new MachineLearningStudioFunctionRetrieveDefaultDefinitionContent { ExecuteEndpoint = "someAzureMLExecuteEndpointUrl", UdfType = StreamingJobFunctionUdfType.Scalar, diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobInputCollection.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobInputCollection.cs index 0ee47d2f4cf00..f4164e8fe5d19 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobInputCollection.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobInputCollection.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.StreamAnalytics.Models; @@ -41,11 +42,11 @@ public async Task CreateOrUpdate_CreateAGatewayMessageBusInput() // invoke the operation string inputName = "input7970"; - StreamingJobInputData input = new StreamingJobInputData() + StreamingJobInputData input = new StreamingJobInputData { - Properties = new StreamInputProperties() + Properties = new StreamInputProperties { - Datasource = new GatewayMessageBusStreamInputDataSource() + Datasource = new GatewayMessageBusStreamInputDataSource { Topic = "EdgeTopic1", }, @@ -86,20 +87,17 @@ public async Task CreateOrUpdate_CreateAReferenceBlobInputWithCSVSerialization() // invoke the operation string inputName = "input7225"; - StreamingJobInputData input = new StreamingJobInputData() + StreamingJobInputData input = new StreamingJobInputData { - Properties = new ReferenceInputProperties() + Properties = new ReferenceInputProperties { - Datasource = new BlobReferenceInputDataSource() + Datasource = new BlobReferenceInputDataSource { - StorageAccounts = -{ -new StreamAnalyticsStorageAccount() + StorageAccounts = {new StreamAnalyticsStorageAccount { AccountName = "someAccountName", AccountKey = "someAccountKey==", -} -}, +}}, Container = "state", PathPattern = "{date}/{time}", DateFormat = "yyyy/MM/dd", @@ -107,10 +105,10 @@ public async Task CreateOrUpdate_CreateAReferenceBlobInputWithCSVSerialization() BlobName = "myblobinput", DeltaPathPattern = "/testBlob/{date}/delta/{time}/", SourcePartitionCount = 16, - FullSnapshotRefreshInterval = TimeSpan.Parse("16:14:30"), - DeltaSnapshotRefreshInterval = TimeSpan.Parse("16:14:30"), + FullSnapshotRefreshInterval = XmlConvert.ToTimeSpan("16:14:30"), + DeltaSnapshotRefreshInterval = XmlConvert.ToTimeSpan("16:14:30"), }, - Serialization = new CsvFormatSerialization() + Serialization = new CsvFormatSerialization { FieldDelimiter = ",", Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, @@ -152,11 +150,11 @@ public async Task CreateOrUpdate_CreateAStreamEventHubInputWithJSONSerialization // invoke the operation string inputName = "input7425"; - StreamingJobInputData input = new StreamingJobInputData() + StreamingJobInputData input = new StreamingJobInputData { - Properties = new StreamInputProperties() + Properties = new StreamInputProperties { - Datasource = new EventHubStreamInputDataSource() + Datasource = new EventHubStreamInputDataSource { ServiceBusNamespace = "sdktest", SharedAccessPolicyName = "RootManageSharedAccessKey", @@ -164,7 +162,7 @@ public async Task CreateOrUpdate_CreateAStreamEventHubInputWithJSONSerialization EventHubName = "sdkeventhub", ConsumerGroupName = "sdkconsumergroup", }, - Serialization = new JsonFormatSerialization() + Serialization = new JsonFormatSerialization { Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, }, @@ -206,11 +204,11 @@ public async Task CreateOrUpdate_CreateAStreamIoTHubInputWithAvroSerialization() // invoke the operation string inputName = "input7970"; - StreamingJobInputData input = new StreamingJobInputData() + StreamingJobInputData input = new StreamingJobInputData { - Properties = new StreamInputProperties() + Properties = new StreamInputProperties { - Datasource = new IoTHubStreamInputDataSource() + Datasource = new IoTHubStreamInputDataSource { IotHubNamespace = "iothub", SharedAccessPolicyName = "owner", @@ -256,27 +254,24 @@ public async Task CreateOrUpdate_CreateAStreamBlobInputWithCSVSerialization() // invoke the operation string inputName = "input8899"; - StreamingJobInputData input = new StreamingJobInputData() + StreamingJobInputData input = new StreamingJobInputData { - Properties = new StreamInputProperties() + Properties = new StreamInputProperties { - Datasource = new BlobStreamInputDataSource() + Datasource = new BlobStreamInputDataSource { - StorageAccounts = -{ -new StreamAnalyticsStorageAccount() + StorageAccounts = {new StreamAnalyticsStorageAccount { AccountName = "someAccountName", AccountKey = "someAccountKey==", -} -}, +}}, Container = "state", PathPattern = "{date}/{time}", DateFormat = "yyyy/MM/dd", TimeFormat = "HH", SourcePartitionCount = 16, }, - Serialization = new CsvFormatSerialization() + Serialization = new CsvFormatSerialization { FieldDelimiter = ",", Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, @@ -318,13 +313,13 @@ public async Task CreateOrUpdate_CreateAnEventGridInput() // invoke the operation string inputName = "input7970"; - StreamingJobInputData input = new StreamingJobInputData() + StreamingJobInputData input = new StreamingJobInputData { - Properties = new StreamInputProperties() + Properties = new StreamInputProperties { - Datasource = new EventGridStreamInputDataSource() + Datasource = new EventGridStreamInputDataSource { - Subscriber = new EventHubV2StreamInputDataSource() + Subscriber = new EventHubV2StreamInputDataSource { ServiceBusNamespace = "sdktest", SharedAccessPolicyName = "RootManageSharedAccessKey", @@ -335,19 +330,13 @@ public async Task CreateOrUpdate_CreateAnEventGridInput() ConsumerGroupName = "sdkconsumergroup", }, Schema = EventGridEventSchemaType.CloudEventSchema, - StorageAccounts = -{ -new StreamAnalyticsStorageAccount() + StorageAccounts = {new StreamAnalyticsStorageAccount { AccountName = "myaccount", AccountKey = "myaccountkey", AuthenticationMode = StreamAnalyticsAuthenticationMode.Msi, -} -}, - EventTypes = -{ -"Microsoft.Storage.BlobCreated" -}, +}}, + EventTypes = { "Microsoft.Storage.BlobCreated" }, }, }, }; @@ -397,9 +386,9 @@ public async Task Get_GetAReferenceBlobInputWithCSVSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAReferenceBlobInputWithCSVSerialization() + public async Task Get_GetAStreamEventHubInputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Reference_Blob_CSV.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_EventHub_JSON.json // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -410,8 +399,8 @@ public async Task Exists_GetAReferenceBlobInputWithCSVSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg8440"; - string jobName = "sj9597"; + string resourceGroupName = "sjrg3139"; + string jobName = "sj197"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -419,17 +408,21 @@ public async Task Exists_GetAReferenceBlobInputWithCSVSerialization() StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); // invoke the operation - string inputName = "input7225"; - bool result = await collection.ExistsAsync(inputName); + string inputName = "input7425"; + StreamingJobInputResource result = await collection.GetAsync(inputName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobInputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAReferenceBlobInputWithCSVSerialization() + public async Task Get_GetAStreamIoTHubInputWithAvroSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Reference_Blob_CSV.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_IoTHub_Avro.json // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -440,8 +433,8 @@ public async Task GetIfExists_GetAReferenceBlobInputWithCSVSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg8440"; - string jobName = "sj9597"; + string resourceGroupName = "sjrg3467"; + string jobName = "sj9742"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -449,29 +442,21 @@ public async Task GetIfExists_GetAReferenceBlobInputWithCSVSerialization() StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); // invoke the operation - string inputName = "input7225"; - NullableResponse response = await collection.GetIfExistsAsync(inputName); - StreamingJobInputResource result = response.HasValue ? response.Value : null; + string inputName = "input7970"; + StreamingJobInputResource result = await collection.GetAsync(inputName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobInputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobInputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAStreamEventHubInputWithJSONSerialization() + public async Task Get_GetAStreamBlobInputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_EventHub_JSON.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_Blob_CSV.json // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -482,8 +467,8 @@ public async Task Get_GetAStreamEventHubInputWithJSONSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg3139"; - string jobName = "sj197"; + string resourceGroupName = "sjrg8161"; + string jobName = "sj6695"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -491,7 +476,7 @@ public async Task Get_GetAStreamEventHubInputWithJSONSerialization() StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); // invoke the operation - string inputName = "input7425"; + string inputName = "input8899"; StreamingJobInputResource result = await collection.GetAsync(inputName); // the variable result is a resource, you could call other operations on this instance as well @@ -503,10 +488,10 @@ public async Task Get_GetAStreamEventHubInputWithJSONSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAStreamEventHubInputWithJSONSerialization() + public async Task GetAll_ListAllInputsInAStreamingJob() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_EventHub_JSON.json - // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_ListByStreamingJob.json + // this example is just showing the usage of "Inputs_ListByStreamingJob" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -516,27 +501,33 @@ public async Task Exists_GetAStreamEventHubInputWithJSONSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg3139"; - string jobName = "sj197"; + string resourceGroupName = "sjrg8440"; + string jobName = "sj9597"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // get the collection of this StreamingJobInputResource StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); - // invoke the operation - string inputName = "input7425"; - bool result = await collection.ExistsAsync(inputName); + // invoke the operation and iterate over the result + await foreach (StreamingJobInputResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobInputData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAStreamEventHubInputWithJSONSerialization() + public async Task GetAll_ListAllInputsInAStreamingJobAndIncludeDiagnosticInformationUsingTheSelectODataQueryParameter() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_EventHub_JSON.json - // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_ListByStreamingJob_Diagnostics.json + // this example is just showing the usage of "Inputs_ListByStreamingJob" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -546,38 +537,33 @@ public async Task GetIfExists_GetAStreamEventHubInputWithJSONSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg3139"; - string jobName = "sj197"; + string resourceGroupName = "sjrg3276"; + string jobName = "sj7804"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // get the collection of this StreamingJobInputResource StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); - // invoke the operation - string inputName = "input7425"; - NullableResponse response = await collection.GetIfExistsAsync(inputName); - StreamingJobInputResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string select = "*"; + await foreach (StreamingJobInputResource item in collection.GetAllAsync(select: select)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamingJobInputData resourceData = result.Data; + StreamingJobInputData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAStreamIoTHubInputWithAvroSerialization() + public async Task Exists_GetAReferenceBlobInputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_IoTHub_Avro.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Reference_Blob_CSV.json // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -588,8 +574,8 @@ public async Task Get_GetAStreamIoTHubInputWithAvroSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg3467"; - string jobName = "sj9742"; + string resourceGroupName = "sjrg8440"; + string jobName = "sj9597"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -597,21 +583,17 @@ public async Task Get_GetAStreamIoTHubInputWithAvroSerialization() StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); // invoke the operation - string inputName = "input7970"; - StreamingJobInputResource result = await collection.GetAsync(inputName); + string inputName = "input7225"; + bool result = await collection.ExistsAsync(inputName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobInputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAStreamIoTHubInputWithAvroSerialization() + public async Task Exists_GetAStreamEventHubInputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_IoTHub_Avro.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_EventHub_JSON.json // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -622,8 +604,8 @@ public async Task Exists_GetAStreamIoTHubInputWithAvroSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg3467"; - string jobName = "sj9742"; + string resourceGroupName = "sjrg3139"; + string jobName = "sj197"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -631,7 +613,7 @@ public async Task Exists_GetAStreamIoTHubInputWithAvroSerialization() StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); // invoke the operation - string inputName = "input7970"; + string inputName = "input7425"; bool result = await collection.ExistsAsync(inputName); Console.WriteLine($"Succeeded: {result}"); @@ -639,7 +621,7 @@ public async Task Exists_GetAStreamIoTHubInputWithAvroSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAStreamIoTHubInputWithAvroSerialization() + public async Task Exists_GetAStreamIoTHubInputWithAvroSerialization() { // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_IoTHub_Avro.json // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. @@ -662,26 +644,14 @@ public async Task GetIfExists_GetAStreamIoTHubInputWithAvroSerialization() // invoke the operation string inputName = "input7970"; - NullableResponse response = await collection.GetIfExistsAsync(inputName); - StreamingJobInputResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(inputName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobInputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAStreamBlobInputWithCSVSerialization() + public async Task Exists_GetAStreamBlobInputWithCSVSerialization() { // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_Blob_CSV.json // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. @@ -704,20 +674,16 @@ public async Task Get_GetAStreamBlobInputWithCSVSerialization() // invoke the operation string inputName = "input8899"; - StreamingJobInputResource result = await collection.GetAsync(inputName); + bool result = await collection.ExistsAsync(inputName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobInputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAStreamBlobInputWithCSVSerialization() + public async Task GetIfExists_GetAReferenceBlobInputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_Blob_CSV.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Reference_Blob_CSV.json // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -728,8 +694,8 @@ public async Task Exists_GetAStreamBlobInputWithCSVSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg8161"; - string jobName = "sj6695"; + string resourceGroupName = "sjrg8440"; + string jobName = "sj9597"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -737,17 +703,29 @@ public async Task Exists_GetAStreamBlobInputWithCSVSerialization() StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); // invoke the operation - string inputName = "input8899"; - bool result = await collection.ExistsAsync(inputName); + string inputName = "input7225"; + NullableResponse response = await collection.GetIfExistsAsync(inputName); + StreamingJobInputResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobInputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAStreamBlobInputWithCSVSerialization() + public async Task GetIfExists_GetAStreamEventHubInputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_Blob_CSV.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_EventHub_JSON.json // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -758,8 +736,8 @@ public async Task GetIfExists_GetAStreamBlobInputWithCSVSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg8161"; - string jobName = "sj6695"; + string resourceGroupName = "sjrg3139"; + string jobName = "sj197"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -767,7 +745,7 @@ public async Task GetIfExists_GetAStreamBlobInputWithCSVSerialization() StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); // invoke the operation - string inputName = "input8899"; + string inputName = "input7425"; NullableResponse response = await collection.GetIfExistsAsync(inputName); StreamingJobInputResource result = response.HasValue ? response.Value : null; @@ -787,10 +765,10 @@ public async Task GetIfExists_GetAStreamBlobInputWithCSVSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllInputsInAStreamingJob() + public async Task GetIfExists_GetAStreamIoTHubInputWithAvroSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_ListByStreamingJob.json - // this example is just showing the usage of "Inputs_ListByStreamingJob" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_IoTHub_Avro.json + // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -800,33 +778,39 @@ public async Task GetAll_ListAllInputsInAStreamingJob() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg8440"; - string jobName = "sj9597"; + string resourceGroupName = "sjrg3467"; + string jobName = "sj9742"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // get the collection of this StreamingJobInputResource StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); - // invoke the operation and iterate over the result - await foreach (StreamingJobInputResource item in collection.GetAllAsync()) + // invoke the operation + string inputName = "input7970"; + NullableResponse response = await collection.GetIfExistsAsync(inputName); + StreamingJobInputResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamingJobInputData resourceData = item.Data; + StreamingJobInputData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllInputsInAStreamingJobAndIncludeDiagnosticInformationUsingTheSelectODataQueryParameter() + public async Task GetIfExists_GetAStreamBlobInputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_ListByStreamingJob_Diagnostics.json - // this example is just showing the usage of "Inputs_ListByStreamingJob" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_Blob_CSV.json + // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -836,26 +820,31 @@ public async Task GetAll_ListAllInputsInAStreamingJobAndIncludeDiagnosticInforma // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg3276"; - string jobName = "sj7804"; + string resourceGroupName = "sjrg8161"; + string jobName = "sj6695"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // get the collection of this StreamingJobInputResource StreamingJobInputCollection collection = streamingJob.GetStreamingJobInputs(); - // invoke the operation and iterate over the result - string select = "*"; - await foreach (StreamingJobInputResource item in collection.GetAllAsync(select: select)) + // invoke the operation + string inputName = "input8899"; + NullableResponse response = await collection.GetIfExistsAsync(inputName); + StreamingJobInputResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamingJobInputData resourceData = item.Data; + StreamingJobInputData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobInputResource.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobInputResource.cs index 098ecb52e96a6..ab577c9851ada 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobInputResource.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobInputResource.cs @@ -18,10 +18,10 @@ public partial class Sample_StreamingJobInputResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAReferenceBlobInput() + public async Task Get_GetAReferenceBlobInputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Update_Reference_Blob.json - // this example is just showing the usage of "Inputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Reference_Blob_CSV.json + // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,22 +38,7 @@ public async Task Update_UpdateAReferenceBlobInput() StreamingJobInputResource streamingJobInput = client.GetStreamingJobInputResource(streamingJobInputResourceId); // invoke the operation - StreamingJobInputData input = new StreamingJobInputData() - { - Properties = new ReferenceInputProperties() - { - Datasource = new BlobReferenceInputDataSource() - { - Container = "differentContainer", - }, - Serialization = new CsvFormatSerialization() - { - FieldDelimiter = "|", - Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, - }, - }, - }; - StreamingJobInputResource result = await streamingJobInput.UpdateAsync(input); + StreamingJobInputResource result = await streamingJobInput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -64,10 +49,10 @@ public async Task Update_UpdateAReferenceBlobInput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAStreamEventHubInput() + public async Task Get_GetAStreamEventHubInputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Update_Stream_EventHub.json - // this example is just showing the usage of "Inputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_EventHub_JSON.json + // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -84,18 +69,7 @@ public async Task Update_UpdateAStreamEventHubInput() StreamingJobInputResource streamingJobInput = client.GetStreamingJobInputResource(streamingJobInputResourceId); // invoke the operation - StreamingJobInputData input = new StreamingJobInputData() - { - Properties = new StreamInputProperties() - { - Datasource = new EventHubStreamInputDataSource() - { - ConsumerGroupName = "differentConsumerGroupName", - }, - Serialization = new AvroFormatSerialization(), - }, - }; - StreamingJobInputResource result = await streamingJobInput.UpdateAsync(input); + StreamingJobInputResource result = await streamingJobInput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -106,10 +80,10 @@ public async Task Update_UpdateAStreamEventHubInput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAStreamIoTHubInput() + public async Task Get_GetAStreamIoTHubInputWithAvroSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Update_Stream_IoTHub.json - // this example is just showing the usage of "Inputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_IoTHub_Avro.json + // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -126,22 +100,7 @@ public async Task Update_UpdateAStreamIoTHubInput() StreamingJobInputResource streamingJobInput = client.GetStreamingJobInputResource(streamingJobInputResourceId); // invoke the operation - StreamingJobInputData input = new StreamingJobInputData() - { - Properties = new StreamInputProperties() - { - Datasource = new IoTHubStreamInputDataSource() - { - Endpoint = "messages/operationsMonitoringEvents", - }, - Serialization = new CsvFormatSerialization() - { - FieldDelimiter = "|", - Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, - }, - }, - }; - StreamingJobInputResource result = await streamingJobInput.UpdateAsync(input); + StreamingJobInputResource result = await streamingJobInput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -152,10 +111,10 @@ public async Task Update_UpdateAStreamIoTHubInput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAStreamBlobInput() + public async Task Get_GetAStreamBlobInputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Update_Stream_Blob.json - // this example is just showing the usage of "Inputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_Blob_CSV.json + // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,22 +131,7 @@ public async Task Update_UpdateAStreamBlobInput() StreamingJobInputResource streamingJobInput = client.GetStreamingJobInputResource(streamingJobInputResourceId); // invoke the operation - StreamingJobInputData input = new StreamingJobInputData() - { - Properties = new StreamInputProperties() - { - Datasource = new BlobStreamInputDataSource() - { - SourcePartitionCount = 32, - }, - Serialization = new CsvFormatSerialization() - { - FieldDelimiter = "|", - Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, - }, - }, - }; - StreamingJobInputResource result = await streamingJobInput.UpdateAsync(input); + StreamingJobInputResource result = await streamingJobInput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -225,10 +169,10 @@ public async Task Delete_DeleteAnInput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAReferenceBlobInputWithCSVSerialization() + public async Task Update_UpdateAReferenceBlobInput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Reference_Blob_CSV.json - // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Update_Reference_Blob.json + // this example is just showing the usage of "Inputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -245,7 +189,22 @@ public async Task Get_GetAReferenceBlobInputWithCSVSerialization() StreamingJobInputResource streamingJobInput = client.GetStreamingJobInputResource(streamingJobInputResourceId); // invoke the operation - StreamingJobInputResource result = await streamingJobInput.GetAsync(); + StreamingJobInputData input = new StreamingJobInputData + { + Properties = new ReferenceInputProperties + { + Datasource = new BlobReferenceInputDataSource + { + Container = "differentContainer", + }, + Serialization = new CsvFormatSerialization + { + FieldDelimiter = "|", + Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, + }, + }, + }; + StreamingJobInputResource result = await streamingJobInput.UpdateAsync(input); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -256,10 +215,10 @@ public async Task Get_GetAReferenceBlobInputWithCSVSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAStreamEventHubInputWithJSONSerialization() + public async Task Update_UpdateAStreamEventHubInput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_EventHub_JSON.json - // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Update_Stream_EventHub.json + // this example is just showing the usage of "Inputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -276,7 +235,18 @@ public async Task Get_GetAStreamEventHubInputWithJSONSerialization() StreamingJobInputResource streamingJobInput = client.GetStreamingJobInputResource(streamingJobInputResourceId); // invoke the operation - StreamingJobInputResource result = await streamingJobInput.GetAsync(); + StreamingJobInputData input = new StreamingJobInputData + { + Properties = new StreamInputProperties + { + Datasource = new EventHubStreamInputDataSource + { + ConsumerGroupName = "differentConsumerGroupName", + }, + Serialization = new AvroFormatSerialization(), + }, + }; + StreamingJobInputResource result = await streamingJobInput.UpdateAsync(input); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -287,10 +257,10 @@ public async Task Get_GetAStreamEventHubInputWithJSONSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAStreamIoTHubInputWithAvroSerialization() + public async Task Update_UpdateAStreamIoTHubInput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_IoTHub_Avro.json - // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Update_Stream_IoTHub.json + // this example is just showing the usage of "Inputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -307,7 +277,22 @@ public async Task Get_GetAStreamIoTHubInputWithAvroSerialization() StreamingJobInputResource streamingJobInput = client.GetStreamingJobInputResource(streamingJobInputResourceId); // invoke the operation - StreamingJobInputResource result = await streamingJobInput.GetAsync(); + StreamingJobInputData input = new StreamingJobInputData + { + Properties = new StreamInputProperties + { + Datasource = new IoTHubStreamInputDataSource + { + Endpoint = "messages/operationsMonitoringEvents", + }, + Serialization = new CsvFormatSerialization + { + FieldDelimiter = "|", + Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, + }, + }, + }; + StreamingJobInputResource result = await streamingJobInput.UpdateAsync(input); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -318,10 +303,10 @@ public async Task Get_GetAStreamIoTHubInputWithAvroSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAStreamBlobInputWithCSVSerialization() + public async Task Update_UpdateAStreamBlobInput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Get_Stream_Blob_CSV.json - // this example is just showing the usage of "Inputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Input_Update_Stream_Blob.json + // this example is just showing the usage of "Inputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -338,7 +323,22 @@ public async Task Get_GetAStreamBlobInputWithCSVSerialization() StreamingJobInputResource streamingJobInput = client.GetStreamingJobInputResource(streamingJobInputResourceId); // invoke the operation - StreamingJobInputResource result = await streamingJobInput.GetAsync(); + StreamingJobInputData input = new StreamingJobInputData + { + Properties = new StreamInputProperties + { + Datasource = new BlobStreamInputDataSource + { + SourcePartitionCount = 32, + }, + Serialization = new CsvFormatSerialization + { + FieldDelimiter = "|", + Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, + }, + }, + }; + StreamingJobInputResource result = await streamingJobInput.UpdateAsync(input); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobOutputCollection.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobOutputCollection.cs index 9070cfa870339..ce755fb2a435d 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobOutputCollection.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobOutputCollection.cs @@ -41,9 +41,9 @@ public async Task CreateOrUpdate_CreateADocumentDBOutput() // invoke the operation string outputName = "output3022"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new DocumentDbOutputDataSource() + Datasource = new DocumentDbOutputDataSource { AccountId = "someAccountId", AccountKey = "accountKey==", @@ -89,9 +89,9 @@ public async Task CreateOrUpdate_CreateAGatewayMessageBusOutput() // invoke the operation string outputName = "output3022"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new GatewayMessageBusOutputDataSource() + Datasource = new GatewayMessageBusOutputDataSource { Topic = "EdgeTopic1", }, @@ -131,9 +131,9 @@ public async Task CreateOrUpdate_CreateAPostgreSQLOutput() // invoke the operation string outputName = "output3022"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new PostgreSQLOutputDataSource() + Datasource = new PostgreSQLOutputDataSource { Server = "someServer", Database = "someDatabase", @@ -179,9 +179,9 @@ public async Task CreateOrUpdate_CreateAPowerBIOutput() // invoke the operation string outputName = "output3022"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new PowerBIOutputDataSource() + Datasource = new PowerBIOutputDataSource { RefreshToken = "someRefreshToken==", TokenUserPrincipalName = "bobsmith@contoso.com", @@ -227,22 +227,19 @@ public async Task CreateOrUpdate_CreateAServiceBusQueueOutputWithAvroSerializati // invoke the operation string outputName = "output3456"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new ServiceBusQueueOutputDataSource() + Datasource = new ServiceBusQueueOutputDataSource { ServiceBusNamespace = "sdktest", SharedAccessPolicyName = "RootManageSharedAccessKey", SharedAccessPolicyKey = "sharedAccessPolicyKey=", QueueName = "sdkqueue", - PropertyColumns = -{ -"column1","column2" -}, + PropertyColumns = { "column1", "column2" }, SystemPropertyColumns = { ["MessageId"] = "col3", -["PartitionKey"] = "col4", +["PartitionKey"] = "col4" }, }, Serialization = new AvroFormatSerialization(), @@ -282,20 +279,17 @@ public async Task CreateOrUpdate_CreateAServiceBusTopicOutputWithCSVSerializatio // invoke the operation string outputName = "output7886"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new ServiceBusTopicOutputDataSource() + Datasource = new ServiceBusTopicOutputDataSource { ServiceBusNamespace = "sdktest", SharedAccessPolicyName = "RootManageSharedAccessKey", SharedAccessPolicyKey = "sharedAccessPolicyKey=", TopicName = "sdktopic", - PropertyColumns = -{ -"column1","column2" -}, + PropertyColumns = { "column1", "column2" }, }, - Serialization = new CsvFormatSerialization() + Serialization = new CsvFormatSerialization { FieldDelimiter = ",", Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, @@ -336,18 +330,15 @@ public async Task CreateOrUpdate_CreateABlobOutputWithCSVSerialization() // invoke the operation string outputName = "output1623"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new BlobOutputDataSource() + Datasource = new BlobOutputDataSource { - StorageAccounts = -{ -new StreamAnalyticsStorageAccount() + StorageAccounts = {new StreamAnalyticsStorageAccount { AccountName = "someAccountName", AccountKey = "accountKey==", -} -}, +}}, Container = "state", PathPattern = "{date}/{time}", DateFormat = "yyyy/MM/dd", @@ -355,7 +346,7 @@ public async Task CreateOrUpdate_CreateABlobOutputWithCSVSerialization() BlobPathPrefix = "my/path", BlobWriteMode = BlobOutputWriteMode.Once, }, - Serialization = new CsvFormatSerialization() + Serialization = new CsvFormatSerialization { FieldDelimiter = ",", Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, @@ -396,9 +387,9 @@ public async Task CreateOrUpdate_CreateAnAzureDataLakeStoreOutputWithJSONSeriali // invoke the operation string outputName = "output5195"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new DataLakeStoreOutputDataSource() + Datasource = new DataLakeStoreOutputDataSource { RefreshToken = "someRefreshToken==", TokenUserPrincipalName = "bobsmith@contoso.com", @@ -409,7 +400,7 @@ public async Task CreateOrUpdate_CreateAnAzureDataLakeStoreOutputWithJSONSeriali DateFormat = "yyyy/MM/dd", TimeFormat = "HH", }, - Serialization = new JsonFormatSerialization() + Serialization = new JsonFormatSerialization { Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, Format = JsonOutputSerializationFormat.Array, @@ -450,9 +441,9 @@ public async Task CreateOrUpdate_CreateAnAzureDataWarehouseOutput() // invoke the operation string outputName = "dwOutput"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new SynapseOutputDataSource() + Datasource = new SynapseOutputDataSource { Server = "asatestserver", Database = "zhayaSQLpool", @@ -497,9 +488,9 @@ public async Task CreateOrUpdate_CreateAnAzureFunctionOutput() // invoke the operation string outputName = "azureFunction1"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new FunctionOutputDataSource() + Datasource = new FunctionOutputDataSource { FunctionAppName = "functionappforasaautomation", FunctionName = "HttpTrigger2", @@ -543,9 +534,9 @@ public async Task CreateOrUpdate_CreateAnAzureSQLDatabaseOutput() // invoke the operation string outputName = "output1755"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new SqlDatabaseOutputDataSource() + Datasource = new SqlDatabaseOutputDataSource { Server = "someServer", Database = "someDatabase", @@ -589,19 +580,16 @@ public async Task CreateOrUpdate_CreateAnAzureTableOutput() // invoke the operation string outputName = "output958"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new TableOutputDataSource() + Datasource = new TableOutputDataSource { AccountName = "someAccountName", AccountKey = "accountKey==", Table = "samples", PartitionKey = "partitionKey", RowKey = "rowKey", - ColumnsToRemove = -{ -"column1","column2" -}, + ColumnsToRemove = { "column1", "column2" }, BatchSize = 25, }, }; @@ -640,9 +628,9 @@ public async Task CreateOrUpdate_CreateAnEventHubOutputWithJSONSerialization() // invoke the operation string outputName = "output5195"; - StreamingJobOutputData data = new StreamingJobOutputData() + StreamingJobOutputData data = new StreamingJobOutputData { - Datasource = new EventHubOutputDataSource() + Datasource = new EventHubOutputDataSource { ServiceBusNamespace = "sdktest", SharedAccessPolicyName = "RootManageSharedAccessKey", @@ -650,12 +638,12 @@ public async Task CreateOrUpdate_CreateAnEventHubOutputWithJSONSerialization() EventHubName = "sdkeventhub", PartitionKey = "partitionKey", }, - Serialization = new JsonFormatSerialization() + Serialization = new JsonFormatSerialization { Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, Format = JsonOutputSerializationFormat.Array, }, - WatermarkSettings = new StreamingJobOutputWatermarkProperties() + WatermarkSettings = new StreamingJobOutputWatermarkProperties { WatermarkMode = StreamingJobOutputWatermarkMode.SendCurrentPartitionWatermark, MaxWatermarkDifferenceAcrossPartitions = "16:14:30", @@ -707,9 +695,9 @@ public async Task Get_GetADocumentDBOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADocumentDBOutput() + public async Task Get_GetAPowerBIOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DocumentDB.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_PowerBI.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -730,16 +718,20 @@ public async Task Exists_GetADocumentDBOutput() // invoke the operation string outputName = "output3022"; - bool result = await collection.ExistsAsync(outputName); + StreamingJobOutputResource result = await collection.GetAsync(outputName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADocumentDBOutput() + public async Task Get_GetAServiceBusQueueOutputWithAvroSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DocumentDB.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusQueue_Avro.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -750,8 +742,8 @@ public async Task GetIfExists_GetADocumentDBOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg7983"; - string jobName = "sj2331"; + string resourceGroupName = "sjrg3410"; + string jobName = "sj5095"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -759,29 +751,21 @@ public async Task GetIfExists_GetADocumentDBOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output3022"; - NullableResponse response = await collection.GetIfExistsAsync(outputName); - StreamingJobOutputResource result = response.HasValue ? response.Value : null; + string outputName = "output3456"; + StreamingJobOutputResource result = await collection.GetAsync(outputName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPowerBIOutput() + public async Task Get_GetAServiceBusTopicOutputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_PowerBI.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusTopic_CSV.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -792,8 +776,8 @@ public async Task Get_GetAPowerBIOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg7983"; - string jobName = "sj2331"; + string resourceGroupName = "sjrg6450"; + string jobName = "sj7094"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -801,7 +785,7 @@ public async Task Get_GetAPowerBIOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output3022"; + string outputName = "output7886"; StreamingJobOutputResource result = await collection.GetAsync(outputName); // the variable result is a resource, you could call other operations on this instance as well @@ -813,9 +797,9 @@ public async Task Get_GetAPowerBIOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPowerBIOutput() + public async Task Get_GetABlobOutputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_PowerBI.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_Blob_CSV.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -826,8 +810,8 @@ public async Task Exists_GetAPowerBIOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg7983"; - string jobName = "sj2331"; + string resourceGroupName = "sjrg5023"; + string jobName = "sj900"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -835,17 +819,21 @@ public async Task Exists_GetAPowerBIOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output3022"; - bool result = await collection.ExistsAsync(outputName); + string outputName = "output1623"; + StreamingJobOutputResource result = await collection.GetAsync(outputName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPowerBIOutput() + public async Task Get_GetAnAzureDataLakeStoreOutputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_PowerBI.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureDataLakeStore_JSON.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -856,8 +844,8 @@ public async Task GetIfExists_GetAPowerBIOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg7983"; - string jobName = "sj2331"; + string resourceGroupName = "sjrg6912"; + string jobName = "sj3310"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -865,29 +853,21 @@ public async Task GetIfExists_GetAPowerBIOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output3022"; - NullableResponse response = await collection.GetIfExistsAsync(outputName); - StreamingJobOutputResource result = response.HasValue ? response.Value : null; + string outputName = "output5195"; + StreamingJobOutputResource result = await collection.GetAsync(outputName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServiceBusQueueOutputWithAvroSerialization() + public async Task Get_GetAnAzureDataWarehouseOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusQueue_Avro.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DataWarehouse.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -898,8 +878,8 @@ public async Task Get_GetAServiceBusQueueOutputWithAvroSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg3410"; - string jobName = "sj5095"; + string resourceGroupName = "sjrg"; + string jobName = "sjName"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -907,7 +887,7 @@ public async Task Get_GetAServiceBusQueueOutputWithAvroSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output3456"; + string outputName = "dwOutput"; StreamingJobOutputResource result = await collection.GetAsync(outputName); // the variable result is a resource, you could call other operations on this instance as well @@ -919,9 +899,9 @@ public async Task Get_GetAServiceBusQueueOutputWithAvroSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServiceBusQueueOutputWithAvroSerialization() + public async Task Get_GetAnAzureFunctionOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusQueue_Avro.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureFunction.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -932,8 +912,8 @@ public async Task Exists_GetAServiceBusQueueOutputWithAvroSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg3410"; - string jobName = "sj5095"; + string resourceGroupName = "sjrg"; + string jobName = "sjName"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -941,17 +921,21 @@ public async Task Exists_GetAServiceBusQueueOutputWithAvroSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output3456"; - bool result = await collection.ExistsAsync(outputName); + string outputName = "azureFunction1"; + StreamingJobOutputResource result = await collection.GetAsync(outputName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServiceBusQueueOutputWithAvroSerialization() + public async Task Get_GetAnAzureSQLDatabaseOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusQueue_Avro.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureSQL.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -962,8 +946,8 @@ public async Task GetIfExists_GetAServiceBusQueueOutputWithAvroSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg3410"; - string jobName = "sj5095"; + string resourceGroupName = "sjrg2157"; + string jobName = "sj6458"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -971,29 +955,21 @@ public async Task GetIfExists_GetAServiceBusQueueOutputWithAvroSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output3456"; - NullableResponse response = await collection.GetIfExistsAsync(outputName); - StreamingJobOutputResource result = response.HasValue ? response.Value : null; + string outputName = "output1755"; + StreamingJobOutputResource result = await collection.GetAsync(outputName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServiceBusTopicOutputWithCSVSerialization() + public async Task Get_GetAnAzureTableOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusTopic_CSV.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureTable.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1004,8 +980,8 @@ public async Task Get_GetAServiceBusTopicOutputWithCSVSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6450"; - string jobName = "sj7094"; + string resourceGroupName = "sjrg5176"; + string jobName = "sj2790"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1013,7 +989,7 @@ public async Task Get_GetAServiceBusTopicOutputWithCSVSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output7886"; + string outputName = "output958"; StreamingJobOutputResource result = await collection.GetAsync(outputName); // the variable result is a resource, you could call other operations on this instance as well @@ -1025,9 +1001,9 @@ public async Task Get_GetAServiceBusTopicOutputWithCSVSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServiceBusTopicOutputWithCSVSerialization() + public async Task Get_GetAnEventHubOutputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusTopic_CSV.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_EventHub_JSON.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1038,8 +1014,8 @@ public async Task Exists_GetAServiceBusTopicOutputWithCSVSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6450"; - string jobName = "sj7094"; + string resourceGroupName = "sjrg6912"; + string jobName = "sj3310"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1047,18 +1023,22 @@ public async Task Exists_GetAServiceBusTopicOutputWithCSVSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output7886"; - bool result = await collection.ExistsAsync(outputName); + string outputName = "output5195"; + StreamingJobOutputResource result = await collection.GetAsync(outputName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServiceBusTopicOutputWithCSVSerialization() + public async Task GetAll_ListAllOutputsInAStreamingJob() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusTopic_CSV.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_ListByStreamingJob.json + // this example is just showing the usage of "Outputs_ListByStreamingJob" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1068,38 +1048,32 @@ public async Task GetIfExists_GetAServiceBusTopicOutputWithCSVSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6450"; - string jobName = "sj7094"; + string resourceGroupName = "sjrg2157"; + string jobName = "sj6458"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // get the collection of this StreamingJobOutputResource StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); - // invoke the operation - string outputName = "output7886"; - NullableResponse response = await collection.GetIfExistsAsync(outputName); - StreamingJobOutputResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (StreamingJobOutputResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; + StreamingJobOutputData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetABlobOutputWithCSVSerialization() + public async Task Exists_GetADocumentDBOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_Blob_CSV.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DocumentDB.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1110,8 +1084,8 @@ public async Task Get_GetABlobOutputWithCSVSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg5023"; - string jobName = "sj900"; + string resourceGroupName = "sjrg7983"; + string jobName = "sj2331"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1119,21 +1093,17 @@ public async Task Get_GetABlobOutputWithCSVSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output1623"; - StreamingJobOutputResource result = await collection.GetAsync(outputName); + string outputName = "output3022"; + bool result = await collection.ExistsAsync(outputName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetABlobOutputWithCSVSerialization() + public async Task Exists_GetAPowerBIOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_Blob_CSV.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_PowerBI.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1144,8 +1114,8 @@ public async Task Exists_GetABlobOutputWithCSVSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg5023"; - string jobName = "sj900"; + string resourceGroupName = "sjrg7983"; + string jobName = "sj2331"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1153,7 +1123,7 @@ public async Task Exists_GetABlobOutputWithCSVSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output1623"; + string outputName = "output3022"; bool result = await collection.ExistsAsync(outputName); Console.WriteLine($"Succeeded: {result}"); @@ -1161,9 +1131,9 @@ public async Task Exists_GetABlobOutputWithCSVSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetABlobOutputWithCSVSerialization() + public async Task Exists_GetAServiceBusQueueOutputWithAvroSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_Blob_CSV.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusQueue_Avro.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1174,8 +1144,8 @@ public async Task GetIfExists_GetABlobOutputWithCSVSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg5023"; - string jobName = "sj900"; + string resourceGroupName = "sjrg3410"; + string jobName = "sj5095"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1183,29 +1153,17 @@ public async Task GetIfExists_GetABlobOutputWithCSVSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output1623"; - NullableResponse response = await collection.GetIfExistsAsync(outputName); - StreamingJobOutputResource result = response.HasValue ? response.Value : null; + string outputName = "output3456"; + bool result = await collection.ExistsAsync(outputName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureDataLakeStoreOutputWithJSONSerialization() + public async Task Exists_GetAServiceBusTopicOutputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureDataLakeStore_JSON.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusTopic_CSV.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1216,8 +1174,8 @@ public async Task Get_GetAnAzureDataLakeStoreOutputWithJSONSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6912"; - string jobName = "sj3310"; + string resourceGroupName = "sjrg6450"; + string jobName = "sj7094"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1225,21 +1183,17 @@ public async Task Get_GetAnAzureDataLakeStoreOutputWithJSONSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output5195"; - StreamingJobOutputResource result = await collection.GetAsync(outputName); + string outputName = "output7886"; + bool result = await collection.ExistsAsync(outputName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAzureDataLakeStoreOutputWithJSONSerialization() + public async Task Exists_GetABlobOutputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureDataLakeStore_JSON.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_Blob_CSV.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1250,8 +1204,8 @@ public async Task Exists_GetAnAzureDataLakeStoreOutputWithJSONSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6912"; - string jobName = "sj3310"; + string resourceGroupName = "sjrg5023"; + string jobName = "sj900"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1259,7 +1213,7 @@ public async Task Exists_GetAnAzureDataLakeStoreOutputWithJSONSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output5195"; + string outputName = "output1623"; bool result = await collection.ExistsAsync(outputName); Console.WriteLine($"Succeeded: {result}"); @@ -1267,7 +1221,7 @@ public async Task Exists_GetAnAzureDataLakeStoreOutputWithJSONSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAzureDataLakeStoreOutputWithJSONSerialization() + public async Task Exists_GetAnAzureDataLakeStoreOutputWithJSONSerialization() { // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureDataLakeStore_JSON.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. @@ -1290,26 +1244,14 @@ public async Task GetIfExists_GetAnAzureDataLakeStoreOutputWithJSONSerialization // invoke the operation string outputName = "output5195"; - NullableResponse response = await collection.GetIfExistsAsync(outputName); - StreamingJobOutputResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(outputName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureDataWarehouseOutput() + public async Task Exists_GetAnAzureDataWarehouseOutput() { // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DataWarehouse.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. @@ -1332,20 +1274,16 @@ public async Task Get_GetAnAzureDataWarehouseOutput() // invoke the operation string outputName = "dwOutput"; - StreamingJobOutputResource result = await collection.GetAsync(outputName); + bool result = await collection.ExistsAsync(outputName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAzureDataWarehouseOutput() + public async Task Exists_GetAnAzureFunctionOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DataWarehouse.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureFunction.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1365,7 +1303,7 @@ public async Task Exists_GetAnAzureDataWarehouseOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "dwOutput"; + string outputName = "azureFunction1"; bool result = await collection.ExistsAsync(outputName); Console.WriteLine($"Succeeded: {result}"); @@ -1373,9 +1311,9 @@ public async Task Exists_GetAnAzureDataWarehouseOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAzureDataWarehouseOutput() + public async Task Exists_GetAnAzureSQLDatabaseOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DataWarehouse.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureSQL.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1386,8 +1324,8 @@ public async Task GetIfExists_GetAnAzureDataWarehouseOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg"; - string jobName = "sjName"; + string resourceGroupName = "sjrg2157"; + string jobName = "sj6458"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1395,29 +1333,17 @@ public async Task GetIfExists_GetAnAzureDataWarehouseOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "dwOutput"; - NullableResponse response = await collection.GetIfExistsAsync(outputName); - StreamingJobOutputResource result = response.HasValue ? response.Value : null; + string outputName = "output1755"; + bool result = await collection.ExistsAsync(outputName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureFunctionOutput() + public async Task Exists_GetAnAzureTableOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureFunction.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureTable.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1428,8 +1354,8 @@ public async Task Get_GetAnAzureFunctionOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg"; - string jobName = "sjName"; + string resourceGroupName = "sjrg5176"; + string jobName = "sj2790"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1437,21 +1363,17 @@ public async Task Get_GetAnAzureFunctionOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "azureFunction1"; - StreamingJobOutputResource result = await collection.GetAsync(outputName); + string outputName = "output958"; + bool result = await collection.ExistsAsync(outputName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAzureFunctionOutput() + public async Task Exists_GetAnEventHubOutputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureFunction.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_EventHub_JSON.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1462,8 +1384,8 @@ public async Task Exists_GetAnAzureFunctionOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg"; - string jobName = "sjName"; + string resourceGroupName = "sjrg6912"; + string jobName = "sj3310"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1471,7 +1393,7 @@ public async Task Exists_GetAnAzureFunctionOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "azureFunction1"; + string outputName = "output5195"; bool result = await collection.ExistsAsync(outputName); Console.WriteLine($"Succeeded: {result}"); @@ -1479,9 +1401,9 @@ public async Task Exists_GetAnAzureFunctionOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAzureFunctionOutput() + public async Task GetIfExists_GetADocumentDBOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureFunction.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DocumentDB.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1492,8 +1414,8 @@ public async Task GetIfExists_GetAnAzureFunctionOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg"; - string jobName = "sjName"; + string resourceGroupName = "sjrg7983"; + string jobName = "sj2331"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1501,7 +1423,7 @@ public async Task GetIfExists_GetAnAzureFunctionOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "azureFunction1"; + string outputName = "output3022"; NullableResponse response = await collection.GetIfExistsAsync(outputName); StreamingJobOutputResource result = response.HasValue ? response.Value : null; @@ -1521,9 +1443,9 @@ public async Task GetIfExists_GetAnAzureFunctionOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureSQLDatabaseOutput() + public async Task GetIfExists_GetAPowerBIOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureSQL.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_PowerBI.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1534,8 +1456,8 @@ public async Task Get_GetAnAzureSQLDatabaseOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg2157"; - string jobName = "sj6458"; + string resourceGroupName = "sjrg7983"; + string jobName = "sj2331"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1543,21 +1465,29 @@ public async Task Get_GetAnAzureSQLDatabaseOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output1755"; - StreamingJobOutputResource result = await collection.GetAsync(outputName); + string outputName = "output3022"; + NullableResponse response = await collection.GetIfExistsAsync(outputName); + StreamingJobOutputResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAzureSQLDatabaseOutput() + public async Task GetIfExists_GetAServiceBusQueueOutputWithAvroSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureSQL.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusQueue_Avro.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1568,8 +1498,8 @@ public async Task Exists_GetAnAzureSQLDatabaseOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg2157"; - string jobName = "sj6458"; + string resourceGroupName = "sjrg3410"; + string jobName = "sj5095"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1577,17 +1507,29 @@ public async Task Exists_GetAnAzureSQLDatabaseOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output1755"; - bool result = await collection.ExistsAsync(outputName); + string outputName = "output3456"; + NullableResponse response = await collection.GetIfExistsAsync(outputName); + StreamingJobOutputResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAzureSQLDatabaseOutput() + public async Task GetIfExists_GetAServiceBusTopicOutputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureSQL.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusTopic_CSV.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1598,8 +1540,8 @@ public async Task GetIfExists_GetAnAzureSQLDatabaseOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg2157"; - string jobName = "sj6458"; + string resourceGroupName = "sjrg6450"; + string jobName = "sj7094"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1607,7 +1549,7 @@ public async Task GetIfExists_GetAnAzureSQLDatabaseOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output1755"; + string outputName = "output7886"; NullableResponse response = await collection.GetIfExistsAsync(outputName); StreamingJobOutputResource result = response.HasValue ? response.Value : null; @@ -1627,9 +1569,9 @@ public async Task GetIfExists_GetAnAzureSQLDatabaseOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureTableOutput() + public async Task GetIfExists_GetABlobOutputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureTable.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_Blob_CSV.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1640,8 +1582,8 @@ public async Task Get_GetAnAzureTableOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg5176"; - string jobName = "sj2790"; + string resourceGroupName = "sjrg5023"; + string jobName = "sj900"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1649,21 +1591,29 @@ public async Task Get_GetAnAzureTableOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output958"; - StreamingJobOutputResource result = await collection.GetAsync(outputName); + string outputName = "output1623"; + NullableResponse response = await collection.GetIfExistsAsync(outputName); + StreamingJobOutputResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAzureTableOutput() + public async Task GetIfExists_GetAnAzureDataLakeStoreOutputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureTable.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureDataLakeStore_JSON.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1674,8 +1624,8 @@ public async Task Exists_GetAnAzureTableOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg5176"; - string jobName = "sj2790"; + string resourceGroupName = "sjrg6912"; + string jobName = "sj3310"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1683,17 +1633,29 @@ public async Task Exists_GetAnAzureTableOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output958"; - bool result = await collection.ExistsAsync(outputName); + string outputName = "output5195"; + NullableResponse response = await collection.GetIfExistsAsync(outputName); + StreamingJobOutputResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAzureTableOutput() + public async Task GetIfExists_GetAnAzureDataWarehouseOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureTable.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DataWarehouse.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1704,8 +1666,8 @@ public async Task GetIfExists_GetAnAzureTableOutput() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg5176"; - string jobName = "sj2790"; + string resourceGroupName = "sjrg"; + string jobName = "sjName"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1713,7 +1675,7 @@ public async Task GetIfExists_GetAnAzureTableOutput() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output958"; + string outputName = "dwOutput"; NullableResponse response = await collection.GetIfExistsAsync(outputName); StreamingJobOutputResource result = response.HasValue ? response.Value : null; @@ -1733,9 +1695,9 @@ public async Task GetIfExists_GetAnAzureTableOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnEventHubOutputWithJSONSerialization() + public async Task GetIfExists_GetAnAzureFunctionOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_EventHub_JSON.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureFunction.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1746,8 +1708,8 @@ public async Task Get_GetAnEventHubOutputWithJSONSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6912"; - string jobName = "sj3310"; + string resourceGroupName = "sjrg"; + string jobName = "sjName"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1755,21 +1717,29 @@ public async Task Get_GetAnEventHubOutputWithJSONSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output5195"; - StreamingJobOutputResource result = await collection.GetAsync(outputName); + string outputName = "azureFunction1"; + NullableResponse response = await collection.GetIfExistsAsync(outputName); + StreamingJobOutputResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnEventHubOutputWithJSONSerialization() + public async Task GetIfExists_GetAnAzureSQLDatabaseOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_EventHub_JSON.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureSQL.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1780,8 +1750,8 @@ public async Task Exists_GetAnEventHubOutputWithJSONSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6912"; - string jobName = "sj3310"; + string resourceGroupName = "sjrg2157"; + string jobName = "sj6458"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1789,17 +1759,29 @@ public async Task Exists_GetAnEventHubOutputWithJSONSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output5195"; - bool result = await collection.ExistsAsync(outputName); + string outputName = "output1755"; + NullableResponse response = await collection.GetIfExistsAsync(outputName); + StreamingJobOutputResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnEventHubOutputWithJSONSerialization() + public async Task GetIfExists_GetAnAzureTableOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_EventHub_JSON.json + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureTable.json // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1810,8 +1792,8 @@ public async Task GetIfExists_GetAnEventHubOutputWithJSONSerialization() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6912"; - string jobName = "sj3310"; + string resourceGroupName = "sjrg5176"; + string jobName = "sj2790"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); @@ -1819,7 +1801,7 @@ public async Task GetIfExists_GetAnEventHubOutputWithJSONSerialization() StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); // invoke the operation - string outputName = "output5195"; + string outputName = "output958"; NullableResponse response = await collection.GetIfExistsAsync(outputName); StreamingJobOutputResource result = response.HasValue ? response.Value : null; @@ -1839,10 +1821,10 @@ public async Task GetIfExists_GetAnEventHubOutputWithJSONSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllOutputsInAStreamingJob() + public async Task GetIfExists_GetAnEventHubOutputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_ListByStreamingJob.json - // this example is just showing the usage of "Outputs_ListByStreamingJob" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_EventHub_JSON.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1852,25 +1834,31 @@ public async Task GetAll_ListAllOutputsInAStreamingJob() // this example assumes you already have this StreamingJobResource created on azure // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg2157"; - string jobName = "sj6458"; + string resourceGroupName = "sjrg6912"; + string jobName = "sj3310"; ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // get the collection of this StreamingJobOutputResource StreamingJobOutputCollection collection = streamingJob.GetStreamingJobOutputs(); - // invoke the operation and iterate over the result - await foreach (StreamingJobOutputResource item in collection.GetAllAsync()) + // invoke the operation + string outputName = "output5195"; + NullableResponse response = await collection.GetIfExistsAsync(outputName); + StreamingJobOutputResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StreamingJobOutputData resourceData = item.Data; + StreamingJobOutputData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobOutputResource.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobOutputResource.cs index 206bca4bfa9b2..24353705473df 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobOutputResource.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobOutputResource.cs @@ -18,10 +18,10 @@ public partial class Sample_StreamingJobOutputResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateADocumentDBOutput() + public async Task Get_GetADocumentDBOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_DocumentDB.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DocumentDB.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,14 +38,7 @@ public async Task Update_UpdateADocumentDBOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new DocumentDbOutputDataSource() - { - PartitionKey = "differentPartitionKey", - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -56,10 +49,10 @@ public async Task Update_UpdateADocumentDBOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAPowerBIOutput() + public async Task Get_GetAPowerBIOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_PowerBI.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_PowerBI.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,14 +69,7 @@ public async Task Update_UpdateAPowerBIOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new PowerBIOutputDataSource() - { - Dataset = "differentDataset", - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -94,10 +80,10 @@ public async Task Update_UpdateAPowerBIOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAServiceBusQueueOutputWithAvroSerialization() + public async Task Get_GetAServiceBusQueueOutputWithAvroSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_ServiceBusQueue.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusQueue_Avro.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,19 +100,7 @@ public async Task Update_UpdateAServiceBusQueueOutputWithAvroSerialization() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new ServiceBusQueueOutputDataSource() - { - QueueName = "differentQueueName", - }, - Serialization = new JsonFormatSerialization() - { - Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, - Format = JsonOutputSerializationFormat.LineSeparated, - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -137,10 +111,10 @@ public async Task Update_UpdateAServiceBusQueueOutputWithAvroSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAServiceBusTopicOutputWithCSVSerialization() + public async Task Get_GetAServiceBusTopicOutputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_ServiceBusTopic.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusTopic_CSV.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -157,19 +131,7 @@ public async Task Update_UpdateAServiceBusTopicOutputWithCSVSerialization() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new ServiceBusTopicOutputDataSource() - { - TopicName = "differentTopicName", - }, - Serialization = new CsvFormatSerialization() - { - FieldDelimiter = "|", - Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -180,10 +142,10 @@ public async Task Update_UpdateAServiceBusTopicOutputWithCSVSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateABlobOutputWithCSVSerialization() + public async Task Get_GetABlobOutputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_Blob.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_Blob_CSV.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -200,19 +162,7 @@ public async Task Update_UpdateABlobOutputWithCSVSerialization() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new BlobOutputDataSource() - { - Container = "differentContainer", - }, - Serialization = new CsvFormatSerialization() - { - FieldDelimiter = "|", - Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -223,10 +173,10 @@ public async Task Update_UpdateABlobOutputWithCSVSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnAzureDataLakeStoreOutputWithJSONSerialization() + public async Task Get_GetAnAzureDataLakeStoreOutputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_AzureDataLakeStore.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureDataLakeStore_JSON.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -243,19 +193,7 @@ public async Task Update_UpdateAnAzureDataLakeStoreOutputWithJSONSerialization() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new DataLakeStoreOutputDataSource() - { - AccountName = "differentaccount", - }, - Serialization = new JsonFormatSerialization() - { - Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, - Format = JsonOutputSerializationFormat.LineSeparated, - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -266,10 +204,10 @@ public async Task Update_UpdateAnAzureDataLakeStoreOutputWithJSONSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnAzureDataWarehouseOutput() + public async Task Get_GetAnAzureDataWarehouseOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_DataWarehouse.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DataWarehouse.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -286,14 +224,7 @@ public async Task Update_UpdateAnAzureDataWarehouseOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new SqlDatabaseOutputDataSource() - { - Table = "differentTable", - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -304,10 +235,10 @@ public async Task Update_UpdateAnAzureDataWarehouseOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnAzureFunctionOutput() + public async Task Get_GetAnAzureFunctionOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_AzureFunction.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureFunction.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -324,14 +255,7 @@ public async Task Update_UpdateAnAzureFunctionOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new FunctionOutputDataSource() - { - FunctionName = "differentFunctionName", - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -342,10 +266,10 @@ public async Task Update_UpdateAnAzureFunctionOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnAzureSQLDatabaseOutput() + public async Task Get_GetAnAzureSQLDatabaseOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_AzureSQL.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureSQL.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -362,14 +286,7 @@ public async Task Update_UpdateAnAzureSQLDatabaseOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new SqlDatabaseOutputDataSource() - { - Table = "differentTable", - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -380,10 +297,10 @@ public async Task Update_UpdateAnAzureSQLDatabaseOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnAzureTableOutput() + public async Task Get_GetAnAzureTableOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_AzureTable.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureTable.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -400,14 +317,7 @@ public async Task Update_UpdateAnAzureTableOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new TableOutputDataSource() - { - PartitionKey = "differentPartitionKey", - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -418,10 +328,10 @@ public async Task Update_UpdateAnAzureTableOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnEventHubOutputWithJSONSerialization() + public async Task Get_GetAnEventHubOutputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_EventHub.json - // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_EventHub_JSON.json + // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -438,19 +348,7 @@ public async Task Update_UpdateAnEventHubOutputWithJSONSerialization() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputData data = new StreamingJobOutputData() - { - Datasource = new EventHubOutputDataSource() - { - PartitionKey = "differentPartitionKey", - }, - Serialization = new JsonFormatSerialization() - { - Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, - Format = JsonOutputSerializationFormat.LineSeparated, - }, - }; - StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); + StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -488,10 +386,10 @@ public async Task Delete_DeleteAnOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADocumentDBOutput() + public async Task Update_UpdateADocumentDBOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DocumentDB.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_DocumentDB.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -508,7 +406,14 @@ public async Task Get_GetADocumentDBOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new DocumentDbOutputDataSource + { + PartitionKey = "differentPartitionKey", + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -519,10 +424,10 @@ public async Task Get_GetADocumentDBOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPowerBIOutput() + public async Task Update_UpdateAPowerBIOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_PowerBI.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_PowerBI.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -539,7 +444,14 @@ public async Task Get_GetAPowerBIOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new PowerBIOutputDataSource + { + Dataset = "differentDataset", + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -550,10 +462,10 @@ public async Task Get_GetAPowerBIOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServiceBusQueueOutputWithAvroSerialization() + public async Task Update_UpdateAServiceBusQueueOutputWithAvroSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusQueue_Avro.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_ServiceBusQueue.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -570,7 +482,19 @@ public async Task Get_GetAServiceBusQueueOutputWithAvroSerialization() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new ServiceBusQueueOutputDataSource + { + QueueName = "differentQueueName", + }, + Serialization = new JsonFormatSerialization + { + Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, + Format = JsonOutputSerializationFormat.LineSeparated, + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -581,10 +505,10 @@ public async Task Get_GetAServiceBusQueueOutputWithAvroSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServiceBusTopicOutputWithCSVSerialization() + public async Task Update_UpdateAServiceBusTopicOutputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_ServiceBusTopic_CSV.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_ServiceBusTopic.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -601,7 +525,19 @@ public async Task Get_GetAServiceBusTopicOutputWithCSVSerialization() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new ServiceBusTopicOutputDataSource + { + TopicName = "differentTopicName", + }, + Serialization = new CsvFormatSerialization + { + FieldDelimiter = "|", + Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -612,10 +548,10 @@ public async Task Get_GetAServiceBusTopicOutputWithCSVSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetABlobOutputWithCSVSerialization() + public async Task Update_UpdateABlobOutputWithCSVSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_Blob_CSV.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_Blob.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -632,7 +568,19 @@ public async Task Get_GetABlobOutputWithCSVSerialization() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new BlobOutputDataSource + { + Container = "differentContainer", + }, + Serialization = new CsvFormatSerialization + { + FieldDelimiter = "|", + Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -643,10 +591,10 @@ public async Task Get_GetABlobOutputWithCSVSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureDataLakeStoreOutputWithJSONSerialization() + public async Task Update_UpdateAnAzureDataLakeStoreOutputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureDataLakeStore_JSON.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_AzureDataLakeStore.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -663,7 +611,19 @@ public async Task Get_GetAnAzureDataLakeStoreOutputWithJSONSerialization() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new DataLakeStoreOutputDataSource + { + AccountName = "differentaccount", + }, + Serialization = new JsonFormatSerialization + { + Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, + Format = JsonOutputSerializationFormat.LineSeparated, + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -674,10 +634,10 @@ public async Task Get_GetAnAzureDataLakeStoreOutputWithJSONSerialization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureDataWarehouseOutput() + public async Task Update_UpdateAnAzureDataWarehouseOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_DataWarehouse.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_DataWarehouse.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -694,7 +654,14 @@ public async Task Get_GetAnAzureDataWarehouseOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new SqlDatabaseOutputDataSource + { + Table = "differentTable", + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -705,10 +672,10 @@ public async Task Get_GetAnAzureDataWarehouseOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureFunctionOutput() + public async Task Update_UpdateAnAzureFunctionOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureFunction.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_AzureFunction.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -725,7 +692,14 @@ public async Task Get_GetAnAzureFunctionOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new FunctionOutputDataSource + { + FunctionName = "differentFunctionName", + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -736,10 +710,10 @@ public async Task Get_GetAnAzureFunctionOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureSQLDatabaseOutput() + public async Task Update_UpdateAnAzureSQLDatabaseOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureSQL.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_AzureSQL.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -756,7 +730,14 @@ public async Task Get_GetAnAzureSQLDatabaseOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new SqlDatabaseOutputDataSource + { + Table = "differentTable", + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -767,10 +748,10 @@ public async Task Get_GetAnAzureSQLDatabaseOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureTableOutput() + public async Task Update_UpdateAnAzureTableOutput() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_AzureTable.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_AzureTable.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -787,7 +768,14 @@ public async Task Get_GetAnAzureTableOutput() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new TableOutputDataSource + { + PartitionKey = "differentPartitionKey", + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -798,10 +786,10 @@ public async Task Get_GetAnAzureTableOutput() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnEventHubOutputWithJSONSerialization() + public async Task Update_UpdateAnEventHubOutputWithJSONSerialization() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Get_EventHub_JSON.json - // this example is just showing the usage of "Outputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Output_Update_EventHub.json + // this example is just showing the usage of "Outputs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -818,7 +806,19 @@ public async Task Get_GetAnEventHubOutputWithJSONSerialization() StreamingJobOutputResource streamingJobOutput = client.GetStreamingJobOutputResource(streamingJobOutputResourceId); // invoke the operation - StreamingJobOutputResource result = await streamingJobOutput.GetAsync(); + StreamingJobOutputData data = new StreamingJobOutputData + { + Datasource = new EventHubOutputDataSource + { + PartitionKey = "differentPartitionKey", + }, + Serialization = new JsonFormatSerialization + { + Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, + Format = JsonOutputSerializationFormat.LineSeparated, + }, + }; + StreamingJobOutputResource result = await streamingJobOutput.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobResource.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobResource.cs index a82459fa38624..0fba6e8bdae53 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobResource.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.StreamAnalytics.Models; using NUnit.Framework; @@ -17,67 +16,6 @@ namespace Azure.ResourceManager.StreamAnalytics.Samples { public partial class Sample_StreamingJobResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAStreamingJob() - { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Update.json - // this example is just showing the usage of "StreamingJobs_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this StreamingJobResource created on azure - // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource - string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6936"; - string jobName = "sj59"; - ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); - StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); - - // invoke the operation - StreamingJobData data = new StreamingJobData(new AzureLocation("placeholder")) - { - EventsOutOfOrderMaxDelayInSeconds = 21, - EventsLateArrivalMaxDelayInSeconds = 13, - }; - StreamingJobResource result = await streamingJob.UpdateAsync(data); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAStreamingJob() - { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Delete.json - // this example is just showing the usage of "StreamingJobs_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this StreamingJobResource created on azure - // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource - string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - string resourceGroupName = "sjrg6936"; - string jobName = "sj59"; - ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); - StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); - - // invoke the operation - await streamingJob.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAStreamingJobAndDoNotUseTheExpandODataQueryParameter() @@ -141,65 +79,63 @@ public async Task Get_GetAStreamingJobAndUseTheExpandODataQueryParameterToExpand [Test] [Ignore("Only validating compilation of examples")] - public async Task GetStreamingJobs_ListAllStreamingJobsInASubscriptionAndDoNotUseTheExpandODataQueryParameter() + public async Task Delete_DeleteAStreamingJob() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_List_BySubscription_NoExpand.json - // this example is just showing the usage of "StreamingJobs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Delete.json + // this example is just showing the usage of "StreamingJobs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this StreamingJobResource created on azure + // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "sjrg6936"; + string jobName = "sj59"; + ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); + StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); - // invoke the operation and iterate over the result - await foreach (StreamingJobResource item in subscriptionResource.GetStreamingJobsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + await streamingJob.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetStreamingJobs_ListAllStreamingJobsInASubscriptionAndUseTheExpandODataQueryParameterToExpandInputsOutputsTransformationAndFunctions() + public async Task Update_UpdateAStreamingJob() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_List_BySubscription_Expand.json - // this example is just showing the usage of "StreamingJobs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_Update.json + // this example is just showing the usage of "StreamingJobs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this StreamingJobResource created on azure + // for more information of creating StreamingJobResource, please refer to the document of StreamingJobResource string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "sjrg6936"; + string jobName = "sj59"; + ResourceIdentifier streamingJobResourceId = StreamingJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); + StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); - // invoke the operation and iterate over the result - string expand = "inputs,outputs,transformation,functions"; - await foreach (StreamingJobResource item in subscriptionResource.GetStreamingJobsAsync(expand: expand)) + // invoke the operation + StreamingJobData data = new StreamingJobData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EventsOutOfOrderMaxDelayInSeconds = 21, + EventsLateArrivalMaxDelayInSeconds = 13, + }; + StreamingJobResource result = await streamingJob.UpdateAsync(data); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -223,7 +159,7 @@ public async Task Start_StartAStreamingJobWithCustomTimeOutputStartMode() StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // invoke the operation - StartStreamingJobContent content = new StartStreamingJobContent() + StartStreamingJobContent content = new StartStreamingJobContent { OutputStartMode = StreamingJobOutputStartMode.CustomTime, OutputStartOn = DateTimeOffset.Parse("2012-12-12T12:12:12Z"), @@ -254,7 +190,7 @@ public async Task Start_StartAStreamingJobWithJobStartTimeOutputStartMode() StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // invoke the operation - StartStreamingJobContent content = new StartStreamingJobContent() + StartStreamingJobContent content = new StartStreamingJobContent { OutputStartMode = StreamingJobOutputStartMode.JobStartTime, }; @@ -284,7 +220,7 @@ public async Task Start_StartAStreamingJobWithLastOutputEventTimeOutputStartMode StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // invoke the operation - StartStreamingJobContent content = new StartStreamingJobContent() + StartStreamingJobContent content = new StartStreamingJobContent { OutputStartMode = StreamingJobOutputStartMode.LastOutputEventTime, }; @@ -340,7 +276,7 @@ public async Task Scale_ScaleAStreamingJob() StreamingJobResource streamingJob = client.GetStreamingJobResource(streamingJobResourceId); // invoke the operation - ScaleStreamingJobContent content = new ScaleStreamingJobContent() + ScaleStreamingJobContent content = new ScaleStreamingJobContent { StreamingUnits = 36, }; diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobTransformationCollection.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobTransformationCollection.cs index db84cae7b9100..c49d83204a8c9 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobTransformationCollection.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobTransformationCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_CreateATransformation() // invoke the operation string transformationName = "transformation952"; - StreamingJobTransformationData data = new StreamingJobTransformationData() + StreamingJobTransformationData data = new StreamingJobTransformationData { StreamingUnits = 6, Query = "Select Id, Name from inputtest", diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobTransformationResource.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobTransformationResource.cs index 2fb90fac633e5..ef9520da1ad99 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobTransformationResource.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_StreamingJobTransformationResource.cs @@ -17,10 +17,10 @@ public partial class Sample_StreamingJobTransformationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateATransformation() + public async Task Get_GetATransformation() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Transformation_Update.json - // this example is just showing the usage of "Transformations_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Transformation_Get.json + // this example is just showing the usage of "Transformations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,11 +37,7 @@ public async Task Update_UpdateATransformation() StreamingJobTransformationResource streamingJobTransformation = client.GetStreamingJobTransformationResource(streamingJobTransformationResourceId); // invoke the operation - StreamingJobTransformationData data = new StreamingJobTransformationData() - { - Query = "New query", - }; - StreamingJobTransformationResource result = await streamingJobTransformation.UpdateAsync(data); + StreamingJobTransformationResource result = await streamingJobTransformation.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +48,10 @@ public async Task Update_UpdateATransformation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetATransformation() + public async Task Update_UpdateATransformation() { - // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Transformation_Get.json - // this example is just showing the usage of "Transformations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/Transformation_Update.json + // this example is just showing the usage of "Transformations_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,7 +68,11 @@ public async Task Get_GetATransformation() StreamingJobTransformationResource streamingJobTransformation = client.GetStreamingJobTransformationResource(streamingJobTransformationResourceId); // invoke the operation - StreamingJobTransformationResource result = await streamingJobTransformation.GetAsync(); + StreamingJobTransformationData data = new StreamingJobTransformationData + { + Query = "New query", + }; + StreamingJobTransformationResource result = await streamingJobTransformation.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index e316be32f7b18..c2caf6d2e6ed2 100644 --- a/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/streamanalytics/Azure.ResourceManager.StreamAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,69 @@ namespace Azure.ResourceManager.StreamAnalytics.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStreamingJobs_ListAllStreamingJobsInASubscriptionAndDoNotUseTheExpandODataQueryParameter() + { + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_List_BySubscription_NoExpand.json + // this example is just showing the usage of "StreamingJobs_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (StreamingJobResource item in subscriptionResource.GetStreamingJobsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStreamingJobs_ListAllStreamingJobsInASubscriptionAndUseTheExpandODataQueryParameterToExpandInputsOutputsTransformationAndFunctions() + { + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2021-10-01-preview/examples/StreamingJob_List_BySubscription_Expand.json + // this example is just showing the usage of "StreamingJobs_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "56b5e0a9-b645-407d-99b0-c64f86013e3d"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string expand = "inputs,outputs,transformation,functions"; + await foreach (StreamingJobResource item in subscriptionResource.GetStreamingJobsAsync(expand: expand)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetQuotasSubscriptions_ListSubscriptionQuotaInformationInWestUS() @@ -74,50 +137,42 @@ public async Task TestQuerySubscription_TestTheStreamAnalyticsQuery() EventsLateArrivalMaxDelayInSeconds = 5, DataLocalion = new AzureLocation("en-US"), CompatibilityLevel = StreamingJobCompatibilityLevel.Level1_0, - Inputs = -{ -new StreamingJobInputData() + Inputs = {new StreamingJobInputData { -Properties = new StreamInputProperties() +Properties = new StreamInputProperties { -Datasource = new RawStreamInputDataSource() +Datasource = new RawStreamInputDataSource { PayloadUri = new Uri("http://myinput.com"), }, -Serialization = new JsonFormatSerialization() +Serialization = new JsonFormatSerialization { Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, }, }, Name = "inputtest", -} -}, - Transformation = new StreamingJobTransformationData() +}}, + Transformation = new StreamingJobTransformationData { StreamingUnits = 1, Query = "Select Id, Name from inputtest", Name = "transformationtest", }, - Outputs = -{ -new StreamingJobOutputData() + Outputs = {new StreamingJobOutputData { -Datasource = new RawOutputDatasource() +Datasource = new RawOutputDatasource { PayloadUri = new Uri("http://myoutput.com"), }, Serialization = new JsonFormatSerialization(), Name = "outputtest", -} -}, - Functions = -{ -}, +}}, + Functions = { }, Tags = { ["key1"] = "value1", ["key3"] = "value3", -["randomKey"] = "randomValue", +["randomKey"] = "randomValue" }, }) { @@ -152,24 +207,18 @@ public async Task CompileQuerySubscription_CompileTheStreamAnalyticsQuery() AzureLocation location = new AzureLocation("West US"); StreamAnalyticsCompileQuery compileQuery = new StreamAnalyticsCompileQuery("SELECT\r\n *\r\nINTO\r\n [output1]\r\nFROM\r\n [input1]", StreamingJobType.Cloud) { - Inputs = -{ -new StreamAnalyticsQueryInput("input1","Stream") -}, - Functions = + Inputs = { new StreamAnalyticsQueryInput("input1", "Stream") }, + Functions = {new StreamAnalyticsQueryFunction("function1", "Scalar", "Microsoft.StreamAnalytics/JavascriptUdf", new StreamingJobFunctionInput[] { -new StreamAnalyticsQueryFunction("function1","Scalar","Microsoft.StreamAnalytics/JavascriptUdf",new StreamingJobFunctionInput[] -{ -new StreamingJobFunctionInput() +new StreamingJobFunctionInput { DataType = "any", -IsConfigurationParameter = null, +IsConfigurationParameter = default, } -},new StreamingJobFunctionOutput() +}, new StreamingJobFunctionOutput { DataType = "bigint", -}) -}, +})}, CompatibilityLevel = StreamingJobCompatibilityLevel.Level1_2, }; StreamAnalyticsQueryCompilationResult result = await subscriptionResource.CompileQuerySubscriptionAsync(location, compileQuery); @@ -197,29 +246,26 @@ public async Task SampleInputSubscription_SampleTheStreamAnalyticsInputData() // invoke the operation AzureLocation location = new AzureLocation("West US"); - StreamAnalyticsSampleInputContent content = new StreamAnalyticsSampleInputContent() + StreamAnalyticsSampleInputContent content = new StreamAnalyticsSampleInputContent { - Input = new StreamingJobInputData() + Input = new StreamingJobInputData { - Properties = new StreamInputProperties() + Properties = new StreamInputProperties { - Datasource = new BlobStreamInputDataSource() + Datasource = new BlobStreamInputDataSource { - StorageAccounts = -{ -new StreamAnalyticsStorageAccount() + StorageAccounts = {new StreamAnalyticsStorageAccount { AccountName = "someAccountName", AccountKey = "someAccountKey==", -} -}, +}}, Container = "state", PathPattern = "{date}/{time}", DateFormat = "yyyy/MM/dd", TimeFormat = "HH", SourcePartitionCount = 16, }, - Serialization = new CsvFormatSerialization() + Serialization = new CsvFormatSerialization { FieldDelimiter = ",", Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, @@ -256,27 +302,24 @@ public async Task TestInputSubscription_TestTheStreamAnalyticsInput() // invoke the operation AzureLocation location = new AzureLocation("West US"); - StreamAnalyticsTestContent content = new StreamAnalyticsTestContent(new StreamingJobInputData() + StreamAnalyticsTestContent content = new StreamAnalyticsTestContent(new StreamingJobInputData { - Properties = new StreamInputProperties() + Properties = new StreamInputProperties { - Datasource = new BlobStreamInputDataSource() + Datasource = new BlobStreamInputDataSource { - StorageAccounts = -{ -new StreamAnalyticsStorageAccount() + StorageAccounts = {new StreamAnalyticsStorageAccount { AccountName = "someAccountName", AccountKey = "someAccountKey==", -} -}, +}}, Container = "state", PathPattern = "{date}/{time}", DateFormat = "yyyy/MM/dd", TimeFormat = "HH", SourcePartitionCount = 16, }, - Serialization = new CsvFormatSerialization() + Serialization = new CsvFormatSerialization { FieldDelimiter = ",", Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, @@ -309,24 +352,21 @@ public async Task TestOutputSubscription_TestTheStreamAnalyticsOutput() // invoke the operation AzureLocation location = new AzureLocation("West US"); - StreamAnalyticsTestOutput testOutput = new StreamAnalyticsTestOutput(new StreamingJobOutputData() + StreamAnalyticsTestOutput testOutput = new StreamAnalyticsTestOutput(new StreamingJobOutputData { - Datasource = new BlobOutputDataSource() + Datasource = new BlobOutputDataSource { - StorageAccounts = -{ -new StreamAnalyticsStorageAccount() + StorageAccounts = {new StreamAnalyticsStorageAccount { AccountName = "someAccountName", AccountKey = "accountKey==", -} -}, +}}, Container = "state", PathPattern = "{date}/{time}", DateFormat = "yyyy/MM/dd", TimeFormat = "HH", }, - Serialization = new CsvFormatSerialization() + Serialization = new CsvFormatSerialization { FieldDelimiter = ",", Encoding = StreamAnalyticsDataSerializationEncoding.Utf8, @@ -337,5 +377,36 @@ public async Task TestOutputSubscription_TestTheStreamAnalyticsOutput() Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStreamAnalyticsClusters_ListTheClustersInASubscription() + { + // Generated from example definition: specification/streamanalytics/resource-manager/Microsoft.StreamAnalytics/preview/2020-03-01-preview/examples/Cluster_ListBySubscription.json + // this example is just showing the usage of "Clusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (StreamAnalyticsClusterResource item in subscriptionResource.GetStreamAnalyticsClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamAnalyticsClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_BillingAccountPolicyCollection.cs b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_BillingAccountPolicyCollection.cs index 4e75a3213859b..3a3969b4aca3e 100644 --- a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_BillingAccountPolicyCollection.cs +++ b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_BillingAccountPolicyCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Subscription.Samples @@ -27,9 +28,7 @@ public async Task Get_GetBillingAccountPolicy() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountPolicyResource BillingAccountPolicyCollection collection = tenantResource.GetBillingAccountPolicies(); @@ -57,9 +56,7 @@ public async Task Exists_GetBillingAccountPolicy() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountPolicyResource BillingAccountPolicyCollection collection = tenantResource.GetBillingAccountPolicies(); @@ -83,9 +80,7 @@ public async Task GetIfExists_GetBillingAccountPolicy() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountPolicyResource BillingAccountPolicyCollection collection = tenantResource.GetBillingAccountPolicies(); diff --git a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionAliasCollection.cs b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionAliasCollection.cs index 1e8326917f9f8..92ef7e09a0f6d 100644 --- a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionAliasCollection.cs +++ b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionAliasCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using Azure.ResourceManager.Subscription.Models; using NUnit.Framework; @@ -28,22 +29,20 @@ public async Task CreateOrUpdate_CreateAlias() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SubscriptionAliasResource SubscriptionAliasCollection collection = tenantResource.GetSubscriptionAliases(); // invoke the operation string aliasName = "aliasForNewSub"; - SubscriptionAliasCreateOrUpdateContent content = new SubscriptionAliasCreateOrUpdateContent() + SubscriptionAliasCreateOrUpdateContent content = new SubscriptionAliasCreateOrUpdateContent { DisplayName = "Test Subscription", Workload = SubscriptionWorkload.Production, BillingScope = "/billingAccounts/af6231a7-7f8d-4fcc-a993-dd8466108d07:c663dac6-a9a5-405a-8938-cd903e12ab5b_2019_05_31/billingProfiles/QWDQ-QWHI-AUW-SJDO-DJH/invoiceSections/FEUF-EUHE-ISJ-SKDW-DJH", SubscriptionId = null, - AdditionalProperties = new SubscriptionAliasAdditionalProperties() + AdditionalProperties = new SubscriptionAliasAdditionalProperties { ManagementGroupId = null, SubscriptionTenantId = Guid.Parse("66f6e4d6-07dc-4aea-94ea-e12d3026a3c8"), @@ -52,7 +51,7 @@ public async Task CreateOrUpdate_CreateAlias() { ["tag1"] = "Messi", ["tag2"] = "Ronaldo", -["tag3"] = "Lebron", +["tag3"] = "Lebron" }, }, }; @@ -78,9 +77,7 @@ public async Task Get_GetAlias() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SubscriptionAliasResource SubscriptionAliasCollection collection = tenantResource.GetSubscriptionAliases(); @@ -96,6 +93,36 @@ public async Task Get_GetAlias() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAlias() + { + // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/listAlias.json + // this example is just showing the usage of "Alias_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this SubscriptionAliasResource + SubscriptionAliasCollection collection = tenantResource.GetSubscriptionAliases(); + + // invoke the operation and iterate over the result + await foreach (SubscriptionAliasResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionAliasData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAlias() @@ -108,9 +135,7 @@ public async Task Exists_GetAlias() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SubscriptionAliasResource SubscriptionAliasCollection collection = tenantResource.GetSubscriptionAliases(); @@ -134,9 +159,7 @@ public async Task GetIfExists_GetAlias() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SubscriptionAliasResource SubscriptionAliasCollection collection = tenantResource.GetSubscriptionAliases(); @@ -159,37 +182,5 @@ public async Task GetIfExists_GetAlias() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAlias() - { - // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/listAlias.json - // this example is just showing the usage of "Alias_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this SubscriptionAliasResource - SubscriptionAliasCollection collection = tenantResource.GetSubscriptionAliases(); - - // invoke the operation and iterate over the result - await foreach (SubscriptionAliasResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionAliasData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionAliasResource.cs b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionAliasResource.cs index c61fc4bd41106..c85de7e53f9c3 100644 --- a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionAliasResource.cs +++ b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionAliasResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SubscriptionAliasResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAlias() + public async Task Get_GetAlias() { - // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/createAlias.json - // this example is just showing the usage of "Alias_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/getAlias.json + // this example is just showing the usage of "Alias_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,27 +35,7 @@ public async Task Update_CreateAlias() SubscriptionAliasResource subscriptionAlias = client.GetSubscriptionAliasResource(subscriptionAliasResourceId); // invoke the operation - SubscriptionAliasCreateOrUpdateContent content = new SubscriptionAliasCreateOrUpdateContent() - { - DisplayName = "Test Subscription", - Workload = SubscriptionWorkload.Production, - BillingScope = "/billingAccounts/af6231a7-7f8d-4fcc-a993-dd8466108d07:c663dac6-a9a5-405a-8938-cd903e12ab5b_2019_05_31/billingProfiles/QWDQ-QWHI-AUW-SJDO-DJH/invoiceSections/FEUF-EUHE-ISJ-SKDW-DJH", - SubscriptionId = null, - AdditionalProperties = new SubscriptionAliasAdditionalProperties() - { - ManagementGroupId = null, - SubscriptionTenantId = Guid.Parse("66f6e4d6-07dc-4aea-94ea-e12d3026a3c8"), - SubscriptionOwnerId = "f09b39eb-c496-482c-9ab9-afd799572f4c", - Tags = -{ -["tag1"] = "Messi", -["tag2"] = "Ronaldo", -["tag3"] = "Lebron", -}, - }, - }; - ArmOperation lro = await subscriptionAlias.UpdateAsync(WaitUntil.Completed, content); - SubscriptionAliasResource result = lro.Value; + SubscriptionAliasResource result = await subscriptionAlias.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -66,10 +46,10 @@ public async Task Update_CreateAlias() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAlias() + public async Task Delete_DeleteAlias() { - // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/getAlias.json - // this example is just showing the usage of "Alias_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/deleteAlias.json + // this example is just showing the usage of "Alias_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -83,21 +63,17 @@ public async Task Get_GetAlias() SubscriptionAliasResource subscriptionAlias = client.GetSubscriptionAliasResource(subscriptionAliasResourceId); // invoke the operation - SubscriptionAliasResource result = await subscriptionAlias.GetAsync(); + await subscriptionAlias.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionAliasData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAlias() + public async Task Update_CreateAlias() { - // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/deleteAlias.json - // this example is just showing the usage of "Alias_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/createAlias.json + // this example is just showing the usage of "Alias_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +87,33 @@ public async Task Delete_DeleteAlias() SubscriptionAliasResource subscriptionAlias = client.GetSubscriptionAliasResource(subscriptionAliasResourceId); // invoke the operation - await subscriptionAlias.DeleteAsync(WaitUntil.Completed); + SubscriptionAliasCreateOrUpdateContent content = new SubscriptionAliasCreateOrUpdateContent + { + DisplayName = "Test Subscription", + Workload = SubscriptionWorkload.Production, + BillingScope = "/billingAccounts/af6231a7-7f8d-4fcc-a993-dd8466108d07:c663dac6-a9a5-405a-8938-cd903e12ab5b_2019_05_31/billingProfiles/QWDQ-QWHI-AUW-SJDO-DJH/invoiceSections/FEUF-EUHE-ISJ-SKDW-DJH", + SubscriptionId = null, + AdditionalProperties = new SubscriptionAliasAdditionalProperties + { + ManagementGroupId = null, + SubscriptionTenantId = Guid.Parse("66f6e4d6-07dc-4aea-94ea-e12d3026a3c8"), + SubscriptionOwnerId = "f09b39eb-c496-482c-9ab9-afd799572f4c", + Tags = +{ +["tag1"] = "Messi", +["tag2"] = "Ronaldo", +["tag3"] = "Lebron" +}, + }, + }; + ArmOperation lro = await subscriptionAlias.UpdateAsync(WaitUntil.Completed, content); + SubscriptionAliasResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionAliasData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 001aeeb166456..528fdeef6f6af 100644 --- a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -60,7 +60,7 @@ public async Task RenameSubscription_RenameSubscription() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - SubscriptionName body = new SubscriptionName() + SubscriptionName body = new SubscriptionName { SubscriptionNameValue = "Test Sub", }; diff --git a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_TenantPolicyResource.cs b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_TenantPolicyResource.cs index bc37cd2de5e4a..02d773b91dbbf 100644 --- a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_TenantPolicyResource.cs +++ b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_TenantPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_TenantPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TenantPolicy() + public async Task Get_GetTenantPolicy() { - // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/changeTenantPolicy.json - // this example is just showing the usage of "SubscriptionPolicy_AddUpdatePolicyForTenant" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/getTenantPolicy.json + // this example is just showing the usage of "SubscriptionPolicy_GetPolicyForTenant" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,17 +34,7 @@ public async Task CreateOrUpdate_TenantPolicy() TenantPolicyResource tenantPolicy = client.GetTenantPolicyResource(tenantPolicyResourceId); // invoke the operation - TenantPolicyCreateOrUpdateContent content = new TenantPolicyCreateOrUpdateContent() - { - BlockSubscriptionsLeavingTenant = true, - BlockSubscriptionsIntoTenant = true, - ExemptedPrincipals = -{ -Guid.Parse("e879cf0f-2b4d-5431-109a-f72fc9868693"),Guid.Parse("9792da87-c97b-410d-a97d-27021ba09ce6") -}, - }; - ArmOperation lro = await tenantPolicy.CreateOrUpdateAsync(WaitUntil.Completed, content); - TenantPolicyResource result = lro.Value; + TenantPolicyResource result = await tenantPolicy.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +45,10 @@ public async Task CreateOrUpdate_TenantPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTenantPolicy() + public async Task CreateOrUpdate_TenantPolicy() { - // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/getTenantPolicy.json - // this example is just showing the usage of "SubscriptionPolicy_GetPolicyForTenant" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/subscription/resource-manager/Microsoft.Subscription/stable/2021-10-01/examples/changeTenantPolicy.json + // this example is just showing the usage of "SubscriptionPolicy_AddUpdatePolicyForTenant" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,7 +61,14 @@ public async Task Get_GetTenantPolicy() TenantPolicyResource tenantPolicy = client.GetTenantPolicyResource(tenantPolicyResourceId); // invoke the operation - TenantPolicyResource result = await tenantPolicy.GetAsync(); + TenantPolicyCreateOrUpdateContent content = new TenantPolicyCreateOrUpdateContent + { + BlockSubscriptionsLeavingTenant = true, + BlockSubscriptionsIntoTenant = true, + ExemptedPrincipals = { Guid.Parse("e879cf0f-2b4d-5431-109a-f72fc9868693"), Guid.Parse("9792da87-c97b-410d-a97d-27021ba09ce6") }, + }; + ArmOperation lro = await tenantPolicy.CreateOrUpdateAsync(WaitUntil.Completed, content); + TenantPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index a035b5ee9fc99..194568a20e6b4 100644 --- a/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/subscription/Azure.ResourceManager.Subscription/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using Azure.ResourceManager.Subscription.Models; using NUnit.Framework; @@ -28,13 +29,11 @@ public async Task AcceptSubscriptionOwnership_AcceptOwnership() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; - AcceptOwnershipContent content = new AcceptOwnershipContent() + AcceptOwnershipContent content = new AcceptOwnershipContent { Properties = new AcceptOwnershipRequestProperties("Test Subscription") { @@ -43,7 +42,7 @@ public async Task AcceptSubscriptionOwnership_AcceptOwnership() { ["tag1"] = "Messi", ["tag2"] = "Ronaldo", -["tag3"] = "Lebron", +["tag3"] = "Lebron" }, }, }; @@ -64,9 +63,7 @@ public async Task GetAcceptOwnershipStatus_AcceptOwnershipStatus() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string subscriptionId = "291bba3f-e0a5-47bc-a099-3bdcb2a50a05"; diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_ProblemClassificationCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_ProblemClassificationCollection.cs index 88c14591c221d..b1fbf098c33f6 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_ProblemClassificationCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_ProblemClassificationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ProblemClassificationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfProblemClassificationsForAServiceForWhichASupportTicketCanBeCreated() + public async Task Get_GetsDetailsOfProblemClassificationForAzureService() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListProblemClassifications.json - // this example is just showing the usage of "ProblemClassifications_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetProblemClassification.json + // this example is just showing the usage of "ProblemClassifications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,25 +36,23 @@ public async Task GetAll_GetsListOfProblemClassificationsForAServiceForWhichASup // get the collection of this ProblemClassificationResource ProblemClassificationCollection collection = supportAzureService.GetProblemClassifications(); - // invoke the operation and iterate over the result - await foreach (ProblemClassificationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProblemClassificationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string problemClassificationName = "problemClassification_guid"; + ProblemClassificationResource result = await collection.GetAsync(problemClassificationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProblemClassificationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsDetailsOfProblemClassificationForAzureService() + public async Task GetAll_GetsListOfProblemClassificationsForAServiceForWhichASupportTicketCanBeCreated() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetProblemClassification.json - // this example is just showing the usage of "ProblemClassifications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListProblemClassifications.json + // this example is just showing the usage of "ProblemClassifications_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,15 +68,17 @@ public async Task Get_GetsDetailsOfProblemClassificationForAzureService() // get the collection of this ProblemClassificationResource ProblemClassificationCollection collection = supportAzureService.GetProblemClassifications(); - // invoke the operation - string problemClassificationName = "problemClassification_guid"; - ProblemClassificationResource result = await collection.GetAsync(problemClassificationName); + // invoke the operation and iterate over the result + await foreach (ProblemClassificationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProblemClassificationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProblemClassificationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionFileWorkspaceCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionFileWorkspaceCollection.cs index d9d1b225b5819..f1d5ca80a0c04 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionFileWorkspaceCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionFileWorkspaceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SubscriptionFileWorkspaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDetailsOfASubscriptionFileWorkspace() + public async Task CreateOrUpdate_CreateAFileWorkspaceForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetFileWorkspaceDetailsForSubscription.json - // this example is just showing the usage of "FileWorkspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateFileWorkspaceForSubscription.json + // this example is just showing the usage of "FileWorkspaces_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,7 +39,8 @@ public async Task Get_GetDetailsOfASubscriptionFileWorkspace() // invoke the operation string fileWorkspaceName = "testworkspace"; - SubscriptionFileWorkspaceResource result = await collection.GetAsync(fileWorkspaceName); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileWorkspaceName); + SubscriptionFileWorkspaceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,7 +51,7 @@ public async Task Get_GetDetailsOfASubscriptionFileWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfASubscriptionFileWorkspace() + public async Task Get_GetDetailsOfASubscriptionFileWorkspace() { // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetFileWorkspaceDetailsForSubscription.json // this example is just showing the usage of "FileWorkspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -71,14 +72,18 @@ public async Task Exists_GetDetailsOfASubscriptionFileWorkspace() // invoke the operation string fileWorkspaceName = "testworkspace"; - bool result = await collection.ExistsAsync(fileWorkspaceName); + SubscriptionFileWorkspaceResource result = await collection.GetAsync(fileWorkspaceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileWorkspaceDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfASubscriptionFileWorkspace() + public async Task Exists_GetDetailsOfASubscriptionFileWorkspace() { // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetFileWorkspaceDetailsForSubscription.json // this example is just showing the usage of "FileWorkspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +104,17 @@ public async Task GetIfExists_GetDetailsOfASubscriptionFileWorkspace() // invoke the operation string fileWorkspaceName = "testworkspace"; - NullableResponse response = await collection.GetIfExistsAsync(fileWorkspaceName); - SubscriptionFileWorkspaceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(fileWorkspaceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileWorkspaceDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAFileWorkspaceForASubscription() + public async Task GetIfExists_GetDetailsOfASubscriptionFileWorkspace() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateFileWorkspaceForSubscription.json - // this example is just showing the usage of "FileWorkspaces_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetFileWorkspaceDetailsForSubscription.json + // this example is just showing the usage of "FileWorkspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,14 +132,21 @@ public async Task CreateOrUpdate_CreateAFileWorkspaceForASubscription() // invoke the operation string fileWorkspaceName = "testworkspace"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileWorkspaceName); - SubscriptionFileWorkspaceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(fileWorkspaceName); + SubscriptionFileWorkspaceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileWorkspaceDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileWorkspaceDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..0ca627e62f74d --- /dev/null +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Support.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Support.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckSupportTicketNameAvailability_ChecksWhetherNameIsAvailableForASubscriptionSupportTicketResource() + { + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CheckNameAvailabilityWithSubscription.json + // this example is just showing the usage of "SupportTickets_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "132d901f-189d-4381-9214-fe68e27e05a1"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + SupportNameAvailabilityContent content = new SupportNameAvailabilityContent("sampleName", SupportResourceType.MicrosoftSupportSupportTickets); + SupportNameAvailabilityResult result = await subscriptionResource.CheckSupportTicketNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionSupportTicketCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionSupportTicketCollection.cs index 293369fa6a311..cee8fd4039272 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionSupportTicketCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionSupportTicketCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SubscriptionSupportTicketCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSupportTicketsCreatedOnOrAfterACertainDateAndInOpenStateForASubscription() + public async Task CreateOrUpdate_CreateATicketForBillingRelatedIssues() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsCreatedOnOrAfterAndInOpenStateBySubscription.json - // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBillingSupportTicketForSubscription.json + // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,26 +38,43 @@ public async Task GetAll_ListSupportTicketsCreatedOnOrAfterACertainDateAndInOpen // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation and iterate over the result - string filter = "createdDate ge 2020-03-10T22:08:51Z and status eq 'Open'"; - await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string supportTicketName = "testticket"; + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/billing_service_guid/problemClassifications/billing_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.No, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/billing_service_guid") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + SubscriptionSupportTicketResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSupportTicketsCreatedOnOrAfterACertainDateAndInUpdatingStateForASubscription() + public async Task CreateOrUpdate_CreateATicketForSubscriptionManagementRelatedIssuesForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsCreatedOnOrAfterAndInUpdatingStateBySubscription.json - // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSubMgmtSupportTicketForSubscription.json + // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,26 +90,43 @@ public async Task GetAll_ListSupportTicketsCreatedOnOrAfterACertainDateAndInUpda // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation and iterate over the result - string filter = "createdDate ge 2020-03-10T22:08:51Z and status eq 'Updating'"; - await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string supportTicketName = "testticket"; + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/subscription_management_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.No, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/subscription_management_service_guid") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + SubscriptionSupportTicketResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSupportTicketsForASubscription() + public async Task CreateOrUpdate_CreateATicketForTechnicalIssueRelatedToASpecificResourceForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsBySubscription.json - // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateTechnicalSupportTicketForSubscription.json + // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,25 +142,50 @@ public async Task GetAll_ListSupportTicketsForASubscription() // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation and iterate over the result - await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync()) + // invoke the operation + string supportTicketName = "testticket"; + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/virtual_machine_running_linux_service_guid/problemClassifications/problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/cddd3eb5-1830-b494-44fd-782f691479dc") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProblemScopingQuestions = "{\"articleId\":\"076846c1-4c0b-4b21-91c6-1a30246b3867\",\"scopingDetails\":[{\"question\":\"When did the problem begin?\",\"controlId\":\"problem_start_time\",\"orderId\":1,\"inputType\":\"static\",\"answer\":{\"displayValue\":\"2023-08-31T18:55:00.739Z\",\"value\":\"2023-08-31T18:55:00.739Z\",\"type\":\"datetime\"}},{\"question\":\"API Type of the Cosmos DB account\",\"controlId\":\"api_type\",\"orderId\":2,\"inputType\":\"static\",\"answer\":{\"displayValue\":\"Table\",\"value\":\"tables\",\"type\":\"string\"}},{\"question\":\"Table name\",\"controlId\":\"collection_name_table\",\"orderId\":11,\"inputType\":\"nonstatic\",\"answer\":{\"displayValue\":\"Select Table Name\",\"value\":\"dont_know_answer\",\"type\":\"string\"}},{\"question\":\"Provide additional details about the issue you're facing\",\"controlId\":\"problem_description\",\"orderId\":12,\"inputType\":\"nonstatic\",\"answer\":{\"displayValue\":\"test ticket, please ignore and close\",\"value\":\"test ticket, please ignore and close\",\"type\":\"string\"}}]}", + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", + TechnicalTicketDetailsResourceId = new ResourceIdentifier("/subscriptions/132d901f-189d-4381-9214-fe68e27e05a1/resourceGroups/test/providers/Microsoft.Compute/virtualMachines/testserver"), + SecondaryConsent = {new SecondaryConsent +{ +UserConsent = UserConsent.Yes, +SecondaryConsentType = "virtualmachinerunninglinuxservice", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + SubscriptionSupportTicketResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSupportTicketsInOpenStateForASubscription() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForActiveJobsAndJobSchedulesForABatchAccount() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsInOpenStateBySubscription.json - // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForActiveJobs.json + // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,26 +201,52 @@ public async Task GetAll_ListSupportTicketsInOpenStateForASubscription() // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation and iterate over the result - string filter = "status eq 'Open'"; - await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string supportTicketName = "testticket"; + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + QuotaTicketDetails = new QuotaTicketDetails + { + QuotaChangeRequestSubType = "Account", + QuotaChangeRequestVersion = "1.0", + QuotaChangeRequests = {new SupportQuotaChangeContent +{ +Region = "EastUS", +Payload = "{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"Jobs\"}", +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + SubscriptionSupportTicketResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSupportTicketsInUpdatingStateForASubscription() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForAzureSQLManagedInstance() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsInUpdatingStateBySubscription.json - // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSqlManagedInstanceQuotaTicket.json + // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,26 +262,56 @@ public async Task GetAll_ListSupportTicketsInUpdatingStateForASubscription() // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation and iterate over the result - string filter = "status eq 'Updating'"; - await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string supportTicketName = "testticket"; + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_managedinstance_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + QuotaTicketDetails = new QuotaTicketDetails + { + QuotaChangeRequestSubType = "SQLMI", + QuotaChangeRequestVersion = "1.0", + QuotaChangeRequests = {new SupportQuotaChangeContent +{ +Region = "EastUS", +Payload = "{\"NewLimit\":200, \"Metadata\":null, \"Type\":\"vCore\"}", +}, new SupportQuotaChangeContent +{ +Region = "EastUS", +Payload = "{\"NewLimit\":200, \"Metadata\":null, \"Type\":\"Subnet\"}", +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + SubscriptionSupportTicketResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSupportTicketsWithACertainProblemClassificationIdForASubscription() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForBatchAccountsForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsProblemClassificationIdEqualsForSubscription.json - // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBatchQuotaTicketForSubscription.json + // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -212,26 +327,52 @@ public async Task GetAll_ListSupportTicketsWithACertainProblemClassificationIdFo // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation and iterate over the result - string filter = "ProblemClassificationId eq 'compute_vm_problemClassification_guid'"; - await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string supportTicketName = "testticket"; + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + QuotaTicketDetails = new QuotaTicketDetails + { + QuotaChangeRequestSubType = "Subscription", + QuotaChangeRequestVersion = "1.0", + QuotaChangeRequests = {new SupportQuotaChangeContent +{ +Region = "EastUS", +Payload = "{\"NewLimit\":200,\"Type\":\"Account\"}", +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + SubscriptionSupportTicketResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSupportTicketsWithACertainServiceIdForASubscription() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForComputeVMCores() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsServiceIdEqualsForSubscription.json - // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateCoresQuotaTicketForSubscription.json + // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -247,26 +388,51 @@ public async Task GetAll_ListSupportTicketsWithACertainServiceIdForASubscription // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation and iterate over the result - string filter = "ServiceId eq 'vm_windows_service_guid'"; - await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string supportTicketName = "testticket"; + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/cores_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + QuotaTicketDetails = new QuotaTicketDetails + { + QuotaChangeRequestVersion = "1.0", + QuotaChangeRequests = {new SupportQuotaChangeContent +{ +Region = "EastUS", +Payload = "{\"SKU\":\"DSv3 Series\",\"NewLimit\":104}", +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + SubscriptionSupportTicketResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDetailsOfASubscriptionTicket() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForDTUsForAzureSynapseAnalytics() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetSubscriptionSupportTicketDetails.json - // this example is just showing the usage of "SupportTickets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSqlDatawarehouseQuotaTicketForDTUs.json + // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -284,7 +450,36 @@ public async Task Get_GetDetailsOfASubscriptionTicket() // invoke the operation string supportTicketName = "testticket"; - SubscriptionSupportTicketResource result = await collection.GetAsync(supportTicketName); + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_datawarehouse_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") + { + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + QuotaTicketDetails = new QuotaTicketDetails + { + QuotaChangeRequestSubType = "DTUs", + QuotaChangeRequestVersion = "1.0", + QuotaChangeRequests = {new SupportQuotaChangeContent +{ +Region = "EastUS", +Payload = "{\"ServerName\":\"testserver\",\"NewLimit\":54000}", +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + SubscriptionSupportTicketResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -295,10 +490,10 @@ public async Task Get_GetDetailsOfASubscriptionTicket() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfASubscriptionTicket() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForDTUsForSQLDatabase() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetSubscriptionSupportTicketDetails.json - // this example is just showing the usage of "SupportTickets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSqlDatabaseQuotaTicketForDTUs.json + // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -316,17 +511,50 @@ public async Task Exists_GetDetailsOfASubscriptionTicket() // invoke the operation string supportTicketName = "testticket"; - bool result = await collection.ExistsAsync(supportTicketName); - - Console.WriteLine($"Succeeded: {result}"); - } - + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_database_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") + { + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + QuotaTicketDetails = new QuotaTicketDetails + { + QuotaChangeRequestSubType = "DTUs", + QuotaChangeRequestVersion = "1.0", + QuotaChangeRequests = {new SupportQuotaChangeContent +{ +Region = "EastUS", +Payload = "{\"ServerName\":\"testserver\",\"NewLimit\":54000}", +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + SubscriptionSupportTicketResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfASubscriptionTicket() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForLowPriorityCoresForMachineLearningService() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetSubscriptionSupportTicketDetails.json - // this example is just showing the usage of "SupportTickets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateMachineLearningQuotaTicketForLowPriorityCores.json + // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -344,28 +572,49 @@ public async Task GetIfExists_GetDetailsOfASubscriptionTicket() // invoke the operation string supportTicketName = "testticket"; - NullableResponse response = await collection.GetIfExistsAsync(supportTicketName); - SubscriptionSupportTicketResource result = response.HasValue ? response.Value : null; - - if (result == null) + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/machine_learning_service_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + QuotaTicketDetails = new QuotaTicketDetails + { + QuotaChangeRequestSubType = "BatchAml", + QuotaChangeRequestVersion = "1.0", + QuotaChangeRequests = {new SupportQuotaChangeContent +{ +Region = "EastUS", +Payload = "{\"NewLimit\":200,\"Type\":\"LowPriority\"}", +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + SubscriptionSupportTicketResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketForBillingRelatedIssues() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForLowPriorityCoresForABatchAccount() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBillingSupportTicketForSubscription.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForLowPriorityCores.json // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -384,10 +633,33 @@ public async Task CreateOrUpdate_CreateATicketForBillingRelatedIssues() // invoke the operation string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/billing_service_guid/problemClassifications/billing_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.No, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/billing_service_guid") + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", + QuotaTicketDetails = new QuotaTicketDetails + { + QuotaChangeRequestSubType = "Account", + QuotaChangeRequestVersion = "1.0", + QuotaChangeRequests = {new SupportQuotaChangeContent +{ +Region = "EastUS", +Payload = "{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"LowPriority\"}", +}}, + }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); SubscriptionSupportTicketResource result = lro.Value; @@ -401,9 +673,9 @@ public async Task CreateOrUpdate_CreateATicketForBillingRelatedIssues() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketForSubscriptionManagementRelatedIssuesForASubscription() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForPoolsForABatchAccount() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSubMgmtSupportTicketForSubscription.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForPools.json // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -422,10 +694,33 @@ public async Task CreateOrUpdate_CreateATicketForSubscriptionManagementRelatedIs // invoke the operation string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/subscription_management_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.No, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/subscription_management_service_guid") + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", + QuotaTicketDetails = new QuotaTicketDetails + { + QuotaChangeRequestSubType = "Account", + QuotaChangeRequestVersion = "1.0", + QuotaChangeRequests = {new SupportQuotaChangeContent +{ +Region = "EastUS", +Payload = "{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"Pools\"}", +}}, + }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); SubscriptionSupportTicketResource result = lro.Value; @@ -439,9 +734,9 @@ public async Task CreateOrUpdate_CreateATicketForSubscriptionManagementRelatedIs [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketForTechnicalIssueRelatedToASpecificResourceForASubscription() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForServersForAzureSynapseAnalytics() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateTechnicalSupportTicketForSubscription.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSqlDatawarehouseQuotaTicketForServers.json // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -460,20 +755,33 @@ public async Task CreateOrUpdate_CreateATicketForTechnicalIssueRelatedToASpecifi // invoke the operation string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/virtual_machine_running_linux_service_guid/problemClassifications/problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/cddd3eb5-1830-b494-44fd-782f691479dc") + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_datawarehouse_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { - ProblemScopingQuestions = "{\"articleId\":\"076846c1-4c0b-4b21-91c6-1a30246b3867\",\"scopingDetails\":[{\"question\":\"When did the problem begin?\",\"controlId\":\"problem_start_time\",\"orderId\":1,\"inputType\":\"static\",\"answer\":{\"displayValue\":\"2023-08-31T18:55:00.739Z\",\"value\":\"2023-08-31T18:55:00.739Z\",\"type\":\"datetime\"}},{\"question\":\"API Type of the Cosmos DB account\",\"controlId\":\"api_type\",\"orderId\":2,\"inputType\":\"static\",\"answer\":{\"displayValue\":\"Table\",\"value\":\"tables\",\"type\":\"string\"}},{\"question\":\"Table name\",\"controlId\":\"collection_name_table\",\"orderId\":11,\"inputType\":\"nonstatic\",\"answer\":{\"displayValue\":\"Select Table Name\",\"value\":\"dont_know_answer\",\"type\":\"string\"}},{\"question\":\"Provide additional details about the issue you're facing\",\"controlId\":\"problem_description\",\"orderId\":12,\"inputType\":\"nonstatic\",\"answer\":{\"displayValue\":\"test ticket, please ignore and close\",\"value\":\"test ticket, please ignore and close\",\"type\":\"string\"}}]}", SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", - TechnicalTicketDetailsResourceId = new ResourceIdentifier("/subscriptions/132d901f-189d-4381-9214-fe68e27e05a1/resourceGroups/test/providers/Microsoft.Compute/virtualMachines/testserver"), - SecondaryConsent = -{ -new SecondaryConsent() + QuotaTicketDetails = new QuotaTicketDetails + { + QuotaChangeRequestSubType = "Servers", + QuotaChangeRequestVersion = "1.0", + QuotaChangeRequests = {new SupportQuotaChangeContent { -UserConsent = UserConsent.Yes, -SecondaryConsentType = "virtualmachinerunninglinuxservice", -} -}, +Region = "EastUS", +Payload = "{\"NewLimit\":200}", +}}, + }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); SubscriptionSupportTicketResource result = lro.Value; @@ -487,9 +795,9 @@ public async Task CreateOrUpdate_CreateATicketForTechnicalIssueRelatedToASpecifi [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForActiveJobsAndJobSchedulesForABatchAccount() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForServersForSQLDatabase() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForActiveJobs.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSqlDatabaseQuotaTicketForServers.json // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -508,21 +816,32 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForActiveJob // invoke the operation string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_database_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() + QuotaTicketDetails = new QuotaTicketDetails { - QuotaChangeRequestSubType = "Account", + QuotaChangeRequestSubType = "Servers", QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() + QuotaChangeRequests = {new SupportQuotaChangeContent { Region = "EastUS", -Payload = "{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"Jobs\"}", -} -}, +Payload = "{\"NewLimit\":200}", +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); @@ -537,9 +856,9 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForActiveJob [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForAzureSQLManagedInstance() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForServicesThatDoNotRequireAdditionalDetailsInTheQuotaTicketDetailsObject() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSqlManagedInstanceQuotaTicket.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateGenericQuotaTicket.json // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -558,27 +877,21 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForAzureSQLM // invoke the operation string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_managedinstance_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") - { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() - { - QuotaChangeRequestSubType = "SQLMI", - QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"NewLimit\":200, \"Metadata\":null, \"Type\":\"vCore\"}", -},new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"NewLimit\":200, \"Metadata\":null, \"Type\":\"Subnet\"}", -} -}, - }, - }; + SupportTicketData data = new SupportTicketData( + "Increase the maximum throughput per container limit to 10000 for account foo bar", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/cosmosdb_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid"); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); SubscriptionSupportTicketResource result = lro.Value; @@ -591,9 +904,9 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForAzureSQLM [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForBatchAccountsForASubscription() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForSpecificVMFamilyCoresForMachineLearningService() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBatchQuotaTicketForSubscription.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateMachineLearningQuotaTicketForDedicatedCores.json // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -612,21 +925,32 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForBatchAcco // invoke the operation string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/machine_learning_service_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() + QuotaTicketDetails = new QuotaTicketDetails { - QuotaChangeRequestSubType = "Subscription", + QuotaChangeRequestSubType = "BatchAml", QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() + QuotaChangeRequests = {new SupportQuotaChangeContent { Region = "EastUS", -Payload = "{\"NewLimit\":200,\"Type\":\"Account\"}", -} -}, +Payload = "{\"VMFamily\":\"standardA0_A7Family\",\"NewLimit\":200,\"Type\":\"Dedicated\"}", +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); @@ -641,9 +965,9 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForBatchAcco [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForComputeVMCores() + public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForSpecificVMFamilyCoresForABatchAccount() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateCoresQuotaTicketForSubscription.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForDedicatedCores.json // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -662,20 +986,32 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForComputeVM // invoke the operation string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/cores_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/quota_service_guid") { SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() + QuotaTicketDetails = new QuotaTicketDetails { + QuotaChangeRequestSubType = "Account", QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() + QuotaChangeRequests = {new SupportQuotaChangeContent { Region = "EastUS", -Payload = "{\"SKU\":\"DSv3 Series\",\"NewLimit\":104}", -} -}, +Payload = "{\"AccountName\":\"test\",\"VMFamily\":\"standardA0_A7Family\",\"NewLimit\":200,\"Type\":\"Dedicated\"}", +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); @@ -690,10 +1026,10 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForComputeVM [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForDTUsForAzureSynapseAnalytics() + public async Task Get_GetDetailsOfASubscriptionTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSqlDatawarehouseQuotaTicketForDTUs.json - // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetSubscriptionSupportTicketDetails.json + // this example is just showing the usage of "SupportTickets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -711,25 +1047,7 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForDTUsForAz // invoke the operation string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_datawarehouse_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") - { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() - { - QuotaChangeRequestSubType = "DTUs", - QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"ServerName\":\"testserver\",\"NewLimit\":54000}", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - SubscriptionSupportTicketResource result = lro.Value; + SubscriptionSupportTicketResource result = await collection.GetAsync(supportTicketName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -740,10 +1058,10 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForDTUsForAz [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForDTUsForSQLDatabase() + public async Task GetAll_ListSupportTicketsCreatedOnOrAfterACertainDateAndInOpenStateForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSqlDatabaseQuotaTicketForDTUs.json - // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsCreatedOnOrAfterAndInOpenStateBySubscription.json + // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -759,41 +1077,26 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForDTUsForSQ // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation - string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_database_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") + // invoke the operation and iterate over the result + string filter = "createdDate ge 2020-03-10T22:08:51Z and status eq 'Open'"; + await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() - { - QuotaChangeRequestSubType = "DTUs", - QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"ServerName\":\"testserver\",\"NewLimit\":54000}", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - SubscriptionSupportTicketResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForLowPriorityCoresForMachineLearningService() + public async Task GetAll_ListSupportTicketsCreatedOnOrAfterACertainDateAndInUpdatingStateForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateMachineLearningQuotaTicketForLowPriorityCores.json - // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsCreatedOnOrAfterAndInUpdatingStateBySubscription.json + // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -809,41 +1112,26 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForLowPriori // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation - string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/machine_learning_service_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") + // invoke the operation and iterate over the result + string filter = "createdDate ge 2020-03-10T22:08:51Z and status eq 'Updating'"; + await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() - { - QuotaChangeRequestSubType = "BatchAml", - QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"NewLimit\":200,\"Type\":\"LowPriority\"}", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - SubscriptionSupportTicketResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForLowPriorityCoresForABatchAccount() + public async Task GetAll_ListSupportTicketsForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForLowPriorityCores.json - // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsBySubscription.json + // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -859,41 +1147,25 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForLowPriori // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation - string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") + // invoke the operation and iterate over the result + await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync()) { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() - { - QuotaChangeRequestSubType = "Account", - QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"LowPriority\"}", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - SubscriptionSupportTicketResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForPoolsForABatchAccount() + public async Task GetAll_ListSupportTicketsInOpenStateForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForPools.json - // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsInOpenStateBySubscription.json + // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -909,41 +1181,26 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForPoolsForA // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation - string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") + // invoke the operation and iterate over the result + string filter = "status eq 'Open'"; + await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() - { - QuotaChangeRequestSubType = "Account", - QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"AccountName\":\"test\",\"NewLimit\":200,\"Type\":\"Pools\"}", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - SubscriptionSupportTicketResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForServersForAzureSynapseAnalytics() + public async Task GetAll_ListSupportTicketsInUpdatingStateForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSqlDatawarehouseQuotaTicketForServers.json - // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsInUpdatingStateBySubscription.json + // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -959,41 +1216,26 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForServersFo // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation - string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_datawarehouse_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") + // invoke the operation and iterate over the result + string filter = "status eq 'Updating'"; + await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() - { - QuotaChangeRequestSubType = "Servers", - QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"NewLimit\":200}", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - SubscriptionSupportTicketResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForServersForSQLDatabase() + public async Task GetAll_ListSupportTicketsWithACertainProblemClassificationIdForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSqlDatabaseQuotaTicketForServers.json - // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsProblemClassificationIdEqualsForSubscription.json + // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1009,41 +1251,26 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForServersFo // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation - string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/sql_database_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") + // invoke the operation and iterate over the result + string filter = "ProblemClassificationId eq 'compute_vm_problemClassification_guid'"; + await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() - { - QuotaChangeRequestSubType = "Servers", - QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"NewLimit\":200}", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - SubscriptionSupportTicketResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForServicesThatDoNotRequireAdditionalDetailsInTheQuotaTicketDetailsObject() + public async Task GetAll_ListSupportTicketsWithACertainServiceIdForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateGenericQuotaTicket.json - // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListSupportTicketsServiceIdEqualsForSubscription.json + // this example is just showing the usage of "SupportTickets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1059,25 +1286,26 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForServicesT // get the collection of this SubscriptionSupportTicketResource SubscriptionSupportTicketCollection collection = subscriptionResource.GetSubscriptionSupportTickets(); - // invoke the operation - string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("Increase the maximum throughput per container limit to 10000 for account foo bar", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/cosmosdb_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - SubscriptionSupportTicketResource result = lro.Value; + // invoke the operation and iterate over the result + string filter = "ServiceId eq 'vm_windows_service_guid'"; + await foreach (SubscriptionSupportTicketResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForSpecificVMFamilyCoresForMachineLearningService() + public async Task Exists_GetDetailsOfASubscriptionTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateMachineLearningQuotaTicketForDedicatedCores.json - // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetSubscriptionSupportTicketDetails.json + // this example is just showing the usage of "SupportTickets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1095,39 +1323,17 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForSpecificV // invoke the operation string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/machine_learning_service_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") - { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() - { - QuotaChangeRequestSubType = "BatchAml", - QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"VMFamily\":\"standardA0_A7Family\",\"NewLimit\":200,\"Type\":\"Dedicated\"}", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - SubscriptionSupportTicketResource result = lro.Value; + bool result = await collection.ExistsAsync(supportTicketName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForSpecificVMFamilyCoresForABatchAccount() + public async Task GetIfExists_GetDetailsOfASubscriptionTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBatchQuotaTicketForSpecificBatchAccountForDedicatedCores.json - // this example is just showing the usage of "SupportTickets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetSubscriptionSupportTicketDetails.json + // this example is just showing the usage of "SupportTickets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1145,31 +1351,21 @@ public async Task CreateOrUpdate_CreateATicketToRequestQuotaIncreaseForSpecificV // invoke the operation string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/quota_service_guid/problemClassifications/batch_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/quota_service_guid") - { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - QuotaTicketDetails = new QuotaTicketDetails() - { - QuotaChangeRequestSubType = "Account", - QuotaChangeRequestVersion = "1.0", - QuotaChangeRequests = -{ -new SupportQuotaChangeContent() -{ -Region = "EastUS", -Payload = "{\"AccountName\":\"test\",\"VMFamily\":\"standardA0_A7Family\",\"NewLimit\":200,\"Type\":\"Dedicated\"}", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - SubscriptionSupportTicketResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(supportTicketName); + SubscriptionSupportTicketResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionSupportTicketResource.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionSupportTicketResource.cs index 450f1a66bf75c..b9ad9a35b3023 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionSupportTicketResource.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SubscriptionSupportTicketResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Support.Models; using NUnit.Framework; @@ -17,31 +16,6 @@ namespace Azure.ResourceManager.Support.Samples { public partial class Sample_SubscriptionSupportTicketResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckSupportTicketNameAvailability_ChecksWhetherNameIsAvailableForASubscriptionSupportTicketResource() - { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CheckNameAvailabilityWithSubscription.json - // this example is just showing the usage of "SupportTickets_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "132d901f-189d-4381-9214-fe68e27e05a1"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - SupportNameAvailabilityContent content = new SupportNameAvailabilityContent("sampleName", SupportResourceType.MicrosoftSupportSupportTickets); - SupportNameAvailabilityResult result = await subscriptionResource.CheckSupportTicketNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetDetailsOfASubscriptionTicket() @@ -91,7 +65,7 @@ public async Task Update_UpdateAdvancedDiagnosticConsentOfASubscriptionSupportTi SubscriptionSupportTicketResource subscriptionSupportTicket = client.GetSubscriptionSupportTicketResource(subscriptionSupportTicketResourceId); // invoke the operation - UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket() + UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket { AdvancedDiagnosticConsent = AdvancedDiagnosticConsent.Yes, }; @@ -124,18 +98,15 @@ public async Task Update_UpdateContactDetailsOfASubscriptionSupportTicket() SubscriptionSupportTicketResource subscriptionSupportTicket = client.GetSubscriptionSupportTicketResource(subscriptionSupportTicketResourceId); // invoke the operation - UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket() + UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket { - ContactDetails = new SupportContactProfileContent() + ContactDetails = new SupportContactProfileContent { FirstName = "first name", LastName = "last name", PreferredContactMethod = PreferredContactMethod.Email, PrimaryEmailAddress = "test.name@contoso.com", - AdditionalEmailAddresses = -{ -"tname@contoso.com","teamtest@contoso.com" -}, + AdditionalEmailAddresses = { "tname@contoso.com", "teamtest@contoso.com" }, PhoneNumber = "123-456-7890", PreferredTimeZone = "Pacific Standard Time", Country = "USA", @@ -171,7 +142,7 @@ public async Task Update_UpdateSeverityOfASubscriptionSupportTicket() SubscriptionSupportTicketResource subscriptionSupportTicket = client.GetSubscriptionSupportTicketResource(subscriptionSupportTicketResourceId); // invoke the operation - UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket() + UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket { Severity = SupportSeverityLevel.Critical, }; @@ -204,7 +175,7 @@ public async Task Update_UpdateStatusOfASubscriptionSupportTicket() SubscriptionSupportTicketResource subscriptionSupportTicket = client.GetSubscriptionSupportTicketResource(subscriptionSupportTicketResourceId); // invoke the operation - UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket() + UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket { Status = SupportTicketStatus.Closed, }; diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportAzureServiceCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportAzureServiceCollection.cs index ff3edeab8020c..ed70838afa3ad 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportAzureServiceCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportAzureServiceCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Support.Samples @@ -17,64 +18,60 @@ public partial class Sample_SupportAzureServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfServicesForWhichASupportTicketCanBeCreated() + public async Task Get_GetsDetailsOfTheAzureService() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListServices.json - // this example is just showing the usage of "Services_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetService.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SupportAzureServiceResource SupportAzureServiceCollection collection = tenantResource.GetSupportAzureServices(); - // invoke the operation and iterate over the result - await foreach (SupportAzureServiceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportAzureServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string serviceName = "service_guid"; + SupportAzureServiceResource result = await collection.GetAsync(serviceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportAzureServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsDetailsOfTheAzureService() + public async Task GetAll_GetsListOfServicesForWhichASupportTicketCanBeCreated() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetService.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListServices.json + // this example is just showing the usage of "Services_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SupportAzureServiceResource SupportAzureServiceCollection collection = tenantResource.GetSupportAzureServices(); - // invoke the operation - string serviceName = "service_guid"; - SupportAzureServiceResource result = await collection.GetAsync(serviceName); + // invoke the operation and iterate over the result + await foreach (SupportAzureServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportAzureServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportAzureServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -89,9 +86,7 @@ public async Task Exists_GetsDetailsOfTheAzureService() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SupportAzureServiceResource SupportAzureServiceCollection collection = tenantResource.GetSupportAzureServices(); @@ -115,9 +110,7 @@ public async Task GetIfExists_GetsDetailsOfTheAzureService() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SupportAzureServiceResource SupportAzureServiceCollection collection = tenantResource.GetSupportAzureServices(); diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketChatTranscriptCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketChatTranscriptCollection.cs index 3d2f781c2c672..16ddcb69769de 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketChatTranscriptCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketChatTranscriptCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SupportTicketChatTranscriptCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListChatTranscriptsForASubscriptionSupportTicket() + public async Task Get_GetChatTranscriptDetailsForASubscriptionSupportTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListChatTranscriptsForSubscriptionSupportTicket.json - // this example is just showing the usage of "ChatTranscripts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetchatTranscriptDetailsForSubscriptionSupportTicket.json + // this example is just showing the usage of "ChatTranscripts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_ListChatTranscriptsForASubscriptionSupportTicket() // get the collection of this SupportTicketChatTranscriptResource SupportTicketChatTranscriptCollection collection = subscriptionSupportTicket.GetSupportTicketChatTranscripts(); - // invoke the operation and iterate over the result - await foreach (SupportTicketChatTranscriptResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChatTranscriptDetailData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string chatTranscriptName = "69586795-45e9-45b5-bd9e-c9bb237d3e44"; + SupportTicketChatTranscriptResource result = await collection.GetAsync(chatTranscriptName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChatTranscriptDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetChatTranscriptDetailsForASubscriptionSupportTicket() + public async Task GetAll_ListChatTranscriptsForASubscriptionSupportTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetchatTranscriptDetailsForSubscriptionSupportTicket.json - // this example is just showing the usage of "ChatTranscripts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListChatTranscriptsForSubscriptionSupportTicket.json + // this example is just showing the usage of "ChatTranscripts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +70,17 @@ public async Task Get_GetChatTranscriptDetailsForASubscriptionSupportTicket() // get the collection of this SupportTicketChatTranscriptResource SupportTicketChatTranscriptCollection collection = subscriptionSupportTicket.GetSupportTicketChatTranscripts(); - // invoke the operation - string chatTranscriptName = "69586795-45e9-45b5-bd9e-c9bb237d3e44"; - SupportTicketChatTranscriptResource result = await collection.GetAsync(chatTranscriptName); + // invoke the operation and iterate over the result + await foreach (SupportTicketChatTranscriptResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChatTranscriptDetailData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChatTranscriptDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketCommunicationCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketCommunicationCollection.cs index ebb9736fd71b0..339b0c43b628e 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketCommunicationCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketCommunicationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SupportTicketCommunicationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCommunicationsForASubscriptionSupportTicket() + public async Task CreateOrUpdate_AddCommunicationToSubscriptionTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListCommunicationsForSubscriptionSupportTicket.json - // this example is just showing the usage of "Communications_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSupportTicketCommunication.json + // this example is just showing the usage of "Communications_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,24 +37,60 @@ public async Task GetAll_ListCommunicationsForASubscriptionSupportTicket() // get the collection of this SupportTicketCommunicationResource SupportTicketCommunicationCollection collection = subscriptionSupportTicket.GetSupportTicketCommunications(); - // invoke the operation and iterate over the result - await foreach (SupportTicketCommunicationResource item in collection.GetAllAsync()) + // invoke the operation + string communicationName = "testcommunication"; + SupportTicketCommunicationData data = new SupportTicketCommunicationData("This is a test message from a customer!", "This is a test message from a customer!") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketCommunicationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sender = "user@contoso.com", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationName, data); + SupportTicketCommunicationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketCommunicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWebCommunicationCreatedOnOrAfterASpecificDateForASubscriptionSupportTicket() + public async Task Get_GetCommunicationDetailsForASubscriptionSupportTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListWebCommunicationsForSubscriptionSupportTicketCreatedOnOrAfter.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetCommunicationDetailsForSubscriptionSupportTicket.json + // this example is just showing the usage of "Communications_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionSupportTicketResource created on azure + // for more information of creating SubscriptionSupportTicketResource, please refer to the document of SubscriptionSupportTicketResource + string subscriptionId = "132d901f-189d-4381-9214-fe68e27e05a1"; + string supportTicketName = "testticket"; + ResourceIdentifier subscriptionSupportTicketResourceId = SubscriptionSupportTicketResource.CreateResourceIdentifier(subscriptionId, supportTicketName); + SubscriptionSupportTicketResource subscriptionSupportTicket = client.GetSubscriptionSupportTicketResource(subscriptionSupportTicketResourceId); + + // get the collection of this SupportTicketCommunicationResource + SupportTicketCommunicationCollection collection = subscriptionSupportTicket.GetSupportTicketCommunications(); + + // invoke the operation + string communicationName = "testmessage"; + SupportTicketCommunicationResource result = await collection.GetAsync(communicationName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketCommunicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListCommunicationsForASubscriptionSupportTicket() + { + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListCommunicationsForSubscriptionSupportTicket.json // this example is just showing the usage of "Communications_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -73,8 +109,7 @@ public async Task GetAll_ListWebCommunicationCreatedOnOrAfterASpecificDateForASu SupportTicketCommunicationCollection collection = subscriptionSupportTicket.GetSupportTicketCommunications(); // invoke the operation and iterate over the result - string filter = "communicationType eq 'web' and createdDate ge 2020-03-10T22:08:51Z"; - await foreach (SupportTicketCommunicationResource item in collection.GetAllAsync(filter: filter)) + await foreach (SupportTicketCommunicationResource item in collection.GetAllAsync()) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,9 +123,9 @@ public async Task GetAll_ListWebCommunicationCreatedOnOrAfterASpecificDateForASu [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWebCommunicationsForASubscriptionSupportTicket() + public async Task GetAll_ListWebCommunicationCreatedOnOrAfterASpecificDateForASubscriptionSupportTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListWebCommunicationsForSubscriptionSupportTicket.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListWebCommunicationsForSubscriptionSupportTicketCreatedOnOrAfter.json // this example is just showing the usage of "Communications_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -109,7 +144,7 @@ public async Task GetAll_ListWebCommunicationsForASubscriptionSupportTicket() SupportTicketCommunicationCollection collection = subscriptionSupportTicket.GetSupportTicketCommunications(); // invoke the operation and iterate over the result - string filter = "communicationType eq 'web'"; + string filter = "communicationType eq 'web' and createdDate ge 2020-03-10T22:08:51Z"; await foreach (SupportTicketCommunicationResource item in collection.GetAllAsync(filter: filter)) { // the variable item is a resource, you could call other operations on this instance as well @@ -124,10 +159,10 @@ public async Task GetAll_ListWebCommunicationsForASubscriptionSupportTicket() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCommunicationDetailsForASubscriptionSupportTicket() + public async Task GetAll_ListWebCommunicationsForASubscriptionSupportTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetCommunicationDetailsForSubscriptionSupportTicket.json - // this example is just showing the usage of "Communications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListWebCommunicationsForSubscriptionSupportTicket.json + // this example is just showing the usage of "Communications_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,15 +179,18 @@ public async Task Get_GetCommunicationDetailsForASubscriptionSupportTicket() // get the collection of this SupportTicketCommunicationResource SupportTicketCommunicationCollection collection = subscriptionSupportTicket.GetSupportTicketCommunications(); - // invoke the operation - string communicationName = "testmessage"; - SupportTicketCommunicationResource result = await collection.GetAsync(communicationName); + // invoke the operation and iterate over the result + string filter = "communicationType eq 'web'"; + await foreach (SupportTicketCommunicationResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketCommunicationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketCommunicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -224,43 +262,5 @@ public async Task GetIfExists_GetCommunicationDetailsForASubscriptionSupportTick Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddCommunicationToSubscriptionTicket() - { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSupportTicketCommunication.json - // this example is just showing the usage of "Communications_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionSupportTicketResource created on azure - // for more information of creating SubscriptionSupportTicketResource, please refer to the document of SubscriptionSupportTicketResource - string subscriptionId = "132d901f-189d-4381-9214-fe68e27e05a1"; - string supportTicketName = "testticket"; - ResourceIdentifier subscriptionSupportTicketResourceId = SubscriptionSupportTicketResource.CreateResourceIdentifier(subscriptionId, supportTicketName); - SubscriptionSupportTicketResource subscriptionSupportTicket = client.GetSubscriptionSupportTicketResource(subscriptionSupportTicketResourceId); - - // get the collection of this SupportTicketCommunicationResource - SupportTicketCommunicationCollection collection = subscriptionSupportTicket.GetSupportTicketCommunications(); - - // invoke the operation - string communicationName = "testcommunication"; - SupportTicketCommunicationData data = new SupportTicketCommunicationData("This is a test message from a customer!", "This is a test message from a customer!") - { - Sender = "user@contoso.com", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationName, data); - SupportTicketCommunicationResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketCommunicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketFileCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketFileCollection.cs index 8f63181116493..0bd817586099a 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketFileCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketFileCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SupportTicketFileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFilesUnderAWorkspaceForASubscription() + public async Task CreateOrUpdate_CreateAFileUnderASubscriptionWorkspace() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListFilesForSubscriptionUnderFileWorkspace.json - // this example is just showing the usage of "Files_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateFileForSubscription.json + // this example is just showing the usage of "Files_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,22 @@ public async Task GetAll_ListFilesUnderAWorkspaceForASubscription() // get the collection of this SupportTicketFileResource SupportTicketFileCollection collection = subscriptionFileWorkspace.GetSupportTicketFiles(); - // invoke the operation and iterate over the result - await foreach (SupportTicketFileResource item in collection.GetAllAsync()) + // invoke the operation + string fileName = "test.txt"; + SupportFileDetailData data = new SupportFileDetailData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportFileDetailData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ChunkSize = 41423, + FileSize = 41423, + NumberOfChunks = 1, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileName, data); + SupportTicketFileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportFileDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -85,10 +90,10 @@ public async Task Get_GetDetailsOfASubscriptionFile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfASubscriptionFile() + public async Task GetAll_ListFilesUnderAWorkspaceForASubscription() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetFileDetailsForSubscription.json - // this example is just showing the usage of "Files_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListFilesForSubscriptionUnderFileWorkspace.json + // this example is just showing the usage of "Files_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,16 +110,22 @@ public async Task Exists_GetDetailsOfASubscriptionFile() // get the collection of this SupportTicketFileResource SupportTicketFileCollection collection = subscriptionFileWorkspace.GetSupportTicketFiles(); - // invoke the operation - string fileName = "test.txt"; - bool result = await collection.ExistsAsync(fileName); + // invoke the operation and iterate over the result + await foreach (SupportTicketFileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportFileDetailData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfASubscriptionFile() + public async Task Exists_GetDetailsOfASubscriptionFile() { // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetFileDetailsForSubscription.json // this example is just showing the usage of "Files_Get" operation, for the dependent resources, they will have to be created separately. @@ -136,29 +147,17 @@ public async Task GetIfExists_GetDetailsOfASubscriptionFile() // invoke the operation string fileName = "test.txt"; - NullableResponse response = await collection.GetIfExistsAsync(fileName); - SupportTicketFileResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(fileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportFileDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAFileUnderASubscriptionWorkspace() + public async Task GetIfExists_GetDetailsOfASubscriptionFile() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateFileForSubscription.json - // this example is just showing the usage of "Files_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetFileDetailsForSubscription.json + // this example is just showing the usage of "Files_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,20 +176,21 @@ public async Task CreateOrUpdate_CreateAFileUnderASubscriptionWorkspace() // invoke the operation string fileName = "test.txt"; - SupportFileDetailData data = new SupportFileDetailData() - { - ChunkSize = 41423, - FileSize = 41423, - NumberOfChunks = 1, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileName, data); - SupportTicketFileResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(fileName); + SupportTicketFileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportFileDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportFileDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketFileResource.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketFileResource.cs index 535d560502a8b..53ad4a9a80343 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketFileResource.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketFileResource.cs @@ -67,7 +67,7 @@ public async Task Update_CreateAFileUnderASubscriptionWorkspace() SupportTicketFileResource supportTicketFile = client.GetSupportTicketFileResource(supportTicketFileResourceId); // invoke the operation - SupportFileDetailData data = new SupportFileDetailData() + SupportFileDetailData data = new SupportFileDetailData { ChunkSize = 41423, FileSize = 41423, @@ -104,7 +104,7 @@ public async Task Upload_UploadFileForSubscription() SupportTicketFileResource supportTicketFile = client.GetSupportTicketFileResource(supportTicketFileResourceId); // invoke the operation - UploadFileContent content = new UploadFileContent() + UploadFileContent content = new UploadFileContent { Content = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABd", ChunkIndex = 0, diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubChatTranscriptCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubChatTranscriptCollection.cs index 3ac0a0a5535f6..86e09555db5f3 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubChatTranscriptCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubChatTranscriptCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SupportTicketNoSubChatTranscriptCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListChatTranscriptsForANoSubscriptionSupportTicket() + public async Task Get_GetChatTranscriptDetailsForASubscriptionSupportTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListChatTranscriptsForSupportTicket.json - // this example is just showing the usage of "ChatTranscriptsNoSubscription_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetchatTranscriptDetailsForSupportTicket.json + // this example is just showing the usage of "ChatTranscriptsNoSubscription_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,25 +36,23 @@ public async Task GetAll_ListChatTranscriptsForANoSubscriptionSupportTicket() // get the collection of this SupportTicketNoSubChatTranscriptResource SupportTicketNoSubChatTranscriptCollection collection = tenantSupportTicket.GetSupportTicketNoSubChatTranscripts(); - // invoke the operation and iterate over the result - await foreach (SupportTicketNoSubChatTranscriptResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChatTranscriptDetailData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string chatTranscriptName = "b371192a-b094-4a71-b093-7246029b0a54"; + SupportTicketNoSubChatTranscriptResource result = await collection.GetAsync(chatTranscriptName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChatTranscriptDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetChatTranscriptDetailsForASubscriptionSupportTicket() + public async Task GetAll_ListChatTranscriptsForANoSubscriptionSupportTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetchatTranscriptDetailsForSupportTicket.json - // this example is just showing the usage of "ChatTranscriptsNoSubscription_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListChatTranscriptsForSupportTicket.json + // this example is just showing the usage of "ChatTranscriptsNoSubscription_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,15 +68,17 @@ public async Task Get_GetChatTranscriptDetailsForASubscriptionSupportTicket() // get the collection of this SupportTicketNoSubChatTranscriptResource SupportTicketNoSubChatTranscriptCollection collection = tenantSupportTicket.GetSupportTicketNoSubChatTranscripts(); - // invoke the operation - string chatTranscriptName = "b371192a-b094-4a71-b093-7246029b0a54"; - SupportTicketNoSubChatTranscriptResource result = await collection.GetAsync(chatTranscriptName); + // invoke the operation and iterate over the result + await foreach (SupportTicketNoSubChatTranscriptResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChatTranscriptDetailData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChatTranscriptDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubCommunicationCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubCommunicationCollection.cs index 6a97d007ee71c..7bbd4df2b7fe4 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubCommunicationCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubCommunicationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SupportTicketNoSubCommunicationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCommunicationsForANoSubscriptionSupportTicket() + public async Task CreateOrUpdate_AddCommunicationToNoSubscriptionTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListCommunicationsForSupportTicket.json - // this example is just showing the usage of "CommunicationsNoSubscription_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateNoSubscriptionSupportTicketCommunication.json + // this example is just showing the usage of "CommunicationsNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,24 +36,59 @@ public async Task GetAll_ListCommunicationsForANoSubscriptionSupportTicket() // get the collection of this SupportTicketNoSubCommunicationResource SupportTicketNoSubCommunicationCollection collection = tenantSupportTicket.GetSupportTicketNoSubCommunications(); - // invoke the operation and iterate over the result - await foreach (SupportTicketNoSubCommunicationResource item in collection.GetAllAsync()) + // invoke the operation + string communicationName = "testcommunication"; + SupportTicketCommunicationData data = new SupportTicketCommunicationData("This is a test message from a customer!", "This is a test message from a customer!") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketCommunicationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sender = "user@contoso.com", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationName, data); + SupportTicketNoSubCommunicationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketCommunicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWebCommunicationCreatedOnOrAfterASpecificDateForANoSubscriptionSupportTicket() + public async Task Get_GetCommunicationDetailsForANoSubscriptionSupportTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListWebCommunicationsForSupportTicketCreatedOnOrAfter.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetCommunicationDetailsForSupportTicket.json + // this example is just showing the usage of "CommunicationsNoSubscription_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TenantSupportTicketResource created on azure + // for more information of creating TenantSupportTicketResource, please refer to the document of TenantSupportTicketResource + string supportTicketName = "testticket"; + ResourceIdentifier tenantSupportTicketResourceId = TenantSupportTicketResource.CreateResourceIdentifier(supportTicketName); + TenantSupportTicketResource tenantSupportTicket = client.GetTenantSupportTicketResource(tenantSupportTicketResourceId); + + // get the collection of this SupportTicketNoSubCommunicationResource + SupportTicketNoSubCommunicationCollection collection = tenantSupportTicket.GetSupportTicketNoSubCommunications(); + + // invoke the operation + string communicationName = "testmessage"; + SupportTicketNoSubCommunicationResource result = await collection.GetAsync(communicationName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketCommunicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListCommunicationsForANoSubscriptionSupportTicket() + { + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListCommunicationsForSupportTicket.json // this example is just showing the usage of "CommunicationsNoSubscription_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -71,8 +106,7 @@ public async Task GetAll_ListWebCommunicationCreatedOnOrAfterASpecificDateForANo SupportTicketNoSubCommunicationCollection collection = tenantSupportTicket.GetSupportTicketNoSubCommunications(); // invoke the operation and iterate over the result - string filter = "communicationType eq 'web' and createdDate ge 2020-03-10T22:08:51Z"; - await foreach (SupportTicketNoSubCommunicationResource item in collection.GetAllAsync(filter: filter)) + await foreach (SupportTicketNoSubCommunicationResource item in collection.GetAllAsync()) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,9 +120,9 @@ public async Task GetAll_ListWebCommunicationCreatedOnOrAfterASpecificDateForANo [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWebCommunicationsForANoSubscriptionSupportTicket() + public async Task GetAll_ListWebCommunicationCreatedOnOrAfterASpecificDateForANoSubscriptionSupportTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListWebCommunicationsForSupportTicket.json + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListWebCommunicationsForSupportTicketCreatedOnOrAfter.json // this example is just showing the usage of "CommunicationsNoSubscription_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -106,7 +140,7 @@ public async Task GetAll_ListWebCommunicationsForANoSubscriptionSupportTicket() SupportTicketNoSubCommunicationCollection collection = tenantSupportTicket.GetSupportTicketNoSubCommunications(); // invoke the operation and iterate over the result - string filter = "communicationType eq 'web'"; + string filter = "communicationType eq 'web' and createdDate ge 2020-03-10T22:08:51Z"; await foreach (SupportTicketNoSubCommunicationResource item in collection.GetAllAsync(filter: filter)) { // the variable item is a resource, you could call other operations on this instance as well @@ -121,10 +155,10 @@ public async Task GetAll_ListWebCommunicationsForANoSubscriptionSupportTicket() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCommunicationDetailsForANoSubscriptionSupportTicket() + public async Task GetAll_ListWebCommunicationsForANoSubscriptionSupportTicket() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetCommunicationDetailsForSupportTicket.json - // this example is just showing the usage of "CommunicationsNoSubscription_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListWebCommunicationsForSupportTicket.json + // this example is just showing the usage of "CommunicationsNoSubscription_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,15 +174,18 @@ public async Task Get_GetCommunicationDetailsForANoSubscriptionSupportTicket() // get the collection of this SupportTicketNoSubCommunicationResource SupportTicketNoSubCommunicationCollection collection = tenantSupportTicket.GetSupportTicketNoSubCommunications(); - // invoke the operation - string communicationName = "testmessage"; - SupportTicketNoSubCommunicationResource result = await collection.GetAsync(communicationName); + // invoke the operation and iterate over the result + string filter = "communicationType eq 'web'"; + await foreach (SupportTicketNoSubCommunicationResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketCommunicationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketCommunicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -218,42 +255,5 @@ public async Task GetIfExists_GetCommunicationDetailsForANoSubscriptionSupportTi Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddCommunicationToNoSubscriptionTicket() - { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateNoSubscriptionSupportTicketCommunication.json - // this example is just showing the usage of "CommunicationsNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantSupportTicketResource created on azure - // for more information of creating TenantSupportTicketResource, please refer to the document of TenantSupportTicketResource - string supportTicketName = "testticket"; - ResourceIdentifier tenantSupportTicketResourceId = TenantSupportTicketResource.CreateResourceIdentifier(supportTicketName); - TenantSupportTicketResource tenantSupportTicket = client.GetTenantSupportTicketResource(tenantSupportTicketResourceId); - - // get the collection of this SupportTicketNoSubCommunicationResource - SupportTicketNoSubCommunicationCollection collection = tenantSupportTicket.GetSupportTicketNoSubCommunications(); - - // invoke the operation - string communicationName = "testcommunication"; - SupportTicketCommunicationData data = new SupportTicketCommunicationData("This is a test message from a customer!", "This is a test message from a customer!") - { - Sender = "user@contoso.com", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationName, data); - SupportTicketNoSubCommunicationResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketCommunicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubFileCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubFileCollection.cs index 64a1346ea1ac0..a3f462c5da010 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubFileCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubFileCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SupportTicketNoSubFileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFilesUnderAWorkspace() + public async Task CreateOrUpdate_CreateAFileWorkspace() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListFilesUnderFileWorkspace.json - // this example is just showing the usage of "FilesNoSubscription_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateFile.json + // this example is just showing the usage of "FilesNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,17 +36,22 @@ public async Task GetAll_ListFilesUnderAWorkspace() // get the collection of this SupportTicketNoSubFileResource SupportTicketNoSubFileCollection collection = tenantFileWorkspace.GetSupportTicketNoSubFiles(); - // invoke the operation and iterate over the result - await foreach (SupportTicketNoSubFileResource item in collection.GetAllAsync()) + // invoke the operation + string fileName = "test.txt"; + SupportFileDetailData data = new SupportFileDetailData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportFileDetailData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ChunkSize = 41423, + FileSize = 41423, + NumberOfChunks = 1, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileName, data); + SupportTicketNoSubFileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportFileDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -83,10 +88,10 @@ public async Task Get_GetDetailsOfASubscriptionFile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfASubscriptionFile() + public async Task GetAll_ListFilesUnderAWorkspace() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetFileDetails.json - // this example is just showing the usage of "FilesNoSubscription_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/ListFilesUnderFileWorkspace.json + // this example is just showing the usage of "FilesNoSubscription_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,16 +107,22 @@ public async Task Exists_GetDetailsOfASubscriptionFile() // get the collection of this SupportTicketNoSubFileResource SupportTicketNoSubFileCollection collection = tenantFileWorkspace.GetSupportTicketNoSubFiles(); - // invoke the operation - string fileName = "test.txt"; - bool result = await collection.ExistsAsync(fileName); + // invoke the operation and iterate over the result + await foreach (SupportTicketNoSubFileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportFileDetailData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfASubscriptionFile() + public async Task Exists_GetDetailsOfASubscriptionFile() { // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetFileDetails.json // this example is just showing the usage of "FilesNoSubscription_Get" operation, for the dependent resources, they will have to be created separately. @@ -132,29 +143,17 @@ public async Task GetIfExists_GetDetailsOfASubscriptionFile() // invoke the operation string fileName = "test.txt"; - NullableResponse response = await collection.GetIfExistsAsync(fileName); - SupportTicketNoSubFileResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(fileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportFileDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAFileWorkspace() + public async Task GetIfExists_GetDetailsOfASubscriptionFile() { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateFile.json - // this example is just showing the usage of "FilesNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetFileDetails.json + // this example is just showing the usage of "FilesNoSubscription_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,20 +171,21 @@ public async Task CreateOrUpdate_CreateAFileWorkspace() // invoke the operation string fileName = "test.txt"; - SupportFileDetailData data = new SupportFileDetailData() - { - ChunkSize = 41423, - FileSize = 41423, - NumberOfChunks = 1, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileName, data); - SupportTicketNoSubFileResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(fileName); + SupportTicketNoSubFileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportFileDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportFileDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubFileResource.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubFileResource.cs index 1b9f35e8bf051..47e88810d9a38 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubFileResource.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_SupportTicketNoSubFileResource.cs @@ -65,7 +65,7 @@ public async Task Update_CreateAFileWorkspace() SupportTicketNoSubFileResource supportTicketNoSubFile = client.GetSupportTicketNoSubFileResource(supportTicketNoSubFileResourceId); // invoke the operation - SupportFileDetailData data = new SupportFileDetailData() + SupportFileDetailData data = new SupportFileDetailData { ChunkSize = 41423, FileSize = 41423, @@ -101,7 +101,7 @@ public async Task Upload_UploadFile() SupportTicketNoSubFileResource supportTicketNoSubFile = client.GetSupportTicketNoSubFileResource(supportTicketNoSubFileResourceId); // invoke the operation - UploadFileContent content = new UploadFileContent() + UploadFileContent content = new UploadFileContent { Content = "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABd", ChunkIndex = 0, diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantFileWorkspaceCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantFileWorkspaceCollection.cs index c80aaf7dc9ec4..fb6c01e1febcb 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantFileWorkspaceCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantFileWorkspaceCollection.cs @@ -9,12 +9,42 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Support.Samples { public partial class Sample_TenantFileWorkspaceCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateAFileWorkspace() + { + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateFileWorkspace.json + // this example is just showing the usage of "FileWorkspacesNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this TenantFileWorkspaceResource + TenantFileWorkspaceCollection collection = tenantResource.GetTenantFileWorkspaces(); + + // invoke the operation + string fileWorkspaceName = "testworkspace"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileWorkspaceName); + TenantFileWorkspaceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileWorkspaceDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetDetailsOfAFileWorkspace() @@ -27,9 +57,7 @@ public async Task Get_GetDetailsOfAFileWorkspace() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantFileWorkspaceResource TenantFileWorkspaceCollection collection = tenantResource.GetTenantFileWorkspaces(); @@ -57,9 +85,7 @@ public async Task Exists_GetDetailsOfAFileWorkspace() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantFileWorkspaceResource TenantFileWorkspaceCollection collection = tenantResource.GetTenantFileWorkspaces(); @@ -83,9 +109,7 @@ public async Task GetIfExists_GetDetailsOfAFileWorkspace() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantFileWorkspaceResource TenantFileWorkspaceCollection collection = tenantResource.GetTenantFileWorkspaces(); @@ -108,36 +132,5 @@ public async Task GetIfExists_GetDetailsOfAFileWorkspace() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAFileWorkspace() - { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateFileWorkspace.json - // this example is just showing the usage of "FileWorkspacesNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantFileWorkspaceResource - TenantFileWorkspaceCollection collection = tenantResource.GetTenantFileWorkspaces(); - - // invoke the operation - string fileWorkspaceName = "testworkspace"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileWorkspaceName); - TenantFileWorkspaceResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileWorkspaceDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantResourceExtensions.cs new file mode 100644 index 0000000000000..3bcbf149b607a --- /dev/null +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Support.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Support.Samples +{ + public partial class Sample_TenantResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckNameAvailabilitySupportTicketsNoSubscription_ChecksWhetherNameIsAvailableForSupportTicketResource() + { + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CheckNameAvailability.json + // this example is just showing the usage of "SupportTicketsNoSubscription_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation + SupportNameAvailabilityContent content = new SupportNameAvailabilityContent("sampleName", SupportResourceType.MicrosoftSupportSupportTickets); + SupportNameAvailabilityResult result = await tenantResource.CheckNameAvailabilitySupportTicketsNoSubscriptionAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantSupportTicketCollection.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantSupportTicketCollection.cs index 29ba90f511fef..6989740e4d710 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantSupportTicketCollection.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantSupportTicketCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using Azure.ResourceManager.Support.Models; using NUnit.Framework; @@ -16,6 +17,184 @@ namespace Azure.ResourceManager.Support.Samples { public partial class Sample_TenantSupportTicketCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateATicketForBillingRelatedIssues() + { + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBillingSupportTicket.json + // this example is just showing the usage of "SupportTicketsNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this TenantSupportTicketResource + TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); + + // invoke the operation + string supportTicketName = "testticket"; + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/billing_service_guid/problemClassifications/billing_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.No, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/billing_service_guid") + { + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + TenantSupportTicketResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateATicketForSubscriptionManagementRelatedIssues() + { + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSubMgmtSupportTicket.json + // this example is just showing the usage of "SupportTicketsNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this TenantSupportTicketResource + TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); + + // invoke the operation + string supportTicketName = "testticket"; + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/subscription_management_problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/subscription_management_service_guid") + { + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + TenantSupportTicketResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateATicketForTechnicalIssueRelatedToASpecificResource() + { + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateTechnicalSupportTicket.json + // this example is just showing the usage of "SupportTicketsNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this TenantSupportTicketResource + TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); + + // invoke the operation + string supportTicketName = "testticket"; + SupportTicketData data = new SupportTicketData( + "my description", + "/providers/Microsoft.Support/services/virtual_machine_running_linux_service_guid/problemClassifications/problemClassification_guid", + SupportSeverityLevel.Moderate, + AdvancedDiagnosticConsent.Yes, + new SupportContactProfile( + "abc", + "xyz", + PreferredContactMethod.Email, + "abc@contoso.com", + "Pacific Standard Time", + "usa", + "en-US"), + "my title", + "/providers/Microsoft.Support/services/cddd3eb5-1830-b494-44fd-782f691479dc") + { + ProblemScopingQuestions = "{\"articleId\":\"076846c1-4c0b-4b21-91c6-1a30246b3867\",\"scopingDetails\":[{\"question\":\"When did the problem begin?\",\"controlId\":\"problem_start_time\",\"orderId\":1,\"inputType\":\"static\",\"answer\":{\"displayValue\":\"2023-08-31T18:55:00.739Z\",\"value\":\"2023-08-31T18:55:00.739Z\",\"type\":\"datetime\"}},{\"question\":\"API Type of the Cosmos DB account\",\"controlId\":\"api_type\",\"orderId\":2,\"inputType\":\"static\",\"answer\":{\"displayValue\":\"Table\",\"value\":\"tables\",\"type\":\"string\"}},{\"question\":\"Table name\",\"controlId\":\"collection_name_table\",\"orderId\":11,\"inputType\":\"nonstatic\",\"answer\":{\"displayValue\":\"Select Table Name\",\"value\":\"dont_know_answer\",\"type\":\"string\"}},{\"question\":\"Provide additional details about the issue you're facing\",\"controlId\":\"problem_description\",\"orderId\":12,\"inputType\":\"nonstatic\",\"answer\":{\"displayValue\":\"test ticket, please ignore and close\",\"value\":\"test ticket, please ignore and close\",\"type\":\"string\"}}]}", + SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", + FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", + SecondaryConsent = {new SecondaryConsent +{ +UserConsent = UserConsent.Yes, +SecondaryConsentType = "virtualmachinerunninglinuxservice", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); + TenantSupportTicketResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetDetailsOfATicket() + { + // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetSupportTicketDetails.json + // this example is just showing the usage of "SupportTicketsNoSubscription_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this TenantSupportTicketResource + TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); + + // invoke the operation + string supportTicketName = "testticket"; + TenantSupportTicketResource result = await collection.GetAsync(supportTicketName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SupportTicketData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListSupportTickets() @@ -28,9 +207,7 @@ public async Task GetAll_ListSupportTickets() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantSupportTicketResource TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); @@ -60,9 +237,7 @@ public async Task GetAll_ListSupportTicketsCreatedOnOrAfterACertainDateAndInOpen // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantSupportTicketResource TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); @@ -93,9 +268,7 @@ public async Task GetAll_ListSupportTicketsCreatedOnOrAfterACertainDateAndInUpda // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantSupportTicketResource TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); @@ -126,9 +299,7 @@ public async Task GetAll_ListSupportTicketsInOpenState() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantSupportTicketResource TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); @@ -159,9 +330,7 @@ public async Task GetAll_ListSupportTicketsInUpdatingState() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantSupportTicketResource TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); @@ -192,9 +361,7 @@ public async Task GetAll_ListSupportTicketsWithACertainProblemClassificationId() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantSupportTicketResource TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); @@ -225,9 +392,7 @@ public async Task GetAll_ListSupportTicketsWithACertainServiceId() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantSupportTicketResource TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); @@ -246,36 +411,6 @@ public async Task GetAll_ListSupportTicketsWithACertainServiceId() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetDetailsOfATicket() - { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/GetSupportTicketDetails.json - // this example is just showing the usage of "SupportTicketsNoSubscription_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantSupportTicketResource - TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); - - // invoke the operation - string supportTicketName = "testticket"; - TenantSupportTicketResource result = await collection.GetAsync(supportTicketName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetDetailsOfATicket() @@ -288,9 +423,7 @@ public async Task Exists_GetDetailsOfATicket() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantSupportTicketResource TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); @@ -314,9 +447,7 @@ public async Task GetIfExists_GetDetailsOfATicket() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantSupportTicketResource TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); @@ -339,122 +470,5 @@ public async Task GetIfExists_GetDetailsOfATicket() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketForBillingRelatedIssues() - { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateBillingSupportTicket.json - // this example is just showing the usage of "SupportTicketsNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantSupportTicketResource - TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); - - // invoke the operation - string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/billing_service_guid/problemClassifications/billing_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.No, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/billing_service_guid") - { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - TenantSupportTicketResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketForSubscriptionManagementRelatedIssues() - { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateSubMgmtSupportTicket.json - // this example is just showing the usage of "SupportTicketsNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantSupportTicketResource - TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); - - // invoke the operation - string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/subscription_management_service_guid/problemClassifications/subscription_management_problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/subscription_management_service_guid") - { - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - TenantSupportTicketResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATicketForTechnicalIssueRelatedToASpecificResource() - { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CreateTechnicalSupportTicket.json - // this example is just showing the usage of "SupportTicketsNoSubscription_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantSupportTicketResource - TenantSupportTicketCollection collection = tenantResource.GetTenantSupportTickets(); - - // invoke the operation - string supportTicketName = "testticket"; - SupportTicketData data = new SupportTicketData("my description", "/providers/Microsoft.Support/services/virtual_machine_running_linux_service_guid/problemClassifications/problemClassification_guid", SupportSeverityLevel.Moderate, AdvancedDiagnosticConsent.Yes, new SupportContactProfile("abc", "xyz", PreferredContactMethod.Email, "abc@contoso.com", "Pacific Standard Time", "usa", "en-US"), "my title", "/providers/Microsoft.Support/services/cddd3eb5-1830-b494-44fd-782f691479dc") - { - ProblemScopingQuestions = "{\"articleId\":\"076846c1-4c0b-4b21-91c6-1a30246b3867\",\"scopingDetails\":[{\"question\":\"When did the problem begin?\",\"controlId\":\"problem_start_time\",\"orderId\":1,\"inputType\":\"static\",\"answer\":{\"displayValue\":\"2023-08-31T18:55:00.739Z\",\"value\":\"2023-08-31T18:55:00.739Z\",\"type\":\"datetime\"}},{\"question\":\"API Type of the Cosmos DB account\",\"controlId\":\"api_type\",\"orderId\":2,\"inputType\":\"static\",\"answer\":{\"displayValue\":\"Table\",\"value\":\"tables\",\"type\":\"string\"}},{\"question\":\"Table name\",\"controlId\":\"collection_name_table\",\"orderId\":11,\"inputType\":\"nonstatic\",\"answer\":{\"displayValue\":\"Select Table Name\",\"value\":\"dont_know_answer\",\"type\":\"string\"}},{\"question\":\"Provide additional details about the issue you're facing\",\"controlId\":\"problem_description\",\"orderId\":12,\"inputType\":\"nonstatic\",\"answer\":{\"displayValue\":\"test ticket, please ignore and close\",\"value\":\"test ticket, please ignore and close\",\"type\":\"string\"}}]}", - SupportPlanId = "U291cmNlOlNDTSxDbGFyaWZ5SW5zdGFsbGF0aW9uU2l0ZUlkOjcsTGluZUl0ZW1JZDo5ODY1NzIyOSxDb250cmFjdElkOjk4NjU5MTk0LFN1YnNjcmlwdGlvbklkOjc2Y2I3N2ZhLThiMTctNGVhYi05NDkzLWI2NWRhY2U5OTgxMyw=", - FileWorkspaceName = "6f16735c-1530836f-e9970f1a-2e49-47b7-96cd-9746b83aa066", - SecondaryConsent = -{ -new SecondaryConsent() -{ -UserConsent = UserConsent.Yes, -SecondaryConsentType = "virtualmachinerunninglinuxservice", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, supportTicketName, data); - TenantSupportTicketResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SupportTicketData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantSupportTicketResource.cs b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantSupportTicketResource.cs index a82390bc2890b..4164c7a4f336d 100644 --- a/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantSupportTicketResource.cs +++ b/sdk/support/Azure.ResourceManager.Support/samples/Generated/Samples/Sample_TenantSupportTicketResource.cs @@ -16,29 +16,6 @@ namespace Azure.ResourceManager.Support.Samples { public partial class Sample_TenantSupportTicketResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckNameAvailabilitySupportTicketsNoSubscription_ChecksWhetherNameIsAvailableForSupportTicketResource() - { - // Generated from example definition: specification/support/resource-manager/Microsoft.Support/stable/2024-04-01/examples/CheckNameAvailability.json - // this example is just showing the usage of "SupportTicketsNoSubscription_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - SupportNameAvailabilityContent content = new SupportNameAvailabilityContent("sampleName", SupportResourceType.MicrosoftSupportSupportTickets); - SupportNameAvailabilityResult result = await tenantResource.CheckNameAvailabilitySupportTicketsNoSubscriptionAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetDetailsOfATicket() @@ -86,7 +63,7 @@ public async Task Update_UpdateAdvancedDiagnosticConsentOfASupportTicket() TenantSupportTicketResource tenantSupportTicket = client.GetTenantSupportTicketResource(tenantSupportTicketResourceId); // invoke the operation - UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket() + UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket { AdvancedDiagnosticConsent = AdvancedDiagnosticConsent.Yes, }; @@ -118,18 +95,15 @@ public async Task Update_UpdateContactDetailsOfASupportTicket() TenantSupportTicketResource tenantSupportTicket = client.GetTenantSupportTicketResource(tenantSupportTicketResourceId); // invoke the operation - UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket() + UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket { - ContactDetails = new SupportContactProfileContent() + ContactDetails = new SupportContactProfileContent { FirstName = "first name", LastName = "last name", PreferredContactMethod = PreferredContactMethod.Email, PrimaryEmailAddress = "test.name@contoso.com", - AdditionalEmailAddresses = -{ -"tname@contoso.com","teamtest@contoso.com" -}, + AdditionalEmailAddresses = { "tname@contoso.com", "teamtest@contoso.com" }, PhoneNumber = "123-456-7890", PreferredTimeZone = "Pacific Standard Time", Country = "USA", @@ -164,7 +138,7 @@ public async Task Update_UpdateSeverityOfASupportTicket() TenantSupportTicketResource tenantSupportTicket = client.GetTenantSupportTicketResource(tenantSupportTicketResourceId); // invoke the operation - UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket() + UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket { Severity = SupportSeverityLevel.Critical, }; @@ -196,7 +170,7 @@ public async Task Update_UpdateStatusOfASupportTicket() TenantSupportTicketResource tenantSupportTicket = client.GetTenantSupportTicketResource(tenantSupportTicketResourceId); // invoke the operation - UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket() + UpdateSupportTicket updateSupportTicket = new UpdateSupportTicket { Status = SupportTicketStatus.Closed, }; diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..8149d0507be4f --- /dev/null +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,135 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Synapse.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Synapse.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSynapsePrivateLinkHubs_ListPrivateLinkHubsInSubscription() + { + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListPrivateLinkHubsInSubscription.json + // this example is just showing the usage of "PrivateLinkHubs_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SynapsePrivateLinkHubResource item in subscriptionResource.GetSynapsePrivateLinkHubsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateLinkHubData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSynapseWorkspaces_ListWorkspacesInSubscription() + { + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspacesInSubscription.json + // this example is just showing the usage of "Workspaces_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SynapseWorkspaceResource item in subscriptionResource.GetSynapseWorkspacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSkusKustoPools_KustoPoolsListSkus() + { + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsListSkus.json + // this example is just showing the usage of "KustoPools_ListSkus" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "12345678-1234-1234-1234-123456789098"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (KustoPoolSkuDescription item in subscriptionResource.GetSkusKustoPoolsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckKustoPoolNameAvailability_KustoPoolsCheckNameAvailability() + { + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsCheckNameAvailability.json + // this example is just showing the usage of "KustoPools_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "12345678-1234-1234-1234-123456789098"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("westus"); + KustoPoolNameAvailabilityContent content = new KustoPoolNameAvailabilityContent("kustoclusterrptest4"); + KustoPoolNameAvailabilityResult result = await subscriptionResource.CheckKustoPoolNameAvailabilityAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAadOnlyAuthenticationCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAadOnlyAuthenticationCollection.cs index 91e51030899a9..6a70f47465782 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAadOnlyAuthenticationCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAadOnlyAuthenticationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseAadOnlyAuthenticationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task CreateOrUpdate_CreateOrUpdateAzureActiveDirectoryOnlyAuthenticationProperty() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetAzureADOnlyAuthentication.json - // this example is just showing the usage of "AzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateAzureADOnlyAuthentication.json + // this example is just showing the usage of "AzureADOnlyAuthentications_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetAzureActiveDirectoryOnlyAuthenticationProperty() // invoke the operation SynapseAadOnlyAuthenticationName azureADOnlyAuthenticationName = SynapseAadOnlyAuthenticationName.Default; - SynapseAadOnlyAuthenticationResource result = await collection.GetAsync(azureADOnlyAuthenticationName); + SynapseAadOnlyAuthenticationData data = new SynapseAadOnlyAuthenticationData + { + IsAadOnlyAuthenticationEnabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureADOnlyAuthenticationName, data); + SynapseAadOnlyAuthenticationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetAzureActiveDirectoryOnlyAuthenticationProperty() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task Get_GetAzureActiveDirectoryOnlyAuthenticationProperty() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetAzureADOnlyAuthentication.json // this example is just showing the usage of "AzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetAzureActiveDirectoryOnlyAuthenticationProperty() // invoke the operation SynapseAadOnlyAuthenticationName azureADOnlyAuthenticationName = SynapseAadOnlyAuthenticationName.Default; - bool result = await collection.ExistsAsync(azureADOnlyAuthenticationName); + SynapseAadOnlyAuthenticationResource result = await collection.GetAsync(azureADOnlyAuthenticationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseAadOnlyAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task GetAll_GetAListOfAzureActiveDirectoryOnlyAuthenticationProperty() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetAzureADOnlyAuthentication.json - // this example is just showing the usage of "AzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListAzureADOnlyAuthentication.json + // this example is just showing the usage of "AzureADOnlyAuthentications_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetAzureActiveDirectoryOnlyAuthenticationProperty( // get the collection of this SynapseAadOnlyAuthenticationResource SynapseAadOnlyAuthenticationCollection collection = synapseWorkspace.GetSynapseAadOnlyAuthentications(); - // invoke the operation - SynapseAadOnlyAuthenticationName azureADOnlyAuthenticationName = SynapseAadOnlyAuthenticationName.Default; - NullableResponse response = await collection.GetIfExistsAsync(azureADOnlyAuthenticationName); - SynapseAadOnlyAuthenticationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SynapseAadOnlyAuthenticationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseAadOnlyAuthenticationData resourceData = result.Data; + SynapseAadOnlyAuthenticationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task Exists_GetAzureActiveDirectoryOnlyAuthenticationProperty() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateAzureADOnlyAuthentication.json - // this example is just showing the usage of "AzureADOnlyAuthentications_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetAzureADOnlyAuthentication.json + // this example is just showing the usage of "AzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAzureActiveDirectoryOnlyAuthentic // invoke the operation SynapseAadOnlyAuthenticationName azureADOnlyAuthenticationName = SynapseAadOnlyAuthenticationName.Default; - SynapseAadOnlyAuthenticationData data = new SynapseAadOnlyAuthenticationData() - { - IsAadOnlyAuthenticationEnabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureADOnlyAuthenticationName, data); - SynapseAadOnlyAuthenticationResource result = lro.Value; + bool result = await collection.ExistsAsync(azureADOnlyAuthenticationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseAadOnlyAuthenticationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task GetIfExists_GetAzureActiveDirectoryOnlyAuthenticationProperty() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListAzureADOnlyAuthentication.json - // this example is just showing the usage of "AzureADOnlyAuthentications_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetAzureADOnlyAuthentication.json + // this example is just showing the usage of "AzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_GetAListOfAzureActiveDirectoryOnlyAuthenticationPropert // get the collection of this SynapseAadOnlyAuthenticationResource SynapseAadOnlyAuthenticationCollection collection = synapseWorkspace.GetSynapseAadOnlyAuthentications(); - // invoke the operation and iterate over the result - await foreach (SynapseAadOnlyAuthenticationResource item in collection.GetAllAsync()) + // invoke the operation + SynapseAadOnlyAuthenticationName azureADOnlyAuthenticationName = SynapseAadOnlyAuthenticationName.Default; + NullableResponse response = await collection.GetIfExistsAsync(azureADOnlyAuthenticationName); + SynapseAadOnlyAuthenticationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseAadOnlyAuthenticationData resourceData = item.Data; + SynapseAadOnlyAuthenticationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAadOnlyAuthenticationResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAadOnlyAuthenticationResource.cs index 62673529a68f4..b0473808983b0 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAadOnlyAuthenticationResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAadOnlyAuthenticationResource.cs @@ -69,7 +69,7 @@ public async Task Update_CreateOrUpdateAzureActiveDirectoryOnlyAuthenticationPro SynapseAadOnlyAuthenticationResource synapseAadOnlyAuthentication = client.GetSynapseAadOnlyAuthenticationResource(synapseAadOnlyAuthenticationResourceId); // invoke the operation - SynapseAadOnlyAuthenticationData data = new SynapseAadOnlyAuthenticationData() + SynapseAadOnlyAuthenticationData data = new SynapseAadOnlyAuthenticationData { IsAadOnlyAuthenticationEnabled = true, }; diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAttachedDatabaseConfigurationCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAttachedDatabaseConfigurationCollection.cs index 17b36cb46cfdc..dd68b56348c94 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAttachedDatabaseConfigurationCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAttachedDatabaseConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseAttachedDatabaseConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoPoolAttachedDatabaseConfigurationsListByKustoPool() + public async Task CreateOrUpdate_KustoPoolAttachedDatabaseConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsListByKustoPool.json - // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_ListByKustoPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsCreateOrUpdate.json + // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,32 @@ public async Task GetAll_KustoPoolAttachedDatabaseConfigurationsListByKustoPool( // get the collection of this SynapseAttachedDatabaseConfigurationResource SynapseAttachedDatabaseConfigurationCollection collection = synapseKustoPool.GetSynapseAttachedDatabaseConfigurations(); - // invoke the operation and iterate over the result - await foreach (SynapseAttachedDatabaseConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string attachedDatabaseConfigurationName = "attachedDatabaseConfigurations1"; + SynapseAttachedDatabaseConfigurationData data = new SynapseAttachedDatabaseConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseAttachedDatabaseConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Location = new AzureLocation("westus"), + DatabaseName = "kustodatabase", + KustoPoolResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Synapse/Workspaces/kustorptest/KustoPools/kustoclusterrptest4"), + DefaultPrincipalsModificationKind = SynapseDefaultPrincipalsModificationKind.Union, + TableLevelSharingProperties = new SynapseTableLevelSharingProperties + { + TablesToInclude = { "Table1" }, + TablesToExclude = { "Table2" }, + ExternalTablesToInclude = { "ExternalTable1" }, + ExternalTablesToExclude = { "ExternalTable2" }, + MaterializedViewsToInclude = { "MaterializedViewTable1" }, + MaterializedViewsToExclude = { "MaterializedViewTable2" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attachedDatabaseConfigurationName, data); + SynapseAttachedDatabaseConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseAttachedDatabaseConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +105,10 @@ public async Task Get_KustoPoolAttachedDatabaseConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoPoolAttachedDatabaseConfigurationsGet() + public async Task GetAll_KustoPoolAttachedDatabaseConfigurationsListByKustoPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsGet.json - // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsListByKustoPool.json + // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_ListByKustoPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +127,22 @@ public async Task Exists_KustoPoolAttachedDatabaseConfigurationsGet() // get the collection of this SynapseAttachedDatabaseConfigurationResource SynapseAttachedDatabaseConfigurationCollection collection = synapseKustoPool.GetSynapseAttachedDatabaseConfigurations(); - // invoke the operation - string attachedDatabaseConfigurationName = "attachedDatabaseConfigurations1"; - bool result = await collection.ExistsAsync(attachedDatabaseConfigurationName); + // invoke the operation and iterate over the result + await foreach (SynapseAttachedDatabaseConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseAttachedDatabaseConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoPoolAttachedDatabaseConfigurationsGet() + public async Task Exists_KustoPoolAttachedDatabaseConfigurationsGet() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsGet.json // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +166,17 @@ public async Task GetIfExists_KustoPoolAttachedDatabaseConfigurationsGet() // invoke the operation string attachedDatabaseConfigurationName = "attachedDatabaseConfigurations1"; - NullableResponse response = await collection.GetIfExistsAsync(attachedDatabaseConfigurationName); - SynapseAttachedDatabaseConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(attachedDatabaseConfigurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseAttachedDatabaseConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoPoolAttachedDatabaseConfigurationsCreateOrUpdate() + public async Task GetIfExists_KustoPoolAttachedDatabaseConfigurationsGet() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsCreateOrUpdate.json - // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsGet.json + // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,48 +197,21 @@ public async Task CreateOrUpdate_KustoPoolAttachedDatabaseConfigurationsCreateOr // invoke the operation string attachedDatabaseConfigurationName = "attachedDatabaseConfigurations1"; - SynapseAttachedDatabaseConfigurationData data = new SynapseAttachedDatabaseConfigurationData() - { - Location = new AzureLocation("westus"), - DatabaseName = "kustodatabase", - KustoPoolResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Synapse/Workspaces/kustorptest/KustoPools/kustoclusterrptest4"), - DefaultPrincipalsModificationKind = SynapseDefaultPrincipalsModificationKind.Union, - TableLevelSharingProperties = new SynapseTableLevelSharingProperties() - { - TablesToInclude = -{ -"Table1" -}, - TablesToExclude = -{ -"Table2" -}, - ExternalTablesToInclude = -{ -"ExternalTable1" -}, - ExternalTablesToExclude = -{ -"ExternalTable2" -}, - MaterializedViewsToInclude = -{ -"MaterializedViewTable1" -}, - MaterializedViewsToExclude = -{ -"MaterializedViewTable2" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attachedDatabaseConfigurationName, data); - SynapseAttachedDatabaseConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(attachedDatabaseConfigurationName); + SynapseAttachedDatabaseConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseAttachedDatabaseConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseAttachedDatabaseConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAttachedDatabaseConfigurationResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAttachedDatabaseConfigurationResource.cs index 24c45f2511e48..25de3566ab322 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAttachedDatabaseConfigurationResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseAttachedDatabaseConfigurationResource.cs @@ -50,10 +50,10 @@ public async Task Get_KustoPoolAttachedDatabaseConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoPoolAttachedDatabaseConfigurationsCreateOrUpdate() + public async Task Delete_KustoPoolAttachedDatabaseConfigurationsDelete() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsCreateOrUpdate.json - // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsDelete.json + // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,56 +71,17 @@ public async Task Update_KustoPoolAttachedDatabaseConfigurationsCreateOrUpdate() SynapseAttachedDatabaseConfigurationResource synapseAttachedDatabaseConfiguration = client.GetSynapseAttachedDatabaseConfigurationResource(synapseAttachedDatabaseConfigurationResourceId); // invoke the operation - SynapseAttachedDatabaseConfigurationData data = new SynapseAttachedDatabaseConfigurationData() - { - Location = new AzureLocation("westus"), - DatabaseName = "kustodatabase", - KustoPoolResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Synapse/Workspaces/kustorptest/KustoPools/kustoclusterrptest4"), - DefaultPrincipalsModificationKind = SynapseDefaultPrincipalsModificationKind.Union, - TableLevelSharingProperties = new SynapseTableLevelSharingProperties() - { - TablesToInclude = -{ -"Table1" -}, - TablesToExclude = -{ -"Table2" -}, - ExternalTablesToInclude = -{ -"ExternalTable1" -}, - ExternalTablesToExclude = -{ -"ExternalTable2" -}, - MaterializedViewsToInclude = -{ -"MaterializedViewTable1" -}, - MaterializedViewsToExclude = -{ -"MaterializedViewTable2" -}, - }, - }; - ArmOperation lro = await synapseAttachedDatabaseConfiguration.UpdateAsync(WaitUntil.Completed, data); - SynapseAttachedDatabaseConfigurationResource result = lro.Value; + await synapseAttachedDatabaseConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseAttachedDatabaseConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoPoolAttachedDatabaseConfigurationsDelete() + public async Task Update_KustoPoolAttachedDatabaseConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsDelete.json - // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolAttachedDatabaseConfigurationsCreateOrUpdate.json + // this example is just showing the usage of "KustoPoolAttachedDatabaseConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,9 +99,30 @@ public async Task Delete_KustoPoolAttachedDatabaseConfigurationsDelete() SynapseAttachedDatabaseConfigurationResource synapseAttachedDatabaseConfiguration = client.GetSynapseAttachedDatabaseConfigurationResource(synapseAttachedDatabaseConfigurationResourceId); // invoke the operation - await synapseAttachedDatabaseConfiguration.DeleteAsync(WaitUntil.Completed); + SynapseAttachedDatabaseConfigurationData data = new SynapseAttachedDatabaseConfigurationData + { + Location = new AzureLocation("westus"), + DatabaseName = "kustodatabase", + KustoPoolResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Synapse/Workspaces/kustorptest/KustoPools/kustoclusterrptest4"), + DefaultPrincipalsModificationKind = SynapseDefaultPrincipalsModificationKind.Union, + TableLevelSharingProperties = new SynapseTableLevelSharingProperties + { + TablesToInclude = { "Table1" }, + TablesToExclude = { "Table2" }, + ExternalTablesToInclude = { "ExternalTable1" }, + ExternalTablesToExclude = { "ExternalTable2" }, + MaterializedViewsToInclude = { "MaterializedViewTable1" }, + MaterializedViewsToExclude = { "MaterializedViewTable2" }, + }, + }; + ArmOperation lro = await synapseAttachedDatabaseConfiguration.UpdateAsync(WaitUntil.Completed, data); + SynapseAttachedDatabaseConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseAttachedDatabaseConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseBigDataPoolInfoCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseBigDataPoolInfoCollection.cs index ff8ac4b897e4d..e3e5647857c10 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseBigDataPoolInfoCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseBigDataPoolInfoCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseBigDataPoolInfoCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetABigDataPool() + public async Task CreateOrUpdate_CreateOrUpdateABigDataPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/GetBigDataPool.json - // this example is just showing the usage of "BigDataPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/CreateOrUpdateBigDataPool.json + // this example is just showing the usage of "BigDataPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,38 @@ public async Task Get_GetABigDataPool() // invoke the operation string bigDataPoolName = "ExamplePool"; - SynapseBigDataPoolInfoResource result = await collection.GetAsync(bigDataPoolName); + SynapseBigDataPoolInfoData info = new SynapseBigDataPoolInfoData(new AzureLocation("West US 2")) + { + AutoScale = new BigDataPoolAutoScaleProperties + { + MinNodeCount = 3, + IsEnabled = true, + MaxNodeCount = 50, + }, + AutoPause = new BigDataPoolAutoPauseProperties + { + DelayInMinutes = 15, + IsEnabled = true, + }, + IsAutotuneEnabled = false, + SparkEventsFolder = "/events", + NodeCount = 4, + LibraryRequirements = new BigDataPoolLibraryRequirements + { + Content = "", + Filename = "requirements.txt", + }, + SparkVersion = "2.4", + DefaultSparkLogFolder = "/logs", + NodeSize = BigDataPoolNodeSize.Medium, + NodeSizeFamily = BigDataPoolNodeSizeFamily.MemoryOptimized, + Tags = +{ +["key"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bigDataPoolName, info); + SynapseBigDataPoolInfoResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +83,7 @@ public async Task Get_GetABigDataPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetABigDataPool() + public async Task Get_GetABigDataPool() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/GetBigDataPool.json // this example is just showing the usage of "BigDataPools_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +106,21 @@ public async Task Exists_GetABigDataPool() // invoke the operation string bigDataPoolName = "ExamplePool"; - bool result = await collection.ExistsAsync(bigDataPoolName); + SynapseBigDataPoolInfoResource result = await collection.GetAsync(bigDataPoolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseBigDataPoolInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetABigDataPool() + public async Task GetAll_ListBigDataPoolsInAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/GetBigDataPool.json - // this example is just showing the usage of "BigDataPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/ListBigDataPoolsInWorkspace.json + // this example is just showing the usage of "BigDataPools_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +138,25 @@ public async Task GetIfExists_GetABigDataPool() // get the collection of this SynapseBigDataPoolInfoResource SynapseBigDataPoolInfoCollection collection = synapseWorkspace.GetSynapseBigDataPoolInfos(); - // invoke the operation - string bigDataPoolName = "ExamplePool"; - NullableResponse response = await collection.GetIfExistsAsync(bigDataPoolName); - SynapseBigDataPoolInfoResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SynapseBigDataPoolInfoResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseBigDataPoolInfoData resourceData = result.Data; + SynapseBigDataPoolInfoData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateABigDataPool() + public async Task Exists_GetABigDataPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/CreateOrUpdateBigDataPool.json - // this example is just showing the usage of "BigDataPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/GetBigDataPool.json + // this example is just showing the usage of "BigDataPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,52 +176,17 @@ public async Task CreateOrUpdate_CreateOrUpdateABigDataPool() // invoke the operation string bigDataPoolName = "ExamplePool"; - SynapseBigDataPoolInfoData info = new SynapseBigDataPoolInfoData(new AzureLocation("West US 2")) - { - AutoScale = new BigDataPoolAutoScaleProperties() - { - MinNodeCount = 3, - IsEnabled = true, - MaxNodeCount = 50, - }, - AutoPause = new BigDataPoolAutoPauseProperties() - { - DelayInMinutes = 15, - IsEnabled = true, - }, - IsAutotuneEnabled = false, - SparkEventsFolder = "/events", - NodeCount = 4, - LibraryRequirements = new BigDataPoolLibraryRequirements() - { - Content = "", - Filename = "requirements.txt", - }, - SparkVersion = "2.4", - DefaultSparkLogFolder = "/logs", - NodeSize = BigDataPoolNodeSize.Medium, - NodeSizeFamily = BigDataPoolNodeSizeFamily.MemoryOptimized, - Tags = -{ -["key"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bigDataPoolName, info); - SynapseBigDataPoolInfoResource result = lro.Value; + bool result = await collection.ExistsAsync(bigDataPoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseBigDataPoolInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBigDataPoolsInAWorkspace() + public async Task GetIfExists_GetABigDataPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/ListBigDataPoolsInWorkspace.json - // this example is just showing the usage of "BigDataPools_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/GetBigDataPool.json + // this example is just showing the usage of "BigDataPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -210,17 +204,23 @@ public async Task GetAll_ListBigDataPoolsInAWorkspace() // get the collection of this SynapseBigDataPoolInfoResource SynapseBigDataPoolInfoCollection collection = synapseWorkspace.GetSynapseBigDataPoolInfos(); - // invoke the operation and iterate over the result - await foreach (SynapseBigDataPoolInfoResource item in collection.GetAllAsync()) + // invoke the operation + string bigDataPoolName = "ExamplePool"; + NullableResponse response = await collection.GetIfExistsAsync(bigDataPoolName); + SynapseBigDataPoolInfoResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseBigDataPoolInfoData resourceData = item.Data; + SynapseBigDataPoolInfoData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseBigDataPoolInfoResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseBigDataPoolInfoResource.cs index f6043377e8bb6..742a9bcc1f05d 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseBigDataPoolInfoResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseBigDataPoolInfoResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetABigDataPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateABigDataPool() + public async Task Delete_DeleteABigDataPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/UpdateBigDataPool.json - // this example is just showing the usage of "BigDataPools_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/DeleteBigDataPool.json + // this example is just showing the usage of "BigDataPools_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,28 +69,18 @@ public async Task Update_UpdateABigDataPool() SynapseBigDataPoolInfoResource synapseBigDataPoolInfo = client.GetSynapseBigDataPoolInfoResource(synapseBigDataPoolInfoResourceId); // invoke the operation - SynapseBigDataPoolInfoPatch patch = new SynapseBigDataPoolInfoPatch() - { - Tags = -{ -["key"] = "value", -}, - }; - SynapseBigDataPoolInfoResource result = await synapseBigDataPoolInfo.UpdateAsync(patch); + ArmOperation lro = await synapseBigDataPoolInfo.DeleteAsync(WaitUntil.Completed); + BinaryData result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseBigDataPoolInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteABigDataPool() + public async Task Update_UpdateABigDataPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/DeleteBigDataPool.json - // this example is just showing the usage of "BigDataPools_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/UpdateBigDataPool.json + // this example is just showing the usage of "BigDataPools_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,10 +97,20 @@ public async Task Delete_DeleteABigDataPool() SynapseBigDataPoolInfoResource synapseBigDataPoolInfo = client.GetSynapseBigDataPoolInfoResource(synapseBigDataPoolInfoResourceId); // invoke the operation - ArmOperation lro = await synapseBigDataPoolInfo.DeleteAsync(WaitUntil.Completed); - BinaryData result = lro.Value; + SynapseBigDataPoolInfoPatch patch = new SynapseBigDataPoolInfoPatch + { + Tags = +{ +["key"] = "value" +}, + }; + SynapseBigDataPoolInfoResource result = await synapseBigDataPoolInfo.UpdateAsync(patch); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseBigDataPoolInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseClusterPrincipalAssignmentCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseClusterPrincipalAssignmentCollection.cs index a78d76b26cc50..a79759e7b6309 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseClusterPrincipalAssignmentCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseClusterPrincipalAssignmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseClusterPrincipalAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoPoolPrincipalAssignmentsList() + public async Task CreateOrUpdate_KustoPoolPrincipalAssignmentsCreateOrUpdate() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsList.json - // this example is just showing the usage of "KustoPoolPrincipalAssignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsCreateOrUpdate.json + // this example is just showing the usage of "KustoPoolPrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,23 @@ public async Task GetAll_KustoPoolPrincipalAssignmentsList() // get the collection of this SynapseClusterPrincipalAssignmentResource SynapseClusterPrincipalAssignmentCollection collection = synapseKustoPool.GetSynapseClusterPrincipalAssignments(); - // invoke the operation and iterate over the result - await foreach (SynapseClusterPrincipalAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string principalAssignmentName = "kustoprincipal1"; + SynapseClusterPrincipalAssignmentData data = new SynapseClusterPrincipalAssignmentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseClusterPrincipalAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrincipalId = "87654321-1234-1234-1234-123456789123", + Role = SynapseClusterPrincipalRole.AllDatabasesAdmin, + TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), + PrincipalType = SynapsePrincipalType.App, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, principalAssignmentName, data); + SynapseClusterPrincipalAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseClusterPrincipalAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +96,10 @@ public async Task Get_KustoPoolPrincipalAssignmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoPoolPrincipalAssignmentsGet() + public async Task GetAll_KustoPoolPrincipalAssignmentsList() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsGet.json - // this example is just showing the usage of "KustoPoolPrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsList.json + // this example is just showing the usage of "KustoPoolPrincipalAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +118,22 @@ public async Task Exists_KustoPoolPrincipalAssignmentsGet() // get the collection of this SynapseClusterPrincipalAssignmentResource SynapseClusterPrincipalAssignmentCollection collection = synapseKustoPool.GetSynapseClusterPrincipalAssignments(); - // invoke the operation - string principalAssignmentName = "kustoprincipal1"; - bool result = await collection.ExistsAsync(principalAssignmentName); + // invoke the operation and iterate over the result + await foreach (SynapseClusterPrincipalAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseClusterPrincipalAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoPoolPrincipalAssignmentsGet() + public async Task Exists_KustoPoolPrincipalAssignmentsGet() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsGet.json // this example is just showing the usage of "KustoPoolPrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +157,17 @@ public async Task GetIfExists_KustoPoolPrincipalAssignmentsGet() // invoke the operation string principalAssignmentName = "kustoprincipal1"; - NullableResponse response = await collection.GetIfExistsAsync(principalAssignmentName); - SynapseClusterPrincipalAssignmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(principalAssignmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseClusterPrincipalAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoPoolPrincipalAssignmentsCreateOrUpdate() + public async Task GetIfExists_KustoPoolPrincipalAssignmentsGet() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsCreateOrUpdate.json - // this example is just showing the usage of "KustoPoolPrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsGet.json + // this example is just showing the usage of "KustoPoolPrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,21 +188,21 @@ public async Task CreateOrUpdate_KustoPoolPrincipalAssignmentsCreateOrUpdate() // invoke the operation string principalAssignmentName = "kustoprincipal1"; - SynapseClusterPrincipalAssignmentData data = new SynapseClusterPrincipalAssignmentData() - { - PrincipalId = "87654321-1234-1234-1234-123456789123", - Role = SynapseClusterPrincipalRole.AllDatabasesAdmin, - TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), - PrincipalType = SynapsePrincipalType.App, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, principalAssignmentName, data); - SynapseClusterPrincipalAssignmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(principalAssignmentName); + SynapseClusterPrincipalAssignmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseClusterPrincipalAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseClusterPrincipalAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseClusterPrincipalAssignmentResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseClusterPrincipalAssignmentResource.cs index 76225b4df9017..b3ee9d9bee9c7 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseClusterPrincipalAssignmentResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseClusterPrincipalAssignmentResource.cs @@ -50,10 +50,10 @@ public async Task Get_KustoPoolPrincipalAssignmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoPoolPrincipalAssignmentsCreateOrUpdate() + public async Task Delete_KustoPoolPrincipalAssignmentsDelete() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsCreateOrUpdate.json - // this example is just showing the usage of "KustoPoolPrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsDelete.json + // this example is just showing the usage of "KustoPoolPrincipalAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,29 +71,17 @@ public async Task Update_KustoPoolPrincipalAssignmentsCreateOrUpdate() SynapseClusterPrincipalAssignmentResource synapseClusterPrincipalAssignment = client.GetSynapseClusterPrincipalAssignmentResource(synapseClusterPrincipalAssignmentResourceId); // invoke the operation - SynapseClusterPrincipalAssignmentData data = new SynapseClusterPrincipalAssignmentData() - { - PrincipalId = "87654321-1234-1234-1234-123456789123", - Role = SynapseClusterPrincipalRole.AllDatabasesAdmin, - TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), - PrincipalType = SynapsePrincipalType.App, - }; - ArmOperation lro = await synapseClusterPrincipalAssignment.UpdateAsync(WaitUntil.Completed, data); - SynapseClusterPrincipalAssignmentResource result = lro.Value; + await synapseClusterPrincipalAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseClusterPrincipalAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoPoolPrincipalAssignmentsDelete() + public async Task Update_KustoPoolPrincipalAssignmentsCreateOrUpdate() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsDelete.json - // this example is just showing the usage of "KustoPoolPrincipalAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolPrincipalAssignmentsCreateOrUpdate.json + // this example is just showing the usage of "KustoPoolPrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +99,21 @@ public async Task Delete_KustoPoolPrincipalAssignmentsDelete() SynapseClusterPrincipalAssignmentResource synapseClusterPrincipalAssignment = client.GetSynapseClusterPrincipalAssignmentResource(synapseClusterPrincipalAssignmentResourceId); // invoke the operation - await synapseClusterPrincipalAssignment.DeleteAsync(WaitUntil.Completed); + SynapseClusterPrincipalAssignmentData data = new SynapseClusterPrincipalAssignmentData + { + PrincipalId = "87654321-1234-1234-1234-123456789123", + Role = SynapseClusterPrincipalRole.AllDatabasesAdmin, + TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), + PrincipalType = SynapsePrincipalType.App, + }; + ArmOperation lro = await synapseClusterPrincipalAssignment.UpdateAsync(WaitUntil.Completed, data); + SynapseClusterPrincipalAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseClusterPrincipalAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataConnectionCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataConnectionCollection.cs index d5de8a06a8108..fb2f0d9fcac20 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataConnectionCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseDataConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoPoolDataConnectionsListByDatabase() + public async Task CreateOrUpdate_KustoPoolDataConnectionsCreateOrUpdateJson() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsListByDatabase.json - // this example is just showing the usage of "KustoPoolDataConnections_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsCreateOrUpdate.json + // this example is just showing the usage of "KustoPoolDataConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,22 @@ public async Task GetAll_KustoPoolDataConnectionsListByDatabase() // get the collection of this SynapseDataConnectionResource SynapseDataConnectionCollection collection = synapseDatabase.GetSynapseDataConnections(); - // invoke the operation and iterate over the result - await foreach (SynapseDataConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string dataConnectionName = "DataConnections8"; + SynapseDataConnectionData data = new SynapseEventHubDataConnection { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDataConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EventHubResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest1"), + ConsumerGroup = "testConsumerGroup1", + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataConnectionName, data); + SynapseDataConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDataConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +97,10 @@ public async Task Get_KustoPoolDataConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoPoolDataConnectionsGet() + public async Task GetAll_KustoPoolDataConnectionsListByDatabase() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsGet.json - // this example is just showing the usage of "KustoPoolDataConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsListByDatabase.json + // this example is just showing the usage of "KustoPoolDataConnections_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +120,22 @@ public async Task Exists_KustoPoolDataConnectionsGet() // get the collection of this SynapseDataConnectionResource SynapseDataConnectionCollection collection = synapseDatabase.GetSynapseDataConnections(); - // invoke the operation - string dataConnectionName = "DataConnections8"; - bool result = await collection.ExistsAsync(dataConnectionName); + // invoke the operation and iterate over the result + await foreach (SynapseDataConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDataConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoPoolDataConnectionsGet() + public async Task Exists_KustoPoolDataConnectionsGet() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsGet.json // this example is just showing the usage of "KustoPoolDataConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +160,17 @@ public async Task GetIfExists_KustoPoolDataConnectionsGet() // invoke the operation string dataConnectionName = "DataConnections8"; - NullableResponse response = await collection.GetIfExistsAsync(dataConnectionName); - SynapseDataConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDataConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoPoolDataConnectionsCreateOrUpdateJson() + public async Task GetIfExists_KustoPoolDataConnectionsGet() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsCreateOrUpdate.json - // this example is just showing the usage of "KustoPoolDataConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsGet.json + // this example is just showing the usage of "KustoPoolDataConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,20 +192,21 @@ public async Task CreateOrUpdate_KustoPoolDataConnectionsCreateOrUpdateJson() // invoke the operation string dataConnectionName = "DataConnections8"; - SynapseDataConnectionData data = new SynapseEventHubDataConnection() - { - EventHubResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest1"), - ConsumerGroup = "testConsumerGroup1", - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataConnectionName, data); - SynapseDataConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dataConnectionName); + SynapseDataConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDataConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDataConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataConnectionResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataConnectionResource.cs index 4005891d176dd..c3b0067c6d771 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataConnectionResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataConnectionResource.cs @@ -51,10 +51,10 @@ public async Task Get_KustoPoolDataConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoPoolDataConnectionsUpdate() + public async Task Delete_KustoPoolDataConnectionsDelete() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsUpdate.json - // this example is just showing the usage of "KustoPoolDataConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsDelete.json + // this example is just showing the usage of "KustoPoolDataConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,33 +68,22 @@ public async Task Update_KustoPoolDataConnectionsUpdate() string workspaceName = "synapseWorkspaceName"; string kustoPoolName = "kustoclusterrptest4"; string databaseName = "KustoDatabase8"; - string dataConnectionName = "DataConnections8"; + string dataConnectionName = "kustoeventhubconnection1"; ResourceIdentifier synapseDataConnectionResourceId = SynapseDataConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, kustoPoolName, databaseName, dataConnectionName); SynapseDataConnectionResource synapseDataConnection = client.GetSynapseDataConnectionResource(synapseDataConnectionResourceId); // invoke the operation - SynapseDataConnectionData data = new SynapseEventHubDataConnection() - { - EventHubResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest1"), - ConsumerGroup = "testConsumerGroup1", - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await synapseDataConnection.UpdateAsync(WaitUntil.Completed, data); - SynapseDataConnectionResource result = lro.Value; + await synapseDataConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDataConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoPoolDataConnectionsDelete() + public async Task Update_KustoPoolDataConnectionsUpdate() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsDelete.json - // this example is just showing the usage of "KustoPoolDataConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDataConnectionsUpdate.json + // this example is just showing the usage of "KustoPoolDataConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,14 +97,25 @@ public async Task Delete_KustoPoolDataConnectionsDelete() string workspaceName = "synapseWorkspaceName"; string kustoPoolName = "kustoclusterrptest4"; string databaseName = "KustoDatabase8"; - string dataConnectionName = "kustoeventhubconnection1"; + string dataConnectionName = "DataConnections8"; ResourceIdentifier synapseDataConnectionResourceId = SynapseDataConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, kustoPoolName, databaseName, dataConnectionName); SynapseDataConnectionResource synapseDataConnection = client.GetSynapseDataConnectionResource(synapseDataConnectionResourceId); // invoke the operation - await synapseDataConnection.DeleteAsync(WaitUntil.Completed); + SynapseDataConnectionData data = new SynapseEventHubDataConnection + { + EventHubResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest1"), + ConsumerGroup = "testConsumerGroup1", + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await synapseDataConnection.UpdateAsync(WaitUntil.Completed, data); + SynapseDataConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDataConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingPolicyResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingPolicyResource.cs index 746874352712f..5d76bc9dd784c 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingPolicyResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseDataMaskingPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMax() + public async Task Get_GetDataMaskingPolicy() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingPolicyCreateOrUpdateMax.json - // this example is just showing the usage of "DataMaskingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingPolicyGet.json + // this example is just showing the usage of "DataMaskingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,13 +38,7 @@ public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMax() SynapseDataMaskingPolicyResource synapseDataMaskingPolicy = client.GetSynapseDataMaskingPolicyResource(synapseDataMaskingPolicyResourceId); // invoke the operation - SynapseDataMaskingPolicyData data = new SynapseDataMaskingPolicyData() - { - DataMaskingState = SynapseDataMaskingState.Enabled, - ExemptPrincipals = "testuser;", - }; - ArmOperation lro = await synapseDataMaskingPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); - SynapseDataMaskingPolicyResource result = lro.Value; + SynapseDataMaskingPolicyResource result = await synapseDataMaskingPolicy.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,9 +49,9 @@ public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMax() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMin() + public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMax() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingPolicyCreateOrUpdateMin.json + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingPolicyCreateOrUpdateMax.json // this example is just showing the usage of "DataMaskingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -75,9 +69,10 @@ public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMin() SynapseDataMaskingPolicyResource synapseDataMaskingPolicy = client.GetSynapseDataMaskingPolicyResource(synapseDataMaskingPolicyResourceId); // invoke the operation - SynapseDataMaskingPolicyData data = new SynapseDataMaskingPolicyData() + SynapseDataMaskingPolicyData data = new SynapseDataMaskingPolicyData { DataMaskingState = SynapseDataMaskingState.Enabled, + ExemptPrincipals = "testuser;", }; ArmOperation lro = await synapseDataMaskingPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); SynapseDataMaskingPolicyResource result = lro.Value; @@ -91,10 +86,10 @@ public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMin() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDataMaskingPolicy() + public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMin() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingPolicyGet.json - // this example is just showing the usage of "DataMaskingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingPolicyCreateOrUpdateMin.json + // this example is just showing the usage of "DataMaskingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,7 +106,12 @@ public async Task Get_GetDataMaskingPolicy() SynapseDataMaskingPolicyResource synapseDataMaskingPolicy = client.GetSynapseDataMaskingPolicyResource(synapseDataMaskingPolicyResourceId); // invoke the operation - SynapseDataMaskingPolicyResource result = await synapseDataMaskingPolicy.GetAsync(); + SynapseDataMaskingPolicyData data = new SynapseDataMaskingPolicyData + { + DataMaskingState = SynapseDataMaskingState.Enabled, + }; + ArmOperation lro = await synapseDataMaskingPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); + SynapseDataMaskingPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingRuleCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingRuleCollection.cs index 578f9d18113bd..b9cac72092711 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingRuleCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingRuleCollection.cs @@ -42,7 +42,7 @@ public async Task CreateOrUpdate_CreateUpdateDataMaskingRuleForDefaultMax() // invoke the operation string dataMaskingRuleName = "rule1"; - SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData() + SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData { AliasName = "nickname", RuleState = SynapseDataMaskingRuleState.Enabled, @@ -87,7 +87,7 @@ public async Task CreateOrUpdate_CreateUpdateDataMaskingRuleForDefaultMin() // invoke the operation string dataMaskingRuleName = "rule1"; - SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData() + SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData { SchemaName = "dbo", TableName = "Table_1", @@ -130,7 +130,7 @@ public async Task CreateOrUpdate_CreateUpdateDataMaskingRuleForNumbers() // invoke the operation string dataMaskingRuleName = "rule1"; - SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData() + SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData { SchemaName = "dbo", TableName = "Table_1", @@ -175,7 +175,7 @@ public async Task CreateOrUpdate_CreateUpdateDataMaskingRuleForText() // invoke the operation string dataMaskingRuleName = "rule1"; - SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData() + SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData { SchemaName = "dbo", TableName = "Table_1", @@ -232,10 +232,10 @@ public async Task Get_GetDataMaskingRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDataMaskingRule() + public async Task GetAll_ListDataMaskingRules() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleGet.json - // this example is just showing the usage of "DataMaskingRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleList.json + // this example is just showing the usage of "DataMaskingRules_ListBySqlPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -254,16 +254,22 @@ public async Task Exists_GetDataMaskingRule() // get the collection of this SynapseDataMaskingRuleResource SynapseDataMaskingRuleCollection collection = synapseDataMaskingPolicy.GetSynapseDataMaskingRules(); - // invoke the operation - string dataMaskingRuleName = "rule1"; - bool result = await collection.ExistsAsync(dataMaskingRuleName); + // invoke the operation and iterate over the result + await foreach (SynapseDataMaskingRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDataMaskingRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDataMaskingRule() + public async Task Exists_GetDataMaskingRule() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleGet.json // this example is just showing the usage of "DataMaskingRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -287,29 +293,17 @@ public async Task GetIfExists_GetDataMaskingRule() // invoke the operation string dataMaskingRuleName = "rule1"; - NullableResponse response = await collection.GetIfExistsAsync(dataMaskingRuleName); - SynapseDataMaskingRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataMaskingRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDataMaskingRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDataMaskingRules() + public async Task GetIfExists_GetDataMaskingRule() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleList.json - // this example is just showing the usage of "DataMaskingRules_ListBySqlPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleGet.json + // this example is just showing the usage of "DataMaskingRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -328,17 +322,23 @@ public async Task GetAll_ListDataMaskingRules() // get the collection of this SynapseDataMaskingRuleResource SynapseDataMaskingRuleCollection collection = synapseDataMaskingPolicy.GetSynapseDataMaskingRules(); - // invoke the operation and iterate over the result - await foreach (SynapseDataMaskingRuleResource item in collection.GetAllAsync()) + // invoke the operation + string dataMaskingRuleName = "rule1"; + NullableResponse response = await collection.GetIfExistsAsync(dataMaskingRuleName); + SynapseDataMaskingRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseDataMaskingRuleData resourceData = item.Data; + SynapseDataMaskingRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingRuleResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingRuleResource.cs index 2ea8922b23978..c91d165a7d8fd 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingRuleResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDataMaskingRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseDataMaskingRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateUpdateDataMaskingRuleForDefaultMax() + public async Task Get_GetDataMaskingRule() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleCreateOrUpdateDefaultMax.json - // this example is just showing the usage of "DataMaskingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleGet.json + // this example is just showing the usage of "DataMaskingRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,7 @@ public async Task Update_CreateUpdateDataMaskingRuleForDefaultMax() SynapseDataMaskingRuleResource synapseDataMaskingRule = client.GetSynapseDataMaskingRuleResource(synapseDataMaskingRuleResourceId); // invoke the operation - SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData() - { - AliasName = "nickname", - RuleState = SynapseDataMaskingRuleState.Enabled, - SchemaName = "dbo", - TableName = "Table_1", - ColumnName = "test1", - MaskingFunction = SynapseDataMaskingFunction.Default, - }; - ArmOperation lro = await synapseDataMaskingRule.UpdateAsync(WaitUntil.Completed, data); - SynapseDataMaskingRuleResource result = lro.Value; + SynapseDataMaskingRuleResource result = await synapseDataMaskingRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -60,9 +50,9 @@ public async Task Update_CreateUpdateDataMaskingRuleForDefaultMax() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateUpdateDataMaskingRuleForDefaultMin() + public async Task Update_CreateUpdateDataMaskingRuleForDefaultMax() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleCreateOrUpdateDefaultMin.json + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleCreateOrUpdateDefaultMax.json // this example is just showing the usage of "DataMaskingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -81,8 +71,10 @@ public async Task Update_CreateUpdateDataMaskingRuleForDefaultMin() SynapseDataMaskingRuleResource synapseDataMaskingRule = client.GetSynapseDataMaskingRuleResource(synapseDataMaskingRuleResourceId); // invoke the operation - SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData() + SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData { + AliasName = "nickname", + RuleState = SynapseDataMaskingRuleState.Enabled, SchemaName = "dbo", TableName = "Table_1", ColumnName = "test1", @@ -100,9 +92,9 @@ public async Task Update_CreateUpdateDataMaskingRuleForDefaultMin() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateUpdateDataMaskingRuleForNumbers() + public async Task Update_CreateUpdateDataMaskingRuleForDefaultMin() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleCreateOrUpdateNumber.json + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleCreateOrUpdateDefaultMin.json // this example is just showing the usage of "DataMaskingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -121,14 +113,12 @@ public async Task Update_CreateUpdateDataMaskingRuleForNumbers() SynapseDataMaskingRuleResource synapseDataMaskingRule = client.GetSynapseDataMaskingRuleResource(synapseDataMaskingRuleResourceId); // invoke the operation - SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData() + SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData { SchemaName = "dbo", TableName = "Table_1", ColumnName = "test1", - MaskingFunction = SynapseDataMaskingFunction.Number, - NumberFrom = "0", - NumberTo = "2", + MaskingFunction = SynapseDataMaskingFunction.Default, }; ArmOperation lro = await synapseDataMaskingRule.UpdateAsync(WaitUntil.Completed, data); SynapseDataMaskingRuleResource result = lro.Value; @@ -142,9 +132,9 @@ public async Task Update_CreateUpdateDataMaskingRuleForNumbers() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateUpdateDataMaskingRuleForText() + public async Task Update_CreateUpdateDataMaskingRuleForNumbers() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleCreateOrUpdateText.json + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleCreateOrUpdateNumber.json // this example is just showing the usage of "DataMaskingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -163,15 +153,14 @@ public async Task Update_CreateUpdateDataMaskingRuleForText() SynapseDataMaskingRuleResource synapseDataMaskingRule = client.GetSynapseDataMaskingRuleResource(synapseDataMaskingRuleResourceId); // invoke the operation - SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData() + SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData { SchemaName = "dbo", TableName = "Table_1", ColumnName = "test1", - MaskingFunction = SynapseDataMaskingFunction.Text, - PrefixSize = "1", - SuffixSize = "0", - ReplacementString = "asdf", + MaskingFunction = SynapseDataMaskingFunction.Number, + NumberFrom = "0", + NumberTo = "2", }; ArmOperation lro = await synapseDataMaskingRule.UpdateAsync(WaitUntil.Completed, data); SynapseDataMaskingRuleResource result = lro.Value; @@ -185,10 +174,10 @@ public async Task Update_CreateUpdateDataMaskingRuleForText() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDataMaskingRule() + public async Task Update_CreateUpdateDataMaskingRuleForText() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleGet.json - // this example is just showing the usage of "DataMaskingRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DataMaskingRuleCreateOrUpdateText.json + // this example is just showing the usage of "DataMaskingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -206,7 +195,18 @@ public async Task Get_GetDataMaskingRule() SynapseDataMaskingRuleResource synapseDataMaskingRule = client.GetSynapseDataMaskingRuleResource(synapseDataMaskingRuleResourceId); // invoke the operation - SynapseDataMaskingRuleResource result = await synapseDataMaskingRule.GetAsync(); + SynapseDataMaskingRuleData data = new SynapseDataMaskingRuleData + { + SchemaName = "dbo", + TableName = "Table_1", + ColumnName = "test1", + MaskingFunction = SynapseDataMaskingFunction.Text, + PrefixSize = "1", + SuffixSize = "0", + ReplacementString = "asdf", + }; + ArmOperation lro = await synapseDataMaskingRule.UpdateAsync(WaitUntil.Completed, data); + SynapseDataMaskingRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabaseCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabaseCollection.cs index 41f67264e9225..41fd8f7123908 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabaseCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabaseCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SynapseDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoDatabasesListByKustoPool() + public async Task CreateOrUpdate_KustoPoolDatabasesCreateOrUpdate() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoDatabasesListByKustoPool.json - // this example is just showing the usage of "KustoPoolDatabases_ListByKustoPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasesCreateOrUpdate.json + // this example is just showing the usage of "KustoPoolDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,21 @@ public async Task GetAll_KustoDatabasesListByKustoPool() // get the collection of this SynapseDatabaseResource SynapseDatabaseCollection collection = synapseKustoPool.GetSynapseDatabases(); - // invoke the operation and iterate over the result - await foreach (SynapseDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "KustoDatabase8"; + SynapseDatabaseData data = new SynapseReadWriteDatabase { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SoftDeletePeriod = XmlConvert.ToTimeSpan("P1D"), + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SynapseDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +95,10 @@ public async Task Get_KustoPoolDatabasesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoPoolDatabasesGet() + public async Task GetAll_KustoDatabasesListByKustoPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasesGet.json - // this example is just showing the usage of "KustoPoolDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoDatabasesListByKustoPool.json + // this example is just showing the usage of "KustoPoolDatabases_ListByKustoPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +117,22 @@ public async Task Exists_KustoPoolDatabasesGet() // get the collection of this SynapseDatabaseResource SynapseDatabaseCollection collection = synapseKustoPool.GetSynapseDatabases(); - // invoke the operation - string databaseName = "KustoDatabase8"; - bool result = await collection.ExistsAsync(databaseName); + // invoke the operation and iterate over the result + await foreach (SynapseDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoPoolDatabasesGet() + public async Task Exists_KustoPoolDatabasesGet() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasesGet.json // this example is just showing the usage of "KustoPoolDatabases_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +156,17 @@ public async Task GetIfExists_KustoPoolDatabasesGet() // invoke the operation string databaseName = "KustoDatabase8"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - SynapseDatabaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(databaseName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoPoolDatabasesCreateOrUpdate() + public async Task GetIfExists_KustoPoolDatabasesGet() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasesCreateOrUpdate.json - // this example is just showing the usage of "KustoPoolDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasesGet.json + // this example is just showing the usage of "KustoPoolDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,19 +187,21 @@ public async Task CreateOrUpdate_KustoPoolDatabasesCreateOrUpdate() // invoke the operation string databaseName = "KustoDatabase8"; - SynapseDatabaseData data = new SynapseReadWriteDatabase() - { - SoftDeletePeriod = XmlConvert.ToTimeSpan("P1D"), - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SynapseDatabaseResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + SynapseDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabasePrincipalAssignmentCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabasePrincipalAssignmentCollection.cs index 4b5fae9b7e5ef..cc96827b57a97 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabasePrincipalAssignmentCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabasePrincipalAssignmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseDatabasePrincipalAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoPoolDatabasePrincipalAssignmentsList() + public async Task CreateOrUpdate_KustoPoolDatabasePrincipalAssignmentsCreateOrUpdate() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsList.json - // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsCreateOrUpdate.json + // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,23 @@ public async Task GetAll_KustoPoolDatabasePrincipalAssignmentsList() // get the collection of this SynapseDatabasePrincipalAssignmentResource SynapseDatabasePrincipalAssignmentCollection collection = synapseDatabase.GetSynapseDatabasePrincipalAssignments(); - // invoke the operation and iterate over the result - await foreach (SynapseDatabasePrincipalAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string principalAssignmentName = "kustoprincipal1"; + SynapseDatabasePrincipalAssignmentData data = new SynapseDatabasePrincipalAssignmentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDatabasePrincipalAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrincipalId = "87654321-1234-1234-1234-123456789123", + Role = SynapseDatabasePrincipalRole.Admin, + TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), + PrincipalType = SynapsePrincipalType.App, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, principalAssignmentName, data); + SynapseDatabasePrincipalAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDatabasePrincipalAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +98,10 @@ public async Task Get_KustoPoolDatabasePrincipalAssignmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoPoolDatabasePrincipalAssignmentsGet() + public async Task GetAll_KustoPoolDatabasePrincipalAssignmentsList() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsGet.json - // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsList.json + // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +121,22 @@ public async Task Exists_KustoPoolDatabasePrincipalAssignmentsGet() // get the collection of this SynapseDatabasePrincipalAssignmentResource SynapseDatabasePrincipalAssignmentCollection collection = synapseDatabase.GetSynapseDatabasePrincipalAssignments(); - // invoke the operation - string principalAssignmentName = "kustoprincipal1"; - bool result = await collection.ExistsAsync(principalAssignmentName); + // invoke the operation and iterate over the result + await foreach (SynapseDatabasePrincipalAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDatabasePrincipalAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoPoolDatabasePrincipalAssignmentsGet() + public async Task Exists_KustoPoolDatabasePrincipalAssignmentsGet() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsGet.json // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +161,17 @@ public async Task GetIfExists_KustoPoolDatabasePrincipalAssignmentsGet() // invoke the operation string principalAssignmentName = "kustoprincipal1"; - NullableResponse response = await collection.GetIfExistsAsync(principalAssignmentName); - SynapseDatabasePrincipalAssignmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(principalAssignmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDatabasePrincipalAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoPoolDatabasePrincipalAssignmentsCreateOrUpdate() + public async Task GetIfExists_KustoPoolDatabasePrincipalAssignmentsGet() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsCreateOrUpdate.json - // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsGet.json + // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,21 +193,21 @@ public async Task CreateOrUpdate_KustoPoolDatabasePrincipalAssignmentsCreateOrUp // invoke the operation string principalAssignmentName = "kustoprincipal1"; - SynapseDatabasePrincipalAssignmentData data = new SynapseDatabasePrincipalAssignmentData() - { - PrincipalId = "87654321-1234-1234-1234-123456789123", - Role = SynapseDatabasePrincipalRole.Admin, - TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), - PrincipalType = SynapsePrincipalType.App, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, principalAssignmentName, data); - SynapseDatabasePrincipalAssignmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(principalAssignmentName); + SynapseDatabasePrincipalAssignmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDatabasePrincipalAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDatabasePrincipalAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabasePrincipalAssignmentResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabasePrincipalAssignmentResource.cs index b6694e0ef35b1..bf98235d17baa 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabasePrincipalAssignmentResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabasePrincipalAssignmentResource.cs @@ -51,10 +51,10 @@ public async Task Get_KustoPoolDatabasePrincipalAssignmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoPoolDatabasePrincipalAssignmentsCreateOrUpdate() + public async Task Delete_KustoPoolDatabasePrincipalAssignmentsDelete() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsCreateOrUpdate.json - // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsDelete.json + // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,29 +73,17 @@ public async Task Update_KustoPoolDatabasePrincipalAssignmentsCreateOrUpdate() SynapseDatabasePrincipalAssignmentResource synapseDatabasePrincipalAssignment = client.GetSynapseDatabasePrincipalAssignmentResource(synapseDatabasePrincipalAssignmentResourceId); // invoke the operation - SynapseDatabasePrincipalAssignmentData data = new SynapseDatabasePrincipalAssignmentData() - { - PrincipalId = "87654321-1234-1234-1234-123456789123", - Role = SynapseDatabasePrincipalRole.Admin, - TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), - PrincipalType = SynapsePrincipalType.App, - }; - ArmOperation lro = await synapseDatabasePrincipalAssignment.UpdateAsync(WaitUntil.Completed, data); - SynapseDatabasePrincipalAssignmentResource result = lro.Value; + await synapseDatabasePrincipalAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDatabasePrincipalAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoPoolDatabasePrincipalAssignmentsDelete() + public async Task Update_KustoPoolDatabasePrincipalAssignmentsCreateOrUpdate() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsDelete.json - // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasePrincipalAssignmentsCreateOrUpdate.json + // this example is just showing the usage of "KustoPoolDatabasePrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +102,21 @@ public async Task Delete_KustoPoolDatabasePrincipalAssignmentsDelete() SynapseDatabasePrincipalAssignmentResource synapseDatabasePrincipalAssignment = client.GetSynapseDatabasePrincipalAssignmentResource(synapseDatabasePrincipalAssignmentResourceId); // invoke the operation - await synapseDatabasePrincipalAssignment.DeleteAsync(WaitUntil.Completed); + SynapseDatabasePrincipalAssignmentData data = new SynapseDatabasePrincipalAssignmentData + { + PrincipalId = "87654321-1234-1234-1234-123456789123", + Role = SynapseDatabasePrincipalRole.Admin, + TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), + PrincipalType = SynapsePrincipalType.App, + }; + ArmOperation lro = await synapseDatabasePrincipalAssignment.UpdateAsync(WaitUntil.Completed, data); + SynapseDatabasePrincipalAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDatabasePrincipalAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabaseResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabaseResource.cs index 5c0de03efba96..8dab58a65e17d 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabaseResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDatabaseResource.cs @@ -51,10 +51,10 @@ public async Task Get_KustoPoolDatabasesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoPoolDatabasesUpdate() + public async Task Delete_KustoPoolDatabasesDelete() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasesUpdate.json - // this example is just showing the usage of "KustoPoolDatabases_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasesDelete.json + // this example is just showing the usage of "KustoPoolDatabases_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,26 +72,17 @@ public async Task Update_KustoPoolDatabasesUpdate() SynapseDatabaseResource synapseDatabase = client.GetSynapseDatabaseResource(synapseDatabaseResourceId); // invoke the operation - SynapseDatabaseData data = new SynapseReadWriteDatabase() - { - SoftDeletePeriod = XmlConvert.ToTimeSpan("P1D"), - }; - ArmOperation lro = await synapseDatabase.UpdateAsync(WaitUntil.Completed, data); - SynapseDatabaseResource result = lro.Value; + await synapseDatabase.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoPoolDatabasesDelete() + public async Task Update_KustoPoolDatabasesUpdate() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasesDelete.json - // this example is just showing the usage of "KustoPoolDatabases_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolDatabasesUpdate.json + // this example is just showing the usage of "KustoPoolDatabases_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +100,18 @@ public async Task Delete_KustoPoolDatabasesDelete() SynapseDatabaseResource synapseDatabase = client.GetSynapseDatabaseResource(synapseDatabaseResourceId); // invoke the operation - await synapseDatabase.DeleteAsync(WaitUntil.Completed); + SynapseDatabaseData data = new SynapseReadWriteDatabase + { + SoftDeletePeriod = XmlConvert.ToTimeSpan("P1D"), + }; + ArmOperation lro = await synapseDatabase.UpdateAsync(WaitUntil.Completed, data); + SynapseDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -166,7 +166,7 @@ public async Task ValidateDataConnection_KustoPoolDataConnectionValidation() SynapseDatabaseResource synapseDatabase = client.GetSynapseDatabaseResource(synapseDatabaseResourceId); // invoke the operation - SynapseDataConnectionValidation synapseDataConnectionValidation = new SynapseDataConnectionValidation() + SynapseDataConnectionValidation synapseDataConnectionValidation = new SynapseDataConnectionValidation { DataConnectionName = "DataConnections8", Properties = new SynapseEventHubDataConnection(), diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDedicatedSqlMinimalTlsSettingCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDedicatedSqlMinimalTlsSettingCollection.cs index da497d6134070..01c2458414590 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDedicatedSqlMinimalTlsSettingCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseDedicatedSqlMinimalTlsSettingCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetWorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettings [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettings() + public async Task GetAll_ListDedicatedSqlMinimalTlsSettingsOfTheWorkspaceManagedSqlServer() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerDedicatedSQLminimalTlsSettings.json - // this example is just showing the usage of "WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerDedicatedSQLminimalTlsSettings.json + // this example is just showing the usage of "WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetWorkspaceManagedSqlServerDedicatedSqlMinimalTlsSetti // get the collection of this SynapseDedicatedSqlMinimalTlsSettingResource SynapseDedicatedSqlMinimalTlsSettingCollection collection = synapseWorkspace.GetSynapseDedicatedSqlMinimalTlsSettings(); - // invoke the operation - string dedicatedSQLminimalTlsSettingsName = "default"; - bool result = await collection.ExistsAsync(dedicatedSQLminimalTlsSettingsName); + // invoke the operation and iterate over the result + await foreach (SynapseDedicatedSqlMinimalTlsSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseDedicatedSqlMinimalTlsSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettings() + public async Task Exists_GetWorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettings() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerDedicatedSQLminimalTlsSettings.json // this example is just showing the usage of "WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetWorkspaceManagedSqlServerDedicatedSqlMinimalTls // invoke the operation string dedicatedSQLminimalTlsSettingsName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(dedicatedSQLminimalTlsSettingsName); - SynapseDedicatedSqlMinimalTlsSettingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dedicatedSQLminimalTlsSettingsName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseDedicatedSqlMinimalTlsSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDedicatedSqlMinimalTlsSettingsOfTheWorkspaceManagedSqlServer() + public async Task GetIfExists_GetWorkspaceManagedSqlServerDedicatedSqlMinimalTlsSettings() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerDedicatedSQLminimalTlsSettings.json - // this example is just showing the usage of "WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerDedicatedSQLminimalTlsSettings.json + // this example is just showing the usage of "WorkspaceManagedSqlServerDedicatedSQLMinimalTlsSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ListDedicatedSqlMinimalTlsSettingsOfTheWorkspaceManaged // get the collection of this SynapseDedicatedSqlMinimalTlsSettingResource SynapseDedicatedSqlMinimalTlsSettingCollection collection = synapseWorkspace.GetSynapseDedicatedSqlMinimalTlsSettings(); - // invoke the operation and iterate over the result - await foreach (SynapseDedicatedSqlMinimalTlsSettingResource item in collection.GetAllAsync()) + // invoke the operation + string dedicatedSQLminimalTlsSettingsName = "default"; + NullableResponse response = await collection.GetIfExistsAsync(dedicatedSQLminimalTlsSettingsName); + SynapseDedicatedSqlMinimalTlsSettingResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseDedicatedSqlMinimalTlsSettingData resourceData = item.Data; + SynapseDedicatedSqlMinimalTlsSettingData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseEncryptionProtectorCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseEncryptionProtectorCollection.cs index 602417359188f..36e9a04c8655b 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseEncryptionProtectorCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseEncryptionProtectorCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseEncryptionProtectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceManagedSqlServerSEncryptionProtector() + public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToKeyVault() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerEncryptionProtector.json - // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/WorkspaceManagedSqlServerEncryptionProtectorCreateOrUpdateKeyVault.json + // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,13 @@ public async Task Get_GetWorkspaceManagedSqlServerSEncryptionProtector() // invoke the operation SynapseEncryptionProtectorName encryptionProtectorName = SynapseEncryptionProtectorName.Current; - SynapseEncryptionProtectorResource result = await collection.GetAsync(encryptionProtectorName); + SynapseEncryptionProtectorData data = new SynapseEncryptionProtectorData + { + ServerKeyName = "someVault_someKey_01234567890123456789012345678901", + ServerKeyType = SynapseServerKeyType.AzureKeyVault, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); + SynapseEncryptionProtectorResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +58,10 @@ public async Task Get_GetWorkspaceManagedSqlServerSEncryptionProtector() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceManagedSqlServerSEncryptionProtector() + public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToServiceManaged() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerEncryptionProtector.json - // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/WorkspaceManagedSqlServerEncryptionProtectorCreateOrUpdateServiceManaged.json + // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +81,24 @@ public async Task Exists_GetWorkspaceManagedSqlServerSEncryptionProtector() // invoke the operation SynapseEncryptionProtectorName encryptionProtectorName = SynapseEncryptionProtectorName.Current; - bool result = await collection.ExistsAsync(encryptionProtectorName); + SynapseEncryptionProtectorData data = new SynapseEncryptionProtectorData + { + ServerKeyName = "ServiceManaged", + ServerKeyType = SynapseServerKeyType.ServiceManaged, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); + SynapseEncryptionProtectorResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseEncryptionProtectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceManagedSqlServerSEncryptionProtector() + public async Task Get_GetWorkspaceManagedSqlServerSEncryptionProtector() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerEncryptionProtector.json // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +121,21 @@ public async Task GetIfExists_GetWorkspaceManagedSqlServerSEncryptionProtector() // invoke the operation SynapseEncryptionProtectorName encryptionProtectorName = SynapseEncryptionProtectorName.Current; - NullableResponse response = await collection.GetIfExistsAsync(encryptionProtectorName); - SynapseEncryptionProtectorResource result = response.HasValue ? response.Value : null; + SynapseEncryptionProtectorResource result = await collection.GetAsync(encryptionProtectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseEncryptionProtectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseEncryptionProtectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToKeyVault() + public async Task GetAll_GetWorkspaceManagedSqlServerSEncryptionProtectors() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/WorkspaceManagedSqlServerEncryptionProtectorCreateOrUpdateKeyVault.json - // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerEncryptionProtectorList.json + // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,29 +153,25 @@ public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToKeyVault() // get the collection of this SynapseEncryptionProtectorResource SynapseEncryptionProtectorCollection collection = synapseWorkspace.GetSynapseEncryptionProtectors(); - // invoke the operation - SynapseEncryptionProtectorName encryptionProtectorName = SynapseEncryptionProtectorName.Current; - SynapseEncryptionProtectorData data = new SynapseEncryptionProtectorData() + // invoke the operation and iterate over the result + await foreach (SynapseEncryptionProtectorResource item in collection.GetAllAsync()) { - ServerKeyName = "someVault_someKey_01234567890123456789012345678901", - ServerKeyType = SynapseServerKeyType.AzureKeyVault, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); - SynapseEncryptionProtectorResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseEncryptionProtectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseEncryptionProtectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToServiceManaged() + public async Task Exists_GetWorkspaceManagedSqlServerSEncryptionProtector() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/WorkspaceManagedSqlServerEncryptionProtectorCreateOrUpdateServiceManaged.json - // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerEncryptionProtector.json + // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,27 +191,17 @@ public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToServiceManaged() // invoke the operation SynapseEncryptionProtectorName encryptionProtectorName = SynapseEncryptionProtectorName.Current; - SynapseEncryptionProtectorData data = new SynapseEncryptionProtectorData() - { - ServerKeyName = "ServiceManaged", - ServerKeyType = SynapseServerKeyType.ServiceManaged, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); - SynapseEncryptionProtectorResource result = lro.Value; + bool result = await collection.ExistsAsync(encryptionProtectorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseEncryptionProtectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetWorkspaceManagedSqlServerSEncryptionProtectors() + public async Task GetIfExists_GetWorkspaceManagedSqlServerSEncryptionProtector() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerEncryptionProtectorList.json - // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerEncryptionProtector.json + // this example is just showing the usage of "WorkspaceManagedSqlServerEncryptionProtector_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -225,17 +219,23 @@ public async Task GetAll_GetWorkspaceManagedSqlServerSEncryptionProtectors() // get the collection of this SynapseEncryptionProtectorResource SynapseEncryptionProtectorCollection collection = synapseWorkspace.GetSynapseEncryptionProtectors(); - // invoke the operation and iterate over the result - await foreach (SynapseEncryptionProtectorResource item in collection.GetAllAsync()) + // invoke the operation + SynapseEncryptionProtectorName encryptionProtectorName = SynapseEncryptionProtectorName.Current; + NullableResponse response = await collection.GetIfExistsAsync(encryptionProtectorName); + SynapseEncryptionProtectorResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseEncryptionProtectorData resourceData = item.Data; + SynapseEncryptionProtectorData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseEncryptionProtectorResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseEncryptionProtectorResource.cs index 33db9e595c89c..c6220cde208ee 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseEncryptionProtectorResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseEncryptionProtectorResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdateTheEncryptionProtectorToKeyVault() SynapseEncryptionProtectorResource synapseEncryptionProtector = client.GetSynapseEncryptionProtectorResource(synapseEncryptionProtectorResourceId); // invoke the operation - SynapseEncryptionProtectorData data = new SynapseEncryptionProtectorData() + SynapseEncryptionProtectorData data = new SynapseEncryptionProtectorData { ServerKeyName = "someVault_someKey_01234567890123456789012345678901", ServerKeyType = SynapseServerKeyType.AzureKeyVault, @@ -106,7 +106,7 @@ public async Task Update_UpdateTheEncryptionProtectorToServiceManaged() SynapseEncryptionProtectorResource synapseEncryptionProtector = client.GetSynapseEncryptionProtectorResource(synapseEncryptionProtectorResourceId); // invoke the operation - SynapseEncryptionProtectorData data = new SynapseEncryptionProtectorData() + SynapseEncryptionProtectorData data = new SynapseEncryptionProtectorData { ServerKeyName = "ServiceManaged", ServerKeyType = SynapseServerKeyType.ServiceManaged, diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedServerBlobAuditingPolicyCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedServerBlobAuditingPolicyCollection.cs index 5f22b725692df..24feed3ad23d3 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedServerBlobAuditingPolicyCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedServerBlobAuditingPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseExtendedServerBlobAuditingPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceManagedSqlServersExtendedBlobAuditingSettings() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceManagedSqlServerSExtendedBlobAuditingPolicyOfWithAllParameters() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlExtendedServerBlobAuditingSettings.json - // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateWorkspaceManagedSqlServerExtendedBlobAuditingSettingsWithAllParameters.json + // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,20 @@ public async Task Get_GetWorkspaceManagedSqlServersExtendedBlobAuditingSettings( // invoke the operation SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; - SynapseExtendedServerBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); + SynapseExtendedServerBlobAuditingPolicyData data = new SynapseExtendedServerBlobAuditingPolicyData + { + PredicateExpression = "object_name = 'SensitiveData'", + State = SynapseBlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + RetentionDays = 6, + AuditActionsAndGroups = { "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP" }, + StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), + IsStorageSecondaryKeyInUse = false, + IsAzureMonitorTargetEnabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + SynapseExtendedServerBlobAuditingPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +65,10 @@ public async Task Get_GetWorkspaceManagedSqlServersExtendedBlobAuditingSettings( [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceManagedSqlServersExtendedBlobAuditingSettings() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceManagedSqlServerSExtendedBlobAuditingPolicyOfWithMinimalParameters() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlExtendedServerBlobAuditingSettings.json - // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateWorkspaceManagedSqlServerExetendedBlobAuditingSettingsWithMinParameters.json + // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +88,25 @@ public async Task Exists_GetWorkspaceManagedSqlServersExtendedBlobAuditingSettin // invoke the operation SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; - bool result = await collection.ExistsAsync(blobAuditingPolicyName); + SynapseExtendedServerBlobAuditingPolicyData data = new SynapseExtendedServerBlobAuditingPolicyData + { + State = SynapseBlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + SynapseExtendedServerBlobAuditingPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseExtendedServerBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceManagedSqlServersExtendedBlobAuditingSettings() + public async Task Get_GetWorkspaceManagedSqlServersExtendedBlobAuditingSettings() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlExtendedServerBlobAuditingSettings.json // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +129,21 @@ public async Task GetIfExists_GetWorkspaceManagedSqlServersExtendedBlobAuditingS // invoke the operation SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); - SynapseExtendedServerBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; + SynapseExtendedServerBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseExtendedServerBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseExtendedServerBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceManagedSqlServerSExtendedBlobAuditingPolicyOfWithAllParameters() + public async Task GetAll_GetWorkspaceManagedSqlServerSExtendedBlobAuditingSettings() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateWorkspaceManagedSqlServerExtendedBlobAuditingSettingsWithAllParameters.json - // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerExtendedBlobAuditingSettings.json + // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,39 +161,25 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceManagedSqlServerSExtende // get the collection of this SynapseExtendedServerBlobAuditingPolicyResource SynapseExtendedServerBlobAuditingPolicyCollection collection = synapseWorkspace.GetSynapseExtendedServerBlobAuditingPolicies(); - // invoke the operation - SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; - SynapseExtendedServerBlobAuditingPolicyData data = new SynapseExtendedServerBlobAuditingPolicyData() + // invoke the operation and iterate over the result + await foreach (SynapseExtendedServerBlobAuditingPolicyResource item in collection.GetAllAsync()) { - PredicateExpression = "object_name = 'SensitiveData'", - State = SynapseBlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - RetentionDays = 6, - AuditActionsAndGroups = -{ -"SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP","FAILED_DATABASE_AUTHENTICATION_GROUP","BATCH_COMPLETED_GROUP" -}, - StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), - IsStorageSecondaryKeyInUse = false, - IsAzureMonitorTargetEnabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - SynapseExtendedServerBlobAuditingPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseExtendedServerBlobAuditingPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseExtendedServerBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceManagedSqlServerSExtendedBlobAuditingPolicyOfWithMinimalParameters() + public async Task Exists_GetWorkspaceManagedSqlServersExtendedBlobAuditingSettings() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateWorkspaceManagedSqlServerExetendedBlobAuditingSettingsWithMinParameters.json - // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlExtendedServerBlobAuditingSettings.json + // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -197,28 +199,17 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceManagedSqlServerSExtende // invoke the operation SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; - SynapseExtendedServerBlobAuditingPolicyData data = new SynapseExtendedServerBlobAuditingPolicyData() - { - State = SynapseBlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - SynapseExtendedServerBlobAuditingPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(blobAuditingPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseExtendedServerBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetWorkspaceManagedSqlServerSExtendedBlobAuditingSettings() + public async Task GetIfExists_GetWorkspaceManagedSqlServersExtendedBlobAuditingSettings() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerExtendedBlobAuditingSettings.json - // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlExtendedServerBlobAuditingSettings.json + // this example is just showing the usage of "WorkspaceManagedSqlServerExtendedBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,17 +227,23 @@ public async Task GetAll_GetWorkspaceManagedSqlServerSExtendedBlobAuditingSettin // get the collection of this SynapseExtendedServerBlobAuditingPolicyResource SynapseExtendedServerBlobAuditingPolicyCollection collection = synapseWorkspace.GetSynapseExtendedServerBlobAuditingPolicies(); - // invoke the operation and iterate over the result - await foreach (SynapseExtendedServerBlobAuditingPolicyResource item in collection.GetAllAsync()) + // invoke the operation + SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); + SynapseExtendedServerBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseExtendedServerBlobAuditingPolicyData resourceData = item.Data; + SynapseExtendedServerBlobAuditingPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedServerBlobAuditingPolicyResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedServerBlobAuditingPolicyResource.cs index c77017417392f..427e0e3aa2a62 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedServerBlobAuditingPolicyResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedServerBlobAuditingPolicyResource.cs @@ -69,17 +69,14 @@ public async Task Update_CreateOrUpdateWorkspaceManagedSqlServerSExtendedBlobAud SynapseExtendedServerBlobAuditingPolicyResource synapseExtendedServerBlobAuditingPolicy = client.GetSynapseExtendedServerBlobAuditingPolicyResource(synapseExtendedServerBlobAuditingPolicyResourceId); // invoke the operation - SynapseExtendedServerBlobAuditingPolicyData data = new SynapseExtendedServerBlobAuditingPolicyData() + SynapseExtendedServerBlobAuditingPolicyData data = new SynapseExtendedServerBlobAuditingPolicyData { PredicateExpression = "object_name = 'SensitiveData'", State = SynapseBlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", RetentionDays = 6, - AuditActionsAndGroups = -{ -"SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP","FAILED_DATABASE_AUTHENTICATION_GROUP","BATCH_COMPLETED_GROUP" -}, + AuditActionsAndGroups = { "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP" }, StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), IsStorageSecondaryKeyInUse = false, IsAzureMonitorTargetEnabled = true, @@ -116,7 +113,7 @@ public async Task Update_CreateOrUpdateWorkspaceManagedSqlServerSExtendedBlobAud SynapseExtendedServerBlobAuditingPolicyResource synapseExtendedServerBlobAuditingPolicy = client.GetSynapseExtendedServerBlobAuditingPolicyResource(synapseExtendedServerBlobAuditingPolicyResourceId); // invoke the operation - SynapseExtendedServerBlobAuditingPolicyData data = new SynapseExtendedServerBlobAuditingPolicyData() + SynapseExtendedServerBlobAuditingPolicyData data = new SynapseExtendedServerBlobAuditingPolicyData { State = SynapseBlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedSqlPoolBlobAuditingPolicyResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedSqlPoolBlobAuditingPolicyResource.cs index 47258a3224e8d..18e4093fd93de 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedSqlPoolBlobAuditingPolicyResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseExtendedSqlPoolBlobAuditingPolicyResource.cs @@ -69,7 +69,7 @@ public async Task CreateOrUpdate_CreateOrUpdateAnExtendedSQLPoolSAzureMonitorAud SynapseExtendedSqlPoolBlobAuditingPolicyResource synapseExtendedSqlPoolBlobAuditingPolicy = client.GetSynapseExtendedSqlPoolBlobAuditingPolicyResource(synapseExtendedSqlPoolBlobAuditingPolicyResourceId); // invoke the operation - SynapseExtendedSqlPoolBlobAuditingPolicyData data = new SynapseExtendedSqlPoolBlobAuditingPolicyData() + SynapseExtendedSqlPoolBlobAuditingPolicyData data = new SynapseExtendedSqlPoolBlobAuditingPolicyData { State = SynapseBlobAuditingPolicyState.Enabled, IsAzureMonitorTargetEnabled = true, @@ -106,17 +106,14 @@ public async Task CreateOrUpdate_CreateOrUpdateAnExtendedSqlPoolSBlobAuditingPol SynapseExtendedSqlPoolBlobAuditingPolicyResource synapseExtendedSqlPoolBlobAuditingPolicy = client.GetSynapseExtendedSqlPoolBlobAuditingPolicyResource(synapseExtendedSqlPoolBlobAuditingPolicyResourceId); // invoke the operation - SynapseExtendedSqlPoolBlobAuditingPolicyData data = new SynapseExtendedSqlPoolBlobAuditingPolicyData() + SynapseExtendedSqlPoolBlobAuditingPolicyData data = new SynapseExtendedSqlPoolBlobAuditingPolicyData { PredicateExpression = "statement = 'select 1'", State = SynapseBlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", RetentionDays = 6, - AuditActionsAndGroups = -{ -"DATABASE_LOGOUT_GROUP","DATABASE_ROLE_MEMBER_CHANGE_GROUP","UPDATE on database::TestDatabaseName by public" -}, + AuditActionsAndGroups = { "DATABASE_LOGOUT_GROUP", "DATABASE_ROLE_MEMBER_CHANGE_GROUP", "UPDATE on database::TestDatabaseName by public" }, StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), IsStorageSecondaryKeyInUse = false, IsAzureMonitorTargetEnabled = true, @@ -153,7 +150,7 @@ public async Task CreateOrUpdate_CreateOrUpdateAnExtendedSqlPoolSBlobAuditingPol SynapseExtendedSqlPoolBlobAuditingPolicyResource synapseExtendedSqlPoolBlobAuditingPolicy = client.GetSynapseExtendedSqlPoolBlobAuditingPolicyResource(synapseExtendedSqlPoolBlobAuditingPolicyResourceId); // invoke the operation - SynapseExtendedSqlPoolBlobAuditingPolicyData data = new SynapseExtendedSqlPoolBlobAuditingPolicyData() + SynapseExtendedSqlPoolBlobAuditingPolicyData data = new SynapseExtendedSqlPoolBlobAuditingPolicyData { State = SynapseBlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseGeoBackupPolicyCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseGeoBackupPolicyCollection.cs index 7ad6ef747a3fd..464e8d3c4c025 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseGeoBackupPolicyCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseGeoBackupPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseGeoBackupPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSqlPoolGeoBackupPolicy() + public async Task CreateOrUpdate_CreateGeoBackupPolicy() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolGeoBackupPolicies_List.json - // this example is just showing the usage of "SqlPoolGeoBackupPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateGeoBackupPolicies.json + // this example is just showing the usage of "SqlPoolGeoBackupPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task GetAll_GetSqlPoolGeoBackupPolicy() // this example assumes you already have this SynapseSqlPoolResource created on azure // for more information of creating SynapseSqlPoolResource, please refer to the document of SynapseSqlPoolResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-4799"; - string workspaceName = "sqlcrudtest-5961"; + string resourceGroupName = "testrg"; + string workspaceName = "testws"; string sqlPoolName = "testdw"; ResourceIdentifier synapseSqlPoolResourceId = SynapseSqlPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName); SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); @@ -40,25 +40,25 @@ public async Task GetAll_GetSqlPoolGeoBackupPolicy() // get the collection of this SynapseGeoBackupPolicyResource SynapseGeoBackupPolicyCollection collection = synapseSqlPool.GetSynapseGeoBackupPolicies(); - // invoke the operation and iterate over the result - await foreach (SynapseGeoBackupPolicyResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseGeoBackupPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + SynapseGeoBackupPolicyName geoBackupPolicyName = SynapseGeoBackupPolicyName.Default; + SynapseGeoBackupPolicyData data = new SynapseGeoBackupPolicyData(SynapseGeoBackupPolicyState.Enabled); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, geoBackupPolicyName, data); + SynapseGeoBackupPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseGeoBackupPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateGeoBackupPolicy() + public async Task Get_GetSqlPoolGeoBackupPolicy() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateGeoBackupPolicies.json - // this example is just showing the usage of "SqlPoolGeoBackupPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolGeoBackupPolicy.json + // this example is just showing the usage of "SqlPoolGeoBackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,8 +68,8 @@ public async Task CreateOrUpdate_CreateGeoBackupPolicy() // this example assumes you already have this SynapseSqlPoolResource created on azure // for more information of creating SynapseSqlPoolResource, please refer to the document of SynapseSqlPoolResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "testrg"; - string workspaceName = "testws"; + string resourceGroupName = "sqlcrudtest-4799"; + string workspaceName = "sqlcrudtest-5961"; string sqlPoolName = "testdw"; ResourceIdentifier synapseSqlPoolResourceId = SynapseSqlPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName); SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); @@ -79,9 +79,7 @@ public async Task CreateOrUpdate_CreateGeoBackupPolicy() // invoke the operation SynapseGeoBackupPolicyName geoBackupPolicyName = SynapseGeoBackupPolicyName.Default; - SynapseGeoBackupPolicyData data = new SynapseGeoBackupPolicyData(SynapseGeoBackupPolicyState.Enabled); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, geoBackupPolicyName, data); - SynapseGeoBackupPolicyResource result = lro.Value; + SynapseGeoBackupPolicyResource result = await collection.GetAsync(geoBackupPolicyName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +90,10 @@ public async Task CreateOrUpdate_CreateGeoBackupPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSqlPoolGeoBackupPolicy() + public async Task GetAll_GetSqlPoolGeoBackupPolicy() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolGeoBackupPolicy.json - // this example is just showing the usage of "SqlPoolGeoBackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolGeoBackupPolicies_List.json + // this example is just showing the usage of "SqlPoolGeoBackupPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,15 +112,17 @@ public async Task Get_GetSqlPoolGeoBackupPolicy() // get the collection of this SynapseGeoBackupPolicyResource SynapseGeoBackupPolicyCollection collection = synapseSqlPool.GetSynapseGeoBackupPolicies(); - // invoke the operation - SynapseGeoBackupPolicyName geoBackupPolicyName = SynapseGeoBackupPolicyName.Default; - SynapseGeoBackupPolicyResource result = await collection.GetAsync(geoBackupPolicyName); + // invoke the operation and iterate over the result + await foreach (SynapseGeoBackupPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseGeoBackupPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseGeoBackupPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseGeoBackupPolicyResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseGeoBackupPolicyResource.cs index 71c1d8cc2fa3c..909bdfb991366 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseGeoBackupPolicyResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseGeoBackupPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseGeoBackupPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateGeoBackupPolicy() + public async Task Get_GetSqlPoolGeoBackupPolicy() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateGeoBackupPolicies.json - // this example is just showing the usage of "SqlPoolGeoBackupPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolGeoBackupPolicy.json + // this example is just showing the usage of "SqlPoolGeoBackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,17 +31,15 @@ public async Task Update_CreateGeoBackupPolicy() // this example assumes you already have this SynapseGeoBackupPolicyResource created on azure // for more information of creating SynapseGeoBackupPolicyResource, please refer to the document of SynapseGeoBackupPolicyResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "testrg"; - string workspaceName = "testws"; + string resourceGroupName = "sqlcrudtest-4799"; + string workspaceName = "sqlcrudtest-5961"; string sqlPoolName = "testdw"; SynapseGeoBackupPolicyName geoBackupPolicyName = SynapseGeoBackupPolicyName.Default; ResourceIdentifier synapseGeoBackupPolicyResourceId = SynapseGeoBackupPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, geoBackupPolicyName); SynapseGeoBackupPolicyResource synapseGeoBackupPolicy = client.GetSynapseGeoBackupPolicyResource(synapseGeoBackupPolicyResourceId); // invoke the operation - SynapseGeoBackupPolicyData data = new SynapseGeoBackupPolicyData(SynapseGeoBackupPolicyState.Enabled); - ArmOperation lro = await synapseGeoBackupPolicy.UpdateAsync(WaitUntil.Completed, data); - SynapseGeoBackupPolicyResource result = lro.Value; + SynapseGeoBackupPolicyResource result = await synapseGeoBackupPolicy.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +50,10 @@ public async Task Update_CreateGeoBackupPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSqlPoolGeoBackupPolicy() + public async Task Update_CreateGeoBackupPolicy() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolGeoBackupPolicy.json - // this example is just showing the usage of "SqlPoolGeoBackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateGeoBackupPolicies.json + // this example is just showing the usage of "SqlPoolGeoBackupPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,15 +63,17 @@ public async Task Get_GetSqlPoolGeoBackupPolicy() // this example assumes you already have this SynapseGeoBackupPolicyResource created on azure // for more information of creating SynapseGeoBackupPolicyResource, please refer to the document of SynapseGeoBackupPolicyResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-4799"; - string workspaceName = "sqlcrudtest-5961"; + string resourceGroupName = "testrg"; + string workspaceName = "testws"; string sqlPoolName = "testdw"; SynapseGeoBackupPolicyName geoBackupPolicyName = SynapseGeoBackupPolicyName.Default; ResourceIdentifier synapseGeoBackupPolicyResourceId = SynapseGeoBackupPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, geoBackupPolicyName); SynapseGeoBackupPolicyResource synapseGeoBackupPolicy = client.GetSynapseGeoBackupPolicyResource(synapseGeoBackupPolicyResourceId); // invoke the operation - SynapseGeoBackupPolicyResource result = await synapseGeoBackupPolicy.GetAsync(); + SynapseGeoBackupPolicyData data = new SynapseGeoBackupPolicyData(SynapseGeoBackupPolicyState.Enabled); + ArmOperation lro = await synapseGeoBackupPolicy.UpdateAsync(WaitUntil.Completed, data); + SynapseGeoBackupPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIPFirewallRuleInfoCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIPFirewallRuleInfoCollection.cs index e1fa2ac19e3a1..a84cb1536eeac 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIPFirewallRuleInfoCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIPFirewallRuleInfoCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseIPFirewallRuleInfoCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIPFirewallRulesInAWorkspace() + public async Task CreateOrUpdate_CreateAnIPFirewallRule() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListIpFirewallRules.json - // this example is just showing the usage of "IpFirewallRules_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateIpFirewallRule.json + // this example is just showing the usage of "IpFirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,29 @@ public async Task GetAll_ListIPFirewallRulesInAWorkspace() // get the collection of this SynapseIPFirewallRuleInfoResource SynapseIPFirewallRuleInfoCollection collection = synapseWorkspace.GetSynapseIPFirewallRuleInfos(); - // invoke the operation and iterate over the result - await foreach (SynapseIPFirewallRuleInfoResource item in collection.GetAllAsync()) + // invoke the operation + string ruleName = "ExampleIpFirewallRule"; + SynapseIPFirewallRuleInfoData info = new SynapseIPFirewallRuleInfoData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseIPFirewallRuleInfoData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EndIPAddress = IPAddress.Parse("10.0.0.254"), + StartIPAddress = IPAddress.Parse("10.0.0.0"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, info); + SynapseIPFirewallRuleInfoResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseIPFirewallRuleInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnIPFirewallRule() + public async Task Get_GetIPFirewallRule() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateIpFirewallRule.json - // this example is just showing the usage of "IpFirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetIpFirewallRule.json + // this example is just showing the usage of "IpFirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,13 +81,7 @@ public async Task CreateOrUpdate_CreateAnIPFirewallRule() // invoke the operation string ruleName = "ExampleIpFirewallRule"; - SynapseIPFirewallRuleInfoData info = new SynapseIPFirewallRuleInfoData() - { - EndIPAddress = IPAddress.Parse("10.0.0.254"), - StartIPAddress = IPAddress.Parse("10.0.0.0"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, info); - SynapseIPFirewallRuleInfoResource result = lro.Value; + SynapseIPFirewallRuleInfoResource result = await collection.GetAsync(ruleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -94,10 +92,10 @@ public async Task CreateOrUpdate_CreateAnIPFirewallRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetIPFirewallRule() + public async Task GetAll_ListIPFirewallRulesInAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetIpFirewallRule.json - // this example is just showing the usage of "IpFirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListIpFirewallRules.json + // this example is just showing the usage of "IpFirewallRules_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,15 +113,17 @@ public async Task Get_GetIPFirewallRule() // get the collection of this SynapseIPFirewallRuleInfoResource SynapseIPFirewallRuleInfoCollection collection = synapseWorkspace.GetSynapseIPFirewallRuleInfos(); - // invoke the operation - string ruleName = "ExampleIpFirewallRule"; - SynapseIPFirewallRuleInfoResource result = await collection.GetAsync(ruleName); + // invoke the operation and iterate over the result + await foreach (SynapseIPFirewallRuleInfoResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseIPFirewallRuleInfoData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseIPFirewallRuleInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIPFirewallRuleInfoResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIPFirewallRuleInfoResource.cs index 1071c0d266c68..d3f5ea9177794 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIPFirewallRuleInfoResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIPFirewallRuleInfoResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseIPFirewallRuleInfoResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAnIPFirewallRule() + public async Task Get_GetIPFirewallRule() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateIpFirewallRule.json - // this example is just showing the usage of "IpFirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetIpFirewallRule.json + // this example is just showing the usage of "IpFirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,13 +38,7 @@ public async Task Update_CreateAnIPFirewallRule() SynapseIPFirewallRuleInfoResource synapseIPFirewallRuleInfo = client.GetSynapseIPFirewallRuleInfoResource(synapseIPFirewallRuleInfoResourceId); // invoke the operation - SynapseIPFirewallRuleInfoData info = new SynapseIPFirewallRuleInfoData() - { - EndIPAddress = IPAddress.Parse("10.0.0.254"), - StartIPAddress = IPAddress.Parse("10.0.0.0"), - }; - ArmOperation lro = await synapseIPFirewallRuleInfo.UpdateAsync(WaitUntil.Completed, info); - SynapseIPFirewallRuleInfoResource result = lro.Value; + SynapseIPFirewallRuleInfoResource result = await synapseIPFirewallRuleInfo.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -83,10 +77,10 @@ public async Task Delete_DeleteAnIPFirewallRuleFromAWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetIPFirewallRule() + public async Task Update_CreateAnIPFirewallRule() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetIpFirewallRule.json - // this example is just showing the usage of "IpFirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateIpFirewallRule.json + // this example is just showing the usage of "IpFirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,7 +97,13 @@ public async Task Get_GetIPFirewallRule() SynapseIPFirewallRuleInfoResource synapseIPFirewallRuleInfo = client.GetSynapseIPFirewallRuleInfoResource(synapseIPFirewallRuleInfoResourceId); // invoke the operation - SynapseIPFirewallRuleInfoResource result = await synapseIPFirewallRuleInfo.GetAsync(); + SynapseIPFirewallRuleInfoData info = new SynapseIPFirewallRuleInfoData + { + EndIPAddress = IPAddress.Parse("10.0.0.254"), + StartIPAddress = IPAddress.Parse("10.0.0.0"), + }; + ArmOperation lro = await synapseIPFirewallRuleInfo.UpdateAsync(WaitUntil.Completed, info); + SynapseIPFirewallRuleInfoResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIntegrationRuntimeCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIntegrationRuntimeCollection.cs index 5aa34bf83b2b1..af827b04a4947 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIntegrationRuntimeCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIntegrationRuntimeCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseIntegrationRuntimeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetIntegrationRuntime() + public async Task CreateOrUpdate_CreateIntegrationRuntime() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Get.json - // this example is just showing the usage of "IntegrationRuntimes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Create.json + // this example is just showing the usage of "IntegrationRuntimes_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetIntegrationRuntime() // invoke the operation string integrationRuntimeName = "exampleIntegrationRuntime"; - SynapseIntegrationRuntimeResource result = await collection.GetAsync(integrationRuntimeName); + SynapseIntegrationRuntimeData data = new SynapseIntegrationRuntimeData(new SynapseSelfHostedIntegrationRuntime + { + Description = "A selfhosted integration runtime", + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, integrationRuntimeName, data); + SynapseIntegrationRuntimeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetIntegrationRuntime() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetIntegrationRuntime() + public async Task Get_GetIntegrationRuntime() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Get.json // this example is just showing the usage of "IntegrationRuntimes_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetIntegrationRuntime() // invoke the operation string integrationRuntimeName = "exampleIntegrationRuntime"; - bool result = await collection.ExistsAsync(integrationRuntimeName); + SynapseIntegrationRuntimeResource result = await collection.GetAsync(integrationRuntimeName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseIntegrationRuntimeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetIntegrationRuntime() + public async Task GetAll_ListIntegrationRuntimes() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Get.json - // this example is just showing the usage of "IntegrationRuntimes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_ListByWorkspace.json + // this example is just showing the usage of "IntegrationRuntimes_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetIntegrationRuntime() // get the collection of this SynapseIntegrationRuntimeResource SynapseIntegrationRuntimeCollection collection = synapseWorkspace.GetSynapseIntegrationRuntimes(); - // invoke the operation - string integrationRuntimeName = "exampleIntegrationRuntime"; - NullableResponse response = await collection.GetIfExistsAsync(integrationRuntimeName); - SynapseIntegrationRuntimeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SynapseIntegrationRuntimeResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseIntegrationRuntimeData resourceData = result.Data; + SynapseIntegrationRuntimeData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateIntegrationRuntime() + public async Task Exists_GetIntegrationRuntime() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Create.json - // this example is just showing the usage of "IntegrationRuntimes_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Get.json + // this example is just showing the usage of "IntegrationRuntimes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_CreateIntegrationRuntime() // invoke the operation string integrationRuntimeName = "exampleIntegrationRuntime"; - SynapseIntegrationRuntimeData data = new SynapseIntegrationRuntimeData(new SynapseSelfHostedIntegrationRuntime() - { - Description = "A selfhosted integration runtime", - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, integrationRuntimeName, data); - SynapseIntegrationRuntimeResource result = lro.Value; + bool result = await collection.ExistsAsync(integrationRuntimeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseIntegrationRuntimeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIntegrationRuntimes() + public async Task GetIfExists_GetIntegrationRuntime() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_ListByWorkspace.json - // this example is just showing the usage of "IntegrationRuntimes_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Get.json + // this example is just showing the usage of "IntegrationRuntimes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListIntegrationRuntimes() // get the collection of this SynapseIntegrationRuntimeResource SynapseIntegrationRuntimeCollection collection = synapseWorkspace.GetSynapseIntegrationRuntimes(); - // invoke the operation and iterate over the result - await foreach (SynapseIntegrationRuntimeResource item in collection.GetAllAsync()) + // invoke the operation + string integrationRuntimeName = "exampleIntegrationRuntime"; + NullableResponse response = await collection.GetIfExistsAsync(integrationRuntimeName); + SynapseIntegrationRuntimeResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseIntegrationRuntimeData resourceData = item.Data; + SynapseIntegrationRuntimeData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIntegrationRuntimeResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIntegrationRuntimeResource.cs index 1c63df3726d64..8b0958f982470 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIntegrationRuntimeResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseIntegrationRuntimeResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseIntegrationRuntimeResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateIntegrationRuntime() + public async Task Get_GetIntegrationRuntime() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Update.json - // this example is just showing the usage of "IntegrationRuntimes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Get.json + // this example is just showing the usage of "IntegrationRuntimes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,12 +38,7 @@ public async Task Update_UpdateIntegrationRuntime() SynapseIntegrationRuntimeResource synapseIntegrationRuntime = client.GetSynapseIntegrationRuntimeResource(synapseIntegrationRuntimeResourceId); // invoke the operation - SynapseIntegrationRuntimePatch patch = new SynapseIntegrationRuntimePatch() - { - AutoUpdate = SynapseIntegrationRuntimeAutoUpdate.Off, - UpdateDelayOffset = "\"PT3H\"", - }; - SynapseIntegrationRuntimeResource result = await synapseIntegrationRuntime.UpdateAsync(patch); + SynapseIntegrationRuntimeResource result = await synapseIntegrationRuntime.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +49,10 @@ public async Task Update_UpdateIntegrationRuntime() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetIntegrationRuntime() + public async Task Delete_DeleteIntegrationRuntime() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Get.json - // this example is just showing the usage of "IntegrationRuntimes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Delete.json + // this example is just showing the usage of "IntegrationRuntimes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,21 +69,17 @@ public async Task Get_GetIntegrationRuntime() SynapseIntegrationRuntimeResource synapseIntegrationRuntime = client.GetSynapseIntegrationRuntimeResource(synapseIntegrationRuntimeResourceId); // invoke the operation - SynapseIntegrationRuntimeResource result = await synapseIntegrationRuntime.GetAsync(); + await synapseIntegrationRuntime.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseIntegrationRuntimeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteIntegrationRuntime() + public async Task Update_UpdateIntegrationRuntime() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Delete.json - // this example is just showing the usage of "IntegrationRuntimes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/IntegrationRuntimes_Update.json + // this example is just showing the usage of "IntegrationRuntimes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeleteIntegrationRuntime() SynapseIntegrationRuntimeResource synapseIntegrationRuntime = client.GetSynapseIntegrationRuntimeResource(synapseIntegrationRuntimeResourceId); // invoke the operation - await synapseIntegrationRuntime.DeleteAsync(WaitUntil.Completed); + SynapseIntegrationRuntimePatch patch = new SynapseIntegrationRuntimePatch + { + AutoUpdate = SynapseIntegrationRuntimeAutoUpdate.Off, + UpdateDelayOffset = "\"PT3H\"", + }; + SynapseIntegrationRuntimeResource result = await synapseIntegrationRuntime.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseIntegrationRuntimeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -326,7 +326,7 @@ public async Task GetAllIntegrationRuntimeObjectMetadata_GetIntegrationRuntimeOb SynapseIntegrationRuntimeResource synapseIntegrationRuntime = client.GetSynapseIntegrationRuntimeResource(synapseIntegrationRuntimeResourceId); // invoke the operation and iterate over the result - SynapseGetSsisObjectMetadataContent content = new SynapseGetSsisObjectMetadataContent() + SynapseGetSsisObjectMetadataContent content = new SynapseGetSsisObjectMetadataContent { MetadataPath = "ssisFolders", }; @@ -417,7 +417,7 @@ public async Task UpdateIntegrationRuntimeNode_UpdateIntegrationRuntimeNode() // invoke the operation string nodeName = "Node_1"; - UpdateIntegrationRuntimeNodeContent content = new UpdateIntegrationRuntimeNodeContent() + UpdateIntegrationRuntimeNodeContent content = new UpdateIntegrationRuntimeNodeContent { ConcurrentJobsLimit = 2, }; @@ -530,7 +530,7 @@ public async Task RegenerateIntegrationRuntimeAuthKey_RegenerateAuthKey() SynapseIntegrationRuntimeResource synapseIntegrationRuntime = client.GetSynapseIntegrationRuntimeResource(synapseIntegrationRuntimeResourceId); // invoke the operation - IntegrationRuntimeRegenerateKeyContent content = new IntegrationRuntimeRegenerateKeyContent() + IntegrationRuntimeRegenerateKeyContent content = new IntegrationRuntimeRegenerateKeyContent { KeyName = SynapseIntegrationRuntimeAuthKeyName.AuthKey2, }; diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKeyCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKeyCollection.cs index 6052cc512452e..78535ce073864 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKeyCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKeyCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseKeyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListKeysInWorkspace() + public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceKey() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListKeysInWorkspace.json - // this example is just showing the usage of "Keys_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateKey.json + // this example is just showing the usage of "Keys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_ListKeysInWorkspace() // get the collection of this SynapseKeyResource SynapseKeyCollection collection = synapseWorkspace.GetSynapseKeys(); - // invoke the operation and iterate over the result - await foreach (SynapseKeyResource item in collection.GetAllAsync()) + // invoke the operation + string keyName = "somekey"; + SynapseKeyData data = new SynapseKeyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsActiveCmk = true, + KeyVaultUri = new Uri("https://vault.azure.net/keys/somesecret"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, data); + SynapseKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_GetAWorkspaceKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAWorkspaceKey() + public async Task GetAll_ListKeysInWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetKey.json - // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListKeysInWorkspace.json + // this example is just showing the usage of "Keys_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,7 +103,7 @@ public async Task Exists_GetAWorkspaceKey() // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string subscriptionId = "01234567-89ab-4def-0123-456789abcdef"; string resourceGroupName = "ExampleResourceGroup"; string workspaceName = "ExampleWorkspace"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); @@ -108,16 +112,22 @@ public async Task Exists_GetAWorkspaceKey() // get the collection of this SynapseKeyResource SynapseKeyCollection collection = synapseWorkspace.GetSynapseKeys(); - // invoke the operation - string keyName = "somekey"; - bool result = await collection.ExistsAsync(keyName); + // invoke the operation and iterate over the result + await foreach (SynapseKeyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAWorkspaceKey() + public async Task Exists_GetAWorkspaceKey() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetKey.json // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_GetAWorkspaceKey() // invoke the operation string keyName = "somekey"; - NullableResponse response = await collection.GetIfExistsAsync(keyName); - SynapseKeyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(keyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceKey() + public async Task GetIfExists_GetAWorkspaceKey() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateKey.json - // this example is just showing the usage of "Keys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetKey.json + // this example is just showing the usage of "Keys_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -171,7 +169,7 @@ public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceKey() // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource - string subscriptionId = "01234567-89ab-4def-0123-456789abcdef"; + string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "ExampleResourceGroup"; string workspaceName = "ExampleWorkspace"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); @@ -182,19 +180,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceKey() // invoke the operation string keyName = "somekey"; - SynapseKeyData data = new SynapseKeyData() - { - IsActiveCmk = true, - KeyVaultUri = new Uri("https://vault.azure.net/keys/somesecret"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, data); - SynapseKeyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(keyName); + SynapseKeyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKeyResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKeyResource.cs index 73a0c8377a891..1b23746917884 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKeyResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKeyResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetAWorkspaceKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAWorkspaceKey() + public async Task Delete_DeleteAWorkspaceKey() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateKey.json - // this example is just showing the usage of "Keys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteKey.json + // this example is just showing the usage of "Keys_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,12 +68,7 @@ public async Task Update_CreateOrUpdateAWorkspaceKey() SynapseKeyResource synapseKey = client.GetSynapseKeyResource(synapseKeyResourceId); // invoke the operation - SynapseKeyData data = new SynapseKeyData() - { - IsActiveCmk = true, - KeyVaultUri = new Uri("https://vault.azure.net/keys/somesecret"), - }; - ArmOperation lro = await synapseKey.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await synapseKey.DeleteAsync(WaitUntil.Completed); SynapseKeyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -85,10 +80,10 @@ public async Task Update_CreateOrUpdateAWorkspaceKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAWorkspaceKey() + public async Task Update_CreateOrUpdateAWorkspaceKey() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteKey.json - // this example is just showing the usage of "Keys_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateKey.json + // this example is just showing the usage of "Keys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,7 +100,12 @@ public async Task Delete_DeleteAWorkspaceKey() SynapseKeyResource synapseKey = client.GetSynapseKeyResource(synapseKeyResourceId); // invoke the operation - ArmOperation lro = await synapseKey.DeleteAsync(WaitUntil.Completed); + SynapseKeyData data = new SynapseKeyData + { + IsActiveCmk = true, + KeyVaultUri = new Uri("https://vault.azure.net/keys/somesecret"), + }; + ArmOperation lro = await synapseKey.UpdateAsync(WaitUntil.Completed, data); SynapseKeyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKustoPoolCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKustoPoolCollection.cs index 2ccddb5ce10fc..dc9f635209ce3 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKustoPoolCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKustoPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseKustoPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListKustoPoolsInAWorkspace() + public async Task CreateOrUpdate_KustoPoolsCreateOrUpdate() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsListByWorkspace.json - // this example is just showing the usage of "KustoPools_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsCreateOrUpdate.json + // this example is just showing the usage of "KustoPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,32 @@ public async Task GetAll_ListKustoPoolsInAWorkspace() // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; - string workspaceName = "kustorptest"; + string workspaceName = "synapseWorkspaceName"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // get the collection of this SynapseKustoPoolResource SynapseKustoPoolCollection collection = synapseWorkspace.GetSynapseKustoPools(); - // invoke the operation and iterate over the result - await foreach (SynapseKustoPoolResource item in collection.GetAllAsync()) + // invoke the operation + string kustoPoolName = "kustoclusterrptest4"; + SynapseKustoPoolData data = new SynapseKustoPoolData(new AzureLocation("westus"), new SynapseDataSourceSku(SynapseSkuName.StorageOptimized, KustoPoolSkuSize.Medium) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseKustoPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Capacity = 2, + }) + { + EnableStreamingIngest = true, + EnablePurge = true, + WorkspaceUid = Guid.Parse("11111111-2222-3333-444444444444"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, kustoPoolName, data); + SynapseKustoPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseKustoPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_KustoPoolsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoPoolsGet() + public async Task GetAll_ListKustoPoolsInAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsGet.json - // this example is just showing the usage of "KustoPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsListByWorkspace.json + // this example is just showing the usage of "KustoPools_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,23 +110,29 @@ public async Task Exists_KustoPoolsGet() // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; - string workspaceName = "synapseWorkspaceName"; + string workspaceName = "kustorptest"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // get the collection of this SynapseKustoPoolResource SynapseKustoPoolCollection collection = synapseWorkspace.GetSynapseKustoPools(); - // invoke the operation - string kustoPoolName = "kustoclusterrptest4"; - bool result = await collection.ExistsAsync(kustoPoolName); + // invoke the operation and iterate over the result + await foreach (SynapseKustoPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseKustoPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoPoolsGet() + public async Task Exists_KustoPoolsGet() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsGet.json // this example is just showing the usage of "KustoPools_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_KustoPoolsGet() // invoke the operation string kustoPoolName = "kustoclusterrptest4"; - NullableResponse response = await collection.GetIfExistsAsync(kustoPoolName); - SynapseKustoPoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(kustoPoolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseKustoPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoPoolsCreateOrUpdate() + public async Task GetIfExists_KustoPoolsGet() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsCreateOrUpdate.json - // this example is just showing the usage of "KustoPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsGet.json + // this example is just showing the usage of "KustoPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_KustoPoolsCreateOrUpdate() // invoke the operation string kustoPoolName = "kustoclusterrptest4"; - SynapseKustoPoolData data = new SynapseKustoPoolData(new AzureLocation("westus"), new SynapseDataSourceSku(SynapseSkuName.StorageOptimized, KustoPoolSkuSize.Medium) + NullableResponse response = await collection.GetIfExistsAsync(kustoPoolName); + SynapseKustoPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Capacity = 2, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - EnableStreamingIngest = true, - EnablePurge = true, - WorkspaceUid = Guid.Parse("11111111-2222-3333-444444444444"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, kustoPoolName, data); - SynapseKustoPoolResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseKustoPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseKustoPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKustoPoolResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKustoPoolResource.cs index df1d43f8eb5b7..b3074bb00ae18 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKustoPoolResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseKustoPoolResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Synapse.Models; using NUnit.Framework; @@ -19,63 +18,41 @@ public partial class Sample_SynapseKustoPoolResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSkusKustoPools_KustoPoolsListSkus() - { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsListSkus.json - // this example is just showing the usage of "KustoPools_ListSkus" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "12345678-1234-1234-1234-123456789098"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (KustoPoolSkuDescription item in subscriptionResource.GetSkusKustoPoolsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckKustoPoolNameAvailability_KustoPoolsCheckNameAvailability() + public async Task Get_KustoPoolsGet() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsCheckNameAvailability.json - // this example is just showing the usage of "KustoPools_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsGet.json + // this example is just showing the usage of "KustoPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this SynapseKustoPoolResource created on azure + // for more information of creating SynapseKustoPoolResource, please refer to the document of SynapseKustoPoolResource string subscriptionId = "12345678-1234-1234-1234-123456789098"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "kustorptest"; + string workspaceName = "synapseWorkspaceName"; + string kustoPoolName = "kustoclusterrptest4"; + ResourceIdentifier synapseKustoPoolResourceId = SynapseKustoPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, kustoPoolName); + SynapseKustoPoolResource synapseKustoPool = client.GetSynapseKustoPoolResource(synapseKustoPoolResourceId); // invoke the operation - AzureLocation location = new AzureLocation("westus"); - KustoPoolNameAvailabilityContent content = new KustoPoolNameAvailabilityContent("kustoclusterrptest4"); - KustoPoolNameAvailabilityResult result = await subscriptionResource.CheckKustoPoolNameAvailabilityAsync(location, content); + SynapseKustoPoolResource result = await synapseKustoPool.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseKustoPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KustoPoolsGet() + public async Task Delete_KustoPoolsDelete() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsGet.json - // this example is just showing the usage of "KustoPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsDelete.json + // this example is just showing the usage of "KustoPools_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -86,19 +63,15 @@ public async Task Get_KustoPoolsGet() // for more information of creating SynapseKustoPoolResource, please refer to the document of SynapseKustoPoolResource string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; - string workspaceName = "synapseWorkspaceName"; + string workspaceName = "kustorptest"; string kustoPoolName = "kustoclusterrptest4"; ResourceIdentifier synapseKustoPoolResourceId = SynapseKustoPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, kustoPoolName); SynapseKustoPoolResource synapseKustoPool = client.GetSynapseKustoPoolResource(synapseKustoPoolResourceId); // invoke the operation - SynapseKustoPoolResource result = await synapseKustoPool.GetAsync(); + await synapseKustoPool.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseKustoPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -123,7 +96,7 @@ public async Task Update_KustoPoolsUpdate() SynapseKustoPoolResource synapseKustoPool = client.GetSynapseKustoPoolResource(synapseKustoPoolResourceId); // invoke the operation - SynapseKustoPoolPatch patch = new SynapseKustoPoolPatch() + SynapseKustoPoolPatch patch = new SynapseKustoPoolPatch { Sku = new SynapseDataSourceSku(SynapseSkuName.StorageOptimized, KustoPoolSkuSize.Medium) { @@ -143,33 +116,6 @@ public async Task Update_KustoPoolsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoPoolsDelete() - { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/KustoPoolsDelete.json - // this example is just showing the usage of "KustoPools_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SynapseKustoPoolResource created on azure - // for more information of creating SynapseKustoPoolResource, please refer to the document of SynapseKustoPoolResource - string subscriptionId = "12345678-1234-1234-1234-123456789098"; - string resourceGroupName = "kustorptest"; - string workspaceName = "kustorptest"; - string kustoPoolName = "kustoclusterrptest4"; - ResourceIdentifier synapseKustoPoolResourceId = SynapseKustoPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, kustoPoolName); - SynapseKustoPoolResource synapseKustoPool = client.GetSynapseKustoPoolResource(synapseKustoPoolResourceId); - - // invoke the operation - await synapseKustoPool.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Stop_KustoPoolsStop() @@ -306,18 +252,15 @@ public async Task AddLanguageExtensions_KustoPoolAddLanguageExtensions() SynapseKustoPoolResource synapseKustoPool = client.GetSynapseKustoPoolResource(synapseKustoPoolResourceId); // invoke the operation - SynapseLanguageExtensionsList languageExtensionsToAdd = new SynapseLanguageExtensionsList() + SynapseLanguageExtensionsList languageExtensionsToAdd = new SynapseLanguageExtensionsList { - Value = -{ -new SynapseLanguageExtension() + Value = {new SynapseLanguageExtension { LanguageExtensionName = SynapseLanguageExtensionName.Python, -},new SynapseLanguageExtension() +}, new SynapseLanguageExtension { LanguageExtensionName = SynapseLanguageExtensionName.R, -} -}, +}}, }; await synapseKustoPool.AddLanguageExtensionsAsync(WaitUntil.Completed, languageExtensionsToAdd); @@ -346,18 +289,15 @@ public async Task RemoveLanguageExtensions_KustoPoolRemoveLanguageExtensions() SynapseKustoPoolResource synapseKustoPool = client.GetSynapseKustoPoolResource(synapseKustoPoolResourceId); // invoke the operation - SynapseLanguageExtensionsList languageExtensionsToRemove = new SynapseLanguageExtensionsList() + SynapseLanguageExtensionsList languageExtensionsToRemove = new SynapseLanguageExtensionsList { - Value = -{ -new SynapseLanguageExtension() + Value = {new SynapseLanguageExtension { LanguageExtensionName = SynapseLanguageExtensionName.Python, -},new SynapseLanguageExtension() +}, new SynapseLanguageExtension { LanguageExtensionName = SynapseLanguageExtensionName.R, -} -}, +}}, }; await synapseKustoPool.RemoveLanguageExtensionsAsync(WaitUntil.Completed, languageExtensionsToRemove); diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseLibraryCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseLibraryCollection.cs index 34891bae27985..6b01670d0975e 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseLibraryCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseLibraryCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetLibraryByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetLibraryByName() + public async Task GetAll_ListLibrariesInAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/Library_Get.json - // this example is just showing the usage of "Library_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/Libraries_ListByWorkspace.json + // this example is just showing the usage of "Libraries_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetLibraryByName() // get the collection of this SynapseLibraryResource SynapseLibraryCollection collection = synapseWorkspace.GetSynapseLibraries(); - // invoke the operation - string libraryName = "exampleLibraryName.jar"; - bool result = await collection.ExistsAsync(libraryName); + // invoke the operation and iterate over the result + await foreach (SynapseLibraryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseLibraryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetLibraryByName() + public async Task Exists_GetLibraryByName() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/Library_Get.json // this example is just showing the usage of "Library_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetLibraryByName() // invoke the operation string libraryName = "exampleLibraryName.jar"; - NullableResponse response = await collection.GetIfExistsAsync(libraryName); - SynapseLibraryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(libraryName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseLibraryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListLibrariesInAWorkspace() + public async Task GetIfExists_GetLibraryByName() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/Libraries_ListByWorkspace.json - // this example is just showing the usage of "Libraries_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/Library_Get.json + // this example is just showing the usage of "Library_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ListLibrariesInAWorkspace() // get the collection of this SynapseLibraryResource SynapseLibraryCollection collection = synapseWorkspace.GetSynapseLibraries(); - // invoke the operation and iterate over the result - await foreach (SynapseLibraryResource item in collection.GetAllAsync()) + // invoke the operation + string libraryName = "exampleLibraryName.jar"; + NullableResponse response = await collection.GetIfExistsAsync(libraryName); + SynapseLibraryResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseLibraryData resourceData = item.Data; + SynapseLibraryData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseMaintenanceWindowResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseMaintenanceWindowResource.cs index a794ce4b1f2ff..a105e743cf086 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseMaintenanceWindowResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseMaintenanceWindowResource.cs @@ -72,17 +72,14 @@ public async Task CreateOrUpdate_SetsMaintenanceWindowSettingsForASelectedSQLAna // invoke the operation string maintenanceWindowName = "current"; - SynapseMaintenanceWindowData data = new SynapseMaintenanceWindowData() + SynapseMaintenanceWindowData data = new SynapseMaintenanceWindowData { - TimeRanges = -{ -new SynapseMaintenanceWindowTimeRange() + TimeRanges = {new SynapseMaintenanceWindowTimeRange { DayOfWeek = SynapseDayOfWeek.Saturday, -StartOn = TimeSpan.Parse("00:00:00"), +StartOn = XmlConvert.ToTimeSpan("00:00:00"), Duration = XmlConvert.ToTimeSpan("PT60M"), -} -}, +}}, }; await synapseMaintenanceWindow.CreateOrUpdateAsync(WaitUntil.Completed, maintenanceWindowName, data); diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseManagedIdentitySqlControlSettingResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseManagedIdentitySqlControlSettingResource.cs index 9a0561649d485..6fb8f9a5c3386 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseManagedIdentitySqlControlSettingResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseManagedIdentitySqlControlSettingResource.cs @@ -67,9 +67,9 @@ public async Task CreateOrUpdate_CreateOrUpdateManagedIdentitySqlControlSettings SynapseManagedIdentitySqlControlSettingResource synapseManagedIdentitySqlControlSetting = client.GetSynapseManagedIdentitySqlControlSettingResource(synapseManagedIdentitySqlControlSettingResourceId); // invoke the operation - SynapseManagedIdentitySqlControlSettingData data = new SynapseManagedIdentitySqlControlSettingData() + SynapseManagedIdentitySqlControlSettingData data = new SynapseManagedIdentitySqlControlSettingData { - GrantSqlControlToManagedIdentity = new SynapseGrantSqlControlToManagedIdentity() + GrantSqlControlToManagedIdentity = new SynapseGrantSqlControlToManagedIdentity { DesiredState = SynapseDesiredState.Enabled, }, diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseMetadataSyncConfigurationResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseMetadataSyncConfigurationResource.cs index fd697ea16c3e9..c2b72ed6cc804 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseMetadataSyncConfigurationResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseMetadataSyncConfigurationResource.cs @@ -68,7 +68,7 @@ public async Task CreateOrUpdate_SetMetadataSyncConfigForASQLAnalyticsPool() SynapseMetadataSyncConfigurationResource synapseMetadataSyncConfiguration = client.GetSynapseMetadataSyncConfigurationResource(synapseMetadataSyncConfigurationResourceId); // invoke the operation - SynapseMetadataSyncConfigurationData data = new SynapseMetadataSyncConfigurationData() + SynapseMetadataSyncConfigurationData data = new SynapseMetadataSyncConfigurationData { IsEnabled = true, }; diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionCollection.cs index aa5dd0f69ed9e..ccb3e6feb2274 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapsePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndpointConnection() + public async Task CreateOrUpdate_ApprovePrivateEndpointConnection() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ApprovePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_GetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "ExamplePrivateEndpointConnection"; - SynapsePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + SynapsePrivateEndpointConnectionData data = new SynapsePrivateEndpointConnectionData + { + ConnectionState = new SynapsePrivateLinkServiceConnectionState + { + Status = "Approved", + Description = "Approved by abc@example.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + SynapsePrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateEndpointConnection() + public async Task Get_GetPrivateEndpointConnection() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +84,21 @@ public async Task Exists_GetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "ExamplePrivateEndpointConnection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + SynapsePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateEndpointConnection() + public async Task GetAll_ListPrivateEndpointConnectionsInWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListPrivateEndpointConnections.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +116,25 @@ public async Task GetIfExists_GetPrivateEndpointConnection() // get the collection of this SynapsePrivateEndpointConnectionResource SynapsePrivateEndpointConnectionCollection collection = synapseWorkspace.GetSynapsePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "ExamplePrivateEndpointConnection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - SynapsePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SynapsePrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapsePrivateEndpointConnectionData resourceData = result.Data; + SynapsePrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApprovePrivateEndpointConnection() + public async Task Exists_GetPrivateEndpointConnection() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ApprovePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,30 +154,17 @@ public async Task CreateOrUpdate_ApprovePrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "ExamplePrivateEndpointConnection"; - SynapsePrivateEndpointConnectionData data = new SynapsePrivateEndpointConnectionData() - { - ConnectionState = new SynapsePrivateLinkServiceConnectionState() - { - Status = "Approved", - Description = "Approved by abc@example.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - SynapsePrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateEndpointConnectionsInWorkspace() + public async Task GetIfExists_GetPrivateEndpointConnection() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListPrivateEndpointConnections.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_ListPrivateEndpointConnectionsInWorkspace() // get the collection of this SynapsePrivateEndpointConnectionResource SynapsePrivateEndpointConnectionCollection collection = synapseWorkspace.GetSynapsePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (SynapsePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "ExamplePrivateEndpointConnection"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + SynapsePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapsePrivateEndpointConnectionData resourceData = item.Data; + SynapsePrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionForPrivateLinkHubCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionForPrivateLinkHubCollection.cs index cf8a434c93dea..3463ffbbeb565 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionForPrivateLinkHubCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionForPrivateLinkHubCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapsePrivateEndpointConnectionForPrivateLinkHubCol { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAPrivateLinkHub() + public async Task Get_GetAPrivateLinkHub() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/PrivateEndpointConnectionsPrivateLinkHub_List.json - // this example is just showing the usage of "PrivateEndpointConnectionsPrivateLinkHub_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/PrivateEndpointConnectionsPrivateLinkHub_Get.json + // this example is just showing the usage of "PrivateEndpointConnectionsPrivateLinkHub_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetAPrivateLinkHub() // get the collection of this SynapsePrivateEndpointConnectionForPrivateLinkHubResource SynapsePrivateEndpointConnectionForPrivateLinkHubCollection collection = synapsePrivateLinkHub.GetSynapsePrivateEndpointConnectionForPrivateLinkHubs(); - // invoke the operation and iterate over the result - await foreach (SynapsePrivateEndpointConnectionForPrivateLinkHubResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateEndpointConnectionForPrivateLinkHubData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateEndpointConnectionName = "pe0-f3ed30f5-338c-4855-a542-24a403694ad2"; + SynapsePrivateEndpointConnectionForPrivateLinkHubResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateEndpointConnectionForPrivateLinkHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPrivateLinkHub() + public async Task GetAll_GetAPrivateLinkHub() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/PrivateEndpointConnectionsPrivateLinkHub_Get.json - // this example is just showing the usage of "PrivateEndpointConnectionsPrivateLinkHub_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/PrivateEndpointConnectionsPrivateLinkHub_List.json + // this example is just showing the usage of "PrivateEndpointConnectionsPrivateLinkHub_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetAPrivateLinkHub() // get the collection of this SynapsePrivateEndpointConnectionForPrivateLinkHubResource SynapsePrivateEndpointConnectionForPrivateLinkHubCollection collection = synapsePrivateLinkHub.GetSynapsePrivateEndpointConnectionForPrivateLinkHubs(); - // invoke the operation - string privateEndpointConnectionName = "pe0-f3ed30f5-338c-4855-a542-24a403694ad2"; - SynapsePrivateEndpointConnectionForPrivateLinkHubResource result = await collection.GetAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (SynapsePrivateEndpointConnectionForPrivateLinkHubResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateEndpointConnectionForPrivateLinkHubData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateEndpointConnectionForPrivateLinkHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionResource.cs index 79d6a6e85291e..24e73c6096372 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApprovePrivateEndpointConnection() + public async Task Delete_DeletePrivateEndpointConnection() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ApprovePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_ApprovePrivateEndpointConnection() SynapsePrivateEndpointConnectionResource synapsePrivateEndpointConnection = client.GetSynapsePrivateEndpointConnectionResource(synapsePrivateEndpointConnectionResourceId); // invoke the operation - SynapsePrivateEndpointConnectionData data = new SynapsePrivateEndpointConnectionData() - { - ConnectionState = new SynapsePrivateLinkServiceConnectionState() - { - Status = "Approved", - Description = "Approved by abc@example.com", - }, - }; - ArmOperation lro = await synapsePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - SynapsePrivateEndpointConnectionResource result = lro.Value; + await synapsePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateEndpointConnection() + public async Task Update_ApprovePrivateEndpointConnection() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ApprovePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_DeletePrivateEndpointConnection() SynapsePrivateEndpointConnectionResource synapsePrivateEndpointConnection = client.GetSynapsePrivateEndpointConnectionResource(synapsePrivateEndpointConnectionResourceId); // invoke the operation - await synapsePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + SynapsePrivateEndpointConnectionData data = new SynapsePrivateEndpointConnectionData + { + ConnectionState = new SynapsePrivateLinkServiceConnectionState + { + Status = "Approved", + Description = "Approved by abc@example.com", + }, + }; + ArmOperation lro = await synapsePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + SynapsePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkHubCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkHubCollection.cs index dda4386d8c61b..f025046f5aca1 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkHubCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkHubCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapsePrivateLinkHubCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateLinkHubsInResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateAPrivateLinkHub() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListPrivateLinkHubsInResourceGroup.json - // this example is just showing the usage of "PrivateLinkHubs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdatePrivateLinkHub.json + // this example is just showing the usage of "PrivateLinkHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,23 @@ public async Task GetAll_ListPrivateLinkHubsInResourceGroup() // get the collection of this SynapsePrivateLinkHubResource SynapsePrivateLinkHubCollection collection = resourceGroupResource.GetSynapsePrivateLinkHubs(); - // invoke the operation and iterate over the result - await foreach (SynapsePrivateLinkHubResource item in collection.GetAllAsync()) + // invoke the operation + string privateLinkHubName = "privateLinkHub1"; + SynapsePrivateLinkHubData data = new SynapsePrivateLinkHubData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateLinkHubData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateLinkHubName, data); + SynapsePrivateLinkHubResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateLinkHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +92,10 @@ public async Task Get_GetAPrivateLinkHub() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPrivateLinkHub() + public async Task GetAll_ListPrivateLinkHubsInResourceGroup() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateLinkHub.json - // this example is just showing the usage of "PrivateLinkHubs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListPrivateLinkHubsInResourceGroup.json + // this example is just showing the usage of "PrivateLinkHubs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +112,22 @@ public async Task Exists_GetAPrivateLinkHub() // get the collection of this SynapsePrivateLinkHubResource SynapsePrivateLinkHubCollection collection = resourceGroupResource.GetSynapsePrivateLinkHubs(); - // invoke the operation - string privateLinkHubName = "privateLinkHub1"; - bool result = await collection.ExistsAsync(privateLinkHubName); + // invoke the operation and iterate over the result + await foreach (SynapsePrivateLinkHubResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateLinkHubData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPrivateLinkHub() + public async Task Exists_GetAPrivateLinkHub() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateLinkHub.json // this example is just showing the usage of "PrivateLinkHubs_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +149,17 @@ public async Task GetIfExists_GetAPrivateLinkHub() // invoke the operation string privateLinkHubName = "privateLinkHub1"; - NullableResponse response = await collection.GetIfExistsAsync(privateLinkHubName); - SynapsePrivateLinkHubResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateLinkHubName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateLinkHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAPrivateLinkHub() + public async Task GetIfExists_GetAPrivateLinkHub() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdatePrivateLinkHub.json - // this example is just showing the usage of "PrivateLinkHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateLinkHub.json + // this example is just showing the usage of "PrivateLinkHubs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,21 +178,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAPrivateLinkHub() // invoke the operation string privateLinkHubName = "privateLinkHub1"; - SynapsePrivateLinkHubData data = new SynapsePrivateLinkHubData(new AzureLocation("East US")) - { - Tags = -{ -["key"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateLinkHubName, data); - SynapsePrivateLinkHubResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateLinkHubName); + SynapsePrivateLinkHubResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateLinkHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateLinkHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkHubResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkHubResource.cs index 75b88ea18ba58..2b49a8e4218d3 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkHubResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkHubResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Synapse.Models; using NUnit.Framework; @@ -49,10 +48,10 @@ public async Task Get_GetAPrivateLinkHub() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAPrivateLinkHub() + public async Task Delete_DeleteAPrivateLinkHub() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/UpdatePrivateLinkHub.json - // this example is just showing the usage of "PrivateLinkHubs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeletePrivateLinkHub.json + // this example is just showing the usage of "PrivateLinkHubs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,28 +67,17 @@ public async Task Update_UpdateAPrivateLinkHub() SynapsePrivateLinkHubResource synapsePrivateLinkHub = client.GetSynapsePrivateLinkHubResource(synapsePrivateLinkHubResourceId); // invoke the operation - SynapsePrivateLinkHubPatch patch = new SynapsePrivateLinkHubPatch() - { - Tags = -{ -["key"] = "value", -}, - }; - SynapsePrivateLinkHubResource result = await synapsePrivateLinkHub.UpdateAsync(patch); + await synapsePrivateLinkHub.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateLinkHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPrivateLinkHub() + public async Task Update_UpdateAPrivateLinkHub() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeletePrivateLinkHub.json - // this example is just showing the usage of "PrivateLinkHubs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/UpdatePrivateLinkHub.json + // this example is just showing the usage of "PrivateLinkHubs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,40 +93,20 @@ public async Task Delete_DeleteAPrivateLinkHub() SynapsePrivateLinkHubResource synapsePrivateLinkHub = client.GetSynapsePrivateLinkHubResource(synapsePrivateLinkHubResourceId); // invoke the operation - await synapsePrivateLinkHub.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSynapsePrivateLinkHubs_ListPrivateLinkHubsInSubscription() - { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListPrivateLinkHubsInSubscription.json - // this example is just showing the usage of "PrivateLinkHubs_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SynapsePrivateLinkHubResource item in subscriptionResource.GetSynapsePrivateLinkHubsAsync()) + SynapsePrivateLinkHubPatch patch = new SynapsePrivateLinkHubPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateLinkHubData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key"] = "value" +}, + }; + SynapsePrivateLinkHubResource result = await synapsePrivateLinkHub.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateLinkHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkResourceCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkResourceCollection.cs index b1a97790b7012..54a8bb9754149 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkResourceCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapsePrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapsePrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetPrivateLinkResourcesForPrivateLinkHub() + public async Task Get_GetPrivateLinkResourcesForPrivateLinkHub() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListPrivateLinkHubPrivateLinkResources.json - // this example is just showing the usage of "PrivateLinkHubPrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateLinkHubPrivateLinkResource.json + // this example is just showing the usage of "PrivateLinkHubPrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetPrivateLinkResourcesForPrivateLinkHub() // get the collection of this SynapsePrivateLinkResource SynapsePrivateLinkResourceCollection collection = synapsePrivateLinkHub.GetSynapsePrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (SynapsePrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateLinkResourceName = "sql"; + SynapsePrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateLinkResourcesForPrivateLinkHub() + public async Task GetAll_GetPrivateLinkResourcesForPrivateLinkHub() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateLinkHubPrivateLinkResource.json - // this example is just showing the usage of "PrivateLinkHubPrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListPrivateLinkHubPrivateLinkResources.json + // this example is just showing the usage of "PrivateLinkHubPrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetPrivateLinkResourcesForPrivateLinkHub() // get the collection of this SynapsePrivateLinkResource SynapsePrivateLinkResourceCollection collection = synapsePrivateLinkHub.GetSynapsePrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "sql"; - SynapsePrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (SynapsePrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRecoverableSqlPoolCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRecoverableSqlPoolCollection.cs index 648d4ab8796d6..cce11232a989f 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRecoverableSqlPoolCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRecoverableSqlPoolCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseRecoverableSqlPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRecoverableSqlPoolsForTheServer() + public async Task Get_GetRecoverableSqlPoolsForTheServer() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerRecoverableSqlPool.json - // this example is just showing the usage of "WorkspaceManagedSqlServerRecoverableSqlPools_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerRecoverableSqlPool.json + // this example is just showing the usage of "WorkspaceManagedSqlServerRecoverableSqlPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListRecoverableSqlPoolsForTheServer() // get the collection of this SynapseRecoverableSqlPoolResource SynapseRecoverableSqlPoolCollection collection = synapseWorkspace.GetSynapseRecoverableSqlPools(); - // invoke the operation and iterate over the result - await foreach (SynapseRecoverableSqlPoolResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseRecoverableSqlPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string sqlPoolName = "recoverableSqlpools-1235"; + SynapseRecoverableSqlPoolResource result = await collection.GetAsync(sqlPoolName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseRecoverableSqlPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRecoverableSqlPoolsForTheServer() + public async Task GetAll_ListRecoverableSqlPoolsForTheServer() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerRecoverableSqlPool.json - // this example is just showing the usage of "WorkspaceManagedSqlServerRecoverableSqlPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerRecoverableSqlPool.json + // this example is just showing the usage of "WorkspaceManagedSqlServerRecoverableSqlPools_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetRecoverableSqlPoolsForTheServer() // get the collection of this SynapseRecoverableSqlPoolResource SynapseRecoverableSqlPoolCollection collection = synapseWorkspace.GetSynapseRecoverableSqlPools(); - // invoke the operation - string sqlPoolName = "recoverableSqlpools-1235"; - SynapseRecoverableSqlPoolResource result = await collection.GetAsync(sqlPoolName); + // invoke the operation and iterate over the result + await foreach (SynapseRecoverableSqlPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseRecoverableSqlPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseRecoverableSqlPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseReplicationLinkCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseReplicationLinkCollection.cs index e9382b60be8b3..8b987fedd42ca 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseReplicationLinkCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseReplicationLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseReplicationLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsASqlAnalyticPoolSReplicationLinks() + public async Task Get_ListsASqlAnalyticPoolSReplicationLinks() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolReplicationLinks.json - // this example is just showing the usage of "SqlPoolReplicationLinks_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolReplicationLinks_GetByName.json + // this example is just showing the usage of "SqlPoolReplicationLinks_GetByName" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListsASqlAnalyticPoolSReplicationLinks() // get the collection of this SynapseReplicationLinkResource SynapseReplicationLinkCollection collection = synapseSqlPool.GetSynapseReplicationLinks(); - // invoke the operation and iterate over the result - await foreach (SynapseReplicationLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseReplicationLinkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string linkId = "5b301b68-03f6-4b26-b0f4-73ebb8634238"; + SynapseReplicationLinkResource result = await collection.GetAsync(linkId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseReplicationLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ListsASqlAnalyticPoolSReplicationLinks() + public async Task GetAll_ListsASqlAnalyticPoolSReplicationLinks() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolReplicationLinks_GetByName.json - // this example is just showing the usage of "SqlPoolReplicationLinks_GetByName" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolReplicationLinks.json + // this example is just showing the usage of "SqlPoolReplicationLinks_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_ListsASqlAnalyticPoolSReplicationLinks() // get the collection of this SynapseReplicationLinkResource SynapseReplicationLinkCollection collection = synapseSqlPool.GetSynapseReplicationLinks(); - // invoke the operation - string linkId = "5b301b68-03f6-4b26-b0f4-73ebb8634238"; - SynapseReplicationLinkResource result = await collection.GetAsync(linkId); + // invoke the operation and iterate over the result + await foreach (SynapseReplicationLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseReplicationLinkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseReplicationLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRestorableDroppedSqlPoolCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRestorableDroppedSqlPoolCollection.cs index 9a8bb43250c12..2555c726a3b6a 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRestorableDroppedSqlPoolCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRestorableDroppedSqlPoolCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetARestorableDroppedSqlPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetARestorableDroppedSqlPool() + public async Task GetAll_GetListOfRestorableDroppedSqlPools() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RestorableDroppedSqlPoolGet.json - // this example is just showing the usage of "RestorableDroppedSqlPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RestorableDroppedSqlpoolList.json + // this example is just showing the usage of "RestorableDroppedSqlPools_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,24 +64,30 @@ public async Task Exists_GetARestorableDroppedSqlPool() // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "restorabledroppeddatabasetest-1257"; - string workspaceName = "restorabledroppeddatabasetest-2389"; + string resourceGroupName = "restorabledroppeddatabasetest-1349"; + string workspaceName = "restorabledroppeddatabasetest-1840"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // get the collection of this SynapseRestorableDroppedSqlPoolResource SynapseRestorableDroppedSqlPoolCollection collection = synapseWorkspace.GetSynapseRestorableDroppedSqlPools(); - // invoke the operation - string restorableDroppedSqlPoolId = "restorabledroppeddatabasetest-7654,131403269876900000"; - bool result = await collection.ExistsAsync(restorableDroppedSqlPoolId); + // invoke the operation and iterate over the result + await foreach (SynapseRestorableDroppedSqlPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseRestorableDroppedSqlPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetARestorableDroppedSqlPool() + public async Task Exists_GetARestorableDroppedSqlPool() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RestorableDroppedSqlPoolGet.json // this example is just showing the usage of "RestorableDroppedSqlPools_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetARestorableDroppedSqlPool() // invoke the operation string restorableDroppedSqlPoolId = "restorabledroppeddatabasetest-7654,131403269876900000"; - NullableResponse response = await collection.GetIfExistsAsync(restorableDroppedSqlPoolId); - SynapseRestorableDroppedSqlPoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(restorableDroppedSqlPoolId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseRestorableDroppedSqlPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetListOfRestorableDroppedSqlPools() + public async Task GetIfExists_GetARestorableDroppedSqlPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RestorableDroppedSqlpoolList.json - // this example is just showing the usage of "RestorableDroppedSqlPools_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RestorableDroppedSqlPoolGet.json + // this example is just showing the usage of "RestorableDroppedSqlPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,25 +130,31 @@ public async Task GetAll_GetListOfRestorableDroppedSqlPools() // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "restorabledroppeddatabasetest-1349"; - string workspaceName = "restorabledroppeddatabasetest-1840"; + string resourceGroupName = "restorabledroppeddatabasetest-1257"; + string workspaceName = "restorabledroppeddatabasetest-2389"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // get the collection of this SynapseRestorableDroppedSqlPoolResource SynapseRestorableDroppedSqlPoolCollection collection = synapseWorkspace.GetSynapseRestorableDroppedSqlPools(); - // invoke the operation and iterate over the result - await foreach (SynapseRestorableDroppedSqlPoolResource item in collection.GetAllAsync()) + // invoke the operation + string restorableDroppedSqlPoolId = "restorabledroppeddatabasetest-7654,131403269876900000"; + NullableResponse response = await collection.GetIfExistsAsync(restorableDroppedSqlPoolId); + SynapseRestorableDroppedSqlPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseRestorableDroppedSqlPoolData resourceData = item.Data; + SynapseRestorableDroppedSqlPoolData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRestorePointCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRestorePointCollection.cs index 74c4c773c09ab..ec79cdbf40097 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRestorePointCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseRestorePointCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseRestorePointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfRestorePointsOfASQLAnalyticsPool() + public async Task Get_GetsASqlPoolRestorePoint() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolRestorePoints.json - // this example is just showing the usage of "SqlPoolRestorePoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolRestorePointsGet.json + // this example is just showing the usage of "SqlPoolRestorePoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,33 +31,31 @@ public async Task GetAll_GetAListOfRestorePointsOfASQLAnalyticsPool() // for more information of creating SynapseSqlPoolResource, please refer to the document of SynapseSqlPoolResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default-SQL-SouthEastAsia"; - string workspaceName = "testserver"; - string sqlPoolName = "testDatabase"; + string workspaceName = "testws"; + string sqlPoolName = "testpool"; ResourceIdentifier synapseSqlPoolResourceId = SynapseSqlPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName); SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); // get the collection of this SynapseRestorePointResource SynapseRestorePointCollection collection = synapseSqlPool.GetSynapseRestorePoints(); - // invoke the operation and iterate over the result - await foreach (SynapseRestorePointResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseRestorePointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string restorePointName = "131546477590000000"; + SynapseRestorePointResource result = await collection.GetAsync(restorePointName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseRestorePointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsASqlPoolRestorePoint() + public async Task GetAll_GetAListOfRestorePointsOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolRestorePointsGet.json - // this example is just showing the usage of "SqlPoolRestorePoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolRestorePoints.json + // this example is just showing the usage of "SqlPoolRestorePoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,23 +66,25 @@ public async Task Get_GetsASqlPoolRestorePoint() // for more information of creating SynapseSqlPoolResource, please refer to the document of SynapseSqlPoolResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default-SQL-SouthEastAsia"; - string workspaceName = "testws"; - string sqlPoolName = "testpool"; + string workspaceName = "testserver"; + string sqlPoolName = "testDatabase"; ResourceIdentifier synapseSqlPoolResourceId = SynapseSqlPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName); SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); // get the collection of this SynapseRestorePointResource SynapseRestorePointCollection collection = synapseSqlPool.GetSynapseRestorePoints(); - // invoke the operation - string restorePointName = "131546477590000000"; - SynapseRestorePointResource result = await collection.GetAsync(restorePointName); + // invoke the operation and iterate over the result + await foreach (SynapseRestorePointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseRestorePointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseRestorePointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerBlobAuditingPolicyCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerBlobAuditingPolicyCollection.cs index d05f2535ed3e7..45fd889b8f188 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerBlobAuditingPolicyCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerBlobAuditingPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseServerBlobAuditingPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetBlobAuditingSettingOfWorkspaceManagedSqlServer() + public async Task CreateOrUpdate_CreateOrUpdateBlobAuditingPolicyOfWorkspaceSQLServerWithAllParameters() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerBlobAuditingSettings.json - // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateWorkspaceManagedSqlServerBlobAuditingSettingsWithAllParameters.json + // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,20 @@ public async Task Get_GetBlobAuditingSettingOfWorkspaceManagedSqlServer() // invoke the operation SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; - SynapseServerBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); + SynapseServerBlobAuditingPolicyData data = new SynapseServerBlobAuditingPolicyData + { + State = SynapseBlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + RetentionDays = 6, + AuditActionsAndGroups = { "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP" }, + StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), + IsStorageSecondaryKeyInUse = false, + IsAzureMonitorTargetEnabled = true, + QueueDelayMs = 4000, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + SynapseServerBlobAuditingPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +65,10 @@ public async Task Get_GetBlobAuditingSettingOfWorkspaceManagedSqlServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetBlobAuditingSettingOfWorkspaceManagedSqlServer() + public async Task CreateOrUpdate_CreateOrUpdateBlobAuditingPolicyOfWorkspaceManagedSqlServerWithMinimalParameters() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerBlobAuditingSettings.json - // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateWorkspaceManagedSqlServerBlobAuditingSettingsWithMinParameters.json + // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +88,25 @@ public async Task Exists_GetBlobAuditingSettingOfWorkspaceManagedSqlServer() // invoke the operation SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; - bool result = await collection.ExistsAsync(blobAuditingPolicyName); + SynapseServerBlobAuditingPolicyData data = new SynapseServerBlobAuditingPolicyData + { + State = SynapseBlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + SynapseServerBlobAuditingPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseServerBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetBlobAuditingSettingOfWorkspaceManagedSqlServer() + public async Task Get_GetBlobAuditingSettingOfWorkspaceManagedSqlServer() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerBlobAuditingSettings.json // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +129,21 @@ public async Task GetIfExists_GetBlobAuditingSettingOfWorkspaceManagedSqlServer( // invoke the operation SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); - SynapseServerBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; + SynapseServerBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseServerBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseServerBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateBlobAuditingPolicyOfWorkspaceSQLServerWithAllParameters() + public async Task GetAll_GetBlobAuditingPolicyOfWorkspaceMangedSqlServer() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateWorkspaceManagedSqlServerBlobAuditingSettingsWithAllParameters.json - // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerBlobAuditingSettings.json + // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,39 +161,25 @@ public async Task CreateOrUpdate_CreateOrUpdateBlobAuditingPolicyOfWorkspaceSQLS // get the collection of this SynapseServerBlobAuditingPolicyResource SynapseServerBlobAuditingPolicyCollection collection = synapseWorkspace.GetSynapseServerBlobAuditingPolicies(); - // invoke the operation - SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; - SynapseServerBlobAuditingPolicyData data = new SynapseServerBlobAuditingPolicyData() + // invoke the operation and iterate over the result + await foreach (SynapseServerBlobAuditingPolicyResource item in collection.GetAllAsync()) { - State = SynapseBlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - RetentionDays = 6, - AuditActionsAndGroups = -{ -"SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP","FAILED_DATABASE_AUTHENTICATION_GROUP","BATCH_COMPLETED_GROUP" -}, - StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), - IsStorageSecondaryKeyInUse = false, - IsAzureMonitorTargetEnabled = true, - QueueDelayMs = 4000, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - SynapseServerBlobAuditingPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseServerBlobAuditingPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseServerBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateBlobAuditingPolicyOfWorkspaceManagedSqlServerWithMinimalParameters() + public async Task Exists_GetBlobAuditingSettingOfWorkspaceManagedSqlServer() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateWorkspaceManagedSqlServerBlobAuditingSettingsWithMinParameters.json - // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerBlobAuditingSettings.json + // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -197,28 +199,17 @@ public async Task CreateOrUpdate_CreateOrUpdateBlobAuditingPolicyOfWorkspaceMana // invoke the operation SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; - SynapseServerBlobAuditingPolicyData data = new SynapseServerBlobAuditingPolicyData() - { - State = SynapseBlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - SynapseServerBlobAuditingPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(blobAuditingPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseServerBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetBlobAuditingPolicyOfWorkspaceMangedSqlServer() + public async Task GetIfExists_GetBlobAuditingSettingOfWorkspaceManagedSqlServer() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerBlobAuditingSettings.json - // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerBlobAuditingSettings.json + // this example is just showing the usage of "WorkspaceManagedSqlServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,17 +227,23 @@ public async Task GetAll_GetBlobAuditingPolicyOfWorkspaceMangedSqlServer() // get the collection of this SynapseServerBlobAuditingPolicyResource SynapseServerBlobAuditingPolicyCollection collection = synapseWorkspace.GetSynapseServerBlobAuditingPolicies(); - // invoke the operation and iterate over the result - await foreach (SynapseServerBlobAuditingPolicyResource item in collection.GetAllAsync()) + // invoke the operation + SynapseBlobAuditingPolicyName blobAuditingPolicyName = SynapseBlobAuditingPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); + SynapseServerBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseServerBlobAuditingPolicyData resourceData = item.Data; + SynapseServerBlobAuditingPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerBlobAuditingPolicyResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerBlobAuditingPolicyResource.cs index e643c5e0c6c47..64960f4feccd0 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerBlobAuditingPolicyResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerBlobAuditingPolicyResource.cs @@ -69,16 +69,13 @@ public async Task Update_CreateOrUpdateBlobAuditingPolicyOfWorkspaceSQLServerWit SynapseServerBlobAuditingPolicyResource synapseServerBlobAuditingPolicy = client.GetSynapseServerBlobAuditingPolicyResource(synapseServerBlobAuditingPolicyResourceId); // invoke the operation - SynapseServerBlobAuditingPolicyData data = new SynapseServerBlobAuditingPolicyData() + SynapseServerBlobAuditingPolicyData data = new SynapseServerBlobAuditingPolicyData { State = SynapseBlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", RetentionDays = 6, - AuditActionsAndGroups = -{ -"SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP","FAILED_DATABASE_AUTHENTICATION_GROUP","BATCH_COMPLETED_GROUP" -}, + AuditActionsAndGroups = { "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP" }, StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), IsStorageSecondaryKeyInUse = false, IsAzureMonitorTargetEnabled = true, @@ -116,7 +113,7 @@ public async Task Update_CreateOrUpdateBlobAuditingPolicyOfWorkspaceManagedSqlSe SynapseServerBlobAuditingPolicyResource synapseServerBlobAuditingPolicy = client.GetSynapseServerBlobAuditingPolicyResource(synapseServerBlobAuditingPolicyResourceId); // invoke the operation - SynapseServerBlobAuditingPolicyData data = new SynapseServerBlobAuditingPolicyData() + SynapseServerBlobAuditingPolicyData data = new SynapseServerBlobAuditingPolicyData { State = SynapseBlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerSecurityAlertPolicyCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerSecurityAlertPolicyCollection.cs index 1c8542e4de4b8..20665931d9952 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerSecurityAlertPolicyCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerSecurityAlertPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseServerSecurityAlertPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() + public async Task CreateOrUpdate_UpdateAWorkspaceManagedSqlServerSThreatDetectionPolicyWithAllParameters() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerSecurityAlertPolicy.json - // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/WorkspaceManagedSqlServerSecurityAlertWithAllParameters.json + // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() // invoke the operation SqlServerSecurityAlertPolicyName securityAlertPolicyName = SqlServerSecurityAlertPolicyName.Default; - SynapseServerSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); + SynapseServerSecurityAlertPolicyData data = new SynapseServerSecurityAlertPolicyData + { + State = SynapseSecurityAlertPolicyState.Enabled, + DisabledAlerts = { "Access_Anomaly", "Usage_Anomaly" }, + EmailAddresses = { "testSecurityAlert@microsoft.com" }, + EnableEmailToAccountAdmins = true, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + RetentionDays = 5, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + SynapseServerSecurityAlertPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +63,10 @@ public async Task Get_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() + public async Task CreateOrUpdate_UpdateAWorkspaceManagedSqlServerSThreatDetectionPolicyWithMinimalParameters() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerSecurityAlertPolicy.json - // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/WorkspaceManagedSqlServerSecurityAlertCreateWithMinParameters.json + // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +86,26 @@ public async Task Exists_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() // invoke the operation SqlServerSecurityAlertPolicyName securityAlertPolicyName = SqlServerSecurityAlertPolicyName.Default; - bool result = await collection.ExistsAsync(securityAlertPolicyName); + SynapseServerSecurityAlertPolicyData data = new SynapseServerSecurityAlertPolicyData + { + State = SynapseSecurityAlertPolicyState.Disabled, + EnableEmailToAccountAdmins = true, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + SynapseServerSecurityAlertPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() + public async Task Get_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerSecurityAlertPolicy.json // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +128,21 @@ public async Task GetIfExists_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() // invoke the operation SqlServerSecurityAlertPolicyName securityAlertPolicyName = SqlServerSecurityAlertPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); - SynapseServerSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + SynapseServerSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAWorkspaceManagedSqlServerSThreatDetectionPolicyWithAllParameters() + public async Task GetAll_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/WorkspaceManagedSqlServerSecurityAlertWithAllParameters.json - // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerSecurityAlertPolicies.json + // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,40 +160,25 @@ public async Task CreateOrUpdate_UpdateAWorkspaceManagedSqlServerSThreatDetectio // get the collection of this SynapseServerSecurityAlertPolicyResource SynapseServerSecurityAlertPolicyCollection collection = synapseWorkspace.GetSynapseServerSecurityAlertPolicies(); - // invoke the operation - SqlServerSecurityAlertPolicyName securityAlertPolicyName = SqlServerSecurityAlertPolicyName.Default; - SynapseServerSecurityAlertPolicyData data = new SynapseServerSecurityAlertPolicyData() + // invoke the operation and iterate over the result + await foreach (SynapseServerSecurityAlertPolicyResource item in collection.GetAllAsync()) { - State = SynapseSecurityAlertPolicyState.Enabled, - DisabledAlerts = -{ -"Access_Anomaly","Usage_Anomaly" -}, - EmailAddresses = -{ -"testSecurityAlert@microsoft.com" -}, - EnableEmailToAccountAdmins = true, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - RetentionDays = 5, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - SynapseServerSecurityAlertPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseServerSecurityAlertPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAWorkspaceManagedSqlServerSThreatDetectionPolicyWithMinimalParameters() + public async Task Exists_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/WorkspaceManagedSqlServerSecurityAlertCreateWithMinParameters.json - // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerSecurityAlertPolicy.json + // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,29 +198,17 @@ public async Task CreateOrUpdate_UpdateAWorkspaceManagedSqlServerSThreatDetectio // invoke the operation SqlServerSecurityAlertPolicyName securityAlertPolicyName = SqlServerSecurityAlertPolicyName.Default; - SynapseServerSecurityAlertPolicyData data = new SynapseServerSecurityAlertPolicyData() - { - State = SynapseSecurityAlertPolicyState.Disabled, - EnableEmailToAccountAdmins = true, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - SynapseServerSecurityAlertPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(securityAlertPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() + public async Task GetIfExists_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerSecurityAlertPolicies.json - // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerSecurityAlertPolicy.json + // this example is just showing the usage of "WorkspaceManagedSqlServerSecurityAlertPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -238,17 +226,23 @@ public async Task GetAll_GetWorkspaceManagedSqlServerSSecurityAlertPolicy() // get the collection of this SynapseServerSecurityAlertPolicyResource SynapseServerSecurityAlertPolicyCollection collection = synapseWorkspace.GetSynapseServerSecurityAlertPolicies(); - // invoke the operation and iterate over the result - await foreach (SynapseServerSecurityAlertPolicyResource item in collection.GetAllAsync()) + // invoke the operation + SqlServerSecurityAlertPolicyName securityAlertPolicyName = SqlServerSecurityAlertPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); + SynapseServerSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseServerSecurityAlertPolicyData resourceData = item.Data; + SynapseServerSecurityAlertPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerSecurityAlertPolicyResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerSecurityAlertPolicyResource.cs index a06a40b00abf7..54fad671d6aa2 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerSecurityAlertPolicyResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerSecurityAlertPolicyResource.cs @@ -69,17 +69,11 @@ public async Task Update_UpdateAWorkspaceManagedSqlServerSThreatDetectionPolicyW SynapseServerSecurityAlertPolicyResource synapseServerSecurityAlertPolicy = client.GetSynapseServerSecurityAlertPolicyResource(synapseServerSecurityAlertPolicyResourceId); // invoke the operation - SynapseServerSecurityAlertPolicyData data = new SynapseServerSecurityAlertPolicyData() + SynapseServerSecurityAlertPolicyData data = new SynapseServerSecurityAlertPolicyData { State = SynapseSecurityAlertPolicyState.Enabled, - DisabledAlerts = -{ -"Access_Anomaly","Usage_Anomaly" -}, - EmailAddresses = -{ -"testSecurityAlert@microsoft.com" -}, + DisabledAlerts = { "Access_Anomaly", "Usage_Anomaly" }, + EmailAddresses = { "testSecurityAlert@microsoft.com" }, EnableEmailToAccountAdmins = true, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", @@ -117,7 +111,7 @@ public async Task Update_UpdateAWorkspaceManagedSqlServerSThreatDetectionPolicyW SynapseServerSecurityAlertPolicyResource synapseServerSecurityAlertPolicy = client.GetSynapseServerSecurityAlertPolicyResource(synapseServerSecurityAlertPolicyResourceId); // invoke the operation - SynapseServerSecurityAlertPolicyData data = new SynapseServerSecurityAlertPolicyData() + SynapseServerSecurityAlertPolicyData data = new SynapseServerSecurityAlertPolicyData { State = SynapseSecurityAlertPolicyState.Disabled, EnableEmailToAccountAdmins = true, diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerVulnerabilityAssessmentCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerVulnerabilityAssessmentCollection.cs index 63fdd96fbb351..1f65b47617044 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerVulnerabilityAssessmentCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerVulnerabilityAssessmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseServerVulnerabilityAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceManagedSqlServerSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityAssessmentWithAllParameters() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerVulnerabilityAssessment.json - // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/PutWorkspaceManagedSqlServerVulnerabilityAssessmentWithAllParameters.json + // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,20 @@ public async Task Get_GetWorkspaceManagedSqlServerSVulnerabilityAssessment() // invoke the operation SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - SynapseServerVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); + SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + RecurringScans = new SynapseVulnerabilityAssessmentRecurringScansProperties + { + IsEnabled = true, + EnableEmailToAccountAdmins = true, + Emails = { "email1@mail.com", "email2@mail.com" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SynapseServerVulnerabilityAssessmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +65,10 @@ public async Task Get_GetWorkspaceManagedSqlServerSVulnerabilityAssessment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceManagedSqlServerSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityAssessmentWithMinimalParametersWhenStorageAccountAccessKeyIsSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerVulnerabilityAssessment.json - // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/PutWorkspaceMangedSqlServerVulnerabilityAssessmentCreateStorageAccessKeyMin.json + // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +88,27 @@ public async Task Exists_GetWorkspaceManagedSqlServerSVulnerabilityAssessment() // invoke the operation SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); + SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SynapseServerVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseServerVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceManagedSqlServerSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityAssessmentWithMinimalParametersWhenStorageContainerSasKeyIsSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerVulnerabilityAssessment.json - // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/PutWorkspaceMangedSqlServerVulnerabilityAssessmentCreateContainerSasKeyMin.json + // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,29 +128,27 @@ public async Task GetIfExists_GetWorkspaceManagedSqlServerSVulnerabilityAssessme // invoke the operation SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); - SynapseServerVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseServerVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SynapseServerVulnerabilityAssessmentResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseServerVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityAssessmentWithAllParameters() + public async Task Get_GetWorkspaceManagedSqlServerSVulnerabilityAssessment() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/PutWorkspaceManagedSqlServerVulnerabilityAssessmentWithAllParameters.json - // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerVulnerabilityAssessment.json + // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,23 +168,7 @@ public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceManagedSqlServerSVulner // invoke the operation SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new SynapseVulnerabilityAssessmentRecurringScansProperties() - { - IsEnabled = true, - EnableEmailToAccountAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SynapseServerVulnerabilityAssessmentResource result = lro.Value; + SynapseServerVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -174,10 +179,10 @@ public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceManagedSqlServerSVulner [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityAssessmentWithMinimalParametersWhenStorageAccountAccessKeyIsSpecified() + public async Task GetAll_GetWorkspaceManagedSqlServerSVulnerabilityAssessmentPolicies() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/PutWorkspaceMangedSqlServerVulnerabilityAssessmentCreateStorageAccessKeyMin.json - // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerVulnerabilityAssessmentPolicies.json + // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,29 +200,25 @@ public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceManagedSqlServerSVulner // get the collection of this SynapseServerVulnerabilityAssessmentResource SynapseServerVulnerabilityAssessmentCollection collection = synapseWorkspace.GetSynapseServerVulnerabilityAssessments(); - // invoke the operation - SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData() + // invoke the operation and iterate over the result + await foreach (SynapseServerVulnerabilityAssessmentResource item in collection.GetAllAsync()) { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SynapseServerVulnerabilityAssessmentResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseServerVulnerabilityAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseServerVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityAssessmentWithMinimalParametersWhenStorageContainerSasKeyIsSpecified() + public async Task Exists_GetWorkspaceManagedSqlServerSVulnerabilityAssessment() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/PutWorkspaceMangedSqlServerVulnerabilityAssessmentCreateContainerSasKeyMin.json - // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerVulnerabilityAssessment.json + // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -237,27 +238,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAWorkspaceManagedSqlServerSVulner // invoke the operation SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SynapseServerVulnerabilityAssessmentResource result = lro.Value; + bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseServerVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetWorkspaceManagedSqlServerSVulnerabilityAssessmentPolicies() + public async Task GetIfExists_GetWorkspaceManagedSqlServerSVulnerabilityAssessment() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerVulnerabilityAssessmentPolicies.json - // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspaceManagedSqlServerVulnerabilityAssessment.json + // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -275,17 +266,23 @@ public async Task GetAll_GetWorkspaceManagedSqlServerSVulnerabilityAssessmentPol // get the collection of this SynapseServerVulnerabilityAssessmentResource SynapseServerVulnerabilityAssessmentCollection collection = synapseWorkspace.GetSynapseServerVulnerabilityAssessments(); - // invoke the operation and iterate over the result - await foreach (SynapseServerVulnerabilityAssessmentResource item in collection.GetAllAsync()) + // invoke the operation + SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; + NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); + SynapseServerVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseServerVulnerabilityAssessmentData resourceData = item.Data; + SynapseServerVulnerabilityAssessmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerVulnerabilityAssessmentResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerVulnerabilityAssessmentResource.cs index 541f61a438aa2..9bf6fbdff63aa 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerVulnerabilityAssessmentResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseServerVulnerabilityAssessmentResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetWorkspaceManagedSqlServerSVulnerabilityAssessment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_RemoveWorkspaceManagedSqlServerSVulnerabilityAssessment() + { + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteWorkspaceManagedSqlServerVulnerabilityAssessment.json + // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SynapseServerVulnerabilityAssessmentResource created on azure + // for more information of creating SynapseServerVulnerabilityAssessmentResource, please refer to the document of SynapseServerVulnerabilityAssessmentResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "wsg-7398"; + string workspaceName = "testWorkspace"; + SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; + ResourceIdentifier synapseServerVulnerabilityAssessmentResourceId = SynapseServerVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, vulnerabilityAssessmentName); + SynapseServerVulnerabilityAssessmentResource synapseServerVulnerabilityAssessment = client.GetSynapseServerVulnerabilityAssessmentResource(synapseServerVulnerabilityAssessmentResourceId); + + // invoke the operation + await synapseServerVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityAssessmentWithAllParameters() @@ -69,19 +96,16 @@ public async Task Update_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityA SynapseServerVulnerabilityAssessmentResource synapseServerVulnerabilityAssessment = client.GetSynapseServerVulnerabilityAssessmentResource(synapseServerVulnerabilityAssessmentResourceId); // invoke the operation - SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData() + SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new SynapseVulnerabilityAssessmentRecurringScansProperties() + RecurringScans = new SynapseVulnerabilityAssessmentRecurringScansProperties { IsEnabled = true, EnableEmailToAccountAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, + Emails = { "email1@mail.com", "email2@mail.com" }, }, }; ArmOperation lro = await synapseServerVulnerabilityAssessment.UpdateAsync(WaitUntil.Completed, data); @@ -116,7 +140,7 @@ public async Task Update_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityA SynapseServerVulnerabilityAssessmentResource synapseServerVulnerabilityAssessment = client.GetSynapseServerVulnerabilityAssessmentResource(synapseServerVulnerabilityAssessmentResourceId); // invoke the operation - SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData() + SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -153,7 +177,7 @@ public async Task Update_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityA SynapseServerVulnerabilityAssessmentResource synapseServerVulnerabilityAssessment = client.GetSynapseServerVulnerabilityAssessmentResource(synapseServerVulnerabilityAssessmentResourceId); // invoke the operation - SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData() + SynapseServerVulnerabilityAssessmentData data = new SynapseServerVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -167,32 +191,5 @@ public async Task Update_CreateOrUpdateAWorkspaceManagedSqlServerSVulnerabilityA // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_RemoveWorkspaceManagedSqlServerSVulnerabilityAssessment() - { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteWorkspaceManagedSqlServerVulnerabilityAssessment.json - // this example is just showing the usage of "WorkspaceManagedSqlServerVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SynapseServerVulnerabilityAssessmentResource created on azure - // for more information of creating SynapseServerVulnerabilityAssessmentResource, please refer to the document of SynapseServerVulnerabilityAssessmentResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "wsg-7398"; - string workspaceName = "testWorkspace"; - SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - ResourceIdentifier synapseServerVulnerabilityAssessmentResourceId = SynapseServerVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, vulnerabilityAssessmentName); - SynapseServerVulnerabilityAssessmentResource synapseServerVulnerabilityAssessment = client.GetSynapseServerVulnerabilityAssessmentResource(synapseServerVulnerabilityAssessmentResourceId); - - // invoke the operation - await synapseServerVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSparkConfigurationCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSparkConfigurationCollection.cs index 8c7bc59f2fdf3..dd0cf374a9f49 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSparkConfigurationCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSparkConfigurationCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetSparkConfigurationByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSparkConfigurationByName() + public async Task GetAll_ListSparkConfigurationsInAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/SparkConfiguration_Get.json - // this example is just showing the usage of "SparkConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/SparkConfigurations_ListByWorkspace.json + // this example is just showing the usage of "SparkConfigurations_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetSparkConfigurationByName() // get the collection of this SynapseSparkConfigurationResource SynapseSparkConfigurationCollection collection = synapseWorkspace.GetSynapseSparkConfigurations(); - // invoke the operation - string sparkConfigurationName = "exampleSparkConfigurationName"; - bool result = await collection.ExistsAsync(sparkConfigurationName); + // invoke the operation and iterate over the result + await foreach (SynapseSparkConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSparkConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSparkConfigurationByName() + public async Task Exists_GetSparkConfigurationByName() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/SparkConfiguration_Get.json // this example is just showing the usage of "SparkConfiguration_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetSparkConfigurationByName() // invoke the operation string sparkConfigurationName = "exampleSparkConfigurationName"; - NullableResponse response = await collection.GetIfExistsAsync(sparkConfigurationName); - SynapseSparkConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sparkConfigurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSparkConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSparkConfigurationsInAWorkspace() + public async Task GetIfExists_GetSparkConfigurationByName() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/SparkConfigurations_ListByWorkspace.json - // this example is just showing the usage of "SparkConfigurations_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/preview/2021-06-01-preview/examples/SparkConfiguration_Get.json + // this example is just showing the usage of "SparkConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ListSparkConfigurationsInAWorkspace() // get the collection of this SynapseSparkConfigurationResource SynapseSparkConfigurationCollection collection = synapseWorkspace.GetSynapseSparkConfigurations(); - // invoke the operation and iterate over the result - await foreach (SynapseSparkConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string sparkConfigurationName = "exampleSparkConfigurationName"; + NullableResponse response = await collection.GetIfExistsAsync(sparkConfigurationName); + SynapseSparkConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseSparkConfigurationData resourceData = item.Data; + SynapseSparkConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolBlobAuditingPolicyResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolBlobAuditingPolicyResource.cs index 252af16501b04..4ac874d981142 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolBlobAuditingPolicyResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolBlobAuditingPolicyResource.cs @@ -69,16 +69,13 @@ public async Task CreateOrUpdate_CreateOrUpdateADatabaseSBlobAuditingPolicyWithA SynapseSqlPoolBlobAuditingPolicyResource synapseSqlPoolBlobAuditingPolicy = client.GetSynapseSqlPoolBlobAuditingPolicyResource(synapseSqlPoolBlobAuditingPolicyResourceId); // invoke the operation - SynapseSqlPoolBlobAuditingPolicyData data = new SynapseSqlPoolBlobAuditingPolicyData() + SynapseSqlPoolBlobAuditingPolicyData data = new SynapseSqlPoolBlobAuditingPolicyData { State = SynapseBlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", RetentionDays = 6, - AuditActionsAndGroups = -{ -"DATABASE_LOGOUT_GROUP","DATABASE_ROLE_MEMBER_CHANGE_GROUP","UPDATE on database::TestDatabaseName by public" -}, + AuditActionsAndGroups = { "DATABASE_LOGOUT_GROUP", "DATABASE_ROLE_MEMBER_CHANGE_GROUP", "UPDATE on database::TestDatabaseName by public" }, StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), IsStorageSecondaryKeyInUse = false, IsAzureMonitorTargetEnabled = true, @@ -115,7 +112,7 @@ public async Task CreateOrUpdate_CreateOrUpdateADatabaseSBlobAuditingPolicyWithM SynapseSqlPoolBlobAuditingPolicyResource synapseSqlPoolBlobAuditingPolicy = client.GetSynapseSqlPoolBlobAuditingPolicyResource(synapseSqlPoolBlobAuditingPolicyResourceId); // invoke the operation - SynapseSqlPoolBlobAuditingPolicyData data = new SynapseSqlPoolBlobAuditingPolicyData() + SynapseSqlPoolBlobAuditingPolicyData data = new SynapseSqlPoolBlobAuditingPolicyData { State = SynapseBlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolCollection.cs index 7638b6632185f..b7640db188a85 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseSqlPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASQLAnalyticsPool() + public async Task CreateOrUpdate_CreateASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPool.json - // this example is just showing the usage of "SqlPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateSqlPool.json + // this example is just showing the usage of "SqlPools_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,9 +30,9 @@ public async Task Get_GetASQLAnalyticsPool() // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-6852"; - string workspaceName = "sqlcrudtest-2080"; + string subscriptionId = "01234567-89ab-4def-0123-456789abcdef"; + string resourceGroupName = "ExampleResourceGroup"; + string workspaceName = "ExampleWorkspace"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); @@ -40,8 +40,24 @@ public async Task Get_GetASQLAnalyticsPool() SynapseSqlPoolCollection collection = synapseWorkspace.GetSynapseSqlPools(); // invoke the operation - string sqlPoolName = "sqlcrudtest-9187"; - SynapseSqlPoolResource result = await collection.GetAsync(sqlPoolName); + string sqlPoolName = "ExampleSqlPool"; + SynapseSqlPoolData data = new SynapseSqlPoolData(new AzureLocation("Southeast Asia")) + { + Sku = new SynapseSku + { + Tier = "", + Name = "", + }, + MaxSizeBytes = 0L, + Collation = "", + SourceDatabaseId = "", + RecoverableDatabaseId = "", + CreateMode = new SqlPoolCreateMode(""), + StorageAccountType = SqlPoolStorageAccountType.Lrs, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlPoolName, data); + SynapseSqlPoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +68,7 @@ public async Task Get_GetASQLAnalyticsPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASQLAnalyticsPool() + public async Task Get_GetASQLAnalyticsPool() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPool.json // this example is just showing the usage of "SqlPools_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +91,21 @@ public async Task Exists_GetASQLAnalyticsPool() // invoke the operation string sqlPoolName = "sqlcrudtest-9187"; - bool result = await collection.ExistsAsync(sqlPoolName); + SynapseSqlPoolResource result = await collection.GetAsync(sqlPoolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASQLAnalyticsPool() + public async Task GetAll_ListSQLAnalyticsPoolsInAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPool.json - // this example is just showing the usage of "SqlPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolsInWorkspace.json + // this example is just showing the usage of "SqlPools_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,39 +115,33 @@ public async Task GetIfExists_GetASQLAnalyticsPool() // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-6852"; - string workspaceName = "sqlcrudtest-2080"; + string resourceGroupName = "sqlcrudtest-6845"; + string workspaceName = "sqlcrudtest-7177"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // get the collection of this SynapseSqlPoolResource SynapseSqlPoolCollection collection = synapseWorkspace.GetSynapseSqlPools(); - // invoke the operation - string sqlPoolName = "sqlcrudtest-9187"; - NullableResponse response = await collection.GetIfExistsAsync(sqlPoolName); - SynapseSqlPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SynapseSqlPoolResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseSqlPoolData resourceData = result.Data; + SynapseSqlPoolData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASQLAnalyticsPool() + public async Task GetAll_ListSQLAnalyticsPoolsInAWorkspaceWithFilter() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateSqlPool.json - // this example is just showing the usage of "SqlPools_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolsInWorkspaceWithFilter.json + // this example is just showing the usage of "SqlPools_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,50 +150,34 @@ public async Task CreateOrUpdate_CreateASQLAnalyticsPool() // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource - string subscriptionId = "01234567-89ab-4def-0123-456789abcdef"; - string resourceGroupName = "ExampleResourceGroup"; - string workspaceName = "ExampleWorkspace"; + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "sqlcrudtest-6845"; + string workspaceName = "sqlcrudtest-7177"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // get the collection of this SynapseSqlPoolResource SynapseSqlPoolCollection collection = synapseWorkspace.GetSynapseSqlPools(); - // invoke the operation - string sqlPoolName = "ExampleSqlPool"; - SynapseSqlPoolData data = new SynapseSqlPoolData(new AzureLocation("Southeast Asia")) + // invoke the operation and iterate over the result + await foreach (SynapseSqlPoolResource item in collection.GetAllAsync()) { - Sku = new SynapseSku() - { - Tier = "", - Name = "", - }, - MaxSizeBytes = 0L, - Collation = "", - SourceDatabaseId = "", - RecoverableDatabaseId = "", - CreateMode = new SqlPoolCreateMode(""), - StorageAccountType = SqlPoolStorageAccountType.Lrs, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlPoolName, data); - SynapseSqlPoolResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSQLAnalyticsPoolsInAWorkspace() + public async Task Exists_GetASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolsInWorkspace.json - // this example is just showing the usage of "SqlPools_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPool.json + // this example is just showing the usage of "SqlPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,33 +187,27 @@ public async Task GetAll_ListSQLAnalyticsPoolsInAWorkspace() // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-6845"; - string workspaceName = "sqlcrudtest-7177"; + string resourceGroupName = "sqlcrudtest-6852"; + string workspaceName = "sqlcrudtest-2080"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // get the collection of this SynapseSqlPoolResource SynapseSqlPoolCollection collection = synapseWorkspace.GetSynapseSqlPools(); - // invoke the operation and iterate over the result - await foreach (SynapseSqlPoolResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string sqlPoolName = "sqlcrudtest-9187"; + bool result = await collection.ExistsAsync(sqlPoolName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSQLAnalyticsPoolsInAWorkspaceWithFilter() + public async Task GetIfExists_GetASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolsInWorkspaceWithFilter.json - // this example is just showing the usage of "SqlPools_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPool.json + // this example is just showing the usage of "SqlPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -225,25 +217,31 @@ public async Task GetAll_ListSQLAnalyticsPoolsInAWorkspaceWithFilter() // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-6845"; - string workspaceName = "sqlcrudtest-7177"; + string resourceGroupName = "sqlcrudtest-6852"; + string workspaceName = "sqlcrudtest-2080"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // get the collection of this SynapseSqlPoolResource SynapseSqlPoolCollection collection = synapseWorkspace.GetSynapseSqlPools(); - // invoke the operation and iterate over the result - await foreach (SynapseSqlPoolResource item in collection.GetAllAsync()) + // invoke the operation + string sqlPoolName = "sqlcrudtest-9187"; + NullableResponse response = await collection.GetIfExistsAsync(sqlPoolName); + SynapseSqlPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseSqlPoolData resourceData = item.Data; + SynapseSqlPoolData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolColumnCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolColumnCollection.cs index c472dfeeba10f..6318bba2ba412 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolColumnCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolColumnCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseSqlPoolColumnCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheColumnsInATableOfAGivenSchemaInASQLAnalyticsPool() + public async Task Get_GetDatabaseColumn() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolColumns.json - // this example is just showing the usage of "SqlPoolTableColumns_ListByTableName" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolColumnGet.json + // this example is just showing the usage of "SqlPoolColumns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_ListTheColumnsInATableOfAGivenSchemaInASQLAnalyticsPool // get the collection of this SynapseSqlPoolColumnResource SynapseSqlPoolColumnCollection collection = synapseSqlPoolTable.GetSynapseSqlPoolColumns(); - // invoke the operation and iterate over the result - await foreach (SynapseSqlPoolColumnResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolColumnData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string columnName = "column1"; + SynapseSqlPoolColumnResource result = await collection.GetAsync(columnName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolColumnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatabaseColumn() + public async Task GetAll_ListTheColumnsInATableOfAGivenSchemaInASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolColumnGet.json - // this example is just showing the usage of "SqlPoolColumns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolColumns.json + // this example is just showing the usage of "SqlPoolTableColumns_ListByTableName" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +78,17 @@ public async Task Get_GetDatabaseColumn() // get the collection of this SynapseSqlPoolColumnResource SynapseSqlPoolColumnCollection collection = synapseSqlPoolTable.GetSynapseSqlPoolColumns(); - // invoke the operation - string columnName = "column1"; - SynapseSqlPoolColumnResource result = await collection.GetAsync(columnName); + // invoke the operation and iterate over the result + await foreach (SynapseSqlPoolColumnResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolColumnData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolColumnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolColumnResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolColumnResource.cs index b86b743e6e7fb..411c75c8bc8ee 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolColumnResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolColumnResource.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseSqlPoolColumnResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task EnableRecommendationSqlPoolSensitivityLabel_EnablesSensitivityRecommendationsOnAGivenColumn() + public async Task Get_GetDatabaseColumn() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RecommendedColumnSensitivityLabelEnable.json - // this example is just showing the usage of "SqlPoolSensitivityLabels_EnableRecommendation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolColumnGet.json + // this example is just showing the usage of "SqlPoolColumns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,26 +31,30 @@ public async Task EnableRecommendationSqlPoolSensitivityLabel_EnablesSensitivity // for more information of creating SynapseSqlPoolColumnResource, please refer to the document of SynapseSqlPoolColumnResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "myRG"; - string workspaceName = "myServer"; + string workspaceName = "serverName"; string sqlPoolName = "myDatabase"; string schemaName = "dbo"; - string tableName = "myTable"; - string columnName = "myColumn"; + string tableName = "table1"; + string columnName = "column1"; ResourceIdentifier synapseSqlPoolColumnResourceId = SynapseSqlPoolColumnResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, schemaName, tableName, columnName); SynapseSqlPoolColumnResource synapseSqlPoolColumn = client.GetSynapseSqlPoolColumnResource(synapseSqlPoolColumnResourceId); // invoke the operation - await synapseSqlPoolColumn.EnableRecommendationSqlPoolSensitivityLabelAsync(); + SynapseSqlPoolColumnResource result = await synapseSqlPoolColumn.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolColumnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task DisableRecommendationSqlPoolSensitivityLabel_DisablesSensitivityRecommendationsOnAGivenColumn() + public async Task EnableRecommendationSqlPoolSensitivityLabel_EnablesSensitivityRecommendationsOnAGivenColumn() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RecommendedColumnSensitivityLabelDisable.json - // this example is just showing the usage of "SqlPoolSensitivityLabels_DisableRecommendation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RecommendedColumnSensitivityLabelEnable.json + // this example is just showing the usage of "SqlPoolSensitivityLabels_EnableRecommendation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,17 +74,17 @@ public async Task DisableRecommendationSqlPoolSensitivityLabel_DisablesSensitivi SynapseSqlPoolColumnResource synapseSqlPoolColumn = client.GetSynapseSqlPoolColumnResource(synapseSqlPoolColumnResourceId); // invoke the operation - await synapseSqlPoolColumn.DisableRecommendationSqlPoolSensitivityLabelAsync(); + await synapseSqlPoolColumn.EnableRecommendationSqlPoolSensitivityLabelAsync(); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatabaseColumn() + public async Task DisableRecommendationSqlPoolSensitivityLabel_DisablesSensitivityRecommendationsOnAGivenColumn() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolColumnGet.json - // this example is just showing the usage of "SqlPoolColumns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/RecommendedColumnSensitivityLabelDisable.json + // this example is just showing the usage of "SqlPoolSensitivityLabels_DisableRecommendation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,22 +95,18 @@ public async Task Get_GetDatabaseColumn() // for more information of creating SynapseSqlPoolColumnResource, please refer to the document of SynapseSqlPoolColumnResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "myRG"; - string workspaceName = "serverName"; + string workspaceName = "myServer"; string sqlPoolName = "myDatabase"; string schemaName = "dbo"; - string tableName = "table1"; - string columnName = "column1"; + string tableName = "myTable"; + string columnName = "myColumn"; ResourceIdentifier synapseSqlPoolColumnResourceId = SynapseSqlPoolColumnResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, schemaName, tableName, columnName); SynapseSqlPoolColumnResource synapseSqlPoolColumn = client.GetSynapseSqlPoolColumnResource(synapseSqlPoolColumnResourceId); // invoke the operation - SynapseSqlPoolColumnResource result = await synapseSqlPoolColumn.GetAsync(); + await synapseSqlPoolColumn.DisableRecommendationSqlPoolSensitivityLabelAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolColumnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolResource.cs index 612ee2af1fd8a..c194424ac45bf 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetASQLAnalyticsPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASQLAnalyticsPool() + public async Task Delete_DeleteASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/UpdateSqlPool.json - // this example is just showing the usage of "SqlPools_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPool.json + // this example is just showing the usage of "SqlPools_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,37 +69,18 @@ public async Task Update_UpdateASQLAnalyticsPool() SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); // invoke the operation - SynapseSqlPoolPatch patch = new SynapseSqlPoolPatch() - { - Tags = -{ -}, - Location = new AzureLocation("West US 2"), - Sku = new SynapseSku() - { - Tier = "", - Name = "", - }, - MaxSizeBytes = 0L, - Collation = "", - RestorePointInTime = DateTimeOffset.Parse("1970-01-01T00:00:00.000Z"), - }; - ArmOperation lro = await synapseSqlPool.UpdateAsync(WaitUntil.Completed, patch); - SynapseSqlPoolResource result = lro.Value; + ArmOperation lro = await synapseSqlPool.DeleteAsync(WaitUntil.Completed); + BinaryData result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASQLAnalyticsPool() + public async Task Update_UpdateASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPool.json - // this example is just showing the usage of "SqlPools_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/UpdateSqlPool.json + // this example is just showing the usage of "SqlPools_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,10 +97,27 @@ public async Task Delete_DeleteASQLAnalyticsPool() SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); // invoke the operation - ArmOperation lro = await synapseSqlPool.DeleteAsync(WaitUntil.Completed); - BinaryData result = lro.Value; + SynapseSqlPoolPatch patch = new SynapseSqlPoolPatch + { + Tags = { }, + Location = new AzureLocation("West US 2"), + Sku = new SynapseSku + { + Tier = "", + Name = "", + }, + MaxSizeBytes = 0L, + Collation = "", + RestorePointInTime = DateTimeOffset.Parse("1970-01-01T00:00:00.000Z"), + }; + ArmOperation lro = await synapseSqlPool.UpdateAsync(WaitUntil.Completed, patch); + SynapseSqlPoolResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -325,17 +323,15 @@ public async Task UpdateSqlPoolSensitivityLabel_UpdateSensitivityLabelsOfAGivenD SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); // invoke the operation - SynapseSensitivityLabelUpdateListResult synapseSensitivityLabelUpdateListResult = new SynapseSensitivityLabelUpdateListResult() + SynapseSensitivityLabelUpdateListResult synapseSensitivityLabelUpdateListResult = new SynapseSensitivityLabelUpdateListResult { - Operations = -{ -new SynapseSensitivityLabelUpdate() + Operations = {new SynapseSensitivityLabelUpdate { Op = SynapseSensitivityLabelUpdateKind.Set, Schema = "dbo", Table = "table1", Column = "column1", -SensitivityLabel = new SynapseSensitivityLabelData() +SensitivityLabel = new SynapseSensitivityLabelData { LabelName = "Highly Confidential", LabelId = Guid.Parse("3A477B16-9423-432B-AA97-6069B481CEC3"), @@ -343,13 +339,13 @@ public async Task UpdateSqlPoolSensitivityLabel_UpdateSensitivityLabelsOfAGivenD InformationTypeId = Guid.Parse("1D3652D6-422C-4115-82F1-65DAEBC665C8"), Rank = SynapseSensitivityLabelRank.Low, }, -},new SynapseSensitivityLabelUpdate() +}, new SynapseSensitivityLabelUpdate { Op = SynapseSensitivityLabelUpdateKind.Set, Schema = "dbo", Table = "table2", Column = "column2", -SensitivityLabel = new SynapseSensitivityLabelData() +SensitivityLabel = new SynapseSensitivityLabelData { LabelName = "PII", LabelId = Guid.Parse("bf91e08c-f4f0-478a-b016-25164b2a65ff"), @@ -357,14 +353,13 @@ public async Task UpdateSqlPoolSensitivityLabel_UpdateSensitivityLabelsOfAGivenD InformationTypeId = Guid.Parse("d22fa6e9-5ee4-3bde-4c2b-a409604c4646"), Rank = SynapseSensitivityLabelRank.Critical, }, -},new SynapseSensitivityLabelUpdate() +}, new SynapseSensitivityLabelUpdate { Op = SynapseSensitivityLabelUpdateKind.Remove, Schema = "dbo", Table = "Table1", Column = "Column3", -} -}, +}}, }; await synapseSqlPool.UpdateSqlPoolSensitivityLabelAsync(synapseSensitivityLabelUpdateListResult); @@ -427,30 +422,27 @@ public async Task UpdateSqlPoolRecommendedSensitivityLabel_UpdateRecommendedSens SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); // invoke the operation - SynapseRecommendedSensitivityLabelUpdateOperationListResult synapseRecommendedSensitivityLabelUpdateOperationListResult = new SynapseRecommendedSensitivityLabelUpdateOperationListResult() + SynapseRecommendedSensitivityLabelUpdateOperationListResult synapseRecommendedSensitivityLabelUpdateOperationListResult = new SynapseRecommendedSensitivityLabelUpdateOperationListResult { - Operations = -{ -new SynapseRecommendedSensitivityLabelUpdate() + Operations = {new SynapseRecommendedSensitivityLabelUpdate { Op = SynapseRecommendedSensitivityLabelUpdateKind.Enable, Schema = "dbo", Table = "table1", Column = "column1", -},new SynapseRecommendedSensitivityLabelUpdate() +}, new SynapseRecommendedSensitivityLabelUpdate { Op = SynapseRecommendedSensitivityLabelUpdateKind.Enable, Schema = "dbo", Table = "table2", Column = "column2", -},new SynapseRecommendedSensitivityLabelUpdate() +}, new SynapseRecommendedSensitivityLabelUpdate { Op = SynapseRecommendedSensitivityLabelUpdateKind.Disable, Schema = "dbo", Table = "table1", Column = "column3", -} -}, +}}, }; await synapseSqlPool.UpdateSqlPoolRecommendedSensitivityLabelAsync(synapseRecommendedSensitivityLabelUpdateOperationListResult); diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSchemaCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSchemaCollection.cs index 1b84dd117cd55..1ccbf7f3eb889 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSchemaCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSchemaCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseSqlPoolSchemaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheSchemaInASQLAnalyticsPool() + public async Task Get_GetDatabaseSchema() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolSchema.json - // this example is just showing the usage of "SqlPoolSchemas_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolSchemaGet.json + // this example is just showing the usage of "SqlPoolSchemas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListTheSchemaInASQLAnalyticsPool() // get the collection of this SynapseSqlPoolSchemaResource SynapseSqlPoolSchemaCollection collection = synapseSqlPool.GetSynapseSqlPoolSchemas(); - // invoke the operation and iterate over the result - await foreach (SynapseSqlPoolSchemaResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolSchemaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string schemaName = "dbo"; + SynapseSqlPoolSchemaResource result = await collection.GetAsync(schemaName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatabaseSchema() + public async Task GetAll_ListTheSchemaInASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolSchemaGet.json - // this example is just showing the usage of "SqlPoolSchemas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolSchema.json + // this example is just showing the usage of "SqlPoolSchemas_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetDatabaseSchema() // get the collection of this SynapseSqlPoolSchemaResource SynapseSqlPoolSchemaCollection collection = synapseSqlPool.GetSynapseSqlPoolSchemas(); - // invoke the operation - string schemaName = "dbo"; - SynapseSqlPoolSchemaResource result = await collection.GetAsync(schemaName); + // invoke the operation and iterate over the result + await foreach (SynapseSqlPoolSchemaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolSchemaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSecurityAlertPolicyCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSecurityAlertPolicyCollection.cs index 83f144e39ce40..3336b88fdd124 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSecurityAlertPolicyCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSecurityAlertPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseSqlPoolSecurityAlertPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetASecurityAlertOfASQLAnalyticsPool() + public async Task CreateOrUpdate_UpdateASqlPoolSThreatDetectionPolicyWithAllParameters() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolSecurityAlertPolicies_List.json - // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolSecurityAlertWithAllParameters.json + // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task GetAll_GetASecurityAlertOfASQLAnalyticsPool() // this example assumes you already have this SynapseSqlPoolResource created on azure // for more information of creating SynapseSqlPoolResource, please refer to the document of SynapseSqlPoolResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-6852"; - string workspaceName = "securityalert-2080"; + string resourceGroupName = "securityalert-4799"; + string workspaceName = "securityalert-6440"; string sqlPoolName = "testdb"; ResourceIdentifier synapseSqlPoolResourceId = SynapseSqlPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName); SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); @@ -40,25 +40,34 @@ public async Task GetAll_GetASecurityAlertOfASQLAnalyticsPool() // get the collection of this SynapseSqlPoolSecurityAlertPolicyResource SynapseSqlPoolSecurityAlertPolicyCollection collection = synapseSqlPool.GetSynapseSqlPoolSecurityAlertPolicies(); - // invoke the operation and iterate over the result - await foreach (SynapseSqlPoolSecurityAlertPolicyResource item in collection.GetAllAsync()) + // invoke the operation + SqlPoolSecurityAlertPolicyName securityAlertPolicyName = SqlPoolSecurityAlertPolicyName.Default; + SynapseSqlPoolSecurityAlertPolicyData data = new SynapseSqlPoolSecurityAlertPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolSecurityAlertPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + State = SynapseSecurityAlertPolicyState.Enabled, + DisabledAlerts = { "Sql_Injection", "Usage_Anomaly" }, + EmailAddresses = { "test@microsoft.com", "user@microsoft.com" }, + EnableEmailToAccountAdmins = true, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + RetentionDays = 6, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + SynapseSqlPoolSecurityAlertPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASecurityAlertOfASQLAnalyticsPool() + public async Task CreateOrUpdate_UpdateASqlPoolSThreatDetectionPolicyWithMinimalParameters() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolSecurityAlert.json - // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolSecurityAlertWithMinParameters.json + // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,8 +77,8 @@ public async Task Get_GetASecurityAlertOfASQLAnalyticsPool() // this example assumes you already have this SynapseSqlPoolResource created on azure // for more information of creating SynapseSqlPoolResource, please refer to the document of SynapseSqlPoolResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-6852"; - string workspaceName = "securityalert-2080"; + string resourceGroupName = "securityalert-4799"; + string workspaceName = "securityalert-6440"; string sqlPoolName = "testdb"; ResourceIdentifier synapseSqlPoolResourceId = SynapseSqlPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName); SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); @@ -79,7 +88,12 @@ public async Task Get_GetASecurityAlertOfASQLAnalyticsPool() // invoke the operation SqlPoolSecurityAlertPolicyName securityAlertPolicyName = SqlPoolSecurityAlertPolicyName.Default; - SynapseSqlPoolSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); + SynapseSqlPoolSecurityAlertPolicyData data = new SynapseSqlPoolSecurityAlertPolicyData + { + State = SynapseSecurityAlertPolicyState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + SynapseSqlPoolSecurityAlertPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,7 +104,7 @@ public async Task Get_GetASecurityAlertOfASQLAnalyticsPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASecurityAlertOfASQLAnalyticsPool() + public async Task Get_GetASecurityAlertOfASQLAnalyticsPool() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolSecurityAlert.json // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -114,17 +128,21 @@ public async Task Exists_GetASecurityAlertOfASQLAnalyticsPool() // invoke the operation SqlPoolSecurityAlertPolicyName securityAlertPolicyName = SqlPoolSecurityAlertPolicyName.Default; - bool result = await collection.ExistsAsync(securityAlertPolicyName); + SynapseSqlPoolSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASecurityAlertOfASQLAnalyticsPool() + public async Task GetAll_GetASecurityAlertOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolSecurityAlert.json - // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolSecurityAlertPolicies_List.json + // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +161,25 @@ public async Task GetIfExists_GetASecurityAlertOfASQLAnalyticsPool() // get the collection of this SynapseSqlPoolSecurityAlertPolicyResource SynapseSqlPoolSecurityAlertPolicyCollection collection = synapseSqlPool.GetSynapseSqlPoolSecurityAlertPolicies(); - // invoke the operation - SqlPoolSecurityAlertPolicyName securityAlertPolicyName = SqlPoolSecurityAlertPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); - SynapseSqlPoolSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SynapseSqlPoolSecurityAlertPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseSqlPoolSecurityAlertPolicyData resourceData = result.Data; + SynapseSqlPoolSecurityAlertPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateASqlPoolSThreatDetectionPolicyWithAllParameters() + public async Task Exists_GetASecurityAlertOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolSecurityAlertWithAllParameters.json - // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolSecurityAlert.json + // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,8 +189,8 @@ public async Task CreateOrUpdate_UpdateASqlPoolSThreatDetectionPolicyWithAllPara // this example assumes you already have this SynapseSqlPoolResource created on azure // for more information of creating SynapseSqlPoolResource, please refer to the document of SynapseSqlPoolResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string workspaceName = "securityalert-6440"; + string resourceGroupName = "securityalert-6852"; + string workspaceName = "securityalert-2080"; string sqlPoolName = "testdb"; ResourceIdentifier synapseSqlPoolResourceId = SynapseSqlPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName); SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); @@ -188,38 +200,17 @@ public async Task CreateOrUpdate_UpdateASqlPoolSThreatDetectionPolicyWithAllPara // invoke the operation SqlPoolSecurityAlertPolicyName securityAlertPolicyName = SqlPoolSecurityAlertPolicyName.Default; - SynapseSqlPoolSecurityAlertPolicyData data = new SynapseSqlPoolSecurityAlertPolicyData() - { - State = SynapseSecurityAlertPolicyState.Enabled, - DisabledAlerts = -{ -"Sql_Injection","Usage_Anomaly" -}, - EmailAddresses = -{ -"test@microsoft.com","user@microsoft.com" -}, - EnableEmailToAccountAdmins = true, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - RetentionDays = 6, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - SynapseSqlPoolSecurityAlertPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(securityAlertPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateASqlPoolSThreatDetectionPolicyWithMinimalParameters() + public async Task GetIfExists_GetASecurityAlertOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolSecurityAlertWithMinParameters.json - // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolSecurityAlert.json + // this example is just showing the usage of "SqlPoolSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -229,8 +220,8 @@ public async Task CreateOrUpdate_UpdateASqlPoolSThreatDetectionPolicyWithMinimal // this example assumes you already have this SynapseSqlPoolResource created on azure // for more information of creating SynapseSqlPoolResource, please refer to the document of SynapseSqlPoolResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string workspaceName = "securityalert-6440"; + string resourceGroupName = "securityalert-6852"; + string workspaceName = "securityalert-2080"; string sqlPoolName = "testdb"; ResourceIdentifier synapseSqlPoolResourceId = SynapseSqlPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName); SynapseSqlPoolResource synapseSqlPool = client.GetSynapseSqlPoolResource(synapseSqlPoolResourceId); @@ -240,18 +231,21 @@ public async Task CreateOrUpdate_UpdateASqlPoolSThreatDetectionPolicyWithMinimal // invoke the operation SqlPoolSecurityAlertPolicyName securityAlertPolicyName = SqlPoolSecurityAlertPolicyName.Default; - SynapseSqlPoolSecurityAlertPolicyData data = new SynapseSqlPoolSecurityAlertPolicyData() - { - State = SynapseSecurityAlertPolicyState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - SynapseSqlPoolSecurityAlertPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); + SynapseSqlPoolSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSecurityAlertPolicyResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSecurityAlertPolicyResource.cs index 6eff29b56d90a..6a7563f7a804d 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSecurityAlertPolicyResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolSecurityAlertPolicyResource.cs @@ -71,17 +71,11 @@ public async Task Update_UpdateASqlPoolSThreatDetectionPolicyWithAllParameters() SynapseSqlPoolSecurityAlertPolicyResource synapseSqlPoolSecurityAlertPolicy = client.GetSynapseSqlPoolSecurityAlertPolicyResource(synapseSqlPoolSecurityAlertPolicyResourceId); // invoke the operation - SynapseSqlPoolSecurityAlertPolicyData data = new SynapseSqlPoolSecurityAlertPolicyData() + SynapseSqlPoolSecurityAlertPolicyData data = new SynapseSqlPoolSecurityAlertPolicyData { State = SynapseSecurityAlertPolicyState.Enabled, - DisabledAlerts = -{ -"Sql_Injection","Usage_Anomaly" -}, - EmailAddresses = -{ -"test@microsoft.com","user@microsoft.com" -}, + DisabledAlerts = { "Sql_Injection", "Usage_Anomaly" }, + EmailAddresses = { "test@microsoft.com", "user@microsoft.com" }, EnableEmailToAccountAdmins = true, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", @@ -120,7 +114,7 @@ public async Task Update_UpdateASqlPoolSThreatDetectionPolicyWithMinimalParamete SynapseSqlPoolSecurityAlertPolicyResource synapseSqlPoolSecurityAlertPolicy = client.GetSynapseSqlPoolSecurityAlertPolicyResource(synapseSqlPoolSecurityAlertPolicyResourceId); // invoke the operation - SynapseSqlPoolSecurityAlertPolicyData data = new SynapseSqlPoolSecurityAlertPolicyData() + SynapseSqlPoolSecurityAlertPolicyData data = new SynapseSqlPoolSecurityAlertPolicyData { State = SynapseSecurityAlertPolicyState.Enabled, }; diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolTableCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolTableCollection.cs index 6f835d70ae5fa..339e4ecf439e4 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolTableCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolTableCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseSqlPoolTableCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheTablesOfAGivenSchemaInASQLAnalyticsPool() + public async Task Get_GetDatabaseTable() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolTables.json - // this example is just showing the usage of "SqlPoolTables_ListBySchema" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolTableGet.json + // this example is just showing the usage of "SqlPoolTables_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListTheTablesOfAGivenSchemaInASQLAnalyticsPool() // get the collection of this SynapseSqlPoolTableResource SynapseSqlPoolTableCollection collection = synapseSqlPoolSchema.GetSynapseSqlPoolTables(); - // invoke the operation and iterate over the result - await foreach (SynapseSqlPoolTableResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolTableData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string tableName = "table1"; + SynapseSqlPoolTableResource result = await collection.GetAsync(tableName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatabaseTable() + public async Task GetAll_ListTheTablesOfAGivenSchemaInASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolTableGet.json - // this example is just showing the usage of "SqlPoolTables_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolTables.json + // this example is just showing the usage of "SqlPoolTables_ListBySchema" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetDatabaseTable() // get the collection of this SynapseSqlPoolTableResource SynapseSqlPoolTableCollection collection = synapseSqlPoolSchema.GetSynapseSqlPoolTables(); - // invoke the operation - string tableName = "table1"; - SynapseSqlPoolTableResource result = await collection.GetAsync(tableName); + // invoke the operation and iterate over the result + await foreach (SynapseSqlPoolTableResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolTableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentCollection.cs index 9dff246a257c0..d9e01ed927347 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseSqlPoolVulnerabilityAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAVulnerabilityAssessmentOfASQLAnalyticsPool() + public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithAllParameters() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolVulnerabilityAssessments.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolVulnerabilityAssessmentWithAllParameters.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,36 @@ public async Task GetAll_GetAVulnerabilityAssessmentOfASQLAnalyticsPool() // get the collection of this SynapseSqlPoolVulnerabilityAssessmentResource SynapseSqlPoolVulnerabilityAssessmentCollection collection = synapseSqlPool.GetSynapseSqlPoolVulnerabilityAssessments(); - // invoke the operation and iterate over the result - await foreach (SynapseSqlPoolVulnerabilityAssessmentResource item in collection.GetAllAsync()) + // invoke the operation + SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; + SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolVulnerabilityAssessmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + RecurringScans = new SynapseVulnerabilityAssessmentRecurringScansProperties + { + IsEnabled = true, + EnableEmailToAccountAdmins = true, + Emails = { "email1@mail.com", "email2@mail.com" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SynapseSqlPoolVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASqlPoolSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMinimalParametersWhenStorageAccountAccessKeyIsSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolVulnerabilityAssessment.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateVulnerabilityAssessmentWithStorageAccessKeyAndMinParameters.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,7 +90,13 @@ public async Task Get_GetASqlPoolSVulnerabilityAssessment() // invoke the operation SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - SynapseSqlPoolVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); + SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SynapseSqlPoolVulnerabilityAssessmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,10 +107,10 @@ public async Task Get_GetASqlPoolSVulnerabilityAssessment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASqlPoolSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMinimalParametersWhenStorageContainerSasKeyIsSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolVulnerabilityAssessment.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolVulnerabilityAssessmentWithContainerSasKeyAndMinParameters.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,14 +131,24 @@ public async Task Exists_GetASqlPoolSVulnerabilityAssessment() // invoke the operation SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); + SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SynapseSqlPoolVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASqlPoolSVulnerabilityAssessment() + public async Task Get_GetASqlPoolSVulnerabilityAssessment() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolVulnerabilityAssessment.json // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +172,21 @@ public async Task GetIfExists_GetASqlPoolSVulnerabilityAssessment() // invoke the operation SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); - SynapseSqlPoolVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; + SynapseSqlPoolVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithAllParameters() + public async Task GetAll_GetAVulnerabilityAssessmentOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolVulnerabilityAssessmentWithAllParameters.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolVulnerabilityAssessments.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,39 +205,25 @@ public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithAllP // get the collection of this SynapseSqlPoolVulnerabilityAssessmentResource SynapseSqlPoolVulnerabilityAssessmentCollection collection = synapseSqlPool.GetSynapseSqlPoolVulnerabilityAssessments(); - // invoke the operation - SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData() + // invoke the operation and iterate over the result + await foreach (SynapseSqlPoolVulnerabilityAssessmentResource item in collection.GetAllAsync()) { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new SynapseVulnerabilityAssessmentRecurringScansProperties() - { - IsEnabled = true, - EnableEmailToAccountAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SynapseSqlPoolVulnerabilityAssessmentResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolVulnerabilityAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMinimalParametersWhenStorageAccountAccessKeyIsSpecified() + public async Task Exists_GetASqlPoolSVulnerabilityAssessment() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateVulnerabilityAssessmentWithStorageAccessKeyAndMinParameters.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolVulnerabilityAssessment.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -239,27 +244,17 @@ public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMini // invoke the operation SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SynapseSqlPoolVulnerabilityAssessmentResource result = lro.Value; + bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMinimalParametersWhenStorageContainerSasKeyIsSpecified() + public async Task GetIfExists_GetASqlPoolSVulnerabilityAssessment() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolVulnerabilityAssessmentWithContainerSasKeyAndMinParameters.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolVulnerabilityAssessment.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -280,19 +275,21 @@ public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMini // invoke the operation SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SynapseSqlPoolVulnerabilityAssessmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); + SynapseSqlPoolVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseSqlPoolVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseSqlPoolVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentResource.cs index cb2c57ef2f15e..b905aa8a454e8 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentResource.cs @@ -48,6 +48,34 @@ public async Task Get_GetASqlPoolSVulnerabilityAssessment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_RemoveADatabaseSVulnerabilityAssessment() + { + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolVulnerabilityAssessment.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SynapseSqlPoolVulnerabilityAssessmentResource created on azure + // for more information of creating SynapseSqlPoolVulnerabilityAssessmentResource, please refer to the document of SynapseSqlPoolVulnerabilityAssessmentResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string workspaceName = "vulnerabilityaseessmenttest-6440"; + string sqlPoolName = "testdb"; + SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; + ResourceIdentifier synapseSqlPoolVulnerabilityAssessmentResourceId = SynapseSqlPoolVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName); + SynapseSqlPoolVulnerabilityAssessmentResource synapseSqlPoolVulnerabilityAssessment = client.GetSynapseSqlPoolVulnerabilityAssessmentResource(synapseSqlPoolVulnerabilityAssessmentResourceId); + + // invoke the operation + await synapseSqlPoolVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithAllParameters() @@ -71,19 +99,16 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithAllParameter SynapseSqlPoolVulnerabilityAssessmentResource synapseSqlPoolVulnerabilityAssessment = client.GetSynapseSqlPoolVulnerabilityAssessmentResource(synapseSqlPoolVulnerabilityAssessmentResourceId); // invoke the operation - SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData() + SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new SynapseVulnerabilityAssessmentRecurringScansProperties() + RecurringScans = new SynapseVulnerabilityAssessmentRecurringScansProperties { IsEnabled = true, EnableEmailToAccountAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, + Emails = { "email1@mail.com", "email2@mail.com" }, }, }; ArmOperation lro = await synapseSqlPoolVulnerabilityAssessment.UpdateAsync(WaitUntil.Completed, data); @@ -119,7 +144,7 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithMinimalParam SynapseSqlPoolVulnerabilityAssessmentResource synapseSqlPoolVulnerabilityAssessment = client.GetSynapseSqlPoolVulnerabilityAssessmentResource(synapseSqlPoolVulnerabilityAssessmentResourceId); // invoke the operation - SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData() + SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -157,7 +182,7 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithMinimalParam SynapseSqlPoolVulnerabilityAssessmentResource synapseSqlPoolVulnerabilityAssessment = client.GetSynapseSqlPoolVulnerabilityAssessmentResource(synapseSqlPoolVulnerabilityAssessmentResourceId); // invoke the operation - SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData() + SynapseSqlPoolVulnerabilityAssessmentData data = new SynapseSqlPoolVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -171,33 +196,5 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithMinimalParam // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_RemoveADatabaseSVulnerabilityAssessment() - { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolVulnerabilityAssessment.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SynapseSqlPoolVulnerabilityAssessmentResource created on azure - // for more information of creating SynapseSqlPoolVulnerabilityAssessmentResource, please refer to the document of SynapseSqlPoolVulnerabilityAssessmentResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string workspaceName = "vulnerabilityaseessmenttest-6440"; - string sqlPoolName = "testdb"; - SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - ResourceIdentifier synapseSqlPoolVulnerabilityAssessmentResourceId = SynapseSqlPoolVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName); - SynapseSqlPoolVulnerabilityAssessmentResource synapseSqlPoolVulnerabilityAssessment = client.GetSynapseSqlPoolVulnerabilityAssessmentResource(synapseSqlPoolVulnerabilityAssessmentResourceId); - - // invoke the operation - await synapseSqlPoolVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentRuleBaselineCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentRuleBaselineCollection.cs index 836012f873399..4bfbb70d217c0 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentRuleBaselineCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentRuleBaselineCollection.cs @@ -44,21 +44,9 @@ public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessme // invoke the operation string ruleId = "VA1001"; SynapseVulnerabilityAssessmentPolicyBaselineName baselineName = SynapseVulnerabilityAssessmentPolicyBaselineName.Default; - SynapseSqlPoolVulnerabilityAssessmentRuleBaselineData data = new SynapseSqlPoolVulnerabilityAssessmentRuleBaselineData() + SynapseSqlPoolVulnerabilityAssessmentRuleBaselineData data = new SynapseSqlPoolVulnerabilityAssessmentRuleBaselineData { - BaselineResults = -{ -new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userA","SELECT" -}),new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userB","SELECT" -}),new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userC","SELECT","tableId_4" -}) -}, + BaselineResults = { new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] { "userA", "SELECT" }), new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] { "userB", "SELECT" }), new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] { "userC", "SELECT", "tableId_4" }) }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, baselineName, data); SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource result = lro.Value; diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource.cs index 30610e88a259c..fe002788ad8f6 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseSqlPoolVulnerabilityAssessmentRuleBaselineRes { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Get_GetsASqlPoolSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolVulnerabilityAssessmentRuleBaseline.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolVulnerabilityAssessmentRuleBaselineGet.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,34 +31,17 @@ public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBa // this example assumes you already have this SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource created on azure // for more information of creating SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource, please refer to the document of SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string workspaceName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityaseessmenttest-4711"; + string workspaceName = "vulnerabilityaseessmenttest-6411"; string sqlPoolName = "testdb"; SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; string ruleId = "VA1001"; - SynapseVulnerabilityAssessmentPolicyBaselineName baselineName = SynapseVulnerabilityAssessmentPolicyBaselineName.Default; + SynapseVulnerabilityAssessmentPolicyBaselineName baselineName = SynapseVulnerabilityAssessmentPolicyBaselineName.Master; ResourceIdentifier synapseSqlPoolVulnerabilityAssessmentRuleBaselineResourceId = SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, ruleId, baselineName); SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource synapseSqlPoolVulnerabilityAssessmentRuleBaseline = client.GetSynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource(synapseSqlPoolVulnerabilityAssessmentRuleBaselineResourceId); // invoke the operation - SynapseSqlPoolVulnerabilityAssessmentRuleBaselineData data = new SynapseSqlPoolVulnerabilityAssessmentRuleBaselineData() - { - BaselineResults = -{ -new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userA","SELECT" -}),new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userB","SELECT" -}),new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userC","SELECT","tableId_4" -}) -}, - }; - ArmOperation lro = await synapseSqlPoolVulnerabilityAssessmentRuleBaseline.UpdateAsync(WaitUntil.Completed, data); - SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource result = lro.Value; + SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource result = await synapseSqlPoolVulnerabilityAssessmentRuleBaseline.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -99,10 +82,10 @@ public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsASqlPoolSVulnerabilityAssessmentRuleBaseline() + public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolVulnerabilityAssessmentRuleBaselineGet.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolVulnerabilityAssessmentRuleBaseline.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,17 +95,22 @@ public async Task Get_GetsASqlPoolSVulnerabilityAssessmentRuleBaseline() // this example assumes you already have this SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource created on azure // for more information of creating SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource, please refer to the document of SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4711"; - string workspaceName = "vulnerabilityaseessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string workspaceName = "vulnerabilityaseessmenttest-6440"; string sqlPoolName = "testdb"; SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; string ruleId = "VA1001"; - SynapseVulnerabilityAssessmentPolicyBaselineName baselineName = SynapseVulnerabilityAssessmentPolicyBaselineName.Master; + SynapseVulnerabilityAssessmentPolicyBaselineName baselineName = SynapseVulnerabilityAssessmentPolicyBaselineName.Default; ResourceIdentifier synapseSqlPoolVulnerabilityAssessmentRuleBaselineResourceId = SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, ruleId, baselineName); SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource synapseSqlPoolVulnerabilityAssessmentRuleBaseline = client.GetSynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource(synapseSqlPoolVulnerabilityAssessmentRuleBaselineResourceId); // invoke the operation - SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource result = await synapseSqlPoolVulnerabilityAssessmentRuleBaseline.GetAsync(); + SynapseSqlPoolVulnerabilityAssessmentRuleBaselineData data = new SynapseSqlPoolVulnerabilityAssessmentRuleBaselineData + { + BaselineResults = { new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] { "userA", "SELECT" }), new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] { "userB", "SELECT" }), new SqlPoolVulnerabilityAssessmentRuleBaselineItem(new string[] { "userC", "SELECT", "tableId_4" }) }, + }; + ArmOperation lro = await synapseSqlPoolVulnerabilityAssessmentRuleBaseline.UpdateAsync(WaitUntil.Completed, data); + SynapseSqlPoolVulnerabilityAssessmentRuleBaselineResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseTransparentDataEncryptionCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseTransparentDataEncryptionCollection.cs index e60505e0c5c00..16f23ab60319d 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseTransparentDataEncryptionCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseTransparentDataEncryptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseTransparentDataEncryptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTransparentDataEncryptionConfigurationOfASQLAnalyticsPool() + public async Task CreateOrUpdate_CreateOrUpdateASqlPoolSTransparentDataEncryptionConfiguration() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolTransparentDataEncryption.json - // this example is just showing the usage of "SqlPoolTransparentDataEncryptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolTransparentDataEncryption.json + // this example is just showing the usage of "SqlPoolTransparentDataEncryptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,12 @@ public async Task Get_GetTransparentDataEncryptionConfigurationOfASQLAnalyticsPo // invoke the operation SynapseTransparentDataEncryptionName transparentDataEncryptionName = SynapseTransparentDataEncryptionName.Current; - SynapseTransparentDataEncryptionResource result = await collection.GetAsync(transparentDataEncryptionName); + SynapseTransparentDataEncryptionData data = new SynapseTransparentDataEncryptionData + { + Status = SynapseTransparentDataEncryptionStatus.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, transparentDataEncryptionName, data); + SynapseTransparentDataEncryptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +58,7 @@ public async Task Get_GetTransparentDataEncryptionConfigurationOfASQLAnalyticsPo [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTransparentDataEncryptionConfigurationOfASQLAnalyticsPool() + public async Task Get_GetTransparentDataEncryptionConfigurationOfASQLAnalyticsPool() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolTransparentDataEncryption.json // this example is just showing the usage of "SqlPoolTransparentDataEncryptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +82,21 @@ public async Task Exists_GetTransparentDataEncryptionConfigurationOfASQLAnalytic // invoke the operation SynapseTransparentDataEncryptionName transparentDataEncryptionName = SynapseTransparentDataEncryptionName.Current; - bool result = await collection.ExistsAsync(transparentDataEncryptionName); + SynapseTransparentDataEncryptionResource result = await collection.GetAsync(transparentDataEncryptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseTransparentDataEncryptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTransparentDataEncryptionConfigurationOfASQLAnalyticsPool() + public async Task GetAll_GetListOfTransparentDataEncryptionConfigurationsOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolTransparentDataEncryption.json - // this example is just showing the usage of "SqlPoolTransparentDataEncryptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolTransparentDataEncryptionList.json + // this example is just showing the usage of "SqlPoolTransparentDataEncryptions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +115,25 @@ public async Task GetIfExists_GetTransparentDataEncryptionConfigurationOfASQLAna // get the collection of this SynapseTransparentDataEncryptionResource SynapseTransparentDataEncryptionCollection collection = synapseSqlPool.GetSynapseTransparentDataEncryptions(); - // invoke the operation - SynapseTransparentDataEncryptionName transparentDataEncryptionName = SynapseTransparentDataEncryptionName.Current; - NullableResponse response = await collection.GetIfExistsAsync(transparentDataEncryptionName); - SynapseTransparentDataEncryptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SynapseTransparentDataEncryptionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseTransparentDataEncryptionData resourceData = result.Data; + SynapseTransparentDataEncryptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateASqlPoolSTransparentDataEncryptionConfiguration() + public async Task Exists_GetTransparentDataEncryptionConfigurationOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolTransparentDataEncryption.json - // this example is just showing the usage of "SqlPoolTransparentDataEncryptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolTransparentDataEncryption.json + // this example is just showing the usage of "SqlPoolTransparentDataEncryptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,26 +154,17 @@ public async Task CreateOrUpdate_CreateOrUpdateASqlPoolSTransparentDataEncryptio // invoke the operation SynapseTransparentDataEncryptionName transparentDataEncryptionName = SynapseTransparentDataEncryptionName.Current; - SynapseTransparentDataEncryptionData data = new SynapseTransparentDataEncryptionData() - { - Status = SynapseTransparentDataEncryptionStatus.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, transparentDataEncryptionName, data); - SynapseTransparentDataEncryptionResource result = lro.Value; + bool result = await collection.ExistsAsync(transparentDataEncryptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseTransparentDataEncryptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetListOfTransparentDataEncryptionConfigurationsOfASQLAnalyticsPool() + public async Task GetIfExists_GetTransparentDataEncryptionConfigurationOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolTransparentDataEncryptionList.json - // this example is just showing the usage of "SqlPoolTransparentDataEncryptions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolTransparentDataEncryption.json + // this example is just showing the usage of "SqlPoolTransparentDataEncryptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_GetListOfTransparentDataEncryptionConfigurationsOfASQLA // get the collection of this SynapseTransparentDataEncryptionResource SynapseTransparentDataEncryptionCollection collection = synapseSqlPool.GetSynapseTransparentDataEncryptions(); - // invoke the operation and iterate over the result - await foreach (SynapseTransparentDataEncryptionResource item in collection.GetAllAsync()) + // invoke the operation + SynapseTransparentDataEncryptionName transparentDataEncryptionName = SynapseTransparentDataEncryptionName.Current; + NullableResponse response = await collection.GetIfExistsAsync(transparentDataEncryptionName); + SynapseTransparentDataEncryptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseTransparentDataEncryptionData resourceData = item.Data; + SynapseTransparentDataEncryptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseTransparentDataEncryptionResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseTransparentDataEncryptionResource.cs index c17aaa301c462..fe96a7eb47f37 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseTransparentDataEncryptionResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseTransparentDataEncryptionResource.cs @@ -71,7 +71,7 @@ public async Task Update_CreateOrUpdateASqlPoolSTransparentDataEncryptionConfigu SynapseTransparentDataEncryptionResource synapseTransparentDataEncryption = client.GetSynapseTransparentDataEncryptionResource(synapseTransparentDataEncryptionResourceId); // invoke the operation - SynapseTransparentDataEncryptionData data = new SynapseTransparentDataEncryptionData() + SynapseTransparentDataEncryptionData data = new SynapseTransparentDataEncryptionData { Status = SynapseTransparentDataEncryptionStatus.Enabled, }; diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseVulnerabilityAssessmentScanRecordCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseVulnerabilityAssessmentScanRecordCollection.cs index f039a36ccee9c..dfd0d605177c9 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseVulnerabilityAssessmentScanRecordCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseVulnerabilityAssessmentScanRecordCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseVulnerabilityAssessmentScanRecordCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAVulnerabilityScanRecordOfASQLAnalyticsPool() + public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolVulnerabilityAssessmentScanRecords.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentScans_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolVulnerabilityAssessmentScanRecordsGet.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_GetAVulnerabilityScanRecordOfASQLAnalyticsPool() // get the collection of this SynapseVulnerabilityAssessmentScanRecordResource SynapseVulnerabilityAssessmentScanRecordCollection collection = synapseSqlPoolVulnerabilityAssessment.GetSynapseVulnerabilityAssessmentScanRecords(); - // invoke the operation and iterate over the result - await foreach (SynapseVulnerabilityAssessmentScanRecordResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseVulnerabilityAssessmentScanRecordData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scanId = "scan001"; + SynapseVulnerabilityAssessmentScanRecordResource result = await collection.GetAsync(scanId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseVulnerabilityAssessmentScanRecordData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() + public async Task GetAll_GetAVulnerabilityScanRecordOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolVulnerabilityAssessmentScanRecordsGet.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListSqlPoolVulnerabilityAssessmentScanRecords.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentScans_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +77,17 @@ public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() // get the collection of this SynapseVulnerabilityAssessmentScanRecordResource SynapseVulnerabilityAssessmentScanRecordCollection collection = synapseSqlPoolVulnerabilityAssessment.GetSynapseVulnerabilityAssessmentScanRecords(); - // invoke the operation - string scanId = "scan001"; - SynapseVulnerabilityAssessmentScanRecordResource result = await collection.GetAsync(scanId); + // invoke the operation and iterate over the result + await foreach (SynapseVulnerabilityAssessmentScanRecordResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseVulnerabilityAssessmentScanRecordData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseVulnerabilityAssessmentScanRecordData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseVulnerabilityAssessmentScanRecordResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseVulnerabilityAssessmentScanRecordResource.cs index 06ab39b7908d2..dda59c95f0e52 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseVulnerabilityAssessmentScanRecordResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseVulnerabilityAssessmentScanRecordResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SynapseVulnerabilityAssessmentScanRecordResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task InitiateScan_ExecutesASqlPoolSVulnerabilityAssessmentScan() + public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ExecuteSqlPoolVulnerabilityAssessmentScans.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentScans_InitiateScan" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolVulnerabilityAssessmentScanRecordsGet.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,22 +35,26 @@ public async Task InitiateScan_ExecutesASqlPoolSVulnerabilityAssessmentScan() string workspaceName = "vulnerabilityassessmenttest-6411"; string sqlPoolName = "testdb"; SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - string scanId = "scan01"; + string scanId = "scan001"; ResourceIdentifier synapseVulnerabilityAssessmentScanRecordResourceId = SynapseVulnerabilityAssessmentScanRecordResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, scanId); SynapseVulnerabilityAssessmentScanRecordResource synapseVulnerabilityAssessmentScanRecord = client.GetSynapseVulnerabilityAssessmentScanRecordResource(synapseVulnerabilityAssessmentScanRecordResourceId); // invoke the operation - await synapseVulnerabilityAssessmentScanRecord.InitiateScanAsync(WaitUntil.Completed); + SynapseVulnerabilityAssessmentScanRecordResource result = await synapseVulnerabilityAssessmentScanRecord.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseVulnerabilityAssessmentScanRecordData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Export_ExportADatabaseSVulnerabilityAssessmentScanResults() + public async Task InitiateScan_ExecutesASqlPoolSVulnerabilityAssessmentScan() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ExportSqlPoolVulnerabilityAssessmentScan.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentScans_Export" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ExecuteSqlPoolVulnerabilityAssessmentScans.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentScans_InitiateScan" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,26 +64,26 @@ public async Task Export_ExportADatabaseSVulnerabilityAssessmentScanResults() // this example assumes you already have this SynapseVulnerabilityAssessmentScanRecordResource created on azure // for more information of creating SynapseVulnerabilityAssessmentScanRecordResource, please refer to the document of SynapseVulnerabilityAssessmentScanRecordResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityassessmenttest-4799"; - string workspaceName = "vulnerabilityassessmenttest-6440"; + string resourceGroupName = "vulnerabilityassessmenttest-4711"; + string workspaceName = "vulnerabilityassessmenttest-6411"; string sqlPoolName = "testdb"; SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; - string scanId = "scan001"; + string scanId = "scan01"; ResourceIdentifier synapseVulnerabilityAssessmentScanRecordResourceId = SynapseVulnerabilityAssessmentScanRecordResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, vulnerabilityAssessmentName, scanId); SynapseVulnerabilityAssessmentScanRecordResource synapseVulnerabilityAssessmentScanRecord = client.GetSynapseVulnerabilityAssessmentScanRecordResource(synapseVulnerabilityAssessmentScanRecordResourceId); // invoke the operation - SqlPoolVulnerabilityAssessmentScansExport result = await synapseVulnerabilityAssessmentScanRecord.ExportAsync(); + await synapseVulnerabilityAssessmentScanRecord.InitiateScanAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() + public async Task Export_ExportADatabaseSVulnerabilityAssessmentScanResults() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/SqlPoolVulnerabilityAssessmentScanRecordsGet.json - // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ExportSqlPoolVulnerabilityAssessmentScan.json + // this example is just showing the usage of "SqlPoolVulnerabilityAssessmentScans_Export" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -89,8 +93,8 @@ public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() // this example assumes you already have this SynapseVulnerabilityAssessmentScanRecordResource created on azure // for more information of creating SynapseVulnerabilityAssessmentScanRecordResource, please refer to the document of SynapseVulnerabilityAssessmentScanRecordResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityassessmenttest-4711"; - string workspaceName = "vulnerabilityassessmenttest-6411"; + string resourceGroupName = "vulnerabilityassessmenttest-4799"; + string workspaceName = "vulnerabilityassessmenttest-6440"; string sqlPoolName = "testdb"; SynapseVulnerabilityAssessmentName vulnerabilityAssessmentName = SynapseVulnerabilityAssessmentName.Default; string scanId = "scan001"; @@ -98,13 +102,9 @@ public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() SynapseVulnerabilityAssessmentScanRecordResource synapseVulnerabilityAssessmentScanRecord = client.GetSynapseVulnerabilityAssessmentScanRecordResource(synapseVulnerabilityAssessmentScanRecordResourceId); // invoke the operation - SynapseVulnerabilityAssessmentScanRecordResource result = await synapseVulnerabilityAssessmentScanRecord.GetAsync(); + SqlPoolVulnerabilityAssessmentScansExport result = await synapseVulnerabilityAssessmentScanRecord.ExportAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseVulnerabilityAssessmentScanRecordData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadClassifierCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadClassifierCollection.cs index 3ba5887242567..c938566733e3d 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadClassifierCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadClassifierCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseWorkloadClassifierCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkloadGroup() + public async Task CreateOrUpdate_CreateAWorkloadClassifierWithAllPropertiesSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroupWorkloadClassifier.json - // this example is just showing the usage of "SqlPoolWorkloadClassifier_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadClassifierMax.json + // this example is just showing the usage of "SqlPoolWorkloadClassifier_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,8 +41,18 @@ public async Task Get_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkloadGroup() SynapseWorkloadClassifierCollection collection = synapseWorkloadGroup.GetSynapseWorkloadClassifiers(); // invoke the operation - string workloadClassifierName = "wlm_classifier"; - SynapseWorkloadClassifierResource result = await collection.GetAsync(workloadClassifierName); + string workloadClassifierName = "wlm_workloadclassifier"; + SynapseWorkloadClassifierData data = new SynapseWorkloadClassifierData + { + MemberName = "dbo", + Label = "test_label", + Context = "test_context", + StartTime = "12:00", + EndTime = "14:00", + Importance = "high", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadClassifierName, data); + SynapseWorkloadClassifierResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +63,10 @@ public async Task Get_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkloadGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkloadGroup() + public async Task CreateOrUpdate_CreateAWorkloadClassifierWithTheRequiredPropertiesSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroupWorkloadClassifier.json - // this example is just showing the usage of "SqlPoolWorkloadClassifier_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadClassifierMin.json + // this example is just showing the usage of "SqlPoolWorkloadClassifier_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +87,24 @@ public async Task Exists_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkloadGroup SynapseWorkloadClassifierCollection collection = synapseWorkloadGroup.GetSynapseWorkloadClassifiers(); // invoke the operation - string workloadClassifierName = "wlm_classifier"; - bool result = await collection.ExistsAsync(workloadClassifierName); + string workloadClassifierName = "wlm_workloadclassifier"; + SynapseWorkloadClassifierData data = new SynapseWorkloadClassifierData + { + MemberName = "dbo", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadClassifierName, data); + SynapseWorkloadClassifierResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkloadClassifierData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkloadGroup() + public async Task Get_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkloadGroup() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroupWorkloadClassifier.json // this example is just showing the usage of "SqlPoolWorkloadClassifier_Get" operation, for the dependent resources, they will have to be created separately. @@ -110,29 +129,21 @@ public async Task GetIfExists_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkload // invoke the operation string workloadClassifierName = "wlm_classifier"; - NullableResponse response = await collection.GetIfExistsAsync(workloadClassifierName); - SynapseWorkloadClassifierResource result = response.HasValue ? response.Value : null; + SynapseWorkloadClassifierResource result = await collection.GetAsync(workloadClassifierName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkloadClassifierData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkloadClassifierData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAWorkloadClassifierWithAllPropertiesSpecified() + public async Task GetAll_GetTheListOfWorkloadClassifiersOfASQLAnalyticsPoolSWorkloadGroup() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadClassifierMax.json - // this example is just showing the usage of "SqlPoolWorkloadClassifier_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroupWorkloadClassifierList.json + // this example is just showing the usage of "SqlPoolWorkloadClassifier_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -152,33 +163,25 @@ public async Task CreateOrUpdate_CreateAWorkloadClassifierWithAllPropertiesSpeci // get the collection of this SynapseWorkloadClassifierResource SynapseWorkloadClassifierCollection collection = synapseWorkloadGroup.GetSynapseWorkloadClassifiers(); - // invoke the operation - string workloadClassifierName = "wlm_workloadclassifier"; - SynapseWorkloadClassifierData data = new SynapseWorkloadClassifierData() + // invoke the operation and iterate over the result + await foreach (SynapseWorkloadClassifierResource item in collection.GetAllAsync()) { - MemberName = "dbo", - Label = "test_label", - Context = "test_context", - StartTime = "12:00", - EndTime = "14:00", - Importance = "high", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadClassifierName, data); - SynapseWorkloadClassifierResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkloadClassifierData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkloadClassifierData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAWorkloadClassifierWithTheRequiredPropertiesSpecified() + public async Task Exists_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkloadGroup() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadClassifierMin.json - // this example is just showing the usage of "SqlPoolWorkloadClassifier_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroupWorkloadClassifier.json + // this example is just showing the usage of "SqlPoolWorkloadClassifier_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,27 +202,18 @@ public async Task CreateOrUpdate_CreateAWorkloadClassifierWithTheRequiredPropert SynapseWorkloadClassifierCollection collection = synapseWorkloadGroup.GetSynapseWorkloadClassifiers(); // invoke the operation - string workloadClassifierName = "wlm_workloadclassifier"; - SynapseWorkloadClassifierData data = new SynapseWorkloadClassifierData() - { - MemberName = "dbo", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadClassifierName, data); - SynapseWorkloadClassifierResource result = lro.Value; + string workloadClassifierName = "wlm_classifier"; + bool result = await collection.ExistsAsync(workloadClassifierName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkloadClassifierData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheListOfWorkloadClassifiersOfASQLAnalyticsPoolSWorkloadGroup() + public async Task GetIfExists_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkloadGroup() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroupWorkloadClassifierList.json - // this example is just showing the usage of "SqlPoolWorkloadClassifier_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroupWorkloadClassifier.json + // this example is just showing the usage of "SqlPoolWorkloadClassifier_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -239,17 +233,23 @@ public async Task GetAll_GetTheListOfWorkloadClassifiersOfASQLAnalyticsPoolSWork // get the collection of this SynapseWorkloadClassifierResource SynapseWorkloadClassifierCollection collection = synapseWorkloadGroup.GetSynapseWorkloadClassifiers(); - // invoke the operation and iterate over the result - await foreach (SynapseWorkloadClassifierResource item in collection.GetAllAsync()) + // invoke the operation + string workloadClassifierName = "wlm_classifier"; + NullableResponse response = await collection.GetIfExistsAsync(workloadClassifierName); + SynapseWorkloadClassifierResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseWorkloadClassifierData resourceData = item.Data; + SynapseWorkloadClassifierData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadClassifierResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadClassifierResource.cs index 7191d2943d208..511eaf9e37ea4 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadClassifierResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadClassifierResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetAWorkloadClassifierForSQLAnalyticsPoolSWorkloadGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAWorkloadClassifierWithAllPropertiesSpecified() + public async Task Delete_DeleteAWorkloadClassifierOfASQLAnalyticsPoolSWorkloadGroup() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadClassifierMax.json - // this example is just showing the usage of "SqlPoolWorkloadClassifier_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolWorkloadGroupWorkloadClassifer.json + // this example is just showing the usage of "SqlPoolWorkloadClassifier_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,30 +72,16 @@ public async Task Update_CreateAWorkloadClassifierWithAllPropertiesSpecified() SynapseWorkloadClassifierResource synapseWorkloadClassifier = client.GetSynapseWorkloadClassifierResource(synapseWorkloadClassifierResourceId); // invoke the operation - SynapseWorkloadClassifierData data = new SynapseWorkloadClassifierData() - { - MemberName = "dbo", - Label = "test_label", - Context = "test_context", - StartTime = "12:00", - EndTime = "14:00", - Importance = "high", - }; - ArmOperation lro = await synapseWorkloadClassifier.UpdateAsync(WaitUntil.Completed, data); - SynapseWorkloadClassifierResource result = lro.Value; + await synapseWorkloadClassifier.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkloadClassifierData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAWorkloadClassifierWithTheRequiredPropertiesSpecified() + public async Task Update_CreateAWorkloadClassifierWithAllPropertiesSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadClassifierMin.json + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadClassifierMax.json // this example is just showing the usage of "SqlPoolWorkloadClassifier_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -115,9 +101,14 @@ public async Task Update_CreateAWorkloadClassifierWithTheRequiredPropertiesSpeci SynapseWorkloadClassifierResource synapseWorkloadClassifier = client.GetSynapseWorkloadClassifierResource(synapseWorkloadClassifierResourceId); // invoke the operation - SynapseWorkloadClassifierData data = new SynapseWorkloadClassifierData() + SynapseWorkloadClassifierData data = new SynapseWorkloadClassifierData { MemberName = "dbo", + Label = "test_label", + Context = "test_context", + StartTime = "12:00", + EndTime = "14:00", + Importance = "high", }; ArmOperation lro = await synapseWorkloadClassifier.UpdateAsync(WaitUntil.Completed, data); SynapseWorkloadClassifierResource result = lro.Value; @@ -131,10 +122,10 @@ public async Task Update_CreateAWorkloadClassifierWithTheRequiredPropertiesSpeci [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAWorkloadClassifierOfASQLAnalyticsPoolSWorkloadGroup() + public async Task Update_CreateAWorkloadClassifierWithTheRequiredPropertiesSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolWorkloadGroupWorkloadClassifer.json - // this example is just showing the usage of "SqlPoolWorkloadClassifier_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadClassifierMin.json + // this example is just showing the usage of "SqlPoolWorkloadClassifier_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -153,9 +144,18 @@ public async Task Delete_DeleteAWorkloadClassifierOfASQLAnalyticsPoolSWorkloadGr SynapseWorkloadClassifierResource synapseWorkloadClassifier = client.GetSynapseWorkloadClassifierResource(synapseWorkloadClassifierResourceId); // invoke the operation - await synapseWorkloadClassifier.DeleteAsync(WaitUntil.Completed); + SynapseWorkloadClassifierData data = new SynapseWorkloadClassifierData + { + MemberName = "dbo", + }; + ArmOperation lro = await synapseWorkloadClassifier.UpdateAsync(WaitUntil.Completed, data); + SynapseWorkloadClassifierResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkloadClassifierData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadGroupCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadGroupCollection.cs index 7ba2eb3f9b1b9..d93326e27e4de 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadGroupCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadGroupCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseWorkloadGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAAWorkloadGroupOfASQLAnalyticsPool() + public async Task CreateOrUpdate_CreateAWorkloadGroupWithAllPropertiesSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroup.json - // this example is just showing the usage of "SqlPoolWorkloadGroup_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadGroupMax.json + // this example is just showing the usage of "SqlPoolWorkloadGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_GetAAWorkloadGroupOfASQLAnalyticsPool() // invoke the operation string workloadGroupName = "smallrc"; - SynapseWorkloadGroupResource result = await collection.GetAsync(workloadGroupName); + SynapseWorkloadGroupData data = new SynapseWorkloadGroupData + { + MinResourcePercent = 0, + MaxResourcePercent = 100, + MinResourcePercentPerRequest = 3, + MaxResourcePercentPerRequest = 3, + Importance = "normal", + QueryExecutionTimeout = 0, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadGroupName, data); + SynapseWorkloadGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +62,10 @@ public async Task Get_GetAAWorkloadGroupOfASQLAnalyticsPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAAWorkloadGroupOfASQLAnalyticsPool() + public async Task CreateOrUpdate_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroup.json - // this example is just showing the usage of "SqlPoolWorkloadGroup_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadGroupMin.json + // this example is just showing the usage of "SqlPoolWorkloadGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,14 +86,25 @@ public async Task Exists_GetAAWorkloadGroupOfASQLAnalyticsPool() // invoke the operation string workloadGroupName = "smallrc"; - bool result = await collection.ExistsAsync(workloadGroupName); + SynapseWorkloadGroupData data = new SynapseWorkloadGroupData + { + MinResourcePercent = 0, + MaxResourcePercent = 100, + MinResourcePercentPerRequest = 3, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadGroupName, data); + SynapseWorkloadGroupResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkloadGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAAWorkloadGroupOfASQLAnalyticsPool() + public async Task Get_GetAAWorkloadGroupOfASQLAnalyticsPool() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroup.json // this example is just showing the usage of "SqlPoolWorkloadGroup_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +128,21 @@ public async Task GetIfExists_GetAAWorkloadGroupOfASQLAnalyticsPool() // invoke the operation string workloadGroupName = "smallrc"; - NullableResponse response = await collection.GetIfExistsAsync(workloadGroupName); - SynapseWorkloadGroupResource result = response.HasValue ? response.Value : null; + SynapseWorkloadGroupResource result = await collection.GetAsync(workloadGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkloadGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkloadGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAWorkloadGroupWithAllPropertiesSpecified() + public async Task GetAll_GetTheListOfWorkloadGroupsOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadGroupMax.json - // this example is just showing the usage of "SqlPoolWorkloadGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroupList.json + // this example is just showing the usage of "SqlPoolWorkloadGroup_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,33 +161,25 @@ public async Task CreateOrUpdate_CreateAWorkloadGroupWithAllPropertiesSpecified( // get the collection of this SynapseWorkloadGroupResource SynapseWorkloadGroupCollection collection = synapseSqlPool.GetSynapseWorkloadGroups(); - // invoke the operation - string workloadGroupName = "smallrc"; - SynapseWorkloadGroupData data = new SynapseWorkloadGroupData() + // invoke the operation and iterate over the result + await foreach (SynapseWorkloadGroupResource item in collection.GetAllAsync()) { - MinResourcePercent = 0, - MaxResourcePercent = 100, - MinResourcePercentPerRequest = 3, - MaxResourcePercentPerRequest = 3, - Importance = "normal", - QueryExecutionTimeout = 0, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadGroupName, data); - SynapseWorkloadGroupResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkloadGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkloadGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() + public async Task Exists_GetAAWorkloadGroupOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadGroupMin.json - // this example is just showing the usage of "SqlPoolWorkloadGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroup.json + // this example is just showing the usage of "SqlPoolWorkloadGroup_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,28 +200,17 @@ public async Task CreateOrUpdate_CreateAWorkloadGroupWithTheRequiredPropertiesSp // invoke the operation string workloadGroupName = "smallrc"; - SynapseWorkloadGroupData data = new SynapseWorkloadGroupData() - { - MinResourcePercent = 0, - MaxResourcePercent = 100, - MinResourcePercentPerRequest = 3, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadGroupName, data); - SynapseWorkloadGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(workloadGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkloadGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheListOfWorkloadGroupsOfASQLAnalyticsPool() + public async Task GetIfExists_GetAAWorkloadGroupOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroupList.json - // this example is just showing the usage of "SqlPoolWorkloadGroup_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetSqlPoolWorkloadGroup.json + // this example is just showing the usage of "SqlPoolWorkloadGroup_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -235,17 +229,23 @@ public async Task GetAll_GetTheListOfWorkloadGroupsOfASQLAnalyticsPool() // get the collection of this SynapseWorkloadGroupResource SynapseWorkloadGroupCollection collection = synapseSqlPool.GetSynapseWorkloadGroups(); - // invoke the operation and iterate over the result - await foreach (SynapseWorkloadGroupResource item in collection.GetAllAsync()) + // invoke the operation + string workloadGroupName = "smallrc"; + NullableResponse response = await collection.GetIfExistsAsync(workloadGroupName); + SynapseWorkloadGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SynapseWorkloadGroupData resourceData = item.Data; + SynapseWorkloadGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadGroupResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadGroupResource.cs index f1bc61ee5ea77..76e1102472ffe 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadGroupResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkloadGroupResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAAWorkloadGroupOfASQLAnalyticsPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAWorkloadGroupWithAllPropertiesSpecified() + public async Task Delete_DeleteAWorkloadGroupOfASQLAnalyticsPool() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadGroupMax.json - // this example is just showing the usage of "SqlPoolWorkloadGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolWorkloadGroup.json + // this example is just showing the usage of "SqlPoolWorkloadGroup_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,35 +65,21 @@ public async Task Update_CreateAWorkloadGroupWithAllPropertiesSpecified() string resourceGroupName = "sqlcrudtest-6852"; string workspaceName = "sqlcrudtest-2080"; string sqlPoolName = "sqlcrudtest-9187"; - string workloadGroupName = "smallrc"; + string workloadGroupName = "wlm_workloadgroup"; ResourceIdentifier synapseWorkloadGroupResourceId = SynapseWorkloadGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, workloadGroupName); SynapseWorkloadGroupResource synapseWorkloadGroup = client.GetSynapseWorkloadGroupResource(synapseWorkloadGroupResourceId); // invoke the operation - SynapseWorkloadGroupData data = new SynapseWorkloadGroupData() - { - MinResourcePercent = 0, - MaxResourcePercent = 100, - MinResourcePercentPerRequest = 3, - MaxResourcePercentPerRequest = 3, - Importance = "normal", - QueryExecutionTimeout = 0, - }; - ArmOperation lro = await synapseWorkloadGroup.UpdateAsync(WaitUntil.Completed, data); - SynapseWorkloadGroupResource result = lro.Value; + await synapseWorkloadGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkloadGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() + public async Task Update_CreateAWorkloadGroupWithAllPropertiesSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadGroupMin.json + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadGroupMax.json // this example is just showing the usage of "SqlPoolWorkloadGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -112,11 +98,14 @@ public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified( SynapseWorkloadGroupResource synapseWorkloadGroup = client.GetSynapseWorkloadGroupResource(synapseWorkloadGroupResourceId); // invoke the operation - SynapseWorkloadGroupData data = new SynapseWorkloadGroupData() + SynapseWorkloadGroupData data = new SynapseWorkloadGroupData { MinResourcePercent = 0, MaxResourcePercent = 100, MinResourcePercentPerRequest = 3, + MaxResourcePercentPerRequest = 3, + Importance = "normal", + QueryExecutionTimeout = 0, }; ArmOperation lro = await synapseWorkloadGroup.UpdateAsync(WaitUntil.Completed, data); SynapseWorkloadGroupResource result = lro.Value; @@ -130,10 +119,10 @@ public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified( [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAWorkloadGroupOfASQLAnalyticsPool() + public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteSqlPoolWorkloadGroup.json - // this example is just showing the usage of "SqlPoolWorkloadGroup_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateSqlPoolWorkloadGroupMin.json + // this example is just showing the usage of "SqlPoolWorkloadGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,14 +135,25 @@ public async Task Delete_DeleteAWorkloadGroupOfASQLAnalyticsPool() string resourceGroupName = "sqlcrudtest-6852"; string workspaceName = "sqlcrudtest-2080"; string sqlPoolName = "sqlcrudtest-9187"; - string workloadGroupName = "wlm_workloadgroup"; + string workloadGroupName = "smallrc"; ResourceIdentifier synapseWorkloadGroupResourceId = SynapseWorkloadGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, sqlPoolName, workloadGroupName); SynapseWorkloadGroupResource synapseWorkloadGroup = client.GetSynapseWorkloadGroupResource(synapseWorkloadGroupResourceId); // invoke the operation - await synapseWorkloadGroup.DeleteAsync(WaitUntil.Completed); + SynapseWorkloadGroupData data = new SynapseWorkloadGroupData + { + MinResourcePercent = 0, + MaxResourcePercent = 100, + MinResourcePercentPerRequest = 3, + }; + ArmOperation lro = await synapseWorkloadGroup.UpdateAsync(WaitUntil.Completed, data); + SynapseWorkloadGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkloadGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceAdministratorResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceAdministratorResource.cs index b596b4b13a688..de729753d994a 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceAdministratorResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceAdministratorResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetWorkspaceActiveDirectoryAdmin() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceActiveDirectoryAdmin() + public async Task Delete_DeleteWorkspaceActiveDirectoryAdmin() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateWorkspaceAadAdmin.json - // this example is just showing the usage of "WorkspaceAadAdmins_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteWorkspaceAadAdmin.json + // this example is just showing the usage of "WorkspaceAadAdmins_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,29 +66,17 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceActiveDirectoryAdmin() SynapseWorkspaceAdministratorResource synapseWorkspaceAdministratorResource = client.GetSynapseWorkspaceAdministratorResource(synapseWorkspaceAdministratorResourceId); // invoke the operation - SynapseWorkspaceAadAdminInfoData info = new SynapseWorkspaceAadAdminInfoData() - { - TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - Login = "bob@contoso.com", - AdministratorType = "ActiveDirectory", - Sid = "c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c", - }; - ArmOperation lro = await synapseWorkspaceAdministratorResource.CreateOrUpdateAsync(WaitUntil.Completed, info); - SynapseWorkspaceAdministratorResource result = lro.Value; + await synapseWorkspaceAdministratorResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkspaceAadAdminInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceActiveDirectoryAdmin() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceActiveDirectoryAdmin() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteWorkspaceAadAdmin.json - // this example is just showing the usage of "WorkspaceAadAdmins_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateWorkspaceAadAdmin.json + // this example is just showing the usage of "WorkspaceAadAdmins_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +92,21 @@ public async Task Delete_DeleteWorkspaceActiveDirectoryAdmin() SynapseWorkspaceAdministratorResource synapseWorkspaceAdministratorResource = client.GetSynapseWorkspaceAdministratorResource(synapseWorkspaceAdministratorResourceId); // invoke the operation - await synapseWorkspaceAdministratorResource.DeleteAsync(WaitUntil.Completed); + SynapseWorkspaceAadAdminInfoData info = new SynapseWorkspaceAadAdminInfoData + { + TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + Login = "bob@contoso.com", + AdministratorType = "ActiveDirectory", + Sid = "c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c", + }; + ArmOperation lro = await synapseWorkspaceAdministratorResource.CreateOrUpdateAsync(WaitUntil.Completed, info); + SynapseWorkspaceAdministratorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkspaceAadAdminInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceCollection.cs index 1d3961ac31022..6ac37d52d0506 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_SynapseWorkspaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspacesInResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspacesInResourceGroup.json - // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateWorkspace.json + // this example is just showing the usage of "Workspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,74 @@ public async Task GetAll_ListWorkspacesInResourceGroup() // get the collection of this SynapseWorkspaceResource SynapseWorkspaceCollection collection = resourceGroupResource.GetSynapseWorkspaces(); - // invoke the operation and iterate over the result - await foreach (SynapseWorkspaceResource item in collection.GetAllAsync()) + // invoke the operation + string workspaceName = "workspace1"; + SynapseWorkspaceData data = new SynapseWorkspaceData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/resourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uami1")] = new UserAssignedIdentity() +}, + }, + DefaultDataLakeStorage = new SynapseDataLakeStorageAccountDetails + { + AccountUri = new Uri("https://accountname.dfs.core.windows.net"), + Filesystem = "default", + }, + SqlAdministratorLoginPassword = "password", + ManagedResourceGroupName = "workspaceManagedResourceGroupUnique", + SqlAdministratorLogin = "login", + ManagedVirtualNetwork = "default", + Encryption = new SynapseEncryptionDetails + { + Cmk = new WorkspaceCustomerManagedKeyDetails + { + Key = new SynapseWorkspaceKeyDetails + { + Name = "default", + KeyVaultUri = new Uri("https://vault.azure.net/keys/key1"), + }, + KekIdentity = new KekIdentityProperties + { + UserAssignedIdentityId = new ResourceIdentifier("/subscriptions/b64d7b94-73e7-4d36-94b2-7764ea3fd74a/resourcegroups/SynapseCI/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uami1"), + UseSystemAssignedIdentity = BinaryData.FromObjectAsJson("false"), + }, + }, + }, + ManagedVirtualNetworkSettings = new SynapseManagedVirtualNetworkSettings + { + PreventDataExfiltration = false, + EnableLinkedAccessCheckOnTargetResource = false, + AllowedAadTenantIdsForLinking = { "740239CE-A25B-485B-86A0-262F29F6EBDB" }, + }, + WorkspaceRepositoryConfiguration = new SynapseWorkspaceRepositoryConfiguration + { + WorkspaceRepositoryConfigurationType = "FactoryGitHubConfiguration", + HostName = "", + AccountName = "mygithubaccount", + ProjectName = "myproject", + RepositoryName = "myrepository", + CollaborationBranch = "master", + RootFolder = "/", + }, + PurviewResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/resourceGroup1/providers/Microsoft.ProjectPurview/accounts/accountname1"), + PublicNetworkAccess = WorkspacePublicNetworkAccess.Enabled, + InitialWorkspaceAdminObjectId = Guid.Parse("6c20646f-8050-49ec-b3b1-80a0e58e454d"), + Tags = +{ +["key"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); + SynapseWorkspaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +145,10 @@ public async Task Get_GetAWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAWorkspace() + public async Task GetAll_ListWorkspacesInResourceGroup() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspace.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspacesInResourceGroup.json + // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +165,22 @@ public async Task Exists_GetAWorkspace() // get the collection of this SynapseWorkspaceResource SynapseWorkspaceCollection collection = resourceGroupResource.GetSynapseWorkspaces(); - // invoke the operation - string workspaceName = "workspace1"; - bool result = await collection.ExistsAsync(workspaceName); + // invoke the operation and iterate over the result + await foreach (SynapseWorkspaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAWorkspace() + public async Task Exists_GetAWorkspace() { // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspace.json // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +202,17 @@ public async Task GetIfExists_GetAWorkspace() // invoke the operation string workspaceName = "workspace1"; - NullableResponse response = await collection.GetIfExistsAsync(workspaceName); - SynapseWorkspaceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(workspaceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAWorkspace() + public async Task GetIfExists_GetAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateWorkspace.json - // this example is just showing the usage of "Workspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspace.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,75 +231,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAWorkspace() // invoke the operation string workspaceName = "workspace1"; - SynapseWorkspaceData data = new SynapseWorkspaceData(new AzureLocation("East US")) - { - Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/resourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uami1")] = new UserAssignedIdentity(), -}, - }, - DefaultDataLakeStorage = new SynapseDataLakeStorageAccountDetails() - { - AccountUri = new Uri("https://accountname.dfs.core.windows.net"), - Filesystem = "default", - }, - SqlAdministratorLoginPassword = "password", - ManagedResourceGroupName = "workspaceManagedResourceGroupUnique", - SqlAdministratorLogin = "login", - ManagedVirtualNetwork = "default", - Encryption = new SynapseEncryptionDetails() - { - Cmk = new WorkspaceCustomerManagedKeyDetails() - { - Key = new SynapseWorkspaceKeyDetails() - { - Name = "default", - KeyVaultUri = new Uri("https://vault.azure.net/keys/key1"), - }, - KekIdentity = new KekIdentityProperties() - { - UserAssignedIdentityId = new ResourceIdentifier("/subscriptions/b64d7b94-73e7-4d36-94b2-7764ea3fd74a/resourcegroups/SynapseCI/providers/Microsoft.ManagedIdentity/userAssignedIdentities/uami1"), - UseSystemAssignedIdentity = BinaryData.FromString("\"false\""), - }, - }, - }, - ManagedVirtualNetworkSettings = new SynapseManagedVirtualNetworkSettings() - { - PreventDataExfiltration = false, - EnableLinkedAccessCheckOnTargetResource = false, - AllowedAadTenantIdsForLinking = -{ -"740239CE-A25B-485B-86A0-262F29F6EBDB" -}, - }, - WorkspaceRepositoryConfiguration = new SynapseWorkspaceRepositoryConfiguration() - { - WorkspaceRepositoryConfigurationType = "FactoryGitHubConfiguration", - HostName = "", - AccountName = "mygithubaccount", - ProjectName = "myproject", - RepositoryName = "myrepository", - CollaborationBranch = "master", - RootFolder = "/", - }, - PurviewResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/resourceGroup1/providers/Microsoft.ProjectPurview/accounts/accountname1"), - PublicNetworkAccess = WorkspacePublicNetworkAccess.Enabled, - InitialWorkspaceAdminObjectId = Guid.Parse("6c20646f-8050-49ec-b3b1-80a0e58e454d"), - Tags = -{ -["key"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); - SynapseWorkspaceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(workspaceName); + SynapseWorkspaceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspacePrivateLinkResourceCollection.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspacePrivateLinkResourceCollection.cs index 4bef4de705198..a44c688e0af23 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspacePrivateLinkResourceCollection.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspacePrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SynapseWorkspacePrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetPrivateLinkResourcesForWorkspace() + public async Task Get_GetPrivateLinkResourcesForWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListPrivateLinkResources.json - // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateLinkResource.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetPrivateLinkResourcesForWorkspace() // get the collection of this SynapseWorkspacePrivateLinkResource SynapseWorkspacePrivateLinkResourceCollection collection = synapseWorkspace.GetSynapseWorkspacePrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (SynapseWorkspacePrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateLinkResourceName = "sql"; + SynapseWorkspacePrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateLinkResourcesForWorkspace() + public async Task GetAll_GetPrivateLinkResourcesForWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetPrivateLinkResource.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListPrivateLinkResources.json + // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetPrivateLinkResourcesForWorkspace() // get the collection of this SynapseWorkspacePrivateLinkResource SynapseWorkspacePrivateLinkResourceCollection collection = synapseWorkspace.GetSynapseWorkspacePrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "sql"; - SynapseWorkspacePrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (SynapseWorkspacePrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapsePrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapsePrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceResource.cs index 8be3ab744872f..be34a2fdb74b6 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Synapse.Models; using NUnit.Framework; @@ -21,53 +20,10 @@ public partial class Sample_SynapseWorkspaceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task ReplaceAllIpFirewallRule_ReplaceAllIPFirewallRulesInAWorkspace() - { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ReplaceAllIpFirewallRules.json - // this example is just showing the usage of "IpFirewallRules_ReplaceAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SynapseWorkspaceResource created on azure - // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource - string subscriptionId = "01234567-89ab-4def-0123-456789abcdef"; - string resourceGroupName = "ExampleResourceGroup"; - string workspaceName = "ExampleWorkspace"; - ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); - SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); - - // invoke the operation - ReplaceAllIPFirewallRulesContent content = new ReplaceAllIPFirewallRulesContent() - { - IPFirewallRules = -{ -["AnotherExampleFirewallRule"] = new SynapseIPFirewallRuleProperties() -{ -EndIPAddress = IPAddress.Parse("10.0.1.254"), -StartIPAddress = IPAddress.Parse("10.0.1.0"), -}, -["ExampleFirewallRule"] = new SynapseIPFirewallRuleProperties() -{ -EndIPAddress = IPAddress.Parse("10.0.0.254"), -StartIPAddress = IPAddress.Parse("10.0.0.0"), -}, -}, - }; - ArmOperation lro = await synapseWorkspace.ReplaceAllIpFirewallRuleAsync(WaitUntil.Completed, content); - ReplaceAllFirewallRulesOperationResult result = lro.Value; - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetWorkspaceManagedSqlServerUsages_ListUsagesMetricForTheWorkspaceManagedSqlServer() + public async Task Get_GetAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerUsages.json - // this example is just showing the usage of "WorkspaceManagedSqlServerUsages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspace.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,26 +33,27 @@ public async Task GetWorkspaceManagedSqlServerUsages_ListUsagesMetricForTheWorks // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "wsg-7398"; - string workspaceName = "testWorkspace"; + string resourceGroupName = "resourceGroup1"; + string workspaceName = "workspace1"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); - // invoke the operation and iterate over the result - await foreach (SynapseServerUsage item in synapseWorkspace.GetWorkspaceManagedSqlServerUsagesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + SynapseWorkspaceResource result = await synapseWorkspace.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkspace() + public async Task Delete_DeleteAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/GetWorkspace.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteWorkspace.json + // this example is just showing the usage of "Workspaces_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,7 +69,8 @@ public async Task Get_GetAWorkspace() SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // invoke the operation - SynapseWorkspaceResource result = await synapseWorkspace.GetAsync(); + ArmOperation lro = await synapseWorkspace.DeleteAsync(WaitUntil.Completed); + SynapseWorkspaceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -142,24 +100,21 @@ public async Task Update_UpdateAWorkspace() SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // invoke the operation - SynapseWorkspacePatch patch = new SynapseWorkspacePatch() + SynapseWorkspacePatch patch = new SynapseWorkspacePatch { Tags = { -["key"] = "value", +["key"] = "value" }, Identity = new ManagedServiceIdentity("SystemAssigned"), SqlAdministratorLoginPassword = "password", - ManagedVirtualNetworkSettings = new SynapseManagedVirtualNetworkSettings() + ManagedVirtualNetworkSettings = new SynapseManagedVirtualNetworkSettings { PreventDataExfiltration = false, EnableLinkedAccessCheckOnTargetResource = false, - AllowedAadTenantIdsForLinking = -{ -"740239CE-A25B-485B-86A0-262F29F6EBDB" -}, + AllowedAadTenantIdsForLinking = { "740239CE-A25B-485B-86A0-262F29F6EBDB" }, }, - WorkspaceRepositoryConfiguration = new SynapseWorkspaceRepositoryConfiguration() + WorkspaceRepositoryConfiguration = new SynapseWorkspaceRepositoryConfiguration { WorkspaceRepositoryConfigurationType = "FactoryGitHubConfiguration", HostName = "", @@ -170,11 +125,11 @@ public async Task Update_UpdateAWorkspace() RootFolder = "/", }, PurviewResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/resourceGroup1/providers/Microsoft.ProjectPurview/accounts/accountname1"), - Encryption = new SynapseEncryptionDetails() + Encryption = new SynapseEncryptionDetails { - Cmk = new WorkspaceCustomerManagedKeyDetails() + Cmk = new WorkspaceCustomerManagedKeyDetails { - Key = new SynapseWorkspaceKeyDetails() + Key = new SynapseWorkspaceKeyDetails { Name = "default", KeyVaultUri = new Uri("https://vault.azure.net/keys/key1"), @@ -195,10 +150,10 @@ public async Task Update_UpdateAWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAWorkspace() + public async Task ReplaceAllIpFirewallRule_ReplaceAllIPFirewallRulesInAWorkspace() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteWorkspace.json - // this example is just showing the usage of "Workspaces_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ReplaceAllIpFirewallRules.json + // this example is just showing the usage of "IpFirewallRules_ReplaceAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -207,49 +162,59 @@ public async Task Delete_DeleteAWorkspace() // this example assumes you already have this SynapseWorkspaceResource created on azure // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "resourceGroup1"; - string workspaceName = "workspace1"; + string subscriptionId = "01234567-89ab-4def-0123-456789abcdef"; + string resourceGroupName = "ExampleResourceGroup"; + string workspaceName = "ExampleWorkspace"; ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // invoke the operation - ArmOperation lro = await synapseWorkspace.DeleteAsync(WaitUntil.Completed); - SynapseWorkspaceResource result = lro.Value; + ReplaceAllIPFirewallRulesContent content = new ReplaceAllIPFirewallRulesContent + { + IPFirewallRules = +{ +["AnotherExampleFirewallRule"] = new SynapseIPFirewallRuleProperties +{ +EndIPAddress = IPAddress.Parse("10.0.1.254"), +StartIPAddress = IPAddress.Parse("10.0.1.0"), +}, +["ExampleFirewallRule"] = new SynapseIPFirewallRuleProperties +{ +EndIPAddress = IPAddress.Parse("10.0.0.254"), +StartIPAddress = IPAddress.Parse("10.0.0.0"), +} +}, + }; + ArmOperation lro = await synapseWorkspace.ReplaceAllIpFirewallRuleAsync(WaitUntil.Completed, content); + ReplaceAllFirewallRulesOperationResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSynapseWorkspaces_ListWorkspacesInSubscription() + public async Task GetWorkspaceManagedSqlServerUsages_ListUsagesMetricForTheWorkspaceManagedSqlServer() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspacesInSubscription.json - // this example is just showing the usage of "Workspaces_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/ListWorkspaceManagedSqlServerUsages.json + // this example is just showing the usage of "WorkspaceManagedSqlServerUsages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this SynapseWorkspaceResource created on azure + // for more information of creating SynapseWorkspaceResource, please refer to the document of SynapseWorkspaceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "wsg-7398"; + string workspaceName = "testWorkspace"; + ResourceIdentifier synapseWorkspaceResourceId = SynapseWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); + SynapseWorkspaceResource synapseWorkspace = client.GetSynapseWorkspaceResource(synapseWorkspaceResourceId); // invoke the operation and iterate over the result - await foreach (SynapseWorkspaceResource item in subscriptionResource.GetSynapseWorkspacesAsync()) + await foreach (SynapseServerUsage item in synapseWorkspace.GetWorkspaceManagedSqlServerUsagesAsync()) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {item}"); } Console.WriteLine("Succeeded"); diff --git a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceSqlAdministratorResource.cs b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceSqlAdministratorResource.cs index 9adde19be424f..17a0c25bea456 100644 --- a/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceSqlAdministratorResource.cs +++ b/sdk/synapse/Azure.ResourceManager.Synapse/samples/Generated/Samples/Sample_SynapseWorkspaceSqlAdministratorResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetWorkspaceActiveDirectoryAdmin() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceActiveDirectoryAdmin() + public async Task Delete_DeleteWorkspaceActiveDirectoryAdmin() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateWorkspaceAadAdmin.json - // this example is just showing the usage of "WorkspaceSqlAadAdmins_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteWorkspaceAadAdmin.json + // this example is just showing the usage of "WorkspaceSqlAadAdmins_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,29 +66,17 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceActiveDirectoryAdmin() SynapseWorkspaceSqlAdministratorResource synapseWorkspaceSqlAdministratorResource = client.GetSynapseWorkspaceSqlAdministratorResource(synapseWorkspaceSqlAdministratorResourceId); // invoke the operation - SynapseWorkspaceAadAdminInfoData info = new SynapseWorkspaceAadAdminInfoData() - { - TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - Login = "bob@contoso.com", - AdministratorType = "ActiveDirectory", - Sid = "c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c", - }; - ArmOperation lro = await synapseWorkspaceSqlAdministratorResource.CreateOrUpdateAsync(WaitUntil.Completed, info); - SynapseWorkspaceSqlAdministratorResource result = lro.Value; + await synapseWorkspaceSqlAdministratorResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SynapseWorkspaceAadAdminInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceActiveDirectoryAdmin() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceActiveDirectoryAdmin() { - // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/DeleteWorkspaceAadAdmin.json - // this example is just showing the usage of "WorkspaceSqlAadAdmins_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/synapse/resource-manager/Microsoft.Synapse/stable/2021-06-01/examples/CreateOrUpdateWorkspaceAadAdmin.json + // this example is just showing the usage of "WorkspaceSqlAadAdmins_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +92,21 @@ public async Task Delete_DeleteWorkspaceActiveDirectoryAdmin() SynapseWorkspaceSqlAdministratorResource synapseWorkspaceSqlAdministratorResource = client.GetSynapseWorkspaceSqlAdministratorResource(synapseWorkspaceSqlAdministratorResourceId); // invoke the operation - await synapseWorkspaceSqlAdministratorResource.DeleteAsync(WaitUntil.Completed); + SynapseWorkspaceAadAdminInfoData info = new SynapseWorkspaceAadAdminInfoData + { + TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + Login = "bob@contoso.com", + AdministratorType = "ActiveDirectory", + Sid = "c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c", + }; + ArmOperation lro = await synapseWorkspaceSqlAdministratorResource.CreateOrUpdateAsync(WaitUntil.Completed, info); + SynapseWorkspaceSqlAdministratorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SynapseWorkspaceAadAdminInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..d35c1298d1e01 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,109 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrafficManager.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.TrafficManager.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckTrafficManagerNameAvailabilityV2_NameAvailabilityV2TestNameAvailablePOST21() + { + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/NameAvailabilityV2Test_NameAvailable-POST-example-21.json + // this example is just showing the usage of "Profiles_CheckTrafficManagerNameAvailabilityV2" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent + { + Name = "azsmnet5403", + ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), + }; + TrafficManagerNameAvailabilityResult result = await subscriptionResource.CheckTrafficManagerNameAvailabilityV2Async(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckTrafficManagerNameAvailabilityV2_NameAvailabilityV2TestNameNotAvailablePOST23() + { + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/NameAvailabilityV2Test_NameNotAvailable-POST-example-23.json + // this example is just showing the usage of "Profiles_CheckTrafficManagerNameAvailabilityV2" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent + { + Name = "azsmnet4696", + ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), + }; + TrafficManagerNameAvailabilityResult result = await subscriptionResource.CheckTrafficManagerNameAvailabilityV2Async(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetTrafficManagerProfiles_ListBySubscription() + { + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-BySubscription.json + // this example is just showing the usage of "Profiles_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (TrafficManagerProfileResource item in subscriptionResource.GetTrafficManagerProfilesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TenantResourceExtensions.cs new file mode 100644 index 0000000000000..56e514380fef8 --- /dev/null +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -0,0 +1,70 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrafficManager.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.TrafficManager.Samples +{ + public partial class Sample_TenantResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckTrafficManagerRelativeDnsNameAvailability_NameAvailabilityTestNameAvailablePOST21() + { + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/NameAvailabilityTest_NameAvailable-POST-example-21.json + // this example is just showing the usage of "Profiles_CheckTrafficManagerRelativeDnsNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation + TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent + { + Name = "azsmnet5403", + ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), + }; + TrafficManagerNameAvailabilityResult result = await tenantResource.CheckTrafficManagerRelativeDnsNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckTrafficManagerRelativeDnsNameAvailability_NameAvailabilityTestNameNotAvailablePOST23() + { + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/NameAvailabilityTest_NameNotAvailable-POST-example-23.json + // this example is just showing the usage of "Profiles_CheckTrafficManagerRelativeDnsNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation + TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent + { + Name = "azsmnet4696", + ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), + }; + TrafficManagerNameAvailabilityResult result = await tenantResource.CheckTrafficManagerRelativeDnsNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerEndpointCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerEndpointCollection.cs index aa90e7e3753a3..1eae8408bfd40 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerEndpointCollection.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerEndpointCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_TrafficManagerEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EndpointGETExternalWithGeoMapping() + public async Task CreateOrUpdate_EndpointPUTExternalWithAlwaysServe() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithGeoMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PUT-External-WithAlwaysServe.json + // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,8 +32,8 @@ public async Task Get_EndpointGETExternalWithGeoMapping() // this example assumes you already have this TrafficManagerProfileResource created on azure // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; + string profileName = "azsmnet6386"; ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); @@ -42,8 +42,18 @@ public async Task Get_EndpointGETExternalWithGeoMapping() // invoke the operation string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - TrafficManagerEndpointResource result = await collection.GetAsync(endpointType, endpointName); + string endpointName = "azsmnet7187"; + TrafficManagerEndpointData data = new TrafficManagerEndpointData + { + Target = "foobar.contoso.com", + EndpointStatus = TrafficManagerEndpointStatus.Enabled, + EndpointLocation = "North Europe", + AlwaysServe = TrafficManagerEndpointAlwaysServeStatus.Enabled, + Name = "azsmnet7187", + ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); + TrafficManagerEndpointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +64,10 @@ public async Task Get_EndpointGETExternalWithGeoMapping() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EndpointGETExternalWithGeoMapping() + public async Task CreateOrUpdate_EndpointPUTExternalWithCustomHeaders() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithGeoMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PUT-External-WithCustomHeaders.json + // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,8 +77,8 @@ public async Task Exists_EndpointGETExternalWithGeoMapping() // this example assumes you already have this TrafficManagerProfileResource created on azure // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; + string profileName = "azsmnet6386"; ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); @@ -77,18 +87,40 @@ public async Task Exists_EndpointGETExternalWithGeoMapping() // invoke the operation string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; - bool result = await collection.ExistsAsync(endpointType, endpointName); + string endpointName = "azsmnet7187"; + TrafficManagerEndpointData data = new TrafficManagerEndpointData + { + Target = "foobar.contoso.com", + EndpointStatus = TrafficManagerEndpointStatus.Enabled, + EndpointLocation = "North Europe", + CustomHeaders = {new TrafficManagerEndpointCustomHeaderInfo +{ +Name = "header-1", +Value = "value-1", +}, new TrafficManagerEndpointCustomHeaderInfo +{ +Name = "header-2", +Value = "value-2", +}}, + Name = "azsmnet7187", + ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); + TrafficManagerEndpointResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EndpointGETExternalWithGeoMapping() + public async Task CreateOrUpdate_EndpointPUTExternalWithGeoMapping() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithGeoMapping.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PUT-External-WithGeoMapping.json + // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,29 +141,30 @@ public async Task GetIfExists_EndpointGETExternalWithGeoMapping() // invoke the operation string endpointType = "ExternalEndpoints"; string endpointName = "My%20external%20endpoint"; - NullableResponse response = await collection.GetIfExistsAsync(endpointType, endpointName); - TrafficManagerEndpointResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + TrafficManagerEndpointData data = new TrafficManagerEndpointData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Target = "foobar.contoso.com", + EndpointStatus = TrafficManagerEndpointStatus.Enabled, + GeoMapping = { "GEO-AS", "GEO-AF" }, + Name = "My external endpoint", + ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); + TrafficManagerEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EndpointGETExternalWithLocation() + public async Task CreateOrUpdate_EndpointPUTExternalWithLocation() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithLocation.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PUT-External-WithLocation.json + // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -152,7 +185,16 @@ public async Task Get_EndpointGETExternalWithLocation() // invoke the operation string endpointType = "ExternalEndpoints"; string endpointName = "azsmnet7187"; - TrafficManagerEndpointResource result = await collection.GetAsync(endpointType, endpointName); + TrafficManagerEndpointData data = new TrafficManagerEndpointData + { + Target = "foobar.contoso.com", + EndpointStatus = TrafficManagerEndpointStatus.Enabled, + EndpointLocation = "North Europe", + Name = "azsmnet7187", + ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); + TrafficManagerEndpointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -163,10 +205,10 @@ public async Task Get_EndpointGETExternalWithLocation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EndpointGETExternalWithLocation() + public async Task CreateOrUpdate_EndpointPUTExternalWithSubnetMapping() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithLocation.json - // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PUT-External-WithSubnetMapping.json + // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,8 +218,8 @@ public async Task Exists_EndpointGETExternalWithLocation() // this example assumes you already have this TrafficManagerProfileResource created on azure // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; + string profileName = "azuresdkfornetautoresttrafficmanager8224"; ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); @@ -186,17 +228,38 @@ public async Task Exists_EndpointGETExternalWithLocation() // invoke the operation string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - bool result = await collection.ExistsAsync(endpointType, endpointName); + string endpointName = "My%20external%20endpoint"; + TrafficManagerEndpointData data = new TrafficManagerEndpointData + { + Target = "foobar.contoso.com", + EndpointStatus = TrafficManagerEndpointStatus.Enabled, + Subnets = {new TrafficManagerEndpointSubnetInfo +{ +First = IPAddress.Parse("1.2.3.0"), +Scope = 24, +}, new TrafficManagerEndpointSubnetInfo +{ +First = IPAddress.Parse("25.26.27.28"), +Last = IPAddress.Parse("29.30.31.32"), +}}, + Name = "My external endpoint", + ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); + TrafficManagerEndpointResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EndpointGETExternalWithLocation() + public async Task Get_EndpointGETExternalWithGeoMapping() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithLocation.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithGeoMapping.json // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -207,8 +270,8 @@ public async Task GetIfExists_EndpointGETExternalWithLocation() // this example assumes you already have this TrafficManagerProfileResource created on azure // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; + string profileName = "azuresdkfornetautoresttrafficmanager8224"; ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); @@ -217,29 +280,21 @@ public async Task GetIfExists_EndpointGETExternalWithLocation() // invoke the operation string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - NullableResponse response = await collection.GetIfExistsAsync(endpointType, endpointName); - TrafficManagerEndpointResource result = response.HasValue ? response.Value : null; + string endpointName = "My%20external%20endpoint"; + TrafficManagerEndpointResource result = await collection.GetAsync(endpointType, endpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EndpointGETExternalWithSubnetMapping() + public async Task Get_EndpointGETExternalWithLocation() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithSubnetMapping.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithLocation.json // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -250,8 +305,8 @@ public async Task Get_EndpointGETExternalWithSubnetMapping() // this example assumes you already have this TrafficManagerProfileResource created on azure // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; - string profileName = "azuresdkfornetautoresttrafficmanager8224"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; + string profileName = "azsmnet6386"; ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); @@ -260,7 +315,7 @@ public async Task Get_EndpointGETExternalWithSubnetMapping() // invoke the operation string endpointType = "ExternalEndpoints"; - string endpointName = "My%20external%20endpoint"; + string endpointName = "azsmnet7187"; TrafficManagerEndpointResource result = await collection.GetAsync(endpointType, endpointName); // the variable result is a resource, you could call other operations on this instance as well @@ -272,7 +327,7 @@ public async Task Get_EndpointGETExternalWithSubnetMapping() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EndpointGETExternalWithSubnetMapping() + public async Task Get_EndpointGETExternalWithSubnetMapping() { // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithSubnetMapping.json // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -296,16 +351,20 @@ public async Task Exists_EndpointGETExternalWithSubnetMapping() // invoke the operation string endpointType = "ExternalEndpoints"; string endpointName = "My%20external%20endpoint"; - bool result = await collection.ExistsAsync(endpointType, endpointName); + TrafficManagerEndpointResource result = await collection.GetAsync(endpointType, endpointName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EndpointGETExternalWithSubnetMapping() + public async Task Exists_EndpointGETExternalWithGeoMapping() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithSubnetMapping.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithGeoMapping.json // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -327,29 +386,17 @@ public async Task GetIfExists_EndpointGETExternalWithSubnetMapping() // invoke the operation string endpointType = "ExternalEndpoints"; string endpointName = "My%20external%20endpoint"; - NullableResponse response = await collection.GetIfExistsAsync(endpointType, endpointName); - TrafficManagerEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(endpointType, endpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointPUTExternalWithAlwaysServe() + public async Task Exists_EndpointGETExternalWithLocation() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PUT-External-WithAlwaysServe.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithLocation.json + // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -370,31 +417,17 @@ public async Task CreateOrUpdate_EndpointPUTExternalWithAlwaysServe() // invoke the operation string endpointType = "ExternalEndpoints"; string endpointName = "azsmnet7187"; - TrafficManagerEndpointData data = new TrafficManagerEndpointData() - { - Target = "foobar.contoso.com", - EndpointStatus = TrafficManagerEndpointStatus.Enabled, - EndpointLocation = "North Europe", - AlwaysServe = TrafficManagerEndpointAlwaysServeStatus.Enabled, - Name = "azsmnet7187", - ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); - TrafficManagerEndpointResource result = lro.Value; + bool result = await collection.ExistsAsync(endpointType, endpointName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointPUTExternalWithCustomHeaders() + public async Task Exists_EndpointGETExternalWithSubnetMapping() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PUT-External-WithCustomHeaders.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithSubnetMapping.json + // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -404,8 +437,8 @@ public async Task CreateOrUpdate_EndpointPUTExternalWithCustomHeaders() // this example assumes you already have this TrafficManagerProfileResource created on azure // for more information of creating TrafficManagerProfileResource, please refer to the document of TrafficManagerProfileResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager2191"; + string profileName = "azuresdkfornetautoresttrafficmanager8224"; ResourceIdentifier trafficManagerProfileResourceId = TrafficManagerProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); @@ -414,43 +447,18 @@ public async Task CreateOrUpdate_EndpointPUTExternalWithCustomHeaders() // invoke the operation string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - TrafficManagerEndpointData data = new TrafficManagerEndpointData() - { - Target = "foobar.contoso.com", - EndpointStatus = TrafficManagerEndpointStatus.Enabled, - EndpointLocation = "North Europe", - CustomHeaders = -{ -new TrafficManagerEndpointCustomHeaderInfo() -{ -Name = "header-1", -Value = "value-1", -},new TrafficManagerEndpointCustomHeaderInfo() -{ -Name = "header-2", -Value = "value-2", -} -}, - Name = "azsmnet7187", - ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); - TrafficManagerEndpointResource result = lro.Value; + string endpointName = "My%20external%20endpoint"; + bool result = await collection.ExistsAsync(endpointType, endpointName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointPUTExternalWithGeoMapping() + public async Task GetIfExists_EndpointGETExternalWithGeoMapping() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PUT-External-WithGeoMapping.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithGeoMapping.json + // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -471,33 +479,29 @@ public async Task CreateOrUpdate_EndpointPUTExternalWithGeoMapping() // invoke the operation string endpointType = "ExternalEndpoints"; string endpointName = "My%20external%20endpoint"; - TrafficManagerEndpointData data = new TrafficManagerEndpointData() - { - Target = "foobar.contoso.com", - EndpointStatus = TrafficManagerEndpointStatus.Enabled, - GeoMapping = -{ -"GEO-AS","GEO-AF" -}, - Name = "My external endpoint", - ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); - TrafficManagerEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(endpointType, endpointName); + TrafficManagerEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointPUTExternalWithLocation() + public async Task GetIfExists_EndpointGETExternalWithLocation() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PUT-External-WithLocation.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithLocation.json + // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -518,30 +522,29 @@ public async Task CreateOrUpdate_EndpointPUTExternalWithLocation() // invoke the operation string endpointType = "ExternalEndpoints"; string endpointName = "azsmnet7187"; - TrafficManagerEndpointData data = new TrafficManagerEndpointData() - { - Target = "foobar.contoso.com", - EndpointStatus = TrafficManagerEndpointStatus.Enabled, - EndpointLocation = "North Europe", - Name = "azsmnet7187", - ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); - TrafficManagerEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(endpointType, endpointName); + TrafficManagerEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointPUTExternalWithSubnetMapping() + public async Task GetIfExists_EndpointGETExternalWithSubnetMapping() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PUT-External-WithSubnetMapping.json - // this example is just showing the usage of "Endpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-GET-External-WithSubnetMapping.json + // this example is just showing the usage of "Endpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -562,33 +565,21 @@ public async Task CreateOrUpdate_EndpointPUTExternalWithSubnetMapping() // invoke the operation string endpointType = "ExternalEndpoints"; string endpointName = "My%20external%20endpoint"; - TrafficManagerEndpointData data = new TrafficManagerEndpointData() - { - Target = "foobar.contoso.com", - EndpointStatus = TrafficManagerEndpointStatus.Enabled, - Subnets = -{ -new TrafficManagerEndpointSubnetInfo() -{ -First = IPAddress.Parse("1.2.3.0"), -Scope = 24, -},new TrafficManagerEndpointSubnetInfo() -{ -First = IPAddress.Parse("25.26.27.28"), -Last = IPAddress.Parse("29.30.31.32"), -} -}, - Name = "My external endpoint", - ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointType, endpointName, data); - TrafficManagerEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(endpointType, endpointName); + TrafficManagerEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerEndpointResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerEndpointResource.cs index bf3bb0fd451e4..5250134474843 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerEndpointResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerEndpointResource.cs @@ -15,45 +15,6 @@ namespace Azure.ResourceManager.TrafficManager.Samples { public partial class Sample_TrafficManagerEndpointResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_EndpointPATCHExternalTarget() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PATCH-External-Target.json - // this example is just showing the usage of "Endpoints_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TrafficManagerEndpointResource created on azure - // for more information of creating TrafficManagerEndpointResource, please refer to the document of TrafficManagerEndpointResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; - string profileName = "azsmnet6386"; - string endpointType = "ExternalEndpoints"; - string endpointName = "azsmnet7187"; - ResourceIdentifier trafficManagerEndpointResourceId = TrafficManagerEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); - TrafficManagerEndpointResource trafficManagerEndpoint = client.GetTrafficManagerEndpointResource(trafficManagerEndpointResourceId); - - // invoke the operation - TrafficManagerEndpointData data = new TrafficManagerEndpointData() - { - Target = "another.foobar.contoso.com", - Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386/externalEndpoints/azsmnet7187"), - Name = "azsmnet7187", - ResourceType = new ResourceType("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), - }; - TrafficManagerEndpointResource result = await trafficManagerEndpoint.UpdateAsync(data); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_EndpointGETExternalWithGeoMapping() @@ -177,5 +138,44 @@ public async Task Delete_EndpointDELETEExternal() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_EndpointPATCHExternalTarget() + { + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Endpoint-PATCH-External-Target.json + // this example is just showing the usage of "Endpoints_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TrafficManagerEndpointResource created on azure + // for more information of creating TrafficManagerEndpointResource, please refer to the document of TrafficManagerEndpointResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; + string profileName = "azsmnet6386"; + string endpointType = "ExternalEndpoints"; + string endpointName = "azsmnet7187"; + ResourceIdentifier trafficManagerEndpointResourceId = TrafficManagerEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointType, endpointName); + TrafficManagerEndpointResource trafficManagerEndpoint = client.GetTrafficManagerEndpointResource(trafficManagerEndpointResourceId); + + // invoke the operation + TrafficManagerEndpointData data = new TrafficManagerEndpointData + { + Target = "another.foobar.contoso.com", + Id = new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/azuresdkfornetautoresttrafficmanager1421/providers/Microsoft.Network/trafficManagerProfiles/azsmnet6386/externalEndpoints/azsmnet7187"), + Name = "azsmnet7187", + ResourceType = new ResourceType("Microsoft.Network/trafficManagerProfiles/externalEndpoints"), + }; + TrafficManagerEndpointResource result = await trafficManagerEndpoint.UpdateAsync(data); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerHeatMapCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerHeatMapCollection.cs index 1c6426e9a1547..ee064e810a572 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerHeatMapCollection.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerHeatMapCollection.cs @@ -53,9 +53,9 @@ public async Task Get_HeatMapGET() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_HeatMapGET() + public async Task Get_HeatMapGETWithNullValues() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET-With-Null-Values.json // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -76,16 +76,20 @@ public async Task Exists_HeatMapGET() // invoke the operation TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - bool result = await collection.ExistsAsync(heatMapType); + TrafficManagerHeatMapResource result = await collection.GetAsync(heatMapType); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerHeatMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HeatMapGET() + public async Task Get_HeatMapGETWithTopLeftBotRight() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET-With-TopLeft-BotRight.json // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -106,28 +110,22 @@ public async Task GetIfExists_HeatMapGET() // invoke the operation TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - NullableResponse response = await collection.GetIfExistsAsync(heatMapType); - TrafficManagerHeatMapResource result = response.HasValue ? response.Value : null; + IEnumerable topLeft = new double[] { 10, 50.001 }; + IEnumerable botRight = new double[] { -50.001, 80 }; + TrafficManagerHeatMapResource result = await collection.GetAsync(heatMapType, topLeft: topLeft, botRight: botRight); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerHeatMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_HeatMapGETWithNullValues() + public async Task Exists_HeatMapGET() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET-With-Null-Values.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET.json // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -148,13 +146,9 @@ public async Task Get_HeatMapGETWithNullValues() // invoke the operation TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - TrafficManagerHeatMapResource result = await collection.GetAsync(heatMapType); + bool result = await collection.ExistsAsync(heatMapType); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -189,9 +183,9 @@ public async Task Exists_HeatMapGETWithNullValues() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HeatMapGETWithNullValues() + public async Task Exists_HeatMapGETWithTopLeftBotRight() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET-With-Null-Values.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET-With-TopLeft-BotRight.json // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -212,28 +206,18 @@ public async Task GetIfExists_HeatMapGETWithNullValues() // invoke the operation TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - NullableResponse response = await collection.GetIfExistsAsync(heatMapType); - TrafficManagerHeatMapResource result = response.HasValue ? response.Value : null; + IEnumerable topLeft = new double[] { 10, 50.001 }; + IEnumerable botRight = new double[] { -50.001, 80 }; + bool result = await collection.ExistsAsync(heatMapType, topLeft: topLeft, botRight: botRight); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_HeatMapGETWithTopLeftBotRight() + public async Task GetIfExists_HeatMapGET() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET-With-TopLeft-BotRight.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET.json // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -254,28 +238,28 @@ public async Task Get_HeatMapGETWithTopLeftBotRight() // invoke the operation TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - IEnumerable topLeft = new double[] + NullableResponse response = await collection.GetIfExistsAsync(heatMapType); + TrafficManagerHeatMapResource result = response.HasValue ? response.Value : null; + + if (result == null) { -10,50.001 - }; - IEnumerable botRight = new double[] + Console.WriteLine("Succeeded with null as result"); + } + else { --50.001,80 - }; - TrafficManagerHeatMapResource result = await collection.GetAsync(heatMapType, topLeft: topLeft, botRight: botRight); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerHeatMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerHeatMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_HeatMapGETWithTopLeftBotRight() + public async Task GetIfExists_HeatMapGETWithNullValues() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET-With-TopLeft-BotRight.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/HeatMap-GET-With-Null-Values.json // this example is just showing the usage of "HeatMap_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -296,17 +280,21 @@ public async Task Exists_HeatMapGETWithTopLeftBotRight() // invoke the operation TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - IEnumerable topLeft = new double[] + NullableResponse response = await collection.GetIfExistsAsync(heatMapType); + TrafficManagerHeatMapResource result = response.HasValue ? response.Value : null; + + if (result == null) { -10,50.001 - }; - IEnumerable botRight = new double[] + Console.WriteLine("Succeeded with null as result"); + } + else { --50.001,80 - }; - bool result = await collection.ExistsAsync(heatMapType, topLeft: topLeft, botRight: botRight); - - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerHeatMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] @@ -334,14 +322,8 @@ public async Task GetIfExists_HeatMapGETWithTopLeftBotRight() // invoke the operation TrafficManagerHeatMapType heatMapType = TrafficManagerHeatMapType.Default; - IEnumerable topLeft = new double[] - { -10,50.001 - }; - IEnumerable botRight = new double[] - { --50.001,80 - }; + IEnumerable topLeft = new double[] { 10, 50.001 }; + IEnumerable botRight = new double[] { -50.001, 80 }; NullableResponse response = await collection.GetIfExistsAsync(heatMapType, topLeft: topLeft, botRight: botRight); TrafficManagerHeatMapResource result = response.HasValue ? response.Value : null; diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerHeatMapResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerHeatMapResource.cs index 285125f3074a3..fb4cf581e27af 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerHeatMapResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerHeatMapResource.cs @@ -101,14 +101,8 @@ public async Task Get_HeatMapGETWithTopLeftBotRight() TrafficManagerHeatMapResource trafficManagerHeatMap = client.GetTrafficManagerHeatMapResource(trafficManagerHeatMapResourceId); // invoke the operation - IEnumerable topLeft = new double[] - { -10,50.001 - }; - IEnumerable botRight = new double[] - { --50.001,80 - }; + IEnumerable topLeft = new double[] { 10, 50.001 }; + IEnumerable botRight = new double[] { -50.001, 80 }; TrafficManagerHeatMapResource result = await trafficManagerHeatMap.GetAsync(topLeft: topLeft, botRight: botRight); // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerProfileCollection.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerProfileCollection.cs index b981eb98959a2..902b45af7dcc6 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerProfileCollection.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerProfileCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_TrafficManagerProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListProfilesByResourceGroup() + public async Task CreateOrUpdate_ProfilePUTMultiValue() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-ByResourceGroup.json - // this example is just showing the usage of "Profiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-MultiValue.json + // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,32 +32,50 @@ public async Task GetAll_ListProfilesByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager3640"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this TrafficManagerProfileResource TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - // invoke the operation and iterate over the result - await foreach (TrafficManagerProfileResource item in collection.GetAllAsync()) + // invoke the operation + string profileName = "azsmnet6386"; + TrafficManagerProfileData data = new TrafficManagerProfileData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProfileStatus = TrafficManagerProfileStatus.Enabled, + TrafficRoutingMethod = TrafficRoutingMethod.MultiValue, + DnsConfig = new TrafficManagerDnsConfig + { + RelativeName = "azsmnet6386", + Ttl = 35L, + }, + MonitorConfig = new TrafficManagerMonitorConfig + { + Protocol = TrafficManagerMonitorProtocol.Http, + Port = 80L, + Path = "/testpath.aspx", + }, + TrafficViewEnrollmentStatus = TrafficViewEnrollmentStatus.Disabled, + MaxReturn = 2L, + Location = new AzureLocation("global"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + TrafficManagerProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithEndpoints() + public async Task CreateOrUpdate_ProfilePUTNoEndpoints() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithEndpoints.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-NoEndpoints.json + // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,7 +85,7 @@ public async Task Get_ProfileGETWithEndpoints() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -75,8 +93,26 @@ public async Task Get_ProfileGETWithEndpoints() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - TrafficManagerProfileResource result = await collection.GetAsync(profileName); + string profileName = "azsmnet6386"; + TrafficManagerProfileData data = new TrafficManagerProfileData + { + ProfileStatus = TrafficManagerProfileStatus.Enabled, + TrafficRoutingMethod = TrafficRoutingMethod.Performance, + DnsConfig = new TrafficManagerDnsConfig + { + RelativeName = "azsmnet6386", + Ttl = 35L, + }, + MonitorConfig = new TrafficManagerMonitorConfig + { + Protocol = TrafficManagerMonitorProtocol.Http, + Port = 80L, + Path = "/testpath.aspx", + }, + Location = new AzureLocation("global"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + TrafficManagerProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,10 +123,10 @@ public async Task Get_ProfileGETWithEndpoints() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProfileGETWithEndpoints() + public async Task CreateOrUpdate_ProfilePUTWithAliasing() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithEndpoints.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithAliasing.json + // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +136,7 @@ public async Task Exists_ProfileGETWithEndpoints() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -108,18 +144,52 @@ public async Task Exists_ProfileGETWithEndpoints() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - bool result = await collection.ExistsAsync(profileName); + string profileName = "azuresdkfornetautoresttrafficmanager6192"; + TrafficManagerProfileData data = new TrafficManagerProfileData + { + ProfileStatus = TrafficManagerProfileStatus.Enabled, + TrafficRoutingMethod = TrafficRoutingMethod.Performance, + DnsConfig = new TrafficManagerDnsConfig + { + RelativeName = "azuresdkfornetautoresttrafficmanager6192", + Ttl = 35L, + }, + MonitorConfig = new TrafficManagerMonitorConfig + { + Protocol = TrafficManagerMonitorProtocol.Http, + Port = 80L, + Path = "/testpath.aspx", + IntervalInSeconds = 10L, + TimeoutInSeconds = 5L, + ToleratedNumberOfFailures = 2L, + }, + Endpoints = {new TrafficManagerEndpointData +{ +Target = "foobar.contoso.com", +EndpointStatus = TrafficManagerEndpointStatus.Enabled, +EndpointLocation = "North Europe", +Name = "My external endpoint", +ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), +}}, + AllowedEndpointRecordTypes = { AllowedEndpointRecordType.DomainName }, + Location = new AzureLocation("global"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + TrafficManagerProfileResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProfileGETWithEndpoints() + public async Task CreateOrUpdate_ProfilePUTWithCustomHeaders() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithEndpoints.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithCustomHeaders.json + // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,7 +199,7 @@ public async Task GetIfExists_ProfileGETWithEndpoints() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -137,49 +207,61 @@ public async Task GetIfExists_ProfileGETWithEndpoints() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - TrafficManagerProfileResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string profileName = "azuresdkfornetautoresttrafficmanager6192"; + TrafficManagerProfileData data = new TrafficManagerProfileData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithTrafficViewDisabled() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewDisabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this TrafficManagerProfileResource - TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); - - // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - TrafficManagerProfileResource result = await collection.GetAsync(profileName); + ProfileStatus = TrafficManagerProfileStatus.Enabled, + TrafficRoutingMethod = TrafficRoutingMethod.Performance, + DnsConfig = new TrafficManagerDnsConfig + { + RelativeName = "azuresdkfornetautoresttrafficmanager6192", + Ttl = 35L, + }, + MonitorConfig = new TrafficManagerMonitorConfig + { + Protocol = TrafficManagerMonitorProtocol.Http, + Port = 80L, + Path = "/testpath.aspx", + IntervalInSeconds = 10L, + TimeoutInSeconds = 5L, + ToleratedNumberOfFailures = 2L, + CustomHeaders = {new TrafficManagerMonitorConfigCustomHeaderInfo +{ +Name = "header-1", +Value = "value-1", +}, new TrafficManagerMonitorConfigCustomHeaderInfo +{ +Name = "header-2", +Value = "value-2", +}}, + ExpectedStatusCodeRanges = {new ExpectedStatusCodeRangeInfo +{ +Min = 200, +Max = 205, +}, new ExpectedStatusCodeRangeInfo +{ +Min = 400, +Max = 410, +}}, + }, + Endpoints = {new TrafficManagerEndpointData +{ +Target = "foobar.contoso.com", +EndpointStatus = TrafficManagerEndpointStatus.Enabled, +EndpointLocation = "North Europe", +CustomHeaders = {new TrafficManagerEndpointCustomHeaderInfo +{ +Name = "header-2", +Value = "value-2-overridden", +}}, +Name = "My external endpoint", +ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), +}}, + TrafficViewEnrollmentStatus = TrafficViewEnrollmentStatus.Disabled, + Location = new AzureLocation("global"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + TrafficManagerProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -190,10 +272,10 @@ public async Task Get_ProfileGETWithTrafficViewDisabled() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProfileGETWithTrafficViewDisabled() + public async Task CreateOrUpdate_ProfilePUTWithEndpoints() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewDisabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithEndpoints.json + // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -203,7 +285,7 @@ public async Task Exists_ProfileGETWithTrafficViewDisabled() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -211,18 +293,51 @@ public async Task Exists_ProfileGETWithTrafficViewDisabled() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - bool result = await collection.ExistsAsync(profileName); + string profileName = "azuresdkfornetautoresttrafficmanager6192"; + TrafficManagerProfileData data = new TrafficManagerProfileData + { + ProfileStatus = TrafficManagerProfileStatus.Enabled, + TrafficRoutingMethod = TrafficRoutingMethod.Performance, + DnsConfig = new TrafficManagerDnsConfig + { + RelativeName = "azuresdkfornetautoresttrafficmanager6192", + Ttl = 35L, + }, + MonitorConfig = new TrafficManagerMonitorConfig + { + Protocol = TrafficManagerMonitorProtocol.Http, + Port = 80L, + Path = "/testpath.aspx", + IntervalInSeconds = 10L, + TimeoutInSeconds = 5L, + ToleratedNumberOfFailures = 2L, + }, + Endpoints = {new TrafficManagerEndpointData +{ +Target = "foobar.contoso.com", +EndpointStatus = TrafficManagerEndpointStatus.Enabled, +EndpointLocation = "North Europe", +Name = "My external endpoint", +ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), +}}, + Location = new AzureLocation("global"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + TrafficManagerProfileResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProfileGETWithTrafficViewDisabled() + public async Task CreateOrUpdate_ProfilePUTWithNestedEndpoints() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewDisabled.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithNestedEndpoints.json + // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -232,7 +347,7 @@ public async Task GetIfExists_ProfileGETWithTrafficViewDisabled() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; + string resourceGroupName = "myresourcegroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -240,29 +355,65 @@ public async Task GetIfExists_ProfileGETWithTrafficViewDisabled() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager3880"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - TrafficManagerProfileResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string profileName = "parentprofile"; + TrafficManagerProfileData data = new TrafficManagerProfileData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProfileStatus = TrafficManagerProfileStatus.Enabled, + TrafficRoutingMethod = TrafficRoutingMethod.Priority, + DnsConfig = new TrafficManagerDnsConfig + { + RelativeName = "parentprofile", + Ttl = 35L, + }, + MonitorConfig = new TrafficManagerMonitorConfig + { + Protocol = TrafficManagerMonitorProtocol.Http, + Port = 80L, + Path = "/testpath.aspx", + IntervalInSeconds = 10L, + TimeoutInSeconds = 5L, + ToleratedNumberOfFailures = 2L, + }, + Endpoints = {new TrafficManagerEndpointData +{ +Target = "firstnestedprofile.tmpreview.watmtest.azure-test.net", +EndpointStatus = TrafficManagerEndpointStatus.Enabled, +Weight = 1L, +Priority = 1L, +MinChildEndpoints = 2L, +MinChildEndpointsIPv4 = 1L, +MinChildEndpointsIPv6 = 2L, +Name = "MyFirstNestedEndpoint", +ResourceType = new ResourceType("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"), +}, new TrafficManagerEndpointData +{ +Target = "secondnestedprofile.tmpreview.watmtest.azure-test.net", +EndpointStatus = TrafficManagerEndpointStatus.Enabled, +Weight = 1L, +Priority = 2L, +MinChildEndpoints = 2L, +MinChildEndpointsIPv4 = 2L, +MinChildEndpointsIPv6 = 1L, +Name = "MySecondNestedEndpoint", +ResourceType = new ResourceType("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"), +}}, + Location = new AzureLocation("global"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + TrafficManagerProfileResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProfileGETWithTrafficViewEnabled() + public async Task Get_ProfileGETWithEndpoints() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewEnabled.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithEndpoints.json // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -293,9 +444,9 @@ public async Task Get_ProfileGETWithTrafficViewEnabled() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProfileGETWithTrafficViewEnabled() + public async Task Get_ProfileGETWithTrafficViewDisabled() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewEnabled.json + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewDisabled.json // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -315,14 +466,18 @@ public async Task Exists_ProfileGETWithTrafficViewEnabled() // invoke the operation string profileName = "azuresdkfornetautoresttrafficmanager3880"; - bool result = await collection.ExistsAsync(profileName); + TrafficManagerProfileResource result = await collection.GetAsync(profileName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProfileGETWithTrafficViewEnabled() + public async Task Get_ProfileGETWithTrafficViewEnabled() { // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewEnabled.json // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -344,29 +499,56 @@ public async Task GetIfExists_ProfileGETWithTrafficViewEnabled() // invoke the operation string profileName = "azuresdkfornetautoresttrafficmanager3880"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - TrafficManagerProfileResource result = response.HasValue ? response.Value : null; + TrafficManagerProfileResource result = await collection.GetAsync(profileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListProfilesByResourceGroup() + { + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-ByResourceGroup.json + // this example is just showing the usage of "Profiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager3640"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this TrafficManagerProfileResource + TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); + + // invoke the operation and iterate over the result + await foreach (TrafficManagerProfileResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; + TrafficManagerProfileData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTMultiValue() + public async Task Exists_ProfileGETWithEndpoints() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-MultiValue.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithEndpoints.json + // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -376,7 +558,7 @@ public async Task CreateOrUpdate_ProfilePUTMultiValue() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -384,42 +566,18 @@ public async Task CreateOrUpdate_ProfilePUTMultiValue() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "azsmnet6386"; - TrafficManagerProfileData data = new TrafficManagerProfileData() - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.MultiValue, - DnsConfig = new TrafficManagerDnsConfig() - { - RelativeName = "azsmnet6386", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig() - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - }, - TrafficViewEnrollmentStatus = TrafficViewEnrollmentStatus.Disabled, - MaxReturn = 2L, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; + string profileName = "azuresdkfornetautoresttrafficmanager3880"; + bool result = await collection.ExistsAsync(profileName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTNoEndpoints() + public async Task Exists_ProfileGETWithTrafficViewDisabled() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-NoEndpoints.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewDisabled.json + // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -429,7 +587,7 @@ public async Task CreateOrUpdate_ProfilePUTNoEndpoints() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager1421"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -437,40 +595,18 @@ public async Task CreateOrUpdate_ProfilePUTNoEndpoints() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "azsmnet6386"; - TrafficManagerProfileData data = new TrafficManagerProfileData() - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Performance, - DnsConfig = new TrafficManagerDnsConfig() - { - RelativeName = "azsmnet6386", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig() - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - }, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; + string profileName = "azuresdkfornetautoresttrafficmanager3880"; + bool result = await collection.ExistsAsync(profileName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTWithAliasing() + public async Task Exists_ProfileGETWithTrafficViewEnabled() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithAliasing.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewEnabled.json + // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -480,7 +616,7 @@ public async Task CreateOrUpdate_ProfilePUTWithAliasing() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -488,58 +624,18 @@ public async Task CreateOrUpdate_ProfilePUTWithAliasing() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager6192"; - TrafficManagerProfileData data = new TrafficManagerProfileData() - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Performance, - DnsConfig = new TrafficManagerDnsConfig() - { - RelativeName = "azuresdkfornetautoresttrafficmanager6192", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig() - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - IntervalInSeconds = 10L, - TimeoutInSeconds = 5L, - ToleratedNumberOfFailures = 2L, - }, - Endpoints = -{ -new TrafficManagerEndpointData() -{ -Target = "foobar.contoso.com", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -EndpointLocation = "North Europe", -Name = "My external endpoint", -ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), -} -}, - AllowedEndpointRecordTypes = -{ -AllowedEndpointRecordType.DomainName -}, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; + string profileName = "azuresdkfornetautoresttrafficmanager3880"; + bool result = await collection.ExistsAsync(profileName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTWithCustomHeaders() + public async Task GetIfExists_ProfileGETWithEndpoints() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithCustomHeaders.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithEndpoints.json + // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -549,7 +645,7 @@ public async Task CreateOrUpdate_ProfilePUTWithCustomHeaders() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -557,87 +653,30 @@ public async Task CreateOrUpdate_ProfilePUTWithCustomHeaders() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager6192"; - TrafficManagerProfileData data = new TrafficManagerProfileData() - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Performance, - DnsConfig = new TrafficManagerDnsConfig() - { - RelativeName = "azuresdkfornetautoresttrafficmanager6192", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig() - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - IntervalInSeconds = 10L, - TimeoutInSeconds = 5L, - ToleratedNumberOfFailures = 2L, - CustomHeaders = -{ -new TrafficManagerMonitorConfigCustomHeaderInfo() -{ -Name = "header-1", -Value = "value-1", -},new TrafficManagerMonitorConfigCustomHeaderInfo() -{ -Name = "header-2", -Value = "value-2", -} -}, - ExpectedStatusCodeRanges = -{ -new ExpectedStatusCodeRangeInfo() -{ -Min = 200, -Max = 205, -},new ExpectedStatusCodeRangeInfo() -{ -Min = 400, -Max = 410, -} -}, - }, - Endpoints = -{ -new TrafficManagerEndpointData() -{ -Target = "foobar.contoso.com", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -EndpointLocation = "North Europe", -CustomHeaders = -{ -new TrafficManagerEndpointCustomHeaderInfo() -{ -Name = "header-2", -Value = "value-2-overridden", -} -}, -Name = "My external endpoint", -ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), -} -}, - TrafficViewEnrollmentStatus = TrafficViewEnrollmentStatus.Disabled, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; + string profileName = "azuresdkfornetautoresttrafficmanager3880"; + NullableResponse response = await collection.GetIfExistsAsync(profileName); + TrafficManagerProfileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTWithEndpoints() + public async Task GetIfExists_ProfileGETWithTrafficViewDisabled() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithEndpoints.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewDisabled.json + // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -647,7 +686,7 @@ public async Task CreateOrUpdate_ProfilePUTWithEndpoints() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "azuresdkfornetautoresttrafficmanager2583"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -655,54 +694,30 @@ public async Task CreateOrUpdate_ProfilePUTWithEndpoints() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "azuresdkfornetautoresttrafficmanager6192"; - TrafficManagerProfileData data = new TrafficManagerProfileData() - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Performance, - DnsConfig = new TrafficManagerDnsConfig() - { - RelativeName = "azuresdkfornetautoresttrafficmanager6192", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig() - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - IntervalInSeconds = 10L, - TimeoutInSeconds = 5L, - ToleratedNumberOfFailures = 2L, - }, - Endpoints = -{ -new TrafficManagerEndpointData() -{ -Target = "foobar.contoso.com", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -EndpointLocation = "North Europe", -Name = "My external endpoint", -ResourceType = new ResourceType("Microsoft.network/TrafficManagerProfiles/ExternalEndpoints"), -} -}, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; + string profileName = "azuresdkfornetautoresttrafficmanager3880"; + NullableResponse response = await collection.GetIfExistsAsync(profileName); + TrafficManagerProfileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilePUTWithNestedEndpoints() + public async Task GetIfExists_ProfileGETWithTrafficViewEnabled() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-PUT-WithNestedEndpoints.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-WithTrafficViewEnabled.json + // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -712,7 +727,7 @@ public async Task CreateOrUpdate_ProfilePUTWithNestedEndpoints() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "myresourcegroup"; + string resourceGroupName = "azuresdkfornetautoresttrafficmanager1323"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -720,61 +735,22 @@ public async Task CreateOrUpdate_ProfilePUTWithNestedEndpoints() TrafficManagerProfileCollection collection = resourceGroupResource.GetTrafficManagerProfiles(); // invoke the operation - string profileName = "parentprofile"; - TrafficManagerProfileData data = new TrafficManagerProfileData() - { - ProfileStatus = TrafficManagerProfileStatus.Enabled, - TrafficRoutingMethod = TrafficRoutingMethod.Priority, - DnsConfig = new TrafficManagerDnsConfig() - { - RelativeName = "parentprofile", - Ttl = 35L, - }, - MonitorConfig = new TrafficManagerMonitorConfig() - { - Protocol = TrafficManagerMonitorProtocol.Http, - Port = 80L, - Path = "/testpath.aspx", - IntervalInSeconds = 10L, - TimeoutInSeconds = 5L, - ToleratedNumberOfFailures = 2L, - }, - Endpoints = -{ -new TrafficManagerEndpointData() -{ -Target = "firstnestedprofile.tmpreview.watmtest.azure-test.net", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -Weight = 1L, -Priority = 1L, -MinChildEndpoints = 2L, -MinChildEndpointsIPv4 = 1L, -MinChildEndpointsIPv6 = 2L, -Name = "MyFirstNestedEndpoint", -ResourceType = new ResourceType("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"), -},new TrafficManagerEndpointData() -{ -Target = "secondnestedprofile.tmpreview.watmtest.azure-test.net", -EndpointStatus = TrafficManagerEndpointStatus.Enabled, -Weight = 1L, -Priority = 2L, -MinChildEndpoints = 2L, -MinChildEndpointsIPv4 = 2L, -MinChildEndpointsIPv6 = 1L, -Name = "MySecondNestedEndpoint", -ResourceType = new ResourceType("Microsoft.Network/trafficManagerProfiles/nestedEndpoints"), -} -}, - Location = new AzureLocation("global"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrafficManagerProfileResource result = lro.Value; + string profileName = "azuresdkfornetautoresttrafficmanager3880"; + NullableResponse response = await collection.GetIfExistsAsync(profileName); + TrafficManagerProfileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerProfileResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerProfileResource.cs index f650afaa206d3..7abb9fe0f574e 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerProfileResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerProfileResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.TrafficManager.Models; using NUnit.Framework; @@ -17,149 +16,6 @@ namespace Azure.ResourceManager.TrafficManager.Samples { public partial class Sample_TrafficManagerProfileResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckTrafficManagerRelativeDnsNameAvailability_NameAvailabilityTestNameAvailablePOST21() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/NameAvailabilityTest_NameAvailable-POST-example-21.json - // this example is just showing the usage of "Profiles_CheckTrafficManagerRelativeDnsNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent() - { - Name = "azsmnet5403", - ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), - }; - TrafficManagerNameAvailabilityResult result = await tenantResource.CheckTrafficManagerRelativeDnsNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckTrafficManagerRelativeDnsNameAvailability_NameAvailabilityTestNameNotAvailablePOST23() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/NameAvailabilityTest_NameNotAvailable-POST-example-23.json - // this example is just showing the usage of "Profiles_CheckTrafficManagerRelativeDnsNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent() - { - Name = "azsmnet4696", - ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), - }; - TrafficManagerNameAvailabilityResult result = await tenantResource.CheckTrafficManagerRelativeDnsNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckTrafficManagerNameAvailabilityV2_NameAvailabilityV2TestNameAvailablePOST21() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/NameAvailabilityV2Test_NameAvailable-POST-example-21.json - // this example is just showing the usage of "Profiles_CheckTrafficManagerNameAvailabilityV2" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent() - { - Name = "azsmnet5403", - ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), - }; - TrafficManagerNameAvailabilityResult result = await subscriptionResource.CheckTrafficManagerNameAvailabilityV2Async(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckTrafficManagerNameAvailabilityV2_NameAvailabilityV2TestNameNotAvailablePOST23() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/NameAvailabilityV2Test_NameNotAvailable-POST-example-23.json - // this example is just showing the usage of "Profiles_CheckTrafficManagerNameAvailabilityV2" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - TrafficManagerRelativeDnsNameAvailabilityContent content = new TrafficManagerRelativeDnsNameAvailabilityContent() - { - Name = "azsmnet4696", - ResourceType = new ResourceType("microsoft.network/trafficmanagerprofiles"), - }; - TrafficManagerNameAvailabilityResult result = await subscriptionResource.CheckTrafficManagerNameAvailabilityV2Async(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetTrafficManagerProfiles_ListBySubscription() - { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/Profile-GET-BySubscription.json - // this example is just showing the usage of "Profiles_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (TrafficManagerProfileResource item in subscriptionResource.GetTrafficManagerProfilesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ProfileGETWithEndpoints() @@ -297,9 +153,9 @@ public async Task Update_ProfilePATCHMonitorConfig() TrafficManagerProfileResource trafficManagerProfile = client.GetTrafficManagerProfileResource(trafficManagerProfileResourceId); // invoke the operation - TrafficManagerProfileData data = new TrafficManagerProfileData() + TrafficManagerProfileData data = new TrafficManagerProfileData { - MonitorConfig = new TrafficManagerMonitorConfig() + MonitorConfig = new TrafficManagerMonitorConfig { Protocol = TrafficManagerMonitorProtocol.Http, Port = 80L, @@ -307,18 +163,15 @@ public async Task Update_ProfilePATCHMonitorConfig() IntervalInSeconds = 30L, TimeoutInSeconds = 6L, ToleratedNumberOfFailures = 4L, - CustomHeaders = -{ -new TrafficManagerMonitorConfigCustomHeaderInfo() + CustomHeaders = {new TrafficManagerMonitorConfigCustomHeaderInfo { Name = "header-1", Value = "value-1", -},new TrafficManagerMonitorConfigCustomHeaderInfo() +}, new TrafficManagerMonitorConfigCustomHeaderInfo { Name = "header-2", Value = "value-2", -} -}, +}}, }, }; TrafficManagerProfileResource result = await trafficManagerProfile.UpdateAsync(data); diff --git a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerUserMetricsResource.cs b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerUserMetricsResource.cs index 0b160839101a0..58acbf5b06e8b 100644 --- a/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerUserMetricsResource.cs +++ b/sdk/trafficmanager/Azure.ResourceManager.TrafficManager/samples/Generated/Samples/Sample_TrafficManagerUserMetricsResource.cs @@ -45,10 +45,10 @@ public async Task Get_TrafficManagerUserMetricsKeysGET() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TrafficManagerUserMetricsKeysPUT() + public async Task Delete_TrafficManagerUserMetricsKeysDELETE() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/TrafficManagerUserMetricsKeys-PUT.json - // this example is just showing the usage of "TrafficManagerUserMetricsKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/TrafficManagerUserMetricsKeys-DELETE.json + // this example is just showing the usage of "TrafficManagerUserMetricsKeys_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,22 +62,17 @@ public async Task CreateOrUpdate_TrafficManagerUserMetricsKeysPUT() TrafficManagerUserMetricsResource trafficManagerUserMetrics = client.GetTrafficManagerUserMetricsResource(trafficManagerUserMetricsResourceId); // invoke the operation - ArmOperation lro = await trafficManagerUserMetrics.CreateOrUpdateAsync(WaitUntil.Completed); - TrafficManagerUserMetricsResource result = lro.Value; + await trafficManagerUserMetrics.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficManagerUserMetricData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_TrafficManagerUserMetricsKeysDELETE() + public async Task CreateOrUpdate_TrafficManagerUserMetricsKeysPUT() { - // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/TrafficManagerUserMetricsKeys-DELETE.json - // this example is just showing the usage of "TrafficManagerUserMetricsKeys_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/trafficmanager/resource-manager/Microsoft.Network/stable/2022-04-01/examples/TrafficManagerUserMetricsKeys-PUT.json + // this example is just showing the usage of "TrafficManagerUserMetricsKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,9 +86,14 @@ public async Task Delete_TrafficManagerUserMetricsKeysDELETE() TrafficManagerUserMetricsResource trafficManagerUserMetrics = client.GetTrafficManagerUserMetricsResource(trafficManagerUserMetricsResourceId); // invoke the operation - await trafficManagerUserMetrics.DeleteAsync(WaitUntil.Completed); + ArmOperation lro = await trafficManagerUserMetrics.CreateOrUpdateAsync(WaitUntil.Completed); + TrafficManagerUserMetricsResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficManagerUserMetricData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..856b0d8ba154b --- /dev/null +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.TrustedSigning.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.TrustedSigning.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckTrustedSigningAccountNameAvailability_ChecksThatTheTrustedSigningAccountNameIsAvailable() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_CheckNameAvailability.json + // this example is just showing the usage of "CodeSigningAccounts_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + TrustedSigningAccountNameAvailabilityContent content = new TrustedSigningAccountNameAvailabilityContent("sample-account", default); + TrustedSigningAccountNameAvailabilityResult result = await subscriptionResource.CheckTrustedSigningAccountNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetTrustedSigningAccounts_ListsTrustedSigningAccountsWithinASubscription() + { + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_ListBySubscription.json + // this example is just showing the usage of "CodeSigningAccounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (TrustedSigningAccountResource item in subscriptionResource.GetTrustedSigningAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrustedSigningAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountCollection.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountCollection.cs index f8dcabd0d3067..0b19adcd530bf 100644 --- a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountCollection.cs +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_TrustedSigningAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTrustedSigningAccountsWithinAResourceGroup() + public async Task CreateOrUpdate_CreateATrustedSigningAccount() { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_ListByResourceGroup.json - // this example is just showing the usage of "CodeSigningAccounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Create.json + // this example is just showing the usage of "CodeSigningAccounts_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ListsTrustedSigningAccountsWithinAResourceGroup() // get the collection of this TrustedSigningAccountResource TrustedSigningAccountCollection collection = resourceGroupResource.GetTrustedSigningAccounts(); - // invoke the operation and iterate over the result - await foreach (TrustedSigningAccountResource item in collection.GetAllAsync()) + // invoke the operation + string accountName = "MyAccount"; + TrustedSigningAccountData data = new TrustedSigningAccountData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrustedSigningAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SkuName = TrustedSigningSkuName.Basic, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + TrustedSigningAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrustedSigningAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetATrustedSigningAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetATrustedSigningAccount() + public async Task GetAll_ListsTrustedSigningAccountsWithinAResourceGroup() { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Get.json - // this example is just showing the usage of "CodeSigningAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_ListByResourceGroup.json + // this example is just showing the usage of "CodeSigningAccounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +110,22 @@ public async Task Exists_GetATrustedSigningAccount() // get the collection of this TrustedSigningAccountResource TrustedSigningAccountCollection collection = resourceGroupResource.GetTrustedSigningAccounts(); - // invoke the operation - string accountName = "MyAccount"; - bool result = await collection.ExistsAsync(accountName); + // invoke the operation and iterate over the result + await foreach (TrustedSigningAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrustedSigningAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetATrustedSigningAccount() + public async Task Exists_GetATrustedSigningAccount() { // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Get.json // this example is just showing the usage of "CodeSigningAccounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +147,17 @@ public async Task GetIfExists_GetATrustedSigningAccount() // invoke the operation string accountName = "MyAccount"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - TrustedSigningAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrustedSigningAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateATrustedSigningAccount() + public async Task GetIfExists_GetATrustedSigningAccount() { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Create.json - // this example is just showing the usage of "CodeSigningAccounts_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Get.json + // this example is just showing the usage of "CodeSigningAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,18 +176,21 @@ public async Task CreateOrUpdate_CreateATrustedSigningAccount() // invoke the operation string accountName = "MyAccount"; - TrustedSigningAccountData data = new TrustedSigningAccountData(new AzureLocation("westus")) - { - SkuName = TrustedSigningSkuName.Basic, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); - TrustedSigningAccountResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + TrustedSigningAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrustedSigningAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrustedSigningAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountResource.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountResource.cs index 12c9679d4fee9..cce5514fc8a77 100644 --- a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountResource.cs +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningAccountResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.TrustedSigning.Models; using NUnit.Framework; @@ -17,62 +16,6 @@ namespace Azure.ResourceManager.TrustedSigning.Samples { public partial class Sample_TrustedSigningAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckTrustedSigningAccountNameAvailability_ChecksThatTheTrustedSigningAccountNameIsAvailable() - { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_CheckNameAvailability.json - // this example is just showing the usage of "CodeSigningAccounts_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - TrustedSigningAccountNameAvailabilityContent content = new TrustedSigningAccountNameAvailabilityContent("sample-account", new ResourceType("placeholder")); - TrustedSigningAccountNameAvailabilityResult result = await subscriptionResource.CheckTrustedSigningAccountNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetTrustedSigningAccounts_ListsTrustedSigningAccountsWithinASubscription() - { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_ListBySubscription.json - // this example is just showing the usage of "CodeSigningAccounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (TrustedSigningAccountResource item in subscriptionResource.GetTrustedSigningAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrustedSigningAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetATrustedSigningAccount() @@ -105,10 +48,10 @@ public async Task Get_GetATrustedSigningAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateATrustedSigningAccount() + public async Task Delete_DeleteATrustedSigningAccount() { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Update.json - // this example is just showing the usage of "CodeSigningAccounts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Delete.json + // this example is just showing the usage of "CodeSigningAccounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -124,29 +67,17 @@ public async Task Update_UpdateATrustedSigningAccount() TrustedSigningAccountResource trustedSigningAccount = client.GetTrustedSigningAccountResource(trustedSigningAccountResourceId); // invoke the operation - TrustedSigningAccountPatch patch = new TrustedSigningAccountPatch() - { - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await trustedSigningAccount.UpdateAsync(WaitUntil.Completed, patch); - TrustedSigningAccountResource result = lro.Value; + await trustedSigningAccount.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrustedSigningAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteATrustedSigningAccount() + public async Task Update_UpdateATrustedSigningAccount() { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Delete.json - // this example is just showing the usage of "CodeSigningAccounts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CodeSigningAccounts_Update.json + // this example is just showing the usage of "CodeSigningAccounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -162,9 +93,21 @@ public async Task Delete_DeleteATrustedSigningAccount() TrustedSigningAccountResource trustedSigningAccount = client.GetTrustedSigningAccountResource(trustedSigningAccountResourceId); // invoke the operation - await trustedSigningAccount.DeleteAsync(WaitUntil.Completed); + TrustedSigningAccountPatch patch = new TrustedSigningAccountPatch + { + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await trustedSigningAccount.UpdateAsync(WaitUntil.Completed, patch); + TrustedSigningAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrustedSigningAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileCollection.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileCollection.cs index df694ce902be2..c2e2a7fb9d9b2 100644 --- a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileCollection.cs +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_TrustedSigningCertificateProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCertificateProfilesUnderATrustedSigningAccount() + public async Task CreateOrUpdate_CreateACertificateProfile() { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_ListByCodeSigningAccount.json - // this example is just showing the usage of "CertificateProfiles_ListByCodeSigningAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Create.json + // this example is just showing the usage of "CertificateProfiles_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_ListCertificateProfilesUnderATrustedSigningAccount() // get the collection of this TrustedSigningCertificateProfileResource TrustedSigningCertificateProfileCollection collection = trustedSigningAccount.GetTrustedSigningCertificateProfiles(); - // invoke the operation and iterate over the result - await foreach (TrustedSigningCertificateProfileResource item in collection.GetAllAsync()) + // invoke the operation + string profileName = "profileA"; + TrustedSigningCertificateProfileData data = new TrustedSigningCertificateProfileData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrustedSigningCertificateProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProfileType = CertificateProfileType.PublicTrust, + IncludeStreetAddress = false, + IncludePostalCode = true, + IdentityValidationId = "00000000-1234-5678-3333-444444444444", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + TrustedSigningCertificateProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrustedSigningCertificateProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +94,10 @@ public async Task Get_GetDetailsOfACertificateProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfACertificateProfile() + public async Task GetAll_ListCertificateProfilesUnderATrustedSigningAccount() { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Get.json - // this example is just showing the usage of "CertificateProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_ListByCodeSigningAccount.json + // this example is just showing the usage of "CertificateProfiles_ListByCodeSigningAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +115,22 @@ public async Task Exists_GetDetailsOfACertificateProfile() // get the collection of this TrustedSigningCertificateProfileResource TrustedSigningCertificateProfileCollection collection = trustedSigningAccount.GetTrustedSigningCertificateProfiles(); - // invoke the operation - string profileName = "profileA"; - bool result = await collection.ExistsAsync(profileName); + // invoke the operation and iterate over the result + await foreach (TrustedSigningCertificateProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrustedSigningCertificateProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfACertificateProfile() + public async Task Exists_GetDetailsOfACertificateProfile() { // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Get.json // this example is just showing the usage of "CertificateProfiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +153,17 @@ public async Task GetIfExists_GetDetailsOfACertificateProfile() // invoke the operation string profileName = "profileA"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - TrustedSigningCertificateProfileResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(profileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrustedSigningCertificateProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateACertificateProfile() + public async Task GetIfExists_GetDetailsOfACertificateProfile() { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Create.json - // this example is just showing the usage of "CertificateProfiles_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Get.json + // this example is just showing the usage of "CertificateProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,21 +183,21 @@ public async Task CreateOrUpdate_CreateACertificateProfile() // invoke the operation string profileName = "profileA"; - TrustedSigningCertificateProfileData data = new TrustedSigningCertificateProfileData() - { - ProfileType = CertificateProfileType.PublicTrust, - IncludeStreetAddress = false, - IncludePostalCode = true, - IdentityValidationId = "00000000-1234-5678-3333-444444444444", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - TrustedSigningCertificateProfileResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(profileName); + TrustedSigningCertificateProfileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrustedSigningCertificateProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrustedSigningCertificateProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileResource.cs b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileResource.cs index 792f9ed374e8f..bf6a87b710d64 100644 --- a/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileResource.cs +++ b/sdk/trustedsigning/Azure.ResourceManager.TrustedSigning/samples/Generated/Samples/Sample_TrustedSigningCertificateProfileResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetDetailsOfACertificateProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateACertificateProfile() + public async Task Delete_DeleteACertificateProfile() { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Create.json - // this example is just showing the usage of "CertificateProfiles_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Delete.json + // this example is just showing the usage of "CertificateProfiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_CreateACertificateProfile() TrustedSigningCertificateProfileResource trustedSigningCertificateProfile = client.GetTrustedSigningCertificateProfileResource(trustedSigningCertificateProfileResourceId); // invoke the operation - TrustedSigningCertificateProfileData data = new TrustedSigningCertificateProfileData() - { - ProfileType = CertificateProfileType.PublicTrust, - IncludeStreetAddress = false, - IncludePostalCode = true, - IdentityValidationId = "00000000-1234-5678-3333-444444444444", - }; - ArmOperation lro = await trustedSigningCertificateProfile.UpdateAsync(WaitUntil.Completed, data); - TrustedSigningCertificateProfileResource result = lro.Value; + await trustedSigningCertificateProfile.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrustedSigningCertificateProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACertificateProfile() + public async Task Update_CreateACertificateProfile() { - // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Delete.json - // this example is just showing the usage of "CertificateProfiles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/codesigning/resource-manager/Microsoft.CodeSigning/preview/2024-02-05-preview/examples/CertificateProfiles_Create.json + // this example is just showing the usage of "CertificateProfiles_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DeleteACertificateProfile() TrustedSigningCertificateProfileResource trustedSigningCertificateProfile = client.GetTrustedSigningCertificateProfileResource(trustedSigningCertificateProfileResourceId); // invoke the operation - await trustedSigningCertificateProfile.DeleteAsync(WaitUntil.Completed); + TrustedSigningCertificateProfileData data = new TrustedSigningCertificateProfileData + { + ProfileType = CertificateProfileType.PublicTrust, + IncludeStreetAddress = false, + IncludePostalCode = true, + IdentityValidationId = "00000000-1234-5678-3333-444444444444", + }; + ArmOperation lro = await trustedSigningCertificateProfile.UpdateAsync(WaitUntil.Completed, data); + TrustedSigningCertificateProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrustedSigningCertificateProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index c94e2f9c56443..98507acf6158d 100644 --- a/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.VoiceServices.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVoiceServicesCommunicationsGateways_ListCommunicationsGatewayResourceSub() + { + // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_ListBySubscription.json + // this example is just showing the usage of "CommunicationsGateways_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VoiceServicesCommunicationsGatewayResource item in subscriptionResource.GetVoiceServicesCommunicationsGatewaysAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VoiceServicesCommunicationsGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CheckVoiceServicesNameAvailability_CheckLocalNameAvailability() @@ -37,7 +68,7 @@ public async Task CheckVoiceServicesNameAvailability_CheckLocalNameAvailability( // invoke the operation AzureLocation location = new AzureLocation("useast"); - VoiceServicesCheckNameAvailabilityContent content = new VoiceServicesCheckNameAvailabilityContent() + VoiceServicesCheckNameAvailabilityContent content = new VoiceServicesCheckNameAvailabilityContent { Name = "myname", ResourceType = new ResourceType("Microsoft.VoiceServices/CommunicationsGateway"), diff --git a/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesCommunicationsGatewayCollection.cs b/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesCommunicationsGatewayCollection.cs index fa0d7d215fcf2..d601f468e512f 100644 --- a/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesCommunicationsGatewayCollection.cs +++ b/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesCommunicationsGatewayCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_VoiceServicesCommunicationsGatewayCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCommunicationsGatewayResource() + public async Task CreateOrUpdate_CreateCommunicationsGatewayResource() { - // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_ListByResourceGroup.json - // this example is just showing the usage of "CommunicationsGateways_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_CreateOrUpdate.json + // this example is just showing the usage of "CommunicationsGateways_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,34 @@ public async Task GetAll_ListCommunicationsGatewayResource() // get the collection of this VoiceServicesCommunicationsGatewayResource VoiceServicesCommunicationsGatewayCollection collection = resourceGroupResource.GetVoiceServicesCommunicationsGateways(); - // invoke the operation and iterate over the result - await foreach (VoiceServicesCommunicationsGatewayResource item in collection.GetAllAsync()) + // invoke the operation + string communicationsGatewayName = "myname"; + VoiceServicesCommunicationsGatewayData data = new VoiceServicesCommunicationsGatewayData(new AzureLocation("useast")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VoiceServicesCommunicationsGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServiceLocations = {new VoiceServicesServiceRegionProperties("useast", new VoiceServicesPrimaryRegionProperties(new string[]{"198.51.100.1"}) +{ +AllowedSignalingSourceAddressPrefixes = {"10.1.1.0/24"}, +AllowedMediaSourceAddressPrefixes = {"10.1.2.0/24"}, +}), new VoiceServicesServiceRegionProperties("useast2", new VoiceServicesPrimaryRegionProperties(new string[]{"198.51.100.2"}) +{ +AllowedSignalingSourceAddressPrefixes = {"10.2.1.0/24"}, +AllowedMediaSourceAddressPrefixes = {"10.2.2.0/24"}, +})}, + Connectivity = VoiceServicesCommunicationsGatewayConnectivity.PublicAddress, + Codecs = { VoiceServicesTeamsCodec.Pcma }, + E911Type = VoiceServicesEmergencyCallType.Standard, + Platforms = { VoiceServicesCommunicationsPlatform.OperatorConnect }, + AutoGeneratedDomainNameLabelScope = VoiceServicesAutoGeneratedDomainNameLabelScope.NoReuse, + TeamsVoicemailPilotNumber = "1234567890", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationsGatewayName, data); + VoiceServicesCommunicationsGatewayResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VoiceServicesCommunicationsGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +104,10 @@ public async Task Get_GetCommunicationsGatewayResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCommunicationsGatewayResource() + public async Task GetAll_ListCommunicationsGatewayResource() { - // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_Get.json - // this example is just showing the usage of "CommunicationsGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_ListByResourceGroup.json + // this example is just showing the usage of "CommunicationsGateways_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +124,22 @@ public async Task Exists_GetCommunicationsGatewayResource() // get the collection of this VoiceServicesCommunicationsGatewayResource VoiceServicesCommunicationsGatewayCollection collection = resourceGroupResource.GetVoiceServicesCommunicationsGateways(); - // invoke the operation - string communicationsGatewayName = "myname"; - bool result = await collection.ExistsAsync(communicationsGatewayName); + // invoke the operation and iterate over the result + await foreach (VoiceServicesCommunicationsGatewayResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VoiceServicesCommunicationsGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCommunicationsGatewayResource() + public async Task Exists_GetCommunicationsGatewayResource() { // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_Get.json // this example is just showing the usage of "CommunicationsGateways_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +161,17 @@ public async Task GetIfExists_GetCommunicationsGatewayResource() // invoke the operation string communicationsGatewayName = "myname"; - NullableResponse response = await collection.GetIfExistsAsync(communicationsGatewayName); - VoiceServicesCommunicationsGatewayResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(communicationsGatewayName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VoiceServicesCommunicationsGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCommunicationsGatewayResource() + public async Task GetIfExists_GetCommunicationsGatewayResource() { - // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_CreateOrUpdate.json - // this example is just showing the usage of "CommunicationsGateways_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_Get.json + // this example is just showing the usage of "CommunicationsGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,59 +190,21 @@ public async Task CreateOrUpdate_CreateCommunicationsGatewayResource() // invoke the operation string communicationsGatewayName = "myname"; - VoiceServicesCommunicationsGatewayData data = new VoiceServicesCommunicationsGatewayData(new AzureLocation("useast")) - { - ServiceLocations = -{ -new VoiceServicesServiceRegionProperties("useast",new VoiceServicesPrimaryRegionProperties(new string[] -{ -"198.51.100.1" -}) -{ -AllowedSignalingSourceAddressPrefixes = -{ -"10.1.1.0/24" -}, -AllowedMediaSourceAddressPrefixes = -{ -"10.1.2.0/24" -}, -}),new VoiceServicesServiceRegionProperties("useast2",new VoiceServicesPrimaryRegionProperties(new string[] -{ -"198.51.100.2" -}) -{ -AllowedSignalingSourceAddressPrefixes = -{ -"10.2.1.0/24" -}, -AllowedMediaSourceAddressPrefixes = -{ -"10.2.2.0/24" -}, -}) -}, - Connectivity = VoiceServicesCommunicationsGatewayConnectivity.PublicAddress, - Codecs = -{ -VoiceServicesTeamsCodec.Pcma -}, - E911Type = VoiceServicesEmergencyCallType.Standard, - Platforms = -{ -VoiceServicesCommunicationsPlatform.OperatorConnect -}, - AutoGeneratedDomainNameLabelScope = VoiceServicesAutoGeneratedDomainNameLabelScope.NoReuse, - TeamsVoicemailPilotNumber = "1234567890", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationsGatewayName, data); - VoiceServicesCommunicationsGatewayResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(communicationsGatewayName); + VoiceServicesCommunicationsGatewayResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VoiceServicesCommunicationsGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VoiceServicesCommunicationsGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesCommunicationsGatewayResource.cs b/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesCommunicationsGatewayResource.cs index dd34ce6d1799a..a799ea68ba232 100644 --- a/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesCommunicationsGatewayResource.cs +++ b/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesCommunicationsGatewayResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.VoiceServices.Models; using NUnit.Framework; @@ -17,37 +16,6 @@ namespace Azure.ResourceManager.VoiceServices.Samples { public partial class Sample_VoiceServicesCommunicationsGatewayResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVoiceServicesCommunicationsGateways_ListCommunicationsGatewayResourceSub() - { - // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/CommunicationsGateways_ListBySubscription.json - // this example is just showing the usage of "CommunicationsGateways_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VoiceServicesCommunicationsGatewayResource item in subscriptionResource.GetVoiceServicesCommunicationsGatewaysAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VoiceServicesCommunicationsGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetCommunicationsGatewayResource() diff --git a/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesTestLineCollection.cs b/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesTestLineCollection.cs index d34172d27b703..437705916760f 100644 --- a/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesTestLineCollection.cs +++ b/sdk/voiceservices/Azure.ResourceManager.VoiceServices/samples/Generated/Samples/Sample_VoiceServicesTestLineCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VoiceServicesTestLineCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTestLineResource() + public async Task CreateOrUpdate_CreateTestLineResource() { - // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_ListByCommunicationsGateway.json - // this example is just showing the usage of "TestLines_ListByCommunicationsGateway" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_CreateOrUpdate.json + // this example is just showing the usage of "TestLines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ListTestLineResource() // get the collection of this VoiceServicesTestLineResource VoiceServicesTestLineCollection collection = voiceServicesCommunicationsGateway.GetVoiceServicesTestLines(); - // invoke the operation and iterate over the result - await foreach (VoiceServicesTestLineResource item in collection.GetAllAsync()) + // invoke the operation + string testLineName = "myline"; + VoiceServicesTestLineData data = new VoiceServicesTestLineData(new AzureLocation("useast")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VoiceServicesTestLineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PhoneNumber = "+1-555-1234", + Purpose = VoiceServicesTestLinePurpose.Automated, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, testLineName, data); + VoiceServicesTestLineResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VoiceServicesTestLineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_GetTestLineResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTestLineResource() + public async Task GetAll_ListTestLineResource() { - // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_Get.json - // this example is just showing the usage of "TestLines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_ListByCommunicationsGateway.json + // this example is just showing the usage of "TestLines_ListByCommunicationsGateway" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +113,22 @@ public async Task Exists_GetTestLineResource() // get the collection of this VoiceServicesTestLineResource VoiceServicesTestLineCollection collection = voiceServicesCommunicationsGateway.GetVoiceServicesTestLines(); - // invoke the operation - string testLineName = "myline"; - bool result = await collection.ExistsAsync(testLineName); + // invoke the operation and iterate over the result + await foreach (VoiceServicesTestLineResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VoiceServicesTestLineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTestLineResource() + public async Task Exists_GetTestLineResource() { // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_Get.json // this example is just showing the usage of "TestLines_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_GetTestLineResource() // invoke the operation string testLineName = "myline"; - NullableResponse response = await collection.GetIfExistsAsync(testLineName); - VoiceServicesTestLineResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(testLineName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VoiceServicesTestLineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateTestLineResource() + public async Task GetIfExists_GetTestLineResource() { - // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_CreateOrUpdate.json - // this example is just showing the usage of "TestLines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/voiceservices/resource-manager/Microsoft.VoiceServices/stable/2023-01-31/examples/TestLines_Get.json + // this example is just showing the usage of "TestLines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,19 +181,21 @@ public async Task CreateOrUpdate_CreateTestLineResource() // invoke the operation string testLineName = "myline"; - VoiceServicesTestLineData data = new VoiceServicesTestLineData(new AzureLocation("useast")) - { - PhoneNumber = "+1-555-1234", - Purpose = VoiceServicesTestLinePurpose.Automated, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, testLineName, data); - VoiceServicesTestLineResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(testLineName); + VoiceServicesTestLineResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VoiceServicesTestLineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VoiceServicesTestLineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 6a6b3043f2fcc..e23708eefc8b0 100644 --- a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,63 @@ namespace Azure.ResourceManager.WebPubSub.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckWebPubSubNameAvailability_WebPubSubCheckNameAvailability() + { + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_CheckNameAvailability.json + // this example is just showing the usage of "WebPubSub_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("eastus"); + WebPubSubNameAvailabilityContent content = new WebPubSubNameAvailabilityContent("Microsoft.SignalRService/WebPubSub", "myWebPubSubService"); + WebPubSubNameAvailability result = await subscriptionResource.CheckWebPubSubNameAvailabilityAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetWebPubSubs_WebPubSubListBySubscription() + { + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_ListBySubscription.json + // this example is just showing the usage of "WebPubSub_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (WebPubSubResource item in subscriptionResource.GetWebPubSubsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetUsages_UsagesList() diff --git a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubCollection.cs b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubCollection.cs index ab2af150eb21a..aae0a90afddf9 100644 --- a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubCollection.cs +++ b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_WebPubSubCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WebPubSubListByResourceGroup() + public async Task CreateOrUpdate_WebPubSubCreateOrUpdate() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_ListByResourceGroup.json - // this example is just showing the usage of "WebPubSub_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_CreateOrUpdate.json + // this example is just showing the usage of "WebPubSub_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,52 @@ public async Task GetAll_WebPubSubListByResourceGroup() // get the collection of this WebPubSubResource WebPubSubCollection collection = resourceGroupResource.GetWebPubSubs(); - // invoke the operation and iterate over the result - await foreach (WebPubSubResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "myWebPubSubService"; + WebPubSubData data = new WebPubSubData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new BillingInfoSku("Standard_S1") + { + Tier = WebPubSubSkuTier.Standard, + Capacity = 1, + }, + Identity = new ManagedServiceIdentity("SystemAssigned"), + IsClientCertEnabled = false, + LiveTraceConfiguration = new LiveTraceConfiguration + { + Categories = {new LiveTraceCategory +{ +Name = "ConnectivityLogs", +}}, + }, + NetworkAcls = new WebPubSubNetworkAcls + { + DefaultAction = AclAction.Deny, + PublicNetwork = new PublicNetworkAcls + { + Allow = { WebPubSubRequestType.ClientConnection }, + }, + PrivateEndpoints = {new PrivateEndpointAcl("mywebpubsubservice.1fa229cd-bf3f-47f0-8c49-afb36723997e") +{ +Allow = {WebPubSubRequestType.ServerConnection}, +}}, + }, + PublicNetworkAccess = "Enabled", + IsLocalAuthDisabled = false, + IsAadAuthDisabled = false, + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + WebPubSubResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +123,10 @@ public async Task Get_WebPubSubGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WebPubSubGet() + public async Task GetAll_WebPubSubListByResourceGroup() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_Get.json - // this example is just showing the usage of "WebPubSub_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_ListByResourceGroup.json + // this example is just showing the usage of "WebPubSub_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +143,22 @@ public async Task Exists_WebPubSubGet() // get the collection of this WebPubSubResource WebPubSubCollection collection = resourceGroupResource.GetWebPubSubs(); - // invoke the operation - string resourceName = "myWebPubSubService"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (WebPubSubResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WebPubSubGet() + public async Task Exists_WebPubSubGet() { // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_Get.json // this example is just showing the usage of "WebPubSub_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +180,17 @@ public async Task GetIfExists_WebPubSubGet() // invoke the operation string resourceName = "myWebPubSubService"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - WebPubSubResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WebPubSubCreateOrUpdate() + public async Task GetIfExists_WebPubSubGet() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_CreateOrUpdate.json - // this example is just showing the usage of "WebPubSub_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_Get.json + // this example is just showing the usage of "WebPubSub_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,62 +209,21 @@ public async Task CreateOrUpdate_WebPubSubCreateOrUpdate() // invoke the operation string resourceName = "myWebPubSubService"; - WebPubSubData data = new WebPubSubData(new AzureLocation("eastus")) - { - Sku = new BillingInfoSku("Standard_S1") - { - Tier = WebPubSubSkuTier.Standard, - Capacity = 1, - }, - Identity = new ManagedServiceIdentity("SystemAssigned"), - IsClientCertEnabled = false, - LiveTraceConfiguration = new LiveTraceConfiguration() - { - Categories = -{ -new LiveTraceCategory() -{ -Name = "ConnectivityLogs", -} -}, - }, - NetworkAcls = new WebPubSubNetworkAcls() - { - DefaultAction = AclAction.Deny, - PublicNetwork = new PublicNetworkAcls() - { - Allow = -{ -WebPubSubRequestType.ClientConnection -}, - }, - PrivateEndpoints = -{ -new PrivateEndpointAcl("mywebpubsubservice.1fa229cd-bf3f-47f0-8c49-afb36723997e") -{ -Allow = -{ -WebPubSubRequestType.ServerConnection -}, -} -}, - }, - PublicNetworkAccess = "Enabled", - IsLocalAuthDisabled = false, - IsAadAuthDisabled = false, - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - WebPubSubResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + WebPubSubResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubHubCollection.cs b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubHubCollection.cs index be720b7e366b0..0059efa5a684a 100644 --- a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubHubCollection.cs +++ b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubHubCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_WebPubSubHubCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WebPubSubHubsList() + public async Task CreateOrUpdate_WebPubSubHubsCreateOrUpdate() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_List.json - // this example is just showing the usage of "WebPubSubHubs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_CreateOrUpdate.json + // this example is just showing the usage of "WebPubSubHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,29 @@ public async Task GetAll_WebPubSubHubsList() // get the collection of this WebPubSubHubResource WebPubSubHubCollection collection = webPubSub.GetWebPubSubHubs(); - // invoke the operation and iterate over the result - await foreach (WebPubSubHubResource item in collection.GetAllAsync()) + // invoke the operation + string hubName = "exampleHub"; + WebPubSubHubData data = new WebPubSubHubData(new WebPubSubHubProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubHubData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EventHandlers = {new WebPubSubEventHandler("http://host.com") +{ +UserEventPattern = "*", +SystemEvents = {"connect", "connected"}, +Auth = new UpstreamAuthSettings +{ +AuthType = UpstreamAuthType.ManagedIdentity, +ManagedIdentityResource = "abc", +}, +}}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hubName, data); + WebPubSubHubResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +100,10 @@ public async Task Get_WebPubSubHubsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WebPubSubHubsGet() + public async Task GetAll_WebPubSubHubsList() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_Get.json - // this example is just showing the usage of "WebPubSubHubs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_List.json + // this example is just showing the usage of "WebPubSubHubs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +121,22 @@ public async Task Exists_WebPubSubHubsGet() // get the collection of this WebPubSubHubResource WebPubSubHubCollection collection = webPubSub.GetWebPubSubHubs(); - // invoke the operation - string hubName = "exampleHub"; - bool result = await collection.ExistsAsync(hubName); + // invoke the operation and iterate over the result + await foreach (WebPubSubHubResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubHubData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WebPubSubHubsGet() + public async Task Exists_WebPubSubHubsGet() { // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_Get.json // this example is just showing the usage of "WebPubSubHubs_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +159,17 @@ public async Task GetIfExists_WebPubSubHubsGet() // invoke the operation string hubName = "exampleHub"; - NullableResponse response = await collection.GetIfExistsAsync(hubName); - WebPubSubHubResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(hubName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WebPubSubHubsCreateOrUpdate() + public async Task GetIfExists_WebPubSubHubsGet() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_CreateOrUpdate.json - // this example is just showing the usage of "WebPubSubHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_Get.json + // this example is just showing the usage of "WebPubSubHubs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,33 +189,21 @@ public async Task CreateOrUpdate_WebPubSubHubsCreateOrUpdate() // invoke the operation string hubName = "exampleHub"; - WebPubSubHubData data = new WebPubSubHubData(new WebPubSubHubProperties() - { - EventHandlers = -{ -new WebPubSubEventHandler("http://host.com") -{ -UserEventPattern = "*", -SystemEvents = -{ -"connect","connected" -}, -Auth = new UpstreamAuthSettings() -{ -AuthType = UpstreamAuthType.ManagedIdentity, -ManagedIdentityResource = "abc", -}, -} -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hubName, data); - WebPubSubHubResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(hubName); + WebPubSubHubResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubHubResource.cs b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubHubResource.cs index 5c65687627a70..0b9327ea05bb3 100644 --- a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubHubResource.cs +++ b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubHubResource.cs @@ -49,10 +49,10 @@ public async Task Get_WebPubSubHubsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WebPubSubHubsCreateOrUpdate() + public async Task Delete_WebPubSubHubsDelete() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_CreateOrUpdate.json - // this example is just showing the usage of "WebPubSubHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_Delete.json + // this example is just showing the usage of "WebPubSubHubs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,41 +69,17 @@ public async Task Update_WebPubSubHubsCreateOrUpdate() WebPubSubHubResource webPubSubHub = client.GetWebPubSubHubResource(webPubSubHubResourceId); // invoke the operation - WebPubSubHubData data = new WebPubSubHubData(new WebPubSubHubProperties() - { - EventHandlers = -{ -new WebPubSubEventHandler("http://host.com") -{ -UserEventPattern = "*", -SystemEvents = -{ -"connect","connected" -}, -Auth = new UpstreamAuthSettings() -{ -AuthType = UpstreamAuthType.ManagedIdentity, -ManagedIdentityResource = "abc", -}, -} -}, - }); - ArmOperation lro = await webPubSubHub.UpdateAsync(WaitUntil.Completed, data); - WebPubSubHubResource result = lro.Value; + await webPubSubHub.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WebPubSubHubsDelete() + public async Task Update_WebPubSubHubsCreateOrUpdate() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_Delete.json - // this example is just showing the usage of "WebPubSubHubs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubHubs_CreateOrUpdate.json + // this example is just showing the usage of "WebPubSubHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,9 +96,27 @@ public async Task Delete_WebPubSubHubsDelete() WebPubSubHubResource webPubSubHub = client.GetWebPubSubHubResource(webPubSubHubResourceId); // invoke the operation - await webPubSubHub.DeleteAsync(WaitUntil.Completed); + WebPubSubHubData data = new WebPubSubHubData(new WebPubSubHubProperties + { + EventHandlers = {new WebPubSubEventHandler("http://host.com") +{ +UserEventPattern = "*", +SystemEvents = {"connect", "connected"}, +Auth = new UpstreamAuthSettings +{ +AuthType = UpstreamAuthType.ManagedIdentity, +ManagedIdentityResource = "abc", +}, +}}, + }); + ArmOperation lro = await webPubSubHub.UpdateAsync(WaitUntil.Completed, data); + WebPubSubHubResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubPrivateEndpointConnectionCollection.cs b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubPrivateEndpointConnectionCollection.cs index 4eb53b593444c..55fb41fb4fe62 100644 --- a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubPrivateEndpointConnectionCollection.cs +++ b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_WebPubSubPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WebPubSubPrivateEndpointConnectionsList() + public async Task CreateOrUpdate_WebPubSubPrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_List.json - // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_Update.json + // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_WebPubSubPrivateEndpointConnectionsList() // get the collection of this WebPubSubPrivateEndpointConnectionResource WebPubSubPrivateEndpointConnectionCollection collection = webPubSub.GetWebPubSubPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (WebPubSubPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "mywebpubsubservice.1fa229cd-bf3f-47f0-8c49-afb36723997e"; + WebPubSubPrivateEndpointConnectionData data = new WebPubSubPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrivateEndpointId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint"), + ConnectionState = new WebPubSubPrivateLinkServiceConnectionState + { + Status = WebPubSubPrivateLinkServiceConnectionStatus.Approved, + ActionsRequired = "None", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + WebPubSubPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_WebPubSubPrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WebPubSubPrivateEndpointConnectionsGet() + public async Task GetAll_WebPubSubPrivateEndpointConnectionsList() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_Get.json - // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_List.json + // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_WebPubSubPrivateEndpointConnectionsGet() // get the collection of this WebPubSubPrivateEndpointConnectionResource WebPubSubPrivateEndpointConnectionCollection collection = webPubSub.GetWebPubSubPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "mywebpubsubservice.1fa229cd-bf3f-47f0-8c49-afb36723997e"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (WebPubSubPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WebPubSubPrivateEndpointConnectionsGet() + public async Task Exists_WebPubSubPrivateEndpointConnectionsGet() { // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_Get.json // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_WebPubSubPrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "mywebpubsubservice.1fa229cd-bf3f-47f0-8c49-afb36723997e"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - WebPubSubPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WebPubSubPrivateEndpointConnectionsUpdate() + public async Task GetIfExists_WebPubSubPrivateEndpointConnectionsGet() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_Update.json - // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_Get.json + // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_WebPubSubPrivateEndpointConnectionsUpdate() // invoke the operation string privateEndpointConnectionName = "mywebpubsubservice.1fa229cd-bf3f-47f0-8c49-afb36723997e"; - WebPubSubPrivateEndpointConnectionData data = new WebPubSubPrivateEndpointConnectionData() - { - PrivateEndpointId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint"), - ConnectionState = new WebPubSubPrivateLinkServiceConnectionState() - { - Status = WebPubSubPrivateLinkServiceConnectionStatus.Approved, - ActionsRequired = "None", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - WebPubSubPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + WebPubSubPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubPrivateEndpointConnectionResource.cs b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubPrivateEndpointConnectionResource.cs index 8682579191a69..d801ad54dfb19 100644 --- a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubPrivateEndpointConnectionResource.cs +++ b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_WebPubSubPrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WebPubSubPrivateEndpointConnectionsUpdate() + public async Task Delete_WebPubSubPrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_Update.json - // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_Delete.json + // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,17 @@ public async Task Update_WebPubSubPrivateEndpointConnectionsUpdate() WebPubSubPrivateEndpointConnectionResource webPubSubPrivateEndpointConnection = client.GetWebPubSubPrivateEndpointConnectionResource(webPubSubPrivateEndpointConnectionResourceId); // invoke the operation - WebPubSubPrivateEndpointConnectionData data = new WebPubSubPrivateEndpointConnectionData() - { - PrivateEndpointId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint"), - ConnectionState = new WebPubSubPrivateLinkServiceConnectionState() - { - Status = WebPubSubPrivateLinkServiceConnectionStatus.Approved, - ActionsRequired = "None", - }, - }; - ArmOperation lro = await webPubSubPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - WebPubSubPrivateEndpointConnectionResource result = lro.Value; + await webPubSubPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WebPubSubPrivateEndpointConnectionsDelete() + public async Task Update_WebPubSubPrivateEndpointConnectionsUpdate() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_Delete.json - // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubPrivateEndpointConnections_Update.json + // this example is just showing the usage of "WebPubSubPrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +96,23 @@ public async Task Delete_WebPubSubPrivateEndpointConnectionsDelete() WebPubSubPrivateEndpointConnectionResource webPubSubPrivateEndpointConnection = client.GetWebPubSubPrivateEndpointConnectionResource(webPubSubPrivateEndpointConnectionResourceId); // invoke the operation - await webPubSubPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + WebPubSubPrivateEndpointConnectionData data = new WebPubSubPrivateEndpointConnectionData + { + PrivateEndpointId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint"), + ConnectionState = new WebPubSubPrivateLinkServiceConnectionState + { + Status = WebPubSubPrivateLinkServiceConnectionStatus.Approved, + ActionsRequired = "None", + }, + }; + ArmOperation lro = await webPubSubPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + WebPubSubPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubResource.cs b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubResource.cs index 081c4bb20475e..778d1f4311bfa 100644 --- a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubResource.cs +++ b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.WebPubSub.Models; using NUnit.Framework; @@ -18,63 +17,6 @@ namespace Azure.ResourceManager.WebPubSub.Samples { public partial class Sample_WebPubSubResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckWebPubSubNameAvailability_WebPubSubCheckNameAvailability() - { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_CheckNameAvailability.json - // this example is just showing the usage of "WebPubSub_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("eastus"); - WebPubSubNameAvailabilityContent content = new WebPubSubNameAvailabilityContent("Microsoft.SignalRService/WebPubSub", "myWebPubSubService"); - WebPubSubNameAvailability result = await subscriptionResource.CheckWebPubSubNameAvailabilityAsync(location, content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetWebPubSubs_WebPubSubListBySubscription() - { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSub_ListBySubscription.json - // this example is just showing the usage of "WebPubSub_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (WebPubSubResource item in subscriptionResource.GetWebPubSubsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_WebPubSubGet() @@ -161,43 +103,31 @@ public async Task Update_WebPubSubUpdate() }, Identity = new ManagedServiceIdentity("SystemAssigned"), IsClientCertEnabled = false, - LiveTraceConfiguration = new LiveTraceConfiguration() + LiveTraceConfiguration = new LiveTraceConfiguration { - Categories = -{ -new LiveTraceCategory() + Categories = {new LiveTraceCategory { Name = "ConnectivityLogs", -} -}, +}}, }, - NetworkAcls = new WebPubSubNetworkAcls() + NetworkAcls = new WebPubSubNetworkAcls { DefaultAction = AclAction.Deny, - PublicNetwork = new PublicNetworkAcls() + PublicNetwork = new PublicNetworkAcls { - Allow = -{ -WebPubSubRequestType.ClientConnection -}, + Allow = { WebPubSubRequestType.ClientConnection }, }, - PrivateEndpoints = + PrivateEndpoints = {new PrivateEndpointAcl("mywebpubsubservice.1fa229cd-bf3f-47f0-8c49-afb36723997e") { -new PrivateEndpointAcl("mywebpubsubservice.1fa229cd-bf3f-47f0-8c49-afb36723997e") -{ -Allow = -{ -WebPubSubRequestType.ServerConnection -}, -} -}, +Allow = {WebPubSubRequestType.ServerConnection}, +}}, }, PublicNetworkAccess = "Enabled", IsLocalAuthDisabled = false, IsAadAuthDisabled = false, Tags = { -["key1"] = "value1", +["key1"] = "value1" }, }; ArmOperation lro = await webPubSub.UpdateAsync(WaitUntil.Completed, data); @@ -257,7 +187,7 @@ public async Task RegenerateKey_WebPubSubRegenerateKey() WebPubSubResource webPubSub = client.GetWebPubSubResource(webPubSubResourceId); // invoke the operation - WebPubSubRegenerateKeyContent content = new WebPubSubRegenerateKeyContent() + WebPubSubRegenerateKeyContent content = new WebPubSubRegenerateKeyContent { KeyType = WebPubSubKeyType.Primary, }; diff --git a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubSharedPrivateLinkCollection.cs b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubSharedPrivateLinkCollection.cs index 836c6b306a108..5706991af30a4 100644 --- a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubSharedPrivateLinkCollection.cs +++ b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubSharedPrivateLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WebPubSubSharedPrivateLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WebPubSubSharedPrivateLinkResourcesList() + public async Task CreateOrUpdate_WebPubSubSharedPrivateLinkResourcesCreateOrUpdate() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_List.json - // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_CreateOrUpdate.json + // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,22 @@ public async Task GetAll_WebPubSubSharedPrivateLinkResourcesList() // get the collection of this WebPubSubSharedPrivateLinkResource WebPubSubSharedPrivateLinkCollection collection = webPubSub.GetWebPubSubSharedPrivateLinks(); - // invoke the operation and iterate over the result - await foreach (WebPubSubSharedPrivateLinkResource item in collection.GetAllAsync()) + // invoke the operation + string sharedPrivateLinkResourceName = "upstream"; + WebPubSubSharedPrivateLinkData data = new WebPubSubSharedPrivateLinkData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubSharedPrivateLinkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + GroupId = "sites", + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Web/sites/myWebApp"), + RequestMessage = "Please approve", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sharedPrivateLinkResourceName, data); + WebPubSubSharedPrivateLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubSharedPrivateLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +92,10 @@ public async Task Get_WebPubSubSharedPrivateLinkResourcesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WebPubSubSharedPrivateLinkResourcesGet() + public async Task GetAll_WebPubSubSharedPrivateLinkResourcesList() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_Get.json - // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_List.json + // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +113,22 @@ public async Task Exists_WebPubSubSharedPrivateLinkResourcesGet() // get the collection of this WebPubSubSharedPrivateLinkResource WebPubSubSharedPrivateLinkCollection collection = webPubSub.GetWebPubSubSharedPrivateLinks(); - // invoke the operation - string sharedPrivateLinkResourceName = "upstream"; - bool result = await collection.ExistsAsync(sharedPrivateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (WebPubSubSharedPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubSharedPrivateLinkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WebPubSubSharedPrivateLinkResourcesGet() + public async Task Exists_WebPubSubSharedPrivateLinkResourcesGet() { // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_Get.json // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +151,17 @@ public async Task GetIfExists_WebPubSubSharedPrivateLinkResourcesGet() // invoke the operation string sharedPrivateLinkResourceName = "upstream"; - NullableResponse response = await collection.GetIfExistsAsync(sharedPrivateLinkResourceName); - WebPubSubSharedPrivateLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sharedPrivateLinkResourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubSharedPrivateLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WebPubSubSharedPrivateLinkResourcesCreateOrUpdate() + public async Task GetIfExists_WebPubSubSharedPrivateLinkResourcesGet() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_CreateOrUpdate.json - // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_Get.json + // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,20 +181,21 @@ public async Task CreateOrUpdate_WebPubSubSharedPrivateLinkResourcesCreateOrUpda // invoke the operation string sharedPrivateLinkResourceName = "upstream"; - WebPubSubSharedPrivateLinkData data = new WebPubSubSharedPrivateLinkData() - { - GroupId = "sites", - PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Web/sites/myWebApp"), - RequestMessage = "Please approve", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sharedPrivateLinkResourceName, data); - WebPubSubSharedPrivateLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(sharedPrivateLinkResourceName); + WebPubSubSharedPrivateLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubSharedPrivateLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubSharedPrivateLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubSharedPrivateLinkResource.cs b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubSharedPrivateLinkResource.cs index 3330d31011f22..f11dd9a5d2968 100644 --- a/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubSharedPrivateLinkResource.cs +++ b/sdk/webpubsub/Azure.ResourceManager.WebPubSub/samples/Generated/Samples/Sample_WebPubSubSharedPrivateLinkResource.cs @@ -48,10 +48,10 @@ public async Task Get_WebPubSubSharedPrivateLinkResourcesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WebPubSubSharedPrivateLinkResourcesCreateOrUpdate() + public async Task Delete_WebPubSubSharedPrivateLinkResourcesDelete() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_CreateOrUpdate.json - // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_Delete.json + // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,28 +68,17 @@ public async Task Update_WebPubSubSharedPrivateLinkResourcesCreateOrUpdate() WebPubSubSharedPrivateLinkResource webPubSubSharedPrivateLink = client.GetWebPubSubSharedPrivateLinkResource(webPubSubSharedPrivateLinkResourceId); // invoke the operation - WebPubSubSharedPrivateLinkData data = new WebPubSubSharedPrivateLinkData() - { - GroupId = "sites", - PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Web/sites/myWebApp"), - RequestMessage = "Please approve", - }; - ArmOperation lro = await webPubSubSharedPrivateLink.UpdateAsync(WaitUntil.Completed, data); - WebPubSubSharedPrivateLinkResource result = lro.Value; + await webPubSubSharedPrivateLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebPubSubSharedPrivateLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WebPubSubSharedPrivateLinkResourcesDelete() + public async Task Update_WebPubSubSharedPrivateLinkResourcesCreateOrUpdate() { - // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_Delete.json - // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/webpubsub/resource-manager/Microsoft.SignalRService/stable/2021-10-01/examples/WebPubSubSharedPrivateLinkResources_CreateOrUpdate.json + // this example is just showing the usage of "WebPubSubSharedPrivateLinkResources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +95,20 @@ public async Task Delete_WebPubSubSharedPrivateLinkResourcesDelete() WebPubSubSharedPrivateLinkResource webPubSubSharedPrivateLink = client.GetWebPubSubSharedPrivateLinkResource(webPubSubSharedPrivateLinkResourceId); // invoke the operation - await webPubSubSharedPrivateLink.DeleteAsync(WaitUntil.Completed); + WebPubSubSharedPrivateLinkData data = new WebPubSubSharedPrivateLinkData + { + GroupId = "sites", + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Web/sites/myWebApp"), + RequestMessage = "Please approve", + }; + ArmOperation lro = await webPubSubSharedPrivateLink.UpdateAsync(WaitUntil.Completed, data); + WebPubSubSharedPrivateLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebPubSubSharedPrivateLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppCertificateCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppCertificateCollection.cs index aedf3933ea988..2f8bffc17e6ae 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppCertificateCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppCertificateCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCertificatesByResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateCertificate() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCertificatesByResourceGroup.json - // this example is just showing the usage of "Certificates_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateCertificate.json + // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_ListCertificatesByResourceGroup() // get the collection of this AppCertificateResource AppCertificateCollection collection = resourceGroupResource.GetAppCertificates(); - // invoke the operation and iterate over the result - await foreach (AppCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string name = "testc6282"; + AppCertificateData data = new AppCertificateData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Password = "", + HostNames = { "ServerCert" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + AppCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +90,10 @@ public async Task Get_GetCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCertificate() + public async Task GetAll_ListCertificatesByResourceGroup() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetCertificate.json - // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCertificatesByResourceGroup.json + // this example is just showing the usage of "Certificates_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +110,22 @@ public async Task Exists_GetCertificate() // get the collection of this AppCertificateResource AppCertificateCollection collection = resourceGroupResource.GetAppCertificates(); - // invoke the operation - string name = "testc6282"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (AppCertificateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCertificate() + public async Task Exists_GetCertificate() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetCertificate.json // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +147,17 @@ public async Task GetIfExists_GetCertificate() // invoke the operation string name = "testc6282"; - NullableResponse response = await collection.GetIfExistsAsync(name); - AppCertificateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateCertificate() + public async Task GetIfExists_GetCertificate() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateCertificate.json - // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetCertificate.json + // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,22 +176,21 @@ public async Task CreateOrUpdate_CreateOrUpdateCertificate() // invoke the operation string name = "testc6282"; - AppCertificateData data = new AppCertificateData(new AzureLocation("East US")) - { - Password = "", - HostNames = -{ -"ServerCert" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - AppCertificateResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + AppCertificateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppCertificateResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppCertificateResource.cs index 6aacf3e0a7b58..6b029643d827e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppCertificateResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppCertificateResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_AppCertificateResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAppCertificates_ListCertificatesForSubscription() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCertificates.json - // this example is just showing the usage of "Certificates_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AppCertificateResource item in subscriptionResource.GetAppCertificatesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetCertificate() @@ -125,7 +93,7 @@ public async Task Update_PatchCertificate() AppCertificateResource appCertificate = client.GetAppCertificateResource(appCertificateResourceId); // invoke the operation - AppCertificatePatch patch = new AppCertificatePatch() + AppCertificatePatch patch = new AppCertificatePatch { Password = "", }; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateCollection.cs index 731f382ff3b32..fe91b61ed367d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppServiceCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCertificatesByAppServiceCertificate() + public async Task CreateOrUpdate_CreateCertificate() { - // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/ListCertificatesByAppServiceCertificateOrder.json - // this example is just showing the usage of "AppServiceCertificateOrders_ListCertificates" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/CreateAppServiceCertificate.json + // this example is just showing the usage of "AppServiceCertificateOrders_CreateOrUpdateCertificate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_ListCertificatesByAppServiceCertificate() // get the collection of this AppServiceCertificateResource AppServiceCertificateCollection collection = appServiceCertificateOrder.GetAppServiceCertificates(); - // invoke the operation and iterate over the result - await foreach (AppServiceCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string name = "SampleCertName1"; + AppServiceCertificateData data = new AppServiceCertificateData(new AzureLocation("Global")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), + KeyVaultSecretName = "SampleSecretName1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + AppServiceCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_GetAppServiceCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppServiceCertificate() + public async Task GetAll_ListCertificatesByAppServiceCertificate() { - // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/GetAppServiceCertificate.json - // this example is just showing the usage of "AppServiceCertificateOrders_GetCertificate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/ListCertificatesByAppServiceCertificateOrder.json + // this example is just showing the usage of "AppServiceCertificateOrders_ListCertificates" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_GetAppServiceCertificate() // get the collection of this AppServiceCertificateResource AppServiceCertificateCollection collection = appServiceCertificateOrder.GetAppServiceCertificates(); - // invoke the operation - string name = "SampleCertName1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (AppServiceCertificateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppServiceCertificate() + public async Task Exists_GetAppServiceCertificate() { // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/GetAppServiceCertificate.json // this example is just showing the usage of "AppServiceCertificateOrders_GetCertificate" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_GetAppServiceCertificate() // invoke the operation string name = "SampleCertName1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - AppServiceCertificateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCertificate() + public async Task GetIfExists_GetAppServiceCertificate() { - // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/CreateAppServiceCertificate.json - // this example is just showing the usage of "AppServiceCertificateOrders_CreateOrUpdateCertificate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/GetAppServiceCertificate.json + // this example is just showing the usage of "AppServiceCertificateOrders_GetCertificate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,19 +180,21 @@ public async Task CreateOrUpdate_CreateCertificate() // invoke the operation string name = "SampleCertName1"; - AppServiceCertificateData data = new AppServiceCertificateData(new AzureLocation("Global")) - { - KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), - KeyVaultSecretName = "SampleSecretName1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - AppServiceCertificateResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + AppServiceCertificateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateOrderCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateOrderCollection.cs index 44b6ce8fa17dc..9453c40ebeafa 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateOrderCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateOrderCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AppServiceCertificateOrderCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppServiceCertificateOrdersByResourceGroup() + public async Task CreateOrUpdate_CreateCertificateOrder() { - // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/ListAppServiceCertificateOrdersByResourceGroup.json - // this example is just showing the usage of "AppServiceCertificateOrders_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/CreateAppServiceCertificateOrder.json + // this example is just showing the usage of "AppServiceCertificateOrders_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,37 @@ public async Task GetAll_ListAppServiceCertificateOrdersByResourceGroup() // get the collection of this AppServiceCertificateOrderResource AppServiceCertificateOrderCollection collection = resourceGroupResource.GetAppServiceCertificateOrders(); - // invoke the operation and iterate over the result - await foreach (AppServiceCertificateOrderResource item in collection.GetAllAsync()) + // invoke the operation + string certificateOrderName = "SampleCertificateOrderName"; + AppServiceCertificateOrderData data = new AppServiceCertificateOrderData(new AzureLocation("Global")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceCertificateOrderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Certificates = +{ +["SampleCertName1"] = new AppServiceCertificateProperties +{ +KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), +KeyVaultSecretName = "SampleSecretName1", +}, +["SampleCertName2"] = new AppServiceCertificateProperties +{ +KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), +KeyVaultSecretName = "SampleSecretName2", +} +}, + DistinguishedName = "CN=SampleCustomDomain.com", + ValidityInYears = 2, + KeySize = 2048, + ProductType = CertificateProductType.StandardDomainValidatedSsl, + IsAutoRenew = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateOrderName, data); + AppServiceCertificateOrderResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceCertificateOrderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +107,10 @@ public async Task Get_GetAppServiceCertificateOrder() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppServiceCertificateOrder() + public async Task GetAll_ListAppServiceCertificateOrdersByResourceGroup() { - // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/GetAppServiceCertificateOrder.json - // this example is just showing the usage of "AppServiceCertificateOrders_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/ListAppServiceCertificateOrdersByResourceGroup.json + // this example is just showing the usage of "AppServiceCertificateOrders_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +127,22 @@ public async Task Exists_GetAppServiceCertificateOrder() // get the collection of this AppServiceCertificateOrderResource AppServiceCertificateOrderCollection collection = resourceGroupResource.GetAppServiceCertificateOrders(); - // invoke the operation - string certificateOrderName = "SampleCertificateOrderName"; - bool result = await collection.ExistsAsync(certificateOrderName); + // invoke the operation and iterate over the result + await foreach (AppServiceCertificateOrderResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceCertificateOrderData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppServiceCertificateOrder() + public async Task Exists_GetAppServiceCertificateOrder() { // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/GetAppServiceCertificateOrder.json // this example is just showing the usage of "AppServiceCertificateOrders_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +164,17 @@ public async Task GetIfExists_GetAppServiceCertificateOrder() // invoke the operation string certificateOrderName = "SampleCertificateOrderName"; - NullableResponse response = await collection.GetIfExistsAsync(certificateOrderName); - AppServiceCertificateOrderResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(certificateOrderName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceCertificateOrderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCertificateOrder() + public async Task GetIfExists_GetAppServiceCertificateOrder() { - // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/CreateAppServiceCertificateOrder.json - // this example is just showing the usage of "AppServiceCertificateOrders_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/GetAppServiceCertificateOrder.json + // this example is just showing the usage of "AppServiceCertificateOrders_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,35 +193,21 @@ public async Task CreateOrUpdate_CreateCertificateOrder() // invoke the operation string certificateOrderName = "SampleCertificateOrderName"; - AppServiceCertificateOrderData data = new AppServiceCertificateOrderData(new AzureLocation("Global")) - { - Certificates = -{ -["SampleCertName1"] = new AppServiceCertificateProperties() -{ -KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), -KeyVaultSecretName = "SampleSecretName1", -}, -["SampleCertName2"] = new AppServiceCertificateProperties() -{ -KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), -KeyVaultSecretName = "SampleSecretName2", -}, -}, - DistinguishedName = "CN=SampleCustomDomain.com", - ValidityInYears = 2, - KeySize = 2048, - ProductType = CertificateProductType.StandardDomainValidatedSsl, - IsAutoRenew = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateOrderName, data); - AppServiceCertificateOrderResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(certificateOrderName); + AppServiceCertificateOrderResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceCertificateOrderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceCertificateOrderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateOrderResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateOrderResource.cs index b8f76dd96d110..731a008ff64e1 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateOrderResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateOrderResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_AppServiceCertificateOrderResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAppServiceCertificateOrders_ListAppServiceCertificateOrdersBySubscription() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/ListAppServiceCertificateOrdersBySubscription.json - // this example is just showing the usage of "AppServiceCertificateOrders_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AppServiceCertificateOrderResource item in subscriptionResource.GetAppServiceCertificateOrdersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceCertificateOrderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAppServiceCertificateOrder() @@ -125,20 +93,20 @@ public async Task Update_UpdateCertificateOrder() AppServiceCertificateOrderResource appServiceCertificateOrder = client.GetAppServiceCertificateOrderResource(appServiceCertificateOrderResourceId); // invoke the operation - AppServiceCertificateOrderPatch patch = new AppServiceCertificateOrderPatch() + AppServiceCertificateOrderPatch patch = new AppServiceCertificateOrderPatch { Certificates = { -["SampleCertName1"] = new AppServiceCertificateProperties() +["SampleCertName1"] = new AppServiceCertificateProperties { KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), KeyVaultSecretName = "SampleSecretName1", }, -["SampleCertName2"] = new AppServiceCertificateProperties() +["SampleCertName2"] = new AppServiceCertificateProperties { KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), KeyVaultSecretName = "SampleSecretName2", -}, +} }, DistinguishedName = "CN=SampleCustomDomain.com", ValidityInYears = 2, @@ -176,7 +144,7 @@ public async Task Reissue_ReissueAppServiceCertificateOrder() AppServiceCertificateOrderResource appServiceCertificateOrder = client.GetAppServiceCertificateOrderResource(appServiceCertificateOrderResourceId); // invoke the operation - ReissueCertificateOrderContent content = new ReissueCertificateOrderContent() + ReissueCertificateOrderContent content = new ReissueCertificateOrderContent { KeySize = 2048, DelayExistingRevokeInHours = 2, @@ -209,7 +177,7 @@ public async Task Renew_RenewAppServiceCertificateOrder() AppServiceCertificateOrderResource appServiceCertificateOrder = client.GetAppServiceCertificateOrderResource(appServiceCertificateOrderResourceId); // invoke the operation - RenewCertificateOrderContent content = new RenewCertificateOrderContent() + RenewCertificateOrderContent content = new RenewCertificateOrderContent { KeySize = 2048, Csr = "CSR1223238Value", @@ -267,7 +235,7 @@ public async Task ResendRequestEmails_ResendDomainOwnershipVerificationEmail() AppServiceCertificateOrderResource appServiceCertificateOrder = client.GetAppServiceCertificateOrderResource(appServiceCertificateOrderResourceId); // invoke the operation - AppServiceDomainNameIdentifier nameIdentifier = new AppServiceDomainNameIdentifier() + AppServiceDomainNameIdentifier nameIdentifier = new AppServiceDomainNameIdentifier { Name = "Domain name", }; @@ -297,7 +265,7 @@ public async Task RetrieveSiteSeal_RetrieveSiteSeal() AppServiceCertificateOrderResource appServiceCertificateOrder = client.GetAppServiceCertificateOrderResource(appServiceCertificateOrderResourceId); // invoke the operation - SiteSealContent content = new SiteSealContent() + SiteSealContent content = new SiteSealContent { IsLightTheme = true, Locale = "en-us", diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateResource.cs index 1713de0190af8..8f501d0f24bfe 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceCertificateResource.cs @@ -96,7 +96,7 @@ public async Task Update_UpdateCertificate() AppServiceCertificateResource appServiceCertificate = client.GetAppServiceCertificateResource(appServiceCertificateResourceId); // invoke the operation - AppServiceCertificatePatch patch = new AppServiceCertificatePatch() + AppServiceCertificatePatch patch = new AppServiceCertificatePatch { KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), KeyVaultSecretName = "SampleSecretName1", diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceDomainCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceDomainCollection.cs index 29c59c2f6d227..5c0404c2844f5 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceDomainCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceDomainCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AppServiceDomainCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDomainsByResourceGroup() + public async Task CreateOrUpdate_CreateAppServiceDomain() { - // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/ListDomainsByResourceGroup.json - // this example is just showing the usage of "Domains_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/CreateAppServiceDomain.json + // this example is just showing the usage of "Domains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,62 @@ public async Task GetAll_ListDomainsByResourceGroup() // get the collection of this AppServiceDomainResource AppServiceDomainCollection collection = resourceGroupResource.GetAppServiceDomains(); - // invoke the operation and iterate over the result - await foreach (AppServiceDomainResource item in collection.GetAllAsync()) + // invoke the operation + string domainName = "example.com"; + AppServiceDomainData data = new AppServiceDomainData(new AzureLocation("global")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDomainData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ContactAdmin = new RegistrationContactInfo("admin@email.com", "John", "Doe", "1-245-534-2242") + { + AddressMailing = new RegistrationAddressInfo("3400 State St", "Chicago", "United States", "67098", "IL"), + Fax = "1-245-534-2242", + JobTitle = "Admin", + NameMiddle = "", + Organization = "Microsoft Inc.", + }, + ContactBilling = new RegistrationContactInfo("billing@email.com", "John", "Doe", "1-245-534-2242") + { + AddressMailing = new RegistrationAddressInfo("3400 State St", "Chicago", "United States", "67098", "IL"), + Fax = "1-245-534-2242", + JobTitle = "Billing", + NameMiddle = "", + Organization = "Microsoft Inc.", + }, + ContactRegistrant = new RegistrationContactInfo("registrant@email.com", "John", "Doe", "1-245-534-2242") + { + AddressMailing = new RegistrationAddressInfo("3400 State St", "Chicago", "United States", "67098", "IL"), + Fax = "1-245-534-2242", + JobTitle = "Registrant", + NameMiddle = "", + Organization = "Microsoft Inc.", + }, + ContactTech = new RegistrationContactInfo("tech@email.com", "John", "Doe", "1-245-534-2242") + { + AddressMailing = new RegistrationAddressInfo("3400 State St", "Chicago", "United States", "67098", "IL"), + Fax = "1-245-534-2242", + JobTitle = "Tech", + NameMiddle = "", + Organization = "Microsoft Inc.", + }, + IsDomainPrivacyEnabled = false, + IsAutoRenew = true, + Consent = new DomainPurchaseConsent + { + AgreementKeys = { "agreementKey1" }, + AgreedBy = "192.0.2.1", + AgreedOn = DateTimeOffset.Parse("2021-09-10T19:30:53Z"), + }, + DnsType = AppServiceDnsType.DefaultDomainRegistrarDns, + AuthCode = "exampleAuthCode", + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); + AppServiceDomainResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +132,10 @@ public async Task Get_GetDomain() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDomain() + public async Task GetAll_ListDomainsByResourceGroup() { - // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/GetDomain.json - // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/ListDomainsByResourceGroup.json + // this example is just showing the usage of "Domains_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +152,22 @@ public async Task Exists_GetDomain() // get the collection of this AppServiceDomainResource AppServiceDomainCollection collection = resourceGroupResource.GetAppServiceDomains(); - // invoke the operation - string domainName = "example.com"; - bool result = await collection.ExistsAsync(domainName); + // invoke the operation and iterate over the result + await foreach (AppServiceDomainResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDomainData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDomain() + public async Task Exists_GetDomain() { // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/GetDomain.json // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +189,17 @@ public async Task GetIfExists_GetDomain() // invoke the operation string domainName = "example.com"; - NullableResponse response = await collection.GetIfExistsAsync(domainName); - AppServiceDomainResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(domainName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAppServiceDomain() + public async Task GetIfExists_GetDomain() { - // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/CreateAppServiceDomain.json - // this example is just showing the usage of "Domains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/GetDomain.json + // this example is just showing the usage of "Domains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,65 +218,21 @@ public async Task CreateOrUpdate_CreateAppServiceDomain() // invoke the operation string domainName = "example.com"; - AppServiceDomainData data = new AppServiceDomainData(new AzureLocation("global")) - { - ContactAdmin = new RegistrationContactInfo("admin@email.com", "John", "Doe", "1-245-534-2242") - { - AddressMailing = new RegistrationAddressInfo("3400 State St", "Chicago", "United States", "67098", "IL"), - Fax = "1-245-534-2242", - JobTitle = "Admin", - NameMiddle = "", - Organization = "Microsoft Inc.", - }, - ContactBilling = new RegistrationContactInfo("billing@email.com", "John", "Doe", "1-245-534-2242") - { - AddressMailing = new RegistrationAddressInfo("3400 State St", "Chicago", "United States", "67098", "IL"), - Fax = "1-245-534-2242", - JobTitle = "Billing", - NameMiddle = "", - Organization = "Microsoft Inc.", - }, - ContactRegistrant = new RegistrationContactInfo("registrant@email.com", "John", "Doe", "1-245-534-2242") - { - AddressMailing = new RegistrationAddressInfo("3400 State St", "Chicago", "United States", "67098", "IL"), - Fax = "1-245-534-2242", - JobTitle = "Registrant", - NameMiddle = "", - Organization = "Microsoft Inc.", - }, - ContactTech = new RegistrationContactInfo("tech@email.com", "John", "Doe", "1-245-534-2242") - { - AddressMailing = new RegistrationAddressInfo("3400 State St", "Chicago", "United States", "67098", "IL"), - Fax = "1-245-534-2242", - JobTitle = "Tech", - NameMiddle = "", - Organization = "Microsoft Inc.", - }, - IsDomainPrivacyEnabled = false, - IsAutoRenew = true, - Consent = new DomainPurchaseConsent() - { - AgreementKeys = -{ -"agreementKey1" -}, - AgreedBy = "192.0.2.1", - AgreedOn = DateTimeOffset.Parse("2021-09-10T19:30:53Z"), - }, - DnsType = AppServiceDnsType.DefaultDomainRegistrarDns, - AuthCode = "exampleAuthCode", - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); - AppServiceDomainResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(domainName); + AppServiceDomainResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceDomainResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceDomainResource.cs index d350bbd7d830b..6d9d6a172f79a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceDomainResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceDomainResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_AppServiceDomainResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAppServiceDomains_ListDomainsBySubscription() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/ListDomainsBySubscription.json - // this example is just showing the usage of "Domains_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AppServiceDomainResource item in subscriptionResource.GetAppServiceDomainsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDomainData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetDomain() @@ -126,7 +94,7 @@ public async Task Update_UpdateAppServiceDomain() AppServiceDomainResource appServiceDomain = client.GetAppServiceDomainResource(appServiceDomainResourceId); // invoke the operation - AppServiceDomainPatch patch = new AppServiceDomainPatch() + AppServiceDomainPatch patch = new AppServiceDomainPatch { ContactAdmin = new RegistrationContactInfo("admin@email.com", "John", "Doe", "1-245-534-2242") { @@ -162,12 +130,9 @@ public async Task Update_UpdateAppServiceDomain() }, IsDomainPrivacyEnabled = false, IsAutoRenew = true, - Consent = new DomainPurchaseConsent() + Consent = new DomainPurchaseConsent { - AgreementKeys = -{ -"agreementKey1" -}, + AgreementKeys = { "agreementKey1" }, AgreedBy = "192.0.2.1", AgreedOn = DateTimeOffset.Parse("2021-09-10T19:30:53Z"), }, diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceEnvironmentCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceEnvironmentCollection.cs index f7a34100fe8c0..e5c531eb83625 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceEnvironmentCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceEnvironmentCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AppServiceEnvironmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllAppServiceEnvironmentsInAResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateAnAppServiceEnvironment() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_ListByResourceGroup.json - // this example is just showing the usage of "AppServiceEnvironments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_CreateOrUpdate.json + // this example is just showing the usage of "AppServiceEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_GetAllAppServiceEnvironmentsInAResourceGroup() // get the collection of this AppServiceEnvironmentResource AppServiceEnvironmentCollection collection = resourceGroupResource.GetAppServiceEnvironments(); - // invoke the operation and iterate over the result - await foreach (AppServiceEnvironmentResource item in collection.GetAllAsync()) + // invoke the operation + string name = "test-ase"; + AppServiceEnvironmentData data = new AppServiceEnvironmentData(new AzureLocation("South Central US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + VirtualNetwork = new AppServiceVirtualNetworkProfile(new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/delegated")), + Kind = "Asev3", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + AppServiceEnvironmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_GetThePropertiesOfAnAppServiceEnvironment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetThePropertiesOfAnAppServiceEnvironment() + public async Task GetAll_GetAllAppServiceEnvironmentsInAResourceGroup() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_Get.json - // this example is just showing the usage of "AppServiceEnvironments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_ListByResourceGroup.json + // this example is just showing the usage of "AppServiceEnvironments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +111,22 @@ public async Task Exists_GetThePropertiesOfAnAppServiceEnvironment() // get the collection of this AppServiceEnvironmentResource AppServiceEnvironmentCollection collection = resourceGroupResource.GetAppServiceEnvironments(); - // invoke the operation - string name = "test-ase"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (AppServiceEnvironmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetThePropertiesOfAnAppServiceEnvironment() + public async Task Exists_GetThePropertiesOfAnAppServiceEnvironment() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_Get.json // this example is just showing the usage of "AppServiceEnvironments_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +148,17 @@ public async Task GetIfExists_GetThePropertiesOfAnAppServiceEnvironment() // invoke the operation string name = "test-ase"; - NullableResponse response = await collection.GetIfExistsAsync(name); - AppServiceEnvironmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnAppServiceEnvironment() + public async Task GetIfExists_GetThePropertiesOfAnAppServiceEnvironment() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_CreateOrUpdate.json - // this example is just showing the usage of "AppServiceEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_Get.json + // this example is just showing the usage of "AppServiceEnvironments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,19 +177,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAppServiceEnvironment() // invoke the operation string name = "test-ase"; - AppServiceEnvironmentData data = new AppServiceEnvironmentData(new AzureLocation("South Central US")) - { - VirtualNetwork = new AppServiceVirtualNetworkProfile(new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/delegated")), - Kind = "Asev3", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - AppServiceEnvironmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + AppServiceEnvironmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceEnvironmentResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceEnvironmentResource.cs index 227c9f7045cc3..4afb637430100 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceEnvironmentResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServiceEnvironmentResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_AppServiceEnvironmentResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAppServiceEnvironments_GetAllAppServiceEnvironmentsForASubscription() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_List.json - // this example is just showing the usage of "AppServiceEnvironments_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AppServiceEnvironmentResource item in subscriptionResource.GetAppServiceEnvironmentsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetThePropertiesOfAnAppServiceEnvironment() @@ -125,7 +93,7 @@ public async Task Update_CreateOrUpdateAnAppServiceEnvironment() AppServiceEnvironmentResource appServiceEnvironment = client.GetAppServiceEnvironmentResource(appServiceEnvironmentResourceId); // invoke the operation - AppServiceEnvironmentPatch patch = new AppServiceEnvironmentPatch() + AppServiceEnvironmentPatch patch = new AppServiceEnvironmentPatch { VirtualNetwork = new AppServiceVirtualNetworkProfile(new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-subnet/subnets/delegated")), FrontEndScaleFactor = 20, diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServicePlanCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServicePlanCollection.cs index 34a7ad8fa77a5..ec77f848ef173 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServicePlanCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServicePlanCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AppServicePlanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppServicePlansByResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateAppServicePlan() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListAppServicePlansByResourceGroup.json - // this example is just showing the usage of "AppServicePlans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateAppServicePlan.json + // this example is just showing the usage of "AppServicePlans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,28 @@ public async Task GetAll_ListAppServicePlansByResourceGroup() // get the collection of this AppServicePlanResource AppServicePlanCollection collection = resourceGroupResource.GetAppServicePlans(); - // invoke the operation and iterate over the result - await foreach (AppServicePlanResource item in collection.GetAllAsync()) + // invoke the operation + string name = "testsf6141"; + AppServicePlanData data = new AppServicePlanData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServicePlanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new AppServiceSkuDescription + { + Name = "P1", + Tier = "Premium", + Size = "P1", + Family = "P", + Capacity = 1, + }, + Kind = "app", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + AppServicePlanResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServicePlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +98,10 @@ public async Task Get_GetAppServicePlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppServicePlan() + public async Task GetAll_ListAppServicePlansByResourceGroup() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetAppServicePlan.json - // this example is just showing the usage of "AppServicePlans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListAppServicePlansByResourceGroup.json + // this example is just showing the usage of "AppServicePlans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +118,22 @@ public async Task Exists_GetAppServicePlan() // get the collection of this AppServicePlanResource AppServicePlanCollection collection = resourceGroupResource.GetAppServicePlans(); - // invoke the operation - string name = "testsf6141"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (AppServicePlanResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServicePlanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppServicePlan() + public async Task Exists_GetAppServicePlan() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetAppServicePlan.json // this example is just showing the usage of "AppServicePlans_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +155,17 @@ public async Task GetIfExists_GetAppServicePlan() // invoke the operation string name = "testsf6141"; - NullableResponse response = await collection.GetIfExistsAsync(name); - AppServicePlanResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServicePlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAppServicePlan() + public async Task GetIfExists_GetAppServicePlan() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateAppServicePlan.json - // this example is just showing the usage of "AppServicePlans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetAppServicePlan.json + // this example is just showing the usage of "AppServicePlans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,26 +184,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAppServicePlan() // invoke the operation string name = "testsf6141"; - AppServicePlanData data = new AppServicePlanData(new AzureLocation("East US")) - { - Sku = new AppServiceSkuDescription() - { - Name = "P1", - Tier = "Premium", - Size = "P1", - Family = "P", - Capacity = 1, - }, - Kind = "app", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - AppServicePlanResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + AppServicePlanResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServicePlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServicePlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServicePlanResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServicePlanResource.cs index b270d6beeb27e..df2cd163f43bf 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServicePlanResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AppServicePlanResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_AppServicePlanResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAppServicePlans_ListAppServicePlans() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListAppServicePlans.json - // this example is just showing the usage of "AppServicePlans_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AppServicePlanResource item in subscriptionResource.GetAppServicePlansAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServicePlanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAppServicePlan() @@ -125,7 +93,7 @@ public async Task Update_PatchServicePlan() AppServicePlanResource appServicePlan = client.GetAppServicePlanResource(appServicePlanResourceId); // invoke the operation - AppServicePlanPatch patch = new AppServicePlanPatch() + AppServicePlanPatch patch = new AppServicePlanPatch { Kind = "app", }; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AseV3NetworkingConfigurationResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AseV3NetworkingConfigurationResource.cs index a1abd5dc1308b..019f58b674b98 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AseV3NetworkingConfigurationResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_AseV3NetworkingConfigurationResource.cs @@ -66,7 +66,7 @@ public async Task CreateOrUpdate_UpdateNetworkingConfigurationOfAnAppServiceEnvi AseV3NetworkingConfigurationResource aseV3NetworkingConfiguration = client.GetAseV3NetworkingConfigurationResource(aseV3NetworkingConfigurationResourceId); // invoke the operation - AseV3NetworkingConfigurationData data = new AseV3NetworkingConfigurationData() + AseV3NetworkingConfigurationData data = new AseV3NetworkingConfigurationData { IsFtpEnabled = true, IsRemoteDebugEnabled = true, diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_CertificateOrderDetectorCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_CertificateOrderDetectorCollection.cs index 7f8b7bd874b2c..885261a0b2648 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_CertificateOrderDetectorCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_CertificateOrderDetectorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CertificateOrderDetectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppServiceCertificateDetectorResponse() + public async Task Get_GetAppServiceCertificateOrderDetectorResponse() { - // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/Diagnostics_ListAppServiceCertificateOrderDetectorResponse.json - // this example is just showing the usage of "CertificateOrdersDiagnostics_ListAppServiceCertificateOrderDetectorResponse" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/Diagnostics_GetAppServiceCertificateOrderDetectorResponse.json + // this example is just showing the usage of "CertificateOrdersDiagnostics_GetAppServiceCertificateOrderDetectorResponse" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListAppServiceCertificateDetectorResponse() // get the collection of this CertificateOrderDetectorResource CertificateOrderDetectorCollection collection = appServiceCertificateOrder.GetCertificateOrderDetectors(); - // invoke the operation and iterate over the result - await foreach (CertificateOrderDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "AutoRenewStatus"; + CertificateOrderDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppServiceCertificateOrderDetectorResponse() + public async Task GetAll_ListAppServiceCertificateDetectorResponse() { - // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/Diagnostics_GetAppServiceCertificateOrderDetectorResponse.json - // this example is just showing the usage of "CertificateOrdersDiagnostics_GetAppServiceCertificateOrderDetectorResponse" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/Diagnostics_ListAppServiceCertificateOrderDetectorResponse.json + // this example is just showing the usage of "CertificateOrdersDiagnostics_ListAppServiceCertificateOrderDetectorResponse" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetAppServiceCertificateOrderDetectorResponse() // get the collection of this CertificateOrderDetectorResource CertificateOrderDetectorCollection collection = appServiceCertificateOrder.GetCertificateOrderDetectors(); - // invoke the operation - string detectorName = "AutoRenewStatus"; - CertificateOrderDetectorResource result = await collection.GetAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (CertificateOrderDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_CustomDnsSuffixConfigurationResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_CustomDnsSuffixConfigurationResource.cs index 61d7f12eabd67..84594b2e87172 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_CustomDnsSuffixConfigurationResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_CustomDnsSuffixConfigurationResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetASECustomDNSSuffixConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateASECustomDNSSuffixConfiguration() + public async Task Delete_DeleteASECustomDNSSuffixConfiguration() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/UpdateAseCustomDnsSuffixConfiguration.json - // this example is just showing the usage of "AppServiceEnvironments_UpdateAseCustomDnsSuffixConfiguration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteAseCustomDnsSuffixConfiguration.json + // this example is just showing the usage of "AppServiceEnvironments_DeleteAseCustomDnsSuffixConfiguration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,28 +66,18 @@ public async Task CreateOrUpdate_UpdateASECustomDNSSuffixConfiguration() CustomDnsSuffixConfigurationResource customDnsSuffixConfiguration = client.GetCustomDnsSuffixConfigurationResource(customDnsSuffixConfigurationResourceId); // invoke the operation - CustomDnsSuffixConfigurationData data = new CustomDnsSuffixConfigurationData() - { - DnsSuffix = "contoso.com", - CertificateUri = new Uri("https://test-kv.vault.azure.net/secrets/contosocert"), - KeyVaultReferenceIdentity = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/test-rg/providers/microsoft.managedidentity/userassignedidentities/test-user-mi", - }; - ArmOperation lro = await customDnsSuffixConfiguration.CreateOrUpdateAsync(WaitUntil.Completed, data); - CustomDnsSuffixConfigurationResource result = lro.Value; + ArmOperation lro = await customDnsSuffixConfiguration.DeleteAsync(WaitUntil.Completed); + BinaryData result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomDnsSuffixConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASECustomDNSSuffixConfiguration() + public async Task CreateOrUpdate_UpdateASECustomDNSSuffixConfiguration() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteAseCustomDnsSuffixConfiguration.json - // this example is just showing the usage of "AppServiceEnvironments_DeleteAseCustomDnsSuffixConfiguration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/UpdateAseCustomDnsSuffixConfiguration.json + // this example is just showing the usage of "AppServiceEnvironments_UpdateAseCustomDnsSuffixConfiguration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,10 +93,20 @@ public async Task Delete_DeleteASECustomDNSSuffixConfiguration() CustomDnsSuffixConfigurationResource customDnsSuffixConfiguration = client.GetCustomDnsSuffixConfigurationResource(customDnsSuffixConfigurationResourceId); // invoke the operation - ArmOperation lro = await customDnsSuffixConfiguration.DeleteAsync(WaitUntil.Completed); - BinaryData result = lro.Value; + CustomDnsSuffixConfigurationData data = new CustomDnsSuffixConfigurationData + { + DnsSuffix = "contoso.com", + CertificateUri = new Uri("https://test-kv.vault.azure.net/secrets/contosocert"), + KeyVaultReferenceIdentity = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/test-rg/providers/microsoft.managedidentity/userassignedidentities/test-user-mi", + }; + ArmOperation lro = await customDnsSuffixConfiguration.CreateOrUpdateAsync(WaitUntil.Completed, data); + CustomDnsSuffixConfigurationResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomDnsSuffixConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DeletedSiteResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DeletedSiteResource.cs index d6dc2fabac9a2..5b098ad51365d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DeletedSiteResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DeletedSiteResource.cs @@ -10,75 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_DeletedSiteResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeletedSitesByLocation_ListDeletedWebAppByLocation() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListDeletedWebAppsByLocation.json - // this example is just showing the usage of "DeletedWebApps_ListByLocation" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("West US 2"); - await foreach (DeletedSiteResource item in subscriptionResource.GetDeletedSitesByLocationAsync(location)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeletedSiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeletedWebAppByLocationDeletedWebApp_GetDeletedWebAppByLocation() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetDeletedWebAppByLocation.json - // this example is just showing the usage of "DeletedWebApps_GetDeletedWebAppByLocation" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("West US 2"); - string deletedSiteId = "9"; - DeletedSiteResource result = await subscriptionResource.GetDeletedWebAppByLocationDeletedWebAppAsync(location, deletedSiteId); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeletedSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetDeletedWebApp() diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DomainOwnershipIdentifierCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DomainOwnershipIdentifierCollection.cs index c98385aa28ae7..2a85632789b13 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DomainOwnershipIdentifierCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DomainOwnershipIdentifierCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DomainOwnershipIdentifierCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDomainOwnershipIdentifiers() + public async Task CreateOrUpdate_CreateAppServiceDomainOwnershipIdentifier() { - // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/ListDomainOwnershipIdentifiers.json - // this example is just showing the usage of "Domains_ListOwnershipIdentifiers" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/CreateAppServiceDomainOwnershipIdentifier.json + // this example is just showing the usage of "Domains_CreateOrUpdateOwnershipIdentifier" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ListDomainOwnershipIdentifiers() // get the collection of this DomainOwnershipIdentifierResource DomainOwnershipIdentifierCollection collection = appServiceDomain.GetDomainOwnershipIdentifiers(); - // invoke the operation and iterate over the result - await foreach (DomainOwnershipIdentifierResource item in collection.GetAllAsync()) + // invoke the operation + string name = "SampleOwnershipId"; + DomainOwnershipIdentifierData data = new DomainOwnershipIdentifierData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DomainOwnershipIdentifierData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + OwnershipId = "SampleOwnershipId", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DomainOwnershipIdentifierResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DomainOwnershipIdentifierData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetDomainOwnershipIdentifier() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDomainOwnershipIdentifier() + public async Task GetAll_ListDomainOwnershipIdentifiers() { - // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/GetDomainOwnershipIdentifier.json - // this example is just showing the usage of "Domains_GetOwnershipIdentifier" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/ListDomainOwnershipIdentifiers.json + // this example is just showing the usage of "Domains_ListOwnershipIdentifiers" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_GetDomainOwnershipIdentifier() // get the collection of this DomainOwnershipIdentifierResource DomainOwnershipIdentifierCollection collection = appServiceDomain.GetDomainOwnershipIdentifiers(); - // invoke the operation - string name = "SampleOwnershipId"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DomainOwnershipIdentifierResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DomainOwnershipIdentifierData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDomainOwnershipIdentifier() + public async Task Exists_GetDomainOwnershipIdentifier() { // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/GetDomainOwnershipIdentifier.json // this example is just showing the usage of "Domains_GetOwnershipIdentifier" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_GetDomainOwnershipIdentifier() // invoke the operation string name = "SampleOwnershipId"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DomainOwnershipIdentifierResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DomainOwnershipIdentifierData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAppServiceDomainOwnershipIdentifier() + public async Task GetIfExists_GetDomainOwnershipIdentifier() { - // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/CreateAppServiceDomainOwnershipIdentifier.json - // this example is just showing the usage of "Domains_CreateOrUpdateOwnershipIdentifier" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/GetDomainOwnershipIdentifier.json + // this example is just showing the usage of "Domains_GetOwnershipIdentifier" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_CreateAppServiceDomainOwnershipIdentifier() // invoke the operation string name = "SampleOwnershipId"; - DomainOwnershipIdentifierData data = new DomainOwnershipIdentifierData() - { - OwnershipId = "SampleOwnershipId", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DomainOwnershipIdentifierResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DomainOwnershipIdentifierResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DomainOwnershipIdentifierData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DomainOwnershipIdentifierData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DomainOwnershipIdentifierResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DomainOwnershipIdentifierResource.cs index 34324f757c444..250f3689366d2 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DomainOwnershipIdentifierResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_DomainOwnershipIdentifierResource.cs @@ -95,7 +95,7 @@ public async Task Update_UpdateAppServiceDomainOwnershipIdentifier() DomainOwnershipIdentifierResource domainOwnershipIdentifier = client.GetDomainOwnershipIdentifierResource(domainOwnershipIdentifierResourceId); // invoke the operation - DomainOwnershipIdentifierData data = new DomainOwnershipIdentifierData() + DomainOwnershipIdentifierData data = new DomainOwnershipIdentifierData { OwnershipId = "SampleOwnershipId", }; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentDetectorCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentDetectorCollection.cs index 35a79eea92523..ddf5a7da8f621 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentDetectorCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentDetectorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HostingEnvironmentDetectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAppServiceEnvironmentDetectorResponses() + public async Task Get_GetAppServiceEnvironmentDetectorResponses() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListHostingEnvironmentDetectorResponses.json - // this example is just showing the usage of "Diagnostics_ListHostingEnvironmentDetectorResponses" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetHostingEnvironmentDetectorResponse.json + // this example is just showing the usage of "Diagnostics_GetHostingEnvironmentDetectorResponse" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetAppServiceEnvironmentDetectorResponses() // get the collection of this HostingEnvironmentDetectorResource HostingEnvironmentDetectorCollection collection = appServiceEnvironment.GetHostingEnvironmentDetectors(); - // invoke the operation and iterate over the result - await foreach (HostingEnvironmentDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "runtimeavailability"; + HostingEnvironmentDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppServiceEnvironmentDetectorResponses() + public async Task GetAll_GetAppServiceEnvironmentDetectorResponses() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetHostingEnvironmentDetectorResponse.json - // this example is just showing the usage of "Diagnostics_GetHostingEnvironmentDetectorResponse" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListHostingEnvironmentDetectorResponses.json + // this example is just showing the usage of "Diagnostics_ListHostingEnvironmentDetectorResponses" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetAppServiceEnvironmentDetectorResponses() // get the collection of this HostingEnvironmentDetectorResource HostingEnvironmentDetectorCollection collection = appServiceEnvironment.GetHostingEnvironmentDetectors(); - // invoke the operation - string detectorName = "runtimeavailability"; - HostingEnvironmentDetectorResource result = await collection.GetAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (HostingEnvironmentDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentMultiRolePoolResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentMultiRolePoolResource.cs index 41cee089663db..dfb463f99bbca 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentMultiRolePoolResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentMultiRolePoolResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetPropertiesOfAMultiRolePool() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAMultiRolePool() + public async Task Update_CreateOrUpdateAMultiRolePool() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_CreateOrUpdateMultiRolePool.json - // this example is just showing the usage of "AppServiceEnvironments_CreateOrUpdateMultiRolePool" operation, for the dependent resources, they will have to be created separately. + // this example is just showing the usage of "AppServiceEnvironments_UpdateMultiRolePool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +67,12 @@ public async Task CreateOrUpdate_CreateOrUpdateAMultiRolePool() HostingEnvironmentMultiRolePoolResource hostingEnvironmentMultiRolePool = client.GetHostingEnvironmentMultiRolePoolResource(hostingEnvironmentMultiRolePoolResourceId); // invoke the operation - AppServiceWorkerPoolData data = new AppServiceWorkerPoolData() + AppServiceWorkerPoolData data = new AppServiceWorkerPoolData { WorkerSize = "Medium", WorkerCount = 3, }; - ArmOperation lro = await hostingEnvironmentMultiRolePool.CreateOrUpdateAsync(WaitUntil.Completed, data); - HostingEnvironmentMultiRolePoolResource result = lro.Value; + HostingEnvironmentMultiRolePoolResource result = await hostingEnvironmentMultiRolePool.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -84,10 +83,10 @@ public async Task CreateOrUpdate_CreateOrUpdateAMultiRolePool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAMultiRolePool() + public async Task CreateOrUpdate_CreateOrUpdateAMultiRolePool() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_CreateOrUpdateMultiRolePool.json - // this example is just showing the usage of "AppServiceEnvironments_UpdateMultiRolePool" operation, for the dependent resources, they will have to be created separately. + // this example is just showing the usage of "AppServiceEnvironments_CreateOrUpdateMultiRolePool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,12 +102,13 @@ public async Task Update_CreateOrUpdateAMultiRolePool() HostingEnvironmentMultiRolePoolResource hostingEnvironmentMultiRolePool = client.GetHostingEnvironmentMultiRolePoolResource(hostingEnvironmentMultiRolePoolResourceId); // invoke the operation - AppServiceWorkerPoolData data = new AppServiceWorkerPoolData() + AppServiceWorkerPoolData data = new AppServiceWorkerPoolData { WorkerSize = "Medium", WorkerCount = 3, }; - HostingEnvironmentMultiRolePoolResource result = await hostingEnvironmentMultiRolePool.UpdateAsync(data); + ArmOperation lro = await hostingEnvironmentMultiRolePool.CreateOrUpdateAsync(WaitUntil.Completed, data); + HostingEnvironmentMultiRolePoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentPrivateEndpointConnectionCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentPrivateEndpointConnectionCollection.cs index 270039e8ec545..8cd8763e3d1e6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentPrivateEndpointConnectionCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HostingEnvironmentPrivateEndpointConnectionCollectio { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfPrivateEndpointsAssociatedWithAHostingEnvironment() + public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnection() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_GetPrivateEndpointConnectionList.json - // this example is just showing the usage of "AppServiceEnvironments_GetPrivateEndpointConnectionList" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_ApproveOrRejectPrivateEndpointConnection.json + // this example is just showing the usage of "AppServiceEnvironments_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_GetsTheListOfPrivateEndpointsAssociatedWithAHostingEnvi // get the collection of this HostingEnvironmentPrivateEndpointConnectionResource HostingEnvironmentPrivateEndpointConnectionCollection collection = appServiceEnvironment.GetHostingEnvironmentPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (HostingEnvironmentPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "fa38656c-034e-43d8-adce-fe06ce039c98"; + RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrivateLinkServiceConnectionState = new PrivateLinkConnectionState + { + Status = "Approved", + Description = "Approved by johndoe@company.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + HostingEnvironmentPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_GetsAPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAPrivateEndpointConnection() + public async Task GetAll_GetsTheListOfPrivateEndpointsAssociatedWithAHostingEnvironment() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_GetPrivateEndpointConnection.json - // this example is just showing the usage of "AppServiceEnvironments_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_GetPrivateEndpointConnectionList.json + // this example is just showing the usage of "AppServiceEnvironments_GetPrivateEndpointConnectionList" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_GetsAPrivateEndpointConnection() // get the collection of this HostingEnvironmentPrivateEndpointConnectionResource HostingEnvironmentPrivateEndpointConnectionCollection collection = appServiceEnvironment.GetHostingEnvironmentPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "fa38656c-034e-43d8-adce-fe06ce039c98"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (HostingEnvironmentPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAPrivateEndpointConnection() + public async Task Exists_GetsAPrivateEndpointConnection() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_GetPrivateEndpointConnection.json // this example is just showing the usage of "AppServiceEnvironments_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_GetsAPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "fa38656c-034e-43d8-adce-fe06ce039c98"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - HostingEnvironmentPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnection() + public async Task GetIfExists_GetsAPrivateEndpointConnection() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_ApproveOrRejectPrivateEndpointConnection.json - // this example is just showing the usage of "AppServiceEnvironments_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_GetPrivateEndpointConnection.json + // this example is just showing the usage of "AppServiceEnvironments_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "fa38656c-034e-43d8-adce-fe06ce039c98"; - RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData() - { - PrivateLinkServiceConnectionState = new PrivateLinkConnectionState() - { - Status = "Approved", - Description = "Approved by johndoe@company.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - HostingEnvironmentPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + HostingEnvironmentPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentPrivateEndpointConnectionResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentPrivateEndpointConnectionResource.cs index c42bad756993b..33960cd3e2c2e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentPrivateEndpointConnectionResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsAPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApprovesOrRejectsAPrivateEndpointConnection() + public async Task Delete_DeletesAPrivateEndpointConnection() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_ApproveOrRejectPrivateEndpointConnection.json - // this example is just showing the usage of "AppServiceEnvironments_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_DeletePrivateEndpointConnection.json + // this example is just showing the usage of "AppServiceEnvironments_DeletePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,18 @@ public async Task Update_ApprovesOrRejectsAPrivateEndpointConnection() HostingEnvironmentPrivateEndpointConnectionResource hostingEnvironmentPrivateEndpointConnection = client.GetHostingEnvironmentPrivateEndpointConnectionResource(hostingEnvironmentPrivateEndpointConnectionResourceId); // invoke the operation - RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData() - { - PrivateLinkServiceConnectionState = new PrivateLinkConnectionState() - { - Status = "Approved", - Description = "Approved by johndoe@company.com", - }, - }; - ArmOperation lro = await hostingEnvironmentPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - HostingEnvironmentPrivateEndpointConnectionResource result = lro.Value; + ArmOperation lro = await hostingEnvironmentPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + BinaryData result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPrivateEndpointConnection() + public async Task Update_ApprovesOrRejectsAPrivateEndpointConnection() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_DeletePrivateEndpointConnection.json - // this example is just showing the usage of "AppServiceEnvironments_DeletePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_ApproveOrRejectPrivateEndpointConnection.json + // this example is just showing the usage of "AppServiceEnvironments_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,10 +97,22 @@ public async Task Delete_DeletesAPrivateEndpointConnection() HostingEnvironmentPrivateEndpointConnectionResource hostingEnvironmentPrivateEndpointConnection = client.GetHostingEnvironmentPrivateEndpointConnectionResource(hostingEnvironmentPrivateEndpointConnectionResourceId); // invoke the operation - ArmOperation lro = await hostingEnvironmentPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - BinaryData result = lro.Value; + RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData + { + PrivateLinkServiceConnectionState = new PrivateLinkConnectionState + { + Status = "Approved", + Description = "Approved by johndoe@company.com", + }, + }; + ArmOperation lro = await hostingEnvironmentPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + HostingEnvironmentPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentWorkerPoolCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentWorkerPoolCollection.cs index e4b409f98b2f3..d1b08c8b363fa 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentWorkerPoolCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentWorkerPoolCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HostingEnvironmentWorkerPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllWorkerPoolsOfAnAppServiceEnvironment() + public async Task CreateOrUpdate_GetPropertiesOfAWorkerPool() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_ListWorkerPools.json - // this example is just showing the usage of "AppServiceEnvironments_ListWorkerPools" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_CreateOrUpdateWorkerPool.json + // this example is just showing the usage of "AppServiceEnvironments_CreateOrUpdateWorkerPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_GetAllWorkerPoolsOfAnAppServiceEnvironment() // get the collection of this HostingEnvironmentWorkerPoolResource HostingEnvironmentWorkerPoolCollection collection = appServiceEnvironment.GetHostingEnvironmentWorkerPools(); - // invoke the operation and iterate over the result - await foreach (HostingEnvironmentWorkerPoolResource item in collection.GetAllAsync()) + // invoke the operation + string workerPoolName = "0"; + AppServiceWorkerPoolData data = new AppServiceWorkerPoolData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceWorkerPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + WorkerSize = "Small", + WorkerCount = 3, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workerPoolName, data); + HostingEnvironmentWorkerPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceWorkerPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_GetPropertiesOfAWorkerPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPropertiesOfAWorkerPool() + public async Task GetAll_GetAllWorkerPoolsOfAnAppServiceEnvironment() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_GetWorkerPool.json - // this example is just showing the usage of "AppServiceEnvironments_GetWorkerPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_ListWorkerPools.json + // this example is just showing the usage of "AppServiceEnvironments_ListWorkerPools" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_GetPropertiesOfAWorkerPool() // get the collection of this HostingEnvironmentWorkerPoolResource HostingEnvironmentWorkerPoolCollection collection = appServiceEnvironment.GetHostingEnvironmentWorkerPools(); - // invoke the operation - string workerPoolName = "workerPool1"; - bool result = await collection.ExistsAsync(workerPoolName); + // invoke the operation and iterate over the result + await foreach (HostingEnvironmentWorkerPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceWorkerPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPropertiesOfAWorkerPool() + public async Task Exists_GetPropertiesOfAWorkerPool() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_GetWorkerPool.json // this example is just showing the usage of "AppServiceEnvironments_GetWorkerPool" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_GetPropertiesOfAWorkerPool() // invoke the operation string workerPoolName = "workerPool1"; - NullableResponse response = await collection.GetIfExistsAsync(workerPoolName); - HostingEnvironmentWorkerPoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(workerPoolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceWorkerPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GetPropertiesOfAWorkerPool() + public async Task GetIfExists_GetPropertiesOfAWorkerPool() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_CreateOrUpdateWorkerPool.json - // this example is just showing the usage of "AppServiceEnvironments_CreateOrUpdateWorkerPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_GetWorkerPool.json + // this example is just showing the usage of "AppServiceEnvironments_GetWorkerPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,20 +179,22 @@ public async Task CreateOrUpdate_GetPropertiesOfAWorkerPool() HostingEnvironmentWorkerPoolCollection collection = appServiceEnvironment.GetHostingEnvironmentWorkerPools(); // invoke the operation - string workerPoolName = "0"; - AppServiceWorkerPoolData data = new AppServiceWorkerPoolData() - { - WorkerSize = "Small", - WorkerCount = 3, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workerPoolName, data); - HostingEnvironmentWorkerPoolResource result = lro.Value; + string workerPoolName = "workerPool1"; + NullableResponse response = await collection.GetIfExistsAsync(workerPoolName); + HostingEnvironmentWorkerPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceWorkerPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceWorkerPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentWorkerPoolResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentWorkerPoolResource.cs index a1b9de163d1e7..2ec471091deab 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentWorkerPoolResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_HostingEnvironmentWorkerPoolResource.cs @@ -69,7 +69,7 @@ public async Task Update_GetPropertiesOfAWorkerPool() HostingEnvironmentWorkerPoolResource hostingEnvironmentWorkerPool = client.GetHostingEnvironmentWorkerPoolResource(hostingEnvironmentWorkerPoolResourceId); // invoke the operation - AppServiceWorkerPoolData data = new AppServiceWorkerPoolData() + AppServiceWorkerPoolData data = new AppServiceWorkerPoolData { WorkerSize = "Small", WorkerCount = 3, diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_KubeEnvironmentCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_KubeEnvironmentCollection.cs index aafccd0f3b9b3..cf3776f9f3b24 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_KubeEnvironmentCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_KubeEnvironmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_KubeEnvironmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListKubeEnvironmentsByResourceGroup() + public async Task CreateOrUpdate_CreateKubeEnvironments() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/KubeEnvironments_ListByResourceGroup.json - // this example is just showing the usage of "KubeEnvironments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/KubeEnvironments_CreateOrUpdate.json + // this example is just showing the usage of "KubeEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task GetAll_ListKubeEnvironmentsByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "examplerg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -38,17 +38,20 @@ public async Task GetAll_ListKubeEnvironmentsByResourceGroup() // get the collection of this KubeEnvironmentResource KubeEnvironmentCollection collection = resourceGroupResource.GetKubeEnvironments(); - // invoke the operation and iterate over the result - await foreach (KubeEnvironmentResource item in collection.GetAllAsync()) + // invoke the operation + string name = "testkubeenv"; + KubeEnvironmentData data = new KubeEnvironmentData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KubeEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StaticIP = "1.2.3.4", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + KubeEnvironmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KubeEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +89,10 @@ public async Task Get_GetKubeEnvironmentsByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetKubeEnvironmentsByName() + public async Task GetAll_ListKubeEnvironmentsByResourceGroup() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/KubeEnvironments_Get.json - // this example is just showing the usage of "KubeEnvironments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/KubeEnvironments_ListByResourceGroup.json + // this example is just showing the usage of "KubeEnvironments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +109,22 @@ public async Task Exists_GetKubeEnvironmentsByName() // get the collection of this KubeEnvironmentResource KubeEnvironmentCollection collection = resourceGroupResource.GetKubeEnvironments(); - // invoke the operation - string name = "jlaw-demo1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (KubeEnvironmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KubeEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetKubeEnvironmentsByName() + public async Task Exists_GetKubeEnvironmentsByName() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/KubeEnvironments_Get.json // this example is just showing the usage of "KubeEnvironments_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +146,17 @@ public async Task GetIfExists_GetKubeEnvironmentsByName() // invoke the operation string name = "jlaw-demo1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - KubeEnvironmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KubeEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateKubeEnvironments() + public async Task GetIfExists_GetKubeEnvironmentsByName() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/KubeEnvironments_CreateOrUpdate.json - // this example is just showing the usage of "KubeEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/KubeEnvironments_Get.json + // this example is just showing the usage of "KubeEnvironments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -168,7 +165,7 @@ public async Task CreateOrUpdate_CreateKubeEnvironments() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; string resourceGroupName = "examplerg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -177,19 +174,22 @@ public async Task CreateOrUpdate_CreateKubeEnvironments() KubeEnvironmentCollection collection = resourceGroupResource.GetKubeEnvironments(); // invoke the operation - string name = "testkubeenv"; - KubeEnvironmentData data = new KubeEnvironmentData(new AzureLocation("East US")) - { - StaticIP = "1.2.3.4", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - KubeEnvironmentResource result = lro.Value; + string name = "jlaw-demo1"; + NullableResponse response = await collection.GetIfExistsAsync(name); + KubeEnvironmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KubeEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KubeEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_KubeEnvironmentResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_KubeEnvironmentResource.cs index 21fa35cbc5a0e..333b726a5234f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_KubeEnvironmentResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_KubeEnvironmentResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_KubeEnvironmentResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetKubeEnvironments_ListKubeEnvironmentsBySubscription() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/KubeEnvironments_ListBySubscription.json - // this example is just showing the usage of "KubeEnvironments_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (KubeEnvironmentResource item in subscriptionResource.GetKubeEnvironmentsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KubeEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetKubeEnvironmentsByName() @@ -125,7 +93,7 @@ public async Task Update_UpdateKubeEnvironments() KubeEnvironmentResource kubeEnvironment = client.GetKubeEnvironmentResource(kubeEnvironmentResourceId); // invoke the operation - KubeEnvironmentPatch patch = new KubeEnvironmentPatch() + KubeEnvironmentPatch patch = new KubeEnvironmentPatch { StaticIP = "1.2.3.4", }; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_ScmSiteBasicPublishingCredentialsPolicyResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_ScmSiteBasicPublishingCredentialsPolicyResource.cs index 16588f0565254..d924191cdd8f8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_ScmSiteBasicPublishingCredentialsPolicyResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_ScmSiteBasicPublishingCredentialsPolicyResource.cs @@ -66,7 +66,7 @@ public async Task CreateOrUpdate_UpdateSCMAllowed() ScmSiteBasicPublishingCredentialsPolicyResource scmSiteBasicPublishingCredentialsPolicy = client.GetScmSiteBasicPublishingCredentialsPolicyResource(scmSiteBasicPublishingCredentialsPolicyResourceId); // invoke the operation - CsmPublishingCredentialsPoliciesEntityData data = new CsmPublishingCredentialsPoliciesEntityData() + CsmPublishingCredentialsPoliciesEntityData data = new CsmPublishingCredentialsPoliciesEntityData { Allow = true, }; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_ScmSiteSlotBasicPublishingCredentialsPolicyResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_ScmSiteSlotBasicPublishingCredentialsPolicyResource.cs index 994d85a349eff..c9675bb5e62d8 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_ScmSiteSlotBasicPublishingCredentialsPolicyResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_ScmSiteSlotBasicPublishingCredentialsPolicyResource.cs @@ -68,7 +68,7 @@ public async Task CreateOrUpdate_UpdateSCMAllowed() ScmSiteSlotBasicPublishingCredentialsPolicyResource scmSiteSlotBasicPublishingCredentialsPolicy = client.GetScmSiteSlotBasicPublishingCredentialsPolicyResource(scmSiteSlotBasicPublishingCredentialsPolicyResourceId); // invoke the operation - CsmPublishingCredentialsPoliciesEntityData data = new CsmPublishingCredentialsPoliciesEntityData() + CsmPublishingCredentialsPoliciesEntityData data = new CsmPublishingCredentialsPoliciesEntityData { Allow = true, }; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteBackupCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteBackupCollection.cs index 92194f6b32035..c17147229b1b3 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteBackupCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteBackupCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteBackupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWebAppBackups() + public async Task Get_GetWebAppBackup() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWebAppBackups.json - // this example is just showing the usage of "WebApps_ListBackups" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebAppBackup.json + // this example is just showing the usage of "WebApps_GetBackupStatus" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListWebAppBackups() // get the collection of this SiteBackupResource SiteBackupCollection collection = webSite.GetSiteBackups(); - // invoke the operation and iterate over the result - await foreach (SiteBackupResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebAppBackupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string backupId = "12345"; + SiteBackupResource result = await collection.GetAsync(backupId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebAppBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWebAppBackup() + public async Task GetAll_ListWebAppBackups() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebAppBackup.json - // this example is just showing the usage of "WebApps_GetBackupStatus" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWebAppBackups.json + // this example is just showing the usage of "WebApps_ListBackups" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetWebAppBackup() // get the collection of this SiteBackupResource SiteBackupCollection collection = webSite.GetSiteBackups(); - // invoke the operation - string backupId = "12345"; - SiteBackupResource result = await collection.GetAsync(backupId); + // invoke the operation and iterate over the result + await foreach (SiteBackupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebAppBackupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebAppBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteBackupResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteBackupResource.cs index d969b03e673b4..5da4383b2ea86 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteBackupResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteBackupResource.cs @@ -96,7 +96,7 @@ public async Task GetBackupStatusSecrets_GetWebAppBackupWithSecrets() SiteBackupResource siteBackup = client.GetSiteBackupResource(siteBackupResourceId); // invoke the operation - WebAppBackupInfo info = new WebAppBackupInfo() + WebAppBackupInfo info = new WebAppBackupInfo { BackupName = "abcdwe", IsEnabled = true, @@ -105,20 +105,17 @@ public async Task GetBackupStatusSecrets_GetWebAppBackupWithSecrets() { StartOn = DateTimeOffset.Parse("2022-09-02T17:33:11.641Z"), }, - Databases = -{ -new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) + Databases = {new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) { Name = "backenddb", ConnectionStringName = "backend", ConnectionString = "DSN=data-source-name[;SERVER=value] [;PWD=value] [;UID=value] [;=]", -},new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) +}, new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) { Name = "statsdb", ConnectionStringName = "stats", ConnectionString = "DSN=data-source-name[;SERVER=value] [;PWD=value] [;UID=value] [;=]", -} -}, +}}, }; SiteBackupResource result = await siteBackup.GetBackupStatusSecretsAsync(info); @@ -151,25 +148,22 @@ public async Task Restore_RestoreWebAppFromBackup() SiteBackupResource siteBackup = client.GetSiteBackupResource(siteBackupResourceId); // invoke the operation - RestoreRequestInfo info = new RestoreRequestInfo() + RestoreRequestInfo info = new RestoreRequestInfo { StorageAccountUri = new Uri("DefaultEndpointsProtocol=https;AccountName=storagesample;AccountKey="), CanOverwrite = true, SiteName = "sitef6141", - Databases = -{ -new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) + Databases = {new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) { Name = "backenddb", ConnectionStringName = "backend", ConnectionString = "DSN=data-source-name[;SERVER=value] [;PWD=value] [;UID=value] [;=]", -},new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) +}, new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) { Name = "statsdb", ConnectionStringName = "stats", ConnectionString = "DSN=data-source-name[;SERVER=value] [;PWD=value] [;UID=value] [;=]", -} -}, +}}, }; await siteBackup.RestoreAsync(WaitUntil.Completed, info); diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteConfigAppsettingCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteConfigAppsettingCollection.cs index 4e03a12330cc7..d349bc95fd8e9 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteConfigAppsettingCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteConfigAppsettingCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteConfigAppsettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAzureKeyVaultReferencesForAppSettings() + public async Task Get_GetAzureKeyVaultAppSettingReference() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetKeyVaultReferencesForAppSettings.json - // this example is just showing the usage of "WebApps_GetAppSettingsKeyVaultReferences" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetKeyVaultReferencesForAppSetting.json + // this example is just showing the usage of "WebApps_GetAppSettingKeyVaultReference" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetAzureKeyVaultReferencesForAppSettings() // get the collection of this SiteConfigAppsettingResource SiteConfigAppsettingCollection collection = webSite.GetSiteConfigAppsettings(); - // invoke the operation and iterate over the result - await foreach (SiteConfigAppsettingResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiKeyVaultReferenceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string appSettingKey = "setting"; + SiteConfigAppsettingResource result = await collection.GetAsync(appSettingKey); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiKeyVaultReferenceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureKeyVaultAppSettingReference() + public async Task GetAll_GetAzureKeyVaultReferencesForAppSettings() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetKeyVaultReferencesForAppSetting.json - // this example is just showing the usage of "WebApps_GetAppSettingKeyVaultReference" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetKeyVaultReferencesForAppSettings.json + // this example is just showing the usage of "WebApps_GetAppSettingsKeyVaultReferences" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetAzureKeyVaultAppSettingReference() // get the collection of this SiteConfigAppsettingResource SiteConfigAppsettingCollection collection = webSite.GetSiteConfigAppsettings(); - // invoke the operation - string appSettingKey = "setting"; - SiteConfigAppsettingResource result = await collection.GetAsync(appSettingKey); + // invoke the operation and iterate over the result + await foreach (SiteConfigAppsettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiKeyVaultReferenceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiKeyVaultReferenceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDetectorCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDetectorCollection.cs index 484eb08f53691..907675b6a209d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDetectorCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDetectorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteDetectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAppDetectorResponses() + public async Task Get_GetAppDetectorResponse() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorResponses.json - // this example is just showing the usage of "Diagnostics_ListSiteDetectorResponses" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponse.json + // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponse" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetAppDetectorResponses() // get the collection of this SiteDetectorResource SiteDetectorCollection collection = webSite.GetSiteDetectors(); - // invoke the operation and iterate over the result - await foreach (SiteDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "runtimeavailability"; + SiteDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAppSlotDetectorResponses() + public async Task Get_GetAppSlotDetectorResponse() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorResponsesSlot.json - // this example is just showing the usage of "Diagnostics_ListSiteDetectorResponses" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponseSlot.json + // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponse" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,25 +72,23 @@ public async Task GetAll_GetAppSlotDetectorResponses() // get the collection of this SiteDetectorResource SiteDetectorCollection collection = webSite.GetSiteDetectors(); - // invoke the operation and iterate over the result - await foreach (SiteDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "runtimeavailability"; + SiteDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppDetectorResponse() + public async Task GetAll_GetAppDetectorResponses() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponse.json - // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponse" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorResponses.json + // this example is just showing the usage of "Diagnostics_ListSiteDetectorResponses" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,23 +106,25 @@ public async Task Get_GetAppDetectorResponse() // get the collection of this SiteDetectorResource SiteDetectorCollection collection = webSite.GetSiteDetectors(); - // invoke the operation - string detectorName = "runtimeavailability"; - SiteDetectorResource result = await collection.GetAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (SiteDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppDetectorResponse() + public async Task GetAll_GetAppSlotDetectorResponses() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponse.json - // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponse" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorResponsesSlot.json + // this example is just showing the usage of "Diagnostics_ListSiteDetectorResponses" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,16 +142,22 @@ public async Task Exists_GetAppDetectorResponse() // get the collection of this SiteDetectorResource SiteDetectorCollection collection = webSite.GetSiteDetectors(); - // invoke the operation - string detectorName = "runtimeavailability"; - bool result = await collection.ExistsAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (SiteDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppDetectorResponse() + public async Task Exists_GetAppDetectorResponse() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponse.json // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponse" operation, for the dependent resources, they will have to be created separately. @@ -176,26 +180,14 @@ public async Task GetIfExists_GetAppDetectorResponse() // invoke the operation string detectorName = "runtimeavailability"; - NullableResponse response = await collection.GetIfExistsAsync(detectorName); - SiteDetectorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(detectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppSlotDetectorResponse() + public async Task Exists_GetAppSlotDetectorResponse() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponseSlot.json // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponse" operation, for the dependent resources, they will have to be created separately. @@ -218,20 +210,16 @@ public async Task Get_GetAppSlotDetectorResponse() // invoke the operation string detectorName = "runtimeavailability"; - SiteDetectorResource result = await collection.GetAsync(detectorName); + bool result = await collection.ExistsAsync(detectorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppSlotDetectorResponse() + public async Task GetIfExists_GetAppDetectorResponse() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponseSlot.json + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponse.json // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponse" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -252,9 +240,21 @@ public async Task Exists_GetAppSlotDetectorResponse() // invoke the operation string detectorName = "runtimeavailability"; - bool result = await collection.ExistsAsync(detectorName); + NullableResponse response = await collection.GetIfExistsAsync(detectorName); + SiteDetectorResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticAnalysisCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticAnalysisCollection.cs index bc4aa09a5ee57..b9ef8599f448f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticAnalysisCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticAnalysisCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteDiagnosticAnalysisCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppAnalyses() + public async Task Get_GetAppAnalysis() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteAnalyses.json - // this example is just showing the usage of "Diagnostics_ListSiteAnalyses" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysis.json + // this example is just showing the usage of "Diagnostics_GetSiteAnalysis" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListAppAnalyses() // get the collection of this SiteDiagnosticAnalysisResource SiteDiagnosticAnalysisCollection collection = siteDiagnostic.GetSiteDiagnosticAnalyses(); - // invoke the operation and iterate over the result - await foreach (SiteDiagnosticAnalysisResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteAnalysisDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string analysisName = "appanalysis"; + SiteDiagnosticAnalysisResource result = await collection.GetAsync(analysisName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteAnalysisDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppSlotAnalyses() + public async Task Get_GetAppSlotAnalysis() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteAnalysesSlot.json - // this example is just showing the usage of "Diagnostics_ListSiteAnalyses" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysisSlot.json + // this example is just showing the usage of "Diagnostics_GetSiteAnalysis" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,25 +74,23 @@ public async Task GetAll_ListAppSlotAnalyses() // get the collection of this SiteDiagnosticAnalysisResource SiteDiagnosticAnalysisCollection collection = siteDiagnostic.GetSiteDiagnosticAnalyses(); - // invoke the operation and iterate over the result - await foreach (SiteDiagnosticAnalysisResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteAnalysisDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string analysisName = "appanalysis"; + SiteDiagnosticAnalysisResource result = await collection.GetAsync(analysisName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteAnalysisDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppAnalysis() + public async Task GetAll_ListAppAnalyses() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysis.json - // this example is just showing the usage of "Diagnostics_GetSiteAnalysis" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteAnalyses.json + // this example is just showing the usage of "Diagnostics_ListSiteAnalyses" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,23 +109,25 @@ public async Task Get_GetAppAnalysis() // get the collection of this SiteDiagnosticAnalysisResource SiteDiagnosticAnalysisCollection collection = siteDiagnostic.GetSiteDiagnosticAnalyses(); - // invoke the operation - string analysisName = "appanalysis"; - SiteDiagnosticAnalysisResource result = await collection.GetAsync(analysisName); + // invoke the operation and iterate over the result + await foreach (SiteDiagnosticAnalysisResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteAnalysisDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteAnalysisDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppAnalysis() + public async Task GetAll_ListAppSlotAnalyses() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysis.json - // this example is just showing the usage of "Diagnostics_GetSiteAnalysis" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteAnalysesSlot.json + // this example is just showing the usage of "Diagnostics_ListSiteAnalyses" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,16 +146,22 @@ public async Task Exists_GetAppAnalysis() // get the collection of this SiteDiagnosticAnalysisResource SiteDiagnosticAnalysisCollection collection = siteDiagnostic.GetSiteDiagnosticAnalyses(); - // invoke the operation - string analysisName = "appanalysis"; - bool result = await collection.ExistsAsync(analysisName); + // invoke the operation and iterate over the result + await foreach (SiteDiagnosticAnalysisResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteAnalysisDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppAnalysis() + public async Task Exists_GetAppAnalysis() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysis.json // this example is just showing the usage of "Diagnostics_GetSiteAnalysis" operation, for the dependent resources, they will have to be created separately. @@ -181,26 +185,14 @@ public async Task GetIfExists_GetAppAnalysis() // invoke the operation string analysisName = "appanalysis"; - NullableResponse response = await collection.GetIfExistsAsync(analysisName); - SiteDiagnosticAnalysisResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(analysisName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteAnalysisDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppSlotAnalysis() + public async Task Exists_GetAppSlotAnalysis() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysisSlot.json // this example is just showing the usage of "Diagnostics_GetSiteAnalysis" operation, for the dependent resources, they will have to be created separately. @@ -224,20 +216,16 @@ public async Task Get_GetAppSlotAnalysis() // invoke the operation string analysisName = "appanalysis"; - SiteDiagnosticAnalysisResource result = await collection.GetAsync(analysisName); + bool result = await collection.ExistsAsync(analysisName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteAnalysisDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppSlotAnalysis() + public async Task GetIfExists_GetAppAnalysis() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysisSlot.json + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysis.json // this example is just showing the usage of "Diagnostics_GetSiteAnalysis" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -259,9 +247,21 @@ public async Task Exists_GetAppSlotAnalysis() // invoke the operation string analysisName = "appanalysis"; - bool result = await collection.ExistsAsync(analysisName); + NullableResponse response = await collection.GetIfExistsAsync(analysisName); + SiteDiagnosticAnalysisResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteAnalysisDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticCollection.cs index c953ff537c9f1..4cb5f459700ee 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteDiagnosticCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppDiagnosticCategories() + public async Task Get_GetAppDiagnosticCategory() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDiagnosticCategories.json - // this example is just showing the usage of "Diagnostics_ListSiteDiagnosticCategories" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategory.json + // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListAppDiagnosticCategories() // get the collection of this SiteDiagnosticResource SiteDiagnosticCollection collection = webSite.GetSiteDiagnostics(); - // invoke the operation and iterate over the result - await foreach (SiteDiagnosticResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticCategoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string diagnosticCategory = "availability"; + SiteDiagnosticResource result = await collection.GetAsync(diagnosticCategory); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticCategoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppSlotDiagnosticCategories() + public async Task Get_GetAppSlotDiagnosticCategory() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDiagnosticCategoriesSlot.json - // this example is just showing the usage of "Diagnostics_ListSiteDiagnosticCategories" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategorySlot.json + // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,25 +72,23 @@ public async Task GetAll_ListAppSlotDiagnosticCategories() // get the collection of this SiteDiagnosticResource SiteDiagnosticCollection collection = webSite.GetSiteDiagnostics(); - // invoke the operation and iterate over the result - await foreach (SiteDiagnosticResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticCategoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string diagnosticCategory = "availability"; + SiteDiagnosticResource result = await collection.GetAsync(diagnosticCategory); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticCategoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppDiagnosticCategory() + public async Task GetAll_ListAppDiagnosticCategories() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategory.json - // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategory" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDiagnosticCategories.json + // this example is just showing the usage of "Diagnostics_ListSiteDiagnosticCategories" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,23 +106,25 @@ public async Task Get_GetAppDiagnosticCategory() // get the collection of this SiteDiagnosticResource SiteDiagnosticCollection collection = webSite.GetSiteDiagnostics(); - // invoke the operation - string diagnosticCategory = "availability"; - SiteDiagnosticResource result = await collection.GetAsync(diagnosticCategory); + // invoke the operation and iterate over the result + await foreach (SiteDiagnosticResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticCategoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticCategoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppDiagnosticCategory() + public async Task GetAll_ListAppSlotDiagnosticCategories() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategory.json - // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategory" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDiagnosticCategoriesSlot.json + // this example is just showing the usage of "Diagnostics_ListSiteDiagnosticCategories" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,16 +142,22 @@ public async Task Exists_GetAppDiagnosticCategory() // get the collection of this SiteDiagnosticResource SiteDiagnosticCollection collection = webSite.GetSiteDiagnostics(); - // invoke the operation - string diagnosticCategory = "availability"; - bool result = await collection.ExistsAsync(diagnosticCategory); + // invoke the operation and iterate over the result + await foreach (SiteDiagnosticResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticCategoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppDiagnosticCategory() + public async Task Exists_GetAppDiagnosticCategory() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategory.json // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategory" operation, for the dependent resources, they will have to be created separately. @@ -176,26 +180,14 @@ public async Task GetIfExists_GetAppDiagnosticCategory() // invoke the operation string diagnosticCategory = "availability"; - NullableResponse response = await collection.GetIfExistsAsync(diagnosticCategory); - SiteDiagnosticResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(diagnosticCategory); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticCategoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppSlotDiagnosticCategory() + public async Task Exists_GetAppSlotDiagnosticCategory() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategorySlot.json // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategory" operation, for the dependent resources, they will have to be created separately. @@ -218,20 +210,16 @@ public async Task Get_GetAppSlotDiagnosticCategory() // invoke the operation string diagnosticCategory = "availability"; - SiteDiagnosticResource result = await collection.GetAsync(diagnosticCategory); + bool result = await collection.ExistsAsync(diagnosticCategory); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticCategoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppSlotDiagnosticCategory() + public async Task GetIfExists_GetAppDiagnosticCategory() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategorySlot.json + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategory.json // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -252,9 +240,21 @@ public async Task Exists_GetAppSlotDiagnosticCategory() // invoke the operation string diagnosticCategory = "availability"; - bool result = await collection.ExistsAsync(diagnosticCategory); + NullableResponse response = await collection.GetIfExistsAsync(diagnosticCategory); + SiteDiagnosticResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticCategoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticDetectorCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticDetectorCollection.cs index 7342e221d8a16..a6450d7217eb7 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticDetectorCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteDiagnosticDetectorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteDiagnosticDetectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppDetectors() + public async Task Get_GetAppDetector() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectors.json - // this example is just showing the usage of "Diagnostics_ListSiteDetectors" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetector.json + // this example is just showing the usage of "Diagnostics_GetSiteDetector" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListAppDetectors() // get the collection of this SiteDiagnosticDetectorResource SiteDiagnosticDetectorCollection collection = siteDiagnostic.GetSiteDiagnosticDetectors(); - // invoke the operation and iterate over the result - await foreach (SiteDiagnosticDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DetectorDefinitionResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "sitecrashes"; + SiteDiagnosticDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DetectorDefinitionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppSlotDetectors() + public async Task Get_GetAppSlotDetector() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorsSlot.json - // this example is just showing the usage of "Diagnostics_ListSiteDetectors" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorSlot.json + // this example is just showing the usage of "Diagnostics_GetSiteDetector" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,25 +74,23 @@ public async Task GetAll_ListAppSlotDetectors() // get the collection of this SiteDiagnosticDetectorResource SiteDiagnosticDetectorCollection collection = siteDiagnostic.GetSiteDiagnosticDetectors(); - // invoke the operation and iterate over the result - await foreach (SiteDiagnosticDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DetectorDefinitionResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "sitecrashes"; + SiteDiagnosticDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DetectorDefinitionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppDetector() + public async Task GetAll_ListAppDetectors() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetector.json - // this example is just showing the usage of "Diagnostics_GetSiteDetector" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectors.json + // this example is just showing the usage of "Diagnostics_ListSiteDetectors" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,23 +109,25 @@ public async Task Get_GetAppDetector() // get the collection of this SiteDiagnosticDetectorResource SiteDiagnosticDetectorCollection collection = siteDiagnostic.GetSiteDiagnosticDetectors(); - // invoke the operation - string detectorName = "sitecrashes"; - SiteDiagnosticDetectorResource result = await collection.GetAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (SiteDiagnosticDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DetectorDefinitionResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DetectorDefinitionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppDetector() + public async Task GetAll_ListAppSlotDetectors() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetector.json - // this example is just showing the usage of "Diagnostics_GetSiteDetector" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorsSlot.json + // this example is just showing the usage of "Diagnostics_ListSiteDetectors" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,16 +146,22 @@ public async Task Exists_GetAppDetector() // get the collection of this SiteDiagnosticDetectorResource SiteDiagnosticDetectorCollection collection = siteDiagnostic.GetSiteDiagnosticDetectors(); - // invoke the operation - string detectorName = "sitecrashes"; - bool result = await collection.ExistsAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (SiteDiagnosticDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DetectorDefinitionResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppDetector() + public async Task Exists_GetAppDetector() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetector.json // this example is just showing the usage of "Diagnostics_GetSiteDetector" operation, for the dependent resources, they will have to be created separately. @@ -181,26 +185,14 @@ public async Task GetIfExists_GetAppDetector() // invoke the operation string detectorName = "sitecrashes"; - NullableResponse response = await collection.GetIfExistsAsync(detectorName); - SiteDiagnosticDetectorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(detectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DetectorDefinitionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppSlotDetector() + public async Task Exists_GetAppSlotDetector() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorSlot.json // this example is just showing the usage of "Diagnostics_GetSiteDetector" operation, for the dependent resources, they will have to be created separately. @@ -224,20 +216,16 @@ public async Task Get_GetAppSlotDetector() // invoke the operation string detectorName = "sitecrashes"; - SiteDiagnosticDetectorResource result = await collection.GetAsync(detectorName); + bool result = await collection.ExistsAsync(detectorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DetectorDefinitionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppSlotDetector() + public async Task GetIfExists_GetAppDetector() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorSlot.json + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetector.json // this example is just showing the usage of "Diagnostics_GetSiteDetector" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -259,9 +247,21 @@ public async Task Exists_GetAppSlotDetector() // invoke the operation string detectorName = "sitecrashes"; - bool result = await collection.ExistsAsync(detectorName); + NullableResponse response = await collection.GetIfExistsAsync(detectorName); + SiteDiagnosticDetectorResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DetectorDefinitionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SitePrivateEndpointConnectionCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SitePrivateEndpointConnectionCollection.cs index 529ea31f6cab4..431b0380143cb 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SitePrivateEndpointConnectionCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SitePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SitePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPrivateEndpointConnectionForASite() + public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnection.json - // this example is just showing the usage of "WebApps_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnection.json + // this example is just showing the usage of "WebApps_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_GetAPrivateEndpointConnectionForASite() // invoke the operation string privateEndpointConnectionName = "connection"; - SitePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData + { + PrivateLinkServiceConnectionState = new PrivateLinkConnectionState + { + Status = "Approved", + Description = "Approved by admin.", + ActionsRequired = "", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + SitePrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +62,7 @@ public async Task Get_GetAPrivateEndpointConnectionForASite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPrivateEndpointConnectionForASite() + public async Task Get_GetAPrivateEndpointConnectionForASite() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnection.json // this example is just showing the usage of "WebApps_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. @@ -75,14 +85,18 @@ public async Task Exists_GetAPrivateEndpointConnectionForASite() // invoke the operation string privateEndpointConnectionName = "connection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + SitePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPrivateEndpointConnectionForASite() + public async Task Exists_GetAPrivateEndpointConnectionForASite() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnection.json // this example is just showing the usage of "WebApps_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +119,17 @@ public async Task GetIfExists_GetAPrivateEndpointConnectionForASite() // invoke the operation string privateEndpointConnectionName = "connection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - SitePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForASite() + public async Task GetIfExists_GetAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnection.json - // this example is just showing the usage of "WebApps_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnection.json + // this example is just showing the usage of "WebApps_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,23 +149,21 @@ public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForA // invoke the operation string privateEndpointConnectionName = "connection"; - RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData() - { - PrivateLinkServiceConnectionState = new PrivateLinkConnectionState() - { - Status = "Approved", - Description = "Approved by admin.", - ActionsRequired = "", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - SitePrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + SitePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SitePrivateEndpointConnectionResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SitePrivateEndpointConnectionResource.cs index fdca885ce2a7a..932cf0060ea06 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SitePrivateEndpointConnectionResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SitePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAPrivateEndpointConnectionForASite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForASite() + public async Task Delete_DeleteAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnection.json - // this example is just showing the usage of "WebApps_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteSitePrivateEndpointConnection.json + // this example is just showing the usage of "WebApps_DeletePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,18 @@ public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForASite() SitePrivateEndpointConnectionResource sitePrivateEndpointConnection = client.GetSitePrivateEndpointConnectionResource(sitePrivateEndpointConnectionResourceId); // invoke the operation - RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData() - { - PrivateLinkServiceConnectionState = new PrivateLinkConnectionState() - { - Status = "Approved", - Description = "Approved by admin.", - ActionsRequired = "", - }, - }; - ArmOperation lro = await sitePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - SitePrivateEndpointConnectionResource result = lro.Value; + ArmOperation lro = await sitePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + BinaryData result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPrivateEndpointConnectionForASite() + public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteSitePrivateEndpointConnection.json - // this example is just showing the usage of "WebApps_DeletePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnection.json + // this example is just showing the usage of "WebApps_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,10 +97,23 @@ public async Task Delete_DeleteAPrivateEndpointConnectionForASite() SitePrivateEndpointConnectionResource sitePrivateEndpointConnection = client.GetSitePrivateEndpointConnectionResource(sitePrivateEndpointConnectionResourceId); // invoke the operation - ArmOperation lro = await sitePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - BinaryData result = lro.Value; + RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData + { + PrivateLinkServiceConnectionState = new PrivateLinkConnectionState + { + Status = "Approved", + Description = "Approved by admin.", + ActionsRequired = "", + }, + }; + ArmOperation lro = await sitePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + SitePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDetectorCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDetectorCollection.cs index e1279a5710545..8524d0a849481 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDetectorCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDetectorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteSlotDetectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAppDetectorResponses() + public async Task Get_GetAppDetectorResponse() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorResponses.json - // this example is just showing the usage of "Diagnostics_ListSiteDetectorResponsesSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponse.json + // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponseSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetAppDetectorResponses() // get the collection of this SiteSlotDetectorResource SiteSlotDetectorCollection collection = webSiteSlot.GetSiteSlotDetectors(); - // invoke the operation and iterate over the result - await foreach (SiteSlotDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "runtimeavailability"; + SiteSlotDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAppSlotDetectorResponses() + public async Task Get_GetAppSlotDetectorResponse() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorResponsesSlot.json - // this example is just showing the usage of "Diagnostics_ListSiteDetectorResponsesSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponseSlot.json + // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponseSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,25 +74,23 @@ public async Task GetAll_GetAppSlotDetectorResponses() // get the collection of this SiteSlotDetectorResource SiteSlotDetectorCollection collection = webSiteSlot.GetSiteSlotDetectors(); - // invoke the operation and iterate over the result - await foreach (SiteSlotDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "runtimeavailability"; + SiteSlotDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppDetectorResponse() + public async Task GetAll_GetAppDetectorResponses() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponse.json - // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponseSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorResponses.json + // this example is just showing the usage of "Diagnostics_ListSiteDetectorResponsesSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,23 +109,25 @@ public async Task Get_GetAppDetectorResponse() // get the collection of this SiteSlotDetectorResource SiteSlotDetectorCollection collection = webSiteSlot.GetSiteSlotDetectors(); - // invoke the operation - string detectorName = "runtimeavailability"; - SiteSlotDetectorResource result = await collection.GetAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (SiteSlotDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppDetectorResponse() + public async Task GetAll_GetAppSlotDetectorResponses() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponse.json - // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponseSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorResponsesSlot.json + // this example is just showing the usage of "Diagnostics_ListSiteDetectorResponsesSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,16 +146,22 @@ public async Task Exists_GetAppDetectorResponse() // get the collection of this SiteSlotDetectorResource SiteSlotDetectorCollection collection = webSiteSlot.GetSiteSlotDetectors(); - // invoke the operation - string detectorName = "runtimeavailability"; - bool result = await collection.ExistsAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (SiteSlotDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppDetectorResponse() + public async Task Exists_GetAppDetectorResponse() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponse.json // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponseSlot" operation, for the dependent resources, they will have to be created separately. @@ -181,26 +185,14 @@ public async Task GetIfExists_GetAppDetectorResponse() // invoke the operation string detectorName = "runtimeavailability"; - NullableResponse response = await collection.GetIfExistsAsync(detectorName); - SiteSlotDetectorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(detectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppSlotDetectorResponse() + public async Task Exists_GetAppSlotDetectorResponse() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponseSlot.json // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponseSlot" operation, for the dependent resources, they will have to be created separately. @@ -224,20 +216,16 @@ public async Task Get_GetAppSlotDetectorResponse() // invoke the operation string detectorName = "runtimeavailability"; - SiteSlotDetectorResource result = await collection.GetAsync(detectorName); + bool result = await collection.ExistsAsync(detectorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppServiceDetectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppSlotDetectorResponse() + public async Task GetIfExists_GetAppDetectorResponse() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponseSlot.json + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorResponse.json // this example is just showing the usage of "Diagnostics_GetSiteDetectorResponseSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -259,9 +247,21 @@ public async Task Exists_GetAppSlotDetectorResponse() // invoke the operation string detectorName = "runtimeavailability"; - bool result = await collection.ExistsAsync(detectorName); + NullableResponse response = await collection.GetIfExistsAsync(detectorName); + SiteSlotDetectorResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDetectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticAnalysisCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticAnalysisCollection.cs index 4fe4f4dc2866c..0d8ffd14eb7b0 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticAnalysisCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticAnalysisCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteSlotDiagnosticAnalysisCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppAnalyses() + public async Task Get_GetAppAnalysis() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteAnalyses.json - // this example is just showing the usage of "Diagnostics_ListSiteAnalysesSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysis.json + // this example is just showing the usage of "Diagnostics_GetSiteAnalysisSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListAppAnalyses() // get the collection of this SiteSlotDiagnosticAnalysisResource SiteSlotDiagnosticAnalysisCollection collection = siteSlotDiagnostic.GetSiteSlotDiagnosticAnalyses(); - // invoke the operation and iterate over the result - await foreach (SiteSlotDiagnosticAnalysisResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteAnalysisDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string analysisName = "appanalysis"; + SiteSlotDiagnosticAnalysisResource result = await collection.GetAsync(analysisName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteAnalysisDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppSlotAnalyses() + public async Task Get_GetAppSlotAnalysis() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteAnalysesSlot.json - // this example is just showing the usage of "Diagnostics_ListSiteAnalysesSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysisSlot.json + // this example is just showing the usage of "Diagnostics_GetSiteAnalysisSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,25 +76,23 @@ public async Task GetAll_ListAppSlotAnalyses() // get the collection of this SiteSlotDiagnosticAnalysisResource SiteSlotDiagnosticAnalysisCollection collection = siteSlotDiagnostic.GetSiteSlotDiagnosticAnalyses(); - // invoke the operation and iterate over the result - await foreach (SiteSlotDiagnosticAnalysisResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteAnalysisDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string analysisName = "appanalysis"; + SiteSlotDiagnosticAnalysisResource result = await collection.GetAsync(analysisName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteAnalysisDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppAnalysis() + public async Task GetAll_ListAppAnalyses() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysis.json - // this example is just showing the usage of "Diagnostics_GetSiteAnalysisSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteAnalyses.json + // this example is just showing the usage of "Diagnostics_ListSiteAnalysesSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,23 +112,25 @@ public async Task Get_GetAppAnalysis() // get the collection of this SiteSlotDiagnosticAnalysisResource SiteSlotDiagnosticAnalysisCollection collection = siteSlotDiagnostic.GetSiteSlotDiagnosticAnalyses(); - // invoke the operation - string analysisName = "appanalysis"; - SiteSlotDiagnosticAnalysisResource result = await collection.GetAsync(analysisName); + // invoke the operation and iterate over the result + await foreach (SiteSlotDiagnosticAnalysisResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteAnalysisDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteAnalysisDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppAnalysis() + public async Task GetAll_ListAppSlotAnalyses() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysis.json - // this example is just showing the usage of "Diagnostics_GetSiteAnalysisSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteAnalysesSlot.json + // this example is just showing the usage of "Diagnostics_ListSiteAnalysesSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,7 +142,7 @@ public async Task Exists_GetAppAnalysis() string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "Sample-WestUSResourceGroup"; string siteName = "SampleApp"; - string slot = "Production"; + string slot = "staging"; string diagnosticCategory = "availability"; ResourceIdentifier siteSlotDiagnosticResourceId = SiteSlotDiagnosticResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, siteName, slot, diagnosticCategory); SiteSlotDiagnosticResource siteSlotDiagnostic = client.GetSiteSlotDiagnosticResource(siteSlotDiagnosticResourceId); @@ -152,16 +150,22 @@ public async Task Exists_GetAppAnalysis() // get the collection of this SiteSlotDiagnosticAnalysisResource SiteSlotDiagnosticAnalysisCollection collection = siteSlotDiagnostic.GetSiteSlotDiagnosticAnalyses(); - // invoke the operation - string analysisName = "appanalysis"; - bool result = await collection.ExistsAsync(analysisName); + // invoke the operation and iterate over the result + await foreach (SiteSlotDiagnosticAnalysisResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteAnalysisDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppAnalysis() + public async Task Exists_GetAppAnalysis() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysis.json // this example is just showing the usage of "Diagnostics_GetSiteAnalysisSlot" operation, for the dependent resources, they will have to be created separately. @@ -186,26 +190,14 @@ public async Task GetIfExists_GetAppAnalysis() // invoke the operation string analysisName = "appanalysis"; - NullableResponse response = await collection.GetIfExistsAsync(analysisName); - SiteSlotDiagnosticAnalysisResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(analysisName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteAnalysisDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppSlotAnalysis() + public async Task Exists_GetAppSlotAnalysis() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysisSlot.json // this example is just showing the usage of "Diagnostics_GetSiteAnalysisSlot" operation, for the dependent resources, they will have to be created separately. @@ -230,20 +222,16 @@ public async Task Get_GetAppSlotAnalysis() // invoke the operation string analysisName = "appanalysis"; - SiteSlotDiagnosticAnalysisResource result = await collection.GetAsync(analysisName); + bool result = await collection.ExistsAsync(analysisName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteAnalysisDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppSlotAnalysis() + public async Task GetIfExists_GetAppAnalysis() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysisSlot.json + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteAnalysis.json // this example is just showing the usage of "Diagnostics_GetSiteAnalysisSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -256,7 +244,7 @@ public async Task Exists_GetAppSlotAnalysis() string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "Sample-WestUSResourceGroup"; string siteName = "SampleApp"; - string slot = "staging"; + string slot = "Production"; string diagnosticCategory = "availability"; ResourceIdentifier siteSlotDiagnosticResourceId = SiteSlotDiagnosticResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, siteName, slot, diagnosticCategory); SiteSlotDiagnosticResource siteSlotDiagnostic = client.GetSiteSlotDiagnosticResource(siteSlotDiagnosticResourceId); @@ -266,9 +254,21 @@ public async Task Exists_GetAppSlotAnalysis() // invoke the operation string analysisName = "appanalysis"; - bool result = await collection.ExistsAsync(analysisName); + NullableResponse response = await collection.GetIfExistsAsync(analysisName); + SiteSlotDiagnosticAnalysisResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteAnalysisDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticCollection.cs index 50333681ce15f..bce5a812ad012 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteSlotDiagnosticCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppDiagnosticCategories() + public async Task Get_GetAppDiagnosticCategory() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDiagnosticCategories.json - // this example is just showing the usage of "Diagnostics_ListSiteDiagnosticCategoriesSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategory.json + // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategorySlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListAppDiagnosticCategories() // get the collection of this SiteSlotDiagnosticResource SiteSlotDiagnosticCollection collection = webSiteSlot.GetSiteSlotDiagnostics(); - // invoke the operation and iterate over the result - await foreach (SiteSlotDiagnosticResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticCategoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string diagnosticCategory = "availability"; + SiteSlotDiagnosticResource result = await collection.GetAsync(diagnosticCategory); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticCategoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppSlotDiagnosticCategories() + public async Task Get_GetAppSlotDiagnosticCategory() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDiagnosticCategoriesSlot.json - // this example is just showing the usage of "Diagnostics_ListSiteDiagnosticCategoriesSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategorySlot.json + // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategorySlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,25 +74,23 @@ public async Task GetAll_ListAppSlotDiagnosticCategories() // get the collection of this SiteSlotDiagnosticResource SiteSlotDiagnosticCollection collection = webSiteSlot.GetSiteSlotDiagnostics(); - // invoke the operation and iterate over the result - await foreach (SiteSlotDiagnosticResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticCategoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string diagnosticCategory = "availability"; + SiteSlotDiagnosticResource result = await collection.GetAsync(diagnosticCategory); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticCategoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppDiagnosticCategory() + public async Task GetAll_ListAppDiagnosticCategories() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategory.json - // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategorySlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDiagnosticCategories.json + // this example is just showing the usage of "Diagnostics_ListSiteDiagnosticCategoriesSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,23 +109,25 @@ public async Task Get_GetAppDiagnosticCategory() // get the collection of this SiteSlotDiagnosticResource SiteSlotDiagnosticCollection collection = webSiteSlot.GetSiteSlotDiagnostics(); - // invoke the operation - string diagnosticCategory = "availability"; - SiteSlotDiagnosticResource result = await collection.GetAsync(diagnosticCategory); + // invoke the operation and iterate over the result + await foreach (SiteSlotDiagnosticResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticCategoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticCategoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppDiagnosticCategory() + public async Task GetAll_ListAppSlotDiagnosticCategories() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategory.json - // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategorySlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDiagnosticCategoriesSlot.json + // this example is just showing the usage of "Diagnostics_ListSiteDiagnosticCategoriesSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,23 +139,29 @@ public async Task Exists_GetAppDiagnosticCategory() string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "Sample-WestUSResourceGroup"; string siteName = "SampleApp"; - string slot = "Production"; + string slot = "staging"; ResourceIdentifier webSiteSlotResourceId = WebSiteSlotResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, siteName, slot); WebSiteSlotResource webSiteSlot = client.GetWebSiteSlotResource(webSiteSlotResourceId); // get the collection of this SiteSlotDiagnosticResource SiteSlotDiagnosticCollection collection = webSiteSlot.GetSiteSlotDiagnostics(); - // invoke the operation - string diagnosticCategory = "availability"; - bool result = await collection.ExistsAsync(diagnosticCategory); + // invoke the operation and iterate over the result + await foreach (SiteSlotDiagnosticResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticCategoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppDiagnosticCategory() + public async Task Exists_GetAppDiagnosticCategory() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategory.json // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategorySlot" operation, for the dependent resources, they will have to be created separately. @@ -181,26 +185,14 @@ public async Task GetIfExists_GetAppDiagnosticCategory() // invoke the operation string diagnosticCategory = "availability"; - NullableResponse response = await collection.GetIfExistsAsync(diagnosticCategory); - SiteSlotDiagnosticResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(diagnosticCategory); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticCategoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppSlotDiagnosticCategory() + public async Task Exists_GetAppSlotDiagnosticCategory() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategorySlot.json // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategorySlot" operation, for the dependent resources, they will have to be created separately. @@ -224,20 +216,16 @@ public async Task Get_GetAppSlotDiagnosticCategory() // invoke the operation string diagnosticCategory = "availability"; - SiteSlotDiagnosticResource result = await collection.GetAsync(diagnosticCategory); + bool result = await collection.ExistsAsync(diagnosticCategory); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticCategoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppSlotDiagnosticCategory() + public async Task GetIfExists_GetAppDiagnosticCategory() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategorySlot.json + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDiagnosticCategory.json // this example is just showing the usage of "Diagnostics_GetSiteDiagnosticCategorySlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -250,7 +238,7 @@ public async Task Exists_GetAppSlotDiagnosticCategory() string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "Sample-WestUSResourceGroup"; string siteName = "SampleApp"; - string slot = "staging"; + string slot = "Production"; ResourceIdentifier webSiteSlotResourceId = WebSiteSlotResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, siteName, slot); WebSiteSlotResource webSiteSlot = client.GetWebSiteSlotResource(webSiteSlotResourceId); @@ -259,9 +247,21 @@ public async Task Exists_GetAppSlotDiagnosticCategory() // invoke the operation string diagnosticCategory = "availability"; - bool result = await collection.ExistsAsync(diagnosticCategory); + NullableResponse response = await collection.GetIfExistsAsync(diagnosticCategory); + SiteSlotDiagnosticResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticCategoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticDetectorCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticDetectorCollection.cs index 319533aa88a7e..0822e2eca3e29 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticDetectorCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotDiagnosticDetectorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteSlotDiagnosticDetectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppDetectors() + public async Task Get_GetAppDetector() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectors.json - // this example is just showing the usage of "Diagnostics_ListSiteDetectorsSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetector.json + // this example is just showing the usage of "Diagnostics_GetSiteDetectorSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListAppDetectors() // get the collection of this SiteSlotDiagnosticDetectorResource SiteSlotDiagnosticDetectorCollection collection = siteSlotDiagnostic.GetSiteSlotDiagnosticDetectors(); - // invoke the operation and iterate over the result - await foreach (SiteSlotDiagnosticDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DetectorDefinitionResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "sitecrashes"; + SiteSlotDiagnosticDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DetectorDefinitionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppSlotDetectors() + public async Task Get_GetAppSlotDetector() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorsSlot.json - // this example is just showing the usage of "Diagnostics_ListSiteDetectorsSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorSlot.json + // this example is just showing the usage of "Diagnostics_GetSiteDetectorSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,25 +76,23 @@ public async Task GetAll_ListAppSlotDetectors() // get the collection of this SiteSlotDiagnosticDetectorResource SiteSlotDiagnosticDetectorCollection collection = siteSlotDiagnostic.GetSiteSlotDiagnosticDetectors(); - // invoke the operation and iterate over the result - await foreach (SiteSlotDiagnosticDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DetectorDefinitionResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "sitecrashes"; + SiteSlotDiagnosticDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DetectorDefinitionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppDetector() + public async Task GetAll_ListAppDetectors() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetector.json - // this example is just showing the usage of "Diagnostics_GetSiteDetectorSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectors.json + // this example is just showing the usage of "Diagnostics_ListSiteDetectorsSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,23 +112,25 @@ public async Task Get_GetAppDetector() // get the collection of this SiteSlotDiagnosticDetectorResource SiteSlotDiagnosticDetectorCollection collection = siteSlotDiagnostic.GetSiteSlotDiagnosticDetectors(); - // invoke the operation - string detectorName = "sitecrashes"; - SiteSlotDiagnosticDetectorResource result = await collection.GetAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (SiteSlotDiagnosticDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DetectorDefinitionResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DetectorDefinitionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppDetector() + public async Task GetAll_ListAppSlotDetectors() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetector.json - // this example is just showing the usage of "Diagnostics_GetSiteDetectorSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_ListSiteDetectorsSlot.json + // this example is just showing the usage of "Diagnostics_ListSiteDetectorsSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,7 +142,7 @@ public async Task Exists_GetAppDetector() string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "Sample-WestUSResourceGroup"; string siteName = "SampleApp"; - string slot = "Production"; + string slot = "staging"; string diagnosticCategory = "availability"; ResourceIdentifier siteSlotDiagnosticResourceId = SiteSlotDiagnosticResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, siteName, slot, diagnosticCategory); SiteSlotDiagnosticResource siteSlotDiagnostic = client.GetSiteSlotDiagnosticResource(siteSlotDiagnosticResourceId); @@ -152,16 +150,22 @@ public async Task Exists_GetAppDetector() // get the collection of this SiteSlotDiagnosticDetectorResource SiteSlotDiagnosticDetectorCollection collection = siteSlotDiagnostic.GetSiteSlotDiagnosticDetectors(); - // invoke the operation - string detectorName = "sitecrashes"; - bool result = await collection.ExistsAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (SiteSlotDiagnosticDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DetectorDefinitionResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAppDetector() + public async Task Exists_GetAppDetector() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetector.json // this example is just showing the usage of "Diagnostics_GetSiteDetectorSlot" operation, for the dependent resources, they will have to be created separately. @@ -186,26 +190,14 @@ public async Task GetIfExists_GetAppDetector() // invoke the operation string detectorName = "sitecrashes"; - NullableResponse response = await collection.GetIfExistsAsync(detectorName); - SiteSlotDiagnosticDetectorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(detectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DetectorDefinitionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAppSlotDetector() + public async Task Exists_GetAppSlotDetector() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorSlot.json // this example is just showing the usage of "Diagnostics_GetSiteDetectorSlot" operation, for the dependent resources, they will have to be created separately. @@ -230,20 +222,16 @@ public async Task Get_GetAppSlotDetector() // invoke the operation string detectorName = "sitecrashes"; - SiteSlotDiagnosticDetectorResource result = await collection.GetAsync(detectorName); + bool result = await collection.ExistsAsync(detectorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DetectorDefinitionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAppSlotDetector() + public async Task GetIfExists_GetAppDetector() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetectorSlot.json + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/Diagnostics_GetSiteDetector.json // this example is just showing the usage of "Diagnostics_GetSiteDetectorSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -256,7 +244,7 @@ public async Task Exists_GetAppSlotDetector() string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "Sample-WestUSResourceGroup"; string siteName = "SampleApp"; - string slot = "staging"; + string slot = "Production"; string diagnosticCategory = "availability"; ResourceIdentifier siteSlotDiagnosticResourceId = SiteSlotDiagnosticResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, siteName, slot, diagnosticCategory); SiteSlotDiagnosticResource siteSlotDiagnostic = client.GetSiteSlotDiagnosticResource(siteSlotDiagnosticResourceId); @@ -266,9 +254,21 @@ public async Task Exists_GetAppSlotDetector() // invoke the operation string detectorName = "sitecrashes"; - bool result = await collection.ExistsAsync(detectorName); + NullableResponse response = await collection.GetIfExistsAsync(detectorName); + SiteSlotDiagnosticDetectorResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DetectorDefinitionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotPrivateEndpointConnectionCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotPrivateEndpointConnectionCollection.cs index 626e4ddb9a173..712169ce54221 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotPrivateEndpointConnectionCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SiteSlotPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPrivateEndpointConnectionForASite() + public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnectionSlot.json - // this example is just showing the usage of "WebApps_GetPrivateEndpointConnectionSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnectionSlot.json + // this example is just showing the usage of "WebApps_ApproveOrRejectPrivateEndpointConnectionSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,17 @@ public async Task Get_GetAPrivateEndpointConnectionForASite() // invoke the operation string privateEndpointConnectionName = "connection"; - SiteSlotPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData + { + PrivateLinkServiceConnectionState = new PrivateLinkConnectionState + { + Status = "Approved", + Description = "Approved by admin.", + ActionsRequired = "", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + SiteSlotPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +63,7 @@ public async Task Get_GetAPrivateEndpointConnectionForASite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPrivateEndpointConnectionForASite() + public async Task Get_GetAPrivateEndpointConnectionForASite() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnectionSlot.json // this example is just showing the usage of "WebApps_GetPrivateEndpointConnectionSlot" operation, for the dependent resources, they will have to be created separately. @@ -77,14 +87,18 @@ public async Task Exists_GetAPrivateEndpointConnectionForASite() // invoke the operation string privateEndpointConnectionName = "connection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + SiteSlotPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPrivateEndpointConnectionForASite() + public async Task Exists_GetAPrivateEndpointConnectionForASite() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnectionSlot.json // this example is just showing the usage of "WebApps_GetPrivateEndpointConnectionSlot" operation, for the dependent resources, they will have to be created separately. @@ -108,29 +122,17 @@ public async Task GetIfExists_GetAPrivateEndpointConnectionForASite() // invoke the operation string privateEndpointConnectionName = "connection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - SiteSlotPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForASite() + public async Task GetIfExists_GetAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnectionSlot.json - // this example is just showing the usage of "WebApps_ApproveOrRejectPrivateEndpointConnectionSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnectionSlot.json + // this example is just showing the usage of "WebApps_GetPrivateEndpointConnectionSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,23 +153,21 @@ public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForA // invoke the operation string privateEndpointConnectionName = "connection"; - RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData() - { - PrivateLinkServiceConnectionState = new PrivateLinkConnectionState() - { - Status = "Approved", - Description = "Approved by admin.", - ActionsRequired = "", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - SiteSlotPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + SiteSlotPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotPrivateEndpointConnectionResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotPrivateEndpointConnectionResource.cs index e45c0a7962736..d354a323dbc0b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotPrivateEndpointConnectionResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotPrivateEndpointConnectionResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetAPrivateEndpointConnectionForASite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForASite() + public async Task Delete_DeleteAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnectionSlot.json - // this example is just showing the usage of "WebApps_ApproveOrRejectPrivateEndpointConnectionSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteSitePrivateEndpointConnectionSlot.json + // this example is just showing the usage of "WebApps_DeletePrivateEndpointConnectionSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,31 +71,18 @@ public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForASite() SiteSlotPrivateEndpointConnectionResource siteSlotPrivateEndpointConnection = client.GetSiteSlotPrivateEndpointConnectionResource(siteSlotPrivateEndpointConnectionResourceId); // invoke the operation - RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData() - { - PrivateLinkServiceConnectionState = new PrivateLinkConnectionState() - { - Status = "Approved", - Description = "Approved by admin.", - ActionsRequired = "", - }, - }; - ArmOperation lro = await siteSlotPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - SiteSlotPrivateEndpointConnectionResource result = lro.Value; + ArmOperation lro = await siteSlotPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + BinaryData result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPrivateEndpointConnectionForASite() + public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteSitePrivateEndpointConnectionSlot.json - // this example is just showing the usage of "WebApps_DeletePrivateEndpointConnectionSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnectionSlot.json + // this example is just showing the usage of "WebApps_ApproveOrRejectPrivateEndpointConnectionSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,10 +100,23 @@ public async Task Delete_DeleteAPrivateEndpointConnectionForASite() SiteSlotPrivateEndpointConnectionResource siteSlotPrivateEndpointConnection = client.GetSiteSlotPrivateEndpointConnectionResource(siteSlotPrivateEndpointConnectionResourceId); // invoke the operation - ArmOperation lro = await siteSlotPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - BinaryData result = lro.Value; + RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData + { + PrivateLinkServiceConnectionState = new PrivateLinkConnectionState + { + Status = "Approved", + Description = "Approved by admin.", + ActionsRequired = "", + }, + }; + ArmOperation lro = await siteSlotPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + SiteSlotPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotWorkflowCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotWorkflowCollection.cs index e7b07a7c4d31f..4e8c2d1c18fa9 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotWorkflowCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteSlotWorkflowCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteSlotWorkflowCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheWorkflowsSlot() + public async Task Get_GETAWorkflowSlot() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWorkflows.json - // this example is just showing the usage of "WebApps_ListInstanceWorkflowsSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWorkflow.json + // this example is just showing the usage of "WebApps_GetInstanceWorkflowSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListTheWorkflowsSlot() // get the collection of this SiteSlotWorkflowResource SiteSlotWorkflowCollection collection = webSiteSlot.GetSiteSlotWorkflows(); - // invoke the operation and iterate over the result - await foreach (SiteSlotWorkflowResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowEnvelopeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string workflowName = "stateful1"; + SiteSlotWorkflowResource result = await collection.GetAsync(workflowName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowEnvelopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GETAWorkflowSlot() + public async Task GetAll_ListTheWorkflowsSlot() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWorkflow.json - // this example is just showing the usage of "WebApps_GetInstanceWorkflowSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWorkflows.json + // this example is just showing the usage of "WebApps_ListInstanceWorkflowsSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GETAWorkflowSlot() // get the collection of this SiteSlotWorkflowResource SiteSlotWorkflowCollection collection = webSiteSlot.GetSiteSlotWorkflows(); - // invoke the operation - string workflowName = "stateful1"; - SiteSlotWorkflowResource result = await collection.GetAsync(workflowName); + // invoke the operation and iterate over the result + await foreach (SiteSlotWorkflowResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowEnvelopeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowEnvelopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteWorkflowCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteWorkflowCollection.cs index 1ae7a7389f44e..fd2666aa04a60 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteWorkflowCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SiteWorkflowCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SiteWorkflowCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheWorkflows() + public async Task Get_GETAWorkflow() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWorkflows.json - // this example is just showing the usage of "WebApps_ListWorkflows" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWorkflow.json + // this example is just showing the usage of "WebApps_GetWorkflow" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListTheWorkflows() // get the collection of this SiteWorkflowResource SiteWorkflowCollection collection = webSite.GetSiteWorkflows(); - // invoke the operation and iterate over the result - await foreach (SiteWorkflowResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowEnvelopeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string workflowName = "stateful1"; + SiteWorkflowResource result = await collection.GetAsync(workflowName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowEnvelopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GETAWorkflow() + public async Task GetAll_ListTheWorkflows() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWorkflow.json - // this example is just showing the usage of "WebApps_GetWorkflow" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWorkflows.json + // this example is just showing the usage of "WebApps_ListWorkflows" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GETAWorkflow() // get the collection of this SiteWorkflowResource SiteWorkflowCollection collection = webSite.GetSiteWorkflows(); - // invoke the operation - string workflowName = "stateful1"; - SiteWorkflowResource result = await collection.GetAsync(workflowName); + // invoke the operation and iterate over the result + await foreach (SiteWorkflowResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowEnvelopeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowEnvelopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBasicAuthPropertyCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBasicAuthPropertyCollection.cs index 7ba8bfaec3161..9feceebce8f47 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBasicAuthPropertyCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBasicAuthPropertyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StaticSiteBasicAuthPropertyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheBasicAuthPropertiesForAStaticSite() + public async Task CreateOrUpdate_CreatesOrUpdatesBasicAuthPropertiesForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListStaticSiteBasicAuth.json - // this example is just showing the usage of "StaticSites_ListBasicAuth" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSiteBasicAuth.json + // this example is just showing the usage of "StaticSites_CreateOrUpdateBasicAuth" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_ListsTheBasicAuthPropertiesForAStaticSite() // get the collection of this StaticSiteBasicAuthPropertyResource StaticSiteBasicAuthPropertyCollection collection = staticSite.GetStaticSiteBasicAuthProperties(); - // invoke the operation and iterate over the result - await foreach (StaticSiteBasicAuthPropertyResource item in collection.GetAllAsync()) + // invoke the operation + StaticSiteBasicAuthName basicAuthName = StaticSiteBasicAuthName.Default; + StaticSiteBasicAuthPropertyData data = new StaticSiteBasicAuthPropertyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteBasicAuthPropertyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Password = "**********************", + SecretUri = null, + ApplicableEnvironmentsMode = "AllEnvironments", + Environments = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, basicAuthName, data); + StaticSiteBasicAuthPropertyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteBasicAuthPropertyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +94,10 @@ public async Task Get_GetsTheBasicAuthPropertiesForAStaticSite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheBasicAuthPropertiesForAStaticSite() + public async Task GetAll_ListsTheBasicAuthPropertiesForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBasicAuth.json - // this example is just showing the usage of "StaticSites_GetBasicAuth" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListStaticSiteBasicAuth.json + // this example is just showing the usage of "StaticSites_ListBasicAuth" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +115,22 @@ public async Task Exists_GetsTheBasicAuthPropertiesForAStaticSite() // get the collection of this StaticSiteBasicAuthPropertyResource StaticSiteBasicAuthPropertyCollection collection = staticSite.GetStaticSiteBasicAuthProperties(); - // invoke the operation - StaticSiteBasicAuthName basicAuthName = StaticSiteBasicAuthName.Default; - bool result = await collection.ExistsAsync(basicAuthName); + // invoke the operation and iterate over the result + await foreach (StaticSiteBasicAuthPropertyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteBasicAuthPropertyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheBasicAuthPropertiesForAStaticSite() + public async Task Exists_GetsTheBasicAuthPropertiesForAStaticSite() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBasicAuth.json // this example is just showing the usage of "StaticSites_GetBasicAuth" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +153,17 @@ public async Task GetIfExists_GetsTheBasicAuthPropertiesForAStaticSite() // invoke the operation StaticSiteBasicAuthName basicAuthName = StaticSiteBasicAuthName.Default; - NullableResponse response = await collection.GetIfExistsAsync(basicAuthName); - StaticSiteBasicAuthPropertyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(basicAuthName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteBasicAuthPropertyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesBasicAuthPropertiesForAStaticSite() + public async Task GetIfExists_GetsTheBasicAuthPropertiesForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSiteBasicAuth.json - // this example is just showing the usage of "StaticSites_CreateOrUpdateBasicAuth" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBasicAuth.json + // this example is just showing the usage of "StaticSites_GetBasicAuth" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +183,21 @@ public async Task CreateOrUpdate_CreatesOrUpdatesBasicAuthPropertiesForAStaticSi // invoke the operation StaticSiteBasicAuthName basicAuthName = StaticSiteBasicAuthName.Default; - StaticSiteBasicAuthPropertyData data = new StaticSiteBasicAuthPropertyData() - { - Password = "**********************", - SecretUri = null, - ApplicableEnvironmentsMode = "AllEnvironments", - Environments = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, basicAuthName, data); - StaticSiteBasicAuthPropertyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(basicAuthName); + StaticSiteBasicAuthPropertyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteBasicAuthPropertyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteBasicAuthPropertyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBasicAuthPropertyResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBasicAuthPropertyResource.cs index ef76ed1195122..7ee15eb0ace90 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBasicAuthPropertyResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBasicAuthPropertyResource.cs @@ -69,14 +69,12 @@ public async Task Update_CreatesOrUpdatesBasicAuthPropertiesForAStaticSite() StaticSiteBasicAuthPropertyResource staticSiteBasicAuthProperty = client.GetStaticSiteBasicAuthPropertyResource(staticSiteBasicAuthPropertyResourceId); // invoke the operation - StaticSiteBasicAuthPropertyData data = new StaticSiteBasicAuthPropertyData() + StaticSiteBasicAuthPropertyData data = new StaticSiteBasicAuthPropertyData { Password = "**********************", SecretUri = null, ApplicableEnvironmentsMode = "AllEnvironments", - Environments = -{ -}, + Environments = { }, }; ArmOperation lro = await staticSiteBasicAuthProperty.UpdateAsync(WaitUntil.Completed, data); StaticSiteBasicAuthPropertyResource result = lro.Value; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildCollection.cs index 9fa13d842064b..787bbfe614ba6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_StaticSiteBuildCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllBuildsForAStaticSite() + public async Task Get_GetAStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBuilds.json - // this example is just showing the usage of "StaticSites_GetStaticSiteBuilds" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_GetStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetAllBuildsForAStaticSite() // get the collection of this StaticSiteBuildResource StaticSiteBuildCollection collection = staticSite.GetStaticSiteBuilds(); - // invoke the operation and iterate over the result - await foreach (StaticSiteBuildResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteBuildData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string environmentName = "12"; + StaticSiteBuildResource result = await collection.GetAsync(environmentName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteBuildData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAStaticSiteBuild() + public async Task GetAll_GetAllBuildsForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_GetStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBuilds.json + // this example is just showing the usage of "StaticSites_GetStaticSiteBuilds" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetAStaticSiteBuild() // get the collection of this StaticSiteBuildResource StaticSiteBuildCollection collection = staticSite.GetStaticSiteBuilds(); - // invoke the operation - string environmentName = "12"; - StaticSiteBuildResource result = await collection.GetAsync(environmentName); + // invoke the operation and iterate over the result + await foreach (StaticSiteBuildResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteBuildData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteBuildData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildDatabaseConnectionCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildDatabaseConnectionCollection.cs index b7bec394de0c3..7d6322a04b9fa 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildDatabaseConnectionCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildDatabaseConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_StaticSiteBuildDatabaseConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOverviewsOfDatabaseConnectionsForTheStaticSiteBuild() + public async Task CreateOrUpdate_CreateOrUpdateADatabaseConnectionForAStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBuildDatabaseConnections.json - // this example is just showing the usage of "StaticSites_GetBuildDatabaseConnections" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSiteBuildDatabaseConnection.json + // this example is just showing the usage of "StaticSites_CreateOrUpdateBuildDatabaseConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_ListOverviewsOfDatabaseConnectionsForTheStaticSiteBuild // get the collection of this StaticSiteBuildDatabaseConnectionResource StaticSiteBuildDatabaseConnectionCollection collection = staticSiteBuild.GetStaticSiteBuildDatabaseConnections(); - // invoke the operation and iterate over the result - await foreach (StaticSiteBuildDatabaseConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string databaseConnectionName = "default"; + StaticSiteDatabaseConnectionData data = new StaticSiteDatabaseConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteDatabaseConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/databaseRG/providers/Microsoft.DocumentDB/databaseAccounts/exampleDatabaseName"), + ConnectionIdentity = "SystemAssigned", + ConnectionString = "AccountEndpoint=https://exampleDatabaseName.documents.azure.com:443/;Database=mydb;", + Region = "West US 2", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseConnectionName, data); + StaticSiteBuildDatabaseConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteDatabaseConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +95,10 @@ public async Task Get_GetOverviewOfDatabaseConnectionsForTheStaticSiteBuild() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetOverviewOfDatabaseConnectionsForTheStaticSiteBuild() + public async Task GetAll_ListOverviewsOfDatabaseConnectionsForTheStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBuildDatabaseConnection.json - // this example is just showing the usage of "StaticSites_GetBuildDatabaseConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBuildDatabaseConnections.json + // this example is just showing the usage of "StaticSites_GetBuildDatabaseConnections" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +117,22 @@ public async Task Exists_GetOverviewOfDatabaseConnectionsForTheStaticSiteBuild() // get the collection of this StaticSiteBuildDatabaseConnectionResource StaticSiteBuildDatabaseConnectionCollection collection = staticSiteBuild.GetStaticSiteBuildDatabaseConnections(); - // invoke the operation - string databaseConnectionName = "default"; - bool result = await collection.ExistsAsync(databaseConnectionName); + // invoke the operation and iterate over the result + await foreach (StaticSiteBuildDatabaseConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteDatabaseConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetOverviewOfDatabaseConnectionsForTheStaticSiteBuild() + public async Task Exists_GetOverviewOfDatabaseConnectionsForTheStaticSiteBuild() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBuildDatabaseConnection.json // this example is just showing the usage of "StaticSites_GetBuildDatabaseConnection" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +156,17 @@ public async Task GetIfExists_GetOverviewOfDatabaseConnectionsForTheStaticSiteBu // invoke the operation string databaseConnectionName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(databaseConnectionName); - StaticSiteBuildDatabaseConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(databaseConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteDatabaseConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateADatabaseConnectionForAStaticSiteBuild() + public async Task GetIfExists_GetOverviewOfDatabaseConnectionsForTheStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSiteBuildDatabaseConnection.json - // this example is just showing the usage of "StaticSites_CreateOrUpdateBuildDatabaseConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteBuildDatabaseConnection.json + // this example is just showing the usage of "StaticSites_GetBuildDatabaseConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,21 +187,21 @@ public async Task CreateOrUpdate_CreateOrUpdateADatabaseConnectionForAStaticSite // invoke the operation string databaseConnectionName = "default"; - StaticSiteDatabaseConnectionData data = new StaticSiteDatabaseConnectionData() - { - ResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/databaseRG/providers/Microsoft.DocumentDB/databaseAccounts/exampleDatabaseName"), - ConnectionIdentity = "SystemAssigned", - ConnectionString = "AccountEndpoint=https://exampleDatabaseName.documents.azure.com:443/;Database=mydb;", - Region = "West US 2", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseConnectionName, data); - StaticSiteBuildDatabaseConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(databaseConnectionName); + StaticSiteBuildDatabaseConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteDatabaseConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteDatabaseConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildLinkedBackendCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildLinkedBackendCollection.cs index 85c8371a68d24..30fc65eb1512b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildLinkedBackendCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildLinkedBackendCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_StaticSiteBuildLinkedBackendCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetDetailsOfTheLinkedBackendsRegisteredWithAStaticSiteBuild() + public async Task CreateOrUpdate_LinkABackendToAStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendsForStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_GetLinkedBackendsForBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/LinkBackendToStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_LinkBackendToBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_GetDetailsOfTheLinkedBackendsRegisteredWithAStaticSiteB // get the collection of this StaticSiteBuildLinkedBackendResource StaticSiteBuildLinkedBackendCollection collection = staticSiteBuild.GetStaticSiteBuildLinkedBackends(); - // invoke the operation and iterate over the result - await foreach (StaticSiteBuildLinkedBackendResource item in collection.GetAllAsync()) + // invoke the operation + string linkedBackendName = "testBackend"; + StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteLinkedBackendData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + BackendResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/backendRg/providers/Microsoft.Web/sites/testBackend"), + Region = "West US 2", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkedBackendName, data); + StaticSiteBuildLinkedBackendResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteLinkedBackendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +93,10 @@ public async Task Get_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteBuild [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteBuildByName() + public async Task GetAll_GetDetailsOfTheLinkedBackendsRegisteredWithAStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendForStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_GetLinkedBackendForBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendsForStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_GetLinkedBackendsForBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +115,22 @@ public async Task Exists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteBu // get the collection of this StaticSiteBuildLinkedBackendResource StaticSiteBuildLinkedBackendCollection collection = staticSiteBuild.GetStaticSiteBuildLinkedBackends(); - // invoke the operation - string linkedBackendName = "testBackend"; - bool result = await collection.ExistsAsync(linkedBackendName); + // invoke the operation and iterate over the result + await foreach (StaticSiteBuildLinkedBackendResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteLinkedBackendData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteBuildByName() + public async Task Exists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteBuildByName() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendForStaticSiteBuild.json // this example is just showing the usage of "StaticSites_GetLinkedBackendForBuild" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +154,17 @@ public async Task GetIfExists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticS // invoke the operation string linkedBackendName = "testBackend"; - NullableResponse response = await collection.GetIfExistsAsync(linkedBackendName); - StaticSiteBuildLinkedBackendResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(linkedBackendName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteLinkedBackendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LinkABackendToAStaticSiteBuild() + public async Task GetIfExists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteBuildByName() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/LinkBackendToStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_LinkBackendToBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendForStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_GetLinkedBackendForBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,19 +185,21 @@ public async Task CreateOrUpdate_LinkABackendToAStaticSiteBuild() // invoke the operation string linkedBackendName = "testBackend"; - StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData() - { - BackendResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/backendRg/providers/Microsoft.Web/sites/testBackend"), - Region = "West US 2", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkedBackendName, data); - StaticSiteBuildLinkedBackendResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(linkedBackendName); + StaticSiteBuildLinkedBackendResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteLinkedBackendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteLinkedBackendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildLinkedBackendResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildLinkedBackendResource.cs index d26840a824599..b8407033fdd46 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildLinkedBackendResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildLinkedBackendResource.cs @@ -17,10 +17,10 @@ public partial class Sample_StaticSiteBuildLinkedBackendResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateBackendForBuild_ValidateIfBackendCanBeLinkedToStaticSiteBuild() + public async Task Get_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteBuildByName() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ValidateLinkedBackendForStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_ValidateBackendForBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendForStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_GetLinkedBackendForBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,22 +38,21 @@ public async Task ValidateBackendForBuild_ValidateIfBackendCanBeLinkedToStaticSi StaticSiteBuildLinkedBackendResource staticSiteBuildLinkedBackend = client.GetStaticSiteBuildLinkedBackendResource(staticSiteBuildLinkedBackendResourceId); // invoke the operation - StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData() - { - BackendResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/backendRg/providers/Microsoft.Web/sites/testBackend"), - Region = "West US 2", - }; - await staticSiteBuildLinkedBackend.ValidateBackendForBuildAsync(WaitUntil.Completed, data); + StaticSiteBuildLinkedBackendResource result = await staticSiteBuildLinkedBackend.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteLinkedBackendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteBuildByName() + public async Task Delete_UnlinkABackendFromAStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendForStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_GetLinkedBackendForBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/UnlinkBackendFromStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_UnlinkBackendFromBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,19 +64,15 @@ public async Task Get_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteBuild string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "rg"; string name = "testStaticSite0"; - string environmentName = "default"; + string environmentName = "12"; string linkedBackendName = "testBackend"; ResourceIdentifier staticSiteBuildLinkedBackendResourceId = StaticSiteBuildLinkedBackendResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, environmentName, linkedBackendName); StaticSiteBuildLinkedBackendResource staticSiteBuildLinkedBackend = client.GetStaticSiteBuildLinkedBackendResource(staticSiteBuildLinkedBackendResourceId); // invoke the operation - StaticSiteBuildLinkedBackendResource result = await staticSiteBuildLinkedBackend.GetAsync(); + await staticSiteBuildLinkedBackend.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteLinkedBackendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -103,7 +98,7 @@ public async Task Update_LinkABackendToAStaticSiteBuild() StaticSiteBuildLinkedBackendResource staticSiteBuildLinkedBackend = client.GetStaticSiteBuildLinkedBackendResource(staticSiteBuildLinkedBackendResourceId); // invoke the operation - StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData() + StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData { BackendResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/backendRg/providers/Microsoft.Web/sites/testBackend"), Region = "West US 2", @@ -120,10 +115,10 @@ public async Task Update_LinkABackendToAStaticSiteBuild() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_UnlinkABackendFromAStaticSiteBuild() + public async Task ValidateBackendForBuild_ValidateIfBackendCanBeLinkedToStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/UnlinkBackendFromStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_UnlinkBackendFromBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ValidateLinkedBackendForStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_ValidateBackendForBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,13 +130,18 @@ public async Task Delete_UnlinkABackendFromAStaticSiteBuild() string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "rg"; string name = "testStaticSite0"; - string environmentName = "12"; + string environmentName = "default"; string linkedBackendName = "testBackend"; ResourceIdentifier staticSiteBuildLinkedBackendResourceId = StaticSiteBuildLinkedBackendResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, environmentName, linkedBackendName); StaticSiteBuildLinkedBackendResource staticSiteBuildLinkedBackend = client.GetStaticSiteBuildLinkedBackendResource(staticSiteBuildLinkedBackendResourceId); // invoke the operation - await staticSiteBuildLinkedBackend.DeleteAsync(WaitUntil.Completed); + StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData + { + BackendResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/backendRg/providers/Microsoft.Web/sites/testBackend"), + Region = "West US 2", + }; + await staticSiteBuildLinkedBackend.ValidateBackendForBuildAsync(WaitUntil.Completed, data); Console.WriteLine("Succeeded"); } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildResource.cs index 177fe2f56e1ef..bd217e40b6909 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildResource.cs @@ -96,12 +96,12 @@ public async Task CreateOrUpdateAppSettings_CreatesOrUpdatesTheFunctionAppSettin StaticSiteBuildResource staticSiteBuild = client.GetStaticSiteBuildResource(staticSiteBuildResourceId); // invoke the operation - AppServiceConfigurationDictionary appSettings = new AppServiceConfigurationDictionary() + AppServiceConfigurationDictionary appSettings = new AppServiceConfigurationDictionary { Properties = { ["setting1"] = "someval", -["setting2"] = "someval2", +["setting2"] = "someval2" }, }; AppServiceConfigurationDictionary result = await staticSiteBuild.CreateOrUpdateAppSettingsAsync(appSettings); @@ -131,12 +131,12 @@ public async Task CreateOrUpdateFunctionAppSettings_CreatesOrUpdatesTheFunctionA StaticSiteBuildResource staticSiteBuild = client.GetStaticSiteBuildResource(staticSiteBuildResourceId); // invoke the operation - AppServiceConfigurationDictionary appSettings = new AppServiceConfigurationDictionary() + AppServiceConfigurationDictionary appSettings = new AppServiceConfigurationDictionary { Properties = { ["setting1"] = "someval", -["setting2"] = "someval2", +["setting2"] = "someval2" }, }; AppServiceConfigurationDictionary result = await staticSiteBuild.CreateOrUpdateFunctionAppSettingsAsync(appSettings); @@ -281,7 +281,7 @@ public async Task CreateZipDeployment_DeployASiteFromAZippedPackageToAParticular StaticSiteBuildResource staticSiteBuild = client.GetStaticSiteBuildResource(staticSiteBuildResourceId); // invoke the operation - StaticSiteZipDeployment staticSiteZipDeploymentEnvelope = new StaticSiteZipDeployment() + StaticSiteZipDeployment staticSiteZipDeploymentEnvelope = new StaticSiteZipDeployment { AppZipUri = new Uri("https://teststorageaccount.net/happy-sea-15afae3e-master-81828877/app-zipdeploy.zip"), ApiZipUri = new Uri("https://teststorageaccount.net/happy-sea-15afae3e-master-81828877/api-zipdeploy.zip"), diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildUserProvidedFunctionAppCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildUserProvidedFunctionAppCollection.cs index 3dd4d221b0e46..26fd5d2a72bab 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildUserProvidedFunctionAppCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildUserProvidedFunctionAppCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_StaticSiteBuildUserProvidedFunctionAppCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetDetailsOfTheUserProvidedFunctionAppsRegisteredWithAStaticSiteBuild() + public async Task CreateOrUpdate_RegisterAUserProvidedFunctionAppWithAStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetUserProvidedFunctionAppsForStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_GetUserProvidedFunctionAppsForStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/RegisterUserProvidedFunctionAppWithStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_RegisterUserProvidedFunctionAppWithStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,22 @@ public async Task GetAll_GetDetailsOfTheUserProvidedFunctionAppsRegisteredWithAS // get the collection of this StaticSiteBuildUserProvidedFunctionAppResource StaticSiteBuildUserProvidedFunctionAppCollection collection = staticSiteBuild.GetStaticSiteBuildUserProvidedFunctionApps(); - // invoke the operation and iterate over the result - await foreach (StaticSiteBuildUserProvidedFunctionAppResource item in collection.GetAllAsync()) + // invoke the operation + string functionAppName = "testFunctionApp"; + StaticSiteUserProvidedFunctionAppData data = new StaticSiteUserProvidedFunctionAppData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteUserProvidedFunctionAppData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + FunctionAppResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/functionRG/providers/Microsoft.Web/sites/testFunctionApp"), + FunctionAppRegion = "West US 2", + }; + bool? isForced = true; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, functionAppName, data, isForced: isForced); + StaticSiteBuildUserProvidedFunctionAppResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteUserProvidedFunctionAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +94,10 @@ public async Task Get_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStati [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStaticSiteBuild() + public async Task GetAll_GetDetailsOfTheUserProvidedFunctionAppsRegisteredWithAStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetUserProvidedFunctionAppForStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_GetUserProvidedFunctionAppForStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetUserProvidedFunctionAppsForStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_GetUserProvidedFunctionAppsForStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +116,22 @@ public async Task Exists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithASt // get the collection of this StaticSiteBuildUserProvidedFunctionAppResource StaticSiteBuildUserProvidedFunctionAppCollection collection = staticSiteBuild.GetStaticSiteBuildUserProvidedFunctionApps(); - // invoke the operation - string functionAppName = "testFunctionApp"; - bool result = await collection.ExistsAsync(functionAppName); + // invoke the operation and iterate over the result + await foreach (StaticSiteBuildUserProvidedFunctionAppResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteUserProvidedFunctionAppData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStaticSiteBuild() + public async Task Exists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStaticSiteBuild() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetUserProvidedFunctionAppForStaticSiteBuild.json // this example is just showing the usage of "StaticSites_GetUserProvidedFunctionAppForStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +155,17 @@ public async Task GetIfExists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWi // invoke the operation string functionAppName = "testFunctionApp"; - NullableResponse response = await collection.GetIfExistsAsync(functionAppName); - StaticSiteBuildUserProvidedFunctionAppResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(functionAppName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteUserProvidedFunctionAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RegisterAUserProvidedFunctionAppWithAStaticSiteBuild() + public async Task GetIfExists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/RegisterUserProvidedFunctionAppWithStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_RegisterUserProvidedFunctionAppWithStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetUserProvidedFunctionAppForStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_GetUserProvidedFunctionAppForStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,20 +186,21 @@ public async Task CreateOrUpdate_RegisterAUserProvidedFunctionAppWithAStaticSite // invoke the operation string functionAppName = "testFunctionApp"; - StaticSiteUserProvidedFunctionAppData data = new StaticSiteUserProvidedFunctionAppData() - { - FunctionAppResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/functionRG/providers/Microsoft.Web/sites/testFunctionApp"), - FunctionAppRegion = "West US 2", - }; - bool? isForced = true; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, functionAppName, data, isForced: isForced); - StaticSiteBuildUserProvidedFunctionAppResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(functionAppName); + StaticSiteBuildUserProvidedFunctionAppResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteUserProvidedFunctionAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteUserProvidedFunctionAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildUserProvidedFunctionAppResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildUserProvidedFunctionAppResource.cs index ba1c0a07f98b2..a1f8aa16274c4 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildUserProvidedFunctionAppResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteBuildUserProvidedFunctionAppResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStati [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RegisterAUserProvidedFunctionAppWithAStaticSiteBuild() + public async Task Delete_DetachTheUserProvidedFunctionAppFromTheStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/RegisterUserProvidedFunctionAppWithStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_RegisterUserProvidedFunctionAppWithStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DetachUserProvidedFunctionAppFromStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_DetachUserProvidedFunctionAppFromStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,34 +64,23 @@ public async Task Update_RegisterAUserProvidedFunctionAppWithAStaticSiteBuild() string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "rg"; string name = "testStaticSite0"; - string environmentName = "default"; + string environmentName = "12"; string functionAppName = "testFunctionApp"; ResourceIdentifier staticSiteBuildUserProvidedFunctionAppResourceId = StaticSiteBuildUserProvidedFunctionAppResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, environmentName, functionAppName); StaticSiteBuildUserProvidedFunctionAppResource staticSiteBuildUserProvidedFunctionApp = client.GetStaticSiteBuildUserProvidedFunctionAppResource(staticSiteBuildUserProvidedFunctionAppResourceId); // invoke the operation - StaticSiteUserProvidedFunctionAppData data = new StaticSiteUserProvidedFunctionAppData() - { - FunctionAppResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/functionRG/providers/Microsoft.Web/sites/testFunctionApp"), - FunctionAppRegion = "West US 2", - }; - bool? isForced = true; - ArmOperation lro = await staticSiteBuildUserProvidedFunctionApp.UpdateAsync(WaitUntil.Completed, data, isForced: isForced); - StaticSiteBuildUserProvidedFunctionAppResource result = lro.Value; + await staticSiteBuildUserProvidedFunctionApp.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteUserProvidedFunctionAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DetachTheUserProvidedFunctionAppFromTheStaticSiteBuild() + public async Task Update_RegisterAUserProvidedFunctionAppWithAStaticSiteBuild() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DetachUserProvidedFunctionAppFromStaticSiteBuild.json - // this example is just showing the usage of "StaticSites_DetachUserProvidedFunctionAppFromStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/RegisterUserProvidedFunctionAppWithStaticSiteBuild.json + // this example is just showing the usage of "StaticSites_RegisterUserProvidedFunctionAppWithStaticSiteBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,15 +92,26 @@ public async Task Delete_DetachTheUserProvidedFunctionAppFromTheStaticSiteBuild( string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "rg"; string name = "testStaticSite0"; - string environmentName = "12"; + string environmentName = "default"; string functionAppName = "testFunctionApp"; ResourceIdentifier staticSiteBuildUserProvidedFunctionAppResourceId = StaticSiteBuildUserProvidedFunctionAppResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name, environmentName, functionAppName); StaticSiteBuildUserProvidedFunctionAppResource staticSiteBuildUserProvidedFunctionApp = client.GetStaticSiteBuildUserProvidedFunctionAppResource(staticSiteBuildUserProvidedFunctionAppResourceId); // invoke the operation - await staticSiteBuildUserProvidedFunctionApp.DeleteAsync(WaitUntil.Completed); + StaticSiteUserProvidedFunctionAppData data = new StaticSiteUserProvidedFunctionAppData + { + FunctionAppResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/functionRG/providers/Microsoft.Web/sites/testFunctionApp"), + FunctionAppRegion = "West US 2", + }; + bool? isForced = true; + ArmOperation lro = await staticSiteBuildUserProvidedFunctionApp.UpdateAsync(WaitUntil.Completed, data, isForced: isForced); + StaticSiteBuildUserProvidedFunctionAppResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteUserProvidedFunctionAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCollection.cs index 959574067844d..683b4e594fe11 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_StaticSiteCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetStaticSitesForAResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSites.json - // this example is just showing the usage of "StaticSites_GetStaticSitesByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSite.json + // this example is just showing the usage of "StaticSites_CreateOrUpdateStaticSite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,33 @@ public async Task GetAll_GetStaticSitesForAResourceGroup() // get the collection of this StaticSiteResource StaticSiteCollection collection = resourceGroupResource.GetStaticSites(); - // invoke the operation and iterate over the result - await foreach (StaticSiteResource item in collection.GetAllAsync()) + // invoke the operation + string name = "testStaticSite0"; + StaticSiteData data = new StaticSiteData(new AzureLocation("West US 2")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new AppServiceSkuDescription + { + Name = "Basic", + Tier = "Basic", + }, + RepositoryUri = new Uri("https://github.com/username/RepoName"), + Branch = "master", + RepositoryToken = "repoToken123", + BuildProperties = new StaticSiteBuildProperties + { + AppLocation = "app", + ApiLocation = "api", + AppArtifactLocation = "build", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + StaticSiteResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +103,10 @@ public async Task Get_GetDetailsForAStaticSite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsForAStaticSite() + public async Task GetAll_GetStaticSitesForAResourceGroup() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSite.json - // this example is just showing the usage of "StaticSites_GetStaticSite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSites.json + // this example is just showing the usage of "StaticSites_GetStaticSitesByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +123,22 @@ public async Task Exists_GetDetailsForAStaticSite() // get the collection of this StaticSiteResource StaticSiteCollection collection = resourceGroupResource.GetStaticSites(); - // invoke the operation - string name = "testStaticSite0"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (StaticSiteResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsForAStaticSite() + public async Task Exists_GetDetailsForAStaticSite() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSite.json // this example is just showing the usage of "StaticSites_GetStaticSite" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +160,17 @@ public async Task GetIfExists_GetDetailsForAStaticSite() // invoke the operation string name = "testStaticSite0"; - NullableResponse response = await collection.GetIfExistsAsync(name); - StaticSiteResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAStaticSite() + public async Task GetIfExists_GetDetailsForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSite.json - // this example is just showing the usage of "StaticSites_CreateOrUpdateStaticSite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSite.json + // this example is just showing the usage of "StaticSites_GetStaticSite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,31 +189,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAStaticSite() // invoke the operation string name = "testStaticSite0"; - StaticSiteData data = new StaticSiteData(new AzureLocation("West US 2")) - { - Sku = new AppServiceSkuDescription() - { - Name = "Basic", - Tier = "Basic", - }, - RepositoryUri = new Uri("https://github.com/username/RepoName"), - Branch = "master", - RepositoryToken = "repoToken123", - BuildProperties = new StaticSiteBuildProperties() - { - AppLocation = "app", - ApiLocation = "api", - AppArtifactLocation = "build", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - StaticSiteResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + StaticSiteResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCustomDomainOverviewCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCustomDomainOverviewCollection.cs index 812f5a8312aff..bf97ab768a235 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCustomDomainOverviewCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCustomDomainOverviewCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StaticSiteCustomDomainOverviewCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCustomDomainsForAStaticSite() + public async Task CreateOrUpdate_CreateOrUpdateACustomDomainForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteCustomDomains.json - // this example is just showing the usage of "StaticSites_ListStaticSiteCustomDomains" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSiteCustomDomain.json + // this example is just showing the usage of "StaticSites_CreateOrUpdateStaticSiteCustomDomain" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,17 @@ public async Task GetAll_ListCustomDomainsForAStaticSite() // get the collection of this StaticSiteCustomDomainOverviewResource StaticSiteCustomDomainOverviewCollection collection = staticSite.GetStaticSiteCustomDomainOverviews(); - // invoke the operation and iterate over the result - await foreach (StaticSiteCustomDomainOverviewResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteCustomDomainOverviewData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string domainName = "custom.domain.net"; + StaticSiteCustomDomainContent content = new StaticSiteCustomDomainContent(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, content); + StaticSiteCustomDomainOverviewResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteCustomDomainOverviewData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +88,10 @@ public async Task Get_GetCustomDomainForAStaticSite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCustomDomainForAStaticSite() + public async Task GetAll_ListCustomDomainsForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteCustomDomain.json - // this example is just showing the usage of "StaticSites_GetStaticSiteCustomDomain" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteCustomDomains.json + // this example is just showing the usage of "StaticSites_ListStaticSiteCustomDomains" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_GetCustomDomainForAStaticSite() // get the collection of this StaticSiteCustomDomainOverviewResource StaticSiteCustomDomainOverviewCollection collection = staticSite.GetStaticSiteCustomDomainOverviews(); - // invoke the operation - string domainName = "custom.domain.net"; - bool result = await collection.ExistsAsync(domainName); + // invoke the operation and iterate over the result + await foreach (StaticSiteCustomDomainOverviewResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteCustomDomainOverviewData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCustomDomainForAStaticSite() + public async Task Exists_GetCustomDomainForAStaticSite() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteCustomDomain.json // this example is just showing the usage of "StaticSites_GetStaticSiteCustomDomain" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_GetCustomDomainForAStaticSite() // invoke the operation string domainName = "custom.domain.net"; - NullableResponse response = await collection.GetIfExistsAsync(domainName); - StaticSiteCustomDomainOverviewResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(domainName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteCustomDomainOverviewData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateACustomDomainForAStaticSite() + public async Task GetIfExists_GetCustomDomainForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSiteCustomDomain.json - // this example is just showing the usage of "StaticSites_CreateOrUpdateStaticSiteCustomDomain" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteCustomDomain.json + // this example is just showing the usage of "StaticSites_GetStaticSiteCustomDomain" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,15 +177,21 @@ public async Task CreateOrUpdate_CreateOrUpdateACustomDomainForAStaticSite() // invoke the operation string domainName = "custom.domain.net"; - StaticSiteCustomDomainContent content = new StaticSiteCustomDomainContent(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, content); - StaticSiteCustomDomainOverviewResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(domainName); + StaticSiteCustomDomainOverviewResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteCustomDomainOverviewData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteCustomDomainOverviewData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCustomDomainOverviewResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCustomDomainOverviewResource.cs index 1127e290cbdf9..bc8ff81a8e70e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCustomDomainOverviewResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteCustomDomainOverviewResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetCustomDomainForAStaticSite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateACustomDomainForAStaticSite() + public async Task Delete_DeleteACustomDomainForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSiteCustomDomain.json - // this example is just showing the usage of "StaticSites_CreateOrUpdateStaticSiteCustomDomain" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteStaticSiteCustomDomain.json + // this example is just showing the usage of "StaticSites_DeleteStaticSiteCustomDomain" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,23 +69,17 @@ public async Task Update_CreateOrUpdateACustomDomainForAStaticSite() StaticSiteCustomDomainOverviewResource staticSiteCustomDomainOverview = client.GetStaticSiteCustomDomainOverviewResource(staticSiteCustomDomainOverviewResourceId); // invoke the operation - StaticSiteCustomDomainContent content = new StaticSiteCustomDomainContent(); - ArmOperation lro = await staticSiteCustomDomainOverview.UpdateAsync(WaitUntil.Completed, content); - StaticSiteCustomDomainOverviewResource result = lro.Value; + await staticSiteCustomDomainOverview.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteCustomDomainOverviewData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACustomDomainForAStaticSite() + public async Task Update_CreateOrUpdateACustomDomainForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteStaticSiteCustomDomain.json - // this example is just showing the usage of "StaticSites_DeleteStaticSiteCustomDomain" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSiteCustomDomain.json + // this example is just showing the usage of "StaticSites_CreateOrUpdateStaticSiteCustomDomain" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_DeleteACustomDomainForAStaticSite() StaticSiteCustomDomainOverviewResource staticSiteCustomDomainOverview = client.GetStaticSiteCustomDomainOverviewResource(staticSiteCustomDomainOverviewResourceId); // invoke the operation - await staticSiteCustomDomainOverview.DeleteAsync(WaitUntil.Completed); + StaticSiteCustomDomainContent content = new StaticSiteCustomDomainContent(); + ArmOperation lro = await staticSiteCustomDomainOverview.UpdateAsync(WaitUntil.Completed, content); + StaticSiteCustomDomainOverviewResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteCustomDomainOverviewData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteDatabaseConnectionCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteDatabaseConnectionCollection.cs index 3b56b85b38d8c..822163eca2270 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteDatabaseConnectionCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteDatabaseConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_StaticSiteDatabaseConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOverviewsOfDatabaseConnectionsForTheStaticSite() + public async Task CreateOrUpdate_CreateOrUpdateADatabaseConnectionForAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteDatabaseConnections.json - // this example is just showing the usage of "StaticSites_GetDatabaseConnections" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSiteDatabaseConnection.json + // this example is just showing the usage of "StaticSites_CreateOrUpdateDatabaseConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,23 @@ public async Task GetAll_ListOverviewsOfDatabaseConnectionsForTheStaticSite() // get the collection of this StaticSiteDatabaseConnectionResource StaticSiteDatabaseConnectionCollection collection = staticSite.GetStaticSiteDatabaseConnections(); - // invoke the operation and iterate over the result - await foreach (StaticSiteDatabaseConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string databaseConnectionName = "default"; + StaticSiteDatabaseConnectionData data = new StaticSiteDatabaseConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteDatabaseConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/databaseRG/providers/Microsoft.DocumentDB/databaseAccounts/exampleDatabaseName"), + ConnectionIdentity = "SystemAssigned", + ConnectionString = "AccountEndpoint=https://exampleDatabaseName.documents.azure.com:443/;Database=mydb;", + Region = "West US 2", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseConnectionName, data); + StaticSiteDatabaseConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteDatabaseConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +93,10 @@ public async Task Get_GetOverviewOfDatabaseConnectionsForTheStaticSite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetOverviewOfDatabaseConnectionsForTheStaticSite() + public async Task GetAll_ListOverviewsOfDatabaseConnectionsForTheStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteDatabaseConnection.json - // this example is just showing the usage of "StaticSites_GetDatabaseConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteDatabaseConnections.json + // this example is just showing the usage of "StaticSites_GetDatabaseConnections" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +114,22 @@ public async Task Exists_GetOverviewOfDatabaseConnectionsForTheStaticSite() // get the collection of this StaticSiteDatabaseConnectionResource StaticSiteDatabaseConnectionCollection collection = staticSite.GetStaticSiteDatabaseConnections(); - // invoke the operation - string databaseConnectionName = "default"; - bool result = await collection.ExistsAsync(databaseConnectionName); + // invoke the operation and iterate over the result + await foreach (StaticSiteDatabaseConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteDatabaseConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetOverviewOfDatabaseConnectionsForTheStaticSite() + public async Task Exists_GetOverviewOfDatabaseConnectionsForTheStaticSite() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteDatabaseConnection.json // this example is just showing the usage of "StaticSites_GetDatabaseConnection" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +152,17 @@ public async Task GetIfExists_GetOverviewOfDatabaseConnectionsForTheStaticSite() // invoke the operation string databaseConnectionName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(databaseConnectionName); - StaticSiteDatabaseConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(databaseConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteDatabaseConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateADatabaseConnectionForAStaticSite() + public async Task GetIfExists_GetOverviewOfDatabaseConnectionsForTheStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateStaticSiteDatabaseConnection.json - // this example is just showing the usage of "StaticSites_CreateOrUpdateDatabaseConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetStaticSiteDatabaseConnection.json + // this example is just showing the usage of "StaticSites_GetDatabaseConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,21 +182,21 @@ public async Task CreateOrUpdate_CreateOrUpdateADatabaseConnectionForAStaticSite // invoke the operation string databaseConnectionName = "default"; - StaticSiteDatabaseConnectionData data = new StaticSiteDatabaseConnectionData() - { - ResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/databaseRG/providers/Microsoft.DocumentDB/databaseAccounts/exampleDatabaseName"), - ConnectionIdentity = "SystemAssigned", - ConnectionString = "AccountEndpoint=https://exampleDatabaseName.documents.azure.com:443/;Database=mydb;", - Region = "West US 2", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseConnectionName, data); - StaticSiteDatabaseConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(databaseConnectionName); + StaticSiteDatabaseConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteDatabaseConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteDatabaseConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteLinkedBackendCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteLinkedBackendCollection.cs index a0c66d873e5a6..d7b894892f519 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteLinkedBackendCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteLinkedBackendCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_StaticSiteLinkedBackendCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetDetailsOfTheLinkedBackendsRegisteredWithAStaticSite() + public async Task CreateOrUpdate_LinkABackendToAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendsForStaticSite.json - // this example is just showing the usage of "StaticSites_GetLinkedBackends" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/LinkBackendToStaticSite.json + // this example is just showing the usage of "StaticSites_LinkBackend" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_GetDetailsOfTheLinkedBackendsRegisteredWithAStaticSite( // get the collection of this StaticSiteLinkedBackendResource StaticSiteLinkedBackendCollection collection = staticSite.GetStaticSiteLinkedBackends(); - // invoke the operation and iterate over the result - await foreach (StaticSiteLinkedBackendResource item in collection.GetAllAsync()) + // invoke the operation + string linkedBackendName = "testBackend"; + StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteLinkedBackendData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + BackendResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/backendRg/providers/Microsoft.Web/sites/testBackend"), + Region = "West US 2", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkedBackendName, data); + StaticSiteLinkedBackendResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteLinkedBackendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteByNam [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteByName() + public async Task GetAll_GetDetailsOfTheLinkedBackendsRegisteredWithAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendForStaticSite.json - // this example is just showing the usage of "StaticSites_GetLinkedBackend" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendsForStaticSite.json + // this example is just showing the usage of "StaticSites_GetLinkedBackends" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteBy // get the collection of this StaticSiteLinkedBackendResource StaticSiteLinkedBackendCollection collection = staticSite.GetStaticSiteLinkedBackends(); - // invoke the operation - string linkedBackendName = "testBackend"; - bool result = await collection.ExistsAsync(linkedBackendName); + // invoke the operation and iterate over the result + await foreach (StaticSiteLinkedBackendResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteLinkedBackendData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteByName() + public async Task Exists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteByName() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendForStaticSite.json // this example is just showing the usage of "StaticSites_GetLinkedBackend" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticS // invoke the operation string linkedBackendName = "testBackend"; - NullableResponse response = await collection.GetIfExistsAsync(linkedBackendName); - StaticSiteLinkedBackendResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(linkedBackendName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteLinkedBackendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LinkABackendToAStaticSite() + public async Task GetIfExists_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteByName() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/LinkBackendToStaticSite.json - // this example is just showing the usage of "StaticSites_LinkBackend" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendForStaticSite.json + // this example is just showing the usage of "StaticSites_GetLinkedBackend" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,19 +180,21 @@ public async Task CreateOrUpdate_LinkABackendToAStaticSite() // invoke the operation string linkedBackendName = "testBackend"; - StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData() - { - BackendResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/backendRg/providers/Microsoft.Web/sites/testBackend"), - Region = "West US 2", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkedBackendName, data); - StaticSiteLinkedBackendResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(linkedBackendName); + StaticSiteLinkedBackendResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteLinkedBackendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteLinkedBackendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteLinkedBackendResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteLinkedBackendResource.cs index 74ecdcc26b2cc..d256095949cc5 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteLinkedBackendResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteLinkedBackendResource.cs @@ -17,10 +17,10 @@ public partial class Sample_StaticSiteLinkedBackendResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateBackend_ValidateIfBackendCanBeLinkedToStaticSite() + public async Task Get_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteByName() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ValidateLinkedBackendForStaticSite.json - // this example is just showing the usage of "StaticSites_ValidateBackend" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendForStaticSite.json + // this example is just showing the usage of "StaticSites_GetLinkedBackend" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,22 +37,21 @@ public async Task ValidateBackend_ValidateIfBackendCanBeLinkedToStaticSite() StaticSiteLinkedBackendResource staticSiteLinkedBackend = client.GetStaticSiteLinkedBackendResource(staticSiteLinkedBackendResourceId); // invoke the operation - StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData() - { - BackendResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/backendRg/providers/Microsoft.Web/sites/testBackend"), - Region = "West US 2", - }; - await staticSiteLinkedBackend.ValidateBackendAsync(WaitUntil.Completed, data); + StaticSiteLinkedBackendResource result = await staticSiteLinkedBackend.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteLinkedBackendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteByName() + public async Task Delete_UnlinkABackendFromAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetLinkedBackendForStaticSite.json - // this example is just showing the usage of "StaticSites_GetLinkedBackend" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/UnlinkBackendFromStaticSite.json + // this example is just showing the usage of "StaticSites_UnlinkBackend" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,13 +68,9 @@ public async Task Get_GetDetailsOfTheLinkedBackendRegisteredWithAStaticSiteByNam StaticSiteLinkedBackendResource staticSiteLinkedBackend = client.GetStaticSiteLinkedBackendResource(staticSiteLinkedBackendResourceId); // invoke the operation - StaticSiteLinkedBackendResource result = await staticSiteLinkedBackend.GetAsync(); + await staticSiteLinkedBackend.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteLinkedBackendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,7 +95,7 @@ public async Task Update_LinkABackendToAStaticSite() StaticSiteLinkedBackendResource staticSiteLinkedBackend = client.GetStaticSiteLinkedBackendResource(staticSiteLinkedBackendResourceId); // invoke the operation - StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData() + StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData { BackendResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/backendRg/providers/Microsoft.Web/sites/testBackend"), Region = "West US 2", @@ -117,10 +112,10 @@ public async Task Update_LinkABackendToAStaticSite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_UnlinkABackendFromAStaticSite() + public async Task ValidateBackend_ValidateIfBackendCanBeLinkedToStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/UnlinkBackendFromStaticSite.json - // this example is just showing the usage of "StaticSites_UnlinkBackend" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ValidateLinkedBackendForStaticSite.json + // this example is just showing the usage of "StaticSites_ValidateBackend" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,7 +132,12 @@ public async Task Delete_UnlinkABackendFromAStaticSite() StaticSiteLinkedBackendResource staticSiteLinkedBackend = client.GetStaticSiteLinkedBackendResource(staticSiteLinkedBackendResourceId); // invoke the operation - await staticSiteLinkedBackend.DeleteAsync(WaitUntil.Completed); + StaticSiteLinkedBackendData data = new StaticSiteLinkedBackendData + { + BackendResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/backendRg/providers/Microsoft.Web/sites/testBackend"), + Region = "West US 2", + }; + await staticSiteLinkedBackend.ValidateBackendAsync(WaitUntil.Completed, data); Console.WriteLine("Succeeded"); } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSitePrivateEndpointConnectionCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSitePrivateEndpointConnectionCollection.cs index 1b127676b81c5..5781c6973c6ea 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSitePrivateEndpointConnectionCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSitePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StaticSitePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfPrivateEndpointConnectionsAssociatedWithASite() + public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnectionList.json - // this example is just showing the usage of "StaticSites_GetPrivateEndpointConnectionList" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnection.json + // this example is just showing the usage of "StaticSites_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,32 @@ public async Task GetAll_GetAListOfPrivateEndpointConnectionsAssociatedWithASite // for more information of creating StaticSiteResource, please refer to the document of StaticSiteResource string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "rg"; - string name = "testStaticSite0"; + string name = "testSite"; ResourceIdentifier staticSiteResourceId = StaticSiteResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); StaticSiteResource staticSite = client.GetStaticSiteResource(staticSiteResourceId); // get the collection of this StaticSitePrivateEndpointConnectionResource StaticSitePrivateEndpointConnectionCollection collection = staticSite.GetStaticSitePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (StaticSitePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "connection"; + RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrivateLinkServiceConnectionState = new PrivateLinkConnectionState + { + Status = "Approved", + Description = "Approved by admin.", + ActionsRequired = "", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + StaticSitePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetAPrivateEndpointConnectionForASite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPrivateEndpointConnectionForASite() + public async Task GetAll_GetAListOfPrivateEndpointConnectionsAssociatedWithASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnection.json - // this example is just showing the usage of "StaticSites_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnectionList.json + // this example is just showing the usage of "StaticSites_GetPrivateEndpointConnectionList" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,23 +110,29 @@ public async Task Exists_GetAPrivateEndpointConnectionForASite() // for more information of creating StaticSiteResource, please refer to the document of StaticSiteResource string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "rg"; - string name = "testSite"; + string name = "testStaticSite0"; ResourceIdentifier staticSiteResourceId = StaticSiteResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, name); StaticSiteResource staticSite = client.GetStaticSiteResource(staticSiteResourceId); // get the collection of this StaticSitePrivateEndpointConnectionResource StaticSitePrivateEndpointConnectionCollection collection = staticSite.GetStaticSitePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "connection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (StaticSitePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPrivateEndpointConnectionForASite() + public async Task Exists_GetAPrivateEndpointConnectionForASite() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnection.json // this example is just showing the usage of "StaticSites_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetAPrivateEndpointConnectionForASite() // invoke the operation string privateEndpointConnectionName = "connection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - StaticSitePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForASite() + public async Task GetIfExists_GetAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnection.json - // this example is just showing the usage of "StaticSites_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetSitePrivateEndpointConnection.json + // this example is just showing the usage of "StaticSites_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForA // invoke the operation string privateEndpointConnectionName = "connection"; - RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData() - { - PrivateLinkServiceConnectionState = new PrivateLinkConnectionState() - { - Status = "Approved", - Description = "Approved by admin.", - ActionsRequired = "", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - StaticSitePrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + StaticSitePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSitePrivateEndpointConnectionResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSitePrivateEndpointConnectionResource.cs index 1d71ec126e70f..1e55d6b46f5d0 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSitePrivateEndpointConnectionResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSitePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAPrivateEndpointConnectionForASite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForASite() + public async Task Delete_DeleteAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnection.json - // this example is just showing the usage of "StaticSites_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteSitePrivateEndpointConnection.json + // this example is just showing the usage of "StaticSites_DeletePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,18 @@ public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForASite() StaticSitePrivateEndpointConnectionResource staticSitePrivateEndpointConnection = client.GetStaticSitePrivateEndpointConnectionResource(staticSitePrivateEndpointConnectionResourceId); // invoke the operation - RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData() - { - PrivateLinkServiceConnectionState = new PrivateLinkConnectionState() - { - Status = "Approved", - Description = "Approved by admin.", - ActionsRequired = "", - }, - }; - ArmOperation lro = await staticSitePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - StaticSitePrivateEndpointConnectionResource result = lro.Value; + ArmOperation lro = await staticSitePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + BinaryData result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPrivateEndpointConnectionForASite() + public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForASite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DeleteSitePrivateEndpointConnection.json - // this example is just showing the usage of "StaticSites_DeletePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ApproveRejectSitePrivateEndpointConnection.json + // this example is just showing the usage of "StaticSites_ApproveOrRejectPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,10 +97,23 @@ public async Task Delete_DeleteAPrivateEndpointConnectionForASite() StaticSitePrivateEndpointConnectionResource staticSitePrivateEndpointConnection = client.GetStaticSitePrivateEndpointConnectionResource(staticSitePrivateEndpointConnectionResourceId); // invoke the operation - ArmOperation lro = await staticSitePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - BinaryData result = lro.Value; + RemotePrivateEndpointConnectionARMResourceData data = new RemotePrivateEndpointConnectionARMResourceData + { + PrivateLinkServiceConnectionState = new PrivateLinkConnectionState + { + Status = "Approved", + Description = "Approved by admin.", + ActionsRequired = "", + }, + }; + ArmOperation lro = await staticSitePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + StaticSitePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemotePrivateEndpointConnectionARMResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteResource.cs index 6e3bfbf116045..3d42d5320921b 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_StaticSiteResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetStaticSites_GetAllStaticSitesInASubscription() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetAllStaticSites.json - // this example is just showing the usage of "StaticSites_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (StaticSiteResource item in subscriptionResource.GetStaticSitesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetDetailsForAStaticSite() @@ -216,7 +184,7 @@ public async Task UpdateUser_CreateOrUpdateAUserForAStaticSite() // invoke the operation string authprovider = "aad"; string userid = "1234"; - StaticSiteUser staticSiteUserEnvelope = new StaticSiteUser() + StaticSiteUser staticSiteUserEnvelope = new StaticSiteUser { Roles = "contributor", }; @@ -246,12 +214,12 @@ public async Task CreateOrUpdateAppSettings_CreatesOrUpdatesTheAppSettingsOfASta StaticSiteResource staticSite = client.GetStaticSiteResource(staticSiteResourceId); // invoke the operation - AppServiceConfigurationDictionary appSettings = new AppServiceConfigurationDictionary() + AppServiceConfigurationDictionary appSettings = new AppServiceConfigurationDictionary { Properties = { ["setting1"] = "someval", -["setting2"] = "someval2", +["setting2"] = "someval2" }, }; AppServiceConfigurationDictionary result = await staticSite.CreateOrUpdateAppSettingsAsync(appSettings); @@ -280,12 +248,12 @@ public async Task CreateOrUpdateFunctionAppSettings_CreatesOrUpdatesTheFunctionA StaticSiteResource staticSite = client.GetStaticSiteResource(staticSiteResourceId); // invoke the operation - AppServiceConfigurationDictionary appSettings = new AppServiceConfigurationDictionary() + AppServiceConfigurationDictionary appSettings = new AppServiceConfigurationDictionary { Properties = { ["setting1"] = "someval", -["setting2"] = "someval2", +["setting2"] = "someval2" }, }; AppServiceConfigurationDictionary result = await staticSite.CreateOrUpdateFunctionAppSettingsAsync(appSettings); @@ -314,7 +282,7 @@ public async Task CreateUserRolesInvitationLink_CreateAnInvitationLinkForAUserFo StaticSiteResource staticSite = client.GetStaticSiteResource(staticSiteResourceId); // invoke the operation - StaticSiteUserInvitationContent content = new StaticSiteUserInvitationContent() + StaticSiteUserInvitationContent content = new StaticSiteUserInvitationContent { Domain = "happy-sea-15afae3e.azurestaticwebsites.net", Provider = "aad", @@ -536,7 +504,7 @@ public async Task ResetApiKey_ResetTheApiKeyForAStaticSite() StaticSiteResource staticSite = client.GetStaticSiteResource(staticSiteResourceId); // invoke the operation - StaticSiteResetContent content = new StaticSiteResetContent() + StaticSiteResetContent content = new StaticSiteResetContent { RepositoryToken = "repoToken123", ShouldUpdateRepository = true, @@ -597,7 +565,7 @@ public async Task CreateZipDeploymentForStaticSite_DeployASiteFromAZippedPackage StaticSiteResource staticSite = client.GetStaticSiteResource(staticSiteResourceId); // invoke the operation - StaticSiteZipDeployment staticSiteZipDeploymentEnvelope = new StaticSiteZipDeployment() + StaticSiteZipDeployment staticSiteZipDeploymentEnvelope = new StaticSiteZipDeployment { AppZipUri = new Uri("https://teststorageaccount.net/happy-sea-15afae3e-master-81828877/app-zipdeploy.zip"), ApiZipUri = new Uri("https://teststorageaccount.net/happy-sea-15afae3e-master-81828877/api-zipdeploy.zip"), diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteUserProvidedFunctionAppCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteUserProvidedFunctionAppCollection.cs index c39bfb4849171..56e5c4338442f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteUserProvidedFunctionAppCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteUserProvidedFunctionAppCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_StaticSiteUserProvidedFunctionAppCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetDetailsOfTheUserProvidedFunctionAppsRegisteredWithAStaticSite() + public async Task CreateOrUpdate_RegisterAUserProvidedFunctionAppWithAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetUserProvidedFunctionAppsForStaticSite.json - // this example is just showing the usage of "StaticSites_GetUserProvidedFunctionAppsForStaticSite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/RegisterUserProvidedFunctionAppWithStaticSite.json + // this example is just showing the usage of "StaticSites_RegisterUserProvidedFunctionAppWithStaticSite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,22 @@ public async Task GetAll_GetDetailsOfTheUserProvidedFunctionAppsRegisteredWithAS // get the collection of this StaticSiteUserProvidedFunctionAppResource StaticSiteUserProvidedFunctionAppCollection collection = staticSite.GetStaticSiteUserProvidedFunctionApps(); - // invoke the operation and iterate over the result - await foreach (StaticSiteUserProvidedFunctionAppResource item in collection.GetAllAsync()) + // invoke the operation + string functionAppName = "testFunctionApp"; + StaticSiteUserProvidedFunctionAppData data = new StaticSiteUserProvidedFunctionAppData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteUserProvidedFunctionAppData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + FunctionAppResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/functionRG/providers/Microsoft.Web/sites/testFunctionApp"), + FunctionAppRegion = "West US 2", + }; + bool? isForced = true; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, functionAppName, data, isForced: isForced); + StaticSiteUserProvidedFunctionAppResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteUserProvidedFunctionAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +92,10 @@ public async Task Get_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStati [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStaticSite() + public async Task GetAll_GetDetailsOfTheUserProvidedFunctionAppsRegisteredWithAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetUserProvidedFunctionAppForStaticSite.json - // this example is just showing the usage of "StaticSites_GetUserProvidedFunctionAppForStaticSite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetUserProvidedFunctionAppsForStaticSite.json + // this example is just showing the usage of "StaticSites_GetUserProvidedFunctionAppsForStaticSite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +113,22 @@ public async Task Exists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithASt // get the collection of this StaticSiteUserProvidedFunctionAppResource StaticSiteUserProvidedFunctionAppCollection collection = staticSite.GetStaticSiteUserProvidedFunctionApps(); - // invoke the operation - string functionAppName = "testFunctionApp"; - bool result = await collection.ExistsAsync(functionAppName); + // invoke the operation and iterate over the result + await foreach (StaticSiteUserProvidedFunctionAppResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteUserProvidedFunctionAppData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStaticSite() + public async Task Exists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStaticSite() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetUserProvidedFunctionAppForStaticSite.json // this example is just showing the usage of "StaticSites_GetUserProvidedFunctionAppForStaticSite" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +151,17 @@ public async Task GetIfExists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWi // invoke the operation string functionAppName = "testFunctionApp"; - NullableResponse response = await collection.GetIfExistsAsync(functionAppName); - StaticSiteUserProvidedFunctionAppResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(functionAppName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteUserProvidedFunctionAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RegisterAUserProvidedFunctionAppWithAStaticSite() + public async Task GetIfExists_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/RegisterUserProvidedFunctionAppWithStaticSite.json - // this example is just showing the usage of "StaticSites_RegisterUserProvidedFunctionAppWithStaticSite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetUserProvidedFunctionAppForStaticSite.json + // this example is just showing the usage of "StaticSites_GetUserProvidedFunctionAppForStaticSite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,20 +181,21 @@ public async Task CreateOrUpdate_RegisterAUserProvidedFunctionAppWithAStaticSite // invoke the operation string functionAppName = "testFunctionApp"; - StaticSiteUserProvidedFunctionAppData data = new StaticSiteUserProvidedFunctionAppData() - { - FunctionAppResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/functionRG/providers/Microsoft.Web/sites/testFunctionApp"), - FunctionAppRegion = "West US 2", - }; - bool? isForced = true; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, functionAppName, data, isForced: isForced); - StaticSiteUserProvidedFunctionAppResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(functionAppName); + StaticSiteUserProvidedFunctionAppResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteUserProvidedFunctionAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteUserProvidedFunctionAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteUserProvidedFunctionAppResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteUserProvidedFunctionAppResource.cs index 33c5d784cd9f3..55a2cd07a7df6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteUserProvidedFunctionAppResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_StaticSiteUserProvidedFunctionAppResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetDetailsOfTheUserProvidedFunctionAppRegisteredWithAStati [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RegisterAUserProvidedFunctionAppWithAStaticSite() + public async Task Delete_DetachTheUserProvidedFunctionAppFromTheStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/RegisterUserProvidedFunctionAppWithStaticSite.json - // this example is just showing the usage of "StaticSites_RegisterUserProvidedFunctionAppWithStaticSite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DetachUserProvidedFunctionAppFromStaticSite.json + // this example is just showing the usage of "StaticSites_DetachUserProvidedFunctionAppFromStaticSite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,28 +68,17 @@ public async Task Update_RegisterAUserProvidedFunctionAppWithAStaticSite() StaticSiteUserProvidedFunctionAppResource staticSiteUserProvidedFunctionApp = client.GetStaticSiteUserProvidedFunctionAppResource(staticSiteUserProvidedFunctionAppResourceId); // invoke the operation - StaticSiteUserProvidedFunctionAppData data = new StaticSiteUserProvidedFunctionAppData() - { - FunctionAppResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/functionRG/providers/Microsoft.Web/sites/testFunctionApp"), - FunctionAppRegion = "West US 2", - }; - bool? isForced = true; - ArmOperation lro = await staticSiteUserProvidedFunctionApp.UpdateAsync(WaitUntil.Completed, data, isForced: isForced); - StaticSiteUserProvidedFunctionAppResource result = lro.Value; + await staticSiteUserProvidedFunctionApp.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StaticSiteUserProvidedFunctionAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DetachTheUserProvidedFunctionAppFromTheStaticSite() + public async Task Update_RegisterAUserProvidedFunctionAppWithAStaticSite() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/DetachUserProvidedFunctionAppFromStaticSite.json - // this example is just showing the usage of "StaticSites_DetachUserProvidedFunctionAppFromStaticSite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/RegisterUserProvidedFunctionAppWithStaticSite.json + // this example is just showing the usage of "StaticSites_RegisterUserProvidedFunctionAppWithStaticSite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +95,20 @@ public async Task Delete_DetachTheUserProvidedFunctionAppFromTheStaticSite() StaticSiteUserProvidedFunctionAppResource staticSiteUserProvidedFunctionApp = client.GetStaticSiteUserProvidedFunctionAppResource(staticSiteUserProvidedFunctionAppResourceId); // invoke the operation - await staticSiteUserProvidedFunctionApp.DeleteAsync(WaitUntil.Completed); + StaticSiteUserProvidedFunctionAppData data = new StaticSiteUserProvidedFunctionAppData + { + FunctionAppResourceId = new ResourceIdentifier("/subscription/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/functionRG/providers/Microsoft.Web/sites/testFunctionApp"), + FunctionAppRegion = "West US 2", + }; + bool? isForced = true; + ArmOperation lro = await staticSiteUserProvidedFunctionApp.UpdateAsync(WaitUntil.Completed, data, isForced: isForced); + StaticSiteUserProvidedFunctionAppResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteUserProvidedFunctionAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 0ec63d514d555..fef78872ed85e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAppServiceCertificateOrders_ListAppServiceCertificateOrdersBySubscription() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.CertificateRegistration/stable/2024-04-01/examples/ListAppServiceCertificateOrdersBySubscription.json + // this example is just showing the usage of "AppServiceCertificateOrders_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AppServiceCertificateOrderResource item in subscriptionResource.GetAppServiceCertificateOrdersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceCertificateOrderData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task ValidateAppServiceCertificateOrderPurchaseInformation_ValidateAppServiceCertificatePurchaseInformationBySubscription() @@ -40,16 +71,16 @@ public async Task ValidateAppServiceCertificateOrderPurchaseInformation_Validate { Certificates = { -["SampleCertName1"] = new AppServiceCertificateProperties() +["SampleCertName1"] = new AppServiceCertificateProperties { KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), KeyVaultSecretName = "SampleSecretName1", }, -["SampleCertName2"] = new AppServiceCertificateProperties() +["SampleCertName2"] = new AppServiceCertificateProperties { KeyVaultId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/microsoft.keyvault/vaults/SamplevaultName"), KeyVaultSecretName = "SampleSecretName2", -}, +} }, DistinguishedName = "CN=SampleCustomDomain.com", ValidityInYears = 2, @@ -81,7 +112,7 @@ public async Task CheckAppServiceDomainRegistrationAvailability_CheckDomainAvail SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - AppServiceDomainNameIdentifier identifier = new AppServiceDomainNameIdentifier() + AppServiceDomainNameIdentifier identifier = new AppServiceDomainNameIdentifier { Name = "abcd.com", }; @@ -90,6 +121,37 @@ public async Task CheckAppServiceDomainRegistrationAvailability_CheckDomainAvail Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAppServiceDomains_ListDomainsBySubscription() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/ListDomainsBySubscription.json + // this example is just showing the usage of "Domains_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AppServiceDomainResource item in subscriptionResource.GetAppServiceDomainsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceDomainData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetControlCenterSsoRequestDomain_GetDomainControlCenterSsoRequest() @@ -133,7 +195,7 @@ public async Task GetAppServiceDomainRecommendations_ListDomainRecommendations() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - DomainRecommendationSearchContent content = new DomainRecommendationSearchContent() + DomainRecommendationSearchContent content = new DomainRecommendationSearchContent { Keywords = "example1", MaxDomainRecommendations = 10, @@ -146,6 +208,192 @@ public async Task GetAppServiceDomainRecommendations_ListDomainRecommendations() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAppServiceEnvironments_GetAllAppServiceEnvironmentsForASubscription() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/AppServiceEnvironments_List.json + // this example is just showing the usage of "AppServiceEnvironments_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AppServiceEnvironmentResource item in subscriptionResource.GetAppServiceEnvironmentsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServiceEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAppServicePlans_ListAppServicePlans() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListAppServicePlans.json + // this example is just showing the usage of "AppServicePlans_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AppServicePlanResource item in subscriptionResource.GetAppServicePlansAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppServicePlanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAppCertificates_ListCertificatesForSubscription() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListCertificates.json + // this example is just showing the usage of "Certificates_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AppCertificateResource item in subscriptionResource.GetAppCertificatesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeletedSitesByLocation_ListDeletedWebAppByLocation() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListDeletedWebAppsByLocation.json + // this example is just showing the usage of "DeletedWebApps_ListByLocation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("West US 2"); + await foreach (DeletedSiteResource item in subscriptionResource.GetDeletedSitesByLocationAsync(location)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeletedSiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeletedWebAppByLocationDeletedWebApp_GetDeletedWebAppByLocation() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetDeletedWebAppByLocation.json + // this example is just showing the usage of "DeletedWebApps_GetDeletedWebAppByLocation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("West US 2"); + string deletedSiteId = "9"; + DeletedSiteResource result = await subscriptionResource.GetDeletedWebAppByLocationDeletedWebAppAsync(location, deletedSiteId); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeletedSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetKubeEnvironments_ListKubeEnvironmentsBySubscription() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/KubeEnvironments_ListBySubscription.json + // this example is just showing the usage of "KubeEnvironments_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (KubeEnvironmentResource item in subscriptionResource.GetKubeEnvironmentsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KubeEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAllResourceHealthMetadata_ListResourceHealthMetadataForASubscription() @@ -275,7 +523,7 @@ public async Task VerifyHostingEnvironmentVnet_VerifyHostingEnvironmentVnet() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - AppServiceVirtualNetworkValidationContent content = new AppServiceVirtualNetworkValidationContent() + AppServiceVirtualNetworkValidationContent content = new AppServiceVirtualNetworkValidationContent { VnetResourceGroup = "vNet123rg", VnetName = "vNet123", @@ -334,11 +582,11 @@ public async Task PreviewStaticSiteWorkflow_GeneratesAPreviewWorkflowFileForTheS // invoke the operation AzureLocation location = new AzureLocation("West US 2"); - StaticSitesWorkflowPreviewContent content = new StaticSitesWorkflowPreviewContent() + StaticSitesWorkflowPreviewContent content = new StaticSitesWorkflowPreviewContent { RepositoryUri = new Uri("https://github.com/username/RepoName"), Branch = "master", - BuildProperties = new StaticSiteBuildProperties() + BuildProperties = new StaticSiteBuildProperties { AppLocation = "app", ApiLocation = "api", @@ -349,5 +597,67 @@ public async Task PreviewStaticSiteWorkflow_GeneratesAPreviewWorkflowFileForTheS Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStaticSites_GetAllStaticSitesInASubscription() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetAllStaticSites.json + // this example is just showing the usage of "StaticSites_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (StaticSiteResource item in subscriptionResource.GetStaticSitesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StaticSiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetWebSites_ListWebAppsForSubscription() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWebApps.json + // this example is just showing the usage of "WebApps_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (WebSiteResource item in subscriptionResource.GetWebSitesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index c0b4cdd2a101e..1c7d96f082704 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppService.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppService.Samples @@ -28,9 +29,7 @@ public async Task GetOperationsCertificateRegistrationProviders_ListOperations() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (CsmOperationDescription item in tenantResource.GetOperationsCertificateRegistrationProvidersAsync()) @@ -53,9 +52,7 @@ public async Task GetOperationsDomainRegistrationProviders_ListOperations() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (CsmOperationDescription item in tenantResource.GetOperationsDomainRegistrationProvidersAsync()) @@ -78,9 +75,7 @@ public async Task GetFunctionAppStacksProviders_GetFunctionAppStacks() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (FunctionAppStack item in tenantResource.GetFunctionAppStacksProvidersAsync()) @@ -103,9 +98,7 @@ public async Task GetFunctionAppStacksForLocationProviders_GetLocationsFunctionA // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result AzureLocation location = new AzureLocation("westus"); @@ -129,9 +122,7 @@ public async Task GetWebAppStacksByLocation_GetLocationsWebAppStacks() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result AzureLocation location = new AzureLocation("westus"); @@ -155,9 +146,7 @@ public async Task GetOperationsProviders_ListOperations() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (CsmOperationDescription item in tenantResource.GetOperationsProvidersAsync()) @@ -180,9 +169,7 @@ public async Task GetWebAppStacksProviders_GetWebAppStacks() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (WebAppStack item in tenantResource.GetWebAppStacksProvidersAsync()) diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TopLevelDomainCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TopLevelDomainCollection.cs index f97a3000de343..14100d8b44e4e 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TopLevelDomainCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TopLevelDomainCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_TopLevelDomainCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTopLevelDomains() + public async Task Get_GetTopLevelDomain() { - // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/ListTopLevelDomains.json - // this example is just showing the usage of "TopLevelDomains_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/GetTopLevelDomain.json + // this example is just showing the usage of "TopLevelDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_ListTopLevelDomains() // get the collection of this TopLevelDomainResource TopLevelDomainCollection collection = subscriptionResource.GetTopLevelDomains(); - // invoke the operation and iterate over the result - await foreach (TopLevelDomainResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TopLevelDomainData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "com"; + TopLevelDomainResource result = await collection.GetAsync(name); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TopLevelDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTopLevelDomain() + public async Task GetAll_ListTopLevelDomains() { - // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/GetTopLevelDomain.json - // this example is just showing the usage of "TopLevelDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.DomainRegistration/stable/2024-04-01/examples/ListTopLevelDomains.json + // this example is just showing the usage of "TopLevelDomains_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +69,17 @@ public async Task Get_GetTopLevelDomain() // get the collection of this TopLevelDomainResource TopLevelDomainCollection collection = subscriptionResource.GetTopLevelDomains(); - // invoke the operation - string name = "com"; - TopLevelDomainResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (TopLevelDomainResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TopLevelDomainData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TopLevelDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TopLevelDomainResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TopLevelDomainResource.cs index f79512bc83f21..afc589d7d2402 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TopLevelDomainResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_TopLevelDomainResource.cs @@ -65,7 +65,7 @@ public async Task GetAgreements_ListTopLevelDomainAgreements() TopLevelDomainResource topLevelDomain = client.GetTopLevelDomainResource(topLevelDomainResourceId); // invoke the operation and iterate over the result - TopLevelDomainAgreementOption agreementOption = new TopLevelDomainAgreementOption() + TopLevelDomainAgreementOption agreementOption = new TopLevelDomainAgreementOption { IncludePrivacy = true, IsForTransfer = false, diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebAppRequestHistoryCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebAppRequestHistoryCollection.cs index 5465a21a1234b..7227a7c3f3131 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebAppRequestHistoryCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebAppRequestHistoryCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WebAppRequestHistoryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRepetitionRequestHistory() + public async Task Get_GetARepetitionRequestHistory() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionRepetitionsRequestHistories_List.json - // this example is just showing the usage of "WorkflowRunActionRepetitionsRequestHistories_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionRepetitionsRequestHistories_Get.json + // this example is just showing the usage of "WorkflowRunActionRepetitionsRequestHistories_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,25 +42,23 @@ public async Task GetAll_ListRepetitionRequestHistory() // get the collection of this WebAppRequestHistoryResource WebAppRequestHistoryCollection collection = workflowRunActionRepetition.GetWebAppRequestHistories(); - // invoke the operation and iterate over the result - await foreach (WebAppRequestHistoryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebAppRequestHistoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string requestHistoryName = "08586611142732800686"; + WebAppRequestHistoryResource result = await collection.GetAsync(requestHistoryName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebAppRequestHistoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARepetitionRequestHistory() + public async Task GetAll_ListRepetitionRequestHistory() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionRepetitionsRequestHistories_Get.json - // this example is just showing the usage of "WorkflowRunActionRepetitionsRequestHistories_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionRepetitionsRequestHistories_List.json + // this example is just showing the usage of "WorkflowRunActionRepetitionsRequestHistories_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -82,15 +80,17 @@ public async Task Get_GetARepetitionRequestHistory() // get the collection of this WebAppRequestHistoryResource WebAppRequestHistoryCollection collection = workflowRunActionRepetition.GetWebAppRequestHistories(); - // invoke the operation - string requestHistoryName = "08586611142732800686"; - WebAppRequestHistoryResource result = await collection.GetAsync(requestHistoryName); + // invoke the operation and iterate over the result + await foreach (WebAppRequestHistoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebAppRequestHistoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebAppRequestHistoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteCollection.cs index aac7402dbaf68..fd17db577a1e6 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteCollection.cs @@ -17,144 +17,6 @@ namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_WebSiteCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWebAppsByResourceGroup() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWebAppsByResourceGroup.json - // this example is just showing the usage of "WebApps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "testrg123"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this WebSiteResource - WebSiteCollection collection = resourceGroupResource.GetWebSites(); - - // invoke the operation and iterate over the result - await foreach (WebSiteResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetWebApp() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebApp.json - // this example is just showing the usage of "WebApps_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "testrg123"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this WebSiteResource - WebSiteCollection collection = resourceGroupResource.GetWebSites(); - - // invoke the operation - string name = "sitef6141"; - WebSiteResource result = await collection.GetAsync(name); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWebApp() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebApp.json - // this example is just showing the usage of "WebApps_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "testrg123"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this WebSiteResource - WebSiteCollection collection = resourceGroupResource.GetWebSites(); - - // invoke the operation - string name = "sitef6141"; - bool result = await collection.ExistsAsync(name); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWebApp() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebApp.json - // this example is just showing the usage of "WebApps_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "testrg123"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this WebSiteResource - WebSiteCollection collection = resourceGroupResource.GetWebSites(); - - // invoke the operation - string name = "sitef6141"; - NullableResponse response = await collection.GetIfExistsAsync(name); - WebSiteResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CloneWebApp() @@ -191,7 +53,7 @@ public async Task CreateOrUpdate_CloneWebApp() AppSettingsOverrides = { ["Setting1"] = "NewValue1", -["Setting3"] = "NewValue5", +["Setting3"] = "NewValue5" }, ConfigureLoadBalancing = false, }, @@ -233,39 +95,36 @@ public async Task CreateOrUpdate_CreateOrUpdateFlexConsumptionFunctionApp() string name = "sitef6141"; WebSiteData data = new WebSiteData(new AzureLocation("East US")) { - SiteConfig = new SiteConfigProperties() + SiteConfig = new SiteConfigProperties { - AppSettings = -{ -new AppServiceNameValuePair() + AppSettings = {new AppServiceNameValuePair { Name = "AzureWebJobsStorage", Value = "DefaultEndpointsProtocol=https;AccountName=StorageAccountName;AccountKey=Sanitized;EndpointSuffix=core.windows.net", -},new AppServiceNameValuePair() +}, new AppServiceNameValuePair { Name = "APPLICATIONINSIGHTS_CONNECTION_STRING", Value = "InstrumentationKey=Sanitized;IngestionEndpoint=Sanitized;LiveEndpoint=Sanitized", -} -}, +}}, }, - FunctionAppConfig = new FunctionAppConfig() + FunctionAppConfig = new FunctionAppConfig { - DeploymentStorage = new FunctionAppStorage() + DeploymentStorage = new FunctionAppStorage { StorageType = FunctionAppStorageType.BlobContainer, Value = new Uri("https://storageAccountName.blob.core.windows.net/containername"), - Authentication = new FunctionAppStorageAuthentication() + Authentication = new FunctionAppStorageAuthentication { AuthenticationType = FunctionAppStorageAccountAuthenticationType.StorageAccountConnectionString, StorageAccountConnectionStringName = "TheAppSettingName", }, }, - Runtime = new FunctionAppRuntime() + Runtime = new FunctionAppRuntime { Name = FunctionAppRuntimeName.Python, Version = "3.11", }, - ScaleAndConcurrency = new FunctionAppScaleAndConcurrency() + ScaleAndConcurrency = new FunctionAppScaleAndConcurrency { FunctionAppMaximumInstanceCount = 100, FunctionAppInstanceMemoryMB = 2048, @@ -309,48 +168,42 @@ public async Task CreateOrUpdate_CreateOrUpdateFlexConsumptionFunctionAppWithDet string name = "sitef6141"; WebSiteData data = new WebSiteData(new AzureLocation("East US")) { - SiteConfig = new SiteConfigProperties() + SiteConfig = new SiteConfigProperties { - AppSettings = -{ -new AppServiceNameValuePair() + AppSettings = {new AppServiceNameValuePair { Name = "AzureWebJobsStorage", Value = "DefaultEndpointsProtocol=https;AccountName=StorageAccountName;AccountKey=Sanitized;EndpointSuffix=core.windows.net", -},new AppServiceNameValuePair() +}, new AppServiceNameValuePair { Name = "APPLICATIONINSIGHTS_CONNECTION_STRING", Value = "InstrumentationKey=Sanitized;IngestionEndpoint=Sanitized;LiveEndpoint=Sanitized", -} -}, +}}, }, - FunctionAppConfig = new FunctionAppConfig() + FunctionAppConfig = new FunctionAppConfig { - DeploymentStorage = new FunctionAppStorage() + DeploymentStorage = new FunctionAppStorage { StorageType = FunctionAppStorageType.BlobContainer, Value = new Uri("https://storageAccountName.blob.core.windows.net/containername"), - Authentication = new FunctionAppStorageAuthentication() + Authentication = new FunctionAppStorageAuthentication { AuthenticationType = FunctionAppStorageAccountAuthenticationType.StorageAccountConnectionString, StorageAccountConnectionStringName = "TheAppSettingName", }, }, - Runtime = new FunctionAppRuntime() + Runtime = new FunctionAppRuntime { Name = FunctionAppRuntimeName.Python, Version = "3.11", }, - ScaleAndConcurrency = new FunctionAppScaleAndConcurrency() + ScaleAndConcurrency = new FunctionAppScaleAndConcurrency { - AlwaysReady = -{ -new FunctionAppAlwaysReadyConfig() + AlwaysReady = {new FunctionAppAlwaysReadyConfig { Name = "http", AlwaysReadyInstanceCount = 2, -} -}, +}}, FunctionAppMaximumInstanceCount = 100, FunctionAppInstanceMemoryMB = 2048, ConcurrentHttpPerInstanceConcurrency = 16, @@ -406,5 +259,143 @@ public async Task CreateOrUpdate_CreateOrUpdateWebApp() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetWebApp() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebApp.json + // this example is just showing the usage of "WebApps_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "testrg123"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WebSiteResource + WebSiteCollection collection = resourceGroupResource.GetWebSites(); + + // invoke the operation + string name = "sitef6141"; + WebSiteResource result = await collection.GetAsync(name); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListWebAppsByResourceGroup() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWebAppsByResourceGroup.json + // this example is just showing the usage of "WebApps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "testrg123"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WebSiteResource + WebSiteCollection collection = resourceGroupResource.GetWebSites(); + + // invoke the operation and iterate over the result + await foreach (WebSiteResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetWebApp() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebApp.json + // this example is just showing the usage of "WebApps_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "testrg123"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WebSiteResource + WebSiteCollection collection = resourceGroupResource.GetWebSites(); + + // invoke the operation + string name = "sitef6141"; + bool result = await collection.ExistsAsync(name); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetWebApp() + { + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebApp.json + // this example is just showing the usage of "WebApps_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "testrg123"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WebSiteResource + WebSiteCollection collection = resourceGroupResource.GetWebSites(); + + // invoke the operation + string name = "sitef6141"; + NullableResponse response = await collection.GetIfExistsAsync(name); + WebSiteResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteConfigResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteConfigResource.cs index 5c55db77f2c1f..8f7427207f7cd 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteConfigResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteConfigResource.cs @@ -67,13 +67,10 @@ public async Task CreateOrUpdate_UpdateSiteConfig() WebSiteConfigResource webSiteConfig = client.GetWebSiteConfigResource(webSiteConfigResourceId); // invoke the operation - SiteConfigData data = new SiteConfigData() + SiteConfigData data = new SiteConfigData { NumberOfWorkers = 1, - DefaultDocuments = -{ -"Default.htm","Default.html","Default.asp","index.htm","index.html","iisstart.htm","default.aspx","index.php","hostingstart.html" -}, + DefaultDocuments = { "Default.htm", "Default.html", "Default.asp", "index.htm", "index.html", "iisstart.htm", "default.aspx", "index.php", "hostingstart.html" }, NetFrameworkVersion = "v4.0", PhpVersion = "5.6", PythonVersion = "", @@ -91,15 +88,12 @@ public async Task CreateOrUpdate_UpdateSiteConfig() IsAlwaysOn = false, AppCommandLine = "", ManagedPipelineMode = ManagedPipelineMode.Integrated, - VirtualApplications = -{ -new VirtualApplication() + VirtualApplications = {new VirtualApplication { VirtualPath = "/", PhysicalPath = "site\\wwwroot", IsPreloadEnabled = false, -} -}, +}}, LoadBalancing = SiteLoadBalancing.LeastRequests, IsAutoHealEnabled = false, VnetName = "", @@ -112,9 +106,7 @@ public async Task CreateOrUpdate_UpdateSiteConfig() FunctionAppScaleLimit = 0, IsFunctionsRuntimeScaleMonitoringEnabled = false, MinimumElasticInstanceCount = 0, - AzureStorageAccounts = -{ -}, + AzureStorageAccounts = { }, }; ArmOperation lro = await webSiteConfig.CreateOrUpdateAsync(WaitUntil.Completed, data); WebSiteConfigResource result = lro.Value; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteFtpPublishingCredentialsPolicyResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteFtpPublishingCredentialsPolicyResource.cs index 447b90abd4f03..8d8944a84a59f 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteFtpPublishingCredentialsPolicyResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteFtpPublishingCredentialsPolicyResource.cs @@ -66,7 +66,7 @@ public async Task CreateOrUpdate_UpdateFTPAllowed() WebSiteFtpPublishingCredentialsPolicyResource webSiteFtpPublishingCredentialsPolicy = client.GetWebSiteFtpPublishingCredentialsPolicyResource(webSiteFtpPublishingCredentialsPolicyResourceId); // invoke the operation - CsmPublishingCredentialsPoliciesEntityData data = new CsmPublishingCredentialsPoliciesEntityData() + CsmPublishingCredentialsPoliciesEntityData data = new CsmPublishingCredentialsPoliciesEntityData { Allow = true, }; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteResource.cs index 542e326177f30..38e40dd1ad7af 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteResource.cs @@ -11,44 +11,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppService.Samples { public partial class Sample_WebSiteResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetWebSites_ListWebAppsForSubscription() - { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWebApps.json - // this example is just showing the usage of "WebApps_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (WebSiteResource item in subscriptionResource.GetWebSitesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetWebApp() @@ -126,7 +94,7 @@ public async Task Update_UpdateWebApp() WebSiteResource webSite = client.GetWebSiteResource(webSiteResourceId); // invoke the operation - SitePatchInfo info = new SitePatchInfo() + SitePatchInfo info = new SitePatchInfo { ServerFarmId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Web/serverfarms/DefaultAsp"), }; @@ -213,7 +181,7 @@ public async Task Backup_BackupWebApp() WebSiteResource webSite = client.GetWebSiteResource(webSiteResourceId); // invoke the operation - WebAppBackupInfo info = new WebAppBackupInfo() + WebAppBackupInfo info = new WebAppBackupInfo { BackupName = "abcdwe", IsEnabled = true, @@ -222,20 +190,17 @@ public async Task Backup_BackupWebApp() { StartOn = DateTimeOffset.Parse("2022-09-02T17:33:11.641Z"), }, - Databases = -{ -new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) + Databases = {new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) { Name = "backenddb", ConnectionStringName = "backend", ConnectionString = "DSN=data-source-name[;SERVER=value] [;PWD=value] [;UID=value] [;=]", -},new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) +}, new AppServiceDatabaseBackupSetting(AppServiceDatabaseType.SqlAzure) { Name = "statsdb", ConnectionStringName = "stats", ConnectionString = "DSN=data-source-name[;SERVER=value] [;PWD=value] [;UID=value] [;=]", -} -}, +}}, }; WebAppBackupData result = await webSite.BackupAsync(info); @@ -294,12 +259,12 @@ public async Task UpdateApplicationSettings_UpdateAppSettings() WebSiteResource webSite = client.GetWebSiteResource(webSiteResourceId); // invoke the operation - AppServiceConfigurationDictionary appSettings = new AppServiceConfigurationDictionary() + AppServiceConfigurationDictionary appSettings = new AppServiceConfigurationDictionary { Properties = { ["Setting1"] = "Value1", -["Setting2"] = "Value2", +["Setting2"] = "Value2" }, }; AppServiceConfigurationDictionary result = await webSite.UpdateApplicationSettingsAsync(appSettings); @@ -354,16 +319,13 @@ public async Task UpdateAuthSettings_UpdateAuthSettings() WebSiteResource webSite = client.GetWebSiteResource(webSiteResourceId); // invoke the operation - SiteAuthSettings siteAuthSettings = new SiteAuthSettings() + SiteAuthSettings siteAuthSettings = new SiteAuthSettings { IsEnabled = true, RuntimeVersion = "~1", UnauthenticatedClientAction = UnauthenticatedClientAction.RedirectToLoginPage, IsTokenStoreEnabled = true, - AllowedExternalRedirectUrls = -{ -"sitef6141.customdomain.net","sitef6141.customdomain.info" -}, + AllowedExternalRedirectUrls = { "sitef6141.customdomain.net", "sitef6141.customdomain.info" }, DefaultProvider = BuiltInAuthenticationProvider.Google, TokenRefreshExtensionHours = 120, ClientId = "42d795a9-8abb-4d06-8534-39528af40f8e.apps.googleusercontent.com", @@ -446,72 +408,60 @@ public async Task UpdateAuthSettingsV2_UpdateAuthSettingsV2() WebSiteResource webSite = client.GetWebSiteResource(webSiteResourceId); // invoke the operation - SiteAuthSettingsV2 siteAuthSettingsV2 = new SiteAuthSettingsV2() + SiteAuthSettingsV2 siteAuthSettingsV2 = new SiteAuthSettingsV2 { - Platform = new AuthPlatform() + Platform = new AuthPlatform { IsEnabled = true, RuntimeVersion = "~1", ConfigFilePath = "/auth/config.json", }, - GlobalValidation = new GlobalValidation() + GlobalValidation = new GlobalValidation { IsAuthenticationRequired = true, UnauthenticatedClientAction = UnauthenticatedClientActionV2.Return403, - ExcludedPaths = -{ -"/nosecrets/Path" -}, + ExcludedPaths = { "/nosecrets/Path" }, }, - IdentityProviders = new AppServiceIdentityProviders() + IdentityProviders = new AppServiceIdentityProviders { - Google = new AppServiceGoogleProvider() + Google = new AppServiceGoogleProvider { IsEnabled = true, - Registration = new ClientRegistration() + Registration = new ClientRegistration { ClientId = "42d795a9-8abb-4d06-8534-39528af40f8e.apps.googleusercontent.com", ClientSecretSettingName = "ClientSecret", }, - LoginScopes = -{ -"admin" -}, - ValidationAllowedAudiences = -{ -"https://example.com" -}, + LoginScopes = { "admin" }, + ValidationAllowedAudiences = { "https://example.com" }, }, }, - Login = new WebAppLoginInfo() + Login = new WebAppLoginInfo { RoutesLogoutEndpoint = "https://app.com/logout", - TokenStore = new AppServiceTokenStore() + TokenStore = new AppServiceTokenStore { IsEnabled = true, TokenRefreshExtensionHours = 96, FileSystemDirectory = "/wwwroot/sites/example", }, PreserveUrlFragmentsForLogins = true, - AllowedExternalRedirectUrls = -{ -"https://someurl.com" -}, - CookieExpiration = new WebAppCookieExpiration() + AllowedExternalRedirectUrls = { "https://someurl.com" }, + CookieExpiration = new WebAppCookieExpiration { Convention = CookieExpirationConvention.IdentityProviderDerived, TimeToExpiration = "2022:09-01T00:00Z", }, - Nonce = new LoginFlowNonceSettings() + Nonce = new LoginFlowNonceSettings { ValidateNonce = true, }, }, - HttpSettings = new AppServiceHttpSettings() + HttpSettings = new AppServiceHttpSettings { IsHttpsRequired = true, RoutesApiPrefix = "/authv2/", - ForwardProxy = new AppServiceForwardProxy() + ForwardProxy = new AppServiceForwardProxy { Convention = ForwardProxyConvention.Standard, CustomHostHeaderName = "authHeader", @@ -571,18 +521,18 @@ public async Task UpdateAzureStorageAccounts_UpdateAzureStorageAccounts() WebSiteResource webSite = client.GetWebSiteResource(webSiteResourceId); // invoke the operation - AzureStoragePropertyDictionary azureStorageAccounts = new AzureStoragePropertyDictionary() + AzureStoragePropertyDictionary azureStorageAccounts = new AzureStoragePropertyDictionary { Properties = { -["account1"] = new AppServiceStorageAccessInfo() +["account1"] = new AppServiceStorageAccessInfo { StorageType = AppServiceStorageType.AzureFiles, AccountName = "testsa", ShareName = "web", AccessKey = "26515^%@#*", MountPath = "/mounts/a/files", -}, +} }, }; AzureStoragePropertyDictionary result = await webSite.UpdateAzureStorageAccountsAsync(azureStorageAccounts); @@ -981,12 +931,9 @@ public async Task DeployWorkflowArtifacts_DeleteWorkflowArtifacts() WebSiteResource webSite = client.GetWebSiteResource(webSiteResourceId); // invoke the operation - WorkflowArtifacts workflowArtifacts = new WorkflowArtifacts() + WorkflowArtifacts workflowArtifacts = new WorkflowArtifacts { - FilesToDelete = -{ -"test/workflow.json","test/" -}, + FilesToDelete = { "test/workflow.json", "test/" }, }; await webSite.DeployWorkflowArtifactsAsync(workflowArtifacts: workflowArtifacts); @@ -1014,59 +961,65 @@ public async Task DeployWorkflowArtifacts_DeploysWorkflowArtifacts() WebSiteResource webSite = client.GetWebSiteResource(webSiteResourceId); // invoke the operation - WorkflowArtifacts workflowArtifacts = new WorkflowArtifacts() + WorkflowArtifacts workflowArtifacts = new WorkflowArtifacts { - AppSettings = BinaryData.FromObjectAsJson(new Dictionary() + AppSettings = BinaryData.FromObjectAsJson(new { - ["eventHub_connectionString"] = "Endpoint=sb://example.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=EXAMPLE1a2b3c4d5e6fEXAMPLE=" + eventHub_connectionString = "Endpoint=sb://example.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=EXAMPLE1a2b3c4d5e6fEXAMPLE=", }), Files = { -["connections.json"] = BinaryData.FromObjectAsJson(new Dictionary() +["connections.json"] = BinaryData.FromObjectAsJson(new { -["managedApiConnections"] = new Dictionary() -{ -}, -["serviceProviderConnections"] = new Dictionary() +managedApiConnections = new object(), +serviceProviderConnections = new { -["eventHub"] = new Dictionary() +eventHub = new { -["displayName"] = "example1", -["parameterValues"] = new Dictionary() +displayName = "example1", +parameterValues = new { -["connectionString"] = "@appsetting('eventHub_connectionString')"}, -["serviceProvider"] = new Dictionary() +connectionString = "@appsetting('eventHub_connectionString')", +}, +serviceProvider = new { -["id"] = "/serviceProviders/eventHub"}}}}), -["test1/workflow.json"] = BinaryData.FromObjectAsJson(new Dictionary() +id = "/serviceProviders/eventHub", +}, +}, +}, +}), +["test1/workflow.json"] = BinaryData.FromObjectAsJson(new { -["definition"] = new Dictionary() +definition = new Dictionary { ["$schema"] = "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", -["actions"] = new Dictionary() -{ -}, +["actions"] = new object(), ["contentVersion"] = "1.0.0.0", -["outputs"] = new Dictionary() +["outputs"] = new object(), +["triggers"] = new { -}, -["triggers"] = new Dictionary() +When_events_are_available_in_Event_hub = new { -["When_events_are_available_in_Event_hub"] = new Dictionary() +type = "ServiceProvider", +inputs = new { -["type"] = "ServiceProvider", -["inputs"] = new Dictionary() +parameters = new { -["parameters"] = new Dictionary() -{ -["eventHubName"] = "test123"}, -["serviceProviderConfiguration"] = new Dictionary() +eventHubName = "test123", +}, +serviceProviderConfiguration = new { -["operationId"] = "receiveEvents", -["connectionName"] = "eventHub", -["serviceProviderId"] = "/serviceProviders/eventHub"}}, -["splitOn"] = "@triggerOutputs()?['body']"}}}, -["kind"] = "Stateful"}), +operationId = "receiveEvents", +connectionName = "eventHub", +serviceProviderId = "/serviceProviders/eventHub", +}, +}, +splitOn = "@triggerOutputs()?['body']", +}, +} +}, +kind = "Stateful", +}) }, }; await webSite.DeployWorkflowArtifactsAsync(workflowArtifacts: workflowArtifacts); @@ -1123,7 +1076,7 @@ public async Task RegenerateAccessKeyWorkflow_RegenerateTheCallbackURLAccessKeyF // invoke the operation string workflowName = "testWorkflowName"; - WorkflowRegenerateActionContent content = new WorkflowRegenerateActionContent() + WorkflowRegenerateActionContent content = new WorkflowRegenerateActionContent { KeyType = WebAppKeyType.Primary, }; @@ -1154,24 +1107,16 @@ public async Task ValidateWorkflow_ValidateAWorkflow() // invoke the operation string workflowName = "test-workflow"; - WorkflowData data = new WorkflowData(new AzureLocation("placeholder")) + WorkflowData data = new WorkflowData(default) { - Definition = BinaryData.FromObjectAsJson(new Dictionary() + Definition = BinaryData.FromObjectAsJson(new Dictionary { ["$schema"] = "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", - ["actions"] = new Dictionary() - { - }, + ["actions"] = new object(), ["contentVersion"] = "1.0.0.0", - ["outputs"] = new Dictionary() - { - }, - ["parameters"] = new Dictionary() - { - }, - ["triggers"] = new Dictionary() - { - } + ["outputs"] = new object(), + ["parameters"] = new object(), + ["triggers"] = new object() }), Kind = AppServiceKind.Stateful, }; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotCollection.cs index 9e2294078c625..84efc360e2003 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_WebSiteSlotCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWebAppSlots() + public async Task CreateOrUpdate_CloneWebAppSlot() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWebAppSlots.json - // this example is just showing the usage of "WebApps_ListSlots" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CloneWebAppSlot.json + // this example is just showing the usage of "WebApps_CreateOrUpdateSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,42 @@ public async Task GetAll_ListWebAppSlots() // get the collection of this WebSiteSlotResource WebSiteSlotCollection collection = webSite.GetWebSiteSlots(); - // invoke the operation and iterate over the result - await foreach (WebSiteSlotResource item in collection.GetAllAsync()) + // invoke the operation + string slot = "staging"; + WebSiteData data = new WebSiteData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CloningInfo = new CloningInfo(new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg456/providers/Microsoft.Web/sites/srcsiteg478/slot/qa")) + { + CanOverwrite = false, + CloneCustomHostNames = true, + CloneSourceControl = true, + SourceWebAppLocation = new AzureLocation("West Europe"), + HostingEnvironment = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg456/providers/Microsoft.Web/hostingenvironments/aseforsites", + AppSettingsOverrides = +{ +["Setting1"] = "NewValue1", +["Setting3"] = "NewValue5" +}, + ConfigureLoadBalancing = false, + }, + Kind = "app", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, slot, data); + WebSiteSlotResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWebAppSlot() + public async Task CreateOrUpdate_CreateOrUpdateWebAppSlot() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebAppSlot.json - // this example is just showing the usage of "WebApps_GetSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateWebAppSlot.json + // this example is just showing the usage of "WebApps_CreateOrUpdateSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +94,13 @@ public async Task Get_GetWebAppSlot() // invoke the operation string slot = "staging"; - WebSiteSlotResource result = await collection.GetAsync(slot); + WebSiteData data = new WebSiteData(new AzureLocation("East US")) + { + AppServicePlanId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Web/serverfarms/DefaultAsp"), + Kind = "app", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, slot, data); + WebSiteSlotResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +111,7 @@ public async Task Get_GetWebAppSlot() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWebAppSlot() + public async Task Get_GetWebAppSlot() { // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebAppSlot.json // this example is just showing the usage of "WebApps_GetSlot" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +134,21 @@ public async Task Exists_GetWebAppSlot() // invoke the operation string slot = "staging"; - bool result = await collection.ExistsAsync(slot); + WebSiteSlotResource result = await collection.GetAsync(slot); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWebAppSlot() + public async Task GetAll_ListWebAppSlots() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebAppSlot.json - // this example is just showing the usage of "WebApps_GetSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/ListWebAppSlots.json + // this example is just showing the usage of "WebApps_ListSlots" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +166,25 @@ public async Task GetIfExists_GetWebAppSlot() // get the collection of this WebSiteSlotResource WebSiteSlotCollection collection = webSite.GetWebSiteSlots(); - // invoke the operation - string slot = "staging"; - NullableResponse response = await collection.GetIfExistsAsync(slot); - WebSiteSlotResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (WebSiteSlotResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - WebSiteData resourceData = result.Data; + WebSiteData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CloneWebAppSlot() + public async Task Exists_GetWebAppSlot() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CloneWebAppSlot.json - // this example is just showing the usage of "WebApps_CreateOrUpdateSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebAppSlot.json + // this example is just showing the usage of "WebApps_GetSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,40 +204,17 @@ public async Task CreateOrUpdate_CloneWebAppSlot() // invoke the operation string slot = "staging"; - WebSiteData data = new WebSiteData(new AzureLocation("East US")) - { - CloningInfo = new CloningInfo(new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg456/providers/Microsoft.Web/sites/srcsiteg478/slot/qa")) - { - CanOverwrite = false, - CloneCustomHostNames = true, - CloneSourceControl = true, - SourceWebAppLocation = new AzureLocation("West Europe"), - HostingEnvironment = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg456/providers/Microsoft.Web/hostingenvironments/aseforsites", - AppSettingsOverrides = -{ -["Setting1"] = "NewValue1", -["Setting3"] = "NewValue5", -}, - ConfigureLoadBalancing = false, - }, - Kind = "app", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, slot, data); - WebSiteSlotResource result = lro.Value; + bool result = await collection.ExistsAsync(slot); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWebAppSlot() + public async Task GetIfExists_GetWebAppSlot() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/CreateOrUpdateWebAppSlot.json - // this example is just showing the usage of "WebApps_CreateOrUpdateSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetWebAppSlot.json + // this example is just showing the usage of "WebApps_GetSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,19 +234,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWebAppSlot() // invoke the operation string slot = "staging"; - WebSiteData data = new WebSiteData(new AzureLocation("East US")) - { - AppServicePlanId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Web/serverfarms/DefaultAsp"), - Kind = "app", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, slot, data); - WebSiteSlotResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(slot); + WebSiteSlotResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotConfigAppSettingCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotConfigAppSettingCollection.cs index 0d9e700a9a887..27e6190b2dc76 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotConfigAppSettingCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotConfigAppSettingCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WebSiteSlotConfigAppSettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAzureKeyVaultReferencesForAppSettingsForSlot() + public async Task Get_GetAzureKeyVaultSlotAppSettingReference() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetKeyVaultReferencesForAppSettingsSlot.json - // this example is just showing the usage of "WebApps_GetAppSettingsKeyVaultReferencesSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetKeyVaultReferencesForAppSettingSlot.json + // this example is just showing the usage of "WebApps_GetAppSettingKeyVaultReferenceSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetAzureKeyVaultReferencesForAppSettingsForSlot() // get the collection of this WebSiteSlotConfigAppSettingResource WebSiteSlotConfigAppSettingCollection collection = webSiteSlot.GetWebSiteSlotConfigAppSettings(); - // invoke the operation and iterate over the result - await foreach (WebSiteSlotConfigAppSettingResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiKeyVaultReferenceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string appSettingKey = "setting"; + WebSiteSlotConfigAppSettingResource result = await collection.GetAsync(appSettingKey); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiKeyVaultReferenceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureKeyVaultSlotAppSettingReference() + public async Task GetAll_GetAzureKeyVaultReferencesForAppSettingsForSlot() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetKeyVaultReferencesForAppSettingSlot.json - // this example is just showing the usage of "WebApps_GetAppSettingKeyVaultReferenceSlot" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/GetKeyVaultReferencesForAppSettingsSlot.json + // this example is just showing the usage of "WebApps_GetAppSettingsKeyVaultReferencesSlot" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetAzureKeyVaultSlotAppSettingReference() // get the collection of this WebSiteSlotConfigAppSettingResource WebSiteSlotConfigAppSettingCollection collection = webSiteSlot.GetWebSiteSlotConfigAppSettings(); - // invoke the operation - string appSettingKey = "setting"; - WebSiteSlotConfigAppSettingResource result = await collection.GetAsync(appSettingKey); + // invoke the operation and iterate over the result + await foreach (WebSiteSlotConfigAppSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiKeyVaultReferenceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiKeyVaultReferenceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotFtpPublishingCredentialsPolicyResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotFtpPublishingCredentialsPolicyResource.cs index 6e9ee6f0ded50..2ed3940a6e8a0 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotFtpPublishingCredentialsPolicyResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotFtpPublishingCredentialsPolicyResource.cs @@ -68,7 +68,7 @@ public async Task CreateOrUpdate_UpdateFTPAllowed() WebSiteSlotFtpPublishingCredentialsPolicyResource webSiteSlotFtpPublishingCredentialsPolicy = client.GetWebSiteSlotFtpPublishingCredentialsPolicyResource(webSiteSlotFtpPublishingCredentialsPolicyResourceId); // invoke the operation - CsmPublishingCredentialsPoliciesEntityData data = new CsmPublishingCredentialsPoliciesEntityData() + CsmPublishingCredentialsPoliciesEntityData data = new CsmPublishingCredentialsPoliciesEntityData { Allow = true, }; diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotResource.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotResource.cs index 61174a964fde7..bba65ee691723 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotResource.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WebSiteSlotResource.cs @@ -97,7 +97,7 @@ public async Task Update_UpdateWebAppSlot() WebSiteSlotResource webSiteSlot = client.GetWebSiteSlotResource(webSiteSlotResourceId); // invoke the operation - SitePatchInfo info = new SitePatchInfo() + SitePatchInfo info = new SitePatchInfo { ServerFarmId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Web/serverfarms/DefaultAsp"), }; @@ -515,59 +515,65 @@ public async Task DeployWorkflowArtifactsSlot_DeploysWorkflowArtifactsSlot() WebSiteSlotResource webSiteSlot = client.GetWebSiteSlotResource(webSiteSlotResourceId); // invoke the operation - WorkflowArtifacts workflowArtifacts = new WorkflowArtifacts() + WorkflowArtifacts workflowArtifacts = new WorkflowArtifacts { - AppSettings = BinaryData.FromObjectAsJson(new Dictionary() + AppSettings = BinaryData.FromObjectAsJson(new { - ["eventHub_connectionString"] = "Endpoint=sb://example.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=EXAMPLE1a2b3c4d5e6fEXAMPLE=" + eventHub_connectionString = "Endpoint=sb://example.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=EXAMPLE1a2b3c4d5e6fEXAMPLE=", }), Files = { -["connections.json"] = BinaryData.FromObjectAsJson(new Dictionary() +["connections.json"] = BinaryData.FromObjectAsJson(new { -["managedApiConnections"] = new Dictionary() +managedApiConnections = new object(), +serviceProviderConnections = new { -}, -["serviceProviderConnections"] = new Dictionary() -{ -["eventHub"] = new Dictionary() +eventHub = new { -["displayName"] = "example1", -["parameterValues"] = new Dictionary() +displayName = "example1", +parameterValues = new { -["connectionString"] = "@appsetting('eventHub_connectionString')"}, -["serviceProvider"] = new Dictionary() +connectionString = "@appsetting('eventHub_connectionString')", +}, +serviceProvider = new { -["id"] = "/serviceProviders/eventHub"}}}}), -["test1/workflow.json"] = BinaryData.FromObjectAsJson(new Dictionary() +id = "/serviceProviders/eventHub", +}, +}, +}, +}), +["test1/workflow.json"] = BinaryData.FromObjectAsJson(new { -["definition"] = new Dictionary() +definition = new Dictionary { ["$schema"] = "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", -["actions"] = new Dictionary() -{ -}, +["actions"] = new object(), ["contentVersion"] = "1.0.0.0", -["outputs"] = new Dictionary() +["outputs"] = new object(), +["triggers"] = new { -}, -["triggers"] = new Dictionary() -{ -["When_events_are_available_in_Event_hub"] = new Dictionary() +When_events_are_available_in_Event_hub = new { -["type"] = "ServiceProvider", -["inputs"] = new Dictionary() +type = "ServiceProvider", +inputs = new { -["parameters"] = new Dictionary() +parameters = new { -["eventHubName"] = "test123"}, -["serviceProviderConfiguration"] = new Dictionary() +eventHubName = "test123", +}, +serviceProviderConfiguration = new { -["operationId"] = "receiveEvents", -["connectionName"] = "eventHub", -["serviceProviderId"] = "/serviceProviders/eventHub"}}, -["splitOn"] = "@triggerOutputs()?['body']"}}}, -["kind"] = "Stateful"}), +operationId = "receiveEvents", +connectionName = "eventHub", +serviceProviderId = "/serviceProviders/eventHub", +}, +}, +splitOn = "@triggerOutputs()?['body']", +}, +} +}, +kind = "Stateful", +}) }, }; await webSiteSlot.DeployWorkflowArtifactsSlotAsync(workflowArtifacts: workflowArtifacts); diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionCollection.cs index 3b58455a06c37..496134b8c778a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkflowRunActionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAWorkflowRunActions() + public async Task Get_GetAWorkflowRunAction() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActions_List.json - // this example is just showing the usage of "WorkflowRunActions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActions_Get.json + // this example is just showing the usage of "WorkflowRunActions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListAWorkflowRunActions() // get the collection of this WorkflowRunActionResource WorkflowRunActionCollection collection = workflowRun.GetWorkflowRunActions(); - // invoke the operation and iterate over the result - await foreach (WorkflowRunActionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowRunActionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string actionName = "HTTP"; + WorkflowRunActionResource result = await collection.GetAsync(actionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowRunActionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkflowRunAction() + public async Task GetAll_ListAWorkflowRunActions() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActions_Get.json - // this example is just showing the usage of "WorkflowRunActions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActions_List.json + // this example is just showing the usage of "WorkflowRunActions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetAWorkflowRunAction() // get the collection of this WorkflowRunActionResource WorkflowRunActionCollection collection = workflowRun.GetWorkflowRunActions(); - // invoke the operation - string actionName = "HTTP"; - WorkflowRunActionResource result = await collection.GetAsync(actionName); + // invoke the operation and iterate over the result + await foreach (WorkflowRunActionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowRunActionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowRunActionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionRepetitionCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionRepetitionCollection.cs index a3d86974f7796..b45d9f04fc644 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionRepetitionCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionRepetitionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkflowRunActionRepetitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRepetitions() + public async Task Get_GetARepetition() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionRepetitions_List.json - // this example is just showing the usage of "WorkflowRunActionRepetitions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionRepetitions_Get.json + // this example is just showing the usage of "WorkflowRunActionRepetitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_ListRepetitions() // get the collection of this WorkflowRunActionRepetitionResource WorkflowRunActionRepetitionCollection collection = workflowRunAction.GetWorkflowRunActionRepetitions(); - // invoke the operation and iterate over the result - await foreach (WorkflowRunActionRepetitionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowRunActionRepetitionDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string repetitionName = "000001"; + WorkflowRunActionRepetitionResource result = await collection.GetAsync(repetitionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowRunActionRepetitionDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARepetition() + public async Task GetAll_ListRepetitions() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionRepetitions_Get.json - // this example is just showing the usage of "WorkflowRunActionRepetitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionRepetitions_List.json + // this example is just showing the usage of "WorkflowRunActionRepetitions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +78,17 @@ public async Task Get_GetARepetition() // get the collection of this WorkflowRunActionRepetitionResource WorkflowRunActionRepetitionCollection collection = workflowRunAction.GetWorkflowRunActionRepetitions(); - // invoke the operation - string repetitionName = "000001"; - WorkflowRunActionRepetitionResource result = await collection.GetAsync(repetitionName); + // invoke the operation and iterate over the result + await foreach (WorkflowRunActionRepetitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowRunActionRepetitionDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowRunActionRepetitionDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionScopeRepetitionCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionScopeRepetitionCollection.cs index 797cc2449ec01..849199fa3ab9d 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionScopeRepetitionCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunActionScopeRepetitionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkflowRunActionScopeRepetitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheScopedRepetitions() + public async Task Get_GetAScopedRepetition() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionScopeRepetitions_List.json - // this example is just showing the usage of "WorkflowRunActionScopeRepetitions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionScopeRepetitions_Get.json + // this example is just showing the usage of "WorkflowRunActionScopeRepetitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_ListTheScopedRepetitions() // get the collection of this WorkflowRunActionScopeRepetitionResource WorkflowRunActionScopeRepetitionCollection collection = workflowRunAction.GetWorkflowRunActionScopeRepetitions(); - // invoke the operation and iterate over the result - await foreach (WorkflowRunActionScopeRepetitionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowRunActionRepetitionDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string repetitionName = "000000"; + WorkflowRunActionScopeRepetitionResource result = await collection.GetAsync(repetitionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowRunActionRepetitionDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAScopedRepetition() + public async Task GetAll_ListTheScopedRepetitions() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionScopeRepetitions_Get.json - // this example is just showing the usage of "WorkflowRunActionScopeRepetitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRunActionScopeRepetitions_List.json + // this example is just showing the usage of "WorkflowRunActionScopeRepetitions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +78,17 @@ public async Task Get_GetAScopedRepetition() // get the collection of this WorkflowRunActionScopeRepetitionResource WorkflowRunActionScopeRepetitionCollection collection = workflowRunAction.GetWorkflowRunActionScopeRepetitions(); - // invoke the operation - string repetitionName = "000000"; - WorkflowRunActionScopeRepetitionResource result = await collection.GetAsync(repetitionName); + // invoke the operation and iterate over the result + await foreach (WorkflowRunActionScopeRepetitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowRunActionRepetitionDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowRunActionRepetitionDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunCollection.cs index 3cb17ea0a383f..f17b31d48690c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowRunCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkflowRunCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkflowRuns() + public async Task Get_GetARunForAWorkflow() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRuns_List.json - // this example is just showing the usage of "WorkflowRuns_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRuns_Get.json + // this example is just showing the usage of "WorkflowRuns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListWorkflowRuns() string workflowName = "test-workflow"; WorkflowRunCollection collection = webSite.GetWorkflowRuns(workflowName); - // invoke the operation and iterate over the result - await foreach (WorkflowRunResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowRunData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string runName = "08586676746934337772206998657CU22"; + WorkflowRunResource result = await collection.GetAsync(runName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowRunData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARunForAWorkflow() + public async Task GetAll_ListWorkflowRuns() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRuns_Get.json - // this example is just showing the usage of "WorkflowRuns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowRuns_List.json + // this example is just showing the usage of "WorkflowRuns_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetARunForAWorkflow() string workflowName = "test-workflow"; WorkflowRunCollection collection = webSite.GetWorkflowRuns(workflowName); - // invoke the operation - string runName = "08586676746934337772206998657CU22"; - WorkflowRunResource result = await collection.GetAsync(runName); + // invoke the operation and iterate over the result + await foreach (WorkflowRunResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowRunData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowRunData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowTriggerCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowTriggerCollection.cs index 2e181663ad523..66268d157c00a 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowTriggerCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowTriggerCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkflowTriggerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkflowTriggers() + public async Task Get_GetAWorkflowTrigger() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowTriggers_List.json - // this example is just showing the usage of "WorkflowTriggers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowTriggers_Get.json + // this example is just showing the usage of "WorkflowTriggers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListWorkflowTriggers() string workflowName = "test-workflow"; WorkflowTriggerCollection collection = webSite.GetWorkflowTriggers(workflowName); - // invoke the operation and iterate over the result - await foreach (WorkflowTriggerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowTriggerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string triggerName = "manual"; + WorkflowTriggerResource result = await collection.GetAsync(triggerName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkflowTrigger() + public async Task GetAll_ListWorkflowTriggers() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowTriggers_Get.json - // this example is just showing the usage of "WorkflowTriggers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowTriggers_List.json + // this example is just showing the usage of "WorkflowTriggers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetAWorkflowTrigger() string workflowName = "test-workflow"; WorkflowTriggerCollection collection = webSite.GetWorkflowTriggers(workflowName); - // invoke the operation - string triggerName = "manual"; - WorkflowTriggerResource result = await collection.GetAsync(triggerName); + // invoke the operation and iterate over the result + await foreach (WorkflowTriggerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowTriggerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowTriggerHistoryCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowTriggerHistoryCollection.cs index d4053a269375b..1b17682ee0d7c 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowTriggerHistoryCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowTriggerHistoryCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkflowTriggerHistoryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAWorkflowTriggerHistory() + public async Task Get_GetAWorkflowTriggerHistory() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowTriggerHistories_List.json - // this example is just showing the usage of "WorkflowTriggerHistories_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowTriggerHistories_Get.json + // this example is just showing the usage of "WorkflowTriggerHistories_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListAWorkflowTriggerHistory() // get the collection of this WorkflowTriggerHistoryResource WorkflowTriggerHistoryCollection collection = workflowTrigger.GetWorkflowTriggerHistories(); - // invoke the operation and iterate over the result - await foreach (WorkflowTriggerHistoryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowTriggerHistoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string historyName = "08586676746934337772206998657CU22"; + WorkflowTriggerHistoryResource result = await collection.GetAsync(historyName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowTriggerHistoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkflowTriggerHistory() + public async Task GetAll_ListAWorkflowTriggerHistory() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowTriggerHistories_Get.json - // this example is just showing the usage of "WorkflowTriggerHistories_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowTriggerHistories_List.json + // this example is just showing the usage of "WorkflowTriggerHistories_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetAWorkflowTriggerHistory() // get the collection of this WorkflowTriggerHistoryResource WorkflowTriggerHistoryCollection collection = workflowTrigger.GetWorkflowTriggerHistories(); - // invoke the operation - string historyName = "08586676746934337772206998657CU22"; - WorkflowTriggerHistoryResource result = await collection.GetAsync(historyName); + // invoke the operation and iterate over the result + await foreach (WorkflowTriggerHistoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowTriggerHistoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowTriggerHistoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowVersionCollection.cs b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowVersionCollection.cs index 0159a7a4da3fc..937958f86d633 100644 --- a/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowVersionCollection.cs +++ b/sdk/websites/Azure.ResourceManager.AppService/samples/Generated/Samples/Sample_WorkflowVersionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkflowVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAWorkflowsVersions() + public async Task Get_GetAWorkflowVersion() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowVersions_List.json - // this example is just showing the usage of "WorkflowVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowVersions_Get.json + // this example is just showing the usage of "WorkflowVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListAWorkflowsVersions() string workflowName = "test-workflow"; WorkflowVersionCollection collection = webSite.GetWorkflowVersions(workflowName); - // invoke the operation and iterate over the result - await foreach (WorkflowVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string versionId = "08586676824806722526"; + WorkflowVersionResource result = await collection.GetAsync(versionId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkflowVersion() + public async Task GetAll_ListAWorkflowsVersions() { - // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowVersions_Get.json - // this example is just showing the usage of "WorkflowVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/web/resource-manager/Microsoft.Web/stable/2024-04-01/examples/WorkflowVersions_List.json + // this example is just showing the usage of "WorkflowVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetAWorkflowVersion() string workflowName = "test-workflow"; WorkflowVersionCollection collection = webSite.GetWorkflowVersions(workflowName); - // invoke the operation - string versionId = "08586676824806722526"; - WorkflowVersionResource result = await collection.GetAsync(versionId); + // invoke the operation and iterate over the result + await foreach (WorkflowVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkflowVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkflowVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/workloadmonitor/Azure.ResourceManager.WorkloadMonitor/samples/Generated/Samples/Sample_HealthMonitorCollection.cs b/sdk/workloadmonitor/Azure.ResourceManager.WorkloadMonitor/samples/Generated/Samples/Sample_HealthMonitorCollection.cs index a1d9913988f1f..7c6ea73afa502 100644 --- a/sdk/workloadmonitor/Azure.ResourceManager.WorkloadMonitor/samples/Generated/Samples/Sample_HealthMonitorCollection.cs +++ b/sdk/workloadmonitor/Azure.ResourceManager.WorkloadMonitor/samples/Generated/Samples/Sample_HealthMonitorCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HealthMonitorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetMonitorListWithDefaultValues() + public async Task Get_GetMonitorWithDefaultValues() { - // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorList_GetDefault.json - // this example is just showing the usage of "HealthMonitors_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/Monitor_GetDefault.json + // this example is just showing the usage of "HealthMonitors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_GetMonitorListWithDefaultValues() string resourceName = "linuxEUS"; HealthMonitorCollection collection = resourceGroupResource.GetHealthMonitors(providerName, resourceCollectionName, resourceName); - // invoke the operation and iterate over the result - await foreach (HealthMonitorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthMonitorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string monitorId = "logical-disks|C@3A|free-space"; + HealthMonitorResource result = await collection.GetAsync(monitorId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthMonitorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetMonitorListWithExpandedValues() + public async Task Get_GetMonitorWithExpandedValues() { - // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorList_GetExpanded.json - // this example is just showing the usage of "HealthMonitors_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/Monitor_GetExpanded.json + // this example is just showing the usage of "HealthMonitors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,25 +77,23 @@ public async Task GetAll_GetMonitorListWithExpandedValues() string resourceName = "linuxEUS"; HealthMonitorCollection collection = resourceGroupResource.GetHealthMonitors(providerName, resourceCollectionName, resourceName); - // invoke the operation and iterate over the result - string expand = "evidence,configuration"; - await foreach (HealthMonitorResource item in collection.GetAllAsync(expand: expand)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthMonitorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string monitorId = "logical-disks|C@3A|free-space"; + string expand = "evidence"; + HealthMonitorResource result = await collection.GetAsync(monitorId, expand: expand); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthMonitorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetMonitorListWithFilteredValues() + public async Task GetAll_GetMonitorListWithDefaultValues() { - // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorList_GetFiltered.json + // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorList_GetDefault.json // this example is just showing the usage of "HealthMonitors_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -119,8 +115,7 @@ public async Task GetAll_GetMonitorListWithFilteredValues() HealthMonitorCollection collection = resourceGroupResource.GetHealthMonitors(providerName, resourceCollectionName, resourceName); // invoke the operation and iterate over the result - string filter = "monitorName eq 'root'"; - await foreach (HealthMonitorResource item in collection.GetAllAsync(filter: filter)) + await foreach (HealthMonitorResource item in collection.GetAllAsync()) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -134,10 +129,10 @@ public async Task GetAll_GetMonitorListWithFilteredValues() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMonitorWithDefaultValues() + public async Task GetAll_GetMonitorListWithExpandedValues() { - // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/Monitor_GetDefault.json - // this example is just showing the usage of "HealthMonitors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorList_GetExpanded.json + // this example is just showing the usage of "HealthMonitors_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -157,23 +152,26 @@ public async Task Get_GetMonitorWithDefaultValues() string resourceName = "linuxEUS"; HealthMonitorCollection collection = resourceGroupResource.GetHealthMonitors(providerName, resourceCollectionName, resourceName); - // invoke the operation - string monitorId = "logical-disks|C@3A|free-space"; - HealthMonitorResource result = await collection.GetAsync(monitorId); + // invoke the operation and iterate over the result + string expand = "evidence,configuration"; + await foreach (HealthMonitorResource item in collection.GetAllAsync(expand: expand)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthMonitorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthMonitorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMonitorWithDefaultValues() + public async Task GetAll_GetMonitorListWithFilteredValues() { - // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/Monitor_GetDefault.json - // this example is just showing the usage of "HealthMonitors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorList_GetFiltered.json + // this example is just showing the usage of "HealthMonitors_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,16 +191,23 @@ public async Task Exists_GetMonitorWithDefaultValues() string resourceName = "linuxEUS"; HealthMonitorCollection collection = resourceGroupResource.GetHealthMonitors(providerName, resourceCollectionName, resourceName); - // invoke the operation - string monitorId = "logical-disks|C@3A|free-space"; - bool result = await collection.ExistsAsync(monitorId); + // invoke the operation and iterate over the result + string filter = "monitorName eq 'root'"; + await foreach (HealthMonitorResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthMonitorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMonitorWithDefaultValues() + public async Task Exists_GetMonitorWithDefaultValues() { // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/Monitor_GetDefault.json // this example is just showing the usage of "HealthMonitors_Get" operation, for the dependent resources, they will have to be created separately. @@ -227,26 +232,14 @@ public async Task GetIfExists_GetMonitorWithDefaultValues() // invoke the operation string monitorId = "logical-disks|C@3A|free-space"; - NullableResponse response = await collection.GetIfExistsAsync(monitorId); - HealthMonitorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(monitorId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthMonitorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMonitorWithExpandedValues() + public async Task Exists_GetMonitorWithExpandedValues() { // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/Monitor_GetExpanded.json // this example is just showing the usage of "HealthMonitors_Get" operation, for the dependent resources, they will have to be created separately. @@ -272,20 +265,16 @@ public async Task Get_GetMonitorWithExpandedValues() // invoke the operation string monitorId = "logical-disks|C@3A|free-space"; string expand = "evidence"; - HealthMonitorResource result = await collection.GetAsync(monitorId, expand: expand); + bool result = await collection.ExistsAsync(monitorId, expand: expand); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthMonitorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMonitorWithExpandedValues() + public async Task GetIfExists_GetMonitorWithDefaultValues() { - // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/Monitor_GetExpanded.json + // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/Monitor_GetDefault.json // this example is just showing the usage of "HealthMonitors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -308,10 +297,21 @@ public async Task Exists_GetMonitorWithExpandedValues() // invoke the operation string monitorId = "logical-disks|C@3A|free-space"; - string expand = "evidence"; - bool result = await collection.ExistsAsync(monitorId, expand: expand); + NullableResponse response = await collection.GetIfExistsAsync(monitorId); + HealthMonitorResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthMonitorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/workloadmonitor/Azure.ResourceManager.WorkloadMonitor/samples/Generated/Samples/Sample_HealthMonitorStateChangeCollection.cs b/sdk/workloadmonitor/Azure.ResourceManager.WorkloadMonitor/samples/Generated/Samples/Sample_HealthMonitorStateChangeCollection.cs index 76375f1882760..4890c3ba7e5bf 100644 --- a/sdk/workloadmonitor/Azure.ResourceManager.WorkloadMonitor/samples/Generated/Samples/Sample_HealthMonitorStateChangeCollection.cs +++ b/sdk/workloadmonitor/Azure.ResourceManager.WorkloadMonitor/samples/Generated/Samples/Sample_HealthMonitorStateChangeCollection.cs @@ -15,6 +15,81 @@ namespace Azure.ResourceManager.WorkloadMonitor.Samples { public partial class Sample_HealthMonitorStateChangeCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetMonitorStateChangeWithDefaultValues() + { + // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorStateChange_GetDefault.json + // this example is just showing the usage of "HealthMonitors_GetStateChange" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HealthMonitorResource created on azure + // for more information of creating HealthMonitorResource, please refer to the document of HealthMonitorResource + string subscriptionId = "bc27da3b-3ba2-4e00-a6ec-1fde64aa1e21"; + string resourceGroupName = "tugamidiAlerts"; + string providerName = "Microsoft.Compute"; + string resourceCollectionName = "virtualMachines"; + string resourceName = "linuxEUS"; + string monitorId = "logical-disks|C@3A"; + ResourceIdentifier healthMonitorResourceId = HealthMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, providerName, resourceCollectionName, resourceName, monitorId); + HealthMonitorResource healthMonitor = client.GetHealthMonitorResource(healthMonitorResourceId); + + // get the collection of this HealthMonitorStateChangeResource + HealthMonitorStateChangeCollection collection = healthMonitor.GetHealthMonitorStateChanges(); + + // invoke the operation + string timestampUnix = "1584316800"; + HealthMonitorStateChangeResource result = await collection.GetAsync(timestampUnix); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthMonitorStateChangeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetMonitorStateChangeWithExpandedValues() + { + // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorStateChange_GetExpanded.json + // this example is just showing the usage of "HealthMonitors_GetStateChange" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HealthMonitorResource created on azure + // for more information of creating HealthMonitorResource, please refer to the document of HealthMonitorResource + string subscriptionId = "bc27da3b-3ba2-4e00-a6ec-1fde64aa1e21"; + string resourceGroupName = "tugamidiAlerts"; + string providerName = "Microsoft.Compute"; + string resourceCollectionName = "virtualMachines"; + string resourceName = "linuxEUS"; + string monitorId = "logical-disks|C@3A"; + ResourceIdentifier healthMonitorResourceId = HealthMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, providerName, resourceCollectionName, resourceName, monitorId); + HealthMonitorResource healthMonitor = client.GetHealthMonitorResource(healthMonitorResourceId); + + // get the collection of this HealthMonitorStateChangeResource + HealthMonitorStateChangeCollection collection = healthMonitor.GetHealthMonitorStateChanges(); + + // invoke the operation + string timestampUnix = "1584316800"; + string expand = "evidence"; + HealthMonitorStateChangeResource result = await collection.GetAsync(timestampUnix, expand: expand); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HealthMonitorStateChangeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_GetMonitorStateChangesWithDefaultValues() @@ -142,7 +217,7 @@ public async Task GetAll_GetMonitorStateChangesWithFilteredValues() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMonitorStateChangeWithDefaultValues() + public async Task Exists_GetMonitorStateChangeWithDefaultValues() { // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorStateChange_GetDefault.json // this example is just showing the usage of "HealthMonitors_GetStateChange" operation, for the dependent resources, they will have to be created separately. @@ -168,20 +243,16 @@ public async Task Get_GetMonitorStateChangeWithDefaultValues() // invoke the operation string timestampUnix = "1584316800"; - HealthMonitorStateChangeResource result = await collection.GetAsync(timestampUnix); + bool result = await collection.ExistsAsync(timestampUnix); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthMonitorStateChangeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMonitorStateChangeWithDefaultValues() + public async Task Exists_GetMonitorStateChangeWithExpandedValues() { - // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorStateChange_GetDefault.json + // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorStateChange_GetExpanded.json // this example is just showing the usage of "HealthMonitors_GetStateChange" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -205,7 +276,8 @@ public async Task Exists_GetMonitorStateChangeWithDefaultValues() // invoke the operation string timestampUnix = "1584316800"; - bool result = await collection.ExistsAsync(timestampUnix); + string expand = "evidence"; + bool result = await collection.ExistsAsync(timestampUnix, expand: expand); Console.WriteLine($"Succeeded: {result}"); } @@ -255,78 +327,6 @@ public async Task GetIfExists_GetMonitorStateChangeWithDefaultValues() } } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetMonitorStateChangeWithExpandedValues() - { - // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorStateChange_GetExpanded.json - // this example is just showing the usage of "HealthMonitors_GetStateChange" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HealthMonitorResource created on azure - // for more information of creating HealthMonitorResource, please refer to the document of HealthMonitorResource - string subscriptionId = "bc27da3b-3ba2-4e00-a6ec-1fde64aa1e21"; - string resourceGroupName = "tugamidiAlerts"; - string providerName = "Microsoft.Compute"; - string resourceCollectionName = "virtualMachines"; - string resourceName = "linuxEUS"; - string monitorId = "logical-disks|C@3A"; - ResourceIdentifier healthMonitorResourceId = HealthMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, providerName, resourceCollectionName, resourceName, monitorId); - HealthMonitorResource healthMonitor = client.GetHealthMonitorResource(healthMonitorResourceId); - - // get the collection of this HealthMonitorStateChangeResource - HealthMonitorStateChangeCollection collection = healthMonitor.GetHealthMonitorStateChanges(); - - // invoke the operation - string timestampUnix = "1584316800"; - string expand = "evidence"; - HealthMonitorStateChangeResource result = await collection.GetAsync(timestampUnix, expand: expand); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HealthMonitorStateChangeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMonitorStateChangeWithExpandedValues() - { - // Generated from example definition: specification/workloadmonitor/resource-manager/Microsoft.WorkloadMonitor/preview/2020-01-13-preview/examples/MonitorStateChange_GetExpanded.json - // this example is just showing the usage of "HealthMonitors_GetStateChange" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HealthMonitorResource created on azure - // for more information of creating HealthMonitorResource, please refer to the document of HealthMonitorResource - string subscriptionId = "bc27da3b-3ba2-4e00-a6ec-1fde64aa1e21"; - string resourceGroupName = "tugamidiAlerts"; - string providerName = "Microsoft.Compute"; - string resourceCollectionName = "virtualMachines"; - string resourceName = "linuxEUS"; - string monitorId = "logical-disks|C@3A"; - ResourceIdentifier healthMonitorResourceId = HealthMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, providerName, resourceCollectionName, resourceName, monitorId); - HealthMonitorResource healthMonitor = client.GetHealthMonitorResource(healthMonitorResourceId); - - // get the collection of this HealthMonitorStateChangeResource - HealthMonitorStateChangeCollection collection = healthMonitor.GetHealthMonitorStateChanges(); - - // invoke the operation - string timestampUnix = "1584316800"; - string expand = "evidence"; - bool result = await collection.ExistsAsync(timestampUnix, expand: expand); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetIfExists_GetMonitorStateChangeWithExpandedValues() diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapApplicationServerInstanceCollection.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapApplicationServerInstanceCollection.cs index c9184587eb29c..05cfb81456627 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapApplicationServerInstanceCollection.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapApplicationServerInstanceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SapApplicationServerInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SAPApplicationServerInstancesGet() + public async Task CreateOrUpdate_CreateSAPApplicationServerInstancesForHASystemWithAvailabilitySet() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Get.json - // this example is just showing the usage of "SAPApplicationServerInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Create_HA_AvSet.json + // this example is just showing the usage of "SAPApplicationServerInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_SAPApplicationServerInstancesGet() // invoke the operation string applicationInstanceName = "app01"; - SapApplicationServerInstanceResource result = await collection.GetAsync(applicationInstanceName); + SapApplicationServerInstanceData data = new SapApplicationServerInstanceData(new AzureLocation("westcentralus")) + { + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationInstanceName, data); + SapApplicationServerInstanceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +56,10 @@ public async Task Get_SAPApplicationServerInstancesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SAPApplicationServerInstancesGet() + public async Task CreateOrUpdate_SAPApplicationServerInstancesCreate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Get.json - // this example is just showing the usage of "SAPApplicationServerInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Create.json + // this example is just showing the usage of "SAPApplicationServerInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,14 +79,23 @@ public async Task Exists_SAPApplicationServerInstancesGet() // invoke the operation string applicationInstanceName = "app01"; - bool result = await collection.ExistsAsync(applicationInstanceName); + SapApplicationServerInstanceData data = new SapApplicationServerInstanceData(new AzureLocation("westcentralus")) + { + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationInstanceName, data); + SapApplicationServerInstanceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapApplicationServerInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SAPApplicationServerInstancesGet() + public async Task Get_SAPApplicationServerInstancesGet() { // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Get.json // this example is just showing the usage of "SAPApplicationServerInstances_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +118,21 @@ public async Task GetIfExists_SAPApplicationServerInstancesGet() // invoke the operation string applicationInstanceName = "app01"; - NullableResponse response = await collection.GetIfExistsAsync(applicationInstanceName); - SapApplicationServerInstanceResource result = response.HasValue ? response.Value : null; + SapApplicationServerInstanceResource result = await collection.GetAsync(applicationInstanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapApplicationServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapApplicationServerInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSAPApplicationServerInstancesForHASystemWithAvailabilitySet() + public async Task GetAll_SAPApplicationServerInstancesList() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Create_HA_AvSet.json - // this example is just showing the usage of "SAPApplicationServerInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_List.json + // this example is just showing the usage of "SAPApplicationServerInstances_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,30 +150,25 @@ public async Task CreateOrUpdate_CreateSAPApplicationServerInstancesForHASystemW // get the collection of this SapApplicationServerInstanceResource SapApplicationServerInstanceCollection collection = sapVirtualInstance.GetSapApplicationServerInstances(); - // invoke the operation - string applicationInstanceName = "app01"; - SapApplicationServerInstanceData data = new SapApplicationServerInstanceData(new AzureLocation("westcentralus")) + // invoke the operation and iterate over the result + await foreach (SapApplicationServerInstanceResource item in collection.GetAllAsync()) { - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationInstanceName, data); - SapApplicationServerInstanceResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapApplicationServerInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapApplicationServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SAPApplicationServerInstancesCreate() + public async Task Exists_SAPApplicationServerInstancesGet() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Create.json - // this example is just showing the usage of "SAPApplicationServerInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Get.json + // this example is just showing the usage of "SAPApplicationServerInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,28 +188,17 @@ public async Task CreateOrUpdate_SAPApplicationServerInstancesCreate() // invoke the operation string applicationInstanceName = "app01"; - SapApplicationServerInstanceData data = new SapApplicationServerInstanceData(new AzureLocation("westcentralus")) - { - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationInstanceName, data); - SapApplicationServerInstanceResource result = lro.Value; + bool result = await collection.ExistsAsync(applicationInstanceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapApplicationServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SAPApplicationServerInstancesList() + public async Task GetIfExists_SAPApplicationServerInstancesGet() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_List.json - // this example is just showing the usage of "SAPApplicationServerInstances_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Get.json + // this example is just showing the usage of "SAPApplicationServerInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,17 +216,23 @@ public async Task GetAll_SAPApplicationServerInstancesList() // get the collection of this SapApplicationServerInstanceResource SapApplicationServerInstanceCollection collection = sapVirtualInstance.GetSapApplicationServerInstances(); - // invoke the operation and iterate over the result - await foreach (SapApplicationServerInstanceResource item in collection.GetAllAsync()) + // invoke the operation + string applicationInstanceName = "app01"; + NullableResponse response = await collection.GetIfExistsAsync(applicationInstanceName); + SapApplicationServerInstanceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SapApplicationServerInstanceData resourceData = item.Data; + SapApplicationServerInstanceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapApplicationServerInstanceResource.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapApplicationServerInstanceResource.cs index 7f008b5b0a9ce..9fcc12da9e36f 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapApplicationServerInstanceResource.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapApplicationServerInstanceResource.cs @@ -50,10 +50,10 @@ public async Task Get_SAPApplicationServerInstancesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SAPApplicationServerInstancesUpdate() + public async Task Delete_SAPApplicationServerInstancesDelete() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Update.json - // this example is just showing the usage of "SAPApplicationServerInstances_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Delete.json + // this example is just showing the usage of "SAPApplicationServerInstances_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,29 +70,18 @@ public async Task Update_SAPApplicationServerInstancesUpdate() SapApplicationServerInstanceResource sapApplicationServerInstance = client.GetSapApplicationServerInstanceResource(sapApplicationServerInstanceResourceId); // invoke the operation - SapApplicationServerInstancePatch patch = new SapApplicationServerInstancePatch() - { - Tags = -{ -["tag1"] = "value1", -}, - }; - ArmOperation lro = await sapApplicationServerInstance.UpdateAsync(WaitUntil.Completed, patch); - SapApplicationServerInstanceResource result = lro.Value; + ArmOperation lro = await sapApplicationServerInstance.DeleteAsync(WaitUntil.Completed); + OperationStatusResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapApplicationServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SAPApplicationServerInstancesDelete() + public async Task Update_SAPApplicationServerInstancesUpdate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Delete.json - // this example is just showing the usage of "SAPApplicationServerInstances_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPApplicationServerInstances_Update.json + // this example is just showing the usage of "SAPApplicationServerInstances_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,10 +98,21 @@ public async Task Delete_SAPApplicationServerInstancesDelete() SapApplicationServerInstanceResource sapApplicationServerInstance = client.GetSapApplicationServerInstanceResource(sapApplicationServerInstanceResourceId); // invoke the operation - ArmOperation lro = await sapApplicationServerInstance.DeleteAsync(WaitUntil.Completed); - OperationStatusResult result = lro.Value; + SapApplicationServerInstancePatch patch = new SapApplicationServerInstancePatch + { + Tags = +{ +["tag1"] = "value1" +}, + }; + ArmOperation lro = await sapApplicationServerInstance.UpdateAsync(WaitUntil.Completed, patch); + SapApplicationServerInstanceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapApplicationServerInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -165,7 +165,7 @@ public async Task StopInstance_StopTheSAPApplicationServerInstance() SapApplicationServerInstanceResource sapApplicationServerInstance = client.GetSapApplicationServerInstanceResource(sapApplicationServerInstanceResourceId); // invoke the operation - SapStopContent content = new SapStopContent() + SapStopContent content = new SapStopContent { SoftStopTimeoutSeconds = 0L, }; diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapCentralServerInstanceCollection.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapCentralServerInstanceCollection.cs index d99c9f4b99392..17e79f32cdb8d 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapCentralServerInstanceCollection.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapCentralServerInstanceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SapCentralServerInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SAPCentralInstancesGet() + public async Task CreateOrUpdate_CreateSAPCentralInstancesForHASystemWithAvailabilitySet() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Get.json - // this example is just showing the usage of "SAPCentralInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Create_HA_AvSet.json + // this example is just showing the usage of "SAPCentralInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_SAPCentralInstancesGet() // invoke the operation string centralInstanceName = "centralServer"; - SapCentralServerInstanceResource result = await collection.GetAsync(centralInstanceName); + SapCentralServerInstanceData data = new SapCentralServerInstanceData(new AzureLocation("westcentralus")) + { + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, centralInstanceName, data); + SapCentralServerInstanceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +56,10 @@ public async Task Get_SAPCentralInstancesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SAPCentralInstancesGet() + public async Task CreateOrUpdate_SAPCentralInstancesCreate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Get.json - // this example is just showing the usage of "SAPCentralInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Create.json + // this example is just showing the usage of "SAPCentralInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,14 +79,23 @@ public async Task Exists_SAPCentralInstancesGet() // invoke the operation string centralInstanceName = "centralServer"; - bool result = await collection.ExistsAsync(centralInstanceName); + SapCentralServerInstanceData data = new SapCentralServerInstanceData(new AzureLocation("westcentralus")) + { + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, centralInstanceName, data); + SapCentralServerInstanceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapCentralServerInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SAPCentralInstancesGet() + public async Task Get_SAPCentralInstancesGet() { // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Get.json // this example is just showing the usage of "SAPCentralInstances_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +118,21 @@ public async Task GetIfExists_SAPCentralInstancesGet() // invoke the operation string centralInstanceName = "centralServer"; - NullableResponse response = await collection.GetIfExistsAsync(centralInstanceName); - SapCentralServerInstanceResource result = response.HasValue ? response.Value : null; + SapCentralServerInstanceResource result = await collection.GetAsync(centralInstanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapCentralServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapCentralServerInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSAPCentralInstancesForHASystemWithAvailabilitySet() + public async Task GetAll_SAPCentralInstancesList() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Create_HA_AvSet.json - // this example is just showing the usage of "SAPCentralInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_List.json + // this example is just showing the usage of "SAPCentralInstances_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,30 +150,25 @@ public async Task CreateOrUpdate_CreateSAPCentralInstancesForHASystemWithAvailab // get the collection of this SapCentralServerInstanceResource SapCentralServerInstanceCollection collection = sapVirtualInstance.GetSapCentralServerInstances(); - // invoke the operation - string centralInstanceName = "centralServer"; - SapCentralServerInstanceData data = new SapCentralServerInstanceData(new AzureLocation("westcentralus")) + // invoke the operation and iterate over the result + await foreach (SapCentralServerInstanceResource item in collection.GetAllAsync()) { - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, centralInstanceName, data); - SapCentralServerInstanceResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapCentralServerInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapCentralServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SAPCentralInstancesCreate() + public async Task Exists_SAPCentralInstancesGet() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Create.json - // this example is just showing the usage of "SAPCentralInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Get.json + // this example is just showing the usage of "SAPCentralInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,28 +188,17 @@ public async Task CreateOrUpdate_SAPCentralInstancesCreate() // invoke the operation string centralInstanceName = "centralServer"; - SapCentralServerInstanceData data = new SapCentralServerInstanceData(new AzureLocation("westcentralus")) - { - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, centralInstanceName, data); - SapCentralServerInstanceResource result = lro.Value; + bool result = await collection.ExistsAsync(centralInstanceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapCentralServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SAPCentralInstancesList() + public async Task GetIfExists_SAPCentralInstancesGet() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_List.json - // this example is just showing the usage of "SAPCentralInstances_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Get.json + // this example is just showing the usage of "SAPCentralInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,17 +216,23 @@ public async Task GetAll_SAPCentralInstancesList() // get the collection of this SapCentralServerInstanceResource SapCentralServerInstanceCollection collection = sapVirtualInstance.GetSapCentralServerInstances(); - // invoke the operation and iterate over the result - await foreach (SapCentralServerInstanceResource item in collection.GetAllAsync()) + // invoke the operation + string centralInstanceName = "centralServer"; + NullableResponse response = await collection.GetIfExistsAsync(centralInstanceName); + SapCentralServerInstanceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SapCentralServerInstanceData resourceData = item.Data; + SapCentralServerInstanceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapCentralServerInstanceResource.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapCentralServerInstanceResource.cs index 3ed772c2a633e..bc0239eed21e0 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapCentralServerInstanceResource.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapCentralServerInstanceResource.cs @@ -50,10 +50,10 @@ public async Task Get_SAPCentralInstancesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SAPCentralInstancesUpdate() + public async Task Delete_SAPCentralInstancesDelete() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Update.json - // this example is just showing the usage of "SAPCentralInstances_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Delete.json + // this example is just showing the usage of "SAPCentralInstances_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,29 +70,18 @@ public async Task Update_SAPCentralInstancesUpdate() SapCentralServerInstanceResource sapCentralServerInstance = client.GetSapCentralServerInstanceResource(sapCentralServerInstanceResourceId); // invoke the operation - SapCentralServerInstancePatch patch = new SapCentralServerInstancePatch() - { - Tags = -{ -["tag1"] = "value1", -}, - }; - ArmOperation lro = await sapCentralServerInstance.UpdateAsync(WaitUntil.Completed, patch); - SapCentralServerInstanceResource result = lro.Value; + ArmOperation lro = await sapCentralServerInstance.DeleteAsync(WaitUntil.Completed); + OperationStatusResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapCentralServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SAPCentralInstancesDelete() + public async Task Update_SAPCentralInstancesUpdate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Delete.json - // this example is just showing the usage of "SAPCentralInstances_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPCentralInstances_Update.json + // this example is just showing the usage of "SAPCentralInstances_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,10 +98,21 @@ public async Task Delete_SAPCentralInstancesDelete() SapCentralServerInstanceResource sapCentralServerInstance = client.GetSapCentralServerInstanceResource(sapCentralServerInstanceResourceId); // invoke the operation - ArmOperation lro = await sapCentralServerInstance.DeleteAsync(WaitUntil.Completed); - OperationStatusResult result = lro.Value; + SapCentralServerInstancePatch patch = new SapCentralServerInstancePatch + { + Tags = +{ +["tag1"] = "value1" +}, + }; + ArmOperation lro = await sapCentralServerInstance.UpdateAsync(WaitUntil.Completed, patch); + SapCentralServerInstanceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapCentralServerInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -165,7 +165,7 @@ public async Task StopInstance_StopTheSAPCentralServicesInstance() SapCentralServerInstanceResource sapCentralServerInstance = client.GetSapCentralServerInstanceResource(sapCentralServerInstanceResourceId); // invoke the operation - SapStopContent content = new SapStopContent() + SapStopContent content = new SapStopContent { SoftStopTimeoutSeconds = 1200L, }; diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapDatabaseInstanceCollection.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapDatabaseInstanceCollection.cs index 5f97503c9c6b4..9f67ffc66d4d8 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapDatabaseInstanceCollection.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapDatabaseInstanceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SapDatabaseInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SAPDatabaseInstancesGet() + public async Task CreateOrUpdate_CreateSAPDatabaseInstancesForHASystemWithAvailabilitySet() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Get.json - // this example is just showing the usage of "SAPDatabaseInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Create_HA_AvSet.json + // this example is just showing the usage of "SAPDatabaseInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_SAPDatabaseInstancesGet() // invoke the operation string databaseInstanceName = "databaseServer"; - SapDatabaseInstanceResource result = await collection.GetAsync(databaseInstanceName); + SapDatabaseInstanceData data = new SapDatabaseInstanceData(new AzureLocation("westcentralus")) + { + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseInstanceName, data); + SapDatabaseInstanceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +56,10 @@ public async Task Get_SAPDatabaseInstancesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SAPDatabaseInstancesGet() + public async Task CreateOrUpdate_SAPDatabaseInstancesCreate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Get.json - // this example is just showing the usage of "SAPDatabaseInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Create.json + // this example is just showing the usage of "SAPDatabaseInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,14 +79,23 @@ public async Task Exists_SAPDatabaseInstancesGet() // invoke the operation string databaseInstanceName = "databaseServer"; - bool result = await collection.ExistsAsync(databaseInstanceName); + SapDatabaseInstanceData data = new SapDatabaseInstanceData(new AzureLocation("westcentralus")) + { + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseInstanceName, data); + SapDatabaseInstanceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDatabaseInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SAPDatabaseInstancesGet() + public async Task Get_SAPDatabaseInstancesGet() { // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Get.json // this example is just showing the usage of "SAPDatabaseInstances_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +118,21 @@ public async Task GetIfExists_SAPDatabaseInstancesGet() // invoke the operation string databaseInstanceName = "databaseServer"; - NullableResponse response = await collection.GetIfExistsAsync(databaseInstanceName); - SapDatabaseInstanceResource result = response.HasValue ? response.Value : null; + SapDatabaseInstanceResource result = await collection.GetAsync(databaseInstanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDatabaseInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDatabaseInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSAPDatabaseInstancesForHASystemWithAvailabilitySet() + public async Task GetAll_SAPDatabaseInstancesList() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Create_HA_AvSet.json - // this example is just showing the usage of "SAPDatabaseInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_List.json + // this example is just showing the usage of "SAPDatabaseInstances_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,30 +150,25 @@ public async Task CreateOrUpdate_CreateSAPDatabaseInstancesForHASystemWithAvaila // get the collection of this SapDatabaseInstanceResource SapDatabaseInstanceCollection collection = sapVirtualInstance.GetSapDatabaseInstances(); - // invoke the operation - string databaseInstanceName = "databaseServer"; - SapDatabaseInstanceData data = new SapDatabaseInstanceData(new AzureLocation("westcentralus")) + // invoke the operation and iterate over the result + await foreach (SapDatabaseInstanceResource item in collection.GetAllAsync()) { - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseInstanceName, data); - SapDatabaseInstanceResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDatabaseInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDatabaseInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SAPDatabaseInstancesCreate() + public async Task Exists_SAPDatabaseInstancesGet() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Create.json - // this example is just showing the usage of "SAPDatabaseInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Get.json + // this example is just showing the usage of "SAPDatabaseInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,28 +188,17 @@ public async Task CreateOrUpdate_SAPDatabaseInstancesCreate() // invoke the operation string databaseInstanceName = "databaseServer"; - SapDatabaseInstanceData data = new SapDatabaseInstanceData(new AzureLocation("westcentralus")) - { - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseInstanceName, data); - SapDatabaseInstanceResource result = lro.Value; + bool result = await collection.ExistsAsync(databaseInstanceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDatabaseInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SAPDatabaseInstancesList() + public async Task GetIfExists_SAPDatabaseInstancesGet() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_List.json - // this example is just showing the usage of "SAPDatabaseInstances_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Get.json + // this example is just showing the usage of "SAPDatabaseInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,17 +216,23 @@ public async Task GetAll_SAPDatabaseInstancesList() // get the collection of this SapDatabaseInstanceResource SapDatabaseInstanceCollection collection = sapVirtualInstance.GetSapDatabaseInstances(); - // invoke the operation and iterate over the result - await foreach (SapDatabaseInstanceResource item in collection.GetAllAsync()) + // invoke the operation + string databaseInstanceName = "databaseServer"; + NullableResponse response = await collection.GetIfExistsAsync(databaseInstanceName); + SapDatabaseInstanceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SapDatabaseInstanceData resourceData = item.Data; + SapDatabaseInstanceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapDatabaseInstanceResource.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapDatabaseInstanceResource.cs index 2eff5302889c1..24d8e32c041a6 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapDatabaseInstanceResource.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapDatabaseInstanceResource.cs @@ -50,10 +50,10 @@ public async Task Get_SAPDatabaseInstancesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SAPDatabaseInstancesUpdate() + public async Task Delete_SAPDatabaseInstancesDelete() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Update.json - // this example is just showing the usage of "SAPDatabaseInstances_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Delete.json + // this example is just showing the usage of "SAPDatabaseInstances_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,29 +70,18 @@ public async Task Update_SAPDatabaseInstancesUpdate() SapDatabaseInstanceResource sapDatabaseInstance = client.GetSapDatabaseInstanceResource(sapDatabaseInstanceResourceId); // invoke the operation - SapDatabaseInstancePatch patch = new SapDatabaseInstancePatch() - { - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await sapDatabaseInstance.UpdateAsync(WaitUntil.Completed, patch); - SapDatabaseInstanceResource result = lro.Value; + ArmOperation lro = await sapDatabaseInstance.DeleteAsync(WaitUntil.Completed); + OperationStatusResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDatabaseInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SAPDatabaseInstancesDelete() + public async Task Update_SAPDatabaseInstancesUpdate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Delete.json - // this example is just showing the usage of "SAPDatabaseInstances_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPDatabaseInstances_Update.json + // this example is just showing the usage of "SAPDatabaseInstances_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,10 +98,21 @@ public async Task Delete_SAPDatabaseInstancesDelete() SapDatabaseInstanceResource sapDatabaseInstance = client.GetSapDatabaseInstanceResource(sapDatabaseInstanceResourceId); // invoke the operation - ArmOperation lro = await sapDatabaseInstance.DeleteAsync(WaitUntil.Completed); - OperationStatusResult result = lro.Value; + SapDatabaseInstancePatch patch = new SapDatabaseInstancePatch + { + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await sapDatabaseInstance.UpdateAsync(WaitUntil.Completed, patch); + SapDatabaseInstanceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDatabaseInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -165,7 +165,7 @@ public async Task StopInstance_StopTheDatabaseInstanceOfTheSAPSystem() SapDatabaseInstanceResource sapDatabaseInstance = client.GetSapDatabaseInstanceResource(sapDatabaseInstanceResourceId); // invoke the operation - SapStopContent content = new SapStopContent() + SapStopContent content = new SapStopContent { SoftStopTimeoutSeconds = 0L, }; diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapLandscapeMonitorResource.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapLandscapeMonitorResource.cs index a9f813d2b4967..d6405f7a9cb14 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapLandscapeMonitorResource.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapLandscapeMonitorResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetPropertiesOfASAPMonitor() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateForSAPLandscapeMonitorDashboard() + public async Task Delete_DeletesSAPMonitor() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/SapLandscapeMonitor_Create.json - // this example is just showing the usage of "SapLandscapeMonitor_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/SapLandscapeMonitor_Delete.json + // this example is just showing the usage of "SapLandscapeMonitor_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,60 +67,17 @@ public async Task CreateOrUpdate_CreateForSAPLandscapeMonitorDashboard() SapLandscapeMonitorResource sapLandscapeMonitor = client.GetSapLandscapeMonitorResource(sapLandscapeMonitorResourceId); // invoke the operation - SapLandscapeMonitorData data = new SapLandscapeMonitorData() - { - Grouping = new SapLandscapeMonitorPropertiesGrouping() - { - Landscape = -{ -new SapLandscapeMonitorSidMapping() -{ -Name = "Prod", -TopSid = -{ -"SID1","SID2" -}, -} -}, - SapApplication = -{ -new SapLandscapeMonitorSidMapping() -{ -Name = "ERP1", -TopSid = -{ -"SID1","SID2" -}, -} -}, - }, - TopMetricsThresholds = -{ -new SapLandscapeMonitorMetricThresholds() -{ -Name = "Instance Availability", -Green = 90, -Yellow = 75, -Red = 50, -} -}, - }; - ArmOperation lro = await sapLandscapeMonitor.CreateOrUpdateAsync(WaitUntil.Completed, data); - SapLandscapeMonitorResource result = lro.Value; + await sapLandscapeMonitor.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapLandscapeMonitorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesSAPMonitor() + public async Task Update_UpdateSAPMonitor() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/SapLandscapeMonitor_Delete.json - // this example is just showing the usage of "SapLandscapeMonitor_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/SapLandscapeMonitor_Update.json + // this example is just showing the usage of "SapLandscapeMonitor_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,17 +93,44 @@ public async Task Delete_DeletesSAPMonitor() SapLandscapeMonitorResource sapLandscapeMonitor = client.GetSapLandscapeMonitorResource(sapLandscapeMonitorResourceId); // invoke the operation - await sapLandscapeMonitor.DeleteAsync(WaitUntil.Completed); + SapLandscapeMonitorData data = new SapLandscapeMonitorData + { + Grouping = new SapLandscapeMonitorPropertiesGrouping + { + Landscape = {new SapLandscapeMonitorSidMapping +{ +Name = "Prod", +TopSid = {"SID1", "SID2"}, +}}, + SapApplication = {new SapLandscapeMonitorSidMapping +{ +Name = "ERP1", +TopSid = {"SID1", "SID2"}, +}}, + }, + TopMetricsThresholds = {new SapLandscapeMonitorMetricThresholds +{ +Name = "Instance Availability", +Green = 90, +Yellow = 75, +Red = 50, +}}, + }; + SapLandscapeMonitorResource result = await sapLandscapeMonitor.UpdateAsync(data); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapLandscapeMonitorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateSAPMonitor() + public async Task CreateOrUpdate_CreateForSAPLandscapeMonitorDashboard() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/SapLandscapeMonitor_Update.json - // this example is just showing the usage of "SapLandscapeMonitor_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/SapLandscapeMonitor_Create.json + // this example is just showing the usage of "SapLandscapeMonitor_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -162,45 +146,31 @@ public async Task Update_UpdateSAPMonitor() SapLandscapeMonitorResource sapLandscapeMonitor = client.GetSapLandscapeMonitorResource(sapLandscapeMonitorResourceId); // invoke the operation - SapLandscapeMonitorData data = new SapLandscapeMonitorData() + SapLandscapeMonitorData data = new SapLandscapeMonitorData { - Grouping = new SapLandscapeMonitorPropertiesGrouping() + Grouping = new SapLandscapeMonitorPropertiesGrouping { - Landscape = -{ -new SapLandscapeMonitorSidMapping() + Landscape = {new SapLandscapeMonitorSidMapping { Name = "Prod", -TopSid = -{ -"SID1","SID2" -}, -} -}, - SapApplication = -{ -new SapLandscapeMonitorSidMapping() +TopSid = {"SID1", "SID2"}, +}}, + SapApplication = {new SapLandscapeMonitorSidMapping { Name = "ERP1", -TopSid = -{ -"SID1","SID2" -}, -} -}, +TopSid = {"SID1", "SID2"}, +}}, }, - TopMetricsThresholds = -{ -new SapLandscapeMonitorMetricThresholds() + TopMetricsThresholds = {new SapLandscapeMonitorMetricThresholds { Name = "Instance Availability", Green = 90, Yellow = 75, Red = 50, -} -}, +}}, }; - SapLandscapeMonitorResource result = await sapLandscapeMonitor.UpdateAsync(data); + ArmOperation lro = await sapLandscapeMonitor.CreateOrUpdateAsync(WaitUntil.Completed, data); + SapLandscapeMonitorResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapMonitorCollection.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapMonitorCollection.cs index e1cfc673490b4..14bde9c485ea0 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapMonitorCollection.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapMonitorCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SapMonitorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllSAPMonitorsInAResourceGroup() + public async Task CreateOrUpdate_CreateASAPMonitor() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/monitors_ListByRG.json - // this example is just showing the usage of "monitors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/monitors_Create.json + // this example is just showing the usage of "monitors_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,35 @@ public async Task GetAll_ListAllSAPMonitorsInAResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "example-rg"; + string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this SapMonitorResource SapMonitorCollection collection = resourceGroupResource.GetSapMonitors(); - // invoke the operation and iterate over the result - await foreach (SapMonitorResource item in collection.GetAllAsync()) + // invoke the operation + string monitorName = "mySapMonitor"; + SapMonitorData data = new SapMonitorData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapMonitorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AppLocation = new AzureLocation("westus"), + RoutingPreference = SapRoutingPreference.RouteAll, + ManagedResourceGroupName = "myManagedRg", + LogAnalyticsWorkspaceArmId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/myWorkspace"), + MonitorSubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + Tags = +{ +["key"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, monitorName, data); + SapMonitorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapMonitorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +98,10 @@ public async Task Get_GetPropertiesOfASAPMonitor() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPropertiesOfASAPMonitor() + public async Task GetAll_ListAllSAPMonitorsInAResourceGroup() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/monitors_Get.json - // this example is just showing the usage of "monitors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/monitors_ListByRG.json + // this example is just showing the usage of "monitors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,23 +111,29 @@ public async Task Exists_GetPropertiesOfASAPMonitor() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; + string resourceGroupName = "example-rg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this SapMonitorResource SapMonitorCollection collection = resourceGroupResource.GetSapMonitors(); - // invoke the operation - string monitorName = "mySapMonitor"; - bool result = await collection.ExistsAsync(monitorName); + // invoke the operation and iterate over the result + await foreach (SapMonitorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapMonitorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPropertiesOfASAPMonitor() + public async Task Exists_GetPropertiesOfASAPMonitor() { // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/monitors_Get.json // this example is just showing the usage of "monitors_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +155,17 @@ public async Task GetIfExists_GetPropertiesOfASAPMonitor() // invoke the operation string monitorName = "mySapMonitor"; - NullableResponse response = await collection.GetIfExistsAsync(monitorName); - SapMonitorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(monitorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapMonitorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASAPMonitor() + public async Task GetIfExists_GetPropertiesOfASAPMonitor() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/monitors_Create.json - // this example is just showing the usage of "monitors_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/monitors_Get.json + // this example is just showing the usage of "monitors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,26 +184,21 @@ public async Task CreateOrUpdate_CreateASAPMonitor() // invoke the operation string monitorName = "mySapMonitor"; - SapMonitorData data = new SapMonitorData(new AzureLocation("westus")) - { - AppLocation = new AzureLocation("westus"), - RoutingPreference = SapRoutingPreference.RouteAll, - ManagedResourceGroupName = "myManagedRg", - LogAnalyticsWorkspaceArmId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.operationalinsights/workspaces/myWorkspace"), - MonitorSubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - Tags = -{ -["key"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, monitorName, data); - SapMonitorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(monitorName); + SapMonitorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapMonitorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapMonitorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapMonitorResource.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapMonitorResource.cs index 68ace281f1940..19577edce648b 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapMonitorResource.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapMonitorResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Workloads.Samples { public partial class Sample_SapMonitorResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSapMonitors_ListAllSAPMonitorsInASubscription() - { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/monitors_List.json - // this example is just showing the usage of "monitors_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SapMonitorResource item in subscriptionResource.GetSapMonitorsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapMonitorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetPropertiesOfASAPMonitor() diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapProviderInstanceCollection.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapProviderInstanceCollection.cs index 88b493e6c0503..367994c981d46 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapProviderInstanceCollection.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapProviderInstanceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SapProviderInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllSAPMonitorsProvidersInASubscription() + public async Task CreateOrUpdate_CreateADb2Provider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_List.json - // this example is just showing the usage of "ProviderInstances_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/Db2ProviderInstances_Create.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,39 @@ public async Task GetAll_ListAllSAPMonitorsProvidersInASubscription() // get the collection of this SapProviderInstanceResource SapProviderInstanceCollection collection = sapMonitor.GetSapProviderInstances(); - // invoke the operation and iterate over the result - await foreach (SapProviderInstanceResource item in collection.GetAllAsync()) + // invoke the operation + string providerInstanceName = "myProviderInstance"; + SapProviderInstanceData data = new SapProviderInstanceData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProviderSettings = new DB2ProviderInstanceProperties + { + Hostname = "hostname", + DBName = "dbName", + DBPort = "dbPort", + DBUsername = "username", + DBPassword = "password", + DBPasswordUri = new Uri(""), + SapSid = "SID", + SslPreference = SapSslPreference.ServerCertificate, + SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPropertiesOfADb2Provider() + public async Task CreateOrUpdate_CreateADb2ProviderWithRootCertificate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/Db2ProviderInstances_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/Db2ProviderInstances_Create_Root_Certificate.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +91,22 @@ public async Task Get_GetPropertiesOfADb2Provider() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceResource result = await collection.GetAsync(providerInstanceName); + SapProviderInstanceData data = new SapProviderInstanceData + { + ProviderSettings = new DB2ProviderInstanceProperties + { + Hostname = "hostname", + DBName = "dbName", + DBPort = "dbPort", + DBUsername = "username", + DBPassword = "password", + DBPasswordUri = new Uri(""), + SapSid = "SID", + SslPreference = SapSslPreference.RootCertificate, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +117,10 @@ public async Task Get_GetPropertiesOfADb2Provider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPropertiesOfADb2Provider() + public async Task CreateOrUpdate_CreateAMsSqlServerProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/Db2ProviderInstances_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/MsSqlServerProviderInstance_Create.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,17 +140,36 @@ public async Task Exists_GetPropertiesOfADb2Provider() // invoke the operation string providerInstanceName = "myProviderInstance"; - bool result = await collection.ExistsAsync(providerInstanceName); + SapProviderInstanceData data = new SapProviderInstanceData + { + ProviderSettings = new MsSqlServerProviderInstanceProperties + { + Hostname = "hostname", + DBPort = "5912", + DBUsername = "user", + DBPassword = "****", + DBPasswordUri = new Uri(""), + SapSid = "sid", + SslPreference = SapSslPreference.ServerCertificate, + SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPropertiesOfADb2Provider() + public async Task CreateOrUpdate_CreateAMsSqlServerProviderWithRootCertificate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/Db2ProviderInstances_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/MsSqlServerProviderInstance_Create_Root_Certificate.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,29 +189,35 @@ public async Task GetIfExists_GetPropertiesOfADb2Provider() // invoke the operation string providerInstanceName = "myProviderInstance"; - NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); - SapProviderInstanceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + SapProviderInstanceData data = new SapProviderInstanceData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProviderSettings = new MsSqlServerProviderInstanceProperties + { + Hostname = "hostname", + DBPort = "5912", + DBUsername = "user", + DBPassword = "****", + DBPasswordUri = new Uri(""), + SapSid = "sid", + SslPreference = SapSslPreference.RootCertificate, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPropertiesOfAMsSqlServerProvider() + public async Task CreateOrUpdate_CreateAOSProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/MsSqlServerProviderInstance_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusOSProviderInstances_Create.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,7 +237,18 @@ public async Task Get_GetPropertiesOfAMsSqlServerProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceResource result = await collection.GetAsync(providerInstanceName); + SapProviderInstanceData data = new SapProviderInstanceData + { + ProviderSettings = new PrometheusOSProviderInstanceProperties + { + PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), + SslPreference = SapSslPreference.ServerCertificate, + SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), + SapSid = "SID", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -194,10 +259,10 @@ public async Task Get_GetPropertiesOfAMsSqlServerProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPropertiesOfAMsSqlServerProvider() + public async Task CreateOrUpdate_CreateAOSProviderWithRootCertificate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/MsSqlServerProviderInstance_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusOSProviderInstances_Create_Root_Certificate.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,17 +282,31 @@ public async Task Exists_GetPropertiesOfAMsSqlServerProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - bool result = await collection.ExistsAsync(providerInstanceName); + SapProviderInstanceData data = new SapProviderInstanceData + { + ProviderSettings = new PrometheusOSProviderInstanceProperties + { + PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), + SslPreference = SapSslPreference.RootCertificate, + SapSid = "SID", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPropertiesOfAMsSqlServerProvider() + public async Task CreateOrUpdate_CreateAPrometheusHaClusterProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/MsSqlServerProviderInstance_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Create.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -247,29 +326,34 @@ public async Task GetIfExists_GetPropertiesOfAMsSqlServerProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); - SapProviderInstanceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + SapProviderInstanceData data = new SapProviderInstanceData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProviderSettings = new PrometheusHAClusterProviderInstanceProperties + { + PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), + Hostname = "hostname", + Sid = "sid", + ClusterName = "clusterName", + SslPreference = SapSslPreference.ServerCertificate, + SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPropertiesOfAOSProvider() + public async Task CreateOrUpdate_CreateAPrometheusHaClusterProviderWithRootCertificate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusOSProviderInstances_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Create_Root_Certificate.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -289,7 +373,19 @@ public async Task Get_GetPropertiesOfAOSProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceResource result = await collection.GetAsync(providerInstanceName); + SapProviderInstanceData data = new SapProviderInstanceData + { + ProviderSettings = new PrometheusHAClusterProviderInstanceProperties + { + PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), + Hostname = "hostname", + Sid = "sid", + ClusterName = "clusterName", + SslPreference = SapSslPreference.RootCertificate, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -300,10 +396,10 @@ public async Task Get_GetPropertiesOfAOSProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPropertiesOfAOSProvider() + public async Task CreateOrUpdate_CreateASAPMonitorHanaProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusOSProviderInstances_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Create.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -323,17 +419,39 @@ public async Task Exists_GetPropertiesOfAOSProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - bool result = await collection.ExistsAsync(providerInstanceName); + SapProviderInstanceData data = new SapProviderInstanceData + { + ProviderSettings = new HanaDBProviderInstanceProperties + { + Hostname = "name", + DBName = "db", + SqlPort = "0000", + InstanceNumber = "00", + DBUsername = "user", + DBPassword = "****", + DBPasswordUri = new Uri(""), + SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), + SslHostNameInCertificate = "xyz.domain.com", + SslPreference = SapSslPreference.ServerCertificate, + SapSid = "SID", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPropertiesOfAOSProvider() + public async Task CreateOrUpdate_CreateASAPMonitorHanaProviderWithRootCertificate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusOSProviderInstances_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Create_Root_Certificate.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -353,29 +471,38 @@ public async Task GetIfExists_GetPropertiesOfAOSProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); - SapProviderInstanceResource result = response.HasValue ? response.Value : null; - - if (result == null) + SapProviderInstanceData data = new SapProviderInstanceData { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProviderSettings = new HanaDBProviderInstanceProperties + { + Hostname = "name", + DBName = "db", + SqlPort = "0000", + InstanceNumber = "00", + DBUsername = "user", + DBPassword = "****", + DBPasswordUri = new Uri(""), + SslHostNameInCertificate = "xyz.domain.com", + SslPreference = SapSslPreference.RootCertificate, + SapSid = "SID", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPropertiesOfAPrometheusHaClusterProvider() + public async Task CreateOrUpdate_CreateASAPMonitorNetWeaverProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/NetWeaverProviderInstances_Create.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -395,7 +522,25 @@ public async Task Get_GetPropertiesOfAPrometheusHaClusterProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceResource result = await collection.GetAsync(providerInstanceName); + SapProviderInstanceData data = new SapProviderInstanceData + { + ProviderSettings = new SapNetWeaverProviderInstanceProperties + { + SapSid = "SID", + SapHostname = "name", + SapInstanceNr = "00", + SapHostFileEntries = { "127.0.0.1 name fqdn" }, + SapUsername = "username", + SapPassword = "****", + SapPasswordUri = new Uri(""), + SapClientId = "111", + SapPortNumber = "1234", + SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), + SslPreference = SapSslPreference.ServerCertificate, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -406,10 +551,10 @@ public async Task Get_GetPropertiesOfAPrometheusHaClusterProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPropertiesOfAPrometheusHaClusterProvider() + public async Task CreateOrUpdate_CreateASAPMonitorNetWeaverProviderWithRootCertificate() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/NetWeaverProviderInstances_Create_Root_Certificate.json + // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -429,16 +574,37 @@ public async Task Exists_GetPropertiesOfAPrometheusHaClusterProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - bool result = await collection.ExistsAsync(providerInstanceName); + SapProviderInstanceData data = new SapProviderInstanceData + { + ProviderSettings = new SapNetWeaverProviderInstanceProperties + { + SapSid = "SID", + SapHostname = "name", + SapInstanceNr = "00", + SapHostFileEntries = { "127.0.0.1 name fqdn" }, + SapUsername = "username", + SapPassword = "****", + SapPasswordUri = new Uri(""), + SapClientId = "111", + SapPortNumber = "1234", + SslPreference = SapSslPreference.RootCertificate, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); + SapProviderInstanceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPropertiesOfAPrometheusHaClusterProvider() + public async Task Get_GetPropertiesOfADb2Provider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Get.json + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/Db2ProviderInstances_Get.json // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -459,28 +625,20 @@ public async Task GetIfExists_GetPropertiesOfAPrometheusHaClusterProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); - SapProviderInstanceResource result = response.HasValue ? response.Value : null; + SapProviderInstanceResource result = await collection.GetAsync(providerInstanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPropertiesOfASAPMonitorHanaProvider() + public async Task Get_GetPropertiesOfAMsSqlServerProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Get.json + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/MsSqlServerProviderInstance_Get.json // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -512,9 +670,9 @@ public async Task Get_GetPropertiesOfASAPMonitorHanaProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPropertiesOfASAPMonitorHanaProvider() + public async Task Get_GetPropertiesOfAOSProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Get.json + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusOSProviderInstances_Get.json // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -535,16 +693,20 @@ public async Task Exists_GetPropertiesOfASAPMonitorHanaProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - bool result = await collection.ExistsAsync(providerInstanceName); + SapProviderInstanceResource result = await collection.GetAsync(providerInstanceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPropertiesOfASAPMonitorHanaProvider() + public async Task Get_GetPropertiesOfAPrometheusHaClusterProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Get.json + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Get.json // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -565,28 +727,20 @@ public async Task GetIfExists_GetPropertiesOfASAPMonitorHanaProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); - SapProviderInstanceResource result = response.HasValue ? response.Value : null; + SapProviderInstanceResource result = await collection.GetAsync(providerInstanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPropertiesOfASAPMonitorNetWeaverProvider() + public async Task Get_GetPropertiesOfASAPMonitorHanaProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/NetWeaverProviderInstances_Get.json + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Get.json // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -618,7 +772,7 @@ public async Task Get_GetPropertiesOfASAPMonitorNetWeaverProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPropertiesOfASAPMonitorNetWeaverProvider() + public async Task Get_GetPropertiesOfASAPMonitorNetWeaverProvider() { // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/NetWeaverProviderInstances_Get.json // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. @@ -641,17 +795,21 @@ public async Task Exists_GetPropertiesOfASAPMonitorNetWeaverProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - bool result = await collection.ExistsAsync(providerInstanceName); + SapProviderInstanceResource result = await collection.GetAsync(providerInstanceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPropertiesOfASAPMonitorNetWeaverProvider() + public async Task GetAll_ListAllSAPMonitorsProvidersInASubscription() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/NetWeaverProviderInstances_Get.json - // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_List.json + // this example is just showing the usage of "ProviderInstances_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -669,31 +827,25 @@ public async Task GetIfExists_GetPropertiesOfASAPMonitorNetWeaverProvider() // get the collection of this SapProviderInstanceResource SapProviderInstanceCollection collection = sapMonitor.GetSapProviderInstances(); - // invoke the operation - string providerInstanceName = "myProviderInstance"; - NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); - SapProviderInstanceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SapProviderInstanceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; + SapProviderInstanceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADb2Provider() + public async Task Exists_GetPropertiesOfADb2Provider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/Db2ProviderInstances_Create.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/Db2ProviderInstances_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -713,37 +865,17 @@ public async Task CreateOrUpdate_CreateADb2Provider() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new DB2ProviderInstanceProperties() - { - Hostname = "hostname", - DBName = "dbName", - DBPort = "dbPort", - DBUsername = "username", - DBPassword = "password", - DBPasswordUri = new Uri(""), - SapSid = "SID", - SslPreference = SapSslPreference.ServerCertificate, - SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + bool result = await collection.ExistsAsync(providerInstanceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADb2ProviderWithRootCertificate() + public async Task Exists_GetPropertiesOfAMsSqlServerProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/Db2ProviderInstances_Create_Root_Certificate.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/MsSqlServerProviderInstance_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -763,36 +895,17 @@ public async Task CreateOrUpdate_CreateADb2ProviderWithRootCertificate() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new DB2ProviderInstanceProperties() - { - Hostname = "hostname", - DBName = "dbName", - DBPort = "dbPort", - DBUsername = "username", - DBPassword = "password", - DBPasswordUri = new Uri(""), - SapSid = "SID", - SslPreference = SapSslPreference.RootCertificate, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + bool result = await collection.ExistsAsync(providerInstanceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAMsSqlServerProvider() + public async Task Exists_GetPropertiesOfAOSProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/MsSqlServerProviderInstance_Create.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusOSProviderInstances_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -812,36 +925,17 @@ public async Task CreateOrUpdate_CreateAMsSqlServerProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new MsSqlServerProviderInstanceProperties() - { - Hostname = "hostname", - DBPort = "5912", - DBUsername = "user", - DBPassword = "****", - DBPasswordUri = new Uri(""), - SapSid = "sid", - SslPreference = SapSslPreference.ServerCertificate, - SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + bool result = await collection.ExistsAsync(providerInstanceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAMsSqlServerProviderWithRootCertificate() + public async Task Exists_GetPropertiesOfAPrometheusHaClusterProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/MsSqlServerProviderInstance_Create_Root_Certificate.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -861,35 +955,17 @@ public async Task CreateOrUpdate_CreateAMsSqlServerProviderWithRootCertificate() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new MsSqlServerProviderInstanceProperties() - { - Hostname = "hostname", - DBPort = "5912", - DBUsername = "user", - DBPassword = "****", - DBPasswordUri = new Uri(""), - SapSid = "sid", - SslPreference = SapSslPreference.RootCertificate, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + bool result = await collection.ExistsAsync(providerInstanceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAOSProvider() + public async Task Exists_GetPropertiesOfASAPMonitorHanaProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusOSProviderInstances_Create.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -909,32 +985,17 @@ public async Task CreateOrUpdate_CreateAOSProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new PrometheusOSProviderInstanceProperties() - { - PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), - SslPreference = SapSslPreference.ServerCertificate, - SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), - SapSid = "SID", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + bool result = await collection.ExistsAsync(providerInstanceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAOSProviderWithRootCertificate() + public async Task Exists_GetPropertiesOfASAPMonitorNetWeaverProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusOSProviderInstances_Create_Root_Certificate.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/NetWeaverProviderInstances_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -954,31 +1015,17 @@ public async Task CreateOrUpdate_CreateAOSProviderWithRootCertificate() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new PrometheusOSProviderInstanceProperties() - { - PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), - SslPreference = SapSslPreference.RootCertificate, - SapSid = "SID", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + bool result = await collection.ExistsAsync(providerInstanceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAPrometheusHaClusterProvider() + public async Task GetIfExists_GetPropertiesOfADb2Provider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Create.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/Db2ProviderInstances_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -998,34 +1045,29 @@ public async Task CreateOrUpdate_CreateAPrometheusHaClusterProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new PrometheusHAClusterProviderInstanceProperties() - { - PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), - Hostname = "hostname", - Sid = "sid", - ClusterName = "clusterName", - SslPreference = SapSslPreference.ServerCertificate, - SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); + SapProviderInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAPrometheusHaClusterProviderWithRootCertificate() + public async Task GetIfExists_GetPropertiesOfAMsSqlServerProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Create_Root_Certificate.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/MsSqlServerProviderInstance_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1045,33 +1087,29 @@ public async Task CreateOrUpdate_CreateAPrometheusHaClusterProviderWithRootCerti // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new PrometheusHAClusterProviderInstanceProperties() - { - PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), - Hostname = "hostname", - Sid = "sid", - ClusterName = "clusterName", - SslPreference = SapSslPreference.RootCertificate, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); + SapProviderInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASAPMonitorHanaProvider() + public async Task GetIfExists_GetPropertiesOfAOSProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Create.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusOSProviderInstances_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1091,39 +1129,29 @@ public async Task CreateOrUpdate_CreateASAPMonitorHanaProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new HanaDBProviderInstanceProperties() - { - Hostname = "name", - DBName = "db", - SqlPort = "0000", - InstanceNumber = "00", - DBUsername = "user", - DBPassword = "****", - DBPasswordUri = new Uri(""), - SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), - SslHostNameInCertificate = "xyz.domain.com", - SslPreference = SapSslPreference.ServerCertificate, - SapSid = "SID", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); + SapProviderInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASAPMonitorHanaProviderWithRootCertificate() + public async Task GetIfExists_GetPropertiesOfAPrometheusHaClusterProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Create_Root_Certificate.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/PrometheusHaClusterProviderInstances_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1143,38 +1171,29 @@ public async Task CreateOrUpdate_CreateASAPMonitorHanaProviderWithRootCertificat // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new HanaDBProviderInstanceProperties() - { - Hostname = "name", - DBName = "db", - SqlPort = "0000", - InstanceNumber = "00", - DBUsername = "user", - DBPassword = "****", - DBPasswordUri = new Uri(""), - SslHostNameInCertificate = "xyz.domain.com", - SslPreference = SapSslPreference.RootCertificate, - SapSid = "SID", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); + SapProviderInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASAPMonitorNetWeaverProvider() + public async Task GetIfExists_GetPropertiesOfASAPMonitorHanaProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/NetWeaverProviderInstances_Create.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1194,42 +1213,29 @@ public async Task CreateOrUpdate_CreateASAPMonitorNetWeaverProvider() // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new SapNetWeaverProviderInstanceProperties() - { - SapSid = "SID", - SapHostname = "name", - SapInstanceNr = "00", - SapHostFileEntries = -{ -"127.0.0.1 name fqdn" -}, - SapUsername = "username", - SapPassword = "****", - SapPasswordUri = new Uri(""), - SapClientId = "111", - SapPortNumber = "1234", - SslCertificateUri = new Uri("https://storageaccount.blob.core.windows.net/containername/filename"), - SslPreference = SapSslPreference.ServerCertificate, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); + SapProviderInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASAPMonitorNetWeaverProviderWithRootCertificate() + public async Task GetIfExists_GetPropertiesOfASAPMonitorNetWeaverProvider() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/NetWeaverProviderInstances_Create_Root_Certificate.json - // this example is just showing the usage of "ProviderInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/NetWeaverProviderInstances_Get.json + // this example is just showing the usage of "ProviderInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1249,33 +1255,21 @@ public async Task CreateOrUpdate_CreateASAPMonitorNetWeaverProviderWithRootCerti // invoke the operation string providerInstanceName = "myProviderInstance"; - SapProviderInstanceData data = new SapProviderInstanceData() - { - ProviderSettings = new SapNetWeaverProviderInstanceProperties() - { - SapSid = "SID", - SapHostname = "name", - SapInstanceNr = "00", - SapHostFileEntries = -{ -"127.0.0.1 name fqdn" -}, - SapUsername = "username", - SapPassword = "****", - SapPasswordUri = new Uri(""), - SapClientId = "111", - SapPortNumber = "1234", - SslPreference = SapSslPreference.RootCertificate, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerInstanceName, data); - SapProviderInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(providerInstanceName); + SapProviderInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapProviderInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapProviderInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapProviderInstanceResource.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapProviderInstanceResource.cs index c9ba2b90f112a..e561cfe2f4960 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapProviderInstanceResource.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapProviderInstanceResource.cs @@ -203,6 +203,34 @@ public async Task Get_GetPropertiesOfASAPMonitorNetWeaverProvider() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeletesASAPMonitorProvider() + { + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Delete.json + // this example is just showing the usage of "ProviderInstances_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SapProviderInstanceResource created on azure + // for more information of creating SapProviderInstanceResource, please refer to the document of SapProviderInstanceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + string monitorName = "mySapMonitor"; + string providerInstanceName = "myProviderInstance"; + ResourceIdentifier sapProviderInstanceResourceId = SapProviderInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName, providerInstanceName); + SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); + + // invoke the operation + ArmOperation lro = await sapProviderInstance.DeleteAsync(WaitUntil.Completed); + OperationStatusResult result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateADb2Provider() @@ -225,9 +253,9 @@ public async Task Update_CreateADb2Provider() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new DB2ProviderInstanceProperties() + ProviderSettings = new DB2ProviderInstanceProperties { Hostname = "hostname", DBName = "dbName", @@ -272,9 +300,9 @@ public async Task Update_CreateADb2ProviderWithRootCertificate() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new DB2ProviderInstanceProperties() + ProviderSettings = new DB2ProviderInstanceProperties { Hostname = "hostname", DBName = "dbName", @@ -318,9 +346,9 @@ public async Task Update_CreateAMsSqlServerProvider() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new MsSqlServerProviderInstanceProperties() + ProviderSettings = new MsSqlServerProviderInstanceProperties { Hostname = "hostname", DBPort = "5912", @@ -364,9 +392,9 @@ public async Task Update_CreateAMsSqlServerProviderWithRootCertificate() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new MsSqlServerProviderInstanceProperties() + ProviderSettings = new MsSqlServerProviderInstanceProperties { Hostname = "hostname", DBPort = "5912", @@ -409,9 +437,9 @@ public async Task Update_CreateAOSProvider() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new PrometheusOSProviderInstanceProperties() + ProviderSettings = new PrometheusOSProviderInstanceProperties { PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), SslPreference = SapSslPreference.ServerCertificate, @@ -451,9 +479,9 @@ public async Task Update_CreateAOSProviderWithRootCertificate() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new PrometheusOSProviderInstanceProperties() + ProviderSettings = new PrometheusOSProviderInstanceProperties { PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), SslPreference = SapSslPreference.RootCertificate, @@ -492,9 +520,9 @@ public async Task Update_CreateAPrometheusHaClusterProvider() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new PrometheusHAClusterProviderInstanceProperties() + ProviderSettings = new PrometheusHAClusterProviderInstanceProperties { PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), Hostname = "hostname", @@ -536,9 +564,9 @@ public async Task Update_CreateAPrometheusHaClusterProviderWithRootCertificate() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new PrometheusHAClusterProviderInstanceProperties() + ProviderSettings = new PrometheusHAClusterProviderInstanceProperties { PrometheusUri = new Uri("http://192.168.0.0:9090/metrics"), Hostname = "hostname", @@ -579,9 +607,9 @@ public async Task Update_CreateASAPMonitorHanaProvider() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new HanaDBProviderInstanceProperties() + ProviderSettings = new HanaDBProviderInstanceProperties { Hostname = "name", DBName = "db", @@ -628,9 +656,9 @@ public async Task Update_CreateASAPMonitorHanaProviderWithRootCertificate() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new HanaDBProviderInstanceProperties() + ProviderSettings = new HanaDBProviderInstanceProperties { Hostname = "name", DBName = "db", @@ -676,17 +704,14 @@ public async Task Update_CreateASAPMonitorNetWeaverProvider() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new SapNetWeaverProviderInstanceProperties() + ProviderSettings = new SapNetWeaverProviderInstanceProperties { SapSid = "SID", SapHostname = "name", SapInstanceNr = "00", - SapHostFileEntries = -{ -"127.0.0.1 name fqdn" -}, + SapHostFileEntries = { "127.0.0.1 name fqdn" }, SapUsername = "username", SapPassword = "****", SapPasswordUri = new Uri(""), @@ -728,17 +753,14 @@ public async Task Update_CreateASAPMonitorNetWeaverProviderWithRootCertificate() SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); // invoke the operation - SapProviderInstanceData data = new SapProviderInstanceData() + SapProviderInstanceData data = new SapProviderInstanceData { - ProviderSettings = new SapNetWeaverProviderInstanceProperties() + ProviderSettings = new SapNetWeaverProviderInstanceProperties { SapSid = "SID", SapHostname = "name", SapInstanceNr = "00", - SapHostFileEntries = -{ -"127.0.0.1 name fqdn" -}, + SapHostFileEntries = { "127.0.0.1 name fqdn" }, SapUsername = "username", SapPassword = "****", SapPasswordUri = new Uri(""), @@ -756,33 +778,5 @@ public async Task Update_CreateASAPMonitorNetWeaverProviderWithRootCertificate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesASAPMonitorProvider() - { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/ProviderInstances_Delete.json - // this example is just showing the usage of "ProviderInstances_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SapProviderInstanceResource created on azure - // for more information of creating SapProviderInstanceResource, please refer to the document of SapProviderInstanceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - string monitorName = "mySapMonitor"; - string providerInstanceName = "myProviderInstance"; - ResourceIdentifier sapProviderInstanceResourceId = SapProviderInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName, providerInstanceName); - SapProviderInstanceResource sapProviderInstance = client.GetSapProviderInstanceResource(sapProviderInstanceResourceId); - - // invoke the operation - ArmOperation lro = await sapProviderInstance.DeleteAsync(WaitUntil.Completed); - OperationStatusResult result = lro.Value; - - Console.WriteLine($"Succeeded: {result}"); - } } } diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapVirtualInstanceCollection.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapVirtualInstanceCollection.cs index f120982d61aa1..4a90bc456b45f 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapVirtualInstanceCollection.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapVirtualInstanceCollection.cs @@ -41,58 +41,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationWithCust // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -103,134 +103,90 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationWithCust DatabaseType = SapDatabaseType.Hana, }) { - CustomResourceNames = new ThreeTierFullResourceNames() + CustomResourceNames = new ThreeTierFullResourceNames { - CentralServer = new CentralServerFullResourceNames() + CentralServer = new CentralServerFullResourceNames { - VirtualMachines = -{ -new VirtualMachineResourceNames() + VirtualMachines = {new VirtualMachineResourceNames { VmName = "ascsvm", HostName = "ascshostName", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "ascsnic", -} -}, +}}, OSDiskName = "ascsosdisk", DataDiskNames = { -["default"] = new string[] -{ -"ascsdisk0" -}, -}, -} +["default"] = {"ascsdisk0"} }, +}}, }, - ApplicationServer = new ApplicationServerFullResourceNames() + ApplicationServer = new ApplicationServerFullResourceNames { - VirtualMachines = -{ -new VirtualMachineResourceNames() + VirtualMachines = {new VirtualMachineResourceNames { VmName = "appvm0", HostName = "apphostName0", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "appnic0", -} -}, +}}, OSDiskName = "app0osdisk", DataDiskNames = { -["default"] = new string[] -{ -"app0disk0" -}, +["default"] = {"app0disk0"} }, -},new VirtualMachineResourceNames() +}, new VirtualMachineResourceNames { VmName = "appvm1", HostName = "apphostName1", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "appnic1", -} -}, +}}, OSDiskName = "app1osdisk", DataDiskNames = { -["default"] = new string[] -{ -"app1disk0" -}, -}, -} +["default"] = {"app1disk0"} }, +}}, AvailabilitySetName = "appAvSet", }, - DatabaseServer = new DatabaseServerFullResourceNames() + DatabaseServer = new DatabaseServerFullResourceNames { - VirtualMachines = -{ -new VirtualMachineResourceNames() + VirtualMachines = {new VirtualMachineResourceNames { VmName = "dbvm", HostName = "dbhostName", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "dbnic", -} -}, +}}, OSDiskName = "dbosdisk", DataDiskNames = { -["hanaData"] = new string[] -{ -"hanadata0","hanadata1" -}, -["hanaLog"] = new string[] -{ -"hanalog0","hanalog1","hanalog2" -}, -["hanaShared"] = new string[] -{ -"hanashared0","hanashared1" -}, -["usrSap"] = new string[] -{ -"usrsap0" -}, -}, -} +["hanaData"] = {"hanadata0", "hanadata1"}, +["hanaLog"] = {"hanalog0", "hanalog1", "hanalog2"}, +["hanaShared"] = {"hanashared0", "hanashared1"}, +["usrSap"] = {"usrsap0"} }, +}}, }, - SharedStorage = new SharedStorageResourceNames() + SharedStorage = new SharedStorageResourceNames { SharedStorageAccountName = "storageacc", SharedStorageAccountPrivateEndPointName = "peForxNFS", }, }, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -266,58 +222,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationWithCust // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -329,204 +285,127 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationWithCust }) { HighAvailabilityType = SapHighAvailabilityType.AvailabilitySet, - CustomResourceNames = new ThreeTierFullResourceNames() + CustomResourceNames = new ThreeTierFullResourceNames { - CentralServer = new CentralServerFullResourceNames() + CentralServer = new CentralServerFullResourceNames { - VirtualMachines = -{ -new VirtualMachineResourceNames() + VirtualMachines = {new VirtualMachineResourceNames { VmName = "ascsvm", HostName = "ascshostName", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "ascsnic", -} -}, +}}, OSDiskName = "ascsosdisk", -},new VirtualMachineResourceNames() +}, new VirtualMachineResourceNames { VmName = "ersvm", HostName = "ershostName", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "ersnic", -} -}, +}}, OSDiskName = "ersosdisk", -} -}, +}}, AvailabilitySetName = "csAvSet", - LoadBalancer = new LoadBalancerResourceNames() + LoadBalancer = new LoadBalancerResourceNames { LoadBalancerName = "ascslb", - FrontendIPConfigurationNames = -{ -"ascsip0","ersip0" -}, - BackendPoolNames = -{ -"ascsBackendPool" -}, - HealthProbeNames = -{ -"ascsHealthProbe","ersHealthProbe" -}, + FrontendIPConfigurationNames = { "ascsip0", "ersip0" }, + BackendPoolNames = { "ascsBackendPool" }, + HealthProbeNames = { "ascsHealthProbe", "ersHealthProbe" }, }, }, - ApplicationServer = new ApplicationServerFullResourceNames() + ApplicationServer = new ApplicationServerFullResourceNames { - VirtualMachines = -{ -new VirtualMachineResourceNames() + VirtualMachines = {new VirtualMachineResourceNames { VmName = "appvm0", HostName = "apphostName0", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "appnic0", -} -}, +}}, OSDiskName = "app0osdisk", DataDiskNames = { -["default"] = new string[] -{ -"app0disk0" -}, +["default"] = {"app0disk0"} }, -},new VirtualMachineResourceNames() +}, new VirtualMachineResourceNames { VmName = "appvm1", HostName = "apphostName1", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "appnic1", -} -}, +}}, OSDiskName = "app1osdisk", DataDiskNames = { -["default"] = new string[] -{ -"app1disk0" -}, -}, -} +["default"] = {"app1disk0"} }, +}}, AvailabilitySetName = "appAvSet", }, - DatabaseServer = new DatabaseServerFullResourceNames() + DatabaseServer = new DatabaseServerFullResourceNames { - VirtualMachines = -{ -new VirtualMachineResourceNames() + VirtualMachines = {new VirtualMachineResourceNames { VmName = "dbvmpr", HostName = "dbprhostName", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "dbprnic", -} -}, +}}, OSDiskName = "dbprosdisk", DataDiskNames = { -["hanaData"] = new string[] -{ -"hanadatapr0","hanadatapr1" -}, -["hanaLog"] = new string[] -{ -"hanalogpr0","hanalogpr1","hanalogpr2" -}, -["hanaShared"] = new string[] -{ -"hanasharedpr0","hanasharedpr1" -}, -["usrSap"] = new string[] -{ -"usrsappr0" +["hanaData"] = {"hanadatapr0", "hanadatapr1"}, +["hanaLog"] = {"hanalogpr0", "hanalogpr1", "hanalogpr2"}, +["hanaShared"] = {"hanasharedpr0", "hanasharedpr1"}, +["usrSap"] = {"usrsappr0"} }, -}, -},new VirtualMachineResourceNames() +}, new VirtualMachineResourceNames { VmName = "dbvmsr", HostName = "dbsrhostName", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "dbsrnic", -} -}, +}}, OSDiskName = "dbsrosdisk", DataDiskNames = { -["hanaData"] = new string[] -{ -"hanadatasr0","hanadatasr1" -}, -["hanaLog"] = new string[] -{ -"hanalogsr0","hanalogsr1","hanalogsr2" -}, -["hanaShared"] = new string[] -{ -"hanasharedsr0","hanasharedsr1" -}, -["usrSap"] = new string[] -{ -"usrsapsr0" -}, -}, -} +["hanaData"] = {"hanadatasr0", "hanadatasr1"}, +["hanaLog"] = {"hanalogsr0", "hanalogsr1", "hanalogsr2"}, +["hanaShared"] = {"hanasharedsr0", "hanasharedsr1"}, +["usrSap"] = {"usrsapsr0"} }, +}}, AvailabilitySetName = "dbAvSet", - LoadBalancer = new LoadBalancerResourceNames() + LoadBalancer = new LoadBalancerResourceNames { LoadBalancerName = "dblb", - FrontendIPConfigurationNames = -{ -"dbip" -}, - BackendPoolNames = -{ -"dbBackendPool" -}, - HealthProbeNames = -{ -"dbHealthProbe" -}, + FrontendIPConfigurationNames = { "dbip" }, + BackendPoolNames = { "dbBackendPool" }, + HealthProbeNames = { "dbHealthProbe" }, }, }, - SharedStorage = new SharedStorageResourceNames() + SharedStorage = new SharedStorageResourceNames { SharedStorageAccountName = "storageacc", SharedStorageAccountPrivateEndPointName = "peForxNFS", }, }, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -562,58 +441,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationWithCust // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -625,201 +504,124 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationWithCust }) { HighAvailabilityType = SapHighAvailabilityType.AvailabilityZone, - CustomResourceNames = new ThreeTierFullResourceNames() + CustomResourceNames = new ThreeTierFullResourceNames { - CentralServer = new CentralServerFullResourceNames() + CentralServer = new CentralServerFullResourceNames { - VirtualMachines = -{ -new VirtualMachineResourceNames() + VirtualMachines = {new VirtualMachineResourceNames { VmName = "ascsvm", HostName = "ascshostName", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "ascsnic", -} -}, +}}, OSDiskName = "ascsosdisk", -},new VirtualMachineResourceNames() +}, new VirtualMachineResourceNames { VmName = "ersvm", HostName = "ershostName", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "ersnic", -} -}, +}}, OSDiskName = "ersosdisk", -} -}, - LoadBalancer = new LoadBalancerResourceNames() +}}, + LoadBalancer = new LoadBalancerResourceNames { LoadBalancerName = "ascslb", - FrontendIPConfigurationNames = -{ -"ascsip0","ersip0" -}, - BackendPoolNames = -{ -"ascsBackendPool" -}, - HealthProbeNames = -{ -"ascsHealthProbe","ersHealthProbe" -}, + FrontendIPConfigurationNames = { "ascsip0", "ersip0" }, + BackendPoolNames = { "ascsBackendPool" }, + HealthProbeNames = { "ascsHealthProbe", "ersHealthProbe" }, }, }, - ApplicationServer = new ApplicationServerFullResourceNames() + ApplicationServer = new ApplicationServerFullResourceNames { - VirtualMachines = -{ -new VirtualMachineResourceNames() + VirtualMachines = {new VirtualMachineResourceNames { VmName = "appvm0", HostName = "apphostName0", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "appnic0", -} -}, +}}, OSDiskName = "app0osdisk", DataDiskNames = { -["default"] = new string[] -{ -"app0disk0" -}, +["default"] = {"app0disk0"} }, -},new VirtualMachineResourceNames() +}, new VirtualMachineResourceNames { VmName = "appvm1", HostName = "apphostName1", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "appnic1", -} -}, +}}, OSDiskName = "app1osdisk", DataDiskNames = { -["default"] = new string[] -{ -"app1disk0" -}, -}, -} +["default"] = {"app1disk0"} }, +}}, }, - DatabaseServer = new DatabaseServerFullResourceNames() + DatabaseServer = new DatabaseServerFullResourceNames { - VirtualMachines = -{ -new VirtualMachineResourceNames() + VirtualMachines = {new VirtualMachineResourceNames { VmName = "dbvmpr", HostName = "dbprhostName", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "dbprnic", -} -}, +}}, OSDiskName = "dbprosdisk", DataDiskNames = { -["hanaData"] = new string[] -{ -"hanadatapr0","hanadatapr1" +["hanaData"] = {"hanadatapr0", "hanadatapr1"}, +["hanaLog"] = {"hanalogpr0", "hanalogpr1", "hanalogpr2"}, +["hanaShared"] = {"hanasharedpr0", "hanasharedpr1"}, +["usrSap"] = {"usrsappr0"} }, -["hanaLog"] = new string[] -{ -"hanalogpr0","hanalogpr1","hanalogpr2" -}, -["hanaShared"] = new string[] -{ -"hanasharedpr0","hanasharedpr1" -}, -["usrSap"] = new string[] -{ -"usrsappr0" -}, -}, -},new VirtualMachineResourceNames() +}, new VirtualMachineResourceNames { VmName = "dbvmsr", HostName = "dbsrhostName", -NetworkInterfaces = -{ -new NetworkInterfaceResourceNames() +NetworkInterfaces = {new NetworkInterfaceResourceNames { NetworkInterfaceName = "dbsrnic", -} -}, +}}, OSDiskName = "dbsrosdisk", DataDiskNames = { -["hanaData"] = new string[] -{ -"hanadatasr0","hanadatasr1" -}, -["hanaLog"] = new string[] -{ -"hanalogsr0","hanalogsr1","hanalogsr2" -}, -["hanaShared"] = new string[] -{ -"hanasharedsr0","hanasharedsr1" -}, -["usrSap"] = new string[] -{ -"usrsapsr0" -}, -}, -} +["hanaData"] = {"hanadatasr0", "hanadatasr1"}, +["hanaLog"] = {"hanalogsr0", "hanalogsr1", "hanalogsr2"}, +["hanaShared"] = {"hanasharedsr0", "hanasharedsr1"}, +["usrSap"] = {"usrsapsr0"} }, - LoadBalancer = new LoadBalancerResourceNames() +}}, + LoadBalancer = new LoadBalancerResourceNames { LoadBalancerName = "dblb", - FrontendIPConfigurationNames = -{ -"dbip" -}, - BackendPoolNames = -{ -"dbBackendPool" -}, - HealthProbeNames = -{ -"dbHealthProbe" -}, + FrontendIPConfigurationNames = { "dbip" }, + BackendPoolNames = { "dbBackendPool" }, + HealthProbeNames = { "dbHealthProbe" }, }, }, - SharedStorage = new SharedStorageResourceNames() + SharedStorage = new SharedStorageResourceNames { SharedStorageAccountName = "storageacc", SharedStorageAccountPrivateEndPointName = "peForxNFS", }, }, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -855,22 +657,22 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationWithCust // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new SingleServerConfiguration("X00-RG", new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + InfrastructureConfiguration = new SingleServerConfiguration("X00-RG", new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -881,15 +683,13 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationWithCust IsSecondaryIPEnabled = true, DatabaseType = SapDatabaseType.Hana, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -925,68 +725,59 @@ public async Task CreateOrUpdate_CreateInfrastructureOnlyForDistributedSystem() // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshPublicKeys = -{ -new SapSshPublicKey() + SshPublicKeys = {new SapSshPublicKey { KeyData = "ssh-rsa public key", -} -}, +}}, }, - }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshPublicKeys = -{ -new SapSshPublicKey() + SshPublicKeys = {new SapSshPublicKey { KeyData = "ssh-rsa public key", -} -}, +}}, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshPublicKeys = -{ -new SapSshPublicKey() + SshPublicKeys = {new SapSshPublicKey { KeyData = "ssh-rsa public key", -} -}, +}}, }, }), 1L) { @@ -994,9 +785,7 @@ public async Task CreateOrUpdate_CreateInfrastructureOnlyForDistributedSystem() }), }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -1032,68 +821,59 @@ public async Task CreateOrUpdate_CreateInfrastructureOnlyForHASystemWithAvailabi // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshPublicKeys = -{ -new SapSshPublicKey() + SshPublicKeys = {new SapSshPublicKey { KeyData = "ssh-rsa public key", -} -}, +}}, }, - }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshPublicKeys = -{ -new SapSshPublicKey() + SshPublicKeys = {new SapSshPublicKey { KeyData = "ssh-rsa public key", -} -}, +}}, }, - }), 5L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 5L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshPublicKeys = -{ -new SapSshPublicKey() + SshPublicKeys = {new SapSshPublicKey { KeyData = "ssh-rsa public key", -} -}, +}}, }, }), 2L) { @@ -1104,9 +884,7 @@ public async Task CreateOrUpdate_CreateInfrastructureOnlyForHASystemWithAvailabi }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -1142,68 +920,59 @@ public async Task CreateOrUpdate_CreateInfrastructureOnlyForHASystemWithAvailabi // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshPublicKeys = -{ -new SapSshPublicKey() + SshPublicKeys = {new SapSshPublicKey { KeyData = "ssh-rsa public key", -} -}, +}}, }, - }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshPublicKeys = -{ -new SapSshPublicKey() + SshPublicKeys = {new SapSshPublicKey { KeyData = "ssh-rsa public key", -} -}, +}}, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshPublicKeys = -{ -new SapSshPublicKey() + SshPublicKeys = {new SapSshPublicKey { KeyData = "ssh-rsa public key", -} -}, +}}, }, }), 2L) { @@ -1214,9 +983,7 @@ public async Task CreateOrUpdate_CreateInfrastructureOnlyForHASystemWithAvailabi }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -1252,28 +1019,25 @@ public async Task CreateOrUpdate_CreateInfrastructureOnlyForSingleServerSystem() // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new SingleServerConfiguration("X00-RG", new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + InfrastructureConfiguration = new SingleServerConfiguration("X00-RG", new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshPublicKeys = -{ -new SapSshPublicKey() + SshPublicKeys = {new SapSshPublicKey { KeyData = "ssh-rsa public key", -} -}, +}}, }, })) { @@ -1282,9 +1046,7 @@ public async Task CreateOrUpdate_CreateInfrastructureOnlyForSingleServerSystem() }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -1320,58 +1082,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithDiskAndOSConfigurationF // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -1382,53 +1144,51 @@ public async Task CreateOrUpdate_CreateInfrastructureWithDiskAndOSConfigurationF DatabaseType = SapDatabaseType.Hana, DiskVolumeConfigurations = { -["backup"] = new DiskVolumeConfiguration() +["backup"] = new DiskVolumeConfiguration { Count = 2L, SizeInGB = 256L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["hana/data"] = new DiskVolumeConfiguration() +["hana/data"] = new DiskVolumeConfiguration { Count = 4L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, }, -["hana/log"] = new DiskVolumeConfiguration() +["hana/log"] = new DiskVolumeConfiguration { Count = 3L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, }, -["hana/shared"] = new DiskVolumeConfiguration() +["hana/shared"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 256L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["os"] = new DiskVolumeConfiguration() +["os"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 64L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["usr/sap"] = new DiskVolumeConfiguration() +["usr/sap"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, -}, +} }, }), - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -1464,58 +1224,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithDiskAndOSConfigurationF // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -1526,56 +1286,54 @@ public async Task CreateOrUpdate_CreateInfrastructureWithDiskAndOSConfigurationF DatabaseType = SapDatabaseType.Hana, DiskVolumeConfigurations = { -["backup"] = new DiskVolumeConfiguration() +["backup"] = new DiskVolumeConfiguration { Count = 2L, SizeInGB = 256L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["hana/data"] = new DiskVolumeConfiguration() +["hana/data"] = new DiskVolumeConfiguration { Count = 4L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, }, -["hana/log"] = new DiskVolumeConfiguration() +["hana/log"] = new DiskVolumeConfiguration { Count = 3L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, }, -["hana/shared"] = new DiskVolumeConfiguration() +["hana/shared"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 256L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["os"] = new DiskVolumeConfiguration() +["os"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 64L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["usr/sap"] = new DiskVolumeConfiguration() +["usr/sap"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, -}, +} }, }) { HighAvailabilityType = SapHighAvailabilityType.AvailabilitySet, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -1611,58 +1369,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithDiskAndOSConfigurationF // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -1673,56 +1431,54 @@ public async Task CreateOrUpdate_CreateInfrastructureWithDiskAndOSConfigurationF DatabaseType = SapDatabaseType.Hana, DiskVolumeConfigurations = { -["backup"] = new DiskVolumeConfiguration() +["backup"] = new DiskVolumeConfiguration { Count = 2L, SizeInGB = 256L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["hana/data"] = new DiskVolumeConfiguration() +["hana/data"] = new DiskVolumeConfiguration { Count = 4L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, }, -["hana/log"] = new DiskVolumeConfiguration() +["hana/log"] = new DiskVolumeConfiguration { Count = 3L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, }, -["hana/shared"] = new DiskVolumeConfiguration() +["hana/shared"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 256L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["os"] = new DiskVolumeConfiguration() +["os"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 64L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["usr/sap"] = new DiskVolumeConfiguration() +["usr/sap"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, -}, +} }, }) { HighAvailabilityType = SapHighAvailabilityType.AvailabilityZone, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -1758,22 +1514,22 @@ public async Task CreateOrUpdate_CreateInfrastructureWithDiskAndOSConfigurations // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new SingleServerConfiguration("X00-RG", new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + InfrastructureConfiguration = new SingleServerConfiguration("X00-RG", new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/dindurkhya-e2etesting/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -1785,53 +1541,51 @@ public async Task CreateOrUpdate_CreateInfrastructureWithDiskAndOSConfigurations DatabaseType = SapDatabaseType.Hana, DiskVolumeConfigurations = { -["backup"] = new DiskVolumeConfiguration() +["backup"] = new DiskVolumeConfiguration { Count = 2L, SizeInGB = 256L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["hana/data"] = new DiskVolumeConfiguration() +["hana/data"] = new DiskVolumeConfiguration { Count = 4L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, }, -["hana/log"] = new DiskVolumeConfiguration() +["hana/log"] = new DiskVolumeConfiguration { Count = 3L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, }, -["hana/shared"] = new DiskVolumeConfiguration() +["hana/shared"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 256L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["os"] = new DiskVolumeConfiguration() +["os"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 64L, SkuName = DiskDetailsDiskSkuName.StandardSsdLrs, }, -["usr/sap"] = new DiskVolumeConfiguration() +["usr/sap"] = new DiskVolumeConfiguration { Count = 1L, SizeInGB = 128L, SkuName = DiskDetailsDiskSkuName.PremiumLrs, -}, +} }, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -1867,58 +1621,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationForDistr // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -1928,15 +1682,13 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationForDistr { DatabaseType = SapDatabaseType.Hana, }), - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -1972,58 +1724,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationForHASys // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -2036,15 +1788,13 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationForHASys { HighAvailabilityType = SapHighAvailabilityType.AvailabilitySet, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -2080,58 +1830,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationForHASys // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -2144,15 +1894,13 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationForHASys { HighAvailabilityType = SapHighAvailabilityType.AvailabilityZone, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -2188,22 +1936,22 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationForSingl // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new SingleServerConfiguration("X00-RG", new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + InfrastructureConfiguration = new SingleServerConfiguration("X00-RG", new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -2214,15 +1962,13 @@ public async Task CreateOrUpdate_CreateInfrastructureWithOSConfigurationForSingl IsSecondaryIPEnabled = true, DatabaseType = SapDatabaseType.Hana, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -2258,58 +2004,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithANewSAPTransportDirecto // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -2320,21 +2066,19 @@ public async Task CreateOrUpdate_CreateInfrastructureWithANewSAPTransportDirecto DatabaseType = SapDatabaseType.Hana, }) { - StorageTransportFileShareConfiguration = new CreateAndMountFileShareConfiguration() + StorageTransportFileShareConfiguration = new CreateAndMountFileShareConfiguration { ResourceGroup = "rgName", StorageAccountName = "storageName", }, }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -2370,58 +2114,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithAnExistingSAPTransportD // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -2434,15 +2178,13 @@ public async Task CreateOrUpdate_CreateInfrastructureWithAnExistingSAPTransportD { StorageTransportFileShareConfiguration = new MountFileShareConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e888-4c46-a868-1936802b762c/resourceGroups/testrg/providers/Microsoft.Network/privateEndpoints/endpoint"), new ResourceIdentifier("/subscriptions/49d64d54-e888-4c46-a868-1936802b762c/resourceGroups/testrg/providers/Microsoft.Network/privateEndpoints/endpoint")), }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -2478,58 +2220,58 @@ public async Task CreateOrUpdate_CreateInfrastructureWithoutASAPTransportDirecto // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -2542,15 +2284,13 @@ public async Task CreateOrUpdate_CreateInfrastructureWithoutASAPTransportDirecto { StorageTransportFileShareConfiguration = new SkipFileShareConfiguration(), }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -2586,58 +2326,58 @@ public async Task CreateOrUpdate_DetectSAPSoftwareInstallationOnADistributedSyst // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("eastus2"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("eastus2"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("{{resourcegrp}}", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_E4ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("{{resourcegrp}}", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_E4ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "azureuser", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "{{sshkey}}", PrivateKey = "{{privateKey}}", }, }, - }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_E4ds_v4", new SapImageReference() + }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_E4ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "azureuser", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "{{sshkey}}", PrivateKey = "{{privateKey}}", }, }, - }), 2L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 2L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "azureuser", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "{{sshkey}}", PrivateKey = "{{privateKey}}", @@ -2647,11 +2387,11 @@ public async Task CreateOrUpdate_DetectSAPSoftwareInstallationOnADistributedSyst { IsSecondaryIPEnabled = true, }, - SoftwareConfiguration = new ExternalInstallationSoftwareConfiguration() + SoftwareConfiguration = new ExternalInstallationSoftwareConfiguration { CentralServerVmId = new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/sapq20scsvm0"), }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "sap.bpaas.com", }, @@ -2659,7 +2399,7 @@ public async Task CreateOrUpdate_DetectSAPSoftwareInstallationOnADistributedSyst { Tags = { -["created by"] = "azureuser", +["created by"] = "azureuser" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); @@ -2696,22 +2436,22 @@ public async Task CreateOrUpdate_DetectSAPSoftwareInstallationOnASingleServerSys // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new SingleServerConfiguration("X00-RG", new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + InfrastructureConfiguration = new SingleServerConfiguration("X00-RG", new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -2722,19 +2462,17 @@ public async Task CreateOrUpdate_DetectSAPSoftwareInstallationOnASingleServerSys IsSecondaryIPEnabled = true, DatabaseType = SapDatabaseType.Hana, }, - SoftwareConfiguration = new ExternalInstallationSoftwareConfiguration() + SoftwareConfiguration = new ExternalInstallationSoftwareConfiguration { CentralServerVmId = new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/sapq20scsvm0"), }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -2770,58 +2508,58 @@ public async Task CreateOrUpdate_DetectSAPSoftwareInstallationOnAnHASystemWithAv // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -2834,19 +2572,17 @@ public async Task CreateOrUpdate_DetectSAPSoftwareInstallationOnAnHASystemWithAv { HighAvailabilityType = SapHighAvailabilityType.AvailabilitySet, }, - SoftwareConfiguration = new ExternalInstallationSoftwareConfiguration() + SoftwareConfiguration = new ExternalInstallationSoftwareConfiguration { CentralServerVmId = new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/sapq20scsvm0"), }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -2882,58 +2618,58 @@ public async Task CreateOrUpdate_DetectSAPSoftwareInstallationOnAnHASystemWithAv // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("westcentralus"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("X00-RG", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E16ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + }), 2L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/appsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", }, }, - }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 6L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Networks/virtualNetworks/test-vnet/subnets/dbsubnet"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "84sapha-gen2", Version = "latest", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "{your-username}", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "abc", PrivateKey = "xyz", @@ -2946,19 +2682,17 @@ public async Task CreateOrUpdate_DetectSAPSoftwareInstallationOnAnHASystemWithAv { HighAvailabilityType = SapHighAvailabilityType.AvailabilityZone, }, - SoftwareConfiguration = new ExternalInstallationSoftwareConfiguration() + SoftwareConfiguration = new ExternalInstallationSoftwareConfiguration { CentralServerVmId = new ResourceIdentifier("/subscriptions/49d64d54-e966-4c46-a868-1999802b762c/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/sapq20scsvm0"), }, - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "xyz.test.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -2994,58 +2728,58 @@ public async Task CreateOrUpdate_InstallSAPSoftwareOnDistributedSystem() // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("eastus2"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("eastus2"), SapEnvironmentType.Prod, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new ThreeTierConfiguration("{{resourcegrp}}", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_E4ds_v4", new SapImageReference() + InfrastructureConfiguration = new ThreeTierConfiguration("{{resourcegrp}}", new CentralServerConfiguration(new ResourceIdentifier("/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_E4ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "8.2", Version = "8.2.2021091201", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "azureuser", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "{{sshkey}}", PrivateKey = "{{privateKey}}", }, }, - }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_E4ds_v4", new SapImageReference() + }), 1L), new ApplicationServerConfiguration(new ResourceIdentifier("/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_E4ds_v4", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "8.2", Version = "8.2.2021091201", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "azureuser", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "{{sshkey}}", PrivateKey = "{{privateKey}}", }, }, - }), 2L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference() + }), 2L), new DatabaseConfiguration(new ResourceIdentifier("/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/app"), new SapVirtualMachineConfiguration("Standard_M32ts", new SapImageReference { Publisher = "RedHat", Offer = "RHEL-SAP-HA", Sku = "8.2", Version = "8.2.2021091201", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "azureuser", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "{{sshkey}}", PrivateKey = "{{privateKey}}", @@ -3056,7 +2790,7 @@ public async Task CreateOrUpdate_InstallSAPSoftwareOnDistributedSystem() IsSecondaryIPEnabled = true, }, SoftwareConfiguration = new SapInstallWithoutOSConfigSoftwareConfiguration(new Uri("https://teststorageaccount.blob.core.windows.net/sapbits/sapfiles/boms/S41909SPS03_v0011ms/S41909SPS03_v0011ms.yaml"), "/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Storage/storageAccounts/teststorageaccount", "SAP S/4HANA 1909 SPS 03"), - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "sap.bpaas.com", }, @@ -3064,7 +2798,7 @@ public async Task CreateOrUpdate_InstallSAPSoftwareOnDistributedSystem() { Tags = { -["created by"] = "azureuser", +["created by"] = "azureuser" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); @@ -3101,22 +2835,22 @@ public async Task CreateOrUpdate_InstallSAPSoftwareOnSingleServerSystem() // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("eastus2"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentWithOSConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("eastus2"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DeploymentWithOSConfiguration { AppLocation = new AzureLocation("eastus"), - InfrastructureConfiguration = new SingleServerConfiguration("test-rg", new ResourceIdentifier("/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/testsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference() + InfrastructureConfiguration = new SingleServerConfiguration("test-rg", new ResourceIdentifier("/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/testsubnet"), new SapVirtualMachineConfiguration("Standard_E32ds_v4", new SapImageReference { Publisher = "SUSE", Offer = "SLES-SAP", Sku = "12-sp4-gen2", Version = "2022.02.01", - }, new SapOSProfile() + }, new SapOSProfile { AdminUsername = "azureappadmin", - OSConfiguration = new SapLinuxConfiguration() + OSConfiguration = new SapLinuxConfiguration { DisablePasswordAuthentication = true, - SshKeyPair = new SapSshKeyPair() + SshKeyPair = new SapSshKeyPair { PublicKey = "{{sshkey}}", PrivateKey = "{{privateKey}}", @@ -3124,15 +2858,13 @@ public async Task CreateOrUpdate_InstallSAPSoftwareOnSingleServerSystem() }, })), SoftwareConfiguration = new SapInstallWithoutOSConfigSoftwareConfiguration(new Uri("https://teststorageaccount.blob.core.windows.net/sapbits/sapfiles/boms/S41909SPS03_v0011ms/S41909SPS03_v0011ms.yaml"), "/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Storage/storageAccounts/teststorageaccount", "SAP S/4HANA 1909 SPS 03"), - OSSapConfiguration = new OSSapConfiguration() + OSSapConfiguration = new OSSapConfiguration { SapFqdn = "sap.bpaas.com", }, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); SapVirtualInstanceResource result = lro.Value; @@ -3168,7 +2900,7 @@ public async Task CreateOrUpdate_RegisterExistingSAPSystemAsVirtualInstanceForSA // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("northeurope"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DiscoveryConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("northeurope"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DiscoveryConfiguration { CentralServerVmId = new ResourceIdentifier("/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/sapq20scsvm0"), ManagedRgStorageAccountName = "q20saacssgrs", @@ -3177,7 +2909,7 @@ public async Task CreateOrUpdate_RegisterExistingSAPSystemAsVirtualInstanceForSA Tags = { ["createdby"] = "abc@microsoft.com", -["test"] = "abc", +["test"] = "abc" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); @@ -3214,7 +2946,7 @@ public async Task CreateOrUpdate_RegisterExistingSAPSystemAsVirtualInstanceForSA // invoke the operation string sapVirtualInstanceName = "X00"; - SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("northeurope"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DiscoveryConfiguration() + SapVirtualInstanceData data = new SapVirtualInstanceData(new AzureLocation("northeurope"), SapEnvironmentType.NonProd, SapProductType.S4Hana, new DiscoveryConfiguration { CentralServerVmId = new ResourceIdentifier("/subscriptions/8e17e36c-42e9-4cd5-a078-7b44883414e0/resourceGroups/test-rg/providers/Microsoft.Compute/virtualMachines/sapq20scsvm0"), }) @@ -3222,7 +2954,7 @@ public async Task CreateOrUpdate_RegisterExistingSAPSystemAsVirtualInstanceForSA Tags = { ["createdby"] = "abc@microsoft.com", -["test"] = "abc", +["test"] = "abc" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapVirtualInstanceName, data); @@ -3270,10 +3002,10 @@ public async Task Get_SAPVirtualInstancesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SAPVirtualInstancesGet() + public async Task GetAll_SAPVirtualInstancesListByResourceGroup() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPVirtualInstances_Get.json - // this example is just showing the usage of "SAPVirtualInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPVirtualInstances_ListByResourceGroup.json + // this example is just showing the usage of "SAPVirtualInstances_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -3282,7 +3014,7 @@ public async Task Exists_SAPVirtualInstancesGet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "8e17e36c-42e9-4cd5-a078-7b44883414e0"; + string subscriptionId = "6d875e77-e412-4d7d-9af4-8895278b4443"; string resourceGroupName = "test-rg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -3290,16 +3022,22 @@ public async Task Exists_SAPVirtualInstancesGet() // get the collection of this SapVirtualInstanceResource SapVirtualInstanceCollection collection = resourceGroupResource.GetSapVirtualInstances(); - // invoke the operation - string sapVirtualInstanceName = "X00"; - bool result = await collection.ExistsAsync(sapVirtualInstanceName); + // invoke the operation and iterate over the result + await foreach (SapVirtualInstanceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapVirtualInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SAPVirtualInstancesGet() + public async Task Exists_SAPVirtualInstancesGet() { // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPVirtualInstances_Get.json // this example is just showing the usage of "SAPVirtualInstances_Get" operation, for the dependent resources, they will have to be created separately. @@ -3321,29 +3059,17 @@ public async Task GetIfExists_SAPVirtualInstancesGet() // invoke the operation string sapVirtualInstanceName = "X00"; - NullableResponse response = await collection.GetIfExistsAsync(sapVirtualInstanceName); - SapVirtualInstanceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sapVirtualInstanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapVirtualInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SAPVirtualInstancesListByResourceGroup() + public async Task GetIfExists_SAPVirtualInstancesGet() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPVirtualInstances_ListByResourceGroup.json - // this example is just showing the usage of "SAPVirtualInstances_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPVirtualInstances_Get.json + // this example is just showing the usage of "SAPVirtualInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -3352,7 +3078,7 @@ public async Task GetAll_SAPVirtualInstancesListByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "6d875e77-e412-4d7d-9af4-8895278b4443"; + string subscriptionId = "8e17e36c-42e9-4cd5-a078-7b44883414e0"; string resourceGroupName = "test-rg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -3360,17 +3086,23 @@ public async Task GetAll_SAPVirtualInstancesListByResourceGroup() // get the collection of this SapVirtualInstanceResource SapVirtualInstanceCollection collection = resourceGroupResource.GetSapVirtualInstances(); - // invoke the operation and iterate over the result - await foreach (SapVirtualInstanceResource item in collection.GetAllAsync()) + // invoke the operation + string sapVirtualInstanceName = "X00"; + NullableResponse response = await collection.GetIfExistsAsync(sapVirtualInstanceName); + SapVirtualInstanceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SapVirtualInstanceData resourceData = item.Data; + SapVirtualInstanceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapVirtualInstanceResource.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapVirtualInstanceResource.cs index fcdaba7b1c308..e31954a2fc7a3 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapVirtualInstanceResource.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SapVirtualInstanceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Workloads.Models; using NUnit.Framework; @@ -75,37 +74,6 @@ public async Task Delete_SAPVirtualInstancesDelete() Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSapVirtualInstances_SAPVirtualInstancesListBySubscription() - { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPVirtualInstances_ListBySubscription.json - // this example is just showing the usage of "SAPVirtualInstances_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "6d875e77-e412-4d7d-9af4-8895278b4443"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SapVirtualInstanceResource item in subscriptionResource.GetSapVirtualInstancesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapVirtualInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Start_SAPVirtualInstancesStart() @@ -154,7 +122,7 @@ public async Task Stop_SAPVirtualInstancesStop() SapVirtualInstanceResource sapVirtualInstance = client.GetSapVirtualInstanceResource(sapVirtualInstanceResourceId); // invoke the operation - SapStopContent content = new SapStopContent() + SapStopContent content = new SapStopContent { SoftStopTimeoutSeconds = 0L, }; diff --git a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 5ac27266bc352..4adcdf0e17a6b 100644 --- a/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/workloads/Azure.ResourceManager.Workloads/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -316,5 +316,67 @@ public async Task SapAvailabilityZoneDetails_SAPAvailabilityZoneDetailsNortheuro Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSapVirtualInstances_SAPVirtualInstancesListBySubscription() + { + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/sapvirtualinstances/SAPVirtualInstances_ListBySubscription.json + // this example is just showing the usage of "SAPVirtualInstances_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "6d875e77-e412-4d7d-9af4-8895278b4443"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SapVirtualInstanceResource item in subscriptionResource.GetSapVirtualInstancesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapVirtualInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSapMonitors_ListAllSAPMonitorsInASubscription() + { + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/stable/2023-04-01/examples/workloadmonitor/monitors_List.json + // this example is just showing the usage of "monitors_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SapMonitorResource item in subscriptionResource.GetSapMonitorsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapMonitorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } From 1e8b50e8ee91094aeeb23f9a2c6632d5a830ded4 Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 04:00:29 +0000 Subject: [PATCH 08/11] Update SDK code sc_st_8 --- ...ecurityPerimeterConfigurationCollection.cs | 48 +- ...archPrivateEndpointConnectionCollection.cs | 68 +- ...SearchPrivateEndpointConnectionResource.cs | 48 +- .../Samples/Sample_SearchServiceCollection.cs | 115 +- .../Samples/Sample_SearchServiceResource.cs | 268 ++--- ..._SharedSearchServicePrivateLinkResource.cs | 58 +- ...rchServicePrivateLinkResourceCollection.cs | 68 +- .../Sample_SubscriptionResourceExtensions.cs | 56 + ...aptiveApplicationControlGroupCollection.cs | 274 +++-- ...AdaptiveApplicationControlGroupResource.cs | 146 +-- ...mple_AdaptiveNetworkHardeningCollection.cs | 48 +- ...Sample_AdaptiveNetworkHardeningResource.cs | 27 +- ...AdvancedThreatProtectionSettingResource.cs | 2 +- ...ample_AutoProvisioningSettingCollection.cs | 96 +- .../Sample_AutoProvisioningSettingResource.cs | 2 +- .../Sample_ComplianceResultCollection.cs | 76 +- ...le_CustomAssessmentAutomationCollection.cs | 100 +- ...mple_CustomAssessmentAutomationResource.cs | 78 +- ...e_CustomEntityStoreAssignmentCollection.cs | 90 +- ...ple_CustomEntityStoreAssignmentResource.cs | 68 +- ...ple_DefenderForStorageSettingCollection.cs | 96 +- ...ample_DefenderForStorageSettingResource.cs | 2 +- .../Sample_DevOpsConfigurationResource.cs | 105 +- .../Samples/Sample_DevOpsOrgCollection.cs | 110 +- .../Samples/Sample_DevOpsOrgResource.cs | 6 +- .../Samples/Sample_DevOpsProjectCollection.cs | 110 +- .../Samples/Sample_DevOpsProjectResource.cs | 6 +- .../Sample_DevOpsRepositoryCollection.cs | 110 +- .../Sample_DevOpsRepositoryResource.cs | 6 +- .../Sample_DeviceSecurityGroupCollection.cs | 119 +-- .../Sample_DeviceSecurityGroupResource.cs | 41 +- .../Sample_GovernanceAssignmentCollection.cs | 128 +-- .../Sample_GovernanceAssignmentResource.cs | 58 +- .../Sample_GovernanceRuleCollection.cs | 583 +++++------ .../Samples/Sample_GovernanceRuleResource.cs | 203 ++-- ...le_IotSecurityAggregatedAlertCollection.cs | 48 +- ...urityAggregatedRecommendationCollection.cs | 62 +- .../Sample_IotSecuritySolutionCollection.cs | 167 ++- .../Sample_IotSecuritySolutionResource.cs | 120 +-- ...Sample_JitNetworkAccessPolicyCollection.cs | 142 ++- .../Sample_JitNetworkAccessPolicyResource.cs | 128 +-- ...egulatoryComplianceAssessmentCollection.cs | 48 +- ...e_RegulatoryComplianceControlCollection.cs | 48 +- ..._RegulatoryComplianceStandardCollection.cs | 48 +- .../Sample_ResourceGroupResourceExtensions.cs | 64 ++ ...le_ResourceGroupSecurityAlertCollection.cs | 48 +- ...ple_ResourceGroupSecurityTaskCollection.cs | 48 +- .../Samples/Sample_SecureScoreCollection.cs | 48 +- ...SecurityAlertsSuppressionRuleCollection.cs | 149 ++- ...e_SecurityAlertsSuppressionRuleResource.cs | 61 +- .../Sample_SecurityAssessmentCollection.cs | 148 ++- .../Sample_SecurityAssessmentResource.cs | 40 +- .../Sample_SecurityAutomationCollection.cs | 345 +++--- .../Sample_SecurityAutomationResource.cs | 222 ++-- ...e_SecurityCenterApiCollectionCollection.cs | 90 +- ...ple_SecurityCenterApiCollectionResource.cs | 94 +- ...Sample_SecurityCenterLocationCollection.cs | 48 +- .../Sample_SecurityCenterPricingCollection.cs | 328 +++--- .../Sample_SecurityCenterPricingResource.cs | 4 +- ...Sample_SecurityCloudConnectorCollection.cs | 235 +++-- .../Sample_SecurityCloudConnectorResource.cs | 77 +- .../Sample_SecurityComplianceCollection.cs | 72 +- ..._SecurityConnectorApplicationCollection.cs | 122 +-- ...le_SecurityConnectorApplicationResource.cs | 64 +- .../Sample_SecurityConnectorCollection.cs | 123 ++- ..._SecurityConnectorGitHubOwnerCollection.cs | 48 +- ...rityConnectorGitHubRepositoryCollection.cs | 48 +- ..._SecurityConnectorGitLabGroupCollection.cs | 96 +- ...ecurityConnectorGitLabProjectCollection.cs | 48 +- .../Sample_SecurityConnectorResource.cs | 91 +- .../Sample_SecurityContactCollection.cs | 121 ++- .../Samples/Sample_SecurityContactResource.cs | 61 +- .../Sample_SecurityHealthReportCollection.cs | 76 +- .../Sample_SecurityOperatorCollection.cs | 90 +- .../Sample_SecurityOperatorResource.cs | 30 +- .../Sample_SecuritySettingCollection.cs | 96 +- .../Samples/Sample_SecuritySettingResource.cs | 2 +- .../Sample_SecuritySubAssessmentCollection.cs | 56 +- ...mple_SecurityWorkspaceSettingCollection.cs | 98 +- ...Sample_SecurityWorkspaceSettingResource.cs | 36 +- .../Sample_SensitivitySettingResource.cs | 31 +- ...ServerVulnerabilityAssessmentCollection.cs | 88 +- ...e_ServerVulnerabilityAssessmentResource.cs | 30 +- ...lnerabilityAssessmentsSettingCollection.cs | 96 +- ...VulnerabilityAssessmentsSettingResource.cs | 38 +- .../Sample_SoftwareInventoryCollection.cs | 48 +- .../Sample_SoftwareInventoryResource.cs | 32 - ...abilityAssessmentBaselineRuleCollection.cs | 205 ++-- ...erabilityAssessmentBaselineRuleResource.cs | 79 +- ...qlVulnerabilityAssessmentScanCollection.cs | 124 +-- ...ubscriptionAssessmentMetadataCollection.cs | 120 +-- ..._SubscriptionAssessmentMetadataResource.cs | 60 +- .../Sample_SubscriptionResourceExtensions.cs | 313 ++++++ ...ple_SubscriptionSecurityAlertCollection.cs | 95 +- ...bscriptionSecurityApplicationCollection.cs | 122 +-- ...SubscriptionSecurityApplicationResource.cs | 62 +- ...mple_SubscriptionSecurityTaskCollection.cs | 48 +- ...mple_TenantAssessmentMetadataCollection.cs | 65 +- .../Sample_TenantResourceExtensions.cs | 5 +- .../Sample_AzureDevOpsConnectorCollection.cs | 129 ++- .../Sample_AzureDevOpsConnectorResource.cs | 76 +- .../Sample_AzureDevOpsOrgCollection.cs | 102 +- .../Samples/Sample_AzureDevOpsOrgResource.cs | 4 +- .../Sample_AzureDevOpsProjectCollection.cs | 102 +- .../Sample_AzureDevOpsProjectResource.cs | 4 +- .../Sample_AzureDevOpsRepoCollection.cs | 127 ++- .../Sample_GitHubConnectorCollection.cs | 102 +- .../Samples/Sample_GitHubConnectorResource.cs | 76 +- .../Samples/Sample_GitHubOwnerCollection.cs | 92 +- .../Samples/Sample_GitHubRepoCollection.cs | 94 +- .../Sample_SubscriptionResourceExtensions.cs | 81 ++ .../Samples/Sample_ArmClientExtensions.cs | 67 ++ .../Sample_SelfHelpDiagnosticCollection.cs | 24 +- .../Sample_SelfHelpDiagnosticResource.cs | 20 +- ...le_SelfHelpSimplifiedSolutionCollection.cs | 28 +- ...mple_SelfHelpSimplifiedSolutionResource.cs | 34 +- .../Sample_SelfHelpSolutionCollection.cs | 35 +- ...Sample_SelfHelpTroubleshooterCollection.cs | 28 +- .../Sample_SelfHelpTroubleshooterResource.cs | 43 +- .../Sample_TenantResourceExtensions.cs | 13 +- ...Sample_MigrationConfigurationCollection.cs | 70 +- .../Sample_MigrationConfigurationResource.cs | 28 +- ...sterRecoveryAuthorizationRuleCollection.cs | 52 +- ...le_ServiceBusDisasterRecoveryCollection.cs | 68 +- ...mple_ServiceBusDisasterRecoveryResource.cs | 32 +- ...BusNamespaceAuthorizationRuleCollection.cs | 67 +- ...ceBusNamespaceAuthorizationRuleResource.cs | 29 +- .../Sample_ServiceBusNamespaceCollection.cs | 72 +- .../Sample_ServiceBusNamespaceResource.cs | 91 +- ...Sample_ServiceBusNetworkRuleSetResource.cs | 88 +- ...eBusPrivateEndpointConnectionCollection.cs | 76 +- ...iceBusPrivateEndpointConnectionResource.cs | 46 +- ...viceBusQueueAuthorizationRuleCollection.cs | 67 +- ...erviceBusQueueAuthorizationRuleResource.cs | 29 +- .../Sample_ServiceBusQueueCollection.cs | 64 +- .../Samples/Sample_ServiceBusQueueResource.cs | 26 +- .../Sample_ServiceBusRuleCollection.cs | 86 +- .../Samples/Sample_ServiceBusRuleResource.cs | 100 +- ...Sample_ServiceBusSubscriptionCollection.cs | 68 +- .../Sample_ServiceBusSubscriptionResource.cs | 26 +- ...viceBusTopicAuthorizationRuleCollection.cs | 67 +- ...erviceBusTopicAuthorizationRuleResource.cs | 49 +- .../Sample_ServiceBusTopicCollection.cs | 68 +- .../Samples/Sample_ServiceBusTopicResource.cs | 26 +- .../Sample_SubscriptionResourceExtensions.cs | 76 ++ ...mple_ServiceFabricApplicationCollection.cs | 262 +++-- ...Sample_ServiceFabricApplicationResource.cs | 61 +- ..._ServiceFabricApplicationTypeCollection.cs | 92 +- ...le_ServiceFabricApplicationTypeResource.cs | 40 +- ...eFabricApplicationTypeVersionCollection.cs | 94 +- ...iceFabricApplicationTypeVersionResource.cs | 42 +- .../Sample_ServiceFabricClusterCollection.cs | 342 +++--- .../Sample_ServiceFabricClusterResource.cs | 105 +- .../Sample_ServiceFabricServiceCollection.cs | 164 ++- .../Sample_ServiceFabricServiceResource.cs | 51 +- ...e_ServiceFabricVmSizeResourceCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + ...rviceFabricManagedApplicationCollection.cs | 181 ++-- ...ServiceFabricManagedApplicationResource.cs | 90 +- ...eFabricManagedApplicationTypeCollection.cs | 84 +- ...iceFabricManagedApplicationTypeResource.cs | 42 +- ...ManagedApplicationTypeVersionCollection.cs | 90 +- ...icManagedApplicationTypeVersionResource.cs | 42 +- ...e_ServiceFabricManagedClusterCollection.cs | 330 +++--- ...ple_ServiceFabricManagedClusterResource.cs | 74 +- ..._ServiceFabricManagedNodeTypeCollection.cs | 451 ++++---- ...le_ServiceFabricManagedNodeTypeResource.cs | 159 ++- ...e_ServiceFabricManagedServiceCollection.cs | 176 ++-- ...ple_ServiceFabricManagedServiceResource.cs | 42 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Samples/Sample_LinkerResource.cs | 4 +- .../Sample_LinkerResourceCollection.cs | 256 ++--- .../Samples/Sample_AssociationCollection.cs | 98 +- .../Samples/Sample_AssociationResource.cs | 38 +- .../Samples/Sample_FrontendCollection.cs | 92 +- .../Samples/Sample_FrontendResource.cs | 30 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Sample_TrafficControllerCollection.cs | 102 +- .../Sample_TrafficControllerResource.cs | 74 +- .../Samples/Sample_SphereCatalogCollection.cs | 92 +- .../Samples/Sample_SphereCatalogResource.cs | 66 +- .../Sample_SphereCertificateCollection.cs | 48 +- .../Sample_SphereDeploymentCollection.cs | 92 +- .../Sample_SphereDeploymentResource.cs | 44 +- .../Samples/Sample_SphereDeviceCollection.cs | 92 +- .../Sample_SphereDeviceGroupCollection.cs | 100 +- .../Sample_SphereDeviceGroupResource.cs | 37 +- .../Samples/Sample_SphereDeviceResource.cs | 45 +- .../Samples/Sample_SphereImageCollection.cs | 96 +- .../Samples/Sample_SphereImageResource.cs | 38 +- .../Samples/Sample_SphereProductCollection.cs | 92 +- .../Samples/Sample_SphereProductResource.cs | 36 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Samples/Sample_SpringBootAppCollection.cs | 130 +-- .../Samples/Sample_SpringBootAppResource.cs | 65 -- .../Sample_SpringBootServerCollection.cs | 198 ++-- .../Sample_SpringBootServerResource.cs | 65 -- .../Sample_SpringBootSiteCollection.cs | 204 ++-- ...le_SpringBootSiteErrorSummaryCollection.cs | 130 +-- .../Samples/Sample_SpringBootSiteResource.cs | 65 +- .../Sample_SpringBootSiteSummaryCollection.cs | 130 +-- .../Sample_SubscriptionResourceExtensions.cs | 209 ++++ ...ackupShortTermRetentionPolicyCollection.cs | 96 +- ..._BackupShortTermRetentionPolicyResource.cs | 2 +- .../Sample_DataMaskingPolicyResource.cs | 42 +- ...ple_DataWarehouseUserActivityCollection.cs | 62 +- ...abaseAdvancedThreatProtectionCollection.cs | 140 +-- ...atabaseAdvancedThreatProtectionResource.cs | 4 +- .../Samples/Sample_DeletedServerCollection.cs | 62 +- .../Samples/Sample_DeletedServerResource.cs | 32 - ..._DistributedAvailabilityGroupCollection.cs | 106 +- ...le_DistributedAvailabilityGroupResource.cs | 2 +- .../Samples/Sample_ElasticPoolCollection.cs | 444 ++++---- .../Samples/Sample_ElasticPoolResource.cs | 440 ++++---- .../Sample_EncryptionProtectorCollection.cs | 130 +-- .../Sample_EncryptionProtectorResource.cs | 4 +- .../Sample_EndpointCertificateCollection.cs | 48 +- ...dedDatabaseBlobAuditingPolicyCollection.cs | 209 ++-- ...endedDatabaseBlobAuditingPolicyResource.cs | 11 +- ...endedServerBlobAuditingPolicyCollection.cs | 149 ++- ...xtendedServerBlobAuditingPolicyResource.cs | 9 +- .../Samples/Sample_FailoverGroupCollection.cs | 188 ++-- .../Samples/Sample_FailoverGroupResource.cs | 14 +- .../Sample_GeoBackupPolicyCollection.cs | 62 +- .../Samples/Sample_GeoBackupPolicyResource.cs | 20 +- .../Sample_IPv6FirewallRuleCollection.cs | 134 +-- .../Sample_IPv6FirewallRuleResource.cs | 58 +- .../Sample_InstanceFailoverGroupCollection.cs | 132 ++- .../Sample_InstanceFailoverGroupResource.cs | 70 +- .../Samples/Sample_InstancePoolCollection.cs | 162 +-- .../Samples/Sample_InstancePoolResource.cs | 198 ++-- .../Sample_LedgerDigestUploadCollection.cs | 90 +- .../Sample_LedgerDigestUploadResource.cs | 2 +- ...baseTransparentDataEncryptionCollection.cs | 104 +- ...tabaseTransparentDataEncryptionResource.cs | 2 +- ...ample_LongTermRetentionPolicyCollection.cs | 106 +- .../Sample_LongTermRetentionPolicyResource.cs | 2 +- .../Sample_MaintenanceWindowsResource.cs | 9 +- ...ackupShortTermRetentionPolicyCollection.cs | 94 +- ...dBackupShortTermRetentionPolicyResource.cs | 2 +- ...abaseAdvancedThreatProtectionCollection.cs | 140 +-- ...atabaseAdvancedThreatProtectionResource.cs | 4 +- .../Sample_ManagedDatabaseCollection.cs | 278 ++--- .../Sample_ManagedDatabaseColumnCollection.cs | 48 +- .../Samples/Sample_ManagedDatabaseResource.cs | 322 +++--- .../Sample_ManagedDatabaseSchemaCollection.cs | 48 +- ...edDatabaseSecurityAlertPolicyCollection.cs | 158 ++- ...agedDatabaseSecurityAlertPolicyResource.cs | 14 +- .../Sample_ManagedDatabaseTableCollection.cs | 48 +- ...tabaseVulnerabilityAssessmentCollection.cs | 143 ++- ...DatabaseVulnerabilityAssessmentResource.cs | 61 +- ...abilityAssessmentRuleBaselineCollection.cs | 96 +- ...erabilityAssessmentRuleBaselineResource.cs | 50 +- ...seVulnerabilityAssessmentScanCollection.cs | 48 +- ...baseVulnerabilityAssessmentScanResource.cs | 50 +- ..._ManagedInstanceAdministratorCollection.cs | 136 +-- ...le_ManagedInstanceAdministratorResource.cs | 50 +- ...tanceAdvancedThreatProtectionCollection.cs | 124 +-- ...nstanceAdvancedThreatProtectionResource.cs | 4 +- ...anceAzureADOnlyAuthenticationCollection.cs | 90 +- ...stanceAzureADOnlyAuthenticationResource.cs | 38 +- .../Sample_ManagedInstanceCollection.cs | 300 +++--- .../Sample_ManagedInstanceDtcCollection.cs | 155 ++- .../Sample_ManagedInstanceDtcResource.cs | 13 +- ...edInstanceEncryptionProtectorCollection.cs | 130 +-- ...agedInstanceEncryptionProtectorResource.cs | 58 +- .../Sample_ManagedInstanceKeyCollection.cs | 98 +- .../Sample_ManagedInstanceKeyResource.cs | 40 +- ...stanceLongTermRetentionPolicyCollection.cs | 96 +- ...InstanceLongTermRetentionPolicyResource.cs | 2 +- ...mple_ManagedInstanceOperationCollection.cs | 48 +- ...ancePrivateEndpointConnectionCollection.cs | 90 +- ...stancePrivateEndpointConnectionResource.cs | 38 +- ...le_ManagedInstancePrivateLinkCollection.cs | 48 +- .../Samples/Sample_ManagedInstanceResource.cs | 271 ++--- ...anceServerConfigurationOptionCollection.cs | 96 +- ...stanceServerConfigurationOptionResource.cs | 2 +- ...nstanceServerTrustCertificateCollection.cs | 100 +- ...dInstanceServerTrustCertificateResource.cs | 42 +- ...agedInstanceStartStopScheduleCollection.cs | 134 ++- ...anagedInstanceStartStopScheduleResource.cs | 56 +- ...stanceVulnerabilityAssessmentCollection.cs | 169 ++- ...InstanceVulnerabilityAssessmentResource.cs | 67 +- ...ple_ManagedLedgerDigestUploadCollection.cs | 96 +- ...ample_ManagedLedgerDigestUploadResource.cs | 2 +- ...ackupShortTermRetentionPolicyCollection.cs | 94 +- ...bBackupShortTermRetentionPolicyResource.cs | 2 +- .../Sample_ManagedServerDnsAliasCollection.cs | 92 +- .../Sample_ManagedServerDnsAliasResource.cs | 32 +- ...agedServerSecurityAlertPolicyCollection.cs | 142 ++- ...anagedServerSecurityAlertPolicyResource.cs | 14 +- ...agedTransparentDataEncryptionCollection.cs | 98 +- ...anagedTransparentDataEncryptionResource.cs | 2 +- .../Sample_OutboundFirewallRuleCollection.cs | 84 +- .../Sample_OutboundFirewallRuleResource.cs | 36 +- .../Sample_RecommendedActionCollection.cs | 48 +- .../Sample_RecommendedActionResource.cs | 2 +- .../Sample_RecoverableDatabaseCollection.cs | 108 +- ...le_RecoverableManagedDatabaseCollection.cs | 48 +- ...eGroupLongTermRetentionBackupCollection.cs | 48 +- ...rceGroupLongTermRetentionBackupResource.cs | 4 +- ...etentionManagedInstanceBackupCollection.cs | 62 +- ...ple_RestorableDroppedDatabaseCollection.cs | 102 +- ...torableDroppedManagedDatabaseCollection.cs | 48 +- ...erverAdvancedThreatProtectionCollection.cs | 124 +-- ..._ServerAdvancedThreatProtectionResource.cs | 4 +- .../Sample_ServiceObjectiveCollection.cs | 62 +- .../Sample_SqlAgentConfigurationResource.cs | 2 +- .../Sample_SqlDatabaseAdvisorCollection.cs | 56 +- .../Sample_SqlDatabaseAdvisorResource.cs | 2 +- ...mple_SqlDatabaseAutomaticTuningResource.cs | 12 +- ...SqlDatabaseBlobAuditingPolicyCollection.cs | 207 ++-- ...e_SqlDatabaseBlobAuditingPolicyResource.cs | 11 +- .../Samples/Sample_SqlDatabaseCollection.cs | 980 +++++++++--------- .../Sample_SqlDatabaseColumnCollection.cs | 48 +- .../Samples/Sample_SqlDatabaseResource.cs | 878 ++++++++-------- .../Sample_SqlDatabaseSchemaCollection.cs | 48 +- ...qlDatabaseSecurityAlertPolicyCollection.cs | 158 ++- ..._SqlDatabaseSecurityAlertPolicyResource.cs | 14 +- ...lnerabilityAssessmentBaselineCollection.cs | 167 ++- ...VulnerabilityAssessmentBaselineResource.cs | 25 +- ...abilityAssessmentBaselineRuleCollection.cs | 118 +-- ...erabilityAssessmentBaselineRuleResource.cs | 60 +- ...aseSqlVulnerabilityAssessmentCollection.cs | 48 +- ...abaseSqlVulnerabilityAssessmentResource.cs | 36 +- ...qlVulnerabilityAssessmentScanCollection.cs | 48 +- ...erabilityAssessmentScanResultCollection.cs | 52 +- .../Sample_SqlDatabaseTableCollection.cs | 48 +- ...tabaseVulnerabilityAssessmentCollection.cs | 169 ++- ...DatabaseVulnerabilityAssessmentResource.cs | 69 +- ...abilityAssessmentRuleBaselineCollection.cs | 96 +- ...erabilityAssessmentRuleBaselineResource.cs | 50 +- ...seVulnerabilityAssessmentScanCollection.cs | 48 +- ...baseVulnerabilityAssessmentScanResource.cs | 32 +- .../Sample_SqlFirewallRuleCollection.cs | 134 +-- .../Samples/Sample_SqlFirewallRuleResource.cs | 58 +- ..._SqlPrivateEndpointConnectionCollection.cs | 96 +- ...le_SqlPrivateEndpointConnectionResource.cs | 38 +- ...Sample_SqlPrivateLinkResourceCollection.cs | 48 +- .../Sample_SqlServerAdvisorCollection.cs | 56 +- .../Sample_SqlServerAdvisorResource.cs | 2 +- ...Sample_SqlServerAutomaticTuningResource.cs | 12 +- ...SqlServerAzureADAdministratorCollection.cs | 96 +- ...e_SqlServerAzureADAdministratorResource.cs | 44 +- ...rverAzureADOnlyAuthenticationCollection.cs | 90 +- ...ServerAzureADOnlyAuthenticationResource.cs | 38 +- ...e_SqlServerBlobAuditingPolicyCollection.cs | 147 ++- ...ple_SqlServerBlobAuditingPolicyResource.cs | 9 +- .../Samples/Sample_SqlServerCollection.cs | 170 +-- ...le_SqlServerCommunicationLinkCollection.cs | 90 +- ...mple_SqlServerCommunicationLinkResource.cs | 30 +- ...ple_SqlServerConnectionPolicyCollection.cs | 98 +- ...ample_SqlServerConnectionPolicyResource.cs | 2 +- ...ServerDatabaseReplicationLinkCollection.cs | 102 +- ...qlServerDatabaseReplicationLinkResource.cs | 2 +- ...SqlServerDatabaseRestorePointCollection.cs | 150 +-- ...qlServerDevOpsAuditingSettingCollection.cs | 136 +-- ..._SqlServerDevOpsAuditingSettingResource.cs | 4 +- .../Sample_SqlServerDnsAliasCollection.cs | 82 +- .../Sample_SqlServerDnsAliasResource.cs | 30 +- .../Sample_SqlServerJobAgentCollection.cs | 96 +- .../Sample_SqlServerJobAgentResource.cs | 8 +- .../Samples/Sample_SqlServerJobCollection.cs | 134 +-- ...Sample_SqlServerJobCredentialCollection.cs | 98 +- .../Sample_SqlServerJobCredentialResource.cs | 40 +- .../Sample_SqlServerJobExecutionCollection.cs | 111 +- .../Sample_SqlServerJobExecutionResource.cs | 38 +- ...ple_SqlServerJobExecutionStepCollection.cs | 50 +- ...lServerJobExecutionStepTargetCollection.cs | 50 +- .../Samples/Sample_SqlServerJobResource.cs | 44 +- .../Sample_SqlServerJobStepCollection.cs | 172 +-- .../Sample_SqlServerJobStepResource.cs | 64 +- ...ample_SqlServerJobTargetGroupCollection.cs | 173 ++-- .../Sample_SqlServerJobTargetGroupResource.cs | 77 +- .../Sample_SqlServerJobVersionCollection.cs | 48 +- ...ample_SqlServerJobVersionStepCollection.cs | 48 +- .../Samples/Sample_SqlServerKeyCollection.cs | 98 +- .../Samples/Sample_SqlServerKeyResource.cs | 40 +- .../Samples/Sample_SqlServerResource.cs | 326 ++---- ..._SqlServerSecurityAlertPolicyCollection.cs | 142 ++- ...le_SqlServerSecurityAlertPolicyResource.cs | 14 +- ...lnerabilityAssessmentBaselineCollection.cs | 159 ++- ...VulnerabilityAssessmentBaselineResource.cs | 25 +- ...abilityAssessmentBaselineRuleCollection.cs | 118 +-- ...erabilityAssessmentBaselineRuleResource.cs | 60 +- ...verSqlVulnerabilityAssessmentCollection.cs | 96 +- ...erverSqlVulnerabilityAssessmentResource.cs | 46 +- ...qlVulnerabilityAssessmentScanCollection.cs | 48 +- ...erabilityAssessmentScanResultCollection.cs | 52 +- .../Sample_SqlServerTrustGroupCollection.cs | 98 +- .../Sample_SqlServerTrustGroupResource.cs | 46 +- ...e_SqlServerVirtualNetworkRuleCollection.cs | 92 +- ...ple_SqlServerVirtualNetworkRuleResource.cs | 40 +- ...ServerVulnerabilityAssessmentCollection.cs | 169 ++- ...qlServerVulnerabilityAssessmentResource.cs | 67 +- .../Samples/Sample_SqlTimeZoneCollection.cs | 48 +- ...iptionLongTermRetentionBackupCollection.cs | 48 +- ...criptionLongTermRetentionBackupResource.cs | 4 +- ...etentionManagedInstanceBackupCollection.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 321 ++++++ .../Sample_SubscriptionUsageCollection.cs | 48 +- .../Samples/Sample_SyncAgentCollection.cs | 124 +-- .../Samples/Sample_SyncAgentResource.cs | 44 +- .../Samples/Sample_SyncGroupCollection.cs | 140 +-- .../Samples/Sample_SyncGroupResource.cs | 162 ++- .../Samples/Sample_SyncMemberCollection.cs | 148 +-- .../Samples/Sample_SyncMemberResource.cs | 2 +- .../Sample_VirtualClusterCollection.cs | 48 +- .../Samples/Sample_VirtualClusterResource.cs | 36 +- .../Sample_WorkloadClassifierCollection.cs | 140 +-- .../Sample_WorkloadClassifierResource.cs | 54 +- .../Samples/Sample_WorkloadGroupCollection.cs | 138 +-- .../Samples/Sample_WorkloadGroupResource.cs | 58 +- ...ple_AvailabilityGroupListenerCollection.cs | 177 ++-- ...ample_AvailabilityGroupListenerResource.cs | 81 +- .../Samples/Sample_SqlVmCollection.cs | 272 +++-- .../Samples/Sample_SqlVmGroupCollection.cs | 122 +-- .../Samples/Sample_SqlVmGroupResource.cs | 36 +- .../Generated/Samples/Sample_SqlVmResource.cs | 36 +- .../Sample_SubscriptionResourceExtensions.cs | 81 ++ ...ple_StandbyContainerGroupPoolCollection.cs | 121 ++- ...ample_StandbyContainerGroupPoolResource.cs | 47 +- ...ContainerGroupPoolRuntimeViewCollection.cs | 62 +- .../Sample_StandbyVirtualMachineCollection.cs | 62 +- ...ple_StandbyVirtualMachinePoolCollection.cs | 108 +- ...ample_StandbyVirtualMachinePoolResource.cs | 40 +- ...VirtualMachinePoolRuntimeViewCollection.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 81 ++ .../Samples/Sample_BlobContainerCollection.cs | 206 ++-- .../Samples/Sample_BlobContainerResource.cs | 95 +- .../Sample_BlobInventoryPolicyResource.cs | 139 +-- .../Samples/Sample_BlobServiceResource.cs | 118 +-- .../Samples/Sample_DeletedAccountResource.cs | 32 - .../Sample_EncryptionScopeCollection.cs | 64 +- .../Samples/Sample_EncryptionScopeResource.cs | 32 +- .../Samples/Sample_FileServiceResource.cs | 95 +- .../Samples/Sample_FileShareCollection.cs | 266 ++--- .../Samples/Sample_FileShareResource.cs | 133 ++- .../Sample_ImmutabilityPolicyResource.cs | 82 +- ...ecurityPerimeterConfigurationCollection.cs | 48 +- ...ample_ObjectReplicationPolicyCollection.cs | 326 +++--- .../Sample_ObjectReplicationPolicyResource.cs | 120 +-- .../Samples/Sample_QueueServiceResource.cs | 65 +- .../Sample_StorageAccountCollection.cs | 425 ++++---- ...ample_StorageAccountLocalUserCollection.cs | 226 ++-- .../Sample_StorageAccountLocalUserResource.cs | 82 +- ..._StorageAccountManagementPolicyResource.cs | 313 +++--- ...ample_StorageAccountMigrationCollection.cs | 60 +- .../Samples/Sample_StorageAccountResource.cs | 223 ++-- ...ragePrivateEndpointConnectionCollection.cs | 112 +- ...toragePrivateEndpointConnectionResource.cs | 54 +- .../Samples/Sample_StorageQueueCollection.cs | 70 +- .../Samples/Sample_StorageQueueResource.cs | 38 +- .../Sample_StorageTaskAssignmentCollection.cs | 77 +- .../Sample_StorageTaskAssignmentResource.cs | 93 +- .../Sample_SubscriptionResourceExtensions.cs | 87 ++ .../Samples/Sample_TableCollection.cs | 77 +- .../Generated/Samples/Sample_TableResource.cs | 85 +- .../Samples/Sample_TableServiceResource.cs | 65 +- .../Samples/Sample_StorageTaskCollection.cs | 75 +- .../Samples/Sample_StorageTaskResource.cs | 246 +---- .../Sample_SubscriptionResourceExtensions.cs | 204 ++++ .../Samples/Sample_AmlFileSystemCollection.cs | 176 ++-- .../Samples/Sample_AmlFileSystemResource.cs | 72 +- .../Samples/Sample_StorageCacheCollection.cs | 324 +++--- .../Sample_StorageCacheImportJobCollection.cs | 105 +- .../Sample_StorageCacheImportJobResource.cs | 32 +- .../Samples/Sample_StorageCacheResource.cs | 142 +-- .../Samples/Sample_StorageTargetCollection.cs | 236 ++--- .../Samples/Sample_StorageTargetResource.cs | 102 +- .../Sample_SubscriptionResourceExtensions.cs | 64 +- 471 files changed, 21134 insertions(+), 22658 deletions(-) create mode 100644 sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_ArmClientExtensions.cs create mode 100644 sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs diff --git a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs index 538af92123f5d..0afe9befb5283 100644 --- a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs +++ b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkSecurityPerimeterConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNSPConfigsBySearchService() + public async Task Get_GetAnNSPConfigByName() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurationsListByService.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurationsGet.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListNSPConfigsBySearchService() // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = searchService.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string nspConfigName = "00000001-2222-3333-4444-111144444444.assoc1"; + NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(nspConfigName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnNSPConfigByName() + public async Task GetAll_ListNSPConfigsBySearchService() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurationsGet.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/NetworkSecurityPerimeterConfigurationsListByService.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetAnNSPConfigByName() // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = searchService.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation - string nspConfigName = "00000001-2222-3333-4444-111144444444.assoc1"; - NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(nspConfigName); + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchPrivateEndpointConnectionCollection.cs b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchPrivateEndpointConnectionCollection.cs index 7653788e4a6de..40d8efc5ab294 100644 --- a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchPrivateEndpointConnectionCollection.cs +++ b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchPrivateEndpointConnectionCollection.cs @@ -41,11 +41,11 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionUpdate() // invoke the operation string privateEndpointConnectionName = "testEndpoint.50bf4fbe-d7c1-4b48-a642-4f5892642546"; - SearchPrivateEndpointConnectionData data = new SearchPrivateEndpointConnectionData() + SearchPrivateEndpointConnectionData data = new SearchPrivateEndpointConnectionData { - Properties = new SearchServicePrivateEndpointConnectionProperties() + Properties = new SearchServicePrivateEndpointConnectionProperties { - ConnectionState = new SearchServicePrivateLinkServiceConnectionState() + ConnectionState = new SearchServicePrivateLinkServiceConnectionState { Status = SearchServicePrivateLinkServiceConnectionStatus.Rejected, Description = "Rejected for some reason.", @@ -98,10 +98,10 @@ public async Task Get_PrivateEndpointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionGet() + public async Task GetAll_ListPrivateEndpointConnectionsByService() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/ListPrivateEndpointConnectionsByService.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -119,16 +119,22 @@ public async Task Exists_PrivateEndpointConnectionGet() // get the collection of this SearchPrivateEndpointConnectionResource SearchPrivateEndpointConnectionCollection collection = searchService.GetSearchPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "testEndpoint.50bf4fbe-d7c1-4b48-a642-4f5892642546"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (SearchPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SearchPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionGet() + public async Task Exists_PrivateEndpointConnectionGet() { // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -151,29 +157,17 @@ public async Task GetIfExists_PrivateEndpointConnectionGet() // invoke the operation string privateEndpointConnectionName = "testEndpoint.50bf4fbe-d7c1-4b48-a642-4f5892642546"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - SearchPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SearchPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateEndpointConnectionsByService() + public async Task GetIfExists_PrivateEndpointConnectionGet() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/ListPrivateEndpointConnectionsByService.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,17 +185,23 @@ public async Task GetAll_ListPrivateEndpointConnectionsByService() // get the collection of this SearchPrivateEndpointConnectionResource SearchPrivateEndpointConnectionCollection collection = searchService.GetSearchPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (SearchPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "testEndpoint.50bf4fbe-d7c1-4b48-a642-4f5892642546"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + SearchPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SearchPrivateEndpointConnectionData resourceData = item.Data; + SearchPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchPrivateEndpointConnectionResource.cs b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchPrivateEndpointConnectionResource.cs index 90bc76fe31f0c..32c1717a8f70c 100644 --- a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchPrivateEndpointConnectionResource.cs +++ b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SearchPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionUpdate() + public async Task Get_PrivateEndpointConnectionGet() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/UpdatePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,19 +38,7 @@ public async Task Update_PrivateEndpointConnectionUpdate() SearchPrivateEndpointConnectionResource searchPrivateEndpointConnection = client.GetSearchPrivateEndpointConnectionResource(searchPrivateEndpointConnectionResourceId); // invoke the operation - SearchPrivateEndpointConnectionData data = new SearchPrivateEndpointConnectionData() - { - Properties = new SearchServicePrivateEndpointConnectionProperties() - { - ConnectionState = new SearchServicePrivateLinkServiceConnectionState() - { - Status = SearchServicePrivateLinkServiceConnectionStatus.Rejected, - Description = "Rejected for some reason.", - }, - }, - }; - ArmOperation lro = await searchPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - SearchPrivateEndpointConnectionResource result = lro.Value; + SearchPrivateEndpointConnectionResource result = await searchPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -61,10 +49,10 @@ public async Task Update_PrivateEndpointConnectionUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionGet() + public async Task Delete_PrivateEndpointConnectionDelete() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/DeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -81,7 +69,8 @@ public async Task Get_PrivateEndpointConnectionGet() SearchPrivateEndpointConnectionResource searchPrivateEndpointConnection = client.GetSearchPrivateEndpointConnectionResource(searchPrivateEndpointConnectionResourceId); // invoke the operation - SearchPrivateEndpointConnectionResource result = await searchPrivateEndpointConnection.GetAsync(); + ArmOperation lro = await searchPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + SearchPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +81,10 @@ public async Task Get_PrivateEndpointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionDelete() + public async Task Update_PrivateEndpointConnectionUpdate() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/DeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/UpdatePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,7 +101,18 @@ public async Task Delete_PrivateEndpointConnectionDelete() SearchPrivateEndpointConnectionResource searchPrivateEndpointConnection = client.GetSearchPrivateEndpointConnectionResource(searchPrivateEndpointConnectionResourceId); // invoke the operation - ArmOperation lro = await searchPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + SearchPrivateEndpointConnectionData data = new SearchPrivateEndpointConnectionData + { + Properties = new SearchServicePrivateEndpointConnectionProperties + { + ConnectionState = new SearchServicePrivateLinkServiceConnectionState + { + Status = SearchServicePrivateLinkServiceConnectionStatus.Rejected, + Description = "Rejected for some reason.", + }, + }, + }; + ArmOperation lro = await searchPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); SearchPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchServiceCollection.cs b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchServiceCollection.cs index 13ef9e3dfce3b..2828300f54365 100644 --- a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchServiceCollection.cs +++ b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchServiceCollection.cs @@ -50,7 +50,7 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateService() HostingMode = SearchServiceHostingMode.Default, Tags = { -["app-name"] = "My e-commerce app", +["app-name"] = "My e-commerce app" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data); @@ -93,13 +93,13 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateServiceAuthOptions() ReplicaCount = 3, PartitionCount = 1, HostingMode = SearchServiceHostingMode.Default, - AuthOptions = new SearchAadAuthDataPlaneAuthOptions() + AuthOptions = new SearchAadAuthDataPlaneAuthOptions { AadAuthFailureMode = SearchAadAuthFailureMode.Http401WithBearerChallenge, }, Tags = { -["app-name"] = "My e-commerce app", +["app-name"] = "My e-commerce app" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data); @@ -145,7 +145,7 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateServiceDisableLocalAuth() IsLocalAuthDisabled = true, Tags = { -["app-name"] = "My e-commerce app", +["app-name"] = "My e-commerce app" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data); @@ -191,7 +191,7 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateServiceToAllowAccessFromPri PublicInternetAccess = SearchServicePublicInternetAccess.Disabled, Tags = { -["app-name"] = "My e-commerce app", +["app-name"] = "My e-commerce app" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data); @@ -234,22 +234,19 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateServiceToAllowAccessFromPub ReplicaCount = 1, PartitionCount = 1, HostingMode = SearchServiceHostingMode.Default, - NetworkRuleSet = new SearchServiceNetworkRuleSet() + NetworkRuleSet = new SearchServiceNetworkRuleSet { - IPRules = -{ -new SearchServiceIPRule() + IPRules = {new SearchServiceIPRule { Value = "123.4.5.6", -},new SearchServiceIPRule() +}, new SearchServiceIPRule { Value = "123.4.6.0/18", -} -}, +}}, }, Tags = { -["app-name"] = "My e-commerce app", +["app-name"] = "My e-commerce app" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data); @@ -292,23 +289,20 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateServiceToAllowAccessFromPub ReplicaCount = 1, PartitionCount = 1, HostingMode = SearchServiceHostingMode.Default, - NetworkRuleSet = new SearchServiceNetworkRuleSet() + NetworkRuleSet = new SearchServiceNetworkRuleSet { - IPRules = -{ -new SearchServiceIPRule() + IPRules = {new SearchServiceIPRule { Value = "123.4.5.6", -},new SearchServiceIPRule() +}, new SearchServiceIPRule { Value = "123.4.6.0/18", -} -}, +}}, Bypass = SearchBypass.AzurePortal, }, Tags = { -["app-name"] = "My e-commerce app", +["app-name"] = "My e-commerce app" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data); @@ -351,13 +345,13 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateServiceWithCmkEnforcement() ReplicaCount = 3, PartitionCount = 1, HostingMode = SearchServiceHostingMode.Default, - EncryptionWithCmk = new SearchEncryptionWithCmk() + EncryptionWithCmk = new SearchEncryptionWithCmk { Enforcement = SearchEncryptionWithCmkEnforcement.Enabled, }, Tags = { -["app-name"] = "My e-commerce app", +["app-name"] = "My e-commerce app" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data); @@ -400,13 +394,10 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateServiceWithDataExfiltration ReplicaCount = 3, PartitionCount = 1, HostingMode = SearchServiceHostingMode.Default, - DisabledDataExfiltrationOptions = -{ -SearchDisabledDataExfiltrationOption.All -}, + DisabledDataExfiltrationOptions = { SearchDisabledDataExfiltrationOption.All }, Tags = { -["app-name"] = "My e-commerce app", +["app-name"] = "My e-commerce app" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data); @@ -450,7 +441,7 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateServiceWithIdentity() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-mi")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/user-mi")] = new UserAssignedIdentity() }, }, ReplicaCount = 3, @@ -458,7 +449,7 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateServiceWithIdentity() HostingMode = SearchServiceHostingMode.Default, Tags = { -["app-name"] = "My e-commerce app", +["app-name"] = "My e-commerce app" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data); @@ -504,7 +495,7 @@ public async Task CreateOrUpdate_SearchCreateOrUpdateWithSemanticSearch() SemanticSearch = SearchSemanticSearch.Free, Tags = { -["app-name"] = "My e-commerce app", +["app-name"] = "My e-commerce app" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, searchServiceName, data); @@ -552,10 +543,10 @@ public async Task Get_SearchGetService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SearchGetService() + public async Task GetAll_SearchListServicesByResourceGroup() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchGetService.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchListServicesByResourceGroup.json + // this example is just showing the usage of "Services_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -572,16 +563,22 @@ public async Task Exists_SearchGetService() // get the collection of this SearchServiceResource SearchServiceCollection collection = resourceGroupResource.GetSearchServices(); - // invoke the operation - string searchServiceName = "mysearchservice"; - bool result = await collection.ExistsAsync(searchServiceName); + // invoke the operation and iterate over the result + await foreach (SearchServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SearchServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SearchGetService() + public async Task Exists_SearchGetService() { // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchGetService.json // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. @@ -603,29 +600,17 @@ public async Task GetIfExists_SearchGetService() // invoke the operation string searchServiceName = "mysearchservice"; - NullableResponse response = await collection.GetIfExistsAsync(searchServiceName); - SearchServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(searchServiceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SearchServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SearchListServicesByResourceGroup() + public async Task GetIfExists_SearchGetService() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchListServicesByResourceGroup.json - // this example is just showing the usage of "Services_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchGetService.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -642,17 +627,23 @@ public async Task GetAll_SearchListServicesByResourceGroup() // get the collection of this SearchServiceResource SearchServiceCollection collection = resourceGroupResource.GetSearchServices(); - // invoke the operation and iterate over the result - await foreach (SearchServiceResource item in collection.GetAllAsync()) + // invoke the operation + string searchServiceName = "mysearchservice"; + NullableResponse response = await collection.GetIfExistsAsync(searchServiceName); + SearchServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SearchServiceData resourceData = item.Data; + SearchServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchServiceResource.cs b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchServiceResource.cs index b9337df46136c..6f2775314b74f 100644 --- a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchServiceResource.cs +++ b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SearchServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Search.Models; using NUnit.Framework; @@ -20,63 +19,10 @@ public partial class Sample_SearchServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAdminKey_SearchGetAdminKeys() - { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchGetAdminKeys.json - // this example is just showing the usage of "AdminKeys_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SearchServiceResource created on azure - // for more information of creating SearchServiceResource, please refer to the document of SearchServiceResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string searchServiceName = "mysearchservice"; - ResourceIdentifier searchServiceResourceId = SearchServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, searchServiceName); - SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); - - // invoke the operation - SearchServiceAdminKeyResult result = await searchService.GetAdminKeyAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task RegenerateAdminKey_SearchRegenerateAdminKey() - { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchRegenerateAdminKey.json - // this example is just showing the usage of "AdminKeys_Regenerate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SearchServiceResource created on azure - // for more information of creating SearchServiceResource, please refer to the document of SearchServiceResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string searchServiceName = "mysearchservice"; - ResourceIdentifier searchServiceResourceId = SearchServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, searchServiceName); - SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); - - // invoke the operation - SearchServiceAdminKeyKind keyKind = SearchServiceAdminKeyKind.Primary; - SearchServiceAdminKeyResult result = await searchService.RegenerateAdminKeyAsync(keyKind); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateQueryKey_SearchCreateQueryKey() + public async Task Get_SearchGetService() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateQueryKey.json - // this example is just showing the usage of "QueryKeys_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchGetService.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,47 +38,21 @@ public async Task CreateQueryKey_SearchCreateQueryKey() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - string name = "An API key granting read-only access to the documents collection of an index."; - SearchServiceQueryKey result = await searchService.CreateQueryKeyAsync(name); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetQueryKeysBySearchService_SearchListQueryKeysBySearchService() - { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchListQueryKeysBySearchService.json - // this example is just showing the usage of "QueryKeys_ListBySearchService" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SearchServiceResource created on azure - // for more information of creating SearchServiceResource, please refer to the document of SearchServiceResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string searchServiceName = "mysearchservice"; - ResourceIdentifier searchServiceResourceId = SearchServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, searchServiceName); - SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); - - // invoke the operation and iterate over the result - await foreach (SearchServiceQueryKey item in searchService.GetQueryKeysBySearchServiceAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + SearchServiceResource result = await searchService.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SearchServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task DeleteQueryKey_SearchDeleteQueryKey() + public async Task Delete_SearchDeleteService() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchDeleteQueryKey.json - // this example is just showing the usage of "QueryKeys_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchDeleteService.json + // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,8 +68,7 @@ public async Task DeleteQueryKey_SearchDeleteQueryKey() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - string key = ""; - await searchService.DeleteQueryKeyAsync(key); + await searchService.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } @@ -175,13 +94,13 @@ public async Task Update_SearchUpdateService() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServicePatch patch = new SearchServicePatch(new AzureLocation("placeholder")) + SearchServicePatch patch = new SearchServicePatch(default) { ReplicaCount = 2, Tags = { ["app-name"] = "My e-commerce app", -["new-tag"] = "Adding a new tag", +["new-tag"] = "Adding a new tag" }, }; SearchServiceResource result = await searchService.UpdateAsync(patch); @@ -214,17 +133,17 @@ public async Task Update_SearchUpdateServiceAuthOptions() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServicePatch patch = new SearchServicePatch(new AzureLocation("placeholder")) + SearchServicePatch patch = new SearchServicePatch(default) { ReplicaCount = 2, - AuthOptions = new SearchAadAuthDataPlaneAuthOptions() + AuthOptions = new SearchAadAuthDataPlaneAuthOptions { AadAuthFailureMode = SearchAadAuthFailureMode.Http401WithBearerChallenge, }, Tags = { ["app-name"] = "My e-commerce app", -["new-tag"] = "Adding a new tag", +["new-tag"] = "Adding a new tag" }, }; SearchServiceResource result = await searchService.UpdateAsync(patch); @@ -257,14 +176,14 @@ public async Task Update_SearchUpdateServiceDisableLocalAuth() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServicePatch patch = new SearchServicePatch(new AzureLocation("placeholder")) + SearchServicePatch patch = new SearchServicePatch(default) { ReplicaCount = 2, IsLocalAuthDisabled = true, Tags = { ["app-name"] = "My e-commerce app", -["new-tag"] = "Adding a new tag", +["new-tag"] = "Adding a new tag" }, }; SearchServiceResource result = await searchService.UpdateAsync(patch); @@ -297,7 +216,7 @@ public async Task Update_SearchUpdateServiceToAllowAccessFromPrivateEndpoints() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServicePatch patch = new SearchServicePatch(new AzureLocation("placeholder")) + SearchServicePatch patch = new SearchServicePatch(default) { ReplicaCount = 1, PartitionCount = 1, @@ -333,23 +252,20 @@ public async Task Update_SearchUpdateServiceToAllowAccessFromPublicCustomIPs() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServicePatch patch = new SearchServicePatch(new AzureLocation("placeholder")) + SearchServicePatch patch = new SearchServicePatch(default) { ReplicaCount = 3, PartitionCount = 1, PublicInternetAccess = SearchServicePublicInternetAccess.Enabled, - NetworkRuleSet = new SearchServiceNetworkRuleSet() + NetworkRuleSet = new SearchServiceNetworkRuleSet { - IPRules = -{ -new SearchServiceIPRule() + IPRules = {new SearchServiceIPRule { Value = "123.4.5.6", -},new SearchServiceIPRule() +}, new SearchServiceIPRule { Value = "123.4.6.0/18", -} -}, +}}, }, }; SearchServiceResource result = await searchService.UpdateAsync(patch); @@ -382,23 +298,20 @@ public async Task Update_SearchUpdateServiceToAllowAccessFromPublicCustomIPsAndB SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServicePatch patch = new SearchServicePatch(new AzureLocation("placeholder")) + SearchServicePatch patch = new SearchServicePatch(default) { ReplicaCount = 3, PartitionCount = 1, PublicInternetAccess = SearchServicePublicInternetAccess.Enabled, - NetworkRuleSet = new SearchServiceNetworkRuleSet() + NetworkRuleSet = new SearchServiceNetworkRuleSet { - IPRules = -{ -new SearchServiceIPRule() + IPRules = {new SearchServiceIPRule { Value = "123.4.5.6", -},new SearchServiceIPRule() +}, new SearchServiceIPRule { Value = "123.4.6.0/18", -} -}, +}}, Bypass = SearchBypass.AzurePortal, }, }; @@ -432,7 +345,7 @@ public async Task Update_SearchUpdateServiceToRemoveIdentity() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServicePatch patch = new SearchServicePatch(new AzureLocation("placeholder")) + SearchServicePatch patch = new SearchServicePatch(default) { SearchSkuName = SearchServiceSkuName.Standard, Identity = new ManagedServiceIdentity("None"), @@ -467,17 +380,17 @@ public async Task Update_SearchUpdateServiceWithCmkEnforcement() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServicePatch patch = new SearchServicePatch(new AzureLocation("placeholder")) + SearchServicePatch patch = new SearchServicePatch(default) { ReplicaCount = 2, - EncryptionWithCmk = new SearchEncryptionWithCmk() + EncryptionWithCmk = new SearchEncryptionWithCmk { Enforcement = SearchEncryptionWithCmkEnforcement.Enabled, }, Tags = { ["app-name"] = "My e-commerce app", -["new-tag"] = "Adding a new tag", +["new-tag"] = "Adding a new tag" }, }; SearchServiceResource result = await searchService.UpdateAsync(patch); @@ -510,17 +423,14 @@ public async Task Update_SearchUpdateServiceWithDataExfiltration() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServicePatch patch = new SearchServicePatch(new AzureLocation("placeholder")) + SearchServicePatch patch = new SearchServicePatch(default) { ReplicaCount = 2, - DisabledDataExfiltrationOptions = -{ -SearchDisabledDataExfiltrationOption.All -}, + DisabledDataExfiltrationOptions = { SearchDisabledDataExfiltrationOption.All }, Tags = { ["app-name"] = "My e-commerce app", -["new-tag"] = "Adding a new tag", +["new-tag"] = "Adding a new tag" }, }; SearchServiceResource result = await searchService.UpdateAsync(patch); @@ -553,14 +463,14 @@ public async Task Update_SearchUpdateServiceWithSemanticSearch() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServicePatch patch = new SearchServicePatch(new AzureLocation("placeholder")) + SearchServicePatch patch = new SearchServicePatch(default) { ReplicaCount = 2, SemanticSearch = SearchSemanticSearch.Standard, Tags = { ["app-name"] = "My e-commerce app", -["new-tag"] = "Adding a new tag", +["new-tag"] = "Adding a new tag" }, }; SearchServiceResource result = await searchService.UpdateAsync(patch); @@ -574,10 +484,10 @@ public async Task Update_SearchUpdateServiceWithSemanticSearch() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SearchGetService() + public async Task GetAdminKey_SearchGetAdminKeys() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchGetService.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchGetAdminKeys.json + // this example is just showing the usage of "AdminKeys_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -593,21 +503,17 @@ public async Task Get_SearchGetService() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServiceResource result = await searchService.GetAsync(); + SearchServiceAdminKeyResult result = await searchService.GetAdminKeyAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SearchServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SearchDeleteService() + public async Task RegenerateAdminKey_SearchRegenerateAdminKey() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchDeleteService.json - // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchRegenerateAdminKey.json + // this example is just showing the usage of "AdminKeys_Regenerate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -623,37 +529,63 @@ public async Task Delete_SearchDeleteService() SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - await searchService.DeleteAsync(WaitUntil.Completed); + SearchServiceAdminKeyKind keyKind = SearchServiceAdminKeyKind.Primary; + SearchServiceAdminKeyResult result = await searchService.RegenerateAdminKeyAsync(keyKind); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSearchServices_SearchListServicesBySubscription() + public async Task CreateQueryKey_SearchCreateQueryKey() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchListServicesBySubscription.json - // this example is just showing the usage of "Services_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCreateQueryKey.json + // this example is just showing the usage of "QueryKeys_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this SearchServiceResource created on azure + // for more information of creating SearchServiceResource, please refer to the document of SearchServiceResource string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rg1"; + string searchServiceName = "mysearchservice"; + ResourceIdentifier searchServiceResourceId = SearchServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, searchServiceName); + SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); + + // invoke the operation + string name = "An API key granting read-only access to the documents collection of an index."; + SearchServiceQueryKey result = await searchService.CreateQueryKeyAsync(name); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetQueryKeysBySearchService_SearchListQueryKeysBySearchService() + { + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchListQueryKeysBySearchService.json + // this example is just showing the usage of "QueryKeys_ListBySearchService" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SearchServiceResource created on azure + // for more information of creating SearchServiceResource, please refer to the document of SearchServiceResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string searchServiceName = "mysearchservice"; + ResourceIdentifier searchServiceResourceId = SearchServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, searchServiceName); + SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation and iterate over the result - await foreach (SearchServiceResource item in subscriptionResource.GetSearchServicesAsync()) + await foreach (SearchServiceQueryKey item in searchService.GetQueryKeysBySearchServiceAsync()) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SearchServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {item}"); } Console.WriteLine("Succeeded"); @@ -661,27 +593,29 @@ public async Task GetSearchServices_SearchListServicesBySubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task CheckSearchServiceNameAvailability_SearchCheckNameAvailability() + public async Task DeleteQueryKey_SearchDeleteQueryKey() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCheckNameAvailability.json - // this example is just showing the usage of "Services_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchDeleteQueryKey.json + // this example is just showing the usage of "QueryKeys_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this SearchServiceResource created on azure + // for more information of creating SearchServiceResource, please refer to the document of SearchServiceResource string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rg1"; + string searchServiceName = "mysearchservice"; + ResourceIdentifier searchServiceResourceId = SearchServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, searchServiceName); + SearchServiceResource searchService = client.GetSearchServiceResource(searchServiceResourceId); // invoke the operation - SearchServiceNameAvailabilityContent content = new SearchServiceNameAvailabilityContent("mysearchservice"); - SearchServiceNameAvailabilityResult result = await subscriptionResource.CheckSearchServiceNameAvailabilityAsync(content); + string key = ""; + await searchService.DeleteQueryKeyAsync(key); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SharedSearchServicePrivateLinkResource.cs b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SharedSearchServicePrivateLinkResource.cs index 469522c1a9342..f30a77fccfa98 100644 --- a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SharedSearchServicePrivateLinkResource.cs +++ b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SharedSearchServicePrivateLinkResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SharedSearchServicePrivateLinkResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SharedPrivateLinkResourceCreateOrUpdate() + public async Task Get_SharedPrivateLinkResourceGet() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/CreateOrUpdateSharedPrivateLinkResource.json - // this example is just showing the usage of "SharedPrivateLinkResources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetSharedPrivateLinkResource.json + // this example is just showing the usage of "SharedPrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,18 +38,7 @@ public async Task Update_SharedPrivateLinkResourceCreateOrUpdate() SharedSearchServicePrivateLinkResource sharedSearchServicePrivateLinkResource = client.GetSharedSearchServicePrivateLinkResource(sharedSearchServicePrivateLinkResourceId); // invoke the operation - SharedSearchServicePrivateLinkResourceData data = new SharedSearchServicePrivateLinkResourceData() - { - Properties = new SharedSearchServicePrivateLinkResourceProperties() - { - PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/storageAccountName"), - GroupId = "blob", - RequestMessage = "please approve", - ResourceRegion = null, - }, - }; - ArmOperation lro = await sharedSearchServicePrivateLinkResource.UpdateAsync(WaitUntil.Completed, data); - SharedSearchServicePrivateLinkResource result = lro.Value; + SharedSearchServicePrivateLinkResource result = await sharedSearchServicePrivateLinkResource.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -60,10 +49,10 @@ public async Task Update_SharedPrivateLinkResourceCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SharedPrivateLinkResourceGet() + public async Task Delete_SharedPrivateLinkResourceDelete() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetSharedPrivateLinkResource.json - // this example is just showing the usage of "SharedPrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/DeleteSharedPrivateLinkResource.json + // this example is just showing the usage of "SharedPrivateLinkResources_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,21 +69,17 @@ public async Task Get_SharedPrivateLinkResourceGet() SharedSearchServicePrivateLinkResource sharedSearchServicePrivateLinkResource = client.GetSharedSearchServicePrivateLinkResource(sharedSearchServicePrivateLinkResourceId); // invoke the operation - SharedSearchServicePrivateLinkResource result = await sharedSearchServicePrivateLinkResource.GetAsync(); + await sharedSearchServicePrivateLinkResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SharedSearchServicePrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SharedPrivateLinkResourceDelete() + public async Task Update_SharedPrivateLinkResourceCreateOrUpdate() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/DeleteSharedPrivateLinkResource.json - // this example is just showing the usage of "SharedPrivateLinkResources_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/CreateOrUpdateSharedPrivateLinkResource.json + // this example is just showing the usage of "SharedPrivateLinkResources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +96,24 @@ public async Task Delete_SharedPrivateLinkResourceDelete() SharedSearchServicePrivateLinkResource sharedSearchServicePrivateLinkResource = client.GetSharedSearchServicePrivateLinkResource(sharedSearchServicePrivateLinkResourceId); // invoke the operation - await sharedSearchServicePrivateLinkResource.DeleteAsync(WaitUntil.Completed); + SharedSearchServicePrivateLinkResourceData data = new SharedSearchServicePrivateLinkResourceData + { + Properties = new SharedSearchServicePrivateLinkResourceProperties + { + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/storageAccountName"), + GroupId = "blob", + RequestMessage = "please approve", + ResourceRegion = default, + }, + }; + ArmOperation lro = await sharedSearchServicePrivateLinkResource.UpdateAsync(WaitUntil.Completed, data); + SharedSearchServicePrivateLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedSearchServicePrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SharedSearchServicePrivateLinkResourceCollection.cs b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SharedSearchServicePrivateLinkResourceCollection.cs index 7dd0daf9e74d3..d0fd0d79439f3 100644 --- a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SharedSearchServicePrivateLinkResourceCollection.cs +++ b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SharedSearchServicePrivateLinkResourceCollection.cs @@ -41,14 +41,14 @@ public async Task CreateOrUpdate_SharedPrivateLinkResourceCreateOrUpdate() // invoke the operation string sharedPrivateLinkResourceName = "testResource"; - SharedSearchServicePrivateLinkResourceData data = new SharedSearchServicePrivateLinkResourceData() + SharedSearchServicePrivateLinkResourceData data = new SharedSearchServicePrivateLinkResourceData { - Properties = new SharedSearchServicePrivateLinkResourceProperties() + Properties = new SharedSearchServicePrivateLinkResourceProperties { PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/storageAccountName"), GroupId = "blob", RequestMessage = "please approve", - ResourceRegion = null, + ResourceRegion = default, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sharedPrivateLinkResourceName, data); @@ -97,10 +97,10 @@ public async Task Get_SharedPrivateLinkResourceGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SharedPrivateLinkResourceGet() + public async Task GetAll_ListSharedPrivateLinkResourcesByService() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetSharedPrivateLinkResource.json - // this example is just showing the usage of "SharedPrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/ListSharedPrivateLinkResourcesByService.json + // this example is just showing the usage of "SharedPrivateLinkResources_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +118,22 @@ public async Task Exists_SharedPrivateLinkResourceGet() // get the collection of this SharedSearchServicePrivateLinkResource SharedSearchServicePrivateLinkResourceCollection collection = searchService.GetSharedSearchServicePrivateLinkResources(); - // invoke the operation - string sharedPrivateLinkResourceName = "testResource"; - bool result = await collection.ExistsAsync(sharedPrivateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (SharedSearchServicePrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SharedSearchServicePrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SharedPrivateLinkResourceGet() + public async Task Exists_SharedPrivateLinkResourceGet() { // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetSharedPrivateLinkResource.json // this example is just showing the usage of "SharedPrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. @@ -150,29 +156,17 @@ public async Task GetIfExists_SharedPrivateLinkResourceGet() // invoke the operation string sharedPrivateLinkResourceName = "testResource"; - NullableResponse response = await collection.GetIfExistsAsync(sharedPrivateLinkResourceName); - SharedSearchServicePrivateLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sharedPrivateLinkResourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SharedSearchServicePrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSharedPrivateLinkResourcesByService() + public async Task GetIfExists_SharedPrivateLinkResourceGet() { - // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/ListSharedPrivateLinkResourcesByService.json - // this example is just showing the usage of "SharedPrivateLinkResources_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/GetSharedPrivateLinkResource.json + // this example is just showing the usage of "SharedPrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +184,23 @@ public async Task GetAll_ListSharedPrivateLinkResourcesByService() // get the collection of this SharedSearchServicePrivateLinkResource SharedSearchServicePrivateLinkResourceCollection collection = searchService.GetSharedSearchServicePrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (SharedSearchServicePrivateLinkResource item in collection.GetAllAsync()) + // invoke the operation + string sharedPrivateLinkResourceName = "testResource"; + NullableResponse response = await collection.GetIfExistsAsync(sharedPrivateLinkResourceName); + SharedSearchServicePrivateLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SharedSearchServicePrivateLinkResourceData resourceData = item.Data; + SharedSearchServicePrivateLinkResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 705c3cf8f3e79..9688cb27405af 100644 --- a/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/search/Azure.ResourceManager.Search/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,62 @@ namespace Azure.ResourceManager.Search.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSearchServices_SearchListServicesBySubscription() + { + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchListServicesBySubscription.json + // this example is just showing the usage of "Services_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SearchServiceResource item in subscriptionResource.GetSearchServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SearchServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckSearchServiceNameAvailability_SearchCheckNameAvailability() + { + // Generated from example definition: specification/search/resource-manager/Microsoft.Search/preview/2024-06-01-preview/examples/SearchCheckNameAvailability.json + // this example is just showing the usage of "Services_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + SearchServiceNameAvailabilityContent content = new SearchServiceNameAvailabilityContent("mysearchservice"); + SearchServiceNameAvailabilityResult result = await subscriptionResource.CheckSearchServiceNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetUsagesBySubscription_GetQuotaUsagesList() diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveApplicationControlGroupCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveApplicationControlGroupCollection.cs index 5437221124813..0af67c4a682a1 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveApplicationControlGroupCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveApplicationControlGroupCollection.cs @@ -16,109 +16,6 @@ namespace Azure.ResourceManager.SecurityCenter.Samples { public partial class Sample_AdaptiveApplicationControlGroupCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAConfiguredApplicationControlVMServerGroup() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsGroup_example.json - // this example is just showing the usage of "AdaptiveApplicationControls_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SecurityCenterLocationResource created on azure - // for more information of creating SecurityCenterLocationResource, please refer to the document of SecurityCenterLocationResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - AzureLocation ascLocation = new AzureLocation("centralus"); - ResourceIdentifier securityCenterLocationResourceId = SecurityCenterLocationResource.CreateResourceIdentifier(subscriptionId, ascLocation); - SecurityCenterLocationResource securityCenterLocation = client.GetSecurityCenterLocationResource(securityCenterLocationResourceId); - - // get the collection of this AdaptiveApplicationControlGroupResource - AdaptiveApplicationControlGroupCollection collection = securityCenterLocation.GetAdaptiveApplicationControlGroups(); - - // invoke the operation - string groupName = "ERELGROUP1"; - AdaptiveApplicationControlGroupResource result = await collection.GetAsync(groupName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdaptiveApplicationControlGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAConfiguredApplicationControlVMServerGroup() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsGroup_example.json - // this example is just showing the usage of "AdaptiveApplicationControls_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SecurityCenterLocationResource created on azure - // for more information of creating SecurityCenterLocationResource, please refer to the document of SecurityCenterLocationResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - AzureLocation ascLocation = new AzureLocation("centralus"); - ResourceIdentifier securityCenterLocationResourceId = SecurityCenterLocationResource.CreateResourceIdentifier(subscriptionId, ascLocation); - SecurityCenterLocationResource securityCenterLocation = client.GetSecurityCenterLocationResource(securityCenterLocationResourceId); - - // get the collection of this AdaptiveApplicationControlGroupResource - AdaptiveApplicationControlGroupCollection collection = securityCenterLocation.GetAdaptiveApplicationControlGroups(); - - // invoke the operation - string groupName = "ERELGROUP1"; - bool result = await collection.ExistsAsync(groupName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAConfiguredApplicationControlVMServerGroup() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsGroup_example.json - // this example is just showing the usage of "AdaptiveApplicationControls_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SecurityCenterLocationResource created on azure - // for more information of creating SecurityCenterLocationResource, please refer to the document of SecurityCenterLocationResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - AzureLocation ascLocation = new AzureLocation("centralus"); - ResourceIdentifier securityCenterLocationResourceId = SecurityCenterLocationResource.CreateResourceIdentifier(subscriptionId, ascLocation); - SecurityCenterLocationResource securityCenterLocation = client.GetSecurityCenterLocationResource(securityCenterLocationResourceId); - - // get the collection of this AdaptiveApplicationControlGroupResource - AdaptiveApplicationControlGroupCollection collection = securityCenterLocation.GetAdaptiveApplicationControlGroups(); - - // invoke the operation - string groupName = "ERELGROUP1"; - NullableResponse response = await collection.GetIfExistsAsync(groupName); - AdaptiveApplicationControlGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdaptiveApplicationControlGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_UpdateAnApplicationControlMachineGroupByAddingANewApplication() @@ -143,39 +40,34 @@ public async Task CreateOrUpdate_UpdateAnApplicationControlMachineGroupByAddingA // invoke the operation string groupName = "ERELGROUP1"; - AdaptiveApplicationControlGroupData data = new AdaptiveApplicationControlGroupData() + AdaptiveApplicationControlGroupData data = new AdaptiveApplicationControlGroupData { EnforcementMode = AdaptiveApplicationControlEnforcementMode.Audit, - ProtectionMode = new SecurityCenterFileProtectionMode() + ProtectionMode = new SecurityCenterFileProtectionMode { Exe = AdaptiveApplicationControlEnforcementMode.Audit, Msi = AdaptiveApplicationControlEnforcementMode.None, Script = AdaptiveApplicationControlEnforcementMode.None, }, - VmRecommendations = -{ -new VmRecommendation() + VmRecommendations = {new VmRecommendation { ConfigurationStatus = SecurityCenterConfigurationStatus.Configured, RecommendationAction = RecommendationAction.Recommended, ResourceId = new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourcegroups/erelh-stable/providers/microsoft.compute/virtualmachines/erelh-16090"), EnforcementSupport = SecurityCenterVmEnforcementSupportState.Supported, -},new VmRecommendation() +}, new VmRecommendation { ConfigurationStatus = SecurityCenterConfigurationStatus.Configured, RecommendationAction = RecommendationAction.Recommended, ResourceId = new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourcegroups/matanvs/providers/microsoft.compute/virtualmachines/matanvs19"), EnforcementSupport = SecurityCenterVmEnforcementSupportState.Supported, -} -}, - PathRecommendations = -{ -new PathRecommendation() +}}, + PathRecommendations = {new PathRecommendation { Path = "[Exe] O=MICROSOFT CORPORATION, L=REDMOND, S=WASHINGTON, C=US\\*\\*\\0.0.0.0", Action = RecommendationAction.Recommended, IotSecurityRecommendationType = new IotSecurityRecommendationType("PublisherSignature"), -PublisherInfo = new SecurityCenterPublisherInfo() +PublisherInfo = new SecurityCenterPublisherInfo { PublisherName = "O=MICROSOFT CORPORATION, L=REDMOND, S=WASHINGTON, C=US", ProductName = "*", @@ -183,26 +75,20 @@ public async Task CreateOrUpdate_UpdateAnApplicationControlMachineGroupByAddingA Version = "0.0.0.0", }, IsCommon = true, -UserSids = -{ -"S-1-1-0" -}, -Usernames = -{ -new UserRecommendation() +UserSids = {"S-1-1-0"}, +Usernames = {new UserRecommendation { Username = "Everyone", RecommendationAction = RecommendationAction.Recommended, -} -}, +}}, FileType = PathRecommendationFileType.Exe, ConfigurationStatus = SecurityCenterConfigurationStatus.Configured, -},new PathRecommendation() +}, new PathRecommendation { Path = "%OSDRIVE%\\WINDOWSAZURE\\SECAGENT\\WASECAGENTPROV.EXE", Action = RecommendationAction.Recommended, IotSecurityRecommendationType = new IotSecurityRecommendationType("ProductSignature"), -PublisherInfo = new SecurityCenterPublisherInfo() +PublisherInfo = new SecurityCenterPublisherInfo { PublisherName = "CN=MICROSOFT AZURE DEPENDENCY CODE SIGN", ProductName = "MICROSOFT® COREXT", @@ -210,26 +96,20 @@ public async Task CreateOrUpdate_UpdateAnApplicationControlMachineGroupByAddingA Version = "0.0.0.0", }, IsCommon = true, -UserSids = -{ -"S-1-1-0" -}, -Usernames = -{ -new UserRecommendation() +UserSids = {"S-1-1-0"}, +Usernames = {new UserRecommendation { Username = "NT AUTHORITY\\SYSTEM", RecommendationAction = RecommendationAction.Recommended, -} -}, +}}, FileType = PathRecommendationFileType.Exe, ConfigurationStatus = SecurityCenterConfigurationStatus.Configured, -},new PathRecommendation() +}, new PathRecommendation { Path = "%OSDRIVE%\\WINDOWSAZURE\\PACKAGES_201973_7415\\COLLECTGUESTLOGS.EXE", Action = RecommendationAction.Recommended, IotSecurityRecommendationType = new IotSecurityRecommendationType("PublisherSignature"), -PublisherInfo = new SecurityCenterPublisherInfo() +PublisherInfo = new SecurityCenterPublisherInfo { PublisherName = "CN=MICROSOFT AZURE DEPENDENCY CODE SIGN", ProductName = "*", @@ -237,28 +117,21 @@ public async Task CreateOrUpdate_UpdateAnApplicationControlMachineGroupByAddingA Version = "0.0.0.0", }, IsCommon = true, -UserSids = -{ -"S-1-1-0" -}, -Usernames = -{ -new UserRecommendation() +UserSids = {"S-1-1-0"}, +Usernames = {new UserRecommendation { Username = "NT AUTHORITY\\SYSTEM", RecommendationAction = RecommendationAction.Recommended, -} -}, +}}, FileType = PathRecommendationFileType.Exe, ConfigurationStatus = SecurityCenterConfigurationStatus.Configured, -},new PathRecommendation() +}, new PathRecommendation { Path = "C:\\directory\\file.exe", Action = RecommendationAction.Add, IotSecurityRecommendationType = new IotSecurityRecommendationType("File"), IsCommon = true, -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupName, data); AdaptiveApplicationControlGroupResource result = lro.Value; @@ -269,5 +142,108 @@ public async Task CreateOrUpdate_UpdateAnApplicationControlMachineGroupByAddingA // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetsAConfiguredApplicationControlVMServerGroup() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsGroup_example.json + // this example is just showing the usage of "AdaptiveApplicationControls_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SecurityCenterLocationResource created on azure + // for more information of creating SecurityCenterLocationResource, please refer to the document of SecurityCenterLocationResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + AzureLocation ascLocation = new AzureLocation("centralus"); + ResourceIdentifier securityCenterLocationResourceId = SecurityCenterLocationResource.CreateResourceIdentifier(subscriptionId, ascLocation); + SecurityCenterLocationResource securityCenterLocation = client.GetSecurityCenterLocationResource(securityCenterLocationResourceId); + + // get the collection of this AdaptiveApplicationControlGroupResource + AdaptiveApplicationControlGroupCollection collection = securityCenterLocation.GetAdaptiveApplicationControlGroups(); + + // invoke the operation + string groupName = "ERELGROUP1"; + AdaptiveApplicationControlGroupResource result = await collection.GetAsync(groupName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdaptiveApplicationControlGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetsAConfiguredApplicationControlVMServerGroup() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsGroup_example.json + // this example is just showing the usage of "AdaptiveApplicationControls_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SecurityCenterLocationResource created on azure + // for more information of creating SecurityCenterLocationResource, please refer to the document of SecurityCenterLocationResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + AzureLocation ascLocation = new AzureLocation("centralus"); + ResourceIdentifier securityCenterLocationResourceId = SecurityCenterLocationResource.CreateResourceIdentifier(subscriptionId, ascLocation); + SecurityCenterLocationResource securityCenterLocation = client.GetSecurityCenterLocationResource(securityCenterLocationResourceId); + + // get the collection of this AdaptiveApplicationControlGroupResource + AdaptiveApplicationControlGroupCollection collection = securityCenterLocation.GetAdaptiveApplicationControlGroups(); + + // invoke the operation + string groupName = "ERELGROUP1"; + bool result = await collection.ExistsAsync(groupName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetsAConfiguredApplicationControlVMServerGroup() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsGroup_example.json + // this example is just showing the usage of "AdaptiveApplicationControls_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SecurityCenterLocationResource created on azure + // for more information of creating SecurityCenterLocationResource, please refer to the document of SecurityCenterLocationResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + AzureLocation ascLocation = new AzureLocation("centralus"); + ResourceIdentifier securityCenterLocationResourceId = SecurityCenterLocationResource.CreateResourceIdentifier(subscriptionId, ascLocation); + SecurityCenterLocationResource securityCenterLocation = client.GetSecurityCenterLocationResource(securityCenterLocationResourceId); + + // get the collection of this AdaptiveApplicationControlGroupResource + AdaptiveApplicationControlGroupCollection collection = securityCenterLocation.GetAdaptiveApplicationControlGroups(); + + // invoke the operation + string groupName = "ERELGROUP1"; + NullableResponse response = await collection.GetIfExistsAsync(groupName); + AdaptiveApplicationControlGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdaptiveApplicationControlGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveApplicationControlGroupResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveApplicationControlGroupResource.cs index 2d98ccb4fdcfb..94bad51c52fb6 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveApplicationControlGroupResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveApplicationControlGroupResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SecurityCenter.Models; using NUnit.Framework; @@ -19,43 +18,40 @@ public partial class Sample_AdaptiveApplicationControlGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAdaptiveApplicationControlGroups_GetsAListOfApplicationControlGroupsOfMachinesForTheSubscription() + public async Task Get_GetsAConfiguredApplicationControlVMServerGroup() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsSubscription_example.json - // this example is just showing the usage of "AdaptiveApplicationControls_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsGroup_example.json + // this example is just showing the usage of "AdaptiveApplicationControls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this AdaptiveApplicationControlGroupResource created on azure + // for more information of creating AdaptiveApplicationControlGroupResource, please refer to the document of AdaptiveApplicationControlGroupResource string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + AzureLocation ascLocation = new AzureLocation("centralus"); + string groupName = "ERELGROUP1"; + ResourceIdentifier adaptiveApplicationControlGroupResourceId = AdaptiveApplicationControlGroupResource.CreateResourceIdentifier(subscriptionId, ascLocation, groupName); + AdaptiveApplicationControlGroupResource adaptiveApplicationControlGroup = client.GetAdaptiveApplicationControlGroupResource(adaptiveApplicationControlGroupResourceId); - // invoke the operation and iterate over the result - bool? includePathRecommendations = true; - bool? summary = false; - await foreach (AdaptiveApplicationControlGroupResource item in subscriptionResource.GetAdaptiveApplicationControlGroupsAsync(includePathRecommendations: includePathRecommendations, summary: summary)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdaptiveApplicationControlGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + AdaptiveApplicationControlGroupResource result = await adaptiveApplicationControlGroup.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdaptiveApplicationControlGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAConfiguredApplicationControlVMServerGroup() + public async Task Delete_DeleteAnApplicationControlMachineGroup() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsGroup_example.json - // this example is just showing the usage of "AdaptiveApplicationControls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/DeleteAdaptiveApplicationControls_example.json + // this example is just showing the usage of "AdaptiveApplicationControls_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,18 +62,14 @@ public async Task Get_GetsAConfiguredApplicationControlVMServerGroup() // for more information of creating AdaptiveApplicationControlGroupResource, please refer to the document of AdaptiveApplicationControlGroupResource string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; AzureLocation ascLocation = new AzureLocation("centralus"); - string groupName = "ERELGROUP1"; + string groupName = "GROUP1"; ResourceIdentifier adaptiveApplicationControlGroupResourceId = AdaptiveApplicationControlGroupResource.CreateResourceIdentifier(subscriptionId, ascLocation, groupName); AdaptiveApplicationControlGroupResource adaptiveApplicationControlGroup = client.GetAdaptiveApplicationControlGroupResource(adaptiveApplicationControlGroupResourceId); // invoke the operation - AdaptiveApplicationControlGroupResource result = await adaptiveApplicationControlGroup.GetAsync(); + await adaptiveApplicationControlGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdaptiveApplicationControlGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -101,39 +93,34 @@ public async Task Update_UpdateAnApplicationControlMachineGroupByAddingANewAppli AdaptiveApplicationControlGroupResource adaptiveApplicationControlGroup = client.GetAdaptiveApplicationControlGroupResource(adaptiveApplicationControlGroupResourceId); // invoke the operation - AdaptiveApplicationControlGroupData data = new AdaptiveApplicationControlGroupData() + AdaptiveApplicationControlGroupData data = new AdaptiveApplicationControlGroupData { EnforcementMode = AdaptiveApplicationControlEnforcementMode.Audit, - ProtectionMode = new SecurityCenterFileProtectionMode() + ProtectionMode = new SecurityCenterFileProtectionMode { Exe = AdaptiveApplicationControlEnforcementMode.Audit, Msi = AdaptiveApplicationControlEnforcementMode.None, Script = AdaptiveApplicationControlEnforcementMode.None, }, - VmRecommendations = -{ -new VmRecommendation() + VmRecommendations = {new VmRecommendation { ConfigurationStatus = SecurityCenterConfigurationStatus.Configured, RecommendationAction = RecommendationAction.Recommended, ResourceId = new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourcegroups/erelh-stable/providers/microsoft.compute/virtualmachines/erelh-16090"), EnforcementSupport = SecurityCenterVmEnforcementSupportState.Supported, -},new VmRecommendation() +}, new VmRecommendation { ConfigurationStatus = SecurityCenterConfigurationStatus.Configured, RecommendationAction = RecommendationAction.Recommended, ResourceId = new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourcegroups/matanvs/providers/microsoft.compute/virtualmachines/matanvs19"), EnforcementSupport = SecurityCenterVmEnforcementSupportState.Supported, -} -}, - PathRecommendations = -{ -new PathRecommendation() +}}, + PathRecommendations = {new PathRecommendation { Path = "[Exe] O=MICROSOFT CORPORATION, L=REDMOND, S=WASHINGTON, C=US\\*\\*\\0.0.0.0", Action = RecommendationAction.Recommended, IotSecurityRecommendationType = new IotSecurityRecommendationType("PublisherSignature"), -PublisherInfo = new SecurityCenterPublisherInfo() +PublisherInfo = new SecurityCenterPublisherInfo { PublisherName = "O=MICROSOFT CORPORATION, L=REDMOND, S=WASHINGTON, C=US", ProductName = "*", @@ -141,26 +128,20 @@ public async Task Update_UpdateAnApplicationControlMachineGroupByAddingANewAppli Version = "0.0.0.0", }, IsCommon = true, -UserSids = -{ -"S-1-1-0" -}, -Usernames = -{ -new UserRecommendation() +UserSids = {"S-1-1-0"}, +Usernames = {new UserRecommendation { Username = "Everyone", RecommendationAction = RecommendationAction.Recommended, -} -}, +}}, FileType = PathRecommendationFileType.Exe, ConfigurationStatus = SecurityCenterConfigurationStatus.Configured, -},new PathRecommendation() +}, new PathRecommendation { Path = "%OSDRIVE%\\WINDOWSAZURE\\SECAGENT\\WASECAGENTPROV.EXE", Action = RecommendationAction.Recommended, IotSecurityRecommendationType = new IotSecurityRecommendationType("ProductSignature"), -PublisherInfo = new SecurityCenterPublisherInfo() +PublisherInfo = new SecurityCenterPublisherInfo { PublisherName = "CN=MICROSOFT AZURE DEPENDENCY CODE SIGN", ProductName = "MICROSOFT® COREXT", @@ -168,26 +149,20 @@ public async Task Update_UpdateAnApplicationControlMachineGroupByAddingANewAppli Version = "0.0.0.0", }, IsCommon = true, -UserSids = -{ -"S-1-1-0" -}, -Usernames = -{ -new UserRecommendation() +UserSids = {"S-1-1-0"}, +Usernames = {new UserRecommendation { Username = "NT AUTHORITY\\SYSTEM", RecommendationAction = RecommendationAction.Recommended, -} -}, +}}, FileType = PathRecommendationFileType.Exe, ConfigurationStatus = SecurityCenterConfigurationStatus.Configured, -},new PathRecommendation() +}, new PathRecommendation { Path = "%OSDRIVE%\\WINDOWSAZURE\\PACKAGES_201973_7415\\COLLECTGUESTLOGS.EXE", Action = RecommendationAction.Recommended, IotSecurityRecommendationType = new IotSecurityRecommendationType("PublisherSignature"), -PublisherInfo = new SecurityCenterPublisherInfo() +PublisherInfo = new SecurityCenterPublisherInfo { PublisherName = "CN=MICROSOFT AZURE DEPENDENCY CODE SIGN", ProductName = "*", @@ -195,28 +170,21 @@ public async Task Update_UpdateAnApplicationControlMachineGroupByAddingANewAppli Version = "0.0.0.0", }, IsCommon = true, -UserSids = -{ -"S-1-1-0" -}, -Usernames = -{ -new UserRecommendation() +UserSids = {"S-1-1-0"}, +Usernames = {new UserRecommendation { Username = "NT AUTHORITY\\SYSTEM", RecommendationAction = RecommendationAction.Recommended, -} -}, +}}, FileType = PathRecommendationFileType.Exe, ConfigurationStatus = SecurityCenterConfigurationStatus.Configured, -},new PathRecommendation() +}, new PathRecommendation { Path = "C:\\directory\\file.exe", Action = RecommendationAction.Add, IotSecurityRecommendationType = new IotSecurityRecommendationType("File"), IsCommon = true, -} -}, +}}, }; ArmOperation lro = await adaptiveApplicationControlGroup.UpdateAsync(WaitUntil.Completed, data); AdaptiveApplicationControlGroupResource result = lro.Value; @@ -227,31 +195,5 @@ public async Task Update_UpdateAnApplicationControlMachineGroupByAddingANewAppli // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnApplicationControlMachineGroup() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/DeleteAdaptiveApplicationControls_example.json - // this example is just showing the usage of "AdaptiveApplicationControls_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AdaptiveApplicationControlGroupResource created on azure - // for more information of creating AdaptiveApplicationControlGroupResource, please refer to the document of AdaptiveApplicationControlGroupResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - AzureLocation ascLocation = new AzureLocation("centralus"); - string groupName = "GROUP1"; - ResourceIdentifier adaptiveApplicationControlGroupResourceId = AdaptiveApplicationControlGroupResource.CreateResourceIdentifier(subscriptionId, ascLocation, groupName); - AdaptiveApplicationControlGroupResource adaptiveApplicationControlGroup = client.GetAdaptiveApplicationControlGroupResource(adaptiveApplicationControlGroupResourceId); - - // invoke the operation - await adaptiveApplicationControlGroup.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveNetworkHardeningCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveNetworkHardeningCollection.cs index 13bd441dd0b49..8cd320eb809aa 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveNetworkHardeningCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveNetworkHardeningCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AdaptiveNetworkHardeningCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAdaptiveNetworkHardeningsResourcesOfAnExtendedResource() + public async Task Get_GetASingleAdaptiveNetworkHardeningResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AdaptiveNetworkHardenings/ListByExtendedResourceAdaptiveNetworkHardenings_example.json - // this example is just showing the usage of "AdaptiveNetworkHardenings_ListByExtendedResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AdaptiveNetworkHardenings/GetAdaptiveNetworkHardening_example.json + // this example is just showing the usage of "AdaptiveNetworkHardenings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_ListAdaptiveNetworkHardeningsResourcesOfAnExtendedResou string resourceName = "vm1"; AdaptiveNetworkHardeningCollection collection = resourceGroupResource.GetAdaptiveNetworkHardenings(resourceNamespace, resourceType, resourceName); - // invoke the operation and iterate over the result - await foreach (AdaptiveNetworkHardeningResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdaptiveNetworkHardeningData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string adaptiveNetworkHardeningResourceName = "default"; + AdaptiveNetworkHardeningResource result = await collection.GetAsync(adaptiveNetworkHardeningResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdaptiveNetworkHardeningData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASingleAdaptiveNetworkHardeningResource() + public async Task GetAll_ListAdaptiveNetworkHardeningsResourcesOfAnExtendedResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AdaptiveNetworkHardenings/GetAdaptiveNetworkHardening_example.json - // this example is just showing the usage of "AdaptiveNetworkHardenings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/AdaptiveNetworkHardenings/ListByExtendedResourceAdaptiveNetworkHardenings_example.json + // this example is just showing the usage of "AdaptiveNetworkHardenings_ListByExtendedResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +77,17 @@ public async Task Get_GetASingleAdaptiveNetworkHardeningResource() string resourceName = "vm1"; AdaptiveNetworkHardeningCollection collection = resourceGroupResource.GetAdaptiveNetworkHardenings(resourceNamespace, resourceType, resourceName); - // invoke the operation - string adaptiveNetworkHardeningResourceName = "default"; - AdaptiveNetworkHardeningResource result = await collection.GetAsync(adaptiveNetworkHardeningResourceName); + // invoke the operation and iterate over the result + await foreach (AdaptiveNetworkHardeningResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdaptiveNetworkHardeningData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdaptiveNetworkHardeningData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveNetworkHardeningResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveNetworkHardeningResource.cs index e03d98de846e6..6a5949c03ccf4 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveNetworkHardeningResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdaptiveNetworkHardeningResource.cs @@ -75,36 +75,23 @@ public async Task Enforce_EnforcesTheGivenRulesOnTheNSGSListedInTheRequest() // invoke the operation AdaptiveNetworkHardeningEnforceContent content = new AdaptiveNetworkHardeningEnforceContent(new RecommendedSecurityRule[] { -new RecommendedSecurityRule() +new RecommendedSecurityRule { Name = "rule1", Direction = SecurityTrafficDirection.Inbound, DestinationPort = 3389, -Protocols = -{ -SecurityTransportProtocol.Tcp -}, -IPAddresses = -{ -"100.10.1.1","200.20.2.2","81.199.3.0/24" +Protocols = {SecurityTransportProtocol.Tcp}, +IPAddresses = {"100.10.1.1", "200.20.2.2", "81.199.3.0/24"}, }, -},new RecommendedSecurityRule() +new RecommendedSecurityRule { Name = "rule2", Direction = SecurityTrafficDirection.Inbound, DestinationPort = 22, -Protocols = -{ -SecurityTransportProtocol.Tcp -}, -IPAddresses = -{ -}, +Protocols = {SecurityTransportProtocol.Tcp}, +IPAddresses = {}, } - }, new string[] - { -"/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg1","/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/nsg2" - }); + }, new string[] { "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/nsg1", "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/rg2/providers/Microsoft.Network/networkSecurityGroups/nsg2" }); await adaptiveNetworkHardening.EnforceAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdvancedThreatProtectionSettingResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdvancedThreatProtectionSettingResource.cs index f71c08966eca5..f2bb1cf44e05e 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdvancedThreatProtectionSettingResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AdvancedThreatProtectionSettingResource.cs @@ -62,7 +62,7 @@ public async Task CreateOrUpdate_CreatesOrUpdatesTheAdvancedThreatProtectionSett AdvancedThreatProtectionSettingResource advancedThreatProtectionSetting = client.GetAdvancedThreatProtectionSettingResource(advancedThreatProtectionSettingResourceId); // invoke the operation - AdvancedThreatProtectionSettingData data = new AdvancedThreatProtectionSettingData() + AdvancedThreatProtectionSettingData data = new AdvancedThreatProtectionSettingData { IsEnabled = true, }; diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AutoProvisioningSettingCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AutoProvisioningSettingCollection.cs index fc2a5c156a1c3..e3e89b3c34830 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AutoProvisioningSettingCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AutoProvisioningSettingCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AutoProvisioningSettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAutoProvisioningSettingsForSubscription() + public async Task CreateOrUpdate_CreateAutoProvisioningSettingsForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/GetAutoProvisioningSettingsSubscription_example.json - // this example is just showing the usage of "AutoProvisioningSettings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/CreateAutoProvisioningSettingsSubscription_example.json + // this example is just showing the usage of "AutoProvisioningSettings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_GetAutoProvisioningSettingsForSubscription() // get the collection of this AutoProvisioningSettingResource AutoProvisioningSettingCollection collection = subscriptionResource.GetAutoProvisioningSettings(); - // invoke the operation and iterate over the result - await foreach (AutoProvisioningSettingResource item in collection.GetAllAsync()) + // invoke the operation + string settingName = "default"; + AutoProvisioningSettingData data = new AutoProvisioningSettingData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoProvisioningSettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AutoProvision = AutoProvisionState.On, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, settingName, data); + AutoProvisioningSettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoProvisioningSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -85,10 +88,10 @@ public async Task Get_GetAnAutoProvisioningSettingForSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAutoProvisioningSettingForSubscription() + public async Task GetAll_GetAutoProvisioningSettingsForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/GetAutoProvisioningSettingSubscription_example.json - // this example is just showing the usage of "AutoProvisioningSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/GetAutoProvisioningSettingsSubscription_example.json + // this example is just showing the usage of "AutoProvisioningSettings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,16 +107,22 @@ public async Task Exists_GetAnAutoProvisioningSettingForSubscription() // get the collection of this AutoProvisioningSettingResource AutoProvisioningSettingCollection collection = subscriptionResource.GetAutoProvisioningSettings(); - // invoke the operation - string settingName = "default"; - bool result = await collection.ExistsAsync(settingName); + // invoke the operation and iterate over the result + await foreach (AutoProvisioningSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoProvisioningSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAutoProvisioningSettingForSubscription() + public async Task Exists_GetAnAutoProvisioningSettingForSubscription() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/GetAutoProvisioningSettingSubscription_example.json // this example is just showing the usage of "AutoProvisioningSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -134,29 +143,17 @@ public async Task GetIfExists_GetAnAutoProvisioningSettingForSubscription() // invoke the operation string settingName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(settingName); - AutoProvisioningSettingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(settingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoProvisioningSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAutoProvisioningSettingsForSubscription() + public async Task GetIfExists_GetAnAutoProvisioningSettingForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/CreateAutoProvisioningSettingsSubscription_example.json - // this example is just showing the usage of "AutoProvisioningSettings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/AutoProvisioningSettings/GetAutoProvisioningSettingSubscription_example.json + // this example is just showing the usage of "AutoProvisioningSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,18 +171,21 @@ public async Task CreateOrUpdate_CreateAutoProvisioningSettingsForSubscription() // invoke the operation string settingName = "default"; - AutoProvisioningSettingData data = new AutoProvisioningSettingData() - { - AutoProvision = AutoProvisionState.On, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, settingName, data); - AutoProvisioningSettingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(settingName); + AutoProvisioningSettingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoProvisioningSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoProvisioningSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AutoProvisioningSettingResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AutoProvisioningSettingResource.cs index 6915b5be93058..f258833dfea65 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AutoProvisioningSettingResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_AutoProvisioningSettingResource.cs @@ -65,7 +65,7 @@ public async Task Update_CreateAutoProvisioningSettingsForSubscription() AutoProvisioningSettingResource autoProvisioningSetting = client.GetAutoProvisioningSettingResource(autoProvisioningSettingResourceId); // invoke the operation - AutoProvisioningSettingData data = new AutoProvisioningSettingData() + AutoProvisioningSettingData data = new AutoProvisioningSettingData { AutoProvision = AutoProvisionState.On, }; diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ComplianceResultCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ComplianceResultCollection.cs index 9859c28dd2831..86ceea107032b 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ComplianceResultCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ComplianceResultCollection.cs @@ -17,66 +17,58 @@ public partial class Sample_ComplianceResultCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetComplianceResultsOnSubscription() + public async Task Get_GetComplianceResultsOnSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2017-08-01/examples/ComplianceResults/ListComplianceResults_example.json - // this example is just showing the usage of "ComplianceResults_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2017-08-01/examples/ComplianceResults/GetComplianceResults_example.json + // this example is just showing the usage of "ComplianceResults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ComplianceResultResource - string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ComplianceResultCollection collection = client.GetComplianceResults(scopeId); + string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + ComplianceResultCollection collection = client.GetComplianceResults(new ResourceIdentifier(resourceId)); - // invoke the operation and iterate over the result - await foreach (ComplianceResultResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ComplianceResultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string complianceResultName = "DesignateMoreThanOneOwner"; + ComplianceResultResource result = await collection.GetAsync(complianceResultName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ComplianceResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetComplianceResultsOnSubscription() + public async Task GetAll_GetComplianceResultsOnSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2017-08-01/examples/ComplianceResults/GetComplianceResults_example.json - // this example is just showing the usage of "ComplianceResults_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2017-08-01/examples/ComplianceResults/ListComplianceResults_example.json + // this example is just showing the usage of "ComplianceResults_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ComplianceResultResource - string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - ComplianceResultCollection collection = client.GetComplianceResults(scopeId); + string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + ComplianceResultCollection collection = client.GetComplianceResults(new ResourceIdentifier(scope)); - // invoke the operation - string complianceResultName = "DesignateMoreThanOneOwner"; - ComplianceResultResource result = await collection.GetAsync(complianceResultName); + // invoke the operation and iterate over the result + await foreach (ComplianceResultResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ComplianceResultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ComplianceResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -91,13 +83,9 @@ public async Task Exists_GetComplianceResultsOnSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ComplianceResultResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - ComplianceResultCollection collection = client.GetComplianceResults(scopeId); + ComplianceResultCollection collection = client.GetComplianceResults(new ResourceIdentifier(resourceId)); // invoke the operation string complianceResultName = "DesignateMoreThanOneOwner"; @@ -118,13 +106,9 @@ public async Task GetIfExists_GetComplianceResultsOnSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ComplianceResultResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - ComplianceResultCollection collection = client.GetComplianceResults(scopeId); + ComplianceResultCollection collection = client.GetComplianceResults(new ResourceIdentifier(resourceId)); // invoke the operation string complianceResultName = "DesignateMoreThanOneOwner"; diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomAssessmentAutomationCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomAssessmentAutomationCollection.cs index 0789f430e684b..514308e80759a 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomAssessmentAutomationCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomAssessmentAutomationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_CustomAssessmentAutomationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACustomAssessmentAutomation() + public async Task CreateOrUpdate_CreateACustomAssessmentAutomation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationGet_example.json - // this example is just showing the usage of "CustomAssessmentAutomations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationCreate_example.json + // this example is just showing the usage of "CustomAssessmentAutomations_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_GetACustomAssessmentAutomation() // invoke the operation string customAssessmentAutomationName = "MyCustomAssessmentAutomation"; - CustomAssessmentAutomationResource result = await collection.GetAsync(customAssessmentAutomationName); + CustomAssessmentAutomationCreateOrUpdateContent content = new CustomAssessmentAutomationCreateOrUpdateContent + { + CompressedQuery = "DQAKAEkAYQBtAF8ARwByAG8AdQBwAA0ACgB8ACAAZQB4AHQAZQBuAGQAIABIAGUAYQBsAHQAaABTAHQAYQB0AHUAcwAgAD0AIABpAGYAZgAoAHQAbwBzAHQAcgBpAG4AZwAoAFIAZQBjAG8AcgBkAC4AVQBzAGUAcgBOAGEAbQBlACkAIABjAG8AbgB0AGEAaQBuAHMAIAAnAHUAcwBlAHIAJwAsACAAJwBVAE4ASABFAEEATABUAEgAWQAnACwAIAAnAEgARQBBAEwAVABIAFkAJwApAA0ACgA=", + SupportedCloud = CustomAssessmentAutomationSupportedCloud.Aws, + Severity = CustomAssessmentSeverity.Medium, + DisplayName = "Password Policy", + Description = "Data should be encrypted", + RemediationDescription = "Encrypt store by...", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, customAssessmentAutomationName, content); + CustomAssessmentAutomationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +62,7 @@ public async Task Get_GetACustomAssessmentAutomation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACustomAssessmentAutomation() + public async Task Get_GetACustomAssessmentAutomation() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationGet_example.json // this example is just showing the usage of "CustomAssessmentAutomations_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +84,21 @@ public async Task Exists_GetACustomAssessmentAutomation() // invoke the operation string customAssessmentAutomationName = "MyCustomAssessmentAutomation"; - bool result = await collection.ExistsAsync(customAssessmentAutomationName); + CustomAssessmentAutomationResource result = await collection.GetAsync(customAssessmentAutomationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomAssessmentAutomationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACustomAssessmentAutomation() + public async Task GetAll_ListCustomAssessmentAutomationsInASubscriptionAndAResourceGroup() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationGet_example.json - // this example is just showing the usage of "CustomAssessmentAutomations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationListByResourceGroup_example.json + // this example is just showing the usage of "CustomAssessmentAutomations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +115,25 @@ public async Task GetIfExists_GetACustomAssessmentAutomation() // get the collection of this CustomAssessmentAutomationResource CustomAssessmentAutomationCollection collection = resourceGroupResource.GetCustomAssessmentAutomations(); - // invoke the operation - string customAssessmentAutomationName = "MyCustomAssessmentAutomation"; - NullableResponse response = await collection.GetIfExistsAsync(customAssessmentAutomationName); - CustomAssessmentAutomationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CustomAssessmentAutomationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CustomAssessmentAutomationData resourceData = result.Data; + CustomAssessmentAutomationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateACustomAssessmentAutomation() + public async Task Exists_GetACustomAssessmentAutomation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationCreate_example.json - // this example is just showing the usage of "CustomAssessmentAutomations_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationGet_example.json + // this example is just showing the usage of "CustomAssessmentAutomations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,31 +152,17 @@ public async Task CreateOrUpdate_CreateACustomAssessmentAutomation() // invoke the operation string customAssessmentAutomationName = "MyCustomAssessmentAutomation"; - CustomAssessmentAutomationCreateOrUpdateContent content = new CustomAssessmentAutomationCreateOrUpdateContent() - { - CompressedQuery = "DQAKAEkAYQBtAF8ARwByAG8AdQBwAA0ACgB8ACAAZQB4AHQAZQBuAGQAIABIAGUAYQBsAHQAaABTAHQAYQB0AHUAcwAgAD0AIABpAGYAZgAoAHQAbwBzAHQAcgBpAG4AZwAoAFIAZQBjAG8AcgBkAC4AVQBzAGUAcgBOAGEAbQBlACkAIABjAG8AbgB0AGEAaQBuAHMAIAAnAHUAcwBlAHIAJwAsACAAJwBVAE4ASABFAEEATABUAEgAWQAnACwAIAAnAEgARQBBAEwAVABIAFkAJwApAA0ACgA=", - SupportedCloud = CustomAssessmentAutomationSupportedCloud.Aws, - Severity = CustomAssessmentSeverity.Medium, - DisplayName = "Password Policy", - Description = "Data should be encrypted", - RemediationDescription = "Encrypt store by...", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, customAssessmentAutomationName, content); - CustomAssessmentAutomationResource result = lro.Value; + bool result = await collection.ExistsAsync(customAssessmentAutomationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomAssessmentAutomationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCustomAssessmentAutomationsInASubscriptionAndAResourceGroup() + public async Task GetIfExists_GetACustomAssessmentAutomation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationListByResourceGroup_example.json - // this example is just showing the usage of "CustomAssessmentAutomations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationGet_example.json + // this example is just showing the usage of "CustomAssessmentAutomations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_ListCustomAssessmentAutomationsInASubscriptionAndAResou // get the collection of this CustomAssessmentAutomationResource CustomAssessmentAutomationCollection collection = resourceGroupResource.GetCustomAssessmentAutomations(); - // invoke the operation and iterate over the result - await foreach (CustomAssessmentAutomationResource item in collection.GetAllAsync()) + // invoke the operation + string customAssessmentAutomationName = "MyCustomAssessmentAutomation"; + NullableResponse response = await collection.GetIfExistsAsync(customAssessmentAutomationName); + CustomAssessmentAutomationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CustomAssessmentAutomationData resourceData = item.Data; + CustomAssessmentAutomationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomAssessmentAutomationResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomAssessmentAutomationResource.cs index 7c7ac519b6dc2..82b36989e172c 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomAssessmentAutomationResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomAssessmentAutomationResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SecurityCenter.Models; using NUnit.Framework; @@ -49,10 +48,10 @@ public async Task Get_GetACustomAssessmentAutomation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateACustomAssessmentAutomation() + public async Task Delete_DeleteACustomAssessmentAutomation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationCreate_example.json - // this example is just showing the usage of "CustomAssessmentAutomations_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationDelete_example.json + // this example is just showing the usage of "CustomAssessmentAutomations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,31 +67,17 @@ public async Task Update_CreateACustomAssessmentAutomation() CustomAssessmentAutomationResource customAssessmentAutomation = client.GetCustomAssessmentAutomationResource(customAssessmentAutomationResourceId); // invoke the operation - CustomAssessmentAutomationCreateOrUpdateContent content = new CustomAssessmentAutomationCreateOrUpdateContent() - { - CompressedQuery = "DQAKAEkAYQBtAF8ARwByAG8AdQBwAA0ACgB8ACAAZQB4AHQAZQBuAGQAIABIAGUAYQBsAHQAaABTAHQAYQB0AHUAcwAgAD0AIABpAGYAZgAoAHQAbwBzAHQAcgBpAG4AZwAoAFIAZQBjAG8AcgBkAC4AVQBzAGUAcgBOAGEAbQBlACkAIABjAG8AbgB0AGEAaQBuAHMAIAAnAHUAcwBlAHIAJwAsACAAJwBVAE4ASABFAEEATABUAEgAWQAnACwAIAAnAEgARQBBAEwAVABIAFkAJwApAA0ACgA=", - SupportedCloud = CustomAssessmentAutomationSupportedCloud.Aws, - Severity = CustomAssessmentSeverity.Medium, - DisplayName = "Password Policy", - Description = "Data should be encrypted", - RemediationDescription = "Encrypt store by...", - }; - ArmOperation lro = await customAssessmentAutomation.UpdateAsync(WaitUntil.Completed, content); - CustomAssessmentAutomationResource result = lro.Value; + await customAssessmentAutomation.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomAssessmentAutomationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACustomAssessmentAutomation() + public async Task Update_CreateACustomAssessmentAutomation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationDelete_example.json - // this example is just showing the usage of "CustomAssessmentAutomations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationCreate_example.json + // this example is just showing the usage of "CustomAssessmentAutomations_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,40 +93,23 @@ public async Task Delete_DeleteACustomAssessmentAutomation() CustomAssessmentAutomationResource customAssessmentAutomation = client.GetCustomAssessmentAutomationResource(customAssessmentAutomationResourceId); // invoke the operation - await customAssessmentAutomation.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCustomAssessmentAutomations_ListCustomAssessmentAutomationsInASubscription() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationListBySubscription_example.json - // this example is just showing the usage of "CustomAssessmentAutomations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "e5d1b86c-3051-44d5-8802-aa65d45a279b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CustomAssessmentAutomationResource item in subscriptionResource.GetCustomAssessmentAutomationsAsync()) + CustomAssessmentAutomationCreateOrUpdateContent content = new CustomAssessmentAutomationCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomAssessmentAutomationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CompressedQuery = "DQAKAEkAYQBtAF8ARwByAG8AdQBwAA0ACgB8ACAAZQB4AHQAZQBuAGQAIABIAGUAYQBsAHQAaABTAHQAYQB0AHUAcwAgAD0AIABpAGYAZgAoAHQAbwBzAHQAcgBpAG4AZwAoAFIAZQBjAG8AcgBkAC4AVQBzAGUAcgBOAGEAbQBlACkAIABjAG8AbgB0AGEAaQBuAHMAIAAnAHUAcwBlAHIAJwAsACAAJwBVAE4ASABFAEEATABUAEgAWQAnACwAIAAnAEgARQBBAEwAVABIAFkAJwApAA0ACgA=", + SupportedCloud = CustomAssessmentAutomationSupportedCloud.Aws, + Severity = CustomAssessmentSeverity.Medium, + DisplayName = "Password Policy", + Description = "Data should be encrypted", + RemediationDescription = "Encrypt store by...", + }; + ArmOperation lro = await customAssessmentAutomation.UpdateAsync(WaitUntil.Completed, content); + CustomAssessmentAutomationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomAssessmentAutomationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomEntityStoreAssignmentCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomEntityStoreAssignmentCollection.cs index 33355ac276b9a..6ca70d3ca05e6 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomEntityStoreAssignmentCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomEntityStoreAssignmentCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_CustomEntityStoreAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACustomEntityStoreAssignment() + public async Task CreateOrUpdate_CreateACustomEntityStoreAssignment() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentGet_example.json - // this example is just showing the usage of "CustomEntityStoreAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentCreate_example.json + // this example is just showing the usage of "CustomEntityStoreAssignments_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetACustomEntityStoreAssignment() // invoke the operation string customEntityStoreAssignmentName = "33e7cc6e-a139-4723-a0e5-76993aee0771"; - CustomEntityStoreAssignmentResource result = await collection.GetAsync(customEntityStoreAssignmentName); + CustomEntityStoreAssignmentCreateOrUpdateContent content = new CustomEntityStoreAssignmentCreateOrUpdateContent + { + Principal = "aaduser=f3923a3e-ad57-4752-b1a9-fbf3c8e5e082;72f988bf-86f1-41af-91ab-2d7cd011db47", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, customEntityStoreAssignmentName, content); + CustomEntityStoreAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetACustomEntityStoreAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACustomEntityStoreAssignment() + public async Task Get_GetACustomEntityStoreAssignment() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentGet_example.json // this example is just showing the usage of "CustomEntityStoreAssignments_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +79,21 @@ public async Task Exists_GetACustomEntityStoreAssignment() // invoke the operation string customEntityStoreAssignmentName = "33e7cc6e-a139-4723-a0e5-76993aee0771"; - bool result = await collection.ExistsAsync(customEntityStoreAssignmentName); + CustomEntityStoreAssignmentResource result = await collection.GetAsync(customEntityStoreAssignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomEntityStoreAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACustomEntityStoreAssignment() + public async Task GetAll_ListCustomEntityStoreAssignmentsInASubscriptionAndAResourceGroup() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentGet_example.json - // this example is just showing the usage of "CustomEntityStoreAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentListByResourceGroup_example.json + // this example is just showing the usage of "CustomEntityStoreAssignments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +110,25 @@ public async Task GetIfExists_GetACustomEntityStoreAssignment() // get the collection of this CustomEntityStoreAssignmentResource CustomEntityStoreAssignmentCollection collection = resourceGroupResource.GetCustomEntityStoreAssignments(); - // invoke the operation - string customEntityStoreAssignmentName = "33e7cc6e-a139-4723-a0e5-76993aee0771"; - NullableResponse response = await collection.GetIfExistsAsync(customEntityStoreAssignmentName); - CustomEntityStoreAssignmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CustomEntityStoreAssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CustomEntityStoreAssignmentData resourceData = result.Data; + CustomEntityStoreAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateACustomEntityStoreAssignment() + public async Task Exists_GetACustomEntityStoreAssignment() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentCreate_example.json - // this example is just showing the usage of "CustomEntityStoreAssignments_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentGet_example.json + // this example is just showing the usage of "CustomEntityStoreAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,26 +147,17 @@ public async Task CreateOrUpdate_CreateACustomEntityStoreAssignment() // invoke the operation string customEntityStoreAssignmentName = "33e7cc6e-a139-4723-a0e5-76993aee0771"; - CustomEntityStoreAssignmentCreateOrUpdateContent content = new CustomEntityStoreAssignmentCreateOrUpdateContent() - { - Principal = "aaduser=f3923a3e-ad57-4752-b1a9-fbf3c8e5e082;72f988bf-86f1-41af-91ab-2d7cd011db47", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, customEntityStoreAssignmentName, content); - CustomEntityStoreAssignmentResource result = lro.Value; + bool result = await collection.ExistsAsync(customEntityStoreAssignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomEntityStoreAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCustomEntityStoreAssignmentsInASubscriptionAndAResourceGroup() + public async Task GetIfExists_GetACustomEntityStoreAssignment() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentListByResourceGroup_example.json - // this example is just showing the usage of "CustomEntityStoreAssignments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentGet_example.json + // this example is just showing the usage of "CustomEntityStoreAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_ListCustomEntityStoreAssignmentsInASubscriptionAndAReso // get the collection of this CustomEntityStoreAssignmentResource CustomEntityStoreAssignmentCollection collection = resourceGroupResource.GetCustomEntityStoreAssignments(); - // invoke the operation and iterate over the result - await foreach (CustomEntityStoreAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string customEntityStoreAssignmentName = "33e7cc6e-a139-4723-a0e5-76993aee0771"; + NullableResponse response = await collection.GetIfExistsAsync(customEntityStoreAssignmentName); + CustomEntityStoreAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CustomEntityStoreAssignmentData resourceData = item.Data; + CustomEntityStoreAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomEntityStoreAssignmentResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomEntityStoreAssignmentResource.cs index b97489e0eb928..3a78820acac64 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomEntityStoreAssignmentResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_CustomEntityStoreAssignmentResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SecurityCenter.Models; using NUnit.Framework; @@ -49,10 +48,10 @@ public async Task Get_GetACustomEntityStoreAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateACustomEntityStoreAssignment() + public async Task Delete_DeleteACustomEntityStoreAssignment() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentCreate_example.json - // this example is just showing the usage of "CustomEntityStoreAssignments_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentDelete_example.json + // this example is just showing the usage of "CustomEntityStoreAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +67,17 @@ public async Task Update_CreateACustomEntityStoreAssignment() CustomEntityStoreAssignmentResource customEntityStoreAssignment = client.GetCustomEntityStoreAssignmentResource(customEntityStoreAssignmentResourceId); // invoke the operation - CustomEntityStoreAssignmentCreateOrUpdateContent content = new CustomEntityStoreAssignmentCreateOrUpdateContent() - { - Principal = "aaduser=f3923a3e-ad57-4752-b1a9-fbf3c8e5e082;72f988bf-86f1-41af-91ab-2d7cd011db47", - }; - ArmOperation lro = await customEntityStoreAssignment.UpdateAsync(WaitUntil.Completed, content); - CustomEntityStoreAssignmentResource result = lro.Value; + await customEntityStoreAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomEntityStoreAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACustomEntityStoreAssignment() + public async Task Update_CreateACustomEntityStoreAssignment() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentDelete_example.json - // this example is just showing the usage of "CustomEntityStoreAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentCreate_example.json + // this example is just showing the usage of "CustomEntityStoreAssignments_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,40 +93,18 @@ public async Task Delete_DeleteACustomEntityStoreAssignment() CustomEntityStoreAssignmentResource customEntityStoreAssignment = client.GetCustomEntityStoreAssignmentResource(customEntityStoreAssignmentResourceId); // invoke the operation - await customEntityStoreAssignment.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCustomEntityStoreAssignments_ListCustomEntityStoreAssignmentsInASubscription() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentListBySubscription_example.json - // this example is just showing the usage of "CustomEntityStoreAssignments_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "e5d1b86c-3051-44d5-8802-aa65d45a279b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CustomEntityStoreAssignmentResource item in subscriptionResource.GetCustomEntityStoreAssignmentsAsync()) + CustomEntityStoreAssignmentCreateOrUpdateContent content = new CustomEntityStoreAssignmentCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomEntityStoreAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Principal = "aaduser=f3923a3e-ad57-4752-b1a9-fbf3c8e5e082;72f988bf-86f1-41af-91ab-2d7cd011db47", + }; + ArmOperation lro = await customEntityStoreAssignment.UpdateAsync(WaitUntil.Completed, content); + CustomEntityStoreAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomEntityStoreAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DefenderForStorageSettingCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DefenderForStorageSettingCollection.cs index 329f57977efbf..8edff36e7bfc4 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DefenderForStorageSettingCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DefenderForStorageSettingCollection.cs @@ -16,6 +16,43 @@ namespace Azure.ResourceManager.SecurityCenter.Samples { public partial class Sample_DefenderForStorageSettingCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreatesOrUpdatesTheDefenderForStorageSettingsOnASpecifiedResource() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-12-01-preview/examples/DefenderForStorage/PutDefenderForStorageSettings_example.json + // this example is just showing the usage of "DefenderForStorage_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this DefenderForStorageSettingResource + string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount"; + DefenderForStorageSettingCollection collection = client.GetDefenderForStorageSettings(new ResourceIdentifier(resourceId)); + + // invoke the operation + DefenderForStorageSettingName settingName = DefenderForStorageSettingName.Current; + DefenderForStorageSettingData data = new DefenderForStorageSettingData + { + IsEnabled = true, + IsOverrideSubscriptionLevelSettingsEnabled = true, + IsSensitiveDataDiscoveryEnabled = true, + ScanResultsEventGridTopicResourceId = new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.EventGrid/topics/sampletopic"), + IsMalwareScanningOnUploadEnabled = true, + CapGBPerMonth = -1, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, settingName, data); + DefenderForStorageSettingResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DefenderForStorageSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetsTheDefenderForStorageSettingsForTheSpecifiedResource() @@ -28,13 +65,9 @@ public async Task Get_GetsTheDefenderForStorageSettingsForTheSpecifiedResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DefenderForStorageSettingResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - DefenderForStorageSettingCollection collection = client.GetDefenderForStorageSettings(scopeId); + DefenderForStorageSettingCollection collection = client.GetDefenderForStorageSettings(new ResourceIdentifier(resourceId)); // invoke the operation DefenderForStorageSettingName settingName = DefenderForStorageSettingName.Current; @@ -59,13 +92,9 @@ public async Task Exists_GetsTheDefenderForStorageSettingsForTheSpecifiedResourc // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DefenderForStorageSettingResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - DefenderForStorageSettingCollection collection = client.GetDefenderForStorageSettings(scopeId); + DefenderForStorageSettingCollection collection = client.GetDefenderForStorageSettings(new ResourceIdentifier(resourceId)); // invoke the operation DefenderForStorageSettingName settingName = DefenderForStorageSettingName.Current; @@ -86,13 +115,9 @@ public async Task GetIfExists_GetsTheDefenderForStorageSettingsForTheSpecifiedRe // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DefenderForStorageSettingResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - DefenderForStorageSettingCollection collection = client.GetDefenderForStorageSettings(scopeId); + DefenderForStorageSettingCollection collection = client.GetDefenderForStorageSettings(new ResourceIdentifier(resourceId)); // invoke the operation DefenderForStorageSettingName settingName = DefenderForStorageSettingName.Current; @@ -112,46 +137,5 @@ public async Task GetIfExists_GetsTheDefenderForStorageSettingsForTheSpecifiedRe Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesTheDefenderForStorageSettingsOnASpecifiedResource() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-12-01-preview/examples/DefenderForStorage/PutDefenderForStorageSettings_example.json - // this example is just showing the usage of "DefenderForStorage_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this DefenderForStorageSettingResource - string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Storage/storageAccounts/samplestorageaccount"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - DefenderForStorageSettingCollection collection = client.GetDefenderForStorageSettings(scopeId); - - // invoke the operation - DefenderForStorageSettingName settingName = DefenderForStorageSettingName.Current; - DefenderForStorageSettingData data = new DefenderForStorageSettingData() - { - IsEnabled = true, - IsOverrideSubscriptionLevelSettingsEnabled = true, - IsSensitiveDataDiscoveryEnabled = true, - ScanResultsEventGridTopicResourceId = new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.EventGrid/topics/sampletopic"), - IsMalwareScanningOnUploadEnabled = true, - CapGBPerMonth = -1, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, settingName, data); - DefenderForStorageSettingResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DefenderForStorageSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DefenderForStorageSettingResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DefenderForStorageSettingResource.cs index 9a475ddcd0be6..a0bff1a67277a 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DefenderForStorageSettingResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DefenderForStorageSettingResource.cs @@ -67,7 +67,7 @@ public async Task Update_CreatesOrUpdatesTheDefenderForStorageSettingsOnASpecifi // invoke the operation DefenderForStorageSettingName settingName0 = DefenderForStorageSettingName.Current; - DefenderForStorageSettingData data = new DefenderForStorageSettingData() + DefenderForStorageSettingData data = new DefenderForStorageSettingData { IsEnabled = true, IsOverrideSubscriptionLevelSettingsEnabled = true, diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsConfigurationResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsConfigurationResource.cs index d610e89de9609..6a43009930ca3 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsConfigurationResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsConfigurationResource.cs @@ -19,10 +19,10 @@ public partial class Sample_DevOpsConfigurationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAvailableDevOpsOrgs_ListAvailableAzureDevOpsOrgs() + public async Task Get_GetDevOpsConfigurations() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListAvailableAzureDevOpsOrgs_example.json - // this example is just showing the usage of "AzureDevOpsOrgs_ListAvailable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetDevOpsConfigurations_example.json + // this example is just showing the usage of "DevOpsConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,22 @@ public async Task GetAvailableDevOpsOrgs_ListAvailableAzureDevOpsOrgs() ResourceIdentifier devOpsConfigurationResourceId = DevOpsConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, securityConnectorName); DevOpsConfigurationResource devOpsConfiguration = client.GetDevOpsConfigurationResource(devOpsConfigurationResourceId); - // invoke the operation and iterate over the result - await foreach (DevOpsOrgResource item in devOpsConfiguration.GetAvailableDevOpsOrgsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsOrgData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + DevOpsConfigurationResource result = await devOpsConfiguration.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDevOpsConfigurations() + public async Task Delete_DeleteDevOpsConfigurations() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetDevOpsConfigurations_example.json - // this example is just showing the usage of "DevOpsConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/DeleteDevOpsConfigurations_example.json + // this example is just showing the usage of "DevOpsConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,21 +68,17 @@ public async Task Get_GetDevOpsConfigurations() DevOpsConfigurationResource devOpsConfiguration = client.GetDevOpsConfigurationResource(devOpsConfigurationResourceId); // invoke the operation - DevOpsConfigurationResource result = await devOpsConfiguration.GetAsync(); + await devOpsConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardCurrentAndFuture() + public async Task Update_UpdateDevOpsConfigurations() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardCurrentAndFuture_example.json - // this example is just showing the usage of "DevOpsConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/UpdateDevOpsConfigurations_example.json + // this example is just showing the usage of "DevOpsConfigurations_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,15 +94,14 @@ public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardCurren DevOpsConfigurationResource devOpsConfiguration = client.GetDevOpsConfigurationResource(devOpsConfigurationResourceId); // invoke the operation - DevOpsConfigurationData data = new DevOpsConfigurationData() + DevOpsConfigurationData data = new DevOpsConfigurationData { - Properties = new DevOpsConfigurationProperties() + Properties = new DevOpsConfigurationProperties { - AuthorizationCode = "00000000000000000000", AutoDiscovery = DevOpsAutoDiscovery.Enabled, }, }; - ArmOperation lro = await devOpsConfiguration.CreateOrUpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await devOpsConfiguration.UpdateAsync(WaitUntil.Completed, data); DevOpsConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -121,9 +113,9 @@ public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardCurren [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardCurrentOnly() + public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardCurrentAndFuture() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardCurrentOnly_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardCurrentAndFuture_example.json // this example is just showing the usage of "DevOpsConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -140,12 +132,12 @@ public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardCurren DevOpsConfigurationResource devOpsConfiguration = client.GetDevOpsConfigurationResource(devOpsConfigurationResourceId); // invoke the operation - DevOpsConfigurationData data = new DevOpsConfigurationData() + DevOpsConfigurationData data = new DevOpsConfigurationData { - Properties = new DevOpsConfigurationProperties() + Properties = new DevOpsConfigurationProperties { AuthorizationCode = "00000000000000000000", - AutoDiscovery = DevOpsAutoDiscovery.Disabled, + AutoDiscovery = DevOpsAutoDiscovery.Enabled, }, }; ArmOperation lro = await devOpsConfiguration.CreateOrUpdateAsync(WaitUntil.Completed, data); @@ -160,9 +152,9 @@ public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardCurren [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardSelected() + public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardCurrentOnly() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardSelected_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardCurrentOnly_example.json // this example is just showing the usage of "DevOpsConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -179,16 +171,12 @@ public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardSelect DevOpsConfigurationResource devOpsConfiguration = client.GetDevOpsConfigurationResource(devOpsConfigurationResourceId); // invoke the operation - DevOpsConfigurationData data = new DevOpsConfigurationData() + DevOpsConfigurationData data = new DevOpsConfigurationData { - Properties = new DevOpsConfigurationProperties() + Properties = new DevOpsConfigurationProperties { AuthorizationCode = "00000000000000000000", AutoDiscovery = DevOpsAutoDiscovery.Disabled, - TopLevelInventoryList = -{ -"org1","org2" -}, }, }; ArmOperation lro = await devOpsConfiguration.CreateOrUpdateAsync(WaitUntil.Completed, data); @@ -203,10 +191,10 @@ public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardSelect [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateDevOpsConfigurations() + public async Task CreateOrUpdate_CreateOrUpdateDevOpsConfigurationsOnboardSelected() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/UpdateDevOpsConfigurations_example.json - // this example is just showing the usage of "DevOpsConfigurations_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateDevOpsConfigurationsOnboardSelected_example.json + // this example is just showing the usage of "DevOpsConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -222,14 +210,16 @@ public async Task Update_UpdateDevOpsConfigurations() DevOpsConfigurationResource devOpsConfiguration = client.GetDevOpsConfigurationResource(devOpsConfigurationResourceId); // invoke the operation - DevOpsConfigurationData data = new DevOpsConfigurationData() + DevOpsConfigurationData data = new DevOpsConfigurationData { - Properties = new DevOpsConfigurationProperties() + Properties = new DevOpsConfigurationProperties { - AutoDiscovery = DevOpsAutoDiscovery.Enabled, + AuthorizationCode = "00000000000000000000", + AutoDiscovery = DevOpsAutoDiscovery.Disabled, + TopLevelInventoryList = { "org1", "org2" }, }, }; - ArmOperation lro = await devOpsConfiguration.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await devOpsConfiguration.CreateOrUpdateAsync(WaitUntil.Completed, data); DevOpsConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -241,10 +231,10 @@ public async Task Update_UpdateDevOpsConfigurations() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDevOpsConfigurations() + public async Task GetAvailableDevOpsOrgs_ListAvailableAzureDevOpsOrgs() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/DeleteDevOpsConfigurations_example.json - // this example is just showing the usage of "DevOpsConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListAvailableAzureDevOpsOrgs_example.json + // this example is just showing the usage of "AzureDevOpsOrgs_ListAvailable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -259,8 +249,15 @@ public async Task Delete_DeleteDevOpsConfigurations() ResourceIdentifier devOpsConfigurationResourceId = DevOpsConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, securityConnectorName); DevOpsConfigurationResource devOpsConfiguration = client.GetDevOpsConfigurationResource(devOpsConfigurationResourceId); - // invoke the operation - await devOpsConfiguration.DeleteAsync(WaitUntil.Completed); + // invoke the operation and iterate over the result + await foreach (DevOpsOrgResource item in devOpsConfiguration.GetAvailableDevOpsOrgsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsOrgData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } Console.WriteLine("Succeeded"); } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsOrgCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsOrgCollection.cs index 30120d1604fe8..04271443144aa 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsOrgCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsOrgCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevOpsOrgCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAzureDevOpsOrgs() + public async Task CreateOrUpdate_CreateOrUpdateAzureDevOpsOrgs() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListAzureDevOpsOrgs_example.json - // this example is just showing the usage of "AzureDevOpsOrgs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsOrgs_example.json + // this example is just showing the usage of "AzureDevOpsOrgs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,27 @@ public async Task GetAll_ListAzureDevOpsOrgs() // get the collection of this DevOpsOrgResource DevOpsOrgCollection collection = devOpsConfiguration.GetDevOpsOrgs(); - // invoke the operation and iterate over the result - await foreach (DevOpsOrgResource item in collection.GetAllAsync()) + // invoke the operation + string orgName = "myAzDevOpsOrg"; + DevOpsOrgData data = new DevOpsOrgData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsOrgData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new DevOpsOrgProperties + { + OnboardingState = ResourceOnboardingState.NotApplicable, + ActionableRemediation = new ActionableRemediation + { + State = ActionableRemediationState.Enabled, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, orgName, data); + DevOpsOrgResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsOrgData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +98,10 @@ public async Task Get_GetAzureDevOpsOrgs() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureDevOpsOrgs() + public async Task GetAll_ListAzureDevOpsOrgs() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetAzureDevOpsOrgs_example.json - // this example is just showing the usage of "AzureDevOpsOrgs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListAzureDevOpsOrgs_example.json + // this example is just showing the usage of "AzureDevOpsOrgs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +119,22 @@ public async Task Exists_GetAzureDevOpsOrgs() // get the collection of this DevOpsOrgResource DevOpsOrgCollection collection = devOpsConfiguration.GetDevOpsOrgs(); - // invoke the operation - string orgName = "myAzDevOpsOrg"; - bool result = await collection.ExistsAsync(orgName); + // invoke the operation and iterate over the result + await foreach (DevOpsOrgResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsOrgData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureDevOpsOrgs() + public async Task Exists_GetAzureDevOpsOrgs() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetAzureDevOpsOrgs_example.json // this example is just showing the usage of "AzureDevOpsOrgs_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +157,17 @@ public async Task GetIfExists_GetAzureDevOpsOrgs() // invoke the operation string orgName = "myAzDevOpsOrg"; - NullableResponse response = await collection.GetIfExistsAsync(orgName); - DevOpsOrgResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(orgName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsOrgData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAzureDevOpsOrgs() + public async Task GetIfExists_GetAzureDevOpsOrgs() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsOrgs_example.json - // this example is just showing the usage of "AzureDevOpsOrgs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetAzureDevOpsOrgs_example.json + // this example is just showing the usage of "AzureDevOpsOrgs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,25 +187,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAzureDevOpsOrgs() // invoke the operation string orgName = "myAzDevOpsOrg"; - DevOpsOrgData data = new DevOpsOrgData() - { - Properties = new DevOpsOrgProperties() - { - OnboardingState = ResourceOnboardingState.NotApplicable, - ActionableRemediation = new ActionableRemediation() - { - State = ActionableRemediationState.Enabled, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, orgName, data); - DevOpsOrgResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(orgName); + DevOpsOrgResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsOrgData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsOrgData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsOrgResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsOrgResource.cs index 5266aec7d3b95..9d13e9805e33f 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsOrgResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsOrgResource.cs @@ -69,12 +69,12 @@ public async Task Update_UpdateAzureDevOpsOrgs() DevOpsOrgResource devOpsOrg = client.GetDevOpsOrgResource(devOpsOrgResourceId); // invoke the operation - DevOpsOrgData data = new DevOpsOrgData() + DevOpsOrgData data = new DevOpsOrgData { - Properties = new DevOpsOrgProperties() + Properties = new DevOpsOrgProperties { OnboardingState = ResourceOnboardingState.NotApplicable, - ActionableRemediation = new ActionableRemediation() + ActionableRemediation = new ActionableRemediation { State = ActionableRemediationState.Enabled, }, diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsProjectCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsProjectCollection.cs index 0ba179042b224..df4cfa067d810 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsProjectCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsProjectCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevOpsProjectCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAzureDevOpsProjects() + public async Task CreateOrUpdate_CreateOrUpdateAzureDevOpsProjects() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListAzureDevOpsProjects_example.json - // this example is just showing the usage of "AzureDevOpsProjects_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsProjects_example.json + // this example is just showing the usage of "AzureDevOpsProjects_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,27 @@ public async Task GetAll_ListAzureDevOpsProjects() // get the collection of this DevOpsProjectResource DevOpsProjectCollection collection = devOpsOrg.GetDevOpsProjects(); - // invoke the operation and iterate over the result - await foreach (DevOpsProjectResource item in collection.GetAllAsync()) + // invoke the operation + string projectName = "myAzDevOpsProject"; + DevOpsProjectData data = new DevOpsProjectData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsProjectData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new DevOpsProjectProperties + { + OnboardingState = ResourceOnboardingState.NotApplicable, + ActionableRemediation = new ActionableRemediation + { + State = ActionableRemediationState.Enabled, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, projectName, data); + DevOpsProjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsProjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +100,10 @@ public async Task Get_GetAzureDevOpsProjects() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureDevOpsProjects() + public async Task GetAll_ListAzureDevOpsProjects() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetAzureDevOpsProjects_example.json - // this example is just showing the usage of "AzureDevOpsProjects_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListAzureDevOpsProjects_example.json + // this example is just showing the usage of "AzureDevOpsProjects_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +122,22 @@ public async Task Exists_GetAzureDevOpsProjects() // get the collection of this DevOpsProjectResource DevOpsProjectCollection collection = devOpsOrg.GetDevOpsProjects(); - // invoke the operation - string projectName = "myAzDevOpsProject"; - bool result = await collection.ExistsAsync(projectName); + // invoke the operation and iterate over the result + await foreach (DevOpsProjectResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsProjectData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureDevOpsProjects() + public async Task Exists_GetAzureDevOpsProjects() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetAzureDevOpsProjects_example.json // this example is just showing the usage of "AzureDevOpsProjects_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +161,17 @@ public async Task GetIfExists_GetAzureDevOpsProjects() // invoke the operation string projectName = "myAzDevOpsProject"; - NullableResponse response = await collection.GetIfExistsAsync(projectName); - DevOpsProjectResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(projectName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsProjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAzureDevOpsProjects() + public async Task GetIfExists_GetAzureDevOpsProjects() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsProjects_example.json - // this example is just showing the usage of "AzureDevOpsProjects_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetAzureDevOpsProjects_example.json + // this example is just showing the usage of "AzureDevOpsProjects_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,25 +192,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAzureDevOpsProjects() // invoke the operation string projectName = "myAzDevOpsProject"; - DevOpsProjectData data = new DevOpsProjectData() - { - Properties = new DevOpsProjectProperties() - { - OnboardingState = ResourceOnboardingState.NotApplicable, - ActionableRemediation = new ActionableRemediation() - { - State = ActionableRemediationState.Enabled, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, projectName, data); - DevOpsProjectResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(projectName); + DevOpsProjectResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsProjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsProjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsProjectResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsProjectResource.cs index d7f46cb137062..c47ae8dbe3715 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsProjectResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsProjectResource.cs @@ -71,12 +71,12 @@ public async Task Update_UpdateAzureDevOpsProjects() DevOpsProjectResource devOpsProject = client.GetDevOpsProjectResource(devOpsProjectResourceId); // invoke the operation - DevOpsProjectData data = new DevOpsProjectData() + DevOpsProjectData data = new DevOpsProjectData { - Properties = new DevOpsProjectProperties() + Properties = new DevOpsProjectProperties { OnboardingState = ResourceOnboardingState.NotApplicable, - ActionableRemediation = new ActionableRemediation() + ActionableRemediation = new ActionableRemediation { State = ActionableRemediationState.Enabled, }, diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsRepositoryCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsRepositoryCollection.cs index d9d2f05bb219c..85cd6420c0000 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsRepositoryCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsRepositoryCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevOpsRepositoryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAzureDevOpsRepos() + public async Task CreateOrUpdate_CreateOrUpdateAzureDevOpsRepos() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListAzureDevOpsRepos_example.json - // this example is just showing the usage of "AzureDevOpsRepos_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsRepos_example.json + // this example is just showing the usage of "AzureDevOpsRepos_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,27 @@ public async Task GetAll_ListAzureDevOpsRepos() // get the collection of this DevOpsRepositoryResource DevOpsRepositoryCollection collection = devOpsProject.GetDevOpsRepositories(); - // invoke the operation and iterate over the result - await foreach (DevOpsRepositoryResource item in collection.GetAllAsync()) + // invoke the operation + string repoName = "myAzDevOpsRepo"; + DevOpsRepositoryData data = new DevOpsRepositoryData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsRepositoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new DevOpsRepositoryProperties + { + OnboardingState = ResourceOnboardingState.NotApplicable, + ActionableRemediation = new ActionableRemediation + { + State = ActionableRemediationState.Enabled, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, repoName, data); + DevOpsRepositoryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsRepositoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +102,10 @@ public async Task Get_GetAzureDevOpsRepos() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureDevOpsRepos() + public async Task GetAll_ListAzureDevOpsRepos() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetAzureDevOpsRepos_example.json - // this example is just showing the usage of "AzureDevOpsRepos_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListAzureDevOpsRepos_example.json + // this example is just showing the usage of "AzureDevOpsRepos_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +125,22 @@ public async Task Exists_GetAzureDevOpsRepos() // get the collection of this DevOpsRepositoryResource DevOpsRepositoryCollection collection = devOpsProject.GetDevOpsRepositories(); - // invoke the operation - string repoName = "myAzDevOpsRepo"; - bool result = await collection.ExistsAsync(repoName); + // invoke the operation and iterate over the result + await foreach (DevOpsRepositoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsRepositoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureDevOpsRepos() + public async Task Exists_GetAzureDevOpsRepos() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetAzureDevOpsRepos_example.json // this example is just showing the usage of "AzureDevOpsRepos_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +165,17 @@ public async Task GetIfExists_GetAzureDevOpsRepos() // invoke the operation string repoName = "myAzDevOpsRepo"; - NullableResponse response = await collection.GetIfExistsAsync(repoName); - DevOpsRepositoryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(repoName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsRepositoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAzureDevOpsRepos() + public async Task GetIfExists_GetAzureDevOpsRepos() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/CreateOrUpdateAzureDevOpsRepos_example.json - // this example is just showing the usage of "AzureDevOpsRepos_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetAzureDevOpsRepos_example.json + // this example is just showing the usage of "AzureDevOpsRepos_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,25 +197,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAzureDevOpsRepos() // invoke the operation string repoName = "myAzDevOpsRepo"; - DevOpsRepositoryData data = new DevOpsRepositoryData() - { - Properties = new DevOpsRepositoryProperties() - { - OnboardingState = ResourceOnboardingState.NotApplicable, - ActionableRemediation = new ActionableRemediation() - { - State = ActionableRemediationState.Enabled, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, repoName, data); - DevOpsRepositoryResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(repoName); + DevOpsRepositoryResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevOpsRepositoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevOpsRepositoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsRepositoryResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsRepositoryResource.cs index 217b386271eae..d83414ac9a072 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsRepositoryResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DevOpsRepositoryResource.cs @@ -73,12 +73,12 @@ public async Task Update_UpdateAzureDevOpsRepos() DevOpsRepositoryResource devOpsRepository = client.GetDevOpsRepositoryResource(devOpsRepositoryResourceId); // invoke the operation - DevOpsRepositoryData data = new DevOpsRepositoryData() + DevOpsRepositoryData data = new DevOpsRepositoryData { - Properties = new DevOpsRepositoryProperties() + Properties = new DevOpsRepositoryProperties { OnboardingState = ResourceOnboardingState.NotApplicable, - ActionableRemediation = new ActionableRemediation() + ActionableRemediation = new ActionableRemediation { State = ActionableRemediationState.Enabled, }, diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DeviceSecurityGroupCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DeviceSecurityGroupCollection.cs index c5677a6ba7ce4..9e49cddc04565 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DeviceSecurityGroupCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DeviceSecurityGroupCollection.cs @@ -19,35 +19,34 @@ public partial class Sample_DeviceSecurityGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllDeviceSecurityGroupsForTheSpecifiedIoTHubResource() + public async Task CreateOrUpdate_CreateOrUpdateADeviceSecurityGroupForTheSpecifiedIoTHubResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/ListDeviceSecurityGroups_example.json - // this example is just showing the usage of "DeviceSecurityGroups_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/PutDeviceSecurityGroups_example.json + // this example is just showing the usage of "DeviceSecurityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DeviceSecurityGroupResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - DeviceSecurityGroupCollection collection = client.GetDeviceSecurityGroups(scopeId); + DeviceSecurityGroupCollection collection = client.GetDeviceSecurityGroups(new ResourceIdentifier(resourceId)); - // invoke the operation and iterate over the result - await foreach (DeviceSecurityGroupResource item in collection.GetAllAsync()) + // invoke the operation + string deviceSecurityGroupName = "samplesecuritygroup"; + DeviceSecurityGroupData data = new DeviceSecurityGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceSecurityGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TimeWindowRules = { new ActiveConnectionsNotInAllowedRange(true, 0, 30, XmlConvert.ToTimeSpan("PT05M")) }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deviceSecurityGroupName, data); + DeviceSecurityGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceSecurityGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -62,13 +61,9 @@ public async Task Get_GetADeviceSecurityGroupForTheSpecifiedIoTHubResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DeviceSecurityGroupResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - DeviceSecurityGroupCollection collection = client.GetDeviceSecurityGroups(scopeId); + DeviceSecurityGroupCollection collection = client.GetDeviceSecurityGroups(new ResourceIdentifier(resourceId)); // invoke the operation string deviceSecurityGroupName = "samplesecuritygroup"; @@ -81,6 +76,35 @@ public async Task Get_GetADeviceSecurityGroupForTheSpecifiedIoTHubResource() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAllDeviceSecurityGroupsForTheSpecifiedIoTHubResource() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/ListDeviceSecurityGroups_example.json + // this example is just showing the usage of "DeviceSecurityGroups_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this DeviceSecurityGroupResource + string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub"; + DeviceSecurityGroupCollection collection = client.GetDeviceSecurityGroups(new ResourceIdentifier(resourceId)); + + // invoke the operation and iterate over the result + await foreach (DeviceSecurityGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceSecurityGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetADeviceSecurityGroupForTheSpecifiedIoTHubResource() @@ -93,13 +117,9 @@ public async Task Exists_GetADeviceSecurityGroupForTheSpecifiedIoTHubResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DeviceSecurityGroupResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - DeviceSecurityGroupCollection collection = client.GetDeviceSecurityGroups(scopeId); + DeviceSecurityGroupCollection collection = client.GetDeviceSecurityGroups(new ResourceIdentifier(resourceId)); // invoke the operation string deviceSecurityGroupName = "samplesecuritygroup"; @@ -120,13 +140,9 @@ public async Task GetIfExists_GetADeviceSecurityGroupForTheSpecifiedIoTHubResour // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DeviceSecurityGroupResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - DeviceSecurityGroupCollection collection = client.GetDeviceSecurityGroups(scopeId); + DeviceSecurityGroupCollection collection = client.GetDeviceSecurityGroups(new ResourceIdentifier(resourceId)); // invoke the operation string deviceSecurityGroupName = "samplesecuritygroup"; @@ -146,44 +162,5 @@ public async Task GetIfExists_GetADeviceSecurityGroupForTheSpecifiedIoTHubResour Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateADeviceSecurityGroupForTheSpecifiedIoTHubResource() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/PutDeviceSecurityGroups_example.json - // this example is just showing the usage of "DeviceSecurityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this DeviceSecurityGroupResource - string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/SampleRG/providers/Microsoft.Devices/iotHubs/sampleiothub"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - DeviceSecurityGroupCollection collection = client.GetDeviceSecurityGroups(scopeId); - - // invoke the operation - string deviceSecurityGroupName = "samplesecuritygroup"; - DeviceSecurityGroupData data = new DeviceSecurityGroupData() - { - TimeWindowRules = -{ -new ActiveConnectionsNotInAllowedRange(true,0,30,XmlConvert.ToTimeSpan("PT05M")) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deviceSecurityGroupName, data); - DeviceSecurityGroupResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceSecurityGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DeviceSecurityGroupResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DeviceSecurityGroupResource.cs index 9deb5523c8f85..710cba45a458c 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DeviceSecurityGroupResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_DeviceSecurityGroupResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetADeviceSecurityGroupForTheSpecifiedIoTHubResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateADeviceSecurityGroupForTheSpecifiedIoTHubResource() + public async Task Delete_DeleteADeviceSecurityGroupForTheSpecifiedIoTHubResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/PutDeviceSecurityGroups_example.json - // this example is just showing the usage of "DeviceSecurityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/DeleteDeviceSecurityGroups_example.json + // this example is just showing the usage of "DeviceSecurityGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,29 +66,17 @@ public async Task Update_CreateOrUpdateADeviceSecurityGroupForTheSpecifiedIoTHub DeviceSecurityGroupResource deviceSecurityGroup = client.GetDeviceSecurityGroupResource(deviceSecurityGroupResourceId); // invoke the operation - DeviceSecurityGroupData data = new DeviceSecurityGroupData() - { - TimeWindowRules = -{ -new ActiveConnectionsNotInAllowedRange(true,0,30,XmlConvert.ToTimeSpan("PT05M")) -}, - }; - ArmOperation lro = await deviceSecurityGroup.UpdateAsync(WaitUntil.Completed, data); - DeviceSecurityGroupResource result = lro.Value; + await deviceSecurityGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeviceSecurityGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteADeviceSecurityGroupForTheSpecifiedIoTHubResource() + public async Task Update_CreateOrUpdateADeviceSecurityGroupForTheSpecifiedIoTHubResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/DeleteDeviceSecurityGroups_example.json - // this example is just showing the usage of "DeviceSecurityGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/DeviceSecurityGroups/PutDeviceSecurityGroups_example.json + // this example is just showing the usage of "DeviceSecurityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,9 +91,18 @@ public async Task Delete_DeleteADeviceSecurityGroupForTheSpecifiedIoTHubResource DeviceSecurityGroupResource deviceSecurityGroup = client.GetDeviceSecurityGroupResource(deviceSecurityGroupResourceId); // invoke the operation - await deviceSecurityGroup.DeleteAsync(WaitUntil.Completed); + DeviceSecurityGroupData data = new DeviceSecurityGroupData + { + TimeWindowRules = { new ActiveConnectionsNotInAllowedRange(true, 0, 30, XmlConvert.ToTimeSpan("PT05M")) }, + }; + ArmOperation lro = await deviceSecurityGroup.UpdateAsync(WaitUntil.Completed, data); + DeviceSecurityGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeviceSecurityGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceAssignmentCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceAssignmentCollection.cs index 6c8611756d211..efac07c961b06 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceAssignmentCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceAssignmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_GovernanceAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGovernanceAssignments() + public async Task CreateOrUpdate_CreateGovernanceAssignment() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/ListGovernanceAssignments_example.json - // this example is just showing the usage of "GovernanceAssignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/PutGovernanceAssignment_example.json + // this example is just showing the usage of "GovernanceAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task GetAll_ListGovernanceAssignments() // this example assumes you already have this SecurityAssessmentResource created on azure // for more information of creating SecurityAssessmentResource, please refer to the document of SecurityAssessmentResource - string scope = "subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd"; + string scope = "subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd/resourceGroups/compute_servers/providers/Microsoft.Compute/virtualMachines/win2012"; string assessmentName = "6b9421dd-5555-2251-9b3d-2be58e2f82cd"; ResourceIdentifier securityAssessmentResourceId = SecurityAssessmentResource.CreateResourceIdentifier(scope, assessmentName); SecurityAssessmentResource securityAssessment = client.GetSecurityAssessmentResource(securityAssessmentResourceId); @@ -38,17 +38,34 @@ public async Task GetAll_ListGovernanceAssignments() // get the collection of this GovernanceAssignmentResource GovernanceAssignmentCollection collection = securityAssessment.GetGovernanceAssignments(); - // invoke the operation and iterate over the result - await foreach (GovernanceAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string assignmentKey = "6634ff9f-127b-4bf2-8e6e-b1737f5e789c"; + GovernanceAssignmentData data = new GovernanceAssignmentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Owner = "user@contoso.com", + RemediationDueOn = DateTimeOffset.Parse("2022-01-07T13:00:00.0000000Z"), + RemediationEta = new RemediationEta(DateTimeOffset.Parse("2022-01-08T13:00:00.0000000Z"), "Justification of ETA"), + IsGracePeriod = true, + GovernanceEmailNotification = new GovernanceEmailNotification + { + IsManagerEmailNotificationDisabled = false, + IsOwnerEmailNotificationDisabled = false, + }, + AdditionalData = new GovernanceAssignmentAdditionalInfo + { + TicketNumber = 123123, + TicketLink = "https://snow.com", + TicketStatus = "Active", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assignmentKey, data); + GovernanceAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +103,10 @@ public async Task Get_GetGovernanceAssignmentBySpecificGovernanceAssignmentKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetGovernanceAssignmentBySpecificGovernanceAssignmentKey() + public async Task GetAll_ListGovernanceAssignments() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/GetGovernanceAssignment_example.json - // this example is just showing the usage of "GovernanceAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/ListGovernanceAssignments_example.json + // this example is just showing the usage of "GovernanceAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,7 +115,7 @@ public async Task Exists_GetGovernanceAssignmentBySpecificGovernanceAssignmentKe // this example assumes you already have this SecurityAssessmentResource created on azure // for more information of creating SecurityAssessmentResource, please refer to the document of SecurityAssessmentResource - string scope = "subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd/resourceGroups/compute_servers/providers/Microsoft.Compute/virtualMachines/win2012"; + string scope = "subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd"; string assessmentName = "6b9421dd-5555-2251-9b3d-2be58e2f82cd"; ResourceIdentifier securityAssessmentResourceId = SecurityAssessmentResource.CreateResourceIdentifier(scope, assessmentName); SecurityAssessmentResource securityAssessment = client.GetSecurityAssessmentResource(securityAssessmentResourceId); @@ -106,16 +123,22 @@ public async Task Exists_GetGovernanceAssignmentBySpecificGovernanceAssignmentKe // get the collection of this GovernanceAssignmentResource GovernanceAssignmentCollection collection = securityAssessment.GetGovernanceAssignments(); - // invoke the operation - string assignmentKey = "6634ff9f-127b-4bf2-8e6e-b1737f5e789c"; - bool result = await collection.ExistsAsync(assignmentKey); + // invoke the operation and iterate over the result + await foreach (GovernanceAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetGovernanceAssignmentBySpecificGovernanceAssignmentKey() + public async Task Exists_GetGovernanceAssignmentBySpecificGovernanceAssignmentKey() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/GetGovernanceAssignment_example.json // this example is just showing the usage of "GovernanceAssignments_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +160,17 @@ public async Task GetIfExists_GetGovernanceAssignmentBySpecificGovernanceAssignm // invoke the operation string assignmentKey = "6634ff9f-127b-4bf2-8e6e-b1737f5e789c"; - NullableResponse response = await collection.GetIfExistsAsync(assignmentKey); - GovernanceAssignmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(assignmentKey); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateGovernanceAssignment() + public async Task GetIfExists_GetGovernanceAssignmentBySpecificGovernanceAssignmentKey() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/PutGovernanceAssignment_example.json - // this example is just showing the usage of "GovernanceAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/GetGovernanceAssignment_example.json + // this example is just showing the usage of "GovernanceAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,32 +189,21 @@ public async Task CreateOrUpdate_CreateGovernanceAssignment() // invoke the operation string assignmentKey = "6634ff9f-127b-4bf2-8e6e-b1737f5e789c"; - GovernanceAssignmentData data = new GovernanceAssignmentData() - { - Owner = "user@contoso.com", - RemediationDueOn = DateTimeOffset.Parse("2022-01-07T13:00:00.0000000Z"), - RemediationEta = new RemediationEta(DateTimeOffset.Parse("2022-01-08T13:00:00.0000000Z"), "Justification of ETA"), - IsGracePeriod = true, - GovernanceEmailNotification = new GovernanceEmailNotification() - { - IsManagerEmailNotificationDisabled = false, - IsOwnerEmailNotificationDisabled = false, - }, - AdditionalData = new GovernanceAssignmentAdditionalInfo() - { - TicketNumber = 123123, - TicketLink = "https://snow.com", - TicketStatus = "Active", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assignmentKey, data); - GovernanceAssignmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(assignmentKey); + GovernanceAssignmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceAssignmentResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceAssignmentResource.cs index 0644a7b6523cb..f592c7481a8df 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceAssignmentResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceAssignmentResource.cs @@ -46,6 +46,32 @@ public async Task Get_GetGovernanceAssignmentBySpecificGovernanceAssignmentKey() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteSecurityAssignment() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/DeleteGovernanceAssignment_example.json + // this example is just showing the usage of "GovernanceAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this GovernanceAssignmentResource created on azure + // for more information of creating GovernanceAssignmentResource, please refer to the document of GovernanceAssignmentResource + string scope = "subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd/resourceGroups/compute_servers/providers/Microsoft.Compute/virtualMachines/win2012"; + string assessmentName = "6b9421dd-5555-2251-9b3d-2be58e2f82cd"; + string assignmentKey = "6634ff9f-127b-4bf2-8e6e-b1737f5e789c"; + ResourceIdentifier governanceAssignmentResourceId = GovernanceAssignmentResource.CreateResourceIdentifier(scope, assessmentName, assignmentKey); + GovernanceAssignmentResource governanceAssignment = client.GetGovernanceAssignmentResource(governanceAssignmentResourceId); + + // invoke the operation + await governanceAssignment.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateGovernanceAssignment() @@ -67,18 +93,18 @@ public async Task Update_CreateGovernanceAssignment() GovernanceAssignmentResource governanceAssignment = client.GetGovernanceAssignmentResource(governanceAssignmentResourceId); // invoke the operation - GovernanceAssignmentData data = new GovernanceAssignmentData() + GovernanceAssignmentData data = new GovernanceAssignmentData { Owner = "user@contoso.com", RemediationDueOn = DateTimeOffset.Parse("2022-01-07T13:00:00.0000000Z"), RemediationEta = new RemediationEta(DateTimeOffset.Parse("2022-01-08T13:00:00.0000000Z"), "Justification of ETA"), IsGracePeriod = true, - GovernanceEmailNotification = new GovernanceEmailNotification() + GovernanceEmailNotification = new GovernanceEmailNotification { IsManagerEmailNotificationDisabled = false, IsOwnerEmailNotificationDisabled = false, }, - AdditionalData = new GovernanceAssignmentAdditionalInfo() + AdditionalData = new GovernanceAssignmentAdditionalInfo { TicketNumber = 123123, TicketLink = "https://snow.com", @@ -94,31 +120,5 @@ public async Task Update_CreateGovernanceAssignment() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSecurityAssignment() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceAssignments/DeleteGovernanceAssignment_example.json - // this example is just showing the usage of "GovernanceAssignments_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this GovernanceAssignmentResource created on azure - // for more information of creating GovernanceAssignmentResource, please refer to the document of GovernanceAssignmentResource - string scope = "subscriptions/c32e05d9-7207-4e22-bdf4-4f7d9c72e5fd/resourceGroups/compute_servers/providers/Microsoft.Compute/virtualMachines/win2012"; - string assessmentName = "6b9421dd-5555-2251-9b3d-2be58e2f82cd"; - string assignmentKey = "6634ff9f-127b-4bf2-8e6e-b1737f5e789c"; - ResourceIdentifier governanceAssignmentResourceId = GovernanceAssignmentResource.CreateResourceIdentifier(scope, assessmentName, assignmentKey); - GovernanceAssignmentResource governanceAssignment = client.GetGovernanceAssignmentResource(governanceAssignmentResourceId); - - // invoke the operation - await governanceAssignment.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceRuleCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceRuleCollection.cs index 12b8ae4f649fd..25c11127db22c 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceRuleCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceRuleCollection.cs @@ -19,101 +19,186 @@ public partial class Sample_GovernanceRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGovernanceRulesByManagementGroupScope() + public async Task CreateOrUpdate_CreateOrUpdateGovernanceRuleOverManagementGroupScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListByManagementGroupGovernanceRules_example.json - // this example is just showing the usage of "GovernanceRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutManagementGroupGovernanceRule_example.json + // this example is just showing the usage of "GovernanceRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource string scope = "providers/Microsoft.Management/managementGroups/contoso"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (GovernanceRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; + GovernanceRuleData data = new GovernanceRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "Management group rule", + Description = "A rule for a management group", + RemediationTimeframe = "7.00:00:00", + IsGracePeriod = true, + RulePriority = 200, + IsDisabled = false, + RuleType = GovernanceRuleType.Integrated, + SourceResourceType = GovernanceRuleSourceResourceType.Assessments, + ExcludedScopes = { "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23" }, + ConditionSets = {BinaryData.FromObjectAsJson(new +{ +conditions = new object[] +{ +new Dictionary +{ +["operator"] = "In", +["property"] = "$.AssessmentKey", +["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]" +} +}, +})}, + OwnerSource = new GovernanceRuleOwnerSource + { + SourceType = GovernanceRuleOwnerSourceType.Manually, + Value = "user@contoso.com", + }, + GovernanceEmailNotification = new GovernanceRuleEmailNotification + { + IsManagerEmailNotificationDisabled = true, + IsOwnerEmailNotificationDisabled = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, data); + GovernanceRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGovernanceRulesBySecurityConnectorScope() + public async Task CreateOrUpdate_CreateOrUpdateGovernanceRuleOverSecurityConnectorScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListBySecurityConnectorGovernanceRules_example.json - // this example is just showing the usage of "GovernanceRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutSecurityConnectorGovernanceRule_example.json + // this example is just showing the usage of "GovernanceRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (GovernanceRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; + GovernanceRuleData data = new GovernanceRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "GCP Admin's rule", + Description = "A rule on critical GCP recommendations", + RemediationTimeframe = "7.00:00:00", + IsGracePeriod = true, + RulePriority = 200, + IsDisabled = false, + RuleType = GovernanceRuleType.Integrated, + SourceResourceType = GovernanceRuleSourceResourceType.Assessments, + ConditionSets = {BinaryData.FromObjectAsJson(new +{ +conditions = new object[] +{ +new Dictionary +{ +["operator"] = "In", +["property"] = "$.AssessmentKey", +["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]" +} +}, +})}, + OwnerSource = new GovernanceRuleOwnerSource + { + SourceType = GovernanceRuleOwnerSourceType.Manually, + Value = "user@contoso.com", + }, + GovernanceEmailNotification = new GovernanceRuleEmailNotification + { + IsManagerEmailNotificationDisabled = true, + IsOwnerEmailNotificationDisabled = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, data); + GovernanceRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGovernanceRulesBySubscriptionScope() + public async Task CreateOrUpdate_CreateOrUpdateGovernanceRuleOverSubscriptionScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListBySubscriptionGovernanceRules_example.json - // this example is just showing the usage of "GovernanceRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutGovernanceRule_example.json + // this example is just showing the usage of "GovernanceRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (GovernanceRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; + GovernanceRuleData data = new GovernanceRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "Admin's rule", + Description = "A rule for critical recommendations", + RemediationTimeframe = "7.00:00:00", + IsGracePeriod = true, + RulePriority = 200, + IsDisabled = false, + RuleType = GovernanceRuleType.Integrated, + SourceResourceType = GovernanceRuleSourceResourceType.Assessments, + ConditionSets = {BinaryData.FromObjectAsJson(new +{ +conditions = new object[] +{ +new Dictionary +{ +["operator"] = "In", +["property"] = "$.AssessmentKey", +["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]" +} +}, +})}, + OwnerSource = new GovernanceRuleOwnerSource + { + SourceType = GovernanceRuleOwnerSourceType.Manually, + Value = "user@contoso.com", + }, + GovernanceEmailNotification = new GovernanceRuleEmailNotification + { + IsManagerEmailNotificationDisabled = false, + IsOwnerEmailNotificationDisabled = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, data); + GovernanceRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -128,13 +213,9 @@ public async Task Get_GetAGovernanceRuleOverManagementGroupScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource string scope = "providers/Microsoft.Management/managementGroups/contoso"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); // invoke the operation string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; @@ -149,9 +230,9 @@ public async Task Get_GetAGovernanceRuleOverManagementGroupScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAGovernanceRuleOverManagementGroupScope() + public async Task Get_GetAGovernanceRuleOverSecurityConnectorScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetManagementGroupGovernanceRule_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetSecurityConnectorGovernanceRule_example.json // this example is just showing the usage of "GovernanceRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -159,26 +240,26 @@ public async Task Exists_GetAGovernanceRuleOverManagementGroupScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource - string scope = "providers/Microsoft.Management/managementGroups/contoso"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector"; + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); // invoke the operation string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - bool result = await collection.ExistsAsync(ruleId); + GovernanceRuleResource result = await collection.GetAsync(ruleId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGovernanceRuleOverManagementGroupScope() + public async Task Get_GetAGovernanceRuleOverSubscriptionScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetManagementGroupGovernanceRule_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetGovernanceRule_example.json // this example is just showing the usage of "GovernanceRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -186,96 +267,113 @@ public async Task GetIfExists_GetAGovernanceRuleOverManagementGroupScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource - string scope = "providers/Microsoft.Management/managementGroups/contoso"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); // invoke the operation string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - NullableResponse response = await collection.GetIfExistsAsync(ruleId); - GovernanceRuleResource result = response.HasValue ? response.Value : null; + GovernanceRuleResource result = await collection.GetAsync(ruleId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListGovernanceRulesByManagementGroupScope() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListByManagementGroupGovernanceRules_example.json + // this example is just showing the usage of "GovernanceRules_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this GovernanceRuleResource + string scope = "providers/Microsoft.Management/managementGroups/contoso"; + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (GovernanceRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GovernanceRuleData resourceData = result.Data; + GovernanceRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGovernanceRuleOverSecurityConnectorScope() + public async Task GetAll_ListGovernanceRulesBySecurityConnectorScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetSecurityConnectorGovernanceRule_example.json - // this example is just showing the usage of "GovernanceRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListBySecurityConnectorGovernanceRules_example.json + // this example is just showing the usage of "GovernanceRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); - // invoke the operation - string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - GovernanceRuleResource result = await collection.GetAsync(ruleId); + // invoke the operation and iterate over the result + await foreach (GovernanceRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAGovernanceRuleOverSecurityConnectorScope() + public async Task GetAll_ListGovernanceRulesBySubscriptionScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetSecurityConnectorGovernanceRule_example.json - // this example is just showing the usage of "GovernanceRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/ListBySubscriptionGovernanceRules_example.json + // this example is just showing the usage of "GovernanceRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource - string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); - // invoke the operation - string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - bool result = await collection.ExistsAsync(ruleId); + // invoke the operation and iterate over the result + await foreach (GovernanceRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGovernanceRuleOverSecurityConnectorScope() + public async Task Exists_GetAGovernanceRuleOverManagementGroupScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetSecurityConnectorGovernanceRule_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetManagementGroupGovernanceRule_example.json // this example is just showing the usage of "GovernanceRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -283,38 +381,22 @@ public async Task GetIfExists_GetAGovernanceRuleOverSecurityConnectorScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource - string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + string scope = "providers/Microsoft.Management/managementGroups/contoso"; + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); // invoke the operation string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - NullableResponse response = await collection.GetIfExistsAsync(ruleId); - GovernanceRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAGovernanceRuleOverSubscriptionScope() + public async Task Exists_GetAGovernanceRuleOverSecurityConnectorScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetGovernanceRule_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetSecurityConnectorGovernanceRule_example.json // this example is just showing the usage of "GovernanceRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -322,23 +404,15 @@ public async Task Get_GetAGovernanceRuleOverSubscriptionScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource - string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector"; + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); // invoke the operation string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - GovernanceRuleResource result = await collection.GetAsync(ruleId); + bool result = await collection.ExistsAsync(ruleId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -353,13 +427,9 @@ public async Task Exists_GetAGovernanceRuleOverSubscriptionScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); // invoke the operation string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; @@ -370,9 +440,9 @@ public async Task Exists_GetAGovernanceRuleOverSubscriptionScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAGovernanceRuleOverSubscriptionScope() + public async Task GetIfExists_GetAGovernanceRuleOverManagementGroupScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetGovernanceRule_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetManagementGroupGovernanceRule_example.json // this example is just showing the usage of "GovernanceRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -380,13 +450,9 @@ public async Task GetIfExists_GetAGovernanceRuleOverSubscriptionScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource - string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + string scope = "providers/Microsoft.Management/managementGroups/contoso"; + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); // invoke the operation string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; @@ -409,195 +475,72 @@ public async Task GetIfExists_GetAGovernanceRuleOverSubscriptionScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateGovernanceRuleOverManagementGroupScope() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutManagementGroupGovernanceRule_example.json - // this example is just showing the usage of "GovernanceRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this GovernanceRuleResource - string scope = "providers/Microsoft.Management/managementGroups/contoso"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); - - // invoke the operation - string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - GovernanceRuleData data = new GovernanceRuleData() - { - DisplayName = "Management group rule", - Description = "A rule for a management group", - RemediationTimeframe = "7.00:00:00", - IsGracePeriod = true, - RulePriority = 200, - IsDisabled = false, - RuleType = GovernanceRuleType.Integrated, - SourceResourceType = GovernanceRuleSourceResourceType.Assessments, - ExcludedScopes = -{ -"/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23" -}, - ConditionSets = -{ -BinaryData.FromObjectAsJson(new Dictionary() -{ -["conditions"] = new object[] { new Dictionary() -{ -["operator"] = "In", -["property"] = "$.AssessmentKey", -["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]"} }}) -}, - OwnerSource = new GovernanceRuleOwnerSource() - { - SourceType = GovernanceRuleOwnerSourceType.Manually, - Value = "user@contoso.com", - }, - GovernanceEmailNotification = new GovernanceRuleEmailNotification() - { - IsManagerEmailNotificationDisabled = true, - IsOwnerEmailNotificationDisabled = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, data); - GovernanceRuleResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateGovernanceRuleOverSecurityConnectorScope() + public async Task GetIfExists_GetAGovernanceRuleOverSecurityConnectorScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutSecurityConnectorGovernanceRule_example.json - // this example is just showing the usage of "GovernanceRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetSecurityConnectorGovernanceRule_example.json + // this example is just showing the usage of "GovernanceRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); // invoke the operation string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - GovernanceRuleData data = new GovernanceRuleData() - { - DisplayName = "GCP Admin's rule", - Description = "A rule on critical GCP recommendations", - RemediationTimeframe = "7.00:00:00", - IsGracePeriod = true, - RulePriority = 200, - IsDisabled = false, - RuleType = GovernanceRuleType.Integrated, - SourceResourceType = GovernanceRuleSourceResourceType.Assessments, - ConditionSets = -{ -BinaryData.FromObjectAsJson(new Dictionary() -{ -["conditions"] = new object[] { new Dictionary() -{ -["operator"] = "In", -["property"] = "$.AssessmentKey", -["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]"} }}) -}, - OwnerSource = new GovernanceRuleOwnerSource() - { - SourceType = GovernanceRuleOwnerSourceType.Manually, - Value = "user@contoso.com", - }, - GovernanceEmailNotification = new GovernanceRuleEmailNotification() - { - IsManagerEmailNotificationDisabled = true, - IsOwnerEmailNotificationDisabled = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, data); - GovernanceRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleId); + GovernanceRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateGovernanceRuleOverSubscriptionScope() + public async Task GetIfExists_GetAGovernanceRuleOverSubscriptionScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/PutGovernanceRule_example.json - // this example is just showing the usage of "GovernanceRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/GetGovernanceRule_example.json + // this example is just showing the usage of "GovernanceRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this GovernanceRuleResource string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - GovernanceRuleCollection collection = client.GetGovernanceRules(scopeId); + GovernanceRuleCollection collection = client.GetGovernanceRules(new ResourceIdentifier(scope)); // invoke the operation string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - GovernanceRuleData data = new GovernanceRuleData() - { - DisplayName = "Admin's rule", - Description = "A rule for critical recommendations", - RemediationTimeframe = "7.00:00:00", - IsGracePeriod = true, - RulePriority = 200, - IsDisabled = false, - RuleType = GovernanceRuleType.Integrated, - SourceResourceType = GovernanceRuleSourceResourceType.Assessments, - ConditionSets = -{ -BinaryData.FromObjectAsJson(new Dictionary() -{ -["conditions"] = new object[] { new Dictionary() -{ -["operator"] = "In", -["property"] = "$.AssessmentKey", -["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]"} }}) -}, - OwnerSource = new GovernanceRuleOwnerSource() - { - SourceType = GovernanceRuleOwnerSourceType.Manually, - Value = "user@contoso.com", - }, - GovernanceEmailNotification = new GovernanceRuleEmailNotification() - { - IsManagerEmailNotificationDisabled = false, - IsOwnerEmailNotificationDisabled = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, data); - GovernanceRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleId); + GovernanceRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GovernanceRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GovernanceRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceRuleResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceRuleResource.cs index 967bd9eadc0c0..78881161f16f9 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceRuleResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_GovernanceRuleResource.cs @@ -104,6 +104,81 @@ public async Task Get_GetAGovernanceRuleOverSubscriptionScope() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAGovernanceRuleOverManagementGroupScope() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteManagementGroupGovernanceRule_example.json + // this example is just showing the usage of "GovernanceRules_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this GovernanceRuleResource created on azure + // for more information of creating GovernanceRuleResource, please refer to the document of GovernanceRuleResource + string scope = "providers/Microsoft.Management/managementGroups/contoso"; + string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; + ResourceIdentifier governanceRuleResourceId = GovernanceRuleResource.CreateResourceIdentifier(scope, ruleId); + GovernanceRuleResource governanceRule = client.GetGovernanceRuleResource(governanceRuleResourceId); + + // invoke the operation + await governanceRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAGovernanceRuleOverSecurityConnectorScope() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteSecurityConnectorGovernanceRule_example.json + // this example is just showing the usage of "GovernanceRules_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this GovernanceRuleResource created on azure + // for more information of creating GovernanceRuleResource, please refer to the document of GovernanceRuleResource + string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector"; + string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; + ResourceIdentifier governanceRuleResourceId = GovernanceRuleResource.CreateResourceIdentifier(scope, ruleId); + GovernanceRuleResource governanceRule = client.GetGovernanceRuleResource(governanceRuleResourceId); + + // invoke the operation + await governanceRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAGovernanceRuleOverSubscriptionScope() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteGovernanceRule_example.json + // this example is just showing the usage of "GovernanceRules_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this GovernanceRuleResource created on azure + // for more information of creating GovernanceRuleResource, please refer to the document of GovernanceRuleResource + string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; + ResourceIdentifier governanceRuleResourceId = GovernanceRuleResource.CreateResourceIdentifier(scope, ruleId); + GovernanceRuleResource governanceRule = client.GetGovernanceRuleResource(governanceRuleResourceId); + + // invoke the operation + await governanceRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateGovernanceRuleOverManagementGroupScope() @@ -124,7 +199,7 @@ public async Task Update_CreateOrUpdateGovernanceRuleOverManagementGroupScope() GovernanceRuleResource governanceRule = client.GetGovernanceRuleResource(governanceRuleResourceId); // invoke the operation - GovernanceRuleData data = new GovernanceRuleData() + GovernanceRuleData data = new GovernanceRuleData { DisplayName = "Management group rule", Description = "A rule for a management group", @@ -134,26 +209,25 @@ public async Task Update_CreateOrUpdateGovernanceRuleOverManagementGroupScope() IsDisabled = false, RuleType = GovernanceRuleType.Integrated, SourceResourceType = GovernanceRuleSourceResourceType.Assessments, - ExcludedScopes = -{ -"/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23" -}, - ConditionSets = + ExcludedScopes = { "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23" }, + ConditionSets = {BinaryData.FromObjectAsJson(new { -BinaryData.FromObjectAsJson(new Dictionary() +conditions = new object[] { -["conditions"] = new object[] { new Dictionary() +new Dictionary { ["operator"] = "In", ["property"] = "$.AssessmentKey", -["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]"} }}) +["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]" +} }, - OwnerSource = new GovernanceRuleOwnerSource() +})}, + OwnerSource = new GovernanceRuleOwnerSource { SourceType = GovernanceRuleOwnerSourceType.Manually, Value = "user@contoso.com", }, - GovernanceEmailNotification = new GovernanceRuleEmailNotification() + GovernanceEmailNotification = new GovernanceRuleEmailNotification { IsManagerEmailNotificationDisabled = true, IsOwnerEmailNotificationDisabled = false, @@ -189,7 +263,7 @@ public async Task Update_CreateOrUpdateGovernanceRuleOverSecurityConnectorScope( GovernanceRuleResource governanceRule = client.GetGovernanceRuleResource(governanceRuleResourceId); // invoke the operation - GovernanceRuleData data = new GovernanceRuleData() + GovernanceRuleData data = new GovernanceRuleData { DisplayName = "GCP Admin's rule", Description = "A rule on critical GCP recommendations", @@ -199,22 +273,24 @@ public async Task Update_CreateOrUpdateGovernanceRuleOverSecurityConnectorScope( IsDisabled = false, RuleType = GovernanceRuleType.Integrated, SourceResourceType = GovernanceRuleSourceResourceType.Assessments, - ConditionSets = + ConditionSets = {BinaryData.FromObjectAsJson(new { -BinaryData.FromObjectAsJson(new Dictionary() +conditions = new object[] { -["conditions"] = new object[] { new Dictionary() +new Dictionary { ["operator"] = "In", ["property"] = "$.AssessmentKey", -["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]"} }}) +["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]" +} }, - OwnerSource = new GovernanceRuleOwnerSource() +})}, + OwnerSource = new GovernanceRuleOwnerSource { SourceType = GovernanceRuleOwnerSourceType.Manually, Value = "user@contoso.com", }, - GovernanceEmailNotification = new GovernanceRuleEmailNotification() + GovernanceEmailNotification = new GovernanceRuleEmailNotification { IsManagerEmailNotificationDisabled = true, IsOwnerEmailNotificationDisabled = false, @@ -250,7 +326,7 @@ public async Task Update_CreateOrUpdateGovernanceRuleOverSubscriptionScope() GovernanceRuleResource governanceRule = client.GetGovernanceRuleResource(governanceRuleResourceId); // invoke the operation - GovernanceRuleData data = new GovernanceRuleData() + GovernanceRuleData data = new GovernanceRuleData { DisplayName = "Admin's rule", Description = "A rule for critical recommendations", @@ -260,22 +336,24 @@ public async Task Update_CreateOrUpdateGovernanceRuleOverSubscriptionScope() IsDisabled = false, RuleType = GovernanceRuleType.Integrated, SourceResourceType = GovernanceRuleSourceResourceType.Assessments, - ConditionSets = + ConditionSets = {BinaryData.FromObjectAsJson(new { -BinaryData.FromObjectAsJson(new Dictionary() +conditions = new object[] { -["conditions"] = new object[] { new Dictionary() +new Dictionary { ["operator"] = "In", ["property"] = "$.AssessmentKey", -["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]"} }}) +["value"] = "[\"b1cd27e0-4ecc-4246-939f-49c426d9d72f\", \"fe83f80b-073d-4ccf-93d9-6797eb870201\"]" +} }, - OwnerSource = new GovernanceRuleOwnerSource() +})}, + OwnerSource = new GovernanceRuleOwnerSource { SourceType = GovernanceRuleOwnerSourceType.Manually, Value = "user@contoso.com", }, - GovernanceEmailNotification = new GovernanceRuleEmailNotification() + GovernanceEmailNotification = new GovernanceRuleEmailNotification { IsManagerEmailNotificationDisabled = false, IsOwnerEmailNotificationDisabled = false, @@ -291,81 +369,6 @@ public async Task Update_CreateOrUpdateGovernanceRuleOverSubscriptionScope() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAGovernanceRuleOverManagementGroupScope() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteManagementGroupGovernanceRule_example.json - // this example is just showing the usage of "GovernanceRules_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this GovernanceRuleResource created on azure - // for more information of creating GovernanceRuleResource, please refer to the document of GovernanceRuleResource - string scope = "providers/Microsoft.Management/managementGroups/contoso"; - string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - ResourceIdentifier governanceRuleResourceId = GovernanceRuleResource.CreateResourceIdentifier(scope, ruleId); - GovernanceRuleResource governanceRule = client.GetGovernanceRuleResource(governanceRuleResourceId); - - // invoke the operation - await governanceRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAGovernanceRuleOverSecurityConnectorScope() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteSecurityConnectorGovernanceRule_example.json - // this example is just showing the usage of "GovernanceRules_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this GovernanceRuleResource created on azure - // for more information of creating GovernanceRuleResource, please refer to the document of GovernanceRuleResource - string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/gcpResourceGroup/providers/Microsoft.Security/securityConnectors/gcpconnector"; - string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - ResourceIdentifier governanceRuleResourceId = GovernanceRuleResource.CreateResourceIdentifier(scope, ruleId); - GovernanceRuleResource governanceRule = client.GetGovernanceRuleResource(governanceRuleResourceId); - - // invoke the operation - await governanceRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAGovernanceRuleOverSubscriptionScope() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-01-01-preview/examples/GovernanceRules/DeleteGovernanceRule_example.json - // this example is just showing the usage of "GovernanceRules_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this GovernanceRuleResource created on azure - // for more information of creating GovernanceRuleResource, please refer to the document of GovernanceRuleResource - string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string ruleId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - ResourceIdentifier governanceRuleResourceId = GovernanceRuleResource.CreateResourceIdentifier(scope, ruleId); - GovernanceRuleResource governanceRule = client.GetGovernanceRuleResource(governanceRuleResourceId); - - // invoke the operation - await governanceRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Execute_ExecuteGovernanceRuleOverSubscriptionScope() diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecurityAggregatedAlertCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecurityAggregatedAlertCollection.cs index c88dd9806b912..c900315401921 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecurityAggregatedAlertCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecurityAggregatedAlertCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_IotSecurityAggregatedAlertCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheAggregatedAlertListOfYoursIoTSecuritySolution() + public async Task Get_GetTheAggregatedSecurityAnalyticsAlertOfYoursIoTSecuritySolutionThisAggregationIsPerformedByAlertName() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAggregatedAlertList.json - // this example is just showing the usage of "IotSecuritySolutionsAnalyticsAggregatedAlert_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAggregatedAlert.json + // this example is just showing the usage of "IotSecuritySolutionsAnalyticsAggregatedAlert_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetTheAggregatedAlertListOfYoursIoTSecuritySolution() // get the collection of this IotSecurityAggregatedAlertResource IotSecurityAggregatedAlertCollection collection = iotSecuritySolutionAnalyticsModel.GetIotSecurityAggregatedAlerts(); - // invoke the operation and iterate over the result - await foreach (IotSecurityAggregatedAlertResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotSecurityAggregatedAlertData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string aggregatedAlertName = "IoT_Bruteforce_Fail/2019-02-02"; + IotSecurityAggregatedAlertResource result = await collection.GetAsync(aggregatedAlertName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotSecurityAggregatedAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheAggregatedSecurityAnalyticsAlertOfYoursIoTSecuritySolutionThisAggregationIsPerformedByAlertName() + public async Task GetAll_GetTheAggregatedAlertListOfYoursIoTSecuritySolution() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAggregatedAlert.json - // this example is just showing the usage of "IotSecuritySolutionsAnalyticsAggregatedAlert_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityAggregatedAlertList.json + // this example is just showing the usage of "IotSecuritySolutionsAnalyticsAggregatedAlert_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetTheAggregatedSecurityAnalyticsAlertOfYoursIoTSecuritySo // get the collection of this IotSecurityAggregatedAlertResource IotSecurityAggregatedAlertCollection collection = iotSecuritySolutionAnalyticsModel.GetIotSecurityAggregatedAlerts(); - // invoke the operation - string aggregatedAlertName = "IoT_Bruteforce_Fail/2019-02-02"; - IotSecurityAggregatedAlertResource result = await collection.GetAsync(aggregatedAlertName); + // invoke the operation and iterate over the result + await foreach (IotSecurityAggregatedAlertResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotSecurityAggregatedAlertData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotSecurityAggregatedAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecurityAggregatedRecommendationCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecurityAggregatedRecommendationCollection.cs index 861372003ec60..8bd7fcd14dda4 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecurityAggregatedRecommendationCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecurityAggregatedRecommendationCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetTheAggregatedSecurityAnalyticsRecommendationOfYoursIoTS [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheAggregatedSecurityAnalyticsRecommendationOfYoursIoTSecuritySolution() + public async Task GetAll_GetTheListOfAggregatedSecurityAnalyticsRecommendationsOfYoursIoTSecuritySolution() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityRecommendation.json - // this example is just showing the usage of "IotSecuritySolutionsAnalyticsRecommendation_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityRecommendationList.json + // this example is just showing the usage of "IotSecuritySolutionsAnalyticsRecommendation_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetTheAggregatedSecurityAnalyticsRecommendationOfYoursI // get the collection of this IotSecurityAggregatedRecommendationResource IotSecurityAggregatedRecommendationCollection collection = iotSecuritySolutionAnalyticsModel.GetIotSecurityAggregatedRecommendations(); - // invoke the operation - string aggregatedRecommendationName = "OpenPortsOnDevice"; - bool result = await collection.ExistsAsync(aggregatedRecommendationName); + // invoke the operation and iterate over the result + await foreach (IotSecurityAggregatedRecommendationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotSecurityAggregatedRecommendationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheAggregatedSecurityAnalyticsRecommendationOfYoursIoTSecuritySolution() + public async Task Exists_GetTheAggregatedSecurityAnalyticsRecommendationOfYoursIoTSecuritySolution() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityRecommendation.json // this example is just showing the usage of "IotSecuritySolutionsAnalyticsRecommendation_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetTheAggregatedSecurityAnalyticsRecommendationOfY // invoke the operation string aggregatedRecommendationName = "OpenPortsOnDevice"; - NullableResponse response = await collection.GetIfExistsAsync(aggregatedRecommendationName); - IotSecurityAggregatedRecommendationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(aggregatedRecommendationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotSecurityAggregatedRecommendationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheListOfAggregatedSecurityAnalyticsRecommendationsOfYoursIoTSecuritySolution() + public async Task GetIfExists_GetTheAggregatedSecurityAnalyticsRecommendationOfYoursIoTSecuritySolution() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityRecommendationList.json - // this example is just showing the usage of "IotSecuritySolutionsAnalyticsRecommendation_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutionsAnalytics/GetIoTSecuritySolutionsSecurityRecommendation.json + // this example is just showing the usage of "IotSecuritySolutionsAnalyticsRecommendation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_GetTheListOfAggregatedSecurityAnalyticsRecommendationsO // get the collection of this IotSecurityAggregatedRecommendationResource IotSecurityAggregatedRecommendationCollection collection = iotSecuritySolutionAnalyticsModel.GetIotSecurityAggregatedRecommendations(); - // invoke the operation and iterate over the result - await foreach (IotSecurityAggregatedRecommendationResource item in collection.GetAllAsync()) + // invoke the operation + string aggregatedRecommendationName = "OpenPortsOnDevice"; + NullableResponse response = await collection.GetIfExistsAsync(aggregatedRecommendationName); + IotSecurityAggregatedRecommendationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IotSecurityAggregatedRecommendationData resourceData = item.Data; + IotSecurityAggregatedRecommendationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecuritySolutionCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecuritySolutionCollection.cs index 09e015e76e58d..bfb8dc9c09337 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecuritySolutionCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecuritySolutionCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_IotSecuritySolutionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIoTSecuritySolutionsByResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateAIoTSecuritySolution() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByRg.json - // this example is just showing the usage of "IotSecuritySolution_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/CreateIoTSecuritySolution.json + // this example is just showing the usage of "IotSecuritySolution_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,24 +39,69 @@ public async Task GetAll_ListIoTSecuritySolutionsByResourceGroup() // get the collection of this IotSecuritySolutionResource IotSecuritySolutionCollection collection = resourceGroupResource.GetIotSecuritySolutions(); - // invoke the operation and iterate over the result - await foreach (IotSecuritySolutionResource item in collection.GetAllAsync()) + // invoke the operation + string solutionName = "default"; + IotSecuritySolutionData data = new IotSecuritySolutionData(new AzureLocation("East Us")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotSecuritySolutionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Workspace = "/subscriptions/c4930e90-cd72-4aa5-93e9-2d081d129569/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace1", + DisplayName = "Solution Default", + Status = SecuritySolutionStatus.Enabled, + Export = { }, + DisabledDataSources = { }, + IotHubs = { "/subscriptions/075423e9-7d33-4166-8bdf-3920b04e3735/resourceGroups/myRg/providers/Microsoft.Devices/IotHubs/FirstIotHub" }, + UserDefinedResources = new UserDefinedResourcesProperties("where type != \"microsoft.devices/iothubs\" | where name contains \"iot\"", new string[] { "075423e9-7d33-4166-8bdf-3920b04e3735" }), + RecommendationsConfiguration = { new RecommendationConfigurationProperties(IotSecurityRecommendationType.IotOpenPorts, RecommendationConfigStatus.Disabled), new RecommendationConfigurationProperties(IotSecurityRecommendationType.IotSharedCredentials, RecommendationConfigStatus.Disabled) }, + UnmaskedIPLoggingStatus = UnmaskedIPLoggingStatus.Enabled, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, solutionName, data); + IotSecuritySolutionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotSecuritySolutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIoTSecuritySolutionsByResourceGroupAndIoTHub() + public async Task Get_GetAIoTSecuritySolution() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByIotHubAndRg.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolution.json + // this example is just showing the usage of "IotSecuritySolution_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + string resourceGroupName = "MyGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this IotSecuritySolutionResource + IotSecuritySolutionCollection collection = resourceGroupResource.GetIotSecuritySolutions(); + + // invoke the operation + string solutionName = "default"; + IotSecuritySolutionResource result = await collection.GetAsync(solutionName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotSecuritySolutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListIoTSecuritySolutionsByResourceGroup() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByRg.json // this example is just showing the usage of "IotSecuritySolution_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -67,7 +112,7 @@ public async Task GetAll_ListIoTSecuritySolutionsByResourceGroupAndIoTHub() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string resourceGroupName = "MyRg"; + string resourceGroupName = "MyGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -75,8 +120,7 @@ public async Task GetAll_ListIoTSecuritySolutionsByResourceGroupAndIoTHub() IotSecuritySolutionCollection collection = resourceGroupResource.GetIotSecuritySolutions(); // invoke the operation and iterate over the result - string filter = "properties.iotHubs/any(i eq \"/subscriptions/075423e9-7d33-4166-8bdf-3920b04e3735/resourceGroups/myRg/providers/Microsoft.Devices/IotHubs/FirstIotHub\")"; - await foreach (IotSecuritySolutionResource item in collection.GetAllAsync(filter: filter)) + await foreach (IotSecuritySolutionResource item in collection.GetAllAsync()) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,10 +134,10 @@ public async Task GetAll_ListIoTSecuritySolutionsByResourceGroupAndIoTHub() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAIoTSecuritySolution() + public async Task GetAll_ListIoTSecuritySolutionsByResourceGroupAndIoTHub() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolution.json - // this example is just showing the usage of "IotSecuritySolution_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByIotHubAndRg.json + // this example is just showing the usage of "IotSecuritySolution_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,22 +147,25 @@ public async Task Get_GetAIoTSecuritySolution() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string resourceGroupName = "MyGroup"; + string resourceGroupName = "MyRg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this IotSecuritySolutionResource IotSecuritySolutionCollection collection = resourceGroupResource.GetIotSecuritySolutions(); - // invoke the operation - string solutionName = "default"; - IotSecuritySolutionResource result = await collection.GetAsync(solutionName); + // invoke the operation and iterate over the result + string filter = "properties.iotHubs/any(i eq \"/subscriptions/075423e9-7d33-4166-8bdf-3920b04e3735/resourceGroups/myRg/providers/Microsoft.Devices/IotHubs/FirstIotHub\")"; + await foreach (IotSecuritySolutionResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotSecuritySolutionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotSecuritySolutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -190,67 +237,5 @@ public async Task GetIfExists_GetAIoTSecuritySolution() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAIoTSecuritySolution() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/CreateIoTSecuritySolution.json - // this example is just showing the usage of "IotSecuritySolution_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string resourceGroupName = "MyGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this IotSecuritySolutionResource - IotSecuritySolutionCollection collection = resourceGroupResource.GetIotSecuritySolutions(); - - // invoke the operation - string solutionName = "default"; - IotSecuritySolutionData data = new IotSecuritySolutionData(new AzureLocation("East Us")) - { - Workspace = "/subscriptions/c4930e90-cd72-4aa5-93e9-2d081d129569/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace1", - DisplayName = "Solution Default", - Status = SecuritySolutionStatus.Enabled, - Export = -{ -}, - DisabledDataSources = -{ -}, - IotHubs = -{ -"/subscriptions/075423e9-7d33-4166-8bdf-3920b04e3735/resourceGroups/myRg/providers/Microsoft.Devices/IotHubs/FirstIotHub" -}, - UserDefinedResources = new UserDefinedResourcesProperties("where type != \"microsoft.devices/iothubs\" | where name contains \"iot\"", new string[] - { -"075423e9-7d33-4166-8bdf-3920b04e3735" - }), - RecommendationsConfiguration = -{ -new RecommendationConfigurationProperties(IotSecurityRecommendationType.IotOpenPorts,RecommendationConfigStatus.Disabled),new RecommendationConfigurationProperties(IotSecurityRecommendationType.IotSharedCredentials,RecommendationConfigStatus.Disabled) -}, - UnmaskedIPLoggingStatus = UnmaskedIPLoggingStatus.Enabled, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, solutionName, data); - IotSecuritySolutionResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotSecuritySolutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecuritySolutionResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecuritySolutionResource.cs index 34d80693adf14..c636b2fb39baf 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecuritySolutionResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_IotSecuritySolutionResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SecurityCenter.Models; using NUnit.Framework; @@ -17,69 +16,6 @@ namespace Azure.ResourceManager.SecurityCenter.Samples { public partial class Sample_IotSecuritySolutionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIotSecuritySolutions_ListIoTSecuritySolutionsByIoTHub() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByIotHub.json - // this example is just showing the usage of "IotSecuritySolution_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string filter = "properties.iotHubs/any(i eq \"/subscriptions/075423e9-7d33-4166-8bdf-3920b04e3735/resourceGroups/myRg/providers/Microsoft.Devices/IotHubs/FirstIotHub\")"; - await foreach (IotSecuritySolutionResource item in subscriptionResource.GetIotSecuritySolutionsAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotSecuritySolutionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIotSecuritySolutions_ListIoTSecuritySolutionsBySubscription() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsList.json - // this example is just showing the usage of "IotSecuritySolution_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (IotSecuritySolutionResource item in subscriptionResource.GetIotSecuritySolutionsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotSecuritySolutionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAIoTSecuritySolution() @@ -112,10 +48,10 @@ public async Task Get_GetAIoTSecuritySolution() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UseThisMethodToUpdateExistingIoTSecuritySolution() + public async Task Delete_DeleteAnIoTSecuritySolution() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/UpdateIoTSecuritySolution.json - // this example is just showing the usage of "IotSecuritySolution_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/DeleteIoTSecuritySolution.json + // this example is just showing the usage of "IotSecuritySolution_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,42 +61,23 @@ public async Task Update_UseThisMethodToUpdateExistingIoTSecuritySolution() // this example assumes you already have this IotSecuritySolutionResource created on azure // for more information of creating IotSecuritySolutionResource, please refer to the document of IotSecuritySolutionResource string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string resourceGroupName = "myRg"; + string resourceGroupName = "MyGroup"; string solutionName = "default"; ResourceIdentifier iotSecuritySolutionResourceId = IotSecuritySolutionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, solutionName); IotSecuritySolutionResource iotSecuritySolution = client.GetIotSecuritySolutionResource(iotSecuritySolutionResourceId); // invoke the operation - IotSecuritySolutionPatch patch = new IotSecuritySolutionPatch() - { - UserDefinedResources = new UserDefinedResourcesProperties("where type != \"microsoft.devices/iothubs\" | where name contains \"v2\"", new string[] - { -"075423e9-7d33-4166-8bdf-3920b04e3735" - }), - RecommendationsConfiguration = -{ -new RecommendationConfigurationProperties(IotSecurityRecommendationType.IotOpenPorts,RecommendationConfigStatus.Disabled),new RecommendationConfigurationProperties(IotSecurityRecommendationType.IotSharedCredentials,RecommendationConfigStatus.Disabled) -}, - Tags = -{ -["foo"] = "bar", -}, - }; - IotSecuritySolutionResource result = await iotSecuritySolution.UpdateAsync(patch); + await iotSecuritySolution.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IotSecuritySolutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnIoTSecuritySolution() + public async Task Update_UseThisMethodToUpdateExistingIoTSecuritySolution() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/DeleteIoTSecuritySolution.json - // this example is just showing the usage of "IotSecuritySolution_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/UpdateIoTSecuritySolution.json + // this example is just showing the usage of "IotSecuritySolution_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -170,15 +87,28 @@ public async Task Delete_DeleteAnIoTSecuritySolution() // this example assumes you already have this IotSecuritySolutionResource created on azure // for more information of creating IotSecuritySolutionResource, please refer to the document of IotSecuritySolutionResource string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string resourceGroupName = "MyGroup"; + string resourceGroupName = "myRg"; string solutionName = "default"; ResourceIdentifier iotSecuritySolutionResourceId = IotSecuritySolutionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, solutionName); IotSecuritySolutionResource iotSecuritySolution = client.GetIotSecuritySolutionResource(iotSecuritySolutionResourceId); // invoke the operation - await iotSecuritySolution.DeleteAsync(WaitUntil.Completed); + IotSecuritySolutionPatch patch = new IotSecuritySolutionPatch + { + UserDefinedResources = new UserDefinedResourcesProperties("where type != \"microsoft.devices/iothubs\" | where name contains \"v2\"", new string[] { "075423e9-7d33-4166-8bdf-3920b04e3735" }), + RecommendationsConfiguration = { new RecommendationConfigurationProperties(IotSecurityRecommendationType.IotOpenPorts, RecommendationConfigStatus.Disabled), new RecommendationConfigurationProperties(IotSecurityRecommendationType.IotSharedCredentials, RecommendationConfigStatus.Disabled) }, + Tags = +{ +["foo"] = "bar" +}, + }; + IotSecuritySolutionResource result = await iotSecuritySolution.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotSecuritySolutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_JitNetworkAccessPolicyCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_JitNetworkAccessPolicyCollection.cs index 1aa003a5697ea..461523c6bdb18 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_JitNetworkAccessPolicyCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_JitNetworkAccessPolicyCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_JitNetworkAccessPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetJITNetworkAccessPoliciesOnAResourceGroupFromASecurityDataLocation() + public async Task CreateOrUpdate_CreateJITNetworkAccessPolicy() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesResourceGroupLocation_example.json - // this example is just showing the usage of "JitNetworkAccessPolicies_ListByResourceGroupAndRegion" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/CreateJitNetworkAccessPolicy_example.json + // this example is just showing the usage of "JitNetworkAccessPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,43 @@ public async Task GetAll_GetJITNetworkAccessPoliciesOnAResourceGroupFromASecurit AzureLocation ascLocation = new AzureLocation("westeurope"); JitNetworkAccessPolicyCollection collection = resourceGroupResource.GetJitNetworkAccessPolicies(ascLocation); - // invoke the operation and iterate over the result - await foreach (JitNetworkAccessPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string jitNetworkAccessPolicyName = "default"; + JitNetworkAccessPolicyData data = new JitNetworkAccessPolicyData(new JitNetworkAccessPolicyVirtualMachine[] { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - JitNetworkAccessPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } +new JitNetworkAccessPolicyVirtualMachine(new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"), new JitNetworkAccessPortRule[] +{ +new JitNetworkAccessPortRule(22, JitNetworkAccessPortProtocol.All, XmlConvert.ToTimeSpan("PT3H")) +{ +AllowedSourceAddressPrefix = "*", +}, +new JitNetworkAccessPortRule(3389, JitNetworkAccessPortProtocol.All, XmlConvert.ToTimeSpan("PT3H")) +{ +AllowedSourceAddressPrefix = "*", +} +}) + }) + { + Requests = {new JitNetworkAccessRequestInfo(new JitNetworkAccessRequestVirtualMachine[] +{ +new JitNetworkAccessRequestVirtualMachine(new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"), new JitNetworkAccessRequestPort[] +{ +new JitNetworkAccessRequestPort(3389, DateTimeOffset.Parse("2018-05-17T09:06:45.5691611Z"), JitNetworkAccessPortStatus.Initiated, JitNetworkAccessPortStatusReason.UserRequested) +{ +AllowedSourceAddressPrefix = "192.127.0.2", +} +}) +}, DateTimeOffset.Parse("2018-05-17T08:06:45.5691611Z"), "barbara@contoso.com")}, + Kind = "Basic", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jitNetworkAccessPolicyName, data); + JitNetworkAccessPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + JitNetworkAccessPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +116,10 @@ public async Task Get_GetJITNetworkAccessPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetJITNetworkAccessPolicy() + public async Task GetAll_GetJITNetworkAccessPoliciesOnAResourceGroupFromASecurityDataLocation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPolicy_example.json - // this example is just showing the usage of "JitNetworkAccessPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesResourceGroupLocation_example.json + // this example is just showing the usage of "JitNetworkAccessPolicies_ListByResourceGroupAndRegion" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +137,22 @@ public async Task Exists_GetJITNetworkAccessPolicy() AzureLocation ascLocation = new AzureLocation("westeurope"); JitNetworkAccessPolicyCollection collection = resourceGroupResource.GetJitNetworkAccessPolicies(ascLocation); - // invoke the operation - string jitNetworkAccessPolicyName = "default"; - bool result = await collection.ExistsAsync(jitNetworkAccessPolicyName); + // invoke the operation and iterate over the result + await foreach (JitNetworkAccessPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + JitNetworkAccessPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetJITNetworkAccessPolicy() + public async Task Exists_GetJITNetworkAccessPolicy() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPolicy_example.json // this example is just showing the usage of "JitNetworkAccessPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,29 +175,17 @@ public async Task GetIfExists_GetJITNetworkAccessPolicy() // invoke the operation string jitNetworkAccessPolicyName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(jitNetworkAccessPolicyName); - JitNetworkAccessPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(jitNetworkAccessPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - JitNetworkAccessPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateJITNetworkAccessPolicy() + public async Task GetIfExists_GetJITNetworkAccessPolicy() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/CreateJitNetworkAccessPolicy_example.json - // this example is just showing the usage of "JitNetworkAccessPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPolicy_example.json + // this example is just showing the usage of "JitNetworkAccessPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,43 +205,21 @@ public async Task CreateOrUpdate_CreateJITNetworkAccessPolicy() // invoke the operation string jitNetworkAccessPolicyName = "default"; - JitNetworkAccessPolicyData data = new JitNetworkAccessPolicyData(new JitNetworkAccessPolicyVirtualMachine[] + NullableResponse response = await collection.GetIfExistsAsync(jitNetworkAccessPolicyName); + JitNetworkAccessPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new JitNetworkAccessPolicyVirtualMachine(new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"),new JitNetworkAccessPortRule[] -{ -new JitNetworkAccessPortRule(22,JitNetworkAccessPortProtocol.All,XmlConvert.ToTimeSpan("PT3H")) -{ -AllowedSourceAddressPrefix = "*", -},new JitNetworkAccessPortRule(3389,JitNetworkAccessPortProtocol.All,XmlConvert.ToTimeSpan("PT3H")) -{ -AllowedSourceAddressPrefix = "*", -} -}) - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Requests = -{ -new JitNetworkAccessRequestInfo(new JitNetworkAccessRequestVirtualMachine[] -{ -new JitNetworkAccessRequestVirtualMachine(new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"),new JitNetworkAccessRequestPort[] -{ -new JitNetworkAccessRequestPort(3389,DateTimeOffset.Parse("2018-05-17T09:06:45.5691611Z"),JitNetworkAccessPortStatus.Initiated,JitNetworkAccessPortStatusReason.UserRequested) -{ -AllowedSourceAddressPrefix = "192.127.0.2", -} -}) -},DateTimeOffset.Parse("2018-05-17T08:06:45.5691611Z"),"barbara@contoso.com") -}, - Kind = "Basic", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jitNetworkAccessPolicyName, data); - JitNetworkAccessPolicyResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - JitNetworkAccessPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + JitNetworkAccessPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_JitNetworkAccessPolicyResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_JitNetworkAccessPolicyResource.cs index 1db6e0fe23de5..0660eb556f036 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_JitNetworkAccessPolicyResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_JitNetworkAccessPolicyResource.cs @@ -10,7 +10,6 @@ using System.Xml; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SecurityCenter.Models; using NUnit.Framework; @@ -20,73 +19,41 @@ public partial class Sample_JitNetworkAccessPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetJitNetworkAccessPolicies_GetJITNetworkAccessPoliciesOnASubscription() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesSubscription_example.json - // this example is just showing the usage of "JitNetworkAccessPolicies_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (JitNetworkAccessPolicyResource item in subscriptionResource.GetJitNetworkAccessPoliciesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - JitNetworkAccessPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetJitNetworkAccessPolicies_GetJITNetworkAccessPoliciesOnAResourceGroup() + public async Task Get_GetJITNetworkAccessPolicy() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesResourceGroup_example.json - // this example is just showing the usage of "JitNetworkAccessPolicies_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPolicy_example.json + // this example is just showing the usage of "JitNetworkAccessPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + // this example assumes you already have this JitNetworkAccessPolicyResource created on azure + // for more information of creating JitNetworkAccessPolicyResource, please refer to the document of JitNetworkAccessPolicyResource string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; string resourceGroupName = "myRg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + AzureLocation ascLocation = new AzureLocation("westeurope"); + string jitNetworkAccessPolicyName = "default"; + ResourceIdentifier jitNetworkAccessPolicyResourceId = JitNetworkAccessPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, ascLocation, jitNetworkAccessPolicyName); + JitNetworkAccessPolicyResource jitNetworkAccessPolicy = client.GetJitNetworkAccessPolicyResource(jitNetworkAccessPolicyResourceId); - // invoke the operation and iterate over the result - await foreach (JitNetworkAccessPolicyResource item in resourceGroupResource.GetJitNetworkAccessPoliciesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - JitNetworkAccessPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + JitNetworkAccessPolicyResource result = await jitNetworkAccessPolicy.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + JitNetworkAccessPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetJITNetworkAccessPolicy() + public async Task Delete_DeleteAJITNetworkAccessPolicy() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPolicy_example.json - // this example is just showing the usage of "JitNetworkAccessPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/DeleteJitNetworkAccessPolicy_example.json + // this example is just showing the usage of "JitNetworkAccessPolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,13 +70,9 @@ public async Task Get_GetJITNetworkAccessPolicy() JitNetworkAccessPolicyResource jitNetworkAccessPolicy = client.GetJitNetworkAccessPolicyResource(jitNetworkAccessPolicyResourceId); // invoke the operation - JitNetworkAccessPolicyResource result = await jitNetworkAccessPolicy.GetAsync(); + await jitNetworkAccessPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - JitNetworkAccessPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -136,31 +99,29 @@ public async Task Update_CreateJITNetworkAccessPolicy() // invoke the operation JitNetworkAccessPolicyData data = new JitNetworkAccessPolicyData(new JitNetworkAccessPolicyVirtualMachine[] { -new JitNetworkAccessPolicyVirtualMachine(new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"),new JitNetworkAccessPortRule[] +new JitNetworkAccessPolicyVirtualMachine(new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"), new JitNetworkAccessPortRule[] { -new JitNetworkAccessPortRule(22,JitNetworkAccessPortProtocol.All,XmlConvert.ToTimeSpan("PT3H")) +new JitNetworkAccessPortRule(22, JitNetworkAccessPortProtocol.All, XmlConvert.ToTimeSpan("PT3H")) { AllowedSourceAddressPrefix = "*", -},new JitNetworkAccessPortRule(3389,JitNetworkAccessPortProtocol.All,XmlConvert.ToTimeSpan("PT3H")) +}, +new JitNetworkAccessPortRule(3389, JitNetworkAccessPortProtocol.All, XmlConvert.ToTimeSpan("PT3H")) { AllowedSourceAddressPrefix = "*", } }) }) { - Requests = + Requests = {new JitNetworkAccessRequestInfo(new JitNetworkAccessRequestVirtualMachine[] { -new JitNetworkAccessRequestInfo(new JitNetworkAccessRequestVirtualMachine[] +new JitNetworkAccessRequestVirtualMachine(new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"), new JitNetworkAccessRequestPort[] { -new JitNetworkAccessRequestVirtualMachine(new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"),new JitNetworkAccessRequestPort[] -{ -new JitNetworkAccessRequestPort(3389,DateTimeOffset.Parse("2018-05-17T09:06:45.5691611Z"),JitNetworkAccessPortStatus.Initiated,JitNetworkAccessPortStatusReason.UserRequested) +new JitNetworkAccessRequestPort(3389, DateTimeOffset.Parse("2018-05-17T09:06:45.5691611Z"), JitNetworkAccessPortStatus.Initiated, JitNetworkAccessPortStatusReason.UserRequested) { AllowedSourceAddressPrefix = "192.127.0.2", } }) -},DateTimeOffset.Parse("2018-05-17T08:06:45.5691611Z"),"barbara@contoso.com") -}, +}, DateTimeOffset.Parse("2018-05-17T08:06:45.5691611Z"), "barbara@contoso.com")}, Kind = "Basic", }; ArmOperation lro = await jitNetworkAccessPolicy.UpdateAsync(WaitUntil.Completed, data); @@ -173,33 +134,6 @@ public async Task Update_CreateJITNetworkAccessPolicy() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAJITNetworkAccessPolicy() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/DeleteJitNetworkAccessPolicy_example.json - // this example is just showing the usage of "JitNetworkAccessPolicies_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this JitNetworkAccessPolicyResource created on azure - // for more information of creating JitNetworkAccessPolicyResource, please refer to the document of JitNetworkAccessPolicyResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string resourceGroupName = "myRg1"; - AzureLocation ascLocation = new AzureLocation("westeurope"); - string jitNetworkAccessPolicyName = "default"; - ResourceIdentifier jitNetworkAccessPolicyResourceId = JitNetworkAccessPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, ascLocation, jitNetworkAccessPolicyName); - JitNetworkAccessPolicyResource jitNetworkAccessPolicy = client.GetJitNetworkAccessPolicyResource(jitNetworkAccessPolicyResourceId); - - // invoke the operation - await jitNetworkAccessPolicy.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Initiate_InitiateAnActionOnAJITNetworkAccessPolicy() @@ -224,9 +158,9 @@ public async Task Initiate_InitiateAnActionOnAJITNetworkAccessPolicy() // invoke the operation JitNetworkAccessPolicyInitiateContent content = new JitNetworkAccessPolicyInitiateContent(new JitNetworkAccessPolicyInitiateVirtualMachine[] { -new JitNetworkAccessPolicyInitiateVirtualMachine(new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"),new JitNetworkAccessPolicyInitiatePort[] +new JitNetworkAccessPolicyInitiateVirtualMachine(new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg1/providers/Microsoft.Compute/virtualMachines/vm1"), new JitNetworkAccessPolicyInitiatePort[] { -new JitNetworkAccessPolicyInitiatePort(3389,DateTimeOffset.Parse("placeholder")) +new JitNetworkAccessPolicyInitiatePort(3389, default) { AllowedSourceAddressPrefix = "192.127.0.2", } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceAssessmentCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceAssessmentCollection.cs index 2a95d13baf5bb..5f041e61449e5 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceAssessmentCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceAssessmentCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RegulatoryComplianceAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllAssessmentsMappedToSelectedRegulatoryComplianceControl() + public async Task Get_GetSelectedRegulatoryComplianceAssessmentDetailsAndState() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceAssessmentList_example.json - // this example is just showing the usage of "RegulatoryComplianceAssessments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceAssessment_example.json + // this example is just showing the usage of "RegulatoryComplianceAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetAllAssessmentsMappedToSelectedRegulatoryComplianceCo // get the collection of this RegulatoryComplianceAssessmentResource RegulatoryComplianceAssessmentCollection collection = regulatoryComplianceControl.GetRegulatoryComplianceAssessments(); - // invoke the operation and iterate over the result - await foreach (RegulatoryComplianceAssessmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RegulatoryComplianceAssessmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string regulatoryComplianceAssessmentName = "968548cb-02b3-8cd2-11f8-0cf64ab1a347"; + RegulatoryComplianceAssessmentResource result = await collection.GetAsync(regulatoryComplianceAssessmentName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegulatoryComplianceAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSelectedRegulatoryComplianceAssessmentDetailsAndState() + public async Task GetAll_GetAllAssessmentsMappedToSelectedRegulatoryComplianceControl() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceAssessment_example.json - // this example is just showing the usage of "RegulatoryComplianceAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceAssessmentList_example.json + // this example is just showing the usage of "RegulatoryComplianceAssessments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetSelectedRegulatoryComplianceAssessmentDetailsAndState() // get the collection of this RegulatoryComplianceAssessmentResource RegulatoryComplianceAssessmentCollection collection = regulatoryComplianceControl.GetRegulatoryComplianceAssessments(); - // invoke the operation - string regulatoryComplianceAssessmentName = "968548cb-02b3-8cd2-11f8-0cf64ab1a347"; - RegulatoryComplianceAssessmentResource result = await collection.GetAsync(regulatoryComplianceAssessmentName); + // invoke the operation and iterate over the result + await foreach (RegulatoryComplianceAssessmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegulatoryComplianceAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RegulatoryComplianceAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceControlCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceControlCollection.cs index 15ae91aa18f43..ba076c5afb03c 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceControlCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceControlCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RegulatoryComplianceControlCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllRegulatoryComplianceControlsDetailsAndStateForSelectedStandard() + public async Task Get_GetSelectedRegulatoryComplianceControlDetailsAndState() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceControlList_example.json - // this example is just showing the usage of "RegulatoryComplianceControls_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceControl_example.json + // this example is just showing the usage of "RegulatoryComplianceControls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_GetAllRegulatoryComplianceControlsDetailsAndStateForSel // get the collection of this RegulatoryComplianceControlResource RegulatoryComplianceControlCollection collection = regulatoryComplianceStandard.GetRegulatoryComplianceControls(); - // invoke the operation and iterate over the result - await foreach (RegulatoryComplianceControlResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RegulatoryComplianceControlData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string regulatoryComplianceControlName = "1.1"; + RegulatoryComplianceControlResource result = await collection.GetAsync(regulatoryComplianceControlName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegulatoryComplianceControlData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSelectedRegulatoryComplianceControlDetailsAndState() + public async Task GetAll_GetAllRegulatoryComplianceControlsDetailsAndStateForSelectedStandard() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceControl_example.json - // this example is just showing the usage of "RegulatoryComplianceControls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceControlList_example.json + // this example is just showing the usage of "RegulatoryComplianceControls_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +70,17 @@ public async Task Get_GetSelectedRegulatoryComplianceControlDetailsAndState() // get the collection of this RegulatoryComplianceControlResource RegulatoryComplianceControlCollection collection = regulatoryComplianceStandard.GetRegulatoryComplianceControls(); - // invoke the operation - string regulatoryComplianceControlName = "1.1"; - RegulatoryComplianceControlResource result = await collection.GetAsync(regulatoryComplianceControlName); + // invoke the operation and iterate over the result + await foreach (RegulatoryComplianceControlResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegulatoryComplianceControlData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RegulatoryComplianceControlData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceStandardCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceStandardCollection.cs index a92f524870b65..2c4a0049a004d 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceStandardCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_RegulatoryComplianceStandardCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RegulatoryComplianceStandardCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllSupportedRegulatoryComplianceStandardsDetailsAndState() + public async Task Get_GetSelectedRegulatoryComplianceStandardDetailsAndState() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceStandardList_example.json - // this example is just showing the usage of "RegulatoryComplianceStandards_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceStandard_example.json + // this example is just showing the usage of "RegulatoryComplianceStandards_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_GetAllSupportedRegulatoryComplianceStandardsDetailsAndS // get the collection of this RegulatoryComplianceStandardResource RegulatoryComplianceStandardCollection collection = subscriptionResource.GetRegulatoryComplianceStandards(); - // invoke the operation and iterate over the result - await foreach (RegulatoryComplianceStandardResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RegulatoryComplianceStandardData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string regulatoryComplianceStandardName = "PCI-DSS-3.2"; + RegulatoryComplianceStandardResource result = await collection.GetAsync(regulatoryComplianceStandardName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegulatoryComplianceStandardData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSelectedRegulatoryComplianceStandardDetailsAndState() + public async Task GetAll_GetAllSupportedRegulatoryComplianceStandardsDetailsAndState() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceStandard_example.json - // this example is just showing the usage of "RegulatoryComplianceStandards_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/RegulatoryCompliance/getRegulatoryComplianceStandardList_example.json + // this example is just showing the usage of "RegulatoryComplianceStandards_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +69,17 @@ public async Task Get_GetSelectedRegulatoryComplianceStandardDetailsAndState() // get the collection of this RegulatoryComplianceStandardResource RegulatoryComplianceStandardCollection collection = subscriptionResource.GetRegulatoryComplianceStandards(); - // invoke the operation - string regulatoryComplianceStandardName = "PCI-DSS-3.2"; - RegulatoryComplianceStandardResource result = await collection.GetAsync(regulatoryComplianceStandardName); + // invoke the operation and iterate over the result + await foreach (RegulatoryComplianceStandardResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegulatoryComplianceStandardData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RegulatoryComplianceStandardData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index b89b54a221067..f2c56c6b0ed22 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -98,6 +98,38 @@ public async Task GetExternalSecuritySolution_GetExternalSecuritySolution() Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetJitNetworkAccessPolicies_GetJITNetworkAccessPoliciesOnAResourceGroup() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesResourceGroup_example.json + // this example is just showing the usage of "JitNetworkAccessPolicies_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + string resourceGroupName = "myRg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + await foreach (JitNetworkAccessPolicyResource item in resourceGroupResource.GetJitNetworkAccessPoliciesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + JitNetworkAccessPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetSecuritySolution_GetASecuritySolutionFromASecurityDataLocation() @@ -180,5 +212,37 @@ public async Task GetAlertsByResourceGroup_GetSecurityAlertsOnAResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSecurityCenterApiCollections_GetsAListOfAPICollectionsWithinAResourceGroupThatHaveBeenOnboardedToMicrosoftDefenderForAPIs() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListByResourceGroup_example.json + // this example is just showing the usage of "APICollections_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "3fa85f64-5717-4562-b3fc-2c963f66afa6"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation and iterate over the result + await foreach (SecurityCenterApiCollectionResource item in resourceGroupResource.GetSecurityCenterApiCollectionsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterApiCollectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupSecurityAlertCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupSecurityAlertCollection.cs index 67b0130b73c39..29540b2b3832d 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupSecurityAlertCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupSecurityAlertCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ResourceGroupSecurityAlertCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSecurityAlertsOnAResourceGroupFromASecurityDataLocation() + public async Task Get_GetSecurityAlertOnAResourceGroupFromASecurityDataLocation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsResourceGroupLocation_example.json - // this example is just showing the usage of "Alerts_ListResourceGroupLevelByRegion" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertResourceGroupLocation_example.json + // this example is just showing the usage of "Alerts_GetResourceGroupLevel" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetSecurityAlertsOnAResourceGroupFromASecurityDataLocat AzureLocation ascLocation = new AzureLocation("westeurope"); ResourceGroupSecurityAlertCollection collection = resourceGroupResource.GetResourceGroupSecurityAlerts(ascLocation); - // invoke the operation and iterate over the result - await foreach (ResourceGroupSecurityAlertResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAlertData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string alertName = "2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a"; + ResourceGroupSecurityAlertResource result = await collection.GetAsync(alertName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityAlertOnAResourceGroupFromASecurityDataLocation() + public async Task GetAll_GetSecurityAlertsOnAResourceGroupFromASecurityDataLocation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertResourceGroupLocation_example.json - // this example is just showing the usage of "Alerts_GetResourceGroupLevel" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertsResourceGroupLocation_example.json + // this example is just showing the usage of "Alerts_ListResourceGroupLevelByRegion" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,15 +73,17 @@ public async Task Get_GetSecurityAlertOnAResourceGroupFromASecurityDataLocation( AzureLocation ascLocation = new AzureLocation("westeurope"); ResourceGroupSecurityAlertCollection collection = resourceGroupResource.GetResourceGroupSecurityAlerts(ascLocation); - // invoke the operation - string alertName = "2518298467986649999_4d25bfef-2d77-4a08-adc0-3e35715cc92a"; - ResourceGroupSecurityAlertResource result = await collection.GetAsync(alertName); + // invoke the operation and iterate over the result + await foreach (ResourceGroupSecurityAlertResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAlertData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupSecurityTaskCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupSecurityTaskCollection.cs index 0c7e6f7b0440d..5616a76b30a06 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupSecurityTaskCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ResourceGroupSecurityTaskCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ResourceGroupSecurityTaskCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSecurityRecommendationTasksInAResourceGroup() + public async Task Get_GetSecurityRecommendationTaskInAResourceGroup() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTasksResourceGroupLocation_example.json - // this example is just showing the usage of "Tasks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTaskResourceGroupLocation_example.json + // this example is just showing the usage of "Tasks_GetResourceGroupLevelTask" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_GetSecurityRecommendationTasksInAResourceGroup() AzureLocation ascLocation = new AzureLocation("westeurope"); ResourceGroupSecurityTaskCollection collection = resourceGroupResource.GetResourceGroupSecurityTasks(ascLocation); - // invoke the operation and iterate over the result - await foreach (ResourceGroupSecurityTaskResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityTaskData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string taskName = "d55b4dc0-779c-c66c-33e5-d7bce24c4222"; + ResourceGroupSecurityTaskResource result = await collection.GetAsync(taskName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityTaskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityRecommendationTaskInAResourceGroup() + public async Task GetAll_GetSecurityRecommendationTasksInAResourceGroup() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTaskResourceGroupLocation_example.json - // this example is just showing the usage of "Tasks_GetResourceGroupLevelTask" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTasksResourceGroupLocation_example.json + // this example is just showing the usage of "Tasks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,15 +73,17 @@ public async Task Get_GetSecurityRecommendationTaskInAResourceGroup() AzureLocation ascLocation = new AzureLocation("westeurope"); ResourceGroupSecurityTaskCollection collection = resourceGroupResource.GetResourceGroupSecurityTasks(ascLocation); - // invoke the operation - string taskName = "d55b4dc0-779c-c66c-33e5-d7bce24c4222"; - ResourceGroupSecurityTaskResource result = await collection.GetAsync(taskName); + // invoke the operation and iterate over the result + await foreach (ResourceGroupSecurityTaskResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityTaskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityTaskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecureScoreCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecureScoreCollection.cs index 6b4f6947479a9..a09396b72bacc 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecureScoreCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecureScoreCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SecureScoreCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecureScores() + public async Task Get_GetSingleSecureScore() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/ListSecureScores_example.json - // this example is just showing the usage of "SecureScores_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/GetSecureScoresSingle_example.json + // this example is just showing the usage of "SecureScores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_ListSecureScores() // get the collection of this SecureScoreResource SecureScoreCollection collection = subscriptionResource.GetSecureScores(); - // invoke the operation and iterate over the result - await foreach (SecureScoreResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecureScoreData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string secureScoreName = "ascScore"; + SecureScoreResource result = await collection.GetAsync(secureScoreName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecureScoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSingleSecureScore() + public async Task GetAll_ListSecureScores() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/GetSecureScoresSingle_example.json - // this example is just showing the usage of "SecureScores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/secureScores/ListSecureScores_example.json + // this example is just showing the usage of "SecureScores_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +69,17 @@ public async Task Get_GetSingleSecureScore() // get the collection of this SecureScoreResource SecureScoreCollection collection = subscriptionResource.GetSecureScores(); - // invoke the operation - string secureScoreName = "ascScore"; - SecureScoreResource result = await collection.GetAsync(secureScoreName); + // invoke the operation and iterate over the result + await foreach (SecureScoreResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecureScoreData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecureScoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAlertsSuppressionRuleCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAlertsSuppressionRuleCollection.cs index d1c8542af5e01..b93d1eb54b0d9 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAlertsSuppressionRuleCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAlertsSuppressionRuleCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SecurityAlertsSuppressionRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSuppressionAlertRuleForSubscriptionFilteredByAlertType() + public async Task CreateOrUpdate_UpdateOrCreateSuppressionRuleForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRulesWithAlertType_example.json - // this example is just showing the usage of "AlertsSuppressionRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/PutAlertsSuppressionRule_example.json + // this example is just showing the usage of "AlertsSuppressionRules_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,24 +38,70 @@ public async Task GetAll_GetSuppressionAlertRuleForSubscriptionFilteredByAlertTy // get the collection of this SecurityAlertsSuppressionRuleResource SecurityAlertsSuppressionRuleCollection collection = subscriptionResource.GetSecurityAlertsSuppressionRules(); - // invoke the operation and iterate over the result - await foreach (SecurityAlertsSuppressionRuleResource item in collection.GetAllAsync()) + // invoke the operation + string alertsSuppressionRuleName = "dismissIpAnomalyAlerts"; + SecurityAlertsSuppressionRuleData data = new SecurityAlertsSuppressionRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAlertsSuppressionRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AlertType = "IpAnomaly", + ExpireOn = DateTimeOffset.Parse("2019-12-01T19:50:47.083633Z"), + Reason = "FalsePositive", + State = SecurityAlertsSuppressionRuleState.Enabled, + Comment = "Test VM", + SuppressionAlertsScopeAllOf = {new SuppressionAlertsScopeElement +{ +Field = "entities.ip.address", +}, new SuppressionAlertsScopeElement +{ +Field = "entities.process.commandline", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertsSuppressionRuleName, data); + SecurityAlertsSuppressionRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAlertsSuppressionRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSuppressionRulesForSubscription() + public async Task Get_GetSuppressionAlertRuleForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRules_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRule_example.json + // this example is just showing the usage of "AlertsSuppressionRules_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this SecurityAlertsSuppressionRuleResource + SecurityAlertsSuppressionRuleCollection collection = subscriptionResource.GetSecurityAlertsSuppressionRules(); + + // invoke the operation + string alertsSuppressionRuleName = "dismissIpAnomalyAlerts"; + SecurityAlertsSuppressionRuleResource result = await collection.GetAsync(alertsSuppressionRuleName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAlertsSuppressionRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetSuppressionAlertRuleForSubscriptionFilteredByAlertType() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRulesWithAlertType_example.json // this example is just showing the usage of "AlertsSuppressionRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -87,10 +133,10 @@ public async Task GetAll_GetSuppressionRulesForSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSuppressionAlertRuleForSubscription() + public async Task GetAll_GetSuppressionRulesForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRule_example.json - // this example is just showing the usage of "AlertsSuppressionRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/GetAlertsSuppressionRules_example.json + // this example is just showing the usage of "AlertsSuppressionRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,15 +152,17 @@ public async Task Get_GetSuppressionAlertRuleForSubscription() // get the collection of this SecurityAlertsSuppressionRuleResource SecurityAlertsSuppressionRuleCollection collection = subscriptionResource.GetSecurityAlertsSuppressionRules(); - // invoke the operation - string alertsSuppressionRuleName = "dismissIpAnomalyAlerts"; - SecurityAlertsSuppressionRuleResource result = await collection.GetAsync(alertsSuppressionRuleName); + // invoke the operation and iterate over the result + await foreach (SecurityAlertsSuppressionRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAlertsSuppressionRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAlertsSuppressionRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -184,56 +232,5 @@ public async Task GetIfExists_GetSuppressionAlertRuleForSubscription() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateOrCreateSuppressionRuleForSubscription() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/PutAlertsSuppressionRule_example.json - // this example is just showing the usage of "AlertsSuppressionRules_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SecurityAlertsSuppressionRuleResource - SecurityAlertsSuppressionRuleCollection collection = subscriptionResource.GetSecurityAlertsSuppressionRules(); - - // invoke the operation - string alertsSuppressionRuleName = "dismissIpAnomalyAlerts"; - SecurityAlertsSuppressionRuleData data = new SecurityAlertsSuppressionRuleData() - { - AlertType = "IpAnomaly", - ExpireOn = DateTimeOffset.Parse("2019-12-01T19:50:47.083633Z"), - Reason = "FalsePositive", - State = SecurityAlertsSuppressionRuleState.Enabled, - Comment = "Test VM", - SuppressionAlertsScopeAllOf = -{ -new SuppressionAlertsScopeElement() -{ -Field = "entities.ip.address", -},new SuppressionAlertsScopeElement() -{ -Field = "entities.process.commandline", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertsSuppressionRuleName, data); - SecurityAlertsSuppressionRuleResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAlertsSuppressionRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAlertsSuppressionRuleResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAlertsSuppressionRuleResource.cs index 25ad1f41b5a8e..abb0729e6834a 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAlertsSuppressionRuleResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAlertsSuppressionRuleResource.cs @@ -45,6 +45,31 @@ public async Task Get_GetSuppressionAlertRuleForSubscription() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteSuppressionRuleDataForASubscription() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/DeleteAlertsSuppressionRule_example.json + // this example is just showing the usage of "AlertsSuppressionRules_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SecurityAlertsSuppressionRuleResource created on azure + // for more information of creating SecurityAlertsSuppressionRuleResource, please refer to the document of SecurityAlertsSuppressionRuleResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + string alertsSuppressionRuleName = "dismissIpAnomalyAlerts"; + ResourceIdentifier securityAlertsSuppressionRuleResourceId = SecurityAlertsSuppressionRuleResource.CreateResourceIdentifier(subscriptionId, alertsSuppressionRuleName); + SecurityAlertsSuppressionRuleResource securityAlertsSuppressionRule = client.GetSecurityAlertsSuppressionRuleResource(securityAlertsSuppressionRuleResourceId); + + // invoke the operation + await securityAlertsSuppressionRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_UpdateOrCreateSuppressionRuleForSubscription() @@ -65,23 +90,20 @@ public async Task Update_UpdateOrCreateSuppressionRuleForSubscription() SecurityAlertsSuppressionRuleResource securityAlertsSuppressionRule = client.GetSecurityAlertsSuppressionRuleResource(securityAlertsSuppressionRuleResourceId); // invoke the operation - SecurityAlertsSuppressionRuleData data = new SecurityAlertsSuppressionRuleData() + SecurityAlertsSuppressionRuleData data = new SecurityAlertsSuppressionRuleData { AlertType = "IpAnomaly", ExpireOn = DateTimeOffset.Parse("2019-12-01T19:50:47.083633Z"), Reason = "FalsePositive", State = SecurityAlertsSuppressionRuleState.Enabled, Comment = "Test VM", - SuppressionAlertsScopeAllOf = -{ -new SuppressionAlertsScopeElement() + SuppressionAlertsScopeAllOf = {new SuppressionAlertsScopeElement { Field = "entities.ip.address", -},new SuppressionAlertsScopeElement() +}, new SuppressionAlertsScopeElement { Field = "entities.process.commandline", -} -}, +}}, }; ArmOperation lro = await securityAlertsSuppressionRule.UpdateAsync(WaitUntil.Completed, data); SecurityAlertsSuppressionRuleResource result = lro.Value; @@ -92,30 +114,5 @@ public async Task Update_UpdateOrCreateSuppressionRuleForSubscription() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSuppressionRuleDataForASubscription() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/AlertsSuppressionRules/DeleteAlertsSuppressionRule_example.json - // this example is just showing the usage of "AlertsSuppressionRules_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SecurityAlertsSuppressionRuleResource created on azure - // for more information of creating SecurityAlertsSuppressionRuleResource, please refer to the document of SecurityAlertsSuppressionRuleResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string alertsSuppressionRuleName = "dismissIpAnomalyAlerts"; - ResourceIdentifier securityAlertsSuppressionRuleResourceId = SecurityAlertsSuppressionRuleResource.CreateResourceIdentifier(subscriptionId, alertsSuppressionRuleName); - SecurityAlertsSuppressionRuleResource securityAlertsSuppressionRule = client.GetSecurityAlertsSuppressionRuleResource(securityAlertsSuppressionRuleResourceId); - - // invoke the operation - await securityAlertsSuppressionRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAssessmentCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAssessmentCollection.cs index a2cbbecd18488..a044ad94124a2 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAssessmentCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAssessmentCollection.cs @@ -18,27 +18,29 @@ public partial class Sample_SecurityAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocation() + public async Task CreateOrUpdate_CreateSecurityRecommendationTaskOnAResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessment_example.json - // this example is just showing the usage of "Assessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/PutAssessment_example.json + // this example is just showing the usage of "Assessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityAssessmentResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SecurityAssessmentCollection collection = client.GetSecurityAssessments(scopeId); + SecurityAssessmentCollection collection = client.GetSecurityAssessments(new ResourceIdentifier(resourceId)); // invoke the operation - string assessmentName = "21300918-b2e3-0346-785f-c77ff57d243b"; - SecurityAssessmentResource result = await collection.GetAsync(assessmentName); + string assessmentName = "8bb8be0a-6010-4789-812f-e4d661c4ed0e"; + SecurityAssessmentCreateOrUpdateContent content = new SecurityAssessmentCreateOrUpdateContent + { + ResourceDetails = new AzureResourceDetails(), + Status = new SecurityAssessmentStatus(SecurityAssessmentStatusCode.Healthy), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assessmentName, content); + SecurityAssessmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,7 +51,7 @@ public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSecurityRecommendationTaskFromSecurityDataLocation() + public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocation() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessment_example.json // this example is just showing the usage of "Assessments_Get" operation, for the dependent resources, they will have to be created separately. @@ -59,26 +61,26 @@ public async Task Exists_GetSecurityRecommendationTaskFromSecurityDataLocation() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityAssessmentResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SecurityAssessmentCollection collection = client.GetSecurityAssessments(scopeId); + SecurityAssessmentCollection collection = client.GetSecurityAssessments(new ResourceIdentifier(resourceId)); // invoke the operation string assessmentName = "21300918-b2e3-0346-785f-c77ff57d243b"; - bool result = await collection.ExistsAsync(assessmentName); + SecurityAssessmentResource result = await collection.GetAsync(assessmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSecurityRecommendationTaskFromSecurityDataLocation() + public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocationWithExpandParameter() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessment_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessmentWithExpand_example.json // this example is just showing the usage of "Assessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -86,38 +88,27 @@ public async Task GetIfExists_GetSecurityRecommendationTaskFromSecurityDataLocat // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityAssessmentResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SecurityAssessmentCollection collection = client.GetSecurityAssessments(scopeId); + SecurityAssessmentCollection collection = client.GetSecurityAssessments(new ResourceIdentifier(resourceId)); // invoke the operation string assessmentName = "21300918-b2e3-0346-785f-c77ff57d243b"; - NullableResponse response = await collection.GetIfExistsAsync(assessmentName); - SecurityAssessmentResource result = response.HasValue ? response.Value : null; + SecurityAssessmentODataExpand? expand = SecurityAssessmentODataExpand.Links; + SecurityAssessmentResource result = await collection.GetAsync(assessmentName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocationWithExpandParameter() + public async Task Exists_GetSecurityRecommendationTaskFromSecurityDataLocation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessmentWithExpand_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessment_example.json // this example is just showing the usage of "Assessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -125,24 +116,15 @@ public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocationWithE // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityAssessmentResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SecurityAssessmentCollection collection = client.GetSecurityAssessments(scopeId); + SecurityAssessmentCollection collection = client.GetSecurityAssessments(new ResourceIdentifier(resourceId)); // invoke the operation string assessmentName = "21300918-b2e3-0346-785f-c77ff57d243b"; - SecurityAssessmentODataExpand? expand = SecurityAssessmentODataExpand.Links; - SecurityAssessmentResource result = await collection.GetAsync(assessmentName, expand: expand); + bool result = await collection.ExistsAsync(assessmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -157,13 +139,9 @@ public async Task Exists_GetSecurityRecommendationTaskFromSecurityDataLocationWi // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityAssessmentResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SecurityAssessmentCollection collection = client.GetSecurityAssessments(scopeId); + SecurityAssessmentCollection collection = client.GetSecurityAssessments(new ResourceIdentifier(resourceId)); // invoke the operation string assessmentName = "21300918-b2e3-0346-785f-c77ff57d243b"; @@ -175,9 +153,9 @@ public async Task Exists_GetSecurityRecommendationTaskFromSecurityDataLocationWi [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSecurityRecommendationTaskFromSecurityDataLocationWithExpandParameter() + public async Task GetIfExists_GetSecurityRecommendationTaskFromSecurityDataLocation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessmentWithExpand_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessment_example.json // this example is just showing the usage of "Assessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -185,18 +163,13 @@ public async Task GetIfExists_GetSecurityRecommendationTaskFromSecurityDataLocat // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityAssessmentResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SecurityAssessmentCollection collection = client.GetSecurityAssessments(scopeId); + SecurityAssessmentCollection collection = client.GetSecurityAssessments(new ResourceIdentifier(resourceId)); // invoke the operation string assessmentName = "21300918-b2e3-0346-785f-c77ff57d243b"; - SecurityAssessmentODataExpand? expand = SecurityAssessmentODataExpand.Links; - NullableResponse response = await collection.GetIfExistsAsync(assessmentName, expand: expand); + NullableResponse response = await collection.GetIfExistsAsync(assessmentName); SecurityAssessmentResource result = response.HasValue ? response.Value : null; if (result == null) @@ -215,39 +188,38 @@ public async Task GetIfExists_GetSecurityRecommendationTaskFromSecurityDataLocat [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSecurityRecommendationTaskOnAResource() + public async Task GetIfExists_GetSecurityRecommendationTaskFromSecurityDataLocationWithExpandParameter() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/PutAssessment_example.json - // this example is just showing the usage of "Assessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/GetAssessmentWithExpand_example.json + // this example is just showing the usage of "Assessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityAssessmentResource string resourceId = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.Compute/virtualMachineScaleSets/vmss2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SecurityAssessmentCollection collection = client.GetSecurityAssessments(scopeId); + SecurityAssessmentCollection collection = client.GetSecurityAssessments(new ResourceIdentifier(resourceId)); // invoke the operation - string assessmentName = "8bb8be0a-6010-4789-812f-e4d661c4ed0e"; - SecurityAssessmentCreateOrUpdateContent content = new SecurityAssessmentCreateOrUpdateContent() - { - ResourceDetails = new AzureResourceDetails(), - Status = new SecurityAssessmentStatus(SecurityAssessmentStatusCode.Healthy), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assessmentName, content); - SecurityAssessmentResource result = lro.Value; + string assessmentName = "21300918-b2e3-0346-785f-c77ff57d243b"; + SecurityAssessmentODataExpand? expand = SecurityAssessmentODataExpand.Links; + NullableResponse response = await collection.GetIfExistsAsync(assessmentName, expand: expand); + SecurityAssessmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAssessmentResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAssessmentResource.cs index cc01197d4628e..145f538871896 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAssessmentResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAssessmentResource.cs @@ -77,10 +77,10 @@ public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocationWithE [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateSecurityRecommendationTaskOnAResource() + public async Task Delete_DeleteASecurityRecommendationTaskOnAResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/PutAssessment_example.json - // this example is just showing the usage of "Assessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/DeleteAssessment_example.json + // this example is just showing the usage of "Assessments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,27 +95,17 @@ public async Task Update_CreateSecurityRecommendationTaskOnAResource() SecurityAssessmentResource securityAssessment = client.GetSecurityAssessmentResource(securityAssessmentResourceId); // invoke the operation - SecurityAssessmentCreateOrUpdateContent content = new SecurityAssessmentCreateOrUpdateContent() - { - ResourceDetails = new AzureResourceDetails(), - Status = new SecurityAssessmentStatus(SecurityAssessmentStatusCode.Healthy), - }; - ArmOperation lro = await securityAssessment.UpdateAsync(WaitUntil.Completed, content); - SecurityAssessmentResource result = lro.Value; + await securityAssessment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASecurityRecommendationTaskOnAResource() + public async Task Update_CreateSecurityRecommendationTaskOnAResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/DeleteAssessment_example.json - // this example is just showing the usage of "Assessments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/Assessments/PutAssessment_example.json + // this example is just showing the usage of "Assessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,9 +120,19 @@ public async Task Delete_DeleteASecurityRecommendationTaskOnAResource() SecurityAssessmentResource securityAssessment = client.GetSecurityAssessmentResource(securityAssessmentResourceId); // invoke the operation - await securityAssessment.DeleteAsync(WaitUntil.Completed); + SecurityAssessmentCreateOrUpdateContent content = new SecurityAssessmentCreateOrUpdateContent + { + ResourceDetails = new AzureResourceDetails(), + Status = new SecurityAssessmentStatus(SecurityAssessmentStatusCode.Healthy), + }; + ArmOperation lro = await securityAssessment.UpdateAsync(WaitUntil.Completed, content); + SecurityAssessmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAutomationCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAutomationCollection.cs index 90e74ebf63340..7ecb01c7d2618 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAutomationCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAutomationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SecurityAutomationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllSecurityAutomationsOfASpecifiedResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateASecurityAutomationForAllAssessmentsIncludingAllSeverities() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationsResourceGroup_example.json - // this example is just showing the usage of "Automations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/PutAutomationAllAssessments_example.json + // this example is just showing the usage of "Automations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,45 @@ public async Task GetAll_ListAllSecurityAutomationsOfASpecifiedResourceGroup() // get the collection of this SecurityAutomationResource SecurityAutomationCollection collection = resourceGroupResource.GetSecurityAutomations(); - // invoke the operation and iterate over the result - await foreach (SecurityAutomationResource item in collection.GetAllAsync()) + // invoke the operation + string automationName = "exampleAutomation"; + SecurityAutomationData data = new SecurityAutomationData(new AzureLocation("Central US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAutomationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment", + IsEnabled = true, + Scopes = {new SecurityAutomationScope +{ +Description = "A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5", +ScopePath = "/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup", +}}, + Sources = {new SecurityAutomationSource +{ +EventSource = SecurityEventSource.Assessments, +}}, + Actions = {new SecurityAutomationActionLogicApp +{ +LogicAppResourceId = new ResourceIdentifier("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), +Uri = new Uri("https://exampleTriggerUri1.com"), +}}, + ETag = new ETag("etag value (must be supplied for update)"), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, automationName, data); + SecurityAutomationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAutomationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveASecurityAutomation() + public async Task CreateOrUpdate_CreateOrUpdateASecurityAutomationForAllHighSeverityAssessments() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationResourceGroup_example.json - // this example is just showing the usage of "Automations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/PutAutomationHighSeverityAssessments_example.json + // this example is just showing the usage of "Automations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +96,39 @@ public async Task Get_RetrieveASecurityAutomation() // invoke the operation string automationName = "exampleAutomation"; - SecurityAutomationResource result = await collection.GetAsync(automationName); + SecurityAutomationData data = new SecurityAutomationData(new AzureLocation("Central US")) + { + Description = "An example of a security automation that triggers one LogicApp resource (myTest1) on any high severity security assessment", + IsEnabled = true, + Scopes = {new SecurityAutomationScope +{ +Description = "A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5", +ScopePath = "/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup", +}}, + Sources = {new SecurityAutomationSource +{ +EventSource = SecurityEventSource.Assessments, +RuleSets = {new SecurityAutomationRuleSet +{ +Rules = {new SecurityAutomationTriggeringRule +{ +PropertyJPath = "properties.metadata.severity", +PropertyType = AutomationTriggeringRulePropertyType.String, +ExpectedValue = "High", +Operator = AutomationTriggeringRuleOperator.EqualsValue, +}}, +}}, +}}, + Actions = {new SecurityAutomationActionLogicApp +{ +LogicAppResourceId = new ResourceIdentifier("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), +Uri = new Uri("https://exampleTriggerUri1.com"), +}}, + ETag = new ETag("etag value (must be supplied for update)"), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, automationName, data); + SecurityAutomationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,10 +139,10 @@ public async Task Get_RetrieveASecurityAutomation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveASecurityAutomation() + public async Task CreateOrUpdate_DisableOrEnableASecurityAutomation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationResourceGroup_example.json - // this example is just showing the usage of "Automations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/PutDisableAutomation_example.json + // this example is just showing the usage of "Automations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,14 +161,50 @@ public async Task Exists_RetrieveASecurityAutomation() // invoke the operation string automationName = "exampleAutomation"; - bool result = await collection.ExistsAsync(automationName); + SecurityAutomationData data = new SecurityAutomationData(new AzureLocation("Central US")) + { + Description = "An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment of type customAssessment", + IsEnabled = false, + Scopes = {new SecurityAutomationScope +{ +Description = "A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5", +ScopePath = "/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup", +}}, + Sources = {new SecurityAutomationSource +{ +EventSource = SecurityEventSource.Assessments, +RuleSets = {new SecurityAutomationRuleSet +{ +Rules = {new SecurityAutomationTriggeringRule +{ +PropertyJPath = "$.Entity.AssessmentType", +PropertyType = AutomationTriggeringRulePropertyType.String, +ExpectedValue = "customAssessment", +Operator = AutomationTriggeringRuleOperator.EqualsValue, +}}, +}}, +}}, + Actions = {new SecurityAutomationActionLogicApp +{ +LogicAppResourceId = new ResourceIdentifier("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), +Uri = new Uri("https://exampleTriggerUri1.com"), +}}, + ETag = new ETag("etag value (must be supplied for update)"), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, automationName, data); + SecurityAutomationResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAutomationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveASecurityAutomation() + public async Task Get_RetrieveASecurityAutomation() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationResourceGroup_example.json // this example is just showing the usage of "Automations_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +226,21 @@ public async Task GetIfExists_RetrieveASecurityAutomation() // invoke the operation string automationName = "exampleAutomation"; - NullableResponse response = await collection.GetIfExistsAsync(automationName); - SecurityAutomationResource result = response.HasValue ? response.Value : null; + SecurityAutomationResource result = await collection.GetAsync(automationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAutomationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAutomationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateASecurityAutomationForAllAssessmentsIncludingAllSeverities() + public async Task GetAll_ListAllSecurityAutomationsOfASpecifiedResourceGroup() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/PutAutomationAllAssessments_example.json - // this example is just showing the usage of "Automations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationsResourceGroup_example.json + // this example is just showing the usage of "Automations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,56 +257,25 @@ public async Task CreateOrUpdate_CreateOrUpdateASecurityAutomationForAllAssessme // get the collection of this SecurityAutomationResource SecurityAutomationCollection collection = resourceGroupResource.GetSecurityAutomations(); - // invoke the operation - string automationName = "exampleAutomation"; - SecurityAutomationData data = new SecurityAutomationData(new AzureLocation("Central US")) + // invoke the operation and iterate over the result + await foreach (SecurityAutomationResource item in collection.GetAllAsync()) { - Description = "An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment", - IsEnabled = true, - Scopes = -{ -new SecurityAutomationScope() -{ -Description = "A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5", -ScopePath = "/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup", -} -}, - Sources = -{ -new SecurityAutomationSource() -{ -EventSource = SecurityEventSource.Assessments, -} -}, - Actions = -{ -new SecurityAutomationActionLogicApp() -{ -LogicAppResourceId = new ResourceIdentifier("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), -Uri = new Uri("https://exampleTriggerUri1.com"), -} -}, - ETag = new ETag("etag value (must be supplied for update)"), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, automationName, data); - SecurityAutomationResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAutomationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAutomationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateASecurityAutomationForAllHighSeverityAssessments() + public async Task Exists_RetrieveASecurityAutomation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/PutAutomationHighSeverityAssessments_example.json - // this example is just showing the usage of "Automations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationResourceGroup_example.json + // this example is just showing the usage of "Automations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -245,70 +294,17 @@ public async Task CreateOrUpdate_CreateOrUpdateASecurityAutomationForAllHighSeve // invoke the operation string automationName = "exampleAutomation"; - SecurityAutomationData data = new SecurityAutomationData(new AzureLocation("Central US")) - { - Description = "An example of a security automation that triggers one LogicApp resource (myTest1) on any high severity security assessment", - IsEnabled = true, - Scopes = -{ -new SecurityAutomationScope() -{ -Description = "A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5", -ScopePath = "/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup", -} -}, - Sources = -{ -new SecurityAutomationSource() -{ -EventSource = SecurityEventSource.Assessments, -RuleSets = -{ -new SecurityAutomationRuleSet() -{ -Rules = -{ -new SecurityAutomationTriggeringRule() -{ -PropertyJPath = "properties.metadata.severity", -PropertyType = AutomationTriggeringRulePropertyType.String, -ExpectedValue = "High", -Operator = AutomationTriggeringRuleOperator.EqualsValue, -} -}, -} -}, -} -}, - Actions = -{ -new SecurityAutomationActionLogicApp() -{ -LogicAppResourceId = new ResourceIdentifier("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), -Uri = new Uri("https://exampleTriggerUri1.com"), -} -}, - ETag = new ETag("etag value (must be supplied for update)"), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, automationName, data); - SecurityAutomationResource result = lro.Value; + bool result = await collection.ExistsAsync(automationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAutomationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DisableOrEnableASecurityAutomation() + public async Task GetIfExists_RetrieveASecurityAutomation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/PutDisableAutomation_example.json - // this example is just showing the usage of "Automations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationResourceGroup_example.json + // this example is just showing the usage of "Automations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -327,62 +323,21 @@ public async Task CreateOrUpdate_DisableOrEnableASecurityAutomation() // invoke the operation string automationName = "exampleAutomation"; - SecurityAutomationData data = new SecurityAutomationData(new AzureLocation("Central US")) - { - Description = "An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment of type customAssessment", - IsEnabled = false, - Scopes = -{ -new SecurityAutomationScope() -{ -Description = "A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5", -ScopePath = "/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup", -} -}, - Sources = -{ -new SecurityAutomationSource() -{ -EventSource = SecurityEventSource.Assessments, -RuleSets = -{ -new SecurityAutomationRuleSet() -{ -Rules = -{ -new SecurityAutomationTriggeringRule() -{ -PropertyJPath = "$.Entity.AssessmentType", -PropertyType = AutomationTriggeringRulePropertyType.String, -ExpectedValue = "customAssessment", -Operator = AutomationTriggeringRuleOperator.EqualsValue, -} -}, -} -}, -} -}, - Actions = -{ -new SecurityAutomationActionLogicApp() -{ -LogicAppResourceId = new ResourceIdentifier("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), -Uri = new Uri("https://exampleTriggerUri1.com"), -} -}, - ETag = new ETag("etag value (must be supplied for update)"), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, automationName, data); - SecurityAutomationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(automationName); + SecurityAutomationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAutomationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAutomationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAutomationResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAutomationResource.cs index 913c2eb014baa..9a2988429ca7a 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAutomationResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityAutomationResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SecurityCenter.Models; using NUnit.Framework; @@ -19,41 +18,40 @@ public partial class Sample_SecurityAutomationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSecurityAutomations_ListAllSecurityAutomationsOfASpecifiedSubscription() + public async Task Get_RetrieveASecurityAutomation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationsSubscription_example.json - // this example is just showing the usage of "Automations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationResourceGroup_example.json + // this example is just showing the usage of "Automations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this SecurityAutomationResource created on azure + // for more information of creating SecurityAutomationResource, please refer to the document of SecurityAutomationResource string subscriptionId = "a5caac9c-5c04-49af-b3d0-e204f40345d5"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "exampleResourceGroup"; + string automationName = "exampleAutomation"; + ResourceIdentifier securityAutomationResourceId = SecurityAutomationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationName); + SecurityAutomationResource securityAutomation = client.GetSecurityAutomationResource(securityAutomationResourceId); - // invoke the operation and iterate over the result - await foreach (SecurityAutomationResource item in subscriptionResource.GetSecurityAutomationsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAutomationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + SecurityAutomationResource result = await securityAutomation.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAutomationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveASecurityAutomation() + public async Task Delete_DeleteASecurityAutomation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationResourceGroup_example.json - // this example is just showing the usage of "Automations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/DeleteAutomation_example.json + // this example is just showing the usage of "Automations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,20 +60,16 @@ public async Task Get_RetrieveASecurityAutomation() // this example assumes you already have this SecurityAutomationResource created on azure // for more information of creating SecurityAutomationResource, please refer to the document of SecurityAutomationResource - string subscriptionId = "a5caac9c-5c04-49af-b3d0-e204f40345d5"; - string resourceGroupName = "exampleResourceGroup"; - string automationName = "exampleAutomation"; + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + string resourceGroupName = "myRg"; + string automationName = "myAutomationName"; ResourceIdentifier securityAutomationResourceId = SecurityAutomationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationName); SecurityAutomationResource securityAutomation = client.GetSecurityAutomationResource(securityAutomationResourceId); // invoke the operation - SecurityAutomationResource result = await securityAutomation.GetAsync(); + await securityAutomation.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAutomationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -103,33 +97,22 @@ public async Task Update_CreateOrUpdateASecurityAutomationForAllAssessmentsInclu { Description = "An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment", IsEnabled = true, - Scopes = -{ -new SecurityAutomationScope() + Scopes = {new SecurityAutomationScope { Description = "A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5", ScopePath = "/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup", -} -}, - Sources = -{ -new SecurityAutomationSource() +}}, + Sources = {new SecurityAutomationSource { EventSource = SecurityEventSource.Assessments, -} -}, - Actions = -{ -new SecurityAutomationActionLogicApp() +}}, + Actions = {new SecurityAutomationActionLogicApp { LogicAppResourceId = new ResourceIdentifier("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), Uri = new Uri("https://exampleTriggerUri1.com"), -} -}, +}}, ETag = new ETag("etag value (must be supplied for update)"), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await securityAutomation.UpdateAsync(WaitUntil.Completed, data); SecurityAutomationResource result = lro.Value; @@ -166,49 +149,32 @@ public async Task Update_CreateOrUpdateASecurityAutomationForAllHighSeverityAsse { Description = "An example of a security automation that triggers one LogicApp resource (myTest1) on any high severity security assessment", IsEnabled = true, - Scopes = -{ -new SecurityAutomationScope() + Scopes = {new SecurityAutomationScope { Description = "A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5", ScopePath = "/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup", -} -}, - Sources = -{ -new SecurityAutomationSource() +}}, + Sources = {new SecurityAutomationSource { EventSource = SecurityEventSource.Assessments, -RuleSets = -{ -new SecurityAutomationRuleSet() +RuleSets = {new SecurityAutomationRuleSet { -Rules = -{ -new SecurityAutomationTriggeringRule() +Rules = {new SecurityAutomationTriggeringRule { PropertyJPath = "properties.metadata.severity", PropertyType = AutomationTriggeringRulePropertyType.String, ExpectedValue = "High", Operator = AutomationTriggeringRuleOperator.EqualsValue, -} -}, -} -}, -} -}, - Actions = -{ -new SecurityAutomationActionLogicApp() +}}, +}}, +}}, + Actions = {new SecurityAutomationActionLogicApp { LogicAppResourceId = new ResourceIdentifier("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), Uri = new Uri("https://exampleTriggerUri1.com"), -} -}, +}}, ETag = new ETag("etag value (must be supplied for update)"), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await securityAutomation.UpdateAsync(WaitUntil.Completed, data); SecurityAutomationResource result = lro.Value; @@ -245,49 +211,32 @@ public async Task Update_DisableOrEnableASecurityAutomation() { Description = "An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment of type customAssessment", IsEnabled = false, - Scopes = -{ -new SecurityAutomationScope() + Scopes = {new SecurityAutomationScope { Description = "A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5", ScopePath = "/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup", -} -}, - Sources = -{ -new SecurityAutomationSource() +}}, + Sources = {new SecurityAutomationSource { EventSource = SecurityEventSource.Assessments, -RuleSets = +RuleSets = {new SecurityAutomationRuleSet { -new SecurityAutomationRuleSet() -{ -Rules = -{ -new SecurityAutomationTriggeringRule() +Rules = {new SecurityAutomationTriggeringRule { PropertyJPath = "$.Entity.AssessmentType", PropertyType = AutomationTriggeringRulePropertyType.String, ExpectedValue = "customAssessment", Operator = AutomationTriggeringRuleOperator.EqualsValue, -} -}, -} -}, -} -}, - Actions = -{ -new SecurityAutomationActionLogicApp() +}}, +}}, +}}, + Actions = {new SecurityAutomationActionLogicApp { LogicAppResourceId = new ResourceIdentifier("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), Uri = new Uri("https://exampleTriggerUri1.com"), -} -}, +}}, ETag = new ETag("etag value (must be supplied for update)"), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await securityAutomation.UpdateAsync(WaitUntil.Completed, data); SecurityAutomationResource result = lro.Value; @@ -299,32 +248,6 @@ public async Task Update_DisableOrEnableASecurityAutomation() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASecurityAutomation() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/DeleteAutomation_example.json - // this example is just showing the usage of "Automations_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SecurityAutomationResource created on azure - // for more information of creating SecurityAutomationResource, please refer to the document of SecurityAutomationResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string resourceGroupName = "myRg"; - string automationName = "myAutomationName"; - ResourceIdentifier securityAutomationResourceId = SecurityAutomationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationName); - SecurityAutomationResource securityAutomation = client.GetSecurityAutomationResource(securityAutomationResourceId); - - // invoke the operation - await securityAutomation.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Validate_ValidateTheSecurityAutomationModelBeforeCreateOrUpdate() @@ -350,48 +273,31 @@ public async Task Validate_ValidateTheSecurityAutomationModelBeforeCreateOrUpdat { Description = "An example of a security automation that triggers one LogicApp resource (myTest1) on any security assessment of type customAssessment", IsEnabled = true, - Scopes = -{ -new SecurityAutomationScope() + Scopes = {new SecurityAutomationScope { Description = "A description that helps to identify this scope - for example: security assessments that relate to the resource group myResourceGroup within the subscription a5caac9c-5c04-49af-b3d0-e204f40345d5", ScopePath = "/subscriptions/a5caac9c-5c04-49af-b3d0-e204f40345d5/resourceGroups/myResourceGroup", -} -}, - Sources = -{ -new SecurityAutomationSource() +}}, + Sources = {new SecurityAutomationSource { EventSource = SecurityEventSource.Assessments, -RuleSets = -{ -new SecurityAutomationRuleSet() -{ -Rules = +RuleSets = {new SecurityAutomationRuleSet { -new SecurityAutomationTriggeringRule() +Rules = {new SecurityAutomationTriggeringRule { PropertyJPath = "$.Entity.AssessmentType", PropertyType = AutomationTriggeringRulePropertyType.String, ExpectedValue = "customAssessment", Operator = AutomationTriggeringRuleOperator.EqualsValue, -} -}, -} -}, -} -}, - Actions = -{ -new SecurityAutomationActionLogicApp() +}}, +}}, +}}, + Actions = {new SecurityAutomationActionLogicApp { LogicAppResourceId = new ResourceIdentifier("/subscriptions/e54a4a18-5b94-4f90-9471-bd3decad8a2e/resourceGroups/sample/providers/Microsoft.Logic/workflows/MyTest1"), Uri = new Uri("https://exampleTriggerUri1.com"), -} -}, - Tags = -{ -}, +}}, + Tags = { }, }; SecurityAutomationValidationStatus result = await securityAutomation.ValidateAsync(data); diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterApiCollectionCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterApiCollectionCollection.cs index 5ed8a8a6ee287..fd18c6bba7f72 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterApiCollectionCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterApiCollectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SecurityCenterApiCollectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfAzureAPIManagementAPIsThatHaveBeenOnboardedToMicrosoftDefenderForAPIs() + public async Task CreateOrUpdate_OnboardAnAzureAPIManagementAPIToMicrosoftDefenderForAPIs() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListByAzureApiManagementService_example.json - // this example is just showing the usage of "APICollections_ListByAzureApiManagementService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_OnboardAzureApiManagementApi_example.json + // this example is just showing the usage of "APICollections_OnboardAzureApiManagementApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,16 @@ public async Task GetAll_GetsAListOfAzureAPIManagementAPIsThatHaveBeenOnboardedT string serviceName = "apimService1"; SecurityCenterApiCollectionCollection collection = resourceGroupResource.GetSecurityCenterApiCollections(serviceName); - // invoke the operation and iterate over the result - await foreach (SecurityCenterApiCollectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterApiCollectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string apiId = "echo-api"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId); + SecurityCenterApiCollectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterApiCollectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +87,10 @@ public async Task Get_GetsAnAzureAPIManagementAPIIfItHasBeenOnboardedToMicrosoft [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAnAzureAPIManagementAPIIfItHasBeenOnboardedToMicrosoftDefenderForAPIs() + public async Task GetAll_GetsAListOfAzureAPIManagementAPIsThatHaveBeenOnboardedToMicrosoftDefenderForAPIs() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_GetByAzureApiManagementService_example.json - // this example is just showing the usage of "APICollections_GetByAzureApiManagementService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListByAzureApiManagementService_example.json + // this example is just showing the usage of "APICollections_ListByAzureApiManagementService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +108,22 @@ public async Task Exists_GetsAnAzureAPIManagementAPIIfItHasBeenOnboardedToMicros string serviceName = "apimService1"; SecurityCenterApiCollectionCollection collection = resourceGroupResource.GetSecurityCenterApiCollections(serviceName); - // invoke the operation - string apiId = "echo-api"; - bool result = await collection.ExistsAsync(apiId); + // invoke the operation and iterate over the result + await foreach (SecurityCenterApiCollectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterApiCollectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAnAzureAPIManagementAPIIfItHasBeenOnboardedToMicrosoftDefenderForAPIs() + public async Task Exists_GetsAnAzureAPIManagementAPIIfItHasBeenOnboardedToMicrosoftDefenderForAPIs() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_GetByAzureApiManagementService_example.json // this example is just showing the usage of "APICollections_GetByAzureApiManagementService" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +146,17 @@ public async Task GetIfExists_GetsAnAzureAPIManagementAPIIfItHasBeenOnboardedToM // invoke the operation string apiId = "echo-api"; - NullableResponse response = await collection.GetIfExistsAsync(apiId); - SecurityCenterApiCollectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(apiId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterApiCollectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_OnboardAnAzureAPIManagementAPIToMicrosoftDefenderForAPIs() + public async Task GetIfExists_GetsAnAzureAPIManagementAPIIfItHasBeenOnboardedToMicrosoftDefenderForAPIs() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_OnboardAzureApiManagementApi_example.json - // this example is just showing the usage of "APICollections_OnboardAzureApiManagementApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_GetByAzureApiManagementService_example.json + // this example is just showing the usage of "APICollections_GetByAzureApiManagementService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,14 +176,21 @@ public async Task CreateOrUpdate_OnboardAnAzureAPIManagementAPIToMicrosoftDefend // invoke the operation string apiId = "echo-api"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId); - SecurityCenterApiCollectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(apiId); + SecurityCenterApiCollectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterApiCollectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterApiCollectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterApiCollectionResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterApiCollectionResource.cs index 980ab074d2bae..1e9e52c61f3d9 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterApiCollectionResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterApiCollectionResource.cs @@ -9,76 +9,12 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.SecurityCenter.Samples { public partial class Sample_SecurityCenterApiCollectionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSecurityCenterApiCollections_GetsAListOfAPICollectionsWithinASubscriptionThatHaveBeenOnboardedToMicrosoftDefenderForAPIs() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListBySubscription_example.json - // this example is just showing the usage of "APICollections_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "3fa85f64-5717-4562-b3fc-2c963f66afa6"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SecurityCenterApiCollectionResource item in subscriptionResource.GetSecurityCenterApiCollectionsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterApiCollectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSecurityCenterApiCollections_GetsAListOfAPICollectionsWithinAResourceGroupThatHaveBeenOnboardedToMicrosoftDefenderForAPIs() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListByResourceGroup_example.json - // this example is just showing the usage of "APICollections_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "3fa85f64-5717-4562-b3fc-2c963f66afa6"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation and iterate over the result - await foreach (SecurityCenterApiCollectionResource item in resourceGroupResource.GetSecurityCenterApiCollectionsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterApiCollectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetsAnAzureAPIManagementAPIIfItHasBeenOnboardedToMicrosoftDefenderForAPIs() @@ -112,10 +48,10 @@ public async Task Get_GetsAnAzureAPIManagementAPIIfItHasBeenOnboardedToMicrosoft [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_OnboardAnAzureAPIManagementAPIToMicrosoftDefenderForAPIs() + public async Task Delete_OffboardAnAzureAPIManagementAPIFromMicrosoftDefenderForAPIs() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_OnboardAzureApiManagementApi_example.json - // this example is just showing the usage of "APICollections_OnboardAzureApiManagementApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_OffboardAzureApiManagementApi_example.json + // this example is just showing the usage of "APICollections_OffboardAzureApiManagementApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,22 +68,17 @@ public async Task Update_OnboardAnAzureAPIManagementAPIToMicrosoftDefenderForAPI SecurityCenterApiCollectionResource securityCenterApiCollection = client.GetSecurityCenterApiCollectionResource(securityCenterApiCollectionResourceId); // invoke the operation - ArmOperation lro = await securityCenterApiCollection.UpdateAsync(WaitUntil.Completed); - SecurityCenterApiCollectionResource result = lro.Value; + await securityCenterApiCollection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterApiCollectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_OffboardAnAzureAPIManagementAPIFromMicrosoftDefenderForAPIs() + public async Task Update_OnboardAnAzureAPIManagementAPIToMicrosoftDefenderForAPIs() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_OffboardAzureApiManagementApi_example.json - // this example is just showing the usage of "APICollections_OffboardAzureApiManagementApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_OnboardAzureApiManagementApi_example.json + // this example is just showing the usage of "APICollections_OnboardAzureApiManagementApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -164,9 +95,14 @@ public async Task Delete_OffboardAnAzureAPIManagementAPIFromMicrosoftDefenderFor SecurityCenterApiCollectionResource securityCenterApiCollection = client.GetSecurityCenterApiCollectionResource(securityCenterApiCollectionResourceId); // invoke the operation - await securityCenterApiCollection.DeleteAsync(WaitUntil.Completed); + ArmOperation lro = await securityCenterApiCollection.UpdateAsync(WaitUntil.Completed); + SecurityCenterApiCollectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterApiCollectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterLocationCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterLocationCollection.cs index 948de348e7d9c..b19312f8ac92e 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterLocationCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterLocationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SecurityCenterLocationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSecurityDataLocations() + public async Task Get_GetSecurityDataLocation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Locations/GetLocations_example.json - // this example is just showing the usage of "Locations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Locations/GetLocation_example.json + // this example is just showing the usage of "Locations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_GetSecurityDataLocations() // get the collection of this SecurityCenterLocationResource SecurityCenterLocationCollection collection = subscriptionResource.GetSecurityCenterLocations(); - // invoke the operation and iterate over the result - await foreach (SecurityCenterLocationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterLocationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + AzureLocation ascLocation = new AzureLocation("centralus"); + SecurityCenterLocationResource result = await collection.GetAsync(ascLocation); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterLocationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityDataLocation() + public async Task GetAll_GetSecurityDataLocations() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Locations/GetLocation_example.json - // this example is just showing the usage of "Locations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Locations/GetLocations_example.json + // this example is just showing the usage of "Locations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +69,17 @@ public async Task Get_GetSecurityDataLocation() // get the collection of this SecurityCenterLocationResource SecurityCenterLocationCollection collection = subscriptionResource.GetSecurityCenterLocations(); - // invoke the operation - AzureLocation ascLocation = new AzureLocation("centralus"); - SecurityCenterLocationResource result = await collection.GetAsync(ascLocation); + // invoke the operation and iterate over the result + await foreach (SecurityCenterLocationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterLocationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterLocationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterPricingCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterPricingCollection.cs index d8812c7b18de5..92342497a1784 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterPricingCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterPricingCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SecurityCenterPricingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetPricingsOnSubscription() + public async Task CreateOrUpdate_UpdatePricingOnSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/ListPricings_example.json - // this example is just showing the usage of "Pricings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/PutPricingByName_example.json + // this example is just showing the usage of "Pricings_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,28 @@ public async Task GetAll_GetPricingsOnSubscription() // get the collection of this SecurityCenterPricingResource SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); - // invoke the operation and iterate over the result - await foreach (SecurityCenterPricingResource item in collection.GetAllAsync()) + // invoke the operation + string pricingName = "CloudPosture"; + SecurityCenterPricingData data = new SecurityCenterPricingData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterPricingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PricingTier = SecurityCenterPricingTier.Standard, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pricingName, data); + SecurityCenterPricingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterPricingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPricingsOnSubscriptionCloudPosturePlan() + public async Task CreateOrUpdate_UpdatePricingOnSubscriptionPartialSuccess() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameCloudPosture_example.json - // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/PutPricingByNamePartialSuccess_example.json + // this example is just showing the usage of "Pricings_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,7 +77,12 @@ public async Task Get_GetPricingsOnSubscriptionCloudPosturePlan() // invoke the operation string pricingName = "CloudPosture"; - SecurityCenterPricingResource result = await collection.GetAsync(pricingName); + SecurityCenterPricingData data = new SecurityCenterPricingData + { + PricingTier = SecurityCenterPricingTier.Standard, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pricingName, data); + SecurityCenterPricingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,7 +93,7 @@ public async Task Get_GetPricingsOnSubscriptionCloudPosturePlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPricingsOnSubscriptionCloudPosturePlan() + public async Task Get_GetPricingsOnSubscriptionCloudPosturePlan() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameCloudPosture_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. @@ -106,16 +114,20 @@ public async Task Exists_GetPricingsOnSubscriptionCloudPosturePlan() // invoke the operation string pricingName = "CloudPosture"; - bool result = await collection.ExistsAsync(pricingName); + SecurityCenterPricingResource result = await collection.GetAsync(pricingName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterPricingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPricingsOnSubscriptionCloudPosturePlan() + public async Task Get_GetPricingsOnSubscriptionContainersPlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameCloudPosture_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameContainers_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -133,29 +145,21 @@ public async Task GetIfExists_GetPricingsOnSubscriptionCloudPosturePlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "CloudPosture"; - NullableResponse response = await collection.GetIfExistsAsync(pricingName); - SecurityCenterPricingResource result = response.HasValue ? response.Value : null; + string pricingName = "Containers"; + SecurityCenterPricingResource result = await collection.GetAsync(pricingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterPricingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterPricingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPricingsOnSubscriptionContainersPlan() + public async Task Get_GetPricingsOnSubscriptionDnsPlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameContainers_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameDns_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -173,7 +177,7 @@ public async Task Get_GetPricingsOnSubscriptionContainersPlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "Containers"; + string pricingName = "Dns"; SecurityCenterPricingResource result = await collection.GetAsync(pricingName); // the variable result is a resource, you could call other operations on this instance as well @@ -185,9 +189,9 @@ public async Task Get_GetPricingsOnSubscriptionContainersPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPricingsOnSubscriptionContainersPlan() + public async Task Get_GetPricingsOnSubscriptionStorageAccountsPlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameContainers_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameStorageAccounts_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -205,17 +209,21 @@ public async Task Exists_GetPricingsOnSubscriptionContainersPlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "Containers"; - bool result = await collection.ExistsAsync(pricingName); + string pricingName = "StorageAccounts"; + SecurityCenterPricingResource result = await collection.GetAsync(pricingName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterPricingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPricingsOnSubscriptionContainersPlan() + public async Task Get_GetPricingsOnSubscriptionVirtualMachinesPlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameContainers_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameVirtualMachines_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -233,29 +241,55 @@ public async Task GetIfExists_GetPricingsOnSubscriptionContainersPlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "Containers"; - NullableResponse response = await collection.GetIfExistsAsync(pricingName); - SecurityCenterPricingResource result = response.HasValue ? response.Value : null; + string pricingName = "VirtualMachines"; + SecurityCenterPricingResource result = await collection.GetAsync(pricingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterPricingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetPricingsOnSubscription() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/ListPricings_example.json + // this example is just showing the usage of "Pricings_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // get the collection of this SecurityCenterPricingResource + SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); + + // invoke the operation and iterate over the result + await foreach (SecurityCenterPricingResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SecurityCenterPricingData resourceData = result.Data; + SecurityCenterPricingData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPricingsOnSubscriptionDnsPlan() + public async Task Exists_GetPricingsOnSubscriptionCloudPosturePlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameDns_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameCloudPosture_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -273,21 +307,17 @@ public async Task Get_GetPricingsOnSubscriptionDnsPlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "Dns"; - SecurityCenterPricingResource result = await collection.GetAsync(pricingName); + string pricingName = "CloudPosture"; + bool result = await collection.ExistsAsync(pricingName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterPricingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPricingsOnSubscriptionDnsPlan() + public async Task Exists_GetPricingsOnSubscriptionContainersPlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameDns_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameContainers_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -305,7 +335,7 @@ public async Task Exists_GetPricingsOnSubscriptionDnsPlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "Dns"; + string pricingName = "Containers"; bool result = await collection.ExistsAsync(pricingName); Console.WriteLine($"Succeeded: {result}"); @@ -313,7 +343,7 @@ public async Task Exists_GetPricingsOnSubscriptionDnsPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPricingsOnSubscriptionDnsPlan() + public async Task Exists_GetPricingsOnSubscriptionDnsPlan() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameDns_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. @@ -334,26 +364,14 @@ public async Task GetIfExists_GetPricingsOnSubscriptionDnsPlan() // invoke the operation string pricingName = "Dns"; - NullableResponse response = await collection.GetIfExistsAsync(pricingName); - SecurityCenterPricingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(pricingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterPricingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPricingsOnSubscriptionStorageAccountsPlan() + public async Task Exists_GetPricingsOnSubscriptionStorageAccountsPlan() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameStorageAccounts_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. @@ -374,20 +392,16 @@ public async Task Get_GetPricingsOnSubscriptionStorageAccountsPlan() // invoke the operation string pricingName = "StorageAccounts"; - SecurityCenterPricingResource result = await collection.GetAsync(pricingName); + bool result = await collection.ExistsAsync(pricingName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterPricingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPricingsOnSubscriptionStorageAccountsPlan() + public async Task Exists_GetPricingsOnSubscriptionVirtualMachinesPlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameStorageAccounts_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameVirtualMachines_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -405,7 +419,7 @@ public async Task Exists_GetPricingsOnSubscriptionStorageAccountsPlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "StorageAccounts"; + string pricingName = "VirtualMachines"; bool result = await collection.ExistsAsync(pricingName); Console.WriteLine($"Succeeded: {result}"); @@ -413,9 +427,9 @@ public async Task Exists_GetPricingsOnSubscriptionStorageAccountsPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPricingsOnSubscriptionStorageAccountsPlan() + public async Task GetIfExists_GetPricingsOnSubscriptionCloudPosturePlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameStorageAccounts_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameCloudPosture_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -433,7 +447,7 @@ public async Task GetIfExists_GetPricingsOnSubscriptionStorageAccountsPlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "StorageAccounts"; + string pricingName = "CloudPosture"; NullableResponse response = await collection.GetIfExistsAsync(pricingName); SecurityCenterPricingResource result = response.HasValue ? response.Value : null; @@ -453,9 +467,9 @@ public async Task GetIfExists_GetPricingsOnSubscriptionStorageAccountsPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPricingsOnSubscriptionVirtualMachinesPlan() + public async Task GetIfExists_GetPricingsOnSubscriptionContainersPlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameVirtualMachines_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameContainers_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -473,21 +487,29 @@ public async Task Get_GetPricingsOnSubscriptionVirtualMachinesPlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "VirtualMachines"; - SecurityCenterPricingResource result = await collection.GetAsync(pricingName); + string pricingName = "Containers"; + NullableResponse response = await collection.GetIfExistsAsync(pricingName); + SecurityCenterPricingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterPricingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterPricingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPricingsOnSubscriptionVirtualMachinesPlan() + public async Task GetIfExists_GetPricingsOnSubscriptionDnsPlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameVirtualMachines_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameDns_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -505,17 +527,29 @@ public async Task Exists_GetPricingsOnSubscriptionVirtualMachinesPlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "VirtualMachines"; - bool result = await collection.ExistsAsync(pricingName); + string pricingName = "Dns"; + NullableResponse response = await collection.GetIfExistsAsync(pricingName); + SecurityCenterPricingResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterPricingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPricingsOnSubscriptionVirtualMachinesPlan() + public async Task GetIfExists_GetPricingsOnSubscriptionStorageAccountsPlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameVirtualMachines_example.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameStorageAccounts_example.json // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -533,7 +567,7 @@ public async Task GetIfExists_GetPricingsOnSubscriptionVirtualMachinesPlan() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "VirtualMachines"; + string pricingName = "StorageAccounts"; NullableResponse response = await collection.GetIfExistsAsync(pricingName); SecurityCenterPricingResource result = response.HasValue ? response.Value : null; @@ -553,10 +587,10 @@ public async Task GetIfExists_GetPricingsOnSubscriptionVirtualMachinesPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatePricingOnSubscription() + public async Task GetIfExists_GetPricingsOnSubscriptionVirtualMachinesPlan() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/PutPricingByName_example.json - // this example is just showing the usage of "Pricings_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/GetPricingByNameVirtualMachines_example.json + // this example is just showing the usage of "Pricings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -573,56 +607,22 @@ public async Task CreateOrUpdate_UpdatePricingOnSubscription() SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); // invoke the operation - string pricingName = "CloudPosture"; - SecurityCenterPricingData data = new SecurityCenterPricingData() - { - PricingTier = SecurityCenterPricingTier.Standard, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pricingName, data); - SecurityCenterPricingResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterPricingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatePricingOnSubscriptionPartialSuccess() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-01-01/examples/Pricings/PutPricingByNamePartialSuccess_example.json - // this example is just showing the usage of "Pricings_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // get the collection of this SecurityCenterPricingResource - SecurityCenterPricingCollection collection = subscriptionResource.GetSecurityCenterPricings(); + string pricingName = "VirtualMachines"; + NullableResponse response = await collection.GetIfExistsAsync(pricingName); + SecurityCenterPricingResource result = response.HasValue ? response.Value : null; - // invoke the operation - string pricingName = "CloudPosture"; - SecurityCenterPricingData data = new SecurityCenterPricingData() + if (result == null) { - PricingTier = SecurityCenterPricingTier.Standard, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pricingName, data); - SecurityCenterPricingResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCenterPricingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterPricingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterPricingResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterPricingResource.cs index 8914a415899f4..fe9101ca73aa9 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterPricingResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCenterPricingResource.cs @@ -181,7 +181,7 @@ public async Task Update_UpdatePricingOnSubscription() SecurityCenterPricingResource securityCenterPricing = client.GetSecurityCenterPricingResource(securityCenterPricingResourceId); // invoke the operation - SecurityCenterPricingData data = new SecurityCenterPricingData() + SecurityCenterPricingData data = new SecurityCenterPricingData { PricingTier = SecurityCenterPricingTier.Standard, }; @@ -215,7 +215,7 @@ public async Task Update_UpdatePricingOnSubscriptionPartialSuccess() SecurityCenterPricingResource securityCenterPricing = client.GetSecurityCenterPricingResource(securityCenterPricingResourceId); // invoke the operation - SecurityCenterPricingData data = new SecurityCenterPricingData() + SecurityCenterPricingData data = new SecurityCenterPricingData { PricingTier = SecurityCenterPricingTier.Standard, }; diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCloudConnectorCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCloudConnectorCollection.cs index 80f98296fd847..2f7c0af776054 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCloudConnectorCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCloudConnectorCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SecurityCloudConnectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllCloudAccountsConnectorsOfASubscription() + public async Task CreateOrUpdate_AwsAssumeRoleCreateACloudAccountConnectorForASubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetListConnectorSubscription_example.json - // this example is just showing the usage of "Connectors_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateAwsAssumeRoleConnectorSubscription_example.json + // this example is just showing the usage of "Connectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,43 @@ public async Task GetAll_GetAllCloudAccountsConnectorsOfASubscription() // get the collection of this SecurityCloudConnectorResource SecurityCloudConnectorCollection collection = subscriptionResource.GetSecurityCloudConnectors(); - // invoke the operation and iterate over the result - await foreach (SecurityCloudConnectorResource item in collection.GetAllAsync()) + // invoke the operation + string connectorName = "aws_dev2"; + SecurityCloudConnectorData data = new SecurityCloudConnectorData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCloudConnectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HybridComputeSettings = new HybridComputeSettingsProperties(AutoProvisionState.On) + { + ResourceGroupName = "AwsConnectorRG", + Region = "West US 2", + ProxyServer = new ProxyServerProperties + { + IP = "167.220.197.140", + Port = "34", + }, + ServicePrincipal = new ServicePrincipalProperties + { + ApplicationId = Guid.Parse("ad9bcd79-be9c-45ab-abd8-80ca1654a7d1"), + Secret = "", + }, + }, + AuthenticationDetails = new AwsAssumeRoleAuthenticationDetailsProperties("arn:aws:iam::81231569658:role/AscConnector", Guid.Parse("20ff7fc3-e762-44dd-bd96-b71116dcdc23")), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectorName, data); + SecurityCloudConnectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCloudConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DetailsOfASpecificCloudAccountConnector() + public async Task CreateOrUpdate_AwsCredCreateACloudAccountConnectorForASubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetConnectorSubscription_example.json - // this example is just showing the usage of "Connectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateAwsCredConnectorSubscription_example.json + // this example is just showing the usage of "Connectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,7 +92,27 @@ public async Task Get_DetailsOfASpecificCloudAccountConnector() // invoke the operation string connectorName = "aws_dev1"; - SecurityCloudConnectorResource result = await collection.GetAsync(connectorName); + SecurityCloudConnectorData data = new SecurityCloudConnectorData + { + HybridComputeSettings = new HybridComputeSettingsProperties(AutoProvisionState.On) + { + ResourceGroupName = "AwsConnectorRG", + Region = "West US 2", + ProxyServer = new ProxyServerProperties + { + IP = "167.220.197.140", + Port = "34", + }, + ServicePrincipal = new ServicePrincipalProperties + { + ApplicationId = Guid.Parse("ad9bcd79-be9c-45ab-abd8-80ca1654a7d1"), + Secret = "", + }, + }, + AuthenticationDetails = new AwsCredsAuthenticationDetailsProperties("AKIARPZCNODDNAEQFSOE", ""), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectorName, data); + SecurityCloudConnectorResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,10 +123,10 @@ public async Task Get_DetailsOfASpecificCloudAccountConnector() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DetailsOfASpecificCloudAccountConnector() + public async Task CreateOrUpdate_GcpCredentialsCreateACloudAccountConnectorForASubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetConnectorSubscription_example.json - // this example is just showing the usage of "Connectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateGcpCredentialsConnectorSubscription_example.json + // this example is just showing the usage of "Connectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,15 +143,36 @@ public async Task Exists_DetailsOfASpecificCloudAccountConnector() SecurityCloudConnectorCollection collection = subscriptionResource.GetSecurityCloudConnectors(); // invoke the operation - string connectorName = "aws_dev1"; - bool result = await collection.ExistsAsync(connectorName); + string connectorName = "gcp_dev"; + SecurityCloudConnectorData data = new SecurityCloudConnectorData + { + HybridComputeSettings = new HybridComputeSettingsProperties(AutoProvisionState.Off), + AuthenticationDetails = new GcpCredentialsDetailsProperties( + "AscDemoOrg", + "service_account", + "asc-project-1234", + "6efg587hra2568as34d22326b044cc20dc2af", + "******", + "asc-135@asc-project-1234.iam.gserviceaccount.com", + "105889053725632919854", + new Uri("https://accounts.google.com/o/oauth2/auth"), + new Uri("https://oauth2.googleapis.com/token"), + new Uri("https://www.googleapis.com/oauth2/v1/certs"), + new Uri("https://www.googleapis.com/robot/v1/metadata/x509/asc-135%40asc-project-1234.iam.gserviceaccount.com")), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectorName, data); + SecurityCloudConnectorResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCloudConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DetailsOfASpecificCloudAccountConnector() + public async Task Get_DetailsOfASpecificCloudAccountConnector() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetConnectorSubscription_example.json // this example is just showing the usage of "Connectors_Get" operation, for the dependent resources, they will have to be created separately. @@ -134,29 +193,21 @@ public async Task GetIfExists_DetailsOfASpecificCloudAccountConnector() // invoke the operation string connectorName = "aws_dev1"; - NullableResponse response = await collection.GetIfExistsAsync(connectorName); - SecurityCloudConnectorResource result = response.HasValue ? response.Value : null; + SecurityCloudConnectorResource result = await collection.GetAsync(connectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCloudConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCloudConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AwsAssumeRoleCreateACloudAccountConnectorForASubscription() + public async Task GetAll_GetAllCloudAccountsConnectorsOfASubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateAwsAssumeRoleConnectorSubscription_example.json - // this example is just showing the usage of "Connectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetListConnectorSubscription_example.json + // this example is just showing the usage of "Connectors_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,43 +223,25 @@ public async Task CreateOrUpdate_AwsAssumeRoleCreateACloudAccountConnectorForASu // get the collection of this SecurityCloudConnectorResource SecurityCloudConnectorCollection collection = subscriptionResource.GetSecurityCloudConnectors(); - // invoke the operation - string connectorName = "aws_dev2"; - SecurityCloudConnectorData data = new SecurityCloudConnectorData() + // invoke the operation and iterate over the result + await foreach (SecurityCloudConnectorResource item in collection.GetAllAsync()) { - HybridComputeSettings = new HybridComputeSettingsProperties(AutoProvisionState.On) - { - ResourceGroupName = "AwsConnectorRG", - Region = "West US 2", - ProxyServer = new ProxyServerProperties() - { - IP = "167.220.197.140", - Port = "34", - }, - ServicePrincipal = new ServicePrincipalProperties() - { - ApplicationId = Guid.Parse("ad9bcd79-be9c-45ab-abd8-80ca1654a7d1"), - Secret = "", - }, - }, - AuthenticationDetails = new AwsAssumeRoleAuthenticationDetailsProperties("arn:aws:iam::81231569658:role/AscConnector", Guid.Parse("20ff7fc3-e762-44dd-bd96-b71116dcdc23")), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectorName, data); - SecurityCloudConnectorResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCloudConnectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCloudConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AwsCredCreateACloudAccountConnectorForASubscription() + public async Task Exists_DetailsOfASpecificCloudAccountConnector() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateAwsCredConnectorSubscription_example.json - // this example is just showing the usage of "Connectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetConnectorSubscription_example.json + // this example is just showing the usage of "Connectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,41 +259,17 @@ public async Task CreateOrUpdate_AwsCredCreateACloudAccountConnectorForASubscrip // invoke the operation string connectorName = "aws_dev1"; - SecurityCloudConnectorData data = new SecurityCloudConnectorData() - { - HybridComputeSettings = new HybridComputeSettingsProperties(AutoProvisionState.On) - { - ResourceGroupName = "AwsConnectorRG", - Region = "West US 2", - ProxyServer = new ProxyServerProperties() - { - IP = "167.220.197.140", - Port = "34", - }, - ServicePrincipal = new ServicePrincipalProperties() - { - ApplicationId = Guid.Parse("ad9bcd79-be9c-45ab-abd8-80ca1654a7d1"), - Secret = "", - }, - }, - AuthenticationDetails = new AwsCredsAuthenticationDetailsProperties("AKIARPZCNODDNAEQFSOE", ""), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectorName, data); - SecurityCloudConnectorResource result = lro.Value; + bool result = await collection.ExistsAsync(connectorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCloudConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GcpCredentialsCreateACloudAccountConnectorForASubscription() + public async Task GetIfExists_DetailsOfASpecificCloudAccountConnector() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/CreateUpdateGcpCredentialsConnectorSubscription_example.json - // this example is just showing the usage of "Connectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/GetConnectorSubscription_example.json + // this example is just showing the usage of "Connectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -277,20 +286,22 @@ public async Task CreateOrUpdate_GcpCredentialsCreateACloudAccountConnectorForAS SecurityCloudConnectorCollection collection = subscriptionResource.GetSecurityCloudConnectors(); // invoke the operation - string connectorName = "gcp_dev"; - SecurityCloudConnectorData data = new SecurityCloudConnectorData() - { - HybridComputeSettings = new HybridComputeSettingsProperties(AutoProvisionState.Off), - AuthenticationDetails = new GcpCredentialsDetailsProperties("AscDemoOrg", "service_account", "asc-project-1234", "6efg587hra2568as34d22326b044cc20dc2af", "******", "asc-135@asc-project-1234.iam.gserviceaccount.com", "105889053725632919854", new Uri("https://accounts.google.com/o/oauth2/auth"), new Uri("https://oauth2.googleapis.com/token"), new Uri("https://www.googleapis.com/oauth2/v1/certs"), new Uri("https://www.googleapis.com/robot/v1/metadata/x509/asc-135%40asc-project-1234.iam.gserviceaccount.com")), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectorName, data); - SecurityCloudConnectorResource result = lro.Value; + string connectorName = "aws_dev1"; + NullableResponse response = await collection.GetIfExistsAsync(connectorName); + SecurityCloudConnectorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityCloudConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCloudConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCloudConnectorResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCloudConnectorResource.cs index 1efcc5988ea5c..e50d2f32c227b 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCloudConnectorResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityCloudConnectorResource.cs @@ -45,6 +45,31 @@ public async Task Get_DetailsOfASpecificCloudAccountConnector() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteACloudAccountConnectorFromASubscription() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/DeleteConnectorSubscription_example.json + // this example is just showing the usage of "Connectors_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SecurityCloudConnectorResource created on azure + // for more information of creating SecurityCloudConnectorResource, please refer to the document of SecurityCloudConnectorResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + string connectorName = "aws_dev1"; + ResourceIdentifier securityCloudConnectorResourceId = SecurityCloudConnectorResource.CreateResourceIdentifier(subscriptionId, connectorName); + SecurityCloudConnectorResource securityCloudConnector = client.GetSecurityCloudConnectorResource(securityCloudConnectorResourceId); + + // invoke the operation + await securityCloudConnector.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_AwsAssumeRoleCreateACloudAccountConnectorForASubscription() @@ -65,18 +90,18 @@ public async Task Update_AwsAssumeRoleCreateACloudAccountConnectorForASubscripti SecurityCloudConnectorResource securityCloudConnector = client.GetSecurityCloudConnectorResource(securityCloudConnectorResourceId); // invoke the operation - SecurityCloudConnectorData data = new SecurityCloudConnectorData() + SecurityCloudConnectorData data = new SecurityCloudConnectorData { HybridComputeSettings = new HybridComputeSettingsProperties(AutoProvisionState.On) { ResourceGroupName = "AwsConnectorRG", Region = "West US 2", - ProxyServer = new ProxyServerProperties() + ProxyServer = new ProxyServerProperties { IP = "167.220.197.140", Port = "34", }, - ServicePrincipal = new ServicePrincipalProperties() + ServicePrincipal = new ServicePrincipalProperties { ApplicationId = Guid.Parse("ad9bcd79-be9c-45ab-abd8-80ca1654a7d1"), Secret = "", @@ -114,18 +139,18 @@ public async Task Update_AwsCredCreateACloudAccountConnectorForASubscription() SecurityCloudConnectorResource securityCloudConnector = client.GetSecurityCloudConnectorResource(securityCloudConnectorResourceId); // invoke the operation - SecurityCloudConnectorData data = new SecurityCloudConnectorData() + SecurityCloudConnectorData data = new SecurityCloudConnectorData { HybridComputeSettings = new HybridComputeSettingsProperties(AutoProvisionState.On) { ResourceGroupName = "AwsConnectorRG", Region = "West US 2", - ProxyServer = new ProxyServerProperties() + ProxyServer = new ProxyServerProperties { IP = "167.220.197.140", Port = "34", }, - ServicePrincipal = new ServicePrincipalProperties() + ServicePrincipal = new ServicePrincipalProperties { ApplicationId = Guid.Parse("ad9bcd79-be9c-45ab-abd8-80ca1654a7d1"), Secret = "", @@ -163,10 +188,21 @@ public async Task Update_GcpCredentialsCreateACloudAccountConnectorForASubscript SecurityCloudConnectorResource securityCloudConnector = client.GetSecurityCloudConnectorResource(securityCloudConnectorResourceId); // invoke the operation - SecurityCloudConnectorData data = new SecurityCloudConnectorData() + SecurityCloudConnectorData data = new SecurityCloudConnectorData { HybridComputeSettings = new HybridComputeSettingsProperties(AutoProvisionState.Off), - AuthenticationDetails = new GcpCredentialsDetailsProperties("AscDemoOrg", "service_account", "asc-project-1234", "6efg587hra2568as34d22326b044cc20dc2af", "******", "asc-135@asc-project-1234.iam.gserviceaccount.com", "105889053725632919854", new Uri("https://accounts.google.com/o/oauth2/auth"), new Uri("https://oauth2.googleapis.com/token"), new Uri("https://www.googleapis.com/oauth2/v1/certs"), new Uri("https://www.googleapis.com/robot/v1/metadata/x509/asc-135%40asc-project-1234.iam.gserviceaccount.com")), + AuthenticationDetails = new GcpCredentialsDetailsProperties( + "AscDemoOrg", + "service_account", + "asc-project-1234", + "6efg587hra2568as34d22326b044cc20dc2af", + "******", + "asc-135@asc-project-1234.iam.gserviceaccount.com", + "105889053725632919854", + new Uri("https://accounts.google.com/o/oauth2/auth"), + new Uri("https://oauth2.googleapis.com/token"), + new Uri("https://www.googleapis.com/oauth2/v1/certs"), + new Uri("https://www.googleapis.com/robot/v1/metadata/x509/asc-135%40asc-project-1234.iam.gserviceaccount.com")), }; ArmOperation lro = await securityCloudConnector.UpdateAsync(WaitUntil.Completed, data); SecurityCloudConnectorResource result = lro.Value; @@ -177,30 +213,5 @@ public async Task Update_GcpCredentialsCreateACloudAccountConnectorForASubscript // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACloudAccountConnectorFromASubscription() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/Connectors/DeleteConnectorSubscription_example.json - // this example is just showing the usage of "Connectors_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SecurityCloudConnectorResource created on azure - // for more information of creating SecurityCloudConnectorResource, please refer to the document of SecurityCloudConnectorResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string connectorName = "aws_dev1"; - ResourceIdentifier securityCloudConnectorResourceId = SecurityCloudConnectorResource.CreateResourceIdentifier(subscriptionId, connectorName); - SecurityCloudConnectorResource securityCloudConnector = client.GetSecurityCloudConnectorResource(securityCloudConnectorResourceId); - - // invoke the operation - await securityCloudConnector.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityComplianceCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityComplianceCollection.cs index 1f120dd0df3e7..d1ce0f91c45fa 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityComplianceCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityComplianceCollection.cs @@ -17,66 +17,58 @@ public partial class Sample_SecurityComplianceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSecurityComplianceDataOverTime() + public async Task Get_GetSecurityComplianceDataForADay() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/Compliances/GetCompliances_example.json - // this example is just showing the usage of "Compliances_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/Compliances/GetCompliance_example.json + // this example is just showing the usage of "Compliances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityComplianceResource string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SecurityComplianceCollection collection = client.GetSecurityCompliances(scopeId); + SecurityComplianceCollection collection = client.GetSecurityCompliances(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (SecurityComplianceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityComplianceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string complianceName = "2018-01-01Z"; + SecurityComplianceResource result = await collection.GetAsync(complianceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityComplianceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityComplianceDataForADay() + public async Task GetAll_GetSecurityComplianceDataOverTime() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/Compliances/GetCompliance_example.json - // this example is just showing the usage of "Compliances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/Compliances/GetCompliances_example.json + // this example is just showing the usage of "Compliances_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityComplianceResource string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SecurityComplianceCollection collection = client.GetSecurityCompliances(scopeId); + SecurityComplianceCollection collection = client.GetSecurityCompliances(new ResourceIdentifier(scope)); - // invoke the operation - string complianceName = "2018-01-01Z"; - SecurityComplianceResource result = await collection.GetAsync(complianceName); + // invoke the operation and iterate over the result + await foreach (SecurityComplianceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityComplianceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityComplianceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -91,13 +83,9 @@ public async Task Exists_GetSecurityComplianceDataForADay() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityComplianceResource string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SecurityComplianceCollection collection = client.GetSecurityCompliances(scopeId); + SecurityComplianceCollection collection = client.GetSecurityCompliances(new ResourceIdentifier(scope)); // invoke the operation string complianceName = "2018-01-01Z"; @@ -118,13 +106,9 @@ public async Task GetIfExists_GetSecurityComplianceDataForADay() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityComplianceResource string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SecurityComplianceCollection collection = client.GetSecurityCompliances(scopeId); + SecurityComplianceCollection collection = client.GetSecurityCompliances(new ResourceIdentifier(scope)); // invoke the operation string complianceName = "2018-01-01Z"; diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorApplicationCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorApplicationCollection.cs index 7f8fe6c6c69d1..8ffc5461765f5 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorApplicationCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorApplicationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SecurityConnectorApplicationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecurityApplicationsBySecurityConnectorLevelScope() + public async Task CreateOrUpdate_CreateApplication() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/ListBySecurityConnectorApplications_example.json - // this example is just showing the usage of "SecurityConnectorApplications_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/PutSecurityConnectorApplication_example.json + // this example is just showing the usage of "SecurityConnectorApplications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,34 @@ public async Task GetAll_ListSecurityApplicationsBySecurityConnectorLevelScope() // get the collection of this SecurityConnectorApplicationResource SecurityConnectorApplicationCollection collection = securityConnector.GetSecurityConnectorApplications(); - // invoke the operation and iterate over the result - await foreach (SecurityConnectorApplicationResource item in collection.GetAllAsync()) + // invoke the operation + string applicationId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; + SecurityApplicationData data = new SecurityApplicationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityApplicationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "GCP Admin's application", + Description = "An application on critical GCP recommendations", + SourceResourceType = ApplicationSourceResourceType.Assessments, + ConditionSets = {BinaryData.FromObjectAsJson(new +{ +conditions = new object[] +{ +new Dictionary +{ +["operator"] = "contains", +["property"] = "$.Id", +["value"] = "-prod-" +} +}, +})}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationId, data); + SecurityConnectorApplicationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +106,10 @@ public async Task Get_GetSecurityApplicationsBySpecificApplicationId() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSecurityApplicationsBySpecificApplicationId() + public async Task GetAll_ListSecurityApplicationsBySecurityConnectorLevelScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/GetSecurityConnectorApplication_example.json - // this example is just showing the usage of "SecurityConnectorApplications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/ListBySecurityConnectorApplications_example.json + // this example is just showing the usage of "SecurityConnectorApplications_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +127,22 @@ public async Task Exists_GetSecurityApplicationsBySpecificApplicationId() // get the collection of this SecurityConnectorApplicationResource SecurityConnectorApplicationCollection collection = securityConnector.GetSecurityConnectorApplications(); - // invoke the operation - string applicationId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - bool result = await collection.ExistsAsync(applicationId); + // invoke the operation and iterate over the result + await foreach (SecurityConnectorApplicationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityApplicationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSecurityApplicationsBySpecificApplicationId() + public async Task Exists_GetSecurityApplicationsBySpecificApplicationId() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/GetSecurityConnectorApplication_example.json // this example is just showing the usage of "SecurityConnectorApplications_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +165,17 @@ public async Task GetIfExists_GetSecurityApplicationsBySpecificApplicationId() // invoke the operation string applicationId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - NullableResponse response = await collection.GetIfExistsAsync(applicationId); - SecurityConnectorApplicationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(applicationId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateApplication() + public async Task GetIfExists_GetSecurityApplicationsBySpecificApplicationId() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/PutSecurityConnectorApplication_example.json - // this example is just showing the usage of "SecurityConnectorApplications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/GetSecurityConnectorApplication_example.json + // this example is just showing the usage of "SecurityConnectorApplications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,30 +195,21 @@ public async Task CreateOrUpdate_CreateApplication() // invoke the operation string applicationId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - SecurityApplicationData data = new SecurityApplicationData() - { - DisplayName = "GCP Admin's application", - Description = "An application on critical GCP recommendations", - SourceResourceType = ApplicationSourceResourceType.Assessments, - ConditionSets = -{ -BinaryData.FromObjectAsJson(new Dictionary() -{ -["conditions"] = new object[] { new Dictionary() -{ -["operator"] = "contains", -["property"] = "$.Id", -["value"] = "-prod-"} }}) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationId, data); - SecurityConnectorApplicationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(applicationId); + SecurityConnectorApplicationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorApplicationResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorApplicationResource.cs index c377e4d5d363f..0dd0d05721a42 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorApplicationResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorApplicationResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetSecurityApplicationsBySpecificApplicationId() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateApplication() + public async Task Delete_DeleteSecurityApplication() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/PutSecurityConnectorApplication_example.json - // this example is just showing the usage of "SecurityConnectorApplications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/DeleteSecurityConnectorApplication_example.json + // this example is just showing the usage of "SecurityConnectorApplications_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,38 +70,17 @@ public async Task Update_CreateApplication() SecurityConnectorApplicationResource securityConnectorApplication = client.GetSecurityConnectorApplicationResource(securityConnectorApplicationResourceId); // invoke the operation - SecurityApplicationData data = new SecurityApplicationData() - { - DisplayName = "GCP Admin's application", - Description = "An application on critical GCP recommendations", - SourceResourceType = ApplicationSourceResourceType.Assessments, - ConditionSets = -{ -BinaryData.FromObjectAsJson(new Dictionary() -{ -["conditions"] = new object[] { new Dictionary() -{ -["operator"] = "contains", -["property"] = "$.Id", -["value"] = "-prod-"} }}) -}, - }; - ArmOperation lro = await securityConnectorApplication.UpdateAsync(WaitUntil.Completed, data); - SecurityConnectorApplicationResource result = lro.Value; + await securityConnectorApplication.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSecurityApplication() + public async Task Update_CreateApplication() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/DeleteSecurityConnectorApplication_example.json - // this example is just showing the usage of "SecurityConnectorApplications_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/PutSecurityConnectorApplication_example.json + // this example is just showing the usage of "SecurityConnectorApplications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,9 +97,32 @@ public async Task Delete_DeleteSecurityApplication() SecurityConnectorApplicationResource securityConnectorApplication = client.GetSecurityConnectorApplicationResource(securityConnectorApplicationResourceId); // invoke the operation - await securityConnectorApplication.DeleteAsync(WaitUntil.Completed); + SecurityApplicationData data = new SecurityApplicationData + { + DisplayName = "GCP Admin's application", + Description = "An application on critical GCP recommendations", + SourceResourceType = ApplicationSourceResourceType.Assessments, + ConditionSets = {BinaryData.FromObjectAsJson(new +{ +conditions = new object[] +{ +new Dictionary +{ +["operator"] = "contains", +["property"] = "$.Id", +["value"] = "-prod-" +} +}, +})}, + }; + ArmOperation lro = await securityConnectorApplication.UpdateAsync(WaitUntil.Completed, data); + SecurityConnectorApplicationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorCollection.cs index ab3248746a2de..eca7e8c306723 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SecurityConnectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllSecurityConnectorsOfASpecifiedResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateASecurityConnector() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/GetSecurityConnectorsResourceGroup_example.json - // this example is just showing the usage of "SecurityConnectors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/PutSecurityConnector_example.json + // this example is just showing the usage of "SecurityConnectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,31 @@ public async Task GetAll_ListAllSecurityConnectorsOfASpecifiedResourceGroup() // get the collection of this SecurityConnectorResource SecurityConnectorCollection collection = resourceGroupResource.GetSecurityConnectors(); - // invoke the operation and iterate over the result - await foreach (SecurityConnectorResource item in collection.GetAllAsync()) + // invoke the operation + string securityConnectorName = "exampleSecurityConnectorName"; + SecurityConnectorData data = new SecurityConnectorData(new AzureLocation("Central US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HierarchyIdentifier = "exampleHierarchyId", + EnvironmentName = SecurityCenterCloudName.Aws, + Offerings = {new CspmMonitorAwsOffering +{ +CloudRoleArn = "arn:aws:iam::00000000:role/ASCMonitor", +}}, + EnvironmentData = new AwsEnvironment + { + ScanInterval = 4L, + }, + ETag = new ETag("etag value (must be supplied for update)"), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityConnectorName, data); + SecurityConnectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +101,10 @@ public async Task Get_RetrieveASecurityConnector() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrieveASecurityConnector() + public async Task GetAll_ListAllSecurityConnectorsOfASpecifiedResourceGroup() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/GetSecurityConnectorSingleResource_example.json - // this example is just showing the usage of "SecurityConnectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/GetSecurityConnectorsResourceGroup_example.json + // this example is just showing the usage of "SecurityConnectors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +121,22 @@ public async Task Exists_RetrieveASecurityConnector() // get the collection of this SecurityConnectorResource SecurityConnectorCollection collection = resourceGroupResource.GetSecurityConnectors(); - // invoke the operation - string securityConnectorName = "exampleSecurityConnectorName"; - bool result = await collection.ExistsAsync(securityConnectorName); + // invoke the operation and iterate over the result + await foreach (SecurityConnectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrieveASecurityConnector() + public async Task Exists_RetrieveASecurityConnector() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/GetSecurityConnectorSingleResource_example.json // this example is just showing the usage of "SecurityConnectors_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +158,17 @@ public async Task GetIfExists_RetrieveASecurityConnector() // invoke the operation string securityConnectorName = "exampleSecurityConnectorName"; - NullableResponse response = await collection.GetIfExistsAsync(securityConnectorName); - SecurityConnectorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(securityConnectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateASecurityConnector() + public async Task GetIfExists_RetrieveASecurityConnector() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/PutSecurityConnector_example.json - // this example is just showing the usage of "SecurityConnectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/GetSecurityConnectorSingleResource_example.json + // this example is just showing the usage of "SecurityConnectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,34 +187,21 @@ public async Task CreateOrUpdate_CreateOrUpdateASecurityConnector() // invoke the operation string securityConnectorName = "exampleSecurityConnectorName"; - SecurityConnectorData data = new SecurityConnectorData(new AzureLocation("Central US")) - { - HierarchyIdentifier = "exampleHierarchyId", - EnvironmentName = SecurityCenterCloudName.Aws, - Offerings = -{ -new CspmMonitorAwsOffering() -{ -CloudRoleArn = "arn:aws:iam::00000000:role/ASCMonitor", -} -}, - EnvironmentData = new AwsEnvironment() - { - ScanInterval = 4L, - }, - ETag = new ETag("etag value (must be supplied for update)"), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityConnectorName, data); - SecurityConnectorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(securityConnectorName); + SecurityConnectorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitHubOwnerCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitHubOwnerCollection.cs index 79fb5d8e3db10..145827b98a81c 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitHubOwnerCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitHubOwnerCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SecurityConnectorGitHubOwnerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGitHubOwners() + public async Task Get_GetGitHubOwners() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListGitHubOwners_example.json - // this example is just showing the usage of "GitHubOwners_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetGitHubOwners_example.json + // this example is just showing the usage of "GitHubOwners_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListGitHubOwners() // get the collection of this SecurityConnectorGitHubOwnerResource SecurityConnectorGitHubOwnerCollection collection = devOpsConfiguration.GetSecurityConnectorGitHubOwners(); - // invoke the operation and iterate over the result - await foreach (SecurityConnectorGitHubOwnerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorGitHubOwnerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string ownerName = "myGitHubOwner"; + SecurityConnectorGitHubOwnerResource result = await collection.GetAsync(ownerName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorGitHubOwnerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetGitHubOwners() + public async Task GetAll_ListGitHubOwners() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetGitHubOwners_example.json - // this example is just showing the usage of "GitHubOwners_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListGitHubOwners_example.json + // this example is just showing the usage of "GitHubOwners_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetGitHubOwners() // get the collection of this SecurityConnectorGitHubOwnerResource SecurityConnectorGitHubOwnerCollection collection = devOpsConfiguration.GetSecurityConnectorGitHubOwners(); - // invoke the operation - string ownerName = "myGitHubOwner"; - SecurityConnectorGitHubOwnerResource result = await collection.GetAsync(ownerName); + // invoke the operation and iterate over the result + await foreach (SecurityConnectorGitHubOwnerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorGitHubOwnerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorGitHubOwnerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitHubRepositoryCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitHubRepositoryCollection.cs index 375beadbd3ba7..30a13e50477ae 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitHubRepositoryCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitHubRepositoryCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SecurityConnectorGitHubRepositoryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGitHubRepos() + public async Task Get_GetGitHubRepos() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListGitHubRepos_example.json - // this example is just showing the usage of "GitHubRepos_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetGitHubRepos_example.json + // this example is just showing the usage of "GitHubRepos_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListGitHubRepos() // get the collection of this SecurityConnectorGitHubRepositoryResource SecurityConnectorGitHubRepositoryCollection collection = securityConnectorGitHubOwner.GetSecurityConnectorGitHubRepositories(); - // invoke the operation and iterate over the result - await foreach (SecurityConnectorGitHubRepositoryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorGitHubRepositoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string repoName = "myGitHubRepo"; + SecurityConnectorGitHubRepositoryResource result = await collection.GetAsync(repoName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorGitHubRepositoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetGitHubRepos() + public async Task GetAll_ListGitHubRepos() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetGitHubRepos_example.json - // this example is just showing the usage of "GitHubRepos_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListGitHubRepos_example.json + // this example is just showing the usage of "GitHubRepos_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetGitHubRepos() // get the collection of this SecurityConnectorGitHubRepositoryResource SecurityConnectorGitHubRepositoryCollection collection = securityConnectorGitHubOwner.GetSecurityConnectorGitHubRepositories(); - // invoke the operation - string repoName = "myGitHubRepo"; - SecurityConnectorGitHubRepositoryResource result = await collection.GetAsync(repoName); + // invoke the operation and iterate over the result + await foreach (SecurityConnectorGitHubRepositoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorGitHubRepositoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorGitHubRepositoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitLabGroupCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitLabGroupCollection.cs index a860d02dbbdd4..c76c62139b8fe 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitLabGroupCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitLabGroupCollection.cs @@ -15,6 +15,40 @@ namespace Azure.ResourceManager.SecurityCenter.Samples { public partial class Sample_SecurityConnectorGitLabGroupCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetGitLabGroups() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetGitLabGroups_example.json + // this example is just showing the usage of "GitLabGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DevOpsConfigurationResource created on azure + // for more information of creating DevOpsConfigurationResource, please refer to the document of DevOpsConfigurationResource + string subscriptionId = "0806e1cd-cfda-4ff8-b99c-2b0af42cffd3"; + string resourceGroupName = "myRg"; + string securityConnectorName = "mySecurityConnectorName"; + ResourceIdentifier devOpsConfigurationResourceId = DevOpsConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, securityConnectorName); + DevOpsConfigurationResource devOpsConfiguration = client.GetDevOpsConfigurationResource(devOpsConfigurationResourceId); + + // get the collection of this SecurityConnectorGitLabGroupResource + SecurityConnectorGitLabGroupCollection collection = devOpsConfiguration.GetSecurityConnectorGitLabGroups(); + + // invoke the operation + string groupFQName = "myGitLabGroup$mySubGroup"; + SecurityConnectorGitLabGroupResource result = await collection.GetAsync(groupFQName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorGitLabGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListGitLabGroups() @@ -53,10 +87,10 @@ public async Task GetAll_ListGitLabGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetGitLabGroups() + public async Task GetGitLabSubgroups_ListGitLabSubgroups() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetGitLabGroups_example.json - // this example is just showing the usage of "GitLabGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListGitLabSubgroups_example.json + // this example is just showing the usage of "GitLabSubgroups_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +108,18 @@ public async Task Get_GetGitLabGroups() // get the collection of this SecurityConnectorGitLabGroupResource SecurityConnectorGitLabGroupCollection collection = devOpsConfiguration.GetSecurityConnectorGitLabGroups(); - // invoke the operation - string groupFQName = "myGitLabGroup$mySubGroup"; - SecurityConnectorGitLabGroupResource result = await collection.GetAsync(groupFQName); + // invoke the operation and iterate over the result + string groupFQName = "myGitLabGroup"; + await foreach (SecurityConnectorGitLabGroupResource item in collection.GetGitLabSubgroupsAsync(groupFQName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorGitLabGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorGitLabGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -156,42 +193,5 @@ public async Task GetIfExists_GetGitLabGroups() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetGitLabSubgroups_ListGitLabSubgroups() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListGitLabSubgroups_example.json - // this example is just showing the usage of "GitLabSubgroups_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DevOpsConfigurationResource created on azure - // for more information of creating DevOpsConfigurationResource, please refer to the document of DevOpsConfigurationResource - string subscriptionId = "0806e1cd-cfda-4ff8-b99c-2b0af42cffd3"; - string resourceGroupName = "myRg"; - string securityConnectorName = "mySecurityConnectorName"; - ResourceIdentifier devOpsConfigurationResourceId = DevOpsConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, securityConnectorName); - DevOpsConfigurationResource devOpsConfiguration = client.GetDevOpsConfigurationResource(devOpsConfigurationResourceId); - - // get the collection of this SecurityConnectorGitLabGroupResource - SecurityConnectorGitLabGroupCollection collection = devOpsConfiguration.GetSecurityConnectorGitLabGroups(); - - // invoke the operation and iterate over the result - string groupFQName = "myGitLabGroup"; - await foreach (SecurityConnectorGitLabGroupResource item in collection.GetGitLabSubgroupsAsync(groupFQName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorGitLabGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitLabProjectCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitLabProjectCollection.cs index 3227ac38715d8..576379f7004ef 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitLabProjectCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorGitLabProjectCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SecurityConnectorGitLabProjectCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGitLabProjects() + public async Task Get_GetGitLabProjects() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListGitLabProjects_example.json - // this example is just showing the usage of "GitLabProjects_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetGitLabProjects_example.json + // this example is just showing the usage of "GitLabProjects_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListGitLabProjects() // get the collection of this SecurityConnectorGitLabProjectResource SecurityConnectorGitLabProjectCollection collection = securityConnectorGitLabGroup.GetSecurityConnectorGitLabProjects(); - // invoke the operation and iterate over the result - await foreach (SecurityConnectorGitLabProjectResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorGitLabProjectData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string projectName = "myGitLabProject"; + SecurityConnectorGitLabProjectResource result = await collection.GetAsync(projectName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorGitLabProjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetGitLabProjects() + public async Task GetAll_ListGitLabProjects() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/GetGitLabProjects_example.json - // this example is just showing the usage of "GitLabProjects_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-09-01-preview/examples/SecurityConnectorsDevOps/ListGitLabProjects_example.json + // this example is just showing the usage of "GitLabProjects_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetGitLabProjects() // get the collection of this SecurityConnectorGitLabProjectResource SecurityConnectorGitLabProjectCollection collection = securityConnectorGitLabGroup.GetSecurityConnectorGitLabProjects(); - // invoke the operation - string projectName = "myGitLabProject"; - SecurityConnectorGitLabProjectResource result = await collection.GetAsync(projectName); + // invoke the operation and iterate over the result + await foreach (SecurityConnectorGitLabProjectResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorGitLabProjectData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorGitLabProjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorResource.cs index 3fb3697577f0a..247925e35b9ba 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityConnectorResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SecurityCenter.Models; using NUnit.Framework; @@ -19,41 +18,40 @@ public partial class Sample_SecurityConnectorResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSecurityConnectors_ListAllSecurityConnectorsOfASpecifiedSubscription() + public async Task Get_RetrieveASecurityConnector() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/GetSecurityConnectorsSubscription_example.json - // this example is just showing the usage of "SecurityConnectors_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/GetSecurityConnectorSingleResource_example.json + // this example is just showing the usage of "SecurityConnectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this SecurityConnectorResource created on azure + // for more information of creating SecurityConnectorResource, please refer to the document of SecurityConnectorResource string subscriptionId = "a5caac9c-5c04-49af-b3d0-e204f40345d5"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "exampleResourceGroup"; + string securityConnectorName = "exampleSecurityConnectorName"; + ResourceIdentifier securityConnectorResourceId = SecurityConnectorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, securityConnectorName); + SecurityConnectorResource securityConnector = client.GetSecurityConnectorResource(securityConnectorResourceId); - // invoke the operation and iterate over the result - await foreach (SecurityConnectorResource item in subscriptionResource.GetSecurityConnectorsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + SecurityConnectorResource result = await securityConnector.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrieveASecurityConnector() + public async Task Delete_DeleteASecurityConnector() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/GetSecurityConnectorSingleResource_example.json - // this example is just showing the usage of "SecurityConnectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/DeleteSecurityConnector_example.json + // this example is just showing the usage of "SecurityConnectors_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,20 +60,16 @@ public async Task Get_RetrieveASecurityConnector() // this example assumes you already have this SecurityConnectorResource created on azure // for more information of creating SecurityConnectorResource, please refer to the document of SecurityConnectorResource - string subscriptionId = "a5caac9c-5c04-49af-b3d0-e204f40345d5"; - string resourceGroupName = "exampleResourceGroup"; - string securityConnectorName = "exampleSecurityConnectorName"; + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + string resourceGroupName = "myRg"; + string securityConnectorName = "mySecurityConnectorName"; ResourceIdentifier securityConnectorResourceId = SecurityConnectorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, securityConnectorName); SecurityConnectorResource securityConnector = client.GetSecurityConnectorResource(securityConnectorResourceId); // invoke the operation - SecurityConnectorResource result = await securityConnector.GetAsync(); + await securityConnector.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -103,18 +97,13 @@ public async Task Update_UpdateASecurityConnector() { HierarchyIdentifier = "exampleHierarchyId", EnvironmentName = SecurityCenterCloudName.Aws, - Offerings = -{ -new CspmMonitorAwsOffering() + Offerings = {new CspmMonitorAwsOffering { CloudRoleArn = "arn:aws:iam::00000000:role/ASCMonitor", -} -}, +}}, EnvironmentData = new AwsEnvironment(), ETag = new ETag("etag value (must be supplied for update)"), - Tags = -{ -}, + Tags = { }, }; SecurityConnectorResource result = await securityConnector.UpdateAsync(data); @@ -124,31 +113,5 @@ public async Task Update_UpdateASecurityConnector() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASecurityConnector() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/DeleteSecurityConnector_example.json - // this example is just showing the usage of "SecurityConnectors_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SecurityConnectorResource created on azure - // for more information of creating SecurityConnectorResource, please refer to the document of SecurityConnectorResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string resourceGroupName = "myRg"; - string securityConnectorName = "mySecurityConnectorName"; - ResourceIdentifier securityConnectorResourceId = SecurityConnectorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, securityConnectorName); - SecurityConnectorResource securityConnector = client.GetSecurityConnectorResource(securityConnectorResourceId); - - // invoke the operation - await securityConnector.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityContactCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityContactCollection.cs index ce636aa2eb837..f562bfecd34fe 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityContactCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityContactCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SecurityContactCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecurityContactData() + public async Task CreateOrUpdate_CreateSecurityContactData() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/GetSecurityContactsSubscription_example.json - // this example is just showing the usage of "SecurityContacts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/CreateSecurityContact_example.json + // this example is just showing the usage of "SecurityContacts_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,31 @@ public async Task GetAll_ListSecurityContactData() // get the collection of this SecurityContactResource SecurityContactCollection collection = subscriptionResource.GetSecurityContacts(); - // invoke the operation and iterate over the result - await foreach (SecurityContactResource item in collection.GetAllAsync()) + // invoke the operation + string securityContactName = "default"; + SecurityContactData data = new SecurityContactData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityContactData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Emails = "john@contoso.com;jane@contoso.com", + Phone = "(214)275-4038", + AlertNotifications = new SecurityContactPropertiesAlertNotifications + { + State = SecurityAlertNotificationState.On, + MinimalSeverity = SecurityAlertMinimalSeverity.Low, + }, + NotificationsByRole = new SecurityContactPropertiesNotificationsByRole + { + State = SecurityAlertNotificationByRoleState.On, + Roles = { SecurityAlertReceivingRole.Owner }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityContactName, data); + SecurityContactResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityContactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -85,10 +99,10 @@ public async Task Get_GetASecurityContact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASecurityContact() + public async Task GetAll_ListSecurityContactData() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/GetSecurityContact_example.json - // this example is just showing the usage of "SecurityContacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/GetSecurityContactsSubscription_example.json + // this example is just showing the usage of "SecurityContacts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,16 +118,22 @@ public async Task Exists_GetASecurityContact() // get the collection of this SecurityContactResource SecurityContactCollection collection = subscriptionResource.GetSecurityContacts(); - // invoke the operation - string securityContactName = "default"; - bool result = await collection.ExistsAsync(securityContactName); + // invoke the operation and iterate over the result + await foreach (SecurityContactResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityContactData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASecurityContact() + public async Task Exists_GetASecurityContact() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/GetSecurityContact_example.json // this example is just showing the usage of "SecurityContacts_Get" operation, for the dependent resources, they will have to be created separately. @@ -134,29 +154,17 @@ public async Task GetIfExists_GetASecurityContact() // invoke the operation string securityContactName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(securityContactName); - SecurityContactResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(securityContactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityContactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSecurityContactData() + public async Task GetIfExists_GetASecurityContact() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/CreateSecurityContact_example.json - // this example is just showing the usage of "SecurityContacts_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/GetSecurityContact_example.json + // this example is just showing the usage of "SecurityContacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,32 +182,21 @@ public async Task CreateOrUpdate_CreateSecurityContactData() // invoke the operation string securityContactName = "default"; - SecurityContactData data = new SecurityContactData() - { - Emails = "john@contoso.com;jane@contoso.com", - Phone = "(214)275-4038", - AlertNotifications = new SecurityContactPropertiesAlertNotifications() - { - State = SecurityAlertNotificationState.On, - MinimalSeverity = SecurityAlertMinimalSeverity.Low, - }, - NotificationsByRole = new SecurityContactPropertiesNotificationsByRole() - { - State = SecurityAlertNotificationByRoleState.On, - Roles = -{ -SecurityAlertReceivingRole.Owner -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityContactName, data); - SecurityContactResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(securityContactName); + SecurityContactResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityContactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityContactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityContactResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityContactResource.cs index ce81756261c8a..ece38245005e0 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityContactResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityContactResource.cs @@ -45,6 +45,31 @@ public async Task Get_GetASecurityContact() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeletesASecurityContactData() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/DeleteSecurityContact_example.json + // this example is just showing the usage of "SecurityContacts_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SecurityContactResource created on azure + // for more information of creating SecurityContactResource, please refer to the document of SecurityContactResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + string securityContactName = "default"; + ResourceIdentifier securityContactResourceId = SecurityContactResource.CreateResourceIdentifier(subscriptionId, securityContactName); + SecurityContactResource securityContact = client.GetSecurityContactResource(securityContactResourceId); + + // invoke the operation + await securityContact.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateSecurityContactData() @@ -65,22 +90,19 @@ public async Task Update_CreateSecurityContactData() SecurityContactResource securityContact = client.GetSecurityContactResource(securityContactResourceId); // invoke the operation - SecurityContactData data = new SecurityContactData() + SecurityContactData data = new SecurityContactData { Emails = "john@contoso.com;jane@contoso.com", Phone = "(214)275-4038", - AlertNotifications = new SecurityContactPropertiesAlertNotifications() + AlertNotifications = new SecurityContactPropertiesAlertNotifications { State = SecurityAlertNotificationState.On, MinimalSeverity = SecurityAlertMinimalSeverity.Low, }, - NotificationsByRole = new SecurityContactPropertiesNotificationsByRole() + NotificationsByRole = new SecurityContactPropertiesNotificationsByRole { State = SecurityAlertNotificationByRoleState.On, - Roles = -{ -SecurityAlertReceivingRole.Owner -}, + Roles = { SecurityAlertReceivingRole.Owner }, }, }; ArmOperation lro = await securityContact.UpdateAsync(WaitUntil.Completed, data); @@ -92,30 +114,5 @@ public async Task Update_CreateSecurityContactData() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesASecurityContactData() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2020-01-01-preview/examples/SecurityContacts/DeleteSecurityContact_example.json - // this example is just showing the usage of "SecurityContacts_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SecurityContactResource created on azure - // for more information of creating SecurityContactResource, please refer to the document of SecurityContactResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string securityContactName = "default"; - ResourceIdentifier securityContactResourceId = SecurityContactResource.CreateResourceIdentifier(subscriptionId, securityContactName); - SecurityContactResource securityContact = client.GetSecurityContactResource(securityContactResourceId); - - // invoke the operation - await securityContact.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityHealthReportCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityHealthReportCollection.cs index 9d8c1d1e0fea6..a7c7ef3e5a48d 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityHealthReportCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityHealthReportCollection.cs @@ -17,66 +17,58 @@ public partial class Sample_SecurityHealthReportCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListHealthReports() + public async Task Get_GetHealthReportOfResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-05-01-preview/examples/HealthReports/ListHealthReports_example.json - // this example is just showing the usage of "HealthReports_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-05-01-preview/examples/HealthReports/GetHealthReports_example.json + // this example is just showing the usage of "HealthReports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityHealthReportResource - string scope = "subscriptions/a1efb6ca-fbc5-4782-9aaa-5c7daded1ce2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SecurityHealthReportCollection collection = client.GetSecurityHealthReports(scopeId); + string resourceId = "subscriptions/a1efb6ca-fbc5-4782-9aaa-5c7daded1ce2/resourcegroups/E2E-IBB0WX/providers/Microsoft.Security/securityconnectors/AwsConnectorAllOfferings"; + SecurityHealthReportCollection collection = client.GetSecurityHealthReports(new ResourceIdentifier(resourceId)); - // invoke the operation and iterate over the result - await foreach (SecurityHealthReportResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityHealthReportData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string healthReportName = "909c629a-bf39-4521-8e4f-10b443a0bc02"; + SecurityHealthReportResource result = await collection.GetAsync(healthReportName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityHealthReportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetHealthReportOfResource() + public async Task GetAll_ListHealthReports() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-05-01-preview/examples/HealthReports/GetHealthReports_example.json - // this example is just showing the usage of "HealthReports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-05-01-preview/examples/HealthReports/ListHealthReports_example.json + // this example is just showing the usage of "HealthReports_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityHealthReportResource - string resourceId = "subscriptions/a1efb6ca-fbc5-4782-9aaa-5c7daded1ce2/resourcegroups/E2E-IBB0WX/providers/Microsoft.Security/securityconnectors/AwsConnectorAllOfferings"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SecurityHealthReportCollection collection = client.GetSecurityHealthReports(scopeId); + string scope = "subscriptions/a1efb6ca-fbc5-4782-9aaa-5c7daded1ce2"; + SecurityHealthReportCollection collection = client.GetSecurityHealthReports(new ResourceIdentifier(scope)); - // invoke the operation - string healthReportName = "909c629a-bf39-4521-8e4f-10b443a0bc02"; - SecurityHealthReportResource result = await collection.GetAsync(healthReportName); + // invoke the operation and iterate over the result + await foreach (SecurityHealthReportResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityHealthReportData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityHealthReportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -91,13 +83,9 @@ public async Task Exists_GetHealthReportOfResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityHealthReportResource string resourceId = "subscriptions/a1efb6ca-fbc5-4782-9aaa-5c7daded1ce2/resourcegroups/E2E-IBB0WX/providers/Microsoft.Security/securityconnectors/AwsConnectorAllOfferings"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SecurityHealthReportCollection collection = client.GetSecurityHealthReports(scopeId); + SecurityHealthReportCollection collection = client.GetSecurityHealthReports(new ResourceIdentifier(resourceId)); // invoke the operation string healthReportName = "909c629a-bf39-4521-8e4f-10b443a0bc02"; @@ -118,13 +106,9 @@ public async Task GetIfExists_GetHealthReportOfResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SecurityHealthReportResource string resourceId = "subscriptions/a1efb6ca-fbc5-4782-9aaa-5c7daded1ce2/resourcegroups/E2E-IBB0WX/providers/Microsoft.Security/securityconnectors/AwsConnectorAllOfferings"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SecurityHealthReportCollection collection = client.GetSecurityHealthReports(scopeId); + SecurityHealthReportCollection collection = client.GetSecurityHealthReports(new ResourceIdentifier(resourceId)); // invoke the operation string healthReportName = "909c629a-bf39-4521-8e4f-10b443a0bc02"; diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityOperatorCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityOperatorCollection.cs index 8a3552b301a27..3e337d6b25c42 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityOperatorCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityOperatorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SecurityOperatorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecurityOperators() + public async Task CreateOrUpdate_CreateASecurityOperatorOnTheGivenScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/ListSecurityOperators_example.json - // this example is just showing the usage of "SecurityOperators_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/PutSecurityOperatorByName_example.json + // this example is just showing the usage of "SecurityOperators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,16 @@ public async Task GetAll_ListSecurityOperators() // get the collection of this SecurityOperatorResource SecurityOperatorCollection collection = securityCenterPricing.GetSecurityOperators(); - // invoke the operation and iterate over the result - await foreach (SecurityOperatorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityOperatorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string securityOperatorName = "DefenderCSPMSecurityOperator"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityOperatorName); + SecurityOperatorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityOperatorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -85,10 +84,10 @@ public async Task Get_GetASpecificSecurityOperatorByScopeAndSecurityOperatorName [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASpecificSecurityOperatorByScopeAndSecurityOperatorName() + public async Task GetAll_ListSecurityOperators() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/GetSecurityOperatorByName_example.json - // this example is just showing the usage of "SecurityOperators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/ListSecurityOperators_example.json + // this example is just showing the usage of "SecurityOperators_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,16 +104,22 @@ public async Task Exists_GetASpecificSecurityOperatorByScopeAndSecurityOperatorN // get the collection of this SecurityOperatorResource SecurityOperatorCollection collection = securityCenterPricing.GetSecurityOperators(); - // invoke the operation - string securityOperatorName = "DefenderCSPMSecurityOperator"; - bool result = await collection.ExistsAsync(securityOperatorName); + // invoke the operation and iterate over the result + await foreach (SecurityOperatorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityOperatorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASpecificSecurityOperatorByScopeAndSecurityOperatorName() + public async Task Exists_GetASpecificSecurityOperatorByScopeAndSecurityOperatorName() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/GetSecurityOperatorByName_example.json // this example is just showing the usage of "SecurityOperators_Get" operation, for the dependent resources, they will have to be created separately. @@ -136,29 +141,17 @@ public async Task GetIfExists_GetASpecificSecurityOperatorByScopeAndSecurityOper // invoke the operation string securityOperatorName = "DefenderCSPMSecurityOperator"; - NullableResponse response = await collection.GetIfExistsAsync(securityOperatorName); - SecurityOperatorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(securityOperatorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityOperatorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASecurityOperatorOnTheGivenScope() + public async Task GetIfExists_GetASpecificSecurityOperatorByScopeAndSecurityOperatorName() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/PutSecurityOperatorByName_example.json - // this example is just showing the usage of "SecurityOperators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/GetSecurityOperatorByName_example.json + // this example is just showing the usage of "SecurityOperators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,14 +170,21 @@ public async Task CreateOrUpdate_CreateASecurityOperatorOnTheGivenScope() // invoke the operation string securityOperatorName = "DefenderCSPMSecurityOperator"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityOperatorName); - SecurityOperatorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(securityOperatorName); + SecurityOperatorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityOperatorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityOperatorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityOperatorResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityOperatorResource.cs index 3620e66424082..a34ae940a71b3 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityOperatorResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityOperatorResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetASpecificSecurityOperatorByScopeAndSecurityOperatorName [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateASecurityOperatorOnTheGivenScope() + public async Task Delete_DeleteSecurityOperatorOnSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/PutSecurityOperatorByName_example.json - // this example is just showing the usage of "SecurityOperators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/DeleteSecurityOperatorByName_example.json + // this example is just showing the usage of "SecurityOperators_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,22 +66,17 @@ public async Task Update_CreateASecurityOperatorOnTheGivenScope() SecurityOperatorResource securityOperator = client.GetSecurityOperatorResource(securityOperatorResourceId); // invoke the operation - ArmOperation lro = await securityOperator.UpdateAsync(WaitUntil.Completed); - SecurityOperatorResource result = lro.Value; + await securityOperator.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityOperatorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSecurityOperatorOnSubscription() + public async Task Update_CreateASecurityOperatorOnTheGivenScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/DeleteSecurityOperatorByName_example.json - // this example is just showing the usage of "SecurityOperators_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-01-01-preview/examples/SecurityOperators/PutSecurityOperatorByName_example.json + // this example is just showing the usage of "SecurityOperators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,9 +92,14 @@ public async Task Delete_DeleteSecurityOperatorOnSubscription() SecurityOperatorResource securityOperator = client.GetSecurityOperatorResource(securityOperatorResourceId); // invoke the operation - await securityOperator.DeleteAsync(WaitUntil.Completed); + ArmOperation lro = await securityOperator.UpdateAsync(WaitUntil.Completed); + SecurityOperatorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityOperatorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySettingCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySettingCollection.cs index 986775fda3ee7..1ffb9b8b2a0d1 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySettingCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySettingCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SecuritySettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSettingsOfSubscription() + public async Task CreateOrUpdate_UpdateASettingForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSettings_example.json - // this example is just showing the usage of "Settings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/UpdateSetting_example.json + // this example is just showing the usage of "Settings_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_GetSettingsOfSubscription() // get the collection of this SecuritySettingResource SecuritySettingCollection collection = subscriptionResource.GetSecuritySettings(); - // invoke the operation and iterate over the result - await foreach (SecuritySettingResource item in collection.GetAllAsync()) + // invoke the operation + SecuritySettingName settingName = SecuritySettingName.Wdatp; + SecuritySettingData data = new DataExportSettings { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecuritySettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsEnabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, settingName, data); + SecuritySettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecuritySettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -85,10 +88,10 @@ public async Task Get_GetASettingOnSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASettingOnSubscription() + public async Task GetAll_GetSettingsOfSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSetting_example.json - // this example is just showing the usage of "Settings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSettings_example.json + // this example is just showing the usage of "Settings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,16 +107,22 @@ public async Task Exists_GetASettingOnSubscription() // get the collection of this SecuritySettingResource SecuritySettingCollection collection = subscriptionResource.GetSecuritySettings(); - // invoke the operation - SecuritySettingName settingName = SecuritySettingName.Wdatp; - bool result = await collection.ExistsAsync(settingName); + // invoke the operation and iterate over the result + await foreach (SecuritySettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecuritySettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASettingOnSubscription() + public async Task Exists_GetASettingOnSubscription() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSetting_example.json // this example is just showing the usage of "Settings_Get" operation, for the dependent resources, they will have to be created separately. @@ -134,29 +143,17 @@ public async Task GetIfExists_GetASettingOnSubscription() // invoke the operation SecuritySettingName settingName = SecuritySettingName.Wdatp; - NullableResponse response = await collection.GetIfExistsAsync(settingName); - SecuritySettingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(settingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecuritySettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateASettingForSubscription() + public async Task GetIfExists_GetASettingOnSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/UpdateSetting_example.json - // this example is just showing the usage of "Settings_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-05-01/examples/Settings/GetSetting_example.json + // this example is just showing the usage of "Settings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,18 +171,21 @@ public async Task CreateOrUpdate_UpdateASettingForSubscription() // invoke the operation SecuritySettingName settingName = SecuritySettingName.Wdatp; - SecuritySettingData data = new DataExportSettings() - { - IsEnabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, settingName, data); - SecuritySettingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(settingName); + SecuritySettingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecuritySettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecuritySettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySettingResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySettingResource.cs index f85c070b080a4..f811ca87dae8a 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySettingResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySettingResource.cs @@ -65,7 +65,7 @@ public async Task Update_UpdateASettingForSubscription() SecuritySettingResource securitySetting = client.GetSecuritySettingResource(securitySettingResourceId); // invoke the operation - SecuritySettingData data = new DataExportSettings() + SecuritySettingData data = new DataExportSettings { IsEnabled = true, }; diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySubAssessmentCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySubAssessmentCollection.cs index 4ae0daa4058e5..afdce4ba1fc69 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySubAssessmentCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecuritySubAssessmentCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SecuritySubAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecuritySubAssessments() + public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/SubAssessments/ListSubAssessments_example.json - // this example is just showing the usage of "SubAssessments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/SubAssessments/GetSubAssessment_example.json + // this example is just showing the usage of "SubAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -29,33 +29,31 @@ public async Task GetAll_ListSecuritySubAssessments() // this example assumes you already have this SecurityAssessmentResource created on azure // for more information of creating SecurityAssessmentResource, please refer to the document of SecurityAssessmentResource - string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string assessmentName = "82e20e14-edc5-4373-bfc4-f13121257c37"; + string scope = "subscriptions/212f9889-769e-45ae-ab43-6da33674bd26/resourceGroups/DEMORG/providers/Microsoft.Compute/virtualMachines/vm2"; + string assessmentName = "1195afff-c881-495e-9bc5-1486211ae03f"; ResourceIdentifier securityAssessmentResourceId = SecurityAssessmentResource.CreateResourceIdentifier(scope, assessmentName); SecurityAssessmentResource securityAssessment = client.GetSecurityAssessmentResource(securityAssessmentResourceId); // get the collection of this SecuritySubAssessmentResource SecuritySubAssessmentCollection collection = securityAssessment.GetSecuritySubAssessments(); - // invoke the operation and iterate over the result - await foreach (SecuritySubAssessmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecuritySubAssessmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string subAssessmentName = "95f7da9c-a2a4-1322-0758-fcd24ef09b85"; + SecuritySubAssessmentResource result = await collection.GetAsync(subAssessmentName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecuritySubAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocation() + public async Task GetAll_ListSecuritySubAssessments() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/SubAssessments/GetSubAssessment_example.json - // this example is just showing the usage of "SubAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/SubAssessments/ListSubAssessments_example.json + // this example is just showing the usage of "SubAssessments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,23 +62,25 @@ public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocation() // this example assumes you already have this SecurityAssessmentResource created on azure // for more information of creating SecurityAssessmentResource, please refer to the document of SecurityAssessmentResource - string scope = "subscriptions/212f9889-769e-45ae-ab43-6da33674bd26/resourceGroups/DEMORG/providers/Microsoft.Compute/virtualMachines/vm2"; - string assessmentName = "1195afff-c881-495e-9bc5-1486211ae03f"; + string scope = "subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + string assessmentName = "82e20e14-edc5-4373-bfc4-f13121257c37"; ResourceIdentifier securityAssessmentResourceId = SecurityAssessmentResource.CreateResourceIdentifier(scope, assessmentName); SecurityAssessmentResource securityAssessment = client.GetSecurityAssessmentResource(securityAssessmentResourceId); // get the collection of this SecuritySubAssessmentResource SecuritySubAssessmentCollection collection = securityAssessment.GetSecuritySubAssessments(); - // invoke the operation - string subAssessmentName = "95f7da9c-a2a4-1322-0758-fcd24ef09b85"; - SecuritySubAssessmentResource result = await collection.GetAsync(subAssessmentName); + // invoke the operation and iterate over the result + await foreach (SecuritySubAssessmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecuritySubAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecuritySubAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityWorkspaceSettingCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityWorkspaceSettingCollection.cs index d037e99229aab..7a3c410cd4177 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityWorkspaceSettingCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityWorkspaceSettingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SecurityWorkspaceSettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetWorkspaceSettingsOnSubscription() + public async Task CreateOrUpdate_CreateAWorkspaceSettingDataForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/GetWorkspaceSettings_example.json - // this example is just showing the usage of "WorkspaceSettings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/CreateWorkspaceSetting_example.json + // this example is just showing the usage of "WorkspaceSettings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task GetAll_GetWorkspaceSettingsOnSubscription() // get the collection of this SecurityWorkspaceSettingResource SecurityWorkspaceSettingCollection collection = subscriptionResource.GetSecurityWorkspaceSettings(); - // invoke the operation and iterate over the result - await foreach (SecurityWorkspaceSettingResource item in collection.GetAllAsync()) + // invoke the operation + string workspaceSettingName = "default"; + SecurityWorkspaceSettingData data = new SecurityWorkspaceSettingData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityWorkspaceSettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + WorkspaceId = new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace"), + Scope = "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceSettingName, data); + SecurityWorkspaceSettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityWorkspaceSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -84,10 +88,10 @@ public async Task Get_GetAWorkspaceSettingOnSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAWorkspaceSettingOnSubscription() + public async Task GetAll_GetWorkspaceSettingsOnSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/GetWorkspaceSetting_example.json - // this example is just showing the usage of "WorkspaceSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/GetWorkspaceSettings_example.json + // this example is just showing the usage of "WorkspaceSettings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,16 +107,22 @@ public async Task Exists_GetAWorkspaceSettingOnSubscription() // get the collection of this SecurityWorkspaceSettingResource SecurityWorkspaceSettingCollection collection = subscriptionResource.GetSecurityWorkspaceSettings(); - // invoke the operation - string workspaceSettingName = "default"; - bool result = await collection.ExistsAsync(workspaceSettingName); + // invoke the operation and iterate over the result + await foreach (SecurityWorkspaceSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityWorkspaceSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAWorkspaceSettingOnSubscription() + public async Task Exists_GetAWorkspaceSettingOnSubscription() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/GetWorkspaceSetting_example.json // this example is just showing the usage of "WorkspaceSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -133,29 +143,17 @@ public async Task GetIfExists_GetAWorkspaceSettingOnSubscription() // invoke the operation string workspaceSettingName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(workspaceSettingName); - SecurityWorkspaceSettingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(workspaceSettingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityWorkspaceSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAWorkspaceSettingDataForSubscription() + public async Task GetIfExists_GetAWorkspaceSettingOnSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/CreateWorkspaceSetting_example.json - // this example is just showing the usage of "WorkspaceSettings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/GetWorkspaceSetting_example.json + // this example is just showing the usage of "WorkspaceSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,19 +171,21 @@ public async Task CreateOrUpdate_CreateAWorkspaceSettingDataForSubscription() // invoke the operation string workspaceSettingName = "default"; - SecurityWorkspaceSettingData data = new SecurityWorkspaceSettingData() - { - WorkspaceId = new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace"), - Scope = "/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceSettingName, data); - SecurityWorkspaceSettingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(workspaceSettingName); + SecurityWorkspaceSettingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityWorkspaceSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityWorkspaceSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityWorkspaceSettingResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityWorkspaceSettingResource.cs index f71dffa86f86c..3d0ee1211f4c7 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityWorkspaceSettingResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SecurityWorkspaceSettingResource.cs @@ -46,10 +46,10 @@ public async Task Get_GetAWorkspaceSettingOnSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAWorkspaceSettingDataForSubscription() + public async Task Delete_DeleteAWorkspaceSettingDataForResourceGroup() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/UpdateWorkspaceSetting_example.json - // this example is just showing the usage of "WorkspaceSettings_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/DeleteWorkspaceSetting_example.json + // this example is just showing the usage of "WorkspaceSettings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,25 +64,17 @@ public async Task Update_UpdateAWorkspaceSettingDataForSubscription() SecurityWorkspaceSettingResource securityWorkspaceSetting = client.GetSecurityWorkspaceSettingResource(securityWorkspaceSettingResourceId); // invoke the operation - SecurityWorkspaceSettingData data = new SecurityWorkspaceSettingData() - { - WorkspaceId = new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace"), - }; - SecurityWorkspaceSettingResource result = await securityWorkspaceSetting.UpdateAsync(data); + await securityWorkspaceSetting.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityWorkspaceSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAWorkspaceSettingDataForResourceGroup() + public async Task Update_UpdateAWorkspaceSettingDataForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/DeleteWorkspaceSetting_example.json - // this example is just showing the usage of "WorkspaceSettings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2017-08-01-preview/examples/WorkspaceSettings/UpdateWorkspaceSetting_example.json + // this example is just showing the usage of "WorkspaceSettings_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,9 +89,17 @@ public async Task Delete_DeleteAWorkspaceSettingDataForResourceGroup() SecurityWorkspaceSettingResource securityWorkspaceSetting = client.GetSecurityWorkspaceSettingResource(securityWorkspaceSettingResourceId); // invoke the operation - await securityWorkspaceSetting.DeleteAsync(WaitUntil.Completed); + SecurityWorkspaceSettingData data = new SecurityWorkspaceSettingData + { + WorkspaceId = new ResourceIdentifier("/subscriptions/20ff7fc3-e762-44dd-bd96-b71116dcdc23/resourceGroups/myRg/providers/Microsoft.OperationalInsights/workspaces/myWorkspace"), + }; + SecurityWorkspaceSettingResource result = await securityWorkspaceSetting.UpdateAsync(data); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityWorkspaceSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SensitivitySettingResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SensitivitySettingResource.cs index a4f901f7c476f..e0920aa4cd825 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SensitivitySettingResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SensitivitySettingResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SensitivitySettingResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateSensitivitySettings() + public async Task Get_GetSensitivitySettings() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-15-preview/examples/SensitivitySettings/PutSensitivitySettings_example.json - // this example is just showing the usage of "UpdateSensitivitySettings" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-15-preview/examples/SensitivitySettings/GetSensitivitySettings_example.json + // this example is just showing the usage of "GetSensitivitySettings" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,16 +34,7 @@ public async Task CreateOrUpdate_UpdateSensitivitySettings() SensitivitySettingResource sensitivitySetting = client.GetSensitivitySettingResource(sensitivitySettingResourceId); // invoke the operation - SensitivitySettingCreateOrUpdateContent content = new SensitivitySettingCreateOrUpdateContent(new Guid[] - { -Guid.Parse("f2f8a7a1-28c0-404b-9ab4-30a0a7af18cb"),Guid.Parse("b452f22b-f87d-4f48-8490-ecf0873325b5"),Guid.Parse("d59ee8b6-2618-404b-a5e7-aa377cd67543") - }) - { - SensitivityThresholdLabelOrder = 2, - SensitivityThresholdLabelId = Guid.Parse("f2f8a7a1-28c0-404b-9ab4-30a0a7af18cb"), - }; - ArmOperation lro = await sensitivitySetting.CreateOrUpdateAsync(WaitUntil.Completed, content); - SensitivitySettingResource result = lro.Value; + SensitivitySettingResource result = await sensitivitySetting.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +45,10 @@ public async Task CreateOrUpdate_UpdateSensitivitySettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSensitivitySettings() + public async Task CreateOrUpdate_UpdateSensitivitySettings() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-15-preview/examples/SensitivitySettings/GetSensitivitySettings_example.json - // this example is just showing the usage of "GetSensitivitySettings" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-15-preview/examples/SensitivitySettings/PutSensitivitySettings_example.json + // this example is just showing the usage of "UpdateSensitivitySettings" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,7 +61,13 @@ public async Task Get_GetSensitivitySettings() SensitivitySettingResource sensitivitySetting = client.GetSensitivitySettingResource(sensitivitySettingResourceId); // invoke the operation - SensitivitySettingResource result = await sensitivitySetting.GetAsync(); + SensitivitySettingCreateOrUpdateContent content = new SensitivitySettingCreateOrUpdateContent(new Guid[] { Guid.Parse("f2f8a7a1-28c0-404b-9ab4-30a0a7af18cb"), Guid.Parse("b452f22b-f87d-4f48-8490-ecf0873325b5"), Guid.Parse("d59ee8b6-2618-404b-a5e7-aa377cd67543") }) + { + SensitivityThresholdLabelOrder = 2, + SensitivityThresholdLabelId = Guid.Parse("f2f8a7a1-28c0-404b-9ab4-30a0a7af18cb"), + }; + ArmOperation lro = await sensitivitySetting.CreateOrUpdateAsync(WaitUntil.Completed, content); + SensitivitySettingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentCollection.cs index 582cf0a540309..b45473149d9e8 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServerVulnerabilityAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfServerVulnerabilityAssessmentsOnAResourceThoughThisAPIReturnsAListCurrentlyMicrosoftSecurityOnlySupportsASingleDefaultTypeOfServerVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateAServerVulnerabilityAssessmentsOnAResourceOnlyDefaultResourceIsSupportedOnceCreatingTheResourceTheServerWillBeOnboardedToVulnerabilityAssessmentByMicrosoftSecurity() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/ListByExtendedResourceServerVulnerabilityAssessments_example.json - // this example is just showing the usage of "ServerVulnerabilityAssessment_ListByExtendedResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/CreateServerVulnerabilityAssessments_example.json + // this example is just showing the usage of "ServerVulnerabilityAssessment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,15 @@ public async Task GetAll_GetAListOfServerVulnerabilityAssessmentsOnAResourceThou string resourceName = "vm1"; ServerVulnerabilityAssessmentCollection collection = resourceGroupResource.GetServerVulnerabilityAssessments(resourceNamespace, resourceType, resourceName); - // invoke the operation and iterate over the result - await foreach (ServerVulnerabilityAssessmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerVulnerabilityAssessmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed); + ServerVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +89,10 @@ public async Task Get_GetAServerVulnerabilityAssessmentsOnboardingStatusOnAResou [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerVulnerabilityAssessmentsOnboardingStatusOnAResourceCurrentlyMicrosoftSecurityOnlySupportsTheSingleDefaultResource() + public async Task GetAll_GetAListOfServerVulnerabilityAssessmentsOnAResourceThoughThisAPIReturnsAListCurrentlyMicrosoftSecurityOnlySupportsASingleDefaultTypeOfServerVulnerabilityAssessment() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/GetServerVulnerabilityAssessments_example.json - // this example is just showing the usage of "ServerVulnerabilityAssessment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/ListByExtendedResourceServerVulnerabilityAssessments_example.json + // this example is just showing the usage of "ServerVulnerabilityAssessment_ListByExtendedResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,15 +112,22 @@ public async Task Exists_GetAServerVulnerabilityAssessmentsOnboardingStatusOnARe string resourceName = "vm1"; ServerVulnerabilityAssessmentCollection collection = resourceGroupResource.GetServerVulnerabilityAssessments(resourceNamespace, resourceType, resourceName); - // invoke the operation - bool result = await collection.ExistsAsync(); + // invoke the operation and iterate over the result + await foreach (ServerVulnerabilityAssessmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerVulnerabilityAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerVulnerabilityAssessmentsOnboardingStatusOnAResourceCurrentlyMicrosoftSecurityOnlySupportsTheSingleDefaultResource() + public async Task Exists_GetAServerVulnerabilityAssessmentsOnboardingStatusOnAResourceCurrentlyMicrosoftSecurityOnlySupportsTheSingleDefaultResource() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/GetServerVulnerabilityAssessments_example.json // this example is just showing the usage of "ServerVulnerabilityAssessment_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +151,17 @@ public async Task GetIfExists_GetAServerVulnerabilityAssessmentsOnboardingStatus ServerVulnerabilityAssessmentCollection collection = resourceGroupResource.GetServerVulnerabilityAssessments(resourceNamespace, resourceType, resourceName); // invoke the operation - NullableResponse response = await collection.GetIfExistsAsync(); - ServerVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAServerVulnerabilityAssessmentsOnAResourceOnlyDefaultResourceIsSupportedOnceCreatingTheResourceTheServerWillBeOnboardedToVulnerabilityAssessmentByMicrosoftSecurity() + public async Task GetIfExists_GetAServerVulnerabilityAssessmentsOnboardingStatusOnAResourceCurrentlyMicrosoftSecurityOnlySupportsTheSingleDefaultResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/CreateServerVulnerabilityAssessments_example.json - // this example is just showing the usage of "ServerVulnerabilityAssessment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/GetServerVulnerabilityAssessments_example.json + // this example is just showing the usage of "ServerVulnerabilityAssessment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,14 +182,21 @@ public async Task CreateOrUpdate_CreateAServerVulnerabilityAssessmentsOnAResourc ServerVulnerabilityAssessmentCollection collection = resourceGroupResource.GetServerVulnerabilityAssessments(resourceNamespace, resourceType, resourceName); // invoke the operation - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed); - ServerVulnerabilityAssessmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(); + ServerVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentResource.cs index 286f33eee2086..2cf1e2706b776 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAServerVulnerabilityAssessmentsOnboardingStatusOnAResou [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAServerVulnerabilityAssessmentsOnAResourceOnlyDefaultResourceIsSupportedOnceCreatingTheResourceTheServerWillBeOnboardedToVulnerabilityAssessmentByMicrosoftSecurity() + public async Task Delete_DeleteAServerVulnerabilityAssessmentsOnAResourceOnlyDefaultResourceIsSupportedOnceDeletingMicrosoftSecurityWillNotProvideVulnerabilityAssessmentFindingsOnTheResource() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/CreateServerVulnerabilityAssessments_example.json - // this example is just showing the usage of "ServerVulnerabilityAssessment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/DeleteServerVulnerabilityAssessments_example.json + // this example is just showing the usage of "ServerVulnerabilityAssessment_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,22 +70,17 @@ public async Task Update_CreateAServerVulnerabilityAssessmentsOnAResourceOnlyDef ServerVulnerabilityAssessmentResource serverVulnerabilityAssessment = client.GetServerVulnerabilityAssessmentResource(serverVulnerabilityAssessmentResourceId); // invoke the operation - ArmOperation lro = await serverVulnerabilityAssessment.UpdateAsync(WaitUntil.Completed); - ServerVulnerabilityAssessmentResource result = lro.Value; + await serverVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAServerVulnerabilityAssessmentsOnAResourceOnlyDefaultResourceIsSupportedOnceDeletingMicrosoftSecurityWillNotProvideVulnerabilityAssessmentFindingsOnTheResource() + public async Task Update_CreateAServerVulnerabilityAssessmentsOnAResourceOnlyDefaultResourceIsSupportedOnceCreatingTheResourceTheServerWillBeOnboardedToVulnerabilityAssessmentByMicrosoftSecurity() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/DeleteServerVulnerabilityAssessments_example.json - // this example is just showing the usage of "ServerVulnerabilityAssessment_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ServerVulnerabilityAssessments/CreateServerVulnerabilityAssessments_example.json + // this example is just showing the usage of "ServerVulnerabilityAssessment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,9 +98,14 @@ public async Task Delete_DeleteAServerVulnerabilityAssessmentsOnAResourceOnlyDef ServerVulnerabilityAssessmentResource serverVulnerabilityAssessment = client.GetServerVulnerabilityAssessmentResource(serverVulnerabilityAssessmentResourceId); // invoke the operation - await serverVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); + ArmOperation lro = await serverVulnerabilityAssessment.UpdateAsync(WaitUntil.Completed); + ServerVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentsSettingCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentsSettingCollection.cs index ae5ff513be0f2..964c0186ae7a7 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentsSettingCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentsSettingCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ServerVulnerabilityAssessmentsSettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheServerVulnerabilityAssessmentsSettingsSetOnTheSubscription() + public async Task CreateOrUpdate_SetAServerVulnerabilityAssessmentsSettingOfTheKindSettingKindOnTheSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/ListServerVulnerabilityAssessmentsSettings_example.json - // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/PutServerVulnerabilityAssessmentsSetting_example.json + // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ListTheServerVulnerabilityAssessmentsSettingsSetOnTheSu // get the collection of this ServerVulnerabilityAssessmentsSettingResource ServerVulnerabilityAssessmentsSettingCollection collection = subscriptionResource.GetServerVulnerabilityAssessmentsSettings(); - // invoke the operation and iterate over the result - await foreach (ServerVulnerabilityAssessmentsSettingResource item in collection.GetAllAsync()) + // invoke the operation + ServerVulnerabilityAssessmentsSettingKindName settingKind = ServerVulnerabilityAssessmentsSettingKindName.AzureServersSetting; + ServerVulnerabilityAssessmentsSettingData data = new AzureServersSetting { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerVulnerabilityAssessmentsSettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SelectedProvider = ServerVulnerabilityAssessmentsAzureSettingSelectedProvider.MdeTvm, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, settingKind, data); + ServerVulnerabilityAssessmentsSettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerVulnerabilityAssessmentsSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -85,10 +88,10 @@ public async Task Get_GetTheServerVulnerabilityAssessmentsSettingOfTheKindSettin [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheServerVulnerabilityAssessmentsSettingOfTheKindSettingKindThatIsSetOnTheSubscription() + public async Task GetAll_ListTheServerVulnerabilityAssessmentsSettingsSetOnTheSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/GetServerVulnerabilityAssessmentsSetting_example.json - // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/ListServerVulnerabilityAssessmentsSettings_example.json + // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,16 +107,22 @@ public async Task Exists_GetTheServerVulnerabilityAssessmentsSettingOfTheKindSet // get the collection of this ServerVulnerabilityAssessmentsSettingResource ServerVulnerabilityAssessmentsSettingCollection collection = subscriptionResource.GetServerVulnerabilityAssessmentsSettings(); - // invoke the operation - ServerVulnerabilityAssessmentsSettingKindName settingKind = ServerVulnerabilityAssessmentsSettingKindName.AzureServersSetting; - bool result = await collection.ExistsAsync(settingKind); + // invoke the operation and iterate over the result + await foreach (ServerVulnerabilityAssessmentsSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerVulnerabilityAssessmentsSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheServerVulnerabilityAssessmentsSettingOfTheKindSettingKindThatIsSetOnTheSubscription() + public async Task Exists_GetTheServerVulnerabilityAssessmentsSettingOfTheKindSettingKindThatIsSetOnTheSubscription() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/GetServerVulnerabilityAssessmentsSetting_example.json // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -134,29 +143,17 @@ public async Task GetIfExists_GetTheServerVulnerabilityAssessmentsSettingOfTheKi // invoke the operation ServerVulnerabilityAssessmentsSettingKindName settingKind = ServerVulnerabilityAssessmentsSettingKindName.AzureServersSetting; - NullableResponse response = await collection.GetIfExistsAsync(settingKind); - ServerVulnerabilityAssessmentsSettingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(settingKind); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerVulnerabilityAssessmentsSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SetAServerVulnerabilityAssessmentsSettingOfTheKindSettingKindOnTheSubscription() + public async Task GetIfExists_GetTheServerVulnerabilityAssessmentsSettingOfTheKindSettingKindThatIsSetOnTheSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/PutServerVulnerabilityAssessmentsSetting_example.json - // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/GetServerVulnerabilityAssessmentsSetting_example.json + // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,18 +171,21 @@ public async Task CreateOrUpdate_SetAServerVulnerabilityAssessmentsSettingOfTheK // invoke the operation ServerVulnerabilityAssessmentsSettingKindName settingKind = ServerVulnerabilityAssessmentsSettingKindName.AzureServersSetting; - ServerVulnerabilityAssessmentsSettingData data = new AzureServersSetting() - { - SelectedProvider = ServerVulnerabilityAssessmentsAzureSettingSelectedProvider.MdeTvm, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, settingKind, data); - ServerVulnerabilityAssessmentsSettingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(settingKind); + ServerVulnerabilityAssessmentsSettingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerVulnerabilityAssessmentsSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerVulnerabilityAssessmentsSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentsSettingResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentsSettingResource.cs index e75c4fd41b3f2..6f1674c937358 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentsSettingResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_ServerVulnerabilityAssessmentsSettingResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetTheServerVulnerabilityAssessmentsSettingOfTheKindSettin [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SetAServerVulnerabilityAssessmentsSettingOfTheKindSettingKindOnTheSubscription() + public async Task Delete_DeleteTheServerVulnerabilityAssessmentsSettingOfTheKindSettingKindFromTheSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/PutServerVulnerabilityAssessmentsSetting_example.json - // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/DeleteServerVulnerabilityAssessmentsSetting_example.json + // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,26 +65,17 @@ public async Task Update_SetAServerVulnerabilityAssessmentsSettingOfTheKindSetti ServerVulnerabilityAssessmentsSettingResource serverVulnerabilityAssessmentsSetting = client.GetServerVulnerabilityAssessmentsSettingResource(serverVulnerabilityAssessmentsSettingResourceId); // invoke the operation - ServerVulnerabilityAssessmentsSettingData data = new AzureServersSetting() - { - SelectedProvider = ServerVulnerabilityAssessmentsAzureSettingSelectedProvider.MdeTvm, - }; - ArmOperation lro = await serverVulnerabilityAssessmentsSetting.UpdateAsync(WaitUntil.Completed, data); - ServerVulnerabilityAssessmentsSettingResource result = lro.Value; + await serverVulnerabilityAssessmentsSetting.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerVulnerabilityAssessmentsSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteTheServerVulnerabilityAssessmentsSettingOfTheKindSettingKindFromTheSubscription() + public async Task Update_SetAServerVulnerabilityAssessmentsSettingOfTheKindSettingKindOnTheSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/DeleteServerVulnerabilityAssessmentsSetting_example.json - // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-05-01/examples/ServerVulnerabilityAssessmentsSettings/PutServerVulnerabilityAssessmentsSetting_example.json + // this example is just showing the usage of "ServerVulnerabilityAssessmentsSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,9 +90,18 @@ public async Task Delete_DeleteTheServerVulnerabilityAssessmentsSettingOfTheKind ServerVulnerabilityAssessmentsSettingResource serverVulnerabilityAssessmentsSetting = client.GetServerVulnerabilityAssessmentsSettingResource(serverVulnerabilityAssessmentsSettingResourceId); // invoke the operation - await serverVulnerabilityAssessmentsSetting.DeleteAsync(WaitUntil.Completed); + ServerVulnerabilityAssessmentsSettingData data = new AzureServersSetting + { + SelectedProvider = ServerVulnerabilityAssessmentsAzureSettingSelectedProvider.MdeTvm, + }; + ArmOperation lro = await serverVulnerabilityAssessmentsSetting.UpdateAsync(WaitUntil.Completed, data); + ServerVulnerabilityAssessmentsSettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerVulnerabilityAssessmentsSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SoftwareInventoryCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SoftwareInventoryCollection.cs index d97468dbb6278..d25ad8ddc759d 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SoftwareInventoryCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SoftwareInventoryCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SoftwareInventoryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheSoftwareInventoryOfTheVirtualMachine() + public async Task Get_GetsASingleSoftwareDataOfTheVirtualMachine() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/ListByExtendedResourceSoftwareInventories_example.json - // this example is just showing the usage of "SoftwareInventories_ListByExtendedResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/GetSoftware_example.json + // this example is just showing the usage of "SoftwareInventories_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_GetsTheSoftwareInventoryOfTheVirtualMachine() string resourceName = "Eitan-Test1"; SoftwareInventoryCollection collection = resourceGroupResource.GetSoftwareInventories(resourceNamespace, resourceType, resourceName); - // invoke the operation and iterate over the result - await foreach (SoftwareInventoryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SoftwareInventoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string softwareName = "outlook_16.0.10371.20060"; + SoftwareInventoryResource result = await collection.GetAsync(softwareName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SoftwareInventoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsASingleSoftwareDataOfTheVirtualMachine() + public async Task GetAll_GetsTheSoftwareInventoryOfTheVirtualMachine() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/GetSoftware_example.json - // this example is just showing the usage of "SoftwareInventories_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/ListByExtendedResourceSoftwareInventories_example.json + // this example is just showing the usage of "SoftwareInventories_ListByExtendedResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +77,17 @@ public async Task Get_GetsASingleSoftwareDataOfTheVirtualMachine() string resourceName = "Eitan-Test1"; SoftwareInventoryCollection collection = resourceGroupResource.GetSoftwareInventories(resourceNamespace, resourceType, resourceName); - // invoke the operation - string softwareName = "outlook_16.0.10371.20060"; - SoftwareInventoryResource result = await collection.GetAsync(softwareName); + // invoke the operation and iterate over the result + await foreach (SoftwareInventoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SoftwareInventoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SoftwareInventoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SoftwareInventoryResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SoftwareInventoryResource.cs index bf3bcca8af367..74d6e1cdec4fb 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SoftwareInventoryResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SoftwareInventoryResource.cs @@ -9,44 +9,12 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.SecurityCenter.Samples { public partial class Sample_SoftwareInventoryResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSoftwareInventories_GetsTheSoftwareInventoryOfAllVirtualMachinesInTheSubscriptions() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/ListBySubscriptionSoftwareInventories_example.json - // this example is just showing the usage of "SoftwareInventories_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "e5d1b86c-3051-44d5-8802-aa65d45a279b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SoftwareInventoryResource item in subscriptionResource.GetSoftwareInventoriesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SoftwareInventoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetsASingleSoftwareDataOfTheVirtualMachine() diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentBaselineRuleCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentBaselineRuleCollection.cs index 25660d96630cb..59c85bb174da3 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentBaselineRuleCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentBaselineRuleCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -29,30 +28,17 @@ public async Task CreateOrUpdate_CreateABaseline() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentBaselineRuleResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(scopeId); + SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(new ResourceIdentifier(resourceId)); // invoke the operation string ruleId = "VA1234"; Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent() + SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent { LatestScan = false, - Results = -{ -new string[] -{ -"userA","SELECT" -},new string[] -{ -"userB","SELECT" -} -}, + Results = { { "userA", "SELECT" }, { "userB", "SELECT" } }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, workspaceId, content); SqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; @@ -76,23 +62,17 @@ public async Task CreateOrUpdate_CreateABaselineUsingTheLatestScanResults() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentBaselineRuleResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(scopeId); + SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(new ResourceIdentifier(resourceId)); // invoke the operation string ruleId = "VA1234"; Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent() + SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent { LatestScan = true, - Results = -{ -}, + Results = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, workspaceId, content); SqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; @@ -116,13 +96,9 @@ public async Task Get_GetTheBaseline() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentBaselineRuleResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(scopeId); + SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(new ResourceIdentifier(resourceId)); // invoke the operation string ruleId = "VA1234"; @@ -138,95 +114,97 @@ public async Task Get_GetTheBaseline() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheBaseline() + public async Task GetAll_ListBaselineForAllRules() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Get.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_List.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentBaselineRuleResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(scopeId); + SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(new ResourceIdentifier(resourceId)); - // invoke the operation - string ruleId = "VA1234"; + // invoke the operation and iterate over the result Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - bool result = await collection.ExistsAsync(ruleId, workspaceId); + await foreach (SqlVulnerabilityAssessmentBaselineRuleResource item in collection.GetAllAsync(workspaceId)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheBaseline() + public async Task GetAll_CreateABaselineForAllRules() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Get.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Add.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Add" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentBaselineRuleResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(scopeId); + SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(new ResourceIdentifier(resourceId)); - // invoke the operation - string ruleId = "VA1234"; + // invoke the operation and iterate over the result Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - NullableResponse response = await collection.GetIfExistsAsync(ruleId, workspaceId); - SqlVulnerabilityAssessmentBaselineRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) + RulesResultsContent content = new RulesResultsContent { - Console.WriteLine("Succeeded with null as result"); - } - else + LatestScan = false, + Results = +{ +["VA1234"] = {{"userA", "SELECT"}, {"userB", "SELECT"}}, +["VA5678"] = {{"Test", "0.0.0.0", "125.125.125.125"}} +}, + }; + await foreach (SqlVulnerabilityAssessmentBaselineRuleResource item in collection.GetAllAsync(workspaceId, content: content)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; + SqlVulnerabilityAssessmentBaselineRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBaselineForAllRules() + public async Task GetAll_CreateABaselineForAllRulesUsingTheLatestScanResults() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_List.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_AddLatest.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Add" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentBaselineRuleResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(scopeId); + SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(new ResourceIdentifier(resourceId)); // invoke the operation and iterate over the result Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - await foreach (SqlVulnerabilityAssessmentBaselineRuleResource item in collection.GetAllAsync(workspaceId)) + RulesResultsContent content = new RulesResultsContent + { + LatestScan = true, + Results = { }, + }; + await foreach (SqlVulnerabilityAssessmentBaselineRuleResource item in collection.GetAllAsync(workspaceId, content: content)) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -240,101 +218,62 @@ public async Task GetAll_ListBaselineForAllRules() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CreateABaselineForAllRules() + public async Task Exists_GetTheBaseline() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Add.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Add" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Get.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentBaselineRuleResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(scopeId); + SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(new ResourceIdentifier(resourceId)); - // invoke the operation and iterate over the result + // invoke the operation + string ruleId = "VA1234"; Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - RulesResultsContent content = new RulesResultsContent() - { - LatestScan = false, - Results = -{ -["VA1234"] = new IList[] -{ -new string[] -{ -"userA","SELECT" -},new string[] -{ -"userB","SELECT" -} -}, -["VA5678"] = new IList[] -{ -new string[] -{ -"Test","0.0.0.0","125.125.125.125" -} -}, -}, - }; - await foreach (SqlVulnerabilityAssessmentBaselineRuleResource item in collection.GetAllAsync(workspaceId, content: content)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + bool result = await collection.ExistsAsync(ruleId, workspaceId); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CreateABaselineForAllRulesUsingTheLatestScanResults() + public async Task GetIfExists_GetTheBaseline() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_AddLatest.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Add" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Get.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentBaselineRuleResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(scopeId); + SqlVulnerabilityAssessmentBaselineRuleCollection collection = client.GetSqlVulnerabilityAssessmentBaselineRules(new ResourceIdentifier(resourceId)); - // invoke the operation and iterate over the result + // invoke the operation + string ruleId = "VA1234"; Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - RulesResultsContent content = new RulesResultsContent() + NullableResponse response = await collection.GetIfExistsAsync(ruleId, workspaceId); + SqlVulnerabilityAssessmentBaselineRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - LatestScan = true, - Results = -{ -}, - }; - await foreach (SqlVulnerabilityAssessmentBaselineRuleResource item in collection.GetAllAsync(workspaceId, content: content)) + Console.WriteLine("Succeeded with null as result"); + } + else { - // the variable item is a resource, you could call other operations on this instance as well + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = item.Data; + SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentBaselineRuleResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentBaselineRuleResource.cs index c8b89f34950d9..e168df89d833d 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentBaselineRuleResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentBaselineRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlVulnerabilityAssessmentBaselineRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateABaseline() + public async Task Get_GetTheBaseline() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Put.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Get.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,22 +37,7 @@ public async Task Update_CreateABaseline() // invoke the operation Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent() - { - LatestScan = false, - Results = -{ -new string[] -{ -"userA","SELECT" -},new string[] -{ -"userB","SELECT" -} -}, - }; - ArmOperation lro = await sqlVulnerabilityAssessmentBaselineRule.UpdateAsync(WaitUntil.Completed, workspaceId, content); - SqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; + SqlVulnerabilityAssessmentBaselineRuleResource result = await sqlVulnerabilityAssessmentBaselineRule.GetAsync(workspaceId); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -63,10 +48,10 @@ public async Task Update_CreateABaseline() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateABaselineUsingTheLatestScanResults() + public async Task Delete_DeleteTheBaseline() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_PutLatest.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Delete.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -82,29 +67,17 @@ public async Task Update_CreateABaselineUsingTheLatestScanResults() // invoke the operation Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent() - { - LatestScan = true, - Results = -{ -}, - }; - ArmOperation lro = await sqlVulnerabilityAssessmentBaselineRule.UpdateAsync(WaitUntil.Completed, workspaceId, content); - SqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; + await sqlVulnerabilityAssessmentBaselineRule.DeleteAsync(WaitUntil.Completed, workspaceId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheBaseline() + public async Task Update_CreateABaseline() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Get.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Put.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,7 +93,13 @@ public async Task Get_GetTheBaseline() // invoke the operation Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - SqlVulnerabilityAssessmentBaselineRuleResource result = await sqlVulnerabilityAssessmentBaselineRule.GetAsync(workspaceId); + SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent + { + LatestScan = false, + Results = { { "userA", "SELECT" }, { "userB", "SELECT" } }, + }; + ArmOperation lro = await sqlVulnerabilityAssessmentBaselineRule.UpdateAsync(WaitUntil.Completed, workspaceId, content); + SqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -131,10 +110,10 @@ public async Task Get_GetTheBaseline() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteTheBaseline() + public async Task Update_CreateABaselineUsingTheLatestScanResults() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_Delete.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentsBaselineRuleOperations/ArcMachineBaselineRules_PutLatest.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselineRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,9 +129,19 @@ public async Task Delete_DeleteTheBaseline() // invoke the operation Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - await sqlVulnerabilityAssessmentBaselineRule.DeleteAsync(WaitUntil.Completed, workspaceId); + SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent + { + LatestScan = true, + Results = { }, + }; + ArmOperation lro = await sqlVulnerabilityAssessmentBaselineRule.UpdateAsync(WaitUntil.Completed, workspaceId, content); + SqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentScanCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentScanCollection.cs index 3246607f7a103..b0e604582d25f 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentScanCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SqlVulnerabilityAssessmentScanCollection.cs @@ -27,13 +27,9 @@ public async Task Get_GetScanDetailsOfAScanRecord() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentScanResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(scopeId); + SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(new ResourceIdentifier(resourceId)); // invoke the operation string scanId = "Scheduled-20200623"; @@ -49,9 +45,9 @@ public async Task Get_GetScanDetailsOfAScanRecord() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetScanDetailsOfAScanRecord() + public async Task Get_GetScanDetailsOfTheLatestScanRecord() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_Get.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_GetLatest.json // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -59,67 +55,57 @@ public async Task Exists_GetScanDetailsOfAScanRecord() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentScanResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(scopeId); + SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(new ResourceIdentifier(resourceId)); // invoke the operation - string scanId = "Scheduled-20200623"; + string scanId = "latest"; Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - bool result = await collection.ExistsAsync(scanId, workspaceId); + SqlVulnerabilityAssessmentScanResource result = await collection.GetAsync(scanId, workspaceId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentScanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetScanDetailsOfAScanRecord() + public async Task GetAll_ListScanDetails() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_Get.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_List.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentScanResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(scopeId); + SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(new ResourceIdentifier(resourceId)); - // invoke the operation - string scanId = "Scheduled-20200623"; + // invoke the operation and iterate over the result Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - NullableResponse response = await collection.GetIfExistsAsync(scanId, workspaceId); - SqlVulnerabilityAssessmentScanResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + await foreach (SqlVulnerabilityAssessmentScanResource item in collection.GetAllAsync(workspaceId)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanData resourceData = result.Data; + SqlVulnerabilityAssessmentScanData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetScanDetailsOfTheLatestScanRecord() + public async Task Exists_GetScanDetailsOfAScanRecord() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_GetLatest.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_Get.json // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -127,24 +113,16 @@ public async Task Get_GetScanDetailsOfTheLatestScanRecord() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentScanResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(scopeId); + SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(new ResourceIdentifier(resourceId)); // invoke the operation - string scanId = "latest"; + string scanId = "Scheduled-20200623"; Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - SqlVulnerabilityAssessmentScanResource result = await collection.GetAsync(scanId, workspaceId); + bool result = await collection.ExistsAsync(scanId, workspaceId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -159,13 +137,9 @@ public async Task Exists_GetScanDetailsOfTheLatestScanRecord() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentScanResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(scopeId); + SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(new ResourceIdentifier(resourceId)); // invoke the operation string scanId = "latest"; @@ -177,9 +151,9 @@ public async Task Exists_GetScanDetailsOfTheLatestScanRecord() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetScanDetailsOfTheLatestScanRecord() + public async Task GetIfExists_GetScanDetailsOfAScanRecord() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_GetLatest.json + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_Get.json // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -187,16 +161,12 @@ public async Task GetIfExists_GetScanDetailsOfTheLatestScanRecord() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentScanResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(scopeId); + SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(new ResourceIdentifier(resourceId)); // invoke the operation - string scanId = "latest"; + string scanId = "Scheduled-20200623"; Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); NullableResponse response = await collection.GetIfExistsAsync(scanId, workspaceId); SqlVulnerabilityAssessmentScanResource result = response.HasValue ? response.Value : null; @@ -217,36 +187,38 @@ public async Task GetIfExists_GetScanDetailsOfTheLatestScanRecord() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListScanDetails() + public async Task GetIfExists_GetScanDetailsOfTheLatestScanRecord() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_List.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-02-01-preview/examples/sqlVulnerabilityAssessmentScanOperations/ArcMachineScans_GetLatest.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SqlVulnerabilityAssessmentScanResource string resourceId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Rg/providers/Microsoft.HybridCompute/machines/MyMachine/sqlServers/server1/databases/master"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceId)); - SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(scopeId); + SqlVulnerabilityAssessmentScanCollection collection = client.GetSqlVulnerabilityAssessmentScans(new ResourceIdentifier(resourceId)); - // invoke the operation and iterate over the result + // invoke the operation + string scanId = "latest"; Guid workspaceId = Guid.Parse("55555555-6666-7777-8888-999999999999"); - await foreach (SqlVulnerabilityAssessmentScanResource item in collection.GetAllAsync(workspaceId)) + NullableResponse response = await collection.GetIfExistsAsync(scanId, workspaceId); + SqlVulnerabilityAssessmentScanResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanData resourceData = item.Data; + SqlVulnerabilityAssessmentScanData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionAssessmentMetadataCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionAssessmentMetadataCollection.cs index fd259bb2220f9..92e7297172bb9 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionAssessmentMetadataCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionAssessmentMetadataCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SubscriptionAssessmentMetadataCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecurityAssessmentMetadataForSubscription() + public async Task CreateOrUpdate_CreateSecurityAssessmentMetadataForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/ListAssessmentsMetadata_subscription_example.json - // this example is just showing the usage of "AssessmentsMetadata_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/CreateAssessmentsMetadata_subscription_example.json + // this example is just showing the usage of "AssessmentsMetadata_CreateInSubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,28 @@ public async Task GetAll_ListSecurityAssessmentMetadataForSubscription() // get the collection of this SubscriptionAssessmentMetadataResource SubscriptionAssessmentMetadataCollection collection = subscriptionResource.GetAllSubscriptionAssessmentMetadata(); - // invoke the operation and iterate over the result - await foreach (SubscriptionAssessmentMetadataResource item in collection.GetAllAsync()) + // invoke the operation + string assessmentMetadataName = "ca039e75-a276-4175-aebc-bcd41e4b14b7"; + SecurityAssessmentMetadataData data = new SecurityAssessmentMetadataData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAssessmentMetadataData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "Install endpoint protection solution on virtual machine scale sets", + Description = "Install an endpoint protection solution on your virtual machines scale sets, to protect them from threats and vulnerabilities.", + RemediationDescription = "To install an endpoint protection solution: 1. Follow the instructions in How do I turn on antimalware in my virtual machine scale set", + Categories = { SecurityAssessmentResourceCategory.Compute }, + Severity = SecurityAssessmentSeverity.Medium, + UserImpact = SecurityAssessmentUserImpact.Low, + ImplementationEffort = ImplementationEffort.Low, + Threats = { SecurityThreat.DataExfiltration, SecurityThreat.DataSpillage, SecurityThreat.MaliciousInsider }, + AssessmentType = SecurityAssessmentType.CustomerManaged, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assessmentMetadataName, data); + SubscriptionAssessmentMetadataResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAssessmentMetadataData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -85,10 +96,10 @@ public async Task Get_GetSecurityAssessmentMetadataForSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSecurityAssessmentMetadataForSubscription() + public async Task GetAll_ListSecurityAssessmentMetadataForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/GetAssessmentsMetadata_subscription_example.json - // this example is just showing the usage of "AssessmentsMetadata_GetInSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/ListAssessmentsMetadata_subscription_example.json + // this example is just showing the usage of "AssessmentsMetadata_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,16 +115,22 @@ public async Task Exists_GetSecurityAssessmentMetadataForSubscription() // get the collection of this SubscriptionAssessmentMetadataResource SubscriptionAssessmentMetadataCollection collection = subscriptionResource.GetAllSubscriptionAssessmentMetadata(); - // invoke the operation - string assessmentMetadataName = "21300918-b2e3-0346-785f-c77ff57d243b"; - bool result = await collection.ExistsAsync(assessmentMetadataName); + // invoke the operation and iterate over the result + await foreach (SubscriptionAssessmentMetadataResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAssessmentMetadataData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSecurityAssessmentMetadataForSubscription() + public async Task Exists_GetSecurityAssessmentMetadataForSubscription() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/GetAssessmentsMetadata_subscription_example.json // this example is just showing the usage of "AssessmentsMetadata_GetInSubscription" operation, for the dependent resources, they will have to be created separately. @@ -134,29 +151,17 @@ public async Task GetIfExists_GetSecurityAssessmentMetadataForSubscription() // invoke the operation string assessmentMetadataName = "21300918-b2e3-0346-785f-c77ff57d243b"; - NullableResponse response = await collection.GetIfExistsAsync(assessmentMetadataName); - SubscriptionAssessmentMetadataResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(assessmentMetadataName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAssessmentMetadataData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSecurityAssessmentMetadataForSubscription() + public async Task GetIfExists_GetSecurityAssessmentMetadataForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/CreateAssessmentsMetadata_subscription_example.json - // this example is just showing the usage of "AssessmentsMetadata_CreateInSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/GetAssessmentsMetadata_subscription_example.json + // this example is just showing the usage of "AssessmentsMetadata_GetInSubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,33 +178,22 @@ public async Task CreateOrUpdate_CreateSecurityAssessmentMetadataForSubscription SubscriptionAssessmentMetadataCollection collection = subscriptionResource.GetAllSubscriptionAssessmentMetadata(); // invoke the operation - string assessmentMetadataName = "ca039e75-a276-4175-aebc-bcd41e4b14b7"; - SecurityAssessmentMetadataData data = new SecurityAssessmentMetadataData() - { - DisplayName = "Install endpoint protection solution on virtual machine scale sets", - Description = "Install an endpoint protection solution on your virtual machines scale sets, to protect them from threats and vulnerabilities.", - RemediationDescription = "To install an endpoint protection solution: 1. Follow the instructions in How do I turn on antimalware in my virtual machine scale set", - Categories = -{ -SecurityAssessmentResourceCategory.Compute -}, - Severity = SecurityAssessmentSeverity.Medium, - UserImpact = SecurityAssessmentUserImpact.Low, - ImplementationEffort = ImplementationEffort.Low, - Threats = -{ -SecurityThreat.DataExfiltration,SecurityThreat.DataSpillage,SecurityThreat.MaliciousInsider -}, - AssessmentType = SecurityAssessmentType.CustomerManaged, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assessmentMetadataName, data); - SubscriptionAssessmentMetadataResource result = lro.Value; + string assessmentMetadataName = "21300918-b2e3-0346-785f-c77ff57d243b"; + NullableResponse response = await collection.GetIfExistsAsync(assessmentMetadataName); + SubscriptionAssessmentMetadataResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAssessmentMetadataData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAssessmentMetadataData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionAssessmentMetadataResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionAssessmentMetadataResource.cs index 6abd15390bc03..2d1419e545dc8 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionAssessmentMetadataResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionAssessmentMetadataResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetSecurityAssessmentMetadataForSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateSecurityAssessmentMetadataForSubscription() + public async Task Delete_DeleteASecurityAssessmentMetadataForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/CreateAssessmentsMetadata_subscription_example.json - // this example is just showing the usage of "AssessmentsMetadata_CreateInSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/DeleteAssessmentsMetadata_subscription_example.json + // this example is just showing the usage of "AssessmentsMetadata_DeleteInSubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,40 +65,17 @@ public async Task Update_CreateSecurityAssessmentMetadataForSubscription() SubscriptionAssessmentMetadataResource subscriptionAssessmentMetadata = client.GetSubscriptionAssessmentMetadataResource(subscriptionAssessmentMetadataResourceId); // invoke the operation - SecurityAssessmentMetadataData data = new SecurityAssessmentMetadataData() - { - DisplayName = "Install endpoint protection solution on virtual machine scale sets", - Description = "Install an endpoint protection solution on your virtual machines scale sets, to protect them from threats and vulnerabilities.", - RemediationDescription = "To install an endpoint protection solution: 1. Follow the instructions in How do I turn on antimalware in my virtual machine scale set", - Categories = -{ -SecurityAssessmentResourceCategory.Compute -}, - Severity = SecurityAssessmentSeverity.Medium, - UserImpact = SecurityAssessmentUserImpact.Low, - ImplementationEffort = ImplementationEffort.Low, - Threats = -{ -SecurityThreat.DataExfiltration,SecurityThreat.DataSpillage,SecurityThreat.MaliciousInsider -}, - AssessmentType = SecurityAssessmentType.CustomerManaged, - }; - ArmOperation lro = await subscriptionAssessmentMetadata.UpdateAsync(WaitUntil.Completed, data); - SubscriptionAssessmentMetadataResource result = lro.Value; + await subscriptionAssessmentMetadata.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAssessmentMetadataData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASecurityAssessmentMetadataForSubscription() + public async Task Update_CreateSecurityAssessmentMetadataForSubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/DeleteAssessmentsMetadata_subscription_example.json - // this example is just showing the usage of "AssessmentsMetadata_DeleteInSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/CreateAssessmentsMetadata_subscription_example.json + // this example is just showing the usage of "AssessmentsMetadata_CreateInSubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,9 +90,26 @@ public async Task Delete_DeleteASecurityAssessmentMetadataForSubscription() SubscriptionAssessmentMetadataResource subscriptionAssessmentMetadata = client.GetSubscriptionAssessmentMetadataResource(subscriptionAssessmentMetadataResourceId); // invoke the operation - await subscriptionAssessmentMetadata.DeleteAsync(WaitUntil.Completed); + SecurityAssessmentMetadataData data = new SecurityAssessmentMetadataData + { + DisplayName = "Install endpoint protection solution on virtual machine scale sets", + Description = "Install an endpoint protection solution on your virtual machines scale sets, to protect them from threats and vulnerabilities.", + RemediationDescription = "To install an endpoint protection solution: 1. Follow the instructions in How do I turn on antimalware in my virtual machine scale set", + Categories = { SecurityAssessmentResourceCategory.Compute }, + Severity = SecurityAssessmentSeverity.Medium, + UserImpact = SecurityAssessmentUserImpact.Low, + ImplementationEffort = ImplementationEffort.Low, + Threats = { SecurityThreat.DataExfiltration, SecurityThreat.DataSpillage, SecurityThreat.MaliciousInsider }, + AssessmentType = SecurityAssessmentType.CustomerManaged, + }; + ArmOperation lro = await subscriptionAssessmentMetadata.UpdateAsync(WaitUntil.Completed, data); + SubscriptionAssessmentMetadataResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAssessmentMetadataData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index eeb2736df7559..d1cbc8cc810f2 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -45,6 +45,130 @@ public async Task GetTasks_GetSecurityRecommendationsTasks() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSecurityAutomations_ListAllSecurityAutomationsOfASpecifiedSubscription() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2019-01-01-preview/examples/Automations/GetAutomationsSubscription_example.json + // this example is just showing the usage of "Automations_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "a5caac9c-5c04-49af-b3d0-e204f40345d5"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SecurityAutomationResource item in subscriptionResource.GetSecurityAutomationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAutomationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSoftwareInventories_GetsTheSoftwareInventoryOfAllVirtualMachinesInTheSubscriptions() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-05-01-preview/examples/SoftwareInventories/ListBySubscriptionSoftwareInventories_example.json + // this example is just showing the usage of "SoftwareInventories_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "e5d1b86c-3051-44d5-8802-aa65d45a279b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SoftwareInventoryResource item in subscriptionResource.GetSoftwareInventoriesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SoftwareInventoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCustomAssessmentAutomations_ListCustomAssessmentAutomationsInASubscription() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomAssessmentAutomations/customAssessmentAutomationListBySubscription_example.json + // this example is just showing the usage of "CustomAssessmentAutomations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "e5d1b86c-3051-44d5-8802-aa65d45a279b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CustomAssessmentAutomationResource item in subscriptionResource.GetCustomAssessmentAutomationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomAssessmentAutomationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCustomEntityStoreAssignments_ListCustomEntityStoreAssignmentsInASubscription() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2021-07-01-preview/examples/CustomEntityStoreAssignments/customEntityStoreAssignmentListBySubscription_example.json + // this example is just showing the usage of "CustomEntityStoreAssignments_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "e5d1b86c-3051-44d5-8802-aa65d45a279b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CustomEntityStoreAssignmentResource item in subscriptionResource.GetCustomEntityStoreAssignmentsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomEntityStoreAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetMdeOnboardings_TheConfigurationOrDataNeededToOnboardTheMachineToMDE() @@ -96,6 +220,100 @@ public async Task GetMdeOnboarding_TheDefaultConfigurationOrDataNeededToOnboardT Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSecurityConnectors_ListAllSecurityConnectorsOfASpecifiedSubscription() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2023-10-01-preview/examples/SecurityConnectors/GetSecurityConnectorsSubscription_example.json + // this example is just showing the usage of "SecurityConnectors_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "a5caac9c-5c04-49af-b3d0-e204f40345d5"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SecurityConnectorResource item in subscriptionResource.GetSecurityConnectorsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityConnectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIotSecuritySolutions_ListIoTSecuritySolutionsByIoTHub() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsListByIotHub.json + // this example is just showing the usage of "IotSecuritySolution_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string filter = "properties.iotHubs/any(i eq \"/subscriptions/075423e9-7d33-4166-8bdf-3920b04e3735/resourceGroups/myRg/providers/Microsoft.Devices/IotHubs/FirstIotHub\")"; + await foreach (IotSecuritySolutionResource item in subscriptionResource.GetIotSecuritySolutionsAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotSecuritySolutionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIotSecuritySolutions_ListIoTSecuritySolutionsBySubscription() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2019-08-01/examples/IoTSecuritySolutions/GetIoTSecuritySolutionsList.json + // this example is just showing the usage of "IotSecuritySolution_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (IotSecuritySolutionResource item in subscriptionResource.GetIotSecuritySolutionsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IotSecuritySolutionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAllowedConnections_GetAllowedConnectionsOnASubscription() @@ -123,6 +341,39 @@ public async Task GetAllowedConnections_GetAllowedConnectionsOnASubscription() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAdaptiveApplicationControlGroups_GetsAListOfApplicationControlGroupsOfMachinesForTheSubscription() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/ApplicationWhitelistings/GetAdaptiveApplicationControlsSubscription_example.json + // this example is just showing the usage of "AdaptiveApplicationControls_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + bool? includePathRecommendations = true; + bool? summary = false; + await foreach (AdaptiveApplicationControlGroupResource item in subscriptionResource.GetAdaptiveApplicationControlGroupsAsync(includePathRecommendations: includePathRecommendations, summary: summary)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdaptiveApplicationControlGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetDiscoveredSecuritySolutions_GetDiscoveredSecuritySolutions() @@ -177,6 +428,37 @@ public async Task GetExternalSecuritySolutions_GetExternalSecuritySolutionsOnASu Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetJitNetworkAccessPolicies_GetJITNetworkAccessPoliciesOnASubscription() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2020-01-01/examples/JitNetworkAccessPolicies/GetJitNetworkAccessPoliciesSubscription_example.json + // this example is just showing the usage of "JitNetworkAccessPolicies_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (JitNetworkAccessPolicyResource item in subscriptionResource.GetJitNetworkAccessPoliciesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + JitNetworkAccessPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetSecureScoreControls_ListAllSecureScoresControls() @@ -339,5 +621,36 @@ public async Task GetAlerts_GetSecurityAlertsOnASubscription() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSecurityCenterApiCollections_GetsAListOfAPICollectionsWithinASubscriptionThatHaveBeenOnboardedToMicrosoftDefenderForAPIs() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2023-11-15/examples/ApiCollections/APICollections_ListBySubscription_example.json + // this example is just showing the usage of "APICollections_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "3fa85f64-5717-4562-b3fc-2c963f66afa6"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SecurityCenterApiCollectionResource item in subscriptionResource.GetSecurityCenterApiCollectionsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityCenterApiCollectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityAlertCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityAlertCollection.cs index 7e4f4eef92060..d363caec0aeea 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityAlertCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityAlertCollection.cs @@ -16,6 +16,39 @@ namespace Azure.ResourceManager.SecurityCenter.Samples { public partial class Sample_SubscriptionSecurityAlertCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetSecurityAlertOnASubscriptionFromASecurityDataLocation() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertSubscriptionLocation_example.json + // this example is just showing the usage of "Alerts_GetSubscriptionLevel" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SecurityCenterLocationResource created on azure + // for more information of creating SecurityCenterLocationResource, please refer to the document of SecurityCenterLocationResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + AzureLocation ascLocation = new AzureLocation("westeurope"); + ResourceIdentifier securityCenterLocationResourceId = SecurityCenterLocationResource.CreateResourceIdentifier(subscriptionId, ascLocation); + SecurityCenterLocationResource securityCenterLocation = client.GetSecurityCenterLocationResource(securityCenterLocationResourceId); + + // get the collection of this SubscriptionSecurityAlertResource + SubscriptionSecurityAlertCollection collection = securityCenterLocation.GetSubscriptionSecurityAlerts(); + + // invoke the operation + string alertName = "2518770965529163669_F144EE95-A3E5-42DA-A279-967D115809AA"; + SubscriptionSecurityAlertResource result = await collection.GetAsync(alertName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_GetSecurityAlertsOnASubscriptionFromASecurityDataLocation() @@ -53,10 +86,10 @@ public async Task GetAll_GetSecurityAlertsOnASubscriptionFromASecurityDataLocati [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityAlertOnASubscriptionFromASecurityDataLocation() + public async Task Simulate_SimulateSecurityAlertsOnASubscription() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/GetAlertSubscriptionLocation_example.json - // this example is just showing the usage of "Alerts_GetSubscriptionLevel" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/SimulateAlerts_example.json + // this example is just showing the usage of "Alerts_Simulate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,7 +99,7 @@ public async Task Get_GetSecurityAlertOnASubscriptionFromASecurityDataLocation() // this example assumes you already have this SecurityCenterLocationResource created on azure // for more information of creating SecurityCenterLocationResource, please refer to the document of SecurityCenterLocationResource string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - AzureLocation ascLocation = new AzureLocation("westeurope"); + AzureLocation ascLocation = new AzureLocation("centralus"); ResourceIdentifier securityCenterLocationResourceId = SecurityCenterLocationResource.CreateResourceIdentifier(subscriptionId, ascLocation); SecurityCenterLocationResource securityCenterLocation = client.GetSecurityCenterLocationResource(securityCenterLocationResourceId); @@ -74,14 +107,16 @@ public async Task Get_GetSecurityAlertOnASubscriptionFromASecurityDataLocation() SubscriptionSecurityAlertCollection collection = securityCenterLocation.GetSubscriptionSecurityAlerts(); // invoke the operation - string alertName = "2518770965529163669_F144EE95-A3E5-42DA-A279-967D115809AA"; - SubscriptionSecurityAlertResource result = await collection.GetAsync(alertName); + SecurityAlertSimulatorContent content = new SecurityAlertSimulatorContent + { + Properties = new SecurityAlertSimulatorBundlesRequestProperties + { + Bundles = { SecurityAlertSimulatorBundleType.AppServices, SecurityAlertSimulatorBundleType.Dns, SecurityAlertSimulatorBundleType.KeyVaults, SecurityAlertSimulatorBundleType.KubernetesService, SecurityAlertSimulatorBundleType.ResourceManager, SecurityAlertSimulatorBundleType.SqlServers, SecurityAlertSimulatorBundleType.StorageAccounts, SecurityAlertSimulatorBundleType.VirtualMachines, SecurityAlertSimulatorBundleType.CosmosDbs }, + }, + }; + await collection.SimulateAsync(WaitUntil.Completed, content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -153,43 +188,5 @@ public async Task GetIfExists_GetSecurityAlertOnASubscriptionFromASecurityDataLo Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Simulate_SimulateSecurityAlertsOnASubscription() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2022-01-01/examples/Alerts/SimulateAlerts_example.json - // this example is just showing the usage of "Alerts_Simulate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SecurityCenterLocationResource created on azure - // for more information of creating SecurityCenterLocationResource, please refer to the document of SecurityCenterLocationResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - AzureLocation ascLocation = new AzureLocation("centralus"); - ResourceIdentifier securityCenterLocationResourceId = SecurityCenterLocationResource.CreateResourceIdentifier(subscriptionId, ascLocation); - SecurityCenterLocationResource securityCenterLocation = client.GetSecurityCenterLocationResource(securityCenterLocationResourceId); - - // get the collection of this SubscriptionSecurityAlertResource - SubscriptionSecurityAlertCollection collection = securityCenterLocation.GetSubscriptionSecurityAlerts(); - - // invoke the operation - SecurityAlertSimulatorContent content = new SecurityAlertSimulatorContent() - { - Properties = new SecurityAlertSimulatorBundlesRequestProperties() - { - Bundles = -{ -SecurityAlertSimulatorBundleType.AppServices,SecurityAlertSimulatorBundleType.Dns,SecurityAlertSimulatorBundleType.KeyVaults,SecurityAlertSimulatorBundleType.KubernetesService,SecurityAlertSimulatorBundleType.ResourceManager,SecurityAlertSimulatorBundleType.SqlServers,SecurityAlertSimulatorBundleType.StorageAccounts,SecurityAlertSimulatorBundleType.VirtualMachines,SecurityAlertSimulatorBundleType.CosmosDbs -}, - }, - }; - await collection.SimulateAsync(WaitUntil.Completed, content); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityApplicationCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityApplicationCollection.cs index 8b295c0cf7274..7d53b2f08abce 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityApplicationCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityApplicationCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_SubscriptionSecurityApplicationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListApplicationsSecurityBySubscriptionLevelScope() + public async Task CreateOrUpdate_CreateApplication() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/ListBySubscriptionApplications_example.json - // this example is just showing the usage of "Applications_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/PutApplication_example.json + // this example is just showing the usage of "Application_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,34 @@ public async Task GetAll_ListApplicationsSecurityBySubscriptionLevelScope() // get the collection of this SubscriptionSecurityApplicationResource SubscriptionSecurityApplicationCollection collection = subscriptionResource.GetSubscriptionSecurityApplications(); - // invoke the operation and iterate over the result - await foreach (SubscriptionSecurityApplicationResource item in collection.GetAllAsync()) + // invoke the operation + string applicationId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; + SecurityApplicationData data = new SecurityApplicationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityApplicationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "Admin's application", + Description = "An application on critical recommendations", + SourceResourceType = ApplicationSourceResourceType.Assessments, + ConditionSets = {BinaryData.FromObjectAsJson(new +{ +conditions = new object[] +{ +new Dictionary +{ +["operator"] = "contains", +["property"] = "$.Id", +["value"] = "-bil-" +} +}, +})}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationId, data); + SubscriptionSecurityApplicationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +103,10 @@ public async Task Get_GetSecurityApplicationBySpecificApplicationId() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSecurityApplicationBySpecificApplicationId() + public async Task GetAll_ListApplicationsSecurityBySubscriptionLevelScope() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/GetApplication_example.json - // this example is just showing the usage of "Application_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/ListBySubscriptionApplications_example.json + // this example is just showing the usage of "Applications_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,16 +122,22 @@ public async Task Exists_GetSecurityApplicationBySpecificApplicationId() // get the collection of this SubscriptionSecurityApplicationResource SubscriptionSecurityApplicationCollection collection = subscriptionResource.GetSubscriptionSecurityApplications(); - // invoke the operation - string applicationId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - bool result = await collection.ExistsAsync(applicationId); + // invoke the operation and iterate over the result + await foreach (SubscriptionSecurityApplicationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityApplicationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSecurityApplicationBySpecificApplicationId() + public async Task Exists_GetSecurityApplicationBySpecificApplicationId() { // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/GetApplication_example.json // this example is just showing the usage of "Application_Get" operation, for the dependent resources, they will have to be created separately. @@ -135,29 +158,17 @@ public async Task GetIfExists_GetSecurityApplicationBySpecificApplicationId() // invoke the operation string applicationId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - NullableResponse response = await collection.GetIfExistsAsync(applicationId); - SubscriptionSecurityApplicationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(applicationId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateApplication() + public async Task GetIfExists_GetSecurityApplicationBySpecificApplicationId() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/PutApplication_example.json - // this example is just showing the usage of "Application_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/GetApplication_example.json + // this example is just showing the usage of "Application_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -175,30 +186,21 @@ public async Task CreateOrUpdate_CreateApplication() // invoke the operation string applicationId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - SecurityApplicationData data = new SecurityApplicationData() - { - DisplayName = "Admin's application", - Description = "An application on critical recommendations", - SourceResourceType = ApplicationSourceResourceType.Assessments, - ConditionSets = -{ -BinaryData.FromObjectAsJson(new Dictionary() -{ -["conditions"] = new object[] { new Dictionary() -{ -["operator"] = "contains", -["property"] = "$.Id", -["value"] = "-bil-"} }}) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationId, data); - SubscriptionSecurityApplicationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(applicationId); + SubscriptionSecurityApplicationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityApplicationResource.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityApplicationResource.cs index 661ccc3d53c94..ae8d3f2d8de6e 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityApplicationResource.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityApplicationResource.cs @@ -46,6 +46,31 @@ public async Task Get_GetSecurityApplicationBySpecificApplicationId() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteSecurityApplication() + { + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/DeleteApplication_example.json + // this example is just showing the usage of "Application_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionSecurityApplicationResource created on azure + // for more information of creating SubscriptionSecurityApplicationResource, please refer to the document of SubscriptionSecurityApplicationResource + string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; + string applicationId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; + ResourceIdentifier subscriptionSecurityApplicationResourceId = SubscriptionSecurityApplicationResource.CreateResourceIdentifier(subscriptionId, applicationId); + SubscriptionSecurityApplicationResource subscriptionSecurityApplication = client.GetSubscriptionSecurityApplicationResource(subscriptionSecurityApplicationResourceId); + + // invoke the operation + await subscriptionSecurityApplication.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateApplication() @@ -66,21 +91,23 @@ public async Task Update_CreateApplication() SubscriptionSecurityApplicationResource subscriptionSecurityApplication = client.GetSubscriptionSecurityApplicationResource(subscriptionSecurityApplicationResourceId); // invoke the operation - SecurityApplicationData data = new SecurityApplicationData() + SecurityApplicationData data = new SecurityApplicationData { DisplayName = "Admin's application", Description = "An application on critical recommendations", SourceResourceType = ApplicationSourceResourceType.Assessments, - ConditionSets = + ConditionSets = {BinaryData.FromObjectAsJson(new { -BinaryData.FromObjectAsJson(new Dictionary() +conditions = new object[] { -["conditions"] = new object[] { new Dictionary() +new Dictionary { ["operator"] = "contains", ["property"] = "$.Id", -["value"] = "-bil-"} }}) +["value"] = "-bil-" +} }, +})}, }; ArmOperation lro = await subscriptionSecurityApplication.UpdateAsync(WaitUntil.Completed, data); SubscriptionSecurityApplicationResource result = lro.Value; @@ -91,30 +118,5 @@ public async Task Update_CreateApplication() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSecurityApplication() - { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2022-07-01-preview/examples/Applications/DeleteApplication_example.json - // this example is just showing the usage of "Application_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionSecurityApplicationResource created on azure - // for more information of creating SubscriptionSecurityApplicationResource, please refer to the document of SubscriptionSecurityApplicationResource - string subscriptionId = "20ff7fc3-e762-44dd-bd96-b71116dcdc23"; - string applicationId = "ad9a8e26-29d9-4829-bb30-e597a58cdbb8"; - ResourceIdentifier subscriptionSecurityApplicationResourceId = SubscriptionSecurityApplicationResource.CreateResourceIdentifier(subscriptionId, applicationId); - SubscriptionSecurityApplicationResource subscriptionSecurityApplication = client.GetSubscriptionSecurityApplicationResource(subscriptionSecurityApplicationResourceId); - - // invoke the operation - await subscriptionSecurityApplication.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityTaskCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityTaskCollection.cs index bf85ac6465541..b9c4fbf4a612c 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityTaskCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_SubscriptionSecurityTaskCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SubscriptionSecurityTaskCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSecurityRecommendationsTasksFromSecurityDataLocation() + public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTasksSubscriptionLocation_example.json - // this example is just showing the usage of "Tasks_ListByHomeRegion" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTaskSubscriptionLocation_example.json + // this example is just showing the usage of "Tasks_GetSubscriptionLevelTask" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_GetSecurityRecommendationsTasksFromSecurityDataLocation // get the collection of this SubscriptionSecurityTaskResource SubscriptionSecurityTaskCollection collection = securityCenterLocation.GetSubscriptionSecurityTasks(); - // invoke the operation and iterate over the result - await foreach (SubscriptionSecurityTaskResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityTaskData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string taskName = "62609ee7-d0a5-8616-9fe4-1df5cca7758d"; + SubscriptionSecurityTaskResource result = await collection.GetAsync(taskName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityTaskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocation() + public async Task GetAll_GetSecurityRecommendationsTasksFromSecurityDataLocation() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTaskSubscriptionLocation_example.json - // this example is just showing the usage of "Tasks_GetSubscriptionLevelTask" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/preview/2015-06-01-preview/examples/Tasks/GetTasksSubscriptionLocation_example.json + // this example is just showing the usage of "Tasks_ListByHomeRegion" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +70,17 @@ public async Task Get_GetSecurityRecommendationTaskFromSecurityDataLocation() // get the collection of this SubscriptionSecurityTaskResource SubscriptionSecurityTaskCollection collection = securityCenterLocation.GetSubscriptionSecurityTasks(); - // invoke the operation - string taskName = "62609ee7-d0a5-8616-9fe4-1df5cca7758d"; - SubscriptionSecurityTaskResource result = await collection.GetAsync(taskName); + // invoke the operation and iterate over the result + await foreach (SubscriptionSecurityTaskResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityTaskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityTaskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_TenantAssessmentMetadataCollection.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_TenantAssessmentMetadataCollection.cs index f5586f5fe0df6..f5ab842908adf 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_TenantAssessmentMetadataCollection.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_TenantAssessmentMetadataCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.SecurityCenter.Samples @@ -17,64 +18,60 @@ public partial class Sample_TenantAssessmentMetadataCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecurityAssessmentMetadata() + public async Task Get_GetSecurityAssessmentMetadata() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/ListAssessmentsMetadata_example.json - // this example is just showing the usage of "AssessmentsMetadata_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/GetAssessmentsMetadata_example.json + // this example is just showing the usage of "AssessmentsMetadata_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantAssessmentMetadataResource TenantAssessmentMetadataCollection collection = tenantResource.GetAllTenantAssessmentMetadata(); - // invoke the operation and iterate over the result - await foreach (TenantAssessmentMetadataResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAssessmentMetadataData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string assessmentMetadataName = "21300918-b2e3-0346-785f-c77ff57d243b"; + TenantAssessmentMetadataResource result = await collection.GetAsync(assessmentMetadataName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAssessmentMetadataData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityAssessmentMetadata() + public async Task GetAll_ListSecurityAssessmentMetadata() { - // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/GetAssessmentsMetadata_example.json - // this example is just showing the usage of "AssessmentsMetadata_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/security/resource-manager/Microsoft.Security/stable/2021-06-01/examples/AssessmentsMetadata/ListAssessmentsMetadata_example.json + // this example is just showing the usage of "AssessmentsMetadata_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantAssessmentMetadataResource TenantAssessmentMetadataCollection collection = tenantResource.GetAllTenantAssessmentMetadata(); - // invoke the operation - string assessmentMetadataName = "21300918-b2e3-0346-785f-c77ff57d243b"; - TenantAssessmentMetadataResource result = await collection.GetAsync(assessmentMetadataName); + // invoke the operation and iterate over the result + await foreach (TenantAssessmentMetadataResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAssessmentMetadataData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAssessmentMetadataData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -89,9 +86,7 @@ public async Task Exists_GetSecurityAssessmentMetadata() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantAssessmentMetadataResource TenantAssessmentMetadataCollection collection = tenantResource.GetAllTenantAssessmentMetadata(); @@ -115,9 +110,7 @@ public async Task GetIfExists_GetSecurityAssessmentMetadata() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantAssessmentMetadataResource TenantAssessmentMetadataCollection collection = tenantResource.GetAllTenantAssessmentMetadata(); diff --git a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index dcff43b7bedce..e5de8457f8450 100644 --- a/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/securitycenter/Azure.ResourceManager.SecurityCenter/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using Azure.ResourceManager.SecurityCenter.Models; using NUnit.Framework; @@ -28,9 +29,7 @@ public async Task GetSecureScoreControlDefinitions_ListSecurityControlsDefinitio // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (SecureScoreControlDefinitionItem item in tenantResource.GetSecureScoreControlDefinitionsAsync()) diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsConnectorCollection.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsConnectorCollection.cs index dcf57308e99a7..6055ab5c784ea 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsConnectorCollection.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsConnectorCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AzureDevOpsConnectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AzureDevOpsConnectorListByResourceGroup() + public async Task CreateOrUpdate_AzureDevOpsConnectorCreateOrUpdate() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorListByResourceGroup.json - // this example is just showing the usage of "AzureDevOpsConnector_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorCreateOrUpdate.json + // this example is just showing the usage of "AzureDevOpsConnector_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,32 @@ public async Task GetAll_AzureDevOpsConnectorListByResourceGroup() // get the collection of this AzureDevOpsConnectorResource AzureDevOpsConnectorCollection collection = resourceGroupResource.GetAzureDevOpsConnectors(); - // invoke the operation and iterate over the result - await foreach (AzureDevOpsConnectorResource item in collection.GetAllAsync()) + // invoke the operation + string azureDevOpsConnectorName = "testconnector"; + AzureDevOpsConnectorData data = new AzureDevOpsConnectorData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsConnectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AzureDevOpsConnectorProperties + { + AuthorizationCode = "00000000000000000000", + Orgs = {new AzureDevOpsOrgMetadata +{ +Name = "testOrg", +Projects = {new AzureDevOpsProjectMetadata +{ +Name = "testProject", +Repos = {"testRepo"}, +}}, +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureDevOpsConnectorName, data); + AzureDevOpsConnectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +102,10 @@ public async Task Get_AzureDevOpsConnectorGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AzureDevOpsConnectorGet() + public async Task GetAll_AzureDevOpsConnectorListByResourceGroup() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorGet.json - // this example is just showing the usage of "AzureDevOpsConnector_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorListByResourceGroup.json + // this example is just showing the usage of "AzureDevOpsConnector_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +122,22 @@ public async Task Exists_AzureDevOpsConnectorGet() // get the collection of this AzureDevOpsConnectorResource AzureDevOpsConnectorCollection collection = resourceGroupResource.GetAzureDevOpsConnectors(); - // invoke the operation - string azureDevOpsConnectorName = "testconnector"; - bool result = await collection.ExistsAsync(azureDevOpsConnectorName); + // invoke the operation and iterate over the result + await foreach (AzureDevOpsConnectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsConnectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AzureDevOpsConnectorGet() + public async Task Exists_AzureDevOpsConnectorGet() { // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorGet.json // this example is just showing the usage of "AzureDevOpsConnector_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +159,17 @@ public async Task GetIfExists_AzureDevOpsConnectorGet() // invoke the operation string azureDevOpsConnectorName = "testconnector"; - NullableResponse response = await collection.GetIfExistsAsync(azureDevOpsConnectorName); - AzureDevOpsConnectorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(azureDevOpsConnectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AzureDevOpsConnectorCreateOrUpdate() + public async Task GetIfExists_AzureDevOpsConnectorGet() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorCreateOrUpdate.json - // this example is just showing the usage of "AzureDevOpsConnector_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorGet.json + // this example is just showing the usage of "AzureDevOpsConnector_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,39 +188,21 @@ public async Task CreateOrUpdate_AzureDevOpsConnectorCreateOrUpdate() // invoke the operation string azureDevOpsConnectorName = "testconnector"; - AzureDevOpsConnectorData data = new AzureDevOpsConnectorData(new AzureLocation("West US")) - { - Properties = new AzureDevOpsConnectorProperties() - { - AuthorizationCode = "00000000000000000000", - Orgs = -{ -new AzureDevOpsOrgMetadata() -{ -Name = "testOrg", -Projects = -{ -new AzureDevOpsProjectMetadata() -{ -Name = "testProject", -Repos = -{ -"testRepo" -}, -} -}, -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureDevOpsConnectorName, data); - AzureDevOpsConnectorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(azureDevOpsConnectorName); + AzureDevOpsConnectorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsConnectorResource.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsConnectorResource.cs index 724f69006318b..7b05db07be39b 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsConnectorResource.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsConnectorResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SecurityDevOps.Models; using NUnit.Framework; @@ -49,10 +48,10 @@ public async Task Get_AzureDevOpsConnectorGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AzureDevOpsConnectorUpdate() + public async Task Delete_AzureDevOpsConnectorDelete() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorUpdate.json - // this example is just showing the usage of "AzureDevOpsConnector_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorDelete.json + // this example is just showing the usage of "AzureDevOpsConnector_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,30 +67,17 @@ public async Task Update_AzureDevOpsConnectorUpdate() AzureDevOpsConnectorResource azureDevOpsConnector = client.GetAzureDevOpsConnectorResource(azureDevOpsConnectorResourceId); // invoke the operation - AzureDevOpsConnectorData data = new AzureDevOpsConnectorData(new AzureLocation("West US")) - { - Tags = -{ -["client"] = "dev-client", -["env"] = "dev", -}, - }; - ArmOperation lro = await azureDevOpsConnector.UpdateAsync(WaitUntil.Completed, data); - AzureDevOpsConnectorResource result = lro.Value; + await azureDevOpsConnector.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AzureDevOpsConnectorDelete() + public async Task Update_AzureDevOpsConnectorUpdate() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorDelete.json - // this example is just showing the usage of "AzureDevOpsConnector_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorUpdate.json + // this example is just showing the usage of "AzureDevOpsConnector_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,40 +93,22 @@ public async Task Delete_AzureDevOpsConnectorDelete() AzureDevOpsConnectorResource azureDevOpsConnector = client.GetAzureDevOpsConnectorResource(azureDevOpsConnectorResourceId); // invoke the operation - await azureDevOpsConnector.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAzureDevOpsConnectors_AzureDevOpsConnectorListBySubscription() - { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorListBySubscription.json - // this example is just showing the usage of "AzureDevOpsConnector_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AzureDevOpsConnectorResource item in subscriptionResource.GetAzureDevOpsConnectorsAsync()) + AzureDevOpsConnectorData data = new AzureDevOpsConnectorData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsConnectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["client"] = "dev-client", +["env"] = "dev" +}, + }; + ArmOperation lro = await azureDevOpsConnector.UpdateAsync(WaitUntil.Completed, data); + AzureDevOpsConnectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsOrgCollection.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsOrgCollection.cs index 58766f45fcb4e..edf768f456a73 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsOrgCollection.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsOrgCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AzureDevOpsOrgCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AzureDevOpsOrgList() + public async Task CreateOrUpdate_AzureDevOpsOrgCreateOrUpdate() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsOrgList.json - // this example is just showing the usage of "AzureDevOpsOrg_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsOrgCreateOrUpdate.json + // this example is just showing the usage of "AzureDevOpsOrg_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_AzureDevOpsOrgList() // get the collection of this AzureDevOpsOrgResource AzureDevOpsOrgCollection collection = azureDevOpsConnector.GetAzureDevOpsOrgs(); - // invoke the operation and iterate over the result - await foreach (AzureDevOpsOrgResource item in collection.GetAllAsync()) + // invoke the operation + string azureDevOpsOrgName = "myOrg"; + AzureDevOpsOrgData data = new AzureDevOpsOrgData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsOrgData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AzureDevOpsOrgProperties + { + AutoDiscovery = AutoDiscovery.Disabled, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureDevOpsOrgName, data); + AzureDevOpsOrgResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsOrgData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +94,10 @@ public async Task Get_AzureDevOpsOrgGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AzureDevOpsOrgGet() + public async Task GetAll_AzureDevOpsOrgList() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsOrgGet.json - // this example is just showing the usage of "AzureDevOpsOrg_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsOrgList.json + // this example is just showing the usage of "AzureDevOpsOrg_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +115,22 @@ public async Task Exists_AzureDevOpsOrgGet() // get the collection of this AzureDevOpsOrgResource AzureDevOpsOrgCollection collection = azureDevOpsConnector.GetAzureDevOpsOrgs(); - // invoke the operation - string azureDevOpsOrgName = "myOrg"; - bool result = await collection.ExistsAsync(azureDevOpsOrgName); + // invoke the operation and iterate over the result + await foreach (AzureDevOpsOrgResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsOrgData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AzureDevOpsOrgGet() + public async Task Exists_AzureDevOpsOrgGet() { // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsOrgGet.json // this example is just showing the usage of "AzureDevOpsOrg_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +153,17 @@ public async Task GetIfExists_AzureDevOpsOrgGet() // invoke the operation string azureDevOpsOrgName = "myOrg"; - NullableResponse response = await collection.GetIfExistsAsync(azureDevOpsOrgName); - AzureDevOpsOrgResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(azureDevOpsOrgName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsOrgData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AzureDevOpsOrgCreateOrUpdate() + public async Task GetIfExists_AzureDevOpsOrgGet() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsOrgCreateOrUpdate.json - // this example is just showing the usage of "AzureDevOpsOrg_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsOrgGet.json + // this example is just showing the usage of "AzureDevOpsOrg_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,21 +183,21 @@ public async Task CreateOrUpdate_AzureDevOpsOrgCreateOrUpdate() // invoke the operation string azureDevOpsOrgName = "myOrg"; - AzureDevOpsOrgData data = new AzureDevOpsOrgData() - { - Properties = new AzureDevOpsOrgProperties() - { - AutoDiscovery = AutoDiscovery.Disabled, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureDevOpsOrgName, data); - AzureDevOpsOrgResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(azureDevOpsOrgName); + AzureDevOpsOrgResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsOrgData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsOrgData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsOrgResource.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsOrgResource.cs index 2394df84934b6..6c6b7236e3ce1 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsOrgResource.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsOrgResource.cs @@ -69,9 +69,9 @@ public async Task Update_AzureDevOpsOrgUpdate() AzureDevOpsOrgResource azureDevOpsOrg = client.GetAzureDevOpsOrgResource(azureDevOpsOrgResourceId); // invoke the operation - AzureDevOpsOrgData data = new AzureDevOpsOrgData() + AzureDevOpsOrgData data = new AzureDevOpsOrgData { - Properties = new AzureDevOpsOrgProperties() + Properties = new AzureDevOpsOrgProperties { AutoDiscovery = AutoDiscovery.Disabled, }, diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsProjectCollection.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsProjectCollection.cs index 874b8d044c167..c019815e65022 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsProjectCollection.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsProjectCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AzureDevOpsProjectCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AzureDevOpsProjectList() + public async Task CreateOrUpdate_AzureDevOpsProjectCreateOrUpdate() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsProjectList.json - // this example is just showing the usage of "AzureDevOpsProject_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsProjectCreateOrUpdate.json + // this example is just showing the usage of "AzureDevOpsProject_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,23 @@ public async Task GetAll_AzureDevOpsProjectList() // get the collection of this AzureDevOpsProjectResource AzureDevOpsProjectCollection collection = azureDevOpsOrg.GetAzureDevOpsProjects(); - // invoke the operation and iterate over the result - await foreach (AzureDevOpsProjectResource item in collection.GetAllAsync()) + // invoke the operation + string azureDevOpsProjectName = "myProject"; + AzureDevOpsProjectData data = new AzureDevOpsProjectData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsProjectData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AzureDevOpsProjectProperties + { + AutoDiscovery = AutoDiscovery.Disabled, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureDevOpsProjectName, data); + AzureDevOpsProjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsProjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +96,10 @@ public async Task Get_AzureDevOpsProjectGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AzureDevOpsProjectGet() + public async Task GetAll_AzureDevOpsProjectList() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsProjectGet.json - // this example is just showing the usage of "AzureDevOpsProject_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsProjectList.json + // this example is just showing the usage of "AzureDevOpsProject_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +118,22 @@ public async Task Exists_AzureDevOpsProjectGet() // get the collection of this AzureDevOpsProjectResource AzureDevOpsProjectCollection collection = azureDevOpsOrg.GetAzureDevOpsProjects(); - // invoke the operation - string azureDevOpsProjectName = "myProject"; - bool result = await collection.ExistsAsync(azureDevOpsProjectName); + // invoke the operation and iterate over the result + await foreach (AzureDevOpsProjectResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsProjectData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AzureDevOpsProjectGet() + public async Task Exists_AzureDevOpsProjectGet() { // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsProjectGet.json // this example is just showing the usage of "AzureDevOpsProject_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +157,17 @@ public async Task GetIfExists_AzureDevOpsProjectGet() // invoke the operation string azureDevOpsProjectName = "myProject"; - NullableResponse response = await collection.GetIfExistsAsync(azureDevOpsProjectName); - AzureDevOpsProjectResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(azureDevOpsProjectName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsProjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AzureDevOpsProjectCreateOrUpdate() + public async Task GetIfExists_AzureDevOpsProjectGet() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsProjectCreateOrUpdate.json - // this example is just showing the usage of "AzureDevOpsProject_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsProjectGet.json + // this example is just showing the usage of "AzureDevOpsProject_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,21 +188,21 @@ public async Task CreateOrUpdate_AzureDevOpsProjectCreateOrUpdate() // invoke the operation string azureDevOpsProjectName = "myProject"; - AzureDevOpsProjectData data = new AzureDevOpsProjectData() - { - Properties = new AzureDevOpsProjectProperties() - { - AutoDiscovery = AutoDiscovery.Disabled, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureDevOpsProjectName, data); - AzureDevOpsProjectResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(azureDevOpsProjectName); + AzureDevOpsProjectResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsProjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsProjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsProjectResource.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsProjectResource.cs index 7cfd4c5a6a098..0b3398e6df02a 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsProjectResource.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsProjectResource.cs @@ -71,9 +71,9 @@ public async Task Update_AzureDevOpsProjectUpdate() AzureDevOpsProjectResource azureDevOpsProject = client.GetAzureDevOpsProjectResource(azureDevOpsProjectResourceId); // invoke the operation - AzureDevOpsProjectData data = new AzureDevOpsProjectData() + AzureDevOpsProjectData data = new AzureDevOpsProjectData { - Properties = new AzureDevOpsProjectProperties() + Properties = new AzureDevOpsProjectProperties { AutoDiscovery = AutoDiscovery.Disabled, }, diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsRepoCollection.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsRepoCollection.cs index e88bc6b4479a9..2a57bb5f3315e 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsRepoCollection.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_AzureDevOpsRepoCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AzureDevOpsRepoCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AzureDevOpsRepoList() + public async Task CreateOrUpdate_AzureDevOpsRepoCreateOrUpdate() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsRepoList.json - // this example is just showing the usage of "AzureDevOpsRepo_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsRepoCreateOrUpdate.json + // this example is just showing the usage of "AzureDevOpsRepo_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,31 @@ public async Task GetAll_AzureDevOpsRepoList() // get the collection of this AzureDevOpsRepoResource AzureDevOpsRepoCollection collection = azureDevOpsProject.GetAzureDevOpsRepos(); - // invoke the operation and iterate over the result - await foreach (AzureDevOpsRepoResource item in collection.GetAllAsync()) + // invoke the operation + string azureDevOpsRepoName = "myRepo"; + AzureDevOpsRepoData data = new AzureDevOpsRepoData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsRepoData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AzureDevOpsRepoProperties + { + RepoId = "00000000-0000-0000-0000-000000000000", + RepoUri = new Uri("https://dev.azure.com/myOrg/myProject/_git/myRepo"), + ActionableRemediation = new ActionableRemediation + { + State = ActionableRemediationState.Enabled, + SeverityLevels = { "High" }, + Categories = { ActionableRemediationRuleCategory.Secrets }, + BranchNames = { "main" }, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureDevOpsRepoName, data); + AzureDevOpsRepoResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsRepoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +106,10 @@ public async Task Get_AzureDevOpsRepoGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AzureDevOpsRepoGet() + public async Task GetAll_AzureDevOpsRepoList() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsRepoGet.json - // this example is just showing the usage of "AzureDevOpsRepo_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsRepoList.json + // this example is just showing the usage of "AzureDevOpsRepo_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +129,22 @@ public async Task Exists_AzureDevOpsRepoGet() // get the collection of this AzureDevOpsRepoResource AzureDevOpsRepoCollection collection = azureDevOpsProject.GetAzureDevOpsRepos(); - // invoke the operation - string azureDevOpsRepoName = "myRepo"; - bool result = await collection.ExistsAsync(azureDevOpsRepoName); + // invoke the operation and iterate over the result + await foreach (AzureDevOpsRepoResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsRepoData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AzureDevOpsRepoGet() + public async Task Exists_AzureDevOpsRepoGet() { // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsRepoGet.json // this example is just showing the usage of "AzureDevOpsRepo_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +169,17 @@ public async Task GetIfExists_AzureDevOpsRepoGet() // invoke the operation string azureDevOpsRepoName = "myRepo"; - NullableResponse response = await collection.GetIfExistsAsync(azureDevOpsRepoName); - AzureDevOpsRepoResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(azureDevOpsRepoName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsRepoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AzureDevOpsRepoCreateOrUpdate() + public async Task GetIfExists_AzureDevOpsRepoGet() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsRepoCreateOrUpdate.json - // this example is just showing the usage of "AzureDevOpsRepo_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsRepoGet.json + // this example is just showing the usage of "AzureDevOpsRepo_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,38 +201,21 @@ public async Task CreateOrUpdate_AzureDevOpsRepoCreateOrUpdate() // invoke the operation string azureDevOpsRepoName = "myRepo"; - AzureDevOpsRepoData data = new AzureDevOpsRepoData() - { - Properties = new AzureDevOpsRepoProperties() - { - RepoId = "00000000-0000-0000-0000-000000000000", - RepoUri = new Uri("https://dev.azure.com/myOrg/myProject/_git/myRepo"), - ActionableRemediation = new ActionableRemediation() - { - State = ActionableRemediationState.Enabled, - SeverityLevels = -{ -"High" -}, - Categories = -{ -ActionableRemediationRuleCategory.Secrets -}, - BranchNames = -{ -"main" -}, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureDevOpsRepoName, data); - AzureDevOpsRepoResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(azureDevOpsRepoName); + AzureDevOpsRepoResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureDevOpsRepoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsRepoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubConnectorCollection.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubConnectorCollection.cs index abdfc165a2f20..1dd61b1bdd37a 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubConnectorCollection.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubConnectorCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_GitHubConnectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GitHubConnectorListByResourceGroup() + public async Task CreateOrUpdate_GitHubConnectorCreateOrUpdate() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorListByResourceGroup.json - // this example is just showing the usage of "GitHubConnector_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorCreateOrUpdate.json + // this example is just showing the usage of "GitHubConnector_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_GitHubConnectorListByResourceGroup() // get the collection of this GitHubConnectorResource GitHubConnectorCollection collection = resourceGroupResource.GetGitHubConnectors(); - // invoke the operation and iterate over the result - await foreach (GitHubConnectorResource item in collection.GetAllAsync()) + // invoke the operation + string gitHubConnectorName = "testconnector"; + GitHubConnectorData data = new GitHubConnectorData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubConnectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new GitHubConnectorProperties + { + Code = "00000000000000000000", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gitHubConnectorName, data); + GitHubConnectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +93,10 @@ public async Task Get_GitHubConnectorGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GitHubConnectorGet() + public async Task GetAll_GitHubConnectorListByResourceGroup() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorGet.json - // this example is just showing the usage of "GitHubConnector_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorListByResourceGroup.json + // this example is just showing the usage of "GitHubConnector_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +113,22 @@ public async Task Exists_GitHubConnectorGet() // get the collection of this GitHubConnectorResource GitHubConnectorCollection collection = resourceGroupResource.GetGitHubConnectors(); - // invoke the operation - string gitHubConnectorName = "testconnector"; - bool result = await collection.ExistsAsync(gitHubConnectorName); + // invoke the operation and iterate over the result + await foreach (GitHubConnectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubConnectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GitHubConnectorGet() + public async Task Exists_GitHubConnectorGet() { // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorGet.json // this example is just showing the usage of "GitHubConnector_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +150,17 @@ public async Task GetIfExists_GitHubConnectorGet() // invoke the operation string gitHubConnectorName = "testconnector"; - NullableResponse response = await collection.GetIfExistsAsync(gitHubConnectorName); - GitHubConnectorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(gitHubConnectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GitHubConnectorCreateOrUpdate() + public async Task GetIfExists_GitHubConnectorGet() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorCreateOrUpdate.json - // this example is just showing the usage of "GitHubConnector_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorGet.json + // this example is just showing the usage of "GitHubConnector_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,21 +179,21 @@ public async Task CreateOrUpdate_GitHubConnectorCreateOrUpdate() // invoke the operation string gitHubConnectorName = "testconnector"; - GitHubConnectorData data = new GitHubConnectorData(new AzureLocation("West US")) - { - Properties = new GitHubConnectorProperties() - { - Code = "00000000000000000000", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gitHubConnectorName, data); - GitHubConnectorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(gitHubConnectorName); + GitHubConnectorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubConnectorResource.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubConnectorResource.cs index ac09eb1536f25..16f74a4db80b8 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubConnectorResource.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubConnectorResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SecurityDevOps.Models; using NUnit.Framework; @@ -49,10 +48,10 @@ public async Task Get_GitHubConnectorGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GitHubConnectorUpdate() + public async Task Delete_GitHubConnectorDelete() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorUpdate.json - // this example is just showing the usage of "GitHubConnector_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorDelete.json + // this example is just showing the usage of "GitHubConnector_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,30 +67,17 @@ public async Task Update_GitHubConnectorUpdate() GitHubConnectorResource gitHubConnector = client.GetGitHubConnectorResource(gitHubConnectorResourceId); // invoke the operation - GitHubConnectorData data = new GitHubConnectorData(new AzureLocation("West US")) - { - Tags = -{ -["client"] = "dev-client", -["env"] = "dev", -}, - }; - ArmOperation lro = await gitHubConnector.UpdateAsync(WaitUntil.Completed, data); - GitHubConnectorResource result = lro.Value; + await gitHubConnector.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubConnectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_GitHubConnectorDelete() + public async Task Update_GitHubConnectorUpdate() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorDelete.json - // this example is just showing the usage of "GitHubConnector_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorUpdate.json + // this example is just showing the usage of "GitHubConnector_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,40 +93,22 @@ public async Task Delete_GitHubConnectorDelete() GitHubConnectorResource gitHubConnector = client.GetGitHubConnectorResource(gitHubConnectorResourceId); // invoke the operation - await gitHubConnector.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetGitHubConnectors_GitHubConnectorListBySubscription() - { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorListBySubscription.json - // this example is just showing the usage of "GitHubConnector_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (GitHubConnectorResource item in subscriptionResource.GetGitHubConnectorsAsync()) + GitHubConnectorData data = new GitHubConnectorData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubConnectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["client"] = "dev-client", +["env"] = "dev" +}, + }; + ArmOperation lro = await gitHubConnector.UpdateAsync(WaitUntil.Completed, data); + GitHubConnectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubConnectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubOwnerCollection.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubOwnerCollection.cs index 0e0d6b4bdfa2c..5eb3e7719d8ef 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubOwnerCollection.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubOwnerCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_GitHubOwnerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GitHubOwnerList() + public async Task CreateOrUpdate_GitHubOwnerCreateOrUpdate() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubOwnerList.json - // this example is just showing the usage of "GitHubOwner_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubOwnerCreateOrUpdate.json + // this example is just showing the usage of "GitHubOwner_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_GitHubOwnerList() // get the collection of this GitHubOwnerResource GitHubOwnerCollection collection = gitHubConnector.GetGitHubOwners(); - // invoke the operation and iterate over the result - await foreach (GitHubOwnerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubOwnerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string gitHubOwnerName = "Azure"; + GitHubOwnerData data = new GitHubOwnerData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gitHubOwnerName, data); + GitHubOwnerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubOwnerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_GitHubOwnerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GitHubOwnerGet() + public async Task GetAll_GitHubOwnerList() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubOwnerGet.json - // this example is just showing the usage of "GitHubOwner_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubOwnerList.json + // this example is just showing the usage of "GitHubOwner_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_GitHubOwnerGet() // get the collection of this GitHubOwnerResource GitHubOwnerCollection collection = gitHubConnector.GetGitHubOwners(); - // invoke the operation - string gitHubOwnerName = "Azure"; - bool result = await collection.ExistsAsync(gitHubOwnerName); + // invoke the operation and iterate over the result + await foreach (GitHubOwnerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubOwnerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GitHubOwnerGet() + public async Task Exists_GitHubOwnerGet() { // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubOwnerGet.json // this example is just showing the usage of "GitHubOwner_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_GitHubOwnerGet() // invoke the operation string gitHubOwnerName = "Azure"; - NullableResponse response = await collection.GetIfExistsAsync(gitHubOwnerName); - GitHubOwnerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(gitHubOwnerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubOwnerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GitHubOwnerCreateOrUpdate() + public async Task GetIfExists_GitHubOwnerGet() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubOwnerCreateOrUpdate.json - // this example is just showing the usage of "GitHubOwner_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubOwnerGet.json + // this example is just showing the usage of "GitHubOwner_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_GitHubOwnerCreateOrUpdate() // invoke the operation string gitHubOwnerName = "Azure"; - GitHubOwnerData data = new GitHubOwnerData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gitHubOwnerName, data); - GitHubOwnerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(gitHubOwnerName); + GitHubOwnerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubOwnerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubOwnerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubRepoCollection.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubRepoCollection.cs index 86aaca2a7842e..fb9169a268b61 100644 --- a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubRepoCollection.cs +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_GitHubRepoCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_GitHubRepoCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GitHubRepoList() + public async Task CreateOrUpdate_GitHubRepoCreateOrUpdate() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubRepoList.json - // this example is just showing the usage of "GitHubRepo_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubRepoCreateOrUpdate.json + // this example is just showing the usage of "GitHubRepo_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,17 @@ public async Task GetAll_GitHubRepoList() // get the collection of this GitHubRepoResource GitHubRepoCollection collection = gitHubOwner.GetGitHubRepos(); - // invoke the operation and iterate over the result - await foreach (GitHubRepoResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubRepoData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string gitHubRepoName = "azure-rest-api-specs"; + GitHubRepoData data = new GitHubRepoData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gitHubRepoName, data); + GitHubRepoResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubRepoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +89,10 @@ public async Task Get_GitHubRepoGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GitHubRepoGet() + public async Task GetAll_GitHubRepoList() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubRepoGet.json - // this example is just showing the usage of "GitHubRepo_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubRepoList.json + // this example is just showing the usage of "GitHubRepo_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +111,22 @@ public async Task Exists_GitHubRepoGet() // get the collection of this GitHubRepoResource GitHubRepoCollection collection = gitHubOwner.GetGitHubRepos(); - // invoke the operation - string gitHubRepoName = "39093389"; - bool result = await collection.ExistsAsync(gitHubRepoName); + // invoke the operation and iterate over the result + await foreach (GitHubRepoResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubRepoData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GitHubRepoGet() + public async Task Exists_GitHubRepoGet() { // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubRepoGet.json // this example is just showing the usage of "GitHubRepo_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_GitHubRepoGet() // invoke the operation string gitHubRepoName = "39093389"; - NullableResponse response = await collection.GetIfExistsAsync(gitHubRepoName); - GitHubRepoResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(gitHubRepoName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubRepoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GitHubRepoCreateOrUpdate() + public async Task GetIfExists_GitHubRepoGet() { - // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubRepoCreateOrUpdate.json - // this example is just showing the usage of "GitHubRepo_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubRepoGet.json + // this example is just showing the usage of "GitHubRepo_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,16 +180,22 @@ public async Task CreateOrUpdate_GitHubRepoCreateOrUpdate() GitHubRepoCollection collection = gitHubOwner.GetGitHubRepos(); // invoke the operation - string gitHubRepoName = "azure-rest-api-specs"; - GitHubRepoData data = new GitHubRepoData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gitHubRepoName, data); - GitHubRepoResource result = lro.Value; + string gitHubRepoName = "39093389"; + NullableResponse response = await collection.GetIfExistsAsync(gitHubRepoName); + GitHubRepoResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GitHubRepoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubRepoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..546256e03fda1 --- /dev/null +++ b/sdk/securitydevops/Azure.ResourceManager.SecurityDevOps/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.SecurityDevOps.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAzureDevOpsConnectors_AzureDevOpsConnectorListBySubscription() + { + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/AzureDevOpsConnectorListBySubscription.json + // this example is just showing the usage of "AzureDevOpsConnector_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AzureDevOpsConnectorResource item in subscriptionResource.GetAzureDevOpsConnectorsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureDevOpsConnectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetGitHubConnectors_GitHubConnectorListBySubscription() + { + // Generated from example definition: specification/securitydevops/resource-manager/Microsoft.SecurityDevOps/preview/2022-09-01-preview/examples/GitHubConnectorListBySubscription.json + // this example is just showing the usage of "GitHubConnector_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (GitHubConnectorResource item in subscriptionResource.GetGitHubConnectorsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GitHubConnectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_ArmClientExtensions.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_ArmClientExtensions.cs new file mode 100644 index 0000000000000..0cfa734d9863b --- /dev/null +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_ArmClientExtensions.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.SelfHelp.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.SelfHelp.Samples +{ + public partial class Sample_ArmClientExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckSelfHelpNameAvailability_ExampleWhenNameIsAvailableForADiagnosticResource() + { + // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/CheckNameAvailabilityForDiagnosticWhenNameIsAvailable.json + // this example is just showing the usage of "CheckNameAvailability_CheckAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation + ResourceIdentifier scope = new ResourceIdentifier("subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6"); + SelfHelpNameAvailabilityContent content = new SelfHelpNameAvailabilityContent + { + ResourceName = "sampleName", + ResourceType = new ResourceType("Microsoft.Help/diagnostics"), + }; + SelfHelpNameAvailabilityResult result = await client.CheckSelfHelpNameAvailabilityAsync(scope, content: content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckSelfHelpNameAvailability_ExampleWhenNameIsNotAvailableForADiagnosticResource() + { + // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/CheckNameAvailabilityForDiagnosticWhenNameIsNotAvailable.json + // this example is just showing the usage of "CheckNameAvailability_CheckAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation + ResourceIdentifier scope = new ResourceIdentifier("subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6"); + SelfHelpNameAvailabilityContent content = new SelfHelpNameAvailabilityContent + { + ResourceName = "sampleName", + ResourceType = new ResourceType("Microsoft.Help/diagnostics"), + }; + SelfHelpNameAvailabilityResult result = await client.CheckSelfHelpNameAvailabilityAsync(scope, content: content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpDiagnosticCollection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpDiagnosticCollection.cs index 6c58aeb02e33b..a279ae225c922 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpDiagnosticCollection.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpDiagnosticCollection.cs @@ -27,13 +27,9 @@ public async Task CreateOrUpdate_CreatesADiagnosticForAKeyVaultResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpDiagnosticResource string scope = "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourceGroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpDiagnosticCollection collection = client.GetSelfHelpDiagnostics(scopeId); + SelfHelpDiagnosticCollection collection = client.GetSelfHelpDiagnostics(new ResourceIdentifier(scope)); // invoke the operation string diagnosticsResourceName = "VMNotWorkingInsight"; @@ -60,13 +56,9 @@ public async Task Get_GetsADiagnosticForAKeyVaultResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpDiagnosticResource string scope = "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourceGroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpDiagnosticCollection collection = client.GetSelfHelpDiagnostics(scopeId); + SelfHelpDiagnosticCollection collection = client.GetSelfHelpDiagnostics(new ResourceIdentifier(scope)); // invoke the operation string diagnosticsResourceName = "VMNotWorkingInsight"; @@ -91,13 +83,9 @@ public async Task Exists_GetsADiagnosticForAKeyVaultResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpDiagnosticResource string scope = "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourceGroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpDiagnosticCollection collection = client.GetSelfHelpDiagnostics(scopeId); + SelfHelpDiagnosticCollection collection = client.GetSelfHelpDiagnostics(new ResourceIdentifier(scope)); // invoke the operation string diagnosticsResourceName = "VMNotWorkingInsight"; @@ -118,13 +106,9 @@ public async Task GetIfExists_GetsADiagnosticForAKeyVaultResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpDiagnosticResource string scope = "subscriptions/0d0fcd2e-c4fd-4349-8497-200edb3923c6/resourceGroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-non-read"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpDiagnosticCollection collection = client.GetSelfHelpDiagnostics(scopeId); + SelfHelpDiagnosticCollection collection = client.GetSelfHelpDiagnostics(new ResourceIdentifier(scope)); // invoke the operation string diagnosticsResourceName = "VMNotWorkingInsight"; diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpDiagnosticResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpDiagnosticResource.cs index 7176e86b8cc5f..ff8f186792712 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpDiagnosticResource.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpDiagnosticResource.cs @@ -17,10 +17,10 @@ public partial class Sample_SelfHelpDiagnosticResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesADiagnosticForAKeyVaultResource() + public async Task Get_GetsADiagnosticForAKeyVaultResource() { - // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/CreateDiagnosticForKeyVaultResource.json - // this example is just showing the usage of "Diagnostics_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/GetDiagnosticForKeyVaultResource.json + // this example is just showing the usage of "Diagnostics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,9 +35,7 @@ public async Task Update_CreatesADiagnosticForAKeyVaultResource() SelfHelpDiagnosticResource selfHelpDiagnostic = client.GetSelfHelpDiagnosticResource(selfHelpDiagnosticResourceId); // invoke the operation - SelfHelpDiagnosticData data = new SelfHelpDiagnosticData(); - ArmOperation lro = await selfHelpDiagnostic.UpdateAsync(WaitUntil.Completed, data); - SelfHelpDiagnosticResource result = lro.Value; + SelfHelpDiagnosticResource result = await selfHelpDiagnostic.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -48,10 +46,10 @@ public async Task Update_CreatesADiagnosticForAKeyVaultResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADiagnosticForAKeyVaultResource() + public async Task Update_CreatesADiagnosticForAKeyVaultResource() { - // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/GetDiagnosticForKeyVaultResource.json - // this example is just showing the usage of "Diagnostics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/CreateDiagnosticForKeyVaultResource.json + // this example is just showing the usage of "Diagnostics_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,7 +64,9 @@ public async Task Get_GetsADiagnosticForAKeyVaultResource() SelfHelpDiagnosticResource selfHelpDiagnostic = client.GetSelfHelpDiagnosticResource(selfHelpDiagnosticResourceId); // invoke the operation - SelfHelpDiagnosticResource result = await selfHelpDiagnostic.GetAsync(); + SelfHelpDiagnosticData data = new SelfHelpDiagnosticData(); + ArmOperation lro = await selfHelpDiagnostic.UpdateAsync(WaitUntil.Completed, data); + SelfHelpDiagnosticResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSimplifiedSolutionCollection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSimplifiedSolutionCollection.cs index 042d9452678b5..d76a78ef1c9f3 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSimplifiedSolutionCollection.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSimplifiedSolutionCollection.cs @@ -27,22 +27,18 @@ public async Task CreateOrUpdate_SolutionCreate() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpSimplifiedSolutionResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpSimplifiedSolutionCollection collection = client.GetSelfHelpSimplifiedSolutions(scopeId); + SelfHelpSimplifiedSolutionCollection collection = client.GetSelfHelpSimplifiedSolutions(new ResourceIdentifier(scope)); // invoke the operation string simplifiedSolutionsResourceName = "simplifiedSolutionsResourceName1"; - SelfHelpSimplifiedSolutionData data = new SelfHelpSimplifiedSolutionData() + SelfHelpSimplifiedSolutionData data = new SelfHelpSimplifiedSolutionData { SolutionId = "sampleSolutionId", Parameters = { -["resourceUri"] = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp", +["resourceUri"] = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, simplifiedSolutionsResourceName, data); @@ -67,13 +63,9 @@ public async Task Get_SolutionGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpSimplifiedSolutionResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpSimplifiedSolutionCollection collection = client.GetSelfHelpSimplifiedSolutions(scopeId); + SelfHelpSimplifiedSolutionCollection collection = client.GetSelfHelpSimplifiedSolutions(new ResourceIdentifier(scope)); // invoke the operation string simplifiedSolutionsResourceName = "simplifiedSolutionsResourceName1"; @@ -98,13 +90,9 @@ public async Task Exists_SolutionGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpSimplifiedSolutionResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpSimplifiedSolutionCollection collection = client.GetSelfHelpSimplifiedSolutions(scopeId); + SelfHelpSimplifiedSolutionCollection collection = client.GetSelfHelpSimplifiedSolutions(new ResourceIdentifier(scope)); // invoke the operation string simplifiedSolutionsResourceName = "simplifiedSolutionsResourceName1"; @@ -125,13 +113,9 @@ public async Task GetIfExists_SolutionGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpSimplifiedSolutionResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpSimplifiedSolutionCollection collection = client.GetSelfHelpSimplifiedSolutions(scopeId); + SelfHelpSimplifiedSolutionCollection collection = client.GetSelfHelpSimplifiedSolutions(new ResourceIdentifier(scope)); // invoke the operation string simplifiedSolutionsResourceName = "simplifiedSolutionsResourceName1"; diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSimplifiedSolutionResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSimplifiedSolutionResource.cs index 642b36cd98465..712104a3cb989 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSimplifiedSolutionResource.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSimplifiedSolutionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_SelfHelpSimplifiedSolutionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SolutionCreate() + public async Task Get_SolutionGet() { - // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/SimplifiedSolutions_Create.json - // this example is just showing the usage of "SimplifiedSolutions_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/SimplifiedSolutions_Get.json + // this example is just showing the usage of "SimplifiedSolutions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,16 +35,7 @@ public async Task Update_SolutionCreate() SelfHelpSimplifiedSolutionResource selfHelpSimplifiedSolution = client.GetSelfHelpSimplifiedSolutionResource(selfHelpSimplifiedSolutionResourceId); // invoke the operation - SelfHelpSimplifiedSolutionData data = new SelfHelpSimplifiedSolutionData() - { - SolutionId = "sampleSolutionId", - Parameters = -{ -["resourceUri"] = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp", -}, - }; - ArmOperation lro = await selfHelpSimplifiedSolution.UpdateAsync(WaitUntil.Completed, data); - SelfHelpSimplifiedSolutionResource result = lro.Value; + SelfHelpSimplifiedSolutionResource result = await selfHelpSimplifiedSolution.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +46,10 @@ public async Task Update_SolutionCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SolutionGet() + public async Task Update_SolutionCreate() { - // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/SimplifiedSolutions_Get.json - // this example is just showing the usage of "SimplifiedSolutions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/SimplifiedSolutions_Create.json + // this example is just showing the usage of "SimplifiedSolutions_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,7 +64,16 @@ public async Task Get_SolutionGet() SelfHelpSimplifiedSolutionResource selfHelpSimplifiedSolution = client.GetSelfHelpSimplifiedSolutionResource(selfHelpSimplifiedSolutionResourceId); // invoke the operation - SelfHelpSimplifiedSolutionResource result = await selfHelpSimplifiedSolution.GetAsync(); + SelfHelpSimplifiedSolutionData data = new SelfHelpSimplifiedSolutionData + { + SolutionId = "sampleSolutionId", + Parameters = +{ +["resourceUri"] = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp" +}, + }; + ArmOperation lro = await selfHelpSimplifiedSolution.UpdateAsync(WaitUntil.Completed, data); + SelfHelpSimplifiedSolutionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSolutionCollection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSolutionCollection.cs index 72a20497abed3..4ef529b798f09 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSolutionCollection.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpSolutionCollection.cs @@ -28,29 +28,22 @@ public async Task CreateOrUpdate_SolutionCreate() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpSolutionResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpSolutionCollection collection = client.GetSelfHelpSolutions(scopeId); + SelfHelpSolutionCollection collection = client.GetSelfHelpSolutions(new ResourceIdentifier(scope)); // invoke the operation string solutionResourceName = "SolutionResourceName1"; - SelfHelpSolutionData data = new SelfHelpSolutionData() + SelfHelpSolutionData data = new SelfHelpSolutionData { - TriggerCriteria = -{ -new SolutionTriggerCriterion() + TriggerCriteria = {new SolutionTriggerCriterion { Name = SelfHelpName.SolutionId, Value = "SolutionId1", -} -}, +}}, Parameters = { -["resourceUri"] = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp", +["resourceUri"] = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, solutionResourceName, data); @@ -75,13 +68,9 @@ public async Task Get_SolutionGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpSolutionResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpSolutionCollection collection = client.GetSelfHelpSolutions(scopeId); + SelfHelpSolutionCollection collection = client.GetSelfHelpSolutions(new ResourceIdentifier(scope)); // invoke the operation string solutionResourceName = "SolutionResource1"; @@ -106,13 +95,9 @@ public async Task Exists_SolutionGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpSolutionResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpSolutionCollection collection = client.GetSelfHelpSolutions(scopeId); + SelfHelpSolutionCollection collection = client.GetSelfHelpSolutions(new ResourceIdentifier(scope)); // invoke the operation string solutionResourceName = "SolutionResource1"; @@ -133,13 +118,9 @@ public async Task GetIfExists_SolutionGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpSolutionResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpSolutionCollection collection = client.GetSelfHelpSolutions(scopeId); + SelfHelpSolutionCollection collection = client.GetSelfHelpSolutions(new ResourceIdentifier(scope)); // invoke the operation string solutionResourceName = "SolutionResource1"; diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpTroubleshooterCollection.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpTroubleshooterCollection.cs index 0e3a77462bae5..f78f338f7dd79 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpTroubleshooterCollection.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpTroubleshooterCollection.cs @@ -27,22 +27,18 @@ public async Task CreateOrUpdate_TroubleshootersCreate() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpTroubleshooterResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpTroubleshooterCollection collection = client.GetSelfHelpTroubleshooters(scopeId); + SelfHelpTroubleshooterCollection collection = client.GetSelfHelpTroubleshooters(new ResourceIdentifier(scope)); // invoke the operation string troubleshooterName = "abf168ed-1b54-454a-86f6-e4b62253d3b1"; - SelfHelpTroubleshooterData data = new SelfHelpTroubleshooterData() + SelfHelpTroubleshooterData data = new SelfHelpTroubleshooterData { SolutionId = "SampleTroubleshooterSolutionId", Parameters = { -["ResourceURI"] = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp", +["ResourceURI"] = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, troubleshooterName, data); @@ -67,13 +63,9 @@ public async Task Get_TroubleshootersGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpTroubleshooterResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpTroubleshooterCollection collection = client.GetSelfHelpTroubleshooters(scopeId); + SelfHelpTroubleshooterCollection collection = client.GetSelfHelpTroubleshooters(new ResourceIdentifier(scope)); // invoke the operation string troubleshooterName = "abf168ed-1b54-454a-86f6-e4b62253d3b1"; @@ -98,13 +90,9 @@ public async Task Exists_TroubleshootersGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpTroubleshooterResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpTroubleshooterCollection collection = client.GetSelfHelpTroubleshooters(scopeId); + SelfHelpTroubleshooterCollection collection = client.GetSelfHelpTroubleshooters(new ResourceIdentifier(scope)); // invoke the operation string troubleshooterName = "abf168ed-1b54-454a-86f6-e4b62253d3b1"; @@ -125,13 +113,9 @@ public async Task GetIfExists_TroubleshootersGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this SelfHelpTroubleshooterResource string scope = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - SelfHelpTroubleshooterCollection collection = client.GetSelfHelpTroubleshooters(scopeId); + SelfHelpTroubleshooterCollection collection = client.GetSelfHelpTroubleshooters(new ResourceIdentifier(scope)); // invoke the operation string troubleshooterName = "abf168ed-1b54-454a-86f6-e4b62253d3b1"; diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpTroubleshooterResource.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpTroubleshooterResource.cs index d59759a3e34c1..87181977fb090 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpTroubleshooterResource.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_SelfHelpTroubleshooterResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SelfHelpTroubleshooterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TroubleshootersCreate() + public async Task Get_TroubleshootersGet() { - // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/Troubleshooter_Create.json - // this example is just showing the usage of "Troubleshooters_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/Troubleshooter_Get.json + // this example is just showing the usage of "Troubleshooters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,16 +36,7 @@ public async Task Update_TroubleshootersCreate() SelfHelpTroubleshooterResource selfHelpTroubleshooter = client.GetSelfHelpTroubleshooterResource(selfHelpTroubleshooterResourceId); // invoke the operation - SelfHelpTroubleshooterData data = new SelfHelpTroubleshooterData() - { - SolutionId = "SampleTroubleshooterSolutionId", - Parameters = -{ -["ResourceURI"] = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp", -}, - }; - ArmOperation lro = await selfHelpTroubleshooter.UpdateAsync(WaitUntil.Completed, data); - SelfHelpTroubleshooterResource result = lro.Value; + SelfHelpTroubleshooterResource result = await selfHelpTroubleshooter.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -56,10 +47,10 @@ public async Task Update_TroubleshootersCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TroubleshootersGet() + public async Task Update_TroubleshootersCreate() { - // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/Troubleshooter_Get.json - // this example is just showing the usage of "Troubleshooters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/help/resource-manager/Microsoft.Help/preview/2024-03-01-preview/examples/Troubleshooter_Create.json + // this example is just showing the usage of "Troubleshooters_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,7 +65,16 @@ public async Task Get_TroubleshootersGet() SelfHelpTroubleshooterResource selfHelpTroubleshooter = client.GetSelfHelpTroubleshooterResource(selfHelpTroubleshooterResourceId); // invoke the operation - SelfHelpTroubleshooterResource result = await selfHelpTroubleshooter.GetAsync(); + SelfHelpTroubleshooterData data = new SelfHelpTroubleshooterData + { + SolutionId = "SampleTroubleshooterSolutionId", + Parameters = +{ +["ResourceURI"] = "subscriptions/mySubscription/resourcegroups/myresourceGroup/providers/Microsoft.KeyVault/vaults/test-keyvault-rp" +}, + }; + ArmOperation lro = await selfHelpTroubleshooter.UpdateAsync(WaitUntil.Completed, data); + SelfHelpTroubleshooterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -103,18 +103,15 @@ public async Task Continue_TroubleshooterContinue() SelfHelpTroubleshooterResource selfHelpTroubleshooter = client.GetSelfHelpTroubleshooterResource(selfHelpTroubleshooterResourceId); // invoke the operation - TroubleshooterContinueContent content = new TroubleshooterContinueContent() + TroubleshooterContinueContent content = new TroubleshooterContinueContent { StepId = "SampleStepId", - Responses = -{ -new TroubleshooterResult() + Responses = {new TroubleshooterResult { QuestionId = "SampleQuestionId", QuestionType = new TroubleshooterQuestionType("Text"), Response = "Connection exception", -} -}, +}}, }; await selfHelpTroubleshooter.ContinueAsync(content: content); diff --git a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index ac3a01c8b01f0..8564000d14d2e 100644 --- a/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/selfhelp/Azure.ResourceManager.SelfHelp/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using Azure.ResourceManager.SelfHelp.Models; using NUnit.Framework; @@ -28,9 +29,7 @@ public async Task DiscoverSolutions_ListDiscoverySolutionsAtResourceScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result string filter = "ProblemClassificationId eq 'SampleProblemClassificationId1'"; @@ -54,9 +53,7 @@ public async Task GetSelfHelpSolutionById_SolutionGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string solutionId = "SolutionId1"; @@ -77,9 +74,7 @@ public async Task DiscoverSolutionsNlp_DiscoverySolutionsUsingIssueSummaryAndSer // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result DiscoveryNlpContent content = new DiscoveryNlpContent("how to retrieve certs from deleted keyvault.") diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_MigrationConfigurationCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_MigrationConfigurationCollection.cs index f00588ae0a6c8..9e4f41eb6ea28 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_MigrationConfigurationCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_MigrationConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MigrationConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MigrationConfigurationsList() + public async Task CreateOrUpdate_MigrationConfigurationsStartMigration() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Migrationconfigurations/SBMigrationconfigurationList.json - // this example is just showing the usage of "MigrationConfigs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Migrationconfigurations/SBMigrationconfigurationCreateAndStartMigration.json + // this example is just showing the usage of "MigrationConfigs_CreateAndStartMigration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,32 +32,36 @@ public async Task GetAll_MigrationConfigurationsList() // for more information of creating ServiceBusNamespaceResource, please refer to the document of ServiceBusNamespaceResource string subscriptionId = "SubscriptionId"; string resourceGroupName = "ResourceGroup"; - string namespaceName = "sdk-Namespace-9259"; + string namespaceName = "sdk-Namespace-41"; ResourceIdentifier serviceBusNamespaceResourceId = ServiceBusNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); ServiceBusNamespaceResource serviceBusNamespace = client.GetServiceBusNamespaceResource(serviceBusNamespaceResourceId); // get the collection of this MigrationConfigurationResource MigrationConfigurationCollection collection = serviceBusNamespace.GetMigrationConfigurations(); - // invoke the operation and iterate over the result - await foreach (MigrationConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + MigrationConfigurationName configName = MigrationConfigurationName.Default; + MigrationConfigurationData data = new MigrationConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MigrationConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TargetServiceBusNamespace = new ResourceIdentifier("/subscriptions/SubscriptionId/resourceGroups/ResourceGroup/providers/Microsoft.ServiceBus/namespaces/sdk-Namespace-4028"), + PostMigrationName = "sdk-PostMigration-5919", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configName, data); + MigrationConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MigrationConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_MigrationConfigurationsStartMigration() + public async Task Get_MigrationConfigurationsGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Migrationconfigurations/SBMigrationconfigurationCreateAndStartMigration.json - // this example is just showing the usage of "MigrationConfigs_CreateAndStartMigration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Migrationconfigurations/SBMigrationconfigurationGet.json + // this example is just showing the usage of "MigrationConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,13 +81,7 @@ public async Task CreateOrUpdate_MigrationConfigurationsStartMigration() // invoke the operation MigrationConfigurationName configName = MigrationConfigurationName.Default; - MigrationConfigurationData data = new MigrationConfigurationData() - { - TargetServiceBusNamespace = new ResourceIdentifier("/subscriptions/SubscriptionId/resourceGroups/ResourceGroup/providers/Microsoft.ServiceBus/namespaces/sdk-Namespace-4028"), - PostMigrationName = "sdk-PostMigration-5919", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configName, data); - MigrationConfigurationResource result = lro.Value; + MigrationConfigurationResource result = await collection.GetAsync(configName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -94,10 +92,10 @@ public async Task CreateOrUpdate_MigrationConfigurationsStartMigration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MigrationConfigurationsGet() + public async Task GetAll_MigrationConfigurationsList() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Migrationconfigurations/SBMigrationconfigurationGet.json - // this example is just showing the usage of "MigrationConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Migrationconfigurations/SBMigrationconfigurationList.json + // this example is just showing the usage of "MigrationConfigs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,22 +106,24 @@ public async Task Get_MigrationConfigurationsGet() // for more information of creating ServiceBusNamespaceResource, please refer to the document of ServiceBusNamespaceResource string subscriptionId = "SubscriptionId"; string resourceGroupName = "ResourceGroup"; - string namespaceName = "sdk-Namespace-41"; + string namespaceName = "sdk-Namespace-9259"; ResourceIdentifier serviceBusNamespaceResourceId = ServiceBusNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); ServiceBusNamespaceResource serviceBusNamespace = client.GetServiceBusNamespaceResource(serviceBusNamespaceResourceId); // get the collection of this MigrationConfigurationResource MigrationConfigurationCollection collection = serviceBusNamespace.GetMigrationConfigurations(); - // invoke the operation - MigrationConfigurationName configName = MigrationConfigurationName.Default; - MigrationConfigurationResource result = await collection.GetAsync(configName); + // invoke the operation and iterate over the result + await foreach (MigrationConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MigrationConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MigrationConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_MigrationConfigurationResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_MigrationConfigurationResource.cs index 667755157ad20..be8c0528c04bf 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_MigrationConfigurationResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_MigrationConfigurationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MigrationConfigurationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MigrationConfigurationsStartMigration() + public async Task Get_MigrationConfigurationsGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Migrationconfigurations/SBMigrationconfigurationCreateAndStartMigration.json - // this example is just showing the usage of "MigrationConfigs_CreateAndStartMigration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Migrationconfigurations/SBMigrationconfigurationGet.json + // this example is just showing the usage of "MigrationConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,13 +38,7 @@ public async Task Update_MigrationConfigurationsStartMigration() MigrationConfigurationResource migrationConfiguration = client.GetMigrationConfigurationResource(migrationConfigurationResourceId); // invoke the operation - MigrationConfigurationData data = new MigrationConfigurationData() - { - TargetServiceBusNamespace = new ResourceIdentifier("/subscriptions/SubscriptionId/resourceGroups/ResourceGroup/providers/Microsoft.ServiceBus/namespaces/sdk-Namespace-4028"), - PostMigrationName = "sdk-PostMigration-5919", - }; - ArmOperation lro = await migrationConfiguration.UpdateAsync(WaitUntil.Completed, data); - MigrationConfigurationResource result = lro.Value; + MigrationConfigurationResource result = await migrationConfiguration.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -82,10 +76,10 @@ public async Task Delete_MigrationConfigurationsDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MigrationConfigurationsGet() + public async Task Update_MigrationConfigurationsStartMigration() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Migrationconfigurations/SBMigrationconfigurationGet.json - // this example is just showing the usage of "MigrationConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Migrationconfigurations/SBMigrationconfigurationCreateAndStartMigration.json + // this example is just showing the usage of "MigrationConfigs_CreateAndStartMigration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,7 +96,13 @@ public async Task Get_MigrationConfigurationsGet() MigrationConfigurationResource migrationConfiguration = client.GetMigrationConfigurationResource(migrationConfigurationResourceId); // invoke the operation - MigrationConfigurationResource result = await migrationConfiguration.GetAsync(); + MigrationConfigurationData data = new MigrationConfigurationData + { + TargetServiceBusNamespace = new ResourceIdentifier("/subscriptions/SubscriptionId/resourceGroups/ResourceGroup/providers/Microsoft.ServiceBus/namespaces/sdk-Namespace-4028"), + PostMigrationName = "sdk-PostMigration-5919", + }; + ArmOperation lro = await migrationConfiguration.UpdateAsync(WaitUntil.Completed, data); + MigrationConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryAuthorizationRuleCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryAuthorizationRuleCollection.cs index 50268fd81bdb5..0d398566a7b77 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryAuthorizationRuleCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryAuthorizationRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceBusDisasterRecoveryAuthorizationRuleCollectio { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NameSpaceAuthorizationRuleListAll() + public async Task Get_DisasterRecoveryConfigsAuthorizationRuleGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasAuthorizationRuleListAll.json - // this example is just showing the usage of "DisasterRecoveryAuthorizationRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasAuthorizationRuleGet.json + // this example is just showing the usage of "DisasterRecoveryAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,32 +32,30 @@ public async Task GetAll_NameSpaceAuthorizationRuleListAll() string subscriptionId = "exampleSubscriptionId"; string resourceGroupName = "exampleResourceGroup"; string namespaceName = "sdk-Namespace-9080"; - string @alias = "sdk-DisasterRecovery-4047"; + string @alias = "sdk-DisasterRecovery-4879"; ResourceIdentifier serviceBusDisasterRecoveryResourceId = ServiceBusDisasterRecoveryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, @alias); ServiceBusDisasterRecoveryResource serviceBusDisasterRecovery = client.GetServiceBusDisasterRecoveryResource(serviceBusDisasterRecoveryResourceId); // get the collection of this ServiceBusDisasterRecoveryAuthorizationRuleResource ServiceBusDisasterRecoveryAuthorizationRuleCollection collection = serviceBusDisasterRecovery.GetServiceBusDisasterRecoveryAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (ServiceBusDisasterRecoveryAuthorizationRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusAuthorizationRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string authorizationRuleName = "sdk-Authrules-4879"; + ServiceBusDisasterRecoveryAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DisasterRecoveryConfigsAuthorizationRuleGet() + public async Task GetAll_NameSpaceAuthorizationRuleListAll() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasAuthorizationRuleGet.json - // this example is just showing the usage of "DisasterRecoveryAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasAuthorizationRuleListAll.json + // this example is just showing the usage of "DisasterRecoveryAuthorizationRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,22 +67,24 @@ public async Task Get_DisasterRecoveryConfigsAuthorizationRuleGet() string subscriptionId = "exampleSubscriptionId"; string resourceGroupName = "exampleResourceGroup"; string namespaceName = "sdk-Namespace-9080"; - string @alias = "sdk-DisasterRecovery-4879"; + string @alias = "sdk-DisasterRecovery-4047"; ResourceIdentifier serviceBusDisasterRecoveryResourceId = ServiceBusDisasterRecoveryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, @alias); ServiceBusDisasterRecoveryResource serviceBusDisasterRecovery = client.GetServiceBusDisasterRecoveryResource(serviceBusDisasterRecoveryResourceId); // get the collection of this ServiceBusDisasterRecoveryAuthorizationRuleResource ServiceBusDisasterRecoveryAuthorizationRuleCollection collection = serviceBusDisasterRecovery.GetServiceBusDisasterRecoveryAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "sdk-Authrules-4879"; - ServiceBusDisasterRecoveryAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (ServiceBusDisasterRecoveryAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryCollection.cs index e400b45c3d4cd..2c8279686459a 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceBusDisasterRecoveryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SBAliasList() + public async Task CreateOrUpdate_SBAliasCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasList.json - // this example is just showing the usage of "DisasterRecoveryConfigs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasCreate.json + // this example is just showing the usage of "DisasterRecoveryConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,29 @@ public async Task GetAll_SBAliasList() // get the collection of this ServiceBusDisasterRecoveryResource ServiceBusDisasterRecoveryCollection collection = serviceBusNamespace.GetServiceBusDisasterRecoveries(); - // invoke the operation and iterate over the result - await foreach (ServiceBusDisasterRecoveryResource item in collection.GetAllAsync()) + // invoke the operation + string @alias = "sdk-Namespace-8860"; + ServiceBusDisasterRecoveryData data = new ServiceBusDisasterRecoveryData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusDisasterRecoveryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PartnerNamespace = "sdk-Namespace-37", + AlternateName = "alternameforAlias-Namespace-8860", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, @alias, data); + ServiceBusDisasterRecoveryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusDisasterRecoveryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SBAliasCreate() + public async Task Get_SBAliasGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasCreate.json - // this example is just showing the usage of "DisasterRecoveryConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasGet.json + // this example is just showing the usage of "DisasterRecoveryConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +79,8 @@ public async Task CreateOrUpdate_SBAliasCreate() ServiceBusDisasterRecoveryCollection collection = serviceBusNamespace.GetServiceBusDisasterRecoveries(); // invoke the operation - string @alias = "sdk-Namespace-8860"; - ServiceBusDisasterRecoveryData data = new ServiceBusDisasterRecoveryData() - { - PartnerNamespace = "sdk-Namespace-37", - AlternateName = "alternameforAlias-Namespace-8860", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, @alias, data); - ServiceBusDisasterRecoveryResource result = lro.Value; + string @alias = "sdk-DisasterRecovery-3814"; + ServiceBusDisasterRecoveryResource result = await collection.GetAsync(@alias); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -93,10 +91,10 @@ public async Task CreateOrUpdate_SBAliasCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SBAliasGet() + public async Task GetAll_SBAliasList() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasGet.json - // this example is just showing the usage of "DisasterRecoveryConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasList.json + // this example is just showing the usage of "DisasterRecoveryConfigs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,15 +112,17 @@ public async Task Get_SBAliasGet() // get the collection of this ServiceBusDisasterRecoveryResource ServiceBusDisasterRecoveryCollection collection = serviceBusNamespace.GetServiceBusDisasterRecoveries(); - // invoke the operation - string @alias = "sdk-DisasterRecovery-3814"; - ServiceBusDisasterRecoveryResource result = await collection.GetAsync(@alias); + // invoke the operation and iterate over the result + await foreach (ServiceBusDisasterRecoveryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusDisasterRecoveryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusDisasterRecoveryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryResource.cs index 43fd25aaef871..4061cb198ef00 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusDisasterRecoveryResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceBusDisasterRecoveryResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SBAliasCreate() + public async Task Get_SBAliasGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasCreate.json - // this example is just showing the usage of "DisasterRecoveryConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasGet.json + // this example is just showing the usage of "DisasterRecoveryConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,18 +32,12 @@ public async Task Update_SBAliasCreate() string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; string resourceGroupName = "ardsouzatestRG"; string namespaceName = "sdk-Namespace-8860"; - string @alias = "sdk-Namespace-8860"; + string @alias = "sdk-DisasterRecovery-3814"; ResourceIdentifier serviceBusDisasterRecoveryResourceId = ServiceBusDisasterRecoveryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, @alias); ServiceBusDisasterRecoveryResource serviceBusDisasterRecovery = client.GetServiceBusDisasterRecoveryResource(serviceBusDisasterRecoveryResourceId); // invoke the operation - ServiceBusDisasterRecoveryData data = new ServiceBusDisasterRecoveryData() - { - PartnerNamespace = "sdk-Namespace-37", - AlternateName = "alternameforAlias-Namespace-8860", - }; - ArmOperation lro = await serviceBusDisasterRecovery.UpdateAsync(WaitUntil.Completed, data); - ServiceBusDisasterRecoveryResource result = lro.Value; + ServiceBusDisasterRecoveryResource result = await serviceBusDisasterRecovery.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +75,10 @@ public async Task Delete_SBAliasDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SBAliasGet() + public async Task Update_SBAliasCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasGet.json - // this example is just showing the usage of "DisasterRecoveryConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/disasterRecoveryConfigs/SBAliasCreate.json + // this example is just showing the usage of "DisasterRecoveryConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,12 +90,18 @@ public async Task Get_SBAliasGet() string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; string resourceGroupName = "ardsouzatestRG"; string namespaceName = "sdk-Namespace-8860"; - string @alias = "sdk-DisasterRecovery-3814"; + string @alias = "sdk-Namespace-8860"; ResourceIdentifier serviceBusDisasterRecoveryResourceId = ServiceBusDisasterRecoveryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, @alias); ServiceBusDisasterRecoveryResource serviceBusDisasterRecovery = client.GetServiceBusDisasterRecoveryResource(serviceBusDisasterRecoveryResourceId); // invoke the operation - ServiceBusDisasterRecoveryResource result = await serviceBusDisasterRecovery.GetAsync(); + ServiceBusDisasterRecoveryData data = new ServiceBusDisasterRecoveryData + { + PartnerNamespace = "sdk-Namespace-37", + AlternateName = "alternameforAlias-Namespace-8860", + }; + ArmOperation lro = await serviceBusDisasterRecovery.UpdateAsync(WaitUntil.Completed, data); + ServiceBusDisasterRecoveryResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceAuthorizationRuleCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceAuthorizationRuleCollection.cs index 88b488e9d571b..09a818789d24d 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceAuthorizationRuleCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceAuthorizationRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceBusNamespaceAuthorizationRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NameSpaceAuthorizationRuleListAll() + public async Task CreateOrUpdate_NameSpaceAuthorizationRuleCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceAuthorizationRuleListAll.json - // this example is just showing the usage of "NamespaceAuthorizationRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceAuthorizationRuleCreate.json + // this example is just showing the usage of "NamespaceAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_NameSpaceAuthorizationRuleListAll() // get the collection of this ServiceBusNamespaceAuthorizationRuleResource ServiceBusNamespaceAuthorizationRuleCollection collection = serviceBusNamespace.GetServiceBusNamespaceAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (ServiceBusNamespaceAuthorizationRuleResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationRuleName = "sdk-AuthRules-1788"; + ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusAuthorizationRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Rights = { ServiceBusAccessRight.Listen, ServiceBusAccessRight.Send }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); + ServiceBusNamespaceAuthorizationRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NameSpaceAuthorizationRuleCreate() + public async Task Get_NameSpaceAuthorizationRuleGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceAuthorizationRuleCreate.json - // this example is just showing the usage of "NamespaceAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceAuthorizationRuleGet.json + // this example is just showing the usage of "NamespaceAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +80,7 @@ public async Task CreateOrUpdate_NameSpaceAuthorizationRuleCreate() // invoke the operation string authorizationRuleName = "sdk-AuthRules-1788"; - ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData() - { - Rights = -{ -ServiceBusAccessRight.Listen,ServiceBusAccessRight.Send -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); - ServiceBusNamespaceAuthorizationRuleResource result = lro.Value; + ServiceBusNamespaceAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -96,10 +91,10 @@ public async Task CreateOrUpdate_NameSpaceAuthorizationRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpaceAuthorizationRuleGet() + public async Task GetAll_NameSpaceAuthorizationRuleListAll() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceAuthorizationRuleGet.json - // this example is just showing the usage of "NamespaceAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceAuthorizationRuleListAll.json + // this example is just showing the usage of "NamespaceAuthorizationRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,15 +112,17 @@ public async Task Get_NameSpaceAuthorizationRuleGet() // get the collection of this ServiceBusNamespaceAuthorizationRuleResource ServiceBusNamespaceAuthorizationRuleCollection collection = serviceBusNamespace.GetServiceBusNamespaceAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "sdk-AuthRules-1788"; - ServiceBusNamespaceAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (ServiceBusNamespaceAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceAuthorizationRuleResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceAuthorizationRuleResource.cs index 19378369bea7f..c349d8442260c 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceAuthorizationRuleResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceAuthorizationRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceBusNamespaceAuthorizationRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NameSpaceAuthorizationRuleCreate() + public async Task Get_NameSpaceAuthorizationRuleGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceAuthorizationRuleCreate.json - // this example is just showing the usage of "NamespaceAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceAuthorizationRuleGet.json + // this example is just showing the usage of "NamespaceAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_NameSpaceAuthorizationRuleCreate() ServiceBusNamespaceAuthorizationRuleResource serviceBusNamespaceAuthorizationRule = client.GetServiceBusNamespaceAuthorizationRuleResource(serviceBusNamespaceAuthorizationRuleResourceId); // invoke the operation - ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData() - { - Rights = -{ -ServiceBusAccessRight.Listen,ServiceBusAccessRight.Send -}, - }; - ArmOperation lro = await serviceBusNamespaceAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); - ServiceBusNamespaceAuthorizationRuleResource result = lro.Value; + ServiceBusNamespaceAuthorizationRuleResource result = await serviceBusNamespaceAuthorizationRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -84,10 +76,10 @@ public async Task Delete_NameSpaceAuthorizationRuleDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpaceAuthorizationRuleGet() + public async Task Update_NameSpaceAuthorizationRuleCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceAuthorizationRuleGet.json - // this example is just showing the usage of "NamespaceAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceAuthorizationRuleCreate.json + // this example is just showing the usage of "NamespaceAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,7 +96,12 @@ public async Task Get_NameSpaceAuthorizationRuleGet() ServiceBusNamespaceAuthorizationRuleResource serviceBusNamespaceAuthorizationRule = client.GetServiceBusNamespaceAuthorizationRuleResource(serviceBusNamespaceAuthorizationRuleResourceId); // invoke the operation - ServiceBusNamespaceAuthorizationRuleResource result = await serviceBusNamespaceAuthorizationRule.GetAsync(); + ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData + { + Rights = { ServiceBusAccessRight.Listen, ServiceBusAccessRight.Send }, + }; + ArmOperation lro = await serviceBusNamespaceAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); + ServiceBusNamespaceAuthorizationRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceCollection.cs index e7b840db24176..a3e873218c4a1 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceCollection.cs @@ -17,41 +17,6 @@ namespace Azure.ResourceManager.ServiceBus.Samples { public partial class Sample_ServiceBusNamespaceCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_NameSpaceListByResourceGroup() - { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceListByResourceGroup.json - // this example is just showing the usage of "Namespaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - string resourceGroupName = "ArunMonocle"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ServiceBusNamespaceResource - ServiceBusNamespaceCollection collection = resourceGroupResource.GetServiceBusNamespaces(); - - // invoke the operation and iterate over the result - await foreach (ServiceBusNamespaceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusNamespaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_NameSpaceCreate() @@ -87,7 +52,7 @@ public async Task CreateOrUpdate_NameSpaceCreate() Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namespaceName, data); @@ -133,6 +98,41 @@ public async Task Get_NameSpaceGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_NameSpaceListByResourceGroup() + { + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceListByResourceGroup.json + // this example is just showing the usage of "Namespaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + string resourceGroupName = "ArunMonocle"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ServiceBusNamespaceResource + ServiceBusNamespaceCollection collection = resourceGroupResource.GetServiceBusNamespaces(); + + // invoke the operation and iterate over the result + await foreach (ServiceBusNamespaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusNamespaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_NameSpaceGet() diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceResource.cs index f75a66c24b3d9..318dd1fd0e1e6 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNamespaceResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.ServiceBus.Models; using NUnit.Framework; @@ -19,33 +18,32 @@ public partial class Sample_ServiceBusNamespaceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetServiceBusNamespaces_NameSpaceList() + public async Task Get_NameSpaceGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceList.json - // this example is just showing the usage of "Namespaces_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceGet.json + // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this ServiceBusNamespaceResource created on azure + // for more information of creating ServiceBusNamespaceResource, please refer to the document of ServiceBusNamespaceResource string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "ArunMonocle"; + string namespaceName = "sdk-Namespace-2924"; + ResourceIdentifier serviceBusNamespaceResourceId = ServiceBusNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); + ServiceBusNamespaceResource serviceBusNamespace = client.GetServiceBusNamespaceResource(serviceBusNamespaceResourceId); - // invoke the operation and iterate over the result - await foreach (ServiceBusNamespaceResource item in subscriptionResource.GetServiceBusNamespacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusNamespaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + ServiceBusNamespaceResource result = await serviceBusNamespace.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusNamespaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -74,36 +72,6 @@ public async Task Delete_NameSpaceDelete() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpaceGet() - { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceGet.json - // this example is just showing the usage of "Namespaces_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceBusNamespaceResource created on azure - // for more information of creating ServiceBusNamespaceResource, please refer to the document of ServiceBusNamespaceResource - string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - string resourceGroupName = "ArunMonocle"; - string namespaceName = "sdk-Namespace-2924"; - ResourceIdentifier serviceBusNamespaceResourceId = ServiceBusNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); - ServiceBusNamespaceResource serviceBusNamespace = client.GetServiceBusNamespaceResource(serviceBusNamespaceResourceId); - - // invoke the operation - ServiceBusNamespaceResource result = await serviceBusNamespace.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusNamespaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Update_NameSpaceUpdate() @@ -130,7 +98,7 @@ public async Task Update_NameSpaceUpdate() Tags = { ["tag3"] = "value3", -["tag4"] = "value4", +["tag4"] = "value4" }, }; ServiceBusNamespaceResource result = await serviceBusNamespace.UpdateAsync(patch); @@ -142,31 +110,6 @@ public async Task Update_NameSpaceUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckServiceBusNamespaceNameAvailability_NameSpaceCheckNameAvailability() - { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceCheckNameAvailability.json - // this example is just showing the usage of "Namespaces_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - ServiceBusNameAvailabilityContent content = new ServiceBusNameAvailabilityContent("sdk-Namespace-2924"); - ServiceBusNameAvailabilityResult result = await subscriptionResource.CheckServiceBusNamespaceNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetPrivateLinkResources_NameSpacePrivateLinkResourcesGet() diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNetworkRuleSetResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNetworkRuleSetResource.cs index 6e75ff7a9a8dc..a8b3907836af7 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNetworkRuleSetResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusNetworkRuleSetResource.cs @@ -16,6 +16,36 @@ namespace Azure.ResourceManager.ServiceBus.Samples { public partial class Sample_ServiceBusNetworkRuleSetResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_NameSpaceNetworkRuleSetGet() + { + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/VirtualNetworkRule/SBNetworkRuleSetGet.json + // this example is just showing the usage of "Namespaces_GetNetworkRuleSet" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceBusNetworkRuleSetResource created on azure + // for more information of creating ServiceBusNetworkRuleSetResource, please refer to the document of ServiceBusNetworkRuleSetResource + string subscriptionId = "Subscription"; + string resourceGroupName = "ResourceGroup"; + string namespaceName = "sdk-Namespace-6019"; + ResourceIdentifier serviceBusNetworkRuleSetResourceId = ServiceBusNetworkRuleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); + ServiceBusNetworkRuleSetResource serviceBusNetworkRuleSet = client.GetServiceBusNetworkRuleSetResource(serviceBusNetworkRuleSetResourceId); + + // invoke the operation + ServiceBusNetworkRuleSetResource result = await serviceBusNetworkRuleSet.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusNetworkRuleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_NameSpaceNetworkRuleSetCreate() @@ -37,49 +67,43 @@ public async Task CreateOrUpdate_NameSpaceNetworkRuleSetCreate() ServiceBusNetworkRuleSetResource serviceBusNetworkRuleSet = client.GetServiceBusNetworkRuleSetResource(serviceBusNetworkRuleSetResourceId); // invoke the operation - ServiceBusNetworkRuleSetData data = new ServiceBusNetworkRuleSetData() + ServiceBusNetworkRuleSetData data = new ServiceBusNetworkRuleSetData { DefaultAction = ServiceBusNetworkRuleSetDefaultAction.Deny, - VirtualNetworkRules = -{ -new ServiceBusNetworkRuleSetVirtualNetworkRules() + VirtualNetworkRules = {new ServiceBusNetworkRuleSetVirtualNetworkRules { SubnetId = new ResourceIdentifier("/subscriptions/854d368f-1828-428f-8f3c-f2affa9b2f7d/resourcegroups/alitest/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet2"), IgnoreMissingVnetServiceEndpoint = true, -},new ServiceBusNetworkRuleSetVirtualNetworkRules() +}, new ServiceBusNetworkRuleSetVirtualNetworkRules { SubnetId = new ResourceIdentifier("/subscriptions/854d368f-1828-428f-8f3c-f2affa9b2f7d/resourcegroups/alitest/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet3"), IgnoreMissingVnetServiceEndpoint = false, -},new ServiceBusNetworkRuleSetVirtualNetworkRules() +}, new ServiceBusNetworkRuleSetVirtualNetworkRules { SubnetId = new ResourceIdentifier("/subscriptions/854d368f-1828-428f-8f3c-f2affa9b2f7d/resourcegroups/alitest/providers/Microsoft.Network/virtualNetworks/myvn/subnets/subnet6"), IgnoreMissingVnetServiceEndpoint = false, -} -}, - IPRules = -{ -new ServiceBusNetworkRuleSetIPRules() +}}, + IPRules = {new ServiceBusNetworkRuleSetIPRules { IPMask = "1.1.1.1", Action = ServiceBusNetworkRuleIPAction.Allow, -},new ServiceBusNetworkRuleSetIPRules() +}, new ServiceBusNetworkRuleSetIPRules { IPMask = "1.1.1.2", Action = ServiceBusNetworkRuleIPAction.Allow, -},new ServiceBusNetworkRuleSetIPRules() +}, new ServiceBusNetworkRuleSetIPRules { IPMask = "1.1.1.3", Action = ServiceBusNetworkRuleIPAction.Allow, -},new ServiceBusNetworkRuleSetIPRules() +}, new ServiceBusNetworkRuleSetIPRules { IPMask = "1.1.1.4", Action = ServiceBusNetworkRuleIPAction.Allow, -},new ServiceBusNetworkRuleSetIPRules() +}, new ServiceBusNetworkRuleSetIPRules { IPMask = "1.1.1.5", Action = ServiceBusNetworkRuleIPAction.Allow, -} -}, +}}, }; ArmOperation lro = await serviceBusNetworkRuleSet.CreateOrUpdateAsync(WaitUntil.Completed, data); ServiceBusNetworkRuleSetResource result = lro.Value; @@ -90,35 +114,5 @@ public async Task CreateOrUpdate_NameSpaceNetworkRuleSetCreate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpaceNetworkRuleSetGet() - { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/VirtualNetworkRule/SBNetworkRuleSetGet.json - // this example is just showing the usage of "Namespaces_GetNetworkRuleSet" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceBusNetworkRuleSetResource created on azure - // for more information of creating ServiceBusNetworkRuleSetResource, please refer to the document of ServiceBusNetworkRuleSetResource - string subscriptionId = "Subscription"; - string resourceGroupName = "ResourceGroup"; - string namespaceName = "sdk-Namespace-6019"; - ResourceIdentifier serviceBusNetworkRuleSetResourceId = ServiceBusNetworkRuleSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); - ServiceBusNetworkRuleSetResource serviceBusNetworkRuleSet = client.GetServiceBusNetworkRuleSetResource(serviceBusNetworkRuleSetResourceId); - - // invoke the operation - ServiceBusNetworkRuleSetResource result = await serviceBusNetworkRuleSet.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusNetworkRuleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusPrivateEndpointConnectionCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusPrivateEndpointConnectionCollection.cs index 944099129b87b..3e1dd717f2cb2 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusPrivateEndpointConnectionCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusPrivateEndpointConnectionCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.ServiceBus.Samples { public partial class Sample_ServiceBusPrivateEndpointConnectionCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_NameSpaceCreate() - { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/PrivateEndPointConnectionList.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceBusNamespaceResource created on azure - // for more information of creating ServiceBusNamespaceResource, please refer to the document of ServiceBusNamespaceResource - string subscriptionId = "subID"; - string resourceGroupName = "SDK-ServiceBus-4794"; - string namespaceName = "sdk-Namespace-5828"; - ResourceIdentifier serviceBusNamespaceResourceId = ServiceBusNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); - ServiceBusNamespaceResource serviceBusNamespace = client.GetServiceBusNamespaceResource(serviceBusNamespaceResourceId); - - // get the collection of this ServiceBusPrivateEndpointConnectionResource - ServiceBusPrivateEndpointConnectionCollection collection = serviceBusNamespace.GetServiceBusPrivateEndpointConnections(); - - // invoke the operation and iterate over the result - await foreach (ServiceBusPrivateEndpointConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_NameSpacePrivateEndPointConnectionCreate() @@ -77,10 +41,10 @@ public async Task CreateOrUpdate_NameSpacePrivateEndPointConnectionCreate() // invoke the operation string privateEndpointConnectionName = "privateEndpointConnectionName"; - ServiceBusPrivateEndpointConnectionData data = new ServiceBusPrivateEndpointConnectionData() + ServiceBusPrivateEndpointConnectionData data = new ServiceBusPrivateEndpointConnectionData { PrivateEndpointId = new ResourceIdentifier("/subscriptions/dbedb4e0-40e6-4145-81f3-f1314c150774/resourceGroups/SDK-ServiceBus-8396/providers/Microsoft.Network/privateEndpoints/sdk-Namespace-2847"), - ConnectionState = new ServiceBusPrivateLinkServiceConnectionState() + ConnectionState = new ServiceBusPrivateLinkServiceConnectionState { Status = ServiceBusPrivateLinkConnectionStatus.Rejected, Description = "testing", @@ -131,6 +95,42 @@ public async Task Get_NameSpacePrivateEndPointConnectionGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_NameSpaceCreate() + { + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/PrivateEndPointConnectionList.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceBusNamespaceResource created on azure + // for more information of creating ServiceBusNamespaceResource, please refer to the document of ServiceBusNamespaceResource + string subscriptionId = "subID"; + string resourceGroupName = "SDK-ServiceBus-4794"; + string namespaceName = "sdk-Namespace-5828"; + ResourceIdentifier serviceBusNamespaceResourceId = ServiceBusNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); + ServiceBusNamespaceResource serviceBusNamespace = client.GetServiceBusNamespaceResource(serviceBusNamespaceResourceId); + + // get the collection of this ServiceBusPrivateEndpointConnectionResource + ServiceBusPrivateEndpointConnectionCollection collection = serviceBusNamespace.GetServiceBusPrivateEndpointConnections(); + + // invoke the operation and iterate over the result + await foreach (ServiceBusPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_NameSpacePrivateEndPointConnectionGet() diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusPrivateEndpointConnectionResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusPrivateEndpointConnectionResource.cs index 85b5b5a344e84..a50bedba9941f 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusPrivateEndpointConnectionResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceBusPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NameSpacePrivateEndPointConnectionCreate() + public async Task Get_NameSpacePrivateEndPointConnectionGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/PrivateEndPointConnectionCreate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/PrivateEndPointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,25 +31,14 @@ public async Task Update_NameSpacePrivateEndPointConnectionCreate() // this example assumes you already have this ServiceBusPrivateEndpointConnectionResource created on azure // for more information of creating ServiceBusPrivateEndpointConnectionResource, please refer to the document of ServiceBusPrivateEndpointConnectionResource string subscriptionId = "subID"; - string resourceGroupName = "ArunMonocle"; - string namespaceName = "sdk-Namespace-2924"; + string resourceGroupName = "SDK-ServiceBus-4794"; + string namespaceName = "sdk-Namespace-5828"; string privateEndpointConnectionName = "privateEndpointConnectionName"; ResourceIdentifier serviceBusPrivateEndpointConnectionResourceId = ServiceBusPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName); ServiceBusPrivateEndpointConnectionResource serviceBusPrivateEndpointConnection = client.GetServiceBusPrivateEndpointConnectionResource(serviceBusPrivateEndpointConnectionResourceId); // invoke the operation - ServiceBusPrivateEndpointConnectionData data = new ServiceBusPrivateEndpointConnectionData() - { - PrivateEndpointId = new ResourceIdentifier("/subscriptions/dbedb4e0-40e6-4145-81f3-f1314c150774/resourceGroups/SDK-ServiceBus-8396/providers/Microsoft.Network/privateEndpoints/sdk-Namespace-2847"), - ConnectionState = new ServiceBusPrivateLinkServiceConnectionState() - { - Status = ServiceBusPrivateLinkConnectionStatus.Rejected, - Description = "testing", - }, - ProvisioningState = ServiceBusPrivateEndpointConnectionProvisioningState.Succeeded, - }; - ArmOperation lro = await serviceBusPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - ServiceBusPrivateEndpointConnectionResource result = lro.Value; + ServiceBusPrivateEndpointConnectionResource result = await serviceBusPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,10 +76,10 @@ public async Task Delete_NameSpacePrivateEndPointConnectionDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NameSpacePrivateEndPointConnectionGet() + public async Task Update_NameSpacePrivateEndPointConnectionCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/PrivateEndPointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/PrivateEndPointConnectionCreate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,14 +89,25 @@ public async Task Get_NameSpacePrivateEndPointConnectionGet() // this example assumes you already have this ServiceBusPrivateEndpointConnectionResource created on azure // for more information of creating ServiceBusPrivateEndpointConnectionResource, please refer to the document of ServiceBusPrivateEndpointConnectionResource string subscriptionId = "subID"; - string resourceGroupName = "SDK-ServiceBus-4794"; - string namespaceName = "sdk-Namespace-5828"; + string resourceGroupName = "ArunMonocle"; + string namespaceName = "sdk-Namespace-2924"; string privateEndpointConnectionName = "privateEndpointConnectionName"; ResourceIdentifier serviceBusPrivateEndpointConnectionResourceId = ServiceBusPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, privateEndpointConnectionName); ServiceBusPrivateEndpointConnectionResource serviceBusPrivateEndpointConnection = client.GetServiceBusPrivateEndpointConnectionResource(serviceBusPrivateEndpointConnectionResourceId); // invoke the operation - ServiceBusPrivateEndpointConnectionResource result = await serviceBusPrivateEndpointConnection.GetAsync(); + ServiceBusPrivateEndpointConnectionData data = new ServiceBusPrivateEndpointConnectionData + { + PrivateEndpointId = new ResourceIdentifier("/subscriptions/dbedb4e0-40e6-4145-81f3-f1314c150774/resourceGroups/SDK-ServiceBus-8396/providers/Microsoft.Network/privateEndpoints/sdk-Namespace-2847"), + ConnectionState = new ServiceBusPrivateLinkServiceConnectionState + { + Status = ServiceBusPrivateLinkConnectionStatus.Rejected, + Description = "testing", + }, + ProvisioningState = ServiceBusPrivateEndpointConnectionProvisioningState.Succeeded, + }; + ArmOperation lro = await serviceBusPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ServiceBusPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueAuthorizationRuleCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueAuthorizationRuleCollection.cs index 1c6779d9f87bd..c55dd8e947e1c 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueAuthorizationRuleCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueAuthorizationRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceBusQueueAuthorizationRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QueueAuthorizationRuleListAll() + public async Task CreateOrUpdate_QueueAuthorizationRuleCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueAuthorizationRuleListAll.json - // this example is just showing the usage of "QueueAuthorizationRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueAuthorizationRuleCreate.json + // this example is just showing the usage of "QueueAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,28 @@ public async Task GetAll_QueueAuthorizationRuleListAll() // get the collection of this ServiceBusQueueAuthorizationRuleResource ServiceBusQueueAuthorizationRuleCollection collection = serviceBusQueue.GetServiceBusQueueAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (ServiceBusQueueAuthorizationRuleResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationRuleName = "sdk-AuthRules-5800"; + ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusAuthorizationRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Rights = { ServiceBusAccessRight.Listen, ServiceBusAccessRight.Send }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); + ServiceBusQueueAuthorizationRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_QueueAuthorizationRuleCreate() + public async Task Get_QueueAuthorizationRuleGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueAuthorizationRuleCreate.json - // this example is just showing the usage of "QueueAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueAuthorizationRuleGet.json + // this example is just showing the usage of "QueueAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +82,7 @@ public async Task CreateOrUpdate_QueueAuthorizationRuleCreate() // invoke the operation string authorizationRuleName = "sdk-AuthRules-5800"; - ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData() - { - Rights = -{ -ServiceBusAccessRight.Listen,ServiceBusAccessRight.Send -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); - ServiceBusQueueAuthorizationRuleResource result = lro.Value; + ServiceBusQueueAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -98,10 +93,10 @@ public async Task CreateOrUpdate_QueueAuthorizationRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QueueAuthorizationRuleGet() + public async Task GetAll_QueueAuthorizationRuleListAll() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueAuthorizationRuleGet.json - // this example is just showing the usage of "QueueAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueAuthorizationRuleListAll.json + // this example is just showing the usage of "QueueAuthorizationRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,15 +115,17 @@ public async Task Get_QueueAuthorizationRuleGet() // get the collection of this ServiceBusQueueAuthorizationRuleResource ServiceBusQueueAuthorizationRuleCollection collection = serviceBusQueue.GetServiceBusQueueAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "sdk-AuthRules-5800"; - ServiceBusQueueAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (ServiceBusQueueAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueAuthorizationRuleResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueAuthorizationRuleResource.cs index 17d005fa28fc1..fb20a3771ffa7 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueAuthorizationRuleResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueAuthorizationRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceBusQueueAuthorizationRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_QueueAuthorizationRuleCreate() + public async Task Get_QueueAuthorizationRuleGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueAuthorizationRuleCreate.json - // this example is just showing the usage of "QueueAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueAuthorizationRuleGet.json + // this example is just showing the usage of "QueueAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,15 +39,7 @@ public async Task Update_QueueAuthorizationRuleCreate() ServiceBusQueueAuthorizationRuleResource serviceBusQueueAuthorizationRule = client.GetServiceBusQueueAuthorizationRuleResource(serviceBusQueueAuthorizationRuleResourceId); // invoke the operation - ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData() - { - Rights = -{ -ServiceBusAccessRight.Listen,ServiceBusAccessRight.Send -}, - }; - ArmOperation lro = await serviceBusQueueAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); - ServiceBusQueueAuthorizationRuleResource result = lro.Value; + ServiceBusQueueAuthorizationRuleResource result = await serviceBusQueueAuthorizationRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,10 +78,10 @@ public async Task Delete_QueueAuthorizationRuleDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QueueAuthorizationRuleGet() + public async Task Update_QueueAuthorizationRuleCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueAuthorizationRuleGet.json - // this example is just showing the usage of "QueueAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueAuthorizationRuleCreate.json + // this example is just showing the usage of "QueueAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,7 +99,12 @@ public async Task Get_QueueAuthorizationRuleGet() ServiceBusQueueAuthorizationRuleResource serviceBusQueueAuthorizationRule = client.GetServiceBusQueueAuthorizationRuleResource(serviceBusQueueAuthorizationRuleResourceId); // invoke the operation - ServiceBusQueueAuthorizationRuleResource result = await serviceBusQueueAuthorizationRule.GetAsync(); + ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData + { + Rights = { ServiceBusAccessRight.Listen, ServiceBusAccessRight.Send }, + }; + ArmOperation lro = await serviceBusQueueAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); + ServiceBusQueueAuthorizationRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueCollection.cs index 96e03ab67293d..82402be5706a9 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceBusQueueCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QueueListByNameSpace() + public async Task CreateOrUpdate_QueueCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueListByNameSpace.json - // this example is just showing the usage of "Queues_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueCreate.json + // this example is just showing the usage of "Queues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,28 @@ public async Task GetAll_QueueListByNameSpace() // get the collection of this ServiceBusQueueResource ServiceBusQueueCollection collection = serviceBusNamespace.GetServiceBusQueues(); - // invoke the operation and iterate over the result - await foreach (ServiceBusQueueResource item in collection.GetAllAsync()) + // invoke the operation + string queueName = "sdk-Queues-5647"; + ServiceBusQueueData data = new ServiceBusQueueData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusQueueData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EnablePartitioning = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, queueName, data); + ServiceBusQueueResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusQueueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_QueueCreate() + public async Task Get_QueueGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueCreate.json - // this example is just showing the usage of "Queues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueGet.json + // this example is just showing the usage of "Queues_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,12 +79,7 @@ public async Task CreateOrUpdate_QueueCreate() // invoke the operation string queueName = "sdk-Queues-5647"; - ServiceBusQueueData data = new ServiceBusQueueData() - { - EnablePartitioning = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, queueName, data); - ServiceBusQueueResource result = lro.Value; + ServiceBusQueueResource result = await collection.GetAsync(queueName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +90,10 @@ public async Task CreateOrUpdate_QueueCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QueueGet() + public async Task GetAll_QueueListByNameSpace() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueGet.json - // this example is just showing the usage of "Queues_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueListByNameSpace.json + // this example is just showing the usage of "Queues_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,15 +111,17 @@ public async Task Get_QueueGet() // get the collection of this ServiceBusQueueResource ServiceBusQueueCollection collection = serviceBusNamespace.GetServiceBusQueues(); - // invoke the operation - string queueName = "sdk-Queues-5647"; - ServiceBusQueueResource result = await collection.GetAsync(queueName); + // invoke the operation and iterate over the result + await foreach (ServiceBusQueueResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusQueueData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusQueueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueResource.cs index b5b34a8b8067b..4eba8a7441d24 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusQueueResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceBusQueueResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_QueueCreate() + public async Task Get_QueueGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueCreate.json - // this example is just showing the usage of "Queues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueGet.json + // this example is just showing the usage of "Queues_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,12 +37,7 @@ public async Task Update_QueueCreate() ServiceBusQueueResource serviceBusQueue = client.GetServiceBusQueueResource(serviceBusQueueResourceId); // invoke the operation - ServiceBusQueueData data = new ServiceBusQueueData() - { - EnablePartitioning = true, - }; - ArmOperation lro = await serviceBusQueue.UpdateAsync(WaitUntil.Completed, data); - ServiceBusQueueResource result = lro.Value; + ServiceBusQueueResource result = await serviceBusQueue.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -80,10 +75,10 @@ public async Task Delete_QueueDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QueueGet() + public async Task Update_QueueCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueGet.json - // this example is just showing the usage of "Queues_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Queues/SBQueueCreate.json + // this example is just showing the usage of "Queues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +95,12 @@ public async Task Get_QueueGet() ServiceBusQueueResource serviceBusQueue = client.GetServiceBusQueueResource(serviceBusQueueResourceId); // invoke the operation - ServiceBusQueueResource result = await serviceBusQueue.GetAsync(); + ServiceBusQueueData data = new ServiceBusQueueData + { + EnablePartitioning = true, + }; + ArmOperation lro = await serviceBusQueue.UpdateAsync(WaitUntil.Completed, data); + ServiceBusQueueResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusRuleCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusRuleCollection.cs index ac50ca574fa4d..ac1e8feecf074 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusRuleCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusRuleCollection.cs @@ -16,44 +16,6 @@ namespace Azure.ResourceManager.ServiceBus.Samples { public partial class Sample_ServiceBusRuleCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_RulesListBySubscriptions() - { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleListBySubscription.json - // this example is just showing the usage of "Rules_ListBySubscriptions" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceBusSubscriptionResource created on azure - // for more information of creating ServiceBusSubscriptionResource, please refer to the document of ServiceBusSubscriptionResource - string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - string resourceGroupName = "ArunMonocle"; - string namespaceName = "sdk-Namespace-1319"; - string topicName = "sdk-Topics-2081"; - string subscriptionName = "sdk-Subscriptions-8691"; - ResourceIdentifier serviceBusSubscriptionResourceId = ServiceBusSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, topicName, subscriptionName); - ServiceBusSubscriptionResource serviceBusSubscription = client.GetServiceBusSubscriptionResource(serviceBusSubscriptionResourceId); - - // get the collection of this ServiceBusRuleResource - ServiceBusRuleCollection collection = serviceBusSubscription.GetServiceBusRules(); - - // invoke the operation and iterate over the result - await foreach (ServiceBusRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_RulesCreateCorrelationFilter() @@ -81,14 +43,14 @@ public async Task CreateOrUpdate_RulesCreateCorrelationFilter() // invoke the operation string ruleName = "sdk-Rules-6571"; - ServiceBusRuleData data = new ServiceBusRuleData() + ServiceBusRuleData data = new ServiceBusRuleData { FilterType = ServiceBusFilterType.CorrelationFilter, - CorrelationFilter = new ServiceBusCorrelationFilter() + CorrelationFilter = new ServiceBusCorrelationFilter { ApplicationProperties = { -["topicHint"] = "Crop", +["topicHint"] = "Crop" }, }, }; @@ -167,10 +129,10 @@ public async Task CreateOrUpdate_RulesCreateSqlFilter() // invoke the operation string ruleName = "sdk-Rules-6571"; - ServiceBusRuleData data = new ServiceBusRuleData() + ServiceBusRuleData data = new ServiceBusRuleData { FilterType = ServiceBusFilterType.SqlFilter, - SqlFilter = new ServiceBusSqlFilter() + SqlFilter = new ServiceBusSqlFilter { SqlExpression = "myproperty=test", }, @@ -221,6 +183,44 @@ public async Task Get_RulesGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_RulesListBySubscriptions() + { + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleListBySubscription.json + // this example is just showing the usage of "Rules_ListBySubscriptions" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceBusSubscriptionResource created on azure + // for more information of creating ServiceBusSubscriptionResource, please refer to the document of ServiceBusSubscriptionResource + string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + string resourceGroupName = "ArunMonocle"; + string namespaceName = "sdk-Namespace-1319"; + string topicName = "sdk-Topics-2081"; + string subscriptionName = "sdk-Subscriptions-8691"; + ResourceIdentifier serviceBusSubscriptionResourceId = ServiceBusSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName, topicName, subscriptionName); + ServiceBusSubscriptionResource serviceBusSubscription = client.GetServiceBusSubscriptionResource(serviceBusSubscriptionResourceId); + + // get the collection of this ServiceBusRuleResource + ServiceBusRuleCollection collection = serviceBusSubscription.GetServiceBusRules(); + + // invoke the operation and iterate over the result + await foreach (ServiceBusRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_RulesGet() diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusRuleResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusRuleResource.cs index d06d184906145..860d4592204e9 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusRuleResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceBusRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RulesCreateCorrelationFilter() + public async Task Get_RulesGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleCreate_CorrelationFilter.json - // this example is just showing the usage of "Rules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleGet.json + // this example is just showing the usage of "Rules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,8 +30,8 @@ public async Task Update_RulesCreateCorrelationFilter() // this example assumes you already have this ServiceBusRuleResource created on azure // for more information of creating ServiceBusRuleResource, please refer to the document of ServiceBusRuleResource - string subscriptionId = "subscriptionId"; - string resourceGroupName = "resourceGroupName"; + string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + string resourceGroupName = "ArunMonocle"; string namespaceName = "sdk-Namespace-1319"; string topicName = "sdk-Topics-2081"; string subscriptionName = "sdk-Subscriptions-8691"; @@ -40,19 +40,7 @@ public async Task Update_RulesCreateCorrelationFilter() ServiceBusRuleResource serviceBusRule = client.GetServiceBusRuleResource(serviceBusRuleResourceId); // invoke the operation - ServiceBusRuleData data = new ServiceBusRuleData() - { - FilterType = ServiceBusFilterType.CorrelationFilter, - CorrelationFilter = new ServiceBusCorrelationFilter() - { - ApplicationProperties = -{ -["topicHint"] = "Crop", -}, - }, - }; - ArmOperation lro = await serviceBusRule.UpdateAsync(WaitUntil.Completed, data); - ServiceBusRuleResource result = lro.Value; + ServiceBusRuleResource result = await serviceBusRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -63,10 +51,10 @@ public async Task Update_RulesCreateCorrelationFilter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RulesCreateOrUpdate() + public async Task Delete_RulesDelete() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleCreate.json - // this example is just showing the usage of "Rules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleDelete.json + // this example is just showing the usage of "Rules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,8 +63,8 @@ public async Task Update_RulesCreateOrUpdate() // this example assumes you already have this ServiceBusRuleResource created on azure // for more information of creating ServiceBusRuleResource, please refer to the document of ServiceBusRuleResource - string subscriptionId = "subscriptionId"; - string resourceGroupName = "resourceGroupName"; + string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + string resourceGroupName = "ArunMonocle"; string namespaceName = "sdk-Namespace-1319"; string topicName = "sdk-Topics-2081"; string subscriptionName = "sdk-Subscriptions-8691"; @@ -85,22 +73,16 @@ public async Task Update_RulesCreateOrUpdate() ServiceBusRuleResource serviceBusRule = client.GetServiceBusRuleResource(serviceBusRuleResourceId); // invoke the operation - ServiceBusRuleData data = new ServiceBusRuleData(); - ArmOperation lro = await serviceBusRule.UpdateAsync(WaitUntil.Completed, data); - ServiceBusRuleResource result = lro.Value; + await serviceBusRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RulesCreateSqlFilter() + public async Task Update_RulesCreateCorrelationFilter() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleCreate_SqlFilter.json + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleCreate_CorrelationFilter.json // this example is just showing the usage of "Rules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -120,12 +102,15 @@ public async Task Update_RulesCreateSqlFilter() ServiceBusRuleResource serviceBusRule = client.GetServiceBusRuleResource(serviceBusRuleResourceId); // invoke the operation - ServiceBusRuleData data = new ServiceBusRuleData() + ServiceBusRuleData data = new ServiceBusRuleData { - FilterType = ServiceBusFilterType.SqlFilter, - SqlFilter = new ServiceBusSqlFilter() + FilterType = ServiceBusFilterType.CorrelationFilter, + CorrelationFilter = new ServiceBusCorrelationFilter { - SqlExpression = "myproperty=test", + ApplicationProperties = +{ +["topicHint"] = "Crop" +}, }, }; ArmOperation lro = await serviceBusRule.UpdateAsync(WaitUntil.Completed, data); @@ -140,10 +125,10 @@ public async Task Update_RulesCreateSqlFilter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RulesDelete() + public async Task Update_RulesCreateOrUpdate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleDelete.json - // this example is just showing the usage of "Rules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleCreate.json + // this example is just showing the usage of "Rules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -152,8 +137,8 @@ public async Task Delete_RulesDelete() // this example assumes you already have this ServiceBusRuleResource created on azure // for more information of creating ServiceBusRuleResource, please refer to the document of ServiceBusRuleResource - string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - string resourceGroupName = "ArunMonocle"; + string subscriptionId = "subscriptionId"; + string resourceGroupName = "resourceGroupName"; string namespaceName = "sdk-Namespace-1319"; string topicName = "sdk-Topics-2081"; string subscriptionName = "sdk-Subscriptions-8691"; @@ -162,17 +147,23 @@ public async Task Delete_RulesDelete() ServiceBusRuleResource serviceBusRule = client.GetServiceBusRuleResource(serviceBusRuleResourceId); // invoke the operation - await serviceBusRule.DeleteAsync(WaitUntil.Completed); + ServiceBusRuleData data = new ServiceBusRuleData(); + ArmOperation lro = await serviceBusRule.UpdateAsync(WaitUntil.Completed, data); + ServiceBusRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RulesGet() + public async Task Update_RulesCreateSqlFilter() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleGet.json - // this example is just showing the usage of "Rules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Rules/RuleCreate_SqlFilter.json + // this example is just showing the usage of "Rules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,8 +172,8 @@ public async Task Get_RulesGet() // this example assumes you already have this ServiceBusRuleResource created on azure // for more information of creating ServiceBusRuleResource, please refer to the document of ServiceBusRuleResource - string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - string resourceGroupName = "ArunMonocle"; + string subscriptionId = "subscriptionId"; + string resourceGroupName = "resourceGroupName"; string namespaceName = "sdk-Namespace-1319"; string topicName = "sdk-Topics-2081"; string subscriptionName = "sdk-Subscriptions-8691"; @@ -191,7 +182,16 @@ public async Task Get_RulesGet() ServiceBusRuleResource serviceBusRule = client.GetServiceBusRuleResource(serviceBusRuleResourceId); // invoke the operation - ServiceBusRuleResource result = await serviceBusRule.GetAsync(); + ServiceBusRuleData data = new ServiceBusRuleData + { + FilterType = ServiceBusFilterType.SqlFilter, + SqlFilter = new ServiceBusSqlFilter + { + SqlExpression = "myproperty=test", + }, + }; + ArmOperation lro = await serviceBusRule.UpdateAsync(WaitUntil.Completed, data); + ServiceBusRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusSubscriptionCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusSubscriptionCollection.cs index e43e192f33615..175335adc8e31 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusSubscriptionCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusSubscriptionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceBusSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SubscriptionListByTopic() + public async Task CreateOrUpdate_SubscriptionCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Subscriptions/SBSubscriptionListByTopic.json - // this example is just showing the usage of "Subscriptions_ListByTopic" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Subscriptions/SBSubscriptionCreate.json + // this example is just showing the usage of "Subscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -29,7 +29,7 @@ public async Task GetAll_SubscriptionListByTopic() // this example assumes you already have this ServiceBusTopicResource created on azure // for more information of creating ServiceBusTopicResource, please refer to the document of ServiceBusTopicResource - string subscriptionId = "5{Subscriptionid}"; + string subscriptionId = "Subscriptionid"; string resourceGroupName = "ResourceGroup"; string namespaceName = "sdk-Namespace-1349"; string topicName = "sdk-Topics-8740"; @@ -39,25 +39,28 @@ public async Task GetAll_SubscriptionListByTopic() // get the collection of this ServiceBusSubscriptionResource ServiceBusSubscriptionCollection collection = serviceBusTopic.GetServiceBusSubscriptions(); - // invoke the operation and iterate over the result - await foreach (ServiceBusSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string subscriptionName = "sdk-Subscriptions-2178"; + ServiceBusSubscriptionData data = new ServiceBusSubscriptionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusSubscriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EnableBatchedOperations = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subscriptionName, data); + ServiceBusSubscriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SubscriptionCreate() + public async Task Get_SubscriptionGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Subscriptions/SBSubscriptionCreate.json - // this example is just showing the usage of "Subscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Subscriptions/SBSubscriptionGet.json + // this example is just showing the usage of "Subscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,12 +81,7 @@ public async Task CreateOrUpdate_SubscriptionCreate() // invoke the operation string subscriptionName = "sdk-Subscriptions-2178"; - ServiceBusSubscriptionData data = new ServiceBusSubscriptionData() - { - EnableBatchedOperations = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subscriptionName, data); - ServiceBusSubscriptionResource result = lro.Value; + ServiceBusSubscriptionResource result = await collection.GetAsync(subscriptionName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -94,10 +92,10 @@ public async Task CreateOrUpdate_SubscriptionCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubscriptionGet() + public async Task GetAll_SubscriptionListByTopic() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Subscriptions/SBSubscriptionGet.json - // this example is just showing the usage of "Subscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Subscriptions/SBSubscriptionListByTopic.json + // this example is just showing the usage of "Subscriptions_ListByTopic" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,7 +104,7 @@ public async Task Get_SubscriptionGet() // this example assumes you already have this ServiceBusTopicResource created on azure // for more information of creating ServiceBusTopicResource, please refer to the document of ServiceBusTopicResource - string subscriptionId = "Subscriptionid"; + string subscriptionId = "5{Subscriptionid}"; string resourceGroupName = "ResourceGroup"; string namespaceName = "sdk-Namespace-1349"; string topicName = "sdk-Topics-8740"; @@ -116,15 +114,17 @@ public async Task Get_SubscriptionGet() // get the collection of this ServiceBusSubscriptionResource ServiceBusSubscriptionCollection collection = serviceBusTopic.GetServiceBusSubscriptions(); - // invoke the operation - string subscriptionName = "sdk-Subscriptions-2178"; - ServiceBusSubscriptionResource result = await collection.GetAsync(subscriptionName); + // invoke the operation and iterate over the result + await foreach (ServiceBusSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusSubscriptionResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusSubscriptionResource.cs index f9908d5e2dcaa..9b9a66162163b 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusSubscriptionResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusSubscriptionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceBusSubscriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SubscriptionCreate() + public async Task Get_SubscriptionGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Subscriptions/SBSubscriptionCreate.json - // this example is just showing the usage of "Subscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Subscriptions/SBSubscriptionGet.json + // this example is just showing the usage of "Subscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,12 +38,7 @@ public async Task Update_SubscriptionCreate() ServiceBusSubscriptionResource serviceBusSubscription = client.GetServiceBusSubscriptionResource(serviceBusSubscriptionResourceId); // invoke the operation - ServiceBusSubscriptionData data = new ServiceBusSubscriptionData() - { - EnableBatchedOperations = true, - }; - ArmOperation lro = await serviceBusSubscription.UpdateAsync(WaitUntil.Completed, data); - ServiceBusSubscriptionResource result = lro.Value; + ServiceBusSubscriptionResource result = await serviceBusSubscription.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -82,10 +77,10 @@ public async Task Delete_SubscriptionDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubscriptionGet() + public async Task Update_SubscriptionCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Subscriptions/SBSubscriptionGet.json - // this example is just showing the usage of "Subscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Subscriptions/SBSubscriptionCreate.json + // this example is just showing the usage of "Subscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,7 +98,12 @@ public async Task Get_SubscriptionGet() ServiceBusSubscriptionResource serviceBusSubscription = client.GetServiceBusSubscriptionResource(serviceBusSubscriptionResourceId); // invoke the operation - ServiceBusSubscriptionResource result = await serviceBusSubscription.GetAsync(); + ServiceBusSubscriptionData data = new ServiceBusSubscriptionData + { + EnableBatchedOperations = true, + }; + ArmOperation lro = await serviceBusSubscription.UpdateAsync(WaitUntil.Completed, data); + ServiceBusSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicAuthorizationRuleCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicAuthorizationRuleCollection.cs index 4530813084c83..7fac1f12b4d4f 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicAuthorizationRuleCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicAuthorizationRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceBusTopicAuthorizationRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TopicAuthorizationRuleListAll() + public async Task CreateOrUpdate_TopicAuthorizationRuleCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleListAll.json - // this example is just showing the usage of "TopicAuthorizationRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleCreate.json + // this example is just showing the usage of "TopicAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,28 @@ public async Task GetAll_TopicAuthorizationRuleListAll() // get the collection of this ServiceBusTopicAuthorizationRuleResource ServiceBusTopicAuthorizationRuleCollection collection = serviceBusTopic.GetServiceBusTopicAuthorizationRules(); - // invoke the operation and iterate over the result - await foreach (ServiceBusTopicAuthorizationRuleResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationRuleName = "sdk-AuthRules-4310"; + ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusAuthorizationRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Rights = { ServiceBusAccessRight.Listen, ServiceBusAccessRight.Send }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); + ServiceBusTopicAuthorizationRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TopicAuthorizationRuleCreate() + public async Task Get_TopicAuthorizationRuleGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleCreate.json - // this example is just showing the usage of "TopicAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleGet.json + // this example is just showing the usage of "TopicAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +82,7 @@ public async Task CreateOrUpdate_TopicAuthorizationRuleCreate() // invoke the operation string authorizationRuleName = "sdk-AuthRules-4310"; - ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData() - { - Rights = -{ -ServiceBusAccessRight.Listen,ServiceBusAccessRight.Send -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationRuleName, data); - ServiceBusTopicAuthorizationRuleResource result = lro.Value; + ServiceBusTopicAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -98,10 +93,10 @@ public async Task CreateOrUpdate_TopicAuthorizationRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TopicAuthorizationRuleGet() + public async Task GetAll_TopicAuthorizationRuleListAll() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleGet.json - // this example is just showing the usage of "TopicAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleListAll.json + // this example is just showing the usage of "TopicAuthorizationRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,15 +115,17 @@ public async Task Get_TopicAuthorizationRuleGet() // get the collection of this ServiceBusTopicAuthorizationRuleResource ServiceBusTopicAuthorizationRuleCollection collection = serviceBusTopic.GetServiceBusTopicAuthorizationRules(); - // invoke the operation - string authorizationRuleName = "sdk-AuthRules-4310"; - ServiceBusTopicAuthorizationRuleResource result = await collection.GetAsync(authorizationRuleName); + // invoke the operation and iterate over the result + await foreach (ServiceBusTopicAuthorizationRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusAuthorizationRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicAuthorizationRuleResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicAuthorizationRuleResource.cs index 3c0eb8aae1158..ca86eeb946ed9 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicAuthorizationRuleResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicAuthorizationRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceBusTopicAuthorizationRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TopicAuthorizationRuleCreate() + public async Task Get_TopicAuthorizationRuleGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleCreate.json - // this example is just showing the usage of "TopicAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleGet.json + // this example is just showing the usage of "TopicAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,15 +39,7 @@ public async Task Update_TopicAuthorizationRuleCreate() ServiceBusTopicAuthorizationRuleResource serviceBusTopicAuthorizationRule = client.GetServiceBusTopicAuthorizationRuleResource(serviceBusTopicAuthorizationRuleResourceId); // invoke the operation - ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData() - { - Rights = -{ -ServiceBusAccessRight.Listen,ServiceBusAccessRight.Send -}, - }; - ArmOperation lro = await serviceBusTopicAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); - ServiceBusTopicAuthorizationRuleResource result = lro.Value; + ServiceBusTopicAuthorizationRuleResource result = await serviceBusTopicAuthorizationRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +50,10 @@ public async Task Update_TopicAuthorizationRuleCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TopicAuthorizationRuleGet() + public async Task Delete_TopicAuthorizationRuleDelete() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleGet.json - // this example is just showing the usage of "TopicAuthorizationRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleDelete.json + // this example is just showing the usage of "TopicAuthorizationRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,21 +71,17 @@ public async Task Get_TopicAuthorizationRuleGet() ServiceBusTopicAuthorizationRuleResource serviceBusTopicAuthorizationRule = client.GetServiceBusTopicAuthorizationRuleResource(serviceBusTopicAuthorizationRuleResourceId); // invoke the operation - ServiceBusTopicAuthorizationRuleResource result = await serviceBusTopicAuthorizationRule.GetAsync(); + await serviceBusTopicAuthorizationRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusAuthorizationRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_TopicAuthorizationRuleDelete() + public async Task Update_TopicAuthorizationRuleCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleDelete.json - // this example is just showing the usage of "TopicAuthorizationRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicAuthorizationRuleCreate.json + // this example is just showing the usage of "TopicAuthorizationRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +99,18 @@ public async Task Delete_TopicAuthorizationRuleDelete() ServiceBusTopicAuthorizationRuleResource serviceBusTopicAuthorizationRule = client.GetServiceBusTopicAuthorizationRuleResource(serviceBusTopicAuthorizationRuleResourceId); // invoke the operation - await serviceBusTopicAuthorizationRule.DeleteAsync(WaitUntil.Completed); + ServiceBusAuthorizationRuleData data = new ServiceBusAuthorizationRuleData + { + Rights = { ServiceBusAccessRight.Listen, ServiceBusAccessRight.Send }, + }; + ArmOperation lro = await serviceBusTopicAuthorizationRule.UpdateAsync(WaitUntil.Completed, data); + ServiceBusTopicAuthorizationRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusAuthorizationRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicCollection.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicCollection.cs index 21ab370ec6de9..b9202936d8e9e 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicCollection.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceBusTopicCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TopicGet() + public async Task CreateOrUpdate_TopicCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicListByNameSpace.json - // this example is just showing the usage of "Topics_ListByNamespace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicCreate.json + // this example is just showing the usage of "Topics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task GetAll_TopicGet() // this example assumes you already have this ServiceBusNamespaceResource created on azure // for more information of creating ServiceBusNamespaceResource, please refer to the document of ServiceBusNamespaceResource string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - string resourceGroupName = "Default-ServiceBus-WestUS"; + string resourceGroupName = "ArunMonocle"; string namespaceName = "sdk-Namespace-1617"; ResourceIdentifier serviceBusNamespaceResourceId = ServiceBusNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); ServiceBusNamespaceResource serviceBusNamespace = client.GetServiceBusNamespaceResource(serviceBusNamespaceResourceId); @@ -38,25 +38,28 @@ public async Task GetAll_TopicGet() // get the collection of this ServiceBusTopicResource ServiceBusTopicCollection collection = serviceBusNamespace.GetServiceBusTopics(); - // invoke the operation and iterate over the result - await foreach (ServiceBusTopicResource item in collection.GetAllAsync()) + // invoke the operation + string topicName = "sdk-Topics-5488"; + ServiceBusTopicData data = new ServiceBusTopicData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusTopicData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EnableExpress = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, topicName, data); + ServiceBusTopicResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusTopicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TopicCreate() + public async Task Get_TopicGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicCreate.json - // this example is just showing the usage of "Topics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicGet.json + // this example is just showing the usage of "Topics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,12 +79,7 @@ public async Task CreateOrUpdate_TopicCreate() // invoke the operation string topicName = "sdk-Topics-5488"; - ServiceBusTopicData data = new ServiceBusTopicData() - { - EnableExpress = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, topicName, data); - ServiceBusTopicResource result = lro.Value; + ServiceBusTopicResource result = await collection.GetAsync(topicName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +90,10 @@ public async Task CreateOrUpdate_TopicCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TopicGet() + public async Task GetAll_TopicGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicGet.json - // this example is just showing the usage of "Topics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicListByNameSpace.json + // this example is just showing the usage of "Topics_ListByNamespace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,7 +103,7 @@ public async Task Get_TopicGet() // this example assumes you already have this ServiceBusNamespaceResource created on azure // for more information of creating ServiceBusNamespaceResource, please refer to the document of ServiceBusNamespaceResource string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; - string resourceGroupName = "ArunMonocle"; + string resourceGroupName = "Default-ServiceBus-WestUS"; string namespaceName = "sdk-Namespace-1617"; ResourceIdentifier serviceBusNamespaceResourceId = ServiceBusNamespaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, namespaceName); ServiceBusNamespaceResource serviceBusNamespace = client.GetServiceBusNamespaceResource(serviceBusNamespaceResourceId); @@ -113,15 +111,17 @@ public async Task Get_TopicGet() // get the collection of this ServiceBusTopicResource ServiceBusTopicCollection collection = serviceBusNamespace.GetServiceBusTopics(); - // invoke the operation - string topicName = "sdk-Topics-5488"; - ServiceBusTopicResource result = await collection.GetAsync(topicName); + // invoke the operation and iterate over the result + await foreach (ServiceBusTopicResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusTopicData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceBusTopicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicResource.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicResource.cs index 47b0421855fbb..7d1d0135e4eeb 100644 --- a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicResource.cs +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_ServiceBusTopicResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceBusTopicResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TopicCreate() + public async Task Get_TopicGet() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicCreate.json - // this example is just showing the usage of "Topics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicGet.json + // this example is just showing the usage of "Topics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,12 +37,7 @@ public async Task Update_TopicCreate() ServiceBusTopicResource serviceBusTopic = client.GetServiceBusTopicResource(serviceBusTopicResourceId); // invoke the operation - ServiceBusTopicData data = new ServiceBusTopicData() - { - EnableExpress = true, - }; - ArmOperation lro = await serviceBusTopic.UpdateAsync(WaitUntil.Completed, data); - ServiceBusTopicResource result = lro.Value; + ServiceBusTopicResource result = await serviceBusTopic.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -80,10 +75,10 @@ public async Task Delete_TopicDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TopicGet() + public async Task Update_TopicCreate() { - // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicGet.json - // this example is just showing the usage of "Topics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/Topics/SBTopicCreate.json + // this example is just showing the usage of "Topics_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +95,12 @@ public async Task Get_TopicGet() ServiceBusTopicResource serviceBusTopic = client.GetServiceBusTopicResource(serviceBusTopicResourceId); // invoke the operation - ServiceBusTopicResource result = await serviceBusTopic.GetAsync(); + ServiceBusTopicData data = new ServiceBusTopicData + { + EnableExpress = true, + }; + ArmOperation lro = await serviceBusTopic.UpdateAsync(WaitUntil.Completed, data); + ServiceBusTopicResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..d27429e18ae5e --- /dev/null +++ b/sdk/servicebus/Azure.ResourceManager.ServiceBus/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.ServiceBus.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.ServiceBus.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetServiceBusNamespaces_NameSpaceList() + { + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceList.json + // this example is just showing the usage of "Namespaces_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ServiceBusNamespaceResource item in subscriptionResource.GetServiceBusNamespacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceBusNamespaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckServiceBusNamespaceNameAvailability_NameSpaceCheckNameAvailability() + { + // Generated from example definition: specification/servicebus/resource-manager/Microsoft.ServiceBus/preview/2022-10-01-preview/examples/NameSpaces/SBNameSpaceCheckNameAvailability.json + // this example is just showing the usage of "Namespaces_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5f750a97-50d9-4e36-8081-c9ee4c0210d4"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + ServiceBusNameAvailabilityContent content = new ServiceBusNameAvailabilityContent("sdk-Namespace-2924"); + ServiceBusNameAvailabilityResult result = await subscriptionResource.CheckServiceBusNamespaceNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationCollection.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationCollection.cs index 6b75120b7a337..b26011e63b3c5 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationCollection.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationCollection.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ServiceFabric.Models; @@ -16,112 +17,6 @@ namespace Azure.ResourceManager.ServiceFabric.Samples { public partial class Sample_ServiceFabricApplicationCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnApplication() - { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationGetOperation_example.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceFabricClusterResource created on azure - // for more information of creating ServiceFabricClusterResource, please refer to the document of ServiceFabricClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - string clusterName = "myCluster"; - ResourceIdentifier serviceFabricClusterResourceId = ServiceFabricClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - ServiceFabricClusterResource serviceFabricCluster = client.GetServiceFabricClusterResource(serviceFabricClusterResourceId); - - // get the collection of this ServiceFabricApplicationResource - ServiceFabricApplicationCollection collection = serviceFabricCluster.GetServiceFabricApplications(); - - // invoke the operation - string applicationName = "myApp"; - ServiceFabricApplicationResource result = await collection.GetAsync(applicationName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnApplication() - { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationGetOperation_example.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceFabricClusterResource created on azure - // for more information of creating ServiceFabricClusterResource, please refer to the document of ServiceFabricClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - string clusterName = "myCluster"; - ResourceIdentifier serviceFabricClusterResourceId = ServiceFabricClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - ServiceFabricClusterResource serviceFabricCluster = client.GetServiceFabricClusterResource(serviceFabricClusterResourceId); - - // get the collection of this ServiceFabricApplicationResource - ServiceFabricApplicationCollection collection = serviceFabricCluster.GetServiceFabricApplications(); - - // invoke the operation - string applicationName = "myApp"; - bool result = await collection.ExistsAsync(applicationName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnApplication() - { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationGetOperation_example.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceFabricClusterResource created on azure - // for more information of creating ServiceFabricClusterResource, please refer to the document of ServiceFabricClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - string clusterName = "myCluster"; - ResourceIdentifier serviceFabricClusterResourceId = ServiceFabricClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - ServiceFabricClusterResource serviceFabricCluster = client.GetServiceFabricClusterResource(serviceFabricClusterResourceId); - - // get the collection of this ServiceFabricApplicationResource - ServiceFabricApplicationCollection collection = serviceFabricCluster.GetServiceFabricApplications(); - - // invoke the operation - string applicationName = "myApp"; - NullableResponse response = await collection.GetIfExistsAsync(applicationName); - ServiceFabricApplicationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_PutAnApplicationWithMaximumParameters() @@ -147,31 +42,31 @@ public async Task CreateOrUpdate_PutAnApplicationWithMaximumParameters() // invoke the operation string applicationName = "myApp"; - ServiceFabricApplicationData data = new ServiceFabricApplicationData(new AzureLocation("placeholder")) + ServiceFabricApplicationData data = new ServiceFabricApplicationData(default) { TypeVersion = "1.0", Parameters = { -["param1"] = "value1", +["param1"] = "value1" }, - UpgradePolicy = new ApplicationUpgradePolicy() + UpgradePolicy = new ApplicationUpgradePolicy { - UpgradeReplicaSetCheckTimeout = TimeSpan.Parse("01:00:00"), + UpgradeReplicaSetCheckTimeout = XmlConvert.ToTimeSpan("01:00:00"), ForceRestart = false, - RollingUpgradeMonitoringPolicy = new ArmRollingUpgradeMonitoringPolicy() + RollingUpgradeMonitoringPolicy = new ArmRollingUpgradeMonitoringPolicy { FailureAction = ArmUpgradeFailureAction.Rollback, - HealthCheckWaitDuration = TimeSpan.Parse("00:02:00"), - HealthCheckStableDuration = TimeSpan.Parse("00:05:00"), - HealthCheckRetryTimeout = TimeSpan.Parse("00:10:00"), - UpgradeTimeout = TimeSpan.Parse("01:00:00"), - UpgradeDomainTimeout = TimeSpan.Parse("1.06:00:00"), + HealthCheckWaitDuration = XmlConvert.ToTimeSpan("00:02:00"), + HealthCheckStableDuration = XmlConvert.ToTimeSpan("00:05:00"), + HealthCheckRetryTimeout = XmlConvert.ToTimeSpan("00:10:00"), + UpgradeTimeout = XmlConvert.ToTimeSpan("01:00:00"), + UpgradeDomainTimeout = XmlConvert.ToTimeSpan("1.06:00:00"), }, - ApplicationHealthPolicy = new ArmApplicationHealthPolicy() + ApplicationHealthPolicy = new ArmApplicationHealthPolicy { ConsiderWarningAsError = true, MaxPercentUnhealthyDeployedApplications = 0, - DefaultServiceTypeHealthPolicy = new ArmServiceTypeHealthPolicy() + DefaultServiceTypeHealthPolicy = new ArmServiceTypeHealthPolicy { MaxPercentUnhealthyServices = 0, MaxPercentUnhealthyPartitionsPerService = 0, @@ -183,20 +78,15 @@ public async Task CreateOrUpdate_PutAnApplicationWithMaximumParameters() MinimumNodes = 1L, MaximumNodes = 3L, RemoveApplicationCapacity = false, - Metrics = -{ -new ApplicationMetricDescription() + Metrics = {new ApplicationMetricDescription { Name = "metric1", MaximumCapacity = 3L, ReservationCapacity = 1L, TotalApplicationCapacity = 5L, -} -}, +}}, TypeName = "myAppType", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); ServiceFabricApplicationResource result = lro.Value; @@ -238,9 +128,7 @@ public async Task CreateOrUpdate_PutAnApplicationWithMinimumParameters() TypeVersion = "1.0", RemoveApplicationCapacity = false, TypeName = "myAppType", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); ServiceFabricApplicationResource result = lro.Value; @@ -277,21 +165,19 @@ public async Task CreateOrUpdate_PutAnApplicationWithRecreateOption() // invoke the operation string applicationName = "myApp"; - ServiceFabricApplicationData data = new ServiceFabricApplicationData(new AzureLocation("placeholder")) + ServiceFabricApplicationData data = new ServiceFabricApplicationData(default) { TypeVersion = "1.0", Parameters = { -["param1"] = "value1", +["param1"] = "value1" }, - UpgradePolicy = new ApplicationUpgradePolicy() + UpgradePolicy = new ApplicationUpgradePolicy { RecreateApplication = true, }, TypeName = "myAppType", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); ServiceFabricApplicationResource result = lro.Value; @@ -303,6 +189,40 @@ public async Task CreateOrUpdate_PutAnApplicationWithRecreateOption() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAnApplication() + { + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationGetOperation_example.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceFabricClusterResource created on azure + // for more information of creating ServiceFabricClusterResource, please refer to the document of ServiceFabricClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + string clusterName = "myCluster"; + ResourceIdentifier serviceFabricClusterResourceId = ServiceFabricClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + ServiceFabricClusterResource serviceFabricCluster = client.GetServiceFabricClusterResource(serviceFabricClusterResourceId); + + // get the collection of this ServiceFabricApplicationResource + ServiceFabricApplicationCollection collection = serviceFabricCluster.GetServiceFabricApplications(); + + // invoke the operation + string applicationName = "myApp"; + ServiceFabricApplicationResource result = await collection.GetAsync(applicationName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_GetAListOfApplicationResources() @@ -338,5 +258,77 @@ public async Task GetAll_GetAListOfApplicationResources() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetAnApplication() + { + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationGetOperation_example.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceFabricClusterResource created on azure + // for more information of creating ServiceFabricClusterResource, please refer to the document of ServiceFabricClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + string clusterName = "myCluster"; + ResourceIdentifier serviceFabricClusterResourceId = ServiceFabricClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + ServiceFabricClusterResource serviceFabricCluster = client.GetServiceFabricClusterResource(serviceFabricClusterResourceId); + + // get the collection of this ServiceFabricApplicationResource + ServiceFabricApplicationCollection collection = serviceFabricCluster.GetServiceFabricApplications(); + + // invoke the operation + string applicationName = "myApp"; + bool result = await collection.ExistsAsync(applicationName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetAnApplication() + { + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationGetOperation_example.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceFabricClusterResource created on azure + // for more information of creating ServiceFabricClusterResource, please refer to the document of ServiceFabricClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + string clusterName = "myCluster"; + ResourceIdentifier serviceFabricClusterResourceId = ServiceFabricClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + ServiceFabricClusterResource serviceFabricCluster = client.GetServiceFabricClusterResource(serviceFabricClusterResourceId); + + // get the collection of this ServiceFabricApplicationResource + ServiceFabricApplicationCollection collection = serviceFabricCluster.GetServiceFabricApplications(); + + // invoke the operation + string applicationName = "myApp"; + NullableResponse response = await collection.GetIfExistsAsync(applicationName); + ServiceFabricApplicationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationResource.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationResource.cs index 8bb9c9795e279..8c606371a4e38 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationResource.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAnApplication() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAnApplication() + public async Task Delete_DeleteAnApplication() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationPatchOperation_example.json - // this example is just showing the usage of "Applications_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationDeleteOperation_example.json + // this example is just showing the usage of "Applications_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,40 +69,17 @@ public async Task Update_PatchAnApplication() ServiceFabricApplicationResource serviceFabricApplication = client.GetServiceFabricApplicationResource(serviceFabricApplicationResourceId); // invoke the operation - ServiceFabricApplicationPatch patch = new ServiceFabricApplicationPatch(new AzureLocation("eastus")) - { - TypeVersion = "1.0", - RemoveApplicationCapacity = false, - Metrics = -{ -new ApplicationMetricDescription() -{ -Name = "metric1", -MaximumCapacity = 3L, -ReservationCapacity = 1L, -TotalApplicationCapacity = 5L, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await serviceFabricApplication.UpdateAsync(WaitUntil.Completed, patch); - ServiceFabricApplicationResource result = lro.Value; + await serviceFabricApplication.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnApplication() + public async Task Update_PatchAnApplication() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationDeleteOperation_example.json - // this example is just showing the usage of "Applications_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationPatchOperation_example.json + // this example is just showing the usage of "Applications_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -119,9 +96,27 @@ public async Task Delete_DeleteAnApplication() ServiceFabricApplicationResource serviceFabricApplication = client.GetServiceFabricApplicationResource(serviceFabricApplicationResourceId); // invoke the operation - await serviceFabricApplication.DeleteAsync(WaitUntil.Completed); + ServiceFabricApplicationPatch patch = new ServiceFabricApplicationPatch(new AzureLocation("eastus")) + { + TypeVersion = "1.0", + RemoveApplicationCapacity = false, + Metrics = {new ApplicationMetricDescription +{ +Name = "metric1", +MaximumCapacity = 3L, +ReservationCapacity = 1L, +TotalApplicationCapacity = 5L, +}}, + Tags = { }, + }; + ArmOperation lro = await serviceFabricApplication.UpdateAsync(WaitUntil.Completed, patch); + ServiceFabricApplicationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeCollection.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeCollection.cs index b82277adc552d..4b6684d963061 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeCollection.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceFabricApplicationTypeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnApplicationType() + public async Task CreateOrUpdate_PutAnApplicationType() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNameGetOperation_example.json - // this example is just showing the usage of "ApplicationTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNamePutOperation_example.json + // this example is just showing the usage of "ApplicationTypes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetAnApplicationType() // invoke the operation string applicationTypeName = "myAppType"; - ServiceFabricApplicationTypeResource result = await collection.GetAsync(applicationTypeName); + ServiceFabricApplicationTypeData data = new ServiceFabricApplicationTypeData(default) + { + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationTypeName, data); + ServiceFabricApplicationTypeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetAnApplicationType() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnApplicationType() + public async Task Get_GetAnApplicationType() { // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNameGetOperation_example.json // this example is just showing the usage of "ApplicationTypes_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +79,21 @@ public async Task Exists_GetAnApplicationType() // invoke the operation string applicationTypeName = "myAppType"; - bool result = await collection.ExistsAsync(applicationTypeName); + ServiceFabricApplicationTypeResource result = await collection.GetAsync(applicationTypeName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricApplicationTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnApplicationType() + public async Task GetAll_GetAListOfApplicationTypeNameResources() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNameGetOperation_example.json - // this example is just showing the usage of "ApplicationTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNameListOperation_example.json + // this example is just showing the usage of "ApplicationTypes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +111,25 @@ public async Task GetIfExists_GetAnApplicationType() // get the collection of this ServiceFabricApplicationTypeResource ServiceFabricApplicationTypeCollection collection = serviceFabricCluster.GetServiceFabricApplicationTypes(); - // invoke the operation - string applicationTypeName = "myAppType"; - NullableResponse response = await collection.GetIfExistsAsync(applicationTypeName); - ServiceFabricApplicationTypeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServiceFabricApplicationTypeResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricApplicationTypeData resourceData = result.Data; + ServiceFabricApplicationTypeData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAnApplicationType() + public async Task Exists_GetAnApplicationType() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNamePutOperation_example.json - // this example is just showing the usage of "ApplicationTypes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNameGetOperation_example.json + // this example is just showing the usage of "ApplicationTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,28 +149,17 @@ public async Task CreateOrUpdate_PutAnApplicationType() // invoke the operation string applicationTypeName = "myAppType"; - ServiceFabricApplicationTypeData data = new ServiceFabricApplicationTypeData(new AzureLocation("placeholder")) - { - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationTypeName, data); - ServiceFabricApplicationTypeResource result = lro.Value; + bool result = await collection.ExistsAsync(applicationTypeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricApplicationTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfApplicationTypeNameResources() + public async Task GetIfExists_GetAnApplicationType() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNameListOperation_example.json - // this example is just showing the usage of "ApplicationTypes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNameGetOperation_example.json + // this example is just showing the usage of "ApplicationTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +177,23 @@ public async Task GetAll_GetAListOfApplicationTypeNameResources() // get the collection of this ServiceFabricApplicationTypeResource ServiceFabricApplicationTypeCollection collection = serviceFabricCluster.GetServiceFabricApplicationTypes(); - // invoke the operation and iterate over the result - await foreach (ServiceFabricApplicationTypeResource item in collection.GetAllAsync()) + // invoke the operation + string applicationTypeName = "myAppType"; + NullableResponse response = await collection.GetIfExistsAsync(applicationTypeName); + ServiceFabricApplicationTypeResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricApplicationTypeData resourceData = item.Data; + ServiceFabricApplicationTypeData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeResource.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeResource.cs index a9fb6360725e6..37f8f883e84d6 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeResource.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetAnApplicationType() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutAnApplicationType() + public async Task Delete_DeleteAnApplicationType() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNamePutOperation_example.json - // this example is just showing the usage of "ApplicationTypes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNameDeleteOperation_example.json + // this example is just showing the usage of "ApplicationTypes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,28 +68,17 @@ public async Task Update_PutAnApplicationType() ServiceFabricApplicationTypeResource serviceFabricApplicationType = client.GetServiceFabricApplicationTypeResource(serviceFabricApplicationTypeResourceId); // invoke the operation - ServiceFabricApplicationTypeData data = new ServiceFabricApplicationTypeData(new AzureLocation("placeholder")) - { - Tags = -{ -}, - }; - ArmOperation lro = await serviceFabricApplicationType.UpdateAsync(WaitUntil.Completed, data); - ServiceFabricApplicationTypeResource result = lro.Value; + await serviceFabricApplicationType.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricApplicationTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnApplicationType() + public async Task Update_PutAnApplicationType() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNameDeleteOperation_example.json - // this example is just showing the usage of "ApplicationTypes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeNamePutOperation_example.json + // this example is just showing the usage of "ApplicationTypes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +95,18 @@ public async Task Delete_DeleteAnApplicationType() ServiceFabricApplicationTypeResource serviceFabricApplicationType = client.GetServiceFabricApplicationTypeResource(serviceFabricApplicationTypeResourceId); // invoke the operation - await serviceFabricApplicationType.DeleteAsync(WaitUntil.Completed); + ServiceFabricApplicationTypeData data = new ServiceFabricApplicationTypeData(default) + { + Tags = { }, + }; + ArmOperation lro = await serviceFabricApplicationType.UpdateAsync(WaitUntil.Completed, data); + ServiceFabricApplicationTypeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricApplicationTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeVersionCollection.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeVersionCollection.cs index f2489f0b29182..3193723af1b8c 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeVersionCollection.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeVersionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceFabricApplicationTypeVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnApplicationTypeVersion() + public async Task CreateOrUpdate_PutAnApplicationTypeVersion() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionGetOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionPutOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,13 @@ public async Task Get_GetAnApplicationTypeVersion() // invoke the operation string version = "1.0"; - ServiceFabricApplicationTypeVersionResource result = await collection.GetAsync(version); + ServiceFabricApplicationTypeVersionData data = new ServiceFabricApplicationTypeVersionData(default) + { + AppPackageUri = new Uri("http://fakelink.test.com/MyAppType"), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + ServiceFabricApplicationTypeVersionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +58,7 @@ public async Task Get_GetAnApplicationTypeVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnApplicationTypeVersion() + public async Task Get_GetAnApplicationTypeVersion() { // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionGetOperation_example.json // this example is just showing the usage of "ApplicationTypeVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +82,21 @@ public async Task Exists_GetAnApplicationTypeVersion() // invoke the operation string version = "1.0"; - bool result = await collection.ExistsAsync(version); + ServiceFabricApplicationTypeVersionResource result = await collection.GetAsync(version); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricApplicationTypeVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnApplicationTypeVersion() + public async Task GetAll_GetAListOfApplicationTypeVersionResources() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionGetOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionListOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,31 +115,25 @@ public async Task GetIfExists_GetAnApplicationTypeVersion() // get the collection of this ServiceFabricApplicationTypeVersionResource ServiceFabricApplicationTypeVersionCollection collection = serviceFabricApplicationType.GetServiceFabricApplicationTypeVersions(); - // invoke the operation - string version = "1.0"; - NullableResponse response = await collection.GetIfExistsAsync(version); - ServiceFabricApplicationTypeVersionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServiceFabricApplicationTypeVersionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricApplicationTypeVersionData resourceData = result.Data; + ServiceFabricApplicationTypeVersionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAnApplicationTypeVersion() + public async Task Exists_GetAnApplicationTypeVersion() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionPutOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionGetOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,29 +154,17 @@ public async Task CreateOrUpdate_PutAnApplicationTypeVersion() // invoke the operation string version = "1.0"; - ServiceFabricApplicationTypeVersionData data = new ServiceFabricApplicationTypeVersionData(new AzureLocation("placeholder")) - { - AppPackageUri = new Uri("http://fakelink.test.com/MyAppType"), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - ServiceFabricApplicationTypeVersionResource result = lro.Value; + bool result = await collection.ExistsAsync(version); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricApplicationTypeVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfApplicationTypeVersionResources() + public async Task GetIfExists_GetAnApplicationTypeVersion() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionListOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionGetOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,17 +183,23 @@ public async Task GetAll_GetAListOfApplicationTypeVersionResources() // get the collection of this ServiceFabricApplicationTypeVersionResource ServiceFabricApplicationTypeVersionCollection collection = serviceFabricApplicationType.GetServiceFabricApplicationTypeVersions(); - // invoke the operation and iterate over the result - await foreach (ServiceFabricApplicationTypeVersionResource item in collection.GetAllAsync()) + // invoke the operation + string version = "1.0"; + NullableResponse response = await collection.GetIfExistsAsync(version); + ServiceFabricApplicationTypeVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricApplicationTypeVersionData resourceData = item.Data; + ServiceFabricApplicationTypeVersionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeVersionResource.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeVersionResource.cs index 16866450d2a3d..50850088086f0 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeVersionResource.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricApplicationTypeVersionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAnApplicationTypeVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutAnApplicationTypeVersion() + public async Task Delete_DeleteAnApplicationTypeVersion() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionPutOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionDeleteOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,29 +70,17 @@ public async Task Update_PutAnApplicationTypeVersion() ServiceFabricApplicationTypeVersionResource serviceFabricApplicationTypeVersion = client.GetServiceFabricApplicationTypeVersionResource(serviceFabricApplicationTypeVersionResourceId); // invoke the operation - ServiceFabricApplicationTypeVersionData data = new ServiceFabricApplicationTypeVersionData(new AzureLocation("placeholder")) - { - AppPackageUri = new Uri("http://fakelink.test.com/MyAppType"), - Tags = -{ -}, - }; - ArmOperation lro = await serviceFabricApplicationTypeVersion.UpdateAsync(WaitUntil.Completed, data); - ServiceFabricApplicationTypeVersionResource result = lro.Value; + await serviceFabricApplicationTypeVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricApplicationTypeVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnApplicationTypeVersion() + public async Task Update_PutAnApplicationTypeVersion() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionDeleteOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ApplicationTypeVersionPutOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +98,19 @@ public async Task Delete_DeleteAnApplicationTypeVersion() ServiceFabricApplicationTypeVersionResource serviceFabricApplicationTypeVersion = client.GetServiceFabricApplicationTypeVersionResource(serviceFabricApplicationTypeVersionResourceId); // invoke the operation - await serviceFabricApplicationTypeVersion.DeleteAsync(WaitUntil.Completed); + ServiceFabricApplicationTypeVersionData data = new ServiceFabricApplicationTypeVersionData(default) + { + AppPackageUri = new Uri("http://fakelink.test.com/MyAppType"), + Tags = { }, + }; + ArmOperation lro = await serviceFabricApplicationTypeVersion.UpdateAsync(WaitUntil.Completed, data); + ServiceFabricApplicationTypeVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricApplicationTypeVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricClusterCollection.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricClusterCollection.cs index d9088a942cdfd..da46deb3934ee 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricClusterCollection.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricClusterCollection.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Resources; @@ -17,109 +18,6 @@ namespace Azure.ResourceManager.ServiceFabric.Samples { public partial class Sample_ServiceFabricClusterCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetACluster() - { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ClusterGetOperation_example.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ServiceFabricClusterResource - ServiceFabricClusterCollection collection = resourceGroupResource.GetServiceFabricClusters(); - - // invoke the operation - string clusterName = "myCluster"; - ServiceFabricClusterResource result = await collection.GetAsync(clusterName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACluster() - { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ClusterGetOperation_example.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ServiceFabricClusterResource - ServiceFabricClusterCollection collection = resourceGroupResource.GetServiceFabricClusters(); - - // invoke the operation - string clusterName = "myCluster"; - bool result = await collection.ExistsAsync(clusterName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACluster() - { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ClusterGetOperation_example.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ServiceFabricClusterResource - ServiceFabricClusterCollection collection = resourceGroupResource.GetServiceFabricClusters(); - - // invoke the operation - string clusterName = "myCluster"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - ServiceFabricClusterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_PutAClusterWithMaximumParameters() @@ -146,82 +44,68 @@ public async Task CreateOrUpdate_PutAClusterWithMaximumParameters() string clusterName = "myCluster"; ServiceFabricClusterData data = new ServiceFabricClusterData(new AzureLocation("eastus")) { - AddOnFeatures = -{ -ClusterAddOnFeature.RepairManager,ClusterAddOnFeature.DnsService,ClusterAddOnFeature.BackupRestoreService,ClusterAddOnFeature.ResourceMonitorService -}, - AzureActiveDirectory = new ClusterAadSetting() + AddOnFeatures = { ClusterAddOnFeature.RepairManager, ClusterAddOnFeature.DnsService, ClusterAddOnFeature.BackupRestoreService, ClusterAddOnFeature.ResourceMonitorService }, + AzureActiveDirectory = new ClusterAadSetting { TenantId = Guid.Parse("6abcc6a0-8666-43f1-87b8-172cf86a9f9c"), ClusterApplication = "5886372e-7bf4-4878-a497-8098aba608ae", ClientApplication = "d151ad89-4bce-4ae8-b3d1-1dc79679fa75", }, - CertificateCommonNames = new ClusterServerCertificateCommonNames() + CertificateCommonNames = new ClusterServerCertificateCommonNames { - CommonNames = -{ -new ClusterServerCertificateCommonName("abc.com",BinaryData.FromString("\"12599211F8F14C90AFA9532AD79A6F2CA1C00622\"")) -}, + CommonNames = { new ClusterServerCertificateCommonName("abc.com", BinaryData.FromObjectAsJson("12599211F8F14C90AFA9532AD79A6F2CA1C00622")) }, X509StoreName = ClusterCertificateStoreName.My, }, - ClientCertificateCommonNames = -{ -new ClusterClientCertificateCommonName(true,"abc.com",BinaryData.FromString("\"5F3660C715EBBDA31DB1FFDCF508302348DE8E7A\"")) -}, - ClientCertificateThumbprints = -{ -new ClusterClientCertificateThumbprint(true,BinaryData.FromString("\"5F3660C715EBBDA31DB1FFDCF508302348DE8E7A\"")) -}, + ClientCertificateCommonNames = { new ClusterClientCertificateCommonName(true, "abc.com", BinaryData.FromObjectAsJson("5F3660C715EBBDA31DB1FFDCF508302348DE8E7A")) }, + ClientCertificateThumbprints = { new ClusterClientCertificateThumbprint(true, BinaryData.FromObjectAsJson("5F3660C715EBBDA31DB1FFDCF508302348DE8E7A")) }, ClusterCodeVersion = "7.0.470.9590", DiagnosticsStorageAccountConfig = new DiagnosticsStorageAccountConfig("diag", "StorageAccountKey1", new Uri("https://diag.blob.core.windows.net/"), new Uri("https://diag.queue.core.windows.net/"), new Uri("https://diag.table.core.windows.net/")), IsEventStoreServiceEnabled = true, - FabricSettings = + FabricSettings = {new SettingsSectionDescription("UpgradeService", new SettingsParameterDescription[] { -new SettingsSectionDescription("UpgradeService",new SettingsParameterDescription[] -{ -new SettingsParameterDescription("AppPollIntervalInSeconds","60") -}) -}, +new SettingsParameterDescription("AppPollIntervalInSeconds", "60") +})}, ManagementEndpoint = new Uri("https://myCluster.eastus.cloudapp.azure.com:19080"), - NodeTypes = -{ -new ClusterNodeTypeDescription("nt1vm",19000,19007,true,5) + NodeTypes = {new ClusterNodeTypeDescription("nt1vm", 19000, 19007, true, 5) { DurabilityLevel = ClusterDurabilityLevel.Silver, -ApplicationPorts = new ClusterEndpointRangeDescription(20000,30000), -EphemeralPorts = new ClusterEndpointRangeDescription(49000,64000), +ApplicationPorts = new ClusterEndpointRangeDescription(20000, 30000), +EphemeralPorts = new ClusterEndpointRangeDescription(49000, 64000), IsStateless = false, IsMultipleAvailabilityZonesSupported = true, HttpGatewayTokenAuthEndpointPort = 19081, -} -}, +}}, ReliabilityLevel = ClusterReliabilityLevel.Platinum, - ReverseProxyCertificateCommonNames = new ClusterServerCertificateCommonNames() + ReverseProxyCertificateCommonNames = new ClusterServerCertificateCommonNames { - CommonNames = -{ -new ClusterServerCertificateCommonName("abc.com",BinaryData.FromString("\"12599211F8F14C90AFA9532AD79A6F2CA1C00622\"")) -}, + CommonNames = { new ClusterServerCertificateCommonName("abc.com", BinaryData.FromObjectAsJson("12599211F8F14C90AFA9532AD79A6F2CA1C00622")) }, X509StoreName = ClusterCertificateStoreName.My, }, - UpgradeDescription = new ClusterUpgradePolicy(TimeSpan.Parse("00:10:00"), TimeSpan.Parse("00:00:30"), TimeSpan.Parse("00:00:30"), TimeSpan.Parse("00:05:00"), TimeSpan.Parse("01:00:00"), TimeSpan.Parse("00:15:00"), new ClusterHealthPolicy() + UpgradeDescription = new ClusterUpgradePolicy( + XmlConvert.ToTimeSpan("00:10:00"), + XmlConvert.ToTimeSpan("00:00:30"), + XmlConvert.ToTimeSpan("00:00:30"), + XmlConvert.ToTimeSpan("00:05:00"), + XmlConvert.ToTimeSpan("01:00:00"), + XmlConvert.ToTimeSpan("00:15:00"), + new ClusterHealthPolicy { MaxPercentUnhealthyNodes = 0, MaxPercentUnhealthyApplications = 0, ApplicationHealthPolicies = -{ -["fabric:/myApp1"] = new ApplicationHealthPolicy() + { +["fabric:/myApp1"] = new ApplicationHealthPolicy { MaxPercentUnhealthyServices = 0, ServiceTypeHealthPolicies = { -["myServiceType1"] = new ServiceTypeHealthPolicy() +["myServiceType1"] = new ServiceTypeHealthPolicy { MaxPercentUnhealthyServices = 100, +} }, -}, -}, -}, +} + }, }) { ForceRestart = false, @@ -229,17 +113,17 @@ public async Task CreateOrUpdate_PutAClusterWithMaximumParameters() { ApplicationDeltaHealthPolicies = { -["fabric:/myApp1"] = new ApplicationDeltaHealthPolicy() +["fabric:/myApp1"] = new ApplicationDeltaHealthPolicy { MaxPercentDeltaUnhealthyServices = 0, ServiceTypeDeltaHealthPolicies = { -["myServiceType1"] = new ServiceTypeDeltaHealthPolicy() +["myServiceType1"] = new ServiceTypeDeltaHealthPolicy { MaxPercentDeltaUnhealthyServices = 0, +} }, -}, -}, +} }, }, }, @@ -252,32 +136,17 @@ public async Task CreateOrUpdate_PutAClusterWithMaximumParameters() UpgradeWave = ClusterUpgradeCadence.Wave1, UpgradePauseStartOn = DateTimeOffset.Parse("2021-06-21T22:00:00Z"), UpgradePauseEndOn = DateTimeOffset.Parse("2021-06-25T22:00:00Z"), - Notifications = -{ -new ClusterNotification(true,ClusterNotificationCategory.WaveProgress,ClusterNotificationLevel.Critical,new ClusterNotificationTarget[] -{ -new ClusterNotificationTarget(ClusterNotificationChannel.EmailUser,new string[] -{ -"****@microsoft.com","****@microsoft.com" -}),new ClusterNotificationTarget(ClusterNotificationChannel.EmailSubscription,new string[] + Notifications = {new ClusterNotification(true, ClusterNotificationCategory.WaveProgress, ClusterNotificationLevel.Critical, new ClusterNotificationTarget[] { -"Owner","AccountAdmin" -}) -}),new ClusterNotification(true,ClusterNotificationCategory.WaveProgress,ClusterNotificationLevel.All,new ClusterNotificationTarget[] +new ClusterNotificationTarget(ClusterNotificationChannel.EmailUser, new string[]{"****@microsoft.com", "****@microsoft.com"}), +new ClusterNotificationTarget(ClusterNotificationChannel.EmailSubscription, new string[]{"Owner", "AccountAdmin"}) +}), new ClusterNotification(true, ClusterNotificationCategory.WaveProgress, ClusterNotificationLevel.All, new ClusterNotificationTarget[] { -new ClusterNotificationTarget(ClusterNotificationChannel.EmailUser,new string[] -{ -"****@microsoft.com","****@microsoft.com" -}),new ClusterNotificationTarget(ClusterNotificationChannel.EmailSubscription,new string[] -{ -"Owner","AccountAdmin" -}) -}) -}, +new ClusterNotificationTarget(ClusterNotificationChannel.EmailUser, new string[]{"****@microsoft.com", "****@microsoft.com"}), +new ClusterNotificationTarget(ClusterNotificationChannel.EmailSubscription, new string[]{"Owner", "AccountAdmin"}) +})}, IsHttpGatewayExclusiveAuthModeEnabled = true, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); ServiceFabricClusterResource result = lro.Value; @@ -316,28 +185,20 @@ public async Task CreateOrUpdate_PutAClusterWithMinimumParameters() ServiceFabricClusterData data = new ServiceFabricClusterData(new AzureLocation("eastus")) { DiagnosticsStorageAccountConfig = new DiagnosticsStorageAccountConfig("diag", "StorageAccountKey1", new Uri("https://diag.blob.core.windows.net/"), new Uri("https://diag.queue.core.windows.net/"), new Uri("https://diag.table.core.windows.net/")), - FabricSettings = -{ -new SettingsSectionDescription("UpgradeService",new SettingsParameterDescription[] + FabricSettings = {new SettingsSectionDescription("UpgradeService", new SettingsParameterDescription[] { -new SettingsParameterDescription("AppPollIntervalInSeconds","60") -}) -}, +new SettingsParameterDescription("AppPollIntervalInSeconds", "60") +})}, ManagementEndpoint = new Uri("http://myCluster.eastus.cloudapp.azure.com:19080"), - NodeTypes = -{ -new ClusterNodeTypeDescription("nt1vm",19000,19007,true,5) + NodeTypes = {new ClusterNodeTypeDescription("nt1vm", 19000, 19007, true, 5) { DurabilityLevel = ClusterDurabilityLevel.Bronze, -ApplicationPorts = new ClusterEndpointRangeDescription(20000,30000), -EphemeralPorts = new ClusterEndpointRangeDescription(49000,64000), -} -}, +ApplicationPorts = new ClusterEndpointRangeDescription(20000, 30000), +EphemeralPorts = new ClusterEndpointRangeDescription(49000, 64000), +}}, ReliabilityLevel = ClusterReliabilityLevel.Silver, UpgradeMode = ClusterUpgradeMode.Automatic, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); ServiceFabricClusterResource result = lro.Value; @@ -349,6 +210,39 @@ public async Task CreateOrUpdate_PutAClusterWithMinimumParameters() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetACluster() + { + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ClusterGetOperation_example.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ServiceFabricClusterResource + ServiceFabricClusterCollection collection = resourceGroupResource.GetServiceFabricClusters(); + + // invoke the operation + string clusterName = "myCluster"; + ServiceFabricClusterResource result = await collection.GetAsync(clusterName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListClusterByResourceGroup() @@ -383,5 +277,75 @@ public async Task GetAll_ListClusterByResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetACluster() + { + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ClusterGetOperation_example.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ServiceFabricClusterResource + ServiceFabricClusterCollection collection = resourceGroupResource.GetServiceFabricClusters(); + + // invoke the operation + string clusterName = "myCluster"; + bool result = await collection.ExistsAsync(clusterName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetACluster() + { + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ClusterGetOperation_example.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ServiceFabricClusterResource + ServiceFabricClusterCollection collection = resourceGroupResource.GetServiceFabricClusters(); + + // invoke the operation + string clusterName = "myCluster"; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + ServiceFabricClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricClusterResource.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricClusterResource.cs index ae3459af1dd82..0f8c18791c79f 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricClusterResource.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricClusterResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.ServiceFabric.Models; using NUnit.Framework; @@ -47,6 +46,32 @@ public async Task Get_GetACluster() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteACluster() + { + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ClusterDeleteOperation_example.json + // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceFabricClusterResource created on azure + // for more information of creating ServiceFabricClusterResource, please refer to the document of ServiceFabricClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + string clusterName = "myCluster"; + ResourceIdentifier serviceFabricClusterResourceId = ServiceFabricClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + ServiceFabricClusterResource serviceFabricCluster = client.GetServiceFabricClusterResource(serviceFabricClusterResourceId); + + // invoke the operation + await serviceFabricCluster.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_PatchACluster() @@ -68,29 +93,26 @@ public async Task Update_PatchACluster() ServiceFabricClusterResource serviceFabricCluster = client.GetServiceFabricClusterResource(serviceFabricClusterResourceId); // invoke the operation - ServiceFabricClusterPatch patch = new ServiceFabricClusterPatch() + ServiceFabricClusterPatch patch = new ServiceFabricClusterPatch { Tags = { -["a"] = "b", +["a"] = "b" }, IsEventStoreServiceEnabled = true, - NodeTypes = -{ -new ClusterNodeTypeDescription("nt1vm",19000,19007,true,5) + NodeTypes = {new ClusterNodeTypeDescription("nt1vm", 19000, 19007, true, 5) { DurabilityLevel = ClusterDurabilityLevel.Bronze, -ApplicationPorts = new ClusterEndpointRangeDescription(20000,30000), -EphemeralPorts = new ClusterEndpointRangeDescription(49000,64000), +ApplicationPorts = new ClusterEndpointRangeDescription(20000, 30000), +EphemeralPorts = new ClusterEndpointRangeDescription(49000, 64000), HttpGatewayTokenAuthEndpointPort = 19081, -},new ClusterNodeTypeDescription("testnt1",0,0,false,3) +}, new ClusterNodeTypeDescription("testnt1", 0, 0, false, 3) { DurabilityLevel = ClusterDurabilityLevel.Bronze, -ApplicationPorts = new ClusterEndpointRangeDescription(1000,2000), -EphemeralPorts = new ClusterEndpointRangeDescription(3000,4000), +ApplicationPorts = new ClusterEndpointRangeDescription(1000, 2000), +EphemeralPorts = new ClusterEndpointRangeDescription(3000, 4000), HttpGatewayTokenAuthEndpointPort = 19081, -} -}, +}}, ReliabilityLevel = ClusterReliabilityLevel.Bronze, UpgradeMode = ClusterUpgradeMode.Automatic, UpgradeWave = new ClusterUpgradeCadence("Wave"), @@ -108,63 +130,6 @@ public async Task Update_PatchACluster() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACluster() - { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ClusterDeleteOperation_example.json - // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceFabricClusterResource created on azure - // for more information of creating ServiceFabricClusterResource, please refer to the document of ServiceFabricClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - string clusterName = "myCluster"; - ResourceIdentifier serviceFabricClusterResourceId = ServiceFabricClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - ServiceFabricClusterResource serviceFabricCluster = client.GetServiceFabricClusterResource(serviceFabricClusterResourceId); - - // invoke the operation - await serviceFabricCluster.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetServiceFabricClusters_ListClusters() - { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ClusterListOperation_example.json - // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ServiceFabricClusterResource item in subscriptionResource.GetServiceFabricClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetUpgradableVersions_GetMinimumAndMaximumCodeVersions() diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricServiceCollection.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricServiceCollection.cs index 3b90b7746cc84..0bc1a87c8d131 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricServiceCollection.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricServiceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceFabricServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAService() + public async Task CreateOrUpdate_PutAServiceWithMaximumParameters() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServiceGetOperation_example.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServicePutOperation_example_max.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,24 @@ public async Task Get_GetAService() // invoke the operation string serviceName = "myService"; - ServiceFabricServiceResource result = await collection.GetAsync(serviceName); + ServiceFabricServiceData data = new ServiceFabricServiceData(default) + { + PlacementConstraints = "NodeType==frontend", + CorrelationScheme = { new ServiceCorrelationDescription(ServiceCorrelationScheme.Affinity, "fabric:/app1/app1~svc1") }, + ServiceLoadMetrics = {new ServiceLoadMetricDescription("metric1") +{ +Weight = ServiceLoadMetricWeight.Low, +}}, + ServicePlacementPolicies = { }, + DefaultMoveCost = ApplicationMoveCost.Medium, + ServiceTypeName = "myServiceType", + PartitionDescription = new SingletonPartitionSchemeDescription(), + ServicePackageActivationMode = ArmServicePackageActivationMode.SharedProcess, + ServiceDnsName = "my.service.dns", + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); + ServiceFabricServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +70,10 @@ public async Task Get_GetAService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAService() + public async Task CreateOrUpdate_PutAServiceWithMinimumParameters() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServiceGetOperation_example.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServicePutOperation_example_min.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,14 +94,25 @@ public async Task Exists_GetAService() // invoke the operation string serviceName = "myService"; - bool result = await collection.ExistsAsync(serviceName); + ServiceFabricServiceData data = new ServiceFabricServiceData(default) + { + ServiceTypeName = "myServiceType", + PartitionDescription = new SingletonPartitionSchemeDescription(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); + ServiceFabricServiceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAService() + public async Task Get_GetAService() { // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServiceGetOperation_example.json // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,29 +136,21 @@ public async Task GetIfExists_GetAService() // invoke the operation string serviceName = "myService"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - ServiceFabricServiceResource result = response.HasValue ? response.Value : null; + ServiceFabricServiceResource result = await collection.GetAsync(serviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAServiceWithMaximumParameters() + public async Task GetAll_GetAListOfServiceResources() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServicePutOperation_example_max.json - // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServiceListOperation_example.json + // this example is just showing the usage of "Services_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,50 +169,25 @@ public async Task CreateOrUpdate_PutAServiceWithMaximumParameters() // get the collection of this ServiceFabricServiceResource ServiceFabricServiceCollection collection = serviceFabricApplication.GetServiceFabricServices(); - // invoke the operation - string serviceName = "myService"; - ServiceFabricServiceData data = new ServiceFabricServiceData(new AzureLocation("placeholder")) + // invoke the operation and iterate over the result + await foreach (ServiceFabricServiceResource item in collection.GetAllAsync()) { - PlacementConstraints = "NodeType==frontend", - CorrelationScheme = -{ -new ServiceCorrelationDescription(ServiceCorrelationScheme.Affinity,"fabric:/app1/app1~svc1") -}, - ServiceLoadMetrics = -{ -new ServiceLoadMetricDescription("metric1") -{ -Weight = ServiceLoadMetricWeight.Low, -} -}, - ServicePlacementPolicies = -{ -}, - DefaultMoveCost = ApplicationMoveCost.Medium, - ServiceTypeName = "myServiceType", - PartitionDescription = new SingletonPartitionSchemeDescription(), - ServicePackageActivationMode = ArmServicePackageActivationMode.SharedProcess, - ServiceDnsName = "my.service.dns", - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); - ServiceFabricServiceResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAServiceWithMinimumParameters() + public async Task Exists_GetAService() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServicePutOperation_example_min.json - // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServiceGetOperation_example.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,30 +208,17 @@ public async Task CreateOrUpdate_PutAServiceWithMinimumParameters() // invoke the operation string serviceName = "myService"; - ServiceFabricServiceData data = new ServiceFabricServiceData(new AzureLocation("placeholder")) - { - ServiceTypeName = "myServiceType", - PartitionDescription = new SingletonPartitionSchemeDescription(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); - ServiceFabricServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(serviceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfServiceResources() + public async Task GetIfExists_GetAService() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServiceListOperation_example.json - // this example is just showing the usage of "Services_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServiceGetOperation_example.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -255,17 +237,23 @@ public async Task GetAll_GetAListOfServiceResources() // get the collection of this ServiceFabricServiceResource ServiceFabricServiceCollection collection = serviceFabricApplication.GetServiceFabricServices(); - // invoke the operation and iterate over the result - await foreach (ServiceFabricServiceResource item in collection.GetAllAsync()) + // invoke the operation + string serviceName = "myService"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + ServiceFabricServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricServiceData resourceData = item.Data; + ServiceFabricServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricServiceResource.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricServiceResource.cs index 1f0c931e581da..67f5a2f67f6a2 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricServiceResource.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricServiceResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetAService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAService() + public async Task Delete_DeleteAService() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServicePatchOperation_example.json - // this example is just showing the usage of "Services_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServiceDeleteOperation_example.json + // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,35 +71,17 @@ public async Task Update_PatchAService() ServiceFabricServiceResource serviceFabricService = client.GetServiceFabricServiceResource(serviceFabricServiceResourceId); // invoke the operation - ServiceFabricServicePatch patch = new ServiceFabricServicePatch(new AzureLocation("placeholder")) - { - ServiceLoadMetrics = -{ -new ServiceLoadMetricDescription("metric1") -{ -Weight = ServiceLoadMetricWeight.Low, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await serviceFabricService.UpdateAsync(WaitUntil.Completed, patch); - ServiceFabricServiceResource result = lro.Value; + await serviceFabricService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAService() + public async Task Update_PatchAService() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServiceDeleteOperation_example.json - // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ServicePatchOperation_example.json + // this example is just showing the usage of "Services_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,9 +99,22 @@ public async Task Delete_DeleteAService() ServiceFabricServiceResource serviceFabricService = client.GetServiceFabricServiceResource(serviceFabricServiceResourceId); // invoke the operation - await serviceFabricService.DeleteAsync(WaitUntil.Completed); + ServiceFabricServicePatch patch = new ServiceFabricServicePatch(default) + { + ServiceLoadMetrics = {new ServiceLoadMetricDescription("metric1") +{ +Weight = ServiceLoadMetricWeight.Low, +}}, + Tags = { }, + }; + ArmOperation lro = await serviceFabricService.UpdateAsync(WaitUntil.Completed, patch); + ServiceFabricServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricVmSizeResourceCollection.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricVmSizeResourceCollection.cs index cc1ad41dc6000..7c2f8a88c1e1c 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricVmSizeResourceCollection.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_ServiceFabricVmSizeResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceFabricVmSizeResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListUnsupportedVmSizes() + public async Task Get_GetUnsupportedVmSizes() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/UnsupportedVMSizesList_example.json - // this example is just showing the usage of "UnsupportedVmSizes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/UnsupportedVMSizesGet_example.json + // this example is just showing the usage of "UnsupportedVmSizes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListUnsupportedVmSizes() AzureLocation location = new AzureLocation("eastus"); ServiceFabricVmSizeResourceCollection collection = subscriptionResource.GetServiceFabricVmSizeResources(location); - // invoke the operation and iterate over the result - await foreach (ServiceFabricVmSizeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricVmSizeResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string vmSize = "Standard_B1ls1"; + ServiceFabricVmSizeResource result = await collection.GetAsync(vmSize); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricVmSizeResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetUnsupportedVmSizes() + public async Task GetAll_ListUnsupportedVmSizes() { - // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/UnsupportedVMSizesGet_example.json - // this example is just showing the usage of "UnsupportedVmSizes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/UnsupportedVMSizesList_example.json + // this example is just showing the usage of "UnsupportedVmSizes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetUnsupportedVmSizes() AzureLocation location = new AzureLocation("eastus"); ServiceFabricVmSizeResourceCollection collection = subscriptionResource.GetServiceFabricVmSizeResources(location); - // invoke the operation - string vmSize = "Standard_B1ls1"; - ServiceFabricVmSizeResource result = await collection.GetAsync(vmSize); + // invoke the operation and iterate over the result + await foreach (ServiceFabricVmSizeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricVmSizeResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricVmSizeResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 692a613312618..766b893ae74f8 100644 --- a/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/servicefabric/Azure.ResourceManager.ServiceFabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.ServiceFabric.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetServiceFabricClusters_ListClusters() + { + // Generated from example definition: specification/servicefabric/resource-manager/Microsoft.ServiceFabric/preview/2023-11-01-preview/examples/ClusterListOperation_example.json + // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ServiceFabricClusterResource item in subscriptionResource.GetServiceFabricClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetClusterVersions_GetClusterVersion() diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationCollection.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationCollection.cs index 677136d881431..2b3a346a5797b 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationCollection.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationCollection.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ServiceFabricManagedClusters.Models; @@ -18,10 +19,10 @@ public partial class Sample_ServiceFabricManagedApplicationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnApplication() + public async Task CreateOrUpdate_PutAnApplicationWithMaximumParameters() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationGetOperation_example.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationPutOperation_example_max.json + // this example is just showing the usage of "Applications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +42,43 @@ public async Task Get_GetAnApplication() // invoke the operation string applicationName = "myApp"; - ServiceFabricManagedApplicationResource result = await collection.GetAsync(applicationName); + ServiceFabricManagedApplicationData data = new ServiceFabricManagedApplicationData(new AzureLocation("eastus")) + { + Version = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/managedclusters/myCluster/applicationTypes/myAppType/versions/1.0", + Parameters = +{ +["param1"] = "value1" +}, + UpgradePolicy = new ApplicationUpgradePolicy + { + ApplicationHealthPolicy = new ApplicationHealthPolicy(true, 0) + { + DefaultServiceTypeHealthPolicy = new ServiceTypeHealthPolicy(0, 0, 0), + ServiceTypeHealthPolicyMap = +{ +["service1"] = new ServiceTypeHealthPolicy(30, 30, 30) +}, + }, + ForceRestart = false, + RollingUpgradeMonitoringPolicy = new RollingUpgradeMonitoringPolicy( + PolicyViolationCompensationAction.Rollback, + XmlConvert.ToTimeSpan("00:02:00"), + XmlConvert.ToTimeSpan("00:05:00"), + XmlConvert.ToTimeSpan("00:10:00"), + XmlConvert.ToTimeSpan("01:00:00"), + XmlConvert.ToTimeSpan("00:15:00")), + InstanceCloseDelayDurationInSeconds = 600L, + UpgradeMode = RollingUpgradeMode.UnmonitoredAuto, + UpgradeReplicaSetCheckTimeout = 3600L, + RecreateApplication = false, + }, + Tags = +{ +["a"] = "b" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); + ServiceFabricManagedApplicationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +89,10 @@ public async Task Get_GetAnApplication() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnApplication() + public async Task CreateOrUpdate_PutAnApplicationWithMinimumParameters() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationGetOperation_example.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationPutOperation_example_min.json + // this example is just showing the usage of "Applications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +112,23 @@ public async Task Exists_GetAnApplication() // invoke the operation string applicationName = "myApp"; - bool result = await collection.ExistsAsync(applicationName); + ServiceFabricManagedApplicationData data = new ServiceFabricManagedApplicationData(new AzureLocation("eastus")) + { + Version = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/managedclusters/myCluster/applicationTypes/myAppType/versions/1.0", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); + ServiceFabricManagedApplicationResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnApplication() + public async Task Get_GetAnApplication() { // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationGetOperation_example.json // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +151,21 @@ public async Task GetIfExists_GetAnApplication() // invoke the operation string applicationName = "myApp"; - NullableResponse response = await collection.GetIfExistsAsync(applicationName); - ServiceFabricManagedApplicationResource result = response.HasValue ? response.Value : null; + ServiceFabricManagedApplicationResource result = await collection.GetAsync(applicationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAnApplicationWithMaximumParameters() + public async Task GetAll_GetAListOfApplicationResources() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationPutOperation_example_max.json - // this example is just showing the usage of "Applications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationListOperation_example.json + // this example is just showing the usage of "Applications_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,53 +183,25 @@ public async Task CreateOrUpdate_PutAnApplicationWithMaximumParameters() // get the collection of this ServiceFabricManagedApplicationResource ServiceFabricManagedApplicationCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedApplications(); - // invoke the operation - string applicationName = "myApp"; - ServiceFabricManagedApplicationData data = new ServiceFabricManagedApplicationData(new AzureLocation("eastus")) + // invoke the operation and iterate over the result + await foreach (ServiceFabricManagedApplicationResource item in collection.GetAllAsync()) { - Version = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/managedclusters/myCluster/applicationTypes/myAppType/versions/1.0", - Parameters = -{ -["param1"] = "value1", -}, - UpgradePolicy = new ApplicationUpgradePolicy() - { - ApplicationHealthPolicy = new ApplicationHealthPolicy(true, 0) - { - DefaultServiceTypeHealthPolicy = new ServiceTypeHealthPolicy(0, 0, 0), - ServiceTypeHealthPolicyMap = -{ -["service1"] = new ServiceTypeHealthPolicy(30,30,30), -}, - }, - ForceRestart = false, - RollingUpgradeMonitoringPolicy = new RollingUpgradeMonitoringPolicy(PolicyViolationCompensationAction.Rollback, TimeSpan.Parse("00:02:00"), TimeSpan.Parse("00:05:00"), TimeSpan.Parse("00:10:00"), TimeSpan.Parse("01:00:00"), TimeSpan.Parse("00:15:00")), - InstanceCloseDelayDurationInSeconds = 600L, - UpgradeMode = RollingUpgradeMode.UnmonitoredAuto, - UpgradeReplicaSetCheckTimeout = 3600L, - RecreateApplication = false, - }, - Tags = -{ -["a"] = "b", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); - ServiceFabricManagedApplicationResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedApplicationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAnApplicationWithMinimumParameters() + public async Task Exists_GetAnApplication() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationPutOperation_example_min.json - // this example is just showing the usage of "Applications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationGetOperation_example.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -211,26 +221,17 @@ public async Task CreateOrUpdate_PutAnApplicationWithMinimumParameters() // invoke the operation string applicationName = "myApp"; - ServiceFabricManagedApplicationData data = new ServiceFabricManagedApplicationData(new AzureLocation("eastus")) - { - Version = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/managedclusters/myCluster/applicationTypes/myAppType/versions/1.0", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); - ServiceFabricManagedApplicationResource result = lro.Value; + bool result = await collection.ExistsAsync(applicationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfApplicationResources() + public async Task GetIfExists_GetAnApplication() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationListOperation_example.json - // this example is just showing the usage of "Applications_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationGetOperation_example.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -248,17 +249,23 @@ public async Task GetAll_GetAListOfApplicationResources() // get the collection of this ServiceFabricManagedApplicationResource ServiceFabricManagedApplicationCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedApplications(); - // invoke the operation and iterate over the result - await foreach (ServiceFabricManagedApplicationResource item in collection.GetAllAsync()) + // invoke the operation + string applicationName = "myApp"; + NullableResponse response = await collection.GetIfExistsAsync(applicationName); + ServiceFabricManagedApplicationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationData resourceData = item.Data; + ServiceFabricManagedApplicationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationResource.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationResource.cs index 5845030d1ad9d..9f6bc0d51e6a3 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationResource.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceFabricManagedApplicationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task ReadUpgrade_GetAnApplicationUpgrade() + public async Task Get_GetAnApplication() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationActionGetUpgrade_example.json - // this example is just showing the usage of "Applications_ReadUpgrade" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationGetOperation_example.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task ReadUpgrade_GetAnApplicationUpgrade() ServiceFabricManagedApplicationResource serviceFabricManagedApplication = client.GetServiceFabricManagedApplicationResource(serviceFabricManagedApplicationResourceId); // invoke the operation - await serviceFabricManagedApplication.ReadUpgradeAsync(WaitUntil.Completed); + ServiceFabricManagedApplicationResource result = await serviceFabricManagedApplication.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task StartRollback_StartAnApplicationUpgradeRollback() + public async Task Delete_DeleteAnApplication() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationActionStartRollback_example.json - // this example is just showing the usage of "Applications_StartRollback" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationDeleteOperation_example.json + // this example is just showing the usage of "Applications_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,17 +69,17 @@ public async Task StartRollback_StartAnApplicationUpgradeRollback() ServiceFabricManagedApplicationResource serviceFabricManagedApplication = client.GetServiceFabricManagedApplicationResource(serviceFabricManagedApplicationResourceId); // invoke the operation - await serviceFabricManagedApplication.StartRollbackAsync(WaitUntil.Completed); + await serviceFabricManagedApplication.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ResumeUpgrade_ResumeUpgrade() + public async Task Update_PatchAnApplication() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationActionResumeUpgrade_example.json - // this example is just showing the usage of "Applications_ResumeUpgrade" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationPatchOperation_example.json + // this example is just showing the usage of "Applications_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,21 +96,28 @@ public async Task ResumeUpgrade_ResumeUpgrade() ServiceFabricManagedApplicationResource serviceFabricManagedApplication = client.GetServiceFabricManagedApplicationResource(serviceFabricManagedApplicationResourceId); // invoke the operation - RuntimeResumeApplicationUpgradeContent content = new RuntimeResumeApplicationUpgradeContent() + ServiceFabricManagedApplicationPatch patch = new ServiceFabricManagedApplicationPatch { - UpgradeDomainName = "UD1", + Tags = +{ +["a"] = "b" +}, }; - await serviceFabricManagedApplication.ResumeUpgradeAsync(WaitUntil.Completed, content); + ServiceFabricManagedApplicationResource result = await serviceFabricManagedApplication.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnApplication() + public async Task ReadUpgrade_GetAnApplicationUpgrade() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationGetOperation_example.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationActionGetUpgrade_example.json + // this example is just showing the usage of "Applications_ReadUpgrade" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -123,21 +134,17 @@ public async Task Get_GetAnApplication() ServiceFabricManagedApplicationResource serviceFabricManagedApplication = client.GetServiceFabricManagedApplicationResource(serviceFabricManagedApplicationResourceId); // invoke the operation - ServiceFabricManagedApplicationResource result = await serviceFabricManagedApplication.GetAsync(); + await serviceFabricManagedApplication.ReadUpgradeAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAnApplication() + public async Task StartRollback_StartAnApplicationUpgradeRollback() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationPatchOperation_example.json - // this example is just showing the usage of "Applications_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationActionStartRollback_example.json + // this example is just showing the usage of "Applications_StartRollback" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -154,28 +161,17 @@ public async Task Update_PatchAnApplication() ServiceFabricManagedApplicationResource serviceFabricManagedApplication = client.GetServiceFabricManagedApplicationResource(serviceFabricManagedApplicationResourceId); // invoke the operation - ServiceFabricManagedApplicationPatch patch = new ServiceFabricManagedApplicationPatch() - { - Tags = -{ -["a"] = "b", -}, - }; - ServiceFabricManagedApplicationResource result = await serviceFabricManagedApplication.UpdateAsync(patch); + await serviceFabricManagedApplication.StartRollbackAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnApplication() + public async Task ResumeUpgrade_ResumeUpgrade() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationDeleteOperation_example.json - // this example is just showing the usage of "Applications_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationActionResumeUpgrade_example.json + // this example is just showing the usage of "Applications_ResumeUpgrade" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,7 +188,11 @@ public async Task Delete_DeleteAnApplication() ServiceFabricManagedApplicationResource serviceFabricManagedApplication = client.GetServiceFabricManagedApplicationResource(serviceFabricManagedApplicationResourceId); // invoke the operation - await serviceFabricManagedApplication.DeleteAsync(WaitUntil.Completed); + RuntimeResumeApplicationUpgradeContent content = new RuntimeResumeApplicationUpgradeContent + { + UpgradeDomainName = "UD1", + }; + await serviceFabricManagedApplication.ResumeUpgradeAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeCollection.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeCollection.cs index a016bb621c9d1..f2acf3beb5b73 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeCollection.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceFabricManagedApplicationTypeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnApplicationType() + public async Task CreateOrUpdate_PutAnApplicationType() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNameGetOperation_example.json - // this example is just showing the usage of "ApplicationTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNamePutOperation_example.json + // this example is just showing the usage of "ApplicationTypes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,9 @@ public async Task Get_GetAnApplicationType() // invoke the operation string applicationTypeName = "myAppType"; - ServiceFabricManagedApplicationTypeResource result = await collection.GetAsync(applicationTypeName); + ServiceFabricManagedApplicationTypeData data = new ServiceFabricManagedApplicationTypeData(new AzureLocation("eastus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationTypeName, data); + ServiceFabricManagedApplicationTypeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_GetAnApplicationType() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnApplicationType() + public async Task Get_GetAnApplicationType() { // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNameGetOperation_example.json // this example is just showing the usage of "ApplicationTypes_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +76,21 @@ public async Task Exists_GetAnApplicationType() // invoke the operation string applicationTypeName = "myAppType"; - bool result = await collection.ExistsAsync(applicationTypeName); + ServiceFabricManagedApplicationTypeResource result = await collection.GetAsync(applicationTypeName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedApplicationTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnApplicationType() + public async Task GetAll_GetAListOfApplicationTypeNameResources() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNameGetOperation_example.json - // this example is just showing the usage of "ApplicationTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNameListOperation_example.json + // this example is just showing the usage of "ApplicationTypes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +108,25 @@ public async Task GetIfExists_GetAnApplicationType() // get the collection of this ServiceFabricManagedApplicationTypeResource ServiceFabricManagedApplicationTypeCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedApplicationTypes(); - // invoke the operation - string applicationTypeName = "myAppType"; - NullableResponse response = await collection.GetIfExistsAsync(applicationTypeName); - ServiceFabricManagedApplicationTypeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServiceFabricManagedApplicationTypeResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationTypeData resourceData = result.Data; + ServiceFabricManagedApplicationTypeData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAnApplicationType() + public async Task Exists_GetAnApplicationType() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNamePutOperation_example.json - // this example is just showing the usage of "ApplicationTypes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNameGetOperation_example.json + // this example is just showing the usage of "ApplicationTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,23 +146,17 @@ public async Task CreateOrUpdate_PutAnApplicationType() // invoke the operation string applicationTypeName = "myAppType"; - ServiceFabricManagedApplicationTypeData data = new ServiceFabricManagedApplicationTypeData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationTypeName, data); - ServiceFabricManagedApplicationTypeResource result = lro.Value; + bool result = await collection.ExistsAsync(applicationTypeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfApplicationTypeNameResources() + public async Task GetIfExists_GetAnApplicationType() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNameListOperation_example.json - // this example is just showing the usage of "ApplicationTypes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNameGetOperation_example.json + // this example is just showing the usage of "ApplicationTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_GetAListOfApplicationTypeNameResources() // get the collection of this ServiceFabricManagedApplicationTypeResource ServiceFabricManagedApplicationTypeCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedApplicationTypes(); - // invoke the operation and iterate over the result - await foreach (ServiceFabricManagedApplicationTypeResource item in collection.GetAllAsync()) + // invoke the operation + string applicationTypeName = "myAppType"; + NullableResponse response = await collection.GetIfExistsAsync(applicationTypeName); + ServiceFabricManagedApplicationTypeResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationTypeData resourceData = item.Data; + ServiceFabricManagedApplicationTypeData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeResource.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeResource.cs index 2a6da792d0866..3449087d87475 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeResource.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAnApplicationType() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAnApplicationType() + public async Task Delete_DeleteAnApplicationType() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNamePatchOperation_example.json - // this example is just showing the usage of "ApplicationTypes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNameDeleteOperation_example.json + // this example is just showing the usage of "ApplicationTypes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,28 +69,17 @@ public async Task Update_PatchAnApplicationType() ServiceFabricManagedApplicationTypeResource serviceFabricManagedApplicationType = client.GetServiceFabricManagedApplicationTypeResource(serviceFabricManagedApplicationTypeResourceId); // invoke the operation - ServiceFabricManagedApplicationTypePatch patch = new ServiceFabricManagedApplicationTypePatch() - { - Tags = -{ -["a"] = "b", -}, - }; - ServiceFabricManagedApplicationTypeResource result = await serviceFabricManagedApplicationType.UpdateAsync(patch); + await serviceFabricManagedApplicationType.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnApplicationType() + public async Task Update_PatchAnApplicationType() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNameDeleteOperation_example.json - // this example is just showing the usage of "ApplicationTypes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeNamePatchOperation_example.json + // this example is just showing the usage of "ApplicationTypes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +96,20 @@ public async Task Delete_DeleteAnApplicationType() ServiceFabricManagedApplicationTypeResource serviceFabricManagedApplicationType = client.GetServiceFabricManagedApplicationTypeResource(serviceFabricManagedApplicationTypeResourceId); // invoke the operation - await serviceFabricManagedApplicationType.DeleteAsync(WaitUntil.Completed); + ServiceFabricManagedApplicationTypePatch patch = new ServiceFabricManagedApplicationTypePatch + { + Tags = +{ +["a"] = "b" +}, + }; + ServiceFabricManagedApplicationTypeResource result = await serviceFabricManagedApplicationType.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedApplicationTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeVersionCollection.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeVersionCollection.cs index 136a868c3a3c5..7f2a3f57370e9 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeVersionCollection.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeVersionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceFabricManagedApplicationTypeVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnApplicationTypeVersion() + public async Task CreateOrUpdate_PutAnApplicationTypeVersion() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionGetOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionPutOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetAnApplicationTypeVersion() // invoke the operation string version = "1.0"; - ServiceFabricManagedApplicationTypeVersionResource result = await collection.GetAsync(version); + ServiceFabricManagedApplicationTypeVersionData data = new ServiceFabricManagedApplicationTypeVersionData(new AzureLocation("eastus")) + { + AppPackageUri = new Uri("http://fakelink.test.com/MyAppType"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + ServiceFabricManagedApplicationTypeVersionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetAnApplicationTypeVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnApplicationTypeVersion() + public async Task Get_GetAnApplicationTypeVersion() { // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionGetOperation_example.json // this example is just showing the usage of "ApplicationTypeVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +81,21 @@ public async Task Exists_GetAnApplicationTypeVersion() // invoke the operation string version = "1.0"; - bool result = await collection.ExistsAsync(version); + ServiceFabricManagedApplicationTypeVersionResource result = await collection.GetAsync(version); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedApplicationTypeVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnApplicationTypeVersion() + public async Task GetAll_GetAListOfApplicationTypeVersionResources() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionGetOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionListOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_ListByApplicationTypes" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,31 +114,25 @@ public async Task GetIfExists_GetAnApplicationTypeVersion() // get the collection of this ServiceFabricManagedApplicationTypeVersionResource ServiceFabricManagedApplicationTypeVersionCollection collection = serviceFabricManagedApplicationType.GetServiceFabricManagedApplicationTypeVersions(); - // invoke the operation - string version = "1.0"; - NullableResponse response = await collection.GetIfExistsAsync(version); - ServiceFabricManagedApplicationTypeVersionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServiceFabricManagedApplicationTypeVersionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationTypeVersionData resourceData = result.Data; + ServiceFabricManagedApplicationTypeVersionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAnApplicationTypeVersion() + public async Task Exists_GetAnApplicationTypeVersion() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionPutOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionGetOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,26 +153,17 @@ public async Task CreateOrUpdate_PutAnApplicationTypeVersion() // invoke the operation string version = "1.0"; - ServiceFabricManagedApplicationTypeVersionData data = new ServiceFabricManagedApplicationTypeVersionData(new AzureLocation("eastus")) - { - AppPackageUri = new Uri("http://fakelink.test.com/MyAppType"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - ServiceFabricManagedApplicationTypeVersionResource result = lro.Value; + bool result = await collection.ExistsAsync(version); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationTypeVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfApplicationTypeVersionResources() + public async Task GetIfExists_GetAnApplicationTypeVersion() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionListOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_ListByApplicationTypes" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionGetOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_GetAListOfApplicationTypeVersionResources() // get the collection of this ServiceFabricManagedApplicationTypeVersionResource ServiceFabricManagedApplicationTypeVersionCollection collection = serviceFabricManagedApplicationType.GetServiceFabricManagedApplicationTypeVersions(); - // invoke the operation and iterate over the result - await foreach (ServiceFabricManagedApplicationTypeVersionResource item in collection.GetAllAsync()) + // invoke the operation + string version = "1.0"; + NullableResponse response = await collection.GetIfExistsAsync(version); + ServiceFabricManagedApplicationTypeVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationTypeVersionData resourceData = item.Data; + ServiceFabricManagedApplicationTypeVersionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeVersionResource.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeVersionResource.cs index 8f9b3646ea56e..29ac2ea50396c 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeVersionResource.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedApplicationTypeVersionResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetAnApplicationTypeVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAnApplicationTypeVersion() + public async Task Delete_DeleteAnApplicationTypeVersion() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionPatchOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionDeleteOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,28 +71,17 @@ public async Task Update_PatchAnApplicationTypeVersion() ServiceFabricManagedApplicationTypeVersionResource serviceFabricManagedApplicationTypeVersion = client.GetServiceFabricManagedApplicationTypeVersionResource(serviceFabricManagedApplicationTypeVersionResourceId); // invoke the operation - ServiceFabricManagedApplicationTypeVersionPatch patch = new ServiceFabricManagedApplicationTypeVersionPatch() - { - Tags = -{ -["a"] = "b", -}, - }; - ServiceFabricManagedApplicationTypeVersionResource result = await serviceFabricManagedApplicationTypeVersion.UpdateAsync(patch); + await serviceFabricManagedApplicationTypeVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedApplicationTypeVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnApplicationTypeVersion() + public async Task Update_PatchAnApplicationTypeVersion() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionDeleteOperation_example.json - // this example is just showing the usage of "ApplicationTypeVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ApplicationTypeVersionPatchOperation_example.json + // this example is just showing the usage of "ApplicationTypeVersions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +99,20 @@ public async Task Delete_DeleteAnApplicationTypeVersion() ServiceFabricManagedApplicationTypeVersionResource serviceFabricManagedApplicationTypeVersion = client.GetServiceFabricManagedApplicationTypeVersionResource(serviceFabricManagedApplicationTypeVersionResourceId); // invoke the operation - await serviceFabricManagedApplicationTypeVersion.DeleteAsync(WaitUntil.Completed); + ServiceFabricManagedApplicationTypeVersionPatch patch = new ServiceFabricManagedApplicationTypeVersionPatch + { + Tags = +{ +["a"] = "b" +}, + }; + ServiceFabricManagedApplicationTypeVersionResource result = await serviceFabricManagedApplicationTypeVersion.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedApplicationTypeVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedClusterCollection.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedClusterCollection.cs index a9131fe813958..0e8b6dc60ac0b 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedClusterCollection.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedClusterCollection.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Resources; @@ -19,10 +20,10 @@ public partial class Sample_ServiceFabricManagedClusterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListClusterByResourceGroup() + public async Task CreateOrUpdate_PutAClusterWithMaximumParameters() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterListByResourceGroupOperation_example.json - // this example is just showing the usage of "ManagedClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterPutOperation_example_max.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +40,101 @@ public async Task GetAll_ListClusterByResourceGroup() // get the collection of this ServiceFabricManagedClusterResource ServiceFabricManagedClusterCollection collection = resourceGroupResource.GetServiceFabricManagedClusters(); - // invoke the operation and iterate over the result - await foreach (ServiceFabricManagedClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "mycluster"; + ServiceFabricManagedClusterData data = new ServiceFabricManagedClusterData(new AzureLocation("eastus"), new ServiceFabricManagedClustersSku(ServiceFabricManagedClustersSkuName.Basic)) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DnsName = "mycluster", + ClientConnectionPort = 19000, + HttpGatewayConnectionPort = 19080, + AdminUserName = "vmadmin", + AdminPassword = "{vm-password}", + LoadBalancingRules = {new ManagedClusterLoadBalancingRule(80, 80, new ManagedClusterLoadBalancingRuleTransportProtocol("http"), ManagedClusterLoadBalanceProbeProtocol.Http) +{ +ProbePort = 80, +}, new ManagedClusterLoadBalancingRule(443, 443, new ManagedClusterLoadBalancingRuleTransportProtocol("http"), ManagedClusterLoadBalanceProbeProtocol.Http) +{ +ProbePort = 443, +}, new ManagedClusterLoadBalancingRule(10000, 10000, ManagedClusterLoadBalancingRuleTransportProtocol.Tcp, ManagedClusterLoadBalanceProbeProtocol.Http) +{ +ProbePort = 10000, +LoadDistribution = "Default", +}}, + IsRdpAccessAllowed = true, + NetworkSecurityRules = {new ServiceFabricManagedNetworkSecurityRule("TestName", ServiceFabricManagedNsgProtocol.Tcp, ServiceFabricManagedNetworkTrafficAccess.Allow, 1010, ServiceFabricManagedNetworkSecurityRuleDirection.Inbound) +{ +Description = "Test description", +SourceAddressPrefixes = {"*"}, +DestinationAddressPrefixes = {"*"}, +SourcePortRanges = {"*"}, +DestinationPortRanges = {"*"}, +}, new ServiceFabricManagedNetworkSecurityRule("AllowARM", new ServiceFabricManagedNsgProtocol("*"), ServiceFabricManagedNetworkTrafficAccess.Allow, 2002, ServiceFabricManagedNetworkSecurityRuleDirection.Inbound) +{ +SourceAddressPrefix = "AzureResourceManager", +DestinationAddressPrefix = "*", +SourcePortRange = "*", +DestinationPortRange = "33500-33699", +}}, + FabricSettings = {new ClusterFabricSettingsSection("ManagedIdentityTokenService", new ClusterFabricSettingsParameterDescription[] +{ +new ClusterFabricSettingsParameterDescription("IsEnabled", "true") +})}, + ClusterCodeVersion = "7.1.168.9494", + ClusterUpgradeMode = ManagedClusterUpgradeMode.Manual, + AddOnFeatures = { ManagedClusterAddOnFeature.DnsService, ManagedClusterAddOnFeature.BackupRestoreService, ManagedClusterAddOnFeature.ResourceMonitorService }, + IsAutoOSUpgradeEnabled = true, + HasZoneResiliency = true, + MaxUnusedVersionsToKeep = 3, + IsIPv6Enabled = true, + IPTags = { new ManagedClusterIPTag("FirstPartyUsage", "SQL") }, + AuxiliarySubnets = {new ManagedClusterSubnet("testSubnet1") +{ +IsIPv6Enabled = true, +PrivateEndpointNetworkPolicies = ManagedClusterSubnetPrivateEndpointNetworkPoliciesState.Enabled, +PrivateLinkServiceNetworkPolicies = ManagedClusterSubnetPrivateLinkServiceNetworkPoliciesState.Enabled, +NetworkSecurityGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/networkSecurityGroups/sn1"), +}}, + ServiceEndpoints = {new ManagedClusterServiceEndpoint("Microsoft.Storage") +{ +Locations = {new AzureLocation("eastus2"), new AzureLocation("usnorth")}, +}}, + ZonalUpdateMode = ZonalUpdateMode.Fast, + UseCustomVnet = true, + PublicIPPrefixId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.Network/publicIPPrefixes/myPublicIPPrefix"), + PublicIPv6PrefixId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.Network/publicIPPrefixes/myPublicIPv6Prefix"), + DdosProtectionPlanId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/ddosProtectionPlans/myDDoSProtectionPlan"), + UpgradeDescription = new ManagedClusterUpgradePolicy + { + ForceRestart = false, + HealthPolicy = new ManagedClusterHealthPolicy(10, 30), + DeltaHealthPolicy = new ManagedClusterUpgradeDeltaHealthPolicy(20) + { + MaxPercentUpgradeDomainDeltaUnhealthyNodes = 40, + MaxPercentDeltaUnhealthyApplications = 40, + }, + MonitoringPolicy = new ManagedClusterMonitoringPolicy(XmlConvert.ToTimeSpan("00:05:00"), XmlConvert.ToTimeSpan("00:45:00"), "00:55:00", "12:00:00", "03:00:00"), + }, + HttpGatewayTokenAuthConnectionPort = 19081, + IsHttpGatewayExclusiveAuthModeEnabled = true, + AutoGeneratedDomainNameLabelScope = AutoGeneratedDomainNameLabelScope.SubscriptionReuse, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); + ServiceFabricManagedClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACluster() + public async Task CreateOrUpdate_PutAClusterWithMinimumParameters() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterGetOperation_example.json - // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterPutOperation_example_min.json + // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +153,20 @@ public async Task Get_GetACluster() // invoke the operation string clusterName = "myCluster"; - ServiceFabricManagedClusterResource result = await collection.GetAsync(clusterName); + ServiceFabricManagedClusterData data = new ServiceFabricManagedClusterData(new AzureLocation("eastus"), new ServiceFabricManagedClustersSku(ServiceFabricManagedClustersSkuName.Basic)) + { + DnsName = "myCluster", + AdminUserName = "vmadmin", + AdminPassword = "{vm-password}", + FabricSettings = {new ClusterFabricSettingsSection("ManagedIdentityTokenService", new ClusterFabricSettingsParameterDescription[] +{ +new ClusterFabricSettingsParameterDescription("IsEnabled", "true") +})}, + ClusterUpgradeMode = ManagedClusterUpgradeMode.Automatic, + ClusterUpgradeCadence = ManagedClusterUpgradeCadence.Wave1, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); + ServiceFabricManagedClusterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +177,7 @@ public async Task Get_GetACluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACluster() + public async Task Get_GetACluster() { // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterGetOperation_example.json // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,17 +199,21 @@ public async Task Exists_GetACluster() // invoke the operation string clusterName = "myCluster"; - bool result = await collection.ExistsAsync(clusterName); + ServiceFabricManagedClusterResource result = await collection.GetAsync(clusterName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACluster() + public async Task GetAll_ListClusterByResourceGroup() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterGetOperation_example.json - // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterListByResourceGroupOperation_example.json + // this example is just showing the usage of "ManagedClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,31 +230,25 @@ public async Task GetIfExists_GetACluster() // get the collection of this ServiceFabricManagedClusterResource ServiceFabricManagedClusterCollection collection = resourceGroupResource.GetServiceFabricManagedClusters(); - // invoke the operation - string clusterName = "myCluster"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - ServiceFabricManagedClusterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServiceFabricManagedClusterResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricManagedClusterData resourceData = result.Data; + ServiceFabricManagedClusterData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAClusterWithMaximumParameters() + public async Task Exists_GetACluster() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterPutOperation_example_max.json - // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterGetOperation_example.json + // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,138 +266,18 @@ public async Task CreateOrUpdate_PutAClusterWithMaximumParameters() ServiceFabricManagedClusterCollection collection = resourceGroupResource.GetServiceFabricManagedClusters(); // invoke the operation - string clusterName = "mycluster"; - ServiceFabricManagedClusterData data = new ServiceFabricManagedClusterData(new AzureLocation("eastus"), new ServiceFabricManagedClustersSku(ServiceFabricManagedClustersSkuName.Basic)) - { - DnsName = "mycluster", - ClientConnectionPort = 19000, - HttpGatewayConnectionPort = 19080, - AdminUserName = "vmadmin", - AdminPassword = "{vm-password}", - LoadBalancingRules = -{ -new ManagedClusterLoadBalancingRule(80,80,new ManagedClusterLoadBalancingRuleTransportProtocol("http"),ManagedClusterLoadBalanceProbeProtocol.Http) -{ -ProbePort = 80, -},new ManagedClusterLoadBalancingRule(443,443,new ManagedClusterLoadBalancingRuleTransportProtocol("http"),ManagedClusterLoadBalanceProbeProtocol.Http) -{ -ProbePort = 443, -},new ManagedClusterLoadBalancingRule(10000,10000,ManagedClusterLoadBalancingRuleTransportProtocol.Tcp,ManagedClusterLoadBalanceProbeProtocol.Http) -{ -ProbePort = 10000, -LoadDistribution = "Default", -} -}, - IsRdpAccessAllowed = true, - NetworkSecurityRules = -{ -new ServiceFabricManagedNetworkSecurityRule("TestName",ServiceFabricManagedNsgProtocol.Tcp,ServiceFabricManagedNetworkTrafficAccess.Allow,1010,ServiceFabricManagedNetworkSecurityRuleDirection.Inbound) -{ -Description = "Test description", -SourceAddressPrefixes = -{ -"*" -}, -DestinationAddressPrefixes = -{ -"*" -}, -SourcePortRanges = -{ -"*" -}, -DestinationPortRanges = -{ -"*" -}, -},new ServiceFabricManagedNetworkSecurityRule("AllowARM",new ServiceFabricManagedNsgProtocol("*"),ServiceFabricManagedNetworkTrafficAccess.Allow,2002,ServiceFabricManagedNetworkSecurityRuleDirection.Inbound) -{ -SourceAddressPrefix = "AzureResourceManager", -DestinationAddressPrefix = "*", -SourcePortRange = "*", -DestinationPortRange = "33500-33699", -} -}, - FabricSettings = -{ -new ClusterFabricSettingsSection("ManagedIdentityTokenService",new ClusterFabricSettingsParameterDescription[] -{ -new ClusterFabricSettingsParameterDescription("IsEnabled","true") -}) -}, - ClusterCodeVersion = "7.1.168.9494", - ClusterUpgradeMode = ManagedClusterUpgradeMode.Manual, - AddOnFeatures = -{ -ManagedClusterAddOnFeature.DnsService,ManagedClusterAddOnFeature.BackupRestoreService,ManagedClusterAddOnFeature.ResourceMonitorService -}, - IsAutoOSUpgradeEnabled = true, - HasZoneResiliency = true, - MaxUnusedVersionsToKeep = 3, - IsIPv6Enabled = true, - IPTags = -{ -new ManagedClusterIPTag("FirstPartyUsage","SQL") -}, - AuxiliarySubnets = -{ -new ManagedClusterSubnet("testSubnet1") -{ -IsIPv6Enabled = true, -PrivateEndpointNetworkPolicies = ManagedClusterSubnetPrivateEndpointNetworkPoliciesState.Enabled, -PrivateLinkServiceNetworkPolicies = ManagedClusterSubnetPrivateLinkServiceNetworkPoliciesState.Enabled, -NetworkSecurityGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/networkSecurityGroups/sn1"), -} -}, - ServiceEndpoints = -{ -new ManagedClusterServiceEndpoint("Microsoft.Storage") -{ -Locations = -{ -new AzureLocation("eastus2"),new AzureLocation("usnorth") -}, -} -}, - ZonalUpdateMode = ZonalUpdateMode.Fast, - UseCustomVnet = true, - PublicIPPrefixId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.Network/publicIPPrefixes/myPublicIPPrefix"), - PublicIPv6PrefixId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.Network/publicIPPrefixes/myPublicIPv6Prefix"), - DdosProtectionPlanId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/ddosProtectionPlans/myDDoSProtectionPlan"), - UpgradeDescription = new ManagedClusterUpgradePolicy() - { - ForceRestart = false, - HealthPolicy = new ManagedClusterHealthPolicy(10, 30), - DeltaHealthPolicy = new ManagedClusterUpgradeDeltaHealthPolicy(20) - { - MaxPercentUpgradeDomainDeltaUnhealthyNodes = 40, - MaxPercentDeltaUnhealthyApplications = 40, - }, - MonitoringPolicy = new ManagedClusterMonitoringPolicy(TimeSpan.Parse("00:05:00"), TimeSpan.Parse("00:45:00"), "00:55:00", "12:00:00", "03:00:00"), - }, - HttpGatewayTokenAuthConnectionPort = 19081, - IsHttpGatewayExclusiveAuthModeEnabled = true, - AutoGeneratedDomainNameLabelScope = AutoGeneratedDomainNameLabelScope.SubscriptionReuse, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); - ServiceFabricManagedClusterResource result = lro.Value; + string clusterName = "myCluster"; + bool result = await collection.ExistsAsync(clusterName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAClusterWithMinimumParameters() + public async Task GetIfExists_GetACluster() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterPutOperation_example_min.json - // this example is just showing the usage of "ManagedClusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterGetOperation_example.json + // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -328,29 +296,21 @@ public async Task CreateOrUpdate_PutAClusterWithMinimumParameters() // invoke the operation string clusterName = "myCluster"; - ServiceFabricManagedClusterData data = new ServiceFabricManagedClusterData(new AzureLocation("eastus"), new ServiceFabricManagedClustersSku(ServiceFabricManagedClustersSkuName.Basic)) - { - DnsName = "myCluster", - AdminUserName = "vmadmin", - AdminPassword = "{vm-password}", - FabricSettings = -{ -new ClusterFabricSettingsSection("ManagedIdentityTokenService",new ClusterFabricSettingsParameterDescription[] -{ -new ClusterFabricSettingsParameterDescription("IsEnabled","true") -}) -}, - ClusterUpgradeMode = ManagedClusterUpgradeMode.Automatic, - ClusterUpgradeCadence = ManagedClusterUpgradeCadence.Wave1, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); - ServiceFabricManagedClusterResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + ServiceFabricManagedClusterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedClusterResource.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedClusterResource.cs index 8b9b1fd5f7855..d0a296913be24 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedClusterResource.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedClusterResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.ServiceFabricManagedClusters.Models; using NUnit.Framework; @@ -17,37 +16,6 @@ namespace Azure.ResourceManager.ServiceFabricManagedClusters.Samples { public partial class Sample_ServiceFabricManagedClusterResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetServiceFabricManagedClusters_ListManagedClusters() - { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterListBySubscriptionOperation_example.json - // this example is just showing the usage of "ManagedClusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ServiceFabricManagedClusterResource item in subscriptionResource.GetServiceFabricManagedClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetACluster() @@ -80,10 +48,10 @@ public async Task Get_GetACluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAManagedCluster() + public async Task Delete_DeleteACluster() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterPatchOperation_example.json - // this example is just showing the usage of "ManagedClusters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterDeleteOperation_example.json + // this example is just showing the usage of "ManagedClusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,28 +67,17 @@ public async Task Update_PatchAManagedCluster() ServiceFabricManagedClusterResource serviceFabricManagedCluster = client.GetServiceFabricManagedClusterResource(serviceFabricManagedClusterResourceId); // invoke the operation - ServiceFabricManagedClusterPatch patch = new ServiceFabricManagedClusterPatch() - { - Tags = -{ -["a"] = "b", -}, - }; - ServiceFabricManagedClusterResource result = await serviceFabricManagedCluster.UpdateAsync(patch); + await serviceFabricManagedCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACluster() + public async Task Update_PatchAManagedCluster() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterDeleteOperation_example.json - // this example is just showing the usage of "ManagedClusters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterPatchOperation_example.json + // this example is just showing the usage of "ManagedClusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,9 +93,20 @@ public async Task Delete_DeleteACluster() ServiceFabricManagedClusterResource serviceFabricManagedCluster = client.GetServiceFabricManagedClusterResource(serviceFabricManagedClusterResourceId); // invoke the operation - await serviceFabricManagedCluster.DeleteAsync(WaitUntil.Completed); + ServiceFabricManagedClusterPatch patch = new ServiceFabricManagedClusterPatch + { + Tags = +{ +["a"] = "b" +}, + }; + ServiceFabricManagedClusterResource result = await serviceFabricManagedCluster.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedNodeTypeCollection.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedNodeTypeCollection.cs index 9a6c7dab27148..5178e3474eaca 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedNodeTypeCollection.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedNodeTypeCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -18,148 +17,6 @@ namespace Azure.ResourceManager.ServiceFabricManagedClusters.Samples { public partial class Sample_ServiceFabricManagedNodeTypeCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNodeTypeOfTheSpecifiedManagedCluster() - { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeListOperation_example.json - // this example is just showing the usage of "NodeTypes_ListByManagedClusters" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceFabricManagedClusterResource created on azure - // for more information of creating ServiceFabricManagedClusterResource, please refer to the document of ServiceFabricManagedClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - string clusterName = "myCluster"; - ResourceIdentifier serviceFabricManagedClusterResourceId = ServiceFabricManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - ServiceFabricManagedClusterResource serviceFabricManagedCluster = client.GetServiceFabricManagedClusterResource(serviceFabricManagedClusterResourceId); - - // get the collection of this ServiceFabricManagedNodeTypeResource - ServiceFabricManagedNodeTypeCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedNodeTypes(); - - // invoke the operation and iterate over the result - await foreach (ServiceFabricManagedNodeTypeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedNodeTypeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetANodeType() - { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeGetOperation_example.json - // this example is just showing the usage of "NodeTypes_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceFabricManagedClusterResource created on azure - // for more information of creating ServiceFabricManagedClusterResource, please refer to the document of ServiceFabricManagedClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - string clusterName = "myCluster"; - ResourceIdentifier serviceFabricManagedClusterResourceId = ServiceFabricManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - ServiceFabricManagedClusterResource serviceFabricManagedCluster = client.GetServiceFabricManagedClusterResource(serviceFabricManagedClusterResourceId); - - // get the collection of this ServiceFabricManagedNodeTypeResource - ServiceFabricManagedNodeTypeCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedNodeTypes(); - - // invoke the operation - string nodeTypeName = "FE"; - ServiceFabricManagedNodeTypeResource result = await collection.GetAsync(nodeTypeName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedNodeTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetANodeType() - { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeGetOperation_example.json - // this example is just showing the usage of "NodeTypes_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceFabricManagedClusterResource created on azure - // for more information of creating ServiceFabricManagedClusterResource, please refer to the document of ServiceFabricManagedClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - string clusterName = "myCluster"; - ResourceIdentifier serviceFabricManagedClusterResourceId = ServiceFabricManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - ServiceFabricManagedClusterResource serviceFabricManagedCluster = client.GetServiceFabricManagedClusterResource(serviceFabricManagedClusterResourceId); - - // get the collection of this ServiceFabricManagedNodeTypeResource - ServiceFabricManagedNodeTypeCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedNodeTypes(); - - // invoke the operation - string nodeTypeName = "FE"; - bool result = await collection.ExistsAsync(nodeTypeName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetANodeType() - { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeGetOperation_example.json - // this example is just showing the usage of "NodeTypes_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceFabricManagedClusterResource created on azure - // for more information of creating ServiceFabricManagedClusterResource, please refer to the document of ServiceFabricManagedClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "resRg"; - string clusterName = "myCluster"; - ResourceIdentifier serviceFabricManagedClusterResourceId = ServiceFabricManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - ServiceFabricManagedClusterResource serviceFabricManagedCluster = client.GetServiceFabricManagedClusterResource(serviceFabricManagedClusterResourceId); - - // get the collection of this ServiceFabricManagedNodeTypeResource - ServiceFabricManagedNodeTypeCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedNodeTypes(); - - // invoke the operation - string nodeTypeName = "FE"; - NullableResponse response = await collection.GetIfExistsAsync(nodeTypeName); - ServiceFabricManagedNodeTypeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedNodeTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_PutANodeTypeWithAutoScaleParameters() @@ -185,7 +42,7 @@ public async Task CreateOrUpdate_PutANodeTypeWithAutoScaleParameters() // invoke the operation string nodeTypeName = "BE"; - ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData() + ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData { IsPrimary = false, VmInstanceCount = -1, @@ -195,41 +52,30 @@ public async Task CreateOrUpdate_PutANodeTypeWithAutoScaleParameters() { ["HasSSD"] = "true", ["NodeColor"] = "green", -["SomeProperty"] = "5", +["SomeProperty"] = "5" }, Capacities = { -["ClientConnections"] = "65536", +["ClientConnections"] = "65536" }, VmSize = "Standard_DS3", VmImagePublisher = "MicrosoftWindowsServer", VmImageOffer = "WindowsServer", VmImageSku = "2016-Datacenter-Server-Core", VmImageVersion = "latest", - VmSecrets = -{ -new NodeTypeVaultSecretGroup(new WritableSubResource() + VmSecrets = {new NodeTypeVaultSecretGroup(new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.KeyVault/vaults/myVault"), -},new NodeTypeVaultCertificate[] -{ -new NodeTypeVaultCertificate(new Uri("https://myVault.vault.azure.net:443/secrets/myCert/ef1a31d39e1f46bca33def54b6cda54c"),"My") -}) -}, - VmExtensions = +}, new NodeTypeVaultCertificate[] { -new NodeTypeVmssExtension("Microsoft.Azure.Geneva.GenevaMonitoring","Microsoft.Azure.Geneva","GenevaMonitoring","2.0") +new NodeTypeVaultCertificate(new Uri("https://myVault.vault.azure.net:443/secrets/myCert/ef1a31d39e1f46bca33def54b6cda54c"), "My") +})}, + VmExtensions = {new NodeTypeVmssExtension("Microsoft.Azure.Geneva.GenevaMonitoring", "Microsoft.Azure.Geneva", "GenevaMonitoring", "2.0") { AutoUpgradeMinorVersion = true, -Settings = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), -} -}, - UserAssignedIdentities = -{ -new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity"),new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity2") -}, +Settings = BinaryData.FromObjectAsJson(new object()), +}}, + UserAssignedIdentities = { new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity"), new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity2") }, IsStateless = true, HasMultiplePlacementGroups = true, }; @@ -268,7 +114,7 @@ public async Task CreateOrUpdate_PutANodeTypeWithMaximumParameters() // invoke the operation string nodeTypeName = "BE-testResourceGroup-testRegion-test"; - ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData() + ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData { IsPrimary = false, VmInstanceCount = 10, @@ -279,62 +125,42 @@ public async Task CreateOrUpdate_PutANodeTypeWithMaximumParameters() { ["HasSSD"] = "true", ["NodeColor"] = "green", -["SomeProperty"] = "5", +["SomeProperty"] = "5" }, Capacities = { -["ClientConnections"] = "65536", +["ClientConnections"] = "65536" }, VmSize = "Standard_DS3", VmImagePublisher = "MicrosoftWindowsServer", VmImageOffer = "WindowsServer", VmImageSku = "2016-Datacenter-Server-Core", VmImageVersion = "latest", - VmSecrets = -{ -new NodeTypeVaultSecretGroup(new WritableSubResource() + VmSecrets = {new NodeTypeVaultSecretGroup(new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.KeyVault/vaults/myVault"), -},new NodeTypeVaultCertificate[] -{ -new NodeTypeVaultCertificate(new Uri("https://myVault.vault.azure.net:443/secrets/myCert/ef1a31d39e1f46bca33def54b6cda54c"),"My") -}) -}, - VmExtensions = +}, new NodeTypeVaultCertificate[] { -new NodeTypeVmssExtension("Microsoft.Azure.Geneva.GenevaMonitoring","Microsoft.Azure.Geneva","GenevaMonitoring","2.0") +new NodeTypeVaultCertificate(new Uri("https://myVault.vault.azure.net:443/secrets/myCert/ef1a31d39e1f46bca33def54b6cda54c"), "My") +})}, + VmExtensions = {new NodeTypeVmssExtension("Microsoft.Azure.Geneva.GenevaMonitoring", "Microsoft.Azure.Geneva", "GenevaMonitoring", "2.0") { AutoUpgradeMinorVersion = true, -Settings = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), +Settings = BinaryData.FromObjectAsJson(new object()), ForceUpdateTag = "v.1.0", IsAutomaticUpgradeEnabled = true, -SetupOrder = -{ -VmssExtensionSetupOrder.BeforeSFRuntime -}, -} -}, - UserAssignedIdentities = -{ -new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity"),new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity2") -}, +SetupOrder = {VmssExtensionSetupOrder.BeforeSFRuntime}, +}}, + UserAssignedIdentities = { new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity"), new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myIdentity2") }, IsStateless = true, HasMultiplePlacementGroups = true, - FrontendConfigurations = -{ -new NodeTypeFrontendConfiguration() + FrontendConfigurations = {new NodeTypeFrontendConfiguration { LoadBalancerBackendAddressPoolId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/loadBalancers/test-LB/backendAddressPools/LoadBalancerBEAddressPool"), LoadBalancerInboundNatPoolId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/loadBalancers/test-LB/inboundNatPools/LoadBalancerNATPool"), ApplicationGatewayBackendAddressPoolId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/applicationGateways/appgw-test/backendAddressPools/appgwBepoolTest"), -} -}, - AdditionalDataDisks = -{ -new NodeTypeVmssDataDisk(1,256,ServiceFabricManagedDataDiskType.StandardSsdLrs,"F"),new NodeTypeVmssDataDisk(2,150,ServiceFabricManagedDataDiskType.PremiumLrs,"G") -}, +}}, + AdditionalDataDisks = { new NodeTypeVmssDataDisk(1, 256, ServiceFabricManagedDataDiskType.StandardSsdLrs, "F"), new NodeTypeVmssDataDisk(2, 150, ServiceFabricManagedDataDiskType.PremiumLrs, "G") }, IsEncryptionAtHostEnabled = true, IsAcceleratedNetworkingEnabled = true, UseDefaultPublicLoadBalancer = true, @@ -344,10 +170,7 @@ public async Task CreateOrUpdate_PutANodeTypeWithMaximumParameters() SpotRestoreTimeout = "PT30M", EvictionPolicy = SpotNodeVmEvictionPolicyType.Deallocate, SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), - VmSetupActions = -{ -VmSetupAction.EnableContainers,VmSetupAction.EnableHyperV -}, + VmSetupActions = { VmSetupAction.EnableContainers, VmSetupAction.EnableHyperV }, SecurityType = ServiceFabricManagedClusterSecurityType.TrustedLaunch, IsSecureBootEnabled = true, IsNodePublicIPEnabled = true, @@ -355,41 +178,27 @@ public async Task CreateOrUpdate_PutANodeTypeWithMaximumParameters() NatGatewayId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/natGateways/myNatGateway"), ServiceArtifactReferenceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/myVmArtifactProfile"), DscpConfigurationId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/dscpConfigurations/myDscpConfig"), - AdditionalNetworkInterfaceConfigurations = -{ -new AdditionalNetworkInterfaceConfiguration("nic-1",new ServiceFabricManagedClusterIPConfiguration[] + AdditionalNetworkInterfaceConfigurations = {new AdditionalNetworkInterfaceConfiguration("nic-1", new ServiceFabricManagedClusterIPConfiguration[] { new ServiceFabricManagedClusterIPConfiguration("ipconfig-1") { -ApplicationGatewayBackendAddressPools = -{ -new WritableSubResource() +ApplicationGatewayBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/applicationGateways/appgw-test/backendAddressPools/appgwBepoolTest"), -} -}, -LoadBalancerBackendAddressPools = -{ -new WritableSubResource() +}}, +LoadBalancerBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/loadBalancers/test-LB/backendAddressPools/LoadBalancerBEAddressPool"), -} -}, -LoadBalancerInboundNatPools = -{ -new WritableSubResource() +}}, +LoadBalancerInboundNatPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/loadBalancers/test-LB/inboundNatPools/LoadBalancerNATPool"), -} -}, +}}, SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), PrivateIPAddressVersion = ServiceFabricManagedClusterPrivateIPAddressVersion.IPv4, PublicIPAddressConfiguration = new ServiceFabricManagedClusterPublicIPAddressConfiguration("publicip-1") { -IPTags = -{ -new ManagedClusterIPTag("RoutingPreference","Internet") -}, +IPTags = {new ManagedClusterIPTag("RoutingPreference", "Internet")}, PublicIPAddressVersion = ServiceFabricManagedClusterPublicIPAddressVersion.IPv4, }, } @@ -397,20 +206,16 @@ public async Task CreateOrUpdate_PutANodeTypeWithMaximumParameters() { EnableAcceleratedNetworking = true, DscpConfigurationId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Network/dscpConfigurations/myDscpConfig"), -} -}, +}}, ComputerNamePrefix = "BE", - VmApplications = -{ -new ServiceFabricManagedVmApplication(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Compute/galleries/myGallery/applications/myApplication/versions/1.0.0")) + VmApplications = {new ServiceFabricManagedVmApplication(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resRg/providers/Microsoft.Compute/galleries/myGallery/applications/myApplication/versions/1.0.0")) { ConfigurationReference = new Uri("https://mystorageaccount.blob.core.windows.net/containername/blobname"), EnableAutomaticUpgrade = true, Order = 1, VmGalleryTags = "{\"Tag1\":\"Value1\",\"Tag2\":\"Value2\"}", TreatFailureAsDeploymentFailure = false, -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, nodeTypeName, data); ServiceFabricManagedNodeTypeResource result = lro.Value; @@ -447,7 +252,7 @@ public async Task CreateOrUpdate_PutANodeTypeWithMinimumParameters() // invoke the operation string nodeTypeName = "BE"; - ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData() + ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData { IsPrimary = false, VmInstanceCount = 10, @@ -493,7 +298,7 @@ public async Task CreateOrUpdate_PutAnStatelessNodeTypeWithTemporaryDiskForServi // invoke the operation string nodeTypeName = "BE"; - ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData() + ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData { IsPrimary = false, VmInstanceCount = 10, @@ -502,16 +307,11 @@ public async Task CreateOrUpdate_PutAnStatelessNodeTypeWithTemporaryDiskForServi VmImageOffer = "WindowsServer", VmImageSku = "2016-Datacenter-Server-Core", VmImageVersion = "latest", - VmExtensions = -{ -new NodeTypeVmssExtension("Microsoft.Azure.Geneva.GenevaMonitoring","Microsoft.Azure.Geneva","GenevaMonitoring","2.0") + VmExtensions = {new NodeTypeVmssExtension("Microsoft.Azure.Geneva.GenevaMonitoring", "Microsoft.Azure.Geneva", "GenevaMonitoring", "2.0") { AutoUpgradeMinorVersion = true, -Settings = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), -} -}, +Settings = BinaryData.FromObjectAsJson(new object()), +}}, IsStateless = true, HasMultiplePlacementGroups = true, IsEncryptionAtHostEnabled = true, @@ -552,7 +352,7 @@ public async Task CreateOrUpdate_PutNodeTypeWithCustomVmImage() // invoke the operation string nodeTypeName = "BE"; - ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData() + ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData { IsPrimary = false, VmInstanceCount = 10, @@ -595,27 +395,20 @@ public async Task CreateOrUpdate_PutNodeTypeWithDedicatedHosts() // invoke the operation string nodeTypeName = "BE"; - ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData() + ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData { IsPrimary = false, VmInstanceCount = 10, DataDiskSizeInGB = 200, DataDiskType = ServiceFabricManagedDataDiskType.StandardSsdLrs, - PlacementProperties = -{ -}, - Capacities = -{ -}, + PlacementProperties = { }, + Capacities = { }, VmSize = "Standard_D8s_v3", VmImagePublisher = "MicrosoftWindowsServer", VmImageOffer = "WindowsServer", VmImageSku = "2019-Datacenter", VmImageVersion = "latest", - Zones = -{ -"1" -}, + Zones = { "1" }, HostGroupId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testhostgroupRG/providers/Microsoft.Compute/hostGroups/testHostGroup", }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, nodeTypeName, data); @@ -653,7 +446,7 @@ public async Task CreateOrUpdate_PutNodeTypeWithSharedGalleriesCustomVmImage() // invoke the operation string nodeTypeName = "BE"; - ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData() + ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData { IsPrimary = false, VmInstanceCount = 10, @@ -696,7 +489,7 @@ public async Task CreateOrUpdate_PutNodeTypeWithVmImagePlan() // invoke the operation string nodeTypeName = "BE"; - ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData() + ServiceFabricManagedNodeTypeData data = new ServiceFabricManagedNodeTypeData { IsPrimary = false, VmInstanceCount = 10, @@ -706,7 +499,7 @@ public async Task CreateOrUpdate_PutNodeTypeWithVmImagePlan() VmImageOffer = "windows_2022_test", VmImageSku = "win_2022_test_20_10_gen2", VmImageVersion = "latest", - VmImagePlan = new VmImagePlan() + VmImagePlan = new VmImagePlan { Name = "win_2022_test_20_10_gen2", Product = "windows_2022_test", @@ -722,5 +515,147 @@ public async Task CreateOrUpdate_PutNodeTypeWithVmImagePlan() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetANodeType() + { + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeGetOperation_example.json + // this example is just showing the usage of "NodeTypes_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceFabricManagedClusterResource created on azure + // for more information of creating ServiceFabricManagedClusterResource, please refer to the document of ServiceFabricManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + string clusterName = "myCluster"; + ResourceIdentifier serviceFabricManagedClusterResourceId = ServiceFabricManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + ServiceFabricManagedClusterResource serviceFabricManagedCluster = client.GetServiceFabricManagedClusterResource(serviceFabricManagedClusterResourceId); + + // get the collection of this ServiceFabricManagedNodeTypeResource + ServiceFabricManagedNodeTypeCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedNodeTypes(); + + // invoke the operation + string nodeTypeName = "FE"; + ServiceFabricManagedNodeTypeResource result = await collection.GetAsync(nodeTypeName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedNodeTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListNodeTypeOfTheSpecifiedManagedCluster() + { + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeListOperation_example.json + // this example is just showing the usage of "NodeTypes_ListByManagedClusters" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceFabricManagedClusterResource created on azure + // for more information of creating ServiceFabricManagedClusterResource, please refer to the document of ServiceFabricManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + string clusterName = "myCluster"; + ResourceIdentifier serviceFabricManagedClusterResourceId = ServiceFabricManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + ServiceFabricManagedClusterResource serviceFabricManagedCluster = client.GetServiceFabricManagedClusterResource(serviceFabricManagedClusterResourceId); + + // get the collection of this ServiceFabricManagedNodeTypeResource + ServiceFabricManagedNodeTypeCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedNodeTypes(); + + // invoke the operation and iterate over the result + await foreach (ServiceFabricManagedNodeTypeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedNodeTypeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetANodeType() + { + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeGetOperation_example.json + // this example is just showing the usage of "NodeTypes_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceFabricManagedClusterResource created on azure + // for more information of creating ServiceFabricManagedClusterResource, please refer to the document of ServiceFabricManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + string clusterName = "myCluster"; + ResourceIdentifier serviceFabricManagedClusterResourceId = ServiceFabricManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + ServiceFabricManagedClusterResource serviceFabricManagedCluster = client.GetServiceFabricManagedClusterResource(serviceFabricManagedClusterResourceId); + + // get the collection of this ServiceFabricManagedNodeTypeResource + ServiceFabricManagedNodeTypeCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedNodeTypes(); + + // invoke the operation + string nodeTypeName = "FE"; + bool result = await collection.ExistsAsync(nodeTypeName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetANodeType() + { + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeGetOperation_example.json + // this example is just showing the usage of "NodeTypes_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceFabricManagedClusterResource created on azure + // for more information of creating ServiceFabricManagedClusterResource, please refer to the document of ServiceFabricManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "resRg"; + string clusterName = "myCluster"; + ResourceIdentifier serviceFabricManagedClusterResourceId = ServiceFabricManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + ServiceFabricManagedClusterResource serviceFabricManagedCluster = client.GetServiceFabricManagedClusterResource(serviceFabricManagedClusterResourceId); + + // get the collection of this ServiceFabricManagedNodeTypeResource + ServiceFabricManagedNodeTypeCollection collection = serviceFabricManagedCluster.GetServiceFabricManagedNodeTypes(); + + // invoke the operation + string nodeTypeName = "FE"; + NullableResponse response = await collection.GetIfExistsAsync(nodeTypeName); + ServiceFabricManagedNodeTypeResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedNodeTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedNodeTypeResource.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedNodeTypeResource.cs index 3cb257d7fd9c2..68de657b1dbac 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedNodeTypeResource.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedNodeTypeResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceFabricManagedNodeTypeResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Restart_RestartNodes() + public async Task Get_GetANodeType() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/RestartNodes_example.json - // this example is just showing the usage of "NodeTypes_Restart" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeGetOperation_example.json + // this example is just showing the usage of "NodeTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,29 +33,26 @@ public async Task Restart_RestartNodes() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "resRg"; string clusterName = "myCluster"; - string nodeTypeName = "BE"; + string nodeTypeName = "FE"; ResourceIdentifier serviceFabricManagedNodeTypeResourceId = ServiceFabricManagedNodeTypeResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, nodeTypeName); ServiceFabricManagedNodeTypeResource serviceFabricManagedNodeType = client.GetServiceFabricManagedNodeTypeResource(serviceFabricManagedNodeTypeResourceId); // invoke the operation - NodeTypeActionContent content = new NodeTypeActionContent() - { - Nodes = -{ -"BE_0","BE_3" -}, - }; - await serviceFabricManagedNodeType.RestartAsync(WaitUntil.Completed, content); + ServiceFabricManagedNodeTypeResource result = await serviceFabricManagedNodeType.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedNodeTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Reimage_ReimageAllNodesByUpgradeDomain() + public async Task Delete_DeleteANodeType() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ReimageNodes_UD_example.json - // this example is just showing the usage of "NodeTypes_Reimage" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeDeleteOperation_example.json + // this example is just showing the usage of "NodeTypes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,21 +69,17 @@ public async Task Reimage_ReimageAllNodesByUpgradeDomain() ServiceFabricManagedNodeTypeResource serviceFabricManagedNodeType = client.GetServiceFabricManagedNodeTypeResource(serviceFabricManagedNodeTypeResourceId); // invoke the operation - NodeTypeActionContent content = new NodeTypeActionContent() - { - UpdateType = ServiceFabricManagedClusterUpdateType.ByUpgradeDomain, - }; - await serviceFabricManagedNodeType.ReimageAsync(WaitUntil.Completed, content); + await serviceFabricManagedNodeType.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Reimage_ReimageNodes() + public async Task Update_PatchANodeType() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ReimageNodes_example.json - // this example is just showing the usage of "NodeTypes_Reimage" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypePatchOperation_example.json + // this example is just showing the usage of "NodeTypes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,24 +96,28 @@ public async Task Reimage_ReimageNodes() ServiceFabricManagedNodeTypeResource serviceFabricManagedNodeType = client.GetServiceFabricManagedNodeTypeResource(serviceFabricManagedNodeTypeResourceId); // invoke the operation - NodeTypeActionContent content = new NodeTypeActionContent() + ServiceFabricManagedNodeTypePatch patch = new ServiceFabricManagedNodeTypePatch { - Nodes = + Tags = { -"BE_0","BE_3" +["a"] = "b" }, }; - await serviceFabricManagedNodeType.ReimageAsync(WaitUntil.Completed, content); + ServiceFabricManagedNodeTypeResource result = await serviceFabricManagedNodeType.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedNodeTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task DeleteNode_DeleteNodes() + public async Task Update_PatchANodeTypeWhileAutoScaling() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/DeleteNodes_example.json - // this example is just showing the usage of "NodeTypes_DeleteNode" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypePatchOperationAutoScale_example.json + // this example is just showing the usage of "NodeTypes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,24 +134,33 @@ public async Task DeleteNode_DeleteNodes() ServiceFabricManagedNodeTypeResource serviceFabricManagedNodeType = client.GetServiceFabricManagedNodeTypeResource(serviceFabricManagedNodeTypeResourceId); // invoke the operation - NodeTypeActionContent content = new NodeTypeActionContent() + ServiceFabricManagedNodeTypePatch patch = new ServiceFabricManagedNodeTypePatch { - Nodes = + Tags = { -"BE_0","BE_3" +["a"] = "b" }, + Sku = new NodeTypeSku(10) + { + Name = "Standard_S0", + Tier = "Standard", + }, }; - await serviceFabricManagedNodeType.DeleteNodeAsync(WaitUntil.Completed, content); + ServiceFabricManagedNodeTypeResource result = await serviceFabricManagedNodeType.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedNodeTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetANodeType() + public async Task Restart_RestartNodes() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeGetOperation_example.json - // this example is just showing the usage of "NodeTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/RestartNodes_example.json + // this example is just showing the usage of "NodeTypes_Restart" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -166,26 +172,26 @@ public async Task Get_GetANodeType() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "resRg"; string clusterName = "myCluster"; - string nodeTypeName = "FE"; + string nodeTypeName = "BE"; ResourceIdentifier serviceFabricManagedNodeTypeResourceId = ServiceFabricManagedNodeTypeResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, nodeTypeName); ServiceFabricManagedNodeTypeResource serviceFabricManagedNodeType = client.GetServiceFabricManagedNodeTypeResource(serviceFabricManagedNodeTypeResourceId); // invoke the operation - ServiceFabricManagedNodeTypeResource result = await serviceFabricManagedNodeType.GetAsync(); + NodeTypeActionContent content = new NodeTypeActionContent + { + Nodes = { "BE_0", "BE_3" }, + }; + await serviceFabricManagedNodeType.RestartAsync(WaitUntil.Completed, content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedNodeTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchANodeType() + public async Task Reimage_ReimageAllNodesByUpgradeDomain() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypePatchOperation_example.json - // this example is just showing the usage of "NodeTypes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ReimageNodes_UD_example.json + // this example is just showing the usage of "NodeTypes_Reimage" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -202,28 +208,21 @@ public async Task Update_PatchANodeType() ServiceFabricManagedNodeTypeResource serviceFabricManagedNodeType = client.GetServiceFabricManagedNodeTypeResource(serviceFabricManagedNodeTypeResourceId); // invoke the operation - ServiceFabricManagedNodeTypePatch patch = new ServiceFabricManagedNodeTypePatch() + NodeTypeActionContent content = new NodeTypeActionContent { - Tags = -{ -["a"] = "b", -}, + UpdateType = ServiceFabricManagedClusterUpdateType.ByUpgradeDomain, }; - ServiceFabricManagedNodeTypeResource result = await serviceFabricManagedNodeType.UpdateAsync(patch); + await serviceFabricManagedNodeType.ReimageAsync(WaitUntil.Completed, content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedNodeTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchANodeTypeWhileAutoScaling() + public async Task Reimage_ReimageNodes() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypePatchOperationAutoScale_example.json - // this example is just showing the usage of "NodeTypes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ReimageNodes_example.json + // this example is just showing the usage of "NodeTypes_Reimage" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -240,33 +239,21 @@ public async Task Update_PatchANodeTypeWhileAutoScaling() ServiceFabricManagedNodeTypeResource serviceFabricManagedNodeType = client.GetServiceFabricManagedNodeTypeResource(serviceFabricManagedNodeTypeResourceId); // invoke the operation - ServiceFabricManagedNodeTypePatch patch = new ServiceFabricManagedNodeTypePatch() + NodeTypeActionContent content = new NodeTypeActionContent { - Tags = -{ -["a"] = "b", -}, - Sku = new NodeTypeSku(10) - { - Name = "Standard_S0", - Tier = "Standard", - }, + Nodes = { "BE_0", "BE_3" }, }; - ServiceFabricManagedNodeTypeResource result = await serviceFabricManagedNodeType.UpdateAsync(patch); + await serviceFabricManagedNodeType.ReimageAsync(WaitUntil.Completed, content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedNodeTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteANodeType() + public async Task DeleteNode_DeleteNodes() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/NodeTypeDeleteOperation_example.json - // this example is just showing the usage of "NodeTypes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/DeleteNodes_example.json + // this example is just showing the usage of "NodeTypes_DeleteNode" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -283,7 +270,11 @@ public async Task Delete_DeleteANodeType() ServiceFabricManagedNodeTypeResource serviceFabricManagedNodeType = client.GetServiceFabricManagedNodeTypeResource(serviceFabricManagedNodeTypeResourceId); // invoke the operation - await serviceFabricManagedNodeType.DeleteAsync(WaitUntil.Completed); + NodeTypeActionContent content = new NodeTypeActionContent + { + Nodes = { "BE_0", "BE_3" }, + }; + await serviceFabricManagedNodeType.DeleteNodeAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedServiceCollection.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedServiceCollection.cs index f24a282d05299..526b108f61f37 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedServiceCollection.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedServiceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceFabricManagedServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAService() + public async Task CreateOrUpdate_PutAServiceWithMaximumParameters() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServiceGetOperation_example.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServicePutOperation_example_max.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,32 @@ public async Task Get_GetAService() // invoke the operation string serviceName = "myService"; - ServiceFabricManagedServiceResource result = await collection.GetAsync(serviceName); + ServiceFabricManagedServiceData data = new ServiceFabricManagedServiceData(new AzureLocation("eastus")) + { + Properties = new StatelessServiceProperties("myServiceType", new SingletonPartitionScheme(), 5) + { + MinInstanceCount = 3, + MinInstancePercentage = 30, + ServicePackageActivationMode = ManagedServicePackageActivationMode.SharedProcess, + ServiceDnsName = "myservicednsname.myApp", + PlacementConstraints = "NodeType==frontend", + CorrelationScheme = { new ManagedServiceCorrelation(ManagedServiceCorrelationScheme.AlignedAffinity, "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/managedclusters/myCluster/applications/myApp/services/myService1") }, + ServiceLoadMetrics = {new ManagedServiceLoadMetric("metric1") +{ +Weight = ManagedServiceLoadMetricWeight.Low, +DefaultLoad = 3, +}}, + ServicePlacementPolicies = { new ServicePlacementNonPartiallyPlaceServicePolicy() }, + DefaultMoveCost = ServiceFabricManagedServiceMoveCost.Medium, + ScalingPolicies = { new ManagedServiceScalingPolicy(new PartitionInstanceCountScalingMechanism(3, 9, 2), new AveragePartitionLoadScalingTrigger("metricName", 2, 8, "00:01:00")) }, + }, + Tags = +{ +["a"] = "b" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); + ServiceFabricManagedServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +78,10 @@ public async Task Get_GetAService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAService() + public async Task CreateOrUpdate_PutAServiceWithMinimumParameters() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServiceGetOperation_example.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServicePutOperation_example_min.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,14 +102,23 @@ public async Task Exists_GetAService() // invoke the operation string serviceName = "myService"; - bool result = await collection.ExistsAsync(serviceName); + ServiceFabricManagedServiceData data = new ServiceFabricManagedServiceData(new AzureLocation("eastus")) + { + Properties = new StatelessServiceProperties("myServiceType", new SingletonPartitionScheme(), 1), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); + ServiceFabricManagedServiceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAService() + public async Task Get_GetAService() { // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServiceGetOperation_example.json // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,29 +142,21 @@ public async Task GetIfExists_GetAService() // invoke the operation string serviceName = "myService"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - ServiceFabricManagedServiceResource result = response.HasValue ? response.Value : null; + ServiceFabricManagedServiceResource result = await collection.GetAsync(serviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAServiceWithMaximumParameters() + public async Task GetAll_GetAListOfServiceResources() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServicePutOperation_example_max.json - // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServiceListOperation_example.json + // this example is just showing the usage of "Services_ListByApplications" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,60 +175,25 @@ public async Task CreateOrUpdate_PutAServiceWithMaximumParameters() // get the collection of this ServiceFabricManagedServiceResource ServiceFabricManagedServiceCollection collection = serviceFabricManagedApplication.GetServiceFabricManagedServices(); - // invoke the operation - string serviceName = "myService"; - ServiceFabricManagedServiceData data = new ServiceFabricManagedServiceData(new AzureLocation("eastus")) + // invoke the operation and iterate over the result + await foreach (ServiceFabricManagedServiceResource item in collection.GetAllAsync()) { - Properties = new StatelessServiceProperties("myServiceType", new SingletonPartitionScheme(), 5) - { - MinInstanceCount = 3, - MinInstancePercentage = 30, - ServicePackageActivationMode = ManagedServicePackageActivationMode.SharedProcess, - ServiceDnsName = "myservicednsname.myApp", - PlacementConstraints = "NodeType==frontend", - CorrelationScheme = -{ -new ManagedServiceCorrelation(ManagedServiceCorrelationScheme.AlignedAffinity,"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/managedclusters/myCluster/applications/myApp/services/myService1") -}, - ServiceLoadMetrics = -{ -new ManagedServiceLoadMetric("metric1") -{ -Weight = ManagedServiceLoadMetricWeight.Low, -DefaultLoad = 3, -} -}, - ServicePlacementPolicies = -{ -new ServicePlacementNonPartiallyPlaceServicePolicy() -}, - DefaultMoveCost = ServiceFabricManagedServiceMoveCost.Medium, - ScalingPolicies = -{ -new ManagedServiceScalingPolicy(new PartitionInstanceCountScalingMechanism(3,9,2),new AveragePartitionLoadScalingTrigger("metricName",2,8,"00:01:00")) -}, - }, - Tags = -{ -["a"] = "b", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); - ServiceFabricManagedServiceResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAServiceWithMinimumParameters() + public async Task Exists_GetAService() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServicePutOperation_example_min.json - // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServiceGetOperation_example.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -223,26 +214,17 @@ public async Task CreateOrUpdate_PutAServiceWithMinimumParameters() // invoke the operation string serviceName = "myService"; - ServiceFabricManagedServiceData data = new ServiceFabricManagedServiceData(new AzureLocation("eastus")) - { - Properties = new StatelessServiceProperties("myServiceType", new SingletonPartitionScheme(), 1), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); - ServiceFabricManagedServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(serviceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfServiceResources() + public async Task GetIfExists_GetAService() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServiceListOperation_example.json - // this example is just showing the usage of "Services_ListByApplications" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServiceGetOperation_example.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -261,17 +243,23 @@ public async Task GetAll_GetAListOfServiceResources() // get the collection of this ServiceFabricManagedServiceResource ServiceFabricManagedServiceCollection collection = serviceFabricManagedApplication.GetServiceFabricManagedServices(); - // invoke the operation and iterate over the result - await foreach (ServiceFabricManagedServiceResource item in collection.GetAllAsync()) + // invoke the operation + string serviceName = "myService"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + ServiceFabricManagedServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceFabricManagedServiceData resourceData = item.Data; + ServiceFabricManagedServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedServiceResource.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedServiceResource.cs index c8465a953f4e3..324712933312c 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedServiceResource.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_ServiceFabricManagedServiceResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetAService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAService() + public async Task Delete_DeleteAService() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServicePatchOperation_example.json - // this example is just showing the usage of "Services_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServiceDeleteOperation_example.json + // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,28 +71,17 @@ public async Task Update_PatchAService() ServiceFabricManagedServiceResource serviceFabricManagedService = client.GetServiceFabricManagedServiceResource(serviceFabricManagedServiceResourceId); // invoke the operation - ServiceFabricManagedServicePatch patch = new ServiceFabricManagedServicePatch() - { - Tags = -{ -["a"] = "b", -}, - }; - ServiceFabricManagedServiceResource result = await serviceFabricManagedService.UpdateAsync(patch); + await serviceFabricManagedService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceFabricManagedServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAService() + public async Task Update_PatchAService() { - // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServiceDeleteOperation_example.json - // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ServicePatchOperation_example.json + // this example is just showing the usage of "Services_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +99,20 @@ public async Task Delete_DeleteAService() ServiceFabricManagedServiceResource serviceFabricManagedService = client.GetServiceFabricManagedServiceResource(serviceFabricManagedServiceResourceId); // invoke the operation - await serviceFabricManagedService.DeleteAsync(WaitUntil.Completed); + ServiceFabricManagedServicePatch patch = new ServiceFabricManagedServicePatch + { + Tags = +{ +["a"] = "b" +}, + }; + ServiceFabricManagedServiceResource result = await serviceFabricManagedService.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 505bfa0661590..42d6a48d84dd5 100644 --- a/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/servicefabricmanagedclusters/Azure.ResourceManager.ServiceFabricManagedClusters/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.ServiceFabricManagedClusters.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetServiceFabricManagedClusters_ListManagedClusters() + { + // Generated from example definition: specification/servicefabricmanagedclusters/resource-manager/Microsoft.ServiceFabric/preview/2024-06-01-preview/examples/ManagedClusterListBySubscriptionOperation_example.json + // this example is just showing the usage of "ManagedClusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ServiceFabricManagedClusterResource item in subscriptionResource.GetServiceFabricManagedClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceFabricManagedClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetManagedClusterVersion_GetClusterVersion() diff --git a/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/samples/Generated/Samples/Sample_LinkerResource.cs b/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/samples/Generated/Samples/Sample_LinkerResource.cs index 99ead6ab0b23a..8d054d7ee825e 100644 --- a/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/samples/Generated/Samples/Sample_LinkerResource.cs +++ b/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/samples/Generated/Samples/Sample_LinkerResource.cs @@ -90,9 +90,9 @@ public async Task Update_PatchLink() LinkerResource linkerResource = client.GetLinkerResource(linkerResourceId); // invoke the operation - LinkerResourcePatch patch = new LinkerResourcePatch() + LinkerResourcePatch patch = new LinkerResourcePatch { - TargetService = new AzureResourceInfo() + TargetService = new AzureResourceInfo { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DocumentDb/databaseAccounts/test-acc/mongodbDatabases/test-db"), }, diff --git a/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/samples/Generated/Samples/Sample_LinkerResourceCollection.cs b/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/samples/Generated/Samples/Sample_LinkerResourceCollection.cs index e97a05b6f65d4..c149ff9033587 100644 --- a/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/samples/Generated/Samples/Sample_LinkerResourceCollection.cs +++ b/sdk/servicelinker/Azure.ResourceManager.ServiceLinker/samples/Generated/Samples/Sample_LinkerResourceCollection.cs @@ -18,60 +18,76 @@ public partial class Sample_LinkerResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LinkList() + public async Task CreateOrUpdate_PutLink() { - // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/LinkList.json - // this example is just showing the usage of "Linker_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/PutLink.json + // this example is just showing the usage of "Linker_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this LinkerResource string resourceUri = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - LinkerResourceCollection collection = client.GetLinkerResources(scopeId); + LinkerResourceCollection collection = client.GetLinkerResources(new ResourceIdentifier(resourceUri)); - // invoke the operation and iterate over the result - await foreach (LinkerResource item in collection.GetAllAsync()) + // invoke the operation + string linkerName = "linkName"; + LinkerResourceData data = new LinkerResourceData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LinkerResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TargetService = new AzureResourceInfo + { + Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DBforPostgreSQL/servers/test-pg/databases/test-db"), + }, + AuthInfo = new SecretAuthInfo + { + Name = "name", + SecretInfo = new RawValueSecretInfo + { + Value = "secret", + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkerName, data); + LinkerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LinkerResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_Link() + public async Task CreateOrUpdate_PutLinkWithSecretStore() { - // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/Link.json - // this example is just showing the usage of "Linker_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/PutLinkWithSecretStore.json + // this example is just showing the usage of "Linker_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this LinkerResource string resourceUri = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - LinkerResourceCollection collection = client.GetLinkerResources(scopeId); + LinkerResourceCollection collection = client.GetLinkerResources(new ResourceIdentifier(resourceUri)); // invoke the operation string linkerName = "linkName"; - LinkerResource result = await collection.GetAsync(linkerName); + LinkerResourceData data = new LinkerResourceData + { + TargetService = new AzureResourceInfo + { + Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DocumentDb/databaseAccounts/test-acc/mongodbDatabases/test-db"), + }, + AuthInfo = new SecretAuthInfo(), + SecretStoreKeyVaultId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.KeyVault/vaults/test-kv"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkerName, data); + LinkerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -82,34 +98,51 @@ public async Task Get_Link() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_Link() + public async Task CreateOrUpdate_PutLinkWithServiceEndpoint() { - // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/Link.json - // this example is just showing the usage of "Linker_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/PutLinkWithServiceEndpoint.json + // this example is just showing the usage of "Linker_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this LinkerResource string resourceUri = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - LinkerResourceCollection collection = client.GetLinkerResources(scopeId); + LinkerResourceCollection collection = client.GetLinkerResources(new ResourceIdentifier(resourceUri)); // invoke the operation string linkerName = "linkName"; - bool result = await collection.ExistsAsync(linkerName); + LinkerResourceData data = new LinkerResourceData + { + TargetService = new AzureResourceInfo + { + Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DBforPostgreSQL/servers/test-pg/databases/test-db"), + }, + AuthInfo = new SecretAuthInfo + { + Name = "name", + SecretInfo = new KeyVaultSecretUriSecretInfo + { + Value = "https://vault-name.vault.azure.net/secrets/secret-name/00000000000000000000000000000000", + }, + }, + SolutionType = VnetSolutionType.ServiceEndpoint, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkerName, data); + LinkerResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LinkerResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_Link() + public async Task Get_Link() { // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/Link.json // this example is just showing the usage of "Linker_Get" operation, for the dependent resources, they will have to be created separately. @@ -119,167 +152,106 @@ public async Task GetIfExists_Link() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this LinkerResource string resourceUri = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - LinkerResourceCollection collection = client.GetLinkerResources(scopeId); + LinkerResourceCollection collection = client.GetLinkerResources(new ResourceIdentifier(resourceUri)); // invoke the operation string linkerName = "linkName"; - NullableResponse response = await collection.GetIfExistsAsync(linkerName); - LinkerResource result = response.HasValue ? response.Value : null; + LinkerResource result = await collection.GetAsync(linkerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LinkerResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LinkerResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutLink() + public async Task GetAll_LinkList() { - // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/PutLink.json - // this example is just showing the usage of "Linker_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/LinkList.json + // this example is just showing the usage of "Linker_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this LinkerResource string resourceUri = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - LinkerResourceCollection collection = client.GetLinkerResources(scopeId); + LinkerResourceCollection collection = client.GetLinkerResources(new ResourceIdentifier(resourceUri)); - // invoke the operation - string linkerName = "linkName"; - LinkerResourceData data = new LinkerResourceData() + // invoke the operation and iterate over the result + await foreach (LinkerResource item in collection.GetAllAsync()) { - TargetService = new AzureResourceInfo() - { - Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DBforPostgreSQL/servers/test-pg/databases/test-db"), - }, - AuthInfo = new SecretAuthInfo() - { - Name = "name", - SecretInfo = new RawValueSecretInfo() - { - Value = "secret", - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkerName, data); - LinkerResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LinkerResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LinkerResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutLinkWithSecretStore() + public async Task Exists_Link() { - // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/PutLinkWithSecretStore.json - // this example is just showing the usage of "Linker_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/Link.json + // this example is just showing the usage of "Linker_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this LinkerResource string resourceUri = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - LinkerResourceCollection collection = client.GetLinkerResources(scopeId); + LinkerResourceCollection collection = client.GetLinkerResources(new ResourceIdentifier(resourceUri)); // invoke the operation string linkerName = "linkName"; - LinkerResourceData data = new LinkerResourceData() - { - TargetService = new AzureResourceInfo() - { - Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DocumentDb/databaseAccounts/test-acc/mongodbDatabases/test-db"), - }, - AuthInfo = new SecretAuthInfo(), - SecretStoreKeyVaultId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.KeyVault/vaults/test-kv"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkerName, data); - LinkerResource result = lro.Value; + bool result = await collection.ExistsAsync(linkerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LinkerResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutLinkWithServiceEndpoint() + public async Task GetIfExists_Link() { - // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/PutLinkWithServiceEndpoint.json - // this example is just showing the usage of "Linker_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicelinker/resource-manager/Microsoft.ServiceLinker/stable/2022-05-01/examples/Link.json + // this example is just showing the usage of "Linker_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this LinkerResource string resourceUri = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.Web/sites/test-app"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - LinkerResourceCollection collection = client.GetLinkerResources(scopeId); + LinkerResourceCollection collection = client.GetLinkerResources(new ResourceIdentifier(resourceUri)); // invoke the operation string linkerName = "linkName"; - LinkerResourceData data = new LinkerResourceData() - { - TargetService = new AzureResourceInfo() - { - Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/test-rg/providers/Microsoft.DBforPostgreSQL/servers/test-pg/databases/test-db"), - }, - AuthInfo = new SecretAuthInfo() - { - Name = "name", - SecretInfo = new KeyVaultSecretUriSecretInfo() - { - Value = "https://vault-name.vault.azure.net/secrets/secret-name/00000000000000000000000000000000", - }, - }, - SolutionType = VnetSolutionType.ServiceEndpoint, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkerName, data); - LinkerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(linkerName); + LinkerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LinkerResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LinkerResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_AssociationCollection.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_AssociationCollection.cs index b9f5da80842ec..6752a00100091 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_AssociationCollection.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_AssociationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AssociationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAssociations() + public async Task CreateOrUpdate_PutAssociation() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationsGet.json - // this example is just showing the usage of "AssociationsInterface_ListByTrafficController" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationPut.json + // this example is just showing the usage of "AssociationsInterface_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_GetAssociations() // get the collection of this AssociationResource AssociationCollection collection = trafficController.GetAssociations(); - // invoke the operation and iterate over the result - await foreach (AssociationResource item in collection.GetAllAsync()) + // invoke the operation + string associationName = "as1"; + AssociationData data = new AssociationData(new AzureLocation("NorthCentralUS")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssociationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AssociationType = AssociationType.Subnets, + SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-tc/subnets/tc-subnet"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, associationName, data); + AssociationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_GetAssociation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAssociation() + public async Task GetAll_GetAssociations() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationGet.json - // this example is just showing the usage of "AssociationsInterface_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationsGet.json + // this example is just showing the usage of "AssociationsInterface_ListByTrafficController" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +113,22 @@ public async Task Exists_GetAssociation() // get the collection of this AssociationResource AssociationCollection collection = trafficController.GetAssociations(); - // invoke the operation - string associationName = "as1"; - bool result = await collection.ExistsAsync(associationName); + // invoke the operation and iterate over the result + await foreach (AssociationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssociationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAssociation() + public async Task Exists_GetAssociation() { // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationGet.json // this example is just showing the usage of "AssociationsInterface_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_GetAssociation() // invoke the operation string associationName = "as1"; - NullableResponse response = await collection.GetIfExistsAsync(associationName); - AssociationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(associationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssociationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAssociation() + public async Task GetIfExists_GetAssociation() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationPut.json - // this example is just showing the usage of "AssociationsInterface_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationGet.json + // this example is just showing the usage of "AssociationsInterface_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,19 +181,21 @@ public async Task CreateOrUpdate_PutAssociation() // invoke the operation string associationName = "as1"; - AssociationData data = new AssociationData(new AzureLocation("NorthCentralUS")) - { - AssociationType = AssociationType.Subnets, - SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-tc/subnets/tc-subnet"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, associationName, data); - AssociationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(associationName); + AssociationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssociationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_AssociationResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_AssociationResource.cs index f508077a68ce9..93705874bcd9a 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_AssociationResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_AssociationResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAssociation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAssociation() + public async Task Delete_DeleteAssociation() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationPatch.json - // this example is just showing the usage of "AssociationsInterface_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationDelete.json + // this example is just showing the usage of "AssociationsInterface_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_UpdateAssociation() AssociationResource association = client.GetAssociationResource(associationResourceId); // invoke the operation - AssociationPatch patch = new AssociationPatch() - { - AssociationType = AssociationType.Subnets, - SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-tc/subnets/tc-subnet"), - }; - AssociationResource result = await association.UpdateAsync(patch); + await association.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssociationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAssociation() + public async Task Update_UpdateAssociation() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationDelete.json - // this example is just showing the usage of "AssociationsInterface_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/AssociationPatch.json + // this example is just showing the usage of "AssociationsInterface_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeleteAssociation() AssociationResource association = client.GetAssociationResource(associationResourceId); // invoke the operation - await association.DeleteAsync(WaitUntil.Completed); + AssociationPatch patch = new AssociationPatch + { + AssociationType = AssociationType.Subnets, + SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-tc/subnets/tc-subnet"), + }; + AssociationResource result = await association.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_FrontendCollection.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_FrontendCollection.cs index 21b888379318f..a380ca94425c1 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_FrontendCollection.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_FrontendCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_FrontendCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetFrontends() + public async Task CreateOrUpdate_PutFrontend() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendsGet.json - // this example is just showing the usage of "FrontendsInterface_ListByTrafficController" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendPut.json + // this example is just showing the usage of "FrontendsInterface_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_GetFrontends() // get the collection of this FrontendResource FrontendCollection collection = trafficController.GetFrontends(); - // invoke the operation and iterate over the result - await foreach (FrontendResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontendData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string frontendName = "fe1"; + FrontendData data = new FrontendData(new AzureLocation("NorthCentralUS")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, frontendName, data); + FrontendResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_GetFrontend() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFrontend() + public async Task GetAll_GetFrontends() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendGet.json - // this example is just showing the usage of "FrontendsInterface_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendsGet.json + // this example is just showing the usage of "FrontendsInterface_ListByTrafficController" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_GetFrontend() // get the collection of this FrontendResource FrontendCollection collection = trafficController.GetFrontends(); - // invoke the operation - string frontendName = "fe1"; - bool result = await collection.ExistsAsync(frontendName); + // invoke the operation and iterate over the result + await foreach (FrontendResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontendData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFrontend() + public async Task Exists_GetFrontend() { // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendGet.json // this example is just showing the usage of "FrontendsInterface_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_GetFrontend() // invoke the operation string frontendName = "fe1"; - NullableResponse response = await collection.GetIfExistsAsync(frontendName); - FrontendResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(frontendName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutFrontend() + public async Task GetIfExists_GetFrontend() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendPut.json - // this example is just showing the usage of "FrontendsInterface_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendGet.json + // this example is just showing the usage of "FrontendsInterface_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_PutFrontend() // invoke the operation string frontendName = "fe1"; - FrontendData data = new FrontendData(new AzureLocation("NorthCentralUS")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, frontendName, data); - FrontendResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(frontendName); + FrontendResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_FrontendResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_FrontendResource.cs index 6e74e49fd06ca..c290fcb3070df 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_FrontendResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_FrontendResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetFrontend() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateFrontend() + public async Task Delete_DeleteFrontend() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendPatch.json - // this example is just showing the usage of "FrontendsInterface_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendDelete.json + // this example is just showing the usage of "FrontendsInterface_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,22 +69,17 @@ public async Task Update_UpdateFrontend() FrontendResource frontend = client.GetFrontendResource(frontendResourceId); // invoke the operation - FrontendPatch patch = new FrontendPatch(); - FrontendResource result = await frontend.UpdateAsync(patch); + await frontend.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteFrontend() + public async Task Update_UpdateFrontend() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendDelete.json - // this example is just showing the usage of "FrontendsInterface_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/FrontendPatch.json + // this example is just showing the usage of "FrontendsInterface_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +96,14 @@ public async Task Delete_DeleteFrontend() FrontendResource frontend = client.GetFrontendResource(frontendResourceId); // invoke the operation - await frontend.DeleteAsync(WaitUntil.Completed); + FrontendPatch patch = new FrontendPatch(); + FrontendResource result = await frontend.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..88a9299c98e2d --- /dev/null +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ServiceNetworking.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetTrafficControllers_GetTrafficControllersList() + { + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllersGetList.json + // this example is just showing the usage of "TrafficControllerInterface_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (TrafficControllerResource item in subscriptionResource.GetTrafficControllersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficControllerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_TrafficControllerCollection.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_TrafficControllerCollection.cs index 2c7e3999fde7e..aab64700d88fa 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_TrafficControllerCollection.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_TrafficControllerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_TrafficControllerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTrafficControllers() + public async Task CreateOrUpdate_PutTrafficController() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllersGet.json - // this example is just showing the usage of "TrafficControllerInterface_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerPut.json + // this example is just showing the usage of "TrafficControllerInterface_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,23 @@ public async Task GetAll_GetTrafficControllers() // get the collection of this TrafficControllerResource TrafficControllerCollection collection = resourceGroupResource.GetTrafficControllers(); - // invoke the operation and iterate over the result - await foreach (TrafficControllerResource item in collection.GetAllAsync()) + // invoke the operation + string trafficControllerName = "tc1"; + TrafficControllerData data = new TrafficControllerData(new AzureLocation("NorthCentralUS")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficControllerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, trafficControllerName, data); + TrafficControllerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficControllerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +92,10 @@ public async Task Get_GetTrafficController() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTrafficController() + public async Task GetAll_GetTrafficControllers() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerGet.json - // this example is just showing the usage of "TrafficControllerInterface_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllersGet.json + // this example is just showing the usage of "TrafficControllerInterface_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +112,22 @@ public async Task Exists_GetTrafficController() // get the collection of this TrafficControllerResource TrafficControllerCollection collection = resourceGroupResource.GetTrafficControllers(); - // invoke the operation - string trafficControllerName = "tc1"; - bool result = await collection.ExistsAsync(trafficControllerName); + // invoke the operation and iterate over the result + await foreach (TrafficControllerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficControllerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTrafficController() + public async Task Exists_GetTrafficController() { // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerGet.json // this example is just showing the usage of "TrafficControllerInterface_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +149,17 @@ public async Task GetIfExists_GetTrafficController() // invoke the operation string trafficControllerName = "tc1"; - NullableResponse response = await collection.GetIfExistsAsync(trafficControllerName); - TrafficControllerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(trafficControllerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficControllerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutTrafficController() + public async Task GetIfExists_GetTrafficController() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerPut.json - // this example is just showing the usage of "TrafficControllerInterface_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerGet.json + // this example is just showing the usage of "TrafficControllerInterface_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,21 +178,21 @@ public async Task CreateOrUpdate_PutTrafficController() // invoke the operation string trafficControllerName = "tc1"; - TrafficControllerData data = new TrafficControllerData(new AzureLocation("NorthCentralUS")) - { - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, trafficControllerName, data); - TrafficControllerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(trafficControllerName); + TrafficControllerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficControllerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficControllerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_TrafficControllerResource.cs b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_TrafficControllerResource.cs index b6e32dc76d200..ecafeaa320b7a 100644 --- a/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_TrafficControllerResource.cs +++ b/sdk/servicenetworking/Azure.ResourceManager.ServiceNetworking/samples/Generated/Samples/Sample_TrafficControllerResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.ServiceNetworking.Models; using NUnit.Framework; @@ -17,37 +16,6 @@ namespace Azure.ResourceManager.ServiceNetworking.Samples { public partial class Sample_TrafficControllerResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetTrafficControllers_GetTrafficControllersList() - { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllersGetList.json - // this example is just showing the usage of "TrafficControllerInterface_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (TrafficControllerResource item in subscriptionResource.GetTrafficControllersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficControllerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetTrafficController() @@ -80,10 +48,10 @@ public async Task Get_GetTrafficController() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchTrafficController() + public async Task Delete_DeleteTrafficController() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerPatch.json - // this example is just showing the usage of "TrafficControllerInterface_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerDelete.json + // this example is just showing the usage of "TrafficControllerInterface_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,28 +67,17 @@ public async Task Update_PatchTrafficController() TrafficControllerResource trafficController = client.GetTrafficControllerResource(trafficControllerResourceId); // invoke the operation - TrafficControllerPatch patch = new TrafficControllerPatch() - { - Tags = -{ -["key1"] = "value1", -}, - }; - TrafficControllerResource result = await trafficController.UpdateAsync(patch); + await trafficController.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TrafficControllerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteTrafficController() + public async Task Update_PatchTrafficController() { - // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerDelete.json - // this example is just showing the usage of "TrafficControllerInterface_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/servicenetworking/resource-manager/Microsoft.ServiceNetworking/stable/2023-11-01/examples/TrafficControllerPatch.json + // this example is just showing the usage of "TrafficControllerInterface_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,9 +93,20 @@ public async Task Delete_DeleteTrafficController() TrafficControllerResource trafficController = client.GetTrafficControllerResource(trafficControllerResourceId); // invoke the operation - await trafficController.DeleteAsync(WaitUntil.Completed); + TrafficControllerPatch patch = new TrafficControllerPatch + { + Tags = +{ +["key1"] = "value1" +}, + }; + TrafficControllerResource result = await trafficController.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TrafficControllerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCatalogCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCatalogCollection.cs index b946e97a0ab51..e18690a360d3b 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCatalogCollection.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCatalogCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SphereCatalogCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CatalogsListByResourceGroup() + public async Task CreateOrUpdate_CatalogsCreateOrUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCatalogsRG.json - // this example is just showing the usage of "Catalogs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutCatalog.json + // this example is just showing the usage of "Catalogs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_CatalogsListByResourceGroup() // get the collection of this SphereCatalogResource SphereCatalogCollection collection = resourceGroupResource.GetSphereCatalogs(); - // invoke the operation and iterate over the result - await foreach (SphereCatalogResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereCatalogData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string catalogName = "MyCatalog1"; + SphereCatalogData data = new SphereCatalogData(new AzureLocation("global")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, catalogName, data); + SphereCatalogResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereCatalogData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +86,10 @@ public async Task Get_CatalogsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CatalogsGet() + public async Task GetAll_CatalogsListByResourceGroup() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCatalog.json - // this example is just showing the usage of "Catalogs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCatalogsRG.json + // this example is just showing the usage of "Catalogs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +106,22 @@ public async Task Exists_CatalogsGet() // get the collection of this SphereCatalogResource SphereCatalogCollection collection = resourceGroupResource.GetSphereCatalogs(); - // invoke the operation - string catalogName = "MyCatalog1"; - bool result = await collection.ExistsAsync(catalogName); + // invoke the operation and iterate over the result + await foreach (SphereCatalogResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereCatalogData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CatalogsGet() + public async Task Exists_CatalogsGet() { // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCatalog.json // this example is just showing the usage of "Catalogs_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +143,17 @@ public async Task GetIfExists_CatalogsGet() // invoke the operation string catalogName = "MyCatalog1"; - NullableResponse response = await collection.GetIfExistsAsync(catalogName); - SphereCatalogResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(catalogName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereCatalogData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CatalogsCreateOrUpdate() + public async Task GetIfExists_CatalogsGet() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutCatalog.json - // this example is just showing the usage of "Catalogs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCatalog.json + // this example is just showing the usage of "Catalogs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,15 +172,21 @@ public async Task CreateOrUpdate_CatalogsCreateOrUpdate() // invoke the operation string catalogName = "MyCatalog1"; - SphereCatalogData data = new SphereCatalogData(new AzureLocation("global")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, catalogName, data); - SphereCatalogResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(catalogName); + SphereCatalogResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereCatalogData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereCatalogData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCatalogResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCatalogResource.cs index 46e9081fc3225..337e225a73145 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCatalogResource.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCatalogResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Sphere.Models; using NUnit.Framework; @@ -17,37 +16,6 @@ namespace Azure.ResourceManager.Sphere.Samples { public partial class Sample_SphereCatalogResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSphereCatalogs_CatalogsListBySubscription() - { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCatalogsSub.json - // this example is just showing the usage of "Catalogs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SphereCatalogResource item in subscriptionResource.GetSphereCatalogsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereCatalogData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_CatalogsGet() @@ -80,10 +48,10 @@ public async Task Get_CatalogsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CatalogsUpdate() + public async Task Delete_CatalogsDelete() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PatchCatalog.json - // this example is just showing the usage of "Catalogs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteCatalog.json + // this example is just showing the usage of "Catalogs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,22 +67,17 @@ public async Task Update_CatalogsUpdate() SphereCatalogResource sphereCatalog = client.GetSphereCatalogResource(sphereCatalogResourceId); // invoke the operation - SphereCatalogPatch patch = new SphereCatalogPatch(); - SphereCatalogResource result = await sphereCatalog.UpdateAsync(patch); + await sphereCatalog.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereCatalogData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CatalogsDelete() + public async Task Update_CatalogsUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteCatalog.json - // this example is just showing the usage of "Catalogs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PatchCatalog.json + // this example is just showing the usage of "Catalogs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,9 +93,14 @@ public async Task Delete_CatalogsDelete() SphereCatalogResource sphereCatalog = client.GetSphereCatalogResource(sphereCatalogResourceId); // invoke the operation - await sphereCatalog.DeleteAsync(WaitUntil.Completed); + SphereCatalogPatch patch = new SphereCatalogPatch(); + SphereCatalogResource result = await sphereCatalog.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereCatalogData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -215,7 +183,7 @@ public async Task GetDeviceGroups_CatalogsListDeviceGroups() SphereCatalogResource sphereCatalog = client.GetSphereCatalogResource(sphereCatalogResourceId); // invoke the operation and iterate over the result - ListSphereDeviceGroupsContent content = new ListSphereDeviceGroupsContent() + ListSphereDeviceGroupsContent content = new ListSphereDeviceGroupsContent { DeviceGroupName = "MyDeviceGroup1", }; @@ -315,7 +283,7 @@ public async Task UploadImage_CatalogsUploadImage() SphereCatalogResource sphereCatalog = client.GetSphereCatalogResource(sphereCatalogResourceId); // invoke the operation - SphereImageData data = new SphereImageData() + SphereImageData data = new SphereImageData { Image = "bXliYXNlNjRzdHJpbmc=", }; diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCertificateCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCertificateCollection.cs index b525d87ae1620..d6446d01ae1a5 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCertificateCollection.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereCertificateCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SphereCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CertificatesListByCatalog() + public async Task Get_CertificatesGet() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCertificates.json - // this example is just showing the usage of "Certificates_ListByCatalog" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCertificate.json + // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_CertificatesListByCatalog() // get the collection of this SphereCertificateResource SphereCertificateCollection collection = sphereCatalog.GetSphereCertificates(); - // invoke the operation and iterate over the result - await foreach (SphereCertificateResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string serialNumber = "default"; + SphereCertificateResource result = await collection.GetAsync(serialNumber); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CertificatesGet() + public async Task GetAll_CertificatesListByCatalog() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCertificate.json - // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCertificates.json + // this example is just showing the usage of "Certificates_ListByCatalog" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_CertificatesGet() // get the collection of this SphereCertificateResource SphereCertificateCollection collection = sphereCatalog.GetSphereCertificates(); - // invoke the operation - string serialNumber = "default"; - SphereCertificateResource result = await collection.GetAsync(serialNumber); + // invoke the operation and iterate over the result + await foreach (SphereCertificateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeploymentCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeploymentCollection.cs index 5f1fb656d3a8a..9c4f942e07a8f 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeploymentCollection.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeploymentCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SphereDeploymentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DeploymentsListByDeviceGroup() + public async Task CreateOrUpdate_DeploymentsCreateOrUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDeployments.json - // this example is just showing the usage of "Deployments_ListByDeviceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutDeployment.json + // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,17 @@ public async Task GetAll_DeploymentsListByDeviceGroup() // get the collection of this SphereDeploymentResource SphereDeploymentCollection collection = sphereDeviceGroup.GetSphereDeployments(); - // invoke the operation and iterate over the result - await foreach (SphereDeploymentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeploymentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string deploymentName = "MyDeployment1"; + SphereDeploymentData data = new SphereDeploymentData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); + SphereDeploymentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +91,10 @@ public async Task Get_DeploymentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DeploymentsGet() + public async Task GetAll_DeploymentsListByDeviceGroup() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDeployment.json - // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDeployments.json + // this example is just showing the usage of "Deployments_ListByDeviceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +114,22 @@ public async Task Exists_DeploymentsGet() // get the collection of this SphereDeploymentResource SphereDeploymentCollection collection = sphereDeviceGroup.GetSphereDeployments(); - // invoke the operation - string deploymentName = "MyDeployment1"; - bool result = await collection.ExistsAsync(deploymentName); + // invoke the operation and iterate over the result + await foreach (SphereDeploymentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeploymentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DeploymentsGet() + public async Task Exists_DeploymentsGet() { // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDeployment.json // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +154,17 @@ public async Task GetIfExists_DeploymentsGet() // invoke the operation string deploymentName = "MyDeployment1"; - NullableResponse response = await collection.GetIfExistsAsync(deploymentName); - SphereDeploymentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(deploymentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DeploymentsCreateOrUpdate() + public async Task GetIfExists_DeploymentsGet() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutDeployment.json - // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDeployment.json + // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,15 +186,21 @@ public async Task CreateOrUpdate_DeploymentsCreateOrUpdate() // invoke the operation string deploymentName = "MyDeployment1"; - SphereDeploymentData data = new SphereDeploymentData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); - SphereDeploymentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(deploymentName); + SphereDeploymentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeploymentResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeploymentResource.cs index 0ef70152df598..1b185f8cd7767 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeploymentResource.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeploymentResource.cs @@ -50,10 +50,10 @@ public async Task Get_DeploymentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DeploymentsCreateOrUpdate() + public async Task Delete_DeploymentsDelete() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutDeployment.json - // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteDeployment.json + // this example is just showing the usage of "Deployments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,30 +65,24 @@ public async Task Update_DeploymentsCreateOrUpdate() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "MyResourceGroup1"; string catalogName = "MyCatalog1"; - string productName = "MyProduct1"; - string deviceGroupName = "myDeviceGroup1"; - string deploymentName = "MyDeployment1"; + string productName = "MyProductName1"; + string deviceGroupName = "DeviceGroupName1"; + string deploymentName = "MyDeploymentName1"; ResourceIdentifier sphereDeploymentResourceId = SphereDeploymentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName); SphereDeploymentResource sphereDeployment = client.GetSphereDeploymentResource(sphereDeploymentResourceId); // invoke the operation - SphereDeploymentData data = new SphereDeploymentData(); - ArmOperation lro = await sphereDeployment.UpdateAsync(WaitUntil.Completed, data); - SphereDeploymentResource result = lro.Value; + await sphereDeployment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeploymentsDelete() + public async Task Update_DeploymentsCreateOrUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteDeployment.json - // this example is just showing the usage of "Deployments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutDeployment.json + // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,16 +94,22 @@ public async Task Delete_DeploymentsDelete() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "MyResourceGroup1"; string catalogName = "MyCatalog1"; - string productName = "MyProductName1"; - string deviceGroupName = "DeviceGroupName1"; - string deploymentName = "MyDeploymentName1"; + string productName = "MyProduct1"; + string deviceGroupName = "myDeviceGroup1"; + string deploymentName = "MyDeployment1"; ResourceIdentifier sphereDeploymentResourceId = SphereDeploymentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deploymentName); SphereDeploymentResource sphereDeployment = client.GetSphereDeploymentResource(sphereDeploymentResourceId); // invoke the operation - await sphereDeployment.DeleteAsync(WaitUntil.Completed); + SphereDeploymentData data = new SphereDeploymentData(); + ArmOperation lro = await sphereDeployment.UpdateAsync(WaitUntil.Completed, data); + SphereDeploymentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceCollection.cs index 0f6b7e6ab649d..a6baa02b9c7cf 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceCollection.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SphereDeviceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DevicesListByDeviceGroup() + public async Task CreateOrUpdate_DevicesCreateOrUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDevices.json - // this example is just showing the usage of "Devices_ListByDeviceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutDevice.json + // this example is just showing the usage of "Devices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,17 @@ public async Task GetAll_DevicesListByDeviceGroup() // get the collection of this SphereDeviceResource SphereDeviceCollection collection = sphereDeviceGroup.GetSphereDevices(); - // invoke the operation and iterate over the result - await foreach (SphereDeviceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeviceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string deviceName = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; + SphereDeviceData data = new SphereDeviceData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deviceName, data); + SphereDeviceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeviceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +91,10 @@ public async Task Get_DevicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DevicesGet() + public async Task GetAll_DevicesListByDeviceGroup() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDevice.json - // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDevices.json + // this example is just showing the usage of "Devices_ListByDeviceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +114,22 @@ public async Task Exists_DevicesGet() // get the collection of this SphereDeviceResource SphereDeviceCollection collection = sphereDeviceGroup.GetSphereDevices(); - // invoke the operation - string deviceName = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - bool result = await collection.ExistsAsync(deviceName); + // invoke the operation and iterate over the result + await foreach (SphereDeviceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeviceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DevicesGet() + public async Task Exists_DevicesGet() { // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDevice.json // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +154,17 @@ public async Task GetIfExists_DevicesGet() // invoke the operation string deviceName = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - NullableResponse response = await collection.GetIfExistsAsync(deviceName); - SphereDeviceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(deviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DevicesCreateOrUpdate() + public async Task GetIfExists_DevicesGet() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutDevice.json - // this example is just showing the usage of "Devices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDevice.json + // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,15 +186,21 @@ public async Task CreateOrUpdate_DevicesCreateOrUpdate() // invoke the operation string deviceName = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; - SphereDeviceData data = new SphereDeviceData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deviceName, data); - SphereDeviceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(deviceName); + SphereDeviceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeviceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceGroupCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceGroupCollection.cs index 7a1d52d48fa1d..4b2ac2b34c527 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceGroupCollection.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SphereDeviceGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DeviceGroupsListByProduct() + public async Task CreateOrUpdate_DeviceGroupsCreateOrUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDeviceGroups.json - // this example is just showing the usage of "DeviceGroups_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutDeviceGroup.json + // this example is just showing the usage of "DeviceGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,22 @@ public async Task GetAll_DeviceGroupsListByProduct() // get the collection of this SphereDeviceGroupResource SphereDeviceGroupCollection collection = sphereProduct.GetSphereDeviceGroups(); - // invoke the operation and iterate over the result - await foreach (SphereDeviceGroupResource item in collection.GetAllAsync()) + // invoke the operation + string deviceGroupName = "MyDeviceGroup1"; + SphereDeviceGroupData data = new SphereDeviceGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeviceGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "Description for MyDeviceGroup1", + OSFeedType = SphereOSFeedType.Retail, + UpdatePolicy = SphereUpdatePolicy.UpdateAll, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deviceGroupName, data); + SphereDeviceGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeviceGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +95,10 @@ public async Task Get_DeviceGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DeviceGroupsGet() + public async Task GetAll_DeviceGroupsListByProduct() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDeviceGroup.json - // this example is just showing the usage of "DeviceGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDeviceGroups.json + // this example is just showing the usage of "DeviceGroups_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +117,22 @@ public async Task Exists_DeviceGroupsGet() // get the collection of this SphereDeviceGroupResource SphereDeviceGroupCollection collection = sphereProduct.GetSphereDeviceGroups(); - // invoke the operation - string deviceGroupName = "MyDeviceGroup1"; - bool result = await collection.ExistsAsync(deviceGroupName); + // invoke the operation and iterate over the result + await foreach (SphereDeviceGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeviceGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DeviceGroupsGet() + public async Task Exists_DeviceGroupsGet() { // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDeviceGroup.json // this example is just showing the usage of "DeviceGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +156,17 @@ public async Task GetIfExists_DeviceGroupsGet() // invoke the operation string deviceGroupName = "MyDeviceGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(deviceGroupName); - SphereDeviceGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(deviceGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeviceGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DeviceGroupsCreateOrUpdate() + public async Task GetIfExists_DeviceGroupsGet() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutDeviceGroup.json - // this example is just showing the usage of "DeviceGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetDeviceGroup.json + // this example is just showing the usage of "DeviceGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,20 +187,21 @@ public async Task CreateOrUpdate_DeviceGroupsCreateOrUpdate() // invoke the operation string deviceGroupName = "MyDeviceGroup1"; - SphereDeviceGroupData data = new SphereDeviceGroupData() - { - Description = "Description for MyDeviceGroup1", - OSFeedType = SphereOSFeedType.Retail, - UpdatePolicy = SphereUpdatePolicy.UpdateAll, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deviceGroupName, data); - SphereDeviceGroupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(deviceGroupName); + SphereDeviceGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeviceGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeviceGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceGroupResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceGroupResource.cs index 92971a1122dc0..eca47345d57c8 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceGroupResource.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceGroupResource.cs @@ -50,10 +50,10 @@ public async Task Get_DeviceGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DeviceGroupsUpdate() + public async Task Delete_DeviceGroupsDelete() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PatchDeviceGroup.json - // this example is just showing the usage of "DeviceGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteDeviceGroup.json + // this example is just showing the usage of "DeviceGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,23 +71,17 @@ public async Task Update_DeviceGroupsUpdate() SphereDeviceGroupResource sphereDeviceGroup = client.GetSphereDeviceGroupResource(sphereDeviceGroupResourceId); // invoke the operation - SphereDeviceGroupPatch patch = new SphereDeviceGroupPatch(); - ArmOperation lro = await sphereDeviceGroup.UpdateAsync(WaitUntil.Completed, patch); - SphereDeviceGroupResource result = lro.Value; + await sphereDeviceGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeviceGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeviceGroupsDelete() + public async Task Update_DeviceGroupsUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteDeviceGroup.json - // this example is just showing the usage of "DeviceGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PatchDeviceGroup.json + // this example is just showing the usage of "DeviceGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +99,15 @@ public async Task Delete_DeviceGroupsDelete() SphereDeviceGroupResource sphereDeviceGroup = client.GetSphereDeviceGroupResource(sphereDeviceGroupResourceId); // invoke the operation - await sphereDeviceGroup.DeleteAsync(WaitUntil.Completed); + SphereDeviceGroupPatch patch = new SphereDeviceGroupPatch(); + ArmOperation lro = await sphereDeviceGroup.UpdateAsync(WaitUntil.Completed, patch); + SphereDeviceGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeviceGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -133,10 +133,7 @@ public async Task ClaimDevices_DeviceGroupsClaimDevices() SphereDeviceGroupResource sphereDeviceGroup = client.GetSphereDeviceGroupResource(sphereDeviceGroupResourceId); // invoke the operation - ClaimSphereDevicesContent content = new ClaimSphereDevicesContent(new string[] - { -"00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" - }); + ClaimSphereDevicesContent content = new ClaimSphereDevicesContent(new string[] { "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" }); await sphereDeviceGroup.ClaimDevicesAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceResource.cs index bb6c3a03ca0ac..dad7e6d621bbb 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceResource.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereDeviceResource.cs @@ -51,10 +51,10 @@ public async Task Get_DevicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DevicesUpdate() + public async Task Delete_DevicesDelete() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PatchDevice.json - // this example is just showing the usage of "Devices_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteDevice.json + // this example is just showing the usage of "Devices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,30 +66,24 @@ public async Task Update_DevicesUpdate() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "MyResourceGroup1"; string catalogName = "MyCatalog1"; - string productName = "MyProduct1"; - string deviceGroupName = "MyDeviceGroup1"; + string productName = "MyProductName1"; + string deviceGroupName = "DeviceGroupName1"; string deviceName = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ResourceIdentifier sphereDeviceResourceId = SphereDeviceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName); SphereDeviceResource sphereDevice = client.GetSphereDeviceResource(sphereDeviceResourceId); // invoke the operation - SphereDevicePatch patch = new SphereDevicePatch(); - ArmOperation lro = await sphereDevice.UpdateAsync(WaitUntil.Completed, patch); - SphereDeviceResource result = lro.Value; + await sphereDevice.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DevicesDelete() + public async Task Update_DevicesUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteDevice.json - // this example is just showing the usage of "Devices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PatchDevice.json + // this example is just showing the usage of "Devices_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,16 +95,22 @@ public async Task Delete_DevicesDelete() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "MyResourceGroup1"; string catalogName = "MyCatalog1"; - string productName = "MyProductName1"; - string deviceGroupName = "DeviceGroupName1"; + string productName = "MyProduct1"; + string deviceGroupName = "MyDeviceGroup1"; string deviceName = "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"; ResourceIdentifier sphereDeviceResourceId = SphereDeviceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, catalogName, productName, deviceGroupName, deviceName); SphereDeviceResource sphereDevice = client.GetSphereDeviceResource(sphereDeviceResourceId); // invoke the operation - await sphereDevice.DeleteAsync(WaitUntil.Completed); + SphereDevicePatch patch = new SphereDevicePatch(); + ArmOperation lro = await sphereDevice.UpdateAsync(WaitUntil.Completed, patch); + SphereDeviceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereDeviceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -137,10 +137,7 @@ public async Task GenerateCapabilityImage_DevicesGenerateCapabilityImage() SphereDeviceResource sphereDevice = client.GetSphereDeviceResource(sphereDeviceResourceId); // invoke the operation - GenerateCapabilityImageContent content = new GenerateCapabilityImageContent(new SphereCapabilityType[] - { -SphereCapabilityType.ApplicationDevelopment - }); + GenerateCapabilityImageContent content = new GenerateCapabilityImageContent(new SphereCapabilityType[] { SphereCapabilityType.ApplicationDevelopment }); ArmOperation lro = await sphereDevice.GenerateCapabilityImageAsync(WaitUntil.Completed, content); SignedCapabilityImageResponse result = lro.Value; diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereImageCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereImageCollection.cs index ef311fdba18ee..6b6a816be9d37 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereImageCollection.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereImageCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SphereImageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ImagesListByCatalog() + public async Task CreateOrUpdate_ImageCreateOrUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetImages.json - // this example is just showing the usage of "Images_ListByCatalog" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutImage.json + // this example is just showing the usage of "Images_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ImagesListByCatalog() // get the collection of this SphereImageResource SphereImageCollection collection = sphereCatalog.GetSphereImages(); - // invoke the operation and iterate over the result - await foreach (SphereImageResource item in collection.GetAllAsync()) + // invoke the operation + string imageName = "00000000-0000-0000-0000-000000000000"; + SphereImageData data = new SphereImageData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereImageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Image = "bXliYXNlNjRzdHJpbmc=", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, imageName, data); + SphereImageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_ImagesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ImagesGet() + public async Task GetAll_ImagesListByCatalog() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetImage.json - // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetImages.json + // this example is just showing the usage of "Images_ListByCatalog" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_ImagesGet() // get the collection of this SphereImageResource SphereImageCollection collection = sphereCatalog.GetSphereImages(); - // invoke the operation - string imageName = "00000000-0000-0000-0000-000000000000"; - bool result = await collection.ExistsAsync(imageName); + // invoke the operation and iterate over the result + await foreach (SphereImageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ImagesGet() + public async Task Exists_ImagesGet() { // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetImage.json // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_ImagesGet() // invoke the operation string imageName = "00000000-0000-0000-0000-000000000000"; - NullableResponse response = await collection.GetIfExistsAsync(imageName); - SphereImageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(imageName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ImageCreateOrUpdate() + public async Task GetIfExists_ImagesGet() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutImage.json - // this example is just showing the usage of "Images_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetImage.json + // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_ImageCreateOrUpdate() // invoke the operation string imageName = "00000000-0000-0000-0000-000000000000"; - SphereImageData data = new SphereImageData() - { - Image = "bXliYXNlNjRzdHJpbmc=", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, imageName, data); - SphereImageResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(imageName); + SphereImageResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereImageResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereImageResource.cs index 1e70466c885a3..4d1ca3664024a 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereImageResource.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereImageResource.cs @@ -48,10 +48,10 @@ public async Task Get_ImagesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ImageCreateOrUpdate() + public async Task Delete_ImagesDelete() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutImage.json - // this example is just showing the usage of "Images_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteImage.json + // this example is just showing the usage of "Images_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_ImageCreateOrUpdate() SphereImageResource sphereImage = client.GetSphereImageResource(sphereImageResourceId); // invoke the operation - SphereImageData data = new SphereImageData() - { - Image = "bXliYXNlNjRzdHJpbmc=", - }; - ArmOperation lro = await sphereImage.UpdateAsync(WaitUntil.Completed, data); - SphereImageResource result = lro.Value; + await sphereImage.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ImagesDelete() + public async Task Update_ImageCreateOrUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteImage.json - // this example is just showing the usage of "Images_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutImage.json + // this example is just showing the usage of "Images_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,18 @@ public async Task Delete_ImagesDelete() SphereImageResource sphereImage = client.GetSphereImageResource(sphereImageResourceId); // invoke the operation - await sphereImage.DeleteAsync(WaitUntil.Completed); + SphereImageData data = new SphereImageData + { + Image = "bXliYXNlNjRzdHJpbmc=", + }; + ArmOperation lro = await sphereImage.UpdateAsync(WaitUntil.Completed, data); + SphereImageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereProductCollection.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereProductCollection.cs index 2fda017a31e6e..c8d8ea0690c73 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereProductCollection.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereProductCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SphereProductCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProductsListByCatalog() + public async Task CreateOrUpdate_ProductsCreateOrUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetProducts.json - // this example is just showing the usage of "Products_ListByCatalog" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutProduct.json + // this example is just showing the usage of "Products_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_ProductsListByCatalog() // get the collection of this SphereProductResource SphereProductCollection collection = sphereCatalog.GetSphereProducts(); - // invoke the operation and iterate over the result - await foreach (SphereProductResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereProductData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string productName = "MyProduct1"; + SphereProductData data = new SphereProductData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, productName, data); + SphereProductResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_ProductsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProductsGet() + public async Task GetAll_ProductsListByCatalog() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetProduct.json - // this example is just showing the usage of "Products_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetProducts.json + // this example is just showing the usage of "Products_ListByCatalog" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_ProductsGet() // get the collection of this SphereProductResource SphereProductCollection collection = sphereCatalog.GetSphereProducts(); - // invoke the operation - string productName = "MyProduct1"; - bool result = await collection.ExistsAsync(productName); + // invoke the operation and iterate over the result + await foreach (SphereProductResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereProductData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProductsGet() + public async Task Exists_ProductsGet() { // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetProduct.json // this example is just showing the usage of "Products_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_ProductsGet() // invoke the operation string productName = "MyProduct1"; - NullableResponse response = await collection.GetIfExistsAsync(productName); - SphereProductResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(productName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProductsCreateOrUpdate() + public async Task GetIfExists_ProductsGet() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PutProduct.json - // this example is just showing the usage of "Products_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetProduct.json + // this example is just showing the usage of "Products_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_ProductsCreateOrUpdate() // invoke the operation string productName = "MyProduct1"; - SphereProductData data = new SphereProductData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, productName, data); - SphereProductResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(productName); + SphereProductResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereProductResource.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereProductResource.cs index 127d8353fc686..99dfc02e5b882 100644 --- a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereProductResource.cs +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SphereProductResource.cs @@ -49,10 +49,10 @@ public async Task Get_ProductsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ProductsUpdate() + public async Task Delete_ProductsDelete() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PatchProduct.json - // this example is just showing the usage of "Products_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteProduct.json + // this example is just showing the usage of "Products_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,28 +64,22 @@ public async Task Update_ProductsUpdate() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "MyResourceGroup1"; string catalogName = "MyCatalog1"; - string productName = "MyProduct1"; + string productName = "MyProductName1"; ResourceIdentifier sphereProductResourceId = SphereProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, catalogName, productName); SphereProductResource sphereProduct = client.GetSphereProductResource(sphereProductResourceId); // invoke the operation - SphereProductPatch patch = new SphereProductPatch(); - ArmOperation lro = await sphereProduct.UpdateAsync(WaitUntil.Completed, patch); - SphereProductResource result = lro.Value; + await sphereProduct.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SphereProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ProductsDelete() + public async Task Update_ProductsUpdate() { - // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/DeleteProduct.json - // this example is just showing the usage of "Products_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/PatchProduct.json + // this example is just showing the usage of "Products_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,14 +91,20 @@ public async Task Delete_ProductsDelete() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "MyResourceGroup1"; string catalogName = "MyCatalog1"; - string productName = "MyProductName1"; + string productName = "MyProduct1"; ResourceIdentifier sphereProductResourceId = SphereProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, catalogName, productName); SphereProductResource sphereProduct = client.GetSphereProductResource(sphereProductResourceId); // invoke the operation - await sphereProduct.DeleteAsync(WaitUntil.Completed); + SphereProductPatch patch = new SphereProductPatch(); + ArmOperation lro = await sphereProduct.UpdateAsync(WaitUntil.Completed, patch); + SphereProductResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..9d1525c53d59b --- /dev/null +++ b/sdk/sphere/Azure.ResourceManager.Sphere/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Sphere.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSphereCatalogs_CatalogsListBySubscription() + { + // Generated from example definition: specification/sphere/resource-manager/Microsoft.AzureSphere/stable/2024-04-01/examples/GetCatalogsSub.json + // this example is just showing the usage of "Catalogs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SphereCatalogResource item in subscriptionResource.GetSphereCatalogsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SphereCatalogData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootAppCollection.cs b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootAppCollection.cs index 1df1e7908fcf1..c02b4d0a75f56 100644 --- a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootAppCollection.cs +++ b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootAppCollection.cs @@ -51,9 +51,9 @@ public async Task Get_SpringbootappsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SpringbootappsGetMaximumSetGen() + public async Task Get_SpringbootappsGetMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_Get_MaximumSet_Gen.json + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_Get_MinimumSet_Gen.json // this example is just showing the usage of "springbootapps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -74,17 +74,21 @@ public async Task Exists_SpringbootappsGetMaximumSetGen() // invoke the operation string springbootappsName = "ofjeesoahqtnovlbuvflyknpbhcpeqqhekntvqxyemuwbcqnuxjgfhsf"; - bool result = await collection.ExistsAsync(springbootappsName); + SpringBootAppResource result = await collection.GetAsync(springbootappsName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SpringbootappsGetMaximumSetGen() + public async Task GetAll_SpringbootappsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_Get_MaximumSet_Gen.json - // this example is just showing the usage of "springbootapps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "springbootapps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +106,25 @@ public async Task GetIfExists_SpringbootappsGetMaximumSetGen() // get the collection of this SpringBootAppResource SpringBootAppCollection collection = springBootSite.GetSpringBootApps(); - // invoke the operation - string springbootappsName = "ofjeesoahqtnovlbuvflyknpbhcpeqqhekntvqxyemuwbcqnuxjgfhsf"; - NullableResponse response = await collection.GetIfExistsAsync(springbootappsName); - SpringBootAppResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SpringBootAppResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootAppData resourceData = result.Data; + SpringBootAppData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SpringbootappsGetMinimumSetGen() + public async Task GetAll_SpringbootappsListByResourceGroupMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_Get_MinimumSet_Gen.json - // this example is just showing the usage of "springbootapps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "springbootapps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,22 +142,24 @@ public async Task Get_SpringbootappsGetMinimumSetGen() // get the collection of this SpringBootAppResource SpringBootAppCollection collection = springBootSite.GetSpringBootApps(); - // invoke the operation - string springbootappsName = "ofjeesoahqtnovlbuvflyknpbhcpeqqhekntvqxyemuwbcqnuxjgfhsf"; - SpringBootAppResource result = await collection.GetAsync(springbootappsName); + // invoke the operation and iterate over the result + await foreach (SpringBootAppResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootAppData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SpringbootappsGetMinimumSetGen() + public async Task Exists_SpringbootappsGetMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_Get_MinimumSet_Gen.json + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_Get_MaximumSet_Gen.json // this example is just showing the usage of "springbootapps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -187,7 +187,7 @@ public async Task Exists_SpringbootappsGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SpringbootappsGetMinimumSetGen() + public async Task Exists_SpringbootappsGetMinimumSetGen() { // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_Get_MinimumSet_Gen.json // this example is just showing the usage of "springbootapps_Get" operation, for the dependent resources, they will have to be created separately. @@ -210,29 +210,17 @@ public async Task GetIfExists_SpringbootappsGetMinimumSetGen() // invoke the operation string springbootappsName = "ofjeesoahqtnovlbuvflyknpbhcpeqqhekntvqxyemuwbcqnuxjgfhsf"; - NullableResponse response = await collection.GetIfExistsAsync(springbootappsName); - SpringBootAppResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(springbootappsName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SpringbootappsListByResourceGroupMaximumSetGen() + public async Task GetIfExists_SpringbootappsGetMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "springbootapps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_Get_MaximumSet_Gen.json + // this example is just showing the usage of "springbootapps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -250,25 +238,31 @@ public async Task GetAll_SpringbootappsListByResourceGroupMaximumSetGen() // get the collection of this SpringBootAppResource SpringBootAppCollection collection = springBootSite.GetSpringBootApps(); - // invoke the operation and iterate over the result - await foreach (SpringBootAppResource item in collection.GetAllAsync()) + // invoke the operation + string springbootappsName = "ofjeesoahqtnovlbuvflyknpbhcpeqqhekntvqxyemuwbcqnuxjgfhsf"; + NullableResponse response = await collection.GetIfExistsAsync(springbootappsName); + SpringBootAppResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootAppData resourceData = item.Data; + SpringBootAppData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SpringbootappsListByResourceGroupMinimumSetGen() + public async Task GetIfExists_SpringbootappsGetMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "springbootapps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_Get_MinimumSet_Gen.json + // this example is just showing the usage of "springbootapps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -286,17 +280,23 @@ public async Task GetAll_SpringbootappsListByResourceGroupMinimumSetGen() // get the collection of this SpringBootAppResource SpringBootAppCollection collection = springBootSite.GetSpringBootApps(); - // invoke the operation and iterate over the result - await foreach (SpringBootAppResource item in collection.GetAllAsync()) + // invoke the operation + string springbootappsName = "ofjeesoahqtnovlbuvflyknpbhcpeqqhekntvqxyemuwbcqnuxjgfhsf"; + NullableResponse response = await collection.GetIfExistsAsync(springbootappsName); + SpringBootAppResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootAppData resourceData = item.Data; + SpringBootAppData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootAppResource.cs b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootAppResource.cs index 09cdd20d7a860..314560c391073 100644 --- a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootAppResource.cs +++ b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootAppResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SpringAppDiscovery.Models; using NUnit.Framework; @@ -144,69 +143,5 @@ public async Task Update_SpringbootappsUpdateMinimumSetGen() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSpringBootApps_SpringbootappsListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "springbootapps_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "jnetwlorzmxpxmcucorv"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string siteName = "pdfosfhtemfsaglvwjdyqlyeipucrd"; - await foreach (SpringBootAppResource item in subscriptionResource.GetSpringBootAppsAsync(siteName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootAppData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSpringBootApps_SpringbootappsListBySubscriptionMinimumSetGen() - { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "springbootapps_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "jnetwlorzmxpxmcucorv"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string siteName = "pdfosfhtemfsaglvwjdyqlyeipucrd"; - await foreach (SpringBootAppResource item in subscriptionResource.GetSpringBootAppsAsync(siteName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootAppData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootServerCollection.cs b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootServerCollection.cs index fd0f3668b07cd..d11a546ac2d9e 100644 --- a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootServerCollection.cs +++ b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootServerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SpringBootServerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SpringbootserversGetMaximumSetGen() + public async Task CreateOrUpdate_SpringbootserversCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_Get_MaximumSet_Gen.json - // this example is just showing the usage of "springbootservers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "springbootservers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,20 @@ public async Task Get_SpringbootserversGetMaximumSetGen() // invoke the operation string springbootserversName = "zkarbqnwnxeozvjrkpdqmgnwedwgtwcmmyqwaijkn"; - SpringBootServerResource result = await collection.GetAsync(springbootserversName); + SpringBootServerData data = new SpringBootServerData + { + Properties = new SpringBootServerProperties("thhuxocfyqpeluqcgnypi") + { + Port = 10, + FqdnAndIPAddressList = { }, + MachineArmId = new ResourceIdentifier("fvfkiapbqsprnbzczdfmuryknrna"), + TotalApps = 5, + SpringBootApps = 17, + Errors = { }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, springbootserversName, data); + SpringBootServerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +65,10 @@ public async Task Get_SpringbootserversGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SpringbootserversGetMaximumSetGen() + public async Task CreateOrUpdate_SpringbootserversCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_Get_MaximumSet_Gen.json - // this example is just showing the usage of "springbootservers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "springbootservers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +88,20 @@ public async Task Exists_SpringbootserversGetMaximumSetGen() // invoke the operation string springbootserversName = "zkarbqnwnxeozvjrkpdqmgnwedwgtwcmmyqwaijkn"; - bool result = await collection.ExistsAsync(springbootserversName); + SpringBootServerData data = new SpringBootServerData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, springbootserversName, data); + SpringBootServerResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SpringbootserversGetMaximumSetGen() + public async Task Get_SpringbootserversGetMaximumSetGen() { // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_Get_MaximumSet_Gen.json // this example is just showing the usage of "springbootservers_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,21 +124,13 @@ public async Task GetIfExists_SpringbootserversGetMaximumSetGen() // invoke the operation string springbootserversName = "zkarbqnwnxeozvjrkpdqmgnwedwgtwcmmyqwaijkn"; - NullableResponse response = await collection.GetIfExistsAsync(springbootserversName); - SpringBootServerResource result = response.HasValue ? response.Value : null; + SpringBootServerResource result = await collection.GetAsync(springbootserversName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -158,10 +169,10 @@ public async Task Get_SpringbootserversGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SpringbootserversGetMinimumSetGen() + public async Task GetAll_SpringbootserversListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_Get_MinimumSet_Gen.json - // this example is just showing the usage of "springbootservers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "springbootservers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,19 +190,25 @@ public async Task Exists_SpringbootserversGetMinimumSetGen() // get the collection of this SpringBootServerResource SpringBootServerCollection collection = springBootSite.GetSpringBootServers(); - // invoke the operation - string springbootserversName = "zkarbqnwnxeozvjrkpdqmgnwedwgtwcmmyqwaijkn"; - bool result = await collection.ExistsAsync(springbootserversName); + // invoke the operation and iterate over the result + await foreach (SpringBootServerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SpringbootserversGetMinimumSetGen() + public async Task GetAll_SpringbootserversListByResourceGroupMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_Get_MinimumSet_Gen.json - // this example is just showing the usage of "springbootservers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "springbootservers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -209,31 +226,25 @@ public async Task GetIfExists_SpringbootserversGetMinimumSetGen() // get the collection of this SpringBootServerResource SpringBootServerCollection collection = springBootSite.GetSpringBootServers(); - // invoke the operation - string springbootserversName = "zkarbqnwnxeozvjrkpdqmgnwedwgtwcmmyqwaijkn"; - NullableResponse response = await collection.GetIfExistsAsync(springbootserversName); - SpringBootServerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SpringBootServerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootServerData resourceData = result.Data; + SpringBootServerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SpringbootserversCreateOrUpdateMaximumSetGen() + public async Task Exists_SpringbootserversGetMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "springbootservers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_Get_MaximumSet_Gen.json + // this example is just showing the usage of "springbootservers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -253,38 +264,17 @@ public async Task CreateOrUpdate_SpringbootserversCreateOrUpdateMaximumSetGen() // invoke the operation string springbootserversName = "zkarbqnwnxeozvjrkpdqmgnwedwgtwcmmyqwaijkn"; - SpringBootServerData data = new SpringBootServerData() - { - Properties = new SpringBootServerProperties("thhuxocfyqpeluqcgnypi") - { - Port = 10, - FqdnAndIPAddressList = -{ -}, - MachineArmId = new ResourceIdentifier("fvfkiapbqsprnbzczdfmuryknrna"), - TotalApps = 5, - SpringBootApps = 17, - Errors = -{ -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, springbootserversName, data); - SpringBootServerResource result = lro.Value; + bool result = await collection.ExistsAsync(springbootserversName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SpringbootserversCreateOrUpdateMinimumSetGen() + public async Task Exists_SpringbootserversGetMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "springbootservers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_Get_MinimumSet_Gen.json + // this example is just showing the usage of "springbootservers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -304,23 +294,17 @@ public async Task CreateOrUpdate_SpringbootserversCreateOrUpdateMinimumSetGen() // invoke the operation string springbootserversName = "zkarbqnwnxeozvjrkpdqmgnwedwgtwcmmyqwaijkn"; - SpringBootServerData data = new SpringBootServerData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, springbootserversName, data); - SpringBootServerResource result = lro.Value; + bool result = await collection.ExistsAsync(springbootserversName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SpringbootserversListByResourceGroupMaximumSetGen() + public async Task GetIfExists_SpringbootserversGetMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "springbootservers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_Get_MaximumSet_Gen.json + // this example is just showing the usage of "springbootservers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -338,25 +322,31 @@ public async Task GetAll_SpringbootserversListByResourceGroupMaximumSetGen() // get the collection of this SpringBootServerResource SpringBootServerCollection collection = springBootSite.GetSpringBootServers(); - // invoke the operation and iterate over the result - await foreach (SpringBootServerResource item in collection.GetAllAsync()) + // invoke the operation + string springbootserversName = "zkarbqnwnxeozvjrkpdqmgnwedwgtwcmmyqwaijkn"; + NullableResponse response = await collection.GetIfExistsAsync(springbootserversName); + SpringBootServerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootServerData resourceData = item.Data; + SpringBootServerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SpringbootserversListByResourceGroupMinimumSetGen() + public async Task GetIfExists_SpringbootserversGetMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "springbootservers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_Get_MinimumSet_Gen.json + // this example is just showing the usage of "springbootservers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -374,17 +364,23 @@ public async Task GetAll_SpringbootserversListByResourceGroupMinimumSetGen() // get the collection of this SpringBootServerResource SpringBootServerCollection collection = springBootSite.GetSpringBootServers(); - // invoke the operation and iterate over the result - await foreach (SpringBootServerResource item in collection.GetAllAsync()) + // invoke the operation + string springbootserversName = "zkarbqnwnxeozvjrkpdqmgnwedwgtwcmmyqwaijkn"; + NullableResponse response = await collection.GetIfExistsAsync(springbootserversName); + SpringBootServerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootServerData resourceData = item.Data; + SpringBootServerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootServerResource.cs b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootServerResource.cs index f035289f61a7a..ff8359b53a89f 100644 --- a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootServerResource.cs +++ b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootServerResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SpringAppDiscovery.Models; using NUnit.Framework; @@ -198,69 +197,5 @@ public async Task Update_SpringbootserversUpdateMinimumSetGen() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSpringBootServers_SpringbootserversListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "springbootservers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "etmdxomjncqvygm"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string siteName = "hlkrzldhyobavtabgpubtjbhlslnjmsvkthwcfboriwyxndacjypzbj"; - await foreach (SpringBootServerResource item in subscriptionResource.GetSpringBootServersAsync(siteName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSpringBootServers_SpringbootserversListBySubscriptionMinimumSetGen() - { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "springbootservers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "etmdxomjncqvygm"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string siteName = "hlkrzldhyobavtabgpubtjbhlslnjmsvkthwcfboriwyxndacjypzbj"; - await foreach (SpringBootServerResource item in subscriptionResource.GetSpringBootServersAsync(siteName)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteCollection.cs b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteCollection.cs index d9f0a04a464bb..16ed23d3f36a3 100644 --- a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteCollection.cs +++ b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SpringBootSiteCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SpringbootsitesGetMaximumSetGen() + public async Task CreateOrUpdate_SpringbootsitesCreateOrUpdateMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_Get_MaximumSet_Gen.json - // this example is just showing the usage of "springbootsites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "springbootsites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,25 @@ public async Task Get_SpringbootsitesGetMaximumSetGen() // invoke the operation string springbootsitesName = "xrmzlavpewxtfeitghdrj"; - SpringBootSiteResource result = await collection.GetAsync(springbootsitesName); + SpringBootSiteData data = new SpringBootSiteData(new AzureLocation("tgobtvxktootwhhvjtsmpddvlqlrq")) + { + Properties = new SpringBootSiteProperties + { + MasterSiteId = "xsoimrgshsactearljwuljmi", + MigrateProjectId = "wwuattybgco", + }, + ExtendedLocation = new SpringBootSiteModelExtendedLocation + { + SpringbootsitesModelExtendedLocationType = "lvsb", + Name = "rywvpbfsqovhlfirtwisugsdsfsgf", + }, + Tags = +{ +["key3558"] = "xeuhtglamqzj" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, springbootsitesName, data); + SpringBootSiteResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +70,10 @@ public async Task Get_SpringbootsitesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SpringbootsitesGetMaximumSetGen() + public async Task CreateOrUpdate_SpringbootsitesCreateOrUpdateMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_Get_MaximumSet_Gen.json - // this example is just showing the usage of "springbootsites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_CreateOrUpdate_MinimumSet_Gen.json + // this example is just showing the usage of "springbootsites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,14 +92,20 @@ public async Task Exists_SpringbootsitesGetMaximumSetGen() // invoke the operation string springbootsitesName = "xrmzlavpewxtfeitghdrj"; - bool result = await collection.ExistsAsync(springbootsitesName); + SpringBootSiteData data = new SpringBootSiteData(new AzureLocation("tgobtvxktootwhhvjtsmpddvlqlrq")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, springbootsitesName, data); + SpringBootSiteResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SpringbootsitesGetMaximumSetGen() + public async Task Get_SpringbootsitesGetMaximumSetGen() { // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_Get_MaximumSet_Gen.json // this example is just showing the usage of "springbootsites_Get" operation, for the dependent resources, they will have to be created separately. @@ -103,21 +127,13 @@ public async Task GetIfExists_SpringbootsitesGetMaximumSetGen() // invoke the operation string springbootsitesName = "xrmzlavpewxtfeitghdrj"; - NullableResponse response = await collection.GetIfExistsAsync(springbootsitesName); - SpringBootSiteResource result = response.HasValue ? response.Value : null; + SpringBootSiteResource result = await collection.GetAsync(springbootsitesName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -155,10 +171,10 @@ public async Task Get_SpringbootsitesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SpringbootsitesGetMinimumSetGen() + public async Task GetAll_SpringbootsitesListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_Get_MinimumSet_Gen.json - // this example is just showing the usage of "springbootsites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "springbootsites_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -175,19 +191,25 @@ public async Task Exists_SpringbootsitesGetMinimumSetGen() // get the collection of this SpringBootSiteResource SpringBootSiteCollection collection = resourceGroupResource.GetSpringBootSites(); - // invoke the operation - string springbootsitesName = "xrmzlavpewxtfeitghdrj"; - bool result = await collection.ExistsAsync(springbootsitesName); + // invoke the operation and iterate over the result + await foreach (SpringBootSiteResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootSiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SpringbootsitesGetMinimumSetGen() + public async Task GetAll_SpringbootsitesListByResourceGroupMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_Get_MinimumSet_Gen.json - // this example is just showing the usage of "springbootsites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_ListByResourceGroup_MinimumSet_Gen.json + // this example is just showing the usage of "springbootsites_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,31 +226,25 @@ public async Task GetIfExists_SpringbootsitesGetMinimumSetGen() // get the collection of this SpringBootSiteResource SpringBootSiteCollection collection = resourceGroupResource.GetSpringBootSites(); - // invoke the operation - string springbootsitesName = "xrmzlavpewxtfeitghdrj"; - NullableResponse response = await collection.GetIfExistsAsync(springbootsitesName); - SpringBootSiteResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SpringBootSiteResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootSiteData resourceData = result.Data; + SpringBootSiteData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SpringbootsitesCreateOrUpdateMaximumSetGen() + public async Task Exists_SpringbootsitesGetMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "springbootsites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_Get_MaximumSet_Gen.json + // this example is just showing the usage of "springbootsites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -247,39 +263,17 @@ public async Task CreateOrUpdate_SpringbootsitesCreateOrUpdateMaximumSetGen() // invoke the operation string springbootsitesName = "xrmzlavpewxtfeitghdrj"; - SpringBootSiteData data = new SpringBootSiteData(new AzureLocation("tgobtvxktootwhhvjtsmpddvlqlrq")) - { - Properties = new SpringBootSiteProperties() - { - MasterSiteId = "xsoimrgshsactearljwuljmi", - MigrateProjectId = "wwuattybgco", - }, - ExtendedLocation = new SpringBootSiteModelExtendedLocation() - { - SpringbootsitesModelExtendedLocationType = "lvsb", - Name = "rywvpbfsqovhlfirtwisugsdsfsgf", - }, - Tags = -{ -["key3558"] = "xeuhtglamqzj", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, springbootsitesName, data); - SpringBootSiteResource result = lro.Value; + bool result = await collection.ExistsAsync(springbootsitesName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SpringbootsitesCreateOrUpdateMinimumSetGen() + public async Task Exists_SpringbootsitesGetMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_CreateOrUpdate_MinimumSet_Gen.json - // this example is just showing the usage of "springbootsites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_Get_MinimumSet_Gen.json + // this example is just showing the usage of "springbootsites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -298,23 +292,17 @@ public async Task CreateOrUpdate_SpringbootsitesCreateOrUpdateMinimumSetGen() // invoke the operation string springbootsitesName = "xrmzlavpewxtfeitghdrj"; - SpringBootSiteData data = new SpringBootSiteData(new AzureLocation("tgobtvxktootwhhvjtsmpddvlqlrq")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, springbootsitesName, data); - SpringBootSiteResource result = lro.Value; + bool result = await collection.ExistsAsync(springbootsitesName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SpringbootsitesListByResourceGroupMaximumSetGen() + public async Task GetIfExists_SpringbootsitesGetMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "springbootsites_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_Get_MaximumSet_Gen.json + // this example is just showing the usage of "springbootsites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -331,25 +319,31 @@ public async Task GetAll_SpringbootsitesListByResourceGroupMaximumSetGen() // get the collection of this SpringBootSiteResource SpringBootSiteCollection collection = resourceGroupResource.GetSpringBootSites(); - // invoke the operation and iterate over the result - await foreach (SpringBootSiteResource item in collection.GetAllAsync()) + // invoke the operation + string springbootsitesName = "xrmzlavpewxtfeitghdrj"; + NullableResponse response = await collection.GetIfExistsAsync(springbootsitesName); + SpringBootSiteResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootSiteData resourceData = item.Data; + SpringBootSiteData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SpringbootsitesListByResourceGroupMinimumSetGen() + public async Task GetIfExists_SpringbootsitesGetMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_ListByResourceGroup_MinimumSet_Gen.json - // this example is just showing the usage of "springbootsites_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_Get_MinimumSet_Gen.json + // this example is just showing the usage of "springbootsites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -366,17 +360,23 @@ public async Task GetAll_SpringbootsitesListByResourceGroupMinimumSetGen() // get the collection of this SpringBootSiteResource SpringBootSiteCollection collection = resourceGroupResource.GetSpringBootSites(); - // invoke the operation and iterate over the result - await foreach (SpringBootSiteResource item in collection.GetAllAsync()) + // invoke the operation + string springbootsitesName = "xrmzlavpewxtfeitghdrj"; + NullableResponse response = await collection.GetIfExistsAsync(springbootsitesName); + SpringBootSiteResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootSiteData resourceData = item.Data; + SpringBootSiteData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteErrorSummaryCollection.cs b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteErrorSummaryCollection.cs index 0aab1fd7aa904..8405f66a5f91b 100644 --- a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteErrorSummaryCollection.cs +++ b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteErrorSummaryCollection.cs @@ -51,9 +51,9 @@ public async Task Get_ErrorSummariesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ErrorSummariesGetMaximumSetGen() + public async Task Get_ErrorSummariesGetMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_Get_MaximumSet_Gen.json + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_Get_MinimumSet_Gen.json // this example is just showing the usage of "ErrorSummaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -74,17 +74,21 @@ public async Task Exists_ErrorSummariesGetMaximumSetGen() // invoke the operation string errorSummaryName = "K2lv"; - bool result = await collection.ExistsAsync(errorSummaryName); + SpringBootSiteErrorSummaryResource result = await collection.GetAsync(errorSummaryName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootSiteErrorSummaryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ErrorSummariesGetMaximumSetGen() + public async Task GetAll_ErrorSummariesListBySiteMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_Get_MaximumSet_Gen.json - // this example is just showing the usage of "ErrorSummaries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_ListBySite_MaximumSet_Gen.json + // this example is just showing the usage of "ErrorSummaries_ListBySite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +106,25 @@ public async Task GetIfExists_ErrorSummariesGetMaximumSetGen() // get the collection of this SpringBootSiteErrorSummaryResource SpringBootSiteErrorSummaryCollection collection = springBootSite.GetSpringBootSiteErrorSummaries(); - // invoke the operation - string errorSummaryName = "K2lv"; - NullableResponse response = await collection.GetIfExistsAsync(errorSummaryName); - SpringBootSiteErrorSummaryResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SpringBootSiteErrorSummaryResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootSiteErrorSummaryData resourceData = result.Data; + SpringBootSiteErrorSummaryData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ErrorSummariesGetMinimumSetGen() + public async Task GetAll_ErrorSummariesListBySiteMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_Get_MinimumSet_Gen.json - // this example is just showing the usage of "ErrorSummaries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_ListBySite_MinimumSet_Gen.json + // this example is just showing the usage of "ErrorSummaries_ListBySite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,22 +142,24 @@ public async Task Get_ErrorSummariesGetMinimumSetGen() // get the collection of this SpringBootSiteErrorSummaryResource SpringBootSiteErrorSummaryCollection collection = springBootSite.GetSpringBootSiteErrorSummaries(); - // invoke the operation - string errorSummaryName = "K2lv"; - SpringBootSiteErrorSummaryResource result = await collection.GetAsync(errorSummaryName); + // invoke the operation and iterate over the result + await foreach (SpringBootSiteErrorSummaryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootSiteErrorSummaryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootSiteErrorSummaryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ErrorSummariesGetMinimumSetGen() + public async Task Exists_ErrorSummariesGetMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_Get_MinimumSet_Gen.json + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_Get_MaximumSet_Gen.json // this example is just showing the usage of "ErrorSummaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -187,7 +187,7 @@ public async Task Exists_ErrorSummariesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ErrorSummariesGetMinimumSetGen() + public async Task Exists_ErrorSummariesGetMinimumSetGen() { // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_Get_MinimumSet_Gen.json // this example is just showing the usage of "ErrorSummaries_Get" operation, for the dependent resources, they will have to be created separately. @@ -210,29 +210,17 @@ public async Task GetIfExists_ErrorSummariesGetMinimumSetGen() // invoke the operation string errorSummaryName = "K2lv"; - NullableResponse response = await collection.GetIfExistsAsync(errorSummaryName); - SpringBootSiteErrorSummaryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(errorSummaryName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootSiteErrorSummaryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ErrorSummariesListBySiteMaximumSetGen() + public async Task GetIfExists_ErrorSummariesGetMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_ListBySite_MaximumSet_Gen.json - // this example is just showing the usage of "ErrorSummaries_ListBySite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_Get_MaximumSet_Gen.json + // this example is just showing the usage of "ErrorSummaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -250,25 +238,31 @@ public async Task GetAll_ErrorSummariesListBySiteMaximumSetGen() // get the collection of this SpringBootSiteErrorSummaryResource SpringBootSiteErrorSummaryCollection collection = springBootSite.GetSpringBootSiteErrorSummaries(); - // invoke the operation and iterate over the result - await foreach (SpringBootSiteErrorSummaryResource item in collection.GetAllAsync()) + // invoke the operation + string errorSummaryName = "K2lv"; + NullableResponse response = await collection.GetIfExistsAsync(errorSummaryName); + SpringBootSiteErrorSummaryResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootSiteErrorSummaryData resourceData = item.Data; + SpringBootSiteErrorSummaryData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ErrorSummariesListBySiteMinimumSetGen() + public async Task GetIfExists_ErrorSummariesGetMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_ListBySite_MinimumSet_Gen.json - // this example is just showing the usage of "ErrorSummaries_ListBySite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/ErrorSummaries_Get_MinimumSet_Gen.json + // this example is just showing the usage of "ErrorSummaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -286,17 +280,23 @@ public async Task GetAll_ErrorSummariesListBySiteMinimumSetGen() // get the collection of this SpringBootSiteErrorSummaryResource SpringBootSiteErrorSummaryCollection collection = springBootSite.GetSpringBootSiteErrorSummaries(); - // invoke the operation and iterate over the result - await foreach (SpringBootSiteErrorSummaryResource item in collection.GetAllAsync()) + // invoke the operation + string errorSummaryName = "K2lv"; + NullableResponse response = await collection.GetIfExistsAsync(errorSummaryName); + SpringBootSiteErrorSummaryResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootSiteErrorSummaryData resourceData = item.Data; + SpringBootSiteErrorSummaryData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteResource.cs b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteResource.cs index bed983059c79c..6b7231515acc8 100644 --- a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteResource.cs +++ b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SpringAppDiscovery.Models; using NUnit.Framework; @@ -154,7 +153,7 @@ public async Task Update_SpringbootsitesUpdateMaximumSetGen() { Tags = { -["key9581"] = "cgdqvbknjrwcwuesquddsxu", +["key9581"] = "cgdqvbknjrwcwuesquddsxu" }, }; ArmOperation lro = await springBootSite.UpdateAsync(WaitUntil.Completed, patch); @@ -250,67 +249,5 @@ public async Task TriggerRefreshSite_SpringbootsitesTriggerRefreshSiteMinimumSet Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSpringBootSites_SpringbootsitesListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "springbootsites_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "chshxczdscjpcyvyethat"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SpringBootSiteResource item in subscriptionResource.GetSpringBootSitesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootSiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSpringBootSites_SpringbootsitesListBySubscriptionMinimumSetGen() - { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_ListBySubscription_MinimumSet_Gen.json - // this example is just showing the usage of "springbootsites_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "chshxczdscjpcyvyethat"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SpringBootSiteResource item in subscriptionResource.GetSpringBootSitesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootSiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteSummaryCollection.cs b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteSummaryCollection.cs index d5ed107d9a51a..47745dbe9ef1d 100644 --- a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteSummaryCollection.cs +++ b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SpringBootSiteSummaryCollection.cs @@ -51,9 +51,9 @@ public async Task Get_SummariesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SummariesGetMaximumSetGen() + public async Task Get_SummariesGetMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_Get_MaximumSet_Gen.json + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_Get_MinimumSet_Gen.json // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -74,17 +74,21 @@ public async Task Exists_SummariesGetMaximumSetGen() // invoke the operation string summaryName = "vjB"; - bool result = await collection.ExistsAsync(summaryName); + SpringBootSiteSummaryResource result = await collection.GetAsync(summaryName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootSiteSummaryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SummariesGetMaximumSetGen() + public async Task GetAll_SummariesListBySiteMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_ListBySite_MaximumSet_Gen.json + // this example is just showing the usage of "Summaries_ListBySite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +106,25 @@ public async Task GetIfExists_SummariesGetMaximumSetGen() // get the collection of this SpringBootSiteSummaryResource SpringBootSiteSummaryCollection collection = springBootSite.GetSpringBootSiteSummaries(); - // invoke the operation - string summaryName = "vjB"; - NullableResponse response = await collection.GetIfExistsAsync(summaryName); - SpringBootSiteSummaryResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SpringBootSiteSummaryResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootSiteSummaryData resourceData = result.Data; + SpringBootSiteSummaryData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SummariesGetMinimumSetGen() + public async Task GetAll_SummariesListBySiteMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_Get_MinimumSet_Gen.json - // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_ListBySite_MinimumSet_Gen.json + // this example is just showing the usage of "Summaries_ListBySite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,22 +142,24 @@ public async Task Get_SummariesGetMinimumSetGen() // get the collection of this SpringBootSiteSummaryResource SpringBootSiteSummaryCollection collection = springBootSite.GetSpringBootSiteSummaries(); - // invoke the operation - string summaryName = "vjB"; - SpringBootSiteSummaryResource result = await collection.GetAsync(summaryName); + // invoke the operation and iterate over the result + await foreach (SpringBootSiteSummaryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootSiteSummaryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootSiteSummaryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SummariesGetMinimumSetGen() + public async Task Exists_SummariesGetMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_Get_MinimumSet_Gen.json + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_Get_MaximumSet_Gen.json // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -187,7 +187,7 @@ public async Task Exists_SummariesGetMinimumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SummariesGetMinimumSetGen() + public async Task Exists_SummariesGetMinimumSetGen() { // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_Get_MinimumSet_Gen.json // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. @@ -210,29 +210,17 @@ public async Task GetIfExists_SummariesGetMinimumSetGen() // invoke the operation string summaryName = "vjB"; - NullableResponse response = await collection.GetIfExistsAsync(summaryName); - SpringBootSiteSummaryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(summaryName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpringBootSiteSummaryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SummariesListBySiteMaximumSetGen() + public async Task GetIfExists_SummariesGetMaximumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_ListBySite_MaximumSet_Gen.json - // this example is just showing the usage of "Summaries_ListBySite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -250,25 +238,31 @@ public async Task GetAll_SummariesListBySiteMaximumSetGen() // get the collection of this SpringBootSiteSummaryResource SpringBootSiteSummaryCollection collection = springBootSite.GetSpringBootSiteSummaries(); - // invoke the operation and iterate over the result - await foreach (SpringBootSiteSummaryResource item in collection.GetAllAsync()) + // invoke the operation + string summaryName = "vjB"; + NullableResponse response = await collection.GetIfExistsAsync(summaryName); + SpringBootSiteSummaryResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootSiteSummaryData resourceData = item.Data; + SpringBootSiteSummaryData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SummariesListBySiteMinimumSetGen() + public async Task GetIfExists_SummariesGetMinimumSetGen() { - // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_ListBySite_MinimumSet_Gen.json - // this example is just showing the usage of "Summaries_ListBySite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/Summaries_Get_MinimumSet_Gen.json + // this example is just showing the usage of "Summaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -286,17 +280,23 @@ public async Task GetAll_SummariesListBySiteMinimumSetGen() // get the collection of this SpringBootSiteSummaryResource SpringBootSiteSummaryCollection collection = springBootSite.GetSpringBootSiteSummaries(); - // invoke the operation and iterate over the result - await foreach (SpringBootSiteSummaryResource item in collection.GetAllAsync()) + // invoke the operation + string summaryName = "vjB"; + NullableResponse response = await collection.GetIfExistsAsync(summaryName); + SpringBootSiteSummaryResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SpringBootSiteSummaryData resourceData = item.Data; + SpringBootSiteSummaryData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..523ab6a0a2325 --- /dev/null +++ b/sdk/springappdiscovery/Azure.ResourceManager.SpringAppDiscovery/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,209 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.SpringAppDiscovery.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSpringBootSites_SpringbootsitesListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "springbootsites_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "chshxczdscjpcyvyethat"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SpringBootSiteResource item in subscriptionResource.GetSpringBootSitesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootSiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSpringBootSites_SpringbootsitesListBySubscriptionMinimumSetGen() + { + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootsites_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "springbootsites_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "chshxczdscjpcyvyethat"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SpringBootSiteResource item in subscriptionResource.GetSpringBootSitesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootSiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSpringBootServers_SpringbootserversListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "springbootservers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "etmdxomjncqvygm"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string siteName = "hlkrzldhyobavtabgpubtjbhlslnjmsvkthwcfboriwyxndacjypzbj"; + await foreach (SpringBootServerResource item in subscriptionResource.GetSpringBootServersAsync(siteName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSpringBootServers_SpringbootserversListBySubscriptionMinimumSetGen() + { + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootservers_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "springbootservers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "etmdxomjncqvygm"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string siteName = "hlkrzldhyobavtabgpubtjbhlslnjmsvkthwcfboriwyxndacjypzbj"; + await foreach (SpringBootServerResource item in subscriptionResource.GetSpringBootServersAsync(siteName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSpringBootApps_SpringbootappsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "springbootapps_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "jnetwlorzmxpxmcucorv"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string siteName = "pdfosfhtemfsaglvwjdyqlyeipucrd"; + await foreach (SpringBootAppResource item in subscriptionResource.GetSpringBootAppsAsync(siteName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootAppData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSpringBootApps_SpringbootappsListBySubscriptionMinimumSetGen() + { + // Generated from example definition: specification/offazurespringboot/resource-manager/Microsoft.OffAzureSpringBoot/preview/2023-01-01-preview/examples/springbootapps_ListBySubscription_MinimumSet_Gen.json + // this example is just showing the usage of "springbootapps_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "jnetwlorzmxpxmcucorv"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string siteName = "pdfosfhtemfsaglvwjdyqlyeipucrd"; + await foreach (SpringBootAppResource item in subscriptionResource.GetSpringBootAppsAsync(siteName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpringBootAppData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_BackupShortTermRetentionPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_BackupShortTermRetentionPolicyCollection.cs index abe5b6d40c9bb..cc5129f7c504b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_BackupShortTermRetentionPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_BackupShortTermRetentionPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BackupShortTermRetentionPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() + public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetShortTermRetentionPolicy.json - // this example is just showing the usage of "BackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/UpdateShortTermRetentionPolicy.json + // this example is just showing the usage of "BackupShortTermRetentionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; + string resourceGroupName = "resourceGroup"; string serverName = "testsvr"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); @@ -42,7 +42,13 @@ public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() // invoke the operation ShortTermRetentionPolicyName policyName = ShortTermRetentionPolicyName.Default; - BackupShortTermRetentionPolicyResource result = await collection.GetAsync(policyName); + BackupShortTermRetentionPolicyData data = new BackupShortTermRetentionPolicyData + { + RetentionDays = 7, + DiffBackupIntervalInHours = DiffBackupIntervalInHours.TwentyFour, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + BackupShortTermRetentionPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +59,7 @@ public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheShortTermRetentionPolicyForTheDatabase() + public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetShortTermRetentionPolicy.json // this example is just showing the usage of "BackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +83,21 @@ public async Task Exists_GetTheShortTermRetentionPolicyForTheDatabase() // invoke the operation ShortTermRetentionPolicyName policyName = ShortTermRetentionPolicyName.Default; - bool result = await collection.ExistsAsync(policyName); + BackupShortTermRetentionPolicyResource result = await collection.GetAsync(policyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackupShortTermRetentionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheShortTermRetentionPolicyForTheDatabase() + public async Task GetAll_GetTheShortTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetShortTermRetentionPolicy.json - // this example is just showing the usage of "BackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListShortTermRetentionPoliciesByDatabase.json + // this example is just showing the usage of "BackupShortTermRetentionPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +116,25 @@ public async Task GetIfExists_GetTheShortTermRetentionPolicyForTheDatabase() // get the collection of this BackupShortTermRetentionPolicyResource BackupShortTermRetentionPolicyCollection collection = sqlDatabase.GetBackupShortTermRetentionPolicies(); - // invoke the operation - ShortTermRetentionPolicyName policyName = ShortTermRetentionPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - BackupShortTermRetentionPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (BackupShortTermRetentionPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BackupShortTermRetentionPolicyData resourceData = result.Data; + BackupShortTermRetentionPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheDatabase() + public async Task Exists_GetTheShortTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/UpdateShortTermRetentionPolicy.json - // this example is just showing the usage of "BackupShortTermRetentionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetShortTermRetentionPolicy.json + // this example is just showing the usage of "BackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,7 +144,7 @@ public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheDatabase // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "resourceGroup"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; string serverName = "testsvr"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); @@ -151,27 +155,17 @@ public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheDatabase // invoke the operation ShortTermRetentionPolicyName policyName = ShortTermRetentionPolicyName.Default; - BackupShortTermRetentionPolicyData data = new BackupShortTermRetentionPolicyData() - { - RetentionDays = 7, - DiffBackupIntervalInHours = DiffBackupIntervalInHours.TwentyFour, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - BackupShortTermRetentionPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(policyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackupShortTermRetentionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheShortTermRetentionPolicyForTheDatabase() + public async Task GetIfExists_GetTheShortTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListShortTermRetentionPoliciesByDatabase.json - // this example is just showing the usage of "BackupShortTermRetentionPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetShortTermRetentionPolicy.json + // this example is just showing the usage of "BackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +184,23 @@ public async Task GetAll_GetTheShortTermRetentionPolicyForTheDatabase() // get the collection of this BackupShortTermRetentionPolicyResource BackupShortTermRetentionPolicyCollection collection = sqlDatabase.GetBackupShortTermRetentionPolicies(); - // invoke the operation and iterate over the result - await foreach (BackupShortTermRetentionPolicyResource item in collection.GetAllAsync()) + // invoke the operation + ShortTermRetentionPolicyName policyName = ShortTermRetentionPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + BackupShortTermRetentionPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BackupShortTermRetentionPolicyData resourceData = item.Data; + BackupShortTermRetentionPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_BackupShortTermRetentionPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_BackupShortTermRetentionPolicyResource.cs index c75bb44259e36..20c2548e6568b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_BackupShortTermRetentionPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_BackupShortTermRetentionPolicyResource.cs @@ -71,7 +71,7 @@ public async Task Update_UpdateTheShortTermRetentionPolicyForTheDatabase() BackupShortTermRetentionPolicyResource backupShortTermRetentionPolicy = client.GetBackupShortTermRetentionPolicyResource(backupShortTermRetentionPolicyResourceId); // invoke the operation - BackupShortTermRetentionPolicyData data = new BackupShortTermRetentionPolicyData() + BackupShortTermRetentionPolicyData data = new BackupShortTermRetentionPolicyData { RetentionDays = 7, DiffBackupIntervalInHours = DiffBackupIntervalInHours.TwentyFour, diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DataMaskingPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DataMaskingPolicyResource.cs index 16a8c0b7f1a08..689478dca04b6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DataMaskingPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DataMaskingPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DataMaskingPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMax() + public async Task Get_GetDataMaskingPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingPolicyCreateOrUpdateMax.json - // this example is just showing the usage of "DataMaskingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingPolicyGet.json + // this example is just showing the usage of "DataMaskingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,13 +38,7 @@ public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMax() DataMaskingPolicyResource dataMaskingPolicy = client.GetDataMaskingPolicyResource(dataMaskingPolicyResourceId); // invoke the operation - DataMaskingPolicyData data = new DataMaskingPolicyData() - { - DataMaskingState = DataMaskingState.Enabled, - ExemptPrincipals = "testuser;", - }; - ArmOperation lro = await dataMaskingPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); - DataMaskingPolicyResource result = lro.Value; + DataMaskingPolicyResource result = await dataMaskingPolicy.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,9 +49,9 @@ public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMax() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMin() + public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMax() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingPolicyCreateOrUpdateMin.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingPolicyCreateOrUpdateMax.json // this example is just showing the usage of "DataMaskingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -75,9 +69,10 @@ public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMin() DataMaskingPolicyResource dataMaskingPolicy = client.GetDataMaskingPolicyResource(dataMaskingPolicyResourceId); // invoke the operation - DataMaskingPolicyData data = new DataMaskingPolicyData() + DataMaskingPolicyData data = new DataMaskingPolicyData { DataMaskingState = DataMaskingState.Enabled, + ExemptPrincipals = "testuser;", }; ArmOperation lro = await dataMaskingPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); DataMaskingPolicyResource result = lro.Value; @@ -91,10 +86,10 @@ public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMin() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDataMaskingPolicy() + public async Task CreateOrUpdate_CreateOrUpdateDataMaskingPolicyMin() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingPolicyGet.json - // this example is just showing the usage of "DataMaskingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DataMaskingPolicyCreateOrUpdateMin.json + // this example is just showing the usage of "DataMaskingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,7 +106,12 @@ public async Task Get_GetDataMaskingPolicy() DataMaskingPolicyResource dataMaskingPolicy = client.GetDataMaskingPolicyResource(dataMaskingPolicyResourceId); // invoke the operation - DataMaskingPolicyResource result = await dataMaskingPolicy.GetAsync(); + DataMaskingPolicyData data = new DataMaskingPolicyData + { + DataMaskingState = DataMaskingState.Enabled, + }; + ArmOperation lro = await dataMaskingPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); + DataMaskingPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -143,7 +143,7 @@ public async Task CreateOrUpdateDataMaskingRule_CreateUpdateDataMaskingRuleForDe // invoke the operation string dataMaskingRuleName = "rule1"; - DataMaskingRule dataMaskingRule = new DataMaskingRule() + DataMaskingRule dataMaskingRule = new DataMaskingRule { AliasName = "nickname", RuleState = DataMaskingRuleState.Enabled, @@ -180,7 +180,7 @@ public async Task CreateOrUpdateDataMaskingRule_CreateUpdateDataMaskingRuleForDe // invoke the operation string dataMaskingRuleName = "rule1"; - DataMaskingRule dataMaskingRule = new DataMaskingRule() + DataMaskingRule dataMaskingRule = new DataMaskingRule { SchemaName = "dbo", TableName = "Table_1", @@ -215,7 +215,7 @@ public async Task CreateOrUpdateDataMaskingRule_CreateUpdateDataMaskingRuleForNu // invoke the operation string dataMaskingRuleName = "rule1"; - DataMaskingRule dataMaskingRule = new DataMaskingRule() + DataMaskingRule dataMaskingRule = new DataMaskingRule { SchemaName = "dbo", TableName = "Table_1", @@ -252,7 +252,7 @@ public async Task CreateOrUpdateDataMaskingRule_CreateUpdateDataMaskingRuleForTe // invoke the operation string dataMaskingRuleName = "rule1"; - DataMaskingRule dataMaskingRule = new DataMaskingRule() + DataMaskingRule dataMaskingRule = new DataMaskingRule { SchemaName = "dbo", TableName = "Table_1", diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DataWarehouseUserActivityCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DataWarehouseUserActivityCollection.cs index 9c9d4b5b71388..20ddd9073e6ee 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DataWarehouseUserActivityCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DataWarehouseUserActivityCollection.cs @@ -53,10 +53,10 @@ public async Task Get_GetTheListOfTheUserActivitiesOfADataWarehouse() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheListOfTheUserActivitiesOfADataWarehouse() + public async Task GetAll_ListOfTheUserActivitiesOfADataWarehouse() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetDataWarehouseUserActivities.json - // this example is just showing the usage of "DataWarehouseUserActivities_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListDataWarehouseUserActivities.json + // this example is just showing the usage of "DataWarehouseUserActivities_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,16 +75,22 @@ public async Task Exists_GetTheListOfTheUserActivitiesOfADataWarehouse() // get the collection of this DataWarehouseUserActivityResource DataWarehouseUserActivityCollection collection = sqlDatabase.GetDataWarehouseUserActivities(); - // invoke the operation - DataWarehouseUserActivityName dataWarehouseUserActivityName = DataWarehouseUserActivityName.Current; - bool result = await collection.ExistsAsync(dataWarehouseUserActivityName); + // invoke the operation and iterate over the result + await foreach (DataWarehouseUserActivityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataWarehouseUserActivityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheListOfTheUserActivitiesOfADataWarehouse() + public async Task Exists_GetTheListOfTheUserActivitiesOfADataWarehouse() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetDataWarehouseUserActivities.json // this example is just showing the usage of "DataWarehouseUserActivities_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,29 +114,17 @@ public async Task GetIfExists_GetTheListOfTheUserActivitiesOfADataWarehouse() // invoke the operation DataWarehouseUserActivityName dataWarehouseUserActivityName = DataWarehouseUserActivityName.Current; - NullableResponse response = await collection.GetIfExistsAsync(dataWarehouseUserActivityName); - DataWarehouseUserActivityResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataWarehouseUserActivityName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataWarehouseUserActivityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfTheUserActivitiesOfADataWarehouse() + public async Task GetIfExists_GetTheListOfTheUserActivitiesOfADataWarehouse() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListDataWarehouseUserActivities.json - // this example is just showing the usage of "DataWarehouseUserActivities_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetDataWarehouseUserActivities.json + // this example is just showing the usage of "DataWarehouseUserActivities_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,17 +143,23 @@ public async Task GetAll_ListOfTheUserActivitiesOfADataWarehouse() // get the collection of this DataWarehouseUserActivityResource DataWarehouseUserActivityCollection collection = sqlDatabase.GetDataWarehouseUserActivities(); - // invoke the operation and iterate over the result - await foreach (DataWarehouseUserActivityResource item in collection.GetAllAsync()) + // invoke the operation + DataWarehouseUserActivityName dataWarehouseUserActivityName = DataWarehouseUserActivityName.Current; + NullableResponse response = await collection.GetIfExistsAsync(dataWarehouseUserActivityName); + DataWarehouseUserActivityResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataWarehouseUserActivityData resourceData = item.Data; + DataWarehouseUserActivityData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DatabaseAdvancedThreatProtectionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DatabaseAdvancedThreatProtectionCollection.cs index dc00de4a0b35d..b67cee270425d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DatabaseAdvancedThreatProtectionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DatabaseAdvancedThreatProtectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DatabaseAdvancedThreatProtectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheDatabaseSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_UpdateADatabaseSAdvancedThreatProtectionSettingsWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsListByDatabase.json - // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsCreateMax.json + // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task GetAll_ListsTheDatabaseSAdvancedThreatProtectionSettings() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-6852"; - string serverName = "threatprotection-2080"; + string resourceGroupName = "threatprotection-4799"; + string serverName = "threatprotection-6440"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -40,25 +40,28 @@ public async Task GetAll_ListsTheDatabaseSAdvancedThreatProtectionSettings() // get the collection of this DatabaseAdvancedThreatProtectionResource DatabaseAdvancedThreatProtectionCollection collection = sqlDatabase.GetDatabaseAdvancedThreatProtections(); - // invoke the operation and iterate over the result - await foreach (DatabaseAdvancedThreatProtectionResource item in collection.GetAllAsync()) + // invoke the operation + AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; + DatabaseAdvancedThreatProtectionData data = new DatabaseAdvancedThreatProtectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseAdvancedThreatProtectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + State = AdvancedThreatProtectionState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); + DatabaseAdvancedThreatProtectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabaseSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_UpdateADatabaseSAdvancedThreatProtectionSettingsWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsGet.json - // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsCreateMin.json + // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,8 +71,8 @@ public async Task Get_GetADatabaseSAdvancedThreatProtectionSettings() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-6852"; - string serverName = "threatprotection-2080"; + string resourceGroupName = "threatprotection-4799"; + string serverName = "threatprotection-6440"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -79,7 +82,12 @@ public async Task Get_GetADatabaseSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - DatabaseAdvancedThreatProtectionResource result = await collection.GetAsync(advancedThreatProtectionName); + DatabaseAdvancedThreatProtectionData data = new DatabaseAdvancedThreatProtectionData + { + State = AdvancedThreatProtectionState.Disabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); + DatabaseAdvancedThreatProtectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,7 +98,7 @@ public async Task Get_GetADatabaseSAdvancedThreatProtectionSettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADatabaseSAdvancedThreatProtectionSettings() + public async Task Get_GetADatabaseSAdvancedThreatProtectionSettings() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsGet.json // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -114,17 +122,21 @@ public async Task Exists_GetADatabaseSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - bool result = await collection.ExistsAsync(advancedThreatProtectionName); + DatabaseAdvancedThreatProtectionResource result = await collection.GetAsync(advancedThreatProtectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADatabaseSAdvancedThreatProtectionSettings() + public async Task GetAll_ListsTheDatabaseSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsGet.json - // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsListByDatabase.json + // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +155,25 @@ public async Task GetIfExists_GetADatabaseSAdvancedThreatProtectionSettings() // get the collection of this DatabaseAdvancedThreatProtectionResource DatabaseAdvancedThreatProtectionCollection collection = sqlDatabase.GetDatabaseAdvancedThreatProtections(); - // invoke the operation - AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - NullableResponse response = await collection.GetIfExistsAsync(advancedThreatProtectionName); - DatabaseAdvancedThreatProtectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DatabaseAdvancedThreatProtectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DatabaseAdvancedThreatProtectionData resourceData = result.Data; + DatabaseAdvancedThreatProtectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateADatabaseSAdvancedThreatProtectionSettingsWithAllParameters() + public async Task Exists_GetADatabaseSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsCreateMax.json - // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsGet.json + // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,8 +183,8 @@ public async Task CreateOrUpdate_UpdateADatabaseSAdvancedThreatProtectionSetting // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-4799"; - string serverName = "threatprotection-6440"; + string resourceGroupName = "threatprotection-6852"; + string serverName = "threatprotection-2080"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -188,26 +194,17 @@ public async Task CreateOrUpdate_UpdateADatabaseSAdvancedThreatProtectionSetting // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - DatabaseAdvancedThreatProtectionData data = new DatabaseAdvancedThreatProtectionData() - { - State = AdvancedThreatProtectionState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); - DatabaseAdvancedThreatProtectionResource result = lro.Value; + bool result = await collection.ExistsAsync(advancedThreatProtectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseAdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateADatabaseSAdvancedThreatProtectionSettingsWithMinimalParameters() + public async Task GetIfExists_GetADatabaseSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsCreateMin.json - // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAdvancedThreatProtectionSettingsGet.json + // this example is just showing the usage of "DatabaseAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,8 +214,8 @@ public async Task CreateOrUpdate_UpdateADatabaseSAdvancedThreatProtectionSetting // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-4799"; - string serverName = "threatprotection-6440"; + string resourceGroupName = "threatprotection-6852"; + string serverName = "threatprotection-2080"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -228,18 +225,21 @@ public async Task CreateOrUpdate_UpdateADatabaseSAdvancedThreatProtectionSetting // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - DatabaseAdvancedThreatProtectionData data = new DatabaseAdvancedThreatProtectionData() - { - State = AdvancedThreatProtectionState.Disabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); - DatabaseAdvancedThreatProtectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(advancedThreatProtectionName); + DatabaseAdvancedThreatProtectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseAdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DatabaseAdvancedThreatProtectionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DatabaseAdvancedThreatProtectionResource.cs index 28a2245244056..b7ca742df2252 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DatabaseAdvancedThreatProtectionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DatabaseAdvancedThreatProtectionResource.cs @@ -71,7 +71,7 @@ public async Task Update_UpdateADatabaseSAdvancedThreatProtectionSettingsWithAll DatabaseAdvancedThreatProtectionResource databaseAdvancedThreatProtection = client.GetDatabaseAdvancedThreatProtectionResource(databaseAdvancedThreatProtectionResourceId); // invoke the operation - DatabaseAdvancedThreatProtectionData data = new DatabaseAdvancedThreatProtectionData() + DatabaseAdvancedThreatProtectionData data = new DatabaseAdvancedThreatProtectionData { State = AdvancedThreatProtectionState.Enabled, }; @@ -108,7 +108,7 @@ public async Task Update_UpdateADatabaseSAdvancedThreatProtectionSettingsWithMin DatabaseAdvancedThreatProtectionResource databaseAdvancedThreatProtection = client.GetDatabaseAdvancedThreatProtectionResource(databaseAdvancedThreatProtectionResourceId); // invoke the operation - DatabaseAdvancedThreatProtectionData data = new DatabaseAdvancedThreatProtectionData() + DatabaseAdvancedThreatProtectionData data = new DatabaseAdvancedThreatProtectionData { State = AdvancedThreatProtectionState.Disabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DeletedServerCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DeletedServerCollection.cs index 32dde4fee851e..4ceef0be2673a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DeletedServerCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DeletedServerCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetDeletedServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDeletedServer() + public async Task GetAll_ListDeletedServers() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerGet.json - // this example is just showing the usage of "DeletedServers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerList.json + // this example is just showing the usage of "DeletedServers_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,16 +71,22 @@ public async Task Exists_GetDeletedServer() AzureLocation locationName = new AzureLocation("japaneast"); DeletedServerCollection collection = subscriptionResource.GetDeletedServers(locationName); - // invoke the operation - string deletedServerName = "sqlcrudtest-d-1414"; - bool result = await collection.ExistsAsync(deletedServerName); + // invoke the operation and iterate over the result + await foreach (DeletedServerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeletedServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDeletedServer() + public async Task Exists_GetDeletedServer() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerGet.json // this example is just showing the usage of "DeletedServers_Get" operation, for the dependent resources, they will have to be created separately. @@ -102,29 +108,17 @@ public async Task GetIfExists_GetDeletedServer() // invoke the operation string deletedServerName = "sqlcrudtest-d-1414"; - NullableResponse response = await collection.GetIfExistsAsync(deletedServerName); - DeletedServerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(deletedServerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeletedServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDeletedServers() + public async Task GetIfExists_GetDeletedServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerList.json - // this example is just showing the usage of "DeletedServers_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerGet.json + // this example is just showing the usage of "DeletedServers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,17 +135,23 @@ public async Task GetAll_ListDeletedServers() AzureLocation locationName = new AzureLocation("japaneast"); DeletedServerCollection collection = subscriptionResource.GetDeletedServers(locationName); - // invoke the operation and iterate over the result - await foreach (DeletedServerResource item in collection.GetAllAsync()) + // invoke the operation + string deletedServerName = "sqlcrudtest-d-1414"; + NullableResponse response = await collection.GetIfExistsAsync(deletedServerName); + DeletedServerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DeletedServerData resourceData = item.Data; + DeletedServerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DeletedServerResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DeletedServerResource.cs index 5b90089170db1..6223039be22ff 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DeletedServerResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DeletedServerResource.cs @@ -9,44 +9,12 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Sql.Samples { public partial class Sample_DeletedServerResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeletedServers_ListDeletedServersInASubscription() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerListBySubscription.json - // this example is just showing the usage of "DeletedServers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeletedServerResource item in subscriptionResource.GetDeletedServersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeletedServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetDeletedServer() diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DistributedAvailabilityGroupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DistributedAvailabilityGroupCollection.cs index ed94ee63579a3..842624c0ddec6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DistributedAvailabilityGroupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DistributedAvailabilityGroupCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DistributedAvailabilityGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsAllDistributedAvailabilityGroupsInInstance() + public async Task CreateOrUpdate_CreateADistributedAvailabilityGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsListByInstance.json - // this example is just showing the usage of "DistributedAvailabilityGroups_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsCreate.json + // this example is just showing the usage of "DistributedAvailabilityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,23 @@ public async Task GetAll_ListsAllDistributedAvailabilityGroupsInInstance() // get the collection of this DistributedAvailabilityGroupResource DistributedAvailabilityGroupCollection collection = managedInstance.GetDistributedAvailabilityGroups(); - // invoke the operation and iterate over the result - await foreach (DistributedAvailabilityGroupResource item in collection.GetAllAsync()) + // invoke the operation + string distributedAvailabilityGroupName = "dag"; + DistributedAvailabilityGroupData data = new DistributedAvailabilityGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DistributedAvailabilityGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TargetDatabase = "testdb", + SourceEndpoint = "TCP://SERVER:7022", + PrimaryAvailabilityGroupName = "BoxLocalAg1", + SecondaryAvailabilityGroupName = "testcl", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, distributedAvailabilityGroupName, data); + DistributedAvailabilityGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DistributedAvailabilityGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +93,10 @@ public async Task Get_GetsTheDistributedAvailabilityGroupInfo() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheDistributedAvailabilityGroupInfo() + public async Task GetAll_ListsAllDistributedAvailabilityGroupsInInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsGet.json - // this example is just showing the usage of "DistributedAvailabilityGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsListByInstance.json + // this example is just showing the usage of "DistributedAvailabilityGroups_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,7 +105,7 @@ public async Task Exists_GetsTheDistributedAvailabilityGroupInfo() // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource - string subscriptionId = "f2669dff-5f08-45dd-b857-b2a60b72cdc9"; + string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "testrg"; string managedInstanceName = "testcl"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); @@ -108,16 +114,22 @@ public async Task Exists_GetsTheDistributedAvailabilityGroupInfo() // get the collection of this DistributedAvailabilityGroupResource DistributedAvailabilityGroupCollection collection = managedInstance.GetDistributedAvailabilityGroups(); - // invoke the operation - string distributedAvailabilityGroupName = "dag"; - bool result = await collection.ExistsAsync(distributedAvailabilityGroupName); + // invoke the operation and iterate over the result + await foreach (DistributedAvailabilityGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DistributedAvailabilityGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheDistributedAvailabilityGroupInfo() + public async Task Exists_GetsTheDistributedAvailabilityGroupInfo() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsGet.json // this example is just showing the usage of "DistributedAvailabilityGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +152,17 @@ public async Task GetIfExists_GetsTheDistributedAvailabilityGroupInfo() // invoke the operation string distributedAvailabilityGroupName = "dag"; - NullableResponse response = await collection.GetIfExistsAsync(distributedAvailabilityGroupName); - DistributedAvailabilityGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(distributedAvailabilityGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DistributedAvailabilityGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADistributedAvailabilityGroup() + public async Task GetIfExists_GetsTheDistributedAvailabilityGroupInfo() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsCreate.json - // this example is just showing the usage of "DistributedAvailabilityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DistributedAvailabilityGroupsGet.json + // this example is just showing the usage of "DistributedAvailabilityGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -171,7 +171,7 @@ public async Task CreateOrUpdate_CreateADistributedAvailabilityGroup() // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string subscriptionId = "f2669dff-5f08-45dd-b857-b2a60b72cdc9"; string resourceGroupName = "testrg"; string managedInstanceName = "testcl"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); @@ -182,21 +182,21 @@ public async Task CreateOrUpdate_CreateADistributedAvailabilityGroup() // invoke the operation string distributedAvailabilityGroupName = "dag"; - DistributedAvailabilityGroupData data = new DistributedAvailabilityGroupData() - { - TargetDatabase = "testdb", - SourceEndpoint = "TCP://SERVER:7022", - PrimaryAvailabilityGroupName = "BoxLocalAg1", - SecondaryAvailabilityGroupName = "testcl", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, distributedAvailabilityGroupName, data); - DistributedAvailabilityGroupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(distributedAvailabilityGroupName); + DistributedAvailabilityGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DistributedAvailabilityGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DistributedAvailabilityGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DistributedAvailabilityGroupResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DistributedAvailabilityGroupResource.cs index 383951cffdbbd..6453f724d4336 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DistributedAvailabilityGroupResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_DistributedAvailabilityGroupResource.cs @@ -96,7 +96,7 @@ public async Task Update_UpdateTheDistributedAvailabilityGroupReplicationModeBef DistributedAvailabilityGroupResource distributedAvailabilityGroup = client.GetDistributedAvailabilityGroupResource(distributedAvailabilityGroupResourceId); // invoke the operation - DistributedAvailabilityGroupData data = new DistributedAvailabilityGroupData() + DistributedAvailabilityGroupData data = new DistributedAvailabilityGroupData { ReplicationMode = DistributedAvailabilityGroupReplicationMode.Sync, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ElasticPoolCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ElasticPoolCollection.cs index 7d8a7c7db5786..1678982aaf9cc 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ElasticPoolCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ElasticPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ElasticPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllElasticPoolsInAServer() + public async Task CreateOrUpdate_CreateOrUpdateAnElasticPoolWithAvailabilityZone() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolListByServer.json - // this example is just showing the usage of "ElasticPools_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateElasticPoolWithAvailabilityZone.json + // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,35 @@ public async Task GetAll_GetAllElasticPoolsInAServer() // get the collection of this ElasticPoolResource ElasticPoolCollection collection = sqlServer.GetElasticPools(); - // invoke the operation and iterate over the result - await foreach (ElasticPoolResource item in collection.GetAllAsync()) + // invoke the operation + string elasticPoolName = "sqlcrudtest-8102"; + ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new SqlSku("HS_Gen5_4"), + PerDatabaseSettings = new ElasticPoolPerDatabaseSettings + { + MinCapacity = 0.25, + MaxCapacity = 2, + }, + IsZoneRedundant = true, + AvailabilityZone = SqlAvailabilityZoneType.One, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); + ElasticPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAHyperscaleElasticPool() + public async Task CreateOrUpdate_CreateOrUpdateHyperscaleElasticPoolWithHighAvailabilityReplicaCountParameter() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolGet.json - // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolCreateOrUpdateSetHighAvailabilityReplicaCount.json + // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +87,13 @@ public async Task Get_GetAHyperscaleElasticPool() // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - ElasticPoolResource result = await collection.GetAsync(elasticPoolName); + ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) + { + Sku = new SqlSku("HS_Gen5_4"), + HighAvailabilityReplicaCount = 2, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); + ElasticPoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +104,10 @@ public async Task Get_GetAHyperscaleElasticPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAHyperscaleElasticPool() + public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithAllParameter() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolGet.json - // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateOrUpdateMax.json + // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,17 +127,35 @@ public async Task Exists_GetAHyperscaleElasticPool() // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - bool result = await collection.ExistsAsync(elasticPoolName); + ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) + { + Sku = new SqlSku("GP_Gen4_2") + { + Tier = "GeneralPurpose", + Capacity = 2, + }, + PerDatabaseSettings = new ElasticPoolPerDatabaseSettings + { + MinCapacity = 0.25, + MaxCapacity = 2, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); + ElasticPoolResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAHyperscaleElasticPool() + public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithMaintenanceConfigurationParameter() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolGet.json - // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateOrUpdateSetMaintenanceConfiguration.json + // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,29 +175,26 @@ public async Task GetIfExists_GetAHyperscaleElasticPool() // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - NullableResponse response = await collection.GetIfExistsAsync(elasticPoolName); - ElasticPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); + ElasticPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnElasticPool() + public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithMinimumParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGet.json - // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateOrUpdateMin.json + // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,7 +214,9 @@ public async Task Get_GetAnElasticPool() // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - ElasticPoolResource result = await collection.GetAsync(elasticPoolName); + ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); + ElasticPoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -194,10 +227,10 @@ public async Task Get_GetAnElasticPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnElasticPool() + public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithPreferredEnclaveTypeParameterAsDefault() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGet.json - // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateWithDefaultPreferredEnclaveType.json + // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,17 +250,27 @@ public async Task Exists_GetAnElasticPool() // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - bool result = await collection.ExistsAsync(elasticPoolName); + ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) + { + Sku = new SqlSku("GP_Gen5_4"), + PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Default, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); + ElasticPoolResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnElasticPool() + public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithPreferredEnclaveTypeParameterAsVBS() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGet.json - // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateWithVBSPreferredEnclaveType.json + // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -247,28 +290,26 @@ public async Task GetIfExists_GetAnElasticPool() // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - NullableResponse response = await collection.GetIfExistsAsync(elasticPoolName); - ElasticPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new SqlSku("GP_Gen5_4"), + PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Vbs, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); + ElasticPoolResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnElasticPoolWithAvailabilityZone() + public async Task Get_GetAHyperscaleElasticPool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetElasticPoolWithAvailabilityZone.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolGet.json // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -300,9 +341,9 @@ public async Task Get_GetAnElasticPoolWithAvailabilityZone() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnElasticPoolWithAvailabilityZone() + public async Task Get_GetAnElasticPool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetElasticPoolWithAvailabilityZone.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGet.json // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -323,14 +364,18 @@ public async Task Exists_GetAnElasticPoolWithAvailabilityZone() // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - bool result = await collection.ExistsAsync(elasticPoolName); + ElasticPoolResource result = await collection.GetAsync(elasticPoolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnElasticPoolWithAvailabilityZone() + public async Task Get_GetAnElasticPoolWithAvailabilityZone() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetElasticPoolWithAvailabilityZone.json // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. @@ -353,21 +398,13 @@ public async Task GetIfExists_GetAnElasticPoolWithAvailabilityZone() // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - NullableResponse response = await collection.GetIfExistsAsync(elasticPoolName); - ElasticPoolResource result = response.HasValue ? response.Value : null; + ElasticPoolResource result = await collection.GetAsync(elasticPoolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -406,10 +443,10 @@ public async Task Get_GetAnElasticPoolWithPreferredEnclaveTypeParameter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnElasticPoolWithPreferredEnclaveTypeParameter() + public async Task GetAll_GetAllElasticPoolsInAServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGetWithPreferredEnclaveType.json - // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolListByServer.json + // this example is just showing the usage of "ElasticPools_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -427,18 +464,24 @@ public async Task Exists_GetAnElasticPoolWithPreferredEnclaveTypeParameter() // get the collection of this ElasticPoolResource ElasticPoolCollection collection = sqlServer.GetElasticPools(); - // invoke the operation - string elasticPoolName = "sqlcrudtest-8102"; - bool result = await collection.ExistsAsync(elasticPoolName); + // invoke the operation and iterate over the result + await foreach (ElasticPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnElasticPoolWithPreferredEnclaveTypeParameter() + public async Task Exists_GetAHyperscaleElasticPool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGetWithPreferredEnclaveType.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolGet.json // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -459,29 +502,17 @@ public async Task GetIfExists_GetAnElasticPoolWithPreferredEnclaveTypeParameter( // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - NullableResponse response = await collection.GetIfExistsAsync(elasticPoolName); - ElasticPoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(elasticPoolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnElasticPoolWithAvailabilityZone() + public async Task Exists_GetAnElasticPool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateElasticPoolWithAvailabilityZone.json - // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGet.json + // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -501,33 +532,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAnElasticPoolWithAvailabilityZone // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) - { - Sku = new SqlSku("HS_Gen5_4"), - PerDatabaseSettings = new ElasticPoolPerDatabaseSettings() - { - MinCapacity = 0.25, - MaxCapacity = 2, - }, - IsZoneRedundant = true, - AvailabilityZone = SqlAvailabilityZoneType.One, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); - ElasticPoolResource result = lro.Value; + bool result = await collection.ExistsAsync(elasticPoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateHyperscaleElasticPoolWithHighAvailabilityReplicaCountParameter() + public async Task Exists_GetAnElasticPoolWithAvailabilityZone() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolCreateOrUpdateSetHighAvailabilityReplicaCount.json - // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetElasticPoolWithAvailabilityZone.json + // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -547,27 +562,17 @@ public async Task CreateOrUpdate_CreateOrUpdateHyperscaleElasticPoolWithHighAvai // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) - { - Sku = new SqlSku("HS_Gen5_4"), - HighAvailabilityReplicaCount = 2, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); - ElasticPoolResource result = lro.Value; + bool result = await collection.ExistsAsync(elasticPoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithAllParameter() + public async Task Exists_GetAnElasticPoolWithPreferredEnclaveTypeParameter() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateOrUpdateMax.json - // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGetWithPreferredEnclaveType.json + // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -587,35 +592,17 @@ public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithAllParameter() // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) - { - Sku = new SqlSku("GP_Gen4_2") - { - Tier = "GeneralPurpose", - Capacity = 2, - }, - PerDatabaseSettings = new ElasticPoolPerDatabaseSettings() - { - MinCapacity = 0.25, - MaxCapacity = 2, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); - ElasticPoolResource result = lro.Value; + bool result = await collection.ExistsAsync(elasticPoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithMaintenanceConfigurationParameter() + public async Task GetIfExists_GetAHyperscaleElasticPool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateOrUpdateSetMaintenanceConfiguration.json - // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/HyperscaleElasticPoolGet.json + // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -635,26 +622,29 @@ public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithMaintenanceConfigu // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) - { - MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); - ElasticPoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(elasticPoolName); + ElasticPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithMinimumParameters() + public async Task GetIfExists_GetAnElasticPool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateOrUpdateMin.json - // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGet.json + // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -674,23 +664,29 @@ public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithMinimumParameters( // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); - ElasticPoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(elasticPoolName); + ElasticPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithPreferredEnclaveTypeParameterAsDefault() + public async Task GetIfExists_GetAnElasticPoolWithAvailabilityZone() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateWithDefaultPreferredEnclaveType.json - // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetElasticPoolWithAvailabilityZone.json + // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -710,27 +706,29 @@ public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithPreferredEnclaveTy // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) - { - Sku = new SqlSku("GP_Gen5_4"), - PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Default, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); - ElasticPoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(elasticPoolName); + ElasticPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithPreferredEnclaveTypeParameterAsVBS() + public async Task GetIfExists_GetAnElasticPoolWithPreferredEnclaveTypeParameter() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolCreateWithVBSPreferredEnclaveType.json - // this example is just showing the usage of "ElasticPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ElasticPoolGetWithPreferredEnclaveType.json + // this example is just showing the usage of "ElasticPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -750,19 +748,21 @@ public async Task CreateOrUpdate_CreateOrUpdateElasticPoolWithPreferredEnclaveTy // invoke the operation string elasticPoolName = "sqlcrudtest-8102"; - ElasticPoolData data = new ElasticPoolData(new AzureLocation("Japan East")) - { - Sku = new SqlSku("GP_Gen5_4"), - PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Vbs, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, elasticPoolName, data); - ElasticPoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(elasticPoolName); + ElasticPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ElasticPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ElasticPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ElasticPoolResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ElasticPoolResource.cs index 75ba9765d165d..b31b337376ec6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ElasticPoolResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ElasticPoolResource.cs @@ -16,219 +16,6 @@ namespace Azure.ResourceManager.Sql.Samples { public partial class Sample_ElasticPoolResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMetrics_ListDatabaseUsageMetrics() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ElasticPoolMetricsListWithFilter.json - // this example is just showing the usage of "Metrics_ListElasticPool" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ElasticPoolResource created on azure - // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-6730"; - string serverName = "sqlcrudtest-9007"; - string elasticPoolName = "3481"; - ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); - ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); - - // invoke the operation and iterate over the result - string filter = "name/value eq 'cpu_percent' and timeGrain eq '00:10:00' and startTime eq '2017-06-02T18:35:00Z' and endTime eq '2017-06-02T18:55:00Z'"; - await foreach (SqlMetric item in elasticPool.GetMetricsAsync(filter)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMetricDefinitions_ListDatabaseUsageMetrics() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ElasticPoolMetricsDefinitionsList.json - // this example is just showing the usage of "MetricDefinitions_ListElasticPool" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ElasticPoolResource created on azure - // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-6730"; - string serverName = "sqlcrudtest-9007"; - string elasticPoolName = "3481"; - ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); - ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); - - // invoke the operation and iterate over the result - await foreach (SqlMetricDefinition item in elasticPool.GetMetricDefinitionsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetElasticPoolActivities_ListElasticPoolActivity() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ElasticPoolActivityList.json - // this example is just showing the usage of "ElasticPoolActivities_ListByElasticPool" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ElasticPoolResource created on azure - // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-4291"; - string serverName = "sqlcrudtest-6574"; - string elasticPoolName = "8749"; - ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); - ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); - - // invoke the operation and iterate over the result - await foreach (ElasticPoolActivity item in elasticPool.GetElasticPoolActivitiesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetElasticPoolDatabaseActivities_ListElasticPoolDatabaseActivity() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ElasticPoolDatabaseActivityList.json - // this example is just showing the usage of "ElasticPoolDatabaseActivities_ListByElasticPool" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ElasticPoolResource created on azure - // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource - string subscriptionId = "9d4e2ad0-e20b-4464-9219-353bded52513"; - string resourceGroupName = "sqlcrudtest-4673"; - string serverName = "sqlcrudtest-603"; - string elasticPoolName = "7537"; - ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); - ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); - - // invoke the operation and iterate over the result - await foreach (ElasticPoolDatabaseActivity item in elasticPool.GetElasticPoolDatabaseActivitiesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CancelElasticPoolOperation_CancelTheElasticPoolManagementOperation() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CancelElasticPoolOperation.json - // this example is just showing the usage of "ElasticPoolOperations_Cancel" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ElasticPoolResource created on azure - // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-7398"; - string serverName = "sqlcrudtest-6661"; - string elasticPoolName = "testpool"; - ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); - ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); - - // invoke the operation - Guid operationId = Guid.Parse("f779414b-e748-4925-8cfe-c8598f7660ae"); - await elasticPool.CancelElasticPoolOperationAsync(operationId); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetElasticPoolOperations_ListTheElasticPoolManagementOperations() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListElasticPoolOperations.json - // this example is just showing the usage of "ElasticPoolOperations_ListByElasticPool" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ElasticPoolResource created on azure - // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtestgroup"; - string serverName = "sqlcrudtestserver"; - string elasticPoolName = "testpool"; - ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); - ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); - - // invoke the operation and iterate over the result - await foreach (ElasticPoolOperationData item in elasticPool.GetElasticPoolOperationsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDatabases_GetsAListOfDatabasesInAnElasticPool() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListDatabasesByElasticPool.json - // this example is just showing the usage of "Databases_ListByElasticPool" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ElasticPoolResource created on azure - // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string elasticPoolName = "pool1"; - ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); - ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); - - // invoke the operation and iterate over the result - await foreach (SqlDatabaseResource item in elasticPool.GetDatabasesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAHyperscaleElasticPool() @@ -402,7 +189,7 @@ public async Task Update_AssignsMaintenanceConfigurationToAnElasticPool() ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); // invoke the operation - ElasticPoolPatch patch = new ElasticPoolPatch() + ElasticPoolPatch patch = new ElasticPoolPatch { MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_1"), }; @@ -438,7 +225,7 @@ public async Task Update_CreateOrUpdateElasticPoolWithPreferredEnclaveTypeParame ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); // invoke the operation - ElasticPoolPatch patch = new ElasticPoolPatch() + ElasticPoolPatch patch = new ElasticPoolPatch { Sku = new SqlSku("GP_Gen5_4"), PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Default, @@ -475,7 +262,7 @@ public async Task Update_CreateOrUpdateElasticPoolWithPreferredEnclaveTypeParame ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); // invoke the operation - ElasticPoolPatch patch = new ElasticPoolPatch() + ElasticPoolPatch patch = new ElasticPoolPatch { Sku = new SqlSku("GP_Gen5_4"), PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Vbs, @@ -512,7 +299,7 @@ public async Task Update_ResetsMaintenanceConfigurationOfAnElasticPoolToDefault( ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); // invoke the operation - ElasticPoolPatch patch = new ElasticPoolPatch() + ElasticPoolPatch patch = new ElasticPoolPatch { MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default"), }; @@ -548,14 +335,14 @@ public async Task Update_UpdateAnElasticPoolWithAllParameter() ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); // invoke the operation - ElasticPoolPatch patch = new ElasticPoolPatch() + ElasticPoolPatch patch = new ElasticPoolPatch { Sku = new SqlSku("BC_Gen4") { Tier = "BusinessCritical", Capacity = 2, }, - PerDatabaseSettings = new ElasticPoolPerDatabaseSettings() + PerDatabaseSettings = new ElasticPoolPerDatabaseSettings { MinCapacity = 0.25, MaxCapacity = 1, @@ -628,7 +415,7 @@ public async Task Update_UpdateHighAvailabilityReplicaCountOfAHyperscaleElasticP ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); // invoke the operation - ElasticPoolPatch patch = new ElasticPoolPatch() + ElasticPoolPatch patch = new ElasticPoolPatch { HighAvailabilityReplicaCount = 2, }; @@ -642,6 +429,219 @@ public async Task Update_UpdateHighAvailabilityReplicaCountOfAHyperscaleElasticP Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMetrics_ListDatabaseUsageMetrics() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ElasticPoolMetricsListWithFilter.json + // this example is just showing the usage of "Metrics_ListElasticPool" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ElasticPoolResource created on azure + // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "sqlcrudtest-6730"; + string serverName = "sqlcrudtest-9007"; + string elasticPoolName = "3481"; + ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); + ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); + + // invoke the operation and iterate over the result + string filter = "name/value eq 'cpu_percent' and timeGrain eq '00:10:00' and startTime eq '2017-06-02T18:35:00Z' and endTime eq '2017-06-02T18:55:00Z'"; + await foreach (SqlMetric item in elasticPool.GetMetricsAsync(filter)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMetricDefinitions_ListDatabaseUsageMetrics() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ElasticPoolMetricsDefinitionsList.json + // this example is just showing the usage of "MetricDefinitions_ListElasticPool" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ElasticPoolResource created on azure + // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "sqlcrudtest-6730"; + string serverName = "sqlcrudtest-9007"; + string elasticPoolName = "3481"; + ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); + ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); + + // invoke the operation and iterate over the result + await foreach (SqlMetricDefinition item in elasticPool.GetMetricDefinitionsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetElasticPoolActivities_ListElasticPoolActivity() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ElasticPoolActivityList.json + // this example is just showing the usage of "ElasticPoolActivities_ListByElasticPool" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ElasticPoolResource created on azure + // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "sqlcrudtest-4291"; + string serverName = "sqlcrudtest-6574"; + string elasticPoolName = "8749"; + ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); + ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); + + // invoke the operation and iterate over the result + await foreach (ElasticPoolActivity item in elasticPool.GetElasticPoolActivitiesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetElasticPoolDatabaseActivities_ListElasticPoolDatabaseActivity() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ElasticPoolDatabaseActivityList.json + // this example is just showing the usage of "ElasticPoolDatabaseActivities_ListByElasticPool" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ElasticPoolResource created on azure + // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource + string subscriptionId = "9d4e2ad0-e20b-4464-9219-353bded52513"; + string resourceGroupName = "sqlcrudtest-4673"; + string serverName = "sqlcrudtest-603"; + string elasticPoolName = "7537"; + ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); + ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); + + // invoke the operation and iterate over the result + await foreach (ElasticPoolDatabaseActivity item in elasticPool.GetElasticPoolDatabaseActivitiesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CancelElasticPoolOperation_CancelTheElasticPoolManagementOperation() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CancelElasticPoolOperation.json + // this example is just showing the usage of "ElasticPoolOperations_Cancel" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ElasticPoolResource created on azure + // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "sqlcrudtest-7398"; + string serverName = "sqlcrudtest-6661"; + string elasticPoolName = "testpool"; + ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); + ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); + + // invoke the operation + Guid operationId = Guid.Parse("f779414b-e748-4925-8cfe-c8598f7660ae"); + await elasticPool.CancelElasticPoolOperationAsync(operationId); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetElasticPoolOperations_ListTheElasticPoolManagementOperations() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListElasticPoolOperations.json + // this example is just showing the usage of "ElasticPoolOperations_ListByElasticPool" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ElasticPoolResource created on azure + // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "sqlcrudtestgroup"; + string serverName = "sqlcrudtestserver"; + string elasticPoolName = "testpool"; + ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); + ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); + + // invoke the operation and iterate over the result + await foreach (ElasticPoolOperationData item in elasticPool.GetElasticPoolOperationsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDatabases_GetsAListOfDatabasesInAnElasticPool() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListDatabasesByElasticPool.json + // this example is just showing the usage of "Databases_ListByElasticPool" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ElasticPoolResource created on azure + // for more information of creating ElasticPoolResource, please refer to the document of ElasticPoolResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; + string elasticPoolName = "pool1"; + ResourceIdentifier elasticPoolResourceId = ElasticPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, elasticPoolName); + ElasticPoolResource elasticPool = client.GetElasticPoolResource(elasticPoolResourceId); + + // invoke the operation and iterate over the result + await foreach (SqlDatabaseResource item in elasticPool.GetDatabasesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Failover_FailoverAnElasticPool() diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EncryptionProtectorCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EncryptionProtectorCollection.cs index 82550992ba625..910b206c40da8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EncryptionProtectorCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EncryptionProtectorCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EncryptionProtectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEncryptionProtectorsByServer() + public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToKeyVault() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorList.json - // this example is just showing the usage of "EncryptionProtectors_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorCreateOrUpdateKeyVault.json + // this example is just showing the usage of "EncryptionProtectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,30 @@ public async Task GetAll_ListEncryptionProtectorsByServer() // get the collection of this EncryptionProtectorResource EncryptionProtectorCollection collection = sqlServer.GetEncryptionProtectors(); - // invoke the operation and iterate over the result - await foreach (EncryptionProtectorResource item in collection.GetAllAsync()) + // invoke the operation + EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; + EncryptionProtectorData data = new EncryptionProtectorData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EncryptionProtectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServerKeyName = "someVault_someKey_01234567890123456789012345678901", + ServerKeyType = SqlServerKeyType.AzureKeyVault, + IsAutoRotationEnabled = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); + EncryptionProtectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EncryptionProtectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheEncryptionProtector() + public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToServiceManaged() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorGet.json - // this example is just showing the usage of "EncryptionProtectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorCreateOrUpdateServiceManaged.json + // this example is just showing the usage of "EncryptionProtectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +82,13 @@ public async Task Get_GetTheEncryptionProtector() // invoke the operation EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - EncryptionProtectorResource result = await collection.GetAsync(encryptionProtectorName); + EncryptionProtectorData data = new EncryptionProtectorData + { + ServerKeyName = "ServiceManaged", + ServerKeyType = SqlServerKeyType.ServiceManaged, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); + EncryptionProtectorResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +99,7 @@ public async Task Get_GetTheEncryptionProtector() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheEncryptionProtector() + public async Task Get_GetTheEncryptionProtector() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorGet.json // this example is just showing the usage of "EncryptionProtectors_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +122,21 @@ public async Task Exists_GetTheEncryptionProtector() // invoke the operation EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - bool result = await collection.ExistsAsync(encryptionProtectorName); + EncryptionProtectorResource result = await collection.GetAsync(encryptionProtectorName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EncryptionProtectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheEncryptionProtector() + public async Task GetAll_ListEncryptionProtectorsByServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorGet.json - // this example is just showing the usage of "EncryptionProtectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorList.json + // this example is just showing the usage of "EncryptionProtectors_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +154,25 @@ public async Task GetIfExists_GetTheEncryptionProtector() // get the collection of this EncryptionProtectorResource EncryptionProtectorCollection collection = sqlServer.GetEncryptionProtectors(); - // invoke the operation - EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - NullableResponse response = await collection.GetIfExistsAsync(encryptionProtectorName); - EncryptionProtectorResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (EncryptionProtectorResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EncryptionProtectorData resourceData = result.Data; + EncryptionProtectorData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToKeyVault() + public async Task Exists_GetTheEncryptionProtector() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorCreateOrUpdateKeyVault.json - // this example is just showing the usage of "EncryptionProtectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorGet.json + // this example is just showing the usage of "EncryptionProtectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,28 +192,17 @@ public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToKeyVault() // invoke the operation EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - EncryptionProtectorData data = new EncryptionProtectorData() - { - ServerKeyName = "someVault_someKey_01234567890123456789012345678901", - ServerKeyType = SqlServerKeyType.AzureKeyVault, - IsAutoRotationEnabled = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); - EncryptionProtectorResource result = lro.Value; + bool result = await collection.ExistsAsync(encryptionProtectorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EncryptionProtectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToServiceManaged() + public async Task GetIfExists_GetTheEncryptionProtector() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorCreateOrUpdateServiceManaged.json - // this example is just showing the usage of "EncryptionProtectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/EncryptionProtectorGet.json + // this example is just showing the usage of "EncryptionProtectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -224,19 +222,21 @@ public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToServiceManaged() // invoke the operation EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - EncryptionProtectorData data = new EncryptionProtectorData() - { - ServerKeyName = "ServiceManaged", - ServerKeyType = SqlServerKeyType.ServiceManaged, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); - EncryptionProtectorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(encryptionProtectorName); + EncryptionProtectorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EncryptionProtectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EncryptionProtectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EncryptionProtectorResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EncryptionProtectorResource.cs index bec68157f5080..17db4b99a9234 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EncryptionProtectorResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EncryptionProtectorResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdateTheEncryptionProtectorToKeyVault() EncryptionProtectorResource encryptionProtector = client.GetEncryptionProtectorResource(encryptionProtectorResourceId); // invoke the operation - EncryptionProtectorData data = new EncryptionProtectorData() + EncryptionProtectorData data = new EncryptionProtectorData { ServerKeyName = "someVault_someKey_01234567890123456789012345678901", ServerKeyType = SqlServerKeyType.AzureKeyVault, @@ -107,7 +107,7 @@ public async Task Update_UpdateTheEncryptionProtectorToServiceManaged() EncryptionProtectorResource encryptionProtector = client.GetEncryptionProtectorResource(encryptionProtectorResourceId); // invoke the operation - EncryptionProtectorData data = new EncryptionProtectorData() + EncryptionProtectorData data = new EncryptionProtectorData { ServerKeyName = "ServiceManaged", ServerKeyType = SqlServerKeyType.ServiceManaged, diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EndpointCertificateCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EndpointCertificateCollection.cs index f77ce7995bb7f..eb310cd153c63 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EndpointCertificateCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_EndpointCertificateCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_EndpointCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfEndpointCertificates() + public async Task Get_GetsAnEndpointCertificate() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/EndpointCertificatesListByInstance.json - // this example is just showing the usage of "EndpointCertificates_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/EndpointCertificatesGet.json + // this example is just showing the usage of "EndpointCertificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetAListOfEndpointCertificates() // get the collection of this EndpointCertificateResource EndpointCertificateCollection collection = managedInstance.GetEndpointCertificates(); - // invoke the operation and iterate over the result - await foreach (EndpointCertificateResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EndpointCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string endpointType = "DATABASE_MIRRORING"; + EndpointCertificateResource result = await collection.GetAsync(endpointType); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EndpointCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAnEndpointCertificate() + public async Task GetAll_GetAListOfEndpointCertificates() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/EndpointCertificatesGet.json - // this example is just showing the usage of "EndpointCertificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/EndpointCertificatesListByInstance.json + // this example is just showing the usage of "EndpointCertificates_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsAnEndpointCertificate() // get the collection of this EndpointCertificateResource EndpointCertificateCollection collection = managedInstance.GetEndpointCertificates(); - // invoke the operation - string endpointType = "DATABASE_MIRRORING"; - EndpointCertificateResource result = await collection.GetAsync(endpointType); + // invoke the operation and iterate over the result + await foreach (EndpointCertificateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EndpointCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EndpointCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedDatabaseBlobAuditingPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedDatabaseBlobAuditingPolicyCollection.cs index 5cc267538d405..e64bc52658078 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedDatabaseBlobAuditingPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedDatabaseBlobAuditingPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ExtendedDatabaseBlobAuditingPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExtendedAuditingSettingsOfADatabase() + public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSAzureMonitorAuditingPolicyWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseExtendedAuditingSettingsList.json - // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseAzureMonitorAuditingCreateMin.json + // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task GetAll_ListExtendedAuditingSettingsOfADatabase() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-6852"; - string serverName = "blobauditingtest-2080"; + string resourceGroupName = "blobauditingtest-4799"; + string serverName = "blobauditingtest-6440"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -40,25 +40,29 @@ public async Task GetAll_ListExtendedAuditingSettingsOfADatabase() // get the collection of this ExtendedDatabaseBlobAuditingPolicyResource ExtendedDatabaseBlobAuditingPolicyCollection collection = sqlDatabase.GetExtendedDatabaseBlobAuditingPolicies(); - // invoke the operation and iterate over the result - await foreach (ExtendedDatabaseBlobAuditingPolicyResource item in collection.GetAllAsync()) + // invoke the operation + BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; + ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedDatabaseBlobAuditingPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsAzureMonitorTargetEnabled = true, + State = BlobAuditingPolicyState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + ExtendedDatabaseBlobAuditingPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedDatabaseBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnExtendedDatabaseSBlobAuditingPolicy() + public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSBlobAuditingPolicyWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingGet.json - // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingCreateMax.json + // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,8 +72,8 @@ public async Task Get_GetAnExtendedDatabaseSBlobAuditingPolicy() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-6852"; - string serverName = "blobauditingtest-2080"; + string resourceGroupName = "blobauditingtest-4799"; + string serverName = "blobauditingtest-6440"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -79,7 +83,21 @@ public async Task Get_GetAnExtendedDatabaseSBlobAuditingPolicy() // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - ExtendedDatabaseBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); + ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData + { + PredicateExpression = "statement = 'select 1'", + RetentionDays = 6, + AuditActionsAndGroups = { "DATABASE_LOGOUT_GROUP", "DATABASE_ROLE_MEMBER_CHANGE_GROUP", "UPDATE on database::TestDatabaseName by public" }, + IsStorageSecondaryKeyInUse = false, + IsAzureMonitorTargetEnabled = true, + QueueDelayMs = 4000, + State = BlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + ExtendedDatabaseBlobAuditingPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,10 +108,10 @@ public async Task Get_GetAnExtendedDatabaseSBlobAuditingPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnExtendedDatabaseSBlobAuditingPolicy() + public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSBlobAuditingPolicyWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingGet.json - // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingCreateMin.json + // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,8 +121,8 @@ public async Task Exists_GetAnExtendedDatabaseSBlobAuditingPolicy() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-6852"; - string serverName = "blobauditingtest-2080"; + string resourceGroupName = "blobauditingtest-4799"; + string serverName = "blobauditingtest-6440"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -114,14 +132,25 @@ public async Task Exists_GetAnExtendedDatabaseSBlobAuditingPolicy() // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - bool result = await collection.ExistsAsync(blobAuditingPolicyName); + ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData + { + State = BlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + ExtendedDatabaseBlobAuditingPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedDatabaseBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnExtendedDatabaseSBlobAuditingPolicy() + public async Task Get_GetAnExtendedDatabaseSBlobAuditingPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingGet.json // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +174,21 @@ public async Task GetIfExists_GetAnExtendedDatabaseSBlobAuditingPolicy() // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); - ExtendedDatabaseBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; + ExtendedDatabaseBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedDatabaseBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedDatabaseBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSAzureMonitorAuditingPolicyWithMinimalParameters() + public async Task GetAll_ListExtendedAuditingSettingsOfADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseAzureMonitorAuditingCreateMin.json - // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseExtendedAuditingSettingsList.json + // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,8 +198,8 @@ public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSAzureMonitorAu // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-4799"; - string serverName = "blobauditingtest-6440"; + string resourceGroupName = "blobauditingtest-6852"; + string serverName = "blobauditingtest-2080"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -186,29 +207,25 @@ public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSAzureMonitorAu // get the collection of this ExtendedDatabaseBlobAuditingPolicyResource ExtendedDatabaseBlobAuditingPolicyCollection collection = sqlDatabase.GetExtendedDatabaseBlobAuditingPolicies(); - // invoke the operation - BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData() + // invoke the operation and iterate over the result + await foreach (ExtendedDatabaseBlobAuditingPolicyResource item in collection.GetAllAsync()) { - IsAzureMonitorTargetEnabled = true, - State = BlobAuditingPolicyState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - ExtendedDatabaseBlobAuditingPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedDatabaseBlobAuditingPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedDatabaseBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSBlobAuditingPolicyWithAllParameters() + public async Task Exists_GetAnExtendedDatabaseSBlobAuditingPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingCreateMax.json - // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingGet.json + // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -218,8 +235,8 @@ public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSBlobAuditingPo // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-4799"; - string serverName = "blobauditingtest-6440"; + string resourceGroupName = "blobauditingtest-6852"; + string serverName = "blobauditingtest-2080"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -229,38 +246,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSBlobAuditingPo // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData() - { - PredicateExpression = "statement = 'select 1'", - RetentionDays = 6, - AuditActionsAndGroups = -{ -"DATABASE_LOGOUT_GROUP","DATABASE_ROLE_MEMBER_CHANGE_GROUP","UPDATE on database::TestDatabaseName by public" -}, - IsStorageSecondaryKeyInUse = false, - IsAzureMonitorTargetEnabled = true, - QueueDelayMs = 4000, - State = BlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - ExtendedDatabaseBlobAuditingPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(blobAuditingPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedDatabaseBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSBlobAuditingPolicyWithMinimalParameters() + public async Task GetIfExists_GetAnExtendedDatabaseSBlobAuditingPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingCreateMin.json - // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedDatabaseBlobAuditingGet.json + // this example is just showing the usage of "ExtendedDatabaseBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -270,8 +266,8 @@ public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSBlobAuditingPo // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-4799"; - string serverName = "blobauditingtest-6440"; + string resourceGroupName = "blobauditingtest-6852"; + string serverName = "blobauditingtest-2080"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -281,20 +277,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAnExtendedDatabaseSBlobAuditingPo // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData() - { - State = BlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - ExtendedDatabaseBlobAuditingPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); + ExtendedDatabaseBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedDatabaseBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedDatabaseBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedDatabaseBlobAuditingPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedDatabaseBlobAuditingPolicyResource.cs index d7cd3fb0890ca..88a5b25e0f9b2 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedDatabaseBlobAuditingPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedDatabaseBlobAuditingPolicyResource.cs @@ -71,7 +71,7 @@ public async Task Update_CreateOrUpdateAnExtendedDatabaseSAzureMonitorAuditingPo ExtendedDatabaseBlobAuditingPolicyResource extendedDatabaseBlobAuditingPolicy = client.GetExtendedDatabaseBlobAuditingPolicyResource(extendedDatabaseBlobAuditingPolicyResourceId); // invoke the operation - ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData() + ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData { IsAzureMonitorTargetEnabled = true, State = BlobAuditingPolicyState.Enabled, @@ -109,14 +109,11 @@ public async Task Update_CreateOrUpdateAnExtendedDatabaseSBlobAuditingPolicyWith ExtendedDatabaseBlobAuditingPolicyResource extendedDatabaseBlobAuditingPolicy = client.GetExtendedDatabaseBlobAuditingPolicyResource(extendedDatabaseBlobAuditingPolicyResourceId); // invoke the operation - ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData() + ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData { PredicateExpression = "statement = 'select 1'", RetentionDays = 6, - AuditActionsAndGroups = -{ -"DATABASE_LOGOUT_GROUP","DATABASE_ROLE_MEMBER_CHANGE_GROUP","UPDATE on database::TestDatabaseName by public" -}, + AuditActionsAndGroups = { "DATABASE_LOGOUT_GROUP", "DATABASE_ROLE_MEMBER_CHANGE_GROUP", "UPDATE on database::TestDatabaseName by public" }, IsStorageSecondaryKeyInUse = false, IsAzureMonitorTargetEnabled = true, QueueDelayMs = 4000, @@ -158,7 +155,7 @@ public async Task Update_CreateOrUpdateAnExtendedDatabaseSBlobAuditingPolicyWith ExtendedDatabaseBlobAuditingPolicyResource extendedDatabaseBlobAuditingPolicy = client.GetExtendedDatabaseBlobAuditingPolicyResource(extendedDatabaseBlobAuditingPolicyResourceId); // invoke the operation - ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData() + ExtendedDatabaseBlobAuditingPolicyData data = new ExtendedDatabaseBlobAuditingPolicyData { State = BlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedServerBlobAuditingPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedServerBlobAuditingPolicyCollection.cs index 7b43cb2493f1e..b4769483c629c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedServerBlobAuditingPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedServerBlobAuditingPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ExtendedServerBlobAuditingPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExtendedAuditingSettingsOfAServer() + public async Task CreateOrUpdate_UpdateAServerSExtendedBlobAuditingPolicyWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerExtendedAuditingSettingsList.json - // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingCreateMax.json + // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,37 @@ public async Task GetAll_ListExtendedAuditingSettingsOfAServer() // get the collection of this ExtendedServerBlobAuditingPolicyResource ExtendedServerBlobAuditingPolicyCollection collection = sqlServer.GetExtendedServerBlobAuditingPolicies(); - // invoke the operation and iterate over the result - await foreach (ExtendedServerBlobAuditingPolicyResource item in collection.GetAllAsync()) + // invoke the operation + BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; + ExtendedServerBlobAuditingPolicyData data = new ExtendedServerBlobAuditingPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedServerBlobAuditingPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PredicateExpression = "object_name = 'SensitiveData'", + RetentionDays = 6, + AuditActionsAndGroups = { "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP" }, + IsStorageSecondaryKeyInUse = false, + IsAzureMonitorTargetEnabled = true, + QueueDelayMs = 4000, + State = BlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + ExtendedServerBlobAuditingPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedServerBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerSBlobExtendedAuditingPolicy() + public async Task CreateOrUpdate_UpdateAServerSExtendedBlobAuditingPolicyWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingGet.json - // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingCreateMin.json + // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +89,14 @@ public async Task Get_GetAServerSBlobExtendedAuditingPolicy() // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - ExtendedServerBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); + ExtendedServerBlobAuditingPolicyData data = new ExtendedServerBlobAuditingPolicyData + { + State = BlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + ExtendedServerBlobAuditingPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +107,7 @@ public async Task Get_GetAServerSBlobExtendedAuditingPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerSBlobExtendedAuditingPolicy() + public async Task Get_GetAServerSBlobExtendedAuditingPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingGet.json // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +130,21 @@ public async Task Exists_GetAServerSBlobExtendedAuditingPolicy() // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - bool result = await collection.ExistsAsync(blobAuditingPolicyName); + ExtendedServerBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedServerBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerSBlobExtendedAuditingPolicy() + public async Task GetAll_ListExtendedAuditingSettingsOfAServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingGet.json - // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerExtendedAuditingSettingsList.json + // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +162,25 @@ public async Task GetIfExists_GetAServerSBlobExtendedAuditingPolicy() // get the collection of this ExtendedServerBlobAuditingPolicyResource ExtendedServerBlobAuditingPolicyCollection collection = sqlServer.GetExtendedServerBlobAuditingPolicies(); - // invoke the operation - BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); - ExtendedServerBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ExtendedServerBlobAuditingPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExtendedServerBlobAuditingPolicyData resourceData = result.Data; + ExtendedServerBlobAuditingPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSExtendedBlobAuditingPolicyWithAllParameters() + public async Task Exists_GetAServerSBlobExtendedAuditingPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingCreateMax.json - // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingGet.json + // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,38 +200,17 @@ public async Task CreateOrUpdate_UpdateAServerSExtendedBlobAuditingPolicyWithAll // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - ExtendedServerBlobAuditingPolicyData data = new ExtendedServerBlobAuditingPolicyData() - { - PredicateExpression = "object_name = 'SensitiveData'", - RetentionDays = 6, - AuditActionsAndGroups = -{ -"SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP","FAILED_DATABASE_AUTHENTICATION_GROUP","BATCH_COMPLETED_GROUP" -}, - IsStorageSecondaryKeyInUse = false, - IsAzureMonitorTargetEnabled = true, - QueueDelayMs = 4000, - State = BlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - ExtendedServerBlobAuditingPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(blobAuditingPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedServerBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSExtendedBlobAuditingPolicyWithMinimalParameters() + public async Task GetIfExists_GetAServerSBlobExtendedAuditingPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingCreateMin.json - // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ExtendedServerBlobAuditingGet.json + // this example is just showing the usage of "ExtendedServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -234,20 +230,21 @@ public async Task CreateOrUpdate_UpdateAServerSExtendedBlobAuditingPolicyWithMin // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - ExtendedServerBlobAuditingPolicyData data = new ExtendedServerBlobAuditingPolicyData() - { - State = BlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - ExtendedServerBlobAuditingPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); + ExtendedServerBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedServerBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedServerBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedServerBlobAuditingPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedServerBlobAuditingPolicyResource.cs index e037733083795..d9ce414a51e80 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedServerBlobAuditingPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ExtendedServerBlobAuditingPolicyResource.cs @@ -69,14 +69,11 @@ public async Task Update_UpdateAServerSExtendedBlobAuditingPolicyWithAllParamete ExtendedServerBlobAuditingPolicyResource extendedServerBlobAuditingPolicy = client.GetExtendedServerBlobAuditingPolicyResource(extendedServerBlobAuditingPolicyResourceId); // invoke the operation - ExtendedServerBlobAuditingPolicyData data = new ExtendedServerBlobAuditingPolicyData() + ExtendedServerBlobAuditingPolicyData data = new ExtendedServerBlobAuditingPolicyData { PredicateExpression = "object_name = 'SensitiveData'", RetentionDays = 6, - AuditActionsAndGroups = -{ -"SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP","FAILED_DATABASE_AUTHENTICATION_GROUP","BATCH_COMPLETED_GROUP" -}, + AuditActionsAndGroups = { "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP" }, IsStorageSecondaryKeyInUse = false, IsAzureMonitorTargetEnabled = true, QueueDelayMs = 4000, @@ -117,7 +114,7 @@ public async Task Update_UpdateAServerSExtendedBlobAuditingPolicyWithMinimalPara ExtendedServerBlobAuditingPolicyResource extendedServerBlobAuditingPolicy = client.GetExtendedServerBlobAuditingPolicyResource(extendedServerBlobAuditingPolicyResourceId); // invoke the operation - ExtendedServerBlobAuditingPolicyData data = new ExtendedServerBlobAuditingPolicyData() + ExtendedServerBlobAuditingPolicyData data = new ExtendedServerBlobAuditingPolicyData { State = BlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_FailoverGroupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_FailoverGroupCollection.cs index 05b4de56bb38b..5c5ff2e4fb75c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_FailoverGroupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_FailoverGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FailoverGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFailoverGroup() + public async Task CreateOrUpdate_CreateFailoverGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupList.json - // this example is just showing the usage of "FailoverGroups_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupCreateOrUpdate.json + // this example is just showing the usage of "FailoverGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,37 @@ public async Task GetAll_ListFailoverGroup() // get the collection of this FailoverGroupResource FailoverGroupCollection collection = sqlServer.GetFailoverGroups(); - // invoke the operation and iterate over the result - await foreach (FailoverGroupResource item in collection.GetAllAsync()) + // invoke the operation + string failoverGroupName = "failover-group-test-3"; + FailoverGroupData data = new FailoverGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FailoverGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ReadWriteEndpoint = new FailoverGroupReadWriteEndpoint(ReadWriteEndpointFailoverPolicy.Automatic) + { + FailoverWithDataLossGracePeriodMinutes = 480, + }, + ReadOnlyEndpoint = new FailoverGroupReadOnlyEndpoint + { + FailoverPolicy = ReadOnlyEndpointFailoverPolicy.Disabled, + }, + PartnerServers = { new PartnerServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-secondary-server")) }, + FailoverDatabases = { new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-1"), new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-2") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, failoverGroupName, data); + FailoverGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FailoverGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFailoverGroup() + public async Task CreateOrUpdate_CreateFailoverGroupWithStandbySecondaryDatabaseOnPartnerServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupGet.json - // this example is just showing the usage of "FailoverGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupCreateOrUpdateStandbySecondary.json + // this example is just showing the usage of "FailoverGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,7 +80,7 @@ public async Task Get_GetFailoverGroup() // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default"; - string serverName = "failovergroupprimaryserver"; + string serverName = "failover-group-primary-server"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); @@ -76,8 +88,23 @@ public async Task Get_GetFailoverGroup() FailoverGroupCollection collection = sqlServer.GetFailoverGroups(); // invoke the operation - string failoverGroupName = "failovergrouptest3"; - FailoverGroupResource result = await collection.GetAsync(failoverGroupName); + string failoverGroupName = "failover-group-test-3"; + FailoverGroupData data = new FailoverGroupData + { + ReadWriteEndpoint = new FailoverGroupReadWriteEndpoint(ReadWriteEndpointFailoverPolicy.Automatic) + { + FailoverWithDataLossGracePeriodMinutes = 480, + }, + ReadOnlyEndpoint = new FailoverGroupReadOnlyEndpoint + { + FailoverPolicy = ReadOnlyEndpointFailoverPolicy.Disabled, + }, + PartnerServers = { new PartnerServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-secondary-server")) }, + FailoverDatabases = { new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-1"), new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-2") }, + SecondaryType = FailoverGroupDatabasesSecondaryType.Standby, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, failoverGroupName, data); + FailoverGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +115,7 @@ public async Task Get_GetFailoverGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFailoverGroup() + public async Task Get_GetFailoverGroup() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupGet.json // this example is just showing the usage of "FailoverGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +138,21 @@ public async Task Exists_GetFailoverGroup() // invoke the operation string failoverGroupName = "failovergrouptest3"; - bool result = await collection.ExistsAsync(failoverGroupName); + FailoverGroupResource result = await collection.GetAsync(failoverGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FailoverGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFailoverGroup() + public async Task GetAll_ListFailoverGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupGet.json - // this example is just showing the usage of "FailoverGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupList.json + // this example is just showing the usage of "FailoverGroups_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,38 +163,32 @@ public async Task GetIfExists_GetFailoverGroup() // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default"; - string serverName = "failovergroupprimaryserver"; + string serverName = "failover-group-primary-server"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); // get the collection of this FailoverGroupResource FailoverGroupCollection collection = sqlServer.GetFailoverGroups(); - // invoke the operation - string failoverGroupName = "failovergrouptest3"; - NullableResponse response = await collection.GetIfExistsAsync(failoverGroupName); - FailoverGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (FailoverGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FailoverGroupData resourceData = result.Data; + FailoverGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFailoverGroup() + public async Task Exists_GetFailoverGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupCreateOrUpdate.json - // this example is just showing the usage of "FailoverGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupGet.json + // this example is just showing the usage of "FailoverGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,7 +199,7 @@ public async Task CreateOrUpdate_CreateFailoverGroup() // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default"; - string serverName = "failover-group-primary-server"; + string serverName = "failovergroupprimaryserver"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); @@ -182,42 +207,18 @@ public async Task CreateOrUpdate_CreateFailoverGroup() FailoverGroupCollection collection = sqlServer.GetFailoverGroups(); // invoke the operation - string failoverGroupName = "failover-group-test-3"; - FailoverGroupData data = new FailoverGroupData() - { - ReadWriteEndpoint = new FailoverGroupReadWriteEndpoint(ReadWriteEndpointFailoverPolicy.Automatic) - { - FailoverWithDataLossGracePeriodMinutes = 480, - }, - ReadOnlyEndpoint = new FailoverGroupReadOnlyEndpoint() - { - FailoverPolicy = ReadOnlyEndpointFailoverPolicy.Disabled, - }, - PartnerServers = -{ -new PartnerServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-secondary-server")) -}, - FailoverDatabases = -{ -new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-1"),new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-2") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, failoverGroupName, data); - FailoverGroupResource result = lro.Value; + string failoverGroupName = "failovergrouptest3"; + bool result = await collection.ExistsAsync(failoverGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FailoverGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFailoverGroupWithStandbySecondaryDatabaseOnPartnerServer() + public async Task GetIfExists_GetFailoverGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupCreateOrUpdateStandbySecondary.json - // this example is just showing the usage of "FailoverGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/FailoverGroupGet.json + // this example is just showing the usage of "FailoverGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -228,7 +229,7 @@ public async Task CreateOrUpdate_CreateFailoverGroupWithStandbySecondaryDatabase // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default"; - string serverName = "failover-group-primary-server"; + string serverName = "failovergroupprimaryserver"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); @@ -236,35 +237,22 @@ public async Task CreateOrUpdate_CreateFailoverGroupWithStandbySecondaryDatabase FailoverGroupCollection collection = sqlServer.GetFailoverGroups(); // invoke the operation - string failoverGroupName = "failover-group-test-3"; - FailoverGroupData data = new FailoverGroupData() - { - ReadWriteEndpoint = new FailoverGroupReadWriteEndpoint(ReadWriteEndpointFailoverPolicy.Automatic) - { - FailoverWithDataLossGracePeriodMinutes = 480, - }, - ReadOnlyEndpoint = new FailoverGroupReadOnlyEndpoint() - { - FailoverPolicy = ReadOnlyEndpointFailoverPolicy.Disabled, - }, - PartnerServers = -{ -new PartnerServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-secondary-server")) -}, - FailoverDatabases = -{ -new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-1"),new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-2") -}, - SecondaryType = FailoverGroupDatabasesSecondaryType.Standby, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, failoverGroupName, data); - FailoverGroupResource result = lro.Value; + string failoverGroupName = "failovergrouptest3"; + NullableResponse response = await collection.GetIfExistsAsync(failoverGroupName); + FailoverGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FailoverGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FailoverGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_FailoverGroupResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_FailoverGroupResource.cs index e6744108a0c0d..30a55dc4c3e7f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_FailoverGroupResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_FailoverGroupResource.cs @@ -96,16 +96,13 @@ public async Task Update_AddDatabaseToFailoverGroupWithStandbySecondaryOnPartner FailoverGroupResource failoverGroup = client.GetFailoverGroupResource(failoverGroupResourceId); // invoke the operation - FailoverGroupPatch patch = new FailoverGroupPatch() + FailoverGroupPatch patch = new FailoverGroupPatch { ReadWriteEndpoint = new FailoverGroupReadWriteEndpoint(ReadWriteEndpointFailoverPolicy.Automatic) { FailoverWithDataLossGracePeriodMinutes = 120, }, - FailoverDatabases = -{ -new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-1") -}, + FailoverDatabases = { new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-1") }, SecondaryType = FailoverGroupDatabasesSecondaryType.Standby, }; ArmOperation lro = await failoverGroup.UpdateAsync(WaitUntil.Completed, patch); @@ -140,16 +137,13 @@ public async Task Update_UpdateFailoverGroup() FailoverGroupResource failoverGroup = client.GetFailoverGroupResource(failoverGroupResourceId); // invoke the operation - FailoverGroupPatch patch = new FailoverGroupPatch() + FailoverGroupPatch patch = new FailoverGroupPatch { ReadWriteEndpoint = new FailoverGroupReadWriteEndpoint(ReadWriteEndpointFailoverPolicy.Automatic) { FailoverWithDataLossGracePeriodMinutes = 120, }, - FailoverDatabases = -{ -new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-1") -}, + FailoverDatabases = { new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/servers/failover-group-primary-server/databases/testdb-1") }, }; ArmOperation lro = await failoverGroup.UpdateAsync(WaitUntil.Completed, patch); FailoverGroupResource result = lro.Value; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_GeoBackupPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_GeoBackupPolicyCollection.cs index c21312551f224..7c00c932a4a1a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_GeoBackupPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_GeoBackupPolicyCollection.cs @@ -90,10 +90,10 @@ public async Task Get_GetGeoBackupPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetGeoBackupPolicy() + public async Task GetAll_ListGeoBackupPolicies() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json - // this example is just showing the usage of "GeoBackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesList.json + // this example is just showing the usage of "GeoBackupPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_GetGeoBackupPolicy() // get the collection of this GeoBackupPolicyResource GeoBackupPolicyCollection collection = sqlDatabase.GetGeoBackupPolicies(); - // invoke the operation - GeoBackupPolicyName geoBackupPolicyName = GeoBackupPolicyName.Default; - bool result = await collection.ExistsAsync(geoBackupPolicyName); + // invoke the operation and iterate over the result + await foreach (GeoBackupPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GeoBackupPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetGeoBackupPolicy() + public async Task Exists_GetGeoBackupPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json // this example is just showing the usage of "GeoBackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +151,17 @@ public async Task GetIfExists_GetGeoBackupPolicy() // invoke the operation GeoBackupPolicyName geoBackupPolicyName = GeoBackupPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(geoBackupPolicyName); - GeoBackupPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(geoBackupPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GeoBackupPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListGeoBackupPolicies() + public async Task GetIfExists_GetGeoBackupPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesList.json - // this example is just showing the usage of "GeoBackupPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json + // this example is just showing the usage of "GeoBackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_ListGeoBackupPolicies() // get the collection of this GeoBackupPolicyResource GeoBackupPolicyCollection collection = sqlDatabase.GetGeoBackupPolicies(); - // invoke the operation and iterate over the result - await foreach (GeoBackupPolicyResource item in collection.GetAllAsync()) + // invoke the operation + GeoBackupPolicyName geoBackupPolicyName = GeoBackupPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(geoBackupPolicyName); + GeoBackupPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - GeoBackupPolicyData resourceData = item.Data; + GeoBackupPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_GeoBackupPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_GeoBackupPolicyResource.cs index db10142028114..050088dc571de 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_GeoBackupPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_GeoBackupPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_GeoBackupPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateGeoBackupPolicy() + public async Task Get_GetGeoBackupPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesCreateOrUpdate.json - // this example is just showing the usage of "GeoBackupPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json + // this example is just showing the usage of "GeoBackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,9 +39,7 @@ public async Task Update_UpdateGeoBackupPolicy() GeoBackupPolicyResource geoBackupPolicy = client.GetGeoBackupPolicyResource(geoBackupPolicyResourceId); // invoke the operation - GeoBackupPolicyData data = new GeoBackupPolicyData(GeoBackupPolicyState.Enabled); - ArmOperation lro = await geoBackupPolicy.UpdateAsync(WaitUntil.Completed, data); - GeoBackupPolicyResource result = lro.Value; + GeoBackupPolicyResource result = await geoBackupPolicy.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +50,10 @@ public async Task Update_UpdateGeoBackupPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetGeoBackupPolicy() + public async Task Update_UpdateGeoBackupPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesGet.json - // this example is just showing the usage of "GeoBackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/GeoBackupPoliciesCreateOrUpdate.json + // this example is just showing the usage of "GeoBackupPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,7 +71,9 @@ public async Task Get_GetGeoBackupPolicy() GeoBackupPolicyResource geoBackupPolicy = client.GetGeoBackupPolicyResource(geoBackupPolicyResourceId); // invoke the operation - GeoBackupPolicyResource result = await geoBackupPolicy.GetAsync(); + GeoBackupPolicyData data = new GeoBackupPolicyData(GeoBackupPolicyState.Enabled); + ArmOperation lro = await geoBackupPolicy.UpdateAsync(WaitUntil.Completed, data); + GeoBackupPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_IPv6FirewallRuleCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_IPv6FirewallRuleCollection.cs index 27e869421115a..d5a594ea5d236 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_IPv6FirewallRuleCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_IPv6FirewallRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_IPv6FirewallRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIPv6FirewallRules() + public async Task CreateOrUpdate_CreateAnIPv6FirewallRuleMaxMin() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleList.json - // this example is just showing the usage of "IPv6FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleCreate.json + // this example is just showing the usage of "IPv6FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,29 @@ public async Task GetAll_ListIPv6FirewallRules() // get the collection of this IPv6FirewallRuleResource IPv6FirewallRuleCollection collection = sqlServer.GetIPv6FirewallRules(); - // invoke the operation and iterate over the result - await foreach (IPv6FirewallRuleResource item in collection.GetAllAsync()) + // invoke the operation + string firewallRuleName = "firewallrulecrudtest-5370"; + IPv6FirewallRuleData data = new IPv6FirewallRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IPv6FirewallRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StartIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0003", + EndIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0003", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data); + IPv6FirewallRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IPv6FirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetIPv6FirewallRule() + public async Task CreateOrUpdate_UpdateAnIPv6FirewallRuleMaxMin() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleGet.json - // this example is just showing the usage of "IPv6FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleUpdate.json + // this example is just showing the usage of "IPv6FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,8 +79,14 @@ public async Task Get_GetIPv6FirewallRule() IPv6FirewallRuleCollection collection = sqlServer.GetIPv6FirewallRules(); // invoke the operation - string firewallRuleName = "firewallrulecrudtest-2304"; - IPv6FirewallRuleResource result = await collection.GetAsync(firewallRuleName); + string firewallRuleName = "firewallrulecrudtest-3927"; + IPv6FirewallRuleData data = new IPv6FirewallRuleData + { + StartIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0001", + EndIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0001", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data); + IPv6FirewallRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +97,7 @@ public async Task Get_GetIPv6FirewallRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetIPv6FirewallRule() + public async Task Get_GetIPv6FirewallRule() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleGet.json // this example is just showing the usage of "IPv6FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -110,17 +120,21 @@ public async Task Exists_GetIPv6FirewallRule() // invoke the operation string firewallRuleName = "firewallrulecrudtest-2304"; - bool result = await collection.ExistsAsync(firewallRuleName); + IPv6FirewallRuleResource result = await collection.GetAsync(firewallRuleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IPv6FirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetIPv6FirewallRule() + public async Task GetAll_ListIPv6FirewallRules() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleGet.json - // this example is just showing the usage of "IPv6FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleList.json + // this example is just showing the usage of "IPv6FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,31 +152,25 @@ public async Task GetIfExists_GetIPv6FirewallRule() // get the collection of this IPv6FirewallRuleResource IPv6FirewallRuleCollection collection = sqlServer.GetIPv6FirewallRules(); - // invoke the operation - string firewallRuleName = "firewallrulecrudtest-2304"; - NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); - IPv6FirewallRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (IPv6FirewallRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IPv6FirewallRuleData resourceData = result.Data; + IPv6FirewallRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnIPv6FirewallRuleMaxMin() + public async Task Exists_GetIPv6FirewallRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleCreate.json - // this example is just showing the usage of "IPv6FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleGet.json + // this example is just showing the usage of "IPv6FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,28 +189,18 @@ public async Task CreateOrUpdate_CreateAnIPv6FirewallRuleMaxMin() IPv6FirewallRuleCollection collection = sqlServer.GetIPv6FirewallRules(); // invoke the operation - string firewallRuleName = "firewallrulecrudtest-5370"; - IPv6FirewallRuleData data = new IPv6FirewallRuleData() - { - StartIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0003", - EndIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0003", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data); - IPv6FirewallRuleResource result = lro.Value; + string firewallRuleName = "firewallrulecrudtest-2304"; + bool result = await collection.ExistsAsync(firewallRuleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IPv6FirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAnIPv6FirewallRuleMaxMin() + public async Task GetIfExists_GetIPv6FirewallRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleUpdate.json - // this example is just showing the usage of "IPv6FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleGet.json + // this example is just showing the usage of "IPv6FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -221,20 +219,22 @@ public async Task CreateOrUpdate_UpdateAnIPv6FirewallRuleMaxMin() IPv6FirewallRuleCollection collection = sqlServer.GetIPv6FirewallRules(); // invoke the operation - string firewallRuleName = "firewallrulecrudtest-3927"; - IPv6FirewallRuleData data = new IPv6FirewallRuleData() - { - StartIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0001", - EndIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0001", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data); - IPv6FirewallRuleResource result = lro.Value; + string firewallRuleName = "firewallrulecrudtest-2304"; + NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); + IPv6FirewallRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IPv6FirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IPv6FirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_IPv6FirewallRuleResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_IPv6FirewallRuleResource.cs index 6c3b690aaebae..a373797010666 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_IPv6FirewallRuleResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_IPv6FirewallRuleResource.cs @@ -46,6 +46,33 @@ public async Task Get_GetIPv6FirewallRule() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAnIPv6FirewallRule() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleDelete.json + // this example is just showing the usage of "IPv6FirewallRules_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IPv6FirewallRuleResource created on azure + // for more information of creating IPv6FirewallRuleResource, please refer to the document of IPv6FirewallRuleResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "firewallrulecrudtest-9886"; + string serverName = "firewallrulecrudtest-2368"; + string firewallRuleName = "firewallrulecrudtest-7011"; + ResourceIdentifier iPv6FirewallRuleResourceId = IPv6FirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + IPv6FirewallRuleResource iPv6FirewallRule = client.GetIPv6FirewallRuleResource(iPv6FirewallRuleResourceId); + + // invoke the operation + await iPv6FirewallRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateAnIPv6FirewallRuleMaxMin() @@ -68,7 +95,7 @@ public async Task Update_CreateAnIPv6FirewallRuleMaxMin() IPv6FirewallRuleResource iPv6FirewallRule = client.GetIPv6FirewallRuleResource(iPv6FirewallRuleResourceId); // invoke the operation - IPv6FirewallRuleData data = new IPv6FirewallRuleData() + IPv6FirewallRuleData data = new IPv6FirewallRuleData { StartIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0003", EndIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0003", @@ -105,7 +132,7 @@ public async Task Update_UpdateAnIPv6FirewallRuleMaxMin() IPv6FirewallRuleResource iPv6FirewallRule = client.GetIPv6FirewallRuleResource(iPv6FirewallRuleResourceId); // invoke the operation - IPv6FirewallRuleData data = new IPv6FirewallRuleData() + IPv6FirewallRuleData data = new IPv6FirewallRuleData { StartIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0001", EndIPv6Address = "0000:0000:0000:0000:0000:ffff:0000:0001", @@ -119,32 +146,5 @@ public async Task Update_UpdateAnIPv6FirewallRuleMaxMin() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnIPv6FirewallRule() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/IPv6FirewallRuleDelete.json - // this example is just showing the usage of "IPv6FirewallRules_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this IPv6FirewallRuleResource created on azure - // for more information of creating IPv6FirewallRuleResource, please refer to the document of IPv6FirewallRuleResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "firewallrulecrudtest-9886"; - string serverName = "firewallrulecrudtest-2368"; - string firewallRuleName = "firewallrulecrudtest-7011"; - ResourceIdentifier iPv6FirewallRuleResourceId = IPv6FirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - IPv6FirewallRuleResource iPv6FirewallRule = client.GetIPv6FirewallRuleResource(iPv6FirewallRuleResourceId); - - // invoke the operation - await iPv6FirewallRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstanceFailoverGroupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstanceFailoverGroupCollection.cs index 097b6358b4224..08532b75e2d52 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstanceFailoverGroupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstanceFailoverGroupCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_InstanceFailoverGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFailoverGroup() + public async Task CreateOrUpdate_CreateFailoverGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupList.json - // this example is just showing the usage of "InstanceFailoverGroups_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupCreateOrUpdate.json + // this example is just showing the usage of "InstanceFailoverGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,34 @@ public async Task GetAll_ListFailoverGroup() AzureLocation locationName = new AzureLocation("Japan East"); InstanceFailoverGroupCollection collection = resourceGroupResource.GetInstanceFailoverGroups(locationName); - // invoke the operation and iterate over the result - await foreach (InstanceFailoverGroupResource item in collection.GetAllAsync()) + // invoke the operation + string failoverGroupName = "failover-group-test-3"; + InstanceFailoverGroupData data = new InstanceFailoverGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InstanceFailoverGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SecondaryType = GeoSecondaryInstanceType.Geo, + ReadWriteEndpoint = new InstanceFailoverGroupReadWriteEndpoint(ReadWriteEndpointFailoverPolicy.Automatic) + { + FailoverWithDataLossGracePeriodMinutes = 480, + }, + ReadOnlyEndpointFailoverPolicy = ReadOnlyEndpointFailoverPolicy.Disabled, + PartnerRegions = {new PartnerRegionInfo +{ +Location = new AzureLocation("Japan West"), +}}, + ManagedInstancePairs = {new ManagedInstancePairInfo +{ +PrimaryManagedInstanceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/failover-group-primary-mngdInstance"), +PartnerManagedInstanceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/failover-group-secondary-mngdInstance"), +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, failoverGroupName, data); + InstanceFailoverGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InstanceFailoverGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +106,10 @@ public async Task Get_GetFailoverGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFailoverGroup() + public async Task GetAll_ListFailoverGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupGet.json - // this example is just showing the usage of "InstanceFailoverGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupList.json + // this example is just showing the usage of "InstanceFailoverGroups_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +127,22 @@ public async Task Exists_GetFailoverGroup() AzureLocation locationName = new AzureLocation("Japan East"); InstanceFailoverGroupCollection collection = resourceGroupResource.GetInstanceFailoverGroups(locationName); - // invoke the operation - string failoverGroupName = "failover-group-test"; - bool result = await collection.ExistsAsync(failoverGroupName); + // invoke the operation and iterate over the result + await foreach (InstanceFailoverGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InstanceFailoverGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFailoverGroup() + public async Task Exists_GetFailoverGroup() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupGet.json // this example is just showing the usage of "InstanceFailoverGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +165,17 @@ public async Task GetIfExists_GetFailoverGroup() // invoke the operation string failoverGroupName = "failover-group-test"; - NullableResponse response = await collection.GetIfExistsAsync(failoverGroupName); - InstanceFailoverGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(failoverGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InstanceFailoverGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFailoverGroup() + public async Task GetIfExists_GetFailoverGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupCreateOrUpdate.json - // this example is just showing the usage of "InstanceFailoverGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupGet.json + // this example is just showing the usage of "InstanceFailoverGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,39 +194,22 @@ public async Task CreateOrUpdate_CreateFailoverGroup() InstanceFailoverGroupCollection collection = resourceGroupResource.GetInstanceFailoverGroups(locationName); // invoke the operation - string failoverGroupName = "failover-group-test-3"; - InstanceFailoverGroupData data = new InstanceFailoverGroupData() - { - SecondaryType = GeoSecondaryInstanceType.Geo, - ReadWriteEndpoint = new InstanceFailoverGroupReadWriteEndpoint(ReadWriteEndpointFailoverPolicy.Automatic) - { - FailoverWithDataLossGracePeriodMinutes = 480, - }, - ReadOnlyEndpointFailoverPolicy = ReadOnlyEndpointFailoverPolicy.Disabled, - PartnerRegions = -{ -new PartnerRegionInfo() -{ -Location = new AzureLocation("Japan West"), -} -}, - ManagedInstancePairs = -{ -new ManagedInstancePairInfo() -{ -PrimaryManagedInstanceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/failover-group-primary-mngdInstance"), -PartnerManagedInstanceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/failover-group-secondary-mngdInstance"), -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, failoverGroupName, data); - InstanceFailoverGroupResource result = lro.Value; + string failoverGroupName = "failover-group-test"; + NullableResponse response = await collection.GetIfExistsAsync(failoverGroupName); + InstanceFailoverGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InstanceFailoverGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InstanceFailoverGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstanceFailoverGroupResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstanceFailoverGroupResource.cs index 5735ab671c19f..317e979e982f8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstanceFailoverGroupResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstanceFailoverGroupResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetFailoverGroup() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteFailoverGroup() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupDelete.json + // this example is just showing the usage of "InstanceFailoverGroups_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this InstanceFailoverGroupResource created on azure + // for more information of creating InstanceFailoverGroupResource, please refer to the document of InstanceFailoverGroupResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default"; + AzureLocation locationName = new AzureLocation("Japan East"); + string failoverGroupName = "failover-group-test-1"; + ResourceIdentifier instanceFailoverGroupResourceId = InstanceFailoverGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, locationName, failoverGroupName); + InstanceFailoverGroupResource instanceFailoverGroup = client.GetInstanceFailoverGroupResource(instanceFailoverGroupResourceId); + + // invoke the operation + await instanceFailoverGroup.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateFailoverGroup() @@ -69,7 +96,7 @@ public async Task Update_CreateFailoverGroup() InstanceFailoverGroupResource instanceFailoverGroup = client.GetInstanceFailoverGroupResource(instanceFailoverGroupResourceId); // invoke the operation - InstanceFailoverGroupData data = new InstanceFailoverGroupData() + InstanceFailoverGroupData data = new InstanceFailoverGroupData { SecondaryType = GeoSecondaryInstanceType.Geo, ReadWriteEndpoint = new InstanceFailoverGroupReadWriteEndpoint(ReadWriteEndpointFailoverPolicy.Automatic) @@ -77,21 +104,15 @@ public async Task Update_CreateFailoverGroup() FailoverWithDataLossGracePeriodMinutes = 480, }, ReadOnlyEndpointFailoverPolicy = ReadOnlyEndpointFailoverPolicy.Disabled, - PartnerRegions = -{ -new PartnerRegionInfo() + PartnerRegions = {new PartnerRegionInfo { Location = new AzureLocation("Japan West"), -} -}, - ManagedInstancePairs = -{ -new ManagedInstancePairInfo() +}}, + ManagedInstancePairs = {new ManagedInstancePairInfo { PrimaryManagedInstanceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/failover-group-primary-mngdInstance"), PartnerManagedInstanceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/failover-group-secondary-mngdInstance"), -} -}, +}}, }; ArmOperation lro = await instanceFailoverGroup.UpdateAsync(WaitUntil.Completed, data); InstanceFailoverGroupResource result = lro.Value; @@ -103,33 +124,6 @@ public async Task Update_CreateFailoverGroup() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteFailoverGroup() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/InstanceFailoverGroupDelete.json - // this example is just showing the usage of "InstanceFailoverGroups_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this InstanceFailoverGroupResource created on azure - // for more information of creating InstanceFailoverGroupResource, please refer to the document of InstanceFailoverGroupResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default"; - AzureLocation locationName = new AzureLocation("Japan East"); - string failoverGroupName = "failover-group-test-1"; - ResourceIdentifier instanceFailoverGroupResourceId = InstanceFailoverGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, locationName, failoverGroupName); - InstanceFailoverGroupResource instanceFailoverGroup = client.GetInstanceFailoverGroupResource(instanceFailoverGroupResourceId); - - // invoke the operation - await instanceFailoverGroup.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Failover_PlannedFailoverOfAFailoverGroup() diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstancePoolCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstancePoolCollection.cs index a17eee5cd8ca8..ebf9b989e5cf8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstancePoolCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstancePoolCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_InstancePoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListInstancePoolsByResourceGroup() + public async Task CreateOrUpdate_CreateAnInstancePoolWithAllProperties() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListInstancePoolsByResourceGroup.json - // this example is just showing the usage of "InstancePools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateInstancePoolMax.json + // this example is just showing the usage of "InstancePools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,40 @@ public async Task GetAll_ListInstancePoolsByResourceGroup() // get the collection of this InstancePoolResource InstancePoolCollection collection = resourceGroupResource.GetInstancePools(); - // invoke the operation and iterate over the result - await foreach (InstancePoolResource item in collection.GetAllAsync()) + // invoke the operation + string instancePoolName = "testIP"; + InstancePoolData data = new InstancePoolData(new AzureLocation("japaneast")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InstancePoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new SqlSku("GP_Gen5") + { + Tier = "GeneralPurpose", + Family = "Gen5", + }, + SubnetId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/mysubnet1"), + VCores = 8, + LicenseType = InstancePoolLicenseType.LicenseIncluded, + MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_MI_1"), + Tags = +{ +["a"] = "b" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, instancePoolName, data); + InstancePoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InstancePoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnInstancePool() + public async Task CreateOrUpdate_CreateAnInstancePoolWithMinProperties() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetInstancePool.json - // this example is just showing the usage of "InstancePools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateInstancePoolMin.json + // this example is just showing the usage of "InstancePools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +91,19 @@ public async Task Get_GetAnInstancePool() // invoke the operation string instancePoolName = "testIP"; - InstancePoolResource result = await collection.GetAsync(instancePoolName); + InstancePoolData data = new InstancePoolData(new AzureLocation("japaneast")) + { + Sku = new SqlSku("GP_Gen5") + { + Tier = "GeneralPurpose", + Family = "Gen5", + }, + SubnetId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/mysubnet1"), + VCores = 8, + LicenseType = InstancePoolLicenseType.LicenseIncluded, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, instancePoolName, data); + InstancePoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +114,7 @@ public async Task Get_GetAnInstancePool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnInstancePool() + public async Task Get_GetAnInstancePool() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetInstancePool.json // this example is just showing the usage of "InstancePools_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,17 +136,21 @@ public async Task Exists_GetAnInstancePool() // invoke the operation string instancePoolName = "testIP"; - bool result = await collection.ExistsAsync(instancePoolName); + InstancePoolResource result = await collection.GetAsync(instancePoolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InstancePoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnInstancePool() + public async Task GetAll_ListInstancePoolsByResourceGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetInstancePool.json - // this example is just showing the usage of "InstancePools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListInstancePoolsByResourceGroup.json + // this example is just showing the usage of "InstancePools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,31 +167,25 @@ public async Task GetIfExists_GetAnInstancePool() // get the collection of this InstancePoolResource InstancePoolCollection collection = resourceGroupResource.GetInstancePools(); - // invoke the operation - string instancePoolName = "testIP"; - NullableResponse response = await collection.GetIfExistsAsync(instancePoolName); - InstancePoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (InstancePoolResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - InstancePoolData resourceData = result.Data; + InstancePoolData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnInstancePoolWithAllProperties() + public async Task Exists_GetAnInstancePool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateInstancePoolMax.json - // this example is just showing the usage of "InstancePools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetInstancePool.json + // this example is just showing the usage of "InstancePools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,38 +204,17 @@ public async Task CreateOrUpdate_CreateAnInstancePoolWithAllProperties() // invoke the operation string instancePoolName = "testIP"; - InstancePoolData data = new InstancePoolData(new AzureLocation("japaneast")) - { - Sku = new SqlSku("GP_Gen5") - { - Tier = "GeneralPurpose", - Family = "Gen5", - }, - SubnetId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/mysubnet1"), - VCores = 8, - LicenseType = InstancePoolLicenseType.LicenseIncluded, - MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_MI_1"), - Tags = -{ -["a"] = "b", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, instancePoolName, data); - InstancePoolResource result = lro.Value; + bool result = await collection.ExistsAsync(instancePoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InstancePoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnInstancePoolWithMinProperties() + public async Task GetIfExists_GetAnInstancePool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CreateOrUpdateInstancePoolMin.json - // this example is just showing the usage of "InstancePools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetInstancePool.json + // this example is just showing the usage of "InstancePools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -229,25 +233,21 @@ public async Task CreateOrUpdate_CreateAnInstancePoolWithMinProperties() // invoke the operation string instancePoolName = "testIP"; - InstancePoolData data = new InstancePoolData(new AzureLocation("japaneast")) - { - Sku = new SqlSku("GP_Gen5") - { - Tier = "GeneralPurpose", - Family = "Gen5", - }, - SubnetId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Network/virtualNetworks/myvnet/subnets/mysubnet1"), - VCores = 8, - LicenseType = InstancePoolLicenseType.LicenseIncluded, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, instancePoolName, data); - InstancePoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(instancePoolName); + InstancePoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InstancePoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InstancePoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstancePoolResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstancePoolResource.cs index 1c8da03dc09e5..3798912e79e73 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstancePoolResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_InstancePoolResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Sql.Models; using NUnit.Framework; @@ -19,10 +18,10 @@ public partial class Sample_InstancePoolResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetUsages_ListInstancePoolUsagesExpandedWithChildren() + public async Task Get_GetAnInstancePool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListInstancePoolUsageExpanded.json - // this example is just showing the usage of "Usages_ListByInstancePool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetInstancePool.json + // this example is just showing the usage of "InstancePools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,22 +36,22 @@ public async Task GetUsages_ListInstancePoolUsagesExpandedWithChildren() ResourceIdentifier instancePoolResourceId = InstancePoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instancePoolName); InstancePoolResource instancePool = client.GetInstancePoolResource(instancePoolResourceId); - // invoke the operation and iterate over the result - bool? expandChildren = true; - await foreach (InstancePoolUsage item in instancePool.GetUsagesAsync(expandChildren: expandChildren)) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + InstancePoolResource result = await instancePool.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InstancePoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetUsages_ListInstancePoolUsages() + public async Task Delete_DeleteAnInstancePool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListInstancePoolUsage.json - // this example is just showing the usage of "Usages_ListByInstancePool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteInstancePool.json + // this example is just showing the usage of "InstancePools_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,21 +66,18 @@ public async Task GetUsages_ListInstancePoolUsages() ResourceIdentifier instancePoolResourceId = InstancePoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instancePoolName); InstancePoolResource instancePool = client.GetInstancePoolResource(instancePoolResourceId); - // invoke the operation and iterate over the result - await foreach (InstancePoolUsage item in instancePool.GetUsagesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + await instancePool.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetManagedInstances_ListManagedInstancesByInstancePool() + public async Task Update_PatchAnInstancePool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByInstancePool.json - // this example is just showing the usage of "ManagedInstances_ListByInstancePool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PatchInstancePool.json + // this example is just showing the usage of "InstancePools_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -90,31 +86,36 @@ public async Task GetManagedInstances_ListManagedInstancesByInstancePool() // this example assumes you already have this InstancePoolResource created on azure // for more information of creating InstancePoolResource, please refer to the document of InstancePoolResource - string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; - string resourceGroupName = "Test1"; - string instancePoolName = "pool1"; + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "group1"; + string instancePoolName = "testIP"; ResourceIdentifier instancePoolResourceId = InstancePoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instancePoolName); InstancePoolResource instancePool = client.GetInstancePoolResource(instancePoolResourceId); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceResource item in instancePool.GetManagedInstancesAsync()) + // invoke the operation + InstancePoolPatch patch = new InstancePoolPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["x"] = "y" +}, + }; + ArmOperation lro = await instancePool.UpdateAsync(WaitUntil.Completed, patch); + InstancePoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InstancePoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetManagedInstances_ListManagedInstancesByInstancePoolWithExpandAdministratorsActivedirectory() + public async Task GetUsages_ListInstancePoolUsagesExpandedWithChildren() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByInstancePoolWithExpandEqualsAdministrators.json - // this example is just showing the usage of "ManagedInstances_ListByInstancePool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListInstancePoolUsageExpanded.json + // this example is just showing the usage of "Usages_ListByInstancePool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -123,51 +124,17 @@ public async Task GetManagedInstances_ListManagedInstancesByInstancePoolWithExpa // this example assumes you already have this InstancePoolResource created on azure // for more information of creating InstancePoolResource, please refer to the document of InstancePoolResource - string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; - string resourceGroupName = "Test1"; - string instancePoolName = "pool1"; + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "group1"; + string instancePoolName = "testIP"; ResourceIdentifier instancePoolResourceId = InstancePoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instancePoolName); InstancePoolResource instancePool = client.GetInstancePoolResource(instancePoolResourceId); // invoke the operation and iterate over the result - await foreach (ManagedInstanceResource item in instancePool.GetManagedInstancesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetInstancePools_ListInstancePoolsInTheSubscription() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListInstancePoolsBySubscriptionId.json - // this example is just showing the usage of "InstancePools_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (InstancePoolResource item in subscriptionResource.GetInstancePoolsAsync()) + bool? expandChildren = true; + await foreach (InstancePoolUsage item in instancePool.GetUsagesAsync(expandChildren: expandChildren)) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InstancePoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {item}"); } Console.WriteLine("Succeeded"); @@ -175,10 +142,10 @@ public async Task GetInstancePools_ListInstancePoolsInTheSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnInstancePool() + public async Task GetUsages_ListInstancePoolUsages() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/GetInstancePool.json - // this example is just showing the usage of "InstancePools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListInstancePoolUsage.json + // this example is just showing the usage of "Usages_ListByInstancePool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,22 +160,21 @@ public async Task Get_GetAnInstancePool() ResourceIdentifier instancePoolResourceId = InstancePoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instancePoolName); InstancePoolResource instancePool = client.GetInstancePoolResource(instancePoolResourceId); - // invoke the operation - InstancePoolResource result = await instancePool.GetAsync(); + // invoke the operation and iterate over the result + await foreach (InstancePoolUsage item in instancePool.GetUsagesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InstancePoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnInstancePool() + public async Task GetManagedInstances_ListManagedInstancesByInstancePool() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/DeleteInstancePool.json - // this example is just showing the usage of "InstancePools_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByInstancePool.json + // this example is just showing the usage of "ManagedInstances_ListByInstancePool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,24 +183,31 @@ public async Task Delete_DeleteAnInstancePool() // this example assumes you already have this InstancePoolResource created on azure // for more information of creating InstancePoolResource, please refer to the document of InstancePoolResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "group1"; - string instancePoolName = "testIP"; + string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; + string resourceGroupName = "Test1"; + string instancePoolName = "pool1"; ResourceIdentifier instancePoolResourceId = InstancePoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instancePoolName); InstancePoolResource instancePool = client.GetInstancePoolResource(instancePoolResourceId); - // invoke the operation - await instancePool.DeleteAsync(WaitUntil.Completed); + // invoke the operation and iterate over the result + await foreach (ManagedInstanceResource item in instancePool.GetManagedInstancesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAnInstancePool() + public async Task GetManagedInstances_ListManagedInstancesByInstancePoolWithExpandAdministratorsActivedirectory() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/PatchInstancePool.json - // this example is just showing the usage of "InstancePools_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByInstancePoolWithExpandEqualsAdministrators.json + // this example is just showing the usage of "ManagedInstances_ListByInstancePool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -243,28 +216,23 @@ public async Task Update_PatchAnInstancePool() // this example assumes you already have this InstancePoolResource created on azure // for more information of creating InstancePoolResource, please refer to the document of InstancePoolResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "group1"; - string instancePoolName = "testIP"; + string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; + string resourceGroupName = "Test1"; + string instancePoolName = "pool1"; ResourceIdentifier instancePoolResourceId = InstancePoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, instancePoolName); InstancePoolResource instancePool = client.GetInstancePoolResource(instancePoolResourceId); - // invoke the operation - InstancePoolPatch patch = new InstancePoolPatch() + // invoke the operation and iterate over the result + await foreach (ManagedInstanceResource item in instancePool.GetManagedInstancesAsync()) { - Tags = -{ -["x"] = "y", -}, - }; - ArmOperation lro = await instancePool.UpdateAsync(WaitUntil.Completed, patch); - InstancePoolResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InstancePoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LedgerDigestUploadCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LedgerDigestUploadCollection.cs index 0146ae61e2d99..2b33005c4c523 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LedgerDigestUploadCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LedgerDigestUploadCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LedgerDigestUploadCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase() + public async Task CreateOrUpdate_EnablesLedgerDigestUploadConfigurationForADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsGet.json - // this example is just showing the usage of "LedgerDigestUploads_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsEnable.json + // this example is just showing the usage of "LedgerDigestUploads_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,12 @@ public async Task Get_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase( // invoke the operation LedgerDigestUploadsName ledgerDigestUploads = LedgerDigestUploadsName.Current; - LedgerDigestUploadResource result = await collection.GetAsync(ledgerDigestUploads); + LedgerDigestUploadData data = new LedgerDigestUploadData + { + DigestStorageEndpoint = "https://MyAccount.blob.core.windows.net", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ledgerDigestUploads, data); + LedgerDigestUploadResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +58,7 @@ public async Task Get_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase( [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase() + public async Task Get_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsGet.json // this example is just showing the usage of "LedgerDigestUploads_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +82,21 @@ public async Task Exists_GetsTheCurrentLedgerDigestUploadConfigurationForADataba // invoke the operation LedgerDigestUploadsName ledgerDigestUploads = LedgerDigestUploadsName.Current; - bool result = await collection.ExistsAsync(ledgerDigestUploads); + LedgerDigestUploadResource result = await collection.GetAsync(ledgerDigestUploads); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LedgerDigestUploadData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase() + public async Task GetAll_GetsListOfLedgerDigestUploadSettingsOnADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsGet.json - // this example is just showing the usage of "LedgerDigestUploads_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsList.json + // this example is just showing the usage of "LedgerDigestUploads_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +115,25 @@ public async Task GetIfExists_GetsTheCurrentLedgerDigestUploadConfigurationForAD // get the collection of this LedgerDigestUploadResource LedgerDigestUploadCollection collection = sqlDatabase.GetLedgerDigestUploads(); - // invoke the operation - LedgerDigestUploadsName ledgerDigestUploads = LedgerDigestUploadsName.Current; - NullableResponse response = await collection.GetIfExistsAsync(ledgerDigestUploads); - LedgerDigestUploadResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (LedgerDigestUploadResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LedgerDigestUploadData resourceData = result.Data; + LedgerDigestUploadData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EnablesLedgerDigestUploadConfigurationForADatabase() + public async Task Exists_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsEnable.json - // this example is just showing the usage of "LedgerDigestUploads_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsGet.json + // this example is just showing the usage of "LedgerDigestUploads_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,26 +154,17 @@ public async Task CreateOrUpdate_EnablesLedgerDigestUploadConfigurationForADatab // invoke the operation LedgerDigestUploadsName ledgerDigestUploads = LedgerDigestUploadsName.Current; - LedgerDigestUploadData data = new LedgerDigestUploadData() - { - DigestStorageEndpoint = "https://MyAccount.blob.core.windows.net", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ledgerDigestUploads, data); - LedgerDigestUploadResource result = lro.Value; + bool result = await collection.ExistsAsync(ledgerDigestUploads); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LedgerDigestUploadData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfLedgerDigestUploadSettingsOnADatabase() + public async Task GetIfExists_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsList.json - // this example is just showing the usage of "LedgerDigestUploads_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/LedgerDigestUploadsGet.json + // this example is just showing the usage of "LedgerDigestUploads_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_GetsListOfLedgerDigestUploadSettingsOnADatabase() // get the collection of this LedgerDigestUploadResource LedgerDigestUploadCollection collection = sqlDatabase.GetLedgerDigestUploads(); - // invoke the operation and iterate over the result - await foreach (LedgerDigestUploadResource item in collection.GetAllAsync()) + // invoke the operation + LedgerDigestUploadsName ledgerDigestUploads = LedgerDigestUploadsName.Current; + NullableResponse response = await collection.GetIfExistsAsync(ledgerDigestUploads); + LedgerDigestUploadResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LedgerDigestUploadData resourceData = item.Data; + LedgerDigestUploadData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LedgerDigestUploadResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LedgerDigestUploadResource.cs index 1dbc30f7deb79..0e340b54d5989 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LedgerDigestUploadResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LedgerDigestUploadResource.cs @@ -71,7 +71,7 @@ public async Task Update_EnablesLedgerDigestUploadConfigurationForADatabase() LedgerDigestUploadResource ledgerDigestUpload = client.GetLedgerDigestUploadResource(ledgerDigestUploadResourceId); // invoke the operation - LedgerDigestUploadData data = new LedgerDigestUploadData() + LedgerDigestUploadData data = new LedgerDigestUploadData { DigestStorageEndpoint = "https://MyAccount.blob.core.windows.net", }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LogicalDatabaseTransparentDataEncryptionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LogicalDatabaseTransparentDataEncryptionCollection.cs index 177d0ebc0b63c..f381fb694cd2f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LogicalDatabaseTransparentDataEncryptionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LogicalDatabaseTransparentDataEncryptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LogicalDatabaseTransparentDataEncryptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfTheDatabaseSTransparentDataEncryption() + public async Task CreateOrUpdate_UpdateADatabaseSTransparentDataEncryptionStateWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionList.json - // this example is just showing the usage of "TransparentDataEncryptions_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionUpdate.json + // this example is just showing the usage of "TransparentDataEncryptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task GetAll_GetAListOfTheDatabaseSTransparentDataEncryption() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "security-tde-resourcegroup"; - string serverName = "securitytde"; + string resourceGroupName = "securitytde-42-rg"; + string serverName = "securitytde-42"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -40,17 +40,20 @@ public async Task GetAll_GetAListOfTheDatabaseSTransparentDataEncryption() // get the collection of this LogicalDatabaseTransparentDataEncryptionResource LogicalDatabaseTransparentDataEncryptionCollection collection = sqlDatabase.GetLogicalDatabaseTransparentDataEncryptions(); - // invoke the operation and iterate over the result - await foreach (LogicalDatabaseTransparentDataEncryptionResource item in collection.GetAllAsync()) + // invoke the operation + TransparentDataEncryptionName tdeName = TransparentDataEncryptionName.Current; + LogicalDatabaseTransparentDataEncryptionData data = new LogicalDatabaseTransparentDataEncryptionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicalDatabaseTransparentDataEncryptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + State = TransparentDataEncryptionState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tdeName, data); + LogicalDatabaseTransparentDataEncryptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicalDatabaseTransparentDataEncryptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +93,10 @@ public async Task Get_GetADatabaseSTransparentDataEncryption() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADatabaseSTransparentDataEncryption() + public async Task GetAll_GetAListOfTheDatabaseSTransparentDataEncryption() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionGet.json - // this example is just showing the usage of "TransparentDataEncryptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionList.json + // this example is just showing the usage of "TransparentDataEncryptions_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +115,22 @@ public async Task Exists_GetADatabaseSTransparentDataEncryption() // get the collection of this LogicalDatabaseTransparentDataEncryptionResource LogicalDatabaseTransparentDataEncryptionCollection collection = sqlDatabase.GetLogicalDatabaseTransparentDataEncryptions(); - // invoke the operation - TransparentDataEncryptionName tdeName = TransparentDataEncryptionName.Current; - bool result = await collection.ExistsAsync(tdeName); + // invoke the operation and iterate over the result + await foreach (LogicalDatabaseTransparentDataEncryptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicalDatabaseTransparentDataEncryptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADatabaseSTransparentDataEncryption() + public async Task Exists_GetADatabaseSTransparentDataEncryption() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionGet.json // this example is just showing the usage of "TransparentDataEncryptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +154,17 @@ public async Task GetIfExists_GetADatabaseSTransparentDataEncryption() // invoke the operation TransparentDataEncryptionName tdeName = TransparentDataEncryptionName.Current; - NullableResponse response = await collection.GetIfExistsAsync(tdeName); - LogicalDatabaseTransparentDataEncryptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tdeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicalDatabaseTransparentDataEncryptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateADatabaseSTransparentDataEncryptionStateWithMinimalParameters() + public async Task GetIfExists_GetADatabaseSTransparentDataEncryption() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionUpdate.json - // this example is just showing the usage of "TransparentDataEncryptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/TransparentDataEncryptionGet.json + // this example is just showing the usage of "TransparentDataEncryptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,8 +174,8 @@ public async Task CreateOrUpdate_UpdateADatabaseSTransparentDataEncryptionStateW // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securitytde-42-rg"; - string serverName = "securitytde-42"; + string resourceGroupName = "security-tde-resourcegroup"; + string serverName = "securitytde"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -188,18 +185,21 @@ public async Task CreateOrUpdate_UpdateADatabaseSTransparentDataEncryptionStateW // invoke the operation TransparentDataEncryptionName tdeName = TransparentDataEncryptionName.Current; - LogicalDatabaseTransparentDataEncryptionData data = new LogicalDatabaseTransparentDataEncryptionData() - { - State = TransparentDataEncryptionState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tdeName, data); - LogicalDatabaseTransparentDataEncryptionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(tdeName); + LogicalDatabaseTransparentDataEncryptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicalDatabaseTransparentDataEncryptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicalDatabaseTransparentDataEncryptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LogicalDatabaseTransparentDataEncryptionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LogicalDatabaseTransparentDataEncryptionResource.cs index 57b0e286f8f18..94810a6556dc4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LogicalDatabaseTransparentDataEncryptionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LogicalDatabaseTransparentDataEncryptionResource.cs @@ -71,7 +71,7 @@ public async Task Update_UpdateADatabaseSTransparentDataEncryptionStateWithMinim LogicalDatabaseTransparentDataEncryptionResource logicalDatabaseTransparentDataEncryption = client.GetLogicalDatabaseTransparentDataEncryptionResource(logicalDatabaseTransparentDataEncryptionResourceId); // invoke the operation - LogicalDatabaseTransparentDataEncryptionData data = new LogicalDatabaseTransparentDataEncryptionData() + LogicalDatabaseTransparentDataEncryptionData data = new LogicalDatabaseTransparentDataEncryptionData { State = TransparentDataEncryptionState.Enabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LongTermRetentionPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LongTermRetentionPolicyCollection.cs index 19d5eaca5a17d..fdfb10c22b2a2 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LongTermRetentionPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LongTermRetentionPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LongTermRetentionPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheLongTermRetentionPolicyForTheDatabase() + public async Task CreateOrUpdate_CreateOrUpdateTheLongTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionPolicyListByDatabase.json - // this example is just showing the usage of "LongTermRetentionPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionPolicyCreateOrUpdate.json + // this example is just showing the usage of "LongTermRetentionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,25 @@ public async Task GetAll_GetTheLongTermRetentionPolicyForTheDatabase() // get the collection of this LongTermRetentionPolicyResource LongTermRetentionPolicyCollection collection = sqlDatabase.GetLongTermRetentionPolicies(); - // invoke the operation and iterate over the result - await foreach (LongTermRetentionPolicyResource item in collection.GetAllAsync()) + // invoke the operation + LongTermRetentionPolicyName policyName = LongTermRetentionPolicyName.Default; + LongTermRetentionPolicyData data = new LongTermRetentionPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LongTermRetentionPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + MakeBackupsImmutable = true, + BackupStorageAccessTier = SqlBackupStorageAccessTier.Hot, + WeeklyRetention = "P1M", + MonthlyRetention = "P1Y", + YearlyRetention = "P5Y", + WeekOfYear = 5, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + LongTermRetentionPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LongTermRetentionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +98,10 @@ public async Task Get_GetTheLongTermRetentionPolicyForTheDatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheLongTermRetentionPolicyForTheDatabase() + public async Task GetAll_GetTheLongTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionPolicyGet.json - // this example is just showing the usage of "LongTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionPolicyListByDatabase.json + // this example is just showing the usage of "LongTermRetentionPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +120,22 @@ public async Task Exists_GetTheLongTermRetentionPolicyForTheDatabase() // get the collection of this LongTermRetentionPolicyResource LongTermRetentionPolicyCollection collection = sqlDatabase.GetLongTermRetentionPolicies(); - // invoke the operation - LongTermRetentionPolicyName policyName = LongTermRetentionPolicyName.Default; - bool result = await collection.ExistsAsync(policyName); + // invoke the operation and iterate over the result + await foreach (LongTermRetentionPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LongTermRetentionPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheLongTermRetentionPolicyForTheDatabase() + public async Task Exists_GetTheLongTermRetentionPolicyForTheDatabase() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionPolicyGet.json // this example is just showing the usage of "LongTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +159,17 @@ public async Task GetIfExists_GetTheLongTermRetentionPolicyForTheDatabase() // invoke the operation LongTermRetentionPolicyName policyName = LongTermRetentionPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - LongTermRetentionPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LongTermRetentionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateTheLongTermRetentionPolicyForTheDatabase() + public async Task GetIfExists_GetTheLongTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionPolicyCreateOrUpdate.json - // this example is just showing the usage of "LongTermRetentionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionPolicyGet.json + // this example is just showing the usage of "LongTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,23 +190,21 @@ public async Task CreateOrUpdate_CreateOrUpdateTheLongTermRetentionPolicyForTheD // invoke the operation LongTermRetentionPolicyName policyName = LongTermRetentionPolicyName.Default; - LongTermRetentionPolicyData data = new LongTermRetentionPolicyData() - { - MakeBackupsImmutable = true, - BackupStorageAccessTier = SqlBackupStorageAccessTier.Hot, - WeeklyRetention = "P1M", - MonthlyRetention = "P1Y", - YearlyRetention = "P5Y", - WeekOfYear = 5, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - LongTermRetentionPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + LongTermRetentionPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LongTermRetentionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LongTermRetentionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LongTermRetentionPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LongTermRetentionPolicyResource.cs index cc004184e7cfc..559efa44405f2 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LongTermRetentionPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_LongTermRetentionPolicyResource.cs @@ -71,7 +71,7 @@ public async Task Update_CreateOrUpdateTheLongTermRetentionPolicyForTheDatabase( LongTermRetentionPolicyResource longTermRetentionPolicy = client.GetLongTermRetentionPolicyResource(longTermRetentionPolicyResourceId); // invoke the operation - LongTermRetentionPolicyData data = new LongTermRetentionPolicyData() + LongTermRetentionPolicyData data = new LongTermRetentionPolicyData { MakeBackupsImmutable = true, BackupStorageAccessTier = SqlBackupStorageAccessTier.Hot, diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_MaintenanceWindowsResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_MaintenanceWindowsResource.cs index 218a552987939..73898b9d5caff 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_MaintenanceWindowsResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_MaintenanceWindowsResource.cs @@ -72,17 +72,14 @@ public async Task CreateOrUpdate_SetsMaintenanceWindowSettingsForASelectedDataba // invoke the operation string maintenanceWindowName = "current"; - MaintenanceWindowsData data = new MaintenanceWindowsData() + MaintenanceWindowsData data = new MaintenanceWindowsData { - TimeRanges = -{ -new MaintenanceWindowTimeRange() + TimeRanges = {new MaintenanceWindowTimeRange { DayOfWeek = SqlDayOfWeek.Saturday, StartTime = "00:00:00", Duration = XmlConvert.ToTimeSpan("PT60M"), -} -}, +}}, }; await maintenanceWindows.CreateOrUpdateAsync(WaitUntil.Completed, maintenanceWindowName, data); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedBackupShortTermRetentionPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedBackupShortTermRetentionPolicyCollection.cs index 7e7b6b4081e1a..38209f9701763 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedBackupShortTermRetentionPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedBackupShortTermRetentionPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedBackupShortTermRetentionPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() + public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicy.json - // this example is just showing the usage of "ManagedBackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/UpdateManagedShortTermRetentionPolicy.json + // this example is just showing the usage of "ManagedBackupShortTermRetentionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; + string resourceGroupName = "resourceGroup"; string managedInstanceName = "testsvr"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); @@ -42,7 +42,12 @@ public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() // invoke the operation ManagedShortTermRetentionPolicyName policyName = ManagedShortTermRetentionPolicyName.Default; - ManagedBackupShortTermRetentionPolicyResource result = await collection.GetAsync(policyName); + ManagedBackupShortTermRetentionPolicyData data = new ManagedBackupShortTermRetentionPolicyData + { + RetentionDays = 14, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + ManagedBackupShortTermRetentionPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +58,7 @@ public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheShortTermRetentionPolicyForTheDatabase() + public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicy.json // this example is just showing the usage of "ManagedBackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +82,21 @@ public async Task Exists_GetTheShortTermRetentionPolicyForTheDatabase() // invoke the operation ManagedShortTermRetentionPolicyName policyName = ManagedShortTermRetentionPolicyName.Default; - bool result = await collection.ExistsAsync(policyName); + ManagedBackupShortTermRetentionPolicyResource result = await collection.GetAsync(policyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedBackupShortTermRetentionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheShortTermRetentionPolicyForTheDatabase() + public async Task GetAll_GetTheShortTermRetentionPolicyListForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicy.json - // this example is just showing the usage of "ManagedBackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetListManagedShortTermRetentionPolicy.json + // this example is just showing the usage of "ManagedBackupShortTermRetentionPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +115,25 @@ public async Task GetIfExists_GetTheShortTermRetentionPolicyForTheDatabase() // get the collection of this ManagedBackupShortTermRetentionPolicyResource ManagedBackupShortTermRetentionPolicyCollection collection = managedDatabase.GetManagedBackupShortTermRetentionPolicies(); - // invoke the operation - ManagedShortTermRetentionPolicyName policyName = ManagedShortTermRetentionPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - ManagedBackupShortTermRetentionPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedBackupShortTermRetentionPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedBackupShortTermRetentionPolicyData resourceData = result.Data; + ManagedBackupShortTermRetentionPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheDatabase() + public async Task Exists_GetTheShortTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/UpdateManagedShortTermRetentionPolicy.json - // this example is just showing the usage of "ManagedBackupShortTermRetentionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicy.json + // this example is just showing the usage of "ManagedBackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,7 +143,7 @@ public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheDatabase // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "resourceGroup"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; string managedInstanceName = "testsvr"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); @@ -151,26 +154,17 @@ public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheDatabase // invoke the operation ManagedShortTermRetentionPolicyName policyName = ManagedShortTermRetentionPolicyName.Default; - ManagedBackupShortTermRetentionPolicyData data = new ManagedBackupShortTermRetentionPolicyData() - { - RetentionDays = 14, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - ManagedBackupShortTermRetentionPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(policyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedBackupShortTermRetentionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheShortTermRetentionPolicyListForTheDatabase() + public async Task GetIfExists_GetTheShortTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetListManagedShortTermRetentionPolicy.json - // this example is just showing the usage of "ManagedBackupShortTermRetentionPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicy.json + // this example is just showing the usage of "ManagedBackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_GetTheShortTermRetentionPolicyListForTheDatabase() // get the collection of this ManagedBackupShortTermRetentionPolicyResource ManagedBackupShortTermRetentionPolicyCollection collection = managedDatabase.GetManagedBackupShortTermRetentionPolicies(); - // invoke the operation and iterate over the result - await foreach (ManagedBackupShortTermRetentionPolicyResource item in collection.GetAllAsync()) + // invoke the operation + ManagedShortTermRetentionPolicyName policyName = ManagedShortTermRetentionPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + ManagedBackupShortTermRetentionPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedBackupShortTermRetentionPolicyData resourceData = item.Data; + ManagedBackupShortTermRetentionPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedBackupShortTermRetentionPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedBackupShortTermRetentionPolicyResource.cs index 756deed0b16b1..acff4aab4f704 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedBackupShortTermRetentionPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedBackupShortTermRetentionPolicyResource.cs @@ -71,7 +71,7 @@ public async Task Update_UpdateTheShortTermRetentionPolicyForTheDatabase() ManagedBackupShortTermRetentionPolicyResource managedBackupShortTermRetentionPolicy = client.GetManagedBackupShortTermRetentionPolicyResource(managedBackupShortTermRetentionPolicyResourceId); // invoke the operation - ManagedBackupShortTermRetentionPolicyData data = new ManagedBackupShortTermRetentionPolicyData() + ManagedBackupShortTermRetentionPolicyData data = new ManagedBackupShortTermRetentionPolicyData { RetentionDays = 14, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseAdvancedThreatProtectionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseAdvancedThreatProtectionCollection.cs index 2666bd7f3ef1d..a0e793ffeb8f0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseAdvancedThreatProtectionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseAdvancedThreatProtectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedDatabaseAdvancedThreatProtectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfTheManagedDatabaseSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_UpdateAManagedDatabaseSAdvancedThreatProtectionSettingsWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsListByDatabase.json - // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsCreateMax.json + // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task GetAll_GetAListOfTheManagedDatabaseSAdvancedThreatProtectionSe // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-6852"; - string managedInstanceName = "threatprotection-2080"; + string resourceGroupName = "threatprotection-4799"; + string managedInstanceName = "threatprotection-6440"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); @@ -40,25 +40,28 @@ public async Task GetAll_GetAListOfTheManagedDatabaseSAdvancedThreatProtectionSe // get the collection of this ManagedDatabaseAdvancedThreatProtectionResource ManagedDatabaseAdvancedThreatProtectionCollection collection = managedDatabase.GetManagedDatabaseAdvancedThreatProtections(); - // invoke the operation and iterate over the result - await foreach (ManagedDatabaseAdvancedThreatProtectionResource item in collection.GetAllAsync()) + // invoke the operation + AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; + ManagedDatabaseAdvancedThreatProtectionData data = new ManagedDatabaseAdvancedThreatProtectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseAdvancedThreatProtectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + State = AdvancedThreatProtectionState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); + ManagedDatabaseAdvancedThreatProtectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAManagedDatabaseSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_UpdateAManagedDatabaseSAdvancedThreatProtectionSettingsWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsGet.json - // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsCreateMin.json + // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,8 +71,8 @@ public async Task Get_GetAManagedDatabaseSAdvancedThreatProtectionSettings() // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-6852"; - string managedInstanceName = "threatprotection-2080"; + string resourceGroupName = "threatprotection-4799"; + string managedInstanceName = "threatprotection-6440"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); @@ -79,7 +82,12 @@ public async Task Get_GetAManagedDatabaseSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - ManagedDatabaseAdvancedThreatProtectionResource result = await collection.GetAsync(advancedThreatProtectionName); + ManagedDatabaseAdvancedThreatProtectionData data = new ManagedDatabaseAdvancedThreatProtectionData + { + State = AdvancedThreatProtectionState.Disabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); + ManagedDatabaseAdvancedThreatProtectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,7 +98,7 @@ public async Task Get_GetAManagedDatabaseSAdvancedThreatProtectionSettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAManagedDatabaseSAdvancedThreatProtectionSettings() + public async Task Get_GetAManagedDatabaseSAdvancedThreatProtectionSettings() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsGet.json // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -114,17 +122,21 @@ public async Task Exists_GetAManagedDatabaseSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - bool result = await collection.ExistsAsync(advancedThreatProtectionName); + ManagedDatabaseAdvancedThreatProtectionResource result = await collection.GetAsync(advancedThreatProtectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAManagedDatabaseSAdvancedThreatProtectionSettings() + public async Task GetAll_GetAListOfTheManagedDatabaseSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsGet.json - // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsListByDatabase.json + // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +155,25 @@ public async Task GetIfExists_GetAManagedDatabaseSAdvancedThreatProtectionSettin // get the collection of this ManagedDatabaseAdvancedThreatProtectionResource ManagedDatabaseAdvancedThreatProtectionCollection collection = managedDatabase.GetManagedDatabaseAdvancedThreatProtections(); - // invoke the operation - AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - NullableResponse response = await collection.GetIfExistsAsync(advancedThreatProtectionName); - ManagedDatabaseAdvancedThreatProtectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedDatabaseAdvancedThreatProtectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedDatabaseAdvancedThreatProtectionData resourceData = result.Data; + ManagedDatabaseAdvancedThreatProtectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAManagedDatabaseSAdvancedThreatProtectionSettingsWithAllParameters() + public async Task Exists_GetAManagedDatabaseSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsCreateMax.json - // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsGet.json + // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,8 +183,8 @@ public async Task CreateOrUpdate_UpdateAManagedDatabaseSAdvancedThreatProtection // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-4799"; - string managedInstanceName = "threatprotection-6440"; + string resourceGroupName = "threatprotection-6852"; + string managedInstanceName = "threatprotection-2080"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); @@ -188,26 +194,17 @@ public async Task CreateOrUpdate_UpdateAManagedDatabaseSAdvancedThreatProtection // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - ManagedDatabaseAdvancedThreatProtectionData data = new ManagedDatabaseAdvancedThreatProtectionData() - { - State = AdvancedThreatProtectionState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); - ManagedDatabaseAdvancedThreatProtectionResource result = lro.Value; + bool result = await collection.ExistsAsync(advancedThreatProtectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseAdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAManagedDatabaseSAdvancedThreatProtectionSettingsWithMinimalParameters() + public async Task GetIfExists_GetAManagedDatabaseSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsCreateMin.json - // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedDatabaseAdvancedThreatProtectionSettingsGet.json + // this example is just showing the usage of "ManagedDatabaseAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,8 +214,8 @@ public async Task CreateOrUpdate_UpdateAManagedDatabaseSAdvancedThreatProtection // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-4799"; - string managedInstanceName = "threatprotection-6440"; + string resourceGroupName = "threatprotection-6852"; + string managedInstanceName = "threatprotection-2080"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); @@ -228,18 +225,21 @@ public async Task CreateOrUpdate_UpdateAManagedDatabaseSAdvancedThreatProtection // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - ManagedDatabaseAdvancedThreatProtectionData data = new ManagedDatabaseAdvancedThreatProtectionData() - { - State = AdvancedThreatProtectionState.Disabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); - ManagedDatabaseAdvancedThreatProtectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(advancedThreatProtectionName); + ManagedDatabaseAdvancedThreatProtectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseAdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseAdvancedThreatProtectionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseAdvancedThreatProtectionResource.cs index 5780d6ea0056f..a0e83b48d5cbe 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseAdvancedThreatProtectionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseAdvancedThreatProtectionResource.cs @@ -71,7 +71,7 @@ public async Task Update_UpdateAManagedDatabaseSAdvancedThreatProtectionSettings ManagedDatabaseAdvancedThreatProtectionResource managedDatabaseAdvancedThreatProtection = client.GetManagedDatabaseAdvancedThreatProtectionResource(managedDatabaseAdvancedThreatProtectionResourceId); // invoke the operation - ManagedDatabaseAdvancedThreatProtectionData data = new ManagedDatabaseAdvancedThreatProtectionData() + ManagedDatabaseAdvancedThreatProtectionData data = new ManagedDatabaseAdvancedThreatProtectionData { State = AdvancedThreatProtectionState.Enabled, }; @@ -108,7 +108,7 @@ public async Task Update_UpdateAManagedDatabaseSAdvancedThreatProtectionSettings ManagedDatabaseAdvancedThreatProtectionResource managedDatabaseAdvancedThreatProtection = client.GetManagedDatabaseAdvancedThreatProtectionResource(managedDatabaseAdvancedThreatProtectionResourceId); // invoke the operation - ManagedDatabaseAdvancedThreatProtectionData data = new ManagedDatabaseAdvancedThreatProtectionData() + ManagedDatabaseAdvancedThreatProtectionData data = new ManagedDatabaseAdvancedThreatProtectionData { State = AdvancedThreatProtectionState.Disabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseCollection.cs index 3968f96d4a6a1..24737c7078e86 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDatabasesByManagedInstances() + public async Task CreateOrUpdate_CreatesANewManagedDatabaseByRestoringFromAnExternalBackup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseListByManagedInstance.json - // this example is just showing the usage of "ManagedDatabases_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRestoreExternalBackup.json + // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_ListDatabasesByManagedInstances() // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Test1"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; string managedInstanceName = "managedInstance"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); @@ -39,25 +39,33 @@ public async Task GetAll_ListDatabasesByManagedInstances() // get the collection of this ManagedDatabaseResource ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases(); - // invoke the operation and iterate over the result - await foreach (ManagedDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "managedDatabase"; + ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Collation = "SQL_Latin1_General_CP1_CI_AS", + CreateMode = ManagedDatabaseCreateMode.RestoreExternalBackup, + StorageContainerUri = new Uri("https://myaccountname.blob.core.windows.net/backups"), + StorageContainerSasToken = "sv=2015-12-11&sr=c&sp=rl&sig=1234", + AllowAutoCompleteRestore = true, + LastBackupName = "last_backup_name", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + ManagedDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAManagedDatabase() + public async Task CreateOrUpdate_CreatesANewManagedDatabaseByRestoringFromAnExternalBackupUsingManagedIdentity() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseGet.json - // this example is just showing the usage of "ManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRestoreExternalBackupManagedIdentity.json + // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,7 +75,7 @@ public async Task Get_GetsAManagedDatabase() // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Test1"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; string managedInstanceName = "managedInstance"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); @@ -77,7 +85,17 @@ public async Task Get_GetsAManagedDatabase() // invoke the operation string databaseName = "managedDatabase"; - ManagedDatabaseResource result = await collection.GetAsync(databaseName); + ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) + { + Collation = "SQL_Latin1_General_CP1_CI_AS", + CreateMode = ManagedDatabaseCreateMode.RestoreExternalBackup, + StorageContainerUri = new Uri("https://myaccountname.blob.core.windows.net/backups"), + StorageContainerIdentity = "ManagedIdentity", + AllowAutoCompleteRestore = true, + LastBackupName = "last_backup_name", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + ManagedDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +106,10 @@ public async Task Get_GetsAManagedDatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAManagedDatabase() + public async Task CreateOrUpdate_CreatesANewManagedDatabaseFromRestoringAGeoReplicatedBackup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseGet.json - // this example is just showing the usage of "ManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRecovery.json + // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,8 +119,8 @@ public async Task Exists_GetsAManagedDatabase() // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Test1"; - string managedInstanceName = "managedInstance"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string managedInstanceName = "server1"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); @@ -110,18 +128,28 @@ public async Task Exists_GetsAManagedDatabase() ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases(); // invoke the operation - string databaseName = "managedDatabase"; - bool result = await collection.ExistsAsync(databaseName); + string databaseName = "testdb_recovered"; + ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) + { + CreateMode = ManagedDatabaseCreateMode.Recovery, + RecoverableDatabaseId = new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-WestEurope/providers/Microsoft.Sql/managedInstances/testsvr/recoverableDatabases/testdb"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + ManagedDatabaseResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAManagedDatabase() + public async Task CreateOrUpdate_CreatesANewManagedDatabaseFromRestoringALongTermRetentionBackup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseGet.json - // this example is just showing the usage of "ManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRestoreLtrBackup.json + // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,7 +159,7 @@ public async Task GetIfExists_GetsAManagedDatabase() // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Test1"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; string managedInstanceName = "managedInstance"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); @@ -141,28 +169,28 @@ public async Task GetIfExists_GetsAManagedDatabase() // invoke the operation string databaseName = "managedDatabase"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - ManagedDatabaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Collation = "SQL_Latin1_General_CP1_CI_AS", + CreateMode = ManagedDatabaseCreateMode.RestoreExternalBackup, + StorageContainerUri = new Uri("https://myaccountname.blob.core.windows.net/backups"), + StorageContainerSasToken = "sv=2015-12-11&sr=c&sp=rl&sig=1234", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + ManagedDatabaseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesANewManagedDatabaseByRestoringFromAnExternalBackup() + public async Task CreateOrUpdate_CreatesANewManagedDatabaseUsingCrossSubscriptionPointInTimeRestore() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRestoreExternalBackup.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateCrossSubscriptionPointInTimeRestore.json // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -185,12 +213,10 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseByRestoringFromAnExte string databaseName = "managedDatabase"; ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) { - Collation = "SQL_Latin1_General_CP1_CI_AS", - CreateMode = ManagedDatabaseCreateMode.RestoreExternalBackup, - StorageContainerUri = new Uri("https://myaccountname.blob.core.windows.net/backups"), - StorageContainerSasToken = "sv=2015-12-11&sr=c&sp=rl&sig=1234", - AllowAutoCompleteRestore = true, - LastBackupName = "last_backup_name", + RestorePointInTime = DateTimeOffset.Parse("2017-07-14T05:35:31.503Z"), + CreateMode = ManagedDatabaseCreateMode.PointInTimeRestore, + CrossSubscriptionSourceDatabaseId = new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr2/databases/testdb"), + CrossSubscriptionTargetManagedInstanceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); ManagedDatabaseResource result = lro.Value; @@ -204,9 +230,9 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseByRestoringFromAnExte [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesANewManagedDatabaseByRestoringFromAnExternalBackupUsingManagedIdentity() + public async Task CreateOrUpdate_CreatesANewManagedDatabaseUsingPointInTimeRestore() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRestoreExternalBackupManagedIdentity.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreatePointInTimeRestore.json // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -229,12 +255,9 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseByRestoringFromAnExte string databaseName = "managedDatabase"; ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) { - Collation = "SQL_Latin1_General_CP1_CI_AS", - CreateMode = ManagedDatabaseCreateMode.RestoreExternalBackup, - StorageContainerUri = new Uri("https://myaccountname.blob.core.windows.net/backups"), - StorageContainerIdentity = "ManagedIdentity", - AllowAutoCompleteRestore = true, - LastBackupName = "last_backup_name", + RestorePointInTime = DateTimeOffset.Parse("2017-07-14T05:35:31.503Z"), + CreateMode = ManagedDatabaseCreateMode.PointInTimeRestore, + SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); ManagedDatabaseResource result = lro.Value; @@ -248,9 +271,9 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseByRestoringFromAnExte [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesANewManagedDatabaseFromRestoringAGeoReplicatedBackup() + public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithLedgerOn() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRecovery.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateManagedDatabaseLedger.json // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -262,7 +285,7 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseFromRestoringAGeoRepl // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default-SQL-SouthEastAsia"; - string managedInstanceName = "server1"; + string managedInstanceName = "managedInstance"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); @@ -270,11 +293,10 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseFromRestoringAGeoRepl ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases(); // invoke the operation - string databaseName = "testdb_recovered"; + string databaseName = "managedDatabase"; ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) { - CreateMode = ManagedDatabaseCreateMode.Recovery, - RecoverableDatabaseId = new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-WestEurope/providers/Microsoft.Sql/managedInstances/testsvr/recoverableDatabases/testdb"), + IsLedgerOn = true, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); ManagedDatabaseResource result = lro.Value; @@ -288,9 +310,9 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseFromRestoringAGeoRepl [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesANewManagedDatabaseFromRestoringALongTermRetentionBackup() + public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithMaximalProperties() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateRestoreLtrBackup.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateMax.json // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -313,10 +335,10 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseFromRestoringALongTer string databaseName = "managedDatabase"; ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) { - Collation = "SQL_Latin1_General_CP1_CI_AS", - CreateMode = ManagedDatabaseCreateMode.RestoreExternalBackup, - StorageContainerUri = new Uri("https://myaccountname.blob.core.windows.net/backups"), - StorageContainerSasToken = "sv=2015-12-11&sr=c&sp=rl&sig=1234", + Tags = +{ +["tagKey1"] = "TagValue1" +}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); ManagedDatabaseResource result = lro.Value; @@ -330,9 +352,9 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseFromRestoringALongTer [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesANewManagedDatabaseUsingCrossSubscriptionPointInTimeRestore() + public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithMinimalProperties() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateCrossSubscriptionPointInTimeRestore.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateMin.json // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -353,13 +375,7 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseUsingCrossSubscriptio // invoke the operation string databaseName = "managedDatabase"; - ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) - { - RestorePointInTime = DateTimeOffset.Parse("2017-07-14T05:35:31.503Z"), - CreateMode = ManagedDatabaseCreateMode.PointInTimeRestore, - CrossSubscriptionSourceDatabaseId = new ResourceIdentifier("/subscriptions/11111111-2222-3333-4444-555555555555/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr2/databases/testdb"), - CrossSubscriptionTargetManagedInstanceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr"), - }; + ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); ManagedDatabaseResource result = lro.Value; @@ -372,10 +388,10 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseUsingCrossSubscriptio [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesANewManagedDatabaseUsingPointInTimeRestore() + public async Task Get_GetsAManagedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreatePointInTimeRestore.json - // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseGet.json + // this example is just showing the usage of "ManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -385,7 +401,7 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseUsingPointInTimeResto // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; + string resourceGroupName = "Test1"; string managedInstanceName = "managedInstance"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); @@ -395,14 +411,7 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseUsingPointInTimeResto // invoke the operation string databaseName = "managedDatabase"; - ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) - { - RestorePointInTime = DateTimeOffset.Parse("2017-07-14T05:35:31.503Z"), - CreateMode = ManagedDatabaseCreateMode.PointInTimeRestore, - SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/managedInstances/testsvr/databases/testdb"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - ManagedDatabaseResource result = lro.Value; + ManagedDatabaseResource result = await collection.GetAsync(databaseName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -413,10 +422,10 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseUsingPointInTimeResto [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithLedgerOn() + public async Task GetAll_ListDatabasesByManagedInstances() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/CreateManagedDatabaseLedger.json - // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseListByManagedInstance.json + // this example is just showing the usage of "ManagedDatabases_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -426,7 +435,7 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithLedgerOn() // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; + string resourceGroupName = "Test1"; string managedInstanceName = "managedInstance"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); @@ -434,28 +443,25 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithLedgerOn() // get the collection of this ManagedDatabaseResource ManagedDatabaseCollection collection = managedInstance.GetManagedDatabases(); - // invoke the operation - string databaseName = "managedDatabase"; - ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) + // invoke the operation and iterate over the result + await foreach (ManagedDatabaseResource item in collection.GetAllAsync()) { - IsLedgerOn = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - ManagedDatabaseResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithMaximalProperties() + public async Task Exists_GetsAManagedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateMax.json - // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseGet.json + // this example is just showing the usage of "ManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -465,7 +471,7 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithMaximalProperties // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; + string resourceGroupName = "Test1"; string managedInstanceName = "managedInstance"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); @@ -475,29 +481,17 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithMaximalProperties // invoke the operation string databaseName = "managedDatabase"; - ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")) - { - Tags = -{ -["tagKey1"] = "TagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - ManagedDatabaseResource result = lro.Value; + bool result = await collection.ExistsAsync(databaseName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithMinimalProperties() + public async Task GetIfExists_GetsAManagedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseCreateMin.json - // this example is just showing the usage of "ManagedDatabases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseGet.json + // this example is just showing the usage of "ManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -507,7 +501,7 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithMinimalProperties // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; + string resourceGroupName = "Test1"; string managedInstanceName = "managedInstance"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); @@ -517,15 +511,21 @@ public async Task CreateOrUpdate_CreatesANewManagedDatabaseWithMinimalProperties // invoke the operation string databaseName = "managedDatabase"; - ManagedDatabaseData data = new ManagedDatabaseData(new AzureLocation("southeastasia")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - ManagedDatabaseResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + ManagedDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseColumnCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseColumnCollection.cs index c9716d4f3376c..15e7bc4856beb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseColumnCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseColumnCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ManagedDatabaseColumnCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedDatabaseColumns() + public async Task Get_GetManagedDatabaseColumn() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseColumnListByTable.json - // this example is just showing the usage of "ManagedDatabaseColumns_ListByTable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseColumnGet.json + // this example is just showing the usage of "ManagedDatabaseColumns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_ListManagedDatabaseColumns() // get the collection of this ManagedDatabaseColumnResource ManagedDatabaseColumnCollection collection = managedDatabaseTable.GetManagedDatabaseColumns(); - // invoke the operation and iterate over the result - await foreach (ManagedDatabaseColumnResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseColumnData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string columnName = "column1"; + ManagedDatabaseColumnResource result = await collection.GetAsync(columnName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseColumnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedDatabaseColumn() + public async Task GetAll_ListManagedDatabaseColumns() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseColumnGet.json - // this example is just showing the usage of "ManagedDatabaseColumns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseColumnListByTable.json + // this example is just showing the usage of "ManagedDatabaseColumns_ListByTable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +78,17 @@ public async Task Get_GetManagedDatabaseColumn() // get the collection of this ManagedDatabaseColumnResource ManagedDatabaseColumnCollection collection = managedDatabaseTable.GetManagedDatabaseColumns(); - // invoke the operation - string columnName = "column1"; - ManagedDatabaseColumnResource result = await collection.GetAsync(columnName); + // invoke the operation and iterate over the result + await foreach (ManagedDatabaseColumnResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseColumnData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseColumnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseResource.cs index 7ab6fed529ee3..5a57fb66230b5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseResource.cs @@ -17,6 +17,142 @@ namespace Azure.ResourceManager.Sql.Samples { public partial class Sample_ManagedDatabaseResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetsAManagedDatabase() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseGet.json + // this example is just showing the usage of "ManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedDatabaseResource created on azure + // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Test1"; + string managedInstanceName = "managedInstance"; + string databaseName = "managedDatabase"; + ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); + ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); + + // invoke the operation + ManagedDatabaseResource result = await managedDatabase.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteManagedDatabase() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseDelete.json + // this example is just showing the usage of "ManagedDatabases_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedDatabaseResource created on azure + // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string managedInstanceName = "managedInstance"; + string databaseName = "testdb"; + ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); + ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); + + // invoke the operation + await managedDatabase.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_UpdatesAManagedDatabaseWithMaximalProperties() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseUpdateMax.json + // this example is just showing the usage of "ManagedDatabases_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedDatabaseResource created on azure + // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string managedInstanceName = "managedInstance"; + string databaseName = "testdb"; + ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); + ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); + + // invoke the operation + ManagedDatabasePatch patch = new ManagedDatabasePatch + { + Tags = +{ +["tagKey1"] = "TagValue1" +}, + }; + ArmOperation lro = await managedDatabase.UpdateAsync(WaitUntil.Completed, patch); + ManagedDatabaseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_UpdatesAManagedDatabaseWithMinimalProperties() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseUpdateMin.json + // this example is just showing the usage of "ManagedDatabases_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedDatabaseResource created on azure + // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string managedInstanceName = "managedInstance"; + string databaseName = "testdb"; + ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); + ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); + + // invoke the operation + ManagedDatabasePatch patch = new ManagedDatabasePatch + { + Tags = +{ +["tagKey1"] = "TagValue1" +}, + }; + ArmOperation lro = await managedDatabase.UpdateAsync(WaitUntil.Completed, patch); + ManagedDatabaseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetManagedDatabaseColumnsByDatabase_FilterManagedDatabaseColumns() @@ -39,22 +175,10 @@ public async Task GetManagedDatabaseColumnsByDatabase_FilterManagedDatabaseColum ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); // invoke the operation and iterate over the result - IEnumerable schema = new string[] - { -"dbo" - }; - IEnumerable table = new string[] - { -"customer","address" - }; - IEnumerable column = new string[] - { -"username" - }; - IEnumerable orderBy = new string[] - { -"schema asc","table","column desc" - }; + IEnumerable schema = new string[] { "dbo" }; + IEnumerable table = new string[] { "customer", "address" }; + IEnumerable column = new string[] { "username" }; + IEnumerable orderBy = new string[] { "schema asc", "table", "column desc" }; await foreach (ManagedDatabaseColumnResource item in managedDatabase.GetManagedDatabaseColumnsByDatabaseAsync(schema: schema, table: table, column: column, orderBy: orderBy)) { // the variable item is a resource, you could call other operations on this instance as well @@ -346,44 +470,41 @@ public async Task UpdateManagedDatabaseSensitivityLabel_UpdateSensitivityLabelsO ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); // invoke the operation - SensitivityLabelUpdateList sensitivityLabelUpdateList = new SensitivityLabelUpdateList() + SensitivityLabelUpdateList sensitivityLabelUpdateList = new SensitivityLabelUpdateList { - Operations = -{ -new SensitivityLabelUpdate() + Operations = {new SensitivityLabelUpdate { Op = SensitivityLabelUpdateKind.Set, Schema = "dbo", Table = "table1", Column = "column1", -SensitivityLabel = new SensitivityLabelData() +SensitivityLabel = new SensitivityLabelData { LabelName = "Highly Confidential", LabelId = "3A477B16-9423-432B-AA97-6069B481CEC3", InformationType = "Financial", InformationTypeId = "1D3652D6-422C-4115-82F1-65DAEBC665C8", }, -},new SensitivityLabelUpdate() +}, new SensitivityLabelUpdate { Op = SensitivityLabelUpdateKind.Set, Schema = "dbo", Table = "table2", Column = "column2", -SensitivityLabel = new SensitivityLabelData() +SensitivityLabel = new SensitivityLabelData { LabelName = "PII", LabelId = "bf91e08c-f4f0-478a-b016-25164b2a65ff", InformationType = "PhoneNumber", InformationTypeId = "d22fa6e9-5ee4-3bde-4c2b-a409604c4646", }, -},new SensitivityLabelUpdate() +}, new SensitivityLabelUpdate { Op = SensitivityLabelUpdateKind.Remove, Schema = "dbo", Table = "Table1", Column = "Column3", -} -}, +}}, }; await managedDatabase.UpdateManagedDatabaseSensitivityLabelAsync(sensitivityLabelUpdateList); @@ -446,172 +567,33 @@ public async Task UpdateRecommendedManagedDatabaseSensitivityLabel_UpdateRecomme ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); // invoke the operation - RecommendedSensitivityLabelUpdateList recommendedSensitivityLabelUpdateList = new RecommendedSensitivityLabelUpdateList() + RecommendedSensitivityLabelUpdateList recommendedSensitivityLabelUpdateList = new RecommendedSensitivityLabelUpdateList { - Operations = -{ -new RecommendedSensitivityLabelUpdate() + Operations = {new RecommendedSensitivityLabelUpdate { Op = RecommendedSensitivityLabelUpdateKind.Enable, Schema = "dbo", Table = "table1", Column = "column1", -},new RecommendedSensitivityLabelUpdate() +}, new RecommendedSensitivityLabelUpdate { Op = RecommendedSensitivityLabelUpdateKind.Disable, Schema = "dbo", Table = "table2", Column = "column2", -},new RecommendedSensitivityLabelUpdate() +}, new RecommendedSensitivityLabelUpdate { Op = RecommendedSensitivityLabelUpdateKind.Disable, Schema = "dbo", Table = "Table1", Column = "Column3", -} -}, +}}, }; await managedDatabase.UpdateRecommendedManagedDatabaseSensitivityLabelAsync(recommendedSensitivityLabelUpdateList); Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAManagedDatabase() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseGet.json - // this example is just showing the usage of "ManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedDatabaseResource created on azure - // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Test1"; - string managedInstanceName = "managedInstance"; - string databaseName = "managedDatabase"; - ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); - ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); - - // invoke the operation - ManagedDatabaseResource result = await managedDatabase.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteManagedDatabase() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseDelete.json - // this example is just showing the usage of "ManagedDatabases_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedDatabaseResource created on azure - // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string managedInstanceName = "managedInstance"; - string databaseName = "testdb"; - ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); - ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); - - // invoke the operation - await managedDatabase.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesAManagedDatabaseWithMaximalProperties() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseUpdateMax.json - // this example is just showing the usage of "ManagedDatabases_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedDatabaseResource created on azure - // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string managedInstanceName = "managedInstance"; - string databaseName = "testdb"; - ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); - ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); - - // invoke the operation - ManagedDatabasePatch patch = new ManagedDatabasePatch() - { - Tags = -{ -["tagKey1"] = "TagValue1", -}, - }; - ArmOperation lro = await managedDatabase.UpdateAsync(WaitUntil.Completed, patch); - ManagedDatabaseResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesAManagedDatabaseWithMinimalProperties() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedDatabaseUpdateMin.json - // this example is just showing the usage of "ManagedDatabases_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedDatabaseResource created on azure - // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string managedInstanceName = "managedInstance"; - string databaseName = "testdb"; - ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); - ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); - - // invoke the operation - ManagedDatabasePatch patch = new ManagedDatabasePatch() - { - Tags = -{ -["tagKey1"] = "TagValue1", -}, - }; - ArmOperation lro = await managedDatabase.UpdateAsync(WaitUntil.Completed, patch); - ManagedDatabaseResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CancelMove_CancelsAManagedDatabaseMove() diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSchemaCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSchemaCollection.cs index b94ccbec29216..1dec2452b6be2 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSchemaCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSchemaCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ManagedDatabaseSchemaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedDatabaseSchemas() + public async Task Get_GetManagedDatabaseSchema() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSchemaListByDatabase.json - // this example is just showing the usage of "ManagedDatabaseSchemas_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSchemaGet.json + // this example is just showing the usage of "ManagedDatabaseSchemas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListManagedDatabaseSchemas() // get the collection of this ManagedDatabaseSchemaResource ManagedDatabaseSchemaCollection collection = managedDatabase.GetManagedDatabaseSchemas(); - // invoke the operation and iterate over the result - await foreach (ManagedDatabaseSchemaResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseSchemaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string schemaName = "dbo"; + ManagedDatabaseSchemaResource result = await collection.GetAsync(schemaName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedDatabaseSchema() + public async Task GetAll_ListManagedDatabaseSchemas() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSchemaGet.json - // this example is just showing the usage of "ManagedDatabaseSchemas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSchemaListByDatabase.json + // this example is just showing the usage of "ManagedDatabaseSchemas_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetManagedDatabaseSchema() // get the collection of this ManagedDatabaseSchemaResource ManagedDatabaseSchemaCollection collection = managedDatabase.GetManagedDatabaseSchemas(); - // invoke the operation - string schemaName = "dbo"; - ManagedDatabaseSchemaResource result = await collection.GetAsync(schemaName); + // invoke the operation and iterate over the result + await foreach (ManagedDatabaseSchemaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseSchemaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSecurityAlertPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSecurityAlertPolicyCollection.cs index c15c173667891..5e990be8c88a7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSecurityAlertPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSecurityAlertPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedDatabaseSecurityAlertPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabaseSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertGet.json - // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertCreateMax.json + // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task Get_GetADatabaseSThreatDetectionPolicy() // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-6852"; - string managedInstanceName = "securityalert-2080"; + string resourceGroupName = "securityalert-4799"; + string managedInstanceName = "securityalert-6440"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); @@ -42,7 +42,18 @@ public async Task Get_GetADatabaseSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - ManagedDatabaseSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); + ManagedDatabaseSecurityAlertPolicyData data = new ManagedDatabaseSecurityAlertPolicyData + { + State = SecurityAlertPolicyState.Enabled, + DisabledAlerts = { "Sql_Injection", "Usage_Anomaly" }, + EmailAddresses = { "test@contoso.com", "user@contoso.com" }, + SendToEmailAccountAdmins = true, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + RetentionDays = 6, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + ManagedDatabaseSecurityAlertPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +64,10 @@ public async Task Get_GetADatabaseSThreatDetectionPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADatabaseSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertGet.json - // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertCreateMin.json + // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,8 +77,8 @@ public async Task Exists_GetADatabaseSThreatDetectionPolicy() // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-6852"; - string managedInstanceName = "securityalert-2080"; + string resourceGroupName = "securityalert-4799"; + string managedInstanceName = "securityalert-6440"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); @@ -77,14 +88,23 @@ public async Task Exists_GetADatabaseSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - bool result = await collection.ExistsAsync(securityAlertPolicyName); + ManagedDatabaseSecurityAlertPolicyData data = new ManagedDatabaseSecurityAlertPolicyData + { + State = SecurityAlertPolicyState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + ManagedDatabaseSecurityAlertPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADatabaseSThreatDetectionPolicy() + public async Task Get_GetADatabaseSThreatDetectionPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertGet.json // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,29 +128,21 @@ public async Task GetIfExists_GetADatabaseSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); - ManagedDatabaseSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + ManagedDatabaseSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithAllParameters() + public async Task GetAll_GetAListOfTheDatabaseSThreatDetectionPolicies() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertCreateMax.json - // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertListByDatabase.json + // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,8 +152,8 @@ public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithAllPar // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string managedInstanceName = "securityalert-6440"; + string resourceGroupName = "securityalert-6852"; + string managedInstanceName = "securityalert-2080"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); @@ -149,40 +161,25 @@ public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithAllPar // get the collection of this ManagedDatabaseSecurityAlertPolicyResource ManagedDatabaseSecurityAlertPolicyCollection collection = managedDatabase.GetManagedDatabaseSecurityAlertPolicies(); - // invoke the operation - SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - ManagedDatabaseSecurityAlertPolicyData data = new ManagedDatabaseSecurityAlertPolicyData() + // invoke the operation and iterate over the result + await foreach (ManagedDatabaseSecurityAlertPolicyResource item in collection.GetAllAsync()) { - State = SecurityAlertPolicyState.Enabled, - DisabledAlerts = -{ -"Sql_Injection","Usage_Anomaly" -}, - EmailAddresses = -{ -"test@contoso.com","user@contoso.com" -}, - SendToEmailAccountAdmins = true, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - RetentionDays = 6, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - ManagedDatabaseSecurityAlertPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseSecurityAlertPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithMinimalParameters() + public async Task Exists_GetADatabaseSThreatDetectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertCreateMin.json - // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertGet.json + // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,8 +189,8 @@ public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithMinima // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string managedInstanceName = "securityalert-6440"; + string resourceGroupName = "securityalert-6852"; + string managedInstanceName = "securityalert-2080"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); @@ -203,26 +200,17 @@ public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithMinima // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - ManagedDatabaseSecurityAlertPolicyData data = new ManagedDatabaseSecurityAlertPolicyData() - { - State = SecurityAlertPolicyState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - ManagedDatabaseSecurityAlertPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(securityAlertPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfTheDatabaseSThreatDetectionPolicies() + public async Task GetIfExists_GetADatabaseSThreatDetectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertListByDatabase.json - // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseSecurityAlertGet.json + // this example is just showing the usage of "ManagedDatabaseSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -241,17 +229,23 @@ public async Task GetAll_GetAListOfTheDatabaseSThreatDetectionPolicies() // get the collection of this ManagedDatabaseSecurityAlertPolicyResource ManagedDatabaseSecurityAlertPolicyCollection collection = managedDatabase.GetManagedDatabaseSecurityAlertPolicies(); - // invoke the operation and iterate over the result - await foreach (ManagedDatabaseSecurityAlertPolicyResource item in collection.GetAllAsync()) + // invoke the operation + SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); + ManagedDatabaseSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedDatabaseSecurityAlertPolicyData resourceData = item.Data; + ManagedDatabaseSecurityAlertPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSecurityAlertPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSecurityAlertPolicyResource.cs index 1bd534f5724aa..e88dbc3d82a34 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSecurityAlertPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseSecurityAlertPolicyResource.cs @@ -71,17 +71,11 @@ public async Task Update_UpdateADatabaseSThreatDetectionPolicyWithAllParameters( ManagedDatabaseSecurityAlertPolicyResource managedDatabaseSecurityAlertPolicy = client.GetManagedDatabaseSecurityAlertPolicyResource(managedDatabaseSecurityAlertPolicyResourceId); // invoke the operation - ManagedDatabaseSecurityAlertPolicyData data = new ManagedDatabaseSecurityAlertPolicyData() + ManagedDatabaseSecurityAlertPolicyData data = new ManagedDatabaseSecurityAlertPolicyData { State = SecurityAlertPolicyState.Enabled, - DisabledAlerts = -{ -"Sql_Injection","Usage_Anomaly" -}, - EmailAddresses = -{ -"test@contoso.com","user@contoso.com" -}, + DisabledAlerts = { "Sql_Injection", "Usage_Anomaly" }, + EmailAddresses = { "test@contoso.com", "user@contoso.com" }, SendToEmailAccountAdmins = true, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", @@ -120,7 +114,7 @@ public async Task Update_UpdateADatabaseSThreatDetectionPolicyWithMinimalParamet ManagedDatabaseSecurityAlertPolicyResource managedDatabaseSecurityAlertPolicy = client.GetManagedDatabaseSecurityAlertPolicyResource(managedDatabaseSecurityAlertPolicyResourceId); // invoke the operation - ManagedDatabaseSecurityAlertPolicyData data = new ManagedDatabaseSecurityAlertPolicyData() + ManagedDatabaseSecurityAlertPolicyData data = new ManagedDatabaseSecurityAlertPolicyData { State = SecurityAlertPolicyState.Enabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseTableCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseTableCollection.cs index 7cc5aa57f9439..f67ed6a4266c0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseTableCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseTableCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ManagedDatabaseTableCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedDatabaseTables() + public async Task Get_GetManagedDatabaseTable() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseTableListBySchema.json - // this example is just showing the usage of "ManagedDatabaseTables_ListBySchema" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseTableGet.json + // this example is just showing the usage of "ManagedDatabaseTables_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListManagedDatabaseTables() // get the collection of this ManagedDatabaseTableResource ManagedDatabaseTableCollection collection = managedDatabaseSchema.GetManagedDatabaseTables(); - // invoke the operation and iterate over the result - await foreach (ManagedDatabaseTableResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseTableData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string tableName = "table1"; + ManagedDatabaseTableResource result = await collection.GetAsync(tableName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedDatabaseTable() + public async Task GetAll_ListManagedDatabaseTables() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseTableGet.json - // this example is just showing the usage of "ManagedDatabaseTables_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseTableListBySchema.json + // this example is just showing the usage of "ManagedDatabaseTables_ListBySchema" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetManagedDatabaseTable() // get the collection of this ManagedDatabaseTableResource ManagedDatabaseTableCollection collection = managedDatabaseSchema.GetManagedDatabaseTables(); - // invoke the operation - string tableName = "table1"; - ManagedDatabaseTableResource result = await collection.GetAsync(tableName); + // invoke the operation and iterate over the result + await foreach (ManagedDatabaseTableResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseTableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentCollection.cs index 55abe1ac8f539..56494247d046c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedDatabaseVulnerabilityAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabaseSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentGet.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMax.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,19 @@ public async Task Get_GetADatabaseSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - ManagedDatabaseVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); + DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + RecurringScans = new VulnerabilityAssessmentRecurringScansProperties + { + IsEnabled = true, + EmailSubscriptionAdmins = true, + Emails = { "email1@mail.com", "email2@mail.com" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + ManagedDatabaseVulnerabilityAssessmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +65,10 @@ public async Task Get_GetADatabaseSVulnerabilityAssessment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADatabaseSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentGet.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMin.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,14 +89,24 @@ public async Task Exists_GetADatabaseSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); + DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + ManagedDatabaseVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADatabaseSVulnerabilityAssessment() + public async Task Get_GetADatabaseSVulnerabilityAssessment() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentGet.json // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,29 +130,21 @@ public async Task GetIfExists_GetADatabaseSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); - ManagedDatabaseVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; + ManagedDatabaseVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithAllParameters() + public async Task GetAll_GetADatabaseSVulnerabilityAssessmentsList() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMax.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentListByDatabase.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,38 +163,25 @@ public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithAllP // get the collection of this ManagedDatabaseVulnerabilityAssessmentResource ManagedDatabaseVulnerabilityAssessmentCollection collection = managedDatabase.GetManagedDatabaseVulnerabilityAssessments(); - // invoke the operation - VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData() + // invoke the operation and iterate over the result + await foreach (ManagedDatabaseVulnerabilityAssessmentResource item in collection.GetAllAsync()) { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new VulnerabilityAssessmentRecurringScansProperties() - { - IsEnabled = true, - EmailSubscriptionAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - ManagedDatabaseVulnerabilityAssessmentResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMinimalParameters() + public async Task Exists_GetADatabaseSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMin.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentGet.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -201,27 +202,17 @@ public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMini // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - ManagedDatabaseVulnerabilityAssessmentResource result = lro.Value; + bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetADatabaseSVulnerabilityAssessmentsList() + public async Task GetIfExists_GetADatabaseSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentListByDatabase.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentGet.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -240,17 +231,23 @@ public async Task GetAll_GetADatabaseSVulnerabilityAssessmentsList() // get the collection of this ManagedDatabaseVulnerabilityAssessmentResource ManagedDatabaseVulnerabilityAssessmentCollection collection = managedDatabase.GetManagedDatabaseVulnerabilityAssessments(); - // invoke the operation and iterate over the result - await foreach (ManagedDatabaseVulnerabilityAssessmentResource item in collection.GetAllAsync()) + // invoke the operation + VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; + NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); + ManagedDatabaseVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentData resourceData = item.Data; + DatabaseVulnerabilityAssessmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentResource.cs index a3a674e5ca893..7073ee5d37bda 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetADatabaseSVulnerabilityAssessment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithAllParameters() + public async Task Delete_RemoveADatabaseSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMax.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentDelete.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,35 +71,16 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithAllParameter ManagedDatabaseVulnerabilityAssessmentResource managedDatabaseVulnerabilityAssessment = client.GetManagedDatabaseVulnerabilityAssessmentResource(managedDatabaseVulnerabilityAssessmentResourceId); // invoke the operation - DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new VulnerabilityAssessmentRecurringScansProperties() - { - IsEnabled = true, - EmailSubscriptionAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, - }, - }; - ArmOperation lro = await managedDatabaseVulnerabilityAssessment.UpdateAsync(WaitUntil.Completed, data); - ManagedDatabaseVulnerabilityAssessmentResource result = lro.Value; + await managedDatabaseVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithMinimalParameters() + public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMin.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMax.json // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -118,10 +99,16 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithMinimalParam ManagedDatabaseVulnerabilityAssessmentResource managedDatabaseVulnerabilityAssessment = client.GetManagedDatabaseVulnerabilityAssessmentResource(managedDatabaseVulnerabilityAssessmentResourceId); // invoke the operation - DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData() + DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + RecurringScans = new VulnerabilityAssessmentRecurringScansProperties + { + IsEnabled = true, + EmailSubscriptionAdmins = true, + Emails = { "email1@mail.com", "email2@mail.com" }, + }, }; ArmOperation lro = await managedDatabaseVulnerabilityAssessment.UpdateAsync(WaitUntil.Completed, data); ManagedDatabaseVulnerabilityAssessmentResource result = lro.Value; @@ -135,10 +122,10 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithMinimalParam [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RemoveADatabaseSVulnerabilityAssessment() + public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentDelete.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentCreateMin.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -156,9 +143,19 @@ public async Task Delete_RemoveADatabaseSVulnerabilityAssessment() ManagedDatabaseVulnerabilityAssessmentResource managedDatabaseVulnerabilityAssessment = client.GetManagedDatabaseVulnerabilityAssessmentResource(managedDatabaseVulnerabilityAssessmentResourceId); // invoke the operation - await managedDatabaseVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); + DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await managedDatabaseVulnerabilityAssessment.UpdateAsync(WaitUntil.Completed, data); + ManagedDatabaseVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentRuleBaselineCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentRuleBaselineCollection.cs index 873108065f79f..2f5dc9bd80436 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentRuleBaselineCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentRuleBaselineCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedDatabaseVulnerabilityAssessmentRuleBaselineCo { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineGet.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineCreate.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() // this example assumes you already have this ManagedDatabaseVulnerabilityAssessmentResource created on azure // for more information of creating ManagedDatabaseVulnerabilityAssessmentResource, please refer to the document of ManagedDatabaseVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4711"; - string managedInstanceName = "vulnerabilityaseessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string managedInstanceName = "vulnerabilityaseessmenttest-6440"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier managedDatabaseVulnerabilityAssessmentResourceId = ManagedDatabaseVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName); @@ -43,8 +43,13 @@ public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() // invoke the operation string ruleId = "VA1001"; - VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Master; - ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource result = await collection.GetAsync(ruleId, baselineName); + VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Default; + DatabaseVulnerabilityAssessmentRuleBaselineData data = new DatabaseVulnerabilityAssessmentRuleBaselineData + { + BaselineResults = { new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userA", "SELECT" }), new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userB", "SELECT" }), new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userC", "SELECT", "tableId_4" }) }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, baselineName, data); + ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,7 +60,7 @@ public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineGet.json // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. @@ -81,14 +86,18 @@ public async Task Exists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() // invoke the operation string ruleId = "VA1001"; VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Master; - bool result = await collection.ExistsAsync(ruleId, baselineName); + ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource result = await collection.GetAsync(ruleId, baselineName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Exists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineGet.json // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. @@ -114,29 +123,17 @@ public async Task GetIfExists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline( // invoke the operation string ruleId = "VA1001"; VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Master; - NullableResponse response = await collection.GetIfExistsAsync(ruleId, baselineName); - ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleId, baselineName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task GetIfExists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineCreate.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineGet.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,8 +143,8 @@ public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessme // this example assumes you already have this ManagedDatabaseVulnerabilityAssessmentResource created on azure // for more information of creating ManagedDatabaseVulnerabilityAssessmentResource, please refer to the document of ManagedDatabaseVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string managedInstanceName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityaseessmenttest-4711"; + string managedInstanceName = "vulnerabilityaseessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier managedDatabaseVulnerabilityAssessmentResourceId = ManagedDatabaseVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName); @@ -158,31 +155,22 @@ public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessme // invoke the operation string ruleId = "VA1001"; - VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Default; - DatabaseVulnerabilityAssessmentRuleBaselineData data = new DatabaseVulnerabilityAssessmentRuleBaselineData() - { - BaselineResults = -{ -new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userA","SELECT" -}),new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userB","SELECT" -}),new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userC","SELECT","tableId_4" -}) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, baselineName, data); - ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource result = lro.Value; + VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Master; + NullableResponse response = await collection.GetIfExistsAsync(ruleId, baselineName); + ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource.cs index 03b6e777e2c79..f6403b937ac4f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource.cs @@ -52,10 +52,10 @@ public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineCreate.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineDelete.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentRuleBaselines_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,38 +75,17 @@ public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBa ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource managedDatabaseVulnerabilityAssessmentRuleBaseline = client.GetManagedDatabaseVulnerabilityAssessmentRuleBaselineResource(managedDatabaseVulnerabilityAssessmentRuleBaselineResourceId); // invoke the operation - DatabaseVulnerabilityAssessmentRuleBaselineData data = new DatabaseVulnerabilityAssessmentRuleBaselineData() - { - BaselineResults = -{ -new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userA","SELECT" -}),new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userB","SELECT" -}),new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userC","SELECT","tableId_4" -}) -}, - }; - ArmOperation lro = await managedDatabaseVulnerabilityAssessmentRuleBaseline.UpdateAsync(WaitUntil.Completed, data); - ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource result = lro.Value; + await managedDatabaseVulnerabilityAssessmentRuleBaseline.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineDelete.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentRuleBaselines_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentRuleBaselineCreate.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -126,9 +105,18 @@ public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource managedDatabaseVulnerabilityAssessmentRuleBaseline = client.GetManagedDatabaseVulnerabilityAssessmentRuleBaselineResource(managedDatabaseVulnerabilityAssessmentRuleBaselineResourceId); // invoke the operation - await managedDatabaseVulnerabilityAssessmentRuleBaseline.DeleteAsync(WaitUntil.Completed); + DatabaseVulnerabilityAssessmentRuleBaselineData data = new DatabaseVulnerabilityAssessmentRuleBaselineData + { + BaselineResults = { new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userA", "SELECT" }), new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userB", "SELECT" }), new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userC", "SELECT", "tableId_4" }) }, + }; + ArmOperation lro = await managedDatabaseVulnerabilityAssessmentRuleBaseline.UpdateAsync(WaitUntil.Completed, data); + ManagedDatabaseVulnerabilityAssessmentRuleBaselineResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentScanCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentScanCollection.cs index f6c923e9ab388..c0812f0366727 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentScanCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentScanCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedDatabaseVulnerabilityAssessmentScanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecords() + public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanRecordsListByDatabase.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentScans_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanRecordsGet.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecord // get the collection of this ManagedDatabaseVulnerabilityAssessmentScanResource ManagedDatabaseVulnerabilityAssessmentScanCollection collection = managedDatabaseVulnerabilityAssessment.GetManagedDatabaseVulnerabilityAssessmentScans(); - // invoke the operation and iterate over the result - await foreach (ManagedDatabaseVulnerabilityAssessmentScanResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VulnerabilityAssessmentScanRecordData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scanId = "scan001"; + ManagedDatabaseVulnerabilityAssessmentScanResource result = await collection.GetAsync(scanId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VulnerabilityAssessmentScanRecordData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() + public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecords() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanRecordsGet.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanRecordsListByDatabase.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentScans_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +77,17 @@ public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() // get the collection of this ManagedDatabaseVulnerabilityAssessmentScanResource ManagedDatabaseVulnerabilityAssessmentScanCollection collection = managedDatabaseVulnerabilityAssessment.GetManagedDatabaseVulnerabilityAssessmentScans(); - // invoke the operation - string scanId = "scan001"; - ManagedDatabaseVulnerabilityAssessmentScanResource result = await collection.GetAsync(scanId); + // invoke the operation and iterate over the result + await foreach (ManagedDatabaseVulnerabilityAssessmentScanResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VulnerabilityAssessmentScanRecordData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VulnerabilityAssessmentScanRecordData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentScanResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentScanResource.cs index 527886ce0b7c7..80654f3799900 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentScanResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedDatabaseVulnerabilityAssessmentScanResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedDatabaseVulnerabilityAssessmentScanResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task InitiateScan_ExecutesADatabaseSVulnerabilityAssessmentScan() + public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScansExecute.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentScans_InitiateScan" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanRecordsGet.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,22 +35,26 @@ public async Task InitiateScan_ExecutesADatabaseSVulnerabilityAssessmentScan() string managedInstanceName = "vulnerabilityassessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - string scanId = "scan01"; + string scanId = "scan001"; ResourceIdentifier managedDatabaseVulnerabilityAssessmentScanResourceId = ManagedDatabaseVulnerabilityAssessmentScanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, scanId); ManagedDatabaseVulnerabilityAssessmentScanResource managedDatabaseVulnerabilityAssessmentScan = client.GetManagedDatabaseVulnerabilityAssessmentScanResource(managedDatabaseVulnerabilityAssessmentScanResourceId); // invoke the operation - await managedDatabaseVulnerabilityAssessmentScan.InitiateScanAsync(WaitUntil.Completed); + ManagedDatabaseVulnerabilityAssessmentScanResource result = await managedDatabaseVulnerabilityAssessmentScan.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VulnerabilityAssessmentScanRecordData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Export_ExportADatabaseSVulnerabilityAssessmentScanResults() + public async Task InitiateScan_ExecutesADatabaseSVulnerabilityAssessmentScan() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanExport.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentScans_Export" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScansExecute.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentScans_InitiateScan" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,26 +64,26 @@ public async Task Export_ExportADatabaseSVulnerabilityAssessmentScanResults() // this example assumes you already have this ManagedDatabaseVulnerabilityAssessmentScanResource created on azure // for more information of creating ManagedDatabaseVulnerabilityAssessmentScanResource, please refer to the document of ManagedDatabaseVulnerabilityAssessmentScanResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityassessmenttest-4799"; - string managedInstanceName = "vulnerabilityassessmenttest-6440"; + string resourceGroupName = "vulnerabilityassessmenttest-4711"; + string managedInstanceName = "vulnerabilityassessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - string scanId = "scan001"; + string scanId = "scan01"; ResourceIdentifier managedDatabaseVulnerabilityAssessmentScanResourceId = ManagedDatabaseVulnerabilityAssessmentScanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName, vulnerabilityAssessmentName, scanId); ManagedDatabaseVulnerabilityAssessmentScanResource managedDatabaseVulnerabilityAssessmentScan = client.GetManagedDatabaseVulnerabilityAssessmentScanResource(managedDatabaseVulnerabilityAssessmentScanResourceId); // invoke the operation - DatabaseVulnerabilityAssessmentScansExport result = await managedDatabaseVulnerabilityAssessmentScan.ExportAsync(); + await managedDatabaseVulnerabilityAssessmentScan.InitiateScanAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() + public async Task Export_ExportADatabaseSVulnerabilityAssessmentScanResults() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanRecordsGet.json - // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedDatabaseVulnerabilityAssessmentScanExport.json + // this example is just showing the usage of "ManagedDatabaseVulnerabilityAssessmentScans_Export" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -89,8 +93,8 @@ public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() // this example assumes you already have this ManagedDatabaseVulnerabilityAssessmentScanResource created on azure // for more information of creating ManagedDatabaseVulnerabilityAssessmentScanResource, please refer to the document of ManagedDatabaseVulnerabilityAssessmentScanResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityassessmenttest-4711"; - string managedInstanceName = "vulnerabilityassessmenttest-6411"; + string resourceGroupName = "vulnerabilityassessmenttest-4799"; + string managedInstanceName = "vulnerabilityassessmenttest-6440"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; string scanId = "scan001"; @@ -98,13 +102,9 @@ public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() ManagedDatabaseVulnerabilityAssessmentScanResource managedDatabaseVulnerabilityAssessmentScan = client.GetManagedDatabaseVulnerabilityAssessmentScanResource(managedDatabaseVulnerabilityAssessmentScanResourceId); // invoke the operation - ManagedDatabaseVulnerabilityAssessmentScanResource result = await managedDatabaseVulnerabilityAssessmentScan.GetAsync(); + DatabaseVulnerabilityAssessmentScansExport result = await managedDatabaseVulnerabilityAssessmentScan.ExportAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VulnerabilityAssessmentScanRecordData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdministratorCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdministratorCollection.cs index 9feea28d1e1ea..a089d32e2dd32 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdministratorCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdministratorCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstanceAdministratorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAdministratorsOfManagedInstance() + public async Task CreateOrUpdate_CreateAdministratorOfManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorListByInstance.json - // this example is just showing the usage of "ManagedInstanceAdministrators_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorCreate.json + // this example is just showing the usage of "ManagedInstanceAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,31 @@ public async Task GetAll_ListAdministratorsOfManagedInstance() // get the collection of this ManagedInstanceAdministratorResource ManagedInstanceAdministratorCollection collection = managedInstance.GetManagedInstanceAdministrators(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceAdministratorResource item in collection.GetAllAsync()) + // invoke the operation + SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; + ManagedInstanceAdministratorData data = new ManagedInstanceAdministratorData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceAdministratorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AdministratorType = ManagedInstanceAdministratorType.ActiveDirectory, + Login = "bob@contoso.com", + Sid = Guid.Parse("44444444-3333-2222-1111-000000000000"), + TenantId = Guid.Parse("55555555-4444-3333-2222-111111111111"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, administratorName, data); + ManagedInstanceAdministratorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAdministratorOfManagedInstance() + public async Task CreateOrUpdate_UpdateAdministratorOfManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorGet.json - // this example is just showing the usage of "ManagedInstanceAdministrators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorUpdate.json + // this example is just showing the usage of "ManagedInstanceAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +83,15 @@ public async Task Get_GetAdministratorOfManagedInstance() // invoke the operation SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; - ManagedInstanceAdministratorResource result = await collection.GetAsync(administratorName); + ManagedInstanceAdministratorData data = new ManagedInstanceAdministratorData + { + AdministratorType = ManagedInstanceAdministratorType.ActiveDirectory, + Login = "bob@contoso.com", + Sid = Guid.Parse("44444444-3333-2222-1111-000000000000"), + TenantId = Guid.Parse("55555555-4444-3333-2222-111111111111"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, administratorName, data); + ManagedInstanceAdministratorResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +102,7 @@ public async Task Get_GetAdministratorOfManagedInstance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAdministratorOfManagedInstance() + public async Task Get_GetAdministratorOfManagedInstance() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorGet.json // this example is just showing the usage of "ManagedInstanceAdministrators_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +125,21 @@ public async Task Exists_GetAdministratorOfManagedInstance() // invoke the operation SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; - bool result = await collection.ExistsAsync(administratorName); + ManagedInstanceAdministratorResource result = await collection.GetAsync(administratorName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAdministratorOfManagedInstance() + public async Task GetAll_ListAdministratorsOfManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorGet.json - // this example is just showing the usage of "ManagedInstanceAdministrators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorListByInstance.json + // this example is just showing the usage of "ManagedInstanceAdministrators_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +157,25 @@ public async Task GetIfExists_GetAdministratorOfManagedInstance() // get the collection of this ManagedInstanceAdministratorResource ManagedInstanceAdministratorCollection collection = managedInstance.GetManagedInstanceAdministrators(); - // invoke the operation - SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; - NullableResponse response = await collection.GetIfExistsAsync(administratorName); - ManagedInstanceAdministratorResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedInstanceAdministratorResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceAdministratorData resourceData = result.Data; + ManagedInstanceAdministratorData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAdministratorOfManagedInstance() + public async Task Exists_GetAdministratorOfManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorCreate.json - // this example is just showing the usage of "ManagedInstanceAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorGet.json + // this example is just showing the usage of "ManagedInstanceAdministrators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,29 +195,17 @@ public async Task CreateOrUpdate_CreateAdministratorOfManagedInstance() // invoke the operation SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; - ManagedInstanceAdministratorData data = new ManagedInstanceAdministratorData() - { - AdministratorType = ManagedInstanceAdministratorType.ActiveDirectory, - Login = "bob@contoso.com", - Sid = Guid.Parse("44444444-3333-2222-1111-000000000000"), - TenantId = Guid.Parse("55555555-4444-3333-2222-111111111111"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, administratorName, data); - ManagedInstanceAdministratorResource result = lro.Value; + bool result = await collection.ExistsAsync(administratorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAdministratorOfManagedInstance() + public async Task GetIfExists_GetAdministratorOfManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorUpdate.json - // this example is just showing the usage of "ManagedInstanceAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorGet.json + // this example is just showing the usage of "ManagedInstanceAdministrators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -225,21 +225,21 @@ public async Task CreateOrUpdate_UpdateAdministratorOfManagedInstance() // invoke the operation SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; - ManagedInstanceAdministratorData data = new ManagedInstanceAdministratorData() - { - AdministratorType = ManagedInstanceAdministratorType.ActiveDirectory, - Login = "bob@contoso.com", - Sid = Guid.Parse("44444444-3333-2222-1111-000000000000"), - TenantId = Guid.Parse("55555555-4444-3333-2222-111111111111"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, administratorName, data); - ManagedInstanceAdministratorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(administratorName); + ManagedInstanceAdministratorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdministratorResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdministratorResource.cs index 76c16ea9f2c16..b69067105dd7d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdministratorResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdministratorResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAdministratorOfManagedInstance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAdministratorOfManagedInstance() + public async Task Delete_DeleteAdministratorOfManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorCreate.json - // this example is just showing the usage of "ManagedInstanceAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorDelete.json + // this example is just showing the usage of "ManagedInstanceAdministrators_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,28 +69,16 @@ public async Task Update_CreateAdministratorOfManagedInstance() ManagedInstanceAdministratorResource managedInstanceAdministrator = client.GetManagedInstanceAdministratorResource(managedInstanceAdministratorResourceId); // invoke the operation - ManagedInstanceAdministratorData data = new ManagedInstanceAdministratorData() - { - AdministratorType = ManagedInstanceAdministratorType.ActiveDirectory, - Login = "bob@contoso.com", - Sid = Guid.Parse("44444444-3333-2222-1111-000000000000"), - TenantId = Guid.Parse("55555555-4444-3333-2222-111111111111"), - }; - ArmOperation lro = await managedInstanceAdministrator.UpdateAsync(WaitUntil.Completed, data); - ManagedInstanceAdministratorResource result = lro.Value; + await managedInstanceAdministrator.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAdministratorOfManagedInstance() + public async Task Update_CreateAdministratorOfManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorUpdate.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorCreate.json // this example is just showing the usage of "ManagedInstanceAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -108,7 +96,7 @@ public async Task Update_UpdateAdministratorOfManagedInstance() ManagedInstanceAdministratorResource managedInstanceAdministrator = client.GetManagedInstanceAdministratorResource(managedInstanceAdministratorResourceId); // invoke the operation - ManagedInstanceAdministratorData data = new ManagedInstanceAdministratorData() + ManagedInstanceAdministratorData data = new ManagedInstanceAdministratorData { AdministratorType = ManagedInstanceAdministratorType.ActiveDirectory, Login = "bob@contoso.com", @@ -127,10 +115,10 @@ public async Task Update_UpdateAdministratorOfManagedInstance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAdministratorOfManagedInstance() + public async Task Update_UpdateAdministratorOfManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorDelete.json - // this example is just showing the usage of "ManagedInstanceAdministrators_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAdministratorUpdate.json + // this example is just showing the usage of "ManagedInstanceAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,9 +135,21 @@ public async Task Delete_DeleteAdministratorOfManagedInstance() ManagedInstanceAdministratorResource managedInstanceAdministrator = client.GetManagedInstanceAdministratorResource(managedInstanceAdministratorResourceId); // invoke the operation - await managedInstanceAdministrator.DeleteAsync(WaitUntil.Completed); + ManagedInstanceAdministratorData data = new ManagedInstanceAdministratorData + { + AdministratorType = ManagedInstanceAdministratorType.ActiveDirectory, + Login = "bob@contoso.com", + Sid = Guid.Parse("44444444-3333-2222-1111-000000000000"), + TenantId = Guid.Parse("55555555-4444-3333-2222-111111111111"), + }; + ArmOperation lro = await managedInstanceAdministrator.UpdateAsync(WaitUntil.Completed, data); + ManagedInstanceAdministratorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdvancedThreatProtectionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdvancedThreatProtectionCollection.cs index 96d038316c4d9..599e8c6b41ec5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdvancedThreatProtectionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdvancedThreatProtectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstanceAdvancedThreatProtectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheManagedInstanceSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_UpdateAManagedInstanceSAdvancedThreatProtectionSettingsWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsListByInstance.json - // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsCreateMax.json + // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_ListTheManagedInstanceSAdvancedThreatProtectionSettings // get the collection of this ManagedInstanceAdvancedThreatProtectionResource ManagedInstanceAdvancedThreatProtectionCollection collection = managedInstance.GetManagedInstanceAdvancedThreatProtections(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceAdvancedThreatProtectionResource item in collection.GetAllAsync()) + // invoke the operation + AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; + ManagedInstanceAdvancedThreatProtectionData data = new ManagedInstanceAdvancedThreatProtectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceAdvancedThreatProtectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + State = AdvancedThreatProtectionState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); + ManagedInstanceAdvancedThreatProtectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAManagedInstanceSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_UpdateAManagedInstanceSAdvancedThreatProtectionSettingsWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsGet.json - // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsCreateMin.json + // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +80,12 @@ public async Task Get_GetAManagedInstanceSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - ManagedInstanceAdvancedThreatProtectionResource result = await collection.GetAsync(advancedThreatProtectionName); + ManagedInstanceAdvancedThreatProtectionData data = new ManagedInstanceAdvancedThreatProtectionData + { + State = AdvancedThreatProtectionState.Disabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); + ManagedInstanceAdvancedThreatProtectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +96,7 @@ public async Task Get_GetAManagedInstanceSAdvancedThreatProtectionSettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAManagedInstanceSAdvancedThreatProtectionSettings() + public async Task Get_GetAManagedInstanceSAdvancedThreatProtectionSettings() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsGet.json // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +119,21 @@ public async Task Exists_GetAManagedInstanceSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - bool result = await collection.ExistsAsync(advancedThreatProtectionName); + ManagedInstanceAdvancedThreatProtectionResource result = await collection.GetAsync(advancedThreatProtectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAManagedInstanceSAdvancedThreatProtectionSettings() + public async Task GetAll_ListTheManagedInstanceSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsGet.json - // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsListByInstance.json + // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +151,25 @@ public async Task GetIfExists_GetAManagedInstanceSAdvancedThreatProtectionSettin // get the collection of this ManagedInstanceAdvancedThreatProtectionResource ManagedInstanceAdvancedThreatProtectionCollection collection = managedInstance.GetManagedInstanceAdvancedThreatProtections(); - // invoke the operation - AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - NullableResponse response = await collection.GetIfExistsAsync(advancedThreatProtectionName); - ManagedInstanceAdvancedThreatProtectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedInstanceAdvancedThreatProtectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceAdvancedThreatProtectionData resourceData = result.Data; + ManagedInstanceAdvancedThreatProtectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAManagedInstanceSAdvancedThreatProtectionSettingsWithAllParameters() + public async Task Exists_GetAManagedInstanceSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsCreateMax.json - // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsGet.json + // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +189,17 @@ public async Task CreateOrUpdate_UpdateAManagedInstanceSAdvancedThreatProtection // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - ManagedInstanceAdvancedThreatProtectionData data = new ManagedInstanceAdvancedThreatProtectionData() - { - State = AdvancedThreatProtectionState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); - ManagedInstanceAdvancedThreatProtectionResource result = lro.Value; + bool result = await collection.ExistsAsync(advancedThreatProtectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceAdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAManagedInstanceSAdvancedThreatProtectionSettingsWithMinimalParameters() + public async Task GetIfExists_GetAManagedInstanceSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsCreateMin.json - // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ManagedInstanceAdvancedThreatProtectionSettingsGet.json + // this example is just showing the usage of "ManagedInstanceAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -222,18 +219,21 @@ public async Task CreateOrUpdate_UpdateAManagedInstanceSAdvancedThreatProtection // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - ManagedInstanceAdvancedThreatProtectionData data = new ManagedInstanceAdvancedThreatProtectionData() - { - State = AdvancedThreatProtectionState.Disabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); - ManagedInstanceAdvancedThreatProtectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(advancedThreatProtectionName); + ManagedInstanceAdvancedThreatProtectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceAdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdvancedThreatProtectionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdvancedThreatProtectionResource.cs index e81220c7b5841..d0d5ea4163af0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdvancedThreatProtectionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAdvancedThreatProtectionResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdateAManagedInstanceSAdvancedThreatProtectionSettings ManagedInstanceAdvancedThreatProtectionResource managedInstanceAdvancedThreatProtection = client.GetManagedInstanceAdvancedThreatProtectionResource(managedInstanceAdvancedThreatProtectionResourceId); // invoke the operation - ManagedInstanceAdvancedThreatProtectionData data = new ManagedInstanceAdvancedThreatProtectionData() + ManagedInstanceAdvancedThreatProtectionData data = new ManagedInstanceAdvancedThreatProtectionData { State = AdvancedThreatProtectionState.Enabled, }; @@ -105,7 +105,7 @@ public async Task Update_UpdateAManagedInstanceSAdvancedThreatProtectionSettings ManagedInstanceAdvancedThreatProtectionResource managedInstanceAdvancedThreatProtection = client.GetManagedInstanceAdvancedThreatProtectionResource(managedInstanceAdvancedThreatProtectionResourceId); // invoke the operation - ManagedInstanceAdvancedThreatProtectionData data = new ManagedInstanceAdvancedThreatProtectionData() + ManagedInstanceAdvancedThreatProtectionData data = new ManagedInstanceAdvancedThreatProtectionData { State = AdvancedThreatProtectionState.Disabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAzureADOnlyAuthenticationCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAzureADOnlyAuthenticationCollection.cs index d377673989787..9a6ba3ca00f86 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAzureADOnlyAuthenticationCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAzureADOnlyAuthenticationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstanceAzureADOnlyAuthenticationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task CreateOrUpdate_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthenticationObject() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthGet.json - // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthCreateOrUpdate.json + // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() // invoke the operation AuthenticationName authenticationName = AuthenticationName.Default; - ManagedInstanceAzureADOnlyAuthenticationResource result = await collection.GetAsync(authenticationName); + ManagedInstanceAzureADOnlyAuthenticationData data = new ManagedInstanceAzureADOnlyAuthenticationData + { + IsAzureADOnlyAuthenticationEnabled = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authenticationName, data); + ManagedInstanceAzureADOnlyAuthenticationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task Get_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthGet.json // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() // invoke the operation AuthenticationName authenticationName = AuthenticationName.Default; - bool result = await collection.ExistsAsync(authenticationName); + ManagedInstanceAzureADOnlyAuthenticationResource result = await collection.GetAsync(authenticationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceAzureADOnlyAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task GetAll_GetsAListOfAzureActiveDirectoryOnlyAuthenticationObject() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthGet.json - // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthListByInstance.json + // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetsAAzureActiveDirectoryOnlyAuthenticationPropert // get the collection of this ManagedInstanceAzureADOnlyAuthenticationResource ManagedInstanceAzureADOnlyAuthenticationCollection collection = managedInstance.GetManagedInstanceAzureADOnlyAuthentications(); - // invoke the operation - AuthenticationName authenticationName = AuthenticationName.Default; - NullableResponse response = await collection.GetIfExistsAsync(authenticationName); - ManagedInstanceAzureADOnlyAuthenticationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedInstanceAzureADOnlyAuthenticationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceAzureADOnlyAuthenticationData resourceData = result.Data; + ManagedInstanceAzureADOnlyAuthenticationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthenticationObject() + public async Task Exists_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthCreateOrUpdate.json - // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthGet.json + // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthent // invoke the operation AuthenticationName authenticationName = AuthenticationName.Default; - ManagedInstanceAzureADOnlyAuthenticationData data = new ManagedInstanceAzureADOnlyAuthenticationData() - { - IsAzureADOnlyAuthenticationEnabled = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authenticationName, data); - ManagedInstanceAzureADOnlyAuthenticationResource result = lro.Value; + bool result = await collection.ExistsAsync(authenticationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceAzureADOnlyAuthenticationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfAzureActiveDirectoryOnlyAuthenticationObject() + public async Task GetIfExists_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthListByInstance.json - // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthGet.json + // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_GetsAListOfAzureActiveDirectoryOnlyAuthenticationObject // get the collection of this ManagedInstanceAzureADOnlyAuthenticationResource ManagedInstanceAzureADOnlyAuthenticationCollection collection = managedInstance.GetManagedInstanceAzureADOnlyAuthentications(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceAzureADOnlyAuthenticationResource item in collection.GetAllAsync()) + // invoke the operation + AuthenticationName authenticationName = AuthenticationName.Default; + NullableResponse response = await collection.GetIfExistsAsync(authenticationName); + ManagedInstanceAzureADOnlyAuthenticationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceAzureADOnlyAuthenticationData resourceData = item.Data; + ManagedInstanceAzureADOnlyAuthenticationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAzureADOnlyAuthenticationResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAzureADOnlyAuthenticationResource.cs index 506637d06b055..21bd538e4e41c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAzureADOnlyAuthenticationResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceAzureADOnlyAuthenticationResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthenticationObject() + public async Task Delete_DeletesAzureActiveDirectoryOnlyAuthenticationObject() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthCreateOrUpdate.json - // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthDelete.json + // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthenticationO ManagedInstanceAzureADOnlyAuthenticationResource managedInstanceAzureADOnlyAuthentication = client.GetManagedInstanceAzureADOnlyAuthenticationResource(managedInstanceAzureADOnlyAuthenticationResourceId); // invoke the operation - ManagedInstanceAzureADOnlyAuthenticationData data = new ManagedInstanceAzureADOnlyAuthenticationData() - { - IsAzureADOnlyAuthenticationEnabled = false, - }; - ArmOperation lro = await managedInstanceAzureADOnlyAuthentication.UpdateAsync(WaitUntil.Completed, data); - ManagedInstanceAzureADOnlyAuthenticationResource result = lro.Value; + await managedInstanceAzureADOnlyAuthentication.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceAzureADOnlyAuthenticationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAzureActiveDirectoryOnlyAuthenticationObject() + public async Task Update_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthenticationObject() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthDelete.json - // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceAzureADOnlyAuthCreateOrUpdate.json + // this example is just showing the usage of "ManagedInstanceAzureADOnlyAuthentications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeletesAzureActiveDirectoryOnlyAuthenticationObject() ManagedInstanceAzureADOnlyAuthenticationResource managedInstanceAzureADOnlyAuthentication = client.GetManagedInstanceAzureADOnlyAuthenticationResource(managedInstanceAzureADOnlyAuthenticationResourceId); // invoke the operation - await managedInstanceAzureADOnlyAuthentication.DeleteAsync(WaitUntil.Completed); + ManagedInstanceAzureADOnlyAuthenticationData data = new ManagedInstanceAzureADOnlyAuthenticationData + { + IsAzureADOnlyAuthenticationEnabled = false, + }; + ArmOperation lro = await managedInstanceAzureADOnlyAuthentication.UpdateAsync(WaitUntil.Completed, data); + ManagedInstanceAzureADOnlyAuthenticationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceAzureADOnlyAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceCollection.cs index a078ecc165687..207424cb13ca9 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ManagedInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedInstancesByResourceGroup() + public async Task CreateOrUpdate_CreateManagedInstanceWithAllProperties() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByResourceGroup.json - // this example is just showing the usage of "ManagedInstances_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceCreateMax.json + // this example is just showing the usage of "ManagedInstances_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,32 +32,69 @@ public async Task GetAll_ListManagedInstancesByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; - string resourceGroupName = "Test1"; + string resourceGroupName = "testrg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this ManagedInstanceResource ManagedInstanceCollection collection = resourceGroupResource.GetManagedInstances(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceResource item in collection.GetAllAsync()) + // invoke the operation + string managedInstanceName = "testinstance"; + ManagedInstanceData data = new ManagedInstanceData(new AzureLocation("Japan East")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new SqlSku("GP_Gen5") + { + Tier = "GeneralPurpose", + }, + AdministratorLogin = "dummylogin", + AdministratorLoginPassword = "PLACEHOLDER", + SubnetId = new ResourceIdentifier("/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), + LicenseType = ManagedInstanceLicenseType.LicenseIncluded, + VCores = 8, + StorageSizeInGB = 1024, + Collation = "SQL_Latin1_General_CP1_CI_AS", + ManagedDnsZonePartner = new ResourceIdentifier("/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testinstance"), + IsPublicDataEndpointEnabled = false, + ProxyOverride = ManagedInstanceProxyOverride.Redirect, + TimezoneId = "UTC", + InstancePoolId = new ResourceIdentifier("/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Sql/instancePools/pool1"), + MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_MI_1"), + MinimalTlsVersion = "1.2", + RequestedBackupStorageRedundancy = SqlBackupStorageRedundancy.Geo, + Administrators = new ManagedInstanceExternalAdministrator + { + PrincipalType = SqlServerPrincipalType.User, + Login = "bob@contoso.com", + Sid = Guid.Parse("00000011-1111-2222-2222-123456789111"), + TenantId = Guid.Parse("00000011-1111-2222-2222-123456789111"), + IsAzureADOnlyAuthenticationEnabled = true, + }, + ServicePrincipal = new SqlServicePrincipal + { + PrincipalType = SqlServicePrincipalType.SystemAssigned, + }, + Tags = +{ +["tagKey1"] = "TagValue1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedInstanceName, data); + ManagedInstanceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedInstancesByResourceGroupWithExpandAdministratorsActivedirectory() + public async Task CreateOrUpdate_CreateManagedInstanceWithMinimalProperties() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByResourceGroupWithExpandEqualsAdministrators.json - // this example is just showing the usage of "ManagedInstances_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceCreateMin.json + // this example is just showing the usage of "ManagedInstances_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,24 +104,36 @@ public async Task GetAll_ListManagedInstancesByResourceGroupWithExpandAdministra // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; - string resourceGroupName = "Test1"; + string resourceGroupName = "testrg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this ManagedInstanceResource ManagedInstanceCollection collection = resourceGroupResource.GetManagedInstances(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceResource item in collection.GetAllAsync()) + // invoke the operation + string managedInstanceName = "testinstance"; + ManagedInstanceData data = new ManagedInstanceData(new AzureLocation("Japan East")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new SqlSku("GP_Gen4") + { + Tier = "GeneralPurpose", + }, + AdministratorLogin = "dummylogin", + AdministratorLoginPassword = "PLACEHOLDER", + SubnetId = new ResourceIdentifier("/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), + LicenseType = ManagedInstanceLicenseType.LicenseIncluded, + VCores = 8, + StorageSizeInGB = 1024, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedInstanceName, data); + ManagedInstanceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -122,9 +171,9 @@ public async Task Get_GetManagedInstance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagedInstance() + public async Task Get_GetManagedInstanceWithExpandAdministratorsActivedirectory() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGet.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGetWithExpandEqualsAdministrators.json // this example is just showing the usage of "ManagedInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -144,17 +193,21 @@ public async Task Exists_GetManagedInstance() // invoke the operation string managedInstanceName = "testinstance"; - bool result = await collection.ExistsAsync(managedInstanceName); + ManagedInstanceResource result = await collection.GetAsync(managedInstanceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagedInstance() + public async Task GetAll_ListManagedInstancesByResourceGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGet.json - // this example is just showing the usage of "ManagedInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByResourceGroup.json + // this example is just showing the usage of "ManagedInstances_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -163,39 +216,33 @@ public async Task GetIfExists_GetManagedInstance() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "20d7082a-0fc7-4468-82bd-542694d5042b"; - string resourceGroupName = "testrg"; + string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; + string resourceGroupName = "Test1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this ManagedInstanceResource ManagedInstanceCollection collection = resourceGroupResource.GetManagedInstances(); - // invoke the operation - string managedInstanceName = "testinstance"; - NullableResponse response = await collection.GetIfExistsAsync(managedInstanceName); - ManagedInstanceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedInstanceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = result.Data; + ManagedInstanceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedInstanceWithExpandAdministratorsActivedirectory() + public async Task GetAll_ListManagedInstancesByResourceGroupWithExpandAdministratorsActivedirectory() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGetWithExpandEqualsAdministrators.json - // this example is just showing the usage of "ManagedInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListByResourceGroupWithExpandEqualsAdministrators.json + // this example is just showing the usage of "ManagedInstances_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,30 +251,32 @@ public async Task Get_GetManagedInstanceWithExpandAdministratorsActivedirectory( // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "20d7082a-0fc7-4468-82bd-542694d5042b"; - string resourceGroupName = "testrg"; + string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; + string resourceGroupName = "Test1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this ManagedInstanceResource ManagedInstanceCollection collection = resourceGroupResource.GetManagedInstances(); - // invoke the operation - string managedInstanceName = "testinstance"; - ManagedInstanceResource result = await collection.GetAsync(managedInstanceName); + // invoke the operation and iterate over the result + await foreach (ManagedInstanceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagedInstanceWithExpandAdministratorsActivedirectory() + public async Task Exists_GetManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGetWithExpandEqualsAdministrators.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGet.json // this example is just showing the usage of "ManagedInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -254,7 +303,7 @@ public async Task Exists_GetManagedInstanceWithExpandAdministratorsActivedirecto [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagedInstanceWithExpandAdministratorsActivedirectory() + public async Task Exists_GetManagedInstanceWithExpandAdministratorsActivedirectory() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGetWithExpandEqualsAdministrators.json // this example is just showing the usage of "ManagedInstances_Get" operation, for the dependent resources, they will have to be created separately. @@ -276,29 +325,17 @@ public async Task GetIfExists_GetManagedInstanceWithExpandAdministratorsActivedi // invoke the operation string managedInstanceName = "testinstance"; - NullableResponse response = await collection.GetIfExistsAsync(managedInstanceName); - ManagedInstanceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(managedInstanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateManagedInstanceWithAllProperties() + public async Task GetIfExists_GetManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceCreateMax.json - // this example is just showing the usage of "ManagedInstances_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGet.json + // this example is just showing the usage of "ManagedInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -307,7 +344,7 @@ public async Task CreateOrUpdate_CreateManagedInstanceWithAllProperties() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; + string subscriptionId = "20d7082a-0fc7-4468-82bd-542694d5042b"; string resourceGroupName = "testrg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -317,60 +354,29 @@ public async Task CreateOrUpdate_CreateManagedInstanceWithAllProperties() // invoke the operation string managedInstanceName = "testinstance"; - ManagedInstanceData data = new ManagedInstanceData(new AzureLocation("Japan East")) - { - Sku = new SqlSku("GP_Gen5") - { - Tier = "GeneralPurpose", - }, - AdministratorLogin = "dummylogin", - AdministratorLoginPassword = "PLACEHOLDER", - SubnetId = new ResourceIdentifier("/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), - LicenseType = ManagedInstanceLicenseType.LicenseIncluded, - VCores = 8, - StorageSizeInGB = 1024, - Collation = "SQL_Latin1_General_CP1_CI_AS", - ManagedDnsZonePartner = new ResourceIdentifier("/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testinstance"), - IsPublicDataEndpointEnabled = false, - ProxyOverride = ManagedInstanceProxyOverride.Redirect, - TimezoneId = "UTC", - InstancePoolId = new ResourceIdentifier("/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Sql/instancePools/pool1"), - MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_JapanEast_MI_1"), - MinimalTlsVersion = "1.2", - RequestedBackupStorageRedundancy = SqlBackupStorageRedundancy.Geo, - Administrators = new ManagedInstanceExternalAdministrator() - { - PrincipalType = SqlServerPrincipalType.User, - Login = "bob@contoso.com", - Sid = Guid.Parse("00000011-1111-2222-2222-123456789111"), - TenantId = Guid.Parse("00000011-1111-2222-2222-123456789111"), - IsAzureADOnlyAuthenticationEnabled = true, - }, - ServicePrincipal = new SqlServicePrincipal() - { - PrincipalType = SqlServicePrincipalType.SystemAssigned, - }, - Tags = -{ -["tagKey1"] = "TagValue1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedInstanceName, data); - ManagedInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(managedInstanceName); + ManagedInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateManagedInstanceWithMinimalProperties() + public async Task GetIfExists_GetManagedInstanceWithExpandAdministratorsActivedirectory() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceCreateMin.json - // this example is just showing the usage of "ManagedInstances_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceGetWithExpandEqualsAdministrators.json + // this example is just showing the usage of "ManagedInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -379,7 +385,7 @@ public async Task CreateOrUpdate_CreateManagedInstanceWithMinimalProperties() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; + string subscriptionId = "20d7082a-0fc7-4468-82bd-542694d5042b"; string resourceGroupName = "testrg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -389,27 +395,21 @@ public async Task CreateOrUpdate_CreateManagedInstanceWithMinimalProperties() // invoke the operation string managedInstanceName = "testinstance"; - ManagedInstanceData data = new ManagedInstanceData(new AzureLocation("Japan East")) - { - Sku = new SqlSku("GP_Gen4") - { - Tier = "GeneralPurpose", - }, - AdministratorLogin = "dummylogin", - AdministratorLoginPassword = "PLACEHOLDER", - SubnetId = new ResourceIdentifier("/subscriptions/20D7082A-0FC7-4468-82BD-542694D5042B/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), - LicenseType = ManagedInstanceLicenseType.LicenseIncluded, - VCores = 8, - StorageSizeInGB = 1024, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedInstanceName, data); - ManagedInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(managedInstanceName); + ManagedInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceDtcCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceDtcCollection.cs index 7cac386d1597c..0277cb19b0ffd 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceDtcCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceDtcCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstanceDtcCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfManagedInstanceDTCSettings() + public async Task CreateOrUpdate_UpdatesManagedInstanceDTCSettingsByEnablingDTC() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcList.json - // this example is just showing the usage of "ManagedInstanceDtcs_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcUpdateEnableDtc.json + // this example is just showing the usage of "ManagedInstanceDtcs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_GetsAListOfManagedInstanceDTCSettings() // get the collection of this ManagedInstanceDtcResource ManagedInstanceDtcCollection collection = managedInstance.GetManagedInstanceDtcs(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceDtcResource item in collection.GetAllAsync()) + // invoke the operation + DtcName dtcName = DtcName.Current; + ManagedInstanceDtcData data = new ManagedInstanceDtcData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceDtcData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DtcEnabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dtcName, data); + ManagedInstanceDtcResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceDtcData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsManagedInstanceDTCSettings() + public async Task CreateOrUpdate_UpdatesManagedInstanceDTCSettingsWithAllOptionalParametersSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcGet.json - // this example is just showing the usage of "ManagedInstanceDtcs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcUpdateMax.json + // this example is just showing the usage of "ManagedInstanceDtcs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +80,26 @@ public async Task Get_GetsManagedInstanceDTCSettings() // invoke the operation DtcName dtcName = DtcName.Current; - ManagedInstanceDtcResource result = await collection.GetAsync(dtcName); + ManagedInstanceDtcData data = new ManagedInstanceDtcData + { + DtcEnabled = true, + SecuritySettings = new ManagedInstanceDtcSecuritySettings + { + TransactionManagerCommunicationSettings = new ManagedInstanceDtcTransactionManagerCommunicationSettings + { + AllowInboundEnabled = false, + AllowOutboundEnabled = true, + Authentication = "NoAuth", + }, + IsXATransactionsEnabled = false, + SnaLu6Point2TransactionsEnabled = false, + XATransactionsDefaultTimeoutInSeconds = 1000, + XATransactionsMaximumTimeoutInSeconds = 3000, + }, + ExternalDnsSuffixSearchList = { "dns.example1.com", "dns.example2.com" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dtcName, data); + ManagedInstanceDtcResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +110,7 @@ public async Task Get_GetsManagedInstanceDTCSettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsManagedInstanceDTCSettings() + public async Task Get_GetsManagedInstanceDTCSettings() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcGet.json // this example is just showing the usage of "ManagedInstanceDtcs_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +133,21 @@ public async Task Exists_GetsManagedInstanceDTCSettings() // invoke the operation DtcName dtcName = DtcName.Current; - bool result = await collection.ExistsAsync(dtcName); + ManagedInstanceDtcResource result = await collection.GetAsync(dtcName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceDtcData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsManagedInstanceDTCSettings() + public async Task GetAll_GetsAListOfManagedInstanceDTCSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcGet.json - // this example is just showing the usage of "ManagedInstanceDtcs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcList.json + // this example is just showing the usage of "ManagedInstanceDtcs_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +165,25 @@ public async Task GetIfExists_GetsManagedInstanceDTCSettings() // get the collection of this ManagedInstanceDtcResource ManagedInstanceDtcCollection collection = managedInstance.GetManagedInstanceDtcs(); - // invoke the operation - DtcName dtcName = DtcName.Current; - NullableResponse response = await collection.GetIfExistsAsync(dtcName); - ManagedInstanceDtcResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedInstanceDtcResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceDtcData resourceData = result.Data; + ManagedInstanceDtcData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatesManagedInstanceDTCSettingsByEnablingDTC() + public async Task Exists_GetsManagedInstanceDTCSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcUpdateEnableDtc.json - // this example is just showing the usage of "ManagedInstanceDtcs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcGet.json + // this example is just showing the usage of "ManagedInstanceDtcs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +203,17 @@ public async Task CreateOrUpdate_UpdatesManagedInstanceDTCSettingsByEnablingDTC( // invoke the operation DtcName dtcName = DtcName.Current; - ManagedInstanceDtcData data = new ManagedInstanceDtcData() - { - DtcEnabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dtcName, data); - ManagedInstanceDtcResource result = lro.Value; + bool result = await collection.ExistsAsync(dtcName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceDtcData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatesManagedInstanceDTCSettingsWithAllOptionalParametersSpecified() + public async Task GetIfExists_GetsManagedInstanceDTCSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcUpdateMax.json - // this example is just showing the usage of "ManagedInstanceDtcs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/ManagedInstanceDtcGet.json + // this example is just showing the usage of "ManagedInstanceDtcs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -222,35 +233,21 @@ public async Task CreateOrUpdate_UpdatesManagedInstanceDTCSettingsWithAllOptiona // invoke the operation DtcName dtcName = DtcName.Current; - ManagedInstanceDtcData data = new ManagedInstanceDtcData() - { - DtcEnabled = true, - SecuritySettings = new ManagedInstanceDtcSecuritySettings() - { - TransactionManagerCommunicationSettings = new ManagedInstanceDtcTransactionManagerCommunicationSettings() - { - AllowInboundEnabled = false, - AllowOutboundEnabled = true, - Authentication = "NoAuth", - }, - IsXATransactionsEnabled = false, - SnaLu6Point2TransactionsEnabled = false, - XATransactionsDefaultTimeoutInSeconds = 1000, - XATransactionsMaximumTimeoutInSeconds = 3000, - }, - ExternalDnsSuffixSearchList = -{ -"dns.example1.com","dns.example2.com" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dtcName, data); - ManagedInstanceDtcResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dtcName); + ManagedInstanceDtcResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceDtcData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceDtcData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceDtcResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceDtcResource.cs index 0ee85308f038a..716ead020e027 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceDtcResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceDtcResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdatesManagedInstanceDTCSettingsByEnablingDTC() ManagedInstanceDtcResource managedInstanceDtc = client.GetManagedInstanceDtcResource(managedInstanceDtcResourceId); // invoke the operation - ManagedInstanceDtcData data = new ManagedInstanceDtcData() + ManagedInstanceDtcData data = new ManagedInstanceDtcData { DtcEnabled = true, }; @@ -105,12 +105,12 @@ public async Task Update_UpdatesManagedInstanceDTCSettingsWithAllOptionalParamet ManagedInstanceDtcResource managedInstanceDtc = client.GetManagedInstanceDtcResource(managedInstanceDtcResourceId); // invoke the operation - ManagedInstanceDtcData data = new ManagedInstanceDtcData() + ManagedInstanceDtcData data = new ManagedInstanceDtcData { DtcEnabled = true, - SecuritySettings = new ManagedInstanceDtcSecuritySettings() + SecuritySettings = new ManagedInstanceDtcSecuritySettings { - TransactionManagerCommunicationSettings = new ManagedInstanceDtcTransactionManagerCommunicationSettings() + TransactionManagerCommunicationSettings = new ManagedInstanceDtcTransactionManagerCommunicationSettings { AllowInboundEnabled = false, AllowOutboundEnabled = true, @@ -121,10 +121,7 @@ public async Task Update_UpdatesManagedInstanceDTCSettingsWithAllOptionalParamet XATransactionsDefaultTimeoutInSeconds = 1000, XATransactionsMaximumTimeoutInSeconds = 3000, }, - ExternalDnsSuffixSearchList = -{ -"dns.example1.com","dns.example2.com" -}, + ExternalDnsSuffixSearchList = { "dns.example1.com", "dns.example2.com" }, }; ArmOperation lro = await managedInstanceDtc.UpdateAsync(WaitUntil.Completed, data); ManagedInstanceDtcResource result = lro.Value; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceEncryptionProtectorCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceEncryptionProtectorCollection.cs index 4aff7531e71ab..c987cfae63cd1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceEncryptionProtectorCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceEncryptionProtectorCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstanceEncryptionProtectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEncryptionProtectorsByManagedInstance() + public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToKeyVault() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorList.json - // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorCreateOrUpdateKeyVault.json + // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,30 @@ public async Task GetAll_ListEncryptionProtectorsByManagedInstance() // get the collection of this ManagedInstanceEncryptionProtectorResource ManagedInstanceEncryptionProtectorCollection collection = managedInstance.GetManagedInstanceEncryptionProtectors(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceEncryptionProtectorResource item in collection.GetAllAsync()) + // invoke the operation + EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; + ManagedInstanceEncryptionProtectorData data = new ManagedInstanceEncryptionProtectorData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceEncryptionProtectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServerKeyName = "someVault_someKey_01234567890123456789012345678901", + ServerKeyType = SqlServerKeyType.AzureKeyVault, + IsAutoRotationEnabled = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); + ManagedInstanceEncryptionProtectorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceEncryptionProtectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheEncryptionProtector() + public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToServiceManaged() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorGet.json - // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorCreateOrUpdateServiceManaged.json + // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +82,13 @@ public async Task Get_GetTheEncryptionProtector() // invoke the operation EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - ManagedInstanceEncryptionProtectorResource result = await collection.GetAsync(encryptionProtectorName); + ManagedInstanceEncryptionProtectorData data = new ManagedInstanceEncryptionProtectorData + { + ServerKeyName = "ServiceManaged", + ServerKeyType = SqlServerKeyType.ServiceManaged, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); + ManagedInstanceEncryptionProtectorResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +99,7 @@ public async Task Get_GetTheEncryptionProtector() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheEncryptionProtector() + public async Task Get_GetTheEncryptionProtector() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorGet.json // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +122,21 @@ public async Task Exists_GetTheEncryptionProtector() // invoke the operation EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - bool result = await collection.ExistsAsync(encryptionProtectorName); + ManagedInstanceEncryptionProtectorResource result = await collection.GetAsync(encryptionProtectorName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceEncryptionProtectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheEncryptionProtector() + public async Task GetAll_ListEncryptionProtectorsByManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorGet.json - // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorList.json + // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +154,25 @@ public async Task GetIfExists_GetTheEncryptionProtector() // get the collection of this ManagedInstanceEncryptionProtectorResource ManagedInstanceEncryptionProtectorCollection collection = managedInstance.GetManagedInstanceEncryptionProtectors(); - // invoke the operation - EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - NullableResponse response = await collection.GetIfExistsAsync(encryptionProtectorName); - ManagedInstanceEncryptionProtectorResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedInstanceEncryptionProtectorResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceEncryptionProtectorData resourceData = result.Data; + ManagedInstanceEncryptionProtectorData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToKeyVault() + public async Task Exists_GetTheEncryptionProtector() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorCreateOrUpdateKeyVault.json - // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorGet.json + // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,28 +192,17 @@ public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToKeyVault() // invoke the operation EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - ManagedInstanceEncryptionProtectorData data = new ManagedInstanceEncryptionProtectorData() - { - ServerKeyName = "someVault_someKey_01234567890123456789012345678901", - ServerKeyType = SqlServerKeyType.AzureKeyVault, - IsAutoRotationEnabled = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); - ManagedInstanceEncryptionProtectorResource result = lro.Value; + bool result = await collection.ExistsAsync(encryptionProtectorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceEncryptionProtectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToServiceManaged() + public async Task GetIfExists_GetTheEncryptionProtector() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorCreateOrUpdateServiceManaged.json - // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorGet.json + // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -224,19 +222,21 @@ public async Task CreateOrUpdate_UpdateTheEncryptionProtectorToServiceManaged() // invoke the operation EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - ManagedInstanceEncryptionProtectorData data = new ManagedInstanceEncryptionProtectorData() - { - ServerKeyName = "ServiceManaged", - ServerKeyType = SqlServerKeyType.ServiceManaged, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, encryptionProtectorName, data); - ManagedInstanceEncryptionProtectorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(encryptionProtectorName); + ManagedInstanceEncryptionProtectorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceEncryptionProtectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceEncryptionProtectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceEncryptionProtectorResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceEncryptionProtectorResource.cs index 0c799d259bf58..39f013e4db7ad 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceEncryptionProtectorResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceEncryptionProtectorResource.cs @@ -16,33 +16,6 @@ namespace Azure.ResourceManager.Sql.Samples { public partial class Sample_ManagedInstanceEncryptionProtectorResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Revalidate_RevalidatesTheEncryptionProtector() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorRevalidate.json - // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_Revalidate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedInstanceEncryptionProtectorResource created on azure - // for more information of creating ManagedInstanceEncryptionProtectorResource, please refer to the document of ManagedInstanceEncryptionProtectorResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-7398"; - string managedInstanceName = "sqlcrudtest-4645"; - EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - ResourceIdentifier managedInstanceEncryptionProtectorResourceId = ManagedInstanceEncryptionProtectorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, encryptionProtectorName); - ManagedInstanceEncryptionProtectorResource managedInstanceEncryptionProtector = client.GetManagedInstanceEncryptionProtectorResource(managedInstanceEncryptionProtectorResourceId); - - // invoke the operation - await managedInstanceEncryptionProtector.RevalidateAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetTheEncryptionProtector() @@ -96,7 +69,7 @@ public async Task Update_UpdateTheEncryptionProtectorToKeyVault() ManagedInstanceEncryptionProtectorResource managedInstanceEncryptionProtector = client.GetManagedInstanceEncryptionProtectorResource(managedInstanceEncryptionProtectorResourceId); // invoke the operation - ManagedInstanceEncryptionProtectorData data = new ManagedInstanceEncryptionProtectorData() + ManagedInstanceEncryptionProtectorData data = new ManagedInstanceEncryptionProtectorData { ServerKeyName = "someVault_someKey_01234567890123456789012345678901", ServerKeyType = SqlServerKeyType.AzureKeyVault, @@ -134,7 +107,7 @@ public async Task Update_UpdateTheEncryptionProtectorToServiceManaged() ManagedInstanceEncryptionProtectorResource managedInstanceEncryptionProtector = client.GetManagedInstanceEncryptionProtectorResource(managedInstanceEncryptionProtectorResourceId); // invoke the operation - ManagedInstanceEncryptionProtectorData data = new ManagedInstanceEncryptionProtectorData() + ManagedInstanceEncryptionProtectorData data = new ManagedInstanceEncryptionProtectorData { ServerKeyName = "ServiceManaged", ServerKeyType = SqlServerKeyType.ServiceManaged, @@ -148,5 +121,32 @@ public async Task Update_UpdateTheEncryptionProtectorToServiceManaged() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Revalidate_RevalidatesTheEncryptionProtector() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceEncryptionProtectorRevalidate.json + // this example is just showing the usage of "ManagedInstanceEncryptionProtectors_Revalidate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedInstanceEncryptionProtectorResource created on azure + // for more information of creating ManagedInstanceEncryptionProtectorResource, please refer to the document of ManagedInstanceEncryptionProtectorResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "sqlcrudtest-7398"; + string managedInstanceName = "sqlcrudtest-4645"; + EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; + ResourceIdentifier managedInstanceEncryptionProtectorResourceId = ManagedInstanceEncryptionProtectorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, encryptionProtectorName); + ManagedInstanceEncryptionProtectorResource managedInstanceEncryptionProtector = client.GetManagedInstanceEncryptionProtectorResource(managedInstanceEncryptionProtectorResourceId); + + // invoke the operation + await managedInstanceEncryptionProtector.RevalidateAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceKeyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceKeyCollection.cs index c79f47160c3dc..54cd8c159952c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceKeyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceKeyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstanceKeyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheKeysForAManagedInstance() + public async Task CreateOrUpdate_CreatesOrUpdatesAManagedInstanceKey() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyList.json - // this example is just showing the usage of "ManagedInstanceKeys_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyCreateOrUpdate.json + // this example is just showing the usage of "ManagedInstanceKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ListTheKeysForAManagedInstance() // get the collection of this ManagedInstanceKeyResource ManagedInstanceKeyCollection collection = managedInstance.GetManagedInstanceKeys(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceKeyResource item in collection.GetAllAsync()) + // invoke the operation + string keyName = "someVault_someKey_01234567890123456789012345678901"; + ManagedInstanceKeyData data = new ManagedInstanceKeyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServerKeyType = SqlServerKeyType.AzureKeyVault, + Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, data); + ManagedInstanceKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_GetTheManagedInstanceKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheManagedInstanceKey() + public async Task GetAll_ListTheKeysForAManagedInstance() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyGet.json - // this example is just showing the usage of "ManagedInstanceKeys_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyList.json + // this example is just showing the usage of "ManagedInstanceKeys_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +113,22 @@ public async Task Exists_GetTheManagedInstanceKey() // get the collection of this ManagedInstanceKeyResource ManagedInstanceKeyCollection collection = managedInstance.GetManagedInstanceKeys(); - // invoke the operation - string keyName = "someVault_someKey_01234567890123456789012345678901"; - bool result = await collection.ExistsAsync(keyName); + // invoke the operation and iterate over the result + await foreach (ManagedInstanceKeyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheManagedInstanceKey() + public async Task Exists_GetTheManagedInstanceKey() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyGet.json // this example is just showing the usage of "ManagedInstanceKeys_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_GetTheManagedInstanceKey() // invoke the operation string keyName = "someVault_someKey_01234567890123456789012345678901"; - NullableResponse response = await collection.GetIfExistsAsync(keyName); - ManagedInstanceKeyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(keyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesAManagedInstanceKey() + public async Task GetIfExists_GetTheManagedInstanceKey() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyCreateOrUpdate.json - // this example is just showing the usage of "ManagedInstanceKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyGet.json + // this example is just showing the usage of "ManagedInstanceKeys_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,19 +181,21 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAManagedInstanceKey() // invoke the operation string keyName = "someVault_someKey_01234567890123456789012345678901"; - ManagedInstanceKeyData data = new ManagedInstanceKeyData() - { - ServerKeyType = SqlServerKeyType.AzureKeyVault, - Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, data); - ManagedInstanceKeyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(keyName); + ManagedInstanceKeyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceKeyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceKeyResource.cs index 7b16cd26f2b38..894e461a49510 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceKeyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceKeyResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetTheManagedInstanceKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesAManagedInstanceKey() + public async Task Delete_DeleteTheManagedInstanceKey() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyCreateOrUpdate.json - // this example is just showing the usage of "ManagedInstanceKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyDelete.json + // this example is just showing the usage of "ManagedInstanceKeys_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,27 +69,17 @@ public async Task Update_CreatesOrUpdatesAManagedInstanceKey() ManagedInstanceKeyResource managedInstanceKey = client.GetManagedInstanceKeyResource(managedInstanceKeyResourceId); // invoke the operation - ManagedInstanceKeyData data = new ManagedInstanceKeyData() - { - ServerKeyType = SqlServerKeyType.AzureKeyVault, - Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), - }; - ArmOperation lro = await managedInstanceKey.UpdateAsync(WaitUntil.Completed, data); - ManagedInstanceKeyResource result = lro.Value; + await managedInstanceKey.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteTheManagedInstanceKey() + public async Task Update_CreatesOrUpdatesAManagedInstanceKey() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyDelete.json - // this example is just showing the usage of "ManagedInstanceKeys_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceKeyCreateOrUpdate.json + // this example is just showing the usage of "ManagedInstanceKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +96,19 @@ public async Task Delete_DeleteTheManagedInstanceKey() ManagedInstanceKeyResource managedInstanceKey = client.GetManagedInstanceKeyResource(managedInstanceKeyResourceId); // invoke the operation - await managedInstanceKey.DeleteAsync(WaitUntil.Completed); + ManagedInstanceKeyData data = new ManagedInstanceKeyData + { + ServerKeyType = SqlServerKeyType.AzureKeyVault, + Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + }; + ArmOperation lro = await managedInstanceKey.UpdateAsync(WaitUntil.Completed, data); + ManagedInstanceKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceLongTermRetentionPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceLongTermRetentionPolicyCollection.cs index b8af790f37960..fb55b8c7119d3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceLongTermRetentionPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceLongTermRetentionPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstanceLongTermRetentionPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheLongTermRetentionPolicyForTheManagedDatabase() + public async Task CreateOrUpdate_CreateOrUpdateTheLTRPolicyForTheManagedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyGet.json - // this example is just showing the usage of "ManagedInstanceLongTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyCreateOrUpdate.json + // this example is just showing the usage of "ManagedInstanceLongTermRetentionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,15 @@ public async Task Get_GetTheLongTermRetentionPolicyForTheManagedDatabase() // invoke the operation ManagedInstanceLongTermRetentionPolicyName policyName = ManagedInstanceLongTermRetentionPolicyName.Default; - ManagedInstanceLongTermRetentionPolicyResource result = await collection.GetAsync(policyName); + ManagedInstanceLongTermRetentionPolicyData data = new ManagedInstanceLongTermRetentionPolicyData + { + WeeklyRetention = "P1M", + MonthlyRetention = "P1Y", + YearlyRetention = "P5Y", + WeekOfYear = 5, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + ManagedInstanceLongTermRetentionPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +61,7 @@ public async Task Get_GetTheLongTermRetentionPolicyForTheManagedDatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheLongTermRetentionPolicyForTheManagedDatabase() + public async Task Get_GetTheLongTermRetentionPolicyForTheManagedDatabase() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyGet.json // this example is just showing the usage of "ManagedInstanceLongTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +85,21 @@ public async Task Exists_GetTheLongTermRetentionPolicyForTheManagedDatabase() // invoke the operation ManagedInstanceLongTermRetentionPolicyName policyName = ManagedInstanceLongTermRetentionPolicyName.Default; - bool result = await collection.ExistsAsync(policyName); + ManagedInstanceLongTermRetentionPolicyResource result = await collection.GetAsync(policyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceLongTermRetentionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheLongTermRetentionPolicyForTheManagedDatabase() + public async Task GetAll_GetTheLongTermRetentionPoliciesForTheManagedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyGet.json - // this example is just showing the usage of "ManagedInstanceLongTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyListByDatabase.json + // this example is just showing the usage of "ManagedInstanceLongTermRetentionPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +118,25 @@ public async Task GetIfExists_GetTheLongTermRetentionPolicyForTheManagedDatabase // get the collection of this ManagedInstanceLongTermRetentionPolicyResource ManagedInstanceLongTermRetentionPolicyCollection collection = managedDatabase.GetManagedInstanceLongTermRetentionPolicies(); - // invoke the operation - ManagedInstanceLongTermRetentionPolicyName policyName = ManagedInstanceLongTermRetentionPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - ManagedInstanceLongTermRetentionPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedInstanceLongTermRetentionPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceLongTermRetentionPolicyData resourceData = result.Data; + ManagedInstanceLongTermRetentionPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateTheLTRPolicyForTheManagedDatabase() + public async Task Exists_GetTheLongTermRetentionPolicyForTheManagedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyCreateOrUpdate.json - // this example is just showing the usage of "ManagedInstanceLongTermRetentionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyGet.json + // this example is just showing the usage of "ManagedInstanceLongTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,29 +157,17 @@ public async Task CreateOrUpdate_CreateOrUpdateTheLTRPolicyForTheManagedDatabase // invoke the operation ManagedInstanceLongTermRetentionPolicyName policyName = ManagedInstanceLongTermRetentionPolicyName.Default; - ManagedInstanceLongTermRetentionPolicyData data = new ManagedInstanceLongTermRetentionPolicyData() - { - WeeklyRetention = "P1M", - MonthlyRetention = "P1Y", - YearlyRetention = "P5Y", - WeekOfYear = 5, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - ManagedInstanceLongTermRetentionPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(policyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceLongTermRetentionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheLongTermRetentionPoliciesForTheManagedDatabase() + public async Task GetIfExists_GetTheLongTermRetentionPolicyForTheManagedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyListByDatabase.json - // this example is just showing the usage of "ManagedInstanceLongTermRetentionPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceLongTermRetentionPolicyGet.json + // this example is just showing the usage of "ManagedInstanceLongTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,17 +186,23 @@ public async Task GetAll_GetTheLongTermRetentionPoliciesForTheManagedDatabase() // get the collection of this ManagedInstanceLongTermRetentionPolicyResource ManagedInstanceLongTermRetentionPolicyCollection collection = managedDatabase.GetManagedInstanceLongTermRetentionPolicies(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceLongTermRetentionPolicyResource item in collection.GetAllAsync()) + // invoke the operation + ManagedInstanceLongTermRetentionPolicyName policyName = ManagedInstanceLongTermRetentionPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + ManagedInstanceLongTermRetentionPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceLongTermRetentionPolicyData resourceData = item.Data; + ManagedInstanceLongTermRetentionPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceLongTermRetentionPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceLongTermRetentionPolicyResource.cs index 22fc541ceb21b..cee3e60302b20 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceLongTermRetentionPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceLongTermRetentionPolicyResource.cs @@ -71,7 +71,7 @@ public async Task Update_CreateOrUpdateTheLTRPolicyForTheManagedDatabase() ManagedInstanceLongTermRetentionPolicyResource managedInstanceLongTermRetentionPolicy = client.GetManagedInstanceLongTermRetentionPolicyResource(managedInstanceLongTermRetentionPolicyResourceId); // invoke the operation - ManagedInstanceLongTermRetentionPolicyData data = new ManagedInstanceLongTermRetentionPolicyData() + ManagedInstanceLongTermRetentionPolicyData data = new ManagedInstanceLongTermRetentionPolicyData { WeeklyRetention = "P1M", MonthlyRetention = "P1Y", diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceOperationCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceOperationCollection.cs index 4a83e29fa4658..a88e1288ed156 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceOperationCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceOperationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ManagedInstanceOperationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheManagedInstanceManagementOperations() + public async Task Get_GetsTheManagedInstanceManagementOperation() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListManagedInstanceOperations.json - // this example is just showing the usage of "ManagedInstanceOperations_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedInstanceOperation.json + // this example is just showing the usage of "ManagedInstanceOperations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListTheManagedInstanceManagementOperations() // get the collection of this ManagedInstanceOperationResource ManagedInstanceOperationCollection collection = managedInstance.GetManagedInstanceOperations(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceOperationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceOperationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + Guid operationId = Guid.Parse("00000000-1111-2222-3333-444444444444"); + ManagedInstanceOperationResource result = await collection.GetAsync(operationId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheManagedInstanceManagementOperation() + public async Task GetAll_ListTheManagedInstanceManagementOperations() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedInstanceOperation.json - // this example is just showing the usage of "ManagedInstanceOperations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListManagedInstanceOperations.json + // this example is just showing the usage of "ManagedInstanceOperations_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsTheManagedInstanceManagementOperation() // get the collection of this ManagedInstanceOperationResource ManagedInstanceOperationCollection collection = managedInstance.GetManagedInstanceOperations(); - // invoke the operation - Guid operationId = Guid.Parse("00000000-1111-2222-3333-444444444444"); - ManagedInstanceOperationResource result = await collection.GetAsync(operationId); + // invoke the operation and iterate over the result + await foreach (ManagedInstanceOperationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceOperationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateEndpointConnectionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateEndpointConnectionCollection.cs index 88b5bb2ccc860..35b4b9c534ce1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateEndpointConnectionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstancePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateEndpointConnection() + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionGet.json - // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - ManagedInstancePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + ManagedInstancePrivateEndpointConnectionData data = new ManagedInstancePrivateEndpointConnectionData + { + ConnectionState = new ManagedInstancePrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + ManagedInstancePrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task Get_GetsPrivateEndpointConnection() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionGet.json // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + ManagedInstancePrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstancePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionGet.json - // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionList.json + // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // get the collection of this ManagedInstancePrivateEndpointConnectionResource ManagedInstancePrivateEndpointConnectionCollection collection = managedInstance.GetManagedInstancePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - ManagedInstancePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedInstancePrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstancePrivateEndpointConnectionData resourceData = result.Data; + ManagedInstancePrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Exists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionGet.json + // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - ManagedInstancePrivateEndpointConnectionData data = new ManagedInstancePrivateEndpointConnectionData() - { - ConnectionState = new ManagedInstancePrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - ManagedInstancePrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstancePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionList.json - // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionGet.json + // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() // get the collection of this ManagedInstancePrivateEndpointConnectionResource ManagedInstancePrivateEndpointConnectionCollection collection = managedInstance.GetManagedInstancePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (ManagedInstancePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + ManagedInstancePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstancePrivateEndpointConnectionData resourceData = item.Data; + ManagedInstancePrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateEndpointConnectionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateEndpointConnectionResource.cs index df4215639f8c6..76186aceb1f7b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateEndpointConnectionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionDelete.json + // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName ManagedInstancePrivateEndpointConnectionResource managedInstancePrivateEndpointConnection = client.GetManagedInstancePrivateEndpointConnectionResource(managedInstancePrivateEndpointConnectionResourceId); // invoke the operation - ManagedInstancePrivateEndpointConnectionData data = new ManagedInstancePrivateEndpointConnectionData() - { - ConnectionState = new ManagedInstancePrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), - }; - ArmOperation lro = await managedInstancePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - ManagedInstancePrivateEndpointConnectionResource result = lro.Value; + await managedInstancePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstancePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionDelete.json - // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "ManagedInstancePrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() ManagedInstancePrivateEndpointConnectionResource managedInstancePrivateEndpointConnection = client.GetManagedInstancePrivateEndpointConnectionResource(managedInstancePrivateEndpointConnectionResourceId); // invoke the operation - await managedInstancePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + ManagedInstancePrivateEndpointConnectionData data = new ManagedInstancePrivateEndpointConnectionData + { + ConnectionState = new ManagedInstancePrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), + }; + ArmOperation lro = await managedInstancePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ManagedInstancePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstancePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateLinkCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateLinkCollection.cs index bf05ef05c997a..9790c47ae04a3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateLinkCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstancePrivateLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ManagedInstancePrivateLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateLinkResourcesForSQL() + public async Task Get_GetsAPrivateLinkResourceForSQL() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateLinkResourcesList.json - // this example is just showing the usage of "ManagedInstancePrivateLinkResources_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateLinkResourcesGet.json + // this example is just showing the usage of "ManagedInstancePrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetsPrivateLinkResourcesForSQL() // get the collection of this ManagedInstancePrivateLinkResource ManagedInstancePrivateLinkCollection collection = managedInstance.GetManagedInstancePrivateLinks(); - // invoke the operation and iterate over the result - await foreach (ManagedInstancePrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstancePrivateLinkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "plr"; + ManagedInstancePrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstancePrivateLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAPrivateLinkResourceForSQL() + public async Task GetAll_GetsPrivateLinkResourcesForSQL() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateLinkResourcesGet.json - // this example is just showing the usage of "ManagedInstancePrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstancePrivateLinkResourcesList.json + // this example is just showing the usage of "ManagedInstancePrivateLinkResources_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsAPrivateLinkResourceForSQL() // get the collection of this ManagedInstancePrivateLinkResource ManagedInstancePrivateLinkCollection collection = managedInstance.GetManagedInstancePrivateLinks(); - // invoke the operation - string groupName = "plr"; - ManagedInstancePrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (ManagedInstancePrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstancePrivateLinkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstancePrivateLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceResource.cs index f5e9cc7b810f3..230c6e050d55e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Sql.Models; using NUnit.Framework; @@ -17,164 +16,6 @@ namespace Azure.ResourceManager.Sql.Samples { public partial class Sample_ManagedInstanceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateManagedInstanceTdeCertificate_UploadATDECertificate() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceTdeCertificate.json - // this example is just showing the usage of "ManagedInstanceTdeCertificates_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedInstanceResource created on azure - // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource - string subscriptionId = "00000000-0000-0000-0000-000000000001"; - string resourceGroupName = "testtdecert"; - string managedInstanceName = "testtdecert"; - ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); - ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); - - // invoke the operation - TdeCertificate tdeCertificate = new TdeCertificate() - { - PrivateBlob = "MIIXXXXXXXX", - }; - await managedInstance.CreateManagedInstanceTdeCertificateAsync(WaitUntil.Completed, tdeCertificate); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSqlServerTrustGroups_ListServerTrustGroupsByManagedInstance() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupListByManagedInstance.json - // this example is just showing the usage of "ServerTrustGroups_ListByInstance" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedInstanceResource created on azure - // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string managedInstanceName = "managedInstance-1"; - ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); - ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); - - // invoke the operation and iterate over the result - await foreach (SqlServerTrustGroupResource item in managedInstance.GetSqlServerTrustGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerTrustGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetInaccessibleManagedDatabases_ListInaccessibleManagedDatabasesByManagedInstances() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/InaccessibleManagedDatabaseListByManagedInstance.json - // this example is just showing the usage of "ManagedDatabases_ListInaccessibleByInstance" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedInstanceResource created on azure - // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "testrg"; - string managedInstanceName = "testcl"; - ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); - ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); - - // invoke the operation and iterate over the result - await foreach (ManagedDatabaseResource item in managedInstance.GetInaccessibleManagedDatabasesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetManagedInstances_ListManagedInstances() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceList.json - // this example is just showing the usage of "ManagedInstances_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ManagedInstanceResource item in subscriptionResource.GetManagedInstancesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetManagedInstances_ListManagedInstancesWithExpandAdministratorsActivedirectory() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListWithExpandEqualsAdministrators.json - // this example is just showing the usage of "ManagedInstances_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ManagedInstanceResource item in subscriptionResource.GetManagedInstancesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetManagedInstance() @@ -282,7 +123,7 @@ public async Task Update_RemoveMaintenancePolicyFromManagedInstanceSelectDefault ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); // invoke the operation - ManagedInstancePatch patch = new ManagedInstancePatch() + ManagedInstancePatch patch = new ManagedInstancePatch { MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/20d7082a-0fc7-4468-82bd-542694d5042b/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default"), }; @@ -317,7 +158,7 @@ public async Task Update_UpdateManagedInstanceWithAllProperties() ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); // invoke the operation - ManagedInstancePatch patch = new ManagedInstancePatch() + ManagedInstancePatch patch = new ManagedInstancePatch { Sku = new SqlSku("GP_Gen4") { @@ -326,7 +167,7 @@ public async Task Update_UpdateManagedInstanceWithAllProperties() }, Tags = { -["tagKey1"] = "TagValue1", +["tagKey1"] = "TagValue1" }, AdministratorLogin = "dummylogin", AdministratorLoginPassword = "PLACEHOLDER", @@ -371,11 +212,11 @@ public async Task Update_UpdateManagedInstanceWithMinimalProperties() ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); // invoke the operation - ManagedInstancePatch patch = new ManagedInstancePatch() + ManagedInstancePatch patch = new ManagedInstancePatch { Tags = { -["tagKey1"] = "TagValue1", +["tagKey1"] = "TagValue1" }, }; ArmOperation lro = await managedInstance.UpdateAsync(WaitUntil.Completed, patch); @@ -388,6 +229,102 @@ public async Task Update_UpdateManagedInstanceWithMinimalProperties() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateManagedInstanceTdeCertificate_UploadATDECertificate() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceTdeCertificate.json + // this example is just showing the usage of "ManagedInstanceTdeCertificates_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedInstanceResource created on azure + // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource + string subscriptionId = "00000000-0000-0000-0000-000000000001"; + string resourceGroupName = "testtdecert"; + string managedInstanceName = "testtdecert"; + ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); + ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); + + // invoke the operation + TdeCertificate tdeCertificate = new TdeCertificate + { + PrivateBlob = "MIIXXXXXXXX", + }; + await managedInstance.CreateManagedInstanceTdeCertificateAsync(WaitUntil.Completed, tdeCertificate); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSqlServerTrustGroups_ListServerTrustGroupsByManagedInstance() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupListByManagedInstance.json + // this example is just showing the usage of "ServerTrustGroups_ListByInstance" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedInstanceResource created on azure + // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string managedInstanceName = "managedInstance-1"; + ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); + ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); + + // invoke the operation and iterate over the result + await foreach (SqlServerTrustGroupResource item in managedInstance.GetSqlServerTrustGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerTrustGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetInaccessibleManagedDatabases_ListInaccessibleManagedDatabasesByManagedInstances() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/InaccessibleManagedDatabaseListByManagedInstance.json + // this example is just showing the usage of "ManagedDatabases_ListInaccessibleByInstance" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedInstanceResource created on azure + // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "testrg"; + string managedInstanceName = "testcl"; + ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); + ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); + + // invoke the operation and iterate over the result + await foreach (ManagedDatabaseResource item in managedInstance.GetInaccessibleManagedDatabasesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Failover_FailoverAManagedInstance() @@ -517,7 +454,7 @@ public async Task GetTopQueries_ObtainListOfInstanceSTopResourceConsumingQueries ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); // invoke the operation and iterate over the result - ManagedInstanceResourceGetTopQueriesOptions options = new ManagedInstanceResourceGetTopQueriesOptions() { Interval = QueryTimeGrainType.PT1H, ObservationMetric = SqlMetricType.Duration }; + ManagedInstanceResourceGetTopQueriesOptions options = new ManagedInstanceResourceGetTopQueriesOptions { Interval = QueryTimeGrainType.PT1H, ObservationMetric = SqlMetricType.Duration }; await foreach (TopQueries item in managedInstance.GetTopQueriesAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -547,7 +484,7 @@ public async Task GetTopQueries_ObtainListOfInstanceSTopResourceConsumingQueries ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); // invoke the operation and iterate over the result - ManagedInstanceResourceGetTopQueriesOptions options = new ManagedInstanceResourceGetTopQueriesOptions() { Databases = "db1,db2", StartTime = "2020-03-10T12:00:00Z", EndTime = "2020-03-12T12:00:00Z", Interval = QueryTimeGrainType.P1D, ObservationMetric = SqlMetricType.Cpu }; + ManagedInstanceResourceGetTopQueriesOptions options = new ManagedInstanceResourceGetTopQueriesOptions { Databases = "db1,db2", StartTime = "2020-03-10T12:00:00Z", EndTime = "2020-03-12T12:00:00Z", Interval = QueryTimeGrainType.P1D, ObservationMetric = SqlMetricType.Cpu }; await foreach (TopQueries item in managedInstance.GetTopQueriesAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -577,7 +514,7 @@ public async Task GetTopQueries_ObtainListOfInstanceSTopResourceConsumingQueries ManagedInstanceResource managedInstance = client.GetManagedInstanceResource(managedInstanceResourceId); // invoke the operation and iterate over the result - ManagedInstanceResourceGetTopQueriesOptions options = new ManagedInstanceResourceGetTopQueriesOptions() { }; + ManagedInstanceResourceGetTopQueriesOptions options = new ManagedInstanceResourceGetTopQueriesOptions(); await foreach (TopQueries item in managedInstance.GetTopQueriesAsync(options)) { Console.WriteLine($"Succeeded: {item}"); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerConfigurationOptionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerConfigurationOptionCollection.cs index db09b167dea37..265dab816b815 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerConfigurationOptionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerConfigurationOptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstanceServerConfigurationOptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfManagedInstanceServerConfigurationOptions() + public async Task CreateOrUpdate_UpdatesManagedInstanceServerConfigurationOption() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerConfigurationOptionList.json - // this example is just showing the usage of "ServerConfigurationOptions_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerConfigurationOptionUpdate.json + // this example is just showing the usage of "ServerConfigurationOptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_GetsAListOfManagedInstanceServerConfigurationOptions() // get the collection of this ManagedInstanceServerConfigurationOptionResource ManagedInstanceServerConfigurationOptionCollection collection = managedInstance.GetManagedInstanceServerConfigurationOptions(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceServerConfigurationOptionResource item in collection.GetAllAsync()) + // invoke the operation + ManagedInstanceServerConfigurationOptionName serverConfigurationOptionName = ManagedInstanceServerConfigurationOptionName.AllowPolybaseExport; + ManagedInstanceServerConfigurationOptionData data = new ManagedInstanceServerConfigurationOptionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceServerConfigurationOptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServerConfigurationOptionValue = 1, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverConfigurationOptionName, data); + ManagedInstanceServerConfigurationOptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceServerConfigurationOptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_GetsManagedInstanceServerConfigurationOption() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsManagedInstanceServerConfigurationOption() + public async Task GetAll_GetsAListOfManagedInstanceServerConfigurationOptions() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerConfigurationOptionGet.json - // this example is just showing the usage of "ServerConfigurationOptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerConfigurationOptionList.json + // this example is just showing the usage of "ServerConfigurationOptions_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_GetsManagedInstanceServerConfigurationOption() // get the collection of this ManagedInstanceServerConfigurationOptionResource ManagedInstanceServerConfigurationOptionCollection collection = managedInstance.GetManagedInstanceServerConfigurationOptions(); - // invoke the operation - ManagedInstanceServerConfigurationOptionName serverConfigurationOptionName = ManagedInstanceServerConfigurationOptionName.AllowPolybaseExport; - bool result = await collection.ExistsAsync(serverConfigurationOptionName); + // invoke the operation and iterate over the result + await foreach (ManagedInstanceServerConfigurationOptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceServerConfigurationOptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsManagedInstanceServerConfigurationOption() + public async Task Exists_GetsManagedInstanceServerConfigurationOption() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerConfigurationOptionGet.json // this example is just showing the usage of "ServerConfigurationOptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_GetsManagedInstanceServerConfigurationOption() // invoke the operation ManagedInstanceServerConfigurationOptionName serverConfigurationOptionName = ManagedInstanceServerConfigurationOptionName.AllowPolybaseExport; - NullableResponse response = await collection.GetIfExistsAsync(serverConfigurationOptionName); - ManagedInstanceServerConfigurationOptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serverConfigurationOptionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceServerConfigurationOptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatesManagedInstanceServerConfigurationOption() + public async Task GetIfExists_GetsManagedInstanceServerConfigurationOption() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerConfigurationOptionUpdate.json - // this example is just showing the usage of "ServerConfigurationOptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ServerConfigurationOptionGet.json + // this example is just showing the usage of "ServerConfigurationOptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_UpdatesManagedInstanceServerConfigurationOption // invoke the operation ManagedInstanceServerConfigurationOptionName serverConfigurationOptionName = ManagedInstanceServerConfigurationOptionName.AllowPolybaseExport; - ManagedInstanceServerConfigurationOptionData data = new ManagedInstanceServerConfigurationOptionData() - { - ServerConfigurationOptionValue = 1, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverConfigurationOptionName, data); - ManagedInstanceServerConfigurationOptionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(serverConfigurationOptionName); + ManagedInstanceServerConfigurationOptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceServerConfigurationOptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceServerConfigurationOptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerConfigurationOptionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerConfigurationOptionResource.cs index 8975a8f6fa7ec..b7e1652d4b5b7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerConfigurationOptionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerConfigurationOptionResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdatesManagedInstanceServerConfigurationOption() ManagedInstanceServerConfigurationOptionResource managedInstanceServerConfigurationOption = client.GetManagedInstanceServerConfigurationOptionResource(managedInstanceServerConfigurationOptionResourceId); // invoke the operation - ManagedInstanceServerConfigurationOptionData data = new ManagedInstanceServerConfigurationOptionData() + ManagedInstanceServerConfigurationOptionData data = new ManagedInstanceServerConfigurationOptionData { ServerConfigurationOptionValue = 1, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerTrustCertificateCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerTrustCertificateCollection.cs index 2fb35a0873723..f3285b0c67098 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerTrustCertificateCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerTrustCertificateCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ManagedInstanceServerTrustCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfServerTrustCertificatesOnAGivenServer() + public async Task CreateOrUpdate_CreateServerTrustCertificate() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesListByInstance.json - // this example is just showing the usage of "ServerTrustCertificates_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesCreate.json + // this example is just showing the usage of "ServerTrustCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -29,7 +29,7 @@ public async Task GetAll_GetsAListOfServerTrustCertificatesOnAGivenServer() // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource - string subscriptionId = "38e0dc56-907f-45ba-a97c-74233baad471"; + string subscriptionId = "0574222d-5c7f-489c-a172-b3013eafab53"; string resourceGroupName = "testrg"; string managedInstanceName = "testcl"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); @@ -38,17 +38,20 @@ public async Task GetAll_GetsAListOfServerTrustCertificatesOnAGivenServer() // get the collection of this ManagedInstanceServerTrustCertificateResource ManagedInstanceServerTrustCertificateCollection collection = managedInstance.GetManagedInstanceServerTrustCertificates(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceServerTrustCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string certificateName = "customerCertificateName"; + ServerTrustCertificateData data = new ServerTrustCertificateData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerTrustCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PublicBlob = "308203AE30820296A0030201020210", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); + ManagedInstanceServerTrustCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerTrustCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetsServerTrustCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsServerTrustCertificate() + public async Task GetAll_GetsAListOfServerTrustCertificatesOnAGivenServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesGet.json - // this example is just showing the usage of "ServerTrustCertificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesListByInstance.json + // this example is just showing the usage of "ServerTrustCertificates_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_GetsServerTrustCertificate() // get the collection of this ManagedInstanceServerTrustCertificateResource ManagedInstanceServerTrustCertificateCollection collection = managedInstance.GetManagedInstanceServerTrustCertificates(); - // invoke the operation - string certificateName = "customerCertificateName"; - bool result = await collection.ExistsAsync(certificateName); + // invoke the operation and iterate over the result + await foreach (ManagedInstanceServerTrustCertificateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerTrustCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsServerTrustCertificate() + public async Task Exists_GetsServerTrustCertificate() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesGet.json // this example is just showing the usage of "ServerTrustCertificates_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_GetsServerTrustCertificate() // invoke the operation string certificateName = "customerCertificateName"; - NullableResponse response = await collection.GetIfExistsAsync(certificateName); - ManagedInstanceServerTrustCertificateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(certificateName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerTrustCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateServerTrustCertificate() + public async Task GetIfExists_GetsServerTrustCertificate() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesCreate.json - // this example is just showing the usage of "ServerTrustCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesGet.json + // this example is just showing the usage of "ServerTrustCertificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -171,7 +168,7 @@ public async Task CreateOrUpdate_CreateServerTrustCertificate() // this example assumes you already have this ManagedInstanceResource created on azure // for more information of creating ManagedInstanceResource, please refer to the document of ManagedInstanceResource - string subscriptionId = "0574222d-5c7f-489c-a172-b3013eafab53"; + string subscriptionId = "38e0dc56-907f-45ba-a97c-74233baad471"; string resourceGroupName = "testrg"; string managedInstanceName = "testcl"; ResourceIdentifier managedInstanceResourceId = ManagedInstanceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_CreateServerTrustCertificate() // invoke the operation string certificateName = "customerCertificateName"; - ServerTrustCertificateData data = new ServerTrustCertificateData() - { - PublicBlob = "308203AE30820296A0030201020210", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); - ManagedInstanceServerTrustCertificateResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(certificateName); + ManagedInstanceServerTrustCertificateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerTrustCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerTrustCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerTrustCertificateResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerTrustCertificateResource.cs index 8196ad66e3183..45faa13fe57bf 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerTrustCertificateResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceServerTrustCertificateResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetsServerTrustCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateServerTrustCertificate() + public async Task Delete_DeleteServerTrustCertificate() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesCreate.json - // this example is just showing the usage of "ServerTrustCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesDelete.json + // this example is just showing the usage of "ServerTrustCertificates_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,7 +60,7 @@ public async Task Update_CreateServerTrustCertificate() // this example assumes you already have this ManagedInstanceServerTrustCertificateResource created on azure // for more information of creating ManagedInstanceServerTrustCertificateResource, please refer to the document of ManagedInstanceServerTrustCertificateResource - string subscriptionId = "0574222d-5c7f-489c-a172-b3013eafab53"; + string subscriptionId = "38e0dc56-907f-45ba-a97c-74233baad471"; string resourceGroupName = "testrg"; string managedInstanceName = "testcl"; string certificateName = "customerCertificateName"; @@ -68,26 +68,17 @@ public async Task Update_CreateServerTrustCertificate() ManagedInstanceServerTrustCertificateResource managedInstanceServerTrustCertificate = client.GetManagedInstanceServerTrustCertificateResource(managedInstanceServerTrustCertificateResourceId); // invoke the operation - ServerTrustCertificateData data = new ServerTrustCertificateData() - { - PublicBlob = "308203AE30820296A0030201020210", - }; - ArmOperation lro = await managedInstanceServerTrustCertificate.UpdateAsync(WaitUntil.Completed, data); - ManagedInstanceServerTrustCertificateResource result = lro.Value; + await managedInstanceServerTrustCertificate.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerTrustCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteServerTrustCertificate() + public async Task Update_CreateServerTrustCertificate() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesDelete.json - // this example is just showing the usage of "ServerTrustCertificates_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerTrustCertificatesCreate.json + // this example is just showing the usage of "ServerTrustCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,7 +87,7 @@ public async Task Delete_DeleteServerTrustCertificate() // this example assumes you already have this ManagedInstanceServerTrustCertificateResource created on azure // for more information of creating ManagedInstanceServerTrustCertificateResource, please refer to the document of ManagedInstanceServerTrustCertificateResource - string subscriptionId = "38e0dc56-907f-45ba-a97c-74233baad471"; + string subscriptionId = "0574222d-5c7f-489c-a172-b3013eafab53"; string resourceGroupName = "testrg"; string managedInstanceName = "testcl"; string certificateName = "customerCertificateName"; @@ -104,9 +95,18 @@ public async Task Delete_DeleteServerTrustCertificate() ManagedInstanceServerTrustCertificateResource managedInstanceServerTrustCertificate = client.GetManagedInstanceServerTrustCertificateResource(managedInstanceServerTrustCertificateResourceId); // invoke the operation - await managedInstanceServerTrustCertificate.DeleteAsync(WaitUntil.Completed); + ServerTrustCertificateData data = new ServerTrustCertificateData + { + PublicBlob = "308203AE30820296A0030201020210", + }; + ArmOperation lro = await managedInstanceServerTrustCertificate.UpdateAsync(WaitUntil.Completed, data); + ManagedInstanceServerTrustCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerTrustCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceStartStopScheduleCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceStartStopScheduleCollection.cs index 5658b4c6968d5..8922c628c9bb3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceStartStopScheduleCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceStartStopScheduleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstanceStartStopScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheManagedInstanceSStartStopSchedules() + public async Task CreateOrUpdate_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWithAllOptionalParametersSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleList.json - // this example is just showing the usage of "StartStopManagedInstanceSchedules_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMax.json + // this example is just showing the usage of "StartStopManagedInstanceSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,30 @@ public async Task GetAll_ListsTheManagedInstanceSStartStopSchedules() // get the collection of this ManagedInstanceStartStopScheduleResource ManagedInstanceStartStopScheduleCollection collection = managedInstance.GetManagedInstanceStartStopSchedules(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceStartStopScheduleResource item in collection.GetAllAsync()) + // invoke the operation + ManagedInstanceStartStopScheduleName startStopScheduleName = ManagedInstanceStartStopScheduleName.Default; + ManagedInstanceStartStopScheduleData data = new ManagedInstanceStartStopScheduleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceStartStopScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "This is a schedule for our Dev/Test environment.", + TimeZoneId = "Central European Standard Time", + ScheduleList = { new SqlScheduleItem(SqlDayOfWeek.Thursday, "18:00", SqlDayOfWeek.Thursday, "17:00"), new SqlScheduleItem(SqlDayOfWeek.Thursday, "15:00", SqlDayOfWeek.Thursday, "14:00") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, startStopScheduleName, data); + ManagedInstanceStartStopScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceStartStopScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheManagedInstanceSStartStopSchedule() + public async Task CreateOrUpdate_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWithNoOptionalParametersSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleGet.json - // this example is just showing the usage of "StartStopManagedInstanceSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMin.json + // this example is just showing the usage of "StartStopManagedInstanceSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +82,12 @@ public async Task Get_GetsTheManagedInstanceSStartStopSchedule() // invoke the operation ManagedInstanceStartStopScheduleName startStopScheduleName = ManagedInstanceStartStopScheduleName.Default; - ManagedInstanceStartStopScheduleResource result = await collection.GetAsync(startStopScheduleName); + ManagedInstanceStartStopScheduleData data = new ManagedInstanceStartStopScheduleData + { + ScheduleList = { new SqlScheduleItem(SqlDayOfWeek.Thursday, "18:00", SqlDayOfWeek.Thursday, "17:00"), new SqlScheduleItem(SqlDayOfWeek.Thursday, "15:00", SqlDayOfWeek.Thursday, "14:00") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, startStopScheduleName, data); + ManagedInstanceStartStopScheduleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +98,7 @@ public async Task Get_GetsTheManagedInstanceSStartStopSchedule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheManagedInstanceSStartStopSchedule() + public async Task Get_GetsTheManagedInstanceSStartStopSchedule() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleGet.json // this example is just showing the usage of "StartStopManagedInstanceSchedules_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +121,21 @@ public async Task Exists_GetsTheManagedInstanceSStartStopSchedule() // invoke the operation ManagedInstanceStartStopScheduleName startStopScheduleName = ManagedInstanceStartStopScheduleName.Default; - bool result = await collection.ExistsAsync(startStopScheduleName); + ManagedInstanceStartStopScheduleResource result = await collection.GetAsync(startStopScheduleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceStartStopScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheManagedInstanceSStartStopSchedule() + public async Task GetAll_ListsTheManagedInstanceSStartStopSchedules() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleGet.json - // this example is just showing the usage of "StartStopManagedInstanceSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleList.json + // this example is just showing the usage of "StartStopManagedInstanceSchedules_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +153,25 @@ public async Task GetIfExists_GetsTheManagedInstanceSStartStopSchedule() // get the collection of this ManagedInstanceStartStopScheduleResource ManagedInstanceStartStopScheduleCollection collection = managedInstance.GetManagedInstanceStartStopSchedules(); - // invoke the operation - ManagedInstanceStartStopScheduleName startStopScheduleName = ManagedInstanceStartStopScheduleName.Default; - NullableResponse response = await collection.GetIfExistsAsync(startStopScheduleName); - ManagedInstanceStartStopScheduleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedInstanceStartStopScheduleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceStartStopScheduleData resourceData = result.Data; + ManagedInstanceStartStopScheduleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWithAllOptionalParametersSpecified() + public async Task Exists_GetsTheManagedInstanceSStartStopSchedule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMax.json - // this example is just showing the usage of "StartStopManagedInstanceSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleGet.json + // this example is just showing the usage of "StartStopManagedInstanceSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,31 +191,17 @@ public async Task CreateOrUpdate_CreatesOrUpdatesTheManagedInstanceSStartStopSch // invoke the operation ManagedInstanceStartStopScheduleName startStopScheduleName = ManagedInstanceStartStopScheduleName.Default; - ManagedInstanceStartStopScheduleData data = new ManagedInstanceStartStopScheduleData() - { - Description = "This is a schedule for our Dev/Test environment.", - TimeZoneId = "Central European Standard Time", - ScheduleList = -{ -new SqlScheduleItem(SqlDayOfWeek.Thursday,"18:00",SqlDayOfWeek.Thursday,"17:00"),new SqlScheduleItem(SqlDayOfWeek.Thursday,"15:00",SqlDayOfWeek.Thursday,"14:00") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, startStopScheduleName, data); - ManagedInstanceStartStopScheduleResource result = lro.Value; + bool result = await collection.ExistsAsync(startStopScheduleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceStartStopScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWithNoOptionalParametersSpecified() + public async Task GetIfExists_GetsTheManagedInstanceSStartStopSchedule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMin.json - // this example is just showing the usage of "StartStopManagedInstanceSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleGet.json + // this example is just showing the usage of "StartStopManagedInstanceSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -227,21 +221,21 @@ public async Task CreateOrUpdate_CreatesOrUpdatesTheManagedInstanceSStartStopSch // invoke the operation ManagedInstanceStartStopScheduleName startStopScheduleName = ManagedInstanceStartStopScheduleName.Default; - ManagedInstanceStartStopScheduleData data = new ManagedInstanceStartStopScheduleData() - { - ScheduleList = -{ -new SqlScheduleItem(SqlDayOfWeek.Thursday,"18:00",SqlDayOfWeek.Thursday,"17:00"),new SqlScheduleItem(SqlDayOfWeek.Thursday,"15:00",SqlDayOfWeek.Thursday,"14:00") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, startStopScheduleName, data); - ManagedInstanceStartStopScheduleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(startStopScheduleName); + ManagedInstanceStartStopScheduleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceStartStopScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceStartStopScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceStartStopScheduleResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceStartStopScheduleResource.cs index 6f0673a1d9bac..4d54bd40b48ac 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceStartStopScheduleResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceStartStopScheduleResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsTheManagedInstanceSStartStopSchedule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWithAllOptionalParametersSpecified() + public async Task Delete_DeletesTheManagedInstanceSStartStopSchedule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMax.json - // this example is just showing the usage of "StartStopManagedInstanceSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleDelete.json + // this example is just showing the usage of "StartStopManagedInstanceSchedules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,16 @@ public async Task Update_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWit ManagedInstanceStartStopScheduleResource managedInstanceStartStopSchedule = client.GetManagedInstanceStartStopScheduleResource(managedInstanceStartStopScheduleResourceId); // invoke the operation - ManagedInstanceStartStopScheduleData data = new ManagedInstanceStartStopScheduleData() - { - Description = "This is a schedule for our Dev/Test environment.", - TimeZoneId = "Central European Standard Time", - ScheduleList = -{ -new SqlScheduleItem(SqlDayOfWeek.Thursday,"18:00",SqlDayOfWeek.Thursday,"17:00"),new SqlScheduleItem(SqlDayOfWeek.Thursday,"15:00",SqlDayOfWeek.Thursday,"14:00") -}, - }; - ArmOperation lro = await managedInstanceStartStopSchedule.UpdateAsync(WaitUntil.Completed, data); - ManagedInstanceStartStopScheduleResource result = lro.Value; + await managedInstanceStartStopSchedule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceStartStopScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWithNoOptionalParametersSpecified() + public async Task Update_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWithAllOptionalParametersSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMin.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMax.json // this example is just showing the usage of "StartStopManagedInstanceSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -110,12 +96,11 @@ public async Task Update_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWit ManagedInstanceStartStopScheduleResource managedInstanceStartStopSchedule = client.GetManagedInstanceStartStopScheduleResource(managedInstanceStartStopScheduleResourceId); // invoke the operation - ManagedInstanceStartStopScheduleData data = new ManagedInstanceStartStopScheduleData() + ManagedInstanceStartStopScheduleData data = new ManagedInstanceStartStopScheduleData { - ScheduleList = -{ -new SqlScheduleItem(SqlDayOfWeek.Thursday,"18:00",SqlDayOfWeek.Thursday,"17:00"),new SqlScheduleItem(SqlDayOfWeek.Thursday,"15:00",SqlDayOfWeek.Thursday,"14:00") -}, + Description = "This is a schedule for our Dev/Test environment.", + TimeZoneId = "Central European Standard Time", + ScheduleList = { new SqlScheduleItem(SqlDayOfWeek.Thursday, "18:00", SqlDayOfWeek.Thursday, "17:00"), new SqlScheduleItem(SqlDayOfWeek.Thursday, "15:00", SqlDayOfWeek.Thursday, "14:00") }, }; ArmOperation lro = await managedInstanceStartStopSchedule.UpdateAsync(WaitUntil.Completed, data); ManagedInstanceStartStopScheduleResource result = lro.Value; @@ -129,10 +114,10 @@ public async Task Update_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWit [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesTheManagedInstanceSStartStopSchedule() + public async Task Update_CreatesOrUpdatesTheManagedInstanceSStartStopScheduleWithNoOptionalParametersSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleDelete.json - // this example is just showing the usage of "StartStopManagedInstanceSchedules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/StartStopManagedInstanceScheduleCreateOrUpdateMin.json + // this example is just showing the usage of "StartStopManagedInstanceSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,9 +134,18 @@ public async Task Delete_DeletesTheManagedInstanceSStartStopSchedule() ManagedInstanceStartStopScheduleResource managedInstanceStartStopSchedule = client.GetManagedInstanceStartStopScheduleResource(managedInstanceStartStopScheduleResourceId); // invoke the operation - await managedInstanceStartStopSchedule.DeleteAsync(WaitUntil.Completed); + ManagedInstanceStartStopScheduleData data = new ManagedInstanceStartStopScheduleData + { + ScheduleList = { new SqlScheduleItem(SqlDayOfWeek.Thursday, "18:00", SqlDayOfWeek.Thursday, "17:00"), new SqlScheduleItem(SqlDayOfWeek.Thursday, "15:00", SqlDayOfWeek.Thursday, "14:00") }, + }; + ArmOperation lro = await managedInstanceStartStopSchedule.UpdateAsync(WaitUntil.Completed, data); + ManagedInstanceStartStopScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceStartStopScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceVulnerabilityAssessmentCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceVulnerabilityAssessmentCollection.cs index 41fd93377a48d..8dbd904f7e91c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceVulnerabilityAssessmentCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceVulnerabilityAssessmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedInstanceVulnerabilityAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAManagedInstanceSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateAManagedInstanceSVulnerabilityAssessmentWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentGet.json - // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateMax.json + // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,20 @@ public async Task Get_GetAManagedInstanceSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - ManagedInstanceVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); + ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + RecurringScans = new VulnerabilityAssessmentRecurringScansProperties + { + IsEnabled = true, + EmailSubscriptionAdmins = true, + Emails = { "email1@mail.com", "email2@mail.com" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + ManagedInstanceVulnerabilityAssessmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +65,10 @@ public async Task Get_GetAManagedInstanceSVulnerabilityAssessment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAManagedInstanceSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateAManagedInstanceSVulnerabilityAssessmentWithMinimalParametersWhenStorageAccountAccessKeyIsSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentGet.json - // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateStorageAccessKeyMin.json + // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +88,27 @@ public async Task Exists_GetAManagedInstanceSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); + ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + ManagedInstanceVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAManagedInstanceSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateAManagedInstanceSVulnerabilityAssessmentWithMinimalParametersWhenStorageContainerSasKeyIsSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentGet.json - // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateContainerSasKeyMin.json + // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,29 +128,27 @@ public async Task GetIfExists_GetAManagedInstanceSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); - ManagedInstanceVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + ManagedInstanceVulnerabilityAssessmentResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAManagedInstanceSVulnerabilityAssessmentWithAllParameters() + public async Task Get_GetAManagedInstanceSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateMax.json - // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentGet.json + // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,23 +168,7 @@ public async Task CreateOrUpdate_CreateAManagedInstanceSVulnerabilityAssessmentW // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new VulnerabilityAssessmentRecurringScansProperties() - { - IsEnabled = true, - EmailSubscriptionAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - ManagedInstanceVulnerabilityAssessmentResource result = lro.Value; + ManagedInstanceVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -174,10 +179,10 @@ public async Task CreateOrUpdate_CreateAManagedInstanceSVulnerabilityAssessmentW [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAManagedInstanceSVulnerabilityAssessmentWithMinimalParametersWhenStorageAccountAccessKeyIsSpecified() + public async Task GetAll_GetAManagedInstanceSVulnerabilityAssessmentPolicies() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateStorageAccessKeyMin.json - // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentListByInstance.json + // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,29 +200,25 @@ public async Task CreateOrUpdate_CreateAManagedInstanceSVulnerabilityAssessmentW // get the collection of this ManagedInstanceVulnerabilityAssessmentResource ManagedInstanceVulnerabilityAssessmentCollection collection = managedInstance.GetManagedInstanceVulnerabilityAssessments(); - // invoke the operation - VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData() + // invoke the operation and iterate over the result + await foreach (ManagedInstanceVulnerabilityAssessmentResource item in collection.GetAllAsync()) { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - ManagedInstanceVulnerabilityAssessmentResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceVulnerabilityAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAManagedInstanceSVulnerabilityAssessmentWithMinimalParametersWhenStorageContainerSasKeyIsSpecified() + public async Task Exists_GetAManagedInstanceSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentCreateContainerSasKeyMin.json - // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentGet.json + // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -237,27 +238,17 @@ public async Task CreateOrUpdate_CreateAManagedInstanceSVulnerabilityAssessmentW // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - ManagedInstanceVulnerabilityAssessmentResource result = lro.Value; + bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAManagedInstanceSVulnerabilityAssessmentPolicies() + public async Task GetIfExists_GetAManagedInstanceSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentListByInstance.json - // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentGet.json + // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -275,17 +266,23 @@ public async Task GetAll_GetAManagedInstanceSVulnerabilityAssessmentPolicies() // get the collection of this ManagedInstanceVulnerabilityAssessmentResource ManagedInstanceVulnerabilityAssessmentCollection collection = managedInstance.GetManagedInstanceVulnerabilityAssessments(); - // invoke the operation and iterate over the result - await foreach (ManagedInstanceVulnerabilityAssessmentResource item in collection.GetAllAsync()) + // invoke the operation + VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; + NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); + ManagedInstanceVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceVulnerabilityAssessmentData resourceData = item.Data; + ManagedInstanceVulnerabilityAssessmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceVulnerabilityAssessmentResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceVulnerabilityAssessmentResource.cs index df25c2ce02300..f2b9526a8c2b8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceVulnerabilityAssessmentResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedInstanceVulnerabilityAssessmentResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetAManagedInstanceSVulnerabilityAssessment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_RemoveAManagedInstanceSVulnerabilityAssessment() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentDelete.json + // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ManagedInstanceVulnerabilityAssessmentResource created on azure + // for more information of creating ManagedInstanceVulnerabilityAssessmentResource, please refer to the document of ManagedInstanceVulnerabilityAssessmentResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string managedInstanceName = "vulnerabilityaseessmenttest-6440"; + VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; + ResourceIdentifier managedInstanceVulnerabilityAssessmentResourceId = ManagedInstanceVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, vulnerabilityAssessmentName); + ManagedInstanceVulnerabilityAssessmentResource managedInstanceVulnerabilityAssessment = client.GetManagedInstanceVulnerabilityAssessmentResource(managedInstanceVulnerabilityAssessmentResourceId); + + // invoke the operation + await managedInstanceVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateAManagedInstanceSVulnerabilityAssessmentWithAllParameters() @@ -69,19 +96,16 @@ public async Task Update_CreateAManagedInstanceSVulnerabilityAssessmentWithAllPa ManagedInstanceVulnerabilityAssessmentResource managedInstanceVulnerabilityAssessment = client.GetManagedInstanceVulnerabilityAssessmentResource(managedInstanceVulnerabilityAssessmentResourceId); // invoke the operation - ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData() + ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new VulnerabilityAssessmentRecurringScansProperties() + RecurringScans = new VulnerabilityAssessmentRecurringScansProperties { IsEnabled = true, EmailSubscriptionAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, + Emails = { "email1@mail.com", "email2@mail.com" }, }, }; ArmOperation lro = await managedInstanceVulnerabilityAssessment.UpdateAsync(WaitUntil.Completed, data); @@ -116,7 +140,7 @@ public async Task Update_CreateAManagedInstanceSVulnerabilityAssessmentWithMinim ManagedInstanceVulnerabilityAssessmentResource managedInstanceVulnerabilityAssessment = client.GetManagedInstanceVulnerabilityAssessmentResource(managedInstanceVulnerabilityAssessmentResourceId); // invoke the operation - ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData() + ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -153,7 +177,7 @@ public async Task Update_CreateAManagedInstanceSVulnerabilityAssessmentWithMinim ManagedInstanceVulnerabilityAssessmentResource managedInstanceVulnerabilityAssessment = client.GetManagedInstanceVulnerabilityAssessmentResource(managedInstanceVulnerabilityAssessmentResourceId); // invoke the operation - ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData() + ManagedInstanceVulnerabilityAssessmentData data = new ManagedInstanceVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -167,32 +191,5 @@ public async Task Update_CreateAManagedInstanceSVulnerabilityAssessmentWithMinim // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_RemoveAManagedInstanceSVulnerabilityAssessment() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceVulnerabilityAssessmentDelete.json - // this example is just showing the usage of "ManagedInstanceVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ManagedInstanceVulnerabilityAssessmentResource created on azure - // for more information of creating ManagedInstanceVulnerabilityAssessmentResource, please refer to the document of ManagedInstanceVulnerabilityAssessmentResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string managedInstanceName = "vulnerabilityaseessmenttest-6440"; - VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - ResourceIdentifier managedInstanceVulnerabilityAssessmentResourceId = ManagedInstanceVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, vulnerabilityAssessmentName); - ManagedInstanceVulnerabilityAssessmentResource managedInstanceVulnerabilityAssessment = client.GetManagedInstanceVulnerabilityAssessmentResource(managedInstanceVulnerabilityAssessmentResourceId); - - // invoke the operation - await managedInstanceVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedLedgerDigestUploadCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedLedgerDigestUploadCollection.cs index b2699b1d1c50b..9e8da7cb6f6eb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedLedgerDigestUploadCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedLedgerDigestUploadCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedLedgerDigestUploadCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfLedgerDigestUploadSettingsOnADatabase() + public async Task CreateOrUpdate_EnablesManagedLedgerDigestUploadConfigurationForADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsList.json - // this example is just showing the usage of "ManagedLedgerDigestUploads_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsEnable.json + // this example is just showing the usage of "ManagedLedgerDigestUploads_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_GetsListOfLedgerDigestUploadSettingsOnADatabase() // get the collection of this ManagedLedgerDigestUploadResource ManagedLedgerDigestUploadCollection collection = managedDatabase.GetManagedLedgerDigestUploads(); - // invoke the operation and iterate over the result - await foreach (ManagedLedgerDigestUploadResource item in collection.GetAllAsync()) + // invoke the operation + ManagedLedgerDigestUploadsName ledgerDigestUploads = ManagedLedgerDigestUploadsName.Current; + ManagedLedgerDigestUploadData data = new ManagedLedgerDigestUploadData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedLedgerDigestUploadData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DigestStorageEndpoint = "https://MyAccount.blob.core.windows.net", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ledgerDigestUploads, data); + ManagedLedgerDigestUploadResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedLedgerDigestUploadData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +93,10 @@ public async Task Get_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase( [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase() + public async Task GetAll_GetsListOfLedgerDigestUploadSettingsOnADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsGet.json - // this example is just showing the usage of "ManagedLedgerDigestUploads_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsList.json + // this example is just showing the usage of "ManagedLedgerDigestUploads_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +115,22 @@ public async Task Exists_GetsTheCurrentLedgerDigestUploadConfigurationForADataba // get the collection of this ManagedLedgerDigestUploadResource ManagedLedgerDigestUploadCollection collection = managedDatabase.GetManagedLedgerDigestUploads(); - // invoke the operation - ManagedLedgerDigestUploadsName ledgerDigestUploads = ManagedLedgerDigestUploadsName.Current; - bool result = await collection.ExistsAsync(ledgerDigestUploads); + // invoke the operation and iterate over the result + await foreach (ManagedLedgerDigestUploadResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedLedgerDigestUploadData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase() + public async Task Exists_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsGet.json // this example is just showing the usage of "ManagedLedgerDigestUploads_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +154,17 @@ public async Task GetIfExists_GetsTheCurrentLedgerDigestUploadConfigurationForAD // invoke the operation ManagedLedgerDigestUploadsName ledgerDigestUploads = ManagedLedgerDigestUploadsName.Current; - NullableResponse response = await collection.GetIfExistsAsync(ledgerDigestUploads); - ManagedLedgerDigestUploadResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ledgerDigestUploads); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedLedgerDigestUploadData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EnablesManagedLedgerDigestUploadConfigurationForADatabase() + public async Task GetIfExists_GetsTheCurrentLedgerDigestUploadConfigurationForADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsEnable.json - // this example is just showing the usage of "ManagedLedgerDigestUploads_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedLedgerDigestUploadsGet.json + // this example is just showing the usage of "ManagedLedgerDigestUploads_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,18 +185,21 @@ public async Task CreateOrUpdate_EnablesManagedLedgerDigestUploadConfigurationFo // invoke the operation ManagedLedgerDigestUploadsName ledgerDigestUploads = ManagedLedgerDigestUploadsName.Current; - ManagedLedgerDigestUploadData data = new ManagedLedgerDigestUploadData() - { - DigestStorageEndpoint = "https://MyAccount.blob.core.windows.net", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ledgerDigestUploads, data); - ManagedLedgerDigestUploadResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ledgerDigestUploads); + ManagedLedgerDigestUploadResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedLedgerDigestUploadData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedLedgerDigestUploadData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedLedgerDigestUploadResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedLedgerDigestUploadResource.cs index 6598766419ea8..aebd017460d22 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedLedgerDigestUploadResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedLedgerDigestUploadResource.cs @@ -71,7 +71,7 @@ public async Task Update_EnablesManagedLedgerDigestUploadConfigurationForADataba ManagedLedgerDigestUploadResource managedLedgerDigestUpload = client.GetManagedLedgerDigestUploadResource(managedLedgerDigestUploadResourceId); // invoke the operation - ManagedLedgerDigestUploadData data = new ManagedLedgerDigestUploadData() + ManagedLedgerDigestUploadData data = new ManagedLedgerDigestUploadData { DigestStorageEndpoint = "https://MyAccount.blob.core.windows.net", }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedRestorableDroppedDbBackupShortTermRetentionPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedRestorableDroppedDbBackupShortTermRetentionPolicyCollection.cs index 95db730de89de..923d409de48a7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedRestorableDroppedDbBackupShortTermRetentionPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedRestorableDroppedDbBackupShortTermRetentionPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedRestorableDroppedDbBackupShortTermRetentionPo { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() + public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheRestorableDroppedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicyRestorableDropped.json - // this example is just showing the usage of "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/UpdateManagedShortTermRetentionPolicyRestorableDropped.json + // this example is just showing the usage of "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() // this example assumes you already have this RestorableDroppedManagedDatabaseResource created on azure // for more information of creating RestorableDroppedManagedDatabaseResource, please refer to the document of RestorableDroppedManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; + string resourceGroupName = "resourceGroup"; string managedInstanceName = "testsvr"; string restorableDroppedDatabaseId = "testdb,131403269876900000"; ResourceIdentifier restorableDroppedManagedDatabaseResourceId = RestorableDroppedManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, restorableDroppedDatabaseId); @@ -42,7 +42,12 @@ public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() // invoke the operation ManagedShortTermRetentionPolicyName policyName = ManagedShortTermRetentionPolicyName.Default; - ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource result = await collection.GetAsync(policyName); + ManagedBackupShortTermRetentionPolicyData data = new ManagedBackupShortTermRetentionPolicyData + { + RetentionDays = 14, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +58,7 @@ public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheShortTermRetentionPolicyForTheDatabase() + public async Task Get_GetTheShortTermRetentionPolicyForTheDatabase() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicyRestorableDropped.json // this example is just showing the usage of "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +82,21 @@ public async Task Exists_GetTheShortTermRetentionPolicyForTheDatabase() // invoke the operation ManagedShortTermRetentionPolicyName policyName = ManagedShortTermRetentionPolicyName.Default; - bool result = await collection.ExistsAsync(policyName); + ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource result = await collection.GetAsync(policyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedBackupShortTermRetentionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheShortTermRetentionPolicyForTheDatabase() + public async Task GetAll_GetTheShortTermRetentionPolicyListForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicyRestorableDropped.json - // this example is just showing the usage of "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetListManagedShortTermRetentionPolicyRestorableDropped.json + // this example is just showing the usage of "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies_ListByRestorableDroppedDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +115,25 @@ public async Task GetIfExists_GetTheShortTermRetentionPolicyForTheDatabase() // get the collection of this ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource ManagedRestorableDroppedDbBackupShortTermRetentionPolicyCollection collection = restorableDroppedManagedDatabase.GetManagedRestorableDroppedDbBackupShortTermRetentionPolicies(); - // invoke the operation - ManagedShortTermRetentionPolicyName policyName = ManagedShortTermRetentionPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedBackupShortTermRetentionPolicyData resourceData = result.Data; + ManagedBackupShortTermRetentionPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheRestorableDroppedDatabase() + public async Task Exists_GetTheShortTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/UpdateManagedShortTermRetentionPolicyRestorableDropped.json - // this example is just showing the usage of "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicyRestorableDropped.json + // this example is just showing the usage of "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,7 +143,7 @@ public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheRestorab // this example assumes you already have this RestorableDroppedManagedDatabaseResource created on azure // for more information of creating RestorableDroppedManagedDatabaseResource, please refer to the document of RestorableDroppedManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "resourceGroup"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; string managedInstanceName = "testsvr"; string restorableDroppedDatabaseId = "testdb,131403269876900000"; ResourceIdentifier restorableDroppedManagedDatabaseResourceId = RestorableDroppedManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, restorableDroppedDatabaseId); @@ -151,26 +154,17 @@ public async Task CreateOrUpdate_UpdateTheShortTermRetentionPolicyForTheRestorab // invoke the operation ManagedShortTermRetentionPolicyName policyName = ManagedShortTermRetentionPolicyName.Default; - ManagedBackupShortTermRetentionPolicyData data = new ManagedBackupShortTermRetentionPolicyData() - { - RetentionDays = 14, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(policyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedBackupShortTermRetentionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheShortTermRetentionPolicyListForTheDatabase() + public async Task GetIfExists_GetTheShortTermRetentionPolicyForTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetListManagedShortTermRetentionPolicyRestorableDropped.json - // this example is just showing the usage of "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies_ListByRestorableDroppedDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetManagedShortTermRetentionPolicyRestorableDropped.json + // this example is just showing the usage of "ManagedRestorableDroppedDatabaseBackupShortTermRetentionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_GetTheShortTermRetentionPolicyListForTheDatabase() // get the collection of this ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource ManagedRestorableDroppedDbBackupShortTermRetentionPolicyCollection collection = restorableDroppedManagedDatabase.GetManagedRestorableDroppedDbBackupShortTermRetentionPolicies(); - // invoke the operation and iterate over the result - await foreach (ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource item in collection.GetAllAsync()) + // invoke the operation + ManagedShortTermRetentionPolicyName policyName = ManagedShortTermRetentionPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedBackupShortTermRetentionPolicyData resourceData = item.Data; + ManagedBackupShortTermRetentionPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource.cs index 8150e68afed2f..3b1823d7f9d18 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource.cs @@ -71,7 +71,7 @@ public async Task Update_UpdateTheShortTermRetentionPolicyForTheRestorableDroppe ManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource managedRestorableDroppedDbBackupShortTermRetentionPolicy = client.GetManagedRestorableDroppedDbBackupShortTermRetentionPolicyResource(managedRestorableDroppedDbBackupShortTermRetentionPolicyResourceId); // invoke the operation - ManagedBackupShortTermRetentionPolicyData data = new ManagedBackupShortTermRetentionPolicyData() + ManagedBackupShortTermRetentionPolicyData data = new ManagedBackupShortTermRetentionPolicyData { RetentionDays = 14, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerDnsAliasCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerDnsAliasCollection.cs index d681defa50cfc..2d9fbd7274745 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerDnsAliasCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerDnsAliasCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedServerDnsAliasCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedServerDNSAliases() + public async Task CreateOrUpdate_CreateManagedServerDNSAlias() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasList.json - // this example is just showing the usage of "ManagedServerDnsAliases_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasCreateOrUpdate.json + // this example is just showing the usage of "ManagedServerDnsAliases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,17 @@ public async Task GetAll_ListManagedServerDNSAliases() // get the collection of this ManagedServerDnsAliasResource ManagedServerDnsAliasCollection collection = managedInstance.GetManagedServerDnsAliases(); - // invoke the operation and iterate over the result - await foreach (ManagedServerDnsAliasResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServerDnsAliasData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string dnsAliasName = "dns-alias-mi"; + ManagedServerDnsAliasCreateOrUpdateContent content = new ManagedServerDnsAliasCreateOrUpdateContent(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dnsAliasName, content); + ManagedServerDnsAliasResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServerDnsAliasData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +88,10 @@ public async Task Get_GetManagedServerDNSAlias() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagedServerDNSAlias() + public async Task GetAll_ListManagedServerDNSAliases() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasGet.json - // this example is just showing the usage of "ManagedServerDnsAliases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasList.json + // this example is just showing the usage of "ManagedServerDnsAliases_ListByManagedInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_GetManagedServerDNSAlias() // get the collection of this ManagedServerDnsAliasResource ManagedServerDnsAliasCollection collection = managedInstance.GetManagedServerDnsAliases(); - // invoke the operation - string dnsAliasName = "dns-alias-mi"; - bool result = await collection.ExistsAsync(dnsAliasName); + // invoke the operation and iterate over the result + await foreach (ManagedServerDnsAliasResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServerDnsAliasData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagedServerDNSAlias() + public async Task Exists_GetManagedServerDNSAlias() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasGet.json // this example is just showing the usage of "ManagedServerDnsAliases_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_GetManagedServerDNSAlias() // invoke the operation string dnsAliasName = "dns-alias-mi"; - NullableResponse response = await collection.GetIfExistsAsync(dnsAliasName); - ManagedServerDnsAliasResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dnsAliasName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServerDnsAliasData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateManagedServerDNSAlias() + public async Task GetIfExists_GetManagedServerDNSAlias() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasCreateOrUpdate.json - // this example is just showing the usage of "ManagedServerDnsAliases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasGet.json + // this example is just showing the usage of "ManagedServerDnsAliases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,15 +177,21 @@ public async Task CreateOrUpdate_CreateManagedServerDNSAlias() // invoke the operation string dnsAliasName = "dns-alias-mi"; - ManagedServerDnsAliasCreateOrUpdateContent content = new ManagedServerDnsAliasCreateOrUpdateContent(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dnsAliasName, content); - ManagedServerDnsAliasResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dnsAliasName); + ManagedServerDnsAliasResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServerDnsAliasData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServerDnsAliasData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerDnsAliasResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerDnsAliasResource.cs index 59533e7368cef..72d020d5a3c80 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerDnsAliasResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerDnsAliasResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetManagedServerDNSAlias() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateManagedServerDNSAlias() + public async Task Delete_DeleteManagedServerDNSAlias() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasCreateOrUpdate.json - // this example is just showing the usage of "ManagedServerDnsAliases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasDelete.json + // this example is just showing the usage of "ManagedServerDnsAliases_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,23 +69,17 @@ public async Task Update_CreateManagedServerDNSAlias() ManagedServerDnsAliasResource managedServerDnsAlias = client.GetManagedServerDnsAliasResource(managedServerDnsAliasResourceId); // invoke the operation - ManagedServerDnsAliasCreateOrUpdateContent content = new ManagedServerDnsAliasCreateOrUpdateContent(); - ArmOperation lro = await managedServerDnsAlias.UpdateAsync(WaitUntil.Completed, content); - ManagedServerDnsAliasResource result = lro.Value; + await managedServerDnsAlias.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServerDnsAliasData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteManagedServerDNSAlias() + public async Task Update_CreateManagedServerDNSAlias() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasDelete.json - // this example is just showing the usage of "ManagedServerDnsAliases_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ManagedServerDnsAliasCreateOrUpdate.json + // this example is just showing the usage of "ManagedServerDnsAliases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_DeleteManagedServerDNSAlias() ManagedServerDnsAliasResource managedServerDnsAlias = client.GetManagedServerDnsAliasResource(managedServerDnsAliasResourceId); // invoke the operation - await managedServerDnsAlias.DeleteAsync(WaitUntil.Completed); + ManagedServerDnsAliasCreateOrUpdateContent content = new ManagedServerDnsAliasCreateOrUpdateContent(); + ArmOperation lro = await managedServerDnsAlias.UpdateAsync(WaitUntil.Completed, content); + ManagedServerDnsAliasResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServerDnsAliasData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerSecurityAlertPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerSecurityAlertPolicyCollection.cs index 707e6186120eb..7322dc234d03d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerSecurityAlertPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerSecurityAlertPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedServerSecurityAlertPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAManagedServerSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateAManagedServerSThreatDetectionPolicyWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertGet.json - // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertCreateMax.json + // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_GetAManagedServerSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - ManagedServerSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); + ManagedServerSecurityAlertPolicyData data = new ManagedServerSecurityAlertPolicyData + { + State = SecurityAlertsPolicyState.Enabled, + DisabledAlerts = { "Access_Anomaly", "Usage_Anomaly" }, + EmailAddresses = { "testSecurityAlert@microsoft.com" }, + SendToEmailAccountAdmins = true, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + RetentionDays = 5, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + ManagedServerSecurityAlertPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +63,10 @@ public async Task Get_GetAManagedServerSThreatDetectionPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAManagedServerSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateAManagedServerSThreatDetectionPolicyWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertGet.json - // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertCreateMin.json + // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +86,23 @@ public async Task Exists_GetAManagedServerSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - bool result = await collection.ExistsAsync(securityAlertPolicyName); + ManagedServerSecurityAlertPolicyData data = new ManagedServerSecurityAlertPolicyData + { + State = SecurityAlertsPolicyState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + ManagedServerSecurityAlertPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAManagedServerSThreatDetectionPolicy() + public async Task Get_GetAManagedServerSThreatDetectionPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertGet.json // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +125,21 @@ public async Task GetIfExists_GetAManagedServerSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); - ManagedServerSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + ManagedServerSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAManagedServerSThreatDetectionPolicyWithAllParameters() + public async Task GetAll_GetTheManagedServerSThreatDetectionPolicies() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertCreateMax.json - // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertListByInstance.json + // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,40 +157,25 @@ public async Task CreateOrUpdate_UpdateAManagedServerSThreatDetectionPolicyWithA // get the collection of this ManagedServerSecurityAlertPolicyResource ManagedServerSecurityAlertPolicyCollection collection = managedInstance.GetManagedServerSecurityAlertPolicies(); - // invoke the operation - SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - ManagedServerSecurityAlertPolicyData data = new ManagedServerSecurityAlertPolicyData() + // invoke the operation and iterate over the result + await foreach (ManagedServerSecurityAlertPolicyResource item in collection.GetAllAsync()) { - State = SecurityAlertsPolicyState.Enabled, - DisabledAlerts = -{ -"Access_Anomaly","Usage_Anomaly" -}, - EmailAddresses = -{ -"testSecurityAlert@microsoft.com" -}, - SendToEmailAccountAdmins = true, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - RetentionDays = 5, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - ManagedServerSecurityAlertPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServerSecurityAlertPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAManagedServerSThreatDetectionPolicyWithMinimalParameters() + public async Task Exists_GetAManagedServerSThreatDetectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertCreateMin.json - // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertGet.json + // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,26 +195,17 @@ public async Task CreateOrUpdate_UpdateAManagedServerSThreatDetectionPolicyWithM // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - ManagedServerSecurityAlertPolicyData data = new ManagedServerSecurityAlertPolicyData() - { - State = SecurityAlertsPolicyState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - ManagedServerSecurityAlertPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(securityAlertPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheManagedServerSThreatDetectionPolicies() + public async Task GetIfExists_GetAManagedServerSThreatDetectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertListByInstance.json - // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedServerSecurityAlertGet.json + // this example is just showing the usage of "ManagedServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -235,17 +223,23 @@ public async Task GetAll_GetTheManagedServerSThreatDetectionPolicies() // get the collection of this ManagedServerSecurityAlertPolicyResource ManagedServerSecurityAlertPolicyCollection collection = managedInstance.GetManagedServerSecurityAlertPolicies(); - // invoke the operation and iterate over the result - await foreach (ManagedServerSecurityAlertPolicyResource item in collection.GetAllAsync()) + // invoke the operation + SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); + ManagedServerSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedServerSecurityAlertPolicyData resourceData = item.Data; + ManagedServerSecurityAlertPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerSecurityAlertPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerSecurityAlertPolicyResource.cs index cc5e6c2718495..9c01b9ad90754 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerSecurityAlertPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedServerSecurityAlertPolicyResource.cs @@ -69,17 +69,11 @@ public async Task Update_UpdateAManagedServerSThreatDetectionPolicyWithAllParame ManagedServerSecurityAlertPolicyResource managedServerSecurityAlertPolicy = client.GetManagedServerSecurityAlertPolicyResource(managedServerSecurityAlertPolicyResourceId); // invoke the operation - ManagedServerSecurityAlertPolicyData data = new ManagedServerSecurityAlertPolicyData() + ManagedServerSecurityAlertPolicyData data = new ManagedServerSecurityAlertPolicyData { State = SecurityAlertsPolicyState.Enabled, - DisabledAlerts = -{ -"Access_Anomaly","Usage_Anomaly" -}, - EmailAddresses = -{ -"testSecurityAlert@microsoft.com" -}, + DisabledAlerts = { "Access_Anomaly", "Usage_Anomaly" }, + EmailAddresses = { "testSecurityAlert@microsoft.com" }, SendToEmailAccountAdmins = true, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", @@ -117,7 +111,7 @@ public async Task Update_UpdateAManagedServerSThreatDetectionPolicyWithMinimalPa ManagedServerSecurityAlertPolicyResource managedServerSecurityAlertPolicy = client.GetManagedServerSecurityAlertPolicyResource(managedServerSecurityAlertPolicyResourceId); // invoke the operation - ManagedServerSecurityAlertPolicyData data = new ManagedServerSecurityAlertPolicyData() + ManagedServerSecurityAlertPolicyData data = new ManagedServerSecurityAlertPolicyData { State = SecurityAlertsPolicyState.Enabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedTransparentDataEncryptionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedTransparentDataEncryptionCollection.cs index 3c8c22d45acdc..bfa4f287189e8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedTransparentDataEncryptionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedTransparentDataEncryptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedTransparentDataEncryptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabaseSTransparentDataEncryption() + public async Task CreateOrUpdate_UpdateADatabaseSTransparentDataEncryptionStateWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionGet.json - // this example is just showing the usage of "ManagedDatabaseTransparentDataEncryption_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionUpdate.json + // this example is just showing the usage of "ManagedDatabaseTransparentDataEncryption_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task Get_GetADatabaseSTransparentDataEncryption() // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "security-tde-resourcegroup"; - string managedInstanceName = "securitytde"; + string resourceGroupName = "securitytde-42-rg"; + string managedInstanceName = "securitytde-42"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); @@ -42,7 +42,12 @@ public async Task Get_GetADatabaseSTransparentDataEncryption() // invoke the operation TransparentDataEncryptionName tdeName = TransparentDataEncryptionName.Current; - ManagedTransparentDataEncryptionResource result = await collection.GetAsync(tdeName); + ManagedTransparentDataEncryptionData data = new ManagedTransparentDataEncryptionData + { + State = TransparentDataEncryptionState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tdeName, data); + ManagedTransparentDataEncryptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +58,7 @@ public async Task Get_GetADatabaseSTransparentDataEncryption() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADatabaseSTransparentDataEncryption() + public async Task Get_GetADatabaseSTransparentDataEncryption() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionGet.json // this example is just showing the usage of "ManagedDatabaseTransparentDataEncryption_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +82,21 @@ public async Task Exists_GetADatabaseSTransparentDataEncryption() // invoke the operation TransparentDataEncryptionName tdeName = TransparentDataEncryptionName.Current; - bool result = await collection.ExistsAsync(tdeName); + ManagedTransparentDataEncryptionResource result = await collection.GetAsync(tdeName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedTransparentDataEncryptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADatabaseSTransparentDataEncryption() + public async Task GetAll_GetAListOfTheDatabaseSTransparentDataEncryptions() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionGet.json - // this example is just showing the usage of "ManagedDatabaseTransparentDataEncryption_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionList.json + // this example is just showing the usage of "ManagedDatabaseTransparentDataEncryption_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +115,25 @@ public async Task GetIfExists_GetADatabaseSTransparentDataEncryption() // get the collection of this ManagedTransparentDataEncryptionResource ManagedTransparentDataEncryptionCollection collection = managedDatabase.GetManagedTransparentDataEncryptions(); - // invoke the operation - TransparentDataEncryptionName tdeName = TransparentDataEncryptionName.Current; - NullableResponse response = await collection.GetIfExistsAsync(tdeName); - ManagedTransparentDataEncryptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedTransparentDataEncryptionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedTransparentDataEncryptionData resourceData = result.Data; + ManagedTransparentDataEncryptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateADatabaseSTransparentDataEncryptionStateWithMinimalParameters() + public async Task Exists_GetADatabaseSTransparentDataEncryption() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionUpdate.json - // this example is just showing the usage of "ManagedDatabaseTransparentDataEncryption_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionGet.json + // this example is just showing the usage of "ManagedDatabaseTransparentDataEncryption_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,8 +143,8 @@ public async Task CreateOrUpdate_UpdateADatabaseSTransparentDataEncryptionStateW // this example assumes you already have this ManagedDatabaseResource created on azure // for more information of creating ManagedDatabaseResource, please refer to the document of ManagedDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securitytde-42-rg"; - string managedInstanceName = "securitytde-42"; + string resourceGroupName = "security-tde-resourcegroup"; + string managedInstanceName = "securitytde"; string databaseName = "testdb"; ResourceIdentifier managedDatabaseResourceId = ManagedDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, managedInstanceName, databaseName); ManagedDatabaseResource managedDatabase = client.GetManagedDatabaseResource(managedDatabaseResourceId); @@ -151,26 +154,17 @@ public async Task CreateOrUpdate_UpdateADatabaseSTransparentDataEncryptionStateW // invoke the operation TransparentDataEncryptionName tdeName = TransparentDataEncryptionName.Current; - ManagedTransparentDataEncryptionData data = new ManagedTransparentDataEncryptionData() - { - State = TransparentDataEncryptionState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tdeName, data); - ManagedTransparentDataEncryptionResource result = lro.Value; + bool result = await collection.ExistsAsync(tdeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedTransparentDataEncryptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfTheDatabaseSTransparentDataEncryptions() + public async Task GetIfExists_GetADatabaseSTransparentDataEncryption() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionList.json - // this example is just showing the usage of "ManagedDatabaseTransparentDataEncryption_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedTransparentDataEncryptionGet.json + // this example is just showing the usage of "ManagedDatabaseTransparentDataEncryption_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_GetAListOfTheDatabaseSTransparentDataEncryptions() // get the collection of this ManagedTransparentDataEncryptionResource ManagedTransparentDataEncryptionCollection collection = managedDatabase.GetManagedTransparentDataEncryptions(); - // invoke the operation and iterate over the result - await foreach (ManagedTransparentDataEncryptionResource item in collection.GetAllAsync()) + // invoke the operation + TransparentDataEncryptionName tdeName = TransparentDataEncryptionName.Current; + NullableResponse response = await collection.GetIfExistsAsync(tdeName); + ManagedTransparentDataEncryptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedTransparentDataEncryptionData resourceData = item.Data; + ManagedTransparentDataEncryptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedTransparentDataEncryptionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedTransparentDataEncryptionResource.cs index 0c720f9eafbd9..f4fadc8e081c8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedTransparentDataEncryptionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ManagedTransparentDataEncryptionResource.cs @@ -71,7 +71,7 @@ public async Task Update_UpdateADatabaseSTransparentDataEncryptionStateWithMinim ManagedTransparentDataEncryptionResource managedTransparentDataEncryption = client.GetManagedTransparentDataEncryptionResource(managedTransparentDataEncryptionResourceId); // invoke the operation - ManagedTransparentDataEncryptionData data = new ManagedTransparentDataEncryptionData() + ManagedTransparentDataEncryptionData data = new ManagedTransparentDataEncryptionData { State = TransparentDataEncryptionState.Enabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_OutboundFirewallRuleCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_OutboundFirewallRuleCollection.cs index d03ac52527836..2c705e42d6871 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_OutboundFirewallRuleCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_OutboundFirewallRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_OutboundFirewallRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsOutboundFirewallRule() + public async Task CreateOrUpdate_ApproveOrRejectAOutboundFirewallRuleWithAGivenName() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleGet.json - // this example is just showing the usage of "OutboundFirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleCreate.json + // this example is just showing the usage of "OutboundFirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,9 @@ public async Task Get_GetsOutboundFirewallRule() // invoke the operation string outboundRuleFqdn = "server.database.windows.net"; - OutboundFirewallRuleResource result = await collection.GetAsync(outboundRuleFqdn); + OutboundFirewallRuleData data = new OutboundFirewallRuleData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, outboundRuleFqdn, data); + OutboundFirewallRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_GetsOutboundFirewallRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsOutboundFirewallRule() + public async Task Get_GetsOutboundFirewallRule() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleGet.json // this example is just showing the usage of "OutboundFirewallRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +76,21 @@ public async Task Exists_GetsOutboundFirewallRule() // invoke the operation string outboundRuleFqdn = "server.database.windows.net"; - bool result = await collection.ExistsAsync(outboundRuleFqdn); + OutboundFirewallRuleResource result = await collection.GetAsync(outboundRuleFqdn); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OutboundFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsOutboundFirewallRule() + public async Task GetAll_GetsListOfOutboundFirewallRulesOnAServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleGet.json - // this example is just showing the usage of "OutboundFirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleList.json + // this example is just showing the usage of "OutboundFirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +108,25 @@ public async Task GetIfExists_GetsOutboundFirewallRule() // get the collection of this OutboundFirewallRuleResource OutboundFirewallRuleCollection collection = sqlServer.GetOutboundFirewallRules(); - // invoke the operation - string outboundRuleFqdn = "server.database.windows.net"; - NullableResponse response = await collection.GetIfExistsAsync(outboundRuleFqdn); - OutboundFirewallRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (OutboundFirewallRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - OutboundFirewallRuleData resourceData = result.Data; + OutboundFirewallRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAOutboundFirewallRuleWithAGivenName() + public async Task Exists_GetsOutboundFirewallRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleCreate.json - // this example is just showing the usage of "OutboundFirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleGet.json + // this example is just showing the usage of "OutboundFirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,23 +146,17 @@ public async Task CreateOrUpdate_ApproveOrRejectAOutboundFirewallRuleWithAGivenN // invoke the operation string outboundRuleFqdn = "server.database.windows.net"; - OutboundFirewallRuleData data = new OutboundFirewallRuleData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, outboundRuleFqdn, data); - OutboundFirewallRuleResource result = lro.Value; + bool result = await collection.ExistsAsync(outboundRuleFqdn); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OutboundFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfOutboundFirewallRulesOnAServer() + public async Task GetIfExists_GetsOutboundFirewallRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleList.json - // this example is just showing the usage of "OutboundFirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleGet.json + // this example is just showing the usage of "OutboundFirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_GetsListOfOutboundFirewallRulesOnAServer() // get the collection of this OutboundFirewallRuleResource OutboundFirewallRuleCollection collection = sqlServer.GetOutboundFirewallRules(); - // invoke the operation and iterate over the result - await foreach (OutboundFirewallRuleResource item in collection.GetAllAsync()) + // invoke the operation + string outboundRuleFqdn = "server.database.windows.net"; + NullableResponse response = await collection.GetIfExistsAsync(outboundRuleFqdn); + OutboundFirewallRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - OutboundFirewallRuleData resourceData = item.Data; + OutboundFirewallRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_OutboundFirewallRuleResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_OutboundFirewallRuleResource.cs index 56bb00736c0fa..99a8ad3b77f05 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_OutboundFirewallRuleResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_OutboundFirewallRuleResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetsOutboundFirewallRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveOrRejectAOutboundFirewallRuleWithAGivenName() + public async Task Delete_DeletesAOutboundFirewallRuleWithAGivenName() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleCreate.json - // this example is just showing the usage of "OutboundFirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleDelete.json + // this example is just showing the usage of "OutboundFirewallRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,29 +62,23 @@ public async Task Update_ApproveOrRejectAOutboundFirewallRuleWithAGivenName() // for more information of creating OutboundFirewallRuleResource, please refer to the document of OutboundFirewallRuleResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "sqlcrudtest-7398"; - string serverName = "sqlcrudtest-4645"; + string serverName = "sqlcrudtest-6661"; string outboundRuleFqdn = "server.database.windows.net"; ResourceIdentifier outboundFirewallRuleResourceId = OutboundFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, outboundRuleFqdn); OutboundFirewallRuleResource outboundFirewallRule = client.GetOutboundFirewallRuleResource(outboundFirewallRuleResourceId); // invoke the operation - OutboundFirewallRuleData data = new OutboundFirewallRuleData(); - ArmOperation lro = await outboundFirewallRule.UpdateAsync(WaitUntil.Completed, data); - OutboundFirewallRuleResource result = lro.Value; + await outboundFirewallRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OutboundFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAOutboundFirewallRuleWithAGivenName() + public async Task Update_ApproveOrRejectAOutboundFirewallRuleWithAGivenName() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleDelete.json - // this example is just showing the usage of "OutboundFirewallRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/OutboundFirewallRuleCreate.json + // this example is just showing the usage of "OutboundFirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,15 +89,21 @@ public async Task Delete_DeletesAOutboundFirewallRuleWithAGivenName() // for more information of creating OutboundFirewallRuleResource, please refer to the document of OutboundFirewallRuleResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "sqlcrudtest-7398"; - string serverName = "sqlcrudtest-6661"; + string serverName = "sqlcrudtest-4645"; string outboundRuleFqdn = "server.database.windows.net"; ResourceIdentifier outboundFirewallRuleResourceId = OutboundFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, outboundRuleFqdn); OutboundFirewallRuleResource outboundFirewallRule = client.GetOutboundFirewallRuleResource(outboundFirewallRuleResourceId); // invoke the operation - await outboundFirewallRule.DeleteAsync(WaitUntil.Completed); + OutboundFirewallRuleData data = new OutboundFirewallRuleData(); + ArmOperation lro = await outboundFirewallRule.UpdateAsync(WaitUntil.Completed, data); + OutboundFirewallRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OutboundFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecommendedActionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecommendedActionCollection.cs index 623ab20bafebb..2f297cf9a8bfb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecommendedActionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecommendedActionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RecommendedActionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfDatabaseRecommendedActions() + public async Task Get_GetDatabaseRecommendedAction() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRecommendedActionList.json - // this example is just showing the usage of "DatabaseRecommendedActions_ListByDatabaseAdvisor" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRecommendedActionGet.json + // this example is just showing the usage of "DatabaseRecommendedActions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListOfDatabaseRecommendedActions() // get the collection of this RecommendedActionResource RecommendedActionCollection collection = sqlDatabaseAdvisor.GetRecommendedActions(); - // invoke the operation and iterate over the result - await foreach (RecommendedActionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecommendedActionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string recommendedActionName = "IR_[CRM]_[DataPoints]_4821CD2F9510D98184BB"; + RecommendedActionResource result = await collection.GetAsync(recommendedActionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecommendedActionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatabaseRecommendedAction() + public async Task GetAll_ListOfDatabaseRecommendedActions() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRecommendedActionGet.json - // this example is just showing the usage of "DatabaseRecommendedActions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRecommendedActionList.json + // this example is just showing the usage of "DatabaseRecommendedActions_ListByDatabaseAdvisor" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetDatabaseRecommendedAction() // get the collection of this RecommendedActionResource RecommendedActionCollection collection = sqlDatabaseAdvisor.GetRecommendedActions(); - // invoke the operation - string recommendedActionName = "IR_[CRM]_[DataPoints]_4821CD2F9510D98184BB"; - RecommendedActionResource result = await collection.GetAsync(recommendedActionName); + // invoke the operation and iterate over the result + await foreach (RecommendedActionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecommendedActionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecommendedActionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecommendedActionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecommendedActionResource.cs index 2d16086acd63e..0794a2b14fa6b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecommendedActionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecommendedActionResource.cs @@ -73,7 +73,7 @@ public async Task Update_UpdateDatabaseRecommendedAction() RecommendedActionResource recommendedAction = client.GetRecommendedActionResource(recommendedActionResourceId); // invoke the operation - RecommendedActionData data = new RecommendedActionData() + RecommendedActionData data = new RecommendedActionData { State = new RecommendedActionStateInfo(RecommendedActionCurrentState.Pending), }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecoverableDatabaseCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecoverableDatabaseCollection.cs index 3d588186c2caf..fd0e7913c1e38 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecoverableDatabaseCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecoverableDatabaseCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RecoverableDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetListOfRecoverableDatabases() + public async Task Get_GetARecoverableDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseList.json - // this example is just showing the usage of "RecoverableDatabases_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseGet.json + // this example is just showing the usage of "RecoverableDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,32 +30,30 @@ public async Task GetAll_GetListOfRecoverableDatabases() // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "recoverabledatabasetest-1234"; - string serverName = "recoverabledatabasetest-7177"; + string resourceGroupName = "recoverabledatabasetest-6852"; + string serverName = "recoverabledatabasetest-2080"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); // get the collection of this RecoverableDatabaseResource RecoverableDatabaseCollection collection = sqlServer.GetRecoverableDatabases(); - // invoke the operation and iterate over the result - await foreach (RecoverableDatabaseResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoverableDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string databaseName = "recoverabledatabasetest-9187"; + RecoverableDatabaseResource result = await collection.GetAsync(databaseName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoverableDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARecoverableDatabase() + public async Task Get_GetsARecoverableDatabaseWithExpandEqualsKeys() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseGet.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseGetWithExpandEqualsKeys.json // this example is just showing the usage of "RecoverableDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -76,7 +74,8 @@ public async Task Get_GetARecoverableDatabase() // invoke the operation string databaseName = "recoverabledatabasetest-9187"; - RecoverableDatabaseResource result = await collection.GetAsync(databaseName); + string expand = "keys"; + RecoverableDatabaseResource result = await collection.GetAsync(databaseName, expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,10 +86,10 @@ public async Task Get_GetARecoverableDatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetARecoverableDatabase() + public async Task GetAll_GetListOfRecoverableDatabases() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseGet.json - // this example is just showing the usage of "RecoverableDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseList.json + // this example is just showing the usage of "RecoverableDatabases_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,24 +99,30 @@ public async Task Exists_GetARecoverableDatabase() // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "recoverabledatabasetest-6852"; - string serverName = "recoverabledatabasetest-2080"; + string resourceGroupName = "recoverabledatabasetest-1234"; + string serverName = "recoverabledatabasetest-7177"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); // get the collection of this RecoverableDatabaseResource RecoverableDatabaseCollection collection = sqlServer.GetRecoverableDatabases(); - // invoke the operation - string databaseName = "recoverabledatabasetest-9187"; - bool result = await collection.ExistsAsync(databaseName); + // invoke the operation and iterate over the result + await foreach (RecoverableDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoverableDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetARecoverableDatabase() + public async Task Exists_GetARecoverableDatabase() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseGet.json // this example is just showing the usage of "RecoverableDatabases_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,26 +145,14 @@ public async Task GetIfExists_GetARecoverableDatabase() // invoke the operation string databaseName = "recoverabledatabasetest-9187"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - RecoverableDatabaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(databaseName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoverableDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsARecoverableDatabaseWithExpandEqualsKeys() + public async Task Exists_GetsARecoverableDatabaseWithExpandEqualsKeys() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseGetWithExpandEqualsKeys.json // this example is just showing the usage of "RecoverableDatabases_Get" operation, for the dependent resources, they will have to be created separately. @@ -183,20 +176,16 @@ public async Task Get_GetsARecoverableDatabaseWithExpandEqualsKeys() // invoke the operation string databaseName = "recoverabledatabasetest-9187"; string expand = "keys"; - RecoverableDatabaseResource result = await collection.GetAsync(databaseName, expand: expand); + bool result = await collection.ExistsAsync(databaseName, expand: expand); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoverableDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsARecoverableDatabaseWithExpandEqualsKeys() + public async Task GetIfExists_GetARecoverableDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseGetWithExpandEqualsKeys.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/RecoverableDatabaseGet.json // this example is just showing the usage of "RecoverableDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -217,10 +206,21 @@ public async Task Exists_GetsARecoverableDatabaseWithExpandEqualsKeys() // invoke the operation string databaseName = "recoverabledatabasetest-9187"; - string expand = "keys"; - bool result = await collection.ExistsAsync(databaseName, expand: expand); + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + RecoverableDatabaseResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoverableDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecoverableManagedDatabaseCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecoverableManagedDatabaseCollection.cs index 9d4a297397c47..c39dce04371b5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecoverableManagedDatabaseCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RecoverableManagedDatabaseCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RecoverableManagedDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRecoverableDatabasesByManagedInstances() + public async Task Get_GetsARecoverableDatabasesByManagedInstances() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListRecoverableManagedDatabasesByServer.json - // this example is just showing the usage of "RecoverableManagedDatabases_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetRecoverableManagedDatabase.json + // this example is just showing the usage of "RecoverableManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListRecoverableDatabasesByManagedInstances() // get the collection of this RecoverableManagedDatabaseResource RecoverableManagedDatabaseCollection collection = managedInstance.GetRecoverableManagedDatabases(); - // invoke the operation and iterate over the result - await foreach (RecoverableManagedDatabaseResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoverableManagedDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string recoverableDatabaseName = "testdb"; + RecoverableManagedDatabaseResource result = await collection.GetAsync(recoverableDatabaseName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoverableManagedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsARecoverableDatabasesByManagedInstances() + public async Task GetAll_ListRecoverableDatabasesByManagedInstances() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetRecoverableManagedDatabase.json - // this example is just showing the usage of "RecoverableManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListRecoverableManagedDatabasesByServer.json + // this example is just showing the usage of "RecoverableManagedDatabases_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsARecoverableDatabasesByManagedInstances() // get the collection of this RecoverableManagedDatabaseResource RecoverableManagedDatabaseCollection collection = managedInstance.GetRecoverableManagedDatabases(); - // invoke the operation - string recoverableDatabaseName = "testdb"; - RecoverableManagedDatabaseResource result = await collection.GetAsync(recoverableDatabaseName); + // invoke the operation and iterate over the result + await foreach (RecoverableManagedDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecoverableManagedDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecoverableManagedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionBackupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionBackupCollection.cs index 984d4ffff97b0..251d6c9ac603e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionBackupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionBackupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ResourceGroupLongTermRetentionBackupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() + public async Task Get_GetTheLongTermRetentionBackup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByDatabase.json - // this example is just showing the usage of "LongTermRetentionBackups_ListByResourceGroupDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupGet.json + // this example is just showing the usage of "LongTermRetentionBackups_GetByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() string longTermRetentionDatabaseName = "testDatabase"; ResourceGroupLongTermRetentionBackupCollection collection = resourceGroupResource.GetResourceGroupLongTermRetentionBackups(locationName, longTermRetentionServerName, longTermRetentionDatabaseName); - // invoke the operation and iterate over the result - await foreach (ResourceGroupLongTermRetentionBackupResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LongTermRetentionBackupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string backupName = "55555555-6666-7777-8888-999999999999;131637960820000000;Archive"; + ResourceGroupLongTermRetentionBackupResource result = await collection.GetAsync(backupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LongTermRetentionBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheLongTermRetentionBackup() + public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupGet.json - // this example is just showing the usage of "LongTermRetentionBackups_GetByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ResourceGroupBasedLongTermRetentionBackupListByDatabase.json + // this example is just showing the usage of "LongTermRetentionBackups_ListByResourceGroupDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +77,17 @@ public async Task Get_GetTheLongTermRetentionBackup() string longTermRetentionDatabaseName = "testDatabase"; ResourceGroupLongTermRetentionBackupCollection collection = resourceGroupResource.GetResourceGroupLongTermRetentionBackups(locationName, longTermRetentionServerName, longTermRetentionDatabaseName); - // invoke the operation - string backupName = "55555555-6666-7777-8888-999999999999;131637960820000000;Archive"; - ResourceGroupLongTermRetentionBackupResource result = await collection.GetAsync(backupName); + // invoke the operation and iterate over the result + await foreach (ResourceGroupLongTermRetentionBackupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LongTermRetentionBackupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LongTermRetentionBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionBackupResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionBackupResource.cs index 492fe7eb6a892..2bee54a22ee1b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionBackupResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionBackupResource.cs @@ -137,7 +137,7 @@ public async Task CopyByResourceGroup_CopyTheLongTermRetentionBackup() ResourceGroupLongTermRetentionBackupResource resourceGroupLongTermRetentionBackup = client.GetResourceGroupLongTermRetentionBackupResource(resourceGroupLongTermRetentionBackupResourceId); // invoke the operation - CopyLongTermRetentionBackupContent content = new CopyLongTermRetentionBackupContent() + CopyLongTermRetentionBackupContent content = new CopyLongTermRetentionBackupContent { TargetServerResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Sql/resourceGroups/resourceGroup/servers/testserver2"), TargetDatabaseName = "testDatabase2", @@ -173,7 +173,7 @@ public async Task UpdateByResourceGroup_UpdateTheLongTermRetentionBackup() ResourceGroupLongTermRetentionBackupResource resourceGroupLongTermRetentionBackup = client.GetResourceGroupLongTermRetentionBackupResource(resourceGroupLongTermRetentionBackupResourceId); // invoke the operation - UpdateLongTermRetentionBackupContent content = new UpdateLongTermRetentionBackupContent() + UpdateLongTermRetentionBackupContent content = new UpdateLongTermRetentionBackupContent { RequestedBackupStorageRedundancy = SqlBackupStorageRedundancy.Geo, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionManagedInstanceBackupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionManagedInstanceBackupCollection.cs index 86f01bfd198cb..5041861d86af7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionManagedInstanceBackupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ResourceGroupLongTermRetentionManagedInstanceBackupCollection.cs @@ -54,10 +54,10 @@ public async Task Get_GetTheLongTermRetentionBackup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheLongTermRetentionBackup() + public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupGet.json - // this example is just showing the usage of "LongTermRetentionManagedInstanceBackups_GetByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByDatabase.json + // this example is just showing the usage of "LongTermRetentionManagedInstanceBackups_ListByResourceGroupDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,16 +77,22 @@ public async Task Exists_GetTheLongTermRetentionBackup() string databaseName = "testDatabase"; ResourceGroupLongTermRetentionManagedInstanceBackupCollection collection = resourceGroupResource.GetResourceGroupLongTermRetentionManagedInstanceBackups(locationName, managedInstanceName, databaseName); - // invoke the operation - string backupName = "55555555-6666-7777-8888-999999999999;131637960820000000"; - bool result = await collection.ExistsAsync(backupName); + // invoke the operation and iterate over the result + await foreach (ResourceGroupLongTermRetentionManagedInstanceBackupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceLongTermRetentionBackupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheLongTermRetentionBackup() + public async Task Exists_GetTheLongTermRetentionBackup() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupGet.json // this example is just showing the usage of "LongTermRetentionManagedInstanceBackups_GetByResourceGroup" operation, for the dependent resources, they will have to be created separately. @@ -111,29 +117,17 @@ public async Task GetIfExists_GetTheLongTermRetentionBackup() // invoke the operation string backupName = "55555555-6666-7777-8888-999999999999;131637960820000000"; - NullableResponse response = await collection.GetIfExistsAsync(backupName); - ResourceGroupLongTermRetentionManagedInstanceBackupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(backupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceLongTermRetentionBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() + public async Task GetIfExists_GetTheLongTermRetentionBackup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupListByDatabase.json - // this example is just showing the usage of "LongTermRetentionManagedInstanceBackups_ListByResourceGroupDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ResourceGroupBasedManagedInstanceLongTermRetentionBackupGet.json + // this example is just showing the usage of "LongTermRetentionManagedInstanceBackups_GetByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -153,17 +147,23 @@ public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() string databaseName = "testDatabase"; ResourceGroupLongTermRetentionManagedInstanceBackupCollection collection = resourceGroupResource.GetResourceGroupLongTermRetentionManagedInstanceBackups(locationName, managedInstanceName, databaseName); - // invoke the operation and iterate over the result - await foreach (ResourceGroupLongTermRetentionManagedInstanceBackupResource item in collection.GetAllAsync()) + // invoke the operation + string backupName = "55555555-6666-7777-8888-999999999999;131637960820000000"; + NullableResponse response = await collection.GetIfExistsAsync(backupName); + ResourceGroupLongTermRetentionManagedInstanceBackupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceLongTermRetentionBackupData resourceData = item.Data; + ManagedInstanceLongTermRetentionBackupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RestorableDroppedDatabaseCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RestorableDroppedDatabaseCollection.cs index eba72b2694744..8351f33f02282 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RestorableDroppedDatabaseCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RestorableDroppedDatabaseCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RestorableDroppedDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfRestorableDroppedDatabases() + public async Task Get_GetsARestorableDroppedDatabaseWithExpandEqualsKeys() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ListRestorableDroppedDatabasesByServer.json - // this example is just showing the usage of "RestorableDroppedDatabases_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetRestorableDroppedDatabaseWithExpandEqualsKeys.json + // this example is just showing the usage of "RestorableDroppedDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,24 +38,23 @@ public async Task GetAll_GetsAListOfRestorableDroppedDatabases() // get the collection of this RestorableDroppedDatabaseResource RestorableDroppedDatabaseCollection collection = sqlServer.GetRestorableDroppedDatabases(); - // invoke the operation and iterate over the result - await foreach (RestorableDroppedDatabaseResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorableDroppedDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string restorableDroppedDatabaseId = "testdb,131403269876900000"; + string expand = "keys"; + RestorableDroppedDatabaseResource result = await collection.GetAsync(restorableDroppedDatabaseId, expand: expand); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorableDroppedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsARestorableDroppedDatabaseWithExpandEqualsKeys() + public async Task Get_GetsARestorableDroppedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetRestorableDroppedDatabaseWithExpandEqualsKeys.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetRestorableDroppedDatabase.json // this example is just showing the usage of "RestorableDroppedDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -76,8 +75,7 @@ public async Task Get_GetsARestorableDroppedDatabaseWithExpandEqualsKeys() // invoke the operation string restorableDroppedDatabaseId = "testdb,131403269876900000"; - string expand = "keys"; - RestorableDroppedDatabaseResource result = await collection.GetAsync(restorableDroppedDatabaseId, expand: expand); + RestorableDroppedDatabaseResource result = await collection.GetAsync(restorableDroppedDatabaseId); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +86,10 @@ public async Task Get_GetsARestorableDroppedDatabaseWithExpandEqualsKeys() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsARestorableDroppedDatabaseWithExpandEqualsKeys() + public async Task GetAll_GetsAListOfRestorableDroppedDatabases() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetRestorableDroppedDatabaseWithExpandEqualsKeys.json - // this example is just showing the usage of "RestorableDroppedDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ListRestorableDroppedDatabasesByServer.json + // this example is just showing the usage of "RestorableDroppedDatabases_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,17 +107,22 @@ public async Task Exists_GetsARestorableDroppedDatabaseWithExpandEqualsKeys() // get the collection of this RestorableDroppedDatabaseResource RestorableDroppedDatabaseCollection collection = sqlServer.GetRestorableDroppedDatabases(); - // invoke the operation - string restorableDroppedDatabaseId = "testdb,131403269876900000"; - string expand = "keys"; - bool result = await collection.ExistsAsync(restorableDroppedDatabaseId, expand: expand); + // invoke the operation and iterate over the result + await foreach (RestorableDroppedDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorableDroppedDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsARestorableDroppedDatabaseWithExpandEqualsKeys() + public async Task Exists_GetsARestorableDroppedDatabaseWithExpandEqualsKeys() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetRestorableDroppedDatabaseWithExpandEqualsKeys.json // this example is just showing the usage of "RestorableDroppedDatabases_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,26 +146,14 @@ public async Task GetIfExists_GetsARestorableDroppedDatabaseWithExpandEqualsKeys // invoke the operation string restorableDroppedDatabaseId = "testdb,131403269876900000"; string expand = "keys"; - NullableResponse response = await collection.GetIfExistsAsync(restorableDroppedDatabaseId, expand: expand); - RestorableDroppedDatabaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(restorableDroppedDatabaseId, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorableDroppedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsARestorableDroppedDatabase() + public async Task Exists_GetsARestorableDroppedDatabase() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetRestorableDroppedDatabase.json // this example is just showing the usage of "RestorableDroppedDatabases_Get" operation, for the dependent resources, they will have to be created separately. @@ -185,20 +176,16 @@ public async Task Get_GetsARestorableDroppedDatabase() // invoke the operation string restorableDroppedDatabaseId = "testdb,131403269876900000"; - RestorableDroppedDatabaseResource result = await collection.GetAsync(restorableDroppedDatabaseId); + bool result = await collection.ExistsAsync(restorableDroppedDatabaseId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorableDroppedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsARestorableDroppedDatabase() + public async Task GetIfExists_GetsARestorableDroppedDatabaseWithExpandEqualsKeys() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetRestorableDroppedDatabase.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/GetRestorableDroppedDatabaseWithExpandEqualsKeys.json // this example is just showing the usage of "RestorableDroppedDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -219,9 +206,22 @@ public async Task Exists_GetsARestorableDroppedDatabase() // invoke the operation string restorableDroppedDatabaseId = "testdb,131403269876900000"; - bool result = await collection.ExistsAsync(restorableDroppedDatabaseId); + string expand = "keys"; + NullableResponse response = await collection.GetIfExistsAsync(restorableDroppedDatabaseId, expand: expand); + RestorableDroppedDatabaseResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorableDroppedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RestorableDroppedManagedDatabaseCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RestorableDroppedManagedDatabaseCollection.cs index 8aa2d25b9826a..756c5c67f0d4c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RestorableDroppedManagedDatabaseCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_RestorableDroppedManagedDatabaseCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RestorableDroppedManagedDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRestorableDroppedDatabasesByManagedInstances() + public async Task Get_GetsARestorableDroppedManagedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/RestorableDroppedManagedDatabaseListByManagedInstance.json - // this example is just showing the usage of "RestorableDroppedManagedDatabases_ListByInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/GetRestorableDroppedManagedDatabase.json + // this example is just showing the usage of "RestorableDroppedManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListRestorableDroppedDatabasesByManagedInstances() // get the collection of this RestorableDroppedManagedDatabaseResource RestorableDroppedManagedDatabaseCollection collection = managedInstance.GetRestorableDroppedManagedDatabases(); - // invoke the operation and iterate over the result - await foreach (RestorableDroppedManagedDatabaseResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorableDroppedManagedDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string restorableDroppedDatabaseId = "testdb,131403269876900000"; + RestorableDroppedManagedDatabaseResource result = await collection.GetAsync(restorableDroppedDatabaseId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorableDroppedManagedDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsARestorableDroppedManagedDatabase() + public async Task GetAll_ListRestorableDroppedDatabasesByManagedInstances() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/GetRestorableDroppedManagedDatabase.json - // this example is just showing the usage of "RestorableDroppedManagedDatabases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/RestorableDroppedManagedDatabaseListByManagedInstance.json + // this example is just showing the usage of "RestorableDroppedManagedDatabases_ListByInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsARestorableDroppedManagedDatabase() // get the collection of this RestorableDroppedManagedDatabaseResource RestorableDroppedManagedDatabaseCollection collection = managedInstance.GetRestorableDroppedManagedDatabases(); - // invoke the operation - string restorableDroppedDatabaseId = "testdb,131403269876900000"; - RestorableDroppedManagedDatabaseResource result = await collection.GetAsync(restorableDroppedDatabaseId); + // invoke the operation and iterate over the result + await foreach (RestorableDroppedManagedDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorableDroppedManagedDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorableDroppedManagedDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServerAdvancedThreatProtectionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServerAdvancedThreatProtectionCollection.cs index 66bb0a414fae4..55aa857a66d6c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServerAdvancedThreatProtectionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServerAdvancedThreatProtectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServerAdvancedThreatProtectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheServerSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_UpdateAServerSAdvancedThreatProtectionSettingsWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsListByServer.json - // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsCreateMax.json + // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_ListTheServerSAdvancedThreatProtectionSettings() // get the collection of this ServerAdvancedThreatProtectionResource ServerAdvancedThreatProtectionCollection collection = sqlServer.GetServerAdvancedThreatProtections(); - // invoke the operation and iterate over the result - await foreach (ServerAdvancedThreatProtectionResource item in collection.GetAllAsync()) + // invoke the operation + AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; + ServerAdvancedThreatProtectionData data = new ServerAdvancedThreatProtectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerAdvancedThreatProtectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + State = AdvancedThreatProtectionState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); + ServerAdvancedThreatProtectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_UpdateAServerSAdvancedThreatProtectionSettingsWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsGet.json - // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsCreateMin.json + // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +80,12 @@ public async Task Get_GetAServerSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - ServerAdvancedThreatProtectionResource result = await collection.GetAsync(advancedThreatProtectionName); + ServerAdvancedThreatProtectionData data = new ServerAdvancedThreatProtectionData + { + State = AdvancedThreatProtectionState.Disabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); + ServerAdvancedThreatProtectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +96,7 @@ public async Task Get_GetAServerSAdvancedThreatProtectionSettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerSAdvancedThreatProtectionSettings() + public async Task Get_GetAServerSAdvancedThreatProtectionSettings() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsGet.json // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +119,21 @@ public async Task Exists_GetAServerSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - bool result = await collection.ExistsAsync(advancedThreatProtectionName); + ServerAdvancedThreatProtectionResource result = await collection.GetAsync(advancedThreatProtectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerSAdvancedThreatProtectionSettings() + public async Task GetAll_ListTheServerSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsGet.json - // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsListByServer.json + // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +151,25 @@ public async Task GetIfExists_GetAServerSAdvancedThreatProtectionSettings() // get the collection of this ServerAdvancedThreatProtectionResource ServerAdvancedThreatProtectionCollection collection = sqlServer.GetServerAdvancedThreatProtections(); - // invoke the operation - AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - NullableResponse response = await collection.GetIfExistsAsync(advancedThreatProtectionName); - ServerAdvancedThreatProtectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServerAdvancedThreatProtectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServerAdvancedThreatProtectionData resourceData = result.Data; + ServerAdvancedThreatProtectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSAdvancedThreatProtectionSettingsWithAllParameters() + public async Task Exists_GetAServerSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsCreateMax.json - // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsGet.json + // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +189,17 @@ public async Task CreateOrUpdate_UpdateAServerSAdvancedThreatProtectionSettingsW // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - ServerAdvancedThreatProtectionData data = new ServerAdvancedThreatProtectionData() - { - State = AdvancedThreatProtectionState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); - ServerAdvancedThreatProtectionResource result = lro.Value; + bool result = await collection.ExistsAsync(advancedThreatProtectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerAdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSAdvancedThreatProtectionSettingsWithMinimalParameters() + public async Task GetIfExists_GetAServerSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsCreateMin.json - // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAdvancedThreatProtectionSettingsGet.json + // this example is just showing the usage of "ServerAdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -222,18 +219,21 @@ public async Task CreateOrUpdate_UpdateAServerSAdvancedThreatProtectionSettingsW // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - ServerAdvancedThreatProtectionData data = new ServerAdvancedThreatProtectionData() - { - State = AdvancedThreatProtectionState.Disabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); - ServerAdvancedThreatProtectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(advancedThreatProtectionName); + ServerAdvancedThreatProtectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServerAdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServerAdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServerAdvancedThreatProtectionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServerAdvancedThreatProtectionResource.cs index 0fe69d30bbea6..e9b21691daa3b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServerAdvancedThreatProtectionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServerAdvancedThreatProtectionResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdateAServerSAdvancedThreatProtectionSettingsWithAllPa ServerAdvancedThreatProtectionResource serverAdvancedThreatProtection = client.GetServerAdvancedThreatProtectionResource(serverAdvancedThreatProtectionResourceId); // invoke the operation - ServerAdvancedThreatProtectionData data = new ServerAdvancedThreatProtectionData() + ServerAdvancedThreatProtectionData data = new ServerAdvancedThreatProtectionData { State = AdvancedThreatProtectionState.Enabled, }; @@ -105,7 +105,7 @@ public async Task Update_UpdateAServerSAdvancedThreatProtectionSettingsWithMinim ServerAdvancedThreatProtectionResource serverAdvancedThreatProtection = client.GetServerAdvancedThreatProtectionResource(serverAdvancedThreatProtectionResourceId); // invoke the operation - ServerAdvancedThreatProtectionData data = new ServerAdvancedThreatProtectionData() + ServerAdvancedThreatProtectionData data = new ServerAdvancedThreatProtectionData { State = AdvancedThreatProtectionState.Disabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServiceObjectiveCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServiceObjectiveCollection.cs index 6bf5b7fbc0bd8..2934467042a96 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServiceObjectiveCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_ServiceObjectiveCollection.cs @@ -51,10 +51,10 @@ public async Task Get_GetAServiceObjective() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServiceObjective() + public async Task GetAll_ListServiceObjectives() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServiceObjectiveGet.json - // this example is just showing the usage of "ServiceObjectives_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServiceObjectiveList.json + // this example is just showing the usage of "ServiceObjectives_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_GetAServiceObjective() // get the collection of this ServiceObjectiveResource ServiceObjectiveCollection collection = sqlServer.GetServiceObjectives(); - // invoke the operation - string serviceObjectiveName = "29dd7459-4a7c-4e56-be22-f0adda49440d"; - bool result = await collection.ExistsAsync(serviceObjectiveName); + // invoke the operation and iterate over the result + await foreach (ServiceObjectiveResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceObjectiveData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServiceObjective() + public async Task Exists_GetAServiceObjective() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServiceObjectiveGet.json // this example is just showing the usage of "ServiceObjectives_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_GetAServiceObjective() // invoke the operation string serviceObjectiveName = "29dd7459-4a7c-4e56-be22-f0adda49440d"; - NullableResponse response = await collection.GetIfExistsAsync(serviceObjectiveName); - ServiceObjectiveResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serviceObjectiveName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceObjectiveData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListServiceObjectives() + public async Task GetIfExists_GetAServiceObjective() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServiceObjectiveList.json - // this example is just showing the usage of "ServiceObjectives_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServiceObjectiveGet.json + // this example is just showing the usage of "ServiceObjectives_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ListServiceObjectives() // get the collection of this ServiceObjectiveResource ServiceObjectiveCollection collection = sqlServer.GetServiceObjectives(); - // invoke the operation and iterate over the result - await foreach (ServiceObjectiveResource item in collection.GetAllAsync()) + // invoke the operation + string serviceObjectiveName = "29dd7459-4a7c-4e56-be22-f0adda49440d"; + NullableResponse response = await collection.GetIfExistsAsync(serviceObjectiveName); + ServiceObjectiveResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceObjectiveData resourceData = item.Data; + ServiceObjectiveData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlAgentConfigurationResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlAgentConfigurationResource.cs index 46704dfd74dcc..3328b73ed5adb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlAgentConfigurationResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlAgentConfigurationResource.cs @@ -67,7 +67,7 @@ public async Task CreateOrUpdate_PutsNewSqlAgentConfigurationToInstance() SqlAgentConfigurationResource sqlAgentConfiguration = client.GetSqlAgentConfigurationResource(sqlAgentConfigurationResourceId); // invoke the operation - SqlAgentConfigurationData data = new SqlAgentConfigurationData() + SqlAgentConfigurationData data = new SqlAgentConfigurationData { State = SqlAgentConfigurationPropertiesState.Enabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAdvisorCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAdvisorCollection.cs index b16a23187e2d5..f075da9ad8dd4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAdvisorCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAdvisorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlDatabaseAdvisorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfDatabaseAdvisors() + public async Task Get_GetDatabaseAdvisor() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseAdvisorList.json - // this example is just showing the usage of "DatabaseAdvisors_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseAdvisorGet.json + // this example is just showing the usage of "DatabaseAdvisors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,24 +39,22 @@ public async Task GetAll_ListOfDatabaseAdvisors() // get the collection of this SqlDatabaseAdvisorResource SqlDatabaseAdvisorCollection collection = sqlDatabase.GetSqlDatabaseAdvisors(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseAdvisorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlAdvisorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string advisorName = "CreateIndex"; + SqlDatabaseAdvisorResource result = await collection.GetAsync(advisorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlAdvisorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfDatabaseRecommendedActionsForAllAdvisors() + public async Task GetAll_ListOfDatabaseAdvisors() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRecommendedActionListExpand.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseAdvisorList.json // this example is just showing the usage of "DatabaseAdvisors_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -77,8 +75,7 @@ public async Task GetAll_ListOfDatabaseRecommendedActionsForAllAdvisors() SqlDatabaseAdvisorCollection collection = sqlDatabase.GetSqlDatabaseAdvisors(); // invoke the operation and iterate over the result - string expand = "recommendedActions"; - await foreach (SqlDatabaseAdvisorResource item in collection.GetAllAsync(expand: expand)) + await foreach (SqlDatabaseAdvisorResource item in collection.GetAllAsync()) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +89,10 @@ public async Task GetAll_ListOfDatabaseRecommendedActionsForAllAdvisors() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatabaseAdvisor() + public async Task GetAll_ListOfDatabaseRecommendedActionsForAllAdvisors() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseAdvisorGet.json - // this example is just showing the usage of "DatabaseAdvisors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRecommendedActionListExpand.json + // this example is just showing the usage of "DatabaseAdvisors_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,15 +111,18 @@ public async Task Get_GetDatabaseAdvisor() // get the collection of this SqlDatabaseAdvisorResource SqlDatabaseAdvisorCollection collection = sqlDatabase.GetSqlDatabaseAdvisors(); - // invoke the operation - string advisorName = "CreateIndex"; - SqlDatabaseAdvisorResource result = await collection.GetAsync(advisorName); + // invoke the operation and iterate over the result + string expand = "recommendedActions"; + await foreach (SqlDatabaseAdvisorResource item in collection.GetAllAsync(expand: expand)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlAdvisorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlAdvisorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAdvisorResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAdvisorResource.cs index ef4910dfef575..c6e965cebc3ea 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAdvisorResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAdvisorResource.cs @@ -71,7 +71,7 @@ public async Task Update_UpdateDatabaseAdvisor() SqlDatabaseAdvisorResource sqlDatabaseAdvisor = client.GetSqlDatabaseAdvisorResource(sqlDatabaseAdvisorResourceId); // invoke the operation - SqlAdvisorData data = new SqlAdvisorData() + SqlAdvisorData data = new SqlAdvisorData { AutoExecuteStatus = AutoExecuteStatus.Disabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAutomaticTuningResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAutomaticTuningResource.cs index 2b17b08688cbb..96b0799b6d9d3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAutomaticTuningResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseAutomaticTuningResource.cs @@ -69,23 +69,23 @@ public async Task Update_UpdatesDatabaseAutomaticTuningSettingsWithAllProperties SqlDatabaseAutomaticTuningResource sqlDatabaseAutomaticTuning = client.GetSqlDatabaseAutomaticTuningResource(sqlDatabaseAutomaticTuningResourceId); // invoke the operation - SqlDatabaseAutomaticTuningData data = new SqlDatabaseAutomaticTuningData() + SqlDatabaseAutomaticTuningData data = new SqlDatabaseAutomaticTuningData { DesiredState = AutomaticTuningMode.Auto, Options = { -["createIndex"] = new AutomaticTuningOptions() +["createIndex"] = new AutomaticTuningOptions { DesiredState = AutomaticTuningOptionModeDesired.Off, }, -["dropIndex"] = new AutomaticTuningOptions() +["dropIndex"] = new AutomaticTuningOptions { DesiredState = AutomaticTuningOptionModeDesired.On, }, -["forceLastGoodPlan"] = new AutomaticTuningOptions() +["forceLastGoodPlan"] = new AutomaticTuningOptions { DesiredState = AutomaticTuningOptionModeDesired.Default, -}, +} }, }; SqlDatabaseAutomaticTuningResource result = await sqlDatabaseAutomaticTuning.UpdateAsync(data); @@ -119,7 +119,7 @@ public async Task Update_UpdatesDatabaseAutomaticTuningSettingsWithMinimalProper SqlDatabaseAutomaticTuningResource sqlDatabaseAutomaticTuning = client.GetSqlDatabaseAutomaticTuningResource(sqlDatabaseAutomaticTuningResourceId); // invoke the operation - SqlDatabaseAutomaticTuningData data = new SqlDatabaseAutomaticTuningData() + SqlDatabaseAutomaticTuningData data = new SqlDatabaseAutomaticTuningData { DesiredState = AutomaticTuningMode.Auto, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseBlobAuditingPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseBlobAuditingPolicyCollection.cs index d910b4b23f528..45122528b623b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseBlobAuditingPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseBlobAuditingPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseBlobAuditingPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAuditSettingsOfADatabase() + public async Task CreateOrUpdate_CreateOrUpdateADatabaseSAzureMonitorAuditingPolicyWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAuditingSettingsList.json - // this example is just showing the usage of "DatabaseBlobAuditingPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAzureMonitorAuditingCreateMin.json + // this example is just showing the usage of "DatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task GetAll_ListAuditSettingsOfADatabase() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-6852"; - string serverName = "blobauditingtest-2080"; + string resourceGroupName = "blobauditingtest-4799"; + string serverName = "blobauditingtest-6440"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -40,25 +40,29 @@ public async Task GetAll_ListAuditSettingsOfADatabase() // get the collection of this SqlDatabaseBlobAuditingPolicyResource SqlDatabaseBlobAuditingPolicyCollection collection = sqlDatabase.GetSqlDatabaseBlobAuditingPolicies(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseBlobAuditingPolicyResource item in collection.GetAllAsync()) + // invoke the operation + BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; + SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseBlobAuditingPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsAzureMonitorTargetEnabled = true, + State = BlobAuditingPolicyState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + SqlDatabaseBlobAuditingPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabaseSBlobAuditingPolicy() + public async Task CreateOrUpdate_CreateOrUpdateADatabaseSBlobAuditingPolicyWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingGet.json - // this example is just showing the usage of "DatabaseBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingCreateMax.json + // this example is just showing the usage of "DatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,8 +72,8 @@ public async Task Get_GetADatabaseSBlobAuditingPolicy() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-6852"; - string serverName = "blobauditingtest-2080"; + string resourceGroupName = "blobauditingtest-4799"; + string serverName = "blobauditingtest-6440"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -79,7 +83,20 @@ public async Task Get_GetADatabaseSBlobAuditingPolicy() // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - SqlDatabaseBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); + SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData + { + RetentionDays = 6, + AuditActionsAndGroups = { "DATABASE_LOGOUT_GROUP", "DATABASE_ROLE_MEMBER_CHANGE_GROUP", "UPDATE on database::TestDatabaseName by public" }, + IsStorageSecondaryKeyInUse = false, + IsAzureMonitorTargetEnabled = true, + QueueDelayMs = 4000, + State = BlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + SqlDatabaseBlobAuditingPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,10 +107,10 @@ public async Task Get_GetADatabaseSBlobAuditingPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADatabaseSBlobAuditingPolicy() + public async Task CreateOrUpdate_CreateOrUpdateADatabaseSBlobAuditingPolicyWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingGet.json - // this example is just showing the usage of "DatabaseBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingCreateMin.json + // this example is just showing the usage of "DatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,8 +120,8 @@ public async Task Exists_GetADatabaseSBlobAuditingPolicy() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-6852"; - string serverName = "blobauditingtest-2080"; + string resourceGroupName = "blobauditingtest-4799"; + string serverName = "blobauditingtest-6440"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -114,14 +131,25 @@ public async Task Exists_GetADatabaseSBlobAuditingPolicy() // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - bool result = await collection.ExistsAsync(blobAuditingPolicyName); + SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData + { + State = BlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + SqlDatabaseBlobAuditingPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADatabaseSBlobAuditingPolicy() + public async Task Get_GetADatabaseSBlobAuditingPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingGet.json // this example is just showing the usage of "DatabaseBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +173,21 @@ public async Task GetIfExists_GetADatabaseSBlobAuditingPolicy() // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); - SqlDatabaseBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; + SqlDatabaseBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateADatabaseSAzureMonitorAuditingPolicyWithMinimalParameters() + public async Task GetAll_ListAuditSettingsOfADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAzureMonitorAuditingCreateMin.json - // this example is just showing the usage of "DatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseAuditingSettingsList.json + // this example is just showing the usage of "DatabaseBlobAuditingPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,8 +197,8 @@ public async Task CreateOrUpdate_CreateOrUpdateADatabaseSAzureMonitorAuditingPol // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-4799"; - string serverName = "blobauditingtest-6440"; + string resourceGroupName = "blobauditingtest-6852"; + string serverName = "blobauditingtest-2080"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -186,29 +206,25 @@ public async Task CreateOrUpdate_CreateOrUpdateADatabaseSAzureMonitorAuditingPol // get the collection of this SqlDatabaseBlobAuditingPolicyResource SqlDatabaseBlobAuditingPolicyCollection collection = sqlDatabase.GetSqlDatabaseBlobAuditingPolicies(); - // invoke the operation - BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData() + // invoke the operation and iterate over the result + await foreach (SqlDatabaseBlobAuditingPolicyResource item in collection.GetAllAsync()) { - IsAzureMonitorTargetEnabled = true, - State = BlobAuditingPolicyState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - SqlDatabaseBlobAuditingPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseBlobAuditingPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateADatabaseSBlobAuditingPolicyWithAllParameters() + public async Task Exists_GetADatabaseSBlobAuditingPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingCreateMax.json - // this example is just showing the usage of "DatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingGet.json + // this example is just showing the usage of "DatabaseBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -218,8 +234,8 @@ public async Task CreateOrUpdate_CreateOrUpdateADatabaseSBlobAuditingPolicyWithA // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-4799"; - string serverName = "blobauditingtest-6440"; + string resourceGroupName = "blobauditingtest-6852"; + string serverName = "blobauditingtest-2080"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -229,37 +245,17 @@ public async Task CreateOrUpdate_CreateOrUpdateADatabaseSBlobAuditingPolicyWithA // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData() - { - RetentionDays = 6, - AuditActionsAndGroups = -{ -"DATABASE_LOGOUT_GROUP","DATABASE_ROLE_MEMBER_CHANGE_GROUP","UPDATE on database::TestDatabaseName by public" -}, - IsStorageSecondaryKeyInUse = false, - IsAzureMonitorTargetEnabled = true, - QueueDelayMs = 4000, - State = BlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - SqlDatabaseBlobAuditingPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(blobAuditingPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateADatabaseSBlobAuditingPolicyWithMinimalParameters() + public async Task GetIfExists_GetADatabaseSBlobAuditingPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingCreateMin.json - // this example is just showing the usage of "DatabaseBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/DatabaseBlobAuditingGet.json + // this example is just showing the usage of "DatabaseBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -269,8 +265,8 @@ public async Task CreateOrUpdate_CreateOrUpdateADatabaseSBlobAuditingPolicyWithM // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "blobauditingtest-4799"; - string serverName = "blobauditingtest-6440"; + string resourceGroupName = "blobauditingtest-6852"; + string serverName = "blobauditingtest-2080"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -280,20 +276,21 @@ public async Task CreateOrUpdate_CreateOrUpdateADatabaseSBlobAuditingPolicyWithM // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData() - { - State = BlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - SqlDatabaseBlobAuditingPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); + SqlDatabaseBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseBlobAuditingPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseBlobAuditingPolicyResource.cs index e02a13be35b3a..f50bf0f40953b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseBlobAuditingPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseBlobAuditingPolicyResource.cs @@ -71,7 +71,7 @@ public async Task Update_CreateOrUpdateADatabaseSAzureMonitorAuditingPolicyWithM SqlDatabaseBlobAuditingPolicyResource sqlDatabaseBlobAuditingPolicy = client.GetSqlDatabaseBlobAuditingPolicyResource(sqlDatabaseBlobAuditingPolicyResourceId); // invoke the operation - SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData() + SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData { IsAzureMonitorTargetEnabled = true, State = BlobAuditingPolicyState.Enabled, @@ -109,13 +109,10 @@ public async Task Update_CreateOrUpdateADatabaseSBlobAuditingPolicyWithAllParame SqlDatabaseBlobAuditingPolicyResource sqlDatabaseBlobAuditingPolicy = client.GetSqlDatabaseBlobAuditingPolicyResource(sqlDatabaseBlobAuditingPolicyResourceId); // invoke the operation - SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData() + SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData { RetentionDays = 6, - AuditActionsAndGroups = -{ -"DATABASE_LOGOUT_GROUP","DATABASE_ROLE_MEMBER_CHANGE_GROUP","UPDATE on database::TestDatabaseName by public" -}, + AuditActionsAndGroups = { "DATABASE_LOGOUT_GROUP", "DATABASE_ROLE_MEMBER_CHANGE_GROUP", "UPDATE on database::TestDatabaseName by public" }, IsStorageSecondaryKeyInUse = false, IsAzureMonitorTargetEnabled = true, QueueDelayMs = 4000, @@ -157,7 +154,7 @@ public async Task Update_CreateOrUpdateADatabaseSBlobAuditingPolicyWithMinimalPa SqlDatabaseBlobAuditingPolicyResource sqlDatabaseBlobAuditingPolicy = client.GetSqlDatabaseBlobAuditingPolicyResource(sqlDatabaseBlobAuditingPolicyResourceId); // invoke the operation - SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData() + SqlDatabaseBlobAuditingPolicyData data = new SqlDatabaseBlobAuditingPolicyData { State = BlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseCollection.cs index ea5d6a69d19e6..289a1c85b8acc 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SqlDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfDatabasesConfiguredWithEnclaveType() + public async Task CreateOrUpdate_CreatesAVCoreDatabaseBySpecifyingServiceObjectiveName() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreDatabasesEnclaveTypeByServer.json - // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateVCoreDatabaseByServiceObjective.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,32 @@ public async Task GetAll_GetsAListOfDatabasesConfiguredWithEnclaveType() // get the collection of this SqlDatabaseResource SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "testdb"; + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new SqlSku("BC") + { + Family = "Gen4", + Capacity = 2, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfDatabases() + public async Task CreateOrUpdate_CreatesAVCoreDatabaseBySpecifyingSkuNameAndCapacity() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreDatabasesByServer.json - // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateVCoreDatabaseBySkuNameCapacity.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,25 +83,31 @@ public async Task GetAll_GetsAListOfDatabases() // get the collection of this SqlDatabaseResource SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "testdb"; + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new SqlSku("BC_Gen4") + { + Capacity = 2, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseConfiguredWithDefaultEnclaveType() + public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscriptionRestoreFromABackupOfADroppedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionRestore.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,8 +126,14 @@ public async Task Get_GetsADatabaseConfiguredWithDefaultEnclaveType() SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); // invoke the operation - string databaseName = "testdb"; - SqlDatabaseResource result = await collection.GetAsync(databaseName); + string databaseName = "testdw"; + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + { + CreateMode = SqlDatabaseCreateMode.Restore, + SourceResourceId = new ResourceIdentifier("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/restorableDroppedDatabases/srcdw,131403269876900000"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -125,10 +144,10 @@ public async Task Get_GetsADatabaseConfiguredWithDefaultEnclaveType() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsADatabaseConfiguredWithDefaultEnclaveType() + public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscriptionRestoreFromAGeoBackup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionRecovery.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,7 +157,7 @@ public async Task Exists_GetsADatabaseConfiguredWithDefaultEnclaveType() // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; + string resourceGroupName = "Default-SQL-WestUS"; string serverName = "testsvr"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); @@ -147,18 +166,28 @@ public async Task Exists_GetsADatabaseConfiguredWithDefaultEnclaveType() SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); // invoke the operation - string databaseName = "testdb"; - bool result = await collection.ExistsAsync(databaseName); + string databaseName = "testdw"; + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("westus")) + { + CreateMode = SqlDatabaseCreateMode.Recovery, + SourceResourceId = new ResourceIdentifier("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-EastUS/providers/Microsoft.Sql/servers/srcsvr/recoverabledatabases/srcdw"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsADatabaseConfiguredWithDefaultEnclaveType() + public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscriptionRestoreFromARestorePointOfAnExistingDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionPITR.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,30 +206,29 @@ public async Task GetIfExists_GetsADatabaseConfiguredWithDefaultEnclaveType() SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); // invoke the operation - string databaseName = "testdb"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - SqlDatabaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string databaseName = "testdw"; + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CreateMode = SqlDatabaseCreateMode.PointInTimeRestore, + RestorePointInTime = DateTimeOffset.Parse("2022-01-22T05:35:31.503Z"), + SourceResourceId = new ResourceIdentifier("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/databases/srcdw"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseConfiguredWithVBSEnclaveType() + public async Task CreateOrUpdate_CreatesADatabaseAsACopy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseCopyMode.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -219,8 +247,18 @@ public async Task Get_GetsADatabaseConfiguredWithVBSEnclaveType() SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); // invoke the operation - string databaseName = "testdb"; - SqlDatabaseResource result = await collection.GetAsync(databaseName); + string databaseName = "dbcopy"; + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + { + Sku = new SqlSku("S0") + { + Tier = "Standard", + }, + CreateMode = SqlDatabaseCreateMode.Copy, + SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -231,10 +269,10 @@ public async Task Get_GetsADatabaseConfiguredWithVBSEnclaveType() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsADatabaseConfiguredWithVBSEnclaveType() + public async Task CreateOrUpdate_CreatesADatabaseAsAStandbySecondary() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseStandbyMode.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -254,17 +292,32 @@ public async Task Exists_GetsADatabaseConfiguredWithVBSEnclaveType() // invoke the operation string databaseName = "testdb"; - bool result = await collection.ExistsAsync(databaseName); + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + { + Sku = new SqlSku("S0") + { + Tier = "Standard", + }, + CreateMode = SqlDatabaseCreateMode.Secondary, + SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb"), + SecondaryType = SecondaryType.Standby, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsADatabaseConfiguredWithVBSEnclaveType() + public async Task CreateOrUpdate_CreatesADatabaseAsAnOnLineSecondary() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseSecondaryMode.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -284,29 +337,32 @@ public async Task GetIfExists_GetsADatabaseConfiguredWithVBSEnclaveType() // invoke the operation string databaseName = "testdb"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - SqlDatabaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new SqlSku("S0") + { + Tier = "Standard", + }, + CreateMode = SqlDatabaseCreateMode.Secondary, + SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb"), + SecondaryType = SecondaryType.Geo, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseWithAvailabilityZoneSpecified() + public async Task CreateOrUpdate_CreatesADatabaseAsNamedReplicaSecondary() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseNamedReplica.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -326,7 +382,19 @@ public async Task Get_GetsADatabaseWithAvailabilityZoneSpecified() // invoke the operation string databaseName = "testdb"; - SqlDatabaseResource result = await collection.GetAsync(databaseName); + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + { + Sku = new SqlSku("HS_Gen4") + { + Tier = "Hyperscale", + Capacity = 2, + }, + CreateMode = SqlDatabaseCreateMode.Secondary, + SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/primarydb"), + SecondaryType = SecondaryType.Named, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -337,10 +405,10 @@ public async Task Get_GetsADatabaseWithAvailabilityZoneSpecified() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsADatabaseWithAvailabilityZoneSpecified() + public async Task CreateOrUpdate_CreatesADatabaseFromPointInTimeRestore() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabasePITRMode.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -359,18 +427,29 @@ public async Task Exists_GetsADatabaseWithAvailabilityZoneSpecified() SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); // invoke the operation - string databaseName = "testdb"; - bool result = await collection.ExistsAsync(databaseName); + string databaseName = "dbpitr"; + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + { + CreateMode = SqlDatabaseCreateMode.PointInTimeRestore, + SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SoutheastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb"), + RestorePointInTime = DateTimeOffset.Parse("2020-10-22T05:35:31.503Z"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsADatabaseWithAvailabilityZoneSpecified() + public async Task CreateOrUpdate_CreatesADatabaseWithDefaultEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultEnclave.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -390,29 +469,26 @@ public async Task GetIfExists_GetsADatabaseWithAvailabilityZoneSpecified() // invoke the operation string databaseName = "testdb"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - SqlDatabaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Default, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseWithDatabaseLevelKeysExpanded() + public async Task CreateOrUpdate_CreatesADatabaseWithVBSEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseVBSEnclave.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -432,8 +508,12 @@ public async Task Get_GetsADatabaseWithDatabaseLevelKeysExpanded() // invoke the operation string databaseName = "testdb"; - string expand = "keys"; - SqlDatabaseResource result = await collection.GetAsync(databaseName, expand: expand); + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + { + PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Vbs, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -444,10 +524,10 @@ public async Task Get_GetsADatabaseWithDatabaseLevelKeysExpanded() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsADatabaseWithDatabaseLevelKeysExpanded() + public async Task CreateOrUpdate_CreatesADatabaseWithAvailabilityZoneSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseWithAvailabilityZone.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -467,18 +547,33 @@ public async Task Exists_GetsADatabaseWithDatabaseLevelKeysExpanded() // invoke the operation string databaseName = "testdb"; - string expand = "keys"; - bool result = await collection.ExistsAsync(databaseName, expand: expand); + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + { + Sku = new SqlSku("S0") + { + Tier = "Standard", + }, + CreateMode = SqlDatabaseCreateMode.Default, + Collation = "SQL_Latin1_General_CP1_CI_AS", + MaxSizeBytes = 1073741824L, + AvailabilityZone = SqlAvailabilityZoneType.One, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsADatabaseWithDatabaseLevelKeysExpanded() + public async Task CreateOrUpdate_CreatesADatabaseWithDatabaseLevelCustomerManagedKeys() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -498,30 +593,46 @@ public async Task GetIfExists_GetsADatabaseWithDatabaseLevelKeysExpanded() // invoke the operation string databaseName = "testdb"; - string expand = "keys"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName, expand: expand); - SqlDatabaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new SqlSku("S0") + { + Tier = "Standard", + }, + Identity = new DatabaseIdentity + { + IdentityType = DatabaseIdentityType.UserAssigned, + UserAssignedIdentities = +{ +["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi"] = new UserAssignedIdentity() +}, + }, + CreateMode = SqlDatabaseCreateMode.Default, + Collation = "SQL_Latin1_General_CP1_CI_AS", + MaxSizeBytes = 1073741824L, + Keys = +{ +["https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion"] = new SqlDatabaseKey(), +["https://your-key-vault-name.vault.azure.net/yourKey2/yourKey2Version"] = new SqlDatabaseKey() +}, + EncryptionProtector = "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabase() + public async Task CreateOrUpdate_CreatesADatabaseWithDefaultMode() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultMode.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -541,7 +652,18 @@ public async Task Get_GetsADatabase() // invoke the operation string databaseName = "testdb"; - SqlDatabaseResource result = await collection.GetAsync(databaseName); + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + { + Sku = new SqlSku("S0") + { + Tier = "Standard", + }, + CreateMode = SqlDatabaseCreateMode.Default, + Collation = "SQL_Latin1_General_CP1_CI_AS", + MaxSizeBytes = 1073741824L, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -552,10 +674,10 @@ public async Task Get_GetsADatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsADatabase() + public async Task CreateOrUpdate_CreatesADatabaseWithLedgerOn() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseLedger.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -575,17 +697,26 @@ public async Task Exists_GetsADatabase() // invoke the operation string databaseName = "testdb"; - bool result = await collection.ExistsAsync(databaseName); + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + { + IsLedgerOn = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsADatabase() + public async Task CreateOrUpdate_CreatesADatabaseWithMinimumNumberOfParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseMin.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -605,28 +736,22 @@ public async Task GetIfExists_GetsADatabase() // invoke the operation string databaseName = "testdb"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - SqlDatabaseResource result = response.HasValue ? response.Value : null; + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + SqlDatabaseResource result = lro.Value; - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAVCoreDatabaseBySpecifyingServiceObjectiveName() + public async Task CreateOrUpdate_CreatesADatabaseWithPreferredMaintenanceWindow() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateVCoreDatabaseByServiceObjective.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseMaintenanceConfiguration.json // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -649,11 +774,14 @@ public async Task CreateOrUpdate_CreatesAVCoreDatabaseBySpecifyingServiceObjecti string databaseName = "testdb"; SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) { - Sku = new SqlSku("BC") + Sku = new SqlSku("S2") { - Family = "Gen4", - Capacity = 2, + Tier = "Standard", }, + CreateMode = SqlDatabaseCreateMode.Default, + Collation = "SQL_Latin1_General_CP1_CI_AS", + MaxSizeBytes = 1073741824L, + MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); SqlDatabaseResource result = lro.Value; @@ -667,9 +795,9 @@ public async Task CreateOrUpdate_CreatesAVCoreDatabaseBySpecifyingServiceObjecti [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAVCoreDatabaseBySpecifyingSkuNameAndCapacity() + public async Task CreateOrUpdate_CreatesADatabaseWithSpecifiedBackupStorageRedundancy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateVCoreDatabaseBySkuNameCapacity.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseConfiguredBackupStorageRedundancy.json // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -692,10 +820,7 @@ public async Task CreateOrUpdate_CreatesAVCoreDatabaseBySpecifyingSkuNameAndCapa string databaseName = "testdb"; SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) { - Sku = new SqlSku("BC_Gen4") - { - Capacity = 2, - }, + RequestedBackupStorageRedundancy = SqlBackupStorageRedundancy.Zone, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); SqlDatabaseResource result = lro.Value; @@ -709,9 +834,9 @@ public async Task CreateOrUpdate_CreatesAVCoreDatabaseBySpecifyingSkuNameAndCapa [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscriptionRestoreFromABackupOfADroppedDatabase() + public async Task CreateOrUpdate_UpdatesADatabaseToHyperscaleSLOWithManualCutover() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionRestore.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpdateDatabaseHyperscaleMigrationWithManualCutover.json // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -731,11 +856,23 @@ public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscripti SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); // invoke the operation - string databaseName = "testdw"; + string databaseName = "testdb"; SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) { - CreateMode = SqlDatabaseCreateMode.Restore, - SourceResourceId = new ResourceIdentifier("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/restorableDroppedDatabases/srcdw,131403269876900000"), + Sku = new SqlSku("HS_Gen5_2") + { + Tier = "Hyperscale", + }, + Identity = new DatabaseIdentity + { + IdentityType = DatabaseIdentityType.UserAssigned, + UserAssignedIdentities = +{ +["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi"] = new UserAssignedIdentity(), +["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete"] = default +}, + }, + ManualCutover = true, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); SqlDatabaseResource result = lro.Value; @@ -749,9 +886,9 @@ public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscripti [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscriptionRestoreFromAGeoBackup() + public async Task CreateOrUpdate_UpdatesADatabaseToHyperscaleTierByTriggeringManualCutoverDuringMigrationWorkflow() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionRecovery.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpdateDatabaseHyperscaleMigrationPerformCutover.json // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -762,7 +899,7 @@ public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscripti // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-WestUS"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; string serverName = "testsvr"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); @@ -771,11 +908,19 @@ public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscripti SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); // invoke the operation - string databaseName = "testdw"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("westus")) + string databaseName = "testdb"; + SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) { - CreateMode = SqlDatabaseCreateMode.Recovery, - SourceResourceId = new ResourceIdentifier("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-EastUS/providers/Microsoft.Sql/servers/srcsvr/recoverabledatabases/srcdw"), + Identity = new DatabaseIdentity + { + IdentityType = DatabaseIdentityType.UserAssigned, + UserAssignedIdentities = +{ +["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi"] = new UserAssignedIdentity(), +["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete"] = default +}, + }, + PerformCutover = true, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); SqlDatabaseResource result = lro.Value; @@ -789,10 +934,10 @@ public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscripti [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscriptionRestoreFromARestorePointOfAnExistingDatabase() + public async Task Get_GetsADatabaseConfiguredWithDefaultEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDwDatabaseCrossSubscriptionPITR.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -811,15 +956,8 @@ public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscripti SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); // invoke the operation - string databaseName = "testdw"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - CreateMode = SqlDatabaseCreateMode.PointInTimeRestore, - RestorePointInTime = DateTimeOffset.Parse("2022-01-22T05:35:31.503Z"), - SourceResourceId = new ResourceIdentifier("/subscriptions/55555555-6666-7777-8888-999999999999/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/srcsvr/databases/srcdw"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + string databaseName = "testdb"; + SqlDatabaseResource result = await collection.GetAsync(databaseName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -830,10 +968,10 @@ public async Task CreateOrUpdate_CreatesADataWarehouseDatabaseAsACrossSubscripti [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseAsACopy() + public async Task Get_GetsADatabaseConfiguredWithVBSEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseCopyMode.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -852,18 +990,8 @@ public async Task CreateOrUpdate_CreatesADatabaseAsACopy() SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); // invoke the operation - string databaseName = "dbcopy"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - Sku = new SqlSku("S0") - { - Tier = "Standard", - }, - CreateMode = SqlDatabaseCreateMode.Copy, - SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + string databaseName = "testdb"; + SqlDatabaseResource result = await collection.GetAsync(databaseName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -874,10 +1002,10 @@ public async Task CreateOrUpdate_CreatesADatabaseAsACopy() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseAsAStandbySecondary() + public async Task Get_GetsADatabaseWithAvailabilityZoneSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseStandbyMode.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -897,18 +1025,7 @@ public async Task CreateOrUpdate_CreatesADatabaseAsAStandbySecondary() // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - Sku = new SqlSku("S0") - { - Tier = "Standard", - }, - CreateMode = SqlDatabaseCreateMode.Secondary, - SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb"), - SecondaryType = SecondaryType.Standby, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + SqlDatabaseResource result = await collection.GetAsync(databaseName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -919,10 +1036,10 @@ public async Task CreateOrUpdate_CreatesADatabaseAsAStandbySecondary() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseAsAnOnLineSecondary() + public async Task Get_GetsADatabaseWithDatabaseLevelKeysExpanded() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseSecondaryMode.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -942,18 +1059,8 @@ public async Task CreateOrUpdate_CreatesADatabaseAsAnOnLineSecondary() // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - Sku = new SqlSku("S0") - { - Tier = "Standard", - }, - CreateMode = SqlDatabaseCreateMode.Secondary, - SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/testdb"), - SecondaryType = SecondaryType.Geo, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + string expand = "keys"; + SqlDatabaseResource result = await collection.GetAsync(databaseName, expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -964,10 +1071,10 @@ public async Task CreateOrUpdate_CreatesADatabaseAsAnOnLineSecondary() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseAsNamedReplicaSecondary() + public async Task Get_GetsADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseNamedReplica.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -987,19 +1094,7 @@ public async Task CreateOrUpdate_CreatesADatabaseAsNamedReplicaSecondary() // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - Sku = new SqlSku("HS_Gen4") - { - Tier = "Hyperscale", - Capacity = 2, - }, - CreateMode = SqlDatabaseCreateMode.Secondary, - SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-NorthEurope/providers/Microsoft.Sql/servers/testsvr1/databases/primarydb"), - SecondaryType = SecondaryType.Named, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + SqlDatabaseResource result = await collection.GetAsync(databaseName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -1010,10 +1105,10 @@ public async Task CreateOrUpdate_CreatesADatabaseAsNamedReplicaSecondary() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseFromPointInTimeRestore() + public async Task GetAll_GetsAListOfDatabasesConfiguredWithEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabasePITRMode.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreDatabasesEnclaveTypeByServer.json + // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1031,30 +1126,25 @@ public async Task CreateOrUpdate_CreatesADatabaseFromPointInTimeRestore() // get the collection of this SqlDatabaseResource SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); - // invoke the operation - string databaseName = "dbpitr"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + // invoke the operation and iterate over the result + await foreach (SqlDatabaseResource item in collection.GetAllAsync()) { - CreateMode = SqlDatabaseCreateMode.PointInTimeRestore, - SourceDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SoutheastAsia/providers/Microsoft.Sql/servers/testsvr/databases/testdb"), - RestorePointInTime = DateTimeOffset.Parse("2020-10-22T05:35:31.503Z"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseWithDefaultEnclaveType() + public async Task GetAll_GetsAListOfDatabases() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultEnclave.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreDatabasesByServer.json + // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1072,28 +1162,25 @@ public async Task CreateOrUpdate_CreatesADatabaseWithDefaultEnclaveType() // get the collection of this SqlDatabaseResource SqlDatabaseCollection collection = sqlServer.GetSqlDatabases(); - // invoke the operation - string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) + // invoke the operation and iterate over the result + await foreach (SqlDatabaseResource item in collection.GetAllAsync()) { - PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Default, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseWithVBSEnclaveType() + public async Task Exists_GetsADatabaseConfiguredWithDefaultEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseVBSEnclave.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1113,26 +1200,17 @@ public async Task CreateOrUpdate_CreatesADatabaseWithVBSEnclaveType() // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Vbs, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + bool result = await collection.ExistsAsync(databaseName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseWithAvailabilityZoneSpecified() + public async Task Exists_GetsADatabaseConfiguredWithVBSEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseWithAvailabilityZone.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1152,33 +1230,17 @@ public async Task CreateOrUpdate_CreatesADatabaseWithAvailabilityZoneSpecified() // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - Sku = new SqlSku("S0") - { - Tier = "Standard", - }, - CreateMode = SqlDatabaseCreateMode.Default, - Collation = "SQL_Latin1_General_CP1_CI_AS", - MaxSizeBytes = 1073741824L, - AvailabilityZone = SqlAvailabilityZoneType.One, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + bool result = await collection.ExistsAsync(databaseName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseWithDatabaseLevelCustomerManagedKeys() + public async Task Exists_GetsADatabaseWithAvailabilityZoneSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultModeWithKeysAndEncryptionProtector.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1198,46 +1260,17 @@ public async Task CreateOrUpdate_CreatesADatabaseWithDatabaseLevelCustomerManage // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - Sku = new SqlSku("S0") - { - Tier = "Standard", - }, - Identity = new DatabaseIdentity() - { - IdentityType = DatabaseIdentityType.UserAssigned, - UserAssignedIdentities = -{ -["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi"] = new UserAssignedIdentity(), -}, - }, - CreateMode = SqlDatabaseCreateMode.Default, - Collation = "SQL_Latin1_General_CP1_CI_AS", - MaxSizeBytes = 1073741824L, - Keys = -{ -["https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion"] = new SqlDatabaseKey(), -["https://your-key-vault-name.vault.azure.net/yourKey2/yourKey2Version"] = new SqlDatabaseKey(), -}, - EncryptionProtector = "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + bool result = await collection.ExistsAsync(databaseName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseWithDefaultMode() + public async Task Exists_GetsADatabaseWithDatabaseLevelKeysExpanded() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseDefaultMode.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1257,32 +1290,18 @@ public async Task CreateOrUpdate_CreatesADatabaseWithDefaultMode() // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - Sku = new SqlSku("S0") - { - Tier = "Standard", - }, - CreateMode = SqlDatabaseCreateMode.Default, - Collation = "SQL_Latin1_General_CP1_CI_AS", - MaxSizeBytes = 1073741824L, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + string expand = "keys"; + bool result = await collection.ExistsAsync(databaseName, expand: expand); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseWithLedgerOn() + public async Task Exists_GetsADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseLedger.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1302,26 +1321,17 @@ public async Task CreateOrUpdate_CreatesADatabaseWithLedgerOn() // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - IsLedgerOn = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + bool result = await collection.ExistsAsync(databaseName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseWithMinimumNumberOfParameters() + public async Task GetIfExists_GetsADatabaseConfiguredWithDefaultEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseMin.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1341,23 +1351,29 @@ public async Task CreateOrUpdate_CreatesADatabaseWithMinimumNumberOfParameters() // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + SqlDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseWithPreferredMaintenanceWindow() + public async Task GetIfExists_GetsADatabaseConfiguredWithVBSEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseMaintenanceConfiguration.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1377,33 +1393,29 @@ public async Task CreateOrUpdate_CreatesADatabaseWithPreferredMaintenanceWindow( // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - Sku = new SqlSku("S2") - { - Tier = "Standard", - }, - CreateMode = SqlDatabaseCreateMode.Default, - Collation = "SQL_Latin1_General_CP1_CI_AS", - MaxSizeBytes = 1073741824L, - MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + SqlDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesADatabaseWithSpecifiedBackupStorageRedundancy() + public async Task GetIfExists_GetsADatabaseWithAvailabilityZoneSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/CreateDatabaseConfiguredBackupStorageRedundancy.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1423,26 +1435,29 @@ public async Task CreateOrUpdate_CreatesADatabaseWithSpecifiedBackupStorageRedun // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - RequestedBackupStorageRedundancy = SqlBackupStorageRedundancy.Zone, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + SqlDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatesADatabaseToHyperscaleSLOWithManualCutover() + public async Task GetIfExists_GetsADatabaseWithDatabaseLevelKeysExpanded() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpdateDatabaseHyperscaleMigrationWithManualCutover.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1462,39 +1477,30 @@ public async Task CreateOrUpdate_UpdatesADatabaseToHyperscaleSLOWithManualCutove // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - Sku = new SqlSku("HS_Gen5_2") - { - Tier = "Hyperscale", - }, - Identity = new DatabaseIdentity() - { - IdentityType = DatabaseIdentityType.UserAssigned, - UserAssignedIdentities = -{ -["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi"] = new UserAssignedIdentity(), -["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete"] = null, -}, - }, - ManualCutover = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + string expand = "keys"; + NullableResponse response = await collection.GetIfExistsAsync(databaseName, expand: expand); + SqlDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatesADatabaseToHyperscaleTierByTriggeringManualCutoverDuringMigrationWorkflow() + public async Task GetIfExists_GetsADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/UpdateDatabaseHyperscaleMigrationPerformCutover.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1514,27 +1520,21 @@ public async Task CreateOrUpdate_UpdatesADatabaseToHyperscaleTierByTriggeringMan // invoke the operation string databaseName = "testdb"; - SqlDatabaseData data = new SqlDatabaseData(new AzureLocation("southeastasia")) - { - Identity = new DatabaseIdentity() - { - IdentityType = DatabaseIdentityType.UserAssigned, - UserAssignedIdentities = -{ -["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umi"] = new UserAssignedIdentity(), -["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/userAssignedIdentities/umiToDelete"] = null, -}, - }, - PerformCutover = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - SqlDatabaseResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + SqlDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseColumnCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseColumnCollection.cs index 205bb2e7039bb..df34a01e52e85 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseColumnCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseColumnCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlDatabaseColumnCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDatabaseColumns() + public async Task Get_GetDatabaseColumn() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseColumnListByTable.json - // this example is just showing the usage of "DatabaseColumns_ListByTable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseColumnGet.json + // this example is just showing the usage of "DatabaseColumns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_ListDatabaseColumns() // get the collection of this SqlDatabaseColumnResource SqlDatabaseColumnCollection collection = sqlDatabaseTable.GetSqlDatabaseColumns(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseColumnResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseColumnData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string columnName = "column1"; + SqlDatabaseColumnResource result = await collection.GetAsync(columnName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseColumnData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatabaseColumn() + public async Task GetAll_ListDatabaseColumns() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseColumnGet.json - // this example is just showing the usage of "DatabaseColumns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseColumnListByTable.json + // this example is just showing the usage of "DatabaseColumns_ListByTable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +78,17 @@ public async Task Get_GetDatabaseColumn() // get the collection of this SqlDatabaseColumnResource SqlDatabaseColumnCollection collection = sqlDatabaseTable.GetSqlDatabaseColumns(); - // invoke the operation - string columnName = "column1"; - SqlDatabaseColumnResource result = await collection.GetAsync(columnName); + // invoke the operation and iterate over the result + await foreach (SqlDatabaseColumnResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseColumnData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseColumnData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseResource.cs index 5444d1cd7191f..f90fd9b6860c0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseResource.cs @@ -20,10 +20,10 @@ public partial class Sample_SqlDatabaseResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetMetrics_ListDatabaseUsageMetrics() + public async Task Get_GetsADatabaseConfiguredWithDefaultEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DatabaseMetricsListWithFilter.json - // this example is just showing the usage of "Metrics_ListDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,28 +33,28 @@ public async Task GetMetrics_ListDatabaseUsageMetrics() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-6730"; - string serverName = "sqlcrudtest-9007"; - string databaseName = "3481"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; + string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation and iterate over the result - string filter = "name/value eq 'cpu_percent' and timeGrain eq '00:10:00' and startTime eq '2017-06-02T18:35:00Z' and endTime eq '2017-06-02T18:55:00Z'"; - await foreach (SqlMetric item in sqlDatabase.GetMetricsAsync(filter)) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + SqlDatabaseResource result = await sqlDatabase.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetMetricDefinitions_ListDatabaseUsageMetrics() + public async Task Get_GetsADatabaseConfiguredWithVBSEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DatabaseMetricsDefinitionsList.json - // this example is just showing the usage of "MetricDefinitions_ListDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,27 +64,28 @@ public async Task GetMetricDefinitions_ListDatabaseUsageMetrics() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-6730"; - string serverName = "sqlcrudtest-9007"; - string databaseName = "3481"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; + string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation and iterate over the result - await foreach (SqlMetricDefinition item in sqlDatabase.GetMetricDefinitionsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + SqlDatabaseResource result = await sqlDatabase.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDatabaseColumns_FilterDatabaseColumns() + public async Task Get_GetsADatabaseWithAvailabilityZoneSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ColumnsListByDatabaseMax.json - // this example is just showing the usage of "DatabaseColumns_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,47 +95,28 @@ public async Task GetDatabaseColumns_FilterDatabaseColumns() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "myRG"; - string serverName = "serverName"; - string databaseName = "myDatabase"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; + string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation and iterate over the result - IEnumerable schema = new string[] - { -"dbo" - }; - IEnumerable table = new string[] - { -"customer","address" - }; - IEnumerable column = new string[] - { -"username" - }; - IEnumerable orderBy = new string[] - { -"schema asc","table","column desc" - }; - await foreach (SqlDatabaseColumnResource item in sqlDatabase.GetDatabaseColumnsAsync(schema: schema, table: table, column: column, orderBy: orderBy)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseColumnData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + SqlDatabaseResource result = await sqlDatabase.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDatabaseColumns_ListDatabaseColumns() + public async Task Get_GetsADatabaseWithDatabaseLevelKeysExpanded() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ColumnsListByDatabaseMin.json - // this example is just showing the usage of "DatabaseColumns_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,31 +126,29 @@ public async Task GetDatabaseColumns_ListDatabaseColumns() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "myRG"; - string serverName = "serverName"; - string databaseName = "myDatabase"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; + string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseColumnResource item in sqlDatabase.GetDatabaseColumnsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseColumnData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string expand = "keys"; + SqlDatabaseResource result = await sqlDatabase.GetAsync(expand: expand); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateRestorePoint_CreatesDatawarehouseDatabaseRestorePoint() + public async Task Get_GetsADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRestorePointsPost.json - // this example is just showing the usage of "RestorePoints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,29 +159,27 @@ public async Task CreateRestorePoint_CreatesDatawarehouseDatabaseRestorePoint() // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testserver"; - string databaseName = "testDatabase"; + string serverName = "testsvr"; + string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation - CreateDatabaseRestorePointDefinition createDatabaseRestorePointDefinition = new CreateDatabaseRestorePointDefinition("mylabel"); - ArmOperation lro = await sqlDatabase.CreateRestorePointAsync(WaitUntil.Completed, createDatabaseRestorePointDefinition); - SqlServerDatabaseRestorePointResource result = lro.Value; + SqlDatabaseResource result = await sqlDatabase.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerDatabaseRestorePointData resourceData = result.Data; + SqlDatabaseData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdateDatabaseExtension_CreateOrUpdateDatabaseExtensions() + public async Task Delete_DeletesADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/CreateOrUpdateDatabaseExtensions.json - // this example is just showing the usage of "DatabaseExtensions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/DeleteDatabase.json + // this example is just showing the usage of "Databases_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -210,64 +188,25 @@ public async Task CreateOrUpdateDatabaseExtension_CreateOrUpdateDatabaseExtensio // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource - string subscriptionId = "a1c0814d-3c18-4e1e-a247-c128c12b1677"; - string resourceGroupName = "rg_20cbe0f0-c2d9-4522-9177-5469aad53029"; - string serverName = "srv_1ffd1cf8-9951-47fb-807d-a9c384763849"; - string databaseName = "878e303f-1ea0-4f17-aa3d-a22ac5e9da08"; + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; + string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation - string extensionName = "polybaseimport"; - SqlDatabaseExtension sqlDatabaseExtension = new SqlDatabaseExtension() - { - OperationMode = DatabaseExtensionOperationMode.PolybaseImport, - StorageKeyType = StorageKeyType.StorageAccessKey, - StorageKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", - StorageUri = new Uri("https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml"), - }; - ArmOperation lro = await sqlDatabase.CreateOrUpdateDatabaseExtensionAsync(WaitUntil.Completed, extensionName, sqlDatabaseExtension); - ImportExportExtensionsOperationResult result = lro.Value; - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDatabaseExtensions_ListDatabaseExtensions() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListDatabaseExtensions.json - // this example is just showing the usage of "DatabaseExtensions_ListByDatabase" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SqlDatabaseResource created on azure - // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource - string subscriptionId = "7b2515fe-f230-4017-8cf0-695163acab85"; - string resourceGroupName = "rg_4007c5a9-b3b0-41e1-bd46-9eef38768a4a"; - string serverName = "srv_3b67ec2a-519b-43a7-8533-fb62dce3431e"; - string databaseName = "719d8fa4-bf0f-48fc-8cd3-ef40fe6ba1fe"; - ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - - // invoke the operation and iterate over the result - await foreach (ImportExportExtensionsOperationResult item in sqlDatabase.GetDatabaseExtensionsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + await sqlDatabase.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDatabaseUsages_GetsDatabaseUsages() + public async Task Update_AssignsMaintenanceWindowToADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetDatabaseUsages.json - // this example is just showing the usage of "DatabaseUsages_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseAssignMaintenanceConfiguration.json + // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -283,21 +222,28 @@ public async Task GetDatabaseUsages_GetsDatabaseUsages() ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation and iterate over the result - await foreach (DatabaseUsage item in sqlDatabase.GetDatabaseUsagesAsync()) + // invoke the operation + SqlDatabasePatch patch = new SqlDatabasePatch { - Console.WriteLine($"Succeeded: {item}"); - } + Sku = new SqlSku("BC_Gen5_4"), + MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1"), + }; + ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); + SqlDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetCurrentSensitivityLabels_GetsTheCurrentSensitivityLabelsOfAGivenDatabase() + public async Task Update_CreatesADatabaseWithVBSEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsListByDatabaseWithSourceCurrent.json - // this example is just showing the usage of "SensitivityLabels_ListCurrentByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchDatabaseVBSEnclave.json + // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -307,31 +253,33 @@ public async Task GetCurrentSensitivityLabels_GetsTheCurrentSensitivityLabelsOfA // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "myRG"; - string serverName = "myServer"; - string databaseName = "myDatabase"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; + string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseSensitivityLabelResource item in sqlDatabase.GetCurrentSensitivityLabelsAsync()) + // invoke the operation + SqlDatabasePatch patch = new SqlDatabasePatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SensitivityLabelData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Vbs, + }; + ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); + SqlDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task UpdateSensitivityLabel_UpdateSensitivityLabelsOfAGivenDatabaseUsingAnOperationsBatch() + public async Task Update_PatchADatabaseWithDatabaseLevelCustomerManagedKeys() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsCurrentUpdate.json - // this example is just showing the usage of "SensitivityLabels_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseWithKeysAndEncryptionProtector.json + // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -341,65 +289,51 @@ public async Task UpdateSensitivityLabel_UpdateSensitivityLabelsOfAGivenDatabase // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "myRG"; - string serverName = "myServer"; - string databaseName = "myDatabase"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; + string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation - SensitivityLabelUpdateList sensitivityLabelUpdateList = new SensitivityLabelUpdateList() + SqlDatabasePatch patch = new SqlDatabasePatch { - Operations = -{ -new SensitivityLabelUpdate() -{ -Op = SensitivityLabelUpdateKind.Set, -Schema = "dbo", -Table = "table1", -Column = "column1", -SensitivityLabel = new SensitivityLabelData() -{ -LabelName = "Highly Confidential", -LabelId = "3A477B16-9423-432B-AA97-6069B481CEC3", -InformationType = "Financial", -InformationTypeId = "1D3652D6-422C-4115-82F1-65DAEBC665C8", -Rank = SensitivityLabelRank.Low, -}, -},new SensitivityLabelUpdate() -{ -Op = SensitivityLabelUpdateKind.Set, -Schema = "dbo", -Table = "table2", -Column = "column2", -SensitivityLabel = new SensitivityLabelData() + Sku = new SqlSku("S0") + { + Tier = "Standard", + }, + Identity = new DatabaseIdentity + { + IdentityType = DatabaseIdentityType.UserAssigned, + UserAssignedIdentities = { -LabelName = "PII", -LabelId = "bf91e08c-f4f0-478a-b016-25164b2a65ff", -InformationType = "PhoneNumber", -InformationTypeId = "d22fa6e9-5ee4-3bde-4c2b-a409604c4646", -Rank = SensitivityLabelRank.Critical, +["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi"] = new UserAssignedIdentity(), +["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umiToDelete"] = default }, -},new SensitivityLabelUpdate() + }, + Keys = { -Op = SensitivityLabelUpdateKind.Remove, -Schema = "dbo", -Table = "Table1", -Column = "Column3", -} +["https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion"] = new SqlDatabaseKey(), +["https://your-key-vault-name.vault.azure.net/yourKey2/yourKey2VersionToDelete"] = default }, + EncryptionProtector = "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion", }; - await sqlDatabase.UpdateSensitivityLabelAsync(sensitivityLabelUpdateList); + ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); + SqlDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetRecommendedSensitivityLabels_GetsTheRecommendedSensitivityLabelsOfAGivenDatabase() + public async Task Update_ResetsMaintenanceWindowOfADatabaseToDefault() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsListByDatabaseWithSourceRecommended.json - // this example is just showing the usage of "SensitivityLabels_ListRecommendedByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseResetMaintenanceConfiguration.json + // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -409,31 +343,34 @@ public async Task GetRecommendedSensitivityLabels_GetsTheRecommendedSensitivityL // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "myRG"; - string serverName = "myServer"; - string databaseName = "myDatabase"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; + string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseSensitivityLabelResource item in sqlDatabase.GetRecommendedSensitivityLabelsAsync()) + // invoke the operation + SqlDatabasePatch patch = new SqlDatabasePatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SensitivityLabelData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new SqlSku("BC_Gen5_4"), + MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default"), + }; + ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); + SqlDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task UpdateRecommendedSensitivityLabel_UpdateRecommendedSensitivityLabelsOfAGivenDatabaseUsingAnOperationsBatch() + public async Task Update_UpdatesADatabaseWithDefaultEnclaveType() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsRecommendedUpdate.json - // this example is just showing the usage of "SensitivityLabels_UpdateRecommended" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchDatabaseDefaultEnclave.json + // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -443,49 +380,33 @@ public async Task UpdateRecommendedSensitivityLabel_UpdateRecommendedSensitivity // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "myRG"; - string serverName = "myServer"; - string databaseName = "myDatabase"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; + string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation - RecommendedSensitivityLabelUpdateList recommendedSensitivityLabelUpdateList = new RecommendedSensitivityLabelUpdateList() + SqlDatabasePatch patch = new SqlDatabasePatch { - Operations = -{ -new RecommendedSensitivityLabelUpdate() -{ -Op = RecommendedSensitivityLabelUpdateKind.Enable, -Schema = "dbo", -Table = "table1", -Column = "column1", -},new RecommendedSensitivityLabelUpdate() -{ -Op = RecommendedSensitivityLabelUpdateKind.Enable, -Schema = "dbo", -Table = "table2", -Column = "column2", -},new RecommendedSensitivityLabelUpdate() -{ -Op = RecommendedSensitivityLabelUpdateKind.Disable, -Schema = "dbo", -Table = "table1", -Column = "column3", -} -}, + PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Default, }; - await sqlDatabase.UpdateRecommendedSensitivityLabelAsync(recommendedSensitivityLabelUpdateList); + ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); + SqlDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSynapseLinkWorkspaces_ListAllSynapselinkWorkspacesForTheGivenDatabase() + public async Task Update_UpdatesADatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/SynapseLinkWorkspaceListByDatabase.json - // this example is just showing the usage of "SynapseLinkWorkspaces_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabase.json + // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -497,12 +418,51 @@ public async Task GetSynapseLinkWorkspaces_ListAllSynapselinkWorkspacesForTheGiv string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default-SQL-SouthEastAsia"; string serverName = "testsvr"; - string databaseName = "dbSynapse"; + string databaseName = "testdb"; + ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); + + // invoke the operation + SqlDatabasePatch patch = new SqlDatabasePatch + { + Sku = new SqlSku("BC_Gen4_4"), + MaxSizeBytes = 1073741824L, + LicenseType = DatabaseLicenseType.LicenseIncluded, + }; + ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); + SqlDatabaseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMetrics_ListDatabaseUsageMetrics() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DatabaseMetricsListWithFilter.json + // this example is just showing the usage of "Metrics_ListDatabase" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SqlDatabaseResource created on azure + // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "sqlcrudtest-6730"; + string serverName = "sqlcrudtest-9007"; + string databaseName = "3481"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation and iterate over the result - await foreach (SqlSynapseLinkWorkspace item in sqlDatabase.GetSynapseLinkWorkspacesAsync()) + string filter = "name/value eq 'cpu_percent' and timeGrain eq '00:10:00' and startTime eq '2017-06-02T18:35:00Z' and endTime eq '2017-06-02T18:55:00Z'"; + await foreach (SqlMetric item in sqlDatabase.GetMetricsAsync(filter)) { Console.WriteLine($"Succeeded: {item}"); } @@ -512,10 +472,10 @@ public async Task GetSynapseLinkWorkspaces_ListAllSynapselinkWorkspacesForTheGiv [Test] [Ignore("Only validating compilation of examples")] - public async Task RevalidateDatabaseEncryptionProtector_RevalidatesTheEncryptionProtectorForAParticularDatabase() + public async Task GetMetricDefinitions_ListDatabaseUsageMetrics() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/DatabaseEncryptionProtectorRevalidate.json - // this example is just showing the usage of "DatabaseEncryptionProtectors_Revalidate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/DatabaseMetricsDefinitionsList.json + // this example is just showing the usage of "MetricDefinitions_ListDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -525,25 +485,27 @@ public async Task RevalidateDatabaseEncryptionProtector_RevalidatesTheEncryption // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-7398"; - string serverName = "sqlcrudtest-4645"; - string databaseName = "sqlcrudtestdb-2342"; + string resourceGroupName = "sqlcrudtest-6730"; + string serverName = "sqlcrudtest-9007"; + string databaseName = "3481"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation - EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - await sqlDatabase.RevalidateDatabaseEncryptionProtectorAsync(WaitUntil.Completed, encryptionProtectorName); + // invoke the operation and iterate over the result + await foreach (SqlMetricDefinition item in sqlDatabase.GetMetricDefinitionsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task RevertDatabaseEncryptionProtector_RevertsTheEncryptionProtectorForAParticularDatabase() + public async Task GetDatabaseColumns_FilterDatabaseColumns() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/DatabaseEncryptionProtectorRevert.json - // this example is just showing the usage of "DatabaseEncryptionProtectors_Revert" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ColumnsListByDatabaseMax.json + // this example is just showing the usage of "DatabaseColumns_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -553,25 +515,35 @@ public async Task RevertDatabaseEncryptionProtector_RevertsTheEncryptionProtecto // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-7398"; - string serverName = "sqlcrudtest-4645"; - string databaseName = "sqlcrudtestdb-2342"; + string resourceGroupName = "myRG"; + string serverName = "serverName"; + string databaseName = "myDatabase"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation - EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; - await sqlDatabase.RevertDatabaseEncryptionProtectorAsync(WaitUntil.Completed, encryptionProtectorName); + // invoke the operation and iterate over the result + IEnumerable schema = new string[] { "dbo" }; + IEnumerable table = new string[] { "customer", "address" }; + IEnumerable column = new string[] { "username" }; + IEnumerable orderBy = new string[] { "schema asc", "table", "column desc" }; + await foreach (SqlDatabaseColumnResource item in sqlDatabase.GetDatabaseColumnsAsync(schema: schema, table: table, column: column, orderBy: orderBy)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseColumnData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseConfiguredWithDefaultEnclaveType() + public async Task GetDatabaseColumns_ListDatabaseColumns() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseDefaultEnclave.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ColumnsListByDatabaseMin.json + // this example is just showing the usage of "DatabaseColumns_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -581,28 +553,31 @@ public async Task Get_GetsADatabaseConfiguredWithDefaultEnclaveType() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string databaseName = "testdb"; + string resourceGroupName = "myRG"; + string serverName = "serverName"; + string databaseName = "myDatabase"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation - SqlDatabaseResource result = await sqlDatabase.GetAsync(); + // invoke the operation and iterate over the result + await foreach (SqlDatabaseColumnResource item in sqlDatabase.GetDatabaseColumnsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseColumnData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseConfiguredWithVBSEnclaveType() + public async Task CreateRestorePoint_CreatesDatawarehouseDatabaseRestorePoint() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseVBSEnclave.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRestorePointsPost.json + // this example is just showing the usage of "RestorePoints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -613,27 +588,29 @@ public async Task Get_GetsADatabaseConfiguredWithVBSEnclaveType() // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string databaseName = "testdb"; + string serverName = "testserver"; + string databaseName = "testDatabase"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation - SqlDatabaseResource result = await sqlDatabase.GetAsync(); + CreateDatabaseRestorePointDefinition createDatabaseRestorePointDefinition = new CreateDatabaseRestorePointDefinition("mylabel"); + ArmOperation lro = await sqlDatabase.CreateRestorePointAsync(WaitUntil.Completed, createDatabaseRestorePointDefinition); + SqlServerDatabaseRestorePointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; + SqlServerDatabaseRestorePointData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseWithAvailabilityZoneSpecified() + public async Task CreateOrUpdateDatabaseExtension_CreateOrUpdateDatabaseExtensions() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetDatabaseWithAvailabilityZone.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/CreateOrUpdateDatabaseExtensions.json + // this example is just showing the usage of "DatabaseExtensions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -642,29 +619,34 @@ public async Task Get_GetsADatabaseWithAvailabilityZoneSpecified() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string databaseName = "testdb"; + string subscriptionId = "a1c0814d-3c18-4e1e-a247-c128c12b1677"; + string resourceGroupName = "rg_20cbe0f0-c2d9-4522-9177-5469aad53029"; + string serverName = "srv_1ffd1cf8-9951-47fb-807d-a9c384763849"; + string databaseName = "878e303f-1ea0-4f17-aa3d-a22ac5e9da08"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation - SqlDatabaseResource result = await sqlDatabase.GetAsync(); + string extensionName = "polybaseimport"; + SqlDatabaseExtension sqlDatabaseExtension = new SqlDatabaseExtension + { + OperationMode = DatabaseExtensionOperationMode.PolybaseImport, + StorageKeyType = StorageKeyType.StorageAccessKey, + StorageKey = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", + StorageUri = new Uri("https://teststorage.blob.core.windows.net/testcontainer/Manifest.xml"), + }; + ArmOperation lro = await sqlDatabase.CreateOrUpdateDatabaseExtensionAsync(WaitUntil.Completed, extensionName, sqlDatabaseExtension); + ImportExportExtensionsOperationResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseWithDatabaseLevelKeysExpanded() + public async Task GetDatabaseExtensions_ListDatabaseExtensions() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabaseWithExpandEqualsKeys.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/ListDatabaseExtensions.json + // this example is just showing the usage of "DatabaseExtensions_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -673,30 +655,28 @@ public async Task Get_GetsADatabaseWithDatabaseLevelKeysExpanded() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string databaseName = "testdb"; + string subscriptionId = "7b2515fe-f230-4017-8cf0-695163acab85"; + string resourceGroupName = "rg_4007c5a9-b3b0-41e1-bd46-9eef38768a4a"; + string serverName = "srv_3b67ec2a-519b-43a7-8533-fb62dce3431e"; + string databaseName = "719d8fa4-bf0f-48fc-8cd3-ef40fe6ba1fe"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation - string expand = "keys"; - SqlDatabaseResource result = await sqlDatabase.GetAsync(expand: expand); + // invoke the operation and iterate over the result + await foreach (ImportExportExtensionsOperationResult item in sqlDatabase.GetDatabaseExtensionsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabase() + public async Task GetDatabaseUsages_GetsDatabaseUsages() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/GetVCoreDatabase.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-02-01-preview/examples/GetDatabaseUsages.json + // this example is just showing the usage of "DatabaseUsages_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -712,22 +692,21 @@ public async Task Get_GetsADatabase() ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation - SqlDatabaseResource result = await sqlDatabase.GetAsync(); + // invoke the operation and iterate over the result + await foreach (DatabaseUsage item in sqlDatabase.GetDatabaseUsagesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesADatabase() + public async Task GetCurrentSensitivityLabels_GetsTheCurrentSensitivityLabelsOfAGivenDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/DeleteDatabase.json - // this example is just showing the usage of "Databases_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsListByDatabaseWithSourceCurrent.json + // this example is just showing the usage of "SensitivityLabels_ListCurrentByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -737,24 +716,31 @@ public async Task Delete_DeletesADatabase() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string databaseName = "testdb"; + string resourceGroupName = "myRG"; + string serverName = "myServer"; + string databaseName = "myDatabase"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation - await sqlDatabase.DeleteAsync(WaitUntil.Completed); + // invoke the operation and iterate over the result + await foreach (SqlDatabaseSensitivityLabelResource item in sqlDatabase.GetCurrentSensitivityLabelsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SensitivityLabelData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AssignsMaintenanceWindowToADatabase() + public async Task UpdateSensitivityLabel_UpdateSensitivityLabelsOfAGivenDatabaseUsingAnOperationsBatch() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseAssignMaintenanceConfiguration.json - // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsCurrentUpdate.json + // this example is just showing the usage of "SensitivityLabels_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -764,34 +750,62 @@ public async Task Update_AssignsMaintenanceWindowToADatabase() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string databaseName = "testdb"; + string resourceGroupName = "myRG"; + string serverName = "myServer"; + string databaseName = "myDatabase"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation - SqlDatabasePatch patch = new SqlDatabasePatch() + SensitivityLabelUpdateList sensitivityLabelUpdateList = new SensitivityLabelUpdateList { - Sku = new SqlSku("BC_Gen5_4"), - MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_SouthEastAsia_1"), + Operations = {new SensitivityLabelUpdate +{ +Op = SensitivityLabelUpdateKind.Set, +Schema = "dbo", +Table = "table1", +Column = "column1", +SensitivityLabel = new SensitivityLabelData +{ +LabelName = "Highly Confidential", +LabelId = "3A477B16-9423-432B-AA97-6069B481CEC3", +InformationType = "Financial", +InformationTypeId = "1D3652D6-422C-4115-82F1-65DAEBC665C8", +Rank = SensitivityLabelRank.Low, +}, +}, new SensitivityLabelUpdate +{ +Op = SensitivityLabelUpdateKind.Set, +Schema = "dbo", +Table = "table2", +Column = "column2", +SensitivityLabel = new SensitivityLabelData +{ +LabelName = "PII", +LabelId = "bf91e08c-f4f0-478a-b016-25164b2a65ff", +InformationType = "PhoneNumber", +InformationTypeId = "d22fa6e9-5ee4-3bde-4c2b-a409604c4646", +Rank = SensitivityLabelRank.Critical, +}, +}, new SensitivityLabelUpdate +{ +Op = SensitivityLabelUpdateKind.Remove, +Schema = "dbo", +Table = "Table1", +Column = "Column3", +}}, }; - ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); - SqlDatabaseResource result = lro.Value; + await sqlDatabase.UpdateSensitivityLabelAsync(sensitivityLabelUpdateList); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesADatabaseWithVBSEnclaveType() + public async Task GetRecommendedSensitivityLabels_GetsTheRecommendedSensitivityLabelsOfAGivenDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchDatabaseVBSEnclave.json - // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsListByDatabaseWithSourceRecommended.json + // this example is just showing the usage of "SensitivityLabels_ListRecommendedByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -801,33 +815,31 @@ public async Task Update_CreatesADatabaseWithVBSEnclaveType() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string databaseName = "testdb"; + string resourceGroupName = "myRG"; + string serverName = "myServer"; + string databaseName = "myDatabase"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation - SqlDatabasePatch patch = new SqlDatabasePatch() + // invoke the operation and iterate over the result + await foreach (SqlDatabaseSensitivityLabelResource item in sqlDatabase.GetRecommendedSensitivityLabelsAsync()) { - PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Vbs, - }; - ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); - SqlDatabaseResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SensitivityLabelData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchADatabaseWithDatabaseLevelCustomerManagedKeys() + public async Task UpdateRecommendedSensitivityLabel_UpdateRecommendedSensitivityLabelsOfAGivenDatabaseUsingAnOperationsBatch() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseWithKeysAndEncryptionProtector.json - // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SensitivityLabelsRecommendedUpdate.json + // this example is just showing the usage of "SensitivityLabels_UpdateRecommended" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -837,51 +849,46 @@ public async Task Update_PatchADatabaseWithDatabaseLevelCustomerManagedKeys() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string databaseName = "testdb"; + string resourceGroupName = "myRG"; + string serverName = "myServer"; + string databaseName = "myDatabase"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation - SqlDatabasePatch patch = new SqlDatabasePatch() + RecommendedSensitivityLabelUpdateList recommendedSensitivityLabelUpdateList = new RecommendedSensitivityLabelUpdateList { - Sku = new SqlSku("S0") - { - Tier = "Standard", - }, - Identity = new DatabaseIdentity() - { - IdentityType = DatabaseIdentityType.UserAssigned, - UserAssignedIdentities = + Operations = {new RecommendedSensitivityLabelUpdate { -["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umi"] = new UserAssignedIdentity(), -["/subscriptions/00000000-1111-2222-3333-444444444444/resourcegroups/Default-SQL-SouthEastAsia/providers/Microsoft.ManagedIdentity/userAssignedIdentities/umiToDelete"] = null, -}, - }, - Keys = +Op = RecommendedSensitivityLabelUpdateKind.Enable, +Schema = "dbo", +Table = "table1", +Column = "column1", +}, new RecommendedSensitivityLabelUpdate { -["https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion"] = new SqlDatabaseKey(), -["https://your-key-vault-name.vault.azure.net/yourKey2/yourKey2VersionToDelete"] = null, -}, - EncryptionProtector = "https://your-key-vault-name.vault.azure.net/yourKey/yourKeyVersion", +Op = RecommendedSensitivityLabelUpdateKind.Enable, +Schema = "dbo", +Table = "table2", +Column = "column2", +}, new RecommendedSensitivityLabelUpdate +{ +Op = RecommendedSensitivityLabelUpdateKind.Disable, +Schema = "dbo", +Table = "table1", +Column = "column3", +}}, }; - ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); - SqlDatabaseResource result = lro.Value; + await sqlDatabase.UpdateRecommendedSensitivityLabelAsync(recommendedSensitivityLabelUpdateList); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ResetsMaintenanceWindowOfADatabaseToDefault() + public async Task GetSynapseLinkWorkspaces_ListAllSynapselinkWorkspacesForTheGivenDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabaseResetMaintenanceConfiguration.json - // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/SynapseLinkWorkspaceListByDatabase.json + // this example is just showing the usage of "SynapseLinkWorkspaces_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -893,32 +900,25 @@ public async Task Update_ResetsMaintenanceWindowOfADatabaseToDefault() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default-SQL-SouthEastAsia"; string serverName = "testsvr"; - string databaseName = "testdb"; + string databaseName = "dbSynapse"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - // invoke the operation - SqlDatabasePatch patch = new SqlDatabasePatch() + // invoke the operation and iterate over the result + await foreach (SqlSynapseLinkWorkspace item in sqlDatabase.GetSynapseLinkWorkspacesAsync()) { - Sku = new SqlSku("BC_Gen5_4"), - MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default"), - }; - ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); - SqlDatabaseResource result = lro.Value; + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesADatabaseWithDefaultEnclaveType() + public async Task RevalidateDatabaseEncryptionProtector_RevalidatesTheEncryptionProtectorForAParticularDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchDatabaseDefaultEnclave.json - // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/DatabaseEncryptionProtectorRevalidate.json + // this example is just showing the usage of "DatabaseEncryptionProtectors_Revalidate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -928,33 +928,25 @@ public async Task Update_UpdatesADatabaseWithDefaultEnclaveType() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string databaseName = "testdb"; + string resourceGroupName = "sqlcrudtest-7398"; + string serverName = "sqlcrudtest-4645"; + string databaseName = "sqlcrudtestdb-2342"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation - SqlDatabasePatch patch = new SqlDatabasePatch() - { - PreferredEnclaveType = SqlAlwaysEncryptedEnclaveType.Default, - }; - ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); - SqlDatabaseResource result = lro.Value; + EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; + await sqlDatabase.RevalidateDatabaseEncryptionProtectorAsync(WaitUntil.Completed, encryptionProtectorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesADatabase() + public async Task RevertDatabaseEncryptionProtector_RevertsTheEncryptionProtectorForAParticularDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/PatchVCoreDatabase.json - // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/DatabaseEncryptionProtectorRevert.json + // this example is just showing the usage of "DatabaseEncryptionProtectors_Revert" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -964,27 +956,17 @@ public async Task Update_UpdatesADatabase() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; - string databaseName = "testdb"; + string resourceGroupName = "sqlcrudtest-7398"; + string serverName = "sqlcrudtest-4645"; + string databaseName = "sqlcrudtestdb-2342"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // invoke the operation - SqlDatabasePatch patch = new SqlDatabasePatch() - { - Sku = new SqlSku("BC_Gen4_4"), - MaxSizeBytes = 1073741824L, - LicenseType = DatabaseLicenseType.LicenseIncluded, - }; - ArmOperation lro = await sqlDatabase.UpdateAsync(WaitUntil.Completed, patch); - SqlDatabaseResource result = lro.Value; + EncryptionProtectorName encryptionProtectorName = EncryptionProtectorName.Current; + await sqlDatabase.RevertDatabaseEncryptionProtectorAsync(WaitUntil.Completed, encryptionProtectorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -1012,7 +994,7 @@ public async Task Export_ExportsADatabaseUsingPrivateLinkToCommunicateWithSQLSer DatabaseExportDefinition databaseExportDefinition = new DatabaseExportDefinition(StorageKeyType.StorageAccessKey, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==", new Uri("https://test.blob.core.windows.net/test.bacpac"), "login", "password") { AuthenticationType = "Sql", - NetworkIsolation = new NetworkIsolationSettings() + NetworkIsolation = new NetworkIsolationSettings { StorageAccountResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Storage/storageAccounts/test-privatelink"), SqlServerResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr"), @@ -1109,7 +1091,7 @@ public async Task Import_ImportsToAnExistingEmptyDatabaseUsingPrivateLinkToCommu ImportExistingDatabaseDefinition importExistingDatabaseDefinition = new ImportExistingDatabaseDefinition(StorageKeyType.StorageAccessKey, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx==", new Uri("https://test.blob.core.windows.net/test.bacpac"), "login", "password") { AuthenticationType = "Sql", - NetworkIsolation = new NetworkIsolationSettings() + NetworkIsolation = new NetworkIsolationSettings { StorageAccountResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Storage/storageAccounts/test-privatelink"), SqlServerResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr"), diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSchemaCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSchemaCollection.cs index 85f789045dd36..fcc90d6e96eb3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSchemaCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSchemaCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlDatabaseSchemaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDatabaseSchemas() + public async Task Get_GetDatabaseSchema() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSchemaListByDatabase.json - // this example is just showing the usage of "DatabaseSchemas_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSchemaGet.json + // this example is just showing the usage of "DatabaseSchemas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListDatabaseSchemas() // get the collection of this SqlDatabaseSchemaResource SqlDatabaseSchemaCollection collection = sqlDatabase.GetSqlDatabaseSchemas(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseSchemaResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseSchemaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string schemaName = "dbo"; + SqlDatabaseSchemaResource result = await collection.GetAsync(schemaName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatabaseSchema() + public async Task GetAll_ListDatabaseSchemas() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSchemaGet.json - // this example is just showing the usage of "DatabaseSchemas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSchemaListByDatabase.json + // this example is just showing the usage of "DatabaseSchemas_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetDatabaseSchema() // get the collection of this SqlDatabaseSchemaResource SqlDatabaseSchemaCollection collection = sqlDatabase.GetSqlDatabaseSchemas(); - // invoke the operation - string schemaName = "dbo"; - SqlDatabaseSchemaResource result = await collection.GetAsync(schemaName); + // invoke the operation and iterate over the result + await foreach (SqlDatabaseSchemaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseSchemaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSecurityAlertPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSecurityAlertPolicyCollection.cs index d1ebd8cc09b86..5775dc0943a74 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSecurityAlertPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSecurityAlertPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseSecurityAlertPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabaseSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertGet.json - // this example is just showing the usage of "DatabaseSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertCreateMax.json + // this example is just showing the usage of "DatabaseSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task Get_GetADatabaseSThreatDetectionPolicy() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-6852"; - string serverName = "securityalert-2080"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -42,7 +42,18 @@ public async Task Get_GetADatabaseSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - SqlDatabaseSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); + SqlDatabaseSecurityAlertPolicyData data = new SqlDatabaseSecurityAlertPolicyData + { + State = SecurityAlertsPolicyState.Enabled, + DisabledAlerts = { "Sql_Injection", "Usage_Anomaly" }, + EmailAddresses = { "test@microsoft.com", "user@microsoft.com" }, + SendToEmailAccountAdmins = true, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + RetentionDays = 6, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + SqlDatabaseSecurityAlertPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +64,10 @@ public async Task Get_GetADatabaseSThreatDetectionPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADatabaseSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertGet.json - // this example is just showing the usage of "DatabaseSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertCreateMin.json + // this example is just showing the usage of "DatabaseSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,8 +77,8 @@ public async Task Exists_GetADatabaseSThreatDetectionPolicy() // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-6852"; - string serverName = "securityalert-2080"; + string resourceGroupName = "securityalert-4799"; + string serverName = "securityalert-6440"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -77,14 +88,23 @@ public async Task Exists_GetADatabaseSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - bool result = await collection.ExistsAsync(securityAlertPolicyName); + SqlDatabaseSecurityAlertPolicyData data = new SqlDatabaseSecurityAlertPolicyData + { + State = SecurityAlertsPolicyState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + SqlDatabaseSecurityAlertPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADatabaseSThreatDetectionPolicy() + public async Task Get_GetADatabaseSThreatDetectionPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertGet.json // this example is just showing the usage of "DatabaseSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,29 +128,21 @@ public async Task GetIfExists_GetADatabaseSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); - SqlDatabaseSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + SqlDatabaseSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithAllParameters() + public async Task GetAll_GetTheDatabaseSThreatDetectionPolicies() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertCreateMax.json - // this example is just showing the usage of "DatabaseSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertListByDatabase.json + // this example is just showing the usage of "DatabaseSecurityAlertPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,8 +152,8 @@ public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithAllPar // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; + string resourceGroupName = "securityalert-6852"; + string serverName = "securityalert-2080"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -149,40 +161,25 @@ public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithAllPar // get the collection of this SqlDatabaseSecurityAlertPolicyResource SqlDatabaseSecurityAlertPolicyCollection collection = sqlDatabase.GetSqlDatabaseSecurityAlertPolicies(); - // invoke the operation - SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - SqlDatabaseSecurityAlertPolicyData data = new SqlDatabaseSecurityAlertPolicyData() + // invoke the operation and iterate over the result + await foreach (SqlDatabaseSecurityAlertPolicyResource item in collection.GetAllAsync()) { - State = SecurityAlertsPolicyState.Enabled, - DisabledAlerts = -{ -"Sql_Injection","Usage_Anomaly" -}, - EmailAddresses = -{ -"test@microsoft.com","user@microsoft.com" -}, - SendToEmailAccountAdmins = true, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - RetentionDays = 6, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - SqlDatabaseSecurityAlertPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseSecurityAlertPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithMinimalParameters() + public async Task Exists_GetADatabaseSThreatDetectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertCreateMin.json - // this example is just showing the usage of "DatabaseSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertGet.json + // this example is just showing the usage of "DatabaseSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,8 +189,8 @@ public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithMinima // this example assumes you already have this SqlDatabaseResource created on azure // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "securityalert-4799"; - string serverName = "securityalert-6440"; + string resourceGroupName = "securityalert-6852"; + string serverName = "securityalert-2080"; string databaseName = "testdb"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); @@ -203,26 +200,17 @@ public async Task CreateOrUpdate_UpdateADatabaseSThreatDetectionPolicyWithMinima // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - SqlDatabaseSecurityAlertPolicyData data = new SqlDatabaseSecurityAlertPolicyData() - { - State = SecurityAlertsPolicyState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - SqlDatabaseSecurityAlertPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(securityAlertPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheDatabaseSThreatDetectionPolicies() + public async Task GetIfExists_GetADatabaseSThreatDetectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertListByDatabase.json - // this example is just showing the usage of "DatabaseSecurityAlertPolicies_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseSecurityAlertGet.json + // this example is just showing the usage of "DatabaseSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -241,17 +229,23 @@ public async Task GetAll_GetTheDatabaseSThreatDetectionPolicies() // get the collection of this SqlDatabaseSecurityAlertPolicyResource SqlDatabaseSecurityAlertPolicyCollection collection = sqlDatabase.GetSqlDatabaseSecurityAlertPolicies(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseSecurityAlertPolicyResource item in collection.GetAllAsync()) + // invoke the operation + SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); + SqlDatabaseSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlDatabaseSecurityAlertPolicyData resourceData = item.Data; + SqlDatabaseSecurityAlertPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSecurityAlertPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSecurityAlertPolicyResource.cs index 6cec4e9ef2860..c9a06a7bf154f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSecurityAlertPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSecurityAlertPolicyResource.cs @@ -71,17 +71,11 @@ public async Task Update_UpdateADatabaseSThreatDetectionPolicyWithAllParameters( SqlDatabaseSecurityAlertPolicyResource sqlDatabaseSecurityAlertPolicy = client.GetSqlDatabaseSecurityAlertPolicyResource(sqlDatabaseSecurityAlertPolicyResourceId); // invoke the operation - SqlDatabaseSecurityAlertPolicyData data = new SqlDatabaseSecurityAlertPolicyData() + SqlDatabaseSecurityAlertPolicyData data = new SqlDatabaseSecurityAlertPolicyData { State = SecurityAlertsPolicyState.Enabled, - DisabledAlerts = -{ -"Sql_Injection","Usage_Anomaly" -}, - EmailAddresses = -{ -"test@microsoft.com","user@microsoft.com" -}, + DisabledAlerts = { "Sql_Injection", "Usage_Anomaly" }, + EmailAddresses = { "test@microsoft.com", "user@microsoft.com" }, SendToEmailAccountAdmins = true, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", @@ -120,7 +114,7 @@ public async Task Update_UpdateADatabaseSThreatDetectionPolicyWithMinimalParamet SqlDatabaseSecurityAlertPolicyResource sqlDatabaseSecurityAlertPolicy = client.GetSqlDatabaseSecurityAlertPolicyResource(sqlDatabaseSecurityAlertPolicyResourceId); // invoke the operation - SqlDatabaseSecurityAlertPolicyData data = new SqlDatabaseSecurityAlertPolicyData() + SqlDatabaseSecurityAlertPolicyData data = new SqlDatabaseSecurityAlertPolicyData { State = SecurityAlertsPolicyState.Enabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineCollection.cs index aa41ca77c2ce7..786427141eeeb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineCollect { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() + public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselineFromTheLatestScanResult() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineListBySqlVulnerabilityAssessment.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_ListBySqlVulnerabilityAssessment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineAddLatest.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,8 +31,8 @@ public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBasel // this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentResource created on azure // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4711"; - string serverName = "vulnerabilityaseessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlDatabaseSqlVulnerabilityAssessmentResourceId = SqlDatabaseSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName); @@ -42,25 +41,29 @@ public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBasel // get the collection of this SqlDatabaseSqlVulnerabilityAssessmentBaselineResource SqlDatabaseSqlVulnerabilityAssessmentBaselineCollection collection = sqlDatabaseSqlVulnerabilityAssessment.GetSqlDatabaseSqlVulnerabilityAssessmentBaselines(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseSqlVulnerabilityAssessmentBaselineResource item in collection.GetAllAsync()) + // invoke the operation + SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; + SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsLatestScan = true, + Results = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, baselineName, content); + SqlDatabaseSqlVulnerabilityAssessmentBaselineResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() + public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselineList() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineGet.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineAdd.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,8 +73,8 @@ public async Task Get_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaseline // this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentResource created on azure // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4711"; - string serverName = "vulnerabilityaseessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlDatabaseSqlVulnerabilityAssessmentResourceId = SqlDatabaseSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName); @@ -82,7 +85,17 @@ public async Task Get_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaseline // invoke the operation SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; - SqlDatabaseSqlVulnerabilityAssessmentBaselineResource result = await collection.GetAsync(baselineName); + SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent + { + IsLatestScan = false, + Results = +{ +["VA2063"] = {{"AllowAll", "0.0.0.0", "255.255.255.255"}}, +["VA2065"] = {{"AllowAll", "0.0.0.0", "255.255.255.255"}} +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, baselineName, content); + SqlDatabaseSqlVulnerabilityAssessmentBaselineResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -93,7 +106,7 @@ public async Task Get_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaseline [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() + public async Task Get_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineGet.json // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_Get" operation, for the dependent resources, they will have to be created separately. @@ -118,17 +131,21 @@ public async Task Exists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBasel // invoke the operation SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; - bool result = await collection.ExistsAsync(baselineName); + SqlDatabaseSqlVulnerabilityAssessmentBaselineResource result = await collection.GetAsync(baselineName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() + public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineGet.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineListBySqlVulnerabilityAssessment.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_ListBySqlVulnerabilityAssessment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,31 +165,25 @@ public async Task GetIfExists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRule // get the collection of this SqlDatabaseSqlVulnerabilityAssessmentBaselineResource SqlDatabaseSqlVulnerabilityAssessmentBaselineCollection collection = sqlDatabaseSqlVulnerabilityAssessment.GetSqlDatabaseSqlVulnerabilityAssessmentBaselines(); - // invoke the operation - SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; - NullableResponse response = await collection.GetIfExistsAsync(baselineName); - SqlDatabaseSqlVulnerabilityAssessmentBaselineResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlDatabaseSqlVulnerabilityAssessmentBaselineResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; + SqlVulnerabilityAssessmentBaselineData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselineFromTheLatestScanResult() + public async Task Exists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineAddLatest.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineGet.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,8 +193,8 @@ public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselin // this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentResource created on azure // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityaseessmenttest-4711"; + string serverName = "vulnerabilityaseessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlDatabaseSqlVulnerabilityAssessmentResourceId = SqlDatabaseSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName); @@ -194,29 +205,17 @@ public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselin // invoke the operation SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; - SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent() - { - IsLatestScan = true, - Results = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, baselineName, content); - SqlDatabaseSqlVulnerabilityAssessmentBaselineResource result = lro.Value; + bool result = await collection.ExistsAsync(baselineName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselineList() + public async Task GetIfExists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineAdd.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentBaselineGet.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentBaselines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,8 +225,8 @@ public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselin // this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentResource created on azure // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityaseessmenttest-4711"; + string serverName = "vulnerabilityaseessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlDatabaseSqlVulnerabilityAssessmentResourceId = SqlDatabaseSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName); @@ -238,35 +237,21 @@ public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselin // invoke the operation SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; - SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent() - { - IsLatestScan = false, - Results = -{ -["VA2063"] = new IList[] -{ -new string[] -{ -"AllowAll","0.0.0.0","255.255.255.255" -} -}, -["VA2065"] = new IList[] -{ -new string[] -{ -"AllowAll","0.0.0.0","255.255.255.255" -} -}, -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, baselineName, content); - SqlDatabaseSqlVulnerabilityAssessmentBaselineResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(baselineName); + SqlDatabaseSqlVulnerabilityAssessmentBaselineResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineResource.cs index 2905286203dda..2a8142d3c1972 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -74,12 +73,10 @@ public async Task Update_AddADatabaseSVulnerabilityAssessmentRuleBaselineFromThe SqlDatabaseSqlVulnerabilityAssessmentBaselineResource sqlDatabaseSqlVulnerabilityAssessmentBaseline = client.GetSqlDatabaseSqlVulnerabilityAssessmentBaselineResource(sqlDatabaseSqlVulnerabilityAssessmentBaselineResourceId); // invoke the operation - SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent() + SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent { IsLatestScan = true, - Results = -{ -}, + Results = { }, }; ArmOperation lro = await sqlDatabaseSqlVulnerabilityAssessmentBaseline.UpdateAsync(WaitUntil.Completed, content); SqlDatabaseSqlVulnerabilityAssessmentBaselineResource result = lro.Value; @@ -115,25 +112,13 @@ public async Task Update_AddADatabaseSVulnerabilityAssessmentRuleBaselineList() SqlDatabaseSqlVulnerabilityAssessmentBaselineResource sqlDatabaseSqlVulnerabilityAssessmentBaseline = client.GetSqlDatabaseSqlVulnerabilityAssessmentBaselineResource(sqlDatabaseSqlVulnerabilityAssessmentBaselineResourceId); // invoke the operation - SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent() + SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent { IsLatestScan = false, Results = { -["VA2063"] = new IList[] -{ -new string[] -{ -"AllowAll","0.0.0.0","255.255.255.255" -} -}, -["VA2065"] = new IList[] -{ -new string[] -{ -"AllowAll","0.0.0.0","255.255.255.255" -} -}, +["VA2063"] = {{"AllowAll", "0.0.0.0", "255.255.255.255"}}, +["VA2065"] = {{"AllowAll", "0.0.0.0", "255.255.255.255"}} }, }; ArmOperation lro = await sqlDatabaseSqlVulnerabilityAssessmentBaseline.UpdateAsync(WaitUntil.Completed, content); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleCollection.cs index 67c60ef610349..17d33c7e8be1a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleCol { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() + public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineListByBaseline.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_ListByBaseline" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineCreate.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBasel // this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentBaselineResource created on azure // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentBaselineResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentBaselineResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4711"; - string serverName = "vulnerabilityaseessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; @@ -42,17 +42,21 @@ public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBasel // get the collection of this SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleCollection collection = sqlDatabaseSqlVulnerabilityAssessmentBaseline.GetSqlDatabaseSqlVulnerabilityAssessmentBaselineRules(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleId = "VA1001"; + SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsLatestScan = false, + Results = { { "userA", "SELECT" }, { "userB", "SELECT" }, { "userC", "SELECT" } }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, content); + SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -94,10 +98,10 @@ public async Task Get_GetsADatabaseSSqlVulnerabilityAssessmentRuleBaseline() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsADatabaseSSqlVulnerabilityAssessmentRuleBaseline() + public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineGet.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineListByBaseline.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_ListByBaseline" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +122,22 @@ public async Task Exists_GetsADatabaseSSqlVulnerabilityAssessmentRuleBaseline() // get the collection of this SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleCollection collection = sqlDatabaseSqlVulnerabilityAssessmentBaseline.GetSqlDatabaseSqlVulnerabilityAssessmentBaselineRules(); - // invoke the operation - string ruleId = "VA1001"; - bool result = await collection.ExistsAsync(ruleId); + // invoke the operation and iterate over the result + await foreach (SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsADatabaseSSqlVulnerabilityAssessmentRuleBaseline() + public async Task Exists_GetsADatabaseSSqlVulnerabilityAssessmentRuleBaseline() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineGet.json // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. @@ -153,29 +163,17 @@ public async Task GetIfExists_GetsADatabaseSSqlVulnerabilityAssessmentRuleBaseli // invoke the operation string ruleId = "VA1001"; - NullableResponse response = await collection.GetIfExistsAsync(ruleId); - SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task GetIfExists_GetsADatabaseSSqlVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineCreate.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineGet.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,8 +183,8 @@ public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessme // this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentBaselineResource created on azure // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentBaselineResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentBaselineResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityaseessmenttest-4711"; + string serverName = "vulnerabilityaseessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; @@ -198,31 +196,21 @@ public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessme // invoke the operation string ruleId = "VA1001"; - SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent() - { - IsLatestScan = false, - Results = -{ -new string[] -{ -"userA","SELECT" -},new string[] -{ -"userB","SELECT" -},new string[] -{ -"userC","SELECT" -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, content); - SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleId); + SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource.cs index 98aaf93f1cec6..d4691d554e4ff 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource.cs @@ -52,10 +52,10 @@ public async Task Get_GetsADatabaseSSqlVulnerabilityAssessmentRuleBaseline() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineCreate.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineDelete.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,8 +65,8 @@ public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBa // this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource created on azure // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityaseessmenttest-4711"; + string serverName = "vulnerabilityaseessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; @@ -75,39 +75,17 @@ public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBa SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource sqlDatabaseSqlVulnerabilityAssessmentBaselineRule = client.GetSqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource(sqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResourceId); // invoke the operation - SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent() - { - IsLatestScan = false, - Results = -{ -new string[] -{ -"userA","SELECT" -},new string[] -{ -"userB","SELECT" -},new string[] -{ -"userC","SELECT" -} -}, - }; - ArmOperation lro = await sqlDatabaseSqlVulnerabilityAssessmentBaselineRule.UpdateAsync(WaitUntil.Completed, content); - SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; + await sqlDatabaseSqlVulnerabilityAssessmentBaselineRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineDelete.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentRuleBaselineCreate.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,8 +95,8 @@ public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() // this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource created on azure // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4711"; - string serverName = "vulnerabilityaseessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; @@ -127,9 +105,19 @@ public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource sqlDatabaseSqlVulnerabilityAssessmentBaselineRule = client.GetSqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource(sqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResourceId); // invoke the operation - await sqlDatabaseSqlVulnerabilityAssessmentBaselineRule.DeleteAsync(WaitUntil.Completed); + SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent + { + IsLatestScan = false, + Results = { { "userA", "SELECT" }, { "userB", "SELECT" }, { "userC", "SELECT" } }, + }; + ArmOperation lro = await sqlDatabaseSqlVulnerabilityAssessmentBaselineRule.UpdateAsync(WaitUntil.Completed, content); + SqlDatabaseSqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentCollection.cs index 0304eb6273d3a..b5327c7eb6f6d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseSqlVulnerabilityAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSQLVulnerabilityAssessmentPoliciesOnAGivenDatabase() + public async Task Get_GetSQLVulnerabilityAssessmentPolicyForDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentListByDatabase.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentsSettings_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentGet.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_GetSQLVulnerabilityAssessmentPoliciesOnAGivenDatabase() // get the collection of this SqlDatabaseSqlVulnerabilityAssessmentResource SqlDatabaseSqlVulnerabilityAssessmentCollection collection = sqlDatabase.GetSqlDatabaseSqlVulnerabilityAssessments(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseSqlVulnerabilityAssessmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; + SqlDatabaseSqlVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSQLVulnerabilityAssessmentPolicyForDatabase() + public async Task GetAll_GetSQLVulnerabilityAssessmentPoliciesOnAGivenDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentGet.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentListByDatabase.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentsSettings_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +75,17 @@ public async Task Get_GetSQLVulnerabilityAssessmentPolicyForDatabase() // get the collection of this SqlDatabaseSqlVulnerabilityAssessmentResource SqlDatabaseSqlVulnerabilityAssessmentCollection collection = sqlDatabase.GetSqlDatabaseSqlVulnerabilityAssessments(); - // invoke the operation - VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - SqlDatabaseSqlVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); + // invoke the operation and iterate over the result + await foreach (SqlDatabaseSqlVulnerabilityAssessmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentResource.cs index c95fa43cd339d..94e5b0b616f95 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseSqlVulnerabilityAssessmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task ExecuteScan_ExecutesADatabaseSVulnerabilityAssessmentScan() + public async Task Get_GetSQLVulnerabilityAssessmentPolicyForDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScansExecute.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentExecuteScan_Execute" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentGet.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,25 +31,29 @@ public async Task ExecuteScan_ExecutesADatabaseSVulnerabilityAssessmentScan() // this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentResource created on azure // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityassessmenttest-4711"; - string serverName = "vulnerabilityassessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlDatabaseSqlVulnerabilityAssessmentResourceId = SqlDatabaseSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName); SqlDatabaseSqlVulnerabilityAssessmentResource sqlDatabaseSqlVulnerabilityAssessment = client.GetSqlDatabaseSqlVulnerabilityAssessmentResource(sqlDatabaseSqlVulnerabilityAssessmentResourceId); // invoke the operation - await sqlDatabaseSqlVulnerabilityAssessment.ExecuteScanAsync(WaitUntil.Completed); + SqlDatabaseSqlVulnerabilityAssessmentResource result = await sqlDatabaseSqlVulnerabilityAssessment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSQLVulnerabilityAssessmentPolicyForDatabase() + public async Task ExecuteScan_ExecutesADatabaseSVulnerabilityAssessmentScan() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentGet.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScansExecute.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentExecuteScan_Execute" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,21 +63,17 @@ public async Task Get_GetSQLVulnerabilityAssessmentPolicyForDatabase() // this example assumes you already have this SqlDatabaseSqlVulnerabilityAssessmentResource created on azure // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityassessmenttest-4711"; + string serverName = "vulnerabilityassessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlDatabaseSqlVulnerabilityAssessmentResourceId = SqlDatabaseSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName); SqlDatabaseSqlVulnerabilityAssessmentResource sqlDatabaseSqlVulnerabilityAssessment = client.GetSqlDatabaseSqlVulnerabilityAssessmentResource(sqlDatabaseSqlVulnerabilityAssessmentResourceId); // invoke the operation - SqlDatabaseSqlVulnerabilityAssessmentResource result = await sqlDatabaseSqlVulnerabilityAssessment.GetAsync(); + await sqlDatabaseSqlVulnerabilityAssessment.ExecuteScanAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentScanCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentScanCollection.cs index d73722527a4bb..11b36243596a6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentScanCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentScanCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseSqlVulnerabilityAssessmentScanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecords() + public async Task Get_GetADatabaseSVulnerabilityAssessmentScan() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScanRecordsListByDatabase.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentScans_ListBySqlVulnerabilityAssessments" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScan.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecord // get the collection of this SqlDatabaseSqlVulnerabilityAssessmentScanResource SqlDatabaseSqlVulnerabilityAssessmentScanCollection collection = sqlDatabaseSqlVulnerabilityAssessment.GetSqlDatabaseSqlVulnerabilityAssessmentScans(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseSqlVulnerabilityAssessmentScanResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scanId = "scan001"; + SqlDatabaseSqlVulnerabilityAssessmentScanResource result = await collection.GetAsync(scanId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentScanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabaseSVulnerabilityAssessmentScan() + public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecords() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScan.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScanRecordsListByDatabase.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentScans_ListBySqlVulnerabilityAssessments" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +77,17 @@ public async Task Get_GetADatabaseSVulnerabilityAssessmentScan() // get the collection of this SqlDatabaseSqlVulnerabilityAssessmentScanResource SqlDatabaseSqlVulnerabilityAssessmentScanCollection collection = sqlDatabaseSqlVulnerabilityAssessment.GetSqlDatabaseSqlVulnerabilityAssessmentScans(); - // invoke the operation - string scanId = "scan001"; - SqlDatabaseSqlVulnerabilityAssessmentScanResource result = await collection.GetAsync(scanId); + // invoke the operation and iterate over the result + await foreach (SqlDatabaseSqlVulnerabilityAssessmentScanResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentScanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentScanResultCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentScanResultCollection.cs index f10373198d6a5..7647e549439dd 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentScanResultCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseSqlVulnerabilityAssessmentScanResultCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseSqlVulnerabilityAssessmentScanResultColle { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDatabaseSQLVulnerabilityAssessmentScanResultsForScanId() + public async Task Get_GetADatabaseSQLVulnerabilityAssessmentScanResultForScanIdAndScanResultId() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentListScansResults.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentScanResult_ListByScan" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScansResults.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentScanResult_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task GetAll_ListDatabaseSQLVulnerabilityAssessmentScanResultsForSca // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentScanResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentScanResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "vulnerabilityassessmenttest-4711"; - string serverName = "testsvr"; + string serverName = "vulnerabilityassessmenttest-6411"; string databaseName = "master"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; string scanId = "scanId1"; @@ -42,25 +42,23 @@ public async Task GetAll_ListDatabaseSQLVulnerabilityAssessmentScanResultsForSca // get the collection of this SqlDatabaseSqlVulnerabilityAssessmentScanResultResource SqlDatabaseSqlVulnerabilityAssessmentScanResultCollection collection = sqlDatabaseSqlVulnerabilityAssessmentScan.GetSqlDatabaseSqlVulnerabilityAssessmentScanResults(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseSqlVulnerabilityAssessmentScanResultResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanResultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scanResultId = "VA1234"; + SqlDatabaseSqlVulnerabilityAssessmentScanResultResource result = await collection.GetAsync(scanResultId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentScanResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabaseSQLVulnerabilityAssessmentScanResultForScanIdAndScanResultId() + public async Task GetAll_ListDatabaseSQLVulnerabilityAssessmentScanResultsForScanId() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentScansResults.json - // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentScanResult_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/DatabaseSqlVulnerabilityAssessmentListScansResults.json + // this example is just showing the usage of "DatabaseSqlVulnerabilityAssessmentScanResult_ListByScan" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,7 +69,7 @@ public async Task Get_GetADatabaseSQLVulnerabilityAssessmentScanResultForScanIdA // for more information of creating SqlDatabaseSqlVulnerabilityAssessmentScanResource, please refer to the document of SqlDatabaseSqlVulnerabilityAssessmentScanResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "vulnerabilityassessmenttest-4711"; - string serverName = "vulnerabilityassessmenttest-6411"; + string serverName = "testsvr"; string databaseName = "master"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; string scanId = "scanId1"; @@ -81,15 +79,17 @@ public async Task Get_GetADatabaseSQLVulnerabilityAssessmentScanResultForScanIdA // get the collection of this SqlDatabaseSqlVulnerabilityAssessmentScanResultResource SqlDatabaseSqlVulnerabilityAssessmentScanResultCollection collection = sqlDatabaseSqlVulnerabilityAssessmentScan.GetSqlDatabaseSqlVulnerabilityAssessmentScanResults(); - // invoke the operation - string scanResultId = "VA1234"; - SqlDatabaseSqlVulnerabilityAssessmentScanResultResource result = await collection.GetAsync(scanResultId); + // invoke the operation and iterate over the result + await foreach (SqlDatabaseSqlVulnerabilityAssessmentScanResultResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentScanResultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseTableCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseTableCollection.cs index a355a567e5144..b12a85466800e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseTableCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseTableCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlDatabaseTableCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDatabaseTables() + public async Task Get_GetDatabaseTable() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseTableListBySchema.json - // this example is just showing the usage of "DatabaseTables_ListBySchema" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseTableGet.json + // this example is just showing the usage of "DatabaseTables_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListDatabaseTables() // get the collection of this SqlDatabaseTableResource SqlDatabaseTableCollection collection = sqlDatabaseSchema.GetSqlDatabaseTables(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseTableResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseTableData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string tableName = "table1"; + SqlDatabaseTableResource result = await collection.GetAsync(tableName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatabaseTable() + public async Task GetAll_ListDatabaseTables() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseTableGet.json - // this example is just showing the usage of "DatabaseTables_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseTableListBySchema.json + // this example is just showing the usage of "DatabaseTables_ListBySchema" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetDatabaseTable() // get the collection of this SqlDatabaseTableResource SqlDatabaseTableCollection collection = sqlDatabaseSchema.GetSqlDatabaseTables(); - // invoke the operation - string tableName = "table1"; - SqlDatabaseTableResource result = await collection.GetAsync(tableName); + // invoke the operation and iterate over the result + await foreach (SqlDatabaseTableResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseTableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentCollection.cs index 8d71191efe8f7..5d00e0e62ced3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseVulnerabilityAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabaseSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentGet.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentCreateMax.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,20 @@ public async Task Get_GetADatabaseSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - SqlDatabaseVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); + DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + RecurringScans = new VulnerabilityAssessmentRecurringScansProperties + { + IsEnabled = true, + EmailSubscriptionAdmins = true, + Emails = { "email1@mail.com", "email2@mail.com" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SqlDatabaseVulnerabilityAssessmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +66,10 @@ public async Task Get_GetADatabaseSVulnerabilityAssessment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADatabaseSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMinimalParametersWhenStorageAccountAccessKeyIsSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentGet.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentCreateStorageAccessKeyMin.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,17 +90,27 @@ public async Task Exists_GetADatabaseSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); + DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SqlDatabaseVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADatabaseSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMinimalParametersWhenStorageContainerSasKeyIsSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentGet.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentCreateContainerSasKeyMin.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,29 +131,27 @@ public async Task GetIfExists_GetADatabaseSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); - SqlDatabaseVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SqlDatabaseVulnerabilityAssessmentResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithAllParameters() + public async Task Get_GetADatabaseSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentCreateMax.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentGet.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,23 +172,7 @@ public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithAllP // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new VulnerabilityAssessmentRecurringScansProperties() - { - IsEnabled = true, - EmailSubscriptionAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SqlDatabaseVulnerabilityAssessmentResource result = lro.Value; + SqlDatabaseVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -178,10 +183,10 @@ public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithAllP [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMinimalParametersWhenStorageAccountAccessKeyIsSpecified() + public async Task GetAll_GetTheDatabaseSVulnerabilityAssessmentPolicies() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentCreateStorageAccessKeyMin.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentListByDatabase.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessments_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -200,29 +205,25 @@ public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMini // get the collection of this SqlDatabaseVulnerabilityAssessmentResource SqlDatabaseVulnerabilityAssessmentCollection collection = sqlDatabase.GetSqlDatabaseVulnerabilityAssessments(); - // invoke the operation - VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData() + // invoke the operation and iterate over the result + await foreach (SqlDatabaseVulnerabilityAssessmentResource item in collection.GetAllAsync()) { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SqlDatabaseVulnerabilityAssessmentResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMinimalParametersWhenStorageContainerSasKeyIsSpecified() + public async Task Exists_GetADatabaseSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentCreateContainerSasKeyMin.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentGet.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -243,27 +244,17 @@ public async Task CreateOrUpdate_CreateADatabaseSVulnerabilityAssessmentWithMini // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SqlDatabaseVulnerabilityAssessmentResource result = lro.Value; + bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheDatabaseSVulnerabilityAssessmentPolicies() + public async Task GetIfExists_GetADatabaseSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentListByDatabase.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessments_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentGet.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -282,17 +273,23 @@ public async Task GetAll_GetTheDatabaseSVulnerabilityAssessmentPolicies() // get the collection of this SqlDatabaseVulnerabilityAssessmentResource SqlDatabaseVulnerabilityAssessmentCollection collection = sqlDatabase.GetSqlDatabaseVulnerabilityAssessments(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseVulnerabilityAssessmentResource item in collection.GetAllAsync()) + // invoke the operation + VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; + NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); + SqlDatabaseVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentData resourceData = item.Data; + DatabaseVulnerabilityAssessmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentResource.cs index a7908b94b0c0b..49c47a6cf4612 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentResource.cs @@ -48,6 +48,34 @@ public async Task Get_GetADatabaseSVulnerabilityAssessment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_RemoveADatabaseSVulnerabilityAssessment() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentDelete.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SqlDatabaseVulnerabilityAssessmentResource created on azure + // for more information of creating SqlDatabaseVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseVulnerabilityAssessmentResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; + string databaseName = "testdb"; + VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; + ResourceIdentifier sqlDatabaseVulnerabilityAssessmentResourceId = SqlDatabaseVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName); + SqlDatabaseVulnerabilityAssessmentResource sqlDatabaseVulnerabilityAssessment = client.GetSqlDatabaseVulnerabilityAssessmentResource(sqlDatabaseVulnerabilityAssessmentResourceId); + + // invoke the operation + await sqlDatabaseVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithAllParameters() @@ -71,19 +99,16 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithAllParameter SqlDatabaseVulnerabilityAssessmentResource sqlDatabaseVulnerabilityAssessment = client.GetSqlDatabaseVulnerabilityAssessmentResource(sqlDatabaseVulnerabilityAssessmentResourceId); // invoke the operation - DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData() + DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new VulnerabilityAssessmentRecurringScansProperties() + RecurringScans = new VulnerabilityAssessmentRecurringScansProperties { IsEnabled = true, EmailSubscriptionAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, + Emails = { "email1@mail.com", "email2@mail.com" }, }, }; ArmOperation lro = await sqlDatabaseVulnerabilityAssessment.UpdateAsync(WaitUntil.Completed, data); @@ -119,7 +144,7 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithMinimalParam SqlDatabaseVulnerabilityAssessmentResource sqlDatabaseVulnerabilityAssessment = client.GetSqlDatabaseVulnerabilityAssessmentResource(sqlDatabaseVulnerabilityAssessmentResourceId); // invoke the operation - DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData() + DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -157,7 +182,7 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithMinimalParam SqlDatabaseVulnerabilityAssessmentResource sqlDatabaseVulnerabilityAssessment = client.GetSqlDatabaseVulnerabilityAssessmentResource(sqlDatabaseVulnerabilityAssessmentResourceId); // invoke the operation - DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData() + DatabaseVulnerabilityAssessmentData data = new DatabaseVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -171,33 +196,5 @@ public async Task Update_CreateADatabaseSVulnerabilityAssessmentWithMinimalParam // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_RemoveADatabaseSVulnerabilityAssessment() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentDelete.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SqlDatabaseVulnerabilityAssessmentResource created on azure - // for more information of creating SqlDatabaseVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseVulnerabilityAssessmentResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; - string databaseName = "testdb"; - VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - ResourceIdentifier sqlDatabaseVulnerabilityAssessmentResourceId = SqlDatabaseVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName); - SqlDatabaseVulnerabilityAssessmentResource sqlDatabaseVulnerabilityAssessment = client.GetSqlDatabaseVulnerabilityAssessmentResource(sqlDatabaseVulnerabilityAssessmentResourceId); - - // invoke the operation - await sqlDatabaseVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentRuleBaselineCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentRuleBaselineCollection.cs index 6a4a8fa73b26f..cd8f26960e673 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentRuleBaselineCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentRuleBaselineCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseVulnerabilityAssessmentRuleBaselineCollec { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineGet.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineCreate.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() // this example assumes you already have this SqlDatabaseVulnerabilityAssessmentResource created on azure // for more information of creating SqlDatabaseVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4711"; - string serverName = "vulnerabilityaseessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlDatabaseVulnerabilityAssessmentResourceId = SqlDatabaseVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName); @@ -43,8 +43,13 @@ public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() // invoke the operation string ruleId = "VA1001"; - VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Master; - SqlDatabaseVulnerabilityAssessmentRuleBaselineResource result = await collection.GetAsync(ruleId, baselineName); + VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Default; + DatabaseVulnerabilityAssessmentRuleBaselineData data = new DatabaseVulnerabilityAssessmentRuleBaselineData + { + BaselineResults = { new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userA", "SELECT" }), new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userB", "SELECT" }), new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userC", "SELECT", "tableId_4" }) }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, baselineName, data); + SqlDatabaseVulnerabilityAssessmentRuleBaselineResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,7 +60,7 @@ public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineGet.json // this example is just showing the usage of "DatabaseVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. @@ -81,14 +86,18 @@ public async Task Exists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() // invoke the operation string ruleId = "VA1001"; VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Master; - bool result = await collection.ExistsAsync(ruleId, baselineName); + SqlDatabaseVulnerabilityAssessmentRuleBaselineResource result = await collection.GetAsync(ruleId, baselineName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Exists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineGet.json // this example is just showing the usage of "DatabaseVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. @@ -114,29 +123,17 @@ public async Task GetIfExists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline( // invoke the operation string ruleId = "VA1001"; VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Master; - NullableResponse response = await collection.GetIfExistsAsync(ruleId, baselineName); - SqlDatabaseVulnerabilityAssessmentRuleBaselineResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleId, baselineName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task GetIfExists_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineCreate.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineGet.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessmentRuleBaselines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,8 +143,8 @@ public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessme // this example assumes you already have this SqlDatabaseVulnerabilityAssessmentResource created on azure // for more information of creating SqlDatabaseVulnerabilityAssessmentResource, please refer to the document of SqlDatabaseVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityaseessmenttest-4711"; + string serverName = "vulnerabilityaseessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlDatabaseVulnerabilityAssessmentResourceId = SqlDatabaseVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName); @@ -158,31 +155,22 @@ public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessme // invoke the operation string ruleId = "VA1001"; - VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Default; - DatabaseVulnerabilityAssessmentRuleBaselineData data = new DatabaseVulnerabilityAssessmentRuleBaselineData() - { - BaselineResults = -{ -new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userA","SELECT" -}),new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userB","SELECT" -}),new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userC","SELECT","tableId_4" -}) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, baselineName, data); - SqlDatabaseVulnerabilityAssessmentRuleBaselineResource result = lro.Value; + VulnerabilityAssessmentPolicyBaselineName baselineName = VulnerabilityAssessmentPolicyBaselineName.Master; + NullableResponse response = await collection.GetIfExistsAsync(ruleId, baselineName); + SqlDatabaseVulnerabilityAssessmentRuleBaselineResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentRuleBaselineResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentRuleBaselineResource.cs index b4079a60d5454..b47775f4e576e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentRuleBaselineResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentRuleBaselineResource.cs @@ -52,10 +52,10 @@ public async Task Get_GetsADatabaseSVulnerabilityAssessmentRuleBaseline() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineCreate.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineDelete.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessmentRuleBaselines_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,38 +75,17 @@ public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBa SqlDatabaseVulnerabilityAssessmentRuleBaselineResource sqlDatabaseVulnerabilityAssessmentRuleBaseline = client.GetSqlDatabaseVulnerabilityAssessmentRuleBaselineResource(sqlDatabaseVulnerabilityAssessmentRuleBaselineResourceId); // invoke the operation - DatabaseVulnerabilityAssessmentRuleBaselineData data = new DatabaseVulnerabilityAssessmentRuleBaselineData() - { - BaselineResults = -{ -new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userA","SELECT" -}),new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userB","SELECT" -}),new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] -{ -"userC","SELECT","tableId_4" -}) -}, - }; - ArmOperation lro = await sqlDatabaseVulnerabilityAssessmentRuleBaseline.UpdateAsync(WaitUntil.Completed, data); - SqlDatabaseVulnerabilityAssessmentRuleBaselineResource result = lro.Value; + await sqlDatabaseVulnerabilityAssessmentRuleBaseline.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineDelete.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessmentRuleBaselines_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentRuleBaselineCreate.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessmentRuleBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -126,9 +105,18 @@ public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() SqlDatabaseVulnerabilityAssessmentRuleBaselineResource sqlDatabaseVulnerabilityAssessmentRuleBaseline = client.GetSqlDatabaseVulnerabilityAssessmentRuleBaselineResource(sqlDatabaseVulnerabilityAssessmentRuleBaselineResourceId); // invoke the operation - await sqlDatabaseVulnerabilityAssessmentRuleBaseline.DeleteAsync(WaitUntil.Completed); + DatabaseVulnerabilityAssessmentRuleBaselineData data = new DatabaseVulnerabilityAssessmentRuleBaselineData + { + BaselineResults = { new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userA", "SELECT" }), new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userB", "SELECT" }), new DatabaseVulnerabilityAssessmentRuleBaselineItem(new string[] { "userC", "SELECT", "tableId_4" }) }, + }; + ArmOperation lro = await sqlDatabaseVulnerabilityAssessmentRuleBaseline.UpdateAsync(WaitUntil.Completed, data); + SqlDatabaseVulnerabilityAssessmentRuleBaselineResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseVulnerabilityAssessmentRuleBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentScanCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentScanCollection.cs index 63e41d7bef720..3268b01ade3e6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentScanCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentScanCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseVulnerabilityAssessmentScanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecords() + public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScanRecordsListByDatabase.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessmentScans_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScanRecordsGet.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecord // get the collection of this SqlDatabaseVulnerabilityAssessmentScanResource SqlDatabaseVulnerabilityAssessmentScanCollection collection = sqlDatabaseVulnerabilityAssessment.GetSqlDatabaseVulnerabilityAssessmentScans(); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseVulnerabilityAssessmentScanResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VulnerabilityAssessmentScanRecordData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scanId = "scan001"; + SqlDatabaseVulnerabilityAssessmentScanResource result = await collection.GetAsync(scanId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VulnerabilityAssessmentScanRecordData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() + public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecords() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScanRecordsGet.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScanRecordsListByDatabase.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessmentScans_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,15 +77,17 @@ public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() // get the collection of this SqlDatabaseVulnerabilityAssessmentScanResource SqlDatabaseVulnerabilityAssessmentScanCollection collection = sqlDatabaseVulnerabilityAssessment.GetSqlDatabaseVulnerabilityAssessmentScans(); - // invoke the operation - string scanId = "scan001"; - SqlDatabaseVulnerabilityAssessmentScanResource result = await collection.GetAsync(scanId); + // invoke the operation and iterate over the result + await foreach (SqlDatabaseVulnerabilityAssessmentScanResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VulnerabilityAssessmentScanRecordData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VulnerabilityAssessmentScanRecordData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentScanResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentScanResource.cs index 626b675abb3a2..a4b8ecdc7e5c3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentScanResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlDatabaseVulnerabilityAssessmentScanResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlDatabaseVulnerabilityAssessmentScanResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task InitiateScan_ExecutesADatabaseSVulnerabilityAssessmentScan() + public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScansExecute.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessmentScans_InitiateScan" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScanRecordsGet.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,22 +35,26 @@ public async Task InitiateScan_ExecutesADatabaseSVulnerabilityAssessmentScan() string serverName = "vulnerabilityassessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - string scanId = "scan01"; + string scanId = "scan001"; ResourceIdentifier sqlDatabaseVulnerabilityAssessmentScanResourceId = SqlDatabaseVulnerabilityAssessmentScanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId); SqlDatabaseVulnerabilityAssessmentScanResource sqlDatabaseVulnerabilityAssessmentScan = client.GetSqlDatabaseVulnerabilityAssessmentScanResource(sqlDatabaseVulnerabilityAssessmentScanResourceId); // invoke the operation - await sqlDatabaseVulnerabilityAssessmentScan.InitiateScanAsync(WaitUntil.Completed); + SqlDatabaseVulnerabilityAssessmentScanResource result = await sqlDatabaseVulnerabilityAssessmentScan.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VulnerabilityAssessmentScanRecordData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() + public async Task InitiateScan_ExecutesADatabaseSVulnerabilityAssessmentScan() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScanRecordsGet.json - // this example is just showing the usage of "DatabaseVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseVulnerabilityAssessmentScansExecute.json + // this example is just showing the usage of "DatabaseVulnerabilityAssessmentScans_InitiateScan" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,18 +68,14 @@ public async Task Get_GetsADatabaseVulnerabilityAssessmentScanRecordByScanID() string serverName = "vulnerabilityassessmenttest-6411"; string databaseName = "testdb"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - string scanId = "scan001"; + string scanId = "scan01"; ResourceIdentifier sqlDatabaseVulnerabilityAssessmentScanResourceId = SqlDatabaseVulnerabilityAssessmentScanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, vulnerabilityAssessmentName, scanId); SqlDatabaseVulnerabilityAssessmentScanResource sqlDatabaseVulnerabilityAssessmentScan = client.GetSqlDatabaseVulnerabilityAssessmentScanResource(sqlDatabaseVulnerabilityAssessmentScanResourceId); // invoke the operation - SqlDatabaseVulnerabilityAssessmentScanResource result = await sqlDatabaseVulnerabilityAssessmentScan.GetAsync(); + await sqlDatabaseVulnerabilityAssessmentScan.InitiateScanAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VulnerabilityAssessmentScanRecordData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlFirewallRuleCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlFirewallRuleCollection.cs index 96df62ba3a01f..efeb063fa63c5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlFirewallRuleCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlFirewallRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlFirewallRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallRule() + public async Task CreateOrUpdate_CreateAFirewallRuleMaxMin() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleCreate.json + // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,14 @@ public async Task Get_GetFirewallRule() SqlFirewallRuleCollection collection = sqlServer.GetSqlFirewallRules(); // invoke the operation - string firewallRuleName = "firewallrulecrudtest-2304"; - SqlFirewallRuleResource result = await collection.GetAsync(firewallRuleName); + string firewallRuleName = "firewallrulecrudtest-5370"; + SqlFirewallRuleData data = new SqlFirewallRuleData + { + StartIPAddress = "0.0.0.3", + EndIPAddress = "0.0.0.3", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data); + SqlFirewallRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +57,10 @@ public async Task Get_GetFirewallRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFirewallRule() + public async Task CreateOrUpdate_UpdateAFirewallRuleMaxMin() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleUpdate.json + // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +79,25 @@ public async Task Exists_GetFirewallRule() SqlFirewallRuleCollection collection = sqlServer.GetSqlFirewallRules(); // invoke the operation - string firewallRuleName = "firewallrulecrudtest-2304"; - bool result = await collection.ExistsAsync(firewallRuleName); + string firewallRuleName = "firewallrulecrudtest-3927"; + SqlFirewallRuleData data = new SqlFirewallRuleData + { + StartIPAddress = "0.0.0.1", + EndIPAddress = "0.0.0.1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data); + SqlFirewallRuleResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFirewallRule() + public async Task Get_GetFirewallRule() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleGet.json // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +120,21 @@ public async Task GetIfExists_GetFirewallRule() // invoke the operation string firewallRuleName = "firewallrulecrudtest-2304"; - NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); - SqlFirewallRuleResource result = response.HasValue ? response.Value : null; + SqlFirewallRuleResource result = await collection.GetAsync(firewallRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAFirewallRuleMaxMin() + public async Task GetAll_ListFirewallRules() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleCreate.json - // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleList.json + // this example is just showing the usage of "FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,29 +152,25 @@ public async Task CreateOrUpdate_CreateAFirewallRuleMaxMin() // get the collection of this SqlFirewallRuleResource SqlFirewallRuleCollection collection = sqlServer.GetSqlFirewallRules(); - // invoke the operation - string firewallRuleName = "firewallrulecrudtest-5370"; - SqlFirewallRuleData data = new SqlFirewallRuleData() + // invoke the operation and iterate over the result + await foreach (SqlFirewallRuleResource item in collection.GetAllAsync()) { - StartIPAddress = "0.0.0.3", - EndIPAddress = "0.0.0.3", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data); - SqlFirewallRuleResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlFirewallRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAFirewallRuleMaxMin() + public async Task Exists_GetFirewallRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleUpdate.json - // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,28 +189,18 @@ public async Task CreateOrUpdate_UpdateAFirewallRuleMaxMin() SqlFirewallRuleCollection collection = sqlServer.GetSqlFirewallRules(); // invoke the operation - string firewallRuleName = "firewallrulecrudtest-3927"; - SqlFirewallRuleData data = new SqlFirewallRuleData() - { - StartIPAddress = "0.0.0.1", - EndIPAddress = "0.0.0.1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data); - SqlFirewallRuleResource result = lro.Value; + string firewallRuleName = "firewallrulecrudtest-2304"; + bool result = await collection.ExistsAsync(firewallRuleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFirewallRules() + public async Task GetIfExists_GetFirewallRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleList.json - // this example is just showing the usage of "FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -224,17 +218,23 @@ public async Task GetAll_ListFirewallRules() // get the collection of this SqlFirewallRuleResource SqlFirewallRuleCollection collection = sqlServer.GetSqlFirewallRules(); - // invoke the operation and iterate over the result - await foreach (SqlFirewallRuleResource item in collection.GetAllAsync()) + // invoke the operation + string firewallRuleName = "firewallrulecrudtest-2304"; + NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); + SqlFirewallRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlFirewallRuleData resourceData = item.Data; + SqlFirewallRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlFirewallRuleResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlFirewallRuleResource.cs index 4f7e3d14a119f..44f7fb1d99d5f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlFirewallRuleResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlFirewallRuleResource.cs @@ -46,6 +46,33 @@ public async Task Get_GetFirewallRule() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAFirewallRule() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleDelete.json + // this example is just showing the usage of "FirewallRules_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SqlFirewallRuleResource created on azure + // for more information of creating SqlFirewallRuleResource, please refer to the document of SqlFirewallRuleResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "firewallrulecrudtest-9886"; + string serverName = "firewallrulecrudtest-2368"; + string firewallRuleName = "firewallrulecrudtest-7011"; + ResourceIdentifier sqlFirewallRuleResourceId = SqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); + SqlFirewallRuleResource sqlFirewallRule = client.GetSqlFirewallRuleResource(sqlFirewallRuleResourceId); + + // invoke the operation + await sqlFirewallRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateAFirewallRuleMaxMin() @@ -68,7 +95,7 @@ public async Task Update_CreateAFirewallRuleMaxMin() SqlFirewallRuleResource sqlFirewallRule = client.GetSqlFirewallRuleResource(sqlFirewallRuleResourceId); // invoke the operation - SqlFirewallRuleData data = new SqlFirewallRuleData() + SqlFirewallRuleData data = new SqlFirewallRuleData { StartIPAddress = "0.0.0.3", EndIPAddress = "0.0.0.3", @@ -105,7 +132,7 @@ public async Task Update_UpdateAFirewallRuleMaxMin() SqlFirewallRuleResource sqlFirewallRule = client.GetSqlFirewallRuleResource(sqlFirewallRuleResourceId); // invoke the operation - SqlFirewallRuleData data = new SqlFirewallRuleData() + SqlFirewallRuleData data = new SqlFirewallRuleData { StartIPAddress = "0.0.0.1", EndIPAddress = "0.0.0.1", @@ -119,32 +146,5 @@ public async Task Update_UpdateAFirewallRuleMaxMin() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAFirewallRule() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/FirewallRuleDelete.json - // this example is just showing the usage of "FirewallRules_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SqlFirewallRuleResource created on azure - // for more information of creating SqlFirewallRuleResource, please refer to the document of SqlFirewallRuleResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "firewallrulecrudtest-9886"; - string serverName = "firewallrulecrudtest-2368"; - string firewallRuleName = "firewallrulecrudtest-7011"; - ResourceIdentifier sqlFirewallRuleResourceId = SqlFirewallRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, firewallRuleName); - SqlFirewallRuleResource sqlFirewallRule = client.GetSqlFirewallRuleResource(sqlFirewallRuleResourceId); - - // invoke the operation - await sqlFirewallRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateEndpointConnectionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateEndpointConnectionCollection.cs index 5f12f2281abe1..b76f4318a1590 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateEndpointConnectionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionList.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() // get the collection of this SqlPrivateEndpointConnectionResource SqlPrivateEndpointConnectionCollection collection = sqlServer.GetSqlPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (SqlPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + SqlPrivateEndpointConnectionData data = new SqlPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new SqlPrivateLinkServiceConnectionStateProperty(SqlPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + SqlPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionList.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_GetsPrivateEndpointConnection() // get the collection of this SqlPrivateEndpointConnectionResource SqlPrivateEndpointConnectionCollection collection = sqlServer.GetSqlPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (SqlPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task Exists_GetsPrivateEndpointConnection() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - SqlPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - SqlPrivateEndpointConnectionData data = new SqlPrivateEndpointConnectionData() - { - ConnectionState = new SqlPrivateLinkServiceConnectionStateProperty(SqlPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - SqlPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + SqlPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateEndpointConnectionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateEndpointConnectionResource.cs index 8246323d7925a..d05aa4b139f0a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateEndpointConnectionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionDelete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName SqlPrivateEndpointConnectionResource sqlPrivateEndpointConnection = client.GetSqlPrivateEndpointConnectionResource(sqlPrivateEndpointConnectionResourceId); // invoke the operation - SqlPrivateEndpointConnectionData data = new SqlPrivateEndpointConnectionData() - { - ConnectionState = new SqlPrivateLinkServiceConnectionStateProperty(SqlPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"), - }; - ArmOperation lro = await sqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - SqlPrivateEndpointConnectionResource result = lro.Value; + await sqlPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionDelete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() SqlPrivateEndpointConnectionResource sqlPrivateEndpointConnection = client.GetSqlPrivateEndpointConnectionResource(sqlPrivateEndpointConnectionResourceId); // invoke the operation - await sqlPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + SqlPrivateEndpointConnectionData data = new SqlPrivateEndpointConnectionData + { + ConnectionState = new SqlPrivateLinkServiceConnectionStateProperty(SqlPrivateLinkServiceConnectionStatus.Approved, "Approved by johndoe@contoso.com"), + }; + ArmOperation lro = await sqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + SqlPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateLinkResourceCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateLinkResourceCollection.cs index 71006dbceeadb..1412ff57d8483 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateLinkResourceCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateLinkResourcesForSQL() + public async Task Get_GetsAPrivateLinkResourceForSQL() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/PrivateLinkResourcesList.json - // this example is just showing the usage of "PrivateLinkResources_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/PrivateLinkResourcesGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetsPrivateLinkResourcesForSQL() // get the collection of this SqlPrivateLinkResource SqlPrivateLinkResourceCollection collection = sqlServer.GetSqlPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (SqlPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "plr"; + SqlPrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAPrivateLinkResourceForSQL() + public async Task GetAll_GetsPrivateLinkResourcesForSQL() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/PrivateLinkResourcesGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/PrivateLinkResourcesList.json + // this example is just showing the usage of "PrivateLinkResources_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsAPrivateLinkResourceForSQL() // get the collection of this SqlPrivateLinkResource SqlPrivateLinkResourceCollection collection = sqlServer.GetSqlPrivateLinkResources(); - // invoke the operation - string groupName = "plr"; - SqlPrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (SqlPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAdvisorCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAdvisorCollection.cs index a2d6c9854a29a..c3a1c6c22029c 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAdvisorCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAdvisorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlServerAdvisorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfServerAdvisors() + public async Task Get_GetServerAdvisor() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerAdvisorList.json - // this example is just showing the usage of "ServerAdvisors_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerAdvisorGet.json + // this example is just showing the usage of "ServerAdvisors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,24 +38,22 @@ public async Task GetAll_ListOfServerAdvisors() // get the collection of this SqlServerAdvisorResource SqlServerAdvisorCollection collection = sqlServer.GetSqlServerAdvisors(); - // invoke the operation and iterate over the result - await foreach (SqlServerAdvisorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlAdvisorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string advisorName = "CreateIndex"; + SqlServerAdvisorResource result = await collection.GetAsync(advisorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlAdvisorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfServerRecommendedActionsForAllAdvisors() + public async Task GetAll_ListOfServerAdvisors() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerRecommendedActionListExpand.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerAdvisorList.json // this example is just showing the usage of "ServerAdvisors_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -75,8 +73,7 @@ public async Task GetAll_ListOfServerRecommendedActionsForAllAdvisors() SqlServerAdvisorCollection collection = sqlServer.GetSqlServerAdvisors(); // invoke the operation and iterate over the result - string expand = "recommendedActions"; - await foreach (SqlServerAdvisorResource item in collection.GetAllAsync(expand: expand)) + await foreach (SqlServerAdvisorResource item in collection.GetAllAsync()) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,10 +87,10 @@ public async Task GetAll_ListOfServerRecommendedActionsForAllAdvisors() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServerAdvisor() + public async Task GetAll_ListOfServerRecommendedActionsForAllAdvisors() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerAdvisorGet.json - // this example is just showing the usage of "ServerAdvisors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerRecommendedActionListExpand.json + // this example is just showing the usage of "ServerAdvisors_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,15 +108,18 @@ public async Task Get_GetServerAdvisor() // get the collection of this SqlServerAdvisorResource SqlServerAdvisorCollection collection = sqlServer.GetSqlServerAdvisors(); - // invoke the operation - string advisorName = "CreateIndex"; - SqlServerAdvisorResource result = await collection.GetAsync(advisorName); + // invoke the operation and iterate over the result + string expand = "recommendedActions"; + await foreach (SqlServerAdvisorResource item in collection.GetAllAsync(expand: expand)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlAdvisorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlAdvisorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAdvisorResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAdvisorResource.cs index 240511db8b42c..c14f3115836fe 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAdvisorResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAdvisorResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdateServerAdvisor() SqlServerAdvisorResource sqlServerAdvisor = client.GetSqlServerAdvisorResource(sqlServerAdvisorResourceId); // invoke the operation - SqlAdvisorData data = new SqlAdvisorData() + SqlAdvisorData data = new SqlAdvisorData { AutoExecuteStatus = AutoExecuteStatus.Disabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAutomaticTuningResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAutomaticTuningResource.cs index 54a0b3cf21e0c..eb4ca054d5841 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAutomaticTuningResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAutomaticTuningResource.cs @@ -67,23 +67,23 @@ public async Task Update_UpdatesServerAutomaticTuningSettingsWithAllProperties() SqlServerAutomaticTuningResource sqlServerAutomaticTuning = client.GetSqlServerAutomaticTuningResource(sqlServerAutomaticTuningResourceId); // invoke the operation - SqlServerAutomaticTuningData data = new SqlServerAutomaticTuningData() + SqlServerAutomaticTuningData data = new SqlServerAutomaticTuningData { DesiredState = AutomaticTuningServerMode.Auto, Options = { -["createIndex"] = new AutomaticTuningServerOptions() +["createIndex"] = new AutomaticTuningServerOptions { DesiredState = AutomaticTuningOptionModeDesired.Off, }, -["dropIndex"] = new AutomaticTuningServerOptions() +["dropIndex"] = new AutomaticTuningServerOptions { DesiredState = AutomaticTuningOptionModeDesired.On, }, -["forceLastGoodPlan"] = new AutomaticTuningServerOptions() +["forceLastGoodPlan"] = new AutomaticTuningServerOptions { DesiredState = AutomaticTuningOptionModeDesired.Default, -}, +} }, }; SqlServerAutomaticTuningResource result = await sqlServerAutomaticTuning.UpdateAsync(data); @@ -116,7 +116,7 @@ public async Task Update_UpdatesServerAutomaticTuningSettingsWithMinimalProperti SqlServerAutomaticTuningResource sqlServerAutomaticTuning = client.GetSqlServerAutomaticTuningResource(sqlServerAutomaticTuningResourceId); // invoke the operation - SqlServerAutomaticTuningData data = new SqlServerAutomaticTuningData() + SqlServerAutomaticTuningData data = new SqlServerAutomaticTuningData { DesiredState = AutomaticTuningServerMode.Auto, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADAdministratorCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADAdministratorCollection.cs index 6ff142218ad7c..4b0a88c37ac1f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADAdministratorCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADAdministratorCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerAzureADAdministratorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAAzureActiveDirectoryAdministrator() + public async Task CreateOrUpdate_CreatesOrUpdatesAnExistingAzureActiveDirectoryAdministrator() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorGet.json - // this example is just showing the usage of "ServerAzureADAdministrators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorCreateOrUpdate.json + // this example is just showing the usage of "ServerAzureADAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_GetsAAzureActiveDirectoryAdministrator() // invoke the operation SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; - SqlServerAzureADAdministratorResource result = await collection.GetAsync(administratorName); + SqlServerAzureADAdministratorData data = new SqlServerAzureADAdministratorData + { + AdministratorType = SqlAdministratorType.ActiveDirectory, + Login = "bob@contoso.com", + Sid = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, administratorName, data); + SqlServerAzureADAdministratorResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_GetsAAzureActiveDirectoryAdministrator() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAAzureActiveDirectoryAdministrator() + public async Task Get_GetsAAzureActiveDirectoryAdministrator() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorGet.json // this example is just showing the usage of "ServerAzureADAdministrators_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +83,21 @@ public async Task Exists_GetsAAzureActiveDirectoryAdministrator() // invoke the operation SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; - bool result = await collection.ExistsAsync(administratorName); + SqlServerAzureADAdministratorResource result = await collection.GetAsync(administratorName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerAzureADAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAAzureActiveDirectoryAdministrator() + public async Task GetAll_GetsAListOfAzureActiveDirectoryAdministrator() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorGet.json - // this example is just showing the usage of "ServerAzureADAdministrators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorList.json + // this example is just showing the usage of "ServerAzureADAdministrators_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +115,25 @@ public async Task GetIfExists_GetsAAzureActiveDirectoryAdministrator() // get the collection of this SqlServerAzureADAdministratorResource SqlServerAzureADAdministratorCollection collection = sqlServer.GetSqlServerAzureADAdministrators(); - // invoke the operation - SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; - NullableResponse response = await collection.GetIfExistsAsync(administratorName); - SqlServerAzureADAdministratorResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerAzureADAdministratorResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerAzureADAdministratorData resourceData = result.Data; + SqlServerAzureADAdministratorData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesAnExistingAzureActiveDirectoryAdministrator() + public async Task Exists_GetsAAzureActiveDirectoryAdministrator() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorCreateOrUpdate.json - // this example is just showing the usage of "ServerAzureADAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorGet.json + // this example is just showing the usage of "ServerAzureADAdministrators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,29 +153,17 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAnExistingAzureActiveDirectoryA // invoke the operation SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; - SqlServerAzureADAdministratorData data = new SqlServerAzureADAdministratorData() - { - AdministratorType = SqlAdministratorType.ActiveDirectory, - Login = "bob@contoso.com", - Sid = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, administratorName, data); - SqlServerAzureADAdministratorResource result = lro.Value; + bool result = await collection.ExistsAsync(administratorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerAzureADAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfAzureActiveDirectoryAdministrator() + public async Task GetIfExists_GetsAAzureActiveDirectoryAdministrator() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorList.json - // this example is just showing the usage of "ServerAzureADAdministrators_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorGet.json + // this example is just showing the usage of "ServerAzureADAdministrators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +181,23 @@ public async Task GetAll_GetsAListOfAzureActiveDirectoryAdministrator() // get the collection of this SqlServerAzureADAdministratorResource SqlServerAzureADAdministratorCollection collection = sqlServer.GetSqlServerAzureADAdministrators(); - // invoke the operation and iterate over the result - await foreach (SqlServerAzureADAdministratorResource item in collection.GetAllAsync()) + // invoke the operation + SqlAdministratorName administratorName = SqlAdministratorName.ActiveDirectory; + NullableResponse response = await collection.GetIfExistsAsync(administratorName); + SqlServerAzureADAdministratorResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerAzureADAdministratorData resourceData = item.Data; + SqlServerAzureADAdministratorData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADAdministratorResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADAdministratorResource.cs index b3c1ebac072f0..ee91d369b29d6 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADAdministratorResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADAdministratorResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsAAzureActiveDirectoryAdministrator() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesAnExistingAzureActiveDirectoryAdministrator() + public async Task Delete_DeleteAzureActiveDirectoryAdministrator() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorCreateOrUpdate.json - // this example is just showing the usage of "ServerAzureADAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorDelete.json + // this example is just showing the usage of "ServerAzureADAdministrators_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_CreatesOrUpdatesAnExistingAzureActiveDirectoryAdministr SqlServerAzureADAdministratorResource sqlServerAzureADAdministrator = client.GetSqlServerAzureADAdministratorResource(sqlServerAzureADAdministratorResourceId); // invoke the operation - SqlServerAzureADAdministratorData data = new SqlServerAzureADAdministratorData() - { - AdministratorType = SqlAdministratorType.ActiveDirectory, - Login = "bob@contoso.com", - Sid = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - }; - ArmOperation lro = await sqlServerAzureADAdministrator.UpdateAsync(WaitUntil.Completed, data); - SqlServerAzureADAdministratorResource result = lro.Value; + await sqlServerAzureADAdministrator.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerAzureADAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAzureActiveDirectoryAdministrator() + public async Task Update_CreatesOrUpdatesAnExistingAzureActiveDirectoryAdministrator() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorDelete.json - // this example is just showing the usage of "ServerAzureADAdministrators_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AdministratorCreateOrUpdate.json + // this example is just showing the usage of "ServerAzureADAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DeleteAzureActiveDirectoryAdministrator() SqlServerAzureADAdministratorResource sqlServerAzureADAdministrator = client.GetSqlServerAzureADAdministratorResource(sqlServerAzureADAdministratorResourceId); // invoke the operation - await sqlServerAzureADAdministrator.DeleteAsync(WaitUntil.Completed); + SqlServerAzureADAdministratorData data = new SqlServerAzureADAdministratorData + { + AdministratorType = SqlAdministratorType.ActiveDirectory, + Login = "bob@contoso.com", + Sid = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + }; + ArmOperation lro = await sqlServerAzureADAdministrator.UpdateAsync(WaitUntil.Completed, data); + SqlServerAzureADAdministratorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerAzureADAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADOnlyAuthenticationCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADOnlyAuthenticationCollection.cs index b49fa5072cd0f..04df4fee8f902 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADOnlyAuthenticationCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADOnlyAuthenticationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerAzureADOnlyAuthenticationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task CreateOrUpdate_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthenticationObject() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthGet.json - // this example is just showing the usage of "ServerAzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthCreateOrUpdate.json + // this example is just showing the usage of "ServerAzureADOnlyAuthentications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() // invoke the operation AuthenticationName authenticationName = AuthenticationName.Default; - SqlServerAzureADOnlyAuthenticationResource result = await collection.GetAsync(authenticationName); + SqlServerAzureADOnlyAuthenticationData data = new SqlServerAzureADOnlyAuthenticationData + { + IsAzureADOnlyAuthenticationEnabled = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authenticationName, data); + SqlServerAzureADOnlyAuthenticationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task Get_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthGet.json // this example is just showing the usage of "ServerAzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() // invoke the operation AuthenticationName authenticationName = AuthenticationName.Default; - bool result = await collection.ExistsAsync(authenticationName); + SqlServerAzureADOnlyAuthenticationResource result = await collection.GetAsync(authenticationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerAzureADOnlyAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() + public async Task GetAll_GetsAListOfAzureActiveDirectoryOnlyAuthenticationObject() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthGet.json - // this example is just showing the usage of "ServerAzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthList.json + // this example is just showing the usage of "ServerAzureADOnlyAuthentications_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetsAAzureActiveDirectoryOnlyAuthenticationPropert // get the collection of this SqlServerAzureADOnlyAuthenticationResource SqlServerAzureADOnlyAuthenticationCollection collection = sqlServer.GetSqlServerAzureADOnlyAuthentications(); - // invoke the operation - AuthenticationName authenticationName = AuthenticationName.Default; - NullableResponse response = await collection.GetIfExistsAsync(authenticationName); - SqlServerAzureADOnlyAuthenticationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerAzureADOnlyAuthenticationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerAzureADOnlyAuthenticationData resourceData = result.Data; + SqlServerAzureADOnlyAuthenticationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthenticationObject() + public async Task Exists_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthCreateOrUpdate.json - // this example is just showing the usage of "ServerAzureADOnlyAuthentications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthGet.json + // this example is just showing the usage of "ServerAzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthent // invoke the operation AuthenticationName authenticationName = AuthenticationName.Default; - SqlServerAzureADOnlyAuthenticationData data = new SqlServerAzureADOnlyAuthenticationData() - { - IsAzureADOnlyAuthenticationEnabled = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authenticationName, data); - SqlServerAzureADOnlyAuthenticationResource result = lro.Value; + bool result = await collection.ExistsAsync(authenticationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerAzureADOnlyAuthenticationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfAzureActiveDirectoryOnlyAuthenticationObject() + public async Task GetIfExists_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthList.json - // this example is just showing the usage of "ServerAzureADOnlyAuthentications_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthGet.json + // this example is just showing the usage of "ServerAzureADOnlyAuthentications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_GetsAListOfAzureActiveDirectoryOnlyAuthenticationObject // get the collection of this SqlServerAzureADOnlyAuthenticationResource SqlServerAzureADOnlyAuthenticationCollection collection = sqlServer.GetSqlServerAzureADOnlyAuthentications(); - // invoke the operation and iterate over the result - await foreach (SqlServerAzureADOnlyAuthenticationResource item in collection.GetAllAsync()) + // invoke the operation + AuthenticationName authenticationName = AuthenticationName.Default; + NullableResponse response = await collection.GetIfExistsAsync(authenticationName); + SqlServerAzureADOnlyAuthenticationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerAzureADOnlyAuthenticationData resourceData = item.Data; + SqlServerAzureADOnlyAuthenticationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADOnlyAuthenticationResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADOnlyAuthenticationResource.cs index e8719d65e8ef5..57dfd33060b15 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADOnlyAuthenticationResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerAzureADOnlyAuthenticationResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsAAzureActiveDirectoryOnlyAuthenticationProperty() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthenticationObject() + public async Task Delete_DeletesAzureActiveDirectoryOnlyAuthenticationObject() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthCreateOrUpdate.json - // this example is just showing the usage of "ServerAzureADOnlyAuthentications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthDelete.json + // this example is just showing the usage of "ServerAzureADOnlyAuthentications_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthenticationO SqlServerAzureADOnlyAuthenticationResource sqlServerAzureADOnlyAuthentication = client.GetSqlServerAzureADOnlyAuthenticationResource(sqlServerAzureADOnlyAuthenticationResourceId); // invoke the operation - SqlServerAzureADOnlyAuthenticationData data = new SqlServerAzureADOnlyAuthenticationData() - { - IsAzureADOnlyAuthenticationEnabled = false, - }; - ArmOperation lro = await sqlServerAzureADOnlyAuthentication.UpdateAsync(WaitUntil.Completed, data); - SqlServerAzureADOnlyAuthenticationResource result = lro.Value; + await sqlServerAzureADOnlyAuthentication.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerAzureADOnlyAuthenticationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAzureActiveDirectoryOnlyAuthenticationObject() + public async Task Update_CreatesOrUpdatesAzureActiveDirectoryOnlyAuthenticationObject() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthDelete.json - // this example is just showing the usage of "ServerAzureADOnlyAuthentications_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/AzureADOnlyAuthCreateOrUpdate.json + // this example is just showing the usage of "ServerAzureADOnlyAuthentications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeletesAzureActiveDirectoryOnlyAuthenticationObject() SqlServerAzureADOnlyAuthenticationResource sqlServerAzureADOnlyAuthentication = client.GetSqlServerAzureADOnlyAuthenticationResource(sqlServerAzureADOnlyAuthenticationResourceId); // invoke the operation - await sqlServerAzureADOnlyAuthentication.DeleteAsync(WaitUntil.Completed); + SqlServerAzureADOnlyAuthenticationData data = new SqlServerAzureADOnlyAuthenticationData + { + IsAzureADOnlyAuthenticationEnabled = false, + }; + ArmOperation lro = await sqlServerAzureADOnlyAuthentication.UpdateAsync(WaitUntil.Completed, data); + SqlServerAzureADOnlyAuthenticationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerAzureADOnlyAuthenticationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerBlobAuditingPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerBlobAuditingPolicyCollection.cs index 38d5518bae45a..791490d694934 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerBlobAuditingPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerBlobAuditingPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerBlobAuditingPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAuditingSettingsOfAServer() + public async Task CreateOrUpdate_UpdateAServerSBlobAuditingPolicyWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAuditingSettingsList.json - // this example is just showing the usage of "ServerBlobAuditingPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingCreateMax.json + // this example is just showing the usage of "ServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,36 @@ public async Task GetAll_ListAuditingSettingsOfAServer() // get the collection of this SqlServerBlobAuditingPolicyResource SqlServerBlobAuditingPolicyCollection collection = sqlServer.GetSqlServerBlobAuditingPolicies(); - // invoke the operation and iterate over the result - await foreach (SqlServerBlobAuditingPolicyResource item in collection.GetAllAsync()) + // invoke the operation + BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; + SqlServerBlobAuditingPolicyData data = new SqlServerBlobAuditingPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerBlobAuditingPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + RetentionDays = 6, + AuditActionsAndGroups = { "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP" }, + IsStorageSecondaryKeyInUse = false, + IsAzureMonitorTargetEnabled = true, + QueueDelayMs = 4000, + State = BlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + SqlServerBlobAuditingPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerSBlobAuditingPolicy() + public async Task CreateOrUpdate_UpdateAServerSBlobAuditingPolicyWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingGet.json - // this example is just showing the usage of "ServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingCreateMin.json + // this example is just showing the usage of "ServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +88,14 @@ public async Task Get_GetAServerSBlobAuditingPolicy() // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - SqlServerBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); + SqlServerBlobAuditingPolicyData data = new SqlServerBlobAuditingPolicyData + { + State = BlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); + SqlServerBlobAuditingPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +106,7 @@ public async Task Get_GetAServerSBlobAuditingPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerSBlobAuditingPolicy() + public async Task Get_GetAServerSBlobAuditingPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingGet.json // this example is just showing the usage of "ServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +129,21 @@ public async Task Exists_GetAServerSBlobAuditingPolicy() // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - bool result = await collection.ExistsAsync(blobAuditingPolicyName); + SqlServerBlobAuditingPolicyResource result = await collection.GetAsync(blobAuditingPolicyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerSBlobAuditingPolicy() + public async Task GetAll_ListAuditingSettingsOfAServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingGet.json - // this example is just showing the usage of "ServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerAuditingSettingsList.json + // this example is just showing the usage of "ServerBlobAuditingPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +161,25 @@ public async Task GetIfExists_GetAServerSBlobAuditingPolicy() // get the collection of this SqlServerBlobAuditingPolicyResource SqlServerBlobAuditingPolicyCollection collection = sqlServer.GetSqlServerBlobAuditingPolicies(); - // invoke the operation - BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); - SqlServerBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerBlobAuditingPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerBlobAuditingPolicyData resourceData = result.Data; + SqlServerBlobAuditingPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSBlobAuditingPolicyWithAllParameters() + public async Task Exists_GetAServerSBlobAuditingPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingCreateMax.json - // this example is just showing the usage of "ServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingGet.json + // this example is just showing the usage of "ServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,37 +199,17 @@ public async Task CreateOrUpdate_UpdateAServerSBlobAuditingPolicyWithAllParamete // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - SqlServerBlobAuditingPolicyData data = new SqlServerBlobAuditingPolicyData() - { - RetentionDays = 6, - AuditActionsAndGroups = -{ -"SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP","FAILED_DATABASE_AUTHENTICATION_GROUP","BATCH_COMPLETED_GROUP" -}, - IsStorageSecondaryKeyInUse = false, - IsAzureMonitorTargetEnabled = true, - QueueDelayMs = 4000, - State = BlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - SqlServerBlobAuditingPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(blobAuditingPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSBlobAuditingPolicyWithMinimalParameters() + public async Task GetIfExists_GetAServerSBlobAuditingPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingCreateMin.json - // this example is just showing the usage of "ServerBlobAuditingPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-11-01-preview/examples/ServerBlobAuditingGet.json + // this example is just showing the usage of "ServerBlobAuditingPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -233,20 +229,21 @@ public async Task CreateOrUpdate_UpdateAServerSBlobAuditingPolicyWithMinimalPara // invoke the operation BlobAuditingPolicyName blobAuditingPolicyName = BlobAuditingPolicyName.Default; - SqlServerBlobAuditingPolicyData data = new SqlServerBlobAuditingPolicyData() - { - State = BlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blobAuditingPolicyName, data); - SqlServerBlobAuditingPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(blobAuditingPolicyName); + SqlServerBlobAuditingPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerBlobAuditingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerBlobAuditingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerBlobAuditingPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerBlobAuditingPolicyResource.cs index 844cc92368a4d..07c5bea9c0df3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerBlobAuditingPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerBlobAuditingPolicyResource.cs @@ -69,13 +69,10 @@ public async Task Update_UpdateAServerSBlobAuditingPolicyWithAllParameters() SqlServerBlobAuditingPolicyResource sqlServerBlobAuditingPolicy = client.GetSqlServerBlobAuditingPolicyResource(sqlServerBlobAuditingPolicyResourceId); // invoke the operation - SqlServerBlobAuditingPolicyData data = new SqlServerBlobAuditingPolicyData() + SqlServerBlobAuditingPolicyData data = new SqlServerBlobAuditingPolicyData { RetentionDays = 6, - AuditActionsAndGroups = -{ -"SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP","FAILED_DATABASE_AUTHENTICATION_GROUP","BATCH_COMPLETED_GROUP" -}, + AuditActionsAndGroups = { "SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP", "FAILED_DATABASE_AUTHENTICATION_GROUP", "BATCH_COMPLETED_GROUP" }, IsStorageSecondaryKeyInUse = false, IsAzureMonitorTargetEnabled = true, QueueDelayMs = 4000, @@ -116,7 +113,7 @@ public async Task Update_UpdateAServerSBlobAuditingPolicyWithMinimalParameters() SqlServerBlobAuditingPolicyResource sqlServerBlobAuditingPolicy = client.GetSqlServerBlobAuditingPolicyResource(sqlServerBlobAuditingPolicyResourceId); // invoke the operation - SqlServerBlobAuditingPolicyData data = new SqlServerBlobAuditingPolicyData() + SqlServerBlobAuditingPolicyData data = new SqlServerBlobAuditingPolicyData { State = BlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCollection.cs index acffb8da6a183..a882e4c12aded 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SqlServerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListServersByResourceGroup() + public async Task CreateOrUpdate_CreateServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerListByResourceGroup.json - // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerCreate.json + // this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,40 @@ public async Task GetAll_ListServersByResourceGroup() // get the collection of this SqlServerResource SqlServerCollection collection = resourceGroupResource.GetSqlServers(); - // invoke the operation and iterate over the result - await foreach (SqlServerResource item in collection.GetAllAsync()) + // invoke the operation + string serverName = "sqlcrudtest-4645"; + SqlServerData data = new SqlServerData(new AzureLocation("Japan East")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AdministratorLogin = "dummylogin", + AdministratorLoginPassword = "PLACEHOLDER", + PublicNetworkAccess = ServerNetworkAccessFlag.Enabled, + Administrators = new ServerExternalAdministrator + { + PrincipalType = SqlServerPrincipalType.User, + Login = "bob@contoso.com", + Sid = Guid.Parse("00000011-1111-2222-2222-123456789111"), + TenantId = Guid.Parse("00000011-1111-2222-2222-123456789111"), + IsAzureADOnlyAuthenticationEnabled = true, + }, + RestrictOutboundNetworkAccess = ServerNetworkAccessFlag.Enabled, + IsIPv6Enabled = ServerNetworkAccessFlag.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); + SqlServerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListServersByResourceGroupWithExpandAdministratorsActivedirectory() + public async Task Get_GetServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerListByResourceGroupWithExpandEqualsAdministrators.json - // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,24 +89,22 @@ public async Task GetAll_ListServersByResourceGroupWithExpandAdministratorsActiv // get the collection of this SqlServerResource SqlServerCollection collection = resourceGroupResource.GetSqlServers(); - // invoke the operation and iterate over the result - await foreach (SqlServerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string serverName = "sqlcrudtest-4645"; + SqlServerResource result = await collection.GetAsync(serverName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServer() + public async Task Get_GetServerWithExpandAdministratorsActivedirectory() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGet.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGetWithExpandEqualsAdministrators.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -122,10 +135,10 @@ public async Task Get_GetServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetServer() + public async Task GetAll_ListServersByResourceGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerListByResourceGroup.json + // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,19 +155,25 @@ public async Task Exists_GetServer() // get the collection of this SqlServerResource SqlServerCollection collection = resourceGroupResource.GetSqlServers(); - // invoke the operation - string serverName = "sqlcrudtest-4645"; - bool result = await collection.ExistsAsync(serverName); + // invoke the operation and iterate over the result + await foreach (SqlServerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetServer() + public async Task GetAll_ListServersByResourceGroupWithExpandAdministratorsActivedirectory() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerListByResourceGroupWithExpandEqualsAdministrators.json + // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -171,30 +190,24 @@ public async Task GetIfExists_GetServer() // get the collection of this SqlServerResource SqlServerCollection collection = resourceGroupResource.GetSqlServers(); - // invoke the operation - string serverName = "sqlcrudtest-4645"; - NullableResponse response = await collection.GetIfExistsAsync(serverName); - SqlServerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerData resourceData = result.Data; + SqlServerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServerWithExpandAdministratorsActivedirectory() + public async Task Exists_GetServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGetWithExpandEqualsAdministrators.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGet.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -214,13 +227,9 @@ public async Task Get_GetServerWithExpandAdministratorsActivedirectory() // invoke the operation string serverName = "sqlcrudtest-4645"; - SqlServerResource result = await collection.GetAsync(serverName); + bool result = await collection.ExistsAsync(serverName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -254,9 +263,9 @@ public async Task Exists_GetServerWithExpandAdministratorsActivedirectory() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetServerWithExpandAdministratorsActivedirectory() + public async Task GetIfExists_GetServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGetWithExpandEqualsAdministrators.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGet.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -295,10 +304,10 @@ public async Task GetIfExists_GetServerWithExpandAdministratorsActivedirectory() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateServer() + public async Task GetIfExists_GetServerWithExpandAdministratorsActivedirectory() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerCreate.json - // this example is just showing the usage of "Servers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGetWithExpandEqualsAdministrators.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -317,30 +326,21 @@ public async Task CreateOrUpdate_CreateServer() // invoke the operation string serverName = "sqlcrudtest-4645"; - SqlServerData data = new SqlServerData(new AzureLocation("Japan East")) - { - AdministratorLogin = "dummylogin", - AdministratorLoginPassword = "PLACEHOLDER", - PublicNetworkAccess = ServerNetworkAccessFlag.Enabled, - Administrators = new ServerExternalAdministrator() - { - PrincipalType = SqlServerPrincipalType.User, - Login = "bob@contoso.com", - Sid = Guid.Parse("00000011-1111-2222-2222-123456789111"), - TenantId = Guid.Parse("00000011-1111-2222-2222-123456789111"), - IsAzureADOnlyAuthenticationEnabled = true, - }, - RestrictOutboundNetworkAccess = ServerNetworkAccessFlag.Enabled, - IsIPv6Enabled = ServerNetworkAccessFlag.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); - SqlServerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(serverName); + SqlServerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCommunicationLinkCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCommunicationLinkCollection.cs index abe7dbd4f7b27..a1ccc6899e69a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCommunicationLinkCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCommunicationLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlServerCommunicationLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerCommunicationLink() + public async Task CreateOrUpdate_CreateAServerCommunicationLink() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkGet.json - // this example is just showing the usage of "ServerCommunicationLinks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkCreateOrUpdate.json + // this example is just showing the usage of "ServerCommunicationLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetAServerCommunicationLink() // invoke the operation string communicationLinkName = "link1"; - SqlServerCommunicationLinkResource result = await collection.GetAsync(communicationLinkName); + SqlServerCommunicationLinkData data = new SqlServerCommunicationLinkData + { + PartnerServer = "sqldcrudtest-test", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationLinkName, data); + SqlServerCommunicationLinkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetAServerCommunicationLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerCommunicationLink() + public async Task Get_GetAServerCommunicationLink() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkGet.json // this example is just showing the usage of "ServerCommunicationLinks_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +79,21 @@ public async Task Exists_GetAServerCommunicationLink() // invoke the operation string communicationLinkName = "link1"; - bool result = await collection.ExistsAsync(communicationLinkName); + SqlServerCommunicationLinkResource result = await collection.GetAsync(communicationLinkName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerCommunicationLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerCommunicationLink() + public async Task GetAll_ListServerCommunicationLinks() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkGet.json - // this example is just showing the usage of "ServerCommunicationLinks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkList.json + // this example is just showing the usage of "ServerCommunicationLinks_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +111,25 @@ public async Task GetIfExists_GetAServerCommunicationLink() // get the collection of this SqlServerCommunicationLinkResource SqlServerCommunicationLinkCollection collection = sqlServer.GetSqlServerCommunicationLinks(); - // invoke the operation - string communicationLinkName = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(communicationLinkName); - SqlServerCommunicationLinkResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerCommunicationLinkResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerCommunicationLinkData resourceData = result.Data; + SqlServerCommunicationLinkData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAServerCommunicationLink() + public async Task Exists_GetAServerCommunicationLink() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkCreateOrUpdate.json - // this example is just showing the usage of "ServerCommunicationLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkGet.json + // this example is just showing the usage of "ServerCommunicationLinks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,26 +149,17 @@ public async Task CreateOrUpdate_CreateAServerCommunicationLink() // invoke the operation string communicationLinkName = "link1"; - SqlServerCommunicationLinkData data = new SqlServerCommunicationLinkData() - { - PartnerServer = "sqldcrudtest-test", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, communicationLinkName, data); - SqlServerCommunicationLinkResource result = lro.Value; + bool result = await collection.ExistsAsync(communicationLinkName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerCommunicationLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListServerCommunicationLinks() + public async Task GetIfExists_GetAServerCommunicationLink() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkList.json - // this example is just showing the usage of "ServerCommunicationLinks_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkGet.json + // this example is just showing the usage of "ServerCommunicationLinks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_ListServerCommunicationLinks() // get the collection of this SqlServerCommunicationLinkResource SqlServerCommunicationLinkCollection collection = sqlServer.GetSqlServerCommunicationLinks(); - // invoke the operation and iterate over the result - await foreach (SqlServerCommunicationLinkResource item in collection.GetAllAsync()) + // invoke the operation + string communicationLinkName = "link1"; + NullableResponse response = await collection.GetIfExistsAsync(communicationLinkName); + SqlServerCommunicationLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerCommunicationLinkData resourceData = item.Data; + SqlServerCommunicationLinkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCommunicationLinkResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCommunicationLinkResource.cs index b963f65c6840c..08918d97336eb 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCommunicationLinkResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerCommunicationLinkResource.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlServerCommunicationLinkResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAServerCommunicationLink() + public async Task Get_GetAServerCommunicationLink() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkDelete.json - // this example is just showing the usage of "ServerCommunicationLinks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkGet.json + // this example is just showing the usage of "ServerCommunicationLinks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task Delete_DeleteAServerCommunicationLink() SqlServerCommunicationLinkResource sqlServerCommunicationLink = client.GetSqlServerCommunicationLinkResource(sqlServerCommunicationLinkResourceId); // invoke the operation - await sqlServerCommunicationLink.DeleteAsync(WaitUntil.Completed); + SqlServerCommunicationLinkResource result = await sqlServerCommunicationLink.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerCommunicationLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerCommunicationLink() + public async Task Delete_DeleteAServerCommunicationLink() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkGet.json - // this example is just showing the usage of "ServerCommunicationLinks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01/examples/ServerCommunicationLinkDelete.json + // this example is just showing the usage of "ServerCommunicationLinks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +68,9 @@ public async Task Get_GetAServerCommunicationLink() SqlServerCommunicationLinkResource sqlServerCommunicationLink = client.GetSqlServerCommunicationLinkResource(sqlServerCommunicationLinkResourceId); // invoke the operation - SqlServerCommunicationLinkResource result = await sqlServerCommunicationLink.GetAsync(); + await sqlServerCommunicationLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerCommunicationLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -95,7 +95,7 @@ public async Task Update_CreateAServerCommunicationLink() SqlServerCommunicationLinkResource sqlServerCommunicationLink = client.GetSqlServerCommunicationLinkResource(sqlServerCommunicationLinkResourceId); // invoke the operation - SqlServerCommunicationLinkData data = new SqlServerCommunicationLinkData() + SqlServerCommunicationLinkData data = new SqlServerCommunicationLinkData { PartnerServer = "sqldcrudtest-test", }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerConnectionPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerConnectionPolicyCollection.cs index 8841a4e35c8e7..ed9ce77192730 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerConnectionPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerConnectionPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerConnectionPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAServerConnectionPolicy() + public async Task CreateOrUpdate_UpdatesAServerConnectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesGet.json - // this example is just showing the usage of "ServerConnectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesUpdate.json + // this example is just showing the usage of "ServerConnectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task Get_GetsAServerConnectionPolicy() // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "rgtest-12"; - string serverName = "servertest-6285"; + string resourceGroupName = "testrg"; + string serverName = "testserver"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); @@ -41,7 +41,12 @@ public async Task Get_GetsAServerConnectionPolicy() // invoke the operation ConnectionPolicyName connectionPolicyName = ConnectionPolicyName.Default; - SqlServerConnectionPolicyResource result = await collection.GetAsync(connectionPolicyName); + SqlServerConnectionPolicyData data = new SqlServerConnectionPolicyData + { + ConnectionType = ServerConnectionType.Redirect, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionPolicyName, data); + SqlServerConnectionPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetsAServerConnectionPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAServerConnectionPolicy() + public async Task Get_GetsAServerConnectionPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesGet.json // this example is just showing the usage of "ServerConnectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetsAServerConnectionPolicy() // invoke the operation ConnectionPolicyName connectionPolicyName = ConnectionPolicyName.Default; - bool result = await collection.ExistsAsync(connectionPolicyName); + SqlServerConnectionPolicyResource result = await collection.GetAsync(connectionPolicyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerConnectionPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAServerConnectionPolicy() + public async Task GetAll_ListsAServersConnectionPolicies() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesGet.json - // this example is just showing the usage of "ServerConnectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesList.json + // this example is just showing the usage of "ServerConnectionPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetsAServerConnectionPolicy() // get the collection of this SqlServerConnectionPolicyResource SqlServerConnectionPolicyCollection collection = sqlServer.GetSqlServerConnectionPolicies(); - // invoke the operation - ConnectionPolicyName connectionPolicyName = ConnectionPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(connectionPolicyName); - SqlServerConnectionPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerConnectionPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerConnectionPolicyData resourceData = result.Data; + SqlServerConnectionPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatesAServerConnectionPolicy() + public async Task Exists_GetsAServerConnectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesUpdate.json - // this example is just showing the usage of "ServerConnectionPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesGet.json + // this example is just showing the usage of "ServerConnectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,8 +140,8 @@ public async Task CreateOrUpdate_UpdatesAServerConnectionPolicy() // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "testrg"; - string serverName = "testserver"; + string resourceGroupName = "rgtest-12"; + string serverName = "servertest-6285"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_UpdatesAServerConnectionPolicy() // invoke the operation ConnectionPolicyName connectionPolicyName = ConnectionPolicyName.Default; - SqlServerConnectionPolicyData data = new SqlServerConnectionPolicyData() - { - ConnectionType = ServerConnectionType.Redirect, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionPolicyName, data); - SqlServerConnectionPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(connectionPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerConnectionPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsAServersConnectionPolicies() + public async Task GetIfExists_GetsAServerConnectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesList.json - // this example is just showing the usage of "ServerConnectionPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ServerConnectionPoliciesGet.json + // this example is just showing the usage of "ServerConnectionPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListsAServersConnectionPolicies() // get the collection of this SqlServerConnectionPolicyResource SqlServerConnectionPolicyCollection collection = sqlServer.GetSqlServerConnectionPolicies(); - // invoke the operation and iterate over the result - await foreach (SqlServerConnectionPolicyResource item in collection.GetAllAsync()) + // invoke the operation + ConnectionPolicyName connectionPolicyName = ConnectionPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(connectionPolicyName); + SqlServerConnectionPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerConnectionPolicyData resourceData = item.Data; + SqlServerConnectionPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerConnectionPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerConnectionPolicyResource.cs index d0ac6fcfd504c..66a433f426305 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerConnectionPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerConnectionPolicyResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdatesAServerConnectionPolicy() SqlServerConnectionPolicyResource sqlServerConnectionPolicy = client.GetSqlServerConnectionPolicyResource(sqlServerConnectionPolicyResourceId); // invoke the operation - SqlServerConnectionPolicyData data = new SqlServerConnectionPolicyData() + SqlServerConnectionPolicyData data = new SqlServerConnectionPolicyData { ConnectionType = ServerConnectionType.Redirect, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseReplicationLinkCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseReplicationLinkCollection.cs index 026ba4e1ea6f6..a1ad434409f49 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseReplicationLinkCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseReplicationLinkCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerDatabaseReplicationLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListReplicationLinksOnServerOnDatabase() + public async Task CreateOrUpdate_UpdatesReplicationLink() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkListByDatabase.json - // this example is just showing the usage of "ReplicationLinks_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkCreateOrUpdate.json + // this example is just showing the usage of "ReplicationLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,24 +33,27 @@ public async Task GetAll_ListReplicationLinksOnServerOnDatabase() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default"; string serverName = "sourcesvr"; - string databaseName = "tetha-db"; + string databaseName = "gamma-db"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // get the collection of this SqlServerDatabaseReplicationLinkResource SqlServerDatabaseReplicationLinkCollection collection = sqlDatabase.GetSqlServerDatabaseReplicationLinks(); - // invoke the operation and iterate over the result - await foreach (SqlServerDatabaseReplicationLinkResource item in collection.GetAllAsync()) + // invoke the operation + string linkId = "00000000-1111-2222-3333-666666666666"; + SqlServerDatabaseReplicationLinkData data = new SqlServerDatabaseReplicationLinkData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerDatabaseReplicationLinkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + LinkType = ReplicationLinkType.Standby, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkId, data); + SqlServerDatabaseReplicationLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerDatabaseReplicationLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +93,10 @@ public async Task Get_GetsTheReplicationLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheReplicationLink() + public async Task GetAll_ListReplicationLinksOnServerOnDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkGet.json - // this example is just showing the usage of "ReplicationLinks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkListByDatabase.json + // this example is just showing the usage of "ReplicationLinks_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,23 +108,29 @@ public async Task Exists_GetsTheReplicationLink() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "Default"; string serverName = "sourcesvr"; - string databaseName = "gamma-db"; + string databaseName = "tetha-db"; ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); // get the collection of this SqlServerDatabaseReplicationLinkResource SqlServerDatabaseReplicationLinkCollection collection = sqlDatabase.GetSqlServerDatabaseReplicationLinks(); - // invoke the operation - string linkId = "4891ca10-ebd0-47d7-9182-c722651780fb"; - bool result = await collection.ExistsAsync(linkId); + // invoke the operation and iterate over the result + await foreach (SqlServerDatabaseReplicationLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerDatabaseReplicationLinkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheReplicationLink() + public async Task Exists_GetsTheReplicationLink() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkGet.json // this example is just showing the usage of "ReplicationLinks_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +154,17 @@ public async Task GetIfExists_GetsTheReplicationLink() // invoke the operation string linkId = "4891ca10-ebd0-47d7-9182-c722651780fb"; - NullableResponse response = await collection.GetIfExistsAsync(linkId); - SqlServerDatabaseReplicationLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(linkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerDatabaseReplicationLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatesReplicationLink() + public async Task GetIfExists_GetsTheReplicationLink() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkCreateOrUpdate.json - // this example is just showing the usage of "ReplicationLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ReplicationLinkGet.json + // this example is just showing the usage of "ReplicationLinks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,19 +184,22 @@ public async Task CreateOrUpdate_UpdatesReplicationLink() SqlServerDatabaseReplicationLinkCollection collection = sqlDatabase.GetSqlServerDatabaseReplicationLinks(); // invoke the operation - string linkId = "00000000-1111-2222-3333-666666666666"; - SqlServerDatabaseReplicationLinkData data = new SqlServerDatabaseReplicationLinkData() - { - LinkType = ReplicationLinkType.Standby, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkId, data); - SqlServerDatabaseReplicationLinkResource result = lro.Value; + string linkId = "4891ca10-ebd0-47d7-9182-c722651780fb"; + NullableResponse response = await collection.GetIfExistsAsync(linkId); + SqlServerDatabaseReplicationLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerDatabaseReplicationLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerDatabaseReplicationLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseReplicationLinkResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseReplicationLinkResource.cs index 704aed6f4cf28..73b88991697ba 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseReplicationLinkResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseReplicationLinkResource.cs @@ -99,7 +99,7 @@ public async Task Update_UpdateReplicationLink() SqlServerDatabaseReplicationLinkResource sqlServerDatabaseReplicationLink = client.GetSqlServerDatabaseReplicationLinkResource(sqlServerDatabaseReplicationLinkResourceId); // invoke the operation - SqlServerDatabaseReplicationLinkPatch patch = new SqlServerDatabaseReplicationLinkPatch() + SqlServerDatabaseReplicationLinkPatch patch = new SqlServerDatabaseReplicationLinkPatch { LinkType = ReplicationLinkType.Standby, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseRestorePointCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseRestorePointCollection.cs index 0a0ab10484072..6a90f4cb3fefe 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseRestorePointCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDatabaseRestorePointCollection.cs @@ -15,6 +15,76 @@ namespace Azure.ResourceManager.Sql.Samples { public partial class Sample_SqlServerDatabaseRestorePointCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetsADatabaseRestorePoint() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRestorePointsGet.json + // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SqlDatabaseResource created on azure + // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testserver"; + string databaseName = "testDatabase"; + ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); + + // get the collection of this SqlServerDatabaseRestorePointResource + SqlServerDatabaseRestorePointCollection collection = sqlDatabase.GetSqlServerDatabaseRestorePoints(); + + // invoke the operation + string restorePointName = "131546477590000000"; + SqlServerDatabaseRestorePointResource result = await collection.GetAsync(restorePointName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerDatabaseRestorePointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetsADatawarehouseDatabaseRestorePoint() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DataWarehouseRestorePointsGet.json + // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SqlDatabaseResource created on azure + // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testserver"; + string databaseName = "testDatabase"; + ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); + SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); + + // get the collection of this SqlServerDatabaseRestorePointResource + SqlServerDatabaseRestorePointCollection collection = sqlDatabase.GetSqlServerDatabaseRestorePoints(); + + // invoke the operation + string restorePointName = "131546477590000000"; + SqlServerDatabaseRestorePointResource result = await collection.GetAsync(restorePointName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerDatabaseRestorePointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListDatabaseRestorePoints() @@ -91,7 +161,7 @@ public async Task GetAll_ListDatawarehouseDatabaseRestorePoints() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatabaseRestorePoint() + public async Task Exists_GetsADatabaseRestorePoint() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRestorePointsGet.json // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -115,20 +185,16 @@ public async Task Get_GetsADatabaseRestorePoint() // invoke the operation string restorePointName = "131546477590000000"; - SqlServerDatabaseRestorePointResource result = await collection.GetAsync(restorePointName); + bool result = await collection.ExistsAsync(restorePointName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerDatabaseRestorePointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsADatabaseRestorePoint() + public async Task Exists_GetsADatawarehouseDatabaseRestorePoint() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DatabaseRestorePointsGet.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DataWarehouseRestorePointsGet.json // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -198,72 +264,6 @@ public async Task GetIfExists_GetsADatabaseRestorePoint() } } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetsADatawarehouseDatabaseRestorePoint() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DataWarehouseRestorePointsGet.json - // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SqlDatabaseResource created on azure - // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testserver"; - string databaseName = "testDatabase"; - ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - - // get the collection of this SqlServerDatabaseRestorePointResource - SqlServerDatabaseRestorePointCollection collection = sqlDatabase.GetSqlServerDatabaseRestorePoints(); - - // invoke the operation - string restorePointName = "131546477590000000"; - SqlServerDatabaseRestorePointResource result = await collection.GetAsync(restorePointName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerDatabaseRestorePointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsADatawarehouseDatabaseRestorePoint() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DataWarehouseRestorePointsGet.json - // this example is just showing the usage of "RestorePoints_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SqlDatabaseResource created on azure - // for more information of creating SqlDatabaseResource, please refer to the document of SqlDatabaseResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testserver"; - string databaseName = "testDatabase"; - ResourceIdentifier sqlDatabaseResourceId = SqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName); - SqlDatabaseResource sqlDatabase = client.GetSqlDatabaseResource(sqlDatabaseResourceId); - - // get the collection of this SqlServerDatabaseRestorePointResource - SqlServerDatabaseRestorePointCollection collection = sqlDatabase.GetSqlServerDatabaseRestorePoints(); - - // invoke the operation - string restorePointName = "131546477590000000"; - bool result = await collection.ExistsAsync(restorePointName); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetIfExists_GetsADatawarehouseDatabaseRestorePoint() diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDevOpsAuditingSettingCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDevOpsAuditingSettingCollection.cs index f9e8c91d4fea2..e3cad5a840f54 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDevOpsAuditingSettingCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDevOpsAuditingSettingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerDevOpsAuditingSettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDevOpsAuditSettingsOfAServer() + public async Task CreateOrUpdate_UpdateAServerSDevOpsAuditSettingsWithAllParams() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditList.json - // this example is just showing the usage of "ServerDevOpsAuditSettings_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditCreateMax.json + // this example is just showing the usage of "ServerDevOpsAuditSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,32 @@ public async Task GetAll_ListDevOpsAuditSettingsOfAServer() // get the collection of this SqlServerDevOpsAuditingSettingResource SqlServerDevOpsAuditingSettingCollection collection = sqlServer.GetSqlServerDevOpsAuditingSettings(); - // invoke the operation and iterate over the result - await foreach (SqlServerDevOpsAuditingSettingResource item in collection.GetAllAsync()) + // invoke the operation + string devOpsAuditingSettingsName = "Default"; + SqlServerDevOpsAuditingSettingData data = new SqlServerDevOpsAuditingSettingData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerDevOpsAuditingSettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsAzureMonitorTargetEnabled = true, + State = BlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, devOpsAuditingSettingsName, data); + SqlServerDevOpsAuditingSettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerDevOpsAuditingSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerSDevOpsAuditSettings() + public async Task CreateOrUpdate_UpdateAServerSDevOpsAuditSettingsWithMinimalInput() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditGet.json - // this example is just showing the usage of "ServerDevOpsAuditSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditCreateMin.json + // this example is just showing the usage of "ServerDevOpsAuditSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +84,14 @@ public async Task Get_GetAServerSDevOpsAuditSettings() // invoke the operation string devOpsAuditingSettingsName = "Default"; - SqlServerDevOpsAuditingSettingResource result = await collection.GetAsync(devOpsAuditingSettingsName); + SqlServerDevOpsAuditingSettingData data = new SqlServerDevOpsAuditingSettingData + { + State = BlobAuditingPolicyState.Enabled, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, devOpsAuditingSettingsName, data); + SqlServerDevOpsAuditingSettingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +102,7 @@ public async Task Get_GetAServerSDevOpsAuditSettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerSDevOpsAuditSettings() + public async Task Get_GetAServerSDevOpsAuditSettings() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditGet.json // this example is just showing the usage of "ServerDevOpsAuditSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +125,21 @@ public async Task Exists_GetAServerSDevOpsAuditSettings() // invoke the operation string devOpsAuditingSettingsName = "Default"; - bool result = await collection.ExistsAsync(devOpsAuditingSettingsName); + SqlServerDevOpsAuditingSettingResource result = await collection.GetAsync(devOpsAuditingSettingsName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerDevOpsAuditingSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerSDevOpsAuditSettings() + public async Task GetAll_ListDevOpsAuditSettingsOfAServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditGet.json - // this example is just showing the usage of "ServerDevOpsAuditSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditList.json + // this example is just showing the usage of "ServerDevOpsAuditSettings_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +157,25 @@ public async Task GetIfExists_GetAServerSDevOpsAuditSettings() // get the collection of this SqlServerDevOpsAuditingSettingResource SqlServerDevOpsAuditingSettingCollection collection = sqlServer.GetSqlServerDevOpsAuditingSettings(); - // invoke the operation - string devOpsAuditingSettingsName = "Default"; - NullableResponse response = await collection.GetIfExistsAsync(devOpsAuditingSettingsName); - SqlServerDevOpsAuditingSettingResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerDevOpsAuditingSettingResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerDevOpsAuditingSettingData resourceData = result.Data; + SqlServerDevOpsAuditingSettingData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSDevOpsAuditSettingsWithAllParams() + public async Task Exists_GetAServerSDevOpsAuditSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditCreateMax.json - // this example is just showing the usage of "ServerDevOpsAuditSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditGet.json + // this example is just showing the usage of "ServerDevOpsAuditSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,30 +195,17 @@ public async Task CreateOrUpdate_UpdateAServerSDevOpsAuditSettingsWithAllParams( // invoke the operation string devOpsAuditingSettingsName = "Default"; - SqlServerDevOpsAuditingSettingData data = new SqlServerDevOpsAuditingSettingData() - { - IsAzureMonitorTargetEnabled = true, - State = BlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - StorageAccountSubscriptionId = Guid.Parse("00000000-1234-0000-5678-000000000000"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, devOpsAuditingSettingsName, data); - SqlServerDevOpsAuditingSettingResource result = lro.Value; + bool result = await collection.ExistsAsync(devOpsAuditingSettingsName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerDevOpsAuditingSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSDevOpsAuditSettingsWithMinimalInput() + public async Task GetIfExists_GetAServerSDevOpsAuditSettings() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditCreateMin.json - // this example is just showing the usage of "ServerDevOpsAuditSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-02-01-preview/examples/ServerDevOpsAuditGet.json + // this example is just showing the usage of "ServerDevOpsAuditSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,20 +225,21 @@ public async Task CreateOrUpdate_UpdateAServerSDevOpsAuditSettingsWithMinimalInp // invoke the operation string devOpsAuditingSettingsName = "Default"; - SqlServerDevOpsAuditingSettingData data = new SqlServerDevOpsAuditingSettingData() - { - State = BlobAuditingPolicyState.Enabled, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, devOpsAuditingSettingsName, data); - SqlServerDevOpsAuditingSettingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(devOpsAuditingSettingsName); + SqlServerDevOpsAuditingSettingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerDevOpsAuditingSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerDevOpsAuditingSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDevOpsAuditingSettingResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDevOpsAuditingSettingResource.cs index 0b555786e111c..077786abc8f81 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDevOpsAuditingSettingResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDevOpsAuditingSettingResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdateAServerSDevOpsAuditSettingsWithAllParams() SqlServerDevOpsAuditingSettingResource sqlServerDevOpsAuditingSetting = client.GetSqlServerDevOpsAuditingSettingResource(sqlServerDevOpsAuditingSettingResourceId); // invoke the operation - SqlServerDevOpsAuditingSettingData data = new SqlServerDevOpsAuditingSettingData() + SqlServerDevOpsAuditingSettingData data = new SqlServerDevOpsAuditingSettingData { IsAzureMonitorTargetEnabled = true, State = BlobAuditingPolicyState.Enabled, @@ -109,7 +109,7 @@ public async Task Update_UpdateAServerSDevOpsAuditSettingsWithMinimalInput() SqlServerDevOpsAuditingSettingResource sqlServerDevOpsAuditingSetting = client.GetSqlServerDevOpsAuditingSettingResource(sqlServerDevOpsAuditingSettingResourceId); // invoke the operation - SqlServerDevOpsAuditingSettingData data = new SqlServerDevOpsAuditingSettingData() + SqlServerDevOpsAuditingSettingData data = new SqlServerDevOpsAuditingSettingData { State = BlobAuditingPolicyState.Enabled, StorageEndpoint = "https://mystorage.blob.core.windows.net", diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDnsAliasCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDnsAliasCollection.cs index a0e6980869a63..57261d2debfaf 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDnsAliasCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDnsAliasCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlServerDnsAliasCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServerDNSAlias() + public async Task CreateOrUpdate_CreateServerDNSAlias() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasGet.json - // this example is just showing the usage of "ServerDnsAliases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasCreateOrUpdate.json + // this example is just showing the usage of "ServerDnsAliases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,8 @@ public async Task Get_GetServerDNSAlias() // invoke the operation string dnsAliasName = "dns-alias-name-1"; - SqlServerDnsAliasResource result = await collection.GetAsync(dnsAliasName); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dnsAliasName); + SqlServerDnsAliasResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +52,7 @@ public async Task Get_GetServerDNSAlias() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetServerDNSAlias() + public async Task Get_GetServerDNSAlias() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasGet.json // this example is just showing the usage of "ServerDnsAliases_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +75,21 @@ public async Task Exists_GetServerDNSAlias() // invoke the operation string dnsAliasName = "dns-alias-name-1"; - bool result = await collection.ExistsAsync(dnsAliasName); + SqlServerDnsAliasResource result = await collection.GetAsync(dnsAliasName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerDnsAliasData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetServerDNSAlias() + public async Task GetAll_ListServerDNSAliases() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasGet.json - // this example is just showing the usage of "ServerDnsAliases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasList.json + // this example is just showing the usage of "ServerDnsAliases_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +107,25 @@ public async Task GetIfExists_GetServerDNSAlias() // get the collection of this SqlServerDnsAliasResource SqlServerDnsAliasCollection collection = sqlServer.GetSqlServerDnsAliases(); - // invoke the operation - string dnsAliasName = "dns-alias-name-1"; - NullableResponse response = await collection.GetIfExistsAsync(dnsAliasName); - SqlServerDnsAliasResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerDnsAliasResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerDnsAliasData resourceData = result.Data; + SqlServerDnsAliasData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateServerDNSAlias() + public async Task Exists_GetServerDNSAlias() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasCreateOrUpdate.json - // this example is just showing the usage of "ServerDnsAliases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasGet.json + // this example is just showing the usage of "ServerDnsAliases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,22 +145,17 @@ public async Task CreateOrUpdate_CreateServerDNSAlias() // invoke the operation string dnsAliasName = "dns-alias-name-1"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dnsAliasName); - SqlServerDnsAliasResource result = lro.Value; + bool result = await collection.ExistsAsync(dnsAliasName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerDnsAliasData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListServerDNSAliases() + public async Task GetIfExists_GetServerDNSAlias() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasList.json - // this example is just showing the usage of "ServerDnsAliases_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasGet.json + // this example is just showing the usage of "ServerDnsAliases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_ListServerDNSAliases() // get the collection of this SqlServerDnsAliasResource SqlServerDnsAliasCollection collection = sqlServer.GetSqlServerDnsAliases(); - // invoke the operation and iterate over the result - await foreach (SqlServerDnsAliasResource item in collection.GetAllAsync()) + // invoke the operation + string dnsAliasName = "dns-alias-name-1"; + NullableResponse response = await collection.GetIfExistsAsync(dnsAliasName); + SqlServerDnsAliasResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerDnsAliasData resourceData = item.Data; + SqlServerDnsAliasData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDnsAliasResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDnsAliasResource.cs index 64b3eabb79cf7..35fd3f4898625 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDnsAliasResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerDnsAliasResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetServerDNSAlias() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateServerDNSAlias() + public async Task Delete_DeleteServerDNSAlias() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasCreateOrUpdate.json - // this example is just showing the usage of "ServerDnsAliases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasDelete.json + // this example is just showing the usage of "ServerDnsAliases_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,22 +69,17 @@ public async Task Update_CreateServerDNSAlias() SqlServerDnsAliasResource sqlServerDnsAlias = client.GetSqlServerDnsAliasResource(sqlServerDnsAliasResourceId); // invoke the operation - ArmOperation lro = await sqlServerDnsAlias.UpdateAsync(WaitUntil.Completed); - SqlServerDnsAliasResource result = lro.Value; + await sqlServerDnsAlias.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerDnsAliasData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteServerDNSAlias() + public async Task Update_CreateServerDNSAlias() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasDelete.json - // this example is just showing the usage of "ServerDnsAliases_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerDnsAliasCreateOrUpdate.json + // this example is just showing the usage of "ServerDnsAliases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +96,14 @@ public async Task Delete_DeleteServerDNSAlias() SqlServerDnsAliasResource sqlServerDnsAlias = client.GetSqlServerDnsAliasResource(sqlServerDnsAliasResourceId); // invoke the operation - await sqlServerDnsAlias.DeleteAsync(WaitUntil.Completed); + ArmOperation lro = await sqlServerDnsAlias.UpdateAsync(WaitUntil.Completed); + SqlServerDnsAliasResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerDnsAliasData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobAgentCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobAgentCollection.cs index 0960f4c0eb653..668d2ab4ffe72 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobAgentCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobAgentCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlServerJobAgentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListJobAgentsInAServer() + public async Task CreateOrUpdate_CreateOrUpdateAJobAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobAgentsByServer.json - // this example is just showing the usage of "JobAgents_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobAgent.json + // this example is just showing the usage of "JobAgents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ListJobAgentsInAServer() // get the collection of this SqlServerJobAgentResource SqlServerJobAgentCollection collection = sqlServer.GetSqlServerJobAgents(); - // invoke the operation and iterate over the result - await foreach (SqlServerJobAgentResource item in collection.GetAllAsync()) + // invoke the operation + string jobAgentName = "agent1"; + SqlServerJobAgentData data = new SqlServerJobAgentData(new AzureLocation("southeastasia")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobAgentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/databases/db1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobAgentName, data); + SqlServerJobAgentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobAgentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetAJobAgent() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAJobAgent() + public async Task GetAll_ListJobAgentsInAServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobAgent.json - // this example is just showing the usage of "JobAgents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobAgentsByServer.json + // this example is just showing the usage of "JobAgents_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_GetAJobAgent() // get the collection of this SqlServerJobAgentResource SqlServerJobAgentCollection collection = sqlServer.GetSqlServerJobAgents(); - // invoke the operation - string jobAgentName = "agent1"; - bool result = await collection.ExistsAsync(jobAgentName); + // invoke the operation and iterate over the result + await foreach (SqlServerJobAgentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobAgentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAJobAgent() + public async Task Exists_GetAJobAgent() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobAgent.json // this example is just showing the usage of "JobAgents_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_GetAJobAgent() // invoke the operation string jobAgentName = "agent1"; - NullableResponse response = await collection.GetIfExistsAsync(jobAgentName); - SqlServerJobAgentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(jobAgentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobAgentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAJobAgent() + public async Task GetIfExists_GetAJobAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobAgent.json - // this example is just showing the usage of "JobAgents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobAgent.json + // this example is just showing the usage of "JobAgents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAJobAgent() // invoke the operation string jobAgentName = "agent1"; - SqlServerJobAgentData data = new SqlServerJobAgentData(new AzureLocation("southeastasia")) - { - DatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/databases/db1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobAgentName, data); - SqlServerJobAgentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(jobAgentName); + SqlServerJobAgentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobAgentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobAgentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobAgentResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobAgentResource.cs index 8feb9872600ab..060ccb336f9ed 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobAgentResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobAgentResource.cs @@ -96,11 +96,11 @@ public async Task Update_UpdateAJobAgentSTags() SqlServerJobAgentResource sqlServerJobAgent = client.GetSqlServerJobAgentResource(sqlServerJobAgentResourceId); // invoke the operation - SqlServerJobAgentPatch patch = new SqlServerJobAgentPatch() + SqlServerJobAgentPatch patch = new SqlServerJobAgentPatch { Tags = { -["mytag1"] = "myvalue1", +["mytag1"] = "myvalue1" }, }; ArmOperation lro = await sqlServerJobAgent.UpdateAsync(WaitUntil.Completed, patch); @@ -135,7 +135,7 @@ public async Task GetJobExecutionsByAgent_ListAllJobExecutionsInAJobAgentWithFil SqlServerJobAgentResource sqlServerJobAgent = client.GetSqlServerJobAgentResource(sqlServerJobAgentResourceId); // invoke the operation and iterate over the result - SqlServerJobAgentResourceGetJobExecutionsByAgentOptions options = new SqlServerJobAgentResourceGetJobExecutionsByAgentOptions() { CreateTimeMin = DateTimeOffset.Parse("2017-03-21T19:00:00Z"), CreateTimeMax = DateTimeOffset.Parse("2017-03-21T19:05:00Z"), EndTimeMin = DateTimeOffset.Parse("2017-03-21T19:20:00Z"), EndTimeMax = DateTimeOffset.Parse("2017-03-21T19:25:00Z"), IsActive = false }; + SqlServerJobAgentResourceGetJobExecutionsByAgentOptions options = new SqlServerJobAgentResourceGetJobExecutionsByAgentOptions { CreateTimeMin = DateTimeOffset.Parse("2017-03-21T19:00:00Z"), CreateTimeMax = DateTimeOffset.Parse("2017-03-21T19:05:00Z"), EndTimeMin = DateTimeOffset.Parse("2017-03-21T19:20:00Z"), EndTimeMax = DateTimeOffset.Parse("2017-03-21T19:25:00Z"), IsActive = false }; await foreach (SqlServerJobExecutionResource item in sqlServerJobAgent.GetJobExecutionsByAgentAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well @@ -170,7 +170,7 @@ public async Task GetJobExecutionsByAgent_ListAllJobExecutionsInAJobAgent() SqlServerJobAgentResource sqlServerJobAgent = client.GetSqlServerJobAgentResource(sqlServerJobAgentResourceId); // invoke the operation and iterate over the result - SqlServerJobAgentResourceGetJobExecutionsByAgentOptions options = new SqlServerJobAgentResourceGetJobExecutionsByAgentOptions() { }; + SqlServerJobAgentResourceGetJobExecutionsByAgentOptions options = new SqlServerJobAgentResourceGetJobExecutionsByAgentOptions(); await foreach (SqlServerJobExecutionResource item in sqlServerJobAgent.GetJobExecutionsByAgentAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCollection.cs index 967365ca9056e..679df4da2a252 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SqlServerJobCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListJobsInAJobAgent() + public async Task CreateOrUpdate_CreateAJobWithAllPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobsByAgent.json - // this example is just showing the usage of "Jobs_ListByAgent" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobMax.json + // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,36 @@ public async Task GetAll_ListJobsInAJobAgent() // get the collection of this SqlServerJobResource SqlServerJobCollection collection = sqlServerJobAgent.GetSqlServerJobs(); - // invoke the operation and iterate over the result - await foreach (SqlServerJobResource item in collection.GetAllAsync()) + // invoke the operation + string jobName = "job1"; + SqlServerJobData data = new SqlServerJobData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "my favourite job", + Schedule = new SqlServerJobSchedule + { + StartOn = DateTimeOffset.Parse("2015-09-24T18:30:01Z"), + EndOn = DateTimeOffset.Parse("2015-09-24T23:59:59Z"), + ScheduleType = SqlServerJobScheduleType.Recurring, + IsEnabled = true, + Interval = XmlConvert.ToTimeSpan("PT5M"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); + SqlServerJobResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAJob() + public async Task CreateOrUpdate_CreateAJobWithDefaultProperties() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJob.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobMin.json + // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,7 +91,9 @@ public async Task Get_GetAJob() // invoke the operation string jobName = "job1"; - SqlServerJobResource result = await collection.GetAsync(jobName); + SqlServerJobData data = new SqlServerJobData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); + SqlServerJobResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -91,7 +104,7 @@ public async Task Get_GetAJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAJob() + public async Task Get_GetAJob() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJob.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. @@ -115,17 +128,21 @@ public async Task Exists_GetAJob() // invoke the operation string jobName = "job1"; - bool result = await collection.ExistsAsync(jobName); + SqlServerJobResource result = await collection.GetAsync(jobName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAJob() + public async Task GetAll_ListJobsInAJobAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJob.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobsByAgent.json + // this example is just showing the usage of "Jobs_ListByAgent" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,31 +161,25 @@ public async Task GetIfExists_GetAJob() // get the collection of this SqlServerJobResource SqlServerJobCollection collection = sqlServerJobAgent.GetSqlServerJobs(); - // invoke the operation - string jobName = "job1"; - NullableResponse response = await collection.GetIfExistsAsync(jobName); - SqlServerJobResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerJobResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerJobData resourceData = result.Data; + SqlServerJobData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAJobWithAllPropertiesSpecified() + public async Task Exists_GetAJob() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobMax.json - // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJob.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,34 +200,17 @@ public async Task CreateOrUpdate_CreateAJobWithAllPropertiesSpecified() // invoke the operation string jobName = "job1"; - SqlServerJobData data = new SqlServerJobData() - { - Description = "my favourite job", - Schedule = new SqlServerJobSchedule() - { - StartOn = DateTimeOffset.Parse("2015-09-24T18:30:01Z"), - EndOn = DateTimeOffset.Parse("2015-09-24T23:59:59Z"), - ScheduleType = SqlServerJobScheduleType.Recurring, - IsEnabled = true, - Interval = XmlConvert.ToTimeSpan("PT5M"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); - SqlServerJobResource result = lro.Value; + bool result = await collection.ExistsAsync(jobName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAJobWithDefaultProperties() + public async Task GetIfExists_GetAJob() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobMin.json - // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJob.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -237,15 +231,21 @@ public async Task CreateOrUpdate_CreateAJobWithDefaultProperties() // invoke the operation string jobName = "job1"; - SqlServerJobData data = new SqlServerJobData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); - SqlServerJobResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(jobName); + SqlServerJobResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCredentialCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCredentialCollection.cs index 0ff9d4f1e5cb1..94b57061b95ee 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCredentialCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCredentialCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlServerJobCredentialCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCredentialsInAJobAgent() + public async Task CreateOrUpdate_CreateOrUpdateACredential() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobCredentialsByAgent.json - // this example is just showing the usage of "JobCredentials_ListByAgent" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobCredential.json + // this example is just showing the usage of "JobCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ListCredentialsInAJobAgent() // get the collection of this SqlServerJobCredentialResource SqlServerJobCredentialCollection collection = sqlServerJobAgent.GetSqlServerJobCredentials(); - // invoke the operation and iterate over the result - await foreach (SqlServerJobCredentialResource item in collection.GetAllAsync()) + // invoke the operation + string credentialName = "cred1"; + SqlServerJobCredentialData data = new SqlServerJobCredentialData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobCredentialData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Username = "myuser", + Password = "", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, credentialName, data); + SqlServerJobCredentialResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +93,10 @@ public async Task Get_GetACredential() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACredential() + public async Task GetAll_ListCredentialsInAJobAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobCredential.json - // this example is just showing the usage of "JobCredentials_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobCredentialsByAgent.json + // this example is just showing the usage of "JobCredentials_ListByAgent" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +115,22 @@ public async Task Exists_GetACredential() // get the collection of this SqlServerJobCredentialResource SqlServerJobCredentialCollection collection = sqlServerJobAgent.GetSqlServerJobCredentials(); - // invoke the operation - string credentialName = "cred1"; - bool result = await collection.ExistsAsync(credentialName); + // invoke the operation and iterate over the result + await foreach (SqlServerJobCredentialResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobCredentialData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACredential() + public async Task Exists_GetACredential() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobCredential.json // this example is just showing the usage of "JobCredentials_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +154,17 @@ public async Task GetIfExists_GetACredential() // invoke the operation string credentialName = "cred1"; - NullableResponse response = await collection.GetIfExistsAsync(credentialName); - SqlServerJobCredentialResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(credentialName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateACredential() + public async Task GetIfExists_GetACredential() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobCredential.json - // this example is just showing the usage of "JobCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobCredential.json + // this example is just showing the usage of "JobCredentials_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,19 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateACredential() // invoke the operation string credentialName = "cred1"; - SqlServerJobCredentialData data = new SqlServerJobCredentialData() - { - Username = "myuser", - Password = "", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, credentialName, data); - SqlServerJobCredentialResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(credentialName); + SqlServerJobCredentialResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCredentialResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCredentialResource.cs index cbda0ea691070..7f30c65dc8550 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCredentialResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobCredentialResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetACredential() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateACredential() + public async Task Delete_DeleteACredential() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobCredential.json - // this example is just showing the usage of "JobCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobCredential.json + // this example is just showing the usage of "JobCredentials_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,27 +70,17 @@ public async Task Update_CreateOrUpdateACredential() SqlServerJobCredentialResource sqlServerJobCredential = client.GetSqlServerJobCredentialResource(sqlServerJobCredentialResourceId); // invoke the operation - SqlServerJobCredentialData data = new SqlServerJobCredentialData() - { - Username = "myuser", - Password = "", - }; - ArmOperation lro = await sqlServerJobCredential.UpdateAsync(WaitUntil.Completed, data); - SqlServerJobCredentialResource result = lro.Value; + await sqlServerJobCredential.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACredential() + public async Task Update_CreateOrUpdateACredential() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobCredential.json - // this example is just showing the usage of "JobCredentials_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobCredential.json + // this example is just showing the usage of "JobCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +98,19 @@ public async Task Delete_DeleteACredential() SqlServerJobCredentialResource sqlServerJobCredential = client.GetSqlServerJobCredentialResource(sqlServerJobCredentialResourceId); // invoke the operation - await sqlServerJobCredential.DeleteAsync(WaitUntil.Completed); + SqlServerJobCredentialData data = new SqlServerJobCredentialData + { + Username = "myuser", + Password = "", + }; + ArmOperation lro = await sqlServerJobCredential.UpdateAsync(WaitUntil.Completed, data); + SqlServerJobCredentialResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionCollection.cs index c6bf51a016180..41ac09f55055b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerJobExecutionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAJobSExecutions() + public async Task CreateOrUpdate_CreateJobExecution() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionsByJob.json - // this example is just showing the usage of "JobExecutions_ListByJob" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobExecution.json + // this example is just showing the usage of "JobExecutions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,18 +41,16 @@ public async Task GetAll_ListAJobSExecutions() // get the collection of this SqlServerJobExecutionResource SqlServerJobExecutionCollection collection = sqlServerJob.GetSqlServerJobExecutions(); - // invoke the operation and iterate over the result - SqlServerJobExecutionCollectionGetAllOptions options = new SqlServerJobExecutionCollectionGetAllOptions() { }; - await foreach (SqlServerJobExecutionResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobExecutionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + Guid jobExecutionId = Guid.Parse("5A86BF65-43AC-F258-2524-9E92992F97CA"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobExecutionId); + SqlServerJobExecutionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobExecutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -93,10 +91,10 @@ public async Task Get_GetAJobExecution() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAJobExecution() + public async Task GetAll_ListAJobSExecutions() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecution.json - // this example is just showing the usage of "JobExecutions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionsByJob.json + // this example is just showing the usage of "JobExecutions_ListByJob" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,19 +114,26 @@ public async Task Exists_GetAJobExecution() // get the collection of this SqlServerJobExecutionResource SqlServerJobExecutionCollection collection = sqlServerJob.GetSqlServerJobExecutions(); - // invoke the operation - Guid jobExecutionId = Guid.Parse("5A86BF65-43AC-F258-2524-9E92992F97CA"); - bool result = await collection.ExistsAsync(jobExecutionId); + // invoke the operation and iterate over the result + SqlServerJobExecutionCollectionGetAllOptions options = new SqlServerJobExecutionCollectionGetAllOptions(); + await foreach (SqlServerJobExecutionResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobExecutionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAJobExecution() + public async Task GetJobTargetExecutions_ListJobStepTargetExecutions() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecution.json - // this example is just showing the usage of "JobExecutions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionTargetsByExecution.json + // this example is just showing the usage of "JobTargetExecutions_ListByJobExecution" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,31 +153,27 @@ public async Task GetIfExists_GetAJobExecution() // get the collection of this SqlServerJobExecutionResource SqlServerJobExecutionCollection collection = sqlServerJob.GetSqlServerJobExecutions(); - // invoke the operation + // invoke the operation and iterate over the result Guid jobExecutionId = Guid.Parse("5A86BF65-43AC-F258-2524-9E92992F97CA"); - NullableResponse response = await collection.GetIfExistsAsync(jobExecutionId); - SqlServerJobExecutionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + SqlServerJobExecutionCollectionGetJobTargetExecutionsOptions options = new SqlServerJobExecutionCollectionGetJobTargetExecutionsOptions(jobExecutionId); + await foreach (SqlServerJobExecutionStepTargetResource item in collection.GetJobTargetExecutionsAsync(options)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerJobExecutionData resourceData = result.Data; + SqlServerJobExecutionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateJobExecution() + public async Task Exists_GetAJobExecution() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobExecution.json - // this example is just showing the usage of "JobExecutions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecution.json + // this example is just showing the usage of "JobExecutions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -194,22 +195,17 @@ public async Task CreateOrUpdate_CreateJobExecution() // invoke the operation Guid jobExecutionId = Guid.Parse("5A86BF65-43AC-F258-2524-9E92992F97CA"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobExecutionId); - SqlServerJobExecutionResource result = lro.Value; + bool result = await collection.ExistsAsync(jobExecutionId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobExecutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetJobTargetExecutions_ListJobStepTargetExecutions() + public async Task GetIfExists_GetAJobExecution() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionTargetsByExecution.json - // this example is just showing the usage of "JobTargetExecutions_ListByJobExecution" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecution.json + // this example is just showing the usage of "JobExecutions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -229,18 +225,23 @@ public async Task GetJobTargetExecutions_ListJobStepTargetExecutions() // get the collection of this SqlServerJobExecutionResource SqlServerJobExecutionCollection collection = sqlServerJob.GetSqlServerJobExecutions(); - // invoke the operation and iterate over the result - SqlServerJobExecutionCollectionGetJobTargetExecutionsOptions options = new SqlServerJobExecutionCollectionGetJobTargetExecutionsOptions(jobExecutionId: Guid.Parse("5A86BF65-43AC-F258-2524-9E92992F97CA")) { }; - await foreach (SqlServerJobExecutionStepTargetResource item in collection.GetJobTargetExecutionsAsync(options)) + // invoke the operation + Guid jobExecutionId = Guid.Parse("5A86BF65-43AC-F258-2524-9E92992F97CA"); + NullableResponse response = await collection.GetIfExistsAsync(jobExecutionId); + SqlServerJobExecutionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerJobExecutionData resourceData = item.Data; + SqlServerJobExecutionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionResource.cs index ff7f177f15e7e..18e562fe39c8b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlServerJobExecutionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Cancel_CancelAJobExecution() + public async Task Get_GetAJobExecution() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CancelJobExecution.json - // this example is just showing the usage of "JobExecutions_Cancel" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecution.json + // this example is just showing the usage of "JobExecutions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Cancel_CancelAJobExecution() SqlServerJobExecutionResource sqlServerJobExecution = client.GetSqlServerJobExecutionResource(sqlServerJobExecutionResourceId); // invoke the operation - await sqlServerJobExecution.CancelAsync(); + SqlServerJobExecutionResource result = await sqlServerJobExecution.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobExecutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAJobExecution() + public async Task Update_CreateJobExecution() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecution.json - // this example is just showing the usage of "JobExecutions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobExecution.json + // this example is just showing the usage of "JobExecutions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,7 +72,8 @@ public async Task Get_GetAJobExecution() SqlServerJobExecutionResource sqlServerJobExecution = client.GetSqlServerJobExecutionResource(sqlServerJobExecutionResourceId); // invoke the operation - SqlServerJobExecutionResource result = await sqlServerJobExecution.GetAsync(); + ArmOperation lro = await sqlServerJobExecution.UpdateAsync(WaitUntil.Completed); + SqlServerJobExecutionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -79,10 +84,10 @@ public async Task Get_GetAJobExecution() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateJobExecution() + public async Task Cancel_CancelAJobExecution() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobExecution.json - // this example is just showing the usage of "JobExecutions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CancelJobExecution.json + // this example is just showing the usage of "JobExecutions_Cancel" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,14 +106,9 @@ public async Task Update_CreateJobExecution() SqlServerJobExecutionResource sqlServerJobExecution = client.GetSqlServerJobExecutionResource(sqlServerJobExecutionResourceId); // invoke the operation - ArmOperation lro = await sqlServerJobExecution.UpdateAsync(WaitUntil.Completed); - SqlServerJobExecutionResource result = lro.Value; + await sqlServerJobExecution.CancelAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobExecutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionStepCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionStepCollection.cs index 1994f3c54c65e..5faaf765d2f9d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionStepCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionStepCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerJobExecutionStepCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListJobStepExecutions() + public async Task Get_GetAJobStepExecution() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionSteps.json - // this example is just showing the usage of "JobStepExecutions_ListByJobExecution" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecutionStep.json + // this example is just showing the usage of "JobStepExecutions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,26 +42,23 @@ public async Task GetAll_ListJobStepExecutions() // get the collection of this SqlServerJobExecutionStepResource SqlServerJobExecutionStepCollection collection = sqlServerJobExecution.GetSqlServerJobExecutionSteps(); - // invoke the operation and iterate over the result - SqlServerJobExecutionStepCollectionGetAllOptions options = new SqlServerJobExecutionStepCollectionGetAllOptions() { }; - await foreach (SqlServerJobExecutionStepResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobExecutionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string stepName = "step1"; + SqlServerJobExecutionStepResource result = await collection.GetAsync(stepName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobExecutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAJobStepExecution() + public async Task GetAll_ListJobStepExecutions() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecutionStep.json - // this example is just showing the usage of "JobStepExecutions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionSteps.json + // this example is just showing the usage of "JobStepExecutions_ListByJobExecution" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -82,15 +79,18 @@ public async Task Get_GetAJobStepExecution() // get the collection of this SqlServerJobExecutionStepResource SqlServerJobExecutionStepCollection collection = sqlServerJobExecution.GetSqlServerJobExecutionSteps(); - // invoke the operation - string stepName = "step1"; - SqlServerJobExecutionStepResource result = await collection.GetAsync(stepName); + // invoke the operation and iterate over the result + SqlServerJobExecutionStepCollectionGetAllOptions options = new SqlServerJobExecutionStepCollectionGetAllOptions(); + await foreach (SqlServerJobExecutionStepResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobExecutionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobExecutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionStepTargetCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionStepTargetCollection.cs index 3923aa8c93038..843d4f8d88671 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionStepTargetCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobExecutionStepTargetCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerJobExecutionStepTargetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListJobStepTargetExecutions() + public async Task Get_GetAJobStepTargetExecution() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionTargetsByStep.json - // this example is just showing the usage of "JobTargetExecutions_ListByStep" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecutionTarget.json + // this example is just showing the usage of "JobTargetExecutions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,26 +43,23 @@ public async Task GetAll_ListJobStepTargetExecutions() // get the collection of this SqlServerJobExecutionStepTargetResource SqlServerJobExecutionStepTargetCollection collection = sqlServerJobExecutionStep.GetSqlServerJobExecutionStepTargets(); - // invoke the operation and iterate over the result - SqlServerJobExecutionStepTargetCollectionGetAllOptions options = new SqlServerJobExecutionStepTargetCollectionGetAllOptions() { }; - await foreach (SqlServerJobExecutionStepTargetResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobExecutionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + Guid targetId = Guid.Parse("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); + SqlServerJobExecutionStepTargetResource result = await collection.GetAsync(targetId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobExecutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAJobStepTargetExecution() + public async Task GetAll_ListJobStepTargetExecutions() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobExecutionTarget.json - // this example is just showing the usage of "JobTargetExecutions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobExecutionTargetsByStep.json + // this example is just showing the usage of "JobTargetExecutions_ListByStep" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -84,15 +81,18 @@ public async Task Get_GetAJobStepTargetExecution() // get the collection of this SqlServerJobExecutionStepTargetResource SqlServerJobExecutionStepTargetCollection collection = sqlServerJobExecutionStep.GetSqlServerJobExecutionStepTargets(); - // invoke the operation - Guid targetId = Guid.Parse("aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee"); - SqlServerJobExecutionStepTargetResource result = await collection.GetAsync(targetId); + // invoke the operation and iterate over the result + SqlServerJobExecutionStepTargetCollectionGetAllOptions options = new SqlServerJobExecutionStepTargetCollectionGetAllOptions(); + await foreach (SqlServerJobExecutionStepTargetResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobExecutionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobExecutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobResource.cs index 254662c028b5d..865931a96a630 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobResource.cs @@ -19,10 +19,10 @@ public partial class Sample_SqlServerJobResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateJobExecution_StartAJobExecution() + public async Task Get_GetAJob() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateJobExecution.json - // this example is just showing the usage of "JobExecutions_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJob.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,22 +40,21 @@ public async Task CreateJobExecution_StartAJobExecution() SqlServerJobResource sqlServerJob = client.GetSqlServerJobResource(sqlServerJobResourceId); // invoke the operation - ArmOperation lro = await sqlServerJob.CreateJobExecutionAsync(WaitUntil.Completed); - SqlServerJobExecutionResource result = lro.Value; + SqlServerJobResource result = await sqlServerJob.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerJobExecutionData resourceData = result.Data; + SqlServerJobData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAJob() + public async Task Delete_DeleteAJob() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJob.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJob.json + // this example is just showing the usage of "Jobs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,13 +72,9 @@ public async Task Get_GetAJob() SqlServerJobResource sqlServerJob = client.GetSqlServerJobResource(sqlServerJobResourceId); // invoke the operation - SqlServerJobResource result = await sqlServerJob.GetAsync(); + await sqlServerJob.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -105,10 +100,10 @@ public async Task Update_CreateAJobWithAllPropertiesSpecified() SqlServerJobResource sqlServerJob = client.GetSqlServerJobResource(sqlServerJobResourceId); // invoke the operation - SqlServerJobData data = new SqlServerJobData() + SqlServerJobData data = new SqlServerJobData { Description = "my favourite job", - Schedule = new SqlServerJobSchedule() + Schedule = new SqlServerJobSchedule { StartOn = DateTimeOffset.Parse("2015-09-24T18:30:01Z"), EndOn = DateTimeOffset.Parse("2015-09-24T23:59:59Z"), @@ -163,10 +158,10 @@ public async Task Update_CreateAJobWithDefaultProperties() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAJob() + public async Task CreateJobExecution_StartAJobExecution() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJob.json - // this example is just showing the usage of "Jobs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateJobExecution.json + // this example is just showing the usage of "JobExecutions_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,9 +179,14 @@ public async Task Delete_DeleteAJob() SqlServerJobResource sqlServerJob = client.GetSqlServerJobResource(sqlServerJobResourceId); // invoke the operation - await sqlServerJob.DeleteAsync(WaitUntil.Completed); + ArmOperation lro = await sqlServerJob.CreateJobExecutionAsync(WaitUntil.Completed); + SqlServerJobExecutionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobExecutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobStepCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobStepCollection.cs index 1480aa3d2b742..fd9a3e872d7f1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobStepCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobStepCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerJobStepCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListJobStepsForTheLatestVersionOfAJob() + public async Task CreateOrUpdate_CreateOrUpdateAJobStepWithAllPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobStepsByJob.json - // this example is just showing the usage of "JobSteps_ListByJob" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobStepMax.json + // this example is just showing the usage of "JobSteps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,50 @@ public async Task GetAll_ListJobStepsForTheLatestVersionOfAJob() // get the collection of this SqlServerJobStepResource SqlServerJobStepCollection collection = sqlServerJob.GetSqlServerJobSteps(); - // invoke the operation and iterate over the result - await foreach (SqlServerJobStepResource item in collection.GetAllAsync()) + // invoke the operation + string stepName = "step1"; + SqlServerJobStepData data = new SqlServerJobStepData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobStepData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StepId = 1, + TargetGroup = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup1", + Credential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred1", + Action = new JobStepAction("select 2") + { + ActionType = JobStepActionType.TSql, + Source = JobStepActionSource.Inline, + }, + Output = new JobStepOutput("server3", "database3", "mytable5678", "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0") + { + OutputType = JobStepOutputType.SqlDatabase, + SubscriptionId = Guid.Parse("3501b905-a848-4b5d-96e8-b253f62d735a"), + ResourceGroupName = "group3", + SchemaName = "myschema1234", + }, + ExecutionOptions = new JobStepExecutionOptions + { + TimeoutSeconds = 1234, + RetryAttempts = 42, + InitialRetryIntervalSeconds = 11, + MaximumRetryIntervalSeconds = 222, + RetryIntervalBackoffMultiplier = 3, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, stepName, data); + SqlServerJobStepResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobStepData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheLatestVersionOfAJobStep() + public async Task CreateOrUpdate_CreateOrUpdateAJobStepWithMinimalPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobStepByJob.json - // this example is just showing the usage of "JobSteps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobStepMin.json + // this example is just showing the usage of "JobSteps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -81,7 +106,14 @@ public async Task Get_GetTheLatestVersionOfAJobStep() // invoke the operation string stepName = "step1"; - SqlServerJobStepResource result = await collection.GetAsync(stepName); + SqlServerJobStepData data = new SqlServerJobStepData + { + TargetGroup = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup0", + Credential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0", + Action = new JobStepAction("select 1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, stepName, data); + SqlServerJobStepResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,7 +124,7 @@ public async Task Get_GetTheLatestVersionOfAJobStep() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheLatestVersionOfAJobStep() + public async Task Get_GetTheLatestVersionOfAJobStep() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobStepByJob.json // this example is just showing the usage of "JobSteps_Get" operation, for the dependent resources, they will have to be created separately. @@ -117,17 +149,21 @@ public async Task Exists_GetTheLatestVersionOfAJobStep() // invoke the operation string stepName = "step1"; - bool result = await collection.ExistsAsync(stepName); + SqlServerJobStepResource result = await collection.GetAsync(stepName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobStepData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheLatestVersionOfAJobStep() + public async Task GetAll_ListJobStepsForTheLatestVersionOfAJob() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobStepByJob.json - // this example is just showing the usage of "JobSteps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobStepsByJob.json + // this example is just showing the usage of "JobSteps_ListByJob" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,31 +183,25 @@ public async Task GetIfExists_GetTheLatestVersionOfAJobStep() // get the collection of this SqlServerJobStepResource SqlServerJobStepCollection collection = sqlServerJob.GetSqlServerJobSteps(); - // invoke the operation - string stepName = "step1"; - NullableResponse response = await collection.GetIfExistsAsync(stepName); - SqlServerJobStepResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerJobStepResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerJobStepData resourceData = result.Data; + SqlServerJobStepData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAJobStepWithAllPropertiesSpecified() + public async Task Exists_GetTheLatestVersionOfAJobStep() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobStepMax.json - // this example is just showing the usage of "JobSteps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobStepByJob.json + // this example is just showing the usage of "JobSteps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,48 +223,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAJobStepWithAllPropertiesSpecifie // invoke the operation string stepName = "step1"; - SqlServerJobStepData data = new SqlServerJobStepData() - { - StepId = 1, - TargetGroup = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup1", - Credential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred1", - Action = new JobStepAction("select 2") - { - ActionType = JobStepActionType.TSql, - Source = JobStepActionSource.Inline, - }, - Output = new JobStepOutput("server3", "database3", "mytable5678", "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0") - { - OutputType = JobStepOutputType.SqlDatabase, - SubscriptionId = Guid.Parse("3501b905-a848-4b5d-96e8-b253f62d735a"), - ResourceGroupName = "group3", - SchemaName = "myschema1234", - }, - ExecutionOptions = new JobStepExecutionOptions() - { - TimeoutSeconds = 1234, - RetryAttempts = 42, - InitialRetryIntervalSeconds = 11, - MaximumRetryIntervalSeconds = 222, - RetryIntervalBackoffMultiplier = 3, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, stepName, data); - SqlServerJobStepResource result = lro.Value; + bool result = await collection.ExistsAsync(stepName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobStepData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAJobStepWithMinimalPropertiesSpecified() + public async Task GetIfExists_GetTheLatestVersionOfAJobStep() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobStepMin.json - // this example is just showing the usage of "JobSteps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobStepByJob.json + // this example is just showing the usage of "JobSteps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -256,20 +255,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAJobStepWithMinimalPropertiesSpec // invoke the operation string stepName = "step1"; - SqlServerJobStepData data = new SqlServerJobStepData() - { - TargetGroup = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup0", - Credential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0", - Action = new JobStepAction("select 1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, stepName, data); - SqlServerJobStepResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(stepName); + SqlServerJobStepResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobStepData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobStepData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobStepResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobStepResource.cs index 0838ec6a76e30..5ffa47a691cf8 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobStepResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobStepResource.cs @@ -49,6 +49,35 @@ public async Task Get_GetTheLatestVersionOfAJobStep() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAJobStep() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobStep.json + // this example is just showing the usage of "JobSteps_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SqlServerJobStepResource created on azure + // for more information of creating SqlServerJobStepResource, please refer to the document of SqlServerJobStepResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "group1"; + string serverName = "server1"; + string jobAgentName = "agent1"; + string jobName = "job1"; + string stepName = "step1"; + ResourceIdentifier sqlServerJobStepResourceId = SqlServerJobStepResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, jobAgentName, jobName, stepName); + SqlServerJobStepResource sqlServerJobStep = client.GetSqlServerJobStepResource(sqlServerJobStepResourceId); + + // invoke the operation + await sqlServerJobStep.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateAJobStepWithAllPropertiesSpecified() @@ -73,7 +102,7 @@ public async Task Update_CreateOrUpdateAJobStepWithAllPropertiesSpecified() SqlServerJobStepResource sqlServerJobStep = client.GetSqlServerJobStepResource(sqlServerJobStepResourceId); // invoke the operation - SqlServerJobStepData data = new SqlServerJobStepData() + SqlServerJobStepData data = new SqlServerJobStepData { StepId = 1, TargetGroup = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup1", @@ -90,7 +119,7 @@ public async Task Update_CreateOrUpdateAJobStepWithAllPropertiesSpecified() ResourceGroupName = "group3", SchemaName = "myschema1234", }, - ExecutionOptions = new JobStepExecutionOptions() + ExecutionOptions = new JobStepExecutionOptions { TimeoutSeconds = 1234, RetryAttempts = 42, @@ -133,7 +162,7 @@ public async Task Update_CreateOrUpdateAJobStepWithMinimalPropertiesSpecified() SqlServerJobStepResource sqlServerJobStep = client.GetSqlServerJobStepResource(sqlServerJobStepResourceId); // invoke the operation - SqlServerJobStepData data = new SqlServerJobStepData() + SqlServerJobStepData data = new SqlServerJobStepData { TargetGroup = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/targetGroups/targetGroup0", Credential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/cred0", @@ -148,34 +177,5 @@ public async Task Update_CreateOrUpdateAJobStepWithMinimalPropertiesSpecified() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAJobStep() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobStep.json - // this example is just showing the usage of "JobSteps_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SqlServerJobStepResource created on azure - // for more information of creating SqlServerJobStepResource, please refer to the document of SqlServerJobStepResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "group1"; - string serverName = "server1"; - string jobAgentName = "agent1"; - string jobName = "job1"; - string stepName = "step1"; - ResourceIdentifier sqlServerJobStepResourceId = SqlServerJobStepResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, jobAgentName, jobName, stepName); - SqlServerJobStepResource sqlServerJobStep = client.GetSqlServerJobStepResource(sqlServerJobStepResourceId); - - // invoke the operation - await sqlServerJobStep.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobTargetGroupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobTargetGroupCollection.cs index 79480cf4b7b69..7ff3db408f2ad 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobTargetGroupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobTargetGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerJobTargetGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllTargetGroupsInAnAgent() + public async Task CreateOrUpdate_CreateOrUpdateATargetGroupWithAllProperties() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobTargetGroups.json - // this example is just showing the usage of "JobTargetGroups_ListByAgent" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobTargetGroupMax.json + // this example is just showing the usage of "JobTargetGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,50 @@ public async Task GetAll_GetAllTargetGroupsInAnAgent() // get the collection of this SqlServerJobTargetGroupResource SqlServerJobTargetGroupCollection collection = sqlServerJobAgent.GetSqlServerJobTargetGroups(); - // invoke the operation and iterate over the result - await foreach (SqlServerJobTargetGroupResource item in collection.GetAllAsync()) + // invoke the operation + string targetGroupName = "targetGroup1"; + SqlServerJobTargetGroupData data = new SqlServerJobTargetGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobTargetGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Members = {new JobTarget(JobTargetType.SqlDatabase) +{ +MembershipType = JobTargetGroupMembershipType.Exclude, +ServerName = "server1", +DatabaseName = "database1", +}, new JobTarget(JobTargetType.SqlServer) +{ +MembershipType = JobTargetGroupMembershipType.Include, +ServerName = "server1", +RefreshCredential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/testCredential", +}, new JobTarget(JobTargetType.SqlElasticPool) +{ +MembershipType = JobTargetGroupMembershipType.Include, +ServerName = "server2", +ElasticPoolName = "pool1", +RefreshCredential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/testCredential", +}, new JobTarget(JobTargetType.SqlShardMap) +{ +MembershipType = JobTargetGroupMembershipType.Include, +ServerName = "server3", +ShardMapName = "shardMap1", +RefreshCredential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/testCredential", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, targetGroupName, data); + SqlServerJobTargetGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobTargetGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetATargetGroup() + public async Task CreateOrUpdate_CreateOrUpdateATargetGroupWithMinimalProperties() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobTargetGroup.json - // this example is just showing the usage of "JobTargetGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobTargetGroupMin.json + // this example is just showing the usage of "JobTargetGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,7 +104,12 @@ public async Task Get_GetATargetGroup() // invoke the operation string targetGroupName = "targetGroup1"; - SqlServerJobTargetGroupResource result = await collection.GetAsync(targetGroupName); + SqlServerJobTargetGroupData data = new SqlServerJobTargetGroupData + { + Members = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, targetGroupName, data); + SqlServerJobTargetGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,7 +120,7 @@ public async Task Get_GetATargetGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetATargetGroup() + public async Task Get_GetATargetGroup() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobTargetGroup.json // this example is just showing the usage of "JobTargetGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -114,17 +144,21 @@ public async Task Exists_GetATargetGroup() // invoke the operation string targetGroupName = "targetGroup1"; - bool result = await collection.ExistsAsync(targetGroupName); + SqlServerJobTargetGroupResource result = await collection.GetAsync(targetGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobTargetGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetATargetGroup() + public async Task GetAll_GetAllTargetGroupsInAnAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobTargetGroup.json - // this example is just showing the usage of "JobTargetGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobTargetGroups.json + // this example is just showing the usage of "JobTargetGroups_ListByAgent" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +177,25 @@ public async Task GetIfExists_GetATargetGroup() // get the collection of this SqlServerJobTargetGroupResource SqlServerJobTargetGroupCollection collection = sqlServerJobAgent.GetSqlServerJobTargetGroups(); - // invoke the operation - string targetGroupName = "targetGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(targetGroupName); - SqlServerJobTargetGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerJobTargetGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerJobTargetGroupData resourceData = result.Data; + SqlServerJobTargetGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateATargetGroupWithAllProperties() + public async Task Exists_GetATargetGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobTargetGroupMax.json - // this example is just showing the usage of "JobTargetGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobTargetGroup.json + // this example is just showing the usage of "JobTargetGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,51 +216,17 @@ public async Task CreateOrUpdate_CreateOrUpdateATargetGroupWithAllProperties() // invoke the operation string targetGroupName = "targetGroup1"; - SqlServerJobTargetGroupData data = new SqlServerJobTargetGroupData() - { - Members = -{ -new JobTarget(JobTargetType.SqlDatabase) -{ -MembershipType = JobTargetGroupMembershipType.Exclude, -ServerName = "server1", -DatabaseName = "database1", -},new JobTarget(JobTargetType.SqlServer) -{ -MembershipType = JobTargetGroupMembershipType.Include, -ServerName = "server1", -RefreshCredential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/testCredential", -},new JobTarget(JobTargetType.SqlElasticPool) -{ -MembershipType = JobTargetGroupMembershipType.Include, -ServerName = "server2", -ElasticPoolName = "pool1", -RefreshCredential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/testCredential", -},new JobTarget(JobTargetType.SqlShardMap) -{ -MembershipType = JobTargetGroupMembershipType.Include, -ServerName = "server3", -ShardMapName = "shardMap1", -RefreshCredential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/testCredential", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, targetGroupName, data); - SqlServerJobTargetGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(targetGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobTargetGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateATargetGroupWithMinimalProperties() + public async Task GetIfExists_GetATargetGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateJobTargetGroupMin.json - // this example is just showing the usage of "JobTargetGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobTargetGroup.json + // this example is just showing the usage of "JobTargetGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -253,20 +247,21 @@ public async Task CreateOrUpdate_CreateOrUpdateATargetGroupWithMinimalProperties // invoke the operation string targetGroupName = "targetGroup1"; - SqlServerJobTargetGroupData data = new SqlServerJobTargetGroupData() - { - Members = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, targetGroupName, data); - SqlServerJobTargetGroupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(targetGroupName); + SqlServerJobTargetGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobTargetGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobTargetGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobTargetGroupResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobTargetGroupResource.cs index ce4b594bdf41f..1a7a09746c382 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobTargetGroupResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobTargetGroupResource.cs @@ -48,6 +48,34 @@ public async Task Get_GetATargetGroup() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteATargetGroup() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobTargetGroup.json + // this example is just showing the usage of "JobTargetGroups_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SqlServerJobTargetGroupResource created on azure + // for more information of creating SqlServerJobTargetGroupResource, please refer to the document of SqlServerJobTargetGroupResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "group1"; + string serverName = "server1"; + string jobAgentName = "agent1"; + string targetGroupName = "targetGroup1"; + ResourceIdentifier sqlServerJobTargetGroupResourceId = SqlServerJobTargetGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, jobAgentName, targetGroupName); + SqlServerJobTargetGroupResource sqlServerJobTargetGroup = client.GetSqlServerJobTargetGroupResource(sqlServerJobTargetGroupResourceId); + + // invoke the operation + await sqlServerJobTargetGroup.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateATargetGroupWithAllProperties() @@ -71,34 +99,31 @@ public async Task Update_CreateOrUpdateATargetGroupWithAllProperties() SqlServerJobTargetGroupResource sqlServerJobTargetGroup = client.GetSqlServerJobTargetGroupResource(sqlServerJobTargetGroupResourceId); // invoke the operation - SqlServerJobTargetGroupData data = new SqlServerJobTargetGroupData() + SqlServerJobTargetGroupData data = new SqlServerJobTargetGroupData { - Members = -{ -new JobTarget(JobTargetType.SqlDatabase) + Members = {new JobTarget(JobTargetType.SqlDatabase) { MembershipType = JobTargetGroupMembershipType.Exclude, ServerName = "server1", DatabaseName = "database1", -},new JobTarget(JobTargetType.SqlServer) +}, new JobTarget(JobTargetType.SqlServer) { MembershipType = JobTargetGroupMembershipType.Include, ServerName = "server1", RefreshCredential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/testCredential", -},new JobTarget(JobTargetType.SqlElasticPool) +}, new JobTarget(JobTargetType.SqlElasticPool) { MembershipType = JobTargetGroupMembershipType.Include, ServerName = "server2", ElasticPoolName = "pool1", RefreshCredential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/testCredential", -},new JobTarget(JobTargetType.SqlShardMap) +}, new JobTarget(JobTargetType.SqlShardMap) { MembershipType = JobTargetGroupMembershipType.Include, ServerName = "server3", ShardMapName = "shardMap1", RefreshCredential = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/group1/providers/Microsoft.Sql/servers/server1/jobAgents/agent1/credentials/testCredential", -} -}, +}}, }; ArmOperation lro = await sqlServerJobTargetGroup.UpdateAsync(WaitUntil.Completed, data); SqlServerJobTargetGroupResource result = lro.Value; @@ -133,11 +158,9 @@ public async Task Update_CreateOrUpdateATargetGroupWithMinimalProperties() SqlServerJobTargetGroupResource sqlServerJobTargetGroup = client.GetSqlServerJobTargetGroupResource(sqlServerJobTargetGroupResourceId); // invoke the operation - SqlServerJobTargetGroupData data = new SqlServerJobTargetGroupData() + SqlServerJobTargetGroupData data = new SqlServerJobTargetGroupData { - Members = -{ -}, + Members = { }, }; ArmOperation lro = await sqlServerJobTargetGroup.UpdateAsync(WaitUntil.Completed, data); SqlServerJobTargetGroupResource result = lro.Value; @@ -148,33 +171,5 @@ public async Task Update_CreateOrUpdateATargetGroupWithMinimalProperties() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteATargetGroup() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteJobTargetGroup.json - // this example is just showing the usage of "JobTargetGroups_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SqlServerJobTargetGroupResource created on azure - // for more information of creating SqlServerJobTargetGroupResource, please refer to the document of SqlServerJobTargetGroupResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "group1"; - string serverName = "server1"; - string jobAgentName = "agent1"; - string targetGroupName = "targetGroup1"; - ResourceIdentifier sqlServerJobTargetGroupResourceId = SqlServerJobTargetGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, jobAgentName, targetGroupName); - SqlServerJobTargetGroupResource sqlServerJobTargetGroup = client.GetSqlServerJobTargetGroupResource(sqlServerJobTargetGroupResourceId); - - // invoke the operation - await sqlServerJobTargetGroup.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobVersionCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobVersionCollection.cs index 9bcf25e6b485f..dd87d10fcd9d1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobVersionCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobVersionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlServerJobVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllVersionsOfAJob() + public async Task Get_GetAVersionOfAJob() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobVersions.json - // this example is just showing the usage of "JobVersions_ListByJob" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobVersion.json + // this example is just showing the usage of "JobVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_GetAllVersionsOfAJob() // get the collection of this SqlServerJobVersionResource SqlServerJobVersionCollection collection = sqlServerJob.GetSqlServerJobVersions(); - // invoke the operation and iterate over the result - await foreach (SqlServerJobVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + int jobVersion = 1; + SqlServerJobVersionResource result = await collection.GetAsync(jobVersion); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVersionOfAJob() + public async Task GetAll_GetAllVersionsOfAJob() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobVersion.json - // this example is just showing the usage of "JobVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobVersions.json + // this example is just showing the usage of "JobVersions_ListByJob" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetAVersionOfAJob() // get the collection of this SqlServerJobVersionResource SqlServerJobVersionCollection collection = sqlServerJob.GetSqlServerJobVersions(); - // invoke the operation - int jobVersion = 1; - SqlServerJobVersionResource result = await collection.GetAsync(jobVersion); + // invoke the operation and iterate over the result + await foreach (SqlServerJobVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobVersionStepCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobVersionStepCollection.cs index fb0979f8a35f9..556f465b08d1e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobVersionStepCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerJobVersionStepCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlServerJobVersionStepCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListJobStepsForTheSpecifiedVersionOfAJob() + public async Task Get_GetTheSpecifiedVersionOfAJobStep() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobStepsByVersion.json - // this example is just showing the usage of "JobSteps_ListByVersion" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobStepByVersion.json + // this example is just showing the usage of "JobSteps_GetByVersion" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_ListJobStepsForTheSpecifiedVersionOfAJob() // get the collection of this SqlServerJobVersionStepResource SqlServerJobVersionStepCollection collection = sqlServerJobVersion.GetSqlServerJobVersionSteps(); - // invoke the operation and iterate over the result - await foreach (SqlServerJobVersionStepResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobStepData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string stepName = "step1"; + SqlServerJobVersionStepResource result = await collection.GetAsync(stepName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobStepData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheSpecifiedVersionOfAJobStep() + public async Task GetAll_ListJobStepsForTheSpecifiedVersionOfAJob() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetJobStepByVersion.json - // this example is just showing the usage of "JobSteps_GetByVersion" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListJobStepsByVersion.json + // this example is just showing the usage of "JobSteps_ListByVersion" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +78,17 @@ public async Task Get_GetTheSpecifiedVersionOfAJobStep() // get the collection of this SqlServerJobVersionStepResource SqlServerJobVersionStepCollection collection = sqlServerJobVersion.GetSqlServerJobVersionSteps(); - // invoke the operation - string stepName = "step1"; - SqlServerJobVersionStepResource result = await collection.GetAsync(stepName); + // invoke the operation and iterate over the result + await foreach (SqlServerJobVersionStepResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerJobStepData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerJobStepData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerKeyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerKeyCollection.cs index cbdfd0e2051b8..b86048426d3c5 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerKeyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerKeyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerKeyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheServerKeysByServer() + public async Task CreateOrUpdate_CreatesOrUpdatesAServerKey() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyList.json - // this example is just showing the usage of "ServerKeys_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyCreateOrUpdate.json + // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ListTheServerKeysByServer() // get the collection of this SqlServerKeyResource SqlServerKeyCollection collection = sqlServer.GetSqlServerKeys(); - // invoke the operation and iterate over the result - await foreach (SqlServerKeyResource item in collection.GetAllAsync()) + // invoke the operation + string keyName = "someVault_someKey_01234567890123456789012345678901"; + SqlServerKeyData data = new SqlServerKeyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServerKeyType = SqlServerKeyType.AzureKeyVault, + Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, data); + SqlServerKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_GetTheServerKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheServerKey() + public async Task GetAll_ListTheServerKeysByServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyGet.json - // this example is just showing the usage of "ServerKeys_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyList.json + // this example is just showing the usage of "ServerKeys_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +113,22 @@ public async Task Exists_GetTheServerKey() // get the collection of this SqlServerKeyResource SqlServerKeyCollection collection = sqlServer.GetSqlServerKeys(); - // invoke the operation - string keyName = "someVault_someKey_01234567890123456789012345678901"; - bool result = await collection.ExistsAsync(keyName); + // invoke the operation and iterate over the result + await foreach (SqlServerKeyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheServerKey() + public async Task Exists_GetTheServerKey() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyGet.json // this example is just showing the usage of "ServerKeys_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_GetTheServerKey() // invoke the operation string keyName = "someVault_someKey_01234567890123456789012345678901"; - NullableResponse response = await collection.GetIfExistsAsync(keyName); - SqlServerKeyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(keyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesAServerKey() + public async Task GetIfExists_GetTheServerKey() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyCreateOrUpdate.json - // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyGet.json + // this example is just showing the usage of "ServerKeys_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,19 +181,21 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAServerKey() // invoke the operation string keyName = "someVault_someKey_01234567890123456789012345678901"; - SqlServerKeyData data = new SqlServerKeyData() - { - ServerKeyType = SqlServerKeyType.AzureKeyVault, - Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, data); - SqlServerKeyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(keyName); + SqlServerKeyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerKeyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerKeyResource.cs index 5581a91104521..da700c377ad9a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerKeyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerKeyResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetTheServerKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesAServerKey() + public async Task Delete_DeleteTheServerKey() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyCreateOrUpdate.json - // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyDelete.json + // this example is just showing the usage of "ServerKeys_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,27 +69,17 @@ public async Task Update_CreatesOrUpdatesAServerKey() SqlServerKeyResource sqlServerKey = client.GetSqlServerKeyResource(sqlServerKeyResourceId); // invoke the operation - SqlServerKeyData data = new SqlServerKeyData() - { - ServerKeyType = SqlServerKeyType.AzureKeyVault, - Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), - }; - ArmOperation lro = await sqlServerKey.UpdateAsync(WaitUntil.Completed, data); - SqlServerKeyResource result = lro.Value; + await sqlServerKey.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteTheServerKey() + public async Task Update_CreatesOrUpdatesAServerKey() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyDelete.json - // this example is just showing the usage of "ServerKeys_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerKeyCreateOrUpdate.json + // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +96,19 @@ public async Task Delete_DeleteTheServerKey() SqlServerKeyResource sqlServerKey = client.GetSqlServerKeyResource(sqlServerKeyResourceId); // invoke the operation - await sqlServerKey.DeleteAsync(WaitUntil.Completed); + SqlServerKeyData data = new SqlServerKeyData + { + ServerKeyType = SqlServerKeyType.AzureKeyVault, + Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + }; + ArmOperation lro = await sqlServerKey.UpdateAsync(WaitUntil.Completed, data); + SqlServerKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerResource.cs index 29a0477332efb..db62231c8ef66 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Sql.Models; using NUnit.Framework; @@ -19,10 +18,10 @@ public partial class Sample_SqlServerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetServerUsages_ListServersUsages() + public async Task Get_GetServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ServerUsageMetricsList.json - // this example is just showing the usage of "ServerUsages_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,26 +31,27 @@ public async Task GetServerUsages_ListServersUsages() // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-6730"; - string serverName = "sqlcrudtest-9007"; + string resourceGroupName = "sqlcrudtest-7398"; + string serverName = "sqlcrudtest-4645"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); - // invoke the operation and iterate over the result - await foreach (SqlServerUsage item in sqlServer.GetServerUsagesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + SqlServerResource result = await sqlServer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetServerOperations_ListTheServerManagementOperations() + public async Task Get_GetServerWithExpandAdministratorsActivedirectory() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListServerOperations.json - // this example is just showing the usage of "ServerOperations_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGetWithExpandEqualsAdministrators.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,21 +66,22 @@ public async Task GetServerOperations_ListTheServerManagementOperations() ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); - // invoke the operation and iterate over the result - await foreach (ServerOperationData item in sqlServer.GetServerOperationsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + SqlServerResource result = await sqlServer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateTdeCertificate_UploadATDECertificate() + public async Task Delete_DeleteServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SqlTdeCertificateCreate.json - // this example is just showing the usage of "TdeCertificates_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDelete.json + // this example is just showing the usage of "Servers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -89,28 +90,24 @@ public async Task CreateTdeCertificate_UploadATDECertificate() // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource - string subscriptionId = "00000000-0000-0000-0000-000000000001"; - string resourceGroupName = "testtdecert"; - string serverName = "testtdecert"; + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "sqlcrudtest-7398"; + string serverName = "sqlcrudtest-6661"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); // invoke the operation - TdeCertificate tdeCertificate = new TdeCertificate() - { - PrivateBlob = "MIIXXXXXXXX", - }; - await sqlServer.CreateTdeCertificateAsync(WaitUntil.Completed, tdeCertificate); + await sqlServer.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetInaccessibleDatabases_GetsAListOfInaccessibleDatabasesInALogicalServer() + public async Task Update_UpdateAServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreInaccessibleDatabasesByServer.json - // this example is just showing the usage of "Databases_ListInaccessibleByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerUpdate.json + // this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,167 +117,36 @@ public async Task GetInaccessibleDatabases_GetsAListOfInaccessibleDatabasesInALo // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "Default-SQL-SouthEastAsia"; - string serverName = "testsvr"; + string resourceGroupName = "sqlcrudtest-7398"; + string serverName = "sqlcrudtest-4645"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); - // invoke the operation and iterate over the result - await foreach (SqlDatabaseResource item in sqlServer.GetInaccessibleDatabasesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckSqlServerNameAvailability_CheckForAServerNameThatAlreadyExists() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CheckNameAvailabilityServerAlreadyExists.json - // this example is just showing the usage of "Servers_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - SqlNameAvailabilityContent content = new SqlNameAvailabilityContent("server1"); - SqlNameAvailabilityResponse result = await subscriptionResource.CheckSqlServerNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckSqlServerNameAvailability_CheckForAServerNameThatIsAvailable() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CheckNameAvailabilityServerAvailable.json - // this example is just showing the usage of "Servers_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - SqlNameAvailabilityContent content = new SqlNameAvailabilityContent("server1"); - SqlNameAvailabilityResponse result = await subscriptionResource.CheckSqlServerNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckSqlServerNameAvailability_CheckForAServerNameThatIsInvalid() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CheckNameAvailabilityServerInvalid.json - // this example is just showing the usage of "Servers_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - // invoke the operation - SqlNameAvailabilityContent content = new SqlNameAvailabilityContent("SERVER1"); - SqlNameAvailabilityResponse result = await subscriptionResource.CheckSqlServerNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSqlServers_ListServers() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerList.json - // this example is just showing the usage of "Servers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SqlServerResource item in subscriptionResource.GetSqlServersAsync()) + SqlServerPatch patch = new SqlServerPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSqlServers_ListServersWithExpandAdministratorsActivedirectory() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerListWithExpandEqualsAdministrators.json - // this example is just showing the usage of "Servers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SqlServerResource item in subscriptionResource.GetSqlServersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AdministratorLogin = "dummylogin", + AdministratorLoginPassword = "placeholder", + PublicNetworkAccess = ServerNetworkAccessFlag.Disabled, + RestrictOutboundNetworkAccess = ServerNetworkAccessFlag.Enabled, + IsIPv6Enabled = ServerNetworkAccessFlag.Enabled, + }; + ArmOperation lro = await sqlServer.UpdateAsync(WaitUntil.Completed, patch); + SqlServerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServer() + public async Task GetServerUsages_ListServersUsages() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/stable/2014-04-01-legacy/examples/ServerUsageMetricsList.json + // this example is just showing the usage of "ServerUsages_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -290,27 +156,26 @@ public async Task Get_GetServer() // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-7398"; - string serverName = "sqlcrudtest-4645"; + string resourceGroupName = "sqlcrudtest-6730"; + string serverName = "sqlcrudtest-9007"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); - // invoke the operation - SqlServerResource result = await sqlServer.GetAsync(); + // invoke the operation and iterate over the result + await foreach (SqlServerUsage item in sqlServer.GetServerUsagesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServerWithExpandAdministratorsActivedirectory() + public async Task GetServerOperations_ListTheServerManagementOperations() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerGetWithExpandEqualsAdministrators.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ListServerOperations.json + // this example is just showing the usage of "ServerOperations_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -325,22 +190,21 @@ public async Task Get_GetServerWithExpandAdministratorsActivedirectory() ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); - // invoke the operation - SqlServerResource result = await sqlServer.GetAsync(); + // invoke the operation and iterate over the result + await foreach (ServerOperationData item in sqlServer.GetServerOperationsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteServer() + public async Task CreateTdeCertificate_UploadATDECertificate() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerDelete.json - // this example is just showing the usage of "Servers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SqlTdeCertificateCreate.json + // this example is just showing the usage of "TdeCertificates_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -349,24 +213,28 @@ public async Task Delete_DeleteServer() // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-7398"; - string serverName = "sqlcrudtest-6661"; + string subscriptionId = "00000000-0000-0000-0000-000000000001"; + string resourceGroupName = "testtdecert"; + string serverName = "testtdecert"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); // invoke the operation - await sqlServer.DeleteAsync(WaitUntil.Completed); + TdeCertificate tdeCertificate = new TdeCertificate + { + PrivateBlob = "MIIXXXXXXXX", + }; + await sqlServer.CreateTdeCertificateAsync(WaitUntil.Completed, tdeCertificate); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAServer() + public async Task GetInaccessibleDatabases_GetsAListOfInaccessibleDatabasesInALogicalServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerUpdate.json - // this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-02-01-preview/examples/ListVCoreInaccessibleDatabasesByServer.json + // this example is just showing the usage of "Databases_ListInaccessibleByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -376,28 +244,22 @@ public async Task Update_UpdateAServer() // this example assumes you already have this SqlServerResource created on azure // for more information of creating SqlServerResource, please refer to the document of SqlServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "sqlcrudtest-7398"; - string serverName = "sqlcrudtest-4645"; + string resourceGroupName = "Default-SQL-SouthEastAsia"; + string serverName = "testsvr"; ResourceIdentifier sqlServerResourceId = SqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); SqlServerResource sqlServer = client.GetSqlServerResource(sqlServerResourceId); - // invoke the operation - SqlServerPatch patch = new SqlServerPatch() + // invoke the operation and iterate over the result + await foreach (SqlDatabaseResource item in sqlServer.GetInaccessibleDatabasesAsync()) { - AdministratorLogin = "dummylogin", - AdministratorLoginPassword = "placeholder", - PublicNetworkAccess = ServerNetworkAccessFlag.Disabled, - RestrictOutboundNetworkAccess = ServerNetworkAccessFlag.Enabled, - IsIPv6Enabled = ServerNetworkAccessFlag.Enabled, - }; - ArmOperation lro = await sqlServer.UpdateAsync(WaitUntil.Completed, patch); - SqlServerResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -425,7 +287,7 @@ public async Task ImportDatabase_ImportsToANewDatabaseUsingPrivateLinkForTheSQLS { DatabaseName = "testdb", AuthenticationType = "Sql", - NetworkIsolation = new NetworkIsolationSettings() + NetworkIsolation = new NetworkIsolationSettings { StorageAccountResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Storage/storageAccounts/test-privatelink"), SqlServerResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-SouthEastAsia/providers/Microsoft.Sql/servers/testsvr"), diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSecurityAlertPolicyCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSecurityAlertPolicyCollection.cs index 93135a7af053a..a85f8d12286a1 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSecurityAlertPolicyCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSecurityAlertPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerSecurityAlertPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsGet.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsCreateMax.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_GetAServerSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - SqlServerSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); + SqlServerSecurityAlertPolicyData data = new SqlServerSecurityAlertPolicyData + { + State = SecurityAlertsPolicyState.Enabled, + DisabledAlerts = { "Access_Anomaly", "Usage_Anomaly" }, + EmailAddresses = { "testSecurityAlert@microsoft.com" }, + SendToEmailAccountAdmins = true, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + RetentionDays = 5, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + SqlServerSecurityAlertPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +63,10 @@ public async Task Get_GetAServerSThreatDetectionPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsGet.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsCreateMin.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +86,23 @@ public async Task Exists_GetAServerSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - bool result = await collection.ExistsAsync(securityAlertPolicyName); + SqlServerSecurityAlertPolicyData data = new SqlServerSecurityAlertPolicyData + { + State = SecurityAlertsPolicyState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + SqlServerSecurityAlertPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerSThreatDetectionPolicy() + public async Task Get_GetAServerSThreatDetectionPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsGet.json // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +125,21 @@ public async Task GetIfExists_GetAServerSThreatDetectionPolicy() // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); - SqlServerSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + SqlServerSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() + public async Task GetAll_ListTheServerSThreatDetectionPolicies() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsCreateMax.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsListByServer.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,40 +157,25 @@ public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParam // get the collection of this SqlServerSecurityAlertPolicyResource SqlServerSecurityAlertPolicyCollection collection = sqlServer.GetSqlServerSecurityAlertPolicies(); - // invoke the operation - SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - SqlServerSecurityAlertPolicyData data = new SqlServerSecurityAlertPolicyData() + // invoke the operation and iterate over the result + await foreach (SqlServerSecurityAlertPolicyResource item in collection.GetAllAsync()) { - State = SecurityAlertsPolicyState.Enabled, - DisabledAlerts = -{ -"Access_Anomaly","Usage_Anomaly" -}, - EmailAddresses = -{ -"testSecurityAlert@microsoft.com" -}, - SendToEmailAccountAdmins = true, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - RetentionDays = 5, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - SqlServerSecurityAlertPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerSecurityAlertPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() + public async Task Exists_GetAServerSThreatDetectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsCreateMin.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsGet.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,26 +195,17 @@ public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalP // invoke the operation SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; - SqlServerSecurityAlertPolicyData data = new SqlServerSecurityAlertPolicyData() - { - State = SecurityAlertsPolicyState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - SqlServerSecurityAlertPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(securityAlertPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheServerSThreatDetectionPolicies() + public async Task GetIfExists_GetAServerSThreatDetectionPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsListByServer.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerSecurityAlertsGet.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -235,17 +223,23 @@ public async Task GetAll_ListTheServerSThreatDetectionPolicies() // get the collection of this SqlServerSecurityAlertPolicyResource SqlServerSecurityAlertPolicyCollection collection = sqlServer.GetSqlServerSecurityAlertPolicies(); - // invoke the operation and iterate over the result - await foreach (SqlServerSecurityAlertPolicyResource item in collection.GetAllAsync()) + // invoke the operation + SqlSecurityAlertPolicyName securityAlertPolicyName = SqlSecurityAlertPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); + SqlServerSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerSecurityAlertPolicyData resourceData = item.Data; + SqlServerSecurityAlertPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSecurityAlertPolicyResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSecurityAlertPolicyResource.cs index af8f93b3e8a00..48ef92cd9f3cd 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSecurityAlertPolicyResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSecurityAlertPolicyResource.cs @@ -69,17 +69,11 @@ public async Task Update_UpdateAServerSThreatDetectionPolicyWithAllParameters() SqlServerSecurityAlertPolicyResource sqlServerSecurityAlertPolicy = client.GetSqlServerSecurityAlertPolicyResource(sqlServerSecurityAlertPolicyResourceId); // invoke the operation - SqlServerSecurityAlertPolicyData data = new SqlServerSecurityAlertPolicyData() + SqlServerSecurityAlertPolicyData data = new SqlServerSecurityAlertPolicyData { State = SecurityAlertsPolicyState.Enabled, - DisabledAlerts = -{ -"Access_Anomaly","Usage_Anomaly" -}, - EmailAddresses = -{ -"testSecurityAlert@microsoft.com" -}, + DisabledAlerts = { "Access_Anomaly", "Usage_Anomaly" }, + EmailAddresses = { "testSecurityAlert@microsoft.com" }, SendToEmailAccountAdmins = true, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", @@ -117,7 +111,7 @@ public async Task Update_UpdateAServerSThreatDetectionPolicyWithMinimalParameter SqlServerSecurityAlertPolicyResource sqlServerSecurityAlertPolicy = client.GetSqlServerSecurityAlertPolicyResource(sqlServerSecurityAlertPolicyResourceId); // invoke the operation - SqlServerSecurityAlertPolicyData data = new SqlServerSecurityAlertPolicyData() + SqlServerSecurityAlertPolicyData data = new SqlServerSecurityAlertPolicyData { State = SecurityAlertsPolicyState.Enabled, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineCollection.cs index e3067d6378c36..a12eb2fbc982f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_SqlServerSqlVulnerabilityAssessmentBaselineCollectio { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() + public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselineFromTheLatestScanResult() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineListBySqlVulnerabilityAssessment.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaseline_ListBySqlVulnerabilityAssessment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineAddLatest.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,8 +31,8 @@ public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBasel // this example assumes you already have this SqlServerSqlVulnerabilityAssessmentResource created on azure // for more information of creating SqlServerSqlVulnerabilityAssessmentResource, please refer to the document of SqlServerSqlVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4711"; - string serverName = "vulnerabilityaseessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlServerSqlVulnerabilityAssessmentResourceId = SqlServerSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, vulnerabilityAssessmentName); SqlServerSqlVulnerabilityAssessmentResource sqlServerSqlVulnerabilityAssessment = client.GetSqlServerSqlVulnerabilityAssessmentResource(sqlServerSqlVulnerabilityAssessmentResourceId); @@ -41,25 +40,29 @@ public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBasel // get the collection of this SqlServerSqlVulnerabilityAssessmentBaselineResource SqlServerSqlVulnerabilityAssessmentBaselineCollection collection = sqlServerSqlVulnerabilityAssessment.GetSqlServerSqlVulnerabilityAssessmentBaselines(); - // invoke the operation and iterate over the result - await foreach (SqlServerSqlVulnerabilityAssessmentBaselineResource item in collection.GetAllAsync()) + // invoke the operation + SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; + SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsLatestScan = true, + Results = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, baselineName, content); + SqlServerSqlVulnerabilityAssessmentBaselineResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() + public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselineList() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineGet.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaseline_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineAdd.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,7 +83,17 @@ public async Task Get_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaseline // invoke the operation SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; - SqlServerSqlVulnerabilityAssessmentBaselineResource result = await collection.GetAsync(baselineName); + SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent + { + IsLatestScan = false, + Results = +{ +["VA2063"] = {{"AllowAll", "0.0.0.0", "255.255.255.255"}}, +["VA2065"] = {{"AllowAll", "0.0.0.0", "255.255.255.255"}} +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, baselineName, content); + SqlServerSqlVulnerabilityAssessmentBaselineResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -91,7 +104,7 @@ public async Task Get_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaseline [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() + public async Task Get_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineGet.json // this example is just showing the usage of "SqlVulnerabilityAssessmentBaseline_Get" operation, for the dependent resources, they will have to be created separately. @@ -115,17 +128,21 @@ public async Task Exists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBasel // invoke the operation SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; - bool result = await collection.ExistsAsync(baselineName); + SqlServerSqlVulnerabilityAssessmentBaselineResource result = await collection.GetAsync(baselineName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() + public async Task GetAll_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineGet.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaseline_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineListBySqlVulnerabilityAssessment.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaseline_ListBySqlVulnerabilityAssessment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,31 +161,25 @@ public async Task GetIfExists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRule // get the collection of this SqlServerSqlVulnerabilityAssessmentBaselineResource SqlServerSqlVulnerabilityAssessmentBaselineCollection collection = sqlServerSqlVulnerabilityAssessment.GetSqlServerSqlVulnerabilityAssessmentBaselines(); - // invoke the operation - SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; - NullableResponse response = await collection.GetIfExistsAsync(baselineName); - SqlServerSqlVulnerabilityAssessmentBaselineResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerSqlVulnerabilityAssessmentBaselineResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; + SqlVulnerabilityAssessmentBaselineData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselineFromTheLatestScanResult() + public async Task Exists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineAddLatest.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineGet.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaseline_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,8 +189,8 @@ public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselin // this example assumes you already have this SqlServerSqlVulnerabilityAssessmentResource created on azure // for more information of creating SqlServerSqlVulnerabilityAssessmentResource, please refer to the document of SqlServerSqlVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityaseessmenttest-4711"; + string serverName = "vulnerabilityaseessmenttest-6411"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlServerSqlVulnerabilityAssessmentResourceId = SqlServerSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, vulnerabilityAssessmentName); SqlServerSqlVulnerabilityAssessmentResource sqlServerSqlVulnerabilityAssessment = client.GetSqlServerSqlVulnerabilityAssessmentResource(sqlServerSqlVulnerabilityAssessmentResourceId); @@ -189,29 +200,17 @@ public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselin // invoke the operation SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; - SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent() - { - IsLatestScan = true, - Results = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, baselineName, content); - SqlServerSqlVulnerabilityAssessmentBaselineResource result = lro.Value; + bool result = await collection.ExistsAsync(baselineName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselineList() + public async Task GetIfExists_GetsAListOfDatabaseSSqlVulnerabilityAssessmentRuleBaselines() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineAdd.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentBaselines_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentBaselineGet.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentBaseline_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -232,35 +231,21 @@ public async Task CreateOrUpdate_AddADatabaseSVulnerabilityAssessmentRuleBaselin // invoke the operation SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; - SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent() - { - IsLatestScan = false, - Results = -{ -["VA2063"] = new IList[] -{ -new string[] -{ -"AllowAll","0.0.0.0","255.255.255.255" -} -}, -["VA2065"] = new IList[] -{ -new string[] -{ -"AllowAll","0.0.0.0","255.255.255.255" -} -}, -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, baselineName, content); - SqlServerSqlVulnerabilityAssessmentBaselineResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(baselineName); + SqlServerSqlVulnerabilityAssessmentBaselineResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineResource.cs index 5a389e3173991..d58872b133b5e 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -72,12 +71,10 @@ public async Task Update_AddADatabaseSVulnerabilityAssessmentRuleBaselineFromThe SqlServerSqlVulnerabilityAssessmentBaselineResource sqlServerSqlVulnerabilityAssessmentBaseline = client.GetSqlServerSqlVulnerabilityAssessmentBaselineResource(sqlServerSqlVulnerabilityAssessmentBaselineResourceId); // invoke the operation - SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent() + SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent { IsLatestScan = true, - Results = -{ -}, + Results = { }, }; ArmOperation lro = await sqlServerSqlVulnerabilityAssessmentBaseline.UpdateAsync(WaitUntil.Completed, content); SqlServerSqlVulnerabilityAssessmentBaselineResource result = lro.Value; @@ -112,25 +109,13 @@ public async Task Update_AddADatabaseSVulnerabilityAssessmentRuleBaselineList() SqlServerSqlVulnerabilityAssessmentBaselineResource sqlServerSqlVulnerabilityAssessmentBaseline = client.GetSqlServerSqlVulnerabilityAssessmentBaselineResource(sqlServerSqlVulnerabilityAssessmentBaselineResourceId); // invoke the operation - SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent() + SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineCreateOrUpdateContent { IsLatestScan = false, Results = { -["VA2063"] = new IList[] -{ -new string[] -{ -"AllowAll","0.0.0.0","255.255.255.255" -} -}, -["VA2065"] = new IList[] -{ -new string[] -{ -"AllowAll","0.0.0.0","255.255.255.255" -} -}, +["VA2063"] = {{"AllowAll", "0.0.0.0", "255.255.255.255"}}, +["VA2065"] = {{"AllowAll", "0.0.0.0", "255.255.255.255"}} }, }; ArmOperation lro = await sqlServerSqlVulnerabilityAssessmentBaseline.UpdateAsync(WaitUntil.Completed, content); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineRuleCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineRuleCollection.cs index 95eb72eb515c8..549f5ed5b43c7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineRuleCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerSqlVulnerabilityAssessmentBaselineRuleColle { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBaseline() + public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineListByBaseline.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaseline_ListByBaseline" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineCreate.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaseline_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task GetAll_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBasel // this example assumes you already have this SqlServerSqlVulnerabilityAssessmentBaselineResource created on azure // for more information of creating SqlServerSqlVulnerabilityAssessmentBaselineResource, please refer to the document of SqlServerSqlVulnerabilityAssessmentBaselineResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4711"; - string serverName = "vulnerabilityaseessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; ResourceIdentifier sqlServerSqlVulnerabilityAssessmentBaselineResourceId = SqlServerSqlVulnerabilityAssessmentBaselineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName); @@ -41,17 +41,21 @@ public async Task GetAll_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBasel // get the collection of this SqlServerSqlVulnerabilityAssessmentBaselineRuleResource SqlServerSqlVulnerabilityAssessmentBaselineRuleCollection collection = sqlServerSqlVulnerabilityAssessmentBaseline.GetSqlServerSqlVulnerabilityAssessmentBaselineRules(); - // invoke the operation and iterate over the result - await foreach (SqlServerSqlVulnerabilityAssessmentBaselineRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleId = "VA1001"; + SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsLatestScan = false, + Results = { { "userA", "SELECT" }, { "userB", "SELECT" }, { "userC", "SELECT" } }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, content); + SqlServerSqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +96,10 @@ public async Task Get_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBaseline [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBaseline() + public async Task GetAll_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineGet.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaseline_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineListByBaseline.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaseline_ListByBaseline" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +119,22 @@ public async Task Exists_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBasel // get the collection of this SqlServerSqlVulnerabilityAssessmentBaselineRuleResource SqlServerSqlVulnerabilityAssessmentBaselineRuleCollection collection = sqlServerSqlVulnerabilityAssessmentBaseline.GetSqlServerSqlVulnerabilityAssessmentBaselineRules(); - // invoke the operation - string ruleId = "VA1001"; - bool result = await collection.ExistsAsync(ruleId); + // invoke the operation and iterate over the result + await foreach (SqlServerSqlVulnerabilityAssessmentBaselineRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBaseline() + public async Task Exists_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBaseline() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineGet.json // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaseline_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +159,17 @@ public async Task GetIfExists_GetsASystemDatabaseSSqlVulnerabilityAssessmentRule // invoke the operation string ruleId = "VA1001"; - NullableResponse response = await collection.GetIfExistsAsync(ruleId); - SqlServerSqlVulnerabilityAssessmentBaselineRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task GetIfExists_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineCreate.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaseline_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineGet.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaseline_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,8 +179,8 @@ public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessme // this example assumes you already have this SqlServerSqlVulnerabilityAssessmentBaselineResource created on azure // for more information of creating SqlServerSqlVulnerabilityAssessmentBaselineResource, please refer to the document of SqlServerSqlVulnerabilityAssessmentBaselineResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityaseessmenttest-4711"; + string serverName = "vulnerabilityaseessmenttest-6411"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; ResourceIdentifier sqlServerSqlVulnerabilityAssessmentBaselineResourceId = SqlServerSqlVulnerabilityAssessmentBaselineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, vulnerabilityAssessmentName, baselineName); @@ -193,31 +191,21 @@ public async Task CreateOrUpdate_CreatesOrUpdatesADatabaseSVulnerabilityAssessme // invoke the operation string ruleId = "VA1001"; - SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent() - { - IsLatestScan = false, - Results = -{ -new string[] -{ -"userA","SELECT" -},new string[] -{ -"userB","SELECT" -},new string[] -{ -"userC","SELECT" -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleId, content); - SqlServerSqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleId); + SqlServerSqlVulnerabilityAssessmentBaselineRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineRuleResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineRuleResource.cs index 31802c6ea364c..d84d8d388d3b9 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineRuleResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentBaselineRuleResource.cs @@ -51,10 +51,10 @@ public async Task Get_GetsASystemDatabaseSSqlVulnerabilityAssessmentRuleBaseline [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineCreate.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaseline_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineDelete.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaselines_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,8 +64,8 @@ public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBa // this example assumes you already have this SqlServerSqlVulnerabilityAssessmentBaselineRuleResource created on azure // for more information of creating SqlServerSqlVulnerabilityAssessmentBaselineRuleResource, please refer to the document of SqlServerSqlVulnerabilityAssessmentBaselineRuleResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityaseessmenttest-4711"; + string serverName = "vulnerabilityaseessmenttest-6411"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; string ruleId = "VA1001"; @@ -73,39 +73,17 @@ public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBa SqlServerSqlVulnerabilityAssessmentBaselineRuleResource sqlServerSqlVulnerabilityAssessmentBaselineRule = client.GetSqlServerSqlVulnerabilityAssessmentBaselineRuleResource(sqlServerSqlVulnerabilityAssessmentBaselineRuleResourceId); // invoke the operation - SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent() - { - IsLatestScan = false, - Results = -{ -new string[] -{ -"userA","SELECT" -},new string[] -{ -"userB","SELECT" -},new string[] -{ -"userC","SELECT" -} -}, - }; - ArmOperation lro = await sqlServerSqlVulnerabilityAssessmentBaselineRule.UpdateAsync(WaitUntil.Completed, content); - SqlServerSqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; + await sqlServerSqlVulnerabilityAssessmentBaselineRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() + public async Task Update_CreatesOrUpdatesADatabaseSVulnerabilityAssessmentRuleBaseline() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineDelete.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaselines_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentRuleBaselineCreate.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentRuleBaseline_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,8 +93,8 @@ public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() // this example assumes you already have this SqlServerSqlVulnerabilityAssessmentBaselineRuleResource created on azure // for more information of creating SqlServerSqlVulnerabilityAssessmentBaselineRuleResource, please refer to the document of SqlServerSqlVulnerabilityAssessmentBaselineRuleResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4711"; - string serverName = "vulnerabilityaseessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; SqlVulnerabilityAssessmentBaselineName baselineName = SqlVulnerabilityAssessmentBaselineName.Default; string ruleId = "VA1001"; @@ -124,9 +102,19 @@ public async Task Delete_RemovesADatabaseSVulnerabilityAssessmentRuleBaseline() SqlServerSqlVulnerabilityAssessmentBaselineRuleResource sqlServerSqlVulnerabilityAssessmentBaselineRule = client.GetSqlServerSqlVulnerabilityAssessmentBaselineRuleResource(sqlServerSqlVulnerabilityAssessmentBaselineRuleResourceId); // invoke the operation - await sqlServerSqlVulnerabilityAssessmentBaselineRule.DeleteAsync(WaitUntil.Completed); + SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent content = new SqlVulnerabilityAssessmentBaselineRuleCreateOrUpdateContent + { + IsLatestScan = false, + Results = { { "userA", "SELECT" }, { "userB", "SELECT" }, { "userC", "SELECT" } }, + }; + ArmOperation lro = await sqlServerSqlVulnerabilityAssessmentBaselineRule.UpdateAsync(WaitUntil.Completed, content); + SqlServerSqlVulnerabilityAssessmentBaselineRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentBaselineRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentCollection.cs index 8416e8628a6a8..85faac9df538b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerSqlVulnerabilityAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSQLVulnerabilityAssessmentPolicies() + public async Task CreateOrUpdate_CreateASQLVulnerabilityAssessmentPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentListByServer.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentsSettings_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentCreate.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentsSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_GetSQLVulnerabilityAssessmentPolicies() // get the collection of this SqlServerSqlVulnerabilityAssessmentResource SqlServerSqlVulnerabilityAssessmentCollection collection = sqlServer.GetSqlServerSqlVulnerabilityAssessments(); - // invoke the operation and iterate over the result - await foreach (SqlServerSqlVulnerabilityAssessmentResource item in collection.GetAllAsync()) + // invoke the operation + VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; + SqlVulnerabilityAssessmentData data = new SqlVulnerabilityAssessmentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + State = SqlVulnerabilityAssessmentState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SqlServerSqlVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_GetSQLVulnerabilityAssessmentPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSQLVulnerabilityAssessmentPolicy() + public async Task GetAll_GetSQLVulnerabilityAssessmentPolicies() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentGet.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentListByServer.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentsSettings_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_GetSQLVulnerabilityAssessmentPolicy() // get the collection of this SqlServerSqlVulnerabilityAssessmentResource SqlServerSqlVulnerabilityAssessmentCollection collection = sqlServer.GetSqlServerSqlVulnerabilityAssessments(); - // invoke the operation - VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); + // invoke the operation and iterate over the result + await foreach (SqlServerSqlVulnerabilityAssessmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSQLVulnerabilityAssessmentPolicy() + public async Task Exists_GetSQLVulnerabilityAssessmentPolicy() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentGet.json // this example is just showing the usage of "SqlVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_GetSQLVulnerabilityAssessmentPolicy() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); - SqlServerSqlVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASQLVulnerabilityAssessmentPolicy() + public async Task GetIfExists_GetSQLVulnerabilityAssessmentPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentCreate.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentsSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentGet.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_CreateASQLVulnerabilityAssessmentPolicy() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - SqlVulnerabilityAssessmentData data = new SqlVulnerabilityAssessmentData() - { - State = SqlVulnerabilityAssessmentState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SqlServerSqlVulnerabilityAssessmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); + SqlServerSqlVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentResource.cs index 9ccc80e1bdd2f..1ce09ad255b0d 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerSqlVulnerabilityAssessmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task ExecuteScan_ExecutesADatabaseSVulnerabilityAssessmentScan() + public async Task Get_GetSQLVulnerabilityAssessmentPolicy() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScansExecute.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentExecuteScan_Execute" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentGet.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,24 +31,28 @@ public async Task ExecuteScan_ExecutesADatabaseSVulnerabilityAssessmentScan() // this example assumes you already have this SqlServerSqlVulnerabilityAssessmentResource created on azure // for more information of creating SqlServerSqlVulnerabilityAssessmentResource, please refer to the document of SqlServerSqlVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityassessmenttest-4711"; - string serverName = "vulnerabilityassessmenttest-6411"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlServerSqlVulnerabilityAssessmentResourceId = SqlServerSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, vulnerabilityAssessmentName); SqlServerSqlVulnerabilityAssessmentResource sqlServerSqlVulnerabilityAssessment = client.GetSqlServerSqlVulnerabilityAssessmentResource(sqlServerSqlVulnerabilityAssessmentResourceId); // invoke the operation - await sqlServerSqlVulnerabilityAssessment.ExecuteScanAsync(WaitUntil.Completed); + SqlServerSqlVulnerabilityAssessmentResource result = await sqlServerSqlVulnerabilityAssessment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSQLVulnerabilityAssessmentPolicy() + public async Task Delete_RemoveSQLVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentGet.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentsSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentDelete.json + // this example is just showing the usage of "SqlVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetSQLVulnerabilityAssessmentPolicy() SqlServerSqlVulnerabilityAssessmentResource sqlServerSqlVulnerabilityAssessment = client.GetSqlServerSqlVulnerabilityAssessmentResource(sqlServerSqlVulnerabilityAssessmentResourceId); // invoke the operation - SqlServerSqlVulnerabilityAssessmentResource result = await sqlServerSqlVulnerabilityAssessment.GetAsync(); + await sqlServerSqlVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_CreateASQLVulnerabilityAssessmentPolicy() SqlServerSqlVulnerabilityAssessmentResource sqlServerSqlVulnerabilityAssessment = client.GetSqlServerSqlVulnerabilityAssessmentResource(sqlServerSqlVulnerabilityAssessmentResourceId); // invoke the operation - SqlVulnerabilityAssessmentData data = new SqlVulnerabilityAssessmentData() + SqlVulnerabilityAssessmentData data = new SqlVulnerabilityAssessmentData { State = SqlVulnerabilityAssessmentState.Enabled, }; @@ -112,10 +112,10 @@ public async Task Update_CreateASQLVulnerabilityAssessmentPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RemoveSQLVulnerabilityAssessment() + public async Task ExecuteScan_ExecutesADatabaseSVulnerabilityAssessmentScan() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentDelete.json - // this example is just showing the usage of "SqlVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScansExecute.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentExecuteScan_Execute" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,14 +125,14 @@ public async Task Delete_RemoveSQLVulnerabilityAssessment() // this example assumes you already have this SqlServerSqlVulnerabilityAssessmentResource created on azure // for more information of creating SqlServerSqlVulnerabilityAssessmentResource, please refer to the document of SqlServerSqlVulnerabilityAssessmentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; + string resourceGroupName = "vulnerabilityassessmenttest-4711"; + string serverName = "vulnerabilityassessmenttest-6411"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; ResourceIdentifier sqlServerSqlVulnerabilityAssessmentResourceId = SqlServerSqlVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, vulnerabilityAssessmentName); SqlServerSqlVulnerabilityAssessmentResource sqlServerSqlVulnerabilityAssessment = client.GetSqlServerSqlVulnerabilityAssessmentResource(sqlServerSqlVulnerabilityAssessmentResourceId); // invoke the operation - await sqlServerSqlVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); + await sqlServerSqlVulnerabilityAssessment.ExecuteScanAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentScanCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentScanCollection.cs index 2e34259f910c7..6d6807e21c865 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentScanCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentScanCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerSqlVulnerabilityAssessmentScanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecords() + public async Task Get_GetsTheADatabaseVulnerabilityAssessmentScanRecords() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScanRecordsListByDatabase.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_ListBySqlVulnerabilityAssessments" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScan.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecord // get the collection of this SqlServerSqlVulnerabilityAssessmentScanResource SqlServerSqlVulnerabilityAssessmentScanCollection collection = sqlServerSqlVulnerabilityAssessment.GetSqlServerSqlVulnerabilityAssessmentScans(); - // invoke the operation and iterate over the result - await foreach (SqlServerSqlVulnerabilityAssessmentScanResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scanId = "scan001"; + SqlServerSqlVulnerabilityAssessmentScanResource result = await collection.GetAsync(scanId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentScanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheADatabaseVulnerabilityAssessmentScanRecords() + public async Task GetAll_GetsTheListOfADatabaseVulnerabilityAssessmentScanRecords() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScan.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScanRecordsListByDatabase.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentScans_ListBySqlVulnerabilityAssessments" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +75,17 @@ public async Task Get_GetsTheADatabaseVulnerabilityAssessmentScanRecords() // get the collection of this SqlServerSqlVulnerabilityAssessmentScanResource SqlServerSqlVulnerabilityAssessmentScanCollection collection = sqlServerSqlVulnerabilityAssessment.GetSqlServerSqlVulnerabilityAssessmentScans(); - // invoke the operation - string scanId = "scan001"; - SqlServerSqlVulnerabilityAssessmentScanResource result = await collection.GetAsync(scanId); + // invoke the operation and iterate over the result + await foreach (SqlServerSqlVulnerabilityAssessmentScanResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentScanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentScanResultCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentScanResultCollection.cs index df7dcde156875..89717612e300f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentScanResultCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerSqlVulnerabilityAssessmentScanResultCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerSqlVulnerabilityAssessmentScanResultCollect { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSystemDatabaseSQLVulnerabilityAssessmentScanResultsForScanId() + public async Task Get_GetASystemDatabaseSQLVulnerabilityAssessmentScanResultForScanIdAndScanResultId() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentListScansResults.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentScanResult_ListByScan" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScansResults.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentScanResult_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task GetAll_ListSystemDatabaseSQLVulnerabilityAssessmentScanResults // for more information of creating SqlServerSqlVulnerabilityAssessmentScanResource, please refer to the document of SqlServerSqlVulnerabilityAssessmentScanResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "vulnerabilityassessmenttest-4711"; - string serverName = "testsvr"; + string serverName = "vulnerabilityassessmenttest-6411"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; string scanId = "scanId1"; ResourceIdentifier sqlServerSqlVulnerabilityAssessmentScanResourceId = SqlServerSqlVulnerabilityAssessmentScanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, vulnerabilityAssessmentName, scanId); @@ -41,25 +41,23 @@ public async Task GetAll_ListSystemDatabaseSQLVulnerabilityAssessmentScanResults // get the collection of this SqlServerSqlVulnerabilityAssessmentScanResultResource SqlServerSqlVulnerabilityAssessmentScanResultCollection collection = sqlServerSqlVulnerabilityAssessmentScan.GetSqlServerSqlVulnerabilityAssessmentScanResults(); - // invoke the operation and iterate over the result - await foreach (SqlServerSqlVulnerabilityAssessmentScanResultResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanResultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scanResultId = "VA1234"; + SqlServerSqlVulnerabilityAssessmentScanResultResource result = await collection.GetAsync(scanResultId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentScanResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASystemDatabaseSQLVulnerabilityAssessmentScanResultForScanIdAndScanResultId() + public async Task GetAll_ListSystemDatabaseSQLVulnerabilityAssessmentScanResultsForScanId() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentScansResults.json - // this example is just showing the usage of "SqlVulnerabilityAssessmentScanResult_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-11-01-preview/examples/SqlVulnerabilityAssessmentListScansResults.json + // this example is just showing the usage of "SqlVulnerabilityAssessmentScanResult_ListByScan" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,7 +68,7 @@ public async Task Get_GetASystemDatabaseSQLVulnerabilityAssessmentScanResultForS // for more information of creating SqlServerSqlVulnerabilityAssessmentScanResource, please refer to the document of SqlServerSqlVulnerabilityAssessmentScanResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "vulnerabilityassessmenttest-4711"; - string serverName = "vulnerabilityassessmenttest-6411"; + string serverName = "testsvr"; VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; string scanId = "scanId1"; ResourceIdentifier sqlServerSqlVulnerabilityAssessmentScanResourceId = SqlServerSqlVulnerabilityAssessmentScanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, vulnerabilityAssessmentName, scanId); @@ -79,15 +77,17 @@ public async Task Get_GetASystemDatabaseSQLVulnerabilityAssessmentScanResultForS // get the collection of this SqlServerSqlVulnerabilityAssessmentScanResultResource SqlServerSqlVulnerabilityAssessmentScanResultCollection collection = sqlServerSqlVulnerabilityAssessmentScan.GetSqlServerSqlVulnerabilityAssessmentScanResults(); - // invoke the operation - string scanResultId = "VA1234"; - SqlServerSqlVulnerabilityAssessmentScanResultResource result = await collection.GetAsync(scanResultId); + // invoke the operation and iterate over the result + await foreach (SqlServerSqlVulnerabilityAssessmentScanResultResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVulnerabilityAssessmentScanResultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVulnerabilityAssessmentScanResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerTrustGroupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerTrustGroupCollection.cs index b74a235b5a1aa..e1345303c6b55 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerTrustGroupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerTrustGroupCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SqlServerTrustGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServerTrustGroup() + public async Task CreateOrUpdate_CreateServerTrustGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupGet.json - // this example is just showing the usage of "ServerTrustGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupCreate.json + // this example is just showing the usage of "ServerTrustGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,13 @@ public async Task Get_GetServerTrustGroup() // invoke the operation string serverTrustGroupName = "server-trust-group-test"; - SqlServerTrustGroupResource result = await collection.GetAsync(serverTrustGroupName); + SqlServerTrustGroupData data = new SqlServerTrustGroupData + { + GroupMembers = { new ServerTrustGroupServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/managedInstance-1")), new ServerTrustGroupServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/managedInstance-2")) }, + TrustScopes = { ServerTrustGroupPropertiesTrustScopesItem.GlobalTransactions, ServerTrustGroupPropertiesTrustScopesItem.ServiceBroker }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverTrustGroupName, data); + SqlServerTrustGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +59,7 @@ public async Task Get_GetServerTrustGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetServerTrustGroup() + public async Task Get_GetServerTrustGroup() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupGet.json // this example is just showing the usage of "ServerTrustGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +82,21 @@ public async Task Exists_GetServerTrustGroup() // invoke the operation string serverTrustGroupName = "server-trust-group-test"; - bool result = await collection.ExistsAsync(serverTrustGroupName); + SqlServerTrustGroupResource result = await collection.GetAsync(serverTrustGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerTrustGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetServerTrustGroup() + public async Task GetAll_ListServerTrustGroups() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupGet.json - // this example is just showing the usage of "ServerTrustGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupList.json + // this example is just showing the usage of "ServerTrustGroups_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,31 +114,25 @@ public async Task GetIfExists_GetServerTrustGroup() AzureLocation locationName = new AzureLocation("Japan East"); SqlServerTrustGroupCollection collection = resourceGroupResource.GetSqlServerTrustGroups(locationName); - // invoke the operation - string serverTrustGroupName = "server-trust-group-test"; - NullableResponse response = await collection.GetIfExistsAsync(serverTrustGroupName); - SqlServerTrustGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerTrustGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerTrustGroupData resourceData = result.Data; + SqlServerTrustGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateServerTrustGroup() + public async Task Exists_GetServerTrustGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupCreate.json - // this example is just showing the usage of "ServerTrustGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupGet.json + // this example is just showing the usage of "ServerTrustGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,33 +152,17 @@ public async Task CreateOrUpdate_CreateServerTrustGroup() // invoke the operation string serverTrustGroupName = "server-trust-group-test"; - SqlServerTrustGroupData data = new SqlServerTrustGroupData() - { - GroupMembers = -{ -new ServerTrustGroupServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/managedInstance-1")),new ServerTrustGroupServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/managedInstance-2")) -}, - TrustScopes = -{ -ServerTrustGroupPropertiesTrustScopesItem.GlobalTransactions,ServerTrustGroupPropertiesTrustScopesItem.ServiceBroker -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverTrustGroupName, data); - SqlServerTrustGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(serverTrustGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerTrustGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListServerTrustGroups() + public async Task GetIfExists_GetServerTrustGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupList.json - // this example is just showing the usage of "ServerTrustGroups_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupGet.json + // this example is just showing the usage of "ServerTrustGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,17 +180,23 @@ public async Task GetAll_ListServerTrustGroups() AzureLocation locationName = new AzureLocation("Japan East"); SqlServerTrustGroupCollection collection = resourceGroupResource.GetSqlServerTrustGroups(locationName); - // invoke the operation and iterate over the result - await foreach (SqlServerTrustGroupResource item in collection.GetAllAsync()) + // invoke the operation + string serverTrustGroupName = "server-trust-group-test"; + NullableResponse response = await collection.GetIfExistsAsync(serverTrustGroupName); + SqlServerTrustGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerTrustGroupData resourceData = item.Data; + SqlServerTrustGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerTrustGroupResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerTrustGroupResource.cs index 7019d9310b542..15abebc3c93c3 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerTrustGroupResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerTrustGroupResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetServerTrustGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateServerTrustGroup() + public async Task Delete_DropServerTrustGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupCreate.json - // this example is just showing the usage of "ServerTrustGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupDelete.json + // this example is just showing the usage of "ServerTrustGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,33 +69,17 @@ public async Task Update_CreateServerTrustGroup() SqlServerTrustGroupResource sqlServerTrustGroup = client.GetSqlServerTrustGroupResource(sqlServerTrustGroupResourceId); // invoke the operation - SqlServerTrustGroupData data = new SqlServerTrustGroupData() - { - GroupMembers = -{ -new ServerTrustGroupServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/managedInstance-1")),new ServerTrustGroupServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/managedInstance-2")) -}, - TrustScopes = -{ -ServerTrustGroupPropertiesTrustScopesItem.GlobalTransactions,ServerTrustGroupPropertiesTrustScopesItem.ServiceBroker -}, - }; - ArmOperation lro = await sqlServerTrustGroup.UpdateAsync(WaitUntil.Completed, data); - SqlServerTrustGroupResource result = lro.Value; + await sqlServerTrustGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerTrustGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DropServerTrustGroup() + public async Task Update_CreateServerTrustGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupDelete.json - // this example is just showing the usage of "ServerTrustGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerTrustGroupCreate.json + // this example is just showing the usage of "ServerTrustGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,9 +96,19 @@ public async Task Delete_DropServerTrustGroup() SqlServerTrustGroupResource sqlServerTrustGroup = client.GetSqlServerTrustGroupResource(sqlServerTrustGroupResourceId); // invoke the operation - await sqlServerTrustGroup.DeleteAsync(WaitUntil.Completed); + SqlServerTrustGroupData data = new SqlServerTrustGroupData + { + GroupMembers = { new ServerTrustGroupServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/managedInstance-1")), new ServerTrustGroupServerInfo(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Sql/managedInstances/managedInstance-2")) }, + TrustScopes = { ServerTrustGroupPropertiesTrustScopesItem.GlobalTransactions, ServerTrustGroupPropertiesTrustScopesItem.ServiceBroker }, + }; + ArmOperation lro = await sqlServerTrustGroup.UpdateAsync(WaitUntil.Completed, data); + SqlServerTrustGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerTrustGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVirtualNetworkRuleCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVirtualNetworkRuleCollection.cs index 4da12b47b7b94..0243dc08ec830 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVirtualNetworkRuleCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVirtualNetworkRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SqlServerVirtualNetworkRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAVirtualNetworkRule() + public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesGet.json - // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesCreateOrUpdate.json + // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,13 @@ public async Task Get_GetsAVirtualNetworkRule() // invoke the operation string virtualNetworkRuleName = "vnet-firewall-rule"; - SqlServerVirtualNetworkRuleResource result = await collection.GetAsync(virtualNetworkRuleName); + SqlServerVirtualNetworkRuleData data = new SqlServerVirtualNetworkRuleData + { + VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + IgnoreMissingVnetServiceEndpoint = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkRuleName, data); + SqlServerVirtualNetworkRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +57,7 @@ public async Task Get_GetsAVirtualNetworkRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAVirtualNetworkRule() + public async Task Get_GetsAVirtualNetworkRule() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesGet.json // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +80,21 @@ public async Task Exists_GetsAVirtualNetworkRule() // invoke the operation string virtualNetworkRuleName = "vnet-firewall-rule"; - bool result = await collection.ExistsAsync(virtualNetworkRuleName); + SqlServerVirtualNetworkRuleResource result = await collection.GetAsync(virtualNetworkRuleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerVirtualNetworkRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAVirtualNetworkRule() + public async Task GetAll_ListVirtualNetworkRules() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesGet.json - // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesList.json + // this example is just showing the usage of "VirtualNetworkRules_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +112,25 @@ public async Task GetIfExists_GetsAVirtualNetworkRule() // get the collection of this SqlServerVirtualNetworkRuleResource SqlServerVirtualNetworkRuleCollection collection = sqlServer.GetSqlServerVirtualNetworkRules(); - // invoke the operation - string virtualNetworkRuleName = "vnet-firewall-rule"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkRuleName); - SqlServerVirtualNetworkRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlServerVirtualNetworkRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerVirtualNetworkRuleData resourceData = result.Data; + SqlServerVirtualNetworkRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() + public async Task Exists_GetsAVirtualNetworkRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesCreateOrUpdate.json - // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesGet.json + // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,27 +150,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() // invoke the operation string virtualNetworkRuleName = "vnet-firewall-rule"; - SqlServerVirtualNetworkRuleData data = new SqlServerVirtualNetworkRuleData() - { - VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), - IgnoreMissingVnetServiceEndpoint = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkRuleName, data); - SqlServerVirtualNetworkRuleResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualNetworkRuleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerVirtualNetworkRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworkRules() + public async Task GetIfExists_GetsAVirtualNetworkRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesList.json - // this example is just showing the usage of "VirtualNetworkRules_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesGet.json + // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListVirtualNetworkRules() // get the collection of this SqlServerVirtualNetworkRuleResource SqlServerVirtualNetworkRuleCollection collection = sqlServer.GetSqlServerVirtualNetworkRules(); - // invoke the operation and iterate over the result - await foreach (SqlServerVirtualNetworkRuleResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkRuleName = "vnet-firewall-rule"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkRuleName); + SqlServerVirtualNetworkRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerVirtualNetworkRuleData resourceData = item.Data; + SqlServerVirtualNetworkRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVirtualNetworkRuleResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVirtualNetworkRuleResource.cs index 605f21232db11..6512160b4a529 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVirtualNetworkRuleResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVirtualNetworkRuleResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetsAVirtualNetworkRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAVirtualNetworkRule() + public async Task Delete_DeleteAVirtualNetworkRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesCreateOrUpdate.json - // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesDelete.json + // this example is just showing the usage of "VirtualNetworkRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,27 +68,17 @@ public async Task Update_CreateOrUpdateAVirtualNetworkRule() SqlServerVirtualNetworkRuleResource sqlServerVirtualNetworkRule = client.GetSqlServerVirtualNetworkRuleResource(sqlServerVirtualNetworkRuleResourceId); // invoke the operation - SqlServerVirtualNetworkRuleData data = new SqlServerVirtualNetworkRuleData() - { - VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), - IgnoreMissingVnetServiceEndpoint = false, - }; - ArmOperation lro = await sqlServerVirtualNetworkRule.UpdateAsync(WaitUntil.Completed, data); - SqlServerVirtualNetworkRuleResource result = lro.Value; + await sqlServerVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerVirtualNetworkRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAVirtualNetworkRule() + public async Task Update_CreateOrUpdateAVirtualNetworkRule() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesDelete.json - // this example is just showing the usage of "VirtualNetworkRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/VirtualNetworkRulesCreateOrUpdate.json + // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +95,19 @@ public async Task Delete_DeleteAVirtualNetworkRule() SqlServerVirtualNetworkRuleResource sqlServerVirtualNetworkRule = client.GetSqlServerVirtualNetworkRuleResource(sqlServerVirtualNetworkRuleResourceId); // invoke the operation - await sqlServerVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); + SqlServerVirtualNetworkRuleData data = new SqlServerVirtualNetworkRuleData + { + VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + IgnoreMissingVnetServiceEndpoint = false, + }; + ArmOperation lro = await sqlServerVirtualNetworkRule.UpdateAsync(WaitUntil.Completed, data); + SqlServerVirtualNetworkRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerVirtualNetworkRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVulnerabilityAssessmentCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVulnerabilityAssessmentCollection.cs index de3323f72b528..dd1fa9b042a2b 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVulnerabilityAssessmentCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVulnerabilityAssessmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlServerVulnerabilityAssessmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateAServerSVulnerabilityAssessmentWithAllParameters() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentGet.json - // this example is just showing the usage of "ServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentCreateMax.json + // this example is just showing the usage of "ServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,20 @@ public async Task Get_GetAServerSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - SqlServerVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); + SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + RecurringScans = new VulnerabilityAssessmentRecurringScansProperties + { + IsEnabled = true, + EmailSubscriptionAdmins = true, + Emails = { "email1@mail.com", "email2@mail.com" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SqlServerVulnerabilityAssessmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +65,10 @@ public async Task Get_GetAServerSVulnerabilityAssessment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateAServerSVulnerabilityAssessmentWithMinimalParametersWhenStorageAccountAccessKeyIsSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentGet.json - // this example is just showing the usage of "ServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentCreateStorageAccessKeyMin.json + // this example is just showing the usage of "ServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +88,27 @@ public async Task Exists_GetAServerSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); + SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData + { + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SqlServerVulnerabilityAssessmentResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerSVulnerabilityAssessment() + public async Task CreateOrUpdate_CreateAServerSVulnerabilityAssessmentWithMinimalParametersWhenStorageContainerSasKeyIsSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentGet.json - // this example is just showing the usage of "ServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentCreateContainerSasKeyMin.json + // this example is just showing the usage of "ServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,29 +128,27 @@ public async Task GetIfExists_GetAServerSVulnerabilityAssessment() // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); - SqlServerVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", + StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); + SqlServerVulnerabilityAssessmentResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerVulnerabilityAssessmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAServerSVulnerabilityAssessmentWithAllParameters() + public async Task Get_GetAServerSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentCreateMax.json - // this example is just showing the usage of "ServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentGet.json + // this example is just showing the usage of "ServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,23 +168,7 @@ public async Task CreateOrUpdate_CreateAServerSVulnerabilityAssessmentWithAllPar // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new VulnerabilityAssessmentRecurringScansProperties() - { - IsEnabled = true, - EmailSubscriptionAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SqlServerVulnerabilityAssessmentResource result = lro.Value; + SqlServerVulnerabilityAssessmentResource result = await collection.GetAsync(vulnerabilityAssessmentName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -174,10 +179,10 @@ public async Task CreateOrUpdate_CreateAServerSVulnerabilityAssessmentWithAllPar [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAServerSVulnerabilityAssessmentWithMinimalParametersWhenStorageAccountAccessKeyIsSpecified() + public async Task GetAll_GetAServerSVulnerabilityAssessmentPolicies() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentCreateStorageAccessKeyMin.json - // this example is just showing the usage of "ServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentListByServer.json + // this example is just showing the usage of "ServerVulnerabilityAssessments_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,29 +200,25 @@ public async Task CreateOrUpdate_CreateAServerSVulnerabilityAssessmentWithMinima // get the collection of this SqlServerVulnerabilityAssessmentResource SqlServerVulnerabilityAssessmentCollection collection = sqlServer.GetSqlServerVulnerabilityAssessments(); - // invoke the operation - VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData() + // invoke the operation and iterate over the result + await foreach (SqlServerVulnerabilityAssessmentResource item in collection.GetAllAsync()) { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SqlServerVulnerabilityAssessmentResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerVulnerabilityAssessmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAServerSVulnerabilityAssessmentWithMinimalParametersWhenStorageContainerSasKeyIsSpecified() + public async Task Exists_GetAServerSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentCreateContainerSasKeyMin.json - // this example is just showing the usage of "ServerVulnerabilityAssessments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentGet.json + // this example is just showing the usage of "ServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -237,27 +238,17 @@ public async Task CreateOrUpdate_CreateAServerSVulnerabilityAssessmentWithMinima // invoke the operation VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData() - { - StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", - StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vulnerabilityAssessmentName, data); - SqlServerVulnerabilityAssessmentResource result = lro.Value; + bool result = await collection.ExistsAsync(vulnerabilityAssessmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlServerVulnerabilityAssessmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAServerSVulnerabilityAssessmentPolicies() + public async Task GetIfExists_GetAServerSVulnerabilityAssessment() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentListByServer.json - // this example is just showing the usage of "ServerVulnerabilityAssessments_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentGet.json + // this example is just showing the usage of "ServerVulnerabilityAssessments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -275,17 +266,23 @@ public async Task GetAll_GetAServerSVulnerabilityAssessmentPolicies() // get the collection of this SqlServerVulnerabilityAssessmentResource SqlServerVulnerabilityAssessmentCollection collection = sqlServer.GetSqlServerVulnerabilityAssessments(); - // invoke the operation and iterate over the result - await foreach (SqlServerVulnerabilityAssessmentResource item in collection.GetAllAsync()) + // invoke the operation + VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; + NullableResponse response = await collection.GetIfExistsAsync(vulnerabilityAssessmentName); + SqlServerVulnerabilityAssessmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlServerVulnerabilityAssessmentData resourceData = item.Data; + SqlServerVulnerabilityAssessmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVulnerabilityAssessmentResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVulnerabilityAssessmentResource.cs index 871466ae75e8c..29b9a74666310 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVulnerabilityAssessmentResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlServerVulnerabilityAssessmentResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetAServerSVulnerabilityAssessment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_RemoveAServerSVulnerabilityAssessment() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentDelete.json + // this example is just showing the usage of "ServerVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SqlServerVulnerabilityAssessmentResource created on azure + // for more information of creating SqlServerVulnerabilityAssessmentResource, please refer to the document of SqlServerVulnerabilityAssessmentResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "vulnerabilityaseessmenttest-4799"; + string serverName = "vulnerabilityaseessmenttest-6440"; + VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; + ResourceIdentifier sqlServerVulnerabilityAssessmentResourceId = SqlServerVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, vulnerabilityAssessmentName); + SqlServerVulnerabilityAssessmentResource sqlServerVulnerabilityAssessment = client.GetSqlServerVulnerabilityAssessmentResource(sqlServerVulnerabilityAssessmentResourceId); + + // invoke the operation + await sqlServerVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateAServerSVulnerabilityAssessmentWithAllParameters() @@ -69,19 +96,16 @@ public async Task Update_CreateAServerSVulnerabilityAssessmentWithAllParameters( SqlServerVulnerabilityAssessmentResource sqlServerVulnerabilityAssessment = client.GetSqlServerVulnerabilityAssessmentResource(sqlServerVulnerabilityAssessmentResourceId); // invoke the operation - SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData() + SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", - RecurringScans = new VulnerabilityAssessmentRecurringScansProperties() + RecurringScans = new VulnerabilityAssessmentRecurringScansProperties { IsEnabled = true, EmailSubscriptionAdmins = true, - Emails = -{ -"email1@mail.com","email2@mail.com" -}, + Emails = { "email1@mail.com", "email2@mail.com" }, }, }; ArmOperation lro = await sqlServerVulnerabilityAssessment.UpdateAsync(WaitUntil.Completed, data); @@ -116,7 +140,7 @@ public async Task Update_CreateAServerSVulnerabilityAssessmentWithMinimalParamet SqlServerVulnerabilityAssessmentResource sqlServerVulnerabilityAssessment = client.GetSqlServerVulnerabilityAssessmentResource(sqlServerVulnerabilityAssessmentResourceId); // invoke the operation - SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData() + SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageAccountAccessKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -153,7 +177,7 @@ public async Task Update_CreateAServerSVulnerabilityAssessmentWithMinimalParamet SqlServerVulnerabilityAssessmentResource sqlServerVulnerabilityAssessment = client.GetSqlServerVulnerabilityAssessmentResource(sqlServerVulnerabilityAssessmentResourceId); // invoke the operation - SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData() + SqlServerVulnerabilityAssessmentData data = new SqlServerVulnerabilityAssessmentData { StorageContainerPath = "https://myStorage.blob.core.windows.net/vulnerability-assessment/", StorageContainerSasKey = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", @@ -167,32 +191,5 @@ public async Task Update_CreateAServerSVulnerabilityAssessmentWithMinimalParamet // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_RemoveAServerSVulnerabilityAssessment() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ServerVulnerabilityAssessmentDelete.json - // this example is just showing the usage of "ServerVulnerabilityAssessments_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SqlServerVulnerabilityAssessmentResource created on azure - // for more information of creating SqlServerVulnerabilityAssessmentResource, please refer to the document of SqlServerVulnerabilityAssessmentResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "vulnerabilityaseessmenttest-4799"; - string serverName = "vulnerabilityaseessmenttest-6440"; - VulnerabilityAssessmentName vulnerabilityAssessmentName = VulnerabilityAssessmentName.Default; - ResourceIdentifier sqlServerVulnerabilityAssessmentResourceId = SqlServerVulnerabilityAssessmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, vulnerabilityAssessmentName); - SqlServerVulnerabilityAssessmentResource sqlServerVulnerabilityAssessment = client.GetSqlServerVulnerabilityAssessmentResource(sqlServerVulnerabilityAssessmentResourceId); - - // invoke the operation - await sqlServerVulnerabilityAssessment.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlTimeZoneCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlTimeZoneCollection.cs index 4812ae12853ef..5d41b01625f62 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlTimeZoneCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SqlTimeZoneCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlTimeZoneCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedInstanceTimeZonesByLocation() + public async Task Get_GetManagedInstanceTimeZone() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceTimeZoneListByLocation.json - // this example is just showing the usage of "TimeZones_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceTimeZoneGet.json + // this example is just showing the usage of "TimeZones_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListManagedInstanceTimeZonesByLocation() AzureLocation locationName = new AzureLocation("canadaeast"); SqlTimeZoneCollection collection = subscriptionResource.GetSqlTimeZones(locationName); - // invoke the operation and iterate over the result - await foreach (SqlTimeZoneResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlTimeZoneData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string timeZoneId = "Haiti Standard Time"; + SqlTimeZoneResource result = await collection.GetAsync(timeZoneId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlTimeZoneData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedInstanceTimeZone() + public async Task GetAll_ListManagedInstanceTimeZonesByLocation() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceTimeZoneGet.json - // this example is just showing the usage of "TimeZones_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/ManagedInstanceTimeZoneListByLocation.json + // this example is just showing the usage of "TimeZones_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetManagedInstanceTimeZone() AzureLocation locationName = new AzureLocation("canadaeast"); SqlTimeZoneCollection collection = subscriptionResource.GetSqlTimeZones(locationName); - // invoke the operation - string timeZoneId = "Haiti Standard Time"; - SqlTimeZoneResource result = await collection.GetAsync(timeZoneId); + // invoke the operation and iterate over the result + await foreach (SqlTimeZoneResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlTimeZoneData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlTimeZoneData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionBackupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionBackupCollection.cs index b094d6dca4254..a42ac414624b4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionBackupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionBackupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SubscriptionLongTermRetentionBackupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() + public async Task Get_GetTheLongTermRetentionBackup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupListByDatabase.json - // this example is just showing the usage of "LongTermRetentionBackups_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupGet.json + // this example is just showing the usage of "LongTermRetentionBackups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() string longTermRetentionDatabaseName = "testDatabase"; SubscriptionLongTermRetentionBackupCollection collection = subscriptionResource.GetSubscriptionLongTermRetentionBackups(locationName, longTermRetentionServerName, longTermRetentionDatabaseName); - // invoke the operation and iterate over the result - await foreach (SubscriptionLongTermRetentionBackupResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LongTermRetentionBackupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string backupName = "55555555-6666-7777-8888-999999999999;131637960820000000;Archive"; + SubscriptionLongTermRetentionBackupResource result = await collection.GetAsync(backupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LongTermRetentionBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheLongTermRetentionBackup() + public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupGet.json - // this example is just showing the usage of "LongTermRetentionBackups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/LongTermRetentionBackupListByDatabase.json + // this example is just showing the usage of "LongTermRetentionBackups_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +75,17 @@ public async Task Get_GetTheLongTermRetentionBackup() string longTermRetentionDatabaseName = "testDatabase"; SubscriptionLongTermRetentionBackupCollection collection = subscriptionResource.GetSubscriptionLongTermRetentionBackups(locationName, longTermRetentionServerName, longTermRetentionDatabaseName); - // invoke the operation - string backupName = "55555555-6666-7777-8888-999999999999;131637960820000000;Archive"; - SubscriptionLongTermRetentionBackupResource result = await collection.GetAsync(backupName); + // invoke the operation and iterate over the result + await foreach (SubscriptionLongTermRetentionBackupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LongTermRetentionBackupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LongTermRetentionBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionBackupResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionBackupResource.cs index 64c29b64859b8..e10ca1dd47e44 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionBackupResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionBackupResource.cs @@ -133,7 +133,7 @@ public async Task Copy_CopyTheLongTermRetentionBackup() SubscriptionLongTermRetentionBackupResource subscriptionLongTermRetentionBackup = client.GetSubscriptionLongTermRetentionBackupResource(subscriptionLongTermRetentionBackupResourceId); // invoke the operation - CopyLongTermRetentionBackupContent content = new CopyLongTermRetentionBackupContent() + CopyLongTermRetentionBackupContent content = new CopyLongTermRetentionBackupContent { TargetServerResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/providers/Microsoft.Sql/resourceGroups/resourceGroup/servers/testserver2"), TargetDatabaseName = "testDatabase2", @@ -168,7 +168,7 @@ public async Task Update_UpdateTheLongTermRetentionBackup() SubscriptionLongTermRetentionBackupResource subscriptionLongTermRetentionBackup = client.GetSubscriptionLongTermRetentionBackupResource(subscriptionLongTermRetentionBackupResourceId); // invoke the operation - UpdateLongTermRetentionBackupContent content = new UpdateLongTermRetentionBackupContent() + UpdateLongTermRetentionBackupContent content = new UpdateLongTermRetentionBackupContent { RequestedBackupStorageRedundancy = SqlBackupStorageRedundancy.Geo, }; diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionManagedInstanceBackupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionManagedInstanceBackupCollection.cs index 40e8f43d01636..ba7d0574487da 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionManagedInstanceBackupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionLongTermRetentionManagedInstanceBackupCollection.cs @@ -53,10 +53,10 @@ public async Task Get_GetTheLongTermRetentionBackupOfAManagedDatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheLongTermRetentionBackupOfAManagedDatabase() + public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupGet.json - // this example is just showing the usage of "LongTermRetentionManagedInstanceBackups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupListByDatabase.json + // this example is just showing the usage of "LongTermRetentionManagedInstanceBackups_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,16 +75,22 @@ public async Task Exists_GetTheLongTermRetentionBackupOfAManagedDatabase() string databaseName = "testDatabase"; SubscriptionLongTermRetentionManagedInstanceBackupCollection collection = subscriptionResource.GetSubscriptionLongTermRetentionManagedInstanceBackups(locationName, managedInstanceName, databaseName); - // invoke the operation - string backupName = "55555555-6666-7777-8888-999999999999;131637960820000000"; - bool result = await collection.ExistsAsync(backupName); + // invoke the operation and iterate over the result + await foreach (SubscriptionLongTermRetentionManagedInstanceBackupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceLongTermRetentionBackupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheLongTermRetentionBackupOfAManagedDatabase() + public async Task Exists_GetTheLongTermRetentionBackupOfAManagedDatabase() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupGet.json // this example is just showing the usage of "LongTermRetentionManagedInstanceBackups_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,29 +114,17 @@ public async Task GetIfExists_GetTheLongTermRetentionBackupOfAManagedDatabase() // invoke the operation string backupName = "55555555-6666-7777-8888-999999999999;131637960820000000"; - NullableResponse response = await collection.GetIfExistsAsync(backupName); - SubscriptionLongTermRetentionManagedInstanceBackupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(backupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedInstanceLongTermRetentionBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() + public async Task GetIfExists_GetTheLongTermRetentionBackupOfAManagedDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupListByDatabase.json - // this example is just showing the usage of "LongTermRetentionManagedInstanceBackups_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2021-05-01-preview/examples/ManagedInstanceLongTermRetentionBackupGet.json + // this example is just showing the usage of "LongTermRetentionManagedInstanceBackups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,17 +143,23 @@ public async Task GetAll_GetAllLongTermRetentionBackupsUnderTheDatabase() string databaseName = "testDatabase"; SubscriptionLongTermRetentionManagedInstanceBackupCollection collection = subscriptionResource.GetSubscriptionLongTermRetentionManagedInstanceBackups(locationName, managedInstanceName, databaseName); - // invoke the operation and iterate over the result - await foreach (SubscriptionLongTermRetentionManagedInstanceBackupResource item in collection.GetAllAsync()) + // invoke the operation + string backupName = "55555555-6666-7777-8888-999999999999;131637960820000000"; + NullableResponse response = await collection.GetIfExistsAsync(backupName); + SubscriptionLongTermRetentionManagedInstanceBackupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedInstanceLongTermRetentionBackupData resourceData = item.Data; + ManagedInstanceLongTermRetentionBackupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 266379190f3eb..bde85a65d39e0 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.Sql.Models; using NUnit.Framework; @@ -17,6 +18,37 @@ namespace Azure.ResourceManager.Sql.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeletedServers_ListDeletedServersInASubscription() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeletedServerListBySubscription.json + // this example is just showing the usage of "DeletedServers_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeletedServerResource item in subscriptionResource.GetDeletedServersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeletedServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetCapabilitiesByLocation_ListSubscriptionCapabilitiesInTheGivenLocation() @@ -42,6 +74,34 @@ public async Task GetCapabilitiesByLocation_ListSubscriptionCapabilitiesInTheGiv Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSyncDatabaseIdsSyncGroups_GetASyncDatabaseID() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGetSyncDatabaseId.json + // this example is just showing the usage of "SyncGroups_ListSyncDatabaseIds" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation locationName = new AzureLocation("westus"); + await foreach (SubResource item in subscriptionResource.GetSyncDatabaseIdsSyncGroupsAsync(locationName)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetLongTermRetentionManagedInstanceBackupsWithInstance_GetAllLongTermRetentionBackupsUnderTheManagedInstance() @@ -101,6 +161,130 @@ public async Task GetLongTermRetentionManagedInstanceBackupsWithLocation_GetAllL Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualClusters_ListVirtualClusters() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterList.json + // this example is just showing the usage of "VirtualClusters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "20d7082a-0fc7-4468-82bd-542694d5042b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VirtualClusterResource item in subscriptionResource.GetVirtualClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetManagedInstances_ListManagedInstances() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceList.json + // this example is just showing the usage of "ManagedInstances_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ManagedInstanceResource item in subscriptionResource.GetManagedInstancesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetManagedInstances_ListManagedInstancesWithExpandAdministratorsActivedirectory() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-08-01-preview/examples/ManagedInstanceListWithExpandEqualsAdministrators.json + // this example is just showing the usage of "ManagedInstances_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "20D7082A-0FC7-4468-82BD-542694D5042B"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ManagedInstanceResource item in subscriptionResource.GetManagedInstancesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetInstancePools_ListInstancePoolsInTheSubscription() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ListInstancePoolsBySubscriptionId.json + // this example is just showing the usage of "InstancePools_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (InstancePoolResource item in subscriptionResource.GetInstancePoolsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InstancePoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetLongTermRetentionBackupsWithLocation_GetAllLongTermRetentionBackupsUnderTheLocation() @@ -159,5 +343,142 @@ public async Task GetLongTermRetentionBackupsWithServer_GetAllLongTermRetentionB Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckSqlServerNameAvailability_CheckForAServerNameThatAlreadyExists() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CheckNameAvailabilityServerAlreadyExists.json + // this example is just showing the usage of "Servers_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + SqlNameAvailabilityContent content = new SqlNameAvailabilityContent("server1"); + SqlNameAvailabilityResponse result = await subscriptionResource.CheckSqlServerNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckSqlServerNameAvailability_CheckForAServerNameThatIsAvailable() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CheckNameAvailabilityServerAvailable.json + // this example is just showing the usage of "Servers_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + SqlNameAvailabilityContent content = new SqlNameAvailabilityContent("server1"); + SqlNameAvailabilityResponse result = await subscriptionResource.CheckSqlServerNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckSqlServerNameAvailability_CheckForAServerNameThatIsInvalid() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/CheckNameAvailabilityServerInvalid.json + // this example is just showing the usage of "Servers_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + SqlNameAvailabilityContent content = new SqlNameAvailabilityContent("SERVER1"); + SqlNameAvailabilityResponse result = await subscriptionResource.CheckSqlServerNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSqlServers_ListServers() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerList.json + // this example is just showing the usage of "Servers_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SqlServerResource item in subscriptionResource.GetSqlServersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSqlServers_ListServersWithExpandAdministratorsActivedirectory() + { + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2023-05-01-preview/examples/ServerListWithExpandEqualsAdministrators.json + // this example is just showing the usage of "Servers_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SqlServerResource item in subscriptionResource.GetSqlServersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionUsageCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionUsageCollection.cs index f0ab031cb9c30..e56cdbfa1bed4 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionUsageCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SubscriptionUsageCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SubscriptionUsageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSubscriptionUsagesInTheGivenLocation() + public async Task Get_GetSpecificSubscriptionUsageInTheGivenLocation() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SubscriptionUsageListByLocation.json - // this example is just showing the usage of "SubscriptionUsages_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SubscriptionUsageGet.json + // this example is just showing the usage of "SubscriptionUsages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListSubscriptionUsagesInTheGivenLocation() AzureLocation locationName = new AzureLocation("WestUS"); SubscriptionUsageCollection collection = subscriptionResource.GetSubscriptionUsages(locationName); - // invoke the operation and iterate over the result - await foreach (SubscriptionUsageResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionUsageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string usageName = "ServerQuota"; + SubscriptionUsageResource result = await collection.GetAsync(usageName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionUsageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSpecificSubscriptionUsageInTheGivenLocation() + public async Task GetAll_ListSubscriptionUsagesInTheGivenLocation() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SubscriptionUsageGet.json - // this example is just showing the usage of "SubscriptionUsages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SubscriptionUsageListByLocation.json + // this example is just showing the usage of "SubscriptionUsages_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetSpecificSubscriptionUsageInTheGivenLocation() AzureLocation locationName = new AzureLocation("WestUS"); SubscriptionUsageCollection collection = subscriptionResource.GetSubscriptionUsages(locationName); - // invoke the operation - string usageName = "ServerQuota"; - SubscriptionUsageResource result = await collection.GetAsync(usageName); + // invoke the operation and iterate over the result + await foreach (SubscriptionUsageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionUsageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionUsageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncAgentCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncAgentCollection.cs index a1e0a717e939c..e7248f7f2644f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncAgentCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncAgentCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SyncAgentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASyncAgent() + public async Task CreateOrUpdate_CreateANewSyncAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentGet.json - // this example is just showing the usage of "SyncAgents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentCreate.json + // this example is just showing the usage of "SyncAgents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetASyncAgent() // invoke the operation string syncAgentName = "syncagentcrud-3187"; - SyncAgentResource result = await collection.GetAsync(syncAgentName); + SyncAgentData data = new SyncAgentData + { + SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-Onebox/providers/Microsoft.Sql/servers/syncagentcrud-8475/databases/sync"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncAgentName, data); + SyncAgentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +56,10 @@ public async Task Get_GetASyncAgent() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASyncAgent() + public async Task CreateOrUpdate_UpdateASyncAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentGet.json - // this example is just showing the usage of "SyncAgents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentUpdate.json + // this example is just showing the usage of "SyncAgents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,14 +79,23 @@ public async Task Exists_GetASyncAgent() // invoke the operation string syncAgentName = "syncagentcrud-3187"; - bool result = await collection.ExistsAsync(syncAgentName); + SyncAgentData data = new SyncAgentData + { + SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-Onebox/providers/Microsoft.Sql/servers/syncagentcrud-8475/databases/sync"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncAgentName, data); + SyncAgentResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncAgentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASyncAgent() + public async Task Get_GetASyncAgent() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentGet.json // this example is just showing the usage of "SyncAgents_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +118,21 @@ public async Task GetIfExists_GetASyncAgent() // invoke the operation string syncAgentName = "syncagentcrud-3187"; - NullableResponse response = await collection.GetIfExistsAsync(syncAgentName); - SyncAgentResource result = response.HasValue ? response.Value : null; + SyncAgentResource result = await collection.GetAsync(syncAgentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncAgentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncAgentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateANewSyncAgent() + public async Task GetAll_GetSyncAgentsUnderAServer() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentCreate.json - // this example is just showing the usage of "SyncAgents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentListByServer.json + // this example is just showing the usage of "SyncAgents_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,28 +150,25 @@ public async Task CreateOrUpdate_CreateANewSyncAgent() // get the collection of this SyncAgentResource SyncAgentCollection collection = sqlServer.GetSyncAgents(); - // invoke the operation - string syncAgentName = "syncagentcrud-3187"; - SyncAgentData data = new SyncAgentData() + // invoke the operation and iterate over the result + await foreach (SyncAgentResource item in collection.GetAllAsync()) { - SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-Onebox/providers/Microsoft.Sql/servers/syncagentcrud-8475/databases/sync"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncAgentName, data); - SyncAgentResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncAgentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncAgentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateASyncAgent() + public async Task Exists_GetASyncAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentUpdate.json - // this example is just showing the usage of "SyncAgents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentGet.json + // this example is just showing the usage of "SyncAgents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,26 +188,17 @@ public async Task CreateOrUpdate_UpdateASyncAgent() // invoke the operation string syncAgentName = "syncagentcrud-3187"; - SyncAgentData data = new SyncAgentData() - { - SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-Onebox/providers/Microsoft.Sql/servers/syncagentcrud-8475/databases/sync"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncAgentName, data); - SyncAgentResource result = lro.Value; + bool result = await collection.ExistsAsync(syncAgentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncAgentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSyncAgentsUnderAServer() + public async Task GetIfExists_GetASyncAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentListByServer.json - // this example is just showing the usage of "SyncAgents_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentGet.json + // this example is just showing the usage of "SyncAgents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -222,17 +216,23 @@ public async Task GetAll_GetSyncAgentsUnderAServer() // get the collection of this SyncAgentResource SyncAgentCollection collection = sqlServer.GetSyncAgents(); - // invoke the operation and iterate over the result - await foreach (SyncAgentResource item in collection.GetAllAsync()) + // invoke the operation + string syncAgentName = "syncagentcrud-3187"; + NullableResponse response = await collection.GetIfExistsAsync(syncAgentName); + SyncAgentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SyncAgentData resourceData = item.Data; + SyncAgentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncAgentResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncAgentResource.cs index 8b179bca39e8f..f6941619e7716 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncAgentResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncAgentResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetASyncAgent() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateANewSyncAgent() + public async Task Delete_DeleteASyncAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentCreate.json - // this example is just showing the usage of "SyncAgents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentDelete.json + // this example is just showing the usage of "SyncAgents_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,25 +69,16 @@ public async Task Update_CreateANewSyncAgent() SyncAgentResource syncAgent = client.GetSyncAgentResource(syncAgentResourceId); // invoke the operation - SyncAgentData data = new SyncAgentData() - { - SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-Onebox/providers/Microsoft.Sql/servers/syncagentcrud-8475/databases/sync"), - }; - ArmOperation lro = await syncAgent.UpdateAsync(WaitUntil.Completed, data); - SyncAgentResource result = lro.Value; + await syncAgent.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncAgentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASyncAgent() + public async Task Update_CreateANewSyncAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentUpdate.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentCreate.json // this example is just showing the usage of "SyncAgents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -105,7 +96,7 @@ public async Task Update_UpdateASyncAgent() SyncAgentResource syncAgent = client.GetSyncAgentResource(syncAgentResourceId); // invoke the operation - SyncAgentData data = new SyncAgentData() + SyncAgentData data = new SyncAgentData { SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-Onebox/providers/Microsoft.Sql/servers/syncagentcrud-8475/databases/sync"), }; @@ -121,10 +112,10 @@ public async Task Update_UpdateASyncAgent() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASyncAgent() + public async Task Update_UpdateASyncAgent() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentDelete.json - // this example is just showing the usage of "SyncAgents_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncAgentUpdate.json + // this example is just showing the usage of "SyncAgents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,9 +132,18 @@ public async Task Delete_DeleteASyncAgent() SyncAgentResource syncAgent = client.GetSyncAgentResource(syncAgentResourceId); // invoke the operation - await syncAgent.DeleteAsync(WaitUntil.Completed); + SyncAgentData data = new SyncAgentData + { + SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/Default-SQL-Onebox/providers/Microsoft.Sql/servers/syncagentcrud-8475/databases/sync"), + }; + ArmOperation lro = await syncAgent.UpdateAsync(WaitUntil.Completed, data); + SyncAgentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncAgentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncGroupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncGroupCollection.cs index 0e2e6380103e6..0cf3518a88523 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncGroupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SyncGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASyncGroup() + public async Task CreateOrUpdate_CreateASyncGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGet.json - // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupCreate.json + // this example is just showing the usage of "SyncGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,16 @@ public async Task Get_GetASyncGroup() // invoke the operation string syncGroupName = "syncgroupcrud-3187"; - SyncGroupResource result = await collection.GetAsync(syncGroupName); + SyncGroupData data = new SyncGroupData + { + Interval = -1, + ConflictResolutionPolicy = SyncConflictResolutionPolicy.HubWin, + SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-3521/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), + HubDatabaseUserName = "hubUser", + UsePrivateLinkConnection = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncGroupName, data); + SyncGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +62,10 @@ public async Task Get_GetASyncGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASyncGroup() + public async Task CreateOrUpdate_UpdateASyncGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGet.json - // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupUpdate.json + // this example is just showing the usage of "SyncGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,14 +86,27 @@ public async Task Exists_GetASyncGroup() // invoke the operation string syncGroupName = "syncgroupcrud-3187"; - bool result = await collection.ExistsAsync(syncGroupName); + SyncGroupData data = new SyncGroupData + { + Interval = -1, + ConflictResolutionPolicy = SyncConflictResolutionPolicy.HubWin, + SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-3521/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), + HubDatabaseUserName = "hubUser", + UsePrivateLinkConnection = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncGroupName, data); + SyncGroupResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASyncGroup() + public async Task Get_GetASyncGroup() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGet.json // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,29 +130,21 @@ public async Task GetIfExists_GetASyncGroup() // invoke the operation string syncGroupName = "syncgroupcrud-3187"; - NullableResponse response = await collection.GetIfExistsAsync(syncGroupName); - SyncGroupResource result = response.HasValue ? response.Value : null; + SyncGroupResource result = await collection.GetAsync(syncGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASyncGroup() + public async Task GetAll_ListSyncGroupsUnderAGivenDatabase() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupCreate.json - // this example is just showing the usage of "SyncGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupListByDatabase.json + // this example is just showing the usage of "SyncGroups_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,32 +163,25 @@ public async Task CreateOrUpdate_CreateASyncGroup() // get the collection of this SyncGroupResource SyncGroupCollection collection = sqlDatabase.GetSyncGroups(); - // invoke the operation - string syncGroupName = "syncgroupcrud-3187"; - SyncGroupData data = new SyncGroupData() + // invoke the operation and iterate over the result + await foreach (SyncGroupResource item in collection.GetAllAsync()) { - Interval = -1, - ConflictResolutionPolicy = SyncConflictResolutionPolicy.HubWin, - SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-3521/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), - HubDatabaseUserName = "hubUser", - UsePrivateLinkConnection = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncGroupName, data); - SyncGroupResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateASyncGroup() + public async Task Exists_GetASyncGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupUpdate.json - // this example is just showing the usage of "SyncGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGet.json + // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,30 +202,17 @@ public async Task CreateOrUpdate_UpdateASyncGroup() // invoke the operation string syncGroupName = "syncgroupcrud-3187"; - SyncGroupData data = new SyncGroupData() - { - Interval = -1, - ConflictResolutionPolicy = SyncConflictResolutionPolicy.HubWin, - SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-3521/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), - HubDatabaseUserName = "hubUser", - UsePrivateLinkConnection = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncGroupName, data); - SyncGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(syncGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSyncGroupsUnderAGivenDatabase() + public async Task GetIfExists_GetASyncGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupListByDatabase.json - // this example is just showing the usage of "SyncGroups_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGet.json + // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -237,17 +231,23 @@ public async Task GetAll_ListSyncGroupsUnderAGivenDatabase() // get the collection of this SyncGroupResource SyncGroupCollection collection = sqlDatabase.GetSyncGroups(); - // invoke the operation and iterate over the result - await foreach (SyncGroupResource item in collection.GetAllAsync()) + // invoke the operation + string syncGroupName = "syncgroupcrud-3187"; + NullableResponse response = await collection.GetIfExistsAsync(syncGroupName); + SyncGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SyncGroupData resourceData = item.Data; + SyncGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncGroupResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncGroupResource.cs index 0fcf8fdb3fff8..4b8a0bdd845a7 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncGroupResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncGroupResource.cs @@ -9,8 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; -using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.Sql.Models; using NUnit.Framework; @@ -20,38 +18,10 @@ public partial class Sample_SyncGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSyncDatabaseIdsSyncGroups_GetASyncDatabaseID() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGetSyncDatabaseId.json - // this example is just showing the usage of "SyncGroups_ListSyncDatabaseIds" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - AzureLocation locationName = new AzureLocation("westus"); - await foreach (SubResource item in subscriptionResource.GetSyncDatabaseIdsSyncGroupsAsync(locationName)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task RefreshHubSchema_RefreshAHubDatabaseSchema() + public async Task Get_GetASyncGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupRefreshHubSchema.json - // this example is just showing the usage of "SyncGroups_RefreshHubSchema" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGet.json + // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,17 +39,21 @@ public async Task RefreshHubSchema_RefreshAHubDatabaseSchema() SyncGroupResource syncGroup = client.GetSyncGroupResource(syncGroupResourceId); // invoke the operation - await syncGroup.RefreshHubSchemaAsync(WaitUntil.Completed); + SyncGroupResource result = await syncGroup.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetHubSchemas_GetAHubDatabaseSchema() + public async Task Delete_DeleteASyncGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGetHubSchema.json - // this example is just showing the usage of "SyncGroups_ListHubSchemas" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupDelete.json + // this example is just showing the usage of "SyncGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,21 +70,18 @@ public async Task GetHubSchemas_GetAHubDatabaseSchema() ResourceIdentifier syncGroupResourceId = SyncGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, syncGroupName); SyncGroupResource syncGroup = client.GetSyncGroupResource(syncGroupResourceId); - // invoke the operation and iterate over the result - await foreach (SyncFullSchemaProperties item in syncGroup.GetHubSchemasAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + await syncGroup.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLogs_GetSyncGroupLogs() + public async Task Update_UpdateASyncGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGetLog.json - // this example is just showing the usage of "SyncGroups_ListLogs" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupPatch.json + // this example is just showing the usage of "SyncGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,24 +98,32 @@ public async Task GetLogs_GetSyncGroupLogs() ResourceIdentifier syncGroupResourceId = SyncGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, syncGroupName); SyncGroupResource syncGroup = client.GetSyncGroupResource(syncGroupResourceId); - // invoke the operation and iterate over the result - string startTime = "2017-01-01T00:00:00"; - string endTime = "2017-12-31T00:00:00"; - SyncGroupLogType type = SyncGroupLogType.All; - await foreach (SyncGroupLogProperties item in syncGroup.GetLogsAsync(startTime, endTime, type)) + // invoke the operation + SyncGroupData data = new SyncGroupData { - Console.WriteLine($"Succeeded: {item}"); - } + Interval = -1, + ConflictResolutionPolicy = SyncConflictResolutionPolicy.HubWin, + SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-3521/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), + HubDatabaseUserName = "hubUser", + HubDatabasePassword = "hubPassword", + UsePrivateLinkConnection = true, + }; + ArmOperation lro = await syncGroup.UpdateAsync(WaitUntil.Completed, data); + SyncGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CancelSync_CancelASyncGroupSynchronization() + public async Task RefreshHubSchema_RefreshAHubDatabaseSchema() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupCancelSync.json - // this example is just showing the usage of "SyncGroups_CancelSync" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupRefreshHubSchema.json + // this example is just showing the usage of "SyncGroups_RefreshHubSchema" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -162,17 +141,17 @@ public async Task CancelSync_CancelASyncGroupSynchronization() SyncGroupResource syncGroup = client.GetSyncGroupResource(syncGroupResourceId); // invoke the operation - await syncGroup.CancelSyncAsync(); + await syncGroup.RefreshHubSchemaAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task TriggerSync_TriggerASyncGroupSynchronization() + public async Task GetHubSchemas_GetAHubDatabaseSchema() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupTriggerSync.json - // this example is just showing the usage of "SyncGroups_TriggerSync" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGetHubSchema.json + // this example is just showing the usage of "SyncGroups_ListHubSchemas" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,18 +168,21 @@ public async Task TriggerSync_TriggerASyncGroupSynchronization() ResourceIdentifier syncGroupResourceId = SyncGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, syncGroupName); SyncGroupResource syncGroup = client.GetSyncGroupResource(syncGroupResourceId); - // invoke the operation - await syncGroup.TriggerSyncAsync(); + // invoke the operation and iterate over the result + await foreach (SyncFullSchemaProperties item in syncGroup.GetHubSchemasAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASyncGroup() + public async Task GetLogs_GetSyncGroupLogs() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGet.json - // this example is just showing the usage of "SyncGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupGetLog.json + // this example is just showing the usage of "SyncGroups_ListLogs" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,22 +199,24 @@ public async Task Get_GetASyncGroup() ResourceIdentifier syncGroupResourceId = SyncGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, syncGroupName); SyncGroupResource syncGroup = client.GetSyncGroupResource(syncGroupResourceId); - // invoke the operation - SyncGroupResource result = await syncGroup.GetAsync(); + // invoke the operation and iterate over the result + string startTime = "2017-01-01T00:00:00"; + string endTime = "2017-12-31T00:00:00"; + SyncGroupLogType type = SyncGroupLogType.All; + await foreach (SyncGroupLogProperties item in syncGroup.GetLogsAsync(startTime, endTime, type)) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASyncGroup() + public async Task CancelSync_CancelASyncGroupSynchronization() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupDelete.json - // this example is just showing the usage of "SyncGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupCancelSync.json + // this example is just showing the usage of "SyncGroups_CancelSync" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -250,17 +234,17 @@ public async Task Delete_DeleteASyncGroup() SyncGroupResource syncGroup = client.GetSyncGroupResource(syncGroupResourceId); // invoke the operation - await syncGroup.DeleteAsync(WaitUntil.Completed); + await syncGroup.CancelSyncAsync(); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASyncGroup() + public async Task TriggerSync_TriggerASyncGroupSynchronization() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupPatch.json - // this example is just showing the usage of "SyncGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncGroupTriggerSync.json + // this example is just showing the usage of "SyncGroups_TriggerSync" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -278,23 +262,9 @@ public async Task Update_UpdateASyncGroup() SyncGroupResource syncGroup = client.GetSyncGroupResource(syncGroupResourceId); // invoke the operation - SyncGroupData data = new SyncGroupData() - { - Interval = -1, - ConflictResolutionPolicy = SyncConflictResolutionPolicy.HubWin, - SyncDatabaseId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-3521/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), - HubDatabaseUserName = "hubUser", - HubDatabasePassword = "hubPassword", - UsePrivateLinkConnection = true, - }; - ArmOperation lro = await syncGroup.UpdateAsync(WaitUntil.Completed, data); - SyncGroupResource result = lro.Value; + await syncGroup.TriggerSyncAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncMemberCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncMemberCollection.cs index 32f9c18302e10..0a7ba71a2184f 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncMemberCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncMemberCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SyncMemberCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASyncMember() + public async Task CreateOrUpdate_CreateANewSyncMember() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberGet.json - // this example is just showing the usage of "SyncMembers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberCreate.json + // this example is just showing the usage of "SyncMembers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,7 +43,18 @@ public async Task Get_GetASyncMember() // invoke the operation string syncMemberName = "syncmembercrud-4879"; - SyncMemberResource result = await collection.GetAsync(syncMemberName); + SyncMemberData data = new SyncMemberData + { + DatabaseType = SyncMemberDbType.AzureSqlDatabase, + SyncMemberAzureDatabaseResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-65440/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), + UsePrivateLinkConnection = true, + ServerName = "syncgroupcrud-3379.database.windows.net", + DatabaseName = "syncgroupcrud-7421", + UserName = "myUser", + SyncDirection = SyncDirection.Bidirectional, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncMemberName, data); + SyncMemberResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +65,10 @@ public async Task Get_GetASyncMember() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASyncMember() + public async Task CreateOrUpdate_UpdateASyncMember() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberGet.json - // this example is just showing the usage of "SyncMembers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberUpdate.json + // this example is just showing the usage of "SyncMembers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,14 +90,29 @@ public async Task Exists_GetASyncMember() // invoke the operation string syncMemberName = "syncmembercrud-4879"; - bool result = await collection.ExistsAsync(syncMemberName); + SyncMemberData data = new SyncMemberData + { + DatabaseType = SyncMemberDbType.AzureSqlDatabase, + SyncMemberAzureDatabaseResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-65440/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), + UsePrivateLinkConnection = true, + ServerName = "syncgroupcrud-3379.database.windows.net", + DatabaseName = "syncgroupcrud-7421", + UserName = "myUser", + SyncDirection = SyncDirection.Bidirectional, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncMemberName, data); + SyncMemberResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncMemberData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASyncMember() + public async Task Get_GetASyncMember() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberGet.json // this example is just showing the usage of "SyncMembers_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,29 +137,21 @@ public async Task GetIfExists_GetASyncMember() // invoke the operation string syncMemberName = "syncmembercrud-4879"; - NullableResponse response = await collection.GetIfExistsAsync(syncMemberName); - SyncMemberResource result = response.HasValue ? response.Value : null; + SyncMemberResource result = await collection.GetAsync(syncMemberName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncMemberData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncMemberData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateANewSyncMember() + public async Task GetAll_ListSyncMembersUnderASyncGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberCreate.json - // this example is just showing the usage of "SyncMembers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberListBySyncGroup.json + // this example is just showing the usage of "SyncMembers_ListBySyncGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -153,34 +171,25 @@ public async Task CreateOrUpdate_CreateANewSyncMember() // get the collection of this SyncMemberResource SyncMemberCollection collection = syncGroup.GetSyncMembers(); - // invoke the operation - string syncMemberName = "syncmembercrud-4879"; - SyncMemberData data = new SyncMemberData() + // invoke the operation and iterate over the result + await foreach (SyncMemberResource item in collection.GetAllAsync()) { - DatabaseType = SyncMemberDbType.AzureSqlDatabase, - SyncMemberAzureDatabaseResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-65440/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), - UsePrivateLinkConnection = true, - ServerName = "syncgroupcrud-3379.database.windows.net", - DatabaseName = "syncgroupcrud-7421", - UserName = "myUser", - SyncDirection = SyncDirection.Bidirectional, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncMemberName, data); - SyncMemberResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SyncMemberData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncMemberData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateASyncMember() + public async Task Exists_GetASyncMember() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberUpdate.json - // this example is just showing the usage of "SyncMembers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberGet.json + // this example is just showing the usage of "SyncMembers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -202,32 +211,17 @@ public async Task CreateOrUpdate_UpdateASyncMember() // invoke the operation string syncMemberName = "syncmembercrud-4879"; - SyncMemberData data = new SyncMemberData() - { - DatabaseType = SyncMemberDbType.AzureSqlDatabase, - SyncMemberAzureDatabaseResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-65440/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), - UsePrivateLinkConnection = true, - ServerName = "syncgroupcrud-3379.database.windows.net", - DatabaseName = "syncgroupcrud-7421", - UserName = "myUser", - SyncDirection = SyncDirection.Bidirectional, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, syncMemberName, data); - SyncMemberResource result = lro.Value; + bool result = await collection.ExistsAsync(syncMemberName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SyncMemberData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSyncMembersUnderASyncGroup() + public async Task GetIfExists_GetASyncMember() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberListBySyncGroup.json - // this example is just showing the usage of "SyncMembers_ListBySyncGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/SyncMemberGet.json + // this example is just showing the usage of "SyncMembers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -247,17 +241,23 @@ public async Task GetAll_ListSyncMembersUnderASyncGroup() // get the collection of this SyncMemberResource SyncMemberCollection collection = syncGroup.GetSyncMembers(); - // invoke the operation and iterate over the result - await foreach (SyncMemberResource item in collection.GetAllAsync()) + // invoke the operation + string syncMemberName = "syncmembercrud-4879"; + NullableResponse response = await collection.GetIfExistsAsync(syncMemberName); + SyncMemberResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SyncMemberData resourceData = item.Data; + SyncMemberData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncMemberResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncMemberResource.cs index 03cb806606d74..81165db38a9ac 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncMemberResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_SyncMemberResource.cs @@ -102,7 +102,7 @@ public async Task Update_UpdateAnExistingSyncMember() SyncMemberResource syncMember = client.GetSyncMemberResource(syncMemberResourceId); // invoke the operation - SyncMemberData data = new SyncMemberData() + SyncMemberData data = new SyncMemberData { DatabaseType = SyncMemberDbType.AzureSqlDatabase, SyncMemberAzureDatabaseResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/syncgroupcrud-65440/providers/Microsoft.Sql/servers/syncgroupcrud-8475/databases/syncgroupcrud-4328"), diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_VirtualClusterCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_VirtualClusterCollection.cs index 27b24f7a27731..a4fd9b5d08bcc 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_VirtualClusterCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_VirtualClusterCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualClusterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualClustersByResourceGroup() + public async Task Get_GetsAVirtualCluster() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterListByResourceGroup.json - // this example is just showing the usage of "VirtualClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterGet.json + // this example is just showing the usage of "VirtualClusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListVirtualClustersByResourceGroup() // get the collection of this VirtualClusterResource VirtualClusterCollection collection = resourceGroupResource.GetVirtualClusters(); - // invoke the operation and iterate over the result - await foreach (VirtualClusterResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string virtualClusterName = "vc-f769ed71-b3ad-491a-a9d5-26eeceaa6be2"; + VirtualClusterResource result = await collection.GetAsync(virtualClusterName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAVirtualCluster() + public async Task GetAll_ListVirtualClustersByResourceGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterGet.json - // this example is just showing the usage of "VirtualClusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterListByResourceGroup.json + // this example is just showing the usage of "VirtualClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetsAVirtualCluster() // get the collection of this VirtualClusterResource VirtualClusterCollection collection = resourceGroupResource.GetVirtualClusters(); - // invoke the operation - string virtualClusterName = "vc-f769ed71-b3ad-491a-a9d5-26eeceaa6be2"; - VirtualClusterResource result = await collection.GetAsync(virtualClusterName); + // invoke the operation and iterate over the result + await foreach (VirtualClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_VirtualClusterResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_VirtualClusterResource.cs index f3799c7df9ccf..0eec05c63ad7a 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_VirtualClusterResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_VirtualClusterResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Sql.Models; using NUnit.Framework; @@ -17,37 +16,6 @@ namespace Azure.ResourceManager.Sql.Samples { public partial class Sample_VirtualClusterResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVirtualClusters_ListVirtualClusters() - { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2022-05-01-preview/examples/VirtualClusterList.json - // this example is just showing the usage of "VirtualClusters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "20d7082a-0fc7-4468-82bd-542694d5042b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VirtualClusterResource item in subscriptionResource.GetVirtualClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetsAVirtualCluster() @@ -125,11 +93,11 @@ public async Task Update_UpdateVirtualClusterWithTags() VirtualClusterResource virtualCluster = client.GetVirtualClusterResource(virtualClusterResourceId); // invoke the operation - VirtualClusterPatch patch = new VirtualClusterPatch() + VirtualClusterPatch patch = new VirtualClusterPatch { Tags = { -["tkey"] = "tvalue1", +["tkey"] = "tvalue1" }, }; ArmOperation lro = await virtualCluster.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadClassifierCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadClassifierCollection.cs index 80d5b19992fbb..7a93f6638b989 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadClassifierCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadClassifierCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkloadClassifierCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAWorkloadClassifierForADataWarehouse() + public async Task CreateOrUpdate_CreateAWorkloadGroupWithAllPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadClassifier.json - // this example is just showing the usage of "WorkloadClassifiers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadClassifierMax.json + // this example is just showing the usage of "WorkloadClassifiers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,8 +41,18 @@ public async Task Get_GetsAWorkloadClassifierForADataWarehouse() WorkloadClassifierCollection collection = workloadGroup.GetWorkloadClassifiers(); // invoke the operation - string workloadClassifierName = "wlm_classifier"; - WorkloadClassifierResource result = await collection.GetAsync(workloadClassifierName); + string workloadClassifierName = "wlm_workloadclassifier"; + WorkloadClassifierData data = new WorkloadClassifierData + { + MemberName = "dbo", + Label = "test_label", + Context = "test_context", + StartTime = "12:00", + EndTime = "14:00", + Importance = "high", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadClassifierName, data); + WorkloadClassifierResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +63,10 @@ public async Task Get_GetsAWorkloadClassifierForADataWarehouse() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAWorkloadClassifierForADataWarehouse() + public async Task CreateOrUpdate_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadClassifier.json - // this example is just showing the usage of "WorkloadClassifiers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadClassifierMin.json + // this example is just showing the usage of "WorkloadClassifiers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +87,24 @@ public async Task Exists_GetsAWorkloadClassifierForADataWarehouse() WorkloadClassifierCollection collection = workloadGroup.GetWorkloadClassifiers(); // invoke the operation - string workloadClassifierName = "wlm_classifier"; - bool result = await collection.ExistsAsync(workloadClassifierName); + string workloadClassifierName = "wlm_workloadclassifier"; + WorkloadClassifierData data = new WorkloadClassifierData + { + MemberName = "dbo", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadClassifierName, data); + WorkloadClassifierResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadClassifierData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAWorkloadClassifierForADataWarehouse() + public async Task Get_GetsAWorkloadClassifierForADataWarehouse() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadClassifier.json // this example is just showing the usage of "WorkloadClassifiers_Get" operation, for the dependent resources, they will have to be created separately. @@ -110,29 +129,21 @@ public async Task GetIfExists_GetsAWorkloadClassifierForADataWarehouse() // invoke the operation string workloadClassifierName = "wlm_classifier"; - NullableResponse response = await collection.GetIfExistsAsync(workloadClassifierName); - WorkloadClassifierResource result = response.HasValue ? response.Value : null; + WorkloadClassifierResource result = await collection.GetAsync(workloadClassifierName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadClassifierData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadClassifierData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAWorkloadGroupWithAllPropertiesSpecified() + public async Task GetAll_GetTheListOfWorkloadClassifiersForAWorkloadGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadClassifierMax.json - // this example is just showing the usage of "WorkloadClassifiers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadClassifierList.json + // this example is just showing the usage of "WorkloadClassifiers_ListByWorkloadGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -152,33 +163,25 @@ public async Task CreateOrUpdate_CreateAWorkloadGroupWithAllPropertiesSpecified( // get the collection of this WorkloadClassifierResource WorkloadClassifierCollection collection = workloadGroup.GetWorkloadClassifiers(); - // invoke the operation - string workloadClassifierName = "wlm_workloadclassifier"; - WorkloadClassifierData data = new WorkloadClassifierData() + // invoke the operation and iterate over the result + await foreach (WorkloadClassifierResource item in collection.GetAllAsync()) { - MemberName = "dbo", - Label = "test_label", - Context = "test_context", - StartTime = "12:00", - EndTime = "14:00", - Importance = "high", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadClassifierName, data); - WorkloadClassifierResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadClassifierData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadClassifierData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() + public async Task Exists_GetsAWorkloadClassifierForADataWarehouse() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadClassifierMin.json - // this example is just showing the usage of "WorkloadClassifiers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadClassifier.json + // this example is just showing the usage of "WorkloadClassifiers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,27 +202,18 @@ public async Task CreateOrUpdate_CreateAWorkloadGroupWithTheRequiredPropertiesSp WorkloadClassifierCollection collection = workloadGroup.GetWorkloadClassifiers(); // invoke the operation - string workloadClassifierName = "wlm_workloadclassifier"; - WorkloadClassifierData data = new WorkloadClassifierData() - { - MemberName = "dbo", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadClassifierName, data); - WorkloadClassifierResource result = lro.Value; + string workloadClassifierName = "wlm_classifier"; + bool result = await collection.ExistsAsync(workloadClassifierName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadClassifierData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheListOfWorkloadClassifiersForAWorkloadGroup() + public async Task GetIfExists_GetsAWorkloadClassifierForADataWarehouse() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadClassifierList.json - // this example is just showing the usage of "WorkloadClassifiers_ListByWorkloadGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadClassifier.json + // this example is just showing the usage of "WorkloadClassifiers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -239,17 +233,23 @@ public async Task GetAll_GetTheListOfWorkloadClassifiersForAWorkloadGroup() // get the collection of this WorkloadClassifierResource WorkloadClassifierCollection collection = workloadGroup.GetWorkloadClassifiers(); - // invoke the operation and iterate over the result - await foreach (WorkloadClassifierResource item in collection.GetAllAsync()) + // invoke the operation + string workloadClassifierName = "wlm_classifier"; + NullableResponse response = await collection.GetIfExistsAsync(workloadClassifierName); + WorkloadClassifierResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - WorkloadClassifierData resourceData = item.Data; + WorkloadClassifierData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadClassifierResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadClassifierResource.cs index 3c20d850ff384..2359bfad7ec99 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadClassifierResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadClassifierResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetsAWorkloadClassifierForADataWarehouse() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAWorkloadGroupWithAllPropertiesSpecified() + public async Task Delete_DeleteAWorkloadClassifier() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadClassifierMax.json - // this example is just showing the usage of "WorkloadClassifiers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteWorkloadClassifier.json + // this example is just showing the usage of "WorkloadClassifiers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,30 +72,16 @@ public async Task Update_CreateAWorkloadGroupWithAllPropertiesSpecified() WorkloadClassifierResource workloadClassifier = client.GetWorkloadClassifierResource(workloadClassifierResourceId); // invoke the operation - WorkloadClassifierData data = new WorkloadClassifierData() - { - MemberName = "dbo", - Label = "test_label", - Context = "test_context", - StartTime = "12:00", - EndTime = "14:00", - Importance = "high", - }; - ArmOperation lro = await workloadClassifier.UpdateAsync(WaitUntil.Completed, data); - WorkloadClassifierResource result = lro.Value; + await workloadClassifier.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadClassifierData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() + public async Task Update_CreateAWorkloadGroupWithAllPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadClassifierMin.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadClassifierMax.json // this example is just showing the usage of "WorkloadClassifiers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -115,9 +101,14 @@ public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified( WorkloadClassifierResource workloadClassifier = client.GetWorkloadClassifierResource(workloadClassifierResourceId); // invoke the operation - WorkloadClassifierData data = new WorkloadClassifierData() + WorkloadClassifierData data = new WorkloadClassifierData { MemberName = "dbo", + Label = "test_label", + Context = "test_context", + StartTime = "12:00", + EndTime = "14:00", + Importance = "high", }; ArmOperation lro = await workloadClassifier.UpdateAsync(WaitUntil.Completed, data); WorkloadClassifierResource result = lro.Value; @@ -131,10 +122,10 @@ public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified( [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAWorkloadClassifier() + public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteWorkloadClassifier.json - // this example is just showing the usage of "WorkloadClassifiers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadClassifierMin.json + // this example is just showing the usage of "WorkloadClassifiers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -153,9 +144,18 @@ public async Task Delete_DeleteAWorkloadClassifier() WorkloadClassifierResource workloadClassifier = client.GetWorkloadClassifierResource(workloadClassifierResourceId); // invoke the operation - await workloadClassifier.DeleteAsync(WaitUntil.Completed); + WorkloadClassifierData data = new WorkloadClassifierData + { + MemberName = "dbo", + }; + ArmOperation lro = await workloadClassifier.UpdateAsync(WaitUntil.Completed, data); + WorkloadClassifierResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadClassifierData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadGroupCollection.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadGroupCollection.cs index 51521b87b32cd..8843e5a97a2a2 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadGroupCollection.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadGroupCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkloadGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAWorkloadGroupForADataWarehouse() + public async Task CreateOrUpdate_CreateAWorkloadGroupWithAllPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadGroup.json - // this example is just showing the usage of "WorkloadGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadGroupMax.json + // this example is just showing the usage of "WorkloadGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_GetsAWorkloadGroupForADataWarehouse() // invoke the operation string workloadGroupName = "smallrc"; - WorkloadGroupResource result = await collection.GetAsync(workloadGroupName); + WorkloadGroupData data = new WorkloadGroupData + { + MinResourcePercent = 0, + MaxResourcePercent = 100, + MinResourcePercentPerRequest = 3, + MaxResourcePercentPerRequest = 3, + Importance = "normal", + QueryExecutionTimeout = 0, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadGroupName, data); + WorkloadGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +62,10 @@ public async Task Get_GetsAWorkloadGroupForADataWarehouse() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAWorkloadGroupForADataWarehouse() + public async Task CreateOrUpdate_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadGroup.json - // this example is just showing the usage of "WorkloadGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadGroupMin.json + // this example is just showing the usage of "WorkloadGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,14 +86,25 @@ public async Task Exists_GetsAWorkloadGroupForADataWarehouse() // invoke the operation string workloadGroupName = "smallrc"; - bool result = await collection.ExistsAsync(workloadGroupName); + WorkloadGroupData data = new WorkloadGroupData + { + MinResourcePercent = 0, + MaxResourcePercent = 100, + MinResourcePercentPerRequest = 3, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadGroupName, data); + WorkloadGroupResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAWorkloadGroupForADataWarehouse() + public async Task Get_GetsAWorkloadGroupForADataWarehouse() { // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadGroup.json // this example is just showing the usage of "WorkloadGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +128,21 @@ public async Task GetIfExists_GetsAWorkloadGroupForADataWarehouse() // invoke the operation string workloadGroupName = "smallrc"; - NullableResponse response = await collection.GetIfExistsAsync(workloadGroupName); - WorkloadGroupResource result = response.HasValue ? response.Value : null; + WorkloadGroupResource result = await collection.GetAsync(workloadGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAWorkloadGroupWithAllPropertiesSpecified() + public async Task GetAll_GetTheListOfWorkloadGroupsForADataWarehouse() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadGroupMax.json - // this example is just showing the usage of "WorkloadGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadGroupList.json + // this example is just showing the usage of "WorkloadGroups_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,33 +161,25 @@ public async Task CreateOrUpdate_CreateAWorkloadGroupWithAllPropertiesSpecified( // get the collection of this WorkloadGroupResource WorkloadGroupCollection collection = sqlDatabase.GetWorkloadGroups(); - // invoke the operation - string workloadGroupName = "smallrc"; - WorkloadGroupData data = new WorkloadGroupData() + // invoke the operation and iterate over the result + await foreach (WorkloadGroupResource item in collection.GetAllAsync()) { - MinResourcePercent = 0, - MaxResourcePercent = 100, - MinResourcePercentPerRequest = 3, - MaxResourcePercentPerRequest = 3, - Importance = "normal", - QueryExecutionTimeout = 0, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadGroupName, data); - WorkloadGroupResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() + public async Task Exists_GetsAWorkloadGroupForADataWarehouse() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadGroupMin.json - // this example is just showing the usage of "WorkloadGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadGroup.json + // this example is just showing the usage of "WorkloadGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,28 +200,17 @@ public async Task CreateOrUpdate_CreateAWorkloadGroupWithTheRequiredPropertiesSp // invoke the operation string workloadGroupName = "smallrc"; - WorkloadGroupData data = new WorkloadGroupData() - { - MinResourcePercent = 0, - MaxResourcePercent = 100, - MinResourcePercentPerRequest = 3, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workloadGroupName, data); - WorkloadGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(workloadGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheListOfWorkloadGroupsForADataWarehouse() + public async Task GetIfExists_GetsAWorkloadGroupForADataWarehouse() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadGroupList.json - // this example is just showing the usage of "WorkloadGroups_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/GetWorkloadGroup.json + // this example is just showing the usage of "WorkloadGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -235,17 +229,23 @@ public async Task GetAll_GetTheListOfWorkloadGroupsForADataWarehouse() // get the collection of this WorkloadGroupResource WorkloadGroupCollection collection = sqlDatabase.GetWorkloadGroups(); - // invoke the operation and iterate over the result - await foreach (WorkloadGroupResource item in collection.GetAllAsync()) + // invoke the operation + string workloadGroupName = "smallrc"; + NullableResponse response = await collection.GetIfExistsAsync(workloadGroupName); + WorkloadGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - WorkloadGroupData resourceData = item.Data; + WorkloadGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadGroupResource.cs b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadGroupResource.cs index 483944ec5ea42..4ee94cbb1f452 100644 --- a/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadGroupResource.cs +++ b/sdk/sqlmanagement/Azure.ResourceManager.Sql/samples/Generated/Samples/Sample_WorkloadGroupResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsAWorkloadGroupForADataWarehouse() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAWorkloadGroupWithAllPropertiesSpecified() + public async Task Delete_DeleteAWorkloadGroup() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadGroupMax.json - // this example is just showing the usage of "WorkloadGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteWorkloadGroup.json + // this example is just showing the usage of "WorkloadGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,35 +65,21 @@ public async Task Update_CreateAWorkloadGroupWithAllPropertiesSpecified() string resourceGroupName = "Default-SQL-SouthEastAsia"; string serverName = "testsvr"; string databaseName = "testdb"; - string workloadGroupName = "smallrc"; + string workloadGroupName = "wlm_workloadgroup"; ResourceIdentifier workloadGroupResourceId = WorkloadGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, workloadGroupName); WorkloadGroupResource workloadGroup = client.GetWorkloadGroupResource(workloadGroupResourceId); // invoke the operation - WorkloadGroupData data = new WorkloadGroupData() - { - MinResourcePercent = 0, - MaxResourcePercent = 100, - MinResourcePercentPerRequest = 3, - MaxResourcePercentPerRequest = 3, - Importance = "normal", - QueryExecutionTimeout = 0, - }; - ArmOperation lro = await workloadGroup.UpdateAsync(WaitUntil.Completed, data); - WorkloadGroupResource result = lro.Value; + await workloadGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() + public async Task Update_CreateAWorkloadGroupWithAllPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadGroupMin.json + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadGroupMax.json // this example is just showing the usage of "WorkloadGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -112,11 +98,14 @@ public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified( WorkloadGroupResource workloadGroup = client.GetWorkloadGroupResource(workloadGroupResourceId); // invoke the operation - WorkloadGroupData data = new WorkloadGroupData() + WorkloadGroupData data = new WorkloadGroupData { MinResourcePercent = 0, MaxResourcePercent = 100, MinResourcePercentPerRequest = 3, + MaxResourcePercentPerRequest = 3, + Importance = "normal", + QueryExecutionTimeout = 0, }; ArmOperation lro = await workloadGroup.UpdateAsync(WaitUntil.Completed, data); WorkloadGroupResource result = lro.Value; @@ -130,10 +119,10 @@ public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified( [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAWorkloadGroup() + public async Task Update_CreateAWorkloadGroupWithTheRequiredPropertiesSpecified() { - // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/DeleteWorkloadGroup.json - // this example is just showing the usage of "WorkloadGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sql/resource-manager/Microsoft.Sql/preview/2020-11-01-preview/examples/CreateOrUpdateWorkloadGroupMin.json + // this example is just showing the usage of "WorkloadGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,14 +135,25 @@ public async Task Delete_DeleteAWorkloadGroup() string resourceGroupName = "Default-SQL-SouthEastAsia"; string serverName = "testsvr"; string databaseName = "testdb"; - string workloadGroupName = "wlm_workloadgroup"; + string workloadGroupName = "smallrc"; ResourceIdentifier workloadGroupResourceId = WorkloadGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, databaseName, workloadGroupName); WorkloadGroupResource workloadGroup = client.GetWorkloadGroupResource(workloadGroupResourceId); // invoke the operation - await workloadGroup.DeleteAsync(WaitUntil.Completed); + WorkloadGroupData data = new WorkloadGroupData + { + MinResourcePercent = 0, + MaxResourcePercent = 100, + MinResourcePercentPerRequest = 3, + }; + ArmOperation lro = await workloadGroup.UpdateAsync(WaitUntil.Completed, data); + WorkloadGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_AvailabilityGroupListenerCollection.cs b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_AvailabilityGroupListenerCollection.cs index 9f3ff5cd107e0..4c2b7893e93d8 100644 --- a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_AvailabilityGroupListenerCollection.cs +++ b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_AvailabilityGroupListenerCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AvailabilityGroupListenerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAnAvailabilityGroupListener() + public async Task CreateOrUpdate_CreatesOrUpdatesAnAvailabilityGroupListenerUsingLoadBalancerThisIsUsedForVMsPresentInSingleSubnet() { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetAvailabilityGroupListener.json - // this example is just showing the usage of "AvailabilityGroupListeners_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/CreateOrUpdateAvailabilityGroupListener.json + // this example is just showing the usage of "AvailabilityGroupListeners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,24 @@ public async Task Get_GetsAnAvailabilityGroupListener() // invoke the operation string availabilityGroupListenerName = "agl-test"; - AvailabilityGroupListenerResource result = await collection.GetAsync(availabilityGroupListenerName); + AvailabilityGroupListenerData data = new AvailabilityGroupListenerData + { + AvailabilityGroupName = "ag-test", + LoadBalancerConfigurations = {new AvailabilityGroupListenerLoadBalancerConfiguration +{ +PrivateIPAddress = new AvailabilityGroupListenerPrivateIPAddress +{ +IPAddress = IPAddress.Parse("10.1.0.112"), +SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/default"), +}, +LoadBalancerResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/loadBalancers/lb-test"), +ProbePort = 59983, +SqlVmInstances = {new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm2"), new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm3")}, +}}, + Port = 1433, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, availabilityGroupListenerName, data); + AvailabilityGroupListenerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +70,10 @@ public async Task Get_GetsAnAvailabilityGroupListener() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAnAvailabilityGroupListener() + public async Task CreateOrUpdate_CreatesOrUpdatesAnAvailabilityGroupListenerThisIsUsedForVMsPresentInMultiSubnet() { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetAvailabilityGroupListener.json - // this example is just showing the usage of "AvailabilityGroupListeners_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/CreateOrUpdateAvailabilityGroupListenerWithMultiSubnet.json + // this example is just showing the usage of "AvailabilityGroupListeners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,14 +93,33 @@ public async Task Exists_GetsAnAvailabilityGroupListener() // invoke the operation string availabilityGroupListenerName = "agl-test"; - bool result = await collection.ExistsAsync(availabilityGroupListenerName); + AvailabilityGroupListenerData data = new AvailabilityGroupListenerData + { + AvailabilityGroupName = "ag-test", + MultiSubnetIPConfigurations = {new MultiSubnetIPConfiguration(new AvailabilityGroupListenerPrivateIPAddress +{ +IPAddress = IPAddress.Parse("10.0.0.112"), +SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/default"), +}, "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm2"), new MultiSubnetIPConfiguration(new AvailabilityGroupListenerPrivateIPAddress +{ +IPAddress = IPAddress.Parse("10.0.1.112"), +SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/alternate"), +}, "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm1")}, + Port = 1433, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, availabilityGroupListenerName, data); + AvailabilityGroupListenerResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvailabilityGroupListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAnAvailabilityGroupListener() + public async Task Get_GetsAnAvailabilityGroupListener() { // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetAvailabilityGroupListener.json // this example is just showing the usage of "AvailabilityGroupListeners_Get" operation, for the dependent resources, they will have to be created separately. @@ -106,29 +142,21 @@ public async Task GetIfExists_GetsAnAvailabilityGroupListener() // invoke the operation string availabilityGroupListenerName = "agl-test"; - NullableResponse response = await collection.GetIfExistsAsync(availabilityGroupListenerName); - AvailabilityGroupListenerResource result = response.HasValue ? response.Value : null; + AvailabilityGroupListenerResource result = await collection.GetAsync(availabilityGroupListenerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvailabilityGroupListenerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvailabilityGroupListenerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesAnAvailabilityGroupListenerUsingLoadBalancerThisIsUsedForVMsPresentInSingleSubnet() + public async Task GetAll_ListsAllAvailabilityGroupListenersInASQLVirtualMachineGroup() { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/CreateOrUpdateAvailabilityGroupListener.json - // this example is just showing the usage of "AvailabilityGroupListeners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/ListByGroupAvailabilityGroupListener.json + // this example is just showing the usage of "AvailabilityGroupListeners_ListByGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,46 +174,25 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAnAvailabilityGroupListenerUsin // get the collection of this AvailabilityGroupListenerResource AvailabilityGroupListenerCollection collection = sqlVmGroup.GetAvailabilityGroupListeners(); - // invoke the operation - string availabilityGroupListenerName = "agl-test"; - AvailabilityGroupListenerData data = new AvailabilityGroupListenerData() + // invoke the operation and iterate over the result + await foreach (AvailabilityGroupListenerResource item in collection.GetAllAsync()) { - AvailabilityGroupName = "ag-test", - LoadBalancerConfigurations = -{ -new AvailabilityGroupListenerLoadBalancerConfiguration() -{ -PrivateIPAddress = new AvailabilityGroupListenerPrivateIPAddress() -{ -IPAddress = IPAddress.Parse("10.1.0.112"), -SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/default"), -}, -LoadBalancerResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/loadBalancers/lb-test"), -ProbePort = 59983, -SqlVmInstances = -{ -new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm2"),new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm3") -}, -} -}, - Port = 1433, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, availabilityGroupListenerName, data); - AvailabilityGroupListenerResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvailabilityGroupListenerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvailabilityGroupListenerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesAnAvailabilityGroupListenerThisIsUsedForVMsPresentInMultiSubnet() + public async Task Exists_GetsAnAvailabilityGroupListener() { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/CreateOrUpdateAvailabilityGroupListenerWithMultiSubnet.json - // this example is just showing the usage of "AvailabilityGroupListeners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetAvailabilityGroupListener.json + // this example is just showing the usage of "AvailabilityGroupListeners_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -205,39 +212,17 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAnAvailabilityGroupListenerThis // invoke the operation string availabilityGroupListenerName = "agl-test"; - AvailabilityGroupListenerData data = new AvailabilityGroupListenerData() - { - AvailabilityGroupName = "ag-test", - MultiSubnetIPConfigurations = -{ -new MultiSubnetIPConfiguration(new AvailabilityGroupListenerPrivateIPAddress() -{ -IPAddress = IPAddress.Parse("10.0.0.112"), -SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/default"), -},"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm2"),new MultiSubnetIPConfiguration(new AvailabilityGroupListenerPrivateIPAddress() -{ -IPAddress = IPAddress.Parse("10.0.1.112"), -SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/alternate"), -},"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm1") -}, - Port = 1433, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, availabilityGroupListenerName, data); - AvailabilityGroupListenerResource result = lro.Value; + bool result = await collection.ExistsAsync(availabilityGroupListenerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvailabilityGroupListenerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsAllAvailabilityGroupListenersInASQLVirtualMachineGroup() + public async Task GetIfExists_GetsAnAvailabilityGroupListener() { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/ListByGroupAvailabilityGroupListener.json - // this example is just showing the usage of "AvailabilityGroupListeners_ListByGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetAvailabilityGroupListener.json + // this example is just showing the usage of "AvailabilityGroupListeners_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -255,17 +240,23 @@ public async Task GetAll_ListsAllAvailabilityGroupListenersInASQLVirtualMachineG // get the collection of this AvailabilityGroupListenerResource AvailabilityGroupListenerCollection collection = sqlVmGroup.GetAvailabilityGroupListeners(); - // invoke the operation and iterate over the result - await foreach (AvailabilityGroupListenerResource item in collection.GetAllAsync()) + // invoke the operation + string availabilityGroupListenerName = "agl-test"; + NullableResponse response = await collection.GetIfExistsAsync(availabilityGroupListenerName); + AvailabilityGroupListenerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AvailabilityGroupListenerData resourceData = item.Data; + AvailabilityGroupListenerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_AvailabilityGroupListenerResource.cs b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_AvailabilityGroupListenerResource.cs index ad626e1f509f8..845ed7eb5ad0b 100644 --- a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_AvailabilityGroupListenerResource.cs +++ b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_AvailabilityGroupListenerResource.cs @@ -48,6 +48,33 @@ public async Task Get_GetsAnAvailabilityGroupListener() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeletesAnAvailabilityGroupListener() + { + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/DeleteAvailabilityGroupListener.json + // this example is just showing the usage of "AvailabilityGroupListeners_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AvailabilityGroupListenerResource created on azure + // for more information of creating AvailabilityGroupListenerResource, please refer to the document of AvailabilityGroupListenerResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "testrg"; + string sqlVmGroupName = "testvmgroup"; + string availabilityGroupListenerName = "agl-test"; + ResourceIdentifier availabilityGroupListenerResourceId = AvailabilityGroupListenerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, sqlVmGroupName, availabilityGroupListenerName); + AvailabilityGroupListenerResource availabilityGroupListener = client.GetAvailabilityGroupListenerResource(availabilityGroupListenerResourceId); + + // invoke the operation + await availabilityGroupListener.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreatesOrUpdatesAnAvailabilityGroupListenerUsingLoadBalancerThisIsUsedForVMsPresentInSingleSubnet() @@ -70,26 +97,20 @@ public async Task Update_CreatesOrUpdatesAnAvailabilityGroupListenerUsingLoadBal AvailabilityGroupListenerResource availabilityGroupListener = client.GetAvailabilityGroupListenerResource(availabilityGroupListenerResourceId); // invoke the operation - AvailabilityGroupListenerData data = new AvailabilityGroupListenerData() + AvailabilityGroupListenerData data = new AvailabilityGroupListenerData { AvailabilityGroupName = "ag-test", - LoadBalancerConfigurations = -{ -new AvailabilityGroupListenerLoadBalancerConfiguration() + LoadBalancerConfigurations = {new AvailabilityGroupListenerLoadBalancerConfiguration { -PrivateIPAddress = new AvailabilityGroupListenerPrivateIPAddress() +PrivateIPAddress = new AvailabilityGroupListenerPrivateIPAddress { IPAddress = IPAddress.Parse("10.1.0.112"), SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/default"), }, LoadBalancerResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/loadBalancers/lb-test"), ProbePort = 59983, -SqlVmInstances = -{ -new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm2"),new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm3") -}, -} -}, +SqlVmInstances = {new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm2"), new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm3")}, +}}, Port = 1433, }; ArmOperation lro = await availabilityGroupListener.UpdateAsync(WaitUntil.Completed, data); @@ -124,21 +145,18 @@ public async Task Update_CreatesOrUpdatesAnAvailabilityGroupListenerThisIsUsedFo AvailabilityGroupListenerResource availabilityGroupListener = client.GetAvailabilityGroupListenerResource(availabilityGroupListenerResourceId); // invoke the operation - AvailabilityGroupListenerData data = new AvailabilityGroupListenerData() + AvailabilityGroupListenerData data = new AvailabilityGroupListenerData { AvailabilityGroupName = "ag-test", - MultiSubnetIPConfigurations = -{ -new MultiSubnetIPConfiguration(new AvailabilityGroupListenerPrivateIPAddress() + MultiSubnetIPConfigurations = {new MultiSubnetIPConfiguration(new AvailabilityGroupListenerPrivateIPAddress { IPAddress = IPAddress.Parse("10.0.0.112"), SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/default"), -},"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm2"),new MultiSubnetIPConfiguration(new AvailabilityGroupListenerPrivateIPAddress() +}, "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm2"), new MultiSubnetIPConfiguration(new AvailabilityGroupListenerPrivateIPAddress { IPAddress = IPAddress.Parse("10.0.1.112"), SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/alternate"), -},"/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm1") -}, +}, "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm1")}, Port = 1433, }; ArmOperation lro = await availabilityGroupListener.UpdateAsync(WaitUntil.Completed, data); @@ -150,32 +168,5 @@ public async Task Update_CreatesOrUpdatesAnAvailabilityGroupListenerThisIsUsedFo // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAnAvailabilityGroupListener() - { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/DeleteAvailabilityGroupListener.json - // this example is just showing the usage of "AvailabilityGroupListeners_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AvailabilityGroupListenerResource created on azure - // for more information of creating AvailabilityGroupListenerResource, please refer to the document of AvailabilityGroupListenerResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "testrg"; - string sqlVmGroupName = "testvmgroup"; - string availabilityGroupListenerName = "agl-test"; - ResourceIdentifier availabilityGroupListenerResourceId = AvailabilityGroupListenerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, sqlVmGroupName, availabilityGroupListenerName); - AvailabilityGroupListenerResource availabilityGroupListener = client.GetAvailabilityGroupListenerResource(availabilityGroupListenerResourceId); - - // invoke the operation - await availabilityGroupListener.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmCollection.cs b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmCollection.cs index 3a045dd2651b1..527709ddfb2b7 100644 --- a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmCollection.cs +++ b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmCollection.cs @@ -18,109 +18,6 @@ namespace Azure.ResourceManager.SqlVirtualMachine.Samples { public partial class Sample_SqlVmCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetsASQLVirtualMachine() - { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachine.json - // this example is just showing the usage of "SqlVirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this SqlVmResource - SqlVmCollection collection = resourceGroupResource.GetSqlVms(); - - // invoke the operation - string sqlVmName = "testvm"; - SqlVmResource result = await collection.GetAsync(sqlVmName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsASQLVirtualMachine() - { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachine.json - // this example is just showing the usage of "SqlVirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this SqlVmResource - SqlVmCollection collection = resourceGroupResource.GetSqlVms(); - - // invoke the operation - string sqlVmName = "testvm"; - bool result = await collection.ExistsAsync(sqlVmName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsASQLVirtualMachine() - { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachine.json - // this example is just showing the usage of "SqlVirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "testrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this SqlVmResource - SqlVmCollection collection = resourceGroupResource.GetSqlVms(); - - // invoke the operation - string sqlVmName = "testvm"; - NullableResponse response = await collection.GetIfExistsAsync(sqlVmName); - SqlVmResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineAndJoinsItToASQLVirtualMachineGroup() @@ -149,7 +46,7 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineAndJoinsItToA { VirtualMachineResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Compute/virtualMachines/testvm2"), SqlVmGroupResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachineGroups/testvmgroup"), - WindowsServerFailoverClusterDomainCredentials = new WindowsServerFailoverClusterDomainCredentials() + WindowsServerFailoverClusterDomainCredentials = new WindowsServerFailoverClusterDomainCredentials { ClusterBootstrapAccountPassword = "", ClusterOperatorAccountPassword = "", @@ -197,14 +94,14 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineForAutomatedB SqlServerLicenseType = SqlServerLicenseType.Payg, SqlManagement = SqlManagementMode.Full, SqlImageSku = SqlImageSku.Enterprise, - AutoPatchingSettings = new SqlVmAutoPatchingSettings() + AutoPatchingSettings = new SqlVmAutoPatchingSettings { IsEnabled = true, DayOfWeek = SqlVmAutoPatchingDayOfWeek.Sunday, MaintenanceWindowStartingHour = 2, MaintenanceWindowDurationInMinutes = 60, }, - AutoBackupSettings = new SqlVmAutoBackupSettings() + AutoBackupSettings = new SqlVmAutoBackupSettings { IsEnabled = true, IsEncryptionEnabled = true, @@ -216,21 +113,18 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineForAutomatedB AreSystemDbsIncludedInBackup = true, BackupScheduleType = SqVmBackupScheduleType.Manual, FullBackupFrequency = SqlVmFullBackupFrequency.Weekly, - DaysOfWeek = -{ -SqlVmAutoBackupDayOfWeek.Monday,SqlVmAutoBackupDayOfWeek.Friday -}, + DaysOfWeek = { SqlVmAutoBackupDayOfWeek.Monday, SqlVmAutoBackupDayOfWeek.Friday }, FullBackupStartHour = 6, FullBackupWindowHours = 11, LogBackupFrequency = 10, }, - KeyVaultCredentialSettings = new SqlVmKeyVaultCredentialSettings() + KeyVaultCredentialSettings = new SqlVmKeyVaultCredentialSettings { IsEnabled = false, }, - ServerConfigurationsManagementSettings = new SqlServerConfigurationsManagementSettings() + ServerConfigurationsManagementSettings = new SqlServerConfigurationsManagementSettings { - SqlConnectivityUpdateSettings = new SqlConnectivityUpdateSettings() + SqlConnectivityUpdateSettings = new SqlConnectivityUpdateSettings { ConnectivityType = SqlServerConnectivityType.Private, Port = 1433, @@ -238,7 +132,7 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineForAutomatedB SqlAuthUpdatePassword = "", }, SqlWorkloadType = SqlWorkloadType.Oltp, - SqlStorageUpdateSettings = new SqlStorageUpdateSettings() + SqlStorageUpdateSettings = new SqlStorageUpdateSettings { DiskCount = 1, StartingDeviceId = 2, @@ -284,14 +178,11 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineForStorageCon SqlVmData data = new SqlVmData(new AzureLocation("northeurope")) { VirtualMachineResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Compute/virtualMachines/testvm"), - StorageConfigurationSettings = new SqlVmStorageConfigurationSettings() + StorageConfigurationSettings = new SqlVmStorageConfigurationSettings { - SqlDataSettings = new SqlStorageSettings() + SqlDataSettings = new SqlStorageSettings { - Luns = -{ -2 -}, + Luns = { 2 }, }, DiskConfigurationType = SqlVmDiskConfigurationType.Extend, }, @@ -333,25 +224,19 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineForStorageCon SqlVmData data = new SqlVmData(new AzureLocation("northeurope")) { VirtualMachineResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Compute/virtualMachines/testvm"), - StorageConfigurationSettings = new SqlVmStorageConfigurationSettings() + StorageConfigurationSettings = new SqlVmStorageConfigurationSettings { - SqlDataSettings = new SqlStorageSettings() + SqlDataSettings = new SqlStorageSettings { - Luns = -{ -0 -}, + Luns = { 0 }, DefaultFilePath = "F:\\folderpath\\", }, - SqlLogSettings = new SqlStorageSettings() + SqlLogSettings = new SqlStorageSettings { - Luns = -{ -1 -}, + Luns = { 1 }, DefaultFilePath = "G:\\folderpath\\", }, - SqlTempDBSettings = new SqlTempDBSettings() + SqlTempDBSettings = new SqlTempDBSettings { DataFileSize = 256, DataGrowth = 512, @@ -405,14 +290,14 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineWithMaxParame SqlServerLicenseType = SqlServerLicenseType.Payg, SqlManagement = SqlManagementMode.Full, SqlImageSku = SqlImageSku.Enterprise, - AutoPatchingSettings = new SqlVmAutoPatchingSettings() + AutoPatchingSettings = new SqlVmAutoPatchingSettings { IsEnabled = true, DayOfWeek = SqlVmAutoPatchingDayOfWeek.Sunday, MaintenanceWindowStartingHour = 2, MaintenanceWindowDurationInMinutes = 60, }, - AutoBackupSettings = new SqlVmAutoBackupSettings() + AutoBackupSettings = new SqlVmAutoBackupSettings { IsEnabled = true, IsEncryptionEnabled = true, @@ -428,13 +313,13 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineWithMaxParame FullBackupWindowHours = 11, LogBackupFrequency = 10, }, - KeyVaultCredentialSettings = new SqlVmKeyVaultCredentialSettings() + KeyVaultCredentialSettings = new SqlVmKeyVaultCredentialSettings { IsEnabled = false, }, - ServerConfigurationsManagementSettings = new SqlServerConfigurationsManagementSettings() + ServerConfigurationsManagementSettings = new SqlServerConfigurationsManagementSettings { - SqlConnectivityUpdateSettings = new SqlConnectivityUpdateSettings() + SqlConnectivityUpdateSettings = new SqlConnectivityUpdateSettings { ConnectivityType = SqlServerConnectivityType.Private, Port = 1433, @@ -442,14 +327,14 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineWithMaxParame SqlAuthUpdatePassword = "", }, SqlWorkloadType = SqlWorkloadType.Oltp, - SqlStorageUpdateSettings = new SqlStorageUpdateSettings() + SqlStorageUpdateSettings = new SqlStorageUpdateSettings { DiskCount = 1, StartingDeviceId = 2, DiskConfigurationType = SqlVmDiskConfigurationType.New, }, IsRServicesEnabled = false, - SqlInstanceSettings = new SqlInstanceSettings() + SqlInstanceSettings = new SqlInstanceSettings { Collation = "SQL_Latin1_General_CP1_CI_AS", MaxDop = 8, @@ -460,15 +345,15 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineWithMaxParame IsIfiEnabled = true, }, }, - AssessmentSettings = new SqlVmAssessmentSettings() + AssessmentSettings = new SqlVmAssessmentSettings { IsEnabled = true, RunImmediately = true, - Schedule = new SqlVmAssessmentSchedule() + Schedule = new SqlVmAssessmentSchedule { IsEnabled = true, WeeklyInterval = 1, - MonthlyOccurrence = null, + MonthlyOccurrence = default, DayOfWeek = SqlVmAssessmentDayOfWeek.Sunday, StartTime = "23:17", }, @@ -522,6 +407,39 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineWithMinParame Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetsASQLVirtualMachine() + { + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachine.json + // this example is just showing the usage of "SqlVirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this SqlVmResource + SqlVmCollection collection = resourceGroupResource.GetSqlVms(); + + // invoke the operation + string sqlVmName = "testvm"; + SqlVmResource result = await collection.GetAsync(sqlVmName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_GetsAllSQLVirtualMachinesInAResourceGroup() @@ -556,5 +474,75 @@ public async Task GetAll_GetsAllSQLVirtualMachinesInAResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetsASQLVirtualMachine() + { + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachine.json + // this example is just showing the usage of "SqlVirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this SqlVmResource + SqlVmCollection collection = resourceGroupResource.GetSqlVms(); + + // invoke the operation + string sqlVmName = "testvm"; + bool result = await collection.ExistsAsync(sqlVmName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetsASQLVirtualMachine() + { + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachine.json + // this example is just showing the usage of "SqlVirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "testrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this SqlVmResource + SqlVmCollection collection = resourceGroupResource.GetSqlVms(); + + // invoke the operation + string sqlVmName = "testvm"; + NullableResponse response = await collection.GetIfExistsAsync(sqlVmName); + SqlVmResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmGroupCollection.cs b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmGroupCollection.cs index 01c6643678580..eba7ebdaf0803 100644 --- a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmGroupCollection.cs +++ b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmGroupCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SqlVmGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsASQLVirtualMachineGroup() + public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineGroup() { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachineGroup.json - // this example is just showing the usage of "SqlVirtualMachineGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/CreateOrUpdateSqlVirtualMachineGroup.json + // this example is just showing the usage of "SqlVirtualMachineGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,28 @@ public async Task Get_GetsASQLVirtualMachineGroup() // invoke the operation string sqlVmGroupName = "testvmgroup"; - SqlVmGroupResource result = await collection.GetAsync(sqlVmGroupName); + SqlVmGroupData data = new SqlVmGroupData(new AzureLocation("northeurope")) + { + SqlImageOffer = "SQL2016-WS2016", + SqlImageSku = SqlVmGroupImageSku.Enterprise, + WindowsServerFailoverClusterDomainProfile = new WindowsServerFailoverClusterDomainProfile + { + DomainFqdn = "testdomain.com", + OrganizationalUnitPath = "OU=WSCluster,DC=testdomain,DC=com", + ClusterBootstrapAccount = "testrpadmin", + ClusterOperatorAccount = "testrp@testdomain.com", + SqlServiceAccount = "sqlservice@testdomain.com", + StorageAccountUri = new Uri("https://storgact.blob.core.windows.net/"), + StorageAccountPrimaryKey = "", + ClusterSubnetType = SqlVmClusterSubnetType.MultiSubnet, + }, + Tags = +{ +["mytag"] = "myval" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlVmGroupName, data); + SqlVmGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +73,7 @@ public async Task Get_GetsASQLVirtualMachineGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsASQLVirtualMachineGroup() + public async Task Get_GetsASQLVirtualMachineGroup() { // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachineGroup.json // this example is just showing the usage of "SqlVirtualMachineGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +95,21 @@ public async Task Exists_GetsASQLVirtualMachineGroup() // invoke the operation string sqlVmGroupName = "testvmgroup"; - bool result = await collection.ExistsAsync(sqlVmGroupName); + SqlVmGroupResource result = await collection.GetAsync(sqlVmGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVmGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsASQLVirtualMachineGroup() + public async Task GetAll_GetsAllSQLVirtualMachineGroupsInAResourceGroup() { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachineGroup.json - // this example is just showing the usage of "SqlVirtualMachineGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/ListByResourceGroupSqlVirtualMachineGroup.json + // this example is just showing the usage of "SqlVirtualMachineGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +126,25 @@ public async Task GetIfExists_GetsASQLVirtualMachineGroup() // get the collection of this SqlVmGroupResource SqlVmGroupCollection collection = resourceGroupResource.GetSqlVmGroups(); - // invoke the operation - string sqlVmGroupName = "testvmgroup"; - NullableResponse response = await collection.GetIfExistsAsync(sqlVmGroupName); - SqlVmGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SqlVmGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlVmGroupData resourceData = result.Data; + SqlVmGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineGroup() + public async Task Exists_GetsASQLVirtualMachineGroup() { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/CreateOrUpdateSqlVirtualMachineGroup.json - // this example is just showing the usage of "SqlVirtualMachineGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachineGroup.json + // this example is just showing the usage of "SqlVirtualMachineGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,42 +163,17 @@ public async Task CreateOrUpdate_CreatesOrUpdatesASQLVirtualMachineGroup() // invoke the operation string sqlVmGroupName = "testvmgroup"; - SqlVmGroupData data = new SqlVmGroupData(new AzureLocation("northeurope")) - { - SqlImageOffer = "SQL2016-WS2016", - SqlImageSku = SqlVmGroupImageSku.Enterprise, - WindowsServerFailoverClusterDomainProfile = new WindowsServerFailoverClusterDomainProfile() - { - DomainFqdn = "testdomain.com", - OrganizationalUnitPath = "OU=WSCluster,DC=testdomain,DC=com", - ClusterBootstrapAccount = "testrpadmin", - ClusterOperatorAccount = "testrp@testdomain.com", - SqlServiceAccount = "sqlservice@testdomain.com", - StorageAccountUri = new Uri("https://storgact.blob.core.windows.net/"), - StorageAccountPrimaryKey = "", - ClusterSubnetType = SqlVmClusterSubnetType.MultiSubnet, - }, - Tags = -{ -["mytag"] = "myval", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlVmGroupName, data); - SqlVmGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(sqlVmGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVmGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsAllSQLVirtualMachineGroupsInAResourceGroup() + public async Task GetIfExists_GetsASQLVirtualMachineGroup() { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/ListByResourceGroupSqlVirtualMachineGroup.json - // this example is just showing the usage of "SqlVirtualMachineGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/GetSqlVirtualMachineGroup.json + // this example is just showing the usage of "SqlVirtualMachineGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,17 +190,23 @@ public async Task GetAll_GetsAllSQLVirtualMachineGroupsInAResourceGroup() // get the collection of this SqlVmGroupResource SqlVmGroupCollection collection = resourceGroupResource.GetSqlVmGroups(); - // invoke the operation and iterate over the result - await foreach (SqlVmGroupResource item in collection.GetAllAsync()) + // invoke the operation + string sqlVmGroupName = "testvmgroup"; + NullableResponse response = await collection.GetIfExistsAsync(sqlVmGroupName); + SqlVmGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlVmGroupData resourceData = item.Data; + SqlVmGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmGroupResource.cs b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmGroupResource.cs index af5d51b7835ea..79b23d586a0b5 100644 --- a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmGroupResource.cs +++ b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmGroupResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SqlVirtualMachine.Models; using NUnit.Framework; @@ -94,11 +93,11 @@ public async Task Update_UpdatesASQLVirtualMachineGroupTags() SqlVmGroupResource sqlVmGroup = client.GetSqlVmGroupResource(sqlVmGroupResourceId); // invoke the operation - SqlVmGroupPatch patch = new SqlVmGroupPatch() + SqlVmGroupPatch patch = new SqlVmGroupPatch { Tags = { -["mytag"] = "myval", +["mytag"] = "myval" }, }; ArmOperation lro = await sqlVmGroup.UpdateAsync(WaitUntil.Completed, patch); @@ -111,37 +110,6 @@ public async Task Update_UpdatesASQLVirtualMachineGroupTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSqlVmGroups_GetsAllSQLVirtualMachineGroupsInASubscription() - { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/ListSubscriptionSqlVirtualMachineGroup.json - // this example is just showing the usage of "SqlVirtualMachineGroups_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SqlVmGroupResource item in subscriptionResource.GetSqlVmGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVmGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSqlVmsBySqlVmGroup_GetsTheListOfSqlVirtualMachinesInASQLVirtualMachineGroup() diff --git a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmResource.cs b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmResource.cs index 2f2618e369dea..5bee00f1d11ed 100644 --- a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmResource.cs +++ b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SqlVmResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.SqlVirtualMachine.Models; using NUnit.Framework; @@ -17,37 +16,6 @@ namespace Azure.ResourceManager.SqlVirtualMachine.Samples { public partial class Sample_SqlVmResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSqlVms_GetsAllSQLVirtualMachinesInASubscription() - { - // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/ListSubscriptionSqlVirtualMachine.json - // this example is just showing the usage of "SqlVirtualMachines_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SqlVmResource item in subscriptionResource.GetSqlVmsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlVmData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetsASQLVirtualMachine() @@ -125,11 +93,11 @@ public async Task Update_UpdatesASQLVirtualMachineTags() SqlVmResource sqlVm = client.GetSqlVmResource(sqlVmResourceId); // invoke the operation - SqlVmPatch patch = new SqlVmPatch() + SqlVmPatch patch = new SqlVmPatch { Tags = { -["mytag"] = "myval", +["mytag"] = "myval" }, }; ArmOperation lro = await sqlVm.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..4c360c3df1271 --- /dev/null +++ b/sdk/sqlvirtualmachine/Azure.ResourceManager.SqlVirtualMachine/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.SqlVirtualMachine.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSqlVmGroups_GetsAllSQLVirtualMachineGroupsInASubscription() + { + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/ListSubscriptionSqlVirtualMachineGroup.json + // this example is just showing the usage of "SqlVirtualMachineGroups_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SqlVmGroupResource item in subscriptionResource.GetSqlVmGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVmGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSqlVms_GetsAllSQLVirtualMachinesInASubscription() + { + // Generated from example definition: specification/sqlvirtualmachine/resource-manager/Microsoft.SqlVirtualMachine/stable/2022-02-01/examples/ListSubscriptionSqlVirtualMachine.json + // this example is just showing the usage of "SqlVirtualMachines_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SqlVmResource item in subscriptionResource.GetSqlVmsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlVmData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolCollection.cs b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolCollection.cs index c8bee63bb07c5..12d0a64fe8a6f 100644 --- a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolCollection.cs +++ b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_StandbyContainerGroupPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StandbyContainerGroupPoolsGet() + public async Task CreateOrUpdate_StandbyContainerGroupPoolsCreateOrUpdate() { - // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_Get.json - // this example is just showing the usage of "StandbyContainerGroupPoolResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_CreateOrUpdate.json + // this example is just showing the usage of "StandbyContainerGroupPoolResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,25 @@ public async Task Get_StandbyContainerGroupPoolsGet() // invoke the operation string standbyContainerGroupPoolName = "pool"; - StandbyContainerGroupPoolResource result = await collection.GetAsync(standbyContainerGroupPoolName); + StandbyContainerGroupPoolData data = new StandbyContainerGroupPoolData(new AzureLocation("West US")) + { + Properties = new StandbyContainerGroupPoolProperties(new StandbyContainerGroupPoolElasticityProfile(688L) + { + RefillPolicy = StandbyRefillPolicy.Always, + }, new StandbyContainerGroupProperties(new StandbyContainerGroupProfile(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000009/resourceGroups/rgstandbypool/providers/Microsoft.ContainerInstance/containerGroupProfiles/cgProfile")) + { + Revision = 1L, + }) + { + SubnetIds = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000009/resourceGroups/rgstandbypool/providers/Microsoft.Network/virtualNetworks/cgSubnet/subnets/cgSubnet"), +}}, + }), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, standbyContainerGroupPoolName, data); + StandbyContainerGroupPoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +71,7 @@ public async Task Get_StandbyContainerGroupPoolsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StandbyContainerGroupPoolsGet() + public async Task Get_StandbyContainerGroupPoolsGet() { // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_Get.json // this example is just showing the usage of "StandbyContainerGroupPoolResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +93,21 @@ public async Task Exists_StandbyContainerGroupPoolsGet() // invoke the operation string standbyContainerGroupPoolName = "pool"; - bool result = await collection.ExistsAsync(standbyContainerGroupPoolName); + StandbyContainerGroupPoolResource result = await collection.GetAsync(standbyContainerGroupPoolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StandbyContainerGroupPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StandbyContainerGroupPoolsGet() + public async Task GetAll_StandbyContainerGroupPoolsListByResourceGroup() { - // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_Get.json - // this example is just showing the usage of "StandbyContainerGroupPoolResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_ListByResourceGroup.json + // this example is just showing the usage of "StandbyContainerGroupPoolResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +124,25 @@ public async Task GetIfExists_StandbyContainerGroupPoolsGet() // get the collection of this StandbyContainerGroupPoolResource StandbyContainerGroupPoolCollection collection = resourceGroupResource.GetStandbyContainerGroupPools(); - // invoke the operation - string standbyContainerGroupPoolName = "pool"; - NullableResponse response = await collection.GetIfExistsAsync(standbyContainerGroupPoolName); - StandbyContainerGroupPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (StandbyContainerGroupPoolResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StandbyContainerGroupPoolData resourceData = result.Data; + StandbyContainerGroupPoolData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StandbyContainerGroupPoolsCreateOrUpdate() + public async Task Exists_StandbyContainerGroupPoolsGet() { - // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_CreateOrUpdate.json - // this example is just showing the usage of "StandbyContainerGroupPoolResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_Get.json + // this example is just showing the usage of "StandbyContainerGroupPoolResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,44 +161,17 @@ public async Task CreateOrUpdate_StandbyContainerGroupPoolsCreateOrUpdate() // invoke the operation string standbyContainerGroupPoolName = "pool"; - StandbyContainerGroupPoolData data = new StandbyContainerGroupPoolData(new AzureLocation("West US")) - { - Properties = new StandbyContainerGroupPoolProperties(new StandbyContainerGroupPoolElasticityProfile(688L) - { - RefillPolicy = StandbyRefillPolicy.Always, - }, new StandbyContainerGroupProperties(new StandbyContainerGroupProfile(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000009/resourceGroups/rgstandbypool/providers/Microsoft.ContainerInstance/containerGroupProfiles/cgProfile")) - { - Revision = 1L, - }) - { - SubnetIds = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000009/resourceGroups/rgstandbypool/providers/Microsoft.Network/virtualNetworks/cgSubnet/subnets/cgSubnet"), -} -}, - }), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, standbyContainerGroupPoolName, data); - StandbyContainerGroupPoolResource result = lro.Value; + bool result = await collection.ExistsAsync(standbyContainerGroupPoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StandbyContainerGroupPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StandbyContainerGroupPoolsListByResourceGroup() + public async Task GetIfExists_StandbyContainerGroupPoolsGet() { - // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_ListByResourceGroup.json - // this example is just showing the usage of "StandbyContainerGroupPoolResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_Get.json + // this example is just showing the usage of "StandbyContainerGroupPoolResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,17 +188,23 @@ public async Task GetAll_StandbyContainerGroupPoolsListByResourceGroup() // get the collection of this StandbyContainerGroupPoolResource StandbyContainerGroupPoolCollection collection = resourceGroupResource.GetStandbyContainerGroupPools(); - // invoke the operation and iterate over the result - await foreach (StandbyContainerGroupPoolResource item in collection.GetAllAsync()) + // invoke the operation + string standbyContainerGroupPoolName = "pool"; + NullableResponse response = await collection.GetIfExistsAsync(standbyContainerGroupPoolName); + StandbyContainerGroupPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StandbyContainerGroupPoolData resourceData = item.Data; + StandbyContainerGroupPoolData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolResource.cs b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolResource.cs index 04fb4863e9c53..fa2a89966741a 100644 --- a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolResource.cs +++ b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.StandbyPool.Models; using NUnit.Framework; @@ -95,12 +94,10 @@ public async Task Update_StandbyContainerGroupPoolsUpdate() StandbyContainerGroupPoolResource standbyContainerGroupPool = client.GetStandbyContainerGroupPoolResource(standbyContainerGroupPoolResourceId); // invoke the operation - StandbyContainerGroupPoolPatch patch = new StandbyContainerGroupPoolPatch() + StandbyContainerGroupPoolPatch patch = new StandbyContainerGroupPoolPatch { - Tags = -{ -}, - Properties = new StandbyContainerGroupPoolUpdateProperties() + Tags = { }, + Properties = new StandbyContainerGroupPoolUpdateProperties { ElasticityProfile = new StandbyContainerGroupPoolElasticityProfile(1743L) { @@ -111,13 +108,10 @@ public async Task Update_StandbyContainerGroupPoolsUpdate() Revision = 2L, }) { - SubnetIds = -{ -new WritableSubResource() + SubnetIds = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000009/resourceGroups/rgstandbypool/providers/Microsoft.Network/virtualNetworks/cgSubnet/subnets/cgSubnet"), -} -}, +}}, }, }, }; @@ -129,36 +123,5 @@ public async Task Update_StandbyContainerGroupPoolsUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetStandbyContainerGroupPools_StandbyContainerGroupPoolsListBySubscription() - { - // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_ListBySubscription.json - // this example is just showing the usage of "StandbyContainerGroupPoolResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000009"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (StandbyContainerGroupPoolResource item in subscriptionResource.GetStandbyContainerGroupPoolsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StandbyContainerGroupPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolRuntimeViewCollection.cs b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolRuntimeViewCollection.cs index 10080ce9b9159..134ac36df3a33 100644 --- a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolRuntimeViewCollection.cs +++ b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyContainerGroupPoolRuntimeViewCollection.cs @@ -51,10 +51,10 @@ public async Task Get_StandbyContainerGroupPoolRuntimeViewsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StandbyContainerGroupPoolRuntimeViewsGet() + public async Task GetAll_StandbyContainerGroupPoolRuntimeViewsListByStandbyPool() { - // Generated from example definition: 2024-03-01/StandbyContainerGroupPoolRuntimeViews_Get.json - // this example is just showing the usage of "StandbyContainerGroupPoolRuntimeViewResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyContainerGroupPoolRuntimeViews_ListByStandbyPool.json + // this example is just showing the usage of "StandbyContainerGroupPoolRuntimeViewResource_ListByStandbyPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_StandbyContainerGroupPoolRuntimeViewsGet() // get the collection of this StandbyContainerGroupPoolRuntimeViewResource StandbyContainerGroupPoolRuntimeViewCollection collection = standbyContainerGroupPool.GetStandbyContainerGroupPoolRuntimeViews(); - // invoke the operation - string runtimeView = "latest"; - bool result = await collection.ExistsAsync(runtimeView); + // invoke the operation and iterate over the result + await foreach (StandbyContainerGroupPoolRuntimeViewResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StandbyContainerGroupPoolRuntimeViewData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StandbyContainerGroupPoolRuntimeViewsGet() + public async Task Exists_StandbyContainerGroupPoolRuntimeViewsGet() { // Generated from example definition: 2024-03-01/StandbyContainerGroupPoolRuntimeViews_Get.json // this example is just showing the usage of "StandbyContainerGroupPoolRuntimeViewResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_StandbyContainerGroupPoolRuntimeViewsGet() // invoke the operation string runtimeView = "latest"; - NullableResponse response = await collection.GetIfExistsAsync(runtimeView); - StandbyContainerGroupPoolRuntimeViewResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(runtimeView); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StandbyContainerGroupPoolRuntimeViewData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StandbyContainerGroupPoolRuntimeViewsListByStandbyPool() + public async Task GetIfExists_StandbyContainerGroupPoolRuntimeViewsGet() { - // Generated from example definition: 2024-03-01/StandbyContainerGroupPoolRuntimeViews_ListByStandbyPool.json - // this example is just showing the usage of "StandbyContainerGroupPoolRuntimeViewResource_ListByStandbyPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyContainerGroupPoolRuntimeViews_Get.json + // this example is just showing the usage of "StandbyContainerGroupPoolRuntimeViewResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_StandbyContainerGroupPoolRuntimeViewsListByStandbyPool( // get the collection of this StandbyContainerGroupPoolRuntimeViewResource StandbyContainerGroupPoolRuntimeViewCollection collection = standbyContainerGroupPool.GetStandbyContainerGroupPoolRuntimeViews(); - // invoke the operation and iterate over the result - await foreach (StandbyContainerGroupPoolRuntimeViewResource item in collection.GetAllAsync()) + // invoke the operation + string runtimeView = "latest"; + NullableResponse response = await collection.GetIfExistsAsync(runtimeView); + StandbyContainerGroupPoolRuntimeViewResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StandbyContainerGroupPoolRuntimeViewData resourceData = item.Data; + StandbyContainerGroupPoolRuntimeViewData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachineCollection.cs b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachineCollection.cs index e594218851015..a5625c622c8cb 100644 --- a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachineCollection.cs +++ b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachineCollection.cs @@ -51,10 +51,10 @@ public async Task Get_StandbyVirtualMachinesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StandbyVirtualMachinesGet() + public async Task GetAll_StandbyVirtualMachinesListByStandbyVirtualMachinePoolResource() { - // Generated from example definition: 2024-03-01/StandbyVirtualMachines_Get.json - // this example is just showing the usage of "StandbyVirtualMachineResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyVirtualMachines_ListByStandbyVirtualMachinePoolResource.json + // this example is just showing the usage of "StandbyVirtualMachineResource_ListByStandbyVirtualMachinePoolResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_StandbyVirtualMachinesGet() // get the collection of this StandbyVirtualMachineResource StandbyVirtualMachineCollection collection = standbyVirtualMachinePool.GetStandbyVirtualMachines(); - // invoke the operation - string standbyVirtualMachineName = "virtualMachine"; - bool result = await collection.ExistsAsync(standbyVirtualMachineName); + // invoke the operation and iterate over the result + await foreach (StandbyVirtualMachineResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StandbyVirtualMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StandbyVirtualMachinesGet() + public async Task Exists_StandbyVirtualMachinesGet() { // Generated from example definition: 2024-03-01/StandbyVirtualMachines_Get.json // this example is just showing the usage of "StandbyVirtualMachineResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_StandbyVirtualMachinesGet() // invoke the operation string standbyVirtualMachineName = "virtualMachine"; - NullableResponse response = await collection.GetIfExistsAsync(standbyVirtualMachineName); - StandbyVirtualMachineResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(standbyVirtualMachineName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StandbyVirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StandbyVirtualMachinesListByStandbyVirtualMachinePoolResource() + public async Task GetIfExists_StandbyVirtualMachinesGet() { - // Generated from example definition: 2024-03-01/StandbyVirtualMachines_ListByStandbyVirtualMachinePoolResource.json - // this example is just showing the usage of "StandbyVirtualMachineResource_ListByStandbyVirtualMachinePoolResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyVirtualMachines_Get.json + // this example is just showing the usage of "StandbyVirtualMachineResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_StandbyVirtualMachinesListByStandbyVirtualMachinePoolRe // get the collection of this StandbyVirtualMachineResource StandbyVirtualMachineCollection collection = standbyVirtualMachinePool.GetStandbyVirtualMachines(); - // invoke the operation and iterate over the result - await foreach (StandbyVirtualMachineResource item in collection.GetAllAsync()) + // invoke the operation + string standbyVirtualMachineName = "virtualMachine"; + NullableResponse response = await collection.GetIfExistsAsync(standbyVirtualMachineName); + StandbyVirtualMachineResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StandbyVirtualMachineData resourceData = item.Data; + StandbyVirtualMachineData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolCollection.cs b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolCollection.cs index 0f8c4325d9378..ce02a08199c92 100644 --- a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolCollection.cs +++ b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_StandbyVirtualMachinePoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StandbyVirtualMachinePoolsGet() + public async Task CreateOrUpdate_StandbyVirtualMachinePoolsCreateOrUpdate() { - // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_Get.json - // this example is just showing the usage of "StandbyVirtualMachinePoolResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_CreateOrUpdate.json + // this example is just showing the usage of "StandbyVirtualMachinePoolResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,20 @@ public async Task Get_StandbyVirtualMachinePoolsGet() // invoke the operation string standbyVirtualMachinePoolName = "pool"; - StandbyVirtualMachinePoolResource result = await collection.GetAsync(standbyVirtualMachinePoolName); + StandbyVirtualMachinePoolData data = new StandbyVirtualMachinePoolData(new AzureLocation("West US")) + { + Properties = new StandbyVirtualMachinePoolProperties(StandbyVirtualMachineState.Running) + { + ElasticityProfile = new StandbyVirtualMachinePoolElasticityProfile(304L) + { + MinReadyCapacity = 300L, + }, + AttachedVirtualMachineScaleSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000009/resourceGroups/rgstandbypool/providers/Microsoft.Compute/virtualMachineScaleSets/myVmss"), + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, standbyVirtualMachinePoolName, data); + StandbyVirtualMachinePoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +65,7 @@ public async Task Get_StandbyVirtualMachinePoolsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StandbyVirtualMachinePoolsGet() + public async Task Get_StandbyVirtualMachinePoolsGet() { // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_Get.json // this example is just showing the usage of "StandbyVirtualMachinePoolResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +87,21 @@ public async Task Exists_StandbyVirtualMachinePoolsGet() // invoke the operation string standbyVirtualMachinePoolName = "pool"; - bool result = await collection.ExistsAsync(standbyVirtualMachinePoolName); + StandbyVirtualMachinePoolResource result = await collection.GetAsync(standbyVirtualMachinePoolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StandbyVirtualMachinePoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StandbyVirtualMachinePoolsGet() + public async Task GetAll_StandbyVirtualMachinePoolsListByResourceGroup() { - // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_Get.json - // this example is just showing the usage of "StandbyVirtualMachinePoolResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_ListByResourceGroup.json + // this example is just showing the usage of "StandbyVirtualMachinePoolResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +118,25 @@ public async Task GetIfExists_StandbyVirtualMachinePoolsGet() // get the collection of this StandbyVirtualMachinePoolResource StandbyVirtualMachinePoolCollection collection = resourceGroupResource.GetStandbyVirtualMachinePools(); - // invoke the operation - string standbyVirtualMachinePoolName = "pool"; - NullableResponse response = await collection.GetIfExistsAsync(standbyVirtualMachinePoolName); - StandbyVirtualMachinePoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (StandbyVirtualMachinePoolResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StandbyVirtualMachinePoolData resourceData = result.Data; + StandbyVirtualMachinePoolData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StandbyVirtualMachinePoolsCreateOrUpdate() + public async Task Exists_StandbyVirtualMachinePoolsGet() { - // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_CreateOrUpdate.json - // this example is just showing the usage of "StandbyVirtualMachinePoolResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_Get.json + // this example is just showing the usage of "StandbyVirtualMachinePoolResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,36 +155,17 @@ public async Task CreateOrUpdate_StandbyVirtualMachinePoolsCreateOrUpdate() // invoke the operation string standbyVirtualMachinePoolName = "pool"; - StandbyVirtualMachinePoolData data = new StandbyVirtualMachinePoolData(new AzureLocation("West US")) - { - Properties = new StandbyVirtualMachinePoolProperties(StandbyVirtualMachineState.Running) - { - ElasticityProfile = new StandbyVirtualMachinePoolElasticityProfile(304L) - { - MinReadyCapacity = 300L, - }, - AttachedVirtualMachineScaleSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000009/resourceGroups/rgstandbypool/providers/Microsoft.Compute/virtualMachineScaleSets/myVmss"), - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, standbyVirtualMachinePoolName, data); - StandbyVirtualMachinePoolResource result = lro.Value; + bool result = await collection.ExistsAsync(standbyVirtualMachinePoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StandbyVirtualMachinePoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StandbyVirtualMachinePoolsListByResourceGroup() + public async Task GetIfExists_StandbyVirtualMachinePoolsGet() { - // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_ListByResourceGroup.json - // this example is just showing the usage of "StandbyVirtualMachinePoolResource_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_Get.json + // this example is just showing the usage of "StandbyVirtualMachinePoolResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +182,23 @@ public async Task GetAll_StandbyVirtualMachinePoolsListByResourceGroup() // get the collection of this StandbyVirtualMachinePoolResource StandbyVirtualMachinePoolCollection collection = resourceGroupResource.GetStandbyVirtualMachinePools(); - // invoke the operation and iterate over the result - await foreach (StandbyVirtualMachinePoolResource item in collection.GetAllAsync()) + // invoke the operation + string standbyVirtualMachinePoolName = "pool"; + NullableResponse response = await collection.GetIfExistsAsync(standbyVirtualMachinePoolName); + StandbyVirtualMachinePoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StandbyVirtualMachinePoolData resourceData = item.Data; + StandbyVirtualMachinePoolData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolResource.cs b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolResource.cs index f21b764baa31c..1667a8484d070 100644 --- a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolResource.cs +++ b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.StandbyPool.Models; using NUnit.Framework; @@ -94,12 +93,10 @@ public async Task Update_StandbyVirtualMachinePoolsUpdate() StandbyVirtualMachinePoolResource standbyVirtualMachinePool = client.GetStandbyVirtualMachinePoolResource(standbyVirtualMachinePoolResourceId); // invoke the operation - StandbyVirtualMachinePoolPatch patch = new StandbyVirtualMachinePoolPatch() + StandbyVirtualMachinePoolPatch patch = new StandbyVirtualMachinePoolPatch { - Tags = -{ -}, - Properties = new StandbyVirtualMachinePoolUpdateProperties() + Tags = { }, + Properties = new StandbyVirtualMachinePoolUpdateProperties { ElasticityProfile = new StandbyVirtualMachinePoolElasticityProfile(304L) { @@ -117,36 +114,5 @@ public async Task Update_StandbyVirtualMachinePoolsUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetStandbyVirtualMachinePools_StandbyVirtualMachinePoolsListBySubscription() - { - // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_ListBySubscription.json - // this example is just showing the usage of "StandbyVirtualMachinePoolResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000009"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (StandbyVirtualMachinePoolResource item in subscriptionResource.GetStandbyVirtualMachinePoolsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StandbyVirtualMachinePoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolRuntimeViewCollection.cs b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolRuntimeViewCollection.cs index 2624ee38922cb..2d38aeca664c4 100644 --- a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolRuntimeViewCollection.cs +++ b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_StandbyVirtualMachinePoolRuntimeViewCollection.cs @@ -51,10 +51,10 @@ public async Task Get_StandbyVirtualMachinePoolRuntimeViewsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StandbyVirtualMachinePoolRuntimeViewsGet() + public async Task GetAll_StandbyVirtualMachinePoolRuntimeViewsListByStandbyPool() { - // Generated from example definition: 2024-03-01/StandbyVirtualMachinePoolRuntimeViews_Get.json - // this example is just showing the usage of "StandbyVirtualMachinePoolRuntimeViewResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyVirtualMachinePoolRuntimeViews_ListByStandbyPool.json + // this example is just showing the usage of "StandbyVirtualMachinePoolRuntimeViewResource_ListByStandbyPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_StandbyVirtualMachinePoolRuntimeViewsGet() // get the collection of this StandbyVirtualMachinePoolRuntimeViewResource StandbyVirtualMachinePoolRuntimeViewCollection collection = standbyVirtualMachinePool.GetStandbyVirtualMachinePoolRuntimeViews(); - // invoke the operation - string runtimeView = "latest"; - bool result = await collection.ExistsAsync(runtimeView); + // invoke the operation and iterate over the result + await foreach (StandbyVirtualMachinePoolRuntimeViewResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StandbyVirtualMachinePoolRuntimeViewData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StandbyVirtualMachinePoolRuntimeViewsGet() + public async Task Exists_StandbyVirtualMachinePoolRuntimeViewsGet() { // Generated from example definition: 2024-03-01/StandbyVirtualMachinePoolRuntimeViews_Get.json // this example is just showing the usage of "StandbyVirtualMachinePoolRuntimeViewResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_StandbyVirtualMachinePoolRuntimeViewsGet() // invoke the operation string runtimeView = "latest"; - NullableResponse response = await collection.GetIfExistsAsync(runtimeView); - StandbyVirtualMachinePoolRuntimeViewResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(runtimeView); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StandbyVirtualMachinePoolRuntimeViewData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StandbyVirtualMachinePoolRuntimeViewsListByStandbyPool() + public async Task GetIfExists_StandbyVirtualMachinePoolRuntimeViewsGet() { - // Generated from example definition: 2024-03-01/StandbyVirtualMachinePoolRuntimeViews_ListByStandbyPool.json - // this example is just showing the usage of "StandbyVirtualMachinePoolRuntimeViewResource_ListByStandbyPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StandbyVirtualMachinePoolRuntimeViews_Get.json + // this example is just showing the usage of "StandbyVirtualMachinePoolRuntimeViewResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_StandbyVirtualMachinePoolRuntimeViewsListByStandbyPool( // get the collection of this StandbyVirtualMachinePoolRuntimeViewResource StandbyVirtualMachinePoolRuntimeViewCollection collection = standbyVirtualMachinePool.GetStandbyVirtualMachinePoolRuntimeViews(); - // invoke the operation and iterate over the result - await foreach (StandbyVirtualMachinePoolRuntimeViewResource item in collection.GetAllAsync()) + // invoke the operation + string runtimeView = "latest"; + NullableResponse response = await collection.GetIfExistsAsync(runtimeView); + StandbyVirtualMachinePoolRuntimeViewResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StandbyVirtualMachinePoolRuntimeViewData resourceData = item.Data; + StandbyVirtualMachinePoolRuntimeViewData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..7e37ead3c509c --- /dev/null +++ b/sdk/standbypool/Azure.ResourceManager.StandbyPool/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.StandbyPool.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStandbyVirtualMachinePools_StandbyVirtualMachinePoolsListBySubscription() + { + // Generated from example definition: 2024-03-01/StandbyVirtualMachinePools_ListBySubscription.json + // this example is just showing the usage of "StandbyVirtualMachinePoolResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000009"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (StandbyVirtualMachinePoolResource item in subscriptionResource.GetStandbyVirtualMachinePoolsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StandbyVirtualMachinePoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStandbyContainerGroupPools_StandbyContainerGroupPoolsListBySubscription() + { + // Generated from example definition: 2024-03-01/StandbyContainerGroupPools_ListBySubscription.json + // this example is just showing the usage of "StandbyContainerGroupPoolResource_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000009"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (StandbyContainerGroupPoolResource item in subscriptionResource.GetStandbyContainerGroupPoolsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StandbyContainerGroupPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobContainerCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobContainerCollection.cs index eb47976324e9a..6eab63b608d5e 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobContainerCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobContainerCollection.cs @@ -16,79 +16,6 @@ namespace Azure.ResourceManager.Storage.Samples { public partial class Sample_BlobContainerCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListContainers() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersList.json - // this example is just showing the usage of "BlobContainers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BlobServiceResource created on azure - // for more information of creating BlobServiceResource, please refer to the document of BlobServiceResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9290"; - string accountName = "sto1590"; - ResourceIdentifier blobServiceResourceId = BlobServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId); - - // get the collection of this BlobContainerResource - BlobContainerCollection collection = blobService.GetBlobContainers(); - - // invoke the operation and iterate over the result - await foreach (BlobContainerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BlobContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDeletedContainers() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/DeletedBlobContainersList.json - // this example is just showing the usage of "BlobContainers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BlobServiceResource created on azure - // for more information of creating BlobServiceResource, please refer to the document of BlobServiceResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9290"; - string accountName = "sto1590"; - ResourceIdentifier blobServiceResourceId = BlobServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId); - - // get the collection of this BlobContainerResource - BlobContainerCollection collection = blobService.GetBlobContainers(); - - // invoke the operation and iterate over the result - BlobContainerState? include = BlobContainerState.Deleted; - await foreach (BlobContainerResource item in collection.GetAllAsync(include: include)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BlobContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_PutContainerWithDefaultEncryptionScope() @@ -114,7 +41,7 @@ public async Task CreateOrUpdate_PutContainerWithDefaultEncryptionScope() // invoke the operation string containerName = "container6185"; - BlobContainerData data = new BlobContainerData() + BlobContainerData data = new BlobContainerData { DefaultEncryptionScope = "encryptionscope185", PreventEncryptionScopeOverride = true, @@ -154,9 +81,9 @@ public async Task CreateOrUpdate_PutContainerWithObjectLevelWorm() // invoke the operation string containerName = "container6185"; - BlobContainerData data = new BlobContainerData() + BlobContainerData data = new BlobContainerData { - ImmutableStorageWithVersioning = new ImmutableStorageWithVersioning() + ImmutableStorageWithVersioning = new ImmutableStorageWithVersioning { IsEnabled = true, }, @@ -243,9 +170,9 @@ public async Task Get_GetBlobContainersGetWithAllowProtectedAppendWritesAll() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetBlobContainersGetWithAllowProtectedAppendWritesAll() + public async Task Get_GetContainers() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGetWithAllowProtectedAppendWritesAll.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGet.json // this example is just showing the usage of "BlobContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -266,17 +193,21 @@ public async Task Exists_GetBlobContainersGetWithAllowProtectedAppendWritesAll() // invoke the operation string containerName = "container1634"; - bool result = await collection.ExistsAsync(containerName); + BlobContainerResource result = await collection.GetAsync(containerName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BlobContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetBlobContainersGetWithAllowProtectedAppendWritesAll() + public async Task GetAll_ListContainers() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGetWithAllowProtectedAppendWritesAll.json - // this example is just showing the usage of "BlobContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersList.json + // this example is just showing the usage of "BlobContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -286,38 +217,69 @@ public async Task GetIfExists_GetBlobContainersGetWithAllowProtectedAppendWrites // this example assumes you already have this BlobServiceResource created on azure // for more information of creating BlobServiceResource, please refer to the document of BlobServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9871"; - string accountName = "sto6217"; + string resourceGroupName = "res9290"; + string accountName = "sto1590"; ResourceIdentifier blobServiceResourceId = BlobServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId); // get the collection of this BlobContainerResource BlobContainerCollection collection = blobService.GetBlobContainers(); - // invoke the operation - string containerName = "container1634"; - NullableResponse response = await collection.GetIfExistsAsync(containerName); - BlobContainerResource result = response.HasValue ? response.Value : null; - - if (result == null) + // invoke the operation and iterate over the result + await foreach (BlobContainerResource item in collection.GetAllAsync()) { - Console.WriteLine("Succeeded with null as result"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BlobContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - else + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListDeletedContainers() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/DeletedBlobContainersList.json + // this example is just showing the usage of "BlobContainers_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BlobServiceResource created on azure + // for more information of creating BlobServiceResource, please refer to the document of BlobServiceResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "res9290"; + string accountName = "sto1590"; + ResourceIdentifier blobServiceResourceId = BlobServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId); + + // get the collection of this BlobContainerResource + BlobContainerCollection collection = blobService.GetBlobContainers(); + + // invoke the operation and iterate over the result + BlobContainerState? include = BlobContainerState.Deleted; + await foreach (BlobContainerResource item in collection.GetAllAsync(include: include)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BlobContainerData resourceData = result.Data; + BlobContainerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetContainers() + public async Task Exists_GetBlobContainersGetWithAllowProtectedAppendWritesAll() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGet.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGetWithAllowProtectedAppendWritesAll.json // this example is just showing the usage of "BlobContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -338,13 +300,9 @@ public async Task Get_GetContainers() // invoke the operation string containerName = "container1634"; - BlobContainerResource result = await collection.GetAsync(containerName); + bool result = await collection.ExistsAsync(containerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BlobContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -377,6 +335,48 @@ public async Task Exists_GetContainers() Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetBlobContainersGetWithAllowProtectedAppendWritesAll() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGetWithAllowProtectedAppendWritesAll.json + // this example is just showing the usage of "BlobContainers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BlobServiceResource created on azure + // for more information of creating BlobServiceResource, please refer to the document of BlobServiceResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "res9871"; + string accountName = "sto6217"; + ResourceIdentifier blobServiceResourceId = BlobServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId); + + // get the collection of this BlobContainerResource + BlobContainerCollection collection = blobService.GetBlobContainers(); + + // invoke the operation + string containerName = "container1634"; + NullableResponse response = await collection.GetIfExistsAsync(containerName); + BlobContainerResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BlobContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetIfExists_GetContainers() diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobContainerResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobContainerResource.cs index 546f6a0fb5f9b..ae74e33dc6695 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobContainerResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BlobContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateContainers() + public async Task Get_GetBlobContainersGetWithAllowProtectedAppendWritesAll() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPatch.json - // this example is just showing the usage of "BlobContainers_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGetWithAllowProtectedAppendWritesAll.json + // this example is just showing the usage of "BlobContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,22 +31,14 @@ public async Task Update_UpdateContainers() // this example assumes you already have this BlobContainerResource created on azure // for more information of creating BlobContainerResource, please refer to the document of BlobContainerResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res3376"; - string accountName = "sto328"; - string containerName = "container6185"; + string resourceGroupName = "res9871"; + string accountName = "sto6217"; + string containerName = "container1634"; ResourceIdentifier blobContainerResourceId = BlobContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, containerName); BlobContainerResource blobContainer = client.GetBlobContainerResource(blobContainerResourceId); // invoke the operation - BlobContainerData data = new BlobContainerData() - { - PublicAccess = StoragePublicAccessType.Container, - Metadata = -{ -["metadata"] = "true", -}, - }; - BlobContainerResource result = await blobContainer.UpdateAsync(data); + BlobContainerResource result = await blobContainer.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,9 +49,9 @@ public async Task Update_UpdateContainers() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetBlobContainersGetWithAllowProtectedAppendWritesAll() + public async Task Get_GetContainers() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGetWithAllowProtectedAppendWritesAll.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGet.json // this example is just showing the usage of "BlobContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -88,10 +80,10 @@ public async Task Get_GetBlobContainersGetWithAllowProtectedAppendWritesAll() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetContainers() + public async Task Delete_DeleteContainers() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGet.json - // this example is just showing the usage of "BlobContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersDelete.json + // this example is just showing the usage of "BlobContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,28 +93,24 @@ public async Task Get_GetContainers() // this example assumes you already have this BlobContainerResource created on azure // for more information of creating BlobContainerResource, please refer to the document of BlobContainerResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9871"; - string accountName = "sto6217"; - string containerName = "container1634"; + string resourceGroupName = "res4079"; + string accountName = "sto4506"; + string containerName = "container9689"; ResourceIdentifier blobContainerResourceId = BlobContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, containerName); BlobContainerResource blobContainer = client.GetBlobContainerResource(blobContainerResourceId); // invoke the operation - BlobContainerResource result = await blobContainer.GetAsync(); + await blobContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BlobContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteContainers() + public async Task Update_UpdateContainers() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersDelete.json - // this example is just showing the usage of "BlobContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPatch.json + // this example is just showing the usage of "BlobContainers_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,16 +120,28 @@ public async Task Delete_DeleteContainers() // this example assumes you already have this BlobContainerResource created on azure // for more information of creating BlobContainerResource, please refer to the document of BlobContainerResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res4079"; - string accountName = "sto4506"; - string containerName = "container9689"; + string resourceGroupName = "res3376"; + string accountName = "sto328"; + string containerName = "container6185"; ResourceIdentifier blobContainerResourceId = BlobContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, containerName); BlobContainerResource blobContainer = client.GetBlobContainerResource(blobContainerResourceId); // invoke the operation - await blobContainer.DeleteAsync(WaitUntil.Completed); + BlobContainerData data = new BlobContainerData + { + PublicAccess = StoragePublicAccessType.Container, + Metadata = +{ +["metadata"] = "true" +}, + }; + BlobContainerResource result = await blobContainer.UpdateAsync(data); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BlobContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -166,10 +166,7 @@ public async Task SetLegalHold_SetLegalHoldContainers() BlobContainerResource blobContainer = client.GetBlobContainerResource(blobContainerResourceId); // invoke the operation - LegalHold legalHold = new LegalHold(new string[] - { -"tag1","tag2","tag3" - }); + LegalHold legalHold = new LegalHold(new string[] { "tag1", "tag2", "tag3" }); LegalHold result = await blobContainer.SetLegalHoldAsync(legalHold); Console.WriteLine($"Succeeded: {result}"); @@ -197,10 +194,7 @@ public async Task SetLegalHold_SetLegalHoldContainersWithAllowProtectedAppendWri BlobContainerResource blobContainer = client.GetBlobContainerResource(blobContainerResourceId); // invoke the operation - LegalHold legalHold = new LegalHold(new string[] - { -"tag1","tag2","tag3" - }) + LegalHold legalHold = new LegalHold(new string[] { "tag1", "tag2", "tag3" }) { AllowProtectedAppendWritesAll = true, }; @@ -231,10 +225,7 @@ public async Task ClearLegalHold_ClearLegalHoldContainers() BlobContainerResource blobContainer = client.GetBlobContainerResource(blobContainerResourceId); // invoke the operation - LegalHold legalHold = new LegalHold(new string[] - { -"tag1","tag2","tag3" - }); + LegalHold legalHold = new LegalHold(new string[] { "tag1", "tag2", "tag3" }); LegalHold result = await blobContainer.ClearLegalHoldAsync(legalHold); Console.WriteLine($"Succeeded: {result}"); @@ -265,7 +256,7 @@ public async Task Lease_AcquireALeaseOnAContainer() LeaseContainerContent content = new LeaseContainerContent(LeaseContainerAction.Acquire) { LeaseId = null, - BreakPeriod = null, + BreakPeriod = default, LeaseDuration = -1, ProposedLeaseId = null, }; @@ -299,8 +290,8 @@ public async Task Lease_BreakALeaseOnAContainer() LeaseContainerContent content = new LeaseContainerContent(LeaseContainerAction.Break) { LeaseId = "8698f513-fa75-44a1-b8eb-30ba336af27d", - BreakPeriod = null, - LeaseDuration = null, + BreakPeriod = default, + LeaseDuration = default, ProposedLeaseId = null, }; LeaseContainerResponse result = await blobContainer.LeaseAsync(content: content); diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobInventoryPolicyResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobInventoryPolicyResource.cs index 5791f2b314bf6..c78acff1b735a 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobInventoryPolicyResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobInventoryPolicyResource.cs @@ -47,6 +47,33 @@ public async Task Get_StorageAccountGetBlobInventoryPolicy() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_StorageAccountDeleteBlobInventoryPolicy() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeleteBlobInventoryPolicy.json + // this example is just showing the usage of "BlobInventoryPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BlobInventoryPolicyResource created on azure + // for more information of creating BlobInventoryPolicyResource, please refer to the document of BlobInventoryPolicyResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "res6977"; + string accountName = "sto2527"; + BlobInventoryPolicyName blobInventoryPolicyName = BlobInventoryPolicyName.Default; + ResourceIdentifier blobInventoryPolicyResourceId = BlobInventoryPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, blobInventoryPolicyName); + BlobInventoryPolicyResource blobInventoryPolicy = client.GetBlobInventoryPolicyResource(blobInventoryPolicyResourceId); + + // invoke the operation + await blobInventoryPolicy.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_StorageAccountSetBlobInventoryPolicy() @@ -69,33 +96,22 @@ public async Task CreateOrUpdate_StorageAccountSetBlobInventoryPolicy() BlobInventoryPolicyResource blobInventoryPolicy = client.GetBlobInventoryPolicyResource(blobInventoryPolicyResourceId); // invoke the operation - BlobInventoryPolicyData data = new BlobInventoryPolicyData() + BlobInventoryPolicyData data = new BlobInventoryPolicyData { PolicySchema = new BlobInventoryPolicySchema(true, BlobInventoryRuleType.Inventory, new BlobInventoryPolicyRule[] { -new BlobInventoryPolicyRule(true,"inventoryPolicyRule1","container1",new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Csv,BlobInventoryPolicySchedule.Daily,BlobInventoryPolicyObjectType.Blob,new string[] -{ -"Name","Creation-Time","Last-Modified","Content-Length","Content-MD5","BlobType","AccessTier","AccessTierChangeTime","Snapshot","VersionId","IsCurrentVersion","Metadata" -}) -{ -Filters = new BlobInventoryPolicyFilter() +new BlobInventoryPolicyRule(true, "inventoryPolicyRule1", "container1", new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Csv, BlobInventoryPolicySchedule.Daily, BlobInventoryPolicyObjectType.Blob, new string[]{"Name", "Creation-Time", "Last-Modified", "Content-Length", "Content-MD5", "BlobType", "AccessTier", "AccessTierChangeTime", "Snapshot", "VersionId", "IsCurrentVersion", "Metadata"}) { -IncludePrefix = +Filters = new BlobInventoryPolicyFilter { -"inventoryprefix1","inventoryprefix2" -}, -BlobTypes = -{ -"blockBlob","appendBlob","pageBlob" -}, +IncludePrefix = {"inventoryprefix1", "inventoryprefix2"}, +BlobTypes = {"blockBlob", "appendBlob", "pageBlob"}, IncludeBlobVersions = true, IncludeSnapshots = true, CreationTimeLastNDays = 1000, }, -}),new BlobInventoryPolicyRule(true,"inventoryPolicyRule2","container2",new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Parquet,BlobInventoryPolicySchedule.Weekly,BlobInventoryPolicyObjectType.Container,new string[] -{ -"Name","Last-Modified","Metadata","LeaseStatus","LeaseState","LeaseDuration","PublicAccess","HasImmutabilityPolicy","HasLegalHold" -})) +}), +new BlobInventoryPolicyRule(true, "inventoryPolicyRule2", "container2", new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Parquet, BlobInventoryPolicySchedule.Weekly, BlobInventoryPolicyObjectType.Container, new string[]{"Name", "Last-Modified", "Metadata", "LeaseStatus", "LeaseState", "LeaseDuration", "PublicAccess", "HasImmutabilityPolicy", "HasLegalHold"})) }), }; ArmOperation lro = await blobInventoryPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); @@ -130,37 +146,23 @@ public async Task CreateOrUpdate_StorageAccountSetBlobInventoryPolicyIncludeDele BlobInventoryPolicyResource blobInventoryPolicy = client.GetBlobInventoryPolicyResource(blobInventoryPolicyResourceId); // invoke the operation - BlobInventoryPolicyData data = new BlobInventoryPolicyData() + BlobInventoryPolicyData data = new BlobInventoryPolicyData { PolicySchema = new BlobInventoryPolicySchema(true, BlobInventoryRuleType.Inventory, new BlobInventoryPolicyRule[] { -new BlobInventoryPolicyRule(true,"inventoryPolicyRule1","container1",new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Csv,BlobInventoryPolicySchedule.Daily,BlobInventoryPolicyObjectType.Blob,new string[] -{ -"Name","Creation-Time","Last-Modified","Content-Length","Content-MD5","BlobType","AccessTier","AccessTierChangeTime","Snapshot","VersionId","IsCurrentVersion","ContentType","ContentEncoding","ContentLanguage","ContentCRC64","CacheControl","Metadata","DeletionId","Deleted","DeletedTime","RemainingRetentionDays" -}) -{ -Filters = new BlobInventoryPolicyFilter() -{ -IncludePrefix = -{ -"inventoryprefix1","inventoryprefix2" -}, -ExcludePrefix = +new BlobInventoryPolicyRule(true, "inventoryPolicyRule1", "container1", new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Csv, BlobInventoryPolicySchedule.Daily, BlobInventoryPolicyObjectType.Blob, new string[]{"Name", "Creation-Time", "Last-Modified", "Content-Length", "Content-MD5", "BlobType", "AccessTier", "AccessTierChangeTime", "Snapshot", "VersionId", "IsCurrentVersion", "ContentType", "ContentEncoding", "ContentLanguage", "ContentCRC64", "CacheControl", "Metadata", "DeletionId", "Deleted", "DeletedTime", "RemainingRetentionDays"}) { -"excludeprefix1","excludeprefix2" -}, -BlobTypes = +Filters = new BlobInventoryPolicyFilter { -"blockBlob","appendBlob","pageBlob" -}, +IncludePrefix = {"inventoryprefix1", "inventoryprefix2"}, +ExcludePrefix = {"excludeprefix1", "excludeprefix2"}, +BlobTypes = {"blockBlob", "appendBlob", "pageBlob"}, IncludeBlobVersions = true, IncludeSnapshots = true, IncludeDeleted = true, }, -}),new BlobInventoryPolicyRule(true,"inventoryPolicyRule2","container2",new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Parquet,BlobInventoryPolicySchedule.Weekly,BlobInventoryPolicyObjectType.Container,new string[] -{ -"Name","Last-Modified","Metadata","LeaseStatus","LeaseState","LeaseDuration","PublicAccess","HasImmutabilityPolicy","HasLegalHold","Etag","DefaultEncryptionScope","DenyEncryptionScopeOverride","ImmutableStorageWithVersioningEnabled","Deleted","Version","DeletedTime","RemainingRetentionDays" -})) +}), +new BlobInventoryPolicyRule(true, "inventoryPolicyRule2", "container2", new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Parquet, BlobInventoryPolicySchedule.Weekly, BlobInventoryPolicyObjectType.Container, new string[]{"Name", "Last-Modified", "Metadata", "LeaseStatus", "LeaseState", "LeaseDuration", "PublicAccess", "HasImmutabilityPolicy", "HasLegalHold", "Etag", "DefaultEncryptionScope", "DenyEncryptionScopeOverride", "ImmutableStorageWithVersioningEnabled", "Deleted", "Version", "DeletedTime", "RemainingRetentionDays"})) }), }; ArmOperation lro = await blobInventoryPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); @@ -195,37 +197,23 @@ public async Task CreateOrUpdate_StorageAccountSetBlobInventoryPolicyIncludeDele BlobInventoryPolicyResource blobInventoryPolicy = client.GetBlobInventoryPolicyResource(blobInventoryPolicyResourceId); // invoke the operation - BlobInventoryPolicyData data = new BlobInventoryPolicyData() + BlobInventoryPolicyData data = new BlobInventoryPolicyData { PolicySchema = new BlobInventoryPolicySchema(true, BlobInventoryRuleType.Inventory, new BlobInventoryPolicyRule[] { -new BlobInventoryPolicyRule(true,"inventoryPolicyRule1","container1",new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Csv,BlobInventoryPolicySchedule.Daily,BlobInventoryPolicyObjectType.Blob,new string[] -{ -"Name","Creation-Time","Last-Modified","Content-Length","Content-MD5","BlobType","AccessTier","AccessTierChangeTime","Snapshot","VersionId","IsCurrentVersion","Tags","ContentType","ContentEncoding","ContentLanguage","ContentCRC64","CacheControl","Metadata","Deleted","RemainingRetentionDays" -}) -{ -Filters = new BlobInventoryPolicyFilter() +new BlobInventoryPolicyRule(true, "inventoryPolicyRule1", "container1", new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Csv, BlobInventoryPolicySchedule.Daily, BlobInventoryPolicyObjectType.Blob, new string[]{"Name", "Creation-Time", "Last-Modified", "Content-Length", "Content-MD5", "BlobType", "AccessTier", "AccessTierChangeTime", "Snapshot", "VersionId", "IsCurrentVersion", "Tags", "ContentType", "ContentEncoding", "ContentLanguage", "ContentCRC64", "CacheControl", "Metadata", "Deleted", "RemainingRetentionDays"}) { -IncludePrefix = +Filters = new BlobInventoryPolicyFilter { -"inventoryprefix1","inventoryprefix2" -}, -ExcludePrefix = -{ -"excludeprefix1","excludeprefix2" -}, -BlobTypes = -{ -"blockBlob","appendBlob","pageBlob" -}, +IncludePrefix = {"inventoryprefix1", "inventoryprefix2"}, +ExcludePrefix = {"excludeprefix1", "excludeprefix2"}, +BlobTypes = {"blockBlob", "appendBlob", "pageBlob"}, IncludeBlobVersions = true, IncludeSnapshots = true, IncludeDeleted = true, }, -}),new BlobInventoryPolicyRule(true,"inventoryPolicyRule2","container2",new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Parquet,BlobInventoryPolicySchedule.Weekly,BlobInventoryPolicyObjectType.Container,new string[] -{ -"Name","Last-Modified","Metadata","LeaseStatus","LeaseState","LeaseDuration","PublicAccess","HasImmutabilityPolicy","HasLegalHold","Etag","DefaultEncryptionScope","DenyEncryptionScopeOverride","ImmutableStorageWithVersioningEnabled","Deleted","Version","DeletedTime","RemainingRetentionDays" -})) +}), +new BlobInventoryPolicyRule(true, "inventoryPolicyRule2", "container2", new BlobInventoryPolicyDefinition(BlobInventoryPolicyFormat.Parquet, BlobInventoryPolicySchedule.Weekly, BlobInventoryPolicyObjectType.Container, new string[]{"Name", "Last-Modified", "Metadata", "LeaseStatus", "LeaseState", "LeaseDuration", "PublicAccess", "HasImmutabilityPolicy", "HasLegalHold", "Etag", "DefaultEncryptionScope", "DenyEncryptionScopeOverride", "ImmutableStorageWithVersioningEnabled", "Deleted", "Version", "DeletedTime", "RemainingRetentionDays"})) }), }; ArmOperation lro = await blobInventoryPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); @@ -237,32 +225,5 @@ public async Task CreateOrUpdate_StorageAccountSetBlobInventoryPolicyIncludeDele // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_StorageAccountDeleteBlobInventoryPolicy() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeleteBlobInventoryPolicy.json - // this example is just showing the usage of "BlobInventoryPolicies_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BlobInventoryPolicyResource created on azure - // for more information of creating BlobInventoryPolicyResource, please refer to the document of BlobInventoryPolicyResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string accountName = "sto2527"; - BlobInventoryPolicyName blobInventoryPolicyName = BlobInventoryPolicyName.Default; - ResourceIdentifier blobInventoryPolicyResourceId = BlobInventoryPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, blobInventoryPolicyName); - BlobInventoryPolicyResource blobInventoryPolicy = client.GetBlobInventoryPolicyResource(blobInventoryPolicyResourceId); - - // invoke the operation - await blobInventoryPolicy.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobServiceResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobServiceResource.cs index 42e80c0dc6bbd..a7589de2b362f 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobServiceResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_BlobServiceResource.cs @@ -16,6 +16,36 @@ namespace Azure.ResourceManager.Storage.Samples { public partial class Sample_BlobServiceResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetBlobServices() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobServicesGet.json + // this example is just showing the usage of "BlobServices_GetServiceProperties" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BlobServiceResource created on azure + // for more information of creating BlobServiceResource, please refer to the document of BlobServiceResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "res4410"; + string accountName = "sto8607"; + ResourceIdentifier blobServiceResourceId = BlobServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId); + + // invoke the operation + BlobServiceResource result = await blobService.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BlobServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_BlobServicesPutAllowPermanentDelete() @@ -37,9 +67,9 @@ public async Task CreateOrUpdate_BlobServicesPutAllowPermanentDelete() BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId); // invoke the operation - BlobServiceData data = new BlobServiceData() + BlobServiceData data = new BlobServiceData { - DeleteRetentionPolicy = new DeleteRetentionPolicy() + DeleteRetentionPolicy = new DeleteRetentionPolicy { IsEnabled = true, Days = 300, @@ -78,16 +108,13 @@ public async Task CreateOrUpdate_BlobServicesPutLastAccessTimeBasedTracking() BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId); // invoke the operation - BlobServiceData data = new BlobServiceData() + BlobServiceData data = new BlobServiceData { LastAccessTimeTrackingPolicy = new LastAccessTimeTrackingPolicy(true) { Name = LastAccessTimeTrackingPolicyName.AccessTimeTracking, TrackingGranularityInDays = 1, - BlobType = -{ -"blockBlob" -}, + BlobType = { "blockBlob" }, }, }; ArmOperation lro = await blobService.CreateOrUpdateAsync(WaitUntil.Completed, data); @@ -121,56 +148,17 @@ public async Task CreateOrUpdate_PutBlobServices() BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId); // invoke the operation - BlobServiceData data = new BlobServiceData() + BlobServiceData data = new BlobServiceData { - CorsRules = -{ -new StorageCorsRule(new string[] -{ -"http://www.contoso.com","http://www.fabrikam.com" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get,CorsRuleAllowedMethod.Head,CorsRuleAllowedMethod.Post,CorsRuleAllowedMethod.Options,CorsRuleAllowedMethod.Merge,CorsRuleAllowedMethod.Put -},100,new string[] -{ -"x-ms-meta-*" -},new string[] -{ -"x-ms-meta-abc","x-ms-meta-data*","x-ms-meta-target*" -}),new StorageCorsRule(new string[] -{ -"*" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get -},2,new string[] -{ -"*" -},new string[] -{ -"*" -}),new StorageCorsRule(new string[] -{ -"http://www.abc23.com","https://www.fabrikam.com/*" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get,CorsRuleAllowedMethod.Put -},2000,new string[] -{ -"x-ms-meta-abc","x-ms-meta-data*","x -ms-meta-target*" -},new string[] -{ -"x-ms-meta-12345675754564*" -}) -}, + CorsRules = { new StorageCorsRule(new string[] { "http://www.contoso.com", "http://www.fabrikam.com" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get, CorsRuleAllowedMethod.Head, CorsRuleAllowedMethod.Post, CorsRuleAllowedMethod.Options, CorsRuleAllowedMethod.Merge, CorsRuleAllowedMethod.Put }, 100, new string[] { "x-ms-meta-*" }, new string[] { "x-ms-meta-abc", "x-ms-meta-data*", "x-ms-meta-target*" }), new StorageCorsRule(new string[] { "*" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get }, 2, new string[] { "*" }, new string[] { "*" }), new StorageCorsRule(new string[] { "http://www.abc23.com", "https://www.fabrikam.com/*" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get, CorsRuleAllowedMethod.Put }, 2000, new string[] { "x-ms-meta-abc", "x-ms-meta-data*", "x -ms-meta-target*" }, new string[] { "x-ms-meta-12345675754564*" }) }, DefaultServiceVersion = "2017-07-29", - DeleteRetentionPolicy = new DeleteRetentionPolicy() + DeleteRetentionPolicy = new DeleteRetentionPolicy { IsEnabled = true, Days = 300, }, IsVersioningEnabled = true, - ChangeFeed = new BlobServiceChangeFeed() + ChangeFeed = new BlobServiceChangeFeed { IsEnabled = true, RetentionInDays = 7, @@ -185,35 +173,5 @@ public async Task CreateOrUpdate_PutBlobServices() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetBlobServices() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobServicesGet.json - // this example is just showing the usage of "BlobServices_GetServiceProperties" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BlobServiceResource created on azure - // for more information of creating BlobServiceResource, please refer to the document of BlobServiceResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res4410"; - string accountName = "sto8607"; - ResourceIdentifier blobServiceResourceId = BlobServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - BlobServiceResource blobService = client.GetBlobServiceResource(blobServiceResourceId); - - // invoke the operation - BlobServiceResource result = await blobService.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BlobServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_DeletedAccountResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_DeletedAccountResource.cs index 3e01d8230028b..c67cc98156b54 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_DeletedAccountResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_DeletedAccountResource.cs @@ -9,44 +9,12 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Storage.Samples { public partial class Sample_DeletedAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDeletedAccounts_DeletedAccountList() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/DeletedAccountList.json - // this example is just showing the usage of "DeletedAccounts_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DeletedAccountResource item in subscriptionResource.GetDeletedAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeletedAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_DeletedAccountGet() diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_EncryptionScopeCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_EncryptionScopeCollection.cs index 63df7e94711f7..087c86a5d309e 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_EncryptionScopeCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_EncryptionScopeCollection.cs @@ -76,7 +76,7 @@ public async Task CreateOrUpdate_StorageAccountPutEncryptionScopeWithInfrastruct // invoke the operation string encryptionScopeName = "{encryption-scope-name}"; - EncryptionScopeData data = new EncryptionScopeData() + EncryptionScopeData data = new EncryptionScopeData { RequireInfrastructureEncryption = true, }; @@ -126,10 +126,10 @@ public async Task Get_StorageAccountGetEncryptionScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGetEncryptionScope() + public async Task GetAll_StorageAccountEncryptionScopeList() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetEncryptionScope.json - // this example is just showing the usage of "EncryptionScopes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountEncryptionScopeList.json + // this example is just showing the usage of "EncryptionScopes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,16 +147,22 @@ public async Task Exists_StorageAccountGetEncryptionScope() // get the collection of this EncryptionScopeResource EncryptionScopeCollection collection = storageAccount.GetEncryptionScopes(); - // invoke the operation - string encryptionScopeName = "{encryption-scope-name}"; - bool result = await collection.ExistsAsync(encryptionScopeName); + // invoke the operation and iterate over the result + await foreach (EncryptionScopeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EncryptionScopeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGetEncryptionScope() + public async Task Exists_StorageAccountGetEncryptionScope() { // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetEncryptionScope.json // this example is just showing the usage of "EncryptionScopes_Get" operation, for the dependent resources, they will have to be created separately. @@ -179,29 +185,17 @@ public async Task GetIfExists_StorageAccountGetEncryptionScope() // invoke the operation string encryptionScopeName = "{encryption-scope-name}"; - NullableResponse response = await collection.GetIfExistsAsync(encryptionScopeName); - EncryptionScopeResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(encryptionScopeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EncryptionScopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StorageAccountEncryptionScopeList() + public async Task GetIfExists_StorageAccountGetEncryptionScope() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountEncryptionScopeList.json - // this example is just showing the usage of "EncryptionScopes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -219,17 +213,23 @@ public async Task GetAll_StorageAccountEncryptionScopeList() // get the collection of this EncryptionScopeResource EncryptionScopeCollection collection = storageAccount.GetEncryptionScopes(); - // invoke the operation and iterate over the result - await foreach (EncryptionScopeResource item in collection.GetAllAsync()) + // invoke the operation + string encryptionScopeName = "{encryption-scope-name}"; + NullableResponse response = await collection.GetIfExistsAsync(encryptionScopeName); + EncryptionScopeResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - EncryptionScopeData resourceData = item.Data; + EncryptionScopeData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_EncryptionScopeResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_EncryptionScopeResource.cs index b7c9ba89cc0f1..cb170cd91ae22 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_EncryptionScopeResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_EncryptionScopeResource.cs @@ -18,10 +18,10 @@ public partial class Sample_EncryptionScopeResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_StorageAccountPatchEncryptionScope() + public async Task Get_StorageAccountGetEncryptionScope() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountPatchEncryptionScope.json - // this example is just showing the usage of "EncryptionScopes_Patch" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_StorageAccountPatchEncryptionScope() EncryptionScopeResource encryptionScope = client.GetEncryptionScopeResource(encryptionScopeResourceId); // invoke the operation - EncryptionScopeData data = new EncryptionScopeData() - { - Source = EncryptionScopeSource.KeyVault, - KeyVaultProperties = new EncryptionScopeKeyVaultProperties() - { - KeyUri = new Uri("https://testvault.vault.core.windows.net/keys/key1/863425f1358359c"), - }, - }; - EncryptionScopeResource result = await encryptionScope.UpdateAsync(data); + EncryptionScopeResource result = await encryptionScope.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +49,10 @@ public async Task Update_StorageAccountPatchEncryptionScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageAccountGetEncryptionScope() + public async Task Update_StorageAccountPatchEncryptionScope() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetEncryptionScope.json - // this example is just showing the usage of "EncryptionScopes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountPatchEncryptionScope.json + // this example is just showing the usage of "EncryptionScopes_Patch" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +69,15 @@ public async Task Get_StorageAccountGetEncryptionScope() EncryptionScopeResource encryptionScope = client.GetEncryptionScopeResource(encryptionScopeResourceId); // invoke the operation - EncryptionScopeResource result = await encryptionScope.GetAsync(); + EncryptionScopeData data = new EncryptionScopeData + { + Source = EncryptionScopeSource.KeyVault, + KeyVaultProperties = new EncryptionScopeKeyVaultProperties + { + KeyUri = new Uri("https://testvault.vault.core.windows.net/keys/key1/863425f1358359c"), + }, + }; + EncryptionScopeResource result = await encryptionScope.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileServiceResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileServiceResource.cs index e2b9b610ac956..ea5ce7b38a6e0 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileServiceResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileServiceResource.cs @@ -18,10 +18,10 @@ public partial class Sample_FileServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutFileServices() + public async Task Get_GetFileServices() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesPut.json - // this example is just showing the usage of "FileServices_SetServiceProperties" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesGet.json + // this example is just showing the usage of "FileServices_GetServiceProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,51 +37,7 @@ public async Task CreateOrUpdate_PutFileServices() FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); // invoke the operation - FileServiceData data = new FileServiceData() - { - CorsRules = -{ -new StorageCorsRule(new string[] -{ -"http://www.contoso.com","http://www.fabrikam.com" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get,CorsRuleAllowedMethod.Head,CorsRuleAllowedMethod.Post,CorsRuleAllowedMethod.Options,CorsRuleAllowedMethod.Merge,CorsRuleAllowedMethod.Put -},100,new string[] -{ -"x-ms-meta-*" -},new string[] -{ -"x-ms-meta-abc","x-ms-meta-data*","x-ms-meta-target*" -}),new StorageCorsRule(new string[] -{ -"*" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get -},2,new string[] -{ -"*" -},new string[] -{ -"*" -}),new StorageCorsRule(new string[] -{ -"http://www.abc23.com","https://www.fabrikam.com/*" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get,CorsRuleAllowedMethod.Put -},2000,new string[] -{ -"x-ms-meta-abc","x-ms-meta-data*","x-ms-meta-target*" -},new string[] -{ -"x-ms-meta-12345675754564*" -}) -}, - }; - ArmOperation lro = await fileService.CreateOrUpdateAsync(WaitUntil.Completed, data); - FileServiceResource result = lro.Value; + FileServiceResource result = await fileService.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,9 +48,9 @@ public async Task CreateOrUpdate_PutFileServices() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutFileServicesEnableSMBMultichannel() + public async Task CreateOrUpdate_PutFileServices() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesPut_EnableSMBMultichannel.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesPut.json // this example is just showing the usage of "FileServices_SetServiceProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -111,12 +67,9 @@ public async Task CreateOrUpdate_PutFileServicesEnableSMBMultichannel() FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); // invoke the operation - FileServiceData data = new FileServiceData() + FileServiceData data = new FileServiceData { - ProtocolSmbSetting = new SmbSetting() - { - IsMultiChannelEnabled = true, - }, + CorsRules = { new StorageCorsRule(new string[] { "http://www.contoso.com", "http://www.fabrikam.com" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get, CorsRuleAllowedMethod.Head, CorsRuleAllowedMethod.Post, CorsRuleAllowedMethod.Options, CorsRuleAllowedMethod.Merge, CorsRuleAllowedMethod.Put }, 100, new string[] { "x-ms-meta-*" }, new string[] { "x-ms-meta-abc", "x-ms-meta-data*", "x-ms-meta-target*" }), new StorageCorsRule(new string[] { "*" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get }, 2, new string[] { "*" }, new string[] { "*" }), new StorageCorsRule(new string[] { "http://www.abc23.com", "https://www.fabrikam.com/*" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get, CorsRuleAllowedMethod.Put }, 2000, new string[] { "x-ms-meta-abc", "x-ms-meta-data*", "x-ms-meta-target*" }, new string[] { "x-ms-meta-12345675754564*" }) }, }; ArmOperation lro = await fileService.CreateOrUpdateAsync(WaitUntil.Completed, data); FileServiceResource result = lro.Value; @@ -130,9 +83,9 @@ public async Task CreateOrUpdate_PutFileServicesEnableSMBMultichannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutFileServicesEnableSecureSmbFeatures() + public async Task CreateOrUpdate_PutFileServicesEnableSMBMultichannel() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesPut_EnableSecureSmbFeatures.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesPut_EnableSMBMultichannel.json // this example is just showing the usage of "FileServices_SetServiceProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -149,14 +102,11 @@ public async Task CreateOrUpdate_PutFileServicesEnableSecureSmbFeatures() FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); // invoke the operation - FileServiceData data = new FileServiceData() + FileServiceData data = new FileServiceData { - ProtocolSmbSetting = new SmbSetting() + ProtocolSmbSetting = new SmbSetting { - Versions = "SMB2.1;SMB3.0;SMB3.1.1", - AuthenticationMethods = "NTLMv2;Kerberos", - KerberosTicketEncryption = "RC4-HMAC;AES-256", - ChannelEncryption = "AES-128-CCM;AES-128-GCM;AES-256-GCM", + IsMultiChannelEnabled = true, }, }; ArmOperation lro = await fileService.CreateOrUpdateAsync(WaitUntil.Completed, data); @@ -171,10 +121,10 @@ public async Task CreateOrUpdate_PutFileServicesEnableSecureSmbFeatures() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFileServices() + public async Task CreateOrUpdate_PutFileServicesEnableSecureSmbFeatures() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesGet.json - // this example is just showing the usage of "FileServices_GetServiceProperties" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileServicesPut_EnableSecureSmbFeatures.json + // this example is just showing the usage of "FileServices_SetServiceProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,7 +140,18 @@ public async Task Get_GetFileServices() FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); // invoke the operation - FileServiceResource result = await fileService.GetAsync(); + FileServiceData data = new FileServiceData + { + ProtocolSmbSetting = new SmbSetting + { + Versions = "SMB2.1;SMB3.0;SMB3.1.1", + AuthenticationMethods = "NTLMv2;Kerberos", + KerberosTicketEncryption = "RC4-HMAC;AES-256", + ChannelEncryption = "AES-128-CCM;AES-128-GCM;AES-256-GCM", + }, + }; + ArmOperation lro = await fileService.CreateOrUpdateAsync(WaitUntil.Completed, data); + FileServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileShareCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileShareCollection.cs index cc8e0a51ccbdc..9095648df0301 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileShareCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileShareCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FileShareCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDeletedShares() + public async Task CreateOrUpdate_CreateNFSShares() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/DeletedFileSharesList.json - // this example is just showing the usage of "FileShares_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPut_NFS.json + // this example is just showing the usage of "FileShares_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,34 +31,36 @@ public async Task GetAll_ListDeletedShares() // this example assumes you already have this FileServiceResource created on azure // for more information of creating FileServiceResource, please refer to the document of FileServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9290"; - string accountName = "sto1590"; + string resourceGroupName = "res346"; + string accountName = "sto666"; ResourceIdentifier fileServiceResourceId = FileServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); // get the collection of this FileShareResource FileShareCollection collection = fileService.GetFileShares(); - // invoke the operation and iterate over the result - string expand = "deleted"; - await foreach (FileShareResource item in collection.GetAllAsync(expand: expand)) + // invoke the operation + string shareName = "share1235"; + FileShareData data = new FileShareData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileShareData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EnabledProtocol = FileShareEnabledProtocol.Nfs, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, shareName, data); + FileShareResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileShareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListShareSnapshots() + public async Task CreateOrUpdate_PutShares() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileShareSnapshotsList.json - // this example is just showing the usage of "FileShares_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPut.json + // this example is just showing the usage of "FileShares_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,34 +70,33 @@ public async Task GetAll_ListShareSnapshots() // this example assumes you already have this FileServiceResource created on azure // for more information of creating FileServiceResource, please refer to the document of FileServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9290"; - string accountName = "sto1590"; + string resourceGroupName = "res3376"; + string accountName = "sto328"; ResourceIdentifier fileServiceResourceId = FileServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); // get the collection of this FileShareResource FileShareCollection collection = fileService.GetFileShares(); - // invoke the operation and iterate over the result - string expand = "snapshots"; - await foreach (FileShareResource item in collection.GetAllAsync(expand: expand)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileShareData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string shareName = "share6185"; + FileShareData data = new FileShareData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, shareName, data); + FileShareResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileShareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListShares() + public async Task CreateOrUpdate_PutSharesWithAccessTier() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesList.json - // this example is just showing the usage of "FileShares_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPut_AccessTier.json + // this example is just showing the usage of "FileShares_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,33 +106,36 @@ public async Task GetAll_ListShares() // this example assumes you already have this FileServiceResource created on azure // for more information of creating FileServiceResource, please refer to the document of FileServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9290"; - string accountName = "sto1590"; + string resourceGroupName = "res346"; + string accountName = "sto666"; ResourceIdentifier fileServiceResourceId = FileServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); // get the collection of this FileShareResource FileShareCollection collection = fileService.GetFileShares(); - // invoke the operation and iterate over the result - await foreach (FileShareResource item in collection.GetAllAsync()) + // invoke the operation + string shareName = "share1235"; + FileShareData data = new FileShareData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileShareData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AccessTier = FileShareAccessTier.Hot, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, shareName, data); + FileShareResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileShareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNFSShares() + public async Task Get_GetShareStats() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPut_NFS.json - // this example is just showing the usage of "FileShares_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet_Stats.json + // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,8 +145,8 @@ public async Task CreateOrUpdate_CreateNFSShares() // this example assumes you already have this FileServiceResource created on azure // for more information of creating FileServiceResource, please refer to the document of FileServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res346"; - string accountName = "sto666"; + string resourceGroupName = "res9871"; + string accountName = "sto6217"; ResourceIdentifier fileServiceResourceId = FileServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); @@ -150,13 +154,9 @@ public async Task CreateOrUpdate_CreateNFSShares() FileShareCollection collection = fileService.GetFileShares(); // invoke the operation - string shareName = "share1235"; - FileShareData data = new FileShareData() - { - EnabledProtocol = FileShareEnabledProtocol.Nfs, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, shareName, data); - FileShareResource result = lro.Value; + string shareName = "share1634"; + string expand = "stats"; + FileShareResource result = await collection.GetAsync(shareName, expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -167,10 +167,10 @@ public async Task CreateOrUpdate_CreateNFSShares() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutShares() + public async Task Get_GetShares() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPut.json - // this example is just showing the usage of "FileShares_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet.json + // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,8 +180,8 @@ public async Task CreateOrUpdate_PutShares() // this example assumes you already have this FileServiceResource created on azure // for more information of creating FileServiceResource, please refer to the document of FileServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res3376"; - string accountName = "sto328"; + string resourceGroupName = "res9871"; + string accountName = "sto6217"; ResourceIdentifier fileServiceResourceId = FileServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); @@ -189,10 +189,8 @@ public async Task CreateOrUpdate_PutShares() FileShareCollection collection = fileService.GetFileShares(); // invoke the operation - string shareName = "share6185"; - FileShareData data = new FileShareData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, shareName, data); - FileShareResource result = lro.Value; + string shareName = "share1634"; + FileShareResource result = await collection.GetAsync(shareName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -203,10 +201,10 @@ public async Task CreateOrUpdate_PutShares() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutSharesWithAccessTier() + public async Task GetAll_ListDeletedShares() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPut_AccessTier.json - // this example is just showing the usage of "FileShares_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/DeletedFileSharesList.json + // this example is just showing the usage of "FileShares_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -216,36 +214,34 @@ public async Task CreateOrUpdate_PutSharesWithAccessTier() // this example assumes you already have this FileServiceResource created on azure // for more information of creating FileServiceResource, please refer to the document of FileServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res346"; - string accountName = "sto666"; + string resourceGroupName = "res9290"; + string accountName = "sto1590"; ResourceIdentifier fileServiceResourceId = FileServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); // get the collection of this FileShareResource FileShareCollection collection = fileService.GetFileShares(); - // invoke the operation - string shareName = "share1235"; - FileShareData data = new FileShareData() + // invoke the operation and iterate over the result + string expand = "deleted"; + await foreach (FileShareResource item in collection.GetAllAsync(expand: expand)) { - AccessTier = FileShareAccessTier.Hot, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, shareName, data); - FileShareResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileShareData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileShareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetShareStats() + public async Task GetAll_ListShareSnapshots() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet_Stats.json - // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileShareSnapshotsList.json + // this example is just showing the usage of "FileShares_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -255,32 +251,34 @@ public async Task Get_GetShareStats() // this example assumes you already have this FileServiceResource created on azure // for more information of creating FileServiceResource, please refer to the document of FileServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9871"; - string accountName = "sto6217"; + string resourceGroupName = "res9290"; + string accountName = "sto1590"; ResourceIdentifier fileServiceResourceId = FileServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); // get the collection of this FileShareResource FileShareCollection collection = fileService.GetFileShares(); - // invoke the operation - string shareName = "share1634"; - string expand = "stats"; - FileShareResource result = await collection.GetAsync(shareName, expand: expand); + // invoke the operation and iterate over the result + string expand = "snapshots"; + await foreach (FileShareResource item in collection.GetAllAsync(expand: expand)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileShareData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileShareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetShareStats() + public async Task GetAll_ListShares() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet_Stats.json - // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesList.json + // this example is just showing the usage of "FileShares_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -290,25 +288,30 @@ public async Task Exists_GetShareStats() // this example assumes you already have this FileServiceResource created on azure // for more information of creating FileServiceResource, please refer to the document of FileServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9871"; - string accountName = "sto6217"; + string resourceGroupName = "res9290"; + string accountName = "sto1590"; ResourceIdentifier fileServiceResourceId = FileServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); FileServiceResource fileService = client.GetFileServiceResource(fileServiceResourceId); // get the collection of this FileShareResource FileShareCollection collection = fileService.GetFileShares(); - // invoke the operation - string shareName = "share1634"; - string expand = "stats"; - bool result = await collection.ExistsAsync(shareName, expand: expand); + // invoke the operation and iterate over the result + await foreach (FileShareResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileShareData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetShareStats() + public async Task Exists_GetShareStats() { // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet_Stats.json // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. @@ -332,26 +335,14 @@ public async Task GetIfExists_GetShareStats() // invoke the operation string shareName = "share1634"; string expand = "stats"; - NullableResponse response = await collection.GetIfExistsAsync(shareName, expand: expand); - FileShareResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(shareName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileShareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetShares() + public async Task Exists_GetShares() { // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet.json // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. @@ -374,20 +365,16 @@ public async Task Get_GetShares() // invoke the operation string shareName = "share1634"; - FileShareResource result = await collection.GetAsync(shareName); + bool result = await collection.ExistsAsync(shareName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileShareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetShares() + public async Task GetIfExists_GetShareStats() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet_Stats.json // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -408,9 +395,22 @@ public async Task Exists_GetShares() // invoke the operation string shareName = "share1634"; - bool result = await collection.ExistsAsync(shareName); + string expand = "stats"; + NullableResponse response = await collection.GetIfExistsAsync(shareName, expand: expand); + FileShareResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileShareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileShareResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileShareResource.cs index f59aaaf3a7924..3bdec6ad49125 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileShareResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_FileShareResource.cs @@ -18,10 +18,10 @@ public partial class Sample_FileShareResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateShareAcls() + public async Task Get_GetShareStats() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileShareAclsPatch.json - // this example is just showing the usage of "FileShares_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet_Stats.json + // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,30 +31,15 @@ public async Task Update_UpdateShareAcls() // this example assumes you already have this FileShareResource created on azure // for more information of creating FileShareResource, please refer to the document of FileShareResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res3376"; - string accountName = "sto328"; - string shareName = "share6185"; + string resourceGroupName = "res9871"; + string accountName = "sto6217"; + string shareName = "share1634"; ResourceIdentifier fileShareResourceId = FileShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); FileShareResource fileShare = client.GetFileShareResource(fileShareResourceId); // invoke the operation - FileShareData data = new FileShareData() - { - SignedIdentifiers = -{ -new StorageSignedIdentifier() -{ -Id = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI", -AccessPolicy = new StorageServiceAccessPolicy() -{ -StartOn = DateTimeOffset.Parse("2021-04-01T08:49:37.0000000Z"), -ExpireOn = DateTimeOffset.Parse("2021-05-01T08:49:37.0000000Z"), -Permission = "rwd", -}, -} -}, - }; - FileShareResource result = await fileShare.UpdateAsync(data); + string expand = "stats"; + FileShareResource result = await fileShare.GetAsync(expand: expand); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -65,10 +50,10 @@ public async Task Update_UpdateShareAcls() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateShares() + public async Task Get_GetShares() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPatch.json - // this example is just showing the usage of "FileShares_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet.json + // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,21 +63,14 @@ public async Task Update_UpdateShares() // this example assumes you already have this FileShareResource created on azure // for more information of creating FileShareResource, please refer to the document of FileShareResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res3376"; - string accountName = "sto328"; - string shareName = "share6185"; + string resourceGroupName = "res9871"; + string accountName = "sto6217"; + string shareName = "share1634"; ResourceIdentifier fileShareResourceId = FileShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); FileShareResource fileShare = client.GetFileShareResource(fileShareResourceId); // invoke the operation - FileShareData data = new FileShareData() - { - Metadata = -{ -["type"] = "image", -}, - }; - FileShareResource result = await fileShare.UpdateAsync(data); + FileShareResource result = await fileShare.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -103,10 +81,10 @@ public async Task Update_UpdateShares() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetShareStats() + public async Task Delete_DeleteShares() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet_Stats.json - // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesDelete.json + // this example is just showing the usage of "FileShares_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,29 +94,24 @@ public async Task Get_GetShareStats() // this example assumes you already have this FileShareResource created on azure // for more information of creating FileShareResource, please refer to the document of FileShareResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9871"; - string accountName = "sto6217"; - string shareName = "share1634"; + string resourceGroupName = "res4079"; + string accountName = "sto4506"; + string shareName = "share9689"; ResourceIdentifier fileShareResourceId = FileShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); FileShareResource fileShare = client.GetFileShareResource(fileShareResourceId); // invoke the operation - string expand = "stats"; - FileShareResource result = await fileShare.GetAsync(expand: expand); + await fileShare.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FileShareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetShares() + public async Task Update_UpdateShareAcls() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesGet.json - // this example is just showing the usage of "FileShares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileShareAclsPatch.json + // this example is just showing the usage of "FileShares_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,14 +121,27 @@ public async Task Get_GetShares() // this example assumes you already have this FileShareResource created on azure // for more information of creating FileShareResource, please refer to the document of FileShareResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9871"; - string accountName = "sto6217"; - string shareName = "share1634"; + string resourceGroupName = "res3376"; + string accountName = "sto328"; + string shareName = "share6185"; ResourceIdentifier fileShareResourceId = FileShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); FileShareResource fileShare = client.GetFileShareResource(fileShareResourceId); // invoke the operation - FileShareResource result = await fileShare.GetAsync(); + FileShareData data = new FileShareData + { + SignedIdentifiers = {new StorageSignedIdentifier +{ +Id = "MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI", +AccessPolicy = new StorageServiceAccessPolicy +{ +StartOn = DateTimeOffset.Parse("2021-04-01T08:49:37.0000000Z"), +ExpireOn = DateTimeOffset.Parse("2021-05-01T08:49:37.0000000Z"), +Permission = "rwd", +}, +}}, + }; + FileShareResource result = await fileShare.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -166,10 +152,10 @@ public async Task Get_GetShares() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteShares() + public async Task Update_UpdateShares() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesDelete.json - // this example is just showing the usage of "FileShares_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/FileSharesPatch.json + // this example is just showing the usage of "FileShares_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,16 +165,27 @@ public async Task Delete_DeleteShares() // this example assumes you already have this FileShareResource created on azure // for more information of creating FileShareResource, please refer to the document of FileShareResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res4079"; - string accountName = "sto4506"; - string shareName = "share9689"; + string resourceGroupName = "res3376"; + string accountName = "sto328"; + string shareName = "share6185"; ResourceIdentifier fileShareResourceId = FileShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); FileShareResource fileShare = client.GetFileShareResource(fileShareResourceId); // invoke the operation - await fileShare.DeleteAsync(WaitUntil.Completed); + FileShareData data = new FileShareData + { + Metadata = +{ +["type"] = "image" +}, + }; + FileShareResource result = await fileShare.UpdateAsync(data); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FileShareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -244,7 +241,7 @@ public async Task Lease_AcquireALeaseOnAShare() LeaseShareContent content = new LeaseShareContent(LeaseShareAction.Acquire) { LeaseId = null, - BreakPeriod = null, + BreakPeriod = default, LeaseDuration = -1, ProposedLeaseId = null, }; @@ -278,8 +275,8 @@ public async Task Lease_BreakALeaseOnAShare() LeaseShareContent content = new LeaseShareContent(LeaseShareAction.Break) { LeaseId = "8698f513-fa75-44a1-b8eb-30ba336af27d", - BreakPeriod = null, - LeaseDuration = null, + BreakPeriod = default, + LeaseDuration = default, ProposedLeaseId = null, }; LeaseShareResponse result = await fileShare.LeaseAsync(content: content); diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ImmutabilityPolicyResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ImmutabilityPolicyResource.cs index 3e53d26104df7..78bcb3251c630 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ImmutabilityPolicyResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ImmutabilityPolicyResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ImmutabilityPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateImmutabilityPolicy() + public async Task Get_GetImmutabilityPolicy() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutImmutabilityPolicy.json - // this example is just showing the usage of "BlobContainers_CreateOrUpdateImmutabilityPolicy" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGetImmutabilityPolicy.json + // this example is just showing the usage of "BlobContainers_GetImmutabilityPolicy" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,20 +30,14 @@ public async Task CreateOrUpdate_CreateOrUpdateImmutabilityPolicy() // this example assumes you already have this ImmutabilityPolicyResource created on azure // for more information of creating ImmutabilityPolicyResource, please refer to the document of ImmutabilityPolicyResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res1782"; - string accountName = "sto7069"; - string containerName = "container6397"; + string resourceGroupName = "res5221"; + string accountName = "sto9177"; + string containerName = "container3489"; ResourceIdentifier immutabilityPolicyResourceId = ImmutabilityPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, containerName); ImmutabilityPolicyResource immutabilityPolicy = client.GetImmutabilityPolicyResource(immutabilityPolicyResourceId); // invoke the operation - ImmutabilityPolicyData data = new ImmutabilityPolicyData() - { - ImmutabilityPeriodSinceCreationInDays = 3, - AllowProtectedAppendWrites = true, - }; - ArmOperation lro = await immutabilityPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); - ImmutabilityPolicyResource result = lro.Value; + ImmutabilityPolicyResource result = await immutabilityPolicy.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +48,10 @@ public async Task CreateOrUpdate_CreateOrUpdateImmutabilityPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateImmutabilityPolicyWithAllowProtectedAppendWritesAll() + public async Task Delete_DeleteImmutabilityPolicy() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutImmutabilityPolicyAllowProtectedAppendWritesAll.json - // this example is just showing the usage of "BlobContainers_CreateOrUpdateImmutabilityPolicy" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersDeleteImmutabilityPolicy.json + // this example is just showing the usage of "BlobContainers_DeleteImmutabilityPolicy" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,19 +61,15 @@ public async Task CreateOrUpdate_CreateOrUpdateImmutabilityPolicyWithAllowProtec // this example assumes you already have this ImmutabilityPolicyResource created on azure // for more information of creating ImmutabilityPolicyResource, please refer to the document of ImmutabilityPolicyResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res1782"; - string accountName = "sto7069"; - string containerName = "container6397"; + string resourceGroupName = "res1581"; + string accountName = "sto9621"; + string containerName = "container4910"; ResourceIdentifier immutabilityPolicyResourceId = ImmutabilityPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, containerName); ImmutabilityPolicyResource immutabilityPolicy = client.GetImmutabilityPolicyResource(immutabilityPolicyResourceId); // invoke the operation - ImmutabilityPolicyData data = new ImmutabilityPolicyData() - { - ImmutabilityPeriodSinceCreationInDays = 3, - AllowProtectedAppendWritesAll = true, - }; - ArmOperation lro = await immutabilityPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); + ETag ifMatch = new ETag("8d59f81a7fa7be0"); + ArmOperation lro = await immutabilityPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); ImmutabilityPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -91,10 +81,10 @@ public async Task CreateOrUpdate_CreateOrUpdateImmutabilityPolicyWithAllowProtec [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetImmutabilityPolicy() + public async Task CreateOrUpdate_CreateOrUpdateImmutabilityPolicy() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersGetImmutabilityPolicy.json - // this example is just showing the usage of "BlobContainers_GetImmutabilityPolicy" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutImmutabilityPolicy.json + // this example is just showing the usage of "BlobContainers_CreateOrUpdateImmutabilityPolicy" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,14 +94,20 @@ public async Task Get_GetImmutabilityPolicy() // this example assumes you already have this ImmutabilityPolicyResource created on azure // for more information of creating ImmutabilityPolicyResource, please refer to the document of ImmutabilityPolicyResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res5221"; - string accountName = "sto9177"; - string containerName = "container3489"; + string resourceGroupName = "res1782"; + string accountName = "sto7069"; + string containerName = "container6397"; ResourceIdentifier immutabilityPolicyResourceId = ImmutabilityPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, containerName); ImmutabilityPolicyResource immutabilityPolicy = client.GetImmutabilityPolicyResource(immutabilityPolicyResourceId); // invoke the operation - ImmutabilityPolicyResource result = await immutabilityPolicy.GetAsync(); + ImmutabilityPolicyData data = new ImmutabilityPolicyData + { + ImmutabilityPeriodSinceCreationInDays = 3, + AllowProtectedAppendWrites = true, + }; + ArmOperation lro = await immutabilityPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); + ImmutabilityPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -122,10 +118,10 @@ public async Task Get_GetImmutabilityPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteImmutabilityPolicy() + public async Task CreateOrUpdate_CreateOrUpdateImmutabilityPolicyWithAllowProtectedAppendWritesAll() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersDeleteImmutabilityPolicy.json - // this example is just showing the usage of "BlobContainers_DeleteImmutabilityPolicy" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/BlobContainersPutImmutabilityPolicyAllowProtectedAppendWritesAll.json + // this example is just showing the usage of "BlobContainers_CreateOrUpdateImmutabilityPolicy" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,15 +131,19 @@ public async Task Delete_DeleteImmutabilityPolicy() // this example assumes you already have this ImmutabilityPolicyResource created on azure // for more information of creating ImmutabilityPolicyResource, please refer to the document of ImmutabilityPolicyResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res1581"; - string accountName = "sto9621"; - string containerName = "container4910"; + string resourceGroupName = "res1782"; + string accountName = "sto7069"; + string containerName = "container6397"; ResourceIdentifier immutabilityPolicyResourceId = ImmutabilityPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, containerName); ImmutabilityPolicyResource immutabilityPolicy = client.GetImmutabilityPolicyResource(immutabilityPolicyResourceId); // invoke the operation - ETag ifMatch = new ETag("8d59f81a7fa7be0"); - ArmOperation lro = await immutabilityPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); + ImmutabilityPolicyData data = new ImmutabilityPolicyData + { + ImmutabilityPeriodSinceCreationInDays = 3, + AllowProtectedAppendWritesAll = true, + }; + ArmOperation lro = await immutabilityPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); ImmutabilityPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -208,7 +208,7 @@ public async Task ExtendImmutabilityPolicy_ExtendImmutabilityPolicy() // invoke the operation ETag ifMatch = new ETag("8d59f830d0c3bf9"); - ImmutabilityPolicyData data = new ImmutabilityPolicyData() + ImmutabilityPolicyData data = new ImmutabilityPolicyData { ImmutabilityPeriodSinceCreationInDays = 100, }; diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs index e1c38df8fb403..1decd2aede78a 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkSecurityPerimeterConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkSecurityPerimeterConfigurationList() + public async Task Get_NetworkSecurityPerimeterConfigurationGet() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/NetworkSecurityPerimeterConfigurationList.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/NetworkSecurityPerimeterConfigurationGet.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_NetworkSecurityPerimeterConfigurationList() // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = storageAccount.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string networkSecurityPerimeterConfigurationName = "dbedb4e0-40e6-4145-81f3-f1314c150774.resourceAssociation1"; + NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(networkSecurityPerimeterConfigurationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NetworkSecurityPerimeterConfigurationGet() + public async Task GetAll_NetworkSecurityPerimeterConfigurationList() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/NetworkSecurityPerimeterConfigurationGet.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/NetworkSecurityPerimeterConfigurationList.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_NetworkSecurityPerimeterConfigurationGet() // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = storageAccount.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation - string networkSecurityPerimeterConfigurationName = "dbedb4e0-40e6-4145-81f3-f1314c150774.resourceAssociation1"; - NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(networkSecurityPerimeterConfigurationName); + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ObjectReplicationPolicyCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ObjectReplicationPolicyCollection.cs index edf4a8d2b996c..a77d9fb60e712 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ObjectReplicationPolicyCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ObjectReplicationPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ObjectReplicationPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StorageAccountListObjectReplicationPolicies() + public async Task CreateOrUpdate_StorageAccountCreateObjectReplicationPolicyOnDestination() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListObjectReplicationPolicies.json - // this example is just showing the usage of "ObjectReplicationPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateObjectReplicationPolicyOnDestination.json + // this example is just showing the usage of "ObjectReplicationPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,33 +31,44 @@ public async Task GetAll_StorageAccountListObjectReplicationPolicies() // this example assumes you already have this StorageAccountResource created on azure // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string accountName = "sto2527"; + string resourceGroupName = "res7687"; + string accountName = "dst112"; ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // get the collection of this ObjectReplicationPolicyResource ObjectReplicationPolicyCollection collection = storageAccount.GetObjectReplicationPolicies(); - // invoke the operation and iterate over the result - await foreach (ObjectReplicationPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string objectReplicationPolicyId = "default"; + ObjectReplicationPolicyData data = new ObjectReplicationPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ObjectReplicationPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SourceAccount = "src1122", + DestinationAccount = "dst112", + Rules = {new ObjectReplicationPolicyRule("scont139", "dcont139") +{ +Filters = new ObjectReplicationPolicyFilter +{ +PrefixMatch = {"blobA", "blobB"}, +}, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectReplicationPolicyId, data); + ObjectReplicationPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ObjectReplicationPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageAccountGetObjectReplicationPolicies() + public async Task CreateOrUpdate_StorageAccountCreateObjectReplicationPolicyOnSource() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetObjectReplicationPolicy.json - // this example is just showing the usage of "ObjectReplicationPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateObjectReplicationPolicyOnSource.json + // this example is just showing the usage of "ObjectReplicationPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,8 +78,8 @@ public async Task Get_StorageAccountGetObjectReplicationPolicies() // this example assumes you already have this StorageAccountResource created on azure // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string accountName = "sto2527"; + string resourceGroupName = "res7687"; + string accountName = "src1122"; ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); @@ -76,8 +87,23 @@ public async Task Get_StorageAccountGetObjectReplicationPolicies() ObjectReplicationPolicyCollection collection = storageAccount.GetObjectReplicationPolicies(); // invoke the operation - string objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; - ObjectReplicationPolicyResource result = await collection.GetAsync(objectReplicationPolicyId); + string objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + ObjectReplicationPolicyData data = new ObjectReplicationPolicyData + { + SourceAccount = "src1122", + DestinationAccount = "dst112", + Rules = {new ObjectReplicationPolicyRule("scont139", "dcont139") +{ +RuleId = "d5d18a48-8801-4554-aeaa-74faf65f5ef9", +Filters = new ObjectReplicationPolicyFilter +{ +PrefixMatch = {"blobA", "blobB"}, +MinCreationTime = "2020-02-19T16:05:00Z", +}, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectReplicationPolicyId, data); + ObjectReplicationPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +114,10 @@ public async Task Get_StorageAccountGetObjectReplicationPolicies() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGetObjectReplicationPolicies() + public async Task CreateOrUpdate_StorageAccountUpdateObjectReplicationPolicyOnDestination() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetObjectReplicationPolicy.json - // this example is just showing the usage of "ObjectReplicationPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateObjectReplicationPolicyOnDestination.json + // this example is just showing the usage of "ObjectReplicationPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,8 +127,8 @@ public async Task Exists_StorageAccountGetObjectReplicationPolicies() // this example assumes you already have this StorageAccountResource created on azure // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string accountName = "sto2527"; + string resourceGroupName = "res7687"; + string accountName = "dst112"; ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); @@ -110,18 +136,36 @@ public async Task Exists_StorageAccountGetObjectReplicationPolicies() ObjectReplicationPolicyCollection collection = storageAccount.GetObjectReplicationPolicies(); // invoke the operation - string objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; - bool result = await collection.ExistsAsync(objectReplicationPolicyId); + string objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + ObjectReplicationPolicyData data = new ObjectReplicationPolicyData + { + SourceAccount = "src1122", + DestinationAccount = "dst112", + Rules = {new ObjectReplicationPolicyRule("scont139", "dcont139") +{ +RuleId = "d5d18a48-8801-4554-aeaa-74faf65f5ef9", +Filters = new ObjectReplicationPolicyFilter +{ +PrefixMatch = {"blobA", "blobB"}, +}, +}, new ObjectReplicationPolicyRule("scont179", "dcont179")}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectReplicationPolicyId, data); + ObjectReplicationPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ObjectReplicationPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGetObjectReplicationPolicies() + public async Task CreateOrUpdate_StorageAccountUpdateObjectReplicationPolicyOnSource() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetObjectReplicationPolicy.json - // this example is just showing the usage of "ObjectReplicationPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateObjectReplicationPolicyOnSource.json + // this example is just showing the usage of "ObjectReplicationPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,8 +175,8 @@ public async Task GetIfExists_StorageAccountGetObjectReplicationPolicies() // this example assumes you already have this StorageAccountResource created on azure // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string accountName = "sto2527"; + string resourceGroupName = "res7687"; + string accountName = "src1122"; ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); @@ -140,30 +184,39 @@ public async Task GetIfExists_StorageAccountGetObjectReplicationPolicies() ObjectReplicationPolicyCollection collection = storageAccount.GetObjectReplicationPolicies(); // invoke the operation - string objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; - NullableResponse response = await collection.GetIfExistsAsync(objectReplicationPolicyId); - ObjectReplicationPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; + ObjectReplicationPolicyData data = new ObjectReplicationPolicyData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ObjectReplicationPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SourceAccount = "src1122", + DestinationAccount = "dst112", + Rules = {new ObjectReplicationPolicyRule("scont139", "dcont139") +{ +RuleId = "d5d18a48-8801-4554-aeaa-74faf65f5ef9", +Filters = new ObjectReplicationPolicyFilter +{ +PrefixMatch = {"blobA", "blobB"}, +}, +}, new ObjectReplicationPolicyRule("scont179", "dcont179") +{ +RuleId = "cfbb4bc2-8b60-429f-b05a-d1e0942b33b2", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectReplicationPolicyId, data); + ObjectReplicationPolicyResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ObjectReplicationPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StorageAccountCreateObjectReplicationPolicyOnDestination() + public async Task Get_StorageAccountGetObjectReplicationPolicies() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateObjectReplicationPolicyOnDestination.json - // this example is just showing the usage of "ObjectReplicationPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetObjectReplicationPolicy.json + // this example is just showing the usage of "ObjectReplicationPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,8 +226,8 @@ public async Task CreateOrUpdate_StorageAccountCreateObjectReplicationPolicyOnDe // this example assumes you already have this StorageAccountResource created on azure // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; - string accountName = "dst112"; + string resourceGroupName = "res6977"; + string accountName = "sto2527"; ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); @@ -182,27 +235,8 @@ public async Task CreateOrUpdate_StorageAccountCreateObjectReplicationPolicyOnDe ObjectReplicationPolicyCollection collection = storageAccount.GetObjectReplicationPolicies(); // invoke the operation - string objectReplicationPolicyId = "default"; - ObjectReplicationPolicyData data = new ObjectReplicationPolicyData() - { - SourceAccount = "src1122", - DestinationAccount = "dst112", - Rules = -{ -new ObjectReplicationPolicyRule("scont139","dcont139") -{ -Filters = new ObjectReplicationPolicyFilter() -{ -PrefixMatch = -{ -"blobA","blobB" -}, -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectReplicationPolicyId, data); - ObjectReplicationPolicyResource result = lro.Value; + string objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; + ObjectReplicationPolicyResource result = await collection.GetAsync(objectReplicationPolicyId); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -213,10 +247,10 @@ public async Task CreateOrUpdate_StorageAccountCreateObjectReplicationPolicyOnDe [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StorageAccountCreateObjectReplicationPolicyOnSource() + public async Task GetAll_StorageAccountListObjectReplicationPolicies() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCreateObjectReplicationPolicyOnSource.json - // this example is just showing the usage of "ObjectReplicationPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListObjectReplicationPolicies.json + // this example is just showing the usage of "ObjectReplicationPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,52 +260,33 @@ public async Task CreateOrUpdate_StorageAccountCreateObjectReplicationPolicyOnSo // this example assumes you already have this StorageAccountResource created on azure // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; - string accountName = "src1122"; + string resourceGroupName = "res6977"; + string accountName = "sto2527"; ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // get the collection of this ObjectReplicationPolicyResource ObjectReplicationPolicyCollection collection = storageAccount.GetObjectReplicationPolicies(); - // invoke the operation - string objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; - ObjectReplicationPolicyData data = new ObjectReplicationPolicyData() + // invoke the operation and iterate over the result + await foreach (ObjectReplicationPolicyResource item in collection.GetAllAsync()) { - SourceAccount = "src1122", - DestinationAccount = "dst112", - Rules = -{ -new ObjectReplicationPolicyRule("scont139","dcont139") -{ -RuleId = "d5d18a48-8801-4554-aeaa-74faf65f5ef9", -Filters = new ObjectReplicationPolicyFilter() -{ -PrefixMatch = -{ -"blobA","blobB" -}, -MinCreationTime = "2020-02-19T16:05:00Z", -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectReplicationPolicyId, data); - ObjectReplicationPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ObjectReplicationPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ObjectReplicationPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StorageAccountUpdateObjectReplicationPolicyOnDestination() + public async Task Exists_StorageAccountGetObjectReplicationPolicies() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateObjectReplicationPolicyOnDestination.json - // this example is just showing the usage of "ObjectReplicationPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetObjectReplicationPolicy.json + // this example is just showing the usage of "ObjectReplicationPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -281,8 +296,8 @@ public async Task CreateOrUpdate_StorageAccountUpdateObjectReplicationPolicyOnDe // this example assumes you already have this StorageAccountResource created on azure // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; - string accountName = "dst112"; + string resourceGroupName = "res6977"; + string accountName = "sto2527"; ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); @@ -290,42 +305,18 @@ public async Task CreateOrUpdate_StorageAccountUpdateObjectReplicationPolicyOnDe ObjectReplicationPolicyCollection collection = storageAccount.GetObjectReplicationPolicies(); // invoke the operation - string objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; - ObjectReplicationPolicyData data = new ObjectReplicationPolicyData() - { - SourceAccount = "src1122", - DestinationAccount = "dst112", - Rules = -{ -new ObjectReplicationPolicyRule("scont139","dcont139") -{ -RuleId = "d5d18a48-8801-4554-aeaa-74faf65f5ef9", -Filters = new ObjectReplicationPolicyFilter() -{ -PrefixMatch = -{ -"blobA","blobB" -}, -}, -},new ObjectReplicationPolicyRule("scont179","dcont179") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectReplicationPolicyId, data); - ObjectReplicationPolicyResource result = lro.Value; + string objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; + bool result = await collection.ExistsAsync(objectReplicationPolicyId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ObjectReplicationPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StorageAccountUpdateObjectReplicationPolicyOnSource() + public async Task GetIfExists_StorageAccountGetObjectReplicationPolicies() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountUpdateObjectReplicationPolicyOnSource.json - // this example is just showing the usage of "ObjectReplicationPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetObjectReplicationPolicy.json + // this example is just showing the usage of "ObjectReplicationPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -335,8 +326,8 @@ public async Task CreateOrUpdate_StorageAccountUpdateObjectReplicationPolicyOnSo // this example assumes you already have this StorageAccountResource created on azure // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; - string accountName = "src1122"; + string resourceGroupName = "res6977"; + string accountName = "sto2527"; ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); @@ -344,37 +335,22 @@ public async Task CreateOrUpdate_StorageAccountUpdateObjectReplicationPolicyOnSo ObjectReplicationPolicyCollection collection = storageAccount.GetObjectReplicationPolicies(); // invoke the operation - string objectReplicationPolicyId = "2a20bb73-5717-4635-985a-5d4cf777438f"; - ObjectReplicationPolicyData data = new ObjectReplicationPolicyData() - { - SourceAccount = "src1122", - DestinationAccount = "dst112", - Rules = -{ -new ObjectReplicationPolicyRule("scont139","dcont139") -{ -RuleId = "d5d18a48-8801-4554-aeaa-74faf65f5ef9", -Filters = new ObjectReplicationPolicyFilter() -{ -PrefixMatch = -{ -"blobA","blobB" -}, -}, -},new ObjectReplicationPolicyRule("scont179","dcont179") -{ -RuleId = "cfbb4bc2-8b60-429f-b05a-d1e0942b33b2", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, objectReplicationPolicyId, data); - ObjectReplicationPolicyResource result = lro.Value; + string objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; + NullableResponse response = await collection.GetIfExistsAsync(objectReplicationPolicyId); + ObjectReplicationPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ObjectReplicationPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ObjectReplicationPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ObjectReplicationPolicyResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ObjectReplicationPolicyResource.cs index 823712029f9c9..0a918528a4300 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ObjectReplicationPolicyResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_ObjectReplicationPolicyResource.cs @@ -47,6 +47,33 @@ public async Task Get_StorageAccountGetObjectReplicationPolicies() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_StorageAccountDeleteObjectReplicationPolicies() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeleteObjectReplicationPolicy.json + // this example is just showing the usage of "ObjectReplicationPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ObjectReplicationPolicyResource created on azure + // for more information of creating ObjectReplicationPolicyResource, please refer to the document of ObjectReplicationPolicyResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "res6977"; + string accountName = "sto2527"; + string objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; + ResourceIdentifier objectReplicationPolicyResourceId = ObjectReplicationPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, objectReplicationPolicyId); + ObjectReplicationPolicyResource objectReplicationPolicy = client.GetObjectReplicationPolicyResource(objectReplicationPolicyResourceId); + + // invoke the operation + await objectReplicationPolicy.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_StorageAccountCreateObjectReplicationPolicyOnDestination() @@ -69,23 +96,17 @@ public async Task Update_StorageAccountCreateObjectReplicationPolicyOnDestinatio ObjectReplicationPolicyResource objectReplicationPolicy = client.GetObjectReplicationPolicyResource(objectReplicationPolicyResourceId); // invoke the operation - ObjectReplicationPolicyData data = new ObjectReplicationPolicyData() + ObjectReplicationPolicyData data = new ObjectReplicationPolicyData { SourceAccount = "src1122", DestinationAccount = "dst112", - Rules = -{ -new ObjectReplicationPolicyRule("scont139","dcont139") + Rules = {new ObjectReplicationPolicyRule("scont139", "dcont139") { -Filters = new ObjectReplicationPolicyFilter() +Filters = new ObjectReplicationPolicyFilter { -PrefixMatch = -{ -"blobA","blobB" -}, -}, -} +PrefixMatch = {"blobA", "blobB"}, }, +}}, }; ArmOperation lro = await objectReplicationPolicy.UpdateAsync(WaitUntil.Completed, data); ObjectReplicationPolicyResource result = lro.Value; @@ -119,25 +140,19 @@ public async Task Update_StorageAccountCreateObjectReplicationPolicyOnSource() ObjectReplicationPolicyResource objectReplicationPolicy = client.GetObjectReplicationPolicyResource(objectReplicationPolicyResourceId); // invoke the operation - ObjectReplicationPolicyData data = new ObjectReplicationPolicyData() + ObjectReplicationPolicyData data = new ObjectReplicationPolicyData { SourceAccount = "src1122", DestinationAccount = "dst112", - Rules = -{ -new ObjectReplicationPolicyRule("scont139","dcont139") + Rules = {new ObjectReplicationPolicyRule("scont139", "dcont139") { RuleId = "d5d18a48-8801-4554-aeaa-74faf65f5ef9", -Filters = new ObjectReplicationPolicyFilter() +Filters = new ObjectReplicationPolicyFilter { -PrefixMatch = -{ -"blobA","blobB" -}, +PrefixMatch = {"blobA", "blobB"}, MinCreationTime = "2020-02-19T16:05:00Z", }, -} -}, +}}, }; ArmOperation lro = await objectReplicationPolicy.UpdateAsync(WaitUntil.Completed, data); ObjectReplicationPolicyResource result = lro.Value; @@ -171,24 +186,18 @@ public async Task Update_StorageAccountUpdateObjectReplicationPolicyOnDestinatio ObjectReplicationPolicyResource objectReplicationPolicy = client.GetObjectReplicationPolicyResource(objectReplicationPolicyResourceId); // invoke the operation - ObjectReplicationPolicyData data = new ObjectReplicationPolicyData() + ObjectReplicationPolicyData data = new ObjectReplicationPolicyData { SourceAccount = "src1122", DestinationAccount = "dst112", - Rules = -{ -new ObjectReplicationPolicyRule("scont139","dcont139") + Rules = {new ObjectReplicationPolicyRule("scont139", "dcont139") { RuleId = "d5d18a48-8801-4554-aeaa-74faf65f5ef9", -Filters = new ObjectReplicationPolicyFilter() -{ -PrefixMatch = +Filters = new ObjectReplicationPolicyFilter { -"blobA","blobB" -}, -}, -},new ObjectReplicationPolicyRule("scont179","dcont179") +PrefixMatch = {"blobA", "blobB"}, }, +}, new ObjectReplicationPolicyRule("scont179", "dcont179")}, }; ArmOperation lro = await objectReplicationPolicy.UpdateAsync(WaitUntil.Completed, data); ObjectReplicationPolicyResource result = lro.Value; @@ -222,27 +231,21 @@ public async Task Update_StorageAccountUpdateObjectReplicationPolicyOnSource() ObjectReplicationPolicyResource objectReplicationPolicy = client.GetObjectReplicationPolicyResource(objectReplicationPolicyResourceId); // invoke the operation - ObjectReplicationPolicyData data = new ObjectReplicationPolicyData() + ObjectReplicationPolicyData data = new ObjectReplicationPolicyData { SourceAccount = "src1122", DestinationAccount = "dst112", - Rules = -{ -new ObjectReplicationPolicyRule("scont139","dcont139") + Rules = {new ObjectReplicationPolicyRule("scont139", "dcont139") { RuleId = "d5d18a48-8801-4554-aeaa-74faf65f5ef9", -Filters = new ObjectReplicationPolicyFilter() +Filters = new ObjectReplicationPolicyFilter { -PrefixMatch = -{ -"blobA","blobB" -}, +PrefixMatch = {"blobA", "blobB"}, }, -},new ObjectReplicationPolicyRule("scont179","dcont179") +}, new ObjectReplicationPolicyRule("scont179", "dcont179") { RuleId = "cfbb4bc2-8b60-429f-b05a-d1e0942b33b2", -} -}, +}}, }; ArmOperation lro = await objectReplicationPolicy.UpdateAsync(WaitUntil.Completed, data); ObjectReplicationPolicyResource result = lro.Value; @@ -253,32 +256,5 @@ public async Task Update_StorageAccountUpdateObjectReplicationPolicyOnSource() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_StorageAccountDeleteObjectReplicationPolicies() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeleteObjectReplicationPolicy.json - // this example is just showing the usage of "ObjectReplicationPolicies_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ObjectReplicationPolicyResource created on azure - // for more information of creating ObjectReplicationPolicyResource, please refer to the document of ObjectReplicationPolicyResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string accountName = "sto2527"; - string objectReplicationPolicyId = "{objectReplicationPolicy-Id}"; - ResourceIdentifier objectReplicationPolicyResourceId = ObjectReplicationPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, objectReplicationPolicyId); - ObjectReplicationPolicyResource objectReplicationPolicy = client.GetObjectReplicationPolicyResource(objectReplicationPolicyResourceId); - - // invoke the operation - await objectReplicationPolicy.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_QueueServiceResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_QueueServiceResource.cs index 3900df70e80f1..88b4468af0965 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_QueueServiceResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_QueueServiceResource.cs @@ -18,10 +18,10 @@ public partial class Sample_QueueServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_QueueServicesPut() + public async Task Get_QueueServicesGet() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueServicesPut.json - // this example is just showing the usage of "QueueServices_SetServiceProperties" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueServicesGet.json + // this example is just showing the usage of "QueueServices_GetServiceProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,51 +37,7 @@ public async Task CreateOrUpdate_QueueServicesPut() QueueServiceResource queueService = client.GetQueueServiceResource(queueServiceResourceId); // invoke the operation - QueueServiceData data = new QueueServiceData() - { - CorsRules = -{ -new StorageCorsRule(new string[] -{ -"http://www.contoso.com","http://www.fabrikam.com" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get,CorsRuleAllowedMethod.Head,CorsRuleAllowedMethod.Post,CorsRuleAllowedMethod.Options,CorsRuleAllowedMethod.Merge,CorsRuleAllowedMethod.Put -},100,new string[] -{ -"x-ms-meta-*" -},new string[] -{ -"x-ms-meta-abc","x-ms-meta-data*","x-ms-meta-target*" -}),new StorageCorsRule(new string[] -{ -"*" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get -},2,new string[] -{ -"*" -},new string[] -{ -"*" -}),new StorageCorsRule(new string[] -{ -"http://www.abc23.com","https://www.fabrikam.com/*" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get,CorsRuleAllowedMethod.Put -},2000,new string[] -{ -"x-ms-meta-abc","x-ms-meta-data*","x-ms-meta-target*" -},new string[] -{ -"x-ms-meta-12345675754564*" -}) -}, - }; - ArmOperation lro = await queueService.CreateOrUpdateAsync(WaitUntil.Completed, data); - QueueServiceResource result = lro.Value; + QueueServiceResource result = await queueService.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +48,10 @@ public async Task CreateOrUpdate_QueueServicesPut() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QueueServicesGet() + public async Task CreateOrUpdate_QueueServicesPut() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueServicesGet.json - // this example is just showing the usage of "QueueServices_GetServiceProperties" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueServicesPut.json + // this example is just showing the usage of "QueueServices_SetServiceProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,7 +67,12 @@ public async Task Get_QueueServicesGet() QueueServiceResource queueService = client.GetQueueServiceResource(queueServiceResourceId); // invoke the operation - QueueServiceResource result = await queueService.GetAsync(); + QueueServiceData data = new QueueServiceData + { + CorsRules = { new StorageCorsRule(new string[] { "http://www.contoso.com", "http://www.fabrikam.com" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get, CorsRuleAllowedMethod.Head, CorsRuleAllowedMethod.Post, CorsRuleAllowedMethod.Options, CorsRuleAllowedMethod.Merge, CorsRuleAllowedMethod.Put }, 100, new string[] { "x-ms-meta-*" }, new string[] { "x-ms-meta-abc", "x-ms-meta-data*", "x-ms-meta-target*" }), new StorageCorsRule(new string[] { "*" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get }, 2, new string[] { "*" }, new string[] { "*" }), new StorageCorsRule(new string[] { "http://www.abc23.com", "https://www.fabrikam.com/*" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get, CorsRuleAllowedMethod.Put }, 2000, new string[] { "x-ms-meta-abc", "x-ms-meta-data*", "x-ms-meta-target*" }, new string[] { "x-ms-meta-12345675754564*" }) }, + }; + ArmOperation lro = await queueService.CreateOrUpdateAsync(WaitUntil.Completed, data); + QueueServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountCollection.cs index 451f8b44f0227..354428c98db6d 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountCollection.cs @@ -48,13 +48,8 @@ public async Task CreateOrUpdate_NfsV3AccountCreate() NetworkRuleSet = new StorageAccountNetworkRuleSet(StorageNetworkDefaultAction.Allow) { Bypass = StorageNetworkBypass.AzureServices, - VirtualNetworkRules = -{ -new StorageAccountVirtualNetworkRule(new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.Network/virtualNetworks/net123/subnets/subnet12")) -}, - IPRules = -{ -}, + VirtualNetworkRules = { new StorageAccountVirtualNetworkRule(new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.Network/virtualNetworks/net123/subnets/subnet12")) }, + IPRules = { }, }, EnableHttpsTrafficOnly = false, IsExtendedGroupEnabled = true, @@ -97,27 +92,27 @@ public async Task CreateOrUpdate_StorageAccountCreate() string accountName = "sto4445"; StorageAccountCreateOrUpdateContent content = new StorageAccountCreateOrUpdateContent(new StorageSku(StorageSkuName.StandardGrs), StorageKind.Storage, new AzureLocation("eastus")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "losangeles001", }, Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, SasPolicy = new StorageAccountSasPolicy("1.15:59:59", ExpirationAction.Log), KeyExpirationPeriodInDays = 20, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -128,7 +123,7 @@ public async Task CreateOrUpdate_StorageAccountCreate() }, IsSftpEnabled = true, IsHnsEnabled = true, - RoutingPreference = new StorageRoutingPreference() + RoutingPreference = new StorageRoutingPreference { RoutingChoice = StorageRoutingChoice.MicrosoftRouting, IsMicrosoftEndpointsPublished = true, @@ -178,21 +173,21 @@ public async Task CreateOrUpdate_StorageAccountCreateAllowedCopyScopeToAAD() Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, AllowedCopyScope = AllowedCopyScope.Aad, SasPolicy = new StorageAccountSasPolicy("1.15:59:59", ExpirationAction.Log), KeyExpirationPeriodInDays = 20, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -202,7 +197,7 @@ public async Task CreateOrUpdate_StorageAccountCreateAllowedCopyScopeToAAD() RequireInfrastructureEncryption = false, }, IsHnsEnabled = true, - RoutingPreference = new StorageRoutingPreference() + RoutingPreference = new StorageRoutingPreference { RoutingChoice = StorageRoutingChoice.MicrosoftRouting, IsMicrosoftEndpointsPublished = true, @@ -251,21 +246,21 @@ public async Task CreateOrUpdate_StorageAccountCreateAllowedCopyScopeToPrivateLi Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, AllowedCopyScope = AllowedCopyScope.PrivateLink, SasPolicy = new StorageAccountSasPolicy("1.15:59:59", ExpirationAction.Log), KeyExpirationPeriodInDays = 20, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -275,7 +270,7 @@ public async Task CreateOrUpdate_StorageAccountCreateAllowedCopyScopeToPrivateLi RequireInfrastructureEncryption = false, }, IsHnsEnabled = true, - RoutingPreference = new StorageRoutingPreference() + RoutingPreference = new StorageRoutingPreference { RoutingChoice = StorageRoutingChoice.MicrosoftRouting, IsMicrosoftEndpointsPublished = true, @@ -321,28 +316,28 @@ public async Task CreateOrUpdate_StorageAccountCreateDisallowPublicNetworkAccess string accountName = "sto4445"; StorageAccountCreateOrUpdateContent content = new StorageAccountCreateOrUpdateContent(new StorageSku(StorageSkuName.StandardGrs), StorageKind.Storage, new AzureLocation("eastus")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "losangeles001", }, Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, PublicNetworkAccess = StoragePublicNetworkAccess.Disabled, SasPolicy = new StorageAccountSasPolicy("1.15:59:59", ExpirationAction.Log), KeyExpirationPeriodInDays = 20, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -352,7 +347,7 @@ public async Task CreateOrUpdate_StorageAccountCreateDisallowPublicNetworkAccess RequireInfrastructureEncryption = false, }, IsHnsEnabled = true, - RoutingPreference = new StorageRoutingPreference() + RoutingPreference = new StorageRoutingPreference { RoutingChoice = StorageRoutingChoice.MicrosoftRouting, IsMicrosoftEndpointsPublished = true, @@ -398,27 +393,27 @@ public async Task CreateOrUpdate_StorageAccountCreateDnsEndpointTypeToAzureDnsZo string accountName = "sto4445"; StorageAccountCreateOrUpdateContent content = new StorageAccountCreateOrUpdateContent(new StorageSku(StorageSkuName.StandardGrs), StorageKind.Storage, new AzureLocation("eastus")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "losangeles001", }, Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, SasPolicy = new StorageAccountSasPolicy("1.15:59:59", ExpirationAction.Log), KeyExpirationPeriodInDays = 20, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -429,7 +424,7 @@ public async Task CreateOrUpdate_StorageAccountCreateDnsEndpointTypeToAzureDnsZo }, IsSftpEnabled = true, IsHnsEnabled = true, - RoutingPreference = new StorageRoutingPreference() + RoutingPreference = new StorageRoutingPreference { RoutingChoice = StorageRoutingChoice.MicrosoftRouting, IsMicrosoftEndpointsPublished = true, @@ -477,27 +472,27 @@ public async Task CreateOrUpdate_StorageAccountCreateDnsEndpointTypeToStandard() string accountName = "sto4445"; StorageAccountCreateOrUpdateContent content = new StorageAccountCreateOrUpdateContent(new StorageSku(StorageSkuName.StandardGrs), StorageKind.Storage, new AzureLocation("eastus")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "losangeles001", }, Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, SasPolicy = new StorageAccountSasPolicy("1.15:59:59", ExpirationAction.Log), KeyExpirationPeriodInDays = 20, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -508,7 +503,7 @@ public async Task CreateOrUpdate_StorageAccountCreateDnsEndpointTypeToStandard() }, IsSftpEnabled = true, IsHnsEnabled = true, - RoutingPreference = new StorageRoutingPreference() + RoutingPreference = new StorageRoutingPreference { RoutingChoice = StorageRoutingChoice.MicrosoftRouting, IsMicrosoftEndpointsPublished = true, @@ -556,28 +551,28 @@ public async Task CreateOrUpdate_StorageAccountCreateEnablePublicNetworkAccess() string accountName = "sto4445"; StorageAccountCreateOrUpdateContent content = new StorageAccountCreateOrUpdateContent(new StorageSku(StorageSkuName.StandardGrs), StorageKind.Storage, new AzureLocation("eastus")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "losangeles001", }, Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, PublicNetworkAccess = StoragePublicNetworkAccess.Enabled, SasPolicy = new StorageAccountSasPolicy("1.15:59:59", ExpirationAction.Log), KeyExpirationPeriodInDays = 20, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -587,7 +582,7 @@ public async Task CreateOrUpdate_StorageAccountCreateEnablePublicNetworkAccess() RequireInfrastructureEncryption = false, }, IsHnsEnabled = true, - RoutingPreference = new StorageRoutingPreference() + RoutingPreference = new StorageRoutingPreference { RoutingChoice = StorageRoutingChoice.MicrosoftRouting, IsMicrosoftEndpointsPublished = true, @@ -636,18 +631,18 @@ public async Task CreateOrUpdate_StorageAccountCreatePremiumBlockBlobStorage() Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -699,32 +694,32 @@ public async Task CreateOrUpdate_StorageAccountCreateUserAssignedEncryptionIdent { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}")] = new UserAssignedIdentity() }, }, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, }, KeySource = StorageAccountKeySource.KeyVault, - KeyVaultProperties = new StorageAccountKeyVaultProperties() + KeyVaultProperties = new StorageAccountKeyVaultProperties { KeyName = "wrappingKey", KeyVersion = "", KeyVaultUri = new Uri("https://myvault8569.vault.azure.net"), }, - EncryptionIdentity = new StorageAccountEncryptionIdentity() + EncryptionIdentity = new StorageAccountEncryptionIdentity { EncryptionUserAssignedIdentity = "/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}", }, @@ -770,32 +765,32 @@ public async Task CreateOrUpdate_StorageAccountCreateUserAssignedIdentityWithFed { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}")] = new UserAssignedIdentity() }, }, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, }, KeySource = StorageAccountKeySource.KeyVault, - KeyVaultProperties = new StorageAccountKeyVaultProperties() + KeyVaultProperties = new StorageAccountKeyVaultProperties { KeyName = "wrappingKey", KeyVersion = "", KeyVaultUri = new Uri("https://myvault8569.vault.azure.net"), }, - EncryptionIdentity = new StorageAccountEncryptionIdentity() + EncryptionIdentity = new StorageAccountEncryptionIdentity { EncryptionUserAssignedIdentity = "/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}", EncryptionFederatedIdentityClientId = "f83c6b1b-4d34-47e4-bb34-9d83df58b540", @@ -838,14 +833,14 @@ public async Task CreateOrUpdate_StorageAccountCreateWithImmutabilityPolicy() string accountName = "sto4445"; StorageAccountCreateOrUpdateContent content = new StorageAccountCreateOrUpdateContent(new StorageSku(StorageSkuName.StandardGrs), StorageKind.Storage, new AzureLocation("eastus")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "losangeles001", }, - ImmutableStorageWithVersioning = new ImmutableStorageAccount() + ImmutableStorageWithVersioning = new ImmutableStorageAccount { IsEnabled = true, - ImmutabilityPolicy = new AccountImmutabilityPolicy() + ImmutabilityPolicy = new AccountImmutabilityPolicy { ImmutabilityPeriodSinceCreationInDays = 15, State = AccountImmutabilityPolicyState.Unlocked, @@ -898,9 +893,9 @@ public async Task Get_StorageAccountGetAsyncSkuConversionStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGetAsyncSkuConversionStatus() + public async Task Get_StorageAccountGetProperties() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetAsyncSkuConversionStatus.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetProperties.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -920,16 +915,20 @@ public async Task Exists_StorageAccountGetAsyncSkuConversionStatus() // invoke the operation string accountName = "sto8596"; - bool result = await collection.ExistsAsync(accountName); + StorageAccountResource result = await collection.GetAsync(accountName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGetAsyncSkuConversionStatus() + public async Task Get_StorageAccountGetPropertiesCMKEnabled() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetAsyncSkuConversionStatus.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKEnabled.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -949,28 +948,20 @@ public async Task GetIfExists_StorageAccountGetAsyncSkuConversionStatus() // invoke the operation string accountName = "sto8596"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - StorageAccountResource result = response.HasValue ? response.Value : null; + StorageAccountResource result = await collection.GetAsync(accountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageAccountGetProperties() + public async Task Get_StorageAccountGetPropertiesCMKVersionExpirationTime() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetProperties.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKVersionExpirationTime.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1001,9 +992,9 @@ public async Task Get_StorageAccountGetProperties() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGetProperties() + public async Task Get_StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetProperties.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1023,16 +1014,21 @@ public async Task Exists_StorageAccountGetProperties() // invoke the operation string accountName = "sto8596"; - bool result = await collection.ExistsAsync(accountName); + StorageAccountExpand? expand = StorageAccountExpand.GeoReplicationStats; + StorageAccountResource result = await collection.GetAsync(accountName, expand: expand); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGetProperties() + public async Task Get_StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetProperties.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1052,29 +1048,22 @@ public async Task GetIfExists_StorageAccountGetProperties() // invoke the operation string accountName = "sto8596"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - StorageAccountResource result = response.HasValue ? response.Value : null; + StorageAccountExpand? expand = StorageAccountExpand.GeoReplicationStats; + StorageAccountResource result = await collection.GetAsync(accountName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageAccountGetPropertiesCMKEnabled() + public async Task GetAll_StorageAccountListByResourceGroup() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKEnabled.json - // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListByResourceGroup.json + // this example is just showing the usage of "StorageAccounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1084,29 +1073,31 @@ public async Task Get_StorageAccountGetPropertiesCMKEnabled() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9407"; + string resourceGroupName = "res6117"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this StorageAccountResource StorageAccountCollection collection = resourceGroupResource.GetStorageAccounts(); - // invoke the operation - string accountName = "sto8596"; - StorageAccountResource result = await collection.GetAsync(accountName); + // invoke the operation and iterate over the result + await foreach (StorageAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGetPropertiesCMKEnabled() + public async Task Exists_StorageAccountGetAsyncSkuConversionStatus() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKEnabled.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetAsyncSkuConversionStatus.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1133,9 +1124,9 @@ public async Task Exists_StorageAccountGetPropertiesCMKEnabled() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGetPropertiesCMKEnabled() + public async Task Exists_StorageAccountGetProperties() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKEnabled.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetProperties.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1155,28 +1146,16 @@ public async Task GetIfExists_StorageAccountGetPropertiesCMKEnabled() // invoke the operation string accountName = "sto8596"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - StorageAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageAccountGetPropertiesCMKVersionExpirationTime() + public async Task Exists_StorageAccountGetPropertiesCMKEnabled() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKVersionExpirationTime.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKEnabled.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1196,13 +1175,9 @@ public async Task Get_StorageAccountGetPropertiesCMKVersionExpirationTime() // invoke the operation string accountName = "sto8596"; - StorageAccountResource result = await collection.GetAsync(accountName); + bool result = await collection.ExistsAsync(accountName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -1236,9 +1211,9 @@ public async Task Exists_StorageAccountGetPropertiesCMKVersionExpirationTime() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGetPropertiesCMKVersionExpirationTime() + public async Task Exists_StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKVersionExpirationTime.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1258,28 +1233,17 @@ public async Task GetIfExists_StorageAccountGetPropertiesCMKVersionExpirationTim // invoke the operation string accountName = "sto8596"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - StorageAccountResource result = response.HasValue ? response.Value : null; + StorageAccountExpand? expand = StorageAccountExpand.GeoReplicationStats; + bool result = await collection.ExistsAsync(accountName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse() + public async Task Exists_StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1300,20 +1264,16 @@ public async Task Get_StorageAccountGetPropertiesGeoReplicationStatscanFailoverF // invoke the operation string accountName = "sto8596"; StorageAccountExpand? expand = StorageAccountExpand.GeoReplicationStats; - StorageAccountResource result = await collection.GetAsync(accountName, expand: expand); + bool result = await collection.ExistsAsync(accountName, expand: expand); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse() + public async Task GetIfExists_StorageAccountGetAsyncSkuConversionStatus() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetAsyncSkuConversionStatus.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1333,17 +1293,28 @@ public async Task Exists_StorageAccountGetPropertiesGeoReplicationStatscanFailov // invoke the operation string accountName = "sto8596"; - StorageAccountExpand? expand = StorageAccountExpand.GeoReplicationStats; - bool result = await collection.ExistsAsync(accountName, expand: expand); + NullableResponse response = await collection.GetIfExistsAsync(accountName); + StorageAccountResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse() + public async Task GetIfExists_StorageAccountGetProperties() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetProperties.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1363,8 +1334,7 @@ public async Task GetIfExists_StorageAccountGetPropertiesGeoReplicationStatscanF // invoke the operation string accountName = "sto8596"; - StorageAccountExpand? expand = StorageAccountExpand.GeoReplicationStats; - NullableResponse response = await collection.GetIfExistsAsync(accountName, expand: expand); + NullableResponse response = await collection.GetIfExistsAsync(accountName); StorageAccountResource result = response.HasValue ? response.Value : null; if (result == null) @@ -1383,9 +1353,9 @@ public async Task GetIfExists_StorageAccountGetPropertiesGeoReplicationStatscanF [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue() + public async Task GetIfExists_StorageAccountGetPropertiesCMKEnabled() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKEnabled.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1405,21 +1375,28 @@ public async Task Get_StorageAccountGetPropertiesGeoReplicationStatscanFailoverT // invoke the operation string accountName = "sto8596"; - StorageAccountExpand? expand = StorageAccountExpand.GeoReplicationStats; - StorageAccountResource result = await collection.GetAsync(accountName, expand: expand); + NullableResponse response = await collection.GetIfExistsAsync(accountName); + StorageAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue() + public async Task GetIfExists_StorageAccountGetPropertiesCMKVersionExpirationTime() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesCMKVersionExpirationTime.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1439,17 +1416,28 @@ public async Task Exists_StorageAccountGetPropertiesGeoReplicationStatscanFailov // invoke the operation string accountName = "sto8596"; - StorageAccountExpand? expand = StorageAccountExpand.GeoReplicationStats; - bool result = await collection.ExistsAsync(accountName, expand: expand); + NullableResponse response = await collection.GetIfExistsAsync(accountName); + StorageAccountResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue() + public async Task GetIfExists_StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverFalse.json // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1489,10 +1477,10 @@ public async Task GetIfExists_StorageAccountGetPropertiesGeoReplicationStatscanF [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StorageAccountListByResourceGroup() + public async Task GetIfExists_StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListByResourceGroup.json - // this example is just showing the usage of "StorageAccounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPropertiesGeoReplicationStatscanFailoverTrue.json + // this example is just showing the usage of "StorageAccounts_GetProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1502,24 +1490,31 @@ public async Task GetAll_StorageAccountListByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6117"; + string resourceGroupName = "res9407"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this StorageAccountResource StorageAccountCollection collection = resourceGroupResource.GetStorageAccounts(); - // invoke the operation and iterate over the result - await foreach (StorageAccountResource item in collection.GetAllAsync()) + // invoke the operation + string accountName = "sto8596"; + StorageAccountExpand? expand = StorageAccountExpand.GeoReplicationStats; + NullableResponse response = await collection.GetIfExistsAsync(accountName, expand: expand); + StorageAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageAccountData resourceData = item.Data; + StorageAccountData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountLocalUserCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountLocalUserCollection.cs index f72c9cffd2b00..9eecc797578d9 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountLocalUserCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountLocalUserCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageAccountLocalUserCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListLocalUsers() + public async Task CreateOrUpdate_CreateLocalUser() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUsersList.json - // this example is just showing the usage of "LocalUsers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserCreate.json + // this example is just showing the usage of "LocalUsers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,37 @@ public async Task GetAll_ListLocalUsers() // get the collection of this StorageAccountLocalUserResource StorageAccountLocalUserCollection collection = storageAccount.GetStorageAccountLocalUsers(); - // invoke the operation and iterate over the result - await foreach (StorageAccountLocalUserResource item in collection.GetAllAsync()) + // invoke the operation + string username = "user1"; + StorageAccountLocalUserData data = new StorageAccountLocalUserData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountLocalUserData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PermissionScopes = { new StoragePermissionScope("rwd", "file", "share1"), new StoragePermissionScope("rw", "file", "share2") }, + HomeDirectory = "homedirectory", + SshAuthorizedKeys = {new StorageSshPublicKey +{ +Description = "key name", +Key = "ssh-rsa keykeykeykeykey=", +}}, + HasSshPassword = true, + GroupId = 2000, + IsAclAuthorizationAllowed = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, username, data); + StorageAccountLocalUserResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountLocalUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNFSv3EnabledLocalUsers() + public async Task CreateOrUpdate_CreateNFSv3EnabledLocalUser() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUsersListNFSv3Enabled.json - // this example is just showing the usage of "LocalUsers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserCreateNFSv3Enabled.json + // this example is just showing the usage of "LocalUsers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,26 +87,29 @@ public async Task GetAll_ListNFSv3EnabledLocalUsers() // get the collection of this StorageAccountLocalUserResource StorageAccountLocalUserCollection collection = storageAccount.GetStorageAccountLocalUsers(); - // invoke the operation and iterate over the result - ListLocalUserIncludeParam? include = ListLocalUserIncludeParam.Nfsv3; - await foreach (StorageAccountLocalUserResource item in collection.GetAllAsync(include: include)) + // invoke the operation + string username = "user1"; + StorageAccountLocalUserData data = new StorageAccountLocalUserData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountLocalUserData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ExtendedGroups = { 1001, 1005, 2005 }, + IsNfsV3Enabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, username, data); + StorageAccountLocalUserResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountLocalUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetLocalUser() + public async Task CreateOrUpdate_UpdateLocalUser() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserGet.json - // this example is just showing the usage of "LocalUsers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserUpdate.json + // this example is just showing the usage of "LocalUsers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,7 +129,19 @@ public async Task Get_GetLocalUser() // invoke the operation string username = "user1"; - StorageAccountLocalUserResource result = await collection.GetAsync(username); + StorageAccountLocalUserData data = new StorageAccountLocalUserData + { + HomeDirectory = "homedirectory2", + HasSharedKey = false, + HasSshKey = false, + HasSshPassword = false, + GroupId = 3000, + IsAclAuthorizationAllowed = false, + ExtendedGroups = { 1001, 1005, 2005 }, + IsNfsV3Enabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, username, data); + StorageAccountLocalUserResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -125,7 +152,7 @@ public async Task Get_GetLocalUser() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetLocalUser() + public async Task Get_GetLocalUser() { // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserGet.json // this example is just showing the usage of "LocalUsers_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,17 +175,21 @@ public async Task Exists_GetLocalUser() // invoke the operation string username = "user1"; - bool result = await collection.ExistsAsync(username); + StorageAccountLocalUserResource result = await collection.GetAsync(username); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountLocalUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetLocalUser() + public async Task GetAll_ListLocalUsers() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserGet.json - // this example is just showing the usage of "LocalUsers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUsersList.json + // this example is just showing the usage of "LocalUsers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,31 +207,25 @@ public async Task GetIfExists_GetLocalUser() // get the collection of this StorageAccountLocalUserResource StorageAccountLocalUserCollection collection = storageAccount.GetStorageAccountLocalUsers(); - // invoke the operation - string username = "user1"; - NullableResponse response = await collection.GetIfExistsAsync(username); - StorageAccountLocalUserResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (StorageAccountLocalUserResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageAccountLocalUserData resourceData = result.Data; + StorageAccountLocalUserData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateLocalUser() + public async Task GetAll_ListNFSv3EnabledLocalUsers() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserCreate.json - // this example is just showing the usage of "LocalUsers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUsersListNFSv3Enabled.json + // this example is just showing the usage of "LocalUsers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -218,43 +243,26 @@ public async Task CreateOrUpdate_CreateLocalUser() // get the collection of this StorageAccountLocalUserResource StorageAccountLocalUserCollection collection = storageAccount.GetStorageAccountLocalUsers(); - // invoke the operation - string username = "user1"; - StorageAccountLocalUserData data = new StorageAccountLocalUserData() + // invoke the operation and iterate over the result + ListLocalUserIncludeParam? include = ListLocalUserIncludeParam.Nfsv3; + await foreach (StorageAccountLocalUserResource item in collection.GetAllAsync(include: include)) { - PermissionScopes = -{ -new StoragePermissionScope("rwd","file","share1"),new StoragePermissionScope("rw","file","share2") -}, - HomeDirectory = "homedirectory", - SshAuthorizedKeys = -{ -new StorageSshPublicKey() -{ -Description = "key name", -Key = "ssh-rsa keykeykeykeykey=", -} -}, - HasSshPassword = true, - GroupId = 2000, - IsAclAuthorizationAllowed = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, username, data); - StorageAccountLocalUserResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountLocalUserData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountLocalUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNFSv3EnabledLocalUser() + public async Task Exists_GetLocalUser() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserCreateNFSv3Enabled.json - // this example is just showing the usage of "LocalUsers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserGet.json + // this example is just showing the usage of "LocalUsers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -274,30 +282,17 @@ public async Task CreateOrUpdate_CreateNFSv3EnabledLocalUser() // invoke the operation string username = "user1"; - StorageAccountLocalUserData data = new StorageAccountLocalUserData() - { - ExtendedGroups = -{ -1001,1005,2005 -}, - IsNfsV3Enabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, username, data); - StorageAccountLocalUserResource result = lro.Value; + bool result = await collection.ExistsAsync(username); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountLocalUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateLocalUser() + public async Task GetIfExists_GetLocalUser() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserUpdate.json - // this example is just showing the usage of "LocalUsers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserGet.json + // this example is just showing the usage of "LocalUsers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -317,28 +312,21 @@ public async Task CreateOrUpdate_UpdateLocalUser() // invoke the operation string username = "user1"; - StorageAccountLocalUserData data = new StorageAccountLocalUserData() - { - HomeDirectory = "homedirectory2", - HasSharedKey = false, - HasSshKey = false, - HasSshPassword = false, - GroupId = 3000, - IsAclAuthorizationAllowed = false, - ExtendedGroups = -{ -1001,1005,2005 -}, - IsNfsV3Enabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, username, data); - StorageAccountLocalUserResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(username); + StorageAccountLocalUserResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountLocalUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountLocalUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountLocalUserResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountLocalUserResource.cs index 987a2b34ebf5d..cc9a25a9052e3 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountLocalUserResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountLocalUserResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetLocalUser() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteLocalUser() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserDelete.json + // this example is just showing the usage of "LocalUsers_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this StorageAccountLocalUserResource created on azure + // for more information of creating StorageAccountLocalUserResource, please refer to the document of StorageAccountLocalUserResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "res6977"; + string accountName = "sto2527"; + string username = "user1"; + ResourceIdentifier storageAccountLocalUserResourceId = StorageAccountLocalUserResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, username); + StorageAccountLocalUserResource storageAccountLocalUser = client.GetStorageAccountLocalUserResource(storageAccountLocalUserResourceId); + + // invoke the operation + await storageAccountLocalUser.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateLocalUser() @@ -69,21 +96,15 @@ public async Task Update_CreateLocalUser() StorageAccountLocalUserResource storageAccountLocalUser = client.GetStorageAccountLocalUserResource(storageAccountLocalUserResourceId); // invoke the operation - StorageAccountLocalUserData data = new StorageAccountLocalUserData() + StorageAccountLocalUserData data = new StorageAccountLocalUserData { - PermissionScopes = -{ -new StoragePermissionScope("rwd","file","share1"),new StoragePermissionScope("rw","file","share2") -}, + PermissionScopes = { new StoragePermissionScope("rwd", "file", "share1"), new StoragePermissionScope("rw", "file", "share2") }, HomeDirectory = "homedirectory", - SshAuthorizedKeys = -{ -new StorageSshPublicKey() + SshAuthorizedKeys = {new StorageSshPublicKey { Description = "key name", Key = "ssh-rsa keykeykeykeykey=", -} -}, +}}, HasSshPassword = true, GroupId = 2000, IsAclAuthorizationAllowed = true, @@ -120,12 +141,9 @@ public async Task Update_CreateNFSv3EnabledLocalUser() StorageAccountLocalUserResource storageAccountLocalUser = client.GetStorageAccountLocalUserResource(storageAccountLocalUserResourceId); // invoke the operation - StorageAccountLocalUserData data = new StorageAccountLocalUserData() + StorageAccountLocalUserData data = new StorageAccountLocalUserData { - ExtendedGroups = -{ -1001,1005,2005 -}, + ExtendedGroups = { 1001, 1005, 2005 }, IsNfsV3Enabled = true, }; ArmOperation lro = await storageAccountLocalUser.UpdateAsync(WaitUntil.Completed, data); @@ -160,7 +178,7 @@ public async Task Update_UpdateLocalUser() StorageAccountLocalUserResource storageAccountLocalUser = client.GetStorageAccountLocalUserResource(storageAccountLocalUserResourceId); // invoke the operation - StorageAccountLocalUserData data = new StorageAccountLocalUserData() + StorageAccountLocalUserData data = new StorageAccountLocalUserData { HomeDirectory = "homedirectory2", HasSharedKey = false, @@ -168,10 +186,7 @@ public async Task Update_UpdateLocalUser() HasSshPassword = false, GroupId = 3000, IsAclAuthorizationAllowed = false, - ExtendedGroups = -{ -1001,1005,2005 -}, + ExtendedGroups = { 1001, 1005, 2005 }, IsNfsV3Enabled = true, }; ArmOperation lro = await storageAccountLocalUser.UpdateAsync(WaitUntil.Completed, data); @@ -184,33 +199,6 @@ public async Task Update_UpdateLocalUser() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteLocalUser() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/LocalUserDelete.json - // this example is just showing the usage of "LocalUsers_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this StorageAccountLocalUserResource created on azure - // for more information of creating StorageAccountLocalUserResource, please refer to the document of StorageAccountLocalUserResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string accountName = "sto2527"; - string username = "user1"; - ResourceIdentifier storageAccountLocalUserResourceId = StorageAccountLocalUserResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, username); - StorageAccountLocalUserResource storageAccountLocalUser = client.GetStorageAccountLocalUserResource(storageAccountLocalUserResourceId); - - // invoke the operation - await storageAccountLocalUser.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetKeys_ListLocalUserKeys() diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountManagementPolicyResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountManagementPolicyResource.cs index 26b1f520c9bdc..9e3aa4f52bbbe 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountManagementPolicyResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountManagementPolicyResource.cs @@ -47,6 +47,33 @@ public async Task Get_StorageAccountGetManagementPolicies() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_StorageAccountDeleteManagementPolicies() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeleteManagementPolicy.json + // this example is just showing the usage of "ManagementPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this StorageAccountManagementPolicyResource created on azure + // for more information of creating StorageAccountManagementPolicyResource, please refer to the document of StorageAccountManagementPolicyResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "res6977"; + string accountName = "sto2527"; + ManagementPolicyName managementPolicyName = ManagementPolicyName.Default; + ResourceIdentifier storageAccountManagementPolicyResourceId = StorageAccountManagementPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, managementPolicyName); + StorageAccountManagementPolicyResource storageAccountManagementPolicy = client.GetStorageAccountManagementPolicyResource(storageAccountManagementPolicyResourceId); + + // invoke the operation + await storageAccountManagementPolicy.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_StorageAccountSetManagementPolicies() @@ -69,84 +96,66 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicies() StorageAccountManagementPolicyResource storageAccountManagementPolicy = client.GetStorageAccountManagementPolicyResource(storageAccountManagementPolicyResourceId); // invoke the operation - StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData() + StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData { - Rules = -{ -new ManagementPolicyRule("olcmtest1",ManagementPolicyRuleType.Lifecycle,new ManagementPolicyDefinition(new ManagementPolicyAction() + Rules = {new ManagementPolicyRule("olcmtest1", ManagementPolicyRuleType.Lifecycle, new ManagementPolicyDefinition(new ManagementPolicyAction { -BaseBlob = new ManagementPolicyBaseBlob() +BaseBlob = new ManagementPolicyBaseBlob { -TierToCool = new DateAfterModification() +TierToCool = new DateAfterModification { DaysAfterModificationGreaterThan = 30, }, -TierToArchive = new DateAfterModification() +TierToArchive = new DateAfterModification { DaysAfterModificationGreaterThan = 90, }, -Delete = new DateAfterModification() +Delete = new DateAfterModification { DaysAfterModificationGreaterThan = 1000, }, }, -Snapshot = new ManagementPolicySnapShot() +Snapshot = new ManagementPolicySnapShot { Delete = new DateAfterCreation(30), }, }) { -Filters = new ManagementPolicyFilter(new string[] -{ -"blockBlob" -}) -{ -PrefixMatch = +Filters = new ManagementPolicyFilter(new string[]{"blockBlob"}) { -"olcmtestcontainer1" -}, +PrefixMatch = {"olcmtestcontainer1"}, }, }) { IsEnabled = true, -},new ManagementPolicyRule("olcmtest2",ManagementPolicyRuleType.Lifecycle,new ManagementPolicyDefinition(new ManagementPolicyAction() +}, new ManagementPolicyRule("olcmtest2", ManagementPolicyRuleType.Lifecycle, new ManagementPolicyDefinition(new ManagementPolicyAction { -BaseBlob = new ManagementPolicyBaseBlob() +BaseBlob = new ManagementPolicyBaseBlob { -TierToCool = new DateAfterModification() +TierToCool = new DateAfterModification { DaysAfterModificationGreaterThan = 30, }, -TierToArchive = new DateAfterModification() +TierToArchive = new DateAfterModification { DaysAfterModificationGreaterThan = 90, }, -Delete = new DateAfterModification() +Delete = new DateAfterModification { DaysAfterModificationGreaterThan = 1000, }, }, }) { -Filters = new ManagementPolicyFilter(new string[] -{ -"blockBlob" -}) -{ -PrefixMatch = -{ -"olcmtestcontainer2" -}, -BlobIndexMatch = +Filters = new ManagementPolicyFilter(new string[]{"blockBlob"}) { -new ManagementPolicyTagFilter("tag1","==","val1"),new ManagementPolicyTagFilter("tag2","==","val2") -}, +PrefixMatch = {"olcmtestcontainer2"}, +BlobIndexMatch = {new ManagementPolicyTagFilter("tag1", "==", "val1"), new ManagementPolicyTagFilter("tag2", "==", "val2")}, }, }) { IsEnabled = true, -} -}, +}}, }; ArmOperation lro = await storageAccountManagementPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); StorageAccountManagementPolicyResource result = lro.Value; @@ -180,58 +189,49 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicyColdTierAction StorageAccountManagementPolicyResource storageAccountManagementPolicy = client.GetStorageAccountManagementPolicyResource(storageAccountManagementPolicyResourceId); // invoke the operation - StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData() + StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData { - Rules = -{ -new ManagementPolicyRule("olcmtest1",ManagementPolicyRuleType.Lifecycle,new ManagementPolicyDefinition(new ManagementPolicyAction() + Rules = {new ManagementPolicyRule("olcmtest1", ManagementPolicyRuleType.Lifecycle, new ManagementPolicyDefinition(new ManagementPolicyAction { -BaseBlob = new ManagementPolicyBaseBlob() +BaseBlob = new ManagementPolicyBaseBlob { -TierToCool = new DateAfterModification() +TierToCool = new DateAfterModification { DaysAfterModificationGreaterThan = 30, }, -TierToArchive = new DateAfterModification() +TierToArchive = new DateAfterModification { DaysAfterModificationGreaterThan = 90, }, -TierToCold = new DateAfterModification() +TierToCold = new DateAfterModification { DaysAfterModificationGreaterThan = 30, }, -Delete = new DateAfterModification() +Delete = new DateAfterModification { DaysAfterModificationGreaterThan = 1000, }, }, -Snapshot = new ManagementPolicySnapShot() +Snapshot = new ManagementPolicySnapShot { TierToCold = new DateAfterCreation(30), Delete = new DateAfterCreation(30), }, -Version = new ManagementPolicyVersion() +Version = new ManagementPolicyVersion { TierToCold = new DateAfterCreation(30), Delete = new DateAfterCreation(30), }, }) { -Filters = new ManagementPolicyFilter(new string[] -{ -"blockBlob" -}) -{ -PrefixMatch = +Filters = new ManagementPolicyFilter(new string[]{"blockBlob"}) { -"olcmtestcontainer1" -}, +PrefixMatch = {"olcmtestcontainer1"}, }, }) { IsEnabled = true, -} -}, +}}, }; ArmOperation lro = await storageAccountManagementPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); StorageAccountManagementPolicyResource result = lro.Value; @@ -265,44 +265,35 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicyForBlockAndApp StorageAccountManagementPolicyResource storageAccountManagementPolicy = client.GetStorageAccountManagementPolicyResource(storageAccountManagementPolicyResourceId); // invoke the operation - StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData() + StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData { - Rules = -{ -new ManagementPolicyRule("olcmtest1",ManagementPolicyRuleType.Lifecycle,new ManagementPolicyDefinition(new ManagementPolicyAction() + Rules = {new ManagementPolicyRule("olcmtest1", ManagementPolicyRuleType.Lifecycle, new ManagementPolicyDefinition(new ManagementPolicyAction { -BaseBlob = new ManagementPolicyBaseBlob() +BaseBlob = new ManagementPolicyBaseBlob { -Delete = new DateAfterModification() +Delete = new DateAfterModification { DaysAfterModificationGreaterThan = 90, }, }, -Snapshot = new ManagementPolicySnapShot() +Snapshot = new ManagementPolicySnapShot { Delete = new DateAfterCreation(90), }, -Version = new ManagementPolicyVersion() +Version = new ManagementPolicyVersion { Delete = new DateAfterCreation(90), }, }) { -Filters = new ManagementPolicyFilter(new string[] -{ -"blockBlob","appendBlob" -}) -{ -PrefixMatch = +Filters = new ManagementPolicyFilter(new string[]{"blockBlob", "appendBlob"}) { -"olcmtestcontainer1" -}, +PrefixMatch = {"olcmtestcontainer1"}, }, }) { IsEnabled = true, -} -}, +}}, }; ArmOperation lro = await storageAccountManagementPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); StorageAccountManagementPolicyResource result = lro.Value; @@ -336,44 +327,35 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicyHotTierActions StorageAccountManagementPolicyResource storageAccountManagementPolicy = client.GetStorageAccountManagementPolicyResource(storageAccountManagementPolicyResourceId); // invoke the operation - StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData() + StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData { - Rules = -{ -new ManagementPolicyRule("olcmtest1",ManagementPolicyRuleType.Lifecycle,new ManagementPolicyDefinition(new ManagementPolicyAction() + Rules = {new ManagementPolicyRule("olcmtest1", ManagementPolicyRuleType.Lifecycle, new ManagementPolicyDefinition(new ManagementPolicyAction { -BaseBlob = new ManagementPolicyBaseBlob() +BaseBlob = new ManagementPolicyBaseBlob { -TierToHot = new DateAfterModification() +TierToHot = new DateAfterModification { DaysAfterModificationGreaterThan = 30, }, }, -Snapshot = new ManagementPolicySnapShot() +Snapshot = new ManagementPolicySnapShot { TierToHot = new DateAfterCreation(30), }, -Version = new ManagementPolicyVersion() +Version = new ManagementPolicyVersion { TierToHot = new DateAfterCreation(30), }, }) { -Filters = new ManagementPolicyFilter(new string[] -{ -"blockBlob" -}) -{ -PrefixMatch = +Filters = new ManagementPolicyFilter(new string[]{"blockBlob"}) { -"olcmtestcontainer1" -}, +PrefixMatch = {"olcmtestcontainer1"}, }, }) { IsEnabled = true, -} -}, +}}, }; ArmOperation lro = await storageAccountManagementPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); StorageAccountManagementPolicyResource result = lro.Value; @@ -407,34 +389,32 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicyWithSnapshotAn StorageAccountManagementPolicyResource storageAccountManagementPolicy = client.GetStorageAccountManagementPolicyResource(storageAccountManagementPolicyResourceId); // invoke the operation - StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData() + StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData { - Rules = -{ -new ManagementPolicyRule("olcmtest1",ManagementPolicyRuleType.Lifecycle,new ManagementPolicyDefinition(new ManagementPolicyAction() + Rules = {new ManagementPolicyRule("olcmtest1", ManagementPolicyRuleType.Lifecycle, new ManagementPolicyDefinition(new ManagementPolicyAction { -BaseBlob = new ManagementPolicyBaseBlob() +BaseBlob = new ManagementPolicyBaseBlob { -TierToCool = new DateAfterModification() +TierToCool = new DateAfterModification { DaysAfterModificationGreaterThan = 30, }, -TierToArchive = new DateAfterModification() +TierToArchive = new DateAfterModification { DaysAfterModificationGreaterThan = 90, }, -Delete = new DateAfterModification() +Delete = new DateAfterModification { DaysAfterModificationGreaterThan = 1000, }, }, -Snapshot = new ManagementPolicySnapShot() +Snapshot = new ManagementPolicySnapShot { TierToCool = new DateAfterCreation(30), TierToArchive = new DateAfterCreation(90), Delete = new DateAfterCreation(1000), }, -Version = new ManagementPolicyVersion() +Version = new ManagementPolicyVersion { TierToCool = new DateAfterCreation(30), TierToArchive = new DateAfterCreation(90), @@ -442,21 +422,14 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicyWithSnapshotAn }, }) { -Filters = new ManagementPolicyFilter(new string[] +Filters = new ManagementPolicyFilter(new string[]{"blockBlob"}) { -"blockBlob" -}) -{ -PrefixMatch = -{ -"olcmtestcontainer1" -}, +PrefixMatch = {"olcmtestcontainer1"}, }, }) { IsEnabled = true, -} -}, +}}, }; ArmOperation lro = await storageAccountManagementPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); StorageAccountManagementPolicyResource result = lro.Value; @@ -490,44 +463,35 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicyBaseBlobDaysAf StorageAccountManagementPolicyResource storageAccountManagementPolicy = client.GetStorageAccountManagementPolicyResource(storageAccountManagementPolicyResourceId); // invoke the operation - StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData() + StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData { - Rules = + Rules = {new ManagementPolicyRule("olcmtest1", ManagementPolicyRuleType.Lifecycle, new ManagementPolicyDefinition(new ManagementPolicyAction { -new ManagementPolicyRule("olcmtest1",ManagementPolicyRuleType.Lifecycle,new ManagementPolicyDefinition(new ManagementPolicyAction() +BaseBlob = new ManagementPolicyBaseBlob { -BaseBlob = new ManagementPolicyBaseBlob() -{ -TierToCool = new DateAfterModification() +TierToCool = new DateAfterModification { DaysAfterCreationGreaterThan = 30, }, -TierToArchive = new DateAfterModification() +TierToArchive = new DateAfterModification { DaysAfterCreationGreaterThan = 90, }, -Delete = new DateAfterModification() +Delete = new DateAfterModification { DaysAfterCreationGreaterThan = 1000, }, }, }) { -Filters = new ManagementPolicyFilter(new string[] +Filters = new ManagementPolicyFilter(new string[]{"blockBlob"}) { -"blockBlob" -}) -{ -PrefixMatch = -{ -"olcmtestcontainer1" -}, +PrefixMatch = {"olcmtestcontainer1"}, }, }) { IsEnabled = true, -} -}, +}}, }; ArmOperation lro = await storageAccountManagementPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); StorageAccountManagementPolicyResource result = lro.Value; @@ -561,49 +525,40 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicyLastAccessTime StorageAccountManagementPolicyResource storageAccountManagementPolicy = client.GetStorageAccountManagementPolicyResource(storageAccountManagementPolicyResourceId); // invoke the operation - StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData() + StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData { - Rules = + Rules = {new ManagementPolicyRule("olcmtest", ManagementPolicyRuleType.Lifecycle, new ManagementPolicyDefinition(new ManagementPolicyAction { -new ManagementPolicyRule("olcmtest",ManagementPolicyRuleType.Lifecycle,new ManagementPolicyDefinition(new ManagementPolicyAction() +BaseBlob = new ManagementPolicyBaseBlob { -BaseBlob = new ManagementPolicyBaseBlob() -{ -TierToCool = new DateAfterModification() +TierToCool = new DateAfterModification { DaysAfterLastAccessTimeGreaterThan = 30, }, -TierToArchive = new DateAfterModification() +TierToArchive = new DateAfterModification { DaysAfterLastAccessTimeGreaterThan = 90, }, -Delete = new DateAfterModification() +Delete = new DateAfterModification { DaysAfterLastAccessTimeGreaterThan = 1000, }, EnableAutoTierToHotFromCool = true, }, -Snapshot = new ManagementPolicySnapShot() +Snapshot = new ManagementPolicySnapShot { Delete = new DateAfterCreation(30), }, }) { -Filters = new ManagementPolicyFilter(new string[] +Filters = new ManagementPolicyFilter(new string[]{"blockBlob"}) { -"blockBlob" -}) -{ -PrefixMatch = -{ -"olcmtestcontainer" -}, +PrefixMatch = {"olcmtestcontainer"}, }, }) { IsEnabled = true, -} -}, +}}, }; ArmOperation lro = await storageAccountManagementPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); StorageAccountManagementPolicyResource result = lro.Value; @@ -637,36 +592,34 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicyLastTierChange StorageAccountManagementPolicyResource storageAccountManagementPolicy = client.GetStorageAccountManagementPolicyResource(storageAccountManagementPolicyResourceId); // invoke the operation - StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData() + StorageAccountManagementPolicyData data = new StorageAccountManagementPolicyData { - Rules = + Rules = {new ManagementPolicyRule("olcmtest", ManagementPolicyRuleType.Lifecycle, new ManagementPolicyDefinition(new ManagementPolicyAction { -new ManagementPolicyRule("olcmtest",ManagementPolicyRuleType.Lifecycle,new ManagementPolicyDefinition(new ManagementPolicyAction() +BaseBlob = new ManagementPolicyBaseBlob { -BaseBlob = new ManagementPolicyBaseBlob() -{ -TierToCool = new DateAfterModification() +TierToCool = new DateAfterModification { DaysAfterModificationGreaterThan = 30, }, -TierToArchive = new DateAfterModification() +TierToArchive = new DateAfterModification { DaysAfterModificationGreaterThan = 90, DaysAfterLastTierChangeGreaterThan = 120, }, -Delete = new DateAfterModification() +Delete = new DateAfterModification { DaysAfterModificationGreaterThan = 1000, }, }, -Snapshot = new ManagementPolicySnapShot() +Snapshot = new ManagementPolicySnapShot { TierToArchive = new DateAfterCreation(30) { DaysAfterLastTierChangeGreaterThan = 90, }, }, -Version = new ManagementPolicyVersion() +Version = new ManagementPolicyVersion { TierToArchive = new DateAfterCreation(30) { @@ -675,21 +628,14 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicyLastTierChange }, }) { -Filters = new ManagementPolicyFilter(new string[] +Filters = new ManagementPolicyFilter(new string[]{"blockBlob"}) { -"blockBlob" -}) -{ -PrefixMatch = -{ -"olcmtestcontainer" -}, +PrefixMatch = {"olcmtestcontainer"}, }, }) { IsEnabled = true, -} -}, +}}, }; ArmOperation lro = await storageAccountManagementPolicy.CreateOrUpdateAsync(WaitUntil.Completed, data); StorageAccountManagementPolicyResource result = lro.Value; @@ -700,32 +646,5 @@ public async Task CreateOrUpdate_StorageAccountSetManagementPolicyLastTierChange // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_StorageAccountDeleteManagementPolicies() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeleteManagementPolicy.json - // this example is just showing the usage of "ManagementPolicies_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this StorageAccountManagementPolicyResource created on azure - // for more information of creating StorageAccountManagementPolicyResource, please refer to the document of StorageAccountManagementPolicyResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string accountName = "sto2527"; - ManagementPolicyName managementPolicyName = ManagementPolicyName.Default; - ResourceIdentifier storageAccountManagementPolicyResourceId = StorageAccountManagementPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, managementPolicyName); - StorageAccountManagementPolicyResource storageAccountManagementPolicy = client.GetStorageAccountManagementPolicyResource(storageAccountManagementPolicyResourceId); - - // invoke the operation - await storageAccountManagementPolicy.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountMigrationCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountMigrationCollection.cs index ff4119c8c0c06..838e79eabab2f 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountMigrationCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountMigrationCollection.cs @@ -52,9 +52,9 @@ public async Task Get_StorageAccountGetMigrationFailed() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGetMigrationFailed() + public async Task Get_StorageAccountGetMigrationInProgress() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetMigrationFailed.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetMigrationInProgress.json // this example is just showing the usage of "StorageAccounts_GetCustomerInitiatedMigration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -75,14 +75,18 @@ public async Task Exists_StorageAccountGetMigrationFailed() // invoke the operation StorageAccountMigrationName migrationName = StorageAccountMigrationName.Default; - bool result = await collection.ExistsAsync(migrationName); + StorageAccountMigrationResource result = await collection.GetAsync(migrationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGetMigrationFailed() + public async Task Exists_StorageAccountGetMigrationFailed() { // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetMigrationFailed.json // this example is just showing the usage of "StorageAccounts_GetCustomerInitiatedMigration" operation, for the dependent resources, they will have to be created separately. @@ -105,26 +109,14 @@ public async Task GetIfExists_StorageAccountGetMigrationFailed() // invoke the operation StorageAccountMigrationName migrationName = StorageAccountMigrationName.Default; - NullableResponse response = await collection.GetIfExistsAsync(migrationName); - StorageAccountMigrationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(migrationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountMigrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageAccountGetMigrationInProgress() + public async Task Exists_StorageAccountGetMigrationInProgress() { // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetMigrationInProgress.json // this example is just showing the usage of "StorageAccounts_GetCustomerInitiatedMigration" operation, for the dependent resources, they will have to be created separately. @@ -147,20 +139,16 @@ public async Task Get_StorageAccountGetMigrationInProgress() // invoke the operation StorageAccountMigrationName migrationName = StorageAccountMigrationName.Default; - StorageAccountMigrationResource result = await collection.GetAsync(migrationName); + bool result = await collection.ExistsAsync(migrationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountMigrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGetMigrationInProgress() + public async Task GetIfExists_StorageAccountGetMigrationFailed() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetMigrationInProgress.json + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetMigrationFailed.json // this example is just showing the usage of "StorageAccounts_GetCustomerInitiatedMigration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -181,9 +169,21 @@ public async Task Exists_StorageAccountGetMigrationInProgress() // invoke the operation StorageAccountMigrationName migrationName = StorageAccountMigrationName.Default; - bool result = await collection.ExistsAsync(migrationName); + NullableResponse response = await collection.GetIfExistsAsync(migrationName); + StorageAccountMigrationResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountMigrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountResource.cs index 7d40cefd154cd..ff4b8d1f53985 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageAccountResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Storage.Models; using NUnit.Framework; @@ -18,57 +17,6 @@ namespace Azure.ResourceManager.Storage.Samples { public partial class Sample_StorageAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckStorageAccountNameAvailability_StorageAccountCheckNameAvailability() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCheckNameAvailability.json - // this example is just showing the usage of "StorageAccounts_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - StorageAccountNameAvailabilityContent content = new StorageAccountNameAvailabilityContent("sto3363"); - StorageAccountNameAvailabilityResult result = await subscriptionResource.CheckStorageAccountNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_StorageAccountDelete() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDelete.json - // this example is just showing the usage of "StorageAccounts_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this StorageAccountResource created on azure - // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource - string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res4228"; - string accountName = "sto2434"; - ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); - - // invoke the operation - await storageAccount.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_StorageAccountGetAsyncSkuConversionStatus() @@ -251,6 +199,32 @@ public async Task Get_StorageAccountGetPropertiesGeoReplicationStatscanFailoverT Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_StorageAccountDelete() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDelete.json + // this example is just showing the usage of "StorageAccounts_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this StorageAccountResource created on azure + // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource + string subscriptionId = "{subscription-id}"; + string resourceGroupName = "res4228"; + string accountName = "sto2434"; + ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); + + // invoke the operation + await storageAccount.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_StorageAccountEnableAD() @@ -272,7 +246,7 @@ public async Task Update_StorageAccountEnableAD() StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // invoke the operation - StorageAccountPatch patch = new StorageAccountPatch() + StorageAccountPatch patch = new StorageAccountPatch { AzureFilesIdentityBasedAuthentication = new FilesIdentityBasedAuthentication(DirectoryServiceOption.AD) { @@ -317,25 +291,25 @@ public async Task Update_StorageAccountEnableCMK() StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // invoke the operation - StorageAccountPatch patch = new StorageAccountPatch() + StorageAccountPatch patch = new StorageAccountPatch { - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, }, KeySource = StorageAccountKeySource.KeyVault, - KeyVaultProperties = new StorageAccountKeyVaultProperties() + KeyVaultProperties = new StorageAccountKeyVaultProperties { KeyName = "wrappingKey", KeyVersion = "", @@ -373,18 +347,18 @@ public async Task Update_StorageAccountUpdate() StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // invoke the operation - StorageAccountPatch patch = new StorageAccountPatch() + StorageAccountPatch patch = new StorageAccountPatch { - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -399,16 +373,13 @@ public async Task Update_StorageAccountUpdate() IsExtendedGroupEnabled = true, NetworkRuleSet = new StorageAccountNetworkRuleSet(StorageNetworkDefaultAction.Allow) { - ResourceAccessRules = -{ -new StorageAccountResourceAccessRule() + ResourceAccessRules = {new StorageAccountResourceAccessRule { TenantId = Guid.Parse("72f988bf-86f1-41af-91ab-2d7cd011db47"), ResourceId = new ResourceIdentifier("/subscriptions/a7e99807-abbf-4642-bdec-2c809a96a8bc/resourceGroups/res9407/providers/Microsoft.Synapse/workspaces/testworkspace"), -} -}, +}}, }, - RoutingPreference = new StorageRoutingPreference() + RoutingPreference = new StorageRoutingPreference { RoutingChoice = StorageRoutingChoice.MicrosoftRouting, IsMicrosoftEndpointsPublished = true, @@ -449,18 +420,18 @@ public async Task Update_StorageAccountUpdateAllowedCopyScopeToAAD() StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // invoke the operation - StorageAccountPatch patch = new StorageAccountPatch() + StorageAccountPatch patch = new StorageAccountPatch { - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -472,16 +443,13 @@ public async Task Update_StorageAccountUpdateAllowedCopyScopeToAAD() KeyExpirationPeriodInDays = 20, NetworkRuleSet = new StorageAccountNetworkRuleSet(StorageNetworkDefaultAction.Allow) { - ResourceAccessRules = -{ -new StorageAccountResourceAccessRule() + ResourceAccessRules = {new StorageAccountResourceAccessRule { TenantId = Guid.Parse("72f988bf-86f1-41af-91ab-2d7cd011db47"), ResourceId = new ResourceIdentifier("/subscriptions/a7e99807-abbf-4642-bdec-2c809a96a8bc/resourceGroups/res9407/providers/Microsoft.Synapse/workspaces/testworkspace"), -} -}, +}}, }, - RoutingPreference = new StorageRoutingPreference() + RoutingPreference = new StorageRoutingPreference { RoutingChoice = StorageRoutingChoice.MicrosoftRouting, IsMicrosoftEndpointsPublished = true, @@ -522,18 +490,18 @@ public async Task Update_StorageAccountUpdateDisablePublicNetworkAccess() StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // invoke the operation - StorageAccountPatch patch = new StorageAccountPatch() + StorageAccountPatch patch = new StorageAccountPatch { - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, @@ -545,16 +513,13 @@ public async Task Update_StorageAccountUpdateDisablePublicNetworkAccess() KeyExpirationPeriodInDays = 20, NetworkRuleSet = new StorageAccountNetworkRuleSet(StorageNetworkDefaultAction.Allow) { - ResourceAccessRules = -{ -new StorageAccountResourceAccessRule() + ResourceAccessRules = {new StorageAccountResourceAccessRule { TenantId = Guid.Parse("72f988bf-86f1-41af-91ab-2d7cd011db47"), ResourceId = new ResourceIdentifier("/subscriptions/a7e99807-abbf-4642-bdec-2c809a96a8bc/resourceGroups/res9407/providers/Microsoft.Synapse/workspaces/testworkspace"), -} -}, +}}, }, - RoutingPreference = new StorageRoutingPreference() + RoutingPreference = new StorageRoutingPreference { RoutingChoice = StorageRoutingChoice.MicrosoftRouting, IsMicrosoftEndpointsPublished = true, @@ -595,40 +560,40 @@ public async Task Update_StorageAccountUpdateUserAssignedEncryptionIdentityWithC StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // invoke the operation - StorageAccountPatch patch = new StorageAccountPatch() + StorageAccountPatch patch = new StorageAccountPatch { Sku = new StorageSku(StorageSkuName.StandardLrs), Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}")] = new UserAssignedIdentity() }, }, Kind = StorageKind.Storage, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, }, KeySource = StorageAccountKeySource.KeyVault, - KeyVaultProperties = new StorageAccountKeyVaultProperties() + KeyVaultProperties = new StorageAccountKeyVaultProperties { KeyName = "wrappingKey", KeyVersion = "", KeyVaultUri = new Uri("https://myvault8569.vault.azure.net"), }, - EncryptionIdentity = new StorageAccountEncryptionIdentity() + EncryptionIdentity = new StorageAccountEncryptionIdentity { EncryptionUserAssignedIdentity = "/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}", }, @@ -664,40 +629,40 @@ public async Task Update_StorageAccountUpdateUserAssignedIdentityWithFederatedId StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // invoke the operation - StorageAccountPatch patch = new StorageAccountPatch() + StorageAccountPatch patch = new StorageAccountPatch { Sku = new StorageSku(StorageSkuName.StandardLrs), Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}")] = new UserAssignedIdentity() }, }, Kind = StorageKind.Storage, - Encryption = new StorageAccountEncryption() + Encryption = new StorageAccountEncryption { - Services = new StorageAccountEncryptionServices() + Services = new StorageAccountEncryptionServices { - Blob = new StorageEncryptionService() + Blob = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, - File = new StorageEncryptionService() + File = new StorageEncryptionService { IsEnabled = true, KeyType = StorageEncryptionKeyType.Account, }, }, KeySource = StorageAccountKeySource.KeyVault, - KeyVaultProperties = new StorageAccountKeyVaultProperties() + KeyVaultProperties = new StorageAccountKeyVaultProperties { KeyName = "wrappingKey", KeyVersion = "", KeyVaultUri = new Uri("https://myvault8569.vault.azure.net"), }, - EncryptionIdentity = new StorageAccountEncryptionIdentity() + EncryptionIdentity = new StorageAccountEncryptionIdentity { EncryptionUserAssignedIdentity = "/subscriptions/{subscription-id}/resourceGroups/res9101/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{managed-identity-name}", EncryptionFederatedIdentityClientId = "3109d1c4-a5de-4d84-8832-feabb916a4b6", @@ -734,12 +699,12 @@ public async Task Update_StorageAccountUpdateWithImmutabilityPolicy() StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // invoke the operation - StorageAccountPatch patch = new StorageAccountPatch() + StorageAccountPatch patch = new StorageAccountPatch { - ImmutableStorageWithVersioning = new ImmutableStorageAccount() + ImmutableStorageWithVersioning = new ImmutableStorageAccount { IsEnabled = true, - ImmutabilityPolicy = new AccountImmutabilityPolicy() + ImmutabilityPolicy = new AccountImmutabilityPolicy { ImmutabilityPeriodSinceCreationInDays = 15, State = AccountImmutabilityPolicyState.Locked, @@ -756,37 +721,6 @@ public async Task Update_StorageAccountUpdateWithImmutabilityPolicy() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetStorageAccounts_StorageAccountList() - { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountList.json - // this example is just showing the usage of "StorageAccounts_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "{subscription-id}"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (StorageAccountResource item in subscriptionResource.GetStorageAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetKeys_StorageAccountListKeys() @@ -1094,9 +1028,10 @@ public async Task RestoreBlobRanges_BlobRangesRestore() StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // invoke the operation - BlobRestoreContent content = new BlobRestoreContent(DateTimeOffset.Parse("placeholder"), new BlobRestoreRange[] + BlobRestoreContent content = new BlobRestoreContent(default, new BlobRestoreRange[] { -new BlobRestoreRange("container/blobpath1","container/blobpath2"),new BlobRestoreRange("container2/blobpath3","") +new BlobRestoreRange("container/blobpath1", "container/blobpath2"), +new BlobRestoreRange("container2/blobpath3", "") }); ArmOperation lro = await storageAccount.RestoreBlobRangesAsync(WaitUntil.Completed, content); BlobRestoreStatus result = lro.Value; diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StoragePrivateEndpointConnectionCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StoragePrivateEndpointConnectionCollection.cs index c16e401f7e4c8..46cb9cb650561 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StoragePrivateEndpointConnectionCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StoragePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StoragePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StorageAccountListPrivateEndpointConnections() + public async Task CreateOrUpdate_StorageAccountPutPrivateEndpointConnection() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListPrivateEndpointConnections.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountPutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,25 +31,32 @@ public async Task GetAll_StorageAccountListPrivateEndpointConnections() // this example assumes you already have this StorageAccountResource created on azure // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string accountName = "sto2527"; + string resourceGroupName = "res7687"; + string accountName = "sto9699"; ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); // get the collection of this StoragePrivateEndpointConnectionResource StoragePrivateEndpointConnectionCollection collection = storageAccount.GetStoragePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (StoragePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "{privateEndpointConnectionName}"; + StoragePrivateEndpointConnectionData data = new StoragePrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StoragePrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new StoragePrivateLinkServiceConnectionState + { + Status = StoragePrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + StoragePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StoragePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_StorageAccountGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGetPrivateEndpointConnection() + public async Task GetAll_StorageAccountListPrivateEndpointConnections() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountListPrivateEndpointConnections.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_StorageAccountGetPrivateEndpointConnection() // get the collection of this StoragePrivateEndpointConnectionResource StoragePrivateEndpointConnectionCollection collection = storageAccount.GetStoragePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (StoragePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StoragePrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGetPrivateEndpointConnection() + public async Task Exists_StorageAccountGetPrivateEndpointConnection() { // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_StorageAccountGetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - StoragePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StoragePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StorageAccountPutPrivateEndpointConnection() + public async Task GetIfExists_StorageAccountGetPrivateEndpointConnection() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountPutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountGetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,8 +174,8 @@ public async Task CreateOrUpdate_StorageAccountPutPrivateEndpointConnection() // this example assumes you already have this StorageAccountResource created on azure // for more information of creating StorageAccountResource, please refer to the document of StorageAccountResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; - string accountName = "sto9699"; + string resourceGroupName = "res6977"; + string accountName = "sto2527"; ResourceIdentifier storageAccountResourceId = StorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); StorageAccountResource storageAccount = client.GetStorageAccountResource(storageAccountResourceId); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_StorageAccountPutPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - StoragePrivateEndpointConnectionData data = new StoragePrivateEndpointConnectionData() - { - ConnectionState = new StoragePrivateLinkServiceConnectionState() - { - Status = StoragePrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - StoragePrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + StoragePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StoragePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StoragePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StoragePrivateEndpointConnectionResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StoragePrivateEndpointConnectionResource.cs index d50df750f569c..2f3f8fe1d7419 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StoragePrivateEndpointConnectionResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StoragePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_StorageAccountGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_StorageAccountPutPrivateEndpointConnection() + public async Task Delete_StorageAccountDeletePrivateEndpointConnection() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountPutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,37 +62,24 @@ public async Task Update_StorageAccountPutPrivateEndpointConnection() // this example assumes you already have this StoragePrivateEndpointConnectionResource created on azure // for more information of creating StoragePrivateEndpointConnectionResource, please refer to the document of StoragePrivateEndpointConnectionResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; - string accountName = "sto9699"; + string resourceGroupName = "res6977"; + string accountName = "sto2527"; string privateEndpointConnectionName = "{privateEndpointConnectionName}"; ResourceIdentifier storagePrivateEndpointConnectionResourceId = StoragePrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, privateEndpointConnectionName); StoragePrivateEndpointConnectionResource storagePrivateEndpointConnection = client.GetStoragePrivateEndpointConnectionResource(storagePrivateEndpointConnectionResourceId); // invoke the operation - StoragePrivateEndpointConnectionData data = new StoragePrivateEndpointConnectionData() - { - ConnectionState = new StoragePrivateLinkServiceConnectionState() - { - Status = StoragePrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await storagePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - StoragePrivateEndpointConnectionResource result = lro.Value; + await storagePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StoragePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_StorageAccountDeletePrivateEndpointConnection() + public async Task Update_StorageAccountPutPrivateEndpointConnection() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountDeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountPutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,16 +89,29 @@ public async Task Delete_StorageAccountDeletePrivateEndpointConnection() // this example assumes you already have this StoragePrivateEndpointConnectionResource created on azure // for more information of creating StoragePrivateEndpointConnectionResource, please refer to the document of StoragePrivateEndpointConnectionResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string accountName = "sto2527"; + string resourceGroupName = "res7687"; + string accountName = "sto9699"; string privateEndpointConnectionName = "{privateEndpointConnectionName}"; ResourceIdentifier storagePrivateEndpointConnectionResourceId = StoragePrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, privateEndpointConnectionName); StoragePrivateEndpointConnectionResource storagePrivateEndpointConnection = client.GetStoragePrivateEndpointConnectionResource(storagePrivateEndpointConnectionResourceId); // invoke the operation - await storagePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + StoragePrivateEndpointConnectionData data = new StoragePrivateEndpointConnectionData + { + ConnectionState = new StoragePrivateLinkServiceConnectionState + { + Status = StoragePrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await storagePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + StoragePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StoragePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageQueueCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageQueueCollection.cs index 137d4bbf3b4f0..8ad7a0c4c25f8 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageQueueCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageQueueCollection.cs @@ -76,12 +76,12 @@ public async Task CreateOrUpdate_QueueOperationPutWithMetadata() // invoke the operation string queueName = "queue6185"; - StorageQueueData data = new StorageQueueData() + StorageQueueData data = new StorageQueueData { Metadata = { ["sample1"] = "meta1", -["sample2"] = "meta2", +["sample2"] = "meta2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, queueName, data); @@ -130,10 +130,10 @@ public async Task Get_QueueOperationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QueueOperationGet() + public async Task GetAll_QueueOperationList() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationGet.json - // this example is just showing the usage of "Queue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationList.json + // this example is just showing the usage of "Queue_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,7 +143,7 @@ public async Task Exists_QueueOperationGet() // this example assumes you already have this QueueServiceResource created on azure // for more information of creating QueueServiceResource, please refer to the document of QueueServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res3376"; + string resourceGroupName = "res9290"; string accountName = "sto328"; ResourceIdentifier queueServiceResourceId = QueueServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); QueueServiceResource queueService = client.GetQueueServiceResource(queueServiceResourceId); @@ -151,16 +151,22 @@ public async Task Exists_QueueOperationGet() // get the collection of this StorageQueueResource StorageQueueCollection collection = queueService.GetStorageQueues(); - // invoke the operation - string queueName = "queue6185"; - bool result = await collection.ExistsAsync(queueName); + // invoke the operation and iterate over the result + await foreach (StorageQueueResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageQueueData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QueueOperationGet() + public async Task Exists_QueueOperationGet() { // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationGet.json // this example is just showing the usage of "Queue_Get" operation, for the dependent resources, they will have to be created separately. @@ -183,29 +189,17 @@ public async Task GetIfExists_QueueOperationGet() // invoke the operation string queueName = "queue6185"; - NullableResponse response = await collection.GetIfExistsAsync(queueName); - StorageQueueResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(queueName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageQueueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QueueOperationList() + public async Task GetIfExists_QueueOperationGet() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationList.json - // this example is just showing the usage of "Queue_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationGet.json + // this example is just showing the usage of "Queue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -215,7 +209,7 @@ public async Task GetAll_QueueOperationList() // this example assumes you already have this QueueServiceResource created on azure // for more information of creating QueueServiceResource, please refer to the document of QueueServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9290"; + string resourceGroupName = "res3376"; string accountName = "sto328"; ResourceIdentifier queueServiceResourceId = QueueServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); QueueServiceResource queueService = client.GetQueueServiceResource(queueServiceResourceId); @@ -223,17 +217,23 @@ public async Task GetAll_QueueOperationList() // get the collection of this StorageQueueResource StorageQueueCollection collection = queueService.GetStorageQueues(); - // invoke the operation and iterate over the result - await foreach (StorageQueueResource item in collection.GetAllAsync()) + // invoke the operation + string queueName = "queue6185"; + NullableResponse response = await collection.GetIfExistsAsync(queueName); + StorageQueueResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageQueueData resourceData = item.Data; + StorageQueueData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageQueueResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageQueueResource.cs index 0d9b48de78c7e..ba6e3a4e4d6e5 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageQueueResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageQueueResource.cs @@ -17,10 +17,10 @@ public partial class Sample_StorageQueueResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_QueueOperationPatch() + public async Task Get_QueueOperationGet() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationPatch.json - // this example is just showing the usage of "Queue_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationGet.json + // this example is just showing the usage of "Queue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,8 +37,7 @@ public async Task Update_QueueOperationPatch() StorageQueueResource storageQueue = client.GetStorageQueueResource(storageQueueResourceId); // invoke the operation - StorageQueueData data = new StorageQueueData(); - StorageQueueResource result = await storageQueue.UpdateAsync(data); + StorageQueueResource result = await storageQueue.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,10 +48,10 @@ public async Task Update_QueueOperationPatch() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QueueOperationGet() + public async Task Delete_QueueOperationDelete() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationGet.json - // this example is just showing the usage of "Queue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationDelete.json + // this example is just showing the usage of "Queue_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,21 +68,17 @@ public async Task Get_QueueOperationGet() StorageQueueResource storageQueue = client.GetStorageQueueResource(storageQueueResourceId); // invoke the operation - StorageQueueResource result = await storageQueue.GetAsync(); + await storageQueue.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageQueueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_QueueOperationDelete() + public async Task Update_QueueOperationPatch() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationDelete.json - // this example is just showing the usage of "Queue_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/QueueOperationPatch.json + // this example is just showing the usage of "Queue_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,9 +95,14 @@ public async Task Delete_QueueOperationDelete() StorageQueueResource storageQueue = client.GetStorageQueueResource(storageQueueResourceId); // invoke the operation - await storageQueue.DeleteAsync(WaitUntil.Completed); + StorageQueueData data = new StorageQueueData(); + StorageQueueResource result = await storageQueue.UpdateAsync(data); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageQueueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageTaskAssignmentCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageTaskAssignmentCollection.cs index e5523833f5c6d..8e63ae6b77490 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageTaskAssignmentCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageTaskAssignmentCollection.cs @@ -41,20 +41,15 @@ public async Task CreateOrUpdate_PutStorageTaskAssignment() // invoke the operation string storageTaskAssignmentName = "myassignment1"; - StorageTaskAssignmentData data = new StorageTaskAssignmentData(new StorageTaskAssignmentProperties(new ResourceIdentifier("/subscriptions/1f31ba14-ce16-4281-b9b4-3e78da6e1616/resourceGroups/res4228/providers/Microsoft.StorageActions/storageTasks/mytask1"), true, "My Storage task assignment", new StorageTaskAssignmentExecutionContext(new ExecutionTrigger(ExecutionTriggerType.RunOnce, new ExecutionTriggerParameters() + StorageTaskAssignmentData data = new StorageTaskAssignmentData(new StorageTaskAssignmentProperties(new ResourceIdentifier("/subscriptions/1f31ba14-ce16-4281-b9b4-3e78da6e1616/resourceGroups/res4228/providers/Microsoft.StorageActions/storageTasks/mytask1"), true, "My Storage task assignment", new StorageTaskAssignmentExecutionContext(new ExecutionTrigger(ExecutionTriggerType.RunOnce, new ExecutionTriggerParameters { StartOn = DateTimeOffset.Parse("2022-11-15T21:52:47.8145095Z"), })) { - Target = new ExecutionTarget() + Target = new ExecutionTarget { - Prefix = -{ -"prefix1","prefix2" -}, - ExcludePrefix = -{ -}, + Prefix = { "prefix1", "prefix2" }, + ExcludePrefix = { }, }, }, new StorageTaskAssignmentReport("container1"))); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageTaskAssignmentName, data); @@ -92,7 +87,7 @@ public async Task CreateOrUpdate_PutStorageTaskAssignmentRequiredProperties() // invoke the operation string storageTaskAssignmentName = "myassignment1"; - StorageTaskAssignmentData data = new StorageTaskAssignmentData(new StorageTaskAssignmentProperties(new ResourceIdentifier("/subscriptions/1f31ba14-ce16-4281-b9b4-3e78da6e1616/resourceGroups/res4228/providers/Microsoft.StorageActions/storageTasks/mytask1"), true, "My Storage task assignment", new StorageTaskAssignmentExecutionContext(new ExecutionTrigger(ExecutionTriggerType.RunOnce, new ExecutionTriggerParameters() + StorageTaskAssignmentData data = new StorageTaskAssignmentData(new StorageTaskAssignmentProperties(new ResourceIdentifier("/subscriptions/1f31ba14-ce16-4281-b9b4-3e78da6e1616/resourceGroups/res4228/providers/Microsoft.StorageActions/storageTasks/mytask1"), true, "My Storage task assignment", new StorageTaskAssignmentExecutionContext(new ExecutionTrigger(ExecutionTriggerType.RunOnce, new ExecutionTriggerParameters { StartOn = DateTimeOffset.Parse("2022-11-15T21:52:47.8145095Z"), })), new StorageTaskAssignmentReport("container1"))); @@ -142,10 +137,10 @@ public async Task Get_GetStorageTaskAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetStorageTaskAssignment() + public async Task GetAll_ListStorageTaskAssignmentsForAccount() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/GetStorageTaskAssignment.json - // this example is just showing the usage of "StorageTaskAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsList/ListStorageTaskAssignmentsForAccount.json + // this example is just showing the usage of "StorageTaskAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -163,16 +158,22 @@ public async Task Exists_GetStorageTaskAssignment() // get the collection of this StorageTaskAssignmentResource StorageTaskAssignmentCollection collection = storageAccount.GetStorageTaskAssignments(); - // invoke the operation - string storageTaskAssignmentName = "myassignment1"; - bool result = await collection.ExistsAsync(storageTaskAssignmentName); + // invoke the operation and iterate over the result + await foreach (StorageTaskAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTaskAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetStorageTaskAssignment() + public async Task Exists_GetStorageTaskAssignment() { // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/GetStorageTaskAssignment.json // this example is just showing the usage of "StorageTaskAssignments_Get" operation, for the dependent resources, they will have to be created separately. @@ -195,29 +196,17 @@ public async Task GetIfExists_GetStorageTaskAssignment() // invoke the operation string storageTaskAssignmentName = "myassignment1"; - NullableResponse response = await collection.GetIfExistsAsync(storageTaskAssignmentName); - StorageTaskAssignmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(storageTaskAssignmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTaskAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListStorageTaskAssignmentsForAccount() + public async Task GetIfExists_GetStorageTaskAssignment() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsList/ListStorageTaskAssignmentsForAccount.json - // this example is just showing the usage of "StorageTaskAssignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/GetStorageTaskAssignment.json + // this example is just showing the usage of "StorageTaskAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -235,17 +224,23 @@ public async Task GetAll_ListStorageTaskAssignmentsForAccount() // get the collection of this StorageTaskAssignmentResource StorageTaskAssignmentCollection collection = storageAccount.GetStorageTaskAssignments(); - // invoke the operation and iterate over the result - await foreach (StorageTaskAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string storageTaskAssignmentName = "myassignment1"; + NullableResponse response = await collection.GetIfExistsAsync(storageTaskAssignmentName); + StorageTaskAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageTaskAssignmentData resourceData = item.Data; + StorageTaskAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageTaskAssignmentResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageTaskAssignmentResource.cs index 577ee6f049da9..b9bb8bba4789e 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageTaskAssignmentResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_StorageTaskAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageTaskAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchStorageTaskAssignment() + public async Task Get_GetStorageTaskAssignment() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/PatchStorageTaskAssignment.json - // this example is just showing the usage of "StorageTaskAssignments_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/GetStorageTaskAssignment.json + // this example is just showing the usage of "StorageTaskAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,38 +38,7 @@ public async Task Update_PatchStorageTaskAssignment() StorageTaskAssignmentResource storageTaskAssignment = client.GetStorageTaskAssignmentResource(storageTaskAssignmentResourceId); // invoke the operation - StorageTaskAssignmentPatch patch = new StorageTaskAssignmentPatch() - { - Properties = new StorageTaskAssignmentPatchProperties() - { - IsEnabled = true, - Description = "My Storage task assignment", - ExecutionContext = new StorageTaskAssignmentUpdateExecutionContext() - { - Target = new ExecutionTarget() - { - Prefix = -{ -"prefix1","prefix2" -}, - ExcludePrefix = -{ -}, - }, - Trigger = new ExecutionTriggerUpdate() - { - TriggerType = ExecutionTriggerType.RunOnce, - Parameters = new ExecutionTriggerParametersUpdate() - { - StartOn = DateTimeOffset.Parse("2022-11-15T21:52:47.8145095Z"), - }, - }, - }, - ReportPrefix = "container1", - }, - }; - ArmOperation lro = await storageTaskAssignment.UpdateAsync(WaitUntil.Completed, patch); - StorageTaskAssignmentResource result = lro.Value; + StorageTaskAssignmentResource result = await storageTaskAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -80,10 +49,10 @@ public async Task Update_PatchStorageTaskAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetStorageTaskAssignment() + public async Task Delete_DeleteStorageTaskAssignment() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/GetStorageTaskAssignment.json - // this example is just showing the usage of "StorageTaskAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/DeleteStorageTaskAssignment.json + // this example is just showing the usage of "StorageTaskAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,21 +69,17 @@ public async Task Get_GetStorageTaskAssignment() StorageTaskAssignmentResource storageTaskAssignment = client.GetStorageTaskAssignmentResource(storageTaskAssignmentResourceId); // invoke the operation - StorageTaskAssignmentResource result = await storageTaskAssignment.GetAsync(); + await storageTaskAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTaskAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteStorageTaskAssignment() + public async Task Update_PatchStorageTaskAssignment() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/DeleteStorageTaskAssignment.json - // this example is just showing the usage of "StorageTaskAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/storageTaskAssignmentsCrud/PatchStorageTaskAssignment.json + // this example is just showing the usage of "StorageTaskAssignments_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,9 +96,39 @@ public async Task Delete_DeleteStorageTaskAssignment() StorageTaskAssignmentResource storageTaskAssignment = client.GetStorageTaskAssignmentResource(storageTaskAssignmentResourceId); // invoke the operation - await storageTaskAssignment.DeleteAsync(WaitUntil.Completed); + StorageTaskAssignmentPatch patch = new StorageTaskAssignmentPatch + { + Properties = new StorageTaskAssignmentPatchProperties + { + IsEnabled = true, + Description = "My Storage task assignment", + ExecutionContext = new StorageTaskAssignmentUpdateExecutionContext + { + Target = new ExecutionTarget + { + Prefix = { "prefix1", "prefix2" }, + ExcludePrefix = { }, + }, + Trigger = new ExecutionTriggerUpdate + { + TriggerType = ExecutionTriggerType.RunOnce, + Parameters = new ExecutionTriggerParametersUpdate + { + StartOn = DateTimeOffset.Parse("2022-11-15T21:52:47.8145095Z"), + }, + }, + }, + ReportPrefix = "container1", + }, + }; + ArmOperation lro = await storageTaskAssignment.UpdateAsync(WaitUntil.Completed, patch); + StorageTaskAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTaskAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index c0363615e328f..de2d05ec52e67 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -44,6 +44,93 @@ public async Task GetSkus_SkuList() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckStorageAccountNameAvailability_StorageAccountCheckNameAvailability() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountCheckNameAvailability.json + // this example is just showing the usage of "StorageAccounts_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + StorageAccountNameAvailabilityContent content = new StorageAccountNameAvailabilityContent("sto3363"); + StorageAccountNameAvailabilityResult result = await subscriptionResource.CheckStorageAccountNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStorageAccounts_StorageAccountList() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/StorageAccountList.json + // this example is just showing the usage of "StorageAccounts_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (StorageAccountResource item in subscriptionResource.GetStorageAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDeletedAccounts_DeletedAccountList() + { + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/DeletedAccountList.json + // this example is just showing the usage of "DeletedAccounts_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "{subscription-id}"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DeletedAccountResource item in subscriptionResource.GetDeletedAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeletedAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetUsagesByLocation_UsageList() diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableCollection.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableCollection.cs index 41bf170bec4db..c003bbc3e1186 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableCollection.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableCollection.cs @@ -77,26 +77,23 @@ public async Task CreateOrUpdate_TableOperationPutOrPatchAcls() // invoke the operation string tableName = "table6185"; - TableData data = new TableData() + TableData data = new TableData { - SignedIdentifiers = -{ -new StorageTableSignedIdentifier("MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI") + SignedIdentifiers = {new StorageTableSignedIdentifier("MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI") { AccessPolicy = new StorageTableAccessPolicy("raud") { StartOn = DateTimeOffset.Parse("2022-03-17T08:49:37.0000000Z"), ExpireOn = DateTimeOffset.Parse("2022-03-20T08:49:37.0000000Z"), }, -},new StorageTableSignedIdentifier("PTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODklMTI") +}, new StorageTableSignedIdentifier("PTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODklMTI") { AccessPolicy = new StorageTableAccessPolicy("rad") { StartOn = DateTimeOffset.Parse("2022-03-17T08:49:37.0000000Z"), ExpireOn = DateTimeOffset.Parse("2022-03-20T08:49:37.0000000Z"), }, -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tableName, data); TableResource result = lro.Value; @@ -144,10 +141,10 @@ public async Task Get_TableOperationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TableOperationGet() + public async Task GetAll_TableOperationList() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationGet.json - // this example is just showing the usage of "Table_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationList.json + // this example is just showing the usage of "Table_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -157,7 +154,7 @@ public async Task Exists_TableOperationGet() // this example assumes you already have this TableServiceResource created on azure // for more information of creating TableServiceResource, please refer to the document of TableServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res3376"; + string resourceGroupName = "res9290"; string accountName = "sto328"; ResourceIdentifier tableServiceResourceId = TableServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); TableServiceResource tableService = client.GetTableServiceResource(tableServiceResourceId); @@ -165,16 +162,22 @@ public async Task Exists_TableOperationGet() // get the collection of this TableResource TableCollection collection = tableService.GetTables(); - // invoke the operation - string tableName = "table6185"; - bool result = await collection.ExistsAsync(tableName); + // invoke the operation and iterate over the result + await foreach (TableResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TableOperationGet() + public async Task Exists_TableOperationGet() { // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationGet.json // this example is just showing the usage of "Table_Get" operation, for the dependent resources, they will have to be created separately. @@ -197,29 +200,17 @@ public async Task GetIfExists_TableOperationGet() // invoke the operation string tableName = "table6185"; - NullableResponse response = await collection.GetIfExistsAsync(tableName); - TableResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tableName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TableOperationList() + public async Task GetIfExists_TableOperationGet() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationList.json - // this example is just showing the usage of "Table_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationGet.json + // this example is just showing the usage of "Table_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -229,7 +220,7 @@ public async Task GetAll_TableOperationList() // this example assumes you already have this TableServiceResource created on azure // for more information of creating TableServiceResource, please refer to the document of TableServiceResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res9290"; + string resourceGroupName = "res3376"; string accountName = "sto328"; ResourceIdentifier tableServiceResourceId = TableServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); TableServiceResource tableService = client.GetTableServiceResource(tableServiceResourceId); @@ -237,17 +228,23 @@ public async Task GetAll_TableOperationList() // get the collection of this TableResource TableCollection collection = tableService.GetTables(); - // invoke the operation and iterate over the result - await foreach (TableResource item in collection.GetAllAsync()) + // invoke the operation + string tableName = "table6185"; + NullableResponse response = await collection.GetIfExistsAsync(tableName); + TableResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - TableData resourceData = item.Data; + TableData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableResource.cs index b140a57035e15..fbf130b01b1da 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableResource.cs @@ -18,10 +18,10 @@ public partial class Sample_TableResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TableOperationPatch() + public async Task Get_TableOperationGet() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationPatch.json - // this example is just showing the usage of "Table_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationGet.json + // this example is just showing the usage of "Table_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,8 +38,7 @@ public async Task Update_TableOperationPatch() TableResource table = client.GetTableResource(tableResourceId); // invoke the operation - TableData data = new TableData(); - TableResource result = await table.UpdateAsync(data); + TableResource result = await table.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,10 +49,10 @@ public async Task Update_TableOperationPatch() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TableOperationPutOrPatchAcls() + public async Task Delete_TableOperationDelete() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationPutOrPatchAcls.json - // this example is just showing the usage of "Table_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationDelete.json + // this example is just showing the usage of "Table_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,42 +69,17 @@ public async Task Update_TableOperationPutOrPatchAcls() TableResource table = client.GetTableResource(tableResourceId); // invoke the operation - TableData data = new TableData() - { - SignedIdentifiers = -{ -new StorageTableSignedIdentifier("MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI") -{ -AccessPolicy = new StorageTableAccessPolicy("raud") -{ -StartOn = DateTimeOffset.Parse("2022-03-17T08:49:37.0000000Z"), -ExpireOn = DateTimeOffset.Parse("2022-03-20T08:49:37.0000000Z"), -}, -},new StorageTableSignedIdentifier("PTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODklMTI") -{ -AccessPolicy = new StorageTableAccessPolicy("rad") -{ -StartOn = DateTimeOffset.Parse("2022-03-17T08:49:37.0000000Z"), -ExpireOn = DateTimeOffset.Parse("2022-03-20T08:49:37.0000000Z"), -}, -} -}, - }; - TableResource result = await table.UpdateAsync(data); + await table.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TableOperationGet() + public async Task Update_TableOperationPatch() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationGet.json - // this example is just showing the usage of "Table_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationPatch.json + // this example is just showing the usage of "Table_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,7 +96,8 @@ public async Task Get_TableOperationGet() TableResource table = client.GetTableResource(tableResourceId); // invoke the operation - TableResource result = await table.GetAsync(); + TableData data = new TableData(); + TableResource result = await table.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -133,10 +108,10 @@ public async Task Get_TableOperationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_TableOperationDelete() + public async Task Update_TableOperationPutOrPatchAcls() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationDelete.json - // this example is just showing the usage of "Table_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableOperationPutOrPatchAcls.json + // this example is just showing the usage of "Table_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -153,9 +128,31 @@ public async Task Delete_TableOperationDelete() TableResource table = client.GetTableResource(tableResourceId); // invoke the operation - await table.DeleteAsync(WaitUntil.Completed); + TableData data = new TableData + { + SignedIdentifiers = {new StorageTableSignedIdentifier("MTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkwMTI") +{ +AccessPolicy = new StorageTableAccessPolicy("raud") +{ +StartOn = DateTimeOffset.Parse("2022-03-17T08:49:37.0000000Z"), +ExpireOn = DateTimeOffset.Parse("2022-03-20T08:49:37.0000000Z"), +}, +}, new StorageTableSignedIdentifier("PTIzNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODklMTI") +{ +AccessPolicy = new StorageTableAccessPolicy("rad") +{ +StartOn = DateTimeOffset.Parse("2022-03-17T08:49:37.0000000Z"), +ExpireOn = DateTimeOffset.Parse("2022-03-20T08:49:37.0000000Z"), +}, +}}, + }; + TableResource result = await table.UpdateAsync(data); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableServiceResource.cs b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableServiceResource.cs index cb2210765d77c..8b13fb4fb4991 100644 --- a/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableServiceResource.cs +++ b/sdk/storage/Azure.ResourceManager.Storage/samples/Generated/Samples/Sample_TableServiceResource.cs @@ -18,10 +18,10 @@ public partial class Sample_TableServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TableServicesPut() + public async Task Get_TableServicesGet() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableServicesPut.json - // this example is just showing the usage of "TableServices_SetServiceProperties" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableServicesGet.json + // this example is just showing the usage of "TableServices_GetServiceProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,51 +37,7 @@ public async Task CreateOrUpdate_TableServicesPut() TableServiceResource tableService = client.GetTableServiceResource(tableServiceResourceId); // invoke the operation - TableServiceData data = new TableServiceData() - { - CorsRules = -{ -new StorageCorsRule(new string[] -{ -"http://www.contoso.com","http://www.fabrikam.com" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get,CorsRuleAllowedMethod.Head,CorsRuleAllowedMethod.Post,CorsRuleAllowedMethod.Options,CorsRuleAllowedMethod.Merge,CorsRuleAllowedMethod.Put -},100,new string[] -{ -"x-ms-meta-*" -},new string[] -{ -"x-ms-meta-abc","x-ms-meta-data*","x-ms-meta-target*" -}),new StorageCorsRule(new string[] -{ -"*" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get -},2,new string[] -{ -"*" -},new string[] -{ -"*" -}),new StorageCorsRule(new string[] -{ -"http://www.abc23.com","https://www.fabrikam.com/*" -},new CorsRuleAllowedMethod[] -{ -CorsRuleAllowedMethod.Get,CorsRuleAllowedMethod.Put -},2000,new string[] -{ -"x-ms-meta-abc","x-ms-meta-data*","x-ms-meta-target*" -},new string[] -{ -"x-ms-meta-12345675754564*" -}) -}, - }; - ArmOperation lro = await tableService.CreateOrUpdateAsync(WaitUntil.Completed, data); - TableServiceResource result = lro.Value; + TableServiceResource result = await tableService.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +48,10 @@ public async Task CreateOrUpdate_TableServicesPut() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TableServicesGet() + public async Task CreateOrUpdate_TableServicesPut() { - // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableServicesGet.json - // this example is just showing the usage of "TableServices_GetServiceProperties" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storage/resource-manager/Microsoft.Storage/stable/2023-05-01/examples/TableServicesPut.json + // this example is just showing the usage of "TableServices_SetServiceProperties" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,7 +67,12 @@ public async Task Get_TableServicesGet() TableServiceResource tableService = client.GetTableServiceResource(tableServiceResourceId); // invoke the operation - TableServiceResource result = await tableService.GetAsync(); + TableServiceData data = new TableServiceData + { + CorsRules = { new StorageCorsRule(new string[] { "http://www.contoso.com", "http://www.fabrikam.com" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get, CorsRuleAllowedMethod.Head, CorsRuleAllowedMethod.Post, CorsRuleAllowedMethod.Options, CorsRuleAllowedMethod.Merge, CorsRuleAllowedMethod.Put }, 100, new string[] { "x-ms-meta-*" }, new string[] { "x-ms-meta-abc", "x-ms-meta-data*", "x-ms-meta-target*" }), new StorageCorsRule(new string[] { "*" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get }, 2, new string[] { "*" }, new string[] { "*" }), new StorageCorsRule(new string[] { "http://www.abc23.com", "https://www.fabrikam.com/*" }, new CorsRuleAllowedMethod[] { CorsRuleAllowedMethod.Get, CorsRuleAllowedMethod.Put }, 2000, new string[] { "x-ms-meta-abc", "x-ms-meta-data*", "x-ms-meta-target*" }, new string[] { "x-ms-meta-12345675754564*" }) }, + }; + ArmOperation lro = await tableService.CreateOrUpdateAsync(WaitUntil.Completed, data); + TableServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_StorageTaskCollection.cs b/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_StorageTaskCollection.cs index 91964e2c33585..5c9449d503a8a 100644 --- a/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_StorageTaskCollection.cs +++ b/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_StorageTaskCollection.cs @@ -48,21 +48,18 @@ public async Task CreateOrUpdate_PutStorageTask() { Parameters = { -["tier"] = "Hot", +["tier"] = "Hot" }, OnSuccess = OnSuccessAction.Continue, OnFailure = OnFailureAction.Break, } })) { - ElseOperations = -{ -new StorageTaskOperationInfo(StorageTaskOperationName.DeleteBlob) + ElseOperations = {new StorageTaskOperationInfo(StorageTaskOperationName.DeleteBlob) { OnSuccess = OnSuccessAction.Continue, OnFailure = OnFailureAction.Break, -} -}, +}}, })); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageTaskName, data); StorageTaskResource result = lro.Value; @@ -109,10 +106,10 @@ public async Task Get_GetStorageTask() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetStorageTask() + public async Task GetAll_ListStorageTasksByResourceGroup() { - // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/GetStorageTask.json - // this example is just showing the usage of "StorageTasks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksList/ListStorageTasksByResourceGroup.json + // this example is just showing the usage of "StorageTasks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,23 +119,29 @@ public async Task Exists_GetStorageTask() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; - string resourceGroupName = "res4228"; + string resourceGroupName = "res6117"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this StorageTaskResource StorageTaskCollection collection = resourceGroupResource.GetStorageTasks(); - // invoke the operation - string storageTaskName = "mytask1"; - bool result = await collection.ExistsAsync(storageTaskName); + // invoke the operation and iterate over the result + await foreach (StorageTaskResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTaskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetStorageTask() + public async Task Exists_GetStorageTask() { // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/GetStorageTask.json // this example is just showing the usage of "StorageTasks_Get" operation, for the dependent resources, they will have to be created separately. @@ -160,29 +163,17 @@ public async Task GetIfExists_GetStorageTask() // invoke the operation string storageTaskName = "mytask1"; - NullableResponse response = await collection.GetIfExistsAsync(storageTaskName); - StorageTaskResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(storageTaskName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTaskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListStorageTasksByResourceGroup() + public async Task GetIfExists_GetStorageTask() { - // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksList/ListStorageTasksByResourceGroup.json - // this example is just showing the usage of "StorageTasks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/GetStorageTask.json + // this example is just showing the usage of "StorageTasks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,24 +183,30 @@ public async Task GetAll_ListStorageTasksByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; - string resourceGroupName = "res6117"; + string resourceGroupName = "res4228"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this StorageTaskResource StorageTaskCollection collection = resourceGroupResource.GetStorageTasks(); - // invoke the operation and iterate over the result - await foreach (StorageTaskResource item in collection.GetAllAsync()) + // invoke the operation + string storageTaskName = "mytask1"; + NullableResponse response = await collection.GetIfExistsAsync(storageTaskName); + StorageTaskResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageTaskData resourceData = item.Data; + StorageTaskData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_StorageTaskResource.cs b/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_StorageTaskResource.cs index 87aac42573aea..cd3d55f75e829 100644 --- a/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_StorageTaskResource.cs +++ b/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_StorageTaskResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.StorageActions.Models; using NUnit.Framework; @@ -21,10 +20,10 @@ public partial class Sample_StorageTaskResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteStorageTask() + public async Task Get_GetStorageTask() { - // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/DeleteStorageTask.json - // this example is just showing the usage of "StorageTasks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/GetStorageTask.json + // this example is just showing the usage of "StorageTasks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +39,21 @@ public async Task Delete_DeleteStorageTask() StorageTaskResource storageTask = client.GetStorageTaskResource(storageTaskResourceId); // invoke the operation - await storageTask.DeleteAsync(WaitUntil.Completed); + StorageTaskResource result = await storageTask.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTaskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetStorageTask() + public async Task Delete_DeleteStorageTask() { - // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/GetStorageTask.json - // this example is just showing the usage of "StorageTasks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksCrud/DeleteStorageTask.json + // this example is just showing the usage of "StorageTasks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,13 +69,9 @@ public async Task Get_GetStorageTask() StorageTaskResource storageTask = client.GetStorageTaskResource(storageTaskResourceId); // invoke the operation - StorageTaskResource result = await storageTask.GetAsync(); + await storageTask.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTaskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,13 +95,13 @@ public async Task Update_PatchStorageTask() StorageTaskResource storageTask = client.GetStorageTaskResource(storageTaskResourceId); // invoke the operation - StorageTaskPatch patch = new StorageTaskPatch() + StorageTaskPatch patch = new StorageTaskPatch { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/1f31ba14-ce16-4281-b9b4-3e78da6e1616/resourceGroups/res4228/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myUserAssignedIdentity")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/1f31ba14-ce16-4281-b9b4-3e78da6e1616/resourceGroups/res4228/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myUserAssignedIdentity")] = new UserAssignedIdentity() }, }, Properties = new StorageTaskProperties(true, "My Storage task", new StorageTaskAction(new StorageTaskIfCondition("[[equals(AccessTier, 'Cool')]]", new StorageTaskOperationInfo[] @@ -111,21 +110,18 @@ public async Task Update_PatchStorageTask() { Parameters = { -["tier"] = "Hot", +["tier"] = "Hot" }, OnSuccess = OnSuccessAction.Continue, OnFailure = OnFailureAction.Break, } })) { - ElseOperations = -{ -new StorageTaskOperationInfo(StorageTaskOperationName.DeleteBlob) + ElseOperations = {new StorageTaskOperationInfo(StorageTaskOperationName.DeleteBlob) { OnSuccess = OnSuccessAction.Continue, OnFailure = OnFailureAction.Break, -} -}, +}}, }), }; ArmOperation lro = await storageTask.UpdateAsync(WaitUntil.Completed, patch); @@ -138,210 +134,6 @@ public async Task Update_PatchStorageTask() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetStorageTasks_ListStorageTasksBySubscription() - { - // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksList/ListStorageTasksBySubscription.json - // this example is just showing the usage of "StorageTasks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (StorageTaskResource item in subscriptionResource.GetStorageTasksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTaskData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task PreviewActions_PerformStorageTaskActionsPreview() - { - // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/misc/PerformStorageTaskActionsPreview.json - // this example is just showing the usage of "StorageTasks_PreviewActions" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("eastus"); - StorageTaskPreviewAction storageTaskPreviewAction = new StorageTaskPreviewAction(new StorageTaskPreviewActionProperties(new StorageTaskPreviewContainerProperties() - { - Name = "firstContainer", - Metadata = -{ -new StorageTaskPreviewKeyValueProperties() -{ -Key = "mContainerKey1", -Value = "mContainerValue1", -} -}, - }, new StorageTaskPreviewBlobProperties[] - { -new StorageTaskPreviewBlobProperties() -{ -Name = "folder1/file1.txt", -Properties = -{ -new StorageTaskPreviewKeyValueProperties() -{ -Key = "Creation-Time", -Value = "Wed, 07 Jun 2023 05:23:29 GMT", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Last-Modified", -Value = "Wed, 07 Jun 2023 05:23:29 GMT", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Etag", -Value = "0x8DB67175454D36D", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Content-Length", -Value = "38619", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Content-Type", -Value = "text/xml", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Content-Encoding", -Value = "", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Content-Language", -Value = "", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Content-CRC64", -Value = "", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Content-MD5", -Value = "njr6iDrmU9+FC89WMK22EA==", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Cache-Control", -Value = "", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Content-Disposition", -Value = "", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "BlobType", -Value = "BlockBlob", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "AccessTier", -Value = "Hot", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "AccessTierInferred", -Value = "true", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "LeaseStatus", -Value = "unlocked", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "LeaseState", -Value = "available", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "ServerEncrypted", -Value = "true", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "TagCount", -Value = "1", -} -}, -Metadata = -{ -new StorageTaskPreviewKeyValueProperties() -{ -Key = "mKey1", -Value = "mValue1", -} -}, -Tags = -{ -new StorageTaskPreviewKeyValueProperties() -{ -Key = "tKey1", -Value = "tValue1", -} -}, -},new StorageTaskPreviewBlobProperties() -{ -Name = "folder2/file1.txt", -Properties = -{ -new StorageTaskPreviewKeyValueProperties() -{ -Key = "Creation-Time", -Value = "Wed, 06 Jun 2023 05:23:29 GMT", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Last-Modified", -Value = "Wed, 06 Jun 2023 05:23:29 GMT", -},new StorageTaskPreviewKeyValueProperties() -{ -Key = "Etag", -Value = "0x6FB67175454D36D", -} -}, -Metadata = -{ -new StorageTaskPreviewKeyValueProperties() -{ -Key = "mKey2", -Value = "mValue2", -} -}, -Tags = -{ -new StorageTaskPreviewKeyValueProperties() -{ -Key = "tKey2", -Value = "tValue2", -} -}, -} - }, new StorageTaskPreviewActionCondition(new StorageTaskPreviewActionIfCondition() - { - Condition = "[[equals(AccessTier, 'Hot')]]", - }, true))); - StorageTaskPreviewAction result = await subscriptionResource.PreviewActionsAsync(location, storageTaskPreviewAction); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetStorageTaskAssignments_ListStorageTaskAssignmentsByResourceGroup() diff --git a/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..90cc66db3db2b --- /dev/null +++ b/sdk/storageactions/Azure.ResourceManager.StorageActions/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,204 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using Azure.ResourceManager.StorageActions.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.StorageActions.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStorageTasks_ListStorageTasksBySubscription() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/storageTasksList/ListStorageTasksBySubscription.json + // this example is just showing the usage of "StorageTasks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (StorageTaskResource item in subscriptionResource.GetStorageTasksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTaskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task PreviewActions_PerformStorageTaskActionsPreview() + { + // Generated from example definition: specification/storageactions/resource-manager/Microsoft.StorageActions/stable/2023-01-01/examples/misc/PerformStorageTaskActionsPreview.json + // this example is just showing the usage of "StorageTasks_PreviewActions" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1f31ba14-ce16-4281-b9b4-3e78da6e1616"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("eastus"); + StorageTaskPreviewAction storageTaskPreviewAction = new StorageTaskPreviewAction(new StorageTaskPreviewActionProperties(new StorageTaskPreviewContainerProperties + { + Name = "firstContainer", + Metadata = {new StorageTaskPreviewKeyValueProperties +{ +Key = "mContainerKey1", +Value = "mContainerValue1", +}}, + }, new StorageTaskPreviewBlobProperties[] + { +new StorageTaskPreviewBlobProperties +{ +Name = "folder1/file1.txt", +Properties = {new StorageTaskPreviewKeyValueProperties +{ +Key = "Creation-Time", +Value = "Wed, 07 Jun 2023 05:23:29 GMT", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Last-Modified", +Value = "Wed, 07 Jun 2023 05:23:29 GMT", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Etag", +Value = "0x8DB67175454D36D", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Content-Length", +Value = "38619", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Content-Type", +Value = "text/xml", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Content-Encoding", +Value = "", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Content-Language", +Value = "", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Content-CRC64", +Value = "", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Content-MD5", +Value = "njr6iDrmU9+FC89WMK22EA==", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Cache-Control", +Value = "", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Content-Disposition", +Value = "", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "BlobType", +Value = "BlockBlob", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "AccessTier", +Value = "Hot", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "AccessTierInferred", +Value = "true", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "LeaseStatus", +Value = "unlocked", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "LeaseState", +Value = "available", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "ServerEncrypted", +Value = "true", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "TagCount", +Value = "1", +}}, +Metadata = {new StorageTaskPreviewKeyValueProperties +{ +Key = "mKey1", +Value = "mValue1", +}}, +Tags = {new StorageTaskPreviewKeyValueProperties +{ +Key = "tKey1", +Value = "tValue1", +}}, +}, +new StorageTaskPreviewBlobProperties +{ +Name = "folder2/file1.txt", +Properties = {new StorageTaskPreviewKeyValueProperties +{ +Key = "Creation-Time", +Value = "Wed, 06 Jun 2023 05:23:29 GMT", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Last-Modified", +Value = "Wed, 06 Jun 2023 05:23:29 GMT", +}, new StorageTaskPreviewKeyValueProperties +{ +Key = "Etag", +Value = "0x6FB67175454D36D", +}}, +Metadata = {new StorageTaskPreviewKeyValueProperties +{ +Key = "mKey2", +Value = "mValue2", +}}, +Tags = {new StorageTaskPreviewKeyValueProperties +{ +Key = "tKey2", +Value = "tValue2", +}}, +} + }, new StorageTaskPreviewActionCondition(new StorageTaskPreviewActionIfCondition + { + Condition = "[[equals(AccessTier, 'Hot')]]", + }, true))); + StorageTaskPreviewAction result = await subscriptionResource.PreviewActionsAsync(location, storageTaskPreviewAction); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_AmlFileSystemCollection.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_AmlFileSystemCollection.cs index d79c8e93adc5b..a6ede17cef96f 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_AmlFileSystemCollection.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_AmlFileSystemCollection.cs @@ -21,10 +21,10 @@ public partial class Sample_AmlFileSystemCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AmlFilesystemsListByResourceGroup() + public async Task CreateOrUpdate_AmlFilesystemsCreateOrUpdate() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_ListByResourceGroup.json - // this example is just showing the usage of "amlFilesystems_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_CreateOrUpdate.json + // this example is just showing the usage of "amlFilesystems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,57 @@ public async Task GetAll_AmlFilesystemsListByResourceGroup() // get the collection of this AmlFileSystemResource AmlFileSystemCollection collection = resourceGroupResource.GetAmlFileSystems(); - // invoke the operation and iterate over the result - await foreach (AmlFileSystemResource item in collection.GetAllAsync()) + // invoke the operation + string amlFileSystemName = "fs1"; + AmlFileSystemData data = new AmlFileSystemData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AmlFileSystemData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity() +}, + }, + SkuName = "AMLFS-Durable-Premium-250", + Zones = { "1" }, + StorageCapacityTiB = 16, + FilesystemSubnet = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/fsSub", + KeyEncryptionKey = new StorageCacheEncryptionKeyVaultKeyReference(new Uri("https://examplekv.vault.azure.net/keys/kvk/3540a47df75541378d3518c6a4bdf5af"), new WritableSubResource + { + Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), + }), + MaintenanceWindow = new AmlFileSystemPropertiesMaintenanceWindow + { + DayOfWeek = MaintenanceDayOfWeekType.Friday, + TimeOfDayUTC = "22:00", + }, + Hsm = new AmlFileSystemPropertiesHsm + { + Settings = new AmlFileSystemHsmSettings("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Storage/storageAccounts/storageaccountname/blobServices/default/containers/containername", "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Storage/storageAccounts/storageaccountname/blobServices/default/containers/loggingcontainername") + { + ImportPrefixesInitial = { "/" }, + }, + }, + RootSquashSettings = new AmlFileSystemRootSquashSettings + { + Mode = AmlFileSystemSquashMode.All, + NoSquashNidLists = "10.0.0.[5-6]@tcp;10.0.1.2@tcp", + SquashUID = 99L, + SquashGID = 99L, + }, + Tags = +{ +["Dept"] = "ContosoAds" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, amlFileSystemName, data); + AmlFileSystemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AmlFileSystemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +129,10 @@ public async Task Get_AmlFilesystemsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AmlFilesystemsGet() + public async Task GetAll_AmlFilesystemsListByResourceGroup() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_Get.json - // this example is just showing the usage of "amlFilesystems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_ListByResourceGroup.json + // this example is just showing the usage of "amlFilesystems_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +149,22 @@ public async Task Exists_AmlFilesystemsGet() // get the collection of this AmlFileSystemResource AmlFileSystemCollection collection = resourceGroupResource.GetAmlFileSystems(); - // invoke the operation - string amlFileSystemName = "fs1"; - bool result = await collection.ExistsAsync(amlFileSystemName); + // invoke the operation and iterate over the result + await foreach (AmlFileSystemResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AmlFileSystemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AmlFilesystemsGet() + public async Task Exists_AmlFilesystemsGet() { // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_Get.json // this example is just showing the usage of "amlFilesystems_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +186,17 @@ public async Task GetIfExists_AmlFilesystemsGet() // invoke the operation string amlFileSystemName = "fs1"; - NullableResponse response = await collection.GetIfExistsAsync(amlFileSystemName); - AmlFileSystemResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(amlFileSystemName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AmlFileSystemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AmlFilesystemsCreateOrUpdate() + public async Task GetIfExists_AmlFilesystemsGet() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_CreateOrUpdate.json - // this example is just showing the usage of "amlFilesystems_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_Get.json + // this example is just showing the usage of "amlFilesystems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,61 +215,21 @@ public async Task CreateOrUpdate_AmlFilesystemsCreateOrUpdate() // invoke the operation string amlFileSystemName = "fs1"; - AmlFileSystemData data = new AmlFileSystemData(new AzureLocation("eastus")) - { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), -}, - }, - SkuName = "AMLFS-Durable-Premium-250", - Zones = -{ -"1" -}, - StorageCapacityTiB = 16, - FilesystemSubnet = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/fsSub", - KeyEncryptionKey = new StorageCacheEncryptionKeyVaultKeyReference(new Uri("https://examplekv.vault.azure.net/keys/kvk/3540a47df75541378d3518c6a4bdf5af"), new WritableSubResource() - { - Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), - }), - MaintenanceWindow = new AmlFileSystemPropertiesMaintenanceWindow() - { - DayOfWeek = MaintenanceDayOfWeekType.Friday, - TimeOfDayUTC = "22:00", - }, - Hsm = new AmlFileSystemPropertiesHsm() - { - Settings = new AmlFileSystemHsmSettings("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Storage/storageAccounts/storageaccountname/blobServices/default/containers/containername", "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Storage/storageAccounts/storageaccountname/blobServices/default/containers/loggingcontainername") - { - ImportPrefixesInitial = -{ -"/" -}, - }, - }, - RootSquashSettings = new AmlFileSystemRootSquashSettings() - { - Mode = AmlFileSystemSquashMode.All, - NoSquashNidLists = "10.0.0.[5-6]@tcp;10.0.1.2@tcp", - SquashUID = 99L, - SquashGID = 99L, - }, - Tags = -{ -["Dept"] = "ContosoAds", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, amlFileSystemName, data); - AmlFileSystemResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(amlFileSystemName); + AmlFileSystemResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AmlFileSystemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AmlFileSystemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_AmlFileSystemResource.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_AmlFileSystemResource.cs index 1c8880059f66f..88f2b014b8b36 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_AmlFileSystemResource.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_AmlFileSystemResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using Azure.ResourceManager.StorageCache.Models; using NUnit.Framework; @@ -20,41 +19,10 @@ public partial class Sample_AmlFileSystemResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAmlFileSystems_AmlFilesystemsList() - { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_List.json - // this example is just showing the usage of "amlFilesystems_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AmlFileSystemResource item in subscriptionResource.GetAmlFileSystemsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AmlFileSystemData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_AmlFilesystemsDelete() + public async Task Get_AmlFilesystemsGet() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_Delete.json - // this example is just showing the usage of "amlFilesystems_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_Get.json + // this example is just showing the usage of "amlFilesystems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,17 +38,21 @@ public async Task Delete_AmlFilesystemsDelete() AmlFileSystemResource amlFileSystem = client.GetAmlFileSystemResource(amlFileSystemResourceId); // invoke the operation - await amlFileSystem.DeleteAsync(WaitUntil.Completed); + AmlFileSystemResource result = await amlFileSystem.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AmlFileSystemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AmlFilesystemsGet() + public async Task Delete_AmlFilesystemsDelete() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_Get.json - // this example is just showing the usage of "amlFilesystems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_Delete.json + // this example is just showing the usage of "amlFilesystems_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,13 +68,9 @@ public async Task Get_AmlFilesystemsGet() AmlFileSystemResource amlFileSystem = client.GetAmlFileSystemResource(amlFileSystemResourceId); // invoke the operation - AmlFileSystemResource result = await amlFileSystem.GetAsync(); + await amlFileSystem.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AmlFileSystemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -126,22 +94,22 @@ public async Task Update_AmlFilesystemsUpdate() AmlFileSystemResource amlFileSystem = client.GetAmlFileSystemResource(amlFileSystemResourceId); // invoke the operation - AmlFileSystemPatch patch = new AmlFileSystemPatch() + AmlFileSystemPatch patch = new AmlFileSystemPatch { Tags = { -["Dept"] = "ContosoAds", +["Dept"] = "ContosoAds" }, - KeyEncryptionKey = new StorageCacheEncryptionKeyVaultKeyReference(new Uri("https://examplekv.vault.azure.net/keys/kvk/3540a47df75541378d3518c6a4bdf5af"), new WritableSubResource() + KeyEncryptionKey = new StorageCacheEncryptionKeyVaultKeyReference(new Uri("https://examplekv.vault.azure.net/keys/kvk/3540a47df75541378d3518c6a4bdf5af"), new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), }), - MaintenanceWindow = new AmlFileSystemUpdatePropertiesMaintenanceWindow() + MaintenanceWindow = new AmlFileSystemUpdatePropertiesMaintenanceWindow { DayOfWeek = MaintenanceDayOfWeekType.Friday, TimeOfDayUTC = "22:00", }, - RootSquashSettings = new AmlFileSystemRootSquashSettings() + RootSquashSettings = new AmlFileSystemRootSquashSettings { Mode = AmlFileSystemSquashMode.All, NoSquashNidLists = "10.0.0.[5-6]@tcp;10.0.1.2@tcp", @@ -180,7 +148,7 @@ public async Task Archive_AmlFilesystemsArchive() AmlFileSystemResource amlFileSystem = client.GetAmlFileSystemResource(amlFileSystemResourceId); // invoke the operation - AmlFileSystemArchiveContent content = new AmlFileSystemArchiveContent() + AmlFileSystemArchiveContent content = new AmlFileSystemArchiveContent { FilesystemPath = "/", }; diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheCollection.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheCollection.cs index 496ee8e09d9a2..4e5dc42687f2b 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheCollection.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheCollection.cs @@ -20,144 +20,6 @@ namespace Azure.ResourceManager.StorageCache.Samples { public partial class Sample_StorageCacheCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_CachesListByResourceGroup() - { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_ListByResourceGroup.json - // this example is just showing the usage of "Caches_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "scgroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this StorageCacheResource - StorageCacheCollection collection = resourceGroupResource.GetStorageCaches(); - - // invoke the operation and iterate over the result - await foreach (StorageCacheResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageCacheData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_CachesGet() - { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_Get.json - // this example is just showing the usage of "Caches_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "scgroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this StorageCacheResource - StorageCacheCollection collection = resourceGroupResource.GetStorageCaches(); - - // invoke the operation - string cacheName = "sc1"; - StorageCacheResource result = await collection.GetAsync(cacheName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageCacheData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_CachesGet() - { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_Get.json - // this example is just showing the usage of "Caches_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "scgroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this StorageCacheResource - StorageCacheCollection collection = resourceGroupResource.GetStorageCaches(); - - // invoke the operation - string cacheName = "sc1"; - bool result = await collection.ExistsAsync(cacheName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CachesGet() - { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_Get.json - // this example is just showing the usage of "Caches_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "scgroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this StorageCacheResource - StorageCacheCollection collection = resourceGroupResource.GetStorageCaches(); - - // invoke the operation - string cacheName = "sc1"; - NullableResponse response = await collection.GetIfExistsAsync(cacheName); - StorageCacheResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageCacheData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CachesCreateOrUpdate() @@ -188,37 +50,34 @@ public async Task CreateOrUpdate_CachesCreateOrUpdate() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity() }, }, SkuName = "Standard_2G", CacheSizeGB = 3072, Subnet = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - UpgradeSettings = new StorageCacheUpgradeSettings() + UpgradeSettings = new StorageCacheUpgradeSettings { EnableUpgradeSchedule = true, ScheduledOn = DateTimeOffset.Parse("2022-04-26T18:25:43.511Z"), }, - EncryptionSettings = new StorageCacheEncryptionSettings() + EncryptionSettings = new StorageCacheEncryptionSettings { - KeyEncryptionKey = new StorageCacheEncryptionKeyVaultKeyReference(new Uri("https://keyvault-cmk.vault.azure.net/keys/key2047/test"), new WritableSubResource() + KeyEncryptionKey = new StorageCacheEncryptionKeyVaultKeyReference(new Uri("https://keyvault-cmk.vault.azure.net/keys/key2047/test"), new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), }), }, - SecurityAccessPolicies = + SecurityAccessPolicies = {new NfsAccessPolicy("default", new NfsAccessRule[] { -new NfsAccessPolicy("default",new NfsAccessRule[] -{ -new NfsAccessRule(NfsAccessRuleScope.Default,NfsAccessRuleAccess.ReadWrite) +new NfsAccessRule(NfsAccessRuleScope.Default, NfsAccessRuleAccess.ReadWrite) { AllowSuid = false, AllowSubmountAccess = true, EnableRootSquash = false, } -}) -}, - DirectoryServicesSettings = new StorageCacheDirectorySettings() +})}, + DirectoryServicesSettings = new StorageCacheDirectorySettings { ActiveDirectory = new StorageCacheActiveDirectorySettings(IPAddress.Parse("192.0.2.10"), "contosoAd.contoso.local", "contosoAd", "contosoSmb") { @@ -228,13 +87,13 @@ public async Task CreateOrUpdate_CachesCreateOrUpdate() Password = "", }, }, - UsernameDownload = new StorageCacheUsernameDownloadSettings() + UsernameDownload = new StorageCacheUsernameDownloadSettings { EnableExtendedGroups = true, UsernameSource = StorageCacheUsernameSourceType.Ldap, LdapServer = "192.0.2.12", LdapBaseDN = "dc=contosoad,dc=contoso,dc=local", - Credentials = new StorageCacheUsernameDownloadCredential() + Credentials = new StorageCacheUsernameDownloadCredential { BindDistinguishedName = "cn=ldapadmin,dc=contosoad,dc=contoso,dc=local", BindPassword = "", @@ -243,7 +102,7 @@ public async Task CreateOrUpdate_CachesCreateOrUpdate() }, Tags = { -["Dept"] = "Contoso", +["Dept"] = "Contoso" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cacheName, data); @@ -285,39 +144,36 @@ public async Task CreateOrUpdate_CachesCreateOrUpdateLdapOnly() SkuName = "Standard_2G", CacheSizeGB = 3072, Subnet = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - UpgradeSettings = new StorageCacheUpgradeSettings() + UpgradeSettings = new StorageCacheUpgradeSettings { EnableUpgradeSchedule = true, ScheduledOn = DateTimeOffset.Parse("2022-04-26T18:25:43.511Z"), }, - EncryptionSettings = new StorageCacheEncryptionSettings() + EncryptionSettings = new StorageCacheEncryptionSettings { - KeyEncryptionKey = new StorageCacheEncryptionKeyVaultKeyReference(new Uri("https://keyvault-cmk.vault.azure.net/keys/key2048/test"), new WritableSubResource() + KeyEncryptionKey = new StorageCacheEncryptionKeyVaultKeyReference(new Uri("https://keyvault-cmk.vault.azure.net/keys/key2048/test"), new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.KeyVault/vaults/keyvault-cmk"), }), }, - SecurityAccessPolicies = + SecurityAccessPolicies = {new NfsAccessPolicy("default", new NfsAccessRule[] { -new NfsAccessPolicy("default",new NfsAccessRule[] -{ -new NfsAccessRule(NfsAccessRuleScope.Default,NfsAccessRuleAccess.ReadWrite) +new NfsAccessRule(NfsAccessRuleScope.Default, NfsAccessRuleAccess.ReadWrite) { AllowSuid = false, AllowSubmountAccess = true, EnableRootSquash = false, } -}) -}, - DirectoryServicesSettings = new StorageCacheDirectorySettings() +})}, + DirectoryServicesSettings = new StorageCacheDirectorySettings { - UsernameDownload = new StorageCacheUsernameDownloadSettings() + UsernameDownload = new StorageCacheUsernameDownloadSettings { EnableExtendedGroups = true, UsernameSource = StorageCacheUsernameSourceType.Ldap, LdapServer = "192.0.2.12", LdapBaseDN = "dc=contosoad,dc=contoso,dc=local", - Credentials = new StorageCacheUsernameDownloadCredential() + Credentials = new StorageCacheUsernameDownloadCredential { BindDistinguishedName = "cn=ldapadmin,dc=contosoad,dc=contoso,dc=local", BindPassword = "", @@ -326,7 +182,7 @@ public async Task CreateOrUpdate_CachesCreateOrUpdateLdapOnly() }, Tags = { -["Dept"] = "Contoso", +["Dept"] = "Contoso" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cacheName, data); @@ -338,5 +194,143 @@ public async Task CreateOrUpdate_CachesCreateOrUpdateLdapOnly() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CachesGet() + { + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_Get.json + // this example is just showing the usage of "Caches_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "scgroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this StorageCacheResource + StorageCacheCollection collection = resourceGroupResource.GetStorageCaches(); + + // invoke the operation + string cacheName = "sc1"; + StorageCacheResource result = await collection.GetAsync(cacheName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageCacheData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_CachesListByResourceGroup() + { + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_ListByResourceGroup.json + // this example is just showing the usage of "Caches_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "scgroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this StorageCacheResource + StorageCacheCollection collection = resourceGroupResource.GetStorageCaches(); + + // invoke the operation and iterate over the result + await foreach (StorageCacheResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageCacheData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_CachesGet() + { + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_Get.json + // this example is just showing the usage of "Caches_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "scgroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this StorageCacheResource + StorageCacheCollection collection = resourceGroupResource.GetStorageCaches(); + + // invoke the operation + string cacheName = "sc1"; + bool result = await collection.ExistsAsync(cacheName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_CachesGet() + { + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_Get.json + // this example is just showing the usage of "Caches_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "scgroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this StorageCacheResource + StorageCacheCollection collection = resourceGroupResource.GetStorageCaches(); + + // invoke the operation + string cacheName = "sc1"; + NullableResponse response = await collection.GetIfExistsAsync(cacheName); + StorageCacheResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageCacheData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheImportJobCollection.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheImportJobCollection.cs index c2b48b2934432..c58215a6fd80b 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheImportJobCollection.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheImportJobCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageCacheImportJobCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ImportJobsGet() + public async Task CreateOrUpdate_ImportJobsCreateOrUpdate() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_Get.json - // this example is just showing the usage of "importJobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_CreateOrUpdate.json + // this example is just showing the usage of "importJobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_ImportJobsGet() // invoke the operation string importJobName = "job1"; - StorageCacheImportJobResource result = await collection.GetAsync(importJobName); + StorageCacheImportJobData data = new StorageCacheImportJobData(new AzureLocation("eastus")) + { + ImportPrefixes = { "/" }, + ConflictResolutionMode = ConflictResolutionMode.OverwriteAlways, + MaximumErrors = 0, + Tags = +{ +["Dept"] = "ContosoAds" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, importJobName, data); + StorageCacheImportJobResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +63,7 @@ public async Task Get_ImportJobsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ImportJobsGet() + public async Task Get_ImportJobsGet() { // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_Get.json // this example is just showing the usage of "importJobs_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +86,21 @@ public async Task Exists_ImportJobsGet() // invoke the operation string importJobName = "job1"; - bool result = await collection.ExistsAsync(importJobName); + StorageCacheImportJobResource result = await collection.GetAsync(importJobName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageCacheImportJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ImportJobsGet() + public async Task GetAll_ImportJobsListByAmlFilesystem() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_Get.json - // this example is just showing the usage of "importJobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_ListByAmlFilesystem.json + // this example is just showing the usage of "importJobs_ListByAmlFileSystem" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +118,25 @@ public async Task GetIfExists_ImportJobsGet() // get the collection of this StorageCacheImportJobResource StorageCacheImportJobCollection collection = amlFileSystem.GetStorageCacheImportJobs(); - // invoke the operation - string importJobName = "job1"; - NullableResponse response = await collection.GetIfExistsAsync(importJobName); - StorageCacheImportJobResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (StorageCacheImportJobResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageCacheImportJobData resourceData = result.Data; + StorageCacheImportJobData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ImportJobsCreateOrUpdate() + public async Task Exists_ImportJobsGet() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_CreateOrUpdate.json - // this example is just showing the usage of "importJobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_Get.json + // this example is just showing the usage of "importJobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,35 +156,17 @@ public async Task CreateOrUpdate_ImportJobsCreateOrUpdate() // invoke the operation string importJobName = "job1"; - StorageCacheImportJobData data = new StorageCacheImportJobData(new AzureLocation("eastus")) - { - ImportPrefixes = -{ -"/" -}, - ConflictResolutionMode = ConflictResolutionMode.OverwriteAlways, - MaximumErrors = 0, - Tags = -{ -["Dept"] = "ContosoAds", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, importJobName, data); - StorageCacheImportJobResource result = lro.Value; + bool result = await collection.ExistsAsync(importJobName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageCacheImportJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ImportJobsListByAmlFilesystem() + public async Task GetIfExists_ImportJobsGet() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_ListByAmlFilesystem.json - // this example is just showing the usage of "importJobs_ListByAmlFileSystem" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_Get.json + // this example is just showing the usage of "importJobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +184,23 @@ public async Task GetAll_ImportJobsListByAmlFilesystem() // get the collection of this StorageCacheImportJobResource StorageCacheImportJobCollection collection = amlFileSystem.GetStorageCacheImportJobs(); - // invoke the operation and iterate over the result - await foreach (StorageCacheImportJobResource item in collection.GetAllAsync()) + // invoke the operation + string importJobName = "job1"; + NullableResponse response = await collection.GetIfExistsAsync(importJobName); + StorageCacheImportJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - StorageCacheImportJobData resourceData = item.Data; + StorageCacheImportJobData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheImportJobResource.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheImportJobResource.cs index c1e33a107a2b2..366e07bf9e988 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheImportJobResource.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheImportJobResource.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageCacheImportJobResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ImportJobsDelete() + public async Task Get_ImportJobsGet() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_Delete.json - // this example is just showing the usage of "importJobs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_Get.json + // this example is just showing the usage of "importJobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_ImportJobsDelete() StorageCacheImportJobResource storageCacheImportJob = client.GetStorageCacheImportJobResource(storageCacheImportJobResourceId); // invoke the operation - await storageCacheImportJob.DeleteAsync(WaitUntil.Completed); + StorageCacheImportJobResource result = await storageCacheImportJob.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageCacheImportJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ImportJobsGet() + public async Task Delete_ImportJobsDelete() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_Get.json - // this example is just showing the usage of "importJobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/importJobs_Delete.json + // this example is just showing the usage of "importJobs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_ImportJobsGet() StorageCacheImportJobResource storageCacheImportJob = client.GetStorageCacheImportJobResource(storageCacheImportJobResourceId); // invoke the operation - StorageCacheImportJobResource result = await storageCacheImportJob.GetAsync(); + await storageCacheImportJob.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageCacheImportJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,11 +96,11 @@ public async Task Update_ImportJobsUpdate() StorageCacheImportJobResource storageCacheImportJob = client.GetStorageCacheImportJobResource(storageCacheImportJobResourceId); // invoke the operation - StorageCacheImportJobPatch patch = new StorageCacheImportJobPatch() + StorageCacheImportJobPatch patch = new StorageCacheImportJobPatch { Tags = { -["Dept"] = "ContosoAds", +["Dept"] = "ContosoAds" }, }; ArmOperation lro = await storageCacheImportJob.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheResource.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheResource.cs index 76e5c01a6e9fc..2dc65815f24b1 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheResource.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageCacheResource.cs @@ -11,7 +11,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.StorageCache.Models; using NUnit.Framework; @@ -21,41 +20,10 @@ public partial class Sample_StorageCacheResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetStorageCaches_CachesList() - { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_List.json - // this example is just showing the usage of "Caches_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (StorageCacheResource item in subscriptionResource.GetStorageCachesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageCacheData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_CachesDelete() + public async Task Get_CachesGet() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_Delete.json - // this example is just showing the usage of "Caches_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_Get.json + // this example is just showing the usage of "Caches_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,22 +34,26 @@ public async Task Delete_CachesDelete() // for more information of creating StorageCacheResource, please refer to the document of StorageCacheResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "scgroup"; - string cacheName = "sc"; + string cacheName = "sc1"; ResourceIdentifier storageCacheResourceId = StorageCacheResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cacheName); StorageCacheResource storageCache = client.GetStorageCacheResource(storageCacheResourceId); // invoke the operation - await storageCache.DeleteAsync(WaitUntil.Completed); + StorageCacheResource result = await storageCache.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageCacheData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CachesGet() + public async Task Delete_CachesDelete() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_Get.json - // this example is just showing the usage of "Caches_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_Delete.json + // this example is just showing the usage of "Caches_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,18 +64,14 @@ public async Task Get_CachesGet() // for more information of creating StorageCacheResource, please refer to the document of StorageCacheResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "scgroup"; - string cacheName = "sc1"; + string cacheName = "sc"; ResourceIdentifier storageCacheResourceId = StorageCacheResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cacheName); StorageCacheResource storageCache = client.GetStorageCacheResource(storageCacheResourceId); // invoke the operation - StorageCacheResource result = await storageCache.GetAsync(); + await storageCache.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageCacheData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -132,46 +100,43 @@ public async Task Update_CachesUpdate() SkuName = "Standard_2G", CacheSizeGB = 3072, Subnet = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - UpgradeSettings = new StorageCacheUpgradeSettings() + UpgradeSettings = new StorageCacheUpgradeSettings { EnableUpgradeSchedule = true, ScheduledOn = DateTimeOffset.Parse("2022-04-26T18:25:43.511Z"), }, - NetworkSettings = new StorageCacheNetworkSettings() + NetworkSettings = new StorageCacheNetworkSettings { Mtu = 1500, - DnsServers = -{ -IPAddress.Parse("10.1.22.33"),IPAddress.Parse("10.1.12.33") -}, + DnsServers = { IPAddress.Parse("10.1.22.33"), IPAddress.Parse("10.1.12.33") }, DnsSearchDomain = "contoso.com", NtpServer = "time.contoso.com", }, - SecurityAccessPolicies = -{ -new NfsAccessPolicy("default",new NfsAccessRule[] + SecurityAccessPolicies = {new NfsAccessPolicy("default", new NfsAccessRule[] { -new NfsAccessRule(NfsAccessRuleScope.Default,NfsAccessRuleAccess.ReadWrite) +new NfsAccessRule(NfsAccessRuleScope.Default, NfsAccessRuleAccess.ReadWrite) { AllowSuid = false, AllowSubmountAccess = true, EnableRootSquash = false, } -}),new NfsAccessPolicy("restrictive",new NfsAccessRule[] +}), new NfsAccessPolicy("restrictive", new NfsAccessRule[] { -new NfsAccessRule(NfsAccessRuleScope.Host,NfsAccessRuleAccess.ReadWrite) +new NfsAccessRule(NfsAccessRuleScope.Host, NfsAccessRuleAccess.ReadWrite) { Filter = "10.99.3.145", AllowSuid = true, AllowSubmountAccess = true, EnableRootSquash = false, -},new NfsAccessRule(NfsAccessRuleScope.Network,NfsAccessRuleAccess.ReadWrite) +}, +new NfsAccessRule(NfsAccessRuleScope.Network, NfsAccessRuleAccess.ReadWrite) { Filter = "10.99.1.0/24", AllowSuid = true, AllowSubmountAccess = true, EnableRootSquash = false, -},new NfsAccessRule(NfsAccessRuleScope.Default,NfsAccessRuleAccess.No) +}, +new NfsAccessRule(NfsAccessRuleScope.Default, NfsAccessRuleAccess.No) { AllowSuid = false, AllowSubmountAccess = true, @@ -179,15 +144,14 @@ public async Task Update_CachesUpdate() AnonymousUID = "65534", AnonymousGID = "65534", } -}) -}, - DirectoryServicesSettings = new StorageCacheDirectorySettings() +})}, + DirectoryServicesSettings = new StorageCacheDirectorySettings { ActiveDirectory = new StorageCacheActiveDirectorySettings(IPAddress.Parse("192.0.2.10"), "contosoAd.contoso.local", "contosoAd", "contosoSmb") { SecondaryDnsIPAddress = IPAddress.Parse("192.0.2.11"), }, - UsernameDownload = new StorageCacheUsernameDownloadSettings() + UsernameDownload = new StorageCacheUsernameDownloadSettings { EnableExtendedGroups = true, UsernameSource = StorageCacheUsernameSourceType.AD, @@ -195,7 +159,7 @@ public async Task Update_CachesUpdate() }, Tags = { -["Dept"] = "Contoso", +["Dept"] = "Contoso" }, }; ArmOperation lro = await storageCache.UpdateAsync(WaitUntil.Completed, data); @@ -234,46 +198,43 @@ public async Task Update_CachesUpdateLdapOnly() SkuName = "Standard_2G", CacheSizeGB = 3072, Subnet = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/sub1"), - UpgradeSettings = new StorageCacheUpgradeSettings() + UpgradeSettings = new StorageCacheUpgradeSettings { EnableUpgradeSchedule = true, ScheduledOn = DateTimeOffset.Parse("2022-04-26T18:25:43.511Z"), }, - NetworkSettings = new StorageCacheNetworkSettings() + NetworkSettings = new StorageCacheNetworkSettings { Mtu = 1500, - DnsServers = -{ -IPAddress.Parse("10.1.22.33"),IPAddress.Parse("10.1.12.33") -}, + DnsServers = { IPAddress.Parse("10.1.22.33"), IPAddress.Parse("10.1.12.33") }, DnsSearchDomain = "contoso.com", NtpServer = "time.contoso.com", }, - SecurityAccessPolicies = -{ -new NfsAccessPolicy("default",new NfsAccessRule[] + SecurityAccessPolicies = {new NfsAccessPolicy("default", new NfsAccessRule[] { -new NfsAccessRule(NfsAccessRuleScope.Default,NfsAccessRuleAccess.ReadWrite) +new NfsAccessRule(NfsAccessRuleScope.Default, NfsAccessRuleAccess.ReadWrite) { AllowSuid = false, AllowSubmountAccess = true, EnableRootSquash = false, } -}),new NfsAccessPolicy("restrictive",new NfsAccessRule[] +}), new NfsAccessPolicy("restrictive", new NfsAccessRule[] { -new NfsAccessRule(NfsAccessRuleScope.Host,NfsAccessRuleAccess.ReadWrite) +new NfsAccessRule(NfsAccessRuleScope.Host, NfsAccessRuleAccess.ReadWrite) { Filter = "10.99.3.145", AllowSuid = true, AllowSubmountAccess = true, EnableRootSquash = false, -},new NfsAccessRule(NfsAccessRuleScope.Network,NfsAccessRuleAccess.ReadWrite) +}, +new NfsAccessRule(NfsAccessRuleScope.Network, NfsAccessRuleAccess.ReadWrite) { Filter = "10.99.1.0/24", AllowSuid = true, AllowSubmountAccess = true, EnableRootSquash = false, -},new NfsAccessRule(NfsAccessRuleScope.Default,NfsAccessRuleAccess.No) +}, +new NfsAccessRule(NfsAccessRuleScope.Default, NfsAccessRuleAccess.No) { AllowSuid = false, AllowSubmountAccess = true, @@ -281,17 +242,16 @@ public async Task Update_CachesUpdateLdapOnly() AnonymousUID = "65534", AnonymousGID = "65534", } -}) -}, - DirectoryServicesSettings = new StorageCacheDirectorySettings() +})}, + DirectoryServicesSettings = new StorageCacheDirectorySettings { - UsernameDownload = new StorageCacheUsernameDownloadSettings() + UsernameDownload = new StorageCacheUsernameDownloadSettings { EnableExtendedGroups = true, UsernameSource = StorageCacheUsernameSourceType.Ldap, LdapServer = "192.0.2.12", LdapBaseDN = "dc=contosoad,dc=contoso,dc=local", - Credentials = new StorageCacheUsernameDownloadCredential() + Credentials = new StorageCacheUsernameDownloadCredential { BindDistinguishedName = "cn=ldapadmin,dc=contosoad,dc=contoso,dc=local", BindPassword = "", @@ -300,7 +260,7 @@ public async Task Update_CachesUpdateLdapOnly() }, Tags = { -["Dept"] = "Contoso", +["Dept"] = "Contoso" }, }; ArmOperation lro = await storageCache.UpdateAsync(WaitUntil.Completed, data); @@ -574,15 +534,17 @@ public async Task UpdateSpaceAllocation_SpaceAllocationPost() // invoke the operation IEnumerable spaceAllocation = new StorageTargetSpaceAllocation[] { -new StorageTargetSpaceAllocation() +new StorageTargetSpaceAllocation { Name = "st1", AllocationPercentage = 25, -},new StorageTargetSpaceAllocation() +}, +new StorageTargetSpaceAllocation { Name = "st2", AllocationPercentage = 50, -},new StorageTargetSpaceAllocation() +}, +new StorageTargetSpaceAllocation { Name = "st3", AllocationPercentage = 25, diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageTargetCollection.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageTargetCollection.cs index 69e5e5358f756..53221a32d00bb 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageTargetCollection.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageTargetCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageTargetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StorageTargetsList() + public async Task CreateOrUpdate_StorageTargetsCreateOrUpdate() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_ListByCache.json - // this example is just showing the usage of "StorageTargets_ListByCache" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_CreateOrUpdate.json + // this example is just showing the usage of "StorageTargets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,47 @@ public async Task GetAll_StorageTargetsList() // get the collection of this StorageTargetResource StorageTargetCollection collection = storageCache.GetStorageTargets(); - // invoke the operation and iterate over the result - await foreach (StorageTargetResource item in collection.GetAllAsync()) + // invoke the operation + string storageTargetName = "st1"; + StorageTargetData data = new StorageTargetData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTargetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Junctions = {new NamespaceJunction +{ +NamespacePath = "/path/on/cache", +TargetPath = "/path/on/exp1", +NfsExport = "exp1", +NfsAccessPolicy = "default", +}, new NamespaceJunction +{ +NamespacePath = "/path2/on/cache", +TargetPath = "/path2/on/exp2", +NfsExport = "exp2", +NfsAccessPolicy = "rootSquash", +}}, + TargetType = StorageTargetType.Nfs3, + Nfs3 = new Nfs3Target + { + Target = "10.0.44.44", + UsageModel = "READ_ONLY", + VerificationDelayInSeconds = 30, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageTargetName, data); + StorageTargetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageTargetsGet() + public async Task CreateOrUpdate_StorageTargetsCreateOrUpdateBlobNfs() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_Get.json - // this example is just showing the usage of "StorageTargets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_CreateOrUpdate_BlobNfs.json + // this example is just showing the usage of "StorageTargets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +99,23 @@ public async Task Get_StorageTargetsGet() // invoke the operation string storageTargetName = "st1"; - StorageTargetResource result = await collection.GetAsync(storageTargetName); + StorageTargetData data = new StorageTargetData + { + Junctions = {new NamespaceJunction +{ +NamespacePath = "/blobnfs", +}}, + TargetType = StorageTargetType.BlobNfs, + BlobNfs = new BlobNfsTarget + { + Target = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Storage/storageAccounts/blofnfs/blobServices/default/containers/blobnfs"), + UsageModel = "READ_WRITE", + VerificationDelayInSeconds = 28800, + WriteBackDelayInSeconds = 3600, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageTargetName, data); + StorageTargetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +126,10 @@ public async Task Get_StorageTargetsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageTargetsGet() + public async Task CreateOrUpdate_StorageTargetsCreateOrUpdateNoJunctions() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_Get.json - // this example is just showing the usage of "StorageTargets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_CreateOrUpdate_NoJunctions.json + // this example is just showing the usage of "StorageTargets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,14 +149,29 @@ public async Task Exists_StorageTargetsGet() // invoke the operation string storageTargetName = "st1"; - bool result = await collection.ExistsAsync(storageTargetName); + StorageTargetData data = new StorageTargetData + { + TargetType = StorageTargetType.Nfs3, + Nfs3 = new Nfs3Target + { + Target = "10.0.44.44", + UsageModel = "READ_ONLY", + VerificationDelayInSeconds = 30, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageTargetName, data); + StorageTargetResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageTargetsGet() + public async Task Get_StorageTargetsGet() { // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_Get.json // this example is just showing the usage of "StorageTargets_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +194,21 @@ public async Task GetIfExists_StorageTargetsGet() // invoke the operation string storageTargetName = "st1"; - NullableResponse response = await collection.GetIfExistsAsync(storageTargetName); - StorageTargetResource result = response.HasValue ? response.Value : null; + StorageTargetResource result = await collection.GetAsync(storageTargetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTargetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StorageTargetsCreateOrUpdate() + public async Task GetAll_StorageTargetsList() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_CreateOrUpdate.json - // this example is just showing the usage of "StorageTargets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_ListByCache.json + // this example is just showing the usage of "StorageTargets_ListByCache" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,50 +226,25 @@ public async Task CreateOrUpdate_StorageTargetsCreateOrUpdate() // get the collection of this StorageTargetResource StorageTargetCollection collection = storageCache.GetStorageTargets(); - // invoke the operation - string storageTargetName = "st1"; - StorageTargetData data = new StorageTargetData() + // invoke the operation and iterate over the result + await foreach (StorageTargetResource item in collection.GetAllAsync()) { - Junctions = -{ -new NamespaceJunction() -{ -NamespacePath = "/path/on/cache", -TargetPath = "/path/on/exp1", -NfsExport = "exp1", -NfsAccessPolicy = "default", -},new NamespaceJunction() -{ -NamespacePath = "/path2/on/cache", -TargetPath = "/path2/on/exp2", -NfsExport = "exp2", -NfsAccessPolicy = "rootSquash", -} -}, - TargetType = StorageTargetType.Nfs3, - Nfs3 = new Nfs3Target() - { - Target = "10.0.44.44", - UsageModel = "READ_ONLY", - VerificationDelayInSeconds = 30, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageTargetName, data); - StorageTargetResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTargetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTargetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StorageTargetsCreateOrUpdateBlobNfs() + public async Task Exists_StorageTargetsGet() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_CreateOrUpdate_BlobNfs.json - // this example is just showing the usage of "StorageTargets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_Get.json + // this example is just showing the usage of "StorageTargets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -244,40 +264,17 @@ public async Task CreateOrUpdate_StorageTargetsCreateOrUpdateBlobNfs() // invoke the operation string storageTargetName = "st1"; - StorageTargetData data = new StorageTargetData() - { - Junctions = -{ -new NamespaceJunction() -{ -NamespacePath = "/blobnfs", -} -}, - TargetType = StorageTargetType.BlobNfs, - BlobNfs = new BlobNfsTarget() - { - Target = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Storage/storageAccounts/blofnfs/blobServices/default/containers/blobnfs"), - UsageModel = "READ_WRITE", - VerificationDelayInSeconds = 28800, - WriteBackDelayInSeconds = 3600, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageTargetName, data); - StorageTargetResource result = lro.Value; + bool result = await collection.ExistsAsync(storageTargetName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTargetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StorageTargetsCreateOrUpdateNoJunctions() + public async Task GetIfExists_StorageTargetsGet() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_CreateOrUpdate_NoJunctions.json - // this example is just showing the usage of "StorageTargets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_Get.json + // this example is just showing the usage of "StorageTargets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -297,24 +294,21 @@ public async Task CreateOrUpdate_StorageTargetsCreateOrUpdateNoJunctions() // invoke the operation string storageTargetName = "st1"; - StorageTargetData data = new StorageTargetData() - { - TargetType = StorageTargetType.Nfs3, - Nfs3 = new Nfs3Target() - { - Target = "10.0.44.44", - UsageModel = "READ_ONLY", - VerificationDelayInSeconds = 30, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageTargetName, data); - StorageTargetResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(storageTargetName); + StorageTargetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTargetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageTargetResource.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageTargetResource.cs index 7577ab936ee36..70bc3c0b5f03b 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageTargetResource.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_StorageTargetResource.cs @@ -18,10 +18,10 @@ public partial class Sample_StorageTargetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task RefreshDns_CachesDnsRefresh() + public async Task Get_StorageTargetsGet() { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_DnsRefresh.json - // this example is just showing the usage of "StorageTargets_DnsRefresh" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_Get.json + // this example is just showing the usage of "StorageTargets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,15 +32,19 @@ public async Task RefreshDns_CachesDnsRefresh() // for more information of creating StorageTargetResource, please refer to the document of StorageTargetResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "scgroup"; - string cacheName = "sc"; + string cacheName = "sc1"; string storageTargetName = "st1"; ResourceIdentifier storageTargetResourceId = StorageTargetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cacheName, storageTargetName); StorageTargetResource storageTarget = client.GetStorageTargetResource(storageTargetResourceId); // invoke the operation - await storageTarget.RefreshDnsAsync(WaitUntil.Completed); + StorageTargetResource result = await storageTarget.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageTargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -70,37 +74,6 @@ public async Task Delete_StorageTargetsDelete() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_StorageTargetsGet() - { - // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_Get.json - // this example is just showing the usage of "StorageTargets_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this StorageTargetResource created on azure - // for more information of creating StorageTargetResource, please refer to the document of StorageTargetResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "scgroup"; - string cacheName = "sc1"; - string storageTargetName = "st1"; - ResourceIdentifier storageTargetResourceId = StorageTargetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cacheName, storageTargetName); - StorageTargetResource storageTarget = client.GetStorageTargetResource(storageTargetResourceId); - - // invoke the operation - StorageTargetResource result = await storageTarget.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StorageTargetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Update_StorageTargetsCreateOrUpdate() @@ -123,26 +96,23 @@ public async Task Update_StorageTargetsCreateOrUpdate() StorageTargetResource storageTarget = client.GetStorageTargetResource(storageTargetResourceId); // invoke the operation - StorageTargetData data = new StorageTargetData() + StorageTargetData data = new StorageTargetData { - Junctions = -{ -new NamespaceJunction() + Junctions = {new NamespaceJunction { NamespacePath = "/path/on/cache", TargetPath = "/path/on/exp1", NfsExport = "exp1", NfsAccessPolicy = "default", -},new NamespaceJunction() +}, new NamespaceJunction { NamespacePath = "/path2/on/cache", TargetPath = "/path2/on/exp2", NfsExport = "exp2", NfsAccessPolicy = "rootSquash", -} -}, +}}, TargetType = StorageTargetType.Nfs3, - Nfs3 = new Nfs3Target() + Nfs3 = new Nfs3Target { Target = "10.0.44.44", UsageModel = "READ_ONLY", @@ -181,17 +151,14 @@ public async Task Update_StorageTargetsCreateOrUpdateBlobNfs() StorageTargetResource storageTarget = client.GetStorageTargetResource(storageTargetResourceId); // invoke the operation - StorageTargetData data = new StorageTargetData() + StorageTargetData data = new StorageTargetData { - Junctions = -{ -new NamespaceJunction() + Junctions = {new NamespaceJunction { NamespacePath = "/blobnfs", -} -}, +}}, TargetType = StorageTargetType.BlobNfs, - BlobNfs = new BlobNfsTarget() + BlobNfs = new BlobNfsTarget { Target = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Storage/storageAccounts/blofnfs/blobServices/default/containers/blobnfs"), UsageModel = "READ_WRITE", @@ -231,10 +198,10 @@ public async Task Update_StorageTargetsCreateOrUpdateNoJunctions() StorageTargetResource storageTarget = client.GetStorageTargetResource(storageTargetResourceId); // invoke the operation - StorageTargetData data = new StorageTargetData() + StorageTargetData data = new StorageTargetData { TargetType = StorageTargetType.Nfs3, - Nfs3 = new Nfs3Target() + Nfs3 = new Nfs3Target { Target = "10.0.44.44", UsageModel = "READ_ONLY", @@ -251,6 +218,33 @@ public async Task Update_StorageTargetsCreateOrUpdateNoJunctions() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task RefreshDns_CachesDnsRefresh() + { + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/StorageTargets_DnsRefresh.json + // this example is just showing the usage of "StorageTargets_DnsRefresh" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this StorageTargetResource created on azure + // for more information of creating StorageTargetResource, please refer to the document of StorageTargetResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "scgroup"; + string cacheName = "sc"; + string storageTargetName = "st1"; + ResourceIdentifier storageTargetResourceId = StorageTargetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, cacheName, storageTargetName); + StorageTargetResource storageTarget = client.GetStorageTargetResource(storageTargetResourceId); + + // invoke the operation + await storageTarget.RefreshDnsAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Flush_StorageTargetsFlush() diff --git a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 8a6e85fc511b8..f5e205cdf6687 100644 --- a/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/storagecache/Azure.ResourceManager.StorageCache/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.StorageCache.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAmlFileSystems_AmlFilesystemsList() + { + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/amlFilesystems_List.json + // this example is just showing the usage of "amlFilesystems_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AmlFileSystemResource item in subscriptionResource.GetAmlFileSystemsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AmlFileSystemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CheckAmlFSSubnets_CheckAmlFSSubnets() @@ -36,7 +67,7 @@ public async Task CheckAmlFSSubnets_CheckAmlFSSubnets() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - AmlFileSystemSubnetContent content = new AmlFileSystemSubnetContent() + AmlFileSystemSubnetContent content = new AmlFileSystemSubnetContent { FilesystemSubnet = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/scgroup/providers/Microsoft.Network/virtualNetworks/scvnet/subnets/fsSub", StorageCapacityTiB = 16, @@ -152,5 +183,36 @@ public async Task GetStorageCacheUsages_AscUsagesList() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetStorageCaches_CachesList() + { + // Generated from example definition: specification/storagecache/resource-manager/Microsoft.StorageCache/stable/2024-03-01/examples/Caches_List.json + // this example is just showing the usage of "Caches_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (StorageCacheResource item in subscriptionResource.GetStorageCachesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StorageCacheData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } From a27c9d7157175f2a81c340e55691ed56d1dc386a Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 04:05:32 +0000 Subject: [PATCH 09/11] Update SDK code co_de_2 --- .../Samples/Sample_ComputeFleetCollection.cs | 447 +++---- .../Samples/Sample_ComputeFleetResource.cs | 284 ++-- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Sample_ConfidentialLedgerCollection.cs | 134 +- .../Sample_ConfidentialLedgerResource.cs | 50 +- .../Samples/Sample_ManagedCcfCollection.cs | 135 +- .../Samples/Sample_ManagedCcfResource.cs | 38 +- .../Sample_SubscriptionResourceExtensions.cs | 64 +- .../Sample_ConfluentOrganizationCollection.cs | 125 +- .../Sample_ConfluentOrganizationResource.cs | 116 +- .../Sample_ResourceGroupResourceExtensions.cs | 14 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Sample_SubscriptionResourceExtensions.cs | 236 ++++ .../Sample_VCenterInventoryItemCollection.cs | 62 +- .../Sample_VCenterInventoryItemResource.cs | 40 +- .../Samples/Sample_VMwareClusterCollection.cs | 64 +- .../Samples/Sample_VMwareClusterResource.cs | 74 +- .../Sample_VMwareDatastoreCollection.cs | 64 +- .../Samples/Sample_VMwareDatastoreResource.cs | 74 +- .../Samples/Sample_VMwareHostCollection.cs | 64 +- .../Samples/Sample_VMwareHostResource.cs | 74 +- .../Sample_VMwareResourcePoolCollection.cs | 64 +- .../Sample_VMwareResourcePoolResource.cs | 74 +- .../Samples/Sample_VMwareVCenterCollection.cs | 66 +- .../Samples/Sample_VMwareVCenterResource.cs | 74 +- .../Sample_VMwareVirtualNetworkCollection.cs | 64 +- .../Sample_VMwareVirtualNetworkResource.cs | 74 +- .../Sample_VMwareVmInstanceResource.cs | 86 +- .../Sample_VMwareVmTemplateCollection.cs | 64 +- .../Sample_VMwareVmTemplateResource.cs | 74 +- .../Sample_VmInstanceGuestAgentResource.cs | 60 +- .../Sample_ConsumptionBudgetCollection.cs | 72 +- ...Sample_ContainerAppAuthConfigCollection.cs | 142 +- .../Sample_ContainerAppAuthConfigResource.cs | 68 +- .../Samples/Sample_ContainerAppCollection.cs | 474 +++---- ...nnectedEnvironmentCertificateCollection.cs | 105 +- ...ConnectedEnvironmentCertificateResource.cs | 4 +- ...tainerAppConnectedEnvironmentCollection.cs | 117 +- ...ectedEnvironmentDaprComponentCollection.cs | 157 ++- ...nnectedEnvironmentDaprComponentResource.cs | 81 +- ...ontainerAppConnectedEnvironmentResource.cs | 34 +- ...ppConnectedEnvironmentStorageCollection.cs | 112 +- ...rAppConnectedEnvironmentStorageResource.cs | 50 +- .../Sample_ContainerAppDetectorCollection.cs | 48 +- ...erAppDetectorPropertyRevisionCollection.cs | 48 +- .../Sample_ContainerAppJobCollection.cs | 325 +++-- ...ample_ContainerAppJobDetectorCollection.cs | 48 +- ...mple_ContainerAppJobExecutionCollection.cs | 48 +- ...Sample_ContainerAppJobExecutionResource.cs | 51 +- .../Samples/Sample_ContainerAppJobResource.cs | 108 +- ...ontainerAppManagedCertificateCollection.cs | 98 +- ..._ContainerAppManagedCertificateResource.cs | 4 +- ...ManagedEnvironmentCertificateCollection.cs | 105 +- ...ppManagedEnvironmentCertificateResource.cs | 4 +- ...ontainerAppManagedEnvironmentCollection.cs | 279 ++-- ...nagedEnvironmentDaprComponentCollection.cs | 293 ++--- ...ManagedEnvironmentDaprComponentResource.cs | 101 +- ...AppManagedEnvironmentDetectorCollection.cs | 48 +- ..._ContainerAppManagedEnvironmentResource.cs | 38 +- ...rAppManagedEnvironmentStorageCollection.cs | 108 +- ...nerAppManagedEnvironmentStorageResource.cs | 50 +- .../Sample_ContainerAppReplicaCollection.cs | 62 +- .../Samples/Sample_ContainerAppResource.cs | 115 +- .../Sample_ContainerAppRevisionCollection.cs | 48 +- ...ple_ContainerAppSourceControlCollection.cs | 136 +- ...ample_ContainerAppSourceControlResource.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 148 +++ .../Sample_ContainerGroupCollection.cs | 779 ++++++----- .../Sample_ContainerGroupProfileCollection.cs | 628 ++++----- .../Sample_ContainerGroupProfileResource.cs | 80 +- ...ContainerGroupProfileRevisionCollection.cs | 48 +- .../Samples/Sample_ContainerGroupResource.cs | 74 +- .../Sample_SubscriptionResourceExtensions.cs | 62 + ...ample_ConnectedClusterBgpPeerCollection.cs | 120 +- .../Sample_ConnectedClusterBgpPeerResource.cs | 38 +- ..._ConnectedClusterLoadBalancerCollection.cs | 135 +- ...le_ConnectedClusterLoadBalancerResource.cs | 53 +- ...ample_ConnectedClusterServiceCollection.cs | 120 +- .../Sample_ConnectedClusterServiceResource.cs | 38 +- ..._ConnectedClusterStorageClassCollection.cs | 120 +- ...le_ConnectedClusterStorageClassResource.cs | 50 +- ...le_ContainerRegistryAgentPoolCollection.cs | 102 +- ...mple_ContainerRegistryAgentPoolResource.cs | 2 +- .../Sample_ContainerRegistryCollection.cs | 140 +- ...stryPrivateEndpointConnectionCollection.cs | 104 +- ...gistryPrivateEndpointConnectionResource.cs | 46 +- ...erRegistryPrivateLinkResourceCollection.cs | 48 +- ..._ContainerRegistryReplicationCollection.cs | 140 +- ...le_ContainerRegistryReplicationResource.cs | 4 +- .../Sample_ContainerRegistryResource.cs | 351 ++--- .../Sample_ContainerRegistryRunCollection.cs | 52 +- .../Sample_ContainerRegistryRunResource.cs | 2 +- .../Sample_ContainerRegistryTaskCollection.cs | 432 +++---- .../Sample_ContainerRegistryTaskResource.cs | 156 +-- ...mple_ContainerRegistryTaskRunCollection.cs | 110 +- ...Sample_ContainerRegistryTaskRunResource.cs | 6 +- ...Sample_ContainerRegistryTokenCollection.cs | 117 +- .../Sample_ContainerRegistryTokenResource.cs | 11 +- ...mple_ContainerRegistryWebhookCollection.cs | 121 +- ...Sample_ContainerRegistryWebhookResource.cs | 11 +- .../Samples/Sample_ScopeMapCollection.cs | 101 +- .../Samples/Sample_ScopeMapResource.cs | 7 +- .../Sample_SubscriptionResourceExtensions.cs | 101 ++ .../Sample_AgentPoolSnapshotCollection.cs | 106 +- .../Sample_AgentPoolSnapshotResource.cs | 76 +- ...ple_ContainerServiceAgentPoolCollection.cs | 376 +++--- ...ample_ContainerServiceAgentPoolResource.cs | 128 +- ...rviceMaintenanceConfigurationCollection.cs | 250 ++-- ...ServiceMaintenanceConfigurationResource.cs | 126 +- ...ontainerServiceManagedClusterCollection.cs | 969 ++++++-------- ..._ContainerServiceManagedClusterResource.cs | 140 +- ...vicePrivateEndpointConnectionCollection.cs | 102 +- ...ervicePrivateEndpointConnectionResource.cs | 44 +- ...rviceTrustedAccessRoleBindingCollection.cs | 95 +- ...ServiceTrustedAccessRoleBindingResource.cs | 35 +- .../Sample_MeshRevisionProfileCollection.cs | 48 +- .../Sample_MeshUpgradeProfileCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 62 + .../Sample_CassandraClusterCollection.cs | 161 ++- .../Sample_CassandraClusterResource.cs | 58 +- .../Sample_CassandraDataCenterCollection.cs | 108 +- .../Sample_CassandraDataCenterResource.cs | 4 +- .../Sample_CassandraKeyspaceCollection.cs | 104 +- .../Sample_CassandraKeyspaceResource.cs | 42 +- ...sandraKeyspaceThroughputSettingResource.cs | 6 +- .../Sample_CassandraTableCollection.cs | 153 +-- .../Samples/Sample_CassandraTableResource.cs | 83 +- ...CassandraTableThroughputSettingResource.cs | 6 +- ...Sample_CassandraViewGetResultCollection.cs | 104 +- .../Sample_CassandraViewGetResultResource.cs | 42 +- ..._CassandraViewThroughputSettingResource.cs | 6 +- .../Sample_CosmosDBAccountCollection.cs | 278 ++-- .../Samples/Sample_CosmosDBAccountResource.cs | 143 +-- .../Sample_CosmosDBChaosFaultResource.cs | 40 +- ...le_CosmosDBChaosFaultResourceCollection.cs | 74 +- .../Sample_CosmosDBLocationCollection.cs | 48 +- ...osDBPrivateEndpointConnectionCollection.cs | 104 +- ...smosDBPrivateEndpointConnectionResource.cs | 46 +- ...e_CosmosDBPrivateLinkResourceCollection.cs | 48 +- .../Sample_CosmosDBServiceCollection.cs | 228 ++-- .../Samples/Sample_CosmosDBServiceResource.cs | 218 ++-- ...osmosDBSqlClientEncryptionKeyCollection.cs | 115 +- ..._CosmosDBSqlClientEncryptionKeyResource.cs | 7 +- .../Sample_CosmosDBSqlContainerCollection.cs | 385 +++--- .../Sample_CosmosDBSqlContainerResource.cs | 155 +-- ...DBSqlContainerThroughputSettingResource.cs | 21 +- .../Sample_CosmosDBSqlDatabaseCollection.cs | 152 ++- .../Sample_CosmosDBSqlDatabaseResource.cs | 66 +- ...sDBSqlDatabaseThroughputSettingResource.cs | 21 +- ...ple_CosmosDBSqlRoleAssignmentCollection.cs | 94 +- ...ample_CosmosDBSqlRoleAssignmentResource.cs | 42 +- ...ple_CosmosDBSqlRoleDefinitionCollection.cs | 115 +- ...ample_CosmosDBSqlRoleDefinitionResource.cs | 63 +- ...le_CosmosDBSqlStoredProcedureCollection.cs | 104 +- ...mple_CosmosDBSqlStoredProcedureResource.cs | 44 +- .../Sample_CosmosDBSqlTriggerCollection.cs | 108 +- .../Sample_CosmosDBSqlTriggerResource.cs | 48 +- ...osmosDBSqlUserDefinedFunctionCollection.cs | 104 +- ..._CosmosDBSqlUserDefinedFunctionResource.cs | 44 +- .../Samples/Sample_CosmosDBTableCollection.cs | 104 +- .../Samples/Sample_CosmosDBTableResource.cs | 44 +- ...CosmosDBThroughputPoolAccountCollection.cs | 102 +- ...e_CosmosDBThroughputPoolAccountResource.cs | 44 +- ...Sample_CosmosDBThroughputPoolCollection.cs | 104 +- .../Sample_CosmosDBThroughputPoolResource.cs | 74 +- ...le_CosmosTableThroughputSettingResource.cs | 6 +- ...mple_DataTransferJobGetResultCollection.cs | 62 +- ...Sample_DataTransferJobGetResultResource.cs | 26 +- ...Sample_GraphResourceGetResultCollection.cs | 108 +- .../Sample_GraphResourceGetResultResource.cs | 48 +- .../Sample_GremlinDatabaseCollection.cs | 104 +- .../Samples/Sample_GremlinDatabaseResource.cs | 42 +- ...remlinDatabaseThroughputSettingResource.cs | 6 +- .../Samples/Sample_GremlinGraphCollection.cs | 195 ++- .../Samples/Sample_GremlinGraphResource.cs | 105 +- ...e_GremlinGraphThroughputSettingResource.cs | 6 +- .../Sample_MongoDBCollectionCollection.cs | 203 ++- .../Sample_MongoDBCollectionResource.cs | 93 +- ...goDBCollectionThroughputSettingResource.cs | 121 +- .../Sample_MongoDBDatabaseCollection.cs | 152 ++- .../Samples/Sample_MongoDBDatabaseResource.cs | 66 +- ...ongoDBDatabaseThroughputSettingResource.cs | 21 +- .../Sample_MongoDBRoleDefinitionCollection.cs | 129 +- .../Sample_MongoDBRoleDefinitionResource.cs | 77 +- .../Sample_MongoDBUserDefinitionCollection.cs | 111 +- .../Sample_MongoDBUserDefinitionResource.cs | 59 +- ...ecurityPerimeterConfigurationCollection.cs | 48 +- ...ple_RestorableCosmosDBAccountCollection.cs | 48 +- ...ample_RestorableCosmosDBAccountResource.cs | 32 - .../Sample_SubscriptionResourceExtensions.cs | 143 +++ .../Sample_TenantResourceExtensions.cs | 40 + ..._CosmosDBForPostgreSqlClusterCollection.cs | 80 +- ...le_CosmosDBForPostgreSqlClusterResource.cs | 69 +- ...sDBForPostgreSqlClusterServerCollection.cs | 48 +- ...sDBForPostgreSqlConfigurationCollection.cs | 48 +- ...reSqlCoordinatorConfigurationCollection.cs | 72 +- ...tgreSqlCoordinatorConfigurationResource.cs | 2 +- ...osDBForPostgreSqlFirewallRuleCollection.cs | 62 +- ...smosDBForPostgreSqlFirewallRuleResource.cs | 20 +- ...orPostgreSqlNodeConfigurationCollection.cs | 72 +- ...BForPostgreSqlNodeConfigurationResource.cs | 2 +- ...eSqlPrivateEndpointConnectionCollection.cs | 108 +- ...greSqlPrivateEndpointConnectionResource.cs | 46 +- ...PostgreSqlPrivateLinkResourceCollection.cs | 52 +- ...ple_CosmosDBForPostgreSqlRoleCollection.cs | 84 +- ...ample_CosmosDBForPostgreSqlRoleResource.cs | 32 +- .../Sample_SubscriptionResourceExtensions.cs | 76 ++ .../Sample_CostManagementAlertCollection.cs | 194 +-- .../Sample_CostManagementAlertResource.cs | 66 +- .../Sample_CostManagementExportCollection.cs | 1144 ++++++++--------- .../Sample_CostManagementExportResource.cs | 366 +++--- .../Sample_CostManagementViewsCollection.cs | 213 ++- .../Sample_CostManagementViewsResource.cs | 87 +- .../Sample_ScheduledActionCollection.cs | 185 +-- .../Samples/Sample_ScheduledActionResource.cs | 119 +- .../Sample_TenantResourceExtensions.cs | 305 ++--- .../Sample_TenantScheduledActionCollection.cs | 34 +- .../Sample_TenantScheduledActionResource.cs | 77 +- ...le_TenantsCostManagementViewsCollection.cs | 178 ++- ...mple_TenantsCostManagementViewsResource.cs | 85 +- ...orizationPolicyResourceFormatCollection.cs | 69 +- ...thorizationPolicyResourceFormatResource.cs | 29 +- ...onnectorMappingResourceFormatCollection.cs | 73 +- ..._ConnectorMappingResourceFormatResource.cs | 109 +- ...ample_ConnectorResourceFormatCollection.cs | 72 +- .../Sample_ConnectorResourceFormatResource.cs | 66 +- .../Generated/Samples/Sample_HubCollection.cs | 64 +- .../Generated/Samples/Sample_HubResource.cs | 70 +- ...ple_InteractionResourceFormatCollection.cs | 76 +- ...ample_InteractionResourceFormatResource.cs | 56 +- .../Sample_KpiResourceFormatCollection.cs | 78 +- .../Sample_KpiResourceFormatResource.cs | 84 +- .../Sample_LinkResourceFormatCollection.cs | 80 +- .../Sample_LinkResourceFormatResource.cs | 84 +- ...mple_PredictionResourceFormatCollection.cs | 84 +- ...Sample_PredictionResourceFormatResource.cs | 92 +- .../Sample_ProfileResourceFormatCollection.cs | 90 +- .../Sample_ProfileResourceFormatResource.cs | 110 +- ...elationshipLinkResourceFormatCollection.cs | 78 +- ..._RelationshipLinkResourceFormatResource.cs | 74 +- ...le_RelationshipResourceFormatCollection.cs | 72 +- ...mple_RelationshipResourceFormatResource.cs | 70 +- ..._RoleAssignmentResourceFormatCollection.cs | 69 +- ...le_RoleAssignmentResourceFormatResource.cs | 51 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Sample_ViewResourceFormatCollection.cs | 76 +- .../Sample_ViewResourceFormatResource.cs | 58 +- ...mple_WidgetTypeResourceFormatCollection.cs | 48 +- .../Samples/Sample_DataBoxJobCollection.cs | 638 +++++---- .../Samples/Sample_DataBoxJobResource.cs | 94 +- .../Sample_ResourceGroupResourceExtensions.cs | 20 +- .../Sample_SubscriptionResourceExtensions.cs | 51 +- .../Sample_BandwidthScheduleCollection.cs | 96 +- .../Sample_BandwidthScheduleResource.cs | 36 +- .../Sample_DataBoxEdgeAlertCollection.cs | 48 +- .../Sample_DataBoxEdgeDeviceCollection.cs | 208 ++- .../Sample_DataBoxEdgeDeviceResource.cs | 41 +- .../Sample_DataBoxEdgeOrderResource.cs | 59 +- .../Sample_DataBoxEdgeRoleAddonCollection.cs | 96 +- .../Sample_DataBoxEdgeRoleAddonResource.cs | 32 +- .../Sample_DataBoxEdgeRoleCollection.cs | 130 +- .../Samples/Sample_DataBoxEdgeRoleResource.cs | 60 +- .../Sample_DataBoxEdgeShareCollection.cs | 105 +- .../Sample_DataBoxEdgeShareResource.cs | 47 +- ...ple_DataBoxEdgeStorageAccountCollection.cs | 100 +- ...xEdgeStorageAccountCredentialCollection.cs | 104 +- ...BoxEdgeStorageAccountCredentialResource.cs | 46 +- ...ample_DataBoxEdgeStorageAccountResource.cs | 46 +- ...e_DataBoxEdgeStorageContainerCollection.cs | 92 +- ...ple_DataBoxEdgeStorageContainerResource.cs | 32 +- .../Sample_DataBoxEdgeTriggerCollection.cs | 96 +- .../Sample_DataBoxEdgeTriggerResource.cs | 38 +- .../Sample_DataBoxEdgeUserCollection.cs | 102 +- .../Samples/Sample_DataBoxEdgeUserResource.cs | 44 +- ..._DiagnosticRemoteSupportSettingResource.cs | 9 +- ...e_MonitoringMetricConfigurationResource.cs | 56 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Samples/Sample_DatadogMonitorResource.cs | 166 +-- ...Sample_DatadogMonitorResourceCollection.cs | 92 +- .../Sample_DatadogSingleSignOnResource.cs | 20 +- ...e_DatadogSingleSignOnResourceCollection.cs | 60 +- .../Sample_MonitoringTagRuleCollection.cs | 60 +- .../Sample_MonitoringTagRuleResource.cs | 20 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + ..._DataFactoryChangeDataCaptureCollection.cs | 48 +- .../Samples/Sample_DataFactoryCollection.cs | 60 +- .../Sample_DataFactoryDataFlowCollection.cs | 128 +- .../Sample_DataFactoryDataFlowResource.cs | 142 +- .../Sample_DataFactoryDatasetCollection.cs | 88 +- .../Sample_DataFactoryDatasetResource.cs | 94 +- ...le_DataFactoryGlobalParameterCollection.cs | 124 +- ...mple_DataFactoryGlobalParameterResource.cs | 46 +- ...DataFactoryIntegrationRuntimeCollection.cs | 64 +- ...e_DataFactoryIntegrationRuntimeResource.cs | 46 +- ...mple_DataFactoryLinkedServiceCollection.cs | 74 +- ...Sample_DataFactoryLinkedServiceResource.cs | 66 +- ...aFactoryManagedVirtualNetworkCollection.cs | 60 +- ...ataFactoryManagedVirtualNetworkResource.cs | 20 +- .../Sample_DataFactoryPipelineCollection.cs | 171 ++- .../Sample_DataFactoryPipelineResource.cs | 221 ++-- ...le_DataFactoryPrivateEndpointCollection.cs | 70 +- ...toryPrivateEndpointConnectionCollection.cs | 78 +- ...actoryPrivateEndpointConnectionResource.cs | 64 +- ...mple_DataFactoryPrivateEndpointResource.cs | 52 +- .../Samples/Sample_DataFactoryResource.cs | 252 ++-- ..._DataFactoryServiceCredentialCollection.cs | 64 +- ...le_DataFactoryServiceCredentialResource.cs | 46 +- .../Sample_DataFactoryTriggerCollection.cs | 104 +- .../Sample_DataFactoryTriggerResource.cs | 134 +- .../Sample_SubscriptionResourceExtensions.cs | 71 +- ...mple_DataLakeAnalyticsAccountCollection.cs | 85 +- ...Sample_DataLakeAnalyticsAccountResource.cs | 115 +- ...ataLakeAnalyticsComputePolicyCollection.cs | 66 +- ..._DataLakeAnalyticsComputePolicyResource.cs | 38 +- ...DataLakeAnalyticsFirewallRuleCollection.cs | 60 +- ...e_DataLakeAnalyticsFirewallRuleResource.cs | 38 +- ...ticsStorageAccountInformationCollection.cs | 64 +- ...lyticsStorageAccountInformationResource.cs | 26 +- ...LakeAnalyticsStorageContainerCollection.cs | 48 +- ...taLakeStoreAccountInformationCollection.cs | 68 +- ...DataLakeStoreAccountInformationResource.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 54 + .../Sample_DataMigrationServiceCollection.cs | 64 +- .../Sample_DataMigrationServiceResource.cs | 64 +- ...Sample_DatabaseMigrationSqlDBCollection.cs | 241 ++-- .../Sample_DatabaseMigrationSqlDBResource.cs | 77 +- ...Sample_DatabaseMigrationSqlMICollection.cs | 278 ++-- .../Sample_DatabaseMigrationSqlMIResource.cs | 34 +- ...Sample_DatabaseMigrationSqlVmCollection.cs | 278 ++-- .../Sample_DatabaseMigrationSqlVmResource.cs | 34 +- .../Samples/Sample_ProjectCollection.cs | 66 +- .../Samples/Sample_ProjectFileCollection.cs | 102 +- .../Samples/Sample_ProjectFileResource.cs | 4 +- .../Sample_ServiceProjectTaskCollection.cs | 78 +- .../Sample_ServiceProjectTaskResource.cs | 6 +- .../Sample_ServiceServiceTaskCollection.cs | 70 +- .../Sample_ServiceServiceTaskResource.cs | 4 +- .../Sample_SqlMigrationServiceCollection.cs | 120 +- .../Sample_SqlMigrationServiceResource.cs | 40 +- .../Sample_SubscriptionResourceExtensions.cs | 92 ++ .../Sample_DataShareAccountCollection.cs | 106 +- .../Sample_DataShareAccountResource.cs | 36 +- .../Samples/Sample_DataShareCollection.cs | 94 +- ...e_DataShareConsumerInvitationCollection.cs | 67 +- ...ple_DataShareConsumerInvitationResource.cs | 28 - .../Sample_DataShareInvitationCollection.cs | 92 +- .../Sample_DataShareInvitationResource.cs | 40 +- .../Samples/Sample_DataShareResource.cs | 104 +- ...taShareSynchronizationSettingCollection.cs | 88 +- ...DataShareSynchronizationSettingResource.cs | 38 +- .../Sample_DataShareTriggerCollection.cs | 90 +- .../Sample_DataShareTriggerResource.cs | 40 +- ...ple_ProviderShareSubscriptionCollection.cs | 62 +- ...ample_ProviderShareSubscriptionResource.cs | 44 +- .../Samples/Sample_ShareDataSetCollection.cs | 226 ++-- .../Sample_ShareDataSetMappingCollection.cs | 172 +-- .../Sample_ShareDataSetMappingResource.cs | 72 +- .../Samples/Sample_ShareDataSetResource.cs | 92 +- .../Sample_ShareSubscriptionCollection.cs | 90 +- .../Sample_ShareSubscriptionResource.cs | 170 +-- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Sample_TenantResourceExtensions.cs | 37 +- .../Samples/Sample_EasmLabelCollection.cs | 92 +- .../Samples/Sample_EasmLabelResource.cs | 30 +- .../Samples/Sample_EasmWorkspaceCollection.cs | 92 +- .../Samples/Sample_EasmWorkspaceResource.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Sample_AppAttachPackageCollection.cs | 172 ++- .../Sample_AppAttachPackageResource.cs | 33 - .../Samples/Sample_HostPoolCollection.cs | 169 ++- ...PoolPrivateEndpointConnectionCollection.cs | 106 +- ...stPoolPrivateEndpointConnectionResource.cs | 4 +- .../Samples/Sample_HostPoolResource.cs | 136 +- .../Samples/Sample_MsixPackageCollection.cs | 154 ++- .../Samples/Sample_MsixPackageResource.cs | 2 +- .../Samples/Sample_ScalingPlanCollection.cs | 171 ++- ...e_ScalingPlanPersonalScheduleCollection.cs | 161 ++- ...ple_ScalingPlanPersonalScheduleResource.cs | 2 +- ...ple_ScalingPlanPooledScheduleCollection.cs | 129 +- ...ample_ScalingPlanPooledScheduleResource.cs | 7 +- .../Samples/Sample_ScalingPlanResource.cs | 35 - .../Samples/Sample_SessionHostCollection.cs | 68 +- .../Samples/Sample_SessionHostResource.cs | 2 +- .../Sample_SubscriptionResourceExtensions.cs | 182 +++ .../Samples/Sample_UserSessionCollection.cs | 68 +- .../Samples/Sample_UserSessionResource.cs | 2 +- .../Sample_VirtualApplicationCollection.cs | 108 +- ...ample_VirtualApplicationGroupCollection.cs | 112 +- .../Sample_VirtualApplicationGroupResource.cs | 37 +- .../Sample_VirtualApplicationResource.cs | 2 +- .../Sample_VirtualDesktopCollection.cs | 68 +- .../Samples/Sample_VirtualDesktopResource.cs | 2 +- .../Sample_VirtualWorkspaceCollection.cs | 108 +- .../Sample_VirtualWorkspaceResource.cs | 36 +- ...pacePrivateEndpointConnectionCollection.cs | 106 +- ...kspacePrivateEndpointConnectionResource.cs | 4 +- ...Sample_AllowedEnvironmentTypeCollection.cs | 48 +- ...ple_AttachedNetworkConnectionCollection.cs | 96 +- ...ample_AttachedNetworkConnectionResource.cs | 38 +- .../Sample_DevBoxDefinitionCollection.cs | 106 +- .../Sample_DevBoxDefinitionResource.cs | 44 +- .../Sample_DevCenterCatalogCollection.cs | 148 +-- .../Sample_DevCenterCatalogResource.cs | 44 +- .../Samples/Sample_DevCenterCollection.cs | 150 +-- ...mple_DevCenterEnvironmentTypeCollection.cs | 102 +- ...Sample_DevCenterEnvironmentTypeResource.cs | 42 +- .../Sample_DevCenterGalleryCollection.cs | 96 +- .../Sample_DevCenterGalleryResource.cs | 38 +- .../Sample_DevCenterImageCollection.cs | 52 +- ...le_DevCenterNetworkConnectionCollection.cs | 106 +- ...mple_DevCenterNetworkConnectionResource.cs | 74 +- .../Samples/Sample_DevCenterPoolCollection.cs | 126 +- .../Samples/Sample_DevCenterPoolResource.cs | 42 +- .../Sample_DevCenterProjectCollection.cs | 146 +-- ...e_DevCenterProjectEnvironmentCollection.cs | 148 +-- ...ple_DevCenterProjectEnvironmentResource.cs | 66 +- .../Sample_DevCenterProjectResource.cs | 78 +- .../Samples/Sample_DevCenterResource.cs | 76 +- .../Sample_DevCenterScheduleCollection.cs | 108 +- .../Sample_DevCenterScheduleResource.cs | 38 +- .../Samples/Sample_ImageVersionCollection.cs | 48 +- ...jectAttachedNetworkConnectionCollection.cs | 48 +- ...ample_ProjectDevBoxDefinitionCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 95 +- 424 files changed, 19267 insertions(+), 21207 deletions(-) create mode 100644 sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_TenantResourceExtensions.cs create mode 100644 sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_ComputeFleetCollection.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_ComputeFleetCollection.cs index c0a789ffe1394..f86e57bcb360d 100644 --- a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_ComputeFleetCollection.cs +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_ComputeFleetCollection.cs @@ -19,109 +19,6 @@ namespace Azure.ResourceManager.ComputeFleet.Samples { public partial class Sample_ComputeFleetCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_FleetsGet() - { - // Generated from example definition: 2024-11-01/Fleets_Get.json - // this example is just showing the usage of "Fleet_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "1DC2F28C-A625-4B0E-9748-9885A3C9E9EB"; - string resourceGroupName = "rgazurefleet"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ComputeFleetResource - ComputeFleetCollection collection = resourceGroupResource.GetComputeFleets(); - - // invoke the operation - string fleetName = "testFleet"; - ComputeFleetResource result = await collection.GetAsync(fleetName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ComputeFleetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_FleetsGet() - { - // Generated from example definition: 2024-11-01/Fleets_Get.json - // this example is just showing the usage of "Fleet_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "1DC2F28C-A625-4B0E-9748-9885A3C9E9EB"; - string resourceGroupName = "rgazurefleet"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ComputeFleetResource - ComputeFleetCollection collection = resourceGroupResource.GetComputeFleets(); - - // invoke the operation - string fleetName = "testFleet"; - bool result = await collection.ExistsAsync(fleetName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FleetsGet() - { - // Generated from example definition: 2024-11-01/Fleets_Get.json - // this example is just showing the usage of "Fleet_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "1DC2F28C-A625-4B0E-9748-9885A3C9E9EB"; - string resourceGroupName = "rgazurefleet"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ComputeFleetResource - ComputeFleetCollection collection = resourceGroupResource.GetComputeFleets(); - - // invoke the operation - string fleetName = "testFleet"; - NullableResponse response = await collection.GetIfExistsAsync(fleetName); - ComputeFleetResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ComputeFleetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_FleetsCreateOrUpdate() @@ -154,67 +51,58 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() { Rank = 19225, } - }, new ComputeFleetComputeProfile(new ComputeFleetVmProfile() + }, new ComputeFleetComputeProfile(new ComputeFleetVmProfile { - OSProfile = new ComputeFleetVmssOSProfile() + OSProfile = new ComputeFleetVmssOSProfile { ComputerNamePrefix = "o", AdminUsername = "nrgzqciiaaxjrqldbmjbqkyhntp", AdminPassword = "adfbrdxpv", CustomData = "xjjib", - WindowsConfiguration = new ComputeFleetWindowsConfiguration() + WindowsConfiguration = new ComputeFleetWindowsConfiguration { IsVmAgentProvisioned = true, IsAutomaticUpdatesEnabled = true, TimeZone = "hlyjiqcfksgrpjrct", - AdditionalUnattendContent = - { -new WindowsSetupAdditionalInformation() + AdditionalUnattendContent = {new WindowsSetupAdditionalInformation { PassName = WindowsSetupAdditionalInformationPassName.OobeSystem, ComponentName = WindowsSetupAdditionalInformationComponentName.MicrosoftWindowsShellSetup, SettingName = AdditionalInformationSettingName.AutoLogon, Content = "bubmqbxjkj", -} - }, - PatchSettings = new ComputeFleetVmGuestPatchSettings() +}}, + PatchSettings = new ComputeFleetVmGuestPatchSettings { PatchMode = ComputeFleetWindowsVmGuestPatchMode.Manual, IsHotPatchingEnabled = true, AssessmentMode = ComputeFleetWindowsPatchAssessmentMode.ImageDefault, - AutomaticByPlatformSettings = new ComputeFleetWindowsVmGuestPatchAutomaticByPlatformSettings() + AutomaticByPlatformSettings = new ComputeFleetWindowsVmGuestPatchAutomaticByPlatformSettings { RebootSetting = ComputeFleetWindowsVmGuestPatchAutomaticByPlatformRebootSetting.Unknown, IsBypassPlatformSafetyChecksOnUserScheduleEnabled = true, }, }, - WinRMListeners = - { -new ComputeFleetWinRMListener() + WinRMListeners = {new ComputeFleetWinRMListener { Protocol = ComputeFleetProtocolType.Https, CertificateUri = new Uri("https://myVaultName.vault.azure.net/secrets/myCertName"), -} - }, +}}, IsVmAgentPlatformUpdatesEnabled = true, }, - LinuxConfiguration = new ComputeFleetLinuxConfiguration() + LinuxConfiguration = new ComputeFleetLinuxConfiguration { IsPasswordAuthenticationDisabled = true, - SshPublicKeys = - { -new ComputeFleetSshPublicKey() + SshPublicKeys = {new ComputeFleetSshPublicKey { Path = "kmqz", KeyData = "kivgsubusvpprwqaqpjcmhsv", -} - }, +}}, IsVmAgentProvisioned = true, - PatchSettings = new ComputeFleetLinuxPatchSettings() + PatchSettings = new ComputeFleetLinuxPatchSettings { PatchMode = ComputeFleetLinuxVmGuestPatchMode.ImageDefault, AssessmentMode = ComputeFleetLinuxPatchAssessmentMode.ImageDefault, - AutomaticByPlatformSettings = new ComputeFleetLinuxVmGuestPatchAutomaticByPlatformSettings() + AutomaticByPlatformSettings = new ComputeFleetLinuxVmGuestPatchAutomaticByPlatformSettings { RebootSetting = ComputeFleetLinuxVmGuestPatchAutomaticByPlatformRebootSetting.Unknown, IsBypassPlatformSafetyChecksOnUserScheduleEnabled = true, @@ -222,27 +110,21 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() }, IsVmAgentPlatformUpdatesEnabled = true, }, - Secrets = - { -new ComputeFleetVaultSecretGroup() + Secrets = {new ComputeFleetVaultSecretGroup { SourceVaultId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}"), -VaultCertificates = -{ -new ComputeFleetVaultCertificate() +VaultCertificates = {new ComputeFleetVaultCertificate { CertificateUri = new Uri("https://myVaultName.vault.azure.net/secrets/myCertName"), CertificateStore = "nlxrwavpzhueffxsshlun", -} -}, -} - }, +}}, +}}, AreExtensionOperationsAllowed = true, IsGuestProvisionSignalRequired = true, }, - StorageProfile = new ComputeFleetVmssStorageProfile() + StorageProfile = new ComputeFleetVmssStorageProfile { - ImageReference = new ComputeFleetImageReference() + ImageReference = new ComputeFleetImageReference { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}/versions/{versionName}"), Publisher = "mqxgwbiyjzmxavhbkd", @@ -257,7 +139,7 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() Name = "wfttw", Caching = ComputeFleetCachingType.None, IsWriteAcceleratorEnabled = true, - DiffDiskSettings = new ComputeFleetDiffDiskSettings() + DiffDiskSettings = new ComputeFleetDiffDiskSettings { Option = ComputeFleetDiffDiskOption.Local, Placement = ComputeFleetDiffDiskPlacement.CacheDisk, @@ -265,15 +147,12 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() DiskSizeGB = 14, OSType = ComputeFleetOperatingSystemType.Windows, ImageUri = new Uri("https://myStorageAccountName.blob.core.windows.net/myContainerName/myVhdName.vhd"), - VhdContainers = - { -"tkzcwddtinkfpnfklatw" - }, - ManagedDisk = new ComputeFleetVmssManagedDisk() + VhdContainers = { "tkzcwddtinkfpnfklatw" }, + ManagedDisk = new ComputeFleetVmssManagedDisk { StorageAccountType = ComputeFleetStorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"), - SecurityProfile = new ComputeFleetVmDiskSecurityProfile() + SecurityProfile = new ComputeFleetVmDiskSecurityProfile { SecurityEncryptionType = ComputeFleetSecurityEncryptionType.VmGuestStateOnly, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"), @@ -281,19 +160,17 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() }, DeleteOption = ComputeFleetDiskDeleteOptionType.Delete, }, - DataDisks = - { -new ComputeFleetVmssDataDisk(14,ComputeFleetDiskCreateOptionType.FromImage) + DataDisks = {new ComputeFleetVmssDataDisk(14, ComputeFleetDiskCreateOptionType.FromImage) { Name = "eogiykmdmeikswxmigjws", Caching = ComputeFleetCachingType.None, IsWriteAcceleratorEnabled = true, DiskSizeGB = 6, -ManagedDisk = new ComputeFleetVmssManagedDisk() +ManagedDisk = new ComputeFleetVmssManagedDisk { StorageAccountType = ComputeFleetStorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"), -SecurityProfile = new ComputeFleetVmDiskSecurityProfile() +SecurityProfile = new ComputeFleetVmDiskSecurityProfile { SecurityEncryptionType = ComputeFleetSecurityEncryptionType.VmGuestStateOnly, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"), @@ -302,80 +179,62 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() DiskIopsReadWrite = 27L, DiskMbpsReadWrite = 2L, DeleteOption = ComputeFleetDiskDeleteOptionType.Delete, -} - }, +}}, }, - NetworkProfile = new ComputeFleetVmssNetworkProfile() + NetworkProfile = new ComputeFleetVmssNetworkProfile { HealthProbeId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}"), - NetworkInterfaceConfigurations = - { -new ComputeFleetVmssNetworkConfiguration("i") + NetworkInterfaceConfigurations = {new ComputeFleetVmssNetworkConfiguration("i") { Properties = new ComputeFleetVmssNetworkConfigurationProperties(new ComputeFleetVmssIPConfiguration[] { new ComputeFleetVmssIPConfiguration("oezqhkidfhyywlfzwuotilrpbqnjg") { -Properties = new ComputeFleetVmssIPConfigurationProperties() +Properties = new ComputeFleetVmssIPConfigurationProperties { SubnetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}"), IsPrimary = true, PublicIPAddressConfiguration = new ComputeFleetVmssPublicIPAddressConfiguration("fvpqf") { -Properties = new ComputeFleetVmssPublicIPAddressConfigurationProperties() +Properties = new ComputeFleetVmssPublicIPAddressConfigurationProperties { IdleTimeoutInMinutes = 9, DnsSettings = new ComputeFleetVmssPublicIPAddressDnsSettings("ukrddzvmorpmfsczjwtbvp") { DomainNameLabelScope = ComputeFleetDomainNameLabelScopeType.TenantReuse, }, -IPTags = -{ -new ComputeFleetVmssIPTag() +IPTags = {new ComputeFleetVmssIPTag { IPTagType = "sddgsoemnzgqizale", Tag = "wufmhrjsakbiaetyara", -} -}, +}}, PublicIPPrefixId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPPrefixes/{publicIPPrefixName}"), PublicIPAddressVersion = ComputeFleetIPVersion.IPv4, DeleteOption = ComputeFleetVmDeleteOption.Delete, }, -Sku = new ComputeFleetPublicIPAddressSku() +Sku = new ComputeFleetPublicIPAddressSku { Name = ComputeFleetPublicIPAddressSkuName.Basic, Tier = ComputeFleetPublicIPAddressSkuTier.Regional, }, }, PrivateIPAddressVersion = ComputeFleetIPVersion.IPv4, -ApplicationGatewayBackendAddressPools = -{ -new WritableSubResource() +ApplicationGatewayBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/backendAddressPools/{backendAddressPoolName}"), -} -}, -ApplicationSecurityGroups = -{ -new WritableSubResource() +}}, +ApplicationSecurityGroups = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationSecurityGroups/{applicationSecurityGroupName}"), -} -}, -LoadBalancerBackendAddressPools = -{ -new WritableSubResource() +}}, +LoadBalancerBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{backendAddressPoolName}"), -} -}, -LoadBalancerInboundNatPools = -{ -new WritableSubResource() +}}, +LoadBalancerInboundNatPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/inboundNatPools/{inboundNatPoolName}"), -} -}, +}}, }, } }) @@ -385,22 +244,18 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() IsTcpStateTrackingDisabled = true, IsFpgaEnabled = true, NetworkSecurityGroupId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}"), -DnsServers = -{ -"nxmmfolhclsesu" -}, +DnsServers = {"nxmmfolhclsesu"}, IsIPForwardingEnabled = true, DeleteOption = ComputeFleetVmDeleteOption.Delete, AuxiliaryMode = ComputeFleetNetworkInterfaceAuxiliaryMode.None, AuxiliarySku = ComputeFleetNetworkInterfaceAuxiliarySku.None, }, -} - }, +}}, NetworkApiVersion = ComputeFleetNetworkApiVersion.V20201101, }, - SecurityProfile = new ComputeFleetSecurityProfile() + SecurityProfile = new ComputeFleetSecurityProfile { - UefiSettings = new ComputeFleetUefiSettings() + UefiSettings = new ComputeFleetUefiSettings { IsSecureBootEnabled = true, IsVTpmEnabled = true, @@ -408,26 +263,24 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() IsEncryptionAtHostEnabled = true, SecurityType = ComputeFleetSecurityType.TrustedLaunch, UserAssignedIdentityResourceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{userAssignedIdentityName}"), - ProxyAgentSettings = new ComputeFleetProxyAgentSettings() + ProxyAgentSettings = new ComputeFleetProxyAgentSettings { IsEnabled = true, Mode = ProxyAgentExecuteMode.Audit, KeyIncarnationId = 20, }, }, - BootDiagnostics = new ComputeFleetBootDiagnostics() + BootDiagnostics = new ComputeFleetBootDiagnostics { IsEnabled = true, StorageUri = new Uri("http://myStorageAccountName.blob.core.windows.net"), }, - ExtensionProfile = new ComputeFleetVmssExtensionProfile() + ExtensionProfile = new ComputeFleetVmssExtensionProfile { - Extensions = - { -new ComputeFleetVmssExtension() + Extensions = {new ComputeFleetVmssExtension { Name = "bndxuxx", -Properties = new ComputeFleetVmssExtensionProperties() +Properties = new ComputeFleetVmssExtensionProperties { ForceUpdateTag = "yhgxw", Publisher = "kpxtirxjfprhs", @@ -435,35 +288,27 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() TypeHandlerVersion = "zevivcoilxmbwlrihhhibq", ShouldAutoUpgradeMinorVersion = true, IsAutomaticUpgradeEnabled = true, -Settings = -{ -}, -ProtectedSettings = -{ -}, -ProvisionAfterExtensions = -{ -"nftzosroolbcwmpupujzqwqe" -}, +Settings = {}, +ProtectedSettings = {}, +ProvisionAfterExtensions = {"nftzosroolbcwmpupujzqwqe"}, IsSuppressFailuresEnabled = true, -ProtectedSettingsFromKeyVault = new ComputeFleetKeyVaultSecretReference(new Uri("https://myvaultName.vault.azure.net/secrets/secret/mySecretName"),new WritableSubResource() +ProtectedSettingsFromKeyVault = new ComputeFleetKeyVaultSecretReference(new Uri("https://myvaultName.vault.azure.net/secrets/secret/mySecretName"), new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}"), }), }, -} - }, +}}, ExtensionsTimeBudget = "mbhjahtdygwgyszdwjtvlvtgchdwil", }, LicenseType = "v", - ScheduledEventsProfile = new ComputeFleetScheduledEventsProfile() + ScheduledEventsProfile = new ComputeFleetScheduledEventsProfile { - TerminateNotificationProfile = new ComputeFleetTerminateNotificationProfile() + TerminateNotificationProfile = new ComputeFleetTerminateNotificationProfile { NotBeforeTimeout = "iljppmmw", IsEnabled = true, }, - OSImageNotificationProfile = new ComputeFleetOSImageNotificationProfile() + OSImageNotificationProfile = new ComputeFleetOSImageNotificationProfile { NotBeforeTimeout = "olbpadmevekyczfokodtfprxti", IsEnabled = true, @@ -471,30 +316,24 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() }, UserData = "s", CapacityReservationGroupId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}"), - GalleryApplications = - { -new ComputeFleetVmGalleryApplication(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{applicationName}/versions/{versionName}")) + GalleryApplications = {new ComputeFleetVmGalleryApplication(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{applicationName}/versions/{versionName}")) { Tags = "eyrqjbib", Order = 5, ConfigurationReference = "ulztmiavpojpbpbddgnuuiimxcpau", IsTreatFailureAsDeploymentFailureEnabled = true, IsAutomaticUpgradeEnabled = true, -} - }, - HardwareVmSizeProperties = new ComputeFleetVmSizeProperties() +}}, + HardwareVmSizeProperties = new ComputeFleetVmSizeProperties { VCPUsAvailable = 16, VCPUsPerCore = 23, }, ServiceArtifactReferenceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactsName}/vmArtifactsProfiles/{vmArtifactsProfileName}"), - SecurityPostureReference = new ComputeFleetSecurityPostureReference() + SecurityPostureReference = new ComputeFleetSecurityPostureReference { Id = "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest", - ExcludeExtensions = - { -"{securityPostureVMExtensionName}" - }, + ExcludeExtensions = { "{securityPostureVMExtensionName}" }, IsOverridable = true, }, }) @@ -503,7 +342,7 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() PlatformFaultDomainCount = 1, }) { - SpotPriorityProfile = new SpotPriorityProfile() + SpotPriorityProfile = new SpotPriorityProfile { Capacity = 20, MinCapacity = 10, @@ -512,22 +351,19 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() AllocationStrategy = SpotAllocationStrategy.PriceCapacityOptimized, IsMaintainEnabled = true, }, - RegularPriorityProfile = new RegularPriorityProfile() + RegularPriorityProfile = new RegularPriorityProfile { Capacity = 20, MinCapacity = 10, AllocationStrategy = RegularPriorityAllocationStrategy.LowestPrice, }, }, - Zones = -{ -"zone1","zone2" -}, + Zones = { "zone1", "zone2" }, Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("key9851")] = new UserAssignedIdentity(), +[new ResourceIdentifier("key9851")] = new UserAssignedIdentity() }, }, Plan = new ArmPlan("jwgrcrnrtfoxn", "iozjbiqqckqm", "cgopbyvdyqikahwyxfpzwaqk") @@ -537,7 +373,7 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdate() }, Tags = { -["key3518"] = "luvrnuvsgdpbuofdskkcoqhfh", +["key3518"] = "luvrnuvsgdpbuofdskkcoqhfh" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fleetName, data); @@ -578,22 +414,24 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdateMinimumSet() { Properties = new ComputeFleetProperties(new ComputeFleetVmSizeProfile[] { -new ComputeFleetVmSizeProfile("Standard_D2s_v3"),new ComputeFleetVmSizeProfile("Standard_D4s_v3"),new ComputeFleetVmSizeProfile("Standard_E2s_v3") - }, new ComputeFleetComputeProfile(new ComputeFleetVmProfile() +new ComputeFleetVmSizeProfile("Standard_D2s_v3"), +new ComputeFleetVmSizeProfile("Standard_D4s_v3"), +new ComputeFleetVmSizeProfile("Standard_E2s_v3") + }, new ComputeFleetComputeProfile(new ComputeFleetVmProfile { - OSProfile = new ComputeFleetVmssOSProfile() + OSProfile = new ComputeFleetVmssOSProfile { ComputerNamePrefix = "prefix", AdminUsername = "azureuser", AdminPassword = "TestPassword$0", - LinuxConfiguration = new ComputeFleetLinuxConfiguration() + LinuxConfiguration = new ComputeFleetLinuxConfiguration { IsPasswordAuthenticationDisabled = false, }, }, - StorageProfile = new ComputeFleetVmssStorageProfile() + StorageProfile = new ComputeFleetVmssStorageProfile { - ImageReference = new ComputeFleetImageReference() + ImageReference = new ComputeFleetImageReference { Publisher = "canonical", Offer = "0001-com-ubuntu-server-focal", @@ -604,33 +442,28 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdateMinimumSet() { Caching = ComputeFleetCachingType.ReadWrite, OSType = ComputeFleetOperatingSystemType.Linux, - ManagedDisk = new ComputeFleetVmssManagedDisk() + ManagedDisk = new ComputeFleetVmssManagedDisk { StorageAccountType = ComputeFleetStorageAccountType.StandardLrs, }, }, }, - NetworkProfile = new ComputeFleetVmssNetworkProfile() + NetworkProfile = new ComputeFleetVmssNetworkProfile { - NetworkInterfaceConfigurations = - { -new ComputeFleetVmssNetworkConfiguration("vmNameTest") + NetworkInterfaceConfigurations = {new ComputeFleetVmssNetworkConfiguration("vmNameTest") { Properties = new ComputeFleetVmssNetworkConfigurationProperties(new ComputeFleetVmssIPConfiguration[] { new ComputeFleetVmssIPConfiguration("vmNameTest") { -Properties = new ComputeFleetVmssIPConfigurationProperties() +Properties = new ComputeFleetVmssIPConfigurationProperties { SubnetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}"), IsPrimary = true, -LoadBalancerBackendAddressPools = -{ -new WritableSubResource() +LoadBalancerBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{backendAddressPoolName}"), -} -}, +}}, }, } }) @@ -639,8 +472,7 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdateMinimumSet() IsAcceleratedNetworkingEnabled = false, IsIPForwardingEnabled = true, }, -} - }, +}}, }, }) { @@ -648,7 +480,7 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdateMinimumSet() PlatformFaultDomainCount = 1, }) { - SpotPriorityProfile = new SpotPriorityProfile() + SpotPriorityProfile = new SpotPriorityProfile { Capacity = 2, MinCapacity = 1, @@ -656,7 +488,7 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdateMinimumSet() AllocationStrategy = SpotAllocationStrategy.PriceCapacityOptimized, IsMaintainEnabled = true, }, - RegularPriorityProfile = new RegularPriorityProfile() + RegularPriorityProfile = new RegularPriorityProfile { Capacity = 2, MinCapacity = 1, @@ -665,7 +497,7 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdateMinimumSet() }, Tags = { -["key"] = "fleets-test", +["key"] = "fleets-test" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fleetName, data); @@ -678,6 +510,39 @@ public async Task CreateOrUpdate_FleetsCreateOrUpdateMinimumSet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_FleetsGet() + { + // Generated from example definition: 2024-11-01/Fleets_Get.json + // this example is just showing the usage of "Fleet_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1DC2F28C-A625-4B0E-9748-9885A3C9E9EB"; + string resourceGroupName = "rgazurefleet"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ComputeFleetResource + ComputeFleetCollection collection = resourceGroupResource.GetComputeFleets(); + + // invoke the operation + string fleetName = "testFleet"; + ComputeFleetResource result = await collection.GetAsync(fleetName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ComputeFleetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_FleetsListByResourceGroup() @@ -712,5 +577,75 @@ public async Task GetAll_FleetsListByResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_FleetsGet() + { + // Generated from example definition: 2024-11-01/Fleets_Get.json + // this example is just showing the usage of "Fleet_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1DC2F28C-A625-4B0E-9748-9885A3C9E9EB"; + string resourceGroupName = "rgazurefleet"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ComputeFleetResource + ComputeFleetCollection collection = resourceGroupResource.GetComputeFleets(); + + // invoke the operation + string fleetName = "testFleet"; + bool result = await collection.ExistsAsync(fleetName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_FleetsGet() + { + // Generated from example definition: 2024-11-01/Fleets_Get.json + // this example is just showing the usage of "Fleet_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1DC2F28C-A625-4B0E-9748-9885A3C9E9EB"; + string resourceGroupName = "rgazurefleet"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ComputeFleetResource + ComputeFleetCollection collection = resourceGroupResource.GetComputeFleets(); + + // invoke the operation + string fleetName = "testFleet"; + NullableResponse response = await collection.GetIfExistsAsync(fleetName); + ComputeFleetResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ComputeFleetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_ComputeFleetResource.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_ComputeFleetResource.cs index a9048cf5907c4..c3fe0ccdd9074 100644 --- a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_ComputeFleetResource.cs +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_ComputeFleetResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.ComputeFleet.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using NUnit.Framework; @@ -49,6 +48,32 @@ public async Task Get_FleetsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_FleetsDelete() + { + // Generated from example definition: 2024-11-01/Fleets_Delete.json + // this example is just showing the usage of "Fleet_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ComputeFleetResource created on azure + // for more information of creating ComputeFleetResource, please refer to the document of ComputeFleetResource + string subscriptionId = "1DC2F28C-A625-4B0E-9748-9885A3C9E9EB"; + string resourceGroupName = "rgazurefleet"; + string fleetName = "testFleet"; + ResourceIdentifier computeFleetResourceId = ComputeFleetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fleetName); + ComputeFleetResource computeFleet = client.GetComputeFleetResource(computeFleetResourceId); + + // invoke the operation + await computeFleet.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_FleetsUpdate() @@ -70,12 +95,10 @@ public async Task Update_FleetsUpdate() ComputeFleetResource computeFleet = client.GetComputeFleetResource(computeFleetResourceId); // invoke the operation - ComputeFleetPatch patch = new ComputeFleetPatch() + ComputeFleetPatch patch = new ComputeFleetPatch { - Tags = -{ -}, - Identity = new ManagedServiceIdentity(default), + Tags = { }, + Identity = (ManagedServiceIdentity)null, Plan = new ArmPlan("jwgrcrnrtfoxn", "iozjbiqqckqm", "cgopbyvdyqikahwyxfpzwaqk") { PromotionCode = "naglezezplcaruqogtxnuizslqnnbr", @@ -87,67 +110,58 @@ public async Task Update_FleetsUpdate() { Rank = 19225, } - }, new ComputeFleetComputeProfile(new ComputeFleetVmProfile() + }, new ComputeFleetComputeProfile(new ComputeFleetVmProfile { - OSProfile = new ComputeFleetVmssOSProfile() + OSProfile = new ComputeFleetVmssOSProfile { ComputerNamePrefix = "o", AdminUsername = "nrgzqciiaaxjrqldbmjbqkyhntp", AdminPassword = "adfbrdxpv", CustomData = "xjjib", - WindowsConfiguration = new ComputeFleetWindowsConfiguration() + WindowsConfiguration = new ComputeFleetWindowsConfiguration { IsVmAgentProvisioned = true, IsAutomaticUpdatesEnabled = true, TimeZone = "hlyjiqcfksgrpjrct", - AdditionalUnattendContent = - { -new WindowsSetupAdditionalInformation() + AdditionalUnattendContent = {new WindowsSetupAdditionalInformation { PassName = WindowsSetupAdditionalInformationPassName.OobeSystem, ComponentName = WindowsSetupAdditionalInformationComponentName.MicrosoftWindowsShellSetup, SettingName = AdditionalInformationSettingName.AutoLogon, Content = "bubmqbxjkj", -} - }, - PatchSettings = new ComputeFleetVmGuestPatchSettings() +}}, + PatchSettings = new ComputeFleetVmGuestPatchSettings { PatchMode = ComputeFleetWindowsVmGuestPatchMode.Manual, IsHotPatchingEnabled = true, AssessmentMode = ComputeFleetWindowsPatchAssessmentMode.ImageDefault, - AutomaticByPlatformSettings = new ComputeFleetWindowsVmGuestPatchAutomaticByPlatformSettings() + AutomaticByPlatformSettings = new ComputeFleetWindowsVmGuestPatchAutomaticByPlatformSettings { RebootSetting = ComputeFleetWindowsVmGuestPatchAutomaticByPlatformRebootSetting.Unknown, IsBypassPlatformSafetyChecksOnUserScheduleEnabled = true, }, }, - WinRMListeners = - { -new ComputeFleetWinRMListener() + WinRMListeners = {new ComputeFleetWinRMListener { Protocol = ComputeFleetProtocolType.Http, CertificateUri = new Uri("https://myVaultName.vault.azure.net/secrets/myCertName"), -} - }, +}}, IsVmAgentPlatformUpdatesEnabled = true, }, - LinuxConfiguration = new ComputeFleetLinuxConfiguration() + LinuxConfiguration = new ComputeFleetLinuxConfiguration { IsPasswordAuthenticationDisabled = true, - SshPublicKeys = - { -new ComputeFleetSshPublicKey() + SshPublicKeys = {new ComputeFleetSshPublicKey { Path = "kmqz", KeyData = "kivgsubusvpprwqaqpjcmhsv", -} - }, +}}, IsVmAgentProvisioned = true, - PatchSettings = new ComputeFleetLinuxPatchSettings() + PatchSettings = new ComputeFleetLinuxPatchSettings { PatchMode = ComputeFleetLinuxVmGuestPatchMode.ImageDefault, AssessmentMode = ComputeFleetLinuxPatchAssessmentMode.ImageDefault, - AutomaticByPlatformSettings = new ComputeFleetLinuxVmGuestPatchAutomaticByPlatformSettings() + AutomaticByPlatformSettings = new ComputeFleetLinuxVmGuestPatchAutomaticByPlatformSettings { RebootSetting = ComputeFleetLinuxVmGuestPatchAutomaticByPlatformRebootSetting.Unknown, IsBypassPlatformSafetyChecksOnUserScheduleEnabled = true, @@ -155,27 +169,21 @@ public async Task Update_FleetsUpdate() }, IsVmAgentPlatformUpdatesEnabled = true, }, - Secrets = - { -new ComputeFleetVaultSecretGroup() + Secrets = {new ComputeFleetVaultSecretGroup { SourceVaultId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}"), -VaultCertificates = -{ -new ComputeFleetVaultCertificate() +VaultCertificates = {new ComputeFleetVaultCertificate { CertificateUri = new Uri("https://myVaultName.vault.azure.net/secrets/myCertName"), CertificateStore = "nlxrwavpzhueffxsshlun", -} -}, -} - }, +}}, +}}, AreExtensionOperationsAllowed = true, IsGuestProvisionSignalRequired = true, }, - StorageProfile = new ComputeFleetVmssStorageProfile() + StorageProfile = new ComputeFleetVmssStorageProfile { - ImageReference = new ComputeFleetImageReference() + ImageReference = new ComputeFleetImageReference { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{imageName}/versions/{versionName}"), Publisher = "mqxgwbiyjzmxavhbkd", @@ -190,7 +198,7 @@ public async Task Update_FleetsUpdate() Name = "wfttw", Caching = ComputeFleetCachingType.None, IsWriteAcceleratorEnabled = true, - DiffDiskSettings = new ComputeFleetDiffDiskSettings() + DiffDiskSettings = new ComputeFleetDiffDiskSettings { Option = ComputeFleetDiffDiskOption.Local, Placement = ComputeFleetDiffDiskPlacement.CacheDisk, @@ -198,15 +206,12 @@ public async Task Update_FleetsUpdate() DiskSizeGB = 14, OSType = ComputeFleetOperatingSystemType.Windows, ImageUri = new Uri("https://myStorageAccountName.blob.core.windows.net/myContainerName/myVhdName.vhd"), - VhdContainers = - { -"tkzcwddtinkfpnfklatw" - }, - ManagedDisk = new ComputeFleetVmssManagedDisk() + VhdContainers = { "tkzcwddtinkfpnfklatw" }, + ManagedDisk = new ComputeFleetVmssManagedDisk { StorageAccountType = ComputeFleetStorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"), - SecurityProfile = new ComputeFleetVmDiskSecurityProfile() + SecurityProfile = new ComputeFleetVmDiskSecurityProfile { SecurityEncryptionType = ComputeFleetSecurityEncryptionType.VmGuestStateOnly, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"), @@ -214,19 +219,17 @@ public async Task Update_FleetsUpdate() }, DeleteOption = ComputeFleetDiskDeleteOptionType.Delete, }, - DataDisks = - { -new ComputeFleetVmssDataDisk(14,ComputeFleetDiskCreateOptionType.FromImage) + DataDisks = {new ComputeFleetVmssDataDisk(14, ComputeFleetDiskCreateOptionType.FromImage) { Name = "eogiykmdmeikswxmigjws", Caching = ComputeFleetCachingType.None, IsWriteAcceleratorEnabled = true, DiskSizeGB = 6, -ManagedDisk = new ComputeFleetVmssManagedDisk() +ManagedDisk = new ComputeFleetVmssManagedDisk { StorageAccountType = ComputeFleetStorageAccountType.StandardLrs, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"), -SecurityProfile = new ComputeFleetVmDiskSecurityProfile() +SecurityProfile = new ComputeFleetVmDiskSecurityProfile { SecurityEncryptionType = ComputeFleetSecurityEncryptionType.VmGuestStateOnly, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/diskEncryptionSets/{diskEncryptionSetName}"), @@ -235,80 +238,62 @@ public async Task Update_FleetsUpdate() DiskIopsReadWrite = 27L, DiskMbpsReadWrite = 2L, DeleteOption = ComputeFleetDiskDeleteOptionType.Delete, -} - }, +}}, }, - NetworkProfile = new ComputeFleetVmssNetworkProfile() + NetworkProfile = new ComputeFleetVmssNetworkProfile { HealthProbeId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/probes/{probeName}"), - NetworkInterfaceConfigurations = - { -new ComputeFleetVmssNetworkConfiguration("i") + NetworkInterfaceConfigurations = {new ComputeFleetVmssNetworkConfiguration("i") { Properties = new ComputeFleetVmssNetworkConfigurationProperties(new ComputeFleetVmssIPConfiguration[] { new ComputeFleetVmssIPConfiguration("oezqhkidfhyywlfzwuotilrpbqnjg") { -Properties = new ComputeFleetVmssIPConfigurationProperties() +Properties = new ComputeFleetVmssIPConfigurationProperties { SubnetId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworks/{virtualNetworkName}/subnets/{subnetName}"), IsPrimary = true, PublicIPAddressConfiguration = new ComputeFleetVmssPublicIPAddressConfiguration("fvpqf") { -Properties = new ComputeFleetVmssPublicIPAddressConfigurationProperties() +Properties = new ComputeFleetVmssPublicIPAddressConfigurationProperties { IdleTimeoutInMinutes = 9, DnsSettings = new ComputeFleetVmssPublicIPAddressDnsSettings("ukrddzvmorpmfsczjwtbvp") { DomainNameLabelScope = ComputeFleetDomainNameLabelScopeType.TenantReuse, }, -IPTags = -{ -new ComputeFleetVmssIPTag() +IPTags = {new ComputeFleetVmssIPTag { IPTagType = "sddgsoemnzgqizale", Tag = "wufmhrjsakbiaetyara", -} -}, +}}, PublicIPPrefixId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/publicIPPrefixes/{publicIPPrefixName}"), PublicIPAddressVersion = ComputeFleetIPVersion.IPv4, DeleteOption = ComputeFleetVmDeleteOption.Delete, }, -Sku = new ComputeFleetPublicIPAddressSku() +Sku = new ComputeFleetPublicIPAddressSku { Name = ComputeFleetPublicIPAddressSkuName.Basic, Tier = ComputeFleetPublicIPAddressSkuTier.Regional, }, }, PrivateIPAddressVersion = ComputeFleetIPVersion.IPv4, -ApplicationGatewayBackendAddressPools = -{ -new WritableSubResource() +ApplicationGatewayBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationGateways/{applicationGatewayName}/backendAddressPools/{backendAddressPoolName}"), -} -}, -ApplicationSecurityGroups = -{ -new WritableSubResource() +}}, +ApplicationSecurityGroups = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/applicationSecurityGroups/{applicationSecurityGroupName}"), -} -}, -LoadBalancerBackendAddressPools = -{ -new WritableSubResource() +}}, +LoadBalancerBackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/backendAddressPools/{backendAddressPoolName}"), -} -}, -LoadBalancerInboundNatPools = -{ -new WritableSubResource() +}}, +LoadBalancerInboundNatPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/loadBalancers/{loadBalancerName}/inboundNatPools/{inboundNatPoolName}"), -} -}, +}}, }, } }) @@ -318,22 +303,18 @@ public async Task Update_FleetsUpdate() IsTcpStateTrackingDisabled = true, IsFpgaEnabled = true, NetworkSecurityGroupId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/{networkSecurityGroupName}"), -DnsServers = -{ -"nxmmfolhclsesu" -}, +DnsServers = {"nxmmfolhclsesu"}, IsIPForwardingEnabled = true, DeleteOption = ComputeFleetVmDeleteOption.Delete, AuxiliaryMode = ComputeFleetNetworkInterfaceAuxiliaryMode.None, AuxiliarySku = ComputeFleetNetworkInterfaceAuxiliarySku.None, }, -} - }, +}}, NetworkApiVersion = ComputeFleetNetworkApiVersion.V20201101, }, - SecurityProfile = new ComputeFleetSecurityProfile() + SecurityProfile = new ComputeFleetSecurityProfile { - UefiSettings = new ComputeFleetUefiSettings() + UefiSettings = new ComputeFleetUefiSettings { IsSecureBootEnabled = true, IsVTpmEnabled = true, @@ -341,26 +322,24 @@ public async Task Update_FleetsUpdate() IsEncryptionAtHostEnabled = true, SecurityType = ComputeFleetSecurityType.TrustedLaunch, UserAssignedIdentityResourceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{userAssignedIdentityName}"), - ProxyAgentSettings = new ComputeFleetProxyAgentSettings() + ProxyAgentSettings = new ComputeFleetProxyAgentSettings { IsEnabled = true, Mode = ProxyAgentExecuteMode.Audit, KeyIncarnationId = 20, }, }, - BootDiagnostics = new ComputeFleetBootDiagnostics() + BootDiagnostics = new ComputeFleetBootDiagnostics { IsEnabled = true, StorageUri = new Uri("http://myStorageAccountName.blob.core.windows.net"), }, - ExtensionProfile = new ComputeFleetVmssExtensionProfile() + ExtensionProfile = new ComputeFleetVmssExtensionProfile { - Extensions = - { -new ComputeFleetVmssExtension() + Extensions = {new ComputeFleetVmssExtension { Name = "bndxuxx", -Properties = new ComputeFleetVmssExtensionProperties() +Properties = new ComputeFleetVmssExtensionProperties { ForceUpdateTag = "yhgxw", Publisher = "kpxtirxjfprhs", @@ -368,35 +347,27 @@ public async Task Update_FleetsUpdate() TypeHandlerVersion = "zevivcoilxmbwlrihhhibq", ShouldAutoUpgradeMinorVersion = true, IsAutomaticUpgradeEnabled = true, -Settings = -{ -}, -ProtectedSettings = -{ -}, -ProvisionAfterExtensions = -{ -"nftzosroolbcwmpupujzqwqe" -}, +Settings = {}, +ProtectedSettings = {}, +ProvisionAfterExtensions = {"nftzosroolbcwmpupujzqwqe"}, IsSuppressFailuresEnabled = true, -ProtectedSettingsFromKeyVault = new ComputeFleetKeyVaultSecretReference(new Uri("https://myVaultName.vault.azure.net/secrets/secret/mySecretName"),new WritableSubResource() +ProtectedSettingsFromKeyVault = new ComputeFleetKeyVaultSecretReference(new Uri("https://myVaultName.vault.azure.net/secrets/secret/mySecretName"), new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}"), }), }, -} - }, +}}, ExtensionsTimeBudget = "mbhjahtdygwgyszdwjtvlvtgchdwil", }, LicenseType = "v", - ScheduledEventsProfile = new ComputeFleetScheduledEventsProfile() + ScheduledEventsProfile = new ComputeFleetScheduledEventsProfile { - TerminateNotificationProfile = new ComputeFleetTerminateNotificationProfile() + TerminateNotificationProfile = new ComputeFleetTerminateNotificationProfile { NotBeforeTimeout = "iljppmmw", IsEnabled = true, }, - OSImageNotificationProfile = new ComputeFleetOSImageNotificationProfile() + OSImageNotificationProfile = new ComputeFleetOSImageNotificationProfile { NotBeforeTimeout = "olbpadmevekyczfokodtfprxti", IsEnabled = true, @@ -404,30 +375,24 @@ public async Task Update_FleetsUpdate() }, UserData = "s", CapacityReservationGroupId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}"), - GalleryApplications = - { -new ComputeFleetVmGalleryApplication(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{applicationName}/versions/{versionName}")) + GalleryApplications = {new ComputeFleetVmGalleryApplication(new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/applications/{applicationName}/versions/{versionName}")) { Tags = "eyrqjbib", Order = 5, ConfigurationReference = "ulztmiavpojpbpbddgnuuiimxcpau", IsTreatFailureAsDeploymentFailureEnabled = true, IsAutomaticUpgradeEnabled = true, -} - }, - HardwareVmSizeProperties = new ComputeFleetVmSizeProperties() +}}, + HardwareVmSizeProperties = new ComputeFleetVmSizeProperties { VCPUsAvailable = 16, VCPUsPerCore = 23, }, ServiceArtifactReferenceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/serviceArtifacts/{serviceArtifactsName}/vmArtifactsProfiles/{vmArtifactsProfileName}"), - SecurityPostureReference = new ComputeFleetSecurityPostureReference() + SecurityPostureReference = new ComputeFleetSecurityPostureReference { Id = "/CommunityGalleries/{communityGalleryName}/securityPostures/{securityPostureName}/versions/{major.minor.patch}|{major.*}|latest", - ExcludeExtensions = - { -"{securityPostureVMExtensionName}" - }, + ExcludeExtensions = { "{securityPostureVMExtensionName}" }, IsOverridable = true, }, }) @@ -436,7 +401,7 @@ public async Task Update_FleetsUpdate() PlatformFaultDomainCount = 1, }) { - SpotPriorityProfile = new SpotPriorityProfile() + SpotPriorityProfile = new SpotPriorityProfile { Capacity = 20, MinCapacity = 10, @@ -445,7 +410,7 @@ public async Task Update_FleetsUpdate() AllocationStrategy = SpotAllocationStrategy.PriceCapacityOptimized, IsMaintainEnabled = true, }, - RegularPriorityProfile = new RegularPriorityProfile() + RegularPriorityProfile = new RegularPriorityProfile { Capacity = 20, MinCapacity = 10, @@ -463,63 +428,6 @@ public async Task Update_FleetsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_FleetsDelete() - { - // Generated from example definition: 2024-11-01/Fleets_Delete.json - // this example is just showing the usage of "Fleet_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ComputeFleetResource created on azure - // for more information of creating ComputeFleetResource, please refer to the document of ComputeFleetResource - string subscriptionId = "1DC2F28C-A625-4B0E-9748-9885A3C9E9EB"; - string resourceGroupName = "rgazurefleet"; - string fleetName = "testFleet"; - ResourceIdentifier computeFleetResourceId = ComputeFleetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, fleetName); - ComputeFleetResource computeFleet = client.GetComputeFleetResource(computeFleetResourceId); - - // invoke the operation - await computeFleet.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetComputeFleets_FleetsListBySubscription() - { - // Generated from example definition: 2024-11-01/Fleets_ListBySubscription.json - // this example is just showing the usage of "Fleet_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1DC2F28C-A625-4B0E-9748-9885A3C9E9EB"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ComputeFleetResource item in subscriptionResource.GetComputeFleetsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ComputeFleetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetVirtualMachineScaleSets_FleetsListVirtualMachineScaleSets() diff --git a/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..bafa91e3e8ba0 --- /dev/null +++ b/sdk/computefleet/Azure.ResourceManager.ComputeFleet/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ComputeFleet.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetComputeFleets_FleetsListBySubscription() + { + // Generated from example definition: 2024-11-01/Fleets_ListBySubscription.json + // this example is just showing the usage of "Fleet_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1DC2F28C-A625-4B0E-9748-9885A3C9E9EB"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ComputeFleetResource item in subscriptionResource.GetComputeFleetsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ComputeFleetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ConfidentialLedgerCollection.cs b/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ConfidentialLedgerCollection.cs index 0a874880fa1db..c3e416c703021 100644 --- a/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ConfidentialLedgerCollection.cs +++ b/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ConfidentialLedgerCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ConfidentialLedgerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConfidentialLedgerGet() + public async Task CreateOrUpdate_ConfidentialLedgerCreate() { - // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_Get.json - // this example is just showing the usage of "Ledger_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_Create.json + // this example is just showing the usage of "Ledger_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,31 @@ public async Task Get_ConfidentialLedgerGet() // invoke the operation string ledgerName = "DummyLedgerName"; - ConfidentialLedgerResource result = await collection.GetAsync(ledgerName); + ConfidentialLedgerData data = new ConfidentialLedgerData(new AzureLocation("EastUS")) + { + Properties = new ConfidentialLedgerProperties + { + LedgerType = ConfidentialLedgerType.Public, + LedgerSku = ConfidentialLedgerSku.Standard, + AadBasedSecurityPrincipals = {new AadBasedSecurityPrincipal +{ +PrincipalId = Guid.Parse("34621747-6fc8-4771-a2eb-72f31c461f2e"), +TenantId = Guid.Parse("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), +LedgerRoleName = ConfidentialLedgerRoleName.Administrator, +}}, + CertBasedSecurityPrincipals = {new CertBasedSecurityPrincipal +{ +Cert = "-----BEGIN CERTIFICATE-----MIIBsjCCATigAwIBAgIUZWIbyG79TniQLd2UxJuU74tqrKcwCgYIKoZIzj0EAwMwEDEOMAwGA1UEAwwFdXNlcjAwHhcNMjEwMzE2MTgwNjExWhcNMjIwMzE2MTgwNjExWjAQMQ4wDAYDVQQDDAV1c2VyMDB2MBAGByqGSM49AgEGBSuBBAAiA2IABBiWSo/j8EFit7aUMm5lF+lUmCu+IgfnpFD+7QMgLKtxRJ3aGSqgS/GpqcYVGddnODtSarNE/HyGKUFUolLPQ5ybHcouUk0kyfA7XMeSoUA4lBz63Wha8wmXo+NdBRo39qNTMFEwHQYDVR0OBBYEFPtuhrwgGjDFHeUUT4nGsXaZn69KMB8GA1UdIwQYMBaAFPtuhrwgGjDFHeUUT4nGsXaZn69KMA8GA1UdEwEB/wQFMAMBAf8wCgYIKoZIzj0EAwMDaAAwZQIxAOnozm2CyqRwSSQLls5r+mUHRGRyXHXwYtM4Dcst/VEZdmS9fqvHRCHbjUlO/+HNfgIwMWZ4FmsjD3wnPxONOm9YdVn/PRD7SsPRPbOjwBiE4EBGaHDsLjYAGDSGi7NJnSkA-----END CERTIFICATE-----", +LedgerRoleName = ConfidentialLedgerRoleName.Reader, +}}, + }, + Tags = +{ +["additionalProps1"] = "additional properties" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ledgerName, data); + ConfidentialLedgerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +76,7 @@ public async Task Get_ConfidentialLedgerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConfidentialLedgerGet() + public async Task Get_ConfidentialLedgerGet() { // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_Get.json // this example is just showing the usage of "Ledger_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +98,21 @@ public async Task Exists_ConfidentialLedgerGet() // invoke the operation string ledgerName = "DummyLedgerName"; - bool result = await collection.ExistsAsync(ledgerName); + ConfidentialLedgerResource result = await collection.GetAsync(ledgerName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfidentialLedgerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConfidentialLedgerGet() + public async Task GetAll_ConfidentialLedgerList() { - // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_Get.json - // this example is just showing the usage of "Ledger_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_List.json + // this example is just showing the usage of "Ledger_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +129,25 @@ public async Task GetIfExists_ConfidentialLedgerGet() // get the collection of this ConfidentialLedgerResource ConfidentialLedgerCollection collection = resourceGroupResource.GetConfidentialLedgers(); - // invoke the operation - string ledgerName = "DummyLedgerName"; - NullableResponse response = await collection.GetIfExistsAsync(ledgerName); - ConfidentialLedgerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ConfidentialLedgerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConfidentialLedgerData resourceData = result.Data; + ConfidentialLedgerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConfidentialLedgerCreate() + public async Task Exists_ConfidentialLedgerGet() { - // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_Create.json - // this example is just showing the usage of "Ledger_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_Get.json + // this example is just showing the usage of "Ledger_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,51 +166,17 @@ public async Task CreateOrUpdate_ConfidentialLedgerCreate() // invoke the operation string ledgerName = "DummyLedgerName"; - ConfidentialLedgerData data = new ConfidentialLedgerData(new AzureLocation("EastUS")) - { - Properties = new ConfidentialLedgerProperties() - { - LedgerType = ConfidentialLedgerType.Public, - LedgerSku = ConfidentialLedgerSku.Standard, - AadBasedSecurityPrincipals = -{ -new AadBasedSecurityPrincipal() -{ -PrincipalId = Guid.Parse("34621747-6fc8-4771-a2eb-72f31c461f2e"), -TenantId = Guid.Parse("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), -LedgerRoleName = ConfidentialLedgerRoleName.Administrator, -} -}, - CertBasedSecurityPrincipals = -{ -new CertBasedSecurityPrincipal() -{ -Cert = "-----BEGIN CERTIFICATE-----MIIBsjCCATigAwIBAgIUZWIbyG79TniQLd2UxJuU74tqrKcwCgYIKoZIzj0EAwMwEDEOMAwGA1UEAwwFdXNlcjAwHhcNMjEwMzE2MTgwNjExWhcNMjIwMzE2MTgwNjExWjAQMQ4wDAYDVQQDDAV1c2VyMDB2MBAGByqGSM49AgEGBSuBBAAiA2IABBiWSo/j8EFit7aUMm5lF+lUmCu+IgfnpFD+7QMgLKtxRJ3aGSqgS/GpqcYVGddnODtSarNE/HyGKUFUolLPQ5ybHcouUk0kyfA7XMeSoUA4lBz63Wha8wmXo+NdBRo39qNTMFEwHQYDVR0OBBYEFPtuhrwgGjDFHeUUT4nGsXaZn69KMB8GA1UdIwQYMBaAFPtuhrwgGjDFHeUUT4nGsXaZn69KMA8GA1UdEwEB/wQFMAMBAf8wCgYIKoZIzj0EAwMDaAAwZQIxAOnozm2CyqRwSSQLls5r+mUHRGRyXHXwYtM4Dcst/VEZdmS9fqvHRCHbjUlO/+HNfgIwMWZ4FmsjD3wnPxONOm9YdVn/PRD7SsPRPbOjwBiE4EBGaHDsLjYAGDSGi7NJnSkA-----END CERTIFICATE-----", -LedgerRoleName = ConfidentialLedgerRoleName.Reader, -} -}, - }, - Tags = -{ -["additionalProps1"] = "additional properties", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ledgerName, data); - ConfidentialLedgerResource result = lro.Value; + bool result = await collection.ExistsAsync(ledgerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfidentialLedgerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConfidentialLedgerList() + public async Task GetIfExists_ConfidentialLedgerGet() { - // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_List.json - // this example is just showing the usage of "Ledger_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_Get.json + // this example is just showing the usage of "Ledger_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -205,17 +193,23 @@ public async Task GetAll_ConfidentialLedgerList() // get the collection of this ConfidentialLedgerResource ConfidentialLedgerCollection collection = resourceGroupResource.GetConfidentialLedgers(); - // invoke the operation and iterate over the result - await foreach (ConfidentialLedgerResource item in collection.GetAllAsync()) + // invoke the operation + string ledgerName = "DummyLedgerName"; + NullableResponse response = await collection.GetIfExistsAsync(ledgerName); + ConfidentialLedgerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConfidentialLedgerData resourceData = item.Data; + ConfidentialLedgerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ConfidentialLedgerResource.cs b/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ConfidentialLedgerResource.cs index 91ba004e34272..4b9bc3a0289eb 100644 --- a/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ConfidentialLedgerResource.cs +++ b/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ConfidentialLedgerResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ConfidentialLedger.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ConfidentialLedger.Samples @@ -96,31 +95,25 @@ public async Task Update_ConfidentialLedgerUpdate() // invoke the operation ConfidentialLedgerData data = new ConfidentialLedgerData(new AzureLocation("EastUS")) { - Properties = new ConfidentialLedgerProperties() + Properties = new ConfidentialLedgerProperties { LedgerType = ConfidentialLedgerType.Public, - AadBasedSecurityPrincipals = -{ -new AadBasedSecurityPrincipal() + AadBasedSecurityPrincipals = {new AadBasedSecurityPrincipal { PrincipalId = Guid.Parse("34621747-6fc8-4771-a2eb-72f31c461f2e"), TenantId = Guid.Parse("bce123b9-2b7b-4975-8360-5ca0b9b1cd08"), LedgerRoleName = ConfidentialLedgerRoleName.Administrator, -} -}, - CertBasedSecurityPrincipals = -{ -new CertBasedSecurityPrincipal() +}}, + CertBasedSecurityPrincipals = {new CertBasedSecurityPrincipal { Cert = "-----BEGIN CERTIFICATE-----\nMIIDUjCCAjqgAwIBAgIQJ2IrDBawSkiAbkBYmiAopDANBgkqhkiG9w0BAQsFADAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwHhcNMjAwOTIzMjIxODQ2WhcNMjEwOTIzMjIyODQ2WjAmMSQwIgYDVQQDExtTeW50aGV0aWNzIExlZGdlciBVc2VyIENlcnQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCX2s/Eu4q/eQ63N+Ugeg5oAciZua/YCJr41c/696szvSY7Zg1SNJlW88/nbz70+QpO55OmqlEE3QCU+T0Vl/h0Gf//n1PYcoBbTGUnYEmV+fTTHict6rFiEwrGJ62tvcpYgwapInSLyEeUzjki0zhOLJ1OfRnYd1eGnFVMpE5aVjiS8Q5dmTEUyd51EIprGE8RYAW9aeWSwTH7gjHUsRlJnHKcdhaK/v5QKJnNu5bzPFUcpC0ZBcizoMPAtroLAD4B68Jl0z3op18MgZe6lRrVoWuxfqnk5GojuB/Vu8ohAZKoFhQ6NB6r+LL2AUs+Zr7Bt26IkEdR178n9JMEA4gHAgMBAAGjfDB6MA4GA1UdDwEB/wQEAwIFoDAJBgNVHRMEAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjAfBgNVHSMEGDAWgBS/a7PU9iOfOKEyZCp11Oen5VSuuDAdBgNVHQ4EFgQUv2uz1PYjnzihMmQqddTnp+VUrrgwDQYJKoZIhvcNAQELBQADggEBAF5q2fDwnse8egXhfaJCqqM969E9gSacqFmASpoDJPRPEX7gqoO7v1ww7nqRtRDoRiBvo/yNk7jlSAkRN3nRRnZLZZ3MYQdmCr4FGyIqRg4Y94+nja+Du9pDD761rxRktMVPSOaAVM/E5DQvscDlPvlPYe9mkcrLCE4DXYpiMmLT8Tm55LJJq5m07dVDgzAIR1L/hmEcbK0pnLgzciMtMLxGO2udnyyW/UW9WxnjvrrD2JluTHH9mVbb+XQP1oFtlRBfH7aui1ZgWfKvxrdP4zdK9QoWSUvRux3TLsGmHRBjBMtqYDY3y5mB+aNjLelvWpeVb0m2aOSVXynrLwNCAVA=\n-----END CERTIFICATE-----", LedgerRoleName = ConfidentialLedgerRoleName.Reader, -} -}, +}}, }, Tags = { ["additionProps2"] = "additional property value", -["additionalProps1"] = "additional properties", +["additionalProps1"] = "additional properties" }, }; ArmOperation lro = await confidentialLedger.UpdateAsync(WaitUntil.Completed, data); @@ -133,37 +126,6 @@ public async Task Update_ConfidentialLedgerUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetConfidentialLedgers_ConfidentialLedgerListBySub() - { - // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_ListBySub.json - // this example is just showing the usage of "Ledger_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "0000000-0000-0000-0000-000000000001"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ConfidentialLedgerResource item in subscriptionResource.GetConfidentialLedgersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfidentialLedgerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Backup_ConfidentialLedgerBackup() diff --git a/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ManagedCcfCollection.cs b/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ManagedCcfCollection.cs index e00ce454bab1f..c488825f0e695 100644 --- a/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ManagedCcfCollection.cs +++ b/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ManagedCcfCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -20,10 +19,10 @@ public partial class Sample_ManagedCcfCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ManagedCCFGet() + public async Task CreateOrUpdate_ManagedCCFCreate() { - // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_Get.json - // this example is just showing the usage of "ManagedCCF_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_Create.json + // this example is just showing the usage of "ManagedCCF_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +41,33 @@ public async Task Get_ManagedCCFGet() // invoke the operation string appName = "DummyMccfAppName"; - ManagedCcfResource result = await collection.GetAsync(appName); + ManagedCcfData data = new ManagedCcfData(new AzureLocation("EastUS")) + { + Properties = new ManagedCcfProperties + { + MemberIdentityCertificates = {new ConfidentialLedgerMemberIdentityCertificate +{ +Certificate = "-----BEGIN CERTIFICATE-----MIIBsjCCATigAwIBAgIUZWIbyG79TniQLd2UxJuU74tqrKcwCgYIKoZIzj0EAwMwEDEOMAwGA1UEAwwFdXNlcjAwHhcNMjEwMzE2MTgwNjExWhcNMjIwMzE2MTgwNjExWjAQMQ4wDAYDVQQDDAV1c2VyMDB2MBAGByqGSM49AgEGBSuBBAAiA2IABBiWSo/j8EFit7aUMm5lF+lUmCu+IgfnpFD+7QMgLKtxRJ3aGSqgS/GpqcYVGddnODtSarNE/HyGKUFUolLPQ5ybHcouUk0kyfA7XMeSoUA4lBz63Wha8wmXo+NdBRo39qNTMFEwHQYDVR0OBBYEFPtuhrwgGjDFHeUUT4nGsXaZn69KMB8GA1UdIwQYMBaAFPtuhrwgGjDFHeUUT4nGsXaZn69KMA8GA1UdEwEB/wQFMAMBAf8wCgYIKoZIzj0EAwMDaAAwZQIxAOnozm2CyqRwSSQLls5r+mUHRGRyXHXwYtM4Dcst/VEZdmS9fqvHRCHbjUlO/+HNfgIwMWZ4FmsjD3wnPxONOm9YdVn/PRD7SsPRPbOjwBiE4EBGaHDsLjYAGDSGi7NJnSkA-----END CERTIFICATE-----", +Encryptionkey = "ledgerencryptionkey", +Tags = BinaryData.FromObjectAsJson(new +{ +additionalProps1 = "additional properties", +}), +}}, + DeploymentType = new ConfidentialLedgerDeploymentType + { + LanguageRuntime = ConfidentialLedgerLanguageRuntime.CPP, + AppSourceUri = new Uri("https://myaccount.blob.core.windows.net/storage/mccfsource?sv=2022-02-11%st=2022-03-11"), + }, + NodeCount = 5, + }, + Tags = +{ +["additionalProps1"] = "additional properties" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, appName, data); + ManagedCcfResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +78,7 @@ public async Task Get_ManagedCCFGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ManagedCCFGet() + public async Task Get_ManagedCCFGet() { // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_Get.json // this example is just showing the usage of "ManagedCCF_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +100,21 @@ public async Task Exists_ManagedCCFGet() // invoke the operation string appName = "DummyMccfAppName"; - bool result = await collection.ExistsAsync(appName); + ManagedCcfResource result = await collection.GetAsync(appName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedCcfData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ManagedCCFGet() + public async Task GetAll_ManagedCCFList() { - // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_Get.json - // this example is just showing the usage of "ManagedCCF_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_List.json + // this example is just showing the usage of "ManagedCCF_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +131,25 @@ public async Task GetIfExists_ManagedCCFGet() // get the collection of this ManagedCcfResource ManagedCcfCollection collection = resourceGroupResource.GetManagedCcfs(); - // invoke the operation - string appName = "DummyMccfAppName"; - NullableResponse response = await collection.GetIfExistsAsync(appName); - ManagedCcfResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedCcfResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedCcfData resourceData = result.Data; + ManagedCcfData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ManagedCCFCreate() + public async Task Exists_ManagedCCFGet() { - // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_Create.json - // this example is just showing the usage of "ManagedCCF_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_Get.json + // this example is just showing the usage of "ManagedCCF_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,49 +168,17 @@ public async Task CreateOrUpdate_ManagedCCFCreate() // invoke the operation string appName = "DummyMccfAppName"; - ManagedCcfData data = new ManagedCcfData(new AzureLocation("EastUS")) - { - Properties = new ManagedCcfProperties() - { - MemberIdentityCertificates = -{ -new ConfidentialLedgerMemberIdentityCertificate() -{ -Certificate = "-----BEGIN CERTIFICATE-----MIIBsjCCATigAwIBAgIUZWIbyG79TniQLd2UxJuU74tqrKcwCgYIKoZIzj0EAwMwEDEOMAwGA1UEAwwFdXNlcjAwHhcNMjEwMzE2MTgwNjExWhcNMjIwMzE2MTgwNjExWjAQMQ4wDAYDVQQDDAV1c2VyMDB2MBAGByqGSM49AgEGBSuBBAAiA2IABBiWSo/j8EFit7aUMm5lF+lUmCu+IgfnpFD+7QMgLKtxRJ3aGSqgS/GpqcYVGddnODtSarNE/HyGKUFUolLPQ5ybHcouUk0kyfA7XMeSoUA4lBz63Wha8wmXo+NdBRo39qNTMFEwHQYDVR0OBBYEFPtuhrwgGjDFHeUUT4nGsXaZn69KMB8GA1UdIwQYMBaAFPtuhrwgGjDFHeUUT4nGsXaZn69KMA8GA1UdEwEB/wQFMAMBAf8wCgYIKoZIzj0EAwMDaAAwZQIxAOnozm2CyqRwSSQLls5r+mUHRGRyXHXwYtM4Dcst/VEZdmS9fqvHRCHbjUlO/+HNfgIwMWZ4FmsjD3wnPxONOm9YdVn/PRD7SsPRPbOjwBiE4EBGaHDsLjYAGDSGi7NJnSkA-----END CERTIFICATE-----", -Encryptionkey = "ledgerencryptionkey", -Tags = BinaryData.FromObjectAsJson(new Dictionary() -{ -["additionalProps1"] = "additional properties"}), -} -}, - DeploymentType = new ConfidentialLedgerDeploymentType() - { - LanguageRuntime = ConfidentialLedgerLanguageRuntime.CPP, - AppSourceUri = new Uri("https://myaccount.blob.core.windows.net/storage/mccfsource?sv=2022-02-11%st=2022-03-11"), - }, - NodeCount = 5, - }, - Tags = -{ -["additionalProps1"] = "additional properties", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, appName, data); - ManagedCcfResource result = lro.Value; + bool result = await collection.ExistsAsync(appName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedCcfData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ManagedCCFList() + public async Task GetIfExists_ManagedCCFGet() { - // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_List.json - // this example is just showing the usage of "ManagedCCF_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_Get.json + // this example is just showing the usage of "ManagedCCF_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,17 +195,23 @@ public async Task GetAll_ManagedCCFList() // get the collection of this ManagedCcfResource ManagedCcfCollection collection = resourceGroupResource.GetManagedCcfs(); - // invoke the operation and iterate over the result - await foreach (ManagedCcfResource item in collection.GetAllAsync()) + // invoke the operation + string appName = "DummyMccfAppName"; + NullableResponse response = await collection.GetIfExistsAsync(appName); + ManagedCcfResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedCcfData resourceData = item.Data; + ManagedCcfData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ManagedCcfResource.cs b/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ManagedCcfResource.cs index 052cbcc5e5b05..274bca6edf586 100644 --- a/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ManagedCcfResource.cs +++ b/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_ManagedCcfResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ConfidentialLedger.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ConfidentialLedger.Samples @@ -96,9 +95,9 @@ public async Task Update_ManagedCCFUpdate() // invoke the operation ManagedCcfData data = new ManagedCcfData(new AzureLocation("EastUS")) { - Properties = new ManagedCcfProperties() + Properties = new ManagedCcfProperties { - DeploymentType = new ConfidentialLedgerDeploymentType() + DeploymentType = new ConfidentialLedgerDeploymentType { LanguageRuntime = ConfidentialLedgerLanguageRuntime.CPP, AppSourceUri = new Uri("https://myaccount.blob.core.windows.net/storage/mccfsource?sv=2022-02-11%st=2022-03-11"), @@ -106,7 +105,7 @@ public async Task Update_ManagedCCFUpdate() }, Tags = { -["additionalProps1"] = "additional properties", +["additionalProps1"] = "additional properties" }, }; ArmOperation lro = await managedCcf.UpdateAsync(WaitUntil.Completed, data); @@ -119,37 +118,6 @@ public async Task Update_ManagedCCFUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetManagedCcfs_ManagedCCFListBySub() - { - // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_ListBySub.json - // this example is just showing the usage of "ManagedCCF_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "0000000-0000-0000-0000-000000000001"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ManagedCcfResource item in subscriptionResource.GetManagedCcfsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedCcfData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Backup_ManagedCCFBackup() diff --git a/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 56b67bed0887a..6b2797b339fd0 100644 --- a/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/confidentialledger/Azure.ResourceManager.ConfidentialLedger/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -36,7 +36,7 @@ public async Task CheckConfidentialLedgerNameAvailability_CheckNameAvailability( SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - ConfidentialLedgerNameAvailabilityContent content = new ConfidentialLedgerNameAvailabilityContent() + ConfidentialLedgerNameAvailabilityContent content = new ConfidentialLedgerNameAvailabilityContent { Name = "sample-name", ResourceType = new ResourceType("Microsoft.ConfidentialLedger/ledgers"), @@ -45,5 +45,67 @@ public async Task CheckConfidentialLedgerNameAvailability_CheckNameAvailability( Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetConfidentialLedgers_ConfidentialLedgerListBySub() + { + // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ConfidentialLedger_ListBySub.json + // this example is just showing the usage of "Ledger_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "0000000-0000-0000-0000-000000000001"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ConfidentialLedgerResource item in subscriptionResource.GetConfidentialLedgersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfidentialLedgerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetManagedCcfs_ManagedCCFListBySub() + { + // Generated from example definition: specification/confidentialledger/resource-manager/Microsoft.ConfidentialLedger/preview/2023-06-28-preview/examples/ManagedCCF_ListBySub.json + // this example is just showing the usage of "ManagedCCF_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "0000000-0000-0000-0000-000000000001"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ManagedCcfResource item in subscriptionResource.GetManagedCcfsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedCcfData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ConfluentOrganizationCollection.cs b/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ConfluentOrganizationCollection.cs index 5446cc4f14bde..e3df67821395f 100644 --- a/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ConfluentOrganizationCollection.cs +++ b/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ConfluentOrganizationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ConfluentOrganizationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_OrganizationListByResourceGroup() + public async Task CreateOrUpdate_OrganizationCreate() { - // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_ListByResourceGroup.json - // this example is just showing the usage of "Organization_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_Create.json + // this example is just showing the usage of "Organization_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,34 @@ public async Task GetAll_OrganizationListByResourceGroup() // get the collection of this ConfluentOrganizationResource ConfluentOrganizationCollection collection = resourceGroupResource.GetConfluentOrganizations(); - // invoke the operation and iterate over the result - await foreach (ConfluentOrganizationResource item in collection.GetAllAsync()) + // invoke the operation + string organizationName = "myOrganization"; + ConfluentOrganizationData data = new ConfluentOrganizationData(new AzureLocation("West US"), new ConfluentOfferDetail("string", "string", "string", "string", "string") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfluentOrganizationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrivateOfferId = "string", + PrivateOfferIds = { "string" }, + }, new ConfluentUserDetail("contoso@microsoft.com") + { + FirstName = "string", + LastName = "string", + UserPrincipalName = "contoso@microsoft.com", + AadEmail = "contoso@microsoft.com", + }) + { + LinkOrganizationToken = "string", + Tags = +{ +["Environment"] = "Dev" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, organizationName, data); + ConfluentOrganizationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfluentOrganizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +104,10 @@ public async Task Get_OrganizationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_OrganizationGet() + public async Task GetAll_OrganizationListByResourceGroup() { - // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_Get.json - // this example is just showing the usage of "Organization_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_ListByResourceGroup.json + // this example is just showing the usage of "Organization_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +124,22 @@ public async Task Exists_OrganizationGet() // get the collection of this ConfluentOrganizationResource ConfluentOrganizationCollection collection = resourceGroupResource.GetConfluentOrganizations(); - // invoke the operation - string organizationName = "myOrganization"; - bool result = await collection.ExistsAsync(organizationName); + // invoke the operation and iterate over the result + await foreach (ConfluentOrganizationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfluentOrganizationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_OrganizationGet() + public async Task Exists_OrganizationGet() { // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_Get.json // this example is just showing the usage of "Organization_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +161,17 @@ public async Task GetIfExists_OrganizationGet() // invoke the operation string organizationName = "myOrganization"; - NullableResponse response = await collection.GetIfExistsAsync(organizationName); - ConfluentOrganizationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(organizationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfluentOrganizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_OrganizationCreate() + public async Task GetIfExists_OrganizationGet() { - // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_Create.json - // this example is just showing the usage of "Organization_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_Get.json + // this example is just showing the usage of "Organization_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,35 +190,21 @@ public async Task CreateOrUpdate_OrganizationCreate() // invoke the operation string organizationName = "myOrganization"; - ConfluentOrganizationData data = new ConfluentOrganizationData(new AzureLocation("West US"), new ConfluentOfferDetail("string", "string", "string", "string", "string") - { - PrivateOfferId = "string", - PrivateOfferIds = -{ -"string" -}, - }, new ConfluentUserDetail("contoso@microsoft.com") + NullableResponse response = await collection.GetIfExistsAsync(organizationName); + ConfluentOrganizationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - FirstName = "string", - LastName = "string", - UserPrincipalName = "contoso@microsoft.com", - AadEmail = "contoso@microsoft.com", - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - LinkOrganizationToken = "string", - Tags = -{ -["Environment"] = "Dev", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, organizationName, data); - ConfluentOrganizationResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfluentOrganizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfluentOrganizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ConfluentOrganizationResource.cs b/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ConfluentOrganizationResource.cs index 0c5ff47cc2352..4f41145e8e49b 100644 --- a/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ConfluentOrganizationResource.cs +++ b/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ConfluentOrganizationResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Confluent.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Confluent.Samples { public partial class Sample_ConfluentOrganizationResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetConfluentOrganizations_OrganizationListBySubscription() - { - // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_ListBySubscription.json - // this example is just showing the usage of "Organization_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ConfluentOrganizationResource item in subscriptionResource.GetConfluentOrganizationsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfluentOrganizationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_OrganizationGet() @@ -80,10 +48,10 @@ public async Task Get_OrganizationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConfluentUpdate() + public async Task Delete_ConfluentDelete() { - // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_Update.json - // this example is just showing the usage of "Organization_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_Delete.json + // this example is just showing the usage of "Organization_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,29 +67,17 @@ public async Task Update_ConfluentUpdate() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - ConfluentOrganizationPatch patch = new ConfluentOrganizationPatch() - { - Tags = -{ -["client"] = "dev-client", -["env"] = "dev", -}, - }; - ConfluentOrganizationResource result = await confluentOrganization.UpdateAsync(patch); + await confluentOrganization.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConfluentOrganizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ConfluentDelete() + public async Task Update_ConfluentUpdate() { - // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_Delete.json - // this example is just showing the usage of "Organization_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_Update.json + // this example is just showing the usage of "Organization_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,9 +93,21 @@ public async Task Delete_ConfluentDelete() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - await confluentOrganization.DeleteAsync(WaitUntil.Completed); + ConfluentOrganizationPatch patch = new ConfluentOrganizationPatch + { + Tags = +{ +["client"] = "dev-client", +["env"] = "dev" +}, + }; + ConfluentOrganizationResource result = await confluentOrganization.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfluentOrganizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -281,13 +249,13 @@ public async Task GetRegions_OrganizationListRegions() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - AccessListContent content = new AccessListContent() + AccessListContent content = new AccessListContent { SearchFilters = { ["cloud"] = "azure", ["packages"] = "ADVANCED,ESSENTIALS", -["region"] = "eastus", +["region"] = "eastus" }, }; ConfluentRegionListResult result = await confluentOrganization.GetRegionsAsync(content); @@ -318,7 +286,7 @@ public async Task CreateApiKey_OrganizationCreateAPIKey() // invoke the operation string environmentId = "env-12132"; string clusterId = "clusterId-123"; - ConfluentApiKeyCreateContent content = new ConfluentApiKeyCreateContent() + ConfluentApiKeyCreateContent content = new ConfluentApiKeyCreateContent { Name = "CI kafka access key", Description = "This API key provides kafka access to cluster x", @@ -459,12 +427,12 @@ public async Task GetAccessUsers_AccessUsersList() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - AccessListContent content = new AccessListContent() + AccessListContent content = new AccessListContent { SearchFilters = { ["pageSize"] = "10", -["pageToken"] = "asc4fts4ft", +["pageToken"] = "asc4fts4ft" }, }; AccessUserListResult result = await confluentOrganization.GetAccessUsersAsync(content); @@ -493,12 +461,12 @@ public async Task GetAccessServiceAccounts_AccessServiceAccountsList() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - AccessListContent content = new AccessListContent() + AccessListContent content = new AccessListContent { SearchFilters = { ["pageSize"] = "10", -["pageToken"] = "asc4fts4ft", +["pageToken"] = "asc4fts4ft" }, }; AccessServiceAccountListResult result = await confluentOrganization.GetAccessServiceAccountsAsync(content); @@ -527,13 +495,13 @@ public async Task GetAccessInvitations_AccessInvitationsList() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - AccessListContent content = new AccessListContent() + AccessListContent content = new AccessListContent { SearchFilters = { ["pageSize"] = "10", ["pageToken"] = "asc4fts4ft", -["status"] = "INVITE_STATUS_SENT", +["status"] = "INVITE_STATUS_SENT" }, }; AccessInvitationListResult result = await confluentOrganization.GetAccessInvitationsAsync(content); @@ -562,9 +530,9 @@ public async Task InviteUser_AccessInviteUser() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - AccessInvitationContent content = new AccessInvitationContent() + AccessInvitationContent content = new AccessInvitationContent { - InvitedUserDetails = new AccessInvitedUserDetails() + InvitedUserDetails = new AccessInvitedUserDetails { InvitedEmail = "user2@onmicrosoft.com", AuthType = "AUTH_TYPE_SSO", @@ -596,12 +564,12 @@ public async Task GetAccessEnvironments_AccessEnvironmentList() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - AccessListContent content = new AccessListContent() + AccessListContent content = new AccessListContent { SearchFilters = { ["pageSize"] = "10", -["pageToken"] = "asc4fts4ft", +["pageToken"] = "asc4fts4ft" }, }; AccessEnvironmentListResult result = await confluentOrganization.GetAccessEnvironmentsAsync(content); @@ -630,12 +598,12 @@ public async Task GetAccessClusters_AccessClusterList() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - AccessListContent content = new AccessListContent() + AccessListContent content = new AccessListContent { SearchFilters = { ["pageSize"] = "10", -["pageToken"] = "asc4fts4ft", +["pageToken"] = "asc4fts4ft" }, }; AccessClusterListResult result = await confluentOrganization.GetAccessClustersAsync(content); @@ -664,12 +632,12 @@ public async Task GetAccessRoleBindings_AccessRoleBindingList() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - AccessListContent content = new AccessListContent() + AccessListContent content = new AccessListContent { SearchFilters = { ["pageSize"] = "10", -["pageToken"] = "asc4fts4ft", +["pageToken"] = "asc4fts4ft" }, }; AccessRoleBindingListResult result = await confluentOrganization.GetAccessRoleBindingsAsync(content); @@ -698,7 +666,7 @@ public async Task CreateAccessRoleBinding_AccessCreateRoleBinding() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - AccessRoleBindingCreateContent content = new AccessRoleBindingCreateContent() + AccessRoleBindingCreateContent content = new AccessRoleBindingCreateContent { Principal = "User:u-111aaa", RoleName = "CloudClusterAdmin", @@ -757,12 +725,12 @@ public async Task GetAccessRoleBindingNames_AccessRoleBindingNameList() ConfluentOrganizationResource confluentOrganization = client.GetConfluentOrganizationResource(confluentOrganizationResourceId); // invoke the operation - AccessListContent content = new AccessListContent() + AccessListContent content = new AccessListContent { SearchFilters = { ["crn_pattern"] = "crn://confluent.cloud/organization=1aa7de07-298e-479c-8f2f-16ac91fd8e76", -["namespace"] = "public,dataplane,networking,identity,datagovernance,connect,streamcatalog,pipelines,ksql", +["namespace"] = "public,dataplane,networking,identity,datagovernance,connect,streamcatalog,pipelines,ksql" }, }; AccessRoleBindingNameListResult result = await confluentOrganization.GetAccessRoleBindingNamesAsync(content); diff --git a/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index abe211ccf4e65..b6c14aed81141 100644 --- a/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -41,10 +41,7 @@ public async Task ValidateOrganization_ValidationsValidateOrganizations() ConfluentOrganizationData data = new ConfluentOrganizationData(new AzureLocation("West US"), new ConfluentOfferDetail("string", "string", "string", "string", "string") { PrivateOfferId = "string", - PrivateOfferIds = -{ -"string" -}, + PrivateOfferIds = { "string" }, }, new ConfluentUserDetail("abc@microsoft.com") { FirstName = "string", @@ -55,7 +52,7 @@ public async Task ValidateOrganization_ValidationsValidateOrganizations() { Tags = { -["Environment"] = "Dev", +["Environment"] = "Dev" }, }; ConfluentOrganizationResource result = await resourceGroupResource.ValidateOrganizationAsync(organizationName, data); @@ -91,10 +88,7 @@ public async Task ValidateOrganizationV2_ValidationsValidateOrganizations() ConfluentOrganizationData data = new ConfluentOrganizationData(new AzureLocation("West US"), new ConfluentOfferDetail("string", "string", "string", "string", "string") { PrivateOfferId = "string", - PrivateOfferIds = -{ -"string" -}, + PrivateOfferIds = { "string" }, }, new ConfluentUserDetail("abc@microsoft.com") { FirstName = "string", @@ -105,7 +99,7 @@ public async Task ValidateOrganizationV2_ValidationsValidateOrganizations() { Tags = { -["Environment"] = "Dev", +["Environment"] = "Dev" }, }; ConfluentOrganizationValidationResult result = await resourceGroupResource.ValidateOrganizationV2Async(organizationName, data); diff --git a/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 56cc1002af244..6e96d95d86727 100644 --- a/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/confluent/Azure.ResourceManager.Confluent/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -67,5 +67,36 @@ public async Task CreateMarketplaceAgreement_MarketplaceAgreementsCreate() Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetConfluentOrganizations_OrganizationListBySubscription() + { + // Generated from example definition: specification/confluent/resource-manager/Microsoft.Confluent/stable/2024-02-13/examples/Organization_ListBySubscription.json + // this example is just showing the usage of "Organization_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ConfluentOrganizationResource item in subscriptionResource.GetConfluentOrganizationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConfluentOrganizationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..fdbc34d84687a --- /dev/null +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,236 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ConnectedVMwarevSphere.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVMwareResourcePools_ListResourcePools() + { + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListResourcePools.json + // this example is just showing the usage of "ResourcePools_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VMwareResourcePoolResource item in subscriptionResource.GetVMwareResourcePoolsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareResourcePoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVMwareClusters_ListClusters() + { + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListClusters.json + // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VMwareClusterResource item in subscriptionResource.GetVMwareClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVMwareHosts_ListHosts() + { + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListHosts.json + // this example is just showing the usage of "Hosts_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VMwareHostResource item in subscriptionResource.GetVMwareHostsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareHostData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVMwareDatastores_ListDatastores() + { + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListDatastores.json + // this example is just showing the usage of "Datastores_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VMwareDatastoreResource item in subscriptionResource.GetVMwareDatastoresAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareDatastoreData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVMwareVCenters_ListVCenters() + { + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVCenters.json + // this example is just showing the usage of "VCenters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VMwareVCenterResource item in subscriptionResource.GetVMwareVCentersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareVCenterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVMwareVmTemplates_ListVirtualMachineTemplates() + { + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVirtualMachineTemplates.json + // this example is just showing the usage of "VirtualMachineTemplates_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VMwareVmTemplateResource item in subscriptionResource.GetVMwareVmTemplatesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareVmTemplateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVMwareVirtualNetworks_ListVirtualNetworks() + { + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVirtualNetworks.json + // this example is just showing the usage of "VirtualNetworks_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VMwareVirtualNetworkResource item in subscriptionResource.GetVMwareVirtualNetworksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareVirtualNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VCenterInventoryItemCollection.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VCenterInventoryItemCollection.cs index d7b54a17b76bd..255210235d509 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VCenterInventoryItemCollection.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VCenterInventoryItemCollection.cs @@ -88,10 +88,10 @@ public async Task Get_GetInventoryItem() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetInventoryItem() + public async Task GetAll_InventoryItemsListByVCenter() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetInventoryItem.json - // this example is just showing the usage of "InventoryItems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/InventoryItems_ListByVCenter.json + // this example is just showing the usage of "InventoryItems_ListByVCenter" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_GetInventoryItem() // get the collection of this VCenterInventoryItemResource VCenterInventoryItemCollection collection = vMwareVCenter.GetVCenterInventoryItems(); - // invoke the operation - string inventoryItemName = "testItem"; - bool result = await collection.ExistsAsync(inventoryItemName); + // invoke the operation and iterate over the result + await foreach (VCenterInventoryItemResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VCenterInventoryItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInventoryItem() + public async Task Exists_GetInventoryItem() { // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetInventoryItem.json // this example is just showing the usage of "InventoryItems_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_GetInventoryItem() // invoke the operation string inventoryItemName = "testItem"; - NullableResponse response = await collection.GetIfExistsAsync(inventoryItemName); - VCenterInventoryItemResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(inventoryItemName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VCenterInventoryItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InventoryItemsListByVCenter() + public async Task GetIfExists_GetInventoryItem() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/InventoryItems_ListByVCenter.json - // this example is just showing the usage of "InventoryItems_ListByVCenter" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetInventoryItem.json + // this example is just showing the usage of "InventoryItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_InventoryItemsListByVCenter() // get the collection of this VCenterInventoryItemResource VCenterInventoryItemCollection collection = vMwareVCenter.GetVCenterInventoryItems(); - // invoke the operation and iterate over the result - await foreach (VCenterInventoryItemResource item in collection.GetAllAsync()) + // invoke the operation + string inventoryItemName = "testItem"; + NullableResponse response = await collection.GetIfExistsAsync(inventoryItemName); + VCenterInventoryItemResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VCenterInventoryItemData resourceData = item.Data; + VCenterInventoryItemData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VCenterInventoryItemResource.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VCenterInventoryItemResource.cs index f38203deae623..3c45492ced2b6 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VCenterInventoryItemResource.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VCenterInventoryItemResource.cs @@ -18,10 +18,10 @@ public partial class Sample_VCenterInventoryItemResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateInventoryItem() + public async Task Get_GetInventoryItem() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/CreateInventoryItem.json - // this example is just showing the usage of "InventoryItems_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetInventoryItem.json + // this example is just showing the usage of "InventoryItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Update_CreateInventoryItem() VCenterInventoryItemResource vCenterInventoryItem = client.GetVCenterInventoryItemResource(vCenterInventoryItemResourceId); // invoke the operation - VCenterInventoryItemData data = new VCenterInventoryItemData(VCenterInventoryType.ResourcePool); - ArmOperation lro = await vCenterInventoryItem.UpdateAsync(WaitUntil.Completed, data); - VCenterInventoryItemResource result = lro.Value; + VCenterInventoryItemResource result = await vCenterInventoryItem.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +49,10 @@ public async Task Update_CreateInventoryItem() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInventoryItem() + public async Task Delete_DeleteInventoryItem() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetInventoryItem.json - // this example is just showing the usage of "InventoryItems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteInventoryItem.json + // this example is just showing the usage of "InventoryItems_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,21 +69,17 @@ public async Task Get_GetInventoryItem() VCenterInventoryItemResource vCenterInventoryItem = client.GetVCenterInventoryItemResource(vCenterInventoryItemResourceId); // invoke the operation - VCenterInventoryItemResource result = await vCenterInventoryItem.GetAsync(); + await vCenterInventoryItem.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VCenterInventoryItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteInventoryItem() + public async Task Update_CreateInventoryItem() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteInventoryItem.json - // this example is just showing the usage of "InventoryItems_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/CreateInventoryItem.json + // this example is just showing the usage of "InventoryItems_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_DeleteInventoryItem() VCenterInventoryItemResource vCenterInventoryItem = client.GetVCenterInventoryItemResource(vCenterInventoryItemResourceId); // invoke the operation - await vCenterInventoryItem.DeleteAsync(WaitUntil.Completed); + VCenterInventoryItemData data = new VCenterInventoryItemData(VCenterInventoryType.ResourcePool); + ArmOperation lro = await vCenterInventoryItem.UpdateAsync(WaitUntil.Completed, data); + VCenterInventoryItemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VCenterInventoryItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareClusterCollection.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareClusterCollection.cs index 06fb06e2254b7..27ffe1ab59c17 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareClusterCollection.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareClusterCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateCluster() string clusterName = "HRCluster"; VMwareClusterData data = new VMwareClusterData(new AzureLocation("East US")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", }, @@ -95,10 +95,10 @@ public async Task Get_GetCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCluster() + public async Task GetAll_ListClustersByResourceGroup() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetCluster.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListClustersByResourceGroup.json + // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +115,22 @@ public async Task Exists_GetCluster() // get the collection of this VMwareClusterResource VMwareClusterCollection collection = resourceGroupResource.GetVMwareClusters(); - // invoke the operation - string clusterName = "HRCluster"; - bool result = await collection.ExistsAsync(clusterName); + // invoke the operation and iterate over the result + await foreach (VMwareClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCluster() + public async Task Exists_GetCluster() { // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetCluster.json // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +152,17 @@ public async Task GetIfExists_GetCluster() // invoke the operation string clusterName = "HRCluster"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - VMwareClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListClustersByResourceGroup() + public async Task GetIfExists_GetCluster() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListClustersByResourceGroup.json - // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetCluster.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_ListClustersByResourceGroup() // get the collection of this VMwareClusterResource VMwareClusterCollection collection = resourceGroupResource.GetVMwareClusters(); - // invoke the operation and iterate over the result - await foreach (VMwareClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "HRCluster"; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + VMwareClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VMwareClusterData resourceData = item.Data; + VMwareClusterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareClusterResource.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareClusterResource.cs index 4cc58f444ff86..43508184ba2c3 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareClusterResource.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareClusterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ConnectedVMwarevSphere.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ConnectedVMwarevSphere.Samples @@ -49,10 +48,10 @@ public async Task Get_GetCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateCluster() + public async Task Delete_DeleteCluster() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateCluster.json - // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteCluster.json + // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_UpdateCluster() VMwareClusterResource vMwareCluster = client.GetVMwareClusterResource(vMwareClusterResourceId); // invoke the operation - VMwareResourcePatchContent content = new VMwareResourcePatchContent() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - VMwareClusterResource result = await vMwareCluster.UpdateAsync(content); + await vMwareCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteCluster() + public async Task Update_UpdateCluster() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteCluster.json - // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateCluster.json + // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_DeleteCluster() VMwareClusterResource vMwareCluster = client.GetVMwareClusterResource(vMwareClusterResourceId); // invoke the operation - await vMwareCluster.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVMwareClusters_ListClusters() - { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListClusters.json - // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VMwareClusterResource item in subscriptionResource.GetVMwareClustersAsync()) + VMwareResourcePatchContent content = new VMwareResourcePatchContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + VMwareClusterResource result = await vMwareCluster.UpdateAsync(content); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareDatastoreCollection.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareDatastoreCollection.cs index 3951c5584cb14..a5a5935641a47 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareDatastoreCollection.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareDatastoreCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateDatastore() string datastoreName = "HRDatastore"; VMwareDatastoreData data = new VMwareDatastoreData(new AzureLocation("East US")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", }, @@ -95,10 +95,10 @@ public async Task Get_GetDatastore() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDatastore() + public async Task GetAll_ListDatastoresByResourceGroup() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetDatastore.json - // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListDatastoresByResourceGroup.json + // this example is just showing the usage of "Datastores_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +115,22 @@ public async Task Exists_GetDatastore() // get the collection of this VMwareDatastoreResource VMwareDatastoreCollection collection = resourceGroupResource.GetVMwareDatastores(); - // invoke the operation - string datastoreName = "HRDatastore"; - bool result = await collection.ExistsAsync(datastoreName); + // invoke the operation and iterate over the result + await foreach (VMwareDatastoreResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareDatastoreData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDatastore() + public async Task Exists_GetDatastore() { // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetDatastore.json // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +152,17 @@ public async Task GetIfExists_GetDatastore() // invoke the operation string datastoreName = "HRDatastore"; - NullableResponse response = await collection.GetIfExistsAsync(datastoreName); - VMwareDatastoreResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(datastoreName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareDatastoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDatastoresByResourceGroup() + public async Task GetIfExists_GetDatastore() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListDatastoresByResourceGroup.json - // this example is just showing the usage of "Datastores_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetDatastore.json + // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_ListDatastoresByResourceGroup() // get the collection of this VMwareDatastoreResource VMwareDatastoreCollection collection = resourceGroupResource.GetVMwareDatastores(); - // invoke the operation and iterate over the result - await foreach (VMwareDatastoreResource item in collection.GetAllAsync()) + // invoke the operation + string datastoreName = "HRDatastore"; + NullableResponse response = await collection.GetIfExistsAsync(datastoreName); + VMwareDatastoreResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VMwareDatastoreData resourceData = item.Data; + VMwareDatastoreData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareDatastoreResource.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareDatastoreResource.cs index 2c7b4681f16e1..46e395961f6ab 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareDatastoreResource.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareDatastoreResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ConnectedVMwarevSphere.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ConnectedVMwarevSphere.Samples @@ -49,10 +48,10 @@ public async Task Get_GetDatastore() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateDatastore() + public async Task Delete_DeleteDatastore() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateDatastore.json - // this example is just showing the usage of "Datastores_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteDatastore.json + // this example is just showing the usage of "Datastores_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_UpdateDatastore() VMwareDatastoreResource vMwareDatastore = client.GetVMwareDatastoreResource(vMwareDatastoreResourceId); // invoke the operation - VMwareResourcePatchContent content = new VMwareResourcePatchContent() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - VMwareDatastoreResource result = await vMwareDatastore.UpdateAsync(content); + await vMwareDatastore.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareDatastoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDatastore() + public async Task Update_UpdateDatastore() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteDatastore.json - // this example is just showing the usage of "Datastores_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateDatastore.json + // this example is just showing the usage of "Datastores_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_DeleteDatastore() VMwareDatastoreResource vMwareDatastore = client.GetVMwareDatastoreResource(vMwareDatastoreResourceId); // invoke the operation - await vMwareDatastore.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVMwareDatastores_ListDatastores() - { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListDatastores.json - // this example is just showing the usage of "Datastores_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VMwareDatastoreResource item in subscriptionResource.GetVMwareDatastoresAsync()) + VMwareResourcePatchContent content = new VMwareResourcePatchContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareDatastoreData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + VMwareDatastoreResource result = await vMwareDatastore.UpdateAsync(content); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareDatastoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareHostCollection.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareHostCollection.cs index 1cb03da7d3037..5fdc397468738 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareHostCollection.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareHostCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateHost() string hostName = "HRHost"; VMwareHostData data = new VMwareHostData(new AzureLocation("East US")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", }, @@ -95,10 +95,10 @@ public async Task Get_GetHost() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetHost() + public async Task GetAll_ListHostsByResourceGroup() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetHost.json - // this example is just showing the usage of "Hosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListHostsByResourceGroup.json + // this example is just showing the usage of "Hosts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +115,22 @@ public async Task Exists_GetHost() // get the collection of this VMwareHostResource VMwareHostCollection collection = resourceGroupResource.GetVMwareHosts(); - // invoke the operation - string hostName = "HRHost"; - bool result = await collection.ExistsAsync(hostName); + // invoke the operation and iterate over the result + await foreach (VMwareHostResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareHostData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetHost() + public async Task Exists_GetHost() { // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetHost.json // this example is just showing the usage of "Hosts_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +152,17 @@ public async Task GetIfExists_GetHost() // invoke the operation string hostName = "HRHost"; - NullableResponse response = await collection.GetIfExistsAsync(hostName); - VMwareHostResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(hostName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListHostsByResourceGroup() + public async Task GetIfExists_GetHost() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListHostsByResourceGroup.json - // this example is just showing the usage of "Hosts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetHost.json + // this example is just showing the usage of "Hosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_ListHostsByResourceGroup() // get the collection of this VMwareHostResource VMwareHostCollection collection = resourceGroupResource.GetVMwareHosts(); - // invoke the operation and iterate over the result - await foreach (VMwareHostResource item in collection.GetAllAsync()) + // invoke the operation + string hostName = "HRHost"; + NullableResponse response = await collection.GetIfExistsAsync(hostName); + VMwareHostResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VMwareHostData resourceData = item.Data; + VMwareHostData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareHostResource.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareHostResource.cs index a20ee500bd381..adcf6292c871b 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareHostResource.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareHostResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ConnectedVMwarevSphere.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ConnectedVMwarevSphere.Samples @@ -49,10 +48,10 @@ public async Task Get_GetHost() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateHost() + public async Task Delete_DeleteHost() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateHost.json - // this example is just showing the usage of "Hosts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteHost.json + // this example is just showing the usage of "Hosts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_UpdateHost() VMwareHostResource vMwareHost = client.GetVMwareHostResource(vMwareHostResourceId); // invoke the operation - VMwareResourcePatchContent content = new VMwareResourcePatchContent() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - VMwareHostResource result = await vMwareHost.UpdateAsync(content); + await vMwareHost.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteHost() + public async Task Update_UpdateHost() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteHost.json - // this example is just showing the usage of "Hosts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateHost.json + // this example is just showing the usage of "Hosts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_DeleteHost() VMwareHostResource vMwareHost = client.GetVMwareHostResource(vMwareHostResourceId); // invoke the operation - await vMwareHost.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVMwareHosts_ListHosts() - { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListHosts.json - // this example is just showing the usage of "Hosts_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VMwareHostResource item in subscriptionResource.GetVMwareHostsAsync()) + VMwareResourcePatchContent content = new VMwareResourcePatchContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareHostData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + VMwareHostResource result = await vMwareHost.UpdateAsync(content); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareResourcePoolCollection.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareResourcePoolCollection.cs index 07e3931f5c607..6a295fd700d62 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareResourcePoolCollection.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareResourcePoolCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateResourcePool() string resourcePoolName = "HRPool"; VMwareResourcePoolData data = new VMwareResourcePoolData(new AzureLocation("East US")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", }, @@ -95,10 +95,10 @@ public async Task Get_GetResourcePool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetResourcePool() + public async Task GetAll_ListResourcePoolsByResourceGroup() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetResourcePool.json - // this example is just showing the usage of "ResourcePools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListResourcePoolsByResourceGroup.json + // this example is just showing the usage of "ResourcePools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +115,22 @@ public async Task Exists_GetResourcePool() // get the collection of this VMwareResourcePoolResource VMwareResourcePoolCollection collection = resourceGroupResource.GetVMwareResourcePools(); - // invoke the operation - string resourcePoolName = "HRPool"; - bool result = await collection.ExistsAsync(resourcePoolName); + // invoke the operation and iterate over the result + await foreach (VMwareResourcePoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareResourcePoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetResourcePool() + public async Task Exists_GetResourcePool() { // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetResourcePool.json // this example is just showing the usage of "ResourcePools_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +152,17 @@ public async Task GetIfExists_GetResourcePool() // invoke the operation string resourcePoolName = "HRPool"; - NullableResponse response = await collection.GetIfExistsAsync(resourcePoolName); - VMwareResourcePoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourcePoolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareResourcePoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListResourcePoolsByResourceGroup() + public async Task GetIfExists_GetResourcePool() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListResourcePoolsByResourceGroup.json - // this example is just showing the usage of "ResourcePools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetResourcePool.json + // this example is just showing the usage of "ResourcePools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_ListResourcePoolsByResourceGroup() // get the collection of this VMwareResourcePoolResource VMwareResourcePoolCollection collection = resourceGroupResource.GetVMwareResourcePools(); - // invoke the operation and iterate over the result - await foreach (VMwareResourcePoolResource item in collection.GetAllAsync()) + // invoke the operation + string resourcePoolName = "HRPool"; + NullableResponse response = await collection.GetIfExistsAsync(resourcePoolName); + VMwareResourcePoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VMwareResourcePoolData resourceData = item.Data; + VMwareResourcePoolData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareResourcePoolResource.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareResourcePoolResource.cs index 136c75a72449b..2600a2b952f6c 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareResourcePoolResource.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareResourcePoolResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ConnectedVMwarevSphere.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ConnectedVMwarevSphere.Samples @@ -49,10 +48,10 @@ public async Task Get_GetResourcePool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateResourcePool() + public async Task Delete_DeleteResourcePool() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateResourcePool.json - // this example is just showing the usage of "ResourcePools_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteResourcePool.json + // this example is just showing the usage of "ResourcePools_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_UpdateResourcePool() VMwareResourcePoolResource vMwareResourcePool = client.GetVMwareResourcePoolResource(vMwareResourcePoolResourceId); // invoke the operation - VMwareResourcePatchContent content = new VMwareResourcePatchContent() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - VMwareResourcePoolResource result = await vMwareResourcePool.UpdateAsync(content); + await vMwareResourcePool.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareResourcePoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteResourcePool() + public async Task Update_UpdateResourcePool() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteResourcePool.json - // this example is just showing the usage of "ResourcePools_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateResourcePool.json + // this example is just showing the usage of "ResourcePools_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_DeleteResourcePool() VMwareResourcePoolResource vMwareResourcePool = client.GetVMwareResourcePoolResource(vMwareResourcePoolResourceId); // invoke the operation - await vMwareResourcePool.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVMwareResourcePools_ListResourcePools() - { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListResourcePools.json - // this example is just showing the usage of "ResourcePools_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VMwareResourcePoolResource item in subscriptionResource.GetVMwareResourcePoolsAsync()) + VMwareResourcePatchContent content = new VMwareResourcePatchContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareResourcePoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + VMwareResourcePoolResource result = await vMwareResourcePool.UpdateAsync(content); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareResourcePoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVCenterCollection.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVCenterCollection.cs index ea16f00616923..d5bcdc913a5a5 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVCenterCollection.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVCenterCollection.cs @@ -44,12 +44,12 @@ public async Task CreateOrUpdate_CreateVCenter() string vcenterName = "ContosoVCenter"; VMwareVCenterData data = new VMwareVCenterData(new AzureLocation("East US"), "ContosoVMware.contoso.com") { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", }, Port = 1234, - Credentials = new VICredential() + Credentials = new VICredential { Username = "tempuser", Password = "", @@ -100,10 +100,10 @@ public async Task Get_GetVCenter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVCenter() + public async Task GetAll_ListVCentersByResourceGroup() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVCenter.json - // this example is just showing the usage of "VCenters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVCentersByResourceGroup.json + // this example is just showing the usage of "VCenters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,16 +120,22 @@ public async Task Exists_GetVCenter() // get the collection of this VMwareVCenterResource VMwareVCenterCollection collection = resourceGroupResource.GetVMwareVCenters(); - // invoke the operation - string vcenterName = "ContosoVCenter"; - bool result = await collection.ExistsAsync(vcenterName); + // invoke the operation and iterate over the result + await foreach (VMwareVCenterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareVCenterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVCenter() + public async Task Exists_GetVCenter() { // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVCenter.json // this example is just showing the usage of "VCenters_Get" operation, for the dependent resources, they will have to be created separately. @@ -151,29 +157,17 @@ public async Task GetIfExists_GetVCenter() // invoke the operation string vcenterName = "ContosoVCenter"; - NullableResponse response = await collection.GetIfExistsAsync(vcenterName); - VMwareVCenterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vcenterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareVCenterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVCentersByResourceGroup() + public async Task GetIfExists_GetVCenter() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVCentersByResourceGroup.json - // this example is just showing the usage of "VCenters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVCenter.json + // this example is just showing the usage of "VCenters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +184,23 @@ public async Task GetAll_ListVCentersByResourceGroup() // get the collection of this VMwareVCenterResource VMwareVCenterCollection collection = resourceGroupResource.GetVMwareVCenters(); - // invoke the operation and iterate over the result - await foreach (VMwareVCenterResource item in collection.GetAllAsync()) + // invoke the operation + string vcenterName = "ContosoVCenter"; + NullableResponse response = await collection.GetIfExistsAsync(vcenterName); + VMwareVCenterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VMwareVCenterData resourceData = item.Data; + VMwareVCenterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVCenterResource.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVCenterResource.cs index 52faa07f4b18a..244ec32edb027 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVCenterResource.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVCenterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ConnectedVMwarevSphere.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ConnectedVMwarevSphere.Samples @@ -49,10 +48,10 @@ public async Task Get_GetVCenter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateVCenter() + public async Task Delete_DeleteVCenter() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateVCenter.json - // this example is just showing the usage of "VCenters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteVCenter.json + // this example is just showing the usage of "VCenters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_UpdateVCenter() VMwareVCenterResource vMwareVCenter = client.GetVMwareVCenterResource(vMwareVCenterResourceId); // invoke the operation - VMwareResourcePatchContent content = new VMwareResourcePatchContent() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - VMwareVCenterResource result = await vMwareVCenter.UpdateAsync(content); + await vMwareVCenter.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareVCenterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVCenter() + public async Task Update_UpdateVCenter() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteVCenter.json - // this example is just showing the usage of "VCenters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateVCenter.json + // this example is just showing the usage of "VCenters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_DeleteVCenter() VMwareVCenterResource vMwareVCenter = client.GetVMwareVCenterResource(vMwareVCenterResourceId); // invoke the operation - await vMwareVCenter.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVMwareVCenters_ListVCenters() - { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVCenters.json - // this example is just showing the usage of "VCenters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VMwareVCenterResource item in subscriptionResource.GetVMwareVCentersAsync()) + VMwareResourcePatchContent content = new VMwareResourcePatchContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareVCenterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + VMwareVCenterResource result = await vMwareVCenter.UpdateAsync(content); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareVCenterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVirtualNetworkCollection.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVirtualNetworkCollection.cs index b24b4b0539a6f..c346e2368617e 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVirtualNetworkCollection.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVirtualNetworkCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateVirtualNetwork() string virtualNetworkName = "ProdNetwork"; VMwareVirtualNetworkData data = new VMwareVirtualNetworkData(new AzureLocation("East US")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", }, @@ -95,10 +95,10 @@ public async Task Get_GetVirtualNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetwork() + public async Task GetAll_ListVirtualNetworksByResourceGroup() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVirtualNetwork.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVirtualNetworksByResourceGroup.json + // this example is just showing the usage of "VirtualNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +115,22 @@ public async Task Exists_GetVirtualNetwork() // get the collection of this VMwareVirtualNetworkResource VMwareVirtualNetworkCollection collection = resourceGroupResource.GetVMwareVirtualNetworks(); - // invoke the operation - string virtualNetworkName = "ProdNetwork"; - bool result = await collection.ExistsAsync(virtualNetworkName); + // invoke the operation and iterate over the result + await foreach (VMwareVirtualNetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareVirtualNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetwork() + public async Task Exists_GetVirtualNetwork() { // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVirtualNetwork.json // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +152,17 @@ public async Task GetIfExists_GetVirtualNetwork() // invoke the operation string virtualNetworkName = "ProdNetwork"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); - VMwareVirtualNetworkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(virtualNetworkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareVirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworksByResourceGroup() + public async Task GetIfExists_GetVirtualNetwork() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVirtualNetworksByResourceGroup.json - // this example is just showing the usage of "VirtualNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVirtualNetwork.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_ListVirtualNetworksByResourceGroup() // get the collection of this VMwareVirtualNetworkResource VMwareVirtualNetworkCollection collection = resourceGroupResource.GetVMwareVirtualNetworks(); - // invoke the operation and iterate over the result - await foreach (VMwareVirtualNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkName = "ProdNetwork"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); + VMwareVirtualNetworkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VMwareVirtualNetworkData resourceData = item.Data; + VMwareVirtualNetworkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVirtualNetworkResource.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVirtualNetworkResource.cs index 5d96df691af0a..0f3694869fe28 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVirtualNetworkResource.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVirtualNetworkResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ConnectedVMwarevSphere.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ConnectedVMwarevSphere.Samples @@ -49,10 +48,10 @@ public async Task Get_GetVirtualNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateVirtualNetwork() + public async Task Delete_DeleteVirtualNetwork() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateVirtualNetwork.json - // this example is just showing the usage of "VirtualNetworks_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteVirtualNetwork.json + // this example is just showing the usage of "VirtualNetworks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_UpdateVirtualNetwork() VMwareVirtualNetworkResource vMwareVirtualNetwork = client.GetVMwareVirtualNetworkResource(vMwareVirtualNetworkResourceId); // invoke the operation - VMwareResourcePatchContent content = new VMwareResourcePatchContent() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - VMwareVirtualNetworkResource result = await vMwareVirtualNetwork.UpdateAsync(content); + await vMwareVirtualNetwork.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareVirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualNetwork() + public async Task Update_UpdateVirtualNetwork() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteVirtualNetwork.json - // this example is just showing the usage of "VirtualNetworks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateVirtualNetwork.json + // this example is just showing the usage of "VirtualNetworks_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_DeleteVirtualNetwork() VMwareVirtualNetworkResource vMwareVirtualNetwork = client.GetVMwareVirtualNetworkResource(vMwareVirtualNetworkResourceId); // invoke the operation - await vMwareVirtualNetwork.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVMwareVirtualNetworks_ListVirtualNetworks() - { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVirtualNetworks.json - // this example is just showing the usage of "VirtualNetworks_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VMwareVirtualNetworkResource item in subscriptionResource.GetVMwareVirtualNetworksAsync()) + VMwareResourcePatchContent content = new VMwareResourcePatchContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareVirtualNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + VMwareVirtualNetworkResource result = await vMwareVirtualNetwork.UpdateAsync(content); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareVirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmInstanceResource.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmInstanceResource.cs index 38aaa979081eb..93b73e85183bf 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmInstanceResource.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmInstanceResource.cs @@ -19,10 +19,10 @@ public partial class Sample_VMwareVmInstanceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualMachine() + public async Task Get_GetVirtualMachine() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/CreateVirtualMachineInstance.json - // this example is just showing the usage of "VirtualMachineInstances_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVirtualMachineInstance.json + // this example is just showing the usage of "VirtualMachineInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,29 +36,7 @@ public async Task CreateOrUpdate_CreateVirtualMachine() VMwareVmInstanceResource vMwareVmInstance = client.GetVMwareVmInstanceResource(vMwareVmInstanceResourceId); // invoke the operation - VMwareVmInstanceData data = new VMwareVmInstanceData() - { - ExtendedLocation = new ExtendedLocation() - { - Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", - }, - PlacementProfile = new PlacementProfile() - { - ResourcePoolId = "/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool", - }, - HardwareProfile = new VmInstanceHardwareProfile() - { - MemorySizeMB = 4196, - NumCpus = 4, - }, - InfrastructureProfile = new VCenterInfrastructureProfile() - { - TemplateId = "/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate", - VCenterId = "/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter", - }, - }; - ArmOperation lro = await vMwareVmInstance.CreateOrUpdateAsync(WaitUntil.Completed, data); - VMwareVmInstanceResource result = lro.Value; + VMwareVmInstanceResource result = await vMwareVmInstance.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -69,10 +47,10 @@ public async Task CreateOrUpdate_CreateVirtualMachine() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualMachine() + public async Task Delete_DeleteVirtualMachine() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVirtualMachineInstance.json - // this example is just showing the usage of "VirtualMachineInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteVirtualMachineInstance.json + // this example is just showing the usage of "VirtualMachineInstances_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -86,13 +64,9 @@ public async Task Get_GetVirtualMachine() VMwareVmInstanceResource vMwareVmInstance = client.GetVMwareVmInstanceResource(vMwareVmInstanceResourceId); // invoke the operation - VMwareVmInstanceResource result = await vMwareVmInstance.GetAsync(); + await vMwareVmInstance.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareVmInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -114,9 +88,9 @@ public async Task Update_UpdateVirtualMachine() VMwareVmInstanceResource vMwareVmInstance = client.GetVMwareVmInstanceResource(vMwareVmInstanceResourceId); // invoke the operation - VMwareVmInstancePatch patch = new VMwareVmInstancePatch() + VMwareVmInstancePatch patch = new VMwareVmInstancePatch { - HardwareProfile = new VmInstanceHardwareProfile() + HardwareProfile = new VmInstanceHardwareProfile { MemorySizeMB = 4196, NumCpus = 4, @@ -134,10 +108,10 @@ public async Task Update_UpdateVirtualMachine() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualMachine() + public async Task CreateOrUpdate_CreateVirtualMachine() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteVirtualMachineInstance.json - // this example is just showing the usage of "VirtualMachineInstances_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/CreateVirtualMachineInstance.json + // this example is just showing the usage of "VirtualMachineInstances_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,9 +125,35 @@ public async Task Delete_DeleteVirtualMachine() VMwareVmInstanceResource vMwareVmInstance = client.GetVMwareVmInstanceResource(vMwareVmInstanceResourceId); // invoke the operation - await vMwareVmInstance.DeleteAsync(WaitUntil.Completed); + VMwareVmInstanceData data = new VMwareVmInstanceData + { + ExtendedLocation = new ExtendedLocation + { + Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", + }, + PlacementProfile = new PlacementProfile + { + ResourcePoolId = "/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/ResourcePools/HRPool", + }, + HardwareProfile = new VmInstanceHardwareProfile + { + MemorySizeMB = 4196, + NumCpus = 4, + }, + InfrastructureProfile = new VCenterInfrastructureProfile + { + TemplateId = "/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VirtualMachineTemplates/WebFrontEndTemplate", + VCenterId = "/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ConnectedVMwarevSphere/VCenters/ContosoVCenter", + }, + }; + ArmOperation lro = await vMwareVmInstance.CreateOrUpdateAsync(WaitUntil.Completed, data); + VMwareVmInstanceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareVmInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -175,7 +175,7 @@ public async Task Stop_StopVirtualMachine() VMwareVmInstanceResource vMwareVmInstance = client.GetVMwareVmInstanceResource(vMwareVmInstanceResourceId); // invoke the operation - StopVirtualMachineContent content = new StopVirtualMachineContent() + StopVirtualMachineContent content = new StopVirtualMachineContent { SkipShutdown = true, }; diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmTemplateCollection.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmTemplateCollection.cs index 2413a4d6699e9..20b3c1e86f79e 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmTemplateCollection.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmTemplateCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateVirtualMachineTemplate() string virtualMachineTemplateName = "WebFrontEndTemplate"; VMwareVmTemplateData data = new VMwareVmTemplateData(new AzureLocation("East US")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", }, @@ -95,10 +95,10 @@ public async Task Get_GetVirtualMachineTemplate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualMachineTemplate() + public async Task GetAll_ListVirtualMachineTemplatesByResourceGroup() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVirtualMachineTemplate.json - // this example is just showing the usage of "VirtualMachineTemplates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVirtualMachineTemplatesByResourceGroup.json + // this example is just showing the usage of "VirtualMachineTemplates_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +115,22 @@ public async Task Exists_GetVirtualMachineTemplate() // get the collection of this VMwareVmTemplateResource VMwareVmTemplateCollection collection = resourceGroupResource.GetVMwareVmTemplates(); - // invoke the operation - string virtualMachineTemplateName = "WebFrontEndTemplate"; - bool result = await collection.ExistsAsync(virtualMachineTemplateName); + // invoke the operation and iterate over the result + await foreach (VMwareVmTemplateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareVmTemplateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualMachineTemplate() + public async Task Exists_GetVirtualMachineTemplate() { // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVirtualMachineTemplate.json // this example is just showing the usage of "VirtualMachineTemplates_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +152,17 @@ public async Task GetIfExists_GetVirtualMachineTemplate() // invoke the operation string virtualMachineTemplateName = "WebFrontEndTemplate"; - NullableResponse response = await collection.GetIfExistsAsync(virtualMachineTemplateName); - VMwareVmTemplateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(virtualMachineTemplateName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareVmTemplateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualMachineTemplatesByResourceGroup() + public async Task GetIfExists_GetVirtualMachineTemplate() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVirtualMachineTemplatesByResourceGroup.json - // this example is just showing the usage of "VirtualMachineTemplates_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVirtualMachineTemplate.json + // this example is just showing the usage of "VirtualMachineTemplates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_ListVirtualMachineTemplatesByResourceGroup() // get the collection of this VMwareVmTemplateResource VMwareVmTemplateCollection collection = resourceGroupResource.GetVMwareVmTemplates(); - // invoke the operation and iterate over the result - await foreach (VMwareVmTemplateResource item in collection.GetAllAsync()) + // invoke the operation + string virtualMachineTemplateName = "WebFrontEndTemplate"; + NullableResponse response = await collection.GetIfExistsAsync(virtualMachineTemplateName); + VMwareVmTemplateResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VMwareVmTemplateData resourceData = item.Data; + VMwareVmTemplateData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmTemplateResource.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmTemplateResource.cs index a5b909b418401..82744cc2df804 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmTemplateResource.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VMwareVmTemplateResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ConnectedVMwarevSphere.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ConnectedVMwarevSphere.Samples @@ -49,10 +48,10 @@ public async Task Get_GetVirtualMachineTemplate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateVirtualMachineTemplate() + public async Task Delete_DeleteVirtualMachineTemplate() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateVirtualMachineTemplate.json - // this example is just showing the usage of "VirtualMachineTemplates_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteVirtualMachineTemplate.json + // this example is just showing the usage of "VirtualMachineTemplates_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_UpdateVirtualMachineTemplate() VMwareVmTemplateResource vMwareVmTemplate = client.GetVMwareVmTemplateResource(vMwareVmTemplateResourceId); // invoke the operation - VMwareResourcePatchContent content = new VMwareResourcePatchContent() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - VMwareVmTemplateResource result = await vMwareVmTemplate.UpdateAsync(content); + await vMwareVmTemplate.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareVmTemplateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualMachineTemplate() + public async Task Update_UpdateVirtualMachineTemplate() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteVirtualMachineTemplate.json - // this example is just showing the usage of "VirtualMachineTemplates_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/UpdateVirtualMachineTemplate.json + // this example is just showing the usage of "VirtualMachineTemplates_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_DeleteVirtualMachineTemplate() VMwareVmTemplateResource vMwareVmTemplate = client.GetVMwareVmTemplateResource(vMwareVmTemplateResourceId); // invoke the operation - await vMwareVmTemplate.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVMwareVmTemplates_ListVirtualMachineTemplates() - { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/ListVirtualMachineTemplates.json - // this example is just showing the usage of "VirtualMachineTemplates_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VMwareVmTemplateResource item in subscriptionResource.GetVMwareVmTemplatesAsync()) + VMwareResourcePatchContent content = new VMwareResourcePatchContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VMwareVmTemplateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + VMwareVmTemplateResource result = await vMwareVmTemplate.UpdateAsync(content); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VMwareVmTemplateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VmInstanceGuestAgentResource.cs b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VmInstanceGuestAgentResource.cs index c26edce18842a..4a99742b8ad3a 100644 --- a/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VmInstanceGuestAgentResource.cs +++ b/sdk/connectedvmwarevsphere/Azure.ResourceManager.ConnectedVMwarevSphere/samples/Generated/Samples/Sample_VmInstanceGuestAgentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_VmInstanceGuestAgentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateGuestAgent() + public async Task Get_GetGuestAgent() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/CreateVMInstanceGuestAgent.json - // this example is just showing the usage of "VMInstanceGuestAgents_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVMInstanceGuestAgent.json + // this example is just showing the usage of "VMInstanceGuestAgents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,19 +35,7 @@ public async Task CreateOrUpdate_CreateGuestAgent() VmInstanceGuestAgentResource vmInstanceGuestAgent = client.GetVmInstanceGuestAgentResource(vmInstanceGuestAgentResourceId); // invoke the operation - VmInstanceGuestAgentData data = new VmInstanceGuestAgentData() - { - Credentials = new VmInstanceGuestCredential() - { - Username = "tempuser", - Password = "", - }, - PrivateLinkScopeResourceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/privateLinkScopes/privateLinkScopeName"), - HttpsProxy = "http://192.1.2.3:8080", - ProvisioningAction = GuestAgentProvisioningAction.Install, - }; - ArmOperation lro = await vmInstanceGuestAgent.CreateOrUpdateAsync(WaitUntil.Completed, data); - VmInstanceGuestAgentResource result = lro.Value; + VmInstanceGuestAgentResource result = await vmInstanceGuestAgent.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +46,10 @@ public async Task CreateOrUpdate_CreateGuestAgent() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetGuestAgent() + public async Task Delete_DeleteGuestAgent() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/GetVMInstanceGuestAgent.json - // this example is just showing the usage of "VMInstanceGuestAgents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteVMInstanceGuestAgent.json + // this example is just showing the usage of "VMInstanceGuestAgents_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,21 +63,17 @@ public async Task Get_GetGuestAgent() VmInstanceGuestAgentResource vmInstanceGuestAgent = client.GetVmInstanceGuestAgentResource(vmInstanceGuestAgentResourceId); // invoke the operation - VmInstanceGuestAgentResource result = await vmInstanceGuestAgent.GetAsync(); + await vmInstanceGuestAgent.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VmInstanceGuestAgentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteGuestAgent() + public async Task CreateOrUpdate_CreateGuestAgent() { - // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/DeleteVMInstanceGuestAgent.json - // this example is just showing the usage of "VMInstanceGuestAgents_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/connectedvmware/resource-manager/Microsoft.ConnectedVMwarevSphere/stable/2023-12-01/examples/CreateVMInstanceGuestAgent.json + // this example is just showing the usage of "VMInstanceGuestAgents_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,9 +87,25 @@ public async Task Delete_DeleteGuestAgent() VmInstanceGuestAgentResource vmInstanceGuestAgent = client.GetVmInstanceGuestAgentResource(vmInstanceGuestAgentResourceId); // invoke the operation - await vmInstanceGuestAgent.DeleteAsync(WaitUntil.Completed); + VmInstanceGuestAgentData data = new VmInstanceGuestAgentData + { + Credentials = new VmInstanceGuestCredential + { + Username = "tempuser", + Password = "", + }, + PrivateLinkScopeResourceId = new ResourceIdentifier("/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.HybridCompute/privateLinkScopes/privateLinkScopeName"), + HttpsProxy = "http://192.1.2.3:8080", + ProvisioningAction = GuestAgentProvisioningAction.Install, + }; + ArmOperation lro = await vmInstanceGuestAgent.CreateOrUpdateAsync(WaitUntil.Completed, data); + VmInstanceGuestAgentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VmInstanceGuestAgentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/consumption/Azure.ResourceManager.Consumption/samples/Generated/Samples/Sample_ConsumptionBudgetCollection.cs b/sdk/consumption/Azure.ResourceManager.Consumption/samples/Generated/Samples/Sample_ConsumptionBudgetCollection.cs index 81b693b4d8644..af45bcfff6fe4 100644 --- a/sdk/consumption/Azure.ResourceManager.Consumption/samples/Generated/Samples/Sample_ConsumptionBudgetCollection.cs +++ b/sdk/consumption/Azure.ResourceManager.Consumption/samples/Generated/Samples/Sample_ConsumptionBudgetCollection.cs @@ -17,66 +17,58 @@ public partial class Sample_ConsumptionBudgetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BudgetsList() + public async Task Get_Budget() { - // Generated from example definition: specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/BudgetsList.json - // this example is just showing the usage of "Budgets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/Budget.json + // this example is just showing the usage of "Budgets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConsumptionBudgetResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ConsumptionBudgetCollection collection = client.GetConsumptionBudgets(scopeId); + ConsumptionBudgetCollection collection = client.GetConsumptionBudgets(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (ConsumptionBudgetResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConsumptionBudgetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string budgetName = "TestBudget"; + ConsumptionBudgetResource result = await collection.GetAsync(budgetName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConsumptionBudgetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_Budget() + public async Task GetAll_BudgetsList() { - // Generated from example definition: specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/Budget.json - // this example is just showing the usage of "Budgets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/consumption/resource-manager/Microsoft.Consumption/stable/2021-10-01/examples/BudgetsList.json + // this example is just showing the usage of "Budgets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConsumptionBudgetResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ConsumptionBudgetCollection collection = client.GetConsumptionBudgets(scopeId); + ConsumptionBudgetCollection collection = client.GetConsumptionBudgets(new ResourceIdentifier(scope)); - // invoke the operation - string budgetName = "TestBudget"; - ConsumptionBudgetResource result = await collection.GetAsync(budgetName); + // invoke the operation and iterate over the result + await foreach (ConsumptionBudgetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConsumptionBudgetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConsumptionBudgetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -91,13 +83,9 @@ public async Task Exists_Budget() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConsumptionBudgetResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ConsumptionBudgetCollection collection = client.GetConsumptionBudgets(scopeId); + ConsumptionBudgetCollection collection = client.GetConsumptionBudgets(new ResourceIdentifier(scope)); // invoke the operation string budgetName = "TestBudget"; @@ -118,13 +106,9 @@ public async Task GetIfExists_Budget() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConsumptionBudgetResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ConsumptionBudgetCollection collection = client.GetConsumptionBudgets(scopeId); + ConsumptionBudgetCollection collection = client.GetConsumptionBudgets(new ResourceIdentifier(scope)); // invoke the operation string budgetName = "TestBudget"; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppAuthConfigCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppAuthConfigCollection.cs index ae9b470a926a7..4038f0a3c3177 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppAuthConfigCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppAuthConfigCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerAppAuthConfigCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAuthConfigsByContainerApps() + public async Task CreateOrUpdate_CreateOrUpdateContainerAppAuthConfig() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/AuthConfigs_ListByContainer.json - // this example is just showing the usage of "ContainerAppsAuthConfigs_ListByContainerApp" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/AuthConfigs_CreateOrUpdate.json + // this example is just showing the usage of "ContainerAppsAuthConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,43 @@ public async Task GetAll_ListAuthConfigsByContainerApps() // get the collection of this ContainerAppAuthConfigResource ContainerAppAuthConfigCollection collection = containerApp.GetContainerAppAuthConfigs(); - // invoke the operation and iterate over the result - await foreach (ContainerAppAuthConfigResource item in collection.GetAllAsync()) + // invoke the operation + string authConfigName = "current"; + ContainerAppAuthConfigData data = new ContainerAppAuthConfigData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppAuthConfigData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Platform = new ContainerAppAuthPlatform + { + IsEnabled = true, + }, + GlobalValidation = new ContainerAppGlobalValidation + { + UnauthenticatedClientAction = ContainerAppUnauthenticatedClientActionV2.AllowAnonymous, + }, + IdentityProviders = new ContainerAppIdentityProvidersConfiguration + { + Facebook = new ContainerAppFacebookConfiguration + { + Registration = new ContainerAppRegistration + { + AppId = "123", + AppSecretSettingName = "facebook-secret", + }, + }, + }, + EncryptionSettings = new EncryptionSettings + { + ContainerAppAuthEncryptionSecretName = "testEncryptionSecretName", + ContainerAppAuthSigningSecretName = "testSigningSecretName", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authConfigName, data); + ContainerAppAuthConfigResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppAuthConfigData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +114,10 @@ public async Task Get_GetContainerAppSAuthConfig() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetContainerAppSAuthConfig() + public async Task GetAll_ListAuthConfigsByContainerApps() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/AuthConfigs_Get.json - // this example is just showing the usage of "ContainerAppsAuthConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/AuthConfigs_ListByContainer.json + // this example is just showing the usage of "ContainerAppsAuthConfigs_ListByContainerApp" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +135,22 @@ public async Task Exists_GetContainerAppSAuthConfig() // get the collection of this ContainerAppAuthConfigResource ContainerAppAuthConfigCollection collection = containerApp.GetContainerAppAuthConfigs(); - // invoke the operation - string authConfigName = "current"; - bool result = await collection.ExistsAsync(authConfigName); + // invoke the operation and iterate over the result + await foreach (ContainerAppAuthConfigResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppAuthConfigData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetContainerAppSAuthConfig() + public async Task Exists_GetContainerAppSAuthConfig() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/AuthConfigs_Get.json // this example is just showing the usage of "ContainerAppsAuthConfigs_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +173,17 @@ public async Task GetIfExists_GetContainerAppSAuthConfig() // invoke the operation string authConfigName = "current"; - NullableResponse response = await collection.GetIfExistsAsync(authConfigName); - ContainerAppAuthConfigResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(authConfigName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppAuthConfigData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateContainerAppAuthConfig() + public async Task GetIfExists_GetContainerAppSAuthConfig() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/AuthConfigs_CreateOrUpdate.json - // this example is just showing the usage of "ContainerAppsAuthConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/AuthConfigs_Get.json + // this example is just showing the usage of "ContainerAppsAuthConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,41 +203,21 @@ public async Task CreateOrUpdate_CreateOrUpdateContainerAppAuthConfig() // invoke the operation string authConfigName = "current"; - ContainerAppAuthConfigData data = new ContainerAppAuthConfigData() - { - Platform = new ContainerAppAuthPlatform() - { - IsEnabled = true, - }, - GlobalValidation = new ContainerAppGlobalValidation() - { - UnauthenticatedClientAction = ContainerAppUnauthenticatedClientActionV2.AllowAnonymous, - }, - IdentityProviders = new ContainerAppIdentityProvidersConfiguration() - { - Facebook = new ContainerAppFacebookConfiguration() - { - Registration = new ContainerAppRegistration() - { - AppId = "123", - AppSecretSettingName = "facebook-secret", - }, - }, - }, - EncryptionSettings = new EncryptionSettings() - { - ContainerAppAuthEncryptionSecretName = "testEncryptionSecretName", - ContainerAppAuthSigningSecretName = "testSigningSecretName", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authConfigName, data); - ContainerAppAuthConfigResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(authConfigName); + ContainerAppAuthConfigResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppAuthConfigData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppAuthConfigData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppAuthConfigResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppAuthConfigResource.cs index e0a3e494267c2..282fe7e664a97 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppAuthConfigResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppAuthConfigResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetContainerAppSAuthConfig() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteContainerAppAuthConfig() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/AuthConfigs_Delete.json + // this example is just showing the usage of "ContainerAppsAuthConfigs_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerAppAuthConfigResource created on azure + // for more information of creating ContainerAppAuthConfigResource, please refer to the document of ContainerAppAuthConfigResource + string subscriptionId = "651f8027-33e8-4ec4-97b4-f6e9f3dc8744"; + string resourceGroupName = "workerapps-rg-xj"; + string containerAppName = "testcanadacentral"; + string authConfigName = "current"; + ResourceIdentifier containerAppAuthConfigResourceId = ContainerAppAuthConfigResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, containerAppName, authConfigName); + ContainerAppAuthConfigResource containerAppAuthConfig = client.GetContainerAppAuthConfigResource(containerAppAuthConfigResourceId); + + // invoke the operation + await containerAppAuthConfig.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateContainerAppAuthConfig() @@ -69,28 +96,28 @@ public async Task Update_CreateOrUpdateContainerAppAuthConfig() ContainerAppAuthConfigResource containerAppAuthConfig = client.GetContainerAppAuthConfigResource(containerAppAuthConfigResourceId); // invoke the operation - ContainerAppAuthConfigData data = new ContainerAppAuthConfigData() + ContainerAppAuthConfigData data = new ContainerAppAuthConfigData { - Platform = new ContainerAppAuthPlatform() + Platform = new ContainerAppAuthPlatform { IsEnabled = true, }, - GlobalValidation = new ContainerAppGlobalValidation() + GlobalValidation = new ContainerAppGlobalValidation { UnauthenticatedClientAction = ContainerAppUnauthenticatedClientActionV2.AllowAnonymous, }, - IdentityProviders = new ContainerAppIdentityProvidersConfiguration() + IdentityProviders = new ContainerAppIdentityProvidersConfiguration { - Facebook = new ContainerAppFacebookConfiguration() + Facebook = new ContainerAppFacebookConfiguration { - Registration = new ContainerAppRegistration() + Registration = new ContainerAppRegistration { AppId = "123", AppSecretSettingName = "facebook-secret", }, }, }, - EncryptionSettings = new EncryptionSettings() + EncryptionSettings = new EncryptionSettings { ContainerAppAuthEncryptionSecretName = "testEncryptionSecretName", ContainerAppAuthSigningSecretName = "testSigningSecretName", @@ -105,32 +132,5 @@ public async Task Update_CreateOrUpdateContainerAppAuthConfig() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteContainerAppAuthConfig() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/AuthConfigs_Delete.json - // this example is just showing the usage of "ContainerAppsAuthConfigs_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerAppAuthConfigResource created on azure - // for more information of creating ContainerAppAuthConfigResource, please refer to the document of ContainerAppAuthConfigResource - string subscriptionId = "651f8027-33e8-4ec4-97b4-f6e9f3dc8744"; - string resourceGroupName = "workerapps-rg-xj"; - string containerAppName = "testcanadacentral"; - string authConfigName = "current"; - ResourceIdentifier containerAppAuthConfigResourceId = ContainerAppAuthConfigResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, containerAppName, authConfigName); - ContainerAppAuthConfigResource containerAppAuthConfig = client.GetContainerAppAuthConfigResource(containerAppAuthConfigResourceId); - - // invoke the operation - await containerAppAuthConfig.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppCollection.cs index 258942e200fae..1dd1f248df46f 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppCollection.cs @@ -17,144 +17,6 @@ namespace Azure.ResourceManager.AppContainers.Samples { public partial class Sample_ContainerAppCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListContainerAppsByResourceGroup() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerApps_ListByResourceGroup.json - // this example is just showing the usage of "ContainerApps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "rg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ContainerAppResource - ContainerAppCollection collection = resourceGroupResource.GetContainerApps(); - - // invoke the operation and iterate over the result - await foreach (ContainerAppResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetContainerApp() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerApps_Get.json - // this example is just showing the usage of "ContainerApps_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "rg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ContainerAppResource - ContainerAppCollection collection = resourceGroupResource.GetContainerApps(); - - // invoke the operation - string containerAppName = "testcontainerapp0"; - ContainerAppResource result = await collection.GetAsync(containerAppName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetContainerApp() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerApps_Get.json - // this example is just showing the usage of "ContainerApps_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "rg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ContainerAppResource - ContainerAppCollection collection = resourceGroupResource.GetContainerApps(); - - // invoke the operation - string containerAppName = "testcontainerapp0"; - bool result = await collection.ExistsAsync(containerAppName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetContainerApp() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerApps_Get.json - // this example is just showing the usage of "ContainerApps_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "rg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ContainerAppResource - ContainerAppCollection collection = resourceGroupResource.GetContainerApps(); - - // invoke the operation - string containerAppName = "testcontainerapp0"; - NullableResponse response = await collection.GetIfExistsAsync(containerAppName); - ContainerAppResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateContainerApp() @@ -183,74 +45,50 @@ public async Task CreateOrUpdate_CreateOrUpdateContainerApp() { EnvironmentId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube"), WorkloadProfileName = "My-GP-01", - Configuration = new ContainerAppConfiguration() + Configuration = new ContainerAppConfiguration { - Ingress = new ContainerAppIngressConfiguration() + Ingress = new ContainerAppIngressConfiguration { External = true, TargetPort = 3000, - Traffic = -{ -new ContainerAppRevisionTrafficWeight() + Traffic = {new ContainerAppRevisionTrafficWeight { RevisionName = "testcontainerapp0-ab1234", Weight = 100, Label = "production", -} -}, - CustomDomains = -{ -new ContainerAppCustomDomain("www.my-name.com") +}}, + CustomDomains = {new ContainerAppCustomDomain("www.my-name.com") { BindingType = ContainerAppCustomDomainBindingType.SniEnabled, CertificateId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube/certificates/my-certificate-for-my-name-dot-com"), -},new ContainerAppCustomDomain("www.my-other-name.com") +}, new ContainerAppCustomDomain("www.my-other-name.com") { BindingType = ContainerAppCustomDomainBindingType.SniEnabled, CertificateId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube/certificates/my-certificate-for-my-other-name-dot-com"), -} -}, - IPSecurityRestrictions = -{ -new ContainerAppIPSecurityRestrictionRule("Allow work IP A subnet","192.168.1.1/32",ContainerAppIPRuleAction.Allow) +}}, + IPSecurityRestrictions = {new ContainerAppIPSecurityRestrictionRule("Allow work IP A subnet", "192.168.1.1/32", ContainerAppIPRuleAction.Allow) { Description = "Allowing all IP's within the subnet below to access containerapp", -},new ContainerAppIPSecurityRestrictionRule("Allow work IP B subnet","192.168.1.1/8",ContainerAppIPRuleAction.Allow) +}, new ContainerAppIPSecurityRestrictionRule("Allow work IP B subnet", "192.168.1.1/8", ContainerAppIPRuleAction.Allow) { Description = "Allowing all IP's within the subnet below to access containerapp", -} -}, +}}, StickySessionsAffinity = Affinity.Sticky, ClientCertificateMode = ContainerAppIngressClientCertificateMode.Accept, - CorsPolicy = new ContainerAppCorsPolicy(new string[] - { -"https://a.test.com","https://b.test.com" - }) + CorsPolicy = new ContainerAppCorsPolicy(new string[] { "https://a.test.com", "https://b.test.com" }) { - AllowedMethods = -{ -"GET","POST" -}, - AllowedHeaders = -{ -"HEADER1","HEADER2" -}, - ExposeHeaders = -{ -"HEADER3","HEADER4" -}, + AllowedMethods = { "GET", "POST" }, + AllowedHeaders = { "HEADER1", "HEADER2" }, + ExposeHeaders = { "HEADER3", "HEADER4" }, MaxAge = 1234, AllowCredentials = true, }, - AdditionalPortMappings = -{ -new IngressPortMapping(true,1234),new IngressPortMapping(false,2345) + AdditionalPortMappings = {new IngressPortMapping(true, 1234), new IngressPortMapping(false, 2345) { ExposedPort = 3456, -} -}, +}}, }, - Dapr = new ContainerAppDaprConfiguration() + Dapr = new ContainerAppDaprConfiguration { IsEnabled = true, AppProtocol = ContainerAppProtocol.Http, @@ -263,82 +101,58 @@ public async Task CreateOrUpdate_CreateOrUpdateContainerApp() MaxInactiveRevisions = 10, ServiceType = "redis", }, - Template = new ContainerAppTemplate() + Template = new ContainerAppTemplate { - InitContainers = -{ -new ContainerAppInitContainer() + InitContainers = {new ContainerAppInitContainer { Image = "repo/testcontainerapp0:v4", Name = "testinitcontainerApp0", -Command = -{ -"/bin/sh" -}, -Args = -{ -"-c","while true; do echo hello; sleep 10;done" -}, -Resources = new AppContainerResources() +Command = {"/bin/sh"}, +Args = {"-c", "while true; do echo hello; sleep 10;done"}, +Resources = new AppContainerResources { Cpu = 0.5, Memory = "1Gi", }, -} -}, - Containers = -{ -new ContainerAppContainer() +}}, + Containers = {new ContainerAppContainer { -Probes = -{ -new ContainerAppProbe() +Probes = {new ContainerAppProbe { HttpGet = new ContainerAppHttpRequestInfo(8080) { -HttpHeaders = -{ -new ContainerAppHttpHeaderInfo("Custom-Header","Awesome") -}, +HttpHeaders = {new ContainerAppHttpHeaderInfo("Custom-Header", "Awesome")}, Path = "/health", }, InitialDelaySeconds = 3, PeriodSeconds = 3, ProbeType = ContainerAppProbeType.Liveness, -} -}, +}}, Image = "repo/testcontainerapp0:v1", Name = "testcontainerapp0", -} -}, - Scale = new ContainerAppScale() +}}, + Scale = new ContainerAppScale { MinReplicas = 1, MaxReplicas = 5, - Rules = -{ -new ContainerAppScaleRule() + Rules = {new ContainerAppScaleRule { Name = "httpscalingrule", -Custom = new ContainerAppCustomScaleRule() +Custom = new ContainerAppCustomScaleRule { CustomScaleRuleType = "http", Metadata = { -["concurrentRequests"] = "50", +["concurrentRequests"] = "50" }, }, -} -}, +}}, }, - ServiceBinds = -{ -new ContainerAppServiceBind() + ServiceBinds = {new ContainerAppServiceBind { ServiceId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/containerApps/redisService"), Name = "redisService", -} -}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerAppName, data); @@ -379,62 +193,50 @@ public async Task CreateOrUpdate_CreateOrUpdateManagedByApp() { ManagedBy = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.AppPlatform/Spring/springapp", EnvironmentId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube"), - Configuration = new ContainerAppConfiguration() + Configuration = new ContainerAppConfiguration { - Ingress = new ContainerAppIngressConfiguration() + Ingress = new ContainerAppIngressConfiguration { External = true, TargetPort = 3000, ExposedPort = 4000, Transport = ContainerAppIngressTransportMethod.Tcp, - Traffic = -{ -new ContainerAppRevisionTrafficWeight() + Traffic = {new ContainerAppRevisionTrafficWeight { RevisionName = "testcontainerappmanagedby-ab1234", Weight = 100, -} -}, +}}, }, }, - Template = new ContainerAppTemplate() + Template = new ContainerAppTemplate { - Containers = + Containers = {new ContainerAppContainer { -new ContainerAppContainer() -{ -Probes = -{ -new ContainerAppProbe() +Probes = {new ContainerAppProbe { InitialDelaySeconds = 3, PeriodSeconds = 3, TcpSocket = new ContainerAppTcpSocketRequestInfo(8080), ProbeType = ContainerAppProbeType.Liveness, -} -}, +}}, Image = "repo/testcontainerappmanagedby:v1", Name = "testcontainerappmanagedby", -} -}, - Scale = new ContainerAppScale() +}}, + Scale = new ContainerAppScale { MinReplicas = 1, MaxReplicas = 5, - Rules = -{ -new ContainerAppScaleRule() + Rules = {new ContainerAppScaleRule { Name = "tcpscalingrule", -Tcp = new ContainerAppTcpScaleRule() +Tcp = new ContainerAppTcpScaleRule { Metadata = { -["concurrentConnections"] = "50", -}, +["concurrentConnections"] = "50" }, -} }, +}}, }, }, }; @@ -475,62 +277,50 @@ public async Task CreateOrUpdate_CreateOrUpdateTcpApp() ContainerAppData data = new ContainerAppData(new AzureLocation("East US")) { EnvironmentId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube"), - Configuration = new ContainerAppConfiguration() + Configuration = new ContainerAppConfiguration { - Ingress = new ContainerAppIngressConfiguration() + Ingress = new ContainerAppIngressConfiguration { External = true, TargetPort = 3000, ExposedPort = 4000, Transport = ContainerAppIngressTransportMethod.Tcp, - Traffic = -{ -new ContainerAppRevisionTrafficWeight() + Traffic = {new ContainerAppRevisionTrafficWeight { RevisionName = "testcontainerapptcp-ab1234", Weight = 100, -} -}, +}}, }, }, - Template = new ContainerAppTemplate() + Template = new ContainerAppTemplate { - Containers = -{ -new ContainerAppContainer() -{ -Probes = + Containers = {new ContainerAppContainer { -new ContainerAppProbe() +Probes = {new ContainerAppProbe { InitialDelaySeconds = 3, PeriodSeconds = 3, TcpSocket = new ContainerAppTcpSocketRequestInfo(8080), ProbeType = ContainerAppProbeType.Liveness, -} -}, +}}, Image = "repo/testcontainerapptcp:v1", Name = "testcontainerapptcp", -} -}, - Scale = new ContainerAppScale() +}}, + Scale = new ContainerAppScale { MinReplicas = 1, MaxReplicas = 5, - Rules = -{ -new ContainerAppScaleRule() + Rules = {new ContainerAppScaleRule { Name = "tcpscalingrule", -Tcp = new ContainerAppTcpScaleRule() +Tcp = new ContainerAppTcpScaleRule { Metadata = { -["concurrentConnections"] = "50", +["concurrentConnections"] = "50" }, }, -} -}, +}}, }, }, }; @@ -543,5 +333,143 @@ public async Task CreateOrUpdate_CreateOrUpdateTcpApp() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetContainerApp() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerApps_Get.json + // this example is just showing the usage of "ContainerApps_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "rg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerAppResource + ContainerAppCollection collection = resourceGroupResource.GetContainerApps(); + + // invoke the operation + string containerAppName = "testcontainerapp0"; + ContainerAppResource result = await collection.GetAsync(containerAppName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListContainerAppsByResourceGroup() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerApps_ListByResourceGroup.json + // this example is just showing the usage of "ContainerApps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "rg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerAppResource + ContainerAppCollection collection = resourceGroupResource.GetContainerApps(); + + // invoke the operation and iterate over the result + await foreach (ContainerAppResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetContainerApp() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerApps_Get.json + // this example is just showing the usage of "ContainerApps_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "rg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerAppResource + ContainerAppCollection collection = resourceGroupResource.GetContainerApps(); + + // invoke the operation + string containerAppName = "testcontainerapp0"; + bool result = await collection.ExistsAsync(containerAppName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetContainerApp() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerApps_Get.json + // this example is just showing the usage of "ContainerApps_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "rg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerAppResource + ContainerAppCollection collection = resourceGroupResource.GetContainerApps(); + + // invoke the operation + string containerAppName = "testcontainerapp0"; + NullableResponse response = await collection.GetIfExistsAsync(containerAppName); + ContainerAppResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCertificateCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCertificateCollection.cs index 1cf02fc30d489..3251690175621 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCertificateCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCertificateCollection.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Text; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -18,10 +19,10 @@ public partial class Sample_ContainerAppConnectedEnvironmentCertificateCollectio { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCertificatesByConnectedEnvironment() + public async Task CreateOrUpdate_CreateOrUpdateCertificate() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsCertificates_ListByConnectedEnvironment.json - // this example is just showing the usage of "ConnectedEnvironmentsCertificates_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsCertificate_CreateOrUpdate.json + // this example is just showing the usage of "ConnectedEnvironmentsCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +40,24 @@ public async Task GetAll_ListCertificatesByConnectedEnvironment() // get the collection of this ContainerAppConnectedEnvironmentCertificateResource ContainerAppConnectedEnvironmentCertificateCollection collection = containerAppConnectedEnvironment.GetContainerAppConnectedEnvironmentCertificates(); - // invoke the operation and iterate over the result - await foreach (ContainerAppConnectedEnvironmentCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string certificateName = "certificate-firendly-name"; + ContainerAppCertificateData data = new ContainerAppCertificateData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new ContainerAppCertificateProperties + { + Password = "private key password", + Value = Encoding.UTF8.GetBytes("Y2VydA=="), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); + ContainerAppConnectedEnvironmentCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCertificate() + public async Task GetAll_ListCertificatesByConnectedEnvironment() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsCertificate_Get.json - // this example is just showing the usage of "ConnectedEnvironmentsCertificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsCertificates_ListByConnectedEnvironment.json + // this example is just showing the usage of "ConnectedEnvironmentsCertificates_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetCertificate() // get the collection of this ContainerAppConnectedEnvironmentCertificateResource ContainerAppConnectedEnvironmentCertificateCollection collection = containerAppConnectedEnvironment.GetContainerAppConnectedEnvironmentCertificates(); - // invoke the operation - string certificateName = "certificate-firendly-name"; - bool result = await collection.ExistsAsync(certificateName); + // invoke the operation and iterate over the result + await foreach (ContainerAppConnectedEnvironmentCertificateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCertificate() + public async Task Exists_GetCertificate() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsCertificate_Get.json // this example is just showing the usage of "ConnectedEnvironmentsCertificates_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetCertificate() // invoke the operation string certificateName = "certificate-firendly-name"; - NullableResponse response = await collection.GetIfExistsAsync(certificateName); - ContainerAppConnectedEnvironmentCertificateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(certificateName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateCertificate() + public async Task GetIfExists_GetCertificate() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsCertificate_CreateOrUpdate.json - // this example is just showing the usage of "ConnectedEnvironmentsCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsCertificate_Get.json + // this example is just showing the usage of "ConnectedEnvironmentsCertificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateCertificate() // invoke the operation string certificateName = "certificate-firendly-name"; - ContainerAppCertificateData data = new ContainerAppCertificateData(new AzureLocation("East US")) - { - Properties = new ContainerAppCertificateProperties() - { - Password = "private key password", - Value = Convert.FromBase64String("Y2VydA=="), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); - ContainerAppConnectedEnvironmentCertificateResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(certificateName); + ContainerAppConnectedEnvironmentCertificateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCertificateResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCertificateResource.cs index 0154527058d13..00e1382ec3adb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCertificateResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCertificateResource.cs @@ -96,12 +96,12 @@ public async Task Update_PatchCertificate() ContainerAppConnectedEnvironmentCertificateResource containerAppConnectedEnvironmentCertificate = client.GetContainerAppConnectedEnvironmentCertificateResource(containerAppConnectedEnvironmentCertificateResourceId); // invoke the operation - ContainerAppCertificatePatch patch = new ContainerAppCertificatePatch() + ContainerAppCertificatePatch patch = new ContainerAppCertificatePatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ContainerAppConnectedEnvironmentCertificateResource result = await containerAppConnectedEnvironmentCertificate.UpdateAsync(patch); diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCollection.cs index 25793ef743b82..b4ebd7aeecb3c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentCollection.cs @@ -7,6 +7,7 @@ using System; using System.Net; +using System.Text; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -20,10 +21,10 @@ public partial class Sample_ContainerAppConnectedEnvironmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEnvironmentsByResourceGroup() + public async Task CreateOrUpdate_CreateKubeEnvironments() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironments_ListByResourceGroup.json - // this example is just showing the usage of "ConnectedEnvironments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironments_CreateOrUpdate.json + // this example is just showing the usage of "ConnectedEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +33,7 @@ public async Task GetAll_ListEnvironmentsByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "examplerg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -40,17 +41,27 @@ public async Task GetAll_ListEnvironmentsByResourceGroup() // get the collection of this ContainerAppConnectedEnvironmentResource ContainerAppConnectedEnvironmentCollection collection = resourceGroupResource.GetContainerAppConnectedEnvironments(); - // invoke the operation and iterate over the result - await foreach (ContainerAppConnectedEnvironmentResource item in collection.GetAllAsync()) + // invoke the operation + string connectedEnvironmentName = "testenv"; + ContainerAppConnectedEnvironmentData data = new ContainerAppConnectedEnvironmentData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppConnectedEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StaticIP = IPAddress.Parse("1.2.3.4"), + DaprAIConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://northcentralus-0.in.applicationinsights.azure.com/", + CustomDomainConfiguration = new ContainerAppCustomDomainConfiguration + { + DnsSuffix = "www.my-name.com", + CertificateValue = Encoding.UTF8.GetBytes("Y2VydA=="), + CertificatePassword = "private key password", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectedEnvironmentName, data); + ContainerAppConnectedEnvironmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppConnectedEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +99,10 @@ public async Task Get_GetConnectedEnvironmentByConnectedEnvironmentName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetConnectedEnvironmentByConnectedEnvironmentName() + public async Task GetAll_ListEnvironmentsByResourceGroup() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironments_Get.json - // this example is just showing the usage of "ConnectedEnvironments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironments_ListByResourceGroup.json + // this example is just showing the usage of "ConnectedEnvironments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +111,7 @@ public async Task Exists_GetConnectedEnvironmentByConnectedEnvironmentName() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; string resourceGroupName = "examplerg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -108,16 +119,22 @@ public async Task Exists_GetConnectedEnvironmentByConnectedEnvironmentName() // get the collection of this ContainerAppConnectedEnvironmentResource ContainerAppConnectedEnvironmentCollection collection = resourceGroupResource.GetContainerAppConnectedEnvironments(); - // invoke the operation - string connectedEnvironmentName = "examplekenv"; - bool result = await collection.ExistsAsync(connectedEnvironmentName); + // invoke the operation and iterate over the result + await foreach (ContainerAppConnectedEnvironmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppConnectedEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetConnectedEnvironmentByConnectedEnvironmentName() + public async Task Exists_GetConnectedEnvironmentByConnectedEnvironmentName() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironments_Get.json // this example is just showing the usage of "ConnectedEnvironments_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +156,17 @@ public async Task GetIfExists_GetConnectedEnvironmentByConnectedEnvironmentName( // invoke the operation string connectedEnvironmentName = "examplekenv"; - NullableResponse response = await collection.GetIfExistsAsync(connectedEnvironmentName); - ContainerAppConnectedEnvironmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(connectedEnvironmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppConnectedEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateKubeEnvironments() + public async Task GetIfExists_GetConnectedEnvironmentByConnectedEnvironmentName() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironments_CreateOrUpdate.json - // this example is just showing the usage of "ConnectedEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironments_Get.json + // this example is just showing the usage of "ConnectedEnvironments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,26 +184,22 @@ public async Task CreateOrUpdate_CreateKubeEnvironments() ContainerAppConnectedEnvironmentCollection collection = resourceGroupResource.GetContainerAppConnectedEnvironments(); // invoke the operation - string connectedEnvironmentName = "testenv"; - ContainerAppConnectedEnvironmentData data = new ContainerAppConnectedEnvironmentData(new AzureLocation("East US")) - { - StaticIP = IPAddress.Parse("1.2.3.4"), - DaprAIConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://northcentralus-0.in.applicationinsights.azure.com/", - CustomDomainConfiguration = new ContainerAppCustomDomainConfiguration() - { - DnsSuffix = "www.my-name.com", - CertificateValue = Convert.FromBase64String("Y2VydA=="), - CertificatePassword = "private key password", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectedEnvironmentName, data); - ContainerAppConnectedEnvironmentResource result = lro.Value; + string connectedEnvironmentName = "examplekenv"; + NullableResponse response = await collection.GetIfExistsAsync(connectedEnvironmentName); + ContainerAppConnectedEnvironmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppConnectedEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppConnectedEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentDaprComponentCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentDaprComponentCollection.cs index 6561d40b85ed1..ad1ad096927ac 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentDaprComponentCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentDaprComponentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerAppConnectedEnvironmentDaprComponentCollect { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDaprComponents() + public async Task CreateOrUpdate_CreateOrUpdateDaprComponent() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsDaprComponents_List.json - // this example is just showing the usage of "ConnectedEnvironmentsDaprComponents_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsDaprComponents_CreateOrUpdate.json + // this example is just showing the usage of "ConnectedEnvironmentsDaprComponents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,46 @@ public async Task GetAll_ListDaprComponents() // get the collection of this ContainerAppConnectedEnvironmentDaprComponentResource ContainerAppConnectedEnvironmentDaprComponentCollection collection = containerAppConnectedEnvironment.GetContainerAppConnectedEnvironmentDaprComponents(); - // invoke the operation and iterate over the result - await foreach (ContainerAppConnectedEnvironmentDaprComponentResource item in collection.GetAllAsync()) + // invoke the operation + string componentName = "reddog"; + ContainerAppDaprComponentData data = new ContainerAppDaprComponentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDaprComponentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ComponentType = "state.azure.cosmosdb", + Version = "v1", + IgnoreErrors = false, + InitTimeout = "50s", + Secrets = {new ContainerAppWritableSecret +{ +Name = "masterkey", +Value = "keyvalue", +}}, + Metadata = {new ContainerAppDaprMetadata +{ +Name = "url", +Value = "", +}, new ContainerAppDaprMetadata +{ +Name = "database", +Value = "itemsDB", +}, new ContainerAppDaprMetadata +{ +Name = "collection", +Value = "items", +}, new ContainerAppDaprMetadata +{ +Name = "masterkey", +SecretRef = "masterkey", +}}, + Scopes = { "container-app-1", "container-app-2" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, componentName, data); + ContainerAppConnectedEnvironmentDaprComponentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDaprComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +117,10 @@ public async Task Get_GetDaprComponent() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDaprComponent() + public async Task GetAll_ListDaprComponents() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsDaprComponents_Get.json - // this example is just showing the usage of "ConnectedEnvironmentsDaprComponents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsDaprComponents_List.json + // this example is just showing the usage of "ConnectedEnvironmentsDaprComponents_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +138,22 @@ public async Task Exists_GetDaprComponent() // get the collection of this ContainerAppConnectedEnvironmentDaprComponentResource ContainerAppConnectedEnvironmentDaprComponentCollection collection = containerAppConnectedEnvironment.GetContainerAppConnectedEnvironmentDaprComponents(); - // invoke the operation - string componentName = "reddog"; - bool result = await collection.ExistsAsync(componentName); + // invoke the operation and iterate over the result + await foreach (ContainerAppConnectedEnvironmentDaprComponentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDaprComponentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDaprComponent() + public async Task Exists_GetDaprComponent() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsDaprComponents_Get.json // this example is just showing the usage of "ConnectedEnvironmentsDaprComponents_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +176,17 @@ public async Task GetIfExists_GetDaprComponent() // invoke the operation string componentName = "reddog"; - NullableResponse response = await collection.GetIfExistsAsync(componentName); - ContainerAppConnectedEnvironmentDaprComponentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(componentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDaprComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDaprComponent() + public async Task GetIfExists_GetDaprComponent() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsDaprComponents_CreateOrUpdate.json - // this example is just showing the usage of "ConnectedEnvironmentsDaprComponents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsDaprComponents_Get.json + // this example is just showing the usage of "ConnectedEnvironmentsDaprComponents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,53 +206,21 @@ public async Task CreateOrUpdate_CreateOrUpdateDaprComponent() // invoke the operation string componentName = "reddog"; - ContainerAppDaprComponentData data = new ContainerAppDaprComponentData() - { - ComponentType = "state.azure.cosmosdb", - Version = "v1", - IgnoreErrors = false, - InitTimeout = "50s", - Secrets = -{ -new ContainerAppWritableSecret() -{ -Name = "masterkey", -Value = "keyvalue", -} -}, - Metadata = -{ -new ContainerAppDaprMetadata() -{ -Name = "url", -Value = "", -},new ContainerAppDaprMetadata() -{ -Name = "database", -Value = "itemsDB", -},new ContainerAppDaprMetadata() -{ -Name = "collection", -Value = "items", -},new ContainerAppDaprMetadata() -{ -Name = "masterkey", -SecretRef = "masterkey", -} -}, - Scopes = -{ -"container-app-1","container-app-2" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, componentName, data); - ContainerAppConnectedEnvironmentDaprComponentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(componentName); + ContainerAppConnectedEnvironmentDaprComponentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDaprComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDaprComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentDaprComponentResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentDaprComponentResource.cs index 571df75578415..bf4cea078eafb 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentDaprComponentResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentDaprComponentResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetDaprComponent() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteDaprComponent() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsDaprComponents_Delete.json + // this example is just showing the usage of "ConnectedEnvironmentsDaprComponents_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerAppConnectedEnvironmentDaprComponentResource created on azure + // for more information of creating ContainerAppConnectedEnvironmentDaprComponentResource, please refer to the document of ContainerAppConnectedEnvironmentDaprComponentResource + string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; + string resourceGroupName = "examplerg"; + string connectedEnvironmentName = "myenvironment"; + string componentName = "reddog"; + ResourceIdentifier containerAppConnectedEnvironmentDaprComponentResourceId = ContainerAppConnectedEnvironmentDaprComponentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, connectedEnvironmentName, componentName); + ContainerAppConnectedEnvironmentDaprComponentResource containerAppConnectedEnvironmentDaprComponent = client.GetContainerAppConnectedEnvironmentDaprComponentResource(containerAppConnectedEnvironmentDaprComponentResourceId); + + // invoke the operation + await containerAppConnectedEnvironmentDaprComponent.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateDaprComponent() @@ -69,44 +96,35 @@ public async Task Update_CreateOrUpdateDaprComponent() ContainerAppConnectedEnvironmentDaprComponentResource containerAppConnectedEnvironmentDaprComponent = client.GetContainerAppConnectedEnvironmentDaprComponentResource(containerAppConnectedEnvironmentDaprComponentResourceId); // invoke the operation - ContainerAppDaprComponentData data = new ContainerAppDaprComponentData() + ContainerAppDaprComponentData data = new ContainerAppDaprComponentData { ComponentType = "state.azure.cosmosdb", Version = "v1", IgnoreErrors = false, InitTimeout = "50s", - Secrets = -{ -new ContainerAppWritableSecret() + Secrets = {new ContainerAppWritableSecret { Name = "masterkey", Value = "keyvalue", -} -}, - Metadata = -{ -new ContainerAppDaprMetadata() +}}, + Metadata = {new ContainerAppDaprMetadata { Name = "url", Value = "", -},new ContainerAppDaprMetadata() +}, new ContainerAppDaprMetadata { Name = "database", Value = "itemsDB", -},new ContainerAppDaprMetadata() +}, new ContainerAppDaprMetadata { Name = "collection", Value = "items", -},new ContainerAppDaprMetadata() +}, new ContainerAppDaprMetadata { Name = "masterkey", SecretRef = "masterkey", -} -}, - Scopes = -{ -"container-app-1","container-app-2" -}, +}}, + Scopes = { "container-app-1", "container-app-2" }, }; ArmOperation lro = await containerAppConnectedEnvironmentDaprComponent.UpdateAsync(WaitUntil.Completed, data); ContainerAppConnectedEnvironmentDaprComponentResource result = lro.Value; @@ -118,33 +136,6 @@ public async Task Update_CreateOrUpdateDaprComponent() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDaprComponent() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsDaprComponents_Delete.json - // this example is just showing the usage of "ConnectedEnvironmentsDaprComponents_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerAppConnectedEnvironmentDaprComponentResource created on azure - // for more information of creating ContainerAppConnectedEnvironmentDaprComponentResource, please refer to the document of ContainerAppConnectedEnvironmentDaprComponentResource - string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; - string resourceGroupName = "examplerg"; - string connectedEnvironmentName = "myenvironment"; - string componentName = "reddog"; - ResourceIdentifier containerAppConnectedEnvironmentDaprComponentResourceId = ContainerAppConnectedEnvironmentDaprComponentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, connectedEnvironmentName, componentName); - ContainerAppConnectedEnvironmentDaprComponentResource containerAppConnectedEnvironmentDaprComponent = client.GetContainerAppConnectedEnvironmentDaprComponentResource(containerAppConnectedEnvironmentDaprComponentResourceId); - - // invoke the operation - await containerAppConnectedEnvironmentDaprComponent.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSecrets_ListContainerAppsSecrets() diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentResource.cs index 675585514d5d6..4e10bd2e91bea 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppContainers.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppContainers.Samples { public partial class Sample_ContainerAppConnectedEnvironmentResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetContainerAppConnectedEnvironments_ListConnectedEnvironmentsBySubscription() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironments_ListBySubscription.json - // this example is just showing the usage of "ConnectedEnvironments_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ContainerAppConnectedEnvironmentResource item in subscriptionResource.GetContainerAppConnectedEnvironmentsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppConnectedEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetConnectedEnvironmentByConnectedEnvironmentName() @@ -155,7 +123,7 @@ public async Task CheckNameAvailability_CertificatesCheckNameAvailability() ContainerAppConnectedEnvironmentResource containerAppConnectedEnvironment = client.GetContainerAppConnectedEnvironmentResource(containerAppConnectedEnvironmentResourceId); // invoke the operation - ContainerAppNameAvailabilityContent content = new ContainerAppNameAvailabilityContent() + ContainerAppNameAvailabilityContent content = new ContainerAppNameAvailabilityContent { Name = "testcertificatename", ResourceType = new ResourceType("Microsoft.App/connectedEnvironments/certificates"), diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentStorageCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentStorageCollection.cs index 447432ae621af..4511512729e52 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentStorageCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentStorageCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerAppConnectedEnvironmentStorageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEnvironmentsStoragesBySubscription() + public async Task CreateOrUpdate_CreateOrUpdateEnvironmentsStorage() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_List.json - // this example is just showing the usage of "ConnectedEnvironmentsStorages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_CreateOrUpdate.json + // this example is just showing the usage of "ConnectedEnvironmentsStorages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,33 @@ public async Task GetAll_ListEnvironmentsStoragesBySubscription() // for more information of creating ContainerAppConnectedEnvironmentResource, please refer to the document of ContainerAppConnectedEnvironmentResource string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; string resourceGroupName = "examplerg"; - string connectedEnvironmentName = "managedEnv"; + string connectedEnvironmentName = "env"; ResourceIdentifier containerAppConnectedEnvironmentResourceId = ContainerAppConnectedEnvironmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, connectedEnvironmentName); ContainerAppConnectedEnvironmentResource containerAppConnectedEnvironment = client.GetContainerAppConnectedEnvironmentResource(containerAppConnectedEnvironmentResourceId); // get the collection of this ContainerAppConnectedEnvironmentStorageResource ContainerAppConnectedEnvironmentStorageCollection collection = containerAppConnectedEnvironment.GetContainerAppConnectedEnvironmentStorages(); - // invoke the operation and iterate over the result - await foreach (ContainerAppConnectedEnvironmentStorageResource item in collection.GetAllAsync()) + // invoke the operation + string storageName = "jlaw-demo1"; + ContainerAppConnectedEnvironmentStorageData data = new ContainerAppConnectedEnvironmentStorageData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppConnectedEnvironmentStorageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectedEnvironmentStorageAzureFile = new ContainerAppAzureFileProperties + { + AccountName = "account1", + AccountKey = "key", + AccessMode = ContainerAppAccessMode.ReadOnly, + ShareName = "share1", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageName, data); + ContainerAppConnectedEnvironmentStorageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppConnectedEnvironmentStorageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +97,10 @@ public async Task Get_GetAEnvironmentsStoragePropertiesBySubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAEnvironmentsStoragePropertiesBySubscription() + public async Task GetAll_ListEnvironmentsStoragesBySubscription() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_Get.json - // this example is just showing the usage of "ConnectedEnvironmentsStorages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_List.json + // this example is just showing the usage of "ConnectedEnvironmentsStorages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,23 +111,29 @@ public async Task Exists_GetAEnvironmentsStoragePropertiesBySubscription() // for more information of creating ContainerAppConnectedEnvironmentResource, please refer to the document of ContainerAppConnectedEnvironmentResource string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; string resourceGroupName = "examplerg"; - string connectedEnvironmentName = "env"; + string connectedEnvironmentName = "managedEnv"; ResourceIdentifier containerAppConnectedEnvironmentResourceId = ContainerAppConnectedEnvironmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, connectedEnvironmentName); ContainerAppConnectedEnvironmentResource containerAppConnectedEnvironment = client.GetContainerAppConnectedEnvironmentResource(containerAppConnectedEnvironmentResourceId); // get the collection of this ContainerAppConnectedEnvironmentStorageResource ContainerAppConnectedEnvironmentStorageCollection collection = containerAppConnectedEnvironment.GetContainerAppConnectedEnvironmentStorages(); - // invoke the operation - string storageName = "jlaw-demo1"; - bool result = await collection.ExistsAsync(storageName); + // invoke the operation and iterate over the result + await foreach (ContainerAppConnectedEnvironmentStorageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppConnectedEnvironmentStorageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAEnvironmentsStoragePropertiesBySubscription() + public async Task Exists_GetAEnvironmentsStoragePropertiesBySubscription() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_Get.json // this example is just showing the usage of "ConnectedEnvironmentsStorages_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +156,17 @@ public async Task GetIfExists_GetAEnvironmentsStoragePropertiesBySubscription() // invoke the operation string storageName = "jlaw-demo1"; - NullableResponse response = await collection.GetIfExistsAsync(storageName); - ContainerAppConnectedEnvironmentStorageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(storageName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppConnectedEnvironmentStorageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateEnvironmentsStorage() + public async Task GetIfExists_GetAEnvironmentsStoragePropertiesBySubscription() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_CreateOrUpdate.json - // this example is just showing the usage of "ConnectedEnvironmentsStorages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_Get.json + // this example is just showing the usage of "ConnectedEnvironmentsStorages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,24 +186,21 @@ public async Task CreateOrUpdate_CreateOrUpdateEnvironmentsStorage() // invoke the operation string storageName = "jlaw-demo1"; - ContainerAppConnectedEnvironmentStorageData data = new ContainerAppConnectedEnvironmentStorageData() - { - ConnectedEnvironmentStorageAzureFile = new ContainerAppAzureFileProperties() - { - AccountName = "account1", - AccountKey = "key", - AccessMode = ContainerAppAccessMode.ReadOnly, - ShareName = "share1", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageName, data); - ContainerAppConnectedEnvironmentStorageResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(storageName); + ContainerAppConnectedEnvironmentStorageResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppConnectedEnvironmentStorageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppConnectedEnvironmentStorageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentStorageResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentStorageResource.cs index a963250f6932c..9243c4e301fb8 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentStorageResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppConnectedEnvironmentStorageResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAEnvironmentsStoragePropertiesBySubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateEnvironmentsStorage() + public async Task Delete_ListEnvironmentsStoragesBySubscription() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_CreateOrUpdate.json - // this example is just showing the usage of "ConnectedEnvironmentsStorages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_Delete.json + // this example is just showing the usage of "ConnectedEnvironmentsStorages_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,32 +69,17 @@ public async Task Update_CreateOrUpdateEnvironmentsStorage() ContainerAppConnectedEnvironmentStorageResource containerAppConnectedEnvironmentStorage = client.GetContainerAppConnectedEnvironmentStorageResource(containerAppConnectedEnvironmentStorageResourceId); // invoke the operation - ContainerAppConnectedEnvironmentStorageData data = new ContainerAppConnectedEnvironmentStorageData() - { - ConnectedEnvironmentStorageAzureFile = new ContainerAppAzureFileProperties() - { - AccountName = "account1", - AccountKey = "key", - AccessMode = ContainerAppAccessMode.ReadOnly, - ShareName = "share1", - }, - }; - ArmOperation lro = await containerAppConnectedEnvironmentStorage.UpdateAsync(WaitUntil.Completed, data); - ContainerAppConnectedEnvironmentStorageResource result = lro.Value; + await containerAppConnectedEnvironmentStorage.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppConnectedEnvironmentStorageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ListEnvironmentsStoragesBySubscription() + public async Task Update_CreateOrUpdateEnvironmentsStorage() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_Delete.json - // this example is just showing the usage of "ConnectedEnvironmentsStorages_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironmentsStorages_CreateOrUpdate.json + // this example is just showing the usage of "ConnectedEnvironmentsStorages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +96,24 @@ public async Task Delete_ListEnvironmentsStoragesBySubscription() ContainerAppConnectedEnvironmentStorageResource containerAppConnectedEnvironmentStorage = client.GetContainerAppConnectedEnvironmentStorageResource(containerAppConnectedEnvironmentStorageResourceId); // invoke the operation - await containerAppConnectedEnvironmentStorage.DeleteAsync(WaitUntil.Completed); + ContainerAppConnectedEnvironmentStorageData data = new ContainerAppConnectedEnvironmentStorageData + { + ConnectedEnvironmentStorageAzureFile = new ContainerAppAzureFileProperties + { + AccountName = "account1", + AccountKey = "key", + AccessMode = ContainerAppAccessMode.ReadOnly, + ShareName = "share1", + }, + }; + ArmOperation lro = await containerAppConnectedEnvironmentStorage.UpdateAsync(WaitUntil.Completed, data); + ContainerAppConnectedEnvironmentStorageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppConnectedEnvironmentStorageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppDetectorCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppDetectorCollection.cs index ebf68b5e515aa..49266e007b542 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppDetectorCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppDetectorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerAppDetectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheListOfAvailableDiagnosticsForAGivenContainerApp() + public async Task Get_GetContainerAppSDiagnosticsInfo() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerAppsDiagnostics_List.json - // this example is just showing the usage of "ContainerAppsDiagnostics_ListDetectors" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerAppsDiagnostics_Get.json + // this example is just showing the usage of "ContainerAppsDiagnostics_GetDetector" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetTheListOfAvailableDiagnosticsForAGivenContainerApp() // get the collection of this ContainerAppDetectorResource ContainerAppDetectorCollection collection = containerApp.GetContainerAppDetectors(); - // invoke the operation and iterate over the result - await foreach (ContainerAppDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDiagnosticData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "cappcontainerappnetworkIO"; + ContainerAppDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDiagnosticData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetContainerAppSDiagnosticsInfo() + public async Task GetAll_GetTheListOfAvailableDiagnosticsForAGivenContainerApp() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerAppsDiagnostics_Get.json - // this example is just showing the usage of "ContainerAppsDiagnostics_GetDetector" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerAppsDiagnostics_List.json + // this example is just showing the usage of "ContainerAppsDiagnostics_ListDetectors" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetContainerAppSDiagnosticsInfo() // get the collection of this ContainerAppDetectorResource ContainerAppDetectorCollection collection = containerApp.GetContainerAppDetectors(); - // invoke the operation - string detectorName = "cappcontainerappnetworkIO"; - ContainerAppDetectorResource result = await collection.GetAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (ContainerAppDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDiagnosticData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDiagnosticData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppDetectorPropertyRevisionCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppDetectorPropertyRevisionCollection.cs index 02866f2675194..ae157778d8700 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppDetectorPropertyRevisionCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppDetectorPropertyRevisionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerAppDetectorPropertyRevisionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListContainerAppSRevisions() + public async Task Get_GetContainerAppSRevision() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Revisions_List.json - // this example is just showing the usage of "ContainerAppsDiagnostics_ListRevisions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Revisions_Get.json + // this example is just showing the usage of "ContainerAppsDiagnostics_GetRevision" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListContainerAppSRevisions() // get the collection of this ContainerAppDetectorPropertyRevisionResource ContainerAppDetectorPropertyRevisionCollection collection = containerApp.GetContainerAppDetectorPropertyRevisions(); - // invoke the operation and iterate over the result - await foreach (ContainerAppDetectorPropertyRevisionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppRevisionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string revisionName = "testcontainerApp0-pjxhsye"; + ContainerAppDetectorPropertyRevisionResource result = await collection.GetAsync(revisionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppRevisionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetContainerAppSRevision() + public async Task GetAll_ListContainerAppSRevisions() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Revisions_Get.json - // this example is just showing the usage of "ContainerAppsDiagnostics_GetRevision" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Revisions_List.json + // this example is just showing the usage of "ContainerAppsDiagnostics_ListRevisions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetContainerAppSRevision() // get the collection of this ContainerAppDetectorPropertyRevisionResource ContainerAppDetectorPropertyRevisionCollection collection = containerApp.GetContainerAppDetectorPropertyRevisions(); - // invoke the operation - string revisionName = "testcontainerApp0-pjxhsye"; - ContainerAppDetectorPropertyRevisionResource result = await collection.GetAsync(revisionName); + // invoke the operation and iterate over the result + await foreach (ContainerAppDetectorPropertyRevisionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppRevisionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppRevisionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobCollection.cs index 35d1c4f02bdff..6124b61068fde 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -20,10 +19,10 @@ public partial class Sample_ContainerAppJobCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListContainerAppsJobsByResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateContainerAppsJob() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Jobs_ListByResourceGroup.json - // this example is just showing the usage of "Jobs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_CreateorUpdate.json + // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +39,68 @@ public async Task GetAll_ListContainerAppsJobsByResourceGroup() // get the collection of this ContainerAppJobResource ContainerAppJobCollection collection = resourceGroupResource.GetContainerAppJobs(); - // invoke the operation and iterate over the result - await foreach (ContainerAppJobResource item in collection.GetAllAsync()) + // invoke the operation + string jobName = "testcontainerappsjob0"; + ContainerAppJobData data = new ContainerAppJobData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EnvironmentId = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube", + Configuration = new ContainerAppJobConfiguration(ContainerAppJobTriggerType.Manual, 10) + { + ReplicaRetryLimit = 10, + ManualTriggerConfig = new JobConfigurationManualTriggerConfig + { + ReplicaCompletionCount = 1, + Parallelism = 4, + }, + }, + Template = new ContainerAppJobTemplate + { + InitContainers = {new ContainerAppInitContainer +{ +Image = "repo/testcontainerappsjob0:v4", +Name = "testinitcontainerAppsJob0", +Command = {"/bin/sh"}, +Args = {"-c", "while true; do echo hello; sleep 10;done"}, +Resources = new AppContainerResources +{ +Cpu = 0.5, +Memory = "1Gi", +}, +}}, + Containers = {new ContainerAppContainer +{ +Probes = {new ContainerAppProbe +{ +HttpGet = new ContainerAppHttpRequestInfo(8080) +{ +HttpHeaders = {new ContainerAppHttpHeaderInfo("Custom-Header", "Awesome")}, +Path = "/health", +}, +InitialDelaySeconds = 5, +PeriodSeconds = 3, +ProbeType = ContainerAppProbeType.Liveness, +}}, +Image = "repo/testcontainerappsjob0:v1", +Name = "testcontainerappsjob0", +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); + ContainerAppJobResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetContainerAppsJob() + public async Task CreateOrUpdate_CreateOrUpdateContainerAppsJobWithEventDrivenTrigger() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Get.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_CreateorUpdate_EventTrigger.json + // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +119,56 @@ public async Task Get_GetContainerAppsJob() // invoke the operation string jobName = "testcontainerappsjob0"; - ContainerAppJobResource result = await collection.GetAsync(jobName); + ContainerAppJobData data = new ContainerAppJobData(new AzureLocation("East US")) + { + EnvironmentId = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube", + Configuration = new ContainerAppJobConfiguration(ContainerAppJobTriggerType.Event, 10) + { + ReplicaRetryLimit = 10, + EventTriggerConfig = new EventTriggerConfiguration + { + ReplicaCompletionCount = 1, + Parallelism = 4, + Scale = new ContainerAppJobScale + { + PollingIntervalInSeconds = 40, + MinExecutions = 1, + MaxExecutions = 5, + Rules = {new ContainerAppJobScaleRule +{ +Name = "servicebuscalingrule", +JobScaleRuleType = "azure-servicebus", +Metadata = BinaryData.FromObjectAsJson(new +{ +topicName = "my-topic", +}), +}}, + }, + }, + }, + Template = new ContainerAppJobTemplate + { + InitContainers = {new ContainerAppInitContainer +{ +Image = "repo/testcontainerappsjob0:v4", +Name = "testinitcontainerAppsJob0", +Command = {"/bin/sh"}, +Args = {"-c", "while true; do echo hello; sleep 10;done"}, +Resources = new AppContainerResources +{ +Cpu = 0.5, +Memory = "1Gi", +}, +}}, + Containers = {new ContainerAppContainer +{ +Image = "repo/testcontainerappsjob0:v1", +Name = "testcontainerappsjob0", +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); + ContainerAppJobResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +179,7 @@ public async Task Get_GetContainerAppsJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetContainerAppsJob() + public async Task Get_GetContainerAppsJob() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. @@ -110,17 +201,21 @@ public async Task Exists_GetContainerAppsJob() // invoke the operation string jobName = "testcontainerappsjob0"; - bool result = await collection.ExistsAsync(jobName); + ContainerAppJobResource result = await collection.GetAsync(jobName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetContainerAppsJob() + public async Task GetAll_ListContainerAppsJobsByResourceGroup() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Get.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Jobs_ListByResourceGroup.json + // this example is just showing the usage of "Jobs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,31 +232,25 @@ public async Task GetIfExists_GetContainerAppsJob() // get the collection of this ContainerAppJobResource ContainerAppJobCollection collection = resourceGroupResource.GetContainerAppJobs(); - // invoke the operation - string jobName = "testcontainerappsjob0"; - NullableResponse response = await collection.GetIfExistsAsync(jobName); - ContainerAppJobResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ContainerAppJobResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerAppJobData resourceData = result.Data; + ContainerAppJobData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateContainerAppsJob() + public async Task Exists_GetContainerAppsJob() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_CreateorUpdate.json - // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Get.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,84 +269,17 @@ public async Task CreateOrUpdate_CreateOrUpdateContainerAppsJob() // invoke the operation string jobName = "testcontainerappsjob0"; - ContainerAppJobData data = new ContainerAppJobData(new AzureLocation("East US")) - { - EnvironmentId = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube", - Configuration = new ContainerAppJobConfiguration(ContainerAppJobTriggerType.Manual, 10) - { - ReplicaRetryLimit = 10, - ManualTriggerConfig = new JobConfigurationManualTriggerConfig() - { - ReplicaCompletionCount = 1, - Parallelism = 4, - }, - }, - Template = new ContainerAppJobTemplate() - { - InitContainers = -{ -new ContainerAppInitContainer() -{ -Image = "repo/testcontainerappsjob0:v4", -Name = "testinitcontainerAppsJob0", -Command = -{ -"/bin/sh" -}, -Args = -{ -"-c","while true; do echo hello; sleep 10;done" -}, -Resources = new AppContainerResources() -{ -Cpu = 0.5, -Memory = "1Gi", -}, -} -}, - Containers = -{ -new ContainerAppContainer() -{ -Probes = -{ -new ContainerAppProbe() -{ -HttpGet = new ContainerAppHttpRequestInfo(8080) -{ -HttpHeaders = -{ -new ContainerAppHttpHeaderInfo("Custom-Header","Awesome") -}, -Path = "/health", -}, -InitialDelaySeconds = 5, -PeriodSeconds = 3, -ProbeType = ContainerAppProbeType.Liveness, -} -}, -Image = "repo/testcontainerappsjob0:v1", -Name = "testcontainerappsjob0", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); - ContainerAppJobResource result = lro.Value; + bool result = await collection.ExistsAsync(jobName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateContainerAppsJobWithEventDrivenTrigger() + public async Task GetIfExists_GetContainerAppsJob() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_CreateorUpdate_EventTrigger.json - // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Get.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -276,76 +298,21 @@ public async Task CreateOrUpdate_CreateOrUpdateContainerAppsJobWithEventDrivenTr // invoke the operation string jobName = "testcontainerappsjob0"; - ContainerAppJobData data = new ContainerAppJobData(new AzureLocation("East US")) - { - EnvironmentId = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube", - Configuration = new ContainerAppJobConfiguration(ContainerAppJobTriggerType.Event, 10) - { - ReplicaRetryLimit = 10, - EventTriggerConfig = new EventTriggerConfiguration() - { - ReplicaCompletionCount = 1, - Parallelism = 4, - Scale = new ContainerAppJobScale() - { - PollingIntervalInSeconds = 40, - MinExecutions = 1, - MaxExecutions = 5, - Rules = -{ -new ContainerAppJobScaleRule() -{ -Name = "servicebuscalingrule", -JobScaleRuleType = "azure-servicebus", -Metadata = BinaryData.FromObjectAsJson(new Dictionary() -{ -["topicName"] = "my-topic"}), -} -}, - }, - }, - }, - Template = new ContainerAppJobTemplate() - { - InitContainers = -{ -new ContainerAppInitContainer() -{ -Image = "repo/testcontainerappsjob0:v4", -Name = "testinitcontainerAppsJob0", -Command = -{ -"/bin/sh" -}, -Args = -{ -"-c","while true; do echo hello; sleep 10;done" -}, -Resources = new AppContainerResources() -{ -Cpu = 0.5, -Memory = "1Gi", -}, -} -}, - Containers = -{ -new ContainerAppContainer() -{ -Image = "repo/testcontainerappsjob0:v1", -Name = "testcontainerappsjob0", -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); - ContainerAppJobResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(jobName); + ContainerAppJobResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobDetectorCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobDetectorCollection.cs index def4a9188692a..aba1ac2808fd7 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobDetectorCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobDetectorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerAppJobDetectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheListOfAvailableDiagnosticDataForAContainerAppJob() + public async Task Get_GetDiagnosticDataForAContainerAppJob() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_ListDetectors.json - // this example is just showing the usage of "Jobs_ListDetectors" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_GetDetector.json + // this example is just showing the usage of "Jobs_GetDetector" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetTheListOfAvailableDiagnosticDataForAContainerAppJob( // get the collection of this ContainerAppJobDetectorResource ContainerAppJobDetectorCollection collection = containerAppJob.GetContainerAppJobDetectors(); - // invoke the operation and iterate over the result - await foreach (ContainerAppJobDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDiagnosticData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "containerappjobnetworkIO"; + ContainerAppJobDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDiagnosticData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDiagnosticDataForAContainerAppJob() + public async Task GetAll_GetTheListOfAvailableDiagnosticDataForAContainerAppJob() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_GetDetector.json - // this example is just showing the usage of "Jobs_GetDetector" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_ListDetectors.json + // this example is just showing the usage of "Jobs_ListDetectors" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetDiagnosticDataForAContainerAppJob() // get the collection of this ContainerAppJobDetectorResource ContainerAppJobDetectorCollection collection = containerAppJob.GetContainerAppJobDetectors(); - // invoke the operation - string detectorName = "containerappjobnetworkIO"; - ContainerAppJobDetectorResource result = await collection.GetAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (ContainerAppJobDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDiagnosticData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDiagnosticData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobExecutionCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobExecutionCollection.cs index 31cf07dff08dd..a4366cbdbb740 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobExecutionCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobExecutionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerAppJobExecutionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAContainerAppsJobExecutions() + public async Task Get_GetASingleJobExecution() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Executions_Get.json - // this example is just showing the usage of "JobsExecutions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Execution_Get.json + // this example is just showing the usage of "JobExecution" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetAContainerAppsJobExecutions() // get the collection of this ContainerAppJobExecutionResource ContainerAppJobExecutionCollection collection = containerAppJob.GetContainerAppJobExecutions(); - // invoke the operation and iterate over the result - await foreach (ContainerAppJobExecutionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppJobExecutionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string jobExecutionName = "jobExecution1"; + ContainerAppJobExecutionResource result = await collection.GetAsync(jobExecutionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppJobExecutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASingleJobExecution() + public async Task GetAll_GetAContainerAppsJobExecutions() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Execution_Get.json - // this example is just showing the usage of "JobExecution" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Executions_Get.json + // this example is just showing the usage of "JobsExecutions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetASingleJobExecution() // get the collection of this ContainerAppJobExecutionResource ContainerAppJobExecutionCollection collection = containerAppJob.GetContainerAppJobExecutions(); - // invoke the operation - string jobExecutionName = "jobExecution1"; - ContainerAppJobExecutionResource result = await collection.GetAsync(jobExecutionName); + // invoke the operation and iterate over the result + await foreach (ContainerAppJobExecutionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppJobExecutionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppJobExecutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobExecutionResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobExecutionResource.cs index af7c0f548eff1..a5d25914a2d9c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobExecutionResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobExecutionResource.cs @@ -9,40 +9,12 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppContainers.Samples { public partial class Sample_ContainerAppJobExecutionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task StopExecutionJob_TerminateAContainerAppsJob() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Stop_Execution.json - // this example is just showing the usage of "Jobs_StopExecution" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerAppJobExecutionResource created on azure - // for more information of creating ContainerAppJobExecutionResource, please refer to the document of ContainerAppJobExecutionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "rg"; - string jobName = "testcontainerappsjob0"; - string jobExecutionName = "jobExecution1"; - ResourceIdentifier containerAppJobExecutionResourceId = ContainerAppJobExecutionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName, jobExecutionName); - ContainerAppJobExecutionResource containerAppJobExecution = client.GetContainerAppJobExecutionResource(containerAppJobExecutionResourceId); - - // invoke the operation - await containerAppJobExecution.StopExecutionJobAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetASingleJobExecution() @@ -76,26 +48,29 @@ public async Task Get_GetASingleJobExecution() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetCustomDomainVerificationId_ListAllOperations() + public async Task StopExecutionJob_TerminateAContainerAppsJob() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Subscriptions_GetCustomDomainVerificationId.json - // this example is just showing the usage of "GetCustomDomainVerificationId" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Job_Stop_Execution.json + // this example is just showing the usage of "Jobs_StopExecution" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "d27c3573-f76e-4b26-b871-0ccd2203d08c"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + // this example assumes you already have this ContainerAppJobExecutionResource created on azure + // for more information of creating ContainerAppJobExecutionResource, please refer to the document of ContainerAppJobExecutionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "rg"; + string jobName = "testcontainerappsjob0"; + string jobExecutionName = "jobExecution1"; + ResourceIdentifier containerAppJobExecutionResourceId = ContainerAppJobExecutionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName, jobExecutionName); + ContainerAppJobExecutionResource containerAppJobExecution = client.GetContainerAppJobExecutionResource(containerAppJobExecutionResourceId); // invoke the operation - string result = await subscriptionResource.GetCustomDomainVerificationIdAsync(); + await containerAppJobExecution.StopExecutionJobAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobResource.cs index f8bba8efb480e..17076a962e286 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppJobResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppContainers.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppContainers.Samples { public partial class Sample_ContainerAppJobResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetContainerAppJobs_ListContainerAppsJobsBySubscription() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Jobs_ListBySubscription.json - // this example is just showing the usage of "Jobs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ContainerAppJobResource item in subscriptionResource.GetContainerAppJobsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetContainerAppsJob() @@ -125,67 +93,49 @@ public async Task Update_PatchContainerAppsJob() ContainerAppJobResource containerAppJob = client.GetContainerAppJobResource(containerAppJobResourceId); // invoke the operation - ContainerAppJobPatch patch = new ContainerAppJobPatch() + ContainerAppJobPatch patch = new ContainerAppJobPatch { - Properties = new ContainerAppJobPatchProperties() + Properties = new ContainerAppJobPatchProperties { Configuration = new ContainerAppJobConfiguration(ContainerAppJobTriggerType.Manual, 10) { ReplicaRetryLimit = 10, - ManualTriggerConfig = new JobConfigurationManualTriggerConfig() + ManualTriggerConfig = new JobConfigurationManualTriggerConfig { ReplicaCompletionCount = 1, Parallelism = 4, }, }, - Template = new ContainerAppJobTemplate() + Template = new ContainerAppJobTemplate { - InitContainers = -{ -new ContainerAppInitContainer() + InitContainers = {new ContainerAppInitContainer { Image = "repo/testcontainerappsjob0:v4", Name = "testinitcontainerAppsJob0", -Command = -{ -"/bin/sh" -}, -Args = -{ -"-c","while true; do echo hello; sleep 10;done" -}, -Resources = new AppContainerResources() +Command = {"/bin/sh"}, +Args = {"-c", "while true; do echo hello; sleep 10;done"}, +Resources = new AppContainerResources { Cpu = 0.5, Memory = "1Gi", }, -} -}, - Containers = +}}, + Containers = {new ContainerAppContainer { -new ContainerAppContainer() -{ -Probes = -{ -new ContainerAppProbe() +Probes = {new ContainerAppProbe { HttpGet = new ContainerAppHttpRequestInfo(8080) { -HttpHeaders = -{ -new ContainerAppHttpHeaderInfo("Custom-Header","Awesome") -}, +HttpHeaders = {new ContainerAppHttpHeaderInfo("Custom-Header", "Awesome")}, Path = "/health", }, InitialDelaySeconds = 3, PeriodSeconds = 3, ProbeType = ContainerAppProbeType.Liveness, -} -}, +}}, Image = "repo/testcontainerappsjob0:v1", Name = "testcontainerappsjob0", -} -}, +}}, }, }, }; @@ -220,42 +170,30 @@ public async Task Start_RunAContainerAppsJob() ContainerAppJobResource containerAppJob = client.GetContainerAppJobResource(containerAppJobResourceId); // invoke the operation - ContainerAppJobExecutionTemplate template = new ContainerAppJobExecutionTemplate() + ContainerAppJobExecutionTemplate template = new ContainerAppJobExecutionTemplate { - Containers = -{ -new JobExecutionContainer() + Containers = {new JobExecutionContainer { Image = "repo/testcontainerappsjob0:v4", Name = "testcontainerappsjob0", -Resources = new AppContainerResources() +Resources = new AppContainerResources { Cpu = 0.5, Memory = "1Gi", }, -} -}, - InitContainers = -{ -new JobExecutionContainer() +}}, + InitContainers = {new JobExecutionContainer { Image = "repo/testcontainerappsjob0:v4", Name = "testinitcontainerAppsJob0", -Command = -{ -"/bin/sh" -}, -Args = -{ -"-c","while true; do echo hello; sleep 10;done" -}, -Resources = new AppContainerResources() +Command = {"/bin/sh"}, +Args = {"-c", "while true; do echo hello; sleep 10;done"}, +Resources = new AppContainerResources { Cpu = 0.5, Memory = "1Gi", }, -} -}, +}}, }; ArmOperation lro = await containerAppJob.StartAsync(WaitUntil.Completed, template: template); ContainerAppJobExecutionBase result = lro.Value; diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedCertificateCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedCertificateCollection.cs index e113e52e1cfd9..27133d60d50aa 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedCertificateCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedCertificateCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerAppManagedCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCertificate() + public async Task CreateOrUpdate_CreateOrUpdateCertificate() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedCertificate_Get.json - // this example is just showing the usage of "ManagedCertificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedCertificate_CreateOrUpdate.json + // this example is just showing the usage of "ManagedCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_GetCertificate() // invoke the operation string managedCertificateName = "certificate-firendly-name"; - ContainerAppManagedCertificateResource result = await collection.GetAsync(managedCertificateName); + ContainerAppManagedCertificateData data = new ContainerAppManagedCertificateData(new AzureLocation("East US")) + { + Properties = new ManagedCertificateProperties + { + SubjectName = "my-subject-name.company.country.net", + DomainControlValidation = ManagedCertificateDomainControlValidation.Cname, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedCertificateName, data); + ContainerAppManagedCertificateResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_GetCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCertificate() + public async Task Get_GetCertificate() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedCertificate_Get.json // this example is just showing the usage of "ManagedCertificates_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +84,21 @@ public async Task Exists_GetCertificate() // invoke the operation string managedCertificateName = "certificate-firendly-name"; - bool result = await collection.ExistsAsync(managedCertificateName); + ContainerAppManagedCertificateResource result = await collection.GetAsync(managedCertificateName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppManagedCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCertificate() + public async Task GetAll_ListManagedCertificatesByManagedEnvironment() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedCertificate_Get.json - // this example is just showing the usage of "ManagedCertificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedCertificates_ListByManagedEnvironment.json + // this example is just showing the usage of "ManagedCertificates_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +116,25 @@ public async Task GetIfExists_GetCertificate() // get the collection of this ContainerAppManagedCertificateResource ContainerAppManagedCertificateCollection collection = containerAppManagedEnvironment.GetContainerAppManagedCertificates(); - // invoke the operation - string managedCertificateName = "certificate-firendly-name"; - NullableResponse response = await collection.GetIfExistsAsync(managedCertificateName); - ContainerAppManagedCertificateResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ContainerAppManagedCertificateResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerAppManagedCertificateData resourceData = result.Data; + ContainerAppManagedCertificateData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateCertificate() + public async Task Exists_GetCertificate() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedCertificate_CreateOrUpdate.json - // this example is just showing the usage of "ManagedCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedCertificate_Get.json + // this example is just showing the usage of "ManagedCertificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,30 +154,17 @@ public async Task CreateOrUpdate_CreateOrUpdateCertificate() // invoke the operation string managedCertificateName = "certificate-firendly-name"; - ContainerAppManagedCertificateData data = new ContainerAppManagedCertificateData(new AzureLocation("East US")) - { - Properties = new ManagedCertificateProperties() - { - SubjectName = "my-subject-name.company.country.net", - DomainControlValidation = ManagedCertificateDomainControlValidation.Cname, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedCertificateName, data); - ContainerAppManagedCertificateResource result = lro.Value; + bool result = await collection.ExistsAsync(managedCertificateName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppManagedCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedCertificatesByManagedEnvironment() + public async Task GetIfExists_GetCertificate() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedCertificates_ListByManagedEnvironment.json - // this example is just showing the usage of "ManagedCertificates_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedCertificate_Get.json + // this example is just showing the usage of "ManagedCertificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_ListManagedCertificatesByManagedEnvironment() // get the collection of this ContainerAppManagedCertificateResource ContainerAppManagedCertificateCollection collection = containerAppManagedEnvironment.GetContainerAppManagedCertificates(); - // invoke the operation and iterate over the result - await foreach (ContainerAppManagedCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string managedCertificateName = "certificate-firendly-name"; + NullableResponse response = await collection.GetIfExistsAsync(managedCertificateName); + ContainerAppManagedCertificateResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerAppManagedCertificateData resourceData = item.Data; + ContainerAppManagedCertificateData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedCertificateResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedCertificateResource.cs index 9d33586d992f2..2ce45f645e26d 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedCertificateResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedCertificateResource.cs @@ -96,12 +96,12 @@ public async Task Update_PatchManagedCertificate() ContainerAppManagedCertificateResource containerAppManagedCertificate = client.GetContainerAppManagedCertificateResource(containerAppManagedCertificateResourceId); // invoke the operation - ContainerAppManagedCertificatePatch patch = new ContainerAppManagedCertificatePatch() + ContainerAppManagedCertificatePatch patch = new ContainerAppManagedCertificatePatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ContainerAppManagedCertificateResource result = await containerAppManagedCertificate.UpdateAsync(patch); diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCertificateCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCertificateCollection.cs index 97b50e5acee34..449ae351648c5 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCertificateCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCertificateCollection.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Text; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -18,10 +19,10 @@ public partial class Sample_ContainerAppManagedEnvironmentCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCertificatesByManagedEnvironment() + public async Task CreateOrUpdate_CreateOrUpdateCertificate() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Certificates_ListByManagedEnvironment.json - // this example is just showing the usage of "Certificates_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Certificate_CreateOrUpdate.json + // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +40,24 @@ public async Task GetAll_ListCertificatesByManagedEnvironment() // get the collection of this ContainerAppManagedEnvironmentCertificateResource ContainerAppManagedEnvironmentCertificateCollection collection = containerAppManagedEnvironment.GetContainerAppManagedEnvironmentCertificates(); - // invoke the operation and iterate over the result - await foreach (ContainerAppManagedEnvironmentCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string certificateName = "certificate-firendly-name"; + ContainerAppCertificateData data = new ContainerAppCertificateData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new ContainerAppCertificateProperties + { + Password = "private key password", + Value = Encoding.UTF8.GetBytes("Y2VydA=="), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); + ContainerAppManagedEnvironmentCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCertificate() + public async Task GetAll_ListCertificatesByManagedEnvironment() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Certificate_Get.json - // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Certificates_ListByManagedEnvironment.json + // this example is just showing the usage of "Certificates_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetCertificate() // get the collection of this ContainerAppManagedEnvironmentCertificateResource ContainerAppManagedEnvironmentCertificateCollection collection = containerAppManagedEnvironment.GetContainerAppManagedEnvironmentCertificates(); - // invoke the operation - string certificateName = "certificate-firendly-name"; - bool result = await collection.ExistsAsync(certificateName); + // invoke the operation and iterate over the result + await foreach (ContainerAppManagedEnvironmentCertificateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCertificate() + public async Task Exists_GetCertificate() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Certificate_Get.json // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetCertificate() // invoke the operation string certificateName = "certificate-firendly-name"; - NullableResponse response = await collection.GetIfExistsAsync(certificateName); - ContainerAppManagedEnvironmentCertificateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(certificateName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateCertificate() + public async Task GetIfExists_GetCertificate() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Certificate_CreateOrUpdate.json - // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Certificate_Get.json + // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateCertificate() // invoke the operation string certificateName = "certificate-firendly-name"; - ContainerAppCertificateData data = new ContainerAppCertificateData(new AzureLocation("East US")) - { - Properties = new ContainerAppCertificateProperties() - { - Password = "private key password", - Value = Convert.FromBase64String("Y2VydA=="), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); - ContainerAppManagedEnvironmentCertificateResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(certificateName); + ContainerAppManagedEnvironmentCertificateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCertificateResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCertificateResource.cs index bfaa8e30c045c..6357e630ce643 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCertificateResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCertificateResource.cs @@ -96,12 +96,12 @@ public async Task Update_PatchCertificate() ContainerAppManagedEnvironmentCertificateResource containerAppManagedEnvironmentCertificate = client.GetContainerAppManagedEnvironmentCertificateResource(containerAppManagedEnvironmentCertificateResourceId); // invoke the operation - ContainerAppCertificatePatch patch = new ContainerAppCertificatePatch() + ContainerAppCertificatePatch patch = new ContainerAppCertificatePatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ContainerAppManagedEnvironmentCertificateResource result = await containerAppManagedEnvironmentCertificate.UpdateAsync(patch); diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCollection.cs index 7aeda9de25b23..03de5b2d35200 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentCollection.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Text; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +20,10 @@ public partial class Sample_ContainerAppManagedEnvironmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEnvironmentsByResourceGroup() + public async Task CreateOrUpdate_CreateEnvironmentWithCustomInfrastructureResourceGroup() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_ListByResourceGroup.json - // this example is just showing the usage of "ManagedEnvironments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_CustomInfrastructureResourceGroup_Create.json + // this example is just showing the usage of "ManagedEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +32,7 @@ public async Task GetAll_ListEnvironmentsByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "examplerg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -39,25 +40,61 @@ public async Task GetAll_ListEnvironmentsByResourceGroup() // get the collection of this ContainerAppManagedEnvironmentResource ContainerAppManagedEnvironmentCollection collection = resourceGroupResource.GetContainerAppManagedEnvironments(); - // invoke the operation and iterate over the result - await foreach (ContainerAppManagedEnvironmentResource item in collection.GetAllAsync()) + // invoke the operation + string environmentName = "testcontainerenv"; + ContainerAppManagedEnvironmentData data = new ContainerAppManagedEnvironmentData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppManagedEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DaprAIConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://northcentralus-0.in.applicationinsights.azure.com/", + VnetConfiguration = new ContainerAppVnetConfiguration + { + InfrastructureSubnetId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/RGName/providers/Microsoft.Network/virtualNetworks/VNetName/subnets/subnetName1"), + }, + AppLogsConfiguration = new ContainerAppLogsConfiguration + { + LogAnalyticsConfiguration = new ContainerAppLogAnalyticsConfiguration + { + CustomerId = "string", + SharedKey = "string", + }, + }, + IsZoneRedundant = true, + CustomDomainConfiguration = new ContainerAppCustomDomainConfiguration + { + DnsSuffix = "www.my-name.com", + CertificateValue = Encoding.UTF8.GetBytes("Y2VydA=="), + CertificatePassword = "1234", + }, + WorkloadProfiles = {new ContainerAppWorkloadProfile("My-GP-01", "GeneralPurpose") +{ +MinimumNodeCount = 3, +MaximumNodeCount = 12, +}, new ContainerAppWorkloadProfile("My-MO-01", "MemoryOptimized") +{ +MinimumNodeCount = 3, +MaximumNodeCount = 6, +}, new ContainerAppWorkloadProfile("My-CO-01", "ComputeOptimized") +{ +MinimumNodeCount = 3, +MaximumNodeCount = 6, +}, new ContainerAppWorkloadProfile("My-consumption-01", "Consumption")}, + InfrastructureResourceGroup = "myInfrastructureRgName", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, environmentName, data); + ContainerAppManagedEnvironmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppManagedEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetEnvironmentsByName() + public async Task CreateOrUpdate_CreateEnvironments() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_Get.json - // this example is just showing the usage of "ManagedEnvironments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_CreateOrUpdate.json + // this example is just showing the usage of "ManagedEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,7 +103,7 @@ public async Task Get_GetEnvironmentsByName() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "examplerg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -75,8 +112,47 @@ public async Task Get_GetEnvironmentsByName() ContainerAppManagedEnvironmentCollection collection = resourceGroupResource.GetContainerAppManagedEnvironments(); // invoke the operation - string environmentName = "jlaw-demo1"; - ContainerAppManagedEnvironmentResource result = await collection.GetAsync(environmentName); + string environmentName = "testcontainerenv"; + ContainerAppManagedEnvironmentData data = new ContainerAppManagedEnvironmentData(new AzureLocation("East US")) + { + DaprAIConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://northcentralus-0.in.applicationinsights.azure.com/", + VnetConfiguration = new ContainerAppVnetConfiguration + { + InfrastructureSubnetId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/RGName/providers/Microsoft.Network/virtualNetworks/VNetName/subnets/subnetName1"), + }, + AppLogsConfiguration = new ContainerAppLogsConfiguration + { + LogAnalyticsConfiguration = new ContainerAppLogAnalyticsConfiguration + { + CustomerId = "string", + SharedKey = "string", + }, + }, + IsZoneRedundant = true, + CustomDomainConfiguration = new ContainerAppCustomDomainConfiguration + { + DnsSuffix = "www.my-name.com", + CertificateValue = Encoding.UTF8.GetBytes("Y2VydA=="), + CertificatePassword = "1234", + }, + WorkloadProfiles = {new ContainerAppWorkloadProfile("My-GP-01", "GeneralPurpose") +{ +MinimumNodeCount = 3, +MaximumNodeCount = 12, +}, new ContainerAppWorkloadProfile("My-MO-01", "MemoryOptimized") +{ +MinimumNodeCount = 3, +MaximumNodeCount = 6, +}, new ContainerAppWorkloadProfile("My-CO-01", "ComputeOptimized") +{ +MinimumNodeCount = 3, +MaximumNodeCount = 6, +}, new ContainerAppWorkloadProfile("My-consumption-01", "Consumption")}, + IsMtlsEnabled = true, + IsEnabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, environmentName, data); + ContainerAppManagedEnvironmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +163,7 @@ public async Task Get_GetEnvironmentsByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetEnvironmentsByName() + public async Task Get_GetEnvironmentsByName() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_Get.json // this example is just showing the usage of "ManagedEnvironments_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,17 +185,21 @@ public async Task Exists_GetEnvironmentsByName() // invoke the operation string environmentName = "jlaw-demo1"; - bool result = await collection.ExistsAsync(environmentName); + ContainerAppManagedEnvironmentResource result = await collection.GetAsync(environmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppManagedEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetEnvironmentsByName() + public async Task GetAll_ListEnvironmentsByResourceGroup() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_Get.json - // this example is just showing the usage of "ManagedEnvironments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_ListByResourceGroup.json + // this example is just showing the usage of "ManagedEnvironments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,31 +216,25 @@ public async Task GetIfExists_GetEnvironmentsByName() // get the collection of this ContainerAppManagedEnvironmentResource ContainerAppManagedEnvironmentCollection collection = resourceGroupResource.GetContainerAppManagedEnvironments(); - // invoke the operation - string environmentName = "jlaw-demo1"; - NullableResponse response = await collection.GetIfExistsAsync(environmentName); - ContainerAppManagedEnvironmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ContainerAppManagedEnvironmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerAppManagedEnvironmentData resourceData = result.Data; + ContainerAppManagedEnvironmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateEnvironmentWithCustomInfrastructureResourceGroup() + public async Task Exists_GetEnvironmentsByName() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_CustomInfrastructureResourceGroup_Create.json - // this example is just showing the usage of "ManagedEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_Get.json + // this example is just showing the usage of "ManagedEnvironments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -169,7 +243,7 @@ public async Task CreateOrUpdate_CreateEnvironmentWithCustomInfrastructureResour // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; string resourceGroupName = "examplerg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -178,63 +252,18 @@ public async Task CreateOrUpdate_CreateEnvironmentWithCustomInfrastructureResour ContainerAppManagedEnvironmentCollection collection = resourceGroupResource.GetContainerAppManagedEnvironments(); // invoke the operation - string environmentName = "testcontainerenv"; - ContainerAppManagedEnvironmentData data = new ContainerAppManagedEnvironmentData(new AzureLocation("East US")) - { - DaprAIConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://northcentralus-0.in.applicationinsights.azure.com/", - VnetConfiguration = new ContainerAppVnetConfiguration() - { - InfrastructureSubnetId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/RGName/providers/Microsoft.Network/virtualNetworks/VNetName/subnets/subnetName1"), - }, - AppLogsConfiguration = new ContainerAppLogsConfiguration() - { - LogAnalyticsConfiguration = new ContainerAppLogAnalyticsConfiguration() - { - CustomerId = "string", - SharedKey = "string", - }, - }, - IsZoneRedundant = true, - CustomDomainConfiguration = new ContainerAppCustomDomainConfiguration() - { - DnsSuffix = "www.my-name.com", - CertificateValue = Convert.FromBase64String("Y2VydA=="), - CertificatePassword = "1234", - }, - WorkloadProfiles = -{ -new ContainerAppWorkloadProfile("My-GP-01","GeneralPurpose") -{ -MinimumNodeCount = 3, -MaximumNodeCount = 12, -},new ContainerAppWorkloadProfile("My-MO-01","MemoryOptimized") -{ -MinimumNodeCount = 3, -MaximumNodeCount = 6, -},new ContainerAppWorkloadProfile("My-CO-01","ComputeOptimized") -{ -MinimumNodeCount = 3, -MaximumNodeCount = 6, -},new ContainerAppWorkloadProfile("My-consumption-01","Consumption") -}, - InfrastructureResourceGroup = "myInfrastructureRgName", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, environmentName, data); - ContainerAppManagedEnvironmentResource result = lro.Value; + string environmentName = "jlaw-demo1"; + bool result = await collection.ExistsAsync(environmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppManagedEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateEnvironments() + public async Task GetIfExists_GetEnvironmentsByName() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_CreateOrUpdate.json - // this example is just showing the usage of "ManagedEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_Get.json + // this example is just showing the usage of "ManagedEnvironments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -243,7 +272,7 @@ public async Task CreateOrUpdate_CreateEnvironments() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; string resourceGroupName = "examplerg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -252,56 +281,22 @@ public async Task CreateOrUpdate_CreateEnvironments() ContainerAppManagedEnvironmentCollection collection = resourceGroupResource.GetContainerAppManagedEnvironments(); // invoke the operation - string environmentName = "testcontainerenv"; - ContainerAppManagedEnvironmentData data = new ContainerAppManagedEnvironmentData(new AzureLocation("East US")) - { - DaprAIConnectionString = "InstrumentationKey=00000000-0000-0000-0000-000000000000;IngestionEndpoint=https://northcentralus-0.in.applicationinsights.azure.com/", - VnetConfiguration = new ContainerAppVnetConfiguration() - { - InfrastructureSubnetId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/RGName/providers/Microsoft.Network/virtualNetworks/VNetName/subnets/subnetName1"), - }, - AppLogsConfiguration = new ContainerAppLogsConfiguration() - { - LogAnalyticsConfiguration = new ContainerAppLogAnalyticsConfiguration() - { - CustomerId = "string", - SharedKey = "string", - }, - }, - IsZoneRedundant = true, - CustomDomainConfiguration = new ContainerAppCustomDomainConfiguration() - { - DnsSuffix = "www.my-name.com", - CertificateValue = Convert.FromBase64String("Y2VydA=="), - CertificatePassword = "1234", - }, - WorkloadProfiles = -{ -new ContainerAppWorkloadProfile("My-GP-01","GeneralPurpose") -{ -MinimumNodeCount = 3, -MaximumNodeCount = 12, -},new ContainerAppWorkloadProfile("My-MO-01","MemoryOptimized") -{ -MinimumNodeCount = 3, -MaximumNodeCount = 6, -},new ContainerAppWorkloadProfile("My-CO-01","ComputeOptimized") -{ -MinimumNodeCount = 3, -MaximumNodeCount = 6, -},new ContainerAppWorkloadProfile("My-consumption-01","Consumption") -}, - IsMtlsEnabled = true, - IsEnabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, environmentName, data); - ContainerAppManagedEnvironmentResource result = lro.Value; + string environmentName = "jlaw-demo1"; + NullableResponse response = await collection.GetIfExistsAsync(environmentName); + ContainerAppManagedEnvironmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppManagedEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppManagedEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDaprComponentCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDaprComponentCollection.cs index c71a0181921ab..b33eb6848ab93 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDaprComponentCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDaprComponentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerAppManagedEnvironmentDaprComponentCollectio { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDaprComponents() + public async Task CreateOrUpdate_CreateOrUpdateDaprComponentWithSecretStoreComponent() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_List.json - // this example is just showing the usage of "DaprComponents_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_CreateOrUpdate_SecretStoreComponent.json + // this example is just showing the usage of "DaprComponents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,50 @@ public async Task GetAll_ListDaprComponents() // get the collection of this ContainerAppManagedEnvironmentDaprComponentResource ContainerAppManagedEnvironmentDaprComponentCollection collection = containerAppManagedEnvironment.GetContainerAppManagedEnvironmentDaprComponents(); - // invoke the operation and iterate over the result - await foreach (ContainerAppManagedEnvironmentDaprComponentResource item in collection.GetAllAsync()) + // invoke the operation + string componentName = "reddog"; + ContainerAppDaprComponentData data = new ContainerAppDaprComponentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDaprComponentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ComponentType = "state.azure.cosmosdb", + Version = "v1", + IgnoreErrors = false, + InitTimeout = "50s", + SecretStoreComponent = "my-secret-store", + Metadata = {new ContainerAppDaprMetadata +{ +Name = "url", +Value = "", +}, new ContainerAppDaprMetadata +{ +Name = "database", +Value = "itemsDB", +}, new ContainerAppDaprMetadata +{ +Name = "collection", +Value = "items", +}, new ContainerAppDaprMetadata +{ +Name = "masterkey", +SecretRef = "masterkey", +}}, + Scopes = { "container-app-1", "container-app-2" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, componentName, data); + ContainerAppManagedEnvironmentDaprComponentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDaprComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDaprComponentWithSecretStoreComponent() + public async Task CreateOrUpdate_CreateOrUpdateDaprComponentWithSecrets() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Get_SecretStoreComponent.json - // this example is just showing the usage of "DaprComponents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_CreateOrUpdate_Secrets.json + // this example is just showing the usage of "DaprComponents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +102,38 @@ public async Task Get_GetDaprComponentWithSecretStoreComponent() // invoke the operation string componentName = "reddog"; - ContainerAppManagedEnvironmentDaprComponentResource result = await collection.GetAsync(componentName); + ContainerAppDaprComponentData data = new ContainerAppDaprComponentData + { + ComponentType = "state.azure.cosmosdb", + Version = "v1", + IgnoreErrors = false, + InitTimeout = "50s", + Secrets = {new ContainerAppWritableSecret +{ +Name = "masterkey", +Value = "keyvalue", +}}, + Metadata = {new ContainerAppDaprMetadata +{ +Name = "url", +Value = "", +}, new ContainerAppDaprMetadata +{ +Name = "database", +Value = "itemsDB", +}, new ContainerAppDaprMetadata +{ +Name = "collection", +Value = "items", +}, new ContainerAppDaprMetadata +{ +Name = "masterkey", +SecretRef = "masterkey", +}}, + Scopes = { "container-app-1", "container-app-2" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, componentName, data); + ContainerAppManagedEnvironmentDaprComponentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +144,7 @@ public async Task Get_GetDaprComponentWithSecretStoreComponent() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDaprComponentWithSecretStoreComponent() + public async Task Get_GetDaprComponentWithSecretStoreComponent() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Get_SecretStoreComponent.json // this example is just showing the usage of "DaprComponents_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,16 +167,20 @@ public async Task Exists_GetDaprComponentWithSecretStoreComponent() // invoke the operation string componentName = "reddog"; - bool result = await collection.ExistsAsync(componentName); + ContainerAppManagedEnvironmentDaprComponentResource result = await collection.GetAsync(componentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDaprComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDaprComponentWithSecretStoreComponent() + public async Task Get_GetDaprComponentWithSecrets() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Get_SecretStoreComponent.json + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Get_Secrets.json // this example is just showing the usage of "DaprComponents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -141,29 +201,21 @@ public async Task GetIfExists_GetDaprComponentWithSecretStoreComponent() // invoke the operation string componentName = "reddog"; - NullableResponse response = await collection.GetIfExistsAsync(componentName); - ContainerAppManagedEnvironmentDaprComponentResource result = response.HasValue ? response.Value : null; + ContainerAppManagedEnvironmentDaprComponentResource result = await collection.GetAsync(componentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDaprComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDaprComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDaprComponentWithSecrets() + public async Task GetAll_ListDaprComponents() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Get_Secrets.json - // this example is just showing the usage of "DaprComponents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_List.json + // this example is just showing the usage of "DaprComponents_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,22 +233,24 @@ public async Task Get_GetDaprComponentWithSecrets() // get the collection of this ContainerAppManagedEnvironmentDaprComponentResource ContainerAppManagedEnvironmentDaprComponentCollection collection = containerAppManagedEnvironment.GetContainerAppManagedEnvironmentDaprComponents(); - // invoke the operation - string componentName = "reddog"; - ContainerAppManagedEnvironmentDaprComponentResource result = await collection.GetAsync(componentName); + // invoke the operation and iterate over the result + await foreach (ContainerAppManagedEnvironmentDaprComponentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDaprComponentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDaprComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDaprComponentWithSecrets() + public async Task Exists_GetDaprComponentWithSecretStoreComponent() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Get_Secrets.json + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Get_SecretStoreComponent.json // this example is just showing the usage of "DaprComponents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -224,7 +278,7 @@ public async Task Exists_GetDaprComponentWithSecrets() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDaprComponentWithSecrets() + public async Task Exists_GetDaprComponentWithSecrets() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Get_Secrets.json // this example is just showing the usage of "DaprComponents_Get" operation, for the dependent resources, they will have to be created separately. @@ -247,29 +301,17 @@ public async Task GetIfExists_GetDaprComponentWithSecrets() // invoke the operation string componentName = "reddog"; - NullableResponse response = await collection.GetIfExistsAsync(componentName); - ContainerAppManagedEnvironmentDaprComponentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(componentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDaprComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDaprComponentWithSecretStoreComponent() + public async Task GetIfExists_GetDaprComponentWithSecretStoreComponent() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_CreateOrUpdate_SecretStoreComponent.json - // this example is just showing the usage of "DaprComponents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Get_SecretStoreComponent.json + // this example is just showing the usage of "DaprComponents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -289,54 +331,29 @@ public async Task CreateOrUpdate_CreateOrUpdateDaprComponentWithSecretStoreCompo // invoke the operation string componentName = "reddog"; - ContainerAppDaprComponentData data = new ContainerAppDaprComponentData() - { - ComponentType = "state.azure.cosmosdb", - Version = "v1", - IgnoreErrors = false, - InitTimeout = "50s", - SecretStoreComponent = "my-secret-store", - Metadata = -{ -new ContainerAppDaprMetadata() -{ -Name = "url", -Value = "", -},new ContainerAppDaprMetadata() -{ -Name = "database", -Value = "itemsDB", -},new ContainerAppDaprMetadata() -{ -Name = "collection", -Value = "items", -},new ContainerAppDaprMetadata() -{ -Name = "masterkey", -SecretRef = "masterkey", -} -}, - Scopes = -{ -"container-app-1","container-app-2" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, componentName, data); - ContainerAppManagedEnvironmentDaprComponentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(componentName); + ContainerAppManagedEnvironmentDaprComponentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDaprComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDaprComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDaprComponentWithSecrets() + public async Task GetIfExists_GetDaprComponentWithSecrets() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_CreateOrUpdate_Secrets.json - // this example is just showing the usage of "DaprComponents_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Get_Secrets.json + // this example is just showing the usage of "DaprComponents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -356,53 +373,21 @@ public async Task CreateOrUpdate_CreateOrUpdateDaprComponentWithSecrets() // invoke the operation string componentName = "reddog"; - ContainerAppDaprComponentData data = new ContainerAppDaprComponentData() - { - ComponentType = "state.azure.cosmosdb", - Version = "v1", - IgnoreErrors = false, - InitTimeout = "50s", - Secrets = -{ -new ContainerAppWritableSecret() -{ -Name = "masterkey", -Value = "keyvalue", -} -}, - Metadata = -{ -new ContainerAppDaprMetadata() -{ -Name = "url", -Value = "", -},new ContainerAppDaprMetadata() -{ -Name = "database", -Value = "itemsDB", -},new ContainerAppDaprMetadata() -{ -Name = "collection", -Value = "items", -},new ContainerAppDaprMetadata() -{ -Name = "masterkey", -SecretRef = "masterkey", -} -}, - Scopes = -{ -"container-app-1","container-app-2" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, componentName, data); - ContainerAppManagedEnvironmentDaprComponentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(componentName); + ContainerAppManagedEnvironmentDaprComponentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDaprComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDaprComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDaprComponentResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDaprComponentResource.cs index 4ec062fb69469..ec58a81acf99e 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDaprComponentResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDaprComponentResource.cs @@ -78,6 +78,33 @@ public async Task Get_GetDaprComponentWithSecrets() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteDaprComponent() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Delete.json + // this example is just showing the usage of "DaprComponents_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerAppManagedEnvironmentDaprComponentResource created on azure + // for more information of creating ContainerAppManagedEnvironmentDaprComponentResource, please refer to the document of ContainerAppManagedEnvironmentDaprComponentResource + string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; + string resourceGroupName = "examplerg"; + string environmentName = "myenvironment"; + string componentName = "reddog"; + ResourceIdentifier containerAppManagedEnvironmentDaprComponentResourceId = ContainerAppManagedEnvironmentDaprComponentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, environmentName, componentName); + ContainerAppManagedEnvironmentDaprComponentResource containerAppManagedEnvironmentDaprComponent = client.GetContainerAppManagedEnvironmentDaprComponentResource(containerAppManagedEnvironmentDaprComponentResourceId); + + // invoke the operation + await containerAppManagedEnvironmentDaprComponent.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateDaprComponentWithSecretStoreComponent() @@ -100,37 +127,31 @@ public async Task Update_CreateOrUpdateDaprComponentWithSecretStoreComponent() ContainerAppManagedEnvironmentDaprComponentResource containerAppManagedEnvironmentDaprComponent = client.GetContainerAppManagedEnvironmentDaprComponentResource(containerAppManagedEnvironmentDaprComponentResourceId); // invoke the operation - ContainerAppDaprComponentData data = new ContainerAppDaprComponentData() + ContainerAppDaprComponentData data = new ContainerAppDaprComponentData { ComponentType = "state.azure.cosmosdb", Version = "v1", IgnoreErrors = false, InitTimeout = "50s", SecretStoreComponent = "my-secret-store", - Metadata = -{ -new ContainerAppDaprMetadata() + Metadata = {new ContainerAppDaprMetadata { Name = "url", Value = "", -},new ContainerAppDaprMetadata() +}, new ContainerAppDaprMetadata { Name = "database", Value = "itemsDB", -},new ContainerAppDaprMetadata() +}, new ContainerAppDaprMetadata { Name = "collection", Value = "items", -},new ContainerAppDaprMetadata() +}, new ContainerAppDaprMetadata { Name = "masterkey", SecretRef = "masterkey", -} -}, - Scopes = -{ -"container-app-1","container-app-2" -}, +}}, + Scopes = { "container-app-1", "container-app-2" }, }; ArmOperation lro = await containerAppManagedEnvironmentDaprComponent.UpdateAsync(WaitUntil.Completed, data); ContainerAppManagedEnvironmentDaprComponentResource result = lro.Value; @@ -164,44 +185,35 @@ public async Task Update_CreateOrUpdateDaprComponentWithSecrets() ContainerAppManagedEnvironmentDaprComponentResource containerAppManagedEnvironmentDaprComponent = client.GetContainerAppManagedEnvironmentDaprComponentResource(containerAppManagedEnvironmentDaprComponentResourceId); // invoke the operation - ContainerAppDaprComponentData data = new ContainerAppDaprComponentData() + ContainerAppDaprComponentData data = new ContainerAppDaprComponentData { ComponentType = "state.azure.cosmosdb", Version = "v1", IgnoreErrors = false, InitTimeout = "50s", - Secrets = -{ -new ContainerAppWritableSecret() + Secrets = {new ContainerAppWritableSecret { Name = "masterkey", Value = "keyvalue", -} -}, - Metadata = -{ -new ContainerAppDaprMetadata() +}}, + Metadata = {new ContainerAppDaprMetadata { Name = "url", Value = "", -},new ContainerAppDaprMetadata() +}, new ContainerAppDaprMetadata { Name = "database", Value = "itemsDB", -},new ContainerAppDaprMetadata() +}, new ContainerAppDaprMetadata { Name = "collection", Value = "items", -},new ContainerAppDaprMetadata() +}, new ContainerAppDaprMetadata { Name = "masterkey", SecretRef = "masterkey", -} -}, - Scopes = -{ -"container-app-1","container-app-2" -}, +}}, + Scopes = { "container-app-1", "container-app-2" }, }; ArmOperation lro = await containerAppManagedEnvironmentDaprComponent.UpdateAsync(WaitUntil.Completed, data); ContainerAppManagedEnvironmentDaprComponentResource result = lro.Value; @@ -213,33 +225,6 @@ public async Task Update_CreateOrUpdateDaprComponentWithSecrets() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDaprComponent() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/DaprComponents_Delete.json - // this example is just showing the usage of "DaprComponents_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerAppManagedEnvironmentDaprComponentResource created on azure - // for more information of creating ContainerAppManagedEnvironmentDaprComponentResource, please refer to the document of ContainerAppManagedEnvironmentDaprComponentResource - string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; - string resourceGroupName = "examplerg"; - string environmentName = "myenvironment"; - string componentName = "reddog"; - ResourceIdentifier containerAppManagedEnvironmentDaprComponentResourceId = ContainerAppManagedEnvironmentDaprComponentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, environmentName, componentName); - ContainerAppManagedEnvironmentDaprComponentResource containerAppManagedEnvironmentDaprComponent = client.GetContainerAppManagedEnvironmentDaprComponentResource(containerAppManagedEnvironmentDaprComponentResourceId); - - // invoke the operation - await containerAppManagedEnvironmentDaprComponent.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSecrets_ListContainerAppsSecrets() diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDetectorCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDetectorCollection.cs index 52fb80c283370..65ce2adb2d13b 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDetectorCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentDetectorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerAppManagedEnvironmentDetectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetTheListOfAvailableDiagnosticDataForAManagedEnvironments() + public async Task Get_GetDiagnosticDataForAManagedEnvironments() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentDiagnostics_List.json - // this example is just showing the usage of "ManagedEnvironmentDiagnostics_ListDetectors" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentDiagnostics_Get.json + // this example is just showing the usage of "ManagedEnvironmentDiagnostics_GetDetector" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetTheListOfAvailableDiagnosticDataForAManagedEnvironme // get the collection of this ContainerAppManagedEnvironmentDetectorResource ContainerAppManagedEnvironmentDetectorCollection collection = containerAppManagedEnvironment.GetContainerAppManagedEnvironmentDetectors(); - // invoke the operation and iterate over the result - await foreach (ContainerAppManagedEnvironmentDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDiagnosticData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorName = "ManagedEnvAvailabilityMetrics"; + ContainerAppManagedEnvironmentDetectorResource result = await collection.GetAsync(detectorName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDiagnosticData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDiagnosticDataForAManagedEnvironments() + public async Task GetAll_GetTheListOfAvailableDiagnosticDataForAManagedEnvironments() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentDiagnostics_Get.json - // this example is just showing the usage of "ManagedEnvironmentDiagnostics_GetDetector" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentDiagnostics_List.json + // this example is just showing the usage of "ManagedEnvironmentDiagnostics_ListDetectors" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetDiagnosticDataForAManagedEnvironments() // get the collection of this ContainerAppManagedEnvironmentDetectorResource ContainerAppManagedEnvironmentDetectorCollection collection = containerAppManagedEnvironment.GetContainerAppManagedEnvironmentDetectors(); - // invoke the operation - string detectorName = "ManagedEnvAvailabilityMetrics"; - ContainerAppManagedEnvironmentDetectorResource result = await collection.GetAsync(detectorName); + // invoke the operation and iterate over the result + await foreach (ContainerAppManagedEnvironmentDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppDiagnosticData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppDiagnosticData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentResource.cs index c8d80e9fa6076..4f0bde4520c23 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppContainers.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppContainers.Samples { public partial class Sample_ContainerAppManagedEnvironmentResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetContainerAppManagedEnvironments_ListEnvironmentsBySubscription() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_ListBySubscription.json - // this example is just showing the usage of "ManagedEnvironments_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ContainerAppManagedEnvironmentResource item in subscriptionResource.GetContainerAppManagedEnvironmentsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppManagedEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetEnvironmentsByName() @@ -130,7 +98,7 @@ public async Task Update_PatchManagedEnvironment() Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await containerAppManagedEnvironment.UpdateAsync(WaitUntil.Completed, data); @@ -219,7 +187,7 @@ public async Task CheckContainerAppNameAvailability_CertificatesCheckNameAvailab ContainerAppManagedEnvironmentResource containerAppManagedEnvironment = client.GetContainerAppManagedEnvironmentResource(containerAppManagedEnvironmentResourceId); // invoke the operation - ContainerAppNameAvailabilityContent content = new ContainerAppNameAvailabilityContent() + ContainerAppNameAvailabilityContent content = new ContainerAppNameAvailabilityContent { Name = "testcertificatename", ResourceType = new ResourceType("Microsoft.App/managedEnvironments/certificates"), @@ -250,7 +218,7 @@ public async Task CheckContainerAppNameAvailability_ContainerAppsCheckNameAvaila ContainerAppManagedEnvironmentResource containerAppManagedEnvironment = client.GetContainerAppManagedEnvironmentResource(containerAppManagedEnvironmentResourceId); // invoke the operation - ContainerAppNameAvailabilityContent content = new ContainerAppNameAvailabilityContent() + ContainerAppNameAvailabilityContent content = new ContainerAppNameAvailabilityContent { Name = "testcappname", ResourceType = new ResourceType("Microsoft.App/containerApps"), diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentStorageCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentStorageCollection.cs index a4743c61b32ef..cd94ac6838154 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentStorageCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentStorageCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerAppManagedEnvironmentStorageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEnvironmentsStoragesBySubscription() + public async Task CreateOrUpdate_CreateOrUpdateEnvironmentsStorage() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_List.json - // this example is just showing the usage of "ManagedEnvironmentsStorages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_CreateOrUpdate.json + // this example is just showing the usage of "ManagedEnvironmentsStorages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,26 @@ public async Task GetAll_ListEnvironmentsStoragesBySubscription() // get the collection of this ContainerAppManagedEnvironmentStorageResource ContainerAppManagedEnvironmentStorageCollection collection = containerAppManagedEnvironment.GetContainerAppManagedEnvironmentStorages(); - // invoke the operation and iterate over the result - await foreach (ContainerAppManagedEnvironmentStorageResource item in collection.GetAllAsync()) + // invoke the operation + string storageName = "jlaw-demo1"; + ContainerAppManagedEnvironmentStorageData data = new ContainerAppManagedEnvironmentStorageData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppManagedEnvironmentStorageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ManagedEnvironmentStorageAzureFile = new ContainerAppAzureFileProperties + { + AccountName = "account1", + AccountKey = "key", + AccessMode = ContainerAppAccessMode.ReadOnly, + ShareName = "share1", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageName, data); + ContainerAppManagedEnvironmentStorageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppManagedEnvironmentStorageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +97,10 @@ public async Task Get_GetAEnvironmentsStoragePropertiesBySubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAEnvironmentsStoragePropertiesBySubscription() + public async Task GetAll_ListEnvironmentsStoragesBySubscription() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_Get.json - // this example is just showing the usage of "ManagedEnvironmentsStorages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_List.json + // this example is just showing the usage of "ManagedEnvironmentsStorages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +118,22 @@ public async Task Exists_GetAEnvironmentsStoragePropertiesBySubscription() // get the collection of this ContainerAppManagedEnvironmentStorageResource ContainerAppManagedEnvironmentStorageCollection collection = containerAppManagedEnvironment.GetContainerAppManagedEnvironmentStorages(); - // invoke the operation - string storageName = "jlaw-demo1"; - bool result = await collection.ExistsAsync(storageName); + // invoke the operation and iterate over the result + await foreach (ContainerAppManagedEnvironmentStorageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppManagedEnvironmentStorageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAEnvironmentsStoragePropertiesBySubscription() + public async Task Exists_GetAEnvironmentsStoragePropertiesBySubscription() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_Get.json // this example is just showing the usage of "ManagedEnvironmentsStorages_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +156,17 @@ public async Task GetIfExists_GetAEnvironmentsStoragePropertiesBySubscription() // invoke the operation string storageName = "jlaw-demo1"; - NullableResponse response = await collection.GetIfExistsAsync(storageName); - ContainerAppManagedEnvironmentStorageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(storageName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppManagedEnvironmentStorageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateEnvironmentsStorage() + public async Task GetIfExists_GetAEnvironmentsStoragePropertiesBySubscription() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_CreateOrUpdate.json - // this example is just showing the usage of "ManagedEnvironmentsStorages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_Get.json + // this example is just showing the usage of "ManagedEnvironmentsStorages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,24 +186,21 @@ public async Task CreateOrUpdate_CreateOrUpdateEnvironmentsStorage() // invoke the operation string storageName = "jlaw-demo1"; - ContainerAppManagedEnvironmentStorageData data = new ContainerAppManagedEnvironmentStorageData() - { - ManagedEnvironmentStorageAzureFile = new ContainerAppAzureFileProperties() - { - AccountName = "account1", - AccountKey = "key", - AccessMode = ContainerAppAccessMode.ReadOnly, - ShareName = "share1", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageName, data); - ContainerAppManagedEnvironmentStorageResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(storageName); + ContainerAppManagedEnvironmentStorageResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppManagedEnvironmentStorageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppManagedEnvironmentStorageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentStorageResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentStorageResource.cs index 177ba174eef0e..a4a23893801bc 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentStorageResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppManagedEnvironmentStorageResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAEnvironmentsStoragePropertiesBySubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateEnvironmentsStorage() + public async Task Delete_ListEnvironmentsStoragesBySubscription() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_CreateOrUpdate.json - // this example is just showing the usage of "ManagedEnvironmentsStorages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_Delete.json + // this example is just showing the usage of "ManagedEnvironmentsStorages_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,32 +69,17 @@ public async Task Update_CreateOrUpdateEnvironmentsStorage() ContainerAppManagedEnvironmentStorageResource containerAppManagedEnvironmentStorage = client.GetContainerAppManagedEnvironmentStorageResource(containerAppManagedEnvironmentStorageResourceId); // invoke the operation - ContainerAppManagedEnvironmentStorageData data = new ContainerAppManagedEnvironmentStorageData() - { - ManagedEnvironmentStorageAzureFile = new ContainerAppAzureFileProperties() - { - AccountName = "account1", - AccountKey = "key", - AccessMode = ContainerAppAccessMode.ReadOnly, - ShareName = "share1", - }, - }; - ArmOperation lro = await containerAppManagedEnvironmentStorage.UpdateAsync(WaitUntil.Completed, data); - ContainerAppManagedEnvironmentStorageResource result = lro.Value; + await containerAppManagedEnvironmentStorage.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppManagedEnvironmentStorageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ListEnvironmentsStoragesBySubscription() + public async Task Update_CreateOrUpdateEnvironmentsStorage() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_Delete.json - // this example is just showing the usage of "ManagedEnvironmentsStorages_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironmentsStorages_CreateOrUpdate.json + // this example is just showing the usage of "ManagedEnvironmentsStorages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +96,24 @@ public async Task Delete_ListEnvironmentsStoragesBySubscription() ContainerAppManagedEnvironmentStorageResource containerAppManagedEnvironmentStorage = client.GetContainerAppManagedEnvironmentStorageResource(containerAppManagedEnvironmentStorageResourceId); // invoke the operation - await containerAppManagedEnvironmentStorage.DeleteAsync(WaitUntil.Completed); + ContainerAppManagedEnvironmentStorageData data = new ContainerAppManagedEnvironmentStorageData + { + ManagedEnvironmentStorageAzureFile = new ContainerAppAzureFileProperties + { + AccountName = "account1", + AccountKey = "key", + AccessMode = ContainerAppAccessMode.ReadOnly, + ShareName = "share1", + }, + }; + ArmOperation lro = await containerAppManagedEnvironmentStorage.UpdateAsync(WaitUntil.Completed, data); + ContainerAppManagedEnvironmentStorageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppManagedEnvironmentStorageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppReplicaCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppReplicaCollection.cs index 43d60f560a5b5..e0ea027d89e08 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppReplicaCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppReplicaCollection.cs @@ -52,10 +52,10 @@ public async Task Get_GetContainerAppSRevisionReplica() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetContainerAppSRevisionReplica() + public async Task GetAll_ListContainerAppSReplicas() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Replicas_Get.json - // this example is just showing the usage of "ContainerAppsRevisionReplicas_GetReplica" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Replicas_List.json + // this example is just showing the usage of "ContainerAppsRevisionReplicas_ListReplicas" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,16 +74,22 @@ public async Task Exists_GetContainerAppSRevisionReplica() // get the collection of this ContainerAppReplicaResource ContainerAppReplicaCollection collection = containerAppRevision.GetContainerAppReplicas(); - // invoke the operation - string replicaName = "myapp--0wlqy09-5d9774cff-5wnd8"; - bool result = await collection.ExistsAsync(replicaName); + // invoke the operation and iterate over the result + await foreach (ContainerAppReplicaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppReplicaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetContainerAppSRevisionReplica() + public async Task Exists_GetContainerAppSRevisionReplica() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Replicas_Get.json // this example is just showing the usage of "ContainerAppsRevisionReplicas_GetReplica" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +113,17 @@ public async Task GetIfExists_GetContainerAppSRevisionReplica() // invoke the operation string replicaName = "myapp--0wlqy09-5d9774cff-5wnd8"; - NullableResponse response = await collection.GetIfExistsAsync(replicaName); - ContainerAppReplicaResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(replicaName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppReplicaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListContainerAppSReplicas() + public async Task GetIfExists_GetContainerAppSRevisionReplica() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Replicas_List.json - // this example is just showing the usage of "ContainerAppsRevisionReplicas_ListReplicas" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Replicas_Get.json + // this example is just showing the usage of "ContainerAppsRevisionReplicas_GetReplica" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,17 +142,23 @@ public async Task GetAll_ListContainerAppSReplicas() // get the collection of this ContainerAppReplicaResource ContainerAppReplicaCollection collection = containerAppRevision.GetContainerAppReplicas(); - // invoke the operation and iterate over the result - await foreach (ContainerAppReplicaResource item in collection.GetAllAsync()) + // invoke the operation + string replicaName = "myapp--0wlqy09-5d9774cff-5wnd8"; + NullableResponse response = await collection.GetIfExistsAsync(replicaName); + ContainerAppReplicaResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerAppReplicaData resourceData = item.Data; + ContainerAppReplicaData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppResource.cs index d194777ea7f61..5ec5043c92f6c 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppContainers.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppContainers.Samples { public partial class Sample_ContainerAppResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetContainerApps_ListContainerAppsBySubscription() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerApps_ListBySubscription.json - // this example is just showing the usage of "ContainerApps_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ContainerAppResource item in subscriptionResource.GetContainerAppsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetContainerApp() @@ -127,46 +95,37 @@ public async Task Update_PatchContainerApp() // invoke the operation ContainerAppData data = new ContainerAppData(new AzureLocation("East US")) { - Configuration = new ContainerAppConfiguration() + Configuration = new ContainerAppConfiguration { - Ingress = new ContainerAppIngressConfiguration() + Ingress = new ContainerAppIngressConfiguration { External = true, TargetPort = 3000, - Traffic = -{ -new ContainerAppRevisionTrafficWeight() + Traffic = {new ContainerAppRevisionTrafficWeight { RevisionName = "testcontainerapp0-ab1234", Weight = 100, Label = "production", -} -}, - CustomDomains = -{ -new ContainerAppCustomDomain("www.my-name.com") +}}, + CustomDomains = {new ContainerAppCustomDomain("www.my-name.com") { BindingType = ContainerAppCustomDomainBindingType.SniEnabled, CertificateId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube/certificates/my-certificate-for-my-name-dot-com"), -},new ContainerAppCustomDomain("www.my-other-name.com") +}, new ContainerAppCustomDomain("www.my-other-name.com") { BindingType = ContainerAppCustomDomainBindingType.SniEnabled, CertificateId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/managedEnvironments/demokube/certificates/my-certificate-for-my-other-name-dot-com"), -} -}, - IPSecurityRestrictions = -{ -new ContainerAppIPSecurityRestrictionRule("Allow work IP A subnet","192.168.1.1/32",ContainerAppIPRuleAction.Allow) +}}, + IPSecurityRestrictions = {new ContainerAppIPSecurityRestrictionRule("Allow work IP A subnet", "192.168.1.1/32", ContainerAppIPRuleAction.Allow) { Description = "Allowing all IP's within the subnet below to access containerapp", -},new ContainerAppIPSecurityRestrictionRule("Allow work IP B subnet","192.168.1.1/8",ContainerAppIPRuleAction.Allow) +}, new ContainerAppIPSecurityRestrictionRule("Allow work IP B subnet", "192.168.1.1/8", ContainerAppIPRuleAction.Allow) { Description = "Allowing all IP's within the subnet below to access containerapp", -} -}, +}}, StickySessionsAffinity = Affinity.Sticky, }, - Dapr = new ContainerAppDaprConfiguration() + Dapr = new ContainerAppDaprConfiguration { IsEnabled = true, AppProtocol = ContainerAppProtocol.Http, @@ -179,79 +138,61 @@ public async Task Update_PatchContainerApp() MaxInactiveRevisions = 10, ServiceType = "redis", }, - Template = new ContainerAppTemplate() + Template = new ContainerAppTemplate { - InitContainers = -{ -new ContainerAppInitContainer() + InitContainers = {new ContainerAppInitContainer { Image = "repo/testcontainerapp0:v4", Name = "testinitcontainerApp0", -Resources = new AppContainerResources() +Resources = new AppContainerResources { Cpu = 0.5, Memory = "1Gi", }, -} -}, - Containers = -{ -new ContainerAppContainer() +}}, + Containers = {new ContainerAppContainer { -Probes = -{ -new ContainerAppProbe() +Probes = {new ContainerAppProbe { HttpGet = new ContainerAppHttpRequestInfo(8080) { -HttpHeaders = -{ -new ContainerAppHttpHeaderInfo("Custom-Header","Awesome") -}, +HttpHeaders = {new ContainerAppHttpHeaderInfo("Custom-Header", "Awesome")}, Path = "/health", }, InitialDelaySeconds = 3, PeriodSeconds = 3, ProbeType = ContainerAppProbeType.Liveness, -} -}, +}}, Image = "repo/testcontainerapp0:v1", Name = "testcontainerapp0", -} -}, - Scale = new ContainerAppScale() +}}, + Scale = new ContainerAppScale { MinReplicas = 1, MaxReplicas = 5, - Rules = -{ -new ContainerAppScaleRule() + Rules = {new ContainerAppScaleRule { Name = "httpscalingrule", -Custom = new ContainerAppCustomScaleRule() +Custom = new ContainerAppCustomScaleRule { CustomScaleRuleType = "http", Metadata = { -["concurrentRequests"] = "50", +["concurrentRequests"] = "50" }, }, -} -}, +}}, }, - ServiceBinds = -{ -new ContainerAppServiceBind() + ServiceBinds = {new ContainerAppServiceBind { ServiceId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/rg/providers/Microsoft.App/containerApps/service"), Name = "service", -} -}, +}}, }, Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await containerApp.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppRevisionCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppRevisionCollection.cs index 3a3ef23c79818..ee9ea86c8f0ad 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppRevisionCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppRevisionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerAppRevisionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListContainerAppSRevisions() + public async Task Get_GetContainerAppSRevision() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Revisions_List.json - // this example is just showing the usage of "ContainerAppsRevisions_ListRevisions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Revisions_Get.json + // this example is just showing the usage of "ContainerAppsRevisions_GetRevision" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListContainerAppSRevisions() // get the collection of this ContainerAppRevisionResource ContainerAppRevisionCollection collection = containerApp.GetContainerAppRevisions(); - // invoke the operation and iterate over the result - await foreach (ContainerAppRevisionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppRevisionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string revisionName = "testcontainerApp0-pjxhsye"; + ContainerAppRevisionResource result = await collection.GetAsync(revisionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppRevisionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetContainerAppSRevision() + public async Task GetAll_ListContainerAppSRevisions() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Revisions_Get.json - // this example is just showing the usage of "ContainerAppsRevisions_GetRevision" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Revisions_List.json + // this example is just showing the usage of "ContainerAppsRevisions_ListRevisions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetContainerAppSRevision() // get the collection of this ContainerAppRevisionResource ContainerAppRevisionCollection collection = containerApp.GetContainerAppRevisions(); - // invoke the operation - string revisionName = "testcontainerApp0-pjxhsye"; - ContainerAppRevisionResource result = await collection.GetAsync(revisionName); + // invoke the operation and iterate over the result + await foreach (ContainerAppRevisionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppRevisionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppRevisionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppSourceControlCollection.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppSourceControlCollection.cs index 91f7a63e344bb..23c45034764c1 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppSourceControlCollection.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppSourceControlCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerAppSourceControlCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAppSSourceControls() + public async Task CreateOrUpdate_CreateOrUpdateContainerAppSourceControl() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/SourceControls_ListByContainer.json - // this example is just showing the usage of "ContainerAppsSourceControls_ListByContainerApp" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/SourceControls_CreateOrUpdate.json + // this example is just showing the usage of "ContainerAppsSourceControls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,40 @@ public async Task GetAll_ListAppSSourceControls() // get the collection of this ContainerAppSourceControlResource ContainerAppSourceControlCollection collection = containerApp.GetContainerAppSourceControls(); - // invoke the operation and iterate over the result - await foreach (ContainerAppSourceControlResource item in collection.GetAllAsync()) + // invoke the operation + string sourceControlName = "current"; + ContainerAppSourceControlData data = new ContainerAppSourceControlData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppSourceControlData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + RepoUri = new Uri("https://github.com/xwang971/ghatest"), + Branch = "master", + GitHubActionConfiguration = new ContainerAppGitHubActionConfiguration + { + RegistryInfo = new ContainerAppRegistryInfo + { + RegistryServer = "test-registry.azurecr.io", + RegistryUserName = "test-registry", + RegistryPassword = "", + }, + AzureCredentials = new ContainerAppCredentials + { + ClientId = "", + ClientSecret = "", + TenantId = Guid.Parse(""), + Kind = "feaderated", + }, + ContextPath = "./", + GitHubPersonalAccessToken = "test", + Image = "image/tag", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sourceControlName, data); + ContainerAppSourceControlResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppSourceControlData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +111,10 @@ public async Task Get_GetContainerAppSSourceControl() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetContainerAppSSourceControl() + public async Task GetAll_ListAppSSourceControls() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/SourceControls_Get.json - // this example is just showing the usage of "ContainerAppsSourceControls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/SourceControls_ListByContainer.json + // this example is just showing the usage of "ContainerAppsSourceControls_ListByContainerApp" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +132,22 @@ public async Task Exists_GetContainerAppSSourceControl() // get the collection of this ContainerAppSourceControlResource ContainerAppSourceControlCollection collection = containerApp.GetContainerAppSourceControls(); - // invoke the operation - string sourceControlName = "current"; - bool result = await collection.ExistsAsync(sourceControlName); + // invoke the operation and iterate over the result + await foreach (ContainerAppSourceControlResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppSourceControlData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetContainerAppSSourceControl() + public async Task Exists_GetContainerAppSSourceControl() { // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/SourceControls_Get.json // this example is just showing the usage of "ContainerAppsSourceControls_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +170,17 @@ public async Task GetIfExists_GetContainerAppSSourceControl() // invoke the operation string sourceControlName = "current"; - NullableResponse response = await collection.GetIfExistsAsync(sourceControlName); - ContainerAppSourceControlResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sourceControlName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppSourceControlData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateContainerAppSourceControl() + public async Task GetIfExists_GetContainerAppSSourceControl() { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/SourceControls_CreateOrUpdate.json - // this example is just showing the usage of "ContainerAppsSourceControls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/SourceControls_Get.json + // this example is just showing the usage of "ContainerAppsSourceControls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,38 +200,21 @@ public async Task CreateOrUpdate_CreateOrUpdateContainerAppSourceControl() // invoke the operation string sourceControlName = "current"; - ContainerAppSourceControlData data = new ContainerAppSourceControlData() - { - RepoUri = new Uri("https://github.com/xwang971/ghatest"), - Branch = "master", - GitHubActionConfiguration = new ContainerAppGitHubActionConfiguration() - { - RegistryInfo = new ContainerAppRegistryInfo() - { - RegistryServer = "test-registry.azurecr.io", - RegistryUserName = "test-registry", - RegistryPassword = "", - }, - AzureCredentials = new ContainerAppCredentials() - { - ClientId = "", - ClientSecret = "", - TenantId = Guid.Parse(""), - Kind = "feaderated", - }, - ContextPath = "./", - GitHubPersonalAccessToken = "test", - Image = "image/tag", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sourceControlName, data); - ContainerAppSourceControlResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(sourceControlName); + ContainerAppSourceControlResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerAppSourceControlData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppSourceControlData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppSourceControlResource.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppSourceControlResource.cs index df335e8997a14..12226c226e699 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppSourceControlResource.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_ContainerAppSourceControlResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetContainerAppSSourceControl() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteContainerAppSourceControl() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/SourceControls_Delete.json + // this example is just showing the usage of "ContainerAppsSourceControls_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerAppSourceControlResource created on azure + // for more information of creating ContainerAppSourceControlResource, please refer to the document of ContainerAppSourceControlResource + string subscriptionId = "651f8027-33e8-4ec4-97b4-f6e9f3dc8744"; + string resourceGroupName = "workerapps-rg-xj"; + string containerAppName = "testcanadacentral"; + string sourceControlName = "current"; + ResourceIdentifier containerAppSourceControlResourceId = ContainerAppSourceControlResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, containerAppName, sourceControlName); + ContainerAppSourceControlResource containerAppSourceControl = client.GetContainerAppSourceControlResource(containerAppSourceControlResourceId); + + // invoke the operation + await containerAppSourceControl.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateContainerAppSourceControl() @@ -69,19 +96,19 @@ public async Task Update_CreateOrUpdateContainerAppSourceControl() ContainerAppSourceControlResource containerAppSourceControl = client.GetContainerAppSourceControlResource(containerAppSourceControlResourceId); // invoke the operation - ContainerAppSourceControlData data = new ContainerAppSourceControlData() + ContainerAppSourceControlData data = new ContainerAppSourceControlData { RepoUri = new Uri("https://github.com/xwang971/ghatest"), Branch = "master", - GitHubActionConfiguration = new ContainerAppGitHubActionConfiguration() + GitHubActionConfiguration = new ContainerAppGitHubActionConfiguration { - RegistryInfo = new ContainerAppRegistryInfo() + RegistryInfo = new ContainerAppRegistryInfo { RegistryServer = "test-registry.azurecr.io", RegistryUserName = "test-registry", RegistryPassword = "", }, - AzureCredentials = new ContainerAppCredentials() + AzureCredentials = new ContainerAppCredentials { ClientId = "", ClientSecret = "", @@ -102,32 +129,5 @@ public async Task Update_CreateOrUpdateContainerAppSourceControl() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteContainerAppSourceControl() - { - // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/SourceControls_Delete.json - // this example is just showing the usage of "ContainerAppsSourceControls_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerAppSourceControlResource created on azure - // for more information of creating ContainerAppSourceControlResource, please refer to the document of ContainerAppSourceControlResource - string subscriptionId = "651f8027-33e8-4ec4-97b4-f6e9f3dc8744"; - string resourceGroupName = "workerapps-rg-xj"; - string containerAppName = "testcanadacentral"; - string sourceControlName = "current"; - ResourceIdentifier containerAppSourceControlResourceId = ContainerAppSourceControlResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, containerAppName, sourceControlName); - ContainerAppSourceControlResource containerAppSourceControl = client.GetContainerAppSourceControlResource(containerAppSourceControlResourceId); - - // invoke the operation - await containerAppSourceControl.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 953e0a8072647..638ad4cbef844 100644 --- a/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/containerapps/Azure.ResourceManager.AppContainers/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -73,6 +73,154 @@ public async Task GetBillingMeters_BillingMetersGet() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetContainerAppConnectedEnvironments_ListConnectedEnvironmentsBySubscription() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ConnectedEnvironments_ListBySubscription.json + // this example is just showing the usage of "ConnectedEnvironments_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerAppConnectedEnvironmentResource item in subscriptionResource.GetContainerAppConnectedEnvironmentsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppConnectedEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetContainerApps_ListContainerAppsBySubscription() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ContainerApps_ListBySubscription.json + // this example is just showing the usage of "ContainerApps_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerAppResource item in subscriptionResource.GetContainerAppsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetContainerAppJobs_ListContainerAppsJobsBySubscription() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Jobs_ListBySubscription.json + // this example is just showing the usage of "Jobs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerAppJobResource item in subscriptionResource.GetContainerAppJobsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCustomDomainVerificationId_ListAllOperations() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/Subscriptions_GetCustomDomainVerificationId.json + // this example is just showing the usage of "GetCustomDomainVerificationId" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "d27c3573-f76e-4b26-b871-0ccd2203d08c"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + string result = await subscriptionResource.GetCustomDomainVerificationIdAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetContainerAppManagedEnvironments_ListEnvironmentsBySubscription() + { + // Generated from example definition: specification/app/resource-manager/Microsoft.App/stable/2024-03-01/examples/ManagedEnvironments_ListBySubscription.json + // this example is just showing the usage of "ManagedEnvironments_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "8efdecc5-919e-44eb-b179-915dca89ebf9"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerAppManagedEnvironmentResource item in subscriptionResource.GetContainerAppManagedEnvironmentsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerAppManagedEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetUsages_ListUsages() diff --git a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupCollection.cs b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupCollection.cs index 1acfbb2baa828..4d52bddad01f4 100644 --- a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupCollection.cs +++ b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -21,10 +20,10 @@ public partial class Sample_ContainerGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ContainerGroupsListByResourceGroup() + public async Task CreateOrUpdate_ConfidentialContainerGroup() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsListByResourceGroup.json - // this example is just showing the usage of "ContainerGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupCreateConfidential.json + // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +40,56 @@ public async Task GetAll_ContainerGroupsListByResourceGroup() // get the collection of this ContainerGroupResource ContainerGroupCollection collection = resourceGroupResource.GetContainerGroups(); - // invoke the operation and iterate over the result - await foreach (ContainerGroupResource item in collection.GetAllAsync()) + // invoke the operation + string containerGroupName = "demo1"; + ContainerGroupData data = new ContainerGroupData(new AzureLocation("westeurope"), new ContainerInstanceContainer[] { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } +new ContainerInstanceContainer("accdemo") +{ +Image = "confiimage", +Command = {}, +Ports = {new ContainerPort(8000)}, +EnvironmentVariables = {}, +Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5, 1)), +SecurityContext = new ContainerSecurityContextDefinition +{ +IsPrivileged = false, +Capabilities = new ContainerSecurityContextCapabilitiesDefinition +{ +Add = {"CAP_NET_ADMIN"}, +}, +}, +} + }) + { + ImageRegistryCredentials = { }, + IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + { +new ContainerGroupPort(8000) +{ +Protocol = ContainerGroupNetworkProtocol.Tcp, +} + }, ContainerGroupIPAddressType.Public), + ContainerGroupOSType = ContainerInstanceOperatingSystemType.Linux, + Sku = ContainerGroupSku.Confidential, + ConfidentialComputeCcePolicy = "eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); + ContainerGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ContainerGroupsGetWithPriority() + public async Task CreateOrUpdate_ContainerGroupCreateOrUpdateWithStandbyPool() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGetPriority.json - // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupCreateOrUpdateStandbyPool.json + // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,7 +108,29 @@ public async Task Get_ContainerGroupsGetWithPriority() // invoke the operation string containerGroupName = "demo1"; - ContainerGroupResource result = await collection.GetAsync(containerGroupName); + ContainerGroupData data = new ContainerGroupData(new AzureLocation("west us"), new ContainerInstanceContainer[] + { +new ContainerInstanceContainer("demo1") +{ +ConfigMapKeyValuePairs = +{ +["Newkey"] = "value" +}, +} + }) + { + ContainerGroupProfile = new ContainerGroupProfileReferenceDefinition + { + Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp"), + Revision = 1, + }, + StandbyPoolProfile = new StandbyPoolProfileDefinition + { + Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.StandbyPool/standbyContainerGroupPools/demopool"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); + ContainerGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +141,10 @@ public async Task Get_ContainerGroupsGetWithPriority() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ContainerGroupsGetWithPriority() + public async Task CreateOrUpdate_ContainerGroupCreateWithExtensions() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGetPriority.json - // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupExtensions.json + // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,17 +163,63 @@ public async Task Exists_ContainerGroupsGetWithPriority() // invoke the operation string containerGroupName = "demo1"; - bool result = await collection.ExistsAsync(containerGroupName); + ContainerGroupData data = new ContainerGroupData(new AzureLocation("eastus2"), new ContainerInstanceContainer[] + { +new ContainerInstanceContainer("demo1") +{ +Image = "nginx", +Command = {}, +Ports = {new ContainerPort(80)}, +EnvironmentVariables = {}, +Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5, 1)), +} + }) + { + ImageRegistryCredentials = { }, + IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + { +new ContainerGroupPort(80) +{ +Protocol = ContainerGroupNetworkProtocol.Tcp, +} + }, ContainerGroupIPAddressType.Private), + ContainerGroupOSType = ContainerInstanceOperatingSystemType.Linux, + SubnetIds = { new ContainerGroupSubnetId(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-rg-vnet/subnets/test-subnet")) }, + Extensions = {new DeploymentExtensionSpec("kube-proxy") +{ +ExtensionType = "kube-proxy", +Version = "1.0", +Settings = BinaryData.FromObjectAsJson(new +{ +clusterCidr = "10.240.0.0/16", +kubeVersion = "v1.9.10", +}), +ProtectedSettings = BinaryData.FromObjectAsJson(new +{ +kubeConfig = "", +}), +}, new DeploymentExtensionSpec("vk-realtime-metrics") +{ +ExtensionType = "realtime-metrics", +Version = "1.0", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); + ContainerGroupResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ContainerGroupsGetWithPriority() + public async Task CreateOrUpdate_ContainerGroupWithEncryptionProperties() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGetPriority.json - // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupEncryptionProperties.json + // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,29 +238,55 @@ public async Task GetIfExists_ContainerGroupsGetWithPriority() // invoke the operation string containerGroupName = "demo1"; - NullableResponse response = await collection.GetIfExistsAsync(containerGroupName); - ContainerGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) + ContainerGroupData data = new ContainerGroupData(new AzureLocation("eastus2"), new ContainerInstanceContainer[] { - Console.WriteLine("Succeeded with null as result"); - } - else +new ContainerInstanceContainer("demo1") +{ +Image = "nginx", +Command = {}, +Ports = {new ContainerPort(80)}, +EnvironmentVariables = {}, +Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5, 1)), +} + }) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity")] = new UserAssignedIdentity() +}, + }, + ImageRegistryCredentials = { }, + IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + { +new ContainerGroupPort(80) +{ +Protocol = ContainerGroupNetworkProtocol.Tcp, +} + }, ContainerGroupIPAddressType.Public), + ContainerGroupOSType = ContainerInstanceOperatingSystemType.Linux, + EncryptionProperties = new ContainerGroupEncryptionProperties(new Uri("https://testkeyvault.vault.azure.net"), "test-key", "") + { + Identity = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); + ContainerGroupResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ContainerGroupsGetFailed() + public async Task CreateOrUpdate_ContainerGroupsCreateOrUpdate() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Failed.json - // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsCreateOrUpdate.json + // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,7 +305,86 @@ public async Task Get_ContainerGroupsGetFailed() // invoke the operation string containerGroupName = "demo1"; - ContainerGroupResource result = await collection.GetAsync(containerGroupName); + ContainerGroupData data = new ContainerGroupData(new AzureLocation("west us"), new ContainerInstanceContainer[] + { +new ContainerInstanceContainer("demo1") +{ +Image = "nginx", +Command = {}, +Ports = {new ContainerPort(80)}, +EnvironmentVariables = {}, +Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5, 1) +{ +Gpu = new ContainerGpuResourceInfo(1, ContainerGpuSku.K80), +}), +VolumeMounts = {new ContainerVolumeMount("volume1", "/mnt/volume1") +{ +IsReadOnly = false, +}, new ContainerVolumeMount("volume2", "/mnt/volume2") +{ +IsReadOnly = false, +}, new ContainerVolumeMount("volume3", "/mnt/volume3") +{ +IsReadOnly = true, +}}, +} + }) + { + Identity = new ManagedServiceIdentity("SystemAssigned, UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name")] = new UserAssignedIdentity() +}, + }, + ImageRegistryCredentials = { }, + IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + { +new ContainerGroupPort(80) +{ +Protocol = ContainerGroupNetworkProtocol.Tcp, +} + }, ContainerGroupIPAddressType.Public) + { + DnsNameLabel = "dnsnamelabel1", + AutoGeneratedDomainNameLabelScope = DnsNameLabelReusePolicy.Unsecure, + }, + ContainerGroupOSType = ContainerInstanceOperatingSystemType.Linux, + Volumes = {new ContainerVolume("volume1") +{ +AzureFile = new ContainerInstanceAzureFileVolume("shareName", "accountName") +{ +StorageAccountKey = "accountKey", +}, +}, new ContainerVolume("volume2") +{ +EmptyDir = BinaryData.FromObjectAsJson(new object()), +}, new ContainerVolume("volume3") +{ +Secret = +{ +["secretKey1"] = "SecretValue1InBase64", +["secretKey2"] = "SecretValue2InBase64" +}, +}}, + DiagnosticsLogAnalytics = new ContainerGroupLogAnalytics("workspaceid", "workspaceKey") + { + LogType = ContainerGroupLogAnalyticsLogType.ContainerInsights, + Metadata = +{ +["test-key"] = "test-metadata-value" +}, + WorkspaceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace"), + }, + SubnetIds = { new ContainerGroupSubnetId(new ResourceIdentifier("[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]")) }, + DnsConfig = new ContainerGroupDnsConfiguration(new string[] { "1.1.1.1" }) + { + SearchDomains = "cluster.local svc.cluster.local", + Options = "ndots:2", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); + ContainerGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -192,10 +395,10 @@ public async Task Get_ContainerGroupsGetFailed() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ContainerGroupsGetFailed() + public async Task CreateOrUpdate_ContainerGroupsCreateWithPriority() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Failed.json - // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsCreatePriority.json + // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -214,16 +417,36 @@ public async Task Exists_ContainerGroupsGetFailed() // invoke the operation string containerGroupName = "demo1"; - bool result = await collection.ExistsAsync(containerGroupName); + ContainerGroupData data = new ContainerGroupData(new AzureLocation("eastus"), new ContainerInstanceContainer[] + { +new ContainerInstanceContainer("test-container-001") +{ +Image = "alpine:latest", +Command = {"/bin/sh", "-c", "sleep 10"}, +Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1, 1)), +} + }) + { + RestartPolicy = ContainerGroupRestartPolicy.Never, + ContainerGroupOSType = ContainerInstanceOperatingSystemType.Linux, + Sku = ContainerGroupSku.Standard, + Priority = ContainerGroupPriority.Spot, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); + ContainerGroupResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ContainerGroupsGetFailed() + public async Task Get_ContainerGroupsGetWithPriority() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Failed.json + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGetPriority.json // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -243,28 +466,20 @@ public async Task GetIfExists_ContainerGroupsGetFailed() // invoke the operation string containerGroupName = "demo1"; - NullableResponse response = await collection.GetIfExistsAsync(containerGroupName); - ContainerGroupResource result = response.HasValue ? response.Value : null; + ContainerGroupResource result = await collection.GetAsync(containerGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ContainerGroupsGetSucceeded() + public async Task Get_ContainerGroupsGetFailed() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Succeeded.json + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Failed.json // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -295,7 +510,7 @@ public async Task Get_ContainerGroupsGetSucceeded() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ContainerGroupsGetSucceeded() + public async Task Get_ContainerGroupsGetSucceeded() { // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Succeeded.json // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -317,17 +532,21 @@ public async Task Exists_ContainerGroupsGetSucceeded() // invoke the operation string containerGroupName = "demo1"; - bool result = await collection.ExistsAsync(containerGroupName); + ContainerGroupResource result = await collection.GetAsync(containerGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ContainerGroupsGetSucceeded() + public async Task GetAll_ContainerGroupsListByResourceGroup() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Succeeded.json - // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsListByResourceGroup.json + // this example is just showing the usage of "ContainerGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -344,31 +563,25 @@ public async Task GetIfExists_ContainerGroupsGetSucceeded() // get the collection of this ContainerGroupResource ContainerGroupCollection collection = resourceGroupResource.GetContainerGroups(); - // invoke the operation - string containerGroupName = "demo1"; - NullableResponse response = await collection.GetIfExistsAsync(containerGroupName); - ContainerGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ContainerGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = result.Data; + ContainerGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConfidentialContainerGroup() + public async Task Exists_ContainerGroupsGetWithPriority() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupCreateConfidential.json - // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGetPriority.json + // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -387,66 +600,17 @@ public async Task CreateOrUpdate_ConfidentialContainerGroup() // invoke the operation string containerGroupName = "demo1"; - ContainerGroupData data = new ContainerGroupData(new AzureLocation("westeurope"), new ContainerInstanceContainer[] - { -new ContainerInstanceContainer("accdemo") -{ -Image = "confiimage", -Command = -{ -}, -Ports = -{ -new ContainerPort(8000) -}, -EnvironmentVariables = -{ -}, -Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5,1)), -SecurityContext = new ContainerSecurityContextDefinition() -{ -IsPrivileged = false, -Capabilities = new ContainerSecurityContextCapabilitiesDefinition() -{ -Add = -{ -"CAP_NET_ADMIN" -}, -}, -}, -} - }) - { - ImageRegistryCredentials = -{ -}, - IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] - { -new ContainerGroupPort(8000) -{ -Protocol = ContainerGroupNetworkProtocol.Tcp, -} - }, ContainerGroupIPAddressType.Public), - ContainerGroupOSType = ContainerInstanceOperatingSystemType.Linux, - Sku = ContainerGroupSku.Confidential, - ConfidentialComputeCcePolicy = "eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); - ContainerGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(containerGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ContainerGroupCreateOrUpdateWithStandbyPool() + public async Task Exists_ContainerGroupsGetFailed() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupCreateOrUpdateStandbyPool.json - // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Failed.json + // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -465,43 +629,17 @@ public async Task CreateOrUpdate_ContainerGroupCreateOrUpdateWithStandbyPool() // invoke the operation string containerGroupName = "demo1"; - ContainerGroupData data = new ContainerGroupData(new AzureLocation("west us"), new ContainerInstanceContainer[] - { -new ContainerInstanceContainer("demo1") -{ -ConfigMapKeyValuePairs = -{ -["Newkey"] = "value", -}, -} - }) - { - ContainerGroupProfile = new ContainerGroupProfileReferenceDefinition() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.ContainerInstance/containerGroupProfiles/democgp"), - Revision = 1, - }, - StandbyPoolProfile = new StandbyPoolProfileDefinition() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/demo/providers/Microsoft.StandbyPool/standbyContainerGroupPools/demopool"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); - ContainerGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(containerGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ContainerGroupCreateWithExtensions() + public async Task Exists_ContainerGroupsGetSucceeded() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupExtensions.json - // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Succeeded.json + // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -520,76 +658,17 @@ public async Task CreateOrUpdate_ContainerGroupCreateWithExtensions() // invoke the operation string containerGroupName = "demo1"; - ContainerGroupData data = new ContainerGroupData(new AzureLocation("eastus2"), new ContainerInstanceContainer[] - { -new ContainerInstanceContainer("demo1") -{ -Image = "nginx", -Command = -{ -}, -Ports = -{ -new ContainerPort(80) -}, -EnvironmentVariables = -{ -}, -Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5,1)), -} - }) - { - ImageRegistryCredentials = -{ -}, - IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] - { -new ContainerGroupPort(80) -{ -Protocol = ContainerGroupNetworkProtocol.Tcp, -} - }, ContainerGroupIPAddressType.Private), - ContainerGroupOSType = ContainerInstanceOperatingSystemType.Linux, - SubnetIds = -{ -new ContainerGroupSubnetId(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/test-rg/providers/Microsoft.Network/virtualNetworks/test-rg-vnet/subnets/test-subnet")) -}, - Extensions = -{ -new DeploymentExtensionSpec("kube-proxy") -{ -ExtensionType = "kube-proxy", -Version = "1.0", -Settings = BinaryData.FromObjectAsJson(new Dictionary() -{ -["clusterCidr"] = "10.240.0.0/16", -["kubeVersion"] = "v1.9.10"}), -ProtectedSettings = BinaryData.FromObjectAsJson(new Dictionary() -{ -["kubeConfig"] = ""}), -},new DeploymentExtensionSpec("vk-realtime-metrics") -{ -ExtensionType = "realtime-metrics", -Version = "1.0", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); - ContainerGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(containerGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ContainerGroupWithEncryptionProperties() + public async Task GetIfExists_ContainerGroupsGetWithPriority() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupEncryptionProperties.json - // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGetPriority.json + // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -608,64 +687,29 @@ public async Task CreateOrUpdate_ContainerGroupWithEncryptionProperties() // invoke the operation string containerGroupName = "demo1"; - ContainerGroupData data = new ContainerGroupData(new AzureLocation("eastus2"), new ContainerInstanceContainer[] - { -new ContainerInstanceContainer("demo1") -{ -Image = "nginx", -Command = -{ -}, -Ports = -{ -new ContainerPort(80) -}, -EnvironmentVariables = -{ -}, -Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5,1)), -} - }) + NullableResponse response = await collection.GetIfExistsAsync(containerGroupName); + ContainerGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity")] = new UserAssignedIdentity(), -}, - }, - ImageRegistryCredentials = -{ -}, - IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + Console.WriteLine("Succeeded with null as result"); + } + else { -new ContainerGroupPort(80) -{ -Protocol = ContainerGroupNetworkProtocol.Tcp, -} - }, ContainerGroupIPAddressType.Public), - ContainerGroupOSType = ContainerInstanceOperatingSystemType.Linux, - EncryptionProperties = new ContainerGroupEncryptionProperties(new Uri("https://testkeyvault.vault.azure.net"), "test-key", "") - { - Identity = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); - ContainerGroupResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ContainerGroupsCreateOrUpdate() + public async Task GetIfExists_ContainerGroupsGetFailed() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsCreateOrUpdate.json - // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Failed.json + // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -684,123 +728,29 @@ public async Task CreateOrUpdate_ContainerGroupsCreateOrUpdate() // invoke the operation string containerGroupName = "demo1"; - ContainerGroupData data = new ContainerGroupData(new AzureLocation("west us"), new ContainerInstanceContainer[] - { -new ContainerInstanceContainer("demo1") -{ -Image = "nginx", -Command = -{ -}, -Ports = -{ -new ContainerPort(80) -}, -EnvironmentVariables = -{ -}, -Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5,1) -{ -Gpu = new ContainerGpuResourceInfo(1,ContainerGpuSku.K80), -}), -VolumeMounts = -{ -new ContainerVolumeMount("volume1","/mnt/volume1") -{ -IsReadOnly = false, -},new ContainerVolumeMount("volume2","/mnt/volume2") -{ -IsReadOnly = false, -},new ContainerVolumeMount("volume3","/mnt/volume3") -{ -IsReadOnly = true, -} -}, -} - }) - { - Identity = new ManagedServiceIdentity("SystemAssigned, UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity-name")] = new UserAssignedIdentity(), -}, - }, - ImageRegistryCredentials = -{ -}, - IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + NullableResponse response = await collection.GetIfExistsAsync(containerGroupName); + ContainerGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new ContainerGroupPort(80) -{ -Protocol = ContainerGroupNetworkProtocol.Tcp, -} - }, ContainerGroupIPAddressType.Public) - { - DnsNameLabel = "dnsnamelabel1", - AutoGeneratedDomainNameLabelScope = DnsNameLabelReusePolicy.Unsecure, - }, - ContainerGroupOSType = ContainerInstanceOperatingSystemType.Linux, - Volumes = -{ -new ContainerVolume("volume1") -{ -AzureFile = new ContainerInstanceAzureFileVolume("shareName","accountName") -{ -StorageAccountKey = "accountKey", -}, -},new ContainerVolume("volume2") -{ -EmptyDir = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), -},new ContainerVolume("volume3") -{ -Secret = -{ -["secretKey1"] = "SecretValue1InBase64", -["secretKey2"] = "SecretValue2InBase64", -}, -} -}, - DiagnosticsLogAnalytics = new ContainerGroupLogAnalytics("workspaceid", "workspaceKey") - { - LogType = ContainerGroupLogAnalyticsLogType.ContainerInsights, - Metadata = -{ -["test-key"] = "test-metadata-value", -}, - WorkspaceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace"), - }, - SubnetIds = -{ -new ContainerGroupSubnetId(new ResourceIdentifier("[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('vnetName'), parameters('subnetName'))]")) -}, - DnsConfig = new ContainerGroupDnsConfiguration(new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"1.1.1.1" - }) - { - SearchDomains = "cluster.local svc.cluster.local", - Options = "ndots:2", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); - ContainerGroupResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ContainerGroupsCreateWithPriority() + public async Task GetIfExists_ContainerGroupsGetSucceeded() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsCreatePriority.json - // this example is just showing the usage of "ContainerGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsGet_Succeeded.json + // this example is just showing the usage of "ContainerGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -819,32 +769,21 @@ public async Task CreateOrUpdate_ContainerGroupsCreateWithPriority() // invoke the operation string containerGroupName = "demo1"; - ContainerGroupData data = new ContainerGroupData(new AzureLocation("eastus"), new ContainerInstanceContainer[] + NullableResponse response = await collection.GetIfExistsAsync(containerGroupName); + ContainerGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new ContainerInstanceContainer("test-container-001") -{ -Image = "alpine:latest", -Command = -{ -"/bin/sh","-c","sleep 10" -}, -Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1,1)), -} - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - RestartPolicy = ContainerGroupRestartPolicy.Never, - ContainerGroupOSType = ContainerInstanceOperatingSystemType.Linux, - Sku = ContainerGroupSku.Standard, - Priority = ContainerGroupPriority.Spot, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupName, data); - ContainerGroupResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileCollection.cs b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileCollection.cs index b56dfe10e7ca8..fe12df8526ba5 100644 --- a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileCollection.cs +++ b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -20,10 +19,10 @@ public partial class Sample_ContainerGroupProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ContainerGroupProfilesListByResourceGroup() + public async Task CreateOrUpdate_ConfidentialContainerGroupProfile() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesListByResourceGroup.json - // this example is just showing the usage of "ContainerGroupProfiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileCreateOrUpdate_CreateConfidential.json + // this example is just showing the usage of "ContainerGroupProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +39,56 @@ public async Task GetAll_ContainerGroupProfilesListByResourceGroup() // get the collection of this ContainerGroupProfileResource ContainerGroupProfileCollection collection = resourceGroupResource.GetContainerGroupProfiles(); - // invoke the operation and iterate over the result - await foreach (ContainerGroupProfileResource item in collection.GetAllAsync()) + // invoke the operation + string containerGroupProfileName = "demo1"; + ContainerGroupProfileData data = new ContainerGroupProfileData(new AzureLocation("westeurope"), new ContainerInstanceContainer[] { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } +new ContainerInstanceContainer("accdemo") +{ +Image = "confiimage", +Command = {}, +Ports = {new ContainerPort(8000)}, +EnvironmentVariables = {}, +Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5, 1)), +SecurityContext = new ContainerSecurityContextDefinition +{ +IsPrivileged = false, +Capabilities = new ContainerSecurityContextCapabilitiesDefinition +{ +Add = {"CAP_NET_ADMIN"}, +}, +}, +} + }, ContainerInstanceOperatingSystemType.Linux) + { + ImageRegistryCredentials = { }, + IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + { +new ContainerGroupPort(8000) +{ +Protocol = ContainerGroupNetworkProtocol.Tcp, +} + }, ContainerGroupIPAddressType.Public), + Sku = ContainerGroupSku.Confidential, + ConfidentialComputeCcePolicy = "eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19", + Zones = { "1" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupProfileName, data); + ContainerGroupProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ContainerGroupProfilesGetWithPriority() + public async Task CreateOrUpdate_ContainerGroupProfileCreateWithExtensions() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGetPriority.json - // this example is just showing the usage of "ContainerGroupProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileCreateOrUpdate_Extensions.json + // this example is just showing the usage of "ContainerGroupProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +107,48 @@ public async Task Get_ContainerGroupProfilesGetWithPriority() // invoke the operation string containerGroupProfileName = "demo1"; - ContainerGroupProfileResource result = await collection.GetAsync(containerGroupProfileName); + ContainerGroupProfileData data = new ContainerGroupProfileData(new AzureLocation("eastus2"), new ContainerInstanceContainer[] + { +new ContainerInstanceContainer("demo1") +{ +Image = "nginx", +Command = {}, +Ports = {new ContainerPort(80)}, +EnvironmentVariables = {}, +Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5, 1)), +} + }, ContainerInstanceOperatingSystemType.Linux) + { + ImageRegistryCredentials = { }, + IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + { +new ContainerGroupPort(80) +{ +Protocol = ContainerGroupNetworkProtocol.Tcp, +} + }, ContainerGroupIPAddressType.Private), + Extensions = {new DeploymentExtensionSpec("kube-proxy") +{ +ExtensionType = "kube-proxy", +Version = "1.0", +Settings = BinaryData.FromObjectAsJson(new +{ +clusterCidr = "10.240.0.0/16", +kubeVersion = "v1.9.10", +}), +ProtectedSettings = BinaryData.FromObjectAsJson(new +{ +kubeConfig = "", +}), +}, new DeploymentExtensionSpec("vk-realtime-metrics") +{ +ExtensionType = "realtime-metrics", +Version = "1.0", +}}, + Zones = { "1" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupProfileName, data); + ContainerGroupProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +159,10 @@ public async Task Get_ContainerGroupProfilesGetWithPriority() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ContainerGroupProfilesGetWithPriority() + public async Task CreateOrUpdate_ContainerGroupProfileWithEncryptionProperties() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGetPriority.json - // this example is just showing the usage of "ContainerGroupProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileCreateOrUpdate_EncryptionProperties.json + // this example is just showing the usage of "ContainerGroupProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,17 +181,48 @@ public async Task Exists_ContainerGroupProfilesGetWithPriority() // invoke the operation string containerGroupProfileName = "demo1"; - bool result = await collection.ExistsAsync(containerGroupProfileName); + ContainerGroupProfileData data = new ContainerGroupProfileData(new AzureLocation("eastus2"), new ContainerInstanceContainer[] + { +new ContainerInstanceContainer("demo1") +{ +Image = "nginx", +Command = {}, +Ports = {new ContainerPort(80)}, +EnvironmentVariables = {}, +Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5, 1)), +} + }, ContainerInstanceOperatingSystemType.Linux) + { + ImageRegistryCredentials = { }, + IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + { +new ContainerGroupPort(80) +{ +Protocol = ContainerGroupNetworkProtocol.Tcp, +} + }, ContainerGroupIPAddressType.Public), + EncryptionProperties = new ContainerGroupEncryptionProperties(new Uri("https://testkeyvault.vault.azure.net"), "test-key", "") + { + Identity = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity", + }, + Zones = { "1" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupProfileName, data); + ContainerGroupProfileResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ContainerGroupProfilesGetWithPriority() + public async Task CreateOrUpdate_ContainerGroupProfilesCreateOrUpdate() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGetPriority.json - // this example is just showing the usage of "ContainerGroupProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesCreateOrUpdate.json + // this example is just showing the usage of "ContainerGroupProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,29 +241,83 @@ public async Task GetIfExists_ContainerGroupProfilesGetWithPriority() // invoke the operation string containerGroupProfileName = "demo1"; - NullableResponse response = await collection.GetIfExistsAsync(containerGroupProfileName); - ContainerGroupProfileResource result = response.HasValue ? response.Value : null; - - if (result == null) + ContainerGroupProfileData data = new ContainerGroupProfileData(new AzureLocation("west us"), new ContainerInstanceContainer[] { - Console.WriteLine("Succeeded with null as result"); - } - else +new ContainerInstanceContainer("demo1") +{ +Image = "nginx", +Command = {}, +Ports = {new ContainerPort(80)}, +EnvironmentVariables = {}, +Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5, 1) +{ +Gpu = new ContainerGpuResourceInfo(1, ContainerGpuSku.K80), +}), +VolumeMounts = {new ContainerVolumeMount("volume1", "/mnt/volume1") +{ +IsReadOnly = false, +}, new ContainerVolumeMount("volume2", "/mnt/volume2") +{ +IsReadOnly = false, +}, new ContainerVolumeMount("volume3", "/mnt/volume3") +{ +IsReadOnly = true, +}}, +} + }, ContainerInstanceOperatingSystemType.Linux) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ImageRegistryCredentials = { }, + IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + { +new ContainerGroupPort(80) +{ +Protocol = ContainerGroupNetworkProtocol.Tcp, +} + }, ContainerGroupIPAddressType.Public), + Volumes = {new ContainerVolume("volume1") +{ +AzureFile = new ContainerInstanceAzureFileVolume("shareName", "accountName") +{ +StorageAccountKey = "accountKey", +}, +}, new ContainerVolume("volume2") +{ +EmptyDir = BinaryData.FromObjectAsJson(new object()), +}, new ContainerVolume("volume3") +{ +Secret = +{ +["secretKey1"] = "SecretValue1InBase64", +["secretKey2"] = "SecretValue2InBase64" +}, +}}, + DiagnosticsLogAnalytics = new ContainerGroupLogAnalytics("workspaceid", "workspaceKey") + { + LogType = ContainerGroupLogAnalyticsLogType.ContainerInsights, + Metadata = +{ +["pod-uuid"] = "test-metadata-value" +}, + WorkspaceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace"), + }, + Zones = { "1" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupProfileName, data); + ContainerGroupProfileResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ContainerGroupProfilesGetSucceeded() + public async Task CreateOrUpdate_ContainerGroupsCreateWithPriority() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGet.json - // this example is just showing the usage of "ContainerGroupProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsProfileCreateOrUpdate_CreatePriority.json + // this example is just showing the usage of "ContainerGroupProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,7 +336,22 @@ public async Task Get_ContainerGroupProfilesGetSucceeded() // invoke the operation string containerGroupProfileName = "demo1"; - ContainerGroupProfileResource result = await collection.GetAsync(containerGroupProfileName); + ContainerGroupProfileData data = new ContainerGroupProfileData(new AzureLocation("eastus"), new ContainerInstanceContainer[] + { +new ContainerInstanceContainer("test-container-001") +{ +Image = "alpine:latest", +Command = {"/bin/sh", "-c", "sleep 10"}, +Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1, 1)), +} + }, ContainerInstanceOperatingSystemType.Linux) + { + RestartPolicy = ContainerGroupRestartPolicy.Never, + Sku = ContainerGroupSku.Standard, + Priority = ContainerGroupPriority.Spot, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupProfileName, data); + ContainerGroupProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -191,9 +362,9 @@ public async Task Get_ContainerGroupProfilesGetSucceeded() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ContainerGroupProfilesGetSucceeded() + public async Task Get_ContainerGroupProfilesGetWithPriority() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGet.json + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGetPriority.json // this example is just showing the usage of "ContainerGroupProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -213,14 +384,18 @@ public async Task Exists_ContainerGroupProfilesGetSucceeded() // invoke the operation string containerGroupProfileName = "demo1"; - bool result = await collection.ExistsAsync(containerGroupProfileName); + ContainerGroupProfileResource result = await collection.GetAsync(containerGroupProfileName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ContainerGroupProfilesGetSucceeded() + public async Task Get_ContainerGroupProfilesGetSucceeded() { // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGet.json // this example is just showing the usage of "ContainerGroupProfiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -242,29 +417,21 @@ public async Task GetIfExists_ContainerGroupProfilesGetSucceeded() // invoke the operation string containerGroupProfileName = "demo1"; - NullableResponse response = await collection.GetIfExistsAsync(containerGroupProfileName); - ContainerGroupProfileResource result = response.HasValue ? response.Value : null; + ContainerGroupProfileResource result = await collection.GetAsync(containerGroupProfileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConfidentialContainerGroupProfile() + public async Task GetAll_ContainerGroupProfilesListByResourceGroup() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileCreateOrUpdate_CreateConfidential.json - // this example is just showing the usage of "ContainerGroupProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesListByResourceGroup.json + // this example is just showing the usage of "ContainerGroupProfiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -281,71 +448,25 @@ public async Task CreateOrUpdate_ConfidentialContainerGroupProfile() // get the collection of this ContainerGroupProfileResource ContainerGroupProfileCollection collection = resourceGroupResource.GetContainerGroupProfiles(); - // invoke the operation - string containerGroupProfileName = "demo1"; - ContainerGroupProfileData data = new ContainerGroupProfileData(new AzureLocation("westeurope"), new ContainerInstanceContainer[] + // invoke the operation and iterate over the result + await foreach (ContainerGroupProfileResource item in collection.GetAllAsync()) { -new ContainerInstanceContainer("accdemo") -{ -Image = "confiimage", -Command = -{ -}, -Ports = -{ -new ContainerPort(8000) -}, -EnvironmentVariables = -{ -}, -Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5,1)), -SecurityContext = new ContainerSecurityContextDefinition() -{ -IsPrivileged = false, -Capabilities = new ContainerSecurityContextCapabilitiesDefinition() -{ -Add = -{ -"CAP_NET_ADMIN" -}, -}, -}, -} - }, ContainerInstanceOperatingSystemType.Linux) - { - ImageRegistryCredentials = -{ -}, - IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] - { -new ContainerGroupPort(8000) -{ -Protocol = ContainerGroupNetworkProtocol.Tcp, -} - }, ContainerGroupIPAddressType.Public), - Sku = ContainerGroupSku.Confidential, - ConfidentialComputeCcePolicy = "eyJhbGxvd19hbGwiOiB0cnVlLCAiY29udGFpbmVycyI6IHsibGVuZ3RoIjogMCwgImVsZW1lbnRzIjogbnVsbH19", - Zones = -{ -"1" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupProfileName, data); - ContainerGroupProfileResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ContainerGroupProfileCreateWithExtensions() + public async Task Exists_ContainerGroupProfilesGetWithPriority() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileCreateOrUpdate_Extensions.json - // this example is just showing the usage of "ContainerGroupProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGetPriority.json + // this example is just showing the usage of "ContainerGroupProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -364,75 +485,17 @@ public async Task CreateOrUpdate_ContainerGroupProfileCreateWithExtensions() // invoke the operation string containerGroupProfileName = "demo1"; - ContainerGroupProfileData data = new ContainerGroupProfileData(new AzureLocation("eastus2"), new ContainerInstanceContainer[] - { -new ContainerInstanceContainer("demo1") -{ -Image = "nginx", -Command = -{ -}, -Ports = -{ -new ContainerPort(80) -}, -EnvironmentVariables = -{ -}, -Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5,1)), -} - }, ContainerInstanceOperatingSystemType.Linux) - { - ImageRegistryCredentials = -{ -}, - IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] - { -new ContainerGroupPort(80) -{ -Protocol = ContainerGroupNetworkProtocol.Tcp, -} - }, ContainerGroupIPAddressType.Private), - Extensions = -{ -new DeploymentExtensionSpec("kube-proxy") -{ -ExtensionType = "kube-proxy", -Version = "1.0", -Settings = BinaryData.FromObjectAsJson(new Dictionary() -{ -["clusterCidr"] = "10.240.0.0/16", -["kubeVersion"] = "v1.9.10"}), -ProtectedSettings = BinaryData.FromObjectAsJson(new Dictionary() -{ -["kubeConfig"] = ""}), -},new DeploymentExtensionSpec("vk-realtime-metrics") -{ -ExtensionType = "realtime-metrics", -Version = "1.0", -} -}, - Zones = -{ -"1" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupProfileName, data); - ContainerGroupProfileResource result = lro.Value; + bool result = await collection.ExistsAsync(containerGroupProfileName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ContainerGroupProfileWithEncryptionProperties() + public async Task Exists_ContainerGroupProfilesGetSucceeded() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileCreateOrUpdate_EncryptionProperties.json - // this example is just showing the usage of "ContainerGroupProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGet.json + // this example is just showing the usage of "ContainerGroupProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -451,60 +514,17 @@ public async Task CreateOrUpdate_ContainerGroupProfileWithEncryptionProperties() // invoke the operation string containerGroupProfileName = "demo1"; - ContainerGroupProfileData data = new ContainerGroupProfileData(new AzureLocation("eastus2"), new ContainerInstanceContainer[] - { -new ContainerInstanceContainer("demo1") -{ -Image = "nginx", -Command = -{ -}, -Ports = -{ -new ContainerPort(80) -}, -EnvironmentVariables = -{ -}, -Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5,1)), -} - }, ContainerInstanceOperatingSystemType.Linux) - { - ImageRegistryCredentials = -{ -}, - IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] - { -new ContainerGroupPort(80) -{ -Protocol = ContainerGroupNetworkProtocol.Tcp, -} - }, ContainerGroupIPAddressType.Public), - EncryptionProperties = new ContainerGroupEncryptionProperties(new Uri("https://testkeyvault.vault.azure.net"), "test-key", "") - { - Identity = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/container-group-identity", - }, - Zones = -{ -"1" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupProfileName, data); - ContainerGroupProfileResource result = lro.Value; + bool result = await collection.ExistsAsync(containerGroupProfileName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ContainerGroupProfilesCreateOrUpdate() + public async Task GetIfExists_ContainerGroupProfilesGetWithPriority() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesCreateOrUpdate.json - // this example is just showing the usage of "ContainerGroupProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGetPriority.json + // this example is just showing the usage of "ContainerGroupProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -523,103 +543,29 @@ public async Task CreateOrUpdate_ContainerGroupProfilesCreateOrUpdate() // invoke the operation string containerGroupProfileName = "demo1"; - ContainerGroupProfileData data = new ContainerGroupProfileData(new AzureLocation("west us"), new ContainerInstanceContainer[] - { -new ContainerInstanceContainer("demo1") -{ -Image = "nginx", -Command = -{ -}, -Ports = -{ -new ContainerPort(80) -}, -EnvironmentVariables = -{ -}, -Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1.5,1) -{ -Gpu = new ContainerGpuResourceInfo(1,ContainerGpuSku.K80), -}), -VolumeMounts = -{ -new ContainerVolumeMount("volume1","/mnt/volume1") -{ -IsReadOnly = false, -},new ContainerVolumeMount("volume2","/mnt/volume2") -{ -IsReadOnly = false, -},new ContainerVolumeMount("volume3","/mnt/volume3") -{ -IsReadOnly = true, -} -}, -} - }, ContainerInstanceOperatingSystemType.Linux) + NullableResponse response = await collection.GetIfExistsAsync(containerGroupProfileName); + ContainerGroupProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) { - ImageRegistryCredentials = -{ -}, - IPAddress = new ContainerGroupIPAddress(new ContainerGroupPort[] + Console.WriteLine("Succeeded with null as result"); + } + else { -new ContainerGroupPort(80) -{ -Protocol = ContainerGroupNetworkProtocol.Tcp, -} - }, ContainerGroupIPAddressType.Public), - Volumes = -{ -new ContainerVolume("volume1") -{ -AzureFile = new ContainerInstanceAzureFileVolume("shareName","accountName") -{ -StorageAccountKey = "accountKey", -}, -},new ContainerVolume("volume2") -{ -EmptyDir = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), -},new ContainerVolume("volume3") -{ -Secret = -{ -["secretKey1"] = "SecretValue1InBase64", -["secretKey2"] = "SecretValue2InBase64", -}, -} -}, - DiagnosticsLogAnalytics = new ContainerGroupLogAnalytics("workspaceid", "workspaceKey") - { - LogType = ContainerGroupLogAnalyticsLogType.ContainerInsights, - Metadata = -{ -["pod-uuid"] = "test-metadata-value", -}, - WorkspaceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/microsoft.operationalinsights/workspaces/workspace"), - }, - Zones = -{ -"1" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupProfileName, data); - ContainerGroupProfileResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ContainerGroupsCreateWithPriority() + public async Task GetIfExists_ContainerGroupProfilesGetSucceeded() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsProfileCreateOrUpdate_CreatePriority.json - // this example is just showing the usage of "ContainerGroupProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesGet.json + // this example is just showing the usage of "ContainerGroupProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -638,31 +584,21 @@ public async Task CreateOrUpdate_ContainerGroupsCreateWithPriority() // invoke the operation string containerGroupProfileName = "demo1"; - ContainerGroupProfileData data = new ContainerGroupProfileData(new AzureLocation("eastus"), new ContainerInstanceContainer[] + NullableResponse response = await collection.GetIfExistsAsync(containerGroupProfileName); + ContainerGroupProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new ContainerInstanceContainer("test-container-001") -{ -Image = "alpine:latest", -Command = -{ -"/bin/sh","-c","sleep 10" -}, -Resources = new ContainerResourceRequirements(new ContainerResourceRequestsContent(1,1)), -} - }, ContainerInstanceOperatingSystemType.Linux) + Console.WriteLine("Succeeded with null as result"); + } + else { - RestartPolicy = ContainerGroupRestartPolicy.Never, - Sku = ContainerGroupSku.Standard, - Priority = ContainerGroupPriority.Spot, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerGroupProfileName, data); - ContainerGroupProfileResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileResource.cs b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileResource.cs index 5d4a59df4f834..f7b6619af12a6 100644 --- a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileResource.cs +++ b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ContainerInstance.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ContainerInstance.Samples { public partial class Sample_ContainerGroupProfileResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetContainerGroupProfiles_ContainerGroupProfilesList() - { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesList.json - // this example is just showing the usage of "ContainerGroupProfiles_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ContainerGroupProfileResource item in subscriptionResource.GetContainerGroupProfilesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ContainerGroupProfilesGetWithPriority() @@ -110,10 +78,10 @@ public async Task Get_ContainerGroupProfilesGetSucceeded() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ContainerGroupProfilesPatch() + public async Task Delete_ContainerGroupProfilesDelete() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesPatch.json - // this example is just showing the usage of "ContainerGroupProfiles_Patch" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesDelete.json + // this example is just showing the usage of "ContainerGroupProfiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -123,35 +91,23 @@ public async Task Update_ContainerGroupProfilesPatch() // this example assumes you already have this ContainerGroupProfileResource created on azure // for more information of creating ContainerGroupProfileResource, please refer to the document of ContainerGroupProfileResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "demoResource"; + string resourceGroupName = "demo"; string containerGroupProfileName = "demo1"; ResourceIdentifier containerGroupProfileResourceId = ContainerGroupProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, containerGroupProfileName); ContainerGroupProfileResource containerGroupProfile = client.GetContainerGroupProfileResource(containerGroupProfileResourceId); // invoke the operation - ContainerGroupProfilePatch patch = new ContainerGroupProfilePatch() - { - Tags = -{ -["tag1key"] = "tag1Value", -["tag2key"] = "tag2Value", -}, - }; - ContainerGroupProfileResource result = await containerGroupProfile.UpdateAsync(patch); + await containerGroupProfile.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ContainerGroupProfilesDelete() + public async Task Update_ContainerGroupProfilesPatch() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesDelete.json - // this example is just showing the usage of "ContainerGroupProfiles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesPatch.json + // this example is just showing the usage of "ContainerGroupProfiles_Patch" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -161,15 +117,27 @@ public async Task Delete_ContainerGroupProfilesDelete() // this example assumes you already have this ContainerGroupProfileResource created on azure // for more information of creating ContainerGroupProfileResource, please refer to the document of ContainerGroupProfileResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "demo"; + string resourceGroupName = "demoResource"; string containerGroupProfileName = "demo1"; ResourceIdentifier containerGroupProfileResourceId = ContainerGroupProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, containerGroupProfileName); ContainerGroupProfileResource containerGroupProfile = client.GetContainerGroupProfileResource(containerGroupProfileResourceId); // invoke the operation - await containerGroupProfile.DeleteAsync(WaitUntil.Completed); + ContainerGroupProfilePatch patch = new ContainerGroupProfilePatch + { + Tags = +{ +["tag1key"] = "tag1Value", +["tag2key"] = "tag2Value" +}, + }; + ContainerGroupProfileResource result = await containerGroupProfile.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileRevisionCollection.cs b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileRevisionCollection.cs index 10acc87c7fa7e..f3e489680fa88 100644 --- a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileRevisionCollection.cs +++ b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupProfileRevisionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerGroupProfileRevisionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ContainerGroupProfileListAllRevisions() + public async Task Get_ContainerGroupProfileGetByRevisionNumber() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileListAllRevisions.json - // this example is just showing the usage of "ContainerGroupProfile_ListAllRevisions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileGetByRevisionNumber.json + // this example is just showing the usage of "ContainerGroupProfile_GetByRevisionNumber" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ContainerGroupProfileListAllRevisions() // get the collection of this ContainerGroupProfileRevisionResource ContainerGroupProfileRevisionCollection collection = containerGroupProfile.GetContainerGroupProfileRevisions(); - // invoke the operation and iterate over the result - await foreach (ContainerGroupProfileRevisionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string revisionNumber = "1"; + ContainerGroupProfileRevisionResource result = await collection.GetAsync(revisionNumber); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ContainerGroupProfileGetByRevisionNumber() + public async Task GetAll_ContainerGroupProfileListAllRevisions() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileGetByRevisionNumber.json - // this example is just showing the usage of "ContainerGroupProfile_GetByRevisionNumber" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfileListAllRevisions.json + // this example is just showing the usage of "ContainerGroupProfile_ListAllRevisions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_ContainerGroupProfileGetByRevisionNumber() // get the collection of this ContainerGroupProfileRevisionResource ContainerGroupProfileRevisionCollection collection = containerGroupProfile.GetContainerGroupProfileRevisions(); - // invoke the operation - string revisionNumber = "1"; - ContainerGroupProfileRevisionResource result = await collection.GetAsync(revisionNumber); + // invoke the operation and iterate over the result + await foreach (ContainerGroupProfileRevisionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupResource.cs b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupResource.cs index b4a9b0697322d..3ac76f1c550a2 100644 --- a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupResource.cs +++ b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_ContainerGroupResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ContainerInstance.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ContainerInstance.Samples { public partial class Sample_ContainerGroupResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetContainerGroups_ContainerGroupsList() - { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsList.json - // this example is just showing the usage of "ContainerGroups_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ContainerGroupResource item in subscriptionResource.GetContainerGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ContainerGroupsGetWithPriority() @@ -140,10 +108,10 @@ public async Task Get_ContainerGroupsGetSucceeded() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ContainerGroupsUpdate() + public async Task Delete_ContainerGroupsDelete() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsUpdate.json - // this example is just showing the usage of "ContainerGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsDelete.json + // this example is just showing the usage of "ContainerGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -153,21 +121,14 @@ public async Task Update_ContainerGroupsUpdate() // this example assumes you already have this ContainerGroupResource created on azure // for more information of creating ContainerGroupResource, please refer to the document of ContainerGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "demoResource"; + string resourceGroupName = "demo"; string containerGroupName = "demo1"; ResourceIdentifier containerGroupResourceId = ContainerGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, containerGroupName); ContainerGroupResource containerGroup = client.GetContainerGroupResource(containerGroupResourceId); // invoke the operation - ContainerGroupPatch patch = new ContainerGroupPatch(new AzureLocation("placeholder")) - { - Tags = -{ -["tag1key"] = "tag1Value", -["tag2key"] = "tag2Value", -}, - }; - ContainerGroupResource result = await containerGroup.UpdateAsync(patch); + ArmOperation lro = await containerGroup.DeleteAsync(WaitUntil.Completed); + ContainerGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -178,10 +139,10 @@ public async Task Update_ContainerGroupsUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ContainerGroupsDelete() + public async Task Update_ContainerGroupsUpdate() { - // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsDelete.json - // this example is just showing the usage of "ContainerGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsUpdate.json + // this example is just showing the usage of "ContainerGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,14 +152,21 @@ public async Task Delete_ContainerGroupsDelete() // this example assumes you already have this ContainerGroupResource created on azure // for more information of creating ContainerGroupResource, please refer to the document of ContainerGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "demo"; + string resourceGroupName = "demoResource"; string containerGroupName = "demo1"; ResourceIdentifier containerGroupResourceId = ContainerGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, containerGroupName); ContainerGroupResource containerGroup = client.GetContainerGroupResource(containerGroupResourceId); // invoke the operation - ArmOperation lro = await containerGroup.DeleteAsync(WaitUntil.Completed); - ContainerGroupResource result = lro.Value; + ContainerGroupPatch patch = new ContainerGroupPatch(default) + { + Tags = +{ +["tag1key"] = "tag1Value", +["tag2key"] = "tag2Value" +}, + }; + ContainerGroupResource result = await containerGroup.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -335,10 +303,10 @@ public async Task ExecuteContainerCommand_ContainerExec() // invoke the operation string containerName = "container1"; - ContainerExecContent content = new ContainerExecContent() + ContainerExecContent content = new ContainerExecContent { Command = "/bin/bash", - TerminalSize = new ContainerExecRequestTerminalSize() + TerminalSize = new ContainerExecRequestTerminalSize { Rows = 12, Cols = 12, diff --git a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 50f82f1a2b200..a2601dcca0a81 100644 --- a/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/containerinstance/Azure.ResourceManager.ContainerInstance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.ContainerInstance.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetContainerGroups_ContainerGroupsList() + { + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupsList.json + // this example is just showing the usage of "ContainerGroups_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerGroupResource item in subscriptionResource.GetContainerGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetUsagesWithLocation_ContainerUsage() @@ -100,5 +131,36 @@ public async Task GetCapabilitiesWithLocation_GetCapabilities() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetContainerGroupProfiles_ContainerGroupProfilesList() + { + // Generated from example definition: specification/containerinstance/resource-manager/Microsoft.ContainerInstance/preview/2024-05-01-preview/examples/ContainerGroupProfilesList.json + // this example is just showing the usage of "ContainerGroupProfiles_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerGroupProfileResource item in subscriptionResource.GetContainerGroupProfilesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerGroupProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerCollection.cs index 621dddc2e6251..f5790337b294e 100644 --- a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerCollection.cs +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerCollection.cs @@ -18,27 +18,28 @@ public partial class Sample_ConnectedClusterBgpPeerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BgpPeersGet() + public async Task CreateOrUpdate_BgpPeersCreateOrUpdate() { - // Generated from example definition: 2024-03-01/BgpPeers_Get.json - // this example is just showing the usage of "BgpPeer_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/BgpPeers_CreateOrUpdate.json + // this example is just showing the usage of "BgpPeer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterBgpPeerResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(scopeId); + ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(new ResourceIdentifier(resourceUri)); // invoke the operation string bgpPeerName = "testpeer"; - ConnectedClusterBgpPeerResource result = await collection.GetAsync(bgpPeerName); + ConnectedClusterBgpPeerData data = new ConnectedClusterBgpPeerData + { + Properties = new ConnectedClusterBgpPeerProperties(64500, 64501, "10.0.0.1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bgpPeerName, data); + ConnectedClusterBgpPeerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,7 +50,7 @@ public async Task Get_BgpPeersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BgpPeersGet() + public async Task Get_BgpPeersGet() { // Generated from example definition: 2024-03-01/BgpPeers_Get.json // this example is just showing the usage of "BgpPeer_Get" operation, for the dependent resources, they will have to be created separately. @@ -59,127 +60,106 @@ public async Task Exists_BgpPeersGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterBgpPeerResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(scopeId); + ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(new ResourceIdentifier(resourceUri)); // invoke the operation string bgpPeerName = "testpeer"; - bool result = await collection.ExistsAsync(bgpPeerName); + ConnectedClusterBgpPeerResource result = await collection.GetAsync(bgpPeerName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterBgpPeerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BgpPeersGet() + public async Task GetAll_BgpPeersList() { - // Generated from example definition: 2024-03-01/BgpPeers_Get.json - // this example is just showing the usage of "BgpPeer_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/BgpPeers_List.json + // this example is just showing the usage of "BgpPeer_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterBgpPeerResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(scopeId); - - // invoke the operation - string bgpPeerName = "testpeer"; - NullableResponse response = await collection.GetIfExistsAsync(bgpPeerName); - ConnectedClusterBgpPeerResource result = response.HasValue ? response.Value : null; + ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(new ResourceIdentifier(resourceUri)); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ConnectedClusterBgpPeerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectedClusterBgpPeerData resourceData = result.Data; + ConnectedClusterBgpPeerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BgpPeersCreateOrUpdate() + public async Task Exists_BgpPeersGet() { - // Generated from example definition: 2024-03-01/BgpPeers_CreateOrUpdate.json - // this example is just showing the usage of "BgpPeer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/BgpPeers_Get.json + // this example is just showing the usage of "BgpPeer_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterBgpPeerResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(scopeId); + ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(new ResourceIdentifier(resourceUri)); // invoke the operation string bgpPeerName = "testpeer"; - ConnectedClusterBgpPeerData data = new ConnectedClusterBgpPeerData() - { - Properties = new ConnectedClusterBgpPeerProperties(64500, 64501, "10.0.0.1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bgpPeerName, data); - ConnectedClusterBgpPeerResource result = lro.Value; + bool result = await collection.ExistsAsync(bgpPeerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterBgpPeerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BgpPeersList() + public async Task GetIfExists_BgpPeersGet() { - // Generated from example definition: 2024-03-01/BgpPeers_List.json - // this example is just showing the usage of "BgpPeer_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/BgpPeers_Get.json + // this example is just showing the usage of "BgpPeer_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterBgpPeerResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(scopeId); + ConnectedClusterBgpPeerCollection collection = client.GetConnectedClusterBgpPeers(new ResourceIdentifier(resourceUri)); - // invoke the operation and iterate over the result - await foreach (ConnectedClusterBgpPeerResource item in collection.GetAllAsync()) + // invoke the operation + string bgpPeerName = "testpeer"; + NullableResponse response = await collection.GetIfExistsAsync(bgpPeerName); + ConnectedClusterBgpPeerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectedClusterBgpPeerData resourceData = item.Data; + ConnectedClusterBgpPeerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerResource.cs index a03c58197b0d4..362e626113fca 100644 --- a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerResource.cs +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterBgpPeerResource.cs @@ -47,10 +47,10 @@ public async Task Get_BgpPeersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BgpPeersCreateOrUpdate() + public async Task Delete_BgpPeersDelete() { - // Generated from example definition: 2024-03-01/BgpPeers_CreateOrUpdate.json - // this example is just showing the usage of "BgpPeer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/BgpPeers_Delete.json + // this example is just showing the usage of "BgpPeer_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,26 +65,17 @@ public async Task Update_BgpPeersCreateOrUpdate() ConnectedClusterBgpPeerResource connectedClusterBgpPeer = client.GetConnectedClusterBgpPeerResource(connectedClusterBgpPeerResourceId); // invoke the operation - ConnectedClusterBgpPeerData data = new ConnectedClusterBgpPeerData() - { - Properties = new ConnectedClusterBgpPeerProperties(64500, 64501, "10.0.0.1"), - }; - ArmOperation lro = await connectedClusterBgpPeer.UpdateAsync(WaitUntil.Completed, data); - ConnectedClusterBgpPeerResource result = lro.Value; + await connectedClusterBgpPeer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterBgpPeerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BgpPeersDelete() + public async Task Update_BgpPeersCreateOrUpdate() { - // Generated from example definition: 2024-03-01/BgpPeers_Delete.json - // this example is just showing the usage of "BgpPeer_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/BgpPeers_CreateOrUpdate.json + // this example is just showing the usage of "BgpPeer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,9 +90,18 @@ public async Task Delete_BgpPeersDelete() ConnectedClusterBgpPeerResource connectedClusterBgpPeer = client.GetConnectedClusterBgpPeerResource(connectedClusterBgpPeerResourceId); // invoke the operation - await connectedClusterBgpPeer.DeleteAsync(WaitUntil.Completed); + ConnectedClusterBgpPeerData data = new ConnectedClusterBgpPeerData + { + Properties = new ConnectedClusterBgpPeerProperties(64500, 64501, "10.0.0.1"), + }; + ArmOperation lro = await connectedClusterBgpPeer.UpdateAsync(WaitUntil.Completed, data); + ConnectedClusterBgpPeerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterBgpPeerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerCollection.cs index 6aae821b63567..cd284bbd9f59c 100644 --- a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerCollection.cs +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerCollection.cs @@ -18,27 +18,34 @@ public partial class Sample_ConnectedClusterLoadBalancerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LoadBalancersGet() + public async Task CreateOrUpdate_LoadBalancersCreateOrUpdate() { - // Generated from example definition: 2024-03-01/LoadBalancers_Get.json - // this example is just showing the usage of "LoadBalancer_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/LoadBalancers_CreateOrUpdate.json + // this example is just showing the usage of "LoadBalancer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterLoadBalancerResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(scopeId); + ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(new ResourceIdentifier(resourceUri)); // invoke the operation string loadBalancerName = "testlb"; - ConnectedClusterLoadBalancerResource result = await collection.GetAsync(loadBalancerName); + ConnectedClusterLoadBalancerData data = new ConnectedClusterLoadBalancerData + { + Properties = new ConnectedClusterLoadBalancerProperties(new string[] { "192.168.50.1/24", "192.168.51.2-192.168.51.10" }, AdvertiseMode.Arp) + { + ServiceSelector = +{ +["app"] = "frontend" +}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); + ConnectedClusterLoadBalancerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,7 +56,7 @@ public async Task Get_LoadBalancersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LoadBalancersGet() + public async Task Get_LoadBalancersGet() { // Generated from example definition: 2024-03-01/LoadBalancers_Get.json // this example is just showing the usage of "LoadBalancer_Get" operation, for the dependent resources, they will have to be created separately. @@ -59,136 +66,106 @@ public async Task Exists_LoadBalancersGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterLoadBalancerResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(scopeId); + ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(new ResourceIdentifier(resourceUri)); // invoke the operation string loadBalancerName = "testlb"; - bool result = await collection.ExistsAsync(loadBalancerName); + ConnectedClusterLoadBalancerResource result = await collection.GetAsync(loadBalancerName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterLoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LoadBalancersGet() + public async Task GetAll_LoadBalancersList() { - // Generated from example definition: 2024-03-01/LoadBalancers_Get.json - // this example is just showing the usage of "LoadBalancer_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/LoadBalancers_List.json + // this example is just showing the usage of "LoadBalancer_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterLoadBalancerResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(scopeId); + ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(new ResourceIdentifier(resourceUri)); - // invoke the operation - string loadBalancerName = "testlb"; - NullableResponse response = await collection.GetIfExistsAsync(loadBalancerName); - ConnectedClusterLoadBalancerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ConnectedClusterLoadBalancerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectedClusterLoadBalancerData resourceData = result.Data; + ConnectedClusterLoadBalancerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LoadBalancersCreateOrUpdate() + public async Task Exists_LoadBalancersGet() { - // Generated from example definition: 2024-03-01/LoadBalancers_CreateOrUpdate.json - // this example is just showing the usage of "LoadBalancer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/LoadBalancers_Get.json + // this example is just showing the usage of "LoadBalancer_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterLoadBalancerResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(scopeId); + ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(new ResourceIdentifier(resourceUri)); // invoke the operation string loadBalancerName = "testlb"; - ConnectedClusterLoadBalancerData data = new ConnectedClusterLoadBalancerData() - { - Properties = new ConnectedClusterLoadBalancerProperties(new string[] - { -"192.168.50.1/24","192.168.51.2-192.168.51.10" - }, AdvertiseMode.Arp) - { - ServiceSelector = -{ -["app"] = "frontend", -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); - ConnectedClusterLoadBalancerResource result = lro.Value; + bool result = await collection.ExistsAsync(loadBalancerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterLoadBalancerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LoadBalancersList() + public async Task GetIfExists_LoadBalancersGet() { - // Generated from example definition: 2024-03-01/LoadBalancers_List.json - // this example is just showing the usage of "LoadBalancer_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/LoadBalancers_Get.json + // this example is just showing the usage of "LoadBalancer_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterLoadBalancerResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(scopeId); + ConnectedClusterLoadBalancerCollection collection = client.GetConnectedClusterLoadBalancers(new ResourceIdentifier(resourceUri)); - // invoke the operation and iterate over the result - await foreach (ConnectedClusterLoadBalancerResource item in collection.GetAllAsync()) + // invoke the operation + string loadBalancerName = "testlb"; + NullableResponse response = await collection.GetIfExistsAsync(loadBalancerName); + ConnectedClusterLoadBalancerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectedClusterLoadBalancerData resourceData = item.Data; + ConnectedClusterLoadBalancerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerResource.cs index 79f8eee13ff88..0c3ee97fae83a 100644 --- a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerResource.cs +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterLoadBalancerResource.cs @@ -47,10 +47,10 @@ public async Task Get_LoadBalancersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_LoadBalancersCreateOrUpdate() + public async Task Delete_LoadBalancersDelete() { - // Generated from example definition: 2024-03-01/LoadBalancers_CreateOrUpdate.json - // this example is just showing the usage of "LoadBalancer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/LoadBalancers_Delete.json + // this example is just showing the usage of "LoadBalancer_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,35 +65,17 @@ public async Task Update_LoadBalancersCreateOrUpdate() ConnectedClusterLoadBalancerResource connectedClusterLoadBalancer = client.GetConnectedClusterLoadBalancerResource(connectedClusterLoadBalancerResourceId); // invoke the operation - ConnectedClusterLoadBalancerData data = new ConnectedClusterLoadBalancerData() - { - Properties = new ConnectedClusterLoadBalancerProperties(new string[] - { -"192.168.50.1/24","192.168.51.2-192.168.51.10" - }, AdvertiseMode.Arp) - { - ServiceSelector = -{ -["app"] = "frontend", -}, - }, - }; - ArmOperation lro = await connectedClusterLoadBalancer.UpdateAsync(WaitUntil.Completed, data); - ConnectedClusterLoadBalancerResource result = lro.Value; + await connectedClusterLoadBalancer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterLoadBalancerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_LoadBalancersDelete() + public async Task Update_LoadBalancersCreateOrUpdate() { - // Generated from example definition: 2024-03-01/LoadBalancers_Delete.json - // this example is just showing the usage of "LoadBalancer_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/LoadBalancers_CreateOrUpdate.json + // this example is just showing the usage of "LoadBalancer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +90,24 @@ public async Task Delete_LoadBalancersDelete() ConnectedClusterLoadBalancerResource connectedClusterLoadBalancer = client.GetConnectedClusterLoadBalancerResource(connectedClusterLoadBalancerResourceId); // invoke the operation - await connectedClusterLoadBalancer.DeleteAsync(WaitUntil.Completed); + ConnectedClusterLoadBalancerData data = new ConnectedClusterLoadBalancerData + { + Properties = new ConnectedClusterLoadBalancerProperties(new string[] { "192.168.50.1/24", "192.168.51.2-192.168.51.10" }, AdvertiseMode.Arp) + { + ServiceSelector = +{ +["app"] = "frontend" +}, + }, + }; + ArmOperation lro = await connectedClusterLoadBalancer.UpdateAsync(WaitUntil.Completed, data); + ConnectedClusterLoadBalancerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterLoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceCollection.cs index d2bd20a137cf3..5147c7625047c 100644 --- a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceCollection.cs +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceCollection.cs @@ -18,27 +18,28 @@ public partial class Sample_ConnectedClusterServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ServicesGet() + public async Task CreateOrUpdate_ServicesCreateOrUpdate() { - // Generated from example definition: 2024-03-01/Services_Get.json - // this example is just showing the usage of "ServiceResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/Services_CreateOrUpdate.json + // this example is just showing the usage of "ServiceResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterServiceResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(scopeId); + ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(new ResourceIdentifier(resourceUri)); // invoke the operation string serviceName = "storageclass"; - ConnectedClusterServiceResource result = await collection.GetAsync(serviceName); + ConnectedClusterServiceData data = new ConnectedClusterServiceData + { + Properties = new ConnectedClusterServiceProperties(), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); + ConnectedClusterServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,7 +50,7 @@ public async Task Get_ServicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServicesGet() + public async Task Get_ServicesGet() { // Generated from example definition: 2024-03-01/Services_Get.json // this example is just showing the usage of "ServiceResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -59,127 +60,106 @@ public async Task Exists_ServicesGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterServiceResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(scopeId); + ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(new ResourceIdentifier(resourceUri)); // invoke the operation string serviceName = "storageclass"; - bool result = await collection.ExistsAsync(serviceName); + ConnectedClusterServiceResource result = await collection.GetAsync(serviceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServicesGet() + public async Task GetAll_ServicesList() { - // Generated from example definition: 2024-03-01/Services_Get.json - // this example is just showing the usage of "ServiceResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/Services_List.json + // this example is just showing the usage of "ServiceResource_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterServiceResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(scopeId); - - // invoke the operation - string serviceName = "storageclass"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - ConnectedClusterServiceResource result = response.HasValue ? response.Value : null; + ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(new ResourceIdentifier(resourceUri)); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ConnectedClusterServiceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectedClusterServiceData resourceData = result.Data; + ConnectedClusterServiceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServicesCreateOrUpdate() + public async Task Exists_ServicesGet() { - // Generated from example definition: 2024-03-01/Services_CreateOrUpdate.json - // this example is just showing the usage of "ServiceResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/Services_Get.json + // this example is just showing the usage of "ServiceResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterServiceResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(scopeId); + ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(new ResourceIdentifier(resourceUri)); // invoke the operation string serviceName = "storageclass"; - ConnectedClusterServiceData data = new ConnectedClusterServiceData() - { - Properties = new ConnectedClusterServiceProperties(), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); - ConnectedClusterServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(serviceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServicesList() + public async Task GetIfExists_ServicesGet() { - // Generated from example definition: 2024-03-01/Services_List.json - // this example is just showing the usage of "ServiceResource_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/Services_Get.json + // this example is just showing the usage of "ServiceResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterServiceResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(scopeId); + ConnectedClusterServiceCollection collection = client.GetConnectedClusterServices(new ResourceIdentifier(resourceUri)); - // invoke the operation and iterate over the result - await foreach (ConnectedClusterServiceResource item in collection.GetAllAsync()) + // invoke the operation + string serviceName = "storageclass"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + ConnectedClusterServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectedClusterServiceData resourceData = item.Data; + ConnectedClusterServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceResource.cs index 96698eb28efe1..1fa5547997d36 100644 --- a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceResource.cs +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterServiceResource.cs @@ -47,10 +47,10 @@ public async Task Get_ServicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ServicesCreateOrUpdate() + public async Task Delete_ServicesDelete() { - // Generated from example definition: 2024-03-01/Services_CreateOrUpdate.json - // this example is just showing the usage of "ServiceResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/Services_Delete.json + // this example is just showing the usage of "ServiceResource_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,26 +65,17 @@ public async Task Update_ServicesCreateOrUpdate() ConnectedClusterServiceResource connectedClusterService = client.GetConnectedClusterServiceResource(connectedClusterServiceResourceId); // invoke the operation - ConnectedClusterServiceData data = new ConnectedClusterServiceData() - { - Properties = new ConnectedClusterServiceProperties(), - }; - ArmOperation lro = await connectedClusterService.UpdateAsync(WaitUntil.Completed, data); - ConnectedClusterServiceResource result = lro.Value; + await connectedClusterService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ServicesDelete() + public async Task Update_ServicesCreateOrUpdate() { - // Generated from example definition: 2024-03-01/Services_Delete.json - // this example is just showing the usage of "ServiceResource_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/Services_CreateOrUpdate.json + // this example is just showing the usage of "ServiceResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,9 +90,18 @@ public async Task Delete_ServicesDelete() ConnectedClusterServiceResource connectedClusterService = client.GetConnectedClusterServiceResource(connectedClusterServiceResourceId); // invoke the operation - await connectedClusterService.DeleteAsync(WaitUntil.Completed); + ConnectedClusterServiceData data = new ConnectedClusterServiceData + { + Properties = new ConnectedClusterServiceProperties(), + }; + ArmOperation lro = await connectedClusterService.UpdateAsync(WaitUntil.Completed, data); + ConnectedClusterServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassCollection.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassCollection.cs index b7b6f1369a774..afa0e28400cec 100644 --- a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassCollection.cs +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassCollection.cs @@ -18,27 +18,28 @@ public partial class Sample_ConnectedClusterStorageClassCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StorageClassGet0() + public async Task CreateOrUpdate_StorageClassCreateOrUpdate0() { - // Generated from example definition: 2024-03-01/StorageClass_Get.json - // this example is just showing the usage of "StorageClassResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StorageClass_CreateOrUpdate.json + // this example is just showing the usage of "StorageClassResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterStorageClassResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(scopeId); + ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(new ResourceIdentifier(resourceUri)); // invoke the operation string storageClassName = "testrwx"; - ConnectedClusterStorageClassResource result = await collection.GetAsync(storageClassName); + ConnectedClusterStorageClassData data = new ConnectedClusterStorageClassData + { + Properties = new ConnectedClusterStorageClassProperties(new RwxStorageClassTypeProperties("default")), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageClassName, data); + ConnectedClusterStorageClassResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,7 +50,7 @@ public async Task Get_StorageClassGet0() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageClassGet0() + public async Task Get_StorageClassGet0() { // Generated from example definition: 2024-03-01/StorageClass_Get.json // this example is just showing the usage of "StorageClassResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -59,127 +60,106 @@ public async Task Exists_StorageClassGet0() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterStorageClassResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(scopeId); + ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(new ResourceIdentifier(resourceUri)); // invoke the operation string storageClassName = "testrwx"; - bool result = await collection.ExistsAsync(storageClassName); + ConnectedClusterStorageClassResource result = await collection.GetAsync(storageClassName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterStorageClassData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageClassGet0() + public async Task GetAll_StorageClassList0() { - // Generated from example definition: 2024-03-01/StorageClass_Get.json - // this example is just showing the usage of "StorageClassResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StorageClass_List.json + // this example is just showing the usage of "StorageClassResource_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterStorageClassResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(scopeId); - - // invoke the operation - string storageClassName = "testrwx"; - NullableResponse response = await collection.GetIfExistsAsync(storageClassName); - ConnectedClusterStorageClassResource result = response.HasValue ? response.Value : null; + ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(new ResourceIdentifier(resourceUri)); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ConnectedClusterStorageClassResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectedClusterStorageClassData resourceData = result.Data; + ConnectedClusterStorageClassData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StorageClassCreateOrUpdate0() + public async Task Exists_StorageClassGet0() { - // Generated from example definition: 2024-03-01/StorageClass_CreateOrUpdate.json - // this example is just showing the usage of "StorageClassResource_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StorageClass_Get.json + // this example is just showing the usage of "StorageClassResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterStorageClassResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(scopeId); + ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(new ResourceIdentifier(resourceUri)); // invoke the operation string storageClassName = "testrwx"; - ConnectedClusterStorageClassData data = new ConnectedClusterStorageClassData() - { - Properties = new ConnectedClusterStorageClassProperties(new RwxStorageClassTypeProperties("default")), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageClassName, data); - ConnectedClusterStorageClassResource result = lro.Value; + bool result = await collection.ExistsAsync(storageClassName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterStorageClassData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StorageClassList0() + public async Task GetIfExists_StorageClassGet0() { - // Generated from example definition: 2024-03-01/StorageClass_List.json - // this example is just showing the usage of "StorageClassResource_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StorageClass_Get.json + // this example is just showing the usage of "StorageClassResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ConnectedClusterStorageClassResource string resourceUri = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/example/providers/Microsoft.Kubernetes/connectedClusters/cluster1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(scopeId); + ConnectedClusterStorageClassCollection collection = client.GetConnectedClusterStorageClasses(new ResourceIdentifier(resourceUri)); - // invoke the operation and iterate over the result - await foreach (ConnectedClusterStorageClassResource item in collection.GetAllAsync()) + // invoke the operation + string storageClassName = "testrwx"; + NullableResponse response = await collection.GetIfExistsAsync(storageClassName); + ConnectedClusterStorageClassResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectedClusterStorageClassData resourceData = item.Data; + ConnectedClusterStorageClassData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassResource.cs b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassResource.cs index b39ffeb563015..4f94641a0e00d 100644 --- a/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassResource.cs +++ b/sdk/containerorchestratorruntime/Azure.ResourceManager.ContainerOrchestratorRuntime/samples/Generated/Samples/Sample_ConnectedClusterStorageClassResource.cs @@ -47,10 +47,10 @@ public async Task Get_StorageClassGet0() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_StorageClassUpdate0() + public async Task Delete_StorageClassDelete0() { - // Generated from example definition: 2024-03-01/StorageClass_Update.json - // this example is just showing the usage of "StorageClassResource_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StorageClass_Delete.json + // this example is just showing the usage of "StorageClassResource_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,32 +65,17 @@ public async Task Update_StorageClassUpdate0() ConnectedClusterStorageClassResource connectedClusterStorageClass = client.GetConnectedClusterStorageClassResource(connectedClusterStorageClassResourceId); // invoke the operation - ConnectedClusterStorageClassPatch patch = new ConnectedClusterStorageClassPatch() - { - Properties = new StorageClassPropertiesUpdate() - { - TypeProperties = new StorageClassTypePropertiesUpdate() - { - BackingStorageClassName = "default", - }, - }, - }; - ArmOperation lro = await connectedClusterStorageClass.UpdateAsync(WaitUntil.Completed, patch); - ConnectedClusterStorageClassResource result = lro.Value; + await connectedClusterStorageClass.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectedClusterStorageClassData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_StorageClassDelete0() + public async Task Update_StorageClassUpdate0() { - // Generated from example definition: 2024-03-01/StorageClass_Delete.json - // this example is just showing the usage of "StorageClassResource_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-03-01/StorageClass_Update.json + // this example is just showing the usage of "StorageClassResource_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +90,24 @@ public async Task Delete_StorageClassDelete0() ConnectedClusterStorageClassResource connectedClusterStorageClass = client.GetConnectedClusterStorageClassResource(connectedClusterStorageClassResourceId); // invoke the operation - await connectedClusterStorageClass.DeleteAsync(WaitUntil.Completed); + ConnectedClusterStorageClassPatch patch = new ConnectedClusterStorageClassPatch + { + Properties = new StorageClassPropertiesUpdate + { + TypeProperties = new StorageClassTypePropertiesUpdate + { + BackingStorageClassName = "default", + }, + }, + }; + ArmOperation lro = await connectedClusterStorageClass.UpdateAsync(WaitUntil.Completed, patch); + ConnectedClusterStorageClassResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectedClusterStorageClassData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryAgentPoolCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryAgentPoolCollection.cs index 564df9d358211..ad75e750ca852 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryAgentPoolCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryAgentPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerRegistryAgentPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AgentPoolsGet() + public async Task CreateOrUpdate_AgentPoolsCreate() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/AgentPoolsGet.json - // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/AgentPoolsCreate.json + // this example is just showing the usage of "AgentPools_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_AgentPoolsGet() // invoke the operation string agentPoolName = "myAgentPool"; - ContainerRegistryAgentPoolResource result = await collection.GetAsync(agentPoolName); + ContainerRegistryAgentPoolData data = new ContainerRegistryAgentPoolData(new AzureLocation("WESTUS")) + { + Count = 1, + Tier = "S1", + OS = ContainerRegistryOS.Linux, + Tags = +{ +["key"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + ContainerRegistryAgentPoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +63,7 @@ public async Task Get_AgentPoolsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AgentPoolsGet() + public async Task Get_AgentPoolsGet() { // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/AgentPoolsGet.json // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +86,21 @@ public async Task Exists_AgentPoolsGet() // invoke the operation string agentPoolName = "myAgentPool"; - bool result = await collection.ExistsAsync(agentPoolName); + ContainerRegistryAgentPoolResource result = await collection.GetAsync(agentPoolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AgentPoolsGet() + public async Task GetAll_AgentPoolsList() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/AgentPoolsGet.json - // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/AgentPoolsList.json + // this example is just showing the usage of "AgentPools_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +118,25 @@ public async Task GetIfExists_AgentPoolsGet() // get the collection of this ContainerRegistryAgentPoolResource ContainerRegistryAgentPoolCollection collection = containerRegistry.GetContainerRegistryAgentPools(); - // invoke the operation - string agentPoolName = "myAgentPool"; - NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); - ContainerRegistryAgentPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ContainerRegistryAgentPoolResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerRegistryAgentPoolData resourceData = result.Data; + ContainerRegistryAgentPoolData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AgentPoolsCreate() + public async Task Exists_AgentPoolsGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/AgentPoolsCreate.json - // this example is just showing the usage of "AgentPools_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/AgentPoolsGet.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,32 +156,17 @@ public async Task CreateOrUpdate_AgentPoolsCreate() // invoke the operation string agentPoolName = "myAgentPool"; - ContainerRegistryAgentPoolData data = new ContainerRegistryAgentPoolData(new AzureLocation("WESTUS")) - { - Count = 1, - Tier = "S1", - OS = ContainerRegistryOS.Linux, - Tags = -{ -["key"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); - ContainerRegistryAgentPoolResource result = lro.Value; + bool result = await collection.ExistsAsync(agentPoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryAgentPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AgentPoolsList() + public async Task GetIfExists_AgentPoolsGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/AgentPoolsList.json - // this example is just showing the usage of "AgentPools_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/AgentPoolsGet.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +184,23 @@ public async Task GetAll_AgentPoolsList() // get the collection of this ContainerRegistryAgentPoolResource ContainerRegistryAgentPoolCollection collection = containerRegistry.GetContainerRegistryAgentPools(); - // invoke the operation and iterate over the result - await foreach (ContainerRegistryAgentPoolResource item in collection.GetAllAsync()) + // invoke the operation + string agentPoolName = "myAgentPool"; + NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); + ContainerRegistryAgentPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerRegistryAgentPoolData resourceData = item.Data; + ContainerRegistryAgentPoolData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryAgentPoolResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryAgentPoolResource.cs index c5155369ce937..5ffb01eff778f 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryAgentPoolResource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryAgentPoolResource.cs @@ -96,7 +96,7 @@ public async Task Update_AgentPoolsUpdate() ContainerRegistryAgentPoolResource containerRegistryAgentPool = client.GetContainerRegistryAgentPoolResource(containerRegistryAgentPoolResourceId); // invoke the operation - ContainerRegistryAgentPoolPatch patch = new ContainerRegistryAgentPoolPatch() + ContainerRegistryAgentPoolPatch patch = new ContainerRegistryAgentPoolPatch { Count = 1, }; diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryCollection.cs index c0e50bfaf66b4..1b88aeb8431f6 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ContainerRegistryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RegistryListByResourceGroup() + public async Task CreateOrUpdate_RegistryCreate() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryListByResourceGroup.json - // this example is just showing the usage of "Registries_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryCreate.json + // this example is just showing the usage of "Registries_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,32 @@ public async Task GetAll_RegistryListByResourceGroup() // get the collection of this ContainerRegistryResource ContainerRegistryCollection collection = resourceGroupResource.GetContainerRegistries(); - // invoke the operation and iterate over the result - await foreach (ContainerRegistryResource item in collection.GetAllAsync()) + // invoke the operation + string registryName = "myRegistry"; + ContainerRegistryData data = new ContainerRegistryData(new AzureLocation("westus"), new ContainerRegistrySku(ContainerRegistrySkuName.Standard)) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsAdminUserEnabled = true, + Tags = +{ +["key"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registryName, data); + ContainerRegistryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RegistryGet() + public async Task CreateOrUpdate_RegistryCreateZoneRedundant() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryGet.json - // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryCreateZoneRedundant.json + // this example is just showing the usage of "Registries_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +83,16 @@ public async Task Get_RegistryGet() // invoke the operation string registryName = "myRegistry"; - ContainerRegistryResource result = await collection.GetAsync(registryName); + ContainerRegistryData data = new ContainerRegistryData(new AzureLocation("westus"), new ContainerRegistrySku(ContainerRegistrySkuName.Standard)) + { + ZoneRedundancy = ContainerRegistryZoneRedundancy.Enabled, + Tags = +{ +["key"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registryName, data); + ContainerRegistryResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +103,7 @@ public async Task Get_RegistryGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RegistryGet() + public async Task Get_RegistryGet() { // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryGet.json // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,17 +125,21 @@ public async Task Exists_RegistryGet() // invoke the operation string registryName = "myRegistry"; - bool result = await collection.ExistsAsync(registryName); + ContainerRegistryResource result = await collection.GetAsync(registryName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RegistryGet() + public async Task GetAll_RegistryListByResourceGroup() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryGet.json - // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryListByResourceGroup.json + // this example is just showing the usage of "Registries_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,31 +156,25 @@ public async Task GetIfExists_RegistryGet() // get the collection of this ContainerRegistryResource ContainerRegistryCollection collection = resourceGroupResource.GetContainerRegistries(); - // invoke the operation - string registryName = "myRegistry"; - NullableResponse response = await collection.GetIfExistsAsync(registryName); - ContainerRegistryResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ContainerRegistryResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerRegistryData resourceData = result.Data; + ContainerRegistryData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RegistryCreate() + public async Task Exists_RegistryGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryCreate.json - // this example is just showing the usage of "Registries_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryGet.json + // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,30 +193,17 @@ public async Task CreateOrUpdate_RegistryCreate() // invoke the operation string registryName = "myRegistry"; - ContainerRegistryData data = new ContainerRegistryData(new AzureLocation("westus"), new ContainerRegistrySku(ContainerRegistrySkuName.Standard)) - { - IsAdminUserEnabled = true, - Tags = -{ -["key"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registryName, data); - ContainerRegistryResource result = lro.Value; + bool result = await collection.ExistsAsync(registryName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RegistryCreateZoneRedundant() + public async Task GetIfExists_RegistryGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryCreateZoneRedundant.json - // this example is just showing the usage of "Registries_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryGet.json + // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -221,22 +222,21 @@ public async Task CreateOrUpdate_RegistryCreateZoneRedundant() // invoke the operation string registryName = "myRegistry"; - ContainerRegistryData data = new ContainerRegistryData(new AzureLocation("westus"), new ContainerRegistrySku(ContainerRegistrySkuName.Standard)) - { - ZoneRedundancy = ContainerRegistryZoneRedundancy.Enabled, - Tags = -{ -["key"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registryName, data); - ContainerRegistryResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(registryName); + ContainerRegistryResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateEndpointConnectionCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateEndpointConnectionCollection.cs index da6f45d06277f..a50d8578dcc66 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateEndpointConnectionCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerRegistryPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionList() + public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionList.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionCreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_PrivateEndpointConnectionList() // get the collection of this ContainerRegistryPrivateEndpointConnectionResource ContainerRegistryPrivateEndpointConnectionCollection collection = containerRegistry.GetContainerRegistryPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (ContainerRegistryPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "myConnection"; + ContainerRegistryPrivateEndpointConnectionData data = new ContainerRegistryPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new ContainerRegistryPrivateLinkServiceConnectionState + { + Status = ContainerRegistryPrivateLinkServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + ContainerRegistryPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_PrivateEndpointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionGet() + public async Task GetAll_PrivateEndpointConnectionList() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionList.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_PrivateEndpointConnectionGet() // get the collection of this ContainerRegistryPrivateEndpointConnectionResource ContainerRegistryPrivateEndpointConnectionCollection collection = containerRegistry.GetContainerRegistryPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "myConnection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (ContainerRegistryPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionGet() + public async Task Exists_PrivateEndpointConnectionGet() { // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_PrivateEndpointConnectionGet() // invoke the operation string privateEndpointConnectionName = "myConnection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - ContainerRegistryPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() + public async Task GetIfExists_PrivateEndpointConnectionGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionCreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionCreateOrUpdate() // invoke the operation string privateEndpointConnectionName = "myConnection"; - ContainerRegistryPrivateEndpointConnectionData data = new ContainerRegistryPrivateEndpointConnectionData() - { - ConnectionState = new ContainerRegistryPrivateLinkServiceConnectionState() - { - Status = ContainerRegistryPrivateLinkServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - ContainerRegistryPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + ContainerRegistryPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateEndpointConnectionResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateEndpointConnectionResource.cs index 14ddc2a64da5d..483dbf7ce61fe 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateEndpointConnectionResource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionCreateOrUpdate() + public async Task Delete_PrivateEndpointConnectionDelete() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionCreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionDelete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_PrivateEndpointConnectionCreateOrUpdate() ContainerRegistryPrivateEndpointConnectionResource containerRegistryPrivateEndpointConnection = client.GetContainerRegistryPrivateEndpointConnectionResource(containerRegistryPrivateEndpointConnectionResourceId); // invoke the operation - ContainerRegistryPrivateEndpointConnectionData data = new ContainerRegistryPrivateEndpointConnectionData() - { - ConnectionState = new ContainerRegistryPrivateLinkServiceConnectionState() - { - Status = ContainerRegistryPrivateLinkServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await containerRegistryPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - ContainerRegistryPrivateEndpointConnectionResource result = lro.Value; + await containerRegistryPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionDelete() + public async Task Update_PrivateEndpointConnectionCreateOrUpdate() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionDelete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/PrivateEndpointConnectionCreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_PrivateEndpointConnectionDelete() ContainerRegistryPrivateEndpointConnectionResource containerRegistryPrivateEndpointConnection = client.GetContainerRegistryPrivateEndpointConnectionResource(containerRegistryPrivateEndpointConnectionResourceId); // invoke the operation - await containerRegistryPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + ContainerRegistryPrivateEndpointConnectionData data = new ContainerRegistryPrivateEndpointConnectionData + { + ConnectionState = new ContainerRegistryPrivateLinkServiceConnectionState + { + Status = ContainerRegistryPrivateLinkServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await containerRegistryPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ContainerRegistryPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateLinkResourceCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateLinkResourceCollection.cs index 08ac0e431a777..d5e4f07a6899c 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateLinkResourceCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerRegistryPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RegistryListPrivateLinkResources() + public async Task Get_RegistryGetPrivateLinkResource() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryListPrivateLinkResources.json - // this example is just showing the usage of "Registries_ListPrivateLinkResources" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryGetPrivateLinkResource.json + // this example is just showing the usage of "Registries_GetPrivateLinkResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_RegistryListPrivateLinkResources() // get the collection of this ContainerRegistryPrivateLinkResource ContainerRegistryPrivateLinkResourceCollection collection = containerRegistry.GetContainerRegistryPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (ContainerRegistryPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "registry"; + ContainerRegistryPrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RegistryGetPrivateLinkResource() + public async Task GetAll_RegistryListPrivateLinkResources() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryGetPrivateLinkResource.json - // this example is just showing the usage of "Registries_GetPrivateLinkResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryListPrivateLinkResources.json + // this example is just showing the usage of "Registries_ListPrivateLinkResources" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_RegistryGetPrivateLinkResource() // get the collection of this ContainerRegistryPrivateLinkResource ContainerRegistryPrivateLinkResourceCollection collection = containerRegistry.GetContainerRegistryPrivateLinkResources(); - // invoke the operation - string groupName = "registry"; - ContainerRegistryPrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (ContainerRegistryPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryReplicationCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryReplicationCollection.cs index d26af5fe03ef8..a51d6410d08f0 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryReplicationCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryReplicationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerRegistryReplicationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ReplicationList() + public async Task CreateOrUpdate_ReplicationCreate() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationList.json - // this example is just showing the usage of "Replications_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationCreate.json + // this example is just showing the usage of "Replications_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,31 @@ public async Task GetAll_ReplicationList() // get the collection of this ContainerRegistryReplicationResource ContainerRegistryReplicationCollection collection = containerRegistry.GetContainerRegistryReplications(); - // invoke the operation and iterate over the result - await foreach (ContainerRegistryReplicationResource item in collection.GetAllAsync()) + // invoke the operation + string replicationName = "myReplication"; + ContainerRegistryReplicationData data = new ContainerRegistryReplicationData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryReplicationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, replicationName, data); + ContainerRegistryReplicationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryReplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ReplicationGet() + public async Task CreateOrUpdate_ReplicationCreateZoneRedundant() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationGet.json - // this example is just showing the usage of "Replications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationCreateZoneRedundant.json + // this example is just showing the usage of "Replications_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +83,17 @@ public async Task Get_ReplicationGet() // invoke the operation string replicationName = "myReplication"; - ContainerRegistryReplicationResource result = await collection.GetAsync(replicationName); + ContainerRegistryReplicationData data = new ContainerRegistryReplicationData(new AzureLocation("eastus")) + { + IsRegionEndpointEnabled = true, + ZoneRedundancy = ContainerRegistryZoneRedundancy.Enabled, + Tags = +{ +["key"] = "value" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, replicationName, data); + ContainerRegistryReplicationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +104,7 @@ public async Task Get_ReplicationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ReplicationGet() + public async Task Get_ReplicationGet() { // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationGet.json // this example is just showing the usage of "Replications_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +127,21 @@ public async Task Exists_ReplicationGet() // invoke the operation string replicationName = "myReplication"; - bool result = await collection.ExistsAsync(replicationName); + ContainerRegistryReplicationResource result = await collection.GetAsync(replicationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryReplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ReplicationGet() + public async Task GetAll_ReplicationList() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationGet.json - // this example is just showing the usage of "Replications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationList.json + // this example is just showing the usage of "Replications_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +159,25 @@ public async Task GetIfExists_ReplicationGet() // get the collection of this ContainerRegistryReplicationResource ContainerRegistryReplicationCollection collection = containerRegistry.GetContainerRegistryReplications(); - // invoke the operation - string replicationName = "myReplication"; - NullableResponse response = await collection.GetIfExistsAsync(replicationName); - ContainerRegistryReplicationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ContainerRegistryReplicationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerRegistryReplicationData resourceData = result.Data; + ContainerRegistryReplicationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ReplicationCreate() + public async Task Exists_ReplicationGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationCreate.json - // this example is just showing the usage of "Replications_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationGet.json + // this example is just showing the usage of "Replications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,29 +197,17 @@ public async Task CreateOrUpdate_ReplicationCreate() // invoke the operation string replicationName = "myReplication"; - ContainerRegistryReplicationData data = new ContainerRegistryReplicationData(new AzureLocation("eastus")) - { - Tags = -{ -["key"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, replicationName, data); - ContainerRegistryReplicationResource result = lro.Value; + bool result = await collection.ExistsAsync(replicationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryReplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ReplicationCreateZoneRedundant() + public async Task GetIfExists_ReplicationGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationCreateZoneRedundant.json - // this example is just showing the usage of "Replications_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ReplicationGet.json + // this example is just showing the usage of "Replications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -225,23 +227,21 @@ public async Task CreateOrUpdate_ReplicationCreateZoneRedundant() // invoke the operation string replicationName = "myReplication"; - ContainerRegistryReplicationData data = new ContainerRegistryReplicationData(new AzureLocation("eastus")) - { - IsRegionEndpointEnabled = true, - ZoneRedundancy = ContainerRegistryZoneRedundancy.Enabled, - Tags = -{ -["key"] = "value", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, replicationName, data); - ContainerRegistryReplicationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(replicationName); + ContainerRegistryReplicationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryReplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryReplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryReplicationResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryReplicationResource.cs index c996d2e423e2f..c924e5188f4d7 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryReplicationResource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryReplicationResource.cs @@ -96,11 +96,11 @@ public async Task Update_ReplicationUpdate() ContainerRegistryReplicationResource containerRegistryReplication = client.GetContainerRegistryReplicationResource(containerRegistryReplicationResourceId); // invoke the operation - ContainerRegistryReplicationPatch patch = new ContainerRegistryReplicationPatch() + ContainerRegistryReplicationPatch patch = new ContainerRegistryReplicationPatch { Tags = { -["key"] = "value", +["key"] = "value" }, }; ArmOperation lro = await containerRegistryReplication.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryResource.cs index 3cbc3f7532c69..7b11dcb271bf4 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryResource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ContainerRegistry.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ContainerRegistry.Samples @@ -19,10 +18,10 @@ public partial class Sample_ContainerRegistryResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task ImportImage_ImportImageByManifestDigest() + public async Task Get_RegistryGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ImportImageByManifestDigest.json - // this example is just showing the usage of "Registries_ImportImage" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryGet.json + // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,32 +37,21 @@ public async Task ImportImage_ImportImageByManifestDigest() ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); // invoke the operation - ContainerRegistryImportImageContent content = new ContainerRegistryImportImageContent(new ContainerRegistryImportSource("sourceRepository@sha256:0000000000000000000000000000000000000000000000000000000000000000") - { - ResourceId = new ResourceIdentifier("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/sourceResourceGroup/providers/Microsoft.ContainerRegistry/registries/sourceRegistry"), - }) - { - TargetTags = -{ -"targetRepository:targetTag" -}, - UntaggedTargetRepositories = -{ -"targetRepository1" -}, - Mode = ContainerRegistryImportMode.Force, - }; - await containerRegistry.ImportImageAsync(WaitUntil.Completed, content); + ContainerRegistryResource result = await containerRegistry.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ImportImage_ImportImageByTag() + public async Task Delete_RegistryDelete() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ImportImageByTag.json - // this example is just showing the usage of "Registries_ImportImage" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryDelete.json + // this example is just showing the usage of "Registries_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,32 +67,17 @@ public async Task ImportImage_ImportImageByTag() ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); // invoke the operation - ContainerRegistryImportImageContent content = new ContainerRegistryImportImageContent(new ContainerRegistryImportSource("sourceRepository:sourceTag") - { - ResourceId = new ResourceIdentifier("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/sourceResourceGroup/providers/Microsoft.ContainerRegistry/registries/sourceRegistry"), - }) - { - TargetTags = -{ -"targetRepository:targetTag" -}, - UntaggedTargetRepositories = -{ -"targetRepository1" -}, - Mode = ContainerRegistryImportMode.Force, - }; - await containerRegistry.ImportImageAsync(WaitUntil.Completed, content); + await containerRegistry.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ImportImage_ImportImageFromPublicRegistry() + public async Task Update_RegistryUpdate() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ImportImageFromPublicRegistry.json - // this example is just showing the usage of "Registries_ImportImage" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryUpdate.json + // this example is just showing the usage of "Registries_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,113 +93,31 @@ public async Task ImportImage_ImportImageFromPublicRegistry() ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); // invoke the operation - ContainerRegistryImportImageContent content = new ContainerRegistryImportImageContent(new ContainerRegistryImportSource("library/hello-world") - { - RegistryAddress = "registry.hub.docker.com", - }) + ContainerRegistryPatch patch = new ContainerRegistryPatch { - TargetTags = -{ -"targetRepository:targetTag" -}, - UntaggedTargetRepositories = + Tags = { -"targetRepository1" +["key"] = "value" }, - Mode = ContainerRegistryImportMode.Force, + Sku = new ContainerRegistrySku(ContainerRegistrySkuName.Standard), + IsAdminUserEnabled = true, }; - await containerRegistry.ImportImageAsync(WaitUntil.Completed, content); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckContainerRegistryNameAvailability_RegistryCheckNameAvailable() - { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryCheckNameAvailable.json - // this example is just showing the usage of "Registries_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - ContainerRegistryNameAvailabilityContent content = new ContainerRegistryNameAvailabilityContent("myRegistry"); - ContainerRegistryNameAvailableResult result = await subscriptionResource.CheckContainerRegistryNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckContainerRegistryNameAvailability_RegistryCheckNameNotAvailable() - { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryCheckNameNotAvailable.json - // this example is just showing the usage of "Registries_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - ContainerRegistryNameAvailabilityContent content = new ContainerRegistryNameAvailabilityContent("myRegistry"); - ContainerRegistryNameAvailableResult result = await subscriptionResource.CheckContainerRegistryNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetContainerRegistries_RegistryList() - { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryList.json - // this example is just showing the usage of "Registries_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ContainerRegistryResource item in subscriptionResource.GetContainerRegistriesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ArmOperation lro = await containerRegistry.UpdateAsync(WaitUntil.Completed, patch); + ContainerRegistryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RegistryGet() + public async Task ImportImage_ImportImageByManifestDigest() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryGet.json - // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ImportImageByManifestDigest.json + // this example is just showing the usage of "Registries_ImportImage" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -242,21 +133,26 @@ public async Task Get_RegistryGet() ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); // invoke the operation - ContainerRegistryResource result = await containerRegistry.GetAsync(); + ContainerRegistryImportImageContent content = new ContainerRegistryImportImageContent(new ContainerRegistryImportSource("sourceRepository@sha256:0000000000000000000000000000000000000000000000000000000000000000") + { + ResourceId = new ResourceIdentifier("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/sourceResourceGroup/providers/Microsoft.ContainerRegistry/registries/sourceRegistry"), + }) + { + TargetTags = { "targetRepository:targetTag" }, + UntaggedTargetRepositories = { "targetRepository1" }, + Mode = ContainerRegistryImportMode.Force, + }; + await containerRegistry.ImportImageAsync(WaitUntil.Completed, content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RegistryDelete() + public async Task ImportImage_ImportImageByTag() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryDelete.json - // this example is just showing the usage of "Registries_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ImportImageByTag.json + // this example is just showing the usage of "Registries_ImportImage" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -272,17 +168,26 @@ public async Task Delete_RegistryDelete() ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); // invoke the operation - await containerRegistry.DeleteAsync(WaitUntil.Completed); + ContainerRegistryImportImageContent content = new ContainerRegistryImportImageContent(new ContainerRegistryImportSource("sourceRepository:sourceTag") + { + ResourceId = new ResourceIdentifier("/subscriptions/10000000-0000-0000-0000-000000000000/resourceGroups/sourceResourceGroup/providers/Microsoft.ContainerRegistry/registries/sourceRegistry"), + }) + { + TargetTags = { "targetRepository:targetTag" }, + UntaggedTargetRepositories = { "targetRepository1" }, + Mode = ContainerRegistryImportMode.Force, + }; + await containerRegistry.ImportImageAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RegistryUpdate() + public async Task ImportImage_ImportImageFromPublicRegistry() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryUpdate.json - // this example is just showing the usage of "Registries_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ImportImageFromPublicRegistry.json + // this example is just showing the usage of "Registries_ImportImage" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -298,23 +203,18 @@ public async Task Update_RegistryUpdate() ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); // invoke the operation - ContainerRegistryPatch patch = new ContainerRegistryPatch() + ContainerRegistryImportImageContent content = new ContainerRegistryImportImageContent(new ContainerRegistryImportSource("library/hello-world") { - Tags = -{ -["key"] = "value", -}, - Sku = new ContainerRegistrySku(ContainerRegistrySkuName.Standard), - IsAdminUserEnabled = true, + RegistryAddress = "registry.hub.docker.com", + }) + { + TargetTags = { "targetRepository:targetTag" }, + UntaggedTargetRepositories = { "targetRepository1" }, + Mode = ContainerRegistryImportMode.Force, }; - ArmOperation lro = await containerRegistry.UpdateAsync(WaitUntil.Completed, patch); - ContainerRegistryResource result = lro.Value; + await containerRegistry.ImportImageAsync(WaitUntil.Completed, content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -420,7 +320,7 @@ public async Task GenerateCredentials_RegistryGenerateCredentials() ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); // invoke the operation - ContainerRegistryGenerateCredentialsContent content = new ContainerRegistryGenerateCredentialsContent() + ContainerRegistryGenerateCredentialsContent content = new ContainerRegistryGenerateCredentialsContent { TokenId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/tokens/myToken"), ExpireOn = DateTimeOffset.Parse("2020-12-31T15:59:59.0707808Z"), @@ -457,22 +357,16 @@ public async Task ScheduleRun_RegistriesScheduleRun() Architecture = ContainerRegistryOSArchitecture.Amd64, }) { - ImageNames = -{ -"azurerest:testtag" -}, + ImageNames = { "azurerest:testtag" }, IsPushEnabled = true, NoCache = true, - Arguments = -{ -new ContainerRegistryRunArgument("mytestargument","mytestvalue") + Arguments = {new ContainerRegistryRunArgument("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryRunArgument("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryRunArgument("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, AgentCpu = 2, SourceLocation = "https://myaccount.blob.core.windows.net/sascontainer/source.zip?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D", IsArchiveEnabled = true, @@ -511,16 +405,13 @@ public async Task ScheduleRun_RegistriesScheduleRunEncodedTaskRun() ContainerRegistryRunContent content = new ContainerRegistryEncodedTaskRunContent("c3RlcHM6Cnt7IGlmIFZhbHVlcy5lbnZpcm9ubWVudCA9PSAncHJvZCcgfX0KICAtIHJ1bjogcHJvZCBzZXR1cAp7eyBlbHNlIGlmIFZhbHVlcy5lbnZpcm9ubWVudCA9PSAnc3RhZ2luZycgfX0KICAtIHJ1bjogc3RhZ2luZyBzZXR1cAp7eyBlbHNlIH19CiAgLSBydW46IGRlZmF1bHQgc2V0dXAKe3sgZW5kIH19CgogIC0gcnVuOiBidWlsZCAtdCBGYW5jeVRoaW5nOnt7LlZhbHVlcy5lbnZpcm9ubWVudH19LXt7LlZhbHVlcy52ZXJzaW9ufX0gLgoKcHVzaDogWydGYW5jeVRoaW5nOnt7LlZhbHVlcy5lbnZpcm9ubWVudH19LXt7LlZhbHVlcy52ZXJzaW9ufX0nXQ==", new ContainerRegistryPlatformProperties(ContainerRegistryOS.Linux)) { EncodedValuesContent = "ZW52aXJvbm1lbnQ6IHByb2QKdmVyc2lvbjogMQ==", - Values = -{ -new ContainerRegistryTaskOverridableValue("mytestargument","mytestvalue") + Values = {new ContainerRegistryTaskOverridableValue("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryTaskOverridableValue("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryTaskOverridableValue("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, AgentCpu = 2, }; ArmOperation lro = await containerRegistry.ScheduleRunAsync(WaitUntil.Completed, content); @@ -557,16 +448,13 @@ public async Task ScheduleRun_RegistriesScheduleRunFileTaskRun() ContainerRegistryRunContent content = new ContainerRegistryFileTaskRunContent("acb.yaml", new ContainerRegistryPlatformProperties(ContainerRegistryOS.Linux)) { ValuesFilePath = "prod-values.yaml", - Values = -{ -new ContainerRegistryTaskOverridableValue("mytestargument","mytestvalue") + Values = {new ContainerRegistryTaskOverridableValue("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryTaskOverridableValue("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryTaskOverridableValue("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, AgentCpu = 2, SourceLocation = "https://myaccount.blob.core.windows.net/sascontainer/source.zip?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D", }; @@ -603,30 +491,24 @@ public async Task ScheduleRun_RegistriesScheduleRunTask() // invoke the operation ContainerRegistryRunContent content = new ContainerRegistryTaskRunContent(new ResourceIdentifier("myTask")) { - OverrideTaskStepProperties = new ContainerRegistryOverrideTaskStepProperties() + OverrideTaskStepProperties = new ContainerRegistryOverrideTaskStepProperties { File = "overriddenDockerfile", - Arguments = -{ -new ContainerRegistryRunArgument("mytestargument","mytestvalue") + Arguments = {new ContainerRegistryRunArgument("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryRunArgument("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryRunArgument("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, Target = "build", - Values = -{ -new ContainerRegistryTaskOverridableValue("mytestname","mytestvalue") + Values = {new ContainerRegistryTaskOverridableValue("mytestname", "mytestvalue") { IsSecret = false, -},new ContainerRegistryTaskOverridableValue("mysecrettestname","mysecrettestvalue") +}, new ContainerRegistryTaskOverridableValue("mysecrettestname", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, UpdateTriggerToken = "aGVsbG8gd29ybGQ=", }, }; @@ -663,34 +545,31 @@ public async Task ScheduleRun_RegistriesScheduleRunTaskWithCustomCredentials() // invoke the operation ContainerRegistryRunContent content = new ContainerRegistryFileTaskRunContent("acb.yaml", new ContainerRegistryPlatformProperties(ContainerRegistryOS.Linux)) { - Values = -{ -new ContainerRegistryTaskOverridableValue("mytestargument","mytestvalue") + Values = {new ContainerRegistryTaskOverridableValue("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryTaskOverridableValue("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryTaskOverridableValue("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, - Credentials = new ContainerRegistryCredentials() +}}, + Credentials = new ContainerRegistryCredentials { SourceRegistryLoginMode = SourceRegistryLoginMode.Default, CustomRegistries = { -["myregistry.azurecr.io"] = new CustomRegistryCredentials() +["myregistry.azurecr.io"] = new CustomRegistryCredentials { -UserName = new ContainerRegistrySecretObject() +UserName = new ContainerRegistrySecretObject { Value = "reg1", ObjectType = ContainerRegistrySecretObjectType.Opaque, }, -Password = new ContainerRegistrySecretObject() +Password = new ContainerRegistrySecretObject { Value = "***", ObjectType = ContainerRegistrySecretObjectType.Opaque, }, -}, +} }, }, }; @@ -730,56 +609,50 @@ public async Task ScheduleRun_RegistriesScheduleRunWithCustomCredentials() Architecture = ContainerRegistryOSArchitecture.Amd64, }) { - ImageNames = -{ -"azurerest:testtag" -}, + ImageNames = { "azurerest:testtag" }, IsPushEnabled = true, NoCache = true, Target = "stage1", - Arguments = -{ -new ContainerRegistryRunArgument("mytestargument","mytestvalue") + Arguments = {new ContainerRegistryRunArgument("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryRunArgument("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryRunArgument("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, AgentCpu = 2, SourceLocation = "https://myaccount.blob.core.windows.net/sascontainer/source.zip?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D", - Credentials = new ContainerRegistryCredentials() + Credentials = new ContainerRegistryCredentials { SourceRegistryLoginMode = SourceRegistryLoginMode.Default, CustomRegistries = { -["myregistry.azurecr.io"] = new CustomRegistryCredentials() +["myregistry.azurecr.io"] = new CustomRegistryCredentials { -UserName = new ContainerRegistrySecretObject() +UserName = new ContainerRegistrySecretObject { Value = "reg1", ObjectType = ContainerRegistrySecretObjectType.Opaque, }, -Password = new ContainerRegistrySecretObject() +Password = new ContainerRegistrySecretObject { Value = "***", ObjectType = ContainerRegistrySecretObjectType.Opaque, }, }, -["myregistry2.azurecr.io"] = new CustomRegistryCredentials() +["myregistry2.azurecr.io"] = new CustomRegistryCredentials { -UserName = new ContainerRegistrySecretObject() +UserName = new ContainerRegistrySecretObject { Value = "reg2", ObjectType = ContainerRegistrySecretObjectType.Opaque, }, -Password = new ContainerRegistrySecretObject() +Password = new ContainerRegistrySecretObject { Value = "***", ObjectType = ContainerRegistrySecretObjectType.Opaque, }, -}, +} }, }, IsArchiveEnabled = true, @@ -820,22 +693,16 @@ public async Task ScheduleRun_RegistriesScheduleRunWithLogTemplate() Architecture = ContainerRegistryOSArchitecture.Amd64, }) { - ImageNames = -{ -"azurerest:testtag" -}, + ImageNames = { "azurerest:testtag" }, IsPushEnabled = true, NoCache = true, - Arguments = -{ -new ContainerRegistryRunArgument("mytestargument","mytestvalue") + Arguments = {new ContainerRegistryRunArgument("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryRunArgument("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryRunArgument("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, AgentCpu = 2, SourceLocation = "https://myaccount.blob.core.windows.net/sascontainer/source.zip?sv=2015-04-05&st=2015-04-29T22%3A18%3A26Z&se=2015-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=Z%2FRHIX5Xcg0Mq2rqI3OlWTjEg2tYkboXr1P9ZUXDtkk%3D", IsArchiveEnabled = true, diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryRunCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryRunCollection.cs index 05f6f8fd8537e..e356684afd7da 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryRunCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryRunCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerRegistryRunCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RunsList() + public async Task Get_RunsGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/RunsList.json - // this example is just showing the usage of "Runs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/RunsGet.json + // this example is just showing the usage of "Runs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,27 +38,23 @@ public async Task GetAll_RunsList() // get the collection of this ContainerRegistryRunResource ContainerRegistryRunCollection collection = containerRegistry.GetContainerRegistryRuns(); - // invoke the operation and iterate over the result - string filter = ""; - int? top = 10; - await foreach (ContainerRegistryRunResource item in collection.GetAllAsync(filter: filter, top: top)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryRunData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string runId = "0accec26-d6de-4757-8e74-d080f38eaaab"; + ContainerRegistryRunResource result = await collection.GetAsync(runId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryRunData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RunsGet() + public async Task GetAll_RunsList() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/RunsGet.json - // this example is just showing the usage of "Runs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/RunsList.json + // this example is just showing the usage of "Runs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +72,19 @@ public async Task Get_RunsGet() // get the collection of this ContainerRegistryRunResource ContainerRegistryRunCollection collection = containerRegistry.GetContainerRegistryRuns(); - // invoke the operation - string runId = "0accec26-d6de-4757-8e74-d080f38eaaab"; - ContainerRegistryRunResource result = await collection.GetAsync(runId); + // invoke the operation and iterate over the result + string filter = ""; + int? top = 10; + await foreach (ContainerRegistryRunResource item in collection.GetAllAsync(filter: filter, top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryRunData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryRunData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryRunResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryRunResource.cs index fdc7815d31aa5..a17617db5d2b8 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryRunResource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryRunResource.cs @@ -69,7 +69,7 @@ public async Task Update_RunsUpdate() ContainerRegistryRunResource containerRegistryRun = client.GetContainerRegistryRunResource(containerRegistryRunResourceId); // invoke the operation - ContainerRegistryRunPatch patch = new ContainerRegistryRunPatch() + ContainerRegistryRunPatch patch = new ContainerRegistryRunPatch { IsArchiveEnabled = true, }; diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskCollection.cs index 07424098460c6..66b7166807366 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskCollection.cs @@ -17,148 +17,6 @@ namespace Azure.ResourceManager.ContainerRegistry.Samples { public partial class Sample_ContainerRegistryTaskCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_TasksList() - { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TasksList.json - // this example is just showing the usage of "Tasks_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerRegistryResource created on azure - // for more information of creating ContainerRegistryResource, please refer to the document of ContainerRegistryResource - string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; - string resourceGroupName = "myResourceGroup"; - string registryName = "myRegistry"; - ResourceIdentifier containerRegistryResourceId = ContainerRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName); - ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); - - // get the collection of this ContainerRegistryTaskResource - ContainerRegistryTaskCollection collection = containerRegistry.GetContainerRegistryTasks(); - - // invoke the operation and iterate over the result - await foreach (ContainerRegistryTaskResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryTaskData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_TasksGet() - { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TasksGet.json - // this example is just showing the usage of "Tasks_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerRegistryResource created on azure - // for more information of creating ContainerRegistryResource, please refer to the document of ContainerRegistryResource - string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; - string resourceGroupName = "myResourceGroup"; - string registryName = "myRegistry"; - ResourceIdentifier containerRegistryResourceId = ContainerRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName); - ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); - - // get the collection of this ContainerRegistryTaskResource - ContainerRegistryTaskCollection collection = containerRegistry.GetContainerRegistryTasks(); - - // invoke the operation - string taskName = "myTask"; - ContainerRegistryTaskResource result = await collection.GetAsync(taskName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryTaskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_TasksGet() - { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TasksGet.json - // this example is just showing the usage of "Tasks_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerRegistryResource created on azure - // for more information of creating ContainerRegistryResource, please refer to the document of ContainerRegistryResource - string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; - string resourceGroupName = "myResourceGroup"; - string registryName = "myRegistry"; - ResourceIdentifier containerRegistryResourceId = ContainerRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName); - ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); - - // get the collection of this ContainerRegistryTaskResource - ContainerRegistryTaskCollection collection = containerRegistry.GetContainerRegistryTasks(); - - // invoke the operation - string taskName = "myTask"; - bool result = await collection.ExistsAsync(taskName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TasksGet() - { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TasksGet.json - // this example is just showing the usage of "Tasks_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerRegistryResource created on azure - // for more information of creating ContainerRegistryResource, please refer to the document of ContainerRegistryResource - string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; - string resourceGroupName = "myResourceGroup"; - string registryName = "myRegistry"; - ResourceIdentifier containerRegistryResourceId = ContainerRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName); - ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); - - // get the collection of this ContainerRegistryTaskResource - ContainerRegistryTaskCollection collection = containerRegistry.GetContainerRegistryTasks(); - - // invoke the operation - string taskName = "myTask"; - NullableResponse response = await collection.GetIfExistsAsync(taskName); - ContainerRegistryTaskResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryTaskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_TasksCreate() @@ -195,41 +53,26 @@ public async Task CreateOrUpdate_TasksCreate() AgentCpu = 2, Step = new ContainerRegistryDockerBuildStep("src/DockerFile") { - ImageNames = -{ -"azurerest:testtag" -}, + ImageNames = { "azurerest:testtag" }, IsPushEnabled = true, NoCache = false, - Arguments = -{ -new ContainerRegistryRunArgument("mytestargument","mytestvalue") + Arguments = {new ContainerRegistryRunArgument("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryRunArgument("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryRunArgument("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, ContextPath = "src", }, - Trigger = new ContainerRegistryTriggerProperties() + Trigger = new ContainerRegistryTriggerProperties { - TimerTriggers = -{ -new ContainerRegistryTimerTrigger("30 9 * * 1-5","myTimerTrigger") -}, - SourceTriggers = -{ -new ContainerRegistrySourceTrigger(new SourceCodeRepoProperties(SourceControlType.Github,new Uri("https://github.com/Azure/azure-rest-api-specs")) + TimerTriggers = { new ContainerRegistryTimerTrigger("30 9 * * 1-5", "myTimerTrigger") }, + SourceTriggers = {new ContainerRegistrySourceTrigger(new SourceCodeRepoProperties(SourceControlType.Github, new Uri("https://github.com/Azure/azure-rest-api-specs")) { Branch = "master", -SourceControlAuthProperties = new SourceCodeRepoAuthInfo(SourceCodeRepoAuthTokenType.Pat,"xxxxx"), -},new ContainerRegistrySourceTriggerEvent[] -{ -ContainerRegistrySourceTriggerEvent.Commit -},"mySourceTrigger") -}, +SourceControlAuthProperties = new SourceCodeRepoAuthInfo(SourceCodeRepoAuthTokenType.Pat, "xxxxx"), +}, new ContainerRegistrySourceTriggerEvent[]{ContainerRegistrySourceTriggerEvent.Commit}, "mySourceTrigger")}, BaseImageTrigger = new ContainerRegistryBaseImageTrigger(ContainerRegistryBaseImageTriggerType.Runtime, "myBaseImageTrigger") { UpdateTriggerEndpoint = "https://user:pass@mycicd.webhook.com?token=foo", @@ -240,7 +83,7 @@ public async Task CreateOrUpdate_TasksCreate() IsSystemTask = false, Tags = { -["testkey"] = "value", +["testkey"] = "value" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, taskName, data); @@ -280,13 +123,13 @@ public async Task CreateOrUpdate_TasksCreateQuickTask() string taskName = "quicktask"; ContainerRegistryTaskData data = new ContainerRegistryTaskData(new AzureLocation("eastus")) { - Identity = null, + Identity = default, Status = ContainerRegistryTaskStatus.Enabled, LogTemplate = "acr/tasks:{{.Run.OS}}", IsSystemTask = true, Tags = { -["testkey"] = "value", +["testkey"] = "value" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, taskName, data); @@ -330,7 +173,7 @@ public async Task CreateOrUpdate_TasksCreateWithSystemAndUserIdentities() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2")] = new UserAssignedIdentity() }, }, Status = ContainerRegistryTaskStatus.Enabled, @@ -341,41 +184,26 @@ public async Task CreateOrUpdate_TasksCreateWithSystemAndUserIdentities() AgentCpu = 2, Step = new ContainerRegistryDockerBuildStep("src/DockerFile") { - ImageNames = -{ -"azurerest:testtag" -}, + ImageNames = { "azurerest:testtag" }, IsPushEnabled = true, NoCache = false, - Arguments = -{ -new ContainerRegistryRunArgument("mytestargument","mytestvalue") + Arguments = {new ContainerRegistryRunArgument("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryRunArgument("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryRunArgument("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, ContextPath = "src", }, - Trigger = new ContainerRegistryTriggerProperties() + Trigger = new ContainerRegistryTriggerProperties { - TimerTriggers = -{ -new ContainerRegistryTimerTrigger("30 9 * * 1-5","myTimerTrigger") -}, - SourceTriggers = -{ -new ContainerRegistrySourceTrigger(new SourceCodeRepoProperties(SourceControlType.Github,new Uri("https://github.com/Azure/azure-rest-api-specs")) + TimerTriggers = { new ContainerRegistryTimerTrigger("30 9 * * 1-5", "myTimerTrigger") }, + SourceTriggers = {new ContainerRegistrySourceTrigger(new SourceCodeRepoProperties(SourceControlType.Github, new Uri("https://github.com/Azure/azure-rest-api-specs")) { Branch = "master", -SourceControlAuthProperties = new SourceCodeRepoAuthInfo(SourceCodeRepoAuthTokenType.Pat,"xxxxx"), -},new ContainerRegistrySourceTriggerEvent[] -{ -ContainerRegistrySourceTriggerEvent.Commit -},"mySourceTrigger") -}, +SourceControlAuthProperties = new SourceCodeRepoAuthInfo(SourceCodeRepoAuthTokenType.Pat, "xxxxx"), +}, new ContainerRegistrySourceTriggerEvent[]{ContainerRegistrySourceTriggerEvent.Commit}, "mySourceTrigger")}, BaseImageTrigger = new ContainerRegistryBaseImageTrigger(ContainerRegistryBaseImageTriggerType.Runtime, "myBaseImageTrigger") { UpdateTriggerEndpoint = "https://user:pass@mycicd.webhook.com?token=foo", @@ -386,7 +214,7 @@ public async Task CreateOrUpdate_TasksCreateWithSystemAndUserIdentities() IsSystemTask = false, Tags = { -["testkey"] = "value", +["testkey"] = "value" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, taskName, data); @@ -431,7 +259,7 @@ public async Task CreateOrUpdate_TasksCreateWithUserIdentities() UserAssignedIdentities = { [new ResourceIdentifier("/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), -[new ResourceIdentifier("/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/f9d7ebed-adbd-4cb4-b973-aaf82c136138/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2")] = new UserAssignedIdentity() }, }, Status = ContainerRegistryTaskStatus.Enabled, @@ -442,41 +270,26 @@ public async Task CreateOrUpdate_TasksCreateWithUserIdentities() AgentCpu = 2, Step = new ContainerRegistryDockerBuildStep("src/DockerFile") { - ImageNames = -{ -"azurerest:testtag" -}, + ImageNames = { "azurerest:testtag" }, IsPushEnabled = true, NoCache = false, - Arguments = -{ -new ContainerRegistryRunArgument("mytestargument","mytestvalue") + Arguments = {new ContainerRegistryRunArgument("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryRunArgument("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryRunArgument("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, ContextPath = "src", }, - Trigger = new ContainerRegistryTriggerProperties() + Trigger = new ContainerRegistryTriggerProperties { - TimerTriggers = -{ -new ContainerRegistryTimerTrigger("30 9 * * 1-5","myTimerTrigger") -}, - SourceTriggers = -{ -new ContainerRegistrySourceTrigger(new SourceCodeRepoProperties(SourceControlType.Github,new Uri("https://github.com/Azure/azure-rest-api-specs")) + TimerTriggers = { new ContainerRegistryTimerTrigger("30 9 * * 1-5", "myTimerTrigger") }, + SourceTriggers = {new ContainerRegistrySourceTrigger(new SourceCodeRepoProperties(SourceControlType.Github, new Uri("https://github.com/Azure/azure-rest-api-specs")) { Branch = "master", -SourceControlAuthProperties = new SourceCodeRepoAuthInfo(SourceCodeRepoAuthTokenType.Pat,"xxxxx"), -},new ContainerRegistrySourceTriggerEvent[] -{ -ContainerRegistrySourceTriggerEvent.Commit -},"mySourceTrigger") -}, +SourceControlAuthProperties = new SourceCodeRepoAuthInfo(SourceCodeRepoAuthTokenType.Pat, "xxxxx"), +}, new ContainerRegistrySourceTriggerEvent[]{ContainerRegistrySourceTriggerEvent.Commit}, "mySourceTrigger")}, BaseImageTrigger = new ContainerRegistryBaseImageTrigger(ContainerRegistryBaseImageTriggerType.Runtime, "myBaseImageTrigger") { UpdateTriggerEndpoint = "https://user:pass@mycicd.webhook.com?token=foo", @@ -487,7 +300,7 @@ public async Task CreateOrUpdate_TasksCreateWithUserIdentities() IsSystemTask = false, Tags = { -["testkey"] = "value", +["testkey"] = "value" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, taskName, data); @@ -536,48 +349,33 @@ public async Task CreateOrUpdate_TasksCreateWithUserIdentitiesWithSystemIdentity AgentCpu = 2, Step = new ContainerRegistryDockerBuildStep("src/DockerFile") { - ImageNames = -{ -"azurerest:testtag" -}, + ImageNames = { "azurerest:testtag" }, IsPushEnabled = true, NoCache = false, - Arguments = -{ -new ContainerRegistryRunArgument("mytestargument","mytestvalue") + Arguments = {new ContainerRegistryRunArgument("mytestargument", "mytestvalue") { IsSecret = false, -},new ContainerRegistryRunArgument("mysecrettestargument","mysecrettestvalue") +}, new ContainerRegistryRunArgument("mysecrettestargument", "mysecrettestvalue") { IsSecret = true, -} -}, +}}, ContextPath = "src", }, - Trigger = new ContainerRegistryTriggerProperties() + Trigger = new ContainerRegistryTriggerProperties { - TimerTriggers = -{ -new ContainerRegistryTimerTrigger("30 9 * * 1-5","myTimerTrigger") -}, - SourceTriggers = -{ -new ContainerRegistrySourceTrigger(new SourceCodeRepoProperties(SourceControlType.Github,new Uri("https://github.com/Azure/azure-rest-api-specs")) + TimerTriggers = { new ContainerRegistryTimerTrigger("30 9 * * 1-5", "myTimerTrigger") }, + SourceTriggers = {new ContainerRegistrySourceTrigger(new SourceCodeRepoProperties(SourceControlType.Github, new Uri("https://github.com/Azure/azure-rest-api-specs")) { Branch = "master", -SourceControlAuthProperties = new SourceCodeRepoAuthInfo(SourceCodeRepoAuthTokenType.Pat,"xxxxx"), -},new ContainerRegistrySourceTriggerEvent[] -{ -ContainerRegistrySourceTriggerEvent.Commit -},"mySourceTrigger") -}, +SourceControlAuthProperties = new SourceCodeRepoAuthInfo(SourceCodeRepoAuthTokenType.Pat, "xxxxx"), +}, new ContainerRegistrySourceTriggerEvent[]{ContainerRegistrySourceTriggerEvent.Commit}, "mySourceTrigger")}, BaseImageTrigger = new ContainerRegistryBaseImageTrigger(ContainerRegistryBaseImageTriggerType.Runtime, "myBaseImageTrigger"), }, LogTemplate = null, IsSystemTask = false, Tags = { -["testkey"] = "value", +["testkey"] = "value" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, taskName, data); @@ -589,5 +387,147 @@ public async Task CreateOrUpdate_TasksCreateWithUserIdentitiesWithSystemIdentity // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_TasksGet() + { + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TasksGet.json + // this example is just showing the usage of "Tasks_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerRegistryResource created on azure + // for more information of creating ContainerRegistryResource, please refer to the document of ContainerRegistryResource + string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; + string resourceGroupName = "myResourceGroup"; + string registryName = "myRegistry"; + ResourceIdentifier containerRegistryResourceId = ContainerRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName); + ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); + + // get the collection of this ContainerRegistryTaskResource + ContainerRegistryTaskCollection collection = containerRegistry.GetContainerRegistryTasks(); + + // invoke the operation + string taskName = "myTask"; + ContainerRegistryTaskResource result = await collection.GetAsync(taskName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryTaskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_TasksList() + { + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TasksList.json + // this example is just showing the usage of "Tasks_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerRegistryResource created on azure + // for more information of creating ContainerRegistryResource, please refer to the document of ContainerRegistryResource + string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; + string resourceGroupName = "myResourceGroup"; + string registryName = "myRegistry"; + ResourceIdentifier containerRegistryResourceId = ContainerRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName); + ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); + + // get the collection of this ContainerRegistryTaskResource + ContainerRegistryTaskCollection collection = containerRegistry.GetContainerRegistryTasks(); + + // invoke the operation and iterate over the result + await foreach (ContainerRegistryTaskResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryTaskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_TasksGet() + { + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TasksGet.json + // this example is just showing the usage of "Tasks_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerRegistryResource created on azure + // for more information of creating ContainerRegistryResource, please refer to the document of ContainerRegistryResource + string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; + string resourceGroupName = "myResourceGroup"; + string registryName = "myRegistry"; + ResourceIdentifier containerRegistryResourceId = ContainerRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName); + ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); + + // get the collection of this ContainerRegistryTaskResource + ContainerRegistryTaskCollection collection = containerRegistry.GetContainerRegistryTasks(); + + // invoke the operation + string taskName = "myTask"; + bool result = await collection.ExistsAsync(taskName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_TasksGet() + { + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TasksGet.json + // this example is just showing the usage of "Tasks_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerRegistryResource created on azure + // for more information of creating ContainerRegistryResource, please refer to the document of ContainerRegistryResource + string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; + string resourceGroupName = "myResourceGroup"; + string registryName = "myRegistry"; + ResourceIdentifier containerRegistryResourceId = ContainerRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName); + ContainerRegistryResource containerRegistry = client.GetContainerRegistryResource(containerRegistryResourceId); + + // get the collection of this ContainerRegistryTaskResource + ContainerRegistryTaskCollection collection = containerRegistry.GetContainerRegistryTasks(); + + // invoke the operation + string taskName = "myTask"; + NullableResponse response = await collection.GetIfExistsAsync(taskName); + ContainerRegistryTaskResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryTaskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskResource.cs index f426cfe4c40fc..f9127b8a0587b 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskResource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskResource.cs @@ -96,61 +96,52 @@ public async Task Update_TasksUpdate() ContainerRegistryTaskResource containerRegistryTask = client.GetContainerRegistryTaskResource(containerRegistryTaskResourceId); // invoke the operation - ContainerRegistryTaskPatch patch = new ContainerRegistryTaskPatch() + ContainerRegistryTaskPatch patch = new ContainerRegistryTaskPatch { Tags = { -["testkey"] = "value", +["testkey"] = "value" }, Status = ContainerRegistryTaskStatus.Enabled, AgentCpu = 3, - Step = new ContainerRegistryDockerBuildStepUpdateContent() + Step = new ContainerRegistryDockerBuildStepUpdateContent { - ImageNames = -{ -"azurerest:testtag1" -}, + ImageNames = { "azurerest:testtag1" }, DockerFilePath = "src/DockerFile", }, - Trigger = new ContainerRegistryTriggerUpdateContent() + Trigger = new ContainerRegistryTriggerUpdateContent { - SourceTriggers = -{ -new ContainerRegistrySourceTriggerUpdateContent("mySourceTrigger") + SourceTriggers = {new ContainerRegistrySourceTriggerUpdateContent("mySourceTrigger") { -SourceRepository = new SourceCodeRepoUpdateContent() +SourceRepository = new SourceCodeRepoUpdateContent { -SourceControlAuthProperties = new SourceCodeRepoAuthInfoUpdateContent() +SourceControlAuthProperties = new SourceCodeRepoAuthInfoUpdateContent { TokenType = SourceCodeRepoAuthTokenType.Pat, Token = "xxxxx", }, }, -SourceTriggerEvents = -{ -ContainerRegistrySourceTriggerEvent.Commit -}, -} -}, +SourceTriggerEvents = {ContainerRegistrySourceTriggerEvent.Commit}, +}}, }, - Credentials = new ContainerRegistryCredentials() + Credentials = new ContainerRegistryCredentials { CustomRegistries = { -["myregistry.azurecr.io"] = new CustomRegistryCredentials() +["myregistry.azurecr.io"] = new CustomRegistryCredentials { -UserName = new ContainerRegistrySecretObject() +UserName = new ContainerRegistrySecretObject { Value = "username", ObjectType = ContainerRegistrySecretObjectType.Opaque, }, -Password = new ContainerRegistrySecretObject() +Password = new ContainerRegistrySecretObject { Value = "https://myacbvault.vault.azure.net/secrets/password", ObjectType = ContainerRegistrySecretObjectType.VaultSecret, }, Identity = "[system]", -}, +} }, }, LogTemplate = "acr/tasks:{{.Run.OS}}", @@ -187,11 +178,11 @@ public async Task Update_TasksUpdateQuickTask() ContainerRegistryTaskResource containerRegistryTask = client.GetContainerRegistryTaskResource(containerRegistryTaskResourceId); // invoke the operation - ContainerRegistryTaskPatch patch = new ContainerRegistryTaskPatch() + ContainerRegistryTaskPatch patch = new ContainerRegistryTaskPatch { Tags = { -["testkey"] = "value", +["testkey"] = "value" }, Status = ContainerRegistryTaskStatus.Enabled, LogTemplate = "acr/tasks:{{.Run.OS}}", @@ -228,61 +219,52 @@ public async Task Update_TasksUpdateWithKeyVaultCustomCredentials() ContainerRegistryTaskResource containerRegistryTask = client.GetContainerRegistryTaskResource(containerRegistryTaskResourceId); // invoke the operation - ContainerRegistryTaskPatch patch = new ContainerRegistryTaskPatch() + ContainerRegistryTaskPatch patch = new ContainerRegistryTaskPatch { Tags = { -["testkey"] = "value", +["testkey"] = "value" }, Status = ContainerRegistryTaskStatus.Enabled, AgentCpu = 3, - Step = new ContainerRegistryDockerBuildStepUpdateContent() + Step = new ContainerRegistryDockerBuildStepUpdateContent { - ImageNames = -{ -"azurerest:testtag1" -}, + ImageNames = { "azurerest:testtag1" }, DockerFilePath = "src/DockerFile", }, - Trigger = new ContainerRegistryTriggerUpdateContent() + Trigger = new ContainerRegistryTriggerUpdateContent { - SourceTriggers = -{ -new ContainerRegistrySourceTriggerUpdateContent("mySourceTrigger") + SourceTriggers = {new ContainerRegistrySourceTriggerUpdateContent("mySourceTrigger") { -SourceRepository = new SourceCodeRepoUpdateContent() +SourceRepository = new SourceCodeRepoUpdateContent { -SourceControlAuthProperties = new SourceCodeRepoAuthInfoUpdateContent() +SourceControlAuthProperties = new SourceCodeRepoAuthInfoUpdateContent { TokenType = SourceCodeRepoAuthTokenType.Pat, Token = "xxxxx", }, }, -SourceTriggerEvents = -{ -ContainerRegistrySourceTriggerEvent.Commit -}, -} -}, +SourceTriggerEvents = {ContainerRegistrySourceTriggerEvent.Commit}, +}}, }, - Credentials = new ContainerRegistryCredentials() + Credentials = new ContainerRegistryCredentials { CustomRegistries = { -["myregistry.azurecr.io"] = new CustomRegistryCredentials() +["myregistry.azurecr.io"] = new CustomRegistryCredentials { -UserName = new ContainerRegistrySecretObject() +UserName = new ContainerRegistrySecretObject { Value = "https://myacbvault.vault.azure.net/secrets/username", ObjectType = ContainerRegistrySecretObjectType.VaultSecret, }, -Password = new ContainerRegistrySecretObject() +Password = new ContainerRegistrySecretObject { Value = "https://myacbvault.vault.azure.net/secrets/password", ObjectType = ContainerRegistrySecretObjectType.VaultSecret, }, Identity = "[system]", -}, +} }, }, LogTemplate = null, @@ -319,51 +301,42 @@ public async Task Update_TasksUpdateWithMSICustomCredentials() ContainerRegistryTaskResource containerRegistryTask = client.GetContainerRegistryTaskResource(containerRegistryTaskResourceId); // invoke the operation - ContainerRegistryTaskPatch patch = new ContainerRegistryTaskPatch() + ContainerRegistryTaskPatch patch = new ContainerRegistryTaskPatch { Tags = { -["testkey"] = "value", +["testkey"] = "value" }, Status = ContainerRegistryTaskStatus.Enabled, AgentCpu = 3, - Step = new ContainerRegistryDockerBuildStepUpdateContent() + Step = new ContainerRegistryDockerBuildStepUpdateContent { - ImageNames = -{ -"azurerest:testtag1" -}, + ImageNames = { "azurerest:testtag1" }, DockerFilePath = "src/DockerFile", }, - Trigger = new ContainerRegistryTriggerUpdateContent() + Trigger = new ContainerRegistryTriggerUpdateContent { - SourceTriggers = -{ -new ContainerRegistrySourceTriggerUpdateContent("mySourceTrigger") + SourceTriggers = {new ContainerRegistrySourceTriggerUpdateContent("mySourceTrigger") { -SourceRepository = new SourceCodeRepoUpdateContent() +SourceRepository = new SourceCodeRepoUpdateContent { -SourceControlAuthProperties = new SourceCodeRepoAuthInfoUpdateContent() +SourceControlAuthProperties = new SourceCodeRepoAuthInfoUpdateContent { TokenType = SourceCodeRepoAuthTokenType.Pat, Token = "xxxxx", }, }, -SourceTriggerEvents = -{ -ContainerRegistrySourceTriggerEvent.Commit -}, -} -}, +SourceTriggerEvents = {ContainerRegistrySourceTriggerEvent.Commit}, +}}, }, - Credentials = new ContainerRegistryCredentials() + Credentials = new ContainerRegistryCredentials { CustomRegistries = { -["myregistry.azurecr.io"] = new CustomRegistryCredentials() +["myregistry.azurecr.io"] = new CustomRegistryCredentials { Identity = "[system]", -}, +} }, }, LogTemplate = null, @@ -400,60 +373,51 @@ public async Task Update_TasksUpdateWithOpaqueCustomCredentials() ContainerRegistryTaskResource containerRegistryTask = client.GetContainerRegistryTaskResource(containerRegistryTaskResourceId); // invoke the operation - ContainerRegistryTaskPatch patch = new ContainerRegistryTaskPatch() + ContainerRegistryTaskPatch patch = new ContainerRegistryTaskPatch { Tags = { -["testkey"] = "value", +["testkey"] = "value" }, Status = ContainerRegistryTaskStatus.Enabled, AgentCpu = 3, - Step = new ContainerRegistryDockerBuildStepUpdateContent() + Step = new ContainerRegistryDockerBuildStepUpdateContent { - ImageNames = -{ -"azurerest:testtag1" -}, + ImageNames = { "azurerest:testtag1" }, DockerFilePath = "src/DockerFile", }, - Trigger = new ContainerRegistryTriggerUpdateContent() + Trigger = new ContainerRegistryTriggerUpdateContent { - SourceTriggers = -{ -new ContainerRegistrySourceTriggerUpdateContent("mySourceTrigger") + SourceTriggers = {new ContainerRegistrySourceTriggerUpdateContent("mySourceTrigger") { -SourceRepository = new SourceCodeRepoUpdateContent() +SourceRepository = new SourceCodeRepoUpdateContent { -SourceControlAuthProperties = new SourceCodeRepoAuthInfoUpdateContent() +SourceControlAuthProperties = new SourceCodeRepoAuthInfoUpdateContent { TokenType = SourceCodeRepoAuthTokenType.Pat, Token = "xxxxx", }, }, -SourceTriggerEvents = -{ -ContainerRegistrySourceTriggerEvent.Commit -}, -} -}, +SourceTriggerEvents = {ContainerRegistrySourceTriggerEvent.Commit}, +}}, }, - Credentials = new ContainerRegistryCredentials() + Credentials = new ContainerRegistryCredentials { CustomRegistries = { -["myregistry.azurecr.io"] = new CustomRegistryCredentials() +["myregistry.azurecr.io"] = new CustomRegistryCredentials { -UserName = new ContainerRegistrySecretObject() +UserName = new ContainerRegistrySecretObject { Value = "username", ObjectType = ContainerRegistrySecretObjectType.Opaque, }, -Password = new ContainerRegistrySecretObject() +Password = new ContainerRegistrySecretObject { Value = "***", ObjectType = ContainerRegistrySecretObjectType.Opaque, }, -}, +} }, }, LogTemplate = null, diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskRunCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskRunCollection.cs index 441abf9dc2815..48ec6347c2c4c 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskRunCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskRunCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerRegistryTaskRunCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TaskRunsGet() + public async Task CreateOrUpdate_TaskRunsCreate() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TaskRunsGet.json - // this example is just showing the usage of "TaskRuns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TaskRunsCreate.json + // this example is just showing the usage of "TaskRuns_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,21 @@ public async Task Get_TaskRunsGet() // invoke the operation string taskRunName = "myRun"; - ContainerRegistryTaskRunResource result = await collection.GetAsync(taskRunName); + ContainerRegistryTaskRunData data = new ContainerRegistryTaskRunData + { + RunRequest = new ContainerRegistryEncodedTaskRunContent("c3RlcHM6IAogIC0gY21kOiB7eyAuVmFsdWVzLmNvbW1hbmQgfX0K", new ContainerRegistryPlatformProperties(ContainerRegistryOS.Linux) + { + Architecture = ContainerRegistryOSArchitecture.Amd64, + }) + { + EncodedValuesContent = "Y29tbWFuZDogYmFzaCBlY2hvIHt7LlJ1bi5SZWdpc3RyeX19Cg==", + Values = { }, + Credentials = new ContainerRegistryCredentials(), + }, + ForceUpdateTag = "test", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, taskRunName, data); + ContainerRegistryTaskRunResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +66,7 @@ public async Task Get_TaskRunsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TaskRunsGet() + public async Task Get_TaskRunsGet() { // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TaskRunsGet.json // this example is just showing the usage of "TaskRuns_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +89,21 @@ public async Task Exists_TaskRunsGet() // invoke the operation string taskRunName = "myRun"; - bool result = await collection.ExistsAsync(taskRunName); + ContainerRegistryTaskRunResource result = await collection.GetAsync(taskRunName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryTaskRunData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TaskRunsGet() + public async Task GetAll_TaskRunsList() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TaskRunsGet.json - // this example is just showing the usage of "TaskRuns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TaskRunsList.json + // this example is just showing the usage of "TaskRuns_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +121,25 @@ public async Task GetIfExists_TaskRunsGet() // get the collection of this ContainerRegistryTaskRunResource ContainerRegistryTaskRunCollection collection = containerRegistry.GetContainerRegistryTaskRuns(); - // invoke the operation - string taskRunName = "myRun"; - NullableResponse response = await collection.GetIfExistsAsync(taskRunName); - ContainerRegistryTaskRunResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ContainerRegistryTaskRunResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerRegistryTaskRunData resourceData = result.Data; + ContainerRegistryTaskRunData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TaskRunsCreate() + public async Task Exists_TaskRunsGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TaskRunsCreate.json - // this example is just showing the usage of "TaskRuns_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TaskRunsGet.json + // this example is just showing the usage of "TaskRuns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,37 +159,17 @@ public async Task CreateOrUpdate_TaskRunsCreate() // invoke the operation string taskRunName = "myRun"; - ContainerRegistryTaskRunData data = new ContainerRegistryTaskRunData() - { - RunRequest = new ContainerRegistryEncodedTaskRunContent("c3RlcHM6IAogIC0gY21kOiB7eyAuVmFsdWVzLmNvbW1hbmQgfX0K", new ContainerRegistryPlatformProperties(ContainerRegistryOS.Linux) - { - Architecture = ContainerRegistryOSArchitecture.Amd64, - }) - { - EncodedValuesContent = "Y29tbWFuZDogYmFzaCBlY2hvIHt7LlJ1bi5SZWdpc3RyeX19Cg==", - Values = -{ -}, - Credentials = new ContainerRegistryCredentials(), - }, - ForceUpdateTag = "test", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, taskRunName, data); - ContainerRegistryTaskRunResource result = lro.Value; + bool result = await collection.ExistsAsync(taskRunName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryTaskRunData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TaskRunsList() + public async Task GetIfExists_TaskRunsGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TaskRunsList.json - // this example is just showing the usage of "TaskRuns_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/preview/2019-06-01-preview/examples/TaskRunsGet.json + // this example is just showing the usage of "TaskRuns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,17 +187,23 @@ public async Task GetAll_TaskRunsList() // get the collection of this ContainerRegistryTaskRunResource ContainerRegistryTaskRunCollection collection = containerRegistry.GetContainerRegistryTaskRuns(); - // invoke the operation and iterate over the result - await foreach (ContainerRegistryTaskRunResource item in collection.GetAllAsync()) + // invoke the operation + string taskRunName = "myRun"; + NullableResponse response = await collection.GetIfExistsAsync(taskRunName); + ContainerRegistryTaskRunResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerRegistryTaskRunData resourceData = item.Data; + ContainerRegistryTaskRunData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskRunResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskRunResource.cs index 6701f061e0dfe..8e460c768aaaf 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskRunResource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTaskRunResource.cs @@ -96,7 +96,7 @@ public async Task Update_TaskRunsUpdate() ContainerRegistryTaskRunResource containerRegistryTaskRun = client.GetContainerRegistryTaskRunResource(containerRegistryTaskRunResourceId); // invoke the operation - ContainerRegistryTaskRunPatch patch = new ContainerRegistryTaskRunPatch() + ContainerRegistryTaskRunPatch patch = new ContainerRegistryTaskRunPatch { RunRequest = new ContainerRegistryEncodedTaskRunContent("c3RlcHM6IAogIC0gY21kOiB7eyAuVmFsdWVzLmNvbW1hbmQgfX0K", new ContainerRegistryPlatformProperties(ContainerRegistryOS.Linux) { @@ -104,9 +104,7 @@ public async Task Update_TaskRunsUpdate() }) { EncodedValuesContent = "Y29tbWFuZDogYmFzaCBlY2hvIHt7LlJ1bi5SZWdpc3RyeX19Cg==", - Values = -{ -}, + Values = { }, Credentials = new ContainerRegistryCredentials(), IsArchiveEnabled = true, }, diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTokenCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTokenCollection.cs index ba390e5c3e67d..4a96d228a5b02 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTokenCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTokenCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerRegistryTokenCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TokenList() + public async Task CreateOrUpdate_TokenCreate() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/TokenList.json - // this example is just showing the usage of "Tokens_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/TokenCreate.json + // this example is just showing the usage of "Tokens_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,29 @@ public async Task GetAll_TokenList() // get the collection of this ContainerRegistryTokenResource ContainerRegistryTokenCollection collection = containerRegistry.GetContainerRegistryTokens(); - // invoke the operation and iterate over the result - await foreach (ContainerRegistryTokenResource item in collection.GetAllAsync()) + // invoke the operation + string tokenName = "myToken"; + ContainerRegistryTokenData data = new ContainerRegistryTokenData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryTokenData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ScopeMapId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/scopeMaps/myScopeMap"), + Credentials = new ContainerRegistryTokenCredentials + { + Certificates = {new ContainerRegistryTokenCertificate +{ +Name = ContainerRegistryTokenCertificateName.Certificate1, +EncodedPemCertificate = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUc3akNDQk5hZ0F3SUJBZ0lURmdBQlR3UVpyZGdmdmhxdzBnQUFBQUZQQkRBTkJna3Foa2lHOXcwQkFRc0YKQURDQml6RUxNQWtHQTFVRUJoTUNWVk14RXpBUkJnTlZCQWdUQ2xkaGMyaHBibWQwYjI0eEVEQU9CZ05WQkFjVApCMUpsWkcxdmJtUXhIakFjQmdOVkJBb1RGVTFwWTNKdmMyOW1kQ0JEYjNKd2IzSmhkR2x2YmpFVk1CTUdBMVVFCkN4TU1UV2xqY205emIyWjBJRWxVTVI0d0hBWURWUVFERXhWTmFXTnliM052Wm5RZ1NWUWdWRXhUSUVOQklEUXcKSGhjTk1UZ3dOREV5TWpJek1qUTRXaGNOTWpBd05ERXlNakl6TWpRNFdqQTVNVGN3TlFZRFZRUURFeTV6WlhKMgphV05sWTJ4cFpXNTBZMlZ5ZEMxd1lYSjBibVZ5TG0xaGJtRm5aVzFsYm5RdVlYcDFjbVV1WTI5dE1JSUJJakFOCkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTBSYjdJcHpxMmR4emhhbVpyS1ZDakMzeTQyYlYKUnNIY2pCUTFuSDBHZ1puUDhXeDZDSE1mWThybkVJQzRLeVRRYkJXVzhnNXlmc3NSQ0ZXbFpxYjR6SkRXS0pmTgpGSmNMUm9LNnhwTktZYVZVTkVlT25IdUxHYTM0ZlA0VjBFRjZybzdvbkRLME5zanhjY1dZVzRNVXVzc0xrQS94CkUrM2RwU1REdk1KcjJoWUpsVnFDcVR6blQvbmZaVUZzQUVEQnp5MUpOOHZiZDlIR2czc2Myd0x4dk95cFJOc0gKT1V3V2pmN2xzWWZleEVlcWkzY29EeHc2alpLVWEyVkdsUnBpTkowMjhBQitYSi9TU1FVNVBsd0JBbU9TT3ovRApGY0NKdGpPZlBqU1NKckFIQVV3SHU3RzlSV05JTFBwYU9zQ1J5eitETE5zNGpvNlEvUUg4d1lManJRSURBUUFCCm80SUNtakNDQXBZd0N3WURWUjBQQkFRREFnU3dNQjBHQTFVZEpRUVdNQlFHQ0NzR0FRVUZCd01DQmdnckJnRUYKQlFjREFUQWRCZ05WSFE0RUZnUVVlbEdkVVJrZzJoSFFOWEQ4WUc4L3drdjJVT0F3SHdZRFZSMGpCQmd3Rm9BVQplbnVNd2Mvbm9Nb2MxR3Y2KytFend3OGFvcDB3Z2F3R0ExVWRId1NCcERDQm9UQ0JucUNCbTZDQm1JWkxhSFIwCmNEb3ZMMjF6WTNKc0xtMXBZM0p2YzI5bWRDNWpiMjB2Y0d0cEwyMXpZMjl5Y0M5amNtd3ZUV2xqY205emIyWjAKSlRJd1NWUWxNakJVVEZNbE1qQkRRU1V5TURRdVkzSnNoa2xvZEhSd09pOHZZM0pzTG0xcFkzSnZjMjltZEM1agpiMjB2Y0d0cEwyMXpZMjl5Y0M5amNtd3ZUV2xqY205emIyWjBKVEl3U1ZRbE1qQlVURk1sTWpCRFFTVXlNRFF1ClkzSnNNSUdGQmdnckJnRUZCUWNCQVFSNU1IY3dVUVlJS3dZQkJRVUhNQUtHUldoMGRIQTZMeTkzZDNjdWJXbGoKY205emIyWjBMbU52YlM5d2Eya3ZiWE5qYjNKd0wwMXBZM0p2YzI5bWRDVXlNRWxVSlRJd1ZFeFRKVEl3UTBFbApNakEwTG1OeWREQWlCZ2dyQmdFRkJRY3dBWVlXYUhSMGNEb3ZMMjlqYzNBdWJYTnZZM053TG1OdmJUQStCZ2tyCkJnRUVBWUkzRlFjRU1UQXZCaWNyQmdFRUFZSTNGUWlIMm9aMWcrN1pBWUxKaFJ1QnRaNWhoZlRyWUlGZGhOTGYKUW9Mbmszb0NBV1FDQVIwd1RRWURWUjBnQkVZd1JEQkNCZ2tyQmdFRUFZSTNLZ0V3TlRBekJnZ3JCZ0VGQlFjQwpBUlluYUhSMGNEb3ZMM2QzZHk1dGFXTnliM052Wm5RdVkyOXRMM0JyYVM5dGMyTnZjbkF2WTNCek1DY0dDU3NHCkFRUUJnamNWQ2dRYU1CZ3dDZ1lJS3dZQkJRVUhBd0l3Q2dZSUt3WUJCUVVIQXdFd09RWURWUjBSQkRJd01JSXUKYzJWeWRtbGpaV05zYVdWdWRHTmxjblF0Y0dGeWRHNWxjaTV0WVc1aFoyVnRaVzUwTG1GNmRYSmxMbU52YlRBTgpCZ2txaGtpRzl3MEJBUXNGQUFPQ0FnRUFIVXIzbk1vdUI5WWdDUlRWYndUTllIS2RkWGJkSW1GUXNDYys4T1g1CjE5c0N6dFFSR05iSXEwVW1Ba01MbFVvWTIxckh4ZXdxU2hWczFhL2RwaFh5Tk1pcUdaU2QzU1BtYzZscitqUFQKNXVEREs0MUlWeXN0K2VUNlpyazFvcCtMVmdkeS9EU2lyNzVqcWZFY016bS82bU8rNnFNeWRLTWtVYmM5K3JHVwphUkpUcjRWUUdIRmEwNEIwZVZpNUd4MG9pL2RpZDNSaXg2aXJMMjFJSGEwYjN6c1hzZHpHU0R2K3hqL2Q2S0l4Ckdrd2FhYmZvU1NoQnFqaFNlQ0VyZXFlb1RpYjljdGw0MGRVdUp3THl4bjhHS2N6K3AvMEJUOEIxU3lYK01OQ2wKY0pkMjVtMjhLajY2TGUxOEVyeFlJYXZJVGVGa3Y2eGZjdkEvcHladDdPaU41QTlGQk1IUmpQK1kyZ2tvdjMrcQpISFRUZG4xNnlRajduNit3YlFHNGVleXc0YisyQkRLcUxNVFU2ZmlSQ3ZPM2FPZVBLSFVNN3R4b1FidWl6Z3NzCkNiMzl3QnJOTEZsMkJLQ1RkSCtkSU9oZVJiSkZvbmlwOGRPOUVFZWdSSG9lQW54ZUlYTFBrdXMzTzEvZjRhNkIKWHQ3RG5BUm8xSzJmeEp3VXRaU2MvR3dFSjU5NzlnRXlEa3pDZEVsLzdpWE9QZXVjTXhlM2xVM2pweUtsNERUaApjSkJqQytqNGpLWTFrK1U4b040aGdqYnJISUx6Vnd2eU15OU5KS290U3BMSjQxeHdPOHlGangxalFTT3Bxc0N1ClFhUFUvTjhSZ0hxWjBGTkFzS3dNUmZ6WmdXanRCNzRzYUVEdk5jVmNuNFhCQnFNSG0ydHo2Uzk3d3kxZGt0cTgKSE5BPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==", +}}, + }, + Status = ContainerRegistryTokenStatus.Disabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tokenName, data); + ContainerRegistryTokenResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryTokenData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +100,10 @@ public async Task Get_TokenGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TokenGet() + public async Task GetAll_TokenList() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/TokenGet.json - // this example is just showing the usage of "Tokens_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/TokenList.json + // this example is just showing the usage of "Tokens_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +121,22 @@ public async Task Exists_TokenGet() // get the collection of this ContainerRegistryTokenResource ContainerRegistryTokenCollection collection = containerRegistry.GetContainerRegistryTokens(); - // invoke the operation - string tokenName = "myToken"; - bool result = await collection.ExistsAsync(tokenName); + // invoke the operation and iterate over the result + await foreach (ContainerRegistryTokenResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryTokenData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TokenGet() + public async Task Exists_TokenGet() { // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/TokenGet.json // this example is just showing the usage of "Tokens_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +159,17 @@ public async Task GetIfExists_TokenGet() // invoke the operation string tokenName = "myToken"; - NullableResponse response = await collection.GetIfExistsAsync(tokenName); - ContainerRegistryTokenResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tokenName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryTokenData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TokenCreate() + public async Task GetIfExists_TokenGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/TokenCreate.json - // this example is just showing the usage of "Tokens_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/TokenGet.json + // this example is just showing the usage of "Tokens_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,30 +189,21 @@ public async Task CreateOrUpdate_TokenCreate() // invoke the operation string tokenName = "myToken"; - ContainerRegistryTokenData data = new ContainerRegistryTokenData() - { - ScopeMapId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/scopeMaps/myScopeMap"), - Credentials = new ContainerRegistryTokenCredentials() - { - Certificates = -{ -new ContainerRegistryTokenCertificate() -{ -Name = ContainerRegistryTokenCertificateName.Certificate1, -EncodedPemCertificate = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUc3akNDQk5hZ0F3SUJBZ0lURmdBQlR3UVpyZGdmdmhxdzBnQUFBQUZQQkRBTkJna3Foa2lHOXcwQkFRc0YKQURDQml6RUxNQWtHQTFVRUJoTUNWVk14RXpBUkJnTlZCQWdUQ2xkaGMyaHBibWQwYjI0eEVEQU9CZ05WQkFjVApCMUpsWkcxdmJtUXhIakFjQmdOVkJBb1RGVTFwWTNKdmMyOW1kQ0JEYjNKd2IzSmhkR2x2YmpFVk1CTUdBMVVFCkN4TU1UV2xqY205emIyWjBJRWxVTVI0d0hBWURWUVFERXhWTmFXTnliM052Wm5RZ1NWUWdWRXhUSUVOQklEUXcKSGhjTk1UZ3dOREV5TWpJek1qUTRXaGNOTWpBd05ERXlNakl6TWpRNFdqQTVNVGN3TlFZRFZRUURFeTV6WlhKMgphV05sWTJ4cFpXNTBZMlZ5ZEMxd1lYSjBibVZ5TG0xaGJtRm5aVzFsYm5RdVlYcDFjbVV1WTI5dE1JSUJJakFOCkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTBSYjdJcHpxMmR4emhhbVpyS1ZDakMzeTQyYlYKUnNIY2pCUTFuSDBHZ1puUDhXeDZDSE1mWThybkVJQzRLeVRRYkJXVzhnNXlmc3NSQ0ZXbFpxYjR6SkRXS0pmTgpGSmNMUm9LNnhwTktZYVZVTkVlT25IdUxHYTM0ZlA0VjBFRjZybzdvbkRLME5zanhjY1dZVzRNVXVzc0xrQS94CkUrM2RwU1REdk1KcjJoWUpsVnFDcVR6blQvbmZaVUZzQUVEQnp5MUpOOHZiZDlIR2czc2Myd0x4dk95cFJOc0gKT1V3V2pmN2xzWWZleEVlcWkzY29EeHc2alpLVWEyVkdsUnBpTkowMjhBQitYSi9TU1FVNVBsd0JBbU9TT3ovRApGY0NKdGpPZlBqU1NKckFIQVV3SHU3RzlSV05JTFBwYU9zQ1J5eitETE5zNGpvNlEvUUg4d1lManJRSURBUUFCCm80SUNtakNDQXBZd0N3WURWUjBQQkFRREFnU3dNQjBHQTFVZEpRUVdNQlFHQ0NzR0FRVUZCd01DQmdnckJnRUYKQlFjREFUQWRCZ05WSFE0RUZnUVVlbEdkVVJrZzJoSFFOWEQ4WUc4L3drdjJVT0F3SHdZRFZSMGpCQmd3Rm9BVQplbnVNd2Mvbm9Nb2MxR3Y2KytFend3OGFvcDB3Z2F3R0ExVWRId1NCcERDQm9UQ0JucUNCbTZDQm1JWkxhSFIwCmNEb3ZMMjF6WTNKc0xtMXBZM0p2YzI5bWRDNWpiMjB2Y0d0cEwyMXpZMjl5Y0M5amNtd3ZUV2xqY205emIyWjAKSlRJd1NWUWxNakJVVEZNbE1qQkRRU1V5TURRdVkzSnNoa2xvZEhSd09pOHZZM0pzTG0xcFkzSnZjMjltZEM1agpiMjB2Y0d0cEwyMXpZMjl5Y0M5amNtd3ZUV2xqY205emIyWjBKVEl3U1ZRbE1qQlVURk1sTWpCRFFTVXlNRFF1ClkzSnNNSUdGQmdnckJnRUZCUWNCQVFSNU1IY3dVUVlJS3dZQkJRVUhNQUtHUldoMGRIQTZMeTkzZDNjdWJXbGoKY205emIyWjBMbU52YlM5d2Eya3ZiWE5qYjNKd0wwMXBZM0p2YzI5bWRDVXlNRWxVSlRJd1ZFeFRKVEl3UTBFbApNakEwTG1OeWREQWlCZ2dyQmdFRkJRY3dBWVlXYUhSMGNEb3ZMMjlqYzNBdWJYTnZZM053TG1OdmJUQStCZ2tyCkJnRUVBWUkzRlFjRU1UQXZCaWNyQmdFRUFZSTNGUWlIMm9aMWcrN1pBWUxKaFJ1QnRaNWhoZlRyWUlGZGhOTGYKUW9Mbmszb0NBV1FDQVIwd1RRWURWUjBnQkVZd1JEQkNCZ2tyQmdFRUFZSTNLZ0V3TlRBekJnZ3JCZ0VGQlFjQwpBUlluYUhSMGNEb3ZMM2QzZHk1dGFXTnliM052Wm5RdVkyOXRMM0JyYVM5dGMyTnZjbkF2WTNCek1DY0dDU3NHCkFRUUJnamNWQ2dRYU1CZ3dDZ1lJS3dZQkJRVUhBd0l3Q2dZSUt3WUJCUVVIQXdFd09RWURWUjBSQkRJd01JSXUKYzJWeWRtbGpaV05zYVdWdWRHTmxjblF0Y0dGeWRHNWxjaTV0WVc1aFoyVnRaVzUwTG1GNmRYSmxMbU52YlRBTgpCZ2txaGtpRzl3MEJBUXNGQUFPQ0FnRUFIVXIzbk1vdUI5WWdDUlRWYndUTllIS2RkWGJkSW1GUXNDYys4T1g1CjE5c0N6dFFSR05iSXEwVW1Ba01MbFVvWTIxckh4ZXdxU2hWczFhL2RwaFh5Tk1pcUdaU2QzU1BtYzZscitqUFQKNXVEREs0MUlWeXN0K2VUNlpyazFvcCtMVmdkeS9EU2lyNzVqcWZFY016bS82bU8rNnFNeWRLTWtVYmM5K3JHVwphUkpUcjRWUUdIRmEwNEIwZVZpNUd4MG9pL2RpZDNSaXg2aXJMMjFJSGEwYjN6c1hzZHpHU0R2K3hqL2Q2S0l4Ckdrd2FhYmZvU1NoQnFqaFNlQ0VyZXFlb1RpYjljdGw0MGRVdUp3THl4bjhHS2N6K3AvMEJUOEIxU3lYK01OQ2wKY0pkMjVtMjhLajY2TGUxOEVyeFlJYXZJVGVGa3Y2eGZjdkEvcHladDdPaU41QTlGQk1IUmpQK1kyZ2tvdjMrcQpISFRUZG4xNnlRajduNit3YlFHNGVleXc0YisyQkRLcUxNVFU2ZmlSQ3ZPM2FPZVBLSFVNN3R4b1FidWl6Z3NzCkNiMzl3QnJOTEZsMkJLQ1RkSCtkSU9oZVJiSkZvbmlwOGRPOUVFZWdSSG9lQW54ZUlYTFBrdXMzTzEvZjRhNkIKWHQ3RG5BUm8xSzJmeEp3VXRaU2MvR3dFSjU5NzlnRXlEa3pDZEVsLzdpWE9QZXVjTXhlM2xVM2pweUtsNERUaApjSkJqQytqNGpLWTFrK1U4b040aGdqYnJISUx6Vnd2eU15OU5KS290U3BMSjQxeHdPOHlGangxalFTT3Bxc0N1ClFhUFUvTjhSZ0hxWjBGTkFzS3dNUmZ6WmdXanRCNzRzYUVEdk5jVmNuNFhCQnFNSG0ydHo2Uzk3d3kxZGt0cTgKSE5BPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==", -} -}, - }, - Status = ContainerRegistryTokenStatus.Disabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tokenName, data); - ContainerRegistryTokenResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(tokenName); + ContainerRegistryTokenResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryTokenData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryTokenData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTokenResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTokenResource.cs index 84cb2b1ff40ba..2ec6c5597c76f 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTokenResource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryTokenResource.cs @@ -96,19 +96,16 @@ public async Task Update_TokenUpdate() ContainerRegistryTokenResource containerRegistryToken = client.GetContainerRegistryTokenResource(containerRegistryTokenResourceId); // invoke the operation - ContainerRegistryTokenPatch patch = new ContainerRegistryTokenPatch() + ContainerRegistryTokenPatch patch = new ContainerRegistryTokenPatch { ScopeMapId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myRegistry/scopeMaps/myNewScopeMap"), - Credentials = new ContainerRegistryTokenCredentials() + Credentials = new ContainerRegistryTokenCredentials { - Certificates = -{ -new ContainerRegistryTokenCertificate() + Certificates = {new ContainerRegistryTokenCertificate { Name = ContainerRegistryTokenCertificateName.Certificate1, EncodedPemCertificate = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUc3akNDQk5hZ0F3SUJBZ0lURmdBQlR3UVpyZGdmdmhxdzBnQUFBQUZQQkRBTkJna3Foa2lHOXcwQkFRc0YKQURDQml6RUxNQWtHQTFVRUJoTUNWVk14RXpBUkJnTlZCQWdUQ2xkaGMyaHBibWQwYjI0eEVEQU9CZ05WQkFjVApCMUpsWkcxdmJtUXhIakFjQmdOVkJBb1RGVTFwWTNKdmMyOW1kQ0JEYjNKd2IzSmhkR2x2YmpFVk1CTUdBMVVFCkN4TU1UV2xqY205emIyWjBJRWxVTVI0d0hBWURWUVFERXhWTmFXTnliM052Wm5RZ1NWUWdWRXhUSUVOQklEUXcKSGhjTk1UZ3dOREV5TWpJek1qUTRXaGNOTWpBd05ERXlNakl6TWpRNFdqQTVNVGN3TlFZRFZRUURFeTV6WlhKMgphV05sWTJ4cFpXNTBZMlZ5ZEMxd1lYSjBibVZ5TG0xaGJtRm5aVzFsYm5RdVlYcDFjbVV1WTI5dE1JSUJJakFOCkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTBSYjdJcHpxMmR4emhhbVpyS1ZDakMzeTQyYlYKUnNIY2pCUTFuSDBHZ1puUDhXeDZDSE1mWThybkVJQzRLeVRRYkJXVzhnNXlmc3NSQ0ZXbFpxYjR6SkRXS0pmTgpGSmNMUm9LNnhwTktZYVZVTkVlT25IdUxHYTM0ZlA0VjBFRjZybzdvbkRLME5zanhjY1dZVzRNVXVzc0xrQS94CkUrM2RwU1REdk1KcjJoWUpsVnFDcVR6blQvbmZaVUZzQUVEQnp5MUpOOHZiZDlIR2czc2Myd0x4dk95cFJOc0gKT1V3V2pmN2xzWWZleEVlcWkzY29EeHc2alpLVWEyVkdsUnBpTkowMjhBQitYSi9TU1FVNVBsd0JBbU9TT3ovRApGY0NKdGpPZlBqU1NKckFIQVV3SHU3RzlSV05JTFBwYU9zQ1J5eitETE5zNGpvNlEvUUg4d1lManJRSURBUUFCCm80SUNtakNDQXBZd0N3WURWUjBQQkFRREFnU3dNQjBHQTFVZEpRUVdNQlFHQ0NzR0FRVUZCd01DQmdnckJnRUYKQlFjREFUQWRCZ05WSFE0RUZnUVVlbEdkVVJrZzJoSFFOWEQ4WUc4L3drdjJVT0F3SHdZRFZSMGpCQmd3Rm9BVQplbnVNd2Mvbm9Nb2MxR3Y2KytFend3OGFvcDB3Z2F3R0ExVWRId1NCcERDQm9UQ0JucUNCbTZDQm1JWkxhSFIwCmNEb3ZMMjF6WTNKc0xtMXBZM0p2YzI5bWRDNWpiMjB2Y0d0cEwyMXpZMjl5Y0M5amNtd3ZUV2xqY205emIyWjAKSlRJd1NWUWxNakJVVEZNbE1qQkRRU1V5TURRdVkzSnNoa2xvZEhSd09pOHZZM0pzTG0xcFkzSnZjMjltZEM1agpiMjB2Y0d0cEwyMXpZMjl5Y0M5amNtd3ZUV2xqY205emIyWjBKVEl3U1ZRbE1qQlVURk1sTWpCRFFTVXlNRFF1ClkzSnNNSUdGQmdnckJnRUZCUWNCQVFSNU1IY3dVUVlJS3dZQkJRVUhNQUtHUldoMGRIQTZMeTkzZDNjdWJXbGoKY205emIyWjBMbU52YlM5d2Eya3ZiWE5qYjNKd0wwMXBZM0p2YzI5bWRDVXlNRWxVSlRJd1ZFeFRKVEl3UTBFbApNakEwTG1OeWREQWlCZ2dyQmdFRkJRY3dBWVlXYUhSMGNEb3ZMMjlqYzNBdWJYTnZZM053TG1OdmJUQStCZ2tyCkJnRUVBWUkzRlFjRU1UQXZCaWNyQmdFRUFZSTNGUWlIMm9aMWcrN1pBWUxKaFJ1QnRaNWhoZlRyWUlGZGhOTGYKUW9Mbmszb0NBV1FDQVIwd1RRWURWUjBnQkVZd1JEQkNCZ2tyQmdFRUFZSTNLZ0V3TlRBekJnZ3JCZ0VGQlFjQwpBUlluYUhSMGNEb3ZMM2QzZHk1dGFXTnliM052Wm5RdVkyOXRMM0JyYVM5dGMyTnZjbkF2WTNCek1DY0dDU3NHCkFRUUJnamNWQ2dRYU1CZ3dDZ1lJS3dZQkJRVUhBd0l3Q2dZSUt3WUJCUVVIQXdFd09RWURWUjBSQkRJd01JSXUKYzJWeWRtbGpaV05zYVdWdWRHTmxjblF0Y0dGeWRHNWxjaTV0WVc1aFoyVnRaVzUwTG1GNmRYSmxMbU52YlRBTgpCZ2txaGtpRzl3MEJBUXNGQUFPQ0FnRUFIVXIzbk1vdUI5WWdDUlRWYndUTllIS2RkWGJkSW1GUXNDYys4T1g1CjE5c0N6dFFSR05iSXEwVW1Ba01MbFVvWTIxckh4ZXdxU2hWczFhL2RwaFh5Tk1pcUdaU2QzU1BtYzZscitqUFQKNXVEREs0MUlWeXN0K2VUNlpyazFvcCtMVmdkeS9EU2lyNzVqcWZFY016bS82bU8rNnFNeWRLTWtVYmM5K3JHVwphUkpUcjRWUUdIRmEwNEIwZVZpNUd4MG9pL2RpZDNSaXg2aXJMMjFJSGEwYjN6c1hzZHpHU0R2K3hqL2Q2S0l4Ckdrd2FhYmZvU1NoQnFqaFNlQ0VyZXFlb1RpYjljdGw0MGRVdUp3THl4bjhHS2N6K3AvMEJUOEIxU3lYK01OQ2wKY0pkMjVtMjhLajY2TGUxOEVyeFlJYXZJVGVGa3Y2eGZjdkEvcHladDdPaU41QTlGQk1IUmpQK1kyZ2tvdjMrcQpISFRUZG4xNnlRajduNit3YlFHNGVleXc0YisyQkRLcUxNVFU2ZmlSQ3ZPM2FPZVBLSFVNN3R4b1FidWl6Z3NzCkNiMzl3QnJOTEZsMkJLQ1RkSCtkSU9oZVJiSkZvbmlwOGRPOUVFZWdSSG9lQW54ZUlYTFBrdXMzTzEvZjRhNkIKWHQ3RG5BUm8xSzJmeEp3VXRaU2MvR3dFSjU5NzlnRXlEa3pDZEVsLzdpWE9QZXVjTXhlM2xVM2pweUtsNERUaApjSkJqQytqNGpLWTFrK1U4b040aGdqYnJISUx6Vnd2eU15OU5KS290U3BMSjQxeHdPOHlGangxalFTT3Bxc0N1ClFhUFUvTjhSZ0hxWjBGTkFzS3dNUmZ6WmdXanRCNzRzYUVEdk5jVmNuNFhCQnFNSG0ydHo2Uzk3d3kxZGt0cTgKSE5BPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==", -} -}, +}}, }, }; ArmOperation lro = await containerRegistryToken.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryWebhookCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryWebhookCollection.cs index 4117bc35abd53..90807d33bed75 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryWebhookCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryWebhookCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerRegistryWebhookCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WebhookList() + public async Task CreateOrUpdate_WebhookCreate() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/WebhookList.json - // this example is just showing the usage of "Webhooks_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/WebhookCreate.json + // this example is just showing the usage of "Webhooks_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,31 @@ public async Task GetAll_WebhookList() // get the collection of this ContainerRegistryWebhookResource ContainerRegistryWebhookCollection collection = containerRegistry.GetContainerRegistryWebhooks(); - // invoke the operation and iterate over the result - await foreach (ContainerRegistryWebhookResource item in collection.GetAllAsync()) + // invoke the operation + string webhookName = "myWebhook"; + ContainerRegistryWebhookCreateOrUpdateContent content = new ContainerRegistryWebhookCreateOrUpdateContent(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryWebhookData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key"] = "value" +}, + ServiceUri = new Uri("http://myservice.com"), + CustomHeaders = +{ +["Authorization"] = "******" +}, + Status = ContainerRegistryWebhookStatus.Enabled, + Scope = "myRepository", + Actions = { ContainerRegistryWebhookAction.Push }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, webhookName, content); + ContainerRegistryWebhookResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryWebhookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +102,10 @@ public async Task Get_WebhookGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WebhookGet() + public async Task GetAll_WebhookList() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/WebhookGet.json - // this example is just showing the usage of "Webhooks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/WebhookList.json + // this example is just showing the usage of "Webhooks_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +123,22 @@ public async Task Exists_WebhookGet() // get the collection of this ContainerRegistryWebhookResource ContainerRegistryWebhookCollection collection = containerRegistry.GetContainerRegistryWebhooks(); - // invoke the operation - string webhookName = "myWebhook"; - bool result = await collection.ExistsAsync(webhookName); + // invoke the operation and iterate over the result + await foreach (ContainerRegistryWebhookResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryWebhookData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WebhookGet() + public async Task Exists_WebhookGet() { // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/WebhookGet.json // this example is just showing the usage of "Webhooks_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +161,17 @@ public async Task GetIfExists_WebhookGet() // invoke the operation string webhookName = "myWebhook"; - NullableResponse response = await collection.GetIfExistsAsync(webhookName); - ContainerRegistryWebhookResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(webhookName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryWebhookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WebhookCreate() + public async Task GetIfExists_WebhookGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/WebhookCreate.json - // this example is just showing the usage of "Webhooks_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/WebhookGet.json + // this example is just showing the usage of "Webhooks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,32 +191,21 @@ public async Task CreateOrUpdate_WebhookCreate() // invoke the operation string webhookName = "myWebhook"; - ContainerRegistryWebhookCreateOrUpdateContent content = new ContainerRegistryWebhookCreateOrUpdateContent(new AzureLocation("westus")) - { - Tags = -{ -["key"] = "value", -}, - ServiceUri = new Uri("http://myservice.com"), - CustomHeaders = -{ -["Authorization"] = "******", -}, - Status = ContainerRegistryWebhookStatus.Enabled, - Scope = "myRepository", - Actions = -{ -ContainerRegistryWebhookAction.Push -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, webhookName, content); - ContainerRegistryWebhookResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(webhookName); + ContainerRegistryWebhookResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerRegistryWebhookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryWebhookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryWebhookResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryWebhookResource.cs index 51a3c18ccd31a..0ab756244a3cd 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryWebhookResource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ContainerRegistryWebhookResource.cs @@ -96,23 +96,20 @@ public async Task Update_WebhookUpdate() ContainerRegistryWebhookResource containerRegistryWebhook = client.GetContainerRegistryWebhookResource(containerRegistryWebhookResourceId); // invoke the operation - ContainerRegistryWebhookPatch patch = new ContainerRegistryWebhookPatch() + ContainerRegistryWebhookPatch patch = new ContainerRegistryWebhookPatch { Tags = { -["key"] = "value", +["key"] = "value" }, ServiceUri = new Uri("http://myservice.com"), CustomHeaders = { -["Authorization"] = "******", +["Authorization"] = "******" }, Status = ContainerRegistryWebhookStatus.Enabled, Scope = "myRepository", - Actions = -{ -ContainerRegistryWebhookAction.Push -}, + Actions = { ContainerRegistryWebhookAction.Push }, }; ArmOperation lro = await containerRegistryWebhook.UpdateAsync(WaitUntil.Completed, patch); ContainerRegistryWebhookResource result = lro.Value; diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ScopeMapCollection.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ScopeMapCollection.cs index 05deb15a1a0d1..06b189f3786e1 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ScopeMapCollection.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ScopeMapCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ScopeMapCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScopeMapList() + public async Task CreateOrUpdate_ScopeMapCreate() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ScopeMapList.json - // this example is just showing the usage of "ScopeMaps_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ScopeMapCreate.json + // this example is just showing the usage of "ScopeMaps_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_ScopeMapList() // get the collection of this ScopeMapResource ScopeMapCollection collection = containerRegistry.GetScopeMaps(); - // invoke the operation and iterate over the result - await foreach (ScopeMapResource item in collection.GetAllAsync()) + // invoke the operation + string scopeMapName = "myScopeMap"; + ScopeMapData data = new ScopeMapData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScopeMapData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "Developer Scopes", + Actions = { "repositories/myrepository/contentWrite", "repositories/myrepository/delete" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeMapName, data); + ScopeMapResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScopeMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_ScopeMapGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ScopeMapGet() + public async Task GetAll_ScopeMapList() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ScopeMapGet.json - // this example is just showing the usage of "ScopeMaps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ScopeMapList.json + // this example is just showing the usage of "ScopeMaps_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_ScopeMapGet() // get the collection of this ScopeMapResource ScopeMapCollection collection = containerRegistry.GetScopeMaps(); - // invoke the operation - string scopeMapName = "myScopeMap"; - bool result = await collection.ExistsAsync(scopeMapName); + // invoke the operation and iterate over the result + await foreach (ScopeMapResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScopeMapData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ScopeMapGet() + public async Task Exists_ScopeMapGet() { // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ScopeMapGet.json // this example is just showing the usage of "ScopeMaps_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_ScopeMapGet() // invoke the operation string scopeMapName = "myScopeMap"; - NullableResponse response = await collection.GetIfExistsAsync(scopeMapName); - ScopeMapResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(scopeMapName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScopeMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ScopeMapCreate() + public async Task GetIfExists_ScopeMapGet() { - // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ScopeMapCreate.json - // this example is just showing the usage of "ScopeMaps_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/ScopeMapGet.json + // this example is just showing the usage of "ScopeMaps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,22 +180,21 @@ public async Task CreateOrUpdate_ScopeMapCreate() // invoke the operation string scopeMapName = "myScopeMap"; - ScopeMapData data = new ScopeMapData() - { - Description = "Developer Scopes", - Actions = -{ -"repositories/myrepository/contentWrite","repositories/myrepository/delete" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeMapName, data); - ScopeMapResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(scopeMapName); + ScopeMapResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScopeMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScopeMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ScopeMapResource.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ScopeMapResource.cs index 1deb11fd043da..152b4a9cc030b 100644 --- a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ScopeMapResource.cs +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_ScopeMapResource.cs @@ -96,13 +96,10 @@ public async Task Update_ScopeMapUpdate() ScopeMapResource scopeMap = client.GetScopeMapResource(scopeMapResourceId); // invoke the operation - ScopeMapPatch patch = new ScopeMapPatch() + ScopeMapPatch patch = new ScopeMapPatch { Description = "Developer Scopes", - Actions = -{ -"repositories/myrepository/contentWrite","repositories/myrepository/contentRead" -}, + Actions = { "repositories/myrepository/contentWrite", "repositories/myrepository/contentRead" }, }; ArmOperation lro = await scopeMap.UpdateAsync(WaitUntil.Completed, patch); ScopeMapResource result = lro.Value; diff --git a/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..cc39c0ff03e94 --- /dev/null +++ b/sdk/containerregistry/Azure.ResourceManager.ContainerRegistry/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,101 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ContainerRegistry.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ContainerRegistry.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckContainerRegistryNameAvailability_RegistryCheckNameAvailable() + { + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryCheckNameAvailable.json + // this example is just showing the usage of "Registries_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + ContainerRegistryNameAvailabilityContent content = new ContainerRegistryNameAvailabilityContent("myRegistry"); + ContainerRegistryNameAvailableResult result = await subscriptionResource.CheckContainerRegistryNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckContainerRegistryNameAvailability_RegistryCheckNameNotAvailable() + { + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryCheckNameNotAvailable.json + // this example is just showing the usage of "Registries_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + ContainerRegistryNameAvailabilityContent content = new ContainerRegistryNameAvailabilityContent("myRegistry"); + ContainerRegistryNameAvailableResult result = await subscriptionResource.CheckContainerRegistryNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetContainerRegistries_RegistryList() + { + // Generated from example definition: specification/containerregistry/resource-manager/Microsoft.ContainerRegistry/stable/2022-12-01/examples/RegistryList.json + // this example is just showing the usage of "Registries_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerRegistryResource item in subscriptionResource.GetContainerRegistriesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerRegistryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotCollection.cs index e1080808cc413..5863b1521d9f7 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotCollection.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AgentPoolSnapshotCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSnapshotsByResourceGroup() + public async Task CreateOrUpdate_CreateUpdateSnapshot() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsListByResourceGroup.json - // this example is just showing the usage of "Snapshots_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsCreate.json + // this example is just showing the usage of "Snapshots_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,25 @@ public async Task GetAll_ListSnapshotsByResourceGroup() // get the collection of this AgentPoolSnapshotResource AgentPoolSnapshotCollection collection = resourceGroupResource.GetAgentPoolSnapshots(); - // invoke the operation and iterate over the result - await foreach (AgentPoolSnapshotResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "snapshot1"; + AgentPoolSnapshotData data = new AgentPoolSnapshotData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AgentPoolSnapshotData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CreationDataSourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1/agentPools/pool0"), + Tags = +{ +["key1"] = "val1", +["key2"] = "val2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + AgentPoolSnapshotResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +94,10 @@ public async Task Get_GetSnapshot() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSnapshot() + public async Task GetAll_ListSnapshotsByResourceGroup() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsGet.json - // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsListByResourceGroup.json + // this example is just showing the usage of "Snapshots_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +114,22 @@ public async Task Exists_GetSnapshot() // get the collection of this AgentPoolSnapshotResource AgentPoolSnapshotCollection collection = resourceGroupResource.GetAgentPoolSnapshots(); - // invoke the operation - string resourceName = "snapshot1"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (AgentPoolSnapshotResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSnapshot() + public async Task Exists_GetSnapshot() { // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsGet.json // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +151,17 @@ public async Task GetIfExists_GetSnapshot() // invoke the operation string resourceName = "snapshot1"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - AgentPoolSnapshotResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AgentPoolSnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateUpdateSnapshot() + public async Task GetIfExists_GetSnapshot() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsCreate.json - // this example is just showing the usage of "Snapshots_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsGet.json + // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,23 +180,21 @@ public async Task CreateOrUpdate_CreateUpdateSnapshot() // invoke the operation string resourceName = "snapshot1"; - AgentPoolSnapshotData data = new AgentPoolSnapshotData(new AzureLocation("westus")) - { - CreationDataSourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/managedClusters/cluster1/agentPools/pool0"), - Tags = -{ -["key1"] = "val1", -["key2"] = "val2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - AgentPoolSnapshotResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + AgentPoolSnapshotResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AgentPoolSnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotResource.cs index fc43864f58ae4..18f0d6f5f8fce 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotResource.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_AgentPoolSnapshotResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ContainerService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ContainerService.Samples { public partial class Sample_AgentPoolSnapshotResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAgentPoolSnapshots_ListSnapshots() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsList.json - // this example is just showing the usage of "Snapshots_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AgentPoolSnapshotResource item in subscriptionResource.GetAgentPoolSnapshotsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AgentPoolSnapshotData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetSnapshot() @@ -80,10 +48,10 @@ public async Task Get_GetSnapshot() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateSnapshotTags() + public async Task Delete_DeleteSnapshot() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsUpdateTags.json - // this example is just showing the usage of "Snapshots_UpdateTags" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsDelete.json + // this example is just showing the usage of "Snapshots_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,29 +67,17 @@ public async Task Update_UpdateSnapshotTags() AgentPoolSnapshotResource agentPoolSnapshot = client.GetAgentPoolSnapshotResource(agentPoolSnapshotResourceId); // invoke the operation - ContainerServiceTagsObject containerServiceTagsObject = new ContainerServiceTagsObject() - { - Tags = -{ -["key2"] = "new-val2", -["key3"] = "val3", -}, - }; - AgentPoolSnapshotResource result = await agentPoolSnapshot.UpdateAsync(containerServiceTagsObject); + await agentPoolSnapshot.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AgentPoolSnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSnapshot() + public async Task Update_UpdateSnapshotTags() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsDelete.json - // this example is just showing the usage of "Snapshots_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsUpdateTags.json + // this example is just showing the usage of "Snapshots_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,9 +93,21 @@ public async Task Delete_DeleteSnapshot() AgentPoolSnapshotResource agentPoolSnapshot = client.GetAgentPoolSnapshotResource(agentPoolSnapshotResourceId); // invoke the operation - await agentPoolSnapshot.DeleteAsync(WaitUntil.Completed); + ContainerServiceTagsObject containerServiceTagsObject = new ContainerServiceTagsObject + { + Tags = +{ +["key2"] = "new-val2", +["key3"] = "val3" +}, + }; + AgentPoolSnapshotResource result = await agentPoolSnapshot.UpdateAsync(containerServiceTagsObject); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolCollection.cs index 4dc70975bd617..d89556d52e005 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolCollection.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolCollection.cs @@ -16,148 +16,6 @@ namespace Azure.ResourceManager.ContainerService.Samples { public partial class Sample_ContainerServiceAgentPoolCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAgentPoolsByManagedCluster() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsList.json - // this example is just showing the usage of "AgentPools_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerServiceManagedClusterResource created on azure - // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string resourceName = "clustername1"; - ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); - ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); - - // get the collection of this ContainerServiceAgentPoolResource - ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); - - // invoke the operation and iterate over the result - await foreach (ContainerServiceAgentPoolResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceAgentPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAgentPool() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json - // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerServiceManagedClusterResource created on azure - // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string resourceName = "clustername1"; - ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); - ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); - - // get the collection of this ContainerServiceAgentPoolResource - ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); - - // invoke the operation - string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolResource result = await collection.GetAsync(agentPoolName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceAgentPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAgentPool() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json - // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerServiceManagedClusterResource created on azure - // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string resourceName = "clustername1"; - ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); - ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); - - // get the collection of this ContainerServiceAgentPoolResource - ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); - - // invoke the operation - string agentPoolName = "agentpool1"; - bool result = await collection.ExistsAsync(agentPoolName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAgentPool() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json - // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ContainerServiceManagedClusterResource created on azure - // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string resourceName = "clustername1"; - ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); - ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); - - // get the collection of this ContainerServiceAgentPoolResource - ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); - - // invoke the operation - string agentPoolName = "agentpool1"; - NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); - ContainerServiceAgentPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceAgentPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateAgentPoolUsingAnAgentPoolSnapshot() @@ -183,7 +41,7 @@ public async Task CreateOrUpdate_CreateAgentPoolUsingAnAgentPoolSnapshot() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -227,7 +85,7 @@ public async Task CreateOrUpdate_CreateAgentPoolWithCapacityReservationGroup() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -270,7 +128,7 @@ public async Task CreateOrUpdate_CreateAgentPoolWithDedicatedHostGroup() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -313,7 +171,7 @@ public async Task CreateOrUpdate_CreateAgentPoolWithEncryptionAtHostEnabled() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -356,7 +214,7 @@ public async Task CreateOrUpdate_CreateAgentPoolWithEphemeralOSDisk() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -400,7 +258,7 @@ public async Task CreateOrUpdate_CreateAgentPoolWithFIPSEnabledOS() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -443,13 +301,13 @@ public async Task CreateOrUpdate_CreateAgentPoolWithGPUMIG() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_ND96asr_v4", OSType = ContainerServiceOSType.Linux, OrchestratorVersion = "", - KubeletConfig = new KubeletConfig() + KubeletConfig = new KubeletConfig { CpuManagerPolicy = "static", IsCpuCfsQuotaEnabled = true, @@ -457,15 +315,12 @@ public async Task CreateOrUpdate_CreateAgentPoolWithGPUMIG() ImageGcHighThreshold = 90, ImageGcLowThreshold = 70, TopologyManagerPolicy = "best-effort", - AllowedUnsafeSysctls = -{ -"kernel.msg*","net.core.somaxconn" -}, + AllowedUnsafeSysctls = { "kernel.msg*", "net.core.somaxconn" }, FailStartWithSwapOn = false, }, - LinuxOSConfig = new LinuxOSConfig() + LinuxOSConfig = new LinuxOSConfig { - Sysctls = new SysctlConfig() + Sysctls = new SysctlConfig { NetCoreWmemDefault = 12345, NetIPv4TcpTwReuse = true, @@ -513,7 +368,7 @@ public async Task CreateOrUpdate_CreateAgentPoolWithKrustletAndTheWASIRuntime() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -558,13 +413,13 @@ public async Task CreateOrUpdate_CreateAgentPoolWithKubeletConfigAndLinuxOSConfi // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", OSType = ContainerServiceOSType.Linux, OrchestratorVersion = "", - KubeletConfig = new KubeletConfig() + KubeletConfig = new KubeletConfig { CpuManagerPolicy = "static", IsCpuCfsQuotaEnabled = true, @@ -572,15 +427,12 @@ public async Task CreateOrUpdate_CreateAgentPoolWithKubeletConfigAndLinuxOSConfi ImageGcHighThreshold = 90, ImageGcLowThreshold = 70, TopologyManagerPolicy = "best-effort", - AllowedUnsafeSysctls = -{ -"kernel.msg*","net.core.somaxconn" -}, + AllowedUnsafeSysctls = { "kernel.msg*", "net.core.somaxconn" }, FailStartWithSwapOn = false, }, - LinuxOSConfig = new LinuxOSConfig() + LinuxOSConfig = new LinuxOSConfig { - Sysctls = new SysctlConfig() + Sysctls = new SysctlConfig { NetCoreWmemDefault = 12345, NetIPv4TcpTwReuse = true, @@ -627,14 +479,14 @@ public async Task CreateOrUpdate_CreateAgentPoolWithOSSKU() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", OSType = ContainerServiceOSType.Linux, OSSku = ContainerServiceOSSku.AzureLinux, OrchestratorVersion = "", - KubeletConfig = new KubeletConfig() + KubeletConfig = new KubeletConfig { CpuManagerPolicy = "static", IsCpuCfsQuotaEnabled = true, @@ -642,15 +494,12 @@ public async Task CreateOrUpdate_CreateAgentPoolWithOSSKU() ImageGcHighThreshold = 90, ImageGcLowThreshold = 70, TopologyManagerPolicy = "best-effort", - AllowedUnsafeSysctls = -{ -"kernel.msg*","net.core.somaxconn" -}, + AllowedUnsafeSysctls = { "kernel.msg*", "net.core.somaxconn" }, FailStartWithSwapOn = false, }, - LinuxOSConfig = new LinuxOSConfig() + LinuxOSConfig = new LinuxOSConfig { - Sysctls = new SysctlConfig() + Sysctls = new SysctlConfig { NetCoreWmemDefault = 12345, NetIPv4TcpTwReuse = true, @@ -697,7 +546,7 @@ public async Task CreateOrUpdate_CreateAgentPoolWithPPG() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -740,7 +589,7 @@ public async Task CreateOrUpdate_CreateAgentPoolWithUltraSSDEnabled() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -783,7 +632,7 @@ public async Task CreateOrUpdate_CreateAgentPoolWithWindowsOSSKU() // invoke the operation string agentPoolName = "wnp2"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_D4s_v3", @@ -826,7 +675,7 @@ public async Task CreateOrUpdate_CreateSpotAgentPool() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS1_v2", @@ -836,16 +685,13 @@ public async Task CreateOrUpdate_CreateSpotAgentPool() ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, Tags = { -["name1"] = "val1", +["name1"] = "val1" }, NodeLabels = { -["key1"] = "val1", -}, - NodeTaints = -{ -"Key1=Value1:NoSchedule" +["key1"] = "val1" }, + NodeTaints = { "Key1=Value1:NoSchedule" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); ContainerServiceAgentPoolResource result = lro.Value; @@ -882,7 +728,7 @@ public async Task CreateOrUpdate_CreateUpdateAgentPool() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS1_v2", @@ -893,16 +739,13 @@ public async Task CreateOrUpdate_CreateUpdateAgentPool() ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, Tags = { -["name1"] = "val1", +["name1"] = "val1" }, NodeLabels = { -["key1"] = "val1", -}, - NodeTaints = -{ -"Key1=Value1:NoSchedule" +["key1"] = "val1" }, + NodeTaints = { "Key1=Value1:NoSchedule" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); ContainerServiceAgentPoolResource result = lro.Value; @@ -939,7 +782,7 @@ public async Task CreateOrUpdate_StartAgentPool() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { PowerStateCode = ContainerServiceStateCode.Running, }; @@ -978,7 +821,7 @@ public async Task CreateOrUpdate_StopAgentPool() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { PowerStateCode = ContainerServiceStateCode.Stopped, }; @@ -1017,7 +860,7 @@ public async Task CreateOrUpdate_UpdateAgentPool() // invoke the operation string agentPoolName = "agentpool1"; - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS1_v2", @@ -1028,10 +871,7 @@ public async Task CreateOrUpdate_UpdateAgentPool() OrchestratorVersion = "", ScaleSetPriority = ScaleSetPriority.Spot, ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, - NodeTaints = -{ -"Key1=Value1:NoSchedule" -}, + NodeTaints = { "Key1=Value1:NoSchedule" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); ContainerServiceAgentPoolResource result = lro.Value; @@ -1042,5 +882,147 @@ public async Task CreateOrUpdate_UpdateAgentPool() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + ContainerServiceAgentPoolResource result = await collection.GetAsync(agentPoolName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAgentPoolsByManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsList.json + // this example is just showing the usage of "AgentPools_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceAgentPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + bool result = await collection.ExistsAsync(agentPoolName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetAgentPool() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ContainerServiceManagedClusterResource created on azure + // for more information of creating ContainerServiceManagedClusterResource, please refer to the document of ContainerServiceManagedClusterResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string resourceName = "clustername1"; + ResourceIdentifier containerServiceManagedClusterResourceId = ContainerServiceManagedClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); + ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); + + // get the collection of this ContainerServiceAgentPoolResource + ContainerServiceAgentPoolCollection collection = containerServiceManagedCluster.GetContainerServiceAgentPools(); + + // invoke the operation + string agentPoolName = "agentpool1"; + NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); + ContainerServiceAgentPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolResource.cs index 170c3e55a7dda..8f449f069239e 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolResource.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceAgentPoolResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerServiceAgentPoolResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task AbortLatestOperation_AbortOperationOnAgentPool() + public async Task Get_GetAgentPool() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsAbortOperation.json - // this example is just showing the usage of "AgentPools_AbortLatestOperation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json + // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task AbortLatestOperation_AbortOperationOnAgentPool() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - await containerServiceAgentPool.AbortLatestOperationAsync(WaitUntil.Completed); + ContainerServiceAgentPoolResource result = await containerServiceAgentPool.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAgentPool() + public async Task Delete_DeleteAgentPool() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsGet.json - // this example is just showing the usage of "AgentPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsDelete.json + // this example is just showing the usage of "AgentPools_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetAgentPool() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolResource result = await containerServiceAgentPool.GetAsync(); + await containerServiceAgentPool.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceAgentPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_CreateAgentPoolUsingAnAgentPoolSnapshot() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -137,7 +137,7 @@ public async Task Update_CreateAgentPoolWithCapacityReservationGroup() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -177,7 +177,7 @@ public async Task Update_CreateAgentPoolWithDedicatedHostGroup() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -217,7 +217,7 @@ public async Task Update_CreateAgentPoolWithEncryptionAtHostEnabled() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -257,7 +257,7 @@ public async Task Update_CreateAgentPoolWithEphemeralOSDisk() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -298,7 +298,7 @@ public async Task Update_CreateAgentPoolWithFIPSEnabledOS() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -338,13 +338,13 @@ public async Task Update_CreateAgentPoolWithGPUMIG() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_ND96asr_v4", OSType = ContainerServiceOSType.Linux, OrchestratorVersion = "", - KubeletConfig = new KubeletConfig() + KubeletConfig = new KubeletConfig { CpuManagerPolicy = "static", IsCpuCfsQuotaEnabled = true, @@ -352,15 +352,12 @@ public async Task Update_CreateAgentPoolWithGPUMIG() ImageGcHighThreshold = 90, ImageGcLowThreshold = 70, TopologyManagerPolicy = "best-effort", - AllowedUnsafeSysctls = -{ -"kernel.msg*","net.core.somaxconn" -}, + AllowedUnsafeSysctls = { "kernel.msg*", "net.core.somaxconn" }, FailStartWithSwapOn = false, }, - LinuxOSConfig = new LinuxOSConfig() + LinuxOSConfig = new LinuxOSConfig { - Sysctls = new SysctlConfig() + Sysctls = new SysctlConfig { NetCoreWmemDefault = 12345, NetIPv4TcpTwReuse = true, @@ -405,7 +402,7 @@ public async Task Update_CreateAgentPoolWithKrustletAndTheWASIRuntime() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -447,13 +444,13 @@ public async Task Update_CreateAgentPoolWithKubeletConfigAndLinuxOSConfig() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", OSType = ContainerServiceOSType.Linux, OrchestratorVersion = "", - KubeletConfig = new KubeletConfig() + KubeletConfig = new KubeletConfig { CpuManagerPolicy = "static", IsCpuCfsQuotaEnabled = true, @@ -461,15 +458,12 @@ public async Task Update_CreateAgentPoolWithKubeletConfigAndLinuxOSConfig() ImageGcHighThreshold = 90, ImageGcLowThreshold = 70, TopologyManagerPolicy = "best-effort", - AllowedUnsafeSysctls = -{ -"kernel.msg*","net.core.somaxconn" -}, + AllowedUnsafeSysctls = { "kernel.msg*", "net.core.somaxconn" }, FailStartWithSwapOn = false, }, - LinuxOSConfig = new LinuxOSConfig() + LinuxOSConfig = new LinuxOSConfig { - Sysctls = new SysctlConfig() + Sysctls = new SysctlConfig { NetCoreWmemDefault = 12345, NetIPv4TcpTwReuse = true, @@ -513,14 +507,14 @@ public async Task Update_CreateAgentPoolWithOSSKU() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", OSType = ContainerServiceOSType.Linux, OSSku = ContainerServiceOSSku.AzureLinux, OrchestratorVersion = "", - KubeletConfig = new KubeletConfig() + KubeletConfig = new KubeletConfig { CpuManagerPolicy = "static", IsCpuCfsQuotaEnabled = true, @@ -528,15 +522,12 @@ public async Task Update_CreateAgentPoolWithOSSKU() ImageGcHighThreshold = 90, ImageGcLowThreshold = 70, TopologyManagerPolicy = "best-effort", - AllowedUnsafeSysctls = -{ -"kernel.msg*","net.core.somaxconn" -}, + AllowedUnsafeSysctls = { "kernel.msg*", "net.core.somaxconn" }, FailStartWithSwapOn = false, }, - LinuxOSConfig = new LinuxOSConfig() + LinuxOSConfig = new LinuxOSConfig { - Sysctls = new SysctlConfig() + Sysctls = new SysctlConfig { NetCoreWmemDefault = 12345, NetIPv4TcpTwReuse = true, @@ -580,7 +571,7 @@ public async Task Update_CreateAgentPoolWithPPG() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -620,7 +611,7 @@ public async Task Update_CreateAgentPoolWithUltraSSDEnabled() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS2_v2", @@ -660,7 +651,7 @@ public async Task Update_CreateAgentPoolWithWindowsOSSKU() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_D4s_v3", @@ -700,7 +691,7 @@ public async Task Update_CreateSpotAgentPool() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS1_v2", @@ -710,16 +701,13 @@ public async Task Update_CreateSpotAgentPool() ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, Tags = { -["name1"] = "val1", +["name1"] = "val1" }, NodeLabels = { -["key1"] = "val1", -}, - NodeTaints = -{ -"Key1=Value1:NoSchedule" +["key1"] = "val1" }, + NodeTaints = { "Key1=Value1:NoSchedule" }, }; ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); ContainerServiceAgentPoolResource result = lro.Value; @@ -753,7 +741,7 @@ public async Task Update_CreateUpdateAgentPool() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS1_v2", @@ -764,16 +752,13 @@ public async Task Update_CreateUpdateAgentPool() ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, Tags = { -["name1"] = "val1", +["name1"] = "val1" }, NodeLabels = { -["key1"] = "val1", -}, - NodeTaints = -{ -"Key1=Value1:NoSchedule" +["key1"] = "val1" }, + NodeTaints = { "Key1=Value1:NoSchedule" }, }; ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); ContainerServiceAgentPoolResource result = lro.Value; @@ -807,7 +792,7 @@ public async Task Update_StartAgentPool() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { PowerStateCode = ContainerServiceStateCode.Running, }; @@ -843,7 +828,7 @@ public async Task Update_StopAgentPool() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { PowerStateCode = ContainerServiceStateCode.Stopped, }; @@ -879,7 +864,7 @@ public async Task Update_UpdateAgentPool() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData() + ContainerServiceAgentPoolData data = new ContainerServiceAgentPoolData { Count = 3, VmSize = "Standard_DS1_v2", @@ -890,10 +875,7 @@ public async Task Update_UpdateAgentPool() OrchestratorVersion = "", ScaleSetPriority = ScaleSetPriority.Spot, ScaleSetEvictionPolicy = ScaleSetEvictionPolicy.Delete, - NodeTaints = -{ -"Key1=Value1:NoSchedule" -}, + NodeTaints = { "Key1=Value1:NoSchedule" }, }; ArmOperation lro = await containerServiceAgentPool.UpdateAsync(WaitUntil.Completed, data); ContainerServiceAgentPoolResource result = lro.Value; @@ -907,10 +889,10 @@ public async Task Update_UpdateAgentPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAgentPool() + public async Task AbortLatestOperation_AbortOperationOnAgentPool() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsDelete.json - // this example is just showing the usage of "AgentPools_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/AgentPoolsAbortOperation.json + // this example is just showing the usage of "AgentPools_AbortLatestOperation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -927,7 +909,7 @@ public async Task Delete_DeleteAgentPool() ContainerServiceAgentPoolResource containerServiceAgentPool = client.GetContainerServiceAgentPoolResource(containerServiceAgentPoolResourceId); // invoke the operation - await containerServiceAgentPool.DeleteAsync(WaitUntil.Completed); + await containerServiceAgentPool.AbortLatestOperationAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationCollection.cs index 81c2f9b3c271e..6c6340f77ea6b 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationCollection.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerServiceMaintenanceConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListMaintenanceConfigurationsByManagedCluster() + public async Task CreateOrUpdate_CreateUpdateMaintenanceConfiguration() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsList.json - // this example is just showing the usage of "MaintenanceConfigurations_ListByManagedCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update.json + // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,37 @@ public async Task GetAll_ListMaintenanceConfigurationsByManagedCluster() // get the collection of this ContainerServiceMaintenanceConfigurationResource ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); - // invoke the operation and iterate over the result - await foreach (ContainerServiceMaintenanceConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string configName = "default"; + ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceMaintenanceConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TimesInWeek = {new ContainerServiceTimeInWeek +{ +Day = ContainerServiceWeekDay.Monday, +HourSlots = {1, 2}, +}}, + NotAllowedTimes = {new ContainerServiceTimeSpan +{ +StartOn = DateTimeOffset.Parse("2020-11-26T03:00:00Z"), +EndOn = DateTimeOffset.Parse("2020-11-30T12:00:00Z"), +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configName, data); + ContainerServiceMaintenanceConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListMaintenanceConfigurationsConfiguredWithMaintenanceWindowByManagedCluster() + public async Task CreateOrUpdate_CreateUpdateMaintenanceConfigurationWithMaintenanceWindow() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsList_MaintenanceWindow.json - // this example is just showing the usage of "MaintenanceConfigurations_ListByManagedCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +87,28 @@ public async Task GetAll_ListMaintenanceConfigurationsConfiguredWithMaintenanceW // get the collection of this ContainerServiceMaintenanceConfigurationResource ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); - // invoke the operation and iterate over the result - await foreach (ContainerServiceMaintenanceConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string configName = "aksManagedAutoUpgradeSchedule"; + ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceMaintenanceConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + MaintenanceWindow = new ContainerServiceMaintenanceWindow(new ContainerServiceMaintenanceSchedule + { + RelativeMonthly = new ContainerServiceMaintenanceRelativeMonthlySchedule(3, ContainerServiceMaintenanceRelativeMonthlyScheduleWeekIndex.First, ContainerServiceWeekDay.Monday), + }, 10, "08:30") + { + UtcOffset = "+05:30", + StartDate = "2023-01-01", + NotAllowedDates = { new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-02-18"), DateTimeOffset.Parse("2023-02-25")), new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-12-23"), DateTimeOffset.Parse("2024-01-05")) }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configName, data); + ContainerServiceMaintenanceConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -124,9 +147,9 @@ public async Task Get_GetMaintenanceConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMaintenanceConfiguration() + public async Task Get_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet.json + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet_MaintenanceWindow.json // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -146,18 +169,22 @@ public async Task Exists_GetMaintenanceConfiguration() ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); // invoke the operation - string configName = "default"; - bool result = await collection.ExistsAsync(configName); + string configName = "aksManagedNodeOSUpgradeSchedule"; + ContainerServiceMaintenanceConfigurationResource result = await collection.GetAsync(configName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMaintenanceConfiguration() + public async Task GetAll_ListMaintenanceConfigurationsByManagedCluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet.json - // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsList.json + // this example is just showing the usage of "MaintenanceConfigurations_ListByManagedCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -175,31 +202,25 @@ public async Task GetIfExists_GetMaintenanceConfiguration() // get the collection of this ContainerServiceMaintenanceConfigurationResource ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); - // invoke the operation - string configName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(configName); - ContainerServiceMaintenanceConfigurationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ContainerServiceMaintenanceConfigurationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + ContainerServiceMaintenanceConfigurationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow() + public async Task GetAll_ListMaintenanceConfigurationsConfiguredWithMaintenanceWindowByManagedCluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet_MaintenanceWindow.json - // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsList_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_ListByManagedCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,22 +238,24 @@ public async Task Get_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow // get the collection of this ContainerServiceMaintenanceConfigurationResource ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); - // invoke the operation - string configName = "aksManagedNodeOSUpgradeSchedule"; - ContainerServiceMaintenanceConfigurationResource result = await collection.GetAsync(configName); + // invoke the operation and iterate over the result + await foreach (ContainerServiceMaintenanceConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceMaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow() + public async Task Exists_GetMaintenanceConfiguration() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet_MaintenanceWindow.json + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet.json // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -252,7 +275,7 @@ public async Task Exists_GetMaintenanceConfigurationConfiguredWithMaintenanceWin ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); // invoke the operation - string configName = "aksManagedNodeOSUpgradeSchedule"; + string configName = "default"; bool result = await collection.ExistsAsync(configName); Console.WriteLine($"Succeeded: {result}"); @@ -260,7 +283,7 @@ public async Task Exists_GetMaintenanceConfigurationConfiguredWithMaintenanceWin [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow() + public async Task Exists_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow() { // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet_MaintenanceWindow.json // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -283,29 +306,17 @@ public async Task GetIfExists_GetMaintenanceConfigurationConfiguredWithMaintenan // invoke the operation string configName = "aksManagedNodeOSUpgradeSchedule"; - NullableResponse response = await collection.GetIfExistsAsync(configName); - ContainerServiceMaintenanceConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceMaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateUpdateMaintenanceConfiguration() + public async Task GetIfExists_GetMaintenanceConfiguration() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update.json - // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -325,44 +336,29 @@ public async Task CreateOrUpdate_CreateUpdateMaintenanceConfiguration() // invoke the operation string configName = "default"; - ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData() - { - TimesInWeek = -{ -new ContainerServiceTimeInWeek() -{ -Day = ContainerServiceWeekDay.Monday, -HourSlots = -{ -1,2 -}, -} -}, - NotAllowedTimes = -{ -new ContainerServiceTimeSpan() -{ -StartOn = DateTimeOffset.Parse("2020-11-26T03:00:00Z"), -EndOn = DateTimeOffset.Parse("2020-11-30T12:00:00Z"), -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configName, data); - ContainerServiceMaintenanceConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(configName); + ContainerServiceMaintenanceConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceMaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateUpdateMaintenanceConfigurationWithMaintenanceWindow() + public async Task GetIfExists_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update_MaintenanceWindow.json - // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsGet_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -381,30 +377,22 @@ public async Task CreateOrUpdate_CreateUpdateMaintenanceConfigurationWithMainten ContainerServiceMaintenanceConfigurationCollection collection = containerServiceManagedCluster.GetContainerServiceMaintenanceConfigurations(); // invoke the operation - string configName = "aksManagedAutoUpgradeSchedule"; - ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData() - { - MaintenanceWindow = new ContainerServiceMaintenanceWindow(new ContainerServiceMaintenanceSchedule() - { - RelativeMonthly = new ContainerServiceMaintenanceRelativeMonthlySchedule(3, ContainerServiceMaintenanceRelativeMonthlyScheduleWeekIndex.First, ContainerServiceWeekDay.Monday), - }, 10, "08:30") - { - UtcOffset = "+05:30", - StartDate = "2023-01-01", - NotAllowedDates = -{ -new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-02-18"),DateTimeOffset.Parse("2023-02-25")),new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-12-23"),DateTimeOffset.Parse("2024-01-05")) -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configName, data); - ContainerServiceMaintenanceConfigurationResource result = lro.Value; + string configName = "aksManagedNodeOSUpgradeSchedule"; + NullableResponse response = await collection.GetIfExistsAsync(configName); + ContainerServiceMaintenanceConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceMaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationResource.cs index 34417b353ab07..bacc1890041f0 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationResource.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceMaintenanceConfigurationResource.cs @@ -80,10 +80,10 @@ public async Task Get_GetMaintenanceConfigurationConfiguredWithMaintenanceWindow [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateUpdateMaintenanceConfiguration() + public async Task Delete_DeleteMaintenanceConfiguration() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update.json - // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsDelete.json + // this example is just showing the usage of "MaintenanceConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,44 +100,17 @@ public async Task Update_CreateUpdateMaintenanceConfiguration() ContainerServiceMaintenanceConfigurationResource containerServiceMaintenanceConfiguration = client.GetContainerServiceMaintenanceConfigurationResource(containerServiceMaintenanceConfigurationResourceId); // invoke the operation - ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData() - { - TimesInWeek = -{ -new ContainerServiceTimeInWeek() -{ -Day = ContainerServiceWeekDay.Monday, -HourSlots = -{ -1,2 -}, -} -}, - NotAllowedTimes = -{ -new ContainerServiceTimeSpan() -{ -StartOn = DateTimeOffset.Parse("2020-11-26T03:00:00Z"), -EndOn = DateTimeOffset.Parse("2020-11-30T12:00:00Z"), -} -}, - }; - ArmOperation lro = await containerServiceMaintenanceConfiguration.UpdateAsync(WaitUntil.Completed, data); - ContainerServiceMaintenanceConfigurationResource result = lro.Value; + await containerServiceMaintenanceConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceMaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateUpdateMaintenanceConfigurationWithMaintenanceWindow() + public async Task Delete_DeleteMaintenanceConfigurationForNodeOSUpgrade() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update_MaintenanceWindow.json - // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsDelete_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,42 +122,22 @@ public async Task Update_CreateUpdateMaintenanceConfigurationWithMaintenanceWind string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string resourceName = "clustername1"; - string configName = "aksManagedAutoUpgradeSchedule"; + string configName = "aksManagedNodeOSUpgradeSchedule"; ResourceIdentifier containerServiceMaintenanceConfigurationResourceId = ContainerServiceMaintenanceConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, configName); ContainerServiceMaintenanceConfigurationResource containerServiceMaintenanceConfiguration = client.GetContainerServiceMaintenanceConfigurationResource(containerServiceMaintenanceConfigurationResourceId); // invoke the operation - ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData() - { - MaintenanceWindow = new ContainerServiceMaintenanceWindow(new ContainerServiceMaintenanceSchedule() - { - RelativeMonthly = new ContainerServiceMaintenanceRelativeMonthlySchedule(3, ContainerServiceMaintenanceRelativeMonthlyScheduleWeekIndex.First, ContainerServiceWeekDay.Monday), - }, 10, "08:30") - { - UtcOffset = "+05:30", - StartDate = "2023-01-01", - NotAllowedDates = -{ -new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-02-18"),DateTimeOffset.Parse("2023-02-25")),new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-12-23"),DateTimeOffset.Parse("2024-01-05")) -}, - }, - }; - ArmOperation lro = await containerServiceMaintenanceConfiguration.UpdateAsync(WaitUntil.Completed, data); - ContainerServiceMaintenanceConfigurationResource result = lro.Value; + await containerServiceMaintenanceConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceMaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteMaintenanceConfiguration() + public async Task Update_CreateUpdateMaintenanceConfiguration() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsDelete.json - // this example is just showing the usage of "MaintenanceConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update.json + // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -201,17 +154,35 @@ public async Task Delete_DeleteMaintenanceConfiguration() ContainerServiceMaintenanceConfigurationResource containerServiceMaintenanceConfiguration = client.GetContainerServiceMaintenanceConfigurationResource(containerServiceMaintenanceConfigurationResourceId); // invoke the operation - await containerServiceMaintenanceConfiguration.DeleteAsync(WaitUntil.Completed); + ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData + { + TimesInWeek = {new ContainerServiceTimeInWeek +{ +Day = ContainerServiceWeekDay.Monday, +HourSlots = {1, 2}, +}}, + NotAllowedTimes = {new ContainerServiceTimeSpan +{ +StartOn = DateTimeOffset.Parse("2020-11-26T03:00:00Z"), +EndOn = DateTimeOffset.Parse("2020-11-30T12:00:00Z"), +}}, + }; + ArmOperation lro = await containerServiceMaintenanceConfiguration.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceMaintenanceConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteMaintenanceConfigurationForNodeOSUpgrade() + public async Task Update_CreateUpdateMaintenanceConfigurationWithMaintenanceWindow() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsDelete_MaintenanceWindow.json - // this example is just showing the usage of "MaintenanceConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/MaintenanceConfigurationsCreate_Update_MaintenanceWindow.json + // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -223,14 +194,31 @@ public async Task Delete_DeleteMaintenanceConfigurationForNodeOSUpgrade() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string resourceName = "clustername1"; - string configName = "aksManagedNodeOSUpgradeSchedule"; + string configName = "aksManagedAutoUpgradeSchedule"; ResourceIdentifier containerServiceMaintenanceConfigurationResourceId = ContainerServiceMaintenanceConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, configName); ContainerServiceMaintenanceConfigurationResource containerServiceMaintenanceConfiguration = client.GetContainerServiceMaintenanceConfigurationResource(containerServiceMaintenanceConfigurationResourceId); // invoke the operation - await containerServiceMaintenanceConfiguration.DeleteAsync(WaitUntil.Completed); + ContainerServiceMaintenanceConfigurationData data = new ContainerServiceMaintenanceConfigurationData + { + MaintenanceWindow = new ContainerServiceMaintenanceWindow(new ContainerServiceMaintenanceSchedule + { + RelativeMonthly = new ContainerServiceMaintenanceRelativeMonthlySchedule(3, ContainerServiceMaintenanceRelativeMonthlyScheduleWeekIndex.First, ContainerServiceWeekDay.Monday), + }, 10, "08:30") + { + UtcOffset = "+05:30", + StartDate = "2023-01-01", + NotAllowedDates = { new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-02-18"), DateTimeOffset.Parse("2023-02-25")), new ContainerServiceDateSpan(DateTimeOffset.Parse("2023-12-23"), DateTimeOffset.Parse("2024-01-05")) }, + }, + }; + ArmOperation lro = await containerServiceMaintenanceConfiguration.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceMaintenanceConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceMaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterCollection.cs index d12bb001d3f29..76550907a7dec 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterCollection.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterCollection.cs @@ -18,144 +18,6 @@ namespace Azure.ResourceManager.ContainerService.Samples { public partial class Sample_ContainerServiceManagedClusterCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetManagedClustersByResourceGroup() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListByResourceGroup.json - // this example is just showing the usage of "ManagedClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ContainerServiceManagedClusterResource - ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); - - // invoke the operation and iterate over the result - await foreach (ContainerServiceManagedClusterResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceManagedClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedCluster() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json - // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ContainerServiceManagedClusterResource - ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); - - // invoke the operation - string resourceName = "clustername1"; - ContainerServiceManagedClusterResource result = await collection.GetAsync(resourceName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceManagedClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagedCluster() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json - // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ContainerServiceManagedClusterResource - ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); - - // invoke the operation - string resourceName = "clustername1"; - bool result = await collection.ExistsAsync(resourceName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagedCluster() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json - // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ContainerServiceManagedClusterResource - ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); - - // invoke the operation - string resourceName = "clustername1"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - ContainerServiceManagedClusterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceManagedClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateManagedClusterUsingAnAgentPoolSnapshot() @@ -182,16 +44,14 @@ public async Task CreateOrUpdate_CreateManagedClusterUsingAnAgentPoolSnapshot() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -201,8 +61,7 @@ public async Task CreateOrUpdate_CreateManagedClusterUsingAnAgentPoolSnapshot() EnableNodePublicIP = true, EnableFips = true, CreationDataSourceResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ContainerService/snapshots/snapshot1"), -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -215,24 +74,22 @@ public async Task CreateOrUpdate_CreateManagedClusterUsingAnAgentPoolSnapshot() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = false, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -241,7 +98,7 @@ public async Task CreateOrUpdate_CreateManagedClusterUsingAnAgentPoolSnapshot() Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -280,16 +137,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithAKSManagedNATGatewayAsO string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -297,8 +152,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithAKSManagedNATGatewayAsO AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, EnableNodePublicIP = false, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -311,21 +165,19 @@ public async Task CreateOrUpdate_CreateManagedClusterWithAKSManagedNATGatewayAsO { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.ManagedNatGateway, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - NatGatewayProfile = new ManagedClusterNatGatewayProfile() + NatGatewayProfile = new ManagedClusterNatGatewayProfile { ManagedOutboundIPCount = 2, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -334,7 +186,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithAKSManagedNATGatewayAsO Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -373,16 +225,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithAzureKeyVaultSecretsPro string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -390,8 +240,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithAzureKeyVaultSecretsPro AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -411,25 +260,25 @@ public async Task CreateOrUpdate_CreateManagedClusterWithAzureKeyVaultSecretsPro Config = { ["enableSecretRotation"] = "true", -["rotationPollInterval"] = "2m", -}, +["rotationPollInterval"] = "2m" }, +} }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -438,7 +287,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithAzureKeyVaultSecretsPro Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -477,16 +326,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithCapacityReservationGrou string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -495,8 +342,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithCapacityReservationGrou Mode = AgentPoolMode.System, EnableNodePublicIP = true, CapacityReservationGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/capacityReservationGroups/crg1"), -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -509,24 +355,22 @@ public async Task CreateOrUpdate_CreateManagedClusterWithCapacityReservationGrou { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -535,7 +379,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithCapacityReservationGrou Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -574,16 +418,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithDedicatedHostGroup() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -591,8 +433,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithDedicatedHostGroup() AgentPoolType = AgentPoolType.VirtualMachineScaleSets, EnableNodePublicIP = true, HostGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg/providers/Microsoft.Compute/hostGroups/hostgroup1"), -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -605,24 +446,22 @@ public async Task CreateOrUpdate_CreateManagedClusterWithDedicatedHostGroup() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = false, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -631,7 +470,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithDedicatedHostGroup() Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -670,16 +509,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithEncryptionAtHostEnabled string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -688,8 +525,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithEncryptionAtHostEnabled Mode = AgentPoolMode.System, EnableNodePublicIP = true, EnableEncryptionAtHost = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -702,24 +538,22 @@ public async Task CreateOrUpdate_CreateManagedClusterWithEncryptionAtHostEnabled { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -728,7 +562,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithEncryptionAtHostEnabled Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -767,16 +601,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithFIPSEnabledOS() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -785,8 +617,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithFIPSEnabledOS() Mode = AgentPoolMode.System, EnableNodePublicIP = true, EnableFips = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -799,24 +630,22 @@ public async Task CreateOrUpdate_CreateManagedClusterWithFIPSEnabledOS() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = false, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -825,7 +654,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithFIPSEnabledOS() Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -864,16 +693,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithGPUMIG() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_ND96asr_v4", @@ -882,8 +709,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithGPUMIG() Mode = AgentPoolMode.System, EnableNodePublicIP = true, GpuInstanceProfile = GpuInstanceProfile.Mig3G, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -896,43 +722,38 @@ public async Task CreateOrUpdate_CreateManagedClusterWithGPUMIG() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", }, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), - HttpProxyConfig = new ManagedClusterHttpProxyConfig() + HttpProxyConfig = new ManagedClusterHttpProxyConfig { HttpProxy = "http://myproxy.server.com:8080", HttpsProxy = "https://myproxy.server.com:8080", - NoProxy = -{ -"localhost","127.0.0.1" -}, + NoProxy = { "localhost", "127.0.0.1" }, TrustedCA = "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=", }, Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -971,16 +792,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithHTTPProxyConfigured() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -988,8 +807,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithHTTPProxyConfigured() AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -1002,43 +820,38 @@ public async Task CreateOrUpdate_CreateManagedClusterWithHTTPProxyConfigured() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", }, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), - HttpProxyConfig = new ManagedClusterHttpProxyConfig() + HttpProxyConfig = new ManagedClusterHttpProxyConfig { HttpProxy = "http://myproxy.server.com:8080", HttpsProxy = "https://myproxy.server.com:8080", - NoProxy = -{ -"localhost","127.0.0.1" -}, + NoProxy = { "localhost", "127.0.0.1" }, TrustedCA = "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=", }, Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -1077,16 +890,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithLongTermSupport() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = ManagedClusterSkuName.Base, Tier = ManagedClusterSkuTier.Premium, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -1095,8 +906,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithLongTermSupport() Mode = AgentPoolMode.System, EnableNodePublicIP = true, EnableEncryptionAtHost = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -1109,37 +919,35 @@ public async Task CreateOrUpdate_CreateManagedClusterWithLongTermSupport() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, SupportPlan = KubernetesSupportPlan.AKSLongTermSupport, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", }, - ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile() + ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile { DisableRunCommand = true, }, Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -1178,16 +986,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithNodePublicIPPrefix() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -1196,8 +1002,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithNodePublicIPPrefix() Mode = AgentPoolMode.System, EnableNodePublicIP = true, NodePublicIPPrefixId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Network/publicIPPrefixes/public-ip-prefix"), -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -1210,24 +1015,22 @@ public async Task CreateOrUpdate_CreateManagedClusterWithNodePublicIPPrefix() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -1236,7 +1039,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithNodePublicIPPrefix() Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -1275,16 +1078,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithOSSKU() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -1293,8 +1094,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithOSSKU() AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -1307,43 +1107,38 @@ public async Task CreateOrUpdate_CreateManagedClusterWithOSSKU() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", }, DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), - HttpProxyConfig = new ManagedClusterHttpProxyConfig() + HttpProxyConfig = new ManagedClusterHttpProxyConfig { HttpProxy = "http://myproxy.server.com:8080", HttpsProxy = "https://myproxy.server.com:8080", - NoProxy = -{ -"localhost","127.0.0.1" -}, + NoProxy = { "localhost", "127.0.0.1" }, TrustedCA = "Q29uZ3JhdHMhIFlvdSBoYXZlIGZvdW5kIGEgaGlkZGVuIG1lc3NhZ2U=", }, Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -1382,16 +1177,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithPPG() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -1400,8 +1193,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithPPG() Mode = AgentPoolMode.System, EnableNodePublicIP = true, ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/proximityPlacementGroups/ppg1"), -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -1414,24 +1206,22 @@ public async Task CreateOrUpdate_CreateManagedClusterWithPPG() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -1440,7 +1230,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithPPG() Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -1479,16 +1269,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithPodIdentityEnabled() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -1496,8 +1284,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithPodIdentityEnabled() AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -1510,29 +1297,27 @@ public async Task CreateOrUpdate_CreateManagedClusterWithPodIdentityEnabled() { Secret = "secret", }, - AddonProfiles = -{ -}, - PodIdentityProfile = new ManagedClusterPodIdentityProfile() + AddonProfiles = { }, + PodIdentityProfile = new ManagedClusterPodIdentityProfile { IsEnabled = true, AllowNetworkPluginKubenet = true, }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -1541,7 +1326,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithPodIdentityEnabled() Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -1580,16 +1365,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithRunCommandDisabled() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -1598,8 +1381,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithRunCommandDisabled() Mode = AgentPoolMode.System, EnableNodePublicIP = true, EnableEncryptionAtHost = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -1612,36 +1394,34 @@ public async Task CreateOrUpdate_CreateManagedClusterWithRunCommandDisabled() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", }, - ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile() + ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile { DisableRunCommand = true, }, Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -1680,16 +1460,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithSecurityProfileConfigur string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -1697,27 +1475,26 @@ public async Task CreateOrUpdate_CreateManagedClusterWithSecurityProfileConfigur AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") })), - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - SecurityProfile = new ManagedClusterSecurityProfile() + SecurityProfile = new ManagedClusterSecurityProfile { - Defender = new ManagedClusterSecurityProfileDefender() + Defender = new ManagedClusterSecurityProfileDefender { LogAnalyticsWorkspaceResourceId = new ResourceIdentifier("/subscriptions/SUB_ID/resourcegroups/RG_NAME/providers/microsoft.operationalinsights/workspaces/WORKSPACE_NAME"), IsSecurityMonitoringEnabled = true, @@ -1727,7 +1504,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithSecurityProfileConfigur Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -1766,16 +1543,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithUltraSSDEnabled() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -1784,8 +1559,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithUltraSSDEnabled() Mode = AgentPoolMode.System, EnableNodePublicIP = true, EnableUltraSsd = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -1798,24 +1572,22 @@ public async Task CreateOrUpdate_CreateManagedClusterWithUltraSSDEnabled() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -1824,7 +1596,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithUltraSSDEnabled() Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -1863,16 +1635,14 @@ public async Task CreateOrUpdate_CreateManagedClusterWithUserAssignedNATGatewayA string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -1880,8 +1650,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithUserAssignedNATGatewayA AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, EnableNodePublicIP = false, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -1894,17 +1663,15 @@ public async Task CreateOrUpdate_CreateManagedClusterWithUserAssignedNATGatewayA { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.UserAssignedNatGateway, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -1913,7 +1680,7 @@ public async Task CreateOrUpdate_CreateManagedClusterWithUserAssignedNATGatewayA Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -1952,16 +1719,14 @@ public async Task CreateOrUpdate_CreateManagedPrivateClusterWithPublicFQDNSpecif string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -1970,8 +1735,7 @@ public async Task CreateOrUpdate_CreateManagedPrivateClusterWithPublicFQDNSpecif Mode = AgentPoolMode.System, EnableNodePublicIP = true, EnableEncryptionAtHost = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -1984,29 +1748,27 @@ public async Task CreateOrUpdate_CreateManagedPrivateClusterWithPublicFQDNSpecif { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", }, - ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile() + ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile { EnablePrivateCluster = true, EnablePrivateClusterPublicFqdn = true, @@ -2014,7 +1776,7 @@ public async Task CreateOrUpdate_CreateManagedPrivateClusterWithPublicFQDNSpecif Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -2053,16 +1815,14 @@ public async Task CreateOrUpdate_CreateManagedPrivateClusterWithFqdnSubdomainSpe string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", FqdnSubdomain = "domain1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -2071,8 +1831,7 @@ public async Task CreateOrUpdate_CreateManagedPrivateClusterWithFqdnSubdomainSpe Mode = AgentPoolMode.System, EnableNodePublicIP = true, EnableEncryptionAtHost = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -2085,29 +1844,27 @@ public async Task CreateOrUpdate_CreateManagedPrivateClusterWithFqdnSubdomainSpe { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", }, - ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile() + ApiServerAccessProfile = new ManagedClusterApiServerAccessProfile { EnablePrivateCluster = true, PrivateDnsZone = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Network/privateDnsZones/privatelink.location1.azmk8s.io", @@ -2115,7 +1872,7 @@ public async Task CreateOrUpdate_CreateManagedPrivateClusterWithFqdnSubdomainSpe Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -2154,29 +1911,23 @@ public async Task CreateOrUpdate_CreateUpdateAADManagedClusterWithEnableAzureRBA string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS1_v2", OSType = ContainerServiceOSType.Linux, AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, -AvailabilityZones = -{ -"1","2","3" -}, +AvailabilityZones = {"1", "2", "3"}, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -2189,29 +1940,27 @@ public async Task CreateOrUpdate_CreateUpdateAADManagedClusterWithEnableAzureRBA { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AadProfile = new ManagedClusterAadProfile() + AadProfile = new ManagedClusterAadProfile { IsManagedAadEnabled = true, IsAzureRbacEnabled = true, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -2220,7 +1969,7 @@ public async Task CreateOrUpdate_CreateUpdateAADManagedClusterWithEnableAzureRBA Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -2259,24 +2008,22 @@ public async Task CreateOrUpdate_CreateUpdateManagedCluster() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, - ClusterIdentity = new ManagedClusterIdentity() + ClusterIdentity = new ManagedClusterIdentity { ResourceIdentityType = "UserAssigned", UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity() }, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS1_v2", @@ -2284,13 +2031,9 @@ public async Task CreateOrUpdate_CreateUpdateManagedCluster() ScaleDownMode = ScaleDownMode.Deallocate, AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, -AvailabilityZones = -{ -"1","2","3" -}, +AvailabilityZones = {"1", "2", "3"}, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -2303,29 +2046,27 @@ public async Task CreateOrUpdate_CreateUpdateManagedCluster() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - UpgradeOverrideSettings = new UpgradeOverrideSettings() + UpgradeOverrideSettings = new UpgradeOverrideSettings { ForceUpgrade = false, Until = DateTimeOffset.Parse("2022-11-01T13:00:00Z"), }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { BalanceSimilarNodeGroups = "true", Expander = AutoScaleExpander.Priority, @@ -2339,7 +2080,7 @@ public async Task CreateOrUpdate_CreateUpdateManagedCluster() Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -2378,16 +2119,14 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithAzureServiceMesh( string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS2_v2", @@ -2395,8 +2134,7 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithAzureServiceMesh( AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -2416,25 +2154,25 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithAzureServiceMesh( Config = { ["enableSecretRotation"] = "true", -["rotationPollInterval"] = "2m", -}, +["rotationPollInterval"] = "2m" }, +} }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -2442,26 +2180,20 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithAzureServiceMesh( DiskEncryptionSetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.Compute/diskEncryptionSets/des"), ServiceMeshProfile = new ServiceMeshProfile(ServiceMeshMode.Istio) { - Istio = new IstioServiceMesh() + Istio = new IstioServiceMesh { - Components = new IstioComponents() + Components = new IstioComponents { - IngressGateways = -{ -new IstioIngressGateway(IstioIngressGatewayMode.Internal,true) -}, - EgressGateways = -{ -new IstioEgressGateway(true) + IngressGateways = { new IstioIngressGateway(IstioIngressGatewayMode.Internal, true) }, + EgressGateways = {new IstioEgressGateway(true) { NodeSelector = { -["istio"] = "egress", -}, -} +["istio"] = "egress" }, +}}, }, - CertificateAuthorityPlugin = new IstioPluginCertificateAuthority() + CertificateAuthorityPlugin = new IstioPluginCertificateAuthority { KeyVaultId = new ResourceIdentifier("/subscriptions/854c9ddb-fe9e-4aea-8d58-99ed88282881/resourceGroups/ddama-test/providers/Microsoft.KeyVault/vaults/my-akv"), CertObjectName = "ca-cert", @@ -2474,7 +2206,7 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithAzureServiceMesh( Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -2513,37 +2245,31 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithEnableAHUB() string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, - ClusterIdentity = new ManagedClusterIdentity() + ClusterIdentity = new ManagedClusterIdentity { ResourceIdentityType = "UserAssigned", UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity() }, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS1_v2", OSType = ContainerServiceOSType.Linux, AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, -AvailabilityZones = -{ -"1","2","3" -}, +AvailabilityZones = {"1", "2", "3"}, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -2557,24 +2283,22 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithEnableAHUB() { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -2583,7 +2307,7 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithEnableAHUB() Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -2622,37 +2346,31 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithWindowsGMSAEnable string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, - ClusterIdentity = new ManagedClusterIdentity() + ClusterIdentity = new ManagedClusterIdentity { ResourceIdentityType = "UserAssigned", UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity() }, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS1_v2", OSType = ContainerServiceOSType.Linux, AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, -AvailabilityZones = -{ -"1","2","3" -}, +AvailabilityZones = {"1", "2", "3"}, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -2660,7 +2378,7 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithWindowsGMSAEnable WindowsProfile = new ManagedClusterWindowsProfile("azureuser") { AdminPassword = "replacePassword1234$", - GmsaProfile = new WindowsGmsaProfile() + GmsaProfile = new WindowsGmsaProfile { IsEnabled = true, }, @@ -2669,24 +2387,22 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithWindowsGMSAEnable { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { ScanIntervalInSeconds = "20s", ScaleDownDelayAfterAdd = "15m", @@ -2695,7 +2411,7 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithWindowsGMSAEnable Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -2734,24 +2450,22 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithDualStackNetworki string resourceName = "clustername1"; ContainerServiceManagedClusterData data = new ContainerServiceManagedClusterData(new AzureLocation("location1")) { - Sku = new ManagedClusterSku() + Sku = new ManagedClusterSku { Name = new ManagedClusterSkuName("Basic"), Tier = ManagedClusterSkuTier.Free, }, - ClusterIdentity = new ManagedClusterIdentity() + ClusterIdentity = new ManagedClusterIdentity { ResourceIdentityType = "UserAssigned", UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rgName1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity() }, }, KubernetesVersion = "", DnsPrefix = "dnsprefix1", - AgentPoolProfiles = -{ -new ManagedClusterAgentPoolProfile("nodepool1") + AgentPoolProfiles = {new ManagedClusterAgentPoolProfile("nodepool1") { Count = 3, VmSize = "Standard_DS1_v2", @@ -2759,13 +2473,9 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithDualStackNetworki ScaleDownMode = ScaleDownMode.Deallocate, AgentPoolType = AgentPoolType.VirtualMachineScaleSets, Mode = AgentPoolMode.System, -AvailabilityZones = -{ -"1","2","3" -}, +AvailabilityZones = {"1", "2", "3"}, EnableNodePublicIP = true, -} -}, +}}, LinuxProfile = new ContainerServiceLinuxProfile("azureuser", new ContainerServiceSshConfiguration(new ContainerServiceSshPublicKey[] { new ContainerServiceSshPublicKey("keydata") @@ -2778,28 +2488,23 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithDualStackNetworki { Secret = "secret", }, - AddonProfiles = -{ -}, + AddonProfiles = { }, EnableRbac = true, EnablePodSecurityPolicy = true, - NetworkProfile = new ContainerServiceNetworkProfile() + NetworkProfile = new ContainerServiceNetworkProfile { OutboundType = ContainerServiceOutboundType.LoadBalancer, LoadBalancerSku = ContainerServiceLoadBalancerSku.Standard, - LoadBalancerProfile = new ManagedClusterLoadBalancerProfile() + LoadBalancerProfile = new ManagedClusterLoadBalancerProfile { - ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs() + ManagedOutboundIPs = new ManagedClusterLoadBalancerProfileManagedOutboundIPs { Count = 2, }, }, - IPFamilies = -{ -IPFamily.IPv4,IPFamily.IPv6 -}, + IPFamilies = { IPFamily.IPv4, IPFamily.IPv6 }, }, - AutoScalerProfile = new ManagedClusterAutoScalerProfile() + AutoScalerProfile = new ManagedClusterAutoScalerProfile { BalanceSimilarNodeGroups = "true", Expander = AutoScaleExpander.Priority, @@ -2813,7 +2518,7 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithDualStackNetworki Tags = { ["archv2"] = "", -["tier"] = "production", +["tier"] = "production" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -2825,5 +2530,143 @@ public async Task CreateOrUpdate_CreateUpdateManagedClusterWithDualStackNetworki // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json + // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + ContainerServiceManagedClusterResource result = await collection.GetAsync(resourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetManagedClustersByResourceGroup() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListByResourceGroup.json + // this example is just showing the usage of "ManagedClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceManagedClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json + // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + bool result = await collection.ExistsAsync(resourceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetManagedCluster() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json + // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ContainerServiceManagedClusterResource + ContainerServiceManagedClusterCollection collection = resourceGroupResource.GetContainerServiceManagedClusters(); + + // invoke the operation + string resourceName = "clustername1"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + ContainerServiceManagedClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterResource.cs index 20961cb545f7b..6d601b6ae0e4d 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterResource.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceManagedClusterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ContainerService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ContainerService.Samples @@ -19,41 +18,10 @@ public partial class Sample_ContainerServiceManagedClusterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetContainerServiceManagedClusters_ListManagedClusters() - { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersList.json - // this example is just showing the usage of "ManagedClusters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ContainerServiceManagedClusterResource item in subscriptionResource.GetContainerServiceManagedClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceManagedClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAccessProfile_GetManagedCluster() + public async Task Get_GetManagedCluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGetAccessProfile.json - // this example is just showing the usage of "ManagedClusters_GetAccessProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json + // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,18 +37,21 @@ public async Task GetAccessProfile_GetManagedCluster() ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); // invoke the operation - string roleName = "clusterUser"; - ManagedClusterAccessProfile result = await containerServiceManagedCluster.GetAccessProfileAsync(roleName); + ContainerServiceManagedClusterResource result = await containerServiceManagedCluster.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetClusterAdminCredentials_GetManagedCluster() + public async Task Delete_DeleteManagedCluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListClusterAdminCredentials.json - // this example is just showing the usage of "ManagedClusters_ListClusterAdminCredentials" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersDelete.json + // this example is just showing the usage of "ManagedClusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,17 +67,17 @@ public async Task GetClusterAdminCredentials_GetManagedCluster() ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); // invoke the operation - ManagedClusterCredentials result = await containerServiceManagedCluster.GetClusterAdminCredentialsAsync(); + await containerServiceManagedCluster.DeleteAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetClusterUserCredentials_GetManagedCluster() + public async Task Update_UpdateManagedClusterTags() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListClusterUserCredentials.json - // this example is just showing the usage of "ManagedClusters_ListClusterUserCredentials" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersUpdateTags.json + // this example is just showing the usage of "ManagedClusters_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,17 +93,30 @@ public async Task GetClusterUserCredentials_GetManagedCluster() ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); // invoke the operation - ManagedClusterCredentials result = await containerServiceManagedCluster.GetClusterUserCredentialsAsync(); + ContainerServiceTagsObject containerServiceTagsObject = new ContainerServiceTagsObject + { + Tags = +{ +["archv3"] = "", +["tier"] = "testing" +}, + }; + ArmOperation lro = await containerServiceManagedCluster.UpdateAsync(WaitUntil.Completed, containerServiceTagsObject); + ContainerServiceManagedClusterResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetClusterMonitoringUserCredentials_GetManagedCluster() + public async Task GetAccessProfile_GetManagedCluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListClusterMonitoringUserCredentials.json - // this example is just showing the usage of "ManagedClusters_ListClusterMonitoringUserCredentials" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGetAccessProfile.json + // this example is just showing the usage of "ManagedClusters_GetAccessProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,17 +132,18 @@ public async Task GetClusterMonitoringUserCredentials_GetManagedCluster() ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); // invoke the operation - ManagedClusterCredentials result = await containerServiceManagedCluster.GetClusterMonitoringUserCredentialsAsync(); + string roleName = "clusterUser"; + ManagedClusterAccessProfile result = await containerServiceManagedCluster.GetAccessProfileAsync(roleName); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedCluster() + public async Task GetClusterAdminCredentials_GetManagedCluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet.json - // this example is just showing the usage of "ManagedClusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListClusterAdminCredentials.json + // this example is just showing the usage of "ManagedClusters_ListClusterAdminCredentials" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,21 +159,17 @@ public async Task Get_GetManagedCluster() ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); // invoke the operation - ContainerServiceManagedClusterResource result = await containerServiceManagedCluster.GetAsync(); + ManagedClusterCredentials result = await containerServiceManagedCluster.GetClusterAdminCredentialsAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceManagedClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateManagedClusterTags() + public async Task GetClusterUserCredentials_GetManagedCluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersUpdateTags.json - // this example is just showing the usage of "ManagedClusters_UpdateTags" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListClusterUserCredentials.json + // this example is just showing the usage of "ManagedClusters_ListClusterUserCredentials" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,30 +185,17 @@ public async Task Update_UpdateManagedClusterTags() ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); // invoke the operation - ContainerServiceTagsObject containerServiceTagsObject = new ContainerServiceTagsObject() - { - Tags = -{ -["archv3"] = "", -["tier"] = "testing", -}, - }; - ArmOperation lro = await containerServiceManagedCluster.UpdateAsync(WaitUntil.Completed, containerServiceTagsObject); - ContainerServiceManagedClusterResource result = lro.Value; + ManagedClusterCredentials result = await containerServiceManagedCluster.GetClusterUserCredentialsAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceManagedClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteManagedCluster() + public async Task GetClusterMonitoringUserCredentials_GetManagedCluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersDelete.json - // this example is just showing the usage of "ManagedClusters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersListClusterMonitoringUserCredentials.json + // this example is just showing the usage of "ManagedClusters_ListClusterMonitoringUserCredentials" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -243,9 +211,9 @@ public async Task Delete_DeleteManagedCluster() ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); // invoke the operation - await containerServiceManagedCluster.DeleteAsync(WaitUntil.Completed); + ManagedClusterCredentials result = await containerServiceManagedCluster.GetClusterMonitoringUserCredentialsAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -299,7 +267,7 @@ public async Task ResetAadProfile_ResetAADProfile() ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); // invoke the operation - ManagedClusterAadProfile managedClusterAadProfile = new ManagedClusterAadProfile() + ManagedClusterAadProfile managedClusterAadProfile = new ManagedClusterAadProfile { ClientAppId = Guid.Parse("clientappid"), ServerAppId = Guid.Parse("serverappid"), @@ -632,7 +600,7 @@ public async Task ResolvePrivateLinkServiceId_ResolveThePrivateLinkServiceIDForM ContainerServiceManagedClusterResource containerServiceManagedCluster = client.GetContainerServiceManagedClusterResource(containerServiceManagedClusterResourceId); // invoke the operation - ContainerServicePrivateLinkResourceData data = new ContainerServicePrivateLinkResourceData() + ContainerServicePrivateLinkResourceData data = new ContainerServicePrivateLinkResourceData { Name = "management", }; diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionCollection.cs index 6dac8393b886e..c86354e22e277 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionCollection.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ContainerServicePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateEndpointConnectionsByManagedCluster() + public async Task CreateOrUpdate_UpdatePrivateEndpointConnection() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsList.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_ListPrivateEndpointConnectionsByManagedCluster() // get the collection of this ContainerServicePrivateEndpointConnectionResource ContainerServicePrivateEndpointConnectionCollection collection = containerServiceManagedCluster.GetContainerServicePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (ContainerServicePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "privateendpointconnection1"; + ContainerServicePrivateEndpointConnectionData data = new ContainerServicePrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServicePrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new ContainerServicePrivateLinkServiceConnectionState + { + Status = ContainerServicePrivateLinkServiceConnectionStatus.Approved, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + ContainerServicePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +94,10 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateEndpointConnection() + public async Task GetAll_ListPrivateEndpointConnectionsByManagedCluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsList.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +115,22 @@ public async Task Exists_GetPrivateEndpointConnection() // get the collection of this ContainerServicePrivateEndpointConnectionResource ContainerServicePrivateEndpointConnectionCollection collection = containerServiceManagedCluster.GetContainerServicePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "privateendpointconnection1"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (ContainerServicePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServicePrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateEndpointConnection() + public async Task Exists_GetPrivateEndpointConnection() { // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +153,17 @@ public async Task GetIfExists_GetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "privateendpointconnection1"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - ContainerServicePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServicePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatePrivateEndpointConnection() + public async Task GetIfExists_GetPrivateEndpointConnection() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,21 +183,21 @@ public async Task CreateOrUpdate_UpdatePrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "privateendpointconnection1"; - ContainerServicePrivateEndpointConnectionData data = new ContainerServicePrivateEndpointConnectionData() - { - ConnectionState = new ContainerServicePrivateLinkServiceConnectionState() - { - Status = ContainerServicePrivateLinkServiceConnectionStatus.Approved, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - ContainerServicePrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + ContainerServicePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServicePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionResource.cs index 71ab12a168072..9e5acc67aca0e 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionResource.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServicePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatePrivateEndpointConnection() + public async Task Delete_DeletePrivateEndpointConnection() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsDelete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_UpdatePrivateEndpointConnection() ContainerServicePrivateEndpointConnectionResource containerServicePrivateEndpointConnection = client.GetContainerServicePrivateEndpointConnectionResource(containerServicePrivateEndpointConnectionResourceId); // invoke the operation - ContainerServicePrivateEndpointConnectionData data = new ContainerServicePrivateEndpointConnectionData() - { - ConnectionState = new ContainerServicePrivateLinkServiceConnectionState() - { - Status = ContainerServicePrivateLinkServiceConnectionStatus.Approved, - }, - }; - ArmOperation lro = await containerServicePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - ContainerServicePrivateEndpointConnectionResource result = lro.Value; + await containerServicePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServicePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateEndpointConnection() + public async Task Update_UpdatePrivateEndpointConnection() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsDelete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/PrivateEndpointConnectionsUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DeletePrivateEndpointConnection() ContainerServicePrivateEndpointConnectionResource containerServicePrivateEndpointConnection = client.GetContainerServicePrivateEndpointConnectionResource(containerServicePrivateEndpointConnectionResourceId); // invoke the operation - await containerServicePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + ContainerServicePrivateEndpointConnectionData data = new ContainerServicePrivateEndpointConnectionData + { + ConnectionState = new ContainerServicePrivateLinkServiceConnectionState + { + Status = ContainerServicePrivateLinkServiceConnectionStatus.Approved, + }, + }; + ArmOperation lro = await containerServicePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ContainerServicePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingCollection.cs index 17a3963eb57e7..0b58e1ae96a74 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingCollection.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ContainerServiceTrustedAccessRoleBindingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTrustedAccessRoleBindings() + public async Task CreateOrUpdate_CreateOrUpdateATrustedAccessRoleBinding() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_List.json - // this example is just showing the usage of "TrustedAccessRoleBindings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_CreateOrUpdate.json + // this example is just showing the usage of "TrustedAccessRoleBindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_ListTrustedAccessRoleBindings() // get the collection of this ContainerServiceTrustedAccessRoleBindingResource ContainerServiceTrustedAccessRoleBindingCollection collection = containerServiceManagedCluster.GetContainerServiceTrustedAccessRoleBindings(); - // invoke the operation and iterate over the result - await foreach (ContainerServiceTrustedAccessRoleBindingResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceTrustedAccessRoleBindingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string trustedAccessRoleBindingName = "binding1"; + ContainerServiceTrustedAccessRoleBindingData data = new ContainerServiceTrustedAccessRoleBindingData(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/b/providers/Microsoft.MachineLearningServices/workspaces/c"), new string[] { "Microsoft.MachineLearningServices/workspaces/reader", "Microsoft.MachineLearningServices/workspaces/writer" }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, trustedAccessRoleBindingName, data); + ContainerServiceTrustedAccessRoleBindingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_GetATrustedAccessRoleBinding() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetATrustedAccessRoleBinding() + public async Task GetAll_ListTrustedAccessRoleBindings() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_Get.json - // this example is just showing the usage of "TrustedAccessRoleBindings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_List.json + // this example is just showing the usage of "TrustedAccessRoleBindings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_GetATrustedAccessRoleBinding() // get the collection of this ContainerServiceTrustedAccessRoleBindingResource ContainerServiceTrustedAccessRoleBindingCollection collection = containerServiceManagedCluster.GetContainerServiceTrustedAccessRoleBindings(); - // invoke the operation - string trustedAccessRoleBindingName = "binding1"; - bool result = await collection.ExistsAsync(trustedAccessRoleBindingName); + // invoke the operation and iterate over the result + await foreach (ContainerServiceTrustedAccessRoleBindingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceTrustedAccessRoleBindingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetATrustedAccessRoleBinding() + public async Task Exists_GetATrustedAccessRoleBinding() { // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_Get.json // this example is just showing the usage of "TrustedAccessRoleBindings_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_GetATrustedAccessRoleBinding() // invoke the operation string trustedAccessRoleBindingName = "binding1"; - NullableResponse response = await collection.GetIfExistsAsync(trustedAccessRoleBindingName); - ContainerServiceTrustedAccessRoleBindingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(trustedAccessRoleBindingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateATrustedAccessRoleBinding() + public async Task GetIfExists_GetATrustedAccessRoleBinding() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_CreateOrUpdate.json - // this example is just showing the usage of "TrustedAccessRoleBindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_Get.json + // this example is just showing the usage of "TrustedAccessRoleBindings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +176,21 @@ public async Task CreateOrUpdate_CreateOrUpdateATrustedAccessRoleBinding() // invoke the operation string trustedAccessRoleBindingName = "binding1"; - ContainerServiceTrustedAccessRoleBindingData data = new ContainerServiceTrustedAccessRoleBindingData(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/b/providers/Microsoft.MachineLearningServices/workspaces/c"), new string[] - { -"Microsoft.MachineLearningServices/workspaces/reader","Microsoft.MachineLearningServices/workspaces/writer" - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, trustedAccessRoleBindingName, data); - ContainerServiceTrustedAccessRoleBindingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(trustedAccessRoleBindingName); + ContainerServiceTrustedAccessRoleBindingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingResource.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingResource.cs index b5d93f7b6ea56..6d9666b3d4c5f 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingResource.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_ContainerServiceTrustedAccessRoleBindingResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetATrustedAccessRoleBinding() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateATrustedAccessRoleBinding() + public async Task Delete_DeleteATrustedAccessRoleBinding() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_CreateOrUpdate.json - // this example is just showing the usage of "TrustedAccessRoleBindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_Delete.json + // this example is just showing the usage of "TrustedAccessRoleBindings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_CreateOrUpdateATrustedAccessRoleBinding() ContainerServiceTrustedAccessRoleBindingResource containerServiceTrustedAccessRoleBinding = client.GetContainerServiceTrustedAccessRoleBindingResource(containerServiceTrustedAccessRoleBindingResourceId); // invoke the operation - ContainerServiceTrustedAccessRoleBindingData data = new ContainerServiceTrustedAccessRoleBindingData(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/b/providers/Microsoft.MachineLearningServices/workspaces/c"), new string[] - { -"Microsoft.MachineLearningServices/workspaces/reader","Microsoft.MachineLearningServices/workspaces/writer" - }); - ArmOperation lro = await containerServiceTrustedAccessRoleBinding.UpdateAsync(WaitUntil.Completed, data); - ContainerServiceTrustedAccessRoleBindingResource result = lro.Value; + await containerServiceTrustedAccessRoleBinding.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteATrustedAccessRoleBinding() + public async Task Update_CreateOrUpdateATrustedAccessRoleBinding() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_Delete.json - // this example is just showing the usage of "TrustedAccessRoleBindings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/TrustedAccessRoleBindings_CreateOrUpdate.json + // this example is just showing the usage of "TrustedAccessRoleBindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,15 @@ public async Task Delete_DeleteATrustedAccessRoleBinding() ContainerServiceTrustedAccessRoleBindingResource containerServiceTrustedAccessRoleBinding = client.GetContainerServiceTrustedAccessRoleBindingResource(containerServiceTrustedAccessRoleBindingResourceId); // invoke the operation - await containerServiceTrustedAccessRoleBinding.DeleteAsync(WaitUntil.Completed); + ContainerServiceTrustedAccessRoleBindingData data = new ContainerServiceTrustedAccessRoleBindingData(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/b/providers/Microsoft.MachineLearningServices/workspaces/c"), new string[] { "Microsoft.MachineLearningServices/workspaces/reader", "Microsoft.MachineLearningServices/workspaces/writer" }); + ArmOperation lro = await containerServiceTrustedAccessRoleBinding.UpdateAsync(WaitUntil.Completed, data); + ContainerServiceTrustedAccessRoleBindingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceTrustedAccessRoleBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileCollection.cs index fb30abbf09d0a..a12ea79e1106c 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileCollection.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshRevisionProfileCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MeshRevisionProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListMeshRevisionProfilesInALocation() + public async Task Get_GetAMeshRevisionProfileForAMeshMode() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersList_MeshRevisionProfiles.json - // this example is just showing the usage of "ManagedClusters_ListMeshRevisionProfiles" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshRevisionProfile.json + // this example is just showing the usage of "ManagedClusters_GetMeshRevisionProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListMeshRevisionProfilesInALocation() AzureLocation location = new AzureLocation("location1"); MeshRevisionProfileCollection collection = subscriptionResource.GetMeshRevisionProfiles(location); - // invoke the operation and iterate over the result - await foreach (MeshRevisionProfileResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MeshRevisionProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string mode = "istio"; + MeshRevisionProfileResource result = await collection.GetAsync(mode); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshRevisionProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAMeshRevisionProfileForAMeshMode() + public async Task GetAll_ListMeshRevisionProfilesInALocation() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshRevisionProfile.json - // this example is just showing the usage of "ManagedClusters_GetMeshRevisionProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersList_MeshRevisionProfiles.json + // this example is just showing the usage of "ManagedClusters_ListMeshRevisionProfiles" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_GetAMeshRevisionProfileForAMeshMode() AzureLocation location = new AzureLocation("location1"); MeshRevisionProfileCollection collection = subscriptionResource.GetMeshRevisionProfiles(location); - // invoke the operation - string mode = "istio"; - MeshRevisionProfileResource result = await collection.GetAsync(mode); + // invoke the operation and iterate over the result + await foreach (MeshRevisionProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshRevisionProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MeshRevisionProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileCollection.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileCollection.cs index ad650abd50dbe..53dc0a0a6d5ce 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileCollection.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_MeshUpgradeProfileCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MeshUpgradeProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsVersionCompatibilityAndUpgradeProfileForAllServiceMeshesInACluster() + public async Task Get_GetsVersionCompatibilityAndUpgradeProfileForAServiceMeshInACluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersList_MeshUpgradeProfiles.json - // this example is just showing the usage of "ManagedClusters_ListMeshUpgradeProfiles" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshUpgradeProfile.json + // this example is just showing the usage of "ManagedClusters_GetMeshUpgradeProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListsVersionCompatibilityAndUpgradeProfileForAllService // get the collection of this MeshUpgradeProfileResource MeshUpgradeProfileCollection collection = containerServiceManagedCluster.GetMeshUpgradeProfiles(); - // invoke the operation and iterate over the result - await foreach (MeshUpgradeProfileResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MeshUpgradeProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string mode = "istio"; + MeshUpgradeProfileResource result = await collection.GetAsync(mode); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshUpgradeProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsVersionCompatibilityAndUpgradeProfileForAServiceMeshInACluster() + public async Task GetAll_ListsVersionCompatibilityAndUpgradeProfileForAllServiceMeshesInACluster() { - // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersGet_MeshUpgradeProfile.json - // this example is just showing the usage of "ManagedClusters_GetMeshUpgradeProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersList_MeshUpgradeProfiles.json + // this example is just showing the usage of "ManagedClusters_ListMeshUpgradeProfiles" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsVersionCompatibilityAndUpgradeProfileForAServiceMeshIn // get the collection of this MeshUpgradeProfileResource MeshUpgradeProfileCollection collection = containerServiceManagedCluster.GetMeshUpgradeProfiles(); - // invoke the operation - string mode = "istio"; - MeshUpgradeProfileResource result = await collection.GetAsync(mode); + // invoke the operation and iterate over the result + await foreach (MeshUpgradeProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MeshUpgradeProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MeshUpgradeProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 6f4590ccac0b2..d4e1e40228ea5 100644 --- a/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/containerservice/Azure.ResourceManager.ContainerService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -42,6 +42,68 @@ public async Task GetKubernetesVersionsManagedCluster_ListKubernetesVersions() Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetContainerServiceManagedClusters_ListManagedClusters() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/ManagedClustersList.json + // this example is just showing the usage of "ManagedClusters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ContainerServiceManagedClusterResource item in subscriptionResource.GetContainerServiceManagedClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContainerServiceManagedClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAgentPoolSnapshots_ListSnapshots() + { + // Generated from example definition: specification/containerservice/resource-manager/Microsoft.ContainerService/aks/stable/2023-10-01/examples/SnapshotsList.json + // this example is just showing the usage of "Snapshots_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AgentPoolSnapshotResource item in subscriptionResource.GetAgentPoolSnapshotsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgentPoolSnapshotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetTrustedAccessRoles_ListTrustedAccessRoles() diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraClusterCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraClusterCollection.cs index 6ee17eb4a1e75..a5a8a3e3c6668 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraClusterCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraClusterCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_CassandraClusterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBManagedCassandraClusterListByResourceGroup() + public async Task CreateOrUpdate_CosmosDBManagedCassandraClusterCreate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraClusterListByResourceGroup.json - // this example is just showing the usage of "CassandraClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraClusterCreate.json + // this example is just showing the usage of "CassandraClusters_CreateUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,47 @@ public async Task GetAll_CosmosDBManagedCassandraClusterListByResourceGroup() // get the collection of this CassandraClusterResource CassandraClusterCollection collection = resourceGroupResource.GetCassandraClusters(); - // invoke the operation and iterate over the result - await foreach (CassandraClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "cassandra-prod"; + CassandraClusterData data = new CassandraClusterData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new CassandraClusterProperties + { + DelegatedManagementSubnetId = new ResourceIdentifier("/subscriptions/536e130b-d7d6-4ac7-98a5-de20d69588d2/resourceGroups/customer-vnet-rg/providers/Microsoft.Network/virtualNetworks/customer-vnet/subnets/management"), + CassandraVersion = "3.11", + ClusterNameOverride = "ClusterNameIllegalForAzureResource", + AuthenticationMethod = CassandraAuthenticationMethod.Cassandra, + InitialCassandraAdminPassword = "mypassword", + ClientCertificates = {new CassandraCertificate +{ +Pem = "-----BEGIN CERTIFICATE-----\n...Base64 encoded certificate...\n-----END CERTIFICATE-----", +}}, + ExternalGossipCertificates = {new CassandraCertificate +{ +Pem = "-----BEGIN CERTIFICATE-----\n...Base64 encoded certificate...\n-----END CERTIFICATE-----", +}}, + ExternalSeedNodes = {new CassandraDataCenterSeedNode +{ +IPAddress = "10.52.221.2", +}, new CassandraDataCenterSeedNode +{ +IPAddress = "10.52.221.3", +}, new CassandraDataCenterSeedNode +{ +IPAddress = "10.52.221.4", +}}, + HoursBetweenBackups = 24, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); + CassandraClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +117,10 @@ public async Task Get_CosmosDBManagedCassandraClusterGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBManagedCassandraClusterGet() + public async Task GetAll_CosmosDBManagedCassandraClusterListByResourceGroup() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraClusterGet.json - // this example is just showing the usage of "CassandraClusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraClusterListByResourceGroup.json + // this example is just showing the usage of "CassandraClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +137,22 @@ public async Task Exists_CosmosDBManagedCassandraClusterGet() // get the collection of this CassandraClusterResource CassandraClusterCollection collection = resourceGroupResource.GetCassandraClusters(); - // invoke the operation - string clusterName = "cassandra-prod"; - bool result = await collection.ExistsAsync(clusterName); + // invoke the operation and iterate over the result + await foreach (CassandraClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBManagedCassandraClusterGet() + public async Task Exists_CosmosDBManagedCassandraClusterGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraClusterGet.json // this example is just showing the usage of "CassandraClusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +174,17 @@ public async Task GetIfExists_CosmosDBManagedCassandraClusterGet() // invoke the operation string clusterName = "cassandra-prod"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - CassandraClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBManagedCassandraClusterCreate() + public async Task GetIfExists_CosmosDBManagedCassandraClusterGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraClusterCreate.json - // this example is just showing the usage of "CassandraClusters_CreateUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraClusterGet.json + // this example is just showing the usage of "CassandraClusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,56 +203,21 @@ public async Task CreateOrUpdate_CosmosDBManagedCassandraClusterCreate() // invoke the operation string clusterName = "cassandra-prod"; - CassandraClusterData data = new CassandraClusterData(new AzureLocation("West US")) - { - Properties = new CassandraClusterProperties() - { - DelegatedManagementSubnetId = new ResourceIdentifier("/subscriptions/536e130b-d7d6-4ac7-98a5-de20d69588d2/resourceGroups/customer-vnet-rg/providers/Microsoft.Network/virtualNetworks/customer-vnet/subnets/management"), - CassandraVersion = "3.11", - ClusterNameOverride = "ClusterNameIllegalForAzureResource", - AuthenticationMethod = CassandraAuthenticationMethod.Cassandra, - InitialCassandraAdminPassword = "mypassword", - ClientCertificates = -{ -new CassandraCertificate() -{ -Pem = "-----BEGIN CERTIFICATE-----\n...Base64 encoded certificate...\n-----END CERTIFICATE-----", -} -}, - ExternalGossipCertificates = -{ -new CassandraCertificate() -{ -Pem = "-----BEGIN CERTIFICATE-----\n...Base64 encoded certificate...\n-----END CERTIFICATE-----", -} -}, - ExternalSeedNodes = -{ -new CassandraDataCenterSeedNode() -{ -IPAddress = "10.52.221.2", -},new CassandraDataCenterSeedNode() -{ -IPAddress = "10.52.221.3", -},new CassandraDataCenterSeedNode() -{ -IPAddress = "10.52.221.4", -} -}, - HoursBetweenBackups = 24, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); - CassandraClusterResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + CassandraClusterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraClusterResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraClusterResource.cs index 334d921f0532c..fd5497f34b549 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraClusterResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraClusterResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.CosmosDB.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CosmosDB.Samples { public partial class Sample_CassandraClusterResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCassandraClusters_CosmosDBManagedCassandraClusterListBySubscription() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraClusterListBySubscription.json - // this example is just showing the usage of "CassandraClusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CassandraClusterResource item in subscriptionResource.GetCassandraClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_CosmosDBManagedCassandraClusterGet() @@ -125,36 +93,30 @@ public async Task Update_CosmosDBManagedCassandraClusterPatch() CassandraClusterResource cassandraCluster = client.GetCassandraClusterResource(cassandraClusterResourceId); // invoke the operation - CassandraClusterData data = new CassandraClusterData(new AzureLocation("placeholder")) + CassandraClusterData data = new CassandraClusterData(default) { - Properties = new CassandraClusterProperties() + Properties = new CassandraClusterProperties { AuthenticationMethod = CassandraAuthenticationMethod.None, - ExternalGossipCertificates = -{ -new CassandraCertificate() + ExternalGossipCertificates = {new CassandraCertificate { Pem = "-----BEGIN CERTIFICATE-----\n...Base64 encoded certificate...\n-----END CERTIFICATE-----", -} -}, - ExternalSeedNodes = -{ -new CassandraDataCenterSeedNode() +}}, + ExternalSeedNodes = {new CassandraDataCenterSeedNode { IPAddress = "10.52.221.2", -},new CassandraDataCenterSeedNode() +}, new CassandraDataCenterSeedNode { IPAddress = "10.52.221.3", -},new CassandraDataCenterSeedNode() +}, new CassandraDataCenterSeedNode { IPAddress = "10.52.221.4", -} -}, +}}, HoursBetweenBackups = 12, }, Tags = { -["owner"] = "mike", +["owner"] = "mike" }, }; ArmOperation lro = await cassandraCluster.UpdateAsync(WaitUntil.Completed, data); @@ -192,7 +154,7 @@ public async Task InvokeCommand_CosmosDBManagedCassandraCommand() { Arguments = { -["status"] = "", +["status"] = "" }, }; ArmOperation lro = await cassandraCluster.InvokeCommandAsync(WaitUntil.Completed, body); diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraDataCenterCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraDataCenterCollection.cs index 20603ea0f281c..15bbd512a556d 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraDataCenterCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraDataCenterCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CassandraDataCenterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBManagedCassandraDataCenterList() + public async Task CreateOrUpdate_CosmosDBManagedCassandraDataCenterCreate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraDataCenterList.json - // this example is just showing the usage of "CassandraDataCenters_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraDataCenterCreate.json + // this example is just showing the usage of "CassandraDataCenters_CreateUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,26 @@ public async Task GetAll_CosmosDBManagedCassandraDataCenterList() // get the collection of this CassandraDataCenterResource CassandraDataCenterCollection collection = cassandraCluster.GetCassandraDataCenters(); - // invoke the operation and iterate over the result - await foreach (CassandraDataCenterResource item in collection.GetAllAsync()) + // invoke the operation + string dataCenterName = "dc1"; + CassandraDataCenterData data = new CassandraDataCenterData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraDataCenterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new CassandraDataCenterProperties + { + DataCenterLocation = new AzureLocation("West US 2"), + DelegatedSubnetId = new ResourceIdentifier("/subscriptions/536e130b-d7d6-4ac7-98a5-de20d69588d2/resourceGroups/customer-vnet-rg/providers/Microsoft.Network/virtualNetworks/customer-vnet/subnets/dc1-subnet"), + NodeCount = 9, + Base64EncodedCassandraYamlFragment = "Y29tcGFjdGlvbl90aHJvdWdocHV0X21iX3Blcl9zZWM6IDMyCmNvbXBhY3Rpb25fbGFyZ2VfcGFydGl0aW9uX3dhcm5pbmdfdGhyZXNob2xkX21iOiAxMDA=", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataCenterName, data); + CassandraDataCenterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraDataCenterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +97,10 @@ public async Task Get_CosmosDBManagedCassandraDataCenterGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBManagedCassandraDataCenterGet() + public async Task GetAll_CosmosDBManagedCassandraDataCenterList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraDataCenterGet.json - // this example is just showing the usage of "CassandraDataCenters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraDataCenterList.json + // this example is just showing the usage of "CassandraDataCenters_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +118,22 @@ public async Task Exists_CosmosDBManagedCassandraDataCenterGet() // get the collection of this CassandraDataCenterResource CassandraDataCenterCollection collection = cassandraCluster.GetCassandraDataCenters(); - // invoke the operation - string dataCenterName = "dc1"; - bool result = await collection.ExistsAsync(dataCenterName); + // invoke the operation and iterate over the result + await foreach (CassandraDataCenterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraDataCenterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBManagedCassandraDataCenterGet() + public async Task Exists_CosmosDBManagedCassandraDataCenterGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraDataCenterGet.json // this example is just showing the usage of "CassandraDataCenters_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +156,17 @@ public async Task GetIfExists_CosmosDBManagedCassandraDataCenterGet() // invoke the operation string dataCenterName = "dc1"; - NullableResponse response = await collection.GetIfExistsAsync(dataCenterName); - CassandraDataCenterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataCenterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraDataCenterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBManagedCassandraDataCenterCreate() + public async Task GetIfExists_CosmosDBManagedCassandraDataCenterGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraDataCenterCreate.json - // this example is just showing the usage of "CassandraDataCenters_CreateUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraDataCenterGet.json + // this example is just showing the usage of "CassandraDataCenters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,24 +186,21 @@ public async Task CreateOrUpdate_CosmosDBManagedCassandraDataCenterCreate() // invoke the operation string dataCenterName = "dc1"; - CassandraDataCenterData data = new CassandraDataCenterData() - { - Properties = new CassandraDataCenterProperties() - { - DataCenterLocation = new AzureLocation("West US 2"), - DelegatedSubnetId = new ResourceIdentifier("/subscriptions/536e130b-d7d6-4ac7-98a5-de20d69588d2/resourceGroups/customer-vnet-rg/providers/Microsoft.Network/virtualNetworks/customer-vnet/subnets/dc1-subnet"), - NodeCount = 9, - Base64EncodedCassandraYamlFragment = "Y29tcGFjdGlvbl90aHJvdWdocHV0X21iX3Blcl9zZWM6IDMyCmNvbXBhY3Rpb25fbGFyZ2VfcGFydGl0aW9uX3dhcm5pbmdfdGhyZXNob2xkX21iOiAxMDA=", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataCenterName, data); - CassandraDataCenterResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dataCenterName); + CassandraDataCenterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraDataCenterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraDataCenterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraDataCenterResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraDataCenterResource.cs index f47134eaed4ba..835547e6c02eb 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraDataCenterResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraDataCenterResource.cs @@ -96,9 +96,9 @@ public async Task Update_CosmosDBManagedCassandraDataCenterUpdate() CassandraDataCenterResource cassandraDataCenter = client.GetCassandraDataCenterResource(cassandraDataCenterResourceId); // invoke the operation - CassandraDataCenterData data = new CassandraDataCenterData() + CassandraDataCenterData data = new CassandraDataCenterData { - Properties = new CassandraDataCenterProperties() + Properties = new CassandraDataCenterProperties { DataCenterLocation = new AzureLocation("West US 2"), DelegatedSubnetId = new ResourceIdentifier("/subscriptions/536e130b-d7d6-4ac7-98a5-de20d69588d2/resourceGroups/customer-vnet-rg/providers/Microsoft.Network/virtualNetworks/customer-vnet/subnets/dc1-subnet"), diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceCollection.cs index 01e16ef9ffa72..59bab8fee3e8b 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CassandraKeyspaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBCassandraKeyspaceList() + public async Task CreateOrUpdate_CosmosDBCassandraKeyspaceCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceList.json - // this example is just showing the usage of "CassandraResources_ListCassandraKeyspaces" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceCreateUpdate.json + // this example is just showing the usage of "CassandraResources_CreateUpdateCassandraKeyspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBCassandraKeyspaceList() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -39,17 +39,21 @@ public async Task GetAll_CosmosDBCassandraKeyspaceList() // get the collection of this CassandraKeyspaceResource CassandraKeyspaceCollection collection = cosmosDBAccount.GetCassandraKeyspaces(); - // invoke the operation and iterate over the result - await foreach (CassandraKeyspaceResource item in collection.GetAllAsync()) + // invoke the operation + string keyspaceName = "keyspaceName"; + CassandraKeyspaceCreateOrUpdateContent content = new CassandraKeyspaceCreateOrUpdateContent(new AzureLocation("West US"), new CassandraKeyspaceResourceInfo("keyspaceName")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraKeyspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyspaceName, content); + CassandraKeyspaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraKeyspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_CosmosDBCassandraKeyspaceGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBCassandraKeyspaceGet() + public async Task GetAll_CosmosDBCassandraKeyspaceList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceGet.json - // this example is just showing the usage of "CassandraResources_GetCassandraKeyspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceList.json + // this example is just showing the usage of "CassandraResources_ListCassandraKeyspaces" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +105,7 @@ public async Task Exists_CosmosDBCassandraKeyspaceGet() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -109,16 +113,22 @@ public async Task Exists_CosmosDBCassandraKeyspaceGet() // get the collection of this CassandraKeyspaceResource CassandraKeyspaceCollection collection = cosmosDBAccount.GetCassandraKeyspaces(); - // invoke the operation - string keyspaceName = "keyspaceName"; - bool result = await collection.ExistsAsync(keyspaceName); + // invoke the operation and iterate over the result + await foreach (CassandraKeyspaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraKeyspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBCassandraKeyspaceGet() + public async Task Exists_CosmosDBCassandraKeyspaceGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceGet.json // this example is just showing the usage of "CassandraResources_GetCassandraKeyspace" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_CosmosDBCassandraKeyspaceGet() // invoke the operation string keyspaceName = "keyspaceName"; - NullableResponse response = await collection.GetIfExistsAsync(keyspaceName); - CassandraKeyspaceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(keyspaceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraKeyspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBCassandraKeyspaceCreateUpdate() + public async Task GetIfExists_CosmosDBCassandraKeyspaceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceCreateUpdate.json - // this example is just showing the usage of "CassandraResources_CreateUpdateCassandraKeyspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceGet.json + // this example is just showing the usage of "CassandraResources_GetCassandraKeyspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,21 +181,21 @@ public async Task CreateOrUpdate_CosmosDBCassandraKeyspaceCreateUpdate() // invoke the operation string keyspaceName = "keyspaceName"; - CassandraKeyspaceCreateOrUpdateContent content = new CassandraKeyspaceCreateOrUpdateContent(new AzureLocation("West US"), new CassandraKeyspaceResourceInfo("keyspaceName")) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyspaceName, content); - CassandraKeyspaceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(keyspaceName); + CassandraKeyspaceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraKeyspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraKeyspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceResource.cs index 96f823cd3d146..c8708455b4958 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceResource.cs @@ -49,10 +49,10 @@ public async Task Get_CosmosDBCassandraKeyspaceGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBCassandraKeyspaceCreateUpdate() + public async Task Delete_CosmosDBCassandraKeyspaceDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceCreateUpdate.json - // this example is just showing the usage of "CassandraResources_CreateUpdateCassandraKeyspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceDelete.json + // this example is just showing the usage of "CassandraResources_DeleteCassandraKeyspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_CosmosDBCassandraKeyspaceCreateUpdate() CassandraKeyspaceResource cassandraKeyspace = client.GetCassandraKeyspaceResource(cassandraKeyspaceResourceId); // invoke the operation - CassandraKeyspaceCreateOrUpdateContent content = new CassandraKeyspaceCreateOrUpdateContent(new AzureLocation("West US"), new CassandraKeyspaceResourceInfo("keyspaceName")) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await cassandraKeyspace.UpdateAsync(WaitUntil.Completed, content); - CassandraKeyspaceResource result = lro.Value; + await cassandraKeyspace.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraKeyspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBCassandraKeyspaceDelete() + public async Task Update_CosmosDBCassandraKeyspaceCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceDelete.json - // this example is just showing the usage of "CassandraResources_DeleteCassandraKeyspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraKeyspaceCreateUpdate.json + // this example is just showing the usage of "CassandraResources_CreateUpdateCassandraKeyspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,19 @@ public async Task Delete_CosmosDBCassandraKeyspaceDelete() CassandraKeyspaceResource cassandraKeyspace = client.GetCassandraKeyspaceResource(cassandraKeyspaceResourceId); // invoke the operation - await cassandraKeyspace.DeleteAsync(WaitUntil.Completed); + CassandraKeyspaceCreateOrUpdateContent content = new CassandraKeyspaceCreateOrUpdateContent(new AzureLocation("West US"), new CassandraKeyspaceResourceInfo("keyspaceName")) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await cassandraKeyspace.UpdateAsync(WaitUntil.Completed, content); + CassandraKeyspaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraKeyspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceThroughputSettingResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceThroughputSettingResource.cs index 5cdad8090e1b9..4fd7e1868287e 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceThroughputSettingResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraKeyspaceThroughputSettingResource.cs @@ -69,14 +69,12 @@ public async Task CreateOrUpdate_CosmosDBCassandraKeyspaceThroughputUpdate() CassandraKeyspaceThroughputSettingResource cassandraKeyspaceThroughputSetting = client.GetCassandraKeyspaceThroughputSettingResource(cassandraKeyspaceThroughputSettingResourceId); // invoke the operation - ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo() + ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo { Throughput = 400, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cassandraKeyspaceThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); CassandraKeyspaceThroughputSettingResource result = lro.Value; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableCollection.cs index 2c7f887875051..52b3e94b06e28 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CassandraTableCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBCassandraTableList() + public async Task CreateOrUpdate_CosmosDBCassandraTableCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraTableList.json - // this example is just showing the usage of "CassandraResources_ListCassandraTables" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraTableCreateUpdate.json + // this example is just showing the usage of "CassandraResources_CreateUpdateCassandraTable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBCassandraTableList() // this example assumes you already have this CassandraKeyspaceResource created on azure // for more information of creating CassandraKeyspaceResource, please refer to the document of CassandraKeyspaceResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string keyspaceName = "keyspaceName"; ResourceIdentifier cassandraKeyspaceResourceId = CassandraKeyspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, keyspaceName); @@ -40,17 +40,42 @@ public async Task GetAll_CosmosDBCassandraTableList() // get the collection of this CassandraTableResource CassandraTableCollection collection = cassandraKeyspace.GetCassandraTables(); - // invoke the operation and iterate over the result - await foreach (CassandraTableResource item in collection.GetAllAsync()) + // invoke the operation + string tableName = "tableName"; + CassandraTableCreateOrUpdateContent content = new CassandraTableCreateOrUpdateContent(new AzureLocation("West US"), new CassandraTableResourceInfo("tableName") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraTableData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DefaultTtl = 100, + Schema = new CassandraSchema + { + Columns = {new CassandraColumn +{ +Name = "columnA", +CassandraColumnType = "Ascii", +}}, + PartitionKeys = {new CassandraPartitionKey +{ +Name = "columnA", +}}, + ClusterKeys = {new CassandraClusterKey +{ +Name = "columnA", +OrderBy = "Asc", +}}, + }, + AnalyticalStorageTtl = 500, + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tableName, content); + CassandraTableResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +115,10 @@ public async Task Get_CosmosDBCassandraTableGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBCassandraTableGet() + public async Task GetAll_CosmosDBCassandraTableList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraTableGet.json - // this example is just showing the usage of "CassandraResources_GetCassandraTable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraTableList.json + // this example is just showing the usage of "CassandraResources_ListCassandraTables" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,7 +128,7 @@ public async Task Exists_CosmosDBCassandraTableGet() // this example assumes you already have this CassandraKeyspaceResource created on azure // for more information of creating CassandraKeyspaceResource, please refer to the document of CassandraKeyspaceResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string keyspaceName = "keyspaceName"; ResourceIdentifier cassandraKeyspaceResourceId = CassandraKeyspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, keyspaceName); @@ -112,16 +137,22 @@ public async Task Exists_CosmosDBCassandraTableGet() // get the collection of this CassandraTableResource CassandraTableCollection collection = cassandraKeyspace.GetCassandraTables(); - // invoke the operation - string tableName = "tableName"; - bool result = await collection.ExistsAsync(tableName); + // invoke the operation and iterate over the result + await foreach (CassandraTableResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraTableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBCassandraTableGet() + public async Task Exists_CosmosDBCassandraTableGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraTableGet.json // this example is just showing the usage of "CassandraResources_GetCassandraTable" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +176,17 @@ public async Task GetIfExists_CosmosDBCassandraTableGet() // invoke the operation string tableName = "tableName"; - NullableResponse response = await collection.GetIfExistsAsync(tableName); - CassandraTableResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tableName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBCassandraTableCreateUpdate() + public async Task GetIfExists_CosmosDBCassandraTableGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraTableCreateUpdate.json - // this example is just showing the usage of "CassandraResources_CreateUpdateCassandraTable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraTableGet.json + // this example is just showing the usage of "CassandraResources_GetCassandraTable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,51 +207,21 @@ public async Task CreateOrUpdate_CosmosDBCassandraTableCreateUpdate() // invoke the operation string tableName = "tableName"; - CassandraTableCreateOrUpdateContent content = new CassandraTableCreateOrUpdateContent(new AzureLocation("West US"), new CassandraTableResourceInfo("tableName") + NullableResponse response = await collection.GetIfExistsAsync(tableName); + CassandraTableResource result = response.HasValue ? response.Value : null; + + if (result == null) { - DefaultTtl = 100, - Schema = new CassandraSchema() - { - Columns = -{ -new CassandraColumn() -{ -Name = "columnA", -CassandraColumnType = "Ascii", -} -}, - PartitionKeys = -{ -new CassandraPartitionKey() -{ -Name = "columnA", -} -}, - ClusterKeys = -{ -new CassandraClusterKey() -{ -Name = "columnA", -OrderBy = "Asc", -} -}, - }, - AnalyticalStorageTtl = 500, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tableName, content); - CassandraTableResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableResource.cs index 8e60f1ebd4d36..a05ebe1d7b55d 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableResource.cs @@ -48,6 +48,34 @@ public async Task Get_CosmosDBCassandraTableGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CosmosDBCassandraTableDelete() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraTableDelete.json + // this example is just showing the usage of "CassandraResources_DeleteCassandraTable" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CassandraTableResource created on azure + // for more information of creating CassandraTableResource, please refer to the document of CassandraTableResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string accountName = "ddb1"; + string keyspaceName = "keyspaceName"; + string tableName = "tableName"; + ResourceIdentifier cassandraTableResourceId = CassandraTableResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, keyspaceName, tableName); + CassandraTableResource cassandraTable = client.GetCassandraTableResource(cassandraTableResourceId); + + // invoke the operation + await cassandraTable.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CosmosDBCassandraTableCreateUpdate() @@ -74,39 +102,28 @@ public async Task Update_CosmosDBCassandraTableCreateUpdate() CassandraTableCreateOrUpdateContent content = new CassandraTableCreateOrUpdateContent(new AzureLocation("West US"), new CassandraTableResourceInfo("tableName") { DefaultTtl = 100, - Schema = new CassandraSchema() + Schema = new CassandraSchema { - Columns = -{ -new CassandraColumn() + Columns = {new CassandraColumn { Name = "columnA", CassandraColumnType = "Ascii", -} -}, - PartitionKeys = -{ -new CassandraPartitionKey() +}}, + PartitionKeys = {new CassandraPartitionKey { Name = "columnA", -} -}, - ClusterKeys = -{ -new CassandraClusterKey() +}}, + ClusterKeys = {new CassandraClusterKey { Name = "columnA", OrderBy = "Asc", -} -}, +}}, }, AnalyticalStorageTtl = 500, }) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cassandraTable.UpdateAsync(WaitUntil.Completed, content); CassandraTableResource result = lro.Value; @@ -117,33 +134,5 @@ public async Task Update_CosmosDBCassandraTableCreateUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBCassandraTableDelete() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraTableDelete.json - // this example is just showing the usage of "CassandraResources_DeleteCassandraTable" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CassandraTableResource created on azure - // for more information of creating CassandraTableResource, please refer to the document of CassandraTableResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string accountName = "ddb1"; - string keyspaceName = "keyspaceName"; - string tableName = "tableName"; - ResourceIdentifier cassandraTableResourceId = CassandraTableResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, keyspaceName, tableName); - CassandraTableResource cassandraTable = client.GetCassandraTableResource(cassandraTableResourceId); - - // invoke the operation - await cassandraTable.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableThroughputSettingResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableThroughputSettingResource.cs index 47a07f87e5c7c..439190ff5413c 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableThroughputSettingResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraTableThroughputSettingResource.cs @@ -71,14 +71,12 @@ public async Task CreateOrUpdate_CosmosDBCassandraTableThroughputUpdate() CassandraTableThroughputSettingResource cassandraTableThroughputSetting = client.GetCassandraTableThroughputSettingResource(cassandraTableThroughputSettingResourceId); // invoke the operation - ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo() + ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo { Throughput = 400, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cassandraTableThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); CassandraTableThroughputSettingResource result = lro.Value; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewGetResultCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewGetResultCollection.cs index 5dca9d9878aa6..b565a54af1a30 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewGetResultCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewGetResultCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CassandraViewGetResultCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBCassandraViewList() + public async Task CreateOrUpdate_CosmosDBCassandraViewCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewList.json - // this example is just showing the usage of "CassandraResources_ListCassandraViews" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewCreateUpdate.json + // this example is just showing the usage of "CassandraResources_CreateUpdateCassandraView" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBCassandraViewList() // this example assumes you already have this CassandraKeyspaceResource created on azure // for more information of creating CassandraKeyspaceResource, please refer to the document of CassandraKeyspaceResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string keyspaceName = "keyspacename"; ResourceIdentifier cassandraKeyspaceResourceId = CassandraKeyspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, keyspaceName); @@ -40,17 +40,21 @@ public async Task GetAll_CosmosDBCassandraViewList() // get the collection of this CassandraViewGetResultResource CassandraViewGetResultCollection collection = cassandraKeyspace.GetCassandraViewGetResults(); - // invoke the operation and iterate over the result - await foreach (CassandraViewGetResultResource item in collection.GetAllAsync()) + // invoke the operation + string viewName = "viewname"; + CassandraViewGetResultCreateOrUpdateContent content = new CassandraViewGetResultCreateOrUpdateContent(default, new CassandraViewResource("viewname", "SELECT columna, columnb, columnc FROM keyspacename.srctablename WHERE columna IS NOT NULL AND columnc IS NOT NULL PRIMARY (columnc, columna)")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraViewGetResultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, viewName, content); + CassandraViewGetResultResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraViewGetResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +94,10 @@ public async Task Get_CosmosDBCassandraViewGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBCassandraViewGet() + public async Task GetAll_CosmosDBCassandraViewList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewGet.json - // this example is just showing the usage of "CassandraResources_GetCassandraView" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewList.json + // this example is just showing the usage of "CassandraResources_ListCassandraViews" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,7 +107,7 @@ public async Task Exists_CosmosDBCassandraViewGet() // this example assumes you already have this CassandraKeyspaceResource created on azure // for more information of creating CassandraKeyspaceResource, please refer to the document of CassandraKeyspaceResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string keyspaceName = "keyspacename"; ResourceIdentifier cassandraKeyspaceResourceId = CassandraKeyspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, keyspaceName); @@ -112,16 +116,22 @@ public async Task Exists_CosmosDBCassandraViewGet() // get the collection of this CassandraViewGetResultResource CassandraViewGetResultCollection collection = cassandraKeyspace.GetCassandraViewGetResults(); - // invoke the operation - string viewName = "viewname"; - bool result = await collection.ExistsAsync(viewName); + // invoke the operation and iterate over the result + await foreach (CassandraViewGetResultResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraViewGetResultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBCassandraViewGet() + public async Task Exists_CosmosDBCassandraViewGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewGet.json // this example is just showing the usage of "CassandraResources_GetCassandraView" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +155,17 @@ public async Task GetIfExists_CosmosDBCassandraViewGet() // invoke the operation string viewName = "viewname"; - NullableResponse response = await collection.GetIfExistsAsync(viewName); - CassandraViewGetResultResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(viewName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraViewGetResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBCassandraViewCreateUpdate() + public async Task GetIfExists_CosmosDBCassandraViewGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewCreateUpdate.json - // this example is just showing the usage of "CassandraResources_CreateUpdateCassandraView" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewGet.json + // this example is just showing the usage of "CassandraResources_GetCassandraView" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,21 +186,21 @@ public async Task CreateOrUpdate_CosmosDBCassandraViewCreateUpdate() // invoke the operation string viewName = "viewname"; - CassandraViewGetResultCreateOrUpdateContent content = new CassandraViewGetResultCreateOrUpdateContent(new AzureLocation("placeholder"), new CassandraViewResource("viewname", "SELECT columna, columnb, columnc FROM keyspacename.srctablename WHERE columna IS NOT NULL AND columnc IS NOT NULL PRIMARY (columnc, columna)")) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, viewName, content); - CassandraViewGetResultResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(viewName); + CassandraViewGetResultResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraViewGetResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraViewGetResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewGetResultResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewGetResultResource.cs index 8107029354030..bc11e41e7de10 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewGetResultResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewGetResultResource.cs @@ -50,10 +50,10 @@ public async Task Get_CosmosDBCassandraViewGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBCassandraViewCreateUpdate() + public async Task Delete_CosmosDBCassandraViewDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewCreateUpdate.json - // this example is just showing the usage of "CassandraResources_CreateUpdateCassandraView" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewDelete.json + // this example is just showing the usage of "CassandraResources_DeleteCassandraView" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,29 +71,17 @@ public async Task Update_CosmosDBCassandraViewCreateUpdate() CassandraViewGetResultResource cassandraViewGetResult = client.GetCassandraViewGetResultResource(cassandraViewGetResultResourceId); // invoke the operation - CassandraViewGetResultCreateOrUpdateContent content = new CassandraViewGetResultCreateOrUpdateContent(new AzureLocation("placeholder"), new CassandraViewResource("viewname", "SELECT columna, columnb, columnc FROM keyspacename.srctablename WHERE columna IS NOT NULL AND columnc IS NOT NULL PRIMARY (columnc, columna)")) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await cassandraViewGetResult.UpdateAsync(WaitUntil.Completed, content); - CassandraViewGetResultResource result = lro.Value; + await cassandraViewGetResult.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CassandraViewGetResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBCassandraViewDelete() + public async Task Update_CosmosDBCassandraViewCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewDelete.json - // this example is just showing the usage of "CassandraResources_DeleteCassandraView" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBCassandraViewCreateUpdate.json + // this example is just showing the usage of "CassandraResources_CreateUpdateCassandraView" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +99,19 @@ public async Task Delete_CosmosDBCassandraViewDelete() CassandraViewGetResultResource cassandraViewGetResult = client.GetCassandraViewGetResultResource(cassandraViewGetResultResourceId); // invoke the operation - await cassandraViewGetResult.DeleteAsync(WaitUntil.Completed); + CassandraViewGetResultCreateOrUpdateContent content = new CassandraViewGetResultCreateOrUpdateContent(default, new CassandraViewResource("viewname", "SELECT columna, columnb, columnc FROM keyspacename.srctablename WHERE columna IS NOT NULL AND columnc IS NOT NULL PRIMARY (columnc, columna)")) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await cassandraViewGetResult.UpdateAsync(WaitUntil.Completed, content); + CassandraViewGetResultResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraViewGetResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewThroughputSettingResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewThroughputSettingResource.cs index ef8ef4ee46f10..35ddb2a8a2630 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewThroughputSettingResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CassandraViewThroughputSettingResource.cs @@ -71,14 +71,12 @@ public async Task CreateOrUpdate_CosmosDBCassandraViewThroughputUpdate() CassandraViewThroughputSettingResource cassandraViewThroughputSetting = client.GetCassandraViewThroughputSettingResource(cassandraViewThroughputSettingResourceId); // invoke the operation - ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("placeholder"), new ThroughputSettingsResourceInfo() + ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(default, new ThroughputSettingsResourceInfo { Throughput = 400, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cassandraViewThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); CassandraViewThroughputSettingResource result = lro.Value; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBAccountCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBAccountCollection.cs index 6c32d330f949e..386418ecc2999 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBAccountCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBAccountCollection.cs @@ -18,109 +18,6 @@ namespace Azure.ResourceManager.CosmosDB.Samples { public partial class Sample_CosmosDBAccountCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBDatabaseAccountGet() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountGet.json - // this example is just showing the usage of "DatabaseAccounts_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this CosmosDBAccountResource - CosmosDBAccountCollection collection = resourceGroupResource.GetCosmosDBAccounts(); - - // invoke the operation - string accountName = "ddb1"; - CosmosDBAccountResource result = await collection.GetAsync(accountName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBDatabaseAccountGet() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountGet.json - // this example is just showing the usage of "DatabaseAccounts_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this CosmosDBAccountResource - CosmosDBAccountCollection collection = resourceGroupResource.GetCosmosDBAccounts(); - - // invoke the operation - string accountName = "ddb1"; - bool result = await collection.ExistsAsync(accountName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBDatabaseAccountGet() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountGet.json - // this example is just showing the usage of "DatabaseAccounts_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this CosmosDBAccountResource - CosmosDBAccountCollection collection = resourceGroupResource.GetCosmosDBAccounts(); - - // invoke the operation - string accountName = "ddb1"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - CosmosDBAccountResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CosmosDBDatabaseAccountCreateMax() @@ -147,12 +44,13 @@ public async Task CreateOrUpdate_CosmosDBDatabaseAccountCreateMax() string accountName = "ddb1"; CosmosDBAccountCreateOrUpdateContent content = new CosmosDBAccountCreateOrUpdateContent(new AzureLocation("westus"), new CosmosDBAccountLocation[] { -new CosmosDBAccountLocation() +new CosmosDBAccountLocation { LocationName = new AzureLocation("southcentralus"), FailoverPriority = 0, IsZoneRedundant = false, -},new CosmosDBAccountLocation() +}, +new CosmosDBAccountLocation { LocationName = new AzureLocation("eastus"), FailoverPriority = 1, @@ -166,25 +64,19 @@ public async Task CreateOrUpdate_CosmosDBDatabaseAccountCreateMax() MaxStalenessPrefix = 200L, MaxIntervalInSeconds = 10, }, - IPRules = -{ -new CosmosDBIPAddressOrRange() + IPRules = {new CosmosDBIPAddressOrRange { IPAddressOrRange = "23.43.230.120", -},new CosmosDBIPAddressOrRange() +}, new CosmosDBIPAddressOrRange { IPAddressOrRange = "110.12.240.0/12", -} -}, +}}, IsVirtualNetworkFilterEnabled = true, - VirtualNetworkRules = -{ -new CosmosDBVirtualNetworkRule() + VirtualNetworkRules = {new CosmosDBVirtualNetworkRule { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), IgnoreMissingVnetServiceEndpoint = false, -} -}, +}}, KeyVaultKeyUri = new Uri("https://myKeyVault.vault.azure.net"), DefaultIdentity = "FirstPartyIdentity", PublicNetworkAccess = CosmosDBPublicNetworkAccess.Enabled, @@ -193,24 +85,18 @@ public async Task CreateOrUpdate_CosmosDBDatabaseAccountCreateMax() IsAnalyticalStorageEnabled = true, AnalyticalStorageSchemaType = AnalyticalStorageSchemaType.WellDefined, CreateMode = CosmosDBAccountCreateMode.Default, - BackupPolicy = new PeriodicModeBackupPolicy() + BackupPolicy = new PeriodicModeBackupPolicy { - PeriodicModeProperties = new PeriodicModeProperties() + PeriodicModeProperties = new PeriodicModeProperties { BackupIntervalInMinutes = 240, BackupRetentionIntervalInHours = 8, BackupStorageRedundancy = CosmosDBBackupStorageRedundancy.Geo, }, }, - Cors = -{ -new CosmosDBAccountCorsPolicy("https://test") -}, + Cors = { new CosmosDBAccountCorsPolicy("https://test") }, NetworkAclBypass = NetworkAclBypass.AzureServices, - NetworkAclBypassResourceIds = -{ -new ResourceIdentifier("/subscriptions/subId/resourcegroups/rgName/providers/Microsoft.Synapse/workspaces/workspaceName") -}, + NetworkAclBypassResourceIds = { new ResourceIdentifier("/subscriptions/subId/resourcegroups/rgName/providers/Microsoft.Synapse/workspaces/workspaceName") }, CapacityTotalThroughputLimit = 2000, CapacityMode = CapacityMode.Provisioned, EnableMaterializedViews = false, @@ -223,12 +109,10 @@ public async Task CreateOrUpdate_CosmosDBDatabaseAccountCreateMax() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/eu2cgroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/eu2cgroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() }, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, content); CosmosDBAccountResource result = lro.Value; @@ -266,7 +150,7 @@ public async Task CreateOrUpdate_CosmosDBDatabaseAccountCreateMin() string accountName = "ddb1"; CosmosDBAccountCreateOrUpdateContent content = new CosmosDBAccountCreateOrUpdateContent(new AzureLocation("westus"), new CosmosDBAccountLocation[] { -new CosmosDBAccountLocation() +new CosmosDBAccountLocation { LocationName = new AzureLocation("southcentralus"), FailoverPriority = 0, @@ -312,7 +196,7 @@ public async Task CreateOrUpdate_CosmosDBRestoreDatabaseAccountCreateUpdateJson( string accountName = "ddb1"; CosmosDBAccountCreateOrUpdateContent content = new CosmosDBAccountCreateOrUpdateContent(new AzureLocation("westus"), new CosmosDBAccountLocation[] { -new CosmosDBAccountLocation() +new CosmosDBAccountLocation { LocationName = new AzureLocation("southcentralus"), FailoverPriority = 0, @@ -331,31 +215,22 @@ public async Task CreateOrUpdate_CosmosDBRestoreDatabaseAccountCreateUpdateJson( ApiServerVersion = CosmosDBServerVersion.V3_2, IsAnalyticalStorageEnabled = true, CreateMode = CosmosDBAccountCreateMode.Restore, - BackupPolicy = new ContinuousModeBackupPolicy() + BackupPolicy = new ContinuousModeBackupPolicy { ContinuousModeTier = ContinuousTier.Continuous30Days, }, - RestoreParameters = new CosmosDBAccountRestoreParameters() + RestoreParameters = new CosmosDBAccountRestoreParameters { RestoreMode = CosmosDBAccountRestoreMode.PointInTime, - DatabasesToRestore = -{ -new DatabaseRestoreResourceInfo() + DatabasesToRestore = {new DatabaseRestoreResourceInfo { DatabaseName = "db1", -CollectionNames = -{ -"collection1","collection2" -}, -},new DatabaseRestoreResourceInfo() +CollectionNames = {"collection1", "collection2"}, +}, new DatabaseRestoreResourceInfo { DatabaseName = "db2", -CollectionNames = -{ -"collection3","collection4" -}, -} -}, +CollectionNames = {"collection3", "collection4"}, +}}, SourceBackupLocation = "westus", RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/westus/restorableDatabaseAccounts/1a97b4bb-f6a0-430e-ade1-638d781830cc", RestoreTimestampInUtc = DateTimeOffset.Parse("2021-03-11T22:05:09Z"), @@ -363,9 +238,7 @@ public async Task CreateOrUpdate_CosmosDBRestoreDatabaseAccountCreateUpdateJson( }, EnableMaterializedViews = false, MinimalTlsVersion = CosmosDBMinimalTlsVersion.Tls, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, content); CosmosDBAccountResource result = lro.Value; @@ -377,6 +250,39 @@ public async Task CreateOrUpdate_CosmosDBRestoreDatabaseAccountCreateUpdateJson( Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CosmosDBDatabaseAccountGet() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountGet.json + // this example is just showing the usage of "DatabaseAccounts_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CosmosDBAccountResource + CosmosDBAccountCollection collection = resourceGroupResource.GetCosmosDBAccounts(); + + // invoke the operation + string accountName = "ddb1"; + CosmosDBAccountResource result = await collection.GetAsync(accountName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_CosmosDBDatabaseAccountListByResourceGroup() @@ -411,5 +317,75 @@ public async Task GetAll_CosmosDBDatabaseAccountListByResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_CosmosDBDatabaseAccountGet() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountGet.json + // this example is just showing the usage of "DatabaseAccounts_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CosmosDBAccountResource + CosmosDBAccountCollection collection = resourceGroupResource.GetCosmosDBAccounts(); + + // invoke the operation + string accountName = "ddb1"; + bool result = await collection.ExistsAsync(accountName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_CosmosDBDatabaseAccountGet() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountGet.json + // this example is just showing the usage of "DatabaseAccounts_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CosmosDBAccountResource + CosmosDBAccountCollection collection = resourceGroupResource.GetCosmosDBAccounts(); + + // invoke the operation + string accountName = "ddb1"; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + CosmosDBAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBAccountResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBAccountResource.cs index f0eeb85373d87..c1af7ec528f50 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBAccountResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBAccountResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.CosmosDB.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CosmosDB.Samples @@ -48,6 +47,32 @@ public async Task Get_CosmosDBDatabaseAccountGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CosmosDBDatabaseAccountDelete() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountDelete.json + // this example is just showing the usage of "DatabaseAccounts_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CosmosDBAccountResource created on azure + // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string accountName = "ddb1"; + ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); + + // invoke the operation + await cosmosDBAccount.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CosmosDBDatabaseAccountPatch() @@ -69,18 +94,18 @@ public async Task Update_CosmosDBDatabaseAccountPatch() CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); // invoke the operation - CosmosDBAccountPatch patch = new CosmosDBAccountPatch() + CosmosDBAccountPatch patch = new CosmosDBAccountPatch { Tags = { -["dept"] = "finance", +["dept"] = "finance" }, Location = new AzureLocation("westus"), Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/eu2cgroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/eu2cgroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() }, }, ConsistencyPolicy = new ConsistencyPolicy(DefaultConsistencyLevel.BoundedStaleness) @@ -88,32 +113,26 @@ public async Task Update_CosmosDBDatabaseAccountPatch() MaxStalenessPrefix = 200L, MaxIntervalInSeconds = 10, }, - IPRules = -{ -new CosmosDBIPAddressOrRange() + IPRules = {new CosmosDBIPAddressOrRange { IPAddressOrRange = "23.43.230.120", -},new CosmosDBIPAddressOrRange() +}, new CosmosDBIPAddressOrRange { IPAddressOrRange = "110.12.240.0/12", -} -}, +}}, IsVirtualNetworkFilterEnabled = true, - VirtualNetworkRules = -{ -new CosmosDBVirtualNetworkRule() + VirtualNetworkRules = {new CosmosDBVirtualNetworkRule { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), IgnoreMissingVnetServiceEndpoint = false, -} -}, +}}, DefaultIdentity = "FirstPartyIdentity", IsFreeTierEnabled = false, IsAnalyticalStorageEnabled = true, AnalyticalStorageSchemaType = AnalyticalStorageSchemaType.WellDefined, - BackupPolicy = new PeriodicModeBackupPolicy() + BackupPolicy = new PeriodicModeBackupPolicy { - PeriodicModeProperties = new PeriodicModeProperties() + PeriodicModeProperties = new PeriodicModeProperties { BackupIntervalInMinutes = 240, BackupRetentionIntervalInHours = 720, @@ -121,10 +140,7 @@ public async Task Update_CosmosDBDatabaseAccountPatch() }, }, NetworkAclBypass = NetworkAclBypass.AzureServices, - NetworkAclBypassResourceIds = -{ -new ResourceIdentifier("/subscriptions/subId/resourcegroups/rgName/providers/Microsoft.Synapse/workspaces/workspaceName") -}, + NetworkAclBypassResourceIds = { new ResourceIdentifier("/subscriptions/subId/resourcegroups/rgName/providers/Microsoft.Synapse/workspaces/workspaceName") }, DiagnosticLogEnableFullTextQuery = EnableFullTextQuery.True, CapacityTotalThroughputLimit = 2000, CapacityMode = CapacityMode.Provisioned, @@ -145,32 +161,6 @@ public async Task Update_CosmosDBDatabaseAccountPatch() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBDatabaseAccountDelete() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountDelete.json - // this example is just showing the usage of "DatabaseAccounts_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CosmosDBAccountResource created on azure - // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string accountName = "ddb1"; - ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); - - // invoke the operation - await cosmosDBAccount.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task FailoverPriorityChange_CosmosDBDatabaseAccountFailoverPriorityChange() @@ -194,11 +184,12 @@ public async Task FailoverPriorityChange_CosmosDBDatabaseAccountFailoverPriority // invoke the operation CosmosDBFailoverPolicies failoverParameters = new CosmosDBFailoverPolicies(new CosmosDBFailoverPolicy[] { -new CosmosDBFailoverPolicy() +new CosmosDBFailoverPolicy { LocationName = new AzureLocation("eastus"), FailoverPriority = 0, -},new CosmosDBFailoverPolicy() +}, +new CosmosDBFailoverPolicy { LocationName = new AzureLocation("westus"), FailoverPriority = 1, @@ -209,37 +200,6 @@ public async Task FailoverPriorityChange_CosmosDBDatabaseAccountFailoverPriority Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCosmosDBAccounts_CosmosDBDatabaseAccountList() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountList.json - // this example is just showing the usage of "DatabaseAccounts_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CosmosDBAccountResource item in subscriptionResource.GetCosmosDBAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetKeys_CosmosDBDatabaseAccountListKeys() @@ -431,29 +391,6 @@ public async Task RegenerateKey_CosmosDBDatabaseAccountRegenerateKey() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckNameExistsDatabaseAccount_CosmosDBDatabaseAccountCheckNameExists() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountCheckNameExists.json - // this example is just showing the usage of "DatabaseAccounts_CheckNameExists" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - string accountName = "ddb1"; - bool result = await tenantResource.CheckNameExistsDatabaseAccountAsync(accountName); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetMetrics_CosmosDBDatabaseAccountGetMetrics() diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBChaosFaultResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBChaosFaultResource.cs index f76916fbb9cf8..b3c789b7522f0 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBChaosFaultResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBChaosFaultResource.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBChaosFaultResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ChaosFaultEnableDisable() + public async Task Get_ChaosFaultGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/ChaosFaultEnableDisable.json - // this example is just showing the usage of "ChaosFault_EnableDisable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/ChaosFaultGet.json + // this example is just showing the usage of "ChaosFault_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,22 +31,14 @@ public async Task Update_ChaosFaultEnableDisable() // this example assumes you already have this CosmosDBChaosFaultResource created on azure // for more information of creating CosmosDBChaosFaultResource, please refer to the document of CosmosDBChaosFaultResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroupName"; - string accountName = "myAccountName"; + string resourceGroupName = "rg1"; + string accountName = "ddb1"; string chaosFault = "ServiceUnavailability"; ResourceIdentifier cosmosDBChaosFaultResourceId = CosmosDBChaosFaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, chaosFault); CosmosDBChaosFaultResource cosmosDBChaosFaultResource = client.GetCosmosDBChaosFaultResource(cosmosDBChaosFaultResourceId); // invoke the operation - CosmosDBChaosFaultResourceData data = new CosmosDBChaosFaultResourceData() - { - CosmosDBChaosFaultSupportedActions = CosmosDBChaosFaultSupportedAction.Enable, - Region = "EastUS", - DatabaseName = "testDatabase", - ContainerName = "testCollection", - }; - ArmOperation lro = await cosmosDBChaosFaultResource.UpdateAsync(WaitUntil.Completed, data); - CosmosDBChaosFaultResource result = lro.Value; + CosmosDBChaosFaultResource result = await cosmosDBChaosFaultResource.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +49,10 @@ public async Task Update_ChaosFaultEnableDisable() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ChaosFaultGet() + public async Task Update_ChaosFaultEnableDisable() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/ChaosFaultGet.json - // this example is just showing the usage of "ChaosFault_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/ChaosFaultEnableDisable.json + // this example is just showing the usage of "ChaosFault_EnableDisable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,14 +62,22 @@ public async Task Get_ChaosFaultGet() // this example assumes you already have this CosmosDBChaosFaultResource created on azure // for more information of creating CosmosDBChaosFaultResource, please refer to the document of CosmosDBChaosFaultResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string accountName = "ddb1"; + string resourceGroupName = "myResourceGroupName"; + string accountName = "myAccountName"; string chaosFault = "ServiceUnavailability"; ResourceIdentifier cosmosDBChaosFaultResourceId = CosmosDBChaosFaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, chaosFault); CosmosDBChaosFaultResource cosmosDBChaosFaultResource = client.GetCosmosDBChaosFaultResource(cosmosDBChaosFaultResourceId); // invoke the operation - CosmosDBChaosFaultResource result = await cosmosDBChaosFaultResource.GetAsync(); + CosmosDBChaosFaultResourceData data = new CosmosDBChaosFaultResourceData + { + CosmosDBChaosFaultSupportedActions = CosmosDBChaosFaultSupportedAction.Enable, + Region = "EastUS", + DatabaseName = "testDatabase", + ContainerName = "testCollection", + }; + ArmOperation lro = await cosmosDBChaosFaultResource.UpdateAsync(WaitUntil.Completed, data); + CosmosDBChaosFaultResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBChaosFaultResourceCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBChaosFaultResourceCollection.cs index 1719aa5208d44..4674a3125a6e9 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBChaosFaultResourceCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBChaosFaultResourceCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.CosmosDB.Samples { public partial class Sample_CosmosDBChaosFaultResourceCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ChaosFaultList() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/ChaosFaultList.json - // this example is just showing the usage of "ChaosFault_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CosmosDBAccountResource created on azure - // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string accountName = "ddb1"; - ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); - - // get the collection of this CosmosDBChaosFaultResource - CosmosDBChaosFaultResourceCollection collection = cosmosDBAccount.GetCosmosDBChaosFaultResources(); - - // invoke the operation and iterate over the result - await foreach (CosmosDBChaosFaultResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBChaosFaultResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_ChaosFaultEnableDisable() @@ -77,7 +41,7 @@ public async Task CreateOrUpdate_ChaosFaultEnableDisable() // invoke the operation string chaosFault = "ServiceUnavailability"; - CosmosDBChaosFaultResourceData data = new CosmosDBChaosFaultResourceData() + CosmosDBChaosFaultResourceData data = new CosmosDBChaosFaultResourceData { CosmosDBChaosFaultSupportedActions = CosmosDBChaosFaultSupportedAction.Enable, Region = "EastUS", @@ -128,6 +92,42 @@ public async Task Get_ChaosFaultGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ChaosFaultList() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/ChaosFaultList.json + // this example is just showing the usage of "ChaosFault_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CosmosDBAccountResource created on azure + // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string accountName = "ddb1"; + ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); + + // get the collection of this CosmosDBChaosFaultResource + CosmosDBChaosFaultResourceCollection collection = cosmosDBAccount.GetCosmosDBChaosFaultResources(); + + // invoke the operation and iterate over the result + await foreach (CosmosDBChaosFaultResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBChaosFaultResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_ChaosFaultGet() diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBLocationCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBLocationCollection.cs index 50cbda714cb10..278ecd03f6272 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBLocationCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBLocationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBLocationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBLocationList() + public async Task Get_CosmosDBLocationGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBLocationList.json - // this example is just showing the usage of "Locations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBLocationGet.json + // this example is just showing the usage of "Locations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_CosmosDBLocationList() // get the collection of this CosmosDBLocationResource CosmosDBLocationCollection collection = subscriptionResource.GetCosmosDBLocations(); - // invoke the operation and iterate over the result - await foreach (CosmosDBLocationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBLocationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + AzureLocation location = new AzureLocation("westus"); + CosmosDBLocationResource result = await collection.GetAsync(location); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBLocationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBLocationGet() + public async Task GetAll_CosmosDBLocationList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBLocationGet.json - // this example is just showing the usage of "Locations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBLocationList.json + // this example is just showing the usage of "Locations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +69,17 @@ public async Task Get_CosmosDBLocationGet() // get the collection of this CosmosDBLocationResource CosmosDBLocationCollection collection = subscriptionResource.GetCosmosDBLocations(); - // invoke the operation - AzureLocation location = new AzureLocation("westus"); - CosmosDBLocationResource result = await collection.GetAsync(location); + // invoke the operation and iterate over the result + await foreach (CosmosDBLocationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBLocationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBLocationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateEndpointConnectionCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateEndpointConnectionCollection.cs index bc738e7cbd008..b517fd6915f23 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateEndpointConnectionCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateEndpointConnection() + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionListGet.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByDatabaseAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_GetsPrivateEndpointConnection() // get the collection of this CosmosDBPrivateEndpointConnectionResource CosmosDBPrivateEndpointConnectionCollection collection = cosmosDBAccount.GetCosmosDBPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (CosmosDBPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "privateEndpointConnectionName"; + CosmosDBPrivateEndpointConnectionData data = new CosmosDBPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new CosmosDBPrivateLinkServiceConnectionStateProperty + { + Status = "Approved", + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + CosmosDBPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task GetAll_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionListGet.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByDatabaseAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_GetsPrivateEndpointConnection() // get the collection of this CosmosDBPrivateEndpointConnectionResource CosmosDBPrivateEndpointConnectionCollection collection = cosmosDBAccount.GetCosmosDBPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "privateEndpointConnectionName"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (CosmosDBPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task Exists_GetsPrivateEndpointConnection() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "privateEndpointConnectionName"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - CosmosDBPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // invoke the operation string privateEndpointConnectionName = "privateEndpointConnectionName"; - CosmosDBPrivateEndpointConnectionData data = new CosmosDBPrivateEndpointConnectionData() - { - ConnectionState = new CosmosDBPrivateLinkServiceConnectionStateProperty() - { - Status = "Approved", - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - CosmosDBPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + CosmosDBPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateEndpointConnectionResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateEndpointConnectionResource.cs index 19561186d034b..c98cebe002899 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateEndpointConnectionResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionDelete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName CosmosDBPrivateEndpointConnectionResource cosmosDBPrivateEndpointConnection = client.GetCosmosDBPrivateEndpointConnectionResource(cosmosDBPrivateEndpointConnectionResourceId); // invoke the operation - CosmosDBPrivateEndpointConnectionData data = new CosmosDBPrivateEndpointConnectionData() - { - ConnectionState = new CosmosDBPrivateLinkServiceConnectionStateProperty() - { - Status = "Approved", - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await cosmosDBPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - CosmosDBPrivateEndpointConnectionResource result = lro.Value; + await cosmosDBPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionDelete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() CosmosDBPrivateEndpointConnectionResource cosmosDBPrivateEndpointConnection = client.GetCosmosDBPrivateEndpointConnectionResource(cosmosDBPrivateEndpointConnectionResourceId); // invoke the operation - await cosmosDBPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + CosmosDBPrivateEndpointConnectionData data = new CosmosDBPrivateEndpointConnectionData + { + ConnectionState = new CosmosDBPrivateLinkServiceConnectionStateProperty + { + Status = "Approved", + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await cosmosDBPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + CosmosDBPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateLinkResourceCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateLinkResourceCollection.cs index 7962b72d2d0f2..87957fa61ba67 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateLinkResourceCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CosmosDBPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateEndpointConnection() + public async Task Get_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateLinkResourceListGet.json - // this example is just showing the usage of "PrivateLinkResources_ListByDatabaseAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateLinkResourceGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetsPrivateEndpointConnection() // get the collection of this CosmosDBPrivateLinkResource CosmosDBPrivateLinkResourceCollection collection = cosmosDBAccount.GetCosmosDBPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (CosmosDBPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "sql"; + CosmosDBPrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateEndpointConnection() + public async Task GetAll_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateLinkResourceGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBPrivateLinkResourceListGet.json + // this example is just showing the usage of "PrivateLinkResources_ListByDatabaseAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsPrivateEndpointConnection() // get the collection of this CosmosDBPrivateLinkResource CosmosDBPrivateLinkResourceCollection collection = cosmosDBAccount.GetCosmosDBPrivateLinkResources(); - // invoke the operation - string groupName = "sql"; - CosmosDBPrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (CosmosDBPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBServiceCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBServiceCollection.cs index 76cd42c15104e..c00b3151f65e2 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBServiceCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBServiceCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.CosmosDB.Samples { public partial class Sample_CosmosDBServiceCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBServicesList() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBServicesList.json - // this example is just showing the usage of "Service_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CosmosDBAccountResource created on azure - // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string accountName = "ddb1"; - ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); - - // get the collection of this CosmosDBServiceResource - CosmosDBServiceCollection collection = cosmosDBAccount.GetCosmosDBServices(); - - // invoke the operation and iterate over the result - await foreach (CosmosDBServiceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_DataTransferServiceCreate() @@ -77,9 +41,9 @@ public async Task CreateOrUpdate_DataTransferServiceCreate() // invoke the operation string serviceName = "DataTransfer"; - CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent() + CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent { - Properties = new DataTransferServiceResourceCreateUpdateProperties() + Properties = new DataTransferServiceResourceCreateUpdateProperties { InstanceSize = CosmosDBServiceSize.CosmosD4S, InstanceCount = 1, @@ -120,9 +84,9 @@ public async Task CreateOrUpdate_GraphAPIComputeServiceCreate() // invoke the operation string serviceName = "GraphAPICompute"; - CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent() + CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent { - Properties = new GraphApiComputeServiceResourceCreateUpdateProperties() + Properties = new GraphApiComputeServiceResourceCreateUpdateProperties { InstanceSize = CosmosDBServiceSize.CosmosD4S, InstanceCount = 1, @@ -163,9 +127,9 @@ public async Task CreateOrUpdate_MaterializedViewsBuilderServiceCreate() // invoke the operation string serviceName = "MaterializedViewsBuilder"; - CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent() + CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent { - Properties = new MaterializedViewsBuilderServiceResourceCreateUpdateProperties() + Properties = new MaterializedViewsBuilderServiceResourceCreateUpdateProperties { InstanceSize = CosmosDBServiceSize.CosmosD4S, InstanceCount = 1, @@ -206,9 +170,9 @@ public async Task CreateOrUpdate_SqlDedicatedGatewayServiceCreate() // invoke the operation string serviceName = "SqlDedicatedGateway"; - CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent() + CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent { - Properties = new SqlDedicatedGatewayServiceResourceCreateUpdateProperties() + Properties = new SqlDedicatedGatewayServiceResourceCreateUpdateProperties { DedicatedGatewayType = DedicatedGatewayType.IntegratedCache, InstanceSize = CosmosDBServiceSize.CosmosD4S, @@ -261,9 +225,9 @@ public async Task Get_DataTransferServiceGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DataTransferServiceGet() + public async Task Get_GraphAPIComputeServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDataTransferServiceGet.json + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceGet.json // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -283,17 +247,21 @@ public async Task Exists_DataTransferServiceGet() CosmosDBServiceCollection collection = cosmosDBAccount.GetCosmosDBServices(); // invoke the operation - string serviceName = "DataTransfer"; - bool result = await collection.ExistsAsync(serviceName); + string serviceName = "GraphAPICompute"; + CosmosDBServiceResource result = await collection.GetAsync(serviceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DataTransferServiceGet() + public async Task Get_MaterializedViewsBuilderServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDataTransferServiceGet.json + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceGet.json // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -313,29 +281,21 @@ public async Task GetIfExists_DataTransferServiceGet() CosmosDBServiceCollection collection = cosmosDBAccount.GetCosmosDBServices(); // invoke the operation - string serviceName = "DataTransfer"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - CosmosDBServiceResource result = response.HasValue ? response.Value : null; + string serviceName = "MaterializedViewsBuilder"; + CosmosDBServiceResource result = await collection.GetAsync(serviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GraphAPIComputeServiceGet() + public async Task Get_SqlDedicatedGatewayServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceGet.json + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/services/sqldedicatedgateway/CosmosDBSqlDedicatedGatewayServiceGet.json // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -355,7 +315,7 @@ public async Task Get_GraphAPIComputeServiceGet() CosmosDBServiceCollection collection = cosmosDBAccount.GetCosmosDBServices(); // invoke the operation - string serviceName = "GraphAPICompute"; + string serviceName = "SqlDedicatedGateway"; CosmosDBServiceResource result = await collection.GetAsync(serviceName); // the variable result is a resource, you could call other operations on this instance as well @@ -367,9 +327,45 @@ public async Task Get_GraphAPIComputeServiceGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GraphAPIComputeServiceGet() + public async Task GetAll_CosmosDBServicesList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceGet.json + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBServicesList.json + // this example is just showing the usage of "Service_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CosmosDBAccountResource created on azure + // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string accountName = "ddb1"; + ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); + + // get the collection of this CosmosDBServiceResource + CosmosDBServiceCollection collection = cosmosDBAccount.GetCosmosDBServices(); + + // invoke the operation and iterate over the result + await foreach (CosmosDBServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_DataTransferServiceGet() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDataTransferServiceGet.json // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -389,7 +385,7 @@ public async Task Exists_GraphAPIComputeServiceGet() CosmosDBServiceCollection collection = cosmosDBAccount.GetCosmosDBServices(); // invoke the operation - string serviceName = "GraphAPICompute"; + string serviceName = "DataTransfer"; bool result = await collection.ExistsAsync(serviceName); Console.WriteLine($"Succeeded: {result}"); @@ -397,7 +393,7 @@ public async Task Exists_GraphAPIComputeServiceGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GraphAPIComputeServiceGet() + public async Task Exists_GraphAPIComputeServiceGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceGet.json // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. @@ -420,26 +416,14 @@ public async Task GetIfExists_GraphAPIComputeServiceGet() // invoke the operation string serviceName = "GraphAPICompute"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - CosmosDBServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MaterializedViewsBuilderServiceGet() + public async Task Exists_MaterializedViewsBuilderServiceGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceGet.json // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. @@ -462,20 +446,16 @@ public async Task Get_MaterializedViewsBuilderServiceGet() // invoke the operation string serviceName = "MaterializedViewsBuilder"; - CosmosDBServiceResource result = await collection.GetAsync(serviceName); + bool result = await collection.ExistsAsync(serviceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MaterializedViewsBuilderServiceGet() + public async Task Exists_SqlDedicatedGatewayServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceGet.json + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/services/sqldedicatedgateway/CosmosDBSqlDedicatedGatewayServiceGet.json // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -495,7 +475,7 @@ public async Task Exists_MaterializedViewsBuilderServiceGet() CosmosDBServiceCollection collection = cosmosDBAccount.GetCosmosDBServices(); // invoke the operation - string serviceName = "MaterializedViewsBuilder"; + string serviceName = "SqlDedicatedGateway"; bool result = await collection.ExistsAsync(serviceName); Console.WriteLine($"Succeeded: {result}"); @@ -503,9 +483,9 @@ public async Task Exists_MaterializedViewsBuilderServiceGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MaterializedViewsBuilderServiceGet() + public async Task GetIfExists_DataTransferServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceGet.json + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDataTransferServiceGet.json // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -525,7 +505,7 @@ public async Task GetIfExists_MaterializedViewsBuilderServiceGet() CosmosDBServiceCollection collection = cosmosDBAccount.GetCosmosDBServices(); // invoke the operation - string serviceName = "MaterializedViewsBuilder"; + string serviceName = "DataTransfer"; NullableResponse response = await collection.GetIfExistsAsync(serviceName); CosmosDBServiceResource result = response.HasValue ? response.Value : null; @@ -545,9 +525,9 @@ public async Task GetIfExists_MaterializedViewsBuilderServiceGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SqlDedicatedGatewayServiceGet() + public async Task GetIfExists_GraphAPIComputeServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/services/sqldedicatedgateway/CosmosDBSqlDedicatedGatewayServiceGet.json + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceGet.json // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -567,21 +547,29 @@ public async Task Get_SqlDedicatedGatewayServiceGet() CosmosDBServiceCollection collection = cosmosDBAccount.GetCosmosDBServices(); // invoke the operation - string serviceName = "SqlDedicatedGateway"; - CosmosDBServiceResource result = await collection.GetAsync(serviceName); + string serviceName = "GraphAPICompute"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + CosmosDBServiceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SqlDedicatedGatewayServiceGet() + public async Task GetIfExists_MaterializedViewsBuilderServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/services/sqldedicatedgateway/CosmosDBSqlDedicatedGatewayServiceGet.json + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceGet.json // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -601,10 +589,22 @@ public async Task Exists_SqlDedicatedGatewayServiceGet() CosmosDBServiceCollection collection = cosmosDBAccount.GetCosmosDBServices(); // invoke the operation - string serviceName = "SqlDedicatedGateway"; - bool result = await collection.ExistsAsync(serviceName); + string serviceName = "MaterializedViewsBuilder"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + CosmosDBServiceResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBServiceResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBServiceResource.cs index 54a5d6eba9b4e..ab3287693a3c9 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBServiceResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBServiceResource.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DataTransferServiceCreate() + public async Task Get_DataTransferServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDataTransferServiceCreate.json - // this example is just showing the usage of "Service_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDataTransferServiceGet.json + // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,7 @@ public async Task Update_DataTransferServiceCreate() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent() - { - Properties = new DataTransferServiceResourceCreateUpdateProperties() - { - InstanceSize = CosmosDBServiceSize.CosmosD4S, - InstanceCount = 1, - }, - }; - ArmOperation lro = await cosmosDBService.UpdateAsync(WaitUntil.Completed, content); - CosmosDBServiceResource result = lro.Value; + CosmosDBServiceResource result = await cosmosDBService.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +49,10 @@ public async Task Update_DataTransferServiceCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GraphAPIComputeServiceCreate() + public async Task Get_GraphAPIComputeServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceCreate.json - // this example is just showing the usage of "Service_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceGet.json + // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,16 +69,7 @@ public async Task Update_GraphAPIComputeServiceCreate() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent() - { - Properties = new GraphApiComputeServiceResourceCreateUpdateProperties() - { - InstanceSize = CosmosDBServiceSize.CosmosD4S, - InstanceCount = 1, - }, - }; - ArmOperation lro = await cosmosDBService.UpdateAsync(WaitUntil.Completed, content); - CosmosDBServiceResource result = lro.Value; + CosmosDBServiceResource result = await cosmosDBService.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -98,10 +80,10 @@ public async Task Update_GraphAPIComputeServiceCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MaterializedViewsBuilderServiceCreate() + public async Task Get_MaterializedViewsBuilderServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceCreate.json - // this example is just showing the usage of "Service_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceGet.json + // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,16 +100,7 @@ public async Task Update_MaterializedViewsBuilderServiceCreate() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent() - { - Properties = new MaterializedViewsBuilderServiceResourceCreateUpdateProperties() - { - InstanceSize = CosmosDBServiceSize.CosmosD4S, - InstanceCount = 1, - }, - }; - ArmOperation lro = await cosmosDBService.UpdateAsync(WaitUntil.Completed, content); - CosmosDBServiceResource result = lro.Value; + CosmosDBServiceResource result = await cosmosDBService.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -138,10 +111,10 @@ public async Task Update_MaterializedViewsBuilderServiceCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SqlDedicatedGatewayServiceCreate() + public async Task Get_SqlDedicatedGatewayServiceGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/services/sqldedicatedgateway/CosmosDBSqlDedicatedGatewayServiceCreate.json - // this example is just showing the usage of "Service_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/services/sqldedicatedgateway/CosmosDBSqlDedicatedGatewayServiceGet.json + // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -158,17 +131,7 @@ public async Task Update_SqlDedicatedGatewayServiceCreate() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent() - { - Properties = new SqlDedicatedGatewayServiceResourceCreateUpdateProperties() - { - DedicatedGatewayType = DedicatedGatewayType.IntegratedCache, - InstanceSize = CosmosDBServiceSize.CosmosD4S, - InstanceCount = 1, - }, - }; - ArmOperation lro = await cosmosDBService.UpdateAsync(WaitUntil.Completed, content); - CosmosDBServiceResource result = lro.Value; + CosmosDBServiceResource result = await cosmosDBService.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -179,10 +142,10 @@ public async Task Update_SqlDedicatedGatewayServiceCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataTransferServiceGet() + public async Task Delete_DataTransferServiceDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDataTransferServiceGet.json - // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDataTransferServiceDelete.json + // this example is just showing the usage of "Service_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,21 +162,17 @@ public async Task Get_DataTransferServiceGet() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - CosmosDBServiceResource result = await cosmosDBService.GetAsync(); + await cosmosDBService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GraphAPIComputeServiceGet() + public async Task Delete_GraphAPIComputeServiceDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceGet.json - // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceDelete.json + // this example is just showing the usage of "Service_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -230,21 +189,17 @@ public async Task Get_GraphAPIComputeServiceGet() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - CosmosDBServiceResource result = await cosmosDBService.GetAsync(); + await cosmosDBService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MaterializedViewsBuilderServiceGet() + public async Task Delete_MaterializedViewsBuilderServiceDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceGet.json - // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceDelete.json + // this example is just showing the usage of "Service_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -261,21 +216,17 @@ public async Task Get_MaterializedViewsBuilderServiceGet() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - CosmosDBServiceResource result = await cosmosDBService.GetAsync(); + await cosmosDBService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SqlDedicatedGatewayServiceGet() + public async Task Delete_SqlDedicatedGatewayServiceDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/services/sqldedicatedgateway/CosmosDBSqlDedicatedGatewayServiceGet.json - // this example is just showing the usage of "Service_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/services/sqldedicatedgateway/CosmosDBSqlDedicatedGatewayServiceDelete.json + // this example is just showing the usage of "Service_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -292,21 +243,17 @@ public async Task Get_SqlDedicatedGatewayServiceGet() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - CosmosDBServiceResource result = await cosmosDBService.GetAsync(); + await cosmosDBService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DataTransferServiceDelete() + public async Task Update_DataTransferServiceCreate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDataTransferServiceDelete.json - // this example is just showing the usage of "Service_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDataTransferServiceCreate.json + // this example is just showing the usage of "Service_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -323,17 +270,30 @@ public async Task Delete_DataTransferServiceDelete() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - await cosmosDBService.DeleteAsync(WaitUntil.Completed); + CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent + { + Properties = new DataTransferServiceResourceCreateUpdateProperties + { + InstanceSize = CosmosDBServiceSize.CosmosD4S, + InstanceCount = 1, + }, + }; + ArmOperation lro = await cosmosDBService.UpdateAsync(WaitUntil.Completed, content); + CosmosDBServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_GraphAPIComputeServiceDelete() + public async Task Update_GraphAPIComputeServiceCreate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceDelete.json - // this example is just showing the usage of "Service_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphAPIComputeServiceCreate.json + // this example is just showing the usage of "Service_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -350,17 +310,30 @@ public async Task Delete_GraphAPIComputeServiceDelete() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - await cosmosDBService.DeleteAsync(WaitUntil.Completed); + CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent + { + Properties = new GraphApiComputeServiceResourceCreateUpdateProperties + { + InstanceSize = CosmosDBServiceSize.CosmosD4S, + InstanceCount = 1, + }, + }; + ArmOperation lro = await cosmosDBService.UpdateAsync(WaitUntil.Completed, content); + CosmosDBServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_MaterializedViewsBuilderServiceDelete() + public async Task Update_MaterializedViewsBuilderServiceCreate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceDelete.json - // this example is just showing the usage of "Service_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMaterializedViewsBuilderServiceCreate.json + // this example is just showing the usage of "Service_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -377,17 +350,30 @@ public async Task Delete_MaterializedViewsBuilderServiceDelete() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - await cosmosDBService.DeleteAsync(WaitUntil.Completed); + CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent + { + Properties = new MaterializedViewsBuilderServiceResourceCreateUpdateProperties + { + InstanceSize = CosmosDBServiceSize.CosmosD4S, + InstanceCount = 1, + }, + }; + ArmOperation lro = await cosmosDBService.UpdateAsync(WaitUntil.Completed, content); + CosmosDBServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SqlDedicatedGatewayServiceDelete() + public async Task Update_SqlDedicatedGatewayServiceCreate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/services/sqldedicatedgateway/CosmosDBSqlDedicatedGatewayServiceDelete.json - // this example is just showing the usage of "Service_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/services/sqldedicatedgateway/CosmosDBSqlDedicatedGatewayServiceCreate.json + // this example is just showing the usage of "Service_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -404,9 +390,23 @@ public async Task Delete_SqlDedicatedGatewayServiceDelete() CosmosDBServiceResource cosmosDBService = client.GetCosmosDBServiceResource(cosmosDBServiceResourceId); // invoke the operation - await cosmosDBService.DeleteAsync(WaitUntil.Completed); + CosmosDBServiceCreateOrUpdateContent content = new CosmosDBServiceCreateOrUpdateContent + { + Properties = new SqlDedicatedGatewayServiceResourceCreateUpdateProperties + { + DedicatedGatewayType = DedicatedGatewayType.IntegratedCache, + InstanceSize = CosmosDBServiceSize.CosmosD4S, + InstanceCount = 1, + }, + }; + ArmOperation lro = await cosmosDBService.UpdateAsync(WaitUntil.Completed, content); + CosmosDBServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlClientEncryptionKeyCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlClientEncryptionKeyCollection.cs index b759a0ab944b6..a392d6e903ea1 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlClientEncryptionKeyCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlClientEncryptionKeyCollection.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Text; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -18,10 +19,10 @@ public partial class Sample_CosmosDBSqlClientEncryptionKeyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBClientEncryptionKeysList() + public async Task CreateOrUpdate_CosmosDBClientEncryptionKeyCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlClientEncryptionKeysList.json - // this example is just showing the usage of "SqlResources_ListClientEncryptionKeys" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlClientEncryptionKeyCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateClientEncryptionKey" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +41,29 @@ public async Task GetAll_CosmosDBClientEncryptionKeysList() // get the collection of this CosmosDBSqlClientEncryptionKeyResource CosmosDBSqlClientEncryptionKeyCollection collection = cosmosDBSqlDatabase.GetCosmosDBSqlClientEncryptionKeys(); - // invoke the operation and iterate over the result - await foreach (CosmosDBSqlClientEncryptionKeyResource item in collection.GetAllAsync()) + // invoke the operation + string clientEncryptionKeyName = "cekName"; + CosmosDBSqlClientEncryptionKeyCreateOrUpdateContent content = new CosmosDBSqlClientEncryptionKeyCreateOrUpdateContent(new CosmosDBSqlClientEncryptionKeyResourceInfo { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlClientEncryptionKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Id = "cekName", + EncryptionAlgorithm = "AEAD_AES_256_CBC_HMAC_SHA256", + WrappedDataEncryptionKey = Encoding.UTF8.GetBytes("VGhpcyBpcyBhY3R1YWxseSBhbiBhcnJheSBvZiBieXRlcy4gVGhpcyByZXF1ZXN0L3Jlc3BvbnNlIGlzIGJlaW5nIHByZXNlbnRlZCBhcyBhIHN0cmluZyBmb3IgcmVhZGFiaWxpdHkgaW4gdGhlIGV4YW1wbGU="), + KeyWrapMetadata = new CosmosDBKeyWrapMetadata + { + Name = "customerManagedKey", + CosmosDBKeyWrapMetadataType = "AzureKeyVault", + Value = "AzureKeyVault Key URL", + Algorithm = "RSA-OAEP", + }, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clientEncryptionKeyName, content); + CosmosDBSqlClientEncryptionKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlClientEncryptionKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +103,10 @@ public async Task Get_CosmosDBClientEncryptionKeyGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBClientEncryptionKeyGet() + public async Task GetAll_CosmosDBClientEncryptionKeysList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlClientEncryptionKeyGet.json - // this example is just showing the usage of "SqlResources_GetClientEncryptionKey" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlClientEncryptionKeysList.json + // this example is just showing the usage of "SqlResources_ListClientEncryptionKeys" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +125,22 @@ public async Task Exists_CosmosDBClientEncryptionKeyGet() // get the collection of this CosmosDBSqlClientEncryptionKeyResource CosmosDBSqlClientEncryptionKeyCollection collection = cosmosDBSqlDatabase.GetCosmosDBSqlClientEncryptionKeys(); - // invoke the operation - string clientEncryptionKeyName = "cekName"; - bool result = await collection.ExistsAsync(clientEncryptionKeyName); + // invoke the operation and iterate over the result + await foreach (CosmosDBSqlClientEncryptionKeyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlClientEncryptionKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBClientEncryptionKeyGet() + public async Task Exists_CosmosDBClientEncryptionKeyGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlClientEncryptionKeyGet.json // this example is just showing the usage of "SqlResources_GetClientEncryptionKey" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +164,17 @@ public async Task GetIfExists_CosmosDBClientEncryptionKeyGet() // invoke the operation string clientEncryptionKeyName = "cekName"; - NullableResponse response = await collection.GetIfExistsAsync(clientEncryptionKeyName); - CosmosDBSqlClientEncryptionKeyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clientEncryptionKeyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlClientEncryptionKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBClientEncryptionKeyCreateUpdate() + public async Task GetIfExists_CosmosDBClientEncryptionKeyGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlClientEncryptionKeyCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateClientEncryptionKey" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlClientEncryptionKeyGet.json + // this example is just showing the usage of "SqlResources_GetClientEncryptionKey" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,27 +195,21 @@ public async Task CreateOrUpdate_CosmosDBClientEncryptionKeyCreateUpdate() // invoke the operation string clientEncryptionKeyName = "cekName"; - CosmosDBSqlClientEncryptionKeyCreateOrUpdateContent content = new CosmosDBSqlClientEncryptionKeyCreateOrUpdateContent(new CosmosDBSqlClientEncryptionKeyResourceInfo() - { - Id = "cekName", - EncryptionAlgorithm = "AEAD_AES_256_CBC_HMAC_SHA256", - WrappedDataEncryptionKey = Convert.FromBase64String("VGhpcyBpcyBhY3R1YWxseSBhbiBhcnJheSBvZiBieXRlcy4gVGhpcyByZXF1ZXN0L3Jlc3BvbnNlIGlzIGJlaW5nIHByZXNlbnRlZCBhcyBhIHN0cmluZyBmb3IgcmVhZGFiaWxpdHkgaW4gdGhlIGV4YW1wbGU="), - KeyWrapMetadata = new CosmosDBKeyWrapMetadata() - { - Name = "customerManagedKey", - CosmosDBKeyWrapMetadataType = "AzureKeyVault", - Value = "AzureKeyVault Key URL", - Algorithm = "RSA-OAEP", - }, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clientEncryptionKeyName, content); - CosmosDBSqlClientEncryptionKeyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(clientEncryptionKeyName); + CosmosDBSqlClientEncryptionKeyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlClientEncryptionKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlClientEncryptionKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlClientEncryptionKeyResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlClientEncryptionKeyResource.cs index b3c4991f1f242..239cf8ad9f14f 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlClientEncryptionKeyResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlClientEncryptionKeyResource.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Text; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -71,12 +72,12 @@ public async Task Update_CosmosDBClientEncryptionKeyCreateUpdate() CosmosDBSqlClientEncryptionKeyResource cosmosDBSqlClientEncryptionKey = client.GetCosmosDBSqlClientEncryptionKeyResource(cosmosDBSqlClientEncryptionKeyResourceId); // invoke the operation - CosmosDBSqlClientEncryptionKeyCreateOrUpdateContent content = new CosmosDBSqlClientEncryptionKeyCreateOrUpdateContent(new CosmosDBSqlClientEncryptionKeyResourceInfo() + CosmosDBSqlClientEncryptionKeyCreateOrUpdateContent content = new CosmosDBSqlClientEncryptionKeyCreateOrUpdateContent(new CosmosDBSqlClientEncryptionKeyResourceInfo { Id = "cekName", EncryptionAlgorithm = "AEAD_AES_256_CBC_HMAC_SHA256", - WrappedDataEncryptionKey = Convert.FromBase64String("VGhpcyBpcyBhY3R1YWxseSBhbiBhcnJheSBvZiBieXRlcy4gVGhpcyByZXF1ZXN0L3Jlc3BvbnNlIGlzIGJlaW5nIHByZXNlbnRlZCBhcyBhIHN0cmluZyBmb3IgcmVhZGFiaWxpdHkgaW4gdGhlIGV4YW1wbGU="), - KeyWrapMetadata = new CosmosDBKeyWrapMetadata() + WrappedDataEncryptionKey = Encoding.UTF8.GetBytes("VGhpcyBpcyBhY3R1YWxseSBhbiBhcnJheSBvZiBieXRlcy4gVGhpcyByZXF1ZXN0L3Jlc3BvbnNlIGlzIGJlaW5nIHByZXNlbnRlZCBhcyBhIHN0cmluZyBmb3IgcmVhZGFiaWxpdHkgaW4gdGhlIGV4YW1wbGU="), + KeyWrapMetadata = new CosmosDBKeyWrapMetadata { Name = "customerManagedKey", CosmosDBKeyWrapMetadataType = "AzureKeyVault", diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerCollection.cs index d55f7936b1e33..0633b9e7e6c5a 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBSqlContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBSqlContainerList() + public async Task CreateOrUpdate_CosmosDBSqlContainerCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerList.json - // this example is just showing the usage of "SqlResources_ListSqlContainers" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlContainer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBSqlContainerList() // this example assumes you already have this CosmosDBSqlDatabaseResource created on azure // for more information of creating CosmosDBSqlDatabaseResource, please refer to the document of CosmosDBSqlDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier cosmosDBSqlDatabaseResourceId = CosmosDBSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -40,25 +40,76 @@ public async Task GetAll_CosmosDBSqlContainerList() // get the collection of this CosmosDBSqlContainerResource CosmosDBSqlContainerCollection collection = cosmosDBSqlDatabase.GetCosmosDBSqlContainers(); - // invoke the operation and iterate over the result - await foreach (CosmosDBSqlContainerResource item in collection.GetAllAsync()) + // invoke the operation + string containerName = "containerName"; + CosmosDBSqlContainerCreateOrUpdateContent content = new CosmosDBSqlContainerCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlContainerResourceInfo("containerName") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IndexingPolicy = new CosmosDBIndexingPolicy + { + IsAutomatic = true, + IndexingMode = CosmosDBIndexingMode.Consistent, + IncludedPaths = {new CosmosDBIncludedPath +{ +Path = "/*", +Indexes = {new CosmosDBPathIndexes +{ +DataType = CosmosDBDataType.String, +Precision = -1, +Kind = CosmosDBIndexKind.Range, +}, new CosmosDBPathIndexes +{ +DataType = CosmosDBDataType.Number, +Precision = -1, +Kind = CosmosDBIndexKind.Range, +}}, +}}, + ExcludedPaths = { }, + }, + PartitionKey = new CosmosDBContainerPartitionKey + { + Paths = { "/AccountNumber" }, + Kind = CosmosDBPartitionKind.Hash, + }, + DefaultTtl = 100, + UniqueKeys = {new CosmosDBUniqueKey +{ +Paths = {"/testPath"}, +}}, + ConflictResolutionPolicy = new ConflictResolutionPolicy + { + Mode = ConflictResolutionMode.LastWriterWins, + ConflictResolutionPath = "/path", + }, + ClientEncryptionPolicy = new CosmosDBClientEncryptionPolicy(new CosmosDBClientEncryptionIncludedPath[] + { +new CosmosDBClientEncryptionIncludedPath("/path", "keyId", "Deterministic", "AEAD_AES_256_CBC_HMAC_SHA256") + }, 2), + ComputedProperties = {new ComputedProperty +{ +Name = "cp_lowerName", +Query = "SELECT VALUE LOWER(c.name) FROM c", +}}, + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, content); + CosmosDBSqlContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBSqlContainerGet() + public async Task CreateOrUpdate_CosmosDBSqlContainerRestore() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerGet.json - // this example is just showing the usage of "SqlResources_GetSqlContainer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerRestore.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlContainer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,7 +119,7 @@ public async Task Get_CosmosDBSqlContainerGet() // this example assumes you already have this CosmosDBSqlDatabaseResource created on azure // for more information of creating CosmosDBSqlDatabaseResource, please refer to the document of CosmosDBSqlDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier cosmosDBSqlDatabaseResourceId = CosmosDBSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -79,7 +130,22 @@ public async Task Get_CosmosDBSqlContainerGet() // invoke the operation string containerName = "containerName"; - CosmosDBSqlContainerResource result = await collection.GetAsync(containerName); + CosmosDBSqlContainerCreateOrUpdateContent content = new CosmosDBSqlContainerCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlContainerResourceInfo("containerName") + { + RestoreParameters = new ResourceRestoreParameters + { + RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", + RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), + IsRestoreWithTtlDisabled = true, + }, + CreateMode = CosmosDBAccountCreateMode.Restore, + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, content); + CosmosDBSqlContainerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,10 +156,10 @@ public async Task Get_CosmosDBSqlContainerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBSqlContainerGet() + public async Task CreateOrUpdate_CosmosDBSqlMaterializedViewCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerGet.json - // this example is just showing the usage of "SqlResources_GetSqlContainer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlMaterializedViewCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlContainer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,7 +169,7 @@ public async Task Exists_CosmosDBSqlContainerGet() // this example assumes you already have this CosmosDBSqlDatabaseResource created on azure // for more information of creating CosmosDBSqlDatabaseResource, please refer to the document of CosmosDBSqlDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier cosmosDBSqlDatabaseResourceId = CosmosDBSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -113,15 +179,54 @@ public async Task Exists_CosmosDBSqlContainerGet() CosmosDBSqlContainerCollection collection = cosmosDBSqlDatabase.GetCosmosDBSqlContainers(); // invoke the operation - string containerName = "containerName"; - bool result = await collection.ExistsAsync(containerName); + string containerName = "mvContainerName"; + CosmosDBSqlContainerCreateOrUpdateContent content = new CosmosDBSqlContainerCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlContainerResourceInfo("mvContainerName") + { + IndexingPolicy = new CosmosDBIndexingPolicy + { + IsAutomatic = true, + IndexingMode = CosmosDBIndexingMode.Consistent, + IncludedPaths = {new CosmosDBIncludedPath +{ +Path = "/*", +Indexes = {new CosmosDBPathIndexes +{ +DataType = CosmosDBDataType.String, +Precision = -1, +Kind = CosmosDBIndexKind.Range, +}, new CosmosDBPathIndexes +{ +DataType = CosmosDBDataType.Number, +Precision = -1, +Kind = CosmosDBIndexKind.Range, +}}, +}}, + ExcludedPaths = { }, + }, + PartitionKey = new CosmosDBContainerPartitionKey + { + Paths = { "/mvpk" }, + Kind = CosmosDBPartitionKind.Hash, + }, + MaterializedViewDefinition = new MaterializedViewDefinition("sourceContainerName", "select * from ROOT"), + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, content); + CosmosDBSqlContainerResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBSqlContainerGet() + public async Task Get_CosmosDBSqlContainerGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerGet.json // this example is just showing the usage of "SqlResources_GetSqlContainer" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +250,21 @@ public async Task GetIfExists_CosmosDBSqlContainerGet() // invoke the operation string containerName = "containerName"; - NullableResponse response = await collection.GetIfExistsAsync(containerName); - CosmosDBSqlContainerResource result = response.HasValue ? response.Value : null; + CosmosDBSqlContainerResource result = await collection.GetAsync(containerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBSqlContainerCreateUpdate() + public async Task GetAll_CosmosDBSqlContainerList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlContainer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerList.json + // this example is just showing the usage of "SqlResources_ListSqlContainers" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,7 +274,7 @@ public async Task CreateOrUpdate_CosmosDBSqlContainerCreateUpdate() // this example assumes you already have this CosmosDBSqlDatabaseResource created on azure // for more information of creating CosmosDBSqlDatabaseResource, please refer to the document of CosmosDBSqlDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier cosmosDBSqlDatabaseResourceId = CosmosDBSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -186,98 +283,25 @@ public async Task CreateOrUpdate_CosmosDBSqlContainerCreateUpdate() // get the collection of this CosmosDBSqlContainerResource CosmosDBSqlContainerCollection collection = cosmosDBSqlDatabase.GetCosmosDBSqlContainers(); - // invoke the operation - string containerName = "containerName"; - CosmosDBSqlContainerCreateOrUpdateContent content = new CosmosDBSqlContainerCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlContainerResourceInfo("containerName") - { - IndexingPolicy = new CosmosDBIndexingPolicy() - { - IsAutomatic = true, - IndexingMode = CosmosDBIndexingMode.Consistent, - IncludedPaths = -{ -new CosmosDBIncludedPath() -{ -Path = "/*", -Indexes = -{ -new CosmosDBPathIndexes() -{ -DataType = CosmosDBDataType.String, -Precision = -1, -Kind = CosmosDBIndexKind.Range, -},new CosmosDBPathIndexes() -{ -DataType = CosmosDBDataType.Number, -Precision = -1, -Kind = CosmosDBIndexKind.Range, -} -}, -} -}, - ExcludedPaths = -{ -}, - }, - PartitionKey = new CosmosDBContainerPartitionKey() - { - Paths = -{ -"/AccountNumber" -}, - Kind = CosmosDBPartitionKind.Hash, - }, - DefaultTtl = 100, - UniqueKeys = -{ -new CosmosDBUniqueKey() -{ -Paths = -{ -"/testPath" -}, -} -}, - ConflictResolutionPolicy = new ConflictResolutionPolicy() - { - Mode = ConflictResolutionMode.LastWriterWins, - ConflictResolutionPath = "/path", - }, - ClientEncryptionPolicy = new CosmosDBClientEncryptionPolicy(new CosmosDBClientEncryptionIncludedPath[] - { -new CosmosDBClientEncryptionIncludedPath("/path","keyId","Deterministic","AEAD_AES_256_CBC_HMAC_SHA256") - }, 2), - ComputedProperties = -{ -new ComputedProperty() -{ -Name = "cp_lowerName", -Query = "SELECT VALUE LOWER(c.name) FROM c", -} -}, - }) + // invoke the operation and iterate over the result + await foreach (CosmosDBSqlContainerResource item in collection.GetAllAsync()) { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, content); - CosmosDBSqlContainerResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBSqlContainerRestore() + public async Task Exists_CosmosDBSqlContainerGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerRestore.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlContainer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerGet.json + // this example is just showing the usage of "SqlResources_GetSqlContainer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -287,7 +311,7 @@ public async Task CreateOrUpdate_CosmosDBSqlContainerRestore() // this example assumes you already have this CosmosDBSqlDatabaseResource created on azure // for more information of creating CosmosDBSqlDatabaseResource, please refer to the document of CosmosDBSqlDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier cosmosDBSqlDatabaseResourceId = CosmosDBSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -298,38 +322,17 @@ public async Task CreateOrUpdate_CosmosDBSqlContainerRestore() // invoke the operation string containerName = "containerName"; - CosmosDBSqlContainerCreateOrUpdateContent content = new CosmosDBSqlContainerCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlContainerResourceInfo("containerName") - { - RestoreParameters = new ResourceRestoreParameters() - { - RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", - RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), - IsRestoreWithTtlDisabled = true, - }, - CreateMode = CosmosDBAccountCreateMode.Restore, - }) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, content); - CosmosDBSqlContainerResource result = lro.Value; + bool result = await collection.ExistsAsync(containerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBSqlMaterializedViewCreateUpdate() + public async Task GetIfExists_CosmosDBSqlContainerGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlMaterializedViewCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlContainer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerGet.json + // this example is just showing the usage of "SqlResources_GetSqlContainer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -339,7 +342,7 @@ public async Task CreateOrUpdate_CosmosDBSqlMaterializedViewCreateUpdate() // this example assumes you already have this CosmosDBSqlDatabaseResource created on azure // for more information of creating CosmosDBSqlDatabaseResource, please refer to the document of CosmosDBSqlDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier cosmosDBSqlDatabaseResourceId = CosmosDBSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -349,62 +352,22 @@ public async Task CreateOrUpdate_CosmosDBSqlMaterializedViewCreateUpdate() CosmosDBSqlContainerCollection collection = cosmosDBSqlDatabase.GetCosmosDBSqlContainers(); // invoke the operation - string containerName = "mvContainerName"; - CosmosDBSqlContainerCreateOrUpdateContent content = new CosmosDBSqlContainerCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlContainerResourceInfo("mvContainerName") + string containerName = "containerName"; + NullableResponse response = await collection.GetIfExistsAsync(containerName); + CosmosDBSqlContainerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - IndexingPolicy = new CosmosDBIndexingPolicy() - { - IsAutomatic = true, - IndexingMode = CosmosDBIndexingMode.Consistent, - IncludedPaths = -{ -new CosmosDBIncludedPath() -{ -Path = "/*", -Indexes = -{ -new CosmosDBPathIndexes() -{ -DataType = CosmosDBDataType.String, -Precision = -1, -Kind = CosmosDBIndexKind.Range, -},new CosmosDBPathIndexes() -{ -DataType = CosmosDBDataType.Number, -Precision = -1, -Kind = CosmosDBIndexKind.Range, -} -}, -} -}, - ExcludedPaths = -{ -}, - }, - PartitionKey = new CosmosDBContainerPartitionKey() - { - Paths = -{ -"/mvpk" -}, - Kind = CosmosDBPartitionKind.Hash, - }, - MaterializedViewDefinition = new MaterializedViewDefinition("sourceContainerName", "select * from ROOT"), - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, content); - CosmosDBSqlContainerResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerResource.cs index f8b397ee7fde4..80bb14e51a0e9 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerResource.cs @@ -48,6 +48,34 @@ public async Task Get_CosmosDBSqlContainerGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CosmosDBSqlContainerDelete() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerDelete.json + // this example is just showing the usage of "SqlResources_DeleteSqlContainer" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CosmosDBSqlContainerResource created on azure + // for more information of creating CosmosDBSqlContainerResource, please refer to the document of CosmosDBSqlContainerResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string accountName = "ddb1"; + string databaseName = "databaseName"; + string containerName = "containerName"; + ResourceIdentifier cosmosDBSqlContainerResourceId = CosmosDBSqlContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName, containerName); + CosmosDBSqlContainerResource cosmosDBSqlContainer = client.GetCosmosDBSqlContainerResource(cosmosDBSqlContainerResourceId); + + // invoke the operation + await cosmosDBSqlContainer.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CosmosDBSqlContainerCreateUpdate() @@ -73,77 +101,55 @@ public async Task Update_CosmosDBSqlContainerCreateUpdate() // invoke the operation CosmosDBSqlContainerCreateOrUpdateContent content = new CosmosDBSqlContainerCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlContainerResourceInfo("containerName") { - IndexingPolicy = new CosmosDBIndexingPolicy() + IndexingPolicy = new CosmosDBIndexingPolicy { IsAutomatic = true, IndexingMode = CosmosDBIndexingMode.Consistent, - IncludedPaths = -{ -new CosmosDBIncludedPath() + IncludedPaths = {new CosmosDBIncludedPath { Path = "/*", -Indexes = -{ -new CosmosDBPathIndexes() +Indexes = {new CosmosDBPathIndexes { DataType = CosmosDBDataType.String, Precision = -1, Kind = CosmosDBIndexKind.Range, -},new CosmosDBPathIndexes() +}, new CosmosDBPathIndexes { DataType = CosmosDBDataType.Number, Precision = -1, Kind = CosmosDBIndexKind.Range, -} -}, -} -}, - ExcludedPaths = -{ -}, +}}, +}}, + ExcludedPaths = { }, }, - PartitionKey = new CosmosDBContainerPartitionKey() + PartitionKey = new CosmosDBContainerPartitionKey { - Paths = -{ -"/AccountNumber" -}, + Paths = { "/AccountNumber" }, Kind = CosmosDBPartitionKind.Hash, }, DefaultTtl = 100, - UniqueKeys = + UniqueKeys = {new CosmosDBUniqueKey { -new CosmosDBUniqueKey() -{ -Paths = -{ -"/testPath" -}, -} -}, - ConflictResolutionPolicy = new ConflictResolutionPolicy() +Paths = {"/testPath"}, +}}, + ConflictResolutionPolicy = new ConflictResolutionPolicy { Mode = ConflictResolutionMode.LastWriterWins, ConflictResolutionPath = "/path", }, ClientEncryptionPolicy = new CosmosDBClientEncryptionPolicy(new CosmosDBClientEncryptionIncludedPath[] { -new CosmosDBClientEncryptionIncludedPath("/path","keyId","Deterministic","AEAD_AES_256_CBC_HMAC_SHA256") +new CosmosDBClientEncryptionIncludedPath("/path", "keyId", "Deterministic", "AEAD_AES_256_CBC_HMAC_SHA256") }, 2), - ComputedProperties = -{ -new ComputedProperty() + ComputedProperties = {new ComputedProperty { Name = "cp_lowerName", Query = "SELECT VALUE LOWER(c.name) FROM c", -} -}, +}}, }) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cosmosDBSqlContainer.UpdateAsync(WaitUntil.Completed, content); CosmosDBSqlContainerResource result = lro.Value; @@ -180,7 +186,7 @@ public async Task Update_CosmosDBSqlContainerRestore() // invoke the operation CosmosDBSqlContainerCreateOrUpdateContent content = new CosmosDBSqlContainerCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlContainerResourceInfo("containerName") { - RestoreParameters = new ResourceRestoreParameters() + RestoreParameters = new ResourceRestoreParameters { RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), @@ -190,9 +196,7 @@ public async Task Update_CosmosDBSqlContainerRestore() }) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cosmosDBSqlContainer.UpdateAsync(WaitUntil.Completed, content); CosmosDBSqlContainerResource result = lro.Value; @@ -229,50 +233,37 @@ public async Task Update_CosmosDBSqlMaterializedViewCreateUpdate() // invoke the operation CosmosDBSqlContainerCreateOrUpdateContent content = new CosmosDBSqlContainerCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlContainerResourceInfo("mvContainerName") { - IndexingPolicy = new CosmosDBIndexingPolicy() + IndexingPolicy = new CosmosDBIndexingPolicy { IsAutomatic = true, IndexingMode = CosmosDBIndexingMode.Consistent, - IncludedPaths = -{ -new CosmosDBIncludedPath() + IncludedPaths = {new CosmosDBIncludedPath { Path = "/*", -Indexes = -{ -new CosmosDBPathIndexes() +Indexes = {new CosmosDBPathIndexes { DataType = CosmosDBDataType.String, Precision = -1, Kind = CosmosDBIndexKind.Range, -},new CosmosDBPathIndexes() +}, new CosmosDBPathIndexes { DataType = CosmosDBDataType.Number, Precision = -1, Kind = CosmosDBIndexKind.Range, -} -}, -} -}, - ExcludedPaths = -{ -}, +}}, +}}, + ExcludedPaths = { }, }, - PartitionKey = new CosmosDBContainerPartitionKey() + PartitionKey = new CosmosDBContainerPartitionKey { - Paths = -{ -"/mvpk" -}, + Paths = { "/mvpk" }, Kind = CosmosDBPartitionKind.Hash, }, MaterializedViewDefinition = new MaterializedViewDefinition("sourceContainerName", "select * from ROOT"), }) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cosmosDBSqlContainer.UpdateAsync(WaitUntil.Completed, content); CosmosDBSqlContainerResource result = lro.Value; @@ -284,34 +275,6 @@ public async Task Update_CosmosDBSqlMaterializedViewCreateUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBSqlContainerDelete() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlContainerDelete.json - // this example is just showing the usage of "SqlResources_DeleteSqlContainer" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CosmosDBSqlContainerResource created on azure - // for more information of creating CosmosDBSqlContainerResource, please refer to the document of CosmosDBSqlContainerResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string accountName = "ddb1"; - string databaseName = "databaseName"; - string containerName = "containerName"; - ResourceIdentifier cosmosDBSqlContainerResourceId = CosmosDBSqlContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName, containerName); - CosmosDBSqlContainerResource cosmosDBSqlContainer = client.GetCosmosDBSqlContainerResource(cosmosDBSqlContainerResourceId); - - // invoke the operation - await cosmosDBSqlContainer.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSqlContainerPartitionMerge_CosmosDBSqlContainerPartitionMerge() @@ -335,7 +298,7 @@ public async Task GetSqlContainerPartitionMerge_CosmosDBSqlContainerPartitionMer CosmosDBSqlContainerResource cosmosDBSqlContainer = client.GetCosmosDBSqlContainerResource(cosmosDBSqlContainerResourceId); // invoke the operation - MergeParameters mergeParameters = new MergeParameters() + MergeParameters mergeParameters = new MergeParameters { IsDryRun = false, }; @@ -368,7 +331,7 @@ public async Task RetrieveContinuousBackupInformation_CosmosDBSqlContainerBackup CosmosDBSqlContainerResource cosmosDBSqlContainer = client.GetCosmosDBSqlContainerResource(cosmosDBSqlContainerResourceId); // invoke the operation - ContinuousBackupRestoreLocation location = new ContinuousBackupRestoreLocation() + ContinuousBackupRestoreLocation location = new ContinuousBackupRestoreLocation { Location = new AzureLocation("North Europe"), }; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerThroughputSettingResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerThroughputSettingResource.cs index 8bdb5007fa3d1..9cdbb5eac80df 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerThroughputSettingResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlContainerThroughputSettingResource.cs @@ -72,14 +72,12 @@ public async Task CreateOrUpdate_CosmosDBSqlContainerThroughputUpdate() CosmosDBSqlContainerThroughputSettingResource cosmosDBSqlContainerThroughputSetting = client.GetCosmosDBSqlContainerThroughputSettingResource(cosmosDBSqlContainerThroughputSettingResourceId); // invoke the operation - ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo() + ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo { Throughput = 400, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cosmosDBSqlContainerThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); CosmosDBSqlContainerThroughputSettingResource result = lro.Value; @@ -180,12 +178,13 @@ public async Task SqlContainerRetrieveThroughputDistribution_CosmosDBSqlContaine CosmosDBSqlContainerThroughputSettingResource cosmosDBSqlContainerThroughputSetting = client.GetCosmosDBSqlContainerThroughputSettingResource(cosmosDBSqlContainerThroughputSettingResourceId); // invoke the operation - RetrieveThroughputParameters retrieveThroughputParameters = new RetrieveThroughputParameters(new AzureLocation("placeholder"), new RetrieveThroughputPropertiesResource(new WritableSubResource[] + RetrieveThroughputParameters retrieveThroughputParameters = new RetrieveThroughputParameters(default, new RetrieveThroughputPropertiesResource(new WritableSubResource[] { -new WritableSubResource() +new WritableSubResource { Id = new ResourceIdentifier("0"), -},new WritableSubResource() +}, +new WritableSubResource { Id = new ResourceIdentifier("1"), } @@ -219,12 +218,13 @@ public async Task SqlContainerRedistributeThroughput_CosmosDBSqlContainerRedistr CosmosDBSqlContainerThroughputSettingResource cosmosDBSqlContainerThroughputSetting = client.GetCosmosDBSqlContainerThroughputSettingResource(cosmosDBSqlContainerThroughputSettingResourceId); // invoke the operation - RedistributeThroughputParameters redistributeThroughputParameters = new RedistributeThroughputParameters(new AzureLocation("placeholder"), new RedistributeThroughputPropertiesResource(ThroughputPolicyType.Custom, new PhysicalPartitionThroughputInfoResource[] + RedistributeThroughputParameters redistributeThroughputParameters = new RedistributeThroughputParameters(default, new RedistributeThroughputPropertiesResource(ThroughputPolicyType.Custom, new PhysicalPartitionThroughputInfoResource[] { new PhysicalPartitionThroughputInfoResource("0") { Throughput = 5000, -},new PhysicalPartitionThroughputInfoResource("1") +}, +new PhysicalPartitionThroughputInfoResource("1") { Throughput = 5000, } @@ -233,7 +233,8 @@ public async Task SqlContainerRedistributeThroughput_CosmosDBSqlContainerRedistr new PhysicalPartitionThroughputInfoResource("2") { Throughput = 5000, -},new PhysicalPartitionThroughputInfoResource("3") +}, +new PhysicalPartitionThroughputInfoResource("3") })); ArmOperation lro = await cosmosDBSqlContainerThroughputSetting.SqlContainerRedistributeThroughputAsync(WaitUntil.Completed, redistributeThroughputParameters); PhysicalPartitionThroughputInfoResult result = lro.Value; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseCollection.cs index 889dc2b312c30..88e8dd7c2e986 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBSqlDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBSqlDatabaseList() + public async Task CreateOrUpdate_CosmosDBSqlDatabaseCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseList.json - // this example is just showing the usage of "SqlResources_ListSqlDatabases" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBSqlDatabaseList() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -39,25 +39,29 @@ public async Task GetAll_CosmosDBSqlDatabaseList() // get the collection of this CosmosDBSqlDatabaseResource CosmosDBSqlDatabaseCollection collection = cosmosDBAccount.GetCosmosDBSqlDatabases(); - // invoke the operation and iterate over the result - await foreach (CosmosDBSqlDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "databaseName"; + CosmosDBSqlDatabaseCreateOrUpdateContent content = new CosmosDBSqlDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlDatabaseResourceInfo("databaseName")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, content); + CosmosDBSqlDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBSqlDatabaseGet() + public async Task CreateOrUpdate_CosmosDBSqlDatabaseRestore() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseGet.json - // this example is just showing the usage of "SqlResources_GetSqlDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseRestore.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +81,22 @@ public async Task Get_CosmosDBSqlDatabaseGet() // invoke the operation string databaseName = "databaseName"; - CosmosDBSqlDatabaseResource result = await collection.GetAsync(databaseName); + CosmosDBSqlDatabaseCreateOrUpdateContent content = new CosmosDBSqlDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlDatabaseResourceInfo("databaseName") + { + RestoreParameters = new ResourceRestoreParameters + { + RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", + RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), + IsRestoreWithTtlDisabled = true, + }, + CreateMode = CosmosDBAccountCreateMode.Restore, + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, content); + CosmosDBSqlDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +107,7 @@ public async Task Get_CosmosDBSqlDatabaseGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBSqlDatabaseGet() + public async Task Get_CosmosDBSqlDatabaseGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseGet.json // this example is just showing the usage of "SqlResources_GetSqlDatabase" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +130,21 @@ public async Task Exists_CosmosDBSqlDatabaseGet() // invoke the operation string databaseName = "databaseName"; - bool result = await collection.ExistsAsync(databaseName); + CosmosDBSqlDatabaseResource result = await collection.GetAsync(databaseName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBSqlDatabaseGet() + public async Task GetAll_CosmosDBSqlDatabaseList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseGet.json - // this example is just showing the usage of "SqlResources_GetSqlDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseList.json + // this example is just showing the usage of "SqlResources_ListSqlDatabases" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,7 +154,7 @@ public async Task GetIfExists_CosmosDBSqlDatabaseGet() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -139,31 +162,25 @@ public async Task GetIfExists_CosmosDBSqlDatabaseGet() // get the collection of this CosmosDBSqlDatabaseResource CosmosDBSqlDatabaseCollection collection = cosmosDBAccount.GetCosmosDBSqlDatabases(); - // invoke the operation - string databaseName = "databaseName"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - CosmosDBSqlDatabaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CosmosDBSqlDatabaseResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CosmosDBSqlDatabaseData resourceData = result.Data; + CosmosDBSqlDatabaseData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBSqlDatabaseCreateUpdate() + public async Task Exists_CosmosDBSqlDatabaseGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseGet.json + // this example is just showing the usage of "SqlResources_GetSqlDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,29 +200,17 @@ public async Task CreateOrUpdate_CosmosDBSqlDatabaseCreateUpdate() // invoke the operation string databaseName = "databaseName"; - CosmosDBSqlDatabaseCreateOrUpdateContent content = new CosmosDBSqlDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlDatabaseResourceInfo("databaseName")) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, content); - CosmosDBSqlDatabaseResource result = lro.Value; + bool result = await collection.ExistsAsync(databaseName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBSqlDatabaseRestore() + public async Task GetIfExists_CosmosDBSqlDatabaseGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseRestore.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseGet.json + // this example is just showing the usage of "SqlResources_GetSqlDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -225,30 +230,21 @@ public async Task CreateOrUpdate_CosmosDBSqlDatabaseRestore() // invoke the operation string databaseName = "databaseName"; - CosmosDBSqlDatabaseCreateOrUpdateContent content = new CosmosDBSqlDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlDatabaseResourceInfo("databaseName") + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + CosmosDBSqlDatabaseResource result = response.HasValue ? response.Value : null; + + if (result == null) { - RestoreParameters = new ResourceRestoreParameters() - { - RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", - RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), - IsRestoreWithTtlDisabled = true, - }, - CreateMode = CosmosDBAccountCreateMode.Restore, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, content); - CosmosDBSqlDatabaseResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseResource.cs index 395e5d30e0dc7..f60d69acdc675 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseResource.cs @@ -47,6 +47,33 @@ public async Task Get_CosmosDBSqlDatabaseGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CosmosDBSqlDatabaseDelete() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseDelete.json + // this example is just showing the usage of "SqlResources_DeleteSqlDatabase" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CosmosDBSqlDatabaseResource created on azure + // for more information of creating CosmosDBSqlDatabaseResource, please refer to the document of CosmosDBSqlDatabaseResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string accountName = "ddb1"; + string databaseName = "databaseName"; + ResourceIdentifier cosmosDBSqlDatabaseResourceId = CosmosDBSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); + CosmosDBSqlDatabaseResource cosmosDBSqlDatabase = client.GetCosmosDBSqlDatabaseResource(cosmosDBSqlDatabaseResourceId); + + // invoke the operation + await cosmosDBSqlDatabase.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CosmosDBSqlDatabaseCreateUpdate() @@ -72,9 +99,7 @@ public async Task Update_CosmosDBSqlDatabaseCreateUpdate() CosmosDBSqlDatabaseCreateOrUpdateContent content = new CosmosDBSqlDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlDatabaseResourceInfo("databaseName")) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cosmosDBSqlDatabase.UpdateAsync(WaitUntil.Completed, content); CosmosDBSqlDatabaseResource result = lro.Value; @@ -110,7 +135,7 @@ public async Task Update_CosmosDBSqlDatabaseRestore() // invoke the operation CosmosDBSqlDatabaseCreateOrUpdateContent content = new CosmosDBSqlDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBSqlDatabaseResourceInfo("databaseName") { - RestoreParameters = new ResourceRestoreParameters() + RestoreParameters = new ResourceRestoreParameters { RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), @@ -120,9 +145,7 @@ public async Task Update_CosmosDBSqlDatabaseRestore() }) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cosmosDBSqlDatabase.UpdateAsync(WaitUntil.Completed, content); CosmosDBSqlDatabaseResource result = lro.Value; @@ -134,33 +157,6 @@ public async Task Update_CosmosDBSqlDatabaseRestore() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBSqlDatabaseDelete() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlDatabaseDelete.json - // this example is just showing the usage of "SqlResources_DeleteSqlDatabase" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CosmosDBSqlDatabaseResource created on azure - // for more information of creating CosmosDBSqlDatabaseResource, please refer to the document of CosmosDBSqlDatabaseResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string accountName = "ddb1"; - string databaseName = "databaseName"; - ResourceIdentifier cosmosDBSqlDatabaseResourceId = CosmosDBSqlDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); - CosmosDBSqlDatabaseResource cosmosDBSqlDatabase = client.GetCosmosDBSqlDatabaseResource(cosmosDBSqlDatabaseResourceId); - - // invoke the operation - await cosmosDBSqlDatabase.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task SqlDatabasePartitionMerge_CosmosDBSqlDatabasePartitionMerge() @@ -183,7 +179,7 @@ public async Task SqlDatabasePartitionMerge_CosmosDBSqlDatabasePartitionMerge() CosmosDBSqlDatabaseResource cosmosDBSqlDatabase = client.GetCosmosDBSqlDatabaseResource(cosmosDBSqlDatabaseResourceId); // invoke the operation - MergeParameters mergeParameters = new MergeParameters() + MergeParameters mergeParameters = new MergeParameters { IsDryRun = false, }; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseThroughputSettingResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseThroughputSettingResource.cs index ac0aa7c41959c..b727e07089dc9 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseThroughputSettingResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlDatabaseThroughputSettingResource.cs @@ -70,14 +70,12 @@ public async Task CreateOrUpdate_CosmosDBSqlDatabaseThroughputUpdate() CosmosDBSqlDatabaseThroughputSettingResource cosmosDBSqlDatabaseThroughputSetting = client.GetCosmosDBSqlDatabaseThroughputSettingResource(cosmosDBSqlDatabaseThroughputSettingResourceId); // invoke the operation - ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo() + ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo { Throughput = 400, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cosmosDBSqlDatabaseThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); CosmosDBSqlDatabaseThroughputSettingResource result = lro.Value; @@ -175,12 +173,13 @@ public async Task SqlDatabaseRetrieveThroughputDistribution_CosmosDBSqlDatabaseR CosmosDBSqlDatabaseThroughputSettingResource cosmosDBSqlDatabaseThroughputSetting = client.GetCosmosDBSqlDatabaseThroughputSettingResource(cosmosDBSqlDatabaseThroughputSettingResourceId); // invoke the operation - RetrieveThroughputParameters retrieveThroughputParameters = new RetrieveThroughputParameters(new AzureLocation("placeholder"), new RetrieveThroughputPropertiesResource(new WritableSubResource[] + RetrieveThroughputParameters retrieveThroughputParameters = new RetrieveThroughputParameters(default, new RetrieveThroughputPropertiesResource(new WritableSubResource[] { -new WritableSubResource() +new WritableSubResource { Id = new ResourceIdentifier("0"), -},new WritableSubResource() +}, +new WritableSubResource { Id = new ResourceIdentifier("1"), } @@ -213,12 +212,13 @@ public async Task SqlDatabaseRedistributeThroughput_CosmosDBSqlDatabaseRedistrib CosmosDBSqlDatabaseThroughputSettingResource cosmosDBSqlDatabaseThroughputSetting = client.GetCosmosDBSqlDatabaseThroughputSettingResource(cosmosDBSqlDatabaseThroughputSettingResourceId); // invoke the operation - RedistributeThroughputParameters redistributeThroughputParameters = new RedistributeThroughputParameters(new AzureLocation("placeholder"), new RedistributeThroughputPropertiesResource(ThroughputPolicyType.Custom, new PhysicalPartitionThroughputInfoResource[] + RedistributeThroughputParameters redistributeThroughputParameters = new RedistributeThroughputParameters(default, new RedistributeThroughputPropertiesResource(ThroughputPolicyType.Custom, new PhysicalPartitionThroughputInfoResource[] { new PhysicalPartitionThroughputInfoResource("0") { Throughput = 5000, -},new PhysicalPartitionThroughputInfoResource("1") +}, +new PhysicalPartitionThroughputInfoResource("1") { Throughput = 5000, } @@ -227,7 +227,8 @@ public async Task SqlDatabaseRedistributeThroughput_CosmosDBSqlDatabaseRedistrib new PhysicalPartitionThroughputInfoResource("2") { Throughput = 5000, -},new PhysicalPartitionThroughputInfoResource("3") +}, +new PhysicalPartitionThroughputInfoResource("3") })); ArmOperation lro = await cosmosDBSqlDatabaseThroughputSetting.SqlDatabaseRedistributeThroughputAsync(WaitUntil.Completed, redistributeThroughputParameters); PhysicalPartitionThroughputInfoResult result = lro.Value; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleAssignmentCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleAssignmentCollection.cs index 307886abf3a3f..7ced1d5de3a11 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleAssignmentCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleAssignmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBSqlRoleAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBSqlRoleAssignmentGet() + public async Task CreateOrUpdate_CosmosDBSqlRoleAssignmentCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentGet.json - // this example is just showing the usage of "SqlResources_GetSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,14 @@ public async Task Get_CosmosDBSqlRoleAssignmentGet() // invoke the operation string roleAssignmentId = "myRoleAssignmentId"; - CosmosDBSqlRoleAssignmentResource result = await collection.GetAsync(roleAssignmentId); + CosmosDBSqlRoleAssignmentCreateOrUpdateContent content = new CosmosDBSqlRoleAssignmentCreateOrUpdateContent + { + RoleDefinitionId = new ResourceIdentifier("/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/sqlRoleDefinitions/myRoleDefinitionId"), + Scope = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/purchases/colls/redmond-purchases", + PrincipalId = Guid.Parse("myPrincipalId"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleAssignmentId, content); + CosmosDBSqlRoleAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +59,7 @@ public async Task Get_CosmosDBSqlRoleAssignmentGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBSqlRoleAssignmentGet() + public async Task Get_CosmosDBSqlRoleAssignmentGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentGet.json // this example is just showing the usage of "SqlResources_GetSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +82,21 @@ public async Task Exists_CosmosDBSqlRoleAssignmentGet() // invoke the operation string roleAssignmentId = "myRoleAssignmentId"; - bool result = await collection.ExistsAsync(roleAssignmentId); + CosmosDBSqlRoleAssignmentResource result = await collection.GetAsync(roleAssignmentId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBSqlRoleAssignmentGet() + public async Task GetAll_CosmosDBSqlRoleAssignmentList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentGet.json - // this example is just showing the usage of "SqlResources_GetSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentList.json + // this example is just showing the usage of "SqlResources_ListSqlRoleAssignments" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +114,25 @@ public async Task GetIfExists_CosmosDBSqlRoleAssignmentGet() // get the collection of this CosmosDBSqlRoleAssignmentResource CosmosDBSqlRoleAssignmentCollection collection = cosmosDBAccount.GetCosmosDBSqlRoleAssignments(); - // invoke the operation - string roleAssignmentId = "myRoleAssignmentId"; - NullableResponse response = await collection.GetIfExistsAsync(roleAssignmentId); - CosmosDBSqlRoleAssignmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CosmosDBSqlRoleAssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CosmosDBSqlRoleAssignmentData resourceData = result.Data; + CosmosDBSqlRoleAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBSqlRoleAssignmentCreateUpdate() + public async Task Exists_CosmosDBSqlRoleAssignmentGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentGet.json + // this example is just showing the usage of "SqlResources_GetSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,28 +152,17 @@ public async Task CreateOrUpdate_CosmosDBSqlRoleAssignmentCreateUpdate() // invoke the operation string roleAssignmentId = "myRoleAssignmentId"; - CosmosDBSqlRoleAssignmentCreateOrUpdateContent content = new CosmosDBSqlRoleAssignmentCreateOrUpdateContent() - { - RoleDefinitionId = new ResourceIdentifier("/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/sqlRoleDefinitions/myRoleDefinitionId"), - Scope = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/purchases/colls/redmond-purchases", - PrincipalId = Guid.Parse("myPrincipalId"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleAssignmentId, content); - CosmosDBSqlRoleAssignmentResource result = lro.Value; + bool result = await collection.ExistsAsync(roleAssignmentId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBSqlRoleAssignmentList() + public async Task GetIfExists_CosmosDBSqlRoleAssignmentGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentList.json - // this example is just showing the usage of "SqlResources_ListSqlRoleAssignments" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentGet.json + // this example is just showing the usage of "SqlResources_GetSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_CosmosDBSqlRoleAssignmentList() // get the collection of this CosmosDBSqlRoleAssignmentResource CosmosDBSqlRoleAssignmentCollection collection = cosmosDBAccount.GetCosmosDBSqlRoleAssignments(); - // invoke the operation and iterate over the result - await foreach (CosmosDBSqlRoleAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string roleAssignmentId = "myRoleAssignmentId"; + NullableResponse response = await collection.GetIfExistsAsync(roleAssignmentId); + CosmosDBSqlRoleAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CosmosDBSqlRoleAssignmentData resourceData = item.Data; + CosmosDBSqlRoleAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleAssignmentResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleAssignmentResource.cs index 49eb15c4e1edd..d83e860a08c2f 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleAssignmentResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleAssignmentResource.cs @@ -49,10 +49,10 @@ public async Task Get_CosmosDBSqlRoleAssignmentGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBSqlRoleAssignmentCreateUpdate() + public async Task Delete_CosmosDBSqlRoleAssignmentDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentDelete.json + // this example is just showing the usage of "SqlResources_DeleteSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,28 +69,17 @@ public async Task Update_CosmosDBSqlRoleAssignmentCreateUpdate() CosmosDBSqlRoleAssignmentResource cosmosDBSqlRoleAssignment = client.GetCosmosDBSqlRoleAssignmentResource(cosmosDBSqlRoleAssignmentResourceId); // invoke the operation - CosmosDBSqlRoleAssignmentCreateOrUpdateContent content = new CosmosDBSqlRoleAssignmentCreateOrUpdateContent() - { - RoleDefinitionId = new ResourceIdentifier("/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/sqlRoleDefinitions/myRoleDefinitionId"), - Scope = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/purchases/colls/redmond-purchases", - PrincipalId = Guid.Parse("myPrincipalId"), - }; - ArmOperation lro = await cosmosDBSqlRoleAssignment.UpdateAsync(WaitUntil.Completed, content); - CosmosDBSqlRoleAssignmentResource result = lro.Value; + await cosmosDBSqlRoleAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBSqlRoleAssignmentDelete() + public async Task Update_CosmosDBSqlRoleAssignmentCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentDelete.json - // this example is just showing the usage of "SqlResources_DeleteSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleAssignmentCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlRoleAssignment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +96,20 @@ public async Task Delete_CosmosDBSqlRoleAssignmentDelete() CosmosDBSqlRoleAssignmentResource cosmosDBSqlRoleAssignment = client.GetCosmosDBSqlRoleAssignmentResource(cosmosDBSqlRoleAssignmentResourceId); // invoke the operation - await cosmosDBSqlRoleAssignment.DeleteAsync(WaitUntil.Completed); + CosmosDBSqlRoleAssignmentCreateOrUpdateContent content = new CosmosDBSqlRoleAssignmentCreateOrUpdateContent + { + RoleDefinitionId = new ResourceIdentifier("/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/sqlRoleDefinitions/myRoleDefinitionId"), + Scope = "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/purchases/colls/redmond-purchases", + PrincipalId = Guid.Parse("myPrincipalId"), + }; + ArmOperation lro = await cosmosDBSqlRoleAssignment.UpdateAsync(WaitUntil.Completed, content); + CosmosDBSqlRoleAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleDefinitionCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleDefinitionCollection.cs index 093d94dc1a058..b21a70a97e7d9 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleDefinitionCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleDefinitionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBSqlRoleDefinitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBSqlRoleDefinitionGet() + public async Task CreateOrUpdate_CosmosDBSqlRoleDefinitionCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionGet.json - // this example is just showing the usage of "SqlResources_GetSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,19 @@ public async Task Get_CosmosDBSqlRoleDefinitionGet() // invoke the operation string roleDefinitionId = "myRoleDefinitionId"; - CosmosDBSqlRoleDefinitionResource result = await collection.GetAsync(roleDefinitionId); + CosmosDBSqlRoleDefinitionCreateOrUpdateContent content = new CosmosDBSqlRoleDefinitionCreateOrUpdateContent + { + RoleName = "myRoleName", + RoleDefinitionType = CosmosDBSqlRoleDefinitionType.CustomRole, + AssignableScopes = { "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/sales", "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/purchases" }, + Permissions = {new CosmosDBSqlRolePermission +{ +DataActions = {"Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/create", "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/read"}, +NotDataActions = {}, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleDefinitionId, content); + CosmosDBSqlRoleDefinitionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +64,7 @@ public async Task Get_CosmosDBSqlRoleDefinitionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBSqlRoleDefinitionGet() + public async Task Get_CosmosDBSqlRoleDefinitionGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionGet.json // this example is just showing the usage of "SqlResources_GetSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +87,21 @@ public async Task Exists_CosmosDBSqlRoleDefinitionGet() // invoke the operation string roleDefinitionId = "myRoleDefinitionId"; - bool result = await collection.ExistsAsync(roleDefinitionId); + CosmosDBSqlRoleDefinitionResource result = await collection.GetAsync(roleDefinitionId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlRoleDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBSqlRoleDefinitionGet() + public async Task GetAll_CosmosDBSqlRoleDefinitionList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionGet.json - // this example is just showing the usage of "SqlResources_GetSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionList.json + // this example is just showing the usage of "SqlResources_ListSqlRoleDefinitions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +119,25 @@ public async Task GetIfExists_CosmosDBSqlRoleDefinitionGet() // get the collection of this CosmosDBSqlRoleDefinitionResource CosmosDBSqlRoleDefinitionCollection collection = cosmosDBAccount.GetCosmosDBSqlRoleDefinitions(); - // invoke the operation - string roleDefinitionId = "myRoleDefinitionId"; - NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionId); - CosmosDBSqlRoleDefinitionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CosmosDBSqlRoleDefinitionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CosmosDBSqlRoleDefinitionData resourceData = result.Data; + CosmosDBSqlRoleDefinitionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBSqlRoleDefinitionCreateUpdate() + public async Task Exists_CosmosDBSqlRoleDefinitionGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionGet.json + // this example is just showing the usage of "SqlResources_GetSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,44 +157,17 @@ public async Task CreateOrUpdate_CosmosDBSqlRoleDefinitionCreateUpdate() // invoke the operation string roleDefinitionId = "myRoleDefinitionId"; - CosmosDBSqlRoleDefinitionCreateOrUpdateContent content = new CosmosDBSqlRoleDefinitionCreateOrUpdateContent() - { - RoleName = "myRoleName", - RoleDefinitionType = CosmosDBSqlRoleDefinitionType.CustomRole, - AssignableScopes = -{ -"/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/sales","/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/purchases" -}, - Permissions = -{ -new CosmosDBSqlRolePermission() -{ -DataActions = -{ -"Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/create","Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/read" -}, -NotDataActions = -{ -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleDefinitionId, content); - CosmosDBSqlRoleDefinitionResource result = lro.Value; + bool result = await collection.ExistsAsync(roleDefinitionId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBSqlRoleDefinitionList() + public async Task GetIfExists_CosmosDBSqlRoleDefinitionGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionList.json - // this example is just showing the usage of "SqlResources_ListSqlRoleDefinitions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionGet.json + // this example is just showing the usage of "SqlResources_GetSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -202,17 +185,23 @@ public async Task GetAll_CosmosDBSqlRoleDefinitionList() // get the collection of this CosmosDBSqlRoleDefinitionResource CosmosDBSqlRoleDefinitionCollection collection = cosmosDBAccount.GetCosmosDBSqlRoleDefinitions(); - // invoke the operation and iterate over the result - await foreach (CosmosDBSqlRoleDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string roleDefinitionId = "myRoleDefinitionId"; + NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionId); + CosmosDBSqlRoleDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CosmosDBSqlRoleDefinitionData resourceData = item.Data; + CosmosDBSqlRoleDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleDefinitionResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleDefinitionResource.cs index 65e68893cd2aa..6b720694f6e84 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleDefinitionResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlRoleDefinitionResource.cs @@ -49,10 +49,10 @@ public async Task Get_CosmosDBSqlRoleDefinitionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBSqlRoleDefinitionCreateUpdate() + public async Task Delete_CosmosDBSqlRoleDefinitionDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionDelete.json + // this example is just showing the usage of "SqlResources_DeleteSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,44 +69,17 @@ public async Task Update_CosmosDBSqlRoleDefinitionCreateUpdate() CosmosDBSqlRoleDefinitionResource cosmosDBSqlRoleDefinition = client.GetCosmosDBSqlRoleDefinitionResource(cosmosDBSqlRoleDefinitionResourceId); // invoke the operation - CosmosDBSqlRoleDefinitionCreateOrUpdateContent content = new CosmosDBSqlRoleDefinitionCreateOrUpdateContent() - { - RoleName = "myRoleName", - RoleDefinitionType = CosmosDBSqlRoleDefinitionType.CustomRole, - AssignableScopes = -{ -"/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/sales","/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/purchases" -}, - Permissions = -{ -new CosmosDBSqlRolePermission() -{ -DataActions = -{ -"Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/create","Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/read" -}, -NotDataActions = -{ -}, -} -}, - }; - ArmOperation lro = await cosmosDBSqlRoleDefinition.UpdateAsync(WaitUntil.Completed, content); - CosmosDBSqlRoleDefinitionResource result = lro.Value; + await cosmosDBSqlRoleDefinition.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBSqlRoleDefinitionDelete() + public async Task Update_CosmosDBSqlRoleDefinitionCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionDelete.json - // this example is just showing the usage of "SqlResources_DeleteSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlRoleDefinitionCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlRoleDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -123,9 +96,25 @@ public async Task Delete_CosmosDBSqlRoleDefinitionDelete() CosmosDBSqlRoleDefinitionResource cosmosDBSqlRoleDefinition = client.GetCosmosDBSqlRoleDefinitionResource(cosmosDBSqlRoleDefinitionResourceId); // invoke the operation - await cosmosDBSqlRoleDefinition.DeleteAsync(WaitUntil.Completed); + CosmosDBSqlRoleDefinitionCreateOrUpdateContent content = new CosmosDBSqlRoleDefinitionCreateOrUpdateContent + { + RoleName = "myRoleName", + RoleDefinitionType = CosmosDBSqlRoleDefinitionType.CustomRole, + AssignableScopes = { "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/sales", "/subscriptions/mySubscriptionId/resourceGroups/myResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/myAccountName/dbs/purchases" }, + Permissions = {new CosmosDBSqlRolePermission +{ +DataActions = {"Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/create", "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/read"}, +NotDataActions = {}, +}}, + }; + ArmOperation lro = await cosmosDBSqlRoleDefinition.UpdateAsync(WaitUntil.Completed, content); + CosmosDBSqlRoleDefinitionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlRoleDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlStoredProcedureCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlStoredProcedureCollection.cs index 70ee6c6777e87..1a1eb6d4c7c31 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlStoredProcedureCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlStoredProcedureCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBSqlStoredProcedureCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBSqlStoredProcedureList() + public async Task CreateOrUpdate_CosmosDBSqlStoredProcedureCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureList.json - // this example is just showing the usage of "SqlResources_ListSqlStoredProcedures" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlStoredProcedure" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBSqlStoredProcedureList() // this example assumes you already have this CosmosDBSqlContainerResource created on azure // for more information of creating CosmosDBSqlContainerResource, please refer to the document of CosmosDBSqlContainerResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string databaseName = "databaseName"; string containerName = "containerName"; @@ -41,17 +41,23 @@ public async Task GetAll_CosmosDBSqlStoredProcedureList() // get the collection of this CosmosDBSqlStoredProcedureResource CosmosDBSqlStoredProcedureCollection collection = cosmosDBSqlContainer.GetCosmosDBSqlStoredProcedures(); - // invoke the operation and iterate over the result - await foreach (CosmosDBSqlStoredProcedureResource item in collection.GetAllAsync()) + // invoke the operation + string storedProcedureName = "storedProcedureName"; + CosmosDBSqlStoredProcedureCreateOrUpdateContent content = new CosmosDBSqlStoredProcedureCreateOrUpdateContent(default, new CosmosDBSqlStoredProcedureResourceInfo("storedProcedureName") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlStoredProcedureData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Body = "body", + }) + { + Options = new CosmosDBCreateUpdateConfig(), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storedProcedureName, content); + CosmosDBSqlStoredProcedureResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlStoredProcedureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +98,10 @@ public async Task Get_CosmosDBSqlStoredProcedureGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBSqlStoredProcedureGet() + public async Task GetAll_CosmosDBSqlStoredProcedureList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureGet.json - // this example is just showing the usage of "SqlResources_GetSqlStoredProcedure" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureList.json + // this example is just showing the usage of "SqlResources_ListSqlStoredProcedures" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +121,22 @@ public async Task Exists_CosmosDBSqlStoredProcedureGet() // get the collection of this CosmosDBSqlStoredProcedureResource CosmosDBSqlStoredProcedureCollection collection = cosmosDBSqlContainer.GetCosmosDBSqlStoredProcedures(); - // invoke the operation - string storedProcedureName = "storedProcedureName"; - bool result = await collection.ExistsAsync(storedProcedureName); + // invoke the operation and iterate over the result + await foreach (CosmosDBSqlStoredProcedureResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlStoredProcedureData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBSqlStoredProcedureGet() + public async Task Exists_CosmosDBSqlStoredProcedureGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureGet.json // this example is just showing the usage of "SqlResources_GetSqlStoredProcedure" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +161,17 @@ public async Task GetIfExists_CosmosDBSqlStoredProcedureGet() // invoke the operation string storedProcedureName = "storedProcedureName"; - NullableResponse response = await collection.GetIfExistsAsync(storedProcedureName); - CosmosDBSqlStoredProcedureResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(storedProcedureName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlStoredProcedureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBSqlStoredProcedureCreateUpdate() + public async Task GetIfExists_CosmosDBSqlStoredProcedureGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlStoredProcedure" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureGet.json + // this example is just showing the usage of "SqlResources_GetSqlStoredProcedure" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,7 +181,7 @@ public async Task CreateOrUpdate_CosmosDBSqlStoredProcedureCreateUpdate() // this example assumes you already have this CosmosDBSqlContainerResource created on azure // for more information of creating CosmosDBSqlContainerResource, please refer to the document of CosmosDBSqlContainerResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string databaseName = "databaseName"; string containerName = "containerName"; @@ -193,21 +193,21 @@ public async Task CreateOrUpdate_CosmosDBSqlStoredProcedureCreateUpdate() // invoke the operation string storedProcedureName = "storedProcedureName"; - CosmosDBSqlStoredProcedureCreateOrUpdateContent content = new CosmosDBSqlStoredProcedureCreateOrUpdateContent(new AzureLocation("placeholder"), new CosmosDBSqlStoredProcedureResourceInfo("storedProcedureName") + NullableResponse response = await collection.GetIfExistsAsync(storedProcedureName); + CosmosDBSqlStoredProcedureResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Body = "body", - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Options = new CosmosDBCreateUpdateConfig(), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storedProcedureName, content); - CosmosDBSqlStoredProcedureResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlStoredProcedureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlStoredProcedureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlStoredProcedureResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlStoredProcedureResource.cs index b8de1415e9764..7d6f77edcbad2 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlStoredProcedureResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlStoredProcedureResource.cs @@ -51,10 +51,10 @@ public async Task Get_CosmosDBSqlStoredProcedureGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBSqlStoredProcedureCreateUpdate() + public async Task Delete_CosmosDBSqlStoredProcedureDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlStoredProcedure" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureDelete.json + // this example is just showing the usage of "SqlResources_DeleteSqlStoredProcedure" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,29 +73,17 @@ public async Task Update_CosmosDBSqlStoredProcedureCreateUpdate() CosmosDBSqlStoredProcedureResource cosmosDBSqlStoredProcedure = client.GetCosmosDBSqlStoredProcedureResource(cosmosDBSqlStoredProcedureResourceId); // invoke the operation - CosmosDBSqlStoredProcedureCreateOrUpdateContent content = new CosmosDBSqlStoredProcedureCreateOrUpdateContent(new AzureLocation("placeholder"), new CosmosDBSqlStoredProcedureResourceInfo("storedProcedureName") - { - Body = "body", - }) - { - Options = new CosmosDBCreateUpdateConfig(), - }; - ArmOperation lro = await cosmosDBSqlStoredProcedure.UpdateAsync(WaitUntil.Completed, content); - CosmosDBSqlStoredProcedureResource result = lro.Value; + await cosmosDBSqlStoredProcedure.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlStoredProcedureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBSqlStoredProcedureDelete() + public async Task Update_CosmosDBSqlStoredProcedureCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureDelete.json - // this example is just showing the usage of "SqlResources_DeleteSqlStoredProcedure" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlStoredProcedureCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlStoredProcedure" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +102,21 @@ public async Task Delete_CosmosDBSqlStoredProcedureDelete() CosmosDBSqlStoredProcedureResource cosmosDBSqlStoredProcedure = client.GetCosmosDBSqlStoredProcedureResource(cosmosDBSqlStoredProcedureResourceId); // invoke the operation - await cosmosDBSqlStoredProcedure.DeleteAsync(WaitUntil.Completed); + CosmosDBSqlStoredProcedureCreateOrUpdateContent content = new CosmosDBSqlStoredProcedureCreateOrUpdateContent(default, new CosmosDBSqlStoredProcedureResourceInfo("storedProcedureName") + { + Body = "body", + }) + { + Options = new CosmosDBCreateUpdateConfig(), + }; + ArmOperation lro = await cosmosDBSqlStoredProcedure.UpdateAsync(WaitUntil.Completed, content); + CosmosDBSqlStoredProcedureResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlStoredProcedureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlTriggerCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlTriggerCollection.cs index 6df1feb95b786..31ecf9a85f1be 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlTriggerCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlTriggerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBSqlTriggerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBSqlTriggerList() + public async Task CreateOrUpdate_CosmosDBSqlTriggerCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerList.json - // this example is just showing the usage of "SqlResources_ListSqlTriggers" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlTrigger" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBSqlTriggerList() // this example assumes you already have this CosmosDBSqlContainerResource created on azure // for more information of creating CosmosDBSqlContainerResource, please refer to the document of CosmosDBSqlContainerResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string databaseName = "databaseName"; string containerName = "containerName"; @@ -41,17 +41,25 @@ public async Task GetAll_CosmosDBSqlTriggerList() // get the collection of this CosmosDBSqlTriggerResource CosmosDBSqlTriggerCollection collection = cosmosDBSqlContainer.GetCosmosDBSqlTriggers(); - // invoke the operation and iterate over the result - await foreach (CosmosDBSqlTriggerResource item in collection.GetAllAsync()) + // invoke the operation + string triggerName = "triggerName"; + CosmosDBSqlTriggerCreateOrUpdateContent content = new CosmosDBSqlTriggerCreateOrUpdateContent(default, new CosmosDBSqlTriggerResourceInfo("triggerName") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlTriggerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Body = "body", + TriggerType = new CosmosDBSqlTriggerType("triggerType"), + TriggerOperation = new CosmosDBSqlTriggerOperation("triggerOperation"), + }) + { + Options = new CosmosDBCreateUpdateConfig(), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, triggerName, content); + CosmosDBSqlTriggerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +100,10 @@ public async Task Get_CosmosDBSqlTriggerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBSqlTriggerGet() + public async Task GetAll_CosmosDBSqlTriggerList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerGet.json - // this example is just showing the usage of "SqlResources_GetSqlTrigger" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerList.json + // this example is just showing the usage of "SqlResources_ListSqlTriggers" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +123,22 @@ public async Task Exists_CosmosDBSqlTriggerGet() // get the collection of this CosmosDBSqlTriggerResource CosmosDBSqlTriggerCollection collection = cosmosDBSqlContainer.GetCosmosDBSqlTriggers(); - // invoke the operation - string triggerName = "triggerName"; - bool result = await collection.ExistsAsync(triggerName); + // invoke the operation and iterate over the result + await foreach (CosmosDBSqlTriggerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlTriggerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBSqlTriggerGet() + public async Task Exists_CosmosDBSqlTriggerGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerGet.json // this example is just showing the usage of "SqlResources_GetSqlTrigger" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +163,17 @@ public async Task GetIfExists_CosmosDBSqlTriggerGet() // invoke the operation string triggerName = "triggerName"; - NullableResponse response = await collection.GetIfExistsAsync(triggerName); - CosmosDBSqlTriggerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(triggerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBSqlTriggerCreateUpdate() + public async Task GetIfExists_CosmosDBSqlTriggerGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlTrigger" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerGet.json + // this example is just showing the usage of "SqlResources_GetSqlTrigger" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,7 +183,7 @@ public async Task CreateOrUpdate_CosmosDBSqlTriggerCreateUpdate() // this example assumes you already have this CosmosDBSqlContainerResource created on azure // for more information of creating CosmosDBSqlContainerResource, please refer to the document of CosmosDBSqlContainerResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string databaseName = "databaseName"; string containerName = "containerName"; @@ -193,23 +195,21 @@ public async Task CreateOrUpdate_CosmosDBSqlTriggerCreateUpdate() // invoke the operation string triggerName = "triggerName"; - CosmosDBSqlTriggerCreateOrUpdateContent content = new CosmosDBSqlTriggerCreateOrUpdateContent(new AzureLocation("placeholder"), new CosmosDBSqlTriggerResourceInfo("triggerName") + NullableResponse response = await collection.GetIfExistsAsync(triggerName); + CosmosDBSqlTriggerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Body = "body", - TriggerType = new CosmosDBSqlTriggerType("triggerType"), - TriggerOperation = new CosmosDBSqlTriggerOperation("triggerOperation"), - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Options = new CosmosDBCreateUpdateConfig(), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, triggerName, content); - CosmosDBSqlTriggerResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlTriggerResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlTriggerResource.cs index 1506718d3a2b3..57d9f39e0c151 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlTriggerResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlTriggerResource.cs @@ -51,10 +51,10 @@ public async Task Get_CosmosDBSqlTriggerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBSqlTriggerCreateUpdate() + public async Task Delete_CosmosDBSqlTriggerDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlTrigger" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerDelete.json + // this example is just showing the usage of "SqlResources_DeleteSqlTrigger" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,31 +73,17 @@ public async Task Update_CosmosDBSqlTriggerCreateUpdate() CosmosDBSqlTriggerResource cosmosDBSqlTrigger = client.GetCosmosDBSqlTriggerResource(cosmosDBSqlTriggerResourceId); // invoke the operation - CosmosDBSqlTriggerCreateOrUpdateContent content = new CosmosDBSqlTriggerCreateOrUpdateContent(new AzureLocation("placeholder"), new CosmosDBSqlTriggerResourceInfo("triggerName") - { - Body = "body", - TriggerType = new CosmosDBSqlTriggerType("triggerType"), - TriggerOperation = new CosmosDBSqlTriggerOperation("triggerOperation"), - }) - { - Options = new CosmosDBCreateUpdateConfig(), - }; - ArmOperation lro = await cosmosDBSqlTrigger.UpdateAsync(WaitUntil.Completed, content); - CosmosDBSqlTriggerResource result = lro.Value; + await cosmosDBSqlTrigger.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBSqlTriggerDelete() + public async Task Update_CosmosDBSqlTriggerCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerDelete.json - // this example is just showing the usage of "SqlResources_DeleteSqlTrigger" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlTriggerCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlTrigger" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,9 +102,23 @@ public async Task Delete_CosmosDBSqlTriggerDelete() CosmosDBSqlTriggerResource cosmosDBSqlTrigger = client.GetCosmosDBSqlTriggerResource(cosmosDBSqlTriggerResourceId); // invoke the operation - await cosmosDBSqlTrigger.DeleteAsync(WaitUntil.Completed); + CosmosDBSqlTriggerCreateOrUpdateContent content = new CosmosDBSqlTriggerCreateOrUpdateContent(default, new CosmosDBSqlTriggerResourceInfo("triggerName") + { + Body = "body", + TriggerType = new CosmosDBSqlTriggerType("triggerType"), + TriggerOperation = new CosmosDBSqlTriggerOperation("triggerOperation"), + }) + { + Options = new CosmosDBCreateUpdateConfig(), + }; + ArmOperation lro = await cosmosDBSqlTrigger.UpdateAsync(WaitUntil.Completed, content); + CosmosDBSqlTriggerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlUserDefinedFunctionCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlUserDefinedFunctionCollection.cs index f57046c3a1cbd..949a4db5e6011 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlUserDefinedFunctionCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlUserDefinedFunctionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBSqlUserDefinedFunctionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBSqlUserDefinedFunctionList() + public async Task CreateOrUpdate_CosmosDBSqlUserDefinedFunctionCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionList.json - // this example is just showing the usage of "SqlResources_ListSqlUserDefinedFunctions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlUserDefinedFunction" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBSqlUserDefinedFunctionList() // this example assumes you already have this CosmosDBSqlContainerResource created on azure // for more information of creating CosmosDBSqlContainerResource, please refer to the document of CosmosDBSqlContainerResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string databaseName = "databaseName"; string containerName = "containerName"; @@ -41,17 +41,23 @@ public async Task GetAll_CosmosDBSqlUserDefinedFunctionList() // get the collection of this CosmosDBSqlUserDefinedFunctionResource CosmosDBSqlUserDefinedFunctionCollection collection = cosmosDBSqlContainer.GetCosmosDBSqlUserDefinedFunctions(); - // invoke the operation and iterate over the result - await foreach (CosmosDBSqlUserDefinedFunctionResource item in collection.GetAllAsync()) + // invoke the operation + string userDefinedFunctionName = "userDefinedFunctionName"; + CosmosDBSqlUserDefinedFunctionCreateOrUpdateContent content = new CosmosDBSqlUserDefinedFunctionCreateOrUpdateContent(default, new CosmosDBSqlUserDefinedFunctionResourceInfo("userDefinedFunctionName") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlUserDefinedFunctionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Body = "body", + }) + { + Options = new CosmosDBCreateUpdateConfig(), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, userDefinedFunctionName, content); + CosmosDBSqlUserDefinedFunctionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlUserDefinedFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +98,10 @@ public async Task Get_CosmosDBSqlUserDefinedFunctionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBSqlUserDefinedFunctionGet() + public async Task GetAll_CosmosDBSqlUserDefinedFunctionList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionGet.json - // this example is just showing the usage of "SqlResources_GetSqlUserDefinedFunction" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionList.json + // this example is just showing the usage of "SqlResources_ListSqlUserDefinedFunctions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +121,22 @@ public async Task Exists_CosmosDBSqlUserDefinedFunctionGet() // get the collection of this CosmosDBSqlUserDefinedFunctionResource CosmosDBSqlUserDefinedFunctionCollection collection = cosmosDBSqlContainer.GetCosmosDBSqlUserDefinedFunctions(); - // invoke the operation - string userDefinedFunctionName = "userDefinedFunctionName"; - bool result = await collection.ExistsAsync(userDefinedFunctionName); + // invoke the operation and iterate over the result + await foreach (CosmosDBSqlUserDefinedFunctionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlUserDefinedFunctionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBSqlUserDefinedFunctionGet() + public async Task Exists_CosmosDBSqlUserDefinedFunctionGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionGet.json // this example is just showing the usage of "SqlResources_GetSqlUserDefinedFunction" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +161,17 @@ public async Task GetIfExists_CosmosDBSqlUserDefinedFunctionGet() // invoke the operation string userDefinedFunctionName = "userDefinedFunctionName"; - NullableResponse response = await collection.GetIfExistsAsync(userDefinedFunctionName); - CosmosDBSqlUserDefinedFunctionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(userDefinedFunctionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlUserDefinedFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBSqlUserDefinedFunctionCreateUpdate() + public async Task GetIfExists_CosmosDBSqlUserDefinedFunctionGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlUserDefinedFunction" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionGet.json + // this example is just showing the usage of "SqlResources_GetSqlUserDefinedFunction" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,7 +181,7 @@ public async Task CreateOrUpdate_CosmosDBSqlUserDefinedFunctionCreateUpdate() // this example assumes you already have this CosmosDBSqlContainerResource created on azure // for more information of creating CosmosDBSqlContainerResource, please refer to the document of CosmosDBSqlContainerResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string databaseName = "databaseName"; string containerName = "containerName"; @@ -193,21 +193,21 @@ public async Task CreateOrUpdate_CosmosDBSqlUserDefinedFunctionCreateUpdate() // invoke the operation string userDefinedFunctionName = "userDefinedFunctionName"; - CosmosDBSqlUserDefinedFunctionCreateOrUpdateContent content = new CosmosDBSqlUserDefinedFunctionCreateOrUpdateContent(new AzureLocation("placeholder"), new CosmosDBSqlUserDefinedFunctionResourceInfo("userDefinedFunctionName") + NullableResponse response = await collection.GetIfExistsAsync(userDefinedFunctionName); + CosmosDBSqlUserDefinedFunctionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Body = "body", - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Options = new CosmosDBCreateUpdateConfig(), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, userDefinedFunctionName, content); - CosmosDBSqlUserDefinedFunctionResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlUserDefinedFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlUserDefinedFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlUserDefinedFunctionResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlUserDefinedFunctionResource.cs index f60dc3e255763..3b95926aa0466 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlUserDefinedFunctionResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBSqlUserDefinedFunctionResource.cs @@ -51,10 +51,10 @@ public async Task Get_CosmosDBSqlUserDefinedFunctionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBSqlUserDefinedFunctionCreateUpdate() + public async Task Delete_CosmosDBSqlUserDefinedFunctionDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionCreateUpdate.json - // this example is just showing the usage of "SqlResources_CreateUpdateSqlUserDefinedFunction" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionDelete.json + // this example is just showing the usage of "SqlResources_DeleteSqlUserDefinedFunction" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,29 +73,17 @@ public async Task Update_CosmosDBSqlUserDefinedFunctionCreateUpdate() CosmosDBSqlUserDefinedFunctionResource cosmosDBSqlUserDefinedFunction = client.GetCosmosDBSqlUserDefinedFunctionResource(cosmosDBSqlUserDefinedFunctionResourceId); // invoke the operation - CosmosDBSqlUserDefinedFunctionCreateOrUpdateContent content = new CosmosDBSqlUserDefinedFunctionCreateOrUpdateContent(new AzureLocation("placeholder"), new CosmosDBSqlUserDefinedFunctionResourceInfo("userDefinedFunctionName") - { - Body = "body", - }) - { - Options = new CosmosDBCreateUpdateConfig(), - }; - ArmOperation lro = await cosmosDBSqlUserDefinedFunction.UpdateAsync(WaitUntil.Completed, content); - CosmosDBSqlUserDefinedFunctionResource result = lro.Value; + await cosmosDBSqlUserDefinedFunction.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBSqlUserDefinedFunctionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBSqlUserDefinedFunctionDelete() + public async Task Update_CosmosDBSqlUserDefinedFunctionCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionDelete.json - // this example is just showing the usage of "SqlResources_DeleteSqlUserDefinedFunction" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBSqlUserDefinedFunctionCreateUpdate.json + // this example is just showing the usage of "SqlResources_CreateUpdateSqlUserDefinedFunction" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +102,21 @@ public async Task Delete_CosmosDBSqlUserDefinedFunctionDelete() CosmosDBSqlUserDefinedFunctionResource cosmosDBSqlUserDefinedFunction = client.GetCosmosDBSqlUserDefinedFunctionResource(cosmosDBSqlUserDefinedFunctionResourceId); // invoke the operation - await cosmosDBSqlUserDefinedFunction.DeleteAsync(WaitUntil.Completed); + CosmosDBSqlUserDefinedFunctionCreateOrUpdateContent content = new CosmosDBSqlUserDefinedFunctionCreateOrUpdateContent(default, new CosmosDBSqlUserDefinedFunctionResourceInfo("userDefinedFunctionName") + { + Body = "body", + }) + { + Options = new CosmosDBCreateUpdateConfig(), + }; + ArmOperation lro = await cosmosDBSqlUserDefinedFunction.UpdateAsync(WaitUntil.Completed, content); + CosmosDBSqlUserDefinedFunctionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBSqlUserDefinedFunctionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBTableCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBTableCollection.cs index 7d3a771d50b4d..646a4d544bfc5 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBTableCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBTableCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBTableCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBTableList() + public async Task CreateOrUpdate_CosmosDBTableReplace() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableList.json - // this example is just showing the usage of "TableResources_ListTables" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableCreateUpdate.json + // this example is just showing the usage of "TableResources_CreateUpdateTable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBTableList() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -39,17 +39,21 @@ public async Task GetAll_CosmosDBTableList() // get the collection of this CosmosDBTableResource CosmosDBTableCollection collection = cosmosDBAccount.GetCosmosDBTables(); - // invoke the operation and iterate over the result - await foreach (CosmosDBTableResource item in collection.GetAllAsync()) + // invoke the operation + string tableName = "tableName"; + CosmosDBTableCreateOrUpdateContent content = new CosmosDBTableCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBTableResourceInfo("tableName")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBTableData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tableName, content); + CosmosDBTableResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_CosmosDBTableGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBTableGet() + public async Task GetAll_CosmosDBTableList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableGet.json - // this example is just showing the usage of "TableResources_GetTable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableList.json + // this example is just showing the usage of "TableResources_ListTables" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +105,7 @@ public async Task Exists_CosmosDBTableGet() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -109,16 +113,22 @@ public async Task Exists_CosmosDBTableGet() // get the collection of this CosmosDBTableResource CosmosDBTableCollection collection = cosmosDBAccount.GetCosmosDBTables(); - // invoke the operation - string tableName = "tableName"; - bool result = await collection.ExistsAsync(tableName); + // invoke the operation and iterate over the result + await foreach (CosmosDBTableResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBTableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBTableGet() + public async Task Exists_CosmosDBTableGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableGet.json // this example is just showing the usage of "TableResources_GetTable" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_CosmosDBTableGet() // invoke the operation string tableName = "tableName"; - NullableResponse response = await collection.GetIfExistsAsync(tableName); - CosmosDBTableResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tableName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBTableReplace() + public async Task GetIfExists_CosmosDBTableGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableCreateUpdate.json - // this example is just showing the usage of "TableResources_CreateUpdateTable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableGet.json + // this example is just showing the usage of "TableResources_GetTable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,21 +181,21 @@ public async Task CreateOrUpdate_CosmosDBTableReplace() // invoke the operation string tableName = "tableName"; - CosmosDBTableCreateOrUpdateContent content = new CosmosDBTableCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBTableResourceInfo("tableName")) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tableName, content); - CosmosDBTableResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(tableName); + CosmosDBTableResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBTableResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBTableResource.cs index 86e7e8ad853ad..048f4f78ee5c8 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBTableResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBTableResource.cs @@ -49,10 +49,10 @@ public async Task Get_CosmosDBTableGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBTableReplace() + public async Task Delete_CosmosDBTableDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableCreateUpdate.json - // this example is just showing the usage of "TableResources_CreateUpdateTable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableDelete.json + // this example is just showing the usage of "TableResources_DeleteTable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_CosmosDBTableReplace() CosmosDBTableResource cosmosDBTable = client.GetCosmosDBTableResource(cosmosDBTableResourceId); // invoke the operation - CosmosDBTableCreateOrUpdateContent content = new CosmosDBTableCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBTableResourceInfo("tableName")) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await cosmosDBTable.UpdateAsync(WaitUntil.Completed, content); - CosmosDBTableResource result = lro.Value; + await cosmosDBTable.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBTableDelete() + public async Task Update_CosmosDBTableReplace() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableDelete.json - // this example is just showing the usage of "TableResources_DeleteTable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBTableCreateUpdate.json + // this example is just showing the usage of "TableResources_CreateUpdateTable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,19 @@ public async Task Delete_CosmosDBTableDelete() CosmosDBTableResource cosmosDBTable = client.GetCosmosDBTableResource(cosmosDBTableResourceId); // invoke the operation - await cosmosDBTable.DeleteAsync(WaitUntil.Completed); + CosmosDBTableCreateOrUpdateContent content = new CosmosDBTableCreateOrUpdateContent(new AzureLocation("West US"), new CosmosDBTableResourceInfo("tableName")) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await cosmosDBTable.UpdateAsync(WaitUntil.Completed, content); + CosmosDBTableResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -135,7 +133,7 @@ public async Task RetrieveContinuousBackupInformation_CosmosDBTableCollectionBac CosmosDBTableResource cosmosDBTable = client.GetCosmosDBTableResource(cosmosDBTableResourceId); // invoke the operation - ContinuousBackupRestoreLocation location = new ContinuousBackupRestoreLocation() + ContinuousBackupRestoreLocation location = new ContinuousBackupRestoreLocation { Location = new AzureLocation("North Europe"), }; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolAccountCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolAccountCollection.cs index fafbddbce7a6f..5f98332d2ca66 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolAccountCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolAccountCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CosmosDBThroughputPoolAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBThroughputPoolAccountList() + public async Task CreateOrUpdate_CosmosDBThroughputPoolAccountCreate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountsList.json - // this example is just showing the usage of "ThroughputPoolAccounts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountCreate.json + // this example is just showing the usage of "ThroughputPoolAccount_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task GetAll_CosmosDBThroughputPoolAccountList() // this example assumes you already have this CosmosDBThroughputPoolResource created on azure // for more information of creating CosmosDBThroughputPoolResource, please refer to the document of CosmosDBThroughputPoolResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string throughputPoolName = "tp1"; ResourceIdentifier cosmosDBThroughputPoolResourceId = CosmosDBThroughputPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, throughputPoolName); CosmosDBThroughputPoolResource cosmosDBThroughputPool = client.GetCosmosDBThroughputPoolResource(cosmosDBThroughputPoolResourceId); @@ -38,17 +38,21 @@ public async Task GetAll_CosmosDBThroughputPoolAccountList() // get the collection of this CosmosDBThroughputPoolAccountResource CosmosDBThroughputPoolAccountCollection collection = cosmosDBThroughputPool.GetCosmosDBThroughputPoolAccounts(); - // invoke the operation and iterate over the result - await foreach (CosmosDBThroughputPoolAccountResource item in collection.GetAllAsync()) + // invoke the operation + string throughputPoolAccountName = "db1"; + CosmosDBThroughputPoolAccountData data = new CosmosDBThroughputPoolAccountData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBThroughputPoolAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AccountResourceIdentifier = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DocumentDB/resourceGroup/rg1/databaseAccounts/db1/"), + AccountLocation = new AzureLocation("West US"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, throughputPoolAccountName, data); + CosmosDBThroughputPoolAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBThroughputPoolAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_CosmosDBThroughputPoolAccountGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBThroughputPoolAccountGet() + public async Task GetAll_CosmosDBThroughputPoolAccountList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountGet.json - // this example is just showing the usage of "ThroughputPoolAccount_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountsList.json + // this example is just showing the usage of "ThroughputPoolAccounts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_CosmosDBThroughputPoolAccountGet() // get the collection of this CosmosDBThroughputPoolAccountResource CosmosDBThroughputPoolAccountCollection collection = cosmosDBThroughputPool.GetCosmosDBThroughputPoolAccounts(); - // invoke the operation - string throughputPoolAccountName = "db1"; - bool result = await collection.ExistsAsync(throughputPoolAccountName); + // invoke the operation and iterate over the result + await foreach (CosmosDBThroughputPoolAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBThroughputPoolAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBThroughputPoolAccountGet() + public async Task Exists_CosmosDBThroughputPoolAccountGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountGet.json // this example is just showing the usage of "ThroughputPoolAccount_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_CosmosDBThroughputPoolAccountGet() // invoke the operation string throughputPoolAccountName = "db1"; - NullableResponse response = await collection.GetIfExistsAsync(throughputPoolAccountName); - CosmosDBThroughputPoolAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(throughputPoolAccountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBThroughputPoolAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBThroughputPoolAccountCreate() + public async Task GetIfExists_CosmosDBThroughputPoolAccountGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountCreate.json - // this example is just showing the usage of "ThroughputPoolAccount_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountGet.json + // this example is just showing the usage of "ThroughputPoolAccount_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,7 +170,7 @@ public async Task CreateOrUpdate_CosmosDBThroughputPoolAccountCreate() // this example assumes you already have this CosmosDBThroughputPoolResource created on azure // for more information of creating CosmosDBThroughputPoolResource, please refer to the document of CosmosDBThroughputPoolResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string throughputPoolName = "tp1"; ResourceIdentifier cosmosDBThroughputPoolResourceId = CosmosDBThroughputPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, throughputPoolName); CosmosDBThroughputPoolResource cosmosDBThroughputPool = client.GetCosmosDBThroughputPoolResource(cosmosDBThroughputPoolResourceId); @@ -182,19 +180,21 @@ public async Task CreateOrUpdate_CosmosDBThroughputPoolAccountCreate() // invoke the operation string throughputPoolAccountName = "db1"; - CosmosDBThroughputPoolAccountData data = new CosmosDBThroughputPoolAccountData() - { - AccountResourceIdentifier = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DocumentDB/resourceGroup/rg1/databaseAccounts/db1/"), - AccountLocation = new AzureLocation("West US"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, throughputPoolAccountName, data); - CosmosDBThroughputPoolAccountResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(throughputPoolAccountName); + CosmosDBThroughputPoolAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBThroughputPoolAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBThroughputPoolAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolAccountResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolAccountResource.cs index 822a0f1b9a50b..b483f9d235890 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolAccountResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolAccountResource.cs @@ -48,10 +48,10 @@ public async Task Get_CosmosDBThroughputPoolAccountGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBThroughputPoolAccountCreate() + public async Task Delete_CosmosDBThroughputPoolAccountDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountCreate.json - // this example is just showing the usage of "ThroughputPoolAccount_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountDelete.json + // this example is just showing the usage of "ThroughputPoolAccount_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,34 +61,24 @@ public async Task Update_CosmosDBThroughputPoolAccountCreate() // this example assumes you already have this CosmosDBThroughputPoolAccountResource created on azure // for more information of creating CosmosDBThroughputPoolAccountResource, please refer to the document of CosmosDBThroughputPoolAccountResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string throughputPoolName = "tp1"; string throughputPoolAccountName = "db1"; ResourceIdentifier cosmosDBThroughputPoolAccountResourceId = CosmosDBThroughputPoolAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, throughputPoolName, throughputPoolAccountName); CosmosDBThroughputPoolAccountResource cosmosDBThroughputPoolAccount = client.GetCosmosDBThroughputPoolAccountResource(cosmosDBThroughputPoolAccountResourceId); // invoke the operation - CosmosDBThroughputPoolAccountData data = new CosmosDBThroughputPoolAccountData() - { - AccountResourceIdentifier = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DocumentDB/resourceGroup/rg1/databaseAccounts/db1/"), - AccountLocation = new AzureLocation("West US"), - }; - ArmOperation lro = await cosmosDBThroughputPoolAccount.UpdateAsync(WaitUntil.Completed, data); - CosmosDBThroughputPoolAccountResource result = lro.Value; + await cosmosDBThroughputPoolAccount.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBThroughputPoolAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBThroughputPoolAccountDelete() + public async Task Update_CosmosDBThroughputPoolAccountCreate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountDelete.json - // this example is just showing the usage of "ThroughputPoolAccount_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolAccountCreate.json + // this example is just showing the usage of "ThroughputPoolAccount_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,16 +88,26 @@ public async Task Delete_CosmosDBThroughputPoolAccountDelete() // this example assumes you already have this CosmosDBThroughputPoolAccountResource created on azure // for more information of creating CosmosDBThroughputPoolAccountResource, please refer to the document of CosmosDBThroughputPoolAccountResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string throughputPoolName = "tp1"; string throughputPoolAccountName = "db1"; ResourceIdentifier cosmosDBThroughputPoolAccountResourceId = CosmosDBThroughputPoolAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, throughputPoolName, throughputPoolAccountName); CosmosDBThroughputPoolAccountResource cosmosDBThroughputPoolAccount = client.GetCosmosDBThroughputPoolAccountResource(cosmosDBThroughputPoolAccountResourceId); // invoke the operation - await cosmosDBThroughputPoolAccount.DeleteAsync(WaitUntil.Completed); + CosmosDBThroughputPoolAccountData data = new CosmosDBThroughputPoolAccountData + { + AccountResourceIdentifier = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/providers/Microsoft.DocumentDB/resourceGroup/rg1/databaseAccounts/db1/"), + AccountLocation = new AzureLocation("West US"), + }; + ArmOperation lro = await cosmosDBThroughputPoolAccount.UpdateAsync(WaitUntil.Completed, data); + CosmosDBThroughputPoolAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBThroughputPoolAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolCollection.cs index c9df7e4ebcd8e..e1a8cb3ccde49 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBThroughputPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBThroughputPoolListByResourceGroup() + public async Task CreateOrUpdate_CosmosDBThroughputPoolCreate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolList.json - // this example is just showing the usage of "ThroughputPools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolCreate.json + // this example is just showing the usage of "ThroughputPool_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,24 +31,28 @@ public async Task GetAll_CosmosDBThroughputPoolListByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this CosmosDBThroughputPoolResource CosmosDBThroughputPoolCollection collection = resourceGroupResource.GetCosmosDBThroughputPools(); - // invoke the operation and iterate over the result - await foreach (CosmosDBThroughputPoolResource item in collection.GetAllAsync()) + // invoke the operation + string throughputPoolName = "tp1"; + CosmosDBThroughputPoolData data = new CosmosDBThroughputPoolData(new AzureLocation("westus2")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBThroughputPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + MaxThroughput = 10000, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, throughputPoolName, data); + CosmosDBThroughputPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBThroughputPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +90,10 @@ public async Task Get_CosmosDBThroughputPoolGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBThroughputPoolGet() + public async Task GetAll_CosmosDBThroughputPoolListByResourceGroup() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolGet.json - // this example is just showing the usage of "ThroughputPool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolList.json + // this example is just showing the usage of "ThroughputPools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +110,22 @@ public async Task Exists_CosmosDBThroughputPoolGet() // get the collection of this CosmosDBThroughputPoolResource CosmosDBThroughputPoolCollection collection = resourceGroupResource.GetCosmosDBThroughputPools(); - // invoke the operation - string throughputPoolName = "tp1"; - bool result = await collection.ExistsAsync(throughputPoolName); + // invoke the operation and iterate over the result + await foreach (CosmosDBThroughputPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBThroughputPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBThroughputPoolGet() + public async Task Exists_CosmosDBThroughputPoolGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolGet.json // this example is just showing the usage of "ThroughputPool_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +147,17 @@ public async Task GetIfExists_CosmosDBThroughputPoolGet() // invoke the operation string throughputPoolName = "tp1"; - NullableResponse response = await collection.GetIfExistsAsync(throughputPoolName); - CosmosDBThroughputPoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(throughputPoolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBThroughputPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBThroughputPoolCreate() + public async Task GetIfExists_CosmosDBThroughputPoolGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolCreate.json - // this example is just showing the usage of "ThroughputPool_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolGet.json + // this example is just showing the usage of "ThroughputPool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -169,7 +167,7 @@ public async Task CreateOrUpdate_CosmosDBThroughputPoolCreate() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -178,21 +176,21 @@ public async Task CreateOrUpdate_CosmosDBThroughputPoolCreate() // invoke the operation string throughputPoolName = "tp1"; - CosmosDBThroughputPoolData data = new CosmosDBThroughputPoolData(new AzureLocation("westus2")) - { - MaxThroughput = 10000, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, throughputPoolName, data); - CosmosDBThroughputPoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(throughputPoolName); + CosmosDBThroughputPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBThroughputPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBThroughputPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolResource.cs index f4d368c4b3719..b3df2c48cbff8 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosDBThroughputPoolResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.CosmosDB.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CosmosDB.Samples { public partial class Sample_CosmosDBThroughputPoolResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCosmosDBThroughputPools_CosmosDBThroughputPoolList() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolList.json - // this example is just showing the usage of "ThroughputPools_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CosmosDBThroughputPoolResource item in subscriptionResource.GetCosmosDBThroughputPoolsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBThroughputPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_CosmosDBThroughputPoolGet() @@ -80,10 +48,10 @@ public async Task Get_CosmosDBThroughputPoolGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBThroughputPoolUpdate() + public async Task Delete_CosmosDBThroughputPoolDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolUpdate.json - // this example is just showing the usage of "ThroughputPool_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolDelete.json + // this example is just showing the usage of "ThroughputPool_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,32 +61,23 @@ public async Task Update_CosmosDBThroughputPoolUpdate() // this example assumes you already have this CosmosDBThroughputPoolResource created on azure // for more information of creating CosmosDBThroughputPoolResource, please refer to the document of CosmosDBThroughputPoolResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string throughputPoolName = "tp1"; ResourceIdentifier cosmosDBThroughputPoolResourceId = CosmosDBThroughputPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, throughputPoolName); CosmosDBThroughputPoolResource cosmosDBThroughputPool = client.GetCosmosDBThroughputPoolResource(cosmosDBThroughputPoolResourceId); // invoke the operation - CosmosDBThroughputPoolPatch patch = new CosmosDBThroughputPoolPatch() - { - MaxThroughput = 10000, - }; - ArmOperation lro = await cosmosDBThroughputPool.UpdateAsync(WaitUntil.Completed, patch); - CosmosDBThroughputPoolResource result = lro.Value; + await cosmosDBThroughputPool.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBThroughputPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBThroughputPoolDelete() + public async Task Update_CosmosDBThroughputPoolUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolDelete.json - // this example is just showing the usage of "ThroughputPool_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolUpdate.json + // this example is just showing the usage of "ThroughputPool_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -128,15 +87,24 @@ public async Task Delete_CosmosDBThroughputPoolDelete() // this example assumes you already have this CosmosDBThroughputPoolResource created on azure // for more information of creating CosmosDBThroughputPoolResource, please refer to the document of CosmosDBThroughputPoolResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string throughputPoolName = "tp1"; ResourceIdentifier cosmosDBThroughputPoolResourceId = CosmosDBThroughputPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, throughputPoolName); CosmosDBThroughputPoolResource cosmosDBThroughputPool = client.GetCosmosDBThroughputPoolResource(cosmosDBThroughputPoolResourceId); // invoke the operation - await cosmosDBThroughputPool.DeleteAsync(WaitUntil.Completed); + CosmosDBThroughputPoolPatch patch = new CosmosDBThroughputPoolPatch + { + MaxThroughput = 10000, + }; + ArmOperation lro = await cosmosDBThroughputPool.UpdateAsync(WaitUntil.Completed, patch); + CosmosDBThroughputPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBThroughputPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosTableThroughputSettingResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosTableThroughputSettingResource.cs index 73bc14fc1ac16..d272f90a65c0b 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosTableThroughputSettingResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_CosmosTableThroughputSettingResource.cs @@ -69,14 +69,12 @@ public async Task CreateOrUpdate_CosmosDBTableThroughputUpdate() CosmosTableThroughputSettingResource cosmosTableThroughputSetting = client.GetCosmosTableThroughputSettingResource(cosmosTableThroughputSettingResourceId); // invoke the operation - ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo() + ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo { Throughput = 400, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await cosmosTableThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); CosmosTableThroughputSettingResource result = lro.Value; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_DataTransferJobGetResultCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_DataTransferJobGetResultCollection.cs index 5bb89b8412a72..98f8c224125eb 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_DataTransferJobGetResultCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_DataTransferJobGetResultCollection.cs @@ -91,10 +91,10 @@ public async Task Get_CosmosDBDataTransferJobGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBDataTransferJobGet() + public async Task GetAll_CosmosDBDataTransferJobFeed() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/data-transfer-service/CosmosDBDataTransferJobGet.json - // this example is just showing the usage of "DataTransferJobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/data-transfer-service/CosmosDBDataTransferJobFeed.json + // this example is just showing the usage of "DataTransferJobs_ListByDatabaseAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_CosmosDBDataTransferJobGet() // get the collection of this DataTransferJobGetResultResource DataTransferJobGetResultCollection collection = cosmosDBAccount.GetDataTransferJobGetResults(); - // invoke the operation - string jobName = "j1"; - bool result = await collection.ExistsAsync(jobName); + // invoke the operation and iterate over the result + await foreach (DataTransferJobGetResultResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataTransferJobGetResultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBDataTransferJobGet() + public async Task Exists_CosmosDBDataTransferJobGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/data-transfer-service/CosmosDBDataTransferJobGet.json // this example is just showing the usage of "DataTransferJobs_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_CosmosDBDataTransferJobGet() // invoke the operation string jobName = "j1"; - NullableResponse response = await collection.GetIfExistsAsync(jobName); - DataTransferJobGetResultResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(jobName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataTransferJobGetResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBDataTransferJobFeed() + public async Task GetIfExists_CosmosDBDataTransferJobGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/data-transfer-service/CosmosDBDataTransferJobFeed.json - // this example is just showing the usage of "DataTransferJobs_ListByDatabaseAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/data-transfer-service/CosmosDBDataTransferJobGet.json + // this example is just showing the usage of "DataTransferJobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_CosmosDBDataTransferJobFeed() // get the collection of this DataTransferJobGetResultResource DataTransferJobGetResultCollection collection = cosmosDBAccount.GetDataTransferJobGetResults(); - // invoke the operation and iterate over the result - await foreach (DataTransferJobGetResultResource item in collection.GetAllAsync()) + // invoke the operation + string jobName = "j1"; + NullableResponse response = await collection.GetIfExistsAsync(jobName); + DataTransferJobGetResultResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataTransferJobGetResultData resourceData = item.Data; + DataTransferJobGetResultData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_DataTransferJobGetResultResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_DataTransferJobGetResultResource.cs index d3f9a09c9fe4e..6c09ee67165de 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_DataTransferJobGetResultResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_DataTransferJobGetResultResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DataTransferJobGetResultResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBDataTransferJobCreate() + public async Task Get_CosmosDBDataTransferJobGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/data-transfer-service/CosmosDBDataTransferJobCreate.json - // this example is just showing the usage of "DataTransferJobs_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/data-transfer-service/CosmosDBDataTransferJobGet.json + // this example is just showing the usage of "DataTransferJobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,12 +38,7 @@ public async Task Update_CosmosDBDataTransferJobCreate() DataTransferJobGetResultResource dataTransferJobGetResult = client.GetDataTransferJobGetResultResource(dataTransferJobGetResultResourceId); // invoke the operation - DataTransferJobGetResultCreateOrUpdateContent content = new DataTransferJobGetResultCreateOrUpdateContent(new DataTransferJobProperties(new CosmosCassandraDataTransferDataSourceSink("keyspace", "table"), new AzureBlobDataTransferDataSourceSink("blob_container") - { - EndpointUri = new Uri("https://blob.windows.net"), - })); - ArmOperation lro = await dataTransferJobGetResult.UpdateAsync(WaitUntil.Completed, content); - DataTransferJobGetResultResource result = lro.Value; + DataTransferJobGetResultResource result = await dataTransferJobGetResult.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +49,10 @@ public async Task Update_CosmosDBDataTransferJobCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBDataTransferJobGet() + public async Task Update_CosmosDBDataTransferJobCreate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/data-transfer-service/CosmosDBDataTransferJobGet.json - // this example is just showing the usage of "DataTransferJobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/data-transfer-service/CosmosDBDataTransferJobCreate.json + // this example is just showing the usage of "DataTransferJobs_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,7 +69,12 @@ public async Task Get_CosmosDBDataTransferJobGet() DataTransferJobGetResultResource dataTransferJobGetResult = client.GetDataTransferJobGetResultResource(dataTransferJobGetResultResourceId); // invoke the operation - DataTransferJobGetResultResource result = await dataTransferJobGetResult.GetAsync(); + DataTransferJobGetResultCreateOrUpdateContent content = new DataTransferJobGetResultCreateOrUpdateContent(new DataTransferJobProperties(new CosmosCassandraDataTransferDataSourceSink("keyspace", "table"), new AzureBlobDataTransferDataSourceSink("blob_container") + { + EndpointUri = new Uri("https://blob.windows.net"), + })); + ArmOperation lro = await dataTransferJobGetResult.UpdateAsync(WaitUntil.Completed, content); + DataTransferJobGetResultResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GraphResourceGetResultCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GraphResourceGetResultCollection.cs index 8738c9f70b1ce..598413ce69623 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GraphResourceGetResultCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GraphResourceGetResultCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_GraphResourceGetResultCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBSqlDatabaseList() + public async Task CreateOrUpdate_CosmosDBGraphCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceList.json - // this example is just showing the usage of "GraphResources_ListGraphs" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceCreateUpdate.json + // this example is just showing the usage of "GraphResources_CreateUpdateGraph" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task GetAll_CosmosDBSqlDatabaseList() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -40,17 +40,24 @@ public async Task GetAll_CosmosDBSqlDatabaseList() // get the collection of this GraphResourceGetResultResource GraphResourceGetResultCollection collection = cosmosDBAccount.GetGraphResourceGetResults(); - // invoke the operation and iterate over the result - await foreach (GraphResourceGetResultResource item in collection.GetAllAsync()) + // invoke the operation + string graphName = "graphName"; + GraphResourceGetResultCreateOrUpdateContent content = new GraphResourceGetResultCreateOrUpdateContent(new AzureLocation("West US"), new WritableSubResource { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GraphResourceGetResultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Id = new ResourceIdentifier("graphName"), + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, graphName, content); + GraphResourceGetResultResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GraphResourceGetResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +96,10 @@ public async Task Get_CosmosDBSqlDatabaseGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBSqlDatabaseGet() + public async Task GetAll_CosmosDBSqlDatabaseList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceGet.json - // this example is just showing the usage of "GraphResources_GetGraph" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceList.json + // this example is just showing the usage of "GraphResources_ListGraphs" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,7 +109,7 @@ public async Task Exists_CosmosDBSqlDatabaseGet() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -110,16 +117,22 @@ public async Task Exists_CosmosDBSqlDatabaseGet() // get the collection of this GraphResourceGetResultResource GraphResourceGetResultCollection collection = cosmosDBAccount.GetGraphResourceGetResults(); - // invoke the operation - string graphName = "graphName"; - bool result = await collection.ExistsAsync(graphName); + // invoke the operation and iterate over the result + await foreach (GraphResourceGetResultResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GraphResourceGetResultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBSqlDatabaseGet() + public async Task Exists_CosmosDBSqlDatabaseGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceGet.json // this example is just showing the usage of "GraphResources_GetGraph" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +155,17 @@ public async Task GetIfExists_CosmosDBSqlDatabaseGet() // invoke the operation string graphName = "graphName"; - NullableResponse response = await collection.GetIfExistsAsync(graphName); - GraphResourceGetResultResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(graphName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GraphResourceGetResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBGraphCreateUpdate() + public async Task GetIfExists_CosmosDBSqlDatabaseGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceCreateUpdate.json - // this example is just showing the usage of "GraphResources_CreateUpdateGraph" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceGet.json + // this example is just showing the usage of "GraphResources_GetGraph" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,24 +185,21 @@ public async Task CreateOrUpdate_CosmosDBGraphCreateUpdate() // invoke the operation string graphName = "graphName"; - GraphResourceGetResultCreateOrUpdateContent content = new GraphResourceGetResultCreateOrUpdateContent(new AzureLocation("West US"), new WritableSubResource() + NullableResponse response = await collection.GetIfExistsAsync(graphName); + GraphResourceGetResultResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Id = new ResourceIdentifier("graphName"), - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, graphName, content); - GraphResourceGetResultResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GraphResourceGetResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GraphResourceGetResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GraphResourceGetResultResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GraphResourceGetResultResource.cs index 7b67698949de3..70870668abbbd 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GraphResourceGetResultResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GraphResourceGetResultResource.cs @@ -50,10 +50,10 @@ public async Task Get_CosmosDBSqlDatabaseGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBGraphCreateUpdate() + public async Task Delete_CosmosDBSqlDatabaseDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceCreateUpdate.json - // this example is just showing the usage of "GraphResources_CreateUpdateGraph" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceDelete.json + // this example is just showing the usage of "GraphResources_DeleteGraphResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,32 +70,17 @@ public async Task Update_CosmosDBGraphCreateUpdate() GraphResourceGetResultResource graphResourceGetResult = client.GetGraphResourceGetResultResource(graphResourceGetResultResourceId); // invoke the operation - GraphResourceGetResultCreateOrUpdateContent content = new GraphResourceGetResultCreateOrUpdateContent(new AzureLocation("West US"), new WritableSubResource() - { - Id = new ResourceIdentifier("graphName"), - }) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await graphResourceGetResult.UpdateAsync(WaitUntil.Completed, content); - GraphResourceGetResultResource result = lro.Value; + await graphResourceGetResult.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GraphResourceGetResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBSqlDatabaseDelete() + public async Task Update_CosmosDBGraphCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceDelete.json - // this example is just showing the usage of "GraphResources_DeleteGraphResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGraphResourceCreateUpdate.json + // this example is just showing the usage of "GraphResources_CreateUpdateGraph" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,9 +97,22 @@ public async Task Delete_CosmosDBSqlDatabaseDelete() GraphResourceGetResultResource graphResourceGetResult = client.GetGraphResourceGetResultResource(graphResourceGetResultResourceId); // invoke the operation - await graphResourceGetResult.DeleteAsync(WaitUntil.Completed); + GraphResourceGetResultCreateOrUpdateContent content = new GraphResourceGetResultCreateOrUpdateContent(new AzureLocation("West US"), new WritableSubResource + { + Id = new ResourceIdentifier("graphName"), + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await graphResourceGetResult.UpdateAsync(WaitUntil.Completed, content); + GraphResourceGetResultResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GraphResourceGetResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseCollection.cs index 4620e5d97a85b..b51f573379adf 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_GremlinDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBGremlinDatabaseList() + public async Task CreateOrUpdate_CosmosDBGremlinDatabaseCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseList.json - // this example is just showing the usage of "GremlinResources_ListGremlinDatabases" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseCreateUpdate.json + // this example is just showing the usage of "GremlinResources_CreateUpdateGremlinDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBGremlinDatabaseList() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -39,17 +39,21 @@ public async Task GetAll_CosmosDBGremlinDatabaseList() // get the collection of this GremlinDatabaseResource GremlinDatabaseCollection collection = cosmosDBAccount.GetGremlinDatabases(); - // invoke the operation and iterate over the result - await foreach (GremlinDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "databaseName"; + GremlinDatabaseCreateOrUpdateContent content = new GremlinDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new GremlinDatabaseResourceInfo("databaseName")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GremlinDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, content); + GremlinDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GremlinDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_CosmosDBGremlinDatabaseGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBGremlinDatabaseGet() + public async Task GetAll_CosmosDBGremlinDatabaseList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseGet.json - // this example is just showing the usage of "GremlinResources_GetGremlinDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseList.json + // this example is just showing the usage of "GremlinResources_ListGremlinDatabases" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +105,7 @@ public async Task Exists_CosmosDBGremlinDatabaseGet() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -109,16 +113,22 @@ public async Task Exists_CosmosDBGremlinDatabaseGet() // get the collection of this GremlinDatabaseResource GremlinDatabaseCollection collection = cosmosDBAccount.GetGremlinDatabases(); - // invoke the operation - string databaseName = "databaseName"; - bool result = await collection.ExistsAsync(databaseName); + // invoke the operation and iterate over the result + await foreach (GremlinDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GremlinDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBGremlinDatabaseGet() + public async Task Exists_CosmosDBGremlinDatabaseGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseGet.json // this example is just showing the usage of "GremlinResources_GetGremlinDatabase" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_CosmosDBGremlinDatabaseGet() // invoke the operation string databaseName = "databaseName"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - GremlinDatabaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(databaseName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GremlinDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBGremlinDatabaseCreateUpdate() + public async Task GetIfExists_CosmosDBGremlinDatabaseGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseCreateUpdate.json - // this example is just showing the usage of "GremlinResources_CreateUpdateGremlinDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseGet.json + // this example is just showing the usage of "GremlinResources_GetGremlinDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,21 +181,21 @@ public async Task CreateOrUpdate_CosmosDBGremlinDatabaseCreateUpdate() // invoke the operation string databaseName = "databaseName"; - GremlinDatabaseCreateOrUpdateContent content = new GremlinDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new GremlinDatabaseResourceInfo("databaseName")) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, content); - GremlinDatabaseResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + GremlinDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GremlinDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GremlinDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseResource.cs index a586dfe91e365..0cba1b357e541 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseResource.cs @@ -49,10 +49,10 @@ public async Task Get_CosmosDBGremlinDatabaseGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBGremlinDatabaseCreateUpdate() + public async Task Delete_CosmosDBGremlinDatabaseDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseCreateUpdate.json - // this example is just showing the usage of "GremlinResources_CreateUpdateGremlinDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseDelete.json + // this example is just showing the usage of "GremlinResources_DeleteGremlinDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_CosmosDBGremlinDatabaseCreateUpdate() GremlinDatabaseResource gremlinDatabase = client.GetGremlinDatabaseResource(gremlinDatabaseResourceId); // invoke the operation - GremlinDatabaseCreateOrUpdateContent content = new GremlinDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new GremlinDatabaseResourceInfo("databaseName")) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await gremlinDatabase.UpdateAsync(WaitUntil.Completed, content); - GremlinDatabaseResource result = lro.Value; + await gremlinDatabase.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GremlinDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBGremlinDatabaseDelete() + public async Task Update_CosmosDBGremlinDatabaseCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseDelete.json - // this example is just showing the usage of "GremlinResources_DeleteGremlinDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinDatabaseCreateUpdate.json + // this example is just showing the usage of "GremlinResources_CreateUpdateGremlinDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,19 @@ public async Task Delete_CosmosDBGremlinDatabaseDelete() GremlinDatabaseResource gremlinDatabase = client.GetGremlinDatabaseResource(gremlinDatabaseResourceId); // invoke the operation - await gremlinDatabase.DeleteAsync(WaitUntil.Completed); + GremlinDatabaseCreateOrUpdateContent content = new GremlinDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new GremlinDatabaseResourceInfo("databaseName")) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await gremlinDatabase.UpdateAsync(WaitUntil.Completed, content); + GremlinDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GremlinDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseThroughputSettingResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseThroughputSettingResource.cs index 02fdf53ad2447..770bbcb300085 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseThroughputSettingResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinDatabaseThroughputSettingResource.cs @@ -69,14 +69,12 @@ public async Task CreateOrUpdate_CosmosDBGremlinDatabaseThroughputUpdate() GremlinDatabaseThroughputSettingResource gremlinDatabaseThroughputSetting = client.GetGremlinDatabaseThroughputSettingResource(gremlinDatabaseThroughputSettingResourceId); // invoke the operation - ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo() + ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo { Throughput = 400, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await gremlinDatabaseThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); GremlinDatabaseThroughputSettingResource result = lro.Value; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphCollection.cs index b871af3dc211f..4cbba86d2fd1f 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_GremlinGraphCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBGremlinGraphList() + public async Task CreateOrUpdate_CosmosDBGremlinGraphCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinGraphList.json - // this example is just showing the usage of "GremlinResources_ListGremlinGraphs" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinGraphCreateUpdate.json + // this example is just showing the usage of "GremlinResources_CreateUpdateGremlinGraph" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBGremlinGraphList() // this example assumes you already have this GremlinDatabaseResource created on azure // for more information of creating GremlinDatabaseResource, please refer to the document of GremlinDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier gremlinDatabaseResourceId = GremlinDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -40,17 +40,59 @@ public async Task GetAll_CosmosDBGremlinGraphList() // get the collection of this GremlinGraphResource GremlinGraphCollection collection = gremlinDatabase.GetGremlinGraphs(); - // invoke the operation and iterate over the result - await foreach (GremlinGraphResource item in collection.GetAllAsync()) + // invoke the operation + string graphName = "graphName"; + GremlinGraphCreateOrUpdateContent content = new GremlinGraphCreateOrUpdateContent(new AzureLocation("West US"), new GremlinGraphResourceInfo("graphName") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GremlinGraphData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IndexingPolicy = new CosmosDBIndexingPolicy + { + IsAutomatic = true, + IndexingMode = CosmosDBIndexingMode.Consistent, + IncludedPaths = {new CosmosDBIncludedPath +{ +Path = "/*", +Indexes = {new CosmosDBPathIndexes +{ +DataType = CosmosDBDataType.String, +Precision = -1, +Kind = CosmosDBIndexKind.Range, +}, new CosmosDBPathIndexes +{ +DataType = CosmosDBDataType.Number, +Precision = -1, +Kind = CosmosDBIndexKind.Range, +}}, +}}, + ExcludedPaths = { }, + }, + PartitionKey = new CosmosDBContainerPartitionKey + { + Paths = { "/AccountNumber" }, + Kind = CosmosDBPartitionKind.Hash, + }, + DefaultTtl = 100, + UniqueKeys = {new CosmosDBUniqueKey +{ +Paths = {"/testPath"}, +}}, + ConflictResolutionPolicy = new ConflictResolutionPolicy + { + Mode = ConflictResolutionMode.LastWriterWins, + ConflictResolutionPath = "/path", + }, + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, graphName, content); + GremlinGraphResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GremlinGraphData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +132,10 @@ public async Task Get_CosmosDBGremlinGraphGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBGremlinGraphGet() + public async Task GetAll_CosmosDBGremlinGraphList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinGraphGet.json - // this example is just showing the usage of "GremlinResources_GetGremlinGraph" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinGraphList.json + // this example is just showing the usage of "GremlinResources_ListGremlinGraphs" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +154,22 @@ public async Task Exists_CosmosDBGremlinGraphGet() // get the collection of this GremlinGraphResource GremlinGraphCollection collection = gremlinDatabase.GetGremlinGraphs(); - // invoke the operation - string graphName = "graphName"; - bool result = await collection.ExistsAsync(graphName); + // invoke the operation and iterate over the result + await foreach (GremlinGraphResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GremlinGraphData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBGremlinGraphGet() + public async Task Exists_CosmosDBGremlinGraphGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinGraphGet.json // this example is just showing the usage of "GremlinResources_GetGremlinGraph" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +193,17 @@ public async Task GetIfExists_CosmosDBGremlinGraphGet() // invoke the operation string graphName = "graphName"; - NullableResponse response = await collection.GetIfExistsAsync(graphName); - GremlinGraphResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(graphName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GremlinGraphData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBGremlinGraphCreateUpdate() + public async Task GetIfExists_CosmosDBGremlinGraphGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinGraphCreateUpdate.json - // this example is just showing the usage of "GremlinResources_CreateUpdateGremlinGraph" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinGraphGet.json + // this example is just showing the usage of "GremlinResources_GetGremlinGraph" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,7 +213,7 @@ public async Task CreateOrUpdate_CosmosDBGremlinGraphCreateUpdate() // this example assumes you already have this GremlinDatabaseResource created on azure // for more information of creating GremlinDatabaseResource, please refer to the document of GremlinDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier gremlinDatabaseResourceId = GremlinDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -188,76 +224,21 @@ public async Task CreateOrUpdate_CosmosDBGremlinGraphCreateUpdate() // invoke the operation string graphName = "graphName"; - GremlinGraphCreateOrUpdateContent content = new GremlinGraphCreateOrUpdateContent(new AzureLocation("West US"), new GremlinGraphResourceInfo("graphName") + NullableResponse response = await collection.GetIfExistsAsync(graphName); + GremlinGraphResource result = response.HasValue ? response.Value : null; + + if (result == null) { - IndexingPolicy = new CosmosDBIndexingPolicy() - { - IsAutomatic = true, - IndexingMode = CosmosDBIndexingMode.Consistent, - IncludedPaths = -{ -new CosmosDBIncludedPath() -{ -Path = "/*", -Indexes = -{ -new CosmosDBPathIndexes() -{ -DataType = CosmosDBDataType.String, -Precision = -1, -Kind = CosmosDBIndexKind.Range, -},new CosmosDBPathIndexes() -{ -DataType = CosmosDBDataType.Number, -Precision = -1, -Kind = CosmosDBIndexKind.Range, -} -}, -} -}, - ExcludedPaths = -{ -}, - }, - PartitionKey = new CosmosDBContainerPartitionKey() - { - Paths = -{ -"/AccountNumber" -}, - Kind = CosmosDBPartitionKind.Hash, - }, - DefaultTtl = 100, - UniqueKeys = -{ -new CosmosDBUniqueKey() -{ -Paths = -{ -"/testPath" -}, -} -}, - ConflictResolutionPolicy = new ConflictResolutionPolicy() - { - Mode = ConflictResolutionMode.LastWriterWins, - ConflictResolutionPath = "/path", - }, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, graphName, content); - GremlinGraphResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GremlinGraphData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GremlinGraphData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphResource.cs index 6bab92ed1e33c..2be2387775f54 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphResource.cs @@ -48,6 +48,34 @@ public async Task Get_CosmosDBGremlinGraphGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CosmosDBGremlinGraphDelete() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinGraphDelete.json + // this example is just showing the usage of "GremlinResources_DeleteGremlinGraph" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this GremlinGraphResource created on azure + // for more information of creating GremlinGraphResource, please refer to the document of GremlinGraphResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string accountName = "ddb1"; + string databaseName = "databaseName"; + string graphName = "graphName"; + ResourceIdentifier gremlinGraphResourceId = GremlinGraphResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName, graphName); + GremlinGraphResource gremlinGraph = client.GetGremlinGraphResource(gremlinGraphResourceId); + + // invoke the operation + await gremlinGraph.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CosmosDBGremlinGraphCreateUpdate() @@ -73,55 +101,38 @@ public async Task Update_CosmosDBGremlinGraphCreateUpdate() // invoke the operation GremlinGraphCreateOrUpdateContent content = new GremlinGraphCreateOrUpdateContent(new AzureLocation("West US"), new GremlinGraphResourceInfo("graphName") { - IndexingPolicy = new CosmosDBIndexingPolicy() + IndexingPolicy = new CosmosDBIndexingPolicy { IsAutomatic = true, IndexingMode = CosmosDBIndexingMode.Consistent, - IncludedPaths = -{ -new CosmosDBIncludedPath() + IncludedPaths = {new CosmosDBIncludedPath { Path = "/*", -Indexes = -{ -new CosmosDBPathIndexes() +Indexes = {new CosmosDBPathIndexes { DataType = CosmosDBDataType.String, Precision = -1, Kind = CosmosDBIndexKind.Range, -},new CosmosDBPathIndexes() +}, new CosmosDBPathIndexes { DataType = CosmosDBDataType.Number, Precision = -1, Kind = CosmosDBIndexKind.Range, -} -}, -} -}, - ExcludedPaths = -{ -}, +}}, +}}, + ExcludedPaths = { }, }, - PartitionKey = new CosmosDBContainerPartitionKey() + PartitionKey = new CosmosDBContainerPartitionKey { - Paths = -{ -"/AccountNumber" -}, + Paths = { "/AccountNumber" }, Kind = CosmosDBPartitionKind.Hash, }, DefaultTtl = 100, - UniqueKeys = -{ -new CosmosDBUniqueKey() -{ -Paths = + UniqueKeys = {new CosmosDBUniqueKey { -"/testPath" -}, -} -}, - ConflictResolutionPolicy = new ConflictResolutionPolicy() +Paths = {"/testPath"}, +}}, + ConflictResolutionPolicy = new ConflictResolutionPolicy { Mode = ConflictResolutionMode.LastWriterWins, ConflictResolutionPath = "/path", @@ -129,9 +140,7 @@ public async Task Update_CosmosDBGremlinGraphCreateUpdate() }) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await gremlinGraph.UpdateAsync(WaitUntil.Completed, content); GremlinGraphResource result = lro.Value; @@ -143,34 +152,6 @@ public async Task Update_CosmosDBGremlinGraphCreateUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBGremlinGraphDelete() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBGremlinGraphDelete.json - // this example is just showing the usage of "GremlinResources_DeleteGremlinGraph" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this GremlinGraphResource created on azure - // for more information of creating GremlinGraphResource, please refer to the document of GremlinGraphResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string accountName = "ddb1"; - string databaseName = "databaseName"; - string graphName = "graphName"; - ResourceIdentifier gremlinGraphResourceId = GremlinGraphResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName, graphName); - GremlinGraphResource gremlinGraph = client.GetGremlinGraphResource(gremlinGraphResourceId); - - // invoke the operation - await gremlinGraph.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task RetrieveContinuousBackupInformation_CosmosDBGremlinGraphBackupInformation() @@ -194,7 +175,7 @@ public async Task RetrieveContinuousBackupInformation_CosmosDBGremlinGraphBackup GremlinGraphResource gremlinGraph = client.GetGremlinGraphResource(gremlinGraphResourceId); // invoke the operation - ContinuousBackupRestoreLocation location = new ContinuousBackupRestoreLocation() + ContinuousBackupRestoreLocation location = new ContinuousBackupRestoreLocation { Location = new AzureLocation("North Europe"), }; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphThroughputSettingResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphThroughputSettingResource.cs index f778314afe89e..27a26d21f8284 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphThroughputSettingResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_GremlinGraphThroughputSettingResource.cs @@ -71,14 +71,12 @@ public async Task CreateOrUpdate_CosmosDBGremlinGraphThroughputUpdate() GremlinGraphThroughputSettingResource gremlinGraphThroughputSetting = client.GetGremlinGraphThroughputSettingResource(gremlinGraphThroughputSettingResourceId); // invoke the operation - ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo() + ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo { Throughput = 400, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await gremlinGraphThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); GremlinGraphThroughputSettingResource result = lro.Value; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionCollection.cs index 929beb6fa87ba..e61673204d778 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MongoDBCollectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBMongoDBCollectionList() + public async Task CreateOrUpdate_CosmosDBMongoDBCollectionCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionList.json - // this example is just showing the usage of "MongoDBResources_ListMongoDBCollections" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionCreateUpdate.json + // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoDBCollection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBMongoDBCollectionList() // this example assumes you already have this MongoDBDatabaseResource created on azure // for more information of creating MongoDBDatabaseResource, please refer to the document of MongoDBDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier mongoDBDatabaseResourceId = MongoDBDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -40,25 +40,48 @@ public async Task GetAll_CosmosDBMongoDBCollectionList() // get the collection of this MongoDBCollectionResource MongoDBCollectionCollection collection = mongoDBDatabase.GetMongoDBCollections(); - // invoke the operation and iterate over the result - await foreach (MongoDBCollectionResource item in collection.GetAllAsync()) + // invoke the operation + string collectionName = "collectionName"; + MongoDBCollectionCreateOrUpdateContent content = new MongoDBCollectionCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBCollectionResourceInfo("collectionName") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoDBCollectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ShardKey = +{ +["testKey"] = "Hash" +}, + Indexes = {new MongoDBIndex +{ +Keys = {"_ts"}, +Options = new MongoDBIndexConfig +{ +ExpireAfterSeconds = 100, +IsUnique = true, +}, +}, new MongoDBIndex +{ +Keys = {"_id"}, +}}, + AnalyticalStorageTtl = 500, + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, collectionName, content); + MongoDBCollectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoDBCollectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBMongoDBCollectionGet() + public async Task CreateOrUpdate_CosmosDBMongoDBCollectionRestore() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionGet.json - // this example is just showing the usage of "MongoDBResources_GetMongoDBCollection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionRestore.json + // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoDBCollection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,7 +91,7 @@ public async Task Get_CosmosDBMongoDBCollectionGet() // this example assumes you already have this MongoDBDatabaseResource created on azure // for more information of creating MongoDBDatabaseResource, please refer to the document of MongoDBDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier mongoDBDatabaseResourceId = MongoDBDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -79,7 +102,22 @@ public async Task Get_CosmosDBMongoDBCollectionGet() // invoke the operation string collectionName = "collectionName"; - MongoDBCollectionResource result = await collection.GetAsync(collectionName); + MongoDBCollectionCreateOrUpdateContent content = new MongoDBCollectionCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBCollectionResourceInfo("collectionName") + { + RestoreParameters = new ResourceRestoreParameters + { + RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", + RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), + IsRestoreWithTtlDisabled = false, + }, + CreateMode = CosmosDBAccountCreateMode.Restore, + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, collectionName, content); + MongoDBCollectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,7 +128,7 @@ public async Task Get_CosmosDBMongoDBCollectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBMongoDBCollectionGet() + public async Task Get_CosmosDBMongoDBCollectionGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionGet.json // this example is just showing the usage of "MongoDBResources_GetMongoDBCollection" operation, for the dependent resources, they will have to be created separately. @@ -114,17 +152,21 @@ public async Task Exists_CosmosDBMongoDBCollectionGet() // invoke the operation string collectionName = "collectionName"; - bool result = await collection.ExistsAsync(collectionName); + MongoDBCollectionResource result = await collection.GetAsync(collectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoDBCollectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBMongoDBCollectionGet() + public async Task GetAll_CosmosDBMongoDBCollectionList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionGet.json - // this example is just showing the usage of "MongoDBResources_GetMongoDBCollection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionList.json + // this example is just showing the usage of "MongoDBResources_ListMongoDBCollections" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +185,25 @@ public async Task GetIfExists_CosmosDBMongoDBCollectionGet() // get the collection of this MongoDBCollectionResource MongoDBCollectionCollection collection = mongoDBDatabase.GetMongoDBCollections(); - // invoke the operation - string collectionName = "collectionName"; - NullableResponse response = await collection.GetIfExistsAsync(collectionName); - MongoDBCollectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MongoDBCollectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MongoDBCollectionData resourceData = result.Data; + MongoDBCollectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBMongoDBCollectionCreateUpdate() + public async Task Exists_CosmosDBMongoDBCollectionGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionCreateUpdate.json - // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoDBCollection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionGet.json + // this example is just showing the usage of "MongoDBResources_GetMongoDBCollection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,7 +213,7 @@ public async Task CreateOrUpdate_CosmosDBMongoDBCollectionCreateUpdate() // this example assumes you already have this MongoDBDatabaseResource created on azure // for more information of creating MongoDBDatabaseResource, please refer to the document of MongoDBDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier mongoDBDatabaseResourceId = MongoDBDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -188,57 +224,17 @@ public async Task CreateOrUpdate_CosmosDBMongoDBCollectionCreateUpdate() // invoke the operation string collectionName = "collectionName"; - MongoDBCollectionCreateOrUpdateContent content = new MongoDBCollectionCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBCollectionResourceInfo("collectionName") - { - ShardKey = -{ -["testKey"] = "Hash", -}, - Indexes = -{ -new MongoDBIndex() -{ -Keys = -{ -"_ts" -}, -Options = new MongoDBIndexConfig() -{ -ExpireAfterSeconds = 100, -IsUnique = true, -}, -},new MongoDBIndex() -{ -Keys = -{ -"_id" -}, -} -}, - AnalyticalStorageTtl = 500, - }) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, collectionName, content); - MongoDBCollectionResource result = lro.Value; + bool result = await collection.ExistsAsync(collectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoDBCollectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBMongoDBCollectionRestore() + public async Task GetIfExists_CosmosDBMongoDBCollectionGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionRestore.json - // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoDBCollection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionGet.json + // this example is just showing the usage of "MongoDBResources_GetMongoDBCollection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -248,7 +244,7 @@ public async Task CreateOrUpdate_CosmosDBMongoDBCollectionRestore() // this example assumes you already have this MongoDBDatabaseResource created on azure // for more information of creating MongoDBDatabaseResource, please refer to the document of MongoDBDatabaseResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; string databaseName = "databaseName"; ResourceIdentifier mongoDBDatabaseResourceId = MongoDBDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); @@ -259,30 +255,21 @@ public async Task CreateOrUpdate_CosmosDBMongoDBCollectionRestore() // invoke the operation string collectionName = "collectionName"; - MongoDBCollectionCreateOrUpdateContent content = new MongoDBCollectionCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBCollectionResourceInfo("collectionName") + NullableResponse response = await collection.GetIfExistsAsync(collectionName); + MongoDBCollectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - RestoreParameters = new ResourceRestoreParameters() - { - RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", - RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), - IsRestoreWithTtlDisabled = false, - }, - CreateMode = CosmosDBAccountCreateMode.Restore, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, collectionName, content); - MongoDBCollectionResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoDBCollectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoDBCollectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionResource.cs index b6eafee1bc8f3..e3251c5fc979a 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionResource.cs @@ -48,6 +48,34 @@ public async Task Get_CosmosDBMongoDBCollectionGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CosmosDBMongoDBCollectionDelete() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionDelete.json + // this example is just showing the usage of "MongoDBResources_DeleteMongoDBCollection" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MongoDBCollectionResource created on azure + // for more information of creating MongoDBCollectionResource, please refer to the document of MongoDBCollectionResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string accountName = "ddb1"; + string databaseName = "databaseName"; + string collectionName = "collectionName"; + ResourceIdentifier mongoDBCollectionResourceId = MongoDBCollectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName, collectionName); + MongoDBCollectionResource mongoDBCollection = client.GetMongoDBCollectionResource(mongoDBCollectionResourceId); + + // invoke the operation + await mongoDBCollection.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CosmosDBMongoDBCollectionCreateUpdate() @@ -75,36 +103,25 @@ public async Task Update_CosmosDBMongoDBCollectionCreateUpdate() { ShardKey = { -["testKey"] = "Hash", +["testKey"] = "Hash" }, - Indexes = -{ -new MongoDBIndex() -{ -Keys = + Indexes = {new MongoDBIndex { -"_ts" -}, -Options = new MongoDBIndexConfig() +Keys = {"_ts"}, +Options = new MongoDBIndexConfig { ExpireAfterSeconds = 100, IsUnique = true, }, -},new MongoDBIndex() -{ -Keys = +}, new MongoDBIndex { -"_id" -}, -} -}, +Keys = {"_id"}, +}}, AnalyticalStorageTtl = 500, }) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await mongoDBCollection.UpdateAsync(WaitUntil.Completed, content); MongoDBCollectionResource result = lro.Value; @@ -141,7 +158,7 @@ public async Task Update_CosmosDBMongoDBCollectionRestore() // invoke the operation MongoDBCollectionCreateOrUpdateContent content = new MongoDBCollectionCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBCollectionResourceInfo("collectionName") { - RestoreParameters = new ResourceRestoreParameters() + RestoreParameters = new ResourceRestoreParameters { RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), @@ -151,9 +168,7 @@ public async Task Update_CosmosDBMongoDBCollectionRestore() }) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await mongoDBCollection.UpdateAsync(WaitUntil.Completed, content); MongoDBCollectionResource result = lro.Value; @@ -165,34 +180,6 @@ public async Task Update_CosmosDBMongoDBCollectionRestore() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBMongoDBCollectionDelete() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionDelete.json - // this example is just showing the usage of "MongoDBResources_DeleteMongoDBCollection" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MongoDBCollectionResource created on azure - // for more information of creating MongoDBCollectionResource, please refer to the document of MongoDBCollectionResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string accountName = "ddb1"; - string databaseName = "databaseName"; - string collectionName = "collectionName"; - ResourceIdentifier mongoDBCollectionResourceId = MongoDBCollectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName, collectionName); - MongoDBCollectionResource mongoDBCollection = client.GetMongoDBCollectionResource(mongoDBCollectionResourceId); - - // invoke the operation - await mongoDBCollection.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetMongoDBCollectionPartitionMerge_CosmosDBMongoDBCollectionPartitionMerge() @@ -216,7 +203,7 @@ public async Task GetMongoDBCollectionPartitionMerge_CosmosDBMongoDBCollectionPa MongoDBCollectionResource mongoDBCollection = client.GetMongoDBCollectionResource(mongoDBCollectionResourceId); // invoke the operation - MergeParameters mergeParameters = new MergeParameters() + MergeParameters mergeParameters = new MergeParameters { IsDryRun = false, }; @@ -249,7 +236,7 @@ public async Task RetrieveContinuousBackupInformation_CosmosDBMongoDBCollectionB MongoDBCollectionResource mongoDBCollection = client.GetMongoDBCollectionResource(mongoDBCollectionResourceId); // invoke the operation - ContinuousBackupRestoreLocation location = new ContinuousBackupRestoreLocation() + ContinuousBackupRestoreLocation location = new ContinuousBackupRestoreLocation { Location = new AzureLocation("North Europe"), }; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionThroughputSettingResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionThroughputSettingResource.cs index dad592ea24ce8..1e256da036ea5 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionThroughputSettingResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBCollectionThroughputSettingResource.cs @@ -19,10 +19,10 @@ public partial class Sample_MongoDBCollectionThroughputSettingResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task MongoDBContainerRetrieveThroughputDistribution_CosmosDBMongoDBCollectionRetrieveThroughputDistribution() + public async Task Get_CosmosDBMongoDBCollectionThroughputGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionRetrieveThroughputDistribution.json - // this example is just showing the usage of "MongoDBResources_MongoDBContainerRetrieveThroughputDistribution" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionThroughputGet.json + // this example is just showing the usage of "MongoDBResources_GetMongoDBCollectionThroughput" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,28 +40,21 @@ public async Task MongoDBContainerRetrieveThroughputDistribution_CosmosDBMongoDB MongoDBCollectionThroughputSettingResource mongoDBCollectionThroughputSetting = client.GetMongoDBCollectionThroughputSettingResource(mongoDBCollectionThroughputSettingResourceId); // invoke the operation - RetrieveThroughputParameters retrieveThroughputParameters = new RetrieveThroughputParameters(new AzureLocation("placeholder"), new RetrieveThroughputPropertiesResource(new WritableSubResource[] - { -new WritableSubResource() -{ -Id = new ResourceIdentifier("0"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("1"), -} - })); - ArmOperation lro = await mongoDBCollectionThroughputSetting.MongoDBContainerRetrieveThroughputDistributionAsync(WaitUntil.Completed, retrieveThroughputParameters); - PhysicalPartitionThroughputInfoResult result = lro.Value; + MongoDBCollectionThroughputSettingResource result = await mongoDBCollectionThroughputSetting.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ThroughputSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task MongoDBContainerRedistributeThroughput_CosmosDBMongoDBCollectionRedistributeThroughput() + public async Task CreateOrUpdate_CosmosDBMongoDBCollectionThroughputUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionRedistributeThroughput.json - // this example is just showing the usage of "MongoDBResources_MongoDBContainerRedistributeThroughput" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionThroughputUpdate.json + // this example is just showing the usage of "MongoDBResources_UpdateMongoDBCollectionThroughput" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,34 +72,29 @@ public async Task MongoDBContainerRedistributeThroughput_CosmosDBMongoDBCollecti MongoDBCollectionThroughputSettingResource mongoDBCollectionThroughputSetting = client.GetMongoDBCollectionThroughputSettingResource(mongoDBCollectionThroughputSettingResourceId); // invoke the operation - RedistributeThroughputParameters redistributeThroughputParameters = new RedistributeThroughputParameters(new AzureLocation("placeholder"), new RedistributeThroughputPropertiesResource(ThroughputPolicyType.Custom, new PhysicalPartitionThroughputInfoResource[] + ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo { -new PhysicalPartitionThroughputInfoResource("0") -{ -Throughput = 5000, -},new PhysicalPartitionThroughputInfoResource("1") -{ -Throughput = 5000, -} - }, new PhysicalPartitionThroughputInfoResource[] + Throughput = 400, + }) { -new PhysicalPartitionThroughputInfoResource("2") -{ -Throughput = 5000, -},new PhysicalPartitionThroughputInfoResource("3") - })); - ArmOperation lro = await mongoDBCollectionThroughputSetting.MongoDBContainerRedistributeThroughputAsync(WaitUntil.Completed, redistributeThroughputParameters); - PhysicalPartitionThroughputInfoResult result = lro.Value; + Tags = { }, + }; + ArmOperation lro = await mongoDBCollectionThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); + MongoDBCollectionThroughputSettingResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ThroughputSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBMongoDBCollectionThroughputGet() + public async Task MongoDBContainerRetrieveThroughputDistribution_CosmosDBMongoDBCollectionRetrieveThroughputDistribution() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionThroughputGet.json - // this example is just showing the usage of "MongoDBResources_GetMongoDBCollectionThroughput" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionRetrieveThroughputDistribution.json + // this example is just showing the usage of "MongoDBResources_MongoDBContainerRetrieveThroughputDistribution" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -124,21 +112,29 @@ public async Task Get_CosmosDBMongoDBCollectionThroughputGet() MongoDBCollectionThroughputSettingResource mongoDBCollectionThroughputSetting = client.GetMongoDBCollectionThroughputSettingResource(mongoDBCollectionThroughputSettingResourceId); // invoke the operation - MongoDBCollectionThroughputSettingResource result = await mongoDBCollectionThroughputSetting.GetAsync(); + RetrieveThroughputParameters retrieveThroughputParameters = new RetrieveThroughputParameters(default, new RetrieveThroughputPropertiesResource(new WritableSubResource[] + { +new WritableSubResource +{ +Id = new ResourceIdentifier("0"), +}, +new WritableSubResource +{ +Id = new ResourceIdentifier("1"), +} + })); + ArmOperation lro = await mongoDBCollectionThroughputSetting.MongoDBContainerRetrieveThroughputDistributionAsync(WaitUntil.Completed, retrieveThroughputParameters); + PhysicalPartitionThroughputInfoResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ThroughputSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBMongoDBCollectionThroughputUpdate() + public async Task MongoDBContainerRedistributeThroughput_CosmosDBMongoDBCollectionRedistributeThroughput() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionThroughputUpdate.json - // this example is just showing the usage of "MongoDBResources_UpdateMongoDBCollectionThroughput" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBCollectionRedistributeThroughput.json + // this example is just showing the usage of "MongoDBResources_MongoDBContainerRedistributeThroughput" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -156,23 +152,28 @@ public async Task CreateOrUpdate_CosmosDBMongoDBCollectionThroughputUpdate() MongoDBCollectionThroughputSettingResource mongoDBCollectionThroughputSetting = client.GetMongoDBCollectionThroughputSettingResource(mongoDBCollectionThroughputSettingResourceId); // invoke the operation - ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo() + RedistributeThroughputParameters redistributeThroughputParameters = new RedistributeThroughputParameters(default, new RedistributeThroughputPropertiesResource(ThroughputPolicyType.Custom, new PhysicalPartitionThroughputInfoResource[] { - Throughput = 400, - }) +new PhysicalPartitionThroughputInfoResource("0") +{ +Throughput = 5000, +}, +new PhysicalPartitionThroughputInfoResource("1") +{ +Throughput = 5000, +} + }, new PhysicalPartitionThroughputInfoResource[] { - Tags = +new PhysicalPartitionThroughputInfoResource("2") { +Throughput = 5000, }, - }; - ArmOperation lro = await mongoDBCollectionThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); - MongoDBCollectionThroughputSettingResource result = lro.Value; +new PhysicalPartitionThroughputInfoResource("3") + })); + ArmOperation lro = await mongoDBCollectionThroughputSetting.MongoDBContainerRedistributeThroughputAsync(WaitUntil.Completed, redistributeThroughputParameters); + PhysicalPartitionThroughputInfoResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ThroughputSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseCollection.cs index 59ffee2b40e7f..693db7b83d422 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MongoDBDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBMongoDBDatabaseList() + public async Task CreateOrUpdate_CosmosDBMongoDBDatabaseCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseList.json - // this example is just showing the usage of "MongoDBResources_ListMongoDBDatabases" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseCreateUpdate.json + // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_CosmosDBMongoDBDatabaseList() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rgName"; + string resourceGroupName = "rg1"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -39,25 +39,29 @@ public async Task GetAll_CosmosDBMongoDBDatabaseList() // get the collection of this MongoDBDatabaseResource MongoDBDatabaseCollection collection = cosmosDBAccount.GetMongoDBDatabases(); - // invoke the operation and iterate over the result - await foreach (MongoDBDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "databaseName"; + MongoDBDatabaseCreateOrUpdateContent content = new MongoDBDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBDatabaseResourceInfo("databaseName")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoDBDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, content); + MongoDBDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoDBDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBMongoDBDatabaseGet() + public async Task CreateOrUpdate_CosmosDBMongoDBDatabaseRestore() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseGet.json - // this example is just showing the usage of "MongoDBResources_GetMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseRestore.json + // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +81,22 @@ public async Task Get_CosmosDBMongoDBDatabaseGet() // invoke the operation string databaseName = "databaseName"; - MongoDBDatabaseResource result = await collection.GetAsync(databaseName); + MongoDBDatabaseCreateOrUpdateContent content = new MongoDBDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBDatabaseResourceInfo("databaseName") + { + RestoreParameters = new ResourceRestoreParameters + { + RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", + RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), + IsRestoreWithTtlDisabled = false, + }, + CreateMode = CosmosDBAccountCreateMode.Restore, + }) + { + Options = new CosmosDBCreateUpdateConfig(), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, content); + MongoDBDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +107,7 @@ public async Task Get_CosmosDBMongoDBDatabaseGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBMongoDBDatabaseGet() + public async Task Get_CosmosDBMongoDBDatabaseGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseGet.json // this example is just showing the usage of "MongoDBResources_GetMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +130,21 @@ public async Task Exists_CosmosDBMongoDBDatabaseGet() // invoke the operation string databaseName = "databaseName"; - bool result = await collection.ExistsAsync(databaseName); + MongoDBDatabaseResource result = await collection.GetAsync(databaseName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoDBDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBMongoDBDatabaseGet() + public async Task GetAll_CosmosDBMongoDBDatabaseList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseGet.json - // this example is just showing the usage of "MongoDBResources_GetMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseList.json + // this example is just showing the usage of "MongoDBResources_ListMongoDBDatabases" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,7 +154,7 @@ public async Task GetIfExists_CosmosDBMongoDBDatabaseGet() // this example assumes you already have this CosmosDBAccountResource created on azure // for more information of creating CosmosDBAccountResource, please refer to the document of CosmosDBAccountResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rgName"; string accountName = "ddb1"; ResourceIdentifier cosmosDBAccountResourceId = CosmosDBAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); CosmosDBAccountResource cosmosDBAccount = client.GetCosmosDBAccountResource(cosmosDBAccountResourceId); @@ -139,31 +162,25 @@ public async Task GetIfExists_CosmosDBMongoDBDatabaseGet() // get the collection of this MongoDBDatabaseResource MongoDBDatabaseCollection collection = cosmosDBAccount.GetMongoDBDatabases(); - // invoke the operation - string databaseName = "databaseName"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - MongoDBDatabaseResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MongoDBDatabaseResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MongoDBDatabaseData resourceData = result.Data; + MongoDBDatabaseData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBMongoDBDatabaseCreateUpdate() + public async Task Exists_CosmosDBMongoDBDatabaseGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseCreateUpdate.json - // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseGet.json + // this example is just showing the usage of "MongoDBResources_GetMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,29 +200,17 @@ public async Task CreateOrUpdate_CosmosDBMongoDBDatabaseCreateUpdate() // invoke the operation string databaseName = "databaseName"; - MongoDBDatabaseCreateOrUpdateContent content = new MongoDBDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBDatabaseResourceInfo("databaseName")) - { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, content); - MongoDBDatabaseResource result = lro.Value; + bool result = await collection.ExistsAsync(databaseName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoDBDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBMongoDBDatabaseRestore() + public async Task GetIfExists_CosmosDBMongoDBDatabaseGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseRestore.json - // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseGet.json + // this example is just showing the usage of "MongoDBResources_GetMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -225,30 +230,21 @@ public async Task CreateOrUpdate_CosmosDBMongoDBDatabaseRestore() // invoke the operation string databaseName = "databaseName"; - MongoDBDatabaseCreateOrUpdateContent content = new MongoDBDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBDatabaseResourceInfo("databaseName") + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + MongoDBDatabaseResource result = response.HasValue ? response.Value : null; + + if (result == null) { - RestoreParameters = new ResourceRestoreParameters() - { - RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", - RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), - IsRestoreWithTtlDisabled = false, - }, - CreateMode = CosmosDBAccountCreateMode.Restore, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, content); - MongoDBDatabaseResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoDBDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoDBDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseResource.cs index a686d761cbdf2..a0d26f6099bcb 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseResource.cs @@ -47,6 +47,33 @@ public async Task Get_CosmosDBMongoDBDatabaseGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_CosmosDBMongoDBDatabaseDelete() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseDelete.json + // this example is just showing the usage of "MongoDBResources_DeleteMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MongoDBDatabaseResource created on azure + // for more information of creating MongoDBDatabaseResource, please refer to the document of MongoDBDatabaseResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string accountName = "ddb1"; + string databaseName = "databaseName"; + ResourceIdentifier mongoDBDatabaseResourceId = MongoDBDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); + MongoDBDatabaseResource mongoDBDatabase = client.GetMongoDBDatabaseResource(mongoDBDatabaseResourceId); + + // invoke the operation + await mongoDBDatabase.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CosmosDBMongoDBDatabaseCreateUpdate() @@ -72,9 +99,7 @@ public async Task Update_CosmosDBMongoDBDatabaseCreateUpdate() MongoDBDatabaseCreateOrUpdateContent content = new MongoDBDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBDatabaseResourceInfo("databaseName")) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await mongoDBDatabase.UpdateAsync(WaitUntil.Completed, content); MongoDBDatabaseResource result = lro.Value; @@ -110,7 +135,7 @@ public async Task Update_CosmosDBMongoDBDatabaseRestore() // invoke the operation MongoDBDatabaseCreateOrUpdateContent content = new MongoDBDatabaseCreateOrUpdateContent(new AzureLocation("West US"), new MongoDBDatabaseResourceInfo("databaseName") { - RestoreParameters = new ResourceRestoreParameters() + RestoreParameters = new ResourceRestoreParameters { RestoreSource = "/subscriptions/subid/providers/Microsoft.DocumentDB/locations/WestUS/restorableDatabaseAccounts/restorableDatabaseAccountId", RestoreTimestampInUtc = DateTimeOffset.Parse("2022-07-20T18:28:00Z"), @@ -120,9 +145,7 @@ public async Task Update_CosmosDBMongoDBDatabaseRestore() }) { Options = new CosmosDBCreateUpdateConfig(), - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await mongoDBDatabase.UpdateAsync(WaitUntil.Completed, content); MongoDBDatabaseResource result = lro.Value; @@ -134,33 +157,6 @@ public async Task Update_CosmosDBMongoDBDatabaseRestore() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBMongoDBDatabaseDelete() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBDatabaseDelete.json - // this example is just showing the usage of "MongoDBResources_DeleteMongoDBDatabase" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MongoDBDatabaseResource created on azure - // for more information of creating MongoDBDatabaseResource, please refer to the document of MongoDBDatabaseResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string accountName = "ddb1"; - string databaseName = "databaseName"; - ResourceIdentifier mongoDBDatabaseResourceId = MongoDBDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, databaseName); - MongoDBDatabaseResource mongoDBDatabase = client.GetMongoDBDatabaseResource(mongoDBDatabaseResourceId); - - // invoke the operation - await mongoDBDatabase.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task MongoDBDatabasePartitionMerge_CosmosDBMongoDBDatabasePartitionMerge() @@ -183,7 +179,7 @@ public async Task MongoDBDatabasePartitionMerge_CosmosDBMongoDBDatabasePartition MongoDBDatabaseResource mongoDBDatabase = client.GetMongoDBDatabaseResource(mongoDBDatabaseResourceId); // invoke the operation - MergeParameters mergeParameters = new MergeParameters() + MergeParameters mergeParameters = new MergeParameters { IsDryRun = false, }; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseThroughputSettingResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseThroughputSettingResource.cs index b79ee42e4ef81..8f6727dab7fd8 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseThroughputSettingResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBDatabaseThroughputSettingResource.cs @@ -70,14 +70,12 @@ public async Task CreateOrUpdate_CosmosDBMongoDBDatabaseThroughputUpdate() MongoDBDatabaseThroughputSettingResource mongoDBDatabaseThroughputSetting = client.GetMongoDBDatabaseThroughputSettingResource(mongoDBDatabaseThroughputSettingResourceId); // invoke the operation - ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo() + ThroughputSettingsUpdateData data = new ThroughputSettingsUpdateData(new AzureLocation("West US"), new ThroughputSettingsResourceInfo { Throughput = 400, }) { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await mongoDBDatabaseThroughputSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); MongoDBDatabaseThroughputSettingResource result = lro.Value; @@ -175,12 +173,13 @@ public async Task MongoDBDatabaseRetrieveThroughputDistribution_CosmosDBMongoDBD MongoDBDatabaseThroughputSettingResource mongoDBDatabaseThroughputSetting = client.GetMongoDBDatabaseThroughputSettingResource(mongoDBDatabaseThroughputSettingResourceId); // invoke the operation - RetrieveThroughputParameters retrieveThroughputParameters = new RetrieveThroughputParameters(new AzureLocation("placeholder"), new RetrieveThroughputPropertiesResource(new WritableSubResource[] + RetrieveThroughputParameters retrieveThroughputParameters = new RetrieveThroughputParameters(default, new RetrieveThroughputPropertiesResource(new WritableSubResource[] { -new WritableSubResource() +new WritableSubResource { Id = new ResourceIdentifier("0"), -},new WritableSubResource() +}, +new WritableSubResource { Id = new ResourceIdentifier("1"), } @@ -213,12 +212,13 @@ public async Task MongoDBDatabaseRedistributeThroughput_CosmosDBMongoDBDatabaseR MongoDBDatabaseThroughputSettingResource mongoDBDatabaseThroughputSetting = client.GetMongoDBDatabaseThroughputSettingResource(mongoDBDatabaseThroughputSettingResourceId); // invoke the operation - RedistributeThroughputParameters redistributeThroughputParameters = new RedistributeThroughputParameters(new AzureLocation("placeholder"), new RedistributeThroughputPropertiesResource(ThroughputPolicyType.Custom, new PhysicalPartitionThroughputInfoResource[] + RedistributeThroughputParameters redistributeThroughputParameters = new RedistributeThroughputParameters(default, new RedistributeThroughputPropertiesResource(ThroughputPolicyType.Custom, new PhysicalPartitionThroughputInfoResource[] { new PhysicalPartitionThroughputInfoResource("0") { Throughput = 5000, -},new PhysicalPartitionThroughputInfoResource("1") +}, +new PhysicalPartitionThroughputInfoResource("1") { Throughput = 5000, } @@ -227,7 +227,8 @@ public async Task MongoDBDatabaseRedistributeThroughput_CosmosDBMongoDBDatabaseR new PhysicalPartitionThroughputInfoResource("2") { Throughput = 5000, -},new PhysicalPartitionThroughputInfoResource("3") +}, +new PhysicalPartitionThroughputInfoResource("3") })); ArmOperation lro = await mongoDBDatabaseThroughputSetting.MongoDBDatabaseRedistributeThroughputAsync(WaitUntil.Completed, redistributeThroughputParameters); PhysicalPartitionThroughputInfoResult result = lro.Value; diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBRoleDefinitionCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBRoleDefinitionCollection.cs index 30ce5e8a90112..70c375c1dedbb 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBRoleDefinitionCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBRoleDefinitionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MongoDBRoleDefinitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBMongoRoleDefinitionGet() + public async Task CreateOrUpdate_CosmosDBMongoDBRoleDefinitionCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionGet.json - // this example is just showing the usage of "MongoDBResources_GetMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionCreateUpdate.json + // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,27 @@ public async Task Get_CosmosDBMongoRoleDefinitionGet() // invoke the operation string mongoRoleDefinitionId = "myMongoRoleDefinitionId"; - MongoDBRoleDefinitionResource result = await collection.GetAsync(mongoRoleDefinitionId); + MongoDBRoleDefinitionCreateOrUpdateContent content = new MongoDBRoleDefinitionCreateOrUpdateContent + { + RoleName = "myRoleName", + DatabaseName = "sales", + Privileges = {new MongoDBPrivilege +{ +Resource = new MongoDBPrivilegeResourceInfo +{ +DBName = "sales", +Collection = "sales", +}, +Actions = {"insert", "find"}, +}}, + Roles = {new MongoDBRole +{ +DBName = "sales", +Role = "myInheritedRole", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mongoRoleDefinitionId, content); + MongoDBRoleDefinitionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +72,7 @@ public async Task Get_CosmosDBMongoRoleDefinitionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBMongoRoleDefinitionGet() + public async Task Get_CosmosDBMongoRoleDefinitionGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionGet.json // this example is just showing the usage of "MongoDBResources_GetMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +95,21 @@ public async Task Exists_CosmosDBMongoRoleDefinitionGet() // invoke the operation string mongoRoleDefinitionId = "myMongoRoleDefinitionId"; - bool result = await collection.ExistsAsync(mongoRoleDefinitionId); + MongoDBRoleDefinitionResource result = await collection.GetAsync(mongoRoleDefinitionId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoDBRoleDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBMongoRoleDefinitionGet() + public async Task GetAll_CosmosDBMongoDBRoleDefinitionList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionGet.json - // this example is just showing the usage of "MongoDBResources_GetMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionList.json + // this example is just showing the usage of "MongoDBResources_ListMongoRoleDefinitions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +127,25 @@ public async Task GetIfExists_CosmosDBMongoRoleDefinitionGet() // get the collection of this MongoDBRoleDefinitionResource MongoDBRoleDefinitionCollection collection = cosmosDBAccount.GetMongoDBRoleDefinitions(); - // invoke the operation - string mongoRoleDefinitionId = "myMongoRoleDefinitionId"; - NullableResponse response = await collection.GetIfExistsAsync(mongoRoleDefinitionId); - MongoDBRoleDefinitionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MongoDBRoleDefinitionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MongoDBRoleDefinitionData resourceData = result.Data; + MongoDBRoleDefinitionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBMongoDBRoleDefinitionCreateUpdate() + public async Task Exists_CosmosDBMongoRoleDefinitionGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionCreateUpdate.json - // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionGet.json + // this example is just showing the usage of "MongoDBResources_GetMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,50 +165,17 @@ public async Task CreateOrUpdate_CosmosDBMongoDBRoleDefinitionCreateUpdate() // invoke the operation string mongoRoleDefinitionId = "myMongoRoleDefinitionId"; - MongoDBRoleDefinitionCreateOrUpdateContent content = new MongoDBRoleDefinitionCreateOrUpdateContent() - { - RoleName = "myRoleName", - DatabaseName = "sales", - Privileges = -{ -new MongoDBPrivilege() -{ -Resource = new MongoDBPrivilegeResourceInfo() -{ -DBName = "sales", -Collection = "sales", -}, -Actions = -{ -"insert","find" -}, -} -}, - Roles = -{ -new MongoDBRole() -{ -DBName = "sales", -Role = "myInheritedRole", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mongoRoleDefinitionId, content); - MongoDBRoleDefinitionResource result = lro.Value; + bool result = await collection.ExistsAsync(mongoRoleDefinitionId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoDBRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBMongoDBRoleDefinitionList() + public async Task GetIfExists_CosmosDBMongoRoleDefinitionGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionList.json - // this example is just showing the usage of "MongoDBResources_ListMongoRoleDefinitions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionGet.json + // this example is just showing the usage of "MongoDBResources_GetMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -208,17 +193,23 @@ public async Task GetAll_CosmosDBMongoDBRoleDefinitionList() // get the collection of this MongoDBRoleDefinitionResource MongoDBRoleDefinitionCollection collection = cosmosDBAccount.GetMongoDBRoleDefinitions(); - // invoke the operation and iterate over the result - await foreach (MongoDBRoleDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string mongoRoleDefinitionId = "myMongoRoleDefinitionId"; + NullableResponse response = await collection.GetIfExistsAsync(mongoRoleDefinitionId); + MongoDBRoleDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MongoDBRoleDefinitionData resourceData = item.Data; + MongoDBRoleDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBRoleDefinitionResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBRoleDefinitionResource.cs index 757a2a31e0d9a..7e8b58582de5b 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBRoleDefinitionResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBRoleDefinitionResource.cs @@ -49,10 +49,10 @@ public async Task Get_CosmosDBMongoRoleDefinitionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBMongoDBRoleDefinitionCreateUpdate() + public async Task Delete_CosmosDBMongoDBRoleDefinitionDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionCreateUpdate.json - // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionDelete.json + // this example is just showing the usage of "MongoDBResources_DeleteMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,50 +69,17 @@ public async Task Update_CosmosDBMongoDBRoleDefinitionCreateUpdate() MongoDBRoleDefinitionResource mongoDBRoleDefinition = client.GetMongoDBRoleDefinitionResource(mongoDBRoleDefinitionResourceId); // invoke the operation - MongoDBRoleDefinitionCreateOrUpdateContent content = new MongoDBRoleDefinitionCreateOrUpdateContent() - { - RoleName = "myRoleName", - DatabaseName = "sales", - Privileges = -{ -new MongoDBPrivilege() -{ -Resource = new MongoDBPrivilegeResourceInfo() -{ -DBName = "sales", -Collection = "sales", -}, -Actions = -{ -"insert","find" -}, -} -}, - Roles = -{ -new MongoDBRole() -{ -DBName = "sales", -Role = "myInheritedRole", -} -}, - }; - ArmOperation lro = await mongoDBRoleDefinition.UpdateAsync(WaitUntil.Completed, content); - MongoDBRoleDefinitionResource result = lro.Value; + await mongoDBRoleDefinition.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoDBRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBMongoDBRoleDefinitionDelete() + public async Task Update_CosmosDBMongoDBRoleDefinitionCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionDelete.json - // this example is just showing the usage of "MongoDBResources_DeleteMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBRoleDefinitionCreateUpdate.json + // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoRoleDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,9 +96,33 @@ public async Task Delete_CosmosDBMongoDBRoleDefinitionDelete() MongoDBRoleDefinitionResource mongoDBRoleDefinition = client.GetMongoDBRoleDefinitionResource(mongoDBRoleDefinitionResourceId); // invoke the operation - await mongoDBRoleDefinition.DeleteAsync(WaitUntil.Completed); + MongoDBRoleDefinitionCreateOrUpdateContent content = new MongoDBRoleDefinitionCreateOrUpdateContent + { + RoleName = "myRoleName", + DatabaseName = "sales", + Privileges = {new MongoDBPrivilege +{ +Resource = new MongoDBPrivilegeResourceInfo +{ +DBName = "sales", +Collection = "sales", +}, +Actions = {"insert", "find"}, +}}, + Roles = {new MongoDBRole +{ +DBName = "sales", +Role = "myInheritedRole", +}}, + }; + ArmOperation lro = await mongoDBRoleDefinition.UpdateAsync(WaitUntil.Completed, content); + MongoDBRoleDefinitionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoDBRoleDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBUserDefinitionCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBUserDefinitionCollection.cs index 397f589a09ab4..ab7e68dbafa95 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBUserDefinitionCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBUserDefinitionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MongoDBUserDefinitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBMongoDBUserDefinitionGet() + public async Task CreateOrUpdate_CosmosDBMongoDBUserDefinitionCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionGet.json - // this example is just showing the usage of "MongoDBResources_GetMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionCreateUpdate.json + // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,21 @@ public async Task Get_CosmosDBMongoDBUserDefinitionGet() // invoke the operation string mongoUserDefinitionId = "myMongoUserDefinitionId"; - MongoDBUserDefinitionResource result = await collection.GetAsync(mongoUserDefinitionId); + MongoDBUserDefinitionCreateOrUpdateContent content = new MongoDBUserDefinitionCreateOrUpdateContent + { + UserName = "myUserName", + Password = "myPassword", + DatabaseName = "sales", + CustomData = "My custom data", + Roles = {new MongoDBRole +{ +DBName = "sales", +Role = "myReadRole", +}}, + Mechanisms = "SCRAM-SHA-256", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mongoUserDefinitionId, content); + MongoDBUserDefinitionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +66,7 @@ public async Task Get_CosmosDBMongoDBUserDefinitionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CosmosDBMongoDBUserDefinitionGet() + public async Task Get_CosmosDBMongoDBUserDefinitionGet() { // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionGet.json // this example is just showing the usage of "MongoDBResources_GetMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +89,21 @@ public async Task Exists_CosmosDBMongoDBUserDefinitionGet() // invoke the operation string mongoUserDefinitionId = "myMongoUserDefinitionId"; - bool result = await collection.ExistsAsync(mongoUserDefinitionId); + MongoDBUserDefinitionResource result = await collection.GetAsync(mongoUserDefinitionId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoDBUserDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CosmosDBMongoDBUserDefinitionGet() + public async Task GetAll_CosmosDBMongoDBUserDefinitionList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionGet.json - // this example is just showing the usage of "MongoDBResources_GetMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionList.json + // this example is just showing the usage of "MongoDBResources_ListMongoUserDefinitions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +121,25 @@ public async Task GetIfExists_CosmosDBMongoDBUserDefinitionGet() // get the collection of this MongoDBUserDefinitionResource MongoDBUserDefinitionCollection collection = cosmosDBAccount.GetMongoDBUserDefinitions(); - // invoke the operation - string mongoUserDefinitionId = "myMongoUserDefinitionId"; - NullableResponse response = await collection.GetIfExistsAsync(mongoUserDefinitionId); - MongoDBUserDefinitionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MongoDBUserDefinitionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MongoDBUserDefinitionData resourceData = result.Data; + MongoDBUserDefinitionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CosmosDBMongoDBUserDefinitionCreateUpdate() + public async Task Exists_CosmosDBMongoDBUserDefinitionGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionCreateUpdate.json - // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionGet.json + // this example is just showing the usage of "MongoDBResources_GetMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,38 +159,17 @@ public async Task CreateOrUpdate_CosmosDBMongoDBUserDefinitionCreateUpdate() // invoke the operation string mongoUserDefinitionId = "myMongoUserDefinitionId"; - MongoDBUserDefinitionCreateOrUpdateContent content = new MongoDBUserDefinitionCreateOrUpdateContent() - { - UserName = "myUserName", - Password = "myPassword", - DatabaseName = "sales", - CustomData = "My custom data", - Roles = -{ -new MongoDBRole() -{ -DBName = "sales", -Role = "myReadRole", -} -}, - Mechanisms = "SCRAM-SHA-256", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mongoUserDefinitionId, content); - MongoDBUserDefinitionResource result = lro.Value; + bool result = await collection.ExistsAsync(mongoUserDefinitionId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoDBUserDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBMongoDBUserDefinitionList() + public async Task GetIfExists_CosmosDBMongoDBUserDefinitionGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionList.json - // this example is just showing the usage of "MongoDBResources_ListMongoUserDefinitions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionGet.json + // this example is just showing the usage of "MongoDBResources_GetMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,17 +187,23 @@ public async Task GetAll_CosmosDBMongoDBUserDefinitionList() // get the collection of this MongoDBUserDefinitionResource MongoDBUserDefinitionCollection collection = cosmosDBAccount.GetMongoDBUserDefinitions(); - // invoke the operation and iterate over the result - await foreach (MongoDBUserDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string mongoUserDefinitionId = "myMongoUserDefinitionId"; + NullableResponse response = await collection.GetIfExistsAsync(mongoUserDefinitionId); + MongoDBUserDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MongoDBUserDefinitionData resourceData = item.Data; + MongoDBUserDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBUserDefinitionResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBUserDefinitionResource.cs index 8e38a70279eea..69e3b1c600120 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBUserDefinitionResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_MongoDBUserDefinitionResource.cs @@ -49,10 +49,10 @@ public async Task Get_CosmosDBMongoDBUserDefinitionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CosmosDBMongoDBUserDefinitionCreateUpdate() + public async Task Delete_CosmosDBMongoDBUserDefinitionDelete() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionCreateUpdate.json - // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionDelete.json + // this example is just showing the usage of "MongoDBResources_DeleteMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,38 +69,17 @@ public async Task Update_CosmosDBMongoDBUserDefinitionCreateUpdate() MongoDBUserDefinitionResource mongoDBUserDefinition = client.GetMongoDBUserDefinitionResource(mongoDBUserDefinitionResourceId); // invoke the operation - MongoDBUserDefinitionCreateOrUpdateContent content = new MongoDBUserDefinitionCreateOrUpdateContent() - { - UserName = "myUserName", - Password = "myPassword", - DatabaseName = "sales", - CustomData = "My custom data", - Roles = -{ -new MongoDBRole() -{ -DBName = "sales", -Role = "myReadRole", -} -}, - Mechanisms = "SCRAM-SHA-256", - }; - ArmOperation lro = await mongoDBUserDefinition.UpdateAsync(WaitUntil.Completed, content); - MongoDBUserDefinitionResource result = lro.Value; + await mongoDBUserDefinition.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoDBUserDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CosmosDBMongoDBUserDefinitionDelete() + public async Task Update_CosmosDBMongoDBUserDefinitionCreateUpdate() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionDelete.json - // this example is just showing the usage of "MongoDBResources_DeleteMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBMongoDBUserDefinitionCreateUpdate.json + // this example is just showing the usage of "MongoDBResources_CreateUpdateMongoUserDefinition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,9 +96,27 @@ public async Task Delete_CosmosDBMongoDBUserDefinitionDelete() MongoDBUserDefinitionResource mongoDBUserDefinition = client.GetMongoDBUserDefinitionResource(mongoDBUserDefinitionResourceId); // invoke the operation - await mongoDBUserDefinition.DeleteAsync(WaitUntil.Completed); + MongoDBUserDefinitionCreateOrUpdateContent content = new MongoDBUserDefinitionCreateOrUpdateContent + { + UserName = "myUserName", + Password = "myPassword", + DatabaseName = "sales", + CustomData = "My custom data", + Roles = {new MongoDBRole +{ +DBName = "sales", +Role = "myReadRole", +}}, + Mechanisms = "SCRAM-SHA-256", + }; + ArmOperation lro = await mongoDBUserDefinition.UpdateAsync(WaitUntil.Completed, content); + MongoDBUserDefinitionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoDBUserDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs index bbf5535c46405..3ffa93995222c 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkSecurityPerimeterConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NamspaceNetworkSecurityPerimeterConfigurationList() + public async Task Get_NamspaceNetworkSecurityPerimeterConfigurationList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/NetworkSecurityPerimeterConfigurationList.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/NetworkSecurityPerimeterConfigurationGet.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_NamspaceNetworkSecurityPerimeterConfigurationList() // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = cosmosDBAccount.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string networkSecurityPerimeterConfigurationName = "dbedb4e0-40e6-4145-81f3-f1314c150774.resourceAssociation1"; + NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(networkSecurityPerimeterConfigurationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NamspaceNetworkSecurityPerimeterConfigurationList() + public async Task GetAll_NamspaceNetworkSecurityPerimeterConfigurationList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/NetworkSecurityPerimeterConfigurationGet.json - // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/NetworkSecurityPerimeterConfigurationList.json + // this example is just showing the usage of "NetworkSecurityPerimeterConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_NamspaceNetworkSecurityPerimeterConfigurationList() // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = cosmosDBAccount.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation - string networkSecurityPerimeterConfigurationName = "dbedb4e0-40e6-4145-81f3-f1314c150774.resourceAssociation1"; - NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(networkSecurityPerimeterConfigurationName); + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_RestorableCosmosDBAccountCollection.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_RestorableCosmosDBAccountCollection.cs index a9eef6227ba2e..9c14779044fa7 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_RestorableCosmosDBAccountCollection.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_RestorableCosmosDBAccountCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_RestorableCosmosDBAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CosmosDBRestorableDatabaseAccountList() + public async Task Get_CosmosDBRestorableDatabaseAccountGet() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBRestorableDatabaseAccountList.json - // this example is just showing the usage of "RestorableDatabaseAccounts_ListByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBRestorableDatabaseAccountGet.json + // this example is just showing the usage of "RestorableDatabaseAccounts_GetByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_CosmosDBRestorableDatabaseAccountList() // get the collection of this RestorableCosmosDBAccountResource RestorableCosmosDBAccountCollection collection = cosmosDBLocation.GetRestorableCosmosDBAccounts(); - // invoke the operation and iterate over the result - await foreach (RestorableCosmosDBAccountResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorableCosmosDBAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + Guid instanceId = Guid.Parse("d9b26648-2f53-4541-b3d8-3044f4f9810d"); + RestorableCosmosDBAccountResource result = await collection.GetAsync(instanceId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorableCosmosDBAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CosmosDBRestorableDatabaseAccountGet() + public async Task GetAll_CosmosDBRestorableDatabaseAccountList() { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBRestorableDatabaseAccountGet.json - // this example is just showing the usage of "RestorableDatabaseAccounts_GetByLocation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBRestorableDatabaseAccountList.json + // this example is just showing the usage of "RestorableDatabaseAccounts_ListByLocation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +70,17 @@ public async Task Get_CosmosDBRestorableDatabaseAccountGet() // get the collection of this RestorableCosmosDBAccountResource RestorableCosmosDBAccountCollection collection = cosmosDBLocation.GetRestorableCosmosDBAccounts(); - // invoke the operation - Guid instanceId = Guid.Parse("d9b26648-2f53-4541-b3d8-3044f4f9810d"); - RestorableCosmosDBAccountResource result = await collection.GetAsync(instanceId); + // invoke the operation and iterate over the result + await foreach (RestorableCosmosDBAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorableCosmosDBAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorableCosmosDBAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_RestorableCosmosDBAccountResource.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_RestorableCosmosDBAccountResource.cs index df374306d6461..5bb4f88467ef0 100644 --- a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_RestorableCosmosDBAccountResource.cs +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_RestorableCosmosDBAccountResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.CosmosDB.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CosmosDB.Samples { public partial class Sample_RestorableCosmosDBAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetRestorableCosmosDBAccounts_CosmosDBRestorableDatabaseAccountNoLocationList() - { - // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBRestorableDatabaseAccountNoLocationList.json - // this example is just showing the usage of "RestorableDatabaseAccounts_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (RestorableCosmosDBAccountResource item in subscriptionResource.GetRestorableCosmosDBAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RestorableCosmosDBAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_CosmosDBRestorableDatabaseAccountGet() diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..4af0365ef0b12 --- /dev/null +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.CosmosDB.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCosmosDBAccounts_CosmosDBDatabaseAccountList() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountList.json + // this example is just showing the usage of "DatabaseAccounts_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CosmosDBAccountResource item in subscriptionResource.GetCosmosDBAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCassandraClusters_CosmosDBManagedCassandraClusterListBySubscription() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBManagedCassandraClusterListBySubscription.json + // this example is just showing the usage of "CassandraClusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CassandraClusterResource item in subscriptionResource.GetCassandraClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CassandraClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetRestorableCosmosDBAccounts_CosmosDBRestorableDatabaseAccountNoLocationList() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBRestorableDatabaseAccountNoLocationList.json + // this example is just showing the usage of "RestorableDatabaseAccounts_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (RestorableCosmosDBAccountResource item in subscriptionResource.GetRestorableCosmosDBAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RestorableCosmosDBAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCosmosDBThroughputPools_CosmosDBThroughputPoolList() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/throughputPool/CosmosDBThroughputPoolList.json + // this example is just showing the usage of "ThroughputPools_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CosmosDBThroughputPoolResource item in subscriptionResource.GetCosmosDBThroughputPoolsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBThroughputPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_TenantResourceExtensions.cs new file mode 100644 index 0000000000000..9ee1f1766e426 --- /dev/null +++ b/sdk/cosmosdb/Azure.ResourceManager.CosmosDB/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.CosmosDB.Samples +{ + public partial class Sample_TenantResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckNameExistsDatabaseAccount_CosmosDBDatabaseAccountCheckNameExists() + { + // Generated from example definition: specification/cosmos-db/resource-manager/Microsoft.DocumentDB/preview/2024-09-01-preview/examples/CosmosDBDatabaseAccountCheckNameExists.json + // this example is just showing the usage of "DatabaseAccounts_CheckNameExists" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation + string accountName = "ddb1"; + bool result = await tenantResource.CheckNameExistsDatabaseAccountAsync(accountName); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterCollection.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterCollection.cs index 399a31048a810..060da9666f191 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterCollection.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterCollection.cs @@ -16,41 +16,6 @@ namespace Azure.ResourceManager.CosmosDBForPostgreSql.Samples { public partial class Sample_CosmosDBForPostgreSqlClusterCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheClustersByResourceGroup() - { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ClusterListByResourceGroup.json - // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this CosmosDBForPostgreSqlClusterResource - CosmosDBForPostgreSqlClusterCollection collection = resourceGroupResource.GetCosmosDBForPostgreSqlClusters(); - - // invoke the operation and iterate over the result - await foreach (CosmosDBForPostgreSqlClusterResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateANewClusterAsAPointInTimeRestore() @@ -171,9 +136,7 @@ public async Task CreateOrUpdate_CreateANewMultiNodeCluster() NodeStorageQuotaInMb = 524288, NodeVCores = 8, IsNodePublicIPAccessEnabled = false, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); CosmosDBForPostgreSqlClusterResource result = lro.Value; @@ -224,7 +187,7 @@ public async Task CreateOrUpdate_CreateANewSingleNodeBurstable1VCoreCluster() NodeCount = 0, Tags = { -["owner"] = "JohnDoe", +["owner"] = "JohnDoe" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); @@ -276,7 +239,7 @@ public async Task CreateOrUpdate_CreateANewSingleNodeBurstable2VCoresCluster() NodeCount = 0, Tags = { -["owner"] = "JohnDoe", +["owner"] = "JohnDoe" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); @@ -328,7 +291,7 @@ public async Task CreateOrUpdate_CreateANewSingleNodeCluster() NodeCount = 0, Tags = { -["owner"] = "JohnDoe", +["owner"] = "JohnDoe" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); @@ -374,6 +337,41 @@ public async Task Get_GetTheCluster() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListTheClustersByResourceGroup() + { + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ClusterListByResourceGroup.json + // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this CosmosDBForPostgreSqlClusterResource + CosmosDBForPostgreSqlClusterCollection collection = resourceGroupResource.GetCosmosDBForPostgreSqlClusters(); + + // invoke the operation and iterate over the result + await foreach (CosmosDBForPostgreSqlClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetTheCluster() diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterResource.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterResource.cs index 423ce1232edb5..fd1509ee7deb0 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterResource.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.CosmosDBForPostgreSql.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CosmosDBForPostgreSql.Samples { public partial class Sample_CosmosDBForPostgreSqlClusterResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCosmosDBForPostgreSqlClusters_ListAllTheClusters() - { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ClusterList.json - // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CosmosDBForPostgreSqlClusterResource item in subscriptionResource.GetCosmosDBForPostgreSqlClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetTheCluster() @@ -125,7 +93,7 @@ public async Task Update_ScaleComputeUpOrDown() CosmosDBForPostgreSqlClusterResource cosmosDBForPostgreSqlCluster = client.GetCosmosDBForPostgreSqlClusterResource(cosmosDBForPostgreSqlClusterResourceId); // invoke the operation - CosmosDBForPostgreSqlClusterPatch patch = new CosmosDBForPostgreSqlClusterPatch() + CosmosDBForPostgreSqlClusterPatch patch = new CosmosDBForPostgreSqlClusterPatch { NodeVCores = 16, }; @@ -160,7 +128,7 @@ public async Task Update_ScaleOutAddNewWorkerNodes() CosmosDBForPostgreSqlClusterResource cosmosDBForPostgreSqlCluster = client.GetCosmosDBForPostgreSqlClusterResource(cosmosDBForPostgreSqlClusterResourceId); // invoke the operation - CosmosDBForPostgreSqlClusterPatch patch = new CosmosDBForPostgreSqlClusterPatch() + CosmosDBForPostgreSqlClusterPatch patch = new CosmosDBForPostgreSqlClusterPatch { NodeCount = 2, }; @@ -195,7 +163,7 @@ public async Task Update_ScaleUpStorage() CosmosDBForPostgreSqlClusterResource cosmosDBForPostgreSqlCluster = client.GetCosmosDBForPostgreSqlClusterResource(cosmosDBForPostgreSqlClusterResourceId); // invoke the operation - CosmosDBForPostgreSqlClusterPatch patch = new CosmosDBForPostgreSqlClusterPatch() + CosmosDBForPostgreSqlClusterPatch patch = new CosmosDBForPostgreSqlClusterPatch { NodeStorageQuotaInMb = 2097152, }; @@ -230,7 +198,7 @@ public async Task Update_UpdateMultipleConfigurationSettingsOfTheCluster() CosmosDBForPostgreSqlClusterResource cosmosDBForPostgreSqlCluster = client.GetCosmosDBForPostgreSqlClusterResource(cosmosDBForPostgreSqlClusterResourceId); // invoke the operation - CosmosDBForPostgreSqlClusterPatch patch = new CosmosDBForPostgreSqlClusterPatch() + CosmosDBForPostgreSqlClusterPatch patch = new CosmosDBForPostgreSqlClusterPatch { AdministratorLoginPassword = "newpassword", CoordinatorVCores = 16, @@ -268,9 +236,9 @@ public async Task Update_UpdateOrDefineMaintenanceWindow() CosmosDBForPostgreSqlClusterResource cosmosDBForPostgreSqlCluster = client.GetCosmosDBForPostgreSqlClusterResource(cosmosDBForPostgreSqlClusterResourceId); // invoke the operation - CosmosDBForPostgreSqlClusterPatch patch = new CosmosDBForPostgreSqlClusterPatch() + CosmosDBForPostgreSqlClusterPatch patch = new CosmosDBForPostgreSqlClusterPatch { - MaintenanceWindow = new CosmosDBForPostgreSqlMaintenanceWindow() + MaintenanceWindow = new CosmosDBForPostgreSqlMaintenanceWindow { CustomWindow = "Enabled", StartHour = 8, @@ -391,30 +359,5 @@ public async Task PromoteReadReplica_PromoteReadReplicaClusterToAnIndependentRea Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckCosmosDBForPostgreSqlClusterNameAvailability_CheckNameAvailability() - { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/CheckNameAvailability.json - // this example is just showing the usage of "Clusters_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - CosmosDBForPostgreSqlClusterNameAvailabilityContent content = new CosmosDBForPostgreSqlClusterNameAvailabilityContent("name1"); - CosmosDBForPostgreSqlClusterNameAvailabilityResult result = await subscriptionResource.CheckCosmosDBForPostgreSqlClusterNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } } } diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterServerCollection.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterServerCollection.cs index 241116b8db24a..6423caa4a1a78 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterServerCollection.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlClusterServerCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CosmosDBForPostgreSqlClusterServerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListServersOfTheCluster() + public async Task Get_GetTheServerOfCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ServerListByCluster.json - // this example is just showing the usage of "Servers_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListServersOfTheCluster() // get the collection of this CosmosDBForPostgreSqlClusterServerResource CosmosDBForPostgreSqlClusterServerCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlClusterServers(); - // invoke the operation and iterate over the result - await foreach (CosmosDBForPostgreSqlClusterServerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlClusterServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string serverName = "testcluster1-c"; + CosmosDBForPostgreSqlClusterServerResource result = await collection.GetAsync(serverName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlClusterServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheServerOfCluster() + public async Task GetAll_ListServersOfTheCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ServerListByCluster.json + // this example is just showing the usage of "Servers_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetTheServerOfCluster() // get the collection of this CosmosDBForPostgreSqlClusterServerResource CosmosDBForPostgreSqlClusterServerCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlClusterServers(); - // invoke the operation - string serverName = "testcluster1-c"; - CosmosDBForPostgreSqlClusterServerResource result = await collection.GetAsync(serverName); + // invoke the operation and iterate over the result + await foreach (CosmosDBForPostgreSqlClusterServerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlClusterServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlClusterServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlConfigurationCollection.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlConfigurationCollection.cs index 83303e436a85b..b58c2812263dc 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlConfigurationCollection.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CosmosDBForPostgreSqlConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConfigurationsOfTheCluster() + public async Task Get_GetConfigurationDetails() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationListByCluster.json - // this example is just showing the usage of "Configurations_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationGet.json + // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListConfigurationsOfTheCluster() // get the collection of this CosmosDBForPostgreSqlConfigurationResource CosmosDBForPostgreSqlConfigurationCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlConfigurations(); - // invoke the operation and iterate over the result - await foreach (CosmosDBForPostgreSqlConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string configurationName = "client_encoding"; + CosmosDBForPostgreSqlConfigurationResource result = await collection.GetAsync(configurationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetConfigurationDetails() + public async Task GetAll_ListConfigurationsOfTheCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationGet.json - // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationListByCluster.json + // this example is just showing the usage of "Configurations_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetConfigurationDetails() // get the collection of this CosmosDBForPostgreSqlConfigurationResource CosmosDBForPostgreSqlConfigurationCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlConfigurations(); - // invoke the operation - string configurationName = "client_encoding"; - CosmosDBForPostgreSqlConfigurationResource result = await collection.GetAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (CosmosDBForPostgreSqlConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlCoordinatorConfigurationCollection.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlCoordinatorConfigurationCollection.cs index ee1f539238a62..3ca639995f90d 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlCoordinatorConfigurationCollection.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlCoordinatorConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CosmosDBForPostgreSqlCoordinatorConfigurationCollect { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetConfigurationDetailsForCoordinator() + public async Task CreateOrUpdate_UpdateSingleConfigurationOfCoordinator() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationGetCoordinator.json - // this example is just showing the usage of "Configurations_GetCoordinator" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationUpdateCoordinator.json + // this example is just showing the usage of "Configurations_UpdateOnCoordinator" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetConfigurationDetailsForCoordinator() // invoke the operation string configurationName = "array_nulls"; - CosmosDBForPostgreSqlCoordinatorConfigurationResource result = await collection.GetAsync(configurationName); + CosmosDBForPostgreSqlServerConfigurationData data = new CosmosDBForPostgreSqlServerConfigurationData + { + Value = "on", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + CosmosDBForPostgreSqlCoordinatorConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetConfigurationDetailsForCoordinator() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetConfigurationDetailsForCoordinator() + public async Task Get_GetConfigurationDetailsForCoordinator() { // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationGetCoordinator.json // this example is just showing the usage of "Configurations_GetCoordinator" operation, for the dependent resources, they will have to be created separately. @@ -74,14 +79,18 @@ public async Task Exists_GetConfigurationDetailsForCoordinator() // invoke the operation string configurationName = "array_nulls"; - bool result = await collection.ExistsAsync(configurationName); + CosmosDBForPostgreSqlCoordinatorConfigurationResource result = await collection.GetAsync(configurationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetConfigurationDetailsForCoordinator() + public async Task Exists_GetConfigurationDetailsForCoordinator() { // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationGetCoordinator.json // this example is just showing the usage of "Configurations_GetCoordinator" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +113,17 @@ public async Task GetIfExists_GetConfigurationDetailsForCoordinator() // invoke the operation string configurationName = "array_nulls"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - CosmosDBForPostgreSqlCoordinatorConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateSingleConfigurationOfCoordinator() + public async Task GetIfExists_GetConfigurationDetailsForCoordinator() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationUpdateCoordinator.json - // this example is just showing the usage of "Configurations_UpdateOnCoordinator" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationGetCoordinator.json + // this example is just showing the usage of "Configurations_GetCoordinator" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,18 +143,21 @@ public async Task CreateOrUpdate_UpdateSingleConfigurationOfCoordinator() // invoke the operation string configurationName = "array_nulls"; - CosmosDBForPostgreSqlServerConfigurationData data = new CosmosDBForPostgreSqlServerConfigurationData() - { - Value = "on", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - CosmosDBForPostgreSqlCoordinatorConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + CosmosDBForPostgreSqlCoordinatorConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlCoordinatorConfigurationResource.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlCoordinatorConfigurationResource.cs index ca6c13154a612..486b525a52889 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlCoordinatorConfigurationResource.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlCoordinatorConfigurationResource.cs @@ -68,7 +68,7 @@ public async Task Update_UpdateSingleConfigurationOfCoordinator() CosmosDBForPostgreSqlCoordinatorConfigurationResource cosmosDBForPostgreSqlCoordinatorConfiguration = client.GetCosmosDBForPostgreSqlCoordinatorConfigurationResource(cosmosDBForPostgreSqlCoordinatorConfigurationResourceId); // invoke the operation - CosmosDBForPostgreSqlServerConfigurationData data = new CosmosDBForPostgreSqlServerConfigurationData() + CosmosDBForPostgreSqlServerConfigurationData data = new CosmosDBForPostgreSqlServerConfigurationData { Value = "on", }; diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlFirewallRuleCollection.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlFirewallRuleCollection.cs index b7136dc6961d2..670f80e9d8025 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlFirewallRuleCollection.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlFirewallRuleCollection.cs @@ -88,10 +88,10 @@ public async Task Get_GetTheFirewallRuleOfTheCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheFirewallRuleOfTheCluster() + public async Task GetAll_ListFirewallRulesOfTheCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/FirewallRuleListByCluster.json + // this example is just showing the usage of "FirewallRules_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_GetTheFirewallRuleOfTheCluster() // get the collection of this CosmosDBForPostgreSqlFirewallRuleResource CosmosDBForPostgreSqlFirewallRuleCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlFirewallRules(); - // invoke the operation - string firewallRuleName = "rule1"; - bool result = await collection.ExistsAsync(firewallRuleName); + // invoke the operation and iterate over the result + await foreach (CosmosDBForPostgreSqlFirewallRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlFirewallRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheFirewallRuleOfTheCluster() + public async Task Exists_GetTheFirewallRuleOfTheCluster() { // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/FirewallRuleGet.json // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_GetTheFirewallRuleOfTheCluster() // invoke the operation string firewallRuleName = "rule1"; - NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); - CosmosDBForPostgreSqlFirewallRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(firewallRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFirewallRulesOfTheCluster() + public async Task GetIfExists_GetTheFirewallRuleOfTheCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/FirewallRuleListByCluster.json - // this example is just showing the usage of "FirewallRules_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_ListFirewallRulesOfTheCluster() // get the collection of this CosmosDBForPostgreSqlFirewallRuleResource CosmosDBForPostgreSqlFirewallRuleCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlFirewallRules(); - // invoke the operation and iterate over the result - await foreach (CosmosDBForPostgreSqlFirewallRuleResource item in collection.GetAllAsync()) + // invoke the operation + string firewallRuleName = "rule1"; + NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); + CosmosDBForPostgreSqlFirewallRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlFirewallRuleData resourceData = item.Data; + CosmosDBForPostgreSqlFirewallRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlFirewallRuleResource.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlFirewallRuleResource.cs index 86707c6655763..c2a194a8e86e4 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlFirewallRuleResource.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlFirewallRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBForPostgreSqlFirewallRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAFirewallRuleOfTheCluster() + public async Task Get_GetTheFirewallRuleOfTheCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/FirewallRuleCreate.json - // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Update_CreateAFirewallRuleOfTheCluster() CosmosDBForPostgreSqlFirewallRuleResource cosmosDBForPostgreSqlFirewallRule = client.GetCosmosDBForPostgreSqlFirewallRuleResource(cosmosDBForPostgreSqlFirewallRuleResourceId); // invoke the operation - CosmosDBForPostgreSqlFirewallRuleData data = new CosmosDBForPostgreSqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); - ArmOperation lro = await cosmosDBForPostgreSqlFirewallRule.UpdateAsync(WaitUntil.Completed, data); - CosmosDBForPostgreSqlFirewallRuleResource result = lro.Value; + CosmosDBForPostgreSqlFirewallRuleResource result = await cosmosDBForPostgreSqlFirewallRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -78,10 +76,10 @@ public async Task Delete_DeleteTheFirewallRuleOfTheCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheFirewallRuleOfTheCluster() + public async Task Update_CreateAFirewallRuleOfTheCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/FirewallRuleCreate.json + // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,7 +96,9 @@ public async Task Get_GetTheFirewallRuleOfTheCluster() CosmosDBForPostgreSqlFirewallRuleResource cosmosDBForPostgreSqlFirewallRule = client.GetCosmosDBForPostgreSqlFirewallRuleResource(cosmosDBForPostgreSqlFirewallRuleResourceId); // invoke the operation - CosmosDBForPostgreSqlFirewallRuleResource result = await cosmosDBForPostgreSqlFirewallRule.GetAsync(); + CosmosDBForPostgreSqlFirewallRuleData data = new CosmosDBForPostgreSqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await cosmosDBForPostgreSqlFirewallRule.UpdateAsync(WaitUntil.Completed, data); + CosmosDBForPostgreSqlFirewallRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlNodeConfigurationCollection.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlNodeConfigurationCollection.cs index b9df39cb3942b..255442c3ee0be 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlNodeConfigurationCollection.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlNodeConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CosmosDBForPostgreSqlNodeConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetConfigurationDetailsForNode() + public async Task CreateOrUpdate_UpdateSingleConfigurationOfNodes() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationGetNode.json - // this example is just showing the usage of "Configurations_GetNode" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationUpdateNode.json + // this example is just showing the usage of "Configurations_UpdateOnNode" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetConfigurationDetailsForNode() // invoke the operation string configurationName = "array_nulls"; - CosmosDBForPostgreSqlNodeConfigurationResource result = await collection.GetAsync(configurationName); + CosmosDBForPostgreSqlServerConfigurationData data = new CosmosDBForPostgreSqlServerConfigurationData + { + Value = "off", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + CosmosDBForPostgreSqlNodeConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetConfigurationDetailsForNode() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetConfigurationDetailsForNode() + public async Task Get_GetConfigurationDetailsForNode() { // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationGetNode.json // this example is just showing the usage of "Configurations_GetNode" operation, for the dependent resources, they will have to be created separately. @@ -74,14 +79,18 @@ public async Task Exists_GetConfigurationDetailsForNode() // invoke the operation string configurationName = "array_nulls"; - bool result = await collection.ExistsAsync(configurationName); + CosmosDBForPostgreSqlNodeConfigurationResource result = await collection.GetAsync(configurationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetConfigurationDetailsForNode() + public async Task Exists_GetConfigurationDetailsForNode() { // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationGetNode.json // this example is just showing the usage of "Configurations_GetNode" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +113,17 @@ public async Task GetIfExists_GetConfigurationDetailsForNode() // invoke the operation string configurationName = "array_nulls"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - CosmosDBForPostgreSqlNodeConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateSingleConfigurationOfNodes() + public async Task GetIfExists_GetConfigurationDetailsForNode() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationUpdateNode.json - // this example is just showing the usage of "Configurations_UpdateOnNode" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ConfigurationGetNode.json + // this example is just showing the usage of "Configurations_GetNode" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,18 +143,21 @@ public async Task CreateOrUpdate_UpdateSingleConfigurationOfNodes() // invoke the operation string configurationName = "array_nulls"; - CosmosDBForPostgreSqlServerConfigurationData data = new CosmosDBForPostgreSqlServerConfigurationData() - { - Value = "off", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - CosmosDBForPostgreSqlNodeConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + CosmosDBForPostgreSqlNodeConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlNodeConfigurationResource.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlNodeConfigurationResource.cs index 43536b1ca751f..76c846574ac19 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlNodeConfigurationResource.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlNodeConfigurationResource.cs @@ -68,7 +68,7 @@ public async Task Update_UpdateSingleConfigurationOfNodes() CosmosDBForPostgreSqlNodeConfigurationResource cosmosDBForPostgreSqlNodeConfiguration = client.GetCosmosDBForPostgreSqlNodeConfigurationResource(cosmosDBForPostgreSqlNodeConfigurationResourceId); // invoke the operation - CosmosDBForPostgreSqlServerConfigurationData data = new CosmosDBForPostgreSqlServerConfigurationData() + CosmosDBForPostgreSqlServerConfigurationData data = new CosmosDBForPostgreSqlServerConfigurationData { Value = "off", }; diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateEndpointConnectionCollection.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateEndpointConnectionCollection.cs index 77e212f3588d2..d7e03bf5ea3ab 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateEndpointConnectionCollection.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CosmosDBForPostgreSqlPrivateEndpointConnectionCollec { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnACluster() + public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionsListByCluster.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionCreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnACluster() // this example assumes you already have this CosmosDBForPostgreSqlClusterResource created on azure // for more information of creating CosmosDBForPostgreSqlClusterResource, please refer to the document of CosmosDBForPostgreSqlClusterResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestResourceGroup"; + string resourceGroupName = "TestGroup"; string clusterName = "testcluster"; ResourceIdentifier cosmosDBForPostgreSqlClusterResourceId = CosmosDBForPostgreSqlClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); CosmosDBForPostgreSqlClusterResource cosmosDBForPostgreSqlCluster = client.GetCosmosDBForPostgreSqlClusterResource(cosmosDBForPostgreSqlClusterResourceId); @@ -39,17 +39,24 @@ public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnACluster() // get the collection of this CosmosDBForPostgreSqlPrivateEndpointConnectionResource CosmosDBForPostgreSqlPrivateEndpointConnectionCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (CosmosDBForPostgreSqlPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + CosmosDBForPostgreSqlPrivateEndpointConnectionData data = new CosmosDBForPostgreSqlPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new CosmosDBForPostgreSqlPrivateLinkServiceConnectionState + { + Status = CosmosDBForPostgreSqlPrivateEndpointServiceConnectionStatus.Approved, + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + CosmosDBForPostgreSqlPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnACluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionsGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionsListByCluster.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +108,7 @@ public async Task Exists_GetsPrivateEndpointConnection() // this example assumes you already have this CosmosDBForPostgreSqlClusterResource created on azure // for more information of creating CosmosDBForPostgreSqlClusterResource, please refer to the document of CosmosDBForPostgreSqlClusterResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; + string resourceGroupName = "TestResourceGroup"; string clusterName = "testcluster"; ResourceIdentifier cosmosDBForPostgreSqlClusterResourceId = CosmosDBForPostgreSqlClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); CosmosDBForPostgreSqlClusterResource cosmosDBForPostgreSqlCluster = client.GetCosmosDBForPostgreSqlClusterResource(cosmosDBForPostgreSqlClusterResourceId); @@ -109,16 +116,22 @@ public async Task Exists_GetsPrivateEndpointConnection() // get the collection of this CosmosDBForPostgreSqlPrivateEndpointConnectionResource CosmosDBForPostgreSqlPrivateEndpointConnectionCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (CosmosDBForPostgreSqlPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task Exists_GetsPrivateEndpointConnection() { // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionsGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - CosmosDBForPostgreSqlPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionWithAGivenName() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionCreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionsGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionWith // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - CosmosDBForPostgreSqlPrivateEndpointConnectionData data = new CosmosDBForPostgreSqlPrivateEndpointConnectionData() - { - ConnectionState = new CosmosDBForPostgreSqlPrivateLinkServiceConnectionState() - { - Status = CosmosDBForPostgreSqlPrivateEndpointServiceConnectionStatus.Approved, - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - CosmosDBForPostgreSqlPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + CosmosDBForPostgreSqlPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateEndpointConnectionResource.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateEndpointConnectionResource.cs index ccf7e386dcbbe..0db085f711157 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateEndpointConnectionResource.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionWithAGivenName() + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionCreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionsDelete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionWithAGivenNa CosmosDBForPostgreSqlPrivateEndpointConnectionResource cosmosDBForPostgreSqlPrivateEndpointConnection = client.GetCosmosDBForPostgreSqlPrivateEndpointConnectionResource(cosmosDBForPostgreSqlPrivateEndpointConnectionResourceId); // invoke the operation - CosmosDBForPostgreSqlPrivateEndpointConnectionData data = new CosmosDBForPostgreSqlPrivateEndpointConnectionData() - { - ConnectionState = new CosmosDBForPostgreSqlPrivateLinkServiceConnectionState() - { - Status = CosmosDBForPostgreSqlPrivateEndpointServiceConnectionStatus.Approved, - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await cosmosDBForPostgreSqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - CosmosDBForPostgreSqlPrivateEndpointConnectionResource result = lro.Value; + await cosmosDBForPostgreSqlPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionsDelete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateEndpointConnectionCreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() CosmosDBForPostgreSqlPrivateEndpointConnectionResource cosmosDBForPostgreSqlPrivateEndpointConnection = client.GetCosmosDBForPostgreSqlPrivateEndpointConnectionResource(cosmosDBForPostgreSqlPrivateEndpointConnectionResourceId); // invoke the operation - await cosmosDBForPostgreSqlPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + CosmosDBForPostgreSqlPrivateEndpointConnectionData data = new CosmosDBForPostgreSqlPrivateEndpointConnectionData + { + ConnectionState = new CosmosDBForPostgreSqlPrivateLinkServiceConnectionState + { + Status = CosmosDBForPostgreSqlPrivateEndpointServiceConnectionStatus.Approved, + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await cosmosDBForPostgreSqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + CosmosDBForPostgreSqlPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateLinkResourceCollection.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateLinkResourceCollection.cs index eca0f92c473c0..782b94a02e04a 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateLinkResourceCollection.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CosmosDBForPostgreSqlPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsThePrivateLinkResourcesForCluster() + public async Task Get_GetsAPrivateLinkResourceForCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateLinkResourceListByCluster.json - // this example is just showing the usage of "PrivateLinkResources_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateLinkResourcesGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task GetAll_GetsThePrivateLinkResourcesForCluster() // this example assumes you already have this CosmosDBForPostgreSqlClusterResource created on azure // for more information of creating CosmosDBForPostgreSqlClusterResource, please refer to the document of CosmosDBForPostgreSqlClusterResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestResourceGroup"; + string resourceGroupName = "TestGroup"; string clusterName = "testcluster"; ResourceIdentifier cosmosDBForPostgreSqlClusterResourceId = CosmosDBForPostgreSqlClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); CosmosDBForPostgreSqlClusterResource cosmosDBForPostgreSqlCluster = client.GetCosmosDBForPostgreSqlClusterResource(cosmosDBForPostgreSqlClusterResourceId); @@ -38,25 +38,23 @@ public async Task GetAll_GetsThePrivateLinkResourcesForCluster() // get the collection of this CosmosDBForPostgreSqlPrivateLinkResource CosmosDBForPostgreSqlPrivateLinkResourceCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (CosmosDBForPostgreSqlPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateLinkResourceName = "plr"; + CosmosDBForPostgreSqlPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAPrivateLinkResourceForCluster() + public async Task GetAll_GetsThePrivateLinkResourcesForCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateLinkResourcesGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/PrivateLinkResourceListByCluster.json + // this example is just showing the usage of "PrivateLinkResources_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,7 +64,7 @@ public async Task Get_GetsAPrivateLinkResourceForCluster() // this example assumes you already have this CosmosDBForPostgreSqlClusterResource created on azure // for more information of creating CosmosDBForPostgreSqlClusterResource, please refer to the document of CosmosDBForPostgreSqlClusterResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; + string resourceGroupName = "TestResourceGroup"; string clusterName = "testcluster"; ResourceIdentifier cosmosDBForPostgreSqlClusterResourceId = CosmosDBForPostgreSqlClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); CosmosDBForPostgreSqlClusterResource cosmosDBForPostgreSqlCluster = client.GetCosmosDBForPostgreSqlClusterResource(cosmosDBForPostgreSqlClusterResourceId); @@ -74,15 +72,17 @@ public async Task Get_GetsAPrivateLinkResourceForCluster() // get the collection of this CosmosDBForPostgreSqlPrivateLinkResource CosmosDBForPostgreSqlPrivateLinkResourceCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlPrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "plr"; - CosmosDBForPostgreSqlPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (CosmosDBForPostgreSqlPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlRoleCollection.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlRoleCollection.cs index 2a1758be0ecff..1dfeed106c3e6 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlRoleCollection.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlRoleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CosmosDBForPostgreSqlRoleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheRoleOfTheCluster() + public async Task CreateOrUpdate_RoleCreate() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleGet.json - // this example is just showing the usage of "Roles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleCreate.json + // this example is just showing the usage of "Roles_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,9 @@ public async Task Get_GetTheRoleOfTheCluster() // invoke the operation string roleName = "role1"; - CosmosDBForPostgreSqlRoleResource result = await collection.GetAsync(roleName); + CosmosDBForPostgreSqlRoleData data = new CosmosDBForPostgreSqlRoleData("password"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleName, data); + CosmosDBForPostgreSqlRoleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_GetTheRoleOfTheCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheRoleOfTheCluster() + public async Task Get_GetTheRoleOfTheCluster() { // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleGet.json // this example is just showing the usage of "Roles_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +76,21 @@ public async Task Exists_GetTheRoleOfTheCluster() // invoke the operation string roleName = "role1"; - bool result = await collection.ExistsAsync(roleName); + CosmosDBForPostgreSqlRoleResource result = await collection.GetAsync(roleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlRoleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheRoleOfTheCluster() + public async Task GetAll_RoleList() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleGet.json - // this example is just showing the usage of "Roles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleListByCluster.json + // this example is just showing the usage of "Roles_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +108,25 @@ public async Task GetIfExists_GetTheRoleOfTheCluster() // get the collection of this CosmosDBForPostgreSqlRoleResource CosmosDBForPostgreSqlRoleCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlRoles(); - // invoke the operation - string roleName = "role1"; - NullableResponse response = await collection.GetIfExistsAsync(roleName); - CosmosDBForPostgreSqlRoleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CosmosDBForPostgreSqlRoleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlRoleData resourceData = result.Data; + CosmosDBForPostgreSqlRoleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RoleCreate() + public async Task Exists_GetTheRoleOfTheCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleCreate.json - // this example is just showing the usage of "Roles_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleGet.json + // this example is just showing the usage of "Roles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,23 +146,17 @@ public async Task CreateOrUpdate_RoleCreate() // invoke the operation string roleName = "role1"; - CosmosDBForPostgreSqlRoleData data = new CosmosDBForPostgreSqlRoleData("password"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleName, data); - CosmosDBForPostgreSqlRoleResource result = lro.Value; + bool result = await collection.ExistsAsync(roleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlRoleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RoleList() + public async Task GetIfExists_GetTheRoleOfTheCluster() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleListByCluster.json - // this example is just showing the usage of "Roles_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleGet.json + // this example is just showing the usage of "Roles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_RoleList() // get the collection of this CosmosDBForPostgreSqlRoleResource CosmosDBForPostgreSqlRoleCollection collection = cosmosDBForPostgreSqlCluster.GetCosmosDBForPostgreSqlRoles(); - // invoke the operation and iterate over the result - await foreach (CosmosDBForPostgreSqlRoleResource item in collection.GetAllAsync()) + // invoke the operation + string roleName = "role1"; + NullableResponse response = await collection.GetIfExistsAsync(roleName); + CosmosDBForPostgreSqlRoleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlRoleData resourceData = item.Data; + CosmosDBForPostgreSqlRoleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlRoleResource.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlRoleResource.cs index 221003efb6c3f..1677add8eacd7 100644 --- a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlRoleResource.cs +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_CosmosDBForPostgreSqlRoleResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetTheRoleOfTheCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RoleCreate() + public async Task Delete_RoleDelete() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleCreate.json - // this example is just showing the usage of "Roles_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleDelete.json + // this example is just showing the usage of "Roles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,23 +68,17 @@ public async Task Update_RoleCreate() CosmosDBForPostgreSqlRoleResource cosmosDBForPostgreSqlRole = client.GetCosmosDBForPostgreSqlRoleResource(cosmosDBForPostgreSqlRoleResourceId); // invoke the operation - CosmosDBForPostgreSqlRoleData data = new CosmosDBForPostgreSqlRoleData("password"); - ArmOperation lro = await cosmosDBForPostgreSqlRole.UpdateAsync(WaitUntil.Completed, data); - CosmosDBForPostgreSqlRoleResource result = lro.Value; + await cosmosDBForPostgreSqlRole.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CosmosDBForPostgreSqlRoleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RoleDelete() + public async Task Update_RoleCreate() { - // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleDelete.json - // this example is just showing the usage of "Roles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/RoleCreate.json + // this example is just showing the usage of "Roles_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +95,15 @@ public async Task Delete_RoleDelete() CosmosDBForPostgreSqlRoleResource cosmosDBForPostgreSqlRole = client.GetCosmosDBForPostgreSqlRoleResource(cosmosDBForPostgreSqlRoleResourceId); // invoke the operation - await cosmosDBForPostgreSqlRole.DeleteAsync(WaitUntil.Completed); + CosmosDBForPostgreSqlRoleData data = new CosmosDBForPostgreSqlRoleData("password"); + ArmOperation lro = await cosmosDBForPostgreSqlRole.UpdateAsync(WaitUntil.Completed, data); + CosmosDBForPostgreSqlRoleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlRoleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..1e6a40e5e4aca --- /dev/null +++ b/sdk/cosmosdbforpostgresql/Azure.ResourceManager.CosmosDBForPostgreSql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,76 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.CosmosDBForPostgreSql.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.CosmosDBForPostgreSql.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCosmosDBForPostgreSqlClusters_ListAllTheClusters() + { + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/ClusterList.json + // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (CosmosDBForPostgreSqlClusterResource item in subscriptionResource.GetCosmosDBForPostgreSqlClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CosmosDBForPostgreSqlClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckCosmosDBForPostgreSqlClusterNameAvailability_CheckNameAvailability() + { + // Generated from example definition: specification/postgresqlhsc/resource-manager/Microsoft.DBforPostgreSQL/stable/2022-11-08/examples/CheckNameAvailability.json + // this example is just showing the usage of "Clusters_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + CosmosDBForPostgreSqlClusterNameAvailabilityContent content = new CosmosDBForPostgreSqlClusterNameAvailabilityContent("name1"); + CosmosDBForPostgreSqlClusterNameAvailabilityResult result = await subscriptionResource.CheckCosmosDBForPostgreSqlClusterNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementAlertCollection.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementAlertCollection.cs index f95e972798e61..9c94e7ca736fd 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementAlertCollection.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementAlertCollection.cs @@ -15,6 +15,60 @@ namespace Azure.ResourceManager.CostManagement.Samples { public partial class Sample_CostManagementAlertCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_SingleResourceGroupAlerts() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/SingleResourceGroupAlert.json + // this example is just showing the usage of "Alerts_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this CostManagementAlertResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer"; + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); + + // invoke the operation + string alertId = "22222222-2222-2222-2222-222222222222"; + CostManagementAlertResource result = await collection.GetAsync(alertId); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_SingleSubscriptionAlerts() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/SingleSubscriptionAlert.json + // this example is just showing the usage of "Alerts_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this CostManagementAlertResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); + + // invoke the operation + string alertId = "22222222-2222-2222-2222-222222222222"; + CostManagementAlertResource result = await collection.GetAsync(alertId); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_BillingAccountAlerts() @@ -27,13 +81,9 @@ public async Task GetAll_BillingAccountAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource string scope = "providers/Microsoft.Billing/billingAccounts/12345:6789"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (CostManagementAlertResource item in collection.GetAllAsync()) @@ -60,13 +110,9 @@ public async Task GetAll_BillingProfileAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource string scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (CostManagementAlertResource item in collection.GetAllAsync()) @@ -93,13 +139,9 @@ public async Task GetAll_DepartmentAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource string scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/departments/123"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (CostManagementAlertResource item in collection.GetAllAsync()) @@ -126,13 +168,9 @@ public async Task GetAll_EnrollmentAccountAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource string scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/enrollmentAccounts/456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (CostManagementAlertResource item in collection.GetAllAsync()) @@ -159,13 +197,9 @@ public async Task GetAll_InvoiceSectionAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource string scope = "providers/Microsoft.Billing/billingAccounts/12345:6789/billingProfiles/13579/invoiceSections/9876"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (CostManagementAlertResource item in collection.GetAllAsync()) @@ -192,13 +226,9 @@ public async Task GetAll_ResourceGroupAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (CostManagementAlertResource item in collection.GetAllAsync()) @@ -225,13 +255,9 @@ public async Task GetAll_SubscriptionAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (CostManagementAlertResource item in collection.GetAllAsync()) @@ -248,7 +274,7 @@ public async Task GetAll_SubscriptionAlerts() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SingleResourceGroupAlerts() + public async Task Exists_SingleResourceGroupAlerts() { // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/SingleResourceGroupAlert.json // this example is just showing the usage of "Alerts_Get" operation, for the dependent resources, they will have to be created separately. @@ -258,30 +284,22 @@ public async Task Get_SingleResourceGroupAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation string alertId = "22222222-2222-2222-2222-222222222222"; - CostManagementAlertResource result = await collection.GetAsync(alertId); + bool result = await collection.ExistsAsync(alertId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SingleResourceGroupAlerts() + public async Task Exists_SingleSubscriptionAlerts() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/SingleResourceGroupAlert.json + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/SingleSubscriptionAlert.json // this example is just showing the usage of "Alerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -289,13 +307,9 @@ public async Task Exists_SingleResourceGroupAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation string alertId = "22222222-2222-2222-2222-222222222222"; @@ -316,13 +330,9 @@ public async Task GetIfExists_SingleResourceGroupAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ScreenSharingTest-peer"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation string alertId = "22222222-2222-2222-2222-222222222222"; @@ -343,64 +353,6 @@ public async Task GetIfExists_SingleResourceGroupAlerts() } } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_SingleSubscriptionAlerts() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/SingleSubscriptionAlert.json - // this example is just showing the usage of "Alerts_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this CostManagementAlertResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); - - // invoke the operation - string alertId = "22222222-2222-2222-2222-222222222222"; - CostManagementAlertResource result = await collection.GetAsync(alertId); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_SingleSubscriptionAlerts() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/SingleSubscriptionAlert.json - // this example is just showing the usage of "Alerts_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this CostManagementAlertResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); - - // invoke the operation - string alertId = "22222222-2222-2222-2222-222222222222"; - bool result = await collection.ExistsAsync(alertId); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetIfExists_SingleSubscriptionAlerts() @@ -413,13 +365,9 @@ public async Task GetIfExists_SingleSubscriptionAlerts() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementAlertResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementAlertCollection collection = client.GetCostManagementAlerts(scopeId); + CostManagementAlertCollection collection = client.GetCostManagementAlerts(new ResourceIdentifier(scope)); // invoke the operation string alertId = "22222222-2222-2222-2222-222222222222"; diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementAlertResource.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementAlertResource.cs index cd53e4f89997e..4a7317e069fa1 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementAlertResource.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementAlertResource.cs @@ -94,7 +94,7 @@ public async Task Update_PatchResourceGroupAlerts() CostManagementAlertResource costManagementAlert = client.GetCostManagementAlertResource(costManagementAlertResourceId); // invoke the operation - CostManagementAlertPatch patch = new CostManagementAlertPatch() + CostManagementAlertPatch patch = new CostManagementAlertPatch { Status = CostManagementAlertStatus.Dismissed, }; @@ -127,7 +127,7 @@ public async Task Update_PatchSubscriptionAlerts() CostManagementAlertResource costManagementAlert = client.GetCostManagementAlertResource(costManagementAlertResourceId); // invoke the operation - CostManagementAlertPatch patch = new CostManagementAlertPatch() + CostManagementAlertPatch patch = new CostManagementAlertPatch { Status = CostManagementAlertStatus.Dismissed, }; @@ -139,67 +139,5 @@ public async Task Update_PatchSubscriptionAlerts() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCostManagementAlerts_ExternalBillingAccountAlerts() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExternalBillingAccountAlerts.json - // this example is just showing the usage of "Alerts_ListExternal" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation and iterate over the result - ExternalCloudProviderType externalCloudProviderType = ExternalCloudProviderType.ExternalBillingAccounts; - string externalCloudProviderId = "100"; - await foreach (CostManagementAlertResource item in tenantResource.GetCostManagementAlertsAsync(externalCloudProviderType, externalCloudProviderId)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementAlertData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCostManagementAlerts_ExternalSubscriptionAlerts() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExternalSubscriptionAlerts.json - // this example is just showing the usage of "Alerts_ListExternal" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation and iterate over the result - ExternalCloudProviderType externalCloudProviderType = ExternalCloudProviderType.ExternalSubscriptions; - string externalCloudProviderId = "100"; - await foreach (CostManagementAlertResource item in tenantResource.GetCostManagementAlertsAsync(externalCloudProviderType, externalCloudProviderId)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementAlertData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementExportCollection.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementExportCollection.cs index 4b5466a35c47b..40f8b3d48d153 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementExportCollection.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementExportCollection.cs @@ -18,225 +18,320 @@ public partial class Sample_CostManagementExportCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExportsGetByBillingAccount() + public async Task CreateOrUpdate_ExportCreateOrUpdateByBillingAccount() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetByBillingAccount.json - // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateByBillingAccount.json + // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "providers/Microsoft.Billing/billingAccounts/123456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (CostManagementExportResource item in collection.GetAllAsync()) + // invoke the operation + string exportName = "TestExport"; + CostManagementExportData data = new CostManagementExportData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Format = ExportFormatType.Csv, + DeliveryInfoDestination = new ExportDeliveryDestination("exports") + { + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), + RootFolderPath = "ad-hoc", + }, + Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) + { + DataSet = new ExportDataset + { + Granularity = GranularityType.Daily, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, + }, + }, + Schedule = new ExportSchedule + { + Status = ExportScheduleStatusType.Active, + Recurrence = ExportScheduleRecurrenceType.Weekly, + RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) + { + To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); + CostManagementExportResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExportsGetByDepartment() + public async Task CreateOrUpdate_ExportCreateOrUpdateByDepartment() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetByDepartment.json - // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateByDepartment.json + // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/123"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (CostManagementExportResource item in collection.GetAllAsync()) + // invoke the operation + string exportName = "TestExport"; + CostManagementExportData data = new CostManagementExportData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Format = ExportFormatType.Csv, + DeliveryInfoDestination = new ExportDeliveryDestination("exports") + { + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), + RootFolderPath = "ad-hoc", + }, + Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) + { + DataSet = new ExportDataset + { + Granularity = GranularityType.Daily, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, + }, + }, + Schedule = new ExportSchedule + { + Status = ExportScheduleStatusType.Active, + Recurrence = ExportScheduleRecurrenceType.Weekly, + RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) + { + To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); + CostManagementExportResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExportsGetByEnrollmentAccount() + public async Task CreateOrUpdate_ExportCreateOrUpdateByEnrollmentAccount() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetByEnrollmentAccount.json - // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateByEnrollmentAccount.json + // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (CostManagementExportResource item in collection.GetAllAsync()) + // invoke the operation + string exportName = "TestExport"; + CostManagementExportData data = new CostManagementExportData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Format = ExportFormatType.Csv, + DeliveryInfoDestination = new ExportDeliveryDestination("exports") + { + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), + RootFolderPath = "ad-hoc", + }, + Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) + { + DataSet = new ExportDataset + { + Granularity = GranularityType.Daily, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, + }, + }, + Schedule = new ExportSchedule + { + Status = ExportScheduleStatusType.Active, + Recurrence = ExportScheduleRecurrenceType.Weekly, + RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) + { + To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); + CostManagementExportResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExportsGetByManagementGroup() + public async Task CreateOrUpdate_ExportCreateOrUpdateByManagementGroup() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetByManagementGroup.json - // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateByManagementGroup.json + // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "providers/Microsoft.Management/managementGroups/TestMG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (CostManagementExportResource item in collection.GetAllAsync()) + // invoke the operation + string exportName = "TestExport"; + CostManagementExportData data = new CostManagementExportData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Format = ExportFormatType.Csv, + DeliveryInfoDestination = new ExportDeliveryDestination("exports") + { + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), + RootFolderPath = "ad-hoc", + }, + Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) + { + DataSet = new ExportDataset + { + Granularity = GranularityType.Daily, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, + }, + }, + Schedule = new ExportSchedule + { + Status = ExportScheduleStatusType.Active, + Recurrence = ExportScheduleRecurrenceType.Weekly, + RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) + { + To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); + CostManagementExportResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExportsGetByResourceGroup() + public async Task CreateOrUpdate_ExportCreateOrUpdateByResourceGroup() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetByResourceGroup.json - // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateByResourceGroup.json + // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (CostManagementExportResource item in collection.GetAllAsync()) + // invoke the operation + string exportName = "TestExport"; + CostManagementExportData data = new CostManagementExportData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Format = ExportFormatType.Csv, + DeliveryInfoDestination = new ExportDeliveryDestination("exports") + { + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), + RootFolderPath = "ad-hoc", + }, + Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) + { + DataSet = new ExportDataset + { + Granularity = GranularityType.Daily, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, + }, + }, + Schedule = new ExportSchedule + { + Status = ExportScheduleStatusType.Active, + Recurrence = ExportScheduleRecurrenceType.Weekly, + RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) + { + To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); + CostManagementExportResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExportsGetBySubscription() + public async Task CreateOrUpdate_ExportCreateOrUpdateBySubscription() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetBySubscription.json - // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateBySubscription.json + // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (CostManagementExportResource item in collection.GetAllAsync()) + // invoke the operation + string exportName = "TestExport"; + CostManagementExportData data = new CostManagementExportData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ExportGetByBillingAccount() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByBillingAccount.json - // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/123456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); - - // invoke the operation - string exportName = "TestExport"; - CostManagementExportResource result = await collection.GetAsync(exportName); + Format = ExportFormatType.Csv, + DeliveryInfoDestination = new ExportDeliveryDestination("exports") + { + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), + RootFolderPath = "ad-hoc", + }, + Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) + { + DataSet = new ExportDataset + { + Granularity = GranularityType.Daily, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, + }, + }, + Schedule = new ExportSchedule + { + Status = ExportScheduleStatusType.Active, + Recurrence = ExportScheduleRecurrenceType.Weekly, + RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) + { + To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); + CostManagementExportResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -247,7 +342,7 @@ public async Task Get_ExportGetByBillingAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExportGetByBillingAccount() + public async Task Get_ExportGetByBillingAccount() { // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByBillingAccount.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. @@ -257,26 +352,26 @@ public async Task Exists_ExportGetByBillingAccount() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "providers/Microsoft.Billing/billingAccounts/123456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - bool result = await collection.ExistsAsync(exportName); + CostManagementExportResource result = await collection.GetAsync(exportName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExportGetByBillingAccount() + public async Task Get_ExportGetByDepartment() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByBillingAccount.json + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByDepartment.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -284,38 +379,26 @@ public async Task GetIfExists_ExportGetByBillingAccount() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/123456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - NullableResponse response = await collection.GetIfExistsAsync(exportName); - CostManagementExportResource result = response.HasValue ? response.Value : null; + CostManagementExportResource result = await collection.GetAsync(exportName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExportGetByDepartment() + public async Task Get_ExportGetByEnrollmentAccount() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByDepartment.json + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByEnrollmentAccount.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -323,13 +406,9 @@ public async Task Get_ExportGetByDepartment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; @@ -344,9 +423,9 @@ public async Task Get_ExportGetByDepartment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExportGetByDepartment() + public async Task Get_ExportGetByManagementGroup() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByDepartment.json + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByManagementGroup.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -354,26 +433,26 @@ public async Task Exists_ExportGetByDepartment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "providers/Microsoft.Management/managementGroups/TestMG"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - bool result = await collection.ExistsAsync(exportName); + CostManagementExportResource result = await collection.GetAsync(exportName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExportGetByDepartment() + public async Task Get_ExportGetByResourceGroup() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByDepartment.json + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByResourceGroup.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -381,38 +460,26 @@ public async Task GetIfExists_ExportGetByDepartment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - NullableResponse response = await collection.GetIfExistsAsync(exportName); - CostManagementExportResource result = response.HasValue ? response.Value : null; + CostManagementExportResource result = await collection.GetAsync(exportName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExportGetByEnrollmentAccount() + public async Task Get_ExportGetBySubscription() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByEnrollmentAccount.json + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetBySubscription.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -420,13 +487,9 @@ public async Task Get_ExportGetByEnrollmentAccount() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; @@ -441,203 +504,206 @@ public async Task Get_ExportGetByEnrollmentAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExportGetByEnrollmentAccount() + public async Task GetAll_ExportsGetByBillingAccount() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByEnrollmentAccount.json - // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetByBillingAccount.json + // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "providers/Microsoft.Billing/billingAccounts/123456"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - // invoke the operation - string exportName = "TestExport"; - bool result = await collection.ExistsAsync(exportName); + // invoke the operation and iterate over the result + await foreach (CostManagementExportResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExportGetByEnrollmentAccount() + public async Task GetAll_ExportsGetByDepartment() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByEnrollmentAccount.json - // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetByDepartment.json + // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); - - // invoke the operation - string exportName = "TestExport"; - NullableResponse response = await collection.GetIfExistsAsync(exportName); - CostManagementExportResource result = response.HasValue ? response.Value : null; + string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/123"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CostManagementExportResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; + CostManagementExportData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExportGetByManagementGroup() + public async Task GetAll_ExportsGetByEnrollmentAccount() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByManagementGroup.json - // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetByEnrollmentAccount.json + // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Management/managementGroups/TestMG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - // invoke the operation - string exportName = "TestExport"; - CostManagementExportResource result = await collection.GetAsync(exportName); + // invoke the operation and iterate over the result + await foreach (CostManagementExportResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExportGetByManagementGroup() + public async Task GetAll_ExportsGetByManagementGroup() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByManagementGroup.json - // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetByManagementGroup.json + // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "providers/Microsoft.Management/managementGroups/TestMG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - // invoke the operation - string exportName = "TestExport"; - bool result = await collection.ExistsAsync(exportName); + // invoke the operation and iterate over the result + await foreach (CostManagementExportResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExportGetByManagementGroup() + public async Task GetAll_ExportsGetByResourceGroup() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByManagementGroup.json - // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetByResourceGroup.json + // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "providers/Microsoft.Management/managementGroups/TestMG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); - - // invoke the operation - string exportName = "TestExport"; - NullableResponse response = await collection.GetIfExistsAsync(exportName); - CostManagementExportResource result = response.HasValue ? response.Value : null; + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CostManagementExportResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; + CostManagementExportData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExportGetByResourceGroup() + public async Task GetAll_ExportsGetBySubscription() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByResourceGroup.json - // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportsGetBySubscription.json + // this example is just showing the usage of "Exports_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource + // get the collection of this CostManagementExportResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (CostManagementExportResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_ExportGetByBillingAccount() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByBillingAccount.json + // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); // get the collection of this CostManagementExportResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "providers/Microsoft.Billing/billingAccounts/123456"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - CostManagementExportResource result = await collection.GetAsync(exportName); + bool result = await collection.ExistsAsync(exportName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExportGetByResourceGroup() + public async Task Exists_ExportGetByDepartment() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByResourceGroup.json + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByDepartment.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -645,13 +711,9 @@ public async Task Exists_ExportGetByResourceGroup() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; @@ -662,9 +724,9 @@ public async Task Exists_ExportGetByResourceGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExportGetByResourceGroup() + public async Task Exists_ExportGetByEnrollmentAccount() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByResourceGroup.json + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByEnrollmentAccount.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -672,38 +734,22 @@ public async Task GetIfExists_ExportGetByResourceGroup() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - NullableResponse response = await collection.GetIfExistsAsync(exportName); - CostManagementExportResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(exportName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExportGetBySubscription() + public async Task Exists_ExportGetByManagementGroup() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetBySubscription.json + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByManagementGroup.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -711,30 +757,22 @@ public async Task Get_ExportGetBySubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "providers/Microsoft.Management/managementGroups/TestMG"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - CostManagementExportResource result = await collection.GetAsync(exportName); + bool result = await collection.ExistsAsync(exportName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExportGetBySubscription() + public async Task Exists_ExportGetByResourceGroup() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetBySubscription.json + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByResourceGroup.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -742,13 +780,9 @@ public async Task Exists_ExportGetBySubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; @@ -759,7 +793,7 @@ public async Task Exists_ExportGetBySubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExportGetBySubscription() + public async Task Exists_ExportGetBySubscription() { // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetBySubscription.json // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. @@ -769,397 +803,225 @@ public async Task GetIfExists_ExportGetBySubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - NullableResponse response = await collection.GetIfExistsAsync(exportName); - CostManagementExportResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(exportName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ExportCreateOrUpdateByBillingAccount() + public async Task GetIfExists_ExportGetByBillingAccount() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateByBillingAccount.json - // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByBillingAccount.json + // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "providers/Microsoft.Billing/billingAccounts/123456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - CostManagementExportData data = new CostManagementExportData() - { - Format = ExportFormatType.Csv, - DeliveryInfoDestination = new ExportDeliveryDestination("exports") - { - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath = "ad-hoc", - }, - Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) - { - DataSet = new ExportDataset() - { - Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, - }, - }, - Schedule = new ExportSchedule() - { - Status = ExportScheduleStatusType.Active, - Recurrence = ExportScheduleRecurrenceType.Weekly, - RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) - { - To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); - CostManagementExportResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(exportName); + CostManagementExportResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ExportCreateOrUpdateByDepartment() + public async Task GetIfExists_ExportGetByDepartment() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateByDepartment.json - // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByDepartment.json + // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - CostManagementExportData data = new CostManagementExportData() - { - Format = ExportFormatType.Csv, - DeliveryInfoDestination = new ExportDeliveryDestination("exports") - { - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath = "ad-hoc", - }, - Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) - { - DataSet = new ExportDataset() - { - Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, - }, - }, - Schedule = new ExportSchedule() - { - Status = ExportScheduleStatusType.Active, - Recurrence = ExportScheduleRecurrenceType.Weekly, - RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) - { - To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); - CostManagementExportResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(exportName); + CostManagementExportResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ExportCreateOrUpdateByEnrollmentAccount() + public async Task GetIfExists_ExportGetByEnrollmentAccount() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateByEnrollmentAccount.json - // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByEnrollmentAccount.json + // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - CostManagementExportData data = new CostManagementExportData() - { - Format = ExportFormatType.Csv, - DeliveryInfoDestination = new ExportDeliveryDestination("exports") - { - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath = "ad-hoc", - }, - Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) - { - DataSet = new ExportDataset() - { - Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, - }, - }, - Schedule = new ExportSchedule() - { - Status = ExportScheduleStatusType.Active, - Recurrence = ExportScheduleRecurrenceType.Weekly, - RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) - { - To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); - CostManagementExportResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(exportName); + CostManagementExportResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ExportCreateOrUpdateByManagementGroup() + public async Task GetIfExists_ExportGetByManagementGroup() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateByManagementGroup.json - // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByManagementGroup.json + // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "providers/Microsoft.Management/managementGroups/TestMG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - CostManagementExportData data = new CostManagementExportData() - { - Format = ExportFormatType.Csv, - DeliveryInfoDestination = new ExportDeliveryDestination("exports") - { - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath = "ad-hoc", - }, - Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) - { - DataSet = new ExportDataset() - { - Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, - }, - }, - Schedule = new ExportSchedule() - { - Status = ExportScheduleStatusType.Active, - Recurrence = ExportScheduleRecurrenceType.Weekly, - RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) - { - To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); - CostManagementExportResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(exportName); + CostManagementExportResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ExportCreateOrUpdateByResourceGroup() + public async Task GetIfExists_ExportGetByResourceGroup() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateByResourceGroup.json - // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetByResourceGroup.json + // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - CostManagementExportData data = new CostManagementExportData() - { - Format = ExportFormatType.Csv, - DeliveryInfoDestination = new ExportDeliveryDestination("exports") - { - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath = "ad-hoc", - }, - Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) - { - DataSet = new ExportDataset() - { - Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, - }, - }, - Schedule = new ExportSchedule() - { - Status = ExportScheduleStatusType.Active, - Recurrence = ExportScheduleRecurrenceType.Weekly, - RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) - { - To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); - CostManagementExportResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(exportName); + CostManagementExportResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ExportCreateOrUpdateBySubscription() + public async Task GetIfExists_ExportGetBySubscription() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportCreateOrUpdateBySubscription.json - // this example is just showing the usage of "Exports_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportGetBySubscription.json + // this example is just showing the usage of "Exports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementExportResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementExportCollection collection = client.GetCostManagementExports(scopeId); + CostManagementExportCollection collection = client.GetCostManagementExports(new ResourceIdentifier(scope)); // invoke the operation string exportName = "TestExport"; - CostManagementExportData data = new CostManagementExportData() - { - Format = ExportFormatType.Csv, - DeliveryInfoDestination = new ExportDeliveryDestination("exports") - { - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Storage/storageAccounts/ccmeastusdiag182"), - RootFolderPath = "ad-hoc", - }, - Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) - { - DataSet = new ExportDataset() - { - Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, - }, - }, - Schedule = new ExportSchedule() - { - Status = ExportScheduleStatusType.Active, - Recurrence = ExportScheduleRecurrenceType.Weekly, - RecurrencePeriod = new ExportRecurrencePeriod(DateTimeOffset.Parse("2020-06-01T00:00:00Z")) - { - To = DateTimeOffset.Parse("2020-10-31T00:00:00Z"), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, exportName, data); - CostManagementExportResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(exportName); + CostManagementExportResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementExportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementExportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementExportResource.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementExportResource.cs index b1745b86ac65b..e397ddca67c34 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementExportResource.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementExportResource.cs @@ -190,6 +190,156 @@ public async Task Get_ExportGetBySubscription() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ExportDeleteByBillingAccount() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteByBillingAccount.json + // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CostManagementExportResource created on azure + // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource + string scope = "providers/Microsoft.Billing/billingAccounts/123456"; + string exportName = "TestExport"; + ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); + CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); + + // invoke the operation + await costManagementExport.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ExportDeleteByDepartment() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteByDepartment.json + // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CostManagementExportResource created on azure + // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource + string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234"; + string exportName = "TestExport"; + ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); + CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); + + // invoke the operation + await costManagementExport.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ExportDeleteByEnrollmentAccount() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteByEnrollmentAccount.json + // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CostManagementExportResource created on azure + // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource + string scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456"; + string exportName = "TestExport"; + ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); + CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); + + // invoke the operation + await costManagementExport.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ExportDeleteByManagementGroup() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteByManagementGroup.json + // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CostManagementExportResource created on azure + // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource + string scope = "providers/Microsoft.Management/managementGroups/TestMG"; + string exportName = "TestExport"; + ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); + CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); + + // invoke the operation + await costManagementExport.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ExportDeleteByResourceGroup() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteByResourceGroup.json + // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CostManagementExportResource created on azure + // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; + string exportName = "TestExport"; + ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); + CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); + + // invoke the operation + await costManagementExport.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ExportDeleteBySubscription() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteBySubscription.json + // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CostManagementExportResource created on azure + // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string exportName = "TestExport"; + ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); + CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); + + // invoke the operation + await costManagementExport.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_ExportCreateOrUpdateByBillingAccount() @@ -210,7 +360,7 @@ public async Task Update_ExportCreateOrUpdateByBillingAccount() CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); // invoke the operation - CostManagementExportData data = new CostManagementExportData() + CostManagementExportData data = new CostManagementExportData { Format = ExportFormatType.Csv, DeliveryInfoDestination = new ExportDeliveryDestination("exports") @@ -220,16 +370,13 @@ public async Task Update_ExportCreateOrUpdateByBillingAccount() }, Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) { - DataSet = new ExportDataset() + DataSet = new ExportDataset { Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, }, }, - Schedule = new ExportSchedule() + Schedule = new ExportSchedule { Status = ExportScheduleStatusType.Active, Recurrence = ExportScheduleRecurrenceType.Weekly, @@ -269,7 +416,7 @@ public async Task Update_ExportCreateOrUpdateByDepartment() CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); // invoke the operation - CostManagementExportData data = new CostManagementExportData() + CostManagementExportData data = new CostManagementExportData { Format = ExportFormatType.Csv, DeliveryInfoDestination = new ExportDeliveryDestination("exports") @@ -279,16 +426,13 @@ public async Task Update_ExportCreateOrUpdateByDepartment() }, Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) { - DataSet = new ExportDataset() + DataSet = new ExportDataset { Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, }, }, - Schedule = new ExportSchedule() + Schedule = new ExportSchedule { Status = ExportScheduleStatusType.Active, Recurrence = ExportScheduleRecurrenceType.Weekly, @@ -328,7 +472,7 @@ public async Task Update_ExportCreateOrUpdateByEnrollmentAccount() CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); // invoke the operation - CostManagementExportData data = new CostManagementExportData() + CostManagementExportData data = new CostManagementExportData { Format = ExportFormatType.Csv, DeliveryInfoDestination = new ExportDeliveryDestination("exports") @@ -338,16 +482,13 @@ public async Task Update_ExportCreateOrUpdateByEnrollmentAccount() }, Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) { - DataSet = new ExportDataset() + DataSet = new ExportDataset { Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, }, }, - Schedule = new ExportSchedule() + Schedule = new ExportSchedule { Status = ExportScheduleStatusType.Active, Recurrence = ExportScheduleRecurrenceType.Weekly, @@ -387,7 +528,7 @@ public async Task Update_ExportCreateOrUpdateByManagementGroup() CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); // invoke the operation - CostManagementExportData data = new CostManagementExportData() + CostManagementExportData data = new CostManagementExportData { Format = ExportFormatType.Csv, DeliveryInfoDestination = new ExportDeliveryDestination("exports") @@ -397,16 +538,13 @@ public async Task Update_ExportCreateOrUpdateByManagementGroup() }, Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) { - DataSet = new ExportDataset() + DataSet = new ExportDataset { Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, }, }, - Schedule = new ExportSchedule() + Schedule = new ExportSchedule { Status = ExportScheduleStatusType.Active, Recurrence = ExportScheduleRecurrenceType.Weekly, @@ -446,7 +584,7 @@ public async Task Update_ExportCreateOrUpdateByResourceGroup() CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); // invoke the operation - CostManagementExportData data = new CostManagementExportData() + CostManagementExportData data = new CostManagementExportData { Format = ExportFormatType.Csv, DeliveryInfoDestination = new ExportDeliveryDestination("exports") @@ -456,16 +594,13 @@ public async Task Update_ExportCreateOrUpdateByResourceGroup() }, Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) { - DataSet = new ExportDataset() + DataSet = new ExportDataset { Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, }, }, - Schedule = new ExportSchedule() + Schedule = new ExportSchedule { Status = ExportScheduleStatusType.Active, Recurrence = ExportScheduleRecurrenceType.Weekly, @@ -505,7 +640,7 @@ public async Task Update_ExportCreateOrUpdateBySubscription() CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); // invoke the operation - CostManagementExportData data = new CostManagementExportData() + CostManagementExportData data = new CostManagementExportData { Format = ExportFormatType.Csv, DeliveryInfoDestination = new ExportDeliveryDestination("exports") @@ -515,16 +650,13 @@ public async Task Update_ExportCreateOrUpdateBySubscription() }, Definition = new ExportDefinition(ExportType.ActualCost, TimeframeType.MonthToDate) { - DataSet = new ExportDataset() + DataSet = new ExportDataset { Granularity = GranularityType.Daily, - Columns = -{ -"Date","MeterId","ResourceId","ResourceLocation","Quantity" -}, + Columns = { "Date", "MeterId", "ResourceId", "ResourceLocation", "Quantity" }, }, }, - Schedule = new ExportSchedule() + Schedule = new ExportSchedule { Status = ExportScheduleStatusType.Active, Recurrence = ExportScheduleRecurrenceType.Weekly, @@ -544,156 +676,6 @@ public async Task Update_ExportCreateOrUpdateBySubscription() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ExportDeleteByBillingAccount() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteByBillingAccount.json - // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CostManagementExportResource created on azure - // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/123456"; - string exportName = "TestExport"; - ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); - CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); - - // invoke the operation - await costManagementExport.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ExportDeleteByDepartment() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteByDepartment.json - // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CostManagementExportResource created on azure - // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/12/departments/1234"; - string exportName = "TestExport"; - ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); - CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); - - // invoke the operation - await costManagementExport.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ExportDeleteByEnrollmentAccount() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteByEnrollmentAccount.json - // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CostManagementExportResource created on azure - // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource - string scope = "providers/Microsoft.Billing/billingAccounts/100/enrollmentAccounts/456"; - string exportName = "TestExport"; - ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); - CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); - - // invoke the operation - await costManagementExport.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ExportDeleteByManagementGroup() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteByManagementGroup.json - // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CostManagementExportResource created on azure - // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource - string scope = "providers/Microsoft.Management/managementGroups/TestMG"; - string exportName = "TestExport"; - ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); - CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); - - // invoke the operation - await costManagementExport.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ExportDeleteByResourceGroup() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteByResourceGroup.json - // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CostManagementExportResource created on azure - // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - string exportName = "TestExport"; - ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); - CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); - - // invoke the operation - await costManagementExport.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ExportDeleteBySubscription() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExportDeleteBySubscription.json - // this example is just showing the usage of "Exports_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CostManagementExportResource created on azure - // for more information of creating CostManagementExportResource, please refer to the document of CostManagementExportResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - string exportName = "TestExport"; - ResourceIdentifier costManagementExportResourceId = CostManagementExportResource.CreateResourceIdentifier(scope, exportName); - CostManagementExportResource costManagementExport = client.GetCostManagementExportResource(costManagementExportResourceId); - - // invoke the operation - await costManagementExport.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Execute_ExportRunByBillingAccount() diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementViewsCollection.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementViewsCollection.cs index 034572d033dcc..3c9bd29a22d3d 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementViewsCollection.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementViewsCollection.cs @@ -18,35 +18,77 @@ public partial class Sample_CostManagementViewsCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ResourceGroupViewList() + public async Task CreateOrUpdate_ResourceGroupCreateOrUpdateView() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ViewListByResourceGroup.json - // this example is just showing the usage of "Views_ListByScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ViewCreateOrUpdateByResourceGroup.json + // this example is just showing the usage of "Views_CreateOrUpdateByScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementViewsResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementViewsCollection collection = client.GetAllCostManagementViews(scopeId); + CostManagementViewsCollection collection = client.GetAllCostManagementViews(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (CostManagementViewsResource item in collection.GetAllAsync()) + // invoke the operation + string viewName = "swaggerExample"; + CostManagementViewData data = new CostManagementViewData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementViewData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "swagger Example", + Chart = ViewChartType.Table, + Accumulated = AccumulatedType.True, + Metric = ViewMetricType.ActualCost, + Kpis = {new ViewKpiProperties +{ +KpiType = ViewKpiType.Forecast, +Id = null, +IsEnabled = true, +}, new ViewKpiProperties +{ +KpiType = ViewKpiType.Budget, +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), +IsEnabled = true, +}}, + Pivots = {new ViewPivotProperties +{ +PivotType = ViewPivotType.Dimension, +Name = "ServiceName", +}, new ViewPivotProperties +{ +PivotType = ViewPivotType.Dimension, +Name = "MeterCategory", +}, new ViewPivotProperties +{ +PivotType = ViewPivotType.TagKey, +Name = "swaggerTagKey", +}}, + TypePropertiesQueryType = ViewReportType.Usage, + Timeframe = ReportTimeframeType.MonthToDate, + DataSet = new ReportConfigDataset + { + Granularity = ReportGranularityType.Daily, + Aggregation = +{ +["totalCost"] = new ReportConfigAggregation("PreTaxCost", FunctionType.Sum) +}, + Grouping = { }, + Sorting = {new ReportConfigSorting("UsageDate") +{ +Direction = ReportConfigSortingType.Ascending, +}}, + }, + ETag = new ETag("\"1d4ff9fe66f1d10\""), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, viewName, data); + CostManagementViewsResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementViewData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -61,13 +103,9 @@ public async Task Get_ResourceGroupView() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementViewsResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementViewsCollection collection = client.GetAllCostManagementViews(scopeId); + CostManagementViewsCollection collection = client.GetAllCostManagementViews(new ResourceIdentifier(scope)); // invoke the operation string viewName = "swaggerExample"; @@ -80,6 +118,35 @@ public async Task Get_ResourceGroupView() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ResourceGroupViewList() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ViewListByResourceGroup.json + // this example is just showing the usage of "Views_ListByScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this CostManagementViewsResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; + CostManagementViewsCollection collection = client.GetAllCostManagementViews(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (CostManagementViewsResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementViewData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_ResourceGroupView() @@ -92,13 +159,9 @@ public async Task Exists_ResourceGroupView() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementViewsResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementViewsCollection collection = client.GetAllCostManagementViews(scopeId); + CostManagementViewsCollection collection = client.GetAllCostManagementViews(new ResourceIdentifier(scope)); // invoke the operation string viewName = "swaggerExample"; @@ -119,13 +182,9 @@ public async Task GetIfExists_ResourceGroupView() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this CostManagementViewsResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementViewsCollection collection = client.GetAllCostManagementViews(scopeId); + CostManagementViewsCollection collection = client.GetAllCostManagementViews(new ResourceIdentifier(scope)); // invoke the operation string viewName = "swaggerExample"; @@ -145,95 +204,5 @@ public async Task GetIfExists_ResourceGroupView() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ResourceGroupCreateOrUpdateView() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ViewCreateOrUpdateByResourceGroup.json - // this example is just showing the usage of "Views_CreateOrUpdateByScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this CostManagementViewsResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - CostManagementViewsCollection collection = client.GetAllCostManagementViews(scopeId); - - // invoke the operation - string viewName = "swaggerExample"; - CostManagementViewData data = new CostManagementViewData() - { - DisplayName = "swagger Example", - Chart = ViewChartType.Table, - Accumulated = AccumulatedType.True, - Metric = ViewMetricType.ActualCost, - Kpis = -{ -new ViewKpiProperties() -{ -KpiType = ViewKpiType.Forecast, -Id = null, -IsEnabled = true, -},new ViewKpiProperties() -{ -KpiType = ViewKpiType.Budget, -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), -IsEnabled = true, -} -}, - Pivots = -{ -new ViewPivotProperties() -{ -PivotType = ViewPivotType.Dimension, -Name = "ServiceName", -},new ViewPivotProperties() -{ -PivotType = ViewPivotType.Dimension, -Name = "MeterCategory", -},new ViewPivotProperties() -{ -PivotType = ViewPivotType.TagKey, -Name = "swaggerTagKey", -} -}, - TypePropertiesQueryType = ViewReportType.Usage, - Timeframe = ReportTimeframeType.MonthToDate, - DataSet = new ReportConfigDataset() - { - Granularity = ReportGranularityType.Daily, - Aggregation = -{ -["totalCost"] = new ReportConfigAggregation("PreTaxCost",FunctionType.Sum), -}, - Grouping = -{ -}, - Sorting = -{ -new ReportConfigSorting("UsageDate") -{ -Direction = ReportConfigSortingType.Ascending, -} -}, - }, - ETag = new ETag("\"1d4ff9fe66f1d10\""), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, viewName, data); - CostManagementViewsResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementViewData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementViewsResource.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementViewsResource.cs index 03f708be83fe6..4a6663b887108 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementViewsResource.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_CostManagementViewsResource.cs @@ -45,6 +45,31 @@ public async Task Get_ResourceGroupView() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ResourceGroupDeleteView() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ViewDeleteByResourceGroup.json + // this example is just showing the usage of "Views_DeleteByScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this CostManagementViewsResource created on azure + // for more information of creating CostManagementViewsResource, please refer to the document of CostManagementViewsResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; + string viewName = "TestView"; + ResourceIdentifier costManagementViewsResourceId = CostManagementViewsResource.CreateResourceIdentifier(scope, viewName); + CostManagementViewsResource costManagementViews = client.GetCostManagementViewsResource(costManagementViewsResourceId); + + // invoke the operation + await costManagementViews.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_ResourceGroupCreateOrUpdateView() @@ -65,61 +90,50 @@ public async Task Update_ResourceGroupCreateOrUpdateView() CostManagementViewsResource costManagementViews = client.GetCostManagementViewsResource(costManagementViewsResourceId); // invoke the operation - CostManagementViewData data = new CostManagementViewData() + CostManagementViewData data = new CostManagementViewData { DisplayName = "swagger Example", Chart = ViewChartType.Table, Accumulated = AccumulatedType.True, Metric = ViewMetricType.ActualCost, - Kpis = -{ -new ViewKpiProperties() + Kpis = {new ViewKpiProperties { KpiType = ViewKpiType.Forecast, Id = null, IsEnabled = true, -},new ViewKpiProperties() +}, new ViewKpiProperties { KpiType = ViewKpiType.Budget, Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), IsEnabled = true, -} -}, - Pivots = -{ -new ViewPivotProperties() +}}, + Pivots = {new ViewPivotProperties { PivotType = ViewPivotType.Dimension, Name = "ServiceName", -},new ViewPivotProperties() +}, new ViewPivotProperties { PivotType = ViewPivotType.Dimension, Name = "MeterCategory", -},new ViewPivotProperties() +}, new ViewPivotProperties { PivotType = ViewPivotType.TagKey, Name = "swaggerTagKey", -} -}, +}}, TypePropertiesQueryType = ViewReportType.Usage, Timeframe = ReportTimeframeType.MonthToDate, - DataSet = new ReportConfigDataset() + DataSet = new ReportConfigDataset { Granularity = ReportGranularityType.Daily, Aggregation = { -["totalCost"] = new ReportConfigAggregation("PreTaxCost",FunctionType.Sum), +["totalCost"] = new ReportConfigAggregation("PreTaxCost", FunctionType.Sum) }, - Grouping = -{ -}, - Sorting = -{ -new ReportConfigSorting("UsageDate") + Grouping = { }, + Sorting = {new ReportConfigSorting("UsageDate") { Direction = ReportConfigSortingType.Ascending, -} -}, +}}, }, ETag = new ETag("\"1d4ff9fe66f1d10\""), }; @@ -132,30 +146,5 @@ public async Task Update_ResourceGroupCreateOrUpdateView() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ResourceGroupDeleteView() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ViewDeleteByResourceGroup.json - // this example is just showing the usage of "Views_DeleteByScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this CostManagementViewsResource created on azure - // for more information of creating CostManagementViewsResource, please refer to the document of CostManagementViewsResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG"; - string viewName = "TestView"; - ResourceIdentifier costManagementViewsResourceId = CostManagementViewsResource.CreateResourceIdentifier(scope, viewName); - CostManagementViewsResource costManagementViews = client.GetCostManagementViewsResource(costManagementViewsResourceId); - - // invoke the operation - await costManagementViews.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_ScheduledActionCollection.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_ScheduledActionCollection.cs index 24d9a60a7c0e5..a843f4ef48cbe 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_ScheduledActionCollection.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_ScheduledActionCollection.cs @@ -16,73 +16,6 @@ namespace Azure.ResourceManager.CostManagement.Samples { public partial class Sample_ScheduledActionCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScheduledActionsListByScope() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledActions-list-shared.json - // this example is just showing the usage of "ScheduledActions_ListByScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ScheduledActionResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScheduledActionCollection collection = client.GetScheduledActions(scopeId); - - // invoke the operation and iterate over the result - await foreach (ScheduledActionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScheduledActionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScheduledActionsListByScopeFilterByViewId() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledActions-listWithFilter-shared.json - // this example is just showing the usage of "ScheduledActions_ListByScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ScheduledActionResource - string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScheduledActionCollection collection = client.GetScheduledActions(scopeId); - - // invoke the operation and iterate over the result - string filter = "properties/viewId eq '/providers/Microsoft.CostManagement/views/swaggerExample'"; - await foreach (ScheduledActionResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScheduledActionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateInsightAlertScheduledActionByScope() @@ -95,23 +28,16 @@ public async Task CreateOrUpdate_CreateOrUpdateInsightAlertScheduledActionByScop // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ScheduledActionResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScheduledActionCollection collection = client.GetScheduledActions(scopeId); + ScheduledActionCollection collection = client.GetScheduledActions(new ResourceIdentifier(scope)); // invoke the operation string name = "dailyAnomalyByResource"; - ScheduledActionData data = new ScheduledActionData() + ScheduledActionData data = new ScheduledActionData { DisplayName = "Daily anomaly by resource", - Notification = new NotificationProperties(new string[] - { -"user@gmail.com","team@gmail.com" - }, "Cost anomaly detected in the resource"), + Notification = new NotificationProperties(new string[] { "user@gmail.com", "team@gmail.com" }, "Cost anomaly detected in the resource"), Schedule = new ScheduleProperties(ScheduleFrequency.Daily, DateTimeOffset.Parse("2020-06-19T22:21:51.1287144Z"), DateTimeOffset.Parse("2021-06-19T22:21:51.1287144Z")), Status = ScheduledActionStatus.Enabled, ViewId = new ResourceIdentifier("/providers/Microsoft.CostManagement/views/swaggerExample"), @@ -140,38 +66,22 @@ public async Task CreateOrUpdate_CreateOrUpdateScheduledActionByScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ScheduledActionResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScheduledActionCollection collection = client.GetScheduledActions(scopeId); + ScheduledActionCollection collection = client.GetScheduledActions(new ResourceIdentifier(scope)); // invoke the operation string name = "monthlyCostByResource"; - ScheduledActionData data = new ScheduledActionData() + ScheduledActionData data = new ScheduledActionData { DisplayName = "Monthly Cost By Resource", - FileFormats = -{ -ScheduledActionFileFormat.Csv -}, - Notification = new NotificationProperties(new string[] - { -"user@gmail.com","team@gmail.com" - }, "Cost by resource this month"), + FileFormats = { ScheduledActionFileFormat.Csv }, + Notification = new NotificationProperties(new string[] { "user@gmail.com", "team@gmail.com" }, "Cost by resource this month"), Schedule = new ScheduleProperties(ScheduleFrequency.Monthly, DateTimeOffset.Parse("2020-06-19T22:21:51.1287144Z"), DateTimeOffset.Parse("2021-06-19T22:21:51.1287144Z")) { HourOfDay = 10, - DaysOfWeek = -{ -ScheduledActionDaysOfWeek.Monday -}, - WeeksOfMonth = -{ -ScheduledActionWeeksOfMonth.First,ScheduledActionWeeksOfMonth.Third -}, + DaysOfWeek = { ScheduledActionDaysOfWeek.Monday }, + WeeksOfMonth = { ScheduledActionWeeksOfMonth.First, ScheduledActionWeeksOfMonth.Third }, }, Status = ScheduledActionStatus.Enabled, ViewId = new ResourceIdentifier("/providers/Microsoft.CostManagement/views/swaggerExample"), @@ -200,13 +110,9 @@ public async Task Get_ScheduledActionByScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ScheduledActionResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScheduledActionCollection collection = client.GetScheduledActions(scopeId); + ScheduledActionCollection collection = client.GetScheduledActions(new ResourceIdentifier(scope)); // invoke the operation string name = "monthlyCostByResource"; @@ -219,6 +125,65 @@ public async Task Get_ScheduledActionByScope() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ScheduledActionsListByScope() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledActions-list-shared.json + // this example is just showing the usage of "ScheduledActions_ListByScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ScheduledActionResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + ScheduledActionCollection collection = client.GetScheduledActions(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (ScheduledActionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScheduledActionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ScheduledActionsListByScopeFilterByViewId() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledActions-listWithFilter-shared.json + // this example is just showing the usage of "ScheduledActions_ListByScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ScheduledActionResource + string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; + ScheduledActionCollection collection = client.GetScheduledActions(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + string filter = "properties/viewId eq '/providers/Microsoft.CostManagement/views/swaggerExample'"; + await foreach (ScheduledActionResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScheduledActionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_ScheduledActionByScope() @@ -231,13 +196,9 @@ public async Task Exists_ScheduledActionByScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ScheduledActionResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScheduledActionCollection collection = client.GetScheduledActions(scopeId); + ScheduledActionCollection collection = client.GetScheduledActions(new ResourceIdentifier(scope)); // invoke the operation string name = "monthlyCostByResource"; @@ -258,13 +219,9 @@ public async Task GetIfExists_ScheduledActionByScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ScheduledActionResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScheduledActionCollection collection = client.GetScheduledActions(scopeId); + ScheduledActionCollection collection = client.GetScheduledActions(new ResourceIdentifier(scope)); // invoke the operation string name = "monthlyCostByResource"; diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_ScheduledActionResource.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_ScheduledActionResource.cs index 31785422da276..45a26560d63ac 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_ScheduledActionResource.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_ScheduledActionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ScheduledActionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateInsightAlertScheduledActionByScope() + public async Task Get_ScheduledActionByScope() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-insightAlert-createOrUpdate-shared.json - // this example is just showing the usage of "ScheduledActions_CreateOrUpdateByScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-get-shared.json + // this example is just showing the usage of "ScheduledActions_GetByScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,26 +31,12 @@ public async Task Update_CreateOrUpdateInsightAlertScheduledActionByScope() // this example assumes you already have this ScheduledActionResource created on azure // for more information of creating ScheduledActionResource, please refer to the document of ScheduledActionResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - string name = "dailyAnomalyByResource"; + string name = "monthlyCostByResource"; ResourceIdentifier scheduledActionResourceId = ScheduledActionResource.CreateResourceIdentifier(scope, name); ScheduledActionResource scheduledAction = client.GetScheduledActionResource(scheduledActionResourceId); // invoke the operation - ScheduledActionData data = new ScheduledActionData() - { - DisplayName = "Daily anomaly by resource", - Notification = new NotificationProperties(new string[] - { -"user@gmail.com","team@gmail.com" - }, "Cost anomaly detected in the resource"), - Schedule = new ScheduleProperties(ScheduleFrequency.Daily, DateTimeOffset.Parse("2020-06-19T22:21:51.1287144Z"), DateTimeOffset.Parse("2021-06-19T22:21:51.1287144Z")), - Status = ScheduledActionStatus.Enabled, - ViewId = new ResourceIdentifier("/providers/Microsoft.CostManagement/views/swaggerExample"), - Kind = ScheduledActionKind.InsightAlert, - }; - string ifMatch = ""; - ArmOperation lro = await scheduledAction.UpdateAsync(WaitUntil.Completed, data, ifMatch: ifMatch); - ScheduledActionResource result = lro.Value; + ScheduledActionResource result = await scheduledAction.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -61,10 +47,10 @@ public async Task Update_CreateOrUpdateInsightAlertScheduledActionByScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateScheduledActionByScope() + public async Task Delete_ScheduledActionDeleteByScope() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-createOrUpdate-shared.json - // this example is just showing the usage of "ScheduledActions_CreateOrUpdateByScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-delete-shared.json + // this example is just showing the usage of "ScheduledActions_DeleteByScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,50 +65,17 @@ public async Task Update_CreateOrUpdateScheduledActionByScope() ScheduledActionResource scheduledAction = client.GetScheduledActionResource(scheduledActionResourceId); // invoke the operation - ScheduledActionData data = new ScheduledActionData() - { - DisplayName = "Monthly Cost By Resource", - FileFormats = -{ -ScheduledActionFileFormat.Csv -}, - Notification = new NotificationProperties(new string[] - { -"user@gmail.com","team@gmail.com" - }, "Cost by resource this month"), - Schedule = new ScheduleProperties(ScheduleFrequency.Monthly, DateTimeOffset.Parse("2020-06-19T22:21:51.1287144Z"), DateTimeOffset.Parse("2021-06-19T22:21:51.1287144Z")) - { - HourOfDay = 10, - DaysOfWeek = -{ -ScheduledActionDaysOfWeek.Monday -}, - WeeksOfMonth = -{ -ScheduledActionWeeksOfMonth.First,ScheduledActionWeeksOfMonth.Third -}, - }, - Status = ScheduledActionStatus.Enabled, - ViewId = new ResourceIdentifier("/providers/Microsoft.CostManagement/views/swaggerExample"), - Kind = ScheduledActionKind.Email, - }; - string ifMatch = ""; - ArmOperation lro = await scheduledAction.UpdateAsync(WaitUntil.Completed, data, ifMatch: ifMatch); - ScheduledActionResource result = lro.Value; + await scheduledAction.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScheduledActionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ScheduledActionByScope() + public async Task Update_CreateOrUpdateInsightAlertScheduledActionByScope() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-get-shared.json - // this example is just showing the usage of "ScheduledActions_GetByScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-insightAlert-createOrUpdate-shared.json + // this example is just showing the usage of "ScheduledActions_CreateOrUpdateByScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,12 +85,23 @@ public async Task Get_ScheduledActionByScope() // this example assumes you already have this ScheduledActionResource created on azure // for more information of creating ScheduledActionResource, please refer to the document of ScheduledActionResource string scope = "subscriptions/00000000-0000-0000-0000-000000000000"; - string name = "monthlyCostByResource"; + string name = "dailyAnomalyByResource"; ResourceIdentifier scheduledActionResourceId = ScheduledActionResource.CreateResourceIdentifier(scope, name); ScheduledActionResource scheduledAction = client.GetScheduledActionResource(scheduledActionResourceId); // invoke the operation - ScheduledActionResource result = await scheduledAction.GetAsync(); + ScheduledActionData data = new ScheduledActionData + { + DisplayName = "Daily anomaly by resource", + Notification = new NotificationProperties(new string[] { "user@gmail.com", "team@gmail.com" }, "Cost anomaly detected in the resource"), + Schedule = new ScheduleProperties(ScheduleFrequency.Daily, DateTimeOffset.Parse("2020-06-19T22:21:51.1287144Z"), DateTimeOffset.Parse("2021-06-19T22:21:51.1287144Z")), + Status = ScheduledActionStatus.Enabled, + ViewId = new ResourceIdentifier("/providers/Microsoft.CostManagement/views/swaggerExample"), + Kind = ScheduledActionKind.InsightAlert, + }; + string ifMatch = ""; + ArmOperation lro = await scheduledAction.UpdateAsync(WaitUntil.Completed, data, ifMatch: ifMatch); + ScheduledActionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -148,10 +112,10 @@ public async Task Get_ScheduledActionByScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ScheduledActionDeleteByScope() + public async Task Update_CreateOrUpdateScheduledActionByScope() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-delete-shared.json - // this example is just showing the usage of "ScheduledActions_DeleteByScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-createOrUpdate-shared.json + // this example is just showing the usage of "ScheduledActions_CreateOrUpdateByScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -166,9 +130,30 @@ public async Task Delete_ScheduledActionDeleteByScope() ScheduledActionResource scheduledAction = client.GetScheduledActionResource(scheduledActionResourceId); // invoke the operation - await scheduledAction.DeleteAsync(WaitUntil.Completed); + ScheduledActionData data = new ScheduledActionData + { + DisplayName = "Monthly Cost By Resource", + FileFormats = { ScheduledActionFileFormat.Csv }, + Notification = new NotificationProperties(new string[] { "user@gmail.com", "team@gmail.com" }, "Cost by resource this month"), + Schedule = new ScheduleProperties(ScheduleFrequency.Monthly, DateTimeOffset.Parse("2020-06-19T22:21:51.1287144Z"), DateTimeOffset.Parse("2021-06-19T22:21:51.1287144Z")) + { + HourOfDay = 10, + DaysOfWeek = { ScheduledActionDaysOfWeek.Monday }, + WeeksOfMonth = { ScheduledActionWeeksOfMonth.First, ScheduledActionWeeksOfMonth.Third }, + }, + Status = ScheduledActionStatus.Enabled, + ViewId = new ResourceIdentifier("/providers/Microsoft.CostManagement/views/swaggerExample"), + Kind = ScheduledActionKind.Email, + }; + string ifMatch = ""; + ArmOperation lro = await scheduledAction.UpdateAsync(WaitUntil.Completed, data, ifMatch: ifMatch); + ScheduledActionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScheduledActionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index db97cab60fb45..9966fd01dedc8 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -11,6 +11,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.CostManagement.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CostManagement.Samples @@ -29,9 +30,7 @@ public async Task GetBenefitUtilizationSummariesByBillingAccountId_SavingsPlanUt // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result string billingAccountId = "12345"; @@ -56,9 +55,7 @@ public async Task GetBenefitUtilizationSummariesByBillingProfileId_SavingsPlanUt // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result string billingAccountId = "c0a00000-0e04-5ee3-000e-f0c6e00000ec:c0a00000-0e04-5ee3-000e-f0c6e00000ec"; @@ -84,9 +81,7 @@ public async Task GetBenefitUtilizationSummariesBySavingsPlanOrder_SavingsPlanUt // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result string savingsPlanOrderId = "66cccc66-6ccc-6c66-666c-66cc6c6c66c6"; @@ -110,9 +105,7 @@ public async Task GetBenefitUtilizationSummariesBySavingsPlanId_SavingsPlanUtili // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result string savingsPlanOrderId = "66cccc66-6ccc-6c66-666c-66cc6c6c66c6"; @@ -137,9 +130,7 @@ public async Task GenerateBenefitUtilizationSummariesReportBillingAccountScope_G // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string billingAccountId = "8099099"; @@ -165,9 +156,7 @@ public async Task GenerateBenefitUtilizationSummariesReportBillingProfileScope_G // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string billingAccountId = "00000000-0000-0000-0000-000000000000"; @@ -194,9 +183,7 @@ public async Task GenerateBenefitUtilizationSummariesReportReservationOrderScope // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string reservationOrderId = "00000000-0000-0000-0000-000000000000"; @@ -219,9 +206,7 @@ public async Task GenerateBenefitUtilizationSummariesReportReservationScope_Gene // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string reservationOrderId = "00000000-0000-0000-0000-000000000000"; @@ -245,9 +230,7 @@ public async Task GenerateBenefitUtilizationSummariesReportSavingsPlanOrderScope // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string savingsPlanOrderId = "00000000-0000-0000-0000-000000000000"; @@ -270,9 +253,7 @@ public async Task GenerateBenefitUtilizationSummariesReportAsyncSavingsPlanScope // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string savingsPlanOrderId = "00000000-0000-0000-0000-000000000000"; @@ -284,6 +265,64 @@ public async Task GenerateBenefitUtilizationSummariesReportAsyncSavingsPlanScope Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCostManagementAlerts_ExternalBillingAccountAlerts() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExternalBillingAccountAlerts.json + // this example is just showing the usage of "Alerts_ListExternal" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation and iterate over the result + ExternalCloudProviderType externalCloudProviderType = ExternalCloudProviderType.ExternalBillingAccounts; + string externalCloudProviderId = "100"; + await foreach (CostManagementAlertResource item in tenantResource.GetCostManagementAlertsAsync(externalCloudProviderType, externalCloudProviderId)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementAlertData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetCostManagementAlerts_ExternalSubscriptionAlerts() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/ExternalSubscriptionAlerts.json + // this example is just showing the usage of "Alerts_ListExternal" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation and iterate over the result + ExternalCloudProviderType externalCloudProviderType = ExternalCloudProviderType.ExternalSubscriptions; + string externalCloudProviderId = "100"; + await foreach (CostManagementAlertResource item in tenantResource.GetCostManagementAlertsAsync(externalCloudProviderType, externalCloudProviderId)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementAlertData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task ExternalCloudProviderUsageForecast_ExternalBillingAccountForecast() @@ -296,49 +335,32 @@ public async Task ExternalCloudProviderUsageForecast_ExternalBillingAccountForec // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ExternalCloudProviderType externalCloudProviderType = ExternalCloudProviderType.ExternalBillingAccounts; string externalCloudProviderId = "100"; - ForecastDefinition forecastDefinition = new ForecastDefinition(ForecastType.Usage, ForecastTimeframe.Custom, new ForecastDataset(new Dictionary() + ForecastDefinition forecastDefinition = new ForecastDefinition(ForecastType.Usage, ForecastTimeframe.Custom, new ForecastDataset(new Dictionary { - ["totalCost"] = new ForecastAggregation(FunctionName.Cost, FunctionType.Sum), + ["totalCost"] = new ForecastAggregation(FunctionName.Cost, FunctionType.Sum) }) { Granularity = GranularityType.Daily, - Filter = new ForecastFilter() + Filter = new ForecastFilter { - And = -{ -new ForecastFilter() -{ -Or = + And = {new ForecastFilter { -new ForecastFilter() +Or = {new ForecastFilter { -Dimensions = new ForecastComparisonExpression("ResourceLocation",ForecastOperatorType.In,new string[] -{ -"East US","West Europe" -}), -},new ForecastFilter() -{ -Tags = new ForecastComparisonExpression("Environment",ForecastOperatorType.In,new string[] -{ -"UAT","Prod" -}), -} -}, -},new ForecastFilter() +Dimensions = new ForecastComparisonExpression("ResourceLocation", ForecastOperatorType.In, new string[]{"East US", "West Europe"}), +}, new ForecastFilter { -Dimensions = new ForecastComparisonExpression("ResourceGroup",ForecastOperatorType.In,new string[] +Tags = new ForecastComparisonExpression("Environment", ForecastOperatorType.In, new string[]{"UAT", "Prod"}), +}}, +}, new ForecastFilter { -"API" -}), -} -}, +Dimensions = new ForecastComparisonExpression("ResourceGroup", ForecastOperatorType.In, new string[]{"API"}), +}}, }, }) { @@ -361,49 +383,32 @@ public async Task ExternalCloudProviderUsageForecast_ExternalSubscriptionForecas // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ExternalCloudProviderType externalCloudProviderType = ExternalCloudProviderType.ExternalSubscriptions; string externalCloudProviderId = "100"; - ForecastDefinition forecastDefinition = new ForecastDefinition(ForecastType.Usage, ForecastTimeframe.Custom, new ForecastDataset(new Dictionary() + ForecastDefinition forecastDefinition = new ForecastDefinition(ForecastType.Usage, ForecastTimeframe.Custom, new ForecastDataset(new Dictionary { - ["totalCost"] = new ForecastAggregation(FunctionName.Cost, FunctionType.Sum), + ["totalCost"] = new ForecastAggregation(FunctionName.Cost, FunctionType.Sum) }) { Granularity = GranularityType.Daily, - Filter = new ForecastFilter() + Filter = new ForecastFilter { - And = -{ -new ForecastFilter() -{ -Or = + And = {new ForecastFilter { -new ForecastFilter() +Or = {new ForecastFilter { -Dimensions = new ForecastComparisonExpression("ResourceLocation",ForecastOperatorType.In,new string[] +Dimensions = new ForecastComparisonExpression("ResourceLocation", ForecastOperatorType.In, new string[]{"East US", "West Europe"}), +}, new ForecastFilter { -"East US","West Europe" -}), -},new ForecastFilter() +Tags = new ForecastComparisonExpression("Environment", ForecastOperatorType.In, new string[]{"UAT", "Prod"}), +}}, +}, new ForecastFilter { -Tags = new ForecastComparisonExpression("Environment",ForecastOperatorType.In,new string[] -{ -"UAT","Prod" -}), -} -}, -},new ForecastFilter() -{ -Dimensions = new ForecastComparisonExpression("ResourceGroup",ForecastOperatorType.In,new string[] -{ -"API" -}), -} -}, +Dimensions = new ForecastComparisonExpression("ResourceGroup", ForecastOperatorType.In, new string[]{"API"}), +}}, }, }) { @@ -426,12 +431,12 @@ public async Task ByExternalCloudProviderTypeDimensions_ExternalBillingAccountDi // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result - TenantResourceByExternalCloudProviderTypeDimensionsOptions options = new TenantResourceByExternalCloudProviderTypeDimensionsOptions(externalCloudProviderType: ExternalCloudProviderType.ExternalBillingAccounts, externalCloudProviderId: "100") { }; + ExternalCloudProviderType externalCloudProviderType = ExternalCloudProviderType.ExternalBillingAccounts; + string externalCloudProviderId = "100"; + TenantResourceByExternalCloudProviderTypeDimensionsOptions options = new TenantResourceByExternalCloudProviderTypeDimensionsOptions(externalCloudProviderType, externalCloudProviderId); await foreach (CostManagementDimension item in tenantResource.ByExternalCloudProviderTypeDimensionsAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -452,12 +457,12 @@ public async Task ByExternalCloudProviderTypeDimensions_ExternalSubscriptionDime // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result - TenantResourceByExternalCloudProviderTypeDimensionsOptions options = new TenantResourceByExternalCloudProviderTypeDimensionsOptions(externalCloudProviderType: ExternalCloudProviderType.ExternalSubscriptions, externalCloudProviderId: "100") { }; + ExternalCloudProviderType externalCloudProviderType = ExternalCloudProviderType.ExternalSubscriptions; + string externalCloudProviderId = "100"; + TenantResourceByExternalCloudProviderTypeDimensionsOptions options = new TenantResourceByExternalCloudProviderTypeDimensionsOptions(externalCloudProviderType, externalCloudProviderId); await foreach (CostManagementDimension item in tenantResource.ByExternalCloudProviderTypeDimensionsAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -478,46 +483,29 @@ public async Task UsageByExternalCloudProviderTypeQuery_ExternalBillingAccountQu // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ExternalCloudProviderType externalCloudProviderType = ExternalCloudProviderType.ExternalBillingAccounts; string externalCloudProviderId = "100"; - QueryDefinition queryDefinition = new QueryDefinition(ExportType.Usage, TimeframeType.MonthToDate, new QueryDataset() + QueryDefinition queryDefinition = new QueryDefinition(ExportType.Usage, TimeframeType.MonthToDate, new QueryDataset { Granularity = GranularityType.Daily, - Filter = new QueryFilter() + Filter = new QueryFilter { - And = -{ -new QueryFilter() -{ -Or = + And = {new QueryFilter { -new QueryFilter() +Or = {new QueryFilter { -Dimensions = new QueryComparisonExpression("ResourceLocation",QueryOperatorType.In,new string[] -{ -"East US","West Europe" -}), -},new QueryFilter() -{ -Tags = new QueryComparisonExpression("Environment",QueryOperatorType.In,new string[] -{ -"UAT","Prod" -}), -} -}, -},new QueryFilter() +Dimensions = new QueryComparisonExpression("ResourceLocation", QueryOperatorType.In, new string[]{"East US", "West Europe"}), +}, new QueryFilter { -Dimensions = new QueryComparisonExpression("ResourceGroup",QueryOperatorType.In,new string[] +Tags = new QueryComparisonExpression("Environment", QueryOperatorType.In, new string[]{"UAT", "Prod"}), +}}, +}, new QueryFilter { -"API" -}), -} -}, +Dimensions = new QueryComparisonExpression("ResourceGroup", QueryOperatorType.In, new string[]{"API"}), +}}, }, }); QueryResult result = await tenantResource.UsageByExternalCloudProviderTypeQueryAsync(externalCloudProviderType, externalCloudProviderId, queryDefinition); @@ -537,46 +525,29 @@ public async Task UsageByExternalCloudProviderTypeQuery_ExternalSubscriptionsQue // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ExternalCloudProviderType externalCloudProviderType = ExternalCloudProviderType.ExternalSubscriptions; string externalCloudProviderId = "100"; - QueryDefinition queryDefinition = new QueryDefinition(ExportType.Usage, TimeframeType.MonthToDate, new QueryDataset() + QueryDefinition queryDefinition = new QueryDefinition(ExportType.Usage, TimeframeType.MonthToDate, new QueryDataset { Granularity = GranularityType.Daily, - Filter = new QueryFilter() + Filter = new QueryFilter { - And = -{ -new QueryFilter() -{ -Or = -{ -new QueryFilter() + And = {new QueryFilter { -Dimensions = new QueryComparisonExpression("ResourceLocation",QueryOperatorType.In,new string[] +Or = {new QueryFilter { -"East US","West Europe" -}), -},new QueryFilter() +Dimensions = new QueryComparisonExpression("ResourceLocation", QueryOperatorType.In, new string[]{"East US", "West Europe"}), +}, new QueryFilter { -Tags = new QueryComparisonExpression("Environment",QueryOperatorType.In,new string[] +Tags = new QueryComparisonExpression("Environment", QueryOperatorType.In, new string[]{"UAT", "Prod"}), +}}, +}, new QueryFilter { -"UAT","Prod" -}), -} -}, -},new QueryFilter() -{ -Dimensions = new QueryComparisonExpression("ResourceGroup",QueryOperatorType.In,new string[] -{ -"API" -}), -} -}, +Dimensions = new QueryComparisonExpression("ResourceGroup", QueryOperatorType.In, new string[]{"API"}), +}}, }, }); QueryResult result = await tenantResource.UsageByExternalCloudProviderTypeQueryAsync(externalCloudProviderType, externalCloudProviderId, queryDefinition); @@ -596,9 +567,7 @@ public async Task ByBillingAccountIdGenerateReservationDetailsReport_Reservation // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string billingAccountId = "9845612"; @@ -622,9 +591,7 @@ public async Task ByBillingProfileIdGenerateReservationDetailsReport_Reservation // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string billingAccountId = "00000000-0000-0000-0000-000000000000"; @@ -649,9 +616,7 @@ public async Task DownloadPriceSheet_PricesheetDownload() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string billingAccountName = "7c05a543-80ff-571e-9f98-1063b3b53cf2:99ad03ad-2d1b-4889-a452-090ad407d25f_2019-05-31"; @@ -675,9 +640,7 @@ public async Task DownloadByBillingProfilePriceSheet_PricesheetDownloadByBilling // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string billingAccountName = "7c05a543-80ff-571e-9f98-1063b3b53cf2:99ad03ad-2d1b-4889-a452-090ad407d25f_2019-05-31"; @@ -700,12 +663,10 @@ public async Task CheckCostManagementNameAvailabilityByScheduledAction_Scheduled // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation - CostManagementNameAvailabilityContent content = new CostManagementNameAvailabilityContent() + CostManagementNameAvailabilityContent content = new CostManagementNameAvailabilityContent { Name = "testName", ResourceType = "Microsoft.CostManagement/ScheduledActions", diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantScheduledActionCollection.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantScheduledActionCollection.cs index 94d954cf055b0..bf9e98e325523 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantScheduledActionCollection.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantScheduledActionCollection.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.CostManagement.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CostManagement.Samples @@ -28,33 +29,22 @@ public async Task CreateOrUpdate_CreateOrUpdatePrivateScheduledAction() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantScheduledActionResource TenantScheduledActionCollection collection = tenantResource.GetTenantScheduledActions(); // invoke the operation string name = "monthlyCostByResource"; - ScheduledActionData data = new ScheduledActionData() + ScheduledActionData data = new ScheduledActionData { DisplayName = "Monthly Cost By Resource", - Notification = new NotificationProperties(new string[] - { -"user@gmail.com","team@gmail.com" - }, "Cost by resource this month"), + Notification = new NotificationProperties(new string[] { "user@gmail.com", "team@gmail.com" }, "Cost by resource this month"), Schedule = new ScheduleProperties(ScheduleFrequency.Monthly, DateTimeOffset.Parse("2020-06-19T22:21:51.1287144Z"), DateTimeOffset.Parse("2021-06-19T22:21:51.1287144Z")) { HourOfDay = 10, - DaysOfWeek = -{ -ScheduledActionDaysOfWeek.Monday -}, - WeeksOfMonth = -{ -ScheduledActionWeeksOfMonth.First,ScheduledActionWeeksOfMonth.Third -}, + DaysOfWeek = { ScheduledActionDaysOfWeek.Monday }, + WeeksOfMonth = { ScheduledActionWeeksOfMonth.First, ScheduledActionWeeksOfMonth.Third }, }, Status = ScheduledActionStatus.Enabled, ViewId = new ResourceIdentifier("/providers/Microsoft.CostManagement/views/swaggerExample"), @@ -83,9 +73,7 @@ public async Task Get_PrivateScheduledAction() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantScheduledActionResource TenantScheduledActionCollection collection = tenantResource.GetTenantScheduledActions(); @@ -113,9 +101,7 @@ public async Task Exists_PrivateScheduledAction() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantScheduledActionResource TenantScheduledActionCollection collection = tenantResource.GetTenantScheduledActions(); @@ -139,9 +125,7 @@ public async Task GetIfExists_PrivateScheduledAction() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantScheduledActionResource TenantScheduledActionCollection collection = tenantResource.GetTenantScheduledActions(); diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantScheduledActionResource.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantScheduledActionResource.cs index 8a3b2af8b6418..7eff8429876c4 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantScheduledActionResource.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantScheduledActionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_TenantScheduledActionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdatePrivateScheduledAction() + public async Task Get_PrivateScheduledAction() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-createOrUpdate-private.json - // this example is just showing the usage of "ScheduledActions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-get-private.json + // this example is just showing the usage of "ScheduledActions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,32 +35,7 @@ public async Task Update_CreateOrUpdatePrivateScheduledAction() TenantScheduledActionResource tenantScheduledAction = client.GetTenantScheduledActionResource(tenantScheduledActionResourceId); // invoke the operation - ScheduledActionData data = new ScheduledActionData() - { - DisplayName = "Monthly Cost By Resource", - Notification = new NotificationProperties(new string[] - { -"user@gmail.com","team@gmail.com" - }, "Cost by resource this month"), - Schedule = new ScheduleProperties(ScheduleFrequency.Monthly, DateTimeOffset.Parse("2020-06-19T22:21:51.1287144Z"), DateTimeOffset.Parse("2021-06-19T22:21:51.1287144Z")) - { - HourOfDay = 10, - DaysOfWeek = -{ -ScheduledActionDaysOfWeek.Monday -}, - WeeksOfMonth = -{ -ScheduledActionWeeksOfMonth.First,ScheduledActionWeeksOfMonth.Third -}, - }, - Status = ScheduledActionStatus.Enabled, - ViewId = new ResourceIdentifier("/providers/Microsoft.CostManagement/views/swaggerExample"), - Kind = ScheduledActionKind.Email, - }; - string ifMatch = ""; - ArmOperation lro = await tenantScheduledAction.UpdateAsync(WaitUntil.Completed, data, ifMatch: ifMatch); - TenantScheduledActionResource result = lro.Value; + TenantScheduledActionResource result = await tenantScheduledAction.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -71,10 +46,10 @@ public async Task Update_CreateOrUpdatePrivateScheduledAction() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateScheduledAction() + public async Task Delete_PrivateScheduledActionDelete() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-get-private.json - // this example is just showing the usage of "ScheduledActions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-delete-private.json + // this example is just showing the usage of "ScheduledActions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -88,21 +63,17 @@ public async Task Get_PrivateScheduledAction() TenantScheduledActionResource tenantScheduledAction = client.GetTenantScheduledActionResource(tenantScheduledActionResourceId); // invoke the operation - TenantScheduledActionResource result = await tenantScheduledAction.GetAsync(); + await tenantScheduledAction.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScheduledActionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateScheduledActionDelete() + public async Task Update_CreateOrUpdatePrivateScheduledAction() { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-delete-private.json - // this example is just showing the usage of "ScheduledActions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/scheduledActions/scheduledAction-createOrUpdate-private.json + // this example is just showing the usage of "ScheduledActions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,9 +87,29 @@ public async Task Delete_PrivateScheduledActionDelete() TenantScheduledActionResource tenantScheduledAction = client.GetTenantScheduledActionResource(tenantScheduledActionResourceId); // invoke the operation - await tenantScheduledAction.DeleteAsync(WaitUntil.Completed); + ScheduledActionData data = new ScheduledActionData + { + DisplayName = "Monthly Cost By Resource", + Notification = new NotificationProperties(new string[] { "user@gmail.com", "team@gmail.com" }, "Cost by resource this month"), + Schedule = new ScheduleProperties(ScheduleFrequency.Monthly, DateTimeOffset.Parse("2020-06-19T22:21:51.1287144Z"), DateTimeOffset.Parse("2021-06-19T22:21:51.1287144Z")) + { + HourOfDay = 10, + DaysOfWeek = { ScheduledActionDaysOfWeek.Monday }, + WeeksOfMonth = { ScheduledActionWeeksOfMonth.First, ScheduledActionWeeksOfMonth.Third }, + }, + Status = ScheduledActionStatus.Enabled, + ViewId = new ResourceIdentifier("/providers/Microsoft.CostManagement/views/swaggerExample"), + Kind = ScheduledActionKind.Email, + }; + string ifMatch = ""; + ArmOperation lro = await tenantScheduledAction.UpdateAsync(WaitUntil.Completed, data, ifMatch: ifMatch); + TenantScheduledActionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScheduledActionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantsCostManagementViewsCollection.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantsCostManagementViewsCollection.cs index 39b6e8d4cc3b0..4bd4842b73df2 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantsCostManagementViewsCollection.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantsCostManagementViewsCollection.cs @@ -10,12 +10,89 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.CostManagement.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CostManagement.Samples { public partial class Sample_TenantsCostManagementViewsCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateOrUpdatePrivateView() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/PrivateViewCreateOrUpdate.json + // this example is just showing the usage of "Views_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this TenantsCostManagementViewsResource + TenantsCostManagementViewsCollection collection = tenantResource.GetAllTenantsCostManagementViews(); + + // invoke the operation + string viewName = "swaggerExample"; + CostManagementViewData data = new CostManagementViewData + { + DisplayName = "swagger Example", + Chart = ViewChartType.Table, + Accumulated = AccumulatedType.True, + Metric = ViewMetricType.ActualCost, + Kpis = {new ViewKpiProperties +{ +KpiType = ViewKpiType.Forecast, +Id = null, +IsEnabled = true, +}, new ViewKpiProperties +{ +KpiType = ViewKpiType.Budget, +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), +IsEnabled = true, +}}, + Pivots = {new ViewPivotProperties +{ +PivotType = ViewPivotType.Dimension, +Name = "ServiceName", +}, new ViewPivotProperties +{ +PivotType = ViewPivotType.Dimension, +Name = "MeterCategory", +}, new ViewPivotProperties +{ +PivotType = ViewPivotType.TagKey, +Name = "swaggerTagKey", +}}, + TypePropertiesQueryType = ViewReportType.Usage, + Timeframe = ReportTimeframeType.MonthToDate, + DataSet = new ReportConfigDataset + { + Granularity = ReportGranularityType.Daily, + Aggregation = +{ +["totalCost"] = new ReportConfigAggregation("PreTaxCost", FunctionType.Sum) +}, + Grouping = { }, + Sorting = {new ReportConfigSorting("UsageDate") +{ +Direction = ReportConfigSortingType.Ascending, +}}, + }, + ETag = new ETag("\"1d4ff9fe66f1d10\""), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, viewName, data); + TenantsCostManagementViewsResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CostManagementViewData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Get_PrivateView() @@ -28,9 +105,7 @@ public async Task Get_PrivateView() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantsCostManagementViewsResource TenantsCostManagementViewsCollection collection = tenantResource.GetAllTenantsCostManagementViews(); @@ -58,9 +133,7 @@ public async Task Exists_PrivateView() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantsCostManagementViewsResource TenantsCostManagementViewsCollection collection = tenantResource.GetAllTenantsCostManagementViews(); @@ -84,9 +157,7 @@ public async Task GetIfExists_PrivateView() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantsCostManagementViewsResource TenantsCostManagementViewsCollection collection = tenantResource.GetAllTenantsCostManagementViews(); @@ -109,94 +180,5 @@ public async Task GetIfExists_PrivateView() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdatePrivateView() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/PrivateViewCreateOrUpdate.json - // this example is just showing the usage of "Views_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantsCostManagementViewsResource - TenantsCostManagementViewsCollection collection = tenantResource.GetAllTenantsCostManagementViews(); - - // invoke the operation - string viewName = "swaggerExample"; - CostManagementViewData data = new CostManagementViewData() - { - DisplayName = "swagger Example", - Chart = ViewChartType.Table, - Accumulated = AccumulatedType.True, - Metric = ViewMetricType.ActualCost, - Kpis = -{ -new ViewKpiProperties() -{ -KpiType = ViewKpiType.Forecast, -Id = null, -IsEnabled = true, -},new ViewKpiProperties() -{ -KpiType = ViewKpiType.Budget, -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), -IsEnabled = true, -} -}, - Pivots = -{ -new ViewPivotProperties() -{ -PivotType = ViewPivotType.Dimension, -Name = "ServiceName", -},new ViewPivotProperties() -{ -PivotType = ViewPivotType.Dimension, -Name = "MeterCategory", -},new ViewPivotProperties() -{ -PivotType = ViewPivotType.TagKey, -Name = "swaggerTagKey", -} -}, - TypePropertiesQueryType = ViewReportType.Usage, - Timeframe = ReportTimeframeType.MonthToDate, - DataSet = new ReportConfigDataset() - { - Granularity = ReportGranularityType.Daily, - Aggregation = -{ -["totalCost"] = new ReportConfigAggregation("PreTaxCost",FunctionType.Sum), -}, - Grouping = -{ -}, - Sorting = -{ -new ReportConfigSorting("UsageDate") -{ -Direction = ReportConfigSortingType.Ascending, -} -}, - }, - ETag = new ETag("\"1d4ff9fe66f1d10\""), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, viewName, data); - TenantsCostManagementViewsResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CostManagementViewData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantsCostManagementViewsResource.cs b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantsCostManagementViewsResource.cs index 51cf5bb4269e9..b40bd33a949dc 100644 --- a/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantsCostManagementViewsResource.cs +++ b/sdk/costmanagement/Azure.ResourceManager.CostManagement/samples/Generated/Samples/Sample_TenantsCostManagementViewsResource.cs @@ -44,6 +44,30 @@ public async Task Get_PrivateView() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeletePrivateView() + { + // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/PrivateViewDelete.json + // this example is just showing the usage of "Views_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TenantsCostManagementViewsResource created on azure + // for more information of creating TenantsCostManagementViewsResource, please refer to the document of TenantsCostManagementViewsResource + string viewName = "TestView"; + ResourceIdentifier tenantsCostManagementViewsResourceId = TenantsCostManagementViewsResource.CreateResourceIdentifier(viewName); + TenantsCostManagementViewsResource tenantsCostManagementViews = client.GetTenantsCostManagementViewsResource(tenantsCostManagementViewsResourceId); + + // invoke the operation + await tenantsCostManagementViews.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdatePrivateView() @@ -63,61 +87,50 @@ public async Task Update_CreateOrUpdatePrivateView() TenantsCostManagementViewsResource tenantsCostManagementViews = client.GetTenantsCostManagementViewsResource(tenantsCostManagementViewsResourceId); // invoke the operation - CostManagementViewData data = new CostManagementViewData() + CostManagementViewData data = new CostManagementViewData { DisplayName = "swagger Example", Chart = ViewChartType.Table, Accumulated = AccumulatedType.True, Metric = ViewMetricType.ActualCost, - Kpis = -{ -new ViewKpiProperties() + Kpis = {new ViewKpiProperties { KpiType = ViewKpiType.Forecast, Id = null, IsEnabled = true, -},new ViewKpiProperties() +}, new ViewKpiProperties { KpiType = ViewKpiType.Budget, Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/MYDEVTESTRG/providers/Microsoft.Consumption/budgets/swaggerDemo"), IsEnabled = true, -} -}, - Pivots = -{ -new ViewPivotProperties() +}}, + Pivots = {new ViewPivotProperties { PivotType = ViewPivotType.Dimension, Name = "ServiceName", -},new ViewPivotProperties() +}, new ViewPivotProperties { PivotType = ViewPivotType.Dimension, Name = "MeterCategory", -},new ViewPivotProperties() +}, new ViewPivotProperties { PivotType = ViewPivotType.TagKey, Name = "swaggerTagKey", -} -}, +}}, TypePropertiesQueryType = ViewReportType.Usage, Timeframe = ReportTimeframeType.MonthToDate, - DataSet = new ReportConfigDataset() + DataSet = new ReportConfigDataset { Granularity = ReportGranularityType.Daily, Aggregation = { -["totalCost"] = new ReportConfigAggregation("PreTaxCost",FunctionType.Sum), +["totalCost"] = new ReportConfigAggregation("PreTaxCost", FunctionType.Sum) }, - Grouping = -{ -}, - Sorting = -{ -new ReportConfigSorting("UsageDate") + Grouping = { }, + Sorting = {new ReportConfigSorting("UsageDate") { Direction = ReportConfigSortingType.Ascending, -} -}, +}}, }, ETag = new ETag("\"1d4ff9fe66f1d10\""), }; @@ -130,29 +143,5 @@ public async Task Update_CreateOrUpdatePrivateView() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateView() - { - // Generated from example definition: specification/cost-management/resource-manager/Microsoft.CostManagement/stable/2023-03-01/examples/PrivateViewDelete.json - // this example is just showing the usage of "Views_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantsCostManagementViewsResource created on azure - // for more information of creating TenantsCostManagementViewsResource, please refer to the document of TenantsCostManagementViewsResource - string viewName = "TestView"; - ResourceIdentifier tenantsCostManagementViewsResourceId = TenantsCostManagementViewsResource.CreateResourceIdentifier(viewName); - TenantsCostManagementViewsResource tenantsCostManagementViews = client.GetTenantsCostManagementViewsResource(tenantsCostManagementViewsResourceId); - - // invoke the operation - await tenantsCostManagementViews.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_AuthorizationPolicyResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_AuthorizationPolicyResourceFormatCollection.cs index 85d0a733a2d5b..5d4f30ec35d69 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_AuthorizationPolicyResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_AuthorizationPolicyResourceFormatCollection.cs @@ -41,12 +41,9 @@ public async Task CreateOrUpdate_AuthorizationPoliciesCreateOrUpdate() // invoke the operation string authorizationPolicyName = "testPolicy4222"; - AuthorizationPolicyResourceFormatData data = new AuthorizationPolicyResourceFormatData() + AuthorizationPolicyResourceFormatData data = new AuthorizationPolicyResourceFormatData { - Permissions = -{ -PermissionType.Read,PermissionType.Write,PermissionType.Manage -}, + Permissions = { PermissionType.Read, PermissionType.Write, PermissionType.Manage }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationPolicyName, data); AuthorizationPolicyResourceFormatResource result = lro.Value; @@ -94,10 +91,10 @@ public async Task Get_AuthorizationPoliciesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AuthorizationPoliciesGet() + public async Task GetAll_AuthorizationPoliciesListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/AuthorizationPoliciesGet.json - // this example is just showing the usage of "AuthorizationPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/AuthorizationPoliciesListByHub.json + // this example is just showing the usage of "AuthorizationPolicies_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +112,22 @@ public async Task Exists_AuthorizationPoliciesGet() // get the collection of this AuthorizationPolicyResourceFormatResource AuthorizationPolicyResourceFormatCollection collection = hub.GetAuthorizationPolicyResourceFormats(); - // invoke the operation - string authorizationPolicyName = "testPolicy4222"; - bool result = await collection.ExistsAsync(authorizationPolicyName); + // invoke the operation and iterate over the result + await foreach (AuthorizationPolicyResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationPolicyResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AuthorizationPoliciesGet() + public async Task Exists_AuthorizationPoliciesGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/AuthorizationPoliciesGet.json // this example is just showing the usage of "AuthorizationPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,29 +150,17 @@ public async Task GetIfExists_AuthorizationPoliciesGet() // invoke the operation string authorizationPolicyName = "testPolicy4222"; - NullableResponse response = await collection.GetIfExistsAsync(authorizationPolicyName); - AuthorizationPolicyResourceFormatResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(authorizationPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationPolicyResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AuthorizationPoliciesListByHub() + public async Task GetIfExists_AuthorizationPoliciesGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/AuthorizationPoliciesListByHub.json - // this example is just showing the usage of "AuthorizationPolicies_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/AuthorizationPoliciesGet.json + // this example is just showing the usage of "AuthorizationPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +178,23 @@ public async Task GetAll_AuthorizationPoliciesListByHub() // get the collection of this AuthorizationPolicyResourceFormatResource AuthorizationPolicyResourceFormatCollection collection = hub.GetAuthorizationPolicyResourceFormats(); - // invoke the operation and iterate over the result - await foreach (AuthorizationPolicyResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationPolicyName = "testPolicy4222"; + NullableResponse response = await collection.GetIfExistsAsync(authorizationPolicyName); + AuthorizationPolicyResourceFormatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AuthorizationPolicyResourceFormatData resourceData = item.Data; + AuthorizationPolicyResourceFormatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_AuthorizationPolicyResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_AuthorizationPolicyResourceFormatResource.cs index d9293e5fe4a28..1322e9ea75e1d 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_AuthorizationPolicyResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_AuthorizationPolicyResourceFormatResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AuthorizationPolicyResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AuthorizationPoliciesCreateOrUpdate() + public async Task Get_AuthorizationPoliciesGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/AuthorizationPoliciesCreateOrUpdate.json - // this example is just showing the usage of "AuthorizationPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/AuthorizationPoliciesGet.json + // this example is just showing the usage of "AuthorizationPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_AuthorizationPoliciesCreateOrUpdate() AuthorizationPolicyResourceFormatResource authorizationPolicyResourceFormat = client.GetAuthorizationPolicyResourceFormatResource(authorizationPolicyResourceFormatResourceId); // invoke the operation - AuthorizationPolicyResourceFormatData data = new AuthorizationPolicyResourceFormatData() - { - Permissions = -{ -PermissionType.Read,PermissionType.Write,PermissionType.Manage -}, - }; - ArmOperation lro = await authorizationPolicyResourceFormat.UpdateAsync(WaitUntil.Completed, data); - AuthorizationPolicyResourceFormatResource result = lro.Value; + AuthorizationPolicyResourceFormatResource result = await authorizationPolicyResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +49,10 @@ public async Task Update_AuthorizationPoliciesCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AuthorizationPoliciesGet() + public async Task Update_AuthorizationPoliciesCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/AuthorizationPoliciesGet.json - // this example is just showing the usage of "AuthorizationPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/AuthorizationPoliciesCreateOrUpdate.json + // this example is just showing the usage of "AuthorizationPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +69,12 @@ public async Task Get_AuthorizationPoliciesGet() AuthorizationPolicyResourceFormatResource authorizationPolicyResourceFormat = client.GetAuthorizationPolicyResourceFormatResource(authorizationPolicyResourceFormatResourceId); // invoke the operation - AuthorizationPolicyResourceFormatResource result = await authorizationPolicyResourceFormat.GetAsync(); + AuthorizationPolicyResourceFormatData data = new AuthorizationPolicyResourceFormatData + { + Permissions = { PermissionType.Read, PermissionType.Write, PermissionType.Manage }, + }; + ArmOperation lro = await authorizationPolicyResourceFormat.UpdateAsync(WaitUntil.Completed, data); + AuthorizationPolicyResourceFormatResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorMappingResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorMappingResourceFormatCollection.cs index aa22295fedecf..becb26e899a5e 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorMappingResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorMappingResourceFormatCollection.cs @@ -42,7 +42,7 @@ public async Task CreateOrUpdate_ConnectorMappingsCreateOrUpdate() // invoke the operation string mappingName = "testMapping12491"; - ConnectorMappingResourceFormatData data = new ConnectorMappingResourceFormatData() + ConnectorMappingResourceFormatData data = new ConnectorMappingResourceFormatData { EntityType = EntityType.Interaction, EntityTypeName = "TestInteractionType2967", @@ -51,7 +51,7 @@ public async Task CreateOrUpdate_ConnectorMappingsCreateOrUpdate() MappingProperties = new ConnectorMappingProperties(new ConnectorMappingErrorManagement(ErrorManagementType.StopImport) { ErrorLimit = 10, - }, new ConnectorMappingFormat() + }, new ConnectorMappingFormat { ColumnDelimiter = "|", }, new ConnectorMappingAvailability(5) @@ -59,14 +59,15 @@ public async Task CreateOrUpdate_ConnectorMappingsCreateOrUpdate() Frequency = FrequencyType.Hour, }, new ConnectorMappingStructure[] { -new ConnectorMappingStructure("unknwon1","unknown1") +new ConnectorMappingStructure("unknwon1", "unknown1") { IsEncrypted = false, -},new ConnectorMappingStructure("unknwon2","unknown2") +}, +new ConnectorMappingStructure("unknwon2", "unknown2") { IsEncrypted = true, } - }, new ConnectorMappingCompleteOperation() + }, new ConnectorMappingCompleteOperation { CompletionOperationType = CompletionOperationType.DeleteFile, DestinationFolder = "fakePath", @@ -124,10 +125,10 @@ public async Task Get_ConnectorMappingsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConnectorMappingsGet() + public async Task GetAll_ConnectorMappingsListByConnector() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsGet.json - // this example is just showing the usage of "ConnectorMappings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsListByConnector.json + // this example is just showing the usage of "ConnectorMappings_ListByConnector" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,16 +147,22 @@ public async Task Exists_ConnectorMappingsGet() // get the collection of this ConnectorMappingResourceFormatResource ConnectorMappingResourceFormatCollection collection = connectorResourceFormat.GetConnectorMappingResourceFormats(); - // invoke the operation - string mappingName = "testMapping12491"; - bool result = await collection.ExistsAsync(mappingName); + // invoke the operation and iterate over the result + await foreach (ConnectorMappingResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectorMappingResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConnectorMappingsGet() + public async Task Exists_ConnectorMappingsGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsGet.json // this example is just showing the usage of "ConnectorMappings_Get" operation, for the dependent resources, they will have to be created separately. @@ -179,29 +186,17 @@ public async Task GetIfExists_ConnectorMappingsGet() // invoke the operation string mappingName = "testMapping12491"; - NullableResponse response = await collection.GetIfExistsAsync(mappingName); - ConnectorMappingResourceFormatResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(mappingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectorMappingResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConnectorMappingsListByConnector() + public async Task GetIfExists_ConnectorMappingsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsListByConnector.json - // this example is just showing the usage of "ConnectorMappings_ListByConnector" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsGet.json + // this example is just showing the usage of "ConnectorMappings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -220,17 +215,23 @@ public async Task GetAll_ConnectorMappingsListByConnector() // get the collection of this ConnectorMappingResourceFormatResource ConnectorMappingResourceFormatCollection collection = connectorResourceFormat.GetConnectorMappingResourceFormats(); - // invoke the operation and iterate over the result - await foreach (ConnectorMappingResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string mappingName = "testMapping12491"; + NullableResponse response = await collection.GetIfExistsAsync(mappingName); + ConnectorMappingResourceFormatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectorMappingResourceFormatData resourceData = item.Data; + ConnectorMappingResourceFormatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorMappingResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorMappingResourceFormatResource.cs index 9788f47fbd6b6..3cc7c46283e18 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorMappingResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorMappingResourceFormatResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ConnectorMappingResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConnectorMappingsCreateOrUpdate() + public async Task Get_ConnectorMappingsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsCreateOrUpdate.json - // this example is just showing the usage of "ConnectorMappings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsGet.json + // this example is just showing the usage of "ConnectorMappings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,43 +39,7 @@ public async Task Update_ConnectorMappingsCreateOrUpdate() ConnectorMappingResourceFormatResource connectorMappingResourceFormat = client.GetConnectorMappingResourceFormatResource(connectorMappingResourceFormatResourceId); // invoke the operation - ConnectorMappingResourceFormatData data = new ConnectorMappingResourceFormatData() - { - EntityType = EntityType.Interaction, - EntityTypeName = "TestInteractionType2967", - DisplayName = "testMapping12491", - Description = "Test mapping", - MappingProperties = new ConnectorMappingProperties(new ConnectorMappingErrorManagement(ErrorManagementType.StopImport) - { - ErrorLimit = 10, - }, new ConnectorMappingFormat() - { - ColumnDelimiter = "|", - }, new ConnectorMappingAvailability(5) - { - Frequency = FrequencyType.Hour, - }, new ConnectorMappingStructure[] - { -new ConnectorMappingStructure("unknwon1","unknown1") -{ -IsEncrypted = false, -},new ConnectorMappingStructure("unknwon2","unknown2") -{ -IsEncrypted = true, -} - }, new ConnectorMappingCompleteOperation() - { - CompletionOperationType = CompletionOperationType.DeleteFile, - DestinationFolder = "fakePath", - }) - { - FolderPath = "http://sample.dne/file", - FileFilter = "unknown", - HasHeader = false, - }, - }; - ArmOperation lro = await connectorMappingResourceFormat.UpdateAsync(WaitUntil.Completed, data); - ConnectorMappingResourceFormatResource result = lro.Value; + ConnectorMappingResourceFormatResource result = await connectorMappingResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,10 +50,10 @@ public async Task Update_ConnectorMappingsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConnectorMappingsGet() + public async Task Delete_ConnectorMappingsDelete() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsGet.json - // this example is just showing the usage of "ConnectorMappings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsDelete.json + // this example is just showing the usage of "ConnectorMappings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,21 +71,17 @@ public async Task Get_ConnectorMappingsGet() ConnectorMappingResourceFormatResource connectorMappingResourceFormat = client.GetConnectorMappingResourceFormatResource(connectorMappingResourceFormatResourceId); // invoke the operation - ConnectorMappingResourceFormatResource result = await connectorMappingResourceFormat.GetAsync(); + await connectorMappingResourceFormat.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectorMappingResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ConnectorMappingsDelete() + public async Task Update_ConnectorMappingsCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsDelete.json - // this example is just showing the usage of "ConnectorMappings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorMappingsCreateOrUpdate.json + // this example is just showing the usage of "ConnectorMappings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,9 +99,50 @@ public async Task Delete_ConnectorMappingsDelete() ConnectorMappingResourceFormatResource connectorMappingResourceFormat = client.GetConnectorMappingResourceFormatResource(connectorMappingResourceFormatResourceId); // invoke the operation - await connectorMappingResourceFormat.DeleteAsync(WaitUntil.Completed); + ConnectorMappingResourceFormatData data = new ConnectorMappingResourceFormatData + { + EntityType = EntityType.Interaction, + EntityTypeName = "TestInteractionType2967", + DisplayName = "testMapping12491", + Description = "Test mapping", + MappingProperties = new ConnectorMappingProperties(new ConnectorMappingErrorManagement(ErrorManagementType.StopImport) + { + ErrorLimit = 10, + }, new ConnectorMappingFormat + { + ColumnDelimiter = "|", + }, new ConnectorMappingAvailability(5) + { + Frequency = FrequencyType.Hour, + }, new ConnectorMappingStructure[] + { +new ConnectorMappingStructure("unknwon1", "unknown1") +{ +IsEncrypted = false, +}, +new ConnectorMappingStructure("unknwon2", "unknown2") +{ +IsEncrypted = true, +} + }, new ConnectorMappingCompleteOperation + { + CompletionOperationType = CompletionOperationType.DeleteFile, + DestinationFolder = "fakePath", + }) + { + FolderPath = "http://sample.dne/file", + FileFilter = "unknown", + HasHeader = false, + }, + }; + ArmOperation lro = await connectorMappingResourceFormat.UpdateAsync(WaitUntil.Completed, data); + ConnectorMappingResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectorMappingResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorResourceFormatCollection.cs index cde30b9f8bb60..2f6c9d67fe57a 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorResourceFormatCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -42,17 +41,18 @@ public async Task CreateOrUpdate_ConnectorsCreateOrUpdate() // invoke the operation string connectorName = "testConnector"; - ConnectorResourceFormatData data = new ConnectorResourceFormatData() + ConnectorResourceFormatData data = new ConnectorResourceFormatData { ConnectorType = ConnectorType.AzureBlob, DisplayName = "testConnector", Description = "Test connector", ConnectorProperties = { -["connectionKeyVaultUrl"] = BinaryData.FromObjectAsJson(new Dictionary() +["connectionKeyVaultUrl"] = BinaryData.FromObjectAsJson(new { -["organizationId"] = "XXX", -["organizationUrl"] = "https://XXX.crmlivetie.com/"}), +organizationId = "XXX", +organizationUrl = "https://XXX.crmlivetie.com/", +}) }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectorName, data); @@ -101,10 +101,10 @@ public async Task Get_ConnectorsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConnectorsGet() + public async Task GetAll_ConnectorsListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsGet.json - // this example is just showing the usage of "Connectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsListByHub.json + // this example is just showing the usage of "Connectors_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,16 +122,22 @@ public async Task Exists_ConnectorsGet() // get the collection of this ConnectorResourceFormatResource ConnectorResourceFormatCollection collection = hub.GetConnectorResourceFormats(); - // invoke the operation - string connectorName = "testConnector"; - bool result = await collection.ExistsAsync(connectorName); + // invoke the operation and iterate over the result + await foreach (ConnectorResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectorResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConnectorsGet() + public async Task Exists_ConnectorsGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsGet.json // this example is just showing the usage of "Connectors_Get" operation, for the dependent resources, they will have to be created separately. @@ -154,29 +160,17 @@ public async Task GetIfExists_ConnectorsGet() // invoke the operation string connectorName = "testConnector"; - NullableResponse response = await collection.GetIfExistsAsync(connectorName); - ConnectorResourceFormatResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(connectorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectorResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConnectorsListByHub() + public async Task GetIfExists_ConnectorsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsListByHub.json - // this example is just showing the usage of "Connectors_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsGet.json + // this example is just showing the usage of "Connectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -194,17 +188,23 @@ public async Task GetAll_ConnectorsListByHub() // get the collection of this ConnectorResourceFormatResource ConnectorResourceFormatCollection collection = hub.GetConnectorResourceFormats(); - // invoke the operation and iterate over the result - await foreach (ConnectorResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string connectorName = "testConnector"; + NullableResponse response = await collection.GetIfExistsAsync(connectorName); + ConnectorResourceFormatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectorResourceFormatData resourceData = item.Data; + ConnectorResourceFormatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorResourceFormatResource.cs index 008f4b366aa96..179ce0f080faf 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ConnectorResourceFormatResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_ConnectorResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConnectorsCreateOrUpdate() + public async Task Get_ConnectorsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsCreateOrUpdate.json - // this example is just showing the usage of "Connectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsGet.json + // this example is just showing the usage of "Connectors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,21 +38,7 @@ public async Task Update_ConnectorsCreateOrUpdate() ConnectorResourceFormatResource connectorResourceFormat = client.GetConnectorResourceFormatResource(connectorResourceFormatResourceId); // invoke the operation - ConnectorResourceFormatData data = new ConnectorResourceFormatData() - { - ConnectorType = ConnectorType.AzureBlob, - DisplayName = "testConnector", - Description = "Test connector", - ConnectorProperties = -{ -["connectionKeyVaultUrl"] = BinaryData.FromObjectAsJson(new Dictionary() -{ -["organizationId"] = "XXX", -["organizationUrl"] = "https://XXX.crmlivetie.com/"}), -}, - }; - ArmOperation lro = await connectorResourceFormat.UpdateAsync(WaitUntil.Completed, data); - ConnectorResourceFormatResource result = lro.Value; + ConnectorResourceFormatResource result = await connectorResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -64,10 +49,10 @@ public async Task Update_ConnectorsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConnectorsGet() + public async Task Delete_ConnectorsDelete() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsGet.json - // this example is just showing the usage of "Connectors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsDelete.json + // this example is just showing the usage of "Connectors_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -84,21 +69,17 @@ public async Task Get_ConnectorsGet() ConnectorResourceFormatResource connectorResourceFormat = client.GetConnectorResourceFormatResource(connectorResourceFormatResourceId); // invoke the operation - ConnectorResourceFormatResource result = await connectorResourceFormat.GetAsync(); + await connectorResourceFormat.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectorResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ConnectorsDelete() + public async Task Update_ConnectorsCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsDelete.json - // this example is just showing the usage of "Connectors_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ConnectorsCreateOrUpdate.json + // this example is just showing the usage of "Connectors_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,9 +96,28 @@ public async Task Delete_ConnectorsDelete() ConnectorResourceFormatResource connectorResourceFormat = client.GetConnectorResourceFormatResource(connectorResourceFormatResourceId); // invoke the operation - await connectorResourceFormat.DeleteAsync(WaitUntil.Completed); + ConnectorResourceFormatData data = new ConnectorResourceFormatData + { + ConnectorType = ConnectorType.AzureBlob, + DisplayName = "testConnector", + Description = "Test connector", + ConnectorProperties = +{ +["connectionKeyVaultUrl"] = BinaryData.FromObjectAsJson(new +{ +organizationId = "XXX", +organizationUrl = "https://XXX.crmlivetie.com/", +}) +}, + }; + ArmOperation lro = await connectorResourceFormat.UpdateAsync(WaitUntil.Completed, data); + ConnectorResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectorResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_HubCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_HubCollection.cs index c0ac35a945f91..643dd3e218312 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_HubCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_HubCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_HubsCreateOrUpdate() string hubName = "sdkTestHub"; HubData data = new HubData(new AzureLocation("West US")) { - HubBillingInfo = new HubBillingInfoFormat() + HubBillingInfo = new HubBillingInfoFormat { SkuName = "B0", MinUnits = 1, @@ -95,10 +95,10 @@ public async Task Get_HubsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_HubsGet() + public async Task GetAll_HubsListByResourceGroup() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsGet.json - // this example is just showing the usage of "Hubs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsListByResourceGroup.json + // this example is just showing the usage of "Hubs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +115,22 @@ public async Task Exists_HubsGet() // get the collection of this HubResource HubCollection collection = resourceGroupResource.GetHubs(); - // invoke the operation - string hubName = "sdkTestHub"; - bool result = await collection.ExistsAsync(hubName); + // invoke the operation and iterate over the result + await foreach (HubResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HubData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HubsGet() + public async Task Exists_HubsGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsGet.json // this example is just showing the usage of "Hubs_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +152,17 @@ public async Task GetIfExists_HubsGet() // invoke the operation string hubName = "sdkTestHub"; - NullableResponse response = await collection.GetIfExistsAsync(hubName); - HubResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(hubName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_HubsListByResourceGroup() + public async Task GetIfExists_HubsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsListByResourceGroup.json - // this example is just showing the usage of "Hubs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsGet.json + // this example is just showing the usage of "Hubs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_HubsListByResourceGroup() // get the collection of this HubResource HubCollection collection = resourceGroupResource.GetHubs(); - // invoke the operation and iterate over the result - await foreach (HubResource item in collection.GetAllAsync()) + // invoke the operation + string hubName = "sdkTestHub"; + NullableResponse response = await collection.GetIfExistsAsync(hubName); + HubResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HubData resourceData = item.Data; + HubData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_HubResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_HubResource.cs index d916e94863071..d9846afe71d49 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_HubResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_HubResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.CustomerInsights.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.CustomerInsights.Samples @@ -19,10 +18,10 @@ public partial class Sample_HubResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_HubsUpdate() + public async Task Get_HubsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsUpdate.json - // this example is just showing the usage of "Hubs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsGet.json + // this example is just showing the usage of "Hubs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +37,7 @@ public async Task Update_HubsUpdate() HubResource hub = client.GetHubResource(hubResourceId); // invoke the operation - HubData data = new HubData(new AzureLocation("West US")) - { - HubBillingInfo = new HubBillingInfoFormat() - { - SkuName = "B0", - MinUnits = 1, - MaxUnits = 5, - }, - }; - HubResource result = await hub.UpdateAsync(data); + HubResource result = await hub.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -84,10 +74,10 @@ public async Task Delete_HubsDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_HubsGet() + public async Task Update_HubsUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsGet.json - // this example is just showing the usage of "Hubs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsUpdate.json + // this example is just showing the usage of "Hubs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,7 +93,16 @@ public async Task Get_HubsGet() HubResource hub = client.GetHubResource(hubResourceId); // invoke the operation - HubResource result = await hub.GetAsync(); + HubData data = new HubData(new AzureLocation("West US")) + { + HubBillingInfo = new HubBillingInfoFormat + { + SkuName = "B0", + MinUnits = 1, + MaxUnits = 5, + }, + }; + HubResource result = await hub.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -112,37 +111,6 @@ public async Task Get_HubsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetHubs_HubsList() - { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsList.json - // this example is just showing the usage of "Hubs_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (HubResource item in subscriptionResource.GetHubsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HubData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetRoles_RolesListByHub() @@ -193,7 +161,7 @@ public async Task GetUploadUrlForEntityTypeImage_ImagesGetUploadUrlForEntityType HubResource hub = client.GetHubResource(hubResourceId); // invoke the operation - GetImageUploadUrlInput input = new GetImageUploadUrlInput() + GetImageUploadUrlInput input = new GetImageUploadUrlInput { EntityType = "Profile", EntityTypeName = "Contact", @@ -225,7 +193,7 @@ public async Task GetUploadUrlForDataImage_ImagesGetUploadUrlForData() HubResource hub = client.GetHubResource(hubResourceId); // invoke the operation - GetImageUploadUrlInput input = new GetImageUploadUrlInput() + GetImageUploadUrlInput input = new GetImageUploadUrlInput { EntityType = "Profile", EntityTypeName = "Contact", diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_InteractionResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_InteractionResourceFormatCollection.cs index a939f66d0e55c..e222a6e22afe3 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_InteractionResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_InteractionResourceFormatCollection.cs @@ -41,24 +41,18 @@ public async Task CreateOrUpdate_InteractionsCreateOrUpdate() // invoke the operation string interactionName = "TestProfileType396"; - InteractionResourceFormatData data = new InteractionResourceFormatData() + InteractionResourceFormatData data = new InteractionResourceFormatData { SmallImage = "\\\\Images\\\\smallImage", MediumImage = "\\\\Images\\\\MediumImage", LargeImage = "\\\\Images\\\\LargeImage", ApiEntitySetName = "TestInteractionType6358", - Fields = -{ -new PropertyDefinition("TestInteractionType6358","Edm.String") + Fields = {new PropertyDefinition("TestInteractionType6358", "Edm.String") { IsArray = false, IsRequired = true, -},new PropertyDefinition("profile1","Edm.String") -}, - IdPropertyNames = -{ -"TestInteractionType6358" -}, +}, new PropertyDefinition("profile1", "Edm.String")}, + IdPropertyNames = { "TestInteractionType6358" }, PrimaryParticipantProfilePropertyName = "profile1", }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, interactionName, data); @@ -107,10 +101,10 @@ public async Task Get_InteractionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_InteractionsGet() + public async Task GetAll_InteractionsListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/InteractionsGet.json - // this example is just showing the usage of "Interactions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/InteractionsListByHub.json + // this example is just showing the usage of "Interactions_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -128,16 +122,22 @@ public async Task Exists_InteractionsGet() // get the collection of this InteractionResourceFormatResource InteractionResourceFormatCollection collection = hub.GetInteractionResourceFormats(); - // invoke the operation - string interactionName = "TestInteractionType6358"; - bool result = await collection.ExistsAsync(interactionName); + // invoke the operation and iterate over the result + await foreach (InteractionResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InteractionResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_InteractionsGet() + public async Task Exists_InteractionsGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/InteractionsGet.json // this example is just showing the usage of "Interactions_Get" operation, for the dependent resources, they will have to be created separately. @@ -160,29 +160,17 @@ public async Task GetIfExists_InteractionsGet() // invoke the operation string interactionName = "TestInteractionType6358"; - NullableResponse response = await collection.GetIfExistsAsync(interactionName); - InteractionResourceFormatResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(interactionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InteractionResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InteractionsListByHub() + public async Task GetIfExists_InteractionsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/InteractionsListByHub.json - // this example is just showing the usage of "Interactions_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/InteractionsGet.json + // this example is just showing the usage of "Interactions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -200,17 +188,23 @@ public async Task GetAll_InteractionsListByHub() // get the collection of this InteractionResourceFormatResource InteractionResourceFormatCollection collection = hub.GetInteractionResourceFormats(); - // invoke the operation and iterate over the result - await foreach (InteractionResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string interactionName = "TestInteractionType6358"; + NullableResponse response = await collection.GetIfExistsAsync(interactionName); + InteractionResourceFormatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - InteractionResourceFormatData resourceData = item.Data; + InteractionResourceFormatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_InteractionResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_InteractionResourceFormatResource.cs index 25443d8875c41..fe958894cea95 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_InteractionResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_InteractionResourceFormatResource.cs @@ -18,10 +18,10 @@ public partial class Sample_InteractionResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_InteractionsCreateOrUpdate() + public async Task Get_InteractionsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/InteractionsCreateOrUpdate.json - // this example is just showing the usage of "Interactions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/InteractionsGet.json + // this example is just showing the usage of "Interactions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,33 +33,12 @@ public async Task Update_InteractionsCreateOrUpdate() string subscriptionId = "subid"; string resourceGroupName = "TestHubRG"; string hubName = "sdkTestHub"; - string interactionName = "TestProfileType396"; + string interactionName = "TestInteractionType6358"; ResourceIdentifier interactionResourceFormatResourceId = InteractionResourceFormatResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hubName, interactionName); InteractionResourceFormatResource interactionResourceFormat = client.GetInteractionResourceFormatResource(interactionResourceFormatResourceId); // invoke the operation - InteractionResourceFormatData data = new InteractionResourceFormatData() - { - SmallImage = "\\\\Images\\\\smallImage", - MediumImage = "\\\\Images\\\\MediumImage", - LargeImage = "\\\\Images\\\\LargeImage", - ApiEntitySetName = "TestInteractionType6358", - Fields = -{ -new PropertyDefinition("TestInteractionType6358","Edm.String") -{ -IsArray = false, -IsRequired = true, -},new PropertyDefinition("profile1","Edm.String") -}, - IdPropertyNames = -{ -"TestInteractionType6358" -}, - PrimaryParticipantProfilePropertyName = "profile1", - }; - ArmOperation lro = await interactionResourceFormat.UpdateAsync(WaitUntil.Completed, data); - InteractionResourceFormatResource result = lro.Value; + InteractionResourceFormatResource result = await interactionResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -70,10 +49,10 @@ public async Task Update_InteractionsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_InteractionsGet() + public async Task Update_InteractionsCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/InteractionsGet.json - // this example is just showing the usage of "Interactions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/InteractionsCreateOrUpdate.json + // this example is just showing the usage of "Interactions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -85,12 +64,27 @@ public async Task Get_InteractionsGet() string subscriptionId = "subid"; string resourceGroupName = "TestHubRG"; string hubName = "sdkTestHub"; - string interactionName = "TestInteractionType6358"; + string interactionName = "TestProfileType396"; ResourceIdentifier interactionResourceFormatResourceId = InteractionResourceFormatResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hubName, interactionName); InteractionResourceFormatResource interactionResourceFormat = client.GetInteractionResourceFormatResource(interactionResourceFormatResourceId); // invoke the operation - InteractionResourceFormatResource result = await interactionResourceFormat.GetAsync(); + InteractionResourceFormatData data = new InteractionResourceFormatData + { + SmallImage = "\\\\Images\\\\smallImage", + MediumImage = "\\\\Images\\\\MediumImage", + LargeImage = "\\\\Images\\\\LargeImage", + ApiEntitySetName = "TestInteractionType6358", + Fields = {new PropertyDefinition("TestInteractionType6358", "Edm.String") +{ +IsArray = false, +IsRequired = true, +}, new PropertyDefinition("profile1", "Edm.String")}, + IdPropertyNames = { "TestInteractionType6358" }, + PrimaryParticipantProfilePropertyName = "profile1", + }; + ArmOperation lro = await interactionResourceFormat.UpdateAsync(WaitUntil.Completed, data); + InteractionResourceFormatResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_KpiResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_KpiResourceFormatCollection.cs index d617652b374bf..34c290418a0a8 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_KpiResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_KpiResourceFormatCollection.cs @@ -41,31 +41,25 @@ public async Task CreateOrUpdate_KpiCreateOrUpdate() // invoke the operation string kpiName = "kpiTest45453647"; - KpiResourceFormatData data = new KpiResourceFormatData() + KpiResourceFormatData data = new KpiResourceFormatData { EntityType = EntityType.Profile, EntityTypeName = "testProfile2327128", DisplayName = { -["en-us"] = "Kpi DisplayName", +["en-us"] = "Kpi DisplayName" }, Description = { -["en-us"] = "Kpi Description", +["en-us"] = "Kpi Description" }, CalculationWindow = CalculationWindowType.Day, Function = KpiFunction.Sum, Expression = "SavingAccountBalance", Unit = "unit", - GroupBy = -{ -"SavingAccountBalance" -}, + GroupBy = { "SavingAccountBalance" }, ThresHolds = new KpiThresholds(5M, 50M, true), - Aliases = -{ -new KpiAlias("alias","Id+4") -}, + Aliases = { new KpiAlias("alias", "Id+4") }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, kpiName, data); KpiResourceFormatResource result = lro.Value; @@ -113,10 +107,10 @@ public async Task Get_KpiGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KpiGet() + public async Task GetAll_KpiListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiGet.json - // this example is just showing the usage of "Kpi_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiListByHub.json + // this example is just showing the usage of "Kpi_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,16 +128,22 @@ public async Task Exists_KpiGet() // get the collection of this KpiResourceFormatResource KpiResourceFormatCollection collection = hub.GetKpiResourceFormats(); - // invoke the operation - string kpiName = "kpiTest45453647"; - bool result = await collection.ExistsAsync(kpiName); + // invoke the operation and iterate over the result + await foreach (KpiResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KpiResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KpiGet() + public async Task Exists_KpiGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiGet.json // this example is just showing the usage of "Kpi_Get" operation, for the dependent resources, they will have to be created separately. @@ -166,29 +166,17 @@ public async Task GetIfExists_KpiGet() // invoke the operation string kpiName = "kpiTest45453647"; - NullableResponse response = await collection.GetIfExistsAsync(kpiName); - KpiResourceFormatResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(kpiName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KpiResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KpiListByHub() + public async Task GetIfExists_KpiGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiListByHub.json - // this example is just showing the usage of "Kpi_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiGet.json + // this example is just showing the usage of "Kpi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -206,17 +194,23 @@ public async Task GetAll_KpiListByHub() // get the collection of this KpiResourceFormatResource KpiResourceFormatCollection collection = hub.GetKpiResourceFormats(); - // invoke the operation and iterate over the result - await foreach (KpiResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string kpiName = "kpiTest45453647"; + NullableResponse response = await collection.GetIfExistsAsync(kpiName); + KpiResourceFormatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KpiResourceFormatData resourceData = item.Data; + KpiResourceFormatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_KpiResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_KpiResourceFormatResource.cs index 557a6589a9875..2c02d8e31dd86 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_KpiResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_KpiResourceFormatResource.cs @@ -18,10 +18,10 @@ public partial class Sample_KpiResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KpiCreateOrUpdate() + public async Task Get_KpiGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiCreateOrUpdate.json - // this example is just showing the usage of "Kpi_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiGet.json + // this example is just showing the usage of "Kpi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,34 +38,7 @@ public async Task Update_KpiCreateOrUpdate() KpiResourceFormatResource kpiResourceFormat = client.GetKpiResourceFormatResource(kpiResourceFormatResourceId); // invoke the operation - KpiResourceFormatData data = new KpiResourceFormatData() - { - EntityType = EntityType.Profile, - EntityTypeName = "testProfile2327128", - DisplayName = -{ -["en-us"] = "Kpi DisplayName", -}, - Description = -{ -["en-us"] = "Kpi Description", -}, - CalculationWindow = CalculationWindowType.Day, - Function = KpiFunction.Sum, - Expression = "SavingAccountBalance", - Unit = "unit", - GroupBy = -{ -"SavingAccountBalance" -}, - ThresHolds = new KpiThresholds(5M, 50M, true), - Aliases = -{ -new KpiAlias("alias","Id+4") -}, - }; - ArmOperation lro = await kpiResourceFormat.UpdateAsync(WaitUntil.Completed, data); - KpiResourceFormatResource result = lro.Value; + KpiResourceFormatResource result = await kpiResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -76,10 +49,10 @@ public async Task Update_KpiCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KpiGet() + public async Task Delete_KpiDelete() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiGet.json - // this example is just showing the usage of "Kpi_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiDelete.json + // this example is just showing the usage of "Kpi_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,21 +69,17 @@ public async Task Get_KpiGet() KpiResourceFormatResource kpiResourceFormat = client.GetKpiResourceFormatResource(kpiResourceFormatResourceId); // invoke the operation - KpiResourceFormatResource result = await kpiResourceFormat.GetAsync(); + await kpiResourceFormat.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KpiResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KpiDelete() + public async Task Update_KpiCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiDelete.json - // this example is just showing the usage of "Kpi_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/KpiCreateOrUpdate.json + // this example is just showing the usage of "Kpi_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,9 +96,34 @@ public async Task Delete_KpiDelete() KpiResourceFormatResource kpiResourceFormat = client.GetKpiResourceFormatResource(kpiResourceFormatResourceId); // invoke the operation - await kpiResourceFormat.DeleteAsync(WaitUntil.Completed); + KpiResourceFormatData data = new KpiResourceFormatData + { + EntityType = EntityType.Profile, + EntityTypeName = "testProfile2327128", + DisplayName = +{ +["en-us"] = "Kpi DisplayName" +}, + Description = +{ +["en-us"] = "Kpi Description" +}, + CalculationWindow = CalculationWindowType.Day, + Function = KpiFunction.Sum, + Expression = "SavingAccountBalance", + Unit = "unit", + GroupBy = { "SavingAccountBalance" }, + ThresHolds = new KpiThresholds(5M, 50M, true), + Aliases = { new KpiAlias("alias", "Id+4") }, + }; + ArmOperation lro = await kpiResourceFormat.UpdateAsync(WaitUntil.Completed, data); + KpiResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KpiResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_LinkResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_LinkResourceFormatCollection.cs index dc10c3f553e62..418ef46612df7 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_LinkResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_LinkResourceFormatCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_LinksCreateOrUpdate() // invoke the operation string linkName = "linkTest4806"; - LinkResourceFormatData data = new LinkResourceFormatData() + LinkResourceFormatData data = new LinkResourceFormatData { SourceEntityType = EntityType.Interaction, TargetEntityType = EntityType.Profile, @@ -49,23 +49,17 @@ public async Task CreateOrUpdate_LinksCreateOrUpdate() TargetEntityTypeName = "testProfile1446", DisplayName = { -["en-us"] = "Link DisplayName", +["en-us"] = "Link DisplayName" }, Description = { -["en-us"] = "Link Description", +["en-us"] = "Link Description" }, - Mappings = -{ -new TypePropertiesMapping("testInteraction1949","testProfile1446") + Mappings = {new TypePropertiesMapping("testInteraction1949", "testProfile1446") { LinkType = LinkType.UpdateAlways, -} -}, - ParticipantPropertyReferences = -{ -new ParticipantPropertyReference("testInteraction1949","ProfileId") -}, +}}, + ParticipantPropertyReferences = { new ParticipantPropertyReference("testInteraction1949", "ProfileId") }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkName, data); LinkResourceFormatResource result = lro.Value; @@ -113,10 +107,10 @@ public async Task Get_LinksGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LinksGet() + public async Task GetAll_LinksListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksGet.json - // this example is just showing the usage of "Links_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksListByHub.json + // this example is just showing the usage of "Links_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,16 +128,22 @@ public async Task Exists_LinksGet() // get the collection of this LinkResourceFormatResource LinkResourceFormatCollection collection = hub.GetLinkResourceFormats(); - // invoke the operation - string linkName = "linkTest4806"; - bool result = await collection.ExistsAsync(linkName); + // invoke the operation and iterate over the result + await foreach (LinkResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LinkResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LinksGet() + public async Task Exists_LinksGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksGet.json // this example is just showing the usage of "Links_Get" operation, for the dependent resources, they will have to be created separately. @@ -166,29 +166,17 @@ public async Task GetIfExists_LinksGet() // invoke the operation string linkName = "linkTest4806"; - NullableResponse response = await collection.GetIfExistsAsync(linkName); - LinkResourceFormatResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(linkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LinkResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LinksListByHub() + public async Task GetIfExists_LinksGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksListByHub.json - // this example is just showing the usage of "Links_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksGet.json + // this example is just showing the usage of "Links_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -206,17 +194,23 @@ public async Task GetAll_LinksListByHub() // get the collection of this LinkResourceFormatResource LinkResourceFormatCollection collection = hub.GetLinkResourceFormats(); - // invoke the operation and iterate over the result - await foreach (LinkResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string linkName = "linkTest4806"; + NullableResponse response = await collection.GetIfExistsAsync(linkName); + LinkResourceFormatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LinkResourceFormatData resourceData = item.Data; + LinkResourceFormatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_LinkResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_LinkResourceFormatResource.cs index d753345addd03..9e317c49004de 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_LinkResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_LinkResourceFormatResource.cs @@ -18,10 +18,10 @@ public partial class Sample_LinkResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_LinksCreateOrUpdate() + public async Task Get_LinksGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksCreateOrUpdate.json - // this example is just showing the usage of "Links_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksGet.json + // this example is just showing the usage of "Links_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,34 +38,7 @@ public async Task Update_LinksCreateOrUpdate() LinkResourceFormatResource linkResourceFormat = client.GetLinkResourceFormatResource(linkResourceFormatResourceId); // invoke the operation - LinkResourceFormatData data = new LinkResourceFormatData() - { - SourceEntityType = EntityType.Interaction, - TargetEntityType = EntityType.Profile, - SourceEntityTypeName = "testInteraction1949", - TargetEntityTypeName = "testProfile1446", - DisplayName = -{ -["en-us"] = "Link DisplayName", -}, - Description = -{ -["en-us"] = "Link Description", -}, - Mappings = -{ -new TypePropertiesMapping("testInteraction1949","testProfile1446") -{ -LinkType = LinkType.UpdateAlways, -} -}, - ParticipantPropertyReferences = -{ -new ParticipantPropertyReference("testInteraction1949","ProfileId") -}, - }; - ArmOperation lro = await linkResourceFormat.UpdateAsync(WaitUntil.Completed, data); - LinkResourceFormatResource result = lro.Value; + LinkResourceFormatResource result = await linkResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -76,10 +49,10 @@ public async Task Update_LinksCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LinksGet() + public async Task Delete_LinksDelete() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksGet.json - // this example is just showing the usage of "Links_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksDelete.json + // this example is just showing the usage of "Links_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,21 +69,17 @@ public async Task Get_LinksGet() LinkResourceFormatResource linkResourceFormat = client.GetLinkResourceFormatResource(linkResourceFormatResourceId); // invoke the operation - LinkResourceFormatResource result = await linkResourceFormat.GetAsync(); + await linkResourceFormat.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LinkResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_LinksDelete() + public async Task Update_LinksCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksDelete.json - // this example is just showing the usage of "Links_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/LinksCreateOrUpdate.json + // this example is just showing the usage of "Links_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,9 +96,34 @@ public async Task Delete_LinksDelete() LinkResourceFormatResource linkResourceFormat = client.GetLinkResourceFormatResource(linkResourceFormatResourceId); // invoke the operation - await linkResourceFormat.DeleteAsync(WaitUntil.Completed); + LinkResourceFormatData data = new LinkResourceFormatData + { + SourceEntityType = EntityType.Interaction, + TargetEntityType = EntityType.Profile, + SourceEntityTypeName = "testInteraction1949", + TargetEntityTypeName = "testProfile1446", + DisplayName = +{ +["en-us"] = "Link DisplayName" +}, + Description = +{ +["en-us"] = "Link Description" +}, + Mappings = {new TypePropertiesMapping("testInteraction1949", "testProfile1446") +{ +LinkType = LinkType.UpdateAlways, +}}, + ParticipantPropertyReferences = { new ParticipantPropertyReference("testInteraction1949", "ProfileId") }, + }; + ArmOperation lro = await linkResourceFormat.UpdateAsync(WaitUntil.Completed, data); + LinkResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LinkResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_PredictionResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_PredictionResourceFormatCollection.cs index 9aedb101cee0f..93c7a2cb405e6 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_PredictionResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_PredictionResourceFormatCollection.cs @@ -41,25 +41,19 @@ public async Task CreateOrUpdate_PredictionsCreateOrUpdate() // invoke the operation string predictionName = "sdktest"; - PredictionResourceFormatData data = new PredictionResourceFormatData() + PredictionResourceFormatData data = new PredictionResourceFormatData { Description = { -["en-us"] = "sdktest", +["en-us"] = "sdktest" }, DisplayName = { -["en-us"] = "sdktest", -}, - InvolvedInteractionTypes = -{ -}, - InvolvedKpiTypes = -{ -}, - InvolvedRelationships = -{ +["en-us"] = "sdktest" }, + InvolvedInteractionTypes = { }, + InvolvedKpiTypes = { }, + InvolvedRelationships = { }, NegativeOutcomeExpression = "Customers.FirstName = 'Mike'", PositiveOutcomeExpression = "Customers.FirstName = 'David'", PrimaryProfileType = "Customers", @@ -68,9 +62,7 @@ public async Task CreateOrUpdate_PredictionsCreateOrUpdate() AutoAnalyze = true, Mappings = new PredictionMappings("sdktest_Score", "sdktest_Grade", "sdktest_Reason"), ScoreLabel = "score label", - Grades = -{ -}, + Grades = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, predictionName, data); PredictionResourceFormatResource result = lro.Value; @@ -118,10 +110,10 @@ public async Task Get_PredictionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PredictionsGet() + public async Task GetAll_PredictionsListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsGet.json - // this example is just showing the usage of "Predictions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsListByHub.json + // this example is just showing the usage of "Predictions_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,16 +131,22 @@ public async Task Exists_PredictionsGet() // get the collection of this PredictionResourceFormatResource PredictionResourceFormatCollection collection = hub.GetPredictionResourceFormats(); - // invoke the operation - string predictionName = "sdktest"; - bool result = await collection.ExistsAsync(predictionName); + // invoke the operation and iterate over the result + await foreach (PredictionResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PredictionResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PredictionsGet() + public async Task Exists_PredictionsGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsGet.json // this example is just showing the usage of "Predictions_Get" operation, for the dependent resources, they will have to be created separately. @@ -171,29 +169,17 @@ public async Task GetIfExists_PredictionsGet() // invoke the operation string predictionName = "sdktest"; - NullableResponse response = await collection.GetIfExistsAsync(predictionName); - PredictionResourceFormatResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(predictionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PredictionResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PredictionsListByHub() + public async Task GetIfExists_PredictionsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsListByHub.json - // this example is just showing the usage of "Predictions_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsGet.json + // this example is just showing the usage of "Predictions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -211,17 +197,23 @@ public async Task GetAll_PredictionsListByHub() // get the collection of this PredictionResourceFormatResource PredictionResourceFormatCollection collection = hub.GetPredictionResourceFormats(); - // invoke the operation and iterate over the result - await foreach (PredictionResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string predictionName = "sdktest"; + NullableResponse response = await collection.GetIfExistsAsync(predictionName); + PredictionResourceFormatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PredictionResourceFormatData resourceData = item.Data; + PredictionResourceFormatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_PredictionResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_PredictionResourceFormatResource.cs index 6aa80397a46b3..e2c40aefeb213 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_PredictionResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_PredictionResourceFormatResource.cs @@ -18,10 +18,10 @@ public partial class Sample_PredictionResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PredictionsCreateOrUpdate() + public async Task Get_PredictionsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsCreateOrUpdate.json - // this example is just showing the usage of "Predictions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsGet.json + // this example is just showing the usage of "Predictions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,39 +38,7 @@ public async Task Update_PredictionsCreateOrUpdate() PredictionResourceFormatResource predictionResourceFormat = client.GetPredictionResourceFormatResource(predictionResourceFormatResourceId); // invoke the operation - PredictionResourceFormatData data = new PredictionResourceFormatData() - { - Description = -{ -["en-us"] = "sdktest", -}, - DisplayName = -{ -["en-us"] = "sdktest", -}, - InvolvedInteractionTypes = -{ -}, - InvolvedKpiTypes = -{ -}, - InvolvedRelationships = -{ -}, - NegativeOutcomeExpression = "Customers.FirstName = 'Mike'", - PositiveOutcomeExpression = "Customers.FirstName = 'David'", - PrimaryProfileType = "Customers", - PredictionName = "sdktest", - ScopeExpression = "*", - AutoAnalyze = true, - Mappings = new PredictionMappings("sdktest_Score", "sdktest_Grade", "sdktest_Reason"), - ScoreLabel = "score label", - Grades = -{ -}, - }; - ArmOperation lro = await predictionResourceFormat.UpdateAsync(WaitUntil.Completed, data); - PredictionResourceFormatResource result = lro.Value; + PredictionResourceFormatResource result = await predictionResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +49,10 @@ public async Task Update_PredictionsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PredictionsGet() + public async Task Delete_PredictionsDelete() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsGet.json - // this example is just showing the usage of "Predictions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsDelete.json + // this example is just showing the usage of "Predictions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,21 +69,17 @@ public async Task Get_PredictionsGet() PredictionResourceFormatResource predictionResourceFormat = client.GetPredictionResourceFormatResource(predictionResourceFormatResourceId); // invoke the operation - PredictionResourceFormatResource result = await predictionResourceFormat.GetAsync(); + await predictionResourceFormat.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PredictionResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PredictionsDelete() + public async Task Update_PredictionsCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsDelete.json - // this example is just showing the usage of "Predictions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/PredictionsCreateOrUpdate.json + // this example is just showing the usage of "Predictions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,9 +96,37 @@ public async Task Delete_PredictionsDelete() PredictionResourceFormatResource predictionResourceFormat = client.GetPredictionResourceFormatResource(predictionResourceFormatResourceId); // invoke the operation - await predictionResourceFormat.DeleteAsync(WaitUntil.Completed); + PredictionResourceFormatData data = new PredictionResourceFormatData + { + Description = +{ +["en-us"] = "sdktest" +}, + DisplayName = +{ +["en-us"] = "sdktest" +}, + InvolvedInteractionTypes = { }, + InvolvedKpiTypes = { }, + InvolvedRelationships = { }, + NegativeOutcomeExpression = "Customers.FirstName = 'Mike'", + PositiveOutcomeExpression = "Customers.FirstName = 'David'", + PrimaryProfileType = "Customers", + PredictionName = "sdktest", + ScopeExpression = "*", + AutoAnalyze = true, + Mappings = new PredictionMappings("sdktest_Score", "sdktest_Grade", "sdktest_Reason"), + ScoreLabel = "score label", + Grades = { }, + }; + ArmOperation lro = await predictionResourceFormat.UpdateAsync(WaitUntil.Completed, data); + PredictionResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PredictionResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ProfileResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ProfileResourceFormatCollection.cs index 129e16aa27e92..d17089a35392a 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ProfileResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ProfileResourceFormatCollection.cs @@ -41,47 +41,35 @@ public async Task CreateOrUpdate_ProfilesCreateOrUpdate() // invoke the operation string profileName = "TestProfileType396"; - ProfileResourceFormatData data = new ProfileResourceFormatData() + ProfileResourceFormatData data = new ProfileResourceFormatData { SmallImage = "\\\\Images\\\\smallImage", MediumImage = "\\\\Images\\\\MediumImage", LargeImage = "\\\\Images\\\\LargeImage", ApiEntitySetName = "TestProfileType396", - Fields = -{ -new PropertyDefinition("Id","Edm.String") + Fields = {new PropertyDefinition("Id", "Edm.String") { IsArray = false, IsRequired = true, -},new PropertyDefinition("ProfileId","Edm.String") +}, new PropertyDefinition("ProfileId", "Edm.String") { IsArray = false, IsRequired = true, -},new PropertyDefinition("LastName","Edm.String") +}, new PropertyDefinition("LastName", "Edm.String") { IsArray = false, IsRequired = true, -},new PropertyDefinition("TestProfileType396","Edm.String") +}, new PropertyDefinition("TestProfileType396", "Edm.String") { IsArray = false, IsRequired = true, -},new PropertyDefinition("SavingAccountBalance","Edm.Int32") +}, new PropertyDefinition("SavingAccountBalance", "Edm.Int32") { IsArray = false, IsRequired = true, -} -}, +}}, SchemaItemTypeLink = "SchemaItemTypeLink", - StrongIds = -{ -new StrongId(new string[] -{ -"Id","SavingAccountBalance" -},"Id"),new StrongId(new string[] -{ -"ProfileId","LastName" -},"ProfileId") -}, + StrongIds = { new StrongId(new string[] { "Id", "SavingAccountBalance" }, "Id"), new StrongId(new string[] { "ProfileId", "LastName" }, "ProfileId") }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); ProfileResourceFormatResource result = lro.Value; @@ -129,10 +117,10 @@ public async Task Get_ProfilesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProfilesGet() + public async Task GetAll_ProfilesListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesGet.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesListByHub.json + // this example is just showing the usage of "Profiles_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,16 +138,22 @@ public async Task Exists_ProfilesGet() // get the collection of this ProfileResourceFormatResource ProfileResourceFormatCollection collection = hub.GetProfileResourceFormats(); - // invoke the operation - string profileName = "TestProfileType396"; - bool result = await collection.ExistsAsync(profileName); + // invoke the operation and iterate over the result + await foreach (ProfileResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProfileResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProfilesGet() + public async Task Exists_ProfilesGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesGet.json // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -182,29 +176,17 @@ public async Task GetIfExists_ProfilesGet() // invoke the operation string profileName = "TestProfileType396"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - ProfileResourceFormatResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(profileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProfileResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProfilesListByHub() + public async Task GetIfExists_ProfilesGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesListByHub.json - // this example is just showing the usage of "Profiles_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesGet.json + // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -222,17 +204,23 @@ public async Task GetAll_ProfilesListByHub() // get the collection of this ProfileResourceFormatResource ProfileResourceFormatCollection collection = hub.GetProfileResourceFormats(); - // invoke the operation and iterate over the result - await foreach (ProfileResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string profileName = "TestProfileType396"; + NullableResponse response = await collection.GetIfExistsAsync(profileName); + ProfileResourceFormatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ProfileResourceFormatData resourceData = item.Data; + ProfileResourceFormatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ProfileResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ProfileResourceFormatResource.cs index df3c66c4138bd..531302395e2c0 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ProfileResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ProfileResourceFormatResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ProfileResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ProfilesCreateOrUpdate() + public async Task Get_ProfilesGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesCreateOrUpdate.json - // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesGet.json + // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,50 +38,7 @@ public async Task Update_ProfilesCreateOrUpdate() ProfileResourceFormatResource profileResourceFormat = client.GetProfileResourceFormatResource(profileResourceFormatResourceId); // invoke the operation - ProfileResourceFormatData data = new ProfileResourceFormatData() - { - SmallImage = "\\\\Images\\\\smallImage", - MediumImage = "\\\\Images\\\\MediumImage", - LargeImage = "\\\\Images\\\\LargeImage", - ApiEntitySetName = "TestProfileType396", - Fields = -{ -new PropertyDefinition("Id","Edm.String") -{ -IsArray = false, -IsRequired = true, -},new PropertyDefinition("ProfileId","Edm.String") -{ -IsArray = false, -IsRequired = true, -},new PropertyDefinition("LastName","Edm.String") -{ -IsArray = false, -IsRequired = true, -},new PropertyDefinition("TestProfileType396","Edm.String") -{ -IsArray = false, -IsRequired = true, -},new PropertyDefinition("SavingAccountBalance","Edm.Int32") -{ -IsArray = false, -IsRequired = true, -} -}, - SchemaItemTypeLink = "SchemaItemTypeLink", - StrongIds = -{ -new StrongId(new string[] -{ -"Id","SavingAccountBalance" -},"Id"),new StrongId(new string[] -{ -"ProfileId","LastName" -},"ProfileId") -}, - }; - ArmOperation lro = await profileResourceFormat.UpdateAsync(WaitUntil.Completed, data); - ProfileResourceFormatResource result = lro.Value; + ProfileResourceFormatResource result = await profileResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,10 +49,10 @@ public async Task Update_ProfilesCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProfilesGet() + public async Task Delete_ProfilesDelete() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesGet.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesDelete.json + // this example is just showing the usage of "Profiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,21 +69,17 @@ public async Task Get_ProfilesGet() ProfileResourceFormatResource profileResourceFormat = client.GetProfileResourceFormatResource(profileResourceFormatResourceId); // invoke the operation - ProfileResourceFormatResource result = await profileResourceFormat.GetAsync(); + await profileResourceFormat.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProfileResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ProfilesDelete() + public async Task Update_ProfilesCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesDelete.json - // this example is just showing the usage of "Profiles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ProfilesCreateOrUpdate.json + // this example is just showing the usage of "Profiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,9 +96,44 @@ public async Task Delete_ProfilesDelete() ProfileResourceFormatResource profileResourceFormat = client.GetProfileResourceFormatResource(profileResourceFormatResourceId); // invoke the operation - await profileResourceFormat.DeleteAsync(WaitUntil.Completed); + ProfileResourceFormatData data = new ProfileResourceFormatData + { + SmallImage = "\\\\Images\\\\smallImage", + MediumImage = "\\\\Images\\\\MediumImage", + LargeImage = "\\\\Images\\\\LargeImage", + ApiEntitySetName = "TestProfileType396", + Fields = {new PropertyDefinition("Id", "Edm.String") +{ +IsArray = false, +IsRequired = true, +}, new PropertyDefinition("ProfileId", "Edm.String") +{ +IsArray = false, +IsRequired = true, +}, new PropertyDefinition("LastName", "Edm.String") +{ +IsArray = false, +IsRequired = true, +}, new PropertyDefinition("TestProfileType396", "Edm.String") +{ +IsArray = false, +IsRequired = true, +}, new PropertyDefinition("SavingAccountBalance", "Edm.Int32") +{ +IsArray = false, +IsRequired = true, +}}, + SchemaItemTypeLink = "SchemaItemTypeLink", + StrongIds = { new StrongId(new string[] { "Id", "SavingAccountBalance" }, "Id"), new StrongId(new string[] { "ProfileId", "LastName" }, "ProfileId") }, + }; + ArmOperation lro = await profileResourceFormat.UpdateAsync(WaitUntil.Completed, data); + ProfileResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProfileResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipLinkResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipLinkResourceFormatCollection.cs index ef0e490786755..f1f36699d0318 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipLinkResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipLinkResourceFormatCollection.cs @@ -41,25 +41,19 @@ public async Task CreateOrUpdate_RelationshipLinksCreateOrUpdate() // invoke the operation string relationshipLinkName = "Somelink"; - RelationshipLinkResourceFormatData data = new RelationshipLinkResourceFormatData() + RelationshipLinkResourceFormatData data = new RelationshipLinkResourceFormatData { DisplayName = { -["en-us"] = "Link DisplayName", +["en-us"] = "Link DisplayName" }, Description = { -["en-us"] = "Link Description", +["en-us"] = "Link Description" }, InteractionType = "testInteraction4332", - ProfilePropertyReferences = -{ -new ParticipantProfilePropertyReference("profile1","ProfileId") -}, - RelatedProfilePropertyReferences = -{ -new ParticipantProfilePropertyReference("profile1","ProfileId") -}, + ProfilePropertyReferences = { new ParticipantProfilePropertyReference("profile1", "ProfileId") }, + RelatedProfilePropertyReferences = { new ParticipantProfilePropertyReference("profile1", "ProfileId") }, RelationshipName = "testProfile2326994", }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, relationshipLinkName, data); @@ -108,10 +102,10 @@ public async Task Get_RelationshipLinksGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RelationshipLinksGet() + public async Task GetAll_RelationshipLinksListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksGet.json - // this example is just showing the usage of "RelationshipLinks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksListByHub.json + // this example is just showing the usage of "RelationshipLinks_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,16 +123,22 @@ public async Task Exists_RelationshipLinksGet() // get the collection of this RelationshipLinkResourceFormatResource RelationshipLinkResourceFormatCollection collection = hub.GetRelationshipLinkResourceFormats(); - // invoke the operation - string relationshipLinkName = "Somelink"; - bool result = await collection.ExistsAsync(relationshipLinkName); + // invoke the operation and iterate over the result + await foreach (RelationshipLinkResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelationshipLinkResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RelationshipLinksGet() + public async Task Exists_RelationshipLinksGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksGet.json // this example is just showing the usage of "RelationshipLinks_Get" operation, for the dependent resources, they will have to be created separately. @@ -161,29 +161,17 @@ public async Task GetIfExists_RelationshipLinksGet() // invoke the operation string relationshipLinkName = "Somelink"; - NullableResponse response = await collection.GetIfExistsAsync(relationshipLinkName); - RelationshipLinkResourceFormatResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(relationshipLinkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelationshipLinkResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RelationshipLinksListByHub() + public async Task GetIfExists_RelationshipLinksGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksListByHub.json - // this example is just showing the usage of "RelationshipLinks_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksGet.json + // this example is just showing the usage of "RelationshipLinks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -201,17 +189,23 @@ public async Task GetAll_RelationshipLinksListByHub() // get the collection of this RelationshipLinkResourceFormatResource RelationshipLinkResourceFormatCollection collection = hub.GetRelationshipLinkResourceFormats(); - // invoke the operation and iterate over the result - await foreach (RelationshipLinkResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string relationshipLinkName = "Somelink"; + NullableResponse response = await collection.GetIfExistsAsync(relationshipLinkName); + RelationshipLinkResourceFormatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RelationshipLinkResourceFormatData resourceData = item.Data; + RelationshipLinkResourceFormatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipLinkResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipLinkResourceFormatResource.cs index 893f6653e5b19..32e3ccf6856af 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipLinkResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipLinkResourceFormatResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RelationshipLinkResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RelationshipLinksCreateOrUpdate() + public async Task Get_RelationshipLinksGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksCreateOrUpdate.json - // this example is just showing the usage of "RelationshipLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksGet.json + // this example is just showing the usage of "RelationshipLinks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,29 +38,7 @@ public async Task Update_RelationshipLinksCreateOrUpdate() RelationshipLinkResourceFormatResource relationshipLinkResourceFormat = client.GetRelationshipLinkResourceFormatResource(relationshipLinkResourceFormatResourceId); // invoke the operation - RelationshipLinkResourceFormatData data = new RelationshipLinkResourceFormatData() - { - DisplayName = -{ -["en-us"] = "Link DisplayName", -}, - Description = -{ -["en-us"] = "Link Description", -}, - InteractionType = "testInteraction4332", - ProfilePropertyReferences = -{ -new ParticipantProfilePropertyReference("profile1","ProfileId") -}, - RelatedProfilePropertyReferences = -{ -new ParticipantProfilePropertyReference("profile1","ProfileId") -}, - RelationshipName = "testProfile2326994", - }; - ArmOperation lro = await relationshipLinkResourceFormat.UpdateAsync(WaitUntil.Completed, data); - RelationshipLinkResourceFormatResource result = lro.Value; + RelationshipLinkResourceFormatResource result = await relationshipLinkResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -71,10 +49,10 @@ public async Task Update_RelationshipLinksCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelationshipLinksGet() + public async Task Delete_RelationshipLinksDelete() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksGet.json - // this example is just showing the usage of "RelationshipLinks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksDelete.json + // this example is just showing the usage of "RelationshipLinks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,21 +69,17 @@ public async Task Get_RelationshipLinksGet() RelationshipLinkResourceFormatResource relationshipLinkResourceFormat = client.GetRelationshipLinkResourceFormatResource(relationshipLinkResourceFormatResourceId); // invoke the operation - RelationshipLinkResourceFormatResource result = await relationshipLinkResourceFormat.GetAsync(); + await relationshipLinkResourceFormat.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelationshipLinkResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RelationshipLinksDelete() + public async Task Update_RelationshipLinksCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksDelete.json - // this example is just showing the usage of "RelationshipLinks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipLinksCreateOrUpdate.json + // this example is just showing the usage of "RelationshipLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,9 +96,29 @@ public async Task Delete_RelationshipLinksDelete() RelationshipLinkResourceFormatResource relationshipLinkResourceFormat = client.GetRelationshipLinkResourceFormatResource(relationshipLinkResourceFormatResourceId); // invoke the operation - await relationshipLinkResourceFormat.DeleteAsync(WaitUntil.Completed); + RelationshipLinkResourceFormatData data = new RelationshipLinkResourceFormatData + { + DisplayName = +{ +["en-us"] = "Link DisplayName" +}, + Description = +{ +["en-us"] = "Link Description" +}, + InteractionType = "testInteraction4332", + ProfilePropertyReferences = { new ParticipantProfilePropertyReference("profile1", "ProfileId") }, + RelatedProfilePropertyReferences = { new ParticipantProfilePropertyReference("profile1", "ProfileId") }, + RelationshipName = "testProfile2326994", + }; + ArmOperation lro = await relationshipLinkResourceFormat.UpdateAsync(WaitUntil.Completed, data); + RelationshipLinkResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelationshipLinkResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipResourceFormatCollection.cs index eafb039f855c6..932db4900edde 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipResourceFormatCollection.cs @@ -41,20 +41,18 @@ public async Task CreateOrUpdate_RelationshipsCreateOrUpdate() // invoke the operation string relationshipName = "SomeRelationship"; - RelationshipResourceFormatData data = new RelationshipResourceFormatData() + RelationshipResourceFormatData data = new RelationshipResourceFormatData { Cardinality = CardinalityType.OneToOne, DisplayName = { -["en-us"] = "Relationship DisplayName", +["en-us"] = "Relationship DisplayName" }, Description = { -["en-us"] = "Relationship Description", -}, - Fields = -{ +["en-us"] = "Relationship Description" }, + Fields = { }, ProfileType = "testProfile2326994", RelatedProfileType = "testProfile2326994", }; @@ -104,10 +102,10 @@ public async Task Get_RelationshipsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RelationshipsGet() + public async Task GetAll_RelationshipsListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsGet.json - // this example is just showing the usage of "Relationships_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsListByHub.json + // this example is just showing the usage of "Relationships_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,16 +123,22 @@ public async Task Exists_RelationshipsGet() // get the collection of this RelationshipResourceFormatResource RelationshipResourceFormatCollection collection = hub.GetRelationshipResourceFormats(); - // invoke the operation - string relationshipName = "SomeRelationship"; - bool result = await collection.ExistsAsync(relationshipName); + // invoke the operation and iterate over the result + await foreach (RelationshipResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelationshipResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RelationshipsGet() + public async Task Exists_RelationshipsGet() { // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsGet.json // this example is just showing the usage of "Relationships_Get" operation, for the dependent resources, they will have to be created separately. @@ -157,29 +161,17 @@ public async Task GetIfExists_RelationshipsGet() // invoke the operation string relationshipName = "SomeRelationship"; - NullableResponse response = await collection.GetIfExistsAsync(relationshipName); - RelationshipResourceFormatResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(relationshipName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelationshipResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RelationshipsListByHub() + public async Task GetIfExists_RelationshipsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsListByHub.json - // this example is just showing the usage of "Relationships_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsGet.json + // this example is just showing the usage of "Relationships_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -197,17 +189,23 @@ public async Task GetAll_RelationshipsListByHub() // get the collection of this RelationshipResourceFormatResource RelationshipResourceFormatCollection collection = hub.GetRelationshipResourceFormats(); - // invoke the operation and iterate over the result - await foreach (RelationshipResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string relationshipName = "SomeRelationship"; + NullableResponse response = await collection.GetIfExistsAsync(relationshipName); + RelationshipResourceFormatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RelationshipResourceFormatData resourceData = item.Data; + RelationshipResourceFormatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipResourceFormatResource.cs index 12fb2b03b210e..20d2ad380b668 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RelationshipResourceFormatResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RelationshipResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RelationshipsCreateOrUpdate() + public async Task Get_RelationshipsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsCreateOrUpdate.json - // this example is just showing the usage of "Relationships_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsGet.json + // this example is just showing the usage of "Relationships_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,7 @@ public async Task Update_RelationshipsCreateOrUpdate() RelationshipResourceFormatResource relationshipResourceFormat = client.GetRelationshipResourceFormatResource(relationshipResourceFormatResourceId); // invoke the operation - RelationshipResourceFormatData data = new RelationshipResourceFormatData() - { - Cardinality = CardinalityType.OneToOne, - DisplayName = -{ -["en-us"] = "Relationship DisplayName", -}, - Description = -{ -["en-us"] = "Relationship Description", -}, - Fields = -{ -}, - ProfileType = "testProfile2326994", - RelatedProfileType = "testProfile2326994", - }; - ArmOperation lro = await relationshipResourceFormat.UpdateAsync(WaitUntil.Completed, data); - RelationshipResourceFormatResource result = lro.Value; + RelationshipResourceFormatResource result = await relationshipResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -67,10 +49,10 @@ public async Task Update_RelationshipsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RelationshipsGet() + public async Task Delete_RelationshipsDelete() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsGet.json - // this example is just showing the usage of "Relationships_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsDelete.json + // this example is just showing the usage of "Relationships_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -87,21 +69,17 @@ public async Task Get_RelationshipsGet() RelationshipResourceFormatResource relationshipResourceFormat = client.GetRelationshipResourceFormatResource(relationshipResourceFormatResourceId); // invoke the operation - RelationshipResourceFormatResource result = await relationshipResourceFormat.GetAsync(); + await relationshipResourceFormat.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RelationshipResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RelationshipsDelete() + public async Task Update_RelationshipsCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsDelete.json - // this example is just showing the usage of "Relationships_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RelationshipsCreateOrUpdate.json + // this example is just showing the usage of "Relationships_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,9 +96,29 @@ public async Task Delete_RelationshipsDelete() RelationshipResourceFormatResource relationshipResourceFormat = client.GetRelationshipResourceFormatResource(relationshipResourceFormatResourceId); // invoke the operation - await relationshipResourceFormat.DeleteAsync(WaitUntil.Completed); + RelationshipResourceFormatData data = new RelationshipResourceFormatData + { + Cardinality = CardinalityType.OneToOne, + DisplayName = +{ +["en-us"] = "Relationship DisplayName" +}, + Description = +{ +["en-us"] = "Relationship Description" +}, + Fields = { }, + ProfileType = "testProfile2326994", + RelatedProfileType = "testProfile2326994", + }; + ArmOperation lro = await relationshipResourceFormat.UpdateAsync(WaitUntil.Completed, data); + RelationshipResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RelationshipResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RoleAssignmentResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RoleAssignmentResourceFormatCollection.cs index c764f9ed06190..cb04306d294ff 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RoleAssignmentResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RoleAssignmentResourceFormatCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RoleAssignmentResourceFormatCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RoleAssignmentsListByHub() + public async Task CreateOrUpdate_RoleAssignmentsCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsListByHub.json - // this example is just showing the usage of "RoleAssignments_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsCreateOrUpdate.json + // this example is just showing the usage of "RoleAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,29 @@ public async Task GetAll_RoleAssignmentsListByHub() // get the collection of this RoleAssignmentResourceFormatResource RoleAssignmentResourceFormatCollection collection = hub.GetRoleAssignmentResourceFormats(); - // invoke the operation and iterate over the result - await foreach (RoleAssignmentResourceFormatResource item in collection.GetAllAsync()) + // invoke the operation + string assignmentName = "assignmentName8976"; + RoleAssignmentResourceFormatData data = new RoleAssignmentResourceFormatData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleAssignmentResourceFormatData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Role = RoleType.Admin, + Principals = { new AssignmentPrincipal("4c54c38ffa9b416ba5a6d6c8a20cbe7e", "User"), new AssignmentPrincipal("93061d15a5054f2b9948ae25724cf9d5", "User") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assignmentName, data); + RoleAssignmentResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleAssignmentResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RoleAssignmentsCreateOrUpdate() + public async Task Get_RoleAssignmentsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsCreateOrUpdate.json - // this example is just showing the usage of "RoleAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsGet.json + // this example is just showing the usage of "RoleAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,16 +81,7 @@ public async Task CreateOrUpdate_RoleAssignmentsCreateOrUpdate() // invoke the operation string assignmentName = "assignmentName8976"; - RoleAssignmentResourceFormatData data = new RoleAssignmentResourceFormatData() - { - Role = RoleType.Admin, - Principals = -{ -new AssignmentPrincipal("4c54c38ffa9b416ba5a6d6c8a20cbe7e","User"),new AssignmentPrincipal("93061d15a5054f2b9948ae25724cf9d5","User") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assignmentName, data); - RoleAssignmentResourceFormatResource result = lro.Value; + RoleAssignmentResourceFormatResource result = await collection.GetAsync(assignmentName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -97,10 +92,10 @@ public async Task CreateOrUpdate_RoleAssignmentsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RoleAssignmentsGet() + public async Task GetAll_RoleAssignmentsListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsGet.json - // this example is just showing the usage of "RoleAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsListByHub.json + // this example is just showing the usage of "RoleAssignments_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,15 +113,17 @@ public async Task Get_RoleAssignmentsGet() // get the collection of this RoleAssignmentResourceFormatResource RoleAssignmentResourceFormatCollection collection = hub.GetRoleAssignmentResourceFormats(); - // invoke the operation - string assignmentName = "assignmentName8976"; - RoleAssignmentResourceFormatResource result = await collection.GetAsync(assignmentName); + // invoke the operation and iterate over the result + await foreach (RoleAssignmentResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleAssignmentResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleAssignmentResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RoleAssignmentResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RoleAssignmentResourceFormatResource.cs index 89b24149e4070..a185e173398f1 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RoleAssignmentResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_RoleAssignmentResourceFormatResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RoleAssignmentResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RoleAssignmentsCreateOrUpdate() + public async Task Get_RoleAssignmentsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsCreateOrUpdate.json - // this example is just showing the usage of "RoleAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsGet.json + // this example is just showing the usage of "RoleAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,7 @@ public async Task Update_RoleAssignmentsCreateOrUpdate() RoleAssignmentResourceFormatResource roleAssignmentResourceFormat = client.GetRoleAssignmentResourceFormatResource(roleAssignmentResourceFormatResourceId); // invoke the operation - RoleAssignmentResourceFormatData data = new RoleAssignmentResourceFormatData() - { - Role = RoleType.Admin, - Principals = -{ -new AssignmentPrincipal("4c54c38ffa9b416ba5a6d6c8a20cbe7e","User"),new AssignmentPrincipal("93061d15a5054f2b9948ae25724cf9d5","User") -}, - }; - ArmOperation lro = await roleAssignmentResourceFormat.UpdateAsync(WaitUntil.Completed, data); - RoleAssignmentResourceFormatResource result = lro.Value; + RoleAssignmentResourceFormatResource result = await roleAssignmentResourceFormat.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +49,10 @@ public async Task Update_RoleAssignmentsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RoleAssignmentsGet() + public async Task Delete_RoleAssignmentsDelete() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsGet.json - // this example is just showing the usage of "RoleAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsDelete.json + // this example is just showing the usage of "RoleAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,21 +69,17 @@ public async Task Get_RoleAssignmentsGet() RoleAssignmentResourceFormatResource roleAssignmentResourceFormat = client.GetRoleAssignmentResourceFormatResource(roleAssignmentResourceFormatResourceId); // invoke the operation - RoleAssignmentResourceFormatResource result = await roleAssignmentResourceFormat.GetAsync(); + await roleAssignmentResourceFormat.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleAssignmentResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RoleAssignmentsDelete() + public async Task Update_RoleAssignmentsCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsDelete.json - // this example is just showing the usage of "RoleAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/RoleAssignmentsCreateOrUpdate.json + // this example is just showing the usage of "RoleAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,19 @@ public async Task Delete_RoleAssignmentsDelete() RoleAssignmentResourceFormatResource roleAssignmentResourceFormat = client.GetRoleAssignmentResourceFormatResource(roleAssignmentResourceFormatResourceId); // invoke the operation - await roleAssignmentResourceFormat.DeleteAsync(WaitUntil.Completed); + RoleAssignmentResourceFormatData data = new RoleAssignmentResourceFormatData + { + Role = RoleType.Admin, + Principals = { new AssignmentPrincipal("4c54c38ffa9b416ba5a6d6c8a20cbe7e", "User"), new AssignmentPrincipal("93061d15a5054f2b9948ae25724cf9d5", "User") }, + }; + ArmOperation lro = await roleAssignmentResourceFormat.UpdateAsync(WaitUntil.Completed, data); + RoleAssignmentResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleAssignmentResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..c9bb55eb1d85c --- /dev/null +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.CustomerInsights.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHubs_HubsList() + { + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/HubsList.json + // this example is just showing the usage of "Hubs_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HubResource item in subscriptionResource.GetHubsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HubData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ViewResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ViewResourceFormatCollection.cs index 2871afcf33cfa..b073cd60a28d4 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ViewResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ViewResourceFormatCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ViewResourceFormatCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ViewsListByHub() + public async Task CreateOrUpdate_ViewsCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsListByHub.json - // this example is just showing the usage of "Views_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsCreateOrUpdate.json + // this example is just showing the usage of "Views_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,26 +38,33 @@ public async Task GetAll_ViewsListByHub() // get the collection of this ViewResourceFormatResource ViewResourceFormatCollection collection = hub.GetViewResourceFormats(); - // invoke the operation and iterate over the result - string userId = "*"; - await foreach (ViewResourceFormatResource item in collection.GetAllAsync(userId)) + // invoke the operation + string viewName = "testView"; + ViewResourceFormatData data = new ViewResourceFormatData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ViewResourceFormatData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + UserId = "testUser", + DisplayName = +{ +["en"] = "some name" +}, + Definition = "{\\\"isProfileType\\\":false,\\\"profileTypes\\\":[],\\\"widgets\\\":[],\\\"style\\\":[]}", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, viewName, data); + ViewResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ViewResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ViewsCreateOrUpdate() + public async Task Get_ViewsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsCreateOrUpdate.json - // this example is just showing the usage of "Views_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsGet.json + // this example is just showing the usage of "Views_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,17 +84,8 @@ public async Task CreateOrUpdate_ViewsCreateOrUpdate() // invoke the operation string viewName = "testView"; - ViewResourceFormatData data = new ViewResourceFormatData() - { - UserId = "testUser", - DisplayName = -{ -["en"] = "some name", -}, - Definition = "{\\\"isProfileType\\\":false,\\\"profileTypes\\\":[],\\\"widgets\\\":[],\\\"style\\\":[]}", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, viewName, data); - ViewResourceFormatResource result = lro.Value; + string userId = "*"; + ViewResourceFormatResource result = await collection.GetAsync(viewName, userId); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -98,10 +96,10 @@ public async Task CreateOrUpdate_ViewsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ViewsGet() + public async Task GetAll_ViewsListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsGet.json - // this example is just showing the usage of "Views_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsListByHub.json + // this example is just showing the usage of "Views_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -119,16 +117,18 @@ public async Task Get_ViewsGet() // get the collection of this ViewResourceFormatResource ViewResourceFormatCollection collection = hub.GetViewResourceFormats(); - // invoke the operation - string viewName = "testView"; + // invoke the operation and iterate over the result string userId = "*"; - ViewResourceFormatResource result = await collection.GetAsync(viewName, userId); + await foreach (ViewResourceFormatResource item in collection.GetAllAsync(userId)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ViewResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ViewResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ViewResourceFormatResource.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ViewResourceFormatResource.cs index 23d6cf01f6b42..d9cd5dedbe5d8 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ViewResourceFormatResource.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_ViewResourceFormatResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ViewResourceFormatResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ViewsCreateOrUpdate() + public async Task Get_ViewsGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsCreateOrUpdate.json - // this example is just showing the usage of "Views_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsGet.json + // this example is just showing the usage of "Views_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,8 @@ public async Task Update_ViewsCreateOrUpdate() ViewResourceFormatResource viewResourceFormat = client.GetViewResourceFormatResource(viewResourceFormatResourceId); // invoke the operation - ViewResourceFormatData data = new ViewResourceFormatData() - { - UserId = "testUser", - DisplayName = -{ -["en"] = "some name", -}, - Definition = "{\\\"isProfileType\\\":false,\\\"profileTypes\\\":[],\\\"widgets\\\":[],\\\"style\\\":[]}", - }; - ArmOperation lro = await viewResourceFormat.UpdateAsync(WaitUntil.Completed, data); - ViewResourceFormatResource result = lro.Value; + string userId = "*"; + ViewResourceFormatResource result = await viewResourceFormat.GetAsync(userId); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +49,10 @@ public async Task Update_ViewsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ViewsGet() + public async Task Delete_ViewsDelete() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsGet.json - // this example is just showing the usage of "Views_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsDelete.json + // this example is just showing the usage of "Views_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,21 +70,17 @@ public async Task Get_ViewsGet() // invoke the operation string userId = "*"; - ViewResourceFormatResource result = await viewResourceFormat.GetAsync(userId); + await viewResourceFormat.DeleteAsync(WaitUntil.Completed, userId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ViewResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ViewsDelete() + public async Task Update_ViewsCreateOrUpdate() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsDelete.json - // this example is just showing the usage of "Views_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/ViewsCreateOrUpdate.json + // this example is just showing the usage of "Views_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,10 +97,23 @@ public async Task Delete_ViewsDelete() ViewResourceFormatResource viewResourceFormat = client.GetViewResourceFormatResource(viewResourceFormatResourceId); // invoke the operation - string userId = "*"; - await viewResourceFormat.DeleteAsync(WaitUntil.Completed, userId); + ViewResourceFormatData data = new ViewResourceFormatData + { + UserId = "testUser", + DisplayName = +{ +["en"] = "some name" +}, + Definition = "{\\\"isProfileType\\\":false,\\\"profileTypes\\\":[],\\\"widgets\\\":[],\\\"style\\\":[]}", + }; + ArmOperation lro = await viewResourceFormat.UpdateAsync(WaitUntil.Completed, data); + ViewResourceFormatResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ViewResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_WidgetTypeResourceFormatCollection.cs b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_WidgetTypeResourceFormatCollection.cs index ad6632510d777..18f9a6af288c9 100644 --- a/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_WidgetTypeResourceFormatCollection.cs +++ b/sdk/customer-insights/Azure.ResourceManager.CustomerInsights/samples/Generated/Samples/Sample_WidgetTypeResourceFormatCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WidgetTypeResourceFormatCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WidgetTypesListByHub() + public async Task Get_WidgetTypesGet() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/WidgetTypesListByHub.json - // this example is just showing the usage of "WidgetTypes_ListByHub" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/WidgetTypesGet.json + // this example is just showing the usage of "WidgetTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_WidgetTypesListByHub() // get the collection of this WidgetTypeResourceFormatResource WidgetTypeResourceFormatCollection collection = hub.GetWidgetTypeResourceFormats(); - // invoke the operation and iterate over the result - await foreach (WidgetTypeResourceFormatResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WidgetTypeResourceFormatData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string widgetTypeName = "ActivityGauge"; + WidgetTypeResourceFormatResource result = await collection.GetAsync(widgetTypeName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WidgetTypeResourceFormatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WidgetTypesGet() + public async Task GetAll_WidgetTypesListByHub() { - // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/WidgetTypesGet.json - // this example is just showing the usage of "WidgetTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/customer-insights/resource-manager/Microsoft.CustomerInsights/stable/2017-04-26/examples/WidgetTypesListByHub.json + // this example is just showing the usage of "WidgetTypes_ListByHub" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_WidgetTypesGet() // get the collection of this WidgetTypeResourceFormatResource WidgetTypeResourceFormatCollection collection = hub.GetWidgetTypeResourceFormats(); - // invoke the operation - string widgetTypeName = "ActivityGauge"; - WidgetTypeResourceFormatResource result = await collection.GetAsync(widgetTypeName); + // invoke the operation and iterate over the result + await foreach (WidgetTypeResourceFormatResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WidgetTypeResourceFormatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WidgetTypeResourceFormatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_DataBoxJobCollection.cs b/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_DataBoxJobCollection.cs index f981a1959d068..033298c31ccda 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_DataBoxJobCollection.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_DataBoxJobCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_DataBoxJobCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_JobsListByResourceGroup() + public async Task CreateOrUpdate_JobsCreate() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsListByResourceGroup.json - // this example is just showing the usage of "Jobs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsCreate.json + // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,42 @@ public async Task GetAll_JobsListByResourceGroup() // get the collection of this DataBoxJobResource DataBoxJobCollection collection = resourceGroupResource.GetDataBoxJobs(); - // invoke the operation and iterate over the result - await foreach (DataBoxJobResource item in collection.GetAllAsync()) + // invoke the operation + string jobName = "TestJobName1"; + DataBoxJobData data = new DataBoxJobData(new AzureLocation("westus"), DataBoxJobTransferType.ImportToAzure, new DataBoxSku(DataBoxSkuName.DataBox)) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Details = new DataBoxJobDetails(new DataBoxContactDetails("XXXX XXXX", "0000000000", new string[] { "xxxx@xxxx.xxx" }) + { + PhoneExtension = "", + }) + { + ShippingAddress = new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") + { + StreetAddress2 = "XXXX XXXX", + City = "XXXX XXXX", + StateOrProvince = "XX", + CompanyName = "XXXX XXXX", + AddressType = DataBoxShippingAddressType.Commercial, + }, + DataImportDetails = { new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourcegroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName"))) }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); + DataBoxJobResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_JobsGet() + public async Task CreateOrUpdate_JobsCreateDevicePassword() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGet.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsCreateDevicePassword.json + // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,8 +94,30 @@ public async Task Get_JobsGet() // invoke the operation string jobName = "TestJobName1"; - string expand = "details"; - DataBoxJobResource result = await collection.GetAsync(jobName, expand: expand); + DataBoxJobData data = new DataBoxJobData(new AzureLocation("westus"), DataBoxJobTransferType.ImportToAzure, new DataBoxSku(DataBoxSkuName.DataBox)) + { + Details = new DataBoxJobDetails(new DataBoxContactDetails("XXXX XXXX", "0000000000", new string[] { "xxxx@xxxx.xxx" }) + { + PhoneExtension = "", + }) + { + DevicePassword = "", + ShippingAddress = new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") + { + StreetAddress2 = "XXXX XXXX", + City = "XXXX XXXX", + StateOrProvince = "XX", + CompanyName = "XXXX XXXX", + AddressType = DataBoxShippingAddressType.Commercial, + }, + DataImportDetails = {new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName")) +{ +SharePassword = "", +})}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); + DataBoxJobResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +128,10 @@ public async Task Get_JobsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_JobsGet() + public async Task CreateOrUpdate_JobsCreateDoubleEncryption() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGet.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsCreateDoubleEncryption.json + // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,18 +150,47 @@ public async Task Exists_JobsGet() // invoke the operation string jobName = "TestJobName1"; - string expand = "details"; - bool result = await collection.ExistsAsync(jobName, expand: expand); + DataBoxJobData data = new DataBoxJobData(new AzureLocation("westus"), DataBoxJobTransferType.ImportToAzure, new DataBoxSku(DataBoxSkuName.DataBox)) + { + Details = new DataBoxJobDetails(new DataBoxContactDetails("XXXX XXXX", "0000000000", new string[] { "xxxx@xxxx.xxx" }) + { + PhoneExtension = "", + }) + { + ShippingAddress = new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") + { + StreetAddress2 = "XXXX XXXX", + City = "XXXX XXXX", + StateOrProvince = "XX", + CompanyName = "XXXX XXXX", + AddressType = DataBoxShippingAddressType.Commercial, + }, + DataImportDetails = { new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourcegroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName"))) }, + Preferences = new DataBoxOrderPreferences + { + EncryptionPreferences = new DataBoxEncryptionPreferences + { + DoubleEncryption = DataBoxDoubleEncryption.Enabled, + }, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); + DataBoxJobResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_JobsGet() + public async Task CreateOrUpdate_JobsCreateExport() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGet.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsCreateExport.json + // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,30 +209,47 @@ public async Task GetIfExists_JobsGet() // invoke the operation string jobName = "TestJobName1"; - string expand = "details"; - NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); - DataBoxJobResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + DataBoxJobData data = new DataBoxJobData(new AzureLocation("westus"), DataBoxJobTransferType.ExportFromAzure, new DataBoxSku(DataBoxSkuName.DataBox)) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Details = new DataBoxJobDetails(new DataBoxContactDetails("XXXX XXXX", "0000000000", new string[] { "xxxx@xxxx.xxx" }) + { + PhoneExtension = "", + }) + { + ShippingAddress = new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") + { + StreetAddress2 = "XXXX XXXX", + City = "XXXX XXXX", + StateOrProvince = "XX", + CompanyName = "XXXX XXXX", + AddressType = DataBoxShippingAddressType.Commercial, + }, + DataExportDetails = {new DataExportDetails(new TransferConfiguration(TransferConfigurationType.TransferAll) +{ +TransferAllDetailsInclude = new TransferAllDetails(DataAccountType.StorageAccount) +{ +TransferAllBlobs = true, +TransferAllFiles = true, +}, +}, new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName")))}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); + DataBoxJobResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_JobsGetCmk() + public async Task CreateOrUpdate_JobsCreateWithUserAssignedIdentity() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetCmk.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsCreateWithUserAssignedIdentity.json + // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,8 +268,33 @@ public async Task Get_JobsGetCmk() // invoke the operation string jobName = "TestJobName1"; - string expand = "details"; - DataBoxJobResource result = await collection.GetAsync(jobName, expand: expand); + DataBoxJobData data = new DataBoxJobData(new AzureLocation("westus"), DataBoxJobTransferType.ImportToAzure, new DataBoxSku(DataBoxSkuName.DataBox)) + { + Details = new DataBoxJobDetails(new DataBoxContactDetails("XXXX XXXX", "0000000000", new string[] { "xxxx@xxxx.xxx" }) + { + PhoneExtension = "", + }) + { + ShippingAddress = new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") + { + StreetAddress2 = "XXXX XXXX", + City = "XXXX XXXX", + StateOrProvince = "XX", + CompanyName = "XXXX XXXX", + AddressType = DataBoxShippingAddressType.Commercial, + }, + DataImportDetails = { new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName"))) }, + }, + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testIdentity")] = new UserAssignedIdentity() +}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); + DataBoxJobResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -195,9 +305,9 @@ public async Task Get_JobsGetCmk() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_JobsGetCmk() + public async Task Get_JobsGet() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetCmk.json + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGet.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -218,14 +328,18 @@ public async Task Exists_JobsGetCmk() // invoke the operation string jobName = "TestJobName1"; string expand = "details"; - bool result = await collection.ExistsAsync(jobName, expand: expand); + DataBoxJobResource result = await collection.GetAsync(jobName, expand: expand); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_JobsGetCmk() + public async Task Get_JobsGetCmk() { // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetCmk.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. @@ -248,21 +362,13 @@ public async Task GetIfExists_JobsGetCmk() // invoke the operation string jobName = "TestJobName1"; string expand = "details"; - NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); - DataBoxJobResource result = response.HasValue ? response.Value : null; + DataBoxJobResource result = await collection.GetAsync(jobName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -301,9 +407,9 @@ public async Task Get_JobsGetCopyStuck() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_JobsGetCopyStuck() + public async Task Get_JobsGetExport() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetCopyStuck.json + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetExport.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -324,16 +430,20 @@ public async Task Exists_JobsGetCopyStuck() // invoke the operation string jobName = "TestJobName1"; string expand = "details"; - bool result = await collection.ExistsAsync(jobName, expand: expand); + DataBoxJobResource result = await collection.GetAsync(jobName, expand: expand); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_JobsGetCopyStuck() + public async Task Get_JobsGetWaitingForAction() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetCopyStuck.json + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetWaitingForAction.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -354,29 +464,21 @@ public async Task GetIfExists_JobsGetCopyStuck() // invoke the operation string jobName = "TestJobName1"; string expand = "details"; - NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); - DataBoxJobResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } + DataBoxJobResource result = await collection.GetAsync(jobName, expand: expand); - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_JobsGetExport() + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_JobsListByResourceGroup() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetExport.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsListByResourceGroup.json + // this example is just showing the usage of "Jobs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -393,23 +495,24 @@ public async Task Get_JobsGetExport() // get the collection of this DataBoxJobResource DataBoxJobCollection collection = resourceGroupResource.GetDataBoxJobs(); - // invoke the operation - string jobName = "TestJobName1"; - string expand = "details"; - DataBoxJobResource result = await collection.GetAsync(jobName, expand: expand); + // invoke the operation and iterate over the result + await foreach (DataBoxJobResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_JobsGetExport() + public async Task Exists_JobsGet() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetExport.json + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGet.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -437,9 +540,9 @@ public async Task Exists_JobsGetExport() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_JobsGetExport() + public async Task Exists_JobsGetCmk() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetExport.json + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetCmk.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -460,28 +563,16 @@ public async Task GetIfExists_JobsGetExport() // invoke the operation string jobName = "TestJobName1"; string expand = "details"; - NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); - DataBoxJobResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(jobName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_JobsGetWaitingForAction() + public async Task Exists_JobsGetCopyStuck() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetWaitingForAction.json + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetCopyStuck.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -502,20 +593,16 @@ public async Task Get_JobsGetWaitingForAction() // invoke the operation string jobName = "TestJobName1"; string expand = "details"; - DataBoxJobResource result = await collection.GetAsync(jobName, expand: expand); + bool result = await collection.ExistsAsync(jobName, expand: expand); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_JobsGetWaitingForAction() + public async Task Exists_JobsGetExport() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetWaitingForAction.json + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetExport.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -543,7 +630,7 @@ public async Task Exists_JobsGetWaitingForAction() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_JobsGetWaitingForAction() + public async Task Exists_JobsGetWaitingForAction() { // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetWaitingForAction.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. @@ -566,29 +653,17 @@ public async Task GetIfExists_JobsGetWaitingForAction() // invoke the operation string jobName = "TestJobName1"; string expand = "details"; - NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); - DataBoxJobResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(jobName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_JobsCreate() + public async Task GetIfExists_JobsGet() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsCreate.json - // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGet.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -607,46 +682,30 @@ public async Task CreateOrUpdate_JobsCreate() // invoke the operation string jobName = "TestJobName1"; - DataBoxJobData data = new DataBoxJobData(new AzureLocation("westus"), DataBoxJobTransferType.ImportToAzure, new DataBoxSku(DataBoxSkuName.DataBox)) + string expand = "details"; + NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); + DataBoxJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Details = new DataBoxJobDetails(new DataBoxContactDetails("XXXX XXXX", "0000000000", new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"xxxx@xxxx.xxx" - }) - { - PhoneExtension = "", - }) - { - ShippingAddress = new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") - { - StreetAddress2 = "XXXX XXXX", - City = "XXXX XXXX", - StateOrProvince = "XX", - CompanyName = "XXXX XXXX", - AddressType = DataBoxShippingAddressType.Commercial, - }, - DataImportDetails = -{ -new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourcegroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName"))) -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); - DataBoxJobResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_JobsCreateDevicePassword() + public async Task GetIfExists_JobsGetCmk() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsCreateDevicePassword.json - // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetCmk.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -665,50 +724,30 @@ public async Task CreateOrUpdate_JobsCreateDevicePassword() // invoke the operation string jobName = "TestJobName1"; - DataBoxJobData data = new DataBoxJobData(new AzureLocation("westus"), DataBoxJobTransferType.ImportToAzure, new DataBoxSku(DataBoxSkuName.DataBox)) + string expand = "details"; + NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); + DataBoxJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Details = new DataBoxJobDetails(new DataBoxContactDetails("XXXX XXXX", "0000000000", new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"xxxx@xxxx.xxx" - }) - { - PhoneExtension = "", - }) - { - DevicePassword = "", - ShippingAddress = new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") - { - StreetAddress2 = "XXXX XXXX", - City = "XXXX XXXX", - StateOrProvince = "XX", - CompanyName = "XXXX XXXX", - AddressType = DataBoxShippingAddressType.Commercial, - }, - DataImportDetails = -{ -new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName")) -{ -SharePassword = "", -}) -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); - DataBoxJobResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_JobsCreateDoubleEncryption() + public async Task GetIfExists_JobsGetCopyStuck() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsCreateDoubleEncryption.json - // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetCopyStuck.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -727,53 +766,30 @@ public async Task CreateOrUpdate_JobsCreateDoubleEncryption() // invoke the operation string jobName = "TestJobName1"; - DataBoxJobData data = new DataBoxJobData(new AzureLocation("westus"), DataBoxJobTransferType.ImportToAzure, new DataBoxSku(DataBoxSkuName.DataBox)) + string expand = "details"; + NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); + DataBoxJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Details = new DataBoxJobDetails(new DataBoxContactDetails("XXXX XXXX", "0000000000", new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"xxxx@xxxx.xxx" - }) - { - PhoneExtension = "", - }) - { - ShippingAddress = new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") - { - StreetAddress2 = "XXXX XXXX", - City = "XXXX XXXX", - StateOrProvince = "XX", - CompanyName = "XXXX XXXX", - AddressType = DataBoxShippingAddressType.Commercial, - }, - DataImportDetails = -{ -new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourcegroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName"))) -}, - Preferences = new DataBoxOrderPreferences() - { - EncryptionPreferences = new DataBoxEncryptionPreferences() - { - DoubleEncryption = DataBoxDoubleEncryption.Enabled, - }, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); - DataBoxJobResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_JobsCreateExport() + public async Task GetIfExists_JobsGetExport() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsCreateExport.json - // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetExport.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -792,53 +808,30 @@ public async Task CreateOrUpdate_JobsCreateExport() // invoke the operation string jobName = "TestJobName1"; - DataBoxJobData data = new DataBoxJobData(new AzureLocation("westus"), DataBoxJobTransferType.ExportFromAzure, new DataBoxSku(DataBoxSkuName.DataBox)) + string expand = "details"; + NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); + DataBoxJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Details = new DataBoxJobDetails(new DataBoxContactDetails("XXXX XXXX", "0000000000", new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"xxxx@xxxx.xxx" - }) - { - PhoneExtension = "", - }) - { - ShippingAddress = new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") - { - StreetAddress2 = "XXXX XXXX", - City = "XXXX XXXX", - StateOrProvince = "XX", - CompanyName = "XXXX XXXX", - AddressType = DataBoxShippingAddressType.Commercial, - }, - DataExportDetails = -{ -new DataExportDetails(new TransferConfiguration(TransferConfigurationType.TransferAll) -{ -TransferAllDetailsInclude = new TransferAllDetails(DataAccountType.StorageAccount) -{ -TransferAllBlobs = true, -TransferAllFiles = true, -}, -},new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName"))) -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); - DataBoxJobResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_JobsCreateWithUserAssignedIdentity() + public async Task GetIfExists_JobsGetWaitingForAction() { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsCreateWithUserAssignedIdentity.json - // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsGetWaitingForAction.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -857,45 +850,22 @@ public async Task CreateOrUpdate_JobsCreateWithUserAssignedIdentity() // invoke the operation string jobName = "TestJobName1"; - DataBoxJobData data = new DataBoxJobData(new AzureLocation("westus"), DataBoxJobTransferType.ImportToAzure, new DataBoxSku(DataBoxSkuName.DataBox)) + string expand = "details"; + NullableResponse response = await collection.GetIfExistsAsync(jobName, expand: expand); + DataBoxJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Details = new DataBoxJobDetails(new DataBoxContactDetails("XXXX XXXX", "0000000000", new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"xxxx@xxxx.xxx" - }) - { - PhoneExtension = "", - }) - { - ShippingAddress = new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") - { - StreetAddress2 = "XXXX XXXX", - City = "XXXX XXXX", - StateOrProvince = "XX", - CompanyName = "XXXX XXXX", - AddressType = DataBoxShippingAddressType.Commercial, - }, - DataImportDetails = -{ -new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName"))) -}, - }, - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourceGroups/YourResourceGroupName/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testIdentity")] = new UserAssignedIdentity(), -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); - DataBoxJobResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_DataBoxJobResource.cs b/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_DataBoxJobResource.cs index ccb8056df305b..c7339ed56c760 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_DataBoxJobResource.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_DataBoxJobResource.cs @@ -10,75 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DataBox.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DataBox.Samples { public partial class Sample_DataBoxJobResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDataBoxJobs_JobsList() - { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsList.json - // this example is just showing the usage of "Jobs_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "YourSubscriptionId"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DataBoxJobResource item in subscriptionResource.GetDataBoxJobsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task MarkDevicesShipped_MarkDevicesShipped() - { - // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/MarkDevicesShipped.json - // this example is just showing the usage of "Jobs_MarkDevicesShipped" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataBoxJobResource created on azure - // for more information of creating DataBoxJobResource, please refer to the document of DataBoxJobResource - string subscriptionId = "YourSubscriptionId"; - string resourceGroupName = "YourResourceGroupName"; - string jobName = "TestJobName1"; - ResourceIdentifier dataBoxJobResourceId = DataBoxJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); - DataBoxJobResource dataBoxJob = client.GetDataBoxJobResource(dataBoxJobResourceId); - - // invoke the operation - MarkDevicesShippedContent content = new MarkDevicesShippedContent(new PackageCarrierInfo() - { - CarrierName = "testCarrier", - TrackingId = "000000", - }); - await dataBoxJob.MarkDevicesShippedAsync(content); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_JobsGet() @@ -260,6 +197,37 @@ public async Task Delete_JobsDelete() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task MarkDevicesShipped_MarkDevicesShipped() + { + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/MarkDevicesShipped.json + // this example is just showing the usage of "Jobs_MarkDevicesShipped" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DataBoxJobResource created on azure + // for more information of creating DataBoxJobResource, please refer to the document of DataBoxJobResource + string subscriptionId = "YourSubscriptionId"; + string resourceGroupName = "YourResourceGroupName"; + string jobName = "TestJobName1"; + ResourceIdentifier dataBoxJobResourceId = DataBoxJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, jobName); + DataBoxJobResource dataBoxJob = client.GetDataBoxJobResource(dataBoxJobResourceId); + + // invoke the operation + MarkDevicesShippedContent content = new MarkDevicesShippedContent(new PackageCarrierInfo + { + CarrierName = "testCarrier", + TrackingId = "000000", + }); + await dataBoxJob.MarkDevicesShippedAsync(content); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task BookShipmentPickUp_BookShipmentPickupPost() diff --git a/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index 325acdbafd97c..73916c4fd6e65 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -70,25 +70,27 @@ public async Task ValidateInputs_ValidateInputsByResourceGroup() AzureLocation location = new AzureLocation("westus"); DataBoxValidationContent content = new CreateJobValidationContent(new DataBoxValidationInputContent[] { -new DataTransferDetailsValidationContent(DataBoxSkuName.DataBox,DataBoxJobTransferType.ImportToAzure) +new DataTransferDetailsValidationContent(DataBoxSkuName.DataBox, DataBoxJobTransferType.ImportToAzure) { -DataImportDetails = -{ -new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourcegroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName"))) +DataImportDetails = {new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourcegroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName")))}, }, -},new DataBoxValidateAddressContent(new DataBoxShippingAddress("XXXX XXXX","XX","00000") +new DataBoxValidateAddressContent(new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") { StreetAddress2 = "XXXX XXXX", City = "XXXX XXXX", StateOrProvince = "XX", CompanyName = "XXXX XXXX", AddressType = DataBoxShippingAddressType.Commercial, -},DataBoxSkuName.DataBox) +}, DataBoxSkuName.DataBox) { TransportPreferences = new TransportPreferences(TransportShipmentType.MicrosoftManaged), -},new SubscriptionIsAllowedToCreateJobValidationContent(),new SkuAvailabilityValidationContent(DataBoxSkuName.DataBox,DataBoxJobTransferType.ImportToAzure,"XX",new AzureLocation("westus")),new CreateOrderLimitForSubscriptionValidationContent(DataBoxSkuName.DataBox),new PreferencesValidationContent(DataBoxSkuName.DataBox) +}, +new SubscriptionIsAllowedToCreateJobValidationContent(), +new SkuAvailabilityValidationContent(DataBoxSkuName.DataBox, DataBoxJobTransferType.ImportToAzure, "XX", new AzureLocation("westus")), +new CreateOrderLimitForSubscriptionValidationContent(DataBoxSkuName.DataBox), +new PreferencesValidationContent(DataBoxSkuName.DataBox) { -Preference = new DataBoxOrderPreferences() +Preference = new DataBoxOrderPreferences { TransportPreferences = new TransportPreferences(TransportShipmentType.MicrosoftManaged), }, @@ -120,7 +122,7 @@ public async Task GetRegionConfiguration_RegionConfigurationByResourceGroup() // invoke the operation AzureLocation location = new AzureLocation("westus"); - RegionConfigurationContent content = new RegionConfigurationContent() + RegionConfigurationContent content = new RegionConfigurationContent { ScheduleAvailabilityRequest = new DataBoxScheduleAvailabilityContent(new AzureLocation("westus")), }; diff --git a/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index f65f49f386724..0e54accb8b8ce 100644 --- a/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/databox/Azure.ResourceManager.DataBox/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.DataBox.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataBoxJobs_JobsList() + { + // Generated from example definition: specification/databox/resource-manager/Microsoft.DataBox/stable/2022-12-01/examples/JobsList.json + // this example is just showing the usage of "Jobs_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "YourSubscriptionId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataBoxJobResource item in subscriptionResource.GetDataBoxJobsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task ValidateAddress_ValidateAddressPost() @@ -72,25 +103,27 @@ public async Task ValidateInputs_ValidateInputs() AzureLocation location = new AzureLocation("westus"); DataBoxValidationContent content = new CreateJobValidationContent(new DataBoxValidationInputContent[] { -new DataTransferDetailsValidationContent(DataBoxSkuName.DataBox,DataBoxJobTransferType.ImportToAzure) +new DataTransferDetailsValidationContent(DataBoxSkuName.DataBox, DataBoxJobTransferType.ImportToAzure) { -DataImportDetails = -{ -new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourcegroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName"))) +DataImportDetails = {new DataImportDetails(new DataBoxStorageAccountDetails(new ResourceIdentifier("/subscriptions/YourSubscriptionId/resourcegroups/YourResourceGroupName/providers/Microsoft.Storage/storageAccounts/YourStorageAccountName")))}, }, -},new DataBoxValidateAddressContent(new DataBoxShippingAddress("XXXX XXXX","XX","00000") +new DataBoxValidateAddressContent(new DataBoxShippingAddress("XXXX XXXX", "XX", "00000") { StreetAddress2 = "XXXX XXXX", City = "XXXX XXXX", StateOrProvince = "XX", CompanyName = "XXXX XXXX", AddressType = DataBoxShippingAddressType.Commercial, -},DataBoxSkuName.DataBox) +}, DataBoxSkuName.DataBox) { TransportPreferences = new TransportPreferences(TransportShipmentType.MicrosoftManaged), -},new SubscriptionIsAllowedToCreateJobValidationContent(),new SkuAvailabilityValidationContent(DataBoxSkuName.DataBox,DataBoxJobTransferType.ImportToAzure,"XX",new AzureLocation("westus")),new CreateOrderLimitForSubscriptionValidationContent(DataBoxSkuName.DataBox),new PreferencesValidationContent(DataBoxSkuName.DataBox) +}, +new SubscriptionIsAllowedToCreateJobValidationContent(), +new SkuAvailabilityValidationContent(DataBoxSkuName.DataBox, DataBoxJobTransferType.ImportToAzure, "XX", new AzureLocation("westus")), +new CreateOrderLimitForSubscriptionValidationContent(DataBoxSkuName.DataBox), +new PreferencesValidationContent(DataBoxSkuName.DataBox) { -Preference = new DataBoxOrderPreferences() +Preference = new DataBoxOrderPreferences { TransportPreferences = new TransportPreferences(TransportShipmentType.MicrosoftManaged), }, @@ -121,7 +154,7 @@ public async Task GetRegionConfiguration_RegionConfiguration() // invoke the operation AzureLocation location = new AzureLocation("westus"); - RegionConfigurationContent content = new RegionConfigurationContent() + RegionConfigurationContent content = new RegionConfigurationContent { ScheduleAvailabilityRequest = new DataBoxScheduleAvailabilityContent(new AzureLocation("westus")), }; diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_BandwidthScheduleCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_BandwidthScheduleCollection.cs index 7043ea36006ff..29bd0c74d4a44 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_BandwidthScheduleCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_BandwidthScheduleCollection.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DataBoxEdge.Models; @@ -18,10 +19,10 @@ public partial class Sample_BandwidthScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BandwidthScheduleGetAllInDevice() + public async Task CreateOrUpdate_BandwidthSchedulePut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthScheduleGetAllInDevice.json - // this example is just showing the usage of "BandwidthSchedules_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthSchedulePut.json + // this example is just showing the usage of "BandwidthSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +40,17 @@ public async Task GetAll_BandwidthScheduleGetAllInDevice() // get the collection of this BandwidthScheduleResource BandwidthScheduleCollection collection = dataBoxEdgeDevice.GetBandwidthSchedules(); - // invoke the operation and iterate over the result - await foreach (BandwidthScheduleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BandwidthScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "bandwidth-1"; + BandwidthScheduleData data = new BandwidthScheduleData(XmlConvert.ToTimeSpan("0:0:0"), XmlConvert.ToTimeSpan("13:59:0"), 100, new DataBoxEdgeDayOfWeek[] { DataBoxEdgeDayOfWeek.Sunday, DataBoxEdgeDayOfWeek.Monday }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + BandwidthScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BandwidthScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +89,10 @@ public async Task Get_BandwidthScheduleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BandwidthScheduleGet() + public async Task GetAll_BandwidthScheduleGetAllInDevice() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthScheduleGet.json - // this example is just showing the usage of "BandwidthSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthScheduleGetAllInDevice.json + // this example is just showing the usage of "BandwidthSchedules_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +110,22 @@ public async Task Exists_BandwidthScheduleGet() // get the collection of this BandwidthScheduleResource BandwidthScheduleCollection collection = dataBoxEdgeDevice.GetBandwidthSchedules(); - // invoke the operation - string name = "bandwidth-1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (BandwidthScheduleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BandwidthScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BandwidthScheduleGet() + public async Task Exists_BandwidthScheduleGet() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthScheduleGet.json // this example is just showing the usage of "BandwidthSchedules_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +148,17 @@ public async Task GetIfExists_BandwidthScheduleGet() // invoke the operation string name = "bandwidth-1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - BandwidthScheduleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BandwidthScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BandwidthSchedulePut() + public async Task GetIfExists_BandwidthScheduleGet() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthSchedulePut.json - // this example is just showing the usage of "BandwidthSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthScheduleGet.json + // this example is just showing the usage of "BandwidthSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +178,21 @@ public async Task CreateOrUpdate_BandwidthSchedulePut() // invoke the operation string name = "bandwidth-1"; - BandwidthScheduleData data = new BandwidthScheduleData(TimeSpan.Parse("0:0:0"), TimeSpan.Parse("13:59:0"), 100, new DataBoxEdgeDayOfWeek[] - { -DataBoxEdgeDayOfWeek.Sunday,DataBoxEdgeDayOfWeek.Monday - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - BandwidthScheduleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + BandwidthScheduleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BandwidthScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BandwidthScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_BandwidthScheduleResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_BandwidthScheduleResource.cs index 0e220766b208d..33313a66f128b 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_BandwidthScheduleResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_BandwidthScheduleResource.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DataBoxEdge.Models; @@ -49,10 +50,10 @@ public async Task Get_BandwidthScheduleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BandwidthSchedulePut() + public async Task Delete_BandwidthScheduleDelete() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthSchedulePut.json - // this example is just showing the usage of "BandwidthSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthScheduleDelete.json + // this example is just showing the usage of "BandwidthSchedules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +70,17 @@ public async Task Update_BandwidthSchedulePut() BandwidthScheduleResource bandwidthSchedule = client.GetBandwidthScheduleResource(bandwidthScheduleResourceId); // invoke the operation - BandwidthScheduleData data = new BandwidthScheduleData(TimeSpan.Parse("0:0:0"), TimeSpan.Parse("13:59:0"), 100, new DataBoxEdgeDayOfWeek[] - { -DataBoxEdgeDayOfWeek.Sunday,DataBoxEdgeDayOfWeek.Monday - }); - ArmOperation lro = await bandwidthSchedule.UpdateAsync(WaitUntil.Completed, data); - BandwidthScheduleResource result = lro.Value; + await bandwidthSchedule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BandwidthScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BandwidthScheduleDelete() + public async Task Update_BandwidthSchedulePut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthScheduleDelete.json - // this example is just showing the usage of "BandwidthSchedules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/BandwidthSchedulePut.json + // this example is just showing the usage of "BandwidthSchedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +97,15 @@ public async Task Delete_BandwidthScheduleDelete() BandwidthScheduleResource bandwidthSchedule = client.GetBandwidthScheduleResource(bandwidthScheduleResourceId); // invoke the operation - await bandwidthSchedule.DeleteAsync(WaitUntil.Completed); + BandwidthScheduleData data = new BandwidthScheduleData(XmlConvert.ToTimeSpan("0:0:0"), XmlConvert.ToTimeSpan("13:59:0"), 100, new DataBoxEdgeDayOfWeek[] { DataBoxEdgeDayOfWeek.Sunday, DataBoxEdgeDayOfWeek.Monday }); + ArmOperation lro = await bandwidthSchedule.UpdateAsync(WaitUntil.Completed, data); + BandwidthScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BandwidthScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeAlertCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeAlertCollection.cs index 12b4ce31c9964..4432d334bc810 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeAlertCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeAlertCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DataBoxEdgeAlertCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AlertGetAllInDevice() + public async Task Get_AlertGet() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/AlertGetAllInDevice.json - // this example is just showing the usage of "Alerts_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/AlertGet.json + // this example is just showing the usage of "Alerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_AlertGetAllInDevice() // get the collection of this DataBoxEdgeAlertResource DataBoxEdgeAlertCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeAlerts(); - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeAlertResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeAlertData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "159a00c7-8543-4343-9435-263ac87df3bb"; + DataBoxEdgeAlertResource result = await collection.GetAsync(name); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AlertGet() + public async Task GetAll_AlertGetAllInDevice() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/AlertGet.json - // this example is just showing the usage of "Alerts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/AlertGetAllInDevice.json + // this example is just showing the usage of "Alerts_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_AlertGet() // get the collection of this DataBoxEdgeAlertResource DataBoxEdgeAlertCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeAlerts(); - // invoke the operation - string name = "159a00c7-8543-4343-9435-263ac87df3bb"; - DataBoxEdgeAlertResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeAlertResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeAlertData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeDeviceCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeDeviceCollection.cs index 66a6f89b20cf8..cada83aa11729 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeDeviceCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeDeviceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DataBoxEdgeDeviceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DataBoxEdgeDeviceGetByResourceGroup() + public async Task CreateOrUpdate_DataBoxEdgeDevicePut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByResourceGroup.json - // this example is just showing the usage of "Devices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDevicePut.json + // this example is just showing the usage of "Devices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,33 @@ public async Task GetAll_DataBoxEdgeDeviceGetByResourceGroup() // get the collection of this DataBoxEdgeDeviceResource DataBoxEdgeDeviceCollection collection = resourceGroupResource.GetDataBoxEdgeDevices(); - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeDeviceResource item in collection.GetAllAsync()) + // invoke the operation + string deviceName = "testedgedevice"; + DataBoxEdgeDeviceData data = new DataBoxEdgeDeviceData(new AzureLocation("WUS")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeDeviceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new DataBoxEdgeSku + { + Name = DataBoxEdgeSkuName.Edge, + Tier = DataBoxEdgeSkuTier.Standard, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deviceName, data); + DataBoxEdgeDeviceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeDeviceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataBoxEdgeDeviceGetByName() + public async Task CreateOrUpdate_DataBoxEdgeDevicePutWithDataResidency() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByName.json - // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDevicePutWithDataResidency.json + // this example is just showing the usage of "Devices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +84,18 @@ public async Task Get_DataBoxEdgeDeviceGetByName() // invoke the operation string deviceName = "testedgedevice"; - DataBoxEdgeDeviceResource result = await collection.GetAsync(deviceName); + DataBoxEdgeDeviceData data = new DataBoxEdgeDeviceData(new AzureLocation("WUS")) + { + Sku = new DataBoxEdgeSku + { + Name = DataBoxEdgeSkuName.Edge, + Tier = DataBoxEdgeSkuTier.Standard, + }, + ResidencyType = DataBoxEdgeDataResidencyType.ZoneReplication, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deviceName, data); + DataBoxEdgeDeviceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +106,7 @@ public async Task Get_DataBoxEdgeDeviceGetByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DataBoxEdgeDeviceGetByName() + public async Task Get_DataBoxEdgeDeviceGetByName() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByName.json // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,16 +128,20 @@ public async Task Exists_DataBoxEdgeDeviceGetByName() // invoke the operation string deviceName = "testedgedevice"; - bool result = await collection.ExistsAsync(deviceName); + DataBoxEdgeDeviceResource result = await collection.GetAsync(deviceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeDeviceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DataBoxEdgeDeviceGetByName() + public async Task Get_DataBoxEdgeDeviceGetByNameWithDataResidency() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByName.json + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByNameWithDataResidency.json // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -138,29 +161,21 @@ public async Task GetIfExists_DataBoxEdgeDeviceGetByName() // invoke the operation string deviceName = "testedgedevice"; - NullableResponse response = await collection.GetIfExistsAsync(deviceName); - DataBoxEdgeDeviceResource result = response.HasValue ? response.Value : null; + DataBoxEdgeDeviceResource result = await collection.GetAsync(deviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeDeviceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataBoxEdgeDeviceGetByNameWithDataResidency() + public async Task GetAll_DataBoxEdgeDeviceGetByResourceGroup() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByNameWithDataResidency.json - // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByResourceGroup.json + // this example is just showing the usage of "Devices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,22 +192,24 @@ public async Task Get_DataBoxEdgeDeviceGetByNameWithDataResidency() // get the collection of this DataBoxEdgeDeviceResource DataBoxEdgeDeviceCollection collection = resourceGroupResource.GetDataBoxEdgeDevices(); - // invoke the operation - string deviceName = "testedgedevice"; - DataBoxEdgeDeviceResource result = await collection.GetAsync(deviceName); + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeDeviceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeDeviceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DataBoxEdgeDeviceGetByNameWithDataResidency() + public async Task Exists_DataBoxEdgeDeviceGetByName() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByNameWithDataResidency.json + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByName.json // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -219,7 +236,7 @@ public async Task Exists_DataBoxEdgeDeviceGetByNameWithDataResidency() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DataBoxEdgeDeviceGetByNameWithDataResidency() + public async Task Exists_DataBoxEdgeDeviceGetByNameWithDataResidency() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByNameWithDataResidency.json // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. @@ -241,29 +258,17 @@ public async Task GetIfExists_DataBoxEdgeDeviceGetByNameWithDataResidency() // invoke the operation string deviceName = "testedgedevice"; - NullableResponse response = await collection.GetIfExistsAsync(deviceName); - DataBoxEdgeDeviceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(deviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataBoxEdgeDevicePut() + public async Task GetIfExists_DataBoxEdgeDeviceGetByName() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDevicePut.json - // this example is just showing the usage of "Devices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByName.json + // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -282,33 +287,29 @@ public async Task CreateOrUpdate_DataBoxEdgeDevicePut() // invoke the operation string deviceName = "testedgedevice"; - DataBoxEdgeDeviceData data = new DataBoxEdgeDeviceData(new AzureLocation("WUS")) - { - Sku = new DataBoxEdgeSku() - { - Name = DataBoxEdgeSkuName.Edge, - Tier = DataBoxEdgeSkuTier.Standard, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deviceName, data); - DataBoxEdgeDeviceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(deviceName); + DataBoxEdgeDeviceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeDeviceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataBoxEdgeDevicePutWithDataResidency() + public async Task GetIfExists_DataBoxEdgeDeviceGetByNameWithDataResidency() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDevicePutWithDataResidency.json - // this example is just showing the usage of "Devices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetByNameWithDataResidency.json + // this example is just showing the usage of "Devices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -327,26 +328,21 @@ public async Task CreateOrUpdate_DataBoxEdgeDevicePutWithDataResidency() // invoke the operation string deviceName = "testedgedevice"; - DataBoxEdgeDeviceData data = new DataBoxEdgeDeviceData(new AzureLocation("WUS")) - { - Sku = new DataBoxEdgeSku() - { - Name = DataBoxEdgeSkuName.Edge, - Tier = DataBoxEdgeSkuTier.Standard, - }, - ResidencyType = DataBoxEdgeDataResidencyType.ZoneReplication, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deviceName, data); - DataBoxEdgeDeviceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(deviceName); + DataBoxEdgeDeviceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeDeviceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeDeviceResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeDeviceResource.cs index 648698834e355..23a7749b85c30 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeDeviceResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeDeviceResource.cs @@ -11,44 +11,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DataBoxEdge.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DataBoxEdge.Samples { public partial class Sample_DataBoxEdgeDeviceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDataBoxEdgeDevices_DataBoxEdgeDeviceGetBySubscription() - { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetBySubscription.json - // this example is just showing the usage of "Devices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeDeviceResource item in subscriptionResource.GetDataBoxEdgeDevicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeDeviceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_DataBoxEdgeDeviceGetByName() @@ -156,7 +124,7 @@ public async Task Update_DataBoxEdgeDevicePatch() DataBoxEdgeDeviceResource dataBoxEdgeDevice = client.GetDataBoxEdgeDeviceResource(dataBoxEdgeDeviceResourceId); // invoke the operation - DataBoxEdgeDevicePatch patch = new DataBoxEdgeDevicePatch() + DataBoxEdgeDevicePatch patch = new DataBoxEdgeDevicePatch { SubscriptionId = new ResourceIdentifier("/subscriptions/0d44739e-0563-474f-97e7-24a0cdb23b29/resourceGroups/rapvs-rg/providers/Microsoft.AzureStack/linkedSubscriptions/ca014ddc-5cf2-45f8-b390-e901e4a0ae87"), }; @@ -458,10 +426,7 @@ public async Task CheckResourceCreationFeasibility_DeviceCapacityRequestPost() // invoke the operation DeviceCapacityRequestContent content = new DeviceCapacityRequestContent(new IList[] { -new string[] -{ -"Standard_D2_v2" -} +new string[]{"Standard_D2_v2"} }); await dataBoxEdgeDevice.CheckResourceCreationFeasibilityAsync(WaitUntil.Completed, content); @@ -544,7 +509,7 @@ public async Task TriggerSupportPackage_TriggerSupportPackage() DataBoxEdgeDeviceResource dataBoxEdgeDevice = client.GetDataBoxEdgeDeviceResource(dataBoxEdgeDeviceResourceId); // invoke the operation - TriggerSupportPackageContent content = new TriggerSupportPackageContent() + TriggerSupportPackageContent content = new TriggerSupportPackageContent { MinimumTimeStamp = DateTimeOffset.Parse("2018-12-18T02:18:51.4270267Z"), MaximumTimeStamp = DateTimeOffset.Parse("2018-12-18T02:19:51.4270267Z"), diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeOrderResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeOrderResource.cs index 7fe65c5bbe1cd..f9cdd6d4a5a85 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeOrderResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeOrderResource.cs @@ -48,10 +48,10 @@ public async Task Get_OrderGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_OrderPut() + public async Task Delete_OrderDelete() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/OrderPut.json - // this example is just showing the usage of "Orders_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/OrderDelete.json + // this example is just showing the usage of "Orders_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,38 +67,17 @@ public async Task CreateOrUpdate_OrderPut() DataBoxEdgeOrderResource dataBoxEdgeOrder = client.GetDataBoxEdgeOrderResource(dataBoxEdgeOrderResourceId); // invoke the operation - DataBoxEdgeOrderData data = new DataBoxEdgeOrderData() - { - ContactInformation = new DataBoxEdgeContactDetails("John Mcclane", "Microsoft", "(800) 426-9400", new string[] - { -"john@microsoft.com" - }), - ShippingAddress = new DataBoxEdgeShippingAddress("USA") - { - AddressLine1 = "Microsoft Corporation", - AddressLine2 = "One Microsoft Way", - AddressLine3 = "Redmond", - PostalCode = "98052", - City = "WA", - State = "WA", - }, - }; - ArmOperation lro = await dataBoxEdgeOrder.CreateOrUpdateAsync(WaitUntil.Completed, data); - DataBoxEdgeOrderResource result = lro.Value; + await dataBoxEdgeOrder.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeOrderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_OrderDelete() + public async Task CreateOrUpdate_OrderPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/OrderDelete.json - // this example is just showing the usage of "Orders_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/OrderPut.json + // this example is just showing the usage of "Orders_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +93,27 @@ public async Task Delete_OrderDelete() DataBoxEdgeOrderResource dataBoxEdgeOrder = client.GetDataBoxEdgeOrderResource(dataBoxEdgeOrderResourceId); // invoke the operation - await dataBoxEdgeOrder.DeleteAsync(WaitUntil.Completed); + DataBoxEdgeOrderData data = new DataBoxEdgeOrderData + { + ContactInformation = new DataBoxEdgeContactDetails("John Mcclane", "Microsoft", "(800) 426-9400", new string[] { "john@microsoft.com" }), + ShippingAddress = new DataBoxEdgeShippingAddress("USA") + { + AddressLine1 = "Microsoft Corporation", + AddressLine2 = "One Microsoft Way", + AddressLine3 = "Redmond", + PostalCode = "98052", + City = "WA", + State = "WA", + }, + }; + ArmOperation lro = await dataBoxEdgeOrder.CreateOrUpdateAsync(WaitUntil.Completed, data); + DataBoxEdgeOrderResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeOrderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleAddonCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleAddonCollection.cs index 1ea466cb1ad46..2b87b7b2c3aa6 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleAddonCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleAddonCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataBoxEdgeRoleAddonCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RoleListAddOns() + public async Task CreateOrUpdate_PutAddOns() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RoleListAddOns.json - // this example is just showing the usage of "Addons_ListByRole" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/PutAddons.json + // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,24 +33,24 @@ public async Task GetAll_RoleListAddOns() string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; string resourceGroupName = "GroupForEdgeAutomation"; string deviceName = "testedgedevice"; - string roleName = "IoTRole1"; + string roleName = "KubernetesRole"; ResourceIdentifier dataBoxEdgeRoleResourceId = DataBoxEdgeRoleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, deviceName, roleName); DataBoxEdgeRoleResource dataBoxEdgeRole = client.GetDataBoxEdgeRoleResource(dataBoxEdgeRoleResourceId); // get the collection of this DataBoxEdgeRoleAddonResource DataBoxEdgeRoleAddonCollection collection = dataBoxEdgeRole.GetDataBoxEdgeRoleAddons(); - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeRoleAddonResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeRoleAddonData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string addonName = "arcName"; + DataBoxEdgeRoleAddonData data = new EdgeArcAddon("4385cf00-2d3a-425a-832f-f4285b1c9dce", "GroupForEdgeAutomation", "testedgedevice", new AzureLocation("EastUS")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addonName, data); + DataBoxEdgeRoleAddonResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeRoleAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +90,10 @@ public async Task Get_GetAddOns() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAddOns() + public async Task GetAll_RoleListAddOns() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/GetAddons.json - // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RoleListAddOns.json + // this example is just showing the usage of "Addons_ListByRole" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,23 +105,29 @@ public async Task Exists_GetAddOns() string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; string resourceGroupName = "GroupForEdgeAutomation"; string deviceName = "testedgedevice"; - string roleName = "KubernetesRole"; + string roleName = "IoTRole1"; ResourceIdentifier dataBoxEdgeRoleResourceId = DataBoxEdgeRoleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, deviceName, roleName); DataBoxEdgeRoleResource dataBoxEdgeRole = client.GetDataBoxEdgeRoleResource(dataBoxEdgeRoleResourceId); // get the collection of this DataBoxEdgeRoleAddonResource DataBoxEdgeRoleAddonCollection collection = dataBoxEdgeRole.GetDataBoxEdgeRoleAddons(); - // invoke the operation - string addonName = "arcName"; - bool result = await collection.ExistsAsync(addonName); + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeRoleAddonResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeRoleAddonData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAddOns() + public async Task Exists_GetAddOns() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/GetAddons.json // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +151,17 @@ public async Task GetIfExists_GetAddOns() // invoke the operation string addonName = "arcName"; - NullableResponse response = await collection.GetIfExistsAsync(addonName); - DataBoxEdgeRoleAddonResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(addonName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeRoleAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutAddOns() + public async Task GetIfExists_GetAddOns() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/PutAddons.json - // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/GetAddons.json + // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,15 +182,21 @@ public async Task CreateOrUpdate_PutAddOns() // invoke the operation string addonName = "arcName"; - DataBoxEdgeRoleAddonData data = new EdgeArcAddon("4385cf00-2d3a-425a-832f-f4285b1c9dce", "GroupForEdgeAutomation", "testedgedevice", new AzureLocation("EastUS")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addonName, data); - DataBoxEdgeRoleAddonResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(addonName); + DataBoxEdgeRoleAddonResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeRoleAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeRoleAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleAddonResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleAddonResource.cs index c35254a1b36ed..e618798f0b954 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleAddonResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleAddonResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetAddOns() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutAddOns() + public async Task Delete_DeleteAddOns() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/PutAddons.json - // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DeleteAddons.json + // this example is just showing the usage of "Addons_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,23 +71,17 @@ public async Task Update_PutAddOns() DataBoxEdgeRoleAddonResource dataBoxEdgeRoleAddon = client.GetDataBoxEdgeRoleAddonResource(dataBoxEdgeRoleAddonResourceId); // invoke the operation - DataBoxEdgeRoleAddonData data = new EdgeArcAddon("4385cf00-2d3a-425a-832f-f4285b1c9dce", "GroupForEdgeAutomation", "testedgedevice", new AzureLocation("EastUS")); - ArmOperation lro = await dataBoxEdgeRoleAddon.UpdateAsync(WaitUntil.Completed, data); - DataBoxEdgeRoleAddonResource result = lro.Value; + await dataBoxEdgeRoleAddon.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeRoleAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAddOns() + public async Task Update_PutAddOns() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DeleteAddons.json - // this example is just showing the usage of "Addons_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/PutAddons.json + // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +99,15 @@ public async Task Delete_DeleteAddOns() DataBoxEdgeRoleAddonResource dataBoxEdgeRoleAddon = client.GetDataBoxEdgeRoleAddonResource(dataBoxEdgeRoleAddonResourceId); // invoke the operation - await dataBoxEdgeRoleAddon.DeleteAsync(WaitUntil.Completed); + DataBoxEdgeRoleAddonData data = new EdgeArcAddon("4385cf00-2d3a-425a-832f-f4285b1c9dce", "GroupForEdgeAutomation", "testedgedevice", new AzureLocation("EastUS")); + ArmOperation lro = await dataBoxEdgeRoleAddon.UpdateAsync(WaitUntil.Completed, data); + DataBoxEdgeRoleAddonResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeRoleAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleCollection.cs index 97a98fff0a5b8..7a028c1b75d2f 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataBoxEdgeRoleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RoleGetAllInDevice() + public async Task CreateOrUpdate_RolePut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RoleGetAllInDevice.json - // this example is just showing the usage of "Roles_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RolePut.json + // this example is just showing the usage of "Roles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,36 @@ public async Task GetAll_RoleGetAllInDevice() // get the collection of this DataBoxEdgeRoleResource DataBoxEdgeRoleCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeRoles(); - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeRoleResource item in collection.GetAllAsync()) + // invoke the operation + string name = "IoTRole1"; + DataBoxEdgeRoleData data = new EdgeIotRole { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeRoleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HostPlatform = DataBoxEdgeOSPlatformType.Linux, + IotDeviceDetails = new EdgeIotDeviceInfo("iotdevice", "iothub.azure-devices.net") + { + SymmetricKeyConnectionString = new AsymmetricEncryptedSecret("Encrypted<>", DataBoxEdgeEncryptionAlgorithm.Aes256) + { + EncryptionCertThumbprint = "348586569999244", + }, + }, + IotEdgeDeviceDetails = new EdgeIotDeviceInfo("iotEdge", "iothub.azure-devices.net") + { + SymmetricKeyConnectionString = new AsymmetricEncryptedSecret("Encrypted<>", DataBoxEdgeEncryptionAlgorithm.Aes256) + { + EncryptionCertThumbprint = "1245475856069999244", + }, + }, + ShareMappings = { }, + RoleStatus = DataBoxEdgeRoleStatus.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DataBoxEdgeRoleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeRoleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +107,10 @@ public async Task Get_RoleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RoleGet() + public async Task GetAll_RoleGetAllInDevice() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RoleGet.json - // this example is just showing the usage of "Roles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RoleGetAllInDevice.json + // this example is just showing the usage of "Roles_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +128,22 @@ public async Task Exists_RoleGet() // get the collection of this DataBoxEdgeRoleResource DataBoxEdgeRoleCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeRoles(); - // invoke the operation - string name = "IoTRole1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeRoleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeRoleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RoleGet() + public async Task Exists_RoleGet() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RoleGet.json // this example is just showing the usage of "Roles_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +166,17 @@ public async Task GetIfExists_RoleGet() // invoke the operation string name = "IoTRole1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DataBoxEdgeRoleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeRoleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RolePut() + public async Task GetIfExists_RoleGet() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RolePut.json - // this example is just showing the usage of "Roles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RoleGet.json + // this example is just showing the usage of "Roles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,36 +196,21 @@ public async Task CreateOrUpdate_RolePut() // invoke the operation string name = "IoTRole1"; - DataBoxEdgeRoleData data = new EdgeIotRole() - { - HostPlatform = DataBoxEdgeOSPlatformType.Linux, - IotDeviceDetails = new EdgeIotDeviceInfo("iotdevice", "iothub.azure-devices.net") - { - SymmetricKeyConnectionString = new AsymmetricEncryptedSecret("Encrypted<>", DataBoxEdgeEncryptionAlgorithm.Aes256) - { - EncryptionCertThumbprint = "348586569999244", - }, - }, - IotEdgeDeviceDetails = new EdgeIotDeviceInfo("iotEdge", "iothub.azure-devices.net") - { - SymmetricKeyConnectionString = new AsymmetricEncryptedSecret("Encrypted<>", DataBoxEdgeEncryptionAlgorithm.Aes256) - { - EncryptionCertThumbprint = "1245475856069999244", - }, - }, - ShareMappings = -{ -}, - RoleStatus = DataBoxEdgeRoleStatus.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DataBoxEdgeRoleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DataBoxEdgeRoleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeRoleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeRoleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleResource.cs index 47144201c910d..53947796dc191 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeRoleResource.cs @@ -47,6 +47,33 @@ public async Task Get_RoleGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_RoleDelete() + { + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RoleDelete.json + // this example is just showing the usage of "Roles_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DataBoxEdgeRoleResource created on azure + // for more information of creating DataBoxEdgeRoleResource, please refer to the document of DataBoxEdgeRoleResource + string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; + string resourceGroupName = "GroupForEdgeAutomation"; + string deviceName = "testedgedevice"; + string name = "IoTRole1"; + ResourceIdentifier dataBoxEdgeRoleResourceId = DataBoxEdgeRoleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, deviceName, name); + DataBoxEdgeRoleResource dataBoxEdgeRole = client.GetDataBoxEdgeRoleResource(dataBoxEdgeRoleResourceId); + + // invoke the operation + await dataBoxEdgeRole.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_RolePut() @@ -69,7 +96,7 @@ public async Task Update_RolePut() DataBoxEdgeRoleResource dataBoxEdgeRole = client.GetDataBoxEdgeRoleResource(dataBoxEdgeRoleResourceId); // invoke the operation - DataBoxEdgeRoleData data = new EdgeIotRole() + DataBoxEdgeRoleData data = new EdgeIotRole { HostPlatform = DataBoxEdgeOSPlatformType.Linux, IotDeviceDetails = new EdgeIotDeviceInfo("iotdevice", "iothub.azure-devices.net") @@ -86,9 +113,7 @@ public async Task Update_RolePut() EncryptionCertThumbprint = "1245475856069999244", }, }, - ShareMappings = -{ -}, + ShareMappings = { }, RoleStatus = DataBoxEdgeRoleStatus.Enabled, }; ArmOperation lro = await dataBoxEdgeRole.UpdateAsync(WaitUntil.Completed, data); @@ -100,32 +125,5 @@ public async Task Update_RolePut() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_RoleDelete() - { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/RoleDelete.json - // this example is just showing the usage of "Roles_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataBoxEdgeRoleResource created on azure - // for more information of creating DataBoxEdgeRoleResource, please refer to the document of DataBoxEdgeRoleResource - string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; - string resourceGroupName = "GroupForEdgeAutomation"; - string deviceName = "testedgedevice"; - string name = "IoTRole1"; - ResourceIdentifier dataBoxEdgeRoleResourceId = DataBoxEdgeRoleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, deviceName, name); - DataBoxEdgeRoleResource dataBoxEdgeRole = client.GetDataBoxEdgeRoleResource(dataBoxEdgeRoleResourceId); - - // invoke the operation - await dataBoxEdgeRole.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeShareCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeShareCollection.cs index f8fb30938e953..4fd864770d133 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeShareCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeShareCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataBoxEdgeShareCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ShareGetAllInDevice() + public async Task CreateOrUpdate_SharePut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ShareGetAllInDevice.json - // this example is just showing the usage of "Shares_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SharePut.json + // this example is just showing the usage of "Shares_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_ShareGetAllInDevice() // get the collection of this DataBoxEdgeShareResource DataBoxEdgeShareCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeShares(); - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeShareResource item in collection.GetAllAsync()) + // invoke the operation + string name = "smbshare"; + DataBoxEdgeShareData data = new DataBoxEdgeShareData(new ShareStatus("Online"), DataBoxEdgeShareMonitoringStatus.Enabled, ShareAccessProtocol.Smb) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeShareData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "", + AzureContainerInfo = new DataBoxEdgeStorageContainerInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/storageAccountCredentials/sac1"), "testContainerSMB", DataBoxEdgeStorageContainerDataFormat.BlockBlob), + UserAccessRights = { new UserAccessRight(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/users/user2"), ShareAccessType.Change) }, + DataPolicy = DataBoxEdgeDataPolicy.Cloud, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DataBoxEdgeShareResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeShareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +94,10 @@ public async Task Get_ShareGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ShareGet() + public async Task GetAll_ShareGetAllInDevice() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ShareGet.json - // this example is just showing the usage of "Shares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ShareGetAllInDevice.json + // this example is just showing the usage of "Shares_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +115,22 @@ public async Task Exists_ShareGet() // get the collection of this DataBoxEdgeShareResource DataBoxEdgeShareCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeShares(); - // invoke the operation - string name = "smbshare"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeShareResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeShareData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ShareGet() + public async Task Exists_ShareGet() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ShareGet.json // this example is just showing the usage of "Shares_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +153,17 @@ public async Task GetIfExists_ShareGet() // invoke the operation string name = "smbshare"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DataBoxEdgeShareResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeShareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SharePut() + public async Task GetIfExists_ShareGet() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SharePut.json - // this example is just showing the usage of "Shares_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ShareGet.json + // this example is just showing the usage of "Shares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,24 +183,21 @@ public async Task CreateOrUpdate_SharePut() // invoke the operation string name = "smbshare"; - DataBoxEdgeShareData data = new DataBoxEdgeShareData(new ShareStatus("Online"), DataBoxEdgeShareMonitoringStatus.Enabled, ShareAccessProtocol.Smb) - { - Description = "", - AzureContainerInfo = new DataBoxEdgeStorageContainerInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/storageAccountCredentials/sac1"), "testContainerSMB", DataBoxEdgeStorageContainerDataFormat.BlockBlob), - UserAccessRights = -{ -new UserAccessRight(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/users/user2"),ShareAccessType.Change) -}, - DataPolicy = DataBoxEdgeDataPolicy.Cloud, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DataBoxEdgeShareResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DataBoxEdgeShareResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeShareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeShareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeShareResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeShareResource.cs index 3138ad8bce388..afc15a5197a19 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeShareResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeShareResource.cs @@ -49,10 +49,10 @@ public async Task Get_ShareGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SharePut() + public async Task Delete_ShareDelete() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SharePut.json - // this example is just showing the usage of "Shares_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ShareDelete.json + // this example is just showing the usage of "Shares_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,32 +69,17 @@ public async Task Update_SharePut() DataBoxEdgeShareResource dataBoxEdgeShare = client.GetDataBoxEdgeShareResource(dataBoxEdgeShareResourceId); // invoke the operation - DataBoxEdgeShareData data = new DataBoxEdgeShareData(new ShareStatus("Online"), DataBoxEdgeShareMonitoringStatus.Enabled, ShareAccessProtocol.Smb) - { - Description = "", - AzureContainerInfo = new DataBoxEdgeStorageContainerInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/storageAccountCredentials/sac1"), "testContainerSMB", DataBoxEdgeStorageContainerDataFormat.BlockBlob), - UserAccessRights = -{ -new UserAccessRight(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/users/user2"),ShareAccessType.Change) -}, - DataPolicy = DataBoxEdgeDataPolicy.Cloud, - }; - ArmOperation lro = await dataBoxEdgeShare.UpdateAsync(WaitUntil.Completed, data); - DataBoxEdgeShareResource result = lro.Value; + await dataBoxEdgeShare.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeShareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ShareDelete() + public async Task Update_SharePut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ShareDelete.json - // this example is just showing the usage of "Shares_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SharePut.json + // this example is just showing the usage of "Shares_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +96,21 @@ public async Task Delete_ShareDelete() DataBoxEdgeShareResource dataBoxEdgeShare = client.GetDataBoxEdgeShareResource(dataBoxEdgeShareResourceId); // invoke the operation - await dataBoxEdgeShare.DeleteAsync(WaitUntil.Completed); + DataBoxEdgeShareData data = new DataBoxEdgeShareData(new ShareStatus("Online"), DataBoxEdgeShareMonitoringStatus.Enabled, ShareAccessProtocol.Smb) + { + Description = "", + AzureContainerInfo = new DataBoxEdgeStorageContainerInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/storageAccountCredentials/sac1"), "testContainerSMB", DataBoxEdgeStorageContainerDataFormat.BlockBlob), + UserAccessRights = { new UserAccessRight(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/users/user2"), ShareAccessType.Change) }, + DataPolicy = DataBoxEdgeDataPolicy.Cloud, + }; + ArmOperation lro = await dataBoxEdgeShare.UpdateAsync(WaitUntil.Completed, data); + DataBoxEdgeShareResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeShareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCollection.cs index 2f9f8b877333b..36bc32d7a0617 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataBoxEdgeStorageAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StorageAccountGetAllInDevice() + public async Task CreateOrUpdate_StorageAccountPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountGetAllInDevice.json - // this example is just showing the usage of "StorageAccounts_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountPut.json + // this example is just showing the usage of "StorageAccounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,22 @@ public async Task GetAll_StorageAccountGetAllInDevice() // get the collection of this DataBoxEdgeStorageAccountResource DataBoxEdgeStorageAccountCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeStorageAccounts(); - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeStorageAccountResource item in collection.GetAllAsync()) + // invoke the operation + string storageAccountName = "blobstorageaccount1"; + DataBoxEdgeStorageAccountData data = new DataBoxEdgeStorageAccountData(DataBoxEdgeDataPolicy.Cloud) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "It's an awesome storage account", + StorageAccountStatus = DataBoxEdgeStorageAccountStatus.OK, + StorageAccountCredentialId = new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForDataBoxEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/storageAccountCredentials/cisbvt"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageAccountName, data); + DataBoxEdgeStorageAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +93,10 @@ public async Task Get_StorageAccountGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StorageAccountGet() + public async Task GetAll_StorageAccountGetAllInDevice() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountGet.json - // this example is just showing the usage of "StorageAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountGetAllInDevice.json + // this example is just showing the usage of "StorageAccounts_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +114,22 @@ public async Task Exists_StorageAccountGet() // get the collection of this DataBoxEdgeStorageAccountResource DataBoxEdgeStorageAccountCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeStorageAccounts(); - // invoke the operation - string storageAccountName = "blobstorageaccount1"; - bool result = await collection.ExistsAsync(storageAccountName); + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeStorageAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StorageAccountGet() + public async Task Exists_StorageAccountGet() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountGet.json // this example is just showing the usage of "StorageAccounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +152,17 @@ public async Task GetIfExists_StorageAccountGet() // invoke the operation string storageAccountName = "blobstorageaccount1"; - NullableResponse response = await collection.GetIfExistsAsync(storageAccountName); - DataBoxEdgeStorageAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(storageAccountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StorageAccountPut() + public async Task GetIfExists_StorageAccountGet() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountPut.json - // this example is just showing the usage of "StorageAccounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountGet.json + // this example is just showing the usage of "StorageAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,20 +182,21 @@ public async Task CreateOrUpdate_StorageAccountPut() // invoke the operation string storageAccountName = "blobstorageaccount1"; - DataBoxEdgeStorageAccountData data = new DataBoxEdgeStorageAccountData(DataBoxEdgeDataPolicy.Cloud) - { - Description = "It's an awesome storage account", - StorageAccountStatus = DataBoxEdgeStorageAccountStatus.OK, - StorageAccountCredentialId = new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForDataBoxEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/storageAccountCredentials/cisbvt"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageAccountName, data); - DataBoxEdgeStorageAccountResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(storageAccountName); + DataBoxEdgeStorageAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCredentialCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCredentialCollection.cs index 30e6b9bb95e98..fb7d18c5a7425 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCredentialCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCredentialCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataBoxEdgeStorageAccountCredentialCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SACGetAllInDevice() + public async Task CreateOrUpdate_SACPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACGetAllInDevice.json - // this example is just showing the usage of "StorageAccountCredentials_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACPut.json + // this example is just showing the usage of "StorageAccountCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_SACGetAllInDevice() // get the collection of this DataBoxEdgeStorageAccountCredentialResource DataBoxEdgeStorageAccountCredentialCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeStorageAccountCredentials(); - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeStorageAccountCredentialResource item in collection.GetAllAsync()) + // invoke the operation + string name = "sac1"; + DataBoxEdgeStorageAccountCredentialData data = new DataBoxEdgeStorageAccountCredentialData("sac1", DataBoxEdgeStorageAccountSslStatus.Disabled, DataBoxEdgeStorageAccountType.BlobStorage) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageAccountCredentialData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + UserName = "cisbvt", + AccountKey = new AsymmetricEncryptedSecret("lAeZEYi6rNP1/EyNaVUYmTSZEYyaIaWmwUsGwek0+xiZj54GM9Ue9/UA2ed/ClC03wuSit2XzM/cLRU5eYiFBwks23rGwiQOr3sruEL2a74EjPD050xYjA6M1I2hu/w2yjVHhn5j+DbXS4Xzi+rHHNZK3DgfDO3PkbECjPck+PbpSBjy9+6Mrjcld5DIZhUAeMlMHrFlg+WKRKB14o/og56u5/xX6WKlrMLEQ+y6E18dUwvWs2elTNoVO8PBE8SM/CfooX4AMNvaNdSObNBPdP+F6Lzc556nFNWXrBLRt0vC7s9qTiVRO4x/qCNaK/B4y7IqXMllwQFf4Np9UQ2ECA==", DataBoxEdgeEncryptionAlgorithm.Aes256) + { + EncryptionCertThumbprint = "2A9D8D6BE51574B5461230AEF02F162C5F01AD31", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DataBoxEdgeStorageAccountCredentialResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageAccountCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_SACGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SACGet() + public async Task GetAll_SACGetAllInDevice() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACGet.json - // this example is just showing the usage of "StorageAccountCredentials_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACGetAllInDevice.json + // this example is just showing the usage of "StorageAccountCredentials_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_SACGet() // get the collection of this DataBoxEdgeStorageAccountCredentialResource DataBoxEdgeStorageAccountCredentialCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeStorageAccountCredentials(); - // invoke the operation - string name = "sac1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeStorageAccountCredentialResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageAccountCredentialData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SACGet() + public async Task Exists_SACGet() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACGet.json // this example is just showing the usage of "StorageAccountCredentials_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_SACGet() // invoke the operation string name = "sac1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DataBoxEdgeStorageAccountCredentialResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageAccountCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SACPut() + public async Task GetIfExists_SACGet() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACPut.json - // this example is just showing the usage of "StorageAccountCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACGet.json + // this example is just showing the usage of "StorageAccountCredentials_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_SACPut() // invoke the operation string name = "sac1"; - DataBoxEdgeStorageAccountCredentialData data = new DataBoxEdgeStorageAccountCredentialData("sac1", DataBoxEdgeStorageAccountSslStatus.Disabled, DataBoxEdgeStorageAccountType.BlobStorage) - { - UserName = "cisbvt", - AccountKey = new AsymmetricEncryptedSecret("lAeZEYi6rNP1/EyNaVUYmTSZEYyaIaWmwUsGwek0+xiZj54GM9Ue9/UA2ed/ClC03wuSit2XzM/cLRU5eYiFBwks23rGwiQOr3sruEL2a74EjPD050xYjA6M1I2hu/w2yjVHhn5j+DbXS4Xzi+rHHNZK3DgfDO3PkbECjPck+PbpSBjy9+6Mrjcld5DIZhUAeMlMHrFlg+WKRKB14o/og56u5/xX6WKlrMLEQ+y6E18dUwvWs2elTNoVO8PBE8SM/CfooX4AMNvaNdSObNBPdP+F6Lzc556nFNWXrBLRt0vC7s9qTiVRO4x/qCNaK/B4y7IqXMllwQFf4Np9UQ2ECA==", DataBoxEdgeEncryptionAlgorithm.Aes256) - { - EncryptionCertThumbprint = "2A9D8D6BE51574B5461230AEF02F162C5F01AD31", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DataBoxEdgeStorageAccountCredentialResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DataBoxEdgeStorageAccountCredentialResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageAccountCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageAccountCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCredentialResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCredentialResource.cs index 2bd8bfa124f50..00e2f26b5ad72 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCredentialResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountCredentialResource.cs @@ -49,10 +49,10 @@ public async Task Get_SACGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SACPut() + public async Task Delete_SACDelete() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACPut.json - // this example is just showing the usage of "StorageAccountCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACDelete.json + // this example is just showing the usage of "StorageAccountCredentials_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_SACPut() DataBoxEdgeStorageAccountCredentialResource dataBoxEdgeStorageAccountCredential = client.GetDataBoxEdgeStorageAccountCredentialResource(dataBoxEdgeStorageAccountCredentialResourceId); // invoke the operation - DataBoxEdgeStorageAccountCredentialData data = new DataBoxEdgeStorageAccountCredentialData("sac1", DataBoxEdgeStorageAccountSslStatus.Disabled, DataBoxEdgeStorageAccountType.BlobStorage) - { - UserName = "cisbvt", - AccountKey = new AsymmetricEncryptedSecret("lAeZEYi6rNP1/EyNaVUYmTSZEYyaIaWmwUsGwek0+xiZj54GM9Ue9/UA2ed/ClC03wuSit2XzM/cLRU5eYiFBwks23rGwiQOr3sruEL2a74EjPD050xYjA6M1I2hu/w2yjVHhn5j+DbXS4Xzi+rHHNZK3DgfDO3PkbECjPck+PbpSBjy9+6Mrjcld5DIZhUAeMlMHrFlg+WKRKB14o/og56u5/xX6WKlrMLEQ+y6E18dUwvWs2elTNoVO8PBE8SM/CfooX4AMNvaNdSObNBPdP+F6Lzc556nFNWXrBLRt0vC7s9qTiVRO4x/qCNaK/B4y7IqXMllwQFf4Np9UQ2ECA==", DataBoxEdgeEncryptionAlgorithm.Aes256) - { - EncryptionCertThumbprint = "2A9D8D6BE51574B5461230AEF02F162C5F01AD31", - }, - }; - ArmOperation lro = await dataBoxEdgeStorageAccountCredential.UpdateAsync(WaitUntil.Completed, data); - DataBoxEdgeStorageAccountCredentialResource result = lro.Value; + await dataBoxEdgeStorageAccountCredential.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageAccountCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SACDelete() + public async Task Update_SACPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACDelete.json - // this example is just showing the usage of "StorageAccountCredentials_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/SACPut.json + // this example is just showing the usage of "StorageAccountCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_SACDelete() DataBoxEdgeStorageAccountCredentialResource dataBoxEdgeStorageAccountCredential = client.GetDataBoxEdgeStorageAccountCredentialResource(dataBoxEdgeStorageAccountCredentialResourceId); // invoke the operation - await dataBoxEdgeStorageAccountCredential.DeleteAsync(WaitUntil.Completed); + DataBoxEdgeStorageAccountCredentialData data = new DataBoxEdgeStorageAccountCredentialData("sac1", DataBoxEdgeStorageAccountSslStatus.Disabled, DataBoxEdgeStorageAccountType.BlobStorage) + { + UserName = "cisbvt", + AccountKey = new AsymmetricEncryptedSecret("lAeZEYi6rNP1/EyNaVUYmTSZEYyaIaWmwUsGwek0+xiZj54GM9Ue9/UA2ed/ClC03wuSit2XzM/cLRU5eYiFBwks23rGwiQOr3sruEL2a74EjPD050xYjA6M1I2hu/w2yjVHhn5j+DbXS4Xzi+rHHNZK3DgfDO3PkbECjPck+PbpSBjy9+6Mrjcld5DIZhUAeMlMHrFlg+WKRKB14o/og56u5/xX6WKlrMLEQ+y6E18dUwvWs2elTNoVO8PBE8SM/CfooX4AMNvaNdSObNBPdP+F6Lzc556nFNWXrBLRt0vC7s9qTiVRO4x/qCNaK/B4y7IqXMllwQFf4Np9UQ2ECA==", DataBoxEdgeEncryptionAlgorithm.Aes256) + { + EncryptionCertThumbprint = "2A9D8D6BE51574B5461230AEF02F162C5F01AD31", + }, + }; + ArmOperation lro = await dataBoxEdgeStorageAccountCredential.UpdateAsync(WaitUntil.Completed, data); + DataBoxEdgeStorageAccountCredentialResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageAccountCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountResource.cs index 2e077a57ab853..a7988688d476f 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageAccountResource.cs @@ -49,10 +49,10 @@ public async Task Get_StorageAccountGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_StorageAccountPut() + public async Task Delete_StorageAccountDelete() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountPut.json - // this example is just showing the usage of "StorageAccounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountDelete.json + // this example is just showing the usage of "StorageAccounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,33 +64,22 @@ public async Task Update_StorageAccountPut() string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; string resourceGroupName = "GroupForEdgeAutomation"; string deviceName = "testedgedevice"; - string storageAccountName = "blobstorageaccount1"; + string storageAccountName = "storageaccount1"; ResourceIdentifier dataBoxEdgeStorageAccountResourceId = DataBoxEdgeStorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, deviceName, storageAccountName); DataBoxEdgeStorageAccountResource dataBoxEdgeStorageAccount = client.GetDataBoxEdgeStorageAccountResource(dataBoxEdgeStorageAccountResourceId); // invoke the operation - DataBoxEdgeStorageAccountData data = new DataBoxEdgeStorageAccountData(DataBoxEdgeDataPolicy.Cloud) - { - Description = "It's an awesome storage account", - StorageAccountStatus = DataBoxEdgeStorageAccountStatus.OK, - StorageAccountCredentialId = new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForDataBoxEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/storageAccountCredentials/cisbvt"), - }; - ArmOperation lro = await dataBoxEdgeStorageAccount.UpdateAsync(WaitUntil.Completed, data); - DataBoxEdgeStorageAccountResource result = lro.Value; + await dataBoxEdgeStorageAccount.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_StorageAccountDelete() + public async Task Update_StorageAccountPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountDelete.json - // this example is just showing the usage of "StorageAccounts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/StorageAccountPut.json + // this example is just showing the usage of "StorageAccounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,14 +91,25 @@ public async Task Delete_StorageAccountDelete() string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; string resourceGroupName = "GroupForEdgeAutomation"; string deviceName = "testedgedevice"; - string storageAccountName = "storageaccount1"; + string storageAccountName = "blobstorageaccount1"; ResourceIdentifier dataBoxEdgeStorageAccountResourceId = DataBoxEdgeStorageAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, deviceName, storageAccountName); DataBoxEdgeStorageAccountResource dataBoxEdgeStorageAccount = client.GetDataBoxEdgeStorageAccountResource(dataBoxEdgeStorageAccountResourceId); // invoke the operation - await dataBoxEdgeStorageAccount.DeleteAsync(WaitUntil.Completed); + DataBoxEdgeStorageAccountData data = new DataBoxEdgeStorageAccountData(DataBoxEdgeDataPolicy.Cloud) + { + Description = "It's an awesome storage account", + StorageAccountStatus = DataBoxEdgeStorageAccountStatus.OK, + StorageAccountCredentialId = new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForDataBoxEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/storageAccountCredentials/cisbvt"), + }; + ArmOperation lro = await dataBoxEdgeStorageAccount.UpdateAsync(WaitUntil.Completed, data); + DataBoxEdgeStorageAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageContainerCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageContainerCollection.cs index e8fd8266e8c83..e17cd3fdcbe9f 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageContainerCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataBoxEdgeStorageContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ContainerListAllInDevice() + public async Task CreateOrUpdate_ContainerPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerListAllInDevice.json - // this example is just showing the usage of "Containers_ListByStorageAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerPut.json + // this example is just showing the usage of "Containers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,17 @@ public async Task GetAll_ContainerListAllInDevice() // get the collection of this DataBoxEdgeStorageContainerResource DataBoxEdgeStorageContainerCollection collection = dataBoxEdgeStorageAccount.GetDataBoxEdgeStorageContainers(); - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeStorageContainerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string containerName = "blobcontainer1"; + DataBoxEdgeStorageContainerData data = new DataBoxEdgeStorageContainerData(DataBoxEdgeStorageContainerDataFormat.BlockBlob); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, data); + DataBoxEdgeStorageContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +90,10 @@ public async Task Get_ContainerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ContainerGet() + public async Task GetAll_ContainerListAllInDevice() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerGet.json - // this example is just showing the usage of "Containers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerListAllInDevice.json + // this example is just showing the usage of "Containers_ListByStorageAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_ContainerGet() // get the collection of this DataBoxEdgeStorageContainerResource DataBoxEdgeStorageContainerCollection collection = dataBoxEdgeStorageAccount.GetDataBoxEdgeStorageContainers(); - // invoke the operation - string containerName = "blobcontainer1"; - bool result = await collection.ExistsAsync(containerName); + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeStorageContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ContainerGet() + public async Task Exists_ContainerGet() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerGet.json // this example is just showing the usage of "Containers_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +151,17 @@ public async Task GetIfExists_ContainerGet() // invoke the operation string containerName = "blobcontainer1"; - NullableResponse response = await collection.GetIfExistsAsync(containerName); - DataBoxEdgeStorageContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(containerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ContainerPut() + public async Task GetIfExists_ContainerGet() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerPut.json - // this example is just showing the usage of "Containers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerGet.json + // this example is just showing the usage of "Containers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,15 +182,21 @@ public async Task CreateOrUpdate_ContainerPut() // invoke the operation string containerName = "blobcontainer1"; - DataBoxEdgeStorageContainerData data = new DataBoxEdgeStorageContainerData(DataBoxEdgeStorageContainerDataFormat.BlockBlob); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, containerName, data); - DataBoxEdgeStorageContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(containerName); + DataBoxEdgeStorageContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageContainerResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageContainerResource.cs index 4b70c7a6c167b..13c1e3e8b81e1 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageContainerResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeStorageContainerResource.cs @@ -50,10 +50,10 @@ public async Task Get_ContainerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ContainerPut() + public async Task Delete_ContainerDelete() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerPut.json - // this example is just showing the usage of "Containers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerDelete.json + // this example is just showing the usage of "Containers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,23 +71,17 @@ public async Task Update_ContainerPut() DataBoxEdgeStorageContainerResource dataBoxEdgeStorageContainer = client.GetDataBoxEdgeStorageContainerResource(dataBoxEdgeStorageContainerResourceId); // invoke the operation - DataBoxEdgeStorageContainerData data = new DataBoxEdgeStorageContainerData(DataBoxEdgeStorageContainerDataFormat.BlockBlob); - ArmOperation lro = await dataBoxEdgeStorageContainer.UpdateAsync(WaitUntil.Completed, data); - DataBoxEdgeStorageContainerResource result = lro.Value; + await dataBoxEdgeStorageContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeStorageContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ContainerDelete() + public async Task Update_ContainerPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerDelete.json - // this example is just showing the usage of "Containers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/ContainerPut.json + // this example is just showing the usage of "Containers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +99,15 @@ public async Task Delete_ContainerDelete() DataBoxEdgeStorageContainerResource dataBoxEdgeStorageContainer = client.GetDataBoxEdgeStorageContainerResource(dataBoxEdgeStorageContainerResourceId); // invoke the operation - await dataBoxEdgeStorageContainer.DeleteAsync(WaitUntil.Completed); + DataBoxEdgeStorageContainerData data = new DataBoxEdgeStorageContainerData(DataBoxEdgeStorageContainerDataFormat.BlockBlob); + ArmOperation lro = await dataBoxEdgeStorageContainer.UpdateAsync(WaitUntil.Completed, data); + DataBoxEdgeStorageContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeStorageContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeTriggerCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeTriggerCollection.cs index e3e6b49b301b5..d580f8b79b105 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeTriggerCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeTriggerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataBoxEdgeTriggerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TriggerGetAllInDevice() + public async Task CreateOrUpdate_TriggerPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerGetAllInDevice.json - // this example is just showing the usage of "Triggers_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerPut.json + // this example is just showing the usage of "Triggers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_TriggerGetAllInDevice() // get the collection of this DataBoxEdgeTriggerResource DataBoxEdgeTriggerCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeTriggers(); - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeTriggerResource item in collection.GetAllAsync()) + // invoke the operation + string name = "trigger1"; + DataBoxEdgeTriggerData data = new EdgeFileEventTrigger(new EdgeFileSourceInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/shares/share1")), new DataBoxEdgeRoleSinkInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/roles/role1"))) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeTriggerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CustomContextTag = "CustomContextTags-1235346475", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DataBoxEdgeTriggerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_TriggerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TriggerGet() + public async Task GetAll_TriggerGetAllInDevice() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerGet.json - // this example is just showing the usage of "Triggers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerGetAllInDevice.json + // this example is just showing the usage of "Triggers_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_TriggerGet() // get the collection of this DataBoxEdgeTriggerResource DataBoxEdgeTriggerCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeTriggers(); - // invoke the operation - string name = "trigger1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeTriggerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeTriggerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TriggerGet() + public async Task Exists_TriggerGet() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerGet.json // this example is just showing the usage of "Triggers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_TriggerGet() // invoke the operation string name = "trigger1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DataBoxEdgeTriggerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TriggerPut() + public async Task GetIfExists_TriggerGet() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerPut.json - // this example is just showing the usage of "Triggers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerGet.json + // this example is just showing the usage of "Triggers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_TriggerPut() // invoke the operation string name = "trigger1"; - DataBoxEdgeTriggerData data = new EdgeFileEventTrigger(new EdgeFileSourceInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/shares/share1")), new DataBoxEdgeRoleSinkInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/roles/role1"))) - { - CustomContextTag = "CustomContextTags-1235346475", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DataBoxEdgeTriggerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DataBoxEdgeTriggerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeTriggerResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeTriggerResource.cs index 2cdb4bab82e95..653745333baa7 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeTriggerResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeTriggerResource.cs @@ -49,10 +49,10 @@ public async Task Get_TriggerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TriggerPut() + public async Task Delete_TriggerDelete() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerPut.json - // this example is just showing the usage of "Triggers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerDelete.json + // this example is just showing the usage of "Triggers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_TriggerPut() DataBoxEdgeTriggerResource dataBoxEdgeTrigger = client.GetDataBoxEdgeTriggerResource(dataBoxEdgeTriggerResourceId); // invoke the operation - DataBoxEdgeTriggerData data = new EdgeFileEventTrigger(new EdgeFileSourceInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/shares/share1")), new DataBoxEdgeRoleSinkInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/roles/role1"))) - { - CustomContextTag = "CustomContextTags-1235346475", - }; - ArmOperation lro = await dataBoxEdgeTrigger.UpdateAsync(WaitUntil.Completed, data); - DataBoxEdgeTriggerResource result = lro.Value; + await dataBoxEdgeTrigger.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_TriggerDelete() + public async Task Update_TriggerPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerDelete.json - // this example is just showing the usage of "Triggers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/TriggerPut.json + // this example is just showing the usage of "Triggers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_TriggerDelete() DataBoxEdgeTriggerResource dataBoxEdgeTrigger = client.GetDataBoxEdgeTriggerResource(dataBoxEdgeTriggerResourceId); // invoke the operation - await dataBoxEdgeTrigger.DeleteAsync(WaitUntil.Completed); + DataBoxEdgeTriggerData data = new EdgeFileEventTrigger(new EdgeFileSourceInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/shares/share1")), new DataBoxEdgeRoleSinkInfo(new ResourceIdentifier("/subscriptions/4385cf00-2d3a-425a-832f-f4285b1c9dce/resourceGroups/GroupForEdgeAutomation/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/testedgedevice/roles/role1"))) + { + CustomContextTag = "CustomContextTags-1235346475", + }; + ArmOperation lro = await dataBoxEdgeTrigger.UpdateAsync(WaitUntil.Completed, data); + DataBoxEdgeTriggerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeUserCollection.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeUserCollection.cs index eb83e4aa6f9a6..57c6fa4a8a40d 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeUserCollection.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeUserCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataBoxEdgeUserCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_UserGetAllInDevice() + public async Task CreateOrUpdate_UserPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserGetAllInDevice.json - // this example is just showing the usage of "Users_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserPut.json + // this example is just showing the usage of "Users_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_UserGetAllInDevice() // get the collection of this DataBoxEdgeUserResource DataBoxEdgeUserCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeUsers(); - // invoke the operation and iterate over the result - await foreach (DataBoxEdgeUserResource item in collection.GetAllAsync()) + // invoke the operation + string name = "user1"; + DataBoxEdgeUserData data = new DataBoxEdgeUserData(DataBoxEdgeUserType.Share) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeUserData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EncryptedPassword = new AsymmetricEncryptedSecret("", DataBoxEdgeEncryptionAlgorithm.None) + { + EncryptionCertThumbprint = "blah", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DataBoxEdgeUserResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +94,10 @@ public async Task Get_UserGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_UserGet() + public async Task GetAll_UserGetAllInDevice() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserGet.json - // this example is just showing the usage of "Users_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserGetAllInDevice.json + // this example is just showing the usage of "Users_ListByDataBoxEdgeDevice" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +115,22 @@ public async Task Exists_UserGet() // get the collection of this DataBoxEdgeUserResource DataBoxEdgeUserCollection collection = dataBoxEdgeDevice.GetDataBoxEdgeUsers(); - // invoke the operation - string name = "user1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeUserResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeUserData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_UserGet() + public async Task Exists_UserGet() { // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserGet.json // this example is just showing the usage of "Users_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +153,17 @@ public async Task GetIfExists_UserGet() // invoke the operation string name = "user1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DataBoxEdgeUserResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UserPut() + public async Task GetIfExists_UserGet() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserPut.json - // this example is just showing the usage of "Users_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserGet.json + // this example is just showing the usage of "Users_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,21 +183,21 @@ public async Task CreateOrUpdate_UserPut() // invoke the operation string name = "user1"; - DataBoxEdgeUserData data = new DataBoxEdgeUserData(DataBoxEdgeUserType.Share) - { - EncryptedPassword = new AsymmetricEncryptedSecret("", DataBoxEdgeEncryptionAlgorithm.None) - { - EncryptionCertThumbprint = "blah", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DataBoxEdgeUserResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + DataBoxEdgeUserResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeUserResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeUserResource.cs index 43c82b8090b73..893bbf2c59b1e 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeUserResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DataBoxEdgeUserResource.cs @@ -49,10 +49,10 @@ public async Task Get_UserGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UserPut() + public async Task Delete_UserDelete() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserPut.json - // this example is just showing the usage of "Users_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserDelete.json + // this example is just showing the usage of "Users_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_UserPut() DataBoxEdgeUserResource dataBoxEdgeUser = client.GetDataBoxEdgeUserResource(dataBoxEdgeUserResourceId); // invoke the operation - DataBoxEdgeUserData data = new DataBoxEdgeUserData(DataBoxEdgeUserType.Share) - { - EncryptedPassword = new AsymmetricEncryptedSecret("", DataBoxEdgeEncryptionAlgorithm.None) - { - EncryptionCertThumbprint = "blah", - }, - }; - ArmOperation lro = await dataBoxEdgeUser.UpdateAsync(WaitUntil.Completed, data); - DataBoxEdgeUserResource result = lro.Value; + await dataBoxEdgeUser.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataBoxEdgeUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_UserDelete() + public async Task Update_UserPut() { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserDelete.json - // this example is just showing the usage of "Users_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/UserPut.json + // this example is just showing the usage of "Users_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_UserDelete() DataBoxEdgeUserResource dataBoxEdgeUser = client.GetDataBoxEdgeUserResource(dataBoxEdgeUserResourceId); // invoke the operation - await dataBoxEdgeUser.DeleteAsync(WaitUntil.Completed); + DataBoxEdgeUserData data = new DataBoxEdgeUserData(DataBoxEdgeUserType.Share) + { + EncryptedPassword = new AsymmetricEncryptedSecret("", DataBoxEdgeEncryptionAlgorithm.None) + { + EncryptionCertThumbprint = "blah", + }, + }; + ArmOperation lro = await dataBoxEdgeUser.UpdateAsync(WaitUntil.Completed, data); + DataBoxEdgeUserResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DiagnosticRemoteSupportSettingResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DiagnosticRemoteSupportSettingResource.cs index fc0a66053ae1d..44db566c59d29 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DiagnosticRemoteSupportSettingResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_DiagnosticRemoteSupportSettingResource.cs @@ -67,17 +67,14 @@ public async Task CreateOrUpdate_UpdateDiagnosticRemoteSupportSettings() DiagnosticRemoteSupportSettingResource diagnosticRemoteSupportSetting = client.GetDiagnosticRemoteSupportSettingResource(diagnosticRemoteSupportSettingResourceId); // invoke the operation - DiagnosticRemoteSupportSettingData data = new DiagnosticRemoteSupportSettingData() + DiagnosticRemoteSupportSettingData data = new DiagnosticRemoteSupportSettingData { - RemoteSupportSettingsList = -{ -new EdgeRemoteSupportSettings() + RemoteSupportSettingsList = {new EdgeRemoteSupportSettings { RemoteApplicationType = EdgeRemoteApplicationType.Powershell, AccessLevel = EdgeRemoteApplicationAccessLevel.ReadWrite, ExpireOn = DateTimeOffset.Parse("2021-07-07T00:00:00+00:00"), -} -}, +}}, }; ArmOperation lro = await diagnosticRemoteSupportSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); DiagnosticRemoteSupportSettingResource result = lro.Value; diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_MonitoringMetricConfigurationResource.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_MonitoringMetricConfigurationResource.cs index 442faf5bfd08c..bdb0d21430c60 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_MonitoringMetricConfigurationResource.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_MonitoringMetricConfigurationResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetMonitoringConfig() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteMonitoringConfig() + { + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DeleteMonitoringConfig.json + // this example is just showing the usage of "MonitoringConfig_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MonitoringMetricConfigurationResource created on azure + // for more information of creating MonitoringMetricConfigurationResource, please refer to the document of MonitoringMetricConfigurationResource + string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; + string resourceGroupName = "GroupForEdgeAutomation"; + string deviceName = "testedgedevice"; + string roleName = "testrole"; + ResourceIdentifier monitoringMetricConfigurationResourceId = MonitoringMetricConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, deviceName, roleName); + MonitoringMetricConfigurationResource monitoringMetricConfiguration = client.GetMonitoringMetricConfigurationResource(monitoringMetricConfigurationResourceId); + + // invoke the operation + await monitoringMetricConfiguration.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_PutMonitoringConfig() @@ -71,7 +98,7 @@ public async Task CreateOrUpdate_PutMonitoringConfig() // invoke the operation MonitoringMetricConfigurationData data = new MonitoringMetricConfigurationData(new DataBoxEdgeMetricConfiguration[] { -new DataBoxEdgeMetricConfiguration(new ResourceIdentifier("test"),new DataBoxEdgeMetricCounterSet[] +new DataBoxEdgeMetricConfiguration(new ResourceIdentifier("test"), new DataBoxEdgeMetricCounterSet[] { new DataBoxEdgeMetricCounterSet(new DataBoxEdgeMetricCounter[] { @@ -92,32 +119,5 @@ public async Task CreateOrUpdate_PutMonitoringConfig() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteMonitoringConfig() - { - // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DeleteMonitoringConfig.json - // this example is just showing the usage of "MonitoringConfig_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MonitoringMetricConfigurationResource created on azure - // for more information of creating MonitoringMetricConfigurationResource, please refer to the document of MonitoringMetricConfigurationResource - string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; - string resourceGroupName = "GroupForEdgeAutomation"; - string deviceName = "testedgedevice"; - string roleName = "testrole"; - ResourceIdentifier monitoringMetricConfigurationResourceId = MonitoringMetricConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, deviceName, roleName); - MonitoringMetricConfigurationResource monitoringMetricConfiguration = client.GetMonitoringMetricConfigurationResource(monitoringMetricConfigurationResourceId); - - // invoke the operation - await monitoringMetricConfiguration.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index e63955162ef71..b8b6a440fa474 100644 --- a/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/databoxedge/Azure.ResourceManager.DataBoxEdge/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -43,5 +43,36 @@ public async Task GetAvailableSkus_AvailableSkus() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataBoxEdgeDevices_DataBoxEdgeDeviceGetBySubscription() + { + // Generated from example definition: specification/databoxedge/resource-manager/Microsoft.DataBoxEdge/stable/2022-03-01/examples/DataBoxEdgeDeviceGetBySubscription.json + // this example is just showing the usage of "Devices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "4385cf00-2d3a-425a-832f-f4285b1c9dce"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataBoxEdgeDeviceResource item in subscriptionResource.GetDataBoxEdgeDevicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataBoxEdgeDeviceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogMonitorResource.cs b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogMonitorResource.cs index 3ca457e42f651..015ee8b557198 100644 --- a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogMonitorResource.cs +++ b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogMonitorResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Datadog.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using NUnit.Framework; @@ -20,10 +19,10 @@ public partial class Sample_DatadogMonitorResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetApiKeys_MonitorsListApiKeys() + public async Task Get_MonitorsGet() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/ApiKeys_List.json - // this example is just showing the usage of "Monitors_ListApiKeys" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Get.json + // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,21 +37,22 @@ public async Task GetApiKeys_MonitorsListApiKeys() ResourceIdentifier datadogMonitorResourceId = DatadogMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); DatadogMonitorResource datadogMonitorResource = client.GetDatadogMonitorResource(datadogMonitorResourceId); - // invoke the operation and iterate over the result - await foreach (DatadogApiKey item in datadogMonitorResource.GetApiKeysAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + DatadogMonitorResource result = await datadogMonitorResource.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatadogMonitorResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDefaultKey_MonitorsGetDefaultKey() + public async Task Delete_MonitorsDelete() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/ApiKeys_GetDefaultKey.json - // this example is just showing the usage of "Monitors_GetDefaultKey" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Delete.json + // this example is just showing the usage of "Monitors_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,17 +68,17 @@ public async Task GetDefaultKey_MonitorsGetDefaultKey() DatadogMonitorResource datadogMonitorResource = client.GetDatadogMonitorResource(datadogMonitorResourceId); // invoke the operation - DatadogApiKey result = await datadogMonitorResource.GetDefaultKeyAsync(); + await datadogMonitorResource.DeleteAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task SetDefaultKey_MonitorsSetDefaultKey() + public async Task Update_MonitorsUpdate() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/ApiKeys_SetDefaultKey.json - // this example is just showing the usage of "Monitors_SetDefaultKey" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Update.json + // this example is just showing the usage of "Monitors_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,17 +94,23 @@ public async Task SetDefaultKey_MonitorsSetDefaultKey() DatadogMonitorResource datadogMonitorResource = client.GetDatadogMonitorResource(datadogMonitorResourceId); // invoke the operation - await datadogMonitorResource.SetDefaultKeyAsync(); + DatadogMonitorResourcePatch patch = new DatadogMonitorResourcePatch(); + ArmOperation lro = await datadogMonitorResource.UpdateAsync(WaitUntil.Completed, patch); + DatadogMonitorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatadogMonitorResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetHosts_MonitorsListHosts() + public async Task GetApiKeys_MonitorsListApiKeys() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Hosts_List.json - // this example is just showing the usage of "Monitors_ListHosts" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/ApiKeys_List.json + // this example is just showing the usage of "Monitors_ListApiKeys" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,7 +126,7 @@ public async Task GetHosts_MonitorsListHosts() DatadogMonitorResource datadogMonitorResource = client.GetDatadogMonitorResource(datadogMonitorResourceId); // invoke the operation and iterate over the result - await foreach (DatadogHost item in datadogMonitorResource.GetHostsAsync()) + await foreach (DatadogApiKey item in datadogMonitorResource.GetApiKeysAsync()) { Console.WriteLine($"Succeeded: {item}"); } @@ -130,10 +136,10 @@ public async Task GetHosts_MonitorsListHosts() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLinkedResources_MonitorsListLinkedResources() + public async Task GetDefaultKey_MonitorsGetDefaultKey() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/LinkedResources_List.json - // this example is just showing the usage of "Monitors_ListLinkedResources" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/ApiKeys_GetDefaultKey.json + // this example is just showing the usage of "Monitors_GetDefaultKey" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,21 +154,18 @@ public async Task GetLinkedResources_MonitorsListLinkedResources() ResourceIdentifier datadogMonitorResourceId = DatadogMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); DatadogMonitorResource datadogMonitorResource = client.GetDatadogMonitorResource(datadogMonitorResourceId); - // invoke the operation and iterate over the result - await foreach (SubResource item in datadogMonitorResource.GetLinkedResourcesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + DatadogApiKey result = await datadogMonitorResource.GetDefaultKeyAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetMonitoredResources_MonitorsListMonitoredResources() + public async Task SetDefaultKey_MonitorsSetDefaultKey() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/MonitoredResources_List.json - // this example is just showing the usage of "Monitors_ListMonitoredResources" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/ApiKeys_SetDefaultKey.json + // this example is just showing the usage of "Monitors_SetDefaultKey" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,52 +180,18 @@ public async Task GetMonitoredResources_MonitorsListMonitoredResources() ResourceIdentifier datadogMonitorResourceId = DatadogMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); DatadogMonitorResource datadogMonitorResource = client.GetDatadogMonitorResource(datadogMonitorResourceId); - // invoke the operation and iterate over the result - await foreach (MonitoredResourceContent item in datadogMonitorResource.GetMonitoredResourcesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDatadogMonitorResources_MonitorsList() - { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_List.json - // this example is just showing the usage of "Monitors_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DatadogMonitorResource item in subscriptionResource.GetDatadogMonitorResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatadogMonitorResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + await datadogMonitorResource.SetDefaultKeyAsync(); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MonitorsGet() + public async Task GetHosts_MonitorsListHosts() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Get.json - // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Hosts_List.json + // this example is just showing the usage of "Monitors_ListHosts" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -237,22 +206,21 @@ public async Task Get_MonitorsGet() ResourceIdentifier datadogMonitorResourceId = DatadogMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); DatadogMonitorResource datadogMonitorResource = client.GetDatadogMonitorResource(datadogMonitorResourceId); - // invoke the operation - DatadogMonitorResource result = await datadogMonitorResource.GetAsync(); + // invoke the operation and iterate over the result + await foreach (DatadogHost item in datadogMonitorResource.GetHostsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatadogMonitorResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MonitorsUpdate() + public async Task GetLinkedResources_MonitorsListLinkedResources() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Update.json - // this example is just showing the usage of "Monitors_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/LinkedResources_List.json + // this example is just showing the usage of "Monitors_ListLinkedResources" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -267,24 +235,21 @@ public async Task Update_MonitorsUpdate() ResourceIdentifier datadogMonitorResourceId = DatadogMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); DatadogMonitorResource datadogMonitorResource = client.GetDatadogMonitorResource(datadogMonitorResourceId); - // invoke the operation - DatadogMonitorResourcePatch patch = new DatadogMonitorResourcePatch(); - ArmOperation lro = await datadogMonitorResource.UpdateAsync(WaitUntil.Completed, patch); - DatadogMonitorResource result = lro.Value; + // invoke the operation and iterate over the result + await foreach (SubResource item in datadogMonitorResource.GetLinkedResourcesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatadogMonitorResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_MonitorsDelete() + public async Task GetMonitoredResources_MonitorsListMonitoredResources() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Delete.json - // this example is just showing the usage of "Monitors_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/MonitoredResources_List.json + // this example is just showing the usage of "Monitors_ListMonitoredResources" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -299,8 +264,11 @@ public async Task Delete_MonitorsDelete() ResourceIdentifier datadogMonitorResourceId = DatadogMonitorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, monitorName); DatadogMonitorResource datadogMonitorResource = client.GetDatadogMonitorResource(datadogMonitorResourceId); - // invoke the operation - await datadogMonitorResource.DeleteAsync(WaitUntil.Completed); + // invoke the operation and iterate over the result + await foreach (MonitoredResourceContent item in datadogMonitorResource.GetMonitoredResourcesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } diff --git a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogMonitorResourceCollection.cs b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogMonitorResourceCollection.cs index 881754895dadd..85dc7891b7096 100644 --- a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogMonitorResourceCollection.cs +++ b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogMonitorResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DatadogMonitorResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MonitorsListByResourceGroup() + public async Task CreateOrUpdate_MonitorsCreate() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_ListByResourceGroup.json - // this example is just showing the usage of "Monitors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Create.json + // this example is just showing the usage of "Monitors_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_MonitorsListByResourceGroup() // get the collection of this DatadogMonitorResource DatadogMonitorResourceCollection collection = resourceGroupResource.GetDatadogMonitorResources(); - // invoke the operation and iterate over the result - await foreach (DatadogMonitorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatadogMonitorResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string monitorName = "myMonitor"; + DatadogMonitorResourceData data = new DatadogMonitorResourceData(default); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, monitorName, data); + DatadogMonitorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatadogMonitorResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +86,10 @@ public async Task Get_MonitorsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MonitorsGet() + public async Task GetAll_MonitorsListByResourceGroup() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Get.json - // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_ListByResourceGroup.json + // this example is just showing the usage of "Monitors_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +106,22 @@ public async Task Exists_MonitorsGet() // get the collection of this DatadogMonitorResource DatadogMonitorResourceCollection collection = resourceGroupResource.GetDatadogMonitorResources(); - // invoke the operation - string monitorName = "myMonitor"; - bool result = await collection.ExistsAsync(monitorName); + // invoke the operation and iterate over the result + await foreach (DatadogMonitorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatadogMonitorResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MonitorsGet() + public async Task Exists_MonitorsGet() { // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Get.json // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +143,17 @@ public async Task GetIfExists_MonitorsGet() // invoke the operation string monitorName = "myMonitor"; - NullableResponse response = await collection.GetIfExistsAsync(monitorName); - DatadogMonitorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(monitorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatadogMonitorResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_MonitorsCreate() + public async Task GetIfExists_MonitorsGet() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Create.json - // this example is just showing the usage of "Monitors_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_Get.json + // this example is just showing the usage of "Monitors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,15 +172,21 @@ public async Task CreateOrUpdate_MonitorsCreate() // invoke the operation string monitorName = "myMonitor"; - DatadogMonitorResourceData data = new DatadogMonitorResourceData(new AzureLocation("placeholder")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, monitorName, data); - DatadogMonitorResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(monitorName); + DatadogMonitorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatadogMonitorResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatadogMonitorResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogSingleSignOnResource.cs b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogSingleSignOnResource.cs index 879d30dc5e0a2..b5aa9f9d097e2 100644 --- a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogSingleSignOnResource.cs +++ b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogSingleSignOnResource.cs @@ -17,10 +17,10 @@ public partial class Sample_DatadogSingleSignOnResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SingleSignOnConfigurationsCreateOrUpdate() + public async Task Get_SingleSignOnConfigurationsGet() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/SingleSignOnConfigurations_CreateOrUpdate.json - // this example is just showing the usage of "SingleSignOnConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/SingleSignOnConfigurations_Get.json + // this example is just showing the usage of "SingleSignOnConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,9 +37,7 @@ public async Task Update_SingleSignOnConfigurationsCreateOrUpdate() DatadogSingleSignOnResource datadogSingleSignOnResource = client.GetDatadogSingleSignOnResource(datadogSingleSignOnResourceId); // invoke the operation - DatadogSingleSignOnResourceData data = new DatadogSingleSignOnResourceData(); - ArmOperation lro = await datadogSingleSignOnResource.UpdateAsync(WaitUntil.Completed, data); - DatadogSingleSignOnResource result = lro.Value; + DatadogSingleSignOnResource result = await datadogSingleSignOnResource.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,10 +48,10 @@ public async Task Update_SingleSignOnConfigurationsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SingleSignOnConfigurationsGet() + public async Task Update_SingleSignOnConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/SingleSignOnConfigurations_Get.json - // this example is just showing the usage of "SingleSignOnConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/SingleSignOnConfigurations_CreateOrUpdate.json + // this example is just showing the usage of "SingleSignOnConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,7 +68,9 @@ public async Task Get_SingleSignOnConfigurationsGet() DatadogSingleSignOnResource datadogSingleSignOnResource = client.GetDatadogSingleSignOnResource(datadogSingleSignOnResourceId); // invoke the operation - DatadogSingleSignOnResource result = await datadogSingleSignOnResource.GetAsync(); + DatadogSingleSignOnResourceData data = new DatadogSingleSignOnResourceData(); + ArmOperation lro = await datadogSingleSignOnResource.UpdateAsync(WaitUntil.Completed, data); + DatadogSingleSignOnResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogSingleSignOnResourceCollection.cs b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogSingleSignOnResourceCollection.cs index f5840203b3b6f..fd2ee71a0950e 100644 --- a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogSingleSignOnResourceCollection.cs +++ b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_DatadogSingleSignOnResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DatadogSingleSignOnResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SingleSignOnConfigurationsList() + public async Task CreateOrUpdate_SingleSignOnConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/SingleSignOnConfigurations_List.json - // this example is just showing the usage of "SingleSignOnConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/SingleSignOnConfigurations_CreateOrUpdate.json + // this example is just showing the usage of "SingleSignOnConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,25 @@ public async Task GetAll_SingleSignOnConfigurationsList() // get the collection of this DatadogSingleSignOnResource DatadogSingleSignOnResourceCollection collection = datadogMonitorResource.GetDatadogSingleSignOnResources(); - // invoke the operation and iterate over the result - await foreach (DatadogSingleSignOnResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatadogSingleSignOnResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string configurationName = "default"; + DatadogSingleSignOnResourceData data = new DatadogSingleSignOnResourceData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + DatadogSingleSignOnResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatadogSingleSignOnResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SingleSignOnConfigurationsCreateOrUpdate() + public async Task Get_SingleSignOnConfigurationsGet() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/SingleSignOnConfigurations_CreateOrUpdate.json - // this example is just showing the usage of "SingleSignOnConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/SingleSignOnConfigurations_Get.json + // this example is just showing the usage of "SingleSignOnConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,9 +76,7 @@ public async Task CreateOrUpdate_SingleSignOnConfigurationsCreateOrUpdate() // invoke the operation string configurationName = "default"; - DatadogSingleSignOnResourceData data = new DatadogSingleSignOnResourceData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - DatadogSingleSignOnResource result = lro.Value; + DatadogSingleSignOnResource result = await collection.GetAsync(configurationName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +87,10 @@ public async Task CreateOrUpdate_SingleSignOnConfigurationsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SingleSignOnConfigurationsGet() + public async Task GetAll_SingleSignOnConfigurationsList() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/SingleSignOnConfigurations_Get.json - // this example is just showing the usage of "SingleSignOnConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/SingleSignOnConfigurations_List.json + // this example is just showing the usage of "SingleSignOnConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,15 +108,17 @@ public async Task Get_SingleSignOnConfigurationsGet() // get the collection of this DatadogSingleSignOnResource DatadogSingleSignOnResourceCollection collection = datadogMonitorResource.GetDatadogSingleSignOnResources(); - // invoke the operation - string configurationName = "default"; - DatadogSingleSignOnResource result = await collection.GetAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (DatadogSingleSignOnResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatadogSingleSignOnResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatadogSingleSignOnResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_MonitoringTagRuleCollection.cs b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_MonitoringTagRuleCollection.cs index e82c1f4d62e3e..88fdab415ea40 100644 --- a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_MonitoringTagRuleCollection.cs +++ b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_MonitoringTagRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MonitoringTagRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TagRulesList() + public async Task CreateOrUpdate_TagRulesCreateOrUpdate() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/TagRules_List.json - // this example is just showing the usage of "TagRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/TagRules_CreateOrUpdate.json + // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,25 @@ public async Task GetAll_TagRulesList() // get the collection of this MonitoringTagRuleResource MonitoringTagRuleCollection collection = datadogMonitorResource.GetMonitoringTagRules(); - // invoke the operation and iterate over the result - await foreach (MonitoringTagRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitoringTagRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string ruleSetName = "default"; + MonitoringTagRuleData data = new MonitoringTagRuleData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName, data); + MonitoringTagRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitoringTagRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TagRulesCreateOrUpdate() + public async Task Get_TagRulesGet() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/TagRules_CreateOrUpdate.json - // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/TagRules_Get.json + // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,9 +76,7 @@ public async Task CreateOrUpdate_TagRulesCreateOrUpdate() // invoke the operation string ruleSetName = "default"; - MonitoringTagRuleData data = new MonitoringTagRuleData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName, data); - MonitoringTagRuleResource result = lro.Value; + MonitoringTagRuleResource result = await collection.GetAsync(ruleSetName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +87,10 @@ public async Task CreateOrUpdate_TagRulesCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TagRulesGet() + public async Task GetAll_TagRulesList() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/TagRules_Get.json - // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/TagRules_List.json + // this example is just showing the usage of "TagRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,15 +108,17 @@ public async Task Get_TagRulesGet() // get the collection of this MonitoringTagRuleResource MonitoringTagRuleCollection collection = datadogMonitorResource.GetMonitoringTagRules(); - // invoke the operation - string ruleSetName = "default"; - MonitoringTagRuleResource result = await collection.GetAsync(ruleSetName); + // invoke the operation and iterate over the result + await foreach (MonitoringTagRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitoringTagRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitoringTagRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_MonitoringTagRuleResource.cs b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_MonitoringTagRuleResource.cs index cd52cd9c78bde..4fd2ac3d570fa 100644 --- a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_MonitoringTagRuleResource.cs +++ b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_MonitoringTagRuleResource.cs @@ -17,10 +17,10 @@ public partial class Sample_MonitoringTagRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TagRulesCreateOrUpdate() + public async Task Get_TagRulesGet() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/TagRules_CreateOrUpdate.json - // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/TagRules_Get.json + // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,9 +37,7 @@ public async Task Update_TagRulesCreateOrUpdate() MonitoringTagRuleResource monitoringTagRule = client.GetMonitoringTagRuleResource(monitoringTagRuleResourceId); // invoke the operation - MonitoringTagRuleData data = new MonitoringTagRuleData(); - ArmOperation lro = await monitoringTagRule.UpdateAsync(WaitUntil.Completed, data); - MonitoringTagRuleResource result = lro.Value; + MonitoringTagRuleResource result = await monitoringTagRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,10 +48,10 @@ public async Task Update_TagRulesCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TagRulesGet() + public async Task Update_TagRulesCreateOrUpdate() { - // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/TagRules_Get.json - // this example is just showing the usage of "TagRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/TagRules_CreateOrUpdate.json + // this example is just showing the usage of "TagRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,7 +68,9 @@ public async Task Get_TagRulesGet() MonitoringTagRuleResource monitoringTagRule = client.GetMonitoringTagRuleResource(monitoringTagRuleResourceId); // invoke the operation - MonitoringTagRuleResource result = await monitoringTagRule.GetAsync(); + MonitoringTagRuleData data = new MonitoringTagRuleData(); + ArmOperation lro = await monitoringTagRule.UpdateAsync(WaitUntil.Completed, data); + MonitoringTagRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index e3a1273613077..3059f7e202b5a 100644 --- a/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/datadog/Azure.ResourceManager.Datadog/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -67,5 +67,36 @@ public async Task CreateOrUpdateMarketplaceAgreement_MarketplaceAgreementsCreate Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDatadogMonitorResources_MonitorsList() + { + // Generated from example definition: specification/datadog/resource-manager/Microsoft.Datadog/stable/2021-03-01/examples/Monitors_List.json + // this example is just showing the usage of "Monitors_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DatadogMonitorResource item in subscriptionResource.GetDatadogMonitorResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatadogMonitorResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryChangeDataCaptureCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryChangeDataCaptureCollection.cs index c0feec403b958..fb1ad8df8028d 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryChangeDataCaptureCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryChangeDataCaptureCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DataFactoryChangeDataCaptureCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ChangeDataCaptureListByFactory() + public async Task Get_ChangeDataCaptureGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ChangeDataCapture_ListByFactory.json - // this example is just showing the usage of "ChangeDataCapture_ListByFactory" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ChangeDataCapture_Get.json + // this example is just showing the usage of "ChangeDataCapture_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ChangeDataCaptureListByFactory() // get the collection of this DataFactoryChangeDataCaptureResource DataFactoryChangeDataCaptureCollection collection = dataFactory.GetDataFactoryChangeDataCaptures(); - // invoke the operation and iterate over the result - await foreach (DataFactoryChangeDataCaptureResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryChangeDataCaptureData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string changeDataCaptureName = "exampleChangeDataCapture"; + DataFactoryChangeDataCaptureResource result = await collection.GetAsync(changeDataCaptureName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryChangeDataCaptureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ChangeDataCaptureGet() + public async Task GetAll_ChangeDataCaptureListByFactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ChangeDataCapture_Get.json - // this example is just showing the usage of "ChangeDataCapture_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ChangeDataCapture_ListByFactory.json + // this example is just showing the usage of "ChangeDataCapture_ListByFactory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_ChangeDataCaptureGet() // get the collection of this DataFactoryChangeDataCaptureResource DataFactoryChangeDataCaptureCollection collection = dataFactory.GetDataFactoryChangeDataCaptures(); - // invoke the operation - string changeDataCaptureName = "exampleChangeDataCapture"; - DataFactoryChangeDataCaptureResource result = await collection.GetAsync(changeDataCaptureName); + // invoke the operation and iterate over the result + await foreach (DataFactoryChangeDataCaptureResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryChangeDataCaptureData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryChangeDataCaptureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryCollection.cs index 0b336c45bac75..f326d80658cac 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FactoriesListByResourceGroup() + public async Task CreateOrUpdate_FactoriesCreateOrUpdate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_ListByResourceGroup.json - // this example is just showing the usage of "Factories_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_CreateOrUpdate.json + // this example is just showing the usage of "Factories_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,25 @@ public async Task GetAll_FactoriesListByResourceGroup() // get the collection of this DataFactoryResource DataFactoryCollection collection = resourceGroupResource.GetDataFactories(); - // invoke the operation and iterate over the result - await foreach (DataFactoryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string factoryName = "exampleFactoryName"; + DataFactoryData data = new DataFactoryData(new AzureLocation("East US")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, factoryName, data); + DataFactoryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FactoriesCreateOrUpdate() + public async Task Get_FactoriesGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_CreateOrUpdate.json - // this example is just showing the usage of "Factories_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_Get.json + // this example is just showing the usage of "Factories_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,9 +75,7 @@ public async Task CreateOrUpdate_FactoriesCreateOrUpdate() // invoke the operation string factoryName = "exampleFactoryName"; - DataFactoryData data = new DataFactoryData(new AzureLocation("East US")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, factoryName, data); - DataFactoryResource result = lro.Value; + DataFactoryResource result = await collection.GetAsync(factoryName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +86,10 @@ public async Task CreateOrUpdate_FactoriesCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FactoriesGet() + public async Task GetAll_FactoriesListByResourceGroup() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_Get.json - // this example is just showing the usage of "Factories_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_ListByResourceGroup.json + // this example is just showing the usage of "Factories_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,15 +106,17 @@ public async Task Get_FactoriesGet() // get the collection of this DataFactoryResource DataFactoryCollection collection = resourceGroupResource.GetDataFactories(); - // invoke the operation - string factoryName = "exampleFactoryName"; - DataFactoryResource result = await collection.GetAsync(factoryName); + // invoke the operation and iterate over the result + await foreach (DataFactoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDataFlowCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDataFlowCollection.cs index 1cfe4d36c3bf4..7b58fdcba6b8e 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDataFlowCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDataFlowCollection.cs @@ -41,32 +41,23 @@ public async Task CreateOrUpdate_DataFlowsCreate() // invoke the operation string dataFlowName = "exampleDataFlow"; - DataFactoryDataFlowData data = new DataFactoryDataFlowData(new DataFactoryMappingDataFlowProperties() + DataFactoryDataFlowData data = new DataFactoryDataFlowData(new DataFactoryMappingDataFlowProperties { - Sources = + Sources = {new DataFlowSource("USDCurrency") { -new DataFlowSource("USDCurrency") +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CurrencyDatasetUSD"), +}, new DataFlowSource("CADSource") { -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CurrencyDatasetUSD"), -},new DataFlowSource("CADSource") +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CurrencyDatasetCAD"), +}}, + Sinks = {new DataFlowSink("USDSink") { -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CurrencyDatasetCAD"), -} -}, - Sinks = -{ -new DataFlowSink("USDSink") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"USDOutput"), -},new DataFlowSink("CADSink") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CADOutput"), -} -}, - ScriptLines = +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "USDOutput"), +}, new DataFlowSink("CADSink") { -"source(output(","PreviousConversionRate as double,","Country as string,","DateTime1 as string,","CurrentConversionRate as double","),","allowSchemaDrift: false,","validateSchema: false) ~> USDCurrency","source(output(","PreviousConversionRate as double,","Country as string,","DateTime1 as string,","CurrentConversionRate as double","),","allowSchemaDrift: true,","validateSchema: false) ~> CADSource","USDCurrency, CADSource union(byName: true)~> Union","Union derive(NewCurrencyRate = round(CurrentConversionRate*1.25)) ~> NewCurrencyColumn","NewCurrencyColumn split(Country == 'USD',","Country == 'CAD',disjoint: false) ~> ConditionalSplit1@(USD, CAD)","ConditionalSplit1@USD sink(saveMode:'overwrite' ) ~> USDSink","ConditionalSplit1@CAD sink(saveMode:'overwrite' ) ~> CADSink" -}, +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CADOutput"), +}}, + ScriptLines = { "source(output(", "PreviousConversionRate as double,", "Country as string,", "DateTime1 as string,", "CurrentConversionRate as double", "),", "allowSchemaDrift: false,", "validateSchema: false) ~> USDCurrency", "source(output(", "PreviousConversionRate as double,", "Country as string,", "DateTime1 as string,", "CurrentConversionRate as double", "),", "allowSchemaDrift: true,", "validateSchema: false) ~> CADSource", "USDCurrency, CADSource union(byName: true)~> Union", "Union derive(NewCurrencyRate = round(CurrentConversionRate*1.25)) ~> NewCurrencyColumn", "NewCurrencyColumn split(Country == 'USD',", "Country == 'CAD',disjoint: false) ~> ConditionalSplit1@(USD, CAD)", "ConditionalSplit1@USD sink(saveMode:'overwrite' ) ~> USDSink", "ConditionalSplit1@CAD sink(saveMode:'overwrite' ) ~> CADSink" }, Description = "Sample demo data flow to convert currencies showing usage of union, derive and conditional split transformation.", }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataFlowName, data); @@ -104,32 +95,23 @@ public async Task CreateOrUpdate_DataFlowsUpdate() // invoke the operation string dataFlowName = "exampleDataFlow"; - DataFactoryDataFlowData data = new DataFactoryDataFlowData(new DataFactoryMappingDataFlowProperties() + DataFactoryDataFlowData data = new DataFactoryDataFlowData(new DataFactoryMappingDataFlowProperties { - Sources = -{ -new DataFlowSource("USDCurrency") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CurrencyDatasetUSD"), -},new DataFlowSource("CADSource") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CurrencyDatasetCAD"), -} -}, - Sinks = + Sources = {new DataFlowSource("USDCurrency") { -new DataFlowSink("USDSink") +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CurrencyDatasetUSD"), +}, new DataFlowSource("CADSource") { -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"USDOutput"), -},new DataFlowSink("CADSink") +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CurrencyDatasetCAD"), +}}, + Sinks = {new DataFlowSink("USDSink") { -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CADOutput"), -} -}, - ScriptLines = +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "USDOutput"), +}, new DataFlowSink("CADSink") { -"source(output(","PreviousConversionRate as double,","Country as string,","DateTime1 as string,","CurrentConversionRate as double","),","allowSchemaDrift: false,","validateSchema: false) ~> USDCurrency","source(output(","PreviousConversionRate as double,","Country as string,","DateTime1 as string,","CurrentConversionRate as double","),","allowSchemaDrift: true,","validateSchema: false) ~> CADSource","USDCurrency, CADSource union(byName: true)~> Union","Union derive(NewCurrencyRate = round(CurrentConversionRate*1.25)) ~> NewCurrencyColumn","NewCurrencyColumn split(Country == 'USD',","Country == 'CAD',disjoint: false) ~> ConditionalSplit1@(USD, CAD)","ConditionalSplit1@USD sink(saveMode:'overwrite' ) ~> USDSink","ConditionalSplit1@CAD sink(saveMode:'overwrite' ) ~> CADSink" -}, +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CADOutput"), +}}, + ScriptLines = { "source(output(", "PreviousConversionRate as double,", "Country as string,", "DateTime1 as string,", "CurrentConversionRate as double", "),", "allowSchemaDrift: false,", "validateSchema: false) ~> USDCurrency", "source(output(", "PreviousConversionRate as double,", "Country as string,", "DateTime1 as string,", "CurrentConversionRate as double", "),", "allowSchemaDrift: true,", "validateSchema: false) ~> CADSource", "USDCurrency, CADSource union(byName: true)~> Union", "Union derive(NewCurrencyRate = round(CurrentConversionRate*1.25)) ~> NewCurrencyColumn", "NewCurrencyColumn split(Country == 'USD',", "Country == 'CAD',disjoint: false) ~> ConditionalSplit1@(USD, CAD)", "ConditionalSplit1@USD sink(saveMode:'overwrite' ) ~> USDSink", "ConditionalSplit1@CAD sink(saveMode:'overwrite' ) ~> CADSink" }, Description = "Sample demo data flow to convert currencies showing usage of union, derive and conditional split transformation.", }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataFlowName, data); @@ -178,10 +160,10 @@ public async Task Get_DataFlowsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DataFlowsGet() + public async Task GetAll_DataFlowsListByFactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Get.json - // this example is just showing the usage of "DataFlows_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_ListByFactory.json + // this example is just showing the usage of "DataFlows_ListByFactory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,16 +181,22 @@ public async Task Exists_DataFlowsGet() // get the collection of this DataFactoryDataFlowResource DataFactoryDataFlowCollection collection = dataFactory.GetDataFactoryDataFlows(); - // invoke the operation - string dataFlowName = "exampleDataFlow"; - bool result = await collection.ExistsAsync(dataFlowName); + // invoke the operation and iterate over the result + await foreach (DataFactoryDataFlowResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryDataFlowData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DataFlowsGet() + public async Task Exists_DataFlowsGet() { // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Get.json // this example is just showing the usage of "DataFlows_Get" operation, for the dependent resources, they will have to be created separately. @@ -231,29 +219,17 @@ public async Task GetIfExists_DataFlowsGet() // invoke the operation string dataFlowName = "exampleDataFlow"; - NullableResponse response = await collection.GetIfExistsAsync(dataFlowName); - DataFactoryDataFlowResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataFlowName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryDataFlowData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DataFlowsListByFactory() + public async Task GetIfExists_DataFlowsGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_ListByFactory.json - // this example is just showing the usage of "DataFlows_ListByFactory" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Get.json + // this example is just showing the usage of "DataFlows_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -271,17 +247,23 @@ public async Task GetAll_DataFlowsListByFactory() // get the collection of this DataFactoryDataFlowResource DataFactoryDataFlowCollection collection = dataFactory.GetDataFactoryDataFlows(); - // invoke the operation and iterate over the result - await foreach (DataFactoryDataFlowResource item in collection.GetAllAsync()) + // invoke the operation + string dataFlowName = "exampleDataFlow"; + NullableResponse response = await collection.GetIfExistsAsync(dataFlowName); + DataFactoryDataFlowResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataFactoryDataFlowData resourceData = item.Data; + DataFactoryDataFlowData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDataFlowResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDataFlowResource.cs index c7c1024630e53..36e35d2668eaf 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDataFlowResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDataFlowResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryDataFlowResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DataFlowsCreate() + public async Task Get_DataFlowsGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Create.json - // this example is just showing the usage of "DataFlows_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Get.json + // this example is just showing the usage of "DataFlows_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,36 +38,7 @@ public async Task Update_DataFlowsCreate() DataFactoryDataFlowResource dataFactoryDataFlow = client.GetDataFactoryDataFlowResource(dataFactoryDataFlowResourceId); // invoke the operation - DataFactoryDataFlowData data = new DataFactoryDataFlowData(new DataFactoryMappingDataFlowProperties() - { - Sources = -{ -new DataFlowSource("USDCurrency") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CurrencyDatasetUSD"), -},new DataFlowSource("CADSource") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CurrencyDatasetCAD"), -} -}, - Sinks = -{ -new DataFlowSink("USDSink") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"USDOutput"), -},new DataFlowSink("CADSink") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CADOutput"), -} -}, - ScriptLines = -{ -"source(output(","PreviousConversionRate as double,","Country as string,","DateTime1 as string,","CurrentConversionRate as double","),","allowSchemaDrift: false,","validateSchema: false) ~> USDCurrency","source(output(","PreviousConversionRate as double,","Country as string,","DateTime1 as string,","CurrentConversionRate as double","),","allowSchemaDrift: true,","validateSchema: false) ~> CADSource","USDCurrency, CADSource union(byName: true)~> Union","Union derive(NewCurrencyRate = round(CurrentConversionRate*1.25)) ~> NewCurrencyColumn","NewCurrencyColumn split(Country == 'USD',","Country == 'CAD',disjoint: false) ~> ConditionalSplit1@(USD, CAD)","ConditionalSplit1@USD sink(saveMode:'overwrite' ) ~> USDSink","ConditionalSplit1@CAD sink(saveMode:'overwrite' ) ~> CADSink" -}, - Description = "Sample demo data flow to convert currencies showing usage of union, derive and conditional split transformation.", - }); - ArmOperation lro = await dataFactoryDataFlow.UpdateAsync(WaitUntil.Completed, data); - DataFactoryDataFlowResource result = lro.Value; + DataFactoryDataFlowResource result = await dataFactoryDataFlow.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -78,10 +49,10 @@ public async Task Update_DataFlowsCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DataFlowsUpdate() + public async Task Delete_DataFlowsDelete() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Update.json - // this example is just showing the usage of "DataFlows_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Delete.json + // this example is just showing the usage of "DataFlows_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,50 +69,17 @@ public async Task Update_DataFlowsUpdate() DataFactoryDataFlowResource dataFactoryDataFlow = client.GetDataFactoryDataFlowResource(dataFactoryDataFlowResourceId); // invoke the operation - DataFactoryDataFlowData data = new DataFactoryDataFlowData(new DataFactoryMappingDataFlowProperties() - { - Sources = -{ -new DataFlowSource("USDCurrency") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CurrencyDatasetUSD"), -},new DataFlowSource("CADSource") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CurrencyDatasetCAD"), -} -}, - Sinks = -{ -new DataFlowSink("USDSink") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"USDOutput"), -},new DataFlowSink("CADSink") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"CADOutput"), -} -}, - ScriptLines = -{ -"source(output(","PreviousConversionRate as double,","Country as string,","DateTime1 as string,","CurrentConversionRate as double","),","allowSchemaDrift: false,","validateSchema: false) ~> USDCurrency","source(output(","PreviousConversionRate as double,","Country as string,","DateTime1 as string,","CurrentConversionRate as double","),","allowSchemaDrift: true,","validateSchema: false) ~> CADSource","USDCurrency, CADSource union(byName: true)~> Union","Union derive(NewCurrencyRate = round(CurrentConversionRate*1.25)) ~> NewCurrencyColumn","NewCurrencyColumn split(Country == 'USD',","Country == 'CAD',disjoint: false) ~> ConditionalSplit1@(USD, CAD)","ConditionalSplit1@USD sink(saveMode:'overwrite' ) ~> USDSink","ConditionalSplit1@CAD sink(saveMode:'overwrite' ) ~> CADSink" -}, - Description = "Sample demo data flow to convert currencies showing usage of union, derive and conditional split transformation.", - }); - ArmOperation lro = await dataFactoryDataFlow.UpdateAsync(WaitUntil.Completed, data); - DataFactoryDataFlowResource result = lro.Value; + await dataFactoryDataFlow.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryDataFlowData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataFlowsGet() + public async Task Update_DataFlowsCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Get.json - // this example is just showing the usage of "DataFlows_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Create.json + // this example is just showing the usage of "DataFlows_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -158,7 +96,27 @@ public async Task Get_DataFlowsGet() DataFactoryDataFlowResource dataFactoryDataFlow = client.GetDataFactoryDataFlowResource(dataFactoryDataFlowResourceId); // invoke the operation - DataFactoryDataFlowResource result = await dataFactoryDataFlow.GetAsync(); + DataFactoryDataFlowData data = new DataFactoryDataFlowData(new DataFactoryMappingDataFlowProperties + { + Sources = {new DataFlowSource("USDCurrency") +{ +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CurrencyDatasetUSD"), +}, new DataFlowSource("CADSource") +{ +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CurrencyDatasetCAD"), +}}, + Sinks = {new DataFlowSink("USDSink") +{ +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "USDOutput"), +}, new DataFlowSink("CADSink") +{ +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CADOutput"), +}}, + ScriptLines = { "source(output(", "PreviousConversionRate as double,", "Country as string,", "DateTime1 as string,", "CurrentConversionRate as double", "),", "allowSchemaDrift: false,", "validateSchema: false) ~> USDCurrency", "source(output(", "PreviousConversionRate as double,", "Country as string,", "DateTime1 as string,", "CurrentConversionRate as double", "),", "allowSchemaDrift: true,", "validateSchema: false) ~> CADSource", "USDCurrency, CADSource union(byName: true)~> Union", "Union derive(NewCurrencyRate = round(CurrentConversionRate*1.25)) ~> NewCurrencyColumn", "NewCurrencyColumn split(Country == 'USD',", "Country == 'CAD',disjoint: false) ~> ConditionalSplit1@(USD, CAD)", "ConditionalSplit1@USD sink(saveMode:'overwrite' ) ~> USDSink", "ConditionalSplit1@CAD sink(saveMode:'overwrite' ) ~> CADSink" }, + Description = "Sample demo data flow to convert currencies showing usage of union, derive and conditional split transformation.", + }); + ArmOperation lro = await dataFactoryDataFlow.UpdateAsync(WaitUntil.Completed, data); + DataFactoryDataFlowResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -169,10 +127,10 @@ public async Task Get_DataFlowsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DataFlowsDelete() + public async Task Update_DataFlowsUpdate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Delete.json - // this example is just showing the usage of "DataFlows_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DataFlows_Update.json + // this example is just showing the usage of "DataFlows_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,9 +147,33 @@ public async Task Delete_DataFlowsDelete() DataFactoryDataFlowResource dataFactoryDataFlow = client.GetDataFactoryDataFlowResource(dataFactoryDataFlowResourceId); // invoke the operation - await dataFactoryDataFlow.DeleteAsync(WaitUntil.Completed); + DataFactoryDataFlowData data = new DataFactoryDataFlowData(new DataFactoryMappingDataFlowProperties + { + Sources = {new DataFlowSource("USDCurrency") +{ +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CurrencyDatasetUSD"), +}, new DataFlowSource("CADSource") +{ +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CurrencyDatasetCAD"), +}}, + Sinks = {new DataFlowSink("USDSink") +{ +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "USDOutput"), +}, new DataFlowSink("CADSink") +{ +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "CADOutput"), +}}, + ScriptLines = { "source(output(", "PreviousConversionRate as double,", "Country as string,", "DateTime1 as string,", "CurrentConversionRate as double", "),", "allowSchemaDrift: false,", "validateSchema: false) ~> USDCurrency", "source(output(", "PreviousConversionRate as double,", "Country as string,", "DateTime1 as string,", "CurrentConversionRate as double", "),", "allowSchemaDrift: true,", "validateSchema: false) ~> CADSource", "USDCurrency, CADSource union(byName: true)~> Union", "Union derive(NewCurrencyRate = round(CurrentConversionRate*1.25)) ~> NewCurrencyColumn", "NewCurrencyColumn split(Country == 'USD',", "Country == 'CAD',disjoint: false) ~> ConditionalSplit1@(USD, CAD)", "ConditionalSplit1@USD sink(saveMode:'overwrite' ) ~> USDSink", "ConditionalSplit1@CAD sink(saveMode:'overwrite' ) ~> CADSink" }, + Description = "Sample demo data flow to convert currencies showing usage of union, derive and conditional split transformation.", + }); + ArmOperation lro = await dataFactoryDataFlow.UpdateAsync(WaitUntil.Completed, data); + DataFactoryDataFlowResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryDataFlowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetCollection.cs index 98fb40f720cc5..0f118940619a6 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetCollection.cs @@ -17,42 +17,6 @@ namespace Azure.ResourceManager.DataFactory.Samples { public partial class Sample_DataFactoryDatasetCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_DatasetsListByFactory() - { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_ListByFactory.json - // this example is just showing the usage of "Datasets_ListByFactory" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataFactoryResource created on azure - // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource - string subscriptionId = "12345678-1234-1234-1234-12345678abc"; - string resourceGroupName = "exampleResourceGroup"; - string factoryName = "exampleFactoryName"; - ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); - DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); - - // get the collection of this DataFactoryDatasetResource - DataFactoryDatasetCollection collection = dataFactory.GetDataFactoryDatasets(); - - // invoke the operation and iterate over the result - await foreach (DataFactoryDatasetResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryDatasetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_DatasetsCreate() @@ -78,15 +42,15 @@ public async Task CreateOrUpdate_DatasetsCreate() // invoke the operation string datasetName = "exampleDataset"; - DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference("LinkedServiceReference", "exampleLinkedService")) + DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference(default, "exampleLinkedService")) { - FolderPath = DataFactoryElement.FromExpression("@dataset().MyFolderPath"), - FileName = DataFactoryElement.FromExpression("@dataset().MyFileName"), + FolderPath = null, + FileName = null, Format = new DatasetTextFormat(), Parameters = { ["MyFileName"] = new EntityParameterSpecification(EntityParameterType.String), -["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String), +["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String) }, }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, datasetName, data); @@ -124,16 +88,16 @@ public async Task CreateOrUpdate_DatasetsUpdate() // invoke the operation string datasetName = "exampleDataset"; - DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference("LinkedServiceReference", "exampleLinkedService")) + DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference(default, "exampleLinkedService")) { - FolderPath = DataFactoryElement.FromExpression("@dataset().MyFolderPath"), - FileName = DataFactoryElement.FromExpression("@dataset().MyFileName"), + FolderPath = null, + FileName = null, Format = new DatasetTextFormat(), Description = "Example description", Parameters = { ["MyFileName"] = new EntityParameterSpecification(EntityParameterType.String), -["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String), +["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String) }, }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, datasetName, data); @@ -180,6 +144,42 @@ public async Task Get_DatasetsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_DatasetsListByFactory() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_ListByFactory.json + // this example is just showing the usage of "Datasets_ListByFactory" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryDatasetResource + DataFactoryDatasetCollection collection = dataFactory.GetDataFactoryDatasets(); + + // invoke the operation and iterate over the result + await foreach (DataFactoryDatasetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryDatasetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_DatasetsGet() diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetResource.cs index acd14fcfd9579..705b4a2bc43db 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryDatasetResource.cs @@ -19,10 +19,10 @@ public partial class Sample_DataFactoryDatasetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DatasetsCreate() + public async Task Get_DatasetsGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Create.json - // this example is just showing the usage of "Datasets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Get.json + // this example is just showing the usage of "Datasets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,19 +39,7 @@ public async Task Update_DatasetsCreate() DataFactoryDatasetResource dataFactoryDataset = client.GetDataFactoryDatasetResource(dataFactoryDatasetResourceId); // invoke the operation - DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference("LinkedServiceReference", "exampleLinkedService")) - { - FolderPath = DataFactoryElement.FromExpression("@dataset().MyFolderPath"), - FileName = DataFactoryElement.FromExpression("@dataset().MyFileName"), - Format = new DatasetTextFormat(), - Parameters = -{ -["MyFileName"] = new EntityParameterSpecification(EntityParameterType.String), -["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String), -}, - }); - ArmOperation lro = await dataFactoryDataset.UpdateAsync(WaitUntil.Completed, data); - DataFactoryDatasetResource result = lro.Value; + DataFactoryDatasetResource result = await dataFactoryDataset.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -62,10 +50,10 @@ public async Task Update_DatasetsCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DatasetsUpdate() + public async Task Delete_DatasetsDelete() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Update.json - // this example is just showing the usage of "Datasets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Delete.json + // this example is just showing the usage of "Datasets_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -82,34 +70,17 @@ public async Task Update_DatasetsUpdate() DataFactoryDatasetResource dataFactoryDataset = client.GetDataFactoryDatasetResource(dataFactoryDatasetResourceId); // invoke the operation - DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference("LinkedServiceReference", "exampleLinkedService")) - { - FolderPath = DataFactoryElement.FromExpression("@dataset().MyFolderPath"), - FileName = DataFactoryElement.FromExpression("@dataset().MyFileName"), - Format = new DatasetTextFormat(), - Description = "Example description", - Parameters = -{ -["MyFileName"] = new EntityParameterSpecification(EntityParameterType.String), -["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String), -}, - }); - ArmOperation lro = await dataFactoryDataset.UpdateAsync(WaitUntil.Completed, data); - DataFactoryDatasetResource result = lro.Value; + await dataFactoryDataset.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryDatasetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DatasetsGet() + public async Task Update_DatasetsCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Get.json - // this example is just showing the usage of "Datasets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Create.json + // this example is just showing the usage of "Datasets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -126,7 +97,19 @@ public async Task Get_DatasetsGet() DataFactoryDatasetResource dataFactoryDataset = client.GetDataFactoryDatasetResource(dataFactoryDatasetResourceId); // invoke the operation - DataFactoryDatasetResource result = await dataFactoryDataset.GetAsync(); + DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference(default, "exampleLinkedService")) + { + FolderPath = null, + FileName = null, + Format = new DatasetTextFormat(), + Parameters = +{ +["MyFileName"] = new EntityParameterSpecification(EntityParameterType.String), +["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String) +}, + }); + ArmOperation lro = await dataFactoryDataset.UpdateAsync(WaitUntil.Completed, data); + DataFactoryDatasetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -137,10 +120,10 @@ public async Task Get_DatasetsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DatasetsDelete() + public async Task Update_DatasetsUpdate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Delete.json - // this example is just showing the usage of "Datasets_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Datasets_Update.json + // this example is just showing the usage of "Datasets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -157,9 +140,26 @@ public async Task Delete_DatasetsDelete() DataFactoryDatasetResource dataFactoryDataset = client.GetDataFactoryDatasetResource(dataFactoryDatasetResourceId); // invoke the operation - await dataFactoryDataset.DeleteAsync(WaitUntil.Completed); + DataFactoryDatasetData data = new DataFactoryDatasetData(new AzureBlobDataset(new DataFactoryLinkedServiceReference(default, "exampleLinkedService")) + { + FolderPath = null, + FileName = null, + Format = new DatasetTextFormat(), + Description = "Example description", + Parameters = +{ +["MyFileName"] = new EntityParameterSpecification(EntityParameterType.String), +["MyFolderPath"] = new EntityParameterSpecification(EntityParameterType.String) +}, + }); + ArmOperation lro = await dataFactoryDataset.UpdateAsync(WaitUntil.Completed, data); + DataFactoryDatasetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryDatasetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryGlobalParameterCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryGlobalParameterCollection.cs index d20cd698af44f..4d37ad10ba680 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryGlobalParameterCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryGlobalParameterCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DataFactoryGlobalParameterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GlobalParametersListByFactory() + public async Task CreateOrUpdate_GlobalParametersCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_ListByFactory.json - // this example is just showing the usage of "GlobalParameters_ListByFactory" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Create.json + // this example is just showing the usage of "GlobalParameters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,28 @@ public async Task GetAll_GlobalParametersListByFactory() // get the collection of this DataFactoryGlobalParameterResource DataFactoryGlobalParameterCollection collection = dataFactory.GetDataFactoryGlobalParameters(); - // invoke the operation and iterate over the result - await foreach (DataFactoryGlobalParameterResource item in collection.GetAllAsync()) + // invoke the operation + string globalParameterName = "default"; + DataFactoryGlobalParameterData data = new DataFactoryGlobalParameterData(new Dictionary { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryGlobalParameterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ["waitTime"] = new DataFactoryGlobalParameterProperties(DataFactoryGlobalParameterType.Int, BinaryData.FromObjectAsJson("5")) + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, globalParameterName, data); + DataFactoryGlobalParameterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryGlobalParameterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GlobalParametersGet() + public async Task CreateOrUpdate_GlobalParametersUpdate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Get.json - // this example is just showing the usage of "GlobalParameters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Update.json + // this example is just showing the usage of "GlobalParameters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,7 +81,12 @@ public async Task Get_GlobalParametersGet() // invoke the operation string globalParameterName = "default"; - DataFactoryGlobalParameterResource result = await collection.GetAsync(globalParameterName); + DataFactoryGlobalParameterData data = new DataFactoryGlobalParameterData(new Dictionary + { + ["waitTime"] = new DataFactoryGlobalParameterProperties(DataFactoryGlobalParameterType.Int, BinaryData.FromObjectAsJson("5")) + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, globalParameterName, data); + DataFactoryGlobalParameterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,7 +97,7 @@ public async Task Get_GlobalParametersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GlobalParametersGet() + public async Task Get_GlobalParametersGet() { // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Get.json // this example is just showing the usage of "GlobalParameters_Get" operation, for the dependent resources, they will have to be created separately. @@ -112,17 +120,21 @@ public async Task Exists_GlobalParametersGet() // invoke the operation string globalParameterName = "default"; - bool result = await collection.ExistsAsync(globalParameterName); + DataFactoryGlobalParameterResource result = await collection.GetAsync(globalParameterName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryGlobalParameterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GlobalParametersGet() + public async Task GetAll_GlobalParametersListByFactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Get.json - // this example is just showing the usage of "GlobalParameters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_ListByFactory.json + // this example is just showing the usage of "GlobalParameters_ListByFactory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,31 +152,25 @@ public async Task GetIfExists_GlobalParametersGet() // get the collection of this DataFactoryGlobalParameterResource DataFactoryGlobalParameterCollection collection = dataFactory.GetDataFactoryGlobalParameters(); - // invoke the operation - string globalParameterName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(globalParameterName); - DataFactoryGlobalParameterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataFactoryGlobalParameterResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataFactoryGlobalParameterData resourceData = result.Data; + DataFactoryGlobalParameterData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GlobalParametersCreate() + public async Task Exists_GlobalParametersGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Create.json - // this example is just showing the usage of "GlobalParameters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Get.json + // this example is just showing the usage of "GlobalParameters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,26 +190,17 @@ public async Task CreateOrUpdate_GlobalParametersCreate() // invoke the operation string globalParameterName = "default"; - DataFactoryGlobalParameterData data = new DataFactoryGlobalParameterData(new Dictionary() - { - ["waitTime"] = new DataFactoryGlobalParameterProperties(DataFactoryGlobalParameterType.Int, BinaryData.FromString("\"5\"")), - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, globalParameterName, data); - DataFactoryGlobalParameterResource result = lro.Value; + bool result = await collection.ExistsAsync(globalParameterName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryGlobalParameterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GlobalParametersUpdate() + public async Task GetIfExists_GlobalParametersGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Update.json - // this example is just showing the usage of "GlobalParameters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Get.json + // this example is just showing the usage of "GlobalParameters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -223,18 +220,21 @@ public async Task CreateOrUpdate_GlobalParametersUpdate() // invoke the operation string globalParameterName = "default"; - DataFactoryGlobalParameterData data = new DataFactoryGlobalParameterData(new Dictionary() - { - ["waitTime"] = new DataFactoryGlobalParameterProperties(DataFactoryGlobalParameterType.Int, BinaryData.FromString("\"5\"")), - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, globalParameterName, data); - DataFactoryGlobalParameterResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(globalParameterName); + DataFactoryGlobalParameterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryGlobalParameterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryGlobalParameterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryGlobalParameterResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryGlobalParameterResource.cs index 3bc842577dd1e..8d2d3991ce777 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryGlobalParameterResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryGlobalParameterResource.cs @@ -50,10 +50,10 @@ public async Task Get_GlobalParametersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GlobalParametersCreate() + public async Task Delete_GlobalParametersDelete() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Create.json - // this example is just showing the usage of "GlobalParameters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Delete.json + // this example is just showing the usage of "GlobalParameters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,25 +70,16 @@ public async Task Update_GlobalParametersCreate() DataFactoryGlobalParameterResource dataFactoryGlobalParameter = client.GetDataFactoryGlobalParameterResource(dataFactoryGlobalParameterResourceId); // invoke the operation - DataFactoryGlobalParameterData data = new DataFactoryGlobalParameterData(new Dictionary() - { - ["waitTime"] = new DataFactoryGlobalParameterProperties(DataFactoryGlobalParameterType.Int, BinaryData.FromString("\"5\"")), - }); - ArmOperation lro = await dataFactoryGlobalParameter.UpdateAsync(WaitUntil.Completed, data); - DataFactoryGlobalParameterResource result = lro.Value; + await dataFactoryGlobalParameter.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryGlobalParameterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GlobalParametersUpdate() + public async Task Update_GlobalParametersCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Update.json + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Create.json // this example is just showing the usage of "GlobalParameters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -106,9 +97,9 @@ public async Task Update_GlobalParametersUpdate() DataFactoryGlobalParameterResource dataFactoryGlobalParameter = client.GetDataFactoryGlobalParameterResource(dataFactoryGlobalParameterResourceId); // invoke the operation - DataFactoryGlobalParameterData data = new DataFactoryGlobalParameterData(new Dictionary() + DataFactoryGlobalParameterData data = new DataFactoryGlobalParameterData(new Dictionary { - ["waitTime"] = new DataFactoryGlobalParameterProperties(DataFactoryGlobalParameterType.Int, BinaryData.FromString("\"5\"")), + ["waitTime"] = new DataFactoryGlobalParameterProperties(DataFactoryGlobalParameterType.Int, BinaryData.FromObjectAsJson("5")) }); ArmOperation lro = await dataFactoryGlobalParameter.UpdateAsync(WaitUntil.Completed, data); DataFactoryGlobalParameterResource result = lro.Value; @@ -122,10 +113,10 @@ public async Task Update_GlobalParametersUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_GlobalParametersDelete() + public async Task Update_GlobalParametersUpdate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Delete.json - // this example is just showing the usage of "GlobalParameters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GlobalParameters_Update.json + // this example is just showing the usage of "GlobalParameters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,9 +133,18 @@ public async Task Delete_GlobalParametersDelete() DataFactoryGlobalParameterResource dataFactoryGlobalParameter = client.GetDataFactoryGlobalParameterResource(dataFactoryGlobalParameterResourceId); // invoke the operation - await dataFactoryGlobalParameter.DeleteAsync(WaitUntil.Completed); + DataFactoryGlobalParameterData data = new DataFactoryGlobalParameterData(new Dictionary + { + ["waitTime"] = new DataFactoryGlobalParameterProperties(DataFactoryGlobalParameterType.Int, BinaryData.FromObjectAsJson("5")) + }); + ArmOperation lro = await dataFactoryGlobalParameter.UpdateAsync(WaitUntil.Completed, data); + DataFactoryGlobalParameterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryGlobalParameterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryIntegrationRuntimeCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryIntegrationRuntimeCollection.cs index 14caf86439d98..266b65b7541c0 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryIntegrationRuntimeCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryIntegrationRuntimeCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryIntegrationRuntimeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_IntegrationRuntimesListByFactory() + public async Task CreateOrUpdate_IntegrationRuntimesCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/IntegrationRuntimes_ListByFactory.json - // this example is just showing the usage of "IntegrationRuntimes_ListByFactory" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/IntegrationRuntimes_Create.json + // this example is just showing the usage of "IntegrationRuntimes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_IntegrationRuntimesListByFactory() // get the collection of this DataFactoryIntegrationRuntimeResource DataFactoryIntegrationRuntimeCollection collection = dataFactory.GetDataFactoryIntegrationRuntimes(); - // invoke the operation and iterate over the result - await foreach (DataFactoryIntegrationRuntimeResource item in collection.GetAllAsync()) + // invoke the operation + string integrationRuntimeName = "exampleIntegrationRuntime"; + DataFactoryIntegrationRuntimeData data = new DataFactoryIntegrationRuntimeData(new SelfHostedIntegrationRuntime { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryIntegrationRuntimeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "A selfhosted integration runtime", + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, integrationRuntimeName, data); + DataFactoryIntegrationRuntimeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryIntegrationRuntimeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_IntegrationRuntimesCreate() + public async Task Get_IntegrationRuntimesGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/IntegrationRuntimes_Create.json - // this example is just showing the usage of "IntegrationRuntimes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/IntegrationRuntimes_Get.json + // this example is just showing the usage of "IntegrationRuntimes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,12 +80,7 @@ public async Task CreateOrUpdate_IntegrationRuntimesCreate() // invoke the operation string integrationRuntimeName = "exampleIntegrationRuntime"; - DataFactoryIntegrationRuntimeData data = new DataFactoryIntegrationRuntimeData(new SelfHostedIntegrationRuntime() - { - Description = "A selfhosted integration runtime", - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, integrationRuntimeName, data); - DataFactoryIntegrationRuntimeResource result = lro.Value; + DataFactoryIntegrationRuntimeResource result = await collection.GetAsync(integrationRuntimeName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -93,10 +91,10 @@ public async Task CreateOrUpdate_IntegrationRuntimesCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_IntegrationRuntimesGet() + public async Task GetAll_IntegrationRuntimesListByFactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/IntegrationRuntimes_Get.json - // this example is just showing the usage of "IntegrationRuntimes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/IntegrationRuntimes_ListByFactory.json + // this example is just showing the usage of "IntegrationRuntimes_ListByFactory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,15 +112,17 @@ public async Task Get_IntegrationRuntimesGet() // get the collection of this DataFactoryIntegrationRuntimeResource DataFactoryIntegrationRuntimeCollection collection = dataFactory.GetDataFactoryIntegrationRuntimes(); - // invoke the operation - string integrationRuntimeName = "exampleIntegrationRuntime"; - DataFactoryIntegrationRuntimeResource result = await collection.GetAsync(integrationRuntimeName); + // invoke the operation and iterate over the result + await foreach (DataFactoryIntegrationRuntimeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryIntegrationRuntimeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryIntegrationRuntimeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryIntegrationRuntimeResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryIntegrationRuntimeResource.cs index 876a1072bee6d..146307ed90ad3 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryIntegrationRuntimeResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryIntegrationRuntimeResource.cs @@ -50,10 +50,10 @@ public async Task Get_IntegrationRuntimesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_IntegrationRuntimesUpdate() + public async Task Delete_IntegrationRuntimesDelete() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/IntegrationRuntimes_Update.json - // this example is just showing the usage of "IntegrationRuntimes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/IntegrationRuntimes_Delete.json + // this example is just showing the usage of "IntegrationRuntimes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_IntegrationRuntimesUpdate() DataFactoryIntegrationRuntimeResource dataFactoryIntegrationRuntime = client.GetDataFactoryIntegrationRuntimeResource(dataFactoryIntegrationRuntimeResourceId); // invoke the operation - DataFactoryIntegrationRuntimePatch patch = new DataFactoryIntegrationRuntimePatch() - { - AutoUpdate = IntegrationRuntimeAutoUpdateState.Off, - UpdateDelayOffset = XmlConvert.ToTimeSpan("\"PT3H\""), - }; - DataFactoryIntegrationRuntimeResource result = await dataFactoryIntegrationRuntime.UpdateAsync(patch); + await dataFactoryIntegrationRuntime.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryIntegrationRuntimeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_IntegrationRuntimesDelete() + public async Task Update_IntegrationRuntimesUpdate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/IntegrationRuntimes_Delete.json - // this example is just showing the usage of "IntegrationRuntimes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/IntegrationRuntimes_Update.json + // this example is just showing the usage of "IntegrationRuntimes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +97,18 @@ public async Task Delete_IntegrationRuntimesDelete() DataFactoryIntegrationRuntimeResource dataFactoryIntegrationRuntime = client.GetDataFactoryIntegrationRuntimeResource(dataFactoryIntegrationRuntimeResourceId); // invoke the operation - await dataFactoryIntegrationRuntime.DeleteAsync(WaitUntil.Completed); + DataFactoryIntegrationRuntimePatch patch = new DataFactoryIntegrationRuntimePatch + { + AutoUpdate = IntegrationRuntimeAutoUpdateState.Off, + UpdateDelayOffset = XmlConvert.ToTimeSpan("\"PT3H\""), + }; + DataFactoryIntegrationRuntimeResource result = await dataFactoryIntegrationRuntime.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryIntegrationRuntimeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -217,7 +217,7 @@ public async Task RegenerateAuthKey_IntegrationRuntimesRegenerateAuthKey() DataFactoryIntegrationRuntimeResource dataFactoryIntegrationRuntime = client.GetDataFactoryIntegrationRuntimeResource(dataFactoryIntegrationRuntimeResourceId); // invoke the operation - IntegrationRuntimeRegenerateKeyContent content = new IntegrationRuntimeRegenerateKeyContent() + IntegrationRuntimeRegenerateKeyContent content = new IntegrationRuntimeRegenerateKeyContent { KeyName = IntegrationRuntimeAuthKeyName.AuthKey2, }; @@ -439,7 +439,7 @@ public async Task CreateLinkedIntegrationRuntime_IntegrationRuntimesCreateLinked DataFactoryIntegrationRuntimeResource dataFactoryIntegrationRuntime = client.GetDataFactoryIntegrationRuntimeResource(dataFactoryIntegrationRuntimeResourceId); // invoke the operation - CreateLinkedIntegrationRuntimeContent content = new CreateLinkedIntegrationRuntimeContent() + CreateLinkedIntegrationRuntimeContent content = new CreateLinkedIntegrationRuntimeContent { Name = "bfa92911-9fb6-4fbe-8f23-beae87bc1c83", SubscriptionId = "061774c7-4b5a-4159-a55b-365581830283", @@ -501,7 +501,7 @@ public async Task GetAllIntegrationRuntimeObjectMetadata_IntegrationRuntimeObjec DataFactoryIntegrationRuntimeResource dataFactoryIntegrationRuntime = client.GetDataFactoryIntegrationRuntimeResource(dataFactoryIntegrationRuntimeResourceId); // invoke the operation and iterate over the result - GetSsisObjectMetadataContent content = new GetSsisObjectMetadataContent() + GetSsisObjectMetadataContent content = new GetSsisObjectMetadataContent { MetadataPath = "ssisFolders", }; @@ -592,7 +592,7 @@ public async Task UpdateIntegrationRuntimeNode_IntegrationRuntimeNodesUpdate() // invoke the operation string nodeName = "Node_1"; - UpdateIntegrationRuntimeNodeContent content = new UpdateIntegrationRuntimeNodeContent() + UpdateIntegrationRuntimeNodeContent content = new UpdateIntegrationRuntimeNodeContent { ConcurrentJobsLimit = 2, }; diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceCollection.cs index 8f038b48905cc..ba43425625b11 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DataFactoryLinkedServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LinkedServicesListByFactory() + public async Task CreateOrUpdate_LinkedServicesCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_ListByFactory.json - // this example is just showing the usage of "LinkedServices_ListByFactory" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Create.json + // this example is just showing the usage of "LinkedServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,24 +40,27 @@ public async Task GetAll_LinkedServicesListByFactory() // get the collection of this DataFactoryLinkedServiceResource DataFactoryLinkedServiceCollection collection = dataFactory.GetDataFactoryLinkedServices(); - // invoke the operation and iterate over the result - await foreach (DataFactoryLinkedServiceResource item in collection.GetAllAsync()) + // invoke the operation + string linkedServiceName = "exampleLinkedService"; + DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryLinkedServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionString = null, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkedServiceName, data); + DataFactoryLinkedServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryLinkedServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LinkedServicesCreate() + public async Task CreateOrUpdate_LinkedServicesUpdate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Create.json + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Update.json // this example is just showing the usage of "LinkedServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -78,9 +81,10 @@ public async Task CreateOrUpdate_LinkedServicesCreate() // invoke the operation string linkedServiceName = "exampleLinkedService"; - DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService() + DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService { - ConnectionString = DataFactoryElement.FromSecretString("DefaultEndpointsProtocol=https;AccountName=examplestorageaccount;AccountKey="), + ConnectionString = null, + Description = "Example description", }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkedServiceName, data); DataFactoryLinkedServiceResource result = lro.Value; @@ -94,10 +98,10 @@ public async Task CreateOrUpdate_LinkedServicesCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LinkedServicesUpdate() + public async Task Get_LinkedServicesGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Update.json - // this example is just showing the usage of "LinkedServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Get.json + // this example is just showing the usage of "LinkedServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,13 +121,7 @@ public async Task CreateOrUpdate_LinkedServicesUpdate() // invoke the operation string linkedServiceName = "exampleLinkedService"; - DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService() - { - ConnectionString = DataFactoryElement.FromSecretString("DefaultEndpointsProtocol=https;AccountName=examplestorageaccount;AccountKey="), - Description = "Example description", - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, linkedServiceName, data); - DataFactoryLinkedServiceResource result = lro.Value; + DataFactoryLinkedServiceResource result = await collection.GetAsync(linkedServiceName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -134,10 +132,10 @@ public async Task CreateOrUpdate_LinkedServicesUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LinkedServicesGet() + public async Task GetAll_LinkedServicesListByFactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Get.json - // this example is just showing the usage of "LinkedServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_ListByFactory.json + // this example is just showing the usage of "LinkedServices_ListByFactory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -155,15 +153,17 @@ public async Task Get_LinkedServicesGet() // get the collection of this DataFactoryLinkedServiceResource DataFactoryLinkedServiceCollection collection = dataFactory.GetDataFactoryLinkedServices(); - // invoke the operation - string linkedServiceName = "exampleLinkedService"; - DataFactoryLinkedServiceResource result = await collection.GetAsync(linkedServiceName); + // invoke the operation and iterate over the result + await foreach (DataFactoryLinkedServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryLinkedServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryLinkedServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceResource.cs index bb1fec5955df3..8be30c827d754 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryLinkedServiceResource.cs @@ -19,10 +19,10 @@ public partial class Sample_DataFactoryLinkedServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_LinkedServicesCreate() + public async Task Get_LinkedServicesGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Create.json - // this example is just showing the usage of "LinkedServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Get.json + // this example is just showing the usage of "LinkedServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,12 +39,7 @@ public async Task Update_LinkedServicesCreate() DataFactoryLinkedServiceResource dataFactoryLinkedService = client.GetDataFactoryLinkedServiceResource(dataFactoryLinkedServiceResourceId); // invoke the operation - DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService() - { - ConnectionString = DataFactoryElement.FromSecretString("DefaultEndpointsProtocol=https;AccountName=examplestorageaccount;AccountKey="), - }); - ArmOperation lro = await dataFactoryLinkedService.UpdateAsync(WaitUntil.Completed, data); - DataFactoryLinkedServiceResource result = lro.Value; + DataFactoryLinkedServiceResource result = await dataFactoryLinkedService.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +50,10 @@ public async Task Update_LinkedServicesCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_LinkedServicesUpdate() + public async Task Delete_LinkedServicesDelete() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Update.json - // this example is just showing the usage of "LinkedServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Delete.json + // this example is just showing the usage of "LinkedServices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,27 +70,17 @@ public async Task Update_LinkedServicesUpdate() DataFactoryLinkedServiceResource dataFactoryLinkedService = client.GetDataFactoryLinkedServiceResource(dataFactoryLinkedServiceResourceId); // invoke the operation - DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService() - { - ConnectionString = DataFactoryElement.FromSecretString("DefaultEndpointsProtocol=https;AccountName=examplestorageaccount;AccountKey="), - Description = "Example description", - }); - ArmOperation lro = await dataFactoryLinkedService.UpdateAsync(WaitUntil.Completed, data); - DataFactoryLinkedServiceResource result = lro.Value; + await dataFactoryLinkedService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryLinkedServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LinkedServicesGet() + public async Task Update_LinkedServicesCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Get.json - // this example is just showing the usage of "LinkedServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Create.json + // this example is just showing the usage of "LinkedServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,7 +97,12 @@ public async Task Get_LinkedServicesGet() DataFactoryLinkedServiceResource dataFactoryLinkedService = client.GetDataFactoryLinkedServiceResource(dataFactoryLinkedServiceResourceId); // invoke the operation - DataFactoryLinkedServiceResource result = await dataFactoryLinkedService.GetAsync(); + DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService + { + ConnectionString = null, + }); + ArmOperation lro = await dataFactoryLinkedService.UpdateAsync(WaitUntil.Completed, data); + DataFactoryLinkedServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -123,10 +113,10 @@ public async Task Get_LinkedServicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_LinkedServicesDelete() + public async Task Update_LinkedServicesUpdate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Delete.json - // this example is just showing the usage of "LinkedServices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/LinkedServices_Update.json + // this example is just showing the usage of "LinkedServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,9 +133,19 @@ public async Task Delete_LinkedServicesDelete() DataFactoryLinkedServiceResource dataFactoryLinkedService = client.GetDataFactoryLinkedServiceResource(dataFactoryLinkedServiceResourceId); // invoke the operation - await dataFactoryLinkedService.DeleteAsync(WaitUntil.Completed); + DataFactoryLinkedServiceData data = new DataFactoryLinkedServiceData(new AzureStorageLinkedService + { + ConnectionString = null, + Description = "Example description", + }); + ArmOperation lro = await dataFactoryLinkedService.UpdateAsync(WaitUntil.Completed, data); + DataFactoryLinkedServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryLinkedServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedVirtualNetworkCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedVirtualNetworkCollection.cs index ea3b0d3c7f7d4..5313ec47c41f2 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedVirtualNetworkCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedVirtualNetworkCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryManagedVirtualNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ManagedVirtualNetworksListByFactory() + public async Task CreateOrUpdate_ManagedVirtualNetworksCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedVirtualNetworks_ListByFactory.json - // this example is just showing the usage of "ManagedVirtualNetworks_ListByFactory" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedVirtualNetworks_Create.json + // this example is just showing the usage of "ManagedVirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,25 @@ public async Task GetAll_ManagedVirtualNetworksListByFactory() // get the collection of this DataFactoryManagedVirtualNetworkResource DataFactoryManagedVirtualNetworkCollection collection = dataFactory.GetDataFactoryManagedVirtualNetworks(); - // invoke the operation and iterate over the result - await foreach (DataFactoryManagedVirtualNetworkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryManagedVirtualNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string managedVirtualNetworkName = "exampleManagedVirtualNetworkName"; + DataFactoryManagedVirtualNetworkData data = new DataFactoryManagedVirtualNetworkData(new DataFactoryManagedVirtualNetworkProperties()); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedVirtualNetworkName, data); + DataFactoryManagedVirtualNetworkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryManagedVirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ManagedVirtualNetworksCreate() + public async Task Get_ManagedVirtualNetworksGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedVirtualNetworks_Create.json - // this example is just showing the usage of "ManagedVirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedVirtualNetworks_Get.json + // this example is just showing the usage of "ManagedVirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,9 +77,7 @@ public async Task CreateOrUpdate_ManagedVirtualNetworksCreate() // invoke the operation string managedVirtualNetworkName = "exampleManagedVirtualNetworkName"; - DataFactoryManagedVirtualNetworkData data = new DataFactoryManagedVirtualNetworkData(new DataFactoryManagedVirtualNetworkProperties()); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedVirtualNetworkName, data); - DataFactoryManagedVirtualNetworkResource result = lro.Value; + DataFactoryManagedVirtualNetworkResource result = await collection.GetAsync(managedVirtualNetworkName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,10 +88,10 @@ public async Task CreateOrUpdate_ManagedVirtualNetworksCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ManagedVirtualNetworksGet() + public async Task GetAll_ManagedVirtualNetworksListByFactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedVirtualNetworks_Get.json - // this example is just showing the usage of "ManagedVirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedVirtualNetworks_ListByFactory.json + // this example is just showing the usage of "ManagedVirtualNetworks_ListByFactory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,15 +109,17 @@ public async Task Get_ManagedVirtualNetworksGet() // get the collection of this DataFactoryManagedVirtualNetworkResource DataFactoryManagedVirtualNetworkCollection collection = dataFactory.GetDataFactoryManagedVirtualNetworks(); - // invoke the operation - string managedVirtualNetworkName = "exampleManagedVirtualNetworkName"; - DataFactoryManagedVirtualNetworkResource result = await collection.GetAsync(managedVirtualNetworkName); + // invoke the operation and iterate over the result + await foreach (DataFactoryManagedVirtualNetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryManagedVirtualNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryManagedVirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedVirtualNetworkResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedVirtualNetworkResource.cs index d4709a60e9cc2..ce830d74dcf66 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedVirtualNetworkResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryManagedVirtualNetworkResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryManagedVirtualNetworkResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ManagedVirtualNetworksCreate() + public async Task Get_ManagedVirtualNetworksGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedVirtualNetworks_Create.json - // this example is just showing the usage of "ManagedVirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedVirtualNetworks_Get.json + // this example is just showing the usage of "ManagedVirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Update_ManagedVirtualNetworksCreate() DataFactoryManagedVirtualNetworkResource dataFactoryManagedVirtualNetwork = client.GetDataFactoryManagedVirtualNetworkResource(dataFactoryManagedVirtualNetworkResourceId); // invoke the operation - DataFactoryManagedVirtualNetworkData data = new DataFactoryManagedVirtualNetworkData(new DataFactoryManagedVirtualNetworkProperties()); - ArmOperation lro = await dataFactoryManagedVirtualNetwork.UpdateAsync(WaitUntil.Completed, data); - DataFactoryManagedVirtualNetworkResource result = lro.Value; + DataFactoryManagedVirtualNetworkResource result = await dataFactoryManagedVirtualNetwork.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +49,10 @@ public async Task Update_ManagedVirtualNetworksCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ManagedVirtualNetworksGet() + public async Task Update_ManagedVirtualNetworksCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedVirtualNetworks_Get.json - // this example is just showing the usage of "ManagedVirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedVirtualNetworks_Create.json + // this example is just showing the usage of "ManagedVirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,7 +69,9 @@ public async Task Get_ManagedVirtualNetworksGet() DataFactoryManagedVirtualNetworkResource dataFactoryManagedVirtualNetwork = client.GetDataFactoryManagedVirtualNetworkResource(dataFactoryManagedVirtualNetworkResourceId); // invoke the operation - DataFactoryManagedVirtualNetworkResource result = await dataFactoryManagedVirtualNetwork.GetAsync(); + DataFactoryManagedVirtualNetworkData data = new DataFactoryManagedVirtualNetworkData(new DataFactoryManagedVirtualNetworkProperties()); + ArmOperation lro = await dataFactoryManagedVirtualNetwork.UpdateAsync(WaitUntil.Completed, data); + DataFactoryManagedVirtualNetworkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineCollection.cs index 1b8643f023c3d..3e30a18f0e3cb 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineCollection.cs @@ -6,9 +6,9 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; +using Azure.Core.Expressions.DataFactory; using Azure.Identity; using Azure.ResourceManager.DataFactory.Models; using NUnit.Framework; @@ -17,42 +17,6 @@ namespace Azure.ResourceManager.DataFactory.Samples { public partial class Sample_DataFactoryPipelineCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_PipelinesListByFactory() - { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Pipelines_ListByFactory.json - // this example is just showing the usage of "Pipelines_ListByFactory" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataFactoryResource created on azure - // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource - string subscriptionId = "12345678-1234-1234-1234-12345678abc"; - string resourceGroupName = "exampleResourceGroup"; - string factoryName = "exampleFactoryName"; - ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); - DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); - - // get the collection of this DataFactoryPipelineResource - DataFactoryPipelineCollection collection = dataFactory.GetDataFactoryPipelines(); - - // invoke the operation and iterate over the result - await foreach (DataFactoryPipelineResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryPipelineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_PipelinesCreate() @@ -78,63 +42,56 @@ public async Task CreateOrUpdate_PipelinesCreate() // invoke the operation string pipelineName = "examplePipeline"; - DataFactoryPipelineData data = new DataFactoryPipelineData() + DataFactoryPipelineData data = new DataFactoryPipelineData { - Activities = -{ -new ForEachActivity("ExampleForeachActivity",new DataFactoryExpression(DataFactoryExpressionType.Expression,"@pipeline().parameters.OutputBlobNameList"),new PipelineActivity[] -{ -new CopyActivity("ExampleCopyActivity",new DataFactoryBlobSource(),new DataFactoryBlobSink()) + Activities = {new ForEachActivity("ExampleForeachActivity", new DataFactoryExpression(DataFactoryExpressionType.Expression, "@pipeline().parameters.OutputBlobNameList"), new PipelineActivity[] { -Inputs = +new CopyActivity("ExampleCopyActivity", new DataFactoryBlobSource(), new DataFactoryBlobSink()) { -new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +Inputs = {new DatasetReference(DatasetReferenceType.DatasetReference, "exampleDataset") { Parameters = { -["MyFileName"] = BinaryData.FromString("\"examplecontainer.csv\""), -["MyFolderPath"] = BinaryData.FromString("\"examplecontainer\""), +["MyFileName"] = BinaryData.FromObjectAsJson("examplecontainer.csv"), +["MyFolderPath"] = BinaryData.FromObjectAsJson("examplecontainer") }, -} -}, -Outputs = -{ -new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +}}, +Outputs = {new DatasetReference(DatasetReferenceType.DatasetReference, "exampleDataset") { Parameters = { -["MyFileName"] = BinaryData.FromObjectAsJson(new Dictionary() +["MyFileName"] = BinaryData.FromObjectAsJson(new { -["type"] = "Expression", -["value"] = "@item()"}), -["MyFolderPath"] = BinaryData.FromString("\"examplecontainer\""), +type = "Expression", +value = "@item()", +}), +["MyFolderPath"] = BinaryData.FromObjectAsJson("examplecontainer") }, -} -}, -DataIntegrationUnits = 32, +}}, +DataIntegrationUnits = null, } }) { IsSequential = true, -} -}, +}}, Parameters = { ["JobId"] = new EntityParameterSpecification(EntityParameterType.String), -["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array), +["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array) }, Variables = { -["TestVariableArray"] = new PipelineVariableSpecification(PipelineVariableType.Array), +["TestVariableArray"] = new PipelineVariableSpecification(PipelineVariableType.Array) }, RunDimensions = { -["JobId"] = BinaryData.FromObjectAsJson(new Dictionary() +["JobId"] = BinaryData.FromObjectAsJson(new { -["type"] = "Expression", -["value"] = "@pipeline().parameters.JobId"}), +type = "Expression", +value = "@pipeline().parameters.JobId", +}) }, - ElapsedTimeMetricDuration = BinaryData.FromString("\"0.00:10:00\""), + ElapsedTimeMetricDuration = BinaryData.FromObjectAsJson("0.00:10:00"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pipelineName, data); DataFactoryPipelineResource result = lro.Value; @@ -171,52 +128,44 @@ public async Task CreateOrUpdate_PipelinesUpdate() // invoke the operation string pipelineName = "examplePipeline"; - DataFactoryPipelineData data = new DataFactoryPipelineData() + DataFactoryPipelineData data = new DataFactoryPipelineData { Description = "Example description", - Activities = + Activities = {new ForEachActivity("ExampleForeachActivity", new DataFactoryExpression(DataFactoryExpressionType.Expression, "@pipeline().parameters.OutputBlobNameList"), new PipelineActivity[] { -new ForEachActivity("ExampleForeachActivity",new DataFactoryExpression(DataFactoryExpressionType.Expression,"@pipeline().parameters.OutputBlobNameList"),new PipelineActivity[] +new CopyActivity("ExampleCopyActivity", new DataFactoryBlobSource(), new DataFactoryBlobSink()) { -new CopyActivity("ExampleCopyActivity",new DataFactoryBlobSource(),new DataFactoryBlobSink()) -{ -Inputs = -{ -new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +Inputs = {new DatasetReference(DatasetReferenceType.DatasetReference, "exampleDataset") { Parameters = { -["MyFileName"] = BinaryData.FromString("\"examplecontainer.csv\""), -["MyFolderPath"] = BinaryData.FromString("\"examplecontainer\""), -}, -} +["MyFileName"] = BinaryData.FromObjectAsJson("examplecontainer.csv"), +["MyFolderPath"] = BinaryData.FromObjectAsJson("examplecontainer") }, -Outputs = -{ -new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +}}, +Outputs = {new DatasetReference(DatasetReferenceType.DatasetReference, "exampleDataset") { Parameters = { -["MyFileName"] = BinaryData.FromObjectAsJson(new Dictionary() +["MyFileName"] = BinaryData.FromObjectAsJson(new { -["type"] = "Expression", -["value"] = "@item()"}), -["MyFolderPath"] = BinaryData.FromString("\"examplecontainer\""), -}, -} +type = "Expression", +value = "@item()", +}), +["MyFolderPath"] = BinaryData.FromObjectAsJson("examplecontainer") }, -DataIntegrationUnits = 32, +}}, +DataIntegrationUnits = null, } }) { IsSequential = true, -} -}, +}}, Parameters = { -["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array), +["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array) }, - ElapsedTimeMetricDuration = BinaryData.FromString("\"0.00:10:00\""), + ElapsedTimeMetricDuration = BinaryData.FromObjectAsJson("0.00:10:00"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pipelineName, data); DataFactoryPipelineResource result = lro.Value; @@ -262,6 +211,42 @@ public async Task Get_PipelinesGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_PipelinesListByFactory() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Pipelines_ListByFactory.json + // this example is just showing the usage of "Pipelines_ListByFactory" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryPipelineResource + DataFactoryPipelineCollection collection = dataFactory.GetDataFactoryPipelines(); + + // invoke the operation and iterate over the result + await foreach (DataFactoryPipelineResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryPipelineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_PipelinesGet() diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineResource.cs index b43a9576ea250..27c35625e97a8 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPipelineResource.cs @@ -9,6 +9,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; +using Azure.Core.Expressions.DataFactory; using Azure.Identity; using Azure.ResourceManager.DataFactory.Models; using NUnit.Framework; @@ -17,6 +18,64 @@ namespace Azure.ResourceManager.DataFactory.Samples { public partial class Sample_DataFactoryPipelineResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_PipelinesGet() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Pipelines_Get.json + // this example is just showing the usage of "Pipelines_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DataFactoryPipelineResource created on azure + // for more information of creating DataFactoryPipelineResource, please refer to the document of DataFactoryPipelineResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + string pipelineName = "examplePipeline"; + ResourceIdentifier dataFactoryPipelineResourceId = DataFactoryPipelineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, pipelineName); + DataFactoryPipelineResource dataFactoryPipeline = client.GetDataFactoryPipelineResource(dataFactoryPipelineResourceId); + + // invoke the operation + DataFactoryPipelineResource result = await dataFactoryPipeline.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryPipelineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_PipelinesDelete() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Pipelines_Delete.json + // this example is just showing the usage of "Pipelines_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DataFactoryPipelineResource created on azure + // for more information of creating DataFactoryPipelineResource, please refer to the document of DataFactoryPipelineResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + string pipelineName = "examplePipeline"; + ResourceIdentifier dataFactoryPipelineResourceId = DataFactoryPipelineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, pipelineName); + DataFactoryPipelineResource dataFactoryPipeline = client.GetDataFactoryPipelineResource(dataFactoryPipelineResourceId); + + // invoke the operation + await dataFactoryPipeline.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_PipelinesCreate() @@ -39,63 +98,56 @@ public async Task Update_PipelinesCreate() DataFactoryPipelineResource dataFactoryPipeline = client.GetDataFactoryPipelineResource(dataFactoryPipelineResourceId); // invoke the operation - DataFactoryPipelineData data = new DataFactoryPipelineData() + DataFactoryPipelineData data = new DataFactoryPipelineData { - Activities = -{ -new ForEachActivity("ExampleForeachActivity",new DataFactoryExpression(DataFactoryExpressionType.Expression,"@pipeline().parameters.OutputBlobNameList"),new PipelineActivity[] -{ -new CopyActivity("ExampleCopyActivity",new DataFactoryBlobSource(),new DataFactoryBlobSink()) + Activities = {new ForEachActivity("ExampleForeachActivity", new DataFactoryExpression(DataFactoryExpressionType.Expression, "@pipeline().parameters.OutputBlobNameList"), new PipelineActivity[] { -Inputs = +new CopyActivity("ExampleCopyActivity", new DataFactoryBlobSource(), new DataFactoryBlobSink()) { -new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +Inputs = {new DatasetReference(DatasetReferenceType.DatasetReference, "exampleDataset") { Parameters = { -["MyFileName"] = BinaryData.FromString("\"examplecontainer.csv\""), -["MyFolderPath"] = BinaryData.FromString("\"examplecontainer\""), +["MyFileName"] = BinaryData.FromObjectAsJson("examplecontainer.csv"), +["MyFolderPath"] = BinaryData.FromObjectAsJson("examplecontainer") }, -} -}, -Outputs = -{ -new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +}}, +Outputs = {new DatasetReference(DatasetReferenceType.DatasetReference, "exampleDataset") { Parameters = { -["MyFileName"] = BinaryData.FromObjectAsJson(new Dictionary() +["MyFileName"] = BinaryData.FromObjectAsJson(new { -["type"] = "Expression", -["value"] = "@item()"}), -["MyFolderPath"] = BinaryData.FromString("\"examplecontainer\""), -}, -} +type = "Expression", +value = "@item()", +}), +["MyFolderPath"] = BinaryData.FromObjectAsJson("examplecontainer") }, -DataIntegrationUnits = 32, +}}, +DataIntegrationUnits = null, } }) { IsSequential = true, -} -}, +}}, Parameters = { ["JobId"] = new EntityParameterSpecification(EntityParameterType.String), -["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array), +["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array) }, Variables = { -["TestVariableArray"] = new PipelineVariableSpecification(PipelineVariableType.Array), +["TestVariableArray"] = new PipelineVariableSpecification(PipelineVariableType.Array) }, RunDimensions = { -["JobId"] = BinaryData.FromObjectAsJson(new Dictionary() +["JobId"] = BinaryData.FromObjectAsJson(new { -["type"] = "Expression", -["value"] = "@pipeline().parameters.JobId"}), +type = "Expression", +value = "@pipeline().parameters.JobId", +}) }, - ElapsedTimeMetricDuration = BinaryData.FromString("\"0.00:10:00\""), + ElapsedTimeMetricDuration = BinaryData.FromObjectAsJson("0.00:10:00"), }; ArmOperation lro = await dataFactoryPipeline.UpdateAsync(WaitUntil.Completed, data); DataFactoryPipelineResource result = lro.Value; @@ -129,52 +181,44 @@ public async Task Update_PipelinesUpdate() DataFactoryPipelineResource dataFactoryPipeline = client.GetDataFactoryPipelineResource(dataFactoryPipelineResourceId); // invoke the operation - DataFactoryPipelineData data = new DataFactoryPipelineData() + DataFactoryPipelineData data = new DataFactoryPipelineData { Description = "Example description", - Activities = + Activities = {new ForEachActivity("ExampleForeachActivity", new DataFactoryExpression(DataFactoryExpressionType.Expression, "@pipeline().parameters.OutputBlobNameList"), new PipelineActivity[] { -new ForEachActivity("ExampleForeachActivity",new DataFactoryExpression(DataFactoryExpressionType.Expression,"@pipeline().parameters.OutputBlobNameList"),new PipelineActivity[] +new CopyActivity("ExampleCopyActivity", new DataFactoryBlobSource(), new DataFactoryBlobSink()) { -new CopyActivity("ExampleCopyActivity",new DataFactoryBlobSource(),new DataFactoryBlobSink()) -{ -Inputs = -{ -new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +Inputs = {new DatasetReference(DatasetReferenceType.DatasetReference, "exampleDataset") { Parameters = { -["MyFileName"] = BinaryData.FromString("\"examplecontainer.csv\""), -["MyFolderPath"] = BinaryData.FromString("\"examplecontainer\""), +["MyFileName"] = BinaryData.FromObjectAsJson("examplecontainer.csv"), +["MyFolderPath"] = BinaryData.FromObjectAsJson("examplecontainer") }, -} -}, -Outputs = -{ -new DatasetReference(DatasetReferenceType.DatasetReference,"exampleDataset") +}}, +Outputs = {new DatasetReference(DatasetReferenceType.DatasetReference, "exampleDataset") { Parameters = { -["MyFileName"] = BinaryData.FromObjectAsJson(new Dictionary() +["MyFileName"] = BinaryData.FromObjectAsJson(new { -["type"] = "Expression", -["value"] = "@item()"}), -["MyFolderPath"] = BinaryData.FromString("\"examplecontainer\""), +type = "Expression", +value = "@item()", +}), +["MyFolderPath"] = BinaryData.FromObjectAsJson("examplecontainer") }, -} -}, -DataIntegrationUnits = 32, +}}, +DataIntegrationUnits = null, } }) { IsSequential = true, -} -}, +}}, Parameters = { -["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array), +["OutputBlobNameList"] = new EntityParameterSpecification(EntityParameterType.Array) }, - ElapsedTimeMetricDuration = BinaryData.FromString("\"0.00:10:00\""), + ElapsedTimeMetricDuration = BinaryData.FromObjectAsJson("0.00:10:00"), }; ArmOperation lro = await dataFactoryPipeline.UpdateAsync(WaitUntil.Completed, data); DataFactoryPipelineResource result = lro.Value; @@ -186,64 +230,6 @@ public async Task Update_PipelinesUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_PipelinesGet() - { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Pipelines_Get.json - // this example is just showing the usage of "Pipelines_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataFactoryPipelineResource created on azure - // for more information of creating DataFactoryPipelineResource, please refer to the document of DataFactoryPipelineResource - string subscriptionId = "12345678-1234-1234-1234-12345678abc"; - string resourceGroupName = "exampleResourceGroup"; - string factoryName = "exampleFactoryName"; - string pipelineName = "examplePipeline"; - ResourceIdentifier dataFactoryPipelineResourceId = DataFactoryPipelineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, pipelineName); - DataFactoryPipelineResource dataFactoryPipeline = client.GetDataFactoryPipelineResource(dataFactoryPipelineResourceId); - - // invoke the operation - DataFactoryPipelineResource result = await dataFactoryPipeline.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryPipelineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_PipelinesDelete() - { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Pipelines_Delete.json - // this example is just showing the usage of "Pipelines_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataFactoryPipelineResource created on azure - // for more information of creating DataFactoryPipelineResource, please refer to the document of DataFactoryPipelineResource - string subscriptionId = "12345678-1234-1234-1234-12345678abc"; - string resourceGroupName = "exampleResourceGroup"; - string factoryName = "exampleFactoryName"; - string pipelineName = "examplePipeline"; - ResourceIdentifier dataFactoryPipelineResourceId = DataFactoryPipelineResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName, pipelineName); - DataFactoryPipelineResource dataFactoryPipeline = client.GetDataFactoryPipelineResource(dataFactoryPipelineResourceId); - - // invoke the operation - await dataFactoryPipeline.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateRun_PipelinesCreateRun() @@ -266,9 +252,12 @@ public async Task CreateRun_PipelinesCreateRun() DataFactoryPipelineResource dataFactoryPipeline = client.GetDataFactoryPipelineResource(dataFactoryPipelineResourceId); // invoke the operation - IDictionary parameterValueSpecification = new Dictionary() + IDictionary parameterValueSpecification = new Dictionary + { + ["OutputBlobNameList"] = BinaryData.FromObjectAsJson(new object[] { - ["OutputBlobNameList"] = BinaryData.FromObjectAsJson(new object[] { "exampleoutput.csv" }), +"exampleoutput.csv" + }) }; string referencePipelineRunId = null; PipelineCreateRunResult result = await dataFactoryPipeline.CreateRunAsync(parameterValueSpecification: parameterValueSpecification, referencePipelineRunId: referencePipelineRunId); diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointCollection.cs index 4c2ef49f8c632..a03de4d90ccba 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryPrivateEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ManagedPrivateEndpointsListByFactory() + public async Task CreateOrUpdate_ManagedVirtualNetworksCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_ListByFactory.json - // this example is just showing the usage of "ManagedPrivateEndpoints_ListByFactory" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_Create.json + // this example is just showing the usage of "ManagedPrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,30 @@ public async Task GetAll_ManagedPrivateEndpointsListByFactory() // get the collection of this DataFactoryPrivateEndpointResource DataFactoryPrivateEndpointCollection collection = dataFactoryManagedVirtualNetwork.GetDataFactoryPrivateEndpoints(); - // invoke the operation and iterate over the result - await foreach (DataFactoryPrivateEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string managedPrivateEndpointName = "exampleManagedPrivateEndpointName"; + DataFactoryPrivateEndpointData data = new DataFactoryPrivateEndpointData(new DataFactoryPrivateEndpointProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryPrivateEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Fqdns = { }, + GroupId = "blob", + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourceGroups/exampleResourceGroup/providers/Microsoft.Storage/storageAccounts/exampleBlobStorage"), + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedPrivateEndpointName, data); + DataFactoryPrivateEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryPrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ManagedVirtualNetworksCreate() + public async Task Get_ManagedPrivateEndpointsGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_Create.json - // this example is just showing the usage of "ManagedPrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_Get.json + // this example is just showing the usage of "ManagedPrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,16 +84,7 @@ public async Task CreateOrUpdate_ManagedVirtualNetworksCreate() // invoke the operation string managedPrivateEndpointName = "exampleManagedPrivateEndpointName"; - DataFactoryPrivateEndpointData data = new DataFactoryPrivateEndpointData(new DataFactoryPrivateEndpointProperties() - { - Fqdns = -{ -}, - GroupId = "blob", - PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourceGroups/exampleResourceGroup/providers/Microsoft.Storage/storageAccounts/exampleBlobStorage"), - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedPrivateEndpointName, data); - DataFactoryPrivateEndpointResource result = lro.Value; + DataFactoryPrivateEndpointResource result = await collection.GetAsync(managedPrivateEndpointName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -99,10 +95,10 @@ public async Task CreateOrUpdate_ManagedVirtualNetworksCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ManagedPrivateEndpointsGet() + public async Task GetAll_ManagedPrivateEndpointsListByFactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_Get.json - // this example is just showing the usage of "ManagedPrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_ListByFactory.json + // this example is just showing the usage of "ManagedPrivateEndpoints_ListByFactory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,15 +117,17 @@ public async Task Get_ManagedPrivateEndpointsGet() // get the collection of this DataFactoryPrivateEndpointResource DataFactoryPrivateEndpointCollection collection = dataFactoryManagedVirtualNetwork.GetDataFactoryPrivateEndpoints(); - // invoke the operation - string managedPrivateEndpointName = "exampleManagedPrivateEndpointName"; - DataFactoryPrivateEndpointResource result = await collection.GetAsync(managedPrivateEndpointName); + // invoke the operation and iterate over the result + await foreach (DataFactoryPrivateEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryPrivateEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryPrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointConnectionCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointConnectionCollection.cs index 25e68e36db9bc..56e1c1de1fd2b 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointConnectionCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointConnectionCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.DataFactory.Samples { public partial class Sample_DataFactoryPrivateEndpointConnectionCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndPointConnectionsListByFactory() - { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/PrivateEndPointConnections_ListByFactory.json - // this example is just showing the usage of "privateEndPointConnections_ListByFactory" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataFactoryResource created on azure - // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource - string subscriptionId = "12345678-1234-1234-1234-12345678abc"; - string resourceGroupName = "exampleResourceGroup"; - string factoryName = "exampleFactoryName"; - ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); - DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); - - // get the collection of this DataFactoryPrivateEndpointConnectionResource - DataFactoryPrivateEndpointConnectionCollection collection = dataFactory.GetDataFactoryPrivateEndpointConnections(); - - // invoke the operation and iterate over the result - await foreach (DataFactoryPrivateEndpointConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForAFactory() @@ -77,11 +41,11 @@ public async Task CreateOrUpdate_ApprovesOrRejectsAPrivateEndpointConnectionForA // invoke the operation string privateEndpointConnectionName = "connection"; - DataFactoryPrivateEndpointConnectionCreateOrUpdateContent content = new DataFactoryPrivateEndpointConnectionCreateOrUpdateContent() + DataFactoryPrivateEndpointConnectionCreateOrUpdateContent content = new DataFactoryPrivateEndpointConnectionCreateOrUpdateContent { - Properties = new PrivateLinkConnectionApprovalRequest() + Properties = new PrivateLinkConnectionApprovalRequest { - PrivateLinkServiceConnectionState = new PrivateLinkConnectionState() + PrivateLinkServiceConnectionState = new PrivateLinkConnectionState { Status = "Approved", Description = "Approved by admin.", @@ -134,6 +98,42 @@ public async Task Get_GetAPrivateEndpointConnectionForADatafactory() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_PrivateEndPointConnectionsListByFactory() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/PrivateEndPointConnections_ListByFactory.json + // this example is just showing the usage of "privateEndPointConnections_ListByFactory" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryPrivateEndpointConnectionResource + DataFactoryPrivateEndpointConnectionCollection collection = dataFactory.GetDataFactoryPrivateEndpointConnections(); + + // invoke the operation and iterate over the result + await foreach (DataFactoryPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAPrivateEndpointConnectionForADatafactory() diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointConnectionResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointConnectionResource.cs index 7544e26050bad..6c13cdfac1c33 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointConnectionResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForAFactory() + public async Task Get_GetAPrivateEndpointConnectionForADatafactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ApproveRejectPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,21 +38,7 @@ public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForAFactory( DataFactoryPrivateEndpointConnectionResource dataFactoryPrivateEndpointConnection = client.GetDataFactoryPrivateEndpointConnectionResource(dataFactoryPrivateEndpointConnectionResourceId); // invoke the operation - DataFactoryPrivateEndpointConnectionCreateOrUpdateContent content = new DataFactoryPrivateEndpointConnectionCreateOrUpdateContent() - { - Properties = new PrivateLinkConnectionApprovalRequest() - { - PrivateLinkServiceConnectionState = new PrivateLinkConnectionState() - { - Status = "Approved", - Description = "Approved by admin.", - ActionsRequired = "", - }, - PrivateEndpointId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourceGroups/exampleResourceGroup/providers/Microsoft.DataFactory/factories/exampleFactoryName/privateEndpoints/myPrivateEndpoint"), - }, - }; - ArmOperation lro = await dataFactoryPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, content); - DataFactoryPrivateEndpointConnectionResource result = lro.Value; + DataFactoryPrivateEndpointConnectionResource result = await dataFactoryPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -63,10 +49,10 @@ public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForAFactory( [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPrivateEndpointConnectionForADatafactory() + public async Task Delete_DeleteAPrivateEndpointConnectionForADatafactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/GetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -83,21 +69,17 @@ public async Task Get_GetAPrivateEndpointConnectionForADatafactory() DataFactoryPrivateEndpointConnectionResource dataFactoryPrivateEndpointConnection = client.GetDataFactoryPrivateEndpointConnectionResource(dataFactoryPrivateEndpointConnectionResourceId); // invoke the operation - DataFactoryPrivateEndpointConnectionResource result = await dataFactoryPrivateEndpointConnection.GetAsync(); + await dataFactoryPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPrivateEndpointConnectionForADatafactory() + public async Task Update_ApprovesOrRejectsAPrivateEndpointConnectionForAFactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/DeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ApproveRejectPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +96,27 @@ public async Task Delete_DeleteAPrivateEndpointConnectionForADatafactory() DataFactoryPrivateEndpointConnectionResource dataFactoryPrivateEndpointConnection = client.GetDataFactoryPrivateEndpointConnectionResource(dataFactoryPrivateEndpointConnectionResourceId); // invoke the operation - await dataFactoryPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + DataFactoryPrivateEndpointConnectionCreateOrUpdateContent content = new DataFactoryPrivateEndpointConnectionCreateOrUpdateContent + { + Properties = new PrivateLinkConnectionApprovalRequest + { + PrivateLinkServiceConnectionState = new PrivateLinkConnectionState + { + Status = "Approved", + Description = "Approved by admin.", + ActionsRequired = "", + }, + PrivateEndpointId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourceGroups/exampleResourceGroup/providers/Microsoft.DataFactory/factories/exampleFactoryName/privateEndpoints/myPrivateEndpoint"), + }, + }; + ArmOperation lro = await dataFactoryPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, content); + DataFactoryPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointResource.cs index 9b3f4104a723b..dfd3df05a0ec9 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryPrivateEndpointResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryPrivateEndpointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ManagedVirtualNetworksCreate() + public async Task Get_ManagedPrivateEndpointsGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_Create.json - // this example is just showing the usage of "ManagedPrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_Get.json + // this example is just showing the usage of "ManagedPrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,16 +39,7 @@ public async Task Update_ManagedVirtualNetworksCreate() DataFactoryPrivateEndpointResource dataFactoryPrivateEndpoint = client.GetDataFactoryPrivateEndpointResource(dataFactoryPrivateEndpointResourceId); // invoke the operation - DataFactoryPrivateEndpointData data = new DataFactoryPrivateEndpointData(new DataFactoryPrivateEndpointProperties() - { - Fqdns = -{ -}, - GroupId = "blob", - PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourceGroups/exampleResourceGroup/providers/Microsoft.Storage/storageAccounts/exampleBlobStorage"), - }); - ArmOperation lro = await dataFactoryPrivateEndpoint.UpdateAsync(WaitUntil.Completed, data); - DataFactoryPrivateEndpointResource result = lro.Value; + DataFactoryPrivateEndpointResource result = await dataFactoryPrivateEndpoint.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -59,10 +50,10 @@ public async Task Update_ManagedVirtualNetworksCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ManagedPrivateEndpointsGet() + public async Task Delete_ManagedVirtualNetworksDelete() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_Get.json - // this example is just showing the usage of "ManagedPrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_Delete.json + // this example is just showing the usage of "ManagedPrivateEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,21 +71,17 @@ public async Task Get_ManagedPrivateEndpointsGet() DataFactoryPrivateEndpointResource dataFactoryPrivateEndpoint = client.GetDataFactoryPrivateEndpointResource(dataFactoryPrivateEndpointResourceId); // invoke the operation - DataFactoryPrivateEndpointResource result = await dataFactoryPrivateEndpoint.GetAsync(); + await dataFactoryPrivateEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryPrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ManagedVirtualNetworksDelete() + public async Task Update_ManagedVirtualNetworksCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_Delete.json - // this example is just showing the usage of "ManagedPrivateEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/ManagedPrivateEndpoints_Create.json + // this example is just showing the usage of "ManagedPrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,9 +99,20 @@ public async Task Delete_ManagedVirtualNetworksDelete() DataFactoryPrivateEndpointResource dataFactoryPrivateEndpoint = client.GetDataFactoryPrivateEndpointResource(dataFactoryPrivateEndpointResourceId); // invoke the operation - await dataFactoryPrivateEndpoint.DeleteAsync(WaitUntil.Completed); + DataFactoryPrivateEndpointData data = new DataFactoryPrivateEndpointData(new DataFactoryPrivateEndpointProperties + { + Fqdns = { }, + GroupId = "blob", + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourceGroups/exampleResourceGroup/providers/Microsoft.Storage/storageAccounts/exampleBlobStorage"), + }); + ArmOperation lro = await dataFactoryPrivateEndpoint.UpdateAsync(WaitUntil.Completed, data); + DataFactoryPrivateEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryPrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryResource.cs index 41f103bb15974..8bfa7b870c662 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryResource.cs @@ -6,13 +6,11 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Core.Expressions.DataFactory; using Azure.Identity; using Azure.ResourceManager.DataFactory.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DataFactory.Samples @@ -21,79 +19,10 @@ public partial class Sample_DataFactoryResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDataFactories_FactoriesList() - { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_List.json - // this example is just showing the usage of "Factories_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "12345678-1234-1234-1234-12345678abc"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DataFactoryResource item in subscriptionResource.GetDataFactoriesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task ConfigureFactoryRepoInformation_FactoriesConfigureFactoryRepo() - { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_ConfigureFactoryRepo.json - // this example is just showing the usage of "Factories_ConfigureFactoryRepo" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "12345678-1234-1234-1234-12345678abc"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation locationId = new AzureLocation("East US"); - FactoryRepoContent content = new FactoryRepoContent() - { - FactoryResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourceGroups/exampleResourceGroup/providers/Microsoft.DataFactory/factories/exampleFactoryName"), - RepoConfiguration = new FactoryVstsConfiguration("ADF", "repo", "master", "/", "project") - { - TenantId = Guid.Parse(""), - LastCommitId = "", - }, - }; - DataFactoryResource result = await subscriptionResource.ConfigureFactoryRepoInformationAsync(locationId, content); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_FactoriesUpdate() + public async Task Get_FactoriesGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_Update.json - // this example is just showing the usage of "Factories_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_Get.json + // this example is just showing the usage of "Factories_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,14 +38,7 @@ public async Task Update_FactoriesUpdate() DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); // invoke the operation - DataFactoryPatch patch = new DataFactoryPatch() - { - Tags = -{ -["exampleTag"] = "exampleValue", -}, - }; - DataFactoryResource result = await dataFactory.UpdateAsync(patch); + DataFactoryResource result = await dataFactory.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -127,10 +49,10 @@ public async Task Update_FactoriesUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FactoriesGet() + public async Task Delete_FactoriesDelete() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_Get.json - // this example is just showing the usage of "Factories_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_Delete.json + // this example is just showing the usage of "Factories_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,21 +68,17 @@ public async Task Get_FactoriesGet() DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); // invoke the operation - DataFactoryResource result = await dataFactory.GetAsync(); + await dataFactory.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_FactoriesDelete() + public async Task Update_FactoriesUpdate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_Delete.json - // this example is just showing the usage of "Factories_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_Update.json + // this example is just showing the usage of "Factories_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,9 +94,20 @@ public async Task Delete_FactoriesDelete() DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); // invoke the operation - await dataFactory.DeleteAsync(WaitUntil.Completed); + DataFactoryPatch patch = new DataFactoryPatch + { + Tags = +{ +["exampleTag"] = "exampleValue" +}, + }; + DataFactoryResource result = await dataFactory.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -232,7 +161,7 @@ public async Task GetDataPlaneAccess_FactoriesGetDataPlaneAccess() DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); // invoke the operation - DataFactoryDataPlaneUserAccessPolicy policy = new DataFactoryDataPlaneUserAccessPolicy() + DataFactoryDataPlaneUserAccessPolicy policy = new DataFactoryDataPlaneUserAccessPolicy { Permissions = "r", AccessResourcePath = "", @@ -266,7 +195,7 @@ public async Task GetExposureControlFeature_ExposureControlGetFeatureValueByFact DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); // invoke the operation - ExposureControlContent content = new ExposureControlContent() + ExposureControlContent content = new ExposureControlContent { FeatureName = "ADFIntegrationRuntimeSharingRbac", FeatureType = "Feature", @@ -299,11 +228,12 @@ public async Task GetExposureControlFeatures_ExposureControlQueryFeatureValuesBy // invoke the operation ExposureControlBatchContent content = new ExposureControlBatchContent(new ExposureControlContent[] { -new ExposureControlContent() +new ExposureControlContent { FeatureName = "ADFIntegrationRuntimeSharingRbac", FeatureType = "Feature", -},new ExposureControlContent() +}, +new ExposureControlContent { FeatureName = "ADFSampleFeature", FeatureType = "Feature", @@ -337,13 +267,7 @@ public async Task GetPipelineRuns_PipelineRunsQueryByFactory() // invoke the operation and iterate over the result RunFilterContent content = new RunFilterContent(DateTimeOffset.Parse("2018-06-16T00:36:44.3345758Z"), DateTimeOffset.Parse("2018-06-16T00:49:48.3686473Z")) { - Filters = -{ -new RunQueryFilter(RunQueryFilterOperand.PipelineName,RunQueryFilterOperator.EqualsValue,new string[] -{ -"examplePipeline" -}) -}, + Filters = { new RunQueryFilter(RunQueryFilterOperand.PipelineName, RunQueryFilterOperator.EqualsValue, new string[] { "examplePipeline" }) }, }; await foreach (DataFactoryPipelineRunInfo item in dataFactory.GetPipelineRunsAsync(content)) { @@ -459,7 +383,7 @@ public async Task GetTriggers_TriggersQueryByFactory() DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); // invoke the operation and iterate over the result - TriggerFilterContent content = new TriggerFilterContent() + TriggerFilterContent content = new TriggerFilterContent { ParentTriggerName = "exampleTrigger", }; @@ -498,13 +422,7 @@ public async Task GetTriggerRuns_TriggerRunsQueryByFactory() // invoke the operation and iterate over the result RunFilterContent content = new RunFilterContent(DateTimeOffset.Parse("2018-06-16T00:36:44.3345758Z"), DateTimeOffset.Parse("2018-06-16T00:49:48.3686473Z")) { - Filters = -{ -new RunQueryFilter(RunQueryFilterOperand.TriggerName,RunQueryFilterOperator.EqualsValue,new string[] -{ -"exampleTrigger" -}) -}, + Filters = { new RunQueryFilter(RunQueryFilterOperand.TriggerName, RunQueryFilterOperator.EqualsValue, new string[] { "exampleTrigger" }) }, }; await foreach (DataFactoryTriggerRun item in dataFactory.GetTriggerRunsAsync(content)) { @@ -535,15 +453,15 @@ public async Task CreateDataFlowDebugSession_DataFlowDebugSessionCreate() DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); // invoke the operation - DataFactoryDataFlowDebugSessionContent content = new DataFactoryDataFlowDebugSessionContent() + DataFactoryDataFlowDebugSessionContent content = new DataFactoryDataFlowDebugSessionContent { TimeToLiveInMinutes = 60, - IntegrationRuntime = new DataFactoryIntegrationRuntimeDebugInfo(new ManagedIntegrationRuntime() + IntegrationRuntime = new DataFactoryIntegrationRuntimeDebugInfo(new ManagedIntegrationRuntime { - ComputeProperties = new IntegrationRuntimeComputeProperties() + ComputeProperties = new IntegrationRuntimeComputeProperties { Location = new AzureLocation("AutoResolve"), - DataFlowProperties = new IntegrationRuntimeDataFlowProperties() + DataFlowProperties = new IntegrationRuntimeDataFlowProperties { ComputeType = DataFlowComputeType.General, CoreCount = 48, @@ -611,99 +529,73 @@ public async Task AddDataFlowToDebugSession_DataFlowDebugSessionAddDataFlow() DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); // invoke the operation - DataFactoryDataFlowDebugPackageContent content = new DataFactoryDataFlowDebugPackageContent() + DataFactoryDataFlowDebugPackageContent content = new DataFactoryDataFlowDebugPackageContent { SessionId = Guid.Parse("f06ed247-9d07-49b2-b05e-2cb4a2fc871e"), - DataFlow = new DataFactoryDataFlowDebugInfo(new DataFactoryMappingDataFlowProperties() + DataFlow = new DataFactoryDataFlowDebugInfo(new DataFactoryMappingDataFlowProperties { - Sources = -{ -new DataFlowSource("source1") -{ -Dataset = new DatasetReference(DatasetReferenceType.DatasetReference,"DelimitedText2"), -} -}, - Sinks = -{ -}, - Transformations = + Sources = {new DataFlowSource("source1") { -}, +Dataset = new DatasetReference(DatasetReferenceType.DatasetReference, "DelimitedText2"), +}}, + Sinks = { }, + Transformations = { }, Script = "\n\nsource(output(\n\t\tColumn_1 as string\n\t),\n\tallowSchemaDrift: true,\n\tvalidateSchema: false) ~> source1", }) { Name = "dataflow1", }, - Datasets = -{ -new DataFactoryDatasetDebugInfo(new DelimitedTextDataset(new DataFactoryLinkedServiceReference("LinkedServiceReference","linkedService5")) + Datasets = {new DataFactoryDatasetDebugInfo(new DelimitedTextDataset(new DataFactoryLinkedServiceReference(default, "linkedService5")) { -DataLocation = new AzureBlobStorageLocation() -{ -Container = "dataflow-sample-data", -FileName = "Ansiencoding.csv", -}, -ColumnDelimiter = ",", -QuoteChar = "\"", -EscapeChar = "\\", -FirstRowAsHeader = true, -Schema = new DatasetSchemaDataElement[] -{ -new DatasetSchemaDataElement() -{ -SchemaColumnType = "String", -} -}, -Annotations = +DataLocation = new AzureBlobStorageLocation { +Container = null, +FileName = null, }, +ColumnDelimiter = null, +QuoteChar = null, +EscapeChar = null, +FirstRowAsHeader = null, +Schema = null, +Annotations = {}, }) { Name = "dataset1", -} -}, - LinkedServices = +}}, + LinkedServices = {new DataFactoryLinkedServiceDebugInfo(new AzureBlobStorageLinkedService { -new DataFactoryLinkedServiceDebugInfo(new AzureBlobStorageLinkedService() -{ -ConnectionString = "DefaultEndpointsProtocol=https;AccountName=;EndpointSuffix=core.windows.net;", +ConnectionString = null, EncryptedCredential = "", -Annotations = -{ -}, +Annotations = {}, }) { Name = "linkedService1", -} -}, - DebugSettings = new DataFlowDebugPackageDebugSettings() +}}, + DebugSettings = new DataFlowDebugPackageDebugSettings { - SourceSettings = -{ -new DataFlowSourceSetting() + SourceSettings = {new DataFlowSourceSetting { SourceName = "source1", RowLimit = 1000, -},new DataFlowSourceSetting() +}, new DataFlowSourceSetting { SourceName = "source2", RowLimit = 222, -} -}, +}}, Parameters = { -["sourcePath"] = BinaryData.FromString("\"Toy\""), +["sourcePath"] = BinaryData.FromObjectAsJson("Toy") }, - DatasetParameters = BinaryData.FromObjectAsJson(new Dictionary() + DatasetParameters = BinaryData.FromObjectAsJson(new { - ["Movies"] = new Dictionary() + Movies = new { - ["path"] = "abc" + path = "abc", }, - ["Output"] = new Dictionary() + Output = new { - ["time"] = "def" - } + time = "def", + }, }), }, }; @@ -733,7 +625,7 @@ public async Task DeleteDataFlowDebugSession_DataFlowDebugSessionDelete() DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); // invoke the operation - DeleteDataFlowDebugSessionContent content = new DeleteDataFlowDebugSessionContent() + DeleteDataFlowDebugSessionContent content = new DeleteDataFlowDebugSessionContent { SessionId = Guid.Parse("91fb57e0-8292-47be-89ff-c8f2d2bb2a7e"), }; @@ -763,7 +655,7 @@ public async Task ExecuteDataFlowDebugSessionCommand_DataFlowDebugSessionExecute DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); // invoke the operation - DataFlowDebugCommandContent content = new DataFlowDebugCommandContent() + DataFlowDebugCommandContent content = new DataFlowDebugCommandContent { SessionId = Guid.Parse("f06ed247-9d07-49b2-b05e-2cb4a2fc871e"), Command = DataFlowDebugCommandType.ExecutePreviewQuery, diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryServiceCredentialCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryServiceCredentialCollection.cs index 12b065098f182..b07d801e2ca53 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryServiceCredentialCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryServiceCredentialCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryServiceCredentialCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CredentialsListByFactory() + public async Task CreateOrUpdate_CredentialsCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_ListByFactory.json - // this example is just showing the usage of "CredentialOperations_ListByFactory" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Create.json + // this example is just showing the usage of "CredentialOperations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_CredentialsListByFactory() // get the collection of this DataFactoryServiceCredentialResource DataFactoryServiceCredentialCollection collection = dataFactory.GetDataFactoryServiceCredentials(); - // invoke the operation and iterate over the result - await foreach (DataFactoryServiceCredentialResource item in collection.GetAllAsync()) + // invoke the operation + string credentialName = "exampleCredential"; + DataFactoryServiceCredentialData data = new DataFactoryServiceCredentialData(new DataFactoryManagedIdentityCredentialProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryServiceCredentialData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourcegroups/exampleResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleUami"), + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, credentialName, data); + DataFactoryServiceCredentialResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryServiceCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CredentialsCreate() + public async Task Get_CredentialsGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Create.json - // this example is just showing the usage of "CredentialOperations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Get.json + // this example is just showing the usage of "CredentialOperations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,12 +80,7 @@ public async Task CreateOrUpdate_CredentialsCreate() // invoke the operation string credentialName = "exampleCredential"; - DataFactoryServiceCredentialData data = new DataFactoryServiceCredentialData(new DataFactoryManagedIdentityCredentialProperties() - { - ResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourcegroups/exampleResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleUami"), - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, credentialName, data); - DataFactoryServiceCredentialResource result = lro.Value; + DataFactoryServiceCredentialResource result = await collection.GetAsync(credentialName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -93,10 +91,10 @@ public async Task CreateOrUpdate_CredentialsCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CredentialsGet() + public async Task GetAll_CredentialsListByFactory() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Get.json - // this example is just showing the usage of "CredentialOperations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_ListByFactory.json + // this example is just showing the usage of "CredentialOperations_ListByFactory" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,15 +112,17 @@ public async Task Get_CredentialsGet() // get the collection of this DataFactoryServiceCredentialResource DataFactoryServiceCredentialCollection collection = dataFactory.GetDataFactoryServiceCredentials(); - // invoke the operation - string credentialName = "exampleCredential"; - DataFactoryServiceCredentialResource result = await collection.GetAsync(credentialName); + // invoke the operation and iterate over the result + await foreach (DataFactoryServiceCredentialResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryServiceCredentialData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryServiceCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryServiceCredentialResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryServiceCredentialResource.cs index 64a9a231cc84b..8a0ef984cc2a7 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryServiceCredentialResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryServiceCredentialResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryServiceCredentialResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CredentialsCreate() + public async Task Get_CredentialsGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Create.json - // this example is just showing the usage of "CredentialOperations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Get.json + // this example is just showing the usage of "CredentialOperations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,12 +38,7 @@ public async Task Update_CredentialsCreate() DataFactoryServiceCredentialResource dataFactoryServiceCredential = client.GetDataFactoryServiceCredentialResource(dataFactoryServiceCredentialResourceId); // invoke the operation - DataFactoryServiceCredentialData data = new DataFactoryServiceCredentialData(new DataFactoryManagedIdentityCredentialProperties() - { - ResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourcegroups/exampleResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleUami"), - }); - ArmOperation lro = await dataFactoryServiceCredential.UpdateAsync(WaitUntil.Completed, data); - DataFactoryServiceCredentialResource result = lro.Value; + DataFactoryServiceCredentialResource result = await dataFactoryServiceCredential.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +49,10 @@ public async Task Update_CredentialsCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CredentialsGet() + public async Task Delete_CredentialsDelete() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Get.json - // this example is just showing the usage of "CredentialOperations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Delete.json + // this example is just showing the usage of "CredentialOperations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,21 +69,17 @@ public async Task Get_CredentialsGet() DataFactoryServiceCredentialResource dataFactoryServiceCredential = client.GetDataFactoryServiceCredentialResource(dataFactoryServiceCredentialResourceId); // invoke the operation - DataFactoryServiceCredentialResource result = await dataFactoryServiceCredential.GetAsync(); + await dataFactoryServiceCredential.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryServiceCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CredentialsDelete() + public async Task Update_CredentialsCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Delete.json - // this example is just showing the usage of "CredentialOperations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Credentials_Create.json + // this example is just showing the usage of "CredentialOperations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_CredentialsDelete() DataFactoryServiceCredentialResource dataFactoryServiceCredential = client.GetDataFactoryServiceCredentialResource(dataFactoryServiceCredentialResourceId); // invoke the operation - await dataFactoryServiceCredential.DeleteAsync(WaitUntil.Completed); + DataFactoryServiceCredentialData data = new DataFactoryServiceCredentialData(new DataFactoryManagedIdentityCredentialProperties + { + ResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourcegroups/exampleResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/exampleUami"), + }); + ArmOperation lro = await dataFactoryServiceCredential.UpdateAsync(WaitUntil.Completed, data); + DataFactoryServiceCredentialResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryServiceCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryTriggerCollection.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryTriggerCollection.cs index 90ea7c5337757..d34224c025c33 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryTriggerCollection.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryTriggerCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.DataFactory.Samples { public partial class Sample_DataFactoryTriggerCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_TriggersListByFactory() - { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Triggers_ListByFactory.json - // this example is just showing the usage of "Triggers_ListByFactory" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataFactoryResource created on azure - // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource - string subscriptionId = "12345678-1234-1234-1234-12345678abc"; - string resourceGroupName = "exampleResourceGroup"; - string factoryName = "exampleFactoryName"; - ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); - DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); - - // get the collection of this DataFactoryTriggerResource - DataFactoryTriggerCollection collection = dataFactory.GetDataFactoryTriggers(); - - // invoke the operation and iterate over the result - await foreach (DataFactoryTriggerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryTriggerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_TriggersCreate() @@ -77,7 +41,7 @@ public async Task CreateOrUpdate_TriggersCreate() // invoke the operation string triggerName = "exampleTrigger"; - DataFactoryTriggerData data = new DataFactoryTriggerData(new DataFactoryScheduleTrigger(new ScheduleTriggerRecurrence() + DataFactoryTriggerData data = new DataFactoryTriggerData(new DataFactoryScheduleTrigger(new ScheduleTriggerRecurrence { Frequency = DataFactoryRecurrenceFrequency.Minute, Interval = 4, @@ -86,17 +50,17 @@ public async Task CreateOrUpdate_TriggersCreate() TimeZone = "UTC", }) { - Pipelines = -{ -new TriggerPipelineReference() + Pipelines = {new TriggerPipelineReference { -PipelineReference = new DataFactoryPipelineReference(DataFactoryPipelineReferenceType.PipelineReference,"examplePipeline"), +PipelineReference = new DataFactoryPipelineReference(DataFactoryPipelineReferenceType.PipelineReference, "examplePipeline"), Parameters = { -["OutputBlobNameList"] = BinaryData.FromObjectAsJson(new object[] { "exampleoutput.csv" }), -}, -} +["OutputBlobNameList"] = BinaryData.FromObjectAsJson(new object[] +{ +"exampleoutput.csv" +}) }, +}}, }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, triggerName, data); DataFactoryTriggerResource result = lro.Value; @@ -133,7 +97,7 @@ public async Task CreateOrUpdate_TriggersUpdate() // invoke the operation string triggerName = "exampleTrigger"; - DataFactoryTriggerData data = new DataFactoryTriggerData(new DataFactoryScheduleTrigger(new ScheduleTriggerRecurrence() + DataFactoryTriggerData data = new DataFactoryTriggerData(new DataFactoryScheduleTrigger(new ScheduleTriggerRecurrence { Frequency = DataFactoryRecurrenceFrequency.Minute, Interval = 4, @@ -142,17 +106,17 @@ public async Task CreateOrUpdate_TriggersUpdate() TimeZone = "UTC", }) { - Pipelines = + Pipelines = {new TriggerPipelineReference { -new TriggerPipelineReference() -{ -PipelineReference = new DataFactoryPipelineReference(DataFactoryPipelineReferenceType.PipelineReference,"examplePipeline"), +PipelineReference = new DataFactoryPipelineReference(DataFactoryPipelineReferenceType.PipelineReference, "examplePipeline"), Parameters = { -["OutputBlobNameList"] = BinaryData.FromObjectAsJson(new object[] { "exampleoutput.csv" }), -}, -} +["OutputBlobNameList"] = BinaryData.FromObjectAsJson(new object[] +{ +"exampleoutput.csv" +}) }, +}}, Description = "Example description", }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, triggerName, data); @@ -199,6 +163,42 @@ public async Task Get_TriggersGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_TriggersListByFactory() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Triggers_ListByFactory.json + // this example is just showing the usage of "Triggers_ListByFactory" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DataFactoryResource created on azure + // for more information of creating DataFactoryResource, please refer to the document of DataFactoryResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + string resourceGroupName = "exampleResourceGroup"; + string factoryName = "exampleFactoryName"; + ResourceIdentifier dataFactoryResourceId = DataFactoryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, factoryName); + DataFactoryResource dataFactory = client.GetDataFactoryResource(dataFactoryResourceId); + + // get the collection of this DataFactoryTriggerResource + DataFactoryTriggerCollection collection = dataFactory.GetDataFactoryTriggers(); + + // invoke the operation and iterate over the result + await foreach (DataFactoryTriggerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryTriggerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_TriggersGet() diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryTriggerResource.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryTriggerResource.cs index 0b0aea010160e..4a47ae57fb1f8 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryTriggerResource.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_DataFactoryTriggerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DataFactoryTriggerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TriggersCreate() + public async Task Get_TriggersGet() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Triggers_Create.json - // this example is just showing the usage of "Triggers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Triggers_Get.json + // this example is just showing the usage of "Triggers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,29 +38,7 @@ public async Task Update_TriggersCreate() DataFactoryTriggerResource dataFactoryTrigger = client.GetDataFactoryTriggerResource(dataFactoryTriggerResourceId); // invoke the operation - DataFactoryTriggerData data = new DataFactoryTriggerData(new DataFactoryScheduleTrigger(new ScheduleTriggerRecurrence() - { - Frequency = DataFactoryRecurrenceFrequency.Minute, - Interval = 4, - StartOn = DateTimeOffset.Parse("2018-06-16T00:39:13.8441801Z"), - EndOn = DateTimeOffset.Parse("2018-06-16T00:55:13.8441801Z"), - TimeZone = "UTC", - }) - { - Pipelines = -{ -new TriggerPipelineReference() -{ -PipelineReference = new DataFactoryPipelineReference(DataFactoryPipelineReferenceType.PipelineReference,"examplePipeline"), -Parameters = -{ -["OutputBlobNameList"] = BinaryData.FromObjectAsJson(new object[] { "exampleoutput.csv" }), -}, -} -}, - }); - ArmOperation lro = await dataFactoryTrigger.UpdateAsync(WaitUntil.Completed, data); - DataFactoryTriggerResource result = lro.Value; + DataFactoryTriggerResource result = await dataFactoryTrigger.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -71,10 +49,10 @@ public async Task Update_TriggersCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TriggersUpdate() + public async Task Delete_TriggersDelete() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Triggers_Update.json - // this example is just showing the usage of "Triggers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Triggers_Delete.json + // this example is just showing the usage of "Triggers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,44 +69,17 @@ public async Task Update_TriggersUpdate() DataFactoryTriggerResource dataFactoryTrigger = client.GetDataFactoryTriggerResource(dataFactoryTriggerResourceId); // invoke the operation - DataFactoryTriggerData data = new DataFactoryTriggerData(new DataFactoryScheduleTrigger(new ScheduleTriggerRecurrence() - { - Frequency = DataFactoryRecurrenceFrequency.Minute, - Interval = 4, - StartOn = DateTimeOffset.Parse("2018-06-16T00:39:14.905167Z"), - EndOn = DateTimeOffset.Parse("2018-06-16T00:55:14.905167Z"), - TimeZone = "UTC", - }) - { - Pipelines = -{ -new TriggerPipelineReference() -{ -PipelineReference = new DataFactoryPipelineReference(DataFactoryPipelineReferenceType.PipelineReference,"examplePipeline"), -Parameters = -{ -["OutputBlobNameList"] = BinaryData.FromObjectAsJson(new object[] { "exampleoutput.csv" }), -}, -} -}, - Description = "Example description", - }); - ArmOperation lro = await dataFactoryTrigger.UpdateAsync(WaitUntil.Completed, data); - DataFactoryTriggerResource result = lro.Value; + await dataFactoryTrigger.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataFactoryTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TriggersGet() + public async Task Update_TriggersCreate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Triggers_Get.json - // this example is just showing the usage of "Triggers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Triggers_Create.json + // this example is just showing the usage of "Triggers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,7 +96,29 @@ public async Task Get_TriggersGet() DataFactoryTriggerResource dataFactoryTrigger = client.GetDataFactoryTriggerResource(dataFactoryTriggerResourceId); // invoke the operation - DataFactoryTriggerResource result = await dataFactoryTrigger.GetAsync(); + DataFactoryTriggerData data = new DataFactoryTriggerData(new DataFactoryScheduleTrigger(new ScheduleTriggerRecurrence + { + Frequency = DataFactoryRecurrenceFrequency.Minute, + Interval = 4, + StartOn = DateTimeOffset.Parse("2018-06-16T00:39:13.8441801Z"), + EndOn = DateTimeOffset.Parse("2018-06-16T00:55:13.8441801Z"), + TimeZone = "UTC", + }) + { + Pipelines = {new TriggerPipelineReference +{ +PipelineReference = new DataFactoryPipelineReference(DataFactoryPipelineReferenceType.PipelineReference, "examplePipeline"), +Parameters = +{ +["OutputBlobNameList"] = BinaryData.FromObjectAsJson(new object[] +{ +"exampleoutput.csv" +}) +}, +}}, + }); + ArmOperation lro = await dataFactoryTrigger.UpdateAsync(WaitUntil.Completed, data); + DataFactoryTriggerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -156,10 +129,10 @@ public async Task Get_TriggersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_TriggersDelete() + public async Task Update_TriggersUpdate() { - // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Triggers_Delete.json - // this example is just showing the usage of "Triggers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Triggers_Update.json + // this example is just showing the usage of "Triggers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,9 +149,36 @@ public async Task Delete_TriggersDelete() DataFactoryTriggerResource dataFactoryTrigger = client.GetDataFactoryTriggerResource(dataFactoryTriggerResourceId); // invoke the operation - await dataFactoryTrigger.DeleteAsync(WaitUntil.Completed); + DataFactoryTriggerData data = new DataFactoryTriggerData(new DataFactoryScheduleTrigger(new ScheduleTriggerRecurrence + { + Frequency = DataFactoryRecurrenceFrequency.Minute, + Interval = 4, + StartOn = DateTimeOffset.Parse("2018-06-16T00:39:14.905167Z"), + EndOn = DateTimeOffset.Parse("2018-06-16T00:55:14.905167Z"), + TimeZone = "UTC", + }) + { + Pipelines = {new TriggerPipelineReference +{ +PipelineReference = new DataFactoryPipelineReference(DataFactoryPipelineReferenceType.PipelineReference, "examplePipeline"), +Parameters = +{ +["OutputBlobNameList"] = BinaryData.FromObjectAsJson(new object[] +{ +"exampleoutput.csv" +}) +}, +}}, + Description = "Example description", + }); + ArmOperation lro = await dataFactoryTrigger.UpdateAsync(WaitUntil.Completed, data); + DataFactoryTriggerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index b0ad8f0f3c778..029e1067dec4f 100644 --- a/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/datafactory/Azure.ResourceManager.DataFactory/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,75 @@ namespace Azure.ResourceManager.DataFactory.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataFactories_FactoriesList() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_List.json + // this example is just showing the usage of "Factories_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataFactoryResource item in subscriptionResource.GetDataFactoriesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task ConfigureFactoryRepoInformation_FactoriesConfigureFactoryRepo() + { + // Generated from example definition: specification/datafactory/resource-manager/Microsoft.DataFactory/stable/2018-06-01/examples/Factories_ConfigureFactoryRepo.json + // this example is just showing the usage of "Factories_ConfigureFactoryRepo" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "12345678-1234-1234-1234-12345678abc"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation locationId = new AzureLocation("East US"); + FactoryRepoContent content = new FactoryRepoContent + { + FactoryResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-12345678abc/resourceGroups/exampleResourceGroup/providers/Microsoft.DataFactory/factories/exampleFactoryName"), + RepoConfiguration = new FactoryVstsConfiguration("ADF", "repo", "master", "/", "project") + { + TenantId = Guid.Parse(""), + LastCommitId = "", + }, + }; + DataFactoryResource result = await subscriptionResource.ConfigureFactoryRepoInformationAsync(locationId, content); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataFactoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetFeatureValueExposureControl_ExposureControlGetFeatureValue() @@ -37,7 +106,7 @@ public async Task GetFeatureValueExposureControl_ExposureControlGetFeatureValue( // invoke the operation AzureLocation locationId = new AzureLocation("WestEurope"); - ExposureControlContent content = new ExposureControlContent() + ExposureControlContent content = new ExposureControlContent { FeatureName = "ADFIntegrationRuntimeSharingRbac", FeatureType = "Feature", diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsAccountCollection.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsAccountCollection.cs index 1fce4eab4bbe7..d8c9ff1024221 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsAccountCollection.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsAccountCollection.cs @@ -18,38 +18,6 @@ namespace Azure.ResourceManager.DataLakeAnalytics.Samples { public partial class Sample_DataLakeAnalyticsAccountCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheFirstPageOfDataLakeAnalyticsAccountsIfAnyWithinASpecificResourceGroupThisIncludesALinkToTheNextPageIfAny() - { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/Accounts_ListByResourceGroup.json - // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "contosorg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this DataLakeAnalyticsAccountResource - DataLakeAnalyticsAccountCollection collection = resourceGroupResource.GetDataLakeAnalyticsAccounts(); - - // invoke the operation and iterate over the result - DataLakeAnalyticsAccountCollectionGetAllOptions options = new DataLakeAnalyticsAccountCollectionGetAllOptions() { Filter = "test_filter", Top = 1, Skip = 1, Select = "test_select", Orderby = "test_orderby", Count = false }; - await foreach (DataLakeAnalyticsAccountBasic item in collection.GetAllAsync(options)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreatesTheSpecifiedDataLakeAnalyticsAccountThisSuppliesTheUserWithComputationServicesForDataLakeAnalyticsWorkloads() @@ -84,27 +52,18 @@ public async Task CreateOrUpdate_CreatesTheSpecifiedDataLakeAnalyticsAccountThis { Tags = { -["test_key"] = "test_value", +["test_key"] = "test_value" }, - StorageAccounts = -{ -new StorageAccountForDataLakeAnalyticsAccountCreateOrUpdateContent("test_storage","34adfa4f-cedf-4dc0-ba29-b6d1a69ab346") + StorageAccounts = {new StorageAccountForDataLakeAnalyticsAccountCreateOrUpdateContent("test_storage", "34adfa4f-cedf-4dc0-ba29-b6d1a69ab346") { Suffix = "test_suffix", -} -}, - ComputePolicies = -{ -new ComputePolicyForDataLakeAnalyticsAccountCreateOrUpdateContent("test_policy",Guid.Parse("34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"),AadObjectIdentifierType.User) +}}, + ComputePolicies = {new ComputePolicyForDataLakeAnalyticsAccountCreateOrUpdateContent("test_policy", Guid.Parse("34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"), AadObjectIdentifierType.User) { MaxDegreeOfParallelismPerJob = 1, MinPriorityPerJob = 1, -} -}, - FirewallRules = -{ -new FirewallRuleForDataLakeAnalyticsAccountCreateOrUpdateContent("test_rule",IPAddress.Parse("1.1.1.1"),IPAddress.Parse("2.2.2.2")) -}, +}}, + FirewallRules = { new FirewallRuleForDataLakeAnalyticsAccountCreateOrUpdateContent("test_rule", IPAddress.Parse("1.1.1.1"), IPAddress.Parse("2.2.2.2")) }, FirewallState = DataLakeAnalyticsFirewallState.Enabled, FirewallAllowAzureIPs = DataLakeAnalyticsFirewallAllowAzureIPsState.Enabled, NewTier = DataLakeAnalyticsCommitmentTierType.Consumption, @@ -157,6 +116,38 @@ public async Task Get_GetsDetailsOfTheSpecifiedDataLakeAnalyticsAccount() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetsTheFirstPageOfDataLakeAnalyticsAccountsIfAnyWithinASpecificResourceGroupThisIncludesALinkToTheNextPageIfAny() + { + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/Accounts_ListByResourceGroup.json + // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "contosorg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this DataLakeAnalyticsAccountResource + DataLakeAnalyticsAccountCollection collection = resourceGroupResource.GetDataLakeAnalyticsAccounts(); + + // invoke the operation and iterate over the result + DataLakeAnalyticsAccountCollectionGetAllOptions options = new DataLakeAnalyticsAccountCollectionGetAllOptions { Filter = "test_filter", Top = 1, Skip = 1, Select = "test_select", Orderby = "test_orderby", Count = false }; + await foreach (DataLakeAnalyticsAccountBasic item in collection.GetAllAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetsDetailsOfTheSpecifiedDataLakeAnalyticsAccount() diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsAccountResource.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsAccountResource.cs index c3215724c6363..f0c6e0b234047 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsAccountResource.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsAccountResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DataLakeAnalytics.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DataLakeAnalytics.Samples @@ -20,38 +19,40 @@ public partial class Sample_DataLakeAnalyticsAccountResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAccounts_GetsTheFirstPageOfDataLakeAnalyticsAccountsIfAnyWithinTheCurrentSubscriptionThisIncludesALinkToTheNextPageIfAny() + public async Task Get_GetsDetailsOfTheSpecifiedDataLakeAnalyticsAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/Accounts_List.json - // this example is just showing the usage of "Accounts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/Accounts_Get.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this DataLakeAnalyticsAccountResource created on azure + // for more information of creating DataLakeAnalyticsAccountResource, please refer to the document of DataLakeAnalyticsAccountResource string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "contosorg"; + string accountName = "contosoadla"; + ResourceIdentifier dataLakeAnalyticsAccountResourceId = DataLakeAnalyticsAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + DataLakeAnalyticsAccountResource dataLakeAnalyticsAccount = client.GetDataLakeAnalyticsAccountResource(dataLakeAnalyticsAccountResourceId); - // invoke the operation and iterate over the result - SubscriptionResourceGetAccountsOptions options = new SubscriptionResourceGetAccountsOptions() { Filter = "test_filter", Top = 1, Skip = 1, Select = "test_select", Orderby = "test_orderby", Count = false }; - await foreach (DataLakeAnalyticsAccountBasic item in subscriptionResource.GetAccountsAsync(options)) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + DataLakeAnalyticsAccountResource result = await dataLakeAnalyticsAccount.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsDetailsOfTheSpecifiedDataLakeAnalyticsAccount() + public async Task Delete_BeginsTheDeleteProcessForTheDataLakeAnalyticsAccountObjectSpecifiedByTheAccountName() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/Accounts_Get.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/Accounts_Delete.json + // this example is just showing the usage of "Accounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +68,9 @@ public async Task Get_GetsDetailsOfTheSpecifiedDataLakeAnalyticsAccount() DataLakeAnalyticsAccountResource dataLakeAnalyticsAccount = client.GetDataLakeAnalyticsAccountResource(dataLakeAnalyticsAccountResourceId); // invoke the operation - DataLakeAnalyticsAccountResource result = await dataLakeAnalyticsAccount.GetAsync(); + await dataLakeAnalyticsAccount.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,30 +94,24 @@ public async Task Update_UpdatesTheDataLakeAnalyticsAccountObjectSpecifiedByTheA DataLakeAnalyticsAccountResource dataLakeAnalyticsAccount = client.GetDataLakeAnalyticsAccountResource(dataLakeAnalyticsAccountResourceId); // invoke the operation - DataLakeAnalyticsAccountPatch patch = new DataLakeAnalyticsAccountPatch() + DataLakeAnalyticsAccountPatch patch = new DataLakeAnalyticsAccountPatch { Tags = { -["test_key"] = "test_value", +["test_key"] = "test_value" }, - ComputePolicies = -{ -new ComputePolicyForDataLakeAnalyticsAccountUpdateContent("test_policy") + ComputePolicies = {new ComputePolicyForDataLakeAnalyticsAccountUpdateContent("test_policy") { ObjectId = Guid.Parse("34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"), ObjectType = AadObjectIdentifierType.User, MaxDegreeOfParallelismPerJob = 1, MinPriorityPerJob = 1, -} -}, - FirewallRules = -{ -new FirewallRuleForDataLakeAnalyticsAccountUpdateContent("test_rule") +}}, + FirewallRules = {new FirewallRuleForDataLakeAnalyticsAccountUpdateContent("test_rule") { StartIPAddress = IPAddress.Parse("1.1.1.1"), EndIPAddress = IPAddress.Parse("2.2.2.2"), -} -}, +}}, FirewallState = DataLakeAnalyticsFirewallState.Enabled, FirewallAllowAzureIPs = DataLakeAnalyticsFirewallAllowAzureIPsState.Enabled, NewTier = DataLakeAnalyticsCommitmentTierType.Consumption, @@ -139,57 +130,5 @@ public async Task Update_UpdatesTheDataLakeAnalyticsAccountObjectSpecifiedByTheA // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_BeginsTheDeleteProcessForTheDataLakeAnalyticsAccountObjectSpecifiedByTheAccountName() - { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/Accounts_Delete.json - // this example is just showing the usage of "Accounts_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DataLakeAnalyticsAccountResource created on azure - // for more information of creating DataLakeAnalyticsAccountResource, please refer to the document of DataLakeAnalyticsAccountResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "contosorg"; - string accountName = "contosoadla"; - ResourceIdentifier dataLakeAnalyticsAccountResourceId = DataLakeAnalyticsAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - DataLakeAnalyticsAccountResource dataLakeAnalyticsAccount = client.GetDataLakeAnalyticsAccountResource(dataLakeAnalyticsAccountResourceId); - - // invoke the operation - await dataLakeAnalyticsAccount.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckDataLakeAnalyticsAccountNameAvailability_ChecksWhetherTheSpecifiedAccountNameIsAvailableOrTaken() - { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/Accounts_CheckNameAvailability.json - // this example is just showing the usage of "Accounts_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("EastUS2"); - DataLakeAnalyticsAccountNameAvailabilityContent content = new DataLakeAnalyticsAccountNameAvailabilityContent("contosoadla", DataLakeAnalyticsResourceType.MicrosoftDataLakeAnalyticsAccounts); - DataLakeAnalyticsAccountNameAvailabilityResult result = await subscriptionResource.CheckDataLakeAnalyticsAccountNameAvailabilityAsync(location, content); - - Console.WriteLine($"Succeeded: {result}"); - } } } diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsComputePolicyCollection.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsComputePolicyCollection.cs index d96297e80cdd4..07b2cd30dedea 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsComputePolicyCollection.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsComputePolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataLakeAnalyticsComputePolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheComputePoliciesWithinTheAdlaAccount() + public async Task CreateOrUpdate_CreatesOrUpdatesTheSpecifiedComputePolicy() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/ComputePolicies_ListByAccount.json - // this example is just showing the usage of "ComputePolicies_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/ComputePolicies_CreateOrUpdate.json + // this example is just showing the usage of "ComputePolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,29 @@ public async Task GetAll_ListsTheComputePoliciesWithinTheAdlaAccount() // get the collection of this DataLakeAnalyticsComputePolicyResource DataLakeAnalyticsComputePolicyCollection collection = dataLakeAnalyticsAccount.GetDataLakeAnalyticsComputePolicies(); - // invoke the operation and iterate over the result - await foreach (DataLakeAnalyticsComputePolicyResource item in collection.GetAllAsync()) + // invoke the operation + string computePolicyName = "test_policy"; + DataLakeAnalyticsComputePolicyCreateOrUpdateContent content = new DataLakeAnalyticsComputePolicyCreateOrUpdateContent(Guid.Parse("776b9091-8916-4638-87f7-9c989a38da98"), AadObjectIdentifierType.User) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsComputePolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + MaxDegreeOfParallelismPerJob = 10, + MinPriorityPerJob = 30, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computePolicyName, content); + DataLakeAnalyticsComputePolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsComputePolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesTheSpecifiedComputePolicy() + public async Task Get_GetsTheSpecifiedComputePolicy() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/ComputePolicies_CreateOrUpdate.json - // this example is just showing the usage of "ComputePolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/ComputePolicies_Get.json + // this example is just showing the usage of "ComputePolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,13 +81,7 @@ public async Task CreateOrUpdate_CreatesOrUpdatesTheSpecifiedComputePolicy() // invoke the operation string computePolicyName = "test_policy"; - DataLakeAnalyticsComputePolicyCreateOrUpdateContent content = new DataLakeAnalyticsComputePolicyCreateOrUpdateContent(Guid.Parse("776b9091-8916-4638-87f7-9c989a38da98"), AadObjectIdentifierType.User) - { - MaxDegreeOfParallelismPerJob = 10, - MinPriorityPerJob = 30, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computePolicyName, content); - DataLakeAnalyticsComputePolicyResource result = lro.Value; + DataLakeAnalyticsComputePolicyResource result = await collection.GetAsync(computePolicyName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -94,10 +92,10 @@ public async Task CreateOrUpdate_CreatesOrUpdatesTheSpecifiedComputePolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheSpecifiedComputePolicy() + public async Task GetAll_ListsTheComputePoliciesWithinTheAdlaAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/ComputePolicies_Get.json - // this example is just showing the usage of "ComputePolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/ComputePolicies_ListByAccount.json + // this example is just showing the usage of "ComputePolicies_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,15 +113,17 @@ public async Task Get_GetsTheSpecifiedComputePolicy() // get the collection of this DataLakeAnalyticsComputePolicyResource DataLakeAnalyticsComputePolicyCollection collection = dataLakeAnalyticsAccount.GetDataLakeAnalyticsComputePolicies(); - // invoke the operation - string computePolicyName = "test_policy"; - DataLakeAnalyticsComputePolicyResource result = await collection.GetAsync(computePolicyName); + // invoke the operation and iterate over the result + await foreach (DataLakeAnalyticsComputePolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsComputePolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsComputePolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsComputePolicyResource.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsComputePolicyResource.cs index c061b0583bce1..950f048d01f08 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsComputePolicyResource.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsComputePolicyResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsTheSpecifiedComputePolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesTheSpecifiedComputePolicy() + public async Task Delete_DeletesTheSpecifiedComputePolicyFromTheAdlaAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/ComputePolicies_Update.json - // this example is just showing the usage of "ComputePolicies_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/ComputePolicies_Delete.json + // this example is just showing the usage of "ComputePolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_UpdatesTheSpecifiedComputePolicy() DataLakeAnalyticsComputePolicyResource dataLakeAnalyticsComputePolicy = client.GetDataLakeAnalyticsComputePolicyResource(dataLakeAnalyticsComputePolicyResourceId); // invoke the operation - DataLakeAnalyticsComputePolicyPatch patch = new DataLakeAnalyticsComputePolicyPatch() - { - MaxDegreeOfParallelismPerJob = 11, - MinPriorityPerJob = 31, - }; - DataLakeAnalyticsComputePolicyResource result = await dataLakeAnalyticsComputePolicy.UpdateAsync(patch); + await dataLakeAnalyticsComputePolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsComputePolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesTheSpecifiedComputePolicyFromTheAdlaAccount() + public async Task Update_UpdatesTheSpecifiedComputePolicy() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/ComputePolicies_Delete.json - // this example is just showing the usage of "ComputePolicies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/ComputePolicies_Update.json + // this example is just showing the usage of "ComputePolicies_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeletesTheSpecifiedComputePolicyFromTheAdlaAccount() DataLakeAnalyticsComputePolicyResource dataLakeAnalyticsComputePolicy = client.GetDataLakeAnalyticsComputePolicyResource(dataLakeAnalyticsComputePolicyResourceId); // invoke the operation - await dataLakeAnalyticsComputePolicy.DeleteAsync(WaitUntil.Completed); + DataLakeAnalyticsComputePolicyPatch patch = new DataLakeAnalyticsComputePolicyPatch + { + MaxDegreeOfParallelismPerJob = 11, + MinPriorityPerJob = 31, + }; + DataLakeAnalyticsComputePolicyResource result = await dataLakeAnalyticsComputePolicy.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsComputePolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsFirewallRuleCollection.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsFirewallRuleCollection.cs index 29694c343c70a..d9fe36db078f9 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsFirewallRuleCollection.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsFirewallRuleCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DataLakeAnalyticsFirewallRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheDataLakeAnalyticsFirewallRules() + public async Task CreateOrUpdate_CreatesOrUpdatesTheSpecifiedFirewallRule() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/FirewallRules_ListByAccount.json - // this example is just showing the usage of "FirewallRules_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/FirewallRules_CreateOrUpdate.json + // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,25 @@ public async Task GetAll_ListsTheDataLakeAnalyticsFirewallRules() // get the collection of this DataLakeAnalyticsFirewallRuleResource DataLakeAnalyticsFirewallRuleCollection collection = dataLakeAnalyticsAccount.GetDataLakeAnalyticsFirewallRules(); - // invoke the operation and iterate over the result - await foreach (DataLakeAnalyticsFirewallRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsFirewallRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string firewallRuleName = "test_rule"; + DataLakeAnalyticsFirewallRuleCreateOrUpdateContent content = new DataLakeAnalyticsFirewallRuleCreateOrUpdateContent(IPAddress.Parse("1.1.1.1"), IPAddress.Parse("2.2.2.2")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, content); + DataLakeAnalyticsFirewallRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesTheSpecifiedFirewallRule() + public async Task Get_GetsTheSpecifiedDataLakeAnalyticsFirewallRule() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/FirewallRules_CreateOrUpdate.json - // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/FirewallRules_Get.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,9 +78,7 @@ public async Task CreateOrUpdate_CreatesOrUpdatesTheSpecifiedFirewallRule() // invoke the operation string firewallRuleName = "test_rule"; - DataLakeAnalyticsFirewallRuleCreateOrUpdateContent content = new DataLakeAnalyticsFirewallRuleCreateOrUpdateContent(IPAddress.Parse("1.1.1.1"), IPAddress.Parse("2.2.2.2")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, content); - DataLakeAnalyticsFirewallRuleResource result = lro.Value; + DataLakeAnalyticsFirewallRuleResource result = await collection.GetAsync(firewallRuleName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -91,10 +89,10 @@ public async Task CreateOrUpdate_CreatesOrUpdatesTheSpecifiedFirewallRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheSpecifiedDataLakeAnalyticsFirewallRule() + public async Task GetAll_ListsTheDataLakeAnalyticsFirewallRules() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/FirewallRules_Get.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/FirewallRules_ListByAccount.json + // this example is just showing the usage of "FirewallRules_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,15 +110,17 @@ public async Task Get_GetsTheSpecifiedDataLakeAnalyticsFirewallRule() // get the collection of this DataLakeAnalyticsFirewallRuleResource DataLakeAnalyticsFirewallRuleCollection collection = dataLakeAnalyticsAccount.GetDataLakeAnalyticsFirewallRules(); - // invoke the operation - string firewallRuleName = "test_rule"; - DataLakeAnalyticsFirewallRuleResource result = await collection.GetAsync(firewallRuleName); + // invoke the operation and iterate over the result + await foreach (DataLakeAnalyticsFirewallRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsFirewallRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsFirewallRuleResource.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsFirewallRuleResource.cs index 3182bd50d1d0c..aa0352e3022eb 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsFirewallRuleResource.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsFirewallRuleResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetsTheSpecifiedDataLakeAnalyticsFirewallRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesTheSpecifiedFirewallRule() + public async Task Delete_DeletesTheSpecifiedFirewallRule() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/FirewallRules_Update.json - // this example is just showing the usage of "FirewallRules_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/FirewallRules_Delete.json + // this example is just showing the usage of "FirewallRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_UpdatesTheSpecifiedFirewallRule() DataLakeAnalyticsFirewallRuleResource dataLakeAnalyticsFirewallRule = client.GetDataLakeAnalyticsFirewallRuleResource(dataLakeAnalyticsFirewallRuleResourceId); // invoke the operation - DataLakeAnalyticsFirewallRulePatch patch = new DataLakeAnalyticsFirewallRulePatch() - { - StartIPAddress = IPAddress.Parse("1.1.1.1"), - EndIPAddress = IPAddress.Parse("2.2.2.2"), - }; - DataLakeAnalyticsFirewallRuleResource result = await dataLakeAnalyticsFirewallRule.UpdateAsync(patch); + await dataLakeAnalyticsFirewallRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesTheSpecifiedFirewallRule() + public async Task Update_UpdatesTheSpecifiedFirewallRule() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/FirewallRules_Delete.json - // this example is just showing the usage of "FirewallRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/FirewallRules_Update.json + // this example is just showing the usage of "FirewallRules_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +97,18 @@ public async Task Delete_DeletesTheSpecifiedFirewallRule() DataLakeAnalyticsFirewallRuleResource dataLakeAnalyticsFirewallRule = client.GetDataLakeAnalyticsFirewallRuleResource(dataLakeAnalyticsFirewallRuleResourceId); // invoke the operation - await dataLakeAnalyticsFirewallRule.DeleteAsync(WaitUntil.Completed); + DataLakeAnalyticsFirewallRulePatch patch = new DataLakeAnalyticsFirewallRulePatch + { + StartIPAddress = IPAddress.Parse("1.1.1.1"), + EndIPAddress = IPAddress.Parse("2.2.2.2"), + }; + DataLakeAnalyticsFirewallRuleResource result = await dataLakeAnalyticsFirewallRule.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageAccountInformationCollection.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageAccountInformationCollection.cs index 3ea156b4055f8..4c22e765554d4 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageAccountInformationCollection.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageAccountInformationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataLakeAnalyticsStorageAccountInformationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheFirstPageOfAzureStorageAccountsLinkedToTheSpecifiedDataLakeAnalyticsAccount() + public async Task CreateOrUpdate_AddsAnAzureStorageAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_ListByAccount.json - // this example is just showing the usage of "StorageAccounts_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_Add.json + // this example is just showing the usage of "StorageAccounts_Add" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,26 +39,23 @@ public async Task GetAll_GetsTheFirstPageOfAzureStorageAccountsLinkedToTheSpecif // get the collection of this DataLakeAnalyticsStorageAccountInformationResource DataLakeAnalyticsStorageAccountInformationCollection collection = dataLakeAnalyticsAccount.GetAllDataLakeAnalyticsStorageAccountInformation(); - // invoke the operation and iterate over the result - DataLakeAnalyticsStorageAccountInformationCollectionGetAllOptions options = new DataLakeAnalyticsStorageAccountInformationCollectionGetAllOptions() { Filter = "test_filter", Top = 1, Skip = 1, Select = "test_select", Orderby = "test_orderby", Count = false }; - await foreach (DataLakeAnalyticsStorageAccountInformationResource item in collection.GetAllAsync(options)) + // invoke the operation + string storageAccountName = "test_storage"; + DataLakeAnalyticsStorageAccountInformationCreateOrUpdateContent content = new DataLakeAnalyticsStorageAccountInformationCreateOrUpdateContent("34adfa4f-cedf-4dc0-ba29-b6d1a69ab346") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsStorageAccountInformationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Suffix = "test_suffix", + }; + await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageAccountName, content); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddsAnAzureStorageAccount() + public async Task Get_GetsTheSpecifiedAzureStorageAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_Add.json - // this example is just showing the usage of "StorageAccounts_Add" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_Get.json + // this example is just showing the usage of "StorageAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,21 +75,21 @@ public async Task CreateOrUpdate_AddsAnAzureStorageAccount() // invoke the operation string storageAccountName = "test_storage"; - DataLakeAnalyticsStorageAccountInformationCreateOrUpdateContent content = new DataLakeAnalyticsStorageAccountInformationCreateOrUpdateContent("34adfa4f-cedf-4dc0-ba29-b6d1a69ab346") - { - Suffix = "test_suffix", - }; - await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageAccountName, content); + DataLakeAnalyticsStorageAccountInformationResource result = await collection.GetAsync(storageAccountName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsStorageAccountInformationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheSpecifiedAzureStorageAccount() + public async Task GetAll_GetsTheFirstPageOfAzureStorageAccountsLinkedToTheSpecifiedDataLakeAnalyticsAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_Get.json - // this example is just showing the usage of "StorageAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_ListByAccount.json + // this example is just showing the usage of "StorageAccounts_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,15 +107,18 @@ public async Task Get_GetsTheSpecifiedAzureStorageAccount() // get the collection of this DataLakeAnalyticsStorageAccountInformationResource DataLakeAnalyticsStorageAccountInformationCollection collection = dataLakeAnalyticsAccount.GetAllDataLakeAnalyticsStorageAccountInformation(); - // invoke the operation - string storageAccountName = "test_storage"; - DataLakeAnalyticsStorageAccountInformationResource result = await collection.GetAsync(storageAccountName); + // invoke the operation and iterate over the result + DataLakeAnalyticsStorageAccountInformationCollectionGetAllOptions options = new DataLakeAnalyticsStorageAccountInformationCollectionGetAllOptions { Filter = "test_filter", Top = 1, Skip = 1, Select = "test_select", Orderby = "test_orderby", Count = false }; + await foreach (DataLakeAnalyticsStorageAccountInformationResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsStorageAccountInformationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsStorageAccountInformationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageAccountInformationResource.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageAccountInformationResource.cs index 6d69b3c9cb02b..46484d1b12a8f 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageAccountInformationResource.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageAccountInformationResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsTheSpecifiedAzureStorageAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ReplacesAzureStorageBlobAccountDetails() + public async Task Delete_RemovesAnAzureStorageAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_Update.json - // this example is just showing the usage of "StorageAccounts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_Delete.json + // this example is just showing the usage of "StorageAccounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,22 +69,17 @@ public async Task Update_ReplacesAzureStorageBlobAccountDetails() DataLakeAnalyticsStorageAccountInformationResource dataLakeAnalyticsStorageAccountInformation = client.GetDataLakeAnalyticsStorageAccountInformationResource(dataLakeAnalyticsStorageAccountInformationResourceId); // invoke the operation - DataLakeAnalyticsStorageAccountInformationPatch patch = new DataLakeAnalyticsStorageAccountInformationPatch() - { - AccessKey = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab346", - Suffix = "test_suffix", - }; - await dataLakeAnalyticsStorageAccountInformation.UpdateAsync(patch); + await dataLakeAnalyticsStorageAccountInformation.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RemovesAnAzureStorageAccount() + public async Task Update_ReplacesAzureStorageBlobAccountDetails() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_Delete.json - // this example is just showing the usage of "StorageAccounts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_Update.json + // this example is just showing the usage of "StorageAccounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +96,12 @@ public async Task Delete_RemovesAnAzureStorageAccount() DataLakeAnalyticsStorageAccountInformationResource dataLakeAnalyticsStorageAccountInformation = client.GetDataLakeAnalyticsStorageAccountInformationResource(dataLakeAnalyticsStorageAccountInformationResourceId); // invoke the operation - await dataLakeAnalyticsStorageAccountInformation.DeleteAsync(WaitUntil.Completed); + DataLakeAnalyticsStorageAccountInformationPatch patch = new DataLakeAnalyticsStorageAccountInformationPatch + { + AccessKey = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab346", + Suffix = "test_suffix", + }; + await dataLakeAnalyticsStorageAccountInformation.UpdateAsync(patch); Console.WriteLine("Succeeded"); } diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageContainerCollection.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageContainerCollection.cs index 00139b746fc7c..bc057684d75a6 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageContainerCollection.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeAnalyticsStorageContainerCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DataLakeAnalyticsStorageContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheAzureStorageContainers() + public async Task Get_GetsTheSpecifiedAzureStorageContainer() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_ListStorageContainers.json - // this example is just showing the usage of "StorageAccounts_ListStorageContainers" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_GetStorageContainer.json + // this example is just showing the usage of "StorageAccounts_GetStorageContainer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListsTheAzureStorageContainers() // get the collection of this DataLakeAnalyticsStorageContainerResource DataLakeAnalyticsStorageContainerCollection collection = dataLakeAnalyticsStorageAccountInformation.GetDataLakeAnalyticsStorageContainers(); - // invoke the operation and iterate over the result - await foreach (DataLakeAnalyticsStorageContainerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsStorageContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string containerName = "test_container"; + DataLakeAnalyticsStorageContainerResource result = await collection.GetAsync(containerName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsStorageContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheSpecifiedAzureStorageContainer() + public async Task GetAll_ListsTheAzureStorageContainers() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_GetStorageContainer.json - // this example is just showing the usage of "StorageAccounts_GetStorageContainer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/StorageAccounts_ListStorageContainers.json + // this example is just showing the usage of "StorageAccounts_ListStorageContainers" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetsTheSpecifiedAzureStorageContainer() // get the collection of this DataLakeAnalyticsStorageContainerResource DataLakeAnalyticsStorageContainerCollection collection = dataLakeAnalyticsStorageAccountInformation.GetDataLakeAnalyticsStorageContainers(); - // invoke the operation - string containerName = "test_container"; - DataLakeAnalyticsStorageContainerResource result = await collection.GetAsync(containerName); + // invoke the operation and iterate over the result + await foreach (DataLakeAnalyticsStorageContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeAnalyticsStorageContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeAnalyticsStorageContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeStoreAccountInformationCollection.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeStoreAccountInformationCollection.cs index dfa5a6f9873a3..75fbe33c77d42 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeStoreAccountInformationCollection.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeStoreAccountInformationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataLakeStoreAccountInformationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheFirstPageOfDataLakeStoreAccountsLinkedToTheSpecifiedDataLakeAnalyticsAccount() + public async Task CreateOrUpdate_AddsADataLakeStoreAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_ListByAccount.json - // this example is just showing the usage of "DataLakeStoreAccounts_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_Add.json + // this example is just showing the usage of "DataLakeStoreAccounts_Add" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,26 +39,23 @@ public async Task GetAll_GetsTheFirstPageOfDataLakeStoreAccountsLinkedToTheSpeci // get the collection of this DataLakeStoreAccountInformationResource DataLakeStoreAccountInformationCollection collection = dataLakeAnalyticsAccount.GetAllDataLakeStoreAccountInformation(); - // invoke the operation and iterate over the result - DataLakeStoreAccountInformationCollectionGetAllOptions options = new DataLakeStoreAccountInformationCollectionGetAllOptions() { Filter = "test_filter", Top = 1, Skip = 1, Select = "test_select", Orderby = "test_orderby", Count = false }; - await foreach (DataLakeStoreAccountInformationResource item in collection.GetAllAsync(options)) + // invoke the operation + string dataLakeStoreAccountName = "test_adls_account"; + DataLakeStoreAccountInformationCreateOrUpdateContent content = new DataLakeStoreAccountInformationCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeStoreAccountInformationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Suffix = "test_suffix", + }; + await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataLakeStoreAccountName, content); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddsADataLakeStoreAccount() + public async Task Get_GetsTheSpecifiedDataLakeStoreAccountDetails() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_Add.json - // this example is just showing the usage of "DataLakeStoreAccounts_Add" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_Get.json + // this example is just showing the usage of "DataLakeStoreAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,7 +64,7 @@ public async Task CreateOrUpdate_AddsADataLakeStoreAccount() // this example assumes you already have this DataLakeAnalyticsAccountResource created on azure // for more information of creating DataLakeAnalyticsAccountResource, please refer to the document of DataLakeAnalyticsAccountResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1669ab345"; string resourceGroupName = "contosorg"; string accountName = "contosoadla"; ResourceIdentifier dataLakeAnalyticsAccountResourceId = DataLakeAnalyticsAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); @@ -78,21 +75,21 @@ public async Task CreateOrUpdate_AddsADataLakeStoreAccount() // invoke the operation string dataLakeStoreAccountName = "test_adls_account"; - DataLakeStoreAccountInformationCreateOrUpdateContent content = new DataLakeStoreAccountInformationCreateOrUpdateContent() - { - Suffix = "test_suffix", - }; - await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataLakeStoreAccountName, content); + DataLakeStoreAccountInformationResource result = await collection.GetAsync(dataLakeStoreAccountName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeStoreAccountInformationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheSpecifiedDataLakeStoreAccountDetails() + public async Task GetAll_GetsTheFirstPageOfDataLakeStoreAccountsLinkedToTheSpecifiedDataLakeAnalyticsAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_Get.json - // this example is just showing the usage of "DataLakeStoreAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_ListByAccount.json + // this example is just showing the usage of "DataLakeStoreAccounts_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +98,7 @@ public async Task Get_GetsTheSpecifiedDataLakeStoreAccountDetails() // this example assumes you already have this DataLakeAnalyticsAccountResource created on azure // for more information of creating DataLakeAnalyticsAccountResource, please refer to the document of DataLakeAnalyticsAccountResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1669ab345"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "contosorg"; string accountName = "contosoadla"; ResourceIdentifier dataLakeAnalyticsAccountResourceId = DataLakeAnalyticsAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); @@ -110,15 +107,18 @@ public async Task Get_GetsTheSpecifiedDataLakeStoreAccountDetails() // get the collection of this DataLakeStoreAccountInformationResource DataLakeStoreAccountInformationCollection collection = dataLakeAnalyticsAccount.GetAllDataLakeStoreAccountInformation(); - // invoke the operation - string dataLakeStoreAccountName = "test_adls_account"; - DataLakeStoreAccountInformationResource result = await collection.GetAsync(dataLakeStoreAccountName); + // invoke the operation and iterate over the result + DataLakeStoreAccountInformationCollectionGetAllOptions options = new DataLakeStoreAccountInformationCollectionGetAllOptions { Filter = "test_filter", Top = 1, Skip = 1, Select = "test_select", Orderby = "test_orderby", Count = false }; + await foreach (DataLakeStoreAccountInformationResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeStoreAccountInformationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeStoreAccountInformationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeStoreAccountInformationResource.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeStoreAccountInformationResource.cs index ff168c8b42286..48b05a42da2ac 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeStoreAccountInformationResource.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_DataLakeStoreAccountInformationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DataLakeStoreAccountInformationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AddsADataLakeStoreAccount() + public async Task Get_GetsTheSpecifiedDataLakeStoreAccountDetails() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_Add.json - // this example is just showing the usage of "DataLakeStoreAccounts_Add" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_Get.json + // this example is just showing the usage of "DataLakeStoreAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task Update_AddsADataLakeStoreAccount() // this example assumes you already have this DataLakeStoreAccountInformationResource created on azure // for more information of creating DataLakeStoreAccountInformationResource, please refer to the document of DataLakeStoreAccountInformationResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1669ab345"; string resourceGroupName = "contosorg"; string accountName = "contosoadla"; string dataLakeStoreAccountName = "test_adls_account"; @@ -38,21 +38,21 @@ public async Task Update_AddsADataLakeStoreAccount() DataLakeStoreAccountInformationResource dataLakeStoreAccountInformation = client.GetDataLakeStoreAccountInformationResource(dataLakeStoreAccountInformationResourceId); // invoke the operation - DataLakeStoreAccountInformationCreateOrUpdateContent content = new DataLakeStoreAccountInformationCreateOrUpdateContent() - { - Suffix = "test_suffix", - }; - await dataLakeStoreAccountInformation.UpdateAsync(WaitUntil.Completed, content); + DataLakeStoreAccountInformationResource result = await dataLakeStoreAccountInformation.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataLakeStoreAccountInformationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheSpecifiedDataLakeStoreAccountDetails() + public async Task Delete_RemovesTheSpecifiedDataLakeStoreAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_Get.json - // this example is just showing the usage of "DataLakeStoreAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_Delete.json + // this example is just showing the usage of "DataLakeStoreAccounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,7 +61,7 @@ public async Task Get_GetsTheSpecifiedDataLakeStoreAccountDetails() // this example assumes you already have this DataLakeStoreAccountInformationResource created on azure // for more information of creating DataLakeStoreAccountInformationResource, please refer to the document of DataLakeStoreAccountInformationResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1669ab345"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "contosorg"; string accountName = "contosoadla"; string dataLakeStoreAccountName = "test_adls_account"; @@ -69,21 +69,17 @@ public async Task Get_GetsTheSpecifiedDataLakeStoreAccountDetails() DataLakeStoreAccountInformationResource dataLakeStoreAccountInformation = client.GetDataLakeStoreAccountInformationResource(dataLakeStoreAccountInformationResourceId); // invoke the operation - DataLakeStoreAccountInformationResource result = await dataLakeStoreAccountInformation.GetAsync(); + await dataLakeStoreAccountInformation.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataLakeStoreAccountInformationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RemovesTheSpecifiedDataLakeStoreAccount() + public async Task Update_AddsADataLakeStoreAccount() { - // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_Delete.json - // this example is just showing the usage of "DataLakeStoreAccounts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/DataLakeStoreAccounts_Add.json + // this example is just showing the usage of "DataLakeStoreAccounts_Add" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +96,11 @@ public async Task Delete_RemovesTheSpecifiedDataLakeStoreAccount() DataLakeStoreAccountInformationResource dataLakeStoreAccountInformation = client.GetDataLakeStoreAccountInformationResource(dataLakeStoreAccountInformationResourceId); // invoke the operation - await dataLakeStoreAccountInformation.DeleteAsync(WaitUntil.Completed); + DataLakeStoreAccountInformationCreateOrUpdateContent content = new DataLakeStoreAccountInformationCreateOrUpdateContent + { + Suffix = "test_suffix", + }; + await dataLakeStoreAccountInformation.UpdateAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); } diff --git a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 1d16d6ac1b649..7025d88f6beca 100644 --- a/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/datalake-analytics/Azure.ResourceManager.DataLakeAnalytics/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,60 @@ namespace Azure.ResourceManager.DataLakeAnalytics.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAccounts_GetsTheFirstPageOfDataLakeAnalyticsAccountsIfAnyWithinTheCurrentSubscriptionThisIncludesALinkToTheNextPageIfAny() + { + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/Accounts_List.json + // this example is just showing the usage of "Accounts_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + SubscriptionResourceGetAccountsOptions options = new SubscriptionResourceGetAccountsOptions { Filter = "test_filter", Top = 1, Skip = 1, Select = "test_select", Orderby = "test_orderby", Count = false }; + await foreach (DataLakeAnalyticsAccountBasic item in subscriptionResource.GetAccountsAsync(options)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckDataLakeAnalyticsAccountNameAvailability_ChecksWhetherTheSpecifiedAccountNameIsAvailableOrTaken() + { + // Generated from example definition: specification/datalake-analytics/resource-manager/Microsoft.DataLakeAnalytics/stable/2016-11-01/examples/Accounts_CheckNameAvailability.json + // this example is just showing the usage of "Accounts_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("EastUS2"); + DataLakeAnalyticsAccountNameAvailabilityContent content = new DataLakeAnalyticsAccountNameAvailabilityContent("contosoadla", DataLakeAnalyticsResourceType.MicrosoftDataLakeAnalyticsAccounts); + DataLakeAnalyticsAccountNameAvailabilityResult result = await subscriptionResource.CheckDataLakeAnalyticsAccountNameAvailabilityAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetCapabilityLocation_GetsSubscriptionLevelPropertiesAndLimitsForDataLakeAnalyticsSpecifiedByResourceLocation() diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DataMigrationServiceCollection.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DataMigrationServiceCollection.cs index 1628283e5b2a7..70b4d4a90aecd 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DataMigrationServiceCollection.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DataMigrationServiceCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_ServicesCreateOrUpdate() string serviceName = "DmsSdkService"; DataMigrationServiceData data = new DataMigrationServiceData(new AzureLocation("southcentralus")) { - Sku = new ServiceSku() + Sku = new ServiceSku { Name = "Basic_1vCore", }, @@ -94,10 +94,10 @@ public async Task Get_ServicesCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServicesCreateOrUpdate() + public async Task GetAll_ServicesListByResourceGroup() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Services_Get.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Services_ListByResourceGroup.json + // this example is just showing the usage of "Services_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +114,22 @@ public async Task Exists_ServicesCreateOrUpdate() // get the collection of this DataMigrationServiceResource DataMigrationServiceCollection collection = resourceGroupResource.GetDataMigrationServices(); - // invoke the operation - string serviceName = "DmsSdkService"; - bool result = await collection.ExistsAsync(serviceName); + // invoke the operation and iterate over the result + await foreach (DataMigrationServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataMigrationServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServicesCreateOrUpdate() + public async Task Exists_ServicesCreateOrUpdate() { // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Services_Get.json // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +151,17 @@ public async Task GetIfExists_ServicesCreateOrUpdate() // invoke the operation string serviceName = "DmsSdkService"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - DataMigrationServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataMigrationServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServicesListByResourceGroup() + public async Task GetIfExists_ServicesCreateOrUpdate() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Services_ListByResourceGroup.json - // this example is just showing the usage of "Services_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Services_Get.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ServicesListByResourceGroup() // get the collection of this DataMigrationServiceResource DataMigrationServiceCollection collection = resourceGroupResource.GetDataMigrationServices(); - // invoke the operation and iterate over the result - await foreach (DataMigrationServiceResource item in collection.GetAllAsync()) + // invoke the operation + string serviceName = "DmsSdkService"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + DataMigrationServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataMigrationServiceData resourceData = item.Data; + DataMigrationServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DataMigrationServiceResource.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DataMigrationServiceResource.cs index 5bd9a9d00aea0..5eb63ec303b61 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DataMigrationServiceResource.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DataMigrationServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DataMigration.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DataMigration.Samples @@ -236,7 +235,7 @@ public async Task CheckChildrenNameAvailability_ServicesCheckChildrenNameAvailab DataMigrationServiceResource dataMigrationService = client.GetDataMigrationServiceResource(dataMigrationServiceResourceId); // invoke the operation - NameAvailabilityRequest nameAvailabilityRequest = new NameAvailabilityRequest() + NameAvailabilityRequest nameAvailabilityRequest = new NameAvailabilityRequest { Name = "Task1", ResourceType = "tasks", @@ -245,66 +244,5 @@ public async Task CheckChildrenNameAvailability_ServicesCheckChildrenNameAvailab Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDataMigrationServices_ServicesList() - { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Services_List.json - // this example is just showing the usage of "Services_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fc04246f-04c5-437e-ac5e-206a19e7193f"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DataMigrationServiceResource item in subscriptionResource.GetDataMigrationServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataMigrationServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckNameAvailabilityService_ServicesCheckNameAvailability() - { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Services_CheckNameAvailability.json - // this example is just showing the usage of "Services_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fc04246f-04c5-437e-ac5e-206a19e7193f"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("eastus"); - NameAvailabilityRequest nameAvailabilityRequest = new NameAvailabilityRequest() - { - Name = "DmsSdkService", - ResourceType = "services", - }; - NameAvailabilityResponse result = await subscriptionResource.CheckNameAvailabilityServiceAsync(location, nameAvailabilityRequest); - - Console.WriteLine($"Succeeded: {result}"); - } } } diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlDBCollection.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlDBCollection.cs index 1049d254e2f49..334a0b78141e4 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlDBCollection.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlDBCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DatabaseMigrationSqlDBCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSqlDBDatabaseMigrationWithTheExpandParameter() + public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMaximumParameters() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbGetDatabaseMigrationExpanded.json - // this example is just showing the usage of "DatabaseMigrationsSqlDb_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbCreateOrUpdateDatabaseMigrationMAX.json + // this example is just showing the usage of "DatabaseMigrationsSqlDb_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,8 +42,36 @@ public async Task Get_GetSqlDBDatabaseMigrationWithTheExpandParameter() // invoke the operation string sqlDBInstanceName = "sqldbinstance"; string targetDBName = "db1"; - string expand = "MigrationStatusDetails"; - DatabaseMigrationSqlDBResource result = await collection.GetAsync(sqlDBInstanceName, targetDBName, expand: expand); + DatabaseMigrationSqlDBData data = new DatabaseMigrationSqlDBData + { + Properties = new DatabaseMigrationSqlDBProperties + { + TargetSqlConnection = new SqlConnectionInformation + { + DataSource = "sqldbinstance", + Authentication = "SqlAuthentication", + UserName = "bbb", + Password = "placeholder", + EncryptConnection = true, + TrustServerCertificate = true, + }, + TableList = { "[Schema1].[TableName1]", "[Schema2].[TableName2]" }, + Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/servers/sqldbinstance", + SourceSqlConnection = new SqlConnectionInformation + { + DataSource = "aaa", + Authentication = "WindowsAuthentication", + UserName = "bbb", + Password = "placeholder", + EncryptConnection = true, + TrustServerCertificate = true, + }, + SourceDatabaseName = "aaa", + MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlDBInstanceName, targetDBName, data); + DatabaseMigrationSqlDBResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +82,10 @@ public async Task Get_GetSqlDBDatabaseMigrationWithTheExpandParameter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSqlDBDatabaseMigrationWithTheExpandParameter() + public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMinimumParameters() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbGetDatabaseMigrationExpanded.json - // this example is just showing the usage of "DatabaseMigrationsSqlDb_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbCreateOrUpdateDatabaseMigrationMIN.json + // this example is just showing the usage of "DatabaseMigrationsSqlDb_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +105,46 @@ public async Task Exists_GetSqlDBDatabaseMigrationWithTheExpandParameter() // invoke the operation string sqlDBInstanceName = "sqldbinstance"; string targetDBName = "db1"; - string expand = "MigrationStatusDetails"; - bool result = await collection.ExistsAsync(sqlDBInstanceName, targetDBName, expand: expand); + DatabaseMigrationSqlDBData data = new DatabaseMigrationSqlDBData + { + Properties = new DatabaseMigrationSqlDBProperties + { + TargetSqlConnection = new SqlConnectionInformation + { + DataSource = "sqldbinstance", + Authentication = "SqlAuthentication", + UserName = "bbb", + Password = "placeholder", + EncryptConnection = true, + TrustServerCertificate = true, + }, + Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/servers/sqldbinstance", + SourceSqlConnection = new SqlConnectionInformation + { + DataSource = "aaa", + Authentication = "WindowsAuthentication", + UserName = "bbb", + Password = "placeholder", + EncryptConnection = true, + TrustServerCertificate = true, + }, + SourceDatabaseName = "aaa", + MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlDBInstanceName, targetDBName, data); + DatabaseMigrationSqlDBResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlDBData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSqlDBDatabaseMigrationWithTheExpandParameter() + public async Task Get_GetSqlDBDatabaseMigrationWithTheExpandParameter() { // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbGetDatabaseMigrationExpanded.json // this example is just showing the usage of "DatabaseMigrationsSqlDb_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,21 +168,13 @@ public async Task GetIfExists_GetSqlDBDatabaseMigrationWithTheExpandParameter() string sqlDBInstanceName = "sqldbinstance"; string targetDBName = "db1"; string expand = "MigrationStatusDetails"; - NullableResponse response = await collection.GetIfExistsAsync(sqlDBInstanceName, targetDBName, expand: expand); - DatabaseMigrationSqlDBResource result = response.HasValue ? response.Value : null; + DatabaseMigrationSqlDBResource result = await collection.GetAsync(sqlDBInstanceName, targetDBName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlDBData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlDBData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -162,9 +213,9 @@ public async Task Get_GetSqlDBDatabaseMigrationWithoutTheExpandParameter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSqlDBDatabaseMigrationWithoutTheExpandParameter() + public async Task Exists_GetSqlDBDatabaseMigrationWithTheExpandParameter() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbGetDatabaseMigration.json + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbGetDatabaseMigrationExpanded.json // this example is just showing the usage of "DatabaseMigrationsSqlDb_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -185,14 +236,15 @@ public async Task Exists_GetSqlDBDatabaseMigrationWithoutTheExpandParameter() // invoke the operation string sqlDBInstanceName = "sqldbinstance"; string targetDBName = "db1"; - bool result = await collection.ExistsAsync(sqlDBInstanceName, targetDBName); + string expand = "MigrationStatusDetails"; + bool result = await collection.ExistsAsync(sqlDBInstanceName, targetDBName, expand: expand); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSqlDBDatabaseMigrationWithoutTheExpandParameter() + public async Task Exists_GetSqlDBDatabaseMigrationWithoutTheExpandParameter() { // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbGetDatabaseMigration.json // this example is just showing the usage of "DatabaseMigrationsSqlDb_Get" operation, for the dependent resources, they will have to be created separately. @@ -215,29 +267,17 @@ public async Task GetIfExists_GetSqlDBDatabaseMigrationWithoutTheExpandParameter // invoke the operation string sqlDBInstanceName = "sqldbinstance"; string targetDBName = "db1"; - NullableResponse response = await collection.GetIfExistsAsync(sqlDBInstanceName, targetDBName); - DatabaseMigrationSqlDBResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sqlDBInstanceName, targetDBName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlDBData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMaximumParameters() + public async Task GetIfExists_GetSqlDBDatabaseMigrationWithTheExpandParameter() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbCreateOrUpdateDatabaseMigrationMAX.json - // this example is just showing the usage of "DatabaseMigrationsSqlDb_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbGetDatabaseMigrationExpanded.json + // this example is just showing the usage of "DatabaseMigrationsSqlDb_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -257,53 +297,30 @@ public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMaxi // invoke the operation string sqlDBInstanceName = "sqldbinstance"; string targetDBName = "db1"; - DatabaseMigrationSqlDBData data = new DatabaseMigrationSqlDBData() - { - Properties = new DatabaseMigrationSqlDBProperties() - { - TargetSqlConnection = new SqlConnectionInformation() - { - DataSource = "sqldbinstance", - Authentication = "SqlAuthentication", - UserName = "bbb", - Password = "placeholder", - EncryptConnection = true, - TrustServerCertificate = true, - }, - TableList = -{ -"[Schema1].[TableName1]","[Schema2].[TableName2]" -}, - Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/servers/sqldbinstance", - SourceSqlConnection = new SqlConnectionInformation() - { - DataSource = "aaa", - Authentication = "WindowsAuthentication", - UserName = "bbb", - Password = "placeholder", - EncryptConnection = true, - TrustServerCertificate = true, - }, - SourceDatabaseName = "aaa", - MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlDBInstanceName, targetDBName, data); - DatabaseMigrationSqlDBResource result = lro.Value; + string expand = "MigrationStatusDetails"; + NullableResponse response = await collection.GetIfExistsAsync(sqlDBInstanceName, targetDBName, expand: expand); + DatabaseMigrationSqlDBResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlDBData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlDBData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMinimumParameters() + public async Task GetIfExists_GetSqlDBDatabaseMigrationWithoutTheExpandParameter() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbCreateOrUpdateDatabaseMigrationMIN.json - // this example is just showing the usage of "DatabaseMigrationsSqlDb_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbGetDatabaseMigration.json + // this example is just showing the usage of "DatabaseMigrationsSqlDb_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -323,41 +340,21 @@ public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMini // invoke the operation string sqlDBInstanceName = "sqldbinstance"; string targetDBName = "db1"; - DatabaseMigrationSqlDBData data = new DatabaseMigrationSqlDBData() - { - Properties = new DatabaseMigrationSqlDBProperties() - { - TargetSqlConnection = new SqlConnectionInformation() - { - DataSource = "sqldbinstance", - Authentication = "SqlAuthentication", - UserName = "bbb", - Password = "placeholder", - EncryptConnection = true, - TrustServerCertificate = true, - }, - Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/servers/sqldbinstance", - SourceSqlConnection = new SqlConnectionInformation() - { - DataSource = "aaa", - Authentication = "WindowsAuthentication", - UserName = "bbb", - Password = "placeholder", - EncryptConnection = true, - TrustServerCertificate = true, - }, - SourceDatabaseName = "aaa", - MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlDBInstanceName, targetDBName, data); - DatabaseMigrationSqlDBResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(sqlDBInstanceName, targetDBName); + DatabaseMigrationSqlDBResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlDBData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlDBData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlDBResource.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlDBResource.cs index 68c4757c52466..1587ab84660cf 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlDBResource.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlDBResource.cs @@ -79,6 +79,33 @@ public async Task Get_GetSqlDBDatabaseMigrationWithoutTheExpandParameter() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteDatabaseMigrationResource() + { + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbDeleteDatabaseMigration.json + // this example is just showing the usage of "DatabaseMigrationsSqlDb_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DatabaseMigrationSqlDBResource created on azure + // for more information of creating DatabaseMigrationSqlDBResource, please refer to the document of DatabaseMigrationSqlDBResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "testrg"; + string sqlDBInstanceName = "sqldbinstance"; + string targetDBName = "db1"; + ResourceIdentifier databaseMigrationSqlDBResourceId = DatabaseMigrationSqlDBResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, sqlDBInstanceName, targetDBName); + DatabaseMigrationSqlDBResource databaseMigrationSqlDB = client.GetDatabaseMigrationSqlDBResource(databaseMigrationSqlDBResourceId); + + // invoke the operation + await databaseMigrationSqlDB.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateDatabaseMigrationResourceWithMaximumParameters() @@ -101,11 +128,11 @@ public async Task Update_CreateOrUpdateDatabaseMigrationResourceWithMaximumParam DatabaseMigrationSqlDBResource databaseMigrationSqlDB = client.GetDatabaseMigrationSqlDBResource(databaseMigrationSqlDBResourceId); // invoke the operation - DatabaseMigrationSqlDBData data = new DatabaseMigrationSqlDBData() + DatabaseMigrationSqlDBData data = new DatabaseMigrationSqlDBData { - Properties = new DatabaseMigrationSqlDBProperties() + Properties = new DatabaseMigrationSqlDBProperties { - TargetSqlConnection = new SqlConnectionInformation() + TargetSqlConnection = new SqlConnectionInformation { DataSource = "sqldbinstance", Authentication = "SqlAuthentication", @@ -114,12 +141,9 @@ public async Task Update_CreateOrUpdateDatabaseMigrationResourceWithMaximumParam EncryptConnection = true, TrustServerCertificate = true, }, - TableList = -{ -"[Schema1].[TableName1]","[Schema2].[TableName2]" -}, + TableList = { "[Schema1].[TableName1]", "[Schema2].[TableName2]" }, Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/servers/sqldbinstance", - SourceSqlConnection = new SqlConnectionInformation() + SourceSqlConnection = new SqlConnectionInformation { DataSource = "aaa", Authentication = "WindowsAuthentication", @@ -164,11 +188,11 @@ public async Task Update_CreateOrUpdateDatabaseMigrationResourceWithMinimumParam DatabaseMigrationSqlDBResource databaseMigrationSqlDB = client.GetDatabaseMigrationSqlDBResource(databaseMigrationSqlDBResourceId); // invoke the operation - DatabaseMigrationSqlDBData data = new DatabaseMigrationSqlDBData() + DatabaseMigrationSqlDBData data = new DatabaseMigrationSqlDBData { - Properties = new DatabaseMigrationSqlDBProperties() + Properties = new DatabaseMigrationSqlDBProperties { - TargetSqlConnection = new SqlConnectionInformation() + TargetSqlConnection = new SqlConnectionInformation { DataSource = "sqldbinstance", Authentication = "SqlAuthentication", @@ -178,7 +202,7 @@ public async Task Update_CreateOrUpdateDatabaseMigrationResourceWithMinimumParam TrustServerCertificate = true, }, Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/servers/sqldbinstance", - SourceSqlConnection = new SqlConnectionInformation() + SourceSqlConnection = new SqlConnectionInformation { DataSource = "aaa", Authentication = "WindowsAuthentication", @@ -201,33 +225,6 @@ public async Task Update_CreateOrUpdateDatabaseMigrationResourceWithMinimumParam Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDatabaseMigrationResource() - { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlDbDeleteDatabaseMigration.json - // this example is just showing the usage of "DatabaseMigrationsSqlDb_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DatabaseMigrationSqlDBResource created on azure - // for more information of creating DatabaseMigrationSqlDBResource, please refer to the document of DatabaseMigrationSqlDBResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "testrg"; - string sqlDBInstanceName = "sqldbinstance"; - string targetDBName = "db1"; - ResourceIdentifier databaseMigrationSqlDBResourceId = DatabaseMigrationSqlDBResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, sqlDBInstanceName, targetDBName); - DatabaseMigrationSqlDBResource databaseMigrationSqlDB = client.GetDatabaseMigrationSqlDBResource(databaseMigrationSqlDBResourceId); - - // invoke the operation - await databaseMigrationSqlDB.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Cancel_StopOngoingMigrationForTheDatabase() @@ -250,7 +247,7 @@ public async Task Cancel_StopOngoingMigrationForTheDatabase() DatabaseMigrationSqlDBResource databaseMigrationSqlDB = client.GetDatabaseMigrationSqlDBResource(databaseMigrationSqlDBResourceId); // invoke the operation - MigrationOperationInput input = new MigrationOperationInput() + MigrationOperationInput input = new MigrationOperationInput { MigrationOperationId = Guid.Parse("9a90bb84-e70f-46f7-b0ae-1aef5b3b9f07"), }; diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlMICollection.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlMICollection.cs index 79f352cdf9810..b7ba690b71984 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlMICollection.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlMICollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DatabaseMigrationSqlMICollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSqlMIDatabaseMigrationWithTheExpandParameter() + public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMaximumParameters() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiGetDatabaseMigrationExpanded.json - // this example is just showing the usage of "DatabaseMigrationsSqlMi_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiCreateOrUpdateDatabaseMigrationMAX.json + // this example is just showing the usage of "DatabaseMigrationsSqlMi_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,8 +42,48 @@ public async Task Get_GetSqlMIDatabaseMigrationWithTheExpandParameter() // invoke the operation string managedInstanceName = "managedInstance1"; string targetDBName = "db1"; - string expand = "MigrationStatusDetails"; - DatabaseMigrationSqlMIResource result = await collection.GetAsync(managedInstanceName, targetDBName, expand: expand); + DatabaseMigrationSqlMIData data = new DatabaseMigrationSqlMIData + { + Properties = new DatabaseMigrationSqlMIProperties + { + BackupConfiguration = new BackupConfiguration + { + SourceLocation = new SourceLocation + { + FileShare = new SqlFileShare + { + Path = "C:\\aaa\\bbb\\ccc", + Username = "name", + Password = "placeholder", + }, + }, + TargetLocation = new TargetLocation + { + StorageAccountResourceId = "account.database.windows.net", + AccountKey = "abcd", + }, + }, + OfflineConfiguration = new OfflineConfiguration + { + Offline = true, + LastBackupName = "last_backup_file_name", + }, + Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/instance", + SourceSqlConnection = new SqlConnectionInformation + { + DataSource = "aaa", + Authentication = "WindowsAuthentication", + UserName = "bbb", + Password = "placeholder", + EncryptConnection = true, + TrustServerCertificate = true, + }, + SourceDatabaseName = "aaa", + MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedInstanceName, targetDBName, data); + DatabaseMigrationSqlMIResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +94,10 @@ public async Task Get_GetSqlMIDatabaseMigrationWithTheExpandParameter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSqlMIDatabaseMigrationWithTheExpandParameter() + public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMinimumParameters() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiGetDatabaseMigrationExpanded.json - // this example is just showing the usage of "DatabaseMigrationsSqlMi_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiCreateOrUpdateDatabaseMigrationMIN.json + // this example is just showing the usage of "DatabaseMigrationsSqlMi_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +117,54 @@ public async Task Exists_GetSqlMIDatabaseMigrationWithTheExpandParameter() // invoke the operation string managedInstanceName = "managedInstance1"; string targetDBName = "db1"; - string expand = "MigrationStatusDetails"; - bool result = await collection.ExistsAsync(managedInstanceName, targetDBName, expand: expand); + DatabaseMigrationSqlMIData data = new DatabaseMigrationSqlMIData + { + Properties = new DatabaseMigrationSqlMIProperties + { + BackupConfiguration = new BackupConfiguration + { + SourceLocation = new SourceLocation + { + FileShare = new SqlFileShare + { + Path = "C:\\aaa\\bbb\\ccc", + Username = "name", + Password = "placeholder", + }, + }, + TargetLocation = new TargetLocation + { + StorageAccountResourceId = "account.database.windows.net", + AccountKey = "abcd", + }, + }, + Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/instance", + SourceSqlConnection = new SqlConnectionInformation + { + DataSource = "aaa", + Authentication = "WindowsAuthentication", + UserName = "bbb", + Password = "placeholder", + EncryptConnection = true, + TrustServerCertificate = true, + }, + SourceDatabaseName = "aaa", + MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedInstanceName, targetDBName, data); + DatabaseMigrationSqlMIResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlMIData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSqlMIDatabaseMigrationWithTheExpandParameter() + public async Task Get_GetSqlMIDatabaseMigrationWithTheExpandParameter() { // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiGetDatabaseMigrationExpanded.json // this example is just showing the usage of "DatabaseMigrationsSqlMi_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,21 +188,13 @@ public async Task GetIfExists_GetSqlMIDatabaseMigrationWithTheExpandParameter() string managedInstanceName = "managedInstance1"; string targetDBName = "db1"; string expand = "MigrationStatusDetails"; - NullableResponse response = await collection.GetIfExistsAsync(managedInstanceName, targetDBName, expand: expand); - DatabaseMigrationSqlMIResource result = response.HasValue ? response.Value : null; + DatabaseMigrationSqlMIResource result = await collection.GetAsync(managedInstanceName, targetDBName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlMIData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlMIData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -162,9 +233,9 @@ public async Task Get_GetSqlMIDatabaseMigrationWithoutTheExpandParameter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSqlMIDatabaseMigrationWithoutTheExpandParameter() + public async Task Exists_GetSqlMIDatabaseMigrationWithTheExpandParameter() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiGetDatabaseMigration.json + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiGetDatabaseMigrationExpanded.json // this example is just showing the usage of "DatabaseMigrationsSqlMi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -185,14 +256,15 @@ public async Task Exists_GetSqlMIDatabaseMigrationWithoutTheExpandParameter() // invoke the operation string managedInstanceName = "managedInstance1"; string targetDBName = "db1"; - bool result = await collection.ExistsAsync(managedInstanceName, targetDBName); + string expand = "MigrationStatusDetails"; + bool result = await collection.ExistsAsync(managedInstanceName, targetDBName, expand: expand); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSqlMIDatabaseMigrationWithoutTheExpandParameter() + public async Task Exists_GetSqlMIDatabaseMigrationWithoutTheExpandParameter() { // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiGetDatabaseMigration.json // this example is just showing the usage of "DatabaseMigrationsSqlMi_Get" operation, for the dependent resources, they will have to be created separately. @@ -215,29 +287,17 @@ public async Task GetIfExists_GetSqlMIDatabaseMigrationWithoutTheExpandParameter // invoke the operation string managedInstanceName = "managedInstance1"; string targetDBName = "db1"; - NullableResponse response = await collection.GetIfExistsAsync(managedInstanceName, targetDBName); - DatabaseMigrationSqlMIResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(managedInstanceName, targetDBName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlMIData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMaximumParameters() + public async Task GetIfExists_GetSqlMIDatabaseMigrationWithTheExpandParameter() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiCreateOrUpdateDatabaseMigrationMAX.json - // this example is just showing the usage of "DatabaseMigrationsSqlMi_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiGetDatabaseMigrationExpanded.json + // this example is just showing the usage of "DatabaseMigrationsSqlMi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -257,62 +317,30 @@ public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMaxi // invoke the operation string managedInstanceName = "managedInstance1"; string targetDBName = "db1"; - DatabaseMigrationSqlMIData data = new DatabaseMigrationSqlMIData() - { - Properties = new DatabaseMigrationSqlMIProperties() - { - BackupConfiguration = new BackupConfiguration() - { - SourceLocation = new SourceLocation() - { - FileShare = new SqlFileShare() - { - Path = "C:\\aaa\\bbb\\ccc", - Username = "name", - Password = "placeholder", - }, - }, - TargetLocation = new TargetLocation() - { - StorageAccountResourceId = "account.database.windows.net", - AccountKey = "abcd", - }, - }, - OfflineConfiguration = new OfflineConfiguration() - { - Offline = true, - LastBackupName = "last_backup_file_name", - }, - Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/instance", - SourceSqlConnection = new SqlConnectionInformation() - { - DataSource = "aaa", - Authentication = "WindowsAuthentication", - UserName = "bbb", - Password = "placeholder", - EncryptConnection = true, - TrustServerCertificate = true, - }, - SourceDatabaseName = "aaa", - MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedInstanceName, targetDBName, data); - DatabaseMigrationSqlMIResource result = lro.Value; + string expand = "MigrationStatusDetails"; + NullableResponse response = await collection.GetIfExistsAsync(managedInstanceName, targetDBName, expand: expand); + DatabaseMigrationSqlMIResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlMIData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlMIData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMinimumParameters() + public async Task GetIfExists_GetSqlMIDatabaseMigrationWithoutTheExpandParameter() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiCreateOrUpdateDatabaseMigrationMIN.json - // this example is just showing the usage of "DatabaseMigrationsSqlMi_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlMiGetDatabaseMigration.json + // this example is just showing the usage of "DatabaseMigrationsSqlMi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -332,49 +360,21 @@ public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMini // invoke the operation string managedInstanceName = "managedInstance1"; string targetDBName = "db1"; - DatabaseMigrationSqlMIData data = new DatabaseMigrationSqlMIData() - { - Properties = new DatabaseMigrationSqlMIProperties() - { - BackupConfiguration = new BackupConfiguration() - { - SourceLocation = new SourceLocation() - { - FileShare = new SqlFileShare() - { - Path = "C:\\aaa\\bbb\\ccc", - Username = "name", - Password = "placeholder", - }, - }, - TargetLocation = new TargetLocation() - { - StorageAccountResourceId = "account.database.windows.net", - AccountKey = "abcd", - }, - }, - Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/instance", - SourceSqlConnection = new SqlConnectionInformation() - { - DataSource = "aaa", - Authentication = "WindowsAuthentication", - UserName = "bbb", - Password = "placeholder", - EncryptConnection = true, - TrustServerCertificate = true, - }, - SourceDatabaseName = "aaa", - MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedInstanceName, targetDBName, data); - DatabaseMigrationSqlMIResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(managedInstanceName, targetDBName); + DatabaseMigrationSqlMIResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlMIData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlMIData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlMIResource.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlMIResource.cs index aed635bd24e8e..dc7fc02699f94 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlMIResource.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlMIResource.cs @@ -101,34 +101,34 @@ public async Task Update_CreateOrUpdateDatabaseMigrationResourceWithMaximumParam DatabaseMigrationSqlMIResource databaseMigrationSqlMI = client.GetDatabaseMigrationSqlMIResource(databaseMigrationSqlMIResourceId); // invoke the operation - DatabaseMigrationSqlMIData data = new DatabaseMigrationSqlMIData() + DatabaseMigrationSqlMIData data = new DatabaseMigrationSqlMIData { - Properties = new DatabaseMigrationSqlMIProperties() + Properties = new DatabaseMigrationSqlMIProperties { - BackupConfiguration = new BackupConfiguration() + BackupConfiguration = new BackupConfiguration { - SourceLocation = new SourceLocation() + SourceLocation = new SourceLocation { - FileShare = new SqlFileShare() + FileShare = new SqlFileShare { Path = "C:\\aaa\\bbb\\ccc", Username = "name", Password = "placeholder", }, }, - TargetLocation = new TargetLocation() + TargetLocation = new TargetLocation { StorageAccountResourceId = "account.database.windows.net", AccountKey = "abcd", }, }, - OfflineConfiguration = new OfflineConfiguration() + OfflineConfiguration = new OfflineConfiguration { Offline = true, LastBackupName = "last_backup_file_name", }, Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/instance", - SourceSqlConnection = new SqlConnectionInformation() + SourceSqlConnection = new SqlConnectionInformation { DataSource = "aaa", Authentication = "WindowsAuthentication", @@ -173,29 +173,29 @@ public async Task Update_CreateOrUpdateDatabaseMigrationResourceWithMinimumParam DatabaseMigrationSqlMIResource databaseMigrationSqlMI = client.GetDatabaseMigrationSqlMIResource(databaseMigrationSqlMIResourceId); // invoke the operation - DatabaseMigrationSqlMIData data = new DatabaseMigrationSqlMIData() + DatabaseMigrationSqlMIData data = new DatabaseMigrationSqlMIData { - Properties = new DatabaseMigrationSqlMIProperties() + Properties = new DatabaseMigrationSqlMIProperties { - BackupConfiguration = new BackupConfiguration() + BackupConfiguration = new BackupConfiguration { - SourceLocation = new SourceLocation() + SourceLocation = new SourceLocation { - FileShare = new SqlFileShare() + FileShare = new SqlFileShare { Path = "C:\\aaa\\bbb\\ccc", Username = "name", Password = "placeholder", }, }, - TargetLocation = new TargetLocation() + TargetLocation = new TargetLocation { StorageAccountResourceId = "account.database.windows.net", AccountKey = "abcd", }, }, Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/instance", - SourceSqlConnection = new SqlConnectionInformation() + SourceSqlConnection = new SqlConnectionInformation { DataSource = "aaa", Authentication = "WindowsAuthentication", @@ -240,7 +240,7 @@ public async Task Cancel_StopOngoingMigrationForTheDatabase() DatabaseMigrationSqlMIResource databaseMigrationSqlMI = client.GetDatabaseMigrationSqlMIResource(databaseMigrationSqlMIResourceId); // invoke the operation - MigrationOperationInput input = new MigrationOperationInput() + MigrationOperationInput input = new MigrationOperationInput { MigrationOperationId = Guid.Parse("4124fe90-d1b6-4b50-b4d9-46d02381f59a"), }; @@ -271,7 +271,7 @@ public async Task Cutover_CutoverOnlineMigrationOperationForTheDatabase() DatabaseMigrationSqlMIResource databaseMigrationSqlMI = client.GetDatabaseMigrationSqlMIResource(databaseMigrationSqlMIResourceId); // invoke the operation - MigrationOperationInput input = new MigrationOperationInput() + MigrationOperationInput input = new MigrationOperationInput { MigrationOperationId = Guid.Parse("4124fe90-d1b6-4b50-b4d9-46d02381f59a"), }; diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlVmCollection.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlVmCollection.cs index 1e7e50017aec9..25f9276be40e9 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlVmCollection.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlVmCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DatabaseMigrationSqlVmCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSqlVMDatabaseMigrationWithTheExpandParameter() + public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMaximumParameters() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmGetDatabaseMigrationExpanded.json - // this example is just showing the usage of "DatabaseMigrationsSqlVm_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmCreateOrUpdateDatabaseMigrationMAX.json + // this example is just showing the usage of "DatabaseMigrationsSqlVm_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,8 +42,48 @@ public async Task Get_GetSqlVMDatabaseMigrationWithTheExpandParameter() // invoke the operation string sqlVirtualMachineName = "testvm"; string targetDBName = "db1"; - string expand = "MigrationStatusDetails"; - DatabaseMigrationSqlVmResource result = await collection.GetAsync(sqlVirtualMachineName, targetDBName, expand: expand); + DatabaseMigrationSqlVmData data = new DatabaseMigrationSqlVmData + { + Properties = new DatabaseMigrationSqlVmProperties + { + BackupConfiguration = new BackupConfiguration + { + SourceLocation = new SourceLocation + { + FileShare = new SqlFileShare + { + Path = "C:\\aaa\\bbb\\ccc", + Username = "name", + Password = "placeholder", + }, + }, + TargetLocation = new TargetLocation + { + StorageAccountResourceId = "account.database.windows.net", + AccountKey = "abcd", + }, + }, + OfflineConfiguration = new OfflineConfiguration + { + Offline = true, + LastBackupName = "last_backup_file_name", + }, + Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm", + SourceSqlConnection = new SqlConnectionInformation + { + DataSource = "aaa", + Authentication = "WindowsAuthentication", + UserName = "bbb", + Password = "placeholder", + EncryptConnection = true, + TrustServerCertificate = true, + }, + SourceDatabaseName = "aaa", + MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlVirtualMachineName, targetDBName, data); + DatabaseMigrationSqlVmResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +94,10 @@ public async Task Get_GetSqlVMDatabaseMigrationWithTheExpandParameter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSqlVMDatabaseMigrationWithTheExpandParameter() + public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMinimumParameters() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmGetDatabaseMigrationExpanded.json - // this example is just showing the usage of "DatabaseMigrationsSqlVm_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmCreateOrUpdateDatabaseMigrationMIN.json + // this example is just showing the usage of "DatabaseMigrationsSqlVm_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +117,54 @@ public async Task Exists_GetSqlVMDatabaseMigrationWithTheExpandParameter() // invoke the operation string sqlVirtualMachineName = "testvm"; string targetDBName = "db1"; - string expand = "MigrationStatusDetails"; - bool result = await collection.ExistsAsync(sqlVirtualMachineName, targetDBName, expand: expand); + DatabaseMigrationSqlVmData data = new DatabaseMigrationSqlVmData + { + Properties = new DatabaseMigrationSqlVmProperties + { + BackupConfiguration = new BackupConfiguration + { + SourceLocation = new SourceLocation + { + FileShare = new SqlFileShare + { + Path = "C:\\aaa\\bbb\\ccc", + Username = "name", + Password = "placeholder", + }, + }, + TargetLocation = new TargetLocation + { + StorageAccountResourceId = "account.database.windows.net", + AccountKey = "abcd", + }, + }, + Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm", + SourceSqlConnection = new SqlConnectionInformation + { + DataSource = "aaa", + Authentication = "WindowsAuthentication", + UserName = "bbb", + Password = "placeholder", + EncryptConnection = true, + TrustServerCertificate = true, + }, + SourceDatabaseName = "aaa", + MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlVirtualMachineName, targetDBName, data); + DatabaseMigrationSqlVmResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSqlVMDatabaseMigrationWithTheExpandParameter() + public async Task Get_GetSqlVMDatabaseMigrationWithTheExpandParameter() { // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmGetDatabaseMigrationExpanded.json // this example is just showing the usage of "DatabaseMigrationsSqlVm_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,21 +188,13 @@ public async Task GetIfExists_GetSqlVMDatabaseMigrationWithTheExpandParameter() string sqlVirtualMachineName = "testvm"; string targetDBName = "db1"; string expand = "MigrationStatusDetails"; - NullableResponse response = await collection.GetIfExistsAsync(sqlVirtualMachineName, targetDBName, expand: expand); - DatabaseMigrationSqlVmResource result = response.HasValue ? response.Value : null; + DatabaseMigrationSqlVmResource result = await collection.GetAsync(sqlVirtualMachineName, targetDBName, expand: expand); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -162,9 +233,9 @@ public async Task Get_GetSqlVMDatabaseMigrationWithoutTheExpandParameter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSqlVMDatabaseMigrationWithoutTheExpandParameter() + public async Task Exists_GetSqlVMDatabaseMigrationWithTheExpandParameter() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmGetDatabaseMigration.json + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmGetDatabaseMigrationExpanded.json // this example is just showing the usage of "DatabaseMigrationsSqlVm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -185,14 +256,15 @@ public async Task Exists_GetSqlVMDatabaseMigrationWithoutTheExpandParameter() // invoke the operation string sqlVirtualMachineName = "testvm"; string targetDBName = "db1"; - bool result = await collection.ExistsAsync(sqlVirtualMachineName, targetDBName); + string expand = "MigrationStatusDetails"; + bool result = await collection.ExistsAsync(sqlVirtualMachineName, targetDBName, expand: expand); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSqlVMDatabaseMigrationWithoutTheExpandParameter() + public async Task Exists_GetSqlVMDatabaseMigrationWithoutTheExpandParameter() { // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmGetDatabaseMigration.json // this example is just showing the usage of "DatabaseMigrationsSqlVm_Get" operation, for the dependent resources, they will have to be created separately. @@ -215,29 +287,17 @@ public async Task GetIfExists_GetSqlVMDatabaseMigrationWithoutTheExpandParameter // invoke the operation string sqlVirtualMachineName = "testvm"; string targetDBName = "db1"; - NullableResponse response = await collection.GetIfExistsAsync(sqlVirtualMachineName, targetDBName); - DatabaseMigrationSqlVmResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sqlVirtualMachineName, targetDBName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMaximumParameters() + public async Task GetIfExists_GetSqlVMDatabaseMigrationWithTheExpandParameter() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmCreateOrUpdateDatabaseMigrationMAX.json - // this example is just showing the usage of "DatabaseMigrationsSqlVm_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmGetDatabaseMigrationExpanded.json + // this example is just showing the usage of "DatabaseMigrationsSqlVm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -257,62 +317,30 @@ public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMaxi // invoke the operation string sqlVirtualMachineName = "testvm"; string targetDBName = "db1"; - DatabaseMigrationSqlVmData data = new DatabaseMigrationSqlVmData() - { - Properties = new DatabaseMigrationSqlVmProperties() - { - BackupConfiguration = new BackupConfiguration() - { - SourceLocation = new SourceLocation() - { - FileShare = new SqlFileShare() - { - Path = "C:\\aaa\\bbb\\ccc", - Username = "name", - Password = "placeholder", - }, - }, - TargetLocation = new TargetLocation() - { - StorageAccountResourceId = "account.database.windows.net", - AccountKey = "abcd", - }, - }, - OfflineConfiguration = new OfflineConfiguration() - { - Offline = true, - LastBackupName = "last_backup_file_name", - }, - Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm", - SourceSqlConnection = new SqlConnectionInformation() - { - DataSource = "aaa", - Authentication = "WindowsAuthentication", - UserName = "bbb", - Password = "placeholder", - EncryptConnection = true, - TrustServerCertificate = true, - }, - SourceDatabaseName = "aaa", - MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlVirtualMachineName, targetDBName, data); - DatabaseMigrationSqlVmResource result = lro.Value; + string expand = "MigrationStatusDetails"; + NullableResponse response = await collection.GetIfExistsAsync(sqlVirtualMachineName, targetDBName, expand: expand); + DatabaseMigrationSqlVmResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMinimumParameters() + public async Task GetIfExists_GetSqlVMDatabaseMigrationWithoutTheExpandParameter() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmCreateOrUpdateDatabaseMigrationMIN.json - // this example is just showing the usage of "DatabaseMigrationsSqlVm_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/SqlVmGetDatabaseMigration.json + // this example is just showing the usage of "DatabaseMigrationsSqlVm_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -332,49 +360,21 @@ public async Task CreateOrUpdate_CreateOrUpdateDatabaseMigrationResourceWithMini // invoke the operation string sqlVirtualMachineName = "testvm"; string targetDBName = "db1"; - DatabaseMigrationSqlVmData data = new DatabaseMigrationSqlVmData() - { - Properties = new DatabaseMigrationSqlVmProperties() - { - BackupConfiguration = new BackupConfiguration() - { - SourceLocation = new SourceLocation() - { - FileShare = new SqlFileShare() - { - Path = "C:\\aaa\\bbb\\ccc", - Username = "name", - Password = "placeholder", - }, - }, - TargetLocation = new TargetLocation() - { - StorageAccountResourceId = "account.database.windows.net", - AccountKey = "abcd", - }, - }, - Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm", - SourceSqlConnection = new SqlConnectionInformation() - { - DataSource = "aaa", - Authentication = "WindowsAuthentication", - UserName = "bbb", - Password = "placeholder", - EncryptConnection = true, - TrustServerCertificate = true, - }, - SourceDatabaseName = "aaa", - MigrationService = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.DataMigration/sqlMigrationServices/testagent", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlVirtualMachineName, targetDBName, data); - DatabaseMigrationSqlVmResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(sqlVirtualMachineName, targetDBName); + DatabaseMigrationSqlVmResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DatabaseMigrationSqlVmData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DatabaseMigrationSqlVmData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlVmResource.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlVmResource.cs index c7aa2822edd63..64d1d09c200cc 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlVmResource.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_DatabaseMigrationSqlVmResource.cs @@ -101,34 +101,34 @@ public async Task Update_CreateOrUpdateDatabaseMigrationResourceWithMaximumParam DatabaseMigrationSqlVmResource databaseMigrationSqlVm = client.GetDatabaseMigrationSqlVmResource(databaseMigrationSqlVmResourceId); // invoke the operation - DatabaseMigrationSqlVmData data = new DatabaseMigrationSqlVmData() + DatabaseMigrationSqlVmData data = new DatabaseMigrationSqlVmData { - Properties = new DatabaseMigrationSqlVmProperties() + Properties = new DatabaseMigrationSqlVmProperties { - BackupConfiguration = new BackupConfiguration() + BackupConfiguration = new BackupConfiguration { - SourceLocation = new SourceLocation() + SourceLocation = new SourceLocation { - FileShare = new SqlFileShare() + FileShare = new SqlFileShare { Path = "C:\\aaa\\bbb\\ccc", Username = "name", Password = "placeholder", }, }, - TargetLocation = new TargetLocation() + TargetLocation = new TargetLocation { StorageAccountResourceId = "account.database.windows.net", AccountKey = "abcd", }, }, - OfflineConfiguration = new OfflineConfiguration() + OfflineConfiguration = new OfflineConfiguration { Offline = true, LastBackupName = "last_backup_file_name", }, Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm", - SourceSqlConnection = new SqlConnectionInformation() + SourceSqlConnection = new SqlConnectionInformation { DataSource = "aaa", Authentication = "WindowsAuthentication", @@ -173,29 +173,29 @@ public async Task Update_CreateOrUpdateDatabaseMigrationResourceWithMinimumParam DatabaseMigrationSqlVmResource databaseMigrationSqlVm = client.GetDatabaseMigrationSqlVmResource(databaseMigrationSqlVmResourceId); // invoke the operation - DatabaseMigrationSqlVmData data = new DatabaseMigrationSqlVmData() + DatabaseMigrationSqlVmData data = new DatabaseMigrationSqlVmData { - Properties = new DatabaseMigrationSqlVmProperties() + Properties = new DatabaseMigrationSqlVmProperties { - BackupConfiguration = new BackupConfiguration() + BackupConfiguration = new BackupConfiguration { - SourceLocation = new SourceLocation() + SourceLocation = new SourceLocation { - FileShare = new SqlFileShare() + FileShare = new SqlFileShare { Path = "C:\\aaa\\bbb\\ccc", Username = "name", Password = "placeholder", }, }, - TargetLocation = new TargetLocation() + TargetLocation = new TargetLocation { StorageAccountResourceId = "account.database.windows.net", AccountKey = "abcd", }, }, Scope = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.SqlVirtualMachine/sqlVirtualMachines/testvm", - SourceSqlConnection = new SqlConnectionInformation() + SourceSqlConnection = new SqlConnectionInformation { DataSource = "aaa", Authentication = "WindowsAuthentication", @@ -240,7 +240,7 @@ public async Task Cancel_StopOngoingMigrationForTheDatabase() DatabaseMigrationSqlVmResource databaseMigrationSqlVm = client.GetDatabaseMigrationSqlVmResource(databaseMigrationSqlVmResourceId); // invoke the operation - MigrationOperationInput input = new MigrationOperationInput() + MigrationOperationInput input = new MigrationOperationInput { MigrationOperationId = Guid.Parse("4124fe90-d1b6-4b50-b4d9-46d02381f59a"), }; @@ -271,7 +271,7 @@ public async Task Cutover_CutoverOnlineMigrationOperationForTheDatabase() DatabaseMigrationSqlVmResource databaseMigrationSqlVm = client.GetDatabaseMigrationSqlVmResource(databaseMigrationSqlVmResourceId); // invoke the operation - MigrationOperationInput input = new MigrationOperationInput() + MigrationOperationInput input = new MigrationOperationInput { MigrationOperationId = Guid.Parse("4124fe90-d1b6-4b50-b4d9-46d02381f59a"), }; diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectCollection.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectCollection.cs index f655b71824fda..0946fbea71562 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectCollection.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ProjectCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProjectsList() + public async Task CreateOrUpdate_ProjectsCreateOrUpdate() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Projects_List.json - // this example is just showing the usage of "Projects_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Projects_CreateOrUpdate.json + // this example is just showing the usage of "Projects_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,29 @@ public async Task GetAll_ProjectsList() // get the collection of this ProjectResource ProjectCollection collection = dataMigrationService.GetProjects(); - // invoke the operation and iterate over the result - await foreach (ProjectResource item in collection.GetAllAsync()) + // invoke the operation + string projectName = "DmsSdkProject"; + ProjectData data = new ProjectData(new AzureLocation("southcentralus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProjectData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SourcePlatform = ProjectSourcePlatform.Sql, + TargetPlatform = ProjectTargetPlatform.SqlDB, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, projectName, data); + ProjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProjectsCreateOrUpdate() + public async Task Get_ProjectsGet() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Projects_CreateOrUpdate.json - // this example is just showing the usage of "Projects_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Projects_Get.json + // this example is just showing the usage of "Projects_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,13 +81,7 @@ public async Task CreateOrUpdate_ProjectsCreateOrUpdate() // invoke the operation string projectName = "DmsSdkProject"; - ProjectData data = new ProjectData(new AzureLocation("southcentralus")) - { - SourcePlatform = ProjectSourcePlatform.Sql, - TargetPlatform = ProjectTargetPlatform.SqlDB, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, projectName, data); - ProjectResource result = lro.Value; + ProjectResource result = await collection.GetAsync(projectName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -94,10 +92,10 @@ public async Task CreateOrUpdate_ProjectsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProjectsGet() + public async Task GetAll_ProjectsList() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Projects_Get.json - // this example is just showing the usage of "Projects_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Projects_List.json + // this example is just showing the usage of "Projects_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,15 +113,17 @@ public async Task Get_ProjectsGet() // get the collection of this ProjectResource ProjectCollection collection = dataMigrationService.GetProjects(); - // invoke the operation - string projectName = "DmsSdkProject"; - ProjectResource result = await collection.GetAsync(projectName); + // invoke the operation and iterate over the result + await foreach (ProjectResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProjectData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectFileCollection.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectFileCollection.cs index 435c72459589f..d33cc22fdc8b4 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectFileCollection.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectFileCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ProjectFileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FilesList() + public async Task CreateOrUpdate_FilesCreateOrUpdate() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Files_List.json - // this example is just showing the usage of "Files_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Files_CreateOrUpdate.json + // this example is just showing the usage of "Files_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,23 @@ public async Task GetAll_FilesList() // get the collection of this ProjectFileResource ProjectFileCollection collection = project.GetProjectFiles(); - // invoke the operation and iterate over the result - await foreach (ProjectFileResource item in collection.GetAllAsync()) + // invoke the operation + string fileName = "x114d023d8"; + ProjectFileData data = new ProjectFileData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProjectFileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new ProjectFileProperties + { + FilePath = "DmsSdkFilePath/DmsSdkFile.sql", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileName, data); + ProjectFileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProjectFileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +96,10 @@ public async Task Get_FilesList() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FilesList() + public async Task GetAll_FilesList() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Files_Get.json - // this example is just showing the usage of "Files_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Files_List.json + // this example is just showing the usage of "Files_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +118,22 @@ public async Task Exists_FilesList() // get the collection of this ProjectFileResource ProjectFileCollection collection = project.GetProjectFiles(); - // invoke the operation - string fileName = "x114d023d8"; - bool result = await collection.ExistsAsync(fileName); + // invoke the operation and iterate over the result + await foreach (ProjectFileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProjectFileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FilesList() + public async Task Exists_FilesList() { // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Files_Get.json // this example is just showing the usage of "Files_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +157,17 @@ public async Task GetIfExists_FilesList() // invoke the operation string fileName = "x114d023d8"; - NullableResponse response = await collection.GetIfExistsAsync(fileName); - ProjectFileResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(fileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProjectFileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FilesCreateOrUpdate() + public async Task GetIfExists_FilesList() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Files_CreateOrUpdate.json - // this example is just showing the usage of "Files_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Files_Get.json + // this example is just showing the usage of "Files_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,21 +188,21 @@ public async Task CreateOrUpdate_FilesCreateOrUpdate() // invoke the operation string fileName = "x114d023d8"; - ProjectFileData data = new ProjectFileData() - { - Properties = new ProjectFileProperties() - { - FilePath = "DmsSdkFilePath/DmsSdkFile.sql", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, fileName, data); - ProjectFileResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(fileName); + ProjectFileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProjectFileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProjectFileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectFileResource.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectFileResource.cs index 9ff95fafc82fa..60eb248918cac 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectFileResource.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ProjectFileResource.cs @@ -99,9 +99,9 @@ public async Task Update_FilesUpdate() ProjectFileResource projectFile = client.GetProjectFileResource(projectFileResourceId); // invoke the operation - ProjectFileData data = new ProjectFileData() + ProjectFileData data = new ProjectFileData { - Properties = new ProjectFileProperties() + Properties = new ProjectFileProperties { FilePath = "DmsSdkFilePath/DmsSdkFile.sql", }, diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceProjectTaskCollection.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceProjectTaskCollection.cs index 31915a71570a6..762648846d3df 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceProjectTaskCollection.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceProjectTaskCollection.cs @@ -16,43 +16,6 @@ namespace Azure.ResourceManager.DataMigration.Samples { public partial class Sample_ServiceProjectTaskCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_TasksList() - { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Tasks_List.json - // this example is just showing the usage of "Tasks_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ProjectResource created on azure - // for more information of creating ProjectResource, please refer to the document of ProjectResource - string subscriptionId = "fc04246f-04c5-437e-ac5e-206a19e7193f"; - string groupName = "DmsSdkRg"; - string serviceName = "DmsSdkService"; - string projectName = "DmsSdkProject"; - ResourceIdentifier projectResourceId = ProjectResource.CreateResourceIdentifier(subscriptionId, groupName, serviceName, projectName); - ProjectResource project = client.GetProjectResource(projectResourceId); - - // get the collection of this ServiceProjectTaskResource - ServiceProjectTaskCollection collection = project.GetServiceProjectTasks(); - - // invoke the operation and iterate over the result - await foreach (ServiceProjectTaskResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProjectTaskData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_TasksCreateOrUpdate() @@ -79,9 +42,9 @@ public async Task CreateOrUpdate_TasksCreateOrUpdate() // invoke the operation string taskName = "DmsSdkTask"; - ProjectTaskData data = new ProjectTaskData() + ProjectTaskData data = new ProjectTaskData { - Properties = new ConnectToTargetSqlDBTaskProperties() + Properties = new ConnectToTargetSqlDBTaskProperties { Input = new ConnectToTargetSqlDBTaskInput(new SqlConnectionInfo("ssma-test-server.database.windows.net") { @@ -138,6 +101,43 @@ public async Task Get_TasksGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_TasksList() + { + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Tasks_List.json + // this example is just showing the usage of "Tasks_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ProjectResource created on azure + // for more information of creating ProjectResource, please refer to the document of ProjectResource + string subscriptionId = "fc04246f-04c5-437e-ac5e-206a19e7193f"; + string groupName = "DmsSdkRg"; + string serviceName = "DmsSdkService"; + string projectName = "DmsSdkProject"; + ResourceIdentifier projectResourceId = ProjectResource.CreateResourceIdentifier(subscriptionId, groupName, serviceName, projectName); + ProjectResource project = client.GetProjectResource(projectResourceId); + + // get the collection of this ServiceProjectTaskResource + ServiceProjectTaskCollection collection = project.GetServiceProjectTasks(); + + // invoke the operation and iterate over the result + await foreach (ServiceProjectTaskResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProjectTaskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_TasksGet() diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceProjectTaskResource.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceProjectTaskResource.cs index 3a1d106e652f0..216e4f48d6a59 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceProjectTaskResource.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceProjectTaskResource.cs @@ -99,9 +99,9 @@ public async Task Update_TasksUpdate() ServiceProjectTaskResource serviceProjectTask = client.GetServiceProjectTaskResource(serviceProjectTaskResourceId); // invoke the operation - ProjectTaskData data = new ProjectTaskData() + ProjectTaskData data = new ProjectTaskData { - Properties = new ConnectToTargetSqlDBTaskProperties() + Properties = new ConnectToTargetSqlDBTaskProperties { Input = new ConnectToTargetSqlDBTaskInput(new SqlConnectionInfo("ssma-test-server.database.windows.net") { @@ -177,7 +177,7 @@ public async Task Command_TasksCommand() ServiceProjectTaskResource serviceProjectTask = client.GetServiceProjectTaskResource(serviceProjectTaskResourceId); // invoke the operation - CommandProperties commandProperties = new MigrateSyncCompleteCommandProperties() + CommandProperties commandProperties = new MigrateSyncCompleteCommandProperties { Input = new MigrateSyncCompleteCommandInput("TestDatabase"), }; diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceServiceTaskCollection.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceServiceTaskCollection.cs index 79eb998ec2baa..44e8f82950d3c 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceServiceTaskCollection.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceServiceTaskCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceServiceTaskCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServiceTasksList() + public async Task CreateOrUpdate_TasksCreateOrUpdate() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/ServiceTasks_List.json - // this example is just showing the usage of "ServiceTasks_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/ServiceTasks_CreateOrUpdate.json + // this example is just showing the usage of "ServiceTasks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,31 @@ public async Task GetAll_ServiceTasksList() // get the collection of this ServiceServiceTaskResource ServiceServiceTaskCollection collection = dataMigrationService.GetServiceServiceTasks(); - // invoke the operation and iterate over the result - await foreach (ServiceServiceTaskResource item in collection.GetAllAsync()) + // invoke the operation + string taskName = "DmsSdkTask"; + ProjectTaskData data = new ProjectTaskData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProjectTaskData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new CheckOciDriverTaskProperties + { + InputServerVersion = "NA", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, taskName, data); + ServiceServiceTaskResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProjectTaskData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TasksCreateOrUpdate() + public async Task Get_TasksGet() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/ServiceTasks_CreateOrUpdate.json - // this example is just showing the usage of "ServiceTasks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/ServiceTasks_Get.json + // this example is just showing the usage of "ServiceTasks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +83,7 @@ public async Task CreateOrUpdate_TasksCreateOrUpdate() // invoke the operation string taskName = "DmsSdkTask"; - ProjectTaskData data = new ProjectTaskData() - { - Properties = new CheckOciDriverTaskProperties() - { - InputServerVersion = "NA", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, taskName, data); - ServiceServiceTaskResource result = lro.Value; + ServiceServiceTaskResource result = await collection.GetAsync(taskName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -96,10 +94,10 @@ public async Task CreateOrUpdate_TasksCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TasksGet() + public async Task GetAll_ServiceTasksList() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/ServiceTasks_Get.json - // this example is just showing the usage of "ServiceTasks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/ServiceTasks_List.json + // this example is just showing the usage of "ServiceTasks_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,15 +115,17 @@ public async Task Get_TasksGet() // get the collection of this ServiceServiceTaskResource ServiceServiceTaskCollection collection = dataMigrationService.GetServiceServiceTasks(); - // invoke the operation - string taskName = "DmsSdkTask"; - ServiceServiceTaskResource result = await collection.GetAsync(taskName); + // invoke the operation and iterate over the result + await foreach (ServiceServiceTaskResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProjectTaskData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProjectTaskData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceServiceTaskResource.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceServiceTaskResource.cs index 8a80135c9be33..408040132a201 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceServiceTaskResource.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_ServiceServiceTaskResource.cs @@ -96,9 +96,9 @@ public async Task Update_TasksUpdate() ServiceServiceTaskResource serviceServiceTask = client.GetServiceServiceTaskResource(serviceServiceTaskResourceId); // invoke the operation - ProjectTaskData data = new ProjectTaskData() + ProjectTaskData data = new ProjectTaskData { - Properties = new CheckOciDriverTaskProperties() + Properties = new CheckOciDriverTaskProperties { InputServerVersion = "NA", }, diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SqlMigrationServiceCollection.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SqlMigrationServiceCollection.cs index 98feb91267fb2..9905b454bd433 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SqlMigrationServiceCollection.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SqlMigrationServiceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SqlMigrationServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMigrationService() + public async Task CreateOrUpdate_CreateOrUpdateSQLMigrationServiceWithMaximumParameters() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/GetMigrationService.json - // this example is just showing the usage of "SqlMigrationServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/CreateOrUpdateMigrationServiceMAX.json + // this example is just showing the usage of "SqlMigrationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,10 @@ public async Task Get_GetMigrationService() SqlMigrationServiceCollection collection = resourceGroupResource.GetSqlMigrationServices(); // invoke the operation - string sqlMigrationServiceName = "service1"; - SqlMigrationServiceResource result = await collection.GetAsync(sqlMigrationServiceName); + string sqlMigrationServiceName = "testagent"; + SqlMigrationServiceData data = new SqlMigrationServiceData(new AzureLocation("northeurope")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlMigrationServiceName, data); + SqlMigrationServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +53,10 @@ public async Task Get_GetMigrationService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMigrationService() + public async Task CreateOrUpdate_CreateOrUpdateSQLMigrationServiceWithMinimumParameters() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/GetMigrationService.json - // this example is just showing the usage of "SqlMigrationServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/CreateOrUpdateMigrationServiceMIN.json + // this example is just showing the usage of "SqlMigrationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +74,21 @@ public async Task Exists_GetMigrationService() SqlMigrationServiceCollection collection = resourceGroupResource.GetSqlMigrationServices(); // invoke the operation - string sqlMigrationServiceName = "service1"; - bool result = await collection.ExistsAsync(sqlMigrationServiceName); + string sqlMigrationServiceName = "testagent"; + SqlMigrationServiceData data = new SqlMigrationServiceData(new AzureLocation("northeurope")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlMigrationServiceName, data); + SqlMigrationServiceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlMigrationServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMigrationService() + public async Task Get_GetMigrationService() { // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/GetMigrationService.json // this example is just showing the usage of "SqlMigrationServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -102,29 +110,21 @@ public async Task GetIfExists_GetMigrationService() // invoke the operation string sqlMigrationServiceName = "service1"; - NullableResponse response = await collection.GetIfExistsAsync(sqlMigrationServiceName); - SqlMigrationServiceResource result = response.HasValue ? response.Value : null; + SqlMigrationServiceResource result = await collection.GetAsync(sqlMigrationServiceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlMigrationServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlMigrationServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateSQLMigrationServiceWithMaximumParameters() + public async Task GetAll_GetMigrationServicesInTheResourceGroup() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/CreateOrUpdateMigrationServiceMAX.json - // this example is just showing the usage of "SqlMigrationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/ListByResourceGroupMigrationService.json + // this example is just showing the usage of "SqlMigrationServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,25 +141,25 @@ public async Task CreateOrUpdate_CreateOrUpdateSQLMigrationServiceWithMaximumPar // get the collection of this SqlMigrationServiceResource SqlMigrationServiceCollection collection = resourceGroupResource.GetSqlMigrationServices(); - // invoke the operation - string sqlMigrationServiceName = "testagent"; - SqlMigrationServiceData data = new SqlMigrationServiceData(new AzureLocation("northeurope")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlMigrationServiceName, data); - SqlMigrationServiceResource result = lro.Value; + // invoke the operation and iterate over the result + await foreach (SqlMigrationServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlMigrationServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlMigrationServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateSQLMigrationServiceWithMinimumParameters() + public async Task Exists_GetMigrationService() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/CreateOrUpdateMigrationServiceMIN.json - // this example is just showing the usage of "SqlMigrationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/GetMigrationService.json + // this example is just showing the usage of "SqlMigrationServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,24 +177,18 @@ public async Task CreateOrUpdate_CreateOrUpdateSQLMigrationServiceWithMinimumPar SqlMigrationServiceCollection collection = resourceGroupResource.GetSqlMigrationServices(); // invoke the operation - string sqlMigrationServiceName = "testagent"; - SqlMigrationServiceData data = new SqlMigrationServiceData(new AzureLocation("northeurope")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sqlMigrationServiceName, data); - SqlMigrationServiceResource result = lro.Value; + string sqlMigrationServiceName = "service1"; + bool result = await collection.ExistsAsync(sqlMigrationServiceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlMigrationServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetMigrationServicesInTheResourceGroup() + public async Task GetIfExists_GetMigrationService() { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/ListByResourceGroupMigrationService.json - // this example is just showing the usage of "SqlMigrationServices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/GetMigrationService.json + // this example is just showing the usage of "SqlMigrationServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -211,17 +205,23 @@ public async Task GetAll_GetMigrationServicesInTheResourceGroup() // get the collection of this SqlMigrationServiceResource SqlMigrationServiceCollection collection = resourceGroupResource.GetSqlMigrationServices(); - // invoke the operation and iterate over the result - await foreach (SqlMigrationServiceResource item in collection.GetAllAsync()) + // invoke the operation + string sqlMigrationServiceName = "service1"; + NullableResponse response = await collection.GetIfExistsAsync(sqlMigrationServiceName); + SqlMigrationServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SqlMigrationServiceData resourceData = item.Data; + SqlMigrationServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SqlMigrationServiceResource.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SqlMigrationServiceResource.cs index 046e5c05eadf8..bff1ae05dd7f6 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SqlMigrationServiceResource.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SqlMigrationServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DataMigration.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DataMigration.Samples @@ -94,11 +93,11 @@ public async Task Update_UpdateSQLMigrationService() SqlMigrationServiceResource sqlMigrationService = client.GetSqlMigrationServiceResource(sqlMigrationServiceResourceId); // invoke the operation - SqlMigrationServicePatch patch = new SqlMigrationServicePatch() + SqlMigrationServicePatch patch = new SqlMigrationServicePatch { Tags = { -["mytag"] = "myval", +["mytag"] = "myval" }, }; ArmOperation lro = await sqlMigrationService.UpdateAsync(WaitUntil.Completed, patch); @@ -158,7 +157,7 @@ public async Task RegenerateAuthKeys_RegenerateTheOfAuthenticationKeys() SqlMigrationServiceResource sqlMigrationService = client.GetSqlMigrationServiceResource(sqlMigrationServiceResourceId); // invoke the operation - RegenAuthKeys regenAuthKeys = new RegenAuthKeys() + RegenAuthKeys regenAuthKeys = new RegenAuthKeys { KeyName = "authKey1", }; @@ -188,7 +187,7 @@ public async Task DeleteNode_DeleteTheIntegrationRuntimeNode() SqlMigrationServiceResource sqlMigrationService = client.GetSqlMigrationServiceResource(sqlMigrationServiceResourceId); // invoke the operation - DeleteNode deleteNode = new DeleteNode() + DeleteNode deleteNode = new DeleteNode { NodeName = "nodeName", IntegrationRuntimeName = "IRName", @@ -252,36 +251,5 @@ public async Task GetMonitoringData_RetrieveTheMonitoringData() Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSqlMigrationServices_GetServicesInTheSubscriptions() - { - // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/ListBySubscriptionMigrationService.json - // this example is just showing the usage of "SqlMigrationServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/managedInstance1"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SqlMigrationServiceResource item in subscriptionResource.GetSqlMigrationServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SqlMigrationServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index f3f1bb83637d2..8fa9ec3759a3e 100644 --- a/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/datamigration/Azure.ResourceManager.DataMigration/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.DataMigration.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSqlMigrationServices_GetServicesInTheSubscriptions() + { + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/ListBySubscriptionMigrationService.json + // this example is just showing the usage of "SqlMigrationServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/managedInstance1"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SqlMigrationServiceResource item in subscriptionResource.GetSqlMigrationServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SqlMigrationServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetSkusResourceSkus_ListSkus() @@ -44,6 +75,67 @@ public async Task GetSkusResourceSkus_ListSkus() Console.WriteLine("Succeeded"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataMigrationServices_ServicesList() + { + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Services_List.json + // this example is just showing the usage of "Services_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fc04246f-04c5-437e-ac5e-206a19e7193f"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataMigrationServiceResource item in subscriptionResource.GetDataMigrationServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataMigrationServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckNameAvailabilityService_ServicesCheckNameAvailability() + { + // Generated from example definition: specification/datamigration/resource-manager/Microsoft.DataMigration/preview/2022-03-30-preview/examples/Services_CheckNameAvailability.json + // this example is just showing the usage of "Services_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fc04246f-04c5-437e-ac5e-206a19e7193f"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("eastus"); + NameAvailabilityRequest nameAvailabilityRequest = new NameAvailabilityRequest + { + Name = "DmsSdkService", + ResourceType = "services", + }; + NameAvailabilityResponse result = await subscriptionResource.CheckNameAvailabilityServiceAsync(location, nameAvailabilityRequest); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetUsages_ServicesUsages() diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareAccountCollection.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareAccountCollection.cs index cfb0a68ce7f84..bc753ddfe93a6 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareAccountCollection.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareAccountCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DataShareAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AccountsGet() + public async Task CreateOrUpdate_AccountsCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_Get.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_Create.json + // this example is just showing the usage of "Accounts_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task Get_AccountsGet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "12345678-1234-1234-12345678abc"; + string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; string resourceGroupName = "SampleResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -41,7 +41,16 @@ public async Task Get_AccountsGet() // invoke the operation string accountName = "Account1"; - DataShareAccountResource result = await collection.GetAsync(accountName); + DataShareAccountData data = new DataShareAccountData(new AzureLocation("West US 2"), new ManagedServiceIdentity("SystemAssigned")) + { + Tags = +{ +["tag1"] = "Red", +["tag2"] = "White" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + DataShareAccountResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_AccountsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AccountsGet() + public async Task Get_AccountsGet() { // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_Get.json // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +83,21 @@ public async Task Exists_AccountsGet() // invoke the operation string accountName = "Account1"; - bool result = await collection.ExistsAsync(accountName); + DataShareAccountResource result = await collection.GetAsync(accountName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AccountsGet() + public async Task GetAll_AccountsListByResourceGroup() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_Get.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_ListByResourceGroup.json + // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,7 +106,7 @@ public async Task GetIfExists_AccountsGet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "12345678-1234-1234-12345678abc"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "SampleResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -101,31 +114,25 @@ public async Task GetIfExists_AccountsGet() // get the collection of this DataShareAccountResource DataShareAccountCollection collection = resourceGroupResource.GetDataShareAccounts(); - // invoke the operation - string accountName = "Account1"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - DataShareAccountResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataShareAccountResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataShareAccountData resourceData = result.Data; + DataShareAccountData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AccountsCreate() + public async Task Exists_AccountsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_Create.json - // this example is just showing the usage of "Accounts_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_Get.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,7 +141,7 @@ public async Task CreateOrUpdate_AccountsCreate() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; + string subscriptionId = "12345678-1234-1234-12345678abc"; string resourceGroupName = "SampleResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -144,30 +151,17 @@ public async Task CreateOrUpdate_AccountsCreate() // invoke the operation string accountName = "Account1"; - DataShareAccountData data = new DataShareAccountData(new AzureLocation("West US 2"), new ManagedServiceIdentity("SystemAssigned")) - { - Tags = -{ -["tag1"] = "Red", -["tag2"] = "White", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); - DataShareAccountResource result = lro.Value; + bool result = await collection.ExistsAsync(accountName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AccountsListByResourceGroup() + public async Task GetIfExists_AccountsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_ListByResourceGroup.json - // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_Get.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,7 +170,7 @@ public async Task GetAll_AccountsListByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = "12345678-1234-1234-12345678abc"; string resourceGroupName = "SampleResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -184,17 +178,23 @@ public async Task GetAll_AccountsListByResourceGroup() // get the collection of this DataShareAccountResource DataShareAccountCollection collection = resourceGroupResource.GetDataShareAccounts(); - // invoke the operation and iterate over the result - await foreach (DataShareAccountResource item in collection.GetAllAsync()) + // invoke the operation + string accountName = "Account1"; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + DataShareAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataShareAccountData resourceData = item.Data; + DataShareAccountData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareAccountResource.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareAccountResource.cs index fab017ba45d19..5784aea573338 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareAccountResource.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareAccountResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DataShare.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DataShare.Samples { public partial class Sample_DataShareAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDataShareAccounts_AccountsListBySubscription() - { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_ListBySubscription.json - // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DataShareAccountResource item in subscriptionResource.GetDataShareAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_AccountsGet() @@ -126,12 +94,12 @@ public async Task Update_AccountsUpdate() DataShareAccountResource dataShareAccount = client.GetDataShareAccountResource(dataShareAccountResourceId); // invoke the operation - DataShareAccountPatch patch = new DataShareAccountPatch() + DataShareAccountPatch patch = new DataShareAccountPatch { Tags = { ["tag1"] = "Red", -["tag2"] = "White", +["tag2"] = "White" }, }; DataShareAccountResource result = await dataShareAccount.UpdateAsync(patch); diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareCollection.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareCollection.cs index 5407952db2980..6befafe6962fa 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareCollection.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataShareCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SharesGet() + public async Task CreateOrUpdate_SharesCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Get.json - // this example is just showing the usage of "Shares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Create.json + // this example is just showing the usage of "Shares_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,14 @@ public async Task Get_SharesGet() // invoke the operation string shareName = "Share1"; - DataShareResource result = await collection.GetAsync(shareName); + DataShareData data = new DataShareData + { + Description = "share description", + ShareKind = DataShareKind.CopyBased, + Terms = "Confidential", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, shareName, data); + DataShareResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +59,7 @@ public async Task Get_SharesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SharesGet() + public async Task Get_SharesGet() { // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Get.json // this example is just showing the usage of "Shares_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +82,21 @@ public async Task Exists_SharesGet() // invoke the operation string shareName = "Share1"; - bool result = await collection.ExistsAsync(shareName); + DataShareResource result = await collection.GetAsync(shareName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SharesGet() + public async Task GetAll_SharesListByAccount() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Get.json - // this example is just showing the usage of "Shares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_ListByAccount.json + // this example is just showing the usage of "Shares_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +114,25 @@ public async Task GetIfExists_SharesGet() // get the collection of this DataShareResource DataShareCollection collection = dataShareAccount.GetDataShares(); - // invoke the operation - string shareName = "Share1"; - NullableResponse response = await collection.GetIfExistsAsync(shareName); - DataShareResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataShareResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataShareData resourceData = result.Data; + DataShareData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SharesCreate() + public async Task Exists_SharesGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Create.json - // this example is just showing the usage of "Shares_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Get.json + // this example is just showing the usage of "Shares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,28 +152,17 @@ public async Task CreateOrUpdate_SharesCreate() // invoke the operation string shareName = "Share1"; - DataShareData data = new DataShareData() - { - Description = "share description", - ShareKind = DataShareKind.CopyBased, - Terms = "Confidential", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, shareName, data); - DataShareResource result = lro.Value; + bool result = await collection.ExistsAsync(shareName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SharesListByAccount() + public async Task GetIfExists_SharesGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_ListByAccount.json - // this example is just showing the usage of "Shares_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Get.json + // this example is just showing the usage of "Shares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_SharesListByAccount() // get the collection of this DataShareResource DataShareCollection collection = dataShareAccount.GetDataShares(); - // invoke the operation and iterate over the result - await foreach (DataShareResource item in collection.GetAllAsync()) + // invoke the operation + string shareName = "Share1"; + NullableResponse response = await collection.GetIfExistsAsync(shareName); + DataShareResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataShareData resourceData = item.Data; + DataShareData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareConsumerInvitationCollection.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareConsumerInvitationCollection.cs index 185890fc10076..117911dbe8c5d 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareConsumerInvitationCollection.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareConsumerInvitationCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DataShare.Samples @@ -17,65 +18,61 @@ public partial class Sample_DataShareConsumerInvitationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConsumerInvitationsListInvitations() + public async Task Get_ConsumerInvitationsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ConsumerInvitations_ListInvitations.json - // this example is just showing the usage of "ConsumerInvitations_ListInvitations" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ConsumerInvitations_Get.json + // this example is just showing the usage of "ConsumerInvitations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DataShareConsumerInvitationResource DataShareConsumerInvitationCollection collection = tenantResource.GetDataShareConsumerInvitations(); - // invoke the operation and iterate over the result - await foreach (DataShareConsumerInvitationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareConsumerInvitationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + AzureLocation location = new AzureLocation("East US 2"); + Guid invitationId = Guid.Parse("dfbbc788-19eb-4607-a5a1-c74181bfff03"); + DataShareConsumerInvitationResource result = await collection.GetAsync(location, invitationId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareConsumerInvitationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConsumerInvitationsGet() + public async Task GetAll_ConsumerInvitationsListInvitations() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ConsumerInvitations_Get.json - // this example is just showing the usage of "ConsumerInvitations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ConsumerInvitations_ListInvitations.json + // this example is just showing the usage of "ConsumerInvitations_ListInvitations" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DataShareConsumerInvitationResource DataShareConsumerInvitationCollection collection = tenantResource.GetDataShareConsumerInvitations(); - // invoke the operation - AzureLocation location = new AzureLocation("East US 2"); - Guid invitationId = Guid.Parse("dfbbc788-19eb-4607-a5a1-c74181bfff03"); - DataShareConsumerInvitationResource result = await collection.GetAsync(location, invitationId); + // invoke the operation and iterate over the result + await foreach (DataShareConsumerInvitationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareConsumerInvitationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareConsumerInvitationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -90,9 +87,7 @@ public async Task Exists_ConsumerInvitationsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DataShareConsumerInvitationResource DataShareConsumerInvitationCollection collection = tenantResource.GetDataShareConsumerInvitations(); @@ -117,9 +112,7 @@ public async Task GetIfExists_ConsumerInvitationsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DataShareConsumerInvitationResource DataShareConsumerInvitationCollection collection = tenantResource.GetDataShareConsumerInvitations(); diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareConsumerInvitationResource.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareConsumerInvitationResource.cs index 640ac4537bdac..172c992659e97 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareConsumerInvitationResource.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareConsumerInvitationResource.cs @@ -43,33 +43,5 @@ public async Task Get_ConsumerInvitationsGet() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task RejectConsumerInvitation_ConsumerInvitationsRejectInvitation() - { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ConsumerInvitations_RejectInvitation.json - // this example is just showing the usage of "ConsumerInvitations_RejectInvitation" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - AzureLocation location = new AzureLocation("East US 2"); - DataShareConsumerInvitationData data = new DataShareConsumerInvitationData(Guid.Parse("dfbbc788-19eb-4607-a5a1-c74181bfff03")); - DataShareConsumerInvitationResource result = await tenantResource.RejectConsumerInvitationAsync(location, data); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareConsumerInvitationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareInvitationCollection.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareInvitationCollection.cs index daf78154b00f7..e855cf8dabfa2 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareInvitationCollection.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareInvitationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DataShareInvitationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_InvitationsGet() + public async Task CreateOrUpdate_InvitationsCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Get.json - // this example is just showing the usage of "Invitations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Create.json + // this example is just showing the usage of "Invitations_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,13 @@ public async Task Get_InvitationsGet() // invoke the operation string invitationName = "Invitation1"; - DataShareInvitationResource result = await collection.GetAsync(invitationName); + DataShareInvitationData data = new DataShareInvitationData + { + ExpireOn = DateTimeOffset.Parse("2020-08-26T22:33:24.5785265Z"), + TargetEmail = "receiver@microsoft.com", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, invitationName, data); + DataShareInvitationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +58,7 @@ public async Task Get_InvitationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_InvitationsGet() + public async Task Get_InvitationsGet() { // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Get.json // this example is just showing the usage of "Invitations_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +82,21 @@ public async Task Exists_InvitationsGet() // invoke the operation string invitationName = "Invitation1"; - bool result = await collection.ExistsAsync(invitationName); + DataShareInvitationResource result = await collection.GetAsync(invitationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareInvitationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_InvitationsGet() + public async Task GetAll_InvitationsListByShare() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Get.json - // this example is just showing the usage of "Invitations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_ListByShare.json + // this example is just showing the usage of "Invitations_ListByShare" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,31 +115,25 @@ public async Task GetIfExists_InvitationsGet() // get the collection of this DataShareInvitationResource DataShareInvitationCollection collection = dataShare.GetDataShareInvitations(); - // invoke the operation - string invitationName = "Invitation1"; - NullableResponse response = await collection.GetIfExistsAsync(invitationName); - DataShareInvitationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataShareInvitationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataShareInvitationData resourceData = result.Data; + DataShareInvitationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_InvitationsCreate() + public async Task Exists_InvitationsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Create.json - // this example is just showing the usage of "Invitations_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Get.json + // this example is just showing the usage of "Invitations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,27 +154,17 @@ public async Task CreateOrUpdate_InvitationsCreate() // invoke the operation string invitationName = "Invitation1"; - DataShareInvitationData data = new DataShareInvitationData() - { - ExpireOn = DateTimeOffset.Parse("2020-08-26T22:33:24.5785265Z"), - TargetEmail = "receiver@microsoft.com", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, invitationName, data); - DataShareInvitationResource result = lro.Value; + bool result = await collection.ExistsAsync(invitationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareInvitationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InvitationsListByShare() + public async Task GetIfExists_InvitationsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_ListByShare.json - // this example is just showing the usage of "Invitations_ListByShare" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Get.json + // this example is just showing the usage of "Invitations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_InvitationsListByShare() // get the collection of this DataShareInvitationResource DataShareInvitationCollection collection = dataShare.GetDataShareInvitations(); - // invoke the operation and iterate over the result - await foreach (DataShareInvitationResource item in collection.GetAllAsync()) + // invoke the operation + string invitationName = "Invitation1"; + NullableResponse response = await collection.GetIfExistsAsync(invitationName); + DataShareInvitationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataShareInvitationData resourceData = item.Data; + DataShareInvitationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareInvitationResource.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareInvitationResource.cs index 398a55c733ebf..3f325e31487a4 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareInvitationResource.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareInvitationResource.cs @@ -49,10 +49,10 @@ public async Task Get_InvitationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_InvitationsCreate() + public async Task Delete_InvitationsDelete() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Create.json - // this example is just showing the usage of "Invitations_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Delete.json + // this example is just showing the usage of "Invitations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,27 +70,17 @@ public async Task Update_InvitationsCreate() DataShareInvitationResource dataShareInvitation = client.GetDataShareInvitationResource(dataShareInvitationResourceId); // invoke the operation - DataShareInvitationData data = new DataShareInvitationData() - { - ExpireOn = DateTimeOffset.Parse("2020-08-26T22:33:24.5785265Z"), - TargetEmail = "receiver@microsoft.com", - }; - ArmOperation lro = await dataShareInvitation.UpdateAsync(WaitUntil.Completed, data); - DataShareInvitationResource result = lro.Value; + await dataShareInvitation.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareInvitationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_InvitationsDelete() + public async Task Update_InvitationsCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Delete.json - // this example is just showing the usage of "Invitations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Invitations_Create.json + // this example is just showing the usage of "Invitations_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +98,19 @@ public async Task Delete_InvitationsDelete() DataShareInvitationResource dataShareInvitation = client.GetDataShareInvitationResource(dataShareInvitationResourceId); // invoke the operation - await dataShareInvitation.DeleteAsync(WaitUntil.Completed); + DataShareInvitationData data = new DataShareInvitationData + { + ExpireOn = DateTimeOffset.Parse("2020-08-26T22:33:24.5785265Z"), + TargetEmail = "receiver@microsoft.com", + }; + ArmOperation lro = await dataShareInvitation.UpdateAsync(WaitUntil.Completed, data); + DataShareInvitationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareInvitationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareResource.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareResource.cs index 78b39b30a44f8..6d538bc553689 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareResource.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DataShareResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSynchronizationDetails_SharesListSynchronizationDetails() + public async Task Get_SharesGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_ListSynchronizationDetails.json - // this example is just showing the usage of "Shares_ListSynchronizationDetails" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Get.json + // this example is just showing the usage of "Shares_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,32 +30,29 @@ public async Task GetSynchronizationDetails_SharesListSynchronizationDetails() // this example assumes you already have this DataShareResource created on azure // for more information of creating DataShareResource, please refer to the document of DataShareResource - string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; + string subscriptionId = "12345678-1234-1234-12345678abc"; string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; string shareName = "Share1"; ResourceIdentifier dataShareResourceId = DataShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); DataShareResource dataShare = client.GetDataShareResource(dataShareResourceId); - // invoke the operation and iterate over the result - ShareSynchronization shareSynchronization = new ShareSynchronization() - { - SynchronizationId = Guid.Parse("7d0536a6-3fa5-43de-b152-3d07c4f6b2bb"), - }; - await foreach (SynchronizationDetails item in dataShare.GetSynchronizationDetailsAsync(shareSynchronization)) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + DataShareResource result = await dataShare.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSynchronizations_SharesListSynchronizations() + public async Task Delete_SharesDelete() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_ListSynchronizations.json - // this example is just showing the usage of "Shares_ListSynchronizations" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Delete.json + // this example is just showing the usage of "Shares_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,28 +61,26 @@ public async Task GetSynchronizations_SharesListSynchronizations() // this example assumes you already have this DataShareResource created on azure // for more information of creating DataShareResource, please refer to the document of DataShareResource - string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; + string subscriptionId = "12345678-1234-1234-12345678abc"; string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; string shareName = "Share1"; ResourceIdentifier dataShareResourceId = DataShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); DataShareResource dataShare = client.GetDataShareResource(dataShareResourceId); - // invoke the operation and iterate over the result - await foreach (ShareSynchronization item in dataShare.GetSynchronizationsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + ArmOperation lro = await dataShare.DeleteAsync(WaitUntil.Completed); + DataShareOperationResult result = lro.Value; - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SharesGet() + public async Task Update_SharesCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Get.json - // this example is just showing the usage of "Shares_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Create.json + // this example is just showing the usage of "Shares_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,7 +97,14 @@ public async Task Get_SharesGet() DataShareResource dataShare = client.GetDataShareResource(dataShareResourceId); // invoke the operation - DataShareResource result = await dataShare.GetAsync(); + DataShareData data = new DataShareData + { + Description = "share description", + ShareKind = DataShareKind.CopyBased, + Terms = "Confidential", + }; + ArmOperation lro = await dataShare.UpdateAsync(WaitUntil.Completed, data); + DataShareResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -113,10 +115,10 @@ public async Task Get_SharesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SharesCreate() + public async Task GetSynchronizationDetails_SharesListSynchronizationDetails() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Create.json - // this example is just showing the usage of "Shares_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_ListSynchronizationDetails.json + // this example is just showing the usage of "Shares_ListSynchronizationDetails" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,36 +127,32 @@ public async Task Update_SharesCreate() // this example assumes you already have this DataShareResource created on azure // for more information of creating DataShareResource, please refer to the document of DataShareResource - string subscriptionId = "12345678-1234-1234-12345678abc"; + string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; string shareName = "Share1"; ResourceIdentifier dataShareResourceId = DataShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); DataShareResource dataShare = client.GetDataShareResource(dataShareResourceId); - // invoke the operation - DataShareData data = new DataShareData() + // invoke the operation and iterate over the result + ShareSynchronization shareSynchronization = new ShareSynchronization { - Description = "share description", - ShareKind = DataShareKind.CopyBased, - Terms = "Confidential", + SynchronizationId = Guid.Parse("7d0536a6-3fa5-43de-b152-3d07c4f6b2bb"), }; - ArmOperation lro = await dataShare.UpdateAsync(WaitUntil.Completed, data); - DataShareResource result = lro.Value; + await foreach (SynchronizationDetails item in dataShare.GetSynchronizationDetailsAsync(shareSynchronization)) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SharesDelete() + public async Task GetSynchronizations_SharesListSynchronizations() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_Delete.json - // this example is just showing the usage of "Shares_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Shares_ListSynchronizations.json + // this example is just showing the usage of "Shares_ListSynchronizations" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -163,18 +161,20 @@ public async Task Delete_SharesDelete() // this example assumes you already have this DataShareResource created on azure // for more information of creating DataShareResource, please refer to the document of DataShareResource - string subscriptionId = "12345678-1234-1234-12345678abc"; + string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; string shareName = "Share1"; ResourceIdentifier dataShareResourceId = DataShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); DataShareResource dataShare = client.GetDataShareResource(dataShareResourceId); - // invoke the operation - ArmOperation lro = await dataShare.DeleteAsync(WaitUntil.Completed); - DataShareOperationResult result = lro.Value; + // invoke the operation and iterate over the result + await foreach (ShareSynchronization item in dataShare.GetSynchronizationsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareSynchronizationSettingCollection.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareSynchronizationSettingCollection.cs index 8710ee155003b..e6c5f6a0a64cb 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareSynchronizationSettingCollection.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareSynchronizationSettingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataShareSynchronizationSettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SynchronizationSettingsGet() + public async Task CreateOrUpdate_SynchronizationSettingsCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Get.json - // this example is just showing the usage of "SynchronizationSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Create.json + // this example is just showing the usage of "SynchronizationSettings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,8 +41,10 @@ public async Task Get_SynchronizationSettingsGet() DataShareSynchronizationSettingCollection collection = dataShare.GetDataShareSynchronizationSettings(); // invoke the operation - string synchronizationSettingName = "SynchronizationSetting1"; - DataShareSynchronizationSettingResource result = await collection.GetAsync(synchronizationSettingName); + string synchronizationSettingName = "Dataset1"; + DataShareSynchronizationSettingData data = new ScheduledSynchronizationSetting(DataShareSynchronizationRecurrenceInterval.Day, DateTimeOffset.Parse("2018-11-14T04:47:52.9614956Z")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, synchronizationSettingName, data); + DataShareSynchronizationSettingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +55,7 @@ public async Task Get_SynchronizationSettingsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SynchronizationSettingsGet() + public async Task Get_SynchronizationSettingsGet() { // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Get.json // this example is just showing the usage of "SynchronizationSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +79,21 @@ public async Task Exists_SynchronizationSettingsGet() // invoke the operation string synchronizationSettingName = "SynchronizationSetting1"; - bool result = await collection.ExistsAsync(synchronizationSettingName); + DataShareSynchronizationSettingResource result = await collection.GetAsync(synchronizationSettingName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareSynchronizationSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SynchronizationSettingsGet() + public async Task GetAll_SynchronizationSettingsListByShare() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Get.json - // this example is just showing the usage of "SynchronizationSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_ListByShare.json + // this example is just showing the usage of "SynchronizationSettings_ListByShare" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +112,25 @@ public async Task GetIfExists_SynchronizationSettingsGet() // get the collection of this DataShareSynchronizationSettingResource DataShareSynchronizationSettingCollection collection = dataShare.GetDataShareSynchronizationSettings(); - // invoke the operation - string synchronizationSettingName = "SynchronizationSetting1"; - NullableResponse response = await collection.GetIfExistsAsync(synchronizationSettingName); - DataShareSynchronizationSettingResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataShareSynchronizationSettingResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataShareSynchronizationSettingData resourceData = result.Data; + DataShareSynchronizationSettingData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SynchronizationSettingsCreate() + public async Task Exists_SynchronizationSettingsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Create.json - // this example is just showing the usage of "SynchronizationSettings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Get.json + // this example is just showing the usage of "SynchronizationSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,24 +150,18 @@ public async Task CreateOrUpdate_SynchronizationSettingsCreate() DataShareSynchronizationSettingCollection collection = dataShare.GetDataShareSynchronizationSettings(); // invoke the operation - string synchronizationSettingName = "Dataset1"; - DataShareSynchronizationSettingData data = new ScheduledSynchronizationSetting(DataShareSynchronizationRecurrenceInterval.Day, DateTimeOffset.Parse("2018-11-14T04:47:52.9614956Z")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, synchronizationSettingName, data); - DataShareSynchronizationSettingResource result = lro.Value; + string synchronizationSettingName = "SynchronizationSetting1"; + bool result = await collection.ExistsAsync(synchronizationSettingName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareSynchronizationSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SynchronizationSettingsListByShare() + public async Task GetIfExists_SynchronizationSettingsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_ListByShare.json - // this example is just showing the usage of "SynchronizationSettings_ListByShare" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Get.json + // this example is just showing the usage of "SynchronizationSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_SynchronizationSettingsListByShare() // get the collection of this DataShareSynchronizationSettingResource DataShareSynchronizationSettingCollection collection = dataShare.GetDataShareSynchronizationSettings(); - // invoke the operation and iterate over the result - await foreach (DataShareSynchronizationSettingResource item in collection.GetAllAsync()) + // invoke the operation + string synchronizationSettingName = "SynchronizationSetting1"; + NullableResponse response = await collection.GetIfExistsAsync(synchronizationSettingName); + DataShareSynchronizationSettingResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataShareSynchronizationSettingData resourceData = item.Data; + DataShareSynchronizationSettingData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareSynchronizationSettingResource.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareSynchronizationSettingResource.cs index 42e428b087def..6ff1f4490f07b 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareSynchronizationSettingResource.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareSynchronizationSettingResource.cs @@ -50,10 +50,10 @@ public async Task Get_SynchronizationSettingsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SynchronizationSettingsCreate() + public async Task Delete_SynchronizationSettingsDelete() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Create.json - // this example is just showing the usage of "SynchronizationSettings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Delete.json + // this example is just showing the usage of "SynchronizationSettings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,28 +66,23 @@ public async Task Update_SynchronizationSettingsCreate() string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; string shareName = "Share1"; - string synchronizationSettingName = "Dataset1"; + string synchronizationSettingName = "SynchronizationSetting1"; ResourceIdentifier dataShareSynchronizationSettingResourceId = DataShareSynchronizationSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName, synchronizationSettingName); DataShareSynchronizationSettingResource dataShareSynchronizationSetting = client.GetDataShareSynchronizationSettingResource(dataShareSynchronizationSettingResourceId); // invoke the operation - DataShareSynchronizationSettingData data = new ScheduledSynchronizationSetting(DataShareSynchronizationRecurrenceInterval.Day, DateTimeOffset.Parse("2018-11-14T04:47:52.9614956Z")); - ArmOperation lro = await dataShareSynchronizationSetting.UpdateAsync(WaitUntil.Completed, data); - DataShareSynchronizationSettingResource result = lro.Value; + ArmOperation lro = await dataShareSynchronizationSetting.DeleteAsync(WaitUntil.Completed); + DataShareOperationResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareSynchronizationSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SynchronizationSettingsDelete() + public async Task Update_SynchronizationSettingsCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Delete.json - // this example is just showing the usage of "SynchronizationSettings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/SynchronizationSettings_Create.json + // this example is just showing the usage of "SynchronizationSettings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,15 +95,20 @@ public async Task Delete_SynchronizationSettingsDelete() string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; string shareName = "Share1"; - string synchronizationSettingName = "SynchronizationSetting1"; + string synchronizationSettingName = "Dataset1"; ResourceIdentifier dataShareSynchronizationSettingResourceId = DataShareSynchronizationSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName, synchronizationSettingName); DataShareSynchronizationSettingResource dataShareSynchronizationSetting = client.GetDataShareSynchronizationSettingResource(dataShareSynchronizationSettingResourceId); // invoke the operation - ArmOperation lro = await dataShareSynchronizationSetting.DeleteAsync(WaitUntil.Completed); - DataShareOperationResult result = lro.Value; + DataShareSynchronizationSettingData data = new ScheduledSynchronizationSetting(DataShareSynchronizationRecurrenceInterval.Day, DateTimeOffset.Parse("2018-11-14T04:47:52.9614956Z")); + ArmOperation lro = await dataShareSynchronizationSetting.UpdateAsync(WaitUntil.Completed, data); + DataShareSynchronizationSettingResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareSynchronizationSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareTriggerCollection.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareTriggerCollection.cs index 8e9c63273123b..2a8e33ef2f858 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareTriggerCollection.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareTriggerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DataShareTriggerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TriggersGet() + public async Task CreateOrUpdate_TriggersCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Get.json - // this example is just showing the usage of "Triggers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Create.json + // this example is just showing the usage of "Triggers_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,12 @@ public async Task Get_TriggersGet() // invoke the operation string triggerName = "Trigger1"; - DataShareTriggerResource result = await collection.GetAsync(triggerName); + DataShareTriggerData data = new ScheduledTrigger(DataShareSynchronizationRecurrenceInterval.Day, DateTimeOffset.Parse("2018-11-14T04:47:52.9614956Z")) + { + SynchronizationMode = SynchronizationMode.Incremental, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, triggerName, data); + DataShareTriggerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +58,7 @@ public async Task Get_TriggersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TriggersGet() + public async Task Get_TriggersGet() { // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Get.json // this example is just showing the usage of "Triggers_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +82,21 @@ public async Task Exists_TriggersGet() // invoke the operation string triggerName = "Trigger1"; - bool result = await collection.ExistsAsync(triggerName); + DataShareTriggerResource result = await collection.GetAsync(triggerName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TriggersGet() + public async Task GetAll_TriggersListByShareSubscription() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Get.json - // this example is just showing the usage of "Triggers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_ListByShareSubscription.json + // this example is just showing the usage of "Triggers_ListByShareSubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +115,25 @@ public async Task GetIfExists_TriggersGet() // get the collection of this DataShareTriggerResource DataShareTriggerCollection collection = shareSubscription.GetDataShareTriggers(); - // invoke the operation - string triggerName = "Trigger1"; - NullableResponse response = await collection.GetIfExistsAsync(triggerName); - DataShareTriggerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DataShareTriggerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataShareTriggerData resourceData = result.Data; + DataShareTriggerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_TriggersCreate() + public async Task Exists_TriggersGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Create.json - // this example is just showing the usage of "Triggers_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Get.json + // this example is just showing the usage of "Triggers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,26 +154,17 @@ public async Task CreateOrUpdate_TriggersCreate() // invoke the operation string triggerName = "Trigger1"; - DataShareTriggerData data = new ScheduledTrigger(DataShareSynchronizationRecurrenceInterval.Day, DateTimeOffset.Parse("2018-11-14T04:47:52.9614956Z")) - { - SynchronizationMode = SynchronizationMode.Incremental, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, triggerName, data); - DataShareTriggerResource result = lro.Value; + bool result = await collection.ExistsAsync(triggerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TriggersListByShareSubscription() + public async Task GetIfExists_TriggersGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_ListByShareSubscription.json - // this example is just showing the usage of "Triggers_ListByShareSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Get.json + // this example is just showing the usage of "Triggers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_TriggersListByShareSubscription() // get the collection of this DataShareTriggerResource DataShareTriggerCollection collection = shareSubscription.GetDataShareTriggers(); - // invoke the operation and iterate over the result - await foreach (DataShareTriggerResource item in collection.GetAllAsync()) + // invoke the operation + string triggerName = "Trigger1"; + NullableResponse response = await collection.GetIfExistsAsync(triggerName); + DataShareTriggerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DataShareTriggerData resourceData = item.Data; + DataShareTriggerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareTriggerResource.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareTriggerResource.cs index d8e8b6e636feb..25194f79117fe 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareTriggerResource.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_DataShareTriggerResource.cs @@ -50,10 +50,10 @@ public async Task Get_TriggersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_TriggersCreate() + public async Task Delete_TriggersDelete() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Create.json - // this example is just showing the usage of "Triggers_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Delete.json + // this example is just showing the usage of "Triggers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,26 +71,18 @@ public async Task Update_TriggersCreate() DataShareTriggerResource dataShareTrigger = client.GetDataShareTriggerResource(dataShareTriggerResourceId); // invoke the operation - DataShareTriggerData data = new ScheduledTrigger(DataShareSynchronizationRecurrenceInterval.Day, DateTimeOffset.Parse("2018-11-14T04:47:52.9614956Z")) - { - SynchronizationMode = SynchronizationMode.Incremental, - }; - ArmOperation lro = await dataShareTrigger.UpdateAsync(WaitUntil.Completed, data); - DataShareTriggerResource result = lro.Value; + ArmOperation lro = await dataShareTrigger.DeleteAsync(WaitUntil.Completed); + DataShareOperationResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataShareTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_TriggersDelete() + public async Task Update_TriggersCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Delete.json - // this example is just showing the usage of "Triggers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Triggers_Create.json + // this example is just showing the usage of "Triggers_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,10 +100,18 @@ public async Task Delete_TriggersDelete() DataShareTriggerResource dataShareTrigger = client.GetDataShareTriggerResource(dataShareTriggerResourceId); // invoke the operation - ArmOperation lro = await dataShareTrigger.DeleteAsync(WaitUntil.Completed); - DataShareOperationResult result = lro.Value; + DataShareTriggerData data = new ScheduledTrigger(DataShareSynchronizationRecurrenceInterval.Day, DateTimeOffset.Parse("2018-11-14T04:47:52.9614956Z")) + { + SynchronizationMode = SynchronizationMode.Incremental, + }; + ArmOperation lro = await dataShareTrigger.UpdateAsync(WaitUntil.Completed, data); + DataShareTriggerResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ProviderShareSubscriptionCollection.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ProviderShareSubscriptionCollection.cs index 551c835619f32..49eedbab232d2 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ProviderShareSubscriptionCollection.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ProviderShareSubscriptionCollection.cs @@ -52,10 +52,10 @@ public async Task Get_ProviderShareSubscriptionsGetByShare() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProviderShareSubscriptionsGetByShare() + public async Task GetAll_ProviderShareSubscriptionsListByShare() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_GetByShare.json - // this example is just showing the usage of "ProviderShareSubscriptions_GetByShare" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_ListByShare.json + // this example is just showing the usage of "ProviderShareSubscriptions_ListByShare" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,16 +74,22 @@ public async Task Exists_ProviderShareSubscriptionsGetByShare() // get the collection of this ProviderShareSubscriptionResource ProviderShareSubscriptionCollection collection = dataShare.GetProviderShareSubscriptions(); - // invoke the operation - string providerShareSubscriptionId = "4256e2cf-0f82-4865-961b-12f83333f487"; - bool result = await collection.ExistsAsync(providerShareSubscriptionId); + // invoke the operation and iterate over the result + await foreach (ProviderShareSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProviderShareSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProviderShareSubscriptionsGetByShare() + public async Task Exists_ProviderShareSubscriptionsGetByShare() { // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_GetByShare.json // this example is just showing the usage of "ProviderShareSubscriptions_GetByShare" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +113,17 @@ public async Task GetIfExists_ProviderShareSubscriptionsGetByShare() // invoke the operation string providerShareSubscriptionId = "4256e2cf-0f82-4865-961b-12f83333f487"; - NullableResponse response = await collection.GetIfExistsAsync(providerShareSubscriptionId); - ProviderShareSubscriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(providerShareSubscriptionId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProviderShareSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProviderShareSubscriptionsListByShare() + public async Task GetIfExists_ProviderShareSubscriptionsGetByShare() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_ListByShare.json - // this example is just showing the usage of "ProviderShareSubscriptions_ListByShare" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_GetByShare.json + // this example is just showing the usage of "ProviderShareSubscriptions_GetByShare" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,17 +142,23 @@ public async Task GetAll_ProviderShareSubscriptionsListByShare() // get the collection of this ProviderShareSubscriptionResource ProviderShareSubscriptionCollection collection = dataShare.GetProviderShareSubscriptions(); - // invoke the operation and iterate over the result - await foreach (ProviderShareSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string providerShareSubscriptionId = "4256e2cf-0f82-4865-961b-12f83333f487"; + NullableResponse response = await collection.GetIfExistsAsync(providerShareSubscriptionId); + ProviderShareSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ProviderShareSubscriptionData resourceData = item.Data; + ProviderShareSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ProviderShareSubscriptionResource.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ProviderShareSubscriptionResource.cs index b54a352b17e57..4cf53bb29e3b6 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ProviderShareSubscriptionResource.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ProviderShareSubscriptionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ProviderShareSubscriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Adjust_ProviderShareSubscriptionsAdjust() + public async Task Get_ProviderShareSubscriptionsGetByShare() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_Adjust.json - // this example is just showing the usage of "ProviderShareSubscriptions_Adjust" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_GetByShare.json + // this example is just showing the usage of "ProviderShareSubscriptions_GetByShare" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,11 +38,7 @@ public async Task Adjust_ProviderShareSubscriptionsAdjust() ProviderShareSubscriptionResource providerShareSubscription = client.GetProviderShareSubscriptionResource(providerShareSubscriptionResourceId); // invoke the operation - ProviderShareSubscriptionData data = new ProviderShareSubscriptionData() - { - ExpireOn = DateTimeOffset.Parse("2020-12-26T22:33:24.5785265Z"), - }; - ProviderShareSubscriptionResource result = await providerShareSubscription.AdjustAsync(data); + ProviderShareSubscriptionResource result = await providerShareSubscription.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +49,10 @@ public async Task Adjust_ProviderShareSubscriptionsAdjust() [Test] [Ignore("Only validating compilation of examples")] - public async Task Reinstate_ProviderShareSubscriptionsReinstate() + public async Task Adjust_ProviderShareSubscriptionsAdjust() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_Reinstate.json - // this example is just showing the usage of "ProviderShareSubscriptions_Reinstate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_Adjust.json + // this example is just showing the usage of "ProviderShareSubscriptions_Adjust" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,11 +70,11 @@ public async Task Reinstate_ProviderShareSubscriptionsReinstate() ProviderShareSubscriptionResource providerShareSubscription = client.GetProviderShareSubscriptionResource(providerShareSubscriptionResourceId); // invoke the operation - ProviderShareSubscriptionData data = new ProviderShareSubscriptionData() + ProviderShareSubscriptionData data = new ProviderShareSubscriptionData { ExpireOn = DateTimeOffset.Parse("2020-12-26T22:33:24.5785265Z"), }; - ProviderShareSubscriptionResource result = await providerShareSubscription.ReinstateAsync(data); + ProviderShareSubscriptionResource result = await providerShareSubscription.AdjustAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +85,10 @@ public async Task Reinstate_ProviderShareSubscriptionsReinstate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Revoke_ProviderShareSubscriptionsRevoke() + public async Task Reinstate_ProviderShareSubscriptionsReinstate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_Revoke.json - // this example is just showing the usage of "ProviderShareSubscriptions_Revoke" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_Reinstate.json + // this example is just showing the usage of "ProviderShareSubscriptions_Reinstate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,8 +106,11 @@ public async Task Revoke_ProviderShareSubscriptionsRevoke() ProviderShareSubscriptionResource providerShareSubscription = client.GetProviderShareSubscriptionResource(providerShareSubscriptionResourceId); // invoke the operation - ArmOperation lro = await providerShareSubscription.RevokeAsync(WaitUntil.Completed); - ProviderShareSubscriptionResource result = lro.Value; + ProviderShareSubscriptionData data = new ProviderShareSubscriptionData + { + ExpireOn = DateTimeOffset.Parse("2020-12-26T22:33:24.5785265Z"), + }; + ProviderShareSubscriptionResource result = await providerShareSubscription.ReinstateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -122,10 +121,10 @@ public async Task Revoke_ProviderShareSubscriptionsRevoke() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProviderShareSubscriptionsGetByShare() + public async Task Revoke_ProviderShareSubscriptionsRevoke() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_GetByShare.json - // this example is just showing the usage of "ProviderShareSubscriptions_GetByShare" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ProviderShareSubscriptions_Revoke.json + // this example is just showing the usage of "ProviderShareSubscriptions_Revoke" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,7 +142,8 @@ public async Task Get_ProviderShareSubscriptionsGetByShare() ProviderShareSubscriptionResource providerShareSubscription = client.GetProviderShareSubscriptionResource(providerShareSubscriptionResourceId); // invoke the operation - ProviderShareSubscriptionResource result = await providerShareSubscription.GetAsync(); + ArmOperation lro = await providerShareSubscription.RevokeAsync(WaitUntil.Completed); + ProviderShareSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetCollection.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetCollection.cs index 46a5aa3bdb3e9..848622da94706 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetCollection.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ShareDataSetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataSetsGet() + public async Task CreateOrUpdate_DataSetsCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_Get.json - // this example is just showing the usage of "DataSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_Create.json + // this example is just showing the usage of "DataSets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,9 @@ public async Task Get_DataSetsGet() // invoke the operation string dataSetName = "Dataset1"; - ShareDataSetResource result = await collection.GetAsync(dataSetName); + ShareDataSetData data = new BlobDataSet("C1", "file21", "SampleResourceGroup", "storage2", "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetName, data); + ShareDataSetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +55,10 @@ public async Task Get_DataSetsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DataSetsGet() + public async Task CreateOrUpdate_DataSetsKustoClusterCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_Get.json - // this example is just showing the usage of "DataSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_KustoCluster_Create.json + // this example is just showing the usage of "DataSets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,17 +79,23 @@ public async Task Exists_DataSetsGet() // invoke the operation string dataSetName = "Dataset1"; - bool result = await collection.ExistsAsync(dataSetName); + ShareDataSetData data = new KustoClusterDataSet(new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Kusto/clusters/Cluster1")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetName, data); + ShareDataSetResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ShareDataSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DataSetsGet() + public async Task CreateOrUpdate_DataSetsKustoDatabaseCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_Get.json - // this example is just showing the usage of "DataSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_KustoDatabase_Create.json + // this example is just showing the usage of "DataSets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,28 +116,22 @@ public async Task GetIfExists_DataSetsGet() // invoke the operation string dataSetName = "Dataset1"; - NullableResponse response = await collection.GetIfExistsAsync(dataSetName); - ShareDataSetResource result = response.HasValue ? response.Value : null; + ShareDataSetData data = new KustoDatabaseDataSet(new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Kusto/clusters/Cluster1/databases/Database1")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetName, data); + ShareDataSetResource result = lro.Value; - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ShareDataSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ShareDataSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetsCreate() + public async Task CreateOrUpdate_DataSetsKustoTableCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_Create.json + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_KustoTable_Create.json // this example is just showing the usage of "DataSets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -151,7 +153,15 @@ public async Task CreateOrUpdate_DataSetsCreate() // invoke the operation string dataSetName = "Dataset1"; - ShareDataSetData data = new BlobDataSet("C1", "file21", "SampleResourceGroup", "storage2", "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"); + ShareDataSetData data = new KustoTableDataSet(new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Kusto/clusters/Cluster1/databases/Database1"), new TableLevelSharingProperties + { + ExternalTablesToExclude = { "test11", "test12" }, + ExternalTablesToInclude = { "test9", "test10" }, + MaterializedViewsToExclude = { "test7", "test8" }, + MaterializedViewsToInclude = { "test5", "test6" }, + TablesToExclude = { "test3", "test4" }, + TablesToInclude = { "test1", "test2" }, + }); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetName, data); ShareDataSetResource result = lro.Value; @@ -164,9 +174,9 @@ public async Task CreateOrUpdate_DataSetsCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetsKustoClusterCreate() + public async Task CreateOrUpdate_DataSetsSqlDBTableCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_KustoCluster_Create.json + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_SqlDBTable_Create.json // this example is just showing the usage of "DataSets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -188,7 +198,13 @@ public async Task CreateOrUpdate_DataSetsKustoClusterCreate() // invoke the operation string dataSetName = "Dataset1"; - ShareDataSetData data = new KustoClusterDataSet(new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Kusto/clusters/Cluster1")); + ShareDataSetData data = new SqlDBTableDataSet + { + DatabaseName = "SqlDB1", + SchemaName = "dbo", + SqlServerResourceId = new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Sql/servers/Server1"), + TableName = "Table1", + }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetName, data); ShareDataSetResource result = lro.Value; @@ -201,9 +217,9 @@ public async Task CreateOrUpdate_DataSetsKustoClusterCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetsKustoDatabaseCreate() + public async Task CreateOrUpdate_DataSetsSqlDWTableCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_KustoDatabase_Create.json + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_SqlDWTable_Create.json // this example is just showing the usage of "DataSets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -225,7 +241,13 @@ public async Task CreateOrUpdate_DataSetsKustoDatabaseCreate() // invoke the operation string dataSetName = "Dataset1"; - ShareDataSetData data = new KustoDatabaseDataSet(new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Kusto/clusters/Cluster1/databases/Database1")); + ShareDataSetData data = new SqlDWTableDataSet + { + DataWarehouseName = "DataWarehouse1", + SchemaName = "dbo", + SqlServerResourceId = new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Sql/servers/Server1"), + TableName = "Table1", + }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetName, data); ShareDataSetResource result = lro.Value; @@ -238,9 +260,9 @@ public async Task CreateOrUpdate_DataSetsKustoDatabaseCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetsKustoTableCreate() + public async Task CreateOrUpdate_DataSetsSynapseWorkspaceSqlPoolTableCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_KustoTable_Create.json + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_SynapseWorkspaceSqlPoolTable_Create.json // this example is just showing the usage of "DataSets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -250,10 +272,10 @@ public async Task CreateOrUpdate_DataSetsKustoTableCreate() // this example assumes you already have this DataShareResource created on azure // for more information of creating DataShareResource, please refer to the document of DataShareResource - string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; + string subscriptionId = "0f3dcfc3-18f8-4099-b381-8353e19d43a7"; string resourceGroupName = "SampleResourceGroup"; - string accountName = "Account1"; - string shareName = "Share1"; + string accountName = "sourceAccount"; + string shareName = "share1"; ResourceIdentifier dataShareResourceId = DataShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); DataShareResource dataShare = client.GetDataShareResource(dataShareResourceId); @@ -261,34 +283,8 @@ public async Task CreateOrUpdate_DataSetsKustoTableCreate() ShareDataSetCollection collection = dataShare.GetShareDataSets(); // invoke the operation - string dataSetName = "Dataset1"; - ShareDataSetData data = new KustoTableDataSet(new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Kusto/clusters/Cluster1/databases/Database1"), new TableLevelSharingProperties() - { - ExternalTablesToExclude = -{ -"test11","test12" -}, - ExternalTablesToInclude = -{ -"test9","test10" -}, - MaterializedViewsToExclude = -{ -"test7","test8" -}, - MaterializedViewsToInclude = -{ -"test5","test6" -}, - TablesToExclude = -{ -"test3","test4" -}, - TablesToInclude = -{ -"test1","test2" -}, - }); + string dataSetName = "dataset1"; + ShareDataSetData data = new SynapseWorkspaceSqlPoolTableDataSet(new ResourceIdentifier("/subscriptions/0f3dcfc3-18f8-4099-b381-8353e19d43a7/resourceGroups/SampleResourceGroup/providers/Microsoft.Synapse/workspaces/ExampleWorkspace/sqlPools/ExampleSqlPool/schemas/dbo/tables/table1")); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetName, data); ShareDataSetResource result = lro.Value; @@ -301,10 +297,10 @@ public async Task CreateOrUpdate_DataSetsKustoTableCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetsSqlDBTableCreate() + public async Task Get_DataSetsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_SqlDBTable_Create.json - // this example is just showing the usage of "DataSets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_Get.json + // this example is just showing the usage of "DataSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -325,15 +321,7 @@ public async Task CreateOrUpdate_DataSetsSqlDBTableCreate() // invoke the operation string dataSetName = "Dataset1"; - ShareDataSetData data = new SqlDBTableDataSet() - { - DatabaseName = "SqlDB1", - SchemaName = "dbo", - SqlServerResourceId = new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Sql/servers/Server1"), - TableName = "Table1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetName, data); - ShareDataSetResource result = lro.Value; + ShareDataSetResource result = await collection.GetAsync(dataSetName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -344,10 +332,10 @@ public async Task CreateOrUpdate_DataSetsSqlDBTableCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetsSqlDWTableCreate() + public async Task GetAll_DataSetsListByShare() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_SqlDWTable_Create.json - // this example is just showing the usage of "DataSets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_ListByShare.json + // this example is just showing the usage of "DataSets_ListByShare" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -366,31 +354,25 @@ public async Task CreateOrUpdate_DataSetsSqlDWTableCreate() // get the collection of this ShareDataSetResource ShareDataSetCollection collection = dataShare.GetShareDataSets(); - // invoke the operation - string dataSetName = "Dataset1"; - ShareDataSetData data = new SqlDWTableDataSet() + // invoke the operation and iterate over the result + await foreach (ShareDataSetResource item in collection.GetAllAsync()) { - DataWarehouseName = "DataWarehouse1", - SchemaName = "dbo", - SqlServerResourceId = new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Sql/servers/Server1"), - TableName = "Table1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetName, data); - ShareDataSetResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ShareDataSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ShareDataSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetsSynapseWorkspaceSqlPoolTableCreate() + public async Task Exists_DataSetsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_SynapseWorkspaceSqlPoolTable_Create.json - // this example is just showing the usage of "DataSets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_Get.json + // this example is just showing the usage of "DataSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -399,10 +381,10 @@ public async Task CreateOrUpdate_DataSetsSynapseWorkspaceSqlPoolTableCreate() // this example assumes you already have this DataShareResource created on azure // for more information of creating DataShareResource, please refer to the document of DataShareResource - string subscriptionId = "0f3dcfc3-18f8-4099-b381-8353e19d43a7"; + string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; string resourceGroupName = "SampleResourceGroup"; - string accountName = "sourceAccount"; - string shareName = "share1"; + string accountName = "Account1"; + string shareName = "Share1"; ResourceIdentifier dataShareResourceId = DataShareResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName); DataShareResource dataShare = client.GetDataShareResource(dataShareResourceId); @@ -410,24 +392,18 @@ public async Task CreateOrUpdate_DataSetsSynapseWorkspaceSqlPoolTableCreate() ShareDataSetCollection collection = dataShare.GetShareDataSets(); // invoke the operation - string dataSetName = "dataset1"; - ShareDataSetData data = new SynapseWorkspaceSqlPoolTableDataSet(new ResourceIdentifier("/subscriptions/0f3dcfc3-18f8-4099-b381-8353e19d43a7/resourceGroups/SampleResourceGroup/providers/Microsoft.Synapse/workspaces/ExampleWorkspace/sqlPools/ExampleSqlPool/schemas/dbo/tables/table1")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetName, data); - ShareDataSetResource result = lro.Value; + string dataSetName = "Dataset1"; + bool result = await collection.ExistsAsync(dataSetName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ShareDataSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DataSetsListByShare() + public async Task GetIfExists_DataSetsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_ListByShare.json - // this example is just showing the usage of "DataSets_ListByShare" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_Get.json + // this example is just showing the usage of "DataSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -446,17 +422,23 @@ public async Task GetAll_DataSetsListByShare() // get the collection of this ShareDataSetResource ShareDataSetCollection collection = dataShare.GetShareDataSets(); - // invoke the operation and iterate over the result - await foreach (ShareDataSetResource item in collection.GetAllAsync()) + // invoke the operation + string dataSetName = "Dataset1"; + NullableResponse response = await collection.GetIfExistsAsync(dataSetName); + ShareDataSetResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ShareDataSetData resourceData = item.Data; + ShareDataSetData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetMappingCollection.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetMappingCollection.cs index 854cd863e3fca..af6fa57a4adb3 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetMappingCollection.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetMappingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ShareDataSetMappingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DataSetMappingsGet() + public async Task CreateOrUpdate_DataSetMappingsCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_Get.json - // this example is just showing the usage of "DataSetMappings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_Create.json + // this example is just showing the usage of "DataSetMappings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,15 @@ public async Task Get_DataSetMappingsGet() // invoke the operation string dataSetMappingName = "DatasetMapping1"; - ShareDataSetMappingResource result = await collection.GetAsync(dataSetMappingName); + ShareDataSetMappingData data = new BlobDataSetMapping( + "C1", + Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), + "file21", + "SampleResourceGroup", + "storage2", + "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetMappingName, data); + ShareDataSetMappingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +61,10 @@ public async Task Get_DataSetMappingsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DataSetMappingsGet() + public async Task CreateOrUpdate_DataSetMappingsSqlDBCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_Get.json - // this example is just showing the usage of "DataSetMappings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_SqlDB_Create.json + // this example is just showing the usage of "DataSetMappings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,17 +85,23 @@ public async Task Exists_DataSetMappingsGet() // invoke the operation string dataSetMappingName = "DatasetMapping1"; - bool result = await collection.ExistsAsync(dataSetMappingName); + ShareDataSetMappingData data = new SqlDBTableDataSetMapping("Database1", Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), "dbo", new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Sql/servers/Server1"), "Table1"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetMappingName, data); + ShareDataSetMappingResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ShareDataSetMappingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DataSetMappingsGet() + public async Task CreateOrUpdate_DataSetMappingsSqlDWDataSetToAdlsGen2FileCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_Get.json - // this example is just showing the usage of "DataSetMappings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_SqlDWDataSetToAdlsGen2File_Create.json + // this example is just showing the usage of "DataSetMappings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,28 +122,31 @@ public async Task GetIfExists_DataSetMappingsGet() // invoke the operation string dataSetMappingName = "DatasetMapping1"; - NullableResponse response = await collection.GetIfExistsAsync(dataSetMappingName); - ShareDataSetMappingResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + ShareDataSetMappingData data = new AdlsGen2FileDataSetMapping( + Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), + "file21", + "fileSystem", + "SampleResourceGroup", + "storage2", + "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a") { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ShareDataSetMappingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + OutputType = DataShareOutputType.Csv, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetMappingName, data); + ShareDataSetMappingResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ShareDataSetMappingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetMappingsCreate() + public async Task CreateOrUpdate_DataSetMappingsSqlDWCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_Create.json + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_SqlDW_Create.json // this example is just showing the usage of "DataSetMappings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -151,7 +168,7 @@ public async Task CreateOrUpdate_DataSetMappingsCreate() // invoke the operation string dataSetMappingName = "DatasetMapping1"; - ShareDataSetMappingData data = new BlobDataSetMapping("C1", Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), "file21", "SampleResourceGroup", "storage2", "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"); + ShareDataSetMappingData data = new SqlDWTableDataSetMapping(Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), "DataWarehouse1", "dbo", new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Sql/servers/Server1"), "Table1"); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetMappingName, data); ShareDataSetMappingResource result = lro.Value; @@ -164,9 +181,9 @@ public async Task CreateOrUpdate_DataSetMappingsCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetMappingsSqlDBCreate() + public async Task CreateOrUpdate_DataSetMappingsSynapseWorkspaceSqlPoolTableCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_SqlDB_Create.json + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_SynapseWorkspaceSqlPoolTable_Create.json // this example is just showing the usage of "DataSetMappings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -176,9 +193,9 @@ public async Task CreateOrUpdate_DataSetMappingsSqlDBCreate() // this example assumes you already have this ShareSubscriptionResource created on azure // for more information of creating ShareSubscriptionResource, please refer to the document of ShareSubscriptionResource - string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; + string subscriptionId = "0f3dcfc3-18f8-4099-b381-8353e19d43a7"; string resourceGroupName = "SampleResourceGroup"; - string accountName = "Account1"; + string accountName = "consumerAccount"; string shareSubscriptionName = "ShareSubscription1"; ResourceIdentifier shareSubscriptionResourceId = ShareSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareSubscriptionName); ShareSubscriptionResource shareSubscription = client.GetShareSubscriptionResource(shareSubscriptionResourceId); @@ -187,8 +204,8 @@ public async Task CreateOrUpdate_DataSetMappingsSqlDBCreate() ShareDataSetMappingCollection collection = shareSubscription.GetShareDataSetMappings(); // invoke the operation - string dataSetMappingName = "DatasetMapping1"; - ShareDataSetMappingData data = new SqlDBTableDataSetMapping("Database1", Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), "dbo", new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Sql/servers/Server1"), "Table1"); + string dataSetMappingName = "datasetMappingName1"; + ShareDataSetMappingData data = new SynapseWorkspaceSqlPoolTableDataSetMapping(Guid.Parse("3dc64e49-1fc3-4186-b3dc-d388c4d3076a"), new ResourceIdentifier("/subscriptions/0f3dcfc3-18f8-4099-b381-8353e19d43a7/resourceGroups/SampleResourceGroup/providers/Microsoft.Synapse/workspaces/ExampleWorkspace/sqlPools/ExampleSqlPool/schemas/dbo/tables/table1")); ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetMappingName, data); ShareDataSetMappingResource result = lro.Value; @@ -201,10 +218,10 @@ public async Task CreateOrUpdate_DataSetMappingsSqlDBCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetMappingsSqlDWDataSetToAdlsGen2FileCreate() + public async Task Get_DataSetMappingsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_SqlDWDataSetToAdlsGen2File_Create.json - // this example is just showing the usage of "DataSetMappings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_Get.json + // this example is just showing the usage of "DataSetMappings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -225,12 +242,7 @@ public async Task CreateOrUpdate_DataSetMappingsSqlDWDataSetToAdlsGen2FileCreate // invoke the operation string dataSetMappingName = "DatasetMapping1"; - ShareDataSetMappingData data = new AdlsGen2FileDataSetMapping(Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), "file21", "fileSystem", "SampleResourceGroup", "storage2", "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a") - { - OutputType = DataShareOutputType.Csv, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetMappingName, data); - ShareDataSetMappingResource result = lro.Value; + ShareDataSetMappingResource result = await collection.GetAsync(dataSetMappingName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -241,10 +253,10 @@ public async Task CreateOrUpdate_DataSetMappingsSqlDWDataSetToAdlsGen2FileCreate [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetMappingsSqlDWCreate() + public async Task GetAll_DataSetMappingsListByShareSubscription() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_SqlDW_Create.json - // this example is just showing the usage of "DataSetMappings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_ListByShareSubscription.json + // this example is just showing the usage of "DataSetMappings_ListByShareSubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -263,25 +275,25 @@ public async Task CreateOrUpdate_DataSetMappingsSqlDWCreate() // get the collection of this ShareDataSetMappingResource ShareDataSetMappingCollection collection = shareSubscription.GetShareDataSetMappings(); - // invoke the operation - string dataSetMappingName = "DatasetMapping1"; - ShareDataSetMappingData data = new SqlDWTableDataSetMapping(Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), "DataWarehouse1", "dbo", new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Sql/servers/Server1"), "Table1"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetMappingName, data); - ShareDataSetMappingResource result = lro.Value; + // invoke the operation and iterate over the result + await foreach (ShareDataSetMappingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ShareDataSetMappingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ShareDataSetMappingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DataSetMappingsSynapseWorkspaceSqlPoolTableCreate() + public async Task Exists_DataSetMappingsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_SynapseWorkspaceSqlPoolTable_Create.json - // this example is just showing the usage of "DataSetMappings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_Get.json + // this example is just showing the usage of "DataSetMappings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -290,9 +302,9 @@ public async Task CreateOrUpdate_DataSetMappingsSynapseWorkspaceSqlPoolTableCrea // this example assumes you already have this ShareSubscriptionResource created on azure // for more information of creating ShareSubscriptionResource, please refer to the document of ShareSubscriptionResource - string subscriptionId = "0f3dcfc3-18f8-4099-b381-8353e19d43a7"; + string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; string resourceGroupName = "SampleResourceGroup"; - string accountName = "consumerAccount"; + string accountName = "Account1"; string shareSubscriptionName = "ShareSubscription1"; ResourceIdentifier shareSubscriptionResourceId = ShareSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareSubscriptionName); ShareSubscriptionResource shareSubscription = client.GetShareSubscriptionResource(shareSubscriptionResourceId); @@ -301,24 +313,18 @@ public async Task CreateOrUpdate_DataSetMappingsSynapseWorkspaceSqlPoolTableCrea ShareDataSetMappingCollection collection = shareSubscription.GetShareDataSetMappings(); // invoke the operation - string dataSetMappingName = "datasetMappingName1"; - ShareDataSetMappingData data = new SynapseWorkspaceSqlPoolTableDataSetMapping(Guid.Parse("3dc64e49-1fc3-4186-b3dc-d388c4d3076a"), new ResourceIdentifier("/subscriptions/0f3dcfc3-18f8-4099-b381-8353e19d43a7/resourceGroups/SampleResourceGroup/providers/Microsoft.Synapse/workspaces/ExampleWorkspace/sqlPools/ExampleSqlPool/schemas/dbo/tables/table1")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataSetMappingName, data); - ShareDataSetMappingResource result = lro.Value; + string dataSetMappingName = "DatasetMapping1"; + bool result = await collection.ExistsAsync(dataSetMappingName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ShareDataSetMappingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DataSetMappingsListByShareSubscription() + public async Task GetIfExists_DataSetMappingsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_ListByShareSubscription.json - // this example is just showing the usage of "DataSetMappings_ListByShareSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_Get.json + // this example is just showing the usage of "DataSetMappings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -337,17 +343,23 @@ public async Task GetAll_DataSetMappingsListByShareSubscription() // get the collection of this ShareDataSetMappingResource ShareDataSetMappingCollection collection = shareSubscription.GetShareDataSetMappings(); - // invoke the operation and iterate over the result - await foreach (ShareDataSetMappingResource item in collection.GetAllAsync()) + // invoke the operation + string dataSetMappingName = "DatasetMapping1"; + NullableResponse response = await collection.GetIfExistsAsync(dataSetMappingName); + ShareDataSetMappingResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ShareDataSetMappingData resourceData = item.Data; + ShareDataSetMappingData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetMappingResource.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetMappingResource.cs index 83fe916d29c54..32a9cf34063e5 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetMappingResource.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetMappingResource.cs @@ -48,6 +48,34 @@ public async Task Get_DataSetMappingsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DataSetMappingsDelete() + { + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_Delete.json + // this example is just showing the usage of "DataSetMappings_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ShareDataSetMappingResource created on azure + // for more information of creating ShareDataSetMappingResource, please refer to the document of ShareDataSetMappingResource + string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; + string resourceGroupName = "SampleResourceGroup"; + string accountName = "Account1"; + string shareSubscriptionName = "ShareSubscription1"; + string dataSetMappingName = "DatasetMapping1"; + ResourceIdentifier shareDataSetMappingResourceId = ShareDataSetMappingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareSubscriptionName, dataSetMappingName); + ShareDataSetMappingResource shareDataSetMapping = client.GetShareDataSetMappingResource(shareDataSetMappingResourceId); + + // invoke the operation + await shareDataSetMapping.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_DataSetMappingsCreate() @@ -71,7 +99,13 @@ public async Task Update_DataSetMappingsCreate() ShareDataSetMappingResource shareDataSetMapping = client.GetShareDataSetMappingResource(shareDataSetMappingResourceId); // invoke the operation - ShareDataSetMappingData data = new BlobDataSetMapping("C1", Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), "file21", "SampleResourceGroup", "storage2", "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"); + ShareDataSetMappingData data = new BlobDataSetMapping( + "C1", + Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), + "file21", + "SampleResourceGroup", + "storage2", + "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"); ArmOperation lro = await shareDataSetMapping.UpdateAsync(WaitUntil.Completed, data); ShareDataSetMappingResource result = lro.Value; @@ -139,7 +173,13 @@ public async Task Update_DataSetMappingsSqlDWDataSetToAdlsGen2FileCreate() ShareDataSetMappingResource shareDataSetMapping = client.GetShareDataSetMappingResource(shareDataSetMappingResourceId); // invoke the operation - ShareDataSetMappingData data = new AdlsGen2FileDataSetMapping(Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), "file21", "fileSystem", "SampleResourceGroup", "storage2", "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a") + ShareDataSetMappingData data = new AdlsGen2FileDataSetMapping( + Guid.Parse("a08f184b-0567-4b11-ba22-a1199336d226"), + "file21", + "fileSystem", + "SampleResourceGroup", + "storage2", + "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a") { OutputType = DataShareOutputType.Csv, }; @@ -220,33 +260,5 @@ public async Task Update_DataSetMappingsSynapseWorkspaceSqlPoolTableCreate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DataSetMappingsDelete() - { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSetMappings_Delete.json - // this example is just showing the usage of "DataSetMappings_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ShareDataSetMappingResource created on azure - // for more information of creating ShareDataSetMappingResource, please refer to the document of ShareDataSetMappingResource - string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; - string resourceGroupName = "SampleResourceGroup"; - string accountName = "Account1"; - string shareSubscriptionName = "ShareSubscription1"; - string dataSetMappingName = "DatasetMapping1"; - ResourceIdentifier shareDataSetMappingResourceId = ShareDataSetMappingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareSubscriptionName, dataSetMappingName); - ShareDataSetMappingResource shareDataSetMapping = client.GetShareDataSetMappingResource(shareDataSetMappingResourceId); - - // invoke the operation - await shareDataSetMapping.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetResource.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetResource.cs index a3528a440ecaf..d8e8a16256c5c 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetResource.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareDataSetResource.cs @@ -48,6 +48,34 @@ public async Task Get_DataSetsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DataSetsDelete() + { + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_Delete.json + // this example is just showing the usage of "DataSets_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ShareDataSetResource created on azure + // for more information of creating ShareDataSetResource, please refer to the document of ShareDataSetResource + string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; + string resourceGroupName = "SampleResourceGroup"; + string accountName = "Account1"; + string shareName = "Share1"; + string dataSetName = "Dataset1"; + ResourceIdentifier shareDataSetResourceId = ShareDataSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName, dataSetName); + ShareDataSetResource shareDataSet = client.GetShareDataSetResource(shareDataSetResourceId); + + // invoke the operation + await shareDataSet.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_DataSetsCreate() @@ -173,32 +201,14 @@ public async Task Update_DataSetsKustoTableCreate() ShareDataSetResource shareDataSet = client.GetShareDataSetResource(shareDataSetResourceId); // invoke the operation - ShareDataSetData data = new KustoTableDataSet(new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Kusto/clusters/Cluster1/databases/Database1"), new TableLevelSharingProperties() + ShareDataSetData data = new KustoTableDataSet(new ResourceIdentifier("/subscriptions/433a8dfd-e5d5-4e77-ad86-90acdc75eb1a/resourceGroups/SampleResourceGroup/providers/Microsoft.Kusto/clusters/Cluster1/databases/Database1"), new TableLevelSharingProperties { - ExternalTablesToExclude = -{ -"test11","test12" -}, - ExternalTablesToInclude = -{ -"test9","test10" -}, - MaterializedViewsToExclude = -{ -"test7","test8" -}, - MaterializedViewsToInclude = -{ -"test5","test6" -}, - TablesToExclude = -{ -"test3","test4" -}, - TablesToInclude = -{ -"test1","test2" -}, + ExternalTablesToExclude = { "test11", "test12" }, + ExternalTablesToInclude = { "test9", "test10" }, + MaterializedViewsToExclude = { "test7", "test8" }, + MaterializedViewsToInclude = { "test5", "test6" }, + TablesToExclude = { "test3", "test4" }, + TablesToInclude = { "test1", "test2" }, }); ArmOperation lro = await shareDataSet.UpdateAsync(WaitUntil.Completed, data); ShareDataSetResource result = lro.Value; @@ -233,7 +243,7 @@ public async Task Update_DataSetsSqlDBTableCreate() ShareDataSetResource shareDataSet = client.GetShareDataSetResource(shareDataSetResourceId); // invoke the operation - ShareDataSetData data = new SqlDBTableDataSet() + ShareDataSetData data = new SqlDBTableDataSet { DatabaseName = "SqlDB1", SchemaName = "dbo", @@ -273,7 +283,7 @@ public async Task Update_DataSetsSqlDWTableCreate() ShareDataSetResource shareDataSet = client.GetShareDataSetResource(shareDataSetResourceId); // invoke the operation - ShareDataSetData data = new SqlDWTableDataSet() + ShareDataSetData data = new SqlDWTableDataSet { DataWarehouseName = "DataWarehouse1", SchemaName = "dbo", @@ -323,33 +333,5 @@ public async Task Update_DataSetsSynapseWorkspaceSqlPoolTableCreate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DataSetsDelete() - { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/DataSets_Delete.json - // this example is just showing the usage of "DataSets_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ShareDataSetResource created on azure - // for more information of creating ShareDataSetResource, please refer to the document of ShareDataSetResource - string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; - string resourceGroupName = "SampleResourceGroup"; - string accountName = "Account1"; - string shareName = "Share1"; - string dataSetName = "Dataset1"; - ResourceIdentifier shareDataSetResourceId = ShareDataSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareName, dataSetName); - ShareDataSetResource shareDataSet = client.GetShareDataSetResource(shareDataSetResourceId); - - // invoke the operation - await shareDataSet.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareSubscriptionCollection.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareSubscriptionCollection.cs index bf5e447898dc8..c4454d3ccfe84 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareSubscriptionCollection.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareSubscriptionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ShareSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ShareSubscriptionsGet() + public async Task CreateOrUpdate_ShareSubscriptionsCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Get.json - // this example is just showing the usage of "ShareSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Create.json + // this example is just showing the usage of "ShareSubscriptions_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_ShareSubscriptionsGet() // invoke the operation string shareSubscriptionName = "ShareSubscription1"; - ShareSubscriptionResource result = await collection.GetAsync(shareSubscriptionName); + ShareSubscriptionData data = new ShareSubscriptionData(Guid.Parse("12345678-1234-1234-12345678abd"), new AzureLocation("eastus2")) + { + ExpireOn = DateTimeOffset.Parse("2020-08-26T22:33:24.5785265Z"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, shareSubscriptionName, data); + ShareSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_ShareSubscriptionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ShareSubscriptionsGet() + public async Task Get_ShareSubscriptionsGet() { // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Get.json // this example is just showing the usage of "ShareSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +79,21 @@ public async Task Exists_ShareSubscriptionsGet() // invoke the operation string shareSubscriptionName = "ShareSubscription1"; - bool result = await collection.ExistsAsync(shareSubscriptionName); + ShareSubscriptionResource result = await collection.GetAsync(shareSubscriptionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ShareSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ShareSubscriptionsGet() + public async Task GetAll_ShareSubscriptionsListByAccount() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Get.json - // this example is just showing the usage of "ShareSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_ListByAccount.json + // this example is just showing the usage of "ShareSubscriptions_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +111,25 @@ public async Task GetIfExists_ShareSubscriptionsGet() // get the collection of this ShareSubscriptionResource ShareSubscriptionCollection collection = dataShareAccount.GetShareSubscriptions(); - // invoke the operation - string shareSubscriptionName = "ShareSubscription1"; - NullableResponse response = await collection.GetIfExistsAsync(shareSubscriptionName); - ShareSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ShareSubscriptionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ShareSubscriptionData resourceData = result.Data; + ShareSubscriptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ShareSubscriptionsCreate() + public async Task Exists_ShareSubscriptionsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Create.json - // this example is just showing the usage of "ShareSubscriptions_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Get.json + // this example is just showing the usage of "ShareSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,26 +149,17 @@ public async Task CreateOrUpdate_ShareSubscriptionsCreate() // invoke the operation string shareSubscriptionName = "ShareSubscription1"; - ShareSubscriptionData data = new ShareSubscriptionData(Guid.Parse("12345678-1234-1234-12345678abd"), new AzureLocation("eastus2")) - { - ExpireOn = DateTimeOffset.Parse("2020-08-26T22:33:24.5785265Z"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, shareSubscriptionName, data); - ShareSubscriptionResource result = lro.Value; + bool result = await collection.ExistsAsync(shareSubscriptionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ShareSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ShareSubscriptionsListByAccount() + public async Task GetIfExists_ShareSubscriptionsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_ListByAccount.json - // this example is just showing the usage of "ShareSubscriptions_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Get.json + // this example is just showing the usage of "ShareSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_ShareSubscriptionsListByAccount() // get the collection of this ShareSubscriptionResource ShareSubscriptionCollection collection = dataShareAccount.GetShareSubscriptions(); - // invoke the operation and iterate over the result - await foreach (ShareSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string shareSubscriptionName = "ShareSubscription1"; + NullableResponse response = await collection.GetIfExistsAsync(shareSubscriptionName); + ShareSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ShareSubscriptionData resourceData = item.Data; + ShareSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareSubscriptionResource.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareSubscriptionResource.cs index 469da1cf68bb5..9939480de9593 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareSubscriptionResource.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_ShareSubscriptionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ShareSubscriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CancelSynchronization_ShareSubscriptionsCancelSynchronization() + public async Task Get_ShareSubscriptionsGet() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_CancelSynchronization.json - // this example is just showing the usage of "ShareSubscriptions_CancelSynchronization" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Get.json + // this example is just showing the usage of "ShareSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,19 +38,21 @@ public async Task CancelSynchronization_ShareSubscriptionsCancelSynchronization( ShareSubscriptionResource shareSubscription = client.GetShareSubscriptionResource(shareSubscriptionResourceId); // invoke the operation - ShareSubscriptionSynchronization shareSubscriptionSynchronization = new ShareSubscriptionSynchronization(Guid.Parse("7d0536a6-3fa5-43de-b152-3d07c4f6b2bb")); - ArmOperation lro = await shareSubscription.CancelSynchronizationAsync(WaitUntil.Completed, shareSubscriptionSynchronization); - ShareSubscriptionSynchronization result = lro.Value; + ShareSubscriptionResource result = await shareSubscription.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ShareSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSourceShareSynchronizationSettings_ShareSubscriptionsListSourceShareSynchronizationSettings() + public async Task Delete_ShareSubscriptionsDelete() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_ListSourceShareSynchronizationSettings.json - // this example is just showing the usage of "ShareSubscriptions_ListSourceShareSynchronizationSettings" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Delete.json + // this example is just showing the usage of "ShareSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,28 +61,26 @@ public async Task GetSourceShareSynchronizationSettings_ShareSubscriptionsListSo // this example assumes you already have this ShareSubscriptionResource created on azure // for more information of creating ShareSubscriptionResource, please refer to the document of ShareSubscriptionResource - string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; + string subscriptionId = "12345678-1234-1234-12345678abc"; string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; - string shareSubscriptionName = "ShareSub1"; + string shareSubscriptionName = "ShareSubscription1"; ResourceIdentifier shareSubscriptionResourceId = ShareSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareSubscriptionName); ShareSubscriptionResource shareSubscription = client.GetShareSubscriptionResource(shareSubscriptionResourceId); - // invoke the operation and iterate over the result - await foreach (SourceShareSynchronizationSetting item in shareSubscription.GetSourceShareSynchronizationSettingsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + ArmOperation lro = await shareSubscription.DeleteAsync(WaitUntil.Completed); + DataShareOperationResult result = lro.Value; - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSynchronizationDetails_ShareSubscriptionsListSynchronizationDetails() + public async Task Update_ShareSubscriptionsCreate() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_ListSynchronizationDetails.json - // this example is just showing the usage of "ShareSubscriptions_ListSynchronizationDetails" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Create.json + // this example is just showing the usage of "ShareSubscriptions_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -89,29 +89,34 @@ public async Task GetSynchronizationDetails_ShareSubscriptionsListSynchronizatio // this example assumes you already have this ShareSubscriptionResource created on azure // for more information of creating ShareSubscriptionResource, please refer to the document of ShareSubscriptionResource - string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; + string subscriptionId = "12345678-1234-1234-12345678abc"; string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; - string shareSubscriptionName = "ShareSub1"; + string shareSubscriptionName = "ShareSubscription1"; ResourceIdentifier shareSubscriptionResourceId = ShareSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareSubscriptionName); ShareSubscriptionResource shareSubscription = client.GetShareSubscriptionResource(shareSubscriptionResourceId); - // invoke the operation and iterate over the result - ShareSubscriptionSynchronization shareSubscriptionSynchronization = new ShareSubscriptionSynchronization(Guid.Parse("7d0536a6-3fa5-43de-b152-3d07c4f6b2bb")); - await foreach (SynchronizationDetails item in shareSubscription.GetSynchronizationDetailsAsync(shareSubscriptionSynchronization)) + // invoke the operation + ShareSubscriptionData data = new ShareSubscriptionData(Guid.Parse("12345678-1234-1234-12345678abd"), new AzureLocation("eastus2")) { - Console.WriteLine($"Succeeded: {item}"); - } + ExpireOn = DateTimeOffset.Parse("2020-08-26T22:33:24.5785265Z"), + }; + ArmOperation lro = await shareSubscription.UpdateAsync(WaitUntil.Completed, data); + ShareSubscriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ShareSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSynchronizations_ShareSubscriptionsListSynchronizations() + public async Task CancelSynchronization_ShareSubscriptionsCancelSynchronization() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_ListSynchronizations.json - // this example is just showing the usage of "ShareSubscriptions_ListSynchronizations" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_CancelSynchronization.json + // this example is just showing the usage of "ShareSubscriptions_CancelSynchronization" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,28 +125,27 @@ public async Task GetSynchronizations_ShareSubscriptionsListSynchronizations() // this example assumes you already have this ShareSubscriptionResource created on azure // for more information of creating ShareSubscriptionResource, please refer to the document of ShareSubscriptionResource - string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; + string subscriptionId = "12345678-1234-1234-12345678abc"; string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; - string shareSubscriptionName = "ShareSub1"; + string shareSubscriptionName = "ShareSubscription1"; ResourceIdentifier shareSubscriptionResourceId = ShareSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareSubscriptionName); ShareSubscriptionResource shareSubscription = client.GetShareSubscriptionResource(shareSubscriptionResourceId); - // invoke the operation and iterate over the result - await foreach (ShareSubscriptionSynchronization item in shareSubscription.GetSynchronizationsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + ShareSubscriptionSynchronization shareSubscriptionSynchronization = new ShareSubscriptionSynchronization(Guid.Parse("7d0536a6-3fa5-43de-b152-3d07c4f6b2bb")); + ArmOperation lro = await shareSubscription.CancelSynchronizationAsync(WaitUntil.Completed, shareSubscriptionSynchronization); + ShareSubscriptionSynchronization result = lro.Value; - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Synchronize_ShareSubscriptionsSynchronize() + public async Task GetSourceShareSynchronizationSettings_ShareSubscriptionsListSourceShareSynchronizationSettings() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Synchronize.json - // this example is just showing the usage of "ShareSubscriptions_Synchronize" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_ListSourceShareSynchronizationSettings.json + // this example is just showing the usage of "ShareSubscriptions_ListSourceShareSynchronizationSettings" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,30 +154,28 @@ public async Task Synchronize_ShareSubscriptionsSynchronize() // this example assumes you already have this ShareSubscriptionResource created on azure // for more information of creating ShareSubscriptionResource, please refer to the document of ShareSubscriptionResource - string subscriptionId = "12345678-1234-1234-12345678abc"; + string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; - string shareSubscriptionName = "ShareSubscription1"; + string shareSubscriptionName = "ShareSub1"; ResourceIdentifier shareSubscriptionResourceId = ShareSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareSubscriptionName); ShareSubscriptionResource shareSubscription = client.GetShareSubscriptionResource(shareSubscriptionResourceId); - // invoke the operation - DataShareSynchronizeContent content = new DataShareSynchronizeContent() + // invoke the operation and iterate over the result + await foreach (SourceShareSynchronizationSetting item in shareSubscription.GetSourceShareSynchronizationSettingsAsync()) { - SynchronizationMode = SynchronizationMode.Incremental, - }; - ArmOperation lro = await shareSubscription.SynchronizeAsync(WaitUntil.Completed, content); - ShareSubscriptionSynchronization result = lro.Value; + Console.WriteLine($"Succeeded: {item}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ShareSubscriptionsGet() + public async Task GetSynchronizationDetails_ShareSubscriptionsListSynchronizationDetails() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Get.json - // this example is just showing the usage of "ShareSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_ListSynchronizationDetails.json + // this example is just showing the usage of "ShareSubscriptions_ListSynchronizationDetails" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,29 +184,29 @@ public async Task Get_ShareSubscriptionsGet() // this example assumes you already have this ShareSubscriptionResource created on azure // for more information of creating ShareSubscriptionResource, please refer to the document of ShareSubscriptionResource - string subscriptionId = "12345678-1234-1234-12345678abc"; + string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; - string shareSubscriptionName = "ShareSubscription1"; + string shareSubscriptionName = "ShareSub1"; ResourceIdentifier shareSubscriptionResourceId = ShareSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareSubscriptionName); ShareSubscriptionResource shareSubscription = client.GetShareSubscriptionResource(shareSubscriptionResourceId); - // invoke the operation - ShareSubscriptionResource result = await shareSubscription.GetAsync(); + // invoke the operation and iterate over the result + ShareSubscriptionSynchronization shareSubscriptionSynchronization = new ShareSubscriptionSynchronization(Guid.Parse("7d0536a6-3fa5-43de-b152-3d07c4f6b2bb")); + await foreach (SynchronizationDetails item in shareSubscription.GetSynchronizationDetailsAsync(shareSubscriptionSynchronization)) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ShareSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ShareSubscriptionsCreate() + public async Task GetSynchronizations_ShareSubscriptionsListSynchronizations() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Create.json - // this example is just showing the usage of "ShareSubscriptions_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_ListSynchronizations.json + // this example is just showing the usage of "ShareSubscriptions_ListSynchronizations" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,34 +215,28 @@ public async Task Update_ShareSubscriptionsCreate() // this example assumes you already have this ShareSubscriptionResource created on azure // for more information of creating ShareSubscriptionResource, please refer to the document of ShareSubscriptionResource - string subscriptionId = "12345678-1234-1234-12345678abc"; + string subscriptionId = "433a8dfd-e5d5-4e77-ad86-90acdc75eb1a"; string resourceGroupName = "SampleResourceGroup"; string accountName = "Account1"; - string shareSubscriptionName = "ShareSubscription1"; + string shareSubscriptionName = "ShareSub1"; ResourceIdentifier shareSubscriptionResourceId = ShareSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, shareSubscriptionName); ShareSubscriptionResource shareSubscription = client.GetShareSubscriptionResource(shareSubscriptionResourceId); - // invoke the operation - ShareSubscriptionData data = new ShareSubscriptionData(Guid.Parse("12345678-1234-1234-12345678abd"), new AzureLocation("eastus2")) + // invoke the operation and iterate over the result + await foreach (ShareSubscriptionSynchronization item in shareSubscription.GetSynchronizationsAsync()) { - ExpireOn = DateTimeOffset.Parse("2020-08-26T22:33:24.5785265Z"), - }; - ArmOperation lro = await shareSubscription.UpdateAsync(WaitUntil.Completed, data); - ShareSubscriptionResource result = lro.Value; + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ShareSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ShareSubscriptionsDelete() + public async Task Synchronize_ShareSubscriptionsSynchronize() { - // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Delete.json - // this example is just showing the usage of "ShareSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ShareSubscriptions_Synchronize.json + // this example is just showing the usage of "ShareSubscriptions_Synchronize" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -257,8 +253,12 @@ public async Task Delete_ShareSubscriptionsDelete() ShareSubscriptionResource shareSubscription = client.GetShareSubscriptionResource(shareSubscriptionResourceId); // invoke the operation - ArmOperation lro = await shareSubscription.DeleteAsync(WaitUntil.Completed); - DataShareOperationResult result = lro.Value; + DataShareSynchronizeContent content = new DataShareSynchronizeContent + { + SynchronizationMode = SynchronizationMode.Incremental, + }; + ArmOperation lro = await shareSubscription.SynchronizeAsync(WaitUntil.Completed, content); + ShareSubscriptionSynchronization result = lro.Value; Console.WriteLine($"Succeeded: {result}"); } diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..5ccc2213c027e --- /dev/null +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.DataShare.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataShareAccounts_AccountsListBySubscription() + { + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/Accounts_ListBySubscription.json + // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataShareAccountResource item in subscriptionResource.GetDataShareAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index 0669f5e9eeb40..b7651b757adb1 100644 --- a/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/datashare/Azure.ResourceManager.DataShare/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,12 +10,39 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DataShare.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DataShare.Samples { public partial class Sample_TenantResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task RejectConsumerInvitation_ConsumerInvitationsRejectInvitation() + { + // Generated from example definition: specification/datashare/resource-manager/Microsoft.DataShare/stable/2021-08-01/examples/ConsumerInvitations_RejectInvitation.json + // this example is just showing the usage of "ConsumerInvitations_RejectInvitation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation + AzureLocation location = new AzureLocation("East US 2"); + DataShareConsumerInvitationData data = new DataShareConsumerInvitationData(Guid.Parse("dfbbc788-19eb-4607-a5a1-c74181bfff03")); + DataShareConsumerInvitationResource result = await tenantResource.RejectConsumerInvitationAsync(location, data); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataShareConsumerInvitationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task ActivateEmail_EmailRegistrationsActivateEmail() @@ -28,13 +55,11 @@ public async Task ActivateEmail_EmailRegistrationsActivateEmail() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation AzureLocation location = new AzureLocation("East US 2"); - DataShareEmailRegistration emailRegistration = new DataShareEmailRegistration() + DataShareEmailRegistration emailRegistration = new DataShareEmailRegistration { ActivationCode = "djsfhakj2lekowd3wepfklpwe9lpflcd", }; @@ -55,9 +80,7 @@ public async Task RegisterEmail_EmailRegistrationsRegisterEmail() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation AzureLocation location = new AzureLocation("East US 2"); diff --git a/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmLabelCollection.cs b/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmLabelCollection.cs index 6e0ad1a95ddd1..24a9302a67404 100644 --- a/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmLabelCollection.cs +++ b/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmLabelCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_EasmLabelCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_Labels() + public async Task CreateOrUpdate_Labels() { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_ListByWorkspace.json - // this example is just showing the usage of "Labels_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_CreateAndUpdate.json + // this example is just showing the usage of "Labels_CreateAndUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_Labels() // get the collection of this EasmLabelResource EasmLabelCollection collection = easmWorkspace.GetEasmLabels(); - // invoke the operation and iterate over the result - await foreach (EasmLabelResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EasmLabelData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string labelName = "ThisisaLabel"; + EasmLabelData data = new EasmLabelData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, labelName, data); + EasmLabelResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EasmLabelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_Labels() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_Labels() + public async Task GetAll_Labels() { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_GetByWorkspace.json - // this example is just showing the usage of "Labels_GetByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_ListByWorkspace.json + // this example is just showing the usage of "Labels_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_Labels() // get the collection of this EasmLabelResource EasmLabelCollection collection = easmWorkspace.GetEasmLabels(); - // invoke the operation - string labelName = "ThisisaLabel"; - bool result = await collection.ExistsAsync(labelName); + // invoke the operation and iterate over the result + await foreach (EasmLabelResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EasmLabelData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_Labels() + public async Task Exists_Labels() { // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_GetByWorkspace.json // this example is just showing the usage of "Labels_GetByWorkspace" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_Labels() // invoke the operation string labelName = "ThisisaLabel"; - NullableResponse response = await collection.GetIfExistsAsync(labelName); - EasmLabelResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(labelName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EasmLabelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_Labels() + public async Task GetIfExists_Labels() { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_CreateAndUpdate.json - // this example is just showing the usage of "Labels_CreateAndUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_GetByWorkspace.json + // this example is just showing the usage of "Labels_GetByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_Labels() // invoke the operation string labelName = "ThisisaLabel"; - EasmLabelData data = new EasmLabelData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, labelName, data); - EasmLabelResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(labelName); + EasmLabelResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EasmLabelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EasmLabelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmLabelResource.cs b/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmLabelResource.cs index 60ce801f5fd89..dc9dd8a06a877 100644 --- a/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmLabelResource.cs +++ b/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmLabelResource.cs @@ -49,10 +49,10 @@ public async Task Get_Labels() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_Labels() + public async Task Delete_Labels() { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_Update.json - // this example is just showing the usage of "Labels_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_Delete.json + // this example is just showing the usage of "Labels_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,22 +69,17 @@ public async Task Update_Labels() EasmLabelResource easmLabel = client.GetEasmLabelResource(easmLabelResourceId); // invoke the operation - EasmLabelPatch patch = new EasmLabelPatch(); - EasmLabelResource result = await easmLabel.UpdateAsync(patch); + await easmLabel.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EasmLabelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_Labels() + public async Task Update_Labels() { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_Delete.json - // this example is just showing the usage of "Labels_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Labels_Update.json + // this example is just showing the usage of "Labels_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +96,14 @@ public async Task Delete_Labels() EasmLabelResource easmLabel = client.GetEasmLabelResource(easmLabelResourceId); // invoke the operation - await easmLabel.DeleteAsync(WaitUntil.Completed); + EasmLabelPatch patch = new EasmLabelPatch(); + EasmLabelResource result = await easmLabel.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EasmLabelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmWorkspaceCollection.cs b/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmWorkspaceCollection.cs index 4985740dc8404..fbf02663bb7c6 100644 --- a/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmWorkspaceCollection.cs +++ b/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmWorkspaceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_EasmWorkspaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_Workspaces() + public async Task CreateOrUpdate_Workspaces() { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_ListByResourceGroup.json - // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_CreateAndUpdate.json + // this example is just showing the usage of "Workspaces_CreateAndUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_Workspaces() // get the collection of this EasmWorkspaceResource EasmWorkspaceCollection collection = resourceGroupResource.GetEasmWorkspaces(); - // invoke the operation and iterate over the result - await foreach (EasmWorkspaceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EasmWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string workspaceName = "ThisisaWorkspace"; + EasmWorkspaceData data = new EasmWorkspaceData(new AzureLocation("West US")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); + EasmWorkspaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EasmWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +86,10 @@ public async Task Get_Workspaces() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_Workspaces() + public async Task GetAll_Workspaces() { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_Get.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_ListByResourceGroup.json + // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +106,22 @@ public async Task Exists_Workspaces() // get the collection of this EasmWorkspaceResource EasmWorkspaceCollection collection = resourceGroupResource.GetEasmWorkspaces(); - // invoke the operation - string workspaceName = "ThisisaWorkspace"; - bool result = await collection.ExistsAsync(workspaceName); + // invoke the operation and iterate over the result + await foreach (EasmWorkspaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EasmWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_Workspaces() + public async Task Exists_Workspaces() { // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_Get.json // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +143,17 @@ public async Task GetIfExists_Workspaces() // invoke the operation string workspaceName = "ThisisaWorkspace"; - NullableResponse response = await collection.GetIfExistsAsync(workspaceName); - EasmWorkspaceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(workspaceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EasmWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_Workspaces() + public async Task GetIfExists_Workspaces() { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_CreateAndUpdate.json - // this example is just showing the usage of "Workspaces_CreateAndUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_Get.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,15 +172,21 @@ public async Task CreateOrUpdate_Workspaces() // invoke the operation string workspaceName = "ThisisaWorkspace"; - EasmWorkspaceData data = new EasmWorkspaceData(new AzureLocation("West US")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); - EasmWorkspaceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(workspaceName); + EasmWorkspaceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EasmWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EasmWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmWorkspaceResource.cs b/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmWorkspaceResource.cs index a4a82d6de7534..bcd7db95d17c1 100644 --- a/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmWorkspaceResource.cs +++ b/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_EasmWorkspaceResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DefenderEasm.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DefenderEasm.Samples { public partial class Sample_EasmWorkspaceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEasmWorkspaces_Workspaces() - { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_ListBySubscription.json - // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (EasmWorkspaceResource item in subscriptionResource.GetEasmWorkspacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EasmWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_Workspaces() @@ -80,10 +48,10 @@ public async Task Get_Workspaces() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_Workspaces() + public async Task Delete_Workspaces() { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_Update.json - // this example is just showing the usage of "Workspaces_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_Delete.json + // this example is just showing the usage of "Workspaces_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,22 +67,17 @@ public async Task Update_Workspaces() EasmWorkspaceResource easmWorkspace = client.GetEasmWorkspaceResource(easmWorkspaceResourceId); // invoke the operation - EasmWorkspacePatch patch = new EasmWorkspacePatch(); - EasmWorkspaceResource result = await easmWorkspace.UpdateAsync(patch); + await easmWorkspace.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - EasmWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_Workspaces() + public async Task Update_Workspaces() { - // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_Delete.json - // this example is just showing the usage of "Workspaces_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_Update.json + // this example is just showing the usage of "Workspaces_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,9 +93,14 @@ public async Task Delete_Workspaces() EasmWorkspaceResource easmWorkspace = client.GetEasmWorkspaceResource(easmWorkspaceResourceId); // invoke the operation - await easmWorkspace.DeleteAsync(WaitUntil.Completed); + EasmWorkspacePatch patch = new EasmWorkspacePatch(); + EasmWorkspaceResource result = await easmWorkspace.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EasmWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..b61d643f52e7c --- /dev/null +++ b/sdk/defendereasm/Azure.ResourceManager.DefenderEasm/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.DefenderEasm.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEasmWorkspaces_Workspaces() + { + // Generated from example definition: specification/riskiq/resource-manager/Microsoft.Easm/preview/2023-04-01-preview/examples/Workspaces_ListBySubscription.json + // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (EasmWorkspaceResource item in subscriptionResource.GetEasmWorkspacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + EasmWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_AppAttachPackageCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_AppAttachPackageCollection.cs index 879b8e7963cd7..b977dc337511f 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_AppAttachPackageCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_AppAttachPackageCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AppAttachPackageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AppAttachPackageGet() + public async Task CreateOrUpdate_AppAttachPackageCreate() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_Get.json - // this example is just showing the usage of "AppAttachPackage_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_Create.json + // this example is just showing the usage of "AppAttachPackage_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,47 @@ public async Task Get_AppAttachPackageGet() AppAttachPackageCollection collection = resourceGroupResource.GetAppAttachPackages(); // invoke the operation - string appAttachPackageName = "packagefullname"; - AppAttachPackageResource result = await collection.GetAsync(appAttachPackageName); + string appAttachPackageName = "msixpackagefullname"; + AppAttachPackageData data = new AppAttachPackageData(new AzureLocation("southcentralus"), new AppAttachPackageProperties + { + Image = new AppAttachPackageInfoProperties + { + PackageAlias = "msixpackagealias", + ImagePath = "imagepath", + PackageName = "MsixPackageName", + PackageFamilyName = "MsixPackage_FamilyName", + PackageFullName = "MsixPackage_FullName", + DisplayName = "displayname", + PackageRelativePath = "packagerelativepath", + IsRegularRegistration = false, + IsActive = false, + PackageDependencies = {new MsixPackageDependencies +{ +DependencyName = "MsixPackage_Dependency_Name", +Publisher = "MsixPackage_Dependency_Publisher", +MinVersion = "packageDep_version", +}}, + Version = "packageversion", + LastUpdatedOn = DateTimeOffset.Parse("2008-09-22T14:01:54.9571247Z"), + PackageApplications = {new MsixPackageApplications +{ +AppId = "AppId", +Description = "PackageApplicationDescription", +AppUserModelId = "AppUserModelId", +FriendlyName = "FriendlyName", +IconImageName = "Iconimagename", +RawIcon = BinaryData.FromObjectAsJson("VGhpcyBpcyBhIHN0cmluZyB0byBoYXNo"), +RawPng = BinaryData.FromObjectAsJson("VGhpcyBpcyBhIHN0cmluZyB0byBoYXNo"), +}}, + CertificateName = "certName", + CertificateExpireOn = DateTimeOffset.Parse("2023-01-02T17:18:19.1234567Z"), + }, + HostPoolReferences = { }, + KeyVaultUri = new Uri(""), + FailHealthCheckOnStagingFailure = FailHealthCheckOnStagingFailure.NeedsAssistance, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, appAttachPackageName, data); + AppAttachPackageResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +91,7 @@ public async Task Get_AppAttachPackageGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AppAttachPackageGet() + public async Task Get_AppAttachPackageGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_Get.json // this example is just showing the usage of "AppAttachPackage_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +113,21 @@ public async Task Exists_AppAttachPackageGet() // invoke the operation string appAttachPackageName = "packagefullname"; - bool result = await collection.ExistsAsync(appAttachPackageName); + AppAttachPackageResource result = await collection.GetAsync(appAttachPackageName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppAttachPackageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AppAttachPackageGet() + public async Task GetAll_AppAttachPackageListByResourceGroup() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_Get.json - // this example is just showing the usage of "AppAttachPackage_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_ListByResourceGroup.json + // this example is just showing the usage of "AppAttachPackage_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +144,26 @@ public async Task GetIfExists_AppAttachPackageGet() // get the collection of this AppAttachPackageResource AppAttachPackageCollection collection = resourceGroupResource.GetAppAttachPackages(); - // invoke the operation - string appAttachPackageName = "packagefullname"; - NullableResponse response = await collection.GetIfExistsAsync(appAttachPackageName); - AppAttachPackageResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string filter = "HostPoolName eq 'hostpool1'"; + await foreach (AppAttachPackageResource item in collection.GetAllAsync(filter: filter)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppAttachPackageData resourceData = result.Data; + AppAttachPackageData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AppAttachPackageCreate() + public async Task Exists_AppAttachPackageGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_Create.json - // this example is just showing the usage of "AppAttachPackage_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_Get.json + // this example is just showing the usage of "AppAttachPackage_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,69 +181,18 @@ public async Task CreateOrUpdate_AppAttachPackageCreate() AppAttachPackageCollection collection = resourceGroupResource.GetAppAttachPackages(); // invoke the operation - string appAttachPackageName = "msixpackagefullname"; - AppAttachPackageData data = new AppAttachPackageData(new AzureLocation("southcentralus"), new AppAttachPackageProperties() - { - Image = new AppAttachPackageInfoProperties() - { - PackageAlias = "msixpackagealias", - ImagePath = "imagepath", - PackageName = "MsixPackageName", - PackageFamilyName = "MsixPackage_FamilyName", - PackageFullName = "MsixPackage_FullName", - DisplayName = "displayname", - PackageRelativePath = "packagerelativepath", - IsRegularRegistration = false, - IsActive = false, - PackageDependencies = -{ -new MsixPackageDependencies() -{ -DependencyName = "MsixPackage_Dependency_Name", -Publisher = "MsixPackage_Dependency_Publisher", -MinVersion = "packageDep_version", -} -}, - Version = "packageversion", - LastUpdatedOn = DateTimeOffset.Parse("2008-09-22T14:01:54.9571247Z"), - PackageApplications = -{ -new MsixPackageApplications() -{ -AppId = "AppId", -Description = "PackageApplicationDescription", -AppUserModelId = "AppUserModelId", -FriendlyName = "FriendlyName", -IconImageName = "Iconimagename", -RawIcon = BinaryData.FromString("\"VGhpcyBpcyBhIHN0cmluZyB0byBoYXNo\""), -RawPng = BinaryData.FromString("\"VGhpcyBpcyBhIHN0cmluZyB0byBoYXNo\""), -} -}, - CertificateName = "certName", - CertificateExpireOn = DateTimeOffset.Parse("2023-01-02T17:18:19.1234567Z"), - }, - HostPoolReferences = -{ -}, - KeyVaultUri = new Uri(""), - FailHealthCheckOnStagingFailure = FailHealthCheckOnStagingFailure.NeedsAssistance, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, appAttachPackageName, data); - AppAttachPackageResource result = lro.Value; + string appAttachPackageName = "packagefullname"; + bool result = await collection.ExistsAsync(appAttachPackageName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppAttachPackageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AppAttachPackageListByResourceGroup() + public async Task GetIfExists_AppAttachPackageGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_ListByResourceGroup.json - // this example is just showing the usage of "AppAttachPackage_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_Get.json + // this example is just showing the usage of "AppAttachPackage_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -222,18 +209,23 @@ public async Task GetAll_AppAttachPackageListByResourceGroup() // get the collection of this AppAttachPackageResource AppAttachPackageCollection collection = resourceGroupResource.GetAppAttachPackages(); - // invoke the operation and iterate over the result - string filter = "HostPoolName eq 'hostpool1'"; - await foreach (AppAttachPackageResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string appAttachPackageName = "packagefullname"; + NullableResponse response = await collection.GetIfExistsAsync(appAttachPackageName); + AppAttachPackageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppAttachPackageData resourceData = item.Data; + AppAttachPackageData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_AppAttachPackageResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_AppAttachPackageResource.cs index 3afc0b5498f5e..b7a1106b3f986 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_AppAttachPackageResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_AppAttachPackageResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DesktopVirtualization.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DesktopVirtualization.Samples @@ -103,37 +102,5 @@ public async Task Update_AppAttachPackageUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAppAttachPackages_AppAttachPackageListBySubscription() - { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_ListBySubscription.json - // this example is just showing the usage of "AppAttachPackage_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string filter = "HostPoolName eq 'hostpool1'"; - await foreach (AppAttachPackageResource item in subscriptionResource.GetAppAttachPackagesAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppAttachPackageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolCollection.cs index 8e2d5f360e013..7e1c9a5c3c7b5 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_HostPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_HostPoolGet() + public async Task CreateOrUpdate_HostPoolCreate() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_Get.json - // this example is just showing the usage of "HostPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_Create.json + // this example is just showing the usage of "HostPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,47 @@ public async Task Get_HostPoolGet() // invoke the operation string hostPoolName = "hostPool1"; - HostPoolResource result = await collection.GetAsync(hostPoolName); + HostPoolData data = new HostPoolData(new AzureLocation("centralus"), HostPoolType.Pooled, HostPoolLoadBalancerType.BreadthFirst, PreferredAppGroupType.Desktop) + { + FriendlyName = "friendly", + Description = "des1", + PersonalDesktopAssignmentType = PersonalDesktopAssignmentType.Automatic, + CustomRdpProperty = null, + MaxSessionLimit = 999999, + RegistrationInfo = new HostPoolRegistrationInfo + { + ExpireOn = DateTimeOffset.Parse("2020-10-01T14:01:54.9571247Z"), + RegistrationTokenOperation = HostPoolRegistrationTokenOperation.Update, + }, + VmTemplate = "{json:json}", + SsoAdfsAuthority = "https://adfs", + SsoClientId = "client", + SsoClientSecretKeyVaultPath = "https://keyvault/secret", + SsoSecretType = HostPoolSsoSecretType.SharedKey, + StartVmOnConnect = false, + AgentUpdate = new SessionHostAgentUpdateProperties + { + UpdateType = SessionHostComponentUpdateType.Scheduled, + DoesUseSessionHostLocalTime = false, + MaintenanceWindowTimeZone = "Alaskan Standard Time", + MaintenanceWindows = {new SessionHostMaintenanceWindowProperties +{ +Hour = 7, +DayOfWeek = DesktopVirtualizationDayOfWeek.Friday, +}, new SessionHostMaintenanceWindowProperties +{ +Hour = 8, +DayOfWeek = DesktopVirtualizationDayOfWeek.Saturday, +}}, + }, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hostPoolName, data); + HostPoolResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +92,7 @@ public async Task Get_HostPoolGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_HostPoolGet() + public async Task Get_HostPoolGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_Get.json // this example is just showing the usage of "HostPools_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +114,21 @@ public async Task Exists_HostPoolGet() // invoke the operation string hostPoolName = "hostPool1"; - bool result = await collection.ExistsAsync(hostPoolName); + HostPoolResource result = await collection.GetAsync(hostPoolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HostPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HostPoolGet() + public async Task GetAll_HostPoolListByResourceGroup() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_Get.json - // this example is just showing the usage of "HostPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_ListByResourceGroup.json + // this example is just showing the usage of "HostPools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +145,28 @@ public async Task GetIfExists_HostPoolGet() // get the collection of this HostPoolResource HostPoolCollection collection = resourceGroupResource.GetHostPools(); - // invoke the operation - string hostPoolName = "hostPool1"; - NullableResponse response = await collection.GetIfExistsAsync(hostPoolName); - HostPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (HostPoolResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HostPoolData resourceData = result.Data; + HostPoolData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_HostPoolCreate() + public async Task Exists_HostPoolGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_Create.json - // this example is just showing the usage of "HostPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_Get.json + // this example is just showing the usage of "HostPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,64 +185,17 @@ public async Task CreateOrUpdate_HostPoolCreate() // invoke the operation string hostPoolName = "hostPool1"; - HostPoolData data = new HostPoolData(new AzureLocation("centralus"), HostPoolType.Pooled, HostPoolLoadBalancerType.BreadthFirst, PreferredAppGroupType.Desktop) - { - FriendlyName = "friendly", - Description = "des1", - PersonalDesktopAssignmentType = PersonalDesktopAssignmentType.Automatic, - CustomRdpProperty = null, - MaxSessionLimit = 999999, - RegistrationInfo = new HostPoolRegistrationInfo() - { - ExpireOn = DateTimeOffset.Parse("2020-10-01T14:01:54.9571247Z"), - RegistrationTokenOperation = HostPoolRegistrationTokenOperation.Update, - }, - VmTemplate = "{json:json}", - SsoAdfsAuthority = "https://adfs", - SsoClientId = "client", - SsoClientSecretKeyVaultPath = "https://keyvault/secret", - SsoSecretType = HostPoolSsoSecretType.SharedKey, - StartVmOnConnect = false, - AgentUpdate = new SessionHostAgentUpdateProperties() - { - UpdateType = SessionHostComponentUpdateType.Scheduled, - DoesUseSessionHostLocalTime = false, - MaintenanceWindowTimeZone = "Alaskan Standard Time", - MaintenanceWindows = -{ -new SessionHostMaintenanceWindowProperties() -{ -Hour = 7, -DayOfWeek = DesktopVirtualizationDayOfWeek.Friday, -},new SessionHostMaintenanceWindowProperties() -{ -Hour = 8, -DayOfWeek = DesktopVirtualizationDayOfWeek.Saturday, -} -}, - }, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hostPoolName, data); - HostPoolResource result = lro.Value; + bool result = await collection.ExistsAsync(hostPoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HostPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_HostPoolListByResourceGroup() + public async Task GetIfExists_HostPoolGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_ListByResourceGroup.json - // this example is just showing the usage of "HostPools_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_Get.json + // this example is just showing the usage of "HostPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -218,20 +212,23 @@ public async Task GetAll_HostPoolListByResourceGroup() // get the collection of this HostPoolResource HostPoolCollection collection = resourceGroupResource.GetHostPools(); - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (HostPoolResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string hostPoolName = "hostPool1"; + NullableResponse response = await collection.GetIfExistsAsync(hostPoolName); + HostPoolResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HostPoolData resourceData = item.Data; + HostPoolData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolPrivateEndpointConnectionCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolPrivateEndpointConnectionCollection.cs index 30070c0bc3651..56146b119bce8 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolPrivateEndpointConnectionCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HostPoolPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionListByHostPool() + public async Task CreateOrUpdate_PrivateEndpointConnectionUpdateByHostPool() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_ListByHostPool.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByHostPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_UpdateByHostPool.json + // this example is just showing the usage of "PrivateEndpointConnections_UpdateByHostPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_PrivateEndpointConnectionListByHostPool() // get the collection of this HostPoolPrivateEndpointConnectionResource HostPoolPrivateEndpointConnectionCollection collection = hostPool.GetHostPoolPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (HostPoolPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "hostPool1.377103f1-5179-4bdf-8556-4cdd3207cc5b"; + DesktopVirtualizationPrivateEndpointConnection connection = new DesktopVirtualizationPrivateEndpointConnection { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new DesktopVirtualizationPrivateLinkServiceConnectionState + { + Status = DesktopVirtualizationPrivateEndpointServiceConnectionStatus.Approved, + Description = "Approved by admin@consoto.com", + ActionsRequired = "None", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, connection); + HostPoolPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_PrivateEndpointConnectionGetByHostPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionGetByHostPool() + public async Task GetAll_PrivateEndpointConnectionListByHostPool() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_GetByHostPool.json - // this example is just showing the usage of "PrivateEndpointConnections_GetByHostPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_ListByHostPool.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByHostPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_PrivateEndpointConnectionGetByHostPool() // get the collection of this HostPoolPrivateEndpointConnectionResource HostPoolPrivateEndpointConnectionCollection collection = hostPool.GetHostPoolPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "hostPool1.377103f1-5179-4bdf-8556-4cdd3207cc5b"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (HostPoolPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionGetByHostPool() + public async Task Exists_PrivateEndpointConnectionGetByHostPool() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_GetByHostPool.json // this example is just showing the usage of "PrivateEndpointConnections_GetByHostPool" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_PrivateEndpointConnectionGetByHostPool() // invoke the operation string privateEndpointConnectionName = "hostPool1.377103f1-5179-4bdf-8556-4cdd3207cc5b"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - HostPoolPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionUpdateByHostPool() + public async Task GetIfExists_PrivateEndpointConnectionGetByHostPool() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_UpdateByHostPool.json - // this example is just showing the usage of "PrivateEndpointConnections_UpdateByHostPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_GetByHostPool.json + // this example is just showing the usage of "PrivateEndpointConnections_GetByHostPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionUpdateByHostPool() // invoke the operation string privateEndpointConnectionName = "hostPool1.377103f1-5179-4bdf-8556-4cdd3207cc5b"; - DesktopVirtualizationPrivateEndpointConnection connection = new DesktopVirtualizationPrivateEndpointConnection() - { - ConnectionState = new DesktopVirtualizationPrivateLinkServiceConnectionState() - { - Status = DesktopVirtualizationPrivateEndpointServiceConnectionStatus.Approved, - Description = "Approved by admin@consoto.com", - ActionsRequired = "None", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, connection); - HostPoolPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + HostPoolPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolPrivateEndpointConnectionResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolPrivateEndpointConnectionResource.cs index c6ea7ff317a2d..aea8c7840276c 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolPrivateEndpointConnectionResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolPrivateEndpointConnectionResource.cs @@ -96,9 +96,9 @@ public async Task Update_PrivateEndpointConnectionUpdateByHostPool() HostPoolPrivateEndpointConnectionResource hostPoolPrivateEndpointConnection = client.GetHostPoolPrivateEndpointConnectionResource(hostPoolPrivateEndpointConnectionResourceId); // invoke the operation - DesktopVirtualizationPrivateEndpointConnection connection = new DesktopVirtualizationPrivateEndpointConnection() + DesktopVirtualizationPrivateEndpointConnection connection = new DesktopVirtualizationPrivateEndpointConnection { - ConnectionState = new DesktopVirtualizationPrivateLinkServiceConnectionState() + ConnectionState = new DesktopVirtualizationPrivateLinkServiceConnectionState { Status = DesktopVirtualizationPrivateEndpointServiceConnectionStatus.Approved, Description = "Approved by admin@consoto.com", diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolResource.cs index 34c165e74d53a..6da17ec4fed6d 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_HostPoolResource.cs @@ -10,78 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DesktopVirtualization.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DesktopVirtualization.Samples { public partial class Sample_HostPoolResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPrivateLinkResources_PrivateLinkResourcesListByHostPool() - { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateLinkResources_ListByHostPool.json - // this example is just showing the usage of "PrivateLinkResources_ListByHostPool" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HostPoolResource created on azure - // for more information of creating HostPoolResource, please refer to the document of HostPoolResource - string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; - string resourceGroupName = "resourceGroup1"; - string hostPoolName = "hostPool1"; - ResourceIdentifier hostPoolResourceId = HostPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostPoolName); - HostPoolResource hostPool = client.GetHostPoolResource(hostPoolResourceId); - - // invoke the operation and iterate over the result - await foreach (DesktopVirtualizationPrivateLinkResourceData item in hostPool.GetPrivateLinkResourcesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetScalingPlans_ScalingPlanListByHostPool() - { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_ListByHostPool.json - // this example is just showing the usage of "ScalingPlans_ListByHostPool" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HostPoolResource created on azure - // for more information of creating HostPoolResource, please refer to the document of HostPoolResource - string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; - string resourceGroupName = "resourceGroup1"; - string hostPoolName = "hostPool1"; - ResourceIdentifier hostPoolResourceId = HostPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostPoolName); - HostPoolResource hostPool = client.GetHostPoolResource(hostPoolResourceId); - - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (ScalingPlanResource item in hostPool.GetScalingPlansAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScalingPlanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_HostPoolGet() @@ -160,12 +94,12 @@ public async Task Update_HostPoolUpdate() HostPoolResource hostPool = client.GetHostPoolResource(hostPoolResourceId); // invoke the operation - HostPoolPatch patch = new HostPoolPatch() + HostPoolPatch patch = new HostPoolPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, FriendlyName = "friendly", Description = "des1", @@ -173,7 +107,7 @@ public async Task Update_HostPoolUpdate() MaxSessionLimit = 999999, PersonalDesktopAssignmentType = PersonalDesktopAssignmentType.Automatic, LoadBalancerType = HostPoolLoadBalancerType.BreadthFirst, - RegistrationInfo = new HostPoolRegistrationInfoPatch() + RegistrationInfo = new HostPoolRegistrationInfoPatch { ExpireOn = DateTimeOffset.Parse("2020-10-01T15:01:54.9571247Z"), RegistrationTokenOperation = HostPoolRegistrationTokenOperation.Update, @@ -184,23 +118,20 @@ public async Task Update_HostPoolUpdate() SsoClientSecretKeyVaultPath = "https://keyvault/secret", SsoSecretType = HostPoolSsoSecretType.SharedKey, StartVmOnConnect = false, - AgentUpdate = new SessionHostAgentUpdatePatchProperties() + AgentUpdate = new SessionHostAgentUpdatePatchProperties { UpdateType = SessionHostComponentUpdateType.Scheduled, DoesUseSessionHostLocalTime = false, MaintenanceWindowTimeZone = "Alaskan Standard Time", - MaintenanceWindows = -{ -new MaintenanceWindowPatchProperties() + MaintenanceWindows = {new MaintenanceWindowPatchProperties { Hour = 7, DayOfWeek = DesktopVirtualizationDayOfWeek.Friday, -},new MaintenanceWindowPatchProperties() +}, new MaintenanceWindowPatchProperties { Hour = 8, DayOfWeek = DesktopVirtualizationDayOfWeek.Saturday, -} -}, +}}, }, }; HostPoolResource result = await hostPool.UpdateAsync(patch); @@ -214,31 +145,62 @@ public async Task Update_HostPoolUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetHostPools_HostPoolList() + public async Task GetPrivateLinkResources_PrivateLinkResourcesListByHostPool() + { + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateLinkResources_ListByHostPool.json + // this example is just showing the usage of "PrivateLinkResources_ListByHostPool" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HostPoolResource created on azure + // for more information of creating HostPoolResource, please refer to the document of HostPoolResource + string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; + string resourceGroupName = "resourceGroup1"; + string hostPoolName = "hostPool1"; + ResourceIdentifier hostPoolResourceId = HostPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostPoolName); + HostPoolResource hostPool = client.GetHostPoolResource(hostPoolResourceId); + + // invoke the operation and iterate over the result + await foreach (DesktopVirtualizationPrivateLinkResourceData item in hostPool.GetPrivateLinkResourcesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetScalingPlans_ScalingPlanListByHostPool() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_List.json - // this example is just showing the usage of "HostPools_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_ListByHostPool.json + // this example is just showing the usage of "ScalingPlans_ListByHostPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this HostPoolResource created on azure + // for more information of creating HostPoolResource, please refer to the document of HostPoolResource string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "resourceGroup1"; + string hostPoolName = "hostPool1"; + ResourceIdentifier hostPoolResourceId = HostPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, hostPoolName); + HostPoolResource hostPool = client.GetHostPoolResource(hostPoolResourceId); // invoke the operation and iterate over the result int? pageSize = 10; bool? isDescending = true; int? initialSkip = 0; - await foreach (HostPoolResource item in subscriptionResource.GetHostPoolsAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + await foreach (ScalingPlanResource item in hostPool.GetScalingPlansAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HostPoolData resourceData = item.Data; + ScalingPlanData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } @@ -330,7 +292,7 @@ public async Task ImportAppAttachPackageInfos_AppAttachPackageInfoImport() HostPoolResource hostPool = client.GetHostPoolResource(hostPoolResourceId); // invoke the operation and iterate over the result - ImportPackageInfoContent content = new ImportPackageInfoContent() + ImportPackageInfoContent content = new ImportPackageInfoContent { Path = "imagepath", PackageArchitecture = AppAttachPackageArchitecture.X64, @@ -368,7 +330,7 @@ public async Task ExpandMsixImages_MsixImageExpand() HostPoolResource hostPool = client.GetHostPoolResource(hostPoolResourceId); // invoke the operation and iterate over the result - MsixImageUri msixImageUri = new MsixImageUri() + MsixImageUri msixImageUri = new MsixImageUri { Uri = new Uri("imagepath"), }; diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_MsixPackageCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_MsixPackageCollection.cs index a1a8819443d89..7e6368e6b4239 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_MsixPackageCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_MsixPackageCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MsixPackageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MSIXPackageGet() + public async Task CreateOrUpdate_MSIXPackageCreate() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/MsixPackage_Get.json - // this example is just showing the usage of "MSIXPackages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/MsixPackage_Create.json + // this example is just showing the usage of "MSIXPackages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,37 @@ public async Task Get_MSIXPackageGet() MsixPackageCollection collection = hostPool.GetMsixPackages(); // invoke the operation - string msixPackageFullName = "packagefullname"; - MsixPackageResource result = await collection.GetAsync(msixPackageFullName); + string msixPackageFullName = "msixpackagefullname"; + MsixPackageData data = new MsixPackageData + { + ImagePath = "imagepath", + PackageName = "MsixPackage_name", + PackageFamilyName = "MsixPackage_FamilyName", + DisplayName = "displayname", + PackageRelativePath = "packagerelativepath", + IsRegularRegistration = false, + IsActive = false, + PackageDependencies = {new MsixPackageDependencies +{ +DependencyName = "MsixTest_Dependency_Name", +Publisher = "PublishedName", +MinVersion = "version", +}}, + Version = "version", + LastUpdatedOn = DateTimeOffset.Parse("2008-09-22T14:01:54.9571247Z"), + PackageApplications = {new MsixPackageApplications +{ +AppId = "ApplicationId", +Description = "application-desc", +AppUserModelId = "AppUserModelId", +FriendlyName = "friendlyname", +IconImageName = "Apptile", +RawIcon = BinaryData.FromObjectAsJson("VGhpcyBpcyBhIHN0cmluZyB0byBoYXNo"), +RawPng = BinaryData.FromObjectAsJson("VGhpcyBpcyBhIHN0cmluZyB0byBoYXNo"), +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, msixPackageFullName, data); + MsixPackageResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +81,7 @@ public async Task Get_MSIXPackageGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MSIXPackageGet() + public async Task Get_MSIXPackageGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/MsixPackage_Get.json // this example is just showing the usage of "MSIXPackages_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +104,21 @@ public async Task Exists_MSIXPackageGet() // invoke the operation string msixPackageFullName = "packagefullname"; - bool result = await collection.ExistsAsync(msixPackageFullName); + MsixPackageResource result = await collection.GetAsync(msixPackageFullName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MsixPackageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MSIXPackageGet() + public async Task GetAll_MSIXPackageList() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/MsixPackage_Get.json - // this example is just showing the usage of "MSIXPackages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/MsixPackage_List.json + // this example is just showing the usage of "MSIXPackages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +136,28 @@ public async Task GetIfExists_MSIXPackageGet() // get the collection of this MsixPackageResource MsixPackageCollection collection = hostPool.GetMsixPackages(); - // invoke the operation - string msixPackageFullName = "packagefullname"; - NullableResponse response = await collection.GetIfExistsAsync(msixPackageFullName); - MsixPackageResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (MsixPackageResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MsixPackageData resourceData = result.Data; + MsixPackageData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_MSIXPackageCreate() + public async Task Exists_MSIXPackageGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/MsixPackage_Create.json - // this example is just showing the usage of "MSIXPackages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/MsixPackage_Get.json + // this example is just showing the usage of "MSIXPackages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,57 +176,18 @@ public async Task CreateOrUpdate_MSIXPackageCreate() MsixPackageCollection collection = hostPool.GetMsixPackages(); // invoke the operation - string msixPackageFullName = "msixpackagefullname"; - MsixPackageData data = new MsixPackageData() - { - ImagePath = "imagepath", - PackageName = "MsixPackage_name", - PackageFamilyName = "MsixPackage_FamilyName", - DisplayName = "displayname", - PackageRelativePath = "packagerelativepath", - IsRegularRegistration = false, - IsActive = false, - PackageDependencies = -{ -new MsixPackageDependencies() -{ -DependencyName = "MsixTest_Dependency_Name", -Publisher = "PublishedName", -MinVersion = "version", -} -}, - Version = "version", - LastUpdatedOn = DateTimeOffset.Parse("2008-09-22T14:01:54.9571247Z"), - PackageApplications = -{ -new MsixPackageApplications() -{ -AppId = "ApplicationId", -Description = "application-desc", -AppUserModelId = "AppUserModelId", -FriendlyName = "friendlyname", -IconImageName = "Apptile", -RawIcon = BinaryData.FromString("\"VGhpcyBpcyBhIHN0cmluZyB0byBoYXNo\""), -RawPng = BinaryData.FromString("\"VGhpcyBpcyBhIHN0cmluZyB0byBoYXNo\""), -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, msixPackageFullName, data); - MsixPackageResource result = lro.Value; + string msixPackageFullName = "packagefullname"; + bool result = await collection.ExistsAsync(msixPackageFullName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MsixPackageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MSIXPackageList() + public async Task GetIfExists_MSIXPackageGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/MsixPackage_List.json - // this example is just showing the usage of "MSIXPackages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/MsixPackage_Get.json + // this example is just showing the usage of "MSIXPackages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -214,20 +205,23 @@ public async Task GetAll_MSIXPackageList() // get the collection of this MsixPackageResource MsixPackageCollection collection = hostPool.GetMsixPackages(); - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (MsixPackageResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string msixPackageFullName = "packagefullname"; + NullableResponse response = await collection.GetIfExistsAsync(msixPackageFullName); + MsixPackageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MsixPackageData resourceData = item.Data; + MsixPackageData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_MsixPackageResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_MsixPackageResource.cs index 19f6d43561a6b..cd2ff7e4eae16 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_MsixPackageResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_MsixPackageResource.cs @@ -96,7 +96,7 @@ public async Task Update_MSIXPackageUpdate() MsixPackageResource msixPackage = client.GetMsixPackageResource(msixPackageResourceId); // invoke the operation - MsixPackagePatch patch = new MsixPackagePatch() + MsixPackagePatch patch = new MsixPackagePatch { IsActive = true, IsRegularRegistration = false, diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanCollection.cs index caf5046993cba..85c1f46fdecfb 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ScalingPlanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ScalingPlansGet() + public async Task CreateOrUpdate_ScalingPlansCreate() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_Get.json - // this example is just showing the usage of "ScalingPlans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_Create.json + // this example is just showing the usage of "ScalingPlans_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,45 @@ public async Task Get_ScalingPlansGet() // invoke the operation string scalingPlanName = "scalingPlan1"; - ScalingPlanResource result = await collection.GetAsync(scalingPlanName); + ScalingPlanData data = new ScalingPlanData(new AzureLocation("centralus"), "Central Standard Time") + { + Description = "Description of Scaling Plan", + FriendlyName = "Scaling Plan 1", + ScalingHostPoolType = ScalingHostPoolType.Pooled, + ExclusionTag = "value", + Schedules = {new ScalingSchedule +{ +Name = "schedule1", +DaysOfWeek = {ScalingScheduleDaysOfWeekItem.Monday, ScalingScheduleDaysOfWeekItem.Tuesday, ScalingScheduleDaysOfWeekItem.Wednesday, ScalingScheduleDaysOfWeekItem.Thursday, ScalingScheduleDaysOfWeekItem.Friday}, +RampUpStartTime = new ScalingActionTime(6, 0), +RampUpLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, +RampUpMinimumHostsPct = 20, +RampUpCapacityThresholdPct = 80, +PeakStartTime = new ScalingActionTime(8, 0), +PeakLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.BreadthFirst, +RampDownStartTime = new ScalingActionTime(18, 0), +RampDownLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, +RampDownMinimumHostsPct = 20, +RampDownCapacityThresholdPct = 50, +RampDownForceLogoffUsers = true, +RampDownWaitTimeMinutes = 30, +RampDownNotificationMessage = "message", +OffPeakStartTime = new ScalingActionTime(20, 0), +OffPeakLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, +}}, + HostPoolReferences = {new ScalingHostPoolReference +{ +HostPoolId = new ResourceIdentifier("/subscriptions/daefabc0-95b4-48b3-b645-8a753a63c4fa/resourceGroups/resourceGroup1/providers/Microsoft.DesktopVirtualization/hostPools/hostPool1"), +IsScalingPlanEnabled = true, +}}, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scalingPlanName, data); + ScalingPlanResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +90,7 @@ public async Task Get_ScalingPlansGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ScalingPlansGet() + public async Task Get_ScalingPlansGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_Get.json // this example is just showing the usage of "ScalingPlans_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +112,21 @@ public async Task Exists_ScalingPlansGet() // invoke the operation string scalingPlanName = "scalingPlan1"; - bool result = await collection.ExistsAsync(scalingPlanName); + ScalingPlanResource result = await collection.GetAsync(scalingPlanName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScalingPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ScalingPlansGet() + public async Task GetAll_ScalingPlansListByResourceGroup() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_Get.json - // this example is just showing the usage of "ScalingPlans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_ListByResourceGroup.json + // this example is just showing the usage of "ScalingPlans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +143,28 @@ public async Task GetIfExists_ScalingPlansGet() // get the collection of this ScalingPlanResource ScalingPlanCollection collection = resourceGroupResource.GetScalingPlans(); - // invoke the operation - string scalingPlanName = "scalingPlan1"; - NullableResponse response = await collection.GetIfExistsAsync(scalingPlanName); - ScalingPlanResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (ScalingPlanResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScalingPlanData resourceData = result.Data; + ScalingPlanData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ScalingPlansCreate() + public async Task Exists_ScalingPlansGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_Create.json - // this example is just showing the usage of "ScalingPlans_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_Get.json + // this example is just showing the usage of "ScalingPlans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,68 +183,17 @@ public async Task CreateOrUpdate_ScalingPlansCreate() // invoke the operation string scalingPlanName = "scalingPlan1"; - ScalingPlanData data = new ScalingPlanData(new AzureLocation("centralus"), "Central Standard Time") - { - Description = "Description of Scaling Plan", - FriendlyName = "Scaling Plan 1", - ScalingHostPoolType = ScalingHostPoolType.Pooled, - ExclusionTag = "value", - Schedules = -{ -new ScalingSchedule() -{ -Name = "schedule1", -DaysOfWeek = -{ -ScalingScheduleDaysOfWeekItem.Monday,ScalingScheduleDaysOfWeekItem.Tuesday,ScalingScheduleDaysOfWeekItem.Wednesday,ScalingScheduleDaysOfWeekItem.Thursday,ScalingScheduleDaysOfWeekItem.Friday -}, -RampUpStartTime = new ScalingActionTime(6,0), -RampUpLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, -RampUpMinimumHostsPct = 20, -RampUpCapacityThresholdPct = 80, -PeakStartTime = new ScalingActionTime(8,0), -PeakLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.BreadthFirst, -RampDownStartTime = new ScalingActionTime(18,0), -RampDownLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, -RampDownMinimumHostsPct = 20, -RampDownCapacityThresholdPct = 50, -RampDownForceLogoffUsers = true, -RampDownWaitTimeMinutes = 30, -RampDownNotificationMessage = "message", -OffPeakStartTime = new ScalingActionTime(20,0), -OffPeakLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, -} -}, - HostPoolReferences = -{ -new ScalingHostPoolReference() -{ -HostPoolId = new ResourceIdentifier("/subscriptions/daefabc0-95b4-48b3-b645-8a753a63c4fa/resourceGroups/resourceGroup1/providers/Microsoft.DesktopVirtualization/hostPools/hostPool1"), -IsScalingPlanEnabled = true, -} -}, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scalingPlanName, data); - ScalingPlanResource result = lro.Value; + bool result = await collection.ExistsAsync(scalingPlanName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScalingPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScalingPlansListByResourceGroup() + public async Task GetIfExists_ScalingPlansGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_ListByResourceGroup.json - // this example is just showing the usage of "ScalingPlans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_Get.json + // this example is just showing the usage of "ScalingPlans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -222,20 +210,23 @@ public async Task GetAll_ScalingPlansListByResourceGroup() // get the collection of this ScalingPlanResource ScalingPlanCollection collection = resourceGroupResource.GetScalingPlans(); - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (ScalingPlanResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string scalingPlanName = "scalingPlan1"; + NullableResponse response = await collection.GetIfExistsAsync(scalingPlanName); + ScalingPlanResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScalingPlanData resourceData = item.Data; + ScalingPlanData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPersonalScheduleCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPersonalScheduleCollection.cs index c3047a1a49cdc..cfddb58b35aac 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPersonalScheduleCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPersonalScheduleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ScalingPlanPersonalScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ScalingPlanPersonalSchedulesGet() + public async Task CreateOrUpdate_ScalingPlanPersonalSchedulesCreate() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPersonalSchedule_Get.json - // this example is just showing the usage of "ScalingPlanPersonalSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPersonalSchedule_Create.json + // this example is just showing the usage of "ScalingPlanPersonalSchedules_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task Get_ScalingPlanPersonalSchedulesGet() // for more information of creating ScalingPlanResource, please refer to the document of ScalingPlanResource string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; string resourceGroupName = "resourceGroup1"; - string scalingPlanName = "PersonalScalingPlan1"; + string scalingPlanName = "scalingPlan1"; ResourceIdentifier scalingPlanResourceId = ScalingPlanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, scalingPlanName); ScalingPlanResource scalingPlan = client.GetScalingPlanResource(scalingPlanResourceId); @@ -40,8 +40,38 @@ public async Task Get_ScalingPlanPersonalSchedulesGet() ScalingPlanPersonalScheduleCollection collection = scalingPlan.GetScalingPlanPersonalSchedules(); // invoke the operation - string scalingPlanScheduleName = "PersonalScalingPlanSchedule"; - ScalingPlanPersonalScheduleResource result = await collection.GetAsync(scalingPlanScheduleName); + string scalingPlanScheduleName = "scalingPlanScheduleWeekdays1"; + ScalingPlanPersonalScheduleData data = new ScalingPlanPersonalScheduleData + { + DaysOfWeek = { DesktopVirtualizationDayOfWeek.Monday, DesktopVirtualizationDayOfWeek.Tuesday, DesktopVirtualizationDayOfWeek.Wednesday, DesktopVirtualizationDayOfWeek.Thursday, DesktopVirtualizationDayOfWeek.Friday }, + RampUpStartTime = new ScalingActionTime(6, 0), + RampUpAutoStartHosts = StartupBehavior.All, + RampUpStartVmOnConnect = SetStartVmOnConnect.Enable, + RampUpActionOnDisconnect = SessionHandlingOperation.None, + RampUpMinutesToWaitOnDisconnect = 10, + RampUpActionOnLogoff = SessionHandlingOperation.None, + RampUpMinutesToWaitOnLogoff = 10, + PeakStartTime = new ScalingActionTime(8, 0), + PeakStartVmOnConnect = SetStartVmOnConnect.Enable, + PeakActionOnDisconnect = SessionHandlingOperation.None, + PeakMinutesToWaitOnDisconnect = 10, + PeakActionOnLogoff = SessionHandlingOperation.Deallocate, + PeakMinutesToWaitOnLogoff = 10, + RampDownStartTime = new ScalingActionTime(18, 0), + RampDownStartVmOnConnect = SetStartVmOnConnect.Enable, + RampDownActionOnDisconnect = SessionHandlingOperation.None, + RampDownMinutesToWaitOnDisconnect = 10, + RampDownActionOnLogoff = SessionHandlingOperation.Deallocate, + RampDownMinutesToWaitOnLogoff = 10, + OffPeakStartTime = new ScalingActionTime(20, 0), + OffPeakStartVmOnConnect = SetStartVmOnConnect.Enable, + OffPeakActionOnDisconnect = SessionHandlingOperation.None, + OffPeakMinutesToWaitOnDisconnect = 10, + OffPeakActionOnLogoff = SessionHandlingOperation.Deallocate, + OffPeakMinutesToWaitOnLogoff = 10, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scalingPlanScheduleName, data); + ScalingPlanPersonalScheduleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +82,7 @@ public async Task Get_ScalingPlanPersonalSchedulesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ScalingPlanPersonalSchedulesGet() + public async Task Get_ScalingPlanPersonalSchedulesGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPersonalSchedule_Get.json // this example is just showing the usage of "ScalingPlanPersonalSchedules_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +105,21 @@ public async Task Exists_ScalingPlanPersonalSchedulesGet() // invoke the operation string scalingPlanScheduleName = "PersonalScalingPlanSchedule"; - bool result = await collection.ExistsAsync(scalingPlanScheduleName); + ScalingPlanPersonalScheduleResource result = await collection.GetAsync(scalingPlanScheduleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScalingPlanPersonalScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ScalingPlanPersonalSchedulesGet() + public async Task GetAll_ScalingPlanPersonalSchedulesList() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPersonalSchedule_Get.json - // this example is just showing the usage of "ScalingPlanPersonalSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPersonalSchedule_List.json + // this example is just showing the usage of "ScalingPlanPersonalSchedules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,38 +130,35 @@ public async Task GetIfExists_ScalingPlanPersonalSchedulesGet() // for more information of creating ScalingPlanResource, please refer to the document of ScalingPlanResource string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; string resourceGroupName = "resourceGroup1"; - string scalingPlanName = "PersonalScalingPlan1"; + string scalingPlanName = "scalingPlan"; ResourceIdentifier scalingPlanResourceId = ScalingPlanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, scalingPlanName); ScalingPlanResource scalingPlan = client.GetScalingPlanResource(scalingPlanResourceId); // get the collection of this ScalingPlanPersonalScheduleResource ScalingPlanPersonalScheduleCollection collection = scalingPlan.GetScalingPlanPersonalSchedules(); - // invoke the operation - string scalingPlanScheduleName = "PersonalScalingPlanSchedule"; - NullableResponse response = await collection.GetIfExistsAsync(scalingPlanScheduleName); - ScalingPlanPersonalScheduleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (ScalingPlanPersonalScheduleResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScalingPlanPersonalScheduleData resourceData = result.Data; + ScalingPlanPersonalScheduleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ScalingPlanPersonalSchedulesCreate() + public async Task Exists_ScalingPlanPersonalSchedulesGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPersonalSchedule_Create.json - // this example is just showing the usage of "ScalingPlanPersonalSchedules_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPersonalSchedule_Get.json + // this example is just showing the usage of "ScalingPlanPersonalSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,7 +169,7 @@ public async Task CreateOrUpdate_ScalingPlanPersonalSchedulesCreate() // for more information of creating ScalingPlanResource, please refer to the document of ScalingPlanResource string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; string resourceGroupName = "resourceGroup1"; - string scalingPlanName = "scalingPlan1"; + string scalingPlanName = "PersonalScalingPlan1"; ResourceIdentifier scalingPlanResourceId = ScalingPlanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, scalingPlanName); ScalingPlanResource scalingPlan = client.GetScalingPlanResource(scalingPlanResourceId); @@ -146,55 +177,18 @@ public async Task CreateOrUpdate_ScalingPlanPersonalSchedulesCreate() ScalingPlanPersonalScheduleCollection collection = scalingPlan.GetScalingPlanPersonalSchedules(); // invoke the operation - string scalingPlanScheduleName = "scalingPlanScheduleWeekdays1"; - ScalingPlanPersonalScheduleData data = new ScalingPlanPersonalScheduleData() - { - DaysOfWeek = -{ -DesktopVirtualizationDayOfWeek.Monday,DesktopVirtualizationDayOfWeek.Tuesday,DesktopVirtualizationDayOfWeek.Wednesday,DesktopVirtualizationDayOfWeek.Thursday,DesktopVirtualizationDayOfWeek.Friday -}, - RampUpStartTime = new ScalingActionTime(6, 0), - RampUpAutoStartHosts = StartupBehavior.All, - RampUpStartVmOnConnect = SetStartVmOnConnect.Enable, - RampUpActionOnDisconnect = SessionHandlingOperation.None, - RampUpMinutesToWaitOnDisconnect = 10, - RampUpActionOnLogoff = SessionHandlingOperation.None, - RampUpMinutesToWaitOnLogoff = 10, - PeakStartTime = new ScalingActionTime(8, 0), - PeakStartVmOnConnect = SetStartVmOnConnect.Enable, - PeakActionOnDisconnect = SessionHandlingOperation.None, - PeakMinutesToWaitOnDisconnect = 10, - PeakActionOnLogoff = SessionHandlingOperation.Deallocate, - PeakMinutesToWaitOnLogoff = 10, - RampDownStartTime = new ScalingActionTime(18, 0), - RampDownStartVmOnConnect = SetStartVmOnConnect.Enable, - RampDownActionOnDisconnect = SessionHandlingOperation.None, - RampDownMinutesToWaitOnDisconnect = 10, - RampDownActionOnLogoff = SessionHandlingOperation.Deallocate, - RampDownMinutesToWaitOnLogoff = 10, - OffPeakStartTime = new ScalingActionTime(20, 0), - OffPeakStartVmOnConnect = SetStartVmOnConnect.Enable, - OffPeakActionOnDisconnect = SessionHandlingOperation.None, - OffPeakMinutesToWaitOnDisconnect = 10, - OffPeakActionOnLogoff = SessionHandlingOperation.Deallocate, - OffPeakMinutesToWaitOnLogoff = 10, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scalingPlanScheduleName, data); - ScalingPlanPersonalScheduleResource result = lro.Value; + string scalingPlanScheduleName = "PersonalScalingPlanSchedule"; + bool result = await collection.ExistsAsync(scalingPlanScheduleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScalingPlanPersonalScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScalingPlanPersonalSchedulesList() + public async Task GetIfExists_ScalingPlanPersonalSchedulesGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPersonalSchedule_List.json - // this example is just showing the usage of "ScalingPlanPersonalSchedules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPersonalSchedule_Get.json + // this example is just showing the usage of "ScalingPlanPersonalSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -205,27 +199,30 @@ public async Task GetAll_ScalingPlanPersonalSchedulesList() // for more information of creating ScalingPlanResource, please refer to the document of ScalingPlanResource string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; string resourceGroupName = "resourceGroup1"; - string scalingPlanName = "scalingPlan"; + string scalingPlanName = "PersonalScalingPlan1"; ResourceIdentifier scalingPlanResourceId = ScalingPlanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, scalingPlanName); ScalingPlanResource scalingPlan = client.GetScalingPlanResource(scalingPlanResourceId); // get the collection of this ScalingPlanPersonalScheduleResource ScalingPlanPersonalScheduleCollection collection = scalingPlan.GetScalingPlanPersonalSchedules(); - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (ScalingPlanPersonalScheduleResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string scalingPlanScheduleName = "PersonalScalingPlanSchedule"; + NullableResponse response = await collection.GetIfExistsAsync(scalingPlanScheduleName); + ScalingPlanPersonalScheduleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScalingPlanPersonalScheduleData resourceData = item.Data; + ScalingPlanPersonalScheduleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPersonalScheduleResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPersonalScheduleResource.cs index 672e66c536393..62750d78eb515 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPersonalScheduleResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPersonalScheduleResource.cs @@ -96,7 +96,7 @@ public async Task Update_ScalingPlanPersonalSchedulesUpdate() ScalingPlanPersonalScheduleResource scalingPlanPersonalSchedule = client.GetScalingPlanPersonalScheduleResource(scalingPlanPersonalScheduleResourceId); // invoke the operation - ScalingPlanPersonalSchedulePatch patch = new ScalingPlanPersonalSchedulePatch() + ScalingPlanPersonalSchedulePatch patch = new ScalingPlanPersonalSchedulePatch { PeakStartTime = new ScalingActionTime(8, 0), PeakActionOnDisconnect = SessionHandlingOperation.None, diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPooledScheduleCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPooledScheduleCollection.cs index 5b84cd19aece4..b69462e6ec46d 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPooledScheduleCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPooledScheduleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ScalingPlanPooledScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ScalingPlanPooledSchedulesGet() + public async Task CreateOrUpdate_ScalingPlanPooledSchedulesCreate() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPooledSchedule_Get.json - // this example is just showing the usage of "ScalingPlanPooledSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPooledSchedule_Create.json + // this example is just showing the usage of "ScalingPlanPooledSchedules_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,27 @@ public async Task Get_ScalingPlanPooledSchedulesGet() // invoke the operation string scalingPlanScheduleName = "scalingPlanScheduleWeekdays1"; - ScalingPlanPooledScheduleResource result = await collection.GetAsync(scalingPlanScheduleName); + ScalingPlanPooledScheduleData data = new ScalingPlanPooledScheduleData + { + DaysOfWeek = { DesktopVirtualizationDayOfWeek.Monday, DesktopVirtualizationDayOfWeek.Tuesday, DesktopVirtualizationDayOfWeek.Wednesday, DesktopVirtualizationDayOfWeek.Thursday, DesktopVirtualizationDayOfWeek.Friday }, + RampUpStartTime = new ScalingActionTime(6, 0), + RampUpLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, + RampUpMinimumHostsPct = 20, + RampUpCapacityThresholdPct = 80, + PeakStartTime = new ScalingActionTime(8, 0), + PeakLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.BreadthFirst, + RampDownStartTime = new ScalingActionTime(18, 0), + RampDownLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, + RampDownMinimumHostsPct = 20, + RampDownCapacityThresholdPct = 50, + RampDownForceLogoffUsers = true, + RampDownWaitTimeMinutes = 30, + RampDownNotificationMessage = "message", + OffPeakStartTime = new ScalingActionTime(20, 0), + OffPeakLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scalingPlanScheduleName, data); + ScalingPlanPooledScheduleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +72,7 @@ public async Task Get_ScalingPlanPooledSchedulesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ScalingPlanPooledSchedulesGet() + public async Task Get_ScalingPlanPooledSchedulesGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPooledSchedule_Get.json // this example is just showing the usage of "ScalingPlanPooledSchedules_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +95,21 @@ public async Task Exists_ScalingPlanPooledSchedulesGet() // invoke the operation string scalingPlanScheduleName = "scalingPlanScheduleWeekdays1"; - bool result = await collection.ExistsAsync(scalingPlanScheduleName); + ScalingPlanPooledScheduleResource result = await collection.GetAsync(scalingPlanScheduleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScalingPlanPooledScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ScalingPlanPooledSchedulesGet() + public async Task GetAll_ScalingPlanPooledSchedulesList() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPooledSchedule_Get.json - // this example is just showing the usage of "ScalingPlanPooledSchedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPooledSchedule_List.json + // this example is just showing the usage of "ScalingPlanPooledSchedules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +127,28 @@ public async Task GetIfExists_ScalingPlanPooledSchedulesGet() // get the collection of this ScalingPlanPooledScheduleResource ScalingPlanPooledScheduleCollection collection = scalingPlan.GetScalingPlanPooledSchedules(); - // invoke the operation - string scalingPlanScheduleName = "scalingPlanScheduleWeekdays1"; - NullableResponse response = await collection.GetIfExistsAsync(scalingPlanScheduleName); - ScalingPlanPooledScheduleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (ScalingPlanPooledScheduleResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScalingPlanPooledScheduleData resourceData = result.Data; + ScalingPlanPooledScheduleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ScalingPlanPooledSchedulesCreate() + public async Task Exists_ScalingPlanPooledSchedulesGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPooledSchedule_Create.json - // this example is just showing the usage of "ScalingPlanPooledSchedules_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPooledSchedule_Get.json + // this example is just showing the usage of "ScalingPlanPooledSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,44 +168,17 @@ public async Task CreateOrUpdate_ScalingPlanPooledSchedulesCreate() // invoke the operation string scalingPlanScheduleName = "scalingPlanScheduleWeekdays1"; - ScalingPlanPooledScheduleData data = new ScalingPlanPooledScheduleData() - { - DaysOfWeek = -{ -DesktopVirtualizationDayOfWeek.Monday,DesktopVirtualizationDayOfWeek.Tuesday,DesktopVirtualizationDayOfWeek.Wednesday,DesktopVirtualizationDayOfWeek.Thursday,DesktopVirtualizationDayOfWeek.Friday -}, - RampUpStartTime = new ScalingActionTime(6, 0), - RampUpLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, - RampUpMinimumHostsPct = 20, - RampUpCapacityThresholdPct = 80, - PeakStartTime = new ScalingActionTime(8, 0), - PeakLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.BreadthFirst, - RampDownStartTime = new ScalingActionTime(18, 0), - RampDownLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, - RampDownMinimumHostsPct = 20, - RampDownCapacityThresholdPct = 50, - RampDownForceLogoffUsers = true, - RampDownWaitTimeMinutes = 30, - RampDownNotificationMessage = "message", - OffPeakStartTime = new ScalingActionTime(20, 0), - OffPeakLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scalingPlanScheduleName, data); - ScalingPlanPooledScheduleResource result = lro.Value; + bool result = await collection.ExistsAsync(scalingPlanScheduleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScalingPlanPooledScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScalingPlanPooledSchedulesList() + public async Task GetIfExists_ScalingPlanPooledSchedulesGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPooledSchedule_List.json - // this example is just showing the usage of "ScalingPlanPooledSchedules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlanPooledSchedule_Get.json + // this example is just showing the usage of "ScalingPlanPooledSchedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -202,20 +196,23 @@ public async Task GetAll_ScalingPlanPooledSchedulesList() // get the collection of this ScalingPlanPooledScheduleResource ScalingPlanPooledScheduleCollection collection = scalingPlan.GetScalingPlanPooledSchedules(); - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (ScalingPlanPooledScheduleResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string scalingPlanScheduleName = "scalingPlanScheduleWeekdays1"; + NullableResponse response = await collection.GetIfExistsAsync(scalingPlanScheduleName); + ScalingPlanPooledScheduleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScalingPlanPooledScheduleData resourceData = item.Data; + ScalingPlanPooledScheduleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPooledScheduleResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPooledScheduleResource.cs index 05357762754dc..33271d157fc8a 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPooledScheduleResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanPooledScheduleResource.cs @@ -96,12 +96,9 @@ public async Task Update_ScalingPlanPooledSchedulesUpdate() ScalingPlanPooledScheduleResource scalingPlanPooledSchedule = client.GetScalingPlanPooledScheduleResource(scalingPlanPooledScheduleResourceId); // invoke the operation - ScalingPlanPooledSchedulePatch patch = new ScalingPlanPooledSchedulePatch() + ScalingPlanPooledSchedulePatch patch = new ScalingPlanPooledSchedulePatch { - DaysOfWeek = -{ -DesktopVirtualizationDayOfWeek.Monday,DesktopVirtualizationDayOfWeek.Tuesday,DesktopVirtualizationDayOfWeek.Wednesday,DesktopVirtualizationDayOfWeek.Thursday,DesktopVirtualizationDayOfWeek.Friday -}, + DaysOfWeek = { DesktopVirtualizationDayOfWeek.Monday, DesktopVirtualizationDayOfWeek.Tuesday, DesktopVirtualizationDayOfWeek.Wednesday, DesktopVirtualizationDayOfWeek.Thursday, DesktopVirtualizationDayOfWeek.Friday }, RampUpLoadBalancingAlgorithm = SessionHostLoadBalancingAlgorithm.DepthFirst, RampUpCapacityThresholdPct = 80, PeakStartTime = new ScalingActionTime(8, 0), diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanResource.cs index ce4b073773c7b..92fa800f4d5eb 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_ScalingPlanResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DesktopVirtualization.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DesktopVirtualization.Samples @@ -103,39 +102,5 @@ public async Task Update_ScalingPlansUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetScalingPlans_ScalingPlansListBySubscription() - { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_ListBySubscription.json - // this example is just showing the usage of "ScalingPlans_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (ScalingPlanResource item in subscriptionResource.GetScalingPlansAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScalingPlanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SessionHostCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SessionHostCollection.cs index af3bd3a235902..b2d6cb8397bd5 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SessionHostCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SessionHostCollection.cs @@ -51,10 +51,10 @@ public async Task Get_SessionHostGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SessionHostGet() + public async Task GetAll_SessionHostList() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/SessionHost_Get.json - // this example is just showing the usage of "SessionHosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/SessionHost_List.json + // this example is just showing the usage of "SessionHosts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,25 @@ public async Task Exists_SessionHostGet() // get the collection of this SessionHostResource SessionHostCollection collection = hostPool.GetSessionHosts(); - // invoke the operation - string sessionHostName = "sessionHost1.microsoft.com"; - bool result = await collection.ExistsAsync(sessionHostName); + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (SessionHostResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SessionHostData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SessionHostGet() + public async Task Exists_SessionHostGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/SessionHost_Get.json // this example is just showing the usage of "SessionHosts_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +113,17 @@ public async Task GetIfExists_SessionHostGet() // invoke the operation string sessionHostName = "sessionHost1.microsoft.com"; - NullableResponse response = await collection.GetIfExistsAsync(sessionHostName); - SessionHostResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sessionHostName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SessionHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SessionHostList() + public async Task GetIfExists_SessionHostGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/SessionHost_List.json - // this example is just showing the usage of "SessionHosts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/SessionHost_Get.json + // this example is just showing the usage of "SessionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,20 +141,23 @@ public async Task GetAll_SessionHostList() // get the collection of this SessionHostResource SessionHostCollection collection = hostPool.GetSessionHosts(); - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (SessionHostResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string sessionHostName = "sessionHost1.microsoft.com"; + NullableResponse response = await collection.GetIfExistsAsync(sessionHostName); + SessionHostResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SessionHostData resourceData = item.Data; + SessionHostData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SessionHostResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SessionHostResource.cs index 29783579e0eea..dc951de52446a 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SessionHostResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SessionHostResource.cs @@ -97,7 +97,7 @@ public async Task Update_SessionHostUpdate() SessionHostResource sessionHost = client.GetSessionHostResource(sessionHostResourceId); // invoke the operation - SessionHostPatch patch = new SessionHostPatch() + SessionHostPatch patch = new SessionHostPatch { AllowNewSession = true, AssignedUser = "user1@microsoft.com", diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..c6ad0227ebe61 --- /dev/null +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.DesktopVirtualization.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualWorkspaces_WorkspaceListBySubscription() + { + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_ListBySubscription.json + // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VirtualWorkspaceResource item in subscriptionResource.GetVirtualWorkspacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetScalingPlans_ScalingPlansListBySubscription() + { + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ScalingPlan_ListBySubscription.json + // this example is just showing the usage of "ScalingPlans_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (ScalingPlanResource item in subscriptionResource.GetScalingPlansAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScalingPlanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualApplicationGroups_ApplicationGroupList() + { + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_ListBySubscription.json + // this example is just showing the usage of "ApplicationGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string filter = "applicationGroupType eq 'RailApplication'"; + await foreach (VirtualApplicationGroupResource item in subscriptionResource.GetVirtualApplicationGroupsAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualApplicationGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHostPools_HostPoolList() + { + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/HostPool_List.json + // this example is just showing the usage of "HostPools_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (HostPoolResource item in subscriptionResource.GetHostPoolsAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HostPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAppAttachPackages_AppAttachPackageListBySubscription() + { + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/AppAttachPackage_ListBySubscription.json + // this example is just showing the usage of "AppAttachPackage_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string filter = "HostPoolName eq 'hostpool1'"; + await foreach (AppAttachPackageResource item in subscriptionResource.GetAppAttachPackagesAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppAttachPackageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_UserSessionCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_UserSessionCollection.cs index 6064717ab3a16..32d5e11c7f8c3 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_UserSessionCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_UserSessionCollection.cs @@ -52,10 +52,10 @@ public async Task Get_UserSessionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_UserSessionGet() + public async Task GetAll_UserSessionList() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/UserSession_Get.json - // this example is just showing the usage of "UserSessions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/UserSession_List.json + // this example is just showing the usage of "UserSessions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,16 +74,25 @@ public async Task Exists_UserSessionGet() // get the collection of this UserSessionResource UserSessionCollection collection = sessionHost.GetUserSessions(); - // invoke the operation - string userSessionId = "1"; - bool result = await collection.ExistsAsync(userSessionId); + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (UserSessionResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + UserSessionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_UserSessionGet() + public async Task Exists_UserSessionGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/UserSession_Get.json // this example is just showing the usage of "UserSessions_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +116,17 @@ public async Task GetIfExists_UserSessionGet() // invoke the operation string userSessionId = "1"; - NullableResponse response = await collection.GetIfExistsAsync(userSessionId); - UserSessionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(userSessionId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - UserSessionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_UserSessionList() + public async Task GetIfExists_UserSessionGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/UserSession_List.json - // this example is just showing the usage of "UserSessions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/UserSession_Get.json + // this example is just showing the usage of "UserSessions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,20 +145,23 @@ public async Task GetAll_UserSessionList() // get the collection of this UserSessionResource UserSessionCollection collection = sessionHost.GetUserSessions(); - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (UserSessionResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string userSessionId = "1"; + NullableResponse response = await collection.GetIfExistsAsync(userSessionId); + UserSessionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - UserSessionData resourceData = item.Data; + UserSessionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_UserSessionResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_UserSessionResource.cs index d0d71c119e0de..0efe289e2d547 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_UserSessionResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_UserSessionResource.cs @@ -128,7 +128,7 @@ public async Task SendMessage_UserSessionSendMessagePost() UserSessionResource userSession = client.GetUserSessionResource(userSessionResourceId); // invoke the operation - UserSessionMessage sendMessage = new UserSessionMessage() + UserSessionMessage sendMessage = new UserSessionMessage { MessageTitle = "title", MessageBody = "body", diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationCollection.cs index 0311ec4938b65..719d7db7a212b 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualApplicationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApplicationGet() + public async Task CreateOrUpdate_ApplicationCreate() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Application_Get.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Application_Create.json + // this example is just showing the usage of "Applications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_ApplicationGet() // invoke the operation string applicationName = "application1"; - VirtualApplicationResource result = await collection.GetAsync(applicationName); + VirtualApplicationData data = new VirtualApplicationData(VirtualApplicationCommandLineSetting.Allow) + { + Description = "des1", + FriendlyName = "friendly", + FilePath = "path", + CommandLineArguments = "arguments", + ShowInPortal = true, + IconPath = "icon", + IconIndex = 1, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); + VirtualApplicationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +63,7 @@ public async Task Get_ApplicationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApplicationGet() + public async Task Get_ApplicationGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Application_Get.json // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +86,21 @@ public async Task Exists_ApplicationGet() // invoke the operation string applicationName = "application1"; - bool result = await collection.ExistsAsync(applicationName); + VirtualApplicationResource result = await collection.GetAsync(applicationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApplicationGet() + public async Task GetAll_ApplicationsList() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Application_Get.json - // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Application_List.json + // this example is just showing the usage of "Applications_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +118,28 @@ public async Task GetIfExists_ApplicationGet() // get the collection of this VirtualApplicationResource VirtualApplicationCollection collection = virtualApplicationGroup.GetVirtualApplications(); - // invoke the operation - string applicationName = "application1"; - NullableResponse response = await collection.GetIfExistsAsync(applicationName); - VirtualApplicationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (VirtualApplicationResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualApplicationData resourceData = result.Data; + VirtualApplicationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApplicationCreate() + public async Task Exists_ApplicationGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Application_Create.json - // this example is just showing the usage of "Applications_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Application_Get.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,32 +159,17 @@ public async Task CreateOrUpdate_ApplicationCreate() // invoke the operation string applicationName = "application1"; - VirtualApplicationData data = new VirtualApplicationData(VirtualApplicationCommandLineSetting.Allow) - { - Description = "des1", - FriendlyName = "friendly", - FilePath = "path", - CommandLineArguments = "arguments", - ShowInPortal = true, - IconPath = "icon", - IconIndex = 1, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationName, data); - VirtualApplicationResource result = lro.Value; + bool result = await collection.ExistsAsync(applicationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApplicationsList() + public async Task GetIfExists_ApplicationGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Application_List.json - // this example is just showing the usage of "Applications_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Application_Get.json + // this example is just showing the usage of "Applications_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,20 +187,23 @@ public async Task GetAll_ApplicationsList() // get the collection of this VirtualApplicationResource VirtualApplicationCollection collection = virtualApplicationGroup.GetVirtualApplications(); - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (VirtualApplicationResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string applicationName = "application1"; + NullableResponse response = await collection.GetIfExistsAsync(applicationName); + VirtualApplicationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualApplicationData resourceData = item.Data; + VirtualApplicationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationGroupCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationGroupCollection.cs index feac197f0f9b4..9cdccdbefedb8 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationGroupCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationGroupCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_VirtualApplicationGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApplicationGroupGet() + public async Task CreateOrUpdate_ApplicationGroupCreate() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_Get.json - // this example is just showing the usage of "ApplicationGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_Create.json + // this example is just showing the usage of "ApplicationGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,19 @@ public async Task Get_ApplicationGroupGet() // invoke the operation string applicationGroupName = "applicationGroup1"; - VirtualApplicationGroupResource result = await collection.GetAsync(applicationGroupName); + VirtualApplicationGroupData data = new VirtualApplicationGroupData(new AzureLocation("centralus"), new ResourceIdentifier("/subscriptions/daefabc0-95b4-48b3-b645-8a753a63c4fa/resourceGroups/resourceGroup1/providers/Microsoft.DesktopVirtualization/hostPools/hostPool1"), VirtualApplicationGroupType.RemoteApp) + { + Description = "des1", + FriendlyName = "friendly", + ShowInFeed = true, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationGroupName, data); + VirtualApplicationGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +64,7 @@ public async Task Get_ApplicationGroupGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApplicationGroupGet() + public async Task Get_ApplicationGroupGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_Get.json // this example is just showing the usage of "ApplicationGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +86,21 @@ public async Task Exists_ApplicationGroupGet() // invoke the operation string applicationGroupName = "applicationGroup1"; - bool result = await collection.ExistsAsync(applicationGroupName); + VirtualApplicationGroupResource result = await collection.GetAsync(applicationGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualApplicationGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApplicationGroupGet() + public async Task GetAll_ApplicationGroupListByResourceGroup() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_Get.json - // this example is just showing the usage of "ApplicationGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_ListByResourceGroup.json + // this example is just showing the usage of "ApplicationGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +117,29 @@ public async Task GetIfExists_ApplicationGroupGet() // get the collection of this VirtualApplicationGroupResource VirtualApplicationGroupCollection collection = resourceGroupResource.GetVirtualApplicationGroups(); - // invoke the operation - string applicationGroupName = "applicationGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(applicationGroupName); - VirtualApplicationGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string filter = "applicationGroupType eq 'RailApplication'"; + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (VirtualApplicationGroupResource item in collection.GetAllAsync(filter: filter, pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualApplicationGroupData resourceData = result.Data; + VirtualApplicationGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApplicationGroupCreate() + public async Task Exists_ApplicationGroupGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_Create.json - // this example is just showing the usage of "ApplicationGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_Get.json + // this example is just showing the usage of "ApplicationGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,33 +158,17 @@ public async Task CreateOrUpdate_ApplicationGroupCreate() // invoke the operation string applicationGroupName = "applicationGroup1"; - VirtualApplicationGroupData data = new VirtualApplicationGroupData(new AzureLocation("centralus"), new ResourceIdentifier("/subscriptions/daefabc0-95b4-48b3-b645-8a753a63c4fa/resourceGroups/resourceGroup1/providers/Microsoft.DesktopVirtualization/hostPools/hostPool1"), VirtualApplicationGroupType.RemoteApp) - { - Description = "des1", - FriendlyName = "friendly", - ShowInFeed = true, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationGroupName, data); - VirtualApplicationGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(applicationGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualApplicationGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApplicationGroupListByResourceGroup() + public async Task GetIfExists_ApplicationGroupGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_ListByResourceGroup.json - // this example is just showing the usage of "ApplicationGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_Get.json + // this example is just showing the usage of "ApplicationGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,21 +185,23 @@ public async Task GetAll_ApplicationGroupListByResourceGroup() // get the collection of this VirtualApplicationGroupResource VirtualApplicationGroupCollection collection = resourceGroupResource.GetVirtualApplicationGroups(); - // invoke the operation and iterate over the result - string filter = "applicationGroupType eq 'RailApplication'"; - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (VirtualApplicationGroupResource item in collection.GetAllAsync(filter: filter, pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string applicationGroupName = "applicationGroup1"; + NullableResponse response = await collection.GetIfExistsAsync(applicationGroupName); + VirtualApplicationGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualApplicationGroupData resourceData = item.Data; + VirtualApplicationGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationGroupResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationGroupResource.cs index 23e7e07158278..a2314ed198a93 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationGroupResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationGroupResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DesktopVirtualization.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DesktopVirtualization.Samples @@ -94,12 +93,12 @@ public async Task Update_ApplicationGroupsUpdate() VirtualApplicationGroupResource virtualApplicationGroup = client.GetVirtualApplicationGroupResource(virtualApplicationGroupResourceId); // invoke the operation - VirtualApplicationGroupPatch patch = new VirtualApplicationGroupPatch() + VirtualApplicationGroupPatch patch = new VirtualApplicationGroupPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, Description = "des1", FriendlyName = "friendly", @@ -114,38 +113,6 @@ public async Task Update_ApplicationGroupsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVirtualApplicationGroups_ApplicationGroupList() - { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/ApplicationGroup_ListBySubscription.json - // this example is just showing the usage of "ApplicationGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string filter = "applicationGroupType eq 'RailApplication'"; - await foreach (VirtualApplicationGroupResource item in subscriptionResource.GetVirtualApplicationGroupsAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualApplicationGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetStartMenuItems_StartMenuItemList() diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationResource.cs index 579dc6dcb5ff2..fcf93c07ee81d 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualApplicationResource.cs @@ -96,7 +96,7 @@ public async Task Update_ApplicationUpdate() VirtualApplicationResource virtualApplication = client.GetVirtualApplicationResource(virtualApplicationResourceId); // invoke the operation - VirtualApplicationPatch patch = new VirtualApplicationPatch() + VirtualApplicationPatch patch = new VirtualApplicationPatch { Description = "des1", FriendlyName = "friendly", diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualDesktopCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualDesktopCollection.cs index c2c95eaeccf35..530d4064a0fb9 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualDesktopCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualDesktopCollection.cs @@ -51,10 +51,10 @@ public async Task Get_DesktopGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DesktopGet() + public async Task GetAll_DesktopList() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Desktop_Get.json - // this example is just showing the usage of "Desktops_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Desktop_List.json + // this example is just showing the usage of "Desktops_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,25 @@ public async Task Exists_DesktopGet() // get the collection of this VirtualDesktopResource VirtualDesktopCollection collection = virtualApplicationGroup.GetVirtualDesktops(); - // invoke the operation - string desktopName = "SessionDesktop"; - bool result = await collection.ExistsAsync(desktopName); + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (VirtualDesktopResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualDesktopData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DesktopGet() + public async Task Exists_DesktopGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Desktop_Get.json // this example is just showing the usage of "Desktops_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +113,17 @@ public async Task GetIfExists_DesktopGet() // invoke the operation string desktopName = "SessionDesktop"; - NullableResponse response = await collection.GetIfExistsAsync(desktopName); - VirtualDesktopResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(desktopName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualDesktopData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DesktopList() + public async Task GetIfExists_DesktopGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Desktop_List.json - // this example is just showing the usage of "Desktops_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Desktop_Get.json + // this example is just showing the usage of "Desktops_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,20 +141,23 @@ public async Task GetAll_DesktopList() // get the collection of this VirtualDesktopResource VirtualDesktopCollection collection = virtualApplicationGroup.GetVirtualDesktops(); - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (VirtualDesktopResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string desktopName = "SessionDesktop"; + NullableResponse response = await collection.GetIfExistsAsync(desktopName); + VirtualDesktopResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualDesktopData resourceData = item.Data; + VirtualDesktopData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualDesktopResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualDesktopResource.cs index fd8c0336d1c26..872fc689d2600 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualDesktopResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualDesktopResource.cs @@ -69,7 +69,7 @@ public async Task Update_DesktopUpdate() VirtualDesktopResource virtualDesktop = client.GetVirtualDesktopResource(virtualDesktopResourceId); // invoke the operation - VirtualDesktopPatch patch = new VirtualDesktopPatch() + VirtualDesktopPatch patch = new VirtualDesktopPatch { Description = "des1", FriendlyName = "friendly", diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualWorkspaceCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualWorkspaceCollection.cs index 25e2a2dd11f1e..c20e2eb44495d 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualWorkspaceCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualWorkspaceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualWorkspaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkspaceGet() + public async Task CreateOrUpdate_WorkspaceCreate() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_Get.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_Create.json + // this example is just showing the usage of "Workspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,18 @@ public async Task Get_WorkspaceGet() // invoke the operation string workspaceName = "workspace1"; - VirtualWorkspaceResource result = await collection.GetAsync(workspaceName); + VirtualWorkspaceData data = new VirtualWorkspaceData(new AzureLocation("centralus")) + { + Description = "des1", + FriendlyName = "friendly", + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); + VirtualWorkspaceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +62,7 @@ public async Task Get_WorkspaceGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkspaceGet() + public async Task Get_WorkspaceGet() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_Get.json // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +84,21 @@ public async Task Exists_WorkspaceGet() // invoke the operation string workspaceName = "workspace1"; - bool result = await collection.ExistsAsync(workspaceName); + VirtualWorkspaceResource result = await collection.GetAsync(workspaceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkspaceGet() + public async Task GetAll_WorkspaceListByResourceGroup() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_Get.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_ListByResourceGroup.json + // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +115,28 @@ public async Task GetIfExists_WorkspaceGet() // get the collection of this VirtualWorkspaceResource VirtualWorkspaceCollection collection = resourceGroupResource.GetVirtualWorkspaces(); - // invoke the operation - string workspaceName = "workspace1"; - NullableResponse response = await collection.GetIfExistsAsync(workspaceName); - VirtualWorkspaceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + int? pageSize = 10; + bool? isDescending = true; + int? initialSkip = 0; + await foreach (VirtualWorkspaceResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualWorkspaceData resourceData = result.Data; + VirtualWorkspaceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkspaceCreate() + public async Task Exists_WorkspaceGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_Create.json - // this example is just showing the usage of "Workspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_Get.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,32 +155,17 @@ public async Task CreateOrUpdate_WorkspaceCreate() // invoke the operation string workspaceName = "workspace1"; - VirtualWorkspaceData data = new VirtualWorkspaceData(new AzureLocation("centralus")) - { - Description = "des1", - FriendlyName = "friendly", - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); - VirtualWorkspaceResource result = lro.Value; + bool result = await collection.ExistsAsync(workspaceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkspaceListByResourceGroup() + public async Task GetIfExists_WorkspaceGet() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_ListByResourceGroup.json - // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_Get.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,20 +182,23 @@ public async Task GetAll_WorkspaceListByResourceGroup() // get the collection of this VirtualWorkspaceResource VirtualWorkspaceCollection collection = resourceGroupResource.GetVirtualWorkspaces(); - // invoke the operation and iterate over the result - int? pageSize = 10; - bool? isDescending = true; - int? initialSkip = 0; - await foreach (VirtualWorkspaceResource item in collection.GetAllAsync(pageSize: pageSize, isDescending: isDescending, initialSkip: initialSkip)) + // invoke the operation + string workspaceName = "workspace1"; + NullableResponse response = await collection.GetIfExistsAsync(workspaceName); + VirtualWorkspaceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualWorkspaceData resourceData = item.Data; + VirtualWorkspaceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualWorkspaceResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualWorkspaceResource.cs index 0ef5c7fc5234f..ae383e2f68d55 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualWorkspaceResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_VirtualWorkspaceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DesktopVirtualization.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DesktopVirtualization.Samples @@ -94,12 +93,12 @@ public async Task Update_WorkspaceUpdate() VirtualWorkspaceResource virtualWorkspace = client.GetVirtualWorkspaceResource(virtualWorkspaceResourceId); // invoke the operation - VirtualWorkspacePatch patch = new VirtualWorkspacePatch() + VirtualWorkspacePatch patch = new VirtualWorkspacePatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, Description = "des1", FriendlyName = "friendly", @@ -113,37 +112,6 @@ public async Task Update_WorkspaceUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVirtualWorkspaces_WorkspaceListBySubscription() - { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/Workspace_ListBySubscription.json - // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "daefabc0-95b4-48b3-b645-8a753a63c4fa"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VirtualWorkspaceResource item in subscriptionResource.GetVirtualWorkspacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetPrivateLinkResources_PrivateLinkResourcesListByWorkspace() diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_WorkspacePrivateEndpointConnectionCollection.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_WorkspacePrivateEndpointConnectionCollection.cs index 644d643709497..96f29b953ae2c 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_WorkspacePrivateEndpointConnectionCollection.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_WorkspacePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_WorkspacePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionListByWorkspace() + public async Task CreateOrUpdate_PrivateEndpointConnectionUpdateByWorkspace() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_ListByWorkspace.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_UpdateByWorkspace.json + // this example is just showing the usage of "PrivateEndpointConnections_UpdateByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_PrivateEndpointConnectionListByWorkspace() // get the collection of this WorkspacePrivateEndpointConnectionResource WorkspacePrivateEndpointConnectionCollection collection = virtualWorkspace.GetWorkspacePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (WorkspacePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "workspace1.377103f1-5179-4bdf-8556-4cdd3207cc5b"; + DesktopVirtualizationPrivateEndpointConnection connection = new DesktopVirtualizationPrivateEndpointConnection { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new DesktopVirtualizationPrivateLinkServiceConnectionState + { + Status = DesktopVirtualizationPrivateEndpointServiceConnectionStatus.Approved, + Description = "Approved by admin@consoto.com", + ActionsRequired = "None", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, connection); + WorkspacePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_PrivateEndpointConnectionGetByWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionGetByWorkspace() + public async Task GetAll_PrivateEndpointConnectionListByWorkspace() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_GetByWorkspace.json - // this example is just showing the usage of "PrivateEndpointConnections_GetByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_ListByWorkspace.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_PrivateEndpointConnectionGetByWorkspace() // get the collection of this WorkspacePrivateEndpointConnectionResource WorkspacePrivateEndpointConnectionCollection collection = virtualWorkspace.GetWorkspacePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "workspace1.377103f1-5179-4bdf-8556-4cdd3207cc5b"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (WorkspacePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionGetByWorkspace() + public async Task Exists_PrivateEndpointConnectionGetByWorkspace() { // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_GetByWorkspace.json // this example is just showing the usage of "PrivateEndpointConnections_GetByWorkspace" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_PrivateEndpointConnectionGetByWorkspace() // invoke the operation string privateEndpointConnectionName = "workspace1.377103f1-5179-4bdf-8556-4cdd3207cc5b"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - WorkspacePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionUpdateByWorkspace() + public async Task GetIfExists_PrivateEndpointConnectionGetByWorkspace() { - // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_UpdateByWorkspace.json - // this example is just showing the usage of "PrivateEndpointConnections_UpdateByWorkspace" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/desktopvirtualization/resource-manager/Microsoft.DesktopVirtualization/stable/2024-04-03/examples/PrivateEndpointConnection_GetByWorkspace.json + // this example is just showing the usage of "PrivateEndpointConnections_GetByWorkspace" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionUpdateByWorkspace() // invoke the operation string privateEndpointConnectionName = "workspace1.377103f1-5179-4bdf-8556-4cdd3207cc5b"; - DesktopVirtualizationPrivateEndpointConnection connection = new DesktopVirtualizationPrivateEndpointConnection() - { - ConnectionState = new DesktopVirtualizationPrivateLinkServiceConnectionState() - { - Status = DesktopVirtualizationPrivateEndpointServiceConnectionStatus.Approved, - Description = "Approved by admin@consoto.com", - ActionsRequired = "None", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, connection); - WorkspacePrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + WorkspacePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DesktopVirtualizationPrivateEndpointConnectionDataData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_WorkspacePrivateEndpointConnectionResource.cs b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_WorkspacePrivateEndpointConnectionResource.cs index a211bce99f204..909f4e397b466 100644 --- a/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_WorkspacePrivateEndpointConnectionResource.cs +++ b/sdk/desktopvirtualization/Azure.ResourceManager.DesktopVirtualization/samples/Generated/Samples/Sample_WorkspacePrivateEndpointConnectionResource.cs @@ -96,9 +96,9 @@ public async Task Update_PrivateEndpointConnectionUpdateByWorkspace() WorkspacePrivateEndpointConnectionResource workspacePrivateEndpointConnection = client.GetWorkspacePrivateEndpointConnectionResource(workspacePrivateEndpointConnectionResourceId); // invoke the operation - DesktopVirtualizationPrivateEndpointConnection connection = new DesktopVirtualizationPrivateEndpointConnection() + DesktopVirtualizationPrivateEndpointConnection connection = new DesktopVirtualizationPrivateEndpointConnection { - ConnectionState = new DesktopVirtualizationPrivateLinkServiceConnectionState() + ConnectionState = new DesktopVirtualizationPrivateLinkServiceConnectionState { Status = DesktopVirtualizationPrivateEndpointServiceConnectionStatus.Approved, Description = "Approved by admin@consoto.com", diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AllowedEnvironmentTypeCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AllowedEnvironmentTypeCollection.cs index fcfd26fffa3e5..cccee5313e5f0 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AllowedEnvironmentTypeCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AllowedEnvironmentTypeCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AllowedEnvironmentTypeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProjectAllowedEnvironmentTypesList() + public async Task Get_ProjectAllowedEnvironmentTypesGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectAllowedEnvironmentTypes_List.json - // this example is just showing the usage of "ProjectAllowedEnvironmentTypes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectAllowedEnvironmentTypes_Get.json + // this example is just showing the usage of "ProjectAllowedEnvironmentTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ProjectAllowedEnvironmentTypesList() // get the collection of this AllowedEnvironmentTypeResource AllowedEnvironmentTypeCollection collection = devCenterProject.GetAllowedEnvironmentTypes(); - // invoke the operation and iterate over the result - await foreach (AllowedEnvironmentTypeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AllowedEnvironmentTypeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string environmentTypeName = "DevTest"; + AllowedEnvironmentTypeResource result = await collection.GetAsync(environmentTypeName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AllowedEnvironmentTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProjectAllowedEnvironmentTypesGet() + public async Task GetAll_ProjectAllowedEnvironmentTypesList() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectAllowedEnvironmentTypes_Get.json - // this example is just showing the usage of "ProjectAllowedEnvironmentTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectAllowedEnvironmentTypes_List.json + // this example is just showing the usage of "ProjectAllowedEnvironmentTypes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_ProjectAllowedEnvironmentTypesGet() // get the collection of this AllowedEnvironmentTypeResource AllowedEnvironmentTypeCollection collection = devCenterProject.GetAllowedEnvironmentTypes(); - // invoke the operation - string environmentTypeName = "DevTest"; - AllowedEnvironmentTypeResource result = await collection.GetAsync(environmentTypeName); + // invoke the operation and iterate over the result + await foreach (AllowedEnvironmentTypeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AllowedEnvironmentTypeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AllowedEnvironmentTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AttachedNetworkConnectionCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AttachedNetworkConnectionCollection.cs index 4e71e0ce37a5a..45be226839c53 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AttachedNetworkConnectionCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AttachedNetworkConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AttachedNetworkConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AttachedNetworksListByDevCenter() + public async Task CreateOrUpdate_AttachedNetworksCreate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_ListByDevCenter.json - // this example is just showing the usage of "AttachedNetworks_ListByDevCenter" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_Create.json + // this example is just showing the usage of "AttachedNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_AttachedNetworksListByDevCenter() // get the collection of this AttachedNetworkConnectionResource AttachedNetworkConnectionCollection collection = devCenter.GetAttachedNetworkConnections(); - // invoke the operation and iterate over the result - await foreach (AttachedNetworkConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string attachedNetworkConnectionName = "network-uswest3"; + AttachedNetworkConnectionData data = new AttachedNetworkConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttachedNetworkConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + NetworkConnectionId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/NetworkConnections/network-uswest3"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attachedNetworkConnectionName, data); + AttachedNetworkConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttachedNetworkConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_AttachedNetworksGetByDevCenter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AttachedNetworksGetByDevCenter() + public async Task GetAll_AttachedNetworksListByDevCenter() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_GetByDevCenter.json - // this example is just showing the usage of "AttachedNetworks_GetByDevCenter" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_ListByDevCenter.json + // this example is just showing the usage of "AttachedNetworks_ListByDevCenter" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_AttachedNetworksGetByDevCenter() // get the collection of this AttachedNetworkConnectionResource AttachedNetworkConnectionCollection collection = devCenter.GetAttachedNetworkConnections(); - // invoke the operation - string attachedNetworkConnectionName = "network-uswest3"; - bool result = await collection.ExistsAsync(attachedNetworkConnectionName); + // invoke the operation and iterate over the result + await foreach (AttachedNetworkConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttachedNetworkConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AttachedNetworksGetByDevCenter() + public async Task Exists_AttachedNetworksGetByDevCenter() { // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_GetByDevCenter.json // this example is just showing the usage of "AttachedNetworks_GetByDevCenter" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_AttachedNetworksGetByDevCenter() // invoke the operation string attachedNetworkConnectionName = "network-uswest3"; - NullableResponse response = await collection.GetIfExistsAsync(attachedNetworkConnectionName); - AttachedNetworkConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(attachedNetworkConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttachedNetworkConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AttachedNetworksCreate() + public async Task GetIfExists_AttachedNetworksGetByDevCenter() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_Create.json - // this example is just showing the usage of "AttachedNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_GetByDevCenter.json + // this example is just showing the usage of "AttachedNetworks_GetByDevCenter" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_AttachedNetworksCreate() // invoke the operation string attachedNetworkConnectionName = "network-uswest3"; - AttachedNetworkConnectionData data = new AttachedNetworkConnectionData() - { - NetworkConnectionId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/NetworkConnections/network-uswest3"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attachedNetworkConnectionName, data); - AttachedNetworkConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(attachedNetworkConnectionName); + AttachedNetworkConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttachedNetworkConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttachedNetworkConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AttachedNetworkConnectionResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AttachedNetworkConnectionResource.cs index e9c0b704c2fdd..50be60c9e6f97 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AttachedNetworkConnectionResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_AttachedNetworkConnectionResource.cs @@ -48,10 +48,10 @@ public async Task Get_AttachedNetworksGetByDevCenter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AttachedNetworksCreate() + public async Task Delete_AttachedNetworksDelete() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_Create.json - // this example is just showing the usage of "AttachedNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_Delete.json + // this example is just showing the usage of "AttachedNetworks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_AttachedNetworksCreate() AttachedNetworkConnectionResource attachedNetworkConnection = client.GetAttachedNetworkConnectionResource(attachedNetworkConnectionResourceId); // invoke the operation - AttachedNetworkConnectionData data = new AttachedNetworkConnectionData() - { - NetworkConnectionId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/NetworkConnections/network-uswest3"), - }; - ArmOperation lro = await attachedNetworkConnection.UpdateAsync(WaitUntil.Completed, data); - AttachedNetworkConnectionResource result = lro.Value; + await attachedNetworkConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttachedNetworkConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AttachedNetworksDelete() + public async Task Update_AttachedNetworksCreate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_Delete.json - // this example is just showing the usage of "AttachedNetworks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_Create.json + // this example is just showing the usage of "AttachedNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,18 @@ public async Task Delete_AttachedNetworksDelete() AttachedNetworkConnectionResource attachedNetworkConnection = client.GetAttachedNetworkConnectionResource(attachedNetworkConnectionResourceId); // invoke the operation - await attachedNetworkConnection.DeleteAsync(WaitUntil.Completed); + AttachedNetworkConnectionData data = new AttachedNetworkConnectionData + { + NetworkConnectionId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/NetworkConnections/network-uswest3"), + }; + ArmOperation lro = await attachedNetworkConnection.UpdateAsync(WaitUntil.Completed, data); + AttachedNetworkConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttachedNetworkConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevBoxDefinitionCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevBoxDefinitionCollection.cs index 875482098d3c6..75df8e2b12bb4 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevBoxDefinitionCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevBoxDefinitionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevBoxDefinitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DevBoxDefinitionsListByDevCenter() + public async Task CreateOrUpdate_DevBoxDefinitionsCreate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_ListByDevCenter.json - // this example is just showing the usage of "DevBoxDefinitions_ListByDevCenter" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_Create.json + // this example is just showing the usage of "DevBoxDefinitions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_DevBoxDefinitionsListByDevCenter() // get the collection of this DevBoxDefinitionResource DevBoxDefinitionCollection collection = devCenter.GetDevBoxDefinitions(); - // invoke the operation and iterate over the result - await foreach (DevBoxDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string devBoxDefinitionName = "WebDevBox"; + DevBoxDefinitionData data = new DevBoxDefinitionData(new AzureLocation("centralus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevBoxDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ImageReference = new DevCenterImageReference + { + Id = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/Example/providers/Microsoft.DevCenter/devcenters/Contoso/galleries/contosogallery/images/exampleImage/version/1.0.0"), + }, + Sku = new DevCenterSku("Preview"), + HibernateSupport = DevCenterHibernateSupport.IsEnabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, devBoxDefinitionName, data); + DevBoxDefinitionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevBoxDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_DevBoxDefinitionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DevBoxDefinitionsGet() + public async Task GetAll_DevBoxDefinitionsListByDevCenter() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_Get.json - // this example is just showing the usage of "DevBoxDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_ListByDevCenter.json + // this example is just showing the usage of "DevBoxDefinitions_ListByDevCenter" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_DevBoxDefinitionsGet() // get the collection of this DevBoxDefinitionResource DevBoxDefinitionCollection collection = devCenter.GetDevBoxDefinitions(); - // invoke the operation - string devBoxDefinitionName = "WebDevBox"; - bool result = await collection.ExistsAsync(devBoxDefinitionName); + // invoke the operation and iterate over the result + await foreach (DevBoxDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevBoxDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DevBoxDefinitionsGet() + public async Task Exists_DevBoxDefinitionsGet() { // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_Get.json // this example is just showing the usage of "DevBoxDefinitions_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_DevBoxDefinitionsGet() // invoke the operation string devBoxDefinitionName = "WebDevBox"; - NullableResponse response = await collection.GetIfExistsAsync(devBoxDefinitionName); - DevBoxDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(devBoxDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevBoxDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DevBoxDefinitionsCreate() + public async Task GetIfExists_DevBoxDefinitionsGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_Create.json - // this example is just showing the usage of "DevBoxDefinitions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_Get.json + // this example is just showing the usage of "DevBoxDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_DevBoxDefinitionsCreate() // invoke the operation string devBoxDefinitionName = "WebDevBox"; - DevBoxDefinitionData data = new DevBoxDefinitionData(new AzureLocation("centralus")) - { - ImageReference = new DevCenterImageReference() - { - Id = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/Example/providers/Microsoft.DevCenter/devcenters/Contoso/galleries/contosogallery/images/exampleImage/version/1.0.0"), - }, - Sku = new DevCenterSku("Preview"), - HibernateSupport = DevCenterHibernateSupport.IsEnabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, devBoxDefinitionName, data); - DevBoxDefinitionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(devBoxDefinitionName); + DevBoxDefinitionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevBoxDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevBoxDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevBoxDefinitionResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevBoxDefinitionResource.cs index de3c694e0552b..ebddfdc345692 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevBoxDefinitionResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevBoxDefinitionResource.cs @@ -49,10 +49,10 @@ public async Task Get_DevBoxDefinitionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DevBoxDefinitionsPatch() + public async Task Delete_DevBoxDefinitionsDelete() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_Patch.json - // this example is just showing the usage of "DevBoxDefinitions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_Delete.json + // this example is just showing the usage of "DevBoxDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_DevBoxDefinitionsPatch() DevBoxDefinitionResource devBoxDefinition = client.GetDevBoxDefinitionResource(devBoxDefinitionResourceId); // invoke the operation - DevBoxDefinitionPatch patch = new DevBoxDefinitionPatch() - { - ImageReference = new DevCenterImageReference() - { - Id = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/Example/providers/Microsoft.DevCenter/devcenters/Contoso/galleries/contosogallery/images/exampleImage/version/2.0.0"), - }, - }; - ArmOperation lro = await devBoxDefinition.UpdateAsync(WaitUntil.Completed, patch); - DevBoxDefinitionResource result = lro.Value; + await devBoxDefinition.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevBoxDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DevBoxDefinitionsDelete() + public async Task Update_DevBoxDefinitionsPatch() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_Delete.json - // this example is just showing the usage of "DevBoxDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_Patch.json + // this example is just showing the usage of "DevBoxDefinitions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DevBoxDefinitionsDelete() DevBoxDefinitionResource devBoxDefinition = client.GetDevBoxDefinitionResource(devBoxDefinitionResourceId); // invoke the operation - await devBoxDefinition.DeleteAsync(WaitUntil.Completed); + DevBoxDefinitionPatch patch = new DevBoxDefinitionPatch + { + ImageReference = new DevCenterImageReference + { + Id = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/Example/providers/Microsoft.DevCenter/devcenters/Contoso/galleries/contosogallery/images/exampleImage/version/2.0.0"), + }, + }; + ArmOperation lro = await devBoxDefinition.UpdateAsync(WaitUntil.Completed, patch); + DevBoxDefinitionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevBoxDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCatalogCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCatalogCollection.cs index ef977b36fae35..c69ac39b2a7ae 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCatalogCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCatalogCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevCenterCatalogCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CatalogsListByDevCenter() + public async Task CreateOrUpdate_CatalogsCreateOrUpdateAdo() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_List.json - // this example is just showing the usage of "Catalogs_ListByDevCenter" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_CreateAdo.json + // this example is just showing the usage of "Catalogs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,34 @@ public async Task GetAll_CatalogsListByDevCenter() // get the collection of this DevCenterCatalogResource DevCenterCatalogCollection collection = devCenter.GetDevCenterCatalogs(); - // invoke the operation and iterate over the result - await foreach (DevCenterCatalogResource item in collection.GetAllAsync()) + // invoke the operation + string catalogName = "CentralCatalog"; + DevCenterCatalogData data = new DevCenterCatalogData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterCatalogData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AdoGit = new DevCenterGitCatalog + { + Uri = new Uri("https://contoso@dev.azure.com/contoso/contosoOrg/_git/centralrepo-fakecontoso"), + Branch = "main", + SecretIdentifier = "https://contosokv.vault.azure.net/secrets/CentralRepoPat", + Path = "/templates", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, catalogName, data); + DevCenterCatalogResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterCatalogData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CatalogsGet() + public async Task CreateOrUpdate_CatalogsCreateOrUpdateGitHub() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_Get.json - // this example is just showing the usage of "Catalogs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_CreateGitHub.json + // this example is just showing the usage of "Catalogs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +86,18 @@ public async Task Get_CatalogsGet() // invoke the operation string catalogName = "CentralCatalog"; - DevCenterCatalogResource result = await collection.GetAsync(catalogName); + DevCenterCatalogData data = new DevCenterCatalogData + { + GitHub = new DevCenterGitCatalog + { + Uri = new Uri("https://github.com/Contoso/centralrepo-fake.git"), + Branch = "main", + SecretIdentifier = "https://contosokv.vault.azure.net/secrets/CentralRepoPat", + Path = "/templates", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, catalogName, data); + DevCenterCatalogResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +108,7 @@ public async Task Get_CatalogsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CatalogsGet() + public async Task Get_CatalogsGet() { // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_Get.json // this example is just showing the usage of "Catalogs_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +131,21 @@ public async Task Exists_CatalogsGet() // invoke the operation string catalogName = "CentralCatalog"; - bool result = await collection.ExistsAsync(catalogName); + DevCenterCatalogResource result = await collection.GetAsync(catalogName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterCatalogData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CatalogsGet() + public async Task GetAll_CatalogsListByDevCenter() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_Get.json - // this example is just showing the usage of "Catalogs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_List.json + // this example is just showing the usage of "Catalogs_ListByDevCenter" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +163,25 @@ public async Task GetIfExists_CatalogsGet() // get the collection of this DevCenterCatalogResource DevCenterCatalogCollection collection = devCenter.GetDevCenterCatalogs(); - // invoke the operation - string catalogName = "CentralCatalog"; - NullableResponse response = await collection.GetIfExistsAsync(catalogName); - DevCenterCatalogResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DevCenterCatalogResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DevCenterCatalogData resourceData = result.Data; + DevCenterCatalogData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CatalogsCreateOrUpdateAdo() + public async Task Exists_CatalogsGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_CreateAdo.json - // this example is just showing the usage of "Catalogs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_Get.json + // this example is just showing the usage of "Catalogs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,32 +201,17 @@ public async Task CreateOrUpdate_CatalogsCreateOrUpdateAdo() // invoke the operation string catalogName = "CentralCatalog"; - DevCenterCatalogData data = new DevCenterCatalogData() - { - AdoGit = new DevCenterGitCatalog() - { - Uri = new Uri("https://contoso@dev.azure.com/contoso/contosoOrg/_git/centralrepo-fakecontoso"), - Branch = "main", - SecretIdentifier = "https://contosokv.vault.azure.net/secrets/CentralRepoPat", - Path = "/templates", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, catalogName, data); - DevCenterCatalogResource result = lro.Value; + bool result = await collection.ExistsAsync(catalogName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterCatalogData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CatalogsCreateOrUpdateGitHub() + public async Task GetIfExists_CatalogsGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_CreateGitHub.json - // this example is just showing the usage of "Catalogs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_Get.json + // this example is just showing the usage of "Catalogs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -228,24 +231,21 @@ public async Task CreateOrUpdate_CatalogsCreateOrUpdateGitHub() // invoke the operation string catalogName = "CentralCatalog"; - DevCenterCatalogData data = new DevCenterCatalogData() - { - GitHub = new DevCenterGitCatalog() - { - Uri = new Uri("https://github.com/Contoso/centralrepo-fake.git"), - Branch = "main", - SecretIdentifier = "https://contosokv.vault.azure.net/secrets/CentralRepoPat", - Path = "/templates", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, catalogName, data); - DevCenterCatalogResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(catalogName); + DevCenterCatalogResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterCatalogData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterCatalogData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCatalogResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCatalogResource.cs index 90abbded511e2..0909d24d98aec 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCatalogResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCatalogResource.cs @@ -49,10 +49,10 @@ public async Task Get_CatalogsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CatalogsUpdate() + public async Task Delete_CatalogsDelete() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_Patch.json - // this example is just showing the usage of "Catalogs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_Delete.json + // this example is just showing the usage of "Catalogs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_CatalogsUpdate() DevCenterCatalogResource devCenterCatalog = client.GetDevCenterCatalogResource(devCenterCatalogResourceId); // invoke the operation - DevCenterCatalogPatch patch = new DevCenterCatalogPatch() - { - GitHub = new DevCenterGitCatalog() - { - Path = "/environments", - }, - }; - ArmOperation lro = await devCenterCatalog.UpdateAsync(WaitUntil.Completed, patch); - DevCenterCatalogResource result = lro.Value; + await devCenterCatalog.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterCatalogData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CatalogsDelete() + public async Task Update_CatalogsUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_Delete.json - // this example is just showing the usage of "Catalogs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Catalogs_Patch.json + // this example is just showing the usage of "Catalogs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_CatalogsDelete() DevCenterCatalogResource devCenterCatalog = client.GetDevCenterCatalogResource(devCenterCatalogResourceId); // invoke the operation - await devCenterCatalog.DeleteAsync(WaitUntil.Completed); + DevCenterCatalogPatch patch = new DevCenterCatalogPatch + { + GitHub = new DevCenterGitCatalog + { + Path = "/environments", + }, + }; + ArmOperation lro = await devCenterCatalog.UpdateAsync(WaitUntil.Completed, patch); + DevCenterCatalogResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterCatalogData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCollection.cs index 12db7e7edaa68..2740077602912 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DevCenterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DevCentersListByResourceGroup() + public async Task CreateOrUpdate_DevCentersCreate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_ListByResourceGroup.json - // this example is just showing the usage of "DevCenters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Create.json + // this example is just showing the usage of "DevCenters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,31 @@ public async Task GetAll_DevCentersListByResourceGroup() // get the collection of this DevCenterResource DevCenterCollection collection = resourceGroupResource.GetDevCenters(); - // invoke the operation and iterate over the result - await foreach (DevCenterResource item in collection.GetAllAsync()) + // invoke the operation + string devCenterName = "Contoso"; + DevCenterData data = new DevCenterData(new AzureLocation("centralus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["CostCode"] = "12345" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, devCenterName, data); + DevCenterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DevCentersGet() + public async Task CreateOrUpdate_DevCentersCreateWithUserIdentity() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Get.json - // this example is just showing the usage of "DevCenters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_CreateWithUserIdentity.json + // this example is just showing the usage of "DevCenters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +82,22 @@ public async Task Get_DevCentersGet() // invoke the operation string devCenterName = "Contoso"; - DevCenterResource result = await collection.GetAsync(devCenterName); + DevCenterData data = new DevCenterData(new AzureLocation("centralus")) + { + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1")] = new UserAssignedIdentity() +}, + }, + Tags = +{ +["CostCode"] = "12345" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, devCenterName, data); + DevCenterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +108,7 @@ public async Task Get_DevCentersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DevCentersGet() + public async Task Get_DevCentersGet() { // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Get.json // this example is just showing the usage of "DevCenters_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,17 +130,21 @@ public async Task Exists_DevCentersGet() // invoke the operation string devCenterName = "Contoso"; - bool result = await collection.ExistsAsync(devCenterName); + DevCenterResource result = await collection.GetAsync(devCenterName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DevCentersGet() + public async Task GetAll_DevCentersListByResourceGroup() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Get.json - // this example is just showing the usage of "DevCenters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_ListByResourceGroup.json + // this example is just showing the usage of "DevCenters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,31 +161,25 @@ public async Task GetIfExists_DevCentersGet() // get the collection of this DevCenterResource DevCenterCollection collection = resourceGroupResource.GetDevCenters(); - // invoke the operation - string devCenterName = "Contoso"; - NullableResponse response = await collection.GetIfExistsAsync(devCenterName); - DevCenterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DevCenterResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DevCenterData resourceData = result.Data; + DevCenterData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DevCentersCreate() + public async Task Exists_DevCentersGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Create.json - // this example is just showing the usage of "DevCenters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Get.json + // this example is just showing the usage of "DevCenters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,29 +198,17 @@ public async Task CreateOrUpdate_DevCentersCreate() // invoke the operation string devCenterName = "Contoso"; - DevCenterData data = new DevCenterData(new AzureLocation("centralus")) - { - Tags = -{ -["CostCode"] = "12345", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, devCenterName, data); - DevCenterResource result = lro.Value; + bool result = await collection.ExistsAsync(devCenterName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DevCentersCreateWithUserIdentity() + public async Task GetIfExists_DevCentersGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_CreateWithUserIdentity.json - // this example is just showing the usage of "DevCenters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Get.json + // this example is just showing the usage of "DevCenters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -220,28 +227,21 @@ public async Task CreateOrUpdate_DevCentersCreateWithUserIdentity() // invoke the operation string devCenterName = "Contoso"; - DevCenterData data = new DevCenterData(new AzureLocation("centralus")) - { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1")] = new UserAssignedIdentity(), -}, - }, - Tags = -{ -["CostCode"] = "12345", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, devCenterName, data); - DevCenterResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(devCenterName); + DevCenterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterEnvironmentTypeCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterEnvironmentTypeCollection.cs index 711bb9913fe7b..be71e39061ede 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterEnvironmentTypeCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterEnvironmentTypeCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DevCenterEnvironmentTypeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EnvironmentTypesListByDevCenter() + public async Task CreateOrUpdate_EnvironmentTypesCreateOrUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_List.json - // this example is just showing the usage of "EnvironmentTypes_ListByDevCenter" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_Put.json + // this example is just showing the usage of "EnvironmentTypes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,23 @@ public async Task GetAll_EnvironmentTypesListByDevCenter() // get the collection of this DevCenterEnvironmentTypeResource DevCenterEnvironmentTypeCollection collection = devCenter.GetDevCenterEnvironmentTypes(); - // invoke the operation and iterate over the result - await foreach (DevCenterEnvironmentTypeResource item in collection.GetAllAsync()) + // invoke the operation + string environmentTypeName = "DevTest"; + DevCenterEnvironmentTypeData data = new DevCenterEnvironmentTypeData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterEnvironmentTypeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["Owner"] = "superuser" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, environmentTypeName, data); + DevCenterEnvironmentTypeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterEnvironmentTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +93,10 @@ public async Task Get_EnvironmentTypesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EnvironmentTypesGet() + public async Task GetAll_EnvironmentTypesListByDevCenter() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_Get.json - // this example is just showing the usage of "EnvironmentTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_List.json + // this example is just showing the usage of "EnvironmentTypes_ListByDevCenter" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +114,22 @@ public async Task Exists_EnvironmentTypesGet() // get the collection of this DevCenterEnvironmentTypeResource DevCenterEnvironmentTypeCollection collection = devCenter.GetDevCenterEnvironmentTypes(); - // invoke the operation - string environmentTypeName = "DevTest"; - bool result = await collection.ExistsAsync(environmentTypeName); + // invoke the operation and iterate over the result + await foreach (DevCenterEnvironmentTypeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterEnvironmentTypeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EnvironmentTypesGet() + public async Task Exists_EnvironmentTypesGet() { // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_Get.json // this example is just showing the usage of "EnvironmentTypes_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +152,17 @@ public async Task GetIfExists_EnvironmentTypesGet() // invoke the operation string environmentTypeName = "DevTest"; - NullableResponse response = await collection.GetIfExistsAsync(environmentTypeName); - DevCenterEnvironmentTypeResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(environmentTypeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterEnvironmentTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EnvironmentTypesCreateOrUpdate() + public async Task GetIfExists_EnvironmentTypesGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_Put.json - // this example is just showing the usage of "EnvironmentTypes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_Get.json + // this example is just showing the usage of "EnvironmentTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,21 +182,21 @@ public async Task CreateOrUpdate_EnvironmentTypesCreateOrUpdate() // invoke the operation string environmentTypeName = "DevTest"; - DevCenterEnvironmentTypeData data = new DevCenterEnvironmentTypeData() - { - Tags = -{ -["Owner"] = "superuser", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, environmentTypeName, data); - DevCenterEnvironmentTypeResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(environmentTypeName); + DevCenterEnvironmentTypeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterEnvironmentTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterEnvironmentTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterEnvironmentTypeResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterEnvironmentTypeResource.cs index c001656eba2aa..e185fe8922888 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterEnvironmentTypeResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterEnvironmentTypeResource.cs @@ -49,10 +49,10 @@ public async Task Get_EnvironmentTypesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_EnvironmentTypesUpdate() + public async Task Delete_EnvironmentTypesDelete() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_Patch.json - // this example is just showing the usage of "EnvironmentTypes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_Delete.json + // this example is just showing the usage of "EnvironmentTypes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,28 +69,17 @@ public async Task Update_EnvironmentTypesUpdate() DevCenterEnvironmentTypeResource devCenterEnvironmentType = client.GetDevCenterEnvironmentTypeResource(devCenterEnvironmentTypeResourceId); // invoke the operation - DevCenterEnvironmentTypePatch patch = new DevCenterEnvironmentTypePatch() - { - Tags = -{ -["Owner"] = "superuser", -}, - }; - DevCenterEnvironmentTypeResource result = await devCenterEnvironmentType.UpdateAsync(patch); + await devCenterEnvironmentType.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterEnvironmentTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_EnvironmentTypesDelete() + public async Task Update_EnvironmentTypesUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_Delete.json - // this example is just showing the usage of "EnvironmentTypes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/EnvironmentTypes_Patch.json + // this example is just showing the usage of "EnvironmentTypes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +96,20 @@ public async Task Delete_EnvironmentTypesDelete() DevCenterEnvironmentTypeResource devCenterEnvironmentType = client.GetDevCenterEnvironmentTypeResource(devCenterEnvironmentTypeResourceId); // invoke the operation - await devCenterEnvironmentType.DeleteAsync(WaitUntil.Completed); + DevCenterEnvironmentTypePatch patch = new DevCenterEnvironmentTypePatch + { + Tags = +{ +["Owner"] = "superuser" +}, + }; + DevCenterEnvironmentTypeResource result = await devCenterEnvironmentType.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterEnvironmentTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterGalleryCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterGalleryCollection.cs index 9f5320c10eb82..3185177ea4807 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterGalleryCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterGalleryCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DevCenterGalleryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GalleriesListByDevCenter() + public async Task CreateOrUpdate_GalleriesCreateOrUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_List.json - // this example is just showing the usage of "Galleries_ListByDevCenter" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_Create.json + // this example is just showing the usage of "Galleries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_GalleriesListByDevCenter() // get the collection of this DevCenterGalleryResource DevCenterGalleryCollection collection = devCenter.GetDevCenterGalleries(); - // invoke the operation and iterate over the result - await foreach (DevCenterGalleryResource item in collection.GetAllAsync()) + // invoke the operation + string galleryName = "StandardGallery"; + DevCenterGalleryData data = new DevCenterGalleryData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterGalleryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + GalleryResourceId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.Compute/galleries/StandardGallery"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryName, data); + DevCenterGalleryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterGalleryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GalleriesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GalleriesGet() + public async Task GetAll_GalleriesListByDevCenter() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_Get.json - // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_List.json + // this example is just showing the usage of "Galleries_ListByDevCenter" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_GalleriesGet() // get the collection of this DevCenterGalleryResource DevCenterGalleryCollection collection = devCenter.GetDevCenterGalleries(); - // invoke the operation - string galleryName = "StandardGallery"; - bool result = await collection.ExistsAsync(galleryName); + // invoke the operation and iterate over the result + await foreach (DevCenterGalleryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterGalleryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GalleriesGet() + public async Task Exists_GalleriesGet() { // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_Get.json // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_GalleriesGet() // invoke the operation string galleryName = "StandardGallery"; - NullableResponse response = await collection.GetIfExistsAsync(galleryName); - DevCenterGalleryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(galleryName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterGalleryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GalleriesCreateOrUpdate() + public async Task GetIfExists_GalleriesGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_Create.json - // this example is just showing the usage of "Galleries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_Get.json + // this example is just showing the usage of "Galleries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_GalleriesCreateOrUpdate() // invoke the operation string galleryName = "StandardGallery"; - DevCenterGalleryData data = new DevCenterGalleryData() - { - GalleryResourceId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.Compute/galleries/StandardGallery"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, galleryName, data); - DevCenterGalleryResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(galleryName); + DevCenterGalleryResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterGalleryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterGalleryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterGalleryResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterGalleryResource.cs index 1f749c4b79968..8d9a1b2a2ccfe 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterGalleryResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterGalleryResource.cs @@ -48,10 +48,10 @@ public async Task Get_GalleriesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GalleriesCreateOrUpdate() + public async Task Delete_GalleriesDelete() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_Create.json - // this example is just showing the usage of "Galleries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_Delete.json + // this example is just showing the usage of "Galleries_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_GalleriesCreateOrUpdate() DevCenterGalleryResource devCenterGallery = client.GetDevCenterGalleryResource(devCenterGalleryResourceId); // invoke the operation - DevCenterGalleryData data = new DevCenterGalleryData() - { - GalleryResourceId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.Compute/galleries/StandardGallery"), - }; - ArmOperation lro = await devCenterGallery.UpdateAsync(WaitUntil.Completed, data); - DevCenterGalleryResource result = lro.Value; + await devCenterGallery.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterGalleryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_GalleriesDelete() + public async Task Update_GalleriesCreateOrUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_Delete.json - // this example is just showing the usage of "Galleries_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Galleries_Create.json + // this example is just showing the usage of "Galleries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,18 @@ public async Task Delete_GalleriesDelete() DevCenterGalleryResource devCenterGallery = client.GetDevCenterGalleryResource(devCenterGalleryResourceId); // invoke the operation - await devCenterGallery.DeleteAsync(WaitUntil.Completed); + DevCenterGalleryData data = new DevCenterGalleryData + { + GalleryResourceId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.Compute/galleries/StandardGallery"), + }; + ArmOperation lro = await devCenterGallery.UpdateAsync(WaitUntil.Completed, data); + DevCenterGalleryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterGalleryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterImageCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterImageCollection.cs index 9394e2f00553c..6043b45bf9138 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterImageCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterImageCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DevCenterImageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ImagesListByGallery() + public async Task Get_ImagesGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Images_ListByGallery.json - // this example is just showing the usage of "Images_ListByGallery" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Images_Get.json + // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,32 +32,30 @@ public async Task GetAll_ImagesListByGallery() string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; string resourceGroupName = "rg1"; string devCenterName = "Contoso"; - string galleryName = "DevGallery"; + string galleryName = "DefaultDevGallery"; ResourceIdentifier devCenterGalleryResourceId = DevCenterGalleryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, devCenterName, galleryName); DevCenterGalleryResource devCenterGallery = client.GetDevCenterGalleryResource(devCenterGalleryResourceId); // get the collection of this DevCenterImageResource DevCenterImageCollection collection = devCenterGallery.GetDevCenterImages(); - // invoke the operation and iterate over the result - await foreach (DevCenterImageResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterImageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string imageName = "ContosoBaseImage"; + DevCenterImageResource result = await collection.GetAsync(imageName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ImagesGet() + public async Task GetAll_ImagesListByGallery() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Images_Get.json - // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Images_ListByGallery.json + // this example is just showing the usage of "Images_ListByGallery" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,22 +67,24 @@ public async Task Get_ImagesGet() string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; string resourceGroupName = "rg1"; string devCenterName = "Contoso"; - string galleryName = "DefaultDevGallery"; + string galleryName = "DevGallery"; ResourceIdentifier devCenterGalleryResourceId = DevCenterGalleryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, devCenterName, galleryName); DevCenterGalleryResource devCenterGallery = client.GetDevCenterGalleryResource(devCenterGalleryResourceId); // get the collection of this DevCenterImageResource DevCenterImageCollection collection = devCenterGallery.GetDevCenterImages(); - // invoke the operation - string imageName = "ContosoBaseImage"; - DevCenterImageResource result = await collection.GetAsync(imageName); + // invoke the operation and iterate over the result + await foreach (DevCenterImageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterNetworkConnectionCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterNetworkConnectionCollection.cs index efdcec0d16f61..fd477c08294a9 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterNetworkConnectionCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterNetworkConnectionCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DevCenterNetworkConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkConnectionsListByResourceGroup() + public async Task CreateOrUpdate_NetworkConnectionsCreateOrUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_ListByResourceGroup.json - // this example is just showing the usage of "NetworkConnections_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_Put.json + // this example is just showing the usage of "NetworkConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_NetworkConnectionsListByResourceGroup() // get the collection of this DevCenterNetworkConnectionResource DevCenterNetworkConnectionCollection collection = resourceGroupResource.GetDevCenterNetworkConnections(); - // invoke the operation and iterate over the result - await foreach (DevCenterNetworkConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string networkConnectionName = "uswest3network"; + DevCenterNetworkConnectionData data = new DevCenterNetworkConnectionData(new AzureLocation("centralus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterNetworkConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ExampleRG/providers/Microsoft.Network/virtualNetworks/ExampleVNet/subnets/default"), + DomainName = "mydomaincontroller.local", + DomainUsername = "testuser@mydomaincontroller.local", + DomainPassword = "Password value for user", + NetworkingResourceGroupName = "NetworkInterfaces", + DomainJoinType = DomainJoinType.HybridAadJoin, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkConnectionName, data); + DevCenterNetworkConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterNetworkConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +95,10 @@ public async Task Get_NetworkConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkConnectionsGet() + public async Task GetAll_NetworkConnectionsListByResourceGroup() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_Get.json - // this example is just showing the usage of "NetworkConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_ListByResourceGroup.json + // this example is just showing the usage of "NetworkConnections_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +115,22 @@ public async Task Exists_NetworkConnectionsGet() // get the collection of this DevCenterNetworkConnectionResource DevCenterNetworkConnectionCollection collection = resourceGroupResource.GetDevCenterNetworkConnections(); - // invoke the operation - string networkConnectionName = "uswest3network"; - bool result = await collection.ExistsAsync(networkConnectionName); + // invoke the operation and iterate over the result + await foreach (DevCenterNetworkConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterNetworkConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkConnectionsGet() + public async Task Exists_NetworkConnectionsGet() { // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_Get.json // this example is just showing the usage of "NetworkConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +152,17 @@ public async Task GetIfExists_NetworkConnectionsGet() // invoke the operation string networkConnectionName = "uswest3network"; - NullableResponse response = await collection.GetIfExistsAsync(networkConnectionName); - DevCenterNetworkConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterNetworkConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NetworkConnectionsCreateOrUpdate() + public async Task GetIfExists_NetworkConnectionsGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_Put.json - // this example is just showing the usage of "NetworkConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_Get.json + // this example is just showing the usage of "NetworkConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,23 +181,21 @@ public async Task CreateOrUpdate_NetworkConnectionsCreateOrUpdate() // invoke the operation string networkConnectionName = "uswest3network"; - DevCenterNetworkConnectionData data = new DevCenterNetworkConnectionData(new AzureLocation("centralus")) - { - SubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/ExampleRG/providers/Microsoft.Network/virtualNetworks/ExampleVNet/subnets/default"), - DomainName = "mydomaincontroller.local", - DomainUsername = "testuser@mydomaincontroller.local", - DomainPassword = "Password value for user", - NetworkingResourceGroupName = "NetworkInterfaces", - DomainJoinType = DomainJoinType.HybridAadJoin, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkConnectionName, data); - DevCenterNetworkConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(networkConnectionName); + DevCenterNetworkConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterNetworkConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterNetworkConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterNetworkConnectionResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterNetworkConnectionResource.cs index 42aad1295365b..93465510f04b6 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterNetworkConnectionResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterNetworkConnectionResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DevCenter.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DevCenter.Samples { public partial class Sample_DevCenterNetworkConnectionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDevCenterNetworkConnections_NetworkConnectionsListBySubscription() - { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_ListBySubscription.json - // this example is just showing the usage of "NetworkConnections_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DevCenterNetworkConnectionResource item in subscriptionResource.GetDevCenterNetworkConnectionsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterNetworkConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_NetworkConnectionsGet() @@ -80,10 +48,10 @@ public async Task Get_NetworkConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NetworkConnectionsUpdate() + public async Task Delete_NetworkConnectionsDelete() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_Patch.json - // this example is just showing the usage of "NetworkConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_Delete.json + // this example is just showing the usage of "NetworkConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,31 +62,22 @@ public async Task Update_NetworkConnectionsUpdate() // for more information of creating DevCenterNetworkConnectionResource, please refer to the document of DevCenterNetworkConnectionResource string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; string resourceGroupName = "rg1"; - string networkConnectionName = "uswest3network"; + string networkConnectionName = "eastusnetwork"; ResourceIdentifier devCenterNetworkConnectionResourceId = DevCenterNetworkConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkConnectionName); DevCenterNetworkConnectionResource devCenterNetworkConnection = client.GetDevCenterNetworkConnectionResource(devCenterNetworkConnectionResourceId); // invoke the operation - DevCenterNetworkConnectionPatch patch = new DevCenterNetworkConnectionPatch() - { - DomainPassword = "New Password value for user", - }; - ArmOperation lro = await devCenterNetworkConnection.UpdateAsync(WaitUntil.Completed, patch); - DevCenterNetworkConnectionResource result = lro.Value; + await devCenterNetworkConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterNetworkConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkConnectionsDelete() + public async Task Update_NetworkConnectionsUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_Delete.json - // this example is just showing the usage of "NetworkConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_Patch.json + // this example is just showing the usage of "NetworkConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,14 +88,23 @@ public async Task Delete_NetworkConnectionsDelete() // for more information of creating DevCenterNetworkConnectionResource, please refer to the document of DevCenterNetworkConnectionResource string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; string resourceGroupName = "rg1"; - string networkConnectionName = "eastusnetwork"; + string networkConnectionName = "uswest3network"; ResourceIdentifier devCenterNetworkConnectionResourceId = DevCenterNetworkConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkConnectionName); DevCenterNetworkConnectionResource devCenterNetworkConnection = client.GetDevCenterNetworkConnectionResource(devCenterNetworkConnectionResourceId); // invoke the operation - await devCenterNetworkConnection.DeleteAsync(WaitUntil.Completed); + DevCenterNetworkConnectionPatch patch = new DevCenterNetworkConnectionPatch + { + DomainPassword = "New Password value for user", + }; + ArmOperation lro = await devCenterNetworkConnection.UpdateAsync(WaitUntil.Completed, patch); + DevCenterNetworkConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterNetworkConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterPoolCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterPoolCollection.cs index 30a96e927f566..1e55312bad32c 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterPoolCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevCenterPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PoolsListByProject() + public async Task CreateOrUpdate_PoolsCreateOrUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_List.json - // this example is just showing the usage of "Pools_ListByProject" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_Put.json + // this example is just showing the usage of "Pools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,28 @@ public async Task GetAll_PoolsListByProject() // get the collection of this DevCenterPoolResource DevCenterPoolCollection collection = devCenterProject.GetDevCenterPools(); - // invoke the operation and iterate over the result - await foreach (DevCenterPoolResource item in collection.GetAllAsync()) + // invoke the operation + string poolName = "DevPool"; + DevCenterPoolData data = new DevCenterPoolData(new AzureLocation("centralus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DevBoxDefinitionName = "WebDevBox", + NetworkConnectionName = "Network1-westus2", + LicenseType = DevCenterLicenseType.WindowsClient, + LocalAdministrator = LocalAdminStatus.IsEnabled, + StopOnDisconnect = new StopOnDisconnectConfiguration + { + Status = StopOnDisconnectEnableStatus.IsEnabled, + GracePeriodMinutes = 60, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data); + DevCenterPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,9 +99,9 @@ public async Task Get_PoolsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PoolsGet() + public async Task Get_PoolsGetUnhealthyStatus() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_Get.json + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_GetUnhealthyStatus.json // this example is just showing the usage of "Pools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -111,17 +122,21 @@ public async Task Exists_PoolsGet() // invoke the operation string poolName = "DevPool"; - bool result = await collection.ExistsAsync(poolName); + DevCenterPoolResource result = await collection.GetAsync(poolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PoolsGet() + public async Task GetAll_PoolsListByProject() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_Get.json - // this example is just showing the usage of "Pools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_List.json + // this example is just showing the usage of "Pools_ListByProject" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,30 +154,24 @@ public async Task GetIfExists_PoolsGet() // get the collection of this DevCenterPoolResource DevCenterPoolCollection collection = devCenterProject.GetDevCenterPools(); - // invoke the operation - string poolName = "DevPool"; - NullableResponse response = await collection.GetIfExistsAsync(poolName); - DevCenterPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DevCenterPoolResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DevCenterPoolData resourceData = result.Data; + DevCenterPoolData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PoolsGetUnhealthyStatus() + public async Task Exists_PoolsGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_GetUnhealthyStatus.json + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_Get.json // this example is just showing the usage of "Pools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -183,13 +192,9 @@ public async Task Get_PoolsGetUnhealthyStatus() // invoke the operation string poolName = "DevPool"; - DevCenterPoolResource result = await collection.GetAsync(poolName); + bool result = await collection.ExistsAsync(poolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -224,9 +229,9 @@ public async Task Exists_PoolsGetUnhealthyStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PoolsGetUnhealthyStatus() + public async Task GetIfExists_PoolsGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_GetUnhealthyStatus.json + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_Get.json // this example is just showing the usage of "Pools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -266,10 +271,10 @@ public async Task GetIfExists_PoolsGetUnhealthyStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PoolsCreateOrUpdate() + public async Task GetIfExists_PoolsGetUnhealthyStatus() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_Put.json - // this example is just showing the usage of "Pools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_GetUnhealthyStatus.json + // this example is just showing the usage of "Pools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -289,26 +294,21 @@ public async Task CreateOrUpdate_PoolsCreateOrUpdate() // invoke the operation string poolName = "DevPool"; - DevCenterPoolData data = new DevCenterPoolData(new AzureLocation("centralus")) - { - DevBoxDefinitionName = "WebDevBox", - NetworkConnectionName = "Network1-westus2", - LicenseType = DevCenterLicenseType.WindowsClient, - LocalAdministrator = LocalAdminStatus.IsEnabled, - StopOnDisconnect = new StopOnDisconnectConfiguration() - { - Status = StopOnDisconnectEnableStatus.IsEnabled, - GracePeriodMinutes = 60, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data); - DevCenterPoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(poolName); + DevCenterPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterPoolResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterPoolResource.cs index b0346f84a4331..c2484c1b36035 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterPoolResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterPoolResource.cs @@ -80,10 +80,10 @@ public async Task Get_PoolsGetUnhealthyStatus() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PoolsUpdate() + public async Task Delete_PoolsDelete() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_Patch.json - // this example is just showing the usage of "Pools_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_Delete.json + // this example is just showing the usage of "Pools_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,31 +95,22 @@ public async Task Update_PoolsUpdate() string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; string resourceGroupName = "rg1"; string projectName = "DevProject"; - string poolName = "DevPool"; + string poolName = "poolName"; ResourceIdentifier devCenterPoolResourceId = DevCenterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, poolName); DevCenterPoolResource devCenterPool = client.GetDevCenterPoolResource(devCenterPoolResourceId); // invoke the operation - DevCenterPoolPatch patch = new DevCenterPoolPatch() - { - DevBoxDefinitionName = "WebDevBox2", - }; - ArmOperation lro = await devCenterPool.UpdateAsync(WaitUntil.Completed, patch); - DevCenterPoolResource result = lro.Value; + await devCenterPool.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PoolsDelete() + public async Task Update_PoolsUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_Delete.json - // this example is just showing the usage of "Pools_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Pools_Patch.json + // this example is just showing the usage of "Pools_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,14 +122,23 @@ public async Task Delete_PoolsDelete() string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; string resourceGroupName = "rg1"; string projectName = "DevProject"; - string poolName = "poolName"; + string poolName = "DevPool"; ResourceIdentifier devCenterPoolResourceId = DevCenterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, poolName); DevCenterPoolResource devCenterPool = client.GetDevCenterPoolResource(devCenterPoolResourceId); // invoke the operation - await devCenterPool.DeleteAsync(WaitUntil.Completed); + DevCenterPoolPatch patch = new DevCenterPoolPatch + { + DevBoxDefinitionName = "WebDevBox2", + }; + ArmOperation lro = await devCenterPool.UpdateAsync(WaitUntil.Completed, patch); + DevCenterPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectCollection.cs index dc7038c00ec84..3d1c3b1702b76 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevCenterProjectCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProjectsListByResourceGroup() + public async Task CreateOrUpdate_ProjectsCreateOrUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_ListByResourceGroup.json - // this example is just showing the usage of "Projects_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Put.json + // this example is just showing the usage of "Projects_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,33 @@ public async Task GetAll_ProjectsListByResourceGroup() // get the collection of this DevCenterProjectResource DevCenterProjectCollection collection = resourceGroupResource.GetDevCenterProjects(); - // invoke the operation and iterate over the result - await foreach (DevCenterProjectResource item in collection.GetAllAsync()) + // invoke the operation + string projectName = "DevProject"; + DevCenterProjectData data = new DevCenterProjectData(new AzureLocation("centralus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterProjectData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DevCenterId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/devcenters/Contoso"), + Description = "This is my first project.", + Tags = +{ +["CostCenter"] = "R&D" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, projectName, data); + DevCenterProjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterProjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProjectsGet() + public async Task CreateOrUpdate_ProjectsCreateOrUpdateWithLimitsPerDev() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Get.json - // this example is just showing the usage of "Projects_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_PutWithMaxDevBoxPerUser.json + // this example is just showing the usage of "Projects_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,7 +83,18 @@ public async Task Get_ProjectsGet() // invoke the operation string projectName = "DevProject"; - DevCenterProjectResource result = await collection.GetAsync(projectName); + DevCenterProjectData data = new DevCenterProjectData(new AzureLocation("centralus")) + { + DevCenterId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/devcenters/Contoso"), + Description = "This is my first project.", + MaxDevBoxesPerUser = 3, + Tags = +{ +["CostCenter"] = "R&D" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, projectName, data); + DevCenterProjectResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -86,7 +105,7 @@ public async Task Get_ProjectsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProjectsGet() + public async Task Get_ProjectsGet() { // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Get.json // this example is just showing the usage of "Projects_Get" operation, for the dependent resources, they will have to be created separately. @@ -108,17 +127,21 @@ public async Task Exists_ProjectsGet() // invoke the operation string projectName = "DevProject"; - bool result = await collection.ExistsAsync(projectName); + DevCenterProjectResource result = await collection.GetAsync(projectName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterProjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProjectsGet() + public async Task GetAll_ProjectsListByResourceGroup() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Get.json - // this example is just showing the usage of "Projects_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_ListByResourceGroup.json + // this example is just showing the usage of "Projects_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,31 +158,25 @@ public async Task GetIfExists_ProjectsGet() // get the collection of this DevCenterProjectResource DevCenterProjectCollection collection = resourceGroupResource.GetDevCenterProjects(); - // invoke the operation - string projectName = "DevProject"; - NullableResponse response = await collection.GetIfExistsAsync(projectName); - DevCenterProjectResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DevCenterProjectResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DevCenterProjectData resourceData = result.Data; + DevCenterProjectData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProjectsCreateOrUpdate() + public async Task Exists_ProjectsGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Put.json - // this example is just showing the usage of "Projects_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Get.json + // this example is just showing the usage of "Projects_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,31 +195,17 @@ public async Task CreateOrUpdate_ProjectsCreateOrUpdate() // invoke the operation string projectName = "DevProject"; - DevCenterProjectData data = new DevCenterProjectData(new AzureLocation("centralus")) - { - DevCenterId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/devcenters/Contoso"), - Description = "This is my first project.", - Tags = -{ -["CostCenter"] = "R&D", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, projectName, data); - DevCenterProjectResource result = lro.Value; + bool result = await collection.ExistsAsync(projectName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterProjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProjectsCreateOrUpdateWithLimitsPerDev() + public async Task GetIfExists_ProjectsGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_PutWithMaxDevBoxPerUser.json - // this example is just showing the usage of "Projects_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Get.json + // this example is just showing the usage of "Projects_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -221,24 +224,21 @@ public async Task CreateOrUpdate_ProjectsCreateOrUpdateWithLimitsPerDev() // invoke the operation string projectName = "DevProject"; - DevCenterProjectData data = new DevCenterProjectData(new AzureLocation("centralus")) - { - DevCenterId = new ResourceIdentifier("/subscriptions/0ac520ee-14c0-480f-b6c9-0a90c58ffff/resourceGroups/rg1/providers/Microsoft.DevCenter/devcenters/Contoso"), - Description = "This is my first project.", - MaxDevBoxesPerUser = 3, - Tags = -{ -["CostCenter"] = "R&D", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, projectName, data); - DevCenterProjectResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(projectName); + DevCenterProjectResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterProjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterProjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectEnvironmentCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectEnvironmentCollection.cs index 079a9560cc6dd..53fdb78804c43 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectEnvironmentCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectEnvironmentCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DevCenterProjectEnvironmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProjectEnvironmentTypesList() + public async Task CreateOrUpdate_ProjectEnvironmentTypesCreateOrUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectEnvironmentTypes_List.json - // this example is just showing the usage of "ProjectEnvironmentTypes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectEnvironmentTypes_Put.json + // this example is just showing the usage of "ProjectEnvironmentTypes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,46 @@ public async Task GetAll_ProjectEnvironmentTypesList() // get the collection of this DevCenterProjectEnvironmentResource DevCenterProjectEnvironmentCollection collection = devCenterProject.GetDevCenterProjectEnvironments(); - // invoke the operation and iterate over the result - await foreach (DevCenterProjectEnvironmentResource item in collection.GetAllAsync()) + // invoke the operation + string environmentTypeName = "DevTest"; + DevCenterProjectEnvironmentData data = new DevCenterProjectEnvironmentData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterProjectEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1")] = new UserAssignedIdentity() +}, + }, + DeploymentTargetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000"), + Status = EnvironmentTypeEnableStatus.IsEnabled, + Roles = +{ +["4cbf0b6c-e750-441c-98a7-10da8387e4d6"] = new DevCenterEnvironmentRole() +}, + UserRoleAssignments = +{ +["e45e3m7c-176e-416a-b466-0c5ec8298f8a"] = new DevCenterUserRoleAssignments +{ +Roles = +{ +["4cbf0b6c-e750-441c-98a7-10da8387e4d6"] = new DevCenterEnvironmentRole() +}, +} +}, + Tags = +{ +["CostCenter"] = "RnD" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, environmentTypeName, data); + DevCenterProjectEnvironmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterProjectEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +118,10 @@ public async Task Get_ProjectEnvironmentTypesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProjectEnvironmentTypesGet() + public async Task GetAll_ProjectEnvironmentTypesList() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectEnvironmentTypes_Get.json - // this example is just showing the usage of "ProjectEnvironmentTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectEnvironmentTypes_List.json + // this example is just showing the usage of "ProjectEnvironmentTypes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +139,22 @@ public async Task Exists_ProjectEnvironmentTypesGet() // get the collection of this DevCenterProjectEnvironmentResource DevCenterProjectEnvironmentCollection collection = devCenterProject.GetDevCenterProjectEnvironments(); - // invoke the operation - string environmentTypeName = "DevTest"; - bool result = await collection.ExistsAsync(environmentTypeName); + // invoke the operation and iterate over the result + await foreach (DevCenterProjectEnvironmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterProjectEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProjectEnvironmentTypesGet() + public async Task Exists_ProjectEnvironmentTypesGet() { // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectEnvironmentTypes_Get.json // this example is just showing the usage of "ProjectEnvironmentTypes_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +177,17 @@ public async Task GetIfExists_ProjectEnvironmentTypesGet() // invoke the operation string environmentTypeName = "DevTest"; - NullableResponse response = await collection.GetIfExistsAsync(environmentTypeName); - DevCenterProjectEnvironmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(environmentTypeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterProjectEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProjectEnvironmentTypesCreateOrUpdate() + public async Task GetIfExists_ProjectEnvironmentTypesGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectEnvironmentTypes_Put.json - // this example is just showing the usage of "ProjectEnvironmentTypes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectEnvironmentTypes_Get.json + // this example is just showing the usage of "ProjectEnvironmentTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,44 +207,21 @@ public async Task CreateOrUpdate_ProjectEnvironmentTypesCreateOrUpdate() // invoke the operation string environmentTypeName = "DevTest"; - DevCenterProjectEnvironmentData data = new DevCenterProjectEnvironmentData(new AzureLocation("placeholder")) - { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1")] = new UserAssignedIdentity(), -}, - }, - DeploymentTargetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000"), - Status = EnvironmentTypeEnableStatus.IsEnabled, - Roles = -{ -["4cbf0b6c-e750-441c-98a7-10da8387e4d6"] = new DevCenterEnvironmentRole(), -}, - UserRoleAssignments = -{ -["e45e3m7c-176e-416a-b466-0c5ec8298f8a"] = new DevCenterUserRoleAssignments() -{ -Roles = -{ -["4cbf0b6c-e750-441c-98a7-10da8387e4d6"] = new DevCenterEnvironmentRole(), -}, -}, -}, - Tags = -{ -["CostCenter"] = "RnD", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, environmentTypeName, data); - DevCenterProjectEnvironmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(environmentTypeName); + DevCenterProjectEnvironmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterProjectEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterProjectEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectEnvironmentResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectEnvironmentResource.cs index ed26049a5a441..da883549b1826 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectEnvironmentResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectEnvironmentResource.cs @@ -48,6 +48,33 @@ public async Task Get_ProjectEnvironmentTypesGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ProjectEnvironmentTypesDelete() + { + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectEnvironmentTypes_Delete.json + // this example is just showing the usage of "ProjectEnvironmentTypes_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DevCenterProjectEnvironmentResource created on azure + // for more information of creating DevCenterProjectEnvironmentResource, please refer to the document of DevCenterProjectEnvironmentResource + string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; + string resourceGroupName = "rg1"; + string projectName = "ContosoProj"; + string environmentTypeName = "DevTest"; + ResourceIdentifier devCenterProjectEnvironmentResourceId = DevCenterProjectEnvironmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, environmentTypeName); + DevCenterProjectEnvironmentResource devCenterProjectEnvironment = client.GetDevCenterProjectEnvironmentResource(devCenterProjectEnvironmentResourceId); + + // invoke the operation + await devCenterProjectEnvironment.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_ProjectEnvironmentTypesUpdate() @@ -70,30 +97,30 @@ public async Task Update_ProjectEnvironmentTypesUpdate() DevCenterProjectEnvironmentResource devCenterProjectEnvironment = client.GetDevCenterProjectEnvironmentResource(devCenterProjectEnvironmentResourceId); // invoke the operation - DevCenterProjectEnvironmentPatch patch = new DevCenterProjectEnvironmentPatch() + DevCenterProjectEnvironmentPatch patch = new DevCenterProjectEnvironmentPatch { Tags = { -["CostCenter"] = "RnD", +["CostCenter"] = "RnD" }, Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/identityGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testidentity1")] = new UserAssignedIdentity() }, }, DeploymentTargetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000"), Status = EnvironmentTypeEnableStatus.IsEnabled, UserRoleAssignments = { -["e45e3m7c-176e-416a-b466-0c5ec8298f8a"] = new DevCenterUserRoleAssignments() +["e45e3m7c-176e-416a-b466-0c5ec8298f8a"] = new DevCenterUserRoleAssignments { Roles = { -["4cbf0b6c-e750-441c-98a7-10da8387e4d6"] = new DevCenterEnvironmentRole(), -}, +["4cbf0b6c-e750-441c-98a7-10da8387e4d6"] = new DevCenterEnvironmentRole() }, +} }, }; DevCenterProjectEnvironmentResource result = await devCenterProjectEnvironment.UpdateAsync(patch); @@ -104,32 +131,5 @@ public async Task Update_ProjectEnvironmentTypesUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ProjectEnvironmentTypesDelete() - { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ProjectEnvironmentTypes_Delete.json - // this example is just showing the usage of "ProjectEnvironmentTypes_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DevCenterProjectEnvironmentResource created on azure - // for more information of creating DevCenterProjectEnvironmentResource, please refer to the document of DevCenterProjectEnvironmentResource - string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; - string resourceGroupName = "rg1"; - string projectName = "ContosoProj"; - string environmentTypeName = "DevTest"; - ResourceIdentifier devCenterProjectEnvironmentResourceId = DevCenterProjectEnvironmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, environmentTypeName); - DevCenterProjectEnvironmentResource devCenterProjectEnvironment = client.GetDevCenterProjectEnvironmentResource(devCenterProjectEnvironmentResourceId); - - // invoke the operation - await devCenterProjectEnvironment.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectResource.cs index 84ca2b6acb9f8..9964aa3894fc8 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterProjectResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DevCenter.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DevCenter.Samples { public partial class Sample_DevCenterProjectResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDevCenterProjects_ProjectsListBySubscription() - { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_ListBySubscription.json - // this example is just showing the usage of "Projects_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DevCenterProjectResource item in subscriptionResource.GetDevCenterProjectsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterProjectData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ProjectsGet() @@ -80,10 +48,10 @@ public async Task Get_ProjectsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ProjectsUpdate() + public async Task Delete_ProjectsDelete() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Patch.json - // this example is just showing the usage of "Projects_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Delete.json + // this example is just showing the usage of "Projects_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,30 +67,17 @@ public async Task Update_ProjectsUpdate() DevCenterProjectResource devCenterProject = client.GetDevCenterProjectResource(devCenterProjectResourceId); // invoke the operation - DevCenterProjectPatch patch = new DevCenterProjectPatch() - { - Description = "This is my first project.", - Tags = -{ -["CostCenter"] = "R&D", -}, - }; - ArmOperation lro = await devCenterProject.UpdateAsync(WaitUntil.Completed, patch); - DevCenterProjectResource result = lro.Value; + await devCenterProject.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterProjectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ProjectsDelete() + public async Task Update_ProjectsUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Delete.json - // this example is just showing the usage of "Projects_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_Patch.json + // this example is just showing the usage of "Projects_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,9 +93,22 @@ public async Task Delete_ProjectsDelete() DevCenterProjectResource devCenterProject = client.GetDevCenterProjectResource(devCenterProjectResourceId); // invoke the operation - await devCenterProject.DeleteAsync(WaitUntil.Completed); + DevCenterProjectPatch patch = new DevCenterProjectPatch + { + Description = "This is my first project.", + Tags = +{ +["CostCenter"] = "R&D" +}, + }; + ArmOperation lro = await devCenterProject.UpdateAsync(WaitUntil.Completed, patch); + DevCenterProjectResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterProjectData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterResource.cs index 7d63c27e94b4e..649b4aabd3230 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.DevCenter.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.DevCenter.Samples { public partial class Sample_DevCenterResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDevCenters_DevCentersListBySubscription() - { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_ListBySubscription.json - // this example is just showing the usage of "DevCenters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DevCenterResource item in subscriptionResource.GetDevCentersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_DevCentersGet() @@ -80,10 +48,10 @@ public async Task Get_DevCentersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DevCentersUpdate() + public async Task Delete_DevCentersDelete() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Patch.json - // this example is just showing the usage of "DevCenters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Delete.json + // this example is just showing the usage of "DevCenters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,29 +67,17 @@ public async Task Update_DevCentersUpdate() DevCenterResource devCenter = client.GetDevCenterResource(devCenterResourceId); // invoke the operation - DevCenterPatch patch = new DevCenterPatch() - { - Tags = -{ -["CostCode"] = "12345", -}, - }; - ArmOperation lro = await devCenter.UpdateAsync(WaitUntil.Completed, patch); - DevCenterResource result = lro.Value; + await devCenter.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DevCentersDelete() + public async Task Update_DevCentersUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Delete.json - // this example is just showing the usage of "DevCenters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_Patch.json + // this example is just showing the usage of "DevCenters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,9 +93,21 @@ public async Task Delete_DevCentersDelete() DevCenterResource devCenter = client.GetDevCenterResource(devCenterResourceId); // invoke the operation - await devCenter.DeleteAsync(WaitUntil.Completed); + DevCenterPatch patch = new DevCenterPatch + { + Tags = +{ +["CostCode"] = "12345" +}, + }; + ArmOperation lro = await devCenter.UpdateAsync(WaitUntil.Completed, patch); + DevCenterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterScheduleCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterScheduleCollection.cs index e3b7a5181aa22..75b8419143f8c 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterScheduleCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterScheduleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DevCenterScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SchedulesListByPool() + public async Task CreateOrUpdate_SchedulesCreateDailyShutdownPoolSchedule() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_ListByPool.json - // this example is just showing the usage of "Schedules_ListByPool" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_CreateDailyShutdownPoolSchedule.json + // this example is just showing the usage of "Schedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task GetAll_SchedulesListByPool() // for more information of creating DevCenterPoolResource, please refer to the document of DevCenterPoolResource string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; string resourceGroupName = "rg1"; - string projectName = "TestProject"; + string projectName = "DevProject"; string poolName = "DevPool"; ResourceIdentifier devCenterPoolResourceId = DevCenterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, poolName); DevCenterPoolResource devCenterPool = client.GetDevCenterPoolResource(devCenterPoolResourceId); @@ -40,17 +40,24 @@ public async Task GetAll_SchedulesListByPool() // get the collection of this DevCenterScheduleResource DevCenterScheduleCollection collection = devCenterPool.GetDevCenterSchedules(); - // invoke the operation and iterate over the result - await foreach (DevCenterScheduleResource item in collection.GetAllAsync()) + // invoke the operation + string scheduleName = "autoShutdown"; + DevCenterScheduleData data = new DevCenterScheduleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ScheduledType = DevCenterScheduledType.StopDevBox, + Frequency = DevCenterScheduledFrequency.Daily, + Time = "17:30", + TimeZone = "America/Los_Angeles", + State = DevCenterScheduleEnableStatus.IsEnabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scheduleName, data); + DevCenterScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +97,10 @@ public async Task Get_SchedulesGetByPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SchedulesGetByPool() + public async Task GetAll_SchedulesListByPool() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_Get.json - // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_ListByPool.json + // this example is just showing the usage of "Schedules_ListByPool" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +119,22 @@ public async Task Exists_SchedulesGetByPool() // get the collection of this DevCenterScheduleResource DevCenterScheduleCollection collection = devCenterPool.GetDevCenterSchedules(); - // invoke the operation - string scheduleName = "autoShutdown"; - bool result = await collection.ExistsAsync(scheduleName); + // invoke the operation and iterate over the result + await foreach (DevCenterScheduleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SchedulesGetByPool() + public async Task Exists_SchedulesGetByPool() { // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_Get.json // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +158,17 @@ public async Task GetIfExists_SchedulesGetByPool() // invoke the operation string scheduleName = "autoShutdown"; - NullableResponse response = await collection.GetIfExistsAsync(scheduleName); - DevCenterScheduleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(scheduleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SchedulesCreateDailyShutdownPoolSchedule() + public async Task GetIfExists_SchedulesGetByPool() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_CreateDailyShutdownPoolSchedule.json - // this example is just showing the usage of "Schedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_Get.json + // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,7 +179,7 @@ public async Task CreateOrUpdate_SchedulesCreateDailyShutdownPoolSchedule() // for more information of creating DevCenterPoolResource, please refer to the document of DevCenterPoolResource string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; string resourceGroupName = "rg1"; - string projectName = "DevProject"; + string projectName = "TestProject"; string poolName = "DevPool"; ResourceIdentifier devCenterPoolResourceId = DevCenterPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, projectName, poolName); DevCenterPoolResource devCenterPool = client.GetDevCenterPoolResource(devCenterPoolResourceId); @@ -188,22 +189,21 @@ public async Task CreateOrUpdate_SchedulesCreateDailyShutdownPoolSchedule() // invoke the operation string scheduleName = "autoShutdown"; - DevCenterScheduleData data = new DevCenterScheduleData() - { - ScheduledType = DevCenterScheduledType.StopDevBox, - Frequency = DevCenterScheduledFrequency.Daily, - Time = "17:30", - TimeZone = "America/Los_Angeles", - State = DevCenterScheduleEnableStatus.IsEnabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scheduleName, data); - DevCenterScheduleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(scheduleName); + DevCenterScheduleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterScheduleResource.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterScheduleResource.cs index 0e1de4deb2420..0510893acc3ef 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterScheduleResource.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_DevCenterScheduleResource.cs @@ -50,10 +50,10 @@ public async Task Get_SchedulesGetByPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SchedulesUpdate() + public async Task Delete_SchedulesDelete() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_Patch.json - // this example is just showing the usage of "Schedules_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_Delete.json + // this example is just showing the usage of "Schedules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,26 +71,17 @@ public async Task Update_SchedulesUpdate() DevCenterScheduleResource devCenterSchedule = client.GetDevCenterScheduleResource(devCenterScheduleResourceId); // invoke the operation - DevCenterSchedulePatch patch = new DevCenterSchedulePatch() - { - Time = "18:00", - }; - ArmOperation lro = await devCenterSchedule.UpdateAsync(WaitUntil.Completed, patch); - DevCenterScheduleResource result = lro.Value; + await devCenterSchedule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevCenterScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SchedulesDelete() + public async Task Update_SchedulesUpdate() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_Delete.json - // this example is just showing the usage of "Schedules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Schedules_Patch.json + // this example is just showing the usage of "Schedules_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +99,18 @@ public async Task Delete_SchedulesDelete() DevCenterScheduleResource devCenterSchedule = client.GetDevCenterScheduleResource(devCenterScheduleResourceId); // invoke the operation - await devCenterSchedule.DeleteAsync(WaitUntil.Completed); + DevCenterSchedulePatch patch = new DevCenterSchedulePatch + { + Time = "18:00", + }; + ArmOperation lro = await devCenterSchedule.UpdateAsync(WaitUntil.Completed, patch); + DevCenterScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ImageVersionCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ImageVersionCollection.cs index 39e83418cb4ff..337544e40f62a 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ImageVersionCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ImageVersionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ImageVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ImageVersionsListByImage() + public async Task Get_VersionsGet() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ImageVersions_List.json - // this example is just showing the usage of "ImageVersions_ListByImage" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ImageVersions_Get.json + // this example is just showing the usage of "ImageVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ImageVersionsListByImage() // get the collection of this ImageVersionResource ImageVersionCollection collection = devCenterImage.GetImageVersions(); - // invoke the operation and iterate over the result - await foreach (ImageVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ImageVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string versionName = "1.0.0"; + ImageVersionResource result = await collection.GetAsync(versionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ImageVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VersionsGet() + public async Task GetAll_ImageVersionsListByImage() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ImageVersions_Get.json - // this example is just showing the usage of "ImageVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/ImageVersions_List.json + // this example is just showing the usage of "ImageVersions_ListByImage" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_VersionsGet() // get the collection of this ImageVersionResource ImageVersionCollection collection = devCenterImage.GetImageVersions(); - // invoke the operation - string versionName = "1.0.0"; - ImageVersionResource result = await collection.GetAsync(versionName); + // invoke the operation and iterate over the result + await foreach (ImageVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ImageVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ImageVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ProjectAttachedNetworkConnectionCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ProjectAttachedNetworkConnectionCollection.cs index 4fb8f2bdd3fb9..bba6191466667 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ProjectAttachedNetworkConnectionCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ProjectAttachedNetworkConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ProjectAttachedNetworkConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AttachedNetworksListByProject() + public async Task Get_AttachedNetworksGetByProject() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_ListByProject.json - // this example is just showing the usage of "AttachedNetworks_ListByProject" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_GetByProject.json + // this example is just showing the usage of "AttachedNetworks_GetByProject" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_AttachedNetworksListByProject() // get the collection of this ProjectAttachedNetworkConnectionResource ProjectAttachedNetworkConnectionCollection collection = devCenterProject.GetProjectAttachedNetworkConnections(); - // invoke the operation and iterate over the result - await foreach (ProjectAttachedNetworkConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttachedNetworkConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string attachedNetworkConnectionName = "network-uswest3"; + ProjectAttachedNetworkConnectionResource result = await collection.GetAsync(attachedNetworkConnectionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttachedNetworkConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AttachedNetworksGetByProject() + public async Task GetAll_AttachedNetworksListByProject() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_GetByProject.json - // this example is just showing the usage of "AttachedNetworks_GetByProject" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/AttachedNetworks_ListByProject.json + // this example is just showing the usage of "AttachedNetworks_ListByProject" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_AttachedNetworksGetByProject() // get the collection of this ProjectAttachedNetworkConnectionResource ProjectAttachedNetworkConnectionCollection collection = devCenterProject.GetProjectAttachedNetworkConnections(); - // invoke the operation - string attachedNetworkConnectionName = "network-uswest3"; - ProjectAttachedNetworkConnectionResource result = await collection.GetAsync(attachedNetworkConnectionName); + // invoke the operation and iterate over the result + await foreach (ProjectAttachedNetworkConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttachedNetworkConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttachedNetworkConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ProjectDevBoxDefinitionCollection.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ProjectDevBoxDefinitionCollection.cs index 6a8b38fbf31d7..0a49611c5f08d 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ProjectDevBoxDefinitionCollection.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_ProjectDevBoxDefinitionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ProjectDevBoxDefinitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DevBoxDefinitionsListByProject() + public async Task Get_DevBoxDefinitionsGetByProject() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_ListByProject.json - // this example is just showing the usage of "DevBoxDefinitions_ListByProject" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_GetByProject.json + // this example is just showing the usage of "DevBoxDefinitions_GetByProject" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_DevBoxDefinitionsListByProject() // get the collection of this ProjectDevBoxDefinitionResource ProjectDevBoxDefinitionCollection collection = devCenterProject.GetProjectDevBoxDefinitions(); - // invoke the operation and iterate over the result - await foreach (ProjectDevBoxDefinitionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevBoxDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string devBoxDefinitionName = "WebDevBox"; + ProjectDevBoxDefinitionResource result = await collection.GetAsync(devBoxDefinitionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevBoxDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DevBoxDefinitionsGetByProject() + public async Task GetAll_DevBoxDefinitionsListByProject() { - // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_GetByProject.json - // this example is just showing the usage of "DevBoxDefinitions_GetByProject" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevBoxDefinitions_ListByProject.json + // this example is just showing the usage of "DevBoxDefinitions_ListByProject" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_DevBoxDefinitionsGetByProject() // get the collection of this ProjectDevBoxDefinitionResource ProjectDevBoxDefinitionCollection collection = devCenterProject.GetProjectDevBoxDefinitions(); - // invoke the operation - string devBoxDefinitionName = "WebDevBox"; - ProjectDevBoxDefinitionResource result = await collection.GetAsync(devBoxDefinitionName); + // invoke the operation and iterate over the result + await foreach (ProjectDevBoxDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevBoxDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DevBoxDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index c6e223ba713e1..c076eb3d0f906 100644 --- a/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/devcenter/Azure.ResourceManager.DevCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,68 @@ namespace Azure.ResourceManager.DevCenter.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDevCenters_DevCentersListBySubscription() + { + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/DevCenters_ListBySubscription.json + // this example is just showing the usage of "DevCenters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DevCenterResource item in subscriptionResource.GetDevCentersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDevCenterProjects_ProjectsListBySubscription() + { + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/Projects_ListBySubscription.json + // this example is just showing the usage of "Projects_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DevCenterProjectResource item in subscriptionResource.GetDevCenterProjectsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterProjectData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetDevCenterOperationStatus_GetOperationStatus() @@ -90,7 +152,7 @@ public async Task CheckDevCenterNameAvailability_NameAvailability() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - DevCenterNameAvailabilityContent content = new DevCenterNameAvailabilityContent() + DevCenterNameAvailabilityContent content = new DevCenterNameAvailabilityContent { Name = "name1", ResourceType = new ResourceType("Microsoft.DevCenter/devcenters"), @@ -126,5 +188,36 @@ public async Task GetDevCenterSkusBySubscription_SkusListBySubscription() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDevCenterNetworkConnections_NetworkConnectionsListBySubscription() + { + // Generated from example definition: specification/devcenter/resource-manager/Microsoft.DevCenter/stable/2023-04-01/examples/NetworkConnections_ListBySubscription.json + // this example is just showing the usage of "NetworkConnections_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "0ac520ee-14c0-480f-b6c9-0a90c58ffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DevCenterNetworkConnectionResource item in subscriptionResource.GetDevCenterNetworkConnectionsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DevCenterNetworkConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } From b117bf8ace8fbcc6f21382b7285c3c9d213a324c Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 04:05:51 +0000 Subject: [PATCH 10/11] Update SDK code ad_co_0 --- .../Sample_MetadataEntityCollection.cs | 75 +-- .../Sample_ResourceGroupResourceExtensions.cs | 14 +- ...le_ResourceRecommendationBaseCollection.cs | 77 +-- ...mple_ResourceRecommendationBaseResource.cs | 50 -- .../Sample_SubscriptionResourceExtensions.cs | 94 ++- .../Sample_SuppressionContractCollection.cs | 72 +- .../Sample_SuppressionContractResource.cs | 68 +- ...formPrivateEndpointConnectionCollection.cs | 66 +- ...atformPrivateEndpointConnectionResource.cs | 54 +- ...odPlatformPrivateLinkResourceCollection.cs | 48 +- .../Samples/Sample_ExtensionCollection.cs | 62 +- .../Samples/Sample_ExtensionResource.cs | 28 +- .../Samples/Sample_FarmBeatCollection.cs | 102 +-- .../Samples/Sample_FarmBeatResource.cs | 96 +-- .../Sample_FarmBeatsExtensionCollection.cs | 65 +- .../Sample_SubscriptionResourceExtensions.cs | 35 +- .../Sample_AlertProcessingRuleCollection.cs | 411 +++++------- .../Sample_AlertProcessingRuleResource.cs | 36 +- .../Samples/Sample_ServiceAlertCollection.cs | 54 +- .../Samples/Sample_ServiceAlertResource.cs | 49 -- .../Samples/Sample_SmartGroupCollection.cs | 54 +- .../Sample_SubscriptionResourceExtensions.cs | 77 +++ .../Sample_TenantResourceExtensions.cs | 41 ++ .../Sample_ApiCenterServiceCollection.cs | 92 +-- .../Sample_ApiCenterServiceResource.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ .../Generated/Samples/Sample_ApiCollection.cs | 632 ++++++++---------- .../Samples/Sample_ApiDiagnosticCollection.cs | 176 +++-- .../Samples/Sample_ApiDiagnosticResource.cs | 76 +-- .../Sample_ApiIssueAttachmentCollection.cs | 104 +-- .../Sample_ApiIssueAttachmentResource.cs | 46 +- .../Samples/Sample_ApiIssueCollection.cs | 108 +-- .../Sample_ApiIssueCommentCollection.cs | 104 +-- .../Samples/Sample_ApiIssueCommentResource.cs | 46 +- .../Samples/Sample_ApiIssueResource.cs | 46 +- ...ManagementAuthorizationServerCollection.cs | 137 ++-- ...piManagementAuthorizationServerResource.cs | 50 +- .../Sample_ApiManagementBackendCollection.cs | 208 +++--- .../Sample_ApiManagementBackendResource.cs | 64 +- .../Sample_ApiManagementCacheCollection.cs | 102 +-- .../Sample_ApiManagementCacheResource.cs | 48 +- ...mple_ApiManagementCertificateCollection.cs | 200 +++--- ...Sample_ApiManagementCertificateResource.cs | 76 +-- ...ple_ApiManagementDeletedServiceResource.cs | 32 - ...ample_ApiManagementDiagnosticCollection.cs | 172 +++-- .../Sample_ApiManagementDiagnosticResource.cs | 76 +-- ...le_ApiManagementEmailTemplateCollection.cs | 96 +-- ...mple_ApiManagementEmailTemplateResource.cs | 42 +- ...ntGatewayCertificateAuthorityCollection.cs | 96 +-- ...mentGatewayCertificateAuthorityResource.cs | 46 +- .../Sample_ApiManagementGatewayCollection.cs | 98 +-- ...tGatewayHostnameConfigurationCollection.cs | 106 +-- ...entGatewayHostnameConfigurationResource.cs | 42 +- .../Sample_ApiManagementGatewayResource.cs | 97 ++- ...ple_ApiManagementGlobalSchemaCollection.cs | 246 +++---- ...ample_ApiManagementGlobalSchemaResource.cs | 84 +-- .../Sample_ApiManagementGroupCollection.cs | 136 ++-- .../Sample_ApiManagementGroupResource.cs | 88 +-- ...ApiManagementIdentityProviderCollection.cs | 100 +-- ...e_ApiManagementIdentityProviderResource.cs | 54 +- .../Sample_ApiManagementIssueCollection.cs | 48 +- .../Sample_ApiManagementLoggerCollection.cs | 152 ++--- .../Sample_ApiManagementLoggerResource.cs | 46 +- ...ample_ApiManagementNamedValueCollection.cs | 216 +++--- .../Sample_ApiManagementNamedValueResource.cs | 91 ++- ...ple_ApiManagementNotificationCollection.cs | 90 +-- ...nagementOpenIdConnectProviderCollection.cs | 108 +-- ...ManagementOpenIdConnectProviderResource.cs | 54 +- .../Sample_ApiManagementPolicyCollection.cs | 118 ++-- .../Sample_ApiManagementPolicyResource.cs | 50 +- ...nagementPortalDelegationSettingResource.cs | 56 +- ...e_ApiManagementPortalRevisionCollection.cs | 98 +-- ...ple_ApiManagementPortalRevisionResource.cs | 50 +- ...piManagementPortalSignInSettingResource.cs | 56 +- ...piManagementPortalSignUpSettingResource.cs | 60 +- ...mentPrivateEndpointConnectionCollection.cs | 106 +-- ...gementPrivateEndpointConnectionResource.cs | 48 +- ...ManagementPrivateLinkResourceCollection.cs | 48 +- .../Sample_ApiManagementProductCollection.cs | 98 +-- ...le_ApiManagementProductPolicyCollection.cs | 104 +-- ...mple_ApiManagementProductPolicyResource.cs | 48 +- .../Sample_ApiManagementProductResource.cs | 90 +-- ...ample_ApiManagementProductTagCollection.cs | 98 +-- .../Sample_ApiManagementProductTagResource.cs | 48 +- .../Sample_ApiManagementServiceCollection.cs | 218 +++--- .../Sample_ApiManagementServiceResource.cs | 614 +++++++---------- ...ple_ApiManagementSubscriptionCollection.cs | 102 +-- ...ample_ApiManagementSubscriptionResource.cs | 70 +- .../Sample_ApiManagementTagCollection.cs | 98 +-- .../Sample_ApiManagementTagResource.cs | 46 +- ...le_ApiManagementTenantSettingCollection.cs | 48 +- .../Sample_ApiManagementUserCollection.cs | 104 +-- .../Sample_ApiManagementUserResource.cs | 90 +-- ...ApiManagementUserSubscriptionCollection.cs | 52 +- .../Samples/Sample_ApiOperationCollection.cs | 187 +++--- .../Sample_ApiOperationPolicyCollection.cs | 112 ++-- .../Sample_ApiOperationPolicyResource.cs | 50 +- .../Samples/Sample_ApiOperationResource.cs | 97 ++- .../Sample_ApiOperationTagCollection.cs | 104 +-- .../Samples/Sample_ApiOperationTagResource.cs | 50 +- .../Samples/Sample_ApiPolicyCollection.cs | 140 ++-- .../Samples/Sample_ApiPolicyResource.cs | 50 +- .../Samples/Sample_ApiReleaseCollection.cs | 100 +-- .../Samples/Sample_ApiReleaseResource.cs | 50 +- .../Generated/Samples/Sample_ApiResource.cs | 82 +-- .../Samples/Sample_ApiSchemaCollection.cs | 102 +-- .../Samples/Sample_ApiSchemaResource.cs | 52 +- .../Samples/Sample_ApiTagCollection.cs | 98 +-- .../Sample_ApiTagDescriptionCollection.cs | 108 +-- .../Sample_ApiTagDescriptionResource.cs | 50 +- .../Samples/Sample_ApiTagResource.cs | 46 +- .../Samples/Sample_ApiVersionSetCollection.cs | 102 +-- .../Samples/Sample_ApiVersionSetResource.cs | 46 +- ...orizationAccessPolicyContractCollection.cs | 98 +-- ...thorizationAccessPolicyContractResource.cs | 42 +- .../Sample_AuthorizationContractCollection.cs | 168 ++--- .../Sample_AuthorizationContractResource.cs | 68 +- ...AuthorizationProviderContractCollection.cs | 308 ++++----- ...e_AuthorizationProviderContractResource.cs | 88 +-- .../Sample_DocumentationContractCollection.cs | 98 +-- .../Sample_DocumentationContractResource.cs | 44 +- ...Sample_PolicyFragmentContractCollection.cs | 120 ++-- .../Sample_PolicyFragmentContractResource.cs | 68 +- .../Sample_PortalConfigContractCollection.cs | 147 ++-- .../Sample_PortalConfigContractResource.cs | 77 +-- .../Sample_ResolverContractCollection.cs | 106 +-- .../Sample_ResolverContractResource.cs | 42 +- ...mple_ServiceApiResolverPolicyCollection.cs | 112 ++-- ...Sample_ServiceApiResolverPolicyResource.cs | 50 +- .../Samples/Sample_ServiceApiWikiResource.cs | 84 ++- .../Sample_ServiceProductApiLinkCollection.cs | 100 +-- .../Sample_ServiceProductApiLinkResource.cs | 38 +- ...ample_ServiceProductGroupLinkCollection.cs | 100 +-- .../Sample_ServiceProductGroupLinkResource.cs | 38 +- .../Sample_ServiceProductWikiResource.cs | 84 ++- .../Sample_ServiceTagApiLinkCollection.cs | 96 +-- .../Sample_ServiceTagApiLinkResource.cs | 38 +- ...ample_ServiceTagOperationLinkCollection.cs | 96 +-- .../Sample_ServiceTagOperationLinkResource.cs | 38 +- .../Sample_ServiceTagProductLinkCollection.cs | 96 +-- .../Sample_ServiceTagProductLinkResource.cs | 38 +- .../Sample_ServiceWorkspaceApiCollection.cs | 155 +++-- ..._ServiceWorkspaceApiOperationCollection.cs | 161 ++--- ...ceWorkspaceApiOperationPolicyCollection.cs | 112 ++-- ...viceWorkspaceApiOperationPolicyResource.cs | 50 +- ...le_ServiceWorkspaceApiOperationResource.cs | 85 +-- ...ple_ServiceWorkspaceApiPolicyCollection.cs | 104 +-- ...ample_ServiceWorkspaceApiPolicyResource.cs | 48 +- ...le_ServiceWorkspaceApiReleaseCollection.cs | 100 +-- ...mple_ServiceWorkspaceApiReleaseResource.cs | 50 +- .../Sample_ServiceWorkspaceApiResource.cs | 72 +- ...ple_ServiceWorkspaceApiSchemaCollection.cs | 102 +-- ...ample_ServiceWorkspaceApiSchemaResource.cs | 52 +- ...ServiceWorkspaceApiVersionSetCollection.cs | 102 +-- ...e_ServiceWorkspaceApiVersionSetResource.cs | 46 +- .../Sample_ServiceWorkspaceGroupCollection.cs | 136 ++-- .../Sample_ServiceWorkspaceGroupResource.cs | 90 +-- ...le_ServiceWorkspaceNamedValueCollection.cs | 216 +++--- ...mple_ServiceWorkspaceNamedValueResource.cs | 91 ++- ..._ServiceWorkspaceNotificationCollection.cs | 90 +-- ...Sample_ServiceWorkspacePolicyCollection.cs | 132 ++-- ...erviceWorkspacePolicyFragmentCollection.cs | 120 ++-- ..._ServiceWorkspacePolicyFragmentResource.cs | 68 +- .../Sample_ServiceWorkspacePolicyResource.cs | 44 +- ...erviceWorkspaceProductApiLinkCollection.cs | 100 +-- ..._ServiceWorkspaceProductApiLinkResource.cs | 38 +- ...ample_ServiceWorkspaceProductCollection.cs | 98 +-- ...viceWorkspaceProductGroupLinkCollection.cs | 100 +-- ...erviceWorkspaceProductGroupLinkResource.cs | 38 +- ...ServiceWorkspaceProductPolicyCollection.cs | 104 +-- ...e_ServiceWorkspaceProductPolicyResource.cs | 48 +- .../Sample_ServiceWorkspaceProductResource.cs | 48 +- ...Sample_ServiceWorkspaceSchemaCollection.cs | 100 +-- .../Sample_ServiceWorkspaceSchemaResource.cs | 48 +- ..._ServiceWorkspaceSubscriptionCollection.cs | 102 +-- ...le_ServiceWorkspaceSubscriptionResource.cs | 70 +- ...le_ServiceWorkspaceTagApiLinkCollection.cs | 96 +-- ...mple_ServiceWorkspaceTagApiLinkResource.cs | 38 +- .../Sample_ServiceWorkspaceTagCollection.cs | 98 +-- ...viceWorkspaceTagOperationLinkCollection.cs | 96 +-- ...erviceWorkspaceTagOperationLinkResource.cs | 38 +- ...erviceWorkspaceTagProductLinkCollection.cs | 96 +-- ..._ServiceWorkspaceTagProductLinkResource.cs | 38 +- .../Sample_ServiceWorkspaceTagResource.cs | 46 +- .../Sample_SubscriptionResourceExtensions.cs | 111 +++ .../Sample_TenantAccessInfoCollection.cs | 120 ++-- .../Sample_TenantAccessInfoResource.cs | 56 +- .../Sample_WorkspaceContractCollection.cs | 98 +-- .../Sample_WorkspaceContractResource.cs | 46 +- .../Sample_AppComplianceReportCollection.cs | 67 +- ...e_AppComplianceReportEvidenceCollection.cs | 54 +- .../Sample_AppComplianceReportResource.cs | 32 +- ...nceReportScopingConfigurationCollection.cs | 48 +- ...e_AppComplianceReportSnapshotCollection.cs | 50 +- ...le_AppComplianceReportWebhookCollection.cs | 50 +- ...mple_AppComplianceReportWebhookResource.cs | 30 +- .../Sample_TenantResourceExtensions.cs | 38 +- ...mple_AppConfigurationKeyValueCollection.cs | 82 +-- ...Sample_AppConfigurationKeyValueResource.cs | 48 +- ...tionPrivateEndpointConnectionCollection.cs | 104 +-- ...rationPrivateEndpointConnectionResource.cs | 46 +- ...figurationPrivateLinkResourceCollection.cs | 48 +- ...ample_AppConfigurationReplicaCollection.cs | 96 +-- .../Sample_AppConfigurationReplicaResource.cs | 38 +- .../Sample_AppConfigurationStoreCollection.cs | 184 ++--- .../Sample_AppConfigurationStoreResource.cs | 46 +- ..._DeletedAppConfigurationStoreCollection.cs | 50 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + ..._ApplicationInsightsComponentCollection.cs | 138 ++-- ...le_ApplicationInsightsComponentResource.cs | 122 +--- ...le_ApplicationInsightsWebTestCollection.cs | 292 ++++---- ...mple_ApplicationInsightsWebTestResource.cs | 82 +-- ...e_ApplicationInsightsWorkbookCollection.cs | 292 ++++---- ...ple_ApplicationInsightsWorkbookResource.cs | 65 -- ...ationInsightsWorkbookRevisionCollection.cs | 48 +- ...ationInsightsWorkbookTemplateCollection.cs | 185 ++--- .../Sample_SubscriptionResourceExtensions.cs | 146 ++++ .../Sample_AppPlatformApiPortalCollection.cs | 113 ++-- ...PlatformApiPortalCustomDomainCollection.cs | 90 +-- ...ppPlatformApiPortalCustomDomainResource.cs | 38 +- .../Sample_AppPlatformApiPortalResource.cs | 61 +- .../Sample_AppPlatformAppCollection.cs | 407 ++++++----- .../Samples/Sample_AppPlatformAppResource.cs | 55 +- .../Sample_AppPlatformBindingCollection.cs | 108 +-- .../Sample_AppPlatformBindingResource.cs | 8 +- .../Sample_AppPlatformBuildCollection.cs | 124 ++-- .../Sample_AppPlatformBuildResource.cs | 8 +- ...Sample_AppPlatformBuildResultCollection.cs | 48 +- ...PlatformBuildServiceAgentPoolCollection.cs | 108 +-- ...ppPlatformBuildServiceAgentPoolResource.cs | 6 +- ...ample_AppPlatformBuildServiceCollection.cs | 48 +- .../Sample_AppPlatformBuilderCollection.cs | 126 ++-- .../Sample_AppPlatformBuilderResource.cs | 74 +- ...e_AppPlatformBuildpackBindingCollection.cs | 122 ++-- ...ple_AppPlatformBuildpackBindingResource.cs | 68 +- ...Sample_AppPlatformCertificateCollection.cs | 100 +-- .../Sample_AppPlatformCertificateResource.cs | 44 +- .../Sample_AppPlatformConfigServerResource.cs | 34 +- ...pPlatformConfigurationServiceCollection.cs | 102 ++- ...AppPlatformConfigurationServiceResource.cs | 60 +- ...ample_AppPlatformCustomDomainCollection.cs | 98 +-- .../Sample_AppPlatformCustomDomainResource.cs | 4 +- .../Sample_AppPlatformDeploymentCollection.cs | 400 ++++++----- .../Sample_AppPlatformDeploymentResource.cs | 32 +- .../Sample_AppPlatformGatewayCollection.cs | 118 ++-- ...ppPlatformGatewayCustomDomainCollection.cs | 90 +-- ..._AppPlatformGatewayCustomDomainResource.cs | 38 +- .../Sample_AppPlatformGatewayResource.cs | 62 +- ...AppPlatformGatewayRouteConfigCollection.cs | 123 ++-- ...e_AppPlatformGatewayRouteConfigResource.cs | 71 +- ...le_AppPlatformMonitoringSettingResource.cs | 24 +- .../Sample_AppPlatformServiceCollection.cs | 222 +++--- ...le_AppPlatformServiceRegistryCollection.cs | 82 +-- ...mple_AppPlatformServiceRegistryResource.cs | 30 +- .../Sample_AppPlatformServiceResource.cs | 69 +- .../Sample_AppPlatformStorageCollection.cs | 94 +-- .../Sample_AppPlatformStorageResource.cs | 38 +- ...AppPlatformSupportedBuildpackCollection.cs | 48 +- ...ple_AppPlatformSupportedStackCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 57 ++ .../Sample_TenantResourceExtensions.cs | 5 +- .../Sample_ScVmmAvailabilitySetCollection.cs | 98 +-- .../Sample_ScVmmAvailabilitySetResource.cs | 36 +- .../Samples/Sample_ScVmmCloudCollection.cs | 98 +-- .../Samples/Sample_ScVmmCloudResource.cs | 36 +- .../Samples/Sample_ScVmmGuestAgentResource.cs | 50 +- .../Sample_ScVmmInventoryItemCollection.cs | 62 +- .../Sample_ScVmmInventoryItemResource.cs | 40 +- .../Samples/Sample_ScVmmServerCollection.cs | 106 +-- .../Samples/Sample_ScVmmServerResource.cs | 36 +- ...ple_ScVmmVirtualMachineInstanceResource.cs | 76 +-- ...e_ScVmmVirtualMachineTemplateCollection.cs | 98 +-- ...ple_ScVmmVirtualMachineTemplateResource.cs | 36 +- .../Sample_ScVmmVirtualNetworkCollection.cs | 98 +-- .../Sample_ScVmmVirtualNetworkResource.cs | 36 +- .../Sample_SubscriptionResourceExtensions.cs | 174 +++++ .../Sample_AstroOrganizationCollection.cs | 169 +++-- .../Sample_AstroOrganizationResource.cs | 97 +-- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ ...tionPrivateEndpointConnectionCollection.cs | 112 ++-- ...tationPrivateEndpointConnectionResource.cs | 54 +- .../Sample_AttestationProviderCollection.cs | 114 ++-- .../Sample_AttestationProviderResource.cs | 132 +--- .../Sample_SubscriptionResourceExtensions.cs | 110 +++ .../Samples/Sample_ArmClientExtensions.cs | 42 ++ ...ionProviderOperationsMetadataCollection.cs | 75 +-- ...e_AuthorizationRoleDefinitionCollection.cs | 114 ++-- ...ple_AuthorizationRoleDefinitionResource.cs | 18 +- .../Sample_DenyAssignmentCollection.cs | 80 +-- .../Sample_RoleAssignmentCollection.cs | 198 +++--- .../Samples/Sample_RoleAssignmentResource.cs | 42 +- ...Sample_RoleAssignmentScheduleCollection.cs | 82 +-- ...oleAssignmentScheduleInstanceCollection.cs | 74 +- ...RoleAssignmentScheduleRequestCollection.cs | 92 +-- ...e_RoleAssignmentScheduleRequestResource.cs | 48 +- ...ample_RoleEligibilityScheduleCollection.cs | 82 +-- ...leEligibilityScheduleInstanceCollection.cs | 74 +- ...oleEligibilityScheduleRequestCollection.cs | 92 +-- ..._RoleEligibilityScheduleRequestResource.cs | 46 +- ...oleManagementPolicyAssignmentCollection.cs | 124 ++-- ..._RoleManagementPolicyAssignmentResource.cs | 2 +- .../Sample_RoleManagementPolicyCollection.cs | 80 +-- .../Sample_RoleManagementPolicyResource.cs | 498 ++++---------- .../Sample_TenantResourceExtensions.cs | 5 +- ...Sample_AutomanageBestPracticeCollection.cs | 75 +-- ...utomanageConfigurationProfileCollection.cs | 66 +- ..._AutomanageConfigurationProfileResource.cs | 38 +- ...geConfigurationProfileVersionCollection.cs | 66 +- ...nageConfigurationProfileVersionResource.cs | 84 +-- ...onfigurationProfileAssignmentCollection.cs | 99 ++- ...rationProfileAssignmentReportCollection.cs | 62 +- ...rConfigurationProfileAssignmentResource.cs | 52 +- ...onfigurationProfileAssignmentCollection.cs | 99 ++- ...rationProfileAssignmentReportCollection.cs | 62 +- ...pConfigurationProfileAssignmentResource.cs | 52 +- ...onfigurationProfileAssignmentCollection.cs | 99 ++- ...rationProfileAssignmentReportCollection.cs | 62 +- ...mConfigurationProfileAssignmentResource.cs | 52 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Sample_AutomationAccountCollection.cs | 64 +- ...ample_AutomationAccountModuleCollection.cs | 94 +-- .../Sample_AutomationAccountModuleResource.cs | 100 +-- ...tomationAccountPython2PackageCollection.cs | 102 ++- ...AutomationAccountPython2PackageResource.cs | 34 +- .../Sample_AutomationAccountResource.cs | 222 +++--- .../Sample_AutomationCertificateCollection.cs | 98 +-- .../Sample_AutomationCertificateResource.cs | 30 +- .../Sample_AutomationConnectionCollection.cs | 136 ++-- .../Sample_AutomationConnectionResource.cs | 32 +- ...mple_AutomationConnectionTypeCollection.cs | 160 ++--- ...Sample_AutomationConnectionTypeResource.cs | 32 +- .../Sample_AutomationCredentialCollection.cs | 126 ++-- .../Sample_AutomationCredentialResource.cs | 34 +- .../Samples/Sample_AutomationJobCollection.cs | 106 +-- .../Samples/Sample_AutomationJobResource.cs | 98 +-- .../Sample_AutomationJobScheduleCollection.cs | 110 +-- .../Sample_AutomationJobScheduleResource.cs | 34 +- ...tionPrivateEndpointConnectionCollection.cs | 104 +-- ...mationPrivateEndpointConnectionResource.cs | 46 +- .../Sample_AutomationRunbookCollection.cs | 174 ++--- .../Sample_AutomationRunbookResource.cs | 112 ++-- .../Sample_AutomationScheduleCollection.cs | 90 +-- .../Sample_AutomationScheduleResource.cs | 48 +- ...ample_AutomationSourceControlCollection.cs | 66 +- .../Sample_AutomationSourceControlResource.cs | 42 +- .../Sample_AutomationVariableCollection.cs | 88 +-- .../Sample_AutomationVariableResource.cs | 26 +- .../Sample_AutomationWatcherCollection.cs | 74 +- .../Sample_AutomationWatcherResource.cs | 38 +- .../Sample_AutomationWebhookCollection.cs | 96 +-- .../Sample_AutomationWebhookResource.cs | 30 +- .../Sample_DscCompilationJobCollection.cs | 64 +- .../Sample_DscCompilationJobResource.cs | 26 +- .../Sample_DscConfigurationCollection.cs | 158 ++--- .../Sample_DscConfigurationResource.cs | 32 +- .../Samples/Sample_DscNodeCollection.cs | 144 ++-- .../Sample_DscNodeConfigurationCollection.cs | 160 ++--- .../Sample_DscNodeConfigurationResource.cs | 40 +- .../Samples/Sample_DscNodeResource.cs | 38 +- .../Sample_HybridRunbookWorkerCollection.cs | 90 +-- ...mple_HybridRunbookWorkerGroupCollection.cs | 90 +-- ...Sample_HybridRunbookWorkerGroupResource.cs | 38 +- .../Sample_HybridRunbookWorkerResource.cs | 40 +- ...e_SoftwareUpdateConfigurationCollection.cs | 172 ++--- ...ple_SoftwareUpdateConfigurationResource.cs | 194 +++--- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Samples/Sample_AvsCloudLinkCollection.cs | 96 +-- .../Samples/Sample_AvsCloudLinkResource.cs | 38 +- .../Sample_AvsPrivateCloudAddonCollection.cs | 360 +++++----- .../Sample_AvsPrivateCloudAddonResource.cs | 66 +- ...Sample_AvsPrivateCloudClusterCollection.cs | 96 +-- .../Sample_AvsPrivateCloudClusterResource.cs | 38 +- ...ateCloudClusterVirtualMachineCollection.cs | 48 +- ...ivateCloudClusterVirtualMachineResource.cs | 2 +- .../Sample_AvsPrivateCloudCollection.cs | 236 ++++--- ...mple_AvsPrivateCloudDatastoreCollection.cs | 96 +-- ...Sample_AvsPrivateCloudDatastoreResource.cs | 38 +- .../Samples/Sample_AvsPrivateCloudResource.cs | 121 +--- ...ple_ExpressRouteAuthorizationCollection.cs | 92 +-- ...ample_ExpressRouteAuthorizationResource.cs | 32 +- .../Sample_GlobalReachConnectionCollection.cs | 98 +-- .../Sample_GlobalReachConnectionResource.cs | 40 +- .../Sample_HcxEnterpriseSiteCollection.cs | 92 +-- .../Sample_HcxEnterpriseSiteResource.cs | 32 +- .../Samples/Sample_IscsiPathResource.cs | 38 +- .../Sample_PlacementPolicyCollection.cs | 108 ++- .../Samples/Sample_PlacementPolicyResource.cs | 52 +- .../Samples/Sample_ScriptCmdletCollection.cs | 48 +- .../Sample_ScriptExecutionCollection.cs | 128 ++-- .../Samples/Sample_ScriptExecutionResource.cs | 75 +-- .../Samples/Sample_ScriptPackageCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 62 ++ .../Sample_WorkloadNetworkDhcpCollection.cs | 108 +-- .../Sample_WorkloadNetworkDhcpResource.cs | 48 +- ...ple_WorkloadNetworkDnsServiceCollection.cs | 109 ++- ...ample_WorkloadNetworkDnsServiceResource.cs | 51 +- ...Sample_WorkloadNetworkDnsZoneCollection.cs | 109 ++- .../Sample_WorkloadNetworkDnsZoneResource.cs | 51 +- ...Sample_WorkloadNetworkGatewayCollection.cs | 48 +- ...adNetworkPortMirroringProfileCollection.cs | 104 +-- ...loadNetworkPortMirroringProfileResource.cs | 44 +- ...ample_WorkloadNetworkPublicIPCollection.cs | 98 +-- .../Sample_WorkloadNetworkPublicIPResource.cs | 40 +- ...Sample_WorkloadNetworkSegmentCollection.cs | 113 ++-- .../Sample_WorkloadNetworkSegmentResource.cs | 53 +- ...WorkloadNetworkVirtualMachineCollection.cs | 48 +- ...Sample_WorkloadNetworkVmGroupCollection.cs | 103 ++- .../Sample_WorkloadNetworkVmGroupResource.cs | 43 +- .../Samples/Sample_LargeInstanceCollection.cs | 48 +- .../Samples/Sample_LargeInstanceResource.cs | 32 - .../Sample_LargeStorageInstanceCollection.cs | 48 +- .../Sample_LargeStorageInstanceResource.cs | 32 - .../Sample_SubscriptionResourceExtensions.cs | 81 +++ .../Samples/Sample_ArcExtensionCollection.cs | 119 ++-- .../Samples/Sample_ArcExtensionResource.cs | 65 +- .../Samples/Sample_ArcSettingCollection.cs | 92 +-- .../Samples/Sample_ArcSettingResource.cs | 55 +- .../Samples/Sample_HciClusterCollection.cs | 102 +-- ...e_HciClusterDeploymentSettingCollection.cs | 399 +++++------ ...ple_HciClusterDeploymentSettingResource.cs | 169 ++--- .../Sample_HciClusterOfferCollection.cs | 48 +- .../Sample_HciClusterPublisherCollection.cs | 48 +- .../Samples/Sample_HciClusterResource.cs | 95 +-- ...ple_HciClusterSecuritySettingCollection.cs | 100 +-- ...ample_HciClusterSecuritySettingResource.cs | 42 +- .../Sample_HciClusterUpdateCollection.cs | 81 ++- .../Sample_HciClusterUpdateResource.cs | 37 +- .../Sample_HciClusterUpdateRunCollection.cs | 87 ++- .../Sample_HciClusterUpdateRunResource.cs | 77 +-- .../Sample_HciClusterUpdateSummaryResource.cs | 56 +- .../Samples/Sample_HciEdgeDeviceCollection.cs | 158 ++--- .../Samples/Sample_HciEdgeDeviceResource.cs | 73 +- .../Samples/Sample_HciSkuCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 50 ++ ...ample_BatchAccountCertificateCollection.cs | 194 +++--- .../Sample_BatchAccountCertificateResource.cs | 54 +- .../Samples/Sample_BatchAccountCollection.cs | 78 +-- .../Sample_BatchAccountDetectorCollection.cs | 48 +- .../Sample_BatchAccountPoolCollection.cs | 584 ++++++++-------- .../Sample_BatchAccountPoolResource.cs | 185 +++-- .../Samples/Sample_BatchAccountResource.cs | 84 +-- .../Sample_BatchApplicationCollection.cs | 64 +- ...ample_BatchApplicationPackageCollection.cs | 62 +- .../Sample_BatchApplicationPackageResource.cs | 50 +- .../Sample_BatchApplicationResource.cs | 30 +- ...atchPrivateEndpointConnectionCollection.cs | 48 +- ..._BatchPrivateEndpointConnectionResource.cs | 48 +- ...mple_BatchPrivateLinkResourceCollection.cs | 48 +- ...ecurityPerimeterConfigurationCollection.cs | 48 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Sample_BillingAccountCollection.cs | 435 ++++++------ ...e_BillingAccountPaymentMethodCollection.cs | 48 +- .../Sample_BillingAccountPolicyResource.cs | 6 +- .../Samples/Sample_BillingAccountResource.cs | 334 +++++---- .../Sample_BillingAgreementCollection.cs | 64 +- ...ample_BillingAssociatedTenantCollection.cs | 102 +-- .../Sample_BillingAssociatedTenantResource.cs | 32 +- .../Sample_BillingCustomerCollection.cs | 92 +-- .../Sample_BillingCustomerPolicyResource.cs | 2 +- .../Samples/Sample_BillingCustomerResource.cs | 62 +- ...BillingCustomerRoleAssignmentCollection.cs | 66 +- ...e_BillingCustomerRoleAssignmentResource.cs | 36 +- ...BillingCustomerRoleDefinitionCollection.cs | 62 +- .../Sample_BillingDepartmentCollection.cs | 62 +- ...ngDepartmentEnrollmentAccountCollection.cs | 64 +- .../Sample_BillingDepartmentResource.cs | 65 +- ...llingDepartmentRoleAssignmentCollection.cs | 112 ++-- ...BillingDepartmentRoleAssignmentResource.cs | 38 +- ...llingDepartmentRoleDefinitionCollection.cs | 62 +- ...mple_BillingEnrollmentAccountCollection.cs | 64 +- ...Sample_BillingEnrollmentAccountResource.cs | 67 +- ...rollmentAccountRoleAssignmentCollection.cs | 112 ++-- ...EnrollmentAccountRoleAssignmentResource.cs | 38 +- ...rollmentAccountRoleDefinitionCollection.cs | 62 +- .../Sample_BillingInvoiceCollection.cs | 64 +- .../Samples/Sample_BillingInvoiceResource.cs | 56 +- .../Sample_BillingInvoiceSectionCollection.cs | 112 ++-- .../Sample_BillingInvoiceSectionResource.cs | 216 +++--- ...gInvoiceSectionRoleAssignmentCollection.cs | 62 +- ...ingInvoiceSectionRoleAssignmentResource.cs | 28 +- ...gInvoiceSectionRoleDefinitionCollection.cs | 62 +- .../Sample_BillingPaymentMethodCollection.cs | 65 +- ...mple_BillingPaymentMethodLinkCollection.cs | 48 +- .../Sample_BillingPaymentMethodResource.cs | 28 +- .../Sample_BillingProductCollection.cs | 64 +- .../Samples/Sample_BillingProductResource.cs | 100 +-- .../Sample_BillingProfileCollection.cs | 175 +++-- ...Sample_BillingProfileCustomerCollection.cs | 64 +- .../Sample_BillingProfileCustomerResource.cs | 78 +-- .../Sample_BillingProfilePolicyResource.cs | 4 +- .../Samples/Sample_BillingProfileResource.cs | 229 ++++--- ..._BillingProfileRoleAssignmentCollection.cs | 62 +- ...le_BillingProfileRoleAssignmentResource.cs | 32 +- ..._BillingProfileRoleDefinitionCollection.cs | 62 +- ...le_BillingProfileSubscriptionCollection.cs | 100 +-- .../Samples/Sample_BillingPropertyResource.cs | 8 +- .../Sample_BillingRequestCollection.cs | 167 +++-- .../Samples/Sample_BillingRequestResource.cs | 6 +- .../Sample_BillingReservationCollection.cs | 184 ++--- ...ample_BillingReservationOrderCollection.cs | 76 +-- .../Sample_BillingReservationResource.cs | 2 +- .../Sample_BillingRoleAssignmentCollection.cs | 108 +-- .../Sample_BillingRoleAssignmentResource.cs | 30 +- .../Sample_BillingRoleDefinitionCollection.cs | 62 +- ...ample_BillingSavingsPlanModelCollection.cs | 96 +-- .../Sample_BillingSavingsPlanModelResource.cs | 23 +- ...mple_BillingSubscriptionAliasCollection.cs | 100 +-- ...Sample_BillingSubscriptionAliasResource.cs | 2 +- .../Sample_BillingSubscriptionCollection.cs | 64 +- .../Sample_BillingSubscriptionResource.cs | 186 +++--- .../Sample_BillingTransferDetailCollection.cs | 90 +-- .../Sample_BillingTransferDetailResource.cs | 2 +- .../Sample_DefaultBillingInvoiceCollection.cs | 13 +- .../Sample_PartnerTransferDetailCollection.cs | 90 +-- .../Sample_PartnerTransferDetailResource.cs | 2 +- ...ample_RecipientTransferDetailCollection.cs | 75 +-- .../Sample_RecipientTransferDetailResource.cs | 78 +-- .../Sample_SavingsPlanOrderModelCollection.cs | 76 +-- ...le_SubscriptionBillingInvoiceCollection.cs | 79 +-- ...mple_SubscriptionBillingInvoiceResource.cs | 36 +- .../Sample_TenantResourceExtensions.cs | 18 +- .../Samples/Sample_AssignmentCollection.cs | 180 ++--- .../Sample_AssignmentOperationCollection.cs | 144 ++-- .../Sample_BlueprintArtifactCollection.cs | 508 +++++++------- .../Sample_BlueprintArtifactResource.cs | 450 +++++++------ .../Samples/Sample_BlueprintCollection.cs | 222 +++--- .../Samples/Sample_BlueprintResource.cs | 220 +++--- ...mple_BlueprintVersionArtifactCollection.cs | 330 ++++----- .../Sample_PublishedBlueprintCollection.cs | 64 +- .../Sample_PublishedBlueprintResource.cs | 56 +- .../Samples/Sample_BotChannelCollection.cs | 216 +++--- .../Samples/Sample_BotChannelResource.cs | 150 ++--- .../Generated/Samples/Sample_BotCollection.cs | 69 +- .../Sample_BotConnectionSettingCollection.cs | 73 +- .../Sample_BotConnectionSettingResource.cs | 89 +-- .../Generated/Samples/Sample_BotResource.cs | 136 +--- ...vicePrivateEndpointConnectionCollection.cs | 112 ++-- ...ervicePrivateEndpointConnectionResource.cs | 54 +- .../Sample_SubscriptionResourceExtensions.cs | 60 +- .../Sample_TenantResourceExtensions.cs | 45 ++ .../Sample_CdnCustomDomainCollection.cs | 96 +-- .../Samples/Sample_CdnCustomDomainResource.cs | 38 +- .../Samples/Sample_CdnEndpointCollection.cs | 92 +-- .../Samples/Sample_CdnEndpointResource.cs | 54 +- .../Samples/Sample_CdnOriginCollection.cs | 114 ++-- .../Sample_CdnOriginGroupCollection.cs | 131 ++-- .../Samples/Sample_CdnOriginGroupResource.cs | 61 +- .../Samples/Sample_CdnOriginResource.cs | 54 +- ...nWebApplicationFirewallPolicyCollection.cs | 250 +++---- ...CdnWebApplicationFirewallPolicyResource.cs | 48 +- .../Sample_FrontDoorCustomDomainCollection.cs | 106 +-- .../Sample_FrontDoorCustomDomainResource.cs | 46 +- .../Sample_FrontDoorEndpointCollection.cs | 92 +-- .../Sample_FrontDoorEndpointResource.cs | 52 +- .../Sample_FrontDoorOriginCollection.cs | 104 +-- .../Sample_FrontDoorOriginGroupCollection.cs | 122 ++-- .../Sample_FrontDoorOriginGroupResource.cs | 60 +- .../Samples/Sample_FrontDoorOriginResource.cs | 44 +- .../Sample_FrontDoorRouteCollection.cs | 161 ++--- .../Samples/Sample_FrontDoorRouteResource.cs | 91 ++- .../Samples/Sample_FrontDoorRuleCollection.cs | 123 ++-- .../Samples/Sample_FrontDoorRuleResource.cs | 49 +- .../Sample_FrontDoorRuleSetCollection.cs | 90 +-- .../Sample_FrontDoorRuleSetResource.cs | 30 +- .../Sample_FrontDoorSecretCollection.cs | 110 +-- .../Samples/Sample_FrontDoorSecretResource.cs | 52 +- ...ample_FrontDoorSecurityPolicyCollection.cs | 133 ++-- .../Sample_FrontDoorSecurityPolicyResource.cs | 75 +-- .../Samples/Sample_ProfileCollection.cs | 96 +-- .../Samples/Sample_ProfileResource.cs | 308 +++------ .../Sample_ResourceGroupResourceExtensions.cs | 64 ++ .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Sample_TenantResourceExtensions.cs | 9 +- .../Sample_ChaosCapabilityCollection.cs | 92 +-- .../Sample_ChaosCapabilityTypeCollection.cs | 48 +- .../Sample_ChaosExperimentCollection.cs | 132 ++-- ...mple_ChaosExperimentExecutionCollection.cs | 48 +- .../Samples/Sample_ChaosExperimentResource.cs | 67 +- .../Samples/Sample_ChaosTargetCollection.cs | 108 +-- .../Samples/Sample_ChaosTargetResource.cs | 12 +- .../Sample_ChaosTargetTypeCollection.cs | 50 +- .../Sample_SubscriptionResourceExtensions.cs | 51 ++ 582 files changed, 25241 insertions(+), 26609 deletions(-) create mode 100644 sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_TenantResourceExtensions.cs create mode 100644 sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_ArmClientExtensions.cs create mode 100644 sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_TenantResourceExtensions.cs create mode 100644 sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs diff --git a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_MetadataEntityCollection.cs b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_MetadataEntityCollection.cs index 75f5108a0bb69..8bb0cf2afc061 100644 --- a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_MetadataEntityCollection.cs +++ b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_MetadataEntityCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Advisor.Samples @@ -27,9 +28,7 @@ public async Task Get_GetMetadata() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this MetadataEntityResource MetadataEntityCollection collection = tenantResource.GetMetadataEntities(); @@ -45,6 +44,36 @@ public async Task Get_GetMetadata() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetMetadata() + { + // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListRecommendationMetadata.json + // this example is just showing the usage of "RecommendationMetadata_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this MetadataEntityResource + MetadataEntityCollection collection = tenantResource.GetMetadataEntities(); + + // invoke the operation and iterate over the result + await foreach (MetadataEntityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetadataEntityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetMetadata() @@ -57,9 +86,7 @@ public async Task Exists_GetMetadata() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this MetadataEntityResource MetadataEntityCollection collection = tenantResource.GetMetadataEntities(); @@ -83,9 +110,7 @@ public async Task GetIfExists_GetMetadata() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this MetadataEntityResource MetadataEntityCollection collection = tenantResource.GetMetadataEntities(); @@ -108,37 +133,5 @@ public async Task GetIfExists_GetMetadata() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetMetadata() - { - // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListRecommendationMetadata.json - // this example is just showing the usage of "RecommendationMetadata_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this MetadataEntityResource - MetadataEntityCollection collection = tenantResource.GetMetadataEntities(); - - // invoke the operation and iterate over the result - await foreach (MetadataEntityResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetadataEntityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index e1a479956fc02..1f023adff750d 100644 --- a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -66,25 +66,19 @@ public async Task CreateConfiguration_PutConfigurations() // invoke the operation ConfigurationName configurationName = ConfigurationName.Default; - ConfigData data = new ConfigData() + ConfigData data = new ConfigData { Exclude = true, LowCpuThreshold = CpuThreshold.Five, - Digests = -{ -new DigestConfig() + Digests = {new DigestConfig { Name = "digestConfigName", ActionGroupResourceId = "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/microsoft.insights/actionGroups/actionGroupName", Frequency = 30, -Categories = -{ -Category.HighAvailability,Category.Security,Category.Performance,Category.Cost,Category.OperationalExcellence -}, +Categories = {Category.HighAvailability, Category.Security, Category.Performance, Category.Cost, Category.OperationalExcellence}, Language = "en", State = DigestConfigState.Active, -} -}, +}}, }; ConfigData result = await resourceGroupResource.CreateConfigurationAsync(configurationName, data); diff --git a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceRecommendationBaseCollection.cs b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceRecommendationBaseCollection.cs index 1897d5f9539cd..79832c00dd3f0 100644 --- a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceRecommendationBaseCollection.cs +++ b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceRecommendationBaseCollection.cs @@ -15,6 +15,33 @@ namespace Azure.ResourceManager.Advisor.Samples { public partial class Sample_ResourceRecommendationBaseCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetRecommendationDetail() + { + // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetRecommendationDetail.json + // this example is just showing the usage of "Recommendations_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ResourceRecommendationBaseResource + string resourceUri = "resourceUri"; + ResourceRecommendationBaseCollection collection = client.GetResourceRecommendationBases(new ResourceIdentifier(resourceUri)); + + // invoke the operation + string recommendationId = "recommendationId"; + ResourceRecommendationBaseResource result = await collection.GetAsync(recommendationId); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResourceRecommendationBaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListRecommendations() @@ -27,13 +54,10 @@ public async Task GetAll_ListRecommendations() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ResourceRecommendationBaseResource string subscriptionId = "subscriptionId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}", subscriptionId)); - ResourceRecommendationBaseCollection collection = client.GetResourceRecommendationBases(scopeId); + string scope = $"/subscriptions/{subscriptionId}"; + ResourceRecommendationBaseCollection collection = client.GetResourceRecommendationBases(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result int? top = 10; @@ -49,37 +73,6 @@ public async Task GetAll_ListRecommendations() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetRecommendationDetail() - { - // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetRecommendationDetail.json - // this example is just showing the usage of "Recommendations_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ResourceRecommendationBaseResource - string resourceUri = "resourceUri"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ResourceRecommendationBaseCollection collection = client.GetResourceRecommendationBases(scopeId); - - // invoke the operation - string recommendationId = "recommendationId"; - ResourceRecommendationBaseResource result = await collection.GetAsync(recommendationId); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResourceRecommendationBaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetRecommendationDetail() @@ -92,13 +85,9 @@ public async Task Exists_GetRecommendationDetail() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ResourceRecommendationBaseResource string resourceUri = "resourceUri"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ResourceRecommendationBaseCollection collection = client.GetResourceRecommendationBases(scopeId); + ResourceRecommendationBaseCollection collection = client.GetResourceRecommendationBases(new ResourceIdentifier(resourceUri)); // invoke the operation string recommendationId = "recommendationId"; @@ -119,13 +108,9 @@ public async Task GetIfExists_GetRecommendationDetail() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ResourceRecommendationBaseResource string resourceUri = "resourceUri"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - ResourceRecommendationBaseCollection collection = client.GetResourceRecommendationBases(scopeId); + ResourceRecommendationBaseCollection collection = client.GetResourceRecommendationBases(new ResourceIdentifier(resourceUri)); // invoke the operation string recommendationId = "recommendationId"; diff --git a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceRecommendationBaseResource.cs b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceRecommendationBaseResource.cs index 38c55d0a5364f..12eb284d414ce 100644 --- a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceRecommendationBaseResource.cs +++ b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_ResourceRecommendationBaseResource.cs @@ -9,62 +9,12 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Advisor.Samples { public partial class Sample_ResourceRecommendationBaseResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GenerateRecommendation_GenerateRecommendations() - { - // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GenerateRecommendations.json - // this example is just showing the usage of "Recommendations_Generate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subscriptionId"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - await subscriptionResource.GenerateRecommendationAsync(); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetGenerateStatusRecommendation_GetGenerateStatus() - { - // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/EmptyResponse.json - // this example is just showing the usage of "Recommendations_GetGenerateStatus" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subscriptionId"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - Guid operationId = Guid.Parse("operationGUID"); - await subscriptionResource.GetGenerateStatusRecommendationAsync(operationId); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetRecommendationDetail() diff --git a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 9a15d0c7415cc..b5a0c01b288b4 100644 --- a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -64,29 +64,103 @@ public async Task CreateConfiguration_PutConfigurations() // invoke the operation ConfigurationName configurationName = ConfigurationName.Default; - ConfigData data = new ConfigData() + ConfigData data = new ConfigData { Exclude = true, LowCpuThreshold = CpuThreshold.Five, - Digests = -{ -new DigestConfig() + Digests = {new DigestConfig { Name = "digestConfigName", ActionGroupResourceId = "/subscriptions/subscriptionId/resourceGroups/resourceGroup/providers/microsoft.insights/actionGroups/actionGroupName", Frequency = 30, -Categories = -{ -Category.HighAvailability,Category.Security,Category.Performance,Category.Cost,Category.OperationalExcellence -}, +Categories = {Category.HighAvailability, Category.Security, Category.Performance, Category.Cost, Category.OperationalExcellence}, Language = "en", State = DigestConfigState.Active, -} -}, +}}, }; ConfigData result = await subscriptionResource.CreateConfigurationAsync(configurationName, data); Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GenerateRecommendation_GenerateRecommendations() + { + // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GenerateRecommendations.json + // this example is just showing the usage of "Recommendations_Generate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subscriptionId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + await subscriptionResource.GenerateRecommendationAsync(); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetGenerateStatusRecommendation_GetGenerateStatus() + { + // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/EmptyResponse.json + // this example is just showing the usage of "Recommendations_GetGenerateStatus" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subscriptionId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + Guid operationId = Guid.Parse("operationGUID"); + await subscriptionResource.GetGenerateStatusRecommendationAsync(operationId); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSuppressionContracts_ListSuppressions() + { + // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListSuppressions.json + // this example is just showing the usage of "Suppressions_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subscriptionId1"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SuppressionContractResource item in subscriptionResource.GetSuppressionContractsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SuppressionContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SuppressionContractCollection.cs b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SuppressionContractCollection.cs index dac3676594403..fdde51a0bf426 100644 --- a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SuppressionContractCollection.cs +++ b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SuppressionContractCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SuppressionContractCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSuppressionDetail() + public async Task CreateOrUpdate_CreateSuppression() { - // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetSuppressionDetail.json - // this example is just showing the usage of "Suppressions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/CreateSuppression.json + // this example is just showing the usage of "Suppressions_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,7 +39,12 @@ public async Task Get_GetSuppressionDetail() // invoke the operation string name = "suppressionName1"; - SuppressionContractResource result = await collection.GetAsync(name); + SuppressionContractData data = new SuppressionContractData + { + Ttl = "07:00:00:00", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + SuppressionContractResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,7 +55,7 @@ public async Task Get_GetSuppressionDetail() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSuppressionDetail() + public async Task Get_GetSuppressionDetail() { // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetSuppressionDetail.json // this example is just showing the usage of "Suppressions_Get" operation, for the dependent resources, they will have to be created separately. @@ -72,14 +77,18 @@ public async Task Exists_GetSuppressionDetail() // invoke the operation string name = "suppressionName1"; - bool result = await collection.ExistsAsync(name); + SuppressionContractResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SuppressionContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSuppressionDetail() + public async Task Exists_GetSuppressionDetail() { // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetSuppressionDetail.json // this example is just showing the usage of "Suppressions_Get" operation, for the dependent resources, they will have to be created separately. @@ -101,29 +110,17 @@ public async Task GetIfExists_GetSuppressionDetail() // invoke the operation string name = "suppressionName1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - SuppressionContractResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SuppressionContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSuppression() + public async Task GetIfExists_GetSuppressionDetail() { - // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/CreateSuppression.json - // this example is just showing the usage of "Suppressions_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/GetSuppressionDetail.json + // this example is just showing the usage of "Suppressions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,18 +139,21 @@ public async Task CreateOrUpdate_CreateSuppression() // invoke the operation string name = "suppressionName1"; - SuppressionContractData data = new SuppressionContractData() - { - Ttl = "07:00:00:00", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - SuppressionContractResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + SuppressionContractResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SuppressionContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SuppressionContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SuppressionContractResource.cs b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SuppressionContractResource.cs index 626a50330cc81..f4759b2de36a0 100644 --- a/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SuppressionContractResource.cs +++ b/sdk/advisor/Azure.ResourceManager.Advisor/samples/Generated/Samples/Sample_SuppressionContractResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Advisor.Samples @@ -48,10 +47,10 @@ public async Task Get_GetSuppressionDetail() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateSuppression() + public async Task Delete_DeleteSuppression() { - // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/CreateSuppression.json - // this example is just showing the usage of "Suppressions_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/DeleteSuppression.json + // this example is just showing the usage of "Suppressions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,26 +66,17 @@ public async Task Update_CreateSuppression() SuppressionContractResource suppressionContract = client.GetSuppressionContractResource(suppressionContractResourceId); // invoke the operation - SuppressionContractData data = new SuppressionContractData() - { - Ttl = "07:00:00:00", - }; - ArmOperation lro = await suppressionContract.UpdateAsync(WaitUntil.Completed, data); - SuppressionContractResource result = lro.Value; + await suppressionContract.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SuppressionContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSuppression() + public async Task Update_CreateSuppression() { - // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/DeleteSuppression.json - // this example is just showing the usage of "Suppressions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/CreateSuppression.json + // this example is just showing the usage of "Suppressions_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,40 +92,18 @@ public async Task Delete_DeleteSuppression() SuppressionContractResource suppressionContract = client.GetSuppressionContractResource(suppressionContractResourceId); // invoke the operation - await suppressionContract.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSuppressionContracts_ListSuppressions() - { - // Generated from example definition: specification/advisor/resource-manager/Microsoft.Advisor/stable/2020-01-01/examples/ListSuppressions.json - // this example is just showing the usage of "Suppressions_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subscriptionId1"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SuppressionContractResource item in subscriptionResource.GetSuppressionContractsAsync()) + SuppressionContractData data = new SuppressionContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SuppressionContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Ttl = "07:00:00:00", + }; + ArmOperation lro = await suppressionContract.UpdateAsync(WaitUntil.Completed, data); + SuppressionContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SuppressionContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateEndpointConnectionCollection.cs b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateEndpointConnectionCollection.cs index eb411a271a1f3..55598e23245f2 100644 --- a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateEndpointConnectionCollection.cs +++ b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateEndpointConnectionCollection.cs @@ -41,9 +41,9 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionsCreateOrUpdate() // invoke the operation string privateEndpointConnectionName = "privateEndpointConnectionName"; - AgFoodPlatformPrivateEndpointConnectionData data = new AgFoodPlatformPrivateEndpointConnectionData() + AgFoodPlatformPrivateEndpointConnectionData data = new AgFoodPlatformPrivateEndpointConnectionData { - ConnectionState = new AgFoodPlatformPrivateLinkServiceConnectionState() + ConnectionState = new AgFoodPlatformPrivateLinkServiceConnectionState { Status = AgFoodPlatformPrivateEndpointServiceConnectionStatus.Approved, Description = "Approved by johndoe@contoso.com", @@ -95,10 +95,10 @@ public async Task Get_PrivateEndpointConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionsGet() + public async Task GetAll_PrivateEndpointConnectionsListByResource() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_ListByResource.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,16 +116,22 @@ public async Task Exists_PrivateEndpointConnectionsGet() // get the collection of this AgFoodPlatformPrivateEndpointConnectionResource AgFoodPlatformPrivateEndpointConnectionCollection collection = farmBeat.GetAgFoodPlatformPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "privateEndpointConnectionName"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (AgFoodPlatformPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgFoodPlatformPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionsGet() + public async Task Exists_PrivateEndpointConnectionsGet() { // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_Get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +154,17 @@ public async Task GetIfExists_PrivateEndpointConnectionsGet() // invoke the operation string privateEndpointConnectionName = "privateEndpointConnectionName"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - AgFoodPlatformPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AgFoodPlatformPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionsListByResource() + public async Task GetIfExists_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_ListByResource.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_PrivateEndpointConnectionsListByResource() // get the collection of this AgFoodPlatformPrivateEndpointConnectionResource AgFoodPlatformPrivateEndpointConnectionCollection collection = farmBeat.GetAgFoodPlatformPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (AgFoodPlatformPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "privateEndpointConnectionName"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + AgFoodPlatformPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AgFoodPlatformPrivateEndpointConnectionData resourceData = item.Data; + AgFoodPlatformPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateEndpointConnectionResource.cs b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateEndpointConnectionResource.cs index 19c98e661a1d1..73e950c795146 100644 --- a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateEndpointConnectionResource.cs +++ b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AgFoodPlatformPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionsCreateOrUpdate() + public async Task Get_PrivateEndpointConnectionsGet() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_CreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_Get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,7 @@ public async Task Update_PrivateEndpointConnectionsCreateOrUpdate() AgFoodPlatformPrivateEndpointConnectionResource agFoodPlatformPrivateEndpointConnection = client.GetAgFoodPlatformPrivateEndpointConnectionResource(agFoodPlatformPrivateEndpointConnectionResourceId); // invoke the operation - AgFoodPlatformPrivateEndpointConnectionData data = new AgFoodPlatformPrivateEndpointConnectionData() - { - ConnectionState = new AgFoodPlatformPrivateLinkServiceConnectionState() - { - Status = AgFoodPlatformPrivateEndpointServiceConnectionStatus.Approved, - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await agFoodPlatformPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - AgFoodPlatformPrivateEndpointConnectionResource result = lro.Value; + AgFoodPlatformPrivateEndpointConnectionResource result = await agFoodPlatformPrivateEndpointConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +49,10 @@ public async Task Update_PrivateEndpointConnectionsCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateEndpointConnectionsGet() + public async Task Delete_PrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_Get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_Delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,21 +69,17 @@ public async Task Get_PrivateEndpointConnectionsGet() AgFoodPlatformPrivateEndpointConnectionResource agFoodPlatformPrivateEndpointConnection = client.GetAgFoodPlatformPrivateEndpointConnectionResource(agFoodPlatformPrivateEndpointConnectionResourceId); // invoke the operation - AgFoodPlatformPrivateEndpointConnectionResource result = await agFoodPlatformPrivateEndpointConnection.GetAsync(); + await agFoodPlatformPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AgFoodPlatformPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDelete() + public async Task Update_PrivateEndpointConnectionsCreateOrUpdate() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_Delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateEndpointConnections_CreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_PrivateEndpointConnectionsDelete() AgFoodPlatformPrivateEndpointConnectionResource agFoodPlatformPrivateEndpointConnection = client.GetAgFoodPlatformPrivateEndpointConnectionResource(agFoodPlatformPrivateEndpointConnectionResourceId); // invoke the operation - await agFoodPlatformPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + AgFoodPlatformPrivateEndpointConnectionData data = new AgFoodPlatformPrivateEndpointConnectionData + { + ConnectionState = new AgFoodPlatformPrivateLinkServiceConnectionState + { + Status = AgFoodPlatformPrivateEndpointServiceConnectionStatus.Approved, + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await agFoodPlatformPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + AgFoodPlatformPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgFoodPlatformPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateLinkResourceCollection.cs b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateLinkResourceCollection.cs index cd4fe9f22289f..8d313d1fb7b8a 100644 --- a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateLinkResourceCollection.cs +++ b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_AgFoodPlatformPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AgFoodPlatformPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesListByResource() + public async Task Get_PrivateLinkResourcesGet() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateLinkResources_ListByResource.json - // this example is just showing the usage of "PrivateLinkResources_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateLinkResources_Get.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_PrivateLinkResourcesListByResource() // get the collection of this AgFoodPlatformPrivateLinkResource AgFoodPlatformPrivateLinkResourceCollection collection = farmBeat.GetAgFoodPlatformPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (AgFoodPlatformPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AgFoodPlatformPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string subResourceName = "farmbeats"; + AgFoodPlatformPrivateLinkResource result = await collection.GetAsync(subResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgFoodPlatformPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkResourcesGet() + public async Task GetAll_PrivateLinkResourcesListByResource() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateLinkResources_Get.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/PrivateLinkResources_ListByResource.json + // this example is just showing the usage of "PrivateLinkResources_ListByResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_PrivateLinkResourcesGet() // get the collection of this AgFoodPlatformPrivateLinkResource AgFoodPlatformPrivateLinkResourceCollection collection = farmBeat.GetAgFoodPlatformPrivateLinkResources(); - // invoke the operation - string subResourceName = "farmbeats"; - AgFoodPlatformPrivateLinkResource result = await collection.GetAsync(subResourceName); + // invoke the operation and iterate over the result + await foreach (AgFoodPlatformPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AgFoodPlatformPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AgFoodPlatformPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_ExtensionCollection.cs b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_ExtensionCollection.cs index 616859f9e725b..a645959eb6e3d 100644 --- a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_ExtensionCollection.cs +++ b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_ExtensionCollection.cs @@ -86,10 +86,10 @@ public async Task Get_ExtensionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExtensionsGet() + public async Task GetAll_ExtensionsListByFarmBeats() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Get.json - // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_ListByFarmBeats.json + // this example is just showing the usage of "Extensions_ListByFarmBeats" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +107,22 @@ public async Task Exists_ExtensionsGet() // get the collection of this ExtensionResource ExtensionCollection collection = farmBeat.GetExtensions(); - // invoke the operation - string extensionId = "provider.extension"; - bool result = await collection.ExistsAsync(extensionId); + // invoke the operation and iterate over the result + await foreach (ExtensionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtensionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExtensionsGet() + public async Task Exists_ExtensionsGet() { // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Get.json // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +145,17 @@ public async Task GetIfExists_ExtensionsGet() // invoke the operation string extensionId = "provider.extension"; - NullableResponse response = await collection.GetIfExistsAsync(extensionId); - ExtensionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(extensionId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExtensionsListByFarmBeats() + public async Task GetIfExists_ExtensionsGet() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_ListByFarmBeats.json - // this example is just showing the usage of "Extensions_ListByFarmBeats" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Get.json + // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_ExtensionsListByFarmBeats() // get the collection of this ExtensionResource ExtensionCollection collection = farmBeat.GetExtensions(); - // invoke the operation and iterate over the result - await foreach (ExtensionResource item in collection.GetAllAsync()) + // invoke the operation + string extensionId = "provider.extension"; + NullableResponse response = await collection.GetIfExistsAsync(extensionId); + ExtensionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExtensionData resourceData = item.Data; + ExtensionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_ExtensionResource.cs b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_ExtensionResource.cs index 21265da9301a0..983c27bfbe802 100644 --- a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_ExtensionResource.cs +++ b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_ExtensionResource.cs @@ -48,10 +48,10 @@ public async Task Get_ExtensionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ExtensionsUpdate() + public async Task Delete_ExtensionsDelete() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Update.json - // this example is just showing the usage of "Extensions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Delete.json + // this example is just showing the usage of "Extensions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,21 +68,17 @@ public async Task Update_ExtensionsUpdate() ExtensionResource extension = client.GetExtensionResource(extensionResourceId); // invoke the operation - ExtensionResource result = await extension.UpdateAsync(); + await extension.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ExtensionsDelete() + public async Task Update_ExtensionsUpdate() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Delete.json - // this example is just showing the usage of "Extensions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/Extensions_Update.json + // this example is just showing the usage of "Extensions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,9 +95,13 @@ public async Task Delete_ExtensionsDelete() ExtensionResource extension = client.GetExtensionResource(extensionResourceId); // invoke the operation - await extension.DeleteAsync(WaitUntil.Completed); + ExtensionResource result = await extension.UpdateAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatCollection.cs b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatCollection.cs index 4c93ba1c98b0a..5e66024cf77b7 100644 --- a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatCollection.cs +++ b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FarmBeatCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FarmBeatsModelsGet() + public async Task CreateOrUpdate_FarmBeatsModelsCreateOrUpdate() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_Get.json - // this example is just showing the usage of "FarmBeatsModels_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_CreateOrUpdate.json + // this example is just showing the usage of "FarmBeatsModels_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,17 @@ public async Task Get_FarmBeatsModelsGet() FarmBeatCollection collection = resourceGroupResource.GetFarmBeats(); // invoke the operation - string farmBeatsResourceName = "examples-farmBeatsResourceName"; - FarmBeatResource result = await collection.GetAsync(farmBeatsResourceName); + string farmBeatsResourceName = "examples-farmbeatsResourceName"; + FarmBeatData data = new FarmBeatData(new AzureLocation("eastus2")) + { + Tags = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, farmBeatsResourceName, data); + FarmBeatResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +60,7 @@ public async Task Get_FarmBeatsModelsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FarmBeatsModelsGet() + public async Task Get_FarmBeatsModelsGet() { // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_Get.json // this example is just showing the usage of "FarmBeatsModels_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +82,21 @@ public async Task Exists_FarmBeatsModelsGet() // invoke the operation string farmBeatsResourceName = "examples-farmBeatsResourceName"; - bool result = await collection.ExistsAsync(farmBeatsResourceName); + FarmBeatResource result = await collection.GetAsync(farmBeatsResourceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FarmBeatData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FarmBeatsModelsGet() + public async Task GetAll_FarmBeatsModelsListByResourceGroup() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_Get.json - // this example is just showing the usage of "FarmBeatsModels_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_ListByResourceGroup.json + // this example is just showing the usage of "FarmBeatsModels_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +113,25 @@ public async Task GetIfExists_FarmBeatsModelsGet() // get the collection of this FarmBeatResource FarmBeatCollection collection = resourceGroupResource.GetFarmBeats(); - // invoke the operation - string farmBeatsResourceName = "examples-farmBeatsResourceName"; - NullableResponse response = await collection.GetIfExistsAsync(farmBeatsResourceName); - FarmBeatResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (FarmBeatResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FarmBeatData resourceData = result.Data; + FarmBeatData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FarmBeatsModelsCreateOrUpdate() + public async Task Exists_FarmBeatsModelsGet() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_CreateOrUpdate.json - // this example is just showing the usage of "FarmBeatsModels_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_Get.json + // this example is just showing the usage of "FarmBeatsModels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,31 +149,18 @@ public async Task CreateOrUpdate_FarmBeatsModelsCreateOrUpdate() FarmBeatCollection collection = resourceGroupResource.GetFarmBeats(); // invoke the operation - string farmBeatsResourceName = "examples-farmbeatsResourceName"; - FarmBeatData data = new FarmBeatData(new AzureLocation("eastus2")) - { - Tags = -{ -["key1"] = "value1", -["key2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, farmBeatsResourceName, data); - FarmBeatResource result = lro.Value; + string farmBeatsResourceName = "examples-farmBeatsResourceName"; + bool result = await collection.ExistsAsync(farmBeatsResourceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FarmBeatData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FarmBeatsModelsListByResourceGroup() + public async Task GetIfExists_FarmBeatsModelsGet() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_ListByResourceGroup.json - // this example is just showing the usage of "FarmBeatsModels_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_Get.json + // this example is just showing the usage of "FarmBeatsModels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_FarmBeatsModelsListByResourceGroup() // get the collection of this FarmBeatResource FarmBeatCollection collection = resourceGroupResource.GetFarmBeats(); - // invoke the operation and iterate over the result - await foreach (FarmBeatResource item in collection.GetAllAsync()) + // invoke the operation + string farmBeatsResourceName = "examples-farmBeatsResourceName"; + NullableResponse response = await collection.GetIfExistsAsync(farmBeatsResourceName); + FarmBeatResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FarmBeatData resourceData = item.Data; + FarmBeatData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatResource.cs b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatResource.cs index 40b5eef44522d..8b738f8f3ba01 100644 --- a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatResource.cs +++ b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.AgFoodPlatform.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AgFoodPlatform.Samples @@ -48,6 +47,32 @@ public async Task Get_FarmBeatsModelsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_FarmBeatsModelsDelete() + { + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_Delete.json + // this example is just showing the usage of "FarmBeatsModels_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this FarmBeatResource created on azure + // for more information of creating FarmBeatResource, please refer to the document of FarmBeatResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + string resourceGroupName = "examples-rg"; + string farmBeatsResourceName = "examples-farmBeatsResourceName"; + ResourceIdentifier farmBeatResourceId = FarmBeatResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, farmBeatsResourceName); + FarmBeatResource farmBeat = client.GetFarmBeatResource(farmBeatResourceId); + + // invoke the operation + await farmBeat.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_FarmBeatsModelsUpdate() @@ -69,12 +94,12 @@ public async Task Update_FarmBeatsModelsUpdate() FarmBeatResource farmBeat = client.GetFarmBeatResource(farmBeatResourceId); // invoke the operation - FarmBeatPatch patch = new FarmBeatPatch() + FarmBeatPatch patch = new FarmBeatPatch { Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, }; ArmOperation lro = await farmBeat.UpdateAsync(WaitUntil.Completed, patch); @@ -108,12 +133,12 @@ public async Task Update_FarmBeatsModelsUpdateWithSensor() FarmBeatResource farmBeat = client.GetFarmBeatResource(farmBeatResourceId); // invoke the operation - FarmBeatPatch patch = new FarmBeatPatch() + FarmBeatPatch patch = new FarmBeatPatch { Identity = new ManagedServiceIdentity("SystemAssigned"), - Properties = new FarmBeatsUpdateProperties() + Properties = new FarmBeatsUpdateProperties { - SensorIntegration = new SensorIntegration() + SensorIntegration = new SensorIntegration { Enabled = "True", }, @@ -121,7 +146,7 @@ public async Task Update_FarmBeatsModelsUpdateWithSensor() Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, }; ArmOperation lro = await farmBeat.UpdateAsync(WaitUntil.Completed, patch); @@ -134,63 +159,6 @@ public async Task Update_FarmBeatsModelsUpdateWithSensor() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_FarmBeatsModelsDelete() - { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_Delete.json - // this example is just showing the usage of "FarmBeatsModels_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this FarmBeatResource created on azure - // for more information of creating FarmBeatResource, please refer to the document of FarmBeatResource - string subscriptionId = "11111111-2222-3333-4444-555555555555"; - string resourceGroupName = "examples-rg"; - string farmBeatsResourceName = "examples-farmBeatsResourceName"; - ResourceIdentifier farmBeatResourceId = FarmBeatResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, farmBeatsResourceName); - FarmBeatResource farmBeat = client.GetFarmBeatResource(farmBeatResourceId); - - // invoke the operation - await farmBeat.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetFarmBeats_FarmBeatsModelsListBySubscription() - { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_ListBySubscription.json - // this example is just showing the usage of "FarmBeatsModels_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "11111111-2222-3333-4444-555555555555"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (FarmBeatResource item in subscriptionResource.GetFarmBeatsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FarmBeatData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetOperationResult_FarmBeatsModelsGetOperationResult() diff --git a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatsExtensionCollection.cs b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatsExtensionCollection.cs index 418e08dbc0b6c..a06c12d38a234 100644 --- a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatsExtensionCollection.cs +++ b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_FarmBeatsExtensionCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AgFoodPlatform.Samples @@ -17,64 +18,60 @@ public partial class Sample_FarmBeatsExtensionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FarmBeatsExtensionsList() + public async Task Get_FarmBeatsExtensionsGet() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsExtensions_List.json - // this example is just showing the usage of "FarmBeatsExtensions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsExtensions_Get.json + // this example is just showing the usage of "FarmBeatsExtensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this FarmBeatsExtensionResource FarmBeatsExtensionCollection collection = tenantResource.GetFarmBeatsExtensions(); - // invoke the operation and iterate over the result - await foreach (FarmBeatsExtensionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FarmBeatsExtensionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string farmBeatsExtensionId = "DTN.ContentServices"; + FarmBeatsExtensionResource result = await collection.GetAsync(farmBeatsExtensionId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FarmBeatsExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FarmBeatsExtensionsGet() + public async Task GetAll_FarmBeatsExtensionsList() { - // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsExtensions_Get.json - // this example is just showing the usage of "FarmBeatsExtensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsExtensions_List.json + // this example is just showing the usage of "FarmBeatsExtensions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this FarmBeatsExtensionResource FarmBeatsExtensionCollection collection = tenantResource.GetFarmBeatsExtensions(); - // invoke the operation - string farmBeatsExtensionId = "DTN.ContentServices"; - FarmBeatsExtensionResource result = await collection.GetAsync(farmBeatsExtensionId); + // invoke the operation and iterate over the result + await foreach (FarmBeatsExtensionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FarmBeatsExtensionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FarmBeatsExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -89,9 +86,7 @@ public async Task Exists_FarmBeatsExtensionsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this FarmBeatsExtensionResource FarmBeatsExtensionCollection collection = tenantResource.GetFarmBeatsExtensions(); @@ -115,9 +110,7 @@ public async Task GetIfExists_FarmBeatsExtensionsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this FarmBeatsExtensionResource FarmBeatsExtensionCollection collection = tenantResource.GetFarmBeatsExtensions(); diff --git a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 1316581d803e1..9a9211dedade9 100644 --- a/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/agrifood/Azure.ResourceManager.AgFoodPlatform/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.AgFoodPlatform.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetFarmBeats_FarmBeatsModelsListBySubscription() + { + // Generated from example definition: specification/agrifood/resource-manager/Microsoft.AgFoodPlatform/preview/2021-09-01-preview/examples/FarmBeatsModels_ListBySubscription.json + // this example is just showing the usage of "FarmBeatsModels_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "11111111-2222-3333-4444-555555555555"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (FarmBeatResource item in subscriptionResource.GetFarmBeatsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FarmBeatData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CheckNameAvailabilityLocation_LocationsCheckNameAvailabilityAlreadyExists() @@ -36,7 +67,7 @@ public async Task CheckNameAvailabilityLocation_LocationsCheckNameAvailabilityAl SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - CheckNameAvailabilityContent content = new CheckNameAvailabilityContent() + CheckNameAvailabilityContent content = new CheckNameAvailabilityContent { Name = "existingaccountname", ResourceType = "Microsoft.AgFoodPlatform/farmBeats", @@ -65,7 +96,7 @@ public async Task CheckNameAvailabilityLocation_LocationsCheckNameAvailabilityAv SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - CheckNameAvailabilityContent content = new CheckNameAvailabilityContent() + CheckNameAvailabilityContent content = new CheckNameAvailabilityContent { Name = "newaccountname", ResourceType = "Microsoft.AgFoodPlatform/farmBeats", diff --git a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_AlertProcessingRuleCollection.cs b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_AlertProcessingRuleCollection.cs index cc6ef2b038389..91c2ff650e674 100644 --- a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_AlertProcessingRuleCollection.cs +++ b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_AlertProcessingRuleCollection.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AlertsManagement.Models; @@ -17,144 +18,6 @@ namespace Azure.ResourceManager.AlertsManagement.Samples { public partial class Sample_AlertProcessingRuleCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAlertProcessingRulesResourceGroupWide() - { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_List_ResourceGroup.json - // this example is just showing the usage of "AlertProcessingRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; - string resourceGroupName = "alertscorrelationrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this AlertProcessingRuleResource - AlertProcessingRuleCollection collection = resourceGroupResource.GetAlertProcessingRules(); - - // invoke the operation and iterate over the result - await foreach (AlertProcessingRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AlertProcessingRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAlertProcessingRuleById() - { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_GetById.json - // this example is just showing the usage of "AlertProcessingRules_GetByName" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; - string resourceGroupName = "alertscorrelationrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this AlertProcessingRuleResource - AlertProcessingRuleCollection collection = resourceGroupResource.GetAlertProcessingRules(); - - // invoke the operation - string alertProcessingRuleName = "DailySuppression"; - AlertProcessingRuleResource result = await collection.GetAsync(alertProcessingRuleName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AlertProcessingRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAlertProcessingRuleById() - { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_GetById.json - // this example is just showing the usage of "AlertProcessingRules_GetByName" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; - string resourceGroupName = "alertscorrelationrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this AlertProcessingRuleResource - AlertProcessingRuleCollection collection = resourceGroupResource.GetAlertProcessingRules(); - - // invoke the operation - string alertProcessingRuleName = "DailySuppression"; - bool result = await collection.ExistsAsync(alertProcessingRuleName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAlertProcessingRuleById() - { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_GetById.json - // this example is just showing the usage of "AlertProcessingRules_GetByName" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; - string resourceGroupName = "alertscorrelationrg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this AlertProcessingRuleResource - AlertProcessingRuleCollection collection = resourceGroupResource.GetAlertProcessingRules(); - - // invoke the operation - string alertProcessingRuleName = "DailySuppression"; - NullableResponse response = await collection.GetIfExistsAsync(alertProcessingRuleName); - AlertProcessingRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AlertProcessingRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateARuleThatAddsAnActionGroupToAllAlertsInASubscription() @@ -181,23 +44,15 @@ public async Task CreateOrUpdate_CreateOrUpdateARuleThatAddsAnActionGroupToAllAl string alertProcessingRuleName = "AddActionGroupToSubscription"; AlertProcessingRuleData data = new AlertProcessingRuleData(new AzureLocation("Global")) { - Properties = new AlertProcessingRuleProperties(new string[] + Properties = new AlertProcessingRuleProperties(new string[] { "/subscriptions/subId1" }, new AlertProcessingRuleAction[] { -"/subscriptions/subId1" - }, new AlertProcessingRuleAction[] - { -new AlertProcessingRuleAddGroupsAction(new ResourceIdentifier[] -{ -new ResourceIdentifier("/subscriptions/subId1/resourcegroups/RGId1/providers/microsoft.insights/actiongroups/ActionGroup1") -}) +new AlertProcessingRuleAddGroupsAction(new ResourceIdentifier[]{new ResourceIdentifier("/subscriptions/subId1/resourcegroups/RGId1/providers/microsoft.insights/actiongroups/ActionGroup1")}) }) { Description = "Add ActionGroup1 to all alerts in the subscription", IsEnabled = true, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertProcessingRuleName, data); AlertProcessingRuleResource result = lro.Value; @@ -235,35 +90,21 @@ public async Task CreateOrUpdate_CreateOrUpdateARuleThatAddsTwoActionGroupsToAll string alertProcessingRuleName = "AddActionGroupsBySeverity"; AlertProcessingRuleData data = new AlertProcessingRuleData(new AzureLocation("Global")) { - Properties = new AlertProcessingRuleProperties(new string[] + Properties = new AlertProcessingRuleProperties(new string[] { "/subscriptions/subId1/resourceGroups/RGId1", "/subscriptions/subId1/resourceGroups/RGId2" }, new AlertProcessingRuleAction[] { -"/subscriptions/subId1/resourceGroups/RGId1","/subscriptions/subId1/resourceGroups/RGId2" - }, new AlertProcessingRuleAction[] - { -new AlertProcessingRuleAddGroupsAction(new ResourceIdentifier[] -{ -new ResourceIdentifier("/subscriptions/subId1/resourcegroups/RGId1/providers/microsoft.insights/actiongroups/AGId1"),new ResourceIdentifier("/subscriptions/subId1/resourcegroups/RGId1/providers/microsoft.insights/actiongroups/AGId2") -}) +new AlertProcessingRuleAddGroupsAction(new ResourceIdentifier[]{new ResourceIdentifier("/subscriptions/subId1/resourcegroups/RGId1/providers/microsoft.insights/actiongroups/AGId1"), new ResourceIdentifier("/subscriptions/subId1/resourcegroups/RGId1/providers/microsoft.insights/actiongroups/AGId2")}) }) { - Conditions = -{ -new AlertProcessingRuleCondition() + Conditions = {new AlertProcessingRuleCondition { Field = AlertProcessingRuleField.Severity, Operator = AlertProcessingRuleOperator.EqualsValue, -Values = -{ -"sev0","sev1" -}, -} -}, +Values = {"sev0", "sev1"}, +}}, Description = "Add AGId1 and AGId2 to all Sev0 and Sev1 alerts in these resourceGroups", IsEnabled = true, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertProcessingRuleName, data); AlertProcessingRuleResource result = lro.Value; @@ -301,15 +142,12 @@ public async Task CreateOrUpdate_CreateOrUpdateARuleThatRemovesAllActionGroupsFr string alertProcessingRuleName = "RemoveActionGroupsMaintenanceWindow"; AlertProcessingRuleData data = new AlertProcessingRuleData(new AzureLocation("Global")) { - Properties = new AlertProcessingRuleProperties(new string[] - { -"/subscriptions/subId1/resourceGroups/RGId1/providers/Microsoft.Compute/virtualMachines/VMName" - }, new AlertProcessingRuleAction[] + Properties = new AlertProcessingRuleProperties(new string[] { "/subscriptions/subId1/resourceGroups/RGId1/providers/Microsoft.Compute/virtualMachines/VMName" }, new AlertProcessingRuleAction[] { new AlertProcessingRuleRemoveAllGroupsAction() }) { - Schedule = new AlertProcessingRuleSchedule() + Schedule = new AlertProcessingRuleSchedule { EffectiveFrom = DateTimeOffset.Parse("2021-04-15T18:00:00"), EffectiveUntil = DateTimeOffset.Parse("2021-04-15T20:00:00"), @@ -318,9 +156,7 @@ public async Task CreateOrUpdate_CreateOrUpdateARuleThatRemovesAllActionGroupsFr Description = "Removes all ActionGroups from all Alerts on VMName during the maintenance window", IsEnabled = true, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertProcessingRuleName, data); AlertProcessingRuleResource result = lro.Value; @@ -358,32 +194,21 @@ public async Task CreateOrUpdate_CreateOrUpdateARuleThatRemovesAllActionGroupsFr string alertProcessingRuleName = "RemoveActionGroupsSpecificAlertRule"; AlertProcessingRuleData data = new AlertProcessingRuleData(new AzureLocation("Global")) { - Properties = new AlertProcessingRuleProperties(new string[] - { -"/subscriptions/subId1" - }, new AlertProcessingRuleAction[] + Properties = new AlertProcessingRuleProperties(new string[] { "/subscriptions/subId1" }, new AlertProcessingRuleAction[] { new AlertProcessingRuleRemoveAllGroupsAction() }) { - Conditions = -{ -new AlertProcessingRuleCondition() + Conditions = {new AlertProcessingRuleCondition { Field = AlertProcessingRuleField.AlertRuleId, Operator = AlertProcessingRuleOperator.EqualsValue, -Values = -{ -"/subscriptions/suubId1/resourceGroups/Rgid2/providers/microsoft.insights/activityLogAlerts/RuleName" -}, -} -}, +Values = {"/subscriptions/suubId1/resourceGroups/Rgid2/providers/microsoft.insights/activityLogAlerts/RuleName"}, +}}, Description = "Removes all ActionGroups from all Alerts that fire on above AlertRule", IsEnabled = true, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertProcessingRuleName, data); AlertProcessingRuleResource result = lro.Value; @@ -421,47 +246,30 @@ public async Task CreateOrUpdate_CreateOrUpdateARuleThatRemovesAllActionGroupsFr string alertProcessingRuleName = "RemoveActionGroupsRecurringMaintenance"; AlertProcessingRuleData data = new AlertProcessingRuleData(new AzureLocation("Global")) { - Properties = new AlertProcessingRuleProperties(new string[] - { -"/subscriptions/subId1/resourceGroups/RGId1","/subscriptions/subId1/resourceGroups/RGId2" - }, new AlertProcessingRuleAction[] + Properties = new AlertProcessingRuleProperties(new string[] { "/subscriptions/subId1/resourceGroups/RGId1", "/subscriptions/subId1/resourceGroups/RGId2" }, new AlertProcessingRuleAction[] { new AlertProcessingRuleRemoveAllGroupsAction() }) { - Conditions = -{ -new AlertProcessingRuleCondition() + Conditions = {new AlertProcessingRuleCondition { Field = AlertProcessingRuleField.TargetResourceType, Operator = AlertProcessingRuleOperator.EqualsValue, -Values = -{ -"microsoft.compute/virtualmachines" -}, -} -}, - Schedule = new AlertProcessingRuleSchedule() +Values = {"microsoft.compute/virtualmachines"}, +}}, + Schedule = new AlertProcessingRuleSchedule { TimeZone = "India Standard Time", - Recurrences = -{ -new AlertProcessingRuleWeeklyRecurrence(new AlertsManagementDayOfWeek[] -{ -AlertsManagementDayOfWeek.Saturday,AlertsManagementDayOfWeek.Sunday -}) + Recurrences = {new AlertProcessingRuleWeeklyRecurrence(new AlertsManagementDayOfWeek[]{AlertsManagementDayOfWeek.Saturday, AlertsManagementDayOfWeek.Sunday}) { -StartOn = TimeSpan.Parse("22:00:00"), -EndOn = TimeSpan.Parse("04:00:00"), -} -}, +StartOn = XmlConvert.ToTimeSpan("22:00:00"), +EndOn = XmlConvert.ToTimeSpan("04:00:00"), +}}, }, Description = "Remove all ActionGroups from all Vitual machine Alerts during the recurring maintenance", IsEnabled = true, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertProcessingRuleName, data); AlertProcessingRuleResource result = lro.Value; @@ -499,35 +307,24 @@ public async Task CreateOrUpdate_CreateOrUpdateARuleThatRemovesAllActionGroupsOu string alertProcessingRuleName = "RemoveActionGroupsOutsideBusinessHours"; AlertProcessingRuleData data = new AlertProcessingRuleData(new AzureLocation("Global")) { - Properties = new AlertProcessingRuleProperties(new string[] - { -"/subscriptions/subId1" - }, new AlertProcessingRuleAction[] + Properties = new AlertProcessingRuleProperties(new string[] { "/subscriptions/subId1" }, new AlertProcessingRuleAction[] { new AlertProcessingRuleRemoveAllGroupsAction() }) { - Schedule = new AlertProcessingRuleSchedule() + Schedule = new AlertProcessingRuleSchedule { TimeZone = "Eastern Standard Time", - Recurrences = -{ -new DailyRecurrence() -{ -StartOn = TimeSpan.Parse("17:00:00"), -EndOn = TimeSpan.Parse("09:00:00"), -},new AlertProcessingRuleWeeklyRecurrence(new AlertsManagementDayOfWeek[] + Recurrences = {new DailyRecurrence { -AlertsManagementDayOfWeek.Saturday,AlertsManagementDayOfWeek.Sunday -}) -}, +StartOn = XmlConvert.ToTimeSpan("17:00:00"), +EndOn = XmlConvert.ToTimeSpan("09:00:00"), +}, new AlertProcessingRuleWeeklyRecurrence(new AlertsManagementDayOfWeek[]{AlertsManagementDayOfWeek.Saturday, AlertsManagementDayOfWeek.Sunday})}, }, Description = "Remove all ActionGroups outside business hours", IsEnabled = true, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, alertProcessingRuleName, data); AlertProcessingRuleResource result = lro.Value; @@ -538,5 +335,143 @@ public async Task CreateOrUpdate_CreateOrUpdateARuleThatRemovesAllActionGroupsOu // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAlertProcessingRuleById() + { + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_GetById.json + // this example is just showing the usage of "AlertProcessingRules_GetByName" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; + string resourceGroupName = "alertscorrelationrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AlertProcessingRuleResource + AlertProcessingRuleCollection collection = resourceGroupResource.GetAlertProcessingRules(); + + // invoke the operation + string alertProcessingRuleName = "DailySuppression"; + AlertProcessingRuleResource result = await collection.GetAsync(alertProcessingRuleName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertProcessingRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetAlertProcessingRulesResourceGroupWide() + { + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_List_ResourceGroup.json + // this example is just showing the usage of "AlertProcessingRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; + string resourceGroupName = "alertscorrelationrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AlertProcessingRuleResource + AlertProcessingRuleCollection collection = resourceGroupResource.GetAlertProcessingRules(); + + // invoke the operation and iterate over the result + await foreach (AlertProcessingRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertProcessingRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetAlertProcessingRuleById() + { + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_GetById.json + // this example is just showing the usage of "AlertProcessingRules_GetByName" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; + string resourceGroupName = "alertscorrelationrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AlertProcessingRuleResource + AlertProcessingRuleCollection collection = resourceGroupResource.GetAlertProcessingRules(); + + // invoke the operation + string alertProcessingRuleName = "DailySuppression"; + bool result = await collection.ExistsAsync(alertProcessingRuleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetAlertProcessingRuleById() + { + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_GetById.json + // this example is just showing the usage of "AlertProcessingRules_GetByName" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; + string resourceGroupName = "alertscorrelationrg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AlertProcessingRuleResource + AlertProcessingRuleCollection collection = resourceGroupResource.GetAlertProcessingRules(); + + // invoke the operation + string alertProcessingRuleName = "DailySuppression"; + NullableResponse response = await collection.GetIfExistsAsync(alertProcessingRuleName); + AlertProcessingRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertProcessingRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_AlertProcessingRuleResource.cs b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_AlertProcessingRuleResource.cs index 3c7b356d3ac72..5bc01ea212d06 100644 --- a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_AlertProcessingRuleResource.cs +++ b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_AlertProcessingRuleResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AlertsManagement.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AlertsManagement.Samples { public partial class Sample_AlertProcessingRuleResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAlertProcessingRules_GetAlertProcessingRulesSubscriptionWide() - { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_List_Subscription.json - // this example is just showing the usage of "AlertProcessingRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AlertProcessingRuleResource item in subscriptionResource.GetAlertProcessingRulesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AlertProcessingRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAlertProcessingRuleById() @@ -125,12 +93,12 @@ public async Task Update_PatchAlertProcessingRule() AlertProcessingRuleResource alertProcessingRule = client.GetAlertProcessingRuleResource(alertProcessingRuleResourceId); // invoke the operation - AlertProcessingRulePatch patch = new AlertProcessingRulePatch() + AlertProcessingRulePatch patch = new AlertProcessingRulePatch { Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, IsEnabled = false, }; diff --git a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_ServiceAlertCollection.cs b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_ServiceAlertCollection.cs index 3eacd73395d84..7cbb9eababe22 100644 --- a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_ServiceAlertCollection.cs +++ b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_ServiceAlertCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ServiceAlertCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAlerts() + public async Task Get_GetById() { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_List.json - // this example is just showing the usage of "Alerts_GetAll" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_GetById.json + // this example is just showing the usage of "Alerts_GetById" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,33 +31,30 @@ public async Task GetAll_ListAlerts() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; + string subscriptionId = "9e261de7-c804-4b9d-9ebf-6f50fe350a9a"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this ServiceAlertResource ServiceAlertCollection collection = subscriptionResource.GetServiceAlerts(); - // invoke the operation and iterate over the result - ServiceAlertCollectionGetAllOptions options = new ServiceAlertCollectionGetAllOptions() { }; - await foreach (ServiceAlertResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceAlertData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + Guid alertId = Guid.Parse("66114d64-d9d9-478b-95c9-b789d6502100"); + ServiceAlertResource result = await collection.GetAsync(alertId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetById() + public async Task GetAll_ListAlerts() { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_GetById.json - // this example is just showing the usage of "Alerts_GetById" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_List.json + // this example is just showing the usage of "Alerts_GetAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,22 +63,25 @@ public async Task Get_GetById() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "9e261de7-c804-4b9d-9ebf-6f50fe350a9a"; + string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this ServiceAlertResource ServiceAlertCollection collection = subscriptionResource.GetServiceAlerts(); - // invoke the operation - Guid alertId = Guid.Parse("66114d64-d9d9-478b-95c9-b789d6502100"); - ServiceAlertResource result = await collection.GetAsync(alertId); + // invoke the operation and iterate over the result + ServiceAlertCollectionGetAllOptions options = new ServiceAlertCollectionGetAllOptions(); + await foreach (ServiceAlertResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceAlertData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_ServiceAlertResource.cs b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_ServiceAlertResource.cs index 8f0f2f837b417..58262e3f5218c 100644 --- a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_ServiceAlertResource.cs +++ b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_ServiceAlertResource.cs @@ -10,36 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AlertsManagement.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AlertsManagement.Samples { public partial class Sample_ServiceAlertResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetServiceAlertMetadata_MonService() - { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/AlertsMetaData_MonitorService.json - // this example is just showing the usage of "Alerts_MetaData" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - RetrievedInformationIdentifier identifier = RetrievedInformationIdentifier.MonitorServiceList; - ServiceAlertMetadata result = await tenantResource.GetServiceAlertMetadataAsync(identifier); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetById() @@ -123,30 +99,5 @@ public async Task GetHistory_Resolve() Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetServiceAlertSummary_Summary() - { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_Summary.json - // this example is just showing the usage of "Alerts_GetSummary" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - SubscriptionResourceGetServiceAlertSummaryOptions options = new SubscriptionResourceGetServiceAlertSummaryOptions(groupby: new AlertsSummaryGroupByField("severity,alertState")) { }; - ServiceAlertSummary result = await subscriptionResource.GetServiceAlertSummaryAsync(options); - - Console.WriteLine($"Succeeded: {result}"); - } } } diff --git a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_SmartGroupCollection.cs b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_SmartGroupCollection.cs index 7f99821358901..03794f99005df 100644 --- a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_SmartGroupCollection.cs +++ b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_SmartGroupCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SmartGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_List() + public async Task Get_Get() { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/SmartGroups_List.json - // this example is just showing the usage of "SmartGroups_GetAll" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/SmartGroups_GetById.json + // this example is just showing the usage of "SmartGroups_GetById" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,33 +31,30 @@ public async Task GetAll_List() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "dd91de05-d791-4ceb-b6dc-988682dc7d72"; + string subscriptionId = "9e261de7-c804-4b9d-9ebf-6f50fe350a9a"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this SmartGroupResource SmartGroupCollection collection = subscriptionResource.GetSmartGroups(); - // invoke the operation and iterate over the result - SmartGroupCollectionGetAllOptions options = new SmartGroupCollectionGetAllOptions() { }; - await foreach (SmartGroupResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SmartGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + Guid smartGroupId = Guid.Parse("603675da-9851-4b26-854a-49fc53d32715"); + SmartGroupResource result = await collection.GetAsync(smartGroupId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SmartGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_Get() + public async Task GetAll_List() { - // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/SmartGroups_GetById.json - // this example is just showing the usage of "SmartGroups_GetById" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/SmartGroups_List.json + // this example is just showing the usage of "SmartGroups_GetAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,22 +63,25 @@ public async Task Get_Get() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "9e261de7-c804-4b9d-9ebf-6f50fe350a9a"; + string subscriptionId = "dd91de05-d791-4ceb-b6dc-988682dc7d72"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // get the collection of this SmartGroupResource SmartGroupCollection collection = subscriptionResource.GetSmartGroups(); - // invoke the operation - Guid smartGroupId = Guid.Parse("603675da-9851-4b26-854a-49fc53d32715"); - SmartGroupResource result = await collection.GetAsync(smartGroupId); + // invoke the operation and iterate over the result + SmartGroupCollectionGetAllOptions options = new SmartGroupCollectionGetAllOptions(); + await foreach (SmartGroupResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SmartGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SmartGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..1a2712a53c538 --- /dev/null +++ b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,77 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.AlertsManagement.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.AlertsManagement.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAlertProcessingRules_GetAlertProcessingRulesSubscriptionWide() + { + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/stable/2021-08-08/examples/AlertProcessingRules_List_Subscription.json + // this example is just showing the usage of "AlertProcessingRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AlertProcessingRuleResource item in subscriptionResource.GetAlertProcessingRulesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertProcessingRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetServiceAlertSummary_Summary() + { + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/Alerts_Summary.json + // this example is just showing the usage of "Alerts_GetSummary" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1e3ff1c0-771a-4119-a03b-be82a51e232d"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AlertsSummaryGroupByField groupby = new AlertsSummaryGroupByField("severity,alertState"); + SubscriptionResourceGetServiceAlertSummaryOptions options = new SubscriptionResourceGetServiceAlertSummaryOptions(groupby); + ServiceAlertSummary result = await subscriptionResource.GetServiceAlertSummaryAsync(options); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_TenantResourceExtensions.cs new file mode 100644 index 0000000000000..8ba53dfb59f6f --- /dev/null +++ b/sdk/alertsmanagement/Azure.ResourceManager.AlertsManagement/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.AlertsManagement.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.AlertsManagement.Samples +{ + public partial class Sample_TenantResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetServiceAlertMetadata_MonService() + { + // Generated from example definition: specification/alertsmanagement/resource-manager/Microsoft.AlertsManagement/preview/2019-05-05-preview/examples/AlertsMetaData_MonitorService.json + // this example is just showing the usage of "Alerts_MetaData" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation + RetrievedInformationIdentifier identifier = RetrievedInformationIdentifier.MonitorServiceList; + ServiceAlertMetadata result = await tenantResource.GetServiceAlertMetadataAsync(identifier); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_ApiCenterServiceCollection.cs b/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_ApiCenterServiceCollection.cs index 8ac71f1cbf6e7..9d5d25d2ec1bb 100644 --- a/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_ApiCenterServiceCollection.cs +++ b/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_ApiCenterServiceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiCenterServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServicesListByResourceGroup() + public async Task CreateOrUpdate_ServicesCreate() { - // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_ListByResourceGroup.json - // this example is just showing the usage of "Services_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_CreateOrUpdate.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_ServicesListByResourceGroup() // get the collection of this ApiCenterServiceResource ApiCenterServiceCollection collection = resourceGroupResource.GetApiCenterServices(); - // invoke the operation and iterate over the result - await foreach (ApiCenterServiceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiCenterServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string serviceName = "contoso"; + ApiCenterServiceData data = new ApiCenterServiceData(default); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); + ApiCenterServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiCenterServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +86,10 @@ public async Task Get_ServicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServicesGet() + public async Task GetAll_ServicesListByResourceGroup() { - // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Get.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_ListByResourceGroup.json + // this example is just showing the usage of "Services_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +106,22 @@ public async Task Exists_ServicesGet() // get the collection of this ApiCenterServiceResource ApiCenterServiceCollection collection = resourceGroupResource.GetApiCenterServices(); - // invoke the operation - string serviceName = "contoso"; - bool result = await collection.ExistsAsync(serviceName); + // invoke the operation and iterate over the result + await foreach (ApiCenterServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiCenterServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServicesGet() + public async Task Exists_ServicesGet() { // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Get.json // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +143,17 @@ public async Task GetIfExists_ServicesGet() // invoke the operation string serviceName = "contoso"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - ApiCenterServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiCenterServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServicesCreate() + public async Task GetIfExists_ServicesGet() { - // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_CreateOrUpdate.json - // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Get.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,15 +172,21 @@ public async Task CreateOrUpdate_ServicesCreate() // invoke the operation string serviceName = "contoso"; - ApiCenterServiceData data = new ApiCenterServiceData(new AzureLocation("placeholder")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); - ApiCenterServiceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + ApiCenterServiceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiCenterServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiCenterServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_ApiCenterServiceResource.cs b/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_ApiCenterServiceResource.cs index 77026fbe2a8c6..59ffe374e7ff2 100644 --- a/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_ApiCenterServiceResource.cs +++ b/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_ApiCenterServiceResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ApiCenter.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ApiCenter.Samples { public partial class Sample_ApiCenterServiceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApiCenterServices_ServicesListBySubscription() - { - // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_ListBySubscription.json - // this example is just showing the usage of "Services_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ApiCenterServiceResource item in subscriptionResource.GetApiCenterServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiCenterServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ServicesGet() @@ -80,10 +48,10 @@ public async Task Get_ServicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ServicesUpdate() + public async Task Delete_ServicesDelete() { - // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Update.json - // this example is just showing the usage of "Services_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Delete.json + // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,22 +67,17 @@ public async Task Update_ServicesUpdate() ApiCenterServiceResource apiCenterService = client.GetApiCenterServiceResource(apiCenterServiceResourceId); // invoke the operation - ApiCenterServicePatch patch = new ApiCenterServicePatch(); - ApiCenterServiceResource result = await apiCenterService.UpdateAsync(patch); + await apiCenterService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiCenterServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ServicesDelete() + public async Task Update_ServicesUpdate() { - // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Delete.json - // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_Update.json + // this example is just showing the usage of "Services_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,9 +93,14 @@ public async Task Delete_ServicesDelete() ApiCenterServiceResource apiCenterService = client.GetApiCenterServiceResource(apiCenterServiceResourceId); // invoke the operation - await apiCenterService.DeleteAsync(WaitUntil.Completed); + ApiCenterServicePatch patch = new ApiCenterServicePatch(); + ApiCenterServiceResource result = await apiCenterService.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiCenterServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..d59c0069f3914 --- /dev/null +++ b/sdk/apicenter/Azure.ResourceManager.ApiCenter/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ApiCenter.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApiCenterServices_ServicesListBySubscription() + { + // Generated from example definition: specification/apicenter/resource-manager/Microsoft.ApiCenter/preview/2023-07-01-preview/examples/Services_ListBySubscription.json + // this example is just showing the usage of "Services_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ApiCenterServiceResource item in subscriptionResource.GetApiCenterServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiCenterServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiCollection.cs index 4207ac2458f6e..05aa2d71ef3b1 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiCollection.cs @@ -16,254 +16,6 @@ namespace Azure.ResourceManager.ApiManagement.Samples { public partial class Sample_ApiCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApis() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApis.json - // this example is just showing the usage of "Api_ListByService" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // get the collection of this ApiResource - ApiCollection collection = apiManagementService.GetApis(); - - // invoke the operation and iterate over the result - await foreach (ApiResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiContract() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiContract.json - // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // get the collection of this ApiResource - ApiCollection collection = apiManagementService.GetApis(); - - // invoke the operation - string apiId = "57d1f7558aa04f15146d9d8a"; - ApiResource result = await collection.GetAsync(apiId); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiContract() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiContract.json - // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // get the collection of this ApiResource - ApiCollection collection = apiManagementService.GetApis(); - - // invoke the operation - string apiId = "57d1f7558aa04f15146d9d8a"; - bool result = await collection.ExistsAsync(apiId); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiContract() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiContract.json - // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // get the collection of this ApiResource - ApiCollection collection = apiManagementService.GetApis(); - - // invoke the operation - string apiId = "57d1f7558aa04f15146d9d8a"; - NullableResponse response = await collection.GetIfExistsAsync(apiId); - ApiResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiRevisionContract() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRevision.json - // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // get the collection of this ApiResource - ApiCollection collection = apiManagementService.GetApis(); - - // invoke the operation - string apiId = "echo-api;rev=3"; - ApiResource result = await collection.GetAsync(apiId); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiRevisionContract() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRevision.json - // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // get the collection of this ApiResource - ApiCollection collection = apiManagementService.GetApis(); - - // invoke the operation - string apiId = "echo-api;rev=3"; - bool result = await collection.ExistsAsync(apiId); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiRevisionContract() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRevision.json - // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // get the collection of this ApiResource - ApiCollection collection = apiManagementService.GetApis(); - - // invoke the operation - string apiId = "echo-api;rev=3"; - NullableResponse response = await collection.GetIfExistsAsync(apiId); - ApiResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_ApiManagementCreateApi() @@ -289,18 +41,18 @@ public async Task CreateOrUpdate_ApiManagementCreateApi() // invoke the operation string apiId = "tempgroup"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Description = "apidescription5200", - AuthenticationSettings = new AuthenticationSettingsContract() + AuthenticationSettings = new AuthenticationSettingsContract { - OAuth2 = new OAuth2AuthenticationSettingsContract() + OAuth2 = new OAuth2AuthenticationSettingsContract { AuthorizationServerId = "authorizationServerId2283", Scope = "oauth2scope2580", }, }, - SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract() + SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract { Header = "header4520", Query = "query3037", @@ -308,10 +60,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApi() DisplayName = "apiname1463", ServiceLink = "http://newechoapi.cloudapp.net/api", Path = "newapiPath", - Protocols = -{ -ApiOperationInvokableProtocol.Https,ApiOperationInvokableProtocol.Http -}, + Protocols = { ApiOperationInvokableProtocol.Https, ApiOperationInvokableProtocol.Http }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId, content); ApiResource result = lro.Value; @@ -348,7 +97,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiClone() // invoke the operation string apiId = "echo-api2"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Description = "Copy of Existing Echo Api including Operations.", IsCurrent = true, @@ -357,10 +106,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiClone() DisplayName = "Echo API2", ServiceLink = "http://echoapi.cloudapp.net/api", Path = "echo2", - Protocols = -{ -ApiOperationInvokableProtocol.Http,ApiOperationInvokableProtocol.Https -}, + Protocols = { ApiOperationInvokableProtocol.Http, ApiOperationInvokableProtocol.Https }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId, content); ApiResource result = lro.Value; @@ -397,7 +143,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiNewVersionUsingExistingAp // invoke the operation string apiId = "echoapiv3"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Description = "Create Echo API into a new Version using Existing Version Set and Copy all Operations.", ApiVersion = "v4", @@ -408,10 +154,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiNewVersionUsingExistingAp DisplayName = "Echo API2", ServiceLink = "http://echoapi.cloudapp.net/api", Path = "echo2", - Protocols = -{ -ApiOperationInvokableProtocol.Http,ApiOperationInvokableProtocol.Https -}, + Protocols = { ApiOperationInvokableProtocol.Http, ApiOperationInvokableProtocol.Https }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId, content); ApiResource result = lro.Value; @@ -448,7 +191,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiRevisionFromExistingApi() // invoke the operation string apiId = "echo-api;rev=3"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { ApiRevisionDescription = "Creating a Revision of an existing API", SourceApiId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api"), @@ -490,7 +233,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiUsingImportOverrideServic // invoke the operation string apiId = "apidocs"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { ServiceLink = "http://petstore.swagger.wordnik.com/api", Path = "petstoreapi123", @@ -532,7 +275,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiUsingOai3Import() // invoke the operation string apiId = "petstore"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Path = "petstore", Value = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml", @@ -573,7 +316,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiUsingOai3ImportWithTransl // invoke the operation string apiId = "petstore"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Path = "petstore", Value = "https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml", @@ -615,7 +358,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiUsingSwaggerImport() // invoke the operation string apiId = "petstore"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Path = "petstore", Value = "http://petstore.swagger.io/v2/swagger.json", @@ -656,7 +399,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiUsingWadlImport() // invoke the operation string apiId = "petstore"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Path = "collector", Value = "https://developer.cisco.com/media/wae-release-6-2-api-reference/wae-collector-rest-api/application.wadl", @@ -697,25 +440,22 @@ public async Task CreateOrUpdate_ApiManagementCreateApiWithMultipleAuthServers() // invoke the operation string apiId = "tempgroup"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Description = "apidescription5200", - AuthenticationSettings = new AuthenticationSettingsContract() + AuthenticationSettings = new AuthenticationSettingsContract { - OAuth2AuthenticationSettings = -{ -new OAuth2AuthenticationSettingsContract() + OAuth2AuthenticationSettings = {new OAuth2AuthenticationSettingsContract { AuthorizationServerId = "authorizationServerId2283", Scope = "oauth2scope2580", -},new OAuth2AuthenticationSettingsContract() +}, new OAuth2AuthenticationSettingsContract { AuthorizationServerId = "authorizationServerId2284", Scope = "oauth2scope2581", -} -}, +}}, }, - SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract() + SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract { Header = "header4520", Query = "query3037", @@ -723,10 +463,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiWithMultipleAuthServers() DisplayName = "apiname1463", ServiceLink = "http://newechoapi.cloudapp.net/api", Path = "newapiPath", - Protocols = -{ -ApiOperationInvokableProtocol.Https,ApiOperationInvokableProtocol.Http -}, + Protocols = { ApiOperationInvokableProtocol.Https, ApiOperationInvokableProtocol.Http }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId, content); ApiResource result = lro.Value; @@ -763,31 +500,22 @@ public async Task CreateOrUpdate_ApiManagementCreateApiWithMultipleOpenIdConnect // invoke the operation string apiId = "tempgroup"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Description = "apidescription5200", - AuthenticationSettings = new AuthenticationSettingsContract() + AuthenticationSettings = new AuthenticationSettingsContract { - OpenidAuthenticationSettings = -{ -new OpenIdAuthenticationSettingsContract() + OpenidAuthenticationSettings = {new OpenIdAuthenticationSettingsContract { OpenIdProviderId = "openidProviderId2283", -BearerTokenSendingMethods = -{ -BearerTokenSendingMethod.AuthorizationHeader -}, -},new OpenIdAuthenticationSettingsContract() +BearerTokenSendingMethods = {BearerTokenSendingMethod.AuthorizationHeader}, +}, new OpenIdAuthenticationSettingsContract { OpenIdProviderId = "openidProviderId2284", -BearerTokenSendingMethods = -{ -BearerTokenSendingMethod.AuthorizationHeader -}, -} -}, +BearerTokenSendingMethods = {BearerTokenSendingMethod.AuthorizationHeader}, +}}, }, - SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract() + SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract { Header = "header4520", Query = "query3037", @@ -795,10 +523,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiWithMultipleOpenIdConnect DisplayName = "apiname1463", ServiceLink = "http://newechoapi.cloudapp.net/api", Path = "newapiPath", - Protocols = -{ -ApiOperationInvokableProtocol.Https,ApiOperationInvokableProtocol.Http -}, + Protocols = { ApiOperationInvokableProtocol.Https, ApiOperationInvokableProtocol.Http }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId, content); ApiResource result = lro.Value; @@ -835,21 +560,18 @@ public async Task CreateOrUpdate_ApiManagementCreateApiWithOpenIdConnect() // invoke the operation string apiId = "tempgroup"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Description = "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.", - AuthenticationSettings = new AuthenticationSettingsContract() + AuthenticationSettings = new AuthenticationSettingsContract { - OpenId = new OpenIdAuthenticationSettingsContract() + OpenId = new OpenIdAuthenticationSettingsContract { OpenIdProviderId = "testopenid", - BearerTokenSendingMethods = -{ -BearerTokenSendingMethod.AuthorizationHeader -}, + BearerTokenSendingMethods = { BearerTokenSendingMethod.AuthorizationHeader }, }, }, - SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract() + SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract { Header = "Ocp-Apim-Subscription-Key", Query = "subscription-key", @@ -857,10 +579,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiWithOpenIdConnect() DisplayName = "Swagger Petstore", ServiceLink = "http://petstore.swagger.io/v2", Path = "petstore", - Protocols = -{ -ApiOperationInvokableProtocol.Https -}, + Protocols = { ApiOperationInvokableProtocol.Https }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId, content); ApiResource result = lro.Value; @@ -897,17 +616,14 @@ public async Task CreateOrUpdate_ApiManagementCreateGraphQLApi() // invoke the operation string apiId = "tempgroup"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Description = "apidescription5200", ApiType = ApiType.GraphQL, DisplayName = "apiname1463", ServiceLink = "https://api.spacex.land/graphql", Path = "graphql-api", - Protocols = -{ -ApiOperationInvokableProtocol.Http,ApiOperationInvokableProtocol.Https -}, + Protocols = { ApiOperationInvokableProtocol.Http, ApiOperationInvokableProtocol.Https }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId, content); ApiResource result = lro.Value; @@ -944,17 +660,14 @@ public async Task CreateOrUpdate_ApiManagementCreateODataApi() // invoke the operation string apiId = "tempgroup"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Description = "apidescription5200", ApiType = ApiType.Odata, DisplayName = "apiname1463", ServiceLink = "https://services.odata.org/TripPinWebApiService", Path = "odata-api", - Protocols = -{ -ApiOperationInvokableProtocol.Http,ApiOperationInvokableProtocol.Https -}, + Protocols = { ApiOperationInvokableProtocol.Http, ApiOperationInvokableProtocol.Https }, Value = "https://services.odata.org/TripPinWebApiService/$metadata", Format = ContentFormat.OdataLink, }; @@ -993,12 +706,12 @@ public async Task CreateOrUpdate_ApiManagementCreateSoapPassThroughApiUsingWsdlI // invoke the operation string apiId = "soapApi"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Path = "currency", Value = "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL", Format = ContentFormat.WsdlLink, - WsdlSelector = new ApiCreateOrUpdatePropertiesWsdlSelector() + WsdlSelector = new ApiCreateOrUpdatePropertiesWsdlSelector { WsdlServiceName = "CurrencyConvertor", WsdlEndpointName = "CurrencyConvertorSoap", @@ -1040,12 +753,12 @@ public async Task CreateOrUpdate_ApiManagementCreateSoapToRestApiUsingWsdlImport // invoke the operation string apiId = "soapApi"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Path = "currency", Value = "http://www.webservicex.net/CurrencyConvertor.asmx?WSDL", Format = ContentFormat.WsdlLink, - WsdlSelector = new ApiCreateOrUpdatePropertiesWsdlSelector() + WsdlSelector = new ApiCreateOrUpdatePropertiesWsdlSelector { WsdlServiceName = "CurrencyConvertor", WsdlEndpointName = "CurrencyConvertorSoap", @@ -1086,17 +799,14 @@ public async Task CreateOrUpdate_ApiManagementCreateWebSocketApi() // invoke the operation string apiId = "tempgroup"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { Description = "apidescription5200", ApiType = ApiType.WebSocket, DisplayName = "apiname1463", ServiceLink = "wss://echo.websocket.org", Path = "newapiPath", - Protocols = -{ -ApiOperationInvokableProtocol.Wss,ApiOperationInvokableProtocol.Ws -}, + Protocols = { ApiOperationInvokableProtocol.Wss, ApiOperationInvokableProtocol.Ws }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId, content); ApiResource result = lro.Value; @@ -1107,5 +817,253 @@ public async Task CreateOrUpdate_ApiManagementCreateWebSocketApi() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_ApiManagementGetApiContract() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiContract.json + // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // get the collection of this ApiResource + ApiCollection collection = apiManagementService.GetApis(); + + // invoke the operation + string apiId = "57d1f7558aa04f15146d9d8a"; + ApiResource result = await collection.GetAsync(apiId); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_ApiManagementGetApiRevisionContract() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRevision.json + // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // get the collection of this ApiResource + ApiCollection collection = apiManagementService.GetApis(); + + // invoke the operation + string apiId = "echo-api;rev=3"; + ApiResource result = await collection.GetAsync(apiId); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ApiManagementListApis() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApis.json + // this example is just showing the usage of "Api_ListByService" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // get the collection of this ApiResource + ApiCollection collection = apiManagementService.GetApis(); + + // invoke the operation and iterate over the result + await foreach (ApiResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_ApiManagementGetApiContract() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiContract.json + // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // get the collection of this ApiResource + ApiCollection collection = apiManagementService.GetApis(); + + // invoke the operation + string apiId = "57d1f7558aa04f15146d9d8a"; + bool result = await collection.ExistsAsync(apiId); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_ApiManagementGetApiRevisionContract() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRevision.json + // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // get the collection of this ApiResource + ApiCollection collection = apiManagementService.GetApis(); + + // invoke the operation + string apiId = "echo-api;rev=3"; + bool result = await collection.ExistsAsync(apiId); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_ApiManagementGetApiContract() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiContract.json + // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // get the collection of this ApiResource + ApiCollection collection = apiManagementService.GetApis(); + + // invoke the operation + string apiId = "57d1f7558aa04f15146d9d8a"; + NullableResponse response = await collection.GetIfExistsAsync(apiId); + ApiResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_ApiManagementGetApiRevisionContract() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRevision.json + // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // get the collection of this ApiResource + ApiCollection collection = apiManagementService.GetApis(); + + // invoke the operation + string apiId = "echo-api;rev=3"; + NullableResponse response = await collection.GetIfExistsAsync(apiId); + ApiResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiDiagnosticCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiDiagnosticCollection.cs index 1567d8d886df6..3f2bfcfe74594 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiDiagnosticCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiDiagnosticCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiDiagnosticCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiDiagnostics() + public async Task CreateOrUpdate_ApiManagementCreateApiDiagnostic() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiDiagnostics.json - // this example is just showing the usage of "ApiDiagnostic_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiDiagnostic.json + // this example is just showing the usage of "ApiDiagnostic_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,24 +33,59 @@ public async Task GetAll_ApiManagementListApiDiagnostics() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "echo-api"; + string apiId = "57d1f7558aa04f15146d9d8a"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiDiagnosticResource ApiDiagnosticCollection collection = api.GetApiDiagnostics(); - // invoke the operation and iterate over the result - await foreach (ApiDiagnosticResource item in collection.GetAllAsync()) + // invoke the operation + string diagnosticId = "applicationinsights"; + DiagnosticContractData data = new DiagnosticContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AlwaysLog = AlwaysLog.AllErrors, + LoggerId = "/loggers/applicationinsights", + Sampling = new SamplingSettings + { + SamplingType = SamplingType.Fixed, + Percentage = 50, + }, + Frontend = new PipelineDiagnosticSettings + { + Request = new HttpMessageDiagnostic + { + Headers = { "Content-type" }, + BodyBytes = 512, + }, + Response = new HttpMessageDiagnostic + { + Headers = { "Content-type" }, + BodyBytes = 512, + }, + }, + Backend = new PipelineDiagnosticSettings + { + Request = new HttpMessageDiagnostic + { + Headers = { "Content-type" }, + BodyBytes = 512, + }, + Response = new HttpMessageDiagnostic + { + Headers = { "Content-type" }, + BodyBytes = 512, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diagnosticId, data); + ApiDiagnosticResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +125,10 @@ public async Task Get_ApiManagementGetApiDiagnostic() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiDiagnostic() + public async Task GetAll_ApiManagementListApiDiagnostics() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiDiagnostic.json - // this example is just showing the usage of "ApiDiagnostic_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiDiagnostics.json + // this example is just showing the usage of "ApiDiagnostic_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,23 +140,29 @@ public async Task Exists_ApiManagementGetApiDiagnostic() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "echo-api"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiDiagnosticResource ApiDiagnosticCollection collection = api.GetApiDiagnostics(); - // invoke the operation - string diagnosticId = "applicationinsights"; - bool result = await collection.ExistsAsync(diagnosticId); + // invoke the operation and iterate over the result + await foreach (ApiDiagnosticResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiDiagnostic() + public async Task Exists_ApiManagementGetApiDiagnostic() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiDiagnostic.json // this example is just showing the usage of "ApiDiagnostic_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +186,17 @@ public async Task GetIfExists_ApiManagementGetApiDiagnostic() // invoke the operation string diagnosticId = "applicationinsights"; - NullableResponse response = await collection.GetIfExistsAsync(diagnosticId); - ApiDiagnosticResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(diagnosticId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiDiagnostic() + public async Task GetIfExists_ApiManagementGetApiDiagnostic() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiDiagnostic.json - // this example is just showing the usage of "ApiDiagnostic_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiDiagnostic.json + // this example is just showing the usage of "ApiDiagnostic_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,62 +217,21 @@ public async Task CreateOrUpdate_ApiManagementCreateApiDiagnostic() // invoke the operation string diagnosticId = "applicationinsights"; - DiagnosticContractData data = new DiagnosticContractData() - { - AlwaysLog = AlwaysLog.AllErrors, - LoggerId = "/loggers/applicationinsights", - Sampling = new SamplingSettings() - { - SamplingType = SamplingType.Fixed, - Percentage = 50, - }, - Frontend = new PipelineDiagnosticSettings() - { - Request = new HttpMessageDiagnostic() - { - Headers = -{ -"Content-type" -}, - BodyBytes = 512, - }, - Response = new HttpMessageDiagnostic() - { - Headers = -{ -"Content-type" -}, - BodyBytes = 512, - }, - }, - Backend = new PipelineDiagnosticSettings() - { - Request = new HttpMessageDiagnostic() - { - Headers = -{ -"Content-type" -}, - BodyBytes = 512, - }, - Response = new HttpMessageDiagnostic() - { - Headers = -{ -"Content-type" -}, - BodyBytes = 512, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diagnosticId, data); - ApiDiagnosticResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(diagnosticId); + ApiDiagnosticResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiDiagnosticResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiDiagnosticResource.cs index da34bf5b992e8..c964eb304f861 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiDiagnosticResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiDiagnosticResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiDiagnosticResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiDiagnostic() + public async Task Get_ApiManagementGetApiDiagnostic() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiDiagnostic.json - // this example is just showing the usage of "ApiDiagnostic_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiDiagnostic.json + // this example is just showing the usage of "ApiDiagnostic_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadApiDiagnostic() ApiDiagnosticResource apiDiagnostic = client.GetApiDiagnosticResource(apiDiagnosticResourceId); // invoke the operation - bool result = await apiDiagnostic.GetEntityTagAsync(); + ApiDiagnosticResource result = await apiDiagnostic.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiDiagnostic() + public async Task Delete_ApiManagementDeleteApiDiagnostic() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiDiagnostic.json - // this example is just showing the usage of "ApiDiagnostic_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiDiagnostic.json + // this example is just showing the usage of "ApiDiagnostic_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,10 @@ public async Task Get_ApiManagementGetApiDiagnostic() ApiDiagnosticResource apiDiagnostic = client.GetApiDiagnosticResource(apiDiagnosticResourceId); // invoke the operation - ApiDiagnosticResource result = await apiDiagnostic.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiDiagnostic.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,50 +101,38 @@ public async Task Update_ApiManagementUpdateApiDiagnostic() // invoke the operation ETag ifMatch = new ETag("*"); - DiagnosticContractData data = new DiagnosticContractData() + DiagnosticContractData data = new DiagnosticContractData { AlwaysLog = AlwaysLog.AllErrors, LoggerId = "/loggers/applicationinsights", - Sampling = new SamplingSettings() + Sampling = new SamplingSettings { SamplingType = SamplingType.Fixed, Percentage = 50, }, - Frontend = new PipelineDiagnosticSettings() + Frontend = new PipelineDiagnosticSettings { - Request = new HttpMessageDiagnostic() + Request = new HttpMessageDiagnostic { - Headers = -{ -"Content-type" -}, + Headers = { "Content-type" }, BodyBytes = 512, }, - Response = new HttpMessageDiagnostic() + Response = new HttpMessageDiagnostic { - Headers = -{ -"Content-type" -}, + Headers = { "Content-type" }, BodyBytes = 512, }, }, - Backend = new PipelineDiagnosticSettings() + Backend = new PipelineDiagnosticSettings { - Request = new HttpMessageDiagnostic() + Request = new HttpMessageDiagnostic { - Headers = -{ -"Content-type" -}, + Headers = { "Content-type" }, BodyBytes = 512, }, - Response = new HttpMessageDiagnostic() + Response = new HttpMessageDiagnostic { - Headers = -{ -"Content-type" -}, + Headers = { "Content-type" }, BodyBytes = 512, }, }, @@ -159,10 +148,10 @@ public async Task Update_ApiManagementUpdateApiDiagnostic() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiDiagnostic() + public async Task GetEntityTag_ApiManagementHeadApiDiagnostic() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiDiagnostic.json - // this example is just showing the usage of "ApiDiagnostic_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiDiagnostic.json + // this example is just showing the usage of "ApiDiagnostic_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,10 +169,9 @@ public async Task Delete_ApiManagementDeleteApiDiagnostic() ApiDiagnosticResource apiDiagnostic = client.GetApiDiagnosticResource(apiDiagnosticResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiDiagnostic.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiDiagnostic.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueAttachmentCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueAttachmentCollection.cs index 8f9b056507b93..1539141e2f3b9 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueAttachmentCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueAttachmentCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiIssueAttachmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiIssueAttachments() + public async Task CreateOrUpdate_ApiManagementCreateApiIssueAttachment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiIssueAttachments.json - // this example is just showing the usage of "ApiIssueAttachment_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiIssueAttachment.json + // this example is just showing the usage of "ApiIssueAttachment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,22 @@ public async Task GetAll_ApiManagementListApiIssueAttachments() // get the collection of this ApiIssueAttachmentResource ApiIssueAttachmentCollection collection = apiIssue.GetApiIssueAttachments(); - // invoke the operation and iterate over the result - await foreach (ApiIssueAttachmentResource item in collection.GetAllAsync()) + // invoke the operation + string attachmentId = "57d2ef278aa04f0888cba3f3"; + ApiIssueAttachmentData data = new ApiIssueAttachmentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiIssueAttachmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Title = "Issue attachment.", + ContentFormat = "image/jpeg", + Content = "IEJhc2U2NA==", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attachmentId, data); + ApiIssueAttachmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiIssueAttachmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +96,10 @@ public async Task Get_ApiManagementGetApiIssueAttachment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiIssueAttachment() + public async Task GetAll_ApiManagementListApiIssueAttachments() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssueAttachment.json - // this example is just showing the usage of "ApiIssueAttachment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiIssueAttachments.json + // this example is just showing the usage of "ApiIssueAttachment_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,7 +111,7 @@ public async Task Exists_ApiManagementGetApiIssueAttachment() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "57d1f7558aa04f15146d9d8a"; string issueId = "57d2ef278aa04f0ad01d6cdc"; ResourceIdentifier apiIssueResourceId = ApiIssueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, issueId); ApiIssueResource apiIssue = client.GetApiIssueResource(apiIssueResourceId); @@ -114,16 +119,22 @@ public async Task Exists_ApiManagementGetApiIssueAttachment() // get the collection of this ApiIssueAttachmentResource ApiIssueAttachmentCollection collection = apiIssue.GetApiIssueAttachments(); - // invoke the operation - string attachmentId = "57d2ef278aa04f0888cba3f3"; - bool result = await collection.ExistsAsync(attachmentId); + // invoke the operation and iterate over the result + await foreach (ApiIssueAttachmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiIssueAttachmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiIssueAttachment() + public async Task Exists_ApiManagementGetApiIssueAttachment() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssueAttachment.json // this example is just showing the usage of "ApiIssueAttachment_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +159,17 @@ public async Task GetIfExists_ApiManagementGetApiIssueAttachment() // invoke the operation string attachmentId = "57d2ef278aa04f0888cba3f3"; - NullableResponse response = await collection.GetIfExistsAsync(attachmentId); - ApiIssueAttachmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(attachmentId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiIssueAttachmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiIssueAttachment() + public async Task GetIfExists_ApiManagementGetApiIssueAttachment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiIssueAttachment.json - // this example is just showing the usage of "ApiIssueAttachment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssueAttachment.json + // this example is just showing the usage of "ApiIssueAttachment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,7 +181,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiIssueAttachment() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "57d2ef278aa04f0888cba3f3"; string issueId = "57d2ef278aa04f0ad01d6cdc"; ResourceIdentifier apiIssueResourceId = ApiIssueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, issueId); ApiIssueResource apiIssue = client.GetApiIssueResource(apiIssueResourceId); @@ -192,20 +191,21 @@ public async Task CreateOrUpdate_ApiManagementCreateApiIssueAttachment() // invoke the operation string attachmentId = "57d2ef278aa04f0888cba3f3"; - ApiIssueAttachmentData data = new ApiIssueAttachmentData() - { - Title = "Issue attachment.", - ContentFormat = "image/jpeg", - Content = "IEJhc2U2NA==", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attachmentId, data); - ApiIssueAttachmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(attachmentId); + ApiIssueAttachmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiIssueAttachmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiIssueAttachmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueAttachmentResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueAttachmentResource.cs index 8b294bdf8c558..4d940fb253852 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueAttachmentResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueAttachmentResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiIssueAttachmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiIssueAttachment() + public async Task Get_ApiManagementGetApiIssueAttachment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiIssueAttachment.json - // this example is just showing the usage of "ApiIssueAttachment_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssueAttachment.json + // this example is just showing the usage of "ApiIssueAttachment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadApiIssueAttachment() ApiIssueAttachmentResource apiIssueAttachment = client.GetApiIssueAttachmentResource(apiIssueAttachmentResourceId); // invoke the operation - bool result = await apiIssueAttachment.GetEntityTagAsync(); + ApiIssueAttachmentResource result = await apiIssueAttachment.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiIssueAttachmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiIssueAttachment() + public async Task Delete_ApiManagementDeleteApiIssueAttachment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssueAttachment.json - // this example is just showing the usage of "ApiIssueAttachment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiIssueAttachment.json + // this example is just showing the usage of "ApiIssueAttachment_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,20 +65,17 @@ public async Task Get_ApiManagementGetApiIssueAttachment() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "57d1f7558aa04f15146d9d8a"; string issueId = "57d2ef278aa04f0ad01d6cdc"; string attachmentId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier apiIssueAttachmentResourceId = ApiIssueAttachmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, issueId, attachmentId); ApiIssueAttachmentResource apiIssueAttachment = client.GetApiIssueAttachmentResource(apiIssueAttachmentResourceId); // invoke the operation - ApiIssueAttachmentResource result = await apiIssueAttachment.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiIssueAttachment.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiIssueAttachmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -101,7 +102,7 @@ public async Task Update_ApiManagementCreateApiIssueAttachment() ApiIssueAttachmentResource apiIssueAttachment = client.GetApiIssueAttachmentResource(apiIssueAttachmentResourceId); // invoke the operation - ApiIssueAttachmentData data = new ApiIssueAttachmentData() + ApiIssueAttachmentData data = new ApiIssueAttachmentData { Title = "Issue attachment.", ContentFormat = "image/jpeg", @@ -119,10 +120,10 @@ public async Task Update_ApiManagementCreateApiIssueAttachment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiIssueAttachment() + public async Task GetEntityTag_ApiManagementHeadApiIssueAttachment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiIssueAttachment.json - // this example is just showing the usage of "ApiIssueAttachment_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiIssueAttachment.json + // this example is just showing the usage of "ApiIssueAttachment_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,17 +135,16 @@ public async Task Delete_ApiManagementDeleteApiIssueAttachment() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "57d2ef278aa04f0888cba3f3"; string issueId = "57d2ef278aa04f0ad01d6cdc"; string attachmentId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier apiIssueAttachmentResourceId = ApiIssueAttachmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, issueId, attachmentId); ApiIssueAttachmentResource apiIssueAttachment = client.GetApiIssueAttachmentResource(apiIssueAttachmentResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiIssueAttachment.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiIssueAttachment.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCollection.cs index 7a0e4040ac07c..195286fc5f3a3 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiIssueCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiIssues() + public async Task CreateOrUpdate_ApiManagementCreateApiIssue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiIssues.json - // this example is just showing the usage of "ApiIssue_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiIssue.json + // this example is just showing the usage of "ApiIssue_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,24 @@ public async Task GetAll_ApiManagementListApiIssues() // get the collection of this ApiIssueResource ApiIssueCollection collection = api.GetApiIssues(); - // invoke the operation and iterate over the result - await foreach (ApiIssueResource item in collection.GetAllAsync()) + // invoke the operation + string issueId = "57d2ef278aa04f0ad01d6cdc"; + IssueContractData data = new IssueContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IssueContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CreatedOn = DateTimeOffset.Parse("2018-02-01T22:21:20.467Z"), + State = IssueState.Open, + Title = "New API issue", + Description = "New API issue description", + UserId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, issueId, data); + ApiIssueResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IssueContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +97,10 @@ public async Task Get_ApiManagementGetApiIssue() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiIssue() + public async Task GetAll_ApiManagementListApiIssues() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssue.json - // this example is just showing the usage of "ApiIssue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiIssues.json + // this example is just showing the usage of "ApiIssue_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,23 +112,29 @@ public async Task Exists_ApiManagementGetApiIssue() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "57d1f7558aa04f15146d9d8a"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiIssueResource ApiIssueCollection collection = api.GetApiIssues(); - // invoke the operation - string issueId = "57d2ef278aa04f0ad01d6cdc"; - bool result = await collection.ExistsAsync(issueId); + // invoke the operation and iterate over the result + await foreach (ApiIssueResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IssueContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiIssue() + public async Task Exists_ApiManagementGetApiIssue() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssue.json // this example is just showing the usage of "ApiIssue_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +158,17 @@ public async Task GetIfExists_ApiManagementGetApiIssue() // invoke the operation string issueId = "57d2ef278aa04f0ad01d6cdc"; - NullableResponse response = await collection.GetIfExistsAsync(issueId); - ApiIssueResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(issueId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IssueContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiIssue() + public async Task GetIfExists_ApiManagementGetApiIssue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiIssue.json - // this example is just showing the usage of "ApiIssue_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssue.json + // this example is just showing the usage of "ApiIssue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,7 +180,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiIssue() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -188,22 +189,21 @@ public async Task CreateOrUpdate_ApiManagementCreateApiIssue() // invoke the operation string issueId = "57d2ef278aa04f0ad01d6cdc"; - IssueContractData data = new IssueContractData() - { - CreatedOn = DateTimeOffset.Parse("2018-02-01T22:21:20.467Z"), - State = IssueState.Open, - Title = "New API issue", - Description = "New API issue description", - UserId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, issueId, data); - ApiIssueResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(issueId); + ApiIssueResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IssueContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IssueContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCommentCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCommentCollection.cs index e02318a7f662f..c5858aae30e61 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCommentCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCommentCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiIssueCommentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiIssueComments() + public async Task CreateOrUpdate_ApiManagementCreateApiIssueComment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiIssueComments.json - // this example is just showing the usage of "ApiIssueComment_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiIssueComment.json + // this example is just showing the usage of "ApiIssueComment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,22 @@ public async Task GetAll_ApiManagementListApiIssueComments() // get the collection of this ApiIssueCommentResource ApiIssueCommentCollection collection = apiIssue.GetApiIssueComments(); - // invoke the operation and iterate over the result - await foreach (ApiIssueCommentResource item in collection.GetAllAsync()) + // invoke the operation + string commentId = "599e29ab193c3c0bd0b3e2fb"; + ApiIssueCommentData data = new ApiIssueCommentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiIssueCommentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Text = "Issue comment.", + CreatedOn = DateTimeOffset.Parse("2018-02-01T22:21:20.467Z"), + UserId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, commentId, data); + ApiIssueCommentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiIssueCommentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +96,10 @@ public async Task Get_ApiManagementGetApiIssueComment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiIssueComment() + public async Task GetAll_ApiManagementListApiIssueComments() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssueComment.json - // this example is just showing the usage of "ApiIssueComment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiIssueComments.json + // this example is just showing the usage of "ApiIssueComment_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,7 +111,7 @@ public async Task Exists_ApiManagementGetApiIssueComment() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "57d1f7558aa04f15146d9d8a"; string issueId = "57d2ef278aa04f0ad01d6cdc"; ResourceIdentifier apiIssueResourceId = ApiIssueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, issueId); ApiIssueResource apiIssue = client.GetApiIssueResource(apiIssueResourceId); @@ -114,16 +119,22 @@ public async Task Exists_ApiManagementGetApiIssueComment() // get the collection of this ApiIssueCommentResource ApiIssueCommentCollection collection = apiIssue.GetApiIssueComments(); - // invoke the operation - string commentId = "599e29ab193c3c0bd0b3e2fb"; - bool result = await collection.ExistsAsync(commentId); + // invoke the operation and iterate over the result + await foreach (ApiIssueCommentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiIssueCommentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiIssueComment() + public async Task Exists_ApiManagementGetApiIssueComment() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssueComment.json // this example is just showing the usage of "ApiIssueComment_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +159,17 @@ public async Task GetIfExists_ApiManagementGetApiIssueComment() // invoke the operation string commentId = "599e29ab193c3c0bd0b3e2fb"; - NullableResponse response = await collection.GetIfExistsAsync(commentId); - ApiIssueCommentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(commentId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiIssueCommentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiIssueComment() + public async Task GetIfExists_ApiManagementGetApiIssueComment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiIssueComment.json - // this example is just showing the usage of "ApiIssueComment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssueComment.json + // this example is just showing the usage of "ApiIssueComment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,7 +181,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiIssueComment() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "57d2ef278aa04f0888cba3f3"; string issueId = "57d2ef278aa04f0ad01d6cdc"; ResourceIdentifier apiIssueResourceId = ApiIssueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, issueId); ApiIssueResource apiIssue = client.GetApiIssueResource(apiIssueResourceId); @@ -192,20 +191,21 @@ public async Task CreateOrUpdate_ApiManagementCreateApiIssueComment() // invoke the operation string commentId = "599e29ab193c3c0bd0b3e2fb"; - ApiIssueCommentData data = new ApiIssueCommentData() - { - Text = "Issue comment.", - CreatedOn = DateTimeOffset.Parse("2018-02-01T22:21:20.467Z"), - UserId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, commentId, data); - ApiIssueCommentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(commentId); + ApiIssueCommentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiIssueCommentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiIssueCommentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCommentResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCommentResource.cs index 9d71ae0336194..ef7bedf1f0441 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCommentResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueCommentResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiIssueCommentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiIssueComment() + public async Task Get_ApiManagementGetApiIssueComment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiIssueComment.json - // this example is just showing the usage of "ApiIssueComment_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssueComment.json + // this example is just showing the usage of "ApiIssueComment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadApiIssueComment() ApiIssueCommentResource apiIssueComment = client.GetApiIssueCommentResource(apiIssueCommentResourceId); // invoke the operation - bool result = await apiIssueComment.GetEntityTagAsync(); + ApiIssueCommentResource result = await apiIssueComment.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiIssueCommentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiIssueComment() + public async Task Delete_ApiManagementDeleteApiIssueComment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssueComment.json - // this example is just showing the usage of "ApiIssueComment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiIssueComment.json + // this example is just showing the usage of "ApiIssueComment_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,20 +65,17 @@ public async Task Get_ApiManagementGetApiIssueComment() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "57d1f7558aa04f15146d9d8a"; string issueId = "57d2ef278aa04f0ad01d6cdc"; string commentId = "599e29ab193c3c0bd0b3e2fb"; ResourceIdentifier apiIssueCommentResourceId = ApiIssueCommentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, issueId, commentId); ApiIssueCommentResource apiIssueComment = client.GetApiIssueCommentResource(apiIssueCommentResourceId); // invoke the operation - ApiIssueCommentResource result = await apiIssueComment.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiIssueComment.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiIssueCommentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -101,7 +102,7 @@ public async Task Update_ApiManagementCreateApiIssueComment() ApiIssueCommentResource apiIssueComment = client.GetApiIssueCommentResource(apiIssueCommentResourceId); // invoke the operation - ApiIssueCommentData data = new ApiIssueCommentData() + ApiIssueCommentData data = new ApiIssueCommentData { Text = "Issue comment.", CreatedOn = DateTimeOffset.Parse("2018-02-01T22:21:20.467Z"), @@ -119,10 +120,10 @@ public async Task Update_ApiManagementCreateApiIssueComment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiIssueComment() + public async Task GetEntityTag_ApiManagementHeadApiIssueComment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiIssueComment.json - // this example is just showing the usage of "ApiIssueComment_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiIssueComment.json + // this example is just showing the usage of "ApiIssueComment_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,17 +135,16 @@ public async Task Delete_ApiManagementDeleteApiIssueComment() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "57d2ef278aa04f0888cba3f3"; string issueId = "57d2ef278aa04f0ad01d6cdc"; string commentId = "599e29ab193c3c0bd0b3e2fb"; ResourceIdentifier apiIssueCommentResourceId = ApiIssueCommentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, issueId, commentId); ApiIssueCommentResource apiIssueComment = client.GetApiIssueCommentResource(apiIssueCommentResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiIssueComment.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiIssueComment.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueResource.cs index f60bd1e92c6c2..a74eecf973804 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiIssueResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiIssueResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiIssue() + public async Task Get_ApiManagementGetApiIssue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiIssue.json - // this example is just showing the usage of "ApiIssue_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssue.json + // this example is just showing the usage of "ApiIssue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadApiIssue() ApiIssueResource apiIssue = client.GetApiIssueResource(apiIssueResourceId); // invoke the operation - bool result = await apiIssue.GetEntityTagAsync(); + ApiIssueResource result = await apiIssue.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IssueContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiIssue() + public async Task Delete_ApiManagementDeleteApiIssue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiIssue.json - // this example is just showing the usage of "ApiIssue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiIssue.json + // this example is just showing the usage of "ApiIssue_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,19 +65,16 @@ public async Task Get_ApiManagementGetApiIssue() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "57d1f7558aa04f15146d9d8a"; string issueId = "57d2ef278aa04f0ad01d6cdc"; ResourceIdentifier apiIssueResourceId = ApiIssueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, issueId); ApiIssueResource apiIssue = client.GetApiIssueResource(apiIssueResourceId); // invoke the operation - ApiIssueResource result = await apiIssue.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiIssue.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IssueContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,7 +101,7 @@ public async Task Update_ApiManagementUpdateApiIssue() // invoke the operation ETag ifMatch = new ETag("*"); - ApiIssuePatch patch = new ApiIssuePatch() + ApiIssuePatch patch = new ApiIssuePatch { State = IssueState.Closed, }; @@ -115,10 +116,10 @@ public async Task Update_ApiManagementUpdateApiIssue() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiIssue() + public async Task GetEntityTag_ApiManagementHeadApiIssue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiIssue.json - // this example is just showing the usage of "ApiIssue_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiIssue.json + // this example is just showing the usage of "ApiIssue_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,16 +131,15 @@ public async Task Delete_ApiManagementDeleteApiIssue() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "57d2ef278aa04f0888cba3f3"; string issueId = "57d2ef278aa04f0ad01d6cdc"; ResourceIdentifier apiIssueResourceId = ApiIssueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, issueId); ApiIssueResource apiIssue = client.GetApiIssueResource(apiIssueResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiIssue.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiIssue.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementAuthorizationServerCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementAuthorizationServerCollection.cs index 90cbfdc6cffc6..5bbd86c8e5f70 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementAuthorizationServerCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementAuthorizationServerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementAuthorizationServerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListAuthorizationServers() + public async Task CreateOrUpdate_ApiManagementCreateAuthorizationServer() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListAuthorizationServers.json - // this example is just showing the usage of "AuthorizationServer_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationServer.json + // this example is just showing the usage of "AuthorizationServer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,35 @@ public async Task GetAll_ApiManagementListAuthorizationServers() // get the collection of this ApiManagementAuthorizationServerResource ApiManagementAuthorizationServerCollection collection = apiManagementService.GetApiManagementAuthorizationServers(); - // invoke the operation and iterate over the result - await foreach (ApiManagementAuthorizationServerResource item in collection.GetAllAsync()) + // invoke the operation + string authsid = "newauthServer"; + ApiManagementAuthorizationServerData data = new ApiManagementAuthorizationServerData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementAuthorizationServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "test server", + AuthorizationMethods = { AuthorizationMethod.Get }, + TokenEndpoint = "https://www.contoso.com/oauth2/token", + DoesSupportState = true, + DefaultScope = "read write", + BearerTokenSendingMethods = { BearerTokenSendingMethod.AuthorizationHeader }, + ResourceOwnerUsername = "un", + ResourceOwnerPassword = "pwd", + DisplayName = "test2", + UseInTestConsole = false, + UseInApiDocumentation = true, + ClientRegistrationEndpoint = "https://www.contoso.com/apps", + AuthorizationEndpoint = "https://www.contoso.com/oauth2/auth", + GrantTypes = { GrantType.AuthorizationCode, GrantType.Implicit }, + ClientId = "1", + ClientSecret = "2", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authsid, data); + ApiManagementAuthorizationServerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementAuthorizationServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +106,10 @@ public async Task Get_ApiManagementGetAuthorizationServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetAuthorizationServer() + public async Task GetAll_ApiManagementListAuthorizationServers() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationServer.json - // this example is just showing the usage of "AuthorizationServer_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListAuthorizationServers.json + // this example is just showing the usage of "AuthorizationServer_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +127,22 @@ public async Task Exists_ApiManagementGetAuthorizationServer() // get the collection of this ApiManagementAuthorizationServerResource ApiManagementAuthorizationServerCollection collection = apiManagementService.GetApiManagementAuthorizationServers(); - // invoke the operation - string authsid = "newauthServer2"; - bool result = await collection.ExistsAsync(authsid); + // invoke the operation and iterate over the result + await foreach (ApiManagementAuthorizationServerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementAuthorizationServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetAuthorizationServer() + public async Task Exists_ApiManagementGetAuthorizationServer() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationServer.json // this example is just showing the usage of "AuthorizationServer_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +165,17 @@ public async Task GetIfExists_ApiManagementGetAuthorizationServer() // invoke the operation string authsid = "newauthServer2"; - NullableResponse response = await collection.GetIfExistsAsync(authsid); - ApiManagementAuthorizationServerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(authsid); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementAuthorizationServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateAuthorizationServer() + public async Task GetIfExists_ApiManagementGetAuthorizationServer() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationServer.json - // this example is just showing the usage of "AuthorizationServer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationServer.json + // this example is just showing the usage of "AuthorizationServer_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,43 +194,22 @@ public async Task CreateOrUpdate_ApiManagementCreateAuthorizationServer() ApiManagementAuthorizationServerCollection collection = apiManagementService.GetApiManagementAuthorizationServers(); // invoke the operation - string authsid = "newauthServer"; - ApiManagementAuthorizationServerData data = new ApiManagementAuthorizationServerData() - { - Description = "test server", - AuthorizationMethods = -{ -AuthorizationMethod.Get -}, - TokenEndpoint = "https://www.contoso.com/oauth2/token", - DoesSupportState = true, - DefaultScope = "read write", - BearerTokenSendingMethods = -{ -BearerTokenSendingMethod.AuthorizationHeader -}, - ResourceOwnerUsername = "un", - ResourceOwnerPassword = "pwd", - DisplayName = "test2", - UseInTestConsole = false, - UseInApiDocumentation = true, - ClientRegistrationEndpoint = "https://www.contoso.com/apps", - AuthorizationEndpoint = "https://www.contoso.com/oauth2/auth", - GrantTypes = -{ -GrantType.AuthorizationCode,GrantType.Implicit -}, - ClientId = "1", - ClientSecret = "2", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authsid, data); - ApiManagementAuthorizationServerResource result = lro.Value; + string authsid = "newauthServer2"; + NullableResponse response = await collection.GetIfExistsAsync(authsid); + ApiManagementAuthorizationServerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementAuthorizationServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementAuthorizationServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementAuthorizationServerResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementAuthorizationServerResource.cs index d78493f3c8b44..8c99366cf043b 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementAuthorizationServerResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementAuthorizationServerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementAuthorizationServerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadAuthorizationServer() + public async Task Get_ApiManagementGetAuthorizationServer() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadAuthorizationServer.json - // this example is just showing the usage of "AuthorizationServer_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationServer.json + // this example is just showing the usage of "AuthorizationServer_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadAuthorizationServer() ApiManagementAuthorizationServerResource apiManagementAuthorizationServer = client.GetApiManagementAuthorizationServerResource(apiManagementAuthorizationServerResourceId); // invoke the operation - bool result = await apiManagementAuthorizationServer.GetEntityTagAsync(); + ApiManagementAuthorizationServerResource result = await apiManagementAuthorizationServer.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementAuthorizationServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetAuthorizationServer() + public async Task Delete_ApiManagementDeleteAuthorizationServer() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationServer.json - // this example is just showing the usage of "AuthorizationServer_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteAuthorizationServer.json + // this example is just showing the usage of "AuthorizationServer_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,10 @@ public async Task Get_ApiManagementGetAuthorizationServer() ApiManagementAuthorizationServerResource apiManagementAuthorizationServer = client.GetApiManagementAuthorizationServerResource(apiManagementAuthorizationServerResourceId); // invoke the operation - ApiManagementAuthorizationServerResource result = await apiManagementAuthorizationServer.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementAuthorizationServer.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementAuthorizationServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateAuthorizationServer() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementAuthorizationServerPatch patch = new ApiManagementAuthorizationServerPatch() + ApiManagementAuthorizationServerPatch patch = new ApiManagementAuthorizationServerPatch { UseInTestConsole = false, UseInApiDocumentation = true, @@ -115,10 +116,10 @@ public async Task Update_ApiManagementUpdateAuthorizationServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteAuthorizationServer() + public async Task GetSecrets_ApiManagementAuthorizationServerListSecrets() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteAuthorizationServer.json - // this example is just showing the usage of "AuthorizationServer_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementAuthorizationServerListSecrets.json + // this example is just showing the usage of "AuthorizationServer_ListSecrets" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,18 +136,17 @@ public async Task Delete_ApiManagementDeleteAuthorizationServer() ApiManagementAuthorizationServerResource apiManagementAuthorizationServer = client.GetApiManagementAuthorizationServerResource(apiManagementAuthorizationServerResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementAuthorizationServer.DeleteAsync(WaitUntil.Completed, ifMatch); + AuthorizationServerSecretsContract result = await apiManagementAuthorizationServer.GetSecretsAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSecrets_ApiManagementAuthorizationServerListSecrets() + public async Task GetEntityTag_ApiManagementHeadAuthorizationServer() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementAuthorizationServerListSecrets.json - // this example is just showing the usage of "AuthorizationServer_ListSecrets" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadAuthorizationServer.json + // this example is just showing the usage of "AuthorizationServer_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -163,7 +163,7 @@ public async Task GetSecrets_ApiManagementAuthorizationServerListSecrets() ApiManagementAuthorizationServerResource apiManagementAuthorizationServer = client.GetApiManagementAuthorizationServerResource(apiManagementAuthorizationServerResourceId); // invoke the operation - AuthorizationServerSecretsContract result = await apiManagementAuthorizationServer.GetSecretsAsync(); + bool result = await apiManagementAuthorizationServer.GetEntityTagAsync(); Console.WriteLine($"Succeeded: {result}"); } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementBackendCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementBackendCollection.cs index bed50e8c28900..e3e9018094f36 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementBackendCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementBackendCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementBackendCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListBackends() + public async Task CreateOrUpdate_ApiManagementCreateBackendProxyBackend() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListBackends.json - // this example is just showing the usage of "Backend_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateBackendProxyBackend.json + // this example is just showing the usage of "Backend_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,52 @@ public async Task GetAll_ApiManagementListBackends() // get the collection of this ApiManagementBackendResource ApiManagementBackendCollection collection = apiManagementService.GetApiManagementBackends(); - // invoke the operation and iterate over the result - await foreach (ApiManagementBackendResource item in collection.GetAllAsync()) + // invoke the operation + string backendId = "proxybackend"; + ApiManagementBackendData data = new ApiManagementBackendData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementBackendData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "description5308", + Credentials = new BackendCredentialsContract + { + Query = +{ +["sv"] = {"xx", "bb", "cc"} +}, + Header = +{ +["x-my-1"] = {"val1", "val2"} +}, + Authorization = new BackendAuthorizationHeaderCredentials("Basic", "opensesma"), + }, + Proxy = new BackendProxyContract(new Uri("http://192.168.1.1:8080")) + { + Username = "Contoso\\admin", + Password = "", + }, + Tls = new BackendTlsProperties + { + ShouldValidateCertificateChain = true, + ShouldValidateCertificateName = true, + }, + Uri = new Uri("https://backendname2644/"), + Protocol = BackendProtocol.Http, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backendId, data); + ApiManagementBackendResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementBackendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetBackend() + public async Task CreateOrUpdate_ApiManagementCreateBackendServiceFabric() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetBackend.json - // this example is just showing the usage of "Backend_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateBackendServiceFabric.json + // this example is just showing the usage of "Backend_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +104,24 @@ public async Task Get_ApiManagementGetBackend() // invoke the operation string backendId = "sfbackend"; - ApiManagementBackendResource result = await collection.GetAsync(backendId); + ApiManagementBackendData data = new ApiManagementBackendData + { + Description = "Service Fabric Test App 1", + BackendServiceFabricCluster = new BackendServiceFabricClusterProperties(new string[] { "https://somecluster.com" }) + { + ClientCertificateId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1", + MaxPartitionResolutionRetries = 5, + ServerX509Names = {new X509CertificateName +{ +Name = "ServerCommonName1", +IssuerCertificateThumbprint = "IssuerCertificateThumbprint1", +}}, + }, + Uri = new Uri("fabric:/mytestapp/mytestservice"), + Protocol = BackendProtocol.Http, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backendId, data); + ApiManagementBackendResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +132,7 @@ public async Task Get_ApiManagementGetBackend() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetBackend() + public async Task Get_ApiManagementGetBackend() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetBackend.json // this example is just showing the usage of "Backend_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +155,21 @@ public async Task Exists_ApiManagementGetBackend() // invoke the operation string backendId = "sfbackend"; - bool result = await collection.ExistsAsync(backendId); + ApiManagementBackendResource result = await collection.GetAsync(backendId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementBackendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetBackend() + public async Task GetAll_ApiManagementListBackends() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetBackend.json - // this example is just showing the usage of "Backend_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListBackends.json + // this example is just showing the usage of "Backend_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +187,25 @@ public async Task GetIfExists_ApiManagementGetBackend() // get the collection of this ApiManagementBackendResource ApiManagementBackendCollection collection = apiManagementService.GetApiManagementBackends(); - // invoke the operation - string backendId = "sfbackend"; - NullableResponse response = await collection.GetIfExistsAsync(backendId); - ApiManagementBackendResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ApiManagementBackendResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApiManagementBackendData resourceData = result.Data; + ApiManagementBackendData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateBackendProxyBackend() + public async Task Exists_ApiManagementGetBackend() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateBackendProxyBackend.json - // this example is just showing the usage of "Backend_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetBackend.json + // this example is just showing the usage of "Backend_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,57 +224,18 @@ public async Task CreateOrUpdate_ApiManagementCreateBackendProxyBackend() ApiManagementBackendCollection collection = apiManagementService.GetApiManagementBackends(); // invoke the operation - string backendId = "proxybackend"; - ApiManagementBackendData data = new ApiManagementBackendData() - { - Description = "description5308", - Credentials = new BackendCredentialsContract() - { - Query = -{ -["sv"] = new string[] -{ -"xx","bb","cc" -}, -}, - Header = -{ -["x-my-1"] = new string[] -{ -"val1","val2" -}, -}, - Authorization = new BackendAuthorizationHeaderCredentials("Basic", "opensesma"), - }, - Proxy = new BackendProxyContract(new Uri("http://192.168.1.1:8080")) - { - Username = "Contoso\\admin", - Password = "", - }, - Tls = new BackendTlsProperties() - { - ShouldValidateCertificateChain = true, - ShouldValidateCertificateName = true, - }, - Uri = new Uri("https://backendname2644/"), - Protocol = BackendProtocol.Http, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backendId, data); - ApiManagementBackendResource result = lro.Value; + string backendId = "sfbackend"; + bool result = await collection.ExistsAsync(backendId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementBackendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateBackendServiceFabric() + public async Task GetIfExists_ApiManagementGetBackend() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateBackendServiceFabric.json - // this example is just showing the usage of "Backend_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetBackend.json + // this example is just showing the usage of "Backend_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -252,36 +255,21 @@ public async Task CreateOrUpdate_ApiManagementCreateBackendServiceFabric() // invoke the operation string backendId = "sfbackend"; - ApiManagementBackendData data = new ApiManagementBackendData() + NullableResponse response = await collection.GetIfExistsAsync(backendId); + ApiManagementBackendResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Description = "Service Fabric Test App 1", - BackendServiceFabricCluster = new BackendServiceFabricClusterProperties(new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"https://somecluster.com" - }) - { - ClientCertificateId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1", - MaxPartitionResolutionRetries = 5, - ServerX509Names = -{ -new X509CertificateName() -{ -Name = "ServerCommonName1", -IssuerCertificateThumbprint = "IssuerCertificateThumbprint1", -} -}, - }, - Uri = new Uri("fabric:/mytestapp/mytestservice"), - Protocol = BackendProtocol.Http, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backendId, data); - ApiManagementBackendResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementBackendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementBackendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementBackendResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementBackendResource.cs index 110bf5ab77532..fb06ec7424570 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementBackendResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementBackendResource.cs @@ -19,10 +19,10 @@ public partial class Sample_ApiManagementBackendResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadBackend() + public async Task Get_ApiManagementGetBackend() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadBackend.json - // this example is just showing the usage of "Backend_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetBackend.json + // this example is just showing the usage of "Backend_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadBackend() ApiManagementBackendResource apiManagementBackend = client.GetApiManagementBackendResource(apiManagementBackendResourceId); // invoke the operation - bool result = await apiManagementBackend.GetEntityTagAsync(); + ApiManagementBackendResource result = await apiManagementBackend.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementBackendData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetBackend() + public async Task Delete_ApiManagementDeleteBackend() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetBackend.json - // this example is just showing the usage of "Backend_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteBackend.json + // this example is just showing the usage of "Backend_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,13 +70,10 @@ public async Task Get_ApiManagementGetBackend() ApiManagementBackendResource apiManagementBackend = client.GetApiManagementBackendResource(apiManagementBackendResourceId); // invoke the operation - ApiManagementBackendResource result = await apiManagementBackend.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementBackend.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementBackendData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -98,10 +99,10 @@ public async Task Update_ApiManagementUpdateBackend() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementBackendPatch patch = new ApiManagementBackendPatch() + ApiManagementBackendPatch patch = new ApiManagementBackendPatch { Description = "description5308", - Tls = new BackendTlsProperties() + Tls = new BackendTlsProperties { ShouldValidateCertificateChain = false, ShouldValidateCertificateName = true, @@ -118,10 +119,10 @@ public async Task Update_ApiManagementUpdateBackend() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteBackend() + public async Task Reconnect_ApiManagementBackendReconnect() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteBackend.json - // this example is just showing the usage of "Backend_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementBackendReconnect.json + // this example is just showing the usage of "Backend_Reconnect" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,23 +134,26 @@ public async Task Delete_ApiManagementDeleteBackend() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string backendId = "sfbackend"; + string backendId = "proxybackend"; ResourceIdentifier apiManagementBackendResourceId = ApiManagementBackendResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, backendId); ApiManagementBackendResource apiManagementBackend = client.GetApiManagementBackendResource(apiManagementBackendResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementBackend.DeleteAsync(WaitUntil.Completed, ifMatch); + BackendReconnectContract backendReconnectContract = new BackendReconnectContract + { + After = XmlConvert.ToTimeSpan("PT3S"), + }; + await apiManagementBackend.ReconnectAsync(backendReconnectContract: backendReconnectContract); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Reconnect_ApiManagementBackendReconnect() + public async Task GetEntityTag_ApiManagementHeadBackend() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementBackendReconnect.json - // this example is just showing the usage of "Backend_Reconnect" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadBackend.json + // this example is just showing the usage of "Backend_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -161,18 +165,14 @@ public async Task Reconnect_ApiManagementBackendReconnect() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string backendId = "proxybackend"; + string backendId = "sfbackend"; ResourceIdentifier apiManagementBackendResourceId = ApiManagementBackendResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, backendId); ApiManagementBackendResource apiManagementBackend = client.GetApiManagementBackendResource(apiManagementBackendResourceId); // invoke the operation - BackendReconnectContract backendReconnectContract = new BackendReconnectContract() - { - After = XmlConvert.ToTimeSpan("PT3S"), - }; - await apiManagementBackend.ReconnectAsync(backendReconnectContract: backendReconnectContract); + bool result = await apiManagementBackend.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCacheCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCacheCollection.cs index b96cd32897900..0cf0e321e4fb0 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCacheCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCacheCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementCacheCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListCaches() + public async Task CreateOrUpdate_ApiManagementCreateCache() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListCaches.json - // this example is just showing the usage of "Cache_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateCache.json + // this example is just showing the usage of "Cache_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,23 @@ public async Task GetAll_ApiManagementListCaches() // get the collection of this ApiManagementCacheResource ApiManagementCacheCollection collection = apiManagementService.GetApiManagementCaches(); - // invoke the operation and iterate over the result - await foreach (ApiManagementCacheResource item in collection.GetAllAsync()) + // invoke the operation + string cacheId = "c1"; + ApiManagementCacheData data = new ApiManagementCacheData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCacheData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "Redis cache instances in West India", + ConnectionString = "apim.redis.cache.windows.net:6380,password=xc,ssl=True,abortConnect=False", + UseFromLocation = "default", + ResourceUri = new Uri("https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Cache/redis/apimservice1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cacheId, data); + ApiManagementCacheResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCacheData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +93,10 @@ public async Task Get_ApiManagementGetCache() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetCache() + public async Task GetAll_ApiManagementListCaches() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCache.json - // this example is just showing the usage of "Cache_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListCaches.json + // this example is just showing the usage of "Cache_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +114,22 @@ public async Task Exists_ApiManagementGetCache() // get the collection of this ApiManagementCacheResource ApiManagementCacheCollection collection = apiManagementService.GetApiManagementCaches(); - // invoke the operation - string cacheId = "c1"; - bool result = await collection.ExistsAsync(cacheId); + // invoke the operation and iterate over the result + await foreach (ApiManagementCacheResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCacheData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetCache() + public async Task Exists_ApiManagementGetCache() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCache.json // this example is just showing the usage of "Cache_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +152,17 @@ public async Task GetIfExists_ApiManagementGetCache() // invoke the operation string cacheId = "c1"; - NullableResponse response = await collection.GetIfExistsAsync(cacheId); - ApiManagementCacheResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(cacheId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCacheData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateCache() + public async Task GetIfExists_ApiManagementGetCache() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateCache.json - // this example is just showing the usage of "Cache_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCache.json + // this example is just showing the usage of "Cache_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,21 +182,21 @@ public async Task CreateOrUpdate_ApiManagementCreateCache() // invoke the operation string cacheId = "c1"; - ApiManagementCacheData data = new ApiManagementCacheData() - { - Description = "Redis cache instances in West India", - ConnectionString = "apim.redis.cache.windows.net:6380,password=xc,ssl=True,abortConnect=False", - UseFromLocation = "default", - ResourceUri = new Uri("https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Cache/redis/apimservice1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cacheId, data); - ApiManagementCacheResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(cacheId); + ApiManagementCacheResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCacheData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCacheData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCacheResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCacheResource.cs index 1f9fc337a5df5..3c94d9b5debb4 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCacheResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCacheResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementCacheResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadCache() + public async Task Get_ApiManagementGetCache() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadCache.json - // this example is just showing the usage of "Cache_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCache.json + // this example is just showing the usage of "Cache_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +33,26 @@ public async Task GetEntityTag_ApiManagementHeadCache() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string cacheId = "default"; + string cacheId = "c1"; ResourceIdentifier apiManagementCacheResourceId = ApiManagementCacheResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, cacheId); ApiManagementCacheResource apiManagementCache = client.GetApiManagementCacheResource(apiManagementCacheResourceId); // invoke the operation - bool result = await apiManagementCache.GetEntityTagAsync(); + ApiManagementCacheResource result = await apiManagementCache.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCacheData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetCache() + public async Task Delete_ApiManagementDeleteCache() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCache.json - // this example is just showing the usage of "Cache_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteCache.json + // this example is just showing the usage of "Cache_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,15 @@ public async Task Get_ApiManagementGetCache() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string cacheId = "c1"; + string cacheId = "southindia"; ResourceIdentifier apiManagementCacheResourceId = ApiManagementCacheResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, cacheId); ApiManagementCacheResource apiManagementCache = client.GetApiManagementCacheResource(apiManagementCacheResourceId); // invoke the operation - ApiManagementCacheResource result = await apiManagementCache.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementCache.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCacheData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateCache() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementCachePatch patch = new ApiManagementCachePatch() + ApiManagementCachePatch patch = new ApiManagementCachePatch { UseFromLocation = "westindia", }; @@ -112,10 +113,10 @@ public async Task Update_ApiManagementUpdateCache() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteCache() + public async Task GetEntityTag_ApiManagementHeadCache() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteCache.json - // this example is just showing the usage of "Cache_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadCache.json + // this example is just showing the usage of "Cache_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,15 +128,14 @@ public async Task Delete_ApiManagementDeleteCache() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string cacheId = "southindia"; + string cacheId = "default"; ResourceIdentifier apiManagementCacheResourceId = ApiManagementCacheResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, cacheId); ApiManagementCacheResource apiManagementCache = client.GetApiManagementCacheResource(apiManagementCacheResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementCache.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiManagementCache.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCertificateCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCertificateCollection.cs index a47d220cdecb5..5e2af7795ed4c 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCertificateCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCertificateCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListCertificates() + public async Task CreateOrUpdate_ApiManagementCreateCertificate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListCertificates.json - // this example is just showing the usage of "Certificate_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateCertificate.json + // this example is just showing the usage of "Certificate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,29 @@ public async Task GetAll_ApiManagementListCertificates() // get the collection of this ApiManagementCertificateResource ApiManagementCertificateCollection collection = apiManagementService.GetApiManagementCertificates(); - // invoke the operation and iterate over the result - await foreach (ApiManagementCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string certificateId = "tempcert"; + ApiManagementCertificateCreateOrUpdateContent content = new ApiManagementCertificateCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Data = "****************Base 64 Encoded Certificate *******************************", + Password = "****Certificate Password******", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateId, content); + ApiManagementCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetCertificate() + public async Task CreateOrUpdate_ApiManagementCreateCertificateWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificate.json - // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateCertificateWithKeyVault.json + // this example is just showing the usage of "Certificate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,8 +80,17 @@ public async Task Get_ApiManagementGetCertificate() ApiManagementCertificateCollection collection = apiManagementService.GetApiManagementCertificates(); // invoke the operation - string certificateId = "templateCert1"; - ApiManagementCertificateResource result = await collection.GetAsync(certificateId); + string certificateId = "templateCertkv"; + ApiManagementCertificateCreateOrUpdateContent content = new ApiManagementCertificateCreateOrUpdateContent + { + KeyVaultDetails = new KeyVaultContractCreateProperties + { + SecretIdentifier = "https://rpbvtkeyvaultintegration.vault-int.azure-int.net/secrets/msitestingCert", + IdentityClientId = "ceaa6b06-c00f-43ef-99ac-f53d1fe876a0", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateId, content); + ApiManagementCertificateResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +101,7 @@ public async Task Get_ApiManagementGetCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetCertificate() + public async Task Get_ApiManagementGetCertificate() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificate.json // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,16 +124,20 @@ public async Task Exists_ApiManagementGetCertificate() // invoke the operation string certificateId = "templateCert1"; - bool result = await collection.ExistsAsync(certificateId); + ApiManagementCertificateResource result = await collection.GetAsync(certificateId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetCertificate() + public async Task Get_ApiManagementGetCertificateWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificate.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificateWithKeyVault.json // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -140,30 +157,22 @@ public async Task GetIfExists_ApiManagementGetCertificate() ApiManagementCertificateCollection collection = apiManagementService.GetApiManagementCertificates(); // invoke the operation - string certificateId = "templateCert1"; - NullableResponse response = await collection.GetIfExistsAsync(certificateId); - ApiManagementCertificateResource result = response.HasValue ? response.Value : null; + string certificateId = "templateCertkv"; + ApiManagementCertificateResource result = await collection.GetAsync(certificateId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetCertificateWithKeyVault() + public async Task GetAll_ApiManagementListCertificates() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificateWithKeyVault.json - // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListCertificates.json + // this example is just showing the usage of "Certificate_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,22 +190,24 @@ public async Task Get_ApiManagementGetCertificateWithKeyVault() // get the collection of this ApiManagementCertificateResource ApiManagementCertificateCollection collection = apiManagementService.GetApiManagementCertificates(); - // invoke the operation - string certificateId = "templateCertkv"; - ApiManagementCertificateResource result = await collection.GetAsync(certificateId); + // invoke the operation and iterate over the result + await foreach (ApiManagementCertificateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetCertificateWithKeyVault() + public async Task Exists_ApiManagementGetCertificate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificateWithKeyVault.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificate.json // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -216,7 +227,7 @@ public async Task Exists_ApiManagementGetCertificateWithKeyVault() ApiManagementCertificateCollection collection = apiManagementService.GetApiManagementCertificates(); // invoke the operation - string certificateId = "templateCertkv"; + string certificateId = "templateCert1"; bool result = await collection.ExistsAsync(certificateId); Console.WriteLine($"Succeeded: {result}"); @@ -224,7 +235,7 @@ public async Task Exists_ApiManagementGetCertificateWithKeyVault() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetCertificateWithKeyVault() + public async Task Exists_ApiManagementGetCertificateWithKeyVault() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificateWithKeyVault.json // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. @@ -247,29 +258,17 @@ public async Task GetIfExists_ApiManagementGetCertificateWithKeyVault() // invoke the operation string certificateId = "templateCertkv"; - NullableResponse response = await collection.GetIfExistsAsync(certificateId); - ApiManagementCertificateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(certificateId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateCertificate() + public async Task GetIfExists_ApiManagementGetCertificate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateCertificate.json - // this example is just showing the usage of "Certificate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificate.json + // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -288,28 +287,30 @@ public async Task CreateOrUpdate_ApiManagementCreateCertificate() ApiManagementCertificateCollection collection = apiManagementService.GetApiManagementCertificates(); // invoke the operation - string certificateId = "tempcert"; - ApiManagementCertificateCreateOrUpdateContent content = new ApiManagementCertificateCreateOrUpdateContent() - { - Data = "****************Base 64 Encoded Certificate *******************************", - Password = "****Certificate Password******", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateId, content); - ApiManagementCertificateResource result = lro.Value; + string certificateId = "templateCert1"; + NullableResponse response = await collection.GetIfExistsAsync(certificateId); + ApiManagementCertificateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateCertificateWithKeyVault() + public async Task GetIfExists_ApiManagementGetCertificateWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateCertificateWithKeyVault.json - // this example is just showing the usage of "Certificate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificateWithKeyVault.json + // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -329,22 +330,21 @@ public async Task CreateOrUpdate_ApiManagementCreateCertificateWithKeyVault() // invoke the operation string certificateId = "templateCertkv"; - ApiManagementCertificateCreateOrUpdateContent content = new ApiManagementCertificateCreateOrUpdateContent() - { - KeyVaultDetails = new KeyVaultContractCreateProperties() - { - SecretIdentifier = "https://rpbvtkeyvaultintegration.vault-int.azure-int.net/secrets/msitestingCert", - IdentityClientId = "ceaa6b06-c00f-43ef-99ac-f53d1fe876a0", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateId, content); - ApiManagementCertificateResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(certificateId); + ApiManagementCertificateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCertificateResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCertificateResource.cs index eb6cf502dc3b1..f41fb422671ff 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCertificateResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementCertificateResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementCertificateResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadCertificate() + public async Task Get_ApiManagementGetCertificate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadCertificate.json - // this example is just showing the usage of "Certificate_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificate.json + // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,20 @@ public async Task GetEntityTag_ApiManagementHeadCertificate() ApiManagementCertificateResource apiManagementCertificate = client.GetApiManagementCertificateResource(apiManagementCertificateResourceId); // invoke the operation - bool result = await apiManagementCertificate.GetEntityTagAsync(); + ApiManagementCertificateResource result = await apiManagementCertificate.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetCertificate() + public async Task Get_ApiManagementGetCertificateWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificate.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificateWithKeyVault.json // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -60,7 +64,7 @@ public async Task Get_ApiManagementGetCertificate() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string certificateId = "templateCert1"; + string certificateId = "templateCertkv"; ResourceIdentifier apiManagementCertificateResourceId = ApiManagementCertificateResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, certificateId); ApiManagementCertificateResource apiManagementCertificate = client.GetApiManagementCertificateResource(apiManagementCertificateResourceId); @@ -76,10 +80,10 @@ public async Task Get_ApiManagementGetCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetCertificateWithKeyVault() + public async Task Delete_ApiManagementDeleteCertificate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetCertificateWithKeyVault.json - // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteCertificate.json + // this example is just showing the usage of "Certificate_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,18 +95,15 @@ public async Task Get_ApiManagementGetCertificateWithKeyVault() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string certificateId = "templateCertkv"; + string certificateId = "tempcert"; ResourceIdentifier apiManagementCertificateResourceId = ApiManagementCertificateResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, certificateId); ApiManagementCertificateResource apiManagementCertificate = client.GetApiManagementCertificateResource(apiManagementCertificateResourceId); // invoke the operation - ApiManagementCertificateResource result = await apiManagementCertificate.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementCertificate.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -127,7 +128,7 @@ public async Task Update_ApiManagementCreateCertificate() ApiManagementCertificateResource apiManagementCertificate = client.GetApiManagementCertificateResource(apiManagementCertificateResourceId); // invoke the operation - ApiManagementCertificateCreateOrUpdateContent content = new ApiManagementCertificateCreateOrUpdateContent() + ApiManagementCertificateCreateOrUpdateContent content = new ApiManagementCertificateCreateOrUpdateContent { Data = "****************Base 64 Encoded Certificate *******************************", Password = "****Certificate Password******", @@ -164,9 +165,9 @@ public async Task Update_ApiManagementCreateCertificateWithKeyVault() ApiManagementCertificateResource apiManagementCertificate = client.GetApiManagementCertificateResource(apiManagementCertificateResourceId); // invoke the operation - ApiManagementCertificateCreateOrUpdateContent content = new ApiManagementCertificateCreateOrUpdateContent() + ApiManagementCertificateCreateOrUpdateContent content = new ApiManagementCertificateCreateOrUpdateContent { - KeyVaultDetails = new KeyVaultContractCreateProperties() + KeyVaultDetails = new KeyVaultContractCreateProperties { SecretIdentifier = "https://rpbvtkeyvaultintegration.vault-int.azure-int.net/secrets/msitestingCert", IdentityClientId = "ceaa6b06-c00f-43ef-99ac-f53d1fe876a0", @@ -184,10 +185,10 @@ public async Task Update_ApiManagementCreateCertificateWithKeyVault() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteCertificate() + public async Task RefreshSecret_ApiManagementRefreshCertificate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteCertificate.json - // this example is just showing the usage of "Certificate_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementRefreshCertificate.json + // this example is just showing the usage of "Certificate_RefreshSecret" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,23 +200,26 @@ public async Task Delete_ApiManagementDeleteCertificate() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string certificateId = "tempcert"; + string certificateId = "templateCertkv"; ResourceIdentifier apiManagementCertificateResourceId = ApiManagementCertificateResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, certificateId); ApiManagementCertificateResource apiManagementCertificate = client.GetApiManagementCertificateResource(apiManagementCertificateResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementCertificate.DeleteAsync(WaitUntil.Completed, ifMatch); + ApiManagementCertificateResource result = await apiManagementCertificate.RefreshSecretAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task RefreshSecret_ApiManagementRefreshCertificate() + public async Task GetEntityTag_ApiManagementHeadCertificate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementRefreshCertificate.json - // this example is just showing the usage of "Certificate_RefreshSecret" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadCertificate.json + // this example is just showing the usage of "Certificate_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -227,18 +231,14 @@ public async Task RefreshSecret_ApiManagementRefreshCertificate() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string certificateId = "templateCertkv"; + string certificateId = "templateCert1"; ResourceIdentifier apiManagementCertificateResourceId = ApiManagementCertificateResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, certificateId); ApiManagementCertificateResource apiManagementCertificate = client.GetApiManagementCertificateResource(apiManagementCertificateResourceId); // invoke the operation - ApiManagementCertificateResource result = await apiManagementCertificate.RefreshSecretAsync(); + bool result = await apiManagementCertificate.GetEntityTagAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDeletedServiceResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDeletedServiceResource.cs index fa9c3a0a1671f..98dba7561125d 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDeletedServiceResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDeletedServiceResource.cs @@ -9,44 +9,12 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ApiManagement.Samples { public partial class Sample_ApiManagementDeletedServiceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApiManagementDeletedServices_ApiManagementDeletedServicesListBySubscription() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeletedServicesListBySubscription.json - // this example is just showing the usage of "DeletedServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ApiManagementDeletedServiceResource item in subscriptionResource.GetApiManagementDeletedServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementDeletedServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ApiManagementGetDeletedServiceByName() diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDiagnosticCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDiagnosticCollection.cs index 5036dda0ed06f..f2a4dae71c04a 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDiagnosticCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDiagnosticCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementDiagnosticCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListDiagnostics() + public async Task CreateOrUpdate_ApiManagementCreateDiagnostic() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListDiagnostics.json - // this example is just showing the usage of "Diagnostic_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateDiagnostic.json + // this example is just showing the usage of "Diagnostic_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,52 @@ public async Task GetAll_ApiManagementListDiagnostics() // get the collection of this ApiManagementDiagnosticResource ApiManagementDiagnosticCollection collection = apiManagementService.GetApiManagementDiagnostics(); - // invoke the operation and iterate over the result - await foreach (ApiManagementDiagnosticResource item in collection.GetAllAsync()) + // invoke the operation + string diagnosticId = "applicationinsights"; + DiagnosticContractData data = new DiagnosticContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AlwaysLog = AlwaysLog.AllErrors, + LoggerId = "/loggers/azuremonitor", + Sampling = new SamplingSettings + { + SamplingType = SamplingType.Fixed, + Percentage = 50, + }, + Frontend = new PipelineDiagnosticSettings + { + Request = new HttpMessageDiagnostic + { + Headers = { "Content-type" }, + BodyBytes = 512, + }, + Response = new HttpMessageDiagnostic + { + Headers = { "Content-type" }, + BodyBytes = 512, + }, + }, + Backend = new PipelineDiagnosticSettings + { + Request = new HttpMessageDiagnostic + { + Headers = { "Content-type" }, + BodyBytes = 512, + }, + Response = new HttpMessageDiagnostic + { + Headers = { "Content-type" }, + BodyBytes = 512, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diagnosticId, data); + ApiManagementDiagnosticResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +123,10 @@ public async Task Get_ApiManagementGetDiagnostic() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetDiagnostic() + public async Task GetAll_ApiManagementListDiagnostics() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetDiagnostic.json - // this example is just showing the usage of "Diagnostic_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListDiagnostics.json + // this example is just showing the usage of "Diagnostic_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +144,22 @@ public async Task Exists_ApiManagementGetDiagnostic() // get the collection of this ApiManagementDiagnosticResource ApiManagementDiagnosticCollection collection = apiManagementService.GetApiManagementDiagnostics(); - // invoke the operation - string diagnosticId = "applicationinsights"; - bool result = await collection.ExistsAsync(diagnosticId); + // invoke the operation and iterate over the result + await foreach (ApiManagementDiagnosticResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetDiagnostic() + public async Task Exists_ApiManagementGetDiagnostic() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetDiagnostic.json // this example is just showing the usage of "Diagnostic_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +182,17 @@ public async Task GetIfExists_ApiManagementGetDiagnostic() // invoke the operation string diagnosticId = "applicationinsights"; - NullableResponse response = await collection.GetIfExistsAsync(diagnosticId); - ApiManagementDiagnosticResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(diagnosticId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateDiagnostic() + public async Task GetIfExists_ApiManagementGetDiagnostic() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateDiagnostic.json - // this example is just showing the usage of "Diagnostic_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetDiagnostic.json + // this example is just showing the usage of "Diagnostic_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,62 +212,21 @@ public async Task CreateOrUpdate_ApiManagementCreateDiagnostic() // invoke the operation string diagnosticId = "applicationinsights"; - DiagnosticContractData data = new DiagnosticContractData() - { - AlwaysLog = AlwaysLog.AllErrors, - LoggerId = "/loggers/azuremonitor", - Sampling = new SamplingSettings() - { - SamplingType = SamplingType.Fixed, - Percentage = 50, - }, - Frontend = new PipelineDiagnosticSettings() - { - Request = new HttpMessageDiagnostic() - { - Headers = -{ -"Content-type" -}, - BodyBytes = 512, - }, - Response = new HttpMessageDiagnostic() - { - Headers = -{ -"Content-type" -}, - BodyBytes = 512, - }, - }, - Backend = new PipelineDiagnosticSettings() - { - Request = new HttpMessageDiagnostic() - { - Headers = -{ -"Content-type" -}, - BodyBytes = 512, - }, - Response = new HttpMessageDiagnostic() - { - Headers = -{ -"Content-type" -}, - BodyBytes = 512, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, diagnosticId, data); - ApiManagementDiagnosticResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(diagnosticId); + ApiManagementDiagnosticResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDiagnosticResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDiagnosticResource.cs index 2c21f25467f4e..0858866d1d47c 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDiagnosticResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementDiagnosticResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementDiagnosticResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadDiagnostic() + public async Task Get_ApiManagementGetDiagnostic() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadDiagnostic.json - // this example is just showing the usage of "Diagnostic_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetDiagnostic.json + // this example is just showing the usage of "Diagnostic_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadDiagnostic() ApiManagementDiagnosticResource apiManagementDiagnostic = client.GetApiManagementDiagnosticResource(apiManagementDiagnosticResourceId); // invoke the operation - bool result = await apiManagementDiagnostic.GetEntityTagAsync(); + ApiManagementDiagnosticResource result = await apiManagementDiagnostic.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetDiagnostic() + public async Task Delete_ApiManagementDeleteDiagnostic() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetDiagnostic.json - // this example is just showing the usage of "Diagnostic_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteDiagnostic.json + // this example is just showing the usage of "Diagnostic_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,10 @@ public async Task Get_ApiManagementGetDiagnostic() ApiManagementDiagnosticResource apiManagementDiagnostic = client.GetApiManagementDiagnosticResource(apiManagementDiagnosticResourceId); // invoke the operation - ApiManagementDiagnosticResource result = await apiManagementDiagnostic.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementDiagnostic.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,50 +98,38 @@ public async Task Update_ApiManagementUpdateDiagnostic() // invoke the operation ETag ifMatch = new ETag("*"); - DiagnosticContractData data = new DiagnosticContractData() + DiagnosticContractData data = new DiagnosticContractData { AlwaysLog = AlwaysLog.AllErrors, LoggerId = "/loggers/applicationinsights", - Sampling = new SamplingSettings() + Sampling = new SamplingSettings { SamplingType = SamplingType.Fixed, Percentage = 50, }, - Frontend = new PipelineDiagnosticSettings() + Frontend = new PipelineDiagnosticSettings { - Request = new HttpMessageDiagnostic() + Request = new HttpMessageDiagnostic { - Headers = -{ -"Content-type" -}, + Headers = { "Content-type" }, BodyBytes = 512, }, - Response = new HttpMessageDiagnostic() + Response = new HttpMessageDiagnostic { - Headers = -{ -"Content-type" -}, + Headers = { "Content-type" }, BodyBytes = 512, }, }, - Backend = new PipelineDiagnosticSettings() + Backend = new PipelineDiagnosticSettings { - Request = new HttpMessageDiagnostic() + Request = new HttpMessageDiagnostic { - Headers = -{ -"Content-type" -}, + Headers = { "Content-type" }, BodyBytes = 512, }, - Response = new HttpMessageDiagnostic() + Response = new HttpMessageDiagnostic { - Headers = -{ -"Content-type" -}, + Headers = { "Content-type" }, BodyBytes = 512, }, }, @@ -156,10 +145,10 @@ public async Task Update_ApiManagementUpdateDiagnostic() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteDiagnostic() + public async Task GetEntityTag_ApiManagementHeadDiagnostic() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteDiagnostic.json - // this example is just showing the usage of "Diagnostic_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadDiagnostic.json + // this example is just showing the usage of "Diagnostic_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,10 +165,9 @@ public async Task Delete_ApiManagementDeleteDiagnostic() ApiManagementDiagnosticResource apiManagementDiagnostic = client.GetApiManagementDiagnosticResource(apiManagementDiagnosticResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementDiagnostic.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiManagementDiagnostic.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementEmailTemplateCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementEmailTemplateCollection.cs index 6bdb611cf99ad..dc1ae49c279c5 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementEmailTemplateCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementEmailTemplateCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementEmailTemplateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListTemplates() + public async Task CreateOrUpdate_ApiManagementCreateTemplate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTemplates.json - // this example is just showing the usage of "EmailTemplate_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTemplate.json + // this example is just showing the usage of "EmailTemplate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ApiManagementListTemplates() // get the collection of this ApiManagementEmailTemplateResource ApiManagementEmailTemplateCollection collection = apiManagementService.GetApiManagementEmailTemplates(); - // invoke the operation and iterate over the result - await foreach (ApiManagementEmailTemplateResource item in collection.GetAllAsync()) + // invoke the operation + TemplateName templateName = TemplateName.NewIssueNotificationMessage; + ApiManagementEmailTemplateCreateOrUpdateContent content = new ApiManagementEmailTemplateCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementEmailTemplateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Subject = "Your request for $IssueName was successfully received.", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, templateName, content); + ApiManagementEmailTemplateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementEmailTemplateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_ApiManagementGetTemplate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetTemplate() + public async Task GetAll_ApiManagementListTemplates() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTemplate.json - // this example is just showing the usage of "EmailTemplate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTemplates.json + // this example is just showing the usage of "EmailTemplate_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_ApiManagementGetTemplate() // get the collection of this ApiManagementEmailTemplateResource ApiManagementEmailTemplateCollection collection = apiManagementService.GetApiManagementEmailTemplates(); - // invoke the operation - TemplateName templateName = TemplateName.NewIssueNotificationMessage; - bool result = await collection.ExistsAsync(templateName); + // invoke the operation and iterate over the result + await foreach (ApiManagementEmailTemplateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementEmailTemplateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetTemplate() + public async Task Exists_ApiManagementGetTemplate() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTemplate.json // this example is just showing the usage of "EmailTemplate_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_ApiManagementGetTemplate() // invoke the operation TemplateName templateName = TemplateName.NewIssueNotificationMessage; - NullableResponse response = await collection.GetIfExistsAsync(templateName); - ApiManagementEmailTemplateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(templateName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementEmailTemplateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateTemplate() + public async Task GetIfExists_ApiManagementGetTemplate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTemplate.json - // this example is just showing the usage of "EmailTemplate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTemplate.json + // this example is just showing the usage of "EmailTemplate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_ApiManagementCreateTemplate() // invoke the operation TemplateName templateName = TemplateName.NewIssueNotificationMessage; - ApiManagementEmailTemplateCreateOrUpdateContent content = new ApiManagementEmailTemplateCreateOrUpdateContent() - { - Subject = "Your request for $IssueName was successfully received.", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, templateName, content); - ApiManagementEmailTemplateResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(templateName); + ApiManagementEmailTemplateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementEmailTemplateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementEmailTemplateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementEmailTemplateResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementEmailTemplateResource.cs index ea075296285aa..efe57f61eb8a7 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementEmailTemplateResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementEmailTemplateResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementEmailTemplateResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadEmailTemplate() + public async Task Get_ApiManagementGetTemplate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadEmailTemplate.json - // this example is just showing the usage of "EmailTemplate_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTemplate.json + // this example is just showing the usage of "EmailTemplate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadEmailTemplate() ApiManagementEmailTemplateResource apiManagementEmailTemplate = client.GetApiManagementEmailTemplateResource(apiManagementEmailTemplateResourceId); // invoke the operation - bool result = await apiManagementEmailTemplate.GetEntityTagAsync(); + ApiManagementEmailTemplateResource result = await apiManagementEmailTemplate.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementEmailTemplateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetTemplate() + public async Task Delete_ApiManagementDeleteTemplate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTemplate.json - // this example is just showing the usage of "EmailTemplate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteTemplate.json + // this example is just showing the usage of "EmailTemplate_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,10 @@ public async Task Get_ApiManagementGetTemplate() ApiManagementEmailTemplateResource apiManagementEmailTemplate = client.GetApiManagementEmailTemplateResource(apiManagementEmailTemplateResourceId); // invoke the operation - ApiManagementEmailTemplateResource result = await apiManagementEmailTemplate.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementEmailTemplate.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementEmailTemplateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateTemplate() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementEmailTemplateCreateOrUpdateContent content = new ApiManagementEmailTemplateCreateOrUpdateContent() + ApiManagementEmailTemplateCreateOrUpdateContent content = new ApiManagementEmailTemplateCreateOrUpdateContent { Subject = "Your request $IssueName was received", Body = "\r\n\r\n \r\n \r\n

Dear $DevFirstName $DevLastName,

\r\n

\r\n We are happy to let you know that your request to publish the $AppName application in the gallery has been approved. Your application has been published and can be viewed here.\r\n

\r\n

Best,

\r\n

The $OrganizationName API Team

\r\n \r\n", @@ -113,10 +114,10 @@ public async Task Update_ApiManagementUpdateTemplate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteTemplate() + public async Task GetEntityTag_ApiManagementHeadEmailTemplate() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteTemplate.json - // this example is just showing the usage of "EmailTemplate_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadEmailTemplate.json + // this example is just showing the usage of "EmailTemplate_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,10 +134,9 @@ public async Task Delete_ApiManagementDeleteTemplate() ApiManagementEmailTemplateResource apiManagementEmailTemplate = client.GetApiManagementEmailTemplateResource(apiManagementEmailTemplateResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementEmailTemplate.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiManagementEmailTemplate.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCertificateAuthorityCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCertificateAuthorityCollection.cs index 5f10bfdbf7f7b..bf2ae5c114f49 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCertificateAuthorityCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCertificateAuthorityCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementGatewayCertificateAuthorityCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListGatewaycertificateAuthorities() + public async Task CreateOrUpdate_ApiManagementCreateGatewayCertificateAuthority() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGatewayCertificateAuthorities.json - // this example is just showing the usage of "GatewayCertificateAuthority_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGatewayCertificateAuthority.json + // this example is just showing the usage of "GatewayCertificateAuthority_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ApiManagementListGatewaycertificateAuthorities() // get the collection of this ApiManagementGatewayCertificateAuthorityResource ApiManagementGatewayCertificateAuthorityCollection collection = apiManagementGateway.GetApiManagementGatewayCertificateAuthorities(); - // invoke the operation and iterate over the result - await foreach (ApiManagementGatewayCertificateAuthorityResource item in collection.GetAllAsync()) + // invoke the operation + string certificateId = "cert1"; + ApiManagementGatewayCertificateAuthorityData data = new ApiManagementGatewayCertificateAuthorityData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayCertificateAuthorityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsTrusted = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateId, data); + ApiManagementGatewayCertificateAuthorityResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayCertificateAuthorityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_ApiManagementGetGatewayCertificateAuthority() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetGatewayCertificateAuthority() + public async Task GetAll_ApiManagementListGatewaycertificateAuthorities() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGatewayCertificateAuthority.json - // this example is just showing the usage of "GatewayCertificateAuthority_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGatewayCertificateAuthorities.json + // this example is just showing the usage of "GatewayCertificateAuthority_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +114,22 @@ public async Task Exists_ApiManagementGetGatewayCertificateAuthority() // get the collection of this ApiManagementGatewayCertificateAuthorityResource ApiManagementGatewayCertificateAuthorityCollection collection = apiManagementGateway.GetApiManagementGatewayCertificateAuthorities(); - // invoke the operation - string certificateId = "cert1"; - bool result = await collection.ExistsAsync(certificateId); + // invoke the operation and iterate over the result + await foreach (ApiManagementGatewayCertificateAuthorityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayCertificateAuthorityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetGatewayCertificateAuthority() + public async Task Exists_ApiManagementGetGatewayCertificateAuthority() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGatewayCertificateAuthority.json // this example is just showing the usage of "GatewayCertificateAuthority_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +153,17 @@ public async Task GetIfExists_ApiManagementGetGatewayCertificateAuthority() // invoke the operation string certificateId = "cert1"; - NullableResponse response = await collection.GetIfExistsAsync(certificateId); - ApiManagementGatewayCertificateAuthorityResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(certificateId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayCertificateAuthorityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateGatewayCertificateAuthority() + public async Task GetIfExists_ApiManagementGetGatewayCertificateAuthority() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGatewayCertificateAuthority.json - // this example is just showing the usage of "GatewayCertificateAuthority_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGatewayCertificateAuthority.json + // this example is just showing the usage of "GatewayCertificateAuthority_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +184,21 @@ public async Task CreateOrUpdate_ApiManagementCreateGatewayCertificateAuthority( // invoke the operation string certificateId = "cert1"; - ApiManagementGatewayCertificateAuthorityData data = new ApiManagementGatewayCertificateAuthorityData() - { - IsTrusted = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateId, data); - ApiManagementGatewayCertificateAuthorityResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(certificateId); + ApiManagementGatewayCertificateAuthorityResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayCertificateAuthorityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayCertificateAuthorityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCertificateAuthorityResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCertificateAuthorityResource.cs index ae8019be2f0f4..760028ae31faa 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCertificateAuthorityResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCertificateAuthorityResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementGatewayCertificateAuthorityResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadGatewayCertificateAuthority() + public async Task Get_ApiManagementGetGatewayCertificateAuthority() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGatewayCertificateAuthority.json - // this example is just showing the usage of "GatewayCertificateAuthority_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGatewayCertificateAuthority.json + // this example is just showing the usage of "GatewayCertificateAuthority_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadGatewayCertificateAuthority() ApiManagementGatewayCertificateAuthorityResource apiManagementGatewayCertificateAuthority = client.GetApiManagementGatewayCertificateAuthorityResource(apiManagementGatewayCertificateAuthorityResourceId); // invoke the operation - bool result = await apiManagementGatewayCertificateAuthority.GetEntityTagAsync(); + ApiManagementGatewayCertificateAuthorityResource result = await apiManagementGatewayCertificateAuthority.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayCertificateAuthorityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetGatewayCertificateAuthority() + public async Task Delete_ApiManagementDeleteGatewayCertificateAuthority() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGatewayCertificateAuthority.json - // this example is just showing the usage of "GatewayCertificateAuthority_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGatewayCertificateAuthority.json + // this example is just showing the usage of "GatewayCertificateAuthority_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,18 +65,15 @@ public async Task Get_ApiManagementGetGatewayCertificateAuthority() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string gatewayId = "gw1"; - string certificateId = "cert1"; + string certificateId = "default"; ResourceIdentifier apiManagementGatewayCertificateAuthorityResourceId = ApiManagementGatewayCertificateAuthorityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, gatewayId, certificateId); ApiManagementGatewayCertificateAuthorityResource apiManagementGatewayCertificateAuthority = client.GetApiManagementGatewayCertificateAuthorityResource(apiManagementGatewayCertificateAuthorityResourceId); // invoke the operation - ApiManagementGatewayCertificateAuthorityResource result = await apiManagementGatewayCertificateAuthority.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementGatewayCertificateAuthority.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayCertificateAuthorityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -98,7 +99,7 @@ public async Task Update_ApiManagementCreateGatewayCertificateAuthority() ApiManagementGatewayCertificateAuthorityResource apiManagementGatewayCertificateAuthority = client.GetApiManagementGatewayCertificateAuthorityResource(apiManagementGatewayCertificateAuthorityResourceId); // invoke the operation - ApiManagementGatewayCertificateAuthorityData data = new ApiManagementGatewayCertificateAuthorityData() + ApiManagementGatewayCertificateAuthorityData data = new ApiManagementGatewayCertificateAuthorityData { IsTrusted = false, }; @@ -114,10 +115,10 @@ public async Task Update_ApiManagementCreateGatewayCertificateAuthority() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteGatewayCertificateAuthority() + public async Task GetEntityTag_ApiManagementHeadGatewayCertificateAuthority() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGatewayCertificateAuthority.json - // this example is just showing the usage of "GatewayCertificateAuthority_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGatewayCertificateAuthority.json + // this example is just showing the usage of "GatewayCertificateAuthority_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,15 +131,14 @@ public async Task Delete_ApiManagementDeleteGatewayCertificateAuthority() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string gatewayId = "gw1"; - string certificateId = "default"; + string certificateId = "cert1"; ResourceIdentifier apiManagementGatewayCertificateAuthorityResourceId = ApiManagementGatewayCertificateAuthorityResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, gatewayId, certificateId); ApiManagementGatewayCertificateAuthorityResource apiManagementGatewayCertificateAuthority = client.GetApiManagementGatewayCertificateAuthorityResource(apiManagementGatewayCertificateAuthorityResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementGatewayCertificateAuthority.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiManagementGatewayCertificateAuthority.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCollection.cs index 94edf0ad60faa..969a61fbf4346 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementGatewayCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListGateways() + public async Task CreateOrUpdate_ApiManagementCreateGateway() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGateways.json - // this example is just showing the usage of "Gateway_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGateway.json + // this example is just showing the usage of "Gateway_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ApiManagementListGateways() // get the collection of this ApiManagementGatewayResource ApiManagementGatewayCollection collection = apiManagementService.GetApiManagementGateways(); - // invoke the operation and iterate over the result - await foreach (ApiManagementGatewayResource item in collection.GetAllAsync()) + // invoke the operation + string gatewayId = "gw1"; + ApiManagementGatewayData data = new ApiManagementGatewayData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + LocationData = new ResourceLocationDataContract("my location"), + Description = "my gateway 1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gatewayId, data); + ApiManagementGatewayResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_ApiManagementGetGateway() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetGateway() + public async Task GetAll_ApiManagementListGateways() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGateway.json - // this example is just showing the usage of "Gateway_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGateways.json + // this example is just showing the usage of "Gateway_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +113,22 @@ public async Task Exists_ApiManagementGetGateway() // get the collection of this ApiManagementGatewayResource ApiManagementGatewayCollection collection = apiManagementService.GetApiManagementGateways(); - // invoke the operation - string gatewayId = "gw1"; - bool result = await collection.ExistsAsync(gatewayId); + // invoke the operation and iterate over the result + await foreach (ApiManagementGatewayResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetGateway() + public async Task Exists_ApiManagementGetGateway() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGateway.json // this example is just showing the usage of "Gateway_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_ApiManagementGetGateway() // invoke the operation string gatewayId = "gw1"; - NullableResponse response = await collection.GetIfExistsAsync(gatewayId); - ApiManagementGatewayResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(gatewayId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateGateway() + public async Task GetIfExists_ApiManagementGetGateway() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGateway.json - // this example is just showing the usage of "Gateway_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGateway.json + // this example is just showing the usage of "Gateway_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,19 +181,21 @@ public async Task CreateOrUpdate_ApiManagementCreateGateway() // invoke the operation string gatewayId = "gw1"; - ApiManagementGatewayData data = new ApiManagementGatewayData() - { - LocationData = new ResourceLocationDataContract("my location"), - Description = "my gateway 1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gatewayId, data); - ApiManagementGatewayResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(gatewayId); + ApiManagementGatewayResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayHostnameConfigurationCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayHostnameConfigurationCollection.cs index 1ef6a38e55019..0ceba842822dd 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayHostnameConfigurationCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayHostnameConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementGatewayHostnameConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListGatewayHostnameConfigurations() + public async Task CreateOrUpdate_ApiManagementCreateGatewayHostnameConfiguration() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGatewayHostnameConfigurations.json - // this example is just showing the usage of "GatewayHostnameConfiguration_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGatewayHostnameConfiguration.json + // this example is just showing the usage of "GatewayHostnameConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ApiManagementListGatewayHostnameConfigurations() // get the collection of this ApiManagementGatewayHostnameConfigurationResource ApiManagementGatewayHostnameConfigurationCollection collection = apiManagementGateway.GetApiManagementGatewayHostnameConfigurations(); - // invoke the operation and iterate over the result - await foreach (ApiManagementGatewayHostnameConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string hcId = "default"; + ApiManagementGatewayHostnameConfigurationData data = new ApiManagementGatewayHostnameConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayHostnameConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Hostname = "*", + CertificateId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1", + IsClientCertificateRequired = false, + IsTls1_0Enabled = false, + IsTls1_1Enabled = false, + IsHttp2_0Enabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hcId, data); + ApiManagementGatewayHostnameConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayHostnameConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +97,10 @@ public async Task Get_ApiManagementGetGatewayHostnameConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetGatewayHostnameConfiguration() + public async Task GetAll_ApiManagementListGatewayHostnameConfigurations() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGatewayHostnameConfiguration.json - // this example is just showing the usage of "GatewayHostnameConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGatewayHostnameConfigurations.json + // this example is just showing the usage of "GatewayHostnameConfiguration_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +119,22 @@ public async Task Exists_ApiManagementGetGatewayHostnameConfiguration() // get the collection of this ApiManagementGatewayHostnameConfigurationResource ApiManagementGatewayHostnameConfigurationCollection collection = apiManagementGateway.GetApiManagementGatewayHostnameConfigurations(); - // invoke the operation - string hcId = "default"; - bool result = await collection.ExistsAsync(hcId); + // invoke the operation and iterate over the result + await foreach (ApiManagementGatewayHostnameConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayHostnameConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetGatewayHostnameConfiguration() + public async Task Exists_ApiManagementGetGatewayHostnameConfiguration() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGatewayHostnameConfiguration.json // this example is just showing the usage of "GatewayHostnameConfiguration_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +158,17 @@ public async Task GetIfExists_ApiManagementGetGatewayHostnameConfiguration() // invoke the operation string hcId = "default"; - NullableResponse response = await collection.GetIfExistsAsync(hcId); - ApiManagementGatewayHostnameConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(hcId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayHostnameConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateGatewayHostnameConfiguration() + public async Task GetIfExists_ApiManagementGetGatewayHostnameConfiguration() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGatewayHostnameConfiguration.json - // this example is just showing the usage of "GatewayHostnameConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGatewayHostnameConfiguration.json + // this example is just showing the usage of "GatewayHostnameConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,23 +189,21 @@ public async Task CreateOrUpdate_ApiManagementCreateGatewayHostnameConfiguration // invoke the operation string hcId = "default"; - ApiManagementGatewayHostnameConfigurationData data = new ApiManagementGatewayHostnameConfigurationData() - { - Hostname = "*", - CertificateId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1", - IsClientCertificateRequired = false, - IsTls1_0Enabled = false, - IsTls1_1Enabled = false, - IsHttp2_0Enabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hcId, data); - ApiManagementGatewayHostnameConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(hcId); + ApiManagementGatewayHostnameConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayHostnameConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayHostnameConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayHostnameConfigurationResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayHostnameConfigurationResource.cs index 70dc56def41f5..f1bb9dcfc68df 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayHostnameConfigurationResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayHostnameConfigurationResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementGatewayHostnameConfigurationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadGatewayHostnameConfiguration() + public async Task Get_ApiManagementGetGatewayHostnameConfiguration() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGatewayHostnameConfiguration.json - // this example is just showing the usage of "GatewayHostnameConfiguration_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGatewayHostnameConfiguration.json + // this example is just showing the usage of "GatewayHostnameConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadGatewayHostnameConfiguration() ApiManagementGatewayHostnameConfigurationResource apiManagementGatewayHostnameConfiguration = client.GetApiManagementGatewayHostnameConfigurationResource(apiManagementGatewayHostnameConfigurationResourceId); // invoke the operation - bool result = await apiManagementGatewayHostnameConfiguration.GetEntityTagAsync(); + ApiManagementGatewayHostnameConfigurationResource result = await apiManagementGatewayHostnameConfiguration.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayHostnameConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetGatewayHostnameConfiguration() + public async Task Delete_ApiManagementDeleteGatewayHostnameConfiguration() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGatewayHostnameConfiguration.json - // this example is just showing the usage of "GatewayHostnameConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGatewayHostnameConfiguration.json + // this example is just showing the usage of "GatewayHostnameConfiguration_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,13 +70,10 @@ public async Task Get_ApiManagementGetGatewayHostnameConfiguration() ApiManagementGatewayHostnameConfigurationResource apiManagementGatewayHostnameConfiguration = client.GetApiManagementGatewayHostnameConfigurationResource(apiManagementGatewayHostnameConfigurationResourceId); // invoke the operation - ApiManagementGatewayHostnameConfigurationResource result = await apiManagementGatewayHostnameConfiguration.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementGatewayHostnameConfiguration.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayHostnameConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -98,7 +99,7 @@ public async Task Update_ApiManagementCreateGatewayHostnameConfiguration() ApiManagementGatewayHostnameConfigurationResource apiManagementGatewayHostnameConfiguration = client.GetApiManagementGatewayHostnameConfigurationResource(apiManagementGatewayHostnameConfigurationResourceId); // invoke the operation - ApiManagementGatewayHostnameConfigurationData data = new ApiManagementGatewayHostnameConfigurationData() + ApiManagementGatewayHostnameConfigurationData data = new ApiManagementGatewayHostnameConfigurationData { Hostname = "*", CertificateId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/certificates/cert1", @@ -119,10 +120,10 @@ public async Task Update_ApiManagementCreateGatewayHostnameConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteGatewayHostnameConfiguration() + public async Task GetEntityTag_ApiManagementHeadGatewayHostnameConfiguration() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGatewayHostnameConfiguration.json - // this example is just showing the usage of "GatewayHostnameConfiguration_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGatewayHostnameConfiguration.json + // this example is just showing the usage of "GatewayHostnameConfiguration_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,10 +141,9 @@ public async Task Delete_ApiManagementDeleteGatewayHostnameConfiguration() ApiManagementGatewayHostnameConfigurationResource apiManagementGatewayHostnameConfiguration = client.GetApiManagementGatewayHostnameConfigurationResource(apiManagementGatewayHostnameConfigurationResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementGatewayHostnameConfiguration.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiManagementGatewayHostnameConfiguration.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayResource.cs index 3ad60afda258b..3f38e2ed29c62 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGatewayResource.cs @@ -20,10 +20,10 @@ public partial class Sample_ApiManagementGatewayResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadGateway() + public async Task Get_ApiManagementGetGateway() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGateway.json - // this example is just showing the usage of "Gateway_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGateway.json + // this example is just showing the usage of "Gateway_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,22 +35,26 @@ public async Task GetEntityTag_ApiManagementHeadGateway() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string gatewayId = "mygateway"; + string gatewayId = "gw1"; ResourceIdentifier apiManagementGatewayResourceId = ApiManagementGatewayResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, gatewayId); ApiManagementGatewayResource apiManagementGateway = client.GetApiManagementGatewayResource(apiManagementGatewayResourceId); // invoke the operation - bool result = await apiManagementGateway.GetEntityTagAsync(); + ApiManagementGatewayResource result = await apiManagementGateway.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetGateway() + public async Task Delete_ApiManagementDeleteGateway() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGateway.json - // this example is just showing the usage of "Gateway_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGateway.json + // this example is just showing the usage of "Gateway_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,10 @@ public async Task Get_ApiManagementGetGateway() ApiManagementGatewayResource apiManagementGateway = client.GetApiManagementGatewayResource(apiManagementGatewayResourceId); // invoke the operation - ApiManagementGatewayResource result = await apiManagementGateway.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementGateway.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,7 +100,7 @@ public async Task Update_ApiManagementUpdateGateway() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementGatewayData data = new ApiManagementGatewayData() + ApiManagementGatewayData data = new ApiManagementGatewayData { LocationData = new ResourceLocationDataContract("my location"), Description = "my gateway 1", @@ -113,34 +114,6 @@ public async Task Update_ApiManagementUpdateGateway() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteGateway() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGateway.json - // this example is just showing the usage of "Gateway_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementGatewayResource created on azure - // for more information of creating ApiManagementGatewayResource, please refer to the document of ApiManagementGatewayResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - string gatewayId = "gw1"; - ResourceIdentifier apiManagementGatewayResourceId = ApiManagementGatewayResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, gatewayId); - ApiManagementGatewayResource apiManagementGateway = client.GetApiManagementGatewayResource(apiManagementGatewayResourceId); - - // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementGateway.DeleteAsync(WaitUntil.Completed, ifMatch); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetKeys_ApiManagementGatewayListKeys() @@ -273,10 +246,7 @@ public async Task GetDebugCredentials_ApiManagementGatewayListDebugCredentials() ApiManagementGatewayResource apiManagementGateway = client.GetApiManagementGatewayResource(apiManagementGatewayResourceId); // invoke the operation - GatewayListDebugCredentialsContract gatewayListDebugCredentialsContract = new GatewayListDebugCredentialsContract(new GatewayListDebugCredentialsContractPurpose[] - { -GatewayListDebugCredentialsContractPurpose.Tracing - }, new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1")) + GatewayListDebugCredentialsContract gatewayListDebugCredentialsContract = new GatewayListDebugCredentialsContract(new GatewayListDebugCredentialsContractPurpose[] { GatewayListDebugCredentialsContractPurpose.Tracing }, new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1")) { CredentialsExpireAfter = XmlConvert.ToTimeSpan("PT1H"), }; @@ -307,7 +277,7 @@ public async Task GetTrace_ApiManagementGatewayListTrace() ApiManagementGatewayResource apiManagementGateway = client.GetApiManagementGatewayResource(apiManagementGatewayResourceId); // invoke the operation - GatewayListTraceContract gatewayListTraceContract = new GatewayListTraceContract() + GatewayListTraceContract gatewayListTraceContract = new GatewayListTraceContract { TraceId = "CrDvXXXXXXXXXXXXXVU3ZA2-1", }; @@ -398,7 +368,7 @@ public async Task CreateOrUpdateGatewayApi_ApiManagementCreateGatewayApi() // invoke the operation string apiId = "echo-api"; - AssociationContract associationContract = new AssociationContract() + AssociationContract associationContract = new AssociationContract { ProvisioningState = AssociationEntityProvisioningState.Created, }; @@ -434,5 +404,32 @@ public async Task DeleteGatewayApi_ApiManagementDeleteGatewayApi() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEntityTag_ApiManagementHeadGateway() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGateway.json + // this example is just showing the usage of "Gateway_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementGatewayResource created on azure + // for more information of creating ApiManagementGatewayResource, please refer to the document of ApiManagementGatewayResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + string gatewayId = "mygateway"; + ResourceIdentifier apiManagementGatewayResourceId = ApiManagementGatewayResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, gatewayId); + ApiManagementGatewayResource apiManagementGateway = client.GetApiManagementGatewayResource(apiManagementGatewayResourceId); + + // invoke the operation + bool result = await apiManagementGateway.GetEntityTagAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGlobalSchemaCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGlobalSchemaCollection.cs index 569f43e396ccd..aaf7146e0aa95 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGlobalSchemaCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGlobalSchemaCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ApiManagementGlobalSchemaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListSchemas() + public async Task CreateOrUpdate_ApiManagementCreateSchema1() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGlobalSchemas.json - // this example is just showing the usage of "GlobalSchema_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGlobalSchema1.json + // this example is just showing the usage of "GlobalSchema_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,30 @@ public async Task GetAll_ApiManagementListSchemas() // get the collection of this ApiManagementGlobalSchemaResource ApiManagementGlobalSchemaCollection collection = apiManagementService.GetApiManagementGlobalSchemas(); - // invoke the operation and iterate over the result - await foreach (ApiManagementGlobalSchemaResource item in collection.GetAllAsync()) + // invoke the operation + string schemaId = "schema1"; + ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SchemaType = ApiSchemaType.Xml, + Description = "sample schema description", + Value = BinaryData.FromObjectAsJson("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaId, data); + ApiManagementGlobalSchemaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetSchema1() + public async Task CreateOrUpdate_ApiManagementCreateSchema2() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema1.json - // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGlobalSchema2.json + // this example is just showing the usage of "GlobalSchema_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,7 +83,39 @@ public async Task Get_ApiManagementGetSchema1() // invoke the operation string schemaId = "schema1"; - ApiManagementGlobalSchemaResource result = await collection.GetAsync(schemaId); + ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData + { + SchemaType = ApiSchemaType.Json, + Description = "sample schema description", + Document = BinaryData.FromObjectAsJson(new Dictionary + { + ["type"] = "object", + ["$id"] = "https://example.com/person.schema.json", + ["$schema"] = "https://json-schema.org/draft/2020-12/schema", + ["properties"] = new + { + age = new + { + type = "integer", + description = "Age in years which must be equal to or greater than zero.", + minimum = "0", + }, + firstName = new + { + type = "string", + description = "The person's first name.", + }, + lastName = new + { + type = "string", + description = "The person's last name.", + }, + }, + ["title"] = "Person" + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaId, data); + ApiManagementGlobalSchemaResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,7 +126,7 @@ public async Task Get_ApiManagementGetSchema1() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetSchema1() + public async Task Get_ApiManagementGetSchema1() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema1.json // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. @@ -112,16 +149,20 @@ public async Task Exists_ApiManagementGetSchema1() // invoke the operation string schemaId = "schema1"; - bool result = await collection.ExistsAsync(schemaId); + ApiManagementGlobalSchemaResource result = await collection.GetAsync(schemaId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetSchema1() + public async Task Get_ApiManagementGetSchema2() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema1.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema2.json // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -141,30 +182,22 @@ public async Task GetIfExists_ApiManagementGetSchema1() ApiManagementGlobalSchemaCollection collection = apiManagementService.GetApiManagementGlobalSchemas(); // invoke the operation - string schemaId = "schema1"; - NullableResponse response = await collection.GetIfExistsAsync(schemaId); - ApiManagementGlobalSchemaResource result = response.HasValue ? response.Value : null; + string schemaId = "schema2"; + ApiManagementGlobalSchemaResource result = await collection.GetAsync(schemaId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetSchema2() + public async Task GetAll_ApiManagementListSchemas() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema2.json - // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGlobalSchemas.json + // this example is just showing the usage of "GlobalSchema_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,22 +215,24 @@ public async Task Get_ApiManagementGetSchema2() // get the collection of this ApiManagementGlobalSchemaResource ApiManagementGlobalSchemaCollection collection = apiManagementService.GetApiManagementGlobalSchemas(); - // invoke the operation - string schemaId = "schema2"; - ApiManagementGlobalSchemaResource result = await collection.GetAsync(schemaId); + // invoke the operation and iterate over the result + await foreach (ApiManagementGlobalSchemaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetSchema2() + public async Task Exists_ApiManagementGetSchema1() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema2.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema1.json // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -217,7 +252,7 @@ public async Task Exists_ApiManagementGetSchema2() ApiManagementGlobalSchemaCollection collection = apiManagementService.GetApiManagementGlobalSchemas(); // invoke the operation - string schemaId = "schema2"; + string schemaId = "schema1"; bool result = await collection.ExistsAsync(schemaId); Console.WriteLine($"Succeeded: {result}"); @@ -225,7 +260,7 @@ public async Task Exists_ApiManagementGetSchema2() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetSchema2() + public async Task Exists_ApiManagementGetSchema2() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema2.json // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. @@ -248,29 +283,17 @@ public async Task GetIfExists_ApiManagementGetSchema2() // invoke the operation string schemaId = "schema2"; - NullableResponse response = await collection.GetIfExistsAsync(schemaId); - ApiManagementGlobalSchemaResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(schemaId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateSchema1() + public async Task GetIfExists_ApiManagementGetSchema1() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGlobalSchema1.json - // this example is just showing the usage of "GlobalSchema_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema1.json + // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -290,28 +313,29 @@ public async Task CreateOrUpdate_ApiManagementCreateSchema1() // invoke the operation string schemaId = "schema1"; - ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData() - { - SchemaType = ApiSchemaType.Xml, - Description = "sample schema description", - Value = BinaryData.FromString("\"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\""), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaId, data); - ApiManagementGlobalSchemaResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(schemaId); + ApiManagementGlobalSchemaResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateSchema2() + public async Task GetIfExists_ApiManagementGetSchema2() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGlobalSchema2.json - // this example is just showing the usage of "GlobalSchema_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema2.json + // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -330,46 +354,22 @@ public async Task CreateOrUpdate_ApiManagementCreateSchema2() ApiManagementGlobalSchemaCollection collection = apiManagementService.GetApiManagementGlobalSchemas(); // invoke the operation - string schemaId = "schema1"; - ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData() - { - SchemaType = ApiSchemaType.Json, - Description = "sample schema description", - Document = BinaryData.FromObjectAsJson(new Dictionary() - { - ["type"] = "object", - ["$id"] = "https://example.com/person.schema.json", - ["$schema"] = "https://json-schema.org/draft/2020-12/schema", - ["properties"] = new Dictionary() - { - ["age"] = new Dictionary() - { - ["type"] = "integer", - ["description"] = "Age in years which must be equal to or greater than zero.", - ["minimum"] = "0" - }, - ["firstName"] = new Dictionary() - { - ["type"] = "string", - ["description"] = "The person's first name." - }, - ["lastName"] = new Dictionary() - { - ["type"] = "string", - ["description"] = "The person's last name." - } - }, - ["title"] = "Person" - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaId, data); - ApiManagementGlobalSchemaResource result = lro.Value; + string schemaId = "schema2"; + NullableResponse response = await collection.GetIfExistsAsync(schemaId); + ApiManagementGlobalSchemaResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGlobalSchemaResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGlobalSchemaResource.cs index e0cc3a1516f45..daf7777331a5b 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGlobalSchemaResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGlobalSchemaResource.cs @@ -19,10 +19,10 @@ public partial class Sample_ApiManagementGlobalSchemaResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApi() + public async Task Get_ApiManagementGetSchema1() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGlobalSchema.json - // this example is just showing the usage of "GlobalSchema_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema1.json + // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,21 +34,25 @@ public async Task GetEntityTag_ApiManagementHeadApi() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string schemaId = "myschema"; + string schemaId = "schema1"; ResourceIdentifier apiManagementGlobalSchemaResourceId = ApiManagementGlobalSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, schemaId); ApiManagementGlobalSchemaResource apiManagementGlobalSchema = client.GetApiManagementGlobalSchemaResource(apiManagementGlobalSchemaResourceId); // invoke the operation - bool result = await apiManagementGlobalSchema.GetEntityTagAsync(); + ApiManagementGlobalSchemaResource result = await apiManagementGlobalSchema.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetSchema1() + public async Task Get_ApiManagementGetSchema2() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema1.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema2.json // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -61,7 +65,7 @@ public async Task Get_ApiManagementGetSchema1() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string schemaId = "schema1"; + string schemaId = "schema2"; ResourceIdentifier apiManagementGlobalSchemaResourceId = ApiManagementGlobalSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, schemaId); ApiManagementGlobalSchemaResource apiManagementGlobalSchema = client.GetApiManagementGlobalSchemaResource(apiManagementGlobalSchemaResourceId); @@ -77,10 +81,10 @@ public async Task Get_ApiManagementGetSchema1() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetSchema2() + public async Task Delete_ApiManagementDeleteSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGlobalSchema2.json - // this example is just showing the usage of "GlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGlobalSchema.json + // this example is just showing the usage of "GlobalSchema_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,18 +96,15 @@ public async Task Get_ApiManagementGetSchema2() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string schemaId = "schema2"; + string schemaId = "schema1"; ResourceIdentifier apiManagementGlobalSchemaResourceId = ApiManagementGlobalSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, schemaId); ApiManagementGlobalSchemaResource apiManagementGlobalSchema = client.GetApiManagementGlobalSchemaResource(apiManagementGlobalSchemaResourceId); // invoke the operation - ApiManagementGlobalSchemaResource result = await apiManagementGlobalSchema.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementGlobalSchema.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -128,11 +129,11 @@ public async Task Update_ApiManagementCreateSchema1() ApiManagementGlobalSchemaResource apiManagementGlobalSchema = client.GetApiManagementGlobalSchemaResource(apiManagementGlobalSchemaResourceId); // invoke the operation - ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData() + ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData { SchemaType = ApiSchemaType.Xml, Description = "sample schema description", - Value = BinaryData.FromString("\"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\""), + Value = BinaryData.FromObjectAsJson("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), }; ArmOperation lro = await apiManagementGlobalSchema.UpdateAsync(WaitUntil.Completed, data); ApiManagementGlobalSchemaResource result = lro.Value; @@ -166,33 +167,33 @@ public async Task Update_ApiManagementCreateSchema2() ApiManagementGlobalSchemaResource apiManagementGlobalSchema = client.GetApiManagementGlobalSchemaResource(apiManagementGlobalSchemaResourceId); // invoke the operation - ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData() + ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData { SchemaType = ApiSchemaType.Json, Description = "sample schema description", - Document = BinaryData.FromObjectAsJson(new Dictionary() + Document = BinaryData.FromObjectAsJson(new Dictionary { ["type"] = "object", ["$id"] = "https://example.com/person.schema.json", ["$schema"] = "https://json-schema.org/draft/2020-12/schema", - ["properties"] = new Dictionary() + ["properties"] = new { - ["age"] = new Dictionary() + age = new { - ["type"] = "integer", - ["description"] = "Age in years which must be equal to or greater than zero.", - ["minimum"] = "0" + type = "integer", + description = "Age in years which must be equal to or greater than zero.", + minimum = "0", }, - ["firstName"] = new Dictionary() + firstName = new { - ["type"] = "string", - ["description"] = "The person's first name." + type = "string", + description = "The person's first name.", }, - ["lastName"] = new Dictionary() + lastName = new { - ["type"] = "string", - ["description"] = "The person's last name." - } + type = "string", + description = "The person's last name.", + }, }, ["title"] = "Person" }), @@ -209,10 +210,10 @@ public async Task Update_ApiManagementCreateSchema2() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteSchema() + public async Task GetEntityTag_ApiManagementHeadApi() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGlobalSchema.json - // this example is just showing the usage of "GlobalSchema_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGlobalSchema.json + // this example is just showing the usage of "GlobalSchema_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -224,15 +225,14 @@ public async Task Delete_ApiManagementDeleteSchema() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string schemaId = "schema1"; + string schemaId = "myschema"; ResourceIdentifier apiManagementGlobalSchemaResourceId = ApiManagementGlobalSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, schemaId); ApiManagementGlobalSchemaResource apiManagementGlobalSchema = client.GetApiManagementGlobalSchemaResource(apiManagementGlobalSchemaResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementGlobalSchema.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiManagementGlobalSchema.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGroupCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGroupCollection.cs index c587b27ff45ef..04af76cd092b4 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGroupCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListGroups() + public async Task CreateOrUpdate_ApiManagementCreateGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGroups.json - // this example is just showing the usage of "Group_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGroup.json + // this example is just showing the usage of "Group_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_ApiManagementListGroups() // get the collection of this ApiManagementGroupResource ApiManagementGroupCollection collection = apiManagementService.GetApiManagementGroups(); - // invoke the operation and iterate over the result - await foreach (ApiManagementGroupResource item in collection.GetAllAsync()) + // invoke the operation + string groupId = "tempgroup"; + ApiManagementGroupCreateOrUpdateContent content = new ApiManagementGroupCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "temp group", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content); + ApiManagementGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetGroup() + public async Task CreateOrUpdate_ApiManagementCreateGroupExternal() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGroup.json - // this example is just showing the usage of "Group_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGroupExternal.json + // this example is just showing the usage of "Group_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,8 +79,16 @@ public async Task Get_ApiManagementGetGroup() ApiManagementGroupCollection collection = apiManagementService.GetApiManagementGroups(); // invoke the operation - string groupId = "59306a29e4bbd510dc24e5f9"; - ApiManagementGroupResource result = await collection.GetAsync(groupId); + string groupId = "aadGroup"; + ApiManagementGroupCreateOrUpdateContent content = new ApiManagementGroupCreateOrUpdateContent + { + DisplayName = "NewGroup (samiraad.onmicrosoft.com)", + Description = "new group to test", + ApiManagementGroupType = ApiManagementGroupType.External, + ExternalId = "aad://samiraad.onmicrosoft.com/groups/83cf2753-5831-4675-bc0e-2f8dc067c58d", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content); + ApiManagementGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +99,7 @@ public async Task Get_ApiManagementGetGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetGroup() + public async Task Get_ApiManagementGetGroup() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGroup.json // this example is just showing the usage of "Group_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +122,21 @@ public async Task Exists_ApiManagementGetGroup() // invoke the operation string groupId = "59306a29e4bbd510dc24e5f9"; - bool result = await collection.ExistsAsync(groupId); + ApiManagementGroupResource result = await collection.GetAsync(groupId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetGroup() + public async Task GetAll_ApiManagementListGroups() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGroup.json - // this example is just showing the usage of "Group_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGroups.json + // this example is just showing the usage of "Group_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +154,25 @@ public async Task GetIfExists_ApiManagementGetGroup() // get the collection of this ApiManagementGroupResource ApiManagementGroupCollection collection = apiManagementService.GetApiManagementGroups(); - // invoke the operation - string groupId = "59306a29e4bbd510dc24e5f9"; - NullableResponse response = await collection.GetIfExistsAsync(groupId); - ApiManagementGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ApiManagementGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApiManagementGroupData resourceData = result.Data; + ApiManagementGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateGroup() + public async Task Exists_ApiManagementGetGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGroup.json - // this example is just showing the usage of "Group_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGroup.json + // this example is just showing the usage of "Group_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,27 +191,18 @@ public async Task CreateOrUpdate_ApiManagementCreateGroup() ApiManagementGroupCollection collection = apiManagementService.GetApiManagementGroups(); // invoke the operation - string groupId = "tempgroup"; - ApiManagementGroupCreateOrUpdateContent content = new ApiManagementGroupCreateOrUpdateContent() - { - DisplayName = "temp group", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content); - ApiManagementGroupResource result = lro.Value; + string groupId = "59306a29e4bbd510dc24e5f9"; + bool result = await collection.ExistsAsync(groupId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateGroupExternal() + public async Task GetIfExists_ApiManagementGetGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGroupExternal.json - // this example is just showing the usage of "Group_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGroup.json + // this example is just showing the usage of "Group_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -221,22 +221,22 @@ public async Task CreateOrUpdate_ApiManagementCreateGroupExternal() ApiManagementGroupCollection collection = apiManagementService.GetApiManagementGroups(); // invoke the operation - string groupId = "aadGroup"; - ApiManagementGroupCreateOrUpdateContent content = new ApiManagementGroupCreateOrUpdateContent() - { - DisplayName = "NewGroup (samiraad.onmicrosoft.com)", - Description = "new group to test", - ApiManagementGroupType = ApiManagementGroupType.External, - ExternalId = "aad://samiraad.onmicrosoft.com/groups/83cf2753-5831-4675-bc0e-2f8dc067c58d", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content); - ApiManagementGroupResource result = lro.Value; + string groupId = "59306a29e4bbd510dc24e5f9"; + NullableResponse response = await collection.GetIfExistsAsync(groupId); + ApiManagementGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGroupResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGroupResource.cs index 8173c9e3dd176..37f46a10fea96 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGroupResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementGroupResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadGroup() + public async Task Get_ApiManagementGetGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGroup.json - // this example is just showing the usage of "Group_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGroup.json + // this example is just showing the usage of "Group_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadGroup() ApiManagementGroupResource apiManagementGroup = client.GetApiManagementGroupResource(apiManagementGroupResourceId); // invoke the operation - bool result = await apiManagementGroup.GetEntityTagAsync(); + ApiManagementGroupResource result = await apiManagementGroup.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetGroup() + public async Task Delete_ApiManagementDeleteGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGroup.json - // this example is just showing the usage of "Group_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGroup.json + // this example is just showing the usage of "Group_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,15 @@ public async Task Get_ApiManagementGetGroup() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string groupId = "59306a29e4bbd510dc24e5f9"; + string groupId = "aadGroup"; ResourceIdentifier apiManagementGroupResourceId = ApiManagementGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, groupId); ApiManagementGroupResource apiManagementGroup = client.GetApiManagementGroupResource(apiManagementGroupResourceId); // invoke the operation - ApiManagementGroupResource result = await apiManagementGroup.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementGroup.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateGroup() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementGroupPatch patch = new ApiManagementGroupPatch() + ApiManagementGroupPatch patch = new ApiManagementGroupPatch { DisplayName = "temp group", }; @@ -110,34 +111,6 @@ public async Task Update_ApiManagementUpdateGroup() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteGroup() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGroup.json - // this example is just showing the usage of "Group_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementGroupResource created on azure - // for more information of creating ApiManagementGroupResource, please refer to the document of ApiManagementGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - string groupId = "aadGroup"; - ResourceIdentifier apiManagementGroupResourceId = ApiManagementGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, groupId); - ApiManagementGroupResource apiManagementGroup = client.GetApiManagementGroupResource(apiManagementGroupResourceId); - - // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementGroup.DeleteAsync(WaitUntil.Completed, ifMatch); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetGroupUsers_ApiManagementListGroupUsers() @@ -251,5 +224,32 @@ public async Task DeleteGroupUser_ApiManagementDeleteGroupUser() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEntityTag_ApiManagementHeadGroup() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGroup.json + // this example is just showing the usage of "Group_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementGroupResource created on azure + // for more information of creating ApiManagementGroupResource, please refer to the document of ApiManagementGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + string groupId = "59306a29e4bbd510dc24e5f9"; + ResourceIdentifier apiManagementGroupResourceId = ApiManagementGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, groupId); + ApiManagementGroupResource apiManagementGroup = client.GetApiManagementGroupResource(apiManagementGroupResourceId); + + // invoke the operation + bool result = await apiManagementGroup.GetEntityTagAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIdentityProviderCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIdentityProviderCollection.cs index 9d5ffc591a9f7..5ea03070dcec6 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIdentityProviderCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIdentityProviderCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementIdentityProviderCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListIdentityProviders() + public async Task CreateOrUpdate_ApiManagementCreateIdentityProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListIdentityProviders.json - // this example is just showing the usage of "IdentityProvider_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateIdentityProvider.json + // this example is just showing the usage of "IdentityProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ApiManagementListIdentityProviders() // get the collection of this ApiManagementIdentityProviderResource ApiManagementIdentityProviderCollection collection = apiManagementService.GetApiManagementIdentityProviders(); - // invoke the operation and iterate over the result - await foreach (ApiManagementIdentityProviderResource item in collection.GetAllAsync()) + // invoke the operation + IdentityProviderType identityProviderName = IdentityProviderType.Facebook; + ApiManagementIdentityProviderCreateOrUpdateContent content = new ApiManagementIdentityProviderCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementIdentityProviderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ClientId = "facebookid", + ClientSecret = "facebookapplicationsecret", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, identityProviderName, content); + ApiManagementIdentityProviderResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementIdentityProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_ApiManagementGetIdentityProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetIdentityProvider() + public async Task GetAll_ApiManagementListIdentityProviders() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetIdentityProvider.json - // this example is just showing the usage of "IdentityProvider_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListIdentityProviders.json + // this example is just showing the usage of "IdentityProvider_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +113,22 @@ public async Task Exists_ApiManagementGetIdentityProvider() // get the collection of this ApiManagementIdentityProviderResource ApiManagementIdentityProviderCollection collection = apiManagementService.GetApiManagementIdentityProviders(); - // invoke the operation - IdentityProviderType identityProviderName = IdentityProviderType.AadB2C; - bool result = await collection.ExistsAsync(identityProviderName); + // invoke the operation and iterate over the result + await foreach (ApiManagementIdentityProviderResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementIdentityProviderData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetIdentityProvider() + public async Task Exists_ApiManagementGetIdentityProvider() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetIdentityProvider.json // this example is just showing the usage of "IdentityProvider_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_ApiManagementGetIdentityProvider() // invoke the operation IdentityProviderType identityProviderName = IdentityProviderType.AadB2C; - NullableResponse response = await collection.GetIfExistsAsync(identityProviderName); - ApiManagementIdentityProviderResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(identityProviderName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementIdentityProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateIdentityProvider() + public async Task GetIfExists_ApiManagementGetIdentityProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateIdentityProvider.json - // this example is just showing the usage of "IdentityProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetIdentityProvider.json + // this example is just showing the usage of "IdentityProvider_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,20 +180,22 @@ public async Task CreateOrUpdate_ApiManagementCreateIdentityProvider() ApiManagementIdentityProviderCollection collection = apiManagementService.GetApiManagementIdentityProviders(); // invoke the operation - IdentityProviderType identityProviderName = IdentityProviderType.Facebook; - ApiManagementIdentityProviderCreateOrUpdateContent content = new ApiManagementIdentityProviderCreateOrUpdateContent() - { - ClientId = "facebookid", - ClientSecret = "facebookapplicationsecret", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, identityProviderName, content); - ApiManagementIdentityProviderResource result = lro.Value; + IdentityProviderType identityProviderName = IdentityProviderType.AadB2C; + NullableResponse response = await collection.GetIfExistsAsync(identityProviderName); + ApiManagementIdentityProviderResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementIdentityProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementIdentityProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIdentityProviderResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIdentityProviderResource.cs index e400e56ee2c91..ddad5f501dfe2 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIdentityProviderResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIdentityProviderResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementIdentityProviderResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadIdentityProvider() + public async Task Get_ApiManagementGetIdentityProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadIdentityProvider.json - // this example is just showing the usage of "IdentityProvider_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetIdentityProvider.json + // this example is just showing the usage of "IdentityProvider_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadIdentityProvider() ApiManagementIdentityProviderResource apiManagementIdentityProvider = client.GetApiManagementIdentityProviderResource(apiManagementIdentityProviderResourceId); // invoke the operation - bool result = await apiManagementIdentityProvider.GetEntityTagAsync(); + ApiManagementIdentityProviderResource result = await apiManagementIdentityProvider.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementIdentityProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetIdentityProvider() + public async Task Delete_ApiManagementDeleteIdentityProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetIdentityProvider.json - // this example is just showing the usage of "IdentityProvider_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteIdentityProvider.json + // this example is just showing the usage of "IdentityProvider_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,15 @@ public async Task Get_ApiManagementGetIdentityProvider() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - IdentityProviderType identityProviderName = IdentityProviderType.AadB2C; + IdentityProviderType identityProviderName = IdentityProviderType.Aad; ResourceIdentifier apiManagementIdentityProviderResourceId = ApiManagementIdentityProviderResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, identityProviderName); ApiManagementIdentityProviderResource apiManagementIdentityProvider = client.GetApiManagementIdentityProviderResource(apiManagementIdentityProviderResourceId); // invoke the operation - ApiManagementIdentityProviderResource result = await apiManagementIdentityProvider.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementIdentityProvider.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementIdentityProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateIdentityProvider() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementIdentityProviderPatch patch = new ApiManagementIdentityProviderPatch() + ApiManagementIdentityProviderPatch patch = new ApiManagementIdentityProviderPatch { ClientId = "updatedfacebookid", ClientSecret = "updatedfacebooksecret", @@ -113,10 +114,10 @@ public async Task Update_ApiManagementUpdateIdentityProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteIdentityProvider() + public async Task GetSecrets_ApiManagementIdentityProviderListSecrets() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteIdentityProvider.json - // this example is just showing the usage of "IdentityProvider_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementIdentityProviderListSecrets.json + // this example is just showing the usage of "IdentityProvider_ListSecrets" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -128,23 +129,22 @@ public async Task Delete_ApiManagementDeleteIdentityProvider() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - IdentityProviderType identityProviderName = IdentityProviderType.Aad; + IdentityProviderType identityProviderName = IdentityProviderType.AadB2C; ResourceIdentifier apiManagementIdentityProviderResourceId = ApiManagementIdentityProviderResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, identityProviderName); ApiManagementIdentityProviderResource apiManagementIdentityProvider = client.GetApiManagementIdentityProviderResource(apiManagementIdentityProviderResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementIdentityProvider.DeleteAsync(WaitUntil.Completed, ifMatch); + ClientSecretContract result = await apiManagementIdentityProvider.GetSecretsAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSecrets_ApiManagementIdentityProviderListSecrets() + public async Task GetEntityTag_ApiManagementHeadIdentityProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementIdentityProviderListSecrets.json - // this example is just showing the usage of "IdentityProvider_ListSecrets" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadIdentityProvider.json + // this example is just showing the usage of "IdentityProvider_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -161,7 +161,7 @@ public async Task GetSecrets_ApiManagementIdentityProviderListSecrets() ApiManagementIdentityProviderResource apiManagementIdentityProvider = client.GetApiManagementIdentityProviderResource(apiManagementIdentityProviderResourceId); // invoke the operation - ClientSecretContract result = await apiManagementIdentityProvider.GetSecretsAsync(); + bool result = await apiManagementIdentityProvider.GetEntityTagAsync(); Console.WriteLine($"Succeeded: {result}"); } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIssueCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIssueCollection.cs index ae9052183e0a7..3a7e1e6450def 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIssueCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementIssueCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementIssueCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListIssues() + public async Task Get_ApiManagementGetIssue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListIssues.json - // this example is just showing the usage of "Issue_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetIssue.json + // this example is just showing the usage of "Issue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ApiManagementListIssues() // get the collection of this ApiManagementIssueResource ApiManagementIssueCollection collection = apiManagementService.GetApiManagementIssues(); - // invoke the operation and iterate over the result - await foreach (ApiManagementIssueResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IssueContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string issueId = "57d2ef278aa04f0ad01d6cdc"; + ApiManagementIssueResource result = await collection.GetAsync(issueId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IssueContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetIssue() + public async Task GetAll_ApiManagementListIssues() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetIssue.json - // this example is just showing the usage of "Issue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListIssues.json + // this example is just showing the usage of "Issue_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_ApiManagementGetIssue() // get the collection of this ApiManagementIssueResource ApiManagementIssueCollection collection = apiManagementService.GetApiManagementIssues(); - // invoke the operation - string issueId = "57d2ef278aa04f0ad01d6cdc"; - ApiManagementIssueResource result = await collection.GetAsync(issueId); + // invoke the operation and iterate over the result + await foreach (ApiManagementIssueResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IssueContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IssueContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementLoggerCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementLoggerCollection.cs index edd7e66046dcc..6d21937627651 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementLoggerCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementLoggerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementLoggerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListLoggers() + public async Task CreateOrUpdate_ApiManagementCreateAILogger() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListLoggers.json - // this example is just showing the usage of "Logger_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAILogger.json + // this example is just showing the usage of "Logger_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,33 @@ public async Task GetAll_ApiManagementListLoggers() // get the collection of this ApiManagementLoggerResource ApiManagementLoggerCollection collection = apiManagementService.GetApiManagementLoggers(); - // invoke the operation and iterate over the result - await foreach (ApiManagementLoggerResource item in collection.GetAllAsync()) + // invoke the operation + string loggerId = "loggerId"; + ApiManagementLoggerData data = new ApiManagementLoggerData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementLoggerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + LoggerType = LoggerType.ApplicationInsights, + Description = "adding a new logger", + Credentials = +{ +["instrumentationKey"] = "11................a1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loggerId, data); + ApiManagementLoggerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementLoggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetLogger() + public async Task CreateOrUpdate_ApiManagementCreateEHLogger() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetLogger.json - // this example is just showing the usage of "Logger_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateEHLogger.json + // this example is just showing the usage of "Logger_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,8 +84,19 @@ public async Task Get_ApiManagementGetLogger() ApiManagementLoggerCollection collection = apiManagementService.GetApiManagementLoggers(); // invoke the operation - string loggerId = "templateLogger"; - ApiManagementLoggerResource result = await collection.GetAsync(loggerId); + string loggerId = "eh1"; + ApiManagementLoggerData data = new ApiManagementLoggerData + { + LoggerType = LoggerType.AzureEventHub, + Description = "adding a new logger", + Credentials = +{ +["name"] = "hydraeventhub", +["connectionString"] = "Endpoint=sb://hydraeventhub-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=********=" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loggerId, data); + ApiManagementLoggerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +107,7 @@ public async Task Get_ApiManagementGetLogger() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetLogger() + public async Task Get_ApiManagementGetLogger() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetLogger.json // this example is just showing the usage of "Logger_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,17 +130,21 @@ public async Task Exists_ApiManagementGetLogger() // invoke the operation string loggerId = "templateLogger"; - bool result = await collection.ExistsAsync(loggerId); + ApiManagementLoggerResource result = await collection.GetAsync(loggerId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementLoggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetLogger() + public async Task GetAll_ApiManagementListLoggers() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetLogger.json - // this example is just showing the usage of "Logger_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListLoggers.json + // this example is just showing the usage of "Logger_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +162,25 @@ public async Task GetIfExists_ApiManagementGetLogger() // get the collection of this ApiManagementLoggerResource ApiManagementLoggerCollection collection = apiManagementService.GetApiManagementLoggers(); - // invoke the operation - string loggerId = "templateLogger"; - NullableResponse response = await collection.GetIfExistsAsync(loggerId); - ApiManagementLoggerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ApiManagementLoggerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApiManagementLoggerData resourceData = result.Data; + ApiManagementLoggerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateAILogger() + public async Task Exists_ApiManagementGetLogger() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAILogger.json - // this example is just showing the usage of "Logger_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetLogger.json + // this example is just showing the usage of "Logger_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,32 +199,18 @@ public async Task CreateOrUpdate_ApiManagementCreateAILogger() ApiManagementLoggerCollection collection = apiManagementService.GetApiManagementLoggers(); // invoke the operation - string loggerId = "loggerId"; - ApiManagementLoggerData data = new ApiManagementLoggerData() - { - LoggerType = LoggerType.ApplicationInsights, - Description = "adding a new logger", - Credentials = -{ -["instrumentationKey"] = "11................a1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loggerId, data); - ApiManagementLoggerResource result = lro.Value; + string loggerId = "templateLogger"; + bool result = await collection.ExistsAsync(loggerId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementLoggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateEHLogger() + public async Task GetIfExists_ApiManagementGetLogger() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateEHLogger.json - // this example is just showing the usage of "Logger_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetLogger.json + // this example is just showing the usage of "Logger_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,25 +229,22 @@ public async Task CreateOrUpdate_ApiManagementCreateEHLogger() ApiManagementLoggerCollection collection = apiManagementService.GetApiManagementLoggers(); // invoke the operation - string loggerId = "eh1"; - ApiManagementLoggerData data = new ApiManagementLoggerData() - { - LoggerType = LoggerType.AzureEventHub, - Description = "adding a new logger", - Credentials = -{ -["name"] = "hydraeventhub", -["connectionString"] = "Endpoint=sb://hydraeventhub-ns.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=********=", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loggerId, data); - ApiManagementLoggerResource result = lro.Value; + string loggerId = "templateLogger"; + NullableResponse response = await collection.GetIfExistsAsync(loggerId); + ApiManagementLoggerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementLoggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementLoggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementLoggerResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementLoggerResource.cs index 603451ba359ad..21ac01936a84d 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementLoggerResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementLoggerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementLoggerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadLogger() + public async Task Get_ApiManagementGetLogger() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadLogger.json - // this example is just showing the usage of "Logger_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetLogger.json + // this example is just showing the usage of "Logger_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadLogger() ApiManagementLoggerResource apiManagementLogger = client.GetApiManagementLoggerResource(apiManagementLoggerResourceId); // invoke the operation - bool result = await apiManagementLogger.GetEntityTagAsync(); + ApiManagementLoggerResource result = await apiManagementLogger.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementLoggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetLogger() + public async Task Delete_ApiManagementDeleteLogger() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetLogger.json - // this example is just showing the usage of "Logger_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteLogger.json + // this example is just showing the usage of "Logger_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,15 @@ public async Task Get_ApiManagementGetLogger() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string loggerId = "templateLogger"; + string loggerId = "loggerId"; ResourceIdentifier apiManagementLoggerResourceId = ApiManagementLoggerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, loggerId); ApiManagementLoggerResource apiManagementLogger = client.GetApiManagementLoggerResource(apiManagementLoggerResourceId); // invoke the operation - ApiManagementLoggerResource result = await apiManagementLogger.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementLogger.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementLoggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateLogger() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementLoggerPatch patch = new ApiManagementLoggerPatch() + ApiManagementLoggerPatch patch = new ApiManagementLoggerPatch { LoggerType = LoggerType.AzureEventHub, Description = "updating description", @@ -113,10 +114,10 @@ public async Task Update_ApiManagementUpdateLogger() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteLogger() + public async Task GetEntityTag_ApiManagementHeadLogger() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteLogger.json - // this example is just showing the usage of "Logger_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadLogger.json + // this example is just showing the usage of "Logger_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -128,15 +129,14 @@ public async Task Delete_ApiManagementDeleteLogger() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string loggerId = "loggerId"; + string loggerId = "templateLogger"; ResourceIdentifier apiManagementLoggerResourceId = ApiManagementLoggerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, loggerId); ApiManagementLoggerResource apiManagementLogger = client.GetApiManagementLoggerResource(apiManagementLoggerResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementLogger.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiManagementLogger.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNamedValueCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNamedValueCollection.cs index 09574adda82d5..11b2d5f150ff2 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNamedValueCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNamedValueCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementNamedValueCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListNamedValues() + public async Task CreateOrUpdate_ApiManagementCreateNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListNamedValues.json - // this example is just showing the usage of "NamedValue_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateNamedValue.json + // this example is just showing the usage of "NamedValue_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,31 @@ public async Task GetAll_ApiManagementListNamedValues() // get the collection of this ApiManagementNamedValueResource ApiManagementNamedValueCollection collection = apiManagementService.GetApiManagementNamedValues(); - // invoke the operation and iterate over the result - await foreach (ApiManagementNamedValueResource item in collection.GetAllAsync()) + // invoke the operation + string namedValueId = "testprop2"; + ApiManagementNamedValueCreateOrUpdateContent content = new ApiManagementNamedValueCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = { "foo", "bar" }, + IsSecret = false, + DisplayName = "prop3name", + Value = "propValue", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namedValueId, content); + ApiManagementNamedValueResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetNamedValue() + public async Task CreateOrUpdate_ApiManagementCreateNamedValueWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValue.json - // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateNamedValueWithKeyVault.json + // this example is just showing the usage of "NamedValue_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,8 +82,20 @@ public async Task Get_ApiManagementGetNamedValue() ApiManagementNamedValueCollection collection = apiManagementService.GetApiManagementNamedValues(); // invoke the operation - string namedValueId = "testarmTemplateproperties2"; - ApiManagementNamedValueResource result = await collection.GetAsync(namedValueId); + string namedValueId = "testprop6"; + ApiManagementNamedValueCreateOrUpdateContent content = new ApiManagementNamedValueCreateOrUpdateContent + { + Tags = { "foo", "bar" }, + IsSecret = true, + DisplayName = "prop6namekv", + KeyVault = new KeyVaultContractCreateProperties + { + SecretIdentifier = "https://contoso.vault.azure.net/secrets/aadSecret", + IdentityClientId = "ceaa6b06-c00f-43ef-99ac-f53d1fe876a0", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namedValueId, content); + ApiManagementNamedValueResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +106,7 @@ public async Task Get_ApiManagementGetNamedValue() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetNamedValue() + public async Task Get_ApiManagementGetNamedValue() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValue.json // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. @@ -111,16 +129,20 @@ public async Task Exists_ApiManagementGetNamedValue() // invoke the operation string namedValueId = "testarmTemplateproperties2"; - bool result = await collection.ExistsAsync(namedValueId); + ApiManagementNamedValueResource result = await collection.GetAsync(namedValueId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetNamedValue() + public async Task Get_ApiManagementGetNamedValueWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValue.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValueWithKeyVault.json // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -140,30 +162,22 @@ public async Task GetIfExists_ApiManagementGetNamedValue() ApiManagementNamedValueCollection collection = apiManagementService.GetApiManagementNamedValues(); // invoke the operation - string namedValueId = "testarmTemplateproperties2"; - NullableResponse response = await collection.GetIfExistsAsync(namedValueId); - ApiManagementNamedValueResource result = response.HasValue ? response.Value : null; + string namedValueId = "testprop6"; + ApiManagementNamedValueResource result = await collection.GetAsync(namedValueId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetNamedValueWithKeyVault() + public async Task GetAll_ApiManagementListNamedValues() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValueWithKeyVault.json - // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListNamedValues.json + // this example is just showing the usage of "NamedValue_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,22 +195,24 @@ public async Task Get_ApiManagementGetNamedValueWithKeyVault() // get the collection of this ApiManagementNamedValueResource ApiManagementNamedValueCollection collection = apiManagementService.GetApiManagementNamedValues(); - // invoke the operation - string namedValueId = "testprop6"; - ApiManagementNamedValueResource result = await collection.GetAsync(namedValueId); + // invoke the operation and iterate over the result + await foreach (ApiManagementNamedValueResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetNamedValueWithKeyVault() + public async Task Exists_ApiManagementGetNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValueWithKeyVault.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValue.json // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -216,7 +232,7 @@ public async Task Exists_ApiManagementGetNamedValueWithKeyVault() ApiManagementNamedValueCollection collection = apiManagementService.GetApiManagementNamedValues(); // invoke the operation - string namedValueId = "testprop6"; + string namedValueId = "testarmTemplateproperties2"; bool result = await collection.ExistsAsync(namedValueId); Console.WriteLine($"Succeeded: {result}"); @@ -224,7 +240,7 @@ public async Task Exists_ApiManagementGetNamedValueWithKeyVault() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetNamedValueWithKeyVault() + public async Task Exists_ApiManagementGetNamedValueWithKeyVault() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValueWithKeyVault.json // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. @@ -247,29 +263,17 @@ public async Task GetIfExists_ApiManagementGetNamedValueWithKeyVault() // invoke the operation string namedValueId = "testprop6"; - NullableResponse response = await collection.GetIfExistsAsync(namedValueId); - ApiManagementNamedValueResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(namedValueId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateNamedValue() + public async Task GetIfExists_ApiManagementGetNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateNamedValue.json - // this example is just showing the usage of "NamedValue_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValue.json + // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -288,33 +292,30 @@ public async Task CreateOrUpdate_ApiManagementCreateNamedValue() ApiManagementNamedValueCollection collection = apiManagementService.GetApiManagementNamedValues(); // invoke the operation - string namedValueId = "testprop2"; - ApiManagementNamedValueCreateOrUpdateContent content = new ApiManagementNamedValueCreateOrUpdateContent() - { - Tags = -{ -"foo","bar" -}, - IsSecret = false, - DisplayName = "prop3name", - Value = "propValue", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namedValueId, content); - ApiManagementNamedValueResource result = lro.Value; + string namedValueId = "testarmTemplateproperties2"; + NullableResponse response = await collection.GetIfExistsAsync(namedValueId); + ApiManagementNamedValueResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateNamedValueWithKeyVault() + public async Task GetIfExists_ApiManagementGetNamedValueWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateNamedValueWithKeyVault.json - // this example is just showing the usage of "NamedValue_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValueWithKeyVault.json + // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -334,28 +335,21 @@ public async Task CreateOrUpdate_ApiManagementCreateNamedValueWithKeyVault() // invoke the operation string namedValueId = "testprop6"; - ApiManagementNamedValueCreateOrUpdateContent content = new ApiManagementNamedValueCreateOrUpdateContent() - { - Tags = -{ -"foo","bar" -}, - IsSecret = true, - DisplayName = "prop6namekv", - KeyVault = new KeyVaultContractCreateProperties() - { - SecretIdentifier = "https://contoso.vault.azure.net/secrets/aadSecret", - IdentityClientId = "ceaa6b06-c00f-43ef-99ac-f53d1fe876a0", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namedValueId, content); - ApiManagementNamedValueResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(namedValueId); + ApiManagementNamedValueResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNamedValueResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNamedValueResource.cs index 4de7ac9b5be61..68c851c168449 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNamedValueResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNamedValueResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementNamedValueResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadNamedValue() + public async Task Get_ApiManagementGetNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadNamedValue.json - // this example is just showing the usage of "NamedValue_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValue.json + // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,20 @@ public async Task GetEntityTag_ApiManagementHeadNamedValue() ApiManagementNamedValueResource apiManagementNamedValue = client.GetApiManagementNamedValueResource(apiManagementNamedValueResourceId); // invoke the operation - bool result = await apiManagementNamedValue.GetEntityTagAsync(); + ApiManagementNamedValueResource result = await apiManagementNamedValue.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetNamedValue() + public async Task Get_ApiManagementGetNamedValueWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValue.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValueWithKeyVault.json // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -60,7 +64,7 @@ public async Task Get_ApiManagementGetNamedValue() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string namedValueId = "testarmTemplateproperties2"; + string namedValueId = "testprop6"; ResourceIdentifier apiManagementNamedValueResourceId = ApiManagementNamedValueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, namedValueId); ApiManagementNamedValueResource apiManagementNamedValue = client.GetApiManagementNamedValueResource(apiManagementNamedValueResourceId); @@ -76,10 +80,10 @@ public async Task Get_ApiManagementGetNamedValue() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetNamedValueWithKeyVault() + public async Task Delete_ApiManagementDeleteNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNamedValueWithKeyVault.json - // this example is just showing the usage of "NamedValue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteNamedValue.json + // this example is just showing the usage of "NamedValue_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,18 +95,15 @@ public async Task Get_ApiManagementGetNamedValueWithKeyVault() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string namedValueId = "testprop6"; + string namedValueId = "testprop2"; ResourceIdentifier apiManagementNamedValueResourceId = ApiManagementNamedValueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, namedValueId); ApiManagementNamedValueResource apiManagementNamedValue = client.GetApiManagementNamedValueResource(apiManagementNamedValueResourceId); // invoke the operation - ApiManagementNamedValueResource result = await apiManagementNamedValue.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementNamedValue.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -128,12 +129,9 @@ public async Task Update_ApiManagementUpdateNamedValue() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementNamedValuePatch patch = new ApiManagementNamedValuePatch() + ApiManagementNamedValuePatch patch = new ApiManagementNamedValuePatch { - Tags = -{ -"foo","bar2" -}, + Tags = { "foo", "bar2" }, IsSecret = false, DisplayName = "prop3name", Value = "propValue", @@ -150,10 +148,10 @@ public async Task Update_ApiManagementUpdateNamedValue() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteNamedValue() + public async Task GetValue_ApiManagementNamedValueListValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteNamedValue.json - // this example is just showing the usage of "NamedValue_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementNamedValueListValue.json + // this example is just showing the usage of "NamedValue_ListValue" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,23 +163,22 @@ public async Task Delete_ApiManagementDeleteNamedValue() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string namedValueId = "testprop2"; + string namedValueId = "testarmTemplateproperties2"; ResourceIdentifier apiManagementNamedValueResourceId = ApiManagementNamedValueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, namedValueId); ApiManagementNamedValueResource apiManagementNamedValue = client.GetApiManagementNamedValueResource(apiManagementNamedValueResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementNamedValue.DeleteAsync(WaitUntil.Completed, ifMatch); + NamedValueSecretContract result = await apiManagementNamedValue.GetValueAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetValue_ApiManagementNamedValueListValue() + public async Task RefreshSecret_ApiManagementRefreshNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementNamedValueListValue.json - // this example is just showing the usage of "NamedValue_ListValue" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementRefreshNamedValue.json + // this example is just showing the usage of "NamedValue_RefreshSecret" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,22 +190,27 @@ public async Task GetValue_ApiManagementNamedValueListValue() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string namedValueId = "testarmTemplateproperties2"; + string namedValueId = "testprop2"; ResourceIdentifier apiManagementNamedValueResourceId = ApiManagementNamedValueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, namedValueId); ApiManagementNamedValueResource apiManagementNamedValue = client.GetApiManagementNamedValueResource(apiManagementNamedValueResourceId); // invoke the operation - NamedValueSecretContract result = await apiManagementNamedValue.GetValueAsync(); + ArmOperation lro = await apiManagementNamedValue.RefreshSecretAsync(WaitUntil.Completed); + ApiManagementNamedValueResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task RefreshSecret_ApiManagementRefreshNamedValue() + public async Task GetEntityTag_ApiManagementHeadNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementRefreshNamedValue.json - // this example is just showing the usage of "NamedValue_RefreshSecret" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadNamedValue.json + // this example is just showing the usage of "NamedValue_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -220,19 +222,14 @@ public async Task RefreshSecret_ApiManagementRefreshNamedValue() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string namedValueId = "testprop2"; + string namedValueId = "testarmTemplateproperties2"; ResourceIdentifier apiManagementNamedValueResourceId = ApiManagementNamedValueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, namedValueId); ApiManagementNamedValueResource apiManagementNamedValue = client.GetApiManagementNamedValueResource(apiManagementNamedValueResourceId); // invoke the operation - ArmOperation lro = await apiManagementNamedValue.RefreshSecretAsync(WaitUntil.Completed); - ApiManagementNamedValueResource result = lro.Value; + bool result = await apiManagementNamedValue.GetEntityTagAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNotificationCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNotificationCollection.cs index 393b345394f4c..3846c4273f08f 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNotificationCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementNotificationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementNotificationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListNotifications() + public async Task CreateOrUpdate_ApiManagementCreateNotification() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListNotifications.json - // this example is just showing the usage of "Notification_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateNotification.json + // this example is just showing the usage of "Notification_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,16 @@ public async Task GetAll_ApiManagementListNotifications() // get the collection of this ApiManagementNotificationResource ApiManagementNotificationCollection collection = apiManagementService.GetApiManagementNotifications(); - // invoke the operation and iterate over the result - await foreach (ApiManagementNotificationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNotificationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + NotificationName notificationName = NotificationName.RequestPublisherNotificationMessage; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, notificationName); + ApiManagementNotificationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNotificationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +87,10 @@ public async Task Get_ApiManagementGetNotification() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetNotification() + public async Task GetAll_ApiManagementListNotifications() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNotification.json - // this example is just showing the usage of "Notification_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListNotifications.json + // this example is just showing the usage of "Notification_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +108,22 @@ public async Task Exists_ApiManagementGetNotification() // get the collection of this ApiManagementNotificationResource ApiManagementNotificationCollection collection = apiManagementService.GetApiManagementNotifications(); - // invoke the operation - NotificationName notificationName = NotificationName.RequestPublisherNotificationMessage; - bool result = await collection.ExistsAsync(notificationName); + // invoke the operation and iterate over the result + await foreach (ApiManagementNotificationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNotificationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetNotification() + public async Task Exists_ApiManagementGetNotification() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNotification.json // this example is just showing the usage of "Notification_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +146,17 @@ public async Task GetIfExists_ApiManagementGetNotification() // invoke the operation NotificationName notificationName = NotificationName.RequestPublisherNotificationMessage; - NullableResponse response = await collection.GetIfExistsAsync(notificationName); - ApiManagementNotificationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(notificationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNotificationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateNotification() + public async Task GetIfExists_ApiManagementGetNotification() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateNotification.json - // this example is just showing the usage of "Notification_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetNotification.json + // this example is just showing the usage of "Notification_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,14 +176,21 @@ public async Task CreateOrUpdate_ApiManagementCreateNotification() // invoke the operation NotificationName notificationName = NotificationName.RequestPublisherNotificationMessage; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, notificationName); - ApiManagementNotificationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(notificationName); + ApiManagementNotificationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNotificationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNotificationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementOpenIdConnectProviderCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementOpenIdConnectProviderCollection.cs index cf4fc40c1fbbc..35f94f7f44313 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementOpenIdConnectProviderCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementOpenIdConnectProviderCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementOpenIdConnectProviderCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListOpenIdConnectProviders() + public async Task CreateOrUpdate_ApiManagementCreateOpenIdConnectProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListOpenIdConnectProviders.json - // this example is just showing the usage of "OpenIdConnectProvider_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateOpenIdConnectProvider.json + // this example is just showing the usage of "OpenIdConnectProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,25 @@ public async Task GetAll_ApiManagementListOpenIdConnectProviders() // get the collection of this ApiManagementOpenIdConnectProviderResource ApiManagementOpenIdConnectProviderCollection collection = apiManagementService.GetApiManagementOpenIdConnectProviders(); - // invoke the operation and iterate over the result - await foreach (ApiManagementOpenIdConnectProviderResource item in collection.GetAllAsync()) + // invoke the operation + string openId = "templateOpenIdConnect3"; + ApiManagementOpenIdConnectProviderData data = new ApiManagementOpenIdConnectProviderData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementOpenIdConnectProviderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "templateoidprovider3", + MetadataEndpoint = "https://oidprovider-template3.net", + ClientId = "oidprovidertemplate3", + ClientSecret = "x", + UseInTestConsole = false, + UseInApiDocumentation = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, openId, data); + ApiManagementOpenIdConnectProviderResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementOpenIdConnectProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +95,10 @@ public async Task Get_ApiManagementGetOpenIdConnectProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetOpenIdConnectProvider() + public async Task GetAll_ApiManagementListOpenIdConnectProviders() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetOpenIdConnectProvider.json - // this example is just showing the usage of "OpenIdConnectProvider_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListOpenIdConnectProviders.json + // this example is just showing the usage of "OpenIdConnectProvider_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +116,22 @@ public async Task Exists_ApiManagementGetOpenIdConnectProvider() // get the collection of this ApiManagementOpenIdConnectProviderResource ApiManagementOpenIdConnectProviderCollection collection = apiManagementService.GetApiManagementOpenIdConnectProviders(); - // invoke the operation - string openId = "templateOpenIdConnect2"; - bool result = await collection.ExistsAsync(openId); + // invoke the operation and iterate over the result + await foreach (ApiManagementOpenIdConnectProviderResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementOpenIdConnectProviderData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetOpenIdConnectProvider() + public async Task Exists_ApiManagementGetOpenIdConnectProvider() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetOpenIdConnectProvider.json // this example is just showing the usage of "OpenIdConnectProvider_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +154,17 @@ public async Task GetIfExists_ApiManagementGetOpenIdConnectProvider() // invoke the operation string openId = "templateOpenIdConnect2"; - NullableResponse response = await collection.GetIfExistsAsync(openId); - ApiManagementOpenIdConnectProviderResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(openId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementOpenIdConnectProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateOpenIdConnectProvider() + public async Task GetIfExists_ApiManagementGetOpenIdConnectProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateOpenIdConnectProvider.json - // this example is just showing the usage of "OpenIdConnectProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetOpenIdConnectProvider.json + // this example is just showing the usage of "OpenIdConnectProvider_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,24 +183,22 @@ public async Task CreateOrUpdate_ApiManagementCreateOpenIdConnectProvider() ApiManagementOpenIdConnectProviderCollection collection = apiManagementService.GetApiManagementOpenIdConnectProviders(); // invoke the operation - string openId = "templateOpenIdConnect3"; - ApiManagementOpenIdConnectProviderData data = new ApiManagementOpenIdConnectProviderData() - { - DisplayName = "templateoidprovider3", - MetadataEndpoint = "https://oidprovider-template3.net", - ClientId = "oidprovidertemplate3", - ClientSecret = "x", - UseInTestConsole = false, - UseInApiDocumentation = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, openId, data); - ApiManagementOpenIdConnectProviderResource result = lro.Value; + string openId = "templateOpenIdConnect2"; + NullableResponse response = await collection.GetIfExistsAsync(openId); + ApiManagementOpenIdConnectProviderResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementOpenIdConnectProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementOpenIdConnectProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementOpenIdConnectProviderResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementOpenIdConnectProviderResource.cs index 676037edc2b3a..452d660987596 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementOpenIdConnectProviderResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementOpenIdConnectProviderResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementOpenIdConnectProviderResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadOpenIdConnectProvider() + public async Task Get_ApiManagementGetOpenIdConnectProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadOpenIdConnectProvider.json - // this example is just showing the usage of "OpenIdConnectProvider_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetOpenIdConnectProvider.json + // this example is just showing the usage of "OpenIdConnectProvider_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadOpenIdConnectProvider() ApiManagementOpenIdConnectProviderResource apiManagementOpenIdConnectProvider = client.GetApiManagementOpenIdConnectProviderResource(apiManagementOpenIdConnectProviderResourceId); // invoke the operation - bool result = await apiManagementOpenIdConnectProvider.GetEntityTagAsync(); + ApiManagementOpenIdConnectProviderResource result = await apiManagementOpenIdConnectProvider.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementOpenIdConnectProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetOpenIdConnectProvider() + public async Task Delete_ApiManagementDeleteOpenIdConnectProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetOpenIdConnectProvider.json - // this example is just showing the usage of "OpenIdConnectProvider_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteOpenIdConnectProvider.json + // this example is just showing the usage of "OpenIdConnectProvider_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,15 @@ public async Task Get_ApiManagementGetOpenIdConnectProvider() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string openId = "templateOpenIdConnect2"; + string openId = "templateOpenIdConnect3"; ResourceIdentifier apiManagementOpenIdConnectProviderResourceId = ApiManagementOpenIdConnectProviderResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, openId); ApiManagementOpenIdConnectProviderResource apiManagementOpenIdConnectProvider = client.GetApiManagementOpenIdConnectProviderResource(apiManagementOpenIdConnectProviderResourceId); // invoke the operation - ApiManagementOpenIdConnectProviderResource result = await apiManagementOpenIdConnectProvider.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementOpenIdConnectProvider.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementOpenIdConnectProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateOpenIdConnectProvider() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementOpenIdConnectProviderPatch patch = new ApiManagementOpenIdConnectProviderPatch() + ApiManagementOpenIdConnectProviderPatch patch = new ApiManagementOpenIdConnectProviderPatch { ClientSecret = "updatedsecret", UseInTestConsole = false, @@ -114,10 +115,10 @@ public async Task Update_ApiManagementUpdateOpenIdConnectProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteOpenIdConnectProvider() + public async Task GetSecrets_ApiManagementOpenidConnectProviderListSecrets() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteOpenIdConnectProvider.json - // this example is just showing the usage of "OpenIdConnectProvider_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementOpenidConnectProviderListSecrets.json + // this example is just showing the usage of "OpenIdConnectProvider_ListSecrets" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,23 +130,22 @@ public async Task Delete_ApiManagementDeleteOpenIdConnectProvider() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string openId = "templateOpenIdConnect3"; + string openId = "templateOpenIdConnect2"; ResourceIdentifier apiManagementOpenIdConnectProviderResourceId = ApiManagementOpenIdConnectProviderResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, openId); ApiManagementOpenIdConnectProviderResource apiManagementOpenIdConnectProvider = client.GetApiManagementOpenIdConnectProviderResource(apiManagementOpenIdConnectProviderResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementOpenIdConnectProvider.DeleteAsync(WaitUntil.Completed, ifMatch); + ClientSecretContract result = await apiManagementOpenIdConnectProvider.GetSecretsAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSecrets_ApiManagementOpenidConnectProviderListSecrets() + public async Task GetEntityTag_ApiManagementHeadOpenIdConnectProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementOpenidConnectProviderListSecrets.json - // this example is just showing the usage of "OpenIdConnectProvider_ListSecrets" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadOpenIdConnectProvider.json + // this example is just showing the usage of "OpenIdConnectProvider_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -162,7 +162,7 @@ public async Task GetSecrets_ApiManagementOpenidConnectProviderListSecrets() ApiManagementOpenIdConnectProviderResource apiManagementOpenIdConnectProvider = client.GetApiManagementOpenIdConnectProviderResource(apiManagementOpenIdConnectProviderResourceId); // invoke the operation - ClientSecretContract result = await apiManagementOpenIdConnectProvider.GetSecretsAsync(); + bool result = await apiManagementOpenIdConnectProvider.GetEntityTagAsync(); Console.WriteLine($"Succeeded: {result}"); } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPolicyCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPolicyCollection.cs index f5ce2881a97a2..205635cdd5dc9 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPolicyCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListPolicies() + public async Task CreateOrUpdate_ApiManagementCreatePolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPolicies.json - // this example is just showing the usage of "Policy_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreatePolicy.json + // this example is just showing the usage of "Policy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ApiManagementListPolicies() // get the collection of this ApiManagementPolicyResource ApiManagementPolicyCollection collection = apiManagementService.GetApiManagementPolicies(); - // invoke the operation and iterate over the result - await foreach (ApiManagementPolicyResource item in collection.GetAllAsync()) + // invoke the operation + PolicyName policyId = PolicyName.Policy; + PolicyContractData data = new PolicyContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = "\r\n \r\n \r\n \r\n \r\n \r\n", + Format = PolicyContentFormat.Xml, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data); + ApiManagementPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,9 +92,9 @@ public async Task Get_ApiManagementGetPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetPolicy() + public async Task Get_ApiManagementGetPolicyFormat() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicy.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFormat.json // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -111,17 +115,22 @@ public async Task Exists_ApiManagementGetPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - bool result = await collection.ExistsAsync(policyId); + PolicyExportFormat? format = PolicyExportFormat.RawXml; + ApiManagementPolicyResource result = await collection.GetAsync(policyId, format: format); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetPolicy() + public async Task GetAll_ApiManagementListPolicies() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicy.json - // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPolicies.json + // this example is just showing the usage of "Policy_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,30 +148,24 @@ public async Task GetIfExists_ApiManagementGetPolicy() // get the collection of this ApiManagementPolicyResource ApiManagementPolicyCollection collection = apiManagementService.GetApiManagementPolicies(); - // invoke the operation - PolicyName policyId = PolicyName.Policy; - NullableResponse response = await collection.GetIfExistsAsync(policyId); - ApiManagementPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ApiManagementPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; + PolicyContractData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetPolicyFormat() + public async Task Exists_ApiManagementGetPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFormat.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicy.json // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -183,14 +186,9 @@ public async Task Get_ApiManagementGetPolicyFormat() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyExportFormat? format = PolicyExportFormat.RawXml; - ApiManagementPolicyResource result = await collection.GetAsync(policyId, format: format); + bool result = await collection.ExistsAsync(policyId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -226,9 +224,9 @@ public async Task Exists_ApiManagementGetPolicyFormat() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetPolicyFormat() + public async Task GetIfExists_ApiManagementGetPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFormat.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicy.json // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -249,8 +247,7 @@ public async Task GetIfExists_ApiManagementGetPolicyFormat() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyExportFormat? format = PolicyExportFormat.RawXml; - NullableResponse response = await collection.GetIfExistsAsync(policyId, format: format); + NullableResponse response = await collection.GetIfExistsAsync(policyId); ApiManagementPolicyResource result = response.HasValue ? response.Value : null; if (result == null) @@ -269,10 +266,10 @@ public async Task GetIfExists_ApiManagementGetPolicyFormat() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreatePolicy() + public async Task GetIfExists_ApiManagementGetPolicyFormat() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreatePolicy.json - // this example is just showing the usage of "Policy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFormat.json + // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -292,19 +289,22 @@ public async Task CreateOrUpdate_ApiManagementCreatePolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = "\r\n \r\n \r\n \r\n \r\n \r\n", - Format = PolicyContentFormat.Xml, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data); - ApiManagementPolicyResource result = lro.Value; + PolicyExportFormat? format = PolicyExportFormat.RawXml; + NullableResponse response = await collection.GetIfExistsAsync(policyId, format: format); + ApiManagementPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPolicyResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPolicyResource.cs index 39010212bb930..6543a4a985e3f 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPolicyResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadPolicy() + public async Task Get_ApiManagementGetPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadPolicy.json - // this example is just showing the usage of "Policy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicy.json + // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,20 @@ public async Task GetEntityTag_ApiManagementHeadPolicy() ApiManagementPolicyResource apiManagementPolicy = client.GetApiManagementPolicyResource(apiManagementPolicyResourceId); // invoke the operation - bool result = await apiManagementPolicy.GetEntityTagAsync(); + ApiManagementPolicyResource result = await apiManagementPolicy.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetPolicy() + public async Task Get_ApiManagementGetPolicyFormat() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicy.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFormat.json // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -65,7 +69,8 @@ public async Task Get_ApiManagementGetPolicy() ApiManagementPolicyResource apiManagementPolicy = client.GetApiManagementPolicyResource(apiManagementPolicyResourceId); // invoke the operation - ApiManagementPolicyResource result = await apiManagementPolicy.GetAsync(); + PolicyExportFormat? format = PolicyExportFormat.RawXml; + ApiManagementPolicyResource result = await apiManagementPolicy.GetAsync(format: format); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -76,10 +81,10 @@ public async Task Get_ApiManagementGetPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetPolicyFormat() + public async Task Delete_ApiManagementDeletePolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFormat.json - // this example is just showing the usage of "Policy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeletePolicy.json + // this example is just showing the usage of "Policy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,14 +101,10 @@ public async Task Get_ApiManagementGetPolicyFormat() ApiManagementPolicyResource apiManagementPolicy = client.GetApiManagementPolicyResource(apiManagementPolicyResourceId); // invoke the operation - PolicyExportFormat? format = PolicyExportFormat.RawXml; - ApiManagementPolicyResource result = await apiManagementPolicy.GetAsync(format: format); + ETag ifMatch = new ETag("*"); + await apiManagementPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -128,7 +129,7 @@ public async Task Update_ApiManagementCreatePolicy() ApiManagementPolicyResource apiManagementPolicy = client.GetApiManagementPolicyResource(apiManagementPolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = "\r\n \r\n \r\n \r\n \r\n \r\n", Format = PolicyContentFormat.Xml, @@ -145,10 +146,10 @@ public async Task Update_ApiManagementCreatePolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeletePolicy() + public async Task GetEntityTag_ApiManagementHeadPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeletePolicy.json - // this example is just showing the usage of "Policy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadPolicy.json + // this example is just showing the usage of "Policy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,10 +166,9 @@ public async Task Delete_ApiManagementDeletePolicy() ApiManagementPolicyResource apiManagementPolicy = client.GetApiManagementPolicyResource(apiManagementPolicyResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiManagementPolicy.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalDelegationSettingResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalDelegationSettingResource.cs index 873e9e5cdec95..a2aa3d76329d2 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalDelegationSettingResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalDelegationSettingResource.cs @@ -16,32 +16,6 @@ namespace Azure.ResourceManager.ApiManagement.Samples { public partial class Sample_ApiManagementPortalDelegationSettingResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadDelegationSettings() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadDelegationSettings.json - // this example is just showing the usage of "DelegationSettings_GetEntityTag" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementPortalDelegationSettingResource created on azure - // for more information of creating ApiManagementPortalDelegationSettingResource, please refer to the document of ApiManagementPortalDelegationSettingResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementPortalDelegationSettingResourceId = ApiManagementPortalDelegationSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementPortalDelegationSettingResource apiManagementPortalDelegationSetting = client.GetApiManagementPortalDelegationSettingResource(apiManagementPortalDelegationSettingResourceId); - - // invoke the operation - bool result = await apiManagementPortalDelegationSetting.GetEntityTagAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ApiManagementPortalSettingsGetDelegation() @@ -94,7 +68,7 @@ public async Task Update_ApiManagementPortalSettingsUpdateDelegation() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementPortalDelegationSettingData data = new ApiManagementPortalDelegationSettingData() + ApiManagementPortalDelegationSettingData data = new ApiManagementPortalDelegationSettingData { Uri = new Uri("http://contoso.com/delegation"), ValidationKey = "", @@ -127,7 +101,7 @@ public async Task CreateOrUpdate_ApiManagementPortalSettingsUpdateDelegation() ApiManagementPortalDelegationSettingResource apiManagementPortalDelegationSetting = client.GetApiManagementPortalDelegationSettingResource(apiManagementPortalDelegationSettingResourceId); // invoke the operation - ApiManagementPortalDelegationSettingData data = new ApiManagementPortalDelegationSettingData() + ApiManagementPortalDelegationSettingData data = new ApiManagementPortalDelegationSettingData { Uri = new Uri("http://contoso.com/delegation"), ValidationKey = "", @@ -170,5 +144,31 @@ public async Task GetSecrets_ApiManagementListSecretsPortalSettings() Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEntityTag_ApiManagementHeadDelegationSettings() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadDelegationSettings.json + // this example is just showing the usage of "DelegationSettings_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementPortalDelegationSettingResource created on azure + // for more information of creating ApiManagementPortalDelegationSettingResource, please refer to the document of ApiManagementPortalDelegationSettingResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementPortalDelegationSettingResourceId = ApiManagementPortalDelegationSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementPortalDelegationSettingResource apiManagementPortalDelegationSetting = client.GetApiManagementPortalDelegationSettingResource(apiManagementPortalDelegationSettingResourceId); + + // invoke the operation + bool result = await apiManagementPortalDelegationSetting.GetEntityTagAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalRevisionCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalRevisionCollection.cs index aeec55e9a6eab..547b561a65045 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalRevisionCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalRevisionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementPortalRevisionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListPortalRevisions() + public async Task CreateOrUpdate_ApiManagementCreatePortalRevision() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPortalRevisions.json - // this example is just showing the usage of "PortalRevision_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreatePortalRevision.json + // this example is just showing the usage of "PortalRevision_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_ApiManagementListPortalRevisions() // get the collection of this ApiManagementPortalRevisionResource ApiManagementPortalRevisionCollection collection = apiManagementService.GetApiManagementPortalRevisions(); - // invoke the operation and iterate over the result - await foreach (ApiManagementPortalRevisionResource item in collection.GetAllAsync()) + // invoke the operation + string portalRevisionId = "20201112101010"; + ApiManagementPortalRevisionData data = new ApiManagementPortalRevisionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementPortalRevisionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "portal revision 1", + IsCurrent = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, portalRevisionId, data); + ApiManagementPortalRevisionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementPortalRevisionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_ApiManagementGetPortalRevision() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetPortalRevision() + public async Task GetAll_ApiManagementListPortalRevisions() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPortalRevision.json - // this example is just showing the usage of "PortalRevision_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPortalRevisions.json + // this example is just showing the usage of "PortalRevision_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_ApiManagementGetPortalRevision() // get the collection of this ApiManagementPortalRevisionResource ApiManagementPortalRevisionCollection collection = apiManagementService.GetApiManagementPortalRevisions(); - // invoke the operation - string portalRevisionId = "20201112101010"; - bool result = await collection.ExistsAsync(portalRevisionId); + // invoke the operation and iterate over the result + await foreach (ApiManagementPortalRevisionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementPortalRevisionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetPortalRevision() + public async Task Exists_ApiManagementGetPortalRevision() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPortalRevision.json // this example is just showing the usage of "PortalRevision_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_ApiManagementGetPortalRevision() // invoke the operation string portalRevisionId = "20201112101010"; - NullableResponse response = await collection.GetIfExistsAsync(portalRevisionId); - ApiManagementPortalRevisionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(portalRevisionId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementPortalRevisionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreatePortalRevision() + public async Task GetIfExists_ApiManagementGetPortalRevision() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreatePortalRevision.json - // this example is just showing the usage of "PortalRevision_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPortalRevision.json + // this example is just showing the usage of "PortalRevision_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,19 +180,21 @@ public async Task CreateOrUpdate_ApiManagementCreatePortalRevision() // invoke the operation string portalRevisionId = "20201112101010"; - ApiManagementPortalRevisionData data = new ApiManagementPortalRevisionData() - { - Description = "portal revision 1", - IsCurrent = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, portalRevisionId, data); - ApiManagementPortalRevisionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(portalRevisionId); + ApiManagementPortalRevisionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementPortalRevisionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementPortalRevisionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalRevisionResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalRevisionResource.cs index 6290e30c37be5..d4220fd5f4b5c 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalRevisionResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalRevisionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementPortalRevisionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadPortalRevision() + public async Task Get_ApiManagementGetPortalRevision() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadPortalRevision.json - // this example is just showing the usage of "PortalRevision_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPortalRevision.json + // this example is just showing the usage of "PortalRevision_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task GetEntityTag_ApiManagementHeadPortalRevision() ApiManagementPortalRevisionResource apiManagementPortalRevision = client.GetApiManagementPortalRevisionResource(apiManagementPortalRevisionResourceId); // invoke the operation - bool result = await apiManagementPortalRevision.GetEntityTagAsync(); + ApiManagementPortalRevisionResource result = await apiManagementPortalRevision.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementPortalRevisionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetPortalRevision() + public async Task Update_ApiManagementUpdatePortalRevision() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPortalRevision.json - // this example is just showing the usage of "PortalRevision_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdatePortalRevision.json + // this example is just showing the usage of "PortalRevision_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,7 +68,14 @@ public async Task Get_ApiManagementGetPortalRevision() ApiManagementPortalRevisionResource apiManagementPortalRevision = client.GetApiManagementPortalRevisionResource(apiManagementPortalRevisionResourceId); // invoke the operation - ApiManagementPortalRevisionResource result = await apiManagementPortalRevision.GetAsync(); + ETag ifMatch = new ETag("*"); + ApiManagementPortalRevisionData data = new ApiManagementPortalRevisionData + { + Description = "portal revision update", + IsCurrent = true, + }; + ArmOperation lro = await apiManagementPortalRevision.UpdateAsync(WaitUntil.Completed, ifMatch, data); + ApiManagementPortalRevisionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -75,10 +86,10 @@ public async Task Get_ApiManagementGetPortalRevision() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementUpdatePortalRevision() + public async Task GetEntityTag_ApiManagementHeadPortalRevision() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdatePortalRevision.json - // this example is just showing the usage of "PortalRevision_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadPortalRevision.json + // this example is just showing the usage of "PortalRevision_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,20 +106,9 @@ public async Task Update_ApiManagementUpdatePortalRevision() ApiManagementPortalRevisionResource apiManagementPortalRevision = client.GetApiManagementPortalRevisionResource(apiManagementPortalRevisionResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - ApiManagementPortalRevisionData data = new ApiManagementPortalRevisionData() - { - Description = "portal revision update", - IsCurrent = true, - }; - ArmOperation lro = await apiManagementPortalRevision.UpdateAsync(WaitUntil.Completed, ifMatch, data); - ApiManagementPortalRevisionResource result = lro.Value; + bool result = await apiManagementPortalRevision.GetEntityTagAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementPortalRevisionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalSignInSettingResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalSignInSettingResource.cs index dae89141817a7..0e1214770967f 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalSignInSettingResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalSignInSettingResource.cs @@ -15,32 +15,6 @@ namespace Azure.ResourceManager.ApiManagement.Samples { public partial class Sample_ApiManagementPortalSignInSettingResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadSignInSettings() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadSignInSettings.json - // this example is just showing the usage of "SignInSettings_GetEntityTag" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementPortalSignInSettingResource created on azure - // for more information of creating ApiManagementPortalSignInSettingResource, please refer to the document of ApiManagementPortalSignInSettingResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementPortalSignInSettingResourceId = ApiManagementPortalSignInSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementPortalSignInSettingResource apiManagementPortalSignInSetting = client.GetApiManagementPortalSignInSettingResource(apiManagementPortalSignInSettingResourceId); - - // invoke the operation - bool result = await apiManagementPortalSignInSetting.GetEntityTagAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ApiManagementPortalSettingsGetSignIn() @@ -93,7 +67,7 @@ public async Task Update_ApiManagementPortalSettingsUpdateSignIn() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementPortalSignInSettingData data = new ApiManagementPortalSignInSettingData() + ApiManagementPortalSignInSettingData data = new ApiManagementPortalSignInSettingData { IsRedirectEnabled = true, }; @@ -123,7 +97,7 @@ public async Task CreateOrUpdate_ApiManagementPortalSettingsUpdateSignIn() ApiManagementPortalSignInSettingResource apiManagementPortalSignInSetting = client.GetApiManagementPortalSignInSettingResource(apiManagementPortalSignInSettingResourceId); // invoke the operation - ApiManagementPortalSignInSettingData data = new ApiManagementPortalSignInSettingData() + ApiManagementPortalSignInSettingData data = new ApiManagementPortalSignInSettingData { IsRedirectEnabled = true, }; @@ -137,5 +111,31 @@ public async Task CreateOrUpdate_ApiManagementPortalSettingsUpdateSignIn() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEntityTag_ApiManagementHeadSignInSettings() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadSignInSettings.json + // this example is just showing the usage of "SignInSettings_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementPortalSignInSettingResource created on azure + // for more information of creating ApiManagementPortalSignInSettingResource, please refer to the document of ApiManagementPortalSignInSettingResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementPortalSignInSettingResourceId = ApiManagementPortalSignInSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementPortalSignInSettingResource apiManagementPortalSignInSetting = client.GetApiManagementPortalSignInSettingResource(apiManagementPortalSignInSettingResourceId); + + // invoke the operation + bool result = await apiManagementPortalSignInSetting.GetEntityTagAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalSignUpSettingResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalSignUpSettingResource.cs index 98490951fc69e..bc00b0f14a24d 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalSignUpSettingResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPortalSignUpSettingResource.cs @@ -16,32 +16,6 @@ namespace Azure.ResourceManager.ApiManagement.Samples { public partial class Sample_ApiManagementPortalSignUpSettingResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadSignUpSettings() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadSignUpSettings.json - // this example is just showing the usage of "SignUpSettings_GetEntityTag" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementPortalSignUpSettingResource created on azure - // for more information of creating ApiManagementPortalSignUpSettingResource, please refer to the document of ApiManagementPortalSignUpSettingResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementPortalSignUpSettingResourceId = ApiManagementPortalSignUpSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementPortalSignUpSettingResource apiManagementPortalSignUpSetting = client.GetApiManagementPortalSignUpSettingResource(apiManagementPortalSignUpSettingResourceId); - - // invoke the operation - bool result = await apiManagementPortalSignUpSetting.GetEntityTagAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ApiManagementPortalSettingsGetSignUp() @@ -94,10 +68,10 @@ public async Task Update_ApiManagementPortalSettingsUpdateSignUp() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementPortalSignUpSettingData data = new ApiManagementPortalSignUpSettingData() + ApiManagementPortalSignUpSettingData data = new ApiManagementPortalSignUpSettingData { IsSignUpDeveloperPortalEnabled = true, - TermsOfService = new TermsOfServiceProperties() + TermsOfService = new TermsOfServiceProperties { Text = "Terms of service text.", IsDisplayEnabled = true, @@ -130,10 +104,10 @@ public async Task CreateOrUpdate_ApiManagementPortalSettingsUpdateSignUp() ApiManagementPortalSignUpSettingResource apiManagementPortalSignUpSetting = client.GetApiManagementPortalSignUpSettingResource(apiManagementPortalSignUpSettingResourceId); // invoke the operation - ApiManagementPortalSignUpSettingData data = new ApiManagementPortalSignUpSettingData() + ApiManagementPortalSignUpSettingData data = new ApiManagementPortalSignUpSettingData { IsSignUpDeveloperPortalEnabled = true, - TermsOfService = new TermsOfServiceProperties() + TermsOfService = new TermsOfServiceProperties { Text = "Terms of service text.", IsDisplayEnabled = true, @@ -150,5 +124,31 @@ public async Task CreateOrUpdate_ApiManagementPortalSettingsUpdateSignUp() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEntityTag_ApiManagementHeadSignUpSettings() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadSignUpSettings.json + // this example is just showing the usage of "SignUpSettings_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementPortalSignUpSettingResource created on azure + // for more information of creating ApiManagementPortalSignUpSettingResource, please refer to the document of ApiManagementPortalSignUpSettingResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementPortalSignUpSettingResourceId = ApiManagementPortalSignUpSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementPortalSignUpSettingResource apiManagementPortalSignUpSetting = client.GetApiManagementPortalSignUpSettingResource(apiManagementPortalSignUpSettingResourceId); + + // invoke the operation + bool result = await apiManagementPortalSignUpSetting.GetEntityTagAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateEndpointConnectionCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateEndpointConnectionCollection.cs index 243a3cda992e0..980a0e9e93748 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateEndpointConnectionCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListPrivateEndpointConnections() + public async Task CreateOrUpdate_ApiManagementApproveOrRejectPrivateEndpointConnection() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPrivateEndpointConnections.json - // this example is just showing the usage of "PrivateEndpointConnection_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementApproveOrRejectPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ApiManagementListPrivateEndpointConnections() // get the collection of this ApiManagementPrivateEndpointConnectionResource ApiManagementPrivateEndpointConnectionCollection collection = apiManagementService.GetApiManagementPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (ApiManagementPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "privateEndpointConnectionName"; + ApiManagementPrivateEndpointConnectionCreateOrUpdateContent content = new ApiManagementPrivateEndpointConnectionCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/connectionName"), + PrivateLinkServiceConnectionState = new ApiManagementPrivateLinkServiceConnectionState + { + Status = ApiManagementPrivateEndpointServiceConnectionStatus.Approved, + Description = "The Private Endpoint Connection is approved.", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, content); + ApiManagementPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_ApiManagementGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetPrivateEndpointConnection() + public async Task GetAll_ApiManagementListPrivateEndpointConnections() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_GetByName" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPrivateEndpointConnections.json + // this example is just showing the usage of "PrivateEndpointConnection_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_ApiManagementGetPrivateEndpointConnection() // get the collection of this ApiManagementPrivateEndpointConnectionResource ApiManagementPrivateEndpointConnectionCollection collection = apiManagementService.GetApiManagementPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "privateEndpointConnectionName"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (ApiManagementPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetPrivateEndpointConnection() + public async Task Exists_ApiManagementGetPrivateEndpointConnection() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnection_GetByName" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_ApiManagementGetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "privateEndpointConnectionName"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - ApiManagementPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementApproveOrRejectPrivateEndpointConnection() + public async Task GetIfExists_ApiManagementGetPrivateEndpointConnection() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementApproveOrRejectPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_GetByName" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_ApiManagementApproveOrRejectPrivateEndpointConn // invoke the operation string privateEndpointConnectionName = "privateEndpointConnectionName"; - ApiManagementPrivateEndpointConnectionCreateOrUpdateContent content = new ApiManagementPrivateEndpointConnectionCreateOrUpdateContent() - { - Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/connectionName"), - PrivateLinkServiceConnectionState = new ApiManagementPrivateLinkServiceConnectionState() - { - Status = ApiManagementPrivateEndpointServiceConnectionStatus.Approved, - Description = "The Private Endpoint Connection is approved.", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, content); - ApiManagementPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + ApiManagementPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateEndpointConnectionResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateEndpointConnectionResource.cs index 72f73def91559..d984d92877846 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateEndpointConnectionResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_ApiManagementGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementApproveOrRejectPrivateEndpointConnection() + public async Task Delete_ApiManagementDeletePrivateEndpointConnection() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementApproveOrRejectPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,17 @@ public async Task Update_ApiManagementApproveOrRejectPrivateEndpointConnection() ApiManagementPrivateEndpointConnectionResource apiManagementPrivateEndpointConnection = client.GetApiManagementPrivateEndpointConnectionResource(apiManagementPrivateEndpointConnectionResourceId); // invoke the operation - ApiManagementPrivateEndpointConnectionCreateOrUpdateContent content = new ApiManagementPrivateEndpointConnectionCreateOrUpdateContent() - { - Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/connectionName"), - PrivateLinkServiceConnectionState = new ApiManagementPrivateLinkServiceConnectionState() - { - Status = ApiManagementPrivateEndpointServiceConnectionStatus.Approved, - Description = "The Private Endpoint Connection is approved.", - }, - }; - ArmOperation lro = await apiManagementPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, content); - ApiManagementPrivateEndpointConnectionResource result = lro.Value; + await apiManagementPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeletePrivateEndpointConnection() + public async Task Update_ApiManagementApproveOrRejectPrivateEndpointConnection() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnection_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementApproveOrRejectPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +96,23 @@ public async Task Delete_ApiManagementDeletePrivateEndpointConnection() ApiManagementPrivateEndpointConnectionResource apiManagementPrivateEndpointConnection = client.GetApiManagementPrivateEndpointConnectionResource(apiManagementPrivateEndpointConnectionResourceId); // invoke the operation - await apiManagementPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + ApiManagementPrivateEndpointConnectionCreateOrUpdateContent content = new ApiManagementPrivateEndpointConnectionCreateOrUpdateContent + { + Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/privateEndpointConnections/connectionName"), + PrivateLinkServiceConnectionState = new ApiManagementPrivateLinkServiceConnectionState + { + Status = ApiManagementPrivateEndpointServiceConnectionStatus.Approved, + Description = "The Private Endpoint Connection is approved.", + }, + }; + ArmOperation lro = await apiManagementPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, content); + ApiManagementPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateLinkResourceCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateLinkResourceCollection.cs index 013889d23915c..9e0e751479995 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateLinkResourceCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListPrivateLinkGroupResources() + public async Task Get_ApiManagementGetPrivateLinkGroupResource() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPrivateLinkGroupResources.json - // this example is just showing the usage of "PrivateEndpointConnection_ListPrivateLinkResources" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPrivateLinkGroupResource.json + // this example is just showing the usage of "PrivateEndpointConnection_GetPrivateLinkResource" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ApiManagementListPrivateLinkGroupResources() // get the collection of this ApiManagementPrivateLinkResource ApiManagementPrivateLinkResourceCollection collection = apiManagementService.GetApiManagementPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (ApiManagementPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateLinkSubResourceName = "privateLinkSubResourceName"; + ApiManagementPrivateLinkResource result = await collection.GetAsync(privateLinkSubResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetPrivateLinkGroupResource() + public async Task GetAll_ApiManagementListPrivateLinkGroupResources() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPrivateLinkGroupResource.json - // this example is just showing the usage of "PrivateEndpointConnection_GetPrivateLinkResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPrivateLinkGroupResources.json + // this example is just showing the usage of "PrivateEndpointConnection_ListPrivateLinkResources" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_ApiManagementGetPrivateLinkGroupResource() // get the collection of this ApiManagementPrivateLinkResource ApiManagementPrivateLinkResourceCollection collection = apiManagementService.GetApiManagementPrivateLinkResources(); - // invoke the operation - string privateLinkSubResourceName = "privateLinkSubResourceName"; - ApiManagementPrivateLinkResource result = await collection.GetAsync(privateLinkSubResourceName); + // invoke the operation and iterate over the result + await foreach (ApiManagementPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductCollection.cs index 56bcab4f7c685..e381a328c9812 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementProductCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListProducts() + public async Task CreateOrUpdate_ApiManagementCreateProduct() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListProducts.json - // this example is just showing the usage of "Product_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProduct.json + // this example is just showing the usage of "Product_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ApiManagementListProducts() // get the collection of this ApiManagementProductResource ApiManagementProductCollection collection = apiManagementService.GetApiManagementProducts(); - // invoke the operation and iterate over the result - await foreach (ApiManagementProductResource item in collection.GetAllAsync()) + // invoke the operation + string productId = "testproduct"; + ApiManagementProductData data = new ApiManagementProductData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementProductData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "Test Template ProductName 4", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, productId, data); + ApiManagementProductResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_ApiManagementGetProduct() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetProduct() + public async Task GetAll_ApiManagementListProducts() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProduct.json - // this example is just showing the usage of "Product_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListProducts.json + // this example is just showing the usage of "Product_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_ApiManagementGetProduct() // get the collection of this ApiManagementProductResource ApiManagementProductCollection collection = apiManagementService.GetApiManagementProducts(); - // invoke the operation - string productId = "unlimited"; - bool result = await collection.ExistsAsync(productId); + // invoke the operation and iterate over the result + await foreach (ApiManagementProductResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementProductData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetProduct() + public async Task Exists_ApiManagementGetProduct() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProduct.json // this example is just showing the usage of "Product_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_ApiManagementGetProduct() // invoke the operation string productId = "unlimited"; - NullableResponse response = await collection.GetIfExistsAsync(productId); - ApiManagementProductResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(productId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateProduct() + public async Task GetIfExists_ApiManagementGetProduct() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProduct.json - // this example is just showing the usage of "Product_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProduct.json + // this example is just showing the usage of "Product_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,19 +178,22 @@ public async Task CreateOrUpdate_ApiManagementCreateProduct() ApiManagementProductCollection collection = apiManagementService.GetApiManagementProducts(); // invoke the operation - string productId = "testproduct"; - ApiManagementProductData data = new ApiManagementProductData() - { - DisplayName = "Test Template ProductName 4", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, productId, data); - ApiManagementProductResource result = lro.Value; + string productId = "unlimited"; + NullableResponse response = await collection.GetIfExistsAsync(productId); + ApiManagementProductResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductPolicyCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductPolicyCollection.cs index 9a2e84df40c23..730092d559554 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductPolicyCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementProductPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListProductPolicies() + public async Task CreateOrUpdate_ApiManagementCreateProductPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListProductPolicies.json - // this example is just showing the usage of "ProductPolicy_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductPolicy.json + // this example is just showing the usage of "ProductPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,24 +33,28 @@ public async Task GetAll_ApiManagementListProductPolicies() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "armTemplateProduct4"; + string productId = "5702e97e5157a50f48dce801"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); // get the collection of this ApiManagementProductPolicyResource ApiManagementProductPolicyCollection collection = apiManagementProduct.GetApiManagementProductPolicies(); - // invoke the operation and iterate over the result - await foreach (ApiManagementProductPolicyResource item in collection.GetAllAsync()) + // invoke the operation + PolicyName policyId = PolicyName.Policy; + PolicyContractData data = new PolicyContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = "\r\n \r\n \r\n \r\n @( string.Join(\",\", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) ) \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", + Format = PolicyContentFormat.Xml, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data); + ApiManagementProductPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +94,10 @@ public async Task Get_ApiManagementGetProductPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetProductPolicy() + public async Task GetAll_ApiManagementListProductPolicies() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductPolicy.json - // this example is just showing the usage of "ProductPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListProductPolicies.json + // this example is just showing the usage of "ProductPolicy_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,23 +109,29 @@ public async Task Exists_ApiManagementGetProductPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "kjoshiarmTemplateProduct4"; + string productId = "armTemplateProduct4"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); // get the collection of this ApiManagementProductPolicyResource ApiManagementProductPolicyCollection collection = apiManagementProduct.GetApiManagementProductPolicies(); - // invoke the operation - PolicyName policyId = PolicyName.Policy; - bool result = await collection.ExistsAsync(policyId); + // invoke the operation and iterate over the result + await foreach (ApiManagementProductPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetProductPolicy() + public async Task Exists_ApiManagementGetProductPolicy() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductPolicy.json // this example is just showing the usage of "ProductPolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +155,17 @@ public async Task GetIfExists_ApiManagementGetProductPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - NullableResponse response = await collection.GetIfExistsAsync(policyId); - ApiManagementProductPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateProductPolicy() + public async Task GetIfExists_ApiManagementGetProductPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductPolicy.json - // this example is just showing the usage of "ProductPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductPolicy.json + // this example is just showing the usage of "ProductPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,7 +177,7 @@ public async Task CreateOrUpdate_ApiManagementCreateProductPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "5702e97e5157a50f48dce801"; + string productId = "kjoshiarmTemplateProduct4"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); @@ -188,19 +186,21 @@ public async Task CreateOrUpdate_ApiManagementCreateProductPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = "\r\n \r\n \r\n \r\n @( string.Join(\",\", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) ) \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", - Format = PolicyContentFormat.Xml, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data); - ApiManagementProductPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyId); + ApiManagementProductPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductPolicyResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductPolicyResource.cs index 4448e1ace09b4..87e75c7ab3b0d 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductPolicyResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementProductPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadProductPolicy() + public async Task Get_ApiManagementGetProductPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadProductPolicy.json - // this example is just showing the usage of "ProductPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductPolicy.json + // this example is just showing the usage of "ProductPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,23 +33,27 @@ public async Task GetEntityTag_ApiManagementHeadProductPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "unlimited"; + string productId = "kjoshiarmTemplateProduct4"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier apiManagementProductPolicyResourceId = ApiManagementProductPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId, policyId); ApiManagementProductPolicyResource apiManagementProductPolicy = client.GetApiManagementProductPolicyResource(apiManagementProductPolicyResourceId); // invoke the operation - bool result = await apiManagementProductPolicy.GetEntityTagAsync(); + ApiManagementProductPolicyResource result = await apiManagementProductPolicy.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetProductPolicy() + public async Task Delete_ApiManagementDeleteProductPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductPolicy.json - // this example is just showing the usage of "ProductPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProductPolicy.json + // this example is just showing the usage of "ProductPolicy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,19 +65,16 @@ public async Task Get_ApiManagementGetProductPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "kjoshiarmTemplateProduct4"; + string productId = "testproduct"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier apiManagementProductPolicyResourceId = ApiManagementProductPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId, policyId); ApiManagementProductPolicyResource apiManagementProductPolicy = client.GetApiManagementProductPolicyResource(apiManagementProductPolicyResourceId); // invoke the operation - ApiManagementProductPolicyResource result = await apiManagementProductPolicy.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementProductPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,7 +100,7 @@ public async Task Update_ApiManagementCreateProductPolicy() ApiManagementProductPolicyResource apiManagementProductPolicy = client.GetApiManagementProductPolicyResource(apiManagementProductPolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = "\r\n \r\n \r\n \r\n @( string.Join(\",\", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) ) \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", Format = PolicyContentFormat.Xml, @@ -116,10 +117,10 @@ public async Task Update_ApiManagementCreateProductPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteProductPolicy() + public async Task GetEntityTag_ApiManagementHeadProductPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProductPolicy.json - // this example is just showing the usage of "ProductPolicy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadProductPolicy.json + // this example is just showing the usage of "ProductPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,16 +132,15 @@ public async Task Delete_ApiManagementDeleteProductPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "testproduct"; + string productId = "unlimited"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier apiManagementProductPolicyResourceId = ApiManagementProductPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId, policyId); ApiManagementProductPolicyResource apiManagementProductPolicy = client.GetApiManagementProductPolicyResource(apiManagementProductPolicyResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementProductPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiManagementProductPolicy.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductResource.cs index a6db97ff4cbbb..958e05292f4a1 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementProductResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadProduct() + public async Task Get_ApiManagementGetProduct() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadProduct.json - // this example is just showing the usage of "Product_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProduct.json + // this example is just showing the usage of "Product_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadProduct() ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); // invoke the operation - bool result = await apiManagementProduct.GetEntityTagAsync(); + ApiManagementProductResource result = await apiManagementProduct.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetProduct() + public async Task Delete_ApiManagementDeleteProduct() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProduct.json - // this example is just showing the usage of "Product_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProduct.json + // this example is just showing the usage of "Product_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,16 @@ public async Task Get_ApiManagementGetProduct() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "unlimited"; + string productId = "testproduct"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); // invoke the operation - ApiManagementProductResource result = await apiManagementProduct.GetAsync(); + ETag ifMatch = new ETag("*"); + bool? deleteSubscriptions = true; + await apiManagementProduct.DeleteAsync(WaitUntil.Completed, ifMatch, deleteSubscriptions: deleteSubscriptions); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +99,7 @@ public async Task Update_ApiManagementUpdateProduct() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementProductPatch patch = new ApiManagementProductPatch() + ApiManagementProductPatch patch = new ApiManagementProductPatch { DisplayName = "Test Template ProductName 4", }; @@ -110,35 +112,6 @@ public async Task Update_ApiManagementUpdateProduct() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteProduct() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProduct.json - // this example is just showing the usage of "Product_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementProductResource created on azure - // for more information of creating ApiManagementProductResource, please refer to the document of ApiManagementProductResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - string productId = "testproduct"; - ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); - ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); - - // invoke the operation - ETag ifMatch = new ETag("*"); - bool? deleteSubscriptions = true; - await apiManagementProduct.DeleteAsync(WaitUntil.Completed, ifMatch, deleteSubscriptions: deleteSubscriptions); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetProductApis_ApiManagementListProductApis() @@ -397,5 +370,32 @@ public async Task GetAllProductSubscriptionData_ApiManagementListProductSubscrip Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEntityTag_ApiManagementHeadProduct() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadProduct.json + // this example is just showing the usage of "Product_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementProductResource created on azure + // for more information of creating ApiManagementProductResource, please refer to the document of ApiManagementProductResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + string productId = "unlimited"; + ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); + ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); + + // invoke the operation + bool result = await apiManagementProduct.GetEntityTagAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductTagCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductTagCollection.cs index eb33a13bdce81..69eb1333db647 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductTagCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductTagCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementProductTagCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListProductTags() + public async Task CreateOrUpdate_ApiManagementCreateProductTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListProductTags.json - // this example is just showing the usage of "Tag_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductTag.json + // this example is just showing the usage of "Tag_AssignToProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,23 @@ public async Task GetAll_ApiManagementListProductTags() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "57d2ef278aa04f0888cba3f1"; + string productId = "5931a75ae4bbd512a88c680b"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); // get the collection of this ApiManagementProductTagResource ApiManagementProductTagCollection collection = apiManagementProduct.GetApiManagementProductTags(); - // invoke the operation and iterate over the result - await foreach (ApiManagementProductTagResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string tagId = "tagId1"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagId); + ApiManagementProductTagResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +88,10 @@ public async Task Get_ApiManagementGetProductTag() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetProductTag() + public async Task GetAll_ApiManagementListProductTags() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductTag.json - // this example is just showing the usage of "Tag_GetByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListProductTags.json + // this example is just showing the usage of "Tag_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,23 +103,29 @@ public async Task Exists_ApiManagementGetProductTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "59d6bb8f1f7fab13dc67ec9b"; + string productId = "57d2ef278aa04f0888cba3f1"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); // get the collection of this ApiManagementProductTagResource ApiManagementProductTagCollection collection = apiManagementProduct.GetApiManagementProductTags(); - // invoke the operation - string tagId = "59306a29e4bbd510dc24e5f9"; - bool result = await collection.ExistsAsync(tagId); + // invoke the operation and iterate over the result + await foreach (ApiManagementProductTagResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetProductTag() + public async Task Exists_ApiManagementGetProductTag() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductTag.json // this example is just showing the usage of "Tag_GetByProduct" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +149,17 @@ public async Task GetIfExists_ApiManagementGetProductTag() // invoke the operation string tagId = "59306a29e4bbd510dc24e5f9"; - NullableResponse response = await collection.GetIfExistsAsync(tagId); - ApiManagementProductTagResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tagId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateProductTag() + public async Task GetIfExists_ApiManagementGetProductTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductTag.json - // this example is just showing the usage of "Tag_AssignToProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductTag.json + // this example is just showing the usage of "Tag_GetByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,7 +171,7 @@ public async Task CreateOrUpdate_ApiManagementCreateProductTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "5931a75ae4bbd512a88c680b"; + string productId = "59d6bb8f1f7fab13dc67ec9b"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); @@ -186,15 +179,22 @@ public async Task CreateOrUpdate_ApiManagementCreateProductTag() ApiManagementProductTagCollection collection = apiManagementProduct.GetApiManagementProductTags(); // invoke the operation - string tagId = "tagId1"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagId); - ApiManagementProductTagResource result = lro.Value; + string tagId = "59306a29e4bbd510dc24e5f9"; + NullableResponse response = await collection.GetIfExistsAsync(tagId); + ApiManagementProductTagResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductTagResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductTagResource.cs index 5c851561c3d3a..978d98425f7fd 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductTagResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementProductTagResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementProductTagResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityStateByProduct_ApiManagementHeadProductTag() + public async Task Get_ApiManagementGetProductTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadProductTag.json - // this example is just showing the usage of "Tag_GetEntityStateByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductTag.json + // this example is just showing the usage of "Tag_GetByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,23 +32,27 @@ public async Task GetEntityStateByProduct_ApiManagementHeadProductTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "59306a29e4bbd510dc24e5f8"; + string productId = "59d6bb8f1f7fab13dc67ec9b"; string tagId = "59306a29e4bbd510dc24e5f9"; ResourceIdentifier apiManagementProductTagResourceId = ApiManagementProductTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId, tagId); ApiManagementProductTagResource apiManagementProductTag = client.GetApiManagementProductTagResource(apiManagementProductTagResourceId); // invoke the operation - bool result = await apiManagementProductTag.GetEntityStateByProductAsync(); + ApiManagementProductTagResource result = await apiManagementProductTag.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetProductTag() + public async Task Delete_ApiManagementDeleteProductTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductTag.json - // this example is just showing the usage of "Tag_GetByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProductTag.json + // this example is just showing the usage of "Tag_DetachFromProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,19 +64,15 @@ public async Task Get_ApiManagementGetProductTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "59d6bb8f1f7fab13dc67ec9b"; - string tagId = "59306a29e4bbd510dc24e5f9"; + string productId = "59d5b28d1f7fab116c282650"; + string tagId = "59d5b28e1f7fab116402044e"; ResourceIdentifier apiManagementProductTagResourceId = ApiManagementProductTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId, tagId); ApiManagementProductTagResource apiManagementProductTag = client.GetApiManagementProductTagResource(apiManagementProductTagResourceId); // invoke the operation - ApiManagementProductTagResource result = await apiManagementProductTag.GetAsync(); + await apiManagementProductTag.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -110,10 +110,10 @@ public async Task Update_ApiManagementCreateProductTag() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteProductTag() + public async Task GetEntityStateByProduct_ApiManagementHeadProductTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProductTag.json - // this example is just showing the usage of "Tag_DetachFromProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadProductTag.json + // this example is just showing the usage of "Tag_GetEntityStateByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,15 +125,15 @@ public async Task Delete_ApiManagementDeleteProductTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "59d5b28d1f7fab116c282650"; - string tagId = "59d5b28e1f7fab116402044e"; + string productId = "59306a29e4bbd510dc24e5f8"; + string tagId = "59306a29e4bbd510dc24e5f9"; ResourceIdentifier apiManagementProductTagResourceId = ApiManagementProductTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId, tagId); ApiManagementProductTagResource apiManagementProductTag = client.GetApiManagementProductTagResource(apiManagementProductTagResourceId); // invoke the operation - await apiManagementProductTag.DeleteAsync(WaitUntil.Completed); + bool result = await apiManagementProductTag.GetEntityStateByProductAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementServiceCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementServiceCollection.cs index e7484a41781b4..44c680d62d861 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementServiceCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementServiceCollection.cs @@ -44,41 +44,35 @@ public async Task CreateOrUpdate_ApiManagementCreateMultiRegionServiceWithCustom string serviceName = "apimService1"; ApiManagementServiceData data = new ApiManagementServiceData(new AzureLocation("West US"), new ApiManagementServiceSkuProperties(ApiManagementServiceSkuType.Premium, 1), "apim@autorestsdk.com", "autorestsdk") { - HostnameConfigurations = -{ -new HostnameConfiguration(HostnameType.Proxy,"gateway1.msitesting.net") + HostnameConfigurations = {new HostnameConfiguration(HostnameType.Proxy, "gateway1.msitesting.net") { EncodedCertificate = "****** Base 64 Encoded Certificate ************", CertificatePassword = "Password", IsDefaultSslBindingEnabled = true, -},new HostnameConfiguration(HostnameType.Management,"mgmt.msitesting.net") +}, new HostnameConfiguration(HostnameType.Management, "mgmt.msitesting.net") { EncodedCertificate = "****** Base 64 Encoded Certificate ************", CertificatePassword = "Password", -},new HostnameConfiguration(HostnameType.Portal,"portal1.msitesting.net") +}, new HostnameConfiguration(HostnameType.Portal, "portal1.msitesting.net") { EncodedCertificate = "****** Base 64 Encoded Certificate ************", CertificatePassword = "Password", -},new HostnameConfiguration(HostnameType.ConfigurationApi,"configuration-api.msitesting.net") +}, new HostnameConfiguration(HostnameType.ConfigurationApi, "configuration-api.msitesting.net") { EncodedCertificate = "****** Base 64 Encoded Certificate ************", CertificatePassword = "Password", -} -}, - AdditionalLocations = -{ -new AdditionalLocation(new AzureLocation("East US"),new ApiManagementServiceSkuProperties(ApiManagementServiceSkuType.Premium,1)) +}}, + AdditionalLocations = {new AdditionalLocation(new AzureLocation("East US"), new ApiManagementServiceSkuProperties(ApiManagementServiceSkuType.Premium, 1)) { DisableGateway = true, -} -}, +}}, VirtualNetworkType = VirtualNetworkType.None, MinApiVersion = "2019-01-01", Tags = { ["tag1"] = "value1", ["tag2"] = "value2", -["tag3"] = "value3", +["tag3"] = "value3" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -120,7 +114,7 @@ public async Task CreateOrUpdate_ApiManagementCreateService() Tags = { ["Name"] = "Contoso", -["Test"] = "User", +["Test"] = "User" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -164,7 +158,7 @@ public async Task CreateOrUpdate_ApiManagementCreateServiceHavingMsi() { ["tag1"] = "value1", ["tag2"] = "value2", -["tag3"] = "value3", +["tag3"] = "value3" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -203,12 +197,9 @@ public async Task CreateOrUpdate_ApiManagementCreateServiceInVnetWithPublicIP() string serviceName = "apimService1"; ApiManagementServiceData data = new ApiManagementServiceData(new AzureLocation("East US 2 EUAP"), new ApiManagementServiceSkuProperties(ApiManagementServiceSkuType.Premium, 2), "apim@autorestsdk.com", "autorestsdk") { - Zones = -{ -"1","2" -}, + Zones = { "1", "2" }, PublicIPAddressId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.Network/publicIPAddresses/apimazvnet"), - VirtualNetworkConfiguration = new VirtualNetworkConfiguration() + VirtualNetworkConfiguration = new VirtualNetworkConfiguration { SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rgName/providers/Microsoft.Network/virtualNetworks/apimcus/subnets/tenant"), }, @@ -217,7 +208,7 @@ public async Task CreateOrUpdate_ApiManagementCreateServiceInVnetWithPublicIP() { ["tag1"] = "value1", ["tag2"] = "value2", -["tag3"] = "value3", +["tag3"] = "value3" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -256,15 +247,12 @@ public async Task CreateOrUpdate_ApiManagementCreateServiceInZones() string serviceName = "apimService1"; ApiManagementServiceData data = new ApiManagementServiceData(new AzureLocation("North europe"), new ApiManagementServiceSkuProperties(ApiManagementServiceSkuType.Premium, 2), "apim@autorestsdk.com", "autorestsdk") { - Zones = -{ -"1","2" -}, + Zones = { "1", "2" }, Tags = { ["tag1"] = "value1", ["tag2"] = "value2", -["tag3"] = "value3", +["tag3"] = "value3" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -307,37 +295,34 @@ public async Task CreateOrUpdate_ApiManagementCreateServiceWithCustomHostnameKey { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() }, }, - HostnameConfigurations = -{ -new HostnameConfiguration(HostnameType.Proxy,"gateway1.msitesting.net") + HostnameConfigurations = {new HostnameConfiguration(HostnameType.Proxy, "gateway1.msitesting.net") { KeyVaultSecretUri = new Uri("https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert"), IdentityClientId = "329419bc-adec-4dce-9568-25a6d486e468", IsDefaultSslBindingEnabled = true, -},new HostnameConfiguration(HostnameType.Management,"mgmt.msitesting.net") +}, new HostnameConfiguration(HostnameType.Management, "mgmt.msitesting.net") { KeyVaultSecretUri = new Uri("https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert"), IdentityClientId = "329419bc-adec-4dce-9568-25a6d486e468", -},new HostnameConfiguration(HostnameType.Portal,"portal1.msitesting.net") +}, new HostnameConfiguration(HostnameType.Portal, "portal1.msitesting.net") { KeyVaultSecretUri = new Uri("https://rpbvtkeyvaultintegration.vault.azure.net/secrets/msitestingCert"), IdentityClientId = "329419bc-adec-4dce-9568-25a6d486e468", -},new HostnameConfiguration(HostnameType.ConfigurationApi,"configuration-api.msitesting.net") +}, new HostnameConfiguration(HostnameType.ConfigurationApi, "configuration-api.msitesting.net") { EncodedCertificate = "****** Base 64 Encoded Certificate ************", CertificatePassword = "Password", -} -}, +}}, VirtualNetworkType = VirtualNetworkType.None, MinApiVersion = "2019-01-01", Tags = { ["tag1"] = "value1", ["tag2"] = "value2", -["tag3"] = "value3", +["tag3"] = "value3" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -380,7 +365,7 @@ public async Task CreateOrUpdate_ApiManagementCreateServiceWithDeveloperPortal() Tags = { ["Name"] = "Contoso", -["Test"] = "User", +["Test"] = "User" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -424,7 +409,7 @@ public async Task CreateOrUpdate_ApiManagementCreateServiceWithNatGatewayEnabled { ["tag1"] = "value1", ["tag2"] = "value2", -["tag3"] = "value3", +["tag3"] = "value3" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -463,19 +448,16 @@ public async Task CreateOrUpdate_ApiManagementCreateServiceWithSystemCertificate string serviceName = "apimService1"; ApiManagementServiceData data = new ApiManagementServiceData(new AzureLocation("Central US"), new ApiManagementServiceSkuProperties(ApiManagementServiceSkuType.Basic, 1), "apim@autorestsdk.com", "autorestsdk") { - Certificates = -{ -new CertificateConfiguration(CertificateConfigurationStoreName.CertificateAuthority) + Certificates = {new CertificateConfiguration(CertificateConfigurationStoreName.CertificateAuthority) { EncodedCertificate = "*******Base64 encoded Certificate******************", CertificatePassword = "Password", -} -}, +}}, Tags = { ["tag1"] = "value1", ["tag2"] = "value2", -["tag3"] = "value3", +["tag3"] = "value3" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -518,14 +500,14 @@ public async Task CreateOrUpdate_ApiManagementCreateServiceWithUserAssignedIdent { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/apimService1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/apimService1")] = new UserAssignedIdentity() }, }, Tags = { ["tag1"] = "value1", ["tag2"] = "value2", -["tag3"] = "value3", +["tag3"] = "value3" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -569,7 +551,7 @@ public async Task CreateOrUpdate_ApiManagementCreateServiceWithoutLegacyConfigur { ["tag1"] = "value1", ["tag2"] = "value2", -["tag3"] = "value3", +["tag3"] = "value3" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -655,9 +637,9 @@ public async Task Get_ApiManagementServiceGetMultiRegionInternalVnet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementServiceGetMultiRegionInternalVnet() + public async Task Get_ApiManagementServiceGetService() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetMultiRegionInternalVnet.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetService.json // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -677,16 +659,20 @@ public async Task Exists_ApiManagementServiceGetMultiRegionInternalVnet() // invoke the operation string serviceName = "apimService1"; - bool result = await collection.ExistsAsync(serviceName); + ApiManagementServiceResource result = await collection.GetAsync(serviceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementServiceGetMultiRegionInternalVnet() + public async Task Get_ApiManagementServiceGetServiceHavingMsi() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetMultiRegionInternalVnet.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetServiceHavingMsi.json // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -706,29 +692,21 @@ public async Task GetIfExists_ApiManagementServiceGetMultiRegionInternalVnet() // invoke the operation string serviceName = "apimService1"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - ApiManagementServiceResource result = response.HasValue ? response.Value : null; + ApiManagementServiceResource result = await collection.GetAsync(serviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementServiceGetService() + public async Task GetAll_ApiManagementListServiceBySubscriptionAndResourceGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetService.json - // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListServiceBySubscriptionAndResourceGroup.json + // this example is just showing the usage of "ApiManagementService_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -745,22 +723,24 @@ public async Task Get_ApiManagementServiceGetService() // get the collection of this ApiManagementServiceResource ApiManagementServiceCollection collection = resourceGroupResource.GetApiManagementServices(); - // invoke the operation - string serviceName = "apimService1"; - ApiManagementServiceResource result = await collection.GetAsync(serviceName); + // invoke the operation and iterate over the result + await foreach (ApiManagementServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementServiceGetService() + public async Task Exists_ApiManagementServiceGetMultiRegionInternalVnet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetService.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetMultiRegionInternalVnet.json // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -787,7 +767,7 @@ public async Task Exists_ApiManagementServiceGetService() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementServiceGetService() + public async Task Exists_ApiManagementServiceGetService() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetService.json // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. @@ -809,26 +789,14 @@ public async Task GetIfExists_ApiManagementServiceGetService() // invoke the operation string serviceName = "apimService1"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - ApiManagementServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementServiceGetServiceHavingMsi() + public async Task Exists_ApiManagementServiceGetServiceHavingMsi() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetServiceHavingMsi.json // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. @@ -850,20 +818,16 @@ public async Task Get_ApiManagementServiceGetServiceHavingMsi() // invoke the operation string serviceName = "apimService1"; - ApiManagementServiceResource result = await collection.GetAsync(serviceName); + bool result = await collection.ExistsAsync(serviceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementServiceGetServiceHavingMsi() + public async Task GetIfExists_ApiManagementServiceGetMultiRegionInternalVnet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetServiceHavingMsi.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetMultiRegionInternalVnet.json // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -883,16 +847,28 @@ public async Task Exists_ApiManagementServiceGetServiceHavingMsi() // invoke the operation string serviceName = "apimService1"; - bool result = await collection.ExistsAsync(serviceName); + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + ApiManagementServiceResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementServiceGetServiceHavingMsi() + public async Task GetIfExists_ApiManagementServiceGetService() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetServiceHavingMsi.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetService.json // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -931,10 +907,10 @@ public async Task GetIfExists_ApiManagementServiceGetServiceHavingMsi() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListServiceBySubscriptionAndResourceGroup() + public async Task GetIfExists_ApiManagementServiceGetServiceHavingMsi() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListServiceBySubscriptionAndResourceGroup.json - // this example is just showing the usage of "ApiManagementService_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetServiceHavingMsi.json + // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -951,17 +927,23 @@ public async Task GetAll_ApiManagementListServiceBySubscriptionAndResourceGroup( // get the collection of this ApiManagementServiceResource ApiManagementServiceCollection collection = resourceGroupResource.GetApiManagementServices(); - // invoke the operation and iterate over the result - await foreach (ApiManagementServiceResource item in collection.GetAllAsync()) + // invoke the operation + string serviceName = "apimService1"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + ApiManagementServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = item.Data; + ApiManagementServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementServiceResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementServiceResource.cs index c00431b6d8326..def7ca59e0bee 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementServiceResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementServiceResource.cs @@ -11,13 +11,253 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ApiManagement.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ApiManagement.Samples { public partial class Sample_ApiManagementServiceResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_ApiManagementServiceGetMultiRegionInternalVnet() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetMultiRegionInternalVnet.json + // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // invoke the operation + ApiManagementServiceResource result = await apiManagementService.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_ApiManagementServiceGetService() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetService.json + // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // invoke the operation + ApiManagementServiceResource result = await apiManagementService.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_ApiManagementServiceGetServiceHavingMsi() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetServiceHavingMsi.json + // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // invoke the operation + ApiManagementServiceResource result = await apiManagementService.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ApiManagementServiceDeleteService() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceDeleteService.json + // this example is just showing the usage of "ApiManagementService_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // invoke the operation + await apiManagementService.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_ApiManagementUpdateServiceDisableTls10() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdateServiceDisableTls10.json + // this example is just showing the usage of "ApiManagementService_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // invoke the operation + ApiManagementServicePatch patch = new ApiManagementServicePatch + { + CustomProperties = +{ +["Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10"] = "false" +}, + }; + ArmOperation lro = await apiManagementService.UpdateAsync(WaitUntil.Completed, patch); + ApiManagementServiceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_ApiManagementUpdateServicePublisherDetails() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdateServicePublisherDetails.json + // this example is just showing the usage of "ApiManagementService_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // invoke the operation + ApiManagementServicePatch patch = new ApiManagementServicePatch + { + PublisherEmail = "foobar@live.com", + PublisherName = "Contoso Vnext", + }; + ArmOperation lro = await apiManagementService.UpdateAsync(WaitUntil.Completed, patch); + ApiManagementServiceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_ApiManagementUpdateServiceToNewVnetAndAvailabilityZones() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdateServiceToNewVnetAndAZs.json + // this example is just showing the usage of "ApiManagementService_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementServiceResource created on azure + // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); + ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); + + // invoke the operation + ApiManagementServicePatch patch = new ApiManagementServicePatch + { + Sku = new ApiManagementServiceSkuProperties(ApiManagementServiceSkuType.Premium, 3), + Zones = { "1", "2", "3" }, + PublicIPAddressId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/publicip-apim-japan-east"), + VirtualNetworkConfiguration = new VirtualNetworkConfiguration + { + SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-apim-japaneast/subnets/apim2"), + }, + AdditionalLocations = {new AdditionalLocation(new AzureLocation("Australia East"), new ApiManagementServiceSkuProperties(ApiManagementServiceSkuType.Premium, 3)) +{ +Zones = {"1", "2", "3"}, +PublicIPAddressId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/apim-australia-east-publicip"), +VirtualNetworkConfiguration = new VirtualNetworkConfiguration +{ +SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/apimaeavnet/subnets/default"), +}, +}}, + VirtualNetworkType = VirtualNetworkType.External, + }; + ArmOperation lro = await apiManagementService.UpdateAsync(WaitUntil.Completed, patch); + ApiManagementServiceResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetApisByTags_ApiManagementListApisByTags() @@ -71,17 +311,11 @@ public async Task PerformConnectivityCheckAsync_HTTPConnectivityCheck() ConnectivityCheckContent content = new ConnectivityCheckContent(new ConnectivityCheckRequestSource("northeurope"), new ConnectivityCheckRequestDestination("https://microsoft.com", 3306L)) { Protocol = ConnectivityCheckProtocol.Https, - ProtocolHttpConfiguration = new ConnectivityCheckRequestHttpConfiguration() + ProtocolHttpConfiguration = new ConnectivityCheckRequestHttpConfiguration { Method = HttpMethodConfiguration.Get, - ValidStatusCodes = -{ -200L,204L -}, - Headers = -{ -new HttpHeaderConfiguration("Authorization","Bearer myPreciousToken") -}, + ValidStatusCodes = { 200L, 204L }, + Headers = { new HttpHeaderConfiguration("Authorization", "Bearer myPreciousToken") }, }, }; ArmOperation lro = await apiManagementService.PerformConnectivityCheckAsyncAsync(WaitUntil.Completed, content); @@ -578,10 +812,10 @@ public async Task Backup_ApiManagementBackupWithUserAssignedManagedIdentity() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementUpdateServiceDisableTls10() + public async Task MigrateToStv2_ApiManagementMigrateService() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdateServiceDisableTls10.json - // this example is just showing the usage of "ApiManagementService_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceMigrateToStv2.json + // this example is just showing the usage of "ApiManagementService_MigrateToStv2" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -597,14 +831,11 @@ public async Task Update_ApiManagementUpdateServiceDisableTls10() ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); // invoke the operation - ApiManagementServicePatch patch = new ApiManagementServicePatch() + MigrateToStv2Contract migrateToStv2Contract = new MigrateToStv2Contract { - CustomProperties = -{ -["Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls10"] = "false", -}, + Mode = MigrateToStv2Mode.PreserveIP, }; - ArmOperation lro = await apiManagementService.UpdateAsync(WaitUntil.Completed, patch); + ArmOperation lro = await apiManagementService.MigrateToStv2Async(WaitUntil.Completed, migrateToStv2Contract: migrateToStv2Contract); ApiManagementServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -616,288 +847,10 @@ public async Task Update_ApiManagementUpdateServiceDisableTls10() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementUpdateServicePublisherDetails() + public async Task GetSsoToken_ApiManagementServiceGetSsoToken() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdateServicePublisherDetails.json - // this example is just showing the usage of "ApiManagementService_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // invoke the operation - ApiManagementServicePatch patch = new ApiManagementServicePatch() - { - PublisherEmail = "foobar@live.com", - PublisherName = "Contoso Vnext", - }; - ArmOperation lro = await apiManagementService.UpdateAsync(WaitUntil.Completed, patch); - ApiManagementServiceResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementUpdateServiceToNewVnetAndAvailabilityZones() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdateServiceToNewVnetAndAZs.json - // this example is just showing the usage of "ApiManagementService_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // invoke the operation - ApiManagementServicePatch patch = new ApiManagementServicePatch() - { - Sku = new ApiManagementServiceSkuProperties(ApiManagementServiceSkuType.Premium, 3), - Zones = -{ -"1","2","3" -}, - PublicIPAddressId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/publicip-apim-japan-east"), - VirtualNetworkConfiguration = new VirtualNetworkConfiguration() - { - SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet-apim-japaneast/subnets/apim2"), - }, - AdditionalLocations = -{ -new AdditionalLocation(new AzureLocation("Australia East"),new ApiManagementServiceSkuProperties(ApiManagementServiceSkuType.Premium,3)) -{ -Zones = -{ -"1","2","3" -}, -PublicIPAddressId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/apim-australia-east-publicip"), -VirtualNetworkConfiguration = new VirtualNetworkConfiguration() -{ -SubnetResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/apimaeavnet/subnets/default"), -}, -} -}, - VirtualNetworkType = VirtualNetworkType.External, - }; - ArmOperation lro = await apiManagementService.UpdateAsync(WaitUntil.Completed, patch); - ApiManagementServiceResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementServiceGetMultiRegionInternalVnet() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetMultiRegionInternalVnet.json - // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // invoke the operation - ApiManagementServiceResource result = await apiManagementService.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementServiceGetService() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetService.json - // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // invoke the operation - ApiManagementServiceResource result = await apiManagementService.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementServiceGetServiceHavingMsi() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetServiceHavingMsi.json - // this example is just showing the usage of "ApiManagementService_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // invoke the operation - ApiManagementServiceResource result = await apiManagementService.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementServiceDeleteService() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceDeleteService.json - // this example is just showing the usage of "ApiManagementService_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // invoke the operation - await apiManagementService.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task MigrateToStv2_ApiManagementMigrateService() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceMigrateToStv2.json - // this example is just showing the usage of "ApiManagementService_MigrateToStv2" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementServiceResource created on azure - // for more information of creating ApiManagementServiceResource, please refer to the document of ApiManagementServiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - ResourceIdentifier apiManagementServiceResourceId = ApiManagementServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); - ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); - - // invoke the operation - MigrateToStv2Contract migrateToStv2Contract = new MigrateToStv2Contract() - { - Mode = MigrateToStv2Mode.PreserveIP, - }; - ArmOperation lro = await apiManagementService.MigrateToStv2Async(WaitUntil.Completed, migrateToStv2Contract: migrateToStv2Contract); - ApiManagementServiceResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApiManagementServices_ApiManagementListServiceBySubscription() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListServiceBySubscription.json - // this example is just showing the usage of "ApiManagementService_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ApiManagementServiceResource item in subscriptionResource.GetApiManagementServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSsoToken_ApiManagementServiceGetSsoToken() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetSsoToken.json - // this example is just showing the usage of "ApiManagementService_GetSsoToken" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetSsoToken.json + // this example is just showing the usage of "ApiManagementService_GetSsoToken" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -918,55 +871,6 @@ public async Task GetSsoToken_ApiManagementServiceGetSsoToken() Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckApiManagementServiceNameAvailability_ApiManagementServiceCheckNameAvailability() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceCheckNameAvailability.json - // this example is just showing the usage of "ApiManagementService_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - ApiManagementServiceNameAvailabilityContent content = new ApiManagementServiceNameAvailabilityContent("apimService1"); - ApiManagementServiceNameAvailabilityResult result = await subscriptionResource.CheckApiManagementServiceNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApiManagementServiceDomainOwnershipIdentifier_ApiManagementServiceGetDomainOwnershipIdentifier() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetDomainOwnershipIdentifier.json - // this example is just showing the usage of "ApiManagementService_GetDomainOwnershipIdentifier" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - ApiManagementServiceGetDomainOwnershipIdentifierResult result = await subscriptionResource.GetApiManagementServiceDomainOwnershipIdentifierAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task ApplyNetworkConfigurationUpdates_ApiManagementApplyNetworkConfigurationUpdates() @@ -988,7 +892,7 @@ public async Task ApplyNetworkConfigurationUpdates_ApiManagementApplyNetworkConf ApiManagementServiceResource apiManagementService = client.GetApiManagementServiceResource(apiManagementServiceResourceId); // invoke the operation - ApiManagementServiceApplyNetworkConfigurationContent content = new ApiManagementServiceApplyNetworkConfigurationContent() + ApiManagementServiceApplyNetworkConfigurationContent content = new ApiManagementServiceApplyNetworkConfigurationContent { Location = new AzureLocation("west us"), }; @@ -1227,7 +1131,7 @@ public async Task UpdateQuotaByCounterKeys_ApiManagementUpdateQuotaCounterKey() // invoke the operation and iterate over the result string quotaCounterKey = "ba"; - QuotaCounterValueUpdateContent content = new QuotaCounterValueUpdateContent() + QuotaCounterValueUpdateContent content = new QuotaCounterValueUpdateContent { CallsCount = 0, KbTransferred = 2.5630078125, @@ -1291,7 +1195,7 @@ public async Task UpdateQuotaByPeriodKey_ApiManagementUpdateQuotaCounterKeyByQuo // invoke the operation string quotaCounterKey = "ba"; string quotaPeriodKey = "0_P3Y6M4DT12H30M5S"; - QuotaCounterValueUpdateContent content = new QuotaCounterValueUpdateContent() + QuotaCounterValueUpdateContent content = new QuotaCounterValueUpdateContent { CallsCount = 0, KbTransferred = 0, @@ -1622,7 +1526,7 @@ public async Task DeployTenantConfiguration_ApiManagementTenantConfigurationDepl // invoke the operation ConfigurationName configurationName = ConfigurationName.Configuration; - ConfigurationDeployContent content = new ConfigurationDeployContent() + ConfigurationDeployContent content = new ConfigurationDeployContent { Branch = "master", }; @@ -1654,7 +1558,7 @@ public async Task SaveTenantConfiguration_ApiManagementTenantConfigurationSave() // invoke the operation ConfigurationName configurationName = ConfigurationName.Configuration; - ConfigurationSaveContent content = new ConfigurationSaveContent() + ConfigurationSaveContent content = new ConfigurationSaveContent { Branch = "master", }; @@ -1686,7 +1590,7 @@ public async Task ValidateTenantConfiguration_ApiManagementTenantConfigurationVa // invoke the operation ConfigurationName configurationName = ConfigurationName.Configuration; - ConfigurationDeployContent content = new ConfigurationDeployContent() + ConfigurationDeployContent content = new ConfigurationDeployContent { Branch = "master", }; diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementSubscriptionCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementSubscriptionCollection.cs index 0d016761dcffd..a71c7becc470d 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementSubscriptionCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementSubscriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListSubscriptions() + public async Task CreateOrUpdate_ApiManagementCreateSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListSubscriptions.json - // this example is just showing the usage of "Subscription_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateSubscription.json + // this example is just showing the usage of "Subscription_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,22 @@ public async Task GetAll_ApiManagementListSubscriptions() // get the collection of this ApiManagementSubscriptionResource ApiManagementSubscriptionCollection collection = apiManagementService.GetApiManagementSubscriptions(); - // invoke the operation and iterate over the result - await foreach (ApiManagementSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string sid = "testsub"; + ApiManagementSubscriptionCreateOrUpdateContent content = new ApiManagementSubscriptionCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + OwnerId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7", + Scope = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002", + DisplayName = "testsub", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sid, content); + ApiManagementSubscriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +93,10 @@ public async Task Get_ApiManagementGetSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetSubscription() + public async Task GetAll_ApiManagementListSubscriptions() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetSubscription.json - // this example is just showing the usage of "Subscription_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListSubscriptions.json + // this example is just showing the usage of "Subscription_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +114,22 @@ public async Task Exists_ApiManagementGetSubscription() // get the collection of this ApiManagementSubscriptionResource ApiManagementSubscriptionCollection collection = apiManagementService.GetApiManagementSubscriptions(); - // invoke the operation - string sid = "5931a769d8d14f0ad8ce13b8"; - bool result = await collection.ExistsAsync(sid); + // invoke the operation and iterate over the result + await foreach (ApiManagementSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetSubscription() + public async Task Exists_ApiManagementGetSubscription() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetSubscription.json // this example is just showing the usage of "Subscription_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +152,17 @@ public async Task GetIfExists_ApiManagementGetSubscription() // invoke the operation string sid = "5931a769d8d14f0ad8ce13b8"; - NullableResponse response = await collection.GetIfExistsAsync(sid); - ApiManagementSubscriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sid); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateSubscription() + public async Task GetIfExists_ApiManagementGetSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateSubscription.json - // this example is just showing the usage of "Subscription_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetSubscription.json + // this example is just showing the usage of "Subscription_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,21 +181,22 @@ public async Task CreateOrUpdate_ApiManagementCreateSubscription() ApiManagementSubscriptionCollection collection = apiManagementService.GetApiManagementSubscriptions(); // invoke the operation - string sid = "testsub"; - ApiManagementSubscriptionCreateOrUpdateContent content = new ApiManagementSubscriptionCreateOrUpdateContent() - { - OwnerId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7", - Scope = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/5600b59475ff190048060002", - DisplayName = "testsub", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sid, content); - ApiManagementSubscriptionResource result = lro.Value; + string sid = "5931a769d8d14f0ad8ce13b8"; + NullableResponse response = await collection.GetIfExistsAsync(sid); + ApiManagementSubscriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementSubscriptionResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementSubscriptionResource.cs index cefef2ddb806b..3ee35ffcccff5 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementSubscriptionResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementSubscriptionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementSubscriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadSubscription() + public async Task Get_ApiManagementGetSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadSubscription.json - // this example is just showing the usage of "Subscription_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetSubscription.json + // this example is just showing the usage of "Subscription_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadSubscription() ApiManagementSubscriptionResource apiManagementSubscription = client.GetApiManagementSubscriptionResource(apiManagementSubscriptionResourceId); // invoke the operation - bool result = await apiManagementSubscription.GetEntityTagAsync(); + ApiManagementSubscriptionResource result = await apiManagementSubscription.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetSubscription() + public async Task Delete_ApiManagementDeleteSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetSubscription.json - // this example is just showing the usage of "Subscription_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteSubscription.json + // this example is just showing the usage of "Subscription_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,15 @@ public async Task Get_ApiManagementGetSubscription() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string sid = "5931a769d8d14f0ad8ce13b8"; + string sid = "testsub"; ResourceIdentifier apiManagementSubscriptionResourceId = ApiManagementSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, sid); ApiManagementSubscriptionResource apiManagementSubscription = client.GetApiManagementSubscriptionResource(apiManagementSubscriptionResourceId); // invoke the operation - ApiManagementSubscriptionResource result = await apiManagementSubscription.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementSubscription.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateSubscription() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementSubscriptionPatch patch = new ApiManagementSubscriptionPatch() + ApiManagementSubscriptionPatch patch = new ApiManagementSubscriptionPatch { DisplayName = "testsub", }; @@ -112,10 +113,10 @@ public async Task Update_ApiManagementUpdateSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteSubscription() + public async Task RegeneratePrimaryKey_ApiManagementSubscriptionRegeneratePrimaryKey() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteSubscription.json - // this example is just showing the usage of "Subscription_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementSubscriptionRegeneratePrimaryKey.json + // this example is just showing the usage of "Subscription_RegeneratePrimaryKey" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,18 +133,17 @@ public async Task Delete_ApiManagementDeleteSubscription() ApiManagementSubscriptionResource apiManagementSubscription = client.GetApiManagementSubscriptionResource(apiManagementSubscriptionResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementSubscription.DeleteAsync(WaitUntil.Completed, ifMatch); + await apiManagementSubscription.RegeneratePrimaryKeyAsync(); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task RegeneratePrimaryKey_ApiManagementSubscriptionRegeneratePrimaryKey() + public async Task RegenerateSecondaryKey_ApiManagementSubscriptionRegenerateSecondaryKey() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementSubscriptionRegeneratePrimaryKey.json - // this example is just showing the usage of "Subscription_RegeneratePrimaryKey" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementSubscriptionRegenerateSecondaryKey.json + // this example is just showing the usage of "Subscription_RegenerateSecondaryKey" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -160,17 +160,17 @@ public async Task RegeneratePrimaryKey_ApiManagementSubscriptionRegeneratePrimar ApiManagementSubscriptionResource apiManagementSubscription = client.GetApiManagementSubscriptionResource(apiManagementSubscriptionResourceId); // invoke the operation - await apiManagementSubscription.RegeneratePrimaryKeyAsync(); + await apiManagementSubscription.RegenerateSecondaryKeyAsync(); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task RegenerateSecondaryKey_ApiManagementSubscriptionRegenerateSecondaryKey() + public async Task GetSecrets_ApiManagementSubscriptionListSecrets() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementSubscriptionRegenerateSecondaryKey.json - // this example is just showing the usage of "Subscription_RegenerateSecondaryKey" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementSubscriptionListSecrets.json + // this example is just showing the usage of "Subscription_ListSecrets" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,22 +182,22 @@ public async Task RegenerateSecondaryKey_ApiManagementSubscriptionRegenerateSeco string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string sid = "testsub"; + string sid = "5931a769d8d14f0ad8ce13b8"; ResourceIdentifier apiManagementSubscriptionResourceId = ApiManagementSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, sid); ApiManagementSubscriptionResource apiManagementSubscription = client.GetApiManagementSubscriptionResource(apiManagementSubscriptionResourceId); // invoke the operation - await apiManagementSubscription.RegenerateSecondaryKeyAsync(); + SubscriptionKeysContract result = await apiManagementSubscription.GetSecretsAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSecrets_ApiManagementSubscriptionListSecrets() + public async Task GetEntityTag_ApiManagementHeadSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementSubscriptionListSecrets.json - // this example is just showing the usage of "Subscription_ListSecrets" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadSubscription.json + // this example is just showing the usage of "Subscription_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -214,7 +214,7 @@ public async Task GetSecrets_ApiManagementSubscriptionListSecrets() ApiManagementSubscriptionResource apiManagementSubscription = client.GetApiManagementSubscriptionResource(apiManagementSubscriptionResourceId); // invoke the operation - SubscriptionKeysContract result = await apiManagementSubscription.GetSecretsAsync(); + bool result = await apiManagementSubscription.GetEntityTagAsync(); Console.WriteLine($"Succeeded: {result}"); } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTagCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTagCollection.cs index 082c9af7466bb..bebb9b2cee086 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTagCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTagCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementTagCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListTags() + public async Task CreateOrUpdate_ApiManagementCreateTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTags.json - // this example is just showing the usage of "Tag_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTag.json + // this example is just showing the usage of "Tag_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ApiManagementListTags() // get the collection of this ApiManagementTagResource ApiManagementTagCollection collection = apiManagementService.GetApiManagementTags(); - // invoke the operation and iterate over the result - await foreach (ApiManagementTagResource item in collection.GetAllAsync()) + // invoke the operation + string tagId = "tagId1"; + ApiManagementTagCreateOrUpdateContent content = new ApiManagementTagCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "tag1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagId, content); + ApiManagementTagResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_ApiManagementGetTag() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetTag() + public async Task GetAll_ApiManagementListTags() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTag.json - // this example is just showing the usage of "Tag_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTags.json + // this example is just showing the usage of "Tag_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_ApiManagementGetTag() // get the collection of this ApiManagementTagResource ApiManagementTagCollection collection = apiManagementService.GetApiManagementTags(); - // invoke the operation - string tagId = "59306a29e4bbd510dc24e5f9"; - bool result = await collection.ExistsAsync(tagId); + // invoke the operation and iterate over the result + await foreach (ApiManagementTagResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetTag() + public async Task Exists_ApiManagementGetTag() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTag.json // this example is just showing the usage of "Tag_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_ApiManagementGetTag() // invoke the operation string tagId = "59306a29e4bbd510dc24e5f9"; - NullableResponse response = await collection.GetIfExistsAsync(tagId); - ApiManagementTagResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tagId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateTag() + public async Task GetIfExists_ApiManagementGetTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTag.json - // this example is just showing the usage of "Tag_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTag.json + // this example is just showing the usage of "Tag_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,19 +179,22 @@ public async Task CreateOrUpdate_ApiManagementCreateTag() ApiManagementTagCollection collection = apiManagementService.GetApiManagementTags(); // invoke the operation - string tagId = "tagId1"; - ApiManagementTagCreateOrUpdateContent content = new ApiManagementTagCreateOrUpdateContent() - { - DisplayName = "tag1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagId, content); - ApiManagementTagResource result = lro.Value; + string tagId = "59306a29e4bbd510dc24e5f9"; + NullableResponse response = await collection.GetIfExistsAsync(tagId); + ApiManagementTagResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTagResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTagResource.cs index 3457166146125..0642ac7422f0e 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTagResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTagResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementTagResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityState_ApiManagementHeadTag() + public async Task Get_ApiManagementGetTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadTag.json - // this example is just showing the usage of "Tag_GetEntityState" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTag.json + // this example is just showing the usage of "Tag_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityState_ApiManagementHeadTag() ApiManagementTagResource apiManagementTag = client.GetApiManagementTagResource(apiManagementTagResourceId); // invoke the operation - bool result = await apiManagementTag.GetEntityStateAsync(); + ApiManagementTagResource result = await apiManagementTag.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetTag() + public async Task Delete_ApiManagementDeleteTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTag.json - // this example is just showing the usage of "Tag_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteTag.json + // this example is just showing the usage of "Tag_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,15 @@ public async Task Get_ApiManagementGetTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string tagId = "59306a29e4bbd510dc24e5f9"; + string tagId = "tagId1"; ResourceIdentifier apiManagementTagResourceId = ApiManagementTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, tagId); ApiManagementTagResource apiManagementTag = client.GetApiManagementTagResource(apiManagementTagResourceId); // invoke the operation - ApiManagementTagResource result = await apiManagementTag.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementTag.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateTag() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementTagCreateOrUpdateContent content = new ApiManagementTagCreateOrUpdateContent() + ApiManagementTagCreateOrUpdateContent content = new ApiManagementTagCreateOrUpdateContent { DisplayName = "temp tag", }; @@ -112,10 +113,10 @@ public async Task Update_ApiManagementUpdateTag() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteTag() + public async Task GetEntityState_ApiManagementHeadTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteTag.json - // this example is just showing the usage of "Tag_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadTag.json + // this example is just showing the usage of "Tag_GetEntityState" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,15 +128,14 @@ public async Task Delete_ApiManagementDeleteTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string tagId = "tagId1"; + string tagId = "59306a29e4bbd510dc24e5f9"; ResourceIdentifier apiManagementTagResourceId = ApiManagementTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, tagId); ApiManagementTagResource apiManagementTag = client.GetApiManagementTagResource(apiManagementTagResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementTag.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiManagementTag.GetEntityStateAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTenantSettingCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTenantSettingCollection.cs index 8f32e54e444b7..ac8865675d60a 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTenantSettingCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementTenantSettingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementTenantSettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListTenantSettings() + public async Task Get_ApiManagementGetTenantSettings() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTenantSettings.json - // this example is just showing the usage of "TenantSettings_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTenantSettings.json + // this example is just showing the usage of "TenantSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ApiManagementListTenantSettings() // get the collection of this ApiManagementTenantSettingResource ApiManagementTenantSettingCollection collection = apiManagementService.GetApiManagementTenantSettings(); - // invoke the operation and iterate over the result - await foreach (ApiManagementTenantSettingResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementTenantSettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + SettingsType settingsType = SettingsType.Public; + ApiManagementTenantSettingResource result = await collection.GetAsync(settingsType); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementTenantSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetTenantSettings() + public async Task GetAll_ApiManagementListTenantSettings() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTenantSettings.json - // this example is just showing the usage of "TenantSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTenantSettings.json + // this example is just showing the usage of "TenantSettings_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,15 +73,17 @@ public async Task Get_ApiManagementGetTenantSettings() // get the collection of this ApiManagementTenantSettingResource ApiManagementTenantSettingCollection collection = apiManagementService.GetApiManagementTenantSettings(); - // invoke the operation - SettingsType settingsType = SettingsType.Public; - ApiManagementTenantSettingResource result = await collection.GetAsync(settingsType); + // invoke the operation and iterate over the result + await foreach (ApiManagementTenantSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementTenantSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementTenantSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserCollection.cs index 8b4d6bff1a0c2..8ef2956f2092e 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementUserCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListUsers() + public async Task CreateOrUpdate_ApiManagementCreateUser() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListUsers.json - // this example is just showing the usage of "User_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateUser.json + // this example is just showing the usage of "User_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_ApiManagementListUsers() // get the collection of this ApiManagementUserResource ApiManagementUserCollection collection = apiManagementService.GetApiManagementUsers(); - // invoke the operation and iterate over the result - await foreach (ApiManagementUserResource item in collection.GetAllAsync()) + // invoke the operation + string userId = "5931a75ae4bbd512288c680b"; + ApiManagementUserCreateOrUpdateContent content = new ApiManagementUserCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - UserContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Email = "foobar@outlook.com", + FirstName = "foo", + LastName = "bar", + Confirmation = ConfirmationEmailType.SignUp, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, userId, content); + ApiManagementUserResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + UserContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +94,10 @@ public async Task Get_ApiManagementGetUser() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetUser() + public async Task GetAll_ApiManagementListUsers() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetUser.json - // this example is just showing the usage of "User_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListUsers.json + // this example is just showing the usage of "User_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +115,22 @@ public async Task Exists_ApiManagementGetUser() // get the collection of this ApiManagementUserResource ApiManagementUserCollection collection = apiManagementService.GetApiManagementUsers(); - // invoke the operation - string userId = "5931a75ae4bbd512a88c680b"; - bool result = await collection.ExistsAsync(userId); + // invoke the operation and iterate over the result + await foreach (ApiManagementUserResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + UserContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetUser() + public async Task Exists_ApiManagementGetUser() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetUser.json // this example is just showing the usage of "User_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +153,17 @@ public async Task GetIfExists_ApiManagementGetUser() // invoke the operation string userId = "5931a75ae4bbd512a88c680b"; - NullableResponse response = await collection.GetIfExistsAsync(userId); - ApiManagementUserResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(userId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - UserContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateUser() + public async Task GetIfExists_ApiManagementGetUser() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateUser.json - // this example is just showing the usage of "User_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetUser.json + // this example is just showing the usage of "User_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,22 +182,22 @@ public async Task CreateOrUpdate_ApiManagementCreateUser() ApiManagementUserCollection collection = apiManagementService.GetApiManagementUsers(); // invoke the operation - string userId = "5931a75ae4bbd512288c680b"; - ApiManagementUserCreateOrUpdateContent content = new ApiManagementUserCreateOrUpdateContent() - { - Email = "foobar@outlook.com", - FirstName = "foo", - LastName = "bar", - Confirmation = ConfirmationEmailType.SignUp, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, userId, content); - ApiManagementUserResource result = lro.Value; + string userId = "5931a75ae4bbd512a88c680b"; + NullableResponse response = await collection.GetIfExistsAsync(userId); + ApiManagementUserResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - UserContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + UserContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserResource.cs index 8bf0e521bc829..3aa9a9bf66241 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiManagementUserResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadUser() + public async Task Get_ApiManagementGetUser() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadUser.json - // this example is just showing the usage of "User_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetUser.json + // this example is just showing the usage of "User_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadUser() ApiManagementUserResource apiManagementUser = client.GetApiManagementUserResource(apiManagementUserResourceId); // invoke the operation - bool result = await apiManagementUser.GetEntityTagAsync(); + ApiManagementUserResource result = await apiManagementUser.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + UserContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetUser() + public async Task Delete_ApiManagementDeleteUser() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetUser.json - // this example is just showing the usage of "User_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteUser.json + // this example is just showing the usage of "User_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,15 @@ public async Task Get_ApiManagementGetUser() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string userId = "5931a75ae4bbd512a88c680b"; + string userId = "5931a75ae4bbd512288c680b"; ResourceIdentifier apiManagementUserResourceId = ApiManagementUserResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, userId); ApiManagementUserResource apiManagementUser = client.GetApiManagementUserResource(apiManagementUserResourceId); // invoke the operation - ApiManagementUserResource result = await apiManagementUser.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiManagementUser.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - UserContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateUser() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementUserPatch patch = new ApiManagementUserPatch() + ApiManagementUserPatch patch = new ApiManagementUserPatch { Email = "foobar@outlook.com", FirstName = "foo", @@ -112,34 +113,6 @@ public async Task Update_ApiManagementUpdateUser() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteUser() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteUser.json - // this example is just showing the usage of "User_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApiManagementUserResource created on azure - // for more information of creating ApiManagementUserResource, please refer to the document of ApiManagementUserResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - string userId = "5931a75ae4bbd512288c680b"; - ResourceIdentifier apiManagementUserResourceId = ApiManagementUserResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, userId); - ApiManagementUserResource apiManagementUser = client.GetApiManagementUserResource(apiManagementUserResourceId); - - // invoke the operation - ETag ifMatch = new ETag("*"); - await apiManagementUser.DeleteAsync(WaitUntil.Completed, ifMatch); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GenerateSsoUri_ApiManagementUserGenerateSsoUrl() @@ -189,7 +162,7 @@ public async Task GetSharedAccessToken_ApiManagementUserToken() ApiManagementUserResource apiManagementUser = client.GetApiManagementUserResource(apiManagementUserResourceId); // invoke the operation - UserTokenContent content = new UserTokenContent() + UserTokenContent content = new UserTokenContent { KeyType = TokenGenerationUsedKeyType.Primary, ExpireOn = DateTimeOffset.Parse("2019-04-21T00:44:24.2845269Z"), @@ -255,5 +228,32 @@ public async Task SendUserConfirmationPassword_ApiManagementUserConfirmationPass Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEntityTag_ApiManagementHeadUser() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadUser.json + // this example is just showing the usage of "User_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ApiManagementUserResource created on azure + // for more information of creating ApiManagementUserResource, please refer to the document of ApiManagementUserResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + string userId = "5931a75ae4bbd512a88c680b"; + ResourceIdentifier apiManagementUserResourceId = ApiManagementUserResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, userId); + ApiManagementUserResource apiManagementUser = client.GetApiManagementUserResource(apiManagementUserResourceId); + + // invoke the operation + bool result = await apiManagementUser.GetEntityTagAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserSubscriptionCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserSubscriptionCollection.cs index 9323265b0372e..3ef0dffc125f2 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserSubscriptionCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiManagementUserSubscriptionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiManagementUserSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListUserSubscriptions() + public async Task Get_ApiManagementGetUserSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListUserSubscriptions.json - // this example is just showing the usage of "UserSubscription_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetUserSubscription.json + // this example is just showing the usage of "UserSubscription_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,32 +32,30 @@ public async Task GetAll_ApiManagementListUserSubscriptions() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string userId = "57681833a40f7eb6c49f6acf"; + string userId = "1"; ResourceIdentifier apiManagementUserResourceId = ApiManagementUserResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, userId); ApiManagementUserResource apiManagementUser = client.GetApiManagementUserResource(apiManagementUserResourceId); // get the collection of this ApiManagementUserSubscriptionResource ApiManagementUserSubscriptionCollection collection = apiManagementUser.GetApiManagementUserSubscriptions(); - // invoke the operation and iterate over the result - await foreach (ApiManagementUserSubscriptionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string sid = "5fa9b096f3df14003c070001"; + ApiManagementUserSubscriptionResource result = await collection.GetAsync(sid); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetUserSubscription() + public async Task GetAll_ApiManagementListUserSubscriptions() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetUserSubscription.json - // this example is just showing the usage of "UserSubscription_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListUserSubscriptions.json + // this example is just showing the usage of "UserSubscription_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,22 +67,24 @@ public async Task Get_ApiManagementGetUserSubscription() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string userId = "1"; + string userId = "57681833a40f7eb6c49f6acf"; ResourceIdentifier apiManagementUserResourceId = ApiManagementUserResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, userId); ApiManagementUserResource apiManagementUser = client.GetApiManagementUserResource(apiManagementUserResourceId); // get the collection of this ApiManagementUserSubscriptionResource ApiManagementUserSubscriptionCollection collection = apiManagementUser.GetApiManagementUserSubscriptions(); - // invoke the operation - string sid = "5fa9b096f3df14003c070001"; - ApiManagementUserSubscriptionResource result = await collection.GetAsync(sid); + // invoke the operation and iterate over the result + await foreach (ApiManagementUserSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationCollection.cs index 048675149ad68..346ff0cbed3a6 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiOperationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiOperations() + public async Task CreateOrUpdate_ApiManagementCreateApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiOperations.json - // this example is just showing the usage of "ApiOperation_ListByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiOperation.json + // this example is just showing the usage of "ApiOperation_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,24 +33,48 @@ public async Task GetAll_ApiManagementListApiOperations() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "PetStoreTemplate2"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiOperationResource ApiOperationCollection collection = api.GetApiOperations(); - // invoke the operation and iterate over the result - await foreach (ApiOperationResource item in collection.GetAllAsync()) + // invoke the operation + string operationId = "newoperations"; + ApiOperationData data = new ApiOperationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiOperationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TemplateParameters = { }, + Description = "This can only be done by the logged in user.", + Request = new RequestContract + { + Description = "Created user object", + QueryParameters = { }, + Headers = { }, + Representations = {new RepresentationContract("application/json") +{ +SchemaId = "592f6c1d0af5840ca8897f0c", +TypeName = "User", +}}, + }, + Responses = {new ResponseContract(200) +{ +Description = "successful operation", +Representations = {new RepresentationContract("application/xml"), new RepresentationContract("application/json")}, +Headers = {}, +}}, + DisplayName = "createUser2", + Method = "POST", + UriTemplate = "/user1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, operationId, data); + ApiOperationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,9 +114,9 @@ public async Task Get_ApiManagementGetApiOperation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiOperation() + public async Task Get_ApiManagementGetApiOperationPetStore() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperation.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPetStore.json // this example is just showing the usage of "ApiOperation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -105,7 +129,7 @@ public async Task Exists_ApiManagementGetApiOperation() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "swagger-petstore"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -113,18 +137,22 @@ public async Task Exists_ApiManagementGetApiOperation() ApiOperationCollection collection = api.GetApiOperations(); // invoke the operation - string operationId = "57d2ef278aa04f0ad01d6cdc"; - bool result = await collection.ExistsAsync(operationId); + string operationId = "loginUser"; + ApiOperationResource result = await collection.GetAsync(operationId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiOperation() + public async Task GetAll_ApiManagementListApiOperations() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperation.json - // this example is just showing the usage of "ApiOperation_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiOperations.json + // this example is just showing the usage of "ApiOperation_ListByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,30 +171,24 @@ public async Task GetIfExists_ApiManagementGetApiOperation() // get the collection of this ApiOperationResource ApiOperationCollection collection = api.GetApiOperations(); - // invoke the operation - string operationId = "57d2ef278aa04f0ad01d6cdc"; - NullableResponse response = await collection.GetIfExistsAsync(operationId); - ApiOperationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ApiOperationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApiOperationData resourceData = result.Data; + ApiOperationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiOperationPetStore() + public async Task Exists_ApiManagementGetApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPetStore.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperation.json // this example is just showing the usage of "ApiOperation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -179,7 +201,7 @@ public async Task Get_ApiManagementGetApiOperationPetStore() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "swagger-petstore"; + string apiId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -187,14 +209,10 @@ public async Task Get_ApiManagementGetApiOperationPetStore() ApiOperationCollection collection = api.GetApiOperations(); // invoke the operation - string operationId = "loginUser"; - ApiOperationResource result = await collection.GetAsync(operationId); + string operationId = "57d2ef278aa04f0ad01d6cdc"; + bool result = await collection.ExistsAsync(operationId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -230,9 +248,9 @@ public async Task Exists_ApiManagementGetApiOperationPetStore() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiOperationPetStore() + public async Task GetIfExists_ApiManagementGetApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPetStore.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperation.json // this example is just showing the usage of "ApiOperation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -245,7 +263,7 @@ public async Task GetIfExists_ApiManagementGetApiOperationPetStore() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "swagger-petstore"; + string apiId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -253,7 +271,7 @@ public async Task GetIfExists_ApiManagementGetApiOperationPetStore() ApiOperationCollection collection = api.GetApiOperations(); // invoke the operation - string operationId = "loginUser"; + string operationId = "57d2ef278aa04f0ad01d6cdc"; NullableResponse response = await collection.GetIfExistsAsync(operationId); ApiOperationResource result = response.HasValue ? response.Value : null; @@ -273,10 +291,10 @@ public async Task GetIfExists_ApiManagementGetApiOperationPetStore() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiOperation() + public async Task GetIfExists_ApiManagementGetApiOperationPetStore() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiOperation.json - // this example is just showing the usage of "ApiOperation_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPetStore.json + // this example is just showing the usage of "ApiOperation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -288,7 +306,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiOperation() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "PetStoreTemplate2"; + string apiId = "swagger-petstore"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -296,57 +314,22 @@ public async Task CreateOrUpdate_ApiManagementCreateApiOperation() ApiOperationCollection collection = api.GetApiOperations(); // invoke the operation - string operationId = "newoperations"; - ApiOperationData data = new ApiOperationData() - { - TemplateParameters = -{ -}, - Description = "This can only be done by the logged in user.", - Request = new RequestContract() - { - Description = "Created user object", - QueryParameters = -{ -}, - Headers = -{ -}, - Representations = -{ -new RepresentationContract("application/json") -{ -SchemaId = "592f6c1d0af5840ca8897f0c", -TypeName = "User", -} -}, - }, - Responses = -{ -new ResponseContract(200) -{ -Description = "successful operation", -Representations = -{ -new RepresentationContract("application/xml"),new RepresentationContract("application/json") -}, -Headers = -{ -}, -} -}, - DisplayName = "createUser2", - Method = "POST", - UriTemplate = "/user1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, operationId, data); - ApiOperationResource result = lro.Value; + string operationId = "loginUser"; + NullableResponse response = await collection.GetIfExistsAsync(operationId); + ApiOperationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationPolicyCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationPolicyCollection.cs index 4016b49bdca28..b66534e20fd24 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationPolicyCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiOperationPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiOperationPolicies() + public async Task CreateOrUpdate_ApiManagementCreateApiOperationPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiOperationPolicies.json - // this example is just showing the usage of "ApiOperationPolicy_ListByOperation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiOperationPolicy.json + // this example is just showing the usage of "ApiOperationPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,25 +33,30 @@ public async Task GetAll_ApiManagementListApiOperationPolicies() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "599e2953193c3c0bd0b3e2fa"; - string operationId = "599e29ab193c3c0bd0b3e2fb"; + string apiId = "5600b57e7e8880006a040001"; + string operationId = "5600b57e7e8880006a080001"; ResourceIdentifier apiOperationResourceId = ApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId); ApiOperationResource apiOperation = client.GetApiOperationResource(apiOperationResourceId); // get the collection of this ApiOperationPolicyResource ApiOperationPolicyCollection collection = apiOperation.GetApiOperationPolicies(); - // invoke the operation and iterate over the result - await foreach (ApiOperationPolicyResource item in collection.GetAllAsync()) + // invoke the operation + PolicyName policyId = PolicyName.Policy; + PolicyContractData data = new PolicyContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = " ", + Format = PolicyContentFormat.Xml, + }; + ETag? ifMatch = new ETag("*"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); + ApiOperationPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +97,10 @@ public async Task Get_ApiManagementGetApiOperationPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiOperationPolicy() + public async Task GetAll_ApiManagementListApiOperationPolicies() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPolicy.json - // this example is just showing the usage of "ApiOperationPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiOperationPolicies.json + // this example is just showing the usage of "ApiOperationPolicy_ListByOperation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,24 +112,30 @@ public async Task Exists_ApiManagementGetApiOperationPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b539c53f5b0062040001"; - string operationId = "5600b53ac53f5b0062080006"; + string apiId = "599e2953193c3c0bd0b3e2fa"; + string operationId = "599e29ab193c3c0bd0b3e2fb"; ResourceIdentifier apiOperationResourceId = ApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId); ApiOperationResource apiOperation = client.GetApiOperationResource(apiOperationResourceId); // get the collection of this ApiOperationPolicyResource ApiOperationPolicyCollection collection = apiOperation.GetApiOperationPolicies(); - // invoke the operation - PolicyName policyId = PolicyName.Policy; - bool result = await collection.ExistsAsync(policyId); + // invoke the operation and iterate over the result + await foreach (ApiOperationPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiOperationPolicy() + public async Task Exists_ApiManagementGetApiOperationPolicy() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPolicy.json // this example is just showing the usage of "ApiOperationPolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +160,17 @@ public async Task GetIfExists_ApiManagementGetApiOperationPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - NullableResponse response = await collection.GetIfExistsAsync(policyId); - ApiOperationPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiOperationPolicy() + public async Task GetIfExists_ApiManagementGetApiOperationPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiOperationPolicy.json - // this example is just showing the usage of "ApiOperationPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPolicy.json + // this example is just showing the usage of "ApiOperationPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,8 +182,8 @@ public async Task CreateOrUpdate_ApiManagementCreateApiOperationPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b57e7e8880006a040001"; - string operationId = "5600b57e7e8880006a080001"; + string apiId = "5600b539c53f5b0062040001"; + string operationId = "5600b53ac53f5b0062080006"; ResourceIdentifier apiOperationResourceId = ApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId); ApiOperationResource apiOperation = client.GetApiOperationResource(apiOperationResourceId); @@ -193,20 +192,21 @@ public async Task CreateOrUpdate_ApiManagementCreateApiOperationPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = " ", - Format = PolicyContentFormat.Xml, - }; - ETag? ifMatch = new ETag("*"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); - ApiOperationPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyId); + ApiOperationPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationPolicyResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationPolicyResource.cs index eb12475445709..33cf0083a5f41 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationPolicyResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiOperationPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiOperationPolicy() + public async Task Get_ApiManagementGetApiOperationPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiOperationPolicy.json - // this example is just showing the usage of "ApiOperationPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPolicy.json + // this example is just showing the usage of "ApiOperationPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,21 @@ public async Task GetEntityTag_ApiManagementHeadApiOperationPolicy() ApiOperationPolicyResource apiOperationPolicy = client.GetApiOperationPolicyResource(apiOperationPolicyResourceId); // invoke the operation - bool result = await apiOperationPolicy.GetEntityTagAsync(); + ApiOperationPolicyResource result = await apiOperationPolicy.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiOperationPolicy() + public async Task Delete_ApiManagementDeleteApiOperationPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPolicy.json - // this example is just showing the usage of "ApiOperationPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiOperationPolicy.json + // this example is just showing the usage of "ApiOperationPolicy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,20 +66,17 @@ public async Task Get_ApiManagementGetApiOperationPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b539c53f5b0062040001"; - string operationId = "5600b53ac53f5b0062080006"; + string apiId = "testapi"; + string operationId = "testoperation"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier apiOperationPolicyResourceId = ApiOperationPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId, policyId); ApiOperationPolicyResource apiOperationPolicy = client.GetApiOperationPolicyResource(apiOperationPolicyResourceId); // invoke the operation - ApiOperationPolicyResource result = await apiOperationPolicy.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiOperationPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -102,7 +103,7 @@ public async Task Update_ApiManagementCreateApiOperationPolicy() ApiOperationPolicyResource apiOperationPolicy = client.GetApiOperationPolicyResource(apiOperationPolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = " ", Format = PolicyContentFormat.Xml, @@ -120,10 +121,10 @@ public async Task Update_ApiManagementCreateApiOperationPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiOperationPolicy() + public async Task GetEntityTag_ApiManagementHeadApiOperationPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiOperationPolicy.json - // this example is just showing the usage of "ApiOperationPolicy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiOperationPolicy.json + // this example is just showing the usage of "ApiOperationPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,17 +136,16 @@ public async Task Delete_ApiManagementDeleteApiOperationPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "testapi"; - string operationId = "testoperation"; + string apiId = "5600b539c53f5b0062040001"; + string operationId = "5600b53ac53f5b0062080006"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier apiOperationPolicyResourceId = ApiOperationPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId, policyId); ApiOperationPolicyResource apiOperationPolicy = client.GetApiOperationPolicyResource(apiOperationPolicyResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiOperationPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiOperationPolicy.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationResource.cs index ce46e18a2c5b2..9cb68a230aa49 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiOperationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiOperation() + public async Task Get_ApiManagementGetApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiOperation.json - // this example is just showing the usage of "ApiOperation_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperation.json + // this example is just showing the usage of "ApiOperation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,16 +39,20 @@ public async Task GetEntityTag_ApiManagementHeadApiOperation() ApiOperationResource apiOperation = client.GetApiOperationResource(apiOperationResourceId); // invoke the operation - bool result = await apiOperation.GetEntityTagAsync(); + ApiOperationResource result = await apiOperation.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiOperation() + public async Task Get_ApiManagementGetApiOperationPetStore() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperation.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPetStore.json // this example is just showing the usage of "ApiOperation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -61,8 +65,8 @@ public async Task Get_ApiManagementGetApiOperation() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; - string operationId = "57d2ef278aa04f0ad01d6cdc"; + string apiId = "swagger-petstore"; + string operationId = "loginUser"; ResourceIdentifier apiOperationResourceId = ApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId); ApiOperationResource apiOperation = client.GetApiOperationResource(apiOperationResourceId); @@ -78,10 +82,10 @@ public async Task Get_ApiManagementGetApiOperation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiOperationPetStore() + public async Task Delete_ApiManagementDeleteApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationPetStore.json - // this example is just showing the usage of "ApiOperation_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiOperation.json + // this example is just showing the usage of "ApiOperation_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,19 +97,16 @@ public async Task Get_ApiManagementGetApiOperationPetStore() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "swagger-petstore"; - string operationId = "loginUser"; + string apiId = "57d2ef278aa04f0888cba3f3"; + string operationId = "57d2ef278aa04f0ad01d6cdc"; ResourceIdentifier apiOperationResourceId = ApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId); ApiOperationResource apiOperation = client.GetApiOperationResource(apiOperationResourceId); // invoke the operation - ApiOperationResource result = await apiOperation.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiOperation.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -132,49 +133,30 @@ public async Task Update_ApiManagementUpdateApiOperation() // invoke the operation ETag ifMatch = new ETag("*"); - ApiOperationPatch patch = new ApiOperationPatch() + ApiOperationPatch patch = new ApiOperationPatch { - TemplateParameters = -{ -}, - Request = new RequestContract() + TemplateParameters = { }, + Request = new RequestContract { - QueryParameters = -{ -new ParameterContract("param1","string") + QueryParameters = {new ParameterContract("param1", "string") { Description = "A sample parameter that is required and has a default value of \"sample\".", DefaultValue = "sample", IsRequired = true, -Values = -{ -"sample" -}, -} -}, +Values = {"sample"}, +}}, }, - Responses = -{ -new ResponseContract(200) + Responses = {new ResponseContract(200) { Description = "Returned in all cases.", -Representations = -{ -}, -Headers = -{ -}, -},new ResponseContract(500) +Representations = {}, +Headers = {}, +}, new ResponseContract(500) { Description = "Server Error.", -Representations = -{ -}, -Headers = -{ -}, -} -}, +Representations = {}, +Headers = {}, +}}, DisplayName = "Retrieve resource", Method = "GET", UriTemplate = "/resource", @@ -190,10 +172,10 @@ public async Task Update_ApiManagementUpdateApiOperation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiOperation() + public async Task GetEntityTag_ApiManagementHeadApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiOperation.json - // this example is just showing the usage of "ApiOperation_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiOperation.json + // this example is just showing the usage of "ApiOperation_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -211,10 +193,9 @@ public async Task Delete_ApiManagementDeleteApiOperation() ApiOperationResource apiOperation = client.GetApiOperationResource(apiOperationResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiOperation.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiOperation.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationTagCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationTagCollection.cs index b4f130307390d..0294dde6a0bf7 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationTagCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationTagCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiOperationTagCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiOperationTags() + public async Task CreateOrUpdate_ApiManagementCreateApiOperationTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiOperationTags.json - // this example is just showing the usage of "Tag_ListByOperation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiOperationTag.json + // this example is just showing the usage of "Tag_AssignToOperation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,25 +32,24 @@ public async Task GetAll_ApiManagementListApiOperationTags() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; - string operationId = "57d2ef278aa04f0888cba3f6"; + string apiId = "5931a75ae4bbd512a88c680b"; + string operationId = "5931a75ae4bbd512a88c680a"; ResourceIdentifier apiOperationResourceId = ApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId); ApiOperationResource apiOperation = client.GetApiOperationResource(apiOperationResourceId); // get the collection of this ApiOperationTagResource ApiOperationTagCollection collection = apiOperation.GetApiOperationTags(); - // invoke the operation and iterate over the result - await foreach (ApiOperationTagResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string tagId = "tagId1"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagId); + ApiOperationTagResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +90,10 @@ public async Task Get_ApiManagementGetApiOperationTag() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiOperationTag() + public async Task GetAll_ApiManagementListApiOperationTags() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationTag.json - // this example is just showing the usage of "Tag_GetByOperation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiOperationTags.json + // this example is just showing the usage of "Tag_ListByOperation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,24 +105,30 @@ public async Task Exists_ApiManagementGetApiOperationTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d6bb8f1f7fab13dc67ec9b"; - string operationId = "59d6bb8f1f7fab13dc67ec9a"; + string apiId = "57d2ef278aa04f0888cba3f3"; + string operationId = "57d2ef278aa04f0888cba3f6"; ResourceIdentifier apiOperationResourceId = ApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId); ApiOperationResource apiOperation = client.GetApiOperationResource(apiOperationResourceId); // get the collection of this ApiOperationTagResource ApiOperationTagCollection collection = apiOperation.GetApiOperationTags(); - // invoke the operation - string tagId = "59306a29e4bbd510dc24e5f9"; - bool result = await collection.ExistsAsync(tagId); + // invoke the operation and iterate over the result + await foreach (ApiOperationTagResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiOperationTag() + public async Task Exists_ApiManagementGetApiOperationTag() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationTag.json // this example is just showing the usage of "Tag_GetByOperation" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +153,17 @@ public async Task GetIfExists_ApiManagementGetApiOperationTag() // invoke the operation string tagId = "59306a29e4bbd510dc24e5f9"; - NullableResponse response = await collection.GetIfExistsAsync(tagId); - ApiOperationTagResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tagId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiOperationTag() + public async Task GetIfExists_ApiManagementGetApiOperationTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiOperationTag.json - // this example is just showing the usage of "Tag_AssignToOperation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationTag.json + // this example is just showing the usage of "Tag_GetByOperation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,8 +175,8 @@ public async Task CreateOrUpdate_ApiManagementCreateApiOperationTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5931a75ae4bbd512a88c680b"; - string operationId = "5931a75ae4bbd512a88c680a"; + string apiId = "59d6bb8f1f7fab13dc67ec9b"; + string operationId = "59d6bb8f1f7fab13dc67ec9a"; ResourceIdentifier apiOperationResourceId = ApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId); ApiOperationResource apiOperation = client.GetApiOperationResource(apiOperationResourceId); @@ -191,15 +184,22 @@ public async Task CreateOrUpdate_ApiManagementCreateApiOperationTag() ApiOperationTagCollection collection = apiOperation.GetApiOperationTags(); // invoke the operation - string tagId = "tagId1"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagId); - ApiOperationTagResource result = lro.Value; + string tagId = "59306a29e4bbd510dc24e5f9"; + NullableResponse response = await collection.GetIfExistsAsync(tagId); + ApiOperationTagResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationTagResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationTagResource.cs index ddf64151fbb3b..e272b8651e96e 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationTagResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiOperationTagResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiOperationTagResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityStateByOperation_ApiManagementHeadApiOperationTag() + public async Task Get_ApiManagementGetApiOperationTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiOperationTag.json - // this example is just showing the usage of "Tag_GetEntityStateByOperation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationTag.json + // this example is just showing the usage of "Tag_GetByOperation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityStateByOperation_ApiManagementHeadApiOperationTag() ApiOperationTagResource apiOperationTag = client.GetApiOperationTagResource(apiOperationTagResourceId); // invoke the operation - bool result = await apiOperationTag.GetEntityStateByOperationAsync(); + ApiOperationTagResource result = await apiOperationTag.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiOperationTag() + public async Task Delete_ApiManagementDeleteApiOperationTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiOperationTag.json - // this example is just showing the usage of "Tag_GetByOperation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiOperationTag.json + // this example is just showing the usage of "Tag_DetachFromOperation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,20 +65,16 @@ public async Task Get_ApiManagementGetApiOperationTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d6bb8f1f7fab13dc67ec9b"; - string operationId = "59d6bb8f1f7fab13dc67ec9a"; - string tagId = "59306a29e4bbd510dc24e5f9"; + string apiId = "59d5b28d1f7fab116c282650"; + string operationId = "59d5b28d1f7fab116c282651"; + string tagId = "59d5b28e1f7fab116402044e"; ResourceIdentifier apiOperationTagResourceId = ApiOperationTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId, tagId); ApiOperationTagResource apiOperationTag = client.GetApiOperationTagResource(apiOperationTagResourceId); // invoke the operation - ApiOperationTagResource result = await apiOperationTag.GetAsync(); + await apiOperationTag.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -113,10 +113,10 @@ public async Task Update_ApiManagementCreateApiOperationTag() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiOperationTag() + public async Task GetEntityStateByOperation_ApiManagementHeadApiOperationTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiOperationTag.json - // this example is just showing the usage of "Tag_DetachFromOperation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiOperationTag.json + // this example is just showing the usage of "Tag_GetEntityStateByOperation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -128,16 +128,16 @@ public async Task Delete_ApiManagementDeleteApiOperationTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d5b28d1f7fab116c282650"; - string operationId = "59d5b28d1f7fab116c282651"; - string tagId = "59d5b28e1f7fab116402044e"; + string apiId = "59d6bb8f1f7fab13dc67ec9b"; + string operationId = "59d6bb8f1f7fab13dc67ec9a"; + string tagId = "59306a29e4bbd510dc24e5f9"; ResourceIdentifier apiOperationTagResourceId = ApiOperationTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, operationId, tagId); ApiOperationTagResource apiOperationTag = client.GetApiOperationTagResource(apiOperationTagResourceId); // invoke the operation - await apiOperationTag.DeleteAsync(WaitUntil.Completed); + bool result = await apiOperationTag.GetEntityStateByOperationAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiPolicyCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiPolicyCollection.cs index ac4f87fdcc59b..16fab527cc8a5 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiPolicyCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiPolicies() + public async Task CreateOrUpdate_ApiManagementCreateApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiPolicies.json - // this example is just showing the usage of "ApiPolicy_ListByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiPolicy.json + // this example is just showing the usage of "ApiPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,32 +33,37 @@ public async Task GetAll_ApiManagementListApiPolicies() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b59475ff190048040001"; + string apiId = "5600b57e7e8880006a040001"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiPolicyResource ApiPolicyCollection collection = api.GetApiPolicies(); - // invoke the operation and iterate over the result - await foreach (ApiPolicyResource item in collection.GetAllAsync()) + // invoke the operation + PolicyName policyId = PolicyName.Policy; + PolicyContractData data = new PolicyContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = " ", + Format = PolicyContentFormat.Xml, + }; + ETag? ifMatch = new ETag("*"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); + ApiPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiPolicy() + public async Task CreateOrUpdate_ApiManagementCreateApiPolicyNonXmlEncoded() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiPolicy.json - // this example is just showing the usage of "ApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiPolicyNonXmlEncoded.json + // this example is just showing the usage of "ApiPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,7 +75,7 @@ public async Task Get_ApiManagementGetApiPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b59475ff190048040001"; + string apiId = "5600b57e7e8880006a040001"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -79,7 +84,14 @@ public async Task Get_ApiManagementGetApiPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - ApiPolicyResource result = await collection.GetAsync(policyId); + PolicyContractData data = new PolicyContractData + { + Value = "\r\n \r\n \r\n \r\n \"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" \r\n \r\n \r\n ", + Format = PolicyContentFormat.RawXml, + }; + ETag? ifMatch = new ETag("*"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); + ApiPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,7 +102,7 @@ public async Task Get_ApiManagementGetApiPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiPolicy() + public async Task Get_ApiManagementGetApiPolicy() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiPolicy.json // this example is just showing the usage of "ApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -114,17 +126,21 @@ public async Task Exists_ApiManagementGetApiPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - bool result = await collection.ExistsAsync(policyId); + ApiPolicyResource result = await collection.GetAsync(policyId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiPolicy() + public async Task GetAll_ApiManagementListApiPolicies() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiPolicy.json - // this example is just showing the usage of "ApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiPolicies.json + // this example is just showing the usage of "ApiPolicy_ListByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +159,25 @@ public async Task GetIfExists_ApiManagementGetApiPolicy() // get the collection of this ApiPolicyResource ApiPolicyCollection collection = api.GetApiPolicies(); - // invoke the operation - PolicyName policyId = PolicyName.Policy; - NullableResponse response = await collection.GetIfExistsAsync(policyId); - ApiPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ApiPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; + PolicyContractData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiPolicy() + public async Task Exists_ApiManagementGetApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiPolicy.json - // this example is just showing the usage of "ApiPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiPolicy.json + // this example is just showing the usage of "ApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,7 +189,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b57e7e8880006a040001"; + string apiId = "5600b59475ff190048040001"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -188,28 +198,17 @@ public async Task CreateOrUpdate_ApiManagementCreateApiPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = " ", - Format = PolicyContentFormat.Xml, - }; - ETag? ifMatch = new ETag("*"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); - ApiPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(policyId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiPolicyNonXmlEncoded() + public async Task GetIfExists_ApiManagementGetApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiPolicyNonXmlEncoded.json - // this example is just showing the usage of "ApiPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiPolicy.json + // this example is just showing the usage of "ApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -221,7 +220,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiPolicyNonXmlEncoded() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b57e7e8880006a040001"; + string apiId = "5600b59475ff190048040001"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -230,20 +229,21 @@ public async Task CreateOrUpdate_ApiManagementCreateApiPolicyNonXmlEncoded() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = "\r\n \r\n \r\n \r\n \"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" \r\n \r\n \r\n ", - Format = PolicyContentFormat.RawXml, - }; - ETag? ifMatch = new ETag("*"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); - ApiPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyId); + ApiPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiPolicyResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiPolicyResource.cs index 3b5dd124b23b0..3e28f818d597a 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiPolicyResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiPolicy() + public async Task Get_ApiManagementGetApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiPolicy.json - // this example is just showing the usage of "ApiPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiPolicy.json + // this example is just showing the usage of "ApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,23 +33,27 @@ public async Task GetEntityTag_ApiManagementHeadApiPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "5600b59475ff190048040001"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier apiPolicyResourceId = ApiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, policyId); ApiPolicyResource apiPolicy = client.GetApiPolicyResource(apiPolicyResourceId); // invoke the operation - bool result = await apiPolicy.GetEntityTagAsync(); + ApiPolicyResource result = await apiPolicy.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiPolicy() + public async Task Delete_ApiManagementDeleteApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiPolicy.json - // this example is just showing the usage of "ApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiPolicy.json + // this example is just showing the usage of "ApiPolicy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,19 +65,16 @@ public async Task Get_ApiManagementGetApiPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b59475ff190048040001"; + string apiId = "loggerId"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier apiPolicyResourceId = ApiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, policyId); ApiPolicyResource apiPolicy = client.GetApiPolicyResource(apiPolicyResourceId); // invoke the operation - ApiPolicyResource result = await apiPolicy.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,7 +100,7 @@ public async Task Update_ApiManagementCreateApiPolicy() ApiPolicyResource apiPolicy = client.GetApiPolicyResource(apiPolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = " ", Format = PolicyContentFormat.Xml, @@ -138,7 +139,7 @@ public async Task Update_ApiManagementCreateApiPolicyNonXmlEncoded() ApiPolicyResource apiPolicy = client.GetApiPolicyResource(apiPolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = "\r\n \r\n \r\n \r\n \"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" \r\n \r\n \r\n ", Format = PolicyContentFormat.RawXml, @@ -156,10 +157,10 @@ public async Task Update_ApiManagementCreateApiPolicyNonXmlEncoded() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiPolicy() + public async Task GetEntityTag_ApiManagementHeadApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiPolicy.json - // this example is just showing the usage of "ApiPolicy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiPolicy.json + // this example is just showing the usage of "ApiPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -171,16 +172,15 @@ public async Task Delete_ApiManagementDeleteApiPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "loggerId"; + string apiId = "57d1f7558aa04f15146d9d8a"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier apiPolicyResourceId = ApiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, policyId); ApiPolicyResource apiPolicy = client.GetApiPolicyResource(apiPolicyResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiPolicy.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiReleaseCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiReleaseCollection.cs index 16da79df30f2e..730eba2064d64 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiReleaseCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiReleaseCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiReleaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiReleases() + public async Task CreateOrUpdate_ApiManagementCreateApiRelease() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiReleases.json - // this example is just showing the usage of "ApiRelease_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiRelease.json + // this example is just showing the usage of "ApiRelease_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ApiManagementListApiReleases() // get the collection of this ApiReleaseResource ApiReleaseCollection collection = api.GetApiReleases(); - // invoke the operation and iterate over the result - await foreach (ApiReleaseResource item in collection.GetAllAsync()) + // invoke the operation + string releaseId = "testrev"; + ApiReleaseData data = new ApiReleaseData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiReleaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ApiId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1"), + Notes = "yahooagain", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, releaseId, data); + ApiReleaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiReleaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +93,10 @@ public async Task Get_ApiManagementGetApiRelease() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiRelease() + public async Task GetAll_ApiManagementListApiReleases() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRelease.json - // this example is just showing the usage of "ApiRelease_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiReleases.json + // this example is just showing the usage of "ApiRelease_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +115,22 @@ public async Task Exists_ApiManagementGetApiRelease() // get the collection of this ApiReleaseResource ApiReleaseCollection collection = api.GetApiReleases(); - // invoke the operation - string releaseId = "5a7cb545298324c53224a799"; - bool result = await collection.ExistsAsync(releaseId); + // invoke the operation and iterate over the result + await foreach (ApiReleaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiReleaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiRelease() + public async Task Exists_ApiManagementGetApiRelease() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRelease.json // this example is just showing the usage of "ApiRelease_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +154,17 @@ public async Task GetIfExists_ApiManagementGetApiRelease() // invoke the operation string releaseId = "5a7cb545298324c53224a799"; - NullableResponse response = await collection.GetIfExistsAsync(releaseId); - ApiReleaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(releaseId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiReleaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiRelease() + public async Task GetIfExists_ApiManagementGetApiRelease() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiRelease.json - // this example is just showing the usage of "ApiRelease_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRelease.json + // this example is just showing the usage of "ApiRelease_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,20 +184,22 @@ public async Task CreateOrUpdate_ApiManagementCreateApiRelease() ApiReleaseCollection collection = api.GetApiReleases(); // invoke the operation - string releaseId = "testrev"; - ApiReleaseData data = new ApiReleaseData() - { - ApiId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1"), - Notes = "yahooagain", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, releaseId, data); - ApiReleaseResource result = lro.Value; + string releaseId = "5a7cb545298324c53224a799"; + NullableResponse response = await collection.GetIfExistsAsync(releaseId); + ApiReleaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiReleaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiReleaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiReleaseResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiReleaseResource.cs index 033a7ebed200d..e5e839fb36485 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiReleaseResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiReleaseResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiReleaseResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiRelease() + public async Task Get_ApiManagementGetApiRelease() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiRelease.json - // this example is just showing the usage of "ApiRelease_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRelease.json + // this example is just showing the usage of "ApiRelease_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadApiRelease() ApiReleaseResource apiRelease = client.GetApiReleaseResource(apiReleaseResourceId); // invoke the operation - bool result = await apiRelease.GetEntityTagAsync(); + ApiReleaseResource result = await apiRelease.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiReleaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiRelease() + public async Task Delete_ApiManagementDeleteApiRelease() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRelease.json - // this example is just showing the usage of "ApiRelease_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiRelease.json + // this example is just showing the usage of "ApiRelease_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,19 +64,16 @@ public async Task Get_ApiManagementGetApiRelease() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "a1"; - string releaseId = "5a7cb545298324c53224a799"; + string apiId = "5a5fcc09124a7fa9b89f2f1d"; + string releaseId = "testrev"; ResourceIdentifier apiReleaseResourceId = ApiReleaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, releaseId); ApiReleaseResource apiRelease = client.GetApiReleaseResource(apiReleaseResourceId); // invoke the operation - ApiReleaseResource result = await apiRelease.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiRelease.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiReleaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,7 +100,7 @@ public async Task Update_ApiManagementUpdateApiRelease() // invoke the operation ETag ifMatch = new ETag("*"); - ApiReleaseData data = new ApiReleaseData() + ApiReleaseData data = new ApiReleaseData { ApiId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/a1"), Notes = "yahooagain", @@ -115,10 +116,10 @@ public async Task Update_ApiManagementUpdateApiRelease() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiRelease() + public async Task GetEntityTag_ApiManagementHeadApiRelease() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiRelease.json - // this example is just showing the usage of "ApiRelease_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiRelease.json + // this example is just showing the usage of "ApiRelease_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,16 +131,15 @@ public async Task Delete_ApiManagementDeleteApiRelease() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5a5fcc09124a7fa9b89f2f1d"; - string releaseId = "testrev"; + string apiId = "a1"; + string releaseId = "5a7cb545298324c53224a799"; ResourceIdentifier apiReleaseResourceId = ApiReleaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, releaseId); ApiReleaseResource apiRelease = client.GetApiReleaseResource(apiReleaseResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiRelease.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiRelease.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiResource.cs index 07f389b2abafc..02bb6345d90e6 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApi() + public async Task Get_ApiManagementGetApiContract() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApi.json - // this example is just showing the usage of "Api_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiContract.json + // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,20 @@ public async Task GetEntityTag_ApiManagementHeadApi() ApiResource api = client.GetApiResource(apiResourceId); // invoke the operation - bool result = await api.GetEntityTagAsync(); + ApiResource result = await api.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiContract() + public async Task Get_ApiManagementGetApiRevisionContract() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiContract.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRevision.json // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -60,7 +64,7 @@ public async Task Get_ApiManagementGetApiContract() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "echo-api;rev=3"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -76,10 +80,10 @@ public async Task Get_ApiManagementGetApiContract() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiRevisionContract() + public async Task Delete_ApiManagementDeleteApi() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiRevision.json - // this example is just showing the usage of "Api_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApi.json + // this example is just showing the usage of "Api_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,18 +95,15 @@ public async Task Get_ApiManagementGetApiRevisionContract() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "echo-api;rev=3"; + string apiId = "echo-api"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // invoke the operation - ApiResource result = await api.GetAsync(); + ETag ifMatch = new ETag("*"); + await api.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -128,7 +129,7 @@ public async Task Update_ApiManagementUpdateApi() // invoke the operation ETag ifMatch = new ETag("*"); - ApiPatch patch = new ApiPatch() + ApiPatch patch = new ApiPatch { DisplayName = "Echo API New", ServiceLink = "http://echoapi.cloudapp.net/api2", @@ -145,10 +146,10 @@ public async Task Update_ApiManagementUpdateApi() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApi() + public async Task GetApiRevisionsByService_ApiManagementListApiRevisions() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApi.json - // this example is just showing the usage of "Api_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiRevisions.json + // this example is just showing the usage of "ApiRevision_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -160,23 +161,25 @@ public async Task Delete_ApiManagementDeleteApi() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "echo-api"; + string apiId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); - // invoke the operation - ETag ifMatch = new ETag("*"); - await api.DeleteAsync(WaitUntil.Completed, ifMatch); + // invoke the operation and iterate over the result + await foreach (ApiRevisionContract item in api.GetApiRevisionsByServiceAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetApiRevisionsByService_ApiManagementListApiRevisions() + public async Task GetOperationsByTags_ApiManagementListApiOperationsByTags() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiRevisions.json - // this example is just showing the usage of "ApiRevision_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiOperationsByTags.json + // this example is just showing the usage of "Operation_ListByTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,12 +191,12 @@ public async Task GetApiRevisionsByService_ApiManagementListApiRevisions() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "a1"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // invoke the operation and iterate over the result - await foreach (ApiRevisionContract item in api.GetApiRevisionsByServiceAsync()) + await foreach (TagResourceContractDetails item in api.GetOperationsByTagsAsync()) { Console.WriteLine($"Succeeded: {item}"); } @@ -203,10 +206,10 @@ public async Task GetApiRevisionsByService_ApiManagementListApiRevisions() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetOperationsByTags_ApiManagementListApiOperationsByTags() + public async Task GetEntityTag_ApiManagementHeadApi() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiOperationsByTags.json - // this example is just showing the usage of "Operation_ListByTags" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApi.json + // this example is just showing the usage of "Api_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -218,17 +221,14 @@ public async Task GetOperationsByTags_ApiManagementListApiOperationsByTags() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "a1"; + string apiId = "57d1f7558aa04f15146d9d8a"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); - // invoke the operation and iterate over the result - await foreach (TagResourceContractDetails item in api.GetOperationsByTagsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + bool result = await api.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiSchemaCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiSchemaCollection.cs index d2c2947d2cba7..43eb3d9c7afde 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiSchemaCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiSchemaCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiSchemaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiSchemas() + public async Task CreateOrUpdate_ApiManagementCreateApiSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiSchemas.json - // this example is just showing the usage of "ApiSchema_ListByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiSchema.json + // this example is just showing the usage of "ApiSchema_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,28 @@ public async Task GetAll_ApiManagementListApiSchemas() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d5b28d1f7fab116c282650"; + string apiId = "59d6bb8f1f7fab13dc67ec9b"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiSchemaResource ApiSchemaCollection collection = api.GetApiSchemas(); - // invoke the operation and iterate over the result - await foreach (ApiSchemaResource item in collection.GetAllAsync()) + // invoke the operation + string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; + ApiSchemaData data = new ApiSchemaData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiSchemaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ContentType = "application/vnd.ms-azure-apim.xsd+xml", + Value = "\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaId, data); + ApiSchemaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +93,10 @@ public async Task Get_ApiManagementGetApiSchema() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiSchema() + public async Task GetAll_ApiManagementListApiSchemas() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiSchema.json - // this example is just showing the usage of "ApiSchema_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiSchemas.json + // this example is just showing the usage of "ApiSchema_ListByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,23 +108,29 @@ public async Task Exists_ApiManagementGetApiSchema() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d6bb8f1f7fab13dc67ec9b"; + string apiId = "59d5b28d1f7fab116c282650"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiSchemaResource ApiSchemaCollection collection = api.GetApiSchemas(); - // invoke the operation - string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; - bool result = await collection.ExistsAsync(schemaId); + // invoke the operation and iterate over the result + await foreach (ApiSchemaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiSchemaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiSchema() + public async Task Exists_ApiManagementGetApiSchema() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiSchema.json // this example is just showing the usage of "ApiSchema_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +154,17 @@ public async Task GetIfExists_ApiManagementGetApiSchema() // invoke the operation string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; - NullableResponse response = await collection.GetIfExistsAsync(schemaId); - ApiSchemaResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(schemaId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiSchema() + public async Task GetIfExists_ApiManagementGetApiSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiSchema.json - // this example is just showing the usage of "ApiSchema_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiSchema.json + // this example is just showing the usage of "ApiSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,19 +185,21 @@ public async Task CreateOrUpdate_ApiManagementCreateApiSchema() // invoke the operation string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; - ApiSchemaData data = new ApiSchemaData() - { - ContentType = "application/vnd.ms-azure-apim.xsd+xml", - Value = "\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaId, data); - ApiSchemaResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(schemaId); + ApiSchemaResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiSchemaResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiSchemaResource.cs index dcdd5226d1ff1..f91a56691882e 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiSchemaResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiSchemaResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiSchemaResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiSchema() + public async Task Get_ApiManagementGetApiSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiSchema.json - // this example is just showing the usage of "ApiSchema_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiSchema.json + // this example is just showing the usage of "ApiSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,23 +32,27 @@ public async Task GetEntityTag_ApiManagementHeadApiSchema() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "59d6bb8f1f7fab13dc67ec9b"; string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; ResourceIdentifier apiSchemaResourceId = ApiSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, schemaId); ApiSchemaResource apiSchema = client.GetApiSchemaResource(apiSchemaResourceId); // invoke the operation - bool result = await apiSchema.GetEntityTagAsync(); + ApiSchemaResource result = await apiSchema.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiSchema() + public async Task Delete_ApiManagementDeleteApiSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiSchema.json - // this example is just showing the usage of "ApiSchema_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiSchema.json + // this example is just showing the usage of "ApiSchema_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,19 +64,16 @@ public async Task Get_ApiManagementGetApiSchema() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d6bb8f1f7fab13dc67ec9b"; - string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; + string apiId = "59d5b28d1f7fab116c282650"; + string schemaId = "59d5b28e1f7fab116402044e"; ResourceIdentifier apiSchemaResourceId = ApiSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, schemaId); ApiSchemaResource apiSchema = client.GetApiSchemaResource(apiSchemaResourceId); // invoke the operation - ApiSchemaResource result = await apiSchema.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiSchema.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -98,7 +99,7 @@ public async Task Update_ApiManagementCreateApiSchema() ApiSchemaResource apiSchema = client.GetApiSchemaResource(apiSchemaResourceId); // invoke the operation - ApiSchemaData data = new ApiSchemaData() + ApiSchemaData data = new ApiSchemaData { ContentType = "application/vnd.ms-azure-apim.xsd+xml", Value = "\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", @@ -115,10 +116,10 @@ public async Task Update_ApiManagementCreateApiSchema() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiSchema() + public async Task GetEntityTag_ApiManagementHeadApiSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiSchema.json - // this example is just showing the usage of "ApiSchema_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiSchema.json + // this example is just showing the usage of "ApiSchema_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,16 +131,15 @@ public async Task Delete_ApiManagementDeleteApiSchema() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d5b28d1f7fab116c282650"; - string schemaId = "59d5b28e1f7fab116402044e"; + string apiId = "57d1f7558aa04f15146d9d8a"; + string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; ResourceIdentifier apiSchemaResourceId = ApiSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, schemaId); ApiSchemaResource apiSchema = client.GetApiSchemaResource(apiSchemaResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiSchema.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiSchema.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagCollection.cs index 0a9c0997b3856..cb1b29c0423dc 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiTagCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiTags() + public async Task CreateOrUpdate_ApiManagementCreateApiTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiTags.json - // this example is just showing the usage of "Tag_ListByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiTag.json + // this example is just showing the usage of "Tag_AssignToApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,23 @@ public async Task GetAll_ApiManagementListApiTags() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "5931a75ae4bbd512a88c680b"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiTagResource ApiTagCollection collection = api.GetApiTags(); - // invoke the operation and iterate over the result - await foreach (ApiTagResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string tagId = "tagId1"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagId); + ApiTagResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +88,10 @@ public async Task Get_ApiManagementGetApiTag() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiTag() + public async Task GetAll_ApiManagementListApiTags() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiTag.json - // this example is just showing the usage of "Tag_GetByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiTags.json + // this example is just showing the usage of "Tag_ListByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,23 +103,29 @@ public async Task Exists_ApiManagementGetApiTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d6bb8f1f7fab13dc67ec9b"; + string apiId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiTagResource ApiTagCollection collection = api.GetApiTags(); - // invoke the operation - string tagId = "59306a29e4bbd510dc24e5f9"; - bool result = await collection.ExistsAsync(tagId); + // invoke the operation and iterate over the result + await foreach (ApiTagResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiTag() + public async Task Exists_ApiManagementGetApiTag() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiTag.json // this example is just showing the usage of "Tag_GetByApi" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +149,17 @@ public async Task GetIfExists_ApiManagementGetApiTag() // invoke the operation string tagId = "59306a29e4bbd510dc24e5f9"; - NullableResponse response = await collection.GetIfExistsAsync(tagId); - ApiTagResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tagId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiTag() + public async Task GetIfExists_ApiManagementGetApiTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiTag.json - // this example is just showing the usage of "Tag_AssignToApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiTag.json + // this example is just showing the usage of "Tag_GetByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,7 +171,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5931a75ae4bbd512a88c680b"; + string apiId = "59d6bb8f1f7fab13dc67ec9b"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -186,15 +179,22 @@ public async Task CreateOrUpdate_ApiManagementCreateApiTag() ApiTagCollection collection = api.GetApiTags(); // invoke the operation - string tagId = "tagId1"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagId); - ApiTagResource result = lro.Value; + string tagId = "59306a29e4bbd510dc24e5f9"; + NullableResponse response = await collection.GetIfExistsAsync(tagId); + ApiTagResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagDescriptionCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagDescriptionCollection.cs index e9302b87ae270..1465f82acaed9 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagDescriptionCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagDescriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiTagDescriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiTagDescriptions() + public async Task CreateOrUpdate_ApiManagementCreateApiTagDescription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiTagDescriptions.json - // this example is just showing the usage of "ApiTagDescription_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiTagDescription.json + // this example is just showing the usage of "ApiTagDescription_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,24 +33,29 @@ public async Task GetAll_ApiManagementListApiTagDescriptions() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "5931a75ae4bbd512a88c680b"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiTagDescriptionResource ApiTagDescriptionCollection collection = api.GetApiTagDescriptions(); - // invoke the operation and iterate over the result - await foreach (ApiTagDescriptionResource item in collection.GetAllAsync()) + // invoke the operation + string tagDescriptionId = "tagId1"; + ApiTagDescriptionCreateOrUpdateContent content = new ApiTagDescriptionCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiTagDescriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "Some description that will be displayed for operation's tag if the tag is assigned to operation of the API", + ExternalDocsUri = new Uri("http://some.url/additionaldoc"), + ExternalDocsDescription = "Description of the external docs resource", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagDescriptionId, content); + ApiTagDescriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiTagDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +95,10 @@ public async Task Get_ApiManagementGetApiTagDescription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiTagDescription() + public async Task GetAll_ApiManagementListApiTagDescriptions() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiTagDescription.json - // this example is just showing the usage of "ApiTagDescription_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiTagDescriptions.json + // this example is just showing the usage of "ApiTagDescription_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,23 +110,29 @@ public async Task Exists_ApiManagementGetApiTagDescription() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d6bb8f1f7fab13dc67ec9b"; + string apiId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ApiTagDescriptionResource ApiTagDescriptionCollection collection = api.GetApiTagDescriptions(); - // invoke the operation - string tagDescriptionId = "59306a29e4bbd510dc24e5f9"; - bool result = await collection.ExistsAsync(tagDescriptionId); + // invoke the operation and iterate over the result + await foreach (ApiTagDescriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiTagDescriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiTagDescription() + public async Task Exists_ApiManagementGetApiTagDescription() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiTagDescription.json // this example is just showing the usage of "ApiTagDescription_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +156,17 @@ public async Task GetIfExists_ApiManagementGetApiTagDescription() // invoke the operation string tagDescriptionId = "59306a29e4bbd510dc24e5f9"; - NullableResponse response = await collection.GetIfExistsAsync(tagDescriptionId); - ApiTagDescriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tagDescriptionId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiTagDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiTagDescription() + public async Task GetIfExists_ApiManagementGetApiTagDescription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiTagDescription.json - // this example is just showing the usage of "ApiTagDescription_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiTagDescription.json + // this example is just showing the usage of "ApiTagDescription_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,7 +178,7 @@ public async Task CreateOrUpdate_ApiManagementCreateApiTagDescription() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5931a75ae4bbd512a88c680b"; + string apiId = "59d6bb8f1f7fab13dc67ec9b"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -187,21 +186,22 @@ public async Task CreateOrUpdate_ApiManagementCreateApiTagDescription() ApiTagDescriptionCollection collection = api.GetApiTagDescriptions(); // invoke the operation - string tagDescriptionId = "tagId1"; - ApiTagDescriptionCreateOrUpdateContent content = new ApiTagDescriptionCreateOrUpdateContent() - { - Description = "Some description that will be displayed for operation's tag if the tag is assigned to operation of the API", - ExternalDocsUri = new Uri("http://some.url/additionaldoc"), - ExternalDocsDescription = "Description of the external docs resource", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagDescriptionId, content); - ApiTagDescriptionResource result = lro.Value; + string tagDescriptionId = "59306a29e4bbd510dc24e5f9"; + NullableResponse response = await collection.GetIfExistsAsync(tagDescriptionId); + ApiTagDescriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiTagDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiTagDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagDescriptionResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagDescriptionResource.cs index 76b0b93bfb96c..19c25572f6b56 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagDescriptionResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagDescriptionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiTagDescriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiTagDescription() + public async Task Get_ApiManagementGetApiTagDescription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiTagDescription.json - // this example is just showing the usage of "ApiTagDescription_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiTagDescription.json + // this example is just showing the usage of "ApiTagDescription_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadApiTagDescription() ApiTagDescriptionResource apiTagDescription = client.GetApiTagDescriptionResource(apiTagDescriptionResourceId); // invoke the operation - bool result = await apiTagDescription.GetEntityTagAsync(); + ApiTagDescriptionResource result = await apiTagDescription.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiTagDescriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiTagDescription() + public async Task Delete_ApiManagementDeleteApiTagDescription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiTagDescription.json - // this example is just showing the usage of "ApiTagDescription_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiTagDescription.json + // this example is just showing the usage of "ApiTagDescription_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,19 +65,16 @@ public async Task Get_ApiManagementGetApiTagDescription() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d6bb8f1f7fab13dc67ec9b"; - string tagDescriptionId = "59306a29e4bbd510dc24e5f9"; + string apiId = "59d5b28d1f7fab116c282650"; + string tagDescriptionId = "59d5b28e1f7fab116402044e"; ResourceIdentifier apiTagDescriptionResourceId = ApiTagDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, tagDescriptionId); ApiTagDescriptionResource apiTagDescription = client.GetApiTagDescriptionResource(apiTagDescriptionResourceId); // invoke the operation - ApiTagDescriptionResource result = await apiTagDescription.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiTagDescription.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiTagDescriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,7 +100,7 @@ public async Task Update_ApiManagementCreateApiTagDescription() ApiTagDescriptionResource apiTagDescription = client.GetApiTagDescriptionResource(apiTagDescriptionResourceId); // invoke the operation - ApiTagDescriptionCreateOrUpdateContent content = new ApiTagDescriptionCreateOrUpdateContent() + ApiTagDescriptionCreateOrUpdateContent content = new ApiTagDescriptionCreateOrUpdateContent { Description = "Some description that will be displayed for operation's tag if the tag is assigned to operation of the API", ExternalDocsUri = new Uri("http://some.url/additionaldoc"), @@ -117,10 +118,10 @@ public async Task Update_ApiManagementCreateApiTagDescription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiTagDescription() + public async Task GetEntityTag_ApiManagementHeadApiTagDescription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiTagDescription.json - // this example is just showing the usage of "ApiTagDescription_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiTagDescription.json + // this example is just showing the usage of "ApiTagDescription_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,16 +133,15 @@ public async Task Delete_ApiManagementDeleteApiTagDescription() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d5b28d1f7fab116c282650"; - string tagDescriptionId = "59d5b28e1f7fab116402044e"; + string apiId = "59d6bb8f1f7fab13dc67ec9b"; + string tagDescriptionId = "59306a29e4bbd510dc24e5f9"; ResourceIdentifier apiTagDescriptionResourceId = ApiTagDescriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, tagDescriptionId); ApiTagDescriptionResource apiTagDescription = client.GetApiTagDescriptionResource(apiTagDescriptionResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiTagDescription.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiTagDescription.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagResource.cs index b609eec10b471..073955bc3112f 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiTagResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ApiTagResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityStateByApi_ApiManagementHeadApiTag() + public async Task Get_ApiManagementGetApiTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiTag.json - // this example is just showing the usage of "Tag_GetEntityStateByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiTag.json + // this example is just showing the usage of "Tag_GetByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityStateByApi_ApiManagementHeadApiTag() ApiTagResource apiTag = client.GetApiTagResource(apiTagResourceId); // invoke the operation - bool result = await apiTag.GetEntityStateByApiAsync(); + ApiTagResource result = await apiTag.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiTag() + public async Task Delete_ApiManagementDeleteApiTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiTag.json - // this example is just showing the usage of "Tag_GetByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiTag.json + // this example is just showing the usage of "Tag_DetachFromApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,19 +64,15 @@ public async Task Get_ApiManagementGetApiTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d6bb8f1f7fab13dc67ec9b"; - string tagId = "59306a29e4bbd510dc24e5f9"; + string apiId = "59d5b28d1f7fab116c282650"; + string tagId = "59d5b28e1f7fab116402044e"; ResourceIdentifier apiTagResourceId = ApiTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, tagId); ApiTagResource apiTag = client.GetApiTagResource(apiTagResourceId); // invoke the operation - ApiTagResource result = await apiTag.GetAsync(); + await apiTag.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -110,10 +110,10 @@ public async Task Update_ApiManagementCreateApiTag() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiTag() + public async Task GetEntityStateByApi_ApiManagementHeadApiTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiTag.json - // this example is just showing the usage of "Tag_DetachFromApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiTag.json + // this example is just showing the usage of "Tag_GetEntityStateByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,15 +125,15 @@ public async Task Delete_ApiManagementDeleteApiTag() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "59d5b28d1f7fab116c282650"; - string tagId = "59d5b28e1f7fab116402044e"; + string apiId = "59d6bb8f1f7fab13dc67ec9b"; + string tagId = "59306a29e4bbd510dc24e5f9"; ResourceIdentifier apiTagResourceId = ApiTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, tagId); ApiTagResource apiTag = client.GetApiTagResource(apiTagResourceId); // invoke the operation - await apiTag.DeleteAsync(WaitUntil.Completed); + bool result = await apiTag.GetEntityStateByApiAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiVersionSetCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiVersionSetCollection.cs index b6d45be230d86..7ddcfe69745c9 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiVersionSetCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiVersionSetCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiVersionSetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApiVersionSets() + public async Task CreateOrUpdate_ApiManagementCreateApiVersionSet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiVersionSets.json - // this example is just showing the usage of "ApiVersionSet_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiVersionSet.json + // this example is just showing the usage of "ApiVersionSet_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,22 @@ public async Task GetAll_ApiManagementListApiVersionSets() // get the collection of this ApiVersionSetResource ApiVersionSetCollection collection = apiManagementService.GetApiVersionSets(); - // invoke the operation and iterate over the result - await foreach (ApiVersionSetResource item in collection.GetAllAsync()) + // invoke the operation + string versionSetId = "api1"; + ApiVersionSetData data = new ApiVersionSetData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiVersionSetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "Version configuration", + DisplayName = "api set 1", + VersioningScheme = VersioningScheme.Segment, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, versionSetId, data); + ApiVersionSetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiVersionSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +93,10 @@ public async Task Get_ApiManagementGetApiVersionSet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetApiVersionSet() + public async Task GetAll_ApiManagementListApiVersionSets() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiVersionSet.json - // this example is just showing the usage of "ApiVersionSet_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListApiVersionSets.json + // this example is just showing the usage of "ApiVersionSet_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +114,22 @@ public async Task Exists_ApiManagementGetApiVersionSet() // get the collection of this ApiVersionSetResource ApiVersionSetCollection collection = apiManagementService.GetApiVersionSets(); - // invoke the operation - string versionSetId = "vs1"; - bool result = await collection.ExistsAsync(versionSetId); + // invoke the operation and iterate over the result + await foreach (ApiVersionSetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiVersionSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetApiVersionSet() + public async Task Exists_ApiManagementGetApiVersionSet() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiVersionSet.json // this example is just showing the usage of "ApiVersionSet_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +152,17 @@ public async Task GetIfExists_ApiManagementGetApiVersionSet() // invoke the operation string versionSetId = "vs1"; - NullableResponse response = await collection.GetIfExistsAsync(versionSetId); - ApiVersionSetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(versionSetId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiVersionSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiVersionSet() + public async Task GetIfExists_ApiManagementGetApiVersionSet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiVersionSet.json - // this example is just showing the usage of "ApiVersionSet_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiVersionSet.json + // this example is just showing the usage of "ApiVersionSet_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,21 +181,22 @@ public async Task CreateOrUpdate_ApiManagementCreateApiVersionSet() ApiVersionSetCollection collection = apiManagementService.GetApiVersionSets(); // invoke the operation - string versionSetId = "api1"; - ApiVersionSetData data = new ApiVersionSetData() - { - Description = "Version configuration", - DisplayName = "api set 1", - VersioningScheme = VersioningScheme.Segment, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, versionSetId, data); - ApiVersionSetResource result = lro.Value; + string versionSetId = "vs1"; + NullableResponse response = await collection.GetIfExistsAsync(versionSetId); + ApiVersionSetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiVersionSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiVersionSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiVersionSetResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiVersionSetResource.cs index 8ffd4e842d2f3..00af7c22bf1c5 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiVersionSetResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ApiVersionSetResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApiVersionSetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiVersionSet() + public async Task Get_ApiManagementGetApiVersionSet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiVersionSet.json - // this example is just showing the usage of "ApiVersionSet_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiVersionSet.json + // this example is just showing the usage of "ApiVersionSet_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadApiVersionSet() ApiVersionSetResource apiVersionSet = client.GetApiVersionSetResource(apiVersionSetResourceId); // invoke the operation - bool result = await apiVersionSet.GetEntityTagAsync(); + ApiVersionSetResource result = await apiVersionSet.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiVersionSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiVersionSet() + public async Task Delete_ApiManagementDeleteApiVersionSet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiVersionSet.json - // this example is just showing the usage of "ApiVersionSet_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiVersionSet.json + // this example is just showing the usage of "ApiVersionSet_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,15 @@ public async Task Get_ApiManagementGetApiVersionSet() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string versionSetId = "vs1"; + string versionSetId = "a1"; ResourceIdentifier apiVersionSetResourceId = ApiVersionSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, versionSetId); ApiVersionSetResource apiVersionSet = client.GetApiVersionSetResource(apiVersionSetResourceId); // invoke the operation - ApiVersionSetResource result = await apiVersionSet.GetAsync(); + ETag ifMatch = new ETag("*"); + await apiVersionSet.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiVersionSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +98,7 @@ public async Task Update_ApiManagementUpdateApiVersionSet() // invoke the operation ETag ifMatch = new ETag("*"); - ApiVersionSetPatch patch = new ApiVersionSetPatch() + ApiVersionSetPatch patch = new ApiVersionSetPatch { Description = "Version configuration", DisplayName = "api set 1", @@ -114,10 +115,10 @@ public async Task Update_ApiManagementUpdateApiVersionSet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiVersionSet() + public async Task GetEntityTag_ApiManagementHeadApiVersionSet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiVersionSet.json - // this example is just showing the usage of "ApiVersionSet_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiVersionSet.json + // this example is just showing the usage of "ApiVersionSet_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,15 +130,14 @@ public async Task Delete_ApiManagementDeleteApiVersionSet() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string versionSetId = "a1"; + string versionSetId = "vs1"; ResourceIdentifier apiVersionSetResourceId = ApiVersionSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, versionSetId); ApiVersionSetResource apiVersionSet = client.GetApiVersionSetResource(apiVersionSetResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await apiVersionSet.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await apiVersionSet.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationAccessPolicyContractCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationAccessPolicyContractCollection.cs index 2d6bd67ee7f28..d101d1a10dbbd 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationAccessPolicyContractCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationAccessPolicyContractCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AuthorizationAccessPolicyContractCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListAuthorizationAccessPolicies() + public async Task CreateOrUpdate_ApiManagementCreateAuthorizationAccessPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListAuthorizationAccessPolicies.json - // this example is just showing the usage of "AuthorizationAccessPolicy_ListByAuthorization" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationAccessPolicy.json + // this example is just showing the usage of "AuthorizationAccessPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,21 @@ public async Task GetAll_ApiManagementListAuthorizationAccessPolicies() // get the collection of this AuthorizationAccessPolicyContractResource AuthorizationAccessPolicyContractCollection collection = authorizationContract.GetAuthorizationAccessPolicyContracts(); - // invoke the operation and iterate over the result - await foreach (AuthorizationAccessPolicyContractResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationAccessPolicyId = "fe0bed83-631f-4149-bd0b-0464b1bc7cab"; + AuthorizationAccessPolicyContractData data = new AuthorizationAccessPolicyContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationAccessPolicyContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TenantId = Guid.Parse("13932a0d-5c63-4d37-901d-1df9c97722ff"), + ObjectId = "fe0bed83-631f-4149-bd0b-0464b1bc7cab", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationAccessPolicyId, data); + AuthorizationAccessPolicyContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationAccessPolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +95,10 @@ public async Task Get_ApiManagementGetAuthorizationAccessPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetAuthorizationAccessPolicy() + public async Task GetAll_ApiManagementListAuthorizationAccessPolicies() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationAccessPolicy.json - // this example is just showing the usage of "AuthorizationAccessPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListAuthorizationAccessPolicies.json + // this example is just showing the usage of "AuthorizationAccessPolicy_ListByAuthorization" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +118,22 @@ public async Task Exists_ApiManagementGetAuthorizationAccessPolicy() // get the collection of this AuthorizationAccessPolicyContractResource AuthorizationAccessPolicyContractCollection collection = authorizationContract.GetAuthorizationAccessPolicyContracts(); - // invoke the operation - string authorizationAccessPolicyId = "fe0bed83-631f-4149-bd0b-0464b1bc7cab"; - bool result = await collection.ExistsAsync(authorizationAccessPolicyId); + // invoke the operation and iterate over the result + await foreach (AuthorizationAccessPolicyContractResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationAccessPolicyContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetAuthorizationAccessPolicy() + public async Task Exists_ApiManagementGetAuthorizationAccessPolicy() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationAccessPolicy.json // this example is just showing the usage of "AuthorizationAccessPolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +158,17 @@ public async Task GetIfExists_ApiManagementGetAuthorizationAccessPolicy() // invoke the operation string authorizationAccessPolicyId = "fe0bed83-631f-4149-bd0b-0464b1bc7cab"; - NullableResponse response = await collection.GetIfExistsAsync(authorizationAccessPolicyId); - AuthorizationAccessPolicyContractResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(authorizationAccessPolicyId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationAccessPolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateAuthorizationAccessPolicy() + public async Task GetIfExists_ApiManagementGetAuthorizationAccessPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationAccessPolicy.json - // this example is just showing the usage of "AuthorizationAccessPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationAccessPolicy.json + // this example is just showing the usage of "AuthorizationAccessPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,19 +190,21 @@ public async Task CreateOrUpdate_ApiManagementCreateAuthorizationAccessPolicy() // invoke the operation string authorizationAccessPolicyId = "fe0bed83-631f-4149-bd0b-0464b1bc7cab"; - AuthorizationAccessPolicyContractData data = new AuthorizationAccessPolicyContractData() - { - TenantId = Guid.Parse("13932a0d-5c63-4d37-901d-1df9c97722ff"), - ObjectId = "fe0bed83-631f-4149-bd0b-0464b1bc7cab", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationAccessPolicyId, data); - AuthorizationAccessPolicyContractResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(authorizationAccessPolicyId); + AuthorizationAccessPolicyContractResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationAccessPolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationAccessPolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationAccessPolicyContractResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationAccessPolicyContractResource.cs index ac05eb17d4be3..5d5e40dbcacac 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationAccessPolicyContractResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationAccessPolicyContractResource.cs @@ -50,10 +50,10 @@ public async Task Get_ApiManagementGetAuthorizationAccessPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateAuthorizationAccessPolicy() + public async Task Delete_ApiManagementDeleteAuthorizationAccessPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationAccessPolicy.json - // this example is just showing the usage of "AuthorizationAccessPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteAuthorizationAccessPolicy.json + // this example is just showing the usage of "AuthorizationAccessPolicy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,27 +72,18 @@ public async Task Update_ApiManagementCreateAuthorizationAccessPolicy() AuthorizationAccessPolicyContractResource authorizationAccessPolicyContract = client.GetAuthorizationAccessPolicyContractResource(authorizationAccessPolicyContractResourceId); // invoke the operation - AuthorizationAccessPolicyContractData data = new AuthorizationAccessPolicyContractData() - { - TenantId = Guid.Parse("13932a0d-5c63-4d37-901d-1df9c97722ff"), - ObjectId = "fe0bed83-631f-4149-bd0b-0464b1bc7cab", - }; - ArmOperation lro = await authorizationAccessPolicyContract.UpdateAsync(WaitUntil.Completed, data); - AuthorizationAccessPolicyContractResource result = lro.Value; + ETag ifMatch = new ETag("*"); + await authorizationAccessPolicyContract.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationAccessPolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteAuthorizationAccessPolicy() + public async Task Update_ApiManagementCreateAuthorizationAccessPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteAuthorizationAccessPolicy.json - // this example is just showing the usage of "AuthorizationAccessPolicy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationAccessPolicy.json + // this example is just showing the usage of "AuthorizationAccessPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,10 +102,19 @@ public async Task Delete_ApiManagementDeleteAuthorizationAccessPolicy() AuthorizationAccessPolicyContractResource authorizationAccessPolicyContract = client.GetAuthorizationAccessPolicyContractResource(authorizationAccessPolicyContractResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await authorizationAccessPolicyContract.DeleteAsync(WaitUntil.Completed, ifMatch); + AuthorizationAccessPolicyContractData data = new AuthorizationAccessPolicyContractData + { + TenantId = Guid.Parse("13932a0d-5c63-4d37-901d-1df9c97722ff"), + ObjectId = "fe0bed83-631f-4149-bd0b-0464b1bc7cab", + }; + ArmOperation lro = await authorizationAccessPolicyContract.UpdateAsync(WaitUntil.Completed, data); + AuthorizationAccessPolicyContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationAccessPolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationContractCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationContractCollection.cs index 9ced3a55de00f..8dc24a78b7480 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationContractCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationContractCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AuthorizationContractCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListAuthorizationsAuthCode() + public async Task CreateOrUpdate_ApiManagementCreateAuthorizationAADAuthCode() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListAuthorizationsAuthCode.json - // this example is just showing the usage of "Authorization_ListByAuthorizationProvider" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationAADAuthCode.json + // this example is just showing the usage of "Authorization_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,29 @@ public async Task GetAll_ApiManagementListAuthorizationsAuthCode() // get the collection of this AuthorizationContractResource AuthorizationContractCollection collection = authorizationProviderContract.GetAuthorizationContracts(); - // invoke the operation and iterate over the result - await foreach (AuthorizationContractResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationId = "authz2"; + AuthorizationContractData data = new AuthorizationContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AuthorizationType = ApiManagementAuthorizationType.OAuth2, + OAuth2GrantType = OAuth2GrantType.AuthorizationCode, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationId, data); + AuthorizationContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListAuthorizationsClientCred() + public async Task CreateOrUpdate_ApiManagementCreateAuthorizationAADClientCred() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListAuthorizationsClientCred.json - // this example is just showing the usage of "Authorization_ListByAuthorizationProvider" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationAADClientCred.json + // this example is just showing the usage of "Authorization_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,17 +81,26 @@ public async Task GetAll_ApiManagementListAuthorizationsClientCred() // get the collection of this AuthorizationContractResource AuthorizationContractCollection collection = authorizationProviderContract.GetAuthorizationContracts(); - // invoke the operation and iterate over the result - await foreach (AuthorizationContractResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationId = "authz1"; + AuthorizationContractData data = new AuthorizationContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AuthorizationType = ApiManagementAuthorizationType.OAuth2, + OAuth2GrantType = OAuth2GrantType.AuthorizationCode, + Parameters = +{ +["clientId"] = "53790925-fdd3-4b80-bc7a-4c3aaf25801d", +["clientSecret"] = "xxxxxxxxxxxxxxx~xxxxxxxxx" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationId, data); + AuthorizationContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -127,10 +140,10 @@ public async Task Get_ApiManagementGetAuthorization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetAuthorization() + public async Task GetAll_ApiManagementListAuthorizationsAuthCode() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorization.json - // this example is just showing the usage of "Authorization_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListAuthorizationsAuthCode.json + // this example is just showing the usage of "Authorization_ListByAuthorizationProvider" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,19 +162,25 @@ public async Task Exists_ApiManagementGetAuthorization() // get the collection of this AuthorizationContractResource AuthorizationContractCollection collection = authorizationProviderContract.GetAuthorizationContracts(); - // invoke the operation - string authorizationId = "authz1"; - bool result = await collection.ExistsAsync(authorizationId); + // invoke the operation and iterate over the result + await foreach (AuthorizationContractResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetAuthorization() + public async Task GetAll_ApiManagementListAuthorizationsClientCred() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorization.json - // this example is just showing the usage of "Authorization_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListAuthorizationsClientCred.json + // this example is just showing the usage of "Authorization_ListByAuthorizationProvider" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,38 +192,32 @@ public async Task GetIfExists_ApiManagementGetAuthorization() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string authorizationProviderId = "aadwithauthcode"; + string authorizationProviderId = "aadwithclientcred"; ResourceIdentifier authorizationProviderContractResourceId = AuthorizationProviderContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, authorizationProviderId); AuthorizationProviderContractResource authorizationProviderContract = client.GetAuthorizationProviderContractResource(authorizationProviderContractResourceId); // get the collection of this AuthorizationContractResource AuthorizationContractCollection collection = authorizationProviderContract.GetAuthorizationContracts(); - // invoke the operation - string authorizationId = "authz1"; - NullableResponse response = await collection.GetIfExistsAsync(authorizationId); - AuthorizationContractResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AuthorizationContractResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AuthorizationContractData resourceData = result.Data; + AuthorizationContractData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateAuthorizationAADAuthCode() + public async Task Exists_ApiManagementGetAuthorization() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationAADAuthCode.json - // this example is just showing the usage of "Authorization_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorization.json + // this example is just showing the usage of "Authorization_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -224,28 +237,18 @@ public async Task CreateOrUpdate_ApiManagementCreateAuthorizationAADAuthCode() AuthorizationContractCollection collection = authorizationProviderContract.GetAuthorizationContracts(); // invoke the operation - string authorizationId = "authz2"; - AuthorizationContractData data = new AuthorizationContractData() - { - AuthorizationType = ApiManagementAuthorizationType.OAuth2, - OAuth2GrantType = OAuth2GrantType.AuthorizationCode, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationId, data); - AuthorizationContractResource result = lro.Value; + string authorizationId = "authz1"; + bool result = await collection.ExistsAsync(authorizationId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateAuthorizationAADClientCred() + public async Task GetIfExists_ApiManagementGetAuthorization() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationAADClientCred.json - // this example is just showing the usage of "Authorization_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorization.json + // this example is just showing the usage of "Authorization_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -257,7 +260,7 @@ public async Task CreateOrUpdate_ApiManagementCreateAuthorizationAADClientCred() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string authorizationProviderId = "aadwithclientcred"; + string authorizationProviderId = "aadwithauthcode"; ResourceIdentifier authorizationProviderContractResourceId = AuthorizationProviderContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, authorizationProviderId); AuthorizationProviderContractResource authorizationProviderContract = client.GetAuthorizationProviderContractResource(authorizationProviderContractResourceId); @@ -266,24 +269,21 @@ public async Task CreateOrUpdate_ApiManagementCreateAuthorizationAADClientCred() // invoke the operation string authorizationId = "authz1"; - AuthorizationContractData data = new AuthorizationContractData() - { - AuthorizationType = ApiManagementAuthorizationType.OAuth2, - OAuth2GrantType = OAuth2GrantType.AuthorizationCode, - Parameters = -{ -["clientId"] = "53790925-fdd3-4b80-bc7a-4c3aaf25801d", -["clientSecret"] = "xxxxxxxxxxxxxxx~xxxxxxxxx", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationId, data); - AuthorizationContractResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(authorizationId); + AuthorizationContractResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationContractResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationContractResource.cs index 0a26e1c1b45ea..07e2e40565a3b 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationContractResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationContractResource.cs @@ -48,6 +48,35 @@ public async Task Get_ApiManagementGetAuthorization() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ApiManagementDeleteAuthorization() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteAuthorization.json + // this example is just showing the usage of "Authorization_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AuthorizationContractResource created on azure + // for more information of creating AuthorizationContractResource, please refer to the document of AuthorizationContractResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + string authorizationProviderId = "aadwithauthcode"; + string authorizationId = "authz1"; + ResourceIdentifier authorizationContractResourceId = AuthorizationContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, authorizationProviderId, authorizationId); + AuthorizationContractResource authorizationContract = client.GetAuthorizationContractResource(authorizationContractResourceId); + + // invoke the operation + ETag ifMatch = new ETag("*"); + await authorizationContract.DeleteAsync(WaitUntil.Completed, ifMatch); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_ApiManagementCreateAuthorizationAADAuthCode() @@ -71,7 +100,7 @@ public async Task Update_ApiManagementCreateAuthorizationAADAuthCode() AuthorizationContractResource authorizationContract = client.GetAuthorizationContractResource(authorizationContractResourceId); // invoke the operation - AuthorizationContractData data = new AuthorizationContractData() + AuthorizationContractData data = new AuthorizationContractData { AuthorizationType = ApiManagementAuthorizationType.OAuth2, OAuth2GrantType = OAuth2GrantType.AuthorizationCode, @@ -109,14 +138,14 @@ public async Task Update_ApiManagementCreateAuthorizationAADClientCred() AuthorizationContractResource authorizationContract = client.GetAuthorizationContractResource(authorizationContractResourceId); // invoke the operation - AuthorizationContractData data = new AuthorizationContractData() + AuthorizationContractData data = new AuthorizationContractData { AuthorizationType = ApiManagementAuthorizationType.OAuth2, OAuth2GrantType = OAuth2GrantType.AuthorizationCode, Parameters = { ["clientId"] = "53790925-fdd3-4b80-bc7a-4c3aaf25801d", -["clientSecret"] = "xxxxxxxxxxxxxxx~xxxxxxxxx", +["clientSecret"] = "xxxxxxxxxxxxxxx~xxxxxxxxx" }, }; ArmOperation lro = await authorizationContract.UpdateAsync(WaitUntil.Completed, data); @@ -129,35 +158,6 @@ public async Task Update_ApiManagementCreateAuthorizationAADClientCred() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteAuthorization() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteAuthorization.json - // this example is just showing the usage of "Authorization_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AuthorizationContractResource created on azure - // for more information of creating AuthorizationContractResource, please refer to the document of AuthorizationContractResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - string authorizationProviderId = "aadwithauthcode"; - string authorizationId = "authz1"; - ResourceIdentifier authorizationContractResourceId = AuthorizationContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, authorizationProviderId, authorizationId); - AuthorizationContractResource authorizationContract = client.GetAuthorizationContractResource(authorizationContractResourceId); - - // invoke the operation - ETag ifMatch = new ETag("*"); - await authorizationContract.DeleteAsync(WaitUntil.Completed, ifMatch); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task ConfirmConsentCode_ApiManagementPostAuthorizationConfirmConsentCodeRequest() @@ -181,7 +181,7 @@ public async Task ConfirmConsentCode_ApiManagementPostAuthorizationConfirmConsen AuthorizationContractResource authorizationContract = client.GetAuthorizationContractResource(authorizationContractResourceId); // invoke the operation - AuthorizationConfirmConsentCodeContent content = new AuthorizationConfirmConsentCodeContent() + AuthorizationConfirmConsentCodeContent content = new AuthorizationConfirmConsentCodeContent { ConsentCode = "theconsentcode", }; @@ -213,7 +213,7 @@ public async Task PostAuthorizationLoginLink_ApiManagementGetAuthorizationLoginR AuthorizationContractResource authorizationContract = client.GetAuthorizationContractResource(authorizationContractResourceId); // invoke the operation - AuthorizationLoginContent content = new AuthorizationLoginContent() + AuthorizationLoginContent content = new AuthorizationLoginContent { PostLoginRedirectUri = new Uri("https://www.bing.com/"), }; diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationProviderContractCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationProviderContractCollection.cs index d75267d936662..07971badac0c6 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationProviderContractCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationProviderContractCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AuthorizationProviderContractCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListAuthorizationProviders() + public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderAADAuthCode() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListAuthorizationProviders.json - // this example is just showing the usage of "AuthorizationProvider_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationProviderAADAuthCode.json + // this example is just showing the usage of "AuthorizationProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,43 @@ public async Task GetAll_ApiManagementListAuthorizationProviders() // get the collection of this AuthorizationProviderContractResource AuthorizationProviderContractCollection collection = apiManagementService.GetAuthorizationProviderContracts(); - // invoke the operation and iterate over the result - await foreach (AuthorizationProviderContractResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationProviderId = "aadwithauthcode"; + AuthorizationProviderContractData data = new AuthorizationProviderContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationProviderContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "aadwithauthcode", + IdentityProvider = "aad", + Oauth2 = new AuthorizationProviderOAuth2Settings + { + RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), + GrantTypes = new AuthorizationProviderOAuth2GrantTypes + { + AuthorizationCode = +{ +["clientId"] = "59790825-fdd3-4b10-bc7a-4c3aaf25801d", +["clientSecret"] = "xxxxxxxxxxxxxxxxxxxxxxxx", +["resourceUri"] = "https://graph.microsoft.com", +["scopes"] = "User.Read.All Group.Read.All" +}, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationProviderId, data); + AuthorizationProviderContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationProviderContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetAuthorizationProvider() + public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderAADClientCred() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationProvider.json - // this example is just showing the usage of "AuthorizationProvider_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationProviderAADClientCred.json + // this example is just showing the usage of "AuthorizationProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,8 +94,26 @@ public async Task Get_ApiManagementGetAuthorizationProvider() AuthorizationProviderContractCollection collection = apiManagementService.GetAuthorizationProviderContracts(); // invoke the operation - string authorizationProviderId = "aadwithauthcode"; - AuthorizationProviderContractResource result = await collection.GetAsync(authorizationProviderId); + string authorizationProviderId = "aadwithclientcred"; + AuthorizationProviderContractData data = new AuthorizationProviderContractData + { + DisplayName = "aadwithclientcred", + IdentityProvider = "aad", + Oauth2 = new AuthorizationProviderOAuth2Settings + { + RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), + GrantTypes = new AuthorizationProviderOAuth2GrantTypes + { + AuthorizationCode = +{ +["resourceUri"] = "https://graph.microsoft.com", +["scopes"] = "User.Read.All Group.Read.All" +}, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationProviderId, data); + AuthorizationProviderContractResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +124,10 @@ public async Task Get_ApiManagementGetAuthorizationProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetAuthorizationProvider() + public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderGenericOAuth2() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationProvider.json - // this example is just showing the usage of "AuthorizationProvider_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationProviderGenericOAuth2.json + // this example is just showing the usage of "AuthorizationProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,18 +146,44 @@ public async Task Exists_ApiManagementGetAuthorizationProvider() AuthorizationProviderContractCollection collection = apiManagementService.GetAuthorizationProviderContracts(); // invoke the operation - string authorizationProviderId = "aadwithauthcode"; - bool result = await collection.ExistsAsync(authorizationProviderId); + string authorizationProviderId = "eventbrite"; + AuthorizationProviderContractData data = new AuthorizationProviderContractData + { + DisplayName = "eventbrite", + IdentityProvider = "oauth2", + Oauth2 = new AuthorizationProviderOAuth2Settings + { + RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), + GrantTypes = new AuthorizationProviderOAuth2GrantTypes + { + AuthorizationCode = +{ +["authorizationUrl"] = "https://www.eventbrite.com/oauth/authorize", +["clientId"] = "genericClientId", +["clientSecret"] = "xxxxxxxxxxxxxxxxxxxxxxxx", +["refreshUrl"] = "https://www.eventbrite.com/oauth/token", +["scopes"] = null, +["tokenUrl"] = "https://www.eventbrite.com/oauth/token" +}, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationProviderId, data); + AuthorizationProviderContractResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationProviderContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetAuthorizationProvider() + public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderOOBGoogle() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationProvider.json - // this example is just showing the usage of "AuthorizationProvider_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationProviderOOBGoogle.json + // this example is just showing the usage of "AuthorizationProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,30 +202,41 @@ public async Task GetIfExists_ApiManagementGetAuthorizationProvider() AuthorizationProviderContractCollection collection = apiManagementService.GetAuthorizationProviderContracts(); // invoke the operation - string authorizationProviderId = "aadwithauthcode"; - NullableResponse response = await collection.GetIfExistsAsync(authorizationProviderId); - AuthorizationProviderContractResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string authorizationProviderId = "google"; + AuthorizationProviderContractData data = new AuthorizationProviderContractData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationProviderContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "google", + IdentityProvider = "google", + Oauth2 = new AuthorizationProviderOAuth2Settings + { + RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), + GrantTypes = new AuthorizationProviderOAuth2GrantTypes + { + AuthorizationCode = +{ +["clientId"] = "99999999-xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com", +["clientSecret"] = "XXXXXXXXXXXXXXXXXXXX", +["scopes"] = "openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email" +}, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationProviderId, data); + AuthorizationProviderContractResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationProviderContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderAADAuthCode() + public async Task Get_ApiManagementGetAuthorizationProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationProviderAADAuthCode.json - // this example is just showing the usage of "AuthorizationProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationProvider.json + // this example is just showing the usage of "AuthorizationProvider_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,27 +256,7 @@ public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderAADAuth // invoke the operation string authorizationProviderId = "aadwithauthcode"; - AuthorizationProviderContractData data = new AuthorizationProviderContractData() - { - DisplayName = "aadwithauthcode", - IdentityProvider = "aad", - Oauth2 = new AuthorizationProviderOAuth2Settings() - { - RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - GrantTypes = new AuthorizationProviderOAuth2GrantTypes() - { - AuthorizationCode = -{ -["clientId"] = "59790825-fdd3-4b10-bc7a-4c3aaf25801d", -["clientSecret"] = "xxxxxxxxxxxxxxxxxxxxxxxx", -["resourceUri"] = "https://graph.microsoft.com", -["scopes"] = "User.Read.All Group.Read.All", -}, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationProviderId, data); - AuthorizationProviderContractResource result = lro.Value; + AuthorizationProviderContractResource result = await collection.GetAsync(authorizationProviderId); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -214,10 +267,10 @@ public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderAADAuth [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderAADClientCred() + public async Task GetAll_ApiManagementListAuthorizationProviders() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationProviderAADClientCred.json - // this example is just showing the usage of "AuthorizationProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListAuthorizationProviders.json + // this example is just showing the usage of "AuthorizationProvider_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -235,41 +288,25 @@ public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderAADClie // get the collection of this AuthorizationProviderContractResource AuthorizationProviderContractCollection collection = apiManagementService.GetAuthorizationProviderContracts(); - // invoke the operation - string authorizationProviderId = "aadwithclientcred"; - AuthorizationProviderContractData data = new AuthorizationProviderContractData() + // invoke the operation and iterate over the result + await foreach (AuthorizationProviderContractResource item in collection.GetAllAsync()) { - DisplayName = "aadwithclientcred", - IdentityProvider = "aad", - Oauth2 = new AuthorizationProviderOAuth2Settings() - { - RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - GrantTypes = new AuthorizationProviderOAuth2GrantTypes() - { - AuthorizationCode = -{ -["resourceUri"] = "https://graph.microsoft.com", -["scopes"] = "User.Read.All Group.Read.All", -}, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationProviderId, data); - AuthorizationProviderContractResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationProviderContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationProviderContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderGenericOAuth2() + public async Task Exists_ApiManagementGetAuthorizationProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationProviderGenericOAuth2.json - // this example is just showing the usage of "AuthorizationProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationProvider.json + // this example is just showing the usage of "AuthorizationProvider_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -288,44 +325,18 @@ public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderGeneric AuthorizationProviderContractCollection collection = apiManagementService.GetAuthorizationProviderContracts(); // invoke the operation - string authorizationProviderId = "eventbrite"; - AuthorizationProviderContractData data = new AuthorizationProviderContractData() - { - DisplayName = "eventbrite", - IdentityProvider = "oauth2", - Oauth2 = new AuthorizationProviderOAuth2Settings() - { - RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - GrantTypes = new AuthorizationProviderOAuth2GrantTypes() - { - AuthorizationCode = -{ -["authorizationUrl"] = "https://www.eventbrite.com/oauth/authorize", -["clientId"] = "genericClientId", -["clientSecret"] = "xxxxxxxxxxxxxxxxxxxxxxxx", -["refreshUrl"] = "https://www.eventbrite.com/oauth/token", -["scopes"] = null, -["tokenUrl"] = "https://www.eventbrite.com/oauth/token", -}, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationProviderId, data); - AuthorizationProviderContractResource result = lro.Value; + string authorizationProviderId = "aadwithauthcode"; + bool result = await collection.ExistsAsync(authorizationProviderId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationProviderContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderOOBGoogle() + public async Task GetIfExists_ApiManagementGetAuthorizationProvider() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateAuthorizationProviderOOBGoogle.json - // this example is just showing the usage of "AuthorizationProvider_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetAuthorizationProvider.json + // this example is just showing the usage of "AuthorizationProvider_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -344,33 +355,22 @@ public async Task CreateOrUpdate_ApiManagementCreateAuthorizationProviderOOBGoog AuthorizationProviderContractCollection collection = apiManagementService.GetAuthorizationProviderContracts(); // invoke the operation - string authorizationProviderId = "google"; - AuthorizationProviderContractData data = new AuthorizationProviderContractData() - { - DisplayName = "google", - IdentityProvider = "google", - Oauth2 = new AuthorizationProviderOAuth2Settings() - { - RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - GrantTypes = new AuthorizationProviderOAuth2GrantTypes() - { - AuthorizationCode = -{ -["clientId"] = "99999999-xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com", -["clientSecret"] = "XXXXXXXXXXXXXXXXXXXX", -["scopes"] = "openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email", -}, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationProviderId, data); - AuthorizationProviderContractResource result = lro.Value; + string authorizationProviderId = "aadwithauthcode"; + NullableResponse response = await collection.GetIfExistsAsync(authorizationProviderId); + AuthorizationProviderContractResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationProviderContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationProviderContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationProviderContractResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationProviderContractResource.cs index 33dfa5faa651b..78861e2ccf6b0 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationProviderContractResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_AuthorizationProviderContractResource.cs @@ -47,6 +47,34 @@ public async Task Get_ApiManagementGetAuthorizationProvider() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ApiManagementDeleteAuthorizationProvider() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteAuthorizationProvider.json + // this example is just showing the usage of "AuthorizationProvider_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AuthorizationProviderContractResource created on azure + // for more information of creating AuthorizationProviderContractResource, please refer to the document of AuthorizationProviderContractResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + string authorizationProviderId = "aadwithauthcode"; + ResourceIdentifier authorizationProviderContractResourceId = AuthorizationProviderContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, authorizationProviderId); + AuthorizationProviderContractResource authorizationProviderContract = client.GetAuthorizationProviderContractResource(authorizationProviderContractResourceId); + + // invoke the operation + ETag ifMatch = new ETag("*"); + await authorizationProviderContract.DeleteAsync(WaitUntil.Completed, ifMatch); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_ApiManagementCreateAuthorizationProviderAADAuthCode() @@ -69,21 +97,21 @@ public async Task Update_ApiManagementCreateAuthorizationProviderAADAuthCode() AuthorizationProviderContractResource authorizationProviderContract = client.GetAuthorizationProviderContractResource(authorizationProviderContractResourceId); // invoke the operation - AuthorizationProviderContractData data = new AuthorizationProviderContractData() + AuthorizationProviderContractData data = new AuthorizationProviderContractData { DisplayName = "aadwithauthcode", IdentityProvider = "aad", - Oauth2 = new AuthorizationProviderOAuth2Settings() + Oauth2 = new AuthorizationProviderOAuth2Settings { RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - GrantTypes = new AuthorizationProviderOAuth2GrantTypes() + GrantTypes = new AuthorizationProviderOAuth2GrantTypes { AuthorizationCode = { ["clientId"] = "59790825-fdd3-4b10-bc7a-4c3aaf25801d", ["clientSecret"] = "xxxxxxxxxxxxxxxxxxxxxxxx", ["resourceUri"] = "https://graph.microsoft.com", -["scopes"] = "User.Read.All Group.Read.All", +["scopes"] = "User.Read.All Group.Read.All" }, }, }, @@ -120,19 +148,19 @@ public async Task Update_ApiManagementCreateAuthorizationProviderAADClientCred() AuthorizationProviderContractResource authorizationProviderContract = client.GetAuthorizationProviderContractResource(authorizationProviderContractResourceId); // invoke the operation - AuthorizationProviderContractData data = new AuthorizationProviderContractData() + AuthorizationProviderContractData data = new AuthorizationProviderContractData { DisplayName = "aadwithclientcred", IdentityProvider = "aad", - Oauth2 = new AuthorizationProviderOAuth2Settings() + Oauth2 = new AuthorizationProviderOAuth2Settings { RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - GrantTypes = new AuthorizationProviderOAuth2GrantTypes() + GrantTypes = new AuthorizationProviderOAuth2GrantTypes { AuthorizationCode = { ["resourceUri"] = "https://graph.microsoft.com", -["scopes"] = "User.Read.All Group.Read.All", +["scopes"] = "User.Read.All Group.Read.All" }, }, }, @@ -169,14 +197,14 @@ public async Task Update_ApiManagementCreateAuthorizationProviderGenericOAuth2() AuthorizationProviderContractResource authorizationProviderContract = client.GetAuthorizationProviderContractResource(authorizationProviderContractResourceId); // invoke the operation - AuthorizationProviderContractData data = new AuthorizationProviderContractData() + AuthorizationProviderContractData data = new AuthorizationProviderContractData { DisplayName = "eventbrite", IdentityProvider = "oauth2", - Oauth2 = new AuthorizationProviderOAuth2Settings() + Oauth2 = new AuthorizationProviderOAuth2Settings { RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - GrantTypes = new AuthorizationProviderOAuth2GrantTypes() + GrantTypes = new AuthorizationProviderOAuth2GrantTypes { AuthorizationCode = { @@ -185,7 +213,7 @@ public async Task Update_ApiManagementCreateAuthorizationProviderGenericOAuth2() ["clientSecret"] = "xxxxxxxxxxxxxxxxxxxxxxxx", ["refreshUrl"] = "https://www.eventbrite.com/oauth/token", ["scopes"] = null, -["tokenUrl"] = "https://www.eventbrite.com/oauth/token", +["tokenUrl"] = "https://www.eventbrite.com/oauth/token" }, }, }, @@ -222,20 +250,20 @@ public async Task Update_ApiManagementCreateAuthorizationProviderOOBGoogle() AuthorizationProviderContractResource authorizationProviderContract = client.GetAuthorizationProviderContractResource(authorizationProviderContractResourceId); // invoke the operation - AuthorizationProviderContractData data = new AuthorizationProviderContractData() + AuthorizationProviderContractData data = new AuthorizationProviderContractData { DisplayName = "google", IdentityProvider = "google", - Oauth2 = new AuthorizationProviderOAuth2Settings() + Oauth2 = new AuthorizationProviderOAuth2Settings { RedirectUri = new Uri("https://authorization-manager.consent.azure-apim.net/redirect/apim/apimService1"), - GrantTypes = new AuthorizationProviderOAuth2GrantTypes() + GrantTypes = new AuthorizationProviderOAuth2GrantTypes { AuthorizationCode = { ["clientId"] = "99999999-xxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com", ["clientSecret"] = "XXXXXXXXXXXXXXXXXXXX", -["scopes"] = "openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email", +["scopes"] = "openid https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email" }, }, }, @@ -249,33 +277,5 @@ public async Task Update_ApiManagementCreateAuthorizationProviderOOBGoogle() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteAuthorizationProvider() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteAuthorizationProvider.json - // this example is just showing the usage of "AuthorizationProvider_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AuthorizationProviderContractResource created on azure - // for more information of creating AuthorizationProviderContractResource, please refer to the document of AuthorizationProviderContractResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - string authorizationProviderId = "aadwithauthcode"; - ResourceIdentifier authorizationProviderContractResourceId = AuthorizationProviderContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, authorizationProviderId); - AuthorizationProviderContractResource authorizationProviderContract = client.GetAuthorizationProviderContractResource(authorizationProviderContractResourceId); - - // invoke the operation - ETag ifMatch = new ETag("*"); - await authorizationProviderContract.DeleteAsync(WaitUntil.Completed, ifMatch); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_DocumentationContractCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_DocumentationContractCollection.cs index 1922d8d9ff1e2..48ea10b678aa5 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_DocumentationContractCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_DocumentationContractCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DocumentationContractCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListApis() + public async Task CreateOrUpdate_ApiManagementCreateDocumentation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListDocumentations.json - // this example is just showing the usage of "Documentation_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateDocumentation.json + // this example is just showing the usage of "Documentation_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_ApiManagementListApis() // get the collection of this DocumentationContractResource DocumentationContractCollection collection = apiManagementService.GetDocumentationContracts(); - // invoke the operation and iterate over the result - await foreach (DocumentationContractResource item in collection.GetAllAsync()) + // invoke the operation + string documentationId = "57d1f7558aa04f15146d9d8a"; + DocumentationContractData data = new DocumentationContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DocumentationContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Title = "Title", + Content = "content", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, documentationId, data); + DocumentationContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DocumentationContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_ApiManagementGetDocumentation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetDocumentation() + public async Task GetAll_ApiManagementListApis() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetDocumentation.json - // this example is just showing the usage of "Documentation_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListDocumentations.json + // this example is just showing the usage of "Documentation_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_ApiManagementGetDocumentation() // get the collection of this DocumentationContractResource DocumentationContractCollection collection = apiManagementService.GetDocumentationContracts(); - // invoke the operation - string documentationId = "57d1f7558aa04f15146d9d8a"; - bool result = await collection.ExistsAsync(documentationId); + // invoke the operation and iterate over the result + await foreach (DocumentationContractResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DocumentationContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetDocumentation() + public async Task Exists_ApiManagementGetDocumentation() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetDocumentation.json // this example is just showing the usage of "Documentation_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_ApiManagementGetDocumentation() // invoke the operation string documentationId = "57d1f7558aa04f15146d9d8a"; - NullableResponse response = await collection.GetIfExistsAsync(documentationId); - DocumentationContractResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(documentationId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DocumentationContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateDocumentation() + public async Task GetIfExists_ApiManagementGetDocumentation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateDocumentation.json - // this example is just showing the usage of "Documentation_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetDocumentation.json + // this example is just showing the usage of "Documentation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,19 +180,21 @@ public async Task CreateOrUpdate_ApiManagementCreateDocumentation() // invoke the operation string documentationId = "57d1f7558aa04f15146d9d8a"; - DocumentationContractData data = new DocumentationContractData() - { - Title = "Title", - Content = "content", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, documentationId, data); - DocumentationContractResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(documentationId); + DocumentationContractResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DocumentationContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DocumentationContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_DocumentationContractResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_DocumentationContractResource.cs index 3ab611f0eb560..6b92a367ff97b 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_DocumentationContractResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_DocumentationContractResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DocumentationContractResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadDocumentation() + public async Task Get_ApiManagementGetDocumentation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadDocumentation.json - // this example is just showing the usage of "Documentation_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetDocumentation.json + // this example is just showing the usage of "Documentation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadDocumentation() DocumentationContractResource documentationContract = client.GetDocumentationContractResource(documentationContractResourceId); // invoke the operation - bool result = await documentationContract.GetEntityTagAsync(); + DocumentationContractResource result = await documentationContract.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DocumentationContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetDocumentation() + public async Task Delete_ApiManagementDeleteDocumentation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetDocumentation.json - // this example is just showing the usage of "Documentation_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteDocumentation.json + // this example is just showing the usage of "Documentation_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,10 @@ public async Task Get_ApiManagementGetDocumentation() DocumentationContractResource documentationContract = client.GetDocumentationContractResource(documentationContractResourceId); // invoke the operation - DocumentationContractResource result = await documentationContract.GetAsync(); + ETag ifMatch = default; + await documentationContract.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DocumentationContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,8 +97,8 @@ public async Task Update_ApiManagementUpdateDocumentation() DocumentationContractResource documentationContract = client.GetDocumentationContractResource(documentationContractResourceId); // invoke the operation - ETag ifMatch = default /* Warning: No value is provided for ifMatch in example 'ApiManagementUpdateDocumentation'. Please consider adding a proper example value for it in swagger*/; - DocumentationContractPatch patch = new DocumentationContractPatch() + ETag ifMatch = default; + DocumentationContractPatch patch = new DocumentationContractPatch { Title = "Title updated", Content = "content updated", @@ -113,10 +114,10 @@ public async Task Update_ApiManagementUpdateDocumentation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteDocumentation() + public async Task GetEntityTag_ApiManagementHeadDocumentation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteDocumentation.json - // this example is just showing the usage of "Documentation_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadDocumentation.json + // this example is just showing the usage of "Documentation_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,10 +134,9 @@ public async Task Delete_ApiManagementDeleteDocumentation() DocumentationContractResource documentationContract = client.GetDocumentationContractResource(documentationContractResourceId); // invoke the operation - ETag ifMatch = default /* Warning: No value is provided for ifMatch in example 'ApiManagementDeleteDocumentation'. Please consider adding a proper example value for it in swagger*/; - await documentationContract.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await documentationContract.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PolicyFragmentContractCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PolicyFragmentContractCollection.cs index 3d0fc49a7c90d..c79e2d154dbfd 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PolicyFragmentContractCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PolicyFragmentContractCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PolicyFragmentContractCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListPolicyFragments() + public async Task CreateOrUpdate_ApiManagementCreatePolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPolicyFragments.json - // this example is just showing the usage of "PolicyFragment_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreatePolicyFragment.json + // this example is just showing the usage of "PolicyFragment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,22 @@ public async Task GetAll_ApiManagementListPolicyFragments() // get the collection of this PolicyFragmentContractResource PolicyFragmentContractCollection collection = apiManagementService.GetPolicyFragmentContracts(); - // invoke the operation and iterate over the result - await foreach (PolicyFragmentContractResource item in collection.GetAllAsync()) + // invoke the operation + string id = "policyFragment1"; + PolicyFragmentContractData data = new PolicyFragmentContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyFragmentContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = "", + Description = "A policy fragment example", + Format = PolicyFragmentContentFormat.Xml, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); + PolicyFragmentContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyFragmentContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,9 +93,9 @@ public async Task Get_ApiManagementGetPolicyFragment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetPolicyFragment() + public async Task Get_ApiManagementGetPolicyFragmentFormat() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragment.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragmentFormat.json // this example is just showing the usage of "PolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -111,17 +116,22 @@ public async Task Exists_ApiManagementGetPolicyFragment() // invoke the operation string id = "policyFragment1"; - bool result = await collection.ExistsAsync(id); + PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; + PolicyFragmentContractResource result = await collection.GetAsync(id, format: format); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyFragmentContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetPolicyFragment() + public async Task GetAll_ApiManagementListPolicyFragments() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragment.json - // this example is just showing the usage of "PolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPolicyFragments.json + // this example is just showing the usage of "PolicyFragment_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,30 +149,24 @@ public async Task GetIfExists_ApiManagementGetPolicyFragment() // get the collection of this PolicyFragmentContractResource PolicyFragmentContractCollection collection = apiManagementService.GetPolicyFragmentContracts(); - // invoke the operation - string id = "policyFragment1"; - NullableResponse response = await collection.GetIfExistsAsync(id); - PolicyFragmentContractResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PolicyFragmentContractResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyFragmentContractData resourceData = result.Data; + PolicyFragmentContractData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetPolicyFragmentFormat() + public async Task Exists_ApiManagementGetPolicyFragment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragmentFormat.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragment.json // this example is just showing the usage of "PolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -183,14 +187,9 @@ public async Task Get_ApiManagementGetPolicyFragmentFormat() // invoke the operation string id = "policyFragment1"; - PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; - PolicyFragmentContractResource result = await collection.GetAsync(id, format: format); + bool result = await collection.ExistsAsync(id); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyFragmentContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -226,9 +225,9 @@ public async Task Exists_ApiManagementGetPolicyFragmentFormat() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetPolicyFragmentFormat() + public async Task GetIfExists_ApiManagementGetPolicyFragment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragmentFormat.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragment.json // this example is just showing the usage of "PolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -249,8 +248,7 @@ public async Task GetIfExists_ApiManagementGetPolicyFragmentFormat() // invoke the operation string id = "policyFragment1"; - PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; - NullableResponse response = await collection.GetIfExistsAsync(id, format: format); + NullableResponse response = await collection.GetIfExistsAsync(id); PolicyFragmentContractResource result = response.HasValue ? response.Value : null; if (result == null) @@ -269,10 +267,10 @@ public async Task GetIfExists_ApiManagementGetPolicyFragmentFormat() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreatePolicy() + public async Task GetIfExists_ApiManagementGetPolicyFragmentFormat() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreatePolicyFragment.json - // this example is just showing the usage of "PolicyFragment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragmentFormat.json + // this example is just showing the usage of "PolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -292,20 +290,22 @@ public async Task CreateOrUpdate_ApiManagementCreatePolicy() // invoke the operation string id = "policyFragment1"; - PolicyFragmentContractData data = new PolicyFragmentContractData() - { - Value = "", - Description = "A policy fragment example", - Format = PolicyFragmentContentFormat.Xml, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); - PolicyFragmentContractResource result = lro.Value; + PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; + NullableResponse response = await collection.GetIfExistsAsync(id, format: format); + PolicyFragmentContractResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyFragmentContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyFragmentContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PolicyFragmentContractResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PolicyFragmentContractResource.cs index b524f5ec0145a..9b401d2248d99 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PolicyFragmentContractResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PolicyFragmentContractResource.cs @@ -18,10 +18,10 @@ public partial class Sample_PolicyFragmentContractResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadPolicyFragment() + public async Task Get_ApiManagementGetPolicyFragment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadPolicyFragment.json - // this example is just showing the usage of "PolicyFragment_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragment.json + // this example is just showing the usage of "PolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,20 @@ public async Task GetEntityTag_ApiManagementHeadPolicyFragment() PolicyFragmentContractResource policyFragmentContract = client.GetPolicyFragmentContractResource(policyFragmentContractResourceId); // invoke the operation - bool result = await policyFragmentContract.GetEntityTagAsync(); + PolicyFragmentContractResource result = await policyFragmentContract.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyFragmentContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetPolicyFragment() + public async Task Get_ApiManagementGetPolicyFragmentFormat() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragment.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragmentFormat.json // this example is just showing the usage of "PolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -65,7 +69,8 @@ public async Task Get_ApiManagementGetPolicyFragment() PolicyFragmentContractResource policyFragmentContract = client.GetPolicyFragmentContractResource(policyFragmentContractResourceId); // invoke the operation - PolicyFragmentContractResource result = await policyFragmentContract.GetAsync(); + PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; + PolicyFragmentContractResource result = await policyFragmentContract.GetAsync(format: format); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -76,10 +81,10 @@ public async Task Get_ApiManagementGetPolicyFragment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetPolicyFragmentFormat() + public async Task Delete_ApiManagementDeletePolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetPolicyFragmentFormat.json - // this example is just showing the usage of "PolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeletePolicyFragment.json + // this example is just showing the usage of "PolicyFragment_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,14 +101,10 @@ public async Task Get_ApiManagementGetPolicyFragmentFormat() PolicyFragmentContractResource policyFragmentContract = client.GetPolicyFragmentContractResource(policyFragmentContractResourceId); // invoke the operation - PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; - PolicyFragmentContractResource result = await policyFragmentContract.GetAsync(format: format); + ETag ifMatch = new ETag("*"); + await policyFragmentContract.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyFragmentContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -128,7 +129,7 @@ public async Task Update_ApiManagementCreatePolicy() PolicyFragmentContractResource policyFragmentContract = client.GetPolicyFragmentContractResource(policyFragmentContractResourceId); // invoke the operation - PolicyFragmentContractData data = new PolicyFragmentContractData() + PolicyFragmentContractData data = new PolicyFragmentContractData { Value = "", Description = "A policy fragment example", @@ -146,10 +147,10 @@ public async Task Update_ApiManagementCreatePolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeletePolicy() + public async Task GetReferences_ApiManagementListPolicyFragmentReferences() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeletePolicyFragment.json - // this example is just showing the usage of "PolicyFragment_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPolicyFragmentReferences.json + // this example is just showing the usage of "PolicyFragment_ListReferences" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,19 +166,21 @@ public async Task Delete_ApiManagementDeletePolicy() ResourceIdentifier policyFragmentContractResourceId = PolicyFragmentContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, id); PolicyFragmentContractResource policyFragmentContract = client.GetPolicyFragmentContractResource(policyFragmentContractResourceId); - // invoke the operation - ETag ifMatch = new ETag("*"); - await policyFragmentContract.DeleteAsync(WaitUntil.Completed, ifMatch); + // invoke the operation and iterate over the result + await foreach (ResourceCollectionValueItem item in policyFragmentContract.GetReferencesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetReferences_ApiManagementListPolicyFragmentReferences() + public async Task GetEntityTag_ApiManagementHeadPolicyFragment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPolicyFragmentReferences.json - // this example is just showing the usage of "PolicyFragment_ListReferences" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadPolicyFragment.json + // this example is just showing the usage of "PolicyFragment_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,13 +196,10 @@ public async Task GetReferences_ApiManagementListPolicyFragmentReferences() ResourceIdentifier policyFragmentContractResourceId = PolicyFragmentContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, id); PolicyFragmentContractResource policyFragmentContract = client.GetPolicyFragmentContractResource(policyFragmentContractResourceId); - // invoke the operation and iterate over the result - await foreach (ResourceCollectionValueItem item in policyFragmentContract.GetReferencesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + bool result = await policyFragmentContract.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PortalConfigContractCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PortalConfigContractCollection.cs index 385f645590bf0..87e66a37e2afc 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PortalConfigContractCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PortalConfigContractCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PortalConfigContractCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListPortalConfig() + public async Task CreateOrUpdate_ApiManagementCreatePortalConfig() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPortalConfig.json - // this example is just showing the usage of "PortalConfig_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreatePortalConfig.json + // this example is just showing the usage of "PortalConfig_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,41 @@ public async Task GetAll_ApiManagementListPortalConfig() // get the collection of this PortalConfigContractResource PortalConfigContractCollection collection = apiManagementService.GetPortalConfigContracts(); - // invoke the operation and iterate over the result - await foreach (PortalConfigContractResource item in collection.GetAllAsync()) + // invoke the operation + string portalConfigId = "default"; + ETag ifMatch = new ETag("*"); + PortalConfigContractData data = new PortalConfigContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PortalConfigContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EnableBasicAuth = true, + Require = false, + SignupTermsOfService = new PortalConfigTermsOfServiceProperties + { + Text = "I agree to the service terms and conditions.", + RequireConsent = false, + }, + Delegation = new PortalConfigDelegationProperties + { + DelegateRegistration = false, + DelegateSubscription = false, + DelegationUri = null, + ValidationKey = null, + }, + CorsAllowedOrigins = { "https://contoso.com" }, + Csp = new PortalConfigCspProperties + { + Mode = PortalSettingsCspMode.ReportOnly, + ReportUri = { new Uri("https://report.contoso.com") }, + AllowedSources = { "*.contoso.com" }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, portalConfigId, ifMatch, data); + PortalConfigContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PortalConfigContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +112,10 @@ public async Task Get_ApiManagementPortalConfig() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementPortalConfig() + public async Task GetAll_ApiManagementListPortalConfig() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementPortalConfig.json - // this example is just showing the usage of "PortalConfig_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListPortalConfig.json + // this example is just showing the usage of "PortalConfig_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +133,22 @@ public async Task Exists_ApiManagementPortalConfig() // get the collection of this PortalConfigContractResource PortalConfigContractCollection collection = apiManagementService.GetPortalConfigContracts(); - // invoke the operation - string portalConfigId = "default"; - bool result = await collection.ExistsAsync(portalConfigId); + // invoke the operation and iterate over the result + await foreach (PortalConfigContractResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PortalConfigContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementPortalConfig() + public async Task Exists_ApiManagementPortalConfig() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementPortalConfig.json // this example is just showing the usage of "PortalConfig_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +171,17 @@ public async Task GetIfExists_ApiManagementPortalConfig() // invoke the operation string portalConfigId = "default"; - NullableResponse response = await collection.GetIfExistsAsync(portalConfigId); - PortalConfigContractResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(portalConfigId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PortalConfigContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreatePortalConfig() + public async Task GetIfExists_ApiManagementPortalConfig() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreatePortalConfig.json - // this example is just showing the usage of "PortalConfig_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementPortalConfig.json + // this example is just showing the usage of "PortalConfig_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,48 +201,21 @@ public async Task CreateOrUpdate_ApiManagementCreatePortalConfig() // invoke the operation string portalConfigId = "default"; - ETag ifMatch = new ETag("*"); - PortalConfigContractData data = new PortalConfigContractData() - { - EnableBasicAuth = true, - Require = false, - SignupTermsOfService = new PortalConfigTermsOfServiceProperties() - { - Text = "I agree to the service terms and conditions.", - RequireConsent = false, - }, - Delegation = new PortalConfigDelegationProperties() - { - DelegateRegistration = false, - DelegateSubscription = false, - DelegationUri = null, - ValidationKey = null, - }, - CorsAllowedOrigins = -{ -"https://contoso.com" -}, - Csp = new PortalConfigCspProperties() - { - Mode = PortalSettingsCspMode.ReportOnly, - ReportUri = -{ -new Uri("https://report.contoso.com") -}, - AllowedSources = -{ -"*.contoso.com" -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, portalConfigId, ifMatch, data); - PortalConfigContractResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(portalConfigId); + PortalConfigContractResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PortalConfigContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PortalConfigContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PortalConfigContractResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PortalConfigContractResource.cs index 5809cc8bdb7d0..9dea8de32e4f5 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PortalConfigContractResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_PortalConfigContractResource.cs @@ -16,33 +16,6 @@ namespace Azure.ResourceManager.ApiManagement.Samples { public partial class Sample_PortalConfigContractResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadPortalConfig() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadPortalConfig.json - // this example is just showing the usage of "PortalConfig_GetEntityTag" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PortalConfigContractResource created on azure - // for more information of creating PortalConfigContractResource, please refer to the document of PortalConfigContractResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - string portalConfigId = "default"; - ResourceIdentifier portalConfigContractResourceId = PortalConfigContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, portalConfigId); - PortalConfigContractResource portalConfigContract = client.GetPortalConfigContractResource(portalConfigContractResourceId); - - // invoke the operation - bool result = await portalConfigContract.GetEntityTagAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ApiManagementPortalConfig() @@ -97,37 +70,28 @@ public async Task Update_ApiManagementUpdatePortalConfig() // invoke the operation ETag ifMatch = new ETag("*"); - PortalConfigContractData data = new PortalConfigContractData() + PortalConfigContractData data = new PortalConfigContractData { EnableBasicAuth = true, Require = false, - SignupTermsOfService = new PortalConfigTermsOfServiceProperties() + SignupTermsOfService = new PortalConfigTermsOfServiceProperties { Text = "I agree to the service terms and conditions.", RequireConsent = false, }, - Delegation = new PortalConfigDelegationProperties() + Delegation = new PortalConfigDelegationProperties { DelegateRegistration = false, DelegateSubscription = false, DelegationUri = null, ValidationKey = null, }, - CorsAllowedOrigins = -{ -"https://contoso.com" -}, - Csp = new PortalConfigCspProperties() + CorsAllowedOrigins = { "https://contoso.com" }, + Csp = new PortalConfigCspProperties { Mode = PortalSettingsCspMode.ReportOnly, - ReportUri = -{ -new Uri("https://report.contoso.com") -}, - AllowedSources = -{ -"*.contoso.com" -}, + ReportUri = { new Uri("https://report.contoso.com") }, + AllowedSources = { "*.contoso.com" }, }, }; PortalConfigContractResource result = await portalConfigContract.UpdateAsync(ifMatch, data); @@ -138,5 +102,32 @@ public async Task Update_ApiManagementUpdatePortalConfig() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEntityTag_ApiManagementHeadPortalConfig() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadPortalConfig.json + // this example is just showing the usage of "PortalConfig_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PortalConfigContractResource created on azure + // for more information of creating PortalConfigContractResource, please refer to the document of PortalConfigContractResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + string portalConfigId = "default"; + ResourceIdentifier portalConfigContractResourceId = PortalConfigContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, portalConfigId); + PortalConfigContractResource portalConfigContract = client.GetPortalConfigContractResource(portalConfigContractResourceId); + + // invoke the operation + bool result = await portalConfigContract.GetEntityTagAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ResolverContractCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ResolverContractCollection.cs index a00d65eb40ec3..8f64884e5b477 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ResolverContractCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ResolverContractCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ResolverContractCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListGraphQLApiResolvers() + public async Task CreateOrUpdate_ApiManagementCreateGraphQLApiResolver() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGraphQLApiResolvers.json - // this example is just showing the usage of "GraphQLApiResolver_ListByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGraphQLApiResolver.json + // this example is just showing the usage of "GraphQLApiResolver_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,29 @@ public async Task GetAll_ApiManagementListGraphQLApiResolvers() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "someAPI"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); // get the collection of this ResolverContractResource ResolverContractCollection collection = api.GetResolverContracts(); - // invoke the operation and iterate over the result - await foreach (ResolverContractResource item in collection.GetAllAsync()) + // invoke the operation + string resolverId = "newResolver"; + ResolverContractData data = new ResolverContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResolverContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "Query Users", + Path = "Query/users", + Description = "A GraphQL Resolver example", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resolverId, data); + ResolverContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResolverContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +94,10 @@ public async Task Get_ApiManagementGetGraphQLApiResolver() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetGraphQLApiResolver() + public async Task GetAll_ApiManagementListGraphQLApiResolvers() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGraphQLApiResolver.json - // this example is just showing the usage of "GraphQLApiResolver_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGraphQLApiResolvers.json + // this example is just showing the usage of "GraphQLApiResolver_ListByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +116,22 @@ public async Task Exists_ApiManagementGetGraphQLApiResolver() // get the collection of this ResolverContractResource ResolverContractCollection collection = api.GetResolverContracts(); - // invoke the operation - string resolverId = "57d2ef278aa04f0ad01d6cdc"; - bool result = await collection.ExistsAsync(resolverId); + // invoke the operation and iterate over the result + await foreach (ResolverContractResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResolverContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetGraphQLApiResolver() + public async Task Exists_ApiManagementGetGraphQLApiResolver() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGraphQLApiResolver.json // this example is just showing the usage of "GraphQLApiResolver_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +155,17 @@ public async Task GetIfExists_ApiManagementGetGraphQLApiResolver() // invoke the operation string resolverId = "57d2ef278aa04f0ad01d6cdc"; - NullableResponse response = await collection.GetIfExistsAsync(resolverId); - ResolverContractResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resolverId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResolverContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateGraphQLApiResolver() + public async Task GetIfExists_ApiManagementGetGraphQLApiResolver() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGraphQLApiResolver.json - // this example is just showing the usage of "GraphQLApiResolver_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGraphQLApiResolver.json + // this example is just showing the usage of "GraphQLApiResolver_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,7 +177,7 @@ public async Task CreateOrUpdate_ApiManagementCreateGraphQLApiResolver() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "someAPI"; + string apiId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier apiResourceId = ApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId); ApiResource api = client.GetApiResource(apiResourceId); @@ -186,21 +185,22 @@ public async Task CreateOrUpdate_ApiManagementCreateGraphQLApiResolver() ResolverContractCollection collection = api.GetResolverContracts(); // invoke the operation - string resolverId = "newResolver"; - ResolverContractData data = new ResolverContractData() - { - DisplayName = "Query Users", - Path = "Query/users", - Description = "A GraphQL Resolver example", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resolverId, data); - ResolverContractResource result = lro.Value; + string resolverId = "57d2ef278aa04f0ad01d6cdc"; + NullableResponse response = await collection.GetIfExistsAsync(resolverId); + ResolverContractResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResolverContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResolverContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ResolverContractResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ResolverContractResource.cs index df3690fb711e4..e9b5d3b1aa2f4 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ResolverContractResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ResolverContractResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ResolverContractResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadGraphQLApiResolver() + public async Task Get_ApiManagementGetGraphQLApiResolver() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGraphQLApiResolver.json - // this example is just showing the usage of "GraphQLApiResolver_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGraphQLApiResolver.json + // this example is just showing the usage of "GraphQLApiResolver_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadGraphQLApiResolver() ResolverContractResource resolverContract = client.GetResolverContractResource(resolverContractResourceId); // invoke the operation - bool result = await resolverContract.GetEntityTagAsync(); + ResolverContractResource result = await resolverContract.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ResolverContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetGraphQLApiResolver() + public async Task Delete_ApiManagementDeleteGraphQLApiResolver() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGraphQLApiResolver.json - // this example is just showing the usage of "GraphQLApiResolver_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGraphQLApiResolver.json + // this example is just showing the usage of "GraphQLApiResolver_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,10 @@ public async Task Get_ApiManagementGetGraphQLApiResolver() ResolverContractResource resolverContract = client.GetResolverContractResource(resolverContractResourceId); // invoke the operation - ResolverContractResource result = await resolverContract.GetAsync(); + ETag ifMatch = new ETag("*"); + await resolverContract.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ResolverContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,7 +101,7 @@ public async Task Update_ApiManagementUpdateGraphQLApiResolver() // invoke the operation ETag ifMatch = new ETag("*"); - ResolverContractPatch patch = new ResolverContractPatch() + ResolverContractPatch patch = new ResolverContractPatch { DisplayName = "Query AdminUsers", Path = "Query/adminUsers", @@ -117,10 +118,10 @@ public async Task Update_ApiManagementUpdateGraphQLApiResolver() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteGraphQLApiResolver() + public async Task GetEntityTag_ApiManagementHeadGraphQLApiResolver() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGraphQLApiResolver.json - // this example is just showing the usage of "GraphQLApiResolver_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGraphQLApiResolver.json + // this example is just showing the usage of "GraphQLApiResolver_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,10 +139,9 @@ public async Task Delete_ApiManagementDeleteGraphQLApiResolver() ResolverContractResource resolverContract = client.GetResolverContractResource(resolverContractResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await resolverContract.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await resolverContract.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiResolverPolicyCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiResolverPolicyCollection.cs index 5dc9327659313..d178138d41ab5 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiResolverPolicyCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiResolverPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceApiResolverPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListGraphQLApiResolverPolicies() + public async Task CreateOrUpdate_ApiManagementCreateGraphQLApiResolverPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGraphQLApiResolverPolicies.json - // this example is just showing the usage of "GraphQLApiResolverPolicy_ListByResolver" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGraphQLApiResolverPolicy.json + // this example is just showing the usage of "GraphQLApiResolverPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,25 +33,30 @@ public async Task GetAll_ApiManagementListGraphQLApiResolverPolicies() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "599e2953193c3c0bd0b3e2fa"; - string resolverId = "599e29ab193c3c0bd0b3e2fb"; + string apiId = "5600b57e7e8880006a040001"; + string resolverId = "5600b57e7e8880006a080001"; ResourceIdentifier resolverContractResourceId = ResolverContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, resolverId); ResolverContractResource resolverContract = client.GetResolverContractResource(resolverContractResourceId); // get the collection of this ServiceApiResolverPolicyResource ServiceApiResolverPolicyCollection collection = resolverContract.GetServiceApiResolverPolicies(); - // invoke the operation and iterate over the result - await foreach (ServiceApiResolverPolicyResource item in collection.GetAllAsync()) + // invoke the operation + PolicyName policyId = PolicyName.Policy; + PolicyContractData data = new PolicyContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = "GET/api/users", + Format = PolicyContentFormat.Xml, + }; + ETag? ifMatch = new ETag("*"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); + ServiceApiResolverPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +97,10 @@ public async Task Get_ApiManagementGetGraphQLApiResolverPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetGraphQLApiResolverPolicy() + public async Task GetAll_ApiManagementListGraphQLApiResolverPolicies() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGraphQLApiResolverPolicy.json - // this example is just showing the usage of "GraphQLApiResolverPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListGraphQLApiResolverPolicies.json + // this example is just showing the usage of "GraphQLApiResolverPolicy_ListByResolver" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,24 +112,30 @@ public async Task Exists_ApiManagementGetGraphQLApiResolverPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b539c53f5b0062040001"; - string resolverId = "5600b53ac53f5b0062080006"; + string apiId = "599e2953193c3c0bd0b3e2fa"; + string resolverId = "599e29ab193c3c0bd0b3e2fb"; ResourceIdentifier resolverContractResourceId = ResolverContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, resolverId); ResolverContractResource resolverContract = client.GetResolverContractResource(resolverContractResourceId); // get the collection of this ServiceApiResolverPolicyResource ServiceApiResolverPolicyCollection collection = resolverContract.GetServiceApiResolverPolicies(); - // invoke the operation - PolicyName policyId = PolicyName.Policy; - bool result = await collection.ExistsAsync(policyId); + // invoke the operation and iterate over the result + await foreach (ServiceApiResolverPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetGraphQLApiResolverPolicy() + public async Task Exists_ApiManagementGetGraphQLApiResolverPolicy() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGraphQLApiResolverPolicy.json // this example is just showing the usage of "GraphQLApiResolverPolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +160,17 @@ public async Task GetIfExists_ApiManagementGetGraphQLApiResolverPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - NullableResponse response = await collection.GetIfExistsAsync(policyId); - ServiceApiResolverPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateGraphQLApiResolverPolicy() + public async Task GetIfExists_ApiManagementGetGraphQLApiResolverPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateGraphQLApiResolverPolicy.json - // this example is just showing the usage of "GraphQLApiResolverPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGraphQLApiResolverPolicy.json + // this example is just showing the usage of "GraphQLApiResolverPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,8 +182,8 @@ public async Task CreateOrUpdate_ApiManagementCreateGraphQLApiResolverPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b57e7e8880006a040001"; - string resolverId = "5600b57e7e8880006a080001"; + string apiId = "5600b539c53f5b0062040001"; + string resolverId = "5600b53ac53f5b0062080006"; ResourceIdentifier resolverContractResourceId = ResolverContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, resolverId); ResolverContractResource resolverContract = client.GetResolverContractResource(resolverContractResourceId); @@ -193,20 +192,21 @@ public async Task CreateOrUpdate_ApiManagementCreateGraphQLApiResolverPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = "GET/api/users", - Format = PolicyContentFormat.Xml, - }; - ETag? ifMatch = new ETag("*"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); - ServiceApiResolverPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyId); + ServiceApiResolverPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiResolverPolicyResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiResolverPolicyResource.cs index 17d39b98a53f4..140e8afbd1295 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiResolverPolicyResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiResolverPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceApiResolverPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadGraphQLApiResolverPolicy() + public async Task Get_ApiManagementGetGraphQLApiResolverPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGraphQLApiResolverPolicy.json - // this example is just showing the usage of "GraphQLApiResolverPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGraphQLApiResolverPolicy.json + // this example is just showing the usage of "GraphQLApiResolverPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,21 @@ public async Task GetEntityTag_ApiManagementHeadGraphQLApiResolverPolicy() ServiceApiResolverPolicyResource serviceApiResolverPolicy = client.GetServiceApiResolverPolicyResource(serviceApiResolverPolicyResourceId); // invoke the operation - bool result = await serviceApiResolverPolicy.GetEntityTagAsync(); + ServiceApiResolverPolicyResource result = await serviceApiResolverPolicy.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetGraphQLApiResolverPolicy() + public async Task Delete_ApiManagementDeleteGraphQLApiResolverPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetGraphQLApiResolverPolicy.json - // this example is just showing the usage of "GraphQLApiResolverPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGraphQLApiResolverPolicy.json + // this example is just showing the usage of "GraphQLApiResolverPolicy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,20 +66,17 @@ public async Task Get_ApiManagementGetGraphQLApiResolverPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "5600b539c53f5b0062040001"; - string resolverId = "5600b53ac53f5b0062080006"; + string apiId = "testapi"; + string resolverId = "testResolver"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier serviceApiResolverPolicyResourceId = ServiceApiResolverPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, resolverId, policyId); ServiceApiResolverPolicyResource serviceApiResolverPolicy = client.GetServiceApiResolverPolicyResource(serviceApiResolverPolicyResourceId); // invoke the operation - ServiceApiResolverPolicyResource result = await serviceApiResolverPolicy.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceApiResolverPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -102,7 +103,7 @@ public async Task Update_ApiManagementCreateGraphQLApiResolverPolicy() ServiceApiResolverPolicyResource serviceApiResolverPolicy = client.GetServiceApiResolverPolicyResource(serviceApiResolverPolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = "GET/api/users", Format = PolicyContentFormat.Xml, @@ -120,10 +121,10 @@ public async Task Update_ApiManagementCreateGraphQLApiResolverPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteGraphQLApiResolverPolicy() + public async Task GetEntityTag_ApiManagementHeadGraphQLApiResolverPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteGraphQLApiResolverPolicy.json - // this example is just showing the usage of "GraphQLApiResolverPolicy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadGraphQLApiResolverPolicy.json + // this example is just showing the usage of "GraphQLApiResolverPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,17 +136,16 @@ public async Task Delete_ApiManagementDeleteGraphQLApiResolverPolicy() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string apiId = "testapi"; - string resolverId = "testResolver"; + string apiId = "5600b539c53f5b0062040001"; + string resolverId = "5600b53ac53f5b0062080006"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier serviceApiResolverPolicyResourceId = ServiceApiResolverPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, apiId, resolverId, policyId); ServiceApiResolverPolicyResource serviceApiResolverPolicy = client.GetServiceApiResolverPolicyResource(serviceApiResolverPolicyResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceApiResolverPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceApiResolverPolicy.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiWikiResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiWikiResource.cs index 8a43cf1475bd8..0b725a5ed9e94 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiWikiResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceApiWikiResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceApiWikiResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadApiWiki() + public async Task Get_ApiManagementGetApiWiki() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiWiki.json - // this example is just showing the usage of "ApiWiki_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiWiki.json + // this example is just showing the usage of "ApiWiki_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadApiWiki() ServiceApiWikiResource serviceApiWiki = client.GetServiceApiWikiResource(serviceApiWikiResourceId); // invoke the operation - bool result = await serviceApiWiki.GetEntityTagAsync(); + ServiceApiWikiResource result = await serviceApiWiki.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WikiContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetApiWiki() + public async Task Delete_ApiManagementDeleteApiWiki() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetApiWiki.json - // this example is just showing the usage of "ApiWiki_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiWiki.json + // this example is just showing the usage of "ApiWiki_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,21 +69,18 @@ public async Task Get_ApiManagementGetApiWiki() ServiceApiWikiResource serviceApiWiki = client.GetServiceApiWikiResource(serviceApiWikiResourceId); // invoke the operation - ServiceApiWikiResource result = await serviceApiWiki.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceApiWiki.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WikiContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateApiWiki() + public async Task Update_ApiManagementUpdateApiWiki() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiWiki.json - // this example is just showing the usage of "ApiWiki_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdateApiWiki.json + // this example is just showing the usage of "ApiWiki_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,21 +97,15 @@ public async Task CreateOrUpdate_ApiManagementCreateApiWiki() ServiceApiWikiResource serviceApiWiki = client.GetServiceApiWikiResource(serviceApiWikiResourceId); // invoke the operation - WikiContractData data = new WikiContractData() + ETag ifMatch = new ETag("*"); + WikiUpdateContract wikiUpdateContract = new WikiUpdateContract { - Documents = -{ -new WikiDocumentationContract() + Documents = {new WikiDocumentationContract { DocumentationId = "docId1", -},new WikiDocumentationContract() -{ -DocumentationId = "docId2", -} -}, +}}, }; - ArmOperation lro = await serviceApiWiki.CreateOrUpdateAsync(WaitUntil.Completed, data); - ServiceApiWikiResource result = lro.Value; + ServiceApiWikiResource result = await serviceApiWiki.UpdateAsync(ifMatch, wikiUpdateContract); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -121,10 +116,10 @@ public async Task CreateOrUpdate_ApiManagementCreateApiWiki() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementUpdateApiWiki() + public async Task CreateOrUpdate_ApiManagementCreateApiWiki() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdateApiWiki.json - // this example is just showing the usage of "ApiWiki_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateApiWiki.json + // this example is just showing the usage of "ApiWiki_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,18 +136,18 @@ public async Task Update_ApiManagementUpdateApiWiki() ServiceApiWikiResource serviceApiWiki = client.GetServiceApiWikiResource(serviceApiWikiResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - WikiUpdateContract wikiUpdateContract = new WikiUpdateContract() + WikiContractData data = new WikiContractData { - Documents = -{ -new WikiDocumentationContract() + Documents = {new WikiDocumentationContract { DocumentationId = "docId1", -} -}, +}, new WikiDocumentationContract +{ +DocumentationId = "docId2", +}}, }; - ServiceApiWikiResource result = await serviceApiWiki.UpdateAsync(ifMatch, wikiUpdateContract); + ArmOperation lro = await serviceApiWiki.CreateOrUpdateAsync(WaitUntil.Completed, data); + ServiceApiWikiResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -163,10 +158,10 @@ public async Task Update_ApiManagementUpdateApiWiki() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteApiWiki() + public async Task GetEntityTag_ApiManagementHeadApiWiki() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteApiWiki.json - // this example is just showing the usage of "ApiWiki_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadApiWiki.json + // this example is just showing the usage of "ApiWiki_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,10 +178,9 @@ public async Task Delete_ApiManagementDeleteApiWiki() ServiceApiWikiResource serviceApiWiki = client.GetServiceApiWikiResource(serviceApiWikiResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceApiWiki.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceApiWiki.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductApiLinkCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductApiLinkCollection.cs index c8e8aa2c706d0..041e637b81b3f 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductApiLinkCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductApiLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceProductApiLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListProductApiLinks() + public async Task CreateOrUpdate_ApiManagementCreateProductApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListProductApiLinks.json - // this example is just showing the usage of "ProductApiLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductApiLink.json + // this example is just showing the usage of "ProductApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,27 @@ public async Task GetAll_ApiManagementListProductApiLinks() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "product1"; + string productId = "testproduct"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); // get the collection of this ServiceProductApiLinkResource ServiceProductApiLinkCollection collection = apiManagementProduct.GetServiceProductApiLinks(); - // invoke the operation and iterate over the result - await foreach (ServiceProductApiLinkResource item in collection.GetAllAsync()) + // invoke the operation + string apiLinkId = "link1"; + ProductApiLinkContractData data = new ProductApiLinkContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductApiLinkContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiLinkId, data); + ServiceProductApiLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_ApiManagementGetProductApiLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetProductApiLink() + public async Task GetAll_ApiManagementListProductApiLinks() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductApiLink.json - // this example is just showing the usage of "ProductApiLink_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListProductApiLinks.json + // this example is just showing the usage of "ProductApiLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,23 +107,29 @@ public async Task Exists_ApiManagementGetProductApiLink() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "testproduct"; + string productId = "product1"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); // get the collection of this ServiceProductApiLinkResource ServiceProductApiLinkCollection collection = apiManagementProduct.GetServiceProductApiLinks(); - // invoke the operation - string apiLinkId = "link1"; - bool result = await collection.ExistsAsync(apiLinkId); + // invoke the operation and iterate over the result + await foreach (ServiceProductApiLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductApiLinkContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetProductApiLink() + public async Task Exists_ApiManagementGetProductApiLink() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductApiLink.json // this example is just showing the usage of "ProductApiLink_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +153,17 @@ public async Task GetIfExists_ApiManagementGetProductApiLink() // invoke the operation string apiLinkId = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(apiLinkId); - ServiceProductApiLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(apiLinkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateProductApiLink() + public async Task GetIfExists_ApiManagementGetProductApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductApiLink.json - // this example is just showing the usage of "ProductApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductApiLink.json + // this example is just showing the usage of "ProductApiLink_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +184,21 @@ public async Task CreateOrUpdate_ApiManagementCreateProductApiLink() // invoke the operation string apiLinkId = "link1"; - ProductApiLinkContractData data = new ProductApiLinkContractData() - { - ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiLinkId, data); - ServiceProductApiLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(apiLinkId); + ServiceProductApiLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductApiLinkResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductApiLinkResource.cs index 942d48d35f09e..6d7ddcef62730 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductApiLinkResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductApiLinkResource.cs @@ -49,10 +49,10 @@ public async Task Get_ApiManagementGetProductApiLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateProductApiLink() + public async Task Delete_ApiManagementDeleteProductApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductApiLink.json - // this example is just showing the usage of "ProductApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProductApiLink.json + // this example is just showing the usage of "ProductApiLink_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_ApiManagementCreateProductApiLink() ServiceProductApiLinkResource serviceProductApiLink = client.GetServiceProductApiLinkResource(serviceProductApiLinkResourceId); // invoke the operation - ProductApiLinkContractData data = new ProductApiLinkContractData() - { - ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api", - }; - ArmOperation lro = await serviceProductApiLink.UpdateAsync(WaitUntil.Completed, data); - ServiceProductApiLinkResource result = lro.Value; + await serviceProductApiLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteProductApiLink() + public async Task Update_ApiManagementCreateProductApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProductApiLink.json - // this example is just showing the usage of "ProductApiLink_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductApiLink.json + // this example is just showing the usage of "ProductApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +98,18 @@ public async Task Delete_ApiManagementDeleteProductApiLink() ServiceProductApiLinkResource serviceProductApiLink = client.GetServiceProductApiLinkResource(serviceProductApiLinkResourceId); // invoke the operation - await serviceProductApiLink.DeleteAsync(WaitUntil.Completed); + ProductApiLinkContractData data = new ProductApiLinkContractData + { + ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api", + }; + ArmOperation lro = await serviceProductApiLink.UpdateAsync(WaitUntil.Completed, data); + ServiceProductApiLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductGroupLinkCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductGroupLinkCollection.cs index 4f6a0e1955036..6e9a7cadd958e 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductGroupLinkCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductGroupLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceProductGroupLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListProductGroupLinks() + public async Task CreateOrUpdate_ApiManagementCreateProductGroupLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListProductGroupLinks.json - // this example is just showing the usage of "ProductGroupLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductGroupLink.json + // this example is just showing the usage of "ProductGroupLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,27 @@ public async Task GetAll_ApiManagementListProductGroupLinks() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "product1"; + string productId = "testproduct"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); // get the collection of this ServiceProductGroupLinkResource ServiceProductGroupLinkCollection collection = apiManagementProduct.GetServiceProductGroupLinks(); - // invoke the operation and iterate over the result - await foreach (ServiceProductGroupLinkResource item in collection.GetAllAsync()) + // invoke the operation + string groupLinkId = "link1"; + ProductGroupLinkContractData data = new ProductGroupLinkContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductGroupLinkContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + GroupId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/group1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupLinkId, data); + ServiceProductGroupLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductGroupLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_ApiManagementGetProductGroupLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetProductGroupLink() + public async Task GetAll_ApiManagementListProductGroupLinks() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductGroupLink.json - // this example is just showing the usage of "ProductGroupLink_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListProductGroupLinks.json + // this example is just showing the usage of "ProductGroupLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,23 +107,29 @@ public async Task Exists_ApiManagementGetProductGroupLink() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string productId = "testproduct"; + string productId = "product1"; ResourceIdentifier apiManagementProductResourceId = ApiManagementProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, productId); ApiManagementProductResource apiManagementProduct = client.GetApiManagementProductResource(apiManagementProductResourceId); // get the collection of this ServiceProductGroupLinkResource ServiceProductGroupLinkCollection collection = apiManagementProduct.GetServiceProductGroupLinks(); - // invoke the operation - string groupLinkId = "link1"; - bool result = await collection.ExistsAsync(groupLinkId); + // invoke the operation and iterate over the result + await foreach (ServiceProductGroupLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductGroupLinkContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetProductGroupLink() + public async Task Exists_ApiManagementGetProductGroupLink() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductGroupLink.json // this example is just showing the usage of "ProductGroupLink_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +153,17 @@ public async Task GetIfExists_ApiManagementGetProductGroupLink() // invoke the operation string groupLinkId = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(groupLinkId); - ServiceProductGroupLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(groupLinkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductGroupLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateProductGroupLink() + public async Task GetIfExists_ApiManagementGetProductGroupLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductGroupLink.json - // this example is just showing the usage of "ProductGroupLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductGroupLink.json + // this example is just showing the usage of "ProductGroupLink_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +184,21 @@ public async Task CreateOrUpdate_ApiManagementCreateProductGroupLink() // invoke the operation string groupLinkId = "link1"; - ProductGroupLinkContractData data = new ProductGroupLinkContractData() - { - GroupId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/group1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupLinkId, data); - ServiceProductGroupLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(groupLinkId); + ServiceProductGroupLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductGroupLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductGroupLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductGroupLinkResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductGroupLinkResource.cs index 003a9cad9e116..bfdee34f72af9 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductGroupLinkResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductGroupLinkResource.cs @@ -49,10 +49,10 @@ public async Task Get_ApiManagementGetProductGroupLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateProductGroupLink() + public async Task Delete_ApiManagementDeleteProductGroupLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductGroupLink.json - // this example is just showing the usage of "ProductGroupLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProductGroupLink.json + // this example is just showing the usage of "ProductGroupLink_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_ApiManagementCreateProductGroupLink() ServiceProductGroupLinkResource serviceProductGroupLink = client.GetServiceProductGroupLinkResource(serviceProductGroupLinkResourceId); // invoke the operation - ProductGroupLinkContractData data = new ProductGroupLinkContractData() - { - GroupId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/group1", - }; - ArmOperation lro = await serviceProductGroupLink.UpdateAsync(WaitUntil.Completed, data); - ServiceProductGroupLinkResource result = lro.Value; + await serviceProductGroupLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductGroupLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteProductGroupLink() + public async Task Update_ApiManagementCreateProductGroupLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProductGroupLink.json - // this example is just showing the usage of "ProductGroupLink_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductGroupLink.json + // this example is just showing the usage of "ProductGroupLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +98,18 @@ public async Task Delete_ApiManagementDeleteProductGroupLink() ServiceProductGroupLinkResource serviceProductGroupLink = client.GetServiceProductGroupLinkResource(serviceProductGroupLinkResourceId); // invoke the operation - await serviceProductGroupLink.DeleteAsync(WaitUntil.Completed); + ProductGroupLinkContractData data = new ProductGroupLinkContractData + { + GroupId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/groups/group1", + }; + ArmOperation lro = await serviceProductGroupLink.UpdateAsync(WaitUntil.Completed, data); + ServiceProductGroupLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductGroupLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductWikiResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductWikiResource.cs index 19a6d9c704cb3..51ca89535844e 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductWikiResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceProductWikiResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceProductWikiResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadProductWiki() + public async Task Get_ApiManagementGetProductWiki() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadProductWiki.json - // this example is just showing the usage of "ProductWiki_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductWiki.json + // this example is just showing the usage of "ProductWiki_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetEntityTag_ApiManagementHeadProductWiki() ServiceProductWikiResource serviceProductWiki = client.GetServiceProductWikiResource(serviceProductWikiResourceId); // invoke the operation - bool result = await serviceProductWiki.GetEntityTagAsync(); + ServiceProductWikiResource result = await serviceProductWiki.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WikiContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetProductWiki() + public async Task Delete_ApiManagementDeleteProductWiki() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetProductWiki.json - // this example is just showing the usage of "ProductWiki_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProductWiki.json + // this example is just showing the usage of "ProductWiki_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,21 +69,18 @@ public async Task Get_ApiManagementGetProductWiki() ServiceProductWikiResource serviceProductWiki = client.GetServiceProductWikiResource(serviceProductWikiResourceId); // invoke the operation - ServiceProductWikiResource result = await serviceProductWiki.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceProductWiki.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WikiContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateProductWiki() + public async Task Update_ApiManagementUpdateProductWiki() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductWiki.json - // this example is just showing the usage of "ProductWiki_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdateProductWiki.json + // this example is just showing the usage of "ProductWiki_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,21 +97,15 @@ public async Task CreateOrUpdate_ApiManagementCreateProductWiki() ServiceProductWikiResource serviceProductWiki = client.GetServiceProductWikiResource(serviceProductWikiResourceId); // invoke the operation - WikiContractData data = new WikiContractData() + ETag ifMatch = new ETag("*"); + WikiUpdateContract wikiUpdateContract = new WikiUpdateContract { - Documents = -{ -new WikiDocumentationContract() + Documents = {new WikiDocumentationContract { DocumentationId = "docId1", -},new WikiDocumentationContract() -{ -DocumentationId = "docId2", -} -}, +}}, }; - ArmOperation lro = await serviceProductWiki.CreateOrUpdateAsync(WaitUntil.Completed, data); - ServiceProductWikiResource result = lro.Value; + ServiceProductWikiResource result = await serviceProductWiki.UpdateAsync(ifMatch, wikiUpdateContract); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -121,10 +116,10 @@ public async Task CreateOrUpdate_ApiManagementCreateProductWiki() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementUpdateProductWiki() + public async Task CreateOrUpdate_ApiManagementCreateProductWiki() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementUpdateProductWiki.json - // this example is just showing the usage of "ProductWiki_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateProductWiki.json + // this example is just showing the usage of "ProductWiki_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,18 +136,18 @@ public async Task Update_ApiManagementUpdateProductWiki() ServiceProductWikiResource serviceProductWiki = client.GetServiceProductWikiResource(serviceProductWikiResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - WikiUpdateContract wikiUpdateContract = new WikiUpdateContract() + WikiContractData data = new WikiContractData { - Documents = -{ -new WikiDocumentationContract() + Documents = {new WikiDocumentationContract { DocumentationId = "docId1", -} -}, +}, new WikiDocumentationContract +{ +DocumentationId = "docId2", +}}, }; - ServiceProductWikiResource result = await serviceProductWiki.UpdateAsync(ifMatch, wikiUpdateContract); + ArmOperation lro = await serviceProductWiki.CreateOrUpdateAsync(WaitUntil.Completed, data); + ServiceProductWikiResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -163,10 +158,10 @@ public async Task Update_ApiManagementUpdateProductWiki() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteProductWiki() + public async Task GetEntityTag_ApiManagementHeadProductWiki() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteProductWiki.json - // this example is just showing the usage of "ProductWiki_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadProductWiki.json + // this example is just showing the usage of "ProductWiki_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,10 +178,9 @@ public async Task Delete_ApiManagementDeleteProductWiki() ServiceProductWikiResource serviceProductWiki = client.GetServiceProductWikiResource(serviceProductWikiResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceProductWiki.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceProductWiki.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagApiLinkCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagApiLinkCollection.cs index 0e154b0b89704..103e650881943 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagApiLinkCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagApiLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceTagApiLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListTagApiLinks() + public async Task CreateOrUpdate_ApiManagementCreateTagApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTagApiLinks.json - // this example is just showing the usage of "TagApiLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagApiLink.json + // this example is just showing the usage of "TagApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ApiManagementListTagApiLinks() // get the collection of this ServiceTagApiLinkResource ServiceTagApiLinkCollection collection = apiManagementTag.GetServiceTagApiLinks(); - // invoke the operation and iterate over the result - await foreach (ServiceTagApiLinkResource item in collection.GetAllAsync()) + // invoke the operation + string apiLinkId = "link1"; + TagApiLinkContractData data = new TagApiLinkContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagApiLinkContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiLinkId, data); + ServiceTagApiLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_ApiManagementGetTagApiLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetTagApiLink() + public async Task GetAll_ApiManagementListTagApiLinks() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTagApiLink.json - // this example is just showing the usage of "TagApiLink_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTagApiLinks.json + // this example is just showing the usage of "TagApiLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +114,22 @@ public async Task Exists_ApiManagementGetTagApiLink() // get the collection of this ServiceTagApiLinkResource ServiceTagApiLinkCollection collection = apiManagementTag.GetServiceTagApiLinks(); - // invoke the operation - string apiLinkId = "link1"; - bool result = await collection.ExistsAsync(apiLinkId); + // invoke the operation and iterate over the result + await foreach (ServiceTagApiLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagApiLinkContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetTagApiLink() + public async Task Exists_ApiManagementGetTagApiLink() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTagApiLink.json // this example is just showing the usage of "TagApiLink_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +153,17 @@ public async Task GetIfExists_ApiManagementGetTagApiLink() // invoke the operation string apiLinkId = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(apiLinkId); - ServiceTagApiLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(apiLinkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateTagApiLink() + public async Task GetIfExists_ApiManagementGetTagApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagApiLink.json - // this example is just showing the usage of "TagApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTagApiLink.json + // this example is just showing the usage of "TagApiLink_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +184,21 @@ public async Task CreateOrUpdate_ApiManagementCreateTagApiLink() // invoke the operation string apiLinkId = "link1"; - TagApiLinkContractData data = new TagApiLinkContractData() - { - ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiLinkId, data); - ServiceTagApiLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(apiLinkId); + ServiceTagApiLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagApiLinkResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagApiLinkResource.cs index aec6d106a1951..3f643b4ce49f9 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagApiLinkResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagApiLinkResource.cs @@ -49,10 +49,10 @@ public async Task Get_ApiManagementGetTagApiLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateTagApiLink() + public async Task Delete_ApiManagementDeleteTagApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagApiLink.json - // this example is just showing the usage of "TagApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteTagApiLink.json + // this example is just showing the usage of "TagApiLink_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_ApiManagementCreateTagApiLink() ServiceTagApiLinkResource serviceTagApiLink = client.GetServiceTagApiLinkResource(serviceTagApiLinkResourceId); // invoke the operation - TagApiLinkContractData data = new TagApiLinkContractData() - { - ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api", - }; - ArmOperation lro = await serviceTagApiLink.UpdateAsync(WaitUntil.Completed, data); - ServiceTagApiLinkResource result = lro.Value; + await serviceTagApiLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteTagApiLink() + public async Task Update_ApiManagementCreateTagApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteTagApiLink.json - // this example is just showing the usage of "TagApiLink_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagApiLink.json + // this example is just showing the usage of "TagApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +98,18 @@ public async Task Delete_ApiManagementDeleteTagApiLink() ServiceTagApiLinkResource serviceTagApiLink = client.GetServiceTagApiLinkResource(serviceTagApiLinkResourceId); // invoke the operation - await serviceTagApiLink.DeleteAsync(WaitUntil.Completed); + TagApiLinkContractData data = new TagApiLinkContractData + { + ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api", + }; + ArmOperation lro = await serviceTagApiLink.UpdateAsync(WaitUntil.Completed, data); + ServiceTagApiLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagOperationLinkCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagOperationLinkCollection.cs index 18079afb3808b..df821a6ab8ec4 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagOperationLinkCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagOperationLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceTagOperationLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListTagOperationLinks() + public async Task CreateOrUpdate_ApiManagementCreateTagOperationLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTagOperationLinks.json - // this example is just showing the usage of "TagOperationLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagOperationLink.json + // this example is just showing the usage of "TagOperationLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ApiManagementListTagOperationLinks() // get the collection of this ServiceTagOperationLinkResource ServiceTagOperationLinkCollection collection = apiManagementTag.GetServiceTagOperationLinks(); - // invoke the operation and iterate over the result - await foreach (ServiceTagOperationLinkResource item in collection.GetAllAsync()) + // invoke the operation + string operationLinkId = "link1"; + TagOperationLinkContractData data = new TagOperationLinkContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagOperationLinkContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + OperationId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api/operations/op1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, operationLinkId, data); + ServiceTagOperationLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagOperationLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_ApiManagementGetTagOperationLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetTagOperationLink() + public async Task GetAll_ApiManagementListTagOperationLinks() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTagOperationLink.json - // this example is just showing the usage of "TagOperationLink_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTagOperationLinks.json + // this example is just showing the usage of "TagOperationLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +114,22 @@ public async Task Exists_ApiManagementGetTagOperationLink() // get the collection of this ServiceTagOperationLinkResource ServiceTagOperationLinkCollection collection = apiManagementTag.GetServiceTagOperationLinks(); - // invoke the operation - string operationLinkId = "link1"; - bool result = await collection.ExistsAsync(operationLinkId); + // invoke the operation and iterate over the result + await foreach (ServiceTagOperationLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagOperationLinkContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetTagOperationLink() + public async Task Exists_ApiManagementGetTagOperationLink() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTagOperationLink.json // this example is just showing the usage of "TagOperationLink_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +153,17 @@ public async Task GetIfExists_ApiManagementGetTagOperationLink() // invoke the operation string operationLinkId = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(operationLinkId); - ServiceTagOperationLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(operationLinkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagOperationLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateTagOperationLink() + public async Task GetIfExists_ApiManagementGetTagOperationLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagOperationLink.json - // this example is just showing the usage of "TagOperationLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTagOperationLink.json + // this example is just showing the usage of "TagOperationLink_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +184,21 @@ public async Task CreateOrUpdate_ApiManagementCreateTagOperationLink() // invoke the operation string operationLinkId = "link1"; - TagOperationLinkContractData data = new TagOperationLinkContractData() - { - OperationId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api/operations/op1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, operationLinkId, data); - ServiceTagOperationLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(operationLinkId); + ServiceTagOperationLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagOperationLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagOperationLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagOperationLinkResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagOperationLinkResource.cs index 7cd2ff946a958..d41cfd4fd28f5 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagOperationLinkResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagOperationLinkResource.cs @@ -49,10 +49,10 @@ public async Task Get_ApiManagementGetTagOperationLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateTagOperationLink() + public async Task Delete_ApiManagementDeleteTagOperationLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagOperationLink.json - // this example is just showing the usage of "TagOperationLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteTagOperationLink.json + // this example is just showing the usage of "TagOperationLink_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_ApiManagementCreateTagOperationLink() ServiceTagOperationLinkResource serviceTagOperationLink = client.GetServiceTagOperationLinkResource(serviceTagOperationLinkResourceId); // invoke the operation - TagOperationLinkContractData data = new TagOperationLinkContractData() - { - OperationId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api/operations/op1", - }; - ArmOperation lro = await serviceTagOperationLink.UpdateAsync(WaitUntil.Completed, data); - ServiceTagOperationLinkResource result = lro.Value; + await serviceTagOperationLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagOperationLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteTagOperationLink() + public async Task Update_ApiManagementCreateTagOperationLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteTagOperationLink.json - // this example is just showing the usage of "TagOperationLink_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagOperationLink.json + // this example is just showing the usage of "TagOperationLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +98,18 @@ public async Task Delete_ApiManagementDeleteTagOperationLink() ServiceTagOperationLinkResource serviceTagOperationLink = client.GetServiceTagOperationLinkResource(serviceTagOperationLinkResourceId); // invoke the operation - await serviceTagOperationLink.DeleteAsync(WaitUntil.Completed); + TagOperationLinkContractData data = new TagOperationLinkContractData + { + OperationId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/apis/echo-api/operations/op1", + }; + ArmOperation lro = await serviceTagOperationLink.UpdateAsync(WaitUntil.Completed, data); + ServiceTagOperationLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagOperationLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagProductLinkCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagProductLinkCollection.cs index 78d16b4936be3..8392157f01132 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagProductLinkCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagProductLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceTagProductLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListTagProductLinks() + public async Task CreateOrUpdate_ApiManagementCreateTagProductLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTagProductLinks.json - // this example is just showing the usage of "TagProductLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagProductLink.json + // this example is just showing the usage of "TagProductLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ApiManagementListTagProductLinks() // get the collection of this ServiceTagProductLinkResource ServiceTagProductLinkCollection collection = apiManagementTag.GetServiceTagProductLinks(); - // invoke the operation and iterate over the result - await foreach (ServiceTagProductLinkResource item in collection.GetAllAsync()) + // invoke the operation + string productLinkId = "link1"; + TagProductLinkContractData data = new TagProductLinkContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagProductLinkContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProductId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/product1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, productLinkId, data); + ServiceTagProductLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagProductLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_ApiManagementGetTagProductLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetTagProductLink() + public async Task GetAll_ApiManagementListTagProductLinks() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTagProductLink.json - // this example is just showing the usage of "TagProductLink_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTagProductLinks.json + // this example is just showing the usage of "TagProductLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +114,22 @@ public async Task Exists_ApiManagementGetTagProductLink() // get the collection of this ServiceTagProductLinkResource ServiceTagProductLinkCollection collection = apiManagementTag.GetServiceTagProductLinks(); - // invoke the operation - string productLinkId = "link1"; - bool result = await collection.ExistsAsync(productLinkId); + // invoke the operation and iterate over the result + await foreach (ServiceTagProductLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagProductLinkContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetTagProductLink() + public async Task Exists_ApiManagementGetTagProductLink() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTagProductLink.json // this example is just showing the usage of "TagProductLink_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +153,17 @@ public async Task GetIfExists_ApiManagementGetTagProductLink() // invoke the operation string productLinkId = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(productLinkId); - ServiceTagProductLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(productLinkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagProductLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateTagProductLink() + public async Task GetIfExists_ApiManagementGetTagProductLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagProductLink.json - // this example is just showing the usage of "TagProductLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTagProductLink.json + // this example is just showing the usage of "TagProductLink_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +184,21 @@ public async Task CreateOrUpdate_ApiManagementCreateTagProductLink() // invoke the operation string productLinkId = "link1"; - TagProductLinkContractData data = new TagProductLinkContractData() - { - ProductId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/product1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, productLinkId, data); - ServiceTagProductLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(productLinkId); + ServiceTagProductLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagProductLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagProductLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagProductLinkResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagProductLinkResource.cs index e405eb2d0615f..7c03d9455bb92 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagProductLinkResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceTagProductLinkResource.cs @@ -49,10 +49,10 @@ public async Task Get_ApiManagementGetTagProductLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateTagProductLink() + public async Task Delete_ApiManagementDeleteTagProductLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagProductLink.json - // this example is just showing the usage of "TagProductLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteTagProductLink.json + // this example is just showing the usage of "TagProductLink_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_ApiManagementCreateTagProductLink() ServiceTagProductLinkResource serviceTagProductLink = client.GetServiceTagProductLinkResource(serviceTagProductLinkResourceId); // invoke the operation - TagProductLinkContractData data = new TagProductLinkContractData() - { - ProductId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/product1", - }; - ArmOperation lro = await serviceTagProductLink.UpdateAsync(WaitUntil.Completed, data); - ServiceTagProductLinkResource result = lro.Value; + await serviceTagProductLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagProductLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteTagProductLink() + public async Task Update_ApiManagementCreateTagProductLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteTagProductLink.json - // this example is just showing the usage of "TagProductLink_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTagProductLink.json + // this example is just showing the usage of "TagProductLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +98,18 @@ public async Task Delete_ApiManagementDeleteTagProductLink() ServiceTagProductLinkResource serviceTagProductLink = client.GetServiceTagProductLinkResource(serviceTagProductLinkResourceId); // invoke the operation - await serviceTagProductLink.DeleteAsync(WaitUntil.Completed); + TagProductLinkContractData data = new TagProductLinkContractData + { + ProductId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/products/product1", + }; + ArmOperation lro = await serviceTagProductLink.UpdateAsync(WaitUntil.Completed, data); + ServiceTagProductLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagProductLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiCollection.cs index 6a5cfb675f0b6..0676d8be9cd85 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceApiCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceApis() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApi() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApis.json - // this example is just showing the usage of "WorkspaceApi_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApi.json + // this example is just showing the usage of "WorkspaceApi_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,37 @@ public async Task GetAll_ApiManagementListWorkspaceApis() // get the collection of this ServiceWorkspaceApiResource ServiceWorkspaceApiCollection collection = workspaceContract.GetServiceWorkspaceApis(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceApiResource item in collection.GetAllAsync()) + // invoke the operation + string apiId = "tempgroup"; + ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "apidescription5200", + AuthenticationSettings = new AuthenticationSettingsContract + { + OAuth2 = new OAuth2AuthenticationSettingsContract + { + AuthorizationServerId = "authorizationServerId2283", + Scope = "oauth2scope2580", + }, + }, + SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract + { + Header = "header4520", + Query = "query3037", + }, + DisplayName = "apiname1463", + ServiceLink = "http://newechoapi.cloudapp.net/api", + Path = "newapiPath", + Protocols = { ApiOperationInvokableProtocol.Https, ApiOperationInvokableProtocol.Http }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId, content); + ServiceWorkspaceApiResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,9 +110,9 @@ public async Task Get_ApiManagementGetWorkspaceApiContract() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceApiContract() + public async Task Get_ApiManagementGetWorkspaceApiRevision() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiContract.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRevision.json // this example is just showing the usage of "WorkspaceApi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -113,18 +133,22 @@ public async Task Exists_ApiManagementGetWorkspaceApiContract() ServiceWorkspaceApiCollection collection = workspaceContract.GetServiceWorkspaceApis(); // invoke the operation - string apiId = "57d1f7558aa04f15146d9d8a"; - bool result = await collection.ExistsAsync(apiId); + string apiId = "echo-api;rev=3"; + ServiceWorkspaceApiResource result = await collection.GetAsync(apiId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceApiContract() + public async Task GetAll_ApiManagementListWorkspaceApis() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiContract.json - // this example is just showing the usage of "WorkspaceApi_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApis.json + // this example is just showing the usage of "WorkspaceApi_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,30 +167,24 @@ public async Task GetIfExists_ApiManagementGetWorkspaceApiContract() // get the collection of this ServiceWorkspaceApiResource ServiceWorkspaceApiCollection collection = workspaceContract.GetServiceWorkspaceApis(); - // invoke the operation - string apiId = "57d1f7558aa04f15146d9d8a"; - NullableResponse response = await collection.GetIfExistsAsync(apiId); - ServiceWorkspaceApiResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceApiResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApiData resourceData = result.Data; + ApiData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceApiRevision() + public async Task Exists_ApiManagementGetWorkspaceApiContract() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRevision.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiContract.json // this example is just showing the usage of "WorkspaceApi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -187,14 +205,10 @@ public async Task Get_ApiManagementGetWorkspaceApiRevision() ServiceWorkspaceApiCollection collection = workspaceContract.GetServiceWorkspaceApis(); // invoke the operation - string apiId = "echo-api;rev=3"; - ServiceWorkspaceApiResource result = await collection.GetAsync(apiId); + string apiId = "57d1f7558aa04f15146d9d8a"; + bool result = await collection.ExistsAsync(apiId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -230,9 +244,9 @@ public async Task Exists_ApiManagementGetWorkspaceApiRevision() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceApiRevision() + public async Task GetIfExists_ApiManagementGetWorkspaceApiContract() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRevision.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiContract.json // this example is just showing the usage of "WorkspaceApi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -253,7 +267,7 @@ public async Task GetIfExists_ApiManagementGetWorkspaceApiRevision() ServiceWorkspaceApiCollection collection = workspaceContract.GetServiceWorkspaceApis(); // invoke the operation - string apiId = "echo-api;rev=3"; + string apiId = "57d1f7558aa04f15146d9d8a"; NullableResponse response = await collection.GetIfExistsAsync(apiId); ServiceWorkspaceApiResource result = response.HasValue ? response.Value : null; @@ -273,10 +287,10 @@ public async Task GetIfExists_ApiManagementGetWorkspaceApiRevision() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApi() + public async Task GetIfExists_ApiManagementGetWorkspaceApiRevision() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApi.json - // this example is just showing the usage of "WorkspaceApi_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRevision.json + // this example is just showing the usage of "WorkspaceApi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -296,39 +310,22 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApi() ServiceWorkspaceApiCollection collection = workspaceContract.GetServiceWorkspaceApis(); // invoke the operation - string apiId = "tempgroup"; - ApiCreateOrUpdateContent content = new ApiCreateOrUpdateContent() - { - Description = "apidescription5200", - AuthenticationSettings = new AuthenticationSettingsContract() - { - OAuth2 = new OAuth2AuthenticationSettingsContract() - { - AuthorizationServerId = "authorizationServerId2283", - Scope = "oauth2scope2580", - }, - }, - SubscriptionKeyParameterNames = new SubscriptionKeyParameterNamesContract() - { - Header = "header4520", - Query = "query3037", - }, - DisplayName = "apiname1463", - ServiceLink = "http://newechoapi.cloudapp.net/api", - Path = "newapiPath", - Protocols = -{ -ApiOperationInvokableProtocol.Https,ApiOperationInvokableProtocol.Http -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiId, content); - ServiceWorkspaceApiResource result = lro.Value; + string apiId = "echo-api;rev=3"; + NullableResponse response = await collection.GetIfExistsAsync(apiId); + ServiceWorkspaceApiResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationCollection.cs index 48f3ecb35f652..2bc0661fc3aa8 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceApiOperationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceApiOperations() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiOperations.json - // this example is just showing the usage of "WorkspaceApiOperation_ListByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiOperation.json + // this example is just showing the usage of "WorkspaceApiOperation_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,24 +34,48 @@ public async Task GetAll_ApiManagementListWorkspaceApiOperations() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "PetStoreTemplate2"; ResourceIdentifier serviceWorkspaceApiResourceId = ServiceWorkspaceApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId); ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); // get the collection of this ServiceWorkspaceApiOperationResource ServiceWorkspaceApiOperationCollection collection = serviceWorkspaceApi.GetServiceWorkspaceApiOperations(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceApiOperationResource item in collection.GetAllAsync()) + // invoke the operation + string operationId = "newoperations"; + ApiOperationData data = new ApiOperationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiOperationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TemplateParameters = { }, + Description = "This can only be done by the logged in user.", + Request = new RequestContract + { + Description = "Created user object", + QueryParameters = { }, + Headers = { }, + Representations = {new RepresentationContract("application/json") +{ +SchemaId = "592f6c1d0af5840ca8897f0c", +TypeName = "User", +}}, + }, + Responses = {new ResponseContract(200) +{ +Description = "successful operation", +Representations = {new RepresentationContract("application/xml"), new RepresentationContract("application/json")}, +Headers = {}, +}}, + DisplayName = "createUser2", + Method = "POST", + UriTemplate = "/user1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, operationId, data); + ServiceWorkspaceApiOperationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +116,10 @@ public async Task Get_ApiManagementGetWorkspaceApiOperation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceApiOperation() + public async Task GetAll_ApiManagementListWorkspaceApiOperations() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiOperation.json - // this example is just showing the usage of "WorkspaceApiOperation_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiOperations.json + // this example is just showing the usage of "WorkspaceApiOperation_ListByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +139,22 @@ public async Task Exists_ApiManagementGetWorkspaceApiOperation() // get the collection of this ServiceWorkspaceApiOperationResource ServiceWorkspaceApiOperationCollection collection = serviceWorkspaceApi.GetServiceWorkspaceApiOperations(); - // invoke the operation - string operationId = "57d2ef278aa04f0ad01d6cdc"; - bool result = await collection.ExistsAsync(operationId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceApiOperationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiOperationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceApiOperation() + public async Task Exists_ApiManagementGetWorkspaceApiOperation() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiOperation.json // this example is just showing the usage of "WorkspaceApiOperation_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +179,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceApiOperation() // invoke the operation string operationId = "57d2ef278aa04f0ad01d6cdc"; - NullableResponse response = await collection.GetIfExistsAsync(operationId); - ServiceWorkspaceApiOperationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(operationId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiOperation() + public async Task GetIfExists_ApiManagementGetWorkspaceApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiOperation.json - // this example is just showing the usage of "WorkspaceApiOperation_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiOperation.json + // this example is just showing the usage of "WorkspaceApiOperation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,7 +202,7 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiOperation() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "PetStoreTemplate2"; + string apiId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier serviceWorkspaceApiResourceId = ServiceWorkspaceApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId); ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); @@ -192,57 +210,22 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiOperation() ServiceWorkspaceApiOperationCollection collection = serviceWorkspaceApi.GetServiceWorkspaceApiOperations(); // invoke the operation - string operationId = "newoperations"; - ApiOperationData data = new ApiOperationData() - { - TemplateParameters = -{ -}, - Description = "This can only be done by the logged in user.", - Request = new RequestContract() - { - Description = "Created user object", - QueryParameters = -{ -}, - Headers = -{ -}, - Representations = -{ -new RepresentationContract("application/json") -{ -SchemaId = "592f6c1d0af5840ca8897f0c", -TypeName = "User", -} -}, - }, - Responses = -{ -new ResponseContract(200) -{ -Description = "successful operation", -Representations = -{ -new RepresentationContract("application/xml"),new RepresentationContract("application/json") -}, -Headers = -{ -}, -} -}, - DisplayName = "createUser2", - Method = "POST", - UriTemplate = "/user1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, operationId, data); - ServiceWorkspaceApiOperationResource result = lro.Value; + string operationId = "57d2ef278aa04f0ad01d6cdc"; + NullableResponse response = await collection.GetIfExistsAsync(operationId); + ServiceWorkspaceApiOperationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationPolicyCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationPolicyCollection.cs index 6f66f6a0e70a3..d2f9aa332a302 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationPolicyCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceApiOperationPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceApiOperationPolicies() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiOperationPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiOperationPolicies.json - // this example is just showing the usage of "WorkspaceApiOperationPolicy_ListByOperation" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiOperationPolicy.json + // this example is just showing the usage of "WorkspaceApiOperationPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,25 +34,30 @@ public async Task GetAll_ApiManagementListWorkspaceApiOperationPolicies() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "599e2953193c3c0bd0b3e2fa"; - string operationId = "599e29ab193c3c0bd0b3e2fb"; + string apiId = "5600b57e7e8880006a040001"; + string operationId = "5600b57e7e8880006a080001"; ResourceIdentifier serviceWorkspaceApiOperationResourceId = ServiceWorkspaceApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, operationId); ServiceWorkspaceApiOperationResource serviceWorkspaceApiOperation = client.GetServiceWorkspaceApiOperationResource(serviceWorkspaceApiOperationResourceId); // get the collection of this ServiceWorkspaceApiOperationPolicyResource ServiceWorkspaceApiOperationPolicyCollection collection = serviceWorkspaceApiOperation.GetServiceWorkspaceApiOperationPolicies(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceApiOperationPolicyResource item in collection.GetAllAsync()) + // invoke the operation + PolicyName policyId = PolicyName.Policy; + PolicyContractData data = new PolicyContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = " ", + Format = PolicyContentFormat.Xml, + }; + ETag? ifMatch = new ETag("*"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); + ServiceWorkspaceApiOperationPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -94,10 +99,10 @@ public async Task Get_ApiManagementGetWorkspaceApiOperationPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceApiOperationPolicy() + public async Task GetAll_ApiManagementListWorkspaceApiOperationPolicies() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiOperationPolicy.json - // this example is just showing the usage of "WorkspaceApiOperationPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiOperationPolicies.json + // this example is just showing the usage of "WorkspaceApiOperationPolicy_ListByOperation" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,24 +115,30 @@ public async Task Exists_ApiManagementGetWorkspaceApiOperationPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "5600b539c53f5b0062040001"; - string operationId = "5600b53ac53f5b0062080006"; + string apiId = "599e2953193c3c0bd0b3e2fa"; + string operationId = "599e29ab193c3c0bd0b3e2fb"; ResourceIdentifier serviceWorkspaceApiOperationResourceId = ServiceWorkspaceApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, operationId); ServiceWorkspaceApiOperationResource serviceWorkspaceApiOperation = client.GetServiceWorkspaceApiOperationResource(serviceWorkspaceApiOperationResourceId); // get the collection of this ServiceWorkspaceApiOperationPolicyResource ServiceWorkspaceApiOperationPolicyCollection collection = serviceWorkspaceApiOperation.GetServiceWorkspaceApiOperationPolicies(); - // invoke the operation - PolicyName policyId = PolicyName.Policy; - bool result = await collection.ExistsAsync(policyId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceApiOperationPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceApiOperationPolicy() + public async Task Exists_ApiManagementGetWorkspaceApiOperationPolicy() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiOperationPolicy.json // this example is just showing the usage of "WorkspaceApiOperationPolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -153,29 +164,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceApiOperationPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - NullableResponse response = await collection.GetIfExistsAsync(policyId); - ServiceWorkspaceApiOperationPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiOperationPolicy() + public async Task GetIfExists_ApiManagementGetWorkspaceApiOperationPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiOperationPolicy.json - // this example is just showing the usage of "WorkspaceApiOperationPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiOperationPolicy.json + // this example is just showing the usage of "WorkspaceApiOperationPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,8 +187,8 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiOperationPolicy( string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "5600b57e7e8880006a040001"; - string operationId = "5600b57e7e8880006a080001"; + string apiId = "5600b539c53f5b0062040001"; + string operationId = "5600b53ac53f5b0062080006"; ResourceIdentifier serviceWorkspaceApiOperationResourceId = ServiceWorkspaceApiOperationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, operationId); ServiceWorkspaceApiOperationResource serviceWorkspaceApiOperation = client.GetServiceWorkspaceApiOperationResource(serviceWorkspaceApiOperationResourceId); @@ -198,20 +197,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiOperationPolicy( // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = " ", - Format = PolicyContentFormat.Xml, - }; - ETag? ifMatch = new ETag("*"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); - ServiceWorkspaceApiOperationPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyId); + ServiceWorkspaceApiOperationPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationPolicyResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationPolicyResource.cs index 345e19a46f5de..e4a17e13afb57 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationPolicyResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceApiOperationPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceApiOperationPolicy() + public async Task Get_ApiManagementGetWorkspaceApiOperationPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiOperationPolicy.json - // this example is just showing the usage of "WorkspaceApiOperationPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiOperationPolicy.json + // this example is just showing the usage of "WorkspaceApiOperationPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,21 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceApiOperationPolicy() ServiceWorkspaceApiOperationPolicyResource serviceWorkspaceApiOperationPolicy = client.GetServiceWorkspaceApiOperationPolicyResource(serviceWorkspaceApiOperationPolicyResourceId); // invoke the operation - bool result = await serviceWorkspaceApiOperationPolicy.GetEntityTagAsync(); + ServiceWorkspaceApiOperationPolicyResource result = await serviceWorkspaceApiOperationPolicy.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceApiOperationPolicy() + public async Task Delete_ApiManagementDeleteWorkspaceApiOperationPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiOperationPolicy.json - // this example is just showing the usage of "WorkspaceApiOperationPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiOperationPolicy.json + // this example is just showing the usage of "WorkspaceApiOperationPolicy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,20 +68,17 @@ public async Task Get_ApiManagementGetWorkspaceApiOperationPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "5600b539c53f5b0062040001"; - string operationId = "5600b53ac53f5b0062080006"; + string apiId = "testapi"; + string operationId = "testoperation"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier serviceWorkspaceApiOperationPolicyResourceId = ServiceWorkspaceApiOperationPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, operationId, policyId); ServiceWorkspaceApiOperationPolicyResource serviceWorkspaceApiOperationPolicy = client.GetServiceWorkspaceApiOperationPolicyResource(serviceWorkspaceApiOperationPolicyResourceId); // invoke the operation - ServiceWorkspaceApiOperationPolicyResource result = await serviceWorkspaceApiOperationPolicy.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceApiOperationPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -105,7 +106,7 @@ public async Task Update_ApiManagementCreateWorkspaceApiOperationPolicy() ServiceWorkspaceApiOperationPolicyResource serviceWorkspaceApiOperationPolicy = client.GetServiceWorkspaceApiOperationPolicyResource(serviceWorkspaceApiOperationPolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = " ", Format = PolicyContentFormat.Xml, @@ -123,10 +124,10 @@ public async Task Update_ApiManagementCreateWorkspaceApiOperationPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceApiOperationPolicy() + public async Task GetEntityTag_ApiManagementHeadWorkspaceApiOperationPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiOperationPolicy.json - // this example is just showing the usage of "WorkspaceApiOperationPolicy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiOperationPolicy.json + // this example is just showing the usage of "WorkspaceApiOperationPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,17 +140,16 @@ public async Task Delete_ApiManagementDeleteWorkspaceApiOperationPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "testapi"; - string operationId = "testoperation"; + string apiId = "5600b539c53f5b0062040001"; + string operationId = "5600b53ac53f5b0062080006"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier serviceWorkspaceApiOperationPolicyResourceId = ServiceWorkspaceApiOperationPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, operationId, policyId); ServiceWorkspaceApiOperationPolicyResource serviceWorkspaceApiOperationPolicy = client.GetServiceWorkspaceApiOperationPolicyResource(serviceWorkspaceApiOperationPolicyResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceApiOperationPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceWorkspaceApiOperationPolicy.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationResource.cs index 1ce543d139dde..92a0386b139ea 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiOperationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceApiOperationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceApiOperation() + public async Task Get_ApiManagementGetWorkspaceApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiOperation.json - // this example is just showing the usage of "WorkspaceApiOperation_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiOperation.json + // this example is just showing the usage of "WorkspaceApiOperation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,21 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceApiOperation() ServiceWorkspaceApiOperationResource serviceWorkspaceApiOperation = client.GetServiceWorkspaceApiOperationResource(serviceWorkspaceApiOperationResourceId); // invoke the operation - bool result = await serviceWorkspaceApiOperation.GetEntityTagAsync(); + ServiceWorkspaceApiOperationResource result = await serviceWorkspaceApiOperation.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceApiOperation() + public async Task Delete_ApiManagementDeleteWorkspaceApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiOperation.json - // this example is just showing the usage of "WorkspaceApiOperation_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiOperation.json + // this example is just showing the usage of "WorkspaceApiOperation_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,13 +73,10 @@ public async Task Get_ApiManagementGetWorkspaceApiOperation() ServiceWorkspaceApiOperationResource serviceWorkspaceApiOperation = client.GetServiceWorkspaceApiOperationResource(serviceWorkspaceApiOperationResourceId); // invoke the operation - ServiceWorkspaceApiOperationResource result = await serviceWorkspaceApiOperation.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceApiOperation.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -103,49 +104,30 @@ public async Task Update_ApiManagementUpdateWorkspaceApiOperation() // invoke the operation ETag ifMatch = new ETag("*"); - ApiOperationPatch patch = new ApiOperationPatch() + ApiOperationPatch patch = new ApiOperationPatch { - TemplateParameters = -{ -}, - Request = new RequestContract() + TemplateParameters = { }, + Request = new RequestContract { - QueryParameters = -{ -new ParameterContract("param1","string") + QueryParameters = {new ParameterContract("param1", "string") { Description = "A sample parameter that is required and has a default value of \"sample\".", DefaultValue = "sample", IsRequired = true, -Values = -{ -"sample" -}, -} -}, +Values = {"sample"}, +}}, }, - Responses = -{ -new ResponseContract(200) + Responses = {new ResponseContract(200) { Description = "Returned in all cases.", -Representations = -{ -}, -Headers = -{ -}, -},new ResponseContract(500) +Representations = {}, +Headers = {}, +}, new ResponseContract(500) { Description = "Server Error.", -Representations = -{ -}, -Headers = -{ -}, -} -}, +Representations = {}, +Headers = {}, +}}, DisplayName = "Retrieve resource", Method = "GET", UriTemplate = "/resource", @@ -161,10 +143,10 @@ public async Task Update_ApiManagementUpdateWorkspaceApiOperation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceApiOperation() + public async Task GetEntityTag_ApiManagementHeadWorkspaceApiOperation() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiOperation.json - // this example is just showing the usage of "WorkspaceApiOperation_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiOperation.json + // this example is just showing the usage of "WorkspaceApiOperation_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,10 +165,9 @@ public async Task Delete_ApiManagementDeleteWorkspaceApiOperation() ServiceWorkspaceApiOperationResource serviceWorkspaceApiOperation = client.GetServiceWorkspaceApiOperationResource(serviceWorkspaceApiOperationResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceApiOperation.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceWorkspaceApiOperation.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiPolicyCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiPolicyCollection.cs index dc7f9b2d858fc..ecc100c9cad60 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiPolicyCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceApiPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceApiPolicies() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiPolicies.json - // this example is just showing the usage of "WorkspaceApiPolicy_ListByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiPolicy.json + // this example is just showing the usage of "WorkspaceApiPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,24 +34,29 @@ public async Task GetAll_ApiManagementListWorkspaceApiPolicies() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "5600b59475ff190048040001"; + string apiId = "5600b57e7e8880006a040001"; ResourceIdentifier serviceWorkspaceApiResourceId = ServiceWorkspaceApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId); ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); // get the collection of this ServiceWorkspaceApiPolicyResource ServiceWorkspaceApiPolicyCollection collection = serviceWorkspaceApi.GetServiceWorkspaceApiPolicies(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceApiPolicyResource item in collection.GetAllAsync()) + // invoke the operation + PolicyName policyId = PolicyName.Policy; + PolicyContractData data = new PolicyContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = " ", + Format = PolicyContentFormat.Xml, + }; + ETag? ifMatch = new ETag("*"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); + ServiceWorkspaceApiPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +97,10 @@ public async Task Get_ApiManagementGetWorkspaceApiPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceApiPolicy() + public async Task GetAll_ApiManagementListWorkspaceApiPolicies() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiPolicy.json - // this example is just showing the usage of "WorkspaceApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiPolicies.json + // this example is just showing the usage of "WorkspaceApiPolicy_ListByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +120,22 @@ public async Task Exists_ApiManagementGetWorkspaceApiPolicy() // get the collection of this ServiceWorkspaceApiPolicyResource ServiceWorkspaceApiPolicyCollection collection = serviceWorkspaceApi.GetServiceWorkspaceApiPolicies(); - // invoke the operation - PolicyName policyId = PolicyName.Policy; - bool result = await collection.ExistsAsync(policyId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceApiPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceApiPolicy() + public async Task Exists_ApiManagementGetWorkspaceApiPolicy() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiPolicy.json // this example is just showing the usage of "WorkspaceApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +160,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceApiPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - NullableResponse response = await collection.GetIfExistsAsync(policyId); - ServiceWorkspaceApiPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiPolicy() + public async Task GetIfExists_ApiManagementGetWorkspaceApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiPolicy.json - // this example is just showing the usage of "WorkspaceApiPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiPolicy.json + // this example is just showing the usage of "WorkspaceApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,7 +183,7 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "5600b57e7e8880006a040001"; + string apiId = "5600b59475ff190048040001"; ResourceIdentifier serviceWorkspaceApiResourceId = ServiceWorkspaceApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId); ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); @@ -193,20 +192,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = " ", - Format = PolicyContentFormat.Xml, - }; - ETag? ifMatch = new ETag("*"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); - ServiceWorkspaceApiPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyId); + ServiceWorkspaceApiPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiPolicyResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiPolicyResource.cs index 7a237cc6393bc..c145e01bef8a4 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiPolicyResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceApiPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceApiPolicy() + public async Task Get_ApiManagementGetWorkspaceApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiPolicy.json - // this example is just showing the usage of "WorkspaceApiPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiPolicy.json + // this example is just showing the usage of "WorkspaceApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,23 +34,27 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceApiPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "5600b59475ff190048040001"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier serviceWorkspaceApiPolicyResourceId = ServiceWorkspaceApiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, policyId); ServiceWorkspaceApiPolicyResource serviceWorkspaceApiPolicy = client.GetServiceWorkspaceApiPolicyResource(serviceWorkspaceApiPolicyResourceId); // invoke the operation - bool result = await serviceWorkspaceApiPolicy.GetEntityTagAsync(); + ServiceWorkspaceApiPolicyResource result = await serviceWorkspaceApiPolicy.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceApiPolicy() + public async Task Delete_ApiManagementDeleteWorkspaceApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiPolicy.json - // this example is just showing the usage of "WorkspaceApiPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiPolicy.json + // this example is just showing the usage of "WorkspaceApiPolicy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,19 +67,16 @@ public async Task Get_ApiManagementGetWorkspaceApiPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "5600b59475ff190048040001"; + string apiId = "loggerId"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier serviceWorkspaceApiPolicyResourceId = ServiceWorkspaceApiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, policyId); ServiceWorkspaceApiPolicyResource serviceWorkspaceApiPolicy = client.GetServiceWorkspaceApiPolicyResource(serviceWorkspaceApiPolicyResourceId); // invoke the operation - ServiceWorkspaceApiPolicyResource result = await serviceWorkspaceApiPolicy.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceApiPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -102,7 +103,7 @@ public async Task Update_ApiManagementCreateWorkspaceApiPolicy() ServiceWorkspaceApiPolicyResource serviceWorkspaceApiPolicy = client.GetServiceWorkspaceApiPolicyResource(serviceWorkspaceApiPolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = " ", Format = PolicyContentFormat.Xml, @@ -120,10 +121,10 @@ public async Task Update_ApiManagementCreateWorkspaceApiPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceApiPolicy() + public async Task GetEntityTag_ApiManagementHeadWorkspaceApiPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiPolicy.json - // this example is just showing the usage of "WorkspaceApiPolicy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiPolicy.json + // this example is just showing the usage of "WorkspaceApiPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,16 +137,15 @@ public async Task Delete_ApiManagementDeleteWorkspaceApiPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "loggerId"; + string apiId = "57d1f7558aa04f15146d9d8a"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier serviceWorkspaceApiPolicyResourceId = ServiceWorkspaceApiPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, policyId); ServiceWorkspaceApiPolicyResource serviceWorkspaceApiPolicy = client.GetServiceWorkspaceApiPolicyResource(serviceWorkspaceApiPolicyResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceApiPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceWorkspaceApiPolicy.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiReleaseCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiReleaseCollection.cs index 3828d1b7ba6ce..9e528c304f37a 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiReleaseCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiReleaseCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceWorkspaceApiReleaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceApiReleases() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiRelease() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiReleases.json - // this example is just showing the usage of "WorkspaceApiRelease_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiRelease.json + // this example is just showing the usage of "WorkspaceApiRelease_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,21 @@ public async Task GetAll_ApiManagementListWorkspaceApiReleases() // get the collection of this ServiceWorkspaceApiReleaseResource ServiceWorkspaceApiReleaseCollection collection = serviceWorkspaceApi.GetServiceWorkspaceApiReleases(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceApiReleaseResource item in collection.GetAllAsync()) + // invoke the operation + string releaseId = "testrev"; + ApiReleaseData data = new ApiReleaseData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiReleaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ApiId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/a1"), + Notes = "yahooagain", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, releaseId, data); + ServiceWorkspaceApiReleaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiReleaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +95,10 @@ public async Task Get_ApiManagementGetWorkspaceApiRelease() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceApiRelease() + public async Task GetAll_ApiManagementListWorkspaceApiReleases() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRelease.json - // this example is just showing the usage of "WorkspaceApiRelease_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiReleases.json + // this example is just showing the usage of "WorkspaceApiRelease_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +118,22 @@ public async Task Exists_ApiManagementGetWorkspaceApiRelease() // get the collection of this ServiceWorkspaceApiReleaseResource ServiceWorkspaceApiReleaseCollection collection = serviceWorkspaceApi.GetServiceWorkspaceApiReleases(); - // invoke the operation - string releaseId = "5a7cb545298324c53224a799"; - bool result = await collection.ExistsAsync(releaseId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceApiReleaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiReleaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceApiRelease() + public async Task Exists_ApiManagementGetWorkspaceApiRelease() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRelease.json // this example is just showing the usage of "WorkspaceApiRelease_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +158,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceApiRelease() // invoke the operation string releaseId = "5a7cb545298324c53224a799"; - NullableResponse response = await collection.GetIfExistsAsync(releaseId); - ServiceWorkspaceApiReleaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(releaseId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiReleaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiRelease() + public async Task GetIfExists_ApiManagementGetWorkspaceApiRelease() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiRelease.json - // this example is just showing the usage of "WorkspaceApiRelease_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRelease.json + // this example is just showing the usage of "WorkspaceApiRelease_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,20 +189,22 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiRelease() ServiceWorkspaceApiReleaseCollection collection = serviceWorkspaceApi.GetServiceWorkspaceApiReleases(); // invoke the operation - string releaseId = "testrev"; - ApiReleaseData data = new ApiReleaseData() - { - ApiId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/a1"), - Notes = "yahooagain", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, releaseId, data); - ServiceWorkspaceApiReleaseResource result = lro.Value; + string releaseId = "5a7cb545298324c53224a799"; + NullableResponse response = await collection.GetIfExistsAsync(releaseId); + ServiceWorkspaceApiReleaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiReleaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiReleaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiReleaseResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiReleaseResource.cs index e45755720ee27..3ab4187055fc3 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiReleaseResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiReleaseResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceWorkspaceApiReleaseResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceApiRelease() + public async Task Get_ApiManagementGetWorkspaceApiRelease() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiRelease.json - // this example is just showing the usage of "WorkspaceApiRelease_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRelease.json + // this example is just showing the usage of "WorkspaceApiRelease_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceApiRelease() ServiceWorkspaceApiReleaseResource serviceWorkspaceApiRelease = client.GetServiceWorkspaceApiReleaseResource(serviceWorkspaceApiReleaseResourceId); // invoke the operation - bool result = await serviceWorkspaceApiRelease.GetEntityTagAsync(); + ServiceWorkspaceApiReleaseResource result = await serviceWorkspaceApiRelease.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiReleaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceApiRelease() + public async Task Delete_ApiManagementDeleteWorkspaceApiRelease() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRelease.json - // this example is just showing the usage of "WorkspaceApiRelease_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiRelease.json + // this example is just showing the usage of "WorkspaceApiRelease_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,19 +66,16 @@ public async Task Get_ApiManagementGetWorkspaceApiRelease() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "a1"; - string releaseId = "5a7cb545298324c53224a799"; + string apiId = "5a5fcc09124a7fa9b89f2f1d"; + string releaseId = "testrev"; ResourceIdentifier serviceWorkspaceApiReleaseResourceId = ServiceWorkspaceApiReleaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, releaseId); ServiceWorkspaceApiReleaseResource serviceWorkspaceApiRelease = client.GetServiceWorkspaceApiReleaseResource(serviceWorkspaceApiReleaseResourceId); // invoke the operation - ServiceWorkspaceApiReleaseResource result = await serviceWorkspaceApiRelease.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceApiRelease.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiReleaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -102,7 +103,7 @@ public async Task Update_ApiManagementUpdateWorkspaceApiRelease() // invoke the operation ETag ifMatch = new ETag("*"); - ApiReleaseData data = new ApiReleaseData() + ApiReleaseData data = new ApiReleaseData { ApiId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/a1"), Notes = "yahooagain", @@ -118,10 +119,10 @@ public async Task Update_ApiManagementUpdateWorkspaceApiRelease() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceApiRelease() + public async Task GetEntityTag_ApiManagementHeadWorkspaceApiRelease() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiRelease.json - // this example is just showing the usage of "WorkspaceApiRelease_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiRelease.json + // this example is just showing the usage of "WorkspaceApiRelease_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,16 +135,15 @@ public async Task Delete_ApiManagementDeleteWorkspaceApiRelease() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "5a5fcc09124a7fa9b89f2f1d"; - string releaseId = "testrev"; + string apiId = "a1"; + string releaseId = "5a7cb545298324c53224a799"; ResourceIdentifier serviceWorkspaceApiReleaseResourceId = ServiceWorkspaceApiReleaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, releaseId); ServiceWorkspaceApiReleaseResource serviceWorkspaceApiRelease = client.GetServiceWorkspaceApiReleaseResource(serviceWorkspaceApiReleaseResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceApiRelease.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceWorkspaceApiRelease.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiResource.cs index 125bdbc4be890..b8c2457ec5411 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceApiResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceApi() + public async Task Get_ApiManagementGetWorkspaceApiContract() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApi.json - // this example is just showing the usage of "WorkspaceApi_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiContract.json + // this example is just showing the usage of "WorkspaceApi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,16 +39,20 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceApi() ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); // invoke the operation - bool result = await serviceWorkspaceApi.GetEntityTagAsync(); + ServiceWorkspaceApiResource result = await serviceWorkspaceApi.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceApiContract() + public async Task Get_ApiManagementGetWorkspaceApiRevision() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiContract.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRevision.json // this example is just showing the usage of "WorkspaceApi_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -62,7 +66,7 @@ public async Task Get_ApiManagementGetWorkspaceApiContract() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "echo-api;rev=3"; ResourceIdentifier serviceWorkspaceApiResourceId = ServiceWorkspaceApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId); ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); @@ -78,10 +82,10 @@ public async Task Get_ApiManagementGetWorkspaceApiContract() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceApiRevision() + public async Task Delete_ApiManagementDeleteWorkspaceApi() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiRevision.json - // this example is just showing the usage of "WorkspaceApi_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApi.json + // this example is just showing the usage of "WorkspaceApi_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,18 +98,15 @@ public async Task Get_ApiManagementGetWorkspaceApiRevision() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "echo-api;rev=3"; + string apiId = "echo-api"; ResourceIdentifier serviceWorkspaceApiResourceId = ServiceWorkspaceApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId); ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); // invoke the operation - ServiceWorkspaceApiResource result = await serviceWorkspaceApi.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceApi.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -132,7 +133,7 @@ public async Task Update_ApiManagementUpdateWorkspaceApi() // invoke the operation ETag ifMatch = new ETag("*"); - ApiPatch patch = new ApiPatch() + ApiPatch patch = new ApiPatch { DisplayName = "Echo API New", ServiceLink = "http://echoapi.cloudapp.net/api2", @@ -149,10 +150,10 @@ public async Task Update_ApiManagementUpdateWorkspaceApi() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceApi() + public async Task GetWorkspaceApiRevisionsByService_ApiManagementListWorkspaceApiRevisions() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApi.json - // this example is just showing the usage of "WorkspaceApi_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiRevisions.json + // this example is just showing the usage of "WorkspaceApiRevision_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,23 +166,25 @@ public async Task Delete_ApiManagementDeleteWorkspaceApi() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "echo-api"; + string apiId = "57d2ef278aa04f0888cba3f3"; ResourceIdentifier serviceWorkspaceApiResourceId = ServiceWorkspaceApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId); ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); - // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceApi.DeleteAsync(WaitUntil.Completed, ifMatch); + // invoke the operation and iterate over the result + await foreach (ApiRevisionContract item in serviceWorkspaceApi.GetWorkspaceApiRevisionsByServiceAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetWorkspaceApiRevisionsByService_ApiManagementListWorkspaceApiRevisions() + public async Task GetEntityTag_ApiManagementHeadWorkspaceApi() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiRevisions.json - // this example is just showing the usage of "WorkspaceApiRevision_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApi.json + // this example is just showing the usage of "WorkspaceApi_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -194,17 +197,14 @@ public async Task GetWorkspaceApiRevisionsByService_ApiManagementListWorkspaceAp string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "57d2ef278aa04f0888cba3f3"; + string apiId = "57d1f7558aa04f15146d9d8a"; ResourceIdentifier serviceWorkspaceApiResourceId = ServiceWorkspaceApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId); ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); - // invoke the operation and iterate over the result - await foreach (ApiRevisionContract item in serviceWorkspaceApi.GetWorkspaceApiRevisionsByServiceAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + bool result = await serviceWorkspaceApi.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiSchemaCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiSchemaCollection.cs index 37c2f76fb0a6a..45697d2bd4c0a 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiSchemaCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiSchemaCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceWorkspaceApiSchemaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceApiSchemas() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiSchemas.json - // this example is just showing the usage of "WorkspaceApiSchema_ListByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiSchema.json + // this example is just showing the usage of "WorkspaceApiSchema_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,24 +33,28 @@ public async Task GetAll_ApiManagementListWorkspaceApiSchemas() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "59d5b28d1f7fab116c282650"; + string apiId = "59d6bb8f1f7fab13dc67ec9b"; ResourceIdentifier serviceWorkspaceApiResourceId = ServiceWorkspaceApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId); ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); // get the collection of this ServiceWorkspaceApiSchemaResource ServiceWorkspaceApiSchemaCollection collection = serviceWorkspaceApi.GetServiceWorkspaceApiSchemas(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceApiSchemaResource item in collection.GetAllAsync()) + // invoke the operation + string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; + ApiSchemaData data = new ApiSchemaData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiSchemaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ContentType = "application/vnd.ms-azure-apim.xsd+xml", + Value = "\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaId, data); + ServiceWorkspaceApiSchemaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +95,10 @@ public async Task Get_ApiManagementGetWorkspaceApiSchema() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceApiSchema() + public async Task GetAll_ApiManagementListWorkspaceApiSchemas() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiSchema.json - // this example is just showing the usage of "WorkspaceApiSchema_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiSchemas.json + // this example is just showing the usage of "WorkspaceApiSchema_ListByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,23 +111,29 @@ public async Task Exists_ApiManagementGetWorkspaceApiSchema() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "59d6bb8f1f7fab13dc67ec9b"; + string apiId = "59d5b28d1f7fab116c282650"; ResourceIdentifier serviceWorkspaceApiResourceId = ServiceWorkspaceApiResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId); ServiceWorkspaceApiResource serviceWorkspaceApi = client.GetServiceWorkspaceApiResource(serviceWorkspaceApiResourceId); // get the collection of this ServiceWorkspaceApiSchemaResource ServiceWorkspaceApiSchemaCollection collection = serviceWorkspaceApi.GetServiceWorkspaceApiSchemas(); - // invoke the operation - string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; - bool result = await collection.ExistsAsync(schemaId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceApiSchemaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiSchemaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceApiSchema() + public async Task Exists_ApiManagementGetWorkspaceApiSchema() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiSchema.json // this example is just showing the usage of "WorkspaceApiSchema_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +158,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceApiSchema() // invoke the operation string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; - NullableResponse response = await collection.GetIfExistsAsync(schemaId); - ServiceWorkspaceApiSchemaResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(schemaId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiSchema() + public async Task GetIfExists_ApiManagementGetWorkspaceApiSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiSchema.json - // this example is just showing the usage of "WorkspaceApiSchema_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiSchema.json + // this example is just showing the usage of "WorkspaceApiSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,19 +190,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiSchema() // invoke the operation string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; - ApiSchemaData data = new ApiSchemaData() - { - ContentType = "application/vnd.ms-azure-apim.xsd+xml", - Value = "\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaId, data); - ServiceWorkspaceApiSchemaResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(schemaId); + ServiceWorkspaceApiSchemaResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiSchemaResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiSchemaResource.cs index 391c264b9a9b0..00e5ee5dd3663 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiSchemaResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiSchemaResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceWorkspaceApiSchemaResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceApiSchema() + public async Task Get_ApiManagementGetWorkspaceApiSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiSchema.json - // this example is just showing the usage of "WorkspaceApiSchema_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiSchema.json + // this example is just showing the usage of "WorkspaceApiSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,23 +33,27 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceApiSchema() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "57d1f7558aa04f15146d9d8a"; + string apiId = "59d6bb8f1f7fab13dc67ec9b"; string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; ResourceIdentifier serviceWorkspaceApiSchemaResourceId = ServiceWorkspaceApiSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, schemaId); ServiceWorkspaceApiSchemaResource serviceWorkspaceApiSchema = client.GetServiceWorkspaceApiSchemaResource(serviceWorkspaceApiSchemaResourceId); // invoke the operation - bool result = await serviceWorkspaceApiSchema.GetEntityTagAsync(); + ServiceWorkspaceApiSchemaResource result = await serviceWorkspaceApiSchema.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceApiSchema() + public async Task Delete_ApiManagementDeleteWorkspaceApiSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiSchema.json - // this example is just showing the usage of "WorkspaceApiSchema_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiSchema.json + // this example is just showing the usage of "WorkspaceApiSchema_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,19 +66,16 @@ public async Task Get_ApiManagementGetWorkspaceApiSchema() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "59d6bb8f1f7fab13dc67ec9b"; - string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; + string apiId = "59d5b28d1f7fab116c282650"; + string schemaId = "59d5b28e1f7fab116402044e"; ResourceIdentifier serviceWorkspaceApiSchemaResourceId = ServiceWorkspaceApiSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, schemaId); ServiceWorkspaceApiSchemaResource serviceWorkspaceApiSchema = client.GetServiceWorkspaceApiSchemaResource(serviceWorkspaceApiSchemaResourceId); // invoke the operation - ServiceWorkspaceApiSchemaResource result = await serviceWorkspaceApiSchema.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceApiSchema.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -101,7 +102,7 @@ public async Task Update_ApiManagementCreateWorkspaceApiSchema() ServiceWorkspaceApiSchemaResource serviceWorkspaceApiSchema = client.GetServiceWorkspaceApiSchemaResource(serviceWorkspaceApiSchemaResourceId); // invoke the operation - ApiSchemaData data = new ApiSchemaData() + ApiSchemaData data = new ApiSchemaData { ContentType = "application/vnd.ms-azure-apim.xsd+xml", Value = "\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", @@ -118,10 +119,10 @@ public async Task Update_ApiManagementCreateWorkspaceApiSchema() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceApiSchema() + public async Task GetEntityTag_ApiManagementHeadWorkspaceApiSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiSchema.json - // this example is just showing the usage of "WorkspaceApiSchema_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiSchema.json + // this example is just showing the usage of "WorkspaceApiSchema_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,16 +135,15 @@ public async Task Delete_ApiManagementDeleteWorkspaceApiSchema() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string apiId = "59d5b28d1f7fab116c282650"; - string schemaId = "59d5b28e1f7fab116402044e"; + string apiId = "57d1f7558aa04f15146d9d8a"; + string schemaId = "ec12520d-9d48-4e7b-8f39-698ca2ac63f1"; ResourceIdentifier serviceWorkspaceApiSchemaResourceId = ServiceWorkspaceApiSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, apiId, schemaId); ServiceWorkspaceApiSchemaResource serviceWorkspaceApiSchema = client.GetServiceWorkspaceApiSchemaResource(serviceWorkspaceApiSchemaResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceApiSchema.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceWorkspaceApiSchema.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiVersionSetCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiVersionSetCollection.cs index 5cc45bf02c5d2..6f005ea888869 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiVersionSetCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiVersionSetCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceApiVersionSetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceApiVersionSets() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiVersionSet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiVersionSets.json - // this example is just showing the usage of "WorkspaceApiVersionSet_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiVersionSet.json + // this example is just showing the usage of "WorkspaceApiVersionSet_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,22 @@ public async Task GetAll_ApiManagementListWorkspaceApiVersionSets() // get the collection of this ServiceWorkspaceApiVersionSetResource ServiceWorkspaceApiVersionSetCollection collection = workspaceContract.GetServiceWorkspaceApiVersionSets(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceApiVersionSetResource item in collection.GetAllAsync()) + // invoke the operation + string versionSetId = "api1"; + ApiVersionSetData data = new ApiVersionSetData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiVersionSetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "Version configuration", + DisplayName = "api set 1", + VersioningScheme = VersioningScheme.Segment, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, versionSetId, data); + ServiceWorkspaceApiVersionSetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiVersionSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +95,10 @@ public async Task Get_ApiManagementGetWorkspaceApiVersionSet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceApiVersionSet() + public async Task GetAll_ApiManagementListWorkspaceApiVersionSets() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiVersionSet.json - // this example is just showing the usage of "WorkspaceApiVersionSet_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceApiVersionSets.json + // this example is just showing the usage of "WorkspaceApiVersionSet_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +117,22 @@ public async Task Exists_ApiManagementGetWorkspaceApiVersionSet() // get the collection of this ServiceWorkspaceApiVersionSetResource ServiceWorkspaceApiVersionSetCollection collection = workspaceContract.GetServiceWorkspaceApiVersionSets(); - // invoke the operation - string versionSetId = "vs1"; - bool result = await collection.ExistsAsync(versionSetId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceApiVersionSetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiVersionSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceApiVersionSet() + public async Task Exists_ApiManagementGetWorkspaceApiVersionSet() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiVersionSet.json // this example is just showing the usage of "WorkspaceApiVersionSet_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +156,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceApiVersionSet() // invoke the operation string versionSetId = "vs1"; - NullableResponse response = await collection.GetIfExistsAsync(versionSetId); - ServiceWorkspaceApiVersionSetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(versionSetId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiVersionSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiVersionSet() + public async Task GetIfExists_ApiManagementGetWorkspaceApiVersionSet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceApiVersionSet.json - // this example is just showing the usage of "WorkspaceApiVersionSet_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiVersionSet.json + // this example is just showing the usage of "WorkspaceApiVersionSet_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,21 +186,22 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceApiVersionSet() ServiceWorkspaceApiVersionSetCollection collection = workspaceContract.GetServiceWorkspaceApiVersionSets(); // invoke the operation - string versionSetId = "api1"; - ApiVersionSetData data = new ApiVersionSetData() - { - Description = "Version configuration", - DisplayName = "api set 1", - VersioningScheme = VersioningScheme.Segment, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, versionSetId, data); - ServiceWorkspaceApiVersionSetResource result = lro.Value; + string versionSetId = "vs1"; + NullableResponse response = await collection.GetIfExistsAsync(versionSetId); + ServiceWorkspaceApiVersionSetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiVersionSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiVersionSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiVersionSetResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiVersionSetResource.cs index 44bdfc3511b67..ea86d94a85561 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiVersionSetResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceApiVersionSetResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceApiVersionSetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceApiVersionSet() + public async Task Get_ApiManagementGetWorkspaceApiVersionSet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiVersionSet.json - // this example is just showing the usage of "WorkspaceApiVersionSet_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiVersionSet.json + // this example is just showing the usage of "WorkspaceApiVersionSet_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceApiVersionSet() ServiceWorkspaceApiVersionSetResource serviceWorkspaceApiVersionSet = client.GetServiceWorkspaceApiVersionSetResource(serviceWorkspaceApiVersionSetResourceId); // invoke the operation - bool result = await serviceWorkspaceApiVersionSet.GetEntityTagAsync(); + ServiceWorkspaceApiVersionSetResource result = await serviceWorkspaceApiVersionSet.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiVersionSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceApiVersionSet() + public async Task Delete_ApiManagementDeleteWorkspaceApiVersionSet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceApiVersionSet.json - // this example is just showing the usage of "WorkspaceApiVersionSet_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiVersionSet.json + // this example is just showing the usage of "WorkspaceApiVersionSet_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,18 +66,15 @@ public async Task Get_ApiManagementGetWorkspaceApiVersionSet() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string versionSetId = "vs1"; + string versionSetId = "a1"; ResourceIdentifier serviceWorkspaceApiVersionSetResourceId = ServiceWorkspaceApiVersionSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, versionSetId); ServiceWorkspaceApiVersionSetResource serviceWorkspaceApiVersionSet = client.GetServiceWorkspaceApiVersionSetResource(serviceWorkspaceApiVersionSetResourceId); // invoke the operation - ServiceWorkspaceApiVersionSetResource result = await serviceWorkspaceApiVersionSet.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceApiVersionSet.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiVersionSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,7 +101,7 @@ public async Task Update_ApiManagementUpdateWorkspaceApiVersionSet() // invoke the operation ETag ifMatch = new ETag("*"); - ApiVersionSetPatch patch = new ApiVersionSetPatch() + ApiVersionSetPatch patch = new ApiVersionSetPatch { Description = "Version configuration", DisplayName = "api set 1", @@ -117,10 +118,10 @@ public async Task Update_ApiManagementUpdateWorkspaceApiVersionSet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceApiVersionSet() + public async Task GetEntityTag_ApiManagementHeadWorkspaceApiVersionSet() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceApiVersionSet.json - // this example is just showing the usage of "WorkspaceApiVersionSet_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceApiVersionSet.json + // this example is just showing the usage of "WorkspaceApiVersionSet_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,15 +134,14 @@ public async Task Delete_ApiManagementDeleteWorkspaceApiVersionSet() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string versionSetId = "a1"; + string versionSetId = "vs1"; ResourceIdentifier serviceWorkspaceApiVersionSetResourceId = ServiceWorkspaceApiVersionSetResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, versionSetId); ServiceWorkspaceApiVersionSetResource serviceWorkspaceApiVersionSet = client.GetServiceWorkspaceApiVersionSetResource(serviceWorkspaceApiVersionSetResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceApiVersionSet.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceWorkspaceApiVersionSet.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceGroupCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceGroupCollection.cs index ca2e00db5c377..e9f575eb19459 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceGroupCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceGroups() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceGroups.json - // this example is just showing the usage of "WorkspaceGroup_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceGroup.json + // this example is just showing the usage of "WorkspaceGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,28 @@ public async Task GetAll_ApiManagementListWorkspaceGroups() // get the collection of this ServiceWorkspaceGroupResource ServiceWorkspaceGroupCollection collection = workspaceContract.GetServiceWorkspaceGroups(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceGroupResource item in collection.GetAllAsync()) + // invoke the operation + string groupId = "tempgroup"; + ApiManagementGroupCreateOrUpdateContent content = new ApiManagementGroupCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "temp group", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content); + ServiceWorkspaceGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceGroup() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceGroupExternal() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceGroup.json - // this example is just showing the usage of "WorkspaceGroup_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceGroupExternal.json + // this example is just showing the usage of "WorkspaceGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,8 +81,16 @@ public async Task Get_ApiManagementGetWorkspaceGroup() ServiceWorkspaceGroupCollection collection = workspaceContract.GetServiceWorkspaceGroups(); // invoke the operation - string groupId = "59306a29e4bbd510dc24e5f9"; - ServiceWorkspaceGroupResource result = await collection.GetAsync(groupId); + string groupId = "aadGroup"; + ApiManagementGroupCreateOrUpdateContent content = new ApiManagementGroupCreateOrUpdateContent + { + DisplayName = "NewGroup (samiraad.onmicrosoft.com)", + Description = "new group to test", + ApiManagementGroupType = ApiManagementGroupType.External, + ExternalId = "aad://samiraad.onmicrosoft.com/groups/83cf2753-5831-4675-bc0e-2f8dc067c58d", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content); + ServiceWorkspaceGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,7 +101,7 @@ public async Task Get_ApiManagementGetWorkspaceGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceGroup() + public async Task Get_ApiManagementGetWorkspaceGroup() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceGroup.json // this example is just showing the usage of "WorkspaceGroup_Get" operation, for the dependent resources, they will have to be created separately. @@ -114,17 +125,21 @@ public async Task Exists_ApiManagementGetWorkspaceGroup() // invoke the operation string groupId = "59306a29e4bbd510dc24e5f9"; - bool result = await collection.ExistsAsync(groupId); + ServiceWorkspaceGroupResource result = await collection.GetAsync(groupId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceGroup() + public async Task GetAll_ApiManagementListWorkspaceGroups() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceGroup.json - // this example is just showing the usage of "WorkspaceGroup_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceGroups.json + // this example is just showing the usage of "WorkspaceGroup_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +158,25 @@ public async Task GetIfExists_ApiManagementGetWorkspaceGroup() // get the collection of this ServiceWorkspaceGroupResource ServiceWorkspaceGroupCollection collection = workspaceContract.GetServiceWorkspaceGroups(); - // invoke the operation - string groupId = "59306a29e4bbd510dc24e5f9"; - NullableResponse response = await collection.GetIfExistsAsync(groupId); - ServiceWorkspaceGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApiManagementGroupData resourceData = result.Data; + ApiManagementGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceGroup() + public async Task Exists_ApiManagementGetWorkspaceGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceGroup.json - // this example is just showing the usage of "WorkspaceGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceGroup.json + // this example is just showing the usage of "WorkspaceGroup_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,27 +196,18 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceGroup() ServiceWorkspaceGroupCollection collection = workspaceContract.GetServiceWorkspaceGroups(); // invoke the operation - string groupId = "tempgroup"; - ApiManagementGroupCreateOrUpdateContent content = new ApiManagementGroupCreateOrUpdateContent() - { - DisplayName = "temp group", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content); - ServiceWorkspaceGroupResource result = lro.Value; + string groupId = "59306a29e4bbd510dc24e5f9"; + bool result = await collection.ExistsAsync(groupId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceGroupExternal() + public async Task GetIfExists_ApiManagementGetWorkspaceGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceGroupExternal.json - // this example is just showing the usage of "WorkspaceGroup_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceGroup.json + // this example is just showing the usage of "WorkspaceGroup_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -227,22 +227,22 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceGroupExternal() ServiceWorkspaceGroupCollection collection = workspaceContract.GetServiceWorkspaceGroups(); // invoke the operation - string groupId = "aadGroup"; - ApiManagementGroupCreateOrUpdateContent content = new ApiManagementGroupCreateOrUpdateContent() - { - DisplayName = "NewGroup (samiraad.onmicrosoft.com)", - Description = "new group to test", - ApiManagementGroupType = ApiManagementGroupType.External, - ExternalId = "aad://samiraad.onmicrosoft.com/groups/83cf2753-5831-4675-bc0e-2f8dc067c58d", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupId, content); - ServiceWorkspaceGroupResource result = lro.Value; + string groupId = "59306a29e4bbd510dc24e5f9"; + NullableResponse response = await collection.GetIfExistsAsync(groupId); + ServiceWorkspaceGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceGroupResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceGroupResource.cs index 184dbf2914936..5845015ab1d4e 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceGroupResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceGroupResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceGroup() + public async Task Get_ApiManagementGetWorkspaceGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceGroup.json - // this example is just showing the usage of "WorkspaceGroup_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceGroup.json + // this example is just showing the usage of "WorkspaceGroup_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceGroup() ServiceWorkspaceGroupResource serviceWorkspaceGroup = client.GetServiceWorkspaceGroupResource(serviceWorkspaceGroupResourceId); // invoke the operation - bool result = await serviceWorkspaceGroup.GetEntityTagAsync(); + ServiceWorkspaceGroupResource result = await serviceWorkspaceGroup.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceGroup() + public async Task Delete_ApiManagementDeleteWorkspaceGroup() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceGroup.json - // this example is just showing the usage of "WorkspaceGroup_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceGroup.json + // this example is just showing the usage of "WorkspaceGroup_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,18 +66,15 @@ public async Task Get_ApiManagementGetWorkspaceGroup() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string groupId = "59306a29e4bbd510dc24e5f9"; + string groupId = "aadGroup"; ResourceIdentifier serviceWorkspaceGroupResourceId = ServiceWorkspaceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, groupId); ServiceWorkspaceGroupResource serviceWorkspaceGroup = client.GetServiceWorkspaceGroupResource(serviceWorkspaceGroupResourceId); // invoke the operation - ServiceWorkspaceGroupResource result = await serviceWorkspaceGroup.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceGroup.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,7 +101,7 @@ public async Task Update_ApiManagementUpdateWorkspaceGroup() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementGroupPatch patch = new ApiManagementGroupPatch() + ApiManagementGroupPatch patch = new ApiManagementGroupPatch { DisplayName = "temp group", }; @@ -113,35 +114,6 @@ public async Task Update_ApiManagementUpdateWorkspaceGroup() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceGroup() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceGroup.json - // this example is just showing the usage of "WorkspaceGroup_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ServiceWorkspaceGroupResource created on azure - // for more information of creating ServiceWorkspaceGroupResource, please refer to the document of ServiceWorkspaceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - string workspaceId = "wks1"; - string groupId = "aadGroup"; - ResourceIdentifier serviceWorkspaceGroupResourceId = ServiceWorkspaceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, groupId); - ServiceWorkspaceGroupResource serviceWorkspaceGroup = client.GetServiceWorkspaceGroupResource(serviceWorkspaceGroupResourceId); - - // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceGroup.DeleteAsync(WaitUntil.Completed, ifMatch); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetWorkspaceGroupUsers_ApiManagementListWorkspaceGroupUsers() @@ -267,5 +239,33 @@ public async Task DeleteWorkspaceGroupUser_ApiManagementDeleteWorkspaceGroupUser Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEntityTag_ApiManagementHeadWorkspaceGroup() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceGroup.json + // this example is just showing the usage of "WorkspaceGroup_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ServiceWorkspaceGroupResource created on azure + // for more information of creating ServiceWorkspaceGroupResource, please refer to the document of ServiceWorkspaceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + string workspaceId = "wks1"; + string groupId = "59306a29e4bbd510dc24e5f9"; + ResourceIdentifier serviceWorkspaceGroupResourceId = ServiceWorkspaceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, groupId); + ServiceWorkspaceGroupResource serviceWorkspaceGroup = client.GetServiceWorkspaceGroupResource(serviceWorkspaceGroupResourceId); + + // invoke the operation + bool result = await serviceWorkspaceGroup.GetEntityTagAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNamedValueCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNamedValueCollection.cs index 134430fefd2d0..820d2420c8bcf 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNamedValueCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNamedValueCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceNamedValueCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceNamedValues() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceNamedValues.json - // this example is just showing the usage of "WorkspaceNamedValue_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceNamedValue.json + // this example is just showing the usage of "WorkspaceNamedValue_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,31 @@ public async Task GetAll_ApiManagementListWorkspaceNamedValues() // get the collection of this ServiceWorkspaceNamedValueResource ServiceWorkspaceNamedValueCollection collection = workspaceContract.GetServiceWorkspaceNamedValues(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceNamedValueResource item in collection.GetAllAsync()) + // invoke the operation + string namedValueId = "testprop2"; + ApiManagementNamedValueCreateOrUpdateContent content = new ApiManagementNamedValueCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = { "foo", "bar" }, + IsSecret = false, + DisplayName = "prop3name", + Value = "propValue", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namedValueId, content); + ServiceWorkspaceNamedValueResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceNamedValue() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceNamedValueWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValue.json - // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceNamedValueWithKeyVault.json + // this example is just showing the usage of "WorkspaceNamedValue_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,8 +84,20 @@ public async Task Get_ApiManagementGetWorkspaceNamedValue() ServiceWorkspaceNamedValueCollection collection = workspaceContract.GetServiceWorkspaceNamedValues(); // invoke the operation - string namedValueId = "testarmTemplateproperties2"; - ServiceWorkspaceNamedValueResource result = await collection.GetAsync(namedValueId); + string namedValueId = "testprop6"; + ApiManagementNamedValueCreateOrUpdateContent content = new ApiManagementNamedValueCreateOrUpdateContent + { + Tags = { "foo", "bar" }, + IsSecret = true, + DisplayName = "prop6namekv", + KeyVault = new KeyVaultContractCreateProperties + { + SecretIdentifier = "https://contoso.vault.azure.net/secrets/aadSecret", + IdentityClientId = "ceaa6b06-c00f-43ef-99ac-f53d1fe876a0", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namedValueId, content); + ServiceWorkspaceNamedValueResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,7 +108,7 @@ public async Task Get_ApiManagementGetWorkspaceNamedValue() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceNamedValue() + public async Task Get_ApiManagementGetWorkspaceNamedValue() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValue.json // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. @@ -114,16 +132,20 @@ public async Task Exists_ApiManagementGetWorkspaceNamedValue() // invoke the operation string namedValueId = "testarmTemplateproperties2"; - bool result = await collection.ExistsAsync(namedValueId); + ServiceWorkspaceNamedValueResource result = await collection.GetAsync(namedValueId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceNamedValue() + public async Task Get_ApiManagementGetWorkspaceNamedValueWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValue.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValueWithKeyVault.json // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -144,30 +166,22 @@ public async Task GetIfExists_ApiManagementGetWorkspaceNamedValue() ServiceWorkspaceNamedValueCollection collection = workspaceContract.GetServiceWorkspaceNamedValues(); // invoke the operation - string namedValueId = "testarmTemplateproperties2"; - NullableResponse response = await collection.GetIfExistsAsync(namedValueId); - ServiceWorkspaceNamedValueResource result = response.HasValue ? response.Value : null; + string namedValueId = "testprop6"; + ServiceWorkspaceNamedValueResource result = await collection.GetAsync(namedValueId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceNamedValueWithKeyVault() + public async Task GetAll_ApiManagementListWorkspaceNamedValues() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValueWithKeyVault.json - // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceNamedValues.json + // this example is just showing the usage of "WorkspaceNamedValue_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,22 +200,24 @@ public async Task Get_ApiManagementGetWorkspaceNamedValueWithKeyVault() // get the collection of this ServiceWorkspaceNamedValueResource ServiceWorkspaceNamedValueCollection collection = workspaceContract.GetServiceWorkspaceNamedValues(); - // invoke the operation - string namedValueId = "testprop6"; - ServiceWorkspaceNamedValueResource result = await collection.GetAsync(namedValueId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceNamedValueResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceNamedValueWithKeyVault() + public async Task Exists_ApiManagementGetWorkspaceNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValueWithKeyVault.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValue.json // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -222,7 +238,7 @@ public async Task Exists_ApiManagementGetWorkspaceNamedValueWithKeyVault() ServiceWorkspaceNamedValueCollection collection = workspaceContract.GetServiceWorkspaceNamedValues(); // invoke the operation - string namedValueId = "testprop6"; + string namedValueId = "testarmTemplateproperties2"; bool result = await collection.ExistsAsync(namedValueId); Console.WriteLine($"Succeeded: {result}"); @@ -230,7 +246,7 @@ public async Task Exists_ApiManagementGetWorkspaceNamedValueWithKeyVault() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceNamedValueWithKeyVault() + public async Task Exists_ApiManagementGetWorkspaceNamedValueWithKeyVault() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValueWithKeyVault.json // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. @@ -254,29 +270,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceNamedValueWithKeyVault() // invoke the operation string namedValueId = "testprop6"; - NullableResponse response = await collection.GetIfExistsAsync(namedValueId); - ServiceWorkspaceNamedValueResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(namedValueId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceNamedValue() + public async Task GetIfExists_ApiManagementGetWorkspaceNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceNamedValue.json - // this example is just showing the usage of "WorkspaceNamedValue_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValue.json + // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -296,33 +300,30 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceNamedValue() ServiceWorkspaceNamedValueCollection collection = workspaceContract.GetServiceWorkspaceNamedValues(); // invoke the operation - string namedValueId = "testprop2"; - ApiManagementNamedValueCreateOrUpdateContent content = new ApiManagementNamedValueCreateOrUpdateContent() - { - Tags = -{ -"foo","bar" -}, - IsSecret = false, - DisplayName = "prop3name", - Value = "propValue", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namedValueId, content); - ServiceWorkspaceNamedValueResource result = lro.Value; + string namedValueId = "testarmTemplateproperties2"; + NullableResponse response = await collection.GetIfExistsAsync(namedValueId); + ServiceWorkspaceNamedValueResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceNamedValueWithKeyVault() + public async Task GetIfExists_ApiManagementGetWorkspaceNamedValueWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceNamedValueWithKeyVault.json - // this example is just showing the usage of "WorkspaceNamedValue_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValueWithKeyVault.json + // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -343,28 +344,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceNamedValueWithKeyVa // invoke the operation string namedValueId = "testprop6"; - ApiManagementNamedValueCreateOrUpdateContent content = new ApiManagementNamedValueCreateOrUpdateContent() - { - Tags = -{ -"foo","bar" -}, - IsSecret = true, - DisplayName = "prop6namekv", - KeyVault = new KeyVaultContractCreateProperties() - { - SecretIdentifier = "https://contoso.vault.azure.net/secrets/aadSecret", - IdentityClientId = "ceaa6b06-c00f-43ef-99ac-f53d1fe876a0", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, namedValueId, content); - ServiceWorkspaceNamedValueResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(namedValueId); + ServiceWorkspaceNamedValueResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNamedValueResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNamedValueResource.cs index 5b69e7b1babf5..7f6a0e1594f39 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNamedValueResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNamedValueResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceNamedValueResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceNamedValue() + public async Task Get_ApiManagementGetWorkspaceNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceNamedValue.json - // this example is just showing the usage of "WorkspaceNamedValue_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValue.json + // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,16 +39,20 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceNamedValue() ServiceWorkspaceNamedValueResource serviceWorkspaceNamedValue = client.GetServiceWorkspaceNamedValueResource(serviceWorkspaceNamedValueResourceId); // invoke the operation - bool result = await serviceWorkspaceNamedValue.GetEntityTagAsync(); + ServiceWorkspaceNamedValueResource result = await serviceWorkspaceNamedValue.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceNamedValue() + public async Task Get_ApiManagementGetWorkspaceNamedValueWithKeyVault() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValue.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValueWithKeyVault.json // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -62,7 +66,7 @@ public async Task Get_ApiManagementGetWorkspaceNamedValue() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string namedValueId = "testarmTemplateproperties2"; + string namedValueId = "testprop6"; ResourceIdentifier serviceWorkspaceNamedValueResourceId = ServiceWorkspaceNamedValueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, namedValueId); ServiceWorkspaceNamedValueResource serviceWorkspaceNamedValue = client.GetServiceWorkspaceNamedValueResource(serviceWorkspaceNamedValueResourceId); @@ -78,10 +82,10 @@ public async Task Get_ApiManagementGetWorkspaceNamedValue() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceNamedValueWithKeyVault() + public async Task Delete_ApiManagementDeleteWorkspaceNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNamedValueWithKeyVault.json - // this example is just showing the usage of "WorkspaceNamedValue_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceNamedValue.json + // this example is just showing the usage of "WorkspaceNamedValue_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,18 +98,15 @@ public async Task Get_ApiManagementGetWorkspaceNamedValueWithKeyVault() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string namedValueId = "testprop6"; + string namedValueId = "testprop2"; ResourceIdentifier serviceWorkspaceNamedValueResourceId = ServiceWorkspaceNamedValueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, namedValueId); ServiceWorkspaceNamedValueResource serviceWorkspaceNamedValue = client.GetServiceWorkspaceNamedValueResource(serviceWorkspaceNamedValueResourceId); // invoke the operation - ServiceWorkspaceNamedValueResource result = await serviceWorkspaceNamedValue.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceNamedValue.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -132,12 +133,9 @@ public async Task Update_ApiManagementUpdateWorkspaceNamedValue() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementNamedValuePatch patch = new ApiManagementNamedValuePatch() + ApiManagementNamedValuePatch patch = new ApiManagementNamedValuePatch { - Tags = -{ -"foo","bar2" -}, + Tags = { "foo", "bar2" }, IsSecret = false, DisplayName = "prop3name", Value = "propValue", @@ -154,10 +152,10 @@ public async Task Update_ApiManagementUpdateWorkspaceNamedValue() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceNamedValue() + public async Task GetValue_ApiManagementWorkspaceNamedValueListValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceNamedValue.json - // this example is just showing the usage of "WorkspaceNamedValue_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementWorkspaceNamedValueListValue.json + // this example is just showing the usage of "WorkspaceNamedValue_ListValue" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -170,23 +168,22 @@ public async Task Delete_ApiManagementDeleteWorkspaceNamedValue() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string namedValueId = "testprop2"; + string namedValueId = "testarmTemplateproperties2"; ResourceIdentifier serviceWorkspaceNamedValueResourceId = ServiceWorkspaceNamedValueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, namedValueId); ServiceWorkspaceNamedValueResource serviceWorkspaceNamedValue = client.GetServiceWorkspaceNamedValueResource(serviceWorkspaceNamedValueResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceNamedValue.DeleteAsync(WaitUntil.Completed, ifMatch); + NamedValueSecretContract result = await serviceWorkspaceNamedValue.GetValueAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetValue_ApiManagementWorkspaceNamedValueListValue() + public async Task RefreshSecret_ApiManagementRefreshWorkspaceNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementWorkspaceNamedValueListValue.json - // this example is just showing the usage of "WorkspaceNamedValue_ListValue" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementRefreshWorkspaceNamedValue.json + // this example is just showing the usage of "WorkspaceNamedValue_RefreshSecret" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,22 +196,27 @@ public async Task GetValue_ApiManagementWorkspaceNamedValueListValue() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string namedValueId = "testarmTemplateproperties2"; + string namedValueId = "testprop2"; ResourceIdentifier serviceWorkspaceNamedValueResourceId = ServiceWorkspaceNamedValueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, namedValueId); ServiceWorkspaceNamedValueResource serviceWorkspaceNamedValue = client.GetServiceWorkspaceNamedValueResource(serviceWorkspaceNamedValueResourceId); // invoke the operation - NamedValueSecretContract result = await serviceWorkspaceNamedValue.GetValueAsync(); + ArmOperation lro = await serviceWorkspaceNamedValue.RefreshSecretAsync(WaitUntil.Completed); + ServiceWorkspaceNamedValueResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNamedValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task RefreshSecret_ApiManagementRefreshWorkspaceNamedValue() + public async Task GetEntityTag_ApiManagementHeadWorkspaceNamedValue() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementRefreshWorkspaceNamedValue.json - // this example is just showing the usage of "WorkspaceNamedValue_RefreshSecret" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceNamedValue.json + // this example is just showing the usage of "WorkspaceNamedValue_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -227,19 +229,14 @@ public async Task RefreshSecret_ApiManagementRefreshWorkspaceNamedValue() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string namedValueId = "testprop2"; + string namedValueId = "testarmTemplateproperties2"; ResourceIdentifier serviceWorkspaceNamedValueResourceId = ServiceWorkspaceNamedValueResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, namedValueId); ServiceWorkspaceNamedValueResource serviceWorkspaceNamedValue = client.GetServiceWorkspaceNamedValueResource(serviceWorkspaceNamedValueResourceId); // invoke the operation - ArmOperation lro = await serviceWorkspaceNamedValue.RefreshSecretAsync(WaitUntil.Completed); - ServiceWorkspaceNamedValueResource result = lro.Value; + bool result = await serviceWorkspaceNamedValue.GetEntityTagAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNamedValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNotificationCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNotificationCollection.cs index 443d2c8b18454..aa56d3757ac48 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNotificationCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceNotificationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceNotificationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceNotifications() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceNotification() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceNotifications.json - // this example is just showing the usage of "WorkspaceNotification_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceNotification.json + // this example is just showing the usage of "WorkspaceNotification_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,16 @@ public async Task GetAll_ApiManagementListWorkspaceNotifications() // get the collection of this ServiceWorkspaceNotificationResource ServiceWorkspaceNotificationCollection collection = workspaceContract.GetServiceWorkspaceNotifications(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceNotificationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNotificationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + NotificationName notificationName = NotificationName.RequestPublisherNotificationMessage; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, notificationName); + ServiceWorkspaceNotificationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNotificationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +89,10 @@ public async Task Get_ApiManagementGetWorkspaceNotification() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceNotification() + public async Task GetAll_ApiManagementListWorkspaceNotifications() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNotification.json - // this example is just showing the usage of "WorkspaceNotification_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceNotifications.json + // this example is just showing the usage of "WorkspaceNotification_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +111,22 @@ public async Task Exists_ApiManagementGetWorkspaceNotification() // get the collection of this ServiceWorkspaceNotificationResource ServiceWorkspaceNotificationCollection collection = workspaceContract.GetServiceWorkspaceNotifications(); - // invoke the operation - NotificationName notificationName = NotificationName.RequestPublisherNotificationMessage; - bool result = await collection.ExistsAsync(notificationName); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceNotificationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNotificationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceNotification() + public async Task Exists_ApiManagementGetWorkspaceNotification() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNotification.json // this example is just showing the usage of "WorkspaceNotification_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +150,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceNotification() // invoke the operation NotificationName notificationName = NotificationName.RequestPublisherNotificationMessage; - NullableResponse response = await collection.GetIfExistsAsync(notificationName); - ServiceWorkspaceNotificationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(notificationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNotificationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceNotification() + public async Task GetIfExists_ApiManagementGetWorkspaceNotification() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceNotification.json - // this example is just showing the usage of "WorkspaceNotification_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceNotification.json + // this example is just showing the usage of "WorkspaceNotification_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,14 +181,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceNotification() // invoke the operation NotificationName notificationName = NotificationName.RequestPublisherNotificationMessage; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, notificationName); - ServiceWorkspaceNotificationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(notificationName); + ServiceWorkspaceNotificationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementNotificationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementNotificationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyCollection.cs index 201f439f40a76..b51f23aa76def 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspacePolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspacePolicies() + public async Task CreateOrUpdate_ApiManagementCreateWorkspacePolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspacePolicies.json - // this example is just showing the usage of "WorkspacePolicy_ListByApi" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspacePolicy.json + // this example is just showing the usage of "WorkspacePolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,30 @@ public async Task GetAll_ApiManagementListWorkspacePolicies() // get the collection of this ServiceWorkspacePolicyResource ServiceWorkspacePolicyCollection collection = workspaceContract.GetServiceWorkspacePolicies(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspacePolicyResource item in collection.GetAllAsync()) + // invoke the operation + PolicyName policyId = PolicyName.Policy; + PolicyContractData data = new PolicyContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = " ", + Format = PolicyContentFormat.Xml, + }; + ETag? ifMatch = new ETag("*"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); + ServiceWorkspacePolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspacePolicy() + public async Task CreateOrUpdate_ApiManagementCreateWorkspacePolicyNonXmlEncoded() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicy.json - // this example is just showing the usage of "WorkspacePolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspacePolicyNonXmlEncoded.json + // this example is just showing the usage of "WorkspacePolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,7 +84,14 @@ public async Task Get_ApiManagementGetWorkspacePolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - ServiceWorkspacePolicyResource result = await collection.GetAsync(policyId); + PolicyContractData data = new PolicyContractData + { + Value = "\r\n \r\n \r\n \r\n \"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" \r\n \r\n \r\n ", + Format = PolicyContentFormat.RawXml, + }; + ETag? ifMatch = new ETag("*"); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); + ServiceWorkspacePolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,7 +102,7 @@ public async Task Get_ApiManagementGetWorkspacePolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspacePolicy() + public async Task Get_ApiManagementGetWorkspacePolicy() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicy.json // this example is just showing the usage of "WorkspacePolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -114,17 +126,21 @@ public async Task Exists_ApiManagementGetWorkspacePolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - bool result = await collection.ExistsAsync(policyId); + ServiceWorkspacePolicyResource result = await collection.GetAsync(policyId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspacePolicy() + public async Task GetAll_ApiManagementListWorkspacePolicies() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicy.json - // this example is just showing the usage of "WorkspacePolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspacePolicies.json + // this example is just showing the usage of "WorkspacePolicy_ListByApi" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +159,25 @@ public async Task GetIfExists_ApiManagementGetWorkspacePolicy() // get the collection of this ServiceWorkspacePolicyResource ServiceWorkspacePolicyCollection collection = workspaceContract.GetServiceWorkspacePolicies(); - // invoke the operation - PolicyName policyId = PolicyName.Policy; - NullableResponse response = await collection.GetIfExistsAsync(policyId); - ServiceWorkspacePolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServiceWorkspacePolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; + PolicyContractData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspacePolicy() + public async Task Exists_ApiManagementGetWorkspacePolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspacePolicy.json - // this example is just showing the usage of "WorkspacePolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicy.json + // this example is just showing the usage of "WorkspacePolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,28 +198,17 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspacePolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = " ", - Format = PolicyContentFormat.Xml, - }; - ETag? ifMatch = new ETag("*"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); - ServiceWorkspacePolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(policyId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspacePolicyNonXmlEncoded() + public async Task GetIfExists_ApiManagementGetWorkspacePolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspacePolicyNonXmlEncoded.json - // this example is just showing the usage of "WorkspacePolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicy.json + // this example is just showing the usage of "WorkspacePolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -230,20 +229,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspacePolicyNonXmlEncoded // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = "\r\n \r\n \r\n \r\n \"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" \r\n \r\n \r\n ", - Format = PolicyContentFormat.RawXml, - }; - ETag? ifMatch = new ETag("*"); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data, ifMatch: ifMatch); - ServiceWorkspacePolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyId); + ServiceWorkspacePolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyFragmentCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyFragmentCollection.cs index 2fcc46f48e7a2..61e7b1f694337 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyFragmentCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyFragmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspacePolicyFragmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspacePolicyFragments() + public async Task CreateOrUpdate_ApiManagementCreateWorkspacePolicyFragment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspacePolicyFragments.json - // this example is just showing the usage of "WorkspacePolicyFragment_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspacePolicyFragment.json + // this example is just showing the usage of "WorkspacePolicyFragment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,22 @@ public async Task GetAll_ApiManagementListWorkspacePolicyFragments() // get the collection of this ServiceWorkspacePolicyFragmentResource ServiceWorkspacePolicyFragmentCollection collection = workspaceContract.GetServiceWorkspacePolicyFragments(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspacePolicyFragmentResource item in collection.GetAllAsync()) + // invoke the operation + string id = "policyFragment1"; + PolicyFragmentContractData data = new PolicyFragmentContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyFragmentContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = "", + Description = "A policy fragment example", + Format = PolicyFragmentContentFormat.Xml, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); + ServiceWorkspacePolicyFragmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyFragmentContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,9 +95,9 @@ public async Task Get_ApiManagementGetWorkspacePolicyFragment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspacePolicyFragment() + public async Task Get_ApiManagementGetWorkspacePolicyFragmentFormat() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragment.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragmentFormat.json // this example is just showing the usage of "WorkspacePolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -114,17 +119,22 @@ public async Task Exists_ApiManagementGetWorkspacePolicyFragment() // invoke the operation string id = "policyFragment1"; - bool result = await collection.ExistsAsync(id); + PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; + ServiceWorkspacePolicyFragmentResource result = await collection.GetAsync(id, format: format); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyFragmentContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspacePolicyFragment() + public async Task GetAll_ApiManagementListWorkspacePolicyFragments() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragment.json - // this example is just showing the usage of "WorkspacePolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspacePolicyFragments.json + // this example is just showing the usage of "WorkspacePolicyFragment_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,30 +153,24 @@ public async Task GetIfExists_ApiManagementGetWorkspacePolicyFragment() // get the collection of this ServiceWorkspacePolicyFragmentResource ServiceWorkspacePolicyFragmentCollection collection = workspaceContract.GetServiceWorkspacePolicyFragments(); - // invoke the operation - string id = "policyFragment1"; - NullableResponse response = await collection.GetIfExistsAsync(id); - ServiceWorkspacePolicyFragmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServiceWorkspacePolicyFragmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PolicyFragmentContractData resourceData = result.Data; + PolicyFragmentContractData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspacePolicyFragmentFormat() + public async Task Exists_ApiManagementGetWorkspacePolicyFragment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragmentFormat.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragment.json // this example is just showing the usage of "WorkspacePolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -188,14 +192,9 @@ public async Task Get_ApiManagementGetWorkspacePolicyFragmentFormat() // invoke the operation string id = "policyFragment1"; - PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; - ServiceWorkspacePolicyFragmentResource result = await collection.GetAsync(id, format: format); + bool result = await collection.ExistsAsync(id); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyFragmentContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -232,9 +231,9 @@ public async Task Exists_ApiManagementGetWorkspacePolicyFragmentFormat() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspacePolicyFragmentFormat() + public async Task GetIfExists_ApiManagementGetWorkspacePolicyFragment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragmentFormat.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragment.json // this example is just showing the usage of "WorkspacePolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -256,8 +255,7 @@ public async Task GetIfExists_ApiManagementGetWorkspacePolicyFragmentFormat() // invoke the operation string id = "policyFragment1"; - PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; - NullableResponse response = await collection.GetIfExistsAsync(id, format: format); + NullableResponse response = await collection.GetIfExistsAsync(id); ServiceWorkspacePolicyFragmentResource result = response.HasValue ? response.Value : null; if (result == null) @@ -276,10 +274,10 @@ public async Task GetIfExists_ApiManagementGetWorkspacePolicyFragmentFormat() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspacePolicyFragment() + public async Task GetIfExists_ApiManagementGetWorkspacePolicyFragmentFormat() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspacePolicyFragment.json - // this example is just showing the usage of "WorkspacePolicyFragment_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragmentFormat.json + // this example is just showing the usage of "WorkspacePolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -300,20 +298,22 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspacePolicyFragment() // invoke the operation string id = "policyFragment1"; - PolicyFragmentContractData data = new PolicyFragmentContractData() - { - Value = "", - Description = "A policy fragment example", - Format = PolicyFragmentContentFormat.Xml, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); - ServiceWorkspacePolicyFragmentResource result = lro.Value; + PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; + NullableResponse response = await collection.GetIfExistsAsync(id, format: format); + ServiceWorkspacePolicyFragmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyFragmentContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyFragmentContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyFragmentResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyFragmentResource.cs index bf82e4e63c871..89ee22b45ffa4 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyFragmentResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyFragmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspacePolicyFragmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspacePolicyFragment() + public async Task Get_ApiManagementGetWorkspacePolicyFragment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspacePolicyFragment.json - // this example is just showing the usage of "WorkspacePolicyFragment_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragment.json + // this example is just showing the usage of "WorkspacePolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,16 +39,20 @@ public async Task GetEntityTag_ApiManagementHeadWorkspacePolicyFragment() ServiceWorkspacePolicyFragmentResource serviceWorkspacePolicyFragment = client.GetServiceWorkspacePolicyFragmentResource(serviceWorkspacePolicyFragmentResourceId); // invoke the operation - bool result = await serviceWorkspacePolicyFragment.GetEntityTagAsync(); + ServiceWorkspacePolicyFragmentResource result = await serviceWorkspacePolicyFragment.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyFragmentContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspacePolicyFragment() + public async Task Get_ApiManagementGetWorkspacePolicyFragmentFormat() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragment.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragmentFormat.json // this example is just showing the usage of "WorkspacePolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -67,7 +71,8 @@ public async Task Get_ApiManagementGetWorkspacePolicyFragment() ServiceWorkspacePolicyFragmentResource serviceWorkspacePolicyFragment = client.GetServiceWorkspacePolicyFragmentResource(serviceWorkspacePolicyFragmentResourceId); // invoke the operation - ServiceWorkspacePolicyFragmentResource result = await serviceWorkspacePolicyFragment.GetAsync(); + PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; + ServiceWorkspacePolicyFragmentResource result = await serviceWorkspacePolicyFragment.GetAsync(format: format); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -78,10 +83,10 @@ public async Task Get_ApiManagementGetWorkspacePolicyFragment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspacePolicyFragmentFormat() + public async Task Delete_ApiManagementDeleteWorkspacePolicyFragment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicyFragmentFormat.json - // this example is just showing the usage of "WorkspacePolicyFragment_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspacePolicyFragment.json + // this example is just showing the usage of "WorkspacePolicyFragment_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,14 +104,10 @@ public async Task Get_ApiManagementGetWorkspacePolicyFragmentFormat() ServiceWorkspacePolicyFragmentResource serviceWorkspacePolicyFragment = client.GetServiceWorkspacePolicyFragmentResource(serviceWorkspacePolicyFragmentResourceId); // invoke the operation - PolicyFragmentContentFormat? format = PolicyFragmentContentFormat.Rawxml; - ServiceWorkspacePolicyFragmentResource result = await serviceWorkspacePolicyFragment.GetAsync(format: format); + ETag ifMatch = new ETag("*"); + await serviceWorkspacePolicyFragment.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyFragmentContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -132,7 +133,7 @@ public async Task Update_ApiManagementCreateWorkspacePolicyFragment() ServiceWorkspacePolicyFragmentResource serviceWorkspacePolicyFragment = client.GetServiceWorkspacePolicyFragmentResource(serviceWorkspacePolicyFragmentResourceId); // invoke the operation - PolicyFragmentContractData data = new PolicyFragmentContractData() + PolicyFragmentContractData data = new PolicyFragmentContractData { Value = "", Description = "A policy fragment example", @@ -150,10 +151,10 @@ public async Task Update_ApiManagementCreateWorkspacePolicyFragment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspacePolicyFragment() + public async Task GetReferences_ApiManagementListWorkspacePolicyFragmentReferences() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspacePolicyFragment.json - // this example is just showing the usage of "WorkspacePolicyFragment_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspacePolicyFragmentReferences.json + // this example is just showing the usage of "WorkspacePolicyFragment_ListReferences" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -170,19 +171,21 @@ public async Task Delete_ApiManagementDeleteWorkspacePolicyFragment() ResourceIdentifier serviceWorkspacePolicyFragmentResourceId = ServiceWorkspacePolicyFragmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, id); ServiceWorkspacePolicyFragmentResource serviceWorkspacePolicyFragment = client.GetServiceWorkspacePolicyFragmentResource(serviceWorkspacePolicyFragmentResourceId); - // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspacePolicyFragment.DeleteAsync(WaitUntil.Completed, ifMatch); + // invoke the operation and iterate over the result + await foreach (ResourceCollectionValueItem item in serviceWorkspacePolicyFragment.GetReferencesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetReferences_ApiManagementListWorkspacePolicyFragmentReferences() + public async Task GetEntityTag_ApiManagementHeadWorkspacePolicyFragment() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspacePolicyFragmentReferences.json - // this example is just showing the usage of "WorkspacePolicyFragment_ListReferences" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspacePolicyFragment.json + // this example is just showing the usage of "WorkspacePolicyFragment_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,13 +202,10 @@ public async Task GetReferences_ApiManagementListWorkspacePolicyFragmentReferenc ResourceIdentifier serviceWorkspacePolicyFragmentResourceId = ServiceWorkspacePolicyFragmentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, id); ServiceWorkspacePolicyFragmentResource serviceWorkspacePolicyFragment = client.GetServiceWorkspacePolicyFragmentResource(serviceWorkspacePolicyFragmentResourceId); - // invoke the operation and iterate over the result - await foreach (ResourceCollectionValueItem item in serviceWorkspacePolicyFragment.GetReferencesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + bool result = await serviceWorkspacePolicyFragment.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyResource.cs index a10ceb8c0693d..89070049a8790 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspacePolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspacePolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspacePolicy() + public async Task Get_ApiManagementGetWorkspacePolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspacePolicy.json - // this example is just showing the usage of "WorkspacePolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicy.json + // this example is just showing the usage of "WorkspacePolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadWorkspacePolicy() ServiceWorkspacePolicyResource serviceWorkspacePolicy = client.GetServiceWorkspacePolicyResource(serviceWorkspacePolicyResourceId); // invoke the operation - bool result = await serviceWorkspacePolicy.GetEntityTagAsync(); + ServiceWorkspacePolicyResource result = await serviceWorkspacePolicy.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspacePolicy() + public async Task Delete_ApiManagementDeleteWorkspacePolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspacePolicy.json - // this example is just showing the usage of "WorkspacePolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspacePolicy.json + // this example is just showing the usage of "WorkspacePolicy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,10 @@ public async Task Get_ApiManagementGetWorkspacePolicy() ServiceWorkspacePolicyResource serviceWorkspacePolicy = client.GetServiceWorkspacePolicyResource(serviceWorkspacePolicyResourceId); // invoke the operation - ServiceWorkspacePolicyResource result = await serviceWorkspacePolicy.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspacePolicy.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,7 +100,7 @@ public async Task Update_ApiManagementCreateWorkspacePolicy() ServiceWorkspacePolicyResource serviceWorkspacePolicy = client.GetServiceWorkspacePolicyResource(serviceWorkspacePolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = " ", Format = PolicyContentFormat.Xml, @@ -138,7 +139,7 @@ public async Task Update_ApiManagementCreateWorkspacePolicyNonXmlEncoded() ServiceWorkspacePolicyResource serviceWorkspacePolicy = client.GetServiceWorkspacePolicyResource(serviceWorkspacePolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = "\r\n \r\n \r\n \r\n \"@(context.Request.Headers.FirstOrDefault(h => h.Ke==\"Via\"))\" \r\n \r\n \r\n ", Format = PolicyContentFormat.RawXml, @@ -156,10 +157,10 @@ public async Task Update_ApiManagementCreateWorkspacePolicyNonXmlEncoded() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspacePolicy() + public async Task GetEntityTag_ApiManagementHeadWorkspacePolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspacePolicy.json - // this example is just showing the usage of "WorkspacePolicy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspacePolicy.json + // this example is just showing the usage of "WorkspacePolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,10 +178,9 @@ public async Task Delete_ApiManagementDeleteWorkspacePolicy() ServiceWorkspacePolicyResource serviceWorkspacePolicy = client.GetServiceWorkspacePolicyResource(serviceWorkspacePolicyResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspacePolicy.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceWorkspacePolicy.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductApiLinkCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductApiLinkCollection.cs index 64044f7fd61cc..50b837f898840 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductApiLinkCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductApiLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceWorkspaceProductApiLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceProductApiLinks() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProductApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceProductApiLinks.json - // this example is just showing the usage of "WorkspaceProductApiLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProductApiLink.json + // this example is just showing the usage of "WorkspaceProductApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,24 +33,27 @@ public async Task GetAll_ApiManagementListWorkspaceProductApiLinks() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "product1"; + string productId = "testproduct"; ResourceIdentifier serviceWorkspaceProductResourceId = ServiceWorkspaceProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId); ServiceWorkspaceProductResource serviceWorkspaceProduct = client.GetServiceWorkspaceProductResource(serviceWorkspaceProductResourceId); // get the collection of this ServiceWorkspaceProductApiLinkResource ServiceWorkspaceProductApiLinkCollection collection = serviceWorkspaceProduct.GetServiceWorkspaceProductApiLinks(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceProductApiLinkResource item in collection.GetAllAsync()) + // invoke the operation + string apiLinkId = "link1"; + ProductApiLinkContractData data = new ProductApiLinkContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductApiLinkContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiLinkId, data); + ServiceWorkspaceProductApiLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +94,10 @@ public async Task Get_ApiManagementGetWorkspaceProductApiLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceProductApiLink() + public async Task GetAll_ApiManagementListWorkspaceProductApiLinks() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductApiLink.json - // this example is just showing the usage of "WorkspaceProductApiLink_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceProductApiLinks.json + // this example is just showing the usage of "WorkspaceProductApiLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,23 +110,29 @@ public async Task Exists_ApiManagementGetWorkspaceProductApiLink() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "testproduct"; + string productId = "product1"; ResourceIdentifier serviceWorkspaceProductResourceId = ServiceWorkspaceProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId); ServiceWorkspaceProductResource serviceWorkspaceProduct = client.GetServiceWorkspaceProductResource(serviceWorkspaceProductResourceId); // get the collection of this ServiceWorkspaceProductApiLinkResource ServiceWorkspaceProductApiLinkCollection collection = serviceWorkspaceProduct.GetServiceWorkspaceProductApiLinks(); - // invoke the operation - string apiLinkId = "link1"; - bool result = await collection.ExistsAsync(apiLinkId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceProductApiLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductApiLinkContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceProductApiLink() + public async Task Exists_ApiManagementGetWorkspaceProductApiLink() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductApiLink.json // this example is just showing the usage of "WorkspaceProductApiLink_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +157,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceProductApiLink() // invoke the operation string apiLinkId = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(apiLinkId); - ServiceWorkspaceProductApiLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(apiLinkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProductApiLink() + public async Task GetIfExists_ApiManagementGetWorkspaceProductApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProductApiLink.json - // this example is just showing the usage of "WorkspaceProductApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductApiLink.json + // this example is just showing the usage of "WorkspaceProductApiLink_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,18 +189,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProductApiLink() // invoke the operation string apiLinkId = "link1"; - ProductApiLinkContractData data = new ProductApiLinkContractData() - { - ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiLinkId, data); - ServiceWorkspaceProductApiLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(apiLinkId); + ServiceWorkspaceProductApiLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductApiLinkResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductApiLinkResource.cs index 7d2f04d483668..d879f72f84658 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductApiLinkResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductApiLinkResource.cs @@ -50,10 +50,10 @@ public async Task Get_ApiManagementGetWorkspaceProductApiLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateWorkspaceProductApiLink() + public async Task Delete_ApiManagementDeleteWorkspaceProductApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProductApiLink.json - // this example is just showing the usage of "WorkspaceProductApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceProductApiLink.json + // this example is just showing the usage of "WorkspaceProductApiLink_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,26 +72,17 @@ public async Task Update_ApiManagementCreateWorkspaceProductApiLink() ServiceWorkspaceProductApiLinkResource serviceWorkspaceProductApiLink = client.GetServiceWorkspaceProductApiLinkResource(serviceWorkspaceProductApiLinkResourceId); // invoke the operation - ProductApiLinkContractData data = new ProductApiLinkContractData() - { - ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api", - }; - ArmOperation lro = await serviceWorkspaceProductApiLink.UpdateAsync(WaitUntil.Completed, data); - ServiceWorkspaceProductApiLinkResource result = lro.Value; + await serviceWorkspaceProductApiLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceProductApiLink() + public async Task Update_ApiManagementCreateWorkspaceProductApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceProductApiLink.json - // this example is just showing the usage of "WorkspaceProductApiLink_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProductApiLink.json + // this example is just showing the usage of "WorkspaceProductApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +101,18 @@ public async Task Delete_ApiManagementDeleteWorkspaceProductApiLink() ServiceWorkspaceProductApiLinkResource serviceWorkspaceProductApiLink = client.GetServiceWorkspaceProductApiLinkResource(serviceWorkspaceProductApiLinkResourceId); // invoke the operation - await serviceWorkspaceProductApiLink.DeleteAsync(WaitUntil.Completed); + ProductApiLinkContractData data = new ProductApiLinkContractData + { + ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api", + }; + ArmOperation lro = await serviceWorkspaceProductApiLink.UpdateAsync(WaitUntil.Completed, data); + ServiceWorkspaceProductApiLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductCollection.cs index 64927b6ddd7f9..369ea8a20a694 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceWorkspaceProductCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceProducts() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProduct() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceProducts.json - // this example is just showing the usage of "WorkspaceProduct_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProduct.json + // this example is just showing the usage of "WorkspaceProduct_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ApiManagementListWorkspaceProducts() // get the collection of this ServiceWorkspaceProductResource ServiceWorkspaceProductCollection collection = workspaceContract.GetServiceWorkspaceProducts(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceProductResource item in collection.GetAllAsync()) + // invoke the operation + string productId = "testproduct"; + ApiManagementProductData data = new ApiManagementProductData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementProductData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "Test Template ProductName 4", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, productId, data); + ServiceWorkspaceProductResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_ApiManagementGetWorkspaceProduct() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceProduct() + public async Task GetAll_ApiManagementListWorkspaceProducts() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProduct.json - // this example is just showing the usage of "WorkspaceProduct_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceProducts.json + // this example is just showing the usage of "WorkspaceProduct_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +114,22 @@ public async Task Exists_ApiManagementGetWorkspaceProduct() // get the collection of this ServiceWorkspaceProductResource ServiceWorkspaceProductCollection collection = workspaceContract.GetServiceWorkspaceProducts(); - // invoke the operation - string productId = "unlimited"; - bool result = await collection.ExistsAsync(productId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceProductResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementProductData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceProduct() + public async Task Exists_ApiManagementGetWorkspaceProduct() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProduct.json // this example is just showing the usage of "WorkspaceProduct_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +153,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceProduct() // invoke the operation string productId = "unlimited"; - NullableResponse response = await collection.GetIfExistsAsync(productId); - ServiceWorkspaceProductResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(productId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProduct() + public async Task GetIfExists_ApiManagementGetWorkspaceProduct() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProduct.json - // this example is just showing the usage of "WorkspaceProduct_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProduct.json + // this example is just showing the usage of "WorkspaceProduct_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,19 +183,22 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProduct() ServiceWorkspaceProductCollection collection = workspaceContract.GetServiceWorkspaceProducts(); // invoke the operation - string productId = "testproduct"; - ApiManagementProductData data = new ApiManagementProductData() - { - DisplayName = "Test Template ProductName 4", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, productId, data); - ServiceWorkspaceProductResource result = lro.Value; + string productId = "unlimited"; + NullableResponse response = await collection.GetIfExistsAsync(productId); + ServiceWorkspaceProductResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductGroupLinkCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductGroupLinkCollection.cs index 8b46a7ff1172d..014d07a588207 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductGroupLinkCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductGroupLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceWorkspaceProductGroupLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceProductGroupLinks() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProductGroupLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceProductGroupLinks.json - // this example is just showing the usage of "WorkspaceProductGroupLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProductGroupLink.json + // this example is just showing the usage of "WorkspaceProductGroupLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,24 +33,27 @@ public async Task GetAll_ApiManagementListWorkspaceProductGroupLinks() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "product1"; + string productId = "testproduct"; ResourceIdentifier serviceWorkspaceProductResourceId = ServiceWorkspaceProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId); ServiceWorkspaceProductResource serviceWorkspaceProduct = client.GetServiceWorkspaceProductResource(serviceWorkspaceProductResourceId); // get the collection of this ServiceWorkspaceProductGroupLinkResource ServiceWorkspaceProductGroupLinkCollection collection = serviceWorkspaceProduct.GetServiceWorkspaceProductGroupLinks(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceProductGroupLinkResource item in collection.GetAllAsync()) + // invoke the operation + string groupLinkId = "link1"; + ProductGroupLinkContractData data = new ProductGroupLinkContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductGroupLinkContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + GroupId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/groups/group1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupLinkId, data); + ServiceWorkspaceProductGroupLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductGroupLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +94,10 @@ public async Task Get_ApiManagementGetWorkspaceProductGroupLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceProductGroupLink() + public async Task GetAll_ApiManagementListWorkspaceProductGroupLinks() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductGroupLink.json - // this example is just showing the usage of "WorkspaceProductGroupLink_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceProductGroupLinks.json + // this example is just showing the usage of "WorkspaceProductGroupLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,23 +110,29 @@ public async Task Exists_ApiManagementGetWorkspaceProductGroupLink() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "testproduct"; + string productId = "product1"; ResourceIdentifier serviceWorkspaceProductResourceId = ServiceWorkspaceProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId); ServiceWorkspaceProductResource serviceWorkspaceProduct = client.GetServiceWorkspaceProductResource(serviceWorkspaceProductResourceId); // get the collection of this ServiceWorkspaceProductGroupLinkResource ServiceWorkspaceProductGroupLinkCollection collection = serviceWorkspaceProduct.GetServiceWorkspaceProductGroupLinks(); - // invoke the operation - string groupLinkId = "link1"; - bool result = await collection.ExistsAsync(groupLinkId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceProductGroupLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductGroupLinkContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceProductGroupLink() + public async Task Exists_ApiManagementGetWorkspaceProductGroupLink() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductGroupLink.json // this example is just showing the usage of "WorkspaceProductGroupLink_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +157,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceProductGroupLink() // invoke the operation string groupLinkId = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(groupLinkId); - ServiceWorkspaceProductGroupLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(groupLinkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductGroupLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProductGroupLink() + public async Task GetIfExists_ApiManagementGetWorkspaceProductGroupLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProductGroupLink.json - // this example is just showing the usage of "WorkspaceProductGroupLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductGroupLink.json + // this example is just showing the usage of "WorkspaceProductGroupLink_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,18 +189,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProductGroupLink() // invoke the operation string groupLinkId = "link1"; - ProductGroupLinkContractData data = new ProductGroupLinkContractData() - { - GroupId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/groups/group1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, groupLinkId, data); - ServiceWorkspaceProductGroupLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(groupLinkId); + ServiceWorkspaceProductGroupLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductGroupLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductGroupLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductGroupLinkResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductGroupLinkResource.cs index 59b3bd8ec599b..f2487bc62fac8 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductGroupLinkResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductGroupLinkResource.cs @@ -50,10 +50,10 @@ public async Task Get_ApiManagementGetWorkspaceProductGroupLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateWorkspaceProductGroupLink() + public async Task Delete_ApiManagementDeleteWorkspaceProductGroupLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProductGroupLink.json - // this example is just showing the usage of "WorkspaceProductGroupLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceProductGroupLink.json + // this example is just showing the usage of "WorkspaceProductGroupLink_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,26 +72,17 @@ public async Task Update_ApiManagementCreateWorkspaceProductGroupLink() ServiceWorkspaceProductGroupLinkResource serviceWorkspaceProductGroupLink = client.GetServiceWorkspaceProductGroupLinkResource(serviceWorkspaceProductGroupLinkResourceId); // invoke the operation - ProductGroupLinkContractData data = new ProductGroupLinkContractData() - { - GroupId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/groups/group1", - }; - ArmOperation lro = await serviceWorkspaceProductGroupLink.UpdateAsync(WaitUntil.Completed, data); - ServiceWorkspaceProductGroupLinkResource result = lro.Value; + await serviceWorkspaceProductGroupLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProductGroupLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceProductGroupLink() + public async Task Update_ApiManagementCreateWorkspaceProductGroupLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceProductGroupLink.json - // this example is just showing the usage of "WorkspaceProductGroupLink_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProductGroupLink.json + // this example is just showing the usage of "WorkspaceProductGroupLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +101,18 @@ public async Task Delete_ApiManagementDeleteWorkspaceProductGroupLink() ServiceWorkspaceProductGroupLinkResource serviceWorkspaceProductGroupLink = client.GetServiceWorkspaceProductGroupLinkResource(serviceWorkspaceProductGroupLinkResourceId); // invoke the operation - await serviceWorkspaceProductGroupLink.DeleteAsync(WaitUntil.Completed); + ProductGroupLinkContractData data = new ProductGroupLinkContractData + { + GroupId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/groups/group1", + }; + ArmOperation lro = await serviceWorkspaceProductGroupLink.UpdateAsync(WaitUntil.Completed, data); + ServiceWorkspaceProductGroupLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProductGroupLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductPolicyCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductPolicyCollection.cs index 20da651b864d3..111dd543e0a84 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductPolicyCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceProductPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceProductPolicies() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProductPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceProductPolicies.json - // this example is just showing the usage of "WorkspaceProductPolicy_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProductPolicy.json + // this example is just showing the usage of "WorkspaceProductPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,24 +34,28 @@ public async Task GetAll_ApiManagementListWorkspaceProductPolicies() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "armTemplateProduct4"; + string productId = "5702e97e5157a50f48dce801"; ResourceIdentifier serviceWorkspaceProductResourceId = ServiceWorkspaceProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId); ServiceWorkspaceProductResource serviceWorkspaceProduct = client.GetServiceWorkspaceProductResource(serviceWorkspaceProductResourceId); // get the collection of this ServiceWorkspaceProductPolicyResource ServiceWorkspaceProductPolicyCollection collection = serviceWorkspaceProduct.GetServiceWorkspaceProductPolicies(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceProductPolicyResource item in collection.GetAllAsync()) + // invoke the operation + PolicyName policyId = PolicyName.Policy; + PolicyContractData data = new PolicyContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Value = "\r\n \r\n \r\n \r\n @( string.Join(\",\", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) ) \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", + Format = PolicyContentFormat.Xml, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data); + ServiceWorkspaceProductPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +96,10 @@ public async Task Get_ApiManagementGetWorkspaceProductPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceProductPolicy() + public async Task GetAll_ApiManagementListWorkspaceProductPolicies() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductPolicy.json - // this example is just showing the usage of "WorkspaceProductPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceProductPolicies.json + // this example is just showing the usage of "WorkspaceProductPolicy_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,23 +112,29 @@ public async Task Exists_ApiManagementGetWorkspaceProductPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "kjoshiarmTemplateProduct4"; + string productId = "armTemplateProduct4"; ResourceIdentifier serviceWorkspaceProductResourceId = ServiceWorkspaceProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId); ServiceWorkspaceProductResource serviceWorkspaceProduct = client.GetServiceWorkspaceProductResource(serviceWorkspaceProductResourceId); // get the collection of this ServiceWorkspaceProductPolicyResource ServiceWorkspaceProductPolicyCollection collection = serviceWorkspaceProduct.GetServiceWorkspaceProductPolicies(); - // invoke the operation - PolicyName policyId = PolicyName.Policy; - bool result = await collection.ExistsAsync(policyId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceProductPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceProductPolicy() + public async Task Exists_ApiManagementGetWorkspaceProductPolicy() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductPolicy.json // this example is just showing the usage of "WorkspaceProductPolicy_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +159,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceProductPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - NullableResponse response = await collection.GetIfExistsAsync(policyId); - ServiceWorkspaceProductPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProductPolicy() + public async Task GetIfExists_ApiManagementGetWorkspaceProductPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceProductPolicy.json - // this example is just showing the usage of "WorkspaceProductPolicy_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductPolicy.json + // this example is just showing the usage of "WorkspaceProductPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,7 +182,7 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProductPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "5702e97e5157a50f48dce801"; + string productId = "kjoshiarmTemplateProduct4"; ResourceIdentifier serviceWorkspaceProductResourceId = ServiceWorkspaceProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId); ServiceWorkspaceProductResource serviceWorkspaceProduct = client.GetServiceWorkspaceProductResource(serviceWorkspaceProductResourceId); @@ -193,19 +191,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceProductPolicy() // invoke the operation PolicyName policyId = PolicyName.Policy; - PolicyContractData data = new PolicyContractData() - { - Value = "\r\n \r\n \r\n \r\n @( string.Join(\",\", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) ) \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", - Format = PolicyContentFormat.Xml, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyId, data); - ServiceWorkspaceProductPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(policyId); + ServiceWorkspaceProductPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductPolicyResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductPolicyResource.cs index 90f2638b24c50..ea243a1d4e3f7 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductPolicyResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceProductPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceProductPolicy() + public async Task Get_ApiManagementGetWorkspaceProductPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceProductPolicy.json - // this example is just showing the usage of "WorkspaceProductPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductPolicy.json + // this example is just showing the usage of "WorkspaceProductPolicy_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,23 +34,27 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceProductPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "unlimited"; + string productId = "kjoshiarmTemplateProduct4"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier serviceWorkspaceProductPolicyResourceId = ServiceWorkspaceProductPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId, policyId); ServiceWorkspaceProductPolicyResource serviceWorkspaceProductPolicy = client.GetServiceWorkspaceProductPolicyResource(serviceWorkspaceProductPolicyResourceId); // invoke the operation - bool result = await serviceWorkspaceProductPolicy.GetEntityTagAsync(); + ServiceWorkspaceProductPolicyResource result = await serviceWorkspaceProductPolicy.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PolicyContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceProductPolicy() + public async Task Delete_ApiManagementDeleteWorkspaceProductPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProductPolicy.json - // this example is just showing the usage of "WorkspaceProductPolicy_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceProductPolicy.json + // this example is just showing the usage of "WorkspaceProductPolicy_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,19 +67,16 @@ public async Task Get_ApiManagementGetWorkspaceProductPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "kjoshiarmTemplateProduct4"; + string productId = "testproduct"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier serviceWorkspaceProductPolicyResourceId = ServiceWorkspaceProductPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId, policyId); ServiceWorkspaceProductPolicyResource serviceWorkspaceProductPolicy = client.GetServiceWorkspaceProductPolicyResource(serviceWorkspaceProductPolicyResourceId); // invoke the operation - ServiceWorkspaceProductPolicyResource result = await serviceWorkspaceProductPolicy.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceProductPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PolicyContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -102,7 +103,7 @@ public async Task Update_ApiManagementCreateWorkspaceProductPolicy() ServiceWorkspaceProductPolicyResource serviceWorkspaceProductPolicy = client.GetServiceWorkspaceProductPolicyResource(serviceWorkspaceProductPolicyResourceId); // invoke the operation - PolicyContractData data = new PolicyContractData() + PolicyContractData data = new PolicyContractData { Value = "\r\n \r\n \r\n \r\n @( string.Join(\",\", DateTime.UtcNow, context.Deployment.ServiceName, context.RequestId, context.Request.IpAddress, context.Operation.Name) ) \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n", Format = PolicyContentFormat.Xml, @@ -119,10 +120,10 @@ public async Task Update_ApiManagementCreateWorkspaceProductPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceProductPolicy() + public async Task GetEntityTag_ApiManagementHeadWorkspaceProductPolicy() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceProductPolicy.json - // this example is just showing the usage of "WorkspaceProductPolicy_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceProductPolicy.json + // this example is just showing the usage of "WorkspaceProductPolicy_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,16 +136,15 @@ public async Task Delete_ApiManagementDeleteWorkspaceProductPolicy() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "testproduct"; + string productId = "unlimited"; PolicyName policyId = PolicyName.Policy; ResourceIdentifier serviceWorkspaceProductPolicyResourceId = ServiceWorkspaceProductPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId, policyId); ServiceWorkspaceProductPolicyResource serviceWorkspaceProductPolicy = client.GetServiceWorkspaceProductPolicyResource(serviceWorkspaceProductPolicyResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceProductPolicy.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceWorkspaceProductPolicy.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductResource.cs index f018c834f76eb..fed87d87a54c0 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceProductResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceProductResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceProduct() + public async Task Get_ApiManagementGetWorkspaceProduct() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceProduct.json - // this example is just showing the usage of "WorkspaceProduct_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProduct.json + // this example is just showing the usage of "WorkspaceProduct_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceProduct() ServiceWorkspaceProductResource serviceWorkspaceProduct = client.GetServiceWorkspaceProductResource(serviceWorkspaceProductResourceId); // invoke the operation - bool result = await serviceWorkspaceProduct.GetEntityTagAsync(); + ServiceWorkspaceProductResource result = await serviceWorkspaceProduct.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceProduct() + public async Task Delete_ApiManagementDeleteWorkspaceProduct() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceProduct.json - // this example is just showing the usage of "WorkspaceProduct_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceProduct.json + // this example is just showing the usage of "WorkspaceProduct_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,18 +66,16 @@ public async Task Get_ApiManagementGetWorkspaceProduct() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "unlimited"; + string productId = "testproduct"; ResourceIdentifier serviceWorkspaceProductResourceId = ServiceWorkspaceProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId); ServiceWorkspaceProductResource serviceWorkspaceProduct = client.GetServiceWorkspaceProductResource(serviceWorkspaceProductResourceId); // invoke the operation - ServiceWorkspaceProductResource result = await serviceWorkspaceProduct.GetAsync(); + ETag ifMatch = new ETag("*"); + bool? deleteSubscriptions = true; + await serviceWorkspaceProduct.DeleteAsync(WaitUntil.Completed, ifMatch, deleteSubscriptions: deleteSubscriptions); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,7 +102,7 @@ public async Task Update_ApiManagementUpdateWorkspaceProduct() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementProductPatch patch = new ApiManagementProductPatch() + ApiManagementProductPatch patch = new ApiManagementProductPatch { DisplayName = "Test Template ProductName 4", }; @@ -115,10 +117,10 @@ public async Task Update_ApiManagementUpdateWorkspaceProduct() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceProduct() + public async Task GetEntityTag_ApiManagementHeadWorkspaceProduct() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceProduct.json - // this example is just showing the usage of "WorkspaceProduct_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceProduct.json + // this example is just showing the usage of "WorkspaceProduct_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,16 +133,14 @@ public async Task Delete_ApiManagementDeleteWorkspaceProduct() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string productId = "testproduct"; + string productId = "unlimited"; ResourceIdentifier serviceWorkspaceProductResourceId = ServiceWorkspaceProductResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, productId); ServiceWorkspaceProductResource serviceWorkspaceProduct = client.GetServiceWorkspaceProductResource(serviceWorkspaceProductResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - bool? deleteSubscriptions = true; - await serviceWorkspaceProduct.DeleteAsync(WaitUntil.Completed, ifMatch, deleteSubscriptions: deleteSubscriptions); + bool result = await serviceWorkspaceProduct.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSchemaCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSchemaCollection.cs index 8a1e1afe3d6b8..bfd6d6fbe3ca0 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSchemaCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSchemaCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceSchemaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceSchemas() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceSchemas.json - // this example is just showing the usage of "WorkspaceGlobalSchema_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceSchema.json + // this example is just showing the usage of "WorkspaceGlobalSchema_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,22 @@ public async Task GetAll_ApiManagementListWorkspaceSchemas() // get the collection of this ServiceWorkspaceSchemaResource ServiceWorkspaceSchemaCollection collection = workspaceContract.GetServiceWorkspaceSchemas(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceSchemaResource item in collection.GetAllAsync()) + // invoke the operation + string schemaId = "schema1"; + ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SchemaType = ApiSchemaType.Xml, + Description = "sample schema description", + Value = BinaryData.FromObjectAsJson("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaId, data); + ServiceWorkspaceSchemaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +95,10 @@ public async Task Get_ApiManagementGetWorkspaceSchema() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceSchema() + public async Task GetAll_ApiManagementListWorkspaceSchemas() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceSchema.json - // this example is just showing the usage of "WorkspaceGlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceSchemas.json + // this example is just showing the usage of "WorkspaceGlobalSchema_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +117,22 @@ public async Task Exists_ApiManagementGetWorkspaceSchema() // get the collection of this ServiceWorkspaceSchemaResource ServiceWorkspaceSchemaCollection collection = workspaceContract.GetServiceWorkspaceSchemas(); - // invoke the operation - string schemaId = "schema1"; - bool result = await collection.ExistsAsync(schemaId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceSchemaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceSchema() + public async Task Exists_ApiManagementGetWorkspaceSchema() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceSchema.json // this example is just showing the usage of "WorkspaceGlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +156,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceSchema() // invoke the operation string schemaId = "schema1"; - NullableResponse response = await collection.GetIfExistsAsync(schemaId); - ServiceWorkspaceSchemaResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(schemaId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceSchema() + public async Task GetIfExists_ApiManagementGetWorkspaceSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceSchema.json - // this example is just showing the usage of "WorkspaceGlobalSchema_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceSchema.json + // this example is just showing the usage of "WorkspaceGlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,20 +187,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceSchema() // invoke the operation string schemaId = "schema1"; - ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData() - { - SchemaType = ApiSchemaType.Xml, - Description = "sample schema description", - Value = BinaryData.FromString("\"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\""), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaId, data); - ServiceWorkspaceSchemaResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(schemaId); + ServiceWorkspaceSchemaResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSchemaResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSchemaResource.cs index ad6651e8448b4..4330d606672fd 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSchemaResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSchemaResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceSchemaResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceSchema() + public async Task Get_ApiManagementGetWorkspaceSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceSchema.json - // this example is just showing the usage of "WorkspaceGlobalSchema_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceSchema.json + // this example is just showing the usage of "WorkspaceGlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,22 +34,26 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceSchema() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string schemaId = "myschema"; + string schemaId = "schema1"; ResourceIdentifier serviceWorkspaceSchemaResourceId = ServiceWorkspaceSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, schemaId); ServiceWorkspaceSchemaResource serviceWorkspaceSchema = client.GetServiceWorkspaceSchemaResource(serviceWorkspaceSchemaResourceId); // invoke the operation - bool result = await serviceWorkspaceSchema.GetEntityTagAsync(); + ServiceWorkspaceSchemaResource result = await serviceWorkspaceSchema.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementGlobalSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceSchema() + public async Task Delete_ApiManagementDeleteWorkspaceSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceSchema.json - // this example is just showing the usage of "WorkspaceGlobalSchema_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceSchema.json + // this example is just showing the usage of "WorkspaceGlobalSchema_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,10 @@ public async Task Get_ApiManagementGetWorkspaceSchema() ServiceWorkspaceSchemaResource serviceWorkspaceSchema = client.GetServiceWorkspaceSchemaResource(serviceWorkspaceSchemaResourceId); // invoke the operation - ServiceWorkspaceSchemaResource result = await serviceWorkspaceSchema.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceSchema.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApiManagementGlobalSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,11 +100,11 @@ public async Task Update_ApiManagementCreateWorkspaceSchema() ServiceWorkspaceSchemaResource serviceWorkspaceSchema = client.GetServiceWorkspaceSchemaResource(serviceWorkspaceSchemaResourceId); // invoke the operation - ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData() + ApiManagementGlobalSchemaData data = new ApiManagementGlobalSchemaData { SchemaType = ApiSchemaType.Xml, Description = "sample schema description", - Value = BinaryData.FromString("\"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\""), + Value = BinaryData.FromObjectAsJson("\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), }; ArmOperation lro = await serviceWorkspaceSchema.UpdateAsync(WaitUntil.Completed, data); ServiceWorkspaceSchemaResource result = lro.Value; @@ -117,10 +118,10 @@ public async Task Update_ApiManagementCreateWorkspaceSchema() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceSchema() + public async Task GetEntityTag_ApiManagementHeadWorkspaceSchema() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceSchema.json - // this example is just showing the usage of "WorkspaceGlobalSchema_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceSchema.json + // this example is just showing the usage of "WorkspaceGlobalSchema_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,15 +134,14 @@ public async Task Delete_ApiManagementDeleteWorkspaceSchema() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string schemaId = "schema1"; + string schemaId = "myschema"; ResourceIdentifier serviceWorkspaceSchemaResourceId = ServiceWorkspaceSchemaResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, schemaId); ServiceWorkspaceSchemaResource serviceWorkspaceSchema = client.GetServiceWorkspaceSchemaResource(serviceWorkspaceSchemaResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceSchema.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceWorkspaceSchema.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSubscriptionCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSubscriptionCollection.cs index 8aece43b45a74..78a280776d7ed 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSubscriptionCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSubscriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceSubscriptions() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceSubscriptions.json - // this example is just showing the usage of "WorkspaceSubscription_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceSubscription.json + // this example is just showing the usage of "WorkspaceSubscription_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,22 @@ public async Task GetAll_ApiManagementListWorkspaceSubscriptions() // get the collection of this ServiceWorkspaceSubscriptionResource ServiceWorkspaceSubscriptionCollection collection = workspaceContract.GetServiceWorkspaceSubscriptions(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceSubscriptionResource item in collection.GetAllAsync()) + // invoke the operation + string sid = "testsub"; + ApiManagementSubscriptionCreateOrUpdateContent content = new ApiManagementSubscriptionCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + OwnerId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7", + Scope = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/products/5600b59475ff190048060002", + DisplayName = "testsub", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sid, content); + ServiceWorkspaceSubscriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +95,10 @@ public async Task Get_ApiManagementGetWorkspaceSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceSubscription() + public async Task GetAll_ApiManagementListWorkspaceSubscriptions() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceSubscription.json - // this example is just showing the usage of "WorkspaceSubscription_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceSubscriptions.json + // this example is just showing the usage of "WorkspaceSubscription_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +117,22 @@ public async Task Exists_ApiManagementGetWorkspaceSubscription() // get the collection of this ServiceWorkspaceSubscriptionResource ServiceWorkspaceSubscriptionCollection collection = workspaceContract.GetServiceWorkspaceSubscriptions(); - // invoke the operation - string sid = "5931a769d8d14f0ad8ce13b8"; - bool result = await collection.ExistsAsync(sid); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceSubscription() + public async Task Exists_ApiManagementGetWorkspaceSubscription() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceSubscription.json // this example is just showing the usage of "WorkspaceSubscription_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +156,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceSubscription() // invoke the operation string sid = "5931a769d8d14f0ad8ce13b8"; - NullableResponse response = await collection.GetIfExistsAsync(sid); - ServiceWorkspaceSubscriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sid); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceSubscription() + public async Task GetIfExists_ApiManagementGetWorkspaceSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceSubscription.json - // this example is just showing the usage of "WorkspaceSubscription_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceSubscription.json + // this example is just showing the usage of "WorkspaceSubscription_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,21 +186,22 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceSubscription() ServiceWorkspaceSubscriptionCollection collection = workspaceContract.GetServiceWorkspaceSubscriptions(); // invoke the operation - string sid = "testsub"; - ApiManagementSubscriptionCreateOrUpdateContent content = new ApiManagementSubscriptionCreateOrUpdateContent() - { - OwnerId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/users/57127d485157a511ace86ae7", - Scope = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/products/5600b59475ff190048060002", - DisplayName = "testsub", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sid, content); - ServiceWorkspaceSubscriptionResource result = lro.Value; + string sid = "5931a769d8d14f0ad8ce13b8"; + NullableResponse response = await collection.GetIfExistsAsync(sid); + ServiceWorkspaceSubscriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSubscriptionResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSubscriptionResource.cs index e0ff8e0d208e4..c92379f2be0e0 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSubscriptionResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceSubscriptionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceSubscriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspaceSubscription() + public async Task Get_ApiManagementGetWorkspaceSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceSubscription.json - // this example is just showing the usage of "WorkspaceSubscription_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceSubscription.json + // this example is just showing the usage of "WorkspaceSubscription_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityTag_ApiManagementHeadWorkspaceSubscription() ServiceWorkspaceSubscriptionResource serviceWorkspaceSubscription = client.GetServiceWorkspaceSubscriptionResource(serviceWorkspaceSubscriptionResourceId); // invoke the operation - bool result = await serviceWorkspaceSubscription.GetEntityTagAsync(); + ServiceWorkspaceSubscriptionResource result = await serviceWorkspaceSubscription.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubscriptionContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceSubscription() + public async Task Delete_ApiManagementDeleteWorkspaceSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceSubscription.json - // this example is just showing the usage of "WorkspaceSubscription_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceSubscription.json + // this example is just showing the usage of "WorkspaceSubscription_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,18 +66,15 @@ public async Task Get_ApiManagementGetWorkspaceSubscription() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string sid = "5931a769d8d14f0ad8ce13b8"; + string sid = "testsub"; ResourceIdentifier serviceWorkspaceSubscriptionResourceId = ServiceWorkspaceSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, sid); ServiceWorkspaceSubscriptionResource serviceWorkspaceSubscription = client.GetServiceWorkspaceSubscriptionResource(serviceWorkspaceSubscriptionResourceId); // invoke the operation - ServiceWorkspaceSubscriptionResource result = await serviceWorkspaceSubscription.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceSubscription.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubscriptionContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,7 +101,7 @@ public async Task Update_ApiManagementUpdateWorkspaceSubscription() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementSubscriptionPatch patch = new ApiManagementSubscriptionPatch() + ApiManagementSubscriptionPatch patch = new ApiManagementSubscriptionPatch { DisplayName = "testsub", }; @@ -115,10 +116,10 @@ public async Task Update_ApiManagementUpdateWorkspaceSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceSubscription() + public async Task RegeneratePrimaryKey_ApiManagementWorkspaceSubscriptionRegeneratePrimaryKey() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceSubscription.json - // this example is just showing the usage of "WorkspaceSubscription_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementWorkspaceSubscriptionRegeneratePrimaryKey.json + // this example is just showing the usage of "WorkspaceSubscription_RegeneratePrimaryKey" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,18 +137,17 @@ public async Task Delete_ApiManagementDeleteWorkspaceSubscription() ServiceWorkspaceSubscriptionResource serviceWorkspaceSubscription = client.GetServiceWorkspaceSubscriptionResource(serviceWorkspaceSubscriptionResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceSubscription.DeleteAsync(WaitUntil.Completed, ifMatch); + await serviceWorkspaceSubscription.RegeneratePrimaryKeyAsync(); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task RegeneratePrimaryKey_ApiManagementWorkspaceSubscriptionRegeneratePrimaryKey() + public async Task RegenerateSecondaryKey_ApiManagementWorkspaceSubscriptionRegenerateSecondaryKey() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementWorkspaceSubscriptionRegeneratePrimaryKey.json - // this example is just showing the usage of "WorkspaceSubscription_RegeneratePrimaryKey" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementWorkspaceSubscriptionRegenerateSecondaryKey.json + // this example is just showing the usage of "WorkspaceSubscription_RegenerateSecondaryKey" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,17 +165,17 @@ public async Task RegeneratePrimaryKey_ApiManagementWorkspaceSubscriptionRegener ServiceWorkspaceSubscriptionResource serviceWorkspaceSubscription = client.GetServiceWorkspaceSubscriptionResource(serviceWorkspaceSubscriptionResourceId); // invoke the operation - await serviceWorkspaceSubscription.RegeneratePrimaryKeyAsync(); + await serviceWorkspaceSubscription.RegenerateSecondaryKeyAsync(); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task RegenerateSecondaryKey_ApiManagementWorkspaceSubscriptionRegenerateSecondaryKey() + public async Task GetSecrets_ApiManagementWorkspaceSubscriptionListSecrets() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementWorkspaceSubscriptionRegenerateSecondaryKey.json - // this example is just showing the usage of "WorkspaceSubscription_RegenerateSecondaryKey" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementWorkspaceSubscriptionListSecrets.json + // this example is just showing the usage of "WorkspaceSubscription_ListSecrets" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,22 +188,22 @@ public async Task RegenerateSecondaryKey_ApiManagementWorkspaceSubscriptionRegen string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string sid = "testsub"; + string sid = "5931a769d8d14f0ad8ce13b8"; ResourceIdentifier serviceWorkspaceSubscriptionResourceId = ServiceWorkspaceSubscriptionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, sid); ServiceWorkspaceSubscriptionResource serviceWorkspaceSubscription = client.GetServiceWorkspaceSubscriptionResource(serviceWorkspaceSubscriptionResourceId); // invoke the operation - await serviceWorkspaceSubscription.RegenerateSecondaryKeyAsync(); + SubscriptionKeysContract result = await serviceWorkspaceSubscription.GetSecretsAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSecrets_ApiManagementWorkspaceSubscriptionListSecrets() + public async Task GetEntityTag_ApiManagementHeadWorkspaceSubscription() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementWorkspaceSubscriptionListSecrets.json - // this example is just showing the usage of "WorkspaceSubscription_ListSecrets" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceSubscription.json + // this example is just showing the usage of "WorkspaceSubscription_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -221,7 +221,7 @@ public async Task GetSecrets_ApiManagementWorkspaceSubscriptionListSecrets() ServiceWorkspaceSubscriptionResource serviceWorkspaceSubscription = client.GetServiceWorkspaceSubscriptionResource(serviceWorkspaceSubscriptionResourceId); // invoke the operation - SubscriptionKeysContract result = await serviceWorkspaceSubscription.GetSecretsAsync(); + bool result = await serviceWorkspaceSubscription.GetEntityTagAsync(); Console.WriteLine($"Succeeded: {result}"); } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagApiLinkCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagApiLinkCollection.cs index 11ed70e2bdce9..6bf4280e32312 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagApiLinkCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagApiLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceWorkspaceTagApiLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceTagApiLinks() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTagApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceTagApiLinks.json - // this example is just showing the usage of "WorkspaceTagApiLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagApiLink.json + // this example is just showing the usage of "WorkspaceTagApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_ApiManagementListWorkspaceTagApiLinks() // get the collection of this ServiceWorkspaceTagApiLinkResource ServiceWorkspaceTagApiLinkCollection collection = serviceWorkspaceTag.GetServiceWorkspaceTagApiLinks(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceTagApiLinkResource item in collection.GetAllAsync()) + // invoke the operation + string apiLinkId = "link1"; + TagApiLinkContractData data = new TagApiLinkContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagApiLinkContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiLinkId, data); + ServiceWorkspaceTagApiLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +94,10 @@ public async Task Get_ApiManagementGetWorkspaceTagApiLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceTagApiLink() + public async Task GetAll_ApiManagementListWorkspaceTagApiLinks() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTagApiLink.json - // this example is just showing the usage of "WorkspaceTagApiLink_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceTagApiLinks.json + // this example is just showing the usage of "WorkspaceTagApiLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +117,22 @@ public async Task Exists_ApiManagementGetWorkspaceTagApiLink() // get the collection of this ServiceWorkspaceTagApiLinkResource ServiceWorkspaceTagApiLinkCollection collection = serviceWorkspaceTag.GetServiceWorkspaceTagApiLinks(); - // invoke the operation - string apiLinkId = "link1"; - bool result = await collection.ExistsAsync(apiLinkId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceTagApiLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagApiLinkContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceTagApiLink() + public async Task Exists_ApiManagementGetWorkspaceTagApiLink() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTagApiLink.json // this example is just showing the usage of "WorkspaceTagApiLink_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +157,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceTagApiLink() // invoke the operation string apiLinkId = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(apiLinkId); - ServiceWorkspaceTagApiLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(apiLinkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTagApiLink() + public async Task GetIfExists_ApiManagementGetWorkspaceTagApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagApiLink.json - // this example is just showing the usage of "WorkspaceTagApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTagApiLink.json + // this example is just showing the usage of "WorkspaceTagApiLink_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,18 +189,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTagApiLink() // invoke the operation string apiLinkId = "link1"; - TagApiLinkContractData data = new TagApiLinkContractData() - { - ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiLinkId, data); - ServiceWorkspaceTagApiLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(apiLinkId); + ServiceWorkspaceTagApiLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagApiLinkResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagApiLinkResource.cs index 7be0b35926987..263659a326e95 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagApiLinkResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagApiLinkResource.cs @@ -50,10 +50,10 @@ public async Task Get_ApiManagementGetWorkspaceTagApiLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateWorkspaceTagApiLink() + public async Task Delete_ApiManagementDeleteWorkspaceTagApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagApiLink.json - // this example is just showing the usage of "WorkspaceTagApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceTagApiLink.json + // this example is just showing the usage of "WorkspaceTagApiLink_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,26 +72,17 @@ public async Task Update_ApiManagementCreateWorkspaceTagApiLink() ServiceWorkspaceTagApiLinkResource serviceWorkspaceTagApiLink = client.GetServiceWorkspaceTagApiLinkResource(serviceWorkspaceTagApiLinkResourceId); // invoke the operation - TagApiLinkContractData data = new TagApiLinkContractData() - { - ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api", - }; - ArmOperation lro = await serviceWorkspaceTagApiLink.UpdateAsync(WaitUntil.Completed, data); - ServiceWorkspaceTagApiLinkResource result = lro.Value; + await serviceWorkspaceTagApiLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagApiLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceTagApiLink() + public async Task Update_ApiManagementCreateWorkspaceTagApiLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceTagApiLink.json - // this example is just showing the usage of "WorkspaceTagApiLink_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagApiLink.json + // this example is just showing the usage of "WorkspaceTagApiLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +101,18 @@ public async Task Delete_ApiManagementDeleteWorkspaceTagApiLink() ServiceWorkspaceTagApiLinkResource serviceWorkspaceTagApiLink = client.GetServiceWorkspaceTagApiLinkResource(serviceWorkspaceTagApiLinkResourceId); // invoke the operation - await serviceWorkspaceTagApiLink.DeleteAsync(WaitUntil.Completed); + TagApiLinkContractData data = new TagApiLinkContractData + { + ApiId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api", + }; + ArmOperation lro = await serviceWorkspaceTagApiLink.UpdateAsync(WaitUntil.Completed, data); + ServiceWorkspaceTagApiLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagApiLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagCollection.cs index 5537eac170f37..109594a6ffa77 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceTagCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceTags() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceTags.json - // this example is just showing the usage of "WorkspaceTag_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTag.json + // this example is just showing the usage of "WorkspaceTag_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_ApiManagementListWorkspaceTags() // get the collection of this ServiceWorkspaceTagResource ServiceWorkspaceTagCollection collection = workspaceContract.GetServiceWorkspaceTags(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceTagResource item in collection.GetAllAsync()) + // invoke the operation + string tagId = "tagId1"; + ApiManagementTagCreateOrUpdateContent content = new ApiManagementTagCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "tag1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagId, content); + ServiceWorkspaceTagResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +93,10 @@ public async Task Get_ApiManagementGetWorkspaceTag() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceTag() + public async Task GetAll_ApiManagementListWorkspaceTags() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTag.json - // this example is just showing the usage of "WorkspaceTag_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceTags.json + // this example is just showing the usage of "WorkspaceTag_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +115,22 @@ public async Task Exists_ApiManagementGetWorkspaceTag() // get the collection of this ServiceWorkspaceTagResource ServiceWorkspaceTagCollection collection = workspaceContract.GetServiceWorkspaceTags(); - // invoke the operation - string tagId = "59306a29e4bbd510dc24e5f9"; - bool result = await collection.ExistsAsync(tagId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceTagResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceTag() + public async Task Exists_ApiManagementGetWorkspaceTag() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTag.json // this example is just showing the usage of "WorkspaceTag_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +154,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceTag() // invoke the operation string tagId = "59306a29e4bbd510dc24e5f9"; - NullableResponse response = await collection.GetIfExistsAsync(tagId); - ServiceWorkspaceTagResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(tagId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTag() + public async Task GetIfExists_ApiManagementGetWorkspaceTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTag.json - // this example is just showing the usage of "WorkspaceTag_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTag.json + // this example is just showing the usage of "WorkspaceTag_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,19 +184,22 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTag() ServiceWorkspaceTagCollection collection = workspaceContract.GetServiceWorkspaceTags(); // invoke the operation - string tagId = "tagId1"; - ApiManagementTagCreateOrUpdateContent content = new ApiManagementTagCreateOrUpdateContent() - { - DisplayName = "tag1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tagId, content); - ServiceWorkspaceTagResource result = lro.Value; + string tagId = "59306a29e4bbd510dc24e5f9"; + NullableResponse response = await collection.GetIfExistsAsync(tagId); + ServiceWorkspaceTagResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagOperationLinkCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagOperationLinkCollection.cs index 818e3aee68507..9da86395c8774 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagOperationLinkCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagOperationLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceWorkspaceTagOperationLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceTagOperationLinks() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTagOperationLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceTagOperationLinks.json - // this example is just showing the usage of "WorkspaceTagOperationLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagOperationLink.json + // this example is just showing the usage of "WorkspaceTagOperationLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_ApiManagementListWorkspaceTagOperationLinks() // get the collection of this ServiceWorkspaceTagOperationLinkResource ServiceWorkspaceTagOperationLinkCollection collection = serviceWorkspaceTag.GetServiceWorkspaceTagOperationLinks(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceTagOperationLinkResource item in collection.GetAllAsync()) + // invoke the operation + string operationLinkId = "link1"; + TagOperationLinkContractData data = new TagOperationLinkContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagOperationLinkContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + OperationId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api/operations/op1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, operationLinkId, data); + ServiceWorkspaceTagOperationLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagOperationLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +94,10 @@ public async Task Get_ApiManagementGetWorkspaceTagOperationLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceTagOperationLink() + public async Task GetAll_ApiManagementListWorkspaceTagOperationLinks() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTagOperationLink.json - // this example is just showing the usage of "WorkspaceTagOperationLink_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceTagOperationLinks.json + // this example is just showing the usage of "WorkspaceTagOperationLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +117,22 @@ public async Task Exists_ApiManagementGetWorkspaceTagOperationLink() // get the collection of this ServiceWorkspaceTagOperationLinkResource ServiceWorkspaceTagOperationLinkCollection collection = serviceWorkspaceTag.GetServiceWorkspaceTagOperationLinks(); - // invoke the operation - string operationLinkId = "link1"; - bool result = await collection.ExistsAsync(operationLinkId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceTagOperationLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagOperationLinkContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceTagOperationLink() + public async Task Exists_ApiManagementGetWorkspaceTagOperationLink() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTagOperationLink.json // this example is just showing the usage of "WorkspaceTagOperationLink_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +157,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceTagOperationLink() // invoke the operation string operationLinkId = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(operationLinkId); - ServiceWorkspaceTagOperationLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(operationLinkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagOperationLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTagOperationLink() + public async Task GetIfExists_ApiManagementGetWorkspaceTagOperationLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagOperationLink.json - // this example is just showing the usage of "WorkspaceTagOperationLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTagOperationLink.json + // this example is just showing the usage of "WorkspaceTagOperationLink_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,18 +189,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTagOperationLink() // invoke the operation string operationLinkId = "link1"; - TagOperationLinkContractData data = new TagOperationLinkContractData() - { - OperationId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api/operations/op1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, operationLinkId, data); - ServiceWorkspaceTagOperationLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(operationLinkId); + ServiceWorkspaceTagOperationLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagOperationLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagOperationLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagOperationLinkResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagOperationLinkResource.cs index 8e24074b4dfe7..b343230f37169 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagOperationLinkResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagOperationLinkResource.cs @@ -50,10 +50,10 @@ public async Task Get_ApiManagementGetWorkspaceTagOperationLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateWorkspaceTagOperationLink() + public async Task Delete_ApiManagementDeleteWorkspaceTagOperationLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagOperationLink.json - // this example is just showing the usage of "WorkspaceTagOperationLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceTagOperationLink.json + // this example is just showing the usage of "WorkspaceTagOperationLink_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,26 +72,17 @@ public async Task Update_ApiManagementCreateWorkspaceTagOperationLink() ServiceWorkspaceTagOperationLinkResource serviceWorkspaceTagOperationLink = client.GetServiceWorkspaceTagOperationLinkResource(serviceWorkspaceTagOperationLinkResourceId); // invoke the operation - TagOperationLinkContractData data = new TagOperationLinkContractData() - { - OperationId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api/operations/op1", - }; - ArmOperation lro = await serviceWorkspaceTagOperationLink.UpdateAsync(WaitUntil.Completed, data); - ServiceWorkspaceTagOperationLinkResource result = lro.Value; + await serviceWorkspaceTagOperationLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagOperationLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceTagOperationLink() + public async Task Update_ApiManagementCreateWorkspaceTagOperationLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceTagOperationLink.json - // this example is just showing the usage of "WorkspaceTagOperationLink_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagOperationLink.json + // this example is just showing the usage of "WorkspaceTagOperationLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +101,18 @@ public async Task Delete_ApiManagementDeleteWorkspaceTagOperationLink() ServiceWorkspaceTagOperationLinkResource serviceWorkspaceTagOperationLink = client.GetServiceWorkspaceTagOperationLinkResource(serviceWorkspaceTagOperationLinkResourceId); // invoke the operation - await serviceWorkspaceTagOperationLink.DeleteAsync(WaitUntil.Completed); + TagOperationLinkContractData data = new TagOperationLinkContractData + { + OperationId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/apis/echo-api/operations/op1", + }; + ArmOperation lro = await serviceWorkspaceTagOperationLink.UpdateAsync(WaitUntil.Completed, data); + ServiceWorkspaceTagOperationLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagOperationLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagProductLinkCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagProductLinkCollection.cs index 4baf780de3fe0..301bab30a76ee 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagProductLinkCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagProductLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceWorkspaceTagProductLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaceTagProductLinks() + public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTagProductLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceTagProductLinks.json - // this example is just showing the usage of "WorkspaceTagProductLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagProductLink.json + // this example is just showing the usage of "WorkspaceTagProductLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_ApiManagementListWorkspaceTagProductLinks() // get the collection of this ServiceWorkspaceTagProductLinkResource ServiceWorkspaceTagProductLinkCollection collection = serviceWorkspaceTag.GetServiceWorkspaceTagProductLinks(); - // invoke the operation and iterate over the result - await foreach (ServiceWorkspaceTagProductLinkResource item in collection.GetAllAsync()) + // invoke the operation + string productLinkId = "link1"; + TagProductLinkContractData data = new TagProductLinkContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagProductLinkContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ProductId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/products/product1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, productLinkId, data); + ServiceWorkspaceTagProductLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagProductLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +94,10 @@ public async Task Get_ApiManagementGetWorkspaceTagProductLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspaceTagProductLink() + public async Task GetAll_ApiManagementListWorkspaceTagProductLinks() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTagProductLink.json - // this example is just showing the usage of "WorkspaceTagProductLink_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaceTagProductLinks.json + // this example is just showing the usage of "WorkspaceTagProductLink_ListByProduct" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +117,22 @@ public async Task Exists_ApiManagementGetWorkspaceTagProductLink() // get the collection of this ServiceWorkspaceTagProductLinkResource ServiceWorkspaceTagProductLinkCollection collection = serviceWorkspaceTag.GetServiceWorkspaceTagProductLinks(); - // invoke the operation - string productLinkId = "link1"; - bool result = await collection.ExistsAsync(productLinkId); + // invoke the operation and iterate over the result + await foreach (ServiceWorkspaceTagProductLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagProductLinkContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspaceTagProductLink() + public async Task Exists_ApiManagementGetWorkspaceTagProductLink() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTagProductLink.json // this example is just showing the usage of "WorkspaceTagProductLink_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +157,17 @@ public async Task GetIfExists_ApiManagementGetWorkspaceTagProductLink() // invoke the operation string productLinkId = "link1"; - NullableResponse response = await collection.GetIfExistsAsync(productLinkId); - ServiceWorkspaceTagProductLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(productLinkId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagProductLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTagProductLink() + public async Task GetIfExists_ApiManagementGetWorkspaceTagProductLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagProductLink.json - // this example is just showing the usage of "WorkspaceTagProductLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTagProductLink.json + // this example is just showing the usage of "WorkspaceTagProductLink_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,18 +189,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspaceTagProductLink() // invoke the operation string productLinkId = "link1"; - TagProductLinkContractData data = new TagProductLinkContractData() - { - ProductId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/products/product1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, productLinkId, data); - ServiceWorkspaceTagProductLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(productLinkId); + ServiceWorkspaceTagProductLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagProductLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagProductLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagProductLinkResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagProductLinkResource.cs index 78e084f38f117..ede43a47f4210 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagProductLinkResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagProductLinkResource.cs @@ -50,10 +50,10 @@ public async Task Get_ApiManagementGetWorkspaceTagProductLink() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiManagementCreateWorkspaceTagProductLink() + public async Task Delete_ApiManagementDeleteWorkspaceTagProductLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagProductLink.json - // this example is just showing the usage of "WorkspaceTagProductLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceTagProductLink.json + // this example is just showing the usage of "WorkspaceTagProductLink_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,26 +72,17 @@ public async Task Update_ApiManagementCreateWorkspaceTagProductLink() ServiceWorkspaceTagProductLinkResource serviceWorkspaceTagProductLink = client.GetServiceWorkspaceTagProductLinkResource(serviceWorkspaceTagProductLinkResourceId); // invoke the operation - TagProductLinkContractData data = new TagProductLinkContractData() - { - ProductId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/products/product1", - }; - ArmOperation lro = await serviceWorkspaceTagProductLink.UpdateAsync(WaitUntil.Completed, data); - ServiceWorkspaceTagProductLinkResource result = lro.Value; + await serviceWorkspaceTagProductLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagProductLinkContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceTagProductLink() + public async Task Update_ApiManagementCreateWorkspaceTagProductLink() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceTagProductLink.json - // this example is just showing the usage of "WorkspaceTagProductLink_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspaceTagProductLink.json + // this example is just showing the usage of "WorkspaceTagProductLink_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +101,18 @@ public async Task Delete_ApiManagementDeleteWorkspaceTagProductLink() ServiceWorkspaceTagProductLinkResource serviceWorkspaceTagProductLink = client.GetServiceWorkspaceTagProductLinkResource(serviceWorkspaceTagProductLinkResourceId); // invoke the operation - await serviceWorkspaceTagProductLink.DeleteAsync(WaitUntil.Completed); + TagProductLinkContractData data = new TagProductLinkContractData + { + ProductId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/workspaces/wks1/products/product1", + }; + ArmOperation lro = await serviceWorkspaceTagProductLink.UpdateAsync(WaitUntil.Completed, data); + ServiceWorkspaceTagProductLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagProductLinkContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagResource.cs index cfb0bbbcd8f40..2c3542c9a6d5a 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_ServiceWorkspaceTagResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceWorkspaceTagResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityState_ApiManagementHeadWorkspaceTag() + public async Task Get_ApiManagementGetWorkspaceTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceTag.json - // this example is just showing the usage of "WorkspaceTag_GetEntityState" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTag.json + // this example is just showing the usage of "WorkspaceTag_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetEntityState_ApiManagementHeadWorkspaceTag() ServiceWorkspaceTagResource serviceWorkspaceTag = client.GetServiceWorkspaceTagResource(serviceWorkspaceTagResourceId); // invoke the operation - bool result = await serviceWorkspaceTag.GetEntityStateAsync(); + ServiceWorkspaceTagResource result = await serviceWorkspaceTag.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TagContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspaceTag() + public async Task Delete_ApiManagementDeleteWorkspaceTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspaceTag.json - // this example is just showing the usage of "WorkspaceTag_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceTag.json + // this example is just showing the usage of "WorkspaceTag_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,18 +66,15 @@ public async Task Get_ApiManagementGetWorkspaceTag() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string tagId = "59306a29e4bbd510dc24e5f9"; + string tagId = "tagId1"; ResourceIdentifier serviceWorkspaceTagResourceId = ServiceWorkspaceTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, tagId); ServiceWorkspaceTagResource serviceWorkspaceTag = client.GetServiceWorkspaceTagResource(serviceWorkspaceTagResourceId); // invoke the operation - ServiceWorkspaceTagResource result = await serviceWorkspaceTag.GetAsync(); + ETag ifMatch = new ETag("*"); + await serviceWorkspaceTag.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TagContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,7 +101,7 @@ public async Task Update_ApiManagementUpdateWorkspaceTag() // invoke the operation ETag ifMatch = new ETag("*"); - ApiManagementTagCreateOrUpdateContent content = new ApiManagementTagCreateOrUpdateContent() + ApiManagementTagCreateOrUpdateContent content = new ApiManagementTagCreateOrUpdateContent { DisplayName = "temp tag", }; @@ -115,10 +116,10 @@ public async Task Update_ApiManagementUpdateWorkspaceTag() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspaceTag() + public async Task GetEntityState_ApiManagementHeadWorkspaceTag() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspaceTag.json - // this example is just showing the usage of "WorkspaceTag_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspaceTag.json + // this example is just showing the usage of "WorkspaceTag_GetEntityState" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,15 +132,14 @@ public async Task Delete_ApiManagementDeleteWorkspaceTag() string resourceGroupName = "rg1"; string serviceName = "apimService1"; string workspaceId = "wks1"; - string tagId = "tagId1"; + string tagId = "59306a29e4bbd510dc24e5f9"; ResourceIdentifier serviceWorkspaceTagResourceId = ServiceWorkspaceTagResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId, tagId); ServiceWorkspaceTagResource serviceWorkspaceTag = client.GetServiceWorkspaceTagResource(serviceWorkspaceTagResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await serviceWorkspaceTag.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await serviceWorkspaceTag.GetEntityStateAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index fea097ee85813..d0c8003959de9 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,117 @@ namespace Azure.ResourceManager.ApiManagement.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApiManagementDeletedServices_ApiManagementDeletedServicesListBySubscription() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeletedServicesListBySubscription.json + // this example is just showing the usage of "DeletedServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ApiManagementDeletedServiceResource item in subscriptionResource.GetApiManagementDeletedServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementDeletedServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApiManagementServices_ApiManagementListServiceBySubscription() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListServiceBySubscription.json + // this example is just showing the usage of "ApiManagementService_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ApiManagementServiceResource item in subscriptionResource.GetApiManagementServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApiManagementServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckApiManagementServiceNameAvailability_ApiManagementServiceCheckNameAvailability() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceCheckNameAvailability.json + // this example is just showing the usage of "ApiManagementService_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + ApiManagementServiceNameAvailabilityContent content = new ApiManagementServiceNameAvailabilityContent("apimService1"); + ApiManagementServiceNameAvailabilityResult result = await subscriptionResource.CheckApiManagementServiceNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApiManagementServiceDomainOwnershipIdentifier_ApiManagementServiceGetDomainOwnershipIdentifier() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementServiceGetDomainOwnershipIdentifier.json + // this example is just showing the usage of "ApiManagementService_GetDomainOwnershipIdentifier" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + ApiManagementServiceGetDomainOwnershipIdentifierResult result = await subscriptionResource.GetApiManagementServiceDomainOwnershipIdentifierAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetApiManagementSkus_ListsAllAvailableResourceSKUs() diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_TenantAccessInfoCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_TenantAccessInfoCollection.cs index 7b90f1c897fb8..eca87188ba45d 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_TenantAccessInfoCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_TenantAccessInfoCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_TenantAccessInfoCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListTenantAccess() + public async Task CreateOrUpdate_ApiManagementCreateTenantAccess() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTenantAccess.json - // this example is just showing the usage of "TenantAccess_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTenantAccess.json + // this example is just showing the usage of "TenantAccess_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ApiManagementListTenantAccess() // get the collection of this TenantAccessInfoResource TenantAccessInfoCollection collection = apiManagementService.GetTenantAccessInfos(); - // invoke the operation and iterate over the result - await foreach (TenantAccessInfoResource item in collection.GetAllAsync()) + // invoke the operation + AccessName accessName = AccessName.TenantAccess; + ETag ifMatch = new ETag("*"); + TenantAccessInfoCreateOrUpdateContent content = new TenantAccessInfoCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TenantAccessInfoData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsDirectAccessEnabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accessName, ifMatch, content); + TenantAccessInfoResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TenantAccessInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,9 +92,9 @@ public async Task Get_ApiManagementGetTenantAccess() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetTenantAccess() + public async Task Get_ApiManagementGetTenantGitAccess() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTenantAccess.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTenantGitAccess.json // this example is just showing the usage of "TenantAccess_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -110,18 +114,22 @@ public async Task Exists_ApiManagementGetTenantAccess() TenantAccessInfoCollection collection = apiManagementService.GetTenantAccessInfos(); // invoke the operation - AccessName accessName = AccessName.TenantAccess; - bool result = await collection.ExistsAsync(accessName); + AccessName accessName = AccessName.TenantGitAccess; + TenantAccessInfoResource result = await collection.GetAsync(accessName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TenantAccessInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetTenantAccess() + public async Task GetAll_ApiManagementListTenantAccess() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTenantAccess.json - // this example is just showing the usage of "TenantAccess_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListTenantAccess.json + // this example is just showing the usage of "TenantAccess_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,30 +147,24 @@ public async Task GetIfExists_ApiManagementGetTenantAccess() // get the collection of this TenantAccessInfoResource TenantAccessInfoCollection collection = apiManagementService.GetTenantAccessInfos(); - // invoke the operation - AccessName accessName = AccessName.TenantAccess; - NullableResponse response = await collection.GetIfExistsAsync(accessName); - TenantAccessInfoResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (TenantAccessInfoResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - TenantAccessInfoData resourceData = result.Data; + TenantAccessInfoData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetTenantGitAccess() + public async Task Exists_ApiManagementGetTenantAccess() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTenantGitAccess.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTenantAccess.json // this example is just showing the usage of "TenantAccess_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -182,14 +184,10 @@ public async Task Get_ApiManagementGetTenantGitAccess() TenantAccessInfoCollection collection = apiManagementService.GetTenantAccessInfos(); // invoke the operation - AccessName accessName = AccessName.TenantGitAccess; - TenantAccessInfoResource result = await collection.GetAsync(accessName); + AccessName accessName = AccessName.TenantAccess; + bool result = await collection.ExistsAsync(accessName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TenantAccessInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -224,9 +222,9 @@ public async Task Exists_ApiManagementGetTenantGitAccess() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetTenantGitAccess() + public async Task GetIfExists_ApiManagementGetTenantAccess() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTenantGitAccess.json + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTenantAccess.json // this example is just showing the usage of "TenantAccess_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -246,7 +244,7 @@ public async Task GetIfExists_ApiManagementGetTenantGitAccess() TenantAccessInfoCollection collection = apiManagementService.GetTenantAccessInfos(); // invoke the operation - AccessName accessName = AccessName.TenantGitAccess; + AccessName accessName = AccessName.TenantAccess; NullableResponse response = await collection.GetIfExistsAsync(accessName); TenantAccessInfoResource result = response.HasValue ? response.Value : null; @@ -266,10 +264,10 @@ public async Task GetIfExists_ApiManagementGetTenantGitAccess() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateTenantAccess() + public async Task GetIfExists_ApiManagementGetTenantGitAccess() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateTenantAccess.json - // this example is just showing the usage of "TenantAccess_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetTenantGitAccess.json + // this example is just showing the usage of "TenantAccess_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -288,20 +286,22 @@ public async Task CreateOrUpdate_ApiManagementCreateTenantAccess() TenantAccessInfoCollection collection = apiManagementService.GetTenantAccessInfos(); // invoke the operation - AccessName accessName = AccessName.TenantAccess; - ETag ifMatch = new ETag("*"); - TenantAccessInfoCreateOrUpdateContent content = new TenantAccessInfoCreateOrUpdateContent() - { - IsDirectAccessEnabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accessName, ifMatch, content); - TenantAccessInfoResource result = lro.Value; + AccessName accessName = AccessName.TenantGitAccess; + NullableResponse response = await collection.GetIfExistsAsync(accessName); + TenantAccessInfoResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - TenantAccessInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + TenantAccessInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_TenantAccessInfoResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_TenantAccessInfoResource.cs index 814c688723c9e..b543c69c522de 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_TenantAccessInfoResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_TenantAccessInfoResource.cs @@ -16,33 +16,6 @@ namespace Azure.ResourceManager.ApiManagement.Samples { public partial class Sample_TenantAccessInfoResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadTenantAccess() - { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadTenantAccess.json - // this example is just showing the usage of "TenantAccess_GetEntityTag" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantAccessInfoResource created on azure - // for more information of creating TenantAccessInfoResource, please refer to the document of TenantAccessInfoResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string serviceName = "apimService1"; - AccessName accessName = AccessName.TenantAccess; - ResourceIdentifier tenantAccessInfoResourceId = TenantAccessInfoResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, accessName); - TenantAccessInfoResource tenantAccessInfo = client.GetTenantAccessInfoResource(tenantAccessInfoResourceId); - - // invoke the operation - bool result = await tenantAccessInfo.GetEntityTagAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ApiManagementGetTenantAccess() @@ -128,7 +101,7 @@ public async Task Update_ApiManagementUpdateTenantAccess() // invoke the operation ETag ifMatch = new ETag("*"); - TenantAccessInfoPatch patch = new TenantAccessInfoPatch() + TenantAccessInfoPatch patch = new TenantAccessInfoPatch { IsDirectAccessEnabled = true, }; @@ -275,5 +248,32 @@ public async Task RegenerateSecondaryKeyForGit_ApiManagementTenantAccessRegenera Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEntityTag_ApiManagementHeadTenantAccess() + { + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadTenantAccess.json + // this example is just showing the usage of "TenantAccess_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this TenantAccessInfoResource created on azure + // for more information of creating TenantAccessInfoResource, please refer to the document of TenantAccessInfoResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string serviceName = "apimService1"; + AccessName accessName = AccessName.TenantAccess; + ResourceIdentifier tenantAccessInfoResourceId = TenantAccessInfoResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, accessName); + TenantAccessInfoResource tenantAccessInfo = client.GetTenantAccessInfoResource(tenantAccessInfoResourceId); + + // invoke the operation + bool result = await tenantAccessInfo.GetEntityTagAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_WorkspaceContractCollection.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_WorkspaceContractCollection.cs index 97159edaa1edc..4ebadec4286f3 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_WorkspaceContractCollection.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_WorkspaceContractCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkspaceContractCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiManagementListWorkspaces() + public async Task CreateOrUpdate_ApiManagementCreateWorkspace() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaces.json - // this example is just showing the usage of "Workspace_ListByService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspace.json + // this example is just showing the usage of "Workspace_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_ApiManagementListWorkspaces() // get the collection of this WorkspaceContractResource WorkspaceContractCollection collection = apiManagementService.GetWorkspaceContracts(); - // invoke the operation and iterate over the result - await foreach (WorkspaceContractResource item in collection.GetAllAsync()) + // invoke the operation + string workspaceId = "wks1"; + WorkspaceContractData data = new WorkspaceContractData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkspaceContractData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "my workspace", + Description = "workspace 1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceId, data); + WorkspaceContractResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkspaceContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_ApiManagementGetWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiManagementGetWorkspace() + public async Task GetAll_ApiManagementListWorkspaces() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspace.json - // this example is just showing the usage of "Workspace_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementListWorkspaces.json + // this example is just showing the usage of "Workspace_ListByService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_ApiManagementGetWorkspace() // get the collection of this WorkspaceContractResource WorkspaceContractCollection collection = apiManagementService.GetWorkspaceContracts(); - // invoke the operation - string workspaceId = "wks1"; - bool result = await collection.ExistsAsync(workspaceId); + // invoke the operation and iterate over the result + await foreach (WorkspaceContractResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkspaceContractData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiManagementGetWorkspace() + public async Task Exists_ApiManagementGetWorkspace() { // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspace.json // this example is just showing the usage of "Workspace_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_ApiManagementGetWorkspace() // invoke the operation string workspaceId = "wks1"; - NullableResponse response = await collection.GetIfExistsAsync(workspaceId); - WorkspaceContractResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(workspaceId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkspaceContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiManagementCreateWorkspace() + public async Task GetIfExists_ApiManagementGetWorkspace() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementCreateWorkspace.json - // this example is just showing the usage of "Workspace_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspace.json + // this example is just showing the usage of "Workspace_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,19 +180,21 @@ public async Task CreateOrUpdate_ApiManagementCreateWorkspace() // invoke the operation string workspaceId = "wks1"; - WorkspaceContractData data = new WorkspaceContractData() - { - DisplayName = "my workspace", - Description = "workspace 1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceId, data); - WorkspaceContractResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(workspaceId); + WorkspaceContractResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkspaceContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkspaceContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_WorkspaceContractResource.cs b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_WorkspaceContractResource.cs index b7a51b6e35a10..fe8b199e26b9a 100644 --- a/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_WorkspaceContractResource.cs +++ b/sdk/apimanagement/Azure.ResourceManager.ApiManagement/samples/Generated/Samples/Sample_WorkspaceContractResource.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkspaceContractResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetEntityTag_ApiManagementHeadWorkspace() + public async Task Get_ApiManagementGetWorkspace() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspace.json - // this example is just showing the usage of "Workspace_GetEntityTag" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspace.json + // this example is just showing the usage of "Workspace_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,22 +32,26 @@ public async Task GetEntityTag_ApiManagementHeadWorkspace() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string workspaceId = "wks"; + string workspaceId = "wks1"; ResourceIdentifier workspaceContractResourceId = WorkspaceContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId); WorkspaceContractResource workspaceContract = client.GetWorkspaceContractResource(workspaceContractResourceId); // invoke the operation - bool result = await workspaceContract.GetEntityTagAsync(); + WorkspaceContractResource result = await workspaceContract.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkspaceContractData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiManagementGetWorkspace() + public async Task Delete_ApiManagementDeleteWorkspace() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementGetWorkspace.json - // this example is just showing the usage of "Workspace_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspace.json + // this example is just showing the usage of "Workspace_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +68,10 @@ public async Task Get_ApiManagementGetWorkspace() WorkspaceContractResource workspaceContract = client.GetWorkspaceContractResource(workspaceContractResourceId); // invoke the operation - WorkspaceContractResource result = await workspaceContract.GetAsync(); + ETag ifMatch = new ETag("*"); + await workspaceContract.DeleteAsync(WaitUntil.Completed, ifMatch); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkspaceContractData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +97,7 @@ public async Task Update_ApiManagementUpdateWorkspace() // invoke the operation ETag ifMatch = new ETag("*"); - WorkspaceContractData data = new WorkspaceContractData() + WorkspaceContractData data = new WorkspaceContractData { DisplayName = "my workspace", Description = "workspace 1", @@ -112,10 +113,10 @@ public async Task Update_ApiManagementUpdateWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiManagementDeleteWorkspace() + public async Task GetEntityTag_ApiManagementHeadWorkspace() { - // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementDeleteWorkspace.json - // this example is just showing the usage of "Workspace_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/apimanagement/resource-manager/Microsoft.ApiManagement/preview/2023-03-01-preview/examples/ApiManagementHeadWorkspace.json + // this example is just showing the usage of "Workspace_GetEntityTag" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,15 +128,14 @@ public async Task Delete_ApiManagementDeleteWorkspace() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string serviceName = "apimService1"; - string workspaceId = "wks1"; + string workspaceId = "wks"; ResourceIdentifier workspaceContractResourceId = WorkspaceContractResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, workspaceId); WorkspaceContractResource workspaceContract = client.GetWorkspaceContractResource(workspaceContractResourceId); // invoke the operation - ETag ifMatch = new ETag("*"); - await workspaceContract.DeleteAsync(WaitUntil.Completed, ifMatch); + bool result = await workspaceContract.GetEntityTagAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportCollection.cs b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportCollection.cs index 184475b401062..36cc2ad105d22 100644 --- a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportCollection.cs +++ b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportCollection.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppComplianceAutomation.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppComplianceAutomation.Samples @@ -18,65 +19,61 @@ public partial class Sample_AppComplianceReportCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ReportList() + public async Task Get_ReportGet() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_List.json - // this example is just showing the usage of "Report_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_Get.json + // this example is just showing the usage of "Report_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this AppComplianceReportResource AppComplianceReportCollection collection = tenantResource.GetAppComplianceReports(); - // invoke the operation and iterate over the result - AppComplianceReportCollectionGetAllOptions options = new AppComplianceReportCollectionGetAllOptions() { SkipToken = "1", Top = 100, OfferGuid = "00000000-0000-0000-0000-000000000000", ReportCreatorTenantId = "00000000-0000-0000-0000-000000000000" }; - await foreach (AppComplianceReportResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string reportName = "testReport"; + AppComplianceReportResource result = await collection.GetAsync(reportName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ReportGet() + public async Task GetAll_ReportList() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_Get.json - // this example is just showing the usage of "Report_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_List.json + // this example is just showing the usage of "Report_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this AppComplianceReportResource AppComplianceReportCollection collection = tenantResource.GetAppComplianceReports(); - // invoke the operation - string reportName = "testReport"; - AppComplianceReportResource result = await collection.GetAsync(reportName); + // invoke the operation and iterate over the result + AppComplianceReportCollectionGetAllOptions options = new AppComplianceReportCollectionGetAllOptions { SkipToken = "1", Top = 100, OfferGuid = "00000000-0000-0000-0000-000000000000", ReportCreatorTenantId = "00000000-0000-0000-0000-000000000000" }; + await foreach (AppComplianceReportResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -91,9 +88,7 @@ public async Task Exists_ReportGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this AppComplianceReportResource AppComplianceReportCollection collection = tenantResource.GetAppComplianceReports(); @@ -117,9 +112,7 @@ public async Task GetIfExists_ReportGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this AppComplianceReportResource AppComplianceReportCollection collection = tenantResource.GetAppComplianceReports(); diff --git a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportEvidenceCollection.cs b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportEvidenceCollection.cs index 1c10bb247de46..8b5b4993fa12b 100644 --- a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportEvidenceCollection.cs +++ b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportEvidenceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppComplianceReportEvidenceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EvidenceListByReport() + public async Task Get_EvidenceGet() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Evidence_ListByReport.json - // this example is just showing the usage of "Evidence_ListByReport" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Evidence_Get.json + // this example is just showing the usage of "Evidence_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,33 +30,30 @@ public async Task GetAll_EvidenceListByReport() // this example assumes you already have this AppComplianceReportResource created on azure // for more information of creating AppComplianceReportResource, please refer to the document of AppComplianceReportResource - string reportName = "reportName"; + string reportName = "testReportName"; ResourceIdentifier appComplianceReportResourceId = AppComplianceReportResource.CreateResourceIdentifier(reportName); AppComplianceReportResource appComplianceReport = client.GetAppComplianceReportResource(appComplianceReportResourceId); // get the collection of this AppComplianceReportEvidenceResource AppComplianceReportEvidenceCollection collection = appComplianceReport.GetAppComplianceReportEvidences(); - // invoke the operation and iterate over the result - AppComplianceReportEvidenceCollectionGetAllOptions options = new AppComplianceReportEvidenceCollectionGetAllOptions() { }; - await foreach (AppComplianceReportEvidenceResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportEvidenceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string evidenceName = "evidence1"; + AppComplianceReportEvidenceResource result = await collection.GetAsync(evidenceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportEvidenceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_EvidenceGet() + public async Task GetAll_EvidenceListByReport() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Evidence_Get.json - // this example is just showing the usage of "Evidence_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Evidence_ListByReport.json + // this example is just showing the usage of "Evidence_ListByReport" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,22 +62,25 @@ public async Task Get_EvidenceGet() // this example assumes you already have this AppComplianceReportResource created on azure // for more information of creating AppComplianceReportResource, please refer to the document of AppComplianceReportResource - string reportName = "testReportName"; + string reportName = "reportName"; ResourceIdentifier appComplianceReportResourceId = AppComplianceReportResource.CreateResourceIdentifier(reportName); AppComplianceReportResource appComplianceReport = client.GetAppComplianceReportResource(appComplianceReportResourceId); // get the collection of this AppComplianceReportEvidenceResource AppComplianceReportEvidenceCollection collection = appComplianceReport.GetAppComplianceReportEvidences(); - // invoke the operation - string evidenceName = "evidence1"; - AppComplianceReportEvidenceResource result = await collection.GetAsync(evidenceName); + // invoke the operation and iterate over the result + AppComplianceReportEvidenceCollectionGetAllOptions options = new AppComplianceReportEvidenceCollectionGetAllOptions(); + await foreach (AppComplianceReportEvidenceResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportEvidenceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportEvidenceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportResource.cs b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportResource.cs index 4f39bd9a94252..1e98ef181df87 100644 --- a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportResource.cs +++ b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportResource.cs @@ -46,10 +46,10 @@ public async Task Get_ReportGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ReportUpdate() + public async Task Delete_ReportDelete() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_Update.json - // this example is just showing the usage of "Report_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_Delete.json + // this example is just showing the usage of "Report_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,23 +63,17 @@ public async Task Update_ReportUpdate() AppComplianceReportResource appComplianceReport = client.GetAppComplianceReportResource(appComplianceReportResourceId); // invoke the operation - AppComplianceReportPatch patch = new AppComplianceReportPatch(); - ArmOperation lro = await appComplianceReport.UpdateAsync(WaitUntil.Completed, patch); - AppComplianceReportResource result = lro.Value; + await appComplianceReport.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ReportDelete() + public async Task Update_ReportUpdate() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_Delete.json - // this example is just showing the usage of "Report_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Report_Update.json + // this example is just showing the usage of "Report_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,9 +87,15 @@ public async Task Delete_ReportDelete() AppComplianceReportResource appComplianceReport = client.GetAppComplianceReportResource(appComplianceReportResourceId); // invoke the operation - await appComplianceReport.DeleteAsync(WaitUntil.Completed); + AppComplianceReportPatch patch = new AppComplianceReportPatch(); + ArmOperation lro = await appComplianceReport.UpdateAsync(WaitUntil.Completed, patch); + AppComplianceReportResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportScopingConfigurationCollection.cs b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportScopingConfigurationCollection.cs index 28a8349a82f14..f1777ca613a63 100644 --- a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportScopingConfigurationCollection.cs +++ b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportScopingConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppComplianceReportScopingConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScopingConfigurationList() + public async Task Get_ScopingConfiguration() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/ScopingConfiguration_List.json - // this example is just showing the usage of "ScopingConfiguration_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/ScopingConfiguration_Get.json + // this example is just showing the usage of "ScopingConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,25 +36,23 @@ public async Task GetAll_ScopingConfigurationList() // get the collection of this AppComplianceReportScopingConfigurationResource AppComplianceReportScopingConfigurationCollection collection = appComplianceReport.GetAppComplianceReportScopingConfigurations(); - // invoke the operation and iterate over the result - await foreach (AppComplianceReportScopingConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportScopingConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scopingConfigurationName = "default"; + AppComplianceReportScopingConfigurationResource result = await collection.GetAsync(scopingConfigurationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportScopingConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ScopingConfiguration() + public async Task GetAll_ScopingConfigurationList() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/ScopingConfiguration_Get.json - // this example is just showing the usage of "ScopingConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/ScopingConfiguration_List.json + // this example is just showing the usage of "ScopingConfiguration_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,15 +68,17 @@ public async Task Get_ScopingConfiguration() // get the collection of this AppComplianceReportScopingConfigurationResource AppComplianceReportScopingConfigurationCollection collection = appComplianceReport.GetAppComplianceReportScopingConfigurations(); - // invoke the operation - string scopingConfigurationName = "default"; - AppComplianceReportScopingConfigurationResource result = await collection.GetAsync(scopingConfigurationName); + // invoke the operation and iterate over the result + await foreach (AppComplianceReportScopingConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportScopingConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportScopingConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportSnapshotCollection.cs b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportSnapshotCollection.cs index dde17efb40731..0f485a19564c4 100644 --- a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportSnapshotCollection.cs +++ b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportSnapshotCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppComplianceReportSnapshotCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SnapshotList() + public async Task Get_SnapshotGet() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Snapshot_List.json - // this example is just showing the usage of "Snapshot_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Snapshot_Get.json + // this example is just showing the usage of "Snapshot_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,26 +37,23 @@ public async Task GetAll_SnapshotList() // get the collection of this AppComplianceReportSnapshotResource AppComplianceReportSnapshotCollection collection = appComplianceReport.GetAppComplianceReportSnapshots(); - // invoke the operation and iterate over the result - AppComplianceReportSnapshotCollectionGetAllOptions options = new AppComplianceReportSnapshotCollectionGetAllOptions() { SkipToken = "1", Top = 100, OfferGuid = "00000000-0000-0000-0000-000000000001", ReportCreatorTenantId = "00000000-0000-0000-0000-000000000000" }; - await foreach (AppComplianceReportSnapshotResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportSnapshotData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string snapshotName = "testSnapshot"; + AppComplianceReportSnapshotResource result = await collection.GetAsync(snapshotName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SnapshotGet() + public async Task GetAll_SnapshotList() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Snapshot_Get.json - // this example is just showing the usage of "Snapshot_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Snapshot_List.json + // this example is just showing the usage of "Snapshot_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +69,18 @@ public async Task Get_SnapshotGet() // get the collection of this AppComplianceReportSnapshotResource AppComplianceReportSnapshotCollection collection = appComplianceReport.GetAppComplianceReportSnapshots(); - // invoke the operation - string snapshotName = "testSnapshot"; - AppComplianceReportSnapshotResource result = await collection.GetAsync(snapshotName); + // invoke the operation and iterate over the result + AppComplianceReportSnapshotCollectionGetAllOptions options = new AppComplianceReportSnapshotCollectionGetAllOptions { SkipToken = "1", Top = 100, OfferGuid = "00000000-0000-0000-0000-000000000001", ReportCreatorTenantId = "00000000-0000-0000-0000-000000000000" }; + await foreach (AppComplianceReportSnapshotResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportSnapshotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportSnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportWebhookCollection.cs b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportWebhookCollection.cs index d780bbf6be770..7c339ad6f0550 100644 --- a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportWebhookCollection.cs +++ b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportWebhookCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppComplianceReportWebhookCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WebhookList() + public async Task Get_WebhookGet() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_List.json - // this example is just showing the usage of "Webhook_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_Get.json + // this example is just showing the usage of "Webhook_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,26 +37,23 @@ public async Task GetAll_WebhookList() // get the collection of this AppComplianceReportWebhookResource AppComplianceReportWebhookCollection collection = appComplianceReport.GetAppComplianceReportWebhooks(); - // invoke the operation and iterate over the result - AppComplianceReportWebhookCollectionGetAllOptions options = new AppComplianceReportWebhookCollectionGetAllOptions() { SkipToken = "1", Top = 100 }; - await foreach (AppComplianceReportWebhookResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportWebhookData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string webhookName = "testWebhookName"; + AppComplianceReportWebhookResource result = await collection.GetAsync(webhookName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportWebhookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WebhookGet() + public async Task GetAll_WebhookList() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_Get.json - // this example is just showing the usage of "Webhook_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_List.json + // this example is just showing the usage of "Webhook_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +69,18 @@ public async Task Get_WebhookGet() // get the collection of this AppComplianceReportWebhookResource AppComplianceReportWebhookCollection collection = appComplianceReport.GetAppComplianceReportWebhooks(); - // invoke the operation - string webhookName = "testWebhookName"; - AppComplianceReportWebhookResource result = await collection.GetAsync(webhookName); + // invoke the operation and iterate over the result + AppComplianceReportWebhookCollectionGetAllOptions options = new AppComplianceReportWebhookCollectionGetAllOptions { SkipToken = "1", Top = 100 }; + await foreach (AppComplianceReportWebhookResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportWebhookData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportWebhookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportWebhookResource.cs b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportWebhookResource.cs index 4a3837f368f15..9c313d028b948 100644 --- a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportWebhookResource.cs +++ b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_AppComplianceReportWebhookResource.cs @@ -47,10 +47,10 @@ public async Task Get_WebhookGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WebhookUpdate() + public async Task Delete_WebhookDelete() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_Update.json - // this example is just showing the usage of "Webhook_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_Delete.json + // this example is just showing the usage of "Webhook_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,22 +65,17 @@ public async Task Update_WebhookUpdate() AppComplianceReportWebhookResource appComplianceReportWebhook = client.GetAppComplianceReportWebhookResource(appComplianceReportWebhookResourceId); // invoke the operation - AppComplianceReportWebhookPatch patch = new AppComplianceReportWebhookPatch(); - AppComplianceReportWebhookResource result = await appComplianceReportWebhook.UpdateAsync(patch); + await appComplianceReportWebhook.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppComplianceReportWebhookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WebhookDelete() + public async Task Update_WebhookUpdate() { - // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_Delete.json - // this example is just showing the usage of "Webhook_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appcomplianceautomation/resource-manager/Microsoft.AppComplianceAutomation/stable/2024-06-27/examples/Webhook_Update.json + // this example is just showing the usage of "Webhook_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,9 +90,14 @@ public async Task Delete_WebhookDelete() AppComplianceReportWebhookResource appComplianceReportWebhook = client.GetAppComplianceReportWebhookResource(appComplianceReportWebhookResourceId); // invoke the operation - await appComplianceReportWebhook.DeleteAsync(WaitUntil.Completed); + AppComplianceReportWebhookPatch patch = new AppComplianceReportWebhookPatch(); + AppComplianceReportWebhookResource result = await appComplianceReportWebhook.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppComplianceReportWebhookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index a3d332d07dde6..e391f865e49a7 100644 --- a/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/appcomplianceautomation/Azure.ResourceManager.AppComplianceAutomation/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -6,10 +6,12 @@ #nullable disable using System; +using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppComplianceAutomation.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppComplianceAutomation.Samples @@ -28,9 +30,7 @@ public async Task CheckAppComplianceReportNameAvailability_ReportCheckNameAvaila // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation AppComplianceReportNameAvailabilityContent content = new AppComplianceReportNameAvailabilityContent(); @@ -51,9 +51,7 @@ public async Task GetCollectionCountProviderAction_ReportGetCollectionCount() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ReportCollectionGetCountContent content = new ReportCollectionGetCountContent(); @@ -74,9 +72,7 @@ public async Task GetOverviewStatusProviderAction_ReportGetOverviewStatus() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation AppComplianceGetOverviewStatusContent content = new AppComplianceGetOverviewStatusContent(); @@ -97,9 +93,7 @@ public async Task GetInUseStorageAccountsProviderAction_ListInUseStorageAccounts // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ReportListInUseStorageAccountsContent content = new ReportListInUseStorageAccountsContent(); @@ -120,9 +114,7 @@ public async Task GetInUseStorageAccountsProviderAction_ListInUseStorageAccounts // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation ReportListInUseStorageAccountsContent content = new ReportListInUseStorageAccountsContent(); @@ -143,14 +135,10 @@ public async Task OnboardProviderAction_Onboard() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation - AppComplianceOnboardContent content = new AppComplianceOnboardContent(new string[] - { - }); + AppComplianceOnboardContent content = new AppComplianceOnboardContent(null); ArmOperation lro = await tenantResource.OnboardProviderActionAsync(WaitUntil.Completed, content); AppComplianceOnboardResult result = lro.Value; @@ -169,14 +157,10 @@ public async Task TriggerEvaluationProviderAction_TriggerEvaluation() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation - TriggerEvaluationContent content = new TriggerEvaluationContent(new string[] - { - }); + TriggerEvaluationContent content = new TriggerEvaluationContent(null); ArmOperation lro = await tenantResource.TriggerEvaluationProviderActionAsync(WaitUntil.Completed, content); TriggerEvaluationResult result = lro.Value; diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationKeyValueCollection.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationKeyValueCollection.cs index 609f3e0862c93..44935187f14f6 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationKeyValueCollection.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationKeyValueCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppConfigurationKeyValueCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KeyValuesGet() + public async Task CreateOrUpdate_KeyValuesCreateOrUpdate() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetKeyValue.json - // this example is just showing the usage of "KeyValues_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateKeyValue.json + // this example is just showing the usage of "KeyValues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,17 @@ public async Task Get_KeyValuesGet() // invoke the operation string keyValueName = "myKey$myLabel"; - AppConfigurationKeyValueResource result = await collection.GetAsync(keyValueName); + AppConfigurationKeyValueData data = new AppConfigurationKeyValueData + { + Value = "myValue", + Tags = +{ +["tag1"] = "tagValue1", +["tag2"] = "tagValue2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyValueName, data); + AppConfigurationKeyValueResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +61,7 @@ public async Task Get_KeyValuesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KeyValuesGet() + public async Task Get_KeyValuesGet() { // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetKeyValue.json // this example is just showing the usage of "KeyValues_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,14 +84,18 @@ public async Task Exists_KeyValuesGet() // invoke the operation string keyValueName = "myKey$myLabel"; - bool result = await collection.ExistsAsync(keyValueName); + AppConfigurationKeyValueResource result = await collection.GetAsync(keyValueName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationKeyValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KeyValuesGet() + public async Task Exists_KeyValuesGet() { // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetKeyValue.json // this example is just showing the usage of "KeyValues_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +118,17 @@ public async Task GetIfExists_KeyValuesGet() // invoke the operation string keyValueName = "myKey$myLabel"; - NullableResponse response = await collection.GetIfExistsAsync(keyValueName); - AppConfigurationKeyValueResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(keyValueName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationKeyValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KeyValuesCreateOrUpdate() + public async Task GetIfExists_KeyValuesGet() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateKeyValue.json - // this example is just showing the usage of "KeyValues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetKeyValue.json + // this example is just showing the usage of "KeyValues_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,23 +148,21 @@ public async Task CreateOrUpdate_KeyValuesCreateOrUpdate() // invoke the operation string keyValueName = "myKey$myLabel"; - AppConfigurationKeyValueData data = new AppConfigurationKeyValueData() - { - Value = "myValue", - Tags = -{ -["tag1"] = "tagValue1", -["tag2"] = "tagValue2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyValueName, data); - AppConfigurationKeyValueResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(keyValueName); + AppConfigurationKeyValueResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationKeyValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationKeyValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationKeyValueResource.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationKeyValueResource.cs index 784ff39b8605b..02b14b3d87c3a 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationKeyValueResource.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationKeyValueResource.cs @@ -48,10 +48,10 @@ public async Task Get_KeyValuesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KeyValuesCreateOrUpdate() + public async Task Delete_KeyValuesDelete() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateKeyValue.json - // this example is just showing the usage of "KeyValues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresDeleteKeyValue.json + // this example is just showing the usage of "KeyValues_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,31 +68,17 @@ public async Task Update_KeyValuesCreateOrUpdate() AppConfigurationKeyValueResource appConfigurationKeyValue = client.GetAppConfigurationKeyValueResource(appConfigurationKeyValueResourceId); // invoke the operation - AppConfigurationKeyValueData data = new AppConfigurationKeyValueData() - { - Value = "myValue", - Tags = -{ -["tag1"] = "tagValue1", -["tag2"] = "tagValue2", -}, - }; - ArmOperation lro = await appConfigurationKeyValue.UpdateAsync(WaitUntil.Completed, data); - AppConfigurationKeyValueResource result = lro.Value; + await appConfigurationKeyValue.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationKeyValueData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KeyValuesDelete() + public async Task Update_KeyValuesCreateOrUpdate() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresDeleteKeyValue.json - // this example is just showing the usage of "KeyValues_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateKeyValue.json + // this example is just showing the usage of "KeyValues_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +95,23 @@ public async Task Delete_KeyValuesDelete() AppConfigurationKeyValueResource appConfigurationKeyValue = client.GetAppConfigurationKeyValueResource(appConfigurationKeyValueResourceId); // invoke the operation - await appConfigurationKeyValue.DeleteAsync(WaitUntil.Completed); + AppConfigurationKeyValueData data = new AppConfigurationKeyValueData + { + Value = "myValue", + Tags = +{ +["tag1"] = "tagValue1", +["tag2"] = "tagValue2" +}, + }; + ArmOperation lro = await appConfigurationKeyValue.UpdateAsync(WaitUntil.Completed, data); + AppConfigurationKeyValueResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationKeyValueData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateEndpointConnectionCollection.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateEndpointConnectionCollection.cs index 382eba9538394..f2d34195f0243 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateEndpointConnectionCollection.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppConfigurationPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateEndpointConnectionList() + public async Task CreateOrUpdate_PrivateEndpointConnectionUpdate() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresListPrivateEndpointConnections.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByConfigurationStore" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresUpdatePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_PrivateEndpointConnectionList() // get the collection of this AppConfigurationPrivateEndpointConnectionResource AppConfigurationPrivateEndpointConnectionCollection collection = appConfigurationStore.GetAppConfigurationPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (AppConfigurationPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "myConnection"; + AppConfigurationPrivateEndpointConnectionData data = new AppConfigurationPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new AppConfigurationPrivateLinkServiceConnectionState + { + Status = AppConfigurationPrivateLinkServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + AppConfigurationPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_PrivateEndpointConnectionGetConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateEndpointConnectionGetConnection() + public async Task GetAll_PrivateEndpointConnectionList() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresListPrivateEndpointConnections.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByConfigurationStore" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_PrivateEndpointConnectionGetConnection() // get the collection of this AppConfigurationPrivateEndpointConnectionResource AppConfigurationPrivateEndpointConnectionCollection collection = appConfigurationStore.GetAppConfigurationPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "myConnection"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (AppConfigurationPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateEndpointConnectionGetConnection() + public async Task Exists_PrivateEndpointConnectionGetConnection() { // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_PrivateEndpointConnectionGetConnection() // invoke the operation string privateEndpointConnectionName = "myConnection"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - AppConfigurationPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateEndpointConnectionUpdate() + public async Task GetIfExists_PrivateEndpointConnectionGetConnection() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresUpdatePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_PrivateEndpointConnectionUpdate() // invoke the operation string privateEndpointConnectionName = "myConnection"; - AppConfigurationPrivateEndpointConnectionData data = new AppConfigurationPrivateEndpointConnectionData() - { - ConnectionState = new AppConfigurationPrivateLinkServiceConnectionState() - { - Status = AppConfigurationPrivateLinkServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - AppConfigurationPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + AppConfigurationPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateEndpointConnectionResource.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateEndpointConnectionResource.cs index b479656dbee73..dbfaab93523ce 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateEndpointConnectionResource.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_PrivateEndpointConnectionGetConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateEndpointConnectionUpdate() + public async Task Delete_PrivateEndpointConnectionsDelete() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresUpdatePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresDeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_PrivateEndpointConnectionUpdate() AppConfigurationPrivateEndpointConnectionResource appConfigurationPrivateEndpointConnection = client.GetAppConfigurationPrivateEndpointConnectionResource(appConfigurationPrivateEndpointConnectionResourceId); // invoke the operation - AppConfigurationPrivateEndpointConnectionData data = new AppConfigurationPrivateEndpointConnectionData() - { - ConnectionState = new AppConfigurationPrivateLinkServiceConnectionState() - { - Status = AppConfigurationPrivateLinkServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await appConfigurationPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - AppConfigurationPrivateEndpointConnectionResource result = lro.Value; + await appConfigurationPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionsDelete() + public async Task Update_PrivateEndpointConnectionUpdate() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresDeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresUpdatePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_PrivateEndpointConnectionsDelete() AppConfigurationPrivateEndpointConnectionResource appConfigurationPrivateEndpointConnection = client.GetAppConfigurationPrivateEndpointConnectionResource(appConfigurationPrivateEndpointConnectionResourceId); // invoke the operation - await appConfigurationPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + AppConfigurationPrivateEndpointConnectionData data = new AppConfigurationPrivateEndpointConnectionData + { + ConnectionState = new AppConfigurationPrivateLinkServiceConnectionState + { + Status = AppConfigurationPrivateLinkServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await appConfigurationPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + AppConfigurationPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateLinkResourceCollection.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateLinkResourceCollection.cs index 3d1314b2fd5f3..22761d6f1f008 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateLinkResourceCollection.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppConfigurationPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkResourcesListGroupIds() + public async Task Get_PrivateLinkResourcesGet() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/PrivateLinkResourcesListByConfigurationStore.json - // this example is just showing the usage of "PrivateLinkResources_ListByConfigurationStore" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/PrivateLinkResourceGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_PrivateLinkResourcesListGroupIds() // get the collection of this AppConfigurationPrivateLinkResource AppConfigurationPrivateLinkResourceCollection collection = appConfigurationStore.GetAppConfigurationPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (AppConfigurationPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "configurationStores"; + AppConfigurationPrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkResourcesGet() + public async Task GetAll_PrivateLinkResourcesListGroupIds() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/PrivateLinkResourceGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/PrivateLinkResourcesListByConfigurationStore.json + // this example is just showing the usage of "PrivateLinkResources_ListByConfigurationStore" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_PrivateLinkResourcesGet() // get the collection of this AppConfigurationPrivateLinkResource AppConfigurationPrivateLinkResourceCollection collection = appConfigurationStore.GetAppConfigurationPrivateLinkResources(); - // invoke the operation - string groupName = "configurationStores"; - AppConfigurationPrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (AppConfigurationPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationReplicaCollection.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationReplicaCollection.cs index 7de757bfc2481..6d56cf0b99411 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationReplicaCollection.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationReplicaCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppConfigurationReplicaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ReplicasListByConfigurationStore() + public async Task CreateOrUpdate_ReplicasCreate() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresListReplicas.json - // this example is just showing the usage of "Replicas_ListByConfigurationStore" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateReplica.json + // this example is just showing the usage of "Replicas_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ReplicasListByConfigurationStore() // get the collection of this AppConfigurationReplicaResource AppConfigurationReplicaCollection collection = appConfigurationStore.GetAppConfigurationReplicas(); - // invoke the operation and iterate over the result - await foreach (AppConfigurationReplicaResource item in collection.GetAllAsync()) + // invoke the operation + string replicaName = "myReplicaEus"; + AppConfigurationReplicaData data = new AppConfigurationReplicaData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationReplicaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, replicaName, data); + AppConfigurationReplicaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationReplicaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_ReplicasGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ReplicasGet() + public async Task GetAll_ReplicasListByConfigurationStore() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetReplica.json - // this example is just showing the usage of "Replicas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresListReplicas.json + // this example is just showing the usage of "Replicas_ListByConfigurationStore" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_ReplicasGet() // get the collection of this AppConfigurationReplicaResource AppConfigurationReplicaCollection collection = appConfigurationStore.GetAppConfigurationReplicas(); - // invoke the operation - string replicaName = "myReplicaEus"; - bool result = await collection.ExistsAsync(replicaName); + // invoke the operation and iterate over the result + await foreach (AppConfigurationReplicaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationReplicaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ReplicasGet() + public async Task Exists_ReplicasGet() { // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetReplica.json // this example is just showing the usage of "Replicas_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_ReplicasGet() // invoke the operation string replicaName = "myReplicaEus"; - NullableResponse response = await collection.GetIfExistsAsync(replicaName); - AppConfigurationReplicaResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(replicaName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationReplicaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ReplicasCreate() + public async Task GetIfExists_ReplicasGet() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateReplica.json - // this example is just showing the usage of "Replicas_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGetReplica.json + // this example is just showing the usage of "Replicas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_ReplicasCreate() // invoke the operation string replicaName = "myReplicaEus"; - AppConfigurationReplicaData data = new AppConfigurationReplicaData() - { - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, replicaName, data); - AppConfigurationReplicaResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(replicaName); + AppConfigurationReplicaResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationReplicaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationReplicaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationReplicaResource.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationReplicaResource.cs index 178db1aeb796c..61e12d1720dee 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationReplicaResource.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationReplicaResource.cs @@ -48,10 +48,10 @@ public async Task Get_ReplicasGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ReplicasCreate() + public async Task Delete_ReplicasDelete() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateReplica.json - // this example is just showing the usage of "Replicas_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresDeleteReplica.json + // this example is just showing the usage of "Replicas_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_ReplicasCreate() AppConfigurationReplicaResource appConfigurationReplica = client.GetAppConfigurationReplicaResource(appConfigurationReplicaResourceId); // invoke the operation - AppConfigurationReplicaData data = new AppConfigurationReplicaData() - { - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await appConfigurationReplica.UpdateAsync(WaitUntil.Completed, data); - AppConfigurationReplicaResource result = lro.Value; + await appConfigurationReplica.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationReplicaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ReplicasDelete() + public async Task Update_ReplicasCreate() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresDeleteReplica.json - // this example is just showing the usage of "Replicas_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateReplica.json + // this example is just showing the usage of "Replicas_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,18 @@ public async Task Delete_ReplicasDelete() AppConfigurationReplicaResource appConfigurationReplica = client.GetAppConfigurationReplicaResource(appConfigurationReplicaResourceId); // invoke the operation - await appConfigurationReplica.DeleteAsync(WaitUntil.Completed); + AppConfigurationReplicaData data = new AppConfigurationReplicaData + { + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await appConfigurationReplica.UpdateAsync(WaitUntil.Completed, data); + AppConfigurationReplicaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationReplicaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationStoreCollection.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationStoreCollection.cs index 7ef0ddb23ba9f..98ddff56e6a9d 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationStoreCollection.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationStoreCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_AppConfigurationStoreCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConfigurationStoresListByResourceGroup() + public async Task CreateOrUpdate_ConfigurationStoresCreate() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresListByResourceGroup.json - // this example is just showing the usage of "ConfigurationStores_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreate.json + // this example is just showing the usage of "ConfigurationStores_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,31 @@ public async Task GetAll_ConfigurationStoresListByResourceGroup() // get the collection of this AppConfigurationStoreResource AppConfigurationStoreCollection collection = resourceGroupResource.GetAppConfigurationStores(); - // invoke the operation and iterate over the result - await foreach (AppConfigurationStoreResource item in collection.GetAllAsync()) + // invoke the operation + string configStoreName = "contoso"; + AppConfigurationStoreData data = new AppConfigurationStoreData(new AzureLocation("westus"), new AppConfigurationSku("Standard")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationStoreData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["myTag"] = "myTagValue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configStoreName, data); + AppConfigurationStoreResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationStoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConfigurationStoresGet() + public async Task CreateOrUpdate_ConfigurationStoresCreateWithIdentity() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGet.json - // this example is just showing the usage of "ConfigurationStores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateWithIdentity.json + // this example is just showing the usage of "ConfigurationStores_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +83,22 @@ public async Task Get_ConfigurationStoresGet() // invoke the operation string configStoreName = "contoso"; - AppConfigurationStoreResource result = await collection.GetAsync(configStoreName); + AppConfigurationStoreData data = new AppConfigurationStoreData(new AzureLocation("westus"), new AppConfigurationSku("Standard")) + { + Identity = new ManagedServiceIdentity("SystemAssigned, UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/c80fb759-c965-4c6a-9110-9b2b2d038882/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2")] = new UserAssignedIdentity() +}, + }, + Tags = +{ +["myTag"] = "myTagValue" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configStoreName, data); + AppConfigurationStoreResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +109,10 @@ public async Task Get_ConfigurationStoresGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConfigurationStoresGet() + public async Task CreateOrUpdate_ConfigurationStoresCreateWithLocalAuthDisabled() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGet.json - // this example is just showing the usage of "ConfigurationStores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateWithLocalAuthDisabled.json + // this example is just showing the usage of "ConfigurationStores_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,14 +131,23 @@ public async Task Exists_ConfigurationStoresGet() // invoke the operation string configStoreName = "contoso"; - bool result = await collection.ExistsAsync(configStoreName); + AppConfigurationStoreData data = new AppConfigurationStoreData(new AzureLocation("westus"), new AppConfigurationSku("Standard")) + { + DisableLocalAuth = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configStoreName, data); + AppConfigurationStoreResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationStoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConfigurationStoresGet() + public async Task Get_ConfigurationStoresGet() { // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGet.json // this example is just showing the usage of "ConfigurationStores_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +169,21 @@ public async Task GetIfExists_ConfigurationStoresGet() // invoke the operation string configStoreName = "contoso"; - NullableResponse response = await collection.GetIfExistsAsync(configStoreName); - AppConfigurationStoreResource result = response.HasValue ? response.Value : null; + AppConfigurationStoreResource result = await collection.GetAsync(configStoreName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationStoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationStoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConfigurationStoresCreate() + public async Task GetAll_ConfigurationStoresListByResourceGroup() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreate.json - // this example is just showing the usage of "ConfigurationStores_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresListByResourceGroup.json + // this example is just showing the usage of "ConfigurationStores_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,31 +200,25 @@ public async Task CreateOrUpdate_ConfigurationStoresCreate() // get the collection of this AppConfigurationStoreResource AppConfigurationStoreCollection collection = resourceGroupResource.GetAppConfigurationStores(); - // invoke the operation - string configStoreName = "contoso"; - AppConfigurationStoreData data = new AppConfigurationStoreData(new AzureLocation("westus"), new AppConfigurationSku("Standard")) + // invoke the operation and iterate over the result + await foreach (AppConfigurationStoreResource item in collection.GetAllAsync()) { - Tags = -{ -["myTag"] = "myTagValue", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configStoreName, data); - AppConfigurationStoreResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationStoreData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationStoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConfigurationStoresCreateWithIdentity() + public async Task Exists_ConfigurationStoresGet() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateWithIdentity.json - // this example is just showing the usage of "ConfigurationStores_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGet.json + // this example is just showing the usage of "ConfigurationStores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -221,36 +237,17 @@ public async Task CreateOrUpdate_ConfigurationStoresCreateWithIdentity() // invoke the operation string configStoreName = "contoso"; - AppConfigurationStoreData data = new AppConfigurationStoreData(new AzureLocation("westus"), new AppConfigurationSku("Standard")) - { - Identity = new ManagedServiceIdentity("SystemAssigned, UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/c80fb759-c965-4c6a-9110-9b2b2d038882/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2")] = new UserAssignedIdentity(), -}, - }, - Tags = -{ -["myTag"] = "myTagValue", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configStoreName, data); - AppConfigurationStoreResource result = lro.Value; + bool result = await collection.ExistsAsync(configStoreName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationStoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConfigurationStoresCreateWithLocalAuthDisabled() + public async Task GetIfExists_ConfigurationStoresGet() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresCreateWithLocalAuthDisabled.json - // this example is just showing the usage of "ConfigurationStores_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresGet.json + // this example is just showing the usage of "ConfigurationStores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -269,18 +266,21 @@ public async Task CreateOrUpdate_ConfigurationStoresCreateWithLocalAuthDisabled( // invoke the operation string configStoreName = "contoso"; - AppConfigurationStoreData data = new AppConfigurationStoreData(new AzureLocation("westus"), new AppConfigurationSku("Standard")) - { - DisableLocalAuth = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configStoreName, data); - AppConfigurationStoreResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(configStoreName); + AppConfigurationStoreResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationStoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationStoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationStoreResource.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationStoreResource.cs index 4086fc3f65e4e..30ae1953e8513 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationStoreResource.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_AppConfigurationStoreResource.cs @@ -11,44 +11,12 @@ using Azure.Identity; using Azure.ResourceManager.AppConfiguration.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppConfiguration.Samples { public partial class Sample_AppConfigurationStoreResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAppConfigurationStores_ConfigurationStoresList() - { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresList.json - // this example is just showing the usage of "ConfigurationStores_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "c80fb759-c965-4c6a-9110-9b2b2d038882"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AppConfigurationStoreResource item in subscriptionResource.GetAppConfigurationStoresAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppConfigurationStoreData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ConfigurationStoresGet() @@ -126,12 +94,12 @@ public async Task Update_ConfigurationStoresUpdate() AppConfigurationStoreResource appConfigurationStore = client.GetAppConfigurationStoreResource(appConfigurationStoreResourceId); // invoke the operation - AppConfigurationStorePatch patch = new AppConfigurationStorePatch() + AppConfigurationStorePatch patch = new AppConfigurationStorePatch { SkuName = "Standard", Tags = { -["Category"] = "Marketing", +["Category"] = "Marketing" }, }; ArmOperation lro = await appConfigurationStore.UpdateAsync(WaitUntil.Completed, patch); @@ -165,7 +133,7 @@ public async Task Update_ConfigurationStoresUpdateDisableLocalAuth() AppConfigurationStoreResource appConfigurationStore = client.GetAppConfigurationStoreResource(appConfigurationStoreResourceId); // invoke the operation - AppConfigurationStorePatch patch = new AppConfigurationStorePatch() + AppConfigurationStorePatch patch = new AppConfigurationStorePatch { SkuName = "Standard", DisableLocalAuth = true, @@ -201,19 +169,19 @@ public async Task Update_ConfigurationStoresUpdateWithIdentity() AppConfigurationStoreResource appConfigurationStore = client.GetAppConfigurationStoreResource(appConfigurationStoreResourceId); // invoke the operation - AppConfigurationStorePatch patch = new AppConfigurationStorePatch() + AppConfigurationStorePatch patch = new AppConfigurationStorePatch { Identity = new ManagedServiceIdentity("SystemAssigned, UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/c80fb759-c965-4c6a-9110-9b2b2d038882/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/c80fb759-c965-4c6a-9110-9b2b2d038882/resourcegroups/myResourceGroup1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity2")] = new UserAssignedIdentity() }, }, SkuName = "Standard", Tags = { -["Category"] = "Marketing", +["Category"] = "Marketing" }, }; ArmOperation lro = await appConfigurationStore.UpdateAsync(WaitUntil.Completed, patch); @@ -276,7 +244,7 @@ public async Task RegenerateKey_ConfigurationStoresRegenerateKey() AppConfigurationStoreResource appConfigurationStore = client.GetAppConfigurationStoreResource(appConfigurationStoreResourceId); // invoke the operation - AppConfigurationRegenerateKeyContent content = new AppConfigurationRegenerateKeyContent() + AppConfigurationRegenerateKeyContent content = new AppConfigurationRegenerateKeyContent { Id = "439AD01B4BE67DB1", }; diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_DeletedAppConfigurationStoreCollection.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_DeletedAppConfigurationStoreCollection.cs index 9e0e026005b1c..e5ee5d3663f91 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_DeletedAppConfigurationStoreCollection.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_DeletedAppConfigurationStoreCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DeletedAppConfigurationStoreCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DeletedConfigurationStoresList() + public async Task Get_DeletedConfigurationStoresGet() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/DeletedConfigurationStoresList.json - // this example is just showing the usage of "ConfigurationStores_ListDeleted" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/DeletedConfigurationStoresGet.json + // this example is just showing the usage of "ConfigurationStores_GetDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,24 @@ public async Task GetAll_DeletedConfigurationStoresList() // get the collection of this DeletedAppConfigurationStoreResource DeletedAppConfigurationStoreCollection collection = subscriptionResource.GetDeletedAppConfigurationStores(); - // invoke the operation and iterate over the result - await foreach (DeletedAppConfigurationStoreResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeletedAppConfigurationStoreData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + AzureLocation location = new AzureLocation("westus"); + string configStoreName = "contoso"; + DeletedAppConfigurationStoreResource result = await collection.GetAsync(location, configStoreName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeletedAppConfigurationStoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DeletedConfigurationStoresGet() + public async Task GetAll_DeletedConfigurationStoresList() { - // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/DeletedConfigurationStoresGet.json - // this example is just showing the usage of "ConfigurationStores_GetDeleted" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/DeletedConfigurationStoresList.json + // this example is just showing the usage of "ConfigurationStores_ListDeleted" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,16 +70,17 @@ public async Task Get_DeletedConfigurationStoresGet() // get the collection of this DeletedAppConfigurationStoreResource DeletedAppConfigurationStoreCollection collection = subscriptionResource.GetDeletedAppConfigurationStores(); - // invoke the operation - AzureLocation location = new AzureLocation("westus"); - string configStoreName = "contoso"; - DeletedAppConfigurationStoreResource result = await collection.GetAsync(location, configStoreName); + // invoke the operation and iterate over the result + await foreach (DeletedAppConfigurationStoreResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DeletedAppConfigurationStoreData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DeletedAppConfigurationStoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index b8ac42fb46b7e..4c0062540d05f 100644 --- a/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/appconfiguration/Azure.ResourceManager.AppConfiguration/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.AppConfiguration.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAppConfigurationStores_ConfigurationStoresList() + { + // Generated from example definition: specification/appconfiguration/resource-manager/Microsoft.AppConfiguration/stable/2023-03-01/examples/ConfigurationStoresList.json + // this example is just showing the usage of "ConfigurationStores_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "c80fb759-c965-4c6a-9110-9b2b2d038882"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AppConfigurationStoreResource item in subscriptionResource.GetAppConfigurationStoresAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppConfigurationStoreData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CheckAppConfigurationNameAvailability_ConfigurationStoresCheckNameAvailable() diff --git a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsComponentCollection.cs b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsComponentCollection.cs index 57e139690d7d8..760d1cf3078cd 100644 --- a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsComponentCollection.cs +++ b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsComponentCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ApplicationInsightsComponentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ComponentListByResourceGroup() + public async Task CreateOrUpdate_ComponentCreate() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsListByResourceGroup.json - // this example is just showing the usage of "Components_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsCreate.json + // this example is just showing the usage of "Components_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,31 @@ public async Task GetAll_ComponentListByResourceGroup() // get the collection of this ApplicationInsightsComponentResource ApplicationInsightsComponentCollection collection = resourceGroupResource.GetApplicationInsightsComponents(); - // invoke the operation and iterate over the result - await foreach (ApplicationInsightsComponentResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "my-component"; + ApplicationInsightsComponentData data = new ApplicationInsightsComponentData(new AzureLocation("South Central US"), "web") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsComponentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ApplicationType = ApplicationInsightsApplicationType.Web, + FlowType = ComponentFlowType.Bluefield, + RequestSource = ComponentRequestSource.Rest, + WorkspaceResourceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ApplicationInsightsComponentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ComponentGet() + public async Task CreateOrUpdate_ComponentUpdate() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsGet.json - // this example is just showing the usage of "Components_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsUpdate.json + // this example is just showing the usage of "Components_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +82,16 @@ public async Task Get_ComponentGet() // invoke the operation string resourceName = "my-component"; - ApplicationInsightsComponentResource result = await collection.GetAsync(resourceName); + ApplicationInsightsComponentData data = new ApplicationInsightsComponentData(new AzureLocation("South Central US"), "web") + { + Tags = +{ +["ApplicationGatewayType"] = "Internal-Only", +["BillingEntity"] = "Self" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ApplicationInsightsComponentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +102,7 @@ public async Task Get_ComponentGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ComponentGet() + public async Task Get_ComponentGet() { // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsGet.json // this example is just showing the usage of "Components_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,17 +124,21 @@ public async Task Exists_ComponentGet() // invoke the operation string resourceName = "my-component"; - bool result = await collection.ExistsAsync(resourceName); + ApplicationInsightsComponentResource result = await collection.GetAsync(resourceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ComponentGet() + public async Task GetAll_ComponentListByResourceGroup() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsGet.json - // this example is just showing the usage of "Components_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsListByResourceGroup.json + // this example is just showing the usage of "Components_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,31 +155,25 @@ public async Task GetIfExists_ComponentGet() // get the collection of this ApplicationInsightsComponentResource ApplicationInsightsComponentCollection collection = resourceGroupResource.GetApplicationInsightsComponents(); - // invoke the operation - string resourceName = "my-component"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - ApplicationInsightsComponentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ApplicationInsightsComponentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApplicationInsightsComponentData resourceData = result.Data; + ApplicationInsightsComponentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ComponentCreate() + public async Task Exists_ComponentGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsCreate.json - // this example is just showing the usage of "Components_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsGet.json + // this example is just showing the usage of "Components_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,29 +192,17 @@ public async Task CreateOrUpdate_ComponentCreate() // invoke the operation string resourceName = "my-component"; - ApplicationInsightsComponentData data = new ApplicationInsightsComponentData(new AzureLocation("South Central US"), "web") - { - ApplicationType = ApplicationInsightsApplicationType.Web, - FlowType = ComponentFlowType.Bluefield, - RequestSource = ComponentRequestSource.Rest, - WorkspaceResourceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/my-resource-group/providers/microsoft.operationalinsights/workspaces/my-workspace"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - ApplicationInsightsComponentResource result = lro.Value; + bool result = await collection.ExistsAsync(resourceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ComponentUpdate() + public async Task GetIfExists_ComponentGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsUpdate.json - // this example is just showing the usage of "Components_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsGet.json + // this example is just showing the usage of "Components_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -220,22 +221,21 @@ public async Task CreateOrUpdate_ComponentUpdate() // invoke the operation string resourceName = "my-component"; - ApplicationInsightsComponentData data = new ApplicationInsightsComponentData(new AzureLocation("South Central US"), "web") - { - Tags = -{ -["ApplicationGatewayType"] = "Internal-Only", -["BillingEntity"] = "Self", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - ApplicationInsightsComponentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + ApplicationInsightsComponentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsComponentResource.cs b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsComponentResource.cs index 487b345982840..910433cf1a195 100644 --- a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsComponentResource.cs +++ b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsComponentResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ApplicationInsights.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ApplicationInsights.Samples @@ -19,41 +18,10 @@ public partial class Sample_ApplicationInsightsComponentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetApplicationInsightsComponents_ComponentsListJson() - { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsList.json - // this example is just showing the usage of "Components_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ApplicationInsightsComponentResource item in subscriptionResource.GetApplicationInsightsComponentsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsComponentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ComponentsDelete() + public async Task Get_ComponentGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsDelete.json - // this example is just showing the usage of "Components_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsGet.json + // this example is just showing the usage of "Components_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,17 +37,21 @@ public async Task Delete_ComponentsDelete() ApplicationInsightsComponentResource applicationInsightsComponent = client.GetApplicationInsightsComponentResource(applicationInsightsComponentResourceId); // invoke the operation - await applicationInsightsComponent.DeleteAsync(WaitUntil.Completed); + ApplicationInsightsComponentResource result = await applicationInsightsComponent.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsComponentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ComponentGet() + public async Task Delete_ComponentsDelete() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsGet.json - // this example is just showing the usage of "Components_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsDelete.json + // this example is just showing the usage of "Components_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,13 +67,9 @@ public async Task Get_ComponentGet() ApplicationInsightsComponentResource applicationInsightsComponent = client.GetApplicationInsightsComponentResource(applicationInsightsComponentResourceId); // invoke the operation - ApplicationInsightsComponentResource result = await applicationInsightsComponent.GetAsync(); + await applicationInsightsComponent.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsComponentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -125,7 +93,7 @@ public async Task Update_ComponentUpdateTagsOnly() ApplicationInsightsComponentResource applicationInsightsComponent = client.GetApplicationInsightsComponentResource(applicationInsightsComponentResourceId); // invoke the operation - WebTestComponentTag componentTags = new WebTestComponentTag() + WebTestComponentTag componentTags = new WebTestComponentTag { Tags = { @@ -133,7 +101,7 @@ public async Task Update_ComponentUpdateTagsOnly() ["BillingEntity"] = "Self", ["Color"] = "AzureBlue", ["CustomField_01"] = "Custom text in some random field named randomly", -["NodeType"] = "Edge", +["NodeType"] = "Edge" }, }; ApplicationInsightsComponentResource result = await applicationInsightsComponent.UpdateAsync(componentTags); @@ -168,11 +136,11 @@ public async Task Purge_ComponentPurge() // invoke the operation ComponentPurgeContent content = new ComponentPurgeContent("Heartbeat", new ComponentPurgeFilters[] { -new ComponentPurgeFilters() +new ComponentPurgeFilters { Column = "TimeGenerated", Operator = ">", -Value = BinaryData.FromString("\"2017-09-01T00:00:00\""), +Value = BinaryData.FromObjectAsJson("2017-09-01T00:00:00"), } }); ComponentPurgeResult result = await applicationInsightsComponent.PurgeAsync(content); @@ -259,7 +227,7 @@ public async Task CreateAnnotations_AnnotationsCreate() ApplicationInsightsComponentResource applicationInsightsComponent = client.GetApplicationInsightsComponentResource(applicationInsightsComponentResourceId); // invoke the operation and iterate over the result - ApplicationInsightsAnnotation annotationProperties = new ApplicationInsightsAnnotation() + ApplicationInsightsAnnotation annotationProperties = new ApplicationInsightsAnnotation { AnnotationName = "TestAnnotation", Category = "Text", @@ -382,17 +350,11 @@ public async Task CreateApiKey_APIKeyCreate() ApplicationInsightsComponentResource applicationInsightsComponent = client.GetApplicationInsightsComponentResource(applicationInsightsComponentResourceId); // invoke the operation - ApplicationInsightsApiKeyContent content = new ApplicationInsightsApiKeyContent() + ApplicationInsightsApiKeyContent content = new ApplicationInsightsApiKeyContent { Name = "test2", - LinkedReadProperties = -{ -"/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api","/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig" -}, - LinkedWriteProperties = -{ -"/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/annotations" -}, + LinkedReadProperties = { "/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/api", "/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/agentconfig" }, + LinkedWriteProperties = { "/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component/annotations" }, }; ApplicationInsightsComponentApiKey result = await applicationInsightsComponent.CreateApiKeyAsync(content); @@ -503,7 +465,7 @@ public async Task CreateExportConfigurations_ExportConfigurationPost() ApplicationInsightsComponentResource applicationInsightsComponent = client.GetApplicationInsightsComponentResource(applicationInsightsComponentResourceId); // invoke the operation and iterate over the result - ApplicationInsightsComponentExportContent content = new ApplicationInsightsComponentExportContent() + ApplicationInsightsComponentExportContent content = new ApplicationInsightsComponentExportContent { RecordTypes = "Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability", DestinationType = "Blob", @@ -599,7 +561,7 @@ public async Task UpdateExportConfiguration_ExportConfigurationUpdate() // invoke the operation string exportId = "uGOoki0jQsyEs3IdQ83Q4QsNr4="; - ApplicationInsightsComponentExportContent content = new ApplicationInsightsComponentExportContent() + ApplicationInsightsComponentExportContent content = new ApplicationInsightsComponentExportContent { RecordTypes = "Requests, Event, Exceptions, Metrics, PageViews, PageViewPerformance, Rdd, PerformanceCounters, Availability", DestinationType = "Blob", @@ -663,17 +625,14 @@ public async Task UpdateComponentCurrentBillingFeature_ComponentCurrentBillingFe ApplicationInsightsComponentResource applicationInsightsComponent = client.GetApplicationInsightsComponentResource(applicationInsightsComponentResourceId); // invoke the operation - ApplicationInsightsComponentBillingFeatures billingFeaturesProperties = new ApplicationInsightsComponentBillingFeatures() + ApplicationInsightsComponentBillingFeatures billingFeaturesProperties = new ApplicationInsightsComponentBillingFeatures { - DataVolumeCap = new ApplicationInsightsComponentDataVolumeCap() + DataVolumeCap = new ApplicationInsightsComponentDataVolumeCap { Cap = 100, IsStopSendNotificationWhenHitCap = true, }, - CurrentBillingFeatures = -{ -"Basic","Application Insights Enterprise" -}, + CurrentBillingFeatures = { "Basic", "Application Insights Enterprise" }, }; ApplicationInsightsComponentBillingFeatures result = await applicationInsightsComponent.UpdateComponentCurrentBillingFeatureAsync(billingFeaturesProperties); @@ -836,17 +795,14 @@ public async Task UpdateProactiveDetectionConfiguration_ProactiveDetectionConfig // invoke the operation string configurationId = "slowpageloadtime"; - ApplicationInsightsComponentProactiveDetectionConfiguration proactiveDetectionProperties = new ApplicationInsightsComponentProactiveDetectionConfiguration() + ApplicationInsightsComponentProactiveDetectionConfiguration proactiveDetectionProperties = new ApplicationInsightsComponentProactiveDetectionConfiguration { Name = "slowpageloadtime", IsEnabled = true, SendEmailsToSubscriptionOwners = true, - CustomEmails = -{ -"foo@microsoft.com","foo2@microsoft.com" -}, - LastUpdatedOn = null, - RuleDefinitions = new ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions() + CustomEmails = { "foo@microsoft.com", "foo2@microsoft.com" }, + LastUpdatedOn = default, + RuleDefinitions = new ApplicationInsightsComponentProactiveDetectionConfigurationRuleDefinitions { Name = "slowpageloadtime", DisplayName = "Slow page load time", @@ -1050,17 +1006,14 @@ public async Task AddFavorite_FavoriteAdd() // invoke the operation string favoriteId = "deadb33f-8bee-4d3b-a059-9be8dac93960"; - ApplicationInsightsComponentFavorite favoriteProperties = new ApplicationInsightsComponentFavorite() + ApplicationInsightsComponentFavorite favoriteProperties = new ApplicationInsightsComponentFavorite { Name = "Blah Blah Blah", Config = "{\"MEDataModelRawJSON\":\"{\\n \\\"version\\\": \\\"1.4.1\\\",\\n \\\"isCustomDataModel\\\": true,\\n \\\"items\\\": [\\n {\\n \\\"id\\\": \\\"90a7134d-9a38-4c25-88d3-a495209873eb\\\",\\n \\\"chartType\\\": \\\"Area\\\",\\n \\\"chartHeight\\\": 4,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"preview/requests/count\\\",\\n \\\"metricAggregation\\\": \\\"Sum\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": false,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"aggregation\\\": \\\"Sum\\\",\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"fail\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n },\\n {\\n \\\"id\\\": \\\"0c289098-88e8-4010-b212-546815cddf70\\\",\\n \\\"chartType\\\": \\\"Area\\\",\\n \\\"chartHeight\\\": 2,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"preview/requests/duration\\\",\\n \\\"metricAggregation\\\": \\\"Avg\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-j1\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": false,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"aggregation\\\": \\\"Avg\\\",\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"greenHues\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n },\\n {\\n \\\"id\\\": \\\"cbdaab6f-a808-4f71-aca5-b3976cbb7345\\\",\\n \\\"chartType\\\": \\\"Bar\\\",\\n \\\"chartHeight\\\": 4,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"preview/requests/duration\\\",\\n \\\"metricAggregation\\\": \\\"Avg\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": false,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"aggregation\\\": \\\"Avg\\\",\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"magentaHues\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n },\\n {\\n \\\"id\\\": \\\"1d5a6a3a-9fa1-4099-9cf9-05eff72d1b02\\\",\\n \\\"grouping\\\": {\\n \\\"kind\\\": \\\"ByDimension\\\",\\n \\\"dimension\\\": \\\"context.application.version\\\"\\n },\\n \\\"chartType\\\": \\\"Grid\\\",\\n \\\"chartHeight\\\": 1,\\n \\\"metrics\\\": [\\n {\\n \\\"id\\\": \\\"basicException.count\\\",\\n \\\"metricAggregation\\\": \\\"Sum\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-g0\\\"\\n },\\n {\\n \\\"id\\\": \\\"requestFailed.count\\\",\\n \\\"metricAggregation\\\": \\\"Sum\\\",\\n \\\"color\\\": \\\"msportalfx-bgcolor-f0s2\\\"\\n }\\n ],\\n \\\"priorPeriod\\\": true,\\n \\\"clickAction\\\": {\\n \\\"defaultBlade\\\": \\\"SearchBlade\\\"\\n },\\n \\\"horizontalBars\\\": true,\\n \\\"showOther\\\": true,\\n \\\"percentage\\\": false,\\n \\\"palette\\\": \\\"blueHues\\\",\\n \\\"yAxisOption\\\": 0,\\n \\\"title\\\": \\\"\\\"\\n }\\n ],\\n \\\"currentFilter\\\": {\\n \\\"eventTypes\\\": [\\n 1,\\n 2\\n ],\\n \\\"typeFacets\\\": {},\\n \\\"isPermissive\\\": false\\n },\\n \\\"timeContext\\\": {\\n \\\"durationMs\\\": 75600000,\\n \\\"endTime\\\": \\\"2018-01-31T20:30:00.000Z\\\",\\n \\\"createdTime\\\": \\\"2018-01-31T23:54:26.280Z\\\",\\n \\\"isInitialTime\\\": false,\\n \\\"grain\\\": 1,\\n \\\"useDashboardTimeRange\\\": false\\n },\\n \\\"jsonUri\\\": \\\"Favorite_BlankChart\\\",\\n \\\"timeSource\\\": 0\\n}\"}", Version = "ME", FavoriteType = ComponentFavoriteType.Shared, SourceType = null, - Tags = -{ -"TagSample01","TagSample02" -}, + Tags = { "TagSample01", "TagSample02" }, Category = null, IsGeneratedFromTemplate = false, }; @@ -1091,17 +1044,14 @@ public async Task UpdateFavorite_FavoriteList() // invoke the operation string favoriteId = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; - ApplicationInsightsComponentFavorite favoriteProperties = new ApplicationInsightsComponentFavorite() + ApplicationInsightsComponentFavorite favoriteProperties = new ApplicationInsightsComponentFavorite { Name = "Derek Changed This", Config = "{\"MEDataModelRawJSON\":\"{\\\"version\\\": \\\"1.4.1\\\",\\\"isCustomDataModel\\\": true,\\\"items\\\": [{\\\"id\\\": \\\"90a7134d-9a38-4c25-88d3-a495209873eb\\\",\\\"chartType\\\": \\\"Area\\\",\\\"chartHeight\\\": 4,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Sum\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"fail\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"0c289098-88e8-4010-b212-546815cddf70\\\",\\\"chartType\\\": \\\"Area\\\",\\\"chartHeight\\\": 2,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/duration\\\",\\\"metricAggregation\\\": \\\"Avg\\\",\\\"color\\\": \\\"msportalfx-bgcolor-j1\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Avg\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"greenHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"cbdaab6f-a808-4f71-aca5-b3976cbb7345\\\",\\\"chartType\\\": \\\"Bar\\\",\\\"chartHeight\\\": 4,\\\"metrics\\\": [{\\\"id\\\": \\\"preview/requests/duration\\\",\\\"metricAggregation\\\": \\\"Avg\\\",\\\"color\\\": \\\"msportalfx-bgcolor-d0\\\"}],\\\"priorPeriod\\\": false,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"aggregation\\\": \\\"Avg\\\",\\\"percentage\\\": false,\\\"palette\\\": \\\"magentaHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"},{\\\"id\\\": \\\"1d5a6a3a-9fa1-4099-9cf9-05eff72d1b02\\\",\\\"grouping\\\": {\\\"kind\\\": \\\"ByDimension\\\",\\\"dimension\\\": \\\"context.application.version\\\"},\\\"chartType\\\": \\\"Grid\\\",\\\"chartHeight\\\": 1,\\\"metrics\\\": [{\\\"id\\\": \\\"basicException.count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-g0\\\"},{\\\"id\\\": \\\"requestFailed.count\\\",\\\"metricAggregation\\\": \\\"Sum\\\",\\\"color\\\": \\\"msportalfx-bgcolor-f0s2\\\"}],\\\"priorPeriod\\\": true,\\\"clickAction\\\": {\\\"defaultBlade\\\": \\\"SearchBlade\\\"},\\\"horizontalBars\\\": true,\\\"showOther\\\": true,\\\"percentage\\\": false,\\\"palette\\\": \\\"blueHues\\\",\\\"yAxisOption\\\": 0,\\\"title\\\": \\\"\\\"}],\\\"currentFilter\\\": {\\\"eventTypes\\\": [1,2],\\\"typeFacets\\\": {},\\\"isPermissive\\\": false},\\\"timeContext\\\": {\\\"durationMs\\\": 75600000,\\\"endTime\\\": \\\"2018-01-31T20:30:00.000Z\\\",\\\"createdTime\\\": \\\"2018-01-31T23:54:26.280Z\\\",\\\"isInitialTime\\\": false,\\\"grain\\\": 1,\\\"useDashboardTimeRange\\\": false},\\\"jsonUri\\\": \\\"Favorite_BlankChart\\\",\\\"timeSource\\\": 0}\"}", Version = "ME", FavoriteType = ComponentFavoriteType.Shared, SourceType = null, - Tags = -{ -"TagSample01","TagSample02","TagSample03" -}, + Tags = { "TagSample01", "TagSample02", "TagSample03" }, Category = null, IsGeneratedFromTemplate = false, }; @@ -1279,7 +1229,7 @@ public async Task AddOrUpdateAnalyticsItem_AnalyticsItemPut() // invoke the operation AnalyticsItemScopePath scopePath = AnalyticsItemScopePath.AnalyticsItems; - ApplicationInsightsComponentAnalyticsItem itemProperties = new ApplicationInsightsComponentAnalyticsItem() + ApplicationInsightsComponentAnalyticsItem itemProperties = new ApplicationInsightsComponentAnalyticsItem { Name = "Exceptions - New in the last 24 hours", Content = "let newExceptionsTimeRange = 1d;\nlet timeRangeToCheckBefore = 7d;\nexceptions\n| where timestamp < ago(timeRangeToCheckBefore)\n| summarize count() by problemId\n| join kind= rightanti (\nexceptions\n| where timestamp >= ago(newExceptionsTimeRange)\n| extend stack = tostring(details[0].rawStack)\n| summarize count(), dcount(user_AuthenticatedId), min(timestamp), max(timestamp), any(stack) by problemId \n) on problemId \n| order by count_ desc\n", diff --git a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWebTestCollection.cs b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWebTestCollection.cs index ecb65ff1eba34..3cf595185bab3 100644 --- a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWebTestCollection.cs +++ b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWebTestCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ApplicationInsightsWebTestCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WebTestListByResourceGroup() + public async Task CreateOrUpdate_WebTestCreate() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestListByResourceGroup.json - // this example is just showing the usage of "WebTests_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestCreate.json + // this example is just showing the usage of "WebTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,41 @@ public async Task GetAll_WebTestListByResourceGroup() // get the collection of this ApplicationInsightsWebTestResource ApplicationInsightsWebTestCollection collection = resourceGroupResource.GetApplicationInsightsWebTests(); - // invoke the operation and iterate over the result - await foreach (ApplicationInsightsWebTestResource item in collection.GetAllAsync()) + // invoke the operation + string webTestName = "my-webtest-my-component"; + ApplicationInsightsWebTestData data = new ApplicationInsightsWebTestData(new AzureLocation("South Central US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWebTestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Kind = WebTestKind.Ping, + SyntheticMonitorId = "my-webtest-my-component", + WebTestName = "my-webtest-my-component", + Description = "Ping web test alert for mytestwebapp", + IsEnabled = true, + FrequencyInSeconds = 900, + TimeoutInSeconds = 120, + WebTestKind = WebTestKind.Ping, + IsRetryEnabled = true, + Locations = {new WebTestGeolocation +{ +Location = new AzureLocation("us-fl-mia-edge"), +}}, + WebTest = "", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, webTestName, data); + ApplicationInsightsWebTestResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWebTestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WebTestGet() + public async Task CreateOrUpdate_WebTestCreateStandard() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestGet.json - // this example is just showing the usage of "WebTests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestCreateStandard.json + // this example is just showing the usage of "WebTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,8 +91,44 @@ public async Task Get_WebTestGet() ApplicationInsightsWebTestCollection collection = resourceGroupResource.GetApplicationInsightsWebTests(); // invoke the operation - string webTestName = "my-webtest-01-mywebservice"; - ApplicationInsightsWebTestResource result = await collection.GetAsync(webTestName); + string webTestName = "my-webtest-my-component"; + ApplicationInsightsWebTestData data = new ApplicationInsightsWebTestData(new AzureLocation("South Central US")) + { + SyntheticMonitorId = "my-webtest-my-component", + WebTestName = "my-webtest-my-component", + Description = "Ping web test alert for mytestwebapp", + IsEnabled = true, + FrequencyInSeconds = 900, + TimeoutInSeconds = 120, + WebTestKind = WebTestKind.Standard, + IsRetryEnabled = true, + Locations = {new WebTestGeolocation +{ +Location = new AzureLocation("us-fl-mia-edge"), +}}, + Request = new WebTestRequest + { + RequestUri = new Uri("https://bing.com"), + Headers = {new WebTestRequestHeaderField +{ +HeaderFieldName = "Content-Language", +HeaderFieldValue = "de-DE", +}, new WebTestRequestHeaderField +{ +HeaderFieldName = "Accept-Language", +HeaderFieldValue = "de-DE", +}}, + HttpVerb = "POST", + RequestBody = "SGVsbG8gd29ybGQ=", + }, + ValidationRules = new WebTestValidationRules + { + CheckSsl = true, + SslCertRemainingLifetimeCheck = 100, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, webTestName, data); + ApplicationInsightsWebTestResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,10 +139,10 @@ public async Task Get_WebTestGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WebTestGet() + public async Task CreateOrUpdate_WebTestUpdate() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestGet.json - // this example is just showing the usage of "WebTests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestUpdate.json + // this example is just showing the usage of "WebTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,15 +160,37 @@ public async Task Exists_WebTestGet() ApplicationInsightsWebTestCollection collection = resourceGroupResource.GetApplicationInsightsWebTests(); // invoke the operation - string webTestName = "my-webtest-01-mywebservice"; - bool result = await collection.ExistsAsync(webTestName); + string webTestName = "my-webtest-my-component"; + ApplicationInsightsWebTestData data = new ApplicationInsightsWebTestData(new AzureLocation("South Central US")) + { + Kind = WebTestKind.Ping, + SyntheticMonitorId = "my-webtest-my-component", + WebTestName = "my-webtest-my-component", + FrequencyInSeconds = 600, + TimeoutInSeconds = 30, + WebTestKind = WebTestKind.Ping, + Locations = {new WebTestGeolocation +{ +Location = new AzureLocation("us-fl-mia-edge"), +}, new WebTestGeolocation +{ +Location = new AzureLocation("apac-hk-hkn-azr"), +}}, + WebTest = "", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, webTestName, data); + ApplicationInsightsWebTestResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWebTestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WebTestGet() + public async Task Get_WebTestGet() { // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestGet.json // this example is just showing the usage of "WebTests_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +212,21 @@ public async Task GetIfExists_WebTestGet() // invoke the operation string webTestName = "my-webtest-01-mywebservice"; - NullableResponse response = await collection.GetIfExistsAsync(webTestName); - ApplicationInsightsWebTestResource result = response.HasValue ? response.Value : null; + ApplicationInsightsWebTestResource result = await collection.GetAsync(webTestName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWebTestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWebTestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WebTestCreate() + public async Task GetAll_WebTestListByResourceGroup() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestCreate.json - // this example is just showing the usage of "WebTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestListByResourceGroup.json + // this example is just showing the usage of "WebTests_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,44 +243,25 @@ public async Task CreateOrUpdate_WebTestCreate() // get the collection of this ApplicationInsightsWebTestResource ApplicationInsightsWebTestCollection collection = resourceGroupResource.GetApplicationInsightsWebTests(); - // invoke the operation - string webTestName = "my-webtest-my-component"; - ApplicationInsightsWebTestData data = new ApplicationInsightsWebTestData(new AzureLocation("South Central US")) + // invoke the operation and iterate over the result + await foreach (ApplicationInsightsWebTestResource item in collection.GetAllAsync()) { - Kind = WebTestKind.Ping, - SyntheticMonitorId = "my-webtest-my-component", - WebTestName = "my-webtest-my-component", - Description = "Ping web test alert for mytestwebapp", - IsEnabled = true, - FrequencyInSeconds = 900, - TimeoutInSeconds = 120, - WebTestKind = WebTestKind.Ping, - IsRetryEnabled = true, - Locations = -{ -new WebTestGeolocation() -{ -Location = new AzureLocation("us-fl-mia-edge"), -} -}, - WebTest = "", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, webTestName, data); - ApplicationInsightsWebTestResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWebTestData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWebTestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WebTestCreateStandard() + public async Task Exists_WebTestGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestCreateStandard.json - // this example is just showing the usage of "WebTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestGet.json + // this example is just showing the usage of "WebTests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -232,64 +279,18 @@ public async Task CreateOrUpdate_WebTestCreateStandard() ApplicationInsightsWebTestCollection collection = resourceGroupResource.GetApplicationInsightsWebTests(); // invoke the operation - string webTestName = "my-webtest-my-component"; - ApplicationInsightsWebTestData data = new ApplicationInsightsWebTestData(new AzureLocation("South Central US")) - { - SyntheticMonitorId = "my-webtest-my-component", - WebTestName = "my-webtest-my-component", - Description = "Ping web test alert for mytestwebapp", - IsEnabled = true, - FrequencyInSeconds = 900, - TimeoutInSeconds = 120, - WebTestKind = WebTestKind.Standard, - IsRetryEnabled = true, - Locations = -{ -new WebTestGeolocation() -{ -Location = new AzureLocation("us-fl-mia-edge"), -} -}, - Request = new WebTestRequest() - { - RequestUri = new Uri("https://bing.com"), - Headers = -{ -new WebTestRequestHeaderField() -{ -HeaderFieldName = "Content-Language", -HeaderFieldValue = "de-DE", -},new WebTestRequestHeaderField() -{ -HeaderFieldName = "Accept-Language", -HeaderFieldValue = "de-DE", -} -}, - HttpVerb = "POST", - RequestBody = "SGVsbG8gd29ybGQ=", - }, - ValidationRules = new WebTestValidationRules() - { - CheckSsl = true, - SslCertRemainingLifetimeCheck = 100, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, webTestName, data); - ApplicationInsightsWebTestResource result = lro.Value; + string webTestName = "my-webtest-01-mywebservice"; + bool result = await collection.ExistsAsync(webTestName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWebTestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WebTestUpdate() + public async Task GetIfExists_WebTestGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestUpdate.json - // this example is just showing the usage of "WebTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestGet.json + // this example is just showing the usage of "WebTests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -307,35 +308,22 @@ public async Task CreateOrUpdate_WebTestUpdate() ApplicationInsightsWebTestCollection collection = resourceGroupResource.GetApplicationInsightsWebTests(); // invoke the operation - string webTestName = "my-webtest-my-component"; - ApplicationInsightsWebTestData data = new ApplicationInsightsWebTestData(new AzureLocation("South Central US")) - { - Kind = WebTestKind.Ping, - SyntheticMonitorId = "my-webtest-my-component", - WebTestName = "my-webtest-my-component", - FrequencyInSeconds = 600, - TimeoutInSeconds = 30, - WebTestKind = WebTestKind.Ping, - Locations = -{ -new WebTestGeolocation() -{ -Location = new AzureLocation("us-fl-mia-edge"), -},new WebTestGeolocation() -{ -Location = new AzureLocation("apac-hk-hkn-azr"), -} -}, - WebTest = "", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, webTestName, data); - ApplicationInsightsWebTestResource result = lro.Value; + string webTestName = "my-webtest-01-mywebservice"; + NullableResponse response = await collection.GetIfExistsAsync(webTestName); + ApplicationInsightsWebTestResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWebTestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWebTestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWebTestResource.cs b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWebTestResource.cs index 88b5ed97ad07f..65330e8f7c2c6 100644 --- a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWebTestResource.cs +++ b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWebTestResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ApplicationInsights.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ApplicationInsights.Samples @@ -47,46 +46,6 @@ public async Task Get_WebTestGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_WebTestUpdateTags() - { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestUpdateTagsOnly.json - // this example is just showing the usage of "WebTests_UpdateTags" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ApplicationInsightsWebTestResource created on azure - // for more information of creating ApplicationInsightsWebTestResource, please refer to the document of ApplicationInsightsWebTestResource - string subscriptionId = "subid"; - string resourceGroupName = "my-resource-group"; - string webTestName = "my-webtest-my-component"; - ResourceIdentifier applicationInsightsWebTestResourceId = ApplicationInsightsWebTestResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, webTestName); - ApplicationInsightsWebTestResource applicationInsightsWebTest = client.GetApplicationInsightsWebTestResource(applicationInsightsWebTestResourceId); - - // invoke the operation - WebTestComponentTag webTestTags = new WebTestComponentTag() - { - Tags = -{ -["Color"] = "AzureBlue", -["CustomField-01"] = "This is a random value", -["SystemType"] = "A08", -["hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"] = "Resource", -}, - }; - ApplicationInsightsWebTestResource result = await applicationInsightsWebTest.UpdateAsync(webTestTags); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWebTestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Delete_WebTestDelete() @@ -115,33 +74,42 @@ public async Task Delete_WebTestDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetApplicationInsightsWebTests_WebTestList() + public async Task Update_WebTestUpdateTags() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestList.json - // this example is just showing the usage of "WebTests_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestUpdateTagsOnly.json + // this example is just showing the usage of "WebTests_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this ApplicationInsightsWebTestResource created on azure + // for more information of creating ApplicationInsightsWebTestResource, please refer to the document of ApplicationInsightsWebTestResource string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "my-resource-group"; + string webTestName = "my-webtest-my-component"; + ResourceIdentifier applicationInsightsWebTestResourceId = ApplicationInsightsWebTestResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, webTestName); + ApplicationInsightsWebTestResource applicationInsightsWebTest = client.GetApplicationInsightsWebTestResource(applicationInsightsWebTestResourceId); - // invoke the operation and iterate over the result - await foreach (ApplicationInsightsWebTestResource item in subscriptionResource.GetApplicationInsightsWebTestsAsync()) + // invoke the operation + WebTestComponentTag webTestTags = new WebTestComponentTag { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWebTestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["Color"] = "AzureBlue", +["CustomField-01"] = "This is a random value", +["SystemType"] = "A08", +["hidden-link:/subscriptions/subid/resourceGroups/my-resource-group/providers/Microsoft.Insights/components/my-component"] = "Resource" +}, + }; + ApplicationInsightsWebTestResource result = await applicationInsightsWebTest.UpdateAsync(webTestTags); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWebTestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookCollection.cs b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookCollection.cs index d220f595959b6..6b9cdd32e42e3 100644 --- a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookCollection.cs +++ b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_ApplicationInsightsWorkbookCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkbooksList() + public async Task CreateOrUpdate_WorkbookAdd() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksList.json - // this example is just showing the usage of "Workbooks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookAdd.json + // this example is just showing the usage of "Workbooks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,27 +40,38 @@ public async Task GetAll_WorkbooksList() // get the collection of this ApplicationInsightsWorkbookResource ApplicationInsightsWorkbookCollection collection = resourceGroupResource.GetApplicationInsightsWorkbooks(); - // invoke the operation and iterate over the result - WorkbookCategoryType category = WorkbookCategoryType.Workbook; - string sourceId = "/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"; - await foreach (ApplicationInsightsWorkbookResource item in collection.GetAllAsync(category, sourceId: sourceId)) + // invoke the operation + string resourceName = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; + ApplicationInsightsWorkbookData data = new ApplicationInsightsWorkbookData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "Sample workbook", + SerializedData = "{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}", + Category = "workbook", + Description = "Sample workbook", + Kind = WorkbookSharedTypeKind.Shared, + Tags = +{ +["TagSample01"] = "sample01", +["TagSample02"] = "sample02" +}, + }; + string sourceId = "/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data, sourceId: sourceId); + ApplicationInsightsWorkbookResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkbooksManagedList() + public async Task CreateOrUpdate_WorkbookManagedAdd() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksManagedList.json - // this example is just showing the usage of "Workbooks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookManagedAdd.json + // this example is just showing the usage of "Workbooks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,7 +80,7 @@ public async Task GetAll_WorkbooksManagedList() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "6b643656-33eb-422f-aee8-3ac119r124af"; + string subscriptionId = "6b643656-33eb-422f-aee8-3ac145d124af"; string resourceGroupName = "my-resource-group"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -77,19 +88,34 @@ public async Task GetAll_WorkbooksManagedList() // get the collection of this ApplicationInsightsWorkbookResource ApplicationInsightsWorkbookCollection collection = resourceGroupResource.GetApplicationInsightsWorkbooks(); - // invoke the operation and iterate over the result - WorkbookCategoryType category = WorkbookCategoryType.Workbook; - string sourceId = "/subscriptions/6b643656-33eb-422f-aee8-3ac119r124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"; - await foreach (ApplicationInsightsWorkbookResource item in collection.GetAllAsync(category, sourceId: sourceId)) + // invoke the operation + string resourceName = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; + ApplicationInsightsWorkbookData data = new ApplicationInsightsWorkbookData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "Sample workbook", + SerializedData = "{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"test\"},\"name\":\"text - 0\"}],\"isLocked\":false,\"fallbackResourceIds\":[\"/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/my-resource-group\"]}", + Version = "Notebook/1.0", + Category = "workbook", + StorageUri = new Uri("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), + Description = "Sample workbook", + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid")] = new UserAssignedIdentity() +}, + }, + Kind = WorkbookSharedTypeKind.Shared, + }; + string sourceId = "/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data, sourceId: sourceId); + ApplicationInsightsWorkbookResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -127,9 +153,9 @@ public async Task Get_WorkbookGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkbookGet() + public async Task Get_WorkbookGet1() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet.json + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet1.json // this example is just showing the usage of "Workbooks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -149,16 +175,20 @@ public async Task Exists_WorkbookGet() // invoke the operation string resourceName = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; - bool result = await collection.ExistsAsync(resourceName); + ApplicationInsightsWorkbookResource result = await collection.GetAsync(resourceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkbookGet() + public async Task Get_WorkbookManagedGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet.json + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookManagedGet.json // this example is just showing the usage of "Workbooks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -178,29 +208,21 @@ public async Task GetIfExists_WorkbookGet() // invoke the operation string resourceName = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - ApplicationInsightsWorkbookResource result = response.HasValue ? response.Value : null; + ApplicationInsightsWorkbookResource result = await collection.GetAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkbookGet1() + public async Task GetAll_WorkbooksList() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet1.json - // this example is just showing the usage of "Workbooks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksList.json + // this example is just showing the usage of "Workbooks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,23 +239,27 @@ public async Task Get_WorkbookGet1() // get the collection of this ApplicationInsightsWorkbookResource ApplicationInsightsWorkbookCollection collection = resourceGroupResource.GetApplicationInsightsWorkbooks(); - // invoke the operation - string resourceName = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; - ApplicationInsightsWorkbookResource result = await collection.GetAsync(resourceName); + // invoke the operation and iterate over the result + WorkbookCategoryType category = WorkbookCategoryType.Workbook; + string sourceId = "/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"; + await foreach (ApplicationInsightsWorkbookResource item in collection.GetAllAsync(category, sourceId: sourceId)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkbookGet1() + public async Task GetAll_WorkbooksManagedList() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet1.json - // this example is just showing the usage of "Workbooks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksManagedList.json + // this example is just showing the usage of "Workbooks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -242,7 +268,7 @@ public async Task Exists_WorkbookGet1() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "6b643656-33eb-422f-aee8-3ac145d124af"; + string subscriptionId = "6b643656-33eb-422f-aee8-3ac119r124af"; string resourceGroupName = "my-resource-group"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -250,18 +276,26 @@ public async Task Exists_WorkbookGet1() // get the collection of this ApplicationInsightsWorkbookResource ApplicationInsightsWorkbookCollection collection = resourceGroupResource.GetApplicationInsightsWorkbooks(); - // invoke the operation - string resourceName = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + WorkbookCategoryType category = WorkbookCategoryType.Workbook; + string sourceId = "/subscriptions/6b643656-33eb-422f-aee8-3ac119r124af/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/MyApp"; + await foreach (ApplicationInsightsWorkbookResource item in collection.GetAllAsync(category, sourceId: sourceId)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkbookGet1() + public async Task Exists_WorkbookGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet1.json + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet.json // this example is just showing the usage of "Workbooks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -281,28 +315,16 @@ public async Task GetIfExists_WorkbookGet1() // invoke the operation string resourceName = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - ApplicationInsightsWorkbookResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkbookManagedGet() + public async Task Exists_WorkbookGet1() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookManagedGet.json + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet1.json // this example is just showing the usage of "Workbooks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -322,13 +344,9 @@ public async Task Get_WorkbookManagedGet() // invoke the operation string resourceName = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; - ApplicationInsightsWorkbookResource result = await collection.GetAsync(resourceName); + bool result = await collection.ExistsAsync(resourceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -362,9 +380,9 @@ public async Task Exists_WorkbookManagedGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkbookManagedGet() + public async Task GetIfExists_WorkbookGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookManagedGet.json + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet.json // this example is just showing the usage of "Workbooks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -403,10 +421,10 @@ public async Task GetIfExists_WorkbookManagedGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkbookAdd() + public async Task GetIfExists_WorkbookGet1() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookAdd.json - // this example is just showing the usage of "Workbooks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookGet1.json + // this example is just showing the usage of "Workbooks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -425,36 +443,29 @@ public async Task CreateOrUpdate_WorkbookAdd() // invoke the operation string resourceName = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; - ApplicationInsightsWorkbookData data = new ApplicationInsightsWorkbookData(new AzureLocation("westus")) - { - DisplayName = "Sample workbook", - SerializedData = "{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":\"{\"json\":\"## New workbook\\r\\n---\\r\\n\\r\\nWelcome to your new workbook. This area will display text formatted as markdown.\\r\\n\\r\\n\\r\\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.\"}\",\"halfWidth\":null,\"conditionalVisibility\":null},{\"type\":3,\"content\":\"{\"version\":\"KqlItem/1.0\",\"query\":\"union withsource=TableName *\\n| summarize Count=count() by TableName\\n| render barchart\",\"showQuery\":false,\"size\":1,\"aggregation\":0,\"showAnnotations\":false}\",\"halfWidth\":null,\"conditionalVisibility\":null}],\"isLocked\":false}", - Category = "workbook", - Description = "Sample workbook", - Kind = WorkbookSharedTypeKind.Shared, - Tags = -{ -["TagSample01"] = "sample01", -["TagSample02"] = "sample02", -}, - }; - string sourceId = "/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data, sourceId: sourceId); - ApplicationInsightsWorkbookResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + ApplicationInsightsWorkbookResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkbookManagedAdd() + public async Task GetIfExists_WorkbookManagedGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookManagedAdd.json - // this example is just showing the usage of "Workbooks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookManagedGet.json + // this example is just showing the usage of "Workbooks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -473,32 +484,21 @@ public async Task CreateOrUpdate_WorkbookManagedAdd() // invoke the operation string resourceName = "deadb33f-5e0d-4064-8ebb-1a4ed0313eb2"; - ApplicationInsightsWorkbookData data = new ApplicationInsightsWorkbookData(new AzureLocation("westus")) - { - DisplayName = "Sample workbook", - SerializedData = "{\"version\":\"Notebook/1.0\",\"items\":[{\"type\":1,\"content\":{\"json\":\"test\"},\"name\":\"text - 0\"}],\"isLocked\":false,\"fallbackResourceIds\":[\"/subscriptions/00000000-0000-0000-0000-00000000/resourceGroups/my-resource-group\"]}", - Version = "Notebook/1.0", - Category = "workbook", - StorageUri = new Uri("/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourceGroups/my-resource-group/providers/Microsoft.Storage/storageAccounts/mystorage/blobServices/default/containers/mycontainer"), - Description = "Sample workbook", - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myid")] = new UserAssignedIdentity(), -}, - }, - Kind = WorkbookSharedTypeKind.Shared, - }; - string sourceId = "/subscriptions/6b643656-33eb-422f-aee8-3ac145d124af/resourcegroups/my-resource-group"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data, sourceId: sourceId); - ApplicationInsightsWorkbookResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + ApplicationInsightsWorkbookResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookResource.cs b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookResource.cs index 7928bba893fd4..9c1ab5644a04f 100644 --- a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookResource.cs +++ b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookResource.cs @@ -10,77 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ApplicationInsights.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ApplicationInsights.Samples { public partial class Sample_ApplicationInsightsWorkbookResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApplicationInsightsWorkbooks_WorkbooksList2() - { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksList2.json - // this example is just showing the usage of "Workbooks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "6b643656-33eb-422f-aee8-3ac145d124af"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - WorkbookCategoryType category = WorkbookCategoryType.Workbook; - await foreach (ApplicationInsightsWorkbookResource item in subscriptionResource.GetApplicationInsightsWorkbooksAsync(category)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApplicationInsightsWorkbooks_WorkbooksListSub() - { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksListSub.json - // this example is just showing the usage of "Workbooks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "6b643656-33eb-422f-aee8-3ac145d124af"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - WorkbookCategoryType category = WorkbookCategoryType.Workbook; - await foreach (ApplicationInsightsWorkbookResource item in subscriptionResource.GetApplicationInsightsWorkbooksAsync(category)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_WorkbookGet() diff --git a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookRevisionCollection.cs b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookRevisionCollection.cs index 06bf77fff2a85..2a7e28677bc33 100644 --- a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookRevisionCollection.cs +++ b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookRevisionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ApplicationInsightsWorkbookRevisionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkbookRevisionsList() + public async Task Get_WorkbookRevisionGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookRevisionsList.json - // this example is just showing the usage of "Workbooks_RevisionsList" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookRevisionGet.json + // this example is just showing the usage of "Workbooks_RevisionGet" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_WorkbookRevisionsList() // get the collection of this ApplicationInsightsWorkbookRevisionResource ApplicationInsightsWorkbookRevisionCollection collection = applicationInsightsWorkbook.GetApplicationInsightsWorkbookRevisions(); - // invoke the operation and iterate over the result - await foreach (ApplicationInsightsWorkbookRevisionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string revisionId = "1e2f8435b98248febee70c64ac22e1ab"; + ApplicationInsightsWorkbookRevisionResource result = await collection.GetAsync(revisionId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkbookRevisionGet() + public async Task GetAll_WorkbookRevisionsList() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookRevisionGet.json - // this example is just showing the usage of "Workbooks_RevisionGet" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbookRevisionsList.json + // this example is just showing the usage of "Workbooks_RevisionsList" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_WorkbookRevisionGet() // get the collection of this ApplicationInsightsWorkbookRevisionResource ApplicationInsightsWorkbookRevisionCollection collection = applicationInsightsWorkbook.GetApplicationInsightsWorkbookRevisions(); - // invoke the operation - string revisionId = "1e2f8435b98248febee70c64ac22e1ab"; - ApplicationInsightsWorkbookRevisionResource result = await collection.GetAsync(revisionId); + // invoke the operation and iterate over the result + await foreach (ApplicationInsightsWorkbookRevisionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookTemplateCollection.cs b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookTemplateCollection.cs index 17ca6e1cbb1b7..ea45e0ba04154 100644 --- a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookTemplateCollection.cs +++ b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_ApplicationInsightsWorkbookTemplateCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_ApplicationInsightsWorkbookTemplateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkbookTemplatesList() + public async Task CreateOrUpdate_WorkbookTemplateAdd() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplatesList.json - // this example is just showing the usage of "WorkbookTemplates_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplateAdd.json + // this example is just showing the usage of "WorkbookTemplates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task GetAll_WorkbookTemplatesList() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "6b643656-33eb-422f-aee8-3ac145d124af"; + string subscriptionId = "subid"; string resourceGroupName = "my-resource-group"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -40,17 +40,62 @@ public async Task GetAll_WorkbookTemplatesList() // get the collection of this ApplicationInsightsWorkbookTemplateResource ApplicationInsightsWorkbookTemplateCollection collection = resourceGroupResource.GetApplicationInsightsWorkbookTemplates(); - // invoke the operation and iterate over the result - await foreach (ApplicationInsightsWorkbookTemplateResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "testtemplate2"; + ApplicationInsightsWorkbookTemplateData data = new ApplicationInsightsWorkbookTemplateData(new AzureLocation("west us")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookTemplateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Priority = 1, + Author = "Contoso", + TemplateData = BinaryData.FromObjectAsJson(new Dictionary + { + ["$schema"] = "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", + ["items"] = new object[] + { +new +{ +name = "text - 2", +type = "1", +content = new +{ +json = "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections.", +}, +}, +new +{ +name = "query - 2", +type = "3", +content = new +{ +exportToExcelOptions = "visible", +query = "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", +queryType = "0", +resourceType = "microsoft.operationalinsights/workspaces", +size = "1", +version = "KqlItem/1.0", +}, +} + }, + ["styleSettings"] = new object(), + ["version"] = "Notebook/1.0" + }), + Galleries = {new WorkbookTemplateGallery +{ +Name = "Simple Template", +Category = "Failures", +WorkbookType = "tsg", +Order = 100, +ResourceType = "microsoft.insights/components", +}}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + ApplicationInsightsWorkbookTemplateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookTemplateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +133,10 @@ public async Task Get_WorkbookTemplateGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkbookTemplateGet() + public async Task GetAll_WorkbookTemplatesList() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplateGet.json - // this example is just showing the usage of "WorkbookTemplates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplatesList.json + // this example is just showing the usage of "WorkbookTemplates_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +153,22 @@ public async Task Exists_WorkbookTemplateGet() // get the collection of this ApplicationInsightsWorkbookTemplateResource ApplicationInsightsWorkbookTemplateCollection collection = resourceGroupResource.GetApplicationInsightsWorkbookTemplates(); - // invoke the operation - string resourceName = "my-resource-name"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (ApplicationInsightsWorkbookTemplateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookTemplateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkbookTemplateGet() + public async Task Exists_WorkbookTemplateGet() { // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplateGet.json // this example is just showing the usage of "WorkbookTemplates_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +190,17 @@ public async Task GetIfExists_WorkbookTemplateGet() // invoke the operation string resourceName = "my-resource-name"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - ApplicationInsightsWorkbookTemplateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookTemplateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkbookTemplateAdd() + public async Task GetIfExists_WorkbookTemplateGet() { - // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplateAdd.json - // this example is just showing the usage of "WorkbookTemplates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-11-20/examples/WorkbookTemplateGet.json + // this example is just showing the usage of "WorkbookTemplates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -170,7 +209,7 @@ public async Task CreateOrUpdate_WorkbookTemplateAdd() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; + string subscriptionId = "6b643656-33eb-422f-aee8-3ac145d124af"; string resourceGroupName = "my-resource-group"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -179,60 +218,22 @@ public async Task CreateOrUpdate_WorkbookTemplateAdd() ApplicationInsightsWorkbookTemplateCollection collection = resourceGroupResource.GetApplicationInsightsWorkbookTemplates(); // invoke the operation - string resourceName = "testtemplate2"; - ApplicationInsightsWorkbookTemplateData data = new ApplicationInsightsWorkbookTemplateData(new AzureLocation("west us")) - { - Priority = 1, - Author = "Contoso", - TemplateData = BinaryData.FromObjectAsJson(new Dictionary() - { - ["$schema"] = "https://github.com/Microsoft/Application-Insights-Workbooks/blob/master/schema/workbook.json", - ["items"] = new object[] { new Dictionary() -{ -["name"] = "text - 2", -["type"] = "1", -["content"] = new Dictionary() -{ -["json"] = "## New workbook\n---\n\nWelcome to your new workbook. This area will display text formatted as markdown.\n\n\nWe've included a basic analytics query to get you started. Use the `Edit` button below each section to configure it or add more sections."}}, new Dictionary() -{ -["name"] = "query - 2", -["type"] = "3", -["content"] = new Dictionary() -{ -["exportToExcelOptions"] = "visible", -["query"] = "union withsource=TableName *\n| summarize Count=count() by TableName\n| render barchart", -["queryType"] = "0", -["resourceType"] = "microsoft.operationalinsights/workspaces", -["size"] = "1", -["version"] = "KqlItem/1.0"}} }, - ["styleSettings"] = new Dictionary() - { - }, - ["version"] = "Notebook/1.0" - }), - Galleries = -{ -new WorkbookTemplateGallery() -{ -Name = "Simple Template", -Category = "Failures", -WorkbookType = "tsg", -Order = 100, -ResourceType = "microsoft.insights/components", -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - ApplicationInsightsWorkbookTemplateResource result = lro.Value; + string resourceName = "my-resource-name"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + ApplicationInsightsWorkbookTemplateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationInsightsWorkbookTemplateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookTemplateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..4793752fae902 --- /dev/null +++ b/sdk/applicationinsights/Azure.ResourceManager.ApplicationInsights/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,146 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.ApplicationInsights.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ApplicationInsights.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApplicationInsightsComponents_ComponentsListJson() + { + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2020-02-02/examples/ComponentsList.json + // this example is just showing the usage of "Components_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ApplicationInsightsComponentResource item in subscriptionResource.GetApplicationInsightsComponentsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsComponentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApplicationInsightsWebTests_WebTestList() + { + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/WebTestList.json + // this example is just showing the usage of "WebTests_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ApplicationInsightsWebTestResource item in subscriptionResource.GetApplicationInsightsWebTestsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWebTestData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApplicationInsightsWorkbooks_WorkbooksList2() + { + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksList2.json + // this example is just showing the usage of "Workbooks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "6b643656-33eb-422f-aee8-3ac145d124af"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + WorkbookCategoryType category = WorkbookCategoryType.Workbook; + await foreach (ApplicationInsightsWorkbookResource item in subscriptionResource.GetApplicationInsightsWorkbooksAsync(category)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApplicationInsightsWorkbooks_WorkbooksListSub() + { + // Generated from example definition: specification/applicationinsights/resource-manager/Microsoft.Insights/stable/2023-06-01/examples/WorkbooksListSub.json + // this example is just showing the usage of "Workbooks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "6b643656-33eb-422f-aee8-3ac145d124af"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + WorkbookCategoryType category = WorkbookCategoryType.Workbook; + await foreach (ApplicationInsightsWorkbookResource item in subscriptionResource.GetApplicationInsightsWorkbooksAsync(category)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationInsightsWorkbookData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCollection.cs index af3679c524a10..1e31c66bbf525 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformApiPortalCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiPortalsGet() + public async Task CreateOrUpdate_ApiPortalsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_Get.json - // this example is just showing the usage of "ApiPortals_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_CreateOrUpdate.json + // this example is just showing the usage of "ApiPortals_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,22 @@ public async Task Get_ApiPortalsGet() // invoke the operation string apiPortalName = "default"; - AppPlatformApiPortalResource result = await collection.GetAsync(apiPortalName); + AppPlatformApiPortalData data = new AppPlatformApiPortalData + { + Properties = new AppPlatformApiPortalProperties + { + IsPublic = true, + GatewayIds = { new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/gateways/default") }, + }, + Sku = new AppPlatformSku + { + Name = "E0", + Tier = "Enterprise", + Capacity = 2, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiPortalName, data); + AppPlatformApiPortalResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +67,7 @@ public async Task Get_ApiPortalsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiPortalsGet() + public async Task Get_ApiPortalsGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_Get.json // this example is just showing the usage of "ApiPortals_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +90,21 @@ public async Task Exists_ApiPortalsGet() // invoke the operation string apiPortalName = "default"; - bool result = await collection.ExistsAsync(apiPortalName); + AppPlatformApiPortalResource result = await collection.GetAsync(apiPortalName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformApiPortalData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiPortalsGet() + public async Task GetAll_ApiPortalsList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_Get.json - // this example is just showing the usage of "ApiPortals_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_List.json + // this example is just showing the usage of "ApiPortals_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +122,25 @@ public async Task GetIfExists_ApiPortalsGet() // get the collection of this AppPlatformApiPortalResource AppPlatformApiPortalCollection collection = appPlatformService.GetAppPlatformApiPortals(); - // invoke the operation - string apiPortalName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(apiPortalName); - AppPlatformApiPortalResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformApiPortalResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformApiPortalData resourceData = result.Data; + AppPlatformApiPortalData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiPortalsCreateOrUpdate() + public async Task Exists_ApiPortalsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_CreateOrUpdate.json - // this example is just showing the usage of "ApiPortals_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_Get.json + // this example is just showing the usage of "ApiPortals_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,39 +160,17 @@ public async Task CreateOrUpdate_ApiPortalsCreateOrUpdate() // invoke the operation string apiPortalName = "default"; - AppPlatformApiPortalData data = new AppPlatformApiPortalData() - { - Properties = new AppPlatformApiPortalProperties() - { - IsPublic = true, - GatewayIds = -{ -new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/gateways/default") -}, - }, - Sku = new AppPlatformSku() - { - Name = "E0", - Tier = "Enterprise", - Capacity = 2, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiPortalName, data); - AppPlatformApiPortalResource result = lro.Value; + bool result = await collection.ExistsAsync(apiPortalName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformApiPortalData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiPortalsList() + public async Task GetIfExists_ApiPortalsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_List.json - // this example is just showing the usage of "ApiPortals_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_Get.json + // this example is just showing the usage of "ApiPortals_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -197,17 +188,23 @@ public async Task GetAll_ApiPortalsList() // get the collection of this AppPlatformApiPortalResource AppPlatformApiPortalCollection collection = appPlatformService.GetAppPlatformApiPortals(); - // invoke the operation and iterate over the result - await foreach (AppPlatformApiPortalResource item in collection.GetAllAsync()) + // invoke the operation + string apiPortalName = "default"; + NullableResponse response = await collection.GetIfExistsAsync(apiPortalName); + AppPlatformApiPortalResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformApiPortalData resourceData = item.Data; + AppPlatformApiPortalData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCustomDomainCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCustomDomainCollection.cs index 89df83fa896f1..bf34c9c9bb150 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCustomDomainCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCustomDomainCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppPlatformApiPortalCustomDomainCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApiPortalCustomDomainsGet() + public async Task CreateOrUpdate_ApiPortalCustomDomainsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_Get.json - // this example is just showing the usage of "ApiPortalCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_CreateOrUpdate.json + // this example is just showing the usage of "ApiPortalCustomDomains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_ApiPortalCustomDomainsGet() // invoke the operation string domainName = "myDomainName"; - AppPlatformApiPortalCustomDomainResource result = await collection.GetAsync(domainName); + AppPlatformApiPortalCustomDomainData data = new AppPlatformApiPortalCustomDomainData + { + ApiPortalCustomDomainThumbprint = "*", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); + AppPlatformApiPortalCustomDomainResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_ApiPortalCustomDomainsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApiPortalCustomDomainsGet() + public async Task Get_ApiPortalCustomDomainsGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_Get.json // this example is just showing the usage of "ApiPortalCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +81,21 @@ public async Task Exists_ApiPortalCustomDomainsGet() // invoke the operation string domainName = "myDomainName"; - bool result = await collection.ExistsAsync(domainName); + AppPlatformApiPortalCustomDomainResource result = await collection.GetAsync(domainName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformApiPortalCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApiPortalCustomDomainsGet() + public async Task GetAll_ApiPortalCustomDomainsList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_Get.json - // this example is just showing the usage of "ApiPortalCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_List.json + // this example is just showing the usage of "ApiPortalCustomDomains_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,31 +114,25 @@ public async Task GetIfExists_ApiPortalCustomDomainsGet() // get the collection of this AppPlatformApiPortalCustomDomainResource AppPlatformApiPortalCustomDomainCollection collection = appPlatformApiPortal.GetAppPlatformApiPortalCustomDomains(); - // invoke the operation - string domainName = "myDomainName"; - NullableResponse response = await collection.GetIfExistsAsync(domainName); - AppPlatformApiPortalCustomDomainResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformApiPortalCustomDomainResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformApiPortalCustomDomainData resourceData = result.Data; + AppPlatformApiPortalCustomDomainData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApiPortalCustomDomainsCreateOrUpdate() + public async Task Exists_ApiPortalCustomDomainsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_CreateOrUpdate.json - // this example is just showing the usage of "ApiPortalCustomDomains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_Get.json + // this example is just showing the usage of "ApiPortalCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,26 +153,17 @@ public async Task CreateOrUpdate_ApiPortalCustomDomainsCreateOrUpdate() // invoke the operation string domainName = "myDomainName"; - AppPlatformApiPortalCustomDomainData data = new AppPlatformApiPortalCustomDomainData() - { - ApiPortalCustomDomainThumbprint = "*", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); - AppPlatformApiPortalCustomDomainResource result = lro.Value; + bool result = await collection.ExistsAsync(domainName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformApiPortalCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApiPortalCustomDomainsList() + public async Task GetIfExists_ApiPortalCustomDomainsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_List.json - // this example is just showing the usage of "ApiPortalCustomDomains_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_Get.json + // this example is just showing the usage of "ApiPortalCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_ApiPortalCustomDomainsList() // get the collection of this AppPlatformApiPortalCustomDomainResource AppPlatformApiPortalCustomDomainCollection collection = appPlatformApiPortal.GetAppPlatformApiPortalCustomDomains(); - // invoke the operation and iterate over the result - await foreach (AppPlatformApiPortalCustomDomainResource item in collection.GetAllAsync()) + // invoke the operation + string domainName = "myDomainName"; + NullableResponse response = await collection.GetIfExistsAsync(domainName); + AppPlatformApiPortalCustomDomainResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformApiPortalCustomDomainData resourceData = item.Data; + AppPlatformApiPortalCustomDomainData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCustomDomainResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCustomDomainResource.cs index b0828a86f478e..8628fc379ca9f 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCustomDomainResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalCustomDomainResource.cs @@ -49,10 +49,10 @@ public async Task Get_ApiPortalCustomDomainsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiPortalCustomDomainsCreateOrUpdate() + public async Task Delete_ApiPortalCustomDomainsDelete() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_CreateOrUpdate.json - // this example is just showing the usage of "ApiPortalCustomDomains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_Delete.json + // this example is just showing the usage of "ApiPortalCustomDomains_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_ApiPortalCustomDomainsCreateOrUpdate() AppPlatformApiPortalCustomDomainResource appPlatformApiPortalCustomDomain = client.GetAppPlatformApiPortalCustomDomainResource(appPlatformApiPortalCustomDomainResourceId); // invoke the operation - AppPlatformApiPortalCustomDomainData data = new AppPlatformApiPortalCustomDomainData() - { - ApiPortalCustomDomainThumbprint = "*", - }; - ArmOperation lro = await appPlatformApiPortalCustomDomain.UpdateAsync(WaitUntil.Completed, data); - AppPlatformApiPortalCustomDomainResource result = lro.Value; + await appPlatformApiPortalCustomDomain.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformApiPortalCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiPortalCustomDomainsDelete() + public async Task Update_ApiPortalCustomDomainsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_Delete.json - // this example is just showing the usage of "ApiPortalCustomDomains_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortalCustomDomains_CreateOrUpdate.json + // this example is just showing the usage of "ApiPortalCustomDomains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +98,18 @@ public async Task Delete_ApiPortalCustomDomainsDelete() AppPlatformApiPortalCustomDomainResource appPlatformApiPortalCustomDomain = client.GetAppPlatformApiPortalCustomDomainResource(appPlatformApiPortalCustomDomainResourceId); // invoke the operation - await appPlatformApiPortalCustomDomain.DeleteAsync(WaitUntil.Completed); + AppPlatformApiPortalCustomDomainData data = new AppPlatformApiPortalCustomDomainData + { + ApiPortalCustomDomainThumbprint = "*", + }; + ArmOperation lro = await appPlatformApiPortalCustomDomain.UpdateAsync(WaitUntil.Completed, data); + AppPlatformApiPortalCustomDomainResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformApiPortalCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalResource.cs index 98e04592dcb74..6d9bbb78a63bf 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformApiPortalResource.cs @@ -49,10 +49,10 @@ public async Task Get_ApiPortalsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApiPortalsCreateOrUpdate() + public async Task Delete_ApiPortalsDelete() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_CreateOrUpdate.json - // this example is just showing the usage of "ApiPortals_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_Delete.json + // this example is just showing the usage of "ApiPortals_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,39 +69,17 @@ public async Task Update_ApiPortalsCreateOrUpdate() AppPlatformApiPortalResource appPlatformApiPortal = client.GetAppPlatformApiPortalResource(appPlatformApiPortalResourceId); // invoke the operation - AppPlatformApiPortalData data = new AppPlatformApiPortalData() - { - Properties = new AppPlatformApiPortalProperties() - { - IsPublic = true, - GatewayIds = -{ -new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/gateways/default") -}, - }, - Sku = new AppPlatformSku() - { - Name = "E0", - Tier = "Enterprise", - Capacity = 2, - }, - }; - ArmOperation lro = await appPlatformApiPortal.UpdateAsync(WaitUntil.Completed, data); - AppPlatformApiPortalResource result = lro.Value; + await appPlatformApiPortal.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformApiPortalData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApiPortalsDelete() + public async Task Update_ApiPortalsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_Delete.json - // this example is just showing the usage of "ApiPortals_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ApiPortals_CreateOrUpdate.json + // this example is just showing the usage of "ApiPortals_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,9 +96,28 @@ public async Task Delete_ApiPortalsDelete() AppPlatformApiPortalResource appPlatformApiPortal = client.GetAppPlatformApiPortalResource(appPlatformApiPortalResourceId); // invoke the operation - await appPlatformApiPortal.DeleteAsync(WaitUntil.Completed); + AppPlatformApiPortalData data = new AppPlatformApiPortalData + { + Properties = new AppPlatformApiPortalProperties + { + IsPublic = true, + GatewayIds = { new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/gateways/default") }, + }, + Sku = new AppPlatformSku + { + Name = "E0", + Tier = "Enterprise", + Capacity = 2, + }, + }; + ArmOperation lro = await appPlatformApiPortal.UpdateAsync(WaitUntil.Completed, data); + AppPlatformApiPortalResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformApiPortalData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformAppCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformAppCollection.cs index 2bc5bc7101a9a..3395b95478209 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformAppCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformAppCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -20,10 +19,10 @@ public partial class Sample_AppPlatformAppCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AppsGet() + public async Task CreateOrUpdate_AppsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_Get.json - // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_CreateOrUpdate.json + // this example is just showing the usage of "Apps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,7 +42,61 @@ public async Task Get_AppsGet() // invoke the operation string appName = "myapp"; - AppPlatformAppResource result = await collection.GetAsync(appName); + AppPlatformAppData data = new AppPlatformAppData + { + Properties = new AppPlatformAppProperties + { + IsPublic = true, + AddonConfigs = +{ +["ApplicationConfigurationService"] = +{ +["resourceId"] = BinaryData.FromObjectAsJson("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/configurationServices/myacs") +}, +["ServiceRegistry"] = +{ +["resourceId"] = BinaryData.FromObjectAsJson("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/serviceRegistries/myServiceRegistry") +} +}, + IsHttpsOnly = false, + TemporaryDisk = new AppTemporaryDisk + { + SizeInGB = 2, + MountPath = "/mytemporarydisk", + }, + PersistentDisk = new AppPersistentDisk + { + SizeInGB = 2, + MountPath = "/mypersistentdisk", + }, + CustomPersistentDisks = {new AppCustomPersistentDisk("myASCStorageID") +{ +CustomPersistentDiskProperties = new AppPlatformAzureFileVolume("/mypath1/mypath2", "myFileShare") +{ +MountOptions = {"uid=0", "gid=0", "dir_mode=0777", "file_mode=0777"}, +}, +}}, + IsEndToEndTlsEnabled = false, + LoadedCertificates = {new AppLoadedCertificate(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/certificates/mycert1")) +{ +LoadTrustStore = false, +}, new AppLoadedCertificate(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/certificates/mycert2")) +{ +LoadTrustStore = true, +}}, + }, + Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity() +}, + }, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, appName, data); + AppPlatformAppResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +107,10 @@ public async Task Get_AppsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AppsGet() + public async Task CreateOrUpdate_AppsCreateOrUpdateVNetInjection() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_Get.json - // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_CreateOrUpdate_VNetInjection.json + // this example is just showing the usage of "Apps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,14 +130,76 @@ public async Task Exists_AppsGet() // invoke the operation string appName = "myapp"; - bool result = await collection.ExistsAsync(appName); + AppPlatformAppData data = new AppPlatformAppData + { + Properties = new AppPlatformAppProperties + { + IsPublic = true, + AddonConfigs = +{ +["ApplicationConfigurationService"] = +{ +["resourceId"] = BinaryData.FromObjectAsJson("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/configurationServices/myacs") +}, +["ServiceRegistry"] = +{ +["resourceId"] = BinaryData.FromObjectAsJson("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/serviceRegistries/myServiceRegistry") +} +}, + IsHttpsOnly = false, + TemporaryDisk = new AppTemporaryDisk + { + SizeInGB = 2, + MountPath = "/mytemporarydisk", + }, + PersistentDisk = new AppPersistentDisk + { + SizeInGB = 2, + MountPath = "/mypersistentdisk", + }, + CustomPersistentDisks = {new AppCustomPersistentDisk("myASCStorageID") +{ +CustomPersistentDiskProperties = new AppPlatformAzureFileVolume("/mypath1/mypath2", "myFileShare") +{ +MountOptions = {"uid=0", "gid=0", "dir_mode=0777", "file_mode=0777"}, +}, +}}, + IsEndToEndTlsEnabled = false, + LoadedCertificates = {new AppLoadedCertificate(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/certificates/mycert1")) +{ +LoadTrustStore = false, +}, new AppLoadedCertificate(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/certificates/mycert2")) +{ +LoadTrustStore = true, +}}, + VnetAddons = new AppVnetAddons + { + IsPublicEndpoint = true, + }, + }, + Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity() +}, + }, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, appName, data); + AppPlatformAppResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AppsGet() + public async Task Get_AppsGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_Get.json // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,21 +222,13 @@ public async Task GetIfExists_AppsGet() // invoke the operation string appName = "myapp"; - NullableResponse response = await collection.GetIfExistsAsync(appName); - AppPlatformAppResource result = response.HasValue ? response.Value : null; + AppPlatformAppResource result = await collection.GetAsync(appName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformAppData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -160,10 +267,10 @@ public async Task Get_AppsGetVNetInjection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AppsGetVNetInjection() + public async Task GetAll_AppsList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_Get_VNetInjection.json - // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_List.json + // this example is just showing the usage of "Apps_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,19 +288,25 @@ public async Task Exists_AppsGetVNetInjection() // get the collection of this AppPlatformAppResource AppPlatformAppCollection collection = appPlatformService.GetAppPlatformApps(); - // invoke the operation - string appName = "myapp"; - bool result = await collection.ExistsAsync(appName); + // invoke the operation and iterate over the result + await foreach (AppPlatformAppResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformAppData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AppsGetVNetInjection() + public async Task GetAll_AppsListVNetInjection() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_Get_VNetInjection.json - // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_List_VNetInjection.json + // this example is just showing the usage of "Apps_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -211,31 +324,25 @@ public async Task GetIfExists_AppsGetVNetInjection() // get the collection of this AppPlatformAppResource AppPlatformAppCollection collection = appPlatformService.GetAppPlatformApps(); - // invoke the operation - string appName = "myapp"; - NullableResponse response = await collection.GetIfExistsAsync(appName); - AppPlatformAppResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformAppResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformAppData resourceData = result.Data; + AppPlatformAppData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AppsCreateOrUpdate() + public async Task Exists_AppsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_CreateOrUpdate.json - // this example is just showing the usage of "Apps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_Get.json + // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -255,84 +362,17 @@ public async Task CreateOrUpdate_AppsCreateOrUpdate() // invoke the operation string appName = "myapp"; - AppPlatformAppData data = new AppPlatformAppData() - { - Properties = new AppPlatformAppProperties() - { - IsPublic = true, - AddonConfigs = -{ -["ApplicationConfigurationService"] = new Dictionary() -{ -["resourceId"] = BinaryData.FromString("\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/configurationServices/myacs\""), -}, -["ServiceRegistry"] = new Dictionary() -{ -["resourceId"] = BinaryData.FromString("\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/serviceRegistries/myServiceRegistry\""), -}, -}, - IsHttpsOnly = false, - TemporaryDisk = new AppTemporaryDisk() - { - SizeInGB = 2, - MountPath = "/mytemporarydisk", - }, - PersistentDisk = new AppPersistentDisk() - { - SizeInGB = 2, - MountPath = "/mypersistentdisk", - }, - CustomPersistentDisks = -{ -new AppCustomPersistentDisk("myASCStorageID") -{ -CustomPersistentDiskProperties = new AppPlatformAzureFileVolume("/mypath1/mypath2","myFileShare") -{ -MountOptions = -{ -"uid=0","gid=0","dir_mode=0777","file_mode=0777" -}, -}, -} -}, - IsEndToEndTlsEnabled = false, - LoadedCertificates = -{ -new AppLoadedCertificate(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/certificates/mycert1")) -{ -LoadTrustStore = false, -},new AppLoadedCertificate(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/certificates/mycert2")) -{ -LoadTrustStore = true, -} -}, - }, - Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity(), -}, - }, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, appName, data); - AppPlatformAppResource result = lro.Value; + bool result = await collection.ExistsAsync(appName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AppsCreateOrUpdateVNetInjection() + public async Task Exists_AppsGetVNetInjection() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_CreateOrUpdate_VNetInjection.json - // this example is just showing the usage of "Apps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_Get_VNetInjection.json + // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -352,88 +392,17 @@ public async Task CreateOrUpdate_AppsCreateOrUpdateVNetInjection() // invoke the operation string appName = "myapp"; - AppPlatformAppData data = new AppPlatformAppData() - { - Properties = new AppPlatformAppProperties() - { - IsPublic = true, - AddonConfigs = -{ -["ApplicationConfigurationService"] = new Dictionary() -{ -["resourceId"] = BinaryData.FromString("\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/configurationServices/myacs\""), -}, -["ServiceRegistry"] = new Dictionary() -{ -["resourceId"] = BinaryData.FromString("\"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/serviceRegistries/myServiceRegistry\""), -}, -}, - IsHttpsOnly = false, - TemporaryDisk = new AppTemporaryDisk() - { - SizeInGB = 2, - MountPath = "/mytemporarydisk", - }, - PersistentDisk = new AppPersistentDisk() - { - SizeInGB = 2, - MountPath = "/mypersistentdisk", - }, - CustomPersistentDisks = -{ -new AppCustomPersistentDisk("myASCStorageID") -{ -CustomPersistentDiskProperties = new AppPlatformAzureFileVolume("/mypath1/mypath2","myFileShare") -{ -MountOptions = -{ -"uid=0","gid=0","dir_mode=0777","file_mode=0777" -}, -}, -} -}, - IsEndToEndTlsEnabled = false, - LoadedCertificates = -{ -new AppLoadedCertificate(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/certificates/mycert1")) -{ -LoadTrustStore = false, -},new AppLoadedCertificate(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/certificates/mycert2")) -{ -LoadTrustStore = true, -} -}, - VnetAddons = new AppVnetAddons() - { - IsPublicEndpoint = true, - }, - }, - Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity(), -}, - }, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, appName, data); - AppPlatformAppResource result = lro.Value; + bool result = await collection.ExistsAsync(appName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformAppData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AppsList() + public async Task GetIfExists_AppsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_List.json - // this example is just showing the usage of "Apps_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_Get.json + // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -451,25 +420,31 @@ public async Task GetAll_AppsList() // get the collection of this AppPlatformAppResource AppPlatformAppCollection collection = appPlatformService.GetAppPlatformApps(); - // invoke the operation and iterate over the result - await foreach (AppPlatformAppResource item in collection.GetAllAsync()) + // invoke the operation + string appName = "myapp"; + NullableResponse response = await collection.GetIfExistsAsync(appName); + AppPlatformAppResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformAppData resourceData = item.Data; + AppPlatformAppData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AppsListVNetInjection() + public async Task GetIfExists_AppsGetVNetInjection() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_List_VNetInjection.json - // this example is just showing the usage of "Apps_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Apps_Get_VNetInjection.json + // this example is just showing the usage of "Apps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -487,17 +462,23 @@ public async Task GetAll_AppsListVNetInjection() // get the collection of this AppPlatformAppResource AppPlatformAppCollection collection = appPlatformService.GetAppPlatformApps(); - // invoke the operation and iterate over the result - await foreach (AppPlatformAppResource item in collection.GetAllAsync()) + // invoke the operation + string appName = "myapp"; + NullableResponse response = await collection.GetIfExistsAsync(appName); + AppPlatformAppResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformAppData resourceData = item.Data; + AppPlatformAppData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformAppResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformAppResource.cs index 56c2b24336d71..962ef07d01535 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformAppResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformAppResource.cs @@ -128,34 +128,29 @@ public async Task Update_AppsUpdate() AppPlatformAppResource appPlatformApp = client.GetAppPlatformAppResource(appPlatformAppResourceId); // invoke the operation - AppPlatformAppData data = new AppPlatformAppData() + AppPlatformAppData data = new AppPlatformAppData { - Properties = new AppPlatformAppProperties() + Properties = new AppPlatformAppProperties { IsPublic = true, IsHttpsOnly = false, - TemporaryDisk = new AppTemporaryDisk() + TemporaryDisk = new AppTemporaryDisk { SizeInGB = 2, MountPath = "/mytemporarydisk", }, - PersistentDisk = new AppPersistentDisk() + PersistentDisk = new AppPersistentDisk { SizeInGB = 2, MountPath = "/mypersistentdisk", }, - CustomPersistentDisks = + CustomPersistentDisks = {new AppCustomPersistentDisk("myASCStorageID") { -new AppCustomPersistentDisk("myASCStorageID") +CustomPersistentDiskProperties = new AppPlatformAzureFileVolume("/mypath1/mypath2", "myFileShare") { -CustomPersistentDiskProperties = new AppPlatformAzureFileVolume("/mypath1/mypath2","myFileShare") -{ -MountOptions = -{ -}, -}, -} +MountOptions = {}, }, +}}, IsEndToEndTlsEnabled = false, }, Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") @@ -163,7 +158,7 @@ public async Task Update_AppsUpdate() UserAssignedIdentities = { [new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity() }, }, Location = new AzureLocation("eastus"), @@ -200,36 +195,31 @@ public async Task Update_AppsUpdateVNetInjection() AppPlatformAppResource appPlatformApp = client.GetAppPlatformAppResource(appPlatformAppResourceId); // invoke the operation - AppPlatformAppData data = new AppPlatformAppData() + AppPlatformAppData data = new AppPlatformAppData { - Properties = new AppPlatformAppProperties() + Properties = new AppPlatformAppProperties { IsPublic = true, IsHttpsOnly = false, - TemporaryDisk = new AppTemporaryDisk() + TemporaryDisk = new AppTemporaryDisk { SizeInGB = 2, MountPath = "/mytemporarydisk", }, - PersistentDisk = new AppPersistentDisk() + PersistentDisk = new AppPersistentDisk { SizeInGB = 2, MountPath = "/mypersistentdisk", }, - CustomPersistentDisks = -{ -new AppCustomPersistentDisk("myASCStorageID") + CustomPersistentDisks = {new AppCustomPersistentDisk("myASCStorageID") { -CustomPersistentDiskProperties = new AppPlatformAzureFileVolume("/mypath1/mypath2","myFileShare") +CustomPersistentDiskProperties = new AppPlatformAzureFileVolume("/mypath1/mypath2", "myFileShare") { -MountOptions = -{ -}, -}, -} +MountOptions = {}, }, +}}, IsEndToEndTlsEnabled = false, - VnetAddons = new AppVnetAddons() + VnetAddons = new AppVnetAddons { IsPublicEndpoint = true, }, @@ -239,7 +229,7 @@ public async Task Update_AppsUpdateVNetInjection() UserAssignedIdentities = { [new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/samplegroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity() }, }, Location = new AzureLocation("eastus"), @@ -303,12 +293,9 @@ public async Task ActivateDeployments_AppsSetActiveDeployments() AppPlatformAppResource appPlatformApp = client.GetAppPlatformAppResource(appPlatformAppResourceId); // invoke the operation - ActiveAppPlatformDeploymentsContent content = new ActiveAppPlatformDeploymentsContent() + ActiveAppPlatformDeploymentsContent content = new ActiveAppPlatformDeploymentsContent { - ActiveDeploymentNames = -{ -"default" -}, + ActiveDeploymentNames = { "default" }, }; ArmOperation lro = await appPlatformApp.ActivateDeploymentsAsync(WaitUntil.Completed, content); AppPlatformAppResource result = lro.Value; diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBindingCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBindingCollection.cs index c1308b3788b9e..5b1fbb8a1e36b 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBindingCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBindingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformBindingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BindingsGet() + public async Task CreateOrUpdate_BindingsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Bindings_Get.json - // this example is just showing the usage of "Bindings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Bindings_CreateOrUpdate.json + // this example is just showing the usage of "Bindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,21 @@ public async Task Get_BindingsGet() // invoke the operation string bindingName = "mybinding"; - AppPlatformBindingResource result = await collection.GetAsync(bindingName); + AppPlatformBindingData data = new AppPlatformBindingData + { + Properties = new AppPlatformBindingProperties + { + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DocumentDB/databaseAccounts/my-cosmosdb-1"), + Key = "xxxx", + BindingParameters = +{ +["apiType"] = BinaryData.FromObjectAsJson("SQL"), +["databaseName"] = BinaryData.FromObjectAsJson("db1") +}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bindingName, data); + AppPlatformBindingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +67,7 @@ public async Task Get_BindingsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BindingsGet() + public async Task Get_BindingsGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Bindings_Get.json // this example is just showing the usage of "Bindings_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +91,21 @@ public async Task Exists_BindingsGet() // invoke the operation string bindingName = "mybinding"; - bool result = await collection.ExistsAsync(bindingName); + AppPlatformBindingResource result = await collection.GetAsync(bindingName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BindingsGet() + public async Task GetAll_BindingsList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Bindings_Get.json - // this example is just showing the usage of "Bindings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Bindings_List.json + // this example is just showing the usage of "Bindings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +124,25 @@ public async Task GetIfExists_BindingsGet() // get the collection of this AppPlatformBindingResource AppPlatformBindingCollection collection = appPlatformApp.GetAppPlatformBindings(); - // invoke the operation - string bindingName = "mybinding"; - NullableResponse response = await collection.GetIfExistsAsync(bindingName); - AppPlatformBindingResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformBindingResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformBindingData resourceData = result.Data; + AppPlatformBindingData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BindingsCreateOrUpdate() + public async Task Exists_BindingsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Bindings_CreateOrUpdate.json - // this example is just showing the usage of "Bindings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Bindings_Get.json + // this example is just showing the usage of "Bindings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,35 +163,17 @@ public async Task CreateOrUpdate_BindingsCreateOrUpdate() // invoke the operation string bindingName = "mybinding"; - AppPlatformBindingData data = new AppPlatformBindingData() - { - Properties = new AppPlatformBindingProperties() - { - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.DocumentDB/databaseAccounts/my-cosmosdb-1"), - Key = "xxxx", - BindingParameters = -{ -["apiType"] = BinaryData.FromString("\"SQL\""), -["databaseName"] = BinaryData.FromString("\"db1\""), -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bindingName, data); - AppPlatformBindingResource result = lro.Value; + bool result = await collection.ExistsAsync(bindingName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBindingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BindingsList() + public async Task GetIfExists_BindingsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Bindings_List.json - // this example is just showing the usage of "Bindings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Bindings_Get.json + // this example is just showing the usage of "Bindings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,17 +192,23 @@ public async Task GetAll_BindingsList() // get the collection of this AppPlatformBindingResource AppPlatformBindingCollection collection = appPlatformApp.GetAppPlatformBindings(); - // invoke the operation and iterate over the result - await foreach (AppPlatformBindingResource item in collection.GetAllAsync()) + // invoke the operation + string bindingName = "mybinding"; + NullableResponse response = await collection.GetIfExistsAsync(bindingName); + AppPlatformBindingResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformBindingData resourceData = item.Data; + AppPlatformBindingData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBindingResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBindingResource.cs index d9b94583dbfa1..1d12dac3423dc 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBindingResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBindingResource.cs @@ -99,15 +99,15 @@ public async Task Update_BindingsUpdate() AppPlatformBindingResource appPlatformBinding = client.GetAppPlatformBindingResource(appPlatformBindingResourceId); // invoke the operation - AppPlatformBindingData data = new AppPlatformBindingData() + AppPlatformBindingData data = new AppPlatformBindingData { - Properties = new AppPlatformBindingProperties() + Properties = new AppPlatformBindingProperties { Key = "xxxx", BindingParameters = { -["apiType"] = BinaryData.FromString("\"SQL\""), -["databaseName"] = BinaryData.FromString("\"db1\""), +["apiType"] = BinaryData.FromObjectAsJson("SQL"), +["databaseName"] = BinaryData.FromObjectAsJson("db1") }, }, }; diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildCollection.cs index 02a22c0a526a3..b6e84aab0277e 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformBuildCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BuildServiceListBuilds() + public async Task CreateOrUpdate_BuildServiceCreateOrUpdateBuild() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_ListBuilds.json - // this example is just showing the usage of "BuildService_ListBuilds" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_CreateOrUpdateBuild.json + // this example is just showing the usage of "BuildService_CreateOrUpdateBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,34 @@ public async Task GetAll_BuildServiceListBuilds() // get the collection of this AppPlatformBuildResource AppPlatformBuildCollection collection = appPlatformBuildService.GetAppPlatformBuilds(); - // invoke the operation and iterate over the result - await foreach (AppPlatformBuildResource item in collection.GetAllAsync()) + // invoke the operation + string buildName = "mybuild"; + AppPlatformBuildData data = new AppPlatformBuildData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AppPlatformBuildProperties + { + RelativePath = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855-20210601-3ed9f4a2-986b-4bbd-b833-a42dccb2f777", + Builder = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/buildServices/default/builders/default", + AgentPool = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/buildServices/default/agentPools/default", + Env = +{ +["environmentVariable"] = "test" +}, + ResourceRequests = new AppPlatformBuildResourceRequirements + { + Cpu = "1", + Memory = "2Gi", + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, buildName, data); + AppPlatformBuildResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +107,10 @@ public async Task Get_BuildServiceGetBuild() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BuildServiceGetBuild() + public async Task GetAll_BuildServiceListBuilds() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetBuild.json - // this example is just showing the usage of "BuildService_GetBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_ListBuilds.json + // this example is just showing the usage of "BuildService_ListBuilds" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +129,22 @@ public async Task Exists_BuildServiceGetBuild() // get the collection of this AppPlatformBuildResource AppPlatformBuildCollection collection = appPlatformBuildService.GetAppPlatformBuilds(); - // invoke the operation - string buildName = "mybuild"; - bool result = await collection.ExistsAsync(buildName); + // invoke the operation and iterate over the result + await foreach (AppPlatformBuildResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BuildServiceGetBuild() + public async Task Exists_BuildServiceGetBuild() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetBuild.json // this example is just showing the usage of "BuildService_GetBuild" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +168,17 @@ public async Task GetIfExists_BuildServiceGetBuild() // invoke the operation string buildName = "mybuild"; - NullableResponse response = await collection.GetIfExistsAsync(buildName); - AppPlatformBuildResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(buildName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BuildServiceCreateOrUpdateBuild() + public async Task GetIfExists_BuildServiceGetBuild() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_CreateOrUpdateBuild.json - // this example is just showing the usage of "BuildService_CreateOrUpdateBuild" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetBuild.json + // this example is just showing the usage of "BuildService_GetBuild" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,32 +199,21 @@ public async Task CreateOrUpdate_BuildServiceCreateOrUpdateBuild() // invoke the operation string buildName = "mybuild"; - AppPlatformBuildData data = new AppPlatformBuildData() - { - Properties = new AppPlatformBuildProperties() - { - RelativePath = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855-20210601-3ed9f4a2-986b-4bbd-b833-a42dccb2f777", - Builder = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/buildServices/default/builders/default", - AgentPool = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/buildServices/default/agentPools/default", - Env = -{ -["environmentVariable"] = "test", -}, - ResourceRequests = new AppPlatformBuildResourceRequirements() - { - Cpu = "1", - Memory = "2Gi", - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, buildName, data); - AppPlatformBuildResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(buildName); + AppPlatformBuildResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildResource.cs index 306f26828c40d..341b571cd210c 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildResource.cs @@ -71,18 +71,18 @@ public async Task Update_BuildServiceCreateOrUpdateBuild() AppPlatformBuildResource appPlatformBuild = client.GetAppPlatformBuildResource(appPlatformBuildResourceId); // invoke the operation - AppPlatformBuildData data = new AppPlatformBuildData() + AppPlatformBuildData data = new AppPlatformBuildData { - Properties = new AppPlatformBuildProperties() + Properties = new AppPlatformBuildProperties { RelativePath = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855-20210601-3ed9f4a2-986b-4bbd-b833-a42dccb2f777", Builder = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/buildServices/default/builders/default", AgentPool = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/buildServices/default/agentPools/default", Env = { -["environmentVariable"] = "test", +["environmentVariable"] = "test" }, - ResourceRequests = new AppPlatformBuildResourceRequirements() + ResourceRequests = new AppPlatformBuildResourceRequirements { Cpu = "1", Memory = "2Gi", diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildResultCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildResultCollection.cs index f415f18da1f7a..a1ddac846a8c8 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildResultCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildResultCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppPlatformBuildResultCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BuildServiceListBuildResults() + public async Task Get_BuildServiceGetBuildResult() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_ListBuildResults.json - // this example is just showing the usage of "BuildService_ListBuildResults" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetBuildResult.json + // this example is just showing the usage of "BuildService_GetBuildResult" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_BuildServiceListBuildResults() // get the collection of this AppPlatformBuildResultResource AppPlatformBuildResultCollection collection = appPlatformBuild.GetAppPlatformBuildResults(); - // invoke the operation and iterate over the result - await foreach (AppPlatformBuildResultResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildResultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string buildResultName = "123"; + AppPlatformBuildResultResource result = await collection.GetAsync(buildResultName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildResultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BuildServiceGetBuildResult() + public async Task GetAll_BuildServiceListBuildResults() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetBuildResult.json - // this example is just showing the usage of "BuildService_GetBuildResult" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_ListBuildResults.json + // this example is just showing the usage of "BuildService_ListBuildResults" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_BuildServiceGetBuildResult() // get the collection of this AppPlatformBuildResultResource AppPlatformBuildResultCollection collection = appPlatformBuild.GetAppPlatformBuildResults(); - // invoke the operation - string buildResultName = "123"; - AppPlatformBuildResultResource result = await collection.GetAsync(buildResultName); + // invoke the operation and iterate over the result + await foreach (AppPlatformBuildResultResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildResultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildResultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceAgentPoolCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceAgentPoolCollection.cs index c9b4f166e880e..6e09ca1aea045 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceAgentPoolCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceAgentPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformBuildServiceAgentPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BuildServiceAgentPoolList() + public async Task CreateOrUpdate_BuildServiceAgentPoolUpdatePut() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceAgentPool_List.json - // this example is just showing the usage of "BuildServiceAgentPool_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceAgentPool_UpdatePut.json + // this example is just showing the usage of "BuildServiceAgentPool_UpdatePut" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,26 @@ public async Task GetAll_BuildServiceAgentPoolList() // get the collection of this AppPlatformBuildServiceAgentPoolResource AppPlatformBuildServiceAgentPoolCollection collection = appPlatformBuildService.GetAppPlatformBuildServiceAgentPools(); - // invoke the operation and iterate over the result - await foreach (AppPlatformBuildServiceAgentPoolResource item in collection.GetAllAsync()) + // invoke the operation + string agentPoolName = "default"; + AppPlatformBuildServiceAgentPoolData data = new AppPlatformBuildServiceAgentPoolData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildServiceAgentPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AppPlatformBuildServiceAgentPoolProperties + { + PoolSize = new BuildServiceAgentPoolSizeProperties + { + Name = "S3", + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); + AppPlatformBuildServiceAgentPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +99,10 @@ public async Task Get_BuildServiceAgentPoolGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BuildServiceAgentPoolGet() + public async Task GetAll_BuildServiceAgentPoolList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceAgentPool_Get.json - // this example is just showing the usage of "BuildServiceAgentPool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceAgentPool_List.json + // this example is just showing the usage of "BuildServiceAgentPool_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +121,22 @@ public async Task Exists_BuildServiceAgentPoolGet() // get the collection of this AppPlatformBuildServiceAgentPoolResource AppPlatformBuildServiceAgentPoolCollection collection = appPlatformBuildService.GetAppPlatformBuildServiceAgentPools(); - // invoke the operation - string agentPoolName = "default"; - bool result = await collection.ExistsAsync(agentPoolName); + // invoke the operation and iterate over the result + await foreach (AppPlatformBuildServiceAgentPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildServiceAgentPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BuildServiceAgentPoolGet() + public async Task Exists_BuildServiceAgentPoolGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceAgentPool_Get.json // this example is just showing the usage of "BuildServiceAgentPool_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +160,17 @@ public async Task GetIfExists_BuildServiceAgentPoolGet() // invoke the operation string agentPoolName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); - AppPlatformBuildServiceAgentPoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(agentPoolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildServiceAgentPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BuildServiceAgentPoolUpdatePut() + public async Task GetIfExists_BuildServiceAgentPoolGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceAgentPool_UpdatePut.json - // this example is just showing the usage of "BuildServiceAgentPool_UpdatePut" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceAgentPool_Get.json + // this example is just showing the usage of "BuildServiceAgentPool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,24 +191,21 @@ public async Task CreateOrUpdate_BuildServiceAgentPoolUpdatePut() // invoke the operation string agentPoolName = "default"; - AppPlatformBuildServiceAgentPoolData data = new AppPlatformBuildServiceAgentPoolData() - { - Properties = new AppPlatformBuildServiceAgentPoolProperties() - { - PoolSize = new BuildServiceAgentPoolSizeProperties() - { - Name = "S3", - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agentPoolName, data); - AppPlatformBuildServiceAgentPoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(agentPoolName); + AppPlatformBuildServiceAgentPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildServiceAgentPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildServiceAgentPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceAgentPoolResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceAgentPoolResource.cs index 74fa7b66e3ce6..4a3e6f4c4a342 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceAgentPoolResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceAgentPoolResource.cs @@ -71,11 +71,11 @@ public async Task Update_BuildServiceAgentPoolUpdatePut() AppPlatformBuildServiceAgentPoolResource appPlatformBuildServiceAgentPool = client.GetAppPlatformBuildServiceAgentPoolResource(appPlatformBuildServiceAgentPoolResourceId); // invoke the operation - AppPlatformBuildServiceAgentPoolData data = new AppPlatformBuildServiceAgentPoolData() + AppPlatformBuildServiceAgentPoolData data = new AppPlatformBuildServiceAgentPoolData { - Properties = new AppPlatformBuildServiceAgentPoolProperties() + Properties = new AppPlatformBuildServiceAgentPoolProperties { - PoolSize = new BuildServiceAgentPoolSizeProperties() + PoolSize = new BuildServiceAgentPoolSizeProperties { Name = "S3", }, diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceCollection.cs index ce4b20ef06dae..e5291a23e7d2d 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildServiceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppPlatformBuildServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BuildServiceListBuildServices() + public async Task Get_BuildServiceGetBuildService() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_ListBuildServices.json - // this example is just showing the usage of "BuildService_ListBuildServices" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetBuildService.json + // this example is just showing the usage of "BuildService_GetBuildService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_BuildServiceListBuildServices() // get the collection of this AppPlatformBuildServiceResource AppPlatformBuildServiceCollection collection = appPlatformService.GetAppPlatformBuildServices(); - // invoke the operation and iterate over the result - await foreach (AppPlatformBuildServiceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string buildServiceName = "default"; + AppPlatformBuildServiceResource result = await collection.GetAsync(buildServiceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BuildServiceGetBuildService() + public async Task GetAll_BuildServiceListBuildServices() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetBuildService.json - // this example is just showing the usage of "BuildService_GetBuildService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_ListBuildServices.json + // this example is just showing the usage of "BuildService_ListBuildServices" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_BuildServiceGetBuildService() // get the collection of this AppPlatformBuildServiceResource AppPlatformBuildServiceCollection collection = appPlatformService.GetAppPlatformBuildServices(); - // invoke the operation - string buildServiceName = "default"; - AppPlatformBuildServiceResource result = await collection.GetAsync(buildServiceName); + // invoke the operation and iterate over the result + await foreach (AppPlatformBuildServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuilderCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuilderCollection.cs index 58e0ac199c607..d3db13caa3481 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuilderCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuilderCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AppPlatformBuilderCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BuildServiceBuilderGet() + public async Task CreateOrUpdate_BuildServiceBuilderCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_Get.json - // this example is just showing the usage of "BuildServiceBuilder_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_CreateOrUpdate.json + // this example is just showing the usage of "BuildServiceBuilder_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,7 +43,27 @@ public async Task Get_BuildServiceBuilderGet() // invoke the operation string builderName = "mybuilder"; - AppPlatformBuilderResource result = await collection.GetAsync(builderName); + AppPlatformBuilderData data = new AppPlatformBuilderData + { + Properties = new AppPlatformBuilderProperties + { + Stack = new AppPlatformClusterStackProperties + { + Id = "io.buildpacks.stacks.bionic", + Version = "base", + }, + BuildpackGroups = {new BuildpacksGroupProperties +{ +Name = "mix", +Buildpacks = {new WritableSubResource +{ +Id = new ResourceIdentifier("tanzu-buildpacks/java-azure"), +}}, +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, builderName, data); + AppPlatformBuilderResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,7 +74,7 @@ public async Task Get_BuildServiceBuilderGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BuildServiceBuilderGet() + public async Task Get_BuildServiceBuilderGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_Get.json // this example is just showing the usage of "BuildServiceBuilder_Get" operation, for the dependent resources, they will have to be created separately. @@ -78,17 +98,21 @@ public async Task Exists_BuildServiceBuilderGet() // invoke the operation string builderName = "mybuilder"; - bool result = await collection.ExistsAsync(builderName); + AppPlatformBuilderResource result = await collection.GetAsync(builderName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuilderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BuildServiceBuilderGet() + public async Task GetAll_BuildServiceBuilderList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_Get.json - // this example is just showing the usage of "BuildServiceBuilder_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_List.json + // this example is just showing the usage of "BuildServiceBuilder_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,31 +131,25 @@ public async Task GetIfExists_BuildServiceBuilderGet() // get the collection of this AppPlatformBuilderResource AppPlatformBuilderCollection collection = appPlatformBuildService.GetAppPlatformBuilders(); - // invoke the operation - string builderName = "mybuilder"; - NullableResponse response = await collection.GetIfExistsAsync(builderName); - AppPlatformBuilderResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformBuilderResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformBuilderData resourceData = result.Data; + AppPlatformBuilderData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BuildServiceBuilderCreateOrUpdate() + public async Task Exists_BuildServiceBuilderGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_CreateOrUpdate.json - // this example is just showing the usage of "BuildServiceBuilder_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_Get.json + // this example is just showing the usage of "BuildServiceBuilder_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -152,47 +170,17 @@ public async Task CreateOrUpdate_BuildServiceBuilderCreateOrUpdate() // invoke the operation string builderName = "mybuilder"; - AppPlatformBuilderData data = new AppPlatformBuilderData() - { - Properties = new AppPlatformBuilderProperties() - { - Stack = new AppPlatformClusterStackProperties() - { - Id = "io.buildpacks.stacks.bionic", - Version = "base", - }, - BuildpackGroups = -{ -new BuildpacksGroupProperties() -{ -Name = "mix", -Buildpacks = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("tanzu-buildpacks/java-azure"), -} -}, -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, builderName, data); - AppPlatformBuilderResource result = lro.Value; + bool result = await collection.ExistsAsync(builderName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuilderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BuildServiceBuilderList() + public async Task GetIfExists_BuildServiceBuilderGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_List.json - // this example is just showing the usage of "BuildServiceBuilder_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_Get.json + // this example is just showing the usage of "BuildServiceBuilder_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -211,17 +199,23 @@ public async Task GetAll_BuildServiceBuilderList() // get the collection of this AppPlatformBuilderResource AppPlatformBuilderCollection collection = appPlatformBuildService.GetAppPlatformBuilders(); - // invoke the operation and iterate over the result - await foreach (AppPlatformBuilderResource item in collection.GetAllAsync()) + // invoke the operation + string builderName = "mybuilder"; + NullableResponse response = await collection.GetIfExistsAsync(builderName); + AppPlatformBuilderResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformBuilderData resourceData = item.Data; + AppPlatformBuilderData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuilderResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuilderResource.cs index 6aacb4c5c481d..542c151387123 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuilderResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuilderResource.cs @@ -51,10 +51,10 @@ public async Task Get_BuildServiceBuilderGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BuildServiceBuilderCreateOrUpdate() + public async Task Delete_BuildServiceBuilderDelete() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_CreateOrUpdate.json - // this example is just showing the usage of "BuildServiceBuilder_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_Delete.json + // this example is just showing the usage of "BuildServiceBuilder_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,47 +72,17 @@ public async Task Update_BuildServiceBuilderCreateOrUpdate() AppPlatformBuilderResource appPlatformBuilder = client.GetAppPlatformBuilderResource(appPlatformBuilderResourceId); // invoke the operation - AppPlatformBuilderData data = new AppPlatformBuilderData() - { - Properties = new AppPlatformBuilderProperties() - { - Stack = new AppPlatformClusterStackProperties() - { - Id = "io.buildpacks.stacks.bionic", - Version = "base", - }, - BuildpackGroups = -{ -new BuildpacksGroupProperties() -{ -Name = "mix", -Buildpacks = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("tanzu-buildpacks/java-azure"), -} -}, -} -}, - }, - }; - ArmOperation lro = await appPlatformBuilder.UpdateAsync(WaitUntil.Completed, data); - AppPlatformBuilderResource result = lro.Value; + await appPlatformBuilder.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuilderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BuildServiceBuilderDelete() + public async Task Update_BuildServiceBuilderCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_Delete.json - // this example is just showing the usage of "BuildServiceBuilder_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildServiceBuilder_CreateOrUpdate.json + // this example is just showing the usage of "BuildServiceBuilder_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,9 +100,33 @@ public async Task Delete_BuildServiceBuilderDelete() AppPlatformBuilderResource appPlatformBuilder = client.GetAppPlatformBuilderResource(appPlatformBuilderResourceId); // invoke the operation - await appPlatformBuilder.DeleteAsync(WaitUntil.Completed); + AppPlatformBuilderData data = new AppPlatformBuilderData + { + Properties = new AppPlatformBuilderProperties + { + Stack = new AppPlatformClusterStackProperties + { + Id = "io.buildpacks.stacks.bionic", + Version = "base", + }, + BuildpackGroups = {new BuildpacksGroupProperties +{ +Name = "mix", +Buildpacks = {new WritableSubResource +{ +Id = new ResourceIdentifier("tanzu-buildpacks/java-azure"), +}}, +}}, + }, + }; + ArmOperation lro = await appPlatformBuilder.UpdateAsync(WaitUntil.Completed, data); + AppPlatformBuilderResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuilderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildpackBindingCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildpackBindingCollection.cs index afdb0f29a782a..759c04a18068d 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildpackBindingCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildpackBindingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformBuildpackBindingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BuildpackBindingGet() + public async Task CreateOrUpdate_BuildpackBindingCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_Get.json - // this example is just showing the usage of "BuildpackBinding_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_CreateOrUpdate.json + // this example is just showing the usage of "BuildpackBinding_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,7 +43,28 @@ public async Task Get_BuildpackBindingGet() // invoke the operation string buildpackBindingName = "myBuildpackBinding"; - AppPlatformBuildpackBindingResource result = await collection.GetAsync(buildpackBindingName); + AppPlatformBuildpackBindingData data = new AppPlatformBuildpackBindingData + { + Properties = new AppPlatformBuildpackBindingProperties + { + BindingType = BuildpackBindingType.ApplicationInsights, + LaunchProperties = new BuildpackBindingLaunchProperties + { + Properties = +{ +["abc"] = "def", +["any-string"] = "any-string", +["sampling-rate"] = "12.0" +}, + Secrets = +{ +["connection-string"] = "XXXXXXXXXXXXXXXXX=XXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXX;XXXXXXXXXXXXXXXXX=XXXXXXXXXXXXXXXXXXX" +}, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, buildpackBindingName, data); + AppPlatformBuildpackBindingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,7 +75,7 @@ public async Task Get_BuildpackBindingGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BuildpackBindingGet() + public async Task Get_BuildpackBindingGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_Get.json // this example is just showing the usage of "BuildpackBinding_Get" operation, for the dependent resources, they will have to be created separately. @@ -79,17 +100,21 @@ public async Task Exists_BuildpackBindingGet() // invoke the operation string buildpackBindingName = "myBuildpackBinding"; - bool result = await collection.ExistsAsync(buildpackBindingName); + AppPlatformBuildpackBindingResource result = await collection.GetAsync(buildpackBindingName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformBuildpackBindingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BuildpackBindingGet() + public async Task GetAll_BuildpackBindingGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_Get.json - // this example is just showing the usage of "BuildpackBinding_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_List.json + // this example is just showing the usage of "BuildpackBinding_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,31 +134,25 @@ public async Task GetIfExists_BuildpackBindingGet() // get the collection of this AppPlatformBuildpackBindingResource AppPlatformBuildpackBindingCollection collection = appPlatformBuilder.GetAppPlatformBuildpackBindings(); - // invoke the operation - string buildpackBindingName = "myBuildpackBinding"; - NullableResponse response = await collection.GetIfExistsAsync(buildpackBindingName); - AppPlatformBuildpackBindingResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformBuildpackBindingResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformBuildpackBindingData resourceData = result.Data; + AppPlatformBuildpackBindingData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BuildpackBindingCreateOrUpdate() + public async Task Exists_BuildpackBindingGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_CreateOrUpdate.json - // this example is just showing the usage of "BuildpackBinding_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_Get.json + // this example is just showing the usage of "BuildpackBinding_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -155,42 +174,17 @@ public async Task CreateOrUpdate_BuildpackBindingCreateOrUpdate() // invoke the operation string buildpackBindingName = "myBuildpackBinding"; - AppPlatformBuildpackBindingData data = new AppPlatformBuildpackBindingData() - { - Properties = new AppPlatformBuildpackBindingProperties() - { - BindingType = BuildpackBindingType.ApplicationInsights, - LaunchProperties = new BuildpackBindingLaunchProperties() - { - Properties = -{ -["abc"] = "def", -["any-string"] = "any-string", -["sampling-rate"] = "12.0", -}, - Secrets = -{ -["connection-string"] = "XXXXXXXXXXXXXXXXX=XXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXX;XXXXXXXXXXXXXXXXX=XXXXXXXXXXXXXXXXXXX", -}, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, buildpackBindingName, data); - AppPlatformBuildpackBindingResource result = lro.Value; + bool result = await collection.ExistsAsync(buildpackBindingName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformBuildpackBindingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BuildpackBindingGet() + public async Task GetIfExists_BuildpackBindingGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_List.json - // this example is just showing the usage of "BuildpackBinding_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_Get.json + // this example is just showing the usage of "BuildpackBinding_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -210,17 +204,23 @@ public async Task GetAll_BuildpackBindingGet() // get the collection of this AppPlatformBuildpackBindingResource AppPlatformBuildpackBindingCollection collection = appPlatformBuilder.GetAppPlatformBuildpackBindings(); - // invoke the operation and iterate over the result - await foreach (AppPlatformBuildpackBindingResource item in collection.GetAllAsync()) + // invoke the operation + string buildpackBindingName = "myBuildpackBinding"; + NullableResponse response = await collection.GetIfExistsAsync(buildpackBindingName); + AppPlatformBuildpackBindingResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformBuildpackBindingData resourceData = item.Data; + AppPlatformBuildpackBindingData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildpackBindingResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildpackBindingResource.cs index e1faf86bb0443..c4fd0ce04b630 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildpackBindingResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformBuildpackBindingResource.cs @@ -49,6 +49,35 @@ public async Task Get_BuildpackBindingGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_BuildpackBindingDelete() + { + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_Delete.json + // this example is just showing the usage of "BuildpackBinding_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AppPlatformBuildpackBindingResource created on azure + // for more information of creating AppPlatformBuildpackBindingResource, please refer to the document of AppPlatformBuildpackBindingResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + string serviceName = "myservice"; + string buildServiceName = "default"; + string builderName = "default"; + string buildpackBindingName = "myBuildpackBinding"; + ResourceIdentifier appPlatformBuildpackBindingResourceId = AppPlatformBuildpackBindingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, buildServiceName, builderName, buildpackBindingName); + AppPlatformBuildpackBindingResource appPlatformBuildpackBinding = client.GetAppPlatformBuildpackBindingResource(appPlatformBuildpackBindingResourceId); + + // invoke the operation + await appPlatformBuildpackBinding.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_BuildpackBindingCreateOrUpdate() @@ -73,22 +102,22 @@ public async Task Update_BuildpackBindingCreateOrUpdate() AppPlatformBuildpackBindingResource appPlatformBuildpackBinding = client.GetAppPlatformBuildpackBindingResource(appPlatformBuildpackBindingResourceId); // invoke the operation - AppPlatformBuildpackBindingData data = new AppPlatformBuildpackBindingData() + AppPlatformBuildpackBindingData data = new AppPlatformBuildpackBindingData { - Properties = new AppPlatformBuildpackBindingProperties() + Properties = new AppPlatformBuildpackBindingProperties { BindingType = BuildpackBindingType.ApplicationInsights, - LaunchProperties = new BuildpackBindingLaunchProperties() + LaunchProperties = new BuildpackBindingLaunchProperties { Properties = { ["abc"] = "def", ["any-string"] = "any-string", -["sampling-rate"] = "12.0", +["sampling-rate"] = "12.0" }, Secrets = { -["connection-string"] = "XXXXXXXXXXXXXXXXX=XXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXX;XXXXXXXXXXXXXXXXX=XXXXXXXXXXXXXXXXXXX", +["connection-string"] = "XXXXXXXXXXXXXXXXX=XXXXXXXXXXXXX-XXXXXXXXXXXXXXXXXXX;XXXXXXXXXXXXXXXXX=XXXXXXXXXXXXXXXXXXX" }, }, }, @@ -102,34 +131,5 @@ public async Task Update_BuildpackBindingCreateOrUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_BuildpackBindingDelete() - { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildpackBinding_Delete.json - // this example is just showing the usage of "BuildpackBinding_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AppPlatformBuildpackBindingResource created on azure - // for more information of creating AppPlatformBuildpackBindingResource, please refer to the document of AppPlatformBuildpackBindingResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - string serviceName = "myservice"; - string buildServiceName = "default"; - string builderName = "default"; - string buildpackBindingName = "myBuildpackBinding"; - ResourceIdentifier appPlatformBuildpackBindingResourceId = AppPlatformBuildpackBindingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, buildServiceName, builderName, buildpackBindingName); - AppPlatformBuildpackBindingResource appPlatformBuildpackBinding = client.GetAppPlatformBuildpackBindingResource(appPlatformBuildpackBindingResourceId); - - // invoke the operation - await appPlatformBuildpackBinding.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCertificateCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCertificateCollection.cs index d631495c0c512..95d69046ad5d6 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCertificateCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCertificateCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CertificatesGet() + public async Task CreateOrUpdate_CertificatesCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_Get.json - // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_CreateOrUpdate.json + // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_CertificatesGet() // invoke the operation string certificateName = "mycertificate"; - AppPlatformCertificateResource result = await collection.GetAsync(certificateName); + AppPlatformCertificateData data = new AppPlatformCertificateData + { + Properties = new AppPlatformKeyVaultCertificateProperties(new Uri("https://myvault.vault.azure.net"), "mycert") + { + CertVersion = "08a219d06d874795a96db47e06fbb01e", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); + AppPlatformCertificateResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_CertificatesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CertificatesGet() + public async Task Get_CertificatesGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_Get.json // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +83,21 @@ public async Task Exists_CertificatesGet() // invoke the operation string certificateName = "mycertificate"; - bool result = await collection.ExistsAsync(certificateName); + AppPlatformCertificateResource result = await collection.GetAsync(certificateName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CertificatesGet() + public async Task GetAll_CertificatesList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_Get.json - // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_List.json + // this example is just showing the usage of "Certificates_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,38 +108,32 @@ public async Task GetIfExists_CertificatesGet() // for more information of creating AppPlatformServiceResource, please refer to the document of AppPlatformServiceResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "myResourceGroup"; - string serviceName = "myservice"; + string serviceName = "myService"; ResourceIdentifier appPlatformServiceResourceId = AppPlatformServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); AppPlatformServiceResource appPlatformService = client.GetAppPlatformServiceResource(appPlatformServiceResourceId); // get the collection of this AppPlatformCertificateResource AppPlatformCertificateCollection collection = appPlatformService.GetAppPlatformCertificates(); - // invoke the operation - string certificateName = "mycertificate"; - NullableResponse response = await collection.GetIfExistsAsync(certificateName); - AppPlatformCertificateResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformCertificateResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformCertificateData resourceData = result.Data; + AppPlatformCertificateData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CertificatesCreateOrUpdate() + public async Task Exists_CertificatesGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_CreateOrUpdate.json - // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_Get.json + // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,29 +153,17 @@ public async Task CreateOrUpdate_CertificatesCreateOrUpdate() // invoke the operation string certificateName = "mycertificate"; - AppPlatformCertificateData data = new AppPlatformCertificateData() - { - Properties = new AppPlatformKeyVaultCertificateProperties(new Uri("https://myvault.vault.azure.net"), "mycert") - { - CertVersion = "08a219d06d874795a96db47e06fbb01e", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); - AppPlatformCertificateResource result = lro.Value; + bool result = await collection.ExistsAsync(certificateName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CertificatesList() + public async Task GetIfExists_CertificatesGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_List.json - // this example is just showing the usage of "Certificates_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_Get.json + // this example is just showing the usage of "Certificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,24 +174,30 @@ public async Task GetAll_CertificatesList() // for more information of creating AppPlatformServiceResource, please refer to the document of AppPlatformServiceResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "myResourceGroup"; - string serviceName = "myService"; + string serviceName = "myservice"; ResourceIdentifier appPlatformServiceResourceId = AppPlatformServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); AppPlatformServiceResource appPlatformService = client.GetAppPlatformServiceResource(appPlatformServiceResourceId); // get the collection of this AppPlatformCertificateResource AppPlatformCertificateCollection collection = appPlatformService.GetAppPlatformCertificates(); - // invoke the operation and iterate over the result - await foreach (AppPlatformCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string certificateName = "mycertificate"; + NullableResponse response = await collection.GetIfExistsAsync(certificateName); + AppPlatformCertificateResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformCertificateData resourceData = item.Data; + AppPlatformCertificateData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCertificateResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCertificateResource.cs index 67ebb5e3560cb..a722d43cf9455 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCertificateResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCertificateResource.cs @@ -49,10 +49,10 @@ public async Task Get_CertificatesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CertificatesCreateOrUpdate() + public async Task Delete_CertificatesDelete() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_CreateOrUpdate.json - // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_Delete.json + // this example is just showing the usage of "Certificates_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_CertificatesCreateOrUpdate() AppPlatformCertificateResource appPlatformCertificate = client.GetAppPlatformCertificateResource(appPlatformCertificateResourceId); // invoke the operation - AppPlatformCertificateData data = new AppPlatformCertificateData() - { - Properties = new AppPlatformKeyVaultCertificateProperties(new Uri("https://myvault.vault.azure.net"), "mycert") - { - CertVersion = "08a219d06d874795a96db47e06fbb01e", - }, - }; - ArmOperation lro = await appPlatformCertificate.UpdateAsync(WaitUntil.Completed, data); - AppPlatformCertificateResource result = lro.Value; + await appPlatformCertificate.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CertificatesDelete() + public async Task Update_CertificatesCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_Delete.json - // this example is just showing the usage of "Certificates_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Certificates_CreateOrUpdate.json + // this example is just showing the usage of "Certificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_CertificatesDelete() AppPlatformCertificateResource appPlatformCertificate = client.GetAppPlatformCertificateResource(appPlatformCertificateResourceId); // invoke the operation - await appPlatformCertificate.DeleteAsync(WaitUntil.Completed); + AppPlatformCertificateData data = new AppPlatformCertificateData + { + Properties = new AppPlatformKeyVaultCertificateProperties(new Uri("https://myvault.vault.azure.net"), "mycert") + { + CertVersion = "08a219d06d874795a96db47e06fbb01e", + }, + }; + ArmOperation lro = await appPlatformCertificate.UpdateAsync(WaitUntil.Completed, data); + AppPlatformCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigServerResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigServerResource.cs index a6759ca3ba612..f40c2c33992c8 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigServerResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigServerResource.cs @@ -48,10 +48,10 @@ public async Task Get_ConfigServersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConfigServersUpdatePut() + public async Task Update_ConfigServersUpdatePatch() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigServers_UpdatePut.json - // this example is just showing the usage of "ConfigServers_UpdatePut" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigServers_UpdatePatch.json + // this example is just showing the usage of "ConfigServers_UpdatePatch" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,21 +67,18 @@ public async Task CreateOrUpdate_ConfigServersUpdatePut() AppPlatformConfigServerResource appPlatformConfigServer = client.GetAppPlatformConfigServerResource(appPlatformConfigServerResourceId); // invoke the operation - AppPlatformConfigServerData data = new AppPlatformConfigServerData() + AppPlatformConfigServerData data = new AppPlatformConfigServerData { - Properties = new AppPlatformConfigServerProperties() + Properties = new AppPlatformConfigServerProperties { ConfigServerGitProperty = new AppPlatformConfigServerGitProperty(new Uri("https://github.com/fake-user/fake-repository.git")) { Label = "master", - SearchPaths = -{ -"/" -}, + SearchPaths = { "/" }, }, }, }; - ArmOperation lro = await appPlatformConfigServer.CreateOrUpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await appPlatformConfigServer.UpdateAsync(WaitUntil.Completed, data); AppPlatformConfigServerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -93,10 +90,10 @@ public async Task CreateOrUpdate_ConfigServersUpdatePut() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConfigServersUpdatePatch() + public async Task CreateOrUpdate_ConfigServersUpdatePut() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigServers_UpdatePatch.json - // this example is just showing the usage of "ConfigServers_UpdatePatch" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigServers_UpdatePut.json + // this example is just showing the usage of "ConfigServers_UpdatePut" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,21 +109,18 @@ public async Task Update_ConfigServersUpdatePatch() AppPlatformConfigServerResource appPlatformConfigServer = client.GetAppPlatformConfigServerResource(appPlatformConfigServerResourceId); // invoke the operation - AppPlatformConfigServerData data = new AppPlatformConfigServerData() + AppPlatformConfigServerData data = new AppPlatformConfigServerData { - Properties = new AppPlatformConfigServerProperties() + Properties = new AppPlatformConfigServerProperties { ConfigServerGitProperty = new AppPlatformConfigServerGitProperty(new Uri("https://github.com/fake-user/fake-repository.git")) { Label = "master", - SearchPaths = -{ -"/" -}, + SearchPaths = { "/" }, }, }, }; - ArmOperation lro = await appPlatformConfigServer.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await appPlatformConfigServer.CreateOrUpdateAsync(WaitUntil.Completed, data); AppPlatformConfigServerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigurationServiceCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigurationServiceCollection.cs index 1d3f3b53976ef..9137c436d0af3 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigurationServiceCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigurationServiceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformConfigurationServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConfigurationServicesGet() + public async Task CreateOrUpdate_ConfigurationServicesCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_Get.json - // this example is just showing the usage of "ConfigurationServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_CreateOrUpdate.json + // this example is just showing the usage of "ConfigurationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_ConfigurationServicesGet() // invoke the operation string configurationServiceName = "default"; - AppPlatformConfigurationServiceResource result = await collection.GetAsync(configurationServiceName); + AppPlatformConfigurationServiceData data = new AppPlatformConfigurationServiceData + { + Properties = new AppPlatformConfigurationServiceProperties + { + ConfigurationServiceGitRepositories = { new AppPlatformConfigurationServiceGitRepository("fake", new string[] { "app/dev" }, new Uri("https://github.com/fake-user/fake-repository"), "master") }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationServiceName, data); + AppPlatformConfigurationServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_ConfigurationServicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConfigurationServicesGet() + public async Task Get_ConfigurationServicesGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_Get.json // this example is just showing the usage of "ConfigurationServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +83,21 @@ public async Task Exists_ConfigurationServicesGet() // invoke the operation string configurationServiceName = "default"; - bool result = await collection.ExistsAsync(configurationServiceName); + AppPlatformConfigurationServiceResource result = await collection.GetAsync(configurationServiceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformConfigurationServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConfigurationServicesGet() + public async Task GetAll_ConfigurationServicesList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_Get.json - // this example is just showing the usage of "ConfigurationServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_List.json + // this example is just showing the usage of "ConfigurationServices_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +115,25 @@ public async Task GetIfExists_ConfigurationServicesGet() // get the collection of this AppPlatformConfigurationServiceResource AppPlatformConfigurationServiceCollection collection = appPlatformService.GetAppPlatformConfigurationServices(); - // invoke the operation - string configurationServiceName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(configurationServiceName); - AppPlatformConfigurationServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformConfigurationServiceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformConfigurationServiceData resourceData = result.Data; + AppPlatformConfigurationServiceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConfigurationServicesCreateOrUpdate() + public async Task Exists_ConfigurationServicesGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_CreateOrUpdate.json - // this example is just showing the usage of "ConfigurationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_Get.json + // this example is just showing the usage of "ConfigurationServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,35 +153,17 @@ public async Task CreateOrUpdate_ConfigurationServicesCreateOrUpdate() // invoke the operation string configurationServiceName = "default"; - AppPlatformConfigurationServiceData data = new AppPlatformConfigurationServiceData() - { - Properties = new AppPlatformConfigurationServiceProperties() - { - ConfigurationServiceGitRepositories = -{ -new AppPlatformConfigurationServiceGitRepository("fake",new string[] -{ -"app/dev" -},new Uri("https://github.com/fake-user/fake-repository"),"master") -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationServiceName, data); - AppPlatformConfigurationServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(configurationServiceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformConfigurationServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConfigurationServicesList() + public async Task GetIfExists_ConfigurationServicesGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_List.json - // this example is just showing the usage of "ConfigurationServices_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_Get.json + // this example is just showing the usage of "ConfigurationServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +181,23 @@ public async Task GetAll_ConfigurationServicesList() // get the collection of this AppPlatformConfigurationServiceResource AppPlatformConfigurationServiceCollection collection = appPlatformService.GetAppPlatformConfigurationServices(); - // invoke the operation and iterate over the result - await foreach (AppPlatformConfigurationServiceResource item in collection.GetAllAsync()) + // invoke the operation + string configurationServiceName = "default"; + NullableResponse response = await collection.GetIfExistsAsync(configurationServiceName); + AppPlatformConfigurationServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformConfigurationServiceData resourceData = item.Data; + AppPlatformConfigurationServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigurationServiceResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigurationServiceResource.cs index 421505fab876b..c6d8e75dbd0f8 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigurationServiceResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformConfigurationServiceResource.cs @@ -49,10 +49,10 @@ public async Task Get_ConfigurationServicesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConfigurationServicesCreateOrUpdate() + public async Task Delete_ConfigurationServicesDelete() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_CreateOrUpdate.json - // this example is just showing the usage of "ConfigurationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_Delete.json + // this example is just showing the usage of "ConfigurationServices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,35 +69,17 @@ public async Task Update_ConfigurationServicesCreateOrUpdate() AppPlatformConfigurationServiceResource appPlatformConfigurationService = client.GetAppPlatformConfigurationServiceResource(appPlatformConfigurationServiceResourceId); // invoke the operation - AppPlatformConfigurationServiceData data = new AppPlatformConfigurationServiceData() - { - Properties = new AppPlatformConfigurationServiceProperties() - { - ConfigurationServiceGitRepositories = -{ -new AppPlatformConfigurationServiceGitRepository("fake",new string[] -{ -"app/dev" -},new Uri("https://github.com/fake-user/fake-repository"),"master") -}, - }, - }; - ArmOperation lro = await appPlatformConfigurationService.UpdateAsync(WaitUntil.Completed, data); - AppPlatformConfigurationServiceResource result = lro.Value; + await appPlatformConfigurationService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformConfigurationServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ConfigurationServicesDelete() + public async Task Update_ConfigurationServicesCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_Delete.json - // this example is just showing the usage of "ConfigurationServices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ConfigurationServices_CreateOrUpdate.json + // this example is just showing the usage of "ConfigurationServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +96,21 @@ public async Task Delete_ConfigurationServicesDelete() AppPlatformConfigurationServiceResource appPlatformConfigurationService = client.GetAppPlatformConfigurationServiceResource(appPlatformConfigurationServiceResourceId); // invoke the operation - await appPlatformConfigurationService.DeleteAsync(WaitUntil.Completed); + AppPlatformConfigurationServiceData data = new AppPlatformConfigurationServiceData + { + Properties = new AppPlatformConfigurationServiceProperties + { + ConfigurationServiceGitRepositories = { new AppPlatformConfigurationServiceGitRepository("fake", new string[] { "app/dev" }, new Uri("https://github.com/fake-user/fake-repository"), "master") }, + }, + }; + ArmOperation lro = await appPlatformConfigurationService.UpdateAsync(WaitUntil.Completed, data); + AppPlatformConfigurationServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformConfigurationServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -141,15 +135,9 @@ public async Task Validate_ConfigurationServicesValidate() AppPlatformConfigurationServiceResource appPlatformConfigurationService = client.GetAppPlatformConfigurationServiceResource(appPlatformConfigurationServiceResourceId); // invoke the operation - AppPlatformConfigurationServiceSettings settings = new AppPlatformConfigurationServiceSettings() + AppPlatformConfigurationServiceSettings settings = new AppPlatformConfigurationServiceSettings { - ConfigurationServiceGitRepositories = -{ -new AppPlatformConfigurationServiceGitRepository("fake",new string[] -{ -"app/dev" -},new Uri("https://github.com/fake-user/fake-repository"),"master") -}, + ConfigurationServiceGitRepositories = { new AppPlatformConfigurationServiceGitRepository("fake", new string[] { "app/dev" }, new Uri("https://github.com/fake-user/fake-repository"), "master") }, }; ArmOperation lro = await appPlatformConfigurationService.ValidateAsync(WaitUntil.Completed, settings); AppPlatformConfigurationServiceSettingsValidateResult result = lro.Value; diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCustomDomainCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCustomDomainCollection.cs index 767b8fd411ecb..26ac7561ee464 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCustomDomainCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCustomDomainCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformCustomDomainCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CustomDomainsGet() + public async Task CreateOrUpdate_CustomDomainsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/CustomDomains_Get.json - // this example is just showing the usage of "CustomDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/CustomDomains_CreateOrUpdate.json + // this example is just showing the usage of "CustomDomains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,16 @@ public async Task Get_CustomDomainsGet() // invoke the operation string domainName = "mydomain.com"; - AppPlatformCustomDomainResource result = await collection.GetAsync(domainName); + AppPlatformCustomDomainData data = new AppPlatformCustomDomainData + { + Properties = new AppPlatformCustomDomainProperties + { + Thumbprint = "934367bf1c97033f877db0f15cb1b586957d3133", + CertName = "mycert", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); + AppPlatformCustomDomainResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +62,7 @@ public async Task Get_CustomDomainsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CustomDomainsGet() + public async Task Get_CustomDomainsGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/CustomDomains_Get.json // this example is just showing the usage of "CustomDomains_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +86,21 @@ public async Task Exists_CustomDomainsGet() // invoke the operation string domainName = "mydomain.com"; - bool result = await collection.ExistsAsync(domainName); + AppPlatformCustomDomainResource result = await collection.GetAsync(domainName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CustomDomainsGet() + public async Task GetAll_CustomDomainsList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/CustomDomains_Get.json - // this example is just showing the usage of "CustomDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/CustomDomains_List.json + // this example is just showing the usage of "CustomDomains_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +119,25 @@ public async Task GetIfExists_CustomDomainsGet() // get the collection of this AppPlatformCustomDomainResource AppPlatformCustomDomainCollection collection = appPlatformApp.GetAppPlatformCustomDomains(); - // invoke the operation - string domainName = "mydomain.com"; - NullableResponse response = await collection.GetIfExistsAsync(domainName); - AppPlatformCustomDomainResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformCustomDomainResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformCustomDomainData resourceData = result.Data; + AppPlatformCustomDomainData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CustomDomainsCreateOrUpdate() + public async Task Exists_CustomDomainsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/CustomDomains_CreateOrUpdate.json - // this example is just showing the usage of "CustomDomains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/CustomDomains_Get.json + // this example is just showing the usage of "CustomDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,30 +158,17 @@ public async Task CreateOrUpdate_CustomDomainsCreateOrUpdate() // invoke the operation string domainName = "mydomain.com"; - AppPlatformCustomDomainData data = new AppPlatformCustomDomainData() - { - Properties = new AppPlatformCustomDomainProperties() - { - Thumbprint = "934367bf1c97033f877db0f15cb1b586957d3133", - CertName = "mycert", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); - AppPlatformCustomDomainResource result = lro.Value; + bool result = await collection.ExistsAsync(domainName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CustomDomainsList() + public async Task GetIfExists_CustomDomainsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/CustomDomains_List.json - // this example is just showing the usage of "CustomDomains_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/CustomDomains_Get.json + // this example is just showing the usage of "CustomDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +187,23 @@ public async Task GetAll_CustomDomainsList() // get the collection of this AppPlatformCustomDomainResource AppPlatformCustomDomainCollection collection = appPlatformApp.GetAppPlatformCustomDomains(); - // invoke the operation and iterate over the result - await foreach (AppPlatformCustomDomainResource item in collection.GetAllAsync()) + // invoke the operation + string domainName = "mydomain.com"; + NullableResponse response = await collection.GetIfExistsAsync(domainName); + AppPlatformCustomDomainResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformCustomDomainData resourceData = item.Data; + AppPlatformCustomDomainData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCustomDomainResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCustomDomainResource.cs index da385ce9f717b..e1cc2cf2e0ddd 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCustomDomainResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformCustomDomainResource.cs @@ -99,9 +99,9 @@ public async Task Update_CustomDomainsUpdate() AppPlatformCustomDomainResource appPlatformCustomDomain = client.GetAppPlatformCustomDomainResource(appPlatformCustomDomainResourceId); // invoke the operation - AppPlatformCustomDomainData data = new AppPlatformCustomDomainData() + AppPlatformCustomDomainData data = new AppPlatformCustomDomainData { - Properties = new AppPlatformCustomDomainProperties() + Properties = new AppPlatformCustomDomainProperties { Thumbprint = "934367bf1c97033f877db0f15cb1b586957d3133", CertName = "mycert", diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformDeploymentCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformDeploymentCollection.cs index de5ab873a97a6..b6bf8926211ce 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformDeploymentCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformDeploymentCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_AppPlatformDeploymentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DeploymentsGet() + public async Task CreateOrUpdate_DeploymentsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_Get.json - // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_CreateOrUpdate.json + // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,7 +42,72 @@ public async Task Get_DeploymentsGet() // invoke the operation string deploymentName = "mydeployment"; - AppPlatformDeploymentResource result = await collection.GetAsync(deploymentName); + AppPlatformDeploymentData data = new AppPlatformDeploymentData + { + Properties = new AppPlatformDeploymentProperties + { + Source = new SourceUploadedUserSourceInfo + { + ArtifactSelector = "sub-module-1", + RelativePath = "resources/a172cedcae47474b615c54d510a5d84a8dea3032e958587430b413538be3f333-2019082605-e3095339-1723-44b7-8b5e-31b1003978bc", + Version = "1.0", + }, + DeploymentSettings = new AppPlatformDeploymentSettings + { + ResourceRequests = new AppPlatformDeploymentResourceRequirements + { + Cpu = "1000m", + Memory = "3Gi", + }, + EnvironmentVariables = +{ +["env"] = "test" +}, + AddonConfigs = +{ +["ApplicationConfigurationService"] = +{ +["patterns"] = BinaryData.FromObjectAsJson(new object[] +{ +"mypattern" +}) +} +}, + LivenessProbe = new AppInstanceProbe(false) + { + ProbeAction = new AppInstanceHttpGetAction + { + Path = "/health", + Scheme = AppInstanceHttpSchemeType.Http, + }, + InitialDelayInSeconds = 30, + PeriodInSeconds = 10, + FailureThreshold = 3, + }, + ReadinessProbe = new AppInstanceProbe(false) + { + ProbeAction = new AppInstanceHttpGetAction + { + Path = "/health", + Scheme = AppInstanceHttpSchemeType.Http, + }, + InitialDelayInSeconds = 30, + PeriodInSeconds = 10, + FailureThreshold = 3, + }, + StartupProbe = default, + TerminationGracePeriodInSeconds = 30, + }, + }, + Sku = new AppPlatformSku + { + Name = "S0", + Tier = "Standard", + Capacity = 1, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); + AppPlatformDeploymentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +118,10 @@ public async Task Get_DeploymentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DeploymentsGet() + public async Task CreateOrUpdate_DeploymentsCreateOrUpdateCustomContainer() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_Get.json - // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_CreateOrUpdate_CustomContainer.json + // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,14 +142,77 @@ public async Task Exists_DeploymentsGet() // invoke the operation string deploymentName = "mydeployment"; - bool result = await collection.ExistsAsync(deploymentName); + AppPlatformDeploymentData data = new AppPlatformDeploymentData + { + Properties = new AppPlatformDeploymentProperties + { + Source = new AppPlatformCustomContainerUserSourceInfo + { + CustomContainer = new AppPlatformCustomContainer + { + Server = "myacr.azurecr.io", + ContainerImage = "myContainerImage:v1", + Command = { "/bin/sh" }, + Args = { "-c", "while true; do echo hello; sleep 10;done" }, + ImageRegistryCredential = new AppPlatformImageRegistryCredential + { + Username = "myUsername", + Password = "myPassword", + }, + LanguageFramework = "springboot", + }, + }, + DeploymentSettings = new AppPlatformDeploymentSettings + { + ResourceRequests = new AppPlatformDeploymentResourceRequirements + { + Cpu = "1000m", + Memory = "3Gi", + }, + EnvironmentVariables = +{ +["env"] = "test" +}, + LivenessProbe = new AppInstanceProbe(false) + { + ProbeAction = new AppInstanceHttpGetAction + { + Path = "/health", + Scheme = AppInstanceHttpSchemeType.Http, + }, + InitialDelayInSeconds = 30, + PeriodInSeconds = 10, + FailureThreshold = 3, + }, + ReadinessProbe = new AppInstanceProbe(false) + { + ProbeAction = new AppInstanceHttpGetAction + { + Path = "/health", + Scheme = AppInstanceHttpSchemeType.Http, + }, + InitialDelayInSeconds = 30, + PeriodInSeconds = 10, + FailureThreshold = 3, + }, + StartupProbe = default, + TerminationGracePeriodInSeconds = 30, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); + AppPlatformDeploymentResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DeploymentsGet() + public async Task Get_DeploymentsGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_Get.json // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,21 +236,13 @@ public async Task GetIfExists_DeploymentsGet() // invoke the operation string deploymentName = "mydeployment"; - NullableResponse response = await collection.GetIfExistsAsync(deploymentName); - AppPlatformDeploymentResource result = response.HasValue ? response.Value : null; + AppPlatformDeploymentResource result = await collection.GetAsync(deploymentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -163,10 +282,10 @@ public async Task Get_DeploymentsGetCustomContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DeploymentsGetCustomContainer() + public async Task GetAll_DeploymentsList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_Get_CustomContainer.json - // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_List.json + // this example is just showing the usage of "Deployments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,18 +304,24 @@ public async Task Exists_DeploymentsGetCustomContainer() // get the collection of this AppPlatformDeploymentResource AppPlatformDeploymentCollection collection = appPlatformApp.GetAppPlatformDeployments(); - // invoke the operation - string deploymentName = "mydeployment"; - bool result = await collection.ExistsAsync(deploymentName); + // invoke the operation and iterate over the result + await foreach (AppPlatformDeploymentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformDeploymentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DeploymentsGetCustomContainer() + public async Task Exists_DeploymentsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_Get_CustomContainer.json + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_Get.json // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -218,29 +343,17 @@ public async Task GetIfExists_DeploymentsGetCustomContainer() // invoke the operation string deploymentName = "mydeployment"; - NullableResponse response = await collection.GetIfExistsAsync(deploymentName); - AppPlatformDeploymentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(deploymentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DeploymentsCreateOrUpdate() + public async Task Exists_DeploymentsGetCustomContainer() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_CreateOrUpdate.json - // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_Get_CustomContainer.json + // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -261,83 +374,17 @@ public async Task CreateOrUpdate_DeploymentsCreateOrUpdate() // invoke the operation string deploymentName = "mydeployment"; - AppPlatformDeploymentData data = new AppPlatformDeploymentData() - { - Properties = new AppPlatformDeploymentProperties() - { - Source = new SourceUploadedUserSourceInfo() - { - ArtifactSelector = "sub-module-1", - RelativePath = "resources/a172cedcae47474b615c54d510a5d84a8dea3032e958587430b413538be3f333-2019082605-e3095339-1723-44b7-8b5e-31b1003978bc", - Version = "1.0", - }, - DeploymentSettings = new AppPlatformDeploymentSettings() - { - ResourceRequests = new AppPlatformDeploymentResourceRequirements() - { - Cpu = "1000m", - Memory = "3Gi", - }, - EnvironmentVariables = -{ -["env"] = "test", -}, - AddonConfigs = -{ -["ApplicationConfigurationService"] = new Dictionary() -{ -["patterns"] = BinaryData.FromObjectAsJson(new object[] { "mypattern" }), -}, -}, - LivenessProbe = new AppInstanceProbe(false) - { - ProbeAction = new AppInstanceHttpGetAction() - { - Path = "/health", - Scheme = AppInstanceHttpSchemeType.Http, - }, - InitialDelayInSeconds = 30, - PeriodInSeconds = 10, - FailureThreshold = 3, - }, - ReadinessProbe = new AppInstanceProbe(false) - { - ProbeAction = new AppInstanceHttpGetAction() - { - Path = "/health", - Scheme = AppInstanceHttpSchemeType.Http, - }, - InitialDelayInSeconds = 30, - PeriodInSeconds = 10, - FailureThreshold = 3, - }, - StartupProbe = null, - TerminationGracePeriodInSeconds = 30, - }, - }, - Sku = new AppPlatformSku() - { - Name = "S0", - Tier = "Standard", - Capacity = 1, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); - AppPlatformDeploymentResource result = lro.Value; + bool result = await collection.ExistsAsync(deploymentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DeploymentsCreateOrUpdateCustomContainer() + public async Task GetIfExists_DeploymentsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_CreateOrUpdate_CustomContainer.json - // this example is just showing the usage of "Deployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_Get.json + // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -358,86 +405,29 @@ public async Task CreateOrUpdate_DeploymentsCreateOrUpdateCustomContainer() // invoke the operation string deploymentName = "mydeployment"; - AppPlatformDeploymentData data = new AppPlatformDeploymentData() - { - Properties = new AppPlatformDeploymentProperties() - { - Source = new AppPlatformCustomContainerUserSourceInfo() - { - CustomContainer = new AppPlatformCustomContainer() - { - Server = "myacr.azurecr.io", - ContainerImage = "myContainerImage:v1", - Command = -{ -"/bin/sh" -}, - Args = -{ -"-c","while true; do echo hello; sleep 10;done" -}, - ImageRegistryCredential = new AppPlatformImageRegistryCredential() - { - Username = "myUsername", - Password = "myPassword", - }, - LanguageFramework = "springboot", - }, - }, - DeploymentSettings = new AppPlatformDeploymentSettings() - { - ResourceRequests = new AppPlatformDeploymentResourceRequirements() - { - Cpu = "1000m", - Memory = "3Gi", - }, - EnvironmentVariables = -{ -["env"] = "test", -}, - LivenessProbe = new AppInstanceProbe(false) - { - ProbeAction = new AppInstanceHttpGetAction() - { - Path = "/health", - Scheme = AppInstanceHttpSchemeType.Http, - }, - InitialDelayInSeconds = 30, - PeriodInSeconds = 10, - FailureThreshold = 3, - }, - ReadinessProbe = new AppInstanceProbe(false) - { - ProbeAction = new AppInstanceHttpGetAction() - { - Path = "/health", - Scheme = AppInstanceHttpSchemeType.Http, - }, - InitialDelayInSeconds = 30, - PeriodInSeconds = 10, - FailureThreshold = 3, - }, - StartupProbe = null, - TerminationGracePeriodInSeconds = 30, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); - AppPlatformDeploymentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(deploymentName); + AppPlatformDeploymentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DeploymentsList() + public async Task GetIfExists_DeploymentsGetCustomContainer() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_List.json - // this example is just showing the usage of "Deployments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Deployments_Get_CustomContainer.json + // this example is just showing the usage of "Deployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -456,17 +446,23 @@ public async Task GetAll_DeploymentsList() // get the collection of this AppPlatformDeploymentResource AppPlatformDeploymentCollection collection = appPlatformApp.GetAppPlatformDeployments(); - // invoke the operation and iterate over the result - await foreach (AppPlatformDeploymentResource item in collection.GetAllAsync()) + // invoke the operation + string deploymentName = "mydeployment"; + NullableResponse response = await collection.GetIfExistsAsync(deploymentName); + AppPlatformDeploymentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformDeploymentData resourceData = item.Data; + AppPlatformDeploymentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformDeploymentResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformDeploymentResource.cs index d7f177986e7d9..979dfde954ec7 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformDeploymentResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformDeploymentResource.cs @@ -131,11 +131,11 @@ public async Task Update_DeploymentsUpdate() AppPlatformDeploymentResource appPlatformDeployment = client.GetAppPlatformDeploymentResource(appPlatformDeploymentResourceId); // invoke the operation - AppPlatformDeploymentData data = new AppPlatformDeploymentData() + AppPlatformDeploymentData data = new AppPlatformDeploymentData { - Properties = new AppPlatformDeploymentProperties() + Properties = new AppPlatformDeploymentProperties { - Source = new SourceUploadedUserSourceInfo() + Source = new SourceUploadedUserSourceInfo { ArtifactSelector = "sub-module-1", RelativePath = "resources/a172cedcae47474b615c54d510a5d84a8dea3032e958587430b413538be3f333-2019082605-e3095339-1723-44b7-8b5e-31b1003978bc", @@ -176,25 +176,19 @@ public async Task Update_DeploymentsUpdateCustomContainer() AppPlatformDeploymentResource appPlatformDeployment = client.GetAppPlatformDeploymentResource(appPlatformDeploymentResourceId); // invoke the operation - AppPlatformDeploymentData data = new AppPlatformDeploymentData() + AppPlatformDeploymentData data = new AppPlatformDeploymentData { - Properties = new AppPlatformDeploymentProperties() + Properties = new AppPlatformDeploymentProperties { - Source = new AppPlatformCustomContainerUserSourceInfo() + Source = new AppPlatformCustomContainerUserSourceInfo { - CustomContainer = new AppPlatformCustomContainer() + CustomContainer = new AppPlatformCustomContainer { Server = "mynewacr.azurecr.io", ContainerImage = "myNewContainerImage:v1", - Command = -{ -"/bin/sh" -}, - Args = -{ -"-c","while true; do echo hello; sleep 10;done" -}, - ImageRegistryCredential = new AppPlatformImageRegistryCredential() + Command = { "/bin/sh" }, + Args = { "-c", "while true; do echo hello; sleep 10;done" }, + ImageRegistryCredential = new AppPlatformImageRegistryCredential { Username = "myNewUsername", Password = "", @@ -435,7 +429,7 @@ public async Task GenerateHeapDump_DeploymentsGenerateHeapDump() AppPlatformDeploymentResource appPlatformDeployment = client.GetAppPlatformDeploymentResource(appPlatformDeploymentResourceId); // invoke the operation - ApplicationDiagnosticContent content = new ApplicationDiagnosticContent() + ApplicationDiagnosticContent content = new ApplicationDiagnosticContent { AppInstance = "myappinstance", FilePath = "/byos/diagnose", @@ -468,7 +462,7 @@ public async Task GenerateThreadDump_DeploymentsGenerateHeapDump() AppPlatformDeploymentResource appPlatformDeployment = client.GetAppPlatformDeploymentResource(appPlatformDeploymentResourceId); // invoke the operation - ApplicationDiagnosticContent content = new ApplicationDiagnosticContent() + ApplicationDiagnosticContent content = new ApplicationDiagnosticContent { AppInstance = "myappinstance", FilePath = "/byos/diagnose", @@ -501,7 +495,7 @@ public async Task StartJfr_DeploymentsStartJFR() AppPlatformDeploymentResource appPlatformDeployment = client.GetAppPlatformDeploymentResource(appPlatformDeploymentResourceId); // invoke the operation - ApplicationDiagnosticContent content = new ApplicationDiagnosticContent() + ApplicationDiagnosticContent content = new ApplicationDiagnosticContent { AppInstance = "myappinstance", FilePath = "/byos/diagnose", diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCollection.cs index 2d0c3225dd711..7287eba815bfc 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformGatewayCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GatewaysGet() + public async Task CreateOrUpdate_GatewaysCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_Get.json - // this example is just showing the usage of "Gateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_CreateOrUpdate.json + // this example is just showing the usage of "Gateways_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,26 @@ public async Task Get_GatewaysGet() // invoke the operation string gatewayName = "default"; - AppPlatformGatewayResource result = await collection.GetAsync(gatewayName); + AppPlatformGatewayData data = new AppPlatformGatewayData + { + Properties = new AppPlatformGatewayProperties + { + IsPublic = true, + ResourceRequests = new AppPlatformGatewayResourceRequirements + { + Cpu = "1", + Memory = "1G", + }, + }, + Sku = new AppPlatformSku + { + Name = "E0", + Tier = "Enterprise", + Capacity = 2, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gatewayName, data); + AppPlatformGatewayResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +71,7 @@ public async Task Get_GatewaysGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GatewaysGet() + public async Task Get_GatewaysGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_Get.json // this example is just showing the usage of "Gateways_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +94,21 @@ public async Task Exists_GatewaysGet() // invoke the operation string gatewayName = "default"; - bool result = await collection.ExistsAsync(gatewayName); + AppPlatformGatewayResource result = await collection.GetAsync(gatewayName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GatewaysGet() + public async Task GetAll_GatewaysList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_Get.json - // this example is just showing the usage of "Gateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_List.json + // this example is just showing the usage of "Gateways_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +126,25 @@ public async Task GetIfExists_GatewaysGet() // get the collection of this AppPlatformGatewayResource AppPlatformGatewayCollection collection = appPlatformService.GetAppPlatformGateways(); - // invoke the operation - string gatewayName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(gatewayName); - AppPlatformGatewayResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformGatewayResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformGatewayData resourceData = result.Data; + AppPlatformGatewayData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GatewaysCreateOrUpdate() + public async Task Exists_GatewaysGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_CreateOrUpdate.json - // this example is just showing the usage of "Gateways_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_Get.json + // this example is just showing the usage of "Gateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,40 +164,17 @@ public async Task CreateOrUpdate_GatewaysCreateOrUpdate() // invoke the operation string gatewayName = "default"; - AppPlatformGatewayData data = new AppPlatformGatewayData() - { - Properties = new AppPlatformGatewayProperties() - { - IsPublic = true, - ResourceRequests = new AppPlatformGatewayResourceRequirements() - { - Cpu = "1", - Memory = "1G", - }, - }, - Sku = new AppPlatformSku() - { - Name = "E0", - Tier = "Enterprise", - Capacity = 2, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gatewayName, data); - AppPlatformGatewayResource result = lro.Value; + bool result = await collection.ExistsAsync(gatewayName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GatewaysList() + public async Task GetIfExists_GatewaysGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_List.json - // this example is just showing the usage of "Gateways_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_Get.json + // this example is just showing the usage of "Gateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,17 +192,23 @@ public async Task GetAll_GatewaysList() // get the collection of this AppPlatformGatewayResource AppPlatformGatewayCollection collection = appPlatformService.GetAppPlatformGateways(); - // invoke the operation and iterate over the result - await foreach (AppPlatformGatewayResource item in collection.GetAllAsync()) + // invoke the operation + string gatewayName = "default"; + NullableResponse response = await collection.GetIfExistsAsync(gatewayName); + AppPlatformGatewayResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformGatewayData resourceData = item.Data; + AppPlatformGatewayData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCustomDomainCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCustomDomainCollection.cs index 53809cd76feb0..08488dd8ce4ab 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCustomDomainCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCustomDomainCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppPlatformGatewayCustomDomainCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GatewayCustomDomainsGet() + public async Task CreateOrUpdate_GatewayCustomDomainsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_Get.json - // this example is just showing the usage of "GatewayCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_CreateOrUpdate.json + // this example is just showing the usage of "GatewayCustomDomains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GatewayCustomDomainsGet() // invoke the operation string domainName = "myDomainName"; - AppPlatformGatewayCustomDomainResource result = await collection.GetAsync(domainName); + AppPlatformGatewayCustomDomainData data = new AppPlatformGatewayCustomDomainData + { + GatewayCustomDomainThumbprint = "*", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); + AppPlatformGatewayCustomDomainResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GatewayCustomDomainsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GatewayCustomDomainsGet() + public async Task Get_GatewayCustomDomainsGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_Get.json // this example is just showing the usage of "GatewayCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +81,21 @@ public async Task Exists_GatewayCustomDomainsGet() // invoke the operation string domainName = "myDomainName"; - bool result = await collection.ExistsAsync(domainName); + AppPlatformGatewayCustomDomainResource result = await collection.GetAsync(domainName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformGatewayCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GatewayCustomDomainsGet() + public async Task GetAll_GatewayCustomDomainsList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_Get.json - // this example is just showing the usage of "GatewayCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_List.json + // this example is just showing the usage of "GatewayCustomDomains_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,31 +114,25 @@ public async Task GetIfExists_GatewayCustomDomainsGet() // get the collection of this AppPlatformGatewayCustomDomainResource AppPlatformGatewayCustomDomainCollection collection = appPlatformGateway.GetAppPlatformGatewayCustomDomains(); - // invoke the operation - string domainName = "myDomainName"; - NullableResponse response = await collection.GetIfExistsAsync(domainName); - AppPlatformGatewayCustomDomainResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformGatewayCustomDomainResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformGatewayCustomDomainData resourceData = result.Data; + AppPlatformGatewayCustomDomainData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GatewayCustomDomainsCreateOrUpdate() + public async Task Exists_GatewayCustomDomainsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_CreateOrUpdate.json - // this example is just showing the usage of "GatewayCustomDomains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_Get.json + // this example is just showing the usage of "GatewayCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,26 +153,17 @@ public async Task CreateOrUpdate_GatewayCustomDomainsCreateOrUpdate() // invoke the operation string domainName = "myDomainName"; - AppPlatformGatewayCustomDomainData data = new AppPlatformGatewayCustomDomainData() - { - GatewayCustomDomainThumbprint = "*", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, domainName, data); - AppPlatformGatewayCustomDomainResource result = lro.Value; + bool result = await collection.ExistsAsync(domainName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformGatewayCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GatewayCustomDomainsList() + public async Task GetIfExists_GatewayCustomDomainsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_List.json - // this example is just showing the usage of "GatewayCustomDomains_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_Get.json + // this example is just showing the usage of "GatewayCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_GatewayCustomDomainsList() // get the collection of this AppPlatformGatewayCustomDomainResource AppPlatformGatewayCustomDomainCollection collection = appPlatformGateway.GetAppPlatformGatewayCustomDomains(); - // invoke the operation and iterate over the result - await foreach (AppPlatformGatewayCustomDomainResource item in collection.GetAllAsync()) + // invoke the operation + string domainName = "myDomainName"; + NullableResponse response = await collection.GetIfExistsAsync(domainName); + AppPlatformGatewayCustomDomainResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformGatewayCustomDomainData resourceData = item.Data; + AppPlatformGatewayCustomDomainData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCustomDomainResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCustomDomainResource.cs index 5f027301faaad..6b7509fab67f3 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCustomDomainResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayCustomDomainResource.cs @@ -49,10 +49,10 @@ public async Task Get_GatewayCustomDomainsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GatewayCustomDomainsCreateOrUpdate() + public async Task Delete_GatewayCustomDomainsDelete() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_CreateOrUpdate.json - // this example is just showing the usage of "GatewayCustomDomains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_Delete.json + // this example is just showing the usage of "GatewayCustomDomains_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_GatewayCustomDomainsCreateOrUpdate() AppPlatformGatewayCustomDomainResource appPlatformGatewayCustomDomain = client.GetAppPlatformGatewayCustomDomainResource(appPlatformGatewayCustomDomainResourceId); // invoke the operation - AppPlatformGatewayCustomDomainData data = new AppPlatformGatewayCustomDomainData() - { - GatewayCustomDomainThumbprint = "*", - }; - ArmOperation lro = await appPlatformGatewayCustomDomain.UpdateAsync(WaitUntil.Completed, data); - AppPlatformGatewayCustomDomainResource result = lro.Value; + await appPlatformGatewayCustomDomain.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformGatewayCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_GatewayCustomDomainsDelete() + public async Task Update_GatewayCustomDomainsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_Delete.json - // this example is just showing the usage of "GatewayCustomDomains_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayCustomDomains_CreateOrUpdate.json + // this example is just showing the usage of "GatewayCustomDomains_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +98,18 @@ public async Task Delete_GatewayCustomDomainsDelete() AppPlatformGatewayCustomDomainResource appPlatformGatewayCustomDomain = client.GetAppPlatformGatewayCustomDomainResource(appPlatformGatewayCustomDomainResourceId); // invoke the operation - await appPlatformGatewayCustomDomain.DeleteAsync(WaitUntil.Completed); + AppPlatformGatewayCustomDomainData data = new AppPlatformGatewayCustomDomainData + { + GatewayCustomDomainThumbprint = "*", + }; + ArmOperation lro = await appPlatformGatewayCustomDomain.UpdateAsync(WaitUntil.Completed, data); + AppPlatformGatewayCustomDomainResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformGatewayCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayResource.cs index 69d05152fa3c5..673c7800921ac 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayResource.cs @@ -47,6 +47,33 @@ public async Task Get_GatewaysGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_GatewaysDelete() + { + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_Delete.json + // this example is just showing the usage of "Gateways_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AppPlatformGatewayResource created on azure + // for more information of creating AppPlatformGatewayResource, please refer to the document of AppPlatformGatewayResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + string serviceName = "myservice"; + string gatewayName = "default"; + ResourceIdentifier appPlatformGatewayResourceId = AppPlatformGatewayResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, gatewayName); + AppPlatformGatewayResource appPlatformGateway = client.GetAppPlatformGatewayResource(appPlatformGatewayResourceId); + + // invoke the operation + await appPlatformGateway.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_GatewaysCreateOrUpdate() @@ -69,18 +96,18 @@ public async Task Update_GatewaysCreateOrUpdate() AppPlatformGatewayResource appPlatformGateway = client.GetAppPlatformGatewayResource(appPlatformGatewayResourceId); // invoke the operation - AppPlatformGatewayData data = new AppPlatformGatewayData() + AppPlatformGatewayData data = new AppPlatformGatewayData { - Properties = new AppPlatformGatewayProperties() + Properties = new AppPlatformGatewayProperties { IsPublic = true, - ResourceRequests = new AppPlatformGatewayResourceRequirements() + ResourceRequests = new AppPlatformGatewayResourceRequirements { Cpu = "1", Memory = "1G", }, }, - Sku = new AppPlatformSku() + Sku = new AppPlatformSku { Name = "E0", Tier = "Enterprise", @@ -97,33 +124,6 @@ public async Task Update_GatewaysCreateOrUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_GatewaysDelete() - { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Gateways_Delete.json - // this example is just showing the usage of "Gateways_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AppPlatformGatewayResource created on azure - // for more information of creating AppPlatformGatewayResource, please refer to the document of AppPlatformGatewayResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - string serviceName = "myservice"; - string gatewayName = "default"; - ResourceIdentifier appPlatformGatewayResourceId = AppPlatformGatewayResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName, gatewayName); - AppPlatformGatewayResource appPlatformGateway = client.GetAppPlatformGatewayResource(appPlatformGatewayResourceId); - - // invoke the operation - await appPlatformGateway.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task ValidateDomain_GatewaysValidateDomain() diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayRouteConfigCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayRouteConfigCollection.cs index 5273653b25030..29c5005b6a648 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayRouteConfigCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayRouteConfigCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformGatewayRouteConfigCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GatewayRouteConfigsGet() + public async Task CreateOrUpdate_GatewayRouteConfigsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_Get.json - // this example is just showing the usage of "GatewayRouteConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_CreateOrUpdate.json + // this example is just showing the usage of "GatewayRouteConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,24 @@ public async Task Get_GatewayRouteConfigsGet() // invoke the operation string routeConfigName = "myRouteConfig"; - AppPlatformGatewayRouteConfigResource result = await collection.GetAsync(routeConfigName); + AppPlatformGatewayRouteConfigData data = new AppPlatformGatewayRouteConfigData + { + Properties = new AppPlatformGatewayRouteConfigProperties + { + AppResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/apps/myApp"), + OpenApiUri = new Uri("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json"), + Protocol = AppPlatformGatewayRouteConfigProtocol.Https, + Routes = {new AppPlatformGatewayApiRoute +{ +Title = "myApp route config", +IsSsoEnabled = true, +Predicates = {"Path=/api5/customer/**"}, +Filters = {"StripPrefix=2", "RateLimit=1,1s"}, +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeConfigName, data); + AppPlatformGatewayRouteConfigResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +70,7 @@ public async Task Get_GatewayRouteConfigsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GatewayRouteConfigsGet() + public async Task Get_GatewayRouteConfigsGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_Get.json // this example is just showing the usage of "GatewayRouteConfigs_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +94,21 @@ public async Task Exists_GatewayRouteConfigsGet() // invoke the operation string routeConfigName = "myRouteConfig"; - bool result = await collection.ExistsAsync(routeConfigName); + AppPlatformGatewayRouteConfigResource result = await collection.GetAsync(routeConfigName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformGatewayRouteConfigData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GatewayRouteConfigsGet() + public async Task GetAll_GatewayRouteConfigsList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_Get.json - // this example is just showing the usage of "GatewayRouteConfigs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_List.json + // this example is just showing the usage of "GatewayRouteConfigs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +127,25 @@ public async Task GetIfExists_GatewayRouteConfigsGet() // get the collection of this AppPlatformGatewayRouteConfigResource AppPlatformGatewayRouteConfigCollection collection = appPlatformGateway.GetAppPlatformGatewayRouteConfigs(); - // invoke the operation - string routeConfigName = "myRouteConfig"; - NullableResponse response = await collection.GetIfExistsAsync(routeConfigName); - AppPlatformGatewayRouteConfigResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformGatewayRouteConfigResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformGatewayRouteConfigData resourceData = result.Data; + AppPlatformGatewayRouteConfigData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GatewayRouteConfigsCreateOrUpdate() + public async Task Exists_GatewayRouteConfigsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_CreateOrUpdate.json - // this example is just showing the usage of "GatewayRouteConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_Get.json + // this example is just showing the usage of "GatewayRouteConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,47 +166,17 @@ public async Task CreateOrUpdate_GatewayRouteConfigsCreateOrUpdate() // invoke the operation string routeConfigName = "myRouteConfig"; - AppPlatformGatewayRouteConfigData data = new AppPlatformGatewayRouteConfigData() - { - Properties = new AppPlatformGatewayRouteConfigProperties() - { - AppResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/apps/myApp"), - OpenApiUri = new Uri("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json"), - Protocol = AppPlatformGatewayRouteConfigProtocol.Https, - Routes = -{ -new AppPlatformGatewayApiRoute() -{ -Title = "myApp route config", -IsSsoEnabled = true, -Predicates = -{ -"Path=/api5/customer/**" -}, -Filters = -{ -"StripPrefix=2","RateLimit=1,1s" -}, -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeConfigName, data); - AppPlatformGatewayRouteConfigResource result = lro.Value; + bool result = await collection.ExistsAsync(routeConfigName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformGatewayRouteConfigData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GatewayRouteConfigsList() + public async Task GetIfExists_GatewayRouteConfigsGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_List.json - // this example is just showing the usage of "GatewayRouteConfigs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_Get.json + // this example is just showing the usage of "GatewayRouteConfigs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -210,17 +195,23 @@ public async Task GetAll_GatewayRouteConfigsList() // get the collection of this AppPlatformGatewayRouteConfigResource AppPlatformGatewayRouteConfigCollection collection = appPlatformGateway.GetAppPlatformGatewayRouteConfigs(); - // invoke the operation and iterate over the result - await foreach (AppPlatformGatewayRouteConfigResource item in collection.GetAllAsync()) + // invoke the operation + string routeConfigName = "myRouteConfig"; + NullableResponse response = await collection.GetIfExistsAsync(routeConfigName); + AppPlatformGatewayRouteConfigResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformGatewayRouteConfigData resourceData = item.Data; + AppPlatformGatewayRouteConfigData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayRouteConfigResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayRouteConfigResource.cs index f26f1edbf07cd..3b65105b7122b 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayRouteConfigResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformGatewayRouteConfigResource.cs @@ -50,10 +50,10 @@ public async Task Get_GatewayRouteConfigsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GatewayRouteConfigsCreateOrUpdate() + public async Task Delete_GatewayRouteConfigsDelete() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_CreateOrUpdate.json - // this example is just showing the usage of "GatewayRouteConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_Delete.json + // this example is just showing the usage of "GatewayRouteConfigs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,47 +71,17 @@ public async Task Update_GatewayRouteConfigsCreateOrUpdate() AppPlatformGatewayRouteConfigResource appPlatformGatewayRouteConfig = client.GetAppPlatformGatewayRouteConfigResource(appPlatformGatewayRouteConfigResourceId); // invoke the operation - AppPlatformGatewayRouteConfigData data = new AppPlatformGatewayRouteConfigData() - { - Properties = new AppPlatformGatewayRouteConfigProperties() - { - AppResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/apps/myApp"), - OpenApiUri = new Uri("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json"), - Protocol = AppPlatformGatewayRouteConfigProtocol.Https, - Routes = -{ -new AppPlatformGatewayApiRoute() -{ -Title = "myApp route config", -IsSsoEnabled = true, -Predicates = -{ -"Path=/api5/customer/**" -}, -Filters = -{ -"StripPrefix=2","RateLimit=1,1s" -}, -} -}, - }, - }; - ArmOperation lro = await appPlatformGatewayRouteConfig.UpdateAsync(WaitUntil.Completed, data); - AppPlatformGatewayRouteConfigResource result = lro.Value; + await appPlatformGatewayRouteConfig.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformGatewayRouteConfigData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_GatewayRouteConfigsDelete() + public async Task Update_GatewayRouteConfigsCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_Delete.json - // this example is just showing the usage of "GatewayRouteConfigs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/GatewayRouteConfigs_CreateOrUpdate.json + // this example is just showing the usage of "GatewayRouteConfigs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,9 +99,30 @@ public async Task Delete_GatewayRouteConfigsDelete() AppPlatformGatewayRouteConfigResource appPlatformGatewayRouteConfig = client.GetAppPlatformGatewayRouteConfigResource(appPlatformGatewayRouteConfigResourceId); // invoke the operation - await appPlatformGatewayRouteConfig.DeleteAsync(WaitUntil.Completed); + AppPlatformGatewayRouteConfigData data = new AppPlatformGatewayRouteConfigData + { + Properties = new AppPlatformGatewayRouteConfigProperties + { + AppResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.AppPlatform/Spring/myservice/apps/myApp"), + OpenApiUri = new Uri("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/main/examples/v3.0/petstore.json"), + Protocol = AppPlatformGatewayRouteConfigProtocol.Https, + Routes = {new AppPlatformGatewayApiRoute +{ +Title = "myApp route config", +IsSsoEnabled = true, +Predicates = {"Path=/api5/customer/**"}, +Filters = {"StripPrefix=2", "RateLimit=1,1s"}, +}}, + }, + }; + ArmOperation lro = await appPlatformGatewayRouteConfig.UpdateAsync(WaitUntil.Completed, data); + AppPlatformGatewayRouteConfigResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformGatewayRouteConfigData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformMonitoringSettingResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformMonitoringSettingResource.cs index 7a1d6ae93dfcf..48c0afec21120 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformMonitoringSettingResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformMonitoringSettingResource.cs @@ -48,10 +48,10 @@ public async Task Get_MonitoringSettingsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_MonitoringSettingsUpdatePut() + public async Task Update_MonitoringSettingsUpdatePatch() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/MonitoringSettings_UpdatePut.json - // this example is just showing the usage of "MonitoringSettings_UpdatePut" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/MonitoringSettings_UpdatePatch.json + // this example is just showing the usage of "MonitoringSettings_UpdatePatch" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,16 +67,16 @@ public async Task CreateOrUpdate_MonitoringSettingsUpdatePut() AppPlatformMonitoringSettingResource appPlatformMonitoringSetting = client.GetAppPlatformMonitoringSettingResource(appPlatformMonitoringSettingResourceId); // invoke the operation - AppPlatformMonitoringSettingData data = new AppPlatformMonitoringSettingData() + AppPlatformMonitoringSettingData data = new AppPlatformMonitoringSettingData { - Properties = new AppPlatformMonitoringSettingProperties() + Properties = new AppPlatformMonitoringSettingProperties { IsTraceEnabled = true, AppInsightsInstrumentationKey = "00000000-0000-0000-0000-000000000000", AppInsightsSamplingRate = 10, }, }; - ArmOperation lro = await appPlatformMonitoringSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await appPlatformMonitoringSetting.UpdateAsync(WaitUntil.Completed, data); AppPlatformMonitoringSettingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -88,10 +88,10 @@ public async Task CreateOrUpdate_MonitoringSettingsUpdatePut() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MonitoringSettingsUpdatePatch() + public async Task CreateOrUpdate_MonitoringSettingsUpdatePut() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/MonitoringSettings_UpdatePatch.json - // this example is just showing the usage of "MonitoringSettings_UpdatePatch" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/MonitoringSettings_UpdatePut.json + // this example is just showing the usage of "MonitoringSettings_UpdatePut" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +107,16 @@ public async Task Update_MonitoringSettingsUpdatePatch() AppPlatformMonitoringSettingResource appPlatformMonitoringSetting = client.GetAppPlatformMonitoringSettingResource(appPlatformMonitoringSettingResourceId); // invoke the operation - AppPlatformMonitoringSettingData data = new AppPlatformMonitoringSettingData() + AppPlatformMonitoringSettingData data = new AppPlatformMonitoringSettingData { - Properties = new AppPlatformMonitoringSettingProperties() + Properties = new AppPlatformMonitoringSettingProperties { IsTraceEnabled = true, AppInsightsInstrumentationKey = "00000000-0000-0000-0000-000000000000", AppInsightsSamplingRate = 10, }, }; - ArmOperation lro = await appPlatformMonitoringSetting.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await appPlatformMonitoringSetting.CreateOrUpdateAsync(WaitUntil.Completed, data); AppPlatformMonitoringSettingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceCollection.cs index b727d24b5e01a..1c76dbcf64d86 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceCollection.cs @@ -17,109 +17,6 @@ namespace Azure.ResourceManager.AppPlatform.Samples { public partial class Sample_AppPlatformServiceCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ServicesGet() - { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Services_Get.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this AppPlatformServiceResource - AppPlatformServiceCollection collection = resourceGroupResource.GetAppPlatformServices(); - - // invoke the operation - string serviceName = "myservice"; - AppPlatformServiceResource result = await collection.GetAsync(serviceName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_ServicesGet() - { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Services_Get.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this AppPlatformServiceResource - AppPlatformServiceCollection collection = resourceGroupResource.GetAppPlatformServices(); - - // invoke the operation - string serviceName = "myservice"; - bool result = await collection.ExistsAsync(serviceName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServicesGet() - { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Services_Get.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this AppPlatformServiceResource - AppPlatformServiceCollection collection = resourceGroupResource.GetAppPlatformServices(); - - // invoke the operation - string serviceName = "myservice"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - AppPlatformServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_ServicesCreateOrUpdate() @@ -147,14 +44,14 @@ public async Task CreateOrUpdate_ServicesCreateOrUpdate() AppPlatformServiceData data = new AppPlatformServiceData(new AzureLocation("eastus")) { Properties = new AppPlatformServiceProperties(), - Sku = new AppPlatformSku() + Sku = new AppPlatformSku { Name = "S0", Tier = "Standard", }, Tags = { -["key1"] = "value1", +["key1"] = "value1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -194,14 +91,14 @@ public async Task CreateOrUpdate_ServicesCreateOrUpdateEnterprise() AppPlatformServiceData data = new AppPlatformServiceData(new AzureLocation("eastus")) { Properties = new AppPlatformServiceProperties(), - Sku = new AppPlatformSku() + Sku = new AppPlatformSku { Name = "E0", Tier = "Enterprise", }, Tags = { -["key1"] = "value1", +["key1"] = "value1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -240,9 +137,9 @@ public async Task CreateOrUpdate_ServicesCreateOrUpdateVNetInjection() string serviceName = "myservice"; AppPlatformServiceData data = new AppPlatformServiceData(new AzureLocation("eastus")) { - Properties = new AppPlatformServiceProperties() + Properties = new AppPlatformServiceProperties { - NetworkProfile = new AppPlatformServiceNetworkProfile() + NetworkProfile = new AppPlatformServiceNetworkProfile { ServiceRuntimeSubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVirtualNetwork/subnets/serviceRuntime"), AppSubnetId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myVirtualNetwork/subnets/apps"), @@ -253,14 +150,14 @@ public async Task CreateOrUpdate_ServicesCreateOrUpdateVNetInjection() }, IsLogStreamPublicEndpoint = true, }, - Sku = new AppPlatformSku() + Sku = new AppPlatformSku { Name = "S0", Tier = "Standard", }, Tags = { -["key1"] = "value1", +["key1"] = "value1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); @@ -273,6 +170,39 @@ public async Task CreateOrUpdate_ServicesCreateOrUpdateVNetInjection() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_ServicesGet() + { + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Services_Get.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AppPlatformServiceResource + AppPlatformServiceCollection collection = resourceGroupResource.GetAppPlatformServices(); + + // invoke the operation + string serviceName = "myservice"; + AppPlatformServiceResource result = await collection.GetAsync(serviceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ServicesList() @@ -307,5 +237,75 @@ public async Task GetAll_ServicesList() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_ServicesGet() + { + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Services_Get.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AppPlatformServiceResource + AppPlatformServiceCollection collection = resourceGroupResource.GetAppPlatformServices(); + + // invoke the operation + string serviceName = "myservice"; + bool result = await collection.ExistsAsync(serviceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_ServicesGet() + { + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Services_Get.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AppPlatformServiceResource + AppPlatformServiceCollection collection = resourceGroupResource.GetAppPlatformServices(); + + // invoke the operation + string serviceName = "myservice"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + AppPlatformServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceRegistryCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceRegistryCollection.cs index 4163a6a5805ab..cb6e60688c004 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceRegistryCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceRegistryCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppPlatformServiceRegistryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ServiceRegistriesGet() + public async Task CreateOrUpdate_ServiceRegistriesCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_Get.json - // this example is just showing the usage of "ServiceRegistries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_CreateOrUpdate.json + // this example is just showing the usage of "ServiceRegistries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,8 @@ public async Task Get_ServiceRegistriesGet() // invoke the operation string serviceRegistryName = "default"; - AppPlatformServiceRegistryResource result = await collection.GetAsync(serviceRegistryName); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceRegistryName); + AppPlatformServiceRegistryResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +52,7 @@ public async Task Get_ServiceRegistriesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServiceRegistriesGet() + public async Task Get_ServiceRegistriesGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_Get.json // this example is just showing the usage of "ServiceRegistries_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +75,21 @@ public async Task Exists_ServiceRegistriesGet() // invoke the operation string serviceRegistryName = "default"; - bool result = await collection.ExistsAsync(serviceRegistryName); + AppPlatformServiceRegistryResource result = await collection.GetAsync(serviceRegistryName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformServiceRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServiceRegistriesGet() + public async Task GetAll_ServiceRegistriesList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_Get.json - // this example is just showing the usage of "ServiceRegistries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_List.json + // this example is just showing the usage of "ServiceRegistries_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +107,25 @@ public async Task GetIfExists_ServiceRegistriesGet() // get the collection of this AppPlatformServiceRegistryResource AppPlatformServiceRegistryCollection collection = appPlatformService.GetAppPlatformServiceRegistries(); - // invoke the operation - string serviceRegistryName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(serviceRegistryName); - AppPlatformServiceRegistryResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformServiceRegistryResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformServiceRegistryData resourceData = result.Data; + AppPlatformServiceRegistryData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServiceRegistriesCreateOrUpdate() + public async Task Exists_ServiceRegistriesGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_CreateOrUpdate.json - // this example is just showing the usage of "ServiceRegistries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_Get.json + // this example is just showing the usage of "ServiceRegistries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,22 +145,17 @@ public async Task CreateOrUpdate_ServiceRegistriesCreateOrUpdate() // invoke the operation string serviceRegistryName = "default"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceRegistryName); - AppPlatformServiceRegistryResource result = lro.Value; + bool result = await collection.ExistsAsync(serviceRegistryName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformServiceRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServiceRegistriesList() + public async Task GetIfExists_ServiceRegistriesGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_List.json - // this example is just showing the usage of "ServiceRegistries_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_Get.json + // this example is just showing the usage of "ServiceRegistries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_ServiceRegistriesList() // get the collection of this AppPlatformServiceRegistryResource AppPlatformServiceRegistryCollection collection = appPlatformService.GetAppPlatformServiceRegistries(); - // invoke the operation and iterate over the result - await foreach (AppPlatformServiceRegistryResource item in collection.GetAllAsync()) + // invoke the operation + string serviceRegistryName = "default"; + NullableResponse response = await collection.GetIfExistsAsync(serviceRegistryName); + AppPlatformServiceRegistryResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformServiceRegistryData resourceData = item.Data; + AppPlatformServiceRegistryData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceRegistryResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceRegistryResource.cs index 32133e47d8084..7c968a107d620 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceRegistryResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceRegistryResource.cs @@ -48,10 +48,10 @@ public async Task Get_ServiceRegistriesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ServiceRegistriesCreateOrUpdate() + public async Task Delete_ServiceRegistriesDelete() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_CreateOrUpdate.json - // this example is just showing the usage of "ServiceRegistries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_Delete.json + // this example is just showing the usage of "ServiceRegistries_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,22 +68,17 @@ public async Task Update_ServiceRegistriesCreateOrUpdate() AppPlatformServiceRegistryResource appPlatformServiceRegistry = client.GetAppPlatformServiceRegistryResource(appPlatformServiceRegistryResourceId); // invoke the operation - ArmOperation lro = await appPlatformServiceRegistry.UpdateAsync(WaitUntil.Completed); - AppPlatformServiceRegistryResource result = lro.Value; + await appPlatformServiceRegistry.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformServiceRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ServiceRegistriesDelete() + public async Task Update_ServiceRegistriesCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_Delete.json - // this example is just showing the usage of "ServiceRegistries_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/ServiceRegistries_CreateOrUpdate.json + // this example is just showing the usage of "ServiceRegistries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,9 +95,14 @@ public async Task Delete_ServiceRegistriesDelete() AppPlatformServiceRegistryResource appPlatformServiceRegistry = client.GetAppPlatformServiceRegistryResource(appPlatformServiceRegistryResourceId); // invoke the operation - await appPlatformServiceRegistry.DeleteAsync(WaitUntil.Completed); + ArmOperation lro = await appPlatformServiceRegistry.UpdateAsync(WaitUntil.Completed); + AppPlatformServiceRegistryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformServiceRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceResource.cs index 0572661a23e87..f6cf2e1da537b 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppPlatform.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppPlatform.Samples @@ -97,14 +96,14 @@ public async Task Update_ServicesUpdate() AppPlatformServiceData data = new AppPlatformServiceData(new AzureLocation("eastus")) { Properties = new AppPlatformServiceProperties(), - Sku = new AppPlatformSku() + Sku = new AppPlatformSku { Name = "S0", Tier = "Standard", }, Tags = { -["key1"] = "value1", +["key1"] = "value1" }, }; ArmOperation lro = await appPlatformService.UpdateAsync(WaitUntil.Completed, data); @@ -274,63 +273,6 @@ public async Task Start_ServicesStart() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckAppPlatformNameAvailability_ServicesCheckNameAvailability() - { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Services_CheckNameAvailability.json - // this example is just showing the usage of "Services_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("eastus"); - AppPlatformNameAvailabilityContent content = new AppPlatformNameAvailabilityContent(new ResourceType("Microsoft.AppPlatform/Spring"), "myservice"); - AppPlatformNameAvailabilityResult result = await subscriptionResource.CheckAppPlatformNameAvailabilityAsync(location, content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAppPlatformServices_ServicesListBySubscription() - { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Services_ListBySubscription.json - // this example is just showing the usage of "Services_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AppPlatformServiceResource item in subscriptionResource.GetAppPlatformServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task ValidateConfigServer_ConfigServersValidate() @@ -352,15 +294,12 @@ public async Task ValidateConfigServer_ConfigServersValidate() AppPlatformServiceResource appPlatformService = client.GetAppPlatformServiceResource(appPlatformServiceResourceId); // invoke the operation - ConfigServerSettings settings = new ConfigServerSettings() + ConfigServerSettings settings = new ConfigServerSettings { GitProperty = new AppPlatformConfigServerGitProperty(new Uri("https://github.com/fake-user/fake-repository.git")) { Label = "master", - SearchPaths = -{ -"/" -}, + SearchPaths = { "/" }, }, }; ArmOperation lro = await appPlatformService.ValidateConfigServerAsync(WaitUntil.Completed, settings); diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformStorageCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformStorageCollection.cs index 57bbf858e2870..cf65676291bbc 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformStorageCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformStorageCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AppPlatformStorageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StoragesGet() + public async Task CreateOrUpdate_StoragesCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_Get.json - // this example is just showing the usage of "Storages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_CreateOrUpdate.json + // this example is just showing the usage of "Storages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_StoragesGet() // invoke the operation string storageName = "mystorage"; - AppPlatformStorageResource result = await collection.GetAsync(storageName); + AppPlatformStorageData data = new AppPlatformStorageData + { + Properties = new AppPlatformStorageAccount("storage-account-name", "account-key-of-storage-account"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageName, data); + AppPlatformStorageResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_StoragesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StoragesGet() + public async Task Get_StoragesGet() { // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_Get.json // this example is just showing the usage of "Storages_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_StoragesGet() // invoke the operation string storageName = "mystorage"; - bool result = await collection.ExistsAsync(storageName); + AppPlatformStorageResource result = await collection.GetAsync(storageName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformStorageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StoragesGet() + public async Task GetAll_StoragesList() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_Get.json - // this example is just showing the usage of "Storages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_List.json + // this example is just showing the usage of "Storages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,38 +105,32 @@ public async Task GetIfExists_StoragesGet() // for more information of creating AppPlatformServiceResource, please refer to the document of AppPlatformServiceResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "myResourceGroup"; - string serviceName = "myservice"; + string serviceName = "myService"; ResourceIdentifier appPlatformServiceResourceId = AppPlatformServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); AppPlatformServiceResource appPlatformService = client.GetAppPlatformServiceResource(appPlatformServiceResourceId); // get the collection of this AppPlatformStorageResource AppPlatformStorageCollection collection = appPlatformService.GetAppPlatformStorages(); - // invoke the operation - string storageName = "mystorage"; - NullableResponse response = await collection.GetIfExistsAsync(storageName); - AppPlatformStorageResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AppPlatformStorageResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformStorageData resourceData = result.Data; + AppPlatformStorageData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StoragesCreateOrUpdate() + public async Task Exists_StoragesGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_CreateOrUpdate.json - // this example is just showing the usage of "Storages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_Get.json + // this example is just showing the usage of "Storages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_StoragesCreateOrUpdate() // invoke the operation string storageName = "mystorage"; - AppPlatformStorageData data = new AppPlatformStorageData() - { - Properties = new AppPlatformStorageAccount("storage-account-name", "account-key-of-storage-account"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, storageName, data); - AppPlatformStorageResource result = lro.Value; + bool result = await collection.ExistsAsync(storageName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformStorageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StoragesList() + public async Task GetIfExists_StoragesGet() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_List.json - // this example is just showing the usage of "Storages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_Get.json + // this example is just showing the usage of "Storages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,24 +171,30 @@ public async Task GetAll_StoragesList() // for more information of creating AppPlatformServiceResource, please refer to the document of AppPlatformServiceResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "myResourceGroup"; - string serviceName = "myService"; + string serviceName = "myservice"; ResourceIdentifier appPlatformServiceResourceId = AppPlatformServiceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceName); AppPlatformServiceResource appPlatformService = client.GetAppPlatformServiceResource(appPlatformServiceResourceId); // get the collection of this AppPlatformStorageResource AppPlatformStorageCollection collection = appPlatformService.GetAppPlatformStorages(); - // invoke the operation and iterate over the result - await foreach (AppPlatformStorageResource item in collection.GetAllAsync()) + // invoke the operation + string storageName = "mystorage"; + NullableResponse response = await collection.GetIfExistsAsync(storageName); + AppPlatformStorageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AppPlatformStorageData resourceData = item.Data; + AppPlatformStorageData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformStorageResource.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformStorageResource.cs index 92466bc990fc7..b9c6fd379b1c5 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformStorageResource.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformStorageResource.cs @@ -49,10 +49,10 @@ public async Task Get_StoragesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_StoragesCreateOrUpdate() + public async Task Delete_StoragesDelete() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_CreateOrUpdate.json - // this example is just showing the usage of "Storages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_Delete.json + // this example is just showing the usage of "Storages_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_StoragesCreateOrUpdate() AppPlatformStorageResource appPlatformStorage = client.GetAppPlatformStorageResource(appPlatformStorageResourceId); // invoke the operation - AppPlatformStorageData data = new AppPlatformStorageData() - { - Properties = new AppPlatformStorageAccount("storage-account-name", "account-key-of-storage-account"), - }; - ArmOperation lro = await appPlatformStorage.UpdateAsync(WaitUntil.Completed, data); - AppPlatformStorageResource result = lro.Value; + await appPlatformStorage.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformStorageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_StoragesDelete() + public async Task Update_StoragesCreateOrUpdate() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_Delete.json - // this example is just showing the usage of "Storages_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Storages_CreateOrUpdate.json + // this example is just showing the usage of "Storages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_StoragesDelete() AppPlatformStorageResource appPlatformStorage = client.GetAppPlatformStorageResource(appPlatformStorageResourceId); // invoke the operation - await appPlatformStorage.DeleteAsync(WaitUntil.Completed); + AppPlatformStorageData data = new AppPlatformStorageData + { + Properties = new AppPlatformStorageAccount("storage-account-name", "account-key-of-storage-account"), + }; + ArmOperation lro = await appPlatformStorage.UpdateAsync(WaitUntil.Completed, data); + AppPlatformStorageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformStorageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformSupportedBuildpackCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformSupportedBuildpackCollection.cs index 22f9b69824424..1688279f3d5fd 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformSupportedBuildpackCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformSupportedBuildpackCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppPlatformSupportedBuildpackCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BuildServiceListSupportedBuildpacks() + public async Task Get_BuildServiceGetSupportedBuildpack() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_ListSupportedBuildpacks.json - // this example is just showing the usage of "BuildService_ListSupportedBuildpacks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetSupportedBuildpack.json + // this example is just showing the usage of "BuildService_GetSupportedBuildpack" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_BuildServiceListSupportedBuildpacks() // get the collection of this AppPlatformSupportedBuildpackResource AppPlatformSupportedBuildpackCollection collection = appPlatformBuildService.GetAppPlatformSupportedBuildpacks(); - // invoke the operation and iterate over the result - await foreach (AppPlatformSupportedBuildpackResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformSupportedBuildpackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string buildpackName = "tanzu-buildpacks-java-azure"; + AppPlatformSupportedBuildpackResource result = await collection.GetAsync(buildpackName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformSupportedBuildpackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BuildServiceGetSupportedBuildpack() + public async Task GetAll_BuildServiceListSupportedBuildpacks() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetSupportedBuildpack.json - // this example is just showing the usage of "BuildService_GetSupportedBuildpack" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_ListSupportedBuildpacks.json + // this example is just showing the usage of "BuildService_ListSupportedBuildpacks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_BuildServiceGetSupportedBuildpack() // get the collection of this AppPlatformSupportedBuildpackResource AppPlatformSupportedBuildpackCollection collection = appPlatformBuildService.GetAppPlatformSupportedBuildpacks(); - // invoke the operation - string buildpackName = "tanzu-buildpacks-java-azure"; - AppPlatformSupportedBuildpackResource result = await collection.GetAsync(buildpackName); + // invoke the operation and iterate over the result + await foreach (AppPlatformSupportedBuildpackResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformSupportedBuildpackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformSupportedBuildpackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformSupportedStackCollection.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformSupportedStackCollection.cs index 8c2ac284c9677..7035cc18cf023 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformSupportedStackCollection.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_AppPlatformSupportedStackCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AppPlatformSupportedStackCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BuildServiceListSupportedStacks() + public async Task Get_BuildServiceGetSupportedStack() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_ListSupportedStacks.json - // this example is just showing the usage of "BuildService_ListSupportedStacks" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetSupportedStack.json + // this example is just showing the usage of "BuildService_GetSupportedStack" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_BuildServiceListSupportedStacks() // get the collection of this AppPlatformSupportedStackResource AppPlatformSupportedStackCollection collection = appPlatformBuildService.GetAppPlatformSupportedStacks(); - // invoke the operation and iterate over the result - await foreach (AppPlatformSupportedStackResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformSupportedStackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string stackName = "io.buildpacks.stacks.bionic-base"; + AppPlatformSupportedStackResource result = await collection.GetAsync(stackName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformSupportedStackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BuildServiceGetSupportedStack() + public async Task GetAll_BuildServiceListSupportedStacks() { - // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_GetSupportedStack.json - // this example is just showing the usage of "BuildService_GetSupportedStack" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/BuildService_ListSupportedStacks.json + // this example is just showing the usage of "BuildService_ListSupportedStacks" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_BuildServiceGetSupportedStack() // get the collection of this AppPlatformSupportedStackResource AppPlatformSupportedStackCollection collection = appPlatformBuildService.GetAppPlatformSupportedStacks(); - // invoke the operation - string stackName = "io.buildpacks.stacks.bionic-base"; - AppPlatformSupportedStackResource result = await collection.GetAsync(stackName); + // invoke the operation and iterate over the result + await foreach (AppPlatformSupportedStackResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformSupportedStackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AppPlatformSupportedStackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index b24a15dea2067..87d9c46a58403 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,63 @@ namespace Azure.ResourceManager.AppPlatform.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckAppPlatformNameAvailability_ServicesCheckNameAvailability() + { + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Services_CheckNameAvailability.json + // this example is just showing the usage of "Services_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("eastus"); + AppPlatformNameAvailabilityContent content = new AppPlatformNameAvailabilityContent(new ResourceType("Microsoft.AppPlatform/Spring"), "myservice"); + AppPlatformNameAvailabilityResult result = await subscriptionResource.CheckAppPlatformNameAvailabilityAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAppPlatformServices_ServicesListBySubscription() + { + // Generated from example definition: specification/appplatform/resource-manager/Microsoft.AppPlatform/stable/2022-12-01/examples/Services_ListBySubscription.json + // this example is just showing the usage of "Services_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AppPlatformServiceResource item in subscriptionResource.GetAppPlatformServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AppPlatformServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetSkus_SkusList() diff --git a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index d371504080f80..afe158454ae48 100644 --- a/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/appplatform/Azure.ResourceManager.AppPlatform/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.AppPlatform.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.AppPlatform.Samples @@ -28,9 +29,7 @@ public async Task GetRuntimeVersions_RuntimeVersionsListRuntimeVersions() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (AppPlatformSupportedRuntimeVersion item in tenantResource.GetRuntimeVersionsAsync()) diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmAvailabilitySetCollection.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmAvailabilitySetCollection.cs index aa2c4fb74af94..b6a4c0e3fe039 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmAvailabilitySetCollection.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmAvailabilitySetCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ScVmmAvailabilitySetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAvailabilitySet() + public async Task CreateOrUpdate_CreateAvailabilitySet() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetAvailabilitySet.json - // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateAvailabilitySet.json + // this example is just showing the usage of "AvailabilitySets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_GetAvailabilitySet() // invoke the operation string availabilitySetResourceName = "HRAvailabilitySet"; - ScVmmAvailabilitySetResource result = await collection.GetAsync(availabilitySetResourceName); + ScVmmAvailabilitySetData data = new ScVmmAvailabilitySetData(new AzureLocation("East US"), new ExtendedLocation + { + Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso", + }) + { + AvailabilitySetName = "hr-avset", + VmmServerId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/VMMServers/ContosoVMMServer"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, availabilitySetResourceName, data); + ScVmmAvailabilitySetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_GetAvailabilitySet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAvailabilitySet() + public async Task Get_GetAvailabilitySet() { // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetAvailabilitySet.json // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +83,21 @@ public async Task Exists_GetAvailabilitySet() // invoke the operation string availabilitySetResourceName = "HRAvailabilitySet"; - bool result = await collection.ExistsAsync(availabilitySetResourceName); + ScVmmAvailabilitySetResource result = await collection.GetAsync(availabilitySetResourceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmAvailabilitySetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAvailabilitySet() + public async Task GetAll_ListAvailabilitySetsByResourceGroup() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetAvailabilitySet.json - // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListAvailabilitySetsByResourceGroup.json + // this example is just showing the usage of "AvailabilitySets_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +114,25 @@ public async Task GetIfExists_GetAvailabilitySet() // get the collection of this ScVmmAvailabilitySetResource ScVmmAvailabilitySetCollection collection = resourceGroupResource.GetScVmmAvailabilitySets(); - // invoke the operation - string availabilitySetResourceName = "HRAvailabilitySet"; - NullableResponse response = await collection.GetIfExistsAsync(availabilitySetResourceName); - ScVmmAvailabilitySetResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ScVmmAvailabilitySetResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmAvailabilitySetData resourceData = result.Data; + ScVmmAvailabilitySetData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAvailabilitySet() + public async Task Exists_GetAvailabilitySet() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateAvailabilitySet.json - // this example is just showing the usage of "AvailabilitySets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetAvailabilitySet.json + // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,30 +151,17 @@ public async Task CreateOrUpdate_CreateAvailabilitySet() // invoke the operation string availabilitySetResourceName = "HRAvailabilitySet"; - ScVmmAvailabilitySetData data = new ScVmmAvailabilitySetData(new AzureLocation("East US"), new ExtendedLocation() - { - Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso", - }) - { - AvailabilitySetName = "hr-avset", - VmmServerId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.ScVmm/VMMServers/ContosoVMMServer"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, availabilitySetResourceName, data); - ScVmmAvailabilitySetResource result = lro.Value; + bool result = await collection.ExistsAsync(availabilitySetResourceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmAvailabilitySetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAvailabilitySetsByResourceGroup() + public async Task GetIfExists_GetAvailabilitySet() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListAvailabilitySetsByResourceGroup.json - // this example is just showing the usage of "AvailabilitySets_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetAvailabilitySet.json + // this example is just showing the usage of "AvailabilitySets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListAvailabilitySetsByResourceGroup() // get the collection of this ScVmmAvailabilitySetResource ScVmmAvailabilitySetCollection collection = resourceGroupResource.GetScVmmAvailabilitySets(); - // invoke the operation and iterate over the result - await foreach (ScVmmAvailabilitySetResource item in collection.GetAllAsync()) + // invoke the operation + string availabilitySetResourceName = "HRAvailabilitySet"; + NullableResponse response = await collection.GetIfExistsAsync(availabilitySetResourceName); + ScVmmAvailabilitySetResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmAvailabilitySetData resourceData = item.Data; + ScVmmAvailabilitySetData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmAvailabilitySetResource.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmAvailabilitySetResource.cs index 4148c220c939e..0443410e5bcf4 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmAvailabilitySetResource.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmAvailabilitySetResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.ScVmm.Models; using NUnit.Framework; @@ -94,12 +93,12 @@ public async Task Update_UpdateAvailabilitySet() ScVmmAvailabilitySetResource scVmmAvailabilitySet = client.GetScVmmAvailabilitySetResource(scVmmAvailabilitySetResourceId); // invoke the operation - ScVmmResourcePatch patch = new ScVmmResourcePatch() + ScVmmResourcePatch patch = new ScVmmResourcePatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await scVmmAvailabilitySet.UpdateAsync(WaitUntil.Completed, patch); @@ -111,36 +110,5 @@ public async Task Update_UpdateAvailabilitySet() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetScVmmAvailabilitySets_ListAvailabilitySetsBySubscription() - { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListAvailabilitySetsBySubscription.json - // this example is just showing the usage of "AvailabilitySets_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ScVmmAvailabilitySetResource item in subscriptionResource.GetScVmmAvailabilitySetsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmAvailabilitySetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmCloudCollection.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmCloudCollection.cs index b809a0050ee3c..54039ff36df80 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmCloudCollection.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmCloudCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ScVmmCloudCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCloud() + public async Task CreateOrUpdate_CreateCloud() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetCloud.json - // this example is just showing the usage of "Clouds_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateCloud.json + // this example is just showing the usage of "Clouds_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_GetCloud() // invoke the operation string cloudResourceName = "HRCloud"; - ScVmmCloudResource result = await collection.GetAsync(cloudResourceName); + ScVmmCloudData data = new ScVmmCloudData(new AzureLocation("East US"), new ExtendedLocation + { + Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso", + }) + { + Uuid = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", + VmmServerId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudResourceName, data); + ScVmmCloudResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_GetCloud() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCloud() + public async Task Get_GetCloud() { // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetCloud.json // this example is just showing the usage of "Clouds_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +83,21 @@ public async Task Exists_GetCloud() // invoke the operation string cloudResourceName = "HRCloud"; - bool result = await collection.ExistsAsync(cloudResourceName); + ScVmmCloudResource result = await collection.GetAsync(cloudResourceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmCloudData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCloud() + public async Task GetAll_ListCloudsByResourceGroup() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetCloud.json - // this example is just showing the usage of "Clouds_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListCloudsByResourceGroup.json + // this example is just showing the usage of "Clouds_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +114,25 @@ public async Task GetIfExists_GetCloud() // get the collection of this ScVmmCloudResource ScVmmCloudCollection collection = resourceGroupResource.GetScVmmClouds(); - // invoke the operation - string cloudResourceName = "HRCloud"; - NullableResponse response = await collection.GetIfExistsAsync(cloudResourceName); - ScVmmCloudResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ScVmmCloudResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmCloudData resourceData = result.Data; + ScVmmCloudData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCloud() + public async Task Exists_GetCloud() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateCloud.json - // this example is just showing the usage of "Clouds_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetCloud.json + // this example is just showing the usage of "Clouds_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,30 +151,17 @@ public async Task CreateOrUpdate_CreateCloud() // invoke the operation string cloudResourceName = "HRCloud"; - ScVmmCloudData data = new ScVmmCloudData(new AzureLocation("East US"), new ExtendedLocation() - { - Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso", - }) - { - Uuid = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", - VmmServerId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudResourceName, data); - ScVmmCloudResource result = lro.Value; + bool result = await collection.ExistsAsync(cloudResourceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmCloudData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCloudsByResourceGroup() + public async Task GetIfExists_GetCloud() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListCloudsByResourceGroup.json - // this example is just showing the usage of "Clouds_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetCloud.json + // this example is just showing the usage of "Clouds_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListCloudsByResourceGroup() // get the collection of this ScVmmCloudResource ScVmmCloudCollection collection = resourceGroupResource.GetScVmmClouds(); - // invoke the operation and iterate over the result - await foreach (ScVmmCloudResource item in collection.GetAllAsync()) + // invoke the operation + string cloudResourceName = "HRCloud"; + NullableResponse response = await collection.GetIfExistsAsync(cloudResourceName); + ScVmmCloudResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmCloudData resourceData = item.Data; + ScVmmCloudData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmCloudResource.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmCloudResource.cs index 972b5271d58b7..8e07db3a2234a 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmCloudResource.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmCloudResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.ScVmm.Models; using NUnit.Framework; @@ -94,12 +93,12 @@ public async Task Update_UpdateCloud() ScVmmCloudResource scVmmCloud = client.GetScVmmCloudResource(scVmmCloudResourceId); // invoke the operation - ScVmmResourcePatch patch = new ScVmmResourcePatch() + ScVmmResourcePatch patch = new ScVmmResourcePatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await scVmmCloud.UpdateAsync(WaitUntil.Completed, patch); @@ -111,36 +110,5 @@ public async Task Update_UpdateCloud() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetScVmmClouds_ListCloudsBySubscription() - { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListCloudsBySubscription.json - // this example is just showing the usage of "Clouds_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ScVmmCloudResource item in subscriptionResource.GetScVmmCloudsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmCloudData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmGuestAgentResource.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmGuestAgentResource.cs index 9e12de5ebbe21..e60be65570fc4 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmGuestAgentResource.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmGuestAgentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ScVmmGuestAgentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateGuestAgent() + public async Task Get_GetGuestAgent() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateVMInstanceGuestAgent.json - // this example is just showing the usage of "VMInstanceGuestAgents_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVMInstanceGuestAgent.json + // this example is just showing the usage of "VMInstanceGuestAgents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,14 +35,7 @@ public async Task CreateOrUpdate_CreateGuestAgent() ScVmmGuestAgentResource scVmmGuestAgent = client.GetScVmmGuestAgentResource(scVmmGuestAgentResourceId); // invoke the operation - ScVmmGuestAgentData data = new ScVmmGuestAgentData() - { - Credentials = new ScVmmGuestCredential("tempuser", ""), - HttpsProxy = "http://192.1.2.3:8080", - ProvisioningAction = ScVmmProvisioningAction.Install, - }; - ArmOperation lro = await scVmmGuestAgent.CreateOrUpdateAsync(WaitUntil.Completed, data); - ScVmmGuestAgentResource result = lro.Value; + ScVmmGuestAgentResource result = await scVmmGuestAgent.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +46,10 @@ public async Task CreateOrUpdate_CreateGuestAgent() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetGuestAgent() + public async Task Delete_DeleteGuestAgent() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVMInstanceGuestAgent.json - // this example is just showing the usage of "VMInstanceGuestAgents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/DeleteVMInstanceGuestAgent.json + // this example is just showing the usage of "VMInstanceGuestAgents_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,21 +63,17 @@ public async Task Get_GetGuestAgent() ScVmmGuestAgentResource scVmmGuestAgent = client.GetScVmmGuestAgentResource(scVmmGuestAgentResourceId); // invoke the operation - ScVmmGuestAgentResource result = await scVmmGuestAgent.GetAsync(); + await scVmmGuestAgent.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmGuestAgentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteGuestAgent() + public async Task CreateOrUpdate_CreateGuestAgent() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/DeleteVMInstanceGuestAgent.json - // this example is just showing the usage of "VMInstanceGuestAgents_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateVMInstanceGuestAgent.json + // this example is just showing the usage of "VMInstanceGuestAgents_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,9 +87,20 @@ public async Task Delete_DeleteGuestAgent() ScVmmGuestAgentResource scVmmGuestAgent = client.GetScVmmGuestAgentResource(scVmmGuestAgentResourceId); // invoke the operation - await scVmmGuestAgent.DeleteAsync(WaitUntil.Completed); + ScVmmGuestAgentData data = new ScVmmGuestAgentData + { + Credentials = new ScVmmGuestCredential("tempuser", ""), + HttpsProxy = "http://192.1.2.3:8080", + ProvisioningAction = ScVmmProvisioningAction.Install, + }; + ArmOperation lro = await scVmmGuestAgent.CreateOrUpdateAsync(WaitUntil.Completed, data); + ScVmmGuestAgentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmGuestAgentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmInventoryItemCollection.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmInventoryItemCollection.cs index 1fb918ced98d8..f71e5e6e16b9a 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmInventoryItemCollection.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmInventoryItemCollection.cs @@ -88,10 +88,10 @@ public async Task Get_GetInventoryItem() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetInventoryItem() + public async Task GetAll_InventoryItemsListByVMMServer() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetInventoryItem.json - // this example is just showing the usage of "InventoryItems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListInventoryItemsByVMMServer.json + // this example is just showing the usage of "InventoryItems_ListByVmmServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_GetInventoryItem() // get the collection of this ScVmmInventoryItemResource ScVmmInventoryItemCollection collection = scVmmServer.GetScVmmInventoryItems(); - // invoke the operation - string inventoryItemResourceName = "12345678-1234-1234-1234-123456789abc"; - bool result = await collection.ExistsAsync(inventoryItemResourceName); + // invoke the operation and iterate over the result + await foreach (ScVmmInventoryItemResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmInventoryItemData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetInventoryItem() + public async Task Exists_GetInventoryItem() { // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetInventoryItem.json // this example is just showing the usage of "InventoryItems_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_GetInventoryItem() // invoke the operation string inventoryItemResourceName = "12345678-1234-1234-1234-123456789abc"; - NullableResponse response = await collection.GetIfExistsAsync(inventoryItemResourceName); - ScVmmInventoryItemResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(inventoryItemResourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmInventoryItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InventoryItemsListByVMMServer() + public async Task GetIfExists_GetInventoryItem() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListInventoryItemsByVMMServer.json - // this example is just showing the usage of "InventoryItems_ListByVmmServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetInventoryItem.json + // this example is just showing the usage of "InventoryItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_InventoryItemsListByVMMServer() // get the collection of this ScVmmInventoryItemResource ScVmmInventoryItemCollection collection = scVmmServer.GetScVmmInventoryItems(); - // invoke the operation and iterate over the result - await foreach (ScVmmInventoryItemResource item in collection.GetAllAsync()) + // invoke the operation + string inventoryItemResourceName = "12345678-1234-1234-1234-123456789abc"; + NullableResponse response = await collection.GetIfExistsAsync(inventoryItemResourceName); + ScVmmInventoryItemResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmInventoryItemData resourceData = item.Data; + ScVmmInventoryItemData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmInventoryItemResource.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmInventoryItemResource.cs index 01638f172536c..618b0eeaf628f 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmInventoryItemResource.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmInventoryItemResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ScVmmInventoryItemResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateInventoryItem() + public async Task Get_GetInventoryItem() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateInventoryItem.json - // this example is just showing the usage of "InventoryItems_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetInventoryItem.json + // this example is just showing the usage of "InventoryItems_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Update_CreateInventoryItem() ScVmmInventoryItemResource scVmmInventoryItem = client.GetScVmmInventoryItemResource(scVmmInventoryItemResourceId); // invoke the operation - ScVmmInventoryItemData data = new ScVmmInventoryItemData(new CloudInventoryItem()); - ArmOperation lro = await scVmmInventoryItem.UpdateAsync(WaitUntil.Completed, data); - ScVmmInventoryItemResource result = lro.Value; + ScVmmInventoryItemResource result = await scVmmInventoryItem.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +49,10 @@ public async Task Update_CreateInventoryItem() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetInventoryItem() + public async Task Delete_DeleteInventoryItem() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetInventoryItem.json - // this example is just showing the usage of "InventoryItems_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/DeleteInventoryItem.json + // this example is just showing the usage of "InventoryItems_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,21 +69,17 @@ public async Task Get_GetInventoryItem() ScVmmInventoryItemResource scVmmInventoryItem = client.GetScVmmInventoryItemResource(scVmmInventoryItemResourceId); // invoke the operation - ScVmmInventoryItemResource result = await scVmmInventoryItem.GetAsync(); + await scVmmInventoryItem.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmInventoryItemData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteInventoryItem() + public async Task Update_CreateInventoryItem() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/DeleteInventoryItem.json - // this example is just showing the usage of "InventoryItems_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateInventoryItem.json + // this example is just showing the usage of "InventoryItems_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_DeleteInventoryItem() ScVmmInventoryItemResource scVmmInventoryItem = client.GetScVmmInventoryItemResource(scVmmInventoryItemResourceId); // invoke the operation - await scVmmInventoryItem.DeleteAsync(WaitUntil.Completed); + ScVmmInventoryItemData data = new ScVmmInventoryItemData(new CloudInventoryItem()); + ArmOperation lro = await scVmmInventoryItem.UpdateAsync(WaitUntil.Completed, data); + ScVmmInventoryItemResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmInventoryItemData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmServerCollection.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmServerCollection.cs index bbedf752b44a9..4bc6c51ad22b1 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmServerCollection.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmServerCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_ScVmmServerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVMMServer() + public async Task CreateOrUpdate_CreateVMMServer() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVMMServer.json - // this example is just showing the usage of "VmmServers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateVMMServer.json + // this example is just showing the usage of "VmmServers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,20 @@ public async Task Get_GetVMMServer() // invoke the operation string vmmServerName = "ContosoVMMServer"; - ScVmmServerResource result = await collection.GetAsync(vmmServerName); + ScVmmServerData data = new ScVmmServerData(new AzureLocation("East US"), new ExtendedLocation + { + Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso", + }, "VMM.contoso.com") + { + Credentials = new VmmCredential + { + Username = "testuser", + Password = "password", + }, + Port = 1234, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmmServerName, data); + ScVmmServerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +66,7 @@ public async Task Get_GetVMMServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVMMServer() + public async Task Get_GetVMMServer() { // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVMMServer.json // this example is just showing the usage of "VmmServers_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +88,21 @@ public async Task Exists_GetVMMServer() // invoke the operation string vmmServerName = "ContosoVMMServer"; - bool result = await collection.ExistsAsync(vmmServerName); + ScVmmServerResource result = await collection.GetAsync(vmmServerName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVMMServer() + public async Task GetAll_ListVmmServersByResourceGroup() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVMMServer.json - // this example is just showing the usage of "VmmServers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVMMServersByResourceGroup.json + // this example is just showing the usage of "VmmServers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +119,25 @@ public async Task GetIfExists_GetVMMServer() // get the collection of this ScVmmServerResource ScVmmServerCollection collection = resourceGroupResource.GetScVmmServers(); - // invoke the operation - string vmmServerName = "ContosoVMMServer"; - NullableResponse response = await collection.GetIfExistsAsync(vmmServerName); - ScVmmServerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ScVmmServerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmServerData resourceData = result.Data; + ScVmmServerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVMMServer() + public async Task Exists_GetVMMServer() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateVMMServer.json - // this example is just showing the usage of "VmmServers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVMMServer.json + // this example is just showing the usage of "VmmServers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,34 +156,17 @@ public async Task CreateOrUpdate_CreateVMMServer() // invoke the operation string vmmServerName = "ContosoVMMServer"; - ScVmmServerData data = new ScVmmServerData(new AzureLocation("East US"), new ExtendedLocation() - { - Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso", - }, "VMM.contoso.com") - { - Credentials = new VmmCredential() - { - Username = "testuser", - Password = "password", - }, - Port = 1234, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmmServerName, data); - ScVmmServerResource result = lro.Value; + bool result = await collection.ExistsAsync(vmmServerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVmmServersByResourceGroup() + public async Task GetIfExists_GetVMMServer() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVMMServersByResourceGroup.json - // this example is just showing the usage of "VmmServers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVMMServer.json + // this example is just showing the usage of "VmmServers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_ListVmmServersByResourceGroup() // get the collection of this ScVmmServerResource ScVmmServerCollection collection = resourceGroupResource.GetScVmmServers(); - // invoke the operation and iterate over the result - await foreach (ScVmmServerResource item in collection.GetAllAsync()) + // invoke the operation + string vmmServerName = "ContosoVMMServer"; + NullableResponse response = await collection.GetIfExistsAsync(vmmServerName); + ScVmmServerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmServerData resourceData = item.Data; + ScVmmServerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmServerResource.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmServerResource.cs index bd896023bc262..d0911f7808c38 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmServerResource.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmServerResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.ScVmm.Models; using NUnit.Framework; @@ -94,12 +93,12 @@ public async Task Update_UpdateVMMServer() ScVmmServerResource scVmmServer = client.GetScVmmServerResource(scVmmServerResourceId); // invoke the operation - ScVmmResourcePatch patch = new ScVmmResourcePatch() + ScVmmResourcePatch patch = new ScVmmResourcePatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await scVmmServer.UpdateAsync(WaitUntil.Completed, patch); @@ -111,36 +110,5 @@ public async Task Update_UpdateVMMServer() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetScVmmServers_ListVmmServersBySubscription() - { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVMMServersBySubscription.json - // this example is just showing the usage of "VmmServers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ScVmmServerResource item in subscriptionResource.GetScVmmServersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineInstanceResource.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineInstanceResource.cs index 3bcff682f4064..bf0037cfb3030 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineInstanceResource.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineInstanceResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetVirtualMachine() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualMachine() + public async Task Delete_DeleteVirtualMachine() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateVirtualMachineInstance.json - // this example is just showing the usage of "VirtualMachineInstances_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/DeleteVirtualMachineInstance.json + // this example is just showing the usage of "VirtualMachineInstances_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,31 +64,9 @@ public async Task CreateOrUpdate_CreateVirtualMachine() ScVmmVirtualMachineInstanceResource scVmmVirtualMachineInstance = client.GetScVmmVirtualMachineInstanceResource(scVmmVirtualMachineInstanceResourceId); // invoke the operation - ScVmmVirtualMachineInstanceData data = new ScVmmVirtualMachineInstanceData(new ExtendedLocation() - { - Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", - }) - { - HardwareProfile = new ScVmmHardwareProfile() - { - MemoryMB = 4196, - CpuCount = 4, - }, - InfrastructureProfile = new ScVmmInfrastructureProfile() - { - VmmServerId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - CloudId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), - TemplateId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), - }, - }; - ArmOperation lro = await scVmmVirtualMachineInstance.CreateOrUpdateAsync(WaitUntil.Completed, data); - ScVmmVirtualMachineInstanceResource result = lro.Value; + await scVmmVirtualMachineInstance.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmVirtualMachineInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -110,9 +88,9 @@ public async Task Update_UpdateVirtualMachine() ScVmmVirtualMachineInstanceResource scVmmVirtualMachineInstance = client.GetScVmmVirtualMachineInstanceResource(scVmmVirtualMachineInstanceResourceId); // invoke the operation - ScVmmVirtualMachineInstancePatch patch = new ScVmmVirtualMachineInstancePatch() + ScVmmVirtualMachineInstancePatch patch = new ScVmmVirtualMachineInstancePatch { - HardwareProfile = new ScVmmHardwareProfileUpdate() + HardwareProfile = new ScVmmHardwareProfileUpdate { MemoryMB = 4196, CpuCount = 4, @@ -130,10 +108,10 @@ public async Task Update_UpdateVirtualMachine() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualMachine() + public async Task CreateOrUpdate_CreateVirtualMachine() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/DeleteVirtualMachineInstance.json - // this example is just showing the usage of "VirtualMachineInstances_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateVirtualMachineInstance.json + // this example is just showing the usage of "VirtualMachineInstances_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,9 +125,31 @@ public async Task Delete_DeleteVirtualMachine() ScVmmVirtualMachineInstanceResource scVmmVirtualMachineInstance = client.GetScVmmVirtualMachineInstanceResource(scVmmVirtualMachineInstanceResourceId); // invoke the operation - await scVmmVirtualMachineInstance.DeleteAsync(WaitUntil.Completed); + ScVmmVirtualMachineInstanceData data = new ScVmmVirtualMachineInstanceData(new ExtendedLocation + { + Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.ExtendedLocation/customLocations/contoso", + }) + { + HardwareProfile = new ScVmmHardwareProfile + { + MemoryMB = 4196, + CpuCount = 4, + }, + InfrastructureProfile = new ScVmmInfrastructureProfile + { + VmmServerId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), + CloudId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/Clouds/HRCloud"), + TemplateId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VirtualMachineTemplates/HRVirtualMachineTemplate"), + }, + }; + ArmOperation lro = await scVmmVirtualMachineInstance.CreateOrUpdateAsync(WaitUntil.Completed, data); + ScVmmVirtualMachineInstanceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmVirtualMachineInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -171,7 +171,7 @@ public async Task Stop_StopVirtualMachine() ScVmmVirtualMachineInstanceResource scVmmVirtualMachineInstance = client.GetScVmmVirtualMachineInstanceResource(scVmmVirtualMachineInstanceResourceId); // invoke the operation - StopVirtualMachineContent content = new StopVirtualMachineContent() + StopVirtualMachineContent content = new StopVirtualMachineContent { SkipShutdown = SkipShutdown.True, }; @@ -247,7 +247,7 @@ public async Task CreateCheckpoint_CreateCheckpointVirtualMachine() ScVmmVirtualMachineInstanceResource scVmmVirtualMachineInstance = client.GetScVmmVirtualMachineInstanceResource(scVmmVirtualMachineInstanceResourceId); // invoke the operation - VirtualMachineCreateCheckpointContent content = new VirtualMachineCreateCheckpointContent() + VirtualMachineCreateCheckpointContent content = new VirtualMachineCreateCheckpointContent { Name = "Demo Checkpoint name", Description = "Demo Checkpoint description", @@ -276,7 +276,7 @@ public async Task DeleteCheckpoint_DeleteCheckpointVirtualMachine() ScVmmVirtualMachineInstanceResource scVmmVirtualMachineInstance = client.GetScVmmVirtualMachineInstanceResource(scVmmVirtualMachineInstanceResourceId); // invoke the operation - VirtualMachineDeleteCheckpointContent content = new VirtualMachineDeleteCheckpointContent() + VirtualMachineDeleteCheckpointContent content = new VirtualMachineDeleteCheckpointContent { Id = "Demo CheckpointID", }; @@ -304,7 +304,7 @@ public async Task RestoreCheckpoint_RestoreCheckpointVirtualMachine() ScVmmVirtualMachineInstanceResource scVmmVirtualMachineInstance = client.GetScVmmVirtualMachineInstanceResource(scVmmVirtualMachineInstanceResourceId); // invoke the operation - VirtualMachineRestoreCheckpointContent content = new VirtualMachineRestoreCheckpointContent() + VirtualMachineRestoreCheckpointContent content = new VirtualMachineRestoreCheckpointContent { Id = "Demo CheckpointID", }; diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineTemplateCollection.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineTemplateCollection.cs index 216b16ac32e02..74a6a73b816b0 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineTemplateCollection.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineTemplateCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ScVmmVirtualMachineTemplateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualMachineTemplate() + public async Task CreateOrUpdate_CreateVirtualMachineTemplate() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVirtualMachineTemplate.json - // this example is just showing the usage of "VirtualMachineTemplates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateVirtualMachineTemplate.json + // this example is just showing the usage of "VirtualMachineTemplates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_GetVirtualMachineTemplate() // invoke the operation string virtualMachineTemplateName = "HRVirtualMachineTemplate"; - ScVmmVirtualMachineTemplateResource result = await collection.GetAsync(virtualMachineTemplateName); + ScVmmVirtualMachineTemplateData data = new ScVmmVirtualMachineTemplateData(new AzureLocation("East US"), new ExtendedLocation + { + Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso", + }) + { + Uuid = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", + VmmServerId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineTemplateName, data); + ScVmmVirtualMachineTemplateResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_GetVirtualMachineTemplate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualMachineTemplate() + public async Task Get_GetVirtualMachineTemplate() { // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVirtualMachineTemplate.json // this example is just showing the usage of "VirtualMachineTemplates_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +83,21 @@ public async Task Exists_GetVirtualMachineTemplate() // invoke the operation string virtualMachineTemplateName = "HRVirtualMachineTemplate"; - bool result = await collection.ExistsAsync(virtualMachineTemplateName); + ScVmmVirtualMachineTemplateResource result = await collection.GetAsync(virtualMachineTemplateName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmVirtualMachineTemplateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualMachineTemplate() + public async Task GetAll_ListVirtualMachineTemplatesByResourceGroup() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVirtualMachineTemplate.json - // this example is just showing the usage of "VirtualMachineTemplates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVirtualMachineTemplatesByResourceGroup.json + // this example is just showing the usage of "VirtualMachineTemplates_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +114,25 @@ public async Task GetIfExists_GetVirtualMachineTemplate() // get the collection of this ScVmmVirtualMachineTemplateResource ScVmmVirtualMachineTemplateCollection collection = resourceGroupResource.GetScVmmVirtualMachineTemplates(); - // invoke the operation - string virtualMachineTemplateName = "HRVirtualMachineTemplate"; - NullableResponse response = await collection.GetIfExistsAsync(virtualMachineTemplateName); - ScVmmVirtualMachineTemplateResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ScVmmVirtualMachineTemplateResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmVirtualMachineTemplateData resourceData = result.Data; + ScVmmVirtualMachineTemplateData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualMachineTemplate() + public async Task Exists_GetVirtualMachineTemplate() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateVirtualMachineTemplate.json - // this example is just showing the usage of "VirtualMachineTemplates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVirtualMachineTemplate.json + // this example is just showing the usage of "VirtualMachineTemplates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,30 +151,17 @@ public async Task CreateOrUpdate_CreateVirtualMachineTemplate() // invoke the operation string virtualMachineTemplateName = "HRVirtualMachineTemplate"; - ScVmmVirtualMachineTemplateData data = new ScVmmVirtualMachineTemplateData(new AzureLocation("East US"), new ExtendedLocation() - { - Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso", - }) - { - Uuid = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", - VmmServerId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualMachineTemplateName, data); - ScVmmVirtualMachineTemplateResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualMachineTemplateName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmVirtualMachineTemplateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualMachineTemplatesByResourceGroup() + public async Task GetIfExists_GetVirtualMachineTemplate() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVirtualMachineTemplatesByResourceGroup.json - // this example is just showing the usage of "VirtualMachineTemplates_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVirtualMachineTemplate.json + // this example is just showing the usage of "VirtualMachineTemplates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListVirtualMachineTemplatesByResourceGroup() // get the collection of this ScVmmVirtualMachineTemplateResource ScVmmVirtualMachineTemplateCollection collection = resourceGroupResource.GetScVmmVirtualMachineTemplates(); - // invoke the operation and iterate over the result - await foreach (ScVmmVirtualMachineTemplateResource item in collection.GetAllAsync()) + // invoke the operation + string virtualMachineTemplateName = "HRVirtualMachineTemplate"; + NullableResponse response = await collection.GetIfExistsAsync(virtualMachineTemplateName); + ScVmmVirtualMachineTemplateResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmVirtualMachineTemplateData resourceData = item.Data; + ScVmmVirtualMachineTemplateData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineTemplateResource.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineTemplateResource.cs index 7d39d8b8439cd..ca91579c73d9c 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineTemplateResource.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualMachineTemplateResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.ScVmm.Models; using NUnit.Framework; @@ -94,12 +93,12 @@ public async Task Update_UpdateVirtualMachineTemplate() ScVmmVirtualMachineTemplateResource scVmmVirtualMachineTemplate = client.GetScVmmVirtualMachineTemplateResource(scVmmVirtualMachineTemplateResourceId); // invoke the operation - ScVmmResourcePatch patch = new ScVmmResourcePatch() + ScVmmResourcePatch patch = new ScVmmResourcePatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await scVmmVirtualMachineTemplate.UpdateAsync(WaitUntil.Completed, patch); @@ -111,36 +110,5 @@ public async Task Update_UpdateVirtualMachineTemplate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetScVmmVirtualMachineTemplates_ListVirtualMachineTemplatesBySubscription() - { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVirtualMachineTemplatesBySubscription.json - // this example is just showing the usage of "VirtualMachineTemplates_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ScVmmVirtualMachineTemplateResource item in subscriptionResource.GetScVmmVirtualMachineTemplatesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmVirtualMachineTemplateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualNetworkCollection.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualNetworkCollection.cs index 549ddfd8ef1cd..de88f0696fd9f 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualNetworkCollection.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualNetworkCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ScVmmVirtualNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetwork() + public async Task CreateOrUpdate_CreateVirtualNetwork() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVirtualNetwork.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateVirtualNetwork.json + // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_GetVirtualNetwork() // invoke the operation string virtualNetworkName = "HRVirtualNetwork"; - ScVmmVirtualNetworkResource result = await collection.GetAsync(virtualNetworkName); + ScVmmVirtualNetworkData data = new ScVmmVirtualNetworkData(new AzureLocation("East US"), new ExtendedLocation + { + Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso", + }) + { + Uuid = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", + VmmServerId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); + ScVmmVirtualNetworkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_GetVirtualNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetwork() + public async Task Get_GetVirtualNetwork() { // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVirtualNetwork.json // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +83,21 @@ public async Task Exists_GetVirtualNetwork() // invoke the operation string virtualNetworkName = "HRVirtualNetwork"; - bool result = await collection.ExistsAsync(virtualNetworkName); + ScVmmVirtualNetworkResource result = await collection.GetAsync(virtualNetworkName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmVirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetwork() + public async Task GetAll_ListVirtualNetworksByResourceGroup() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVirtualNetwork.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVirtualNetworksByResourceGroup.json + // this example is just showing the usage of "VirtualNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +114,25 @@ public async Task GetIfExists_GetVirtualNetwork() // get the collection of this ScVmmVirtualNetworkResource ScVmmVirtualNetworkCollection collection = resourceGroupResource.GetScVmmVirtualNetworks(); - // invoke the operation - string virtualNetworkName = "HRVirtualNetwork"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); - ScVmmVirtualNetworkResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ScVmmVirtualNetworkResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmVirtualNetworkData resourceData = result.Data; + ScVmmVirtualNetworkData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetwork() + public async Task Exists_GetVirtualNetwork() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/CreateVirtualNetwork.json - // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVirtualNetwork.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,30 +151,17 @@ public async Task CreateOrUpdate_CreateVirtualNetwork() // invoke the operation string virtualNetworkName = "HRVirtualNetwork"; - ScVmmVirtualNetworkData data = new ScVmmVirtualNetworkData(new AzureLocation("East US"), new ExtendedLocation() - { - Name = "/subscriptions/a5015e1c-867f-4533-8541-85cd470d0cfb/resourceGroups/demoRG/providers/Microsoft.Arc/customLocations/contoso", - }) - { - Uuid = "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee", - VmmServerId = new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/testrg/providers/Microsoft.SCVMM/VMMServers/ContosoVMMServer"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); - ScVmmVirtualNetworkResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualNetworkName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmVirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworksByResourceGroup() + public async Task GetIfExists_GetVirtualNetwork() { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVirtualNetworksByResourceGroup.json - // this example is just showing the usage of "VirtualNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/GetVirtualNetwork.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListVirtualNetworksByResourceGroup() // get the collection of this ScVmmVirtualNetworkResource ScVmmVirtualNetworkCollection collection = resourceGroupResource.GetScVmmVirtualNetworks(); - // invoke the operation and iterate over the result - await foreach (ScVmmVirtualNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkName = "HRVirtualNetwork"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); + ScVmmVirtualNetworkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScVmmVirtualNetworkData resourceData = item.Data; + ScVmmVirtualNetworkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualNetworkResource.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualNetworkResource.cs index fba144dfb5fba..575ccdba2ab1d 100644 --- a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualNetworkResource.cs +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_ScVmmVirtualNetworkResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.ScVmm.Models; using NUnit.Framework; @@ -94,12 +93,12 @@ public async Task Update_UpdateVirtualNetwork() ScVmmVirtualNetworkResource scVmmVirtualNetwork = client.GetScVmmVirtualNetworkResource(scVmmVirtualNetworkResourceId); // invoke the operation - ScVmmResourcePatch patch = new ScVmmResourcePatch() + ScVmmResourcePatch patch = new ScVmmResourcePatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await scVmmVirtualNetwork.UpdateAsync(WaitUntil.Completed, patch); @@ -111,36 +110,5 @@ public async Task Update_UpdateVirtualNetwork() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetScVmmVirtualNetworks_ListVirtualNetworksBySubscription() - { - // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVirtualNetworksBySubscription.json - // this example is just showing the usage of "VirtualNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ScVmmVirtualNetworkResource item in subscriptionResource.GetScVmmVirtualNetworksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScVmmVirtualNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..e2683c990b5fa --- /dev/null +++ b/sdk/arc-scvmm/Azure.ResourceManager.ScVmm/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ScVmm.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetScVmmServers_ListVmmServersBySubscription() + { + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVMMServersBySubscription.json + // this example is just showing the usage of "VmmServers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ScVmmServerResource item in subscriptionResource.GetScVmmServersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetScVmmClouds_ListCloudsBySubscription() + { + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListCloudsBySubscription.json + // this example is just showing the usage of "Clouds_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ScVmmCloudResource item in subscriptionResource.GetScVmmCloudsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmCloudData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetScVmmVirtualNetworks_ListVirtualNetworksBySubscription() + { + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVirtualNetworksBySubscription.json + // this example is just showing the usage of "VirtualNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ScVmmVirtualNetworkResource item in subscriptionResource.GetScVmmVirtualNetworksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmVirtualNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetScVmmVirtualMachineTemplates_ListVirtualMachineTemplatesBySubscription() + { + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListVirtualMachineTemplatesBySubscription.json + // this example is just showing the usage of "VirtualMachineTemplates_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ScVmmVirtualMachineTemplateResource item in subscriptionResource.GetScVmmVirtualMachineTemplatesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmVirtualMachineTemplateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetScVmmAvailabilitySets_ListAvailabilitySetsBySubscription() + { + // Generated from example definition: specification/scvmm/resource-manager/Microsoft.ScVmm/stable/2023-10-07/examples/ListAvailabilitySetsBySubscription.json + // this example is just showing the usage of "AvailabilitySets_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ScVmmAvailabilitySetResource item in subscriptionResource.GetScVmmAvailabilitySetsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScVmmAvailabilitySetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_AstroOrganizationCollection.cs b/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_AstroOrganizationCollection.cs index a5684e02b250c..5b9b1bcd6e383 100644 --- a/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_AstroOrganizationCollection.cs +++ b/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_AstroOrganizationCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_AstroOrganizationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_OrganizationsListByResourceGroupGeneratedByMaximumSetRule() + public async Task CreateOrUpdate_OrganizationsCreateOrUpdateGeneratedByMaximumSetRule() { - // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "Organizations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_CreateOrUpdate_MaximumSet_Gen.json + // this example is just showing the usage of "Organizations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,52 @@ public async Task GetAll_OrganizationsListByResourceGroupGeneratedByMaximumSetRu // get the collection of this AstroOrganizationResource AstroOrganizationCollection collection = resourceGroupResource.GetAstroOrganizations(); - // invoke the operation and iterate over the result - await foreach (AstroOrganizationResource item in collection.GetAllAsync()) + // invoke the operation + string organizationName = "U.1-:7"; + AstroOrganizationData data = new AstroOrganizationData(new AzureLocation("mhqthlsatwvqkl")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AstroOrganizationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AstroOrganizationProperties(new AstroMarketplaceDetails("ntthclydlpqmasr", new AstroOfferDetails("gfsqxygpnerxmvols", "krzkefmpxztqyusidzgpchfaswuyce", "kndxzygsanuiqzwbfbbvoipv") + { + PlanName = "pwqjwlq", + TermUnit = "xyygyzcazkuelz", + TermId = "pwds", + }) + { + SubscriptionStatus = MarketplaceSubscriptionStatus.PendingFulfillmentStart, + }, new AstroUserDetails("nfh", "lazfbstcccykibvcrxpmglqam", ".K_@e7N-g1.xjqnbPs") + { + Upn = "xtutvycpxjrtoftx", + PhoneNumber = "inxkscllh", + }) + { + PartnerOrganizationProperties = new AstroPartnerOrganizationProperties("3-") + { + OrganizationId = "lskgzdmziusgrsucv", + WorkspaceId = "vcrupxwpaba", + WorkspaceName = "9.:06", + SingleSignOnProperties = new AstroSingleSignOnProperties + { + SingleSignOnState = AstroSingleSignOnState.Initial, + EnterpriseAppId = "mklfypyujwumgwdzae", + SingleSignOnUri = new Uri("ymmtzkyghvinvhgnqlzwrr"), + AadDomains = { "kfbleh" }, + }, + }, + }, + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = { }, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, organizationName, data); + AstroOrganizationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AstroOrganizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +123,10 @@ public async Task Get_OrganizationsGetGeneratedByMaximumSetRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_OrganizationsGetGeneratedByMaximumSetRule() + public async Task GetAll_OrganizationsListByResourceGroupGeneratedByMaximumSetRule() { - // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Organizations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "Organizations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +143,22 @@ public async Task Exists_OrganizationsGetGeneratedByMaximumSetRule() // get the collection of this AstroOrganizationResource AstroOrganizationCollection collection = resourceGroupResource.GetAstroOrganizations(); - // invoke the operation - string organizationName = "S PS"; - bool result = await collection.ExistsAsync(organizationName); + // invoke the operation and iterate over the result + await foreach (AstroOrganizationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AstroOrganizationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_OrganizationsGetGeneratedByMaximumSetRule() + public async Task Exists_OrganizationsGetGeneratedByMaximumSetRule() { // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_Get_MaximumSet_Gen.json // this example is just showing the usage of "Organizations_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +180,17 @@ public async Task GetIfExists_OrganizationsGetGeneratedByMaximumSetRule() // invoke the operation string organizationName = "S PS"; - NullableResponse response = await collection.GetIfExistsAsync(organizationName); - AstroOrganizationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(organizationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AstroOrganizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_OrganizationsCreateOrUpdateGeneratedByMaximumSetRule() + public async Task GetIfExists_OrganizationsGetGeneratedByMaximumSetRule() { - // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_CreateOrUpdate_MaximumSet_Gen.json - // this example is just showing the usage of "Organizations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Organizations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,58 +208,22 @@ public async Task CreateOrUpdate_OrganizationsCreateOrUpdateGeneratedByMaximumSe AstroOrganizationCollection collection = resourceGroupResource.GetAstroOrganizations(); // invoke the operation - string organizationName = "U.1-:7"; - AstroOrganizationData data = new AstroOrganizationData(new AzureLocation("mhqthlsatwvqkl")) - { - Properties = new AstroOrganizationProperties(new AstroMarketplaceDetails("ntthclydlpqmasr", new AstroOfferDetails("gfsqxygpnerxmvols", "krzkefmpxztqyusidzgpchfaswuyce", "kndxzygsanuiqzwbfbbvoipv") - { - PlanName = "pwqjwlq", - TermUnit = "xyygyzcazkuelz", - TermId = "pwds", - }) - { - SubscriptionStatus = MarketplaceSubscriptionStatus.PendingFulfillmentStart, - }, new AstroUserDetails("nfh", "lazfbstcccykibvcrxpmglqam", ".K_@e7N-g1.xjqnbPs") - { - Upn = "xtutvycpxjrtoftx", - PhoneNumber = "inxkscllh", - }) - { - PartnerOrganizationProperties = new AstroPartnerOrganizationProperties("3-") - { - OrganizationId = "lskgzdmziusgrsucv", - WorkspaceId = "vcrupxwpaba", - WorkspaceName = "9.:06", - SingleSignOnProperties = new AstroSingleSignOnProperties() - { - SingleSignOnState = AstroSingleSignOnState.Initial, - EnterpriseAppId = "mklfypyujwumgwdzae", - SingleSignOnUri = new Uri("ymmtzkyghvinvhgnqlzwrr"), - AadDomains = -{ -"kfbleh" -}, - }, - }, - }, - Identity = new ManagedServiceIdentity("None") - { - UserAssignedIdentities = -{ -}, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, organizationName, data); - AstroOrganizationResource result = lro.Value; + string organizationName = "S PS"; + NullableResponse response = await collection.GetIfExistsAsync(organizationName); + AstroOrganizationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AstroOrganizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AstroOrganizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_AstroOrganizationResource.cs b/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_AstroOrganizationResource.cs index aef7dd19cb838..83fd69cd6662a 100644 --- a/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_AstroOrganizationResource.cs +++ b/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_AstroOrganizationResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Astro.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Astro.Samples @@ -20,41 +19,40 @@ public partial class Sample_AstroOrganizationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAstroOrganizations_OrganizationsListBySubscriptionGeneratedByMaximumSetRule() + public async Task Get_OrganizationsGetGeneratedByMaximumSetRule() { - // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "Organizations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_Get_MaximumSet_Gen.json + // this example is just showing the usage of "Organizations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this AstroOrganizationResource created on azure + // for more information of creating AstroOrganizationResource, please refer to the document of AstroOrganizationResource string subscriptionId = "43454B17-172A-40FE-80FA-549EA23D12B3"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rgastronomer"; + string organizationName = "S PS"; + ResourceIdentifier astroOrganizationResourceId = AstroOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); + AstroOrganizationResource astroOrganization = client.GetAstroOrganizationResource(astroOrganizationResourceId); - // invoke the operation and iterate over the result - await foreach (AstroOrganizationResource item in subscriptionResource.GetAstroOrganizationsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AstroOrganizationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + AstroOrganizationResource result = await astroOrganization.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AstroOrganizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_OrganizationsGetGeneratedByMaximumSetRule() + public async Task Delete_OrganizationsDeleteGeneratedByMaximumSetRule() { - // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_Get_MaximumSet_Gen.json - // this example is just showing the usage of "Organizations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "Organizations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,18 +63,14 @@ public async Task Get_OrganizationsGetGeneratedByMaximumSetRule() // for more information of creating AstroOrganizationResource, please refer to the document of AstroOrganizationResource string subscriptionId = "43454B17-172A-40FE-80FA-549EA23D12B3"; string resourceGroupName = "rgastronomer"; - string organizationName = "S PS"; + string organizationName = "q:"; ResourceIdentifier astroOrganizationResourceId = AstroOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); AstroOrganizationResource astroOrganization = client.GetAstroOrganizationResource(astroOrganizationResourceId); // invoke the operation - AstroOrganizationResource result = await astroOrganization.GetAsync(); + await astroOrganization.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AstroOrganizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,21 +94,19 @@ public async Task Update_OrganizationsUpdate() AstroOrganizationResource astroOrganization = client.GetAstroOrganizationResource(astroOrganizationResourceId); // invoke the operation - AstroOrganizationPatch patch = new AstroOrganizationPatch() + AstroOrganizationPatch patch = new AstroOrganizationPatch { Identity = new ManagedServiceIdentity("None") { - UserAssignedIdentities = -{ -}, + UserAssignedIdentities = { }, }, Tags = { -["key1474"] = "bqqyipxnbbxryhznyaosmtpo", +["key1474"] = "bqqyipxnbbxryhznyaosmtpo" }, - Properties = new AstroOrganizationUpdateProperties() + Properties = new AstroOrganizationUpdateProperties { - User = new AstroUserUpdateDetails() + User = new AstroUserUpdateDetails { FirstName = "qeuofehzypzljgcuysugefbgxde", LastName = "g", @@ -122,21 +114,18 @@ public async Task Update_OrganizationsUpdate() Upn = "uwtprzdfpsqmktx", PhoneNumber = "aqpyxznvqpgkzohevynofrjdfgoo", }, - PartnerOrganizationProperties = new AstroPartnerOrganizationUpdateProperties() + PartnerOrganizationProperties = new AstroPartnerOrganizationUpdateProperties { OrganizationId = "lrtmbkvyvvoszhjevohkmyjhfyty", WorkspaceId = "xsepuskdhejaadusyxq", OrganizationName = "U2P_", WorkspaceName = "L.-y_--:", - SingleSignOnProperties = new AstroSingleSignOnProperties() + SingleSignOnProperties = new AstroSingleSignOnProperties { SingleSignOnState = AstroSingleSignOnState.Initial, EnterpriseAppId = "mklfypyujwumgwdzae", SingleSignOnUri = new Uri("ymmtzkyghvinvhgnqlzwrr"), - AadDomains = -{ -"kfbleh" -}, + AadDomains = { "kfbleh" }, }, }, }, @@ -150,31 +139,5 @@ public async Task Update_OrganizationsUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_OrganizationsDeleteGeneratedByMaximumSetRule() - { - // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "Organizations_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AstroOrganizationResource created on azure - // for more information of creating AstroOrganizationResource, please refer to the document of AstroOrganizationResource - string subscriptionId = "43454B17-172A-40FE-80FA-549EA23D12B3"; - string resourceGroupName = "rgastronomer"; - string organizationName = "q:"; - ResourceIdentifier astroOrganizationResourceId = AstroOrganizationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, organizationName); - AstroOrganizationResource astroOrganization = client.GetAstroOrganizationResource(astroOrganizationResourceId); - - // invoke the operation - await astroOrganization.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..2e2162002e9c4 --- /dev/null +++ b/sdk/astronomer/Azure.ResourceManager.Astro/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Astro.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAstroOrganizations_OrganizationsListBySubscriptionGeneratedByMaximumSetRule() + { + // Generated from example definition: specification/liftrastronomer/resource-manager/Astronomer.Astro/stable/2023-08-01/examples/Organizations_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "Organizations_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "43454B17-172A-40FE-80FA-549EA23D12B3"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AstroOrganizationResource item in subscriptionResource.GetAstroOrganizationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AstroOrganizationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationPrivateEndpointConnectionCollection.cs b/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationPrivateEndpointConnectionCollection.cs index 11a6a64e29526..92764ecd40a02 100644 --- a/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationPrivateEndpointConnectionCollection.cs +++ b/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AttestationPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AttestationProviderListPrivateEndpointConnections() + public async Task CreateOrUpdate_AttestationProviderPutPrivateEndpointConnection() { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderListPrivateEndpointConnections.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderPutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,25 +31,32 @@ public async Task GetAll_AttestationProviderListPrivateEndpointConnections() // this example assumes you already have this AttestationProviderResource created on azure // for more information of creating AttestationProviderResource, please refer to the document of AttestationProviderResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string providerName = "sto2527"; + string resourceGroupName = "res7687"; + string providerName = "sto9699"; ResourceIdentifier attestationProviderResourceId = AttestationProviderResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, providerName); AttestationProviderResource attestationProvider = client.GetAttestationProviderResource(attestationProviderResourceId); // get the collection of this AttestationPrivateEndpointConnectionResource AttestationPrivateEndpointConnectionCollection collection = attestationProvider.GetAttestationPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (AttestationPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "{privateEndpointConnectionName}"; + AttestationPrivateEndpointConnectionData data = new AttestationPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttestationPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new AttestationPrivateLinkServiceConnectionState + { + Status = AttestationPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + AttestationPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttestationPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_AttestationProviderGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AttestationProviderGetPrivateEndpointConnection() + public async Task GetAll_AttestationProviderListPrivateEndpointConnections() { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderGetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderListPrivateEndpointConnections.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_AttestationProviderGetPrivateEndpointConnection() // get the collection of this AttestationPrivateEndpointConnectionResource AttestationPrivateEndpointConnectionCollection collection = attestationProvider.GetAttestationPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (AttestationPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttestationPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AttestationProviderGetPrivateEndpointConnection() + public async Task Exists_AttestationProviderGetPrivateEndpointConnection() { // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderGetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_AttestationProviderGetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - AttestationPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttestationPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AttestationProviderPutPrivateEndpointConnection() + public async Task GetIfExists_AttestationProviderGetPrivateEndpointConnection() { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderPutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderGetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,8 +174,8 @@ public async Task CreateOrUpdate_AttestationProviderPutPrivateEndpointConnection // this example assumes you already have this AttestationProviderResource created on azure // for more information of creating AttestationProviderResource, please refer to the document of AttestationProviderResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; - string providerName = "sto9699"; + string resourceGroupName = "res6977"; + string providerName = "sto2527"; ResourceIdentifier attestationProviderResourceId = AttestationProviderResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, providerName); AttestationProviderResource attestationProvider = client.GetAttestationProviderResource(attestationProviderResourceId); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_AttestationProviderPutPrivateEndpointConnection // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - AttestationPrivateEndpointConnectionData data = new AttestationPrivateEndpointConnectionData() - { - ConnectionState = new AttestationPrivateLinkServiceConnectionState() - { - Status = AttestationPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - AttestationPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + AttestationPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttestationPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttestationPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationPrivateEndpointConnectionResource.cs b/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationPrivateEndpointConnectionResource.cs index 96abb5ac17049..b936ba53f9101 100644 --- a/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationPrivateEndpointConnectionResource.cs +++ b/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_AttestationProviderGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AttestationProviderPutPrivateEndpointConnection() + public async Task Delete_AttestationProviderDeletePrivateEndpointConnection() { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderPutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderDeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,37 +62,24 @@ public async Task Update_AttestationProviderPutPrivateEndpointConnection() // this example assumes you already have this AttestationPrivateEndpointConnectionResource created on azure // for more information of creating AttestationPrivateEndpointConnectionResource, please refer to the document of AttestationPrivateEndpointConnectionResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; - string providerName = "sto9699"; + string resourceGroupName = "res6977"; + string providerName = "sto2527"; string privateEndpointConnectionName = "{privateEndpointConnectionName}"; ResourceIdentifier attestationPrivateEndpointConnectionResourceId = AttestationPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, providerName, privateEndpointConnectionName); AttestationPrivateEndpointConnectionResource attestationPrivateEndpointConnection = client.GetAttestationPrivateEndpointConnectionResource(attestationPrivateEndpointConnectionResourceId); // invoke the operation - AttestationPrivateEndpointConnectionData data = new AttestationPrivateEndpointConnectionData() - { - ConnectionState = new AttestationPrivateLinkServiceConnectionState() - { - Status = AttestationPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await attestationPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - AttestationPrivateEndpointConnectionResource result = lro.Value; + await attestationPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttestationPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AttestationProviderDeletePrivateEndpointConnection() + public async Task Update_AttestationProviderPutPrivateEndpointConnection() { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderDeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/AttestationProviderPutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,16 +89,29 @@ public async Task Delete_AttestationProviderDeletePrivateEndpointConnection() // this example assumes you already have this AttestationPrivateEndpointConnectionResource created on azure // for more information of creating AttestationPrivateEndpointConnectionResource, please refer to the document of AttestationPrivateEndpointConnectionResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string providerName = "sto2527"; + string resourceGroupName = "res7687"; + string providerName = "sto9699"; string privateEndpointConnectionName = "{privateEndpointConnectionName}"; ResourceIdentifier attestationPrivateEndpointConnectionResourceId = AttestationPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, providerName, privateEndpointConnectionName); AttestationPrivateEndpointConnectionResource attestationPrivateEndpointConnection = client.GetAttestationPrivateEndpointConnectionResource(attestationPrivateEndpointConnectionResourceId); // invoke the operation - await attestationPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + AttestationPrivateEndpointConnectionData data = new AttestationPrivateEndpointConnectionData + { + ConnectionState = new AttestationPrivateLinkServiceConnectionState + { + Status = AttestationPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await attestationPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + AttestationPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttestationPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationProviderCollection.cs b/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationProviderCollection.cs index d32830f56fdef..ff7c0818083a8 100644 --- a/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationProviderCollection.cs +++ b/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationProviderCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AttestationProviderCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AttestationProvidersGet() + public async Task CreateOrUpdate_AttestationProvidersCreate() { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_AttestationProvider.json - // this example is just showing the usage of "AttestationProviders_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Create_AttestationProvider.json + // this example is just showing the usage of "AttestationProviders_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,20 @@ public async Task Get_AttestationProvidersGet() // invoke the operation string providerName = "myattestationprovider"; - AttestationProviderResource result = await collection.GetAsync(providerName); + AttestationProviderCreateOrUpdateContent content = new AttestationProviderCreateOrUpdateContent(new AzureLocation("East US"), new AttestationServiceCreationSpecificParams + { + PublicNetworkAccess = PublicNetworkAccessType.Enabled, + }) + { + Tags = +{ +["Property1"] = "Value1", +["Property2"] = "Value2", +["Property3"] = "Value3" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerName, content); + AttestationProviderResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +65,7 @@ public async Task Get_AttestationProvidersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AttestationProvidersGet() + public async Task Get_AttestationProvidersGet() { // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_AttestationProvider.json // this example is just showing the usage of "AttestationProviders_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +87,21 @@ public async Task Exists_AttestationProvidersGet() // invoke the operation string providerName = "myattestationprovider"; - bool result = await collection.ExistsAsync(providerName); + AttestationProviderResource result = await collection.GetAsync(providerName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttestationProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AttestationProvidersGet() + public async Task GetAll_AttestationProvidersListByResourceGroup() { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_AttestationProvider.json - // this example is just showing the usage of "AttestationProviders_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_AttestationProvidersListByResourceGroup.json + // this example is just showing the usage of "AttestationProviders_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,39 +110,33 @@ public async Task GetIfExists_AttestationProvidersGet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "MyResourceGroup"; + string subscriptionId = "6c96b33e-f5b8-40a6-9011-5cb1c58b0915"; + string resourceGroupName = "testrg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this AttestationProviderResource AttestationProviderCollection collection = resourceGroupResource.GetAttestationProviders(); - // invoke the operation - string providerName = "myattestationprovider"; - NullableResponse response = await collection.GetIfExistsAsync(providerName); - AttestationProviderResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AttestationProviderResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AttestationProviderData resourceData = result.Data; + AttestationProviderData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AttestationProvidersCreate() + public async Task Exists_AttestationProvidersGet() { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Create_AttestationProvider.json - // this example is just showing the usage of "AttestationProviders_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_AttestationProvider.json + // this example is just showing the usage of "AttestationProviders_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,34 +155,17 @@ public async Task CreateOrUpdate_AttestationProvidersCreate() // invoke the operation string providerName = "myattestationprovider"; - AttestationProviderCreateOrUpdateContent content = new AttestationProviderCreateOrUpdateContent(new AzureLocation("East US"), new AttestationServiceCreationSpecificParams() - { - PublicNetworkAccess = PublicNetworkAccessType.Enabled, - }) - { - Tags = -{ -["Property1"] = "Value1", -["Property2"] = "Value2", -["Property3"] = "Value3", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerName, content); - AttestationProviderResource result = lro.Value; + bool result = await collection.ExistsAsync(providerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttestationProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AttestationProvidersListByResourceGroup() + public async Task GetIfExists_AttestationProvidersGet() { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_AttestationProvidersListByResourceGroup.json - // this example is just showing the usage of "AttestationProviders_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_AttestationProvider.json + // this example is just showing the usage of "AttestationProviders_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,25 +174,31 @@ public async Task GetAll_AttestationProvidersListByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "6c96b33e-f5b8-40a6-9011-5cb1c58b0915"; - string resourceGroupName = "testrg1"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "MyResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this AttestationProviderResource AttestationProviderCollection collection = resourceGroupResource.GetAttestationProviders(); - // invoke the operation and iterate over the result - await foreach (AttestationProviderResource item in collection.GetAllAsync()) + // invoke the operation + string providerName = "myattestationprovider"; + NullableResponse response = await collection.GetIfExistsAsync(providerName); + AttestationProviderResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AttestationProviderData resourceData = item.Data; + AttestationProviderData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationProviderResource.cs b/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationProviderResource.cs index f121c07567629..3bf46d9e0f3c9 100644 --- a/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationProviderResource.cs +++ b/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_AttestationProviderResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Attestation.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Attestation.Samples @@ -47,46 +46,6 @@ public async Task Get_AttestationProvidersGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_AttestationProvidersUpdate() - { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Update_AttestationProvider.json - // this example is just showing the usage of "AttestationProviders_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AttestationProviderResource created on azure - // for more information of creating AttestationProviderResource, please refer to the document of AttestationProviderResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "MyResourceGroup"; - string providerName = "myattestationprovider"; - ResourceIdentifier attestationProviderResourceId = AttestationProviderResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, providerName); - AttestationProviderResource attestationProvider = client.GetAttestationProviderResource(attestationProviderResourceId); - - // invoke the operation - AttestationProviderPatch patch = new AttestationProviderPatch() - { - Tags = -{ -["Property1"] = "Value1", -["Property2"] = "Value2", -["Property3"] = "Value3", -}, - AttestationServicePatchSpecificParamsPublicNetworkAccess = PublicNetworkAccessType.Disabled, - }; - AttestationProviderResource result = await attestationProvider.UpdateAsync(patch); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttestationProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Delete_AttestationProvidersDelete() @@ -115,87 +74,36 @@ public async Task Delete_AttestationProvidersDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAttestationProviders_AttestationProvidersList() + public async Task Update_AttestationProvidersUpdate() { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_AttestationProvidersList.json - // this example is just showing the usage of "AttestationProviders_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Update_AttestationProvider.json + // this example is just showing the usage of "AttestationProviders_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this AttestationProviderResource created on azure + // for more information of creating AttestationProviderResource, please refer to the document of AttestationProviderResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AttestationProviderResource item in subscriptionResource.GetAttestationProvidersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttestationProviderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAttestationProvidersByDefaultProvider_AttestationProvidersGetDefault() - { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_DefaultProviders.json - // this example is just showing the usage of "AttestationProviders_ListDefault" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "6c96b33e-f5b8-40a6-9011-5cb1c58b0915"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AttestationProviderResource item in subscriptionResource.GetAttestationProvidersByDefaultProviderAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AttestationProviderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDefaultByLocationAttestationProvider_AttestationProvidersGetDefaultWithLocation() - { - // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_DefaultProviderByLocation.json - // this example is just showing the usage of "AttestationProviders_GetDefaultByLocation" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "6c96b33e-f5b8-40a6-9011-5cb1c58b0915"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "MyResourceGroup"; + string providerName = "myattestationprovider"; + ResourceIdentifier attestationProviderResourceId = AttestationProviderResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, providerName); + AttestationProviderResource attestationProvider = client.GetAttestationProviderResource(attestationProviderResourceId); // invoke the operation - AzureLocation location = new AzureLocation("Central US"); - AttestationProviderResource result = await subscriptionResource.GetDefaultByLocationAttestationProviderAsync(location); + AttestationProviderPatch patch = new AttestationProviderPatch + { + Tags = +{ +["Property1"] = "Value1", +["Property2"] = "Value2", +["Property3"] = "Value3" +}, + AttestationServicePatchSpecificParamsPublicNetworkAccess = PublicNetworkAccessType.Disabled, + }; + AttestationProviderResource result = await attestationProvider.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..0387592466062 --- /dev/null +++ b/sdk/attestation/Azure.ResourceManager.Attestation/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Attestation.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAttestationProviders_AttestationProvidersList() + { + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_AttestationProvidersList.json + // this example is just showing the usage of "AttestationProviders_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AttestationProviderResource item in subscriptionResource.GetAttestationProvidersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttestationProviderData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAttestationProvidersByDefaultProvider_AttestationProvidersGetDefault() + { + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_DefaultProviders.json + // this example is just showing the usage of "AttestationProviders_ListDefault" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "6c96b33e-f5b8-40a6-9011-5cb1c58b0915"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AttestationProviderResource item in subscriptionResource.GetAttestationProvidersByDefaultProviderAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttestationProviderData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDefaultByLocationAttestationProvider_AttestationProvidersGetDefaultWithLocation() + { + // Generated from example definition: specification/attestation/resource-manager/Microsoft.Attestation/preview/2021-06-01-preview/examples/Get_DefaultProviderByLocation.json + // this example is just showing the usage of "AttestationProviders_GetDefaultByLocation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "6c96b33e-f5b8-40a6-9011-5cb1c58b0915"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("Central US"); + AttestationProviderResource result = await subscriptionResource.GetDefaultByLocationAttestationProviderAsync(location); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AttestationProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } +} diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_ArmClientExtensions.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_ArmClientExtensions.cs new file mode 100644 index 0000000000000..bcb5961114065 --- /dev/null +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_ArmClientExtensions.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Authorization.Models; +using NUnit.Framework; + +namespace Azure.ResourceManager.Authorization.Samples +{ + public partial class Sample_ArmClientExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetEligibleChildResources_GetEligibleChildResourcesByScope() + { + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetEligibleChildResourcesByScope.json + // this example is just showing the usage of "EligibleChildResources_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // invoke the operation and iterate over the result + ResourceIdentifier scope = new ResourceIdentifier("providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"); + string filter = "resourceType+eq+'resourcegroup'"; + await foreach (EligibleChildResource item in client.GetEligibleChildResourcesAsync(scope, filter: filter)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationProviderOperationsMetadataCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationProviderOperationsMetadataCollection.cs index 98894d4c212d4..e5a474140a155 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationProviderOperationsMetadataCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationProviderOperationsMetadataCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Authorization.Samples @@ -27,9 +28,7 @@ public async Task Get_ListProviderOperationsMetadataForResourceProvider() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this AuthorizationProviderOperationsMetadataResource AuthorizationProviderOperationsMetadataCollection collection = tenantResource.GetAllAuthorizationProviderOperationsMetadata(); @@ -45,6 +44,36 @@ public async Task Get_ListProviderOperationsMetadataForResourceProvider() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListProviderOperationsMetadataForAllResourceProviders() + { + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetAllProviderOperations.json + // this example is just showing the usage of "ProviderOperationsMetadata_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this AuthorizationProviderOperationsMetadataResource + AuthorizationProviderOperationsMetadataCollection collection = tenantResource.GetAllAuthorizationProviderOperationsMetadata(); + + // invoke the operation and iterate over the result + await foreach (AuthorizationProviderOperationsMetadataResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationProviderOperationsMetadataData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_ListProviderOperationsMetadataForResourceProvider() @@ -57,9 +86,7 @@ public async Task Exists_ListProviderOperationsMetadataForResourceProvider() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this AuthorizationProviderOperationsMetadataResource AuthorizationProviderOperationsMetadataCollection collection = tenantResource.GetAllAuthorizationProviderOperationsMetadata(); @@ -83,9 +110,7 @@ public async Task GetIfExists_ListProviderOperationsMetadataForResourceProvider( // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this AuthorizationProviderOperationsMetadataResource AuthorizationProviderOperationsMetadataCollection collection = tenantResource.GetAllAuthorizationProviderOperationsMetadata(); @@ -108,37 +133,5 @@ public async Task GetIfExists_ListProviderOperationsMetadataForResourceProvider( Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListProviderOperationsMetadataForAllResourceProviders() - { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetAllProviderOperations.json - // this example is just showing the usage of "ProviderOperationsMetadata_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this AuthorizationProviderOperationsMetadataResource - AuthorizationProviderOperationsMetadataCollection collection = tenantResource.GetAllAuthorizationProviderOperationsMetadata(); - - // invoke the operation and iterate over the result - await foreach (AuthorizationProviderOperationsMetadataResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationProviderOperationsMetadataData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationRoleDefinitionCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationRoleDefinitionCollection.cs index 18bfa52302fa8..da98cd2dc3f6c 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationRoleDefinitionCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationRoleDefinitionCollection.cs @@ -17,27 +17,25 @@ public partial class Sample_AuthorizationRoleDefinitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRoleDefinitionByName() + public async Task CreateOrUpdate_CreateRoleDefinition() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionByName.json - // this example is just showing the usage of "RoleDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/PutRoleDefinition.json + // this example is just showing the usage of "RoleDefinitions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AuthorizationRoleDefinitionResource string scope = "scope"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - AuthorizationRoleDefinitionCollection collection = client.GetAuthorizationRoleDefinitions(scopeId); + AuthorizationRoleDefinitionCollection collection = client.GetAuthorizationRoleDefinitions(new ResourceIdentifier(scope)); // invoke the operation ResourceIdentifier roleDefinitionId = new ResourceIdentifier("roleDefinitionId"); - AuthorizationRoleDefinitionResource result = await collection.GetAsync(roleDefinitionId); + AuthorizationRoleDefinitionData data = new AuthorizationRoleDefinitionData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleDefinitionId, data); + AuthorizationRoleDefinitionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -48,7 +46,7 @@ public async Task Get_GetRoleDefinitionByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRoleDefinitionByName() + public async Task Get_GetRoleDefinitionByName() { // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionByName.json // this example is just showing the usage of "RoleDefinitions_Get" operation, for the dependent resources, they will have to be created separately. @@ -58,124 +56,106 @@ public async Task Exists_GetRoleDefinitionByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AuthorizationRoleDefinitionResource string scope = "scope"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - AuthorizationRoleDefinitionCollection collection = client.GetAuthorizationRoleDefinitions(scopeId); + AuthorizationRoleDefinitionCollection collection = client.GetAuthorizationRoleDefinitions(new ResourceIdentifier(scope)); // invoke the operation ResourceIdentifier roleDefinitionId = new ResourceIdentifier("roleDefinitionId"); - bool result = await collection.ExistsAsync(roleDefinitionId); + AuthorizationRoleDefinitionResource result = await collection.GetAsync(roleDefinitionId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AuthorizationRoleDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRoleDefinitionByName() + public async Task GetAll_ListRoleDefinitionsForScope() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionByName.json - // this example is just showing the usage of "RoleDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionAtScope.json + // this example is just showing the usage of "RoleDefinitions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AuthorizationRoleDefinitionResource string scope = "scope"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - AuthorizationRoleDefinitionCollection collection = client.GetAuthorizationRoleDefinitions(scopeId); - - // invoke the operation - ResourceIdentifier roleDefinitionId = new ResourceIdentifier("roleDefinitionId"); - NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionId); - AuthorizationRoleDefinitionResource result = response.HasValue ? response.Value : null; + AuthorizationRoleDefinitionCollection collection = client.GetAuthorizationRoleDefinitions(new ResourceIdentifier(scope)); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AuthorizationRoleDefinitionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AuthorizationRoleDefinitionData resourceData = result.Data; + AuthorizationRoleDefinitionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateRoleDefinition() + public async Task Exists_GetRoleDefinitionByName() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/PutRoleDefinition.json - // this example is just showing the usage of "RoleDefinitions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionByName.json + // this example is just showing the usage of "RoleDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AuthorizationRoleDefinitionResource string scope = "scope"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - AuthorizationRoleDefinitionCollection collection = client.GetAuthorizationRoleDefinitions(scopeId); + AuthorizationRoleDefinitionCollection collection = client.GetAuthorizationRoleDefinitions(new ResourceIdentifier(scope)); // invoke the operation ResourceIdentifier roleDefinitionId = new ResourceIdentifier("roleDefinitionId"); - AuthorizationRoleDefinitionData data = new AuthorizationRoleDefinitionData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleDefinitionId, data); - AuthorizationRoleDefinitionResource result = lro.Value; + bool result = await collection.ExistsAsync(roleDefinitionId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AuthorizationRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRoleDefinitionsForScope() + public async Task GetIfExists_GetRoleDefinitionByName() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionAtScope.json - // this example is just showing the usage of "RoleDefinitions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionByName.json + // this example is just showing the usage of "RoleDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AuthorizationRoleDefinitionResource string scope = "scope"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - AuthorizationRoleDefinitionCollection collection = client.GetAuthorizationRoleDefinitions(scopeId); + AuthorizationRoleDefinitionCollection collection = client.GetAuthorizationRoleDefinitions(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (AuthorizationRoleDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + ResourceIdentifier roleDefinitionId = new ResourceIdentifier("roleDefinitionId"); + NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionId); + AuthorizationRoleDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AuthorizationRoleDefinitionData resourceData = item.Data; + AuthorizationRoleDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationRoleDefinitionResource.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationRoleDefinitionResource.cs index 7a158fc5df9af..92494fde2e83f 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationRoleDefinitionResource.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_AuthorizationRoleDefinitionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_AuthorizationRoleDefinitionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRoleDefinition() + public async Task Get_GetRoleDefinitionByName() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/DeleteRoleDefinition.json - // this example is just showing the usage of "RoleDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionByName.json + // this example is just showing the usage of "RoleDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,8 +35,7 @@ public async Task Delete_DeleteRoleDefinition() AuthorizationRoleDefinitionResource authorizationRoleDefinition = client.GetAuthorizationRoleDefinitionResource(authorizationRoleDefinitionResourceId); // invoke the operation - ArmOperation lro = await authorizationRoleDefinition.DeleteAsync(WaitUntil.Completed); - AuthorizationRoleDefinitionResource result = lro.Value; + AuthorizationRoleDefinitionResource result = await authorizationRoleDefinition.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -47,10 +46,10 @@ public async Task Delete_DeleteRoleDefinition() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRoleDefinitionByName() + public async Task Delete_DeleteRoleDefinition() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetRoleDefinitionByName.json - // this example is just showing the usage of "RoleDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/DeleteRoleDefinition.json + // this example is just showing the usage of "RoleDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,7 +64,8 @@ public async Task Get_GetRoleDefinitionByName() AuthorizationRoleDefinitionResource authorizationRoleDefinition = client.GetAuthorizationRoleDefinitionResource(authorizationRoleDefinitionResourceId); // invoke the operation - AuthorizationRoleDefinitionResource result = await authorizationRoleDefinition.GetAsync(); + ArmOperation lro = await authorizationRoleDefinition.DeleteAsync(WaitUntil.Completed); + AuthorizationRoleDefinitionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_DenyAssignmentCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_DenyAssignmentCollection.cs index 88b4ff7c964a9..36f813031cce7 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_DenyAssignmentCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_DenyAssignmentCollection.cs @@ -27,13 +27,9 @@ public async Task Get_GetDenyAssignmentByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DenyAssignmentResource string scope = "subscriptions/subId/resourcegroups/rgname"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - DenyAssignmentCollection collection = client.GetDenyAssignments(scopeId); + DenyAssignmentCollection collection = client.GetDenyAssignments(new ResourceIdentifier(scope)); // invoke the operation string denyAssignmentId = "denyAssignmentId"; @@ -46,6 +42,35 @@ public async Task Get_GetDenyAssignmentByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListDenyAssignmentsForScope() + { + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetDenyAssignmentByScope.json + // this example is just showing the usage of "DenyAssignments_ListForScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this DenyAssignmentResource + string scope = "subscriptions/subId"; + DenyAssignmentCollection collection = client.GetDenyAssignments(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (DenyAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DenyAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetDenyAssignmentByName() @@ -58,13 +83,9 @@ public async Task Exists_GetDenyAssignmentByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DenyAssignmentResource string scope = "subscriptions/subId/resourcegroups/rgname"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - DenyAssignmentCollection collection = client.GetDenyAssignments(scopeId); + DenyAssignmentCollection collection = client.GetDenyAssignments(new ResourceIdentifier(scope)); // invoke the operation string denyAssignmentId = "denyAssignmentId"; @@ -85,13 +106,9 @@ public async Task GetIfExists_GetDenyAssignmentByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DenyAssignmentResource string scope = "subscriptions/subId/resourcegroups/rgname"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - DenyAssignmentCollection collection = client.GetDenyAssignments(scopeId); + DenyAssignmentCollection collection = client.GetDenyAssignments(new ResourceIdentifier(scope)); // invoke the operation string denyAssignmentId = "denyAssignmentId"; @@ -111,38 +128,5 @@ public async Task GetIfExists_GetDenyAssignmentByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDenyAssignmentsForScope() - { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/GetDenyAssignmentByScope.json - // this example is just showing the usage of "DenyAssignments_ListForScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this DenyAssignmentResource - string scope = "subscriptions/subId"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - DenyAssignmentCollection collection = client.GetDenyAssignments(scopeId); - - // invoke the operation and iterate over the result - await foreach (DenyAssignmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DenyAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentCollection.cs index 0cc5c48575197..396009749c672 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentCollection.cs @@ -18,27 +18,28 @@ public partial class Sample_RoleAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRoleAssignmentByScopeAndName() + public async Task CreateOrUpdate_CreateRoleAssignmentForResource() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_Get.json - // this example is just showing the usage of "RoleAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForResource.json + // this example is just showing the usage of "RoleAssignments_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentResource - string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentCollection collection = client.GetRoleAssignments(scopeId); + string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"; + RoleAssignmentCollection collection = client.GetRoleAssignments(new ResourceIdentifier(scope)); // invoke the operation - string roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; - RoleAssignmentResource result = await collection.GetAsync(roleAssignmentName); + string roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + RoleAssignmentCreateOrUpdateContent content = new RoleAssignmentCreateOrUpdateContent(new ResourceIdentifier("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"), Guid.Parse("ce2ce14e-85d7-4629-bdbc-454d0519d987")) + { + PrincipalType = RoleManagementPrincipalType.User, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleAssignmentName, content); + RoleAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,75 +50,9 @@ public async Task Get_GetRoleAssignmentByScopeAndName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRoleAssignmentByScopeAndName() - { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_Get.json - // this example is just showing the usage of "RoleAssignments_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this RoleAssignmentResource - string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentCollection collection = client.GetRoleAssignments(scopeId); - - // invoke the operation - string roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; - bool result = await collection.ExistsAsync(roleAssignmentName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRoleAssignmentByScopeAndName() - { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_Get.json - // this example is just showing the usage of "RoleAssignments_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this RoleAssignmentResource - string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentCollection collection = client.GetRoleAssignments(scopeId); - - // invoke the operation - string roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; - NullableResponse response = await collection.GetIfExistsAsync(roleAssignmentName); - RoleAssignmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateRoleAssignmentForResource() + public async Task CreateOrUpdate_CreateRoleAssignmentForResourceGroup() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForResource.json + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForResourceGroup.json // this example is just showing the usage of "RoleAssignments_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -125,13 +60,9 @@ public async Task CreateOrUpdate_CreateRoleAssignmentForResource() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentResource - string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentCollection collection = client.GetRoleAssignments(scopeId); + string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"; + RoleAssignmentCollection collection = client.GetRoleAssignments(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; @@ -151,9 +82,9 @@ public async Task CreateOrUpdate_CreateRoleAssignmentForResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateRoleAssignmentForResourceGroup() + public async Task CreateOrUpdate_CreateRoleAssignmentForSubscription() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForResourceGroup.json + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForSubscription.json // this example is just showing the usage of "RoleAssignments_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -161,13 +92,9 @@ public async Task CreateOrUpdate_CreateRoleAssignmentForResourceGroup() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentResource - string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentCollection collection = client.GetRoleAssignments(scopeId); + string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + RoleAssignmentCollection collection = client.GetRoleAssignments(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; @@ -187,32 +114,23 @@ public async Task CreateOrUpdate_CreateRoleAssignmentForResourceGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateRoleAssignmentForSubscription() + public async Task Get_GetRoleAssignmentByScopeAndName() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForSubscription.json - // this example is just showing the usage of "RoleAssignments_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_Get.json + // this example is just showing the usage of "RoleAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentResource string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentCollection collection = client.GetRoleAssignments(scopeId); + RoleAssignmentCollection collection = client.GetRoleAssignments(new ResourceIdentifier(scope)); // invoke the operation - string roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; - RoleAssignmentCreateOrUpdateContent content = new RoleAssignmentCreateOrUpdateContent(new ResourceIdentifier("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"), Guid.Parse("ce2ce14e-85d7-4629-bdbc-454d0519d987")) - { - PrincipalType = RoleManagementPrincipalType.User, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleAssignmentName, content); - RoleAssignmentResource result = lro.Value; + string roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; + RoleAssignmentResource result = await collection.GetAsync(roleAssignmentName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -233,13 +151,9 @@ public async Task GetAll_ListRoleAssignmentsForScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentResource string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentCollection collection = client.GetRoleAssignments(scopeId); + RoleAssignmentCollection collection = client.GetRoleAssignments(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (RoleAssignmentResource item in collection.GetAllAsync()) @@ -253,5 +167,63 @@ public async Task GetAll_ListRoleAssignmentsForScope() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetRoleAssignmentByScopeAndName() + { + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_Get.json + // this example is just showing the usage of "RoleAssignments_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this RoleAssignmentResource + string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + RoleAssignmentCollection collection = client.GetRoleAssignments(new ResourceIdentifier(scope)); + + // invoke the operation + string roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; + bool result = await collection.ExistsAsync(roleAssignmentName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetRoleAssignmentByScopeAndName() + { + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_Get.json + // this example is just showing the usage of "RoleAssignments_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this RoleAssignmentResource + string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + RoleAssignmentCollection collection = client.GetRoleAssignments(new ResourceIdentifier(scope)); + + // invoke the operation + string roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; + NullableResponse response = await collection.GetIfExistsAsync(roleAssignmentName); + RoleAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentResource.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentResource.cs index 3d99d0cac8f53..12696dd6bf566 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentResource.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentResource.cs @@ -47,10 +47,10 @@ public async Task Get_GetRoleAssignmentByScopeAndName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateRoleAssignmentForResource() + public async Task Delete_DeleteRoleAssignment() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForResource.json - // this example is just showing the usage of "RoleAssignments_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_Delete.json + // this example is just showing the usage of "RoleAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,17 +59,13 @@ public async Task Update_CreateRoleAssignmentForResource() // this example assumes you already have this RoleAssignmentResource created on azure // for more information of creating RoleAssignmentResource, please refer to the document of RoleAssignmentResource - string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"; - string roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; + string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + string roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; ResourceIdentifier roleAssignmentResourceId = RoleAssignmentResource.CreateResourceIdentifier(scope, roleAssignmentName); RoleAssignmentResource roleAssignment = client.GetRoleAssignmentResource(roleAssignmentResourceId); // invoke the operation - RoleAssignmentCreateOrUpdateContent content = new RoleAssignmentCreateOrUpdateContent(new ResourceIdentifier("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"), Guid.Parse("ce2ce14e-85d7-4629-bdbc-454d0519d987")) - { - PrincipalType = RoleManagementPrincipalType.User, - }; - ArmOperation lro = await roleAssignment.UpdateAsync(WaitUntil.Completed, content); + ArmOperation lro = await roleAssignment.DeleteAsync(WaitUntil.Completed); RoleAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -81,9 +77,9 @@ public async Task Update_CreateRoleAssignmentForResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateRoleAssignmentForResourceGroup() + public async Task Update_CreateRoleAssignmentForResource() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForResourceGroup.json + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForResource.json // this example is just showing the usage of "RoleAssignments_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -93,7 +89,7 @@ public async Task Update_CreateRoleAssignmentForResourceGroup() // this example assumes you already have this RoleAssignmentResource created on azure // for more information of creating RoleAssignmentResource, please refer to the document of RoleAssignmentResource - string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"; + string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg/providers/Microsoft.DocumentDb/databaseAccounts/test-db-account"; string roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; ResourceIdentifier roleAssignmentResourceId = RoleAssignmentResource.CreateResourceIdentifier(scope, roleAssignmentName); RoleAssignmentResource roleAssignment = client.GetRoleAssignmentResource(roleAssignmentResourceId); @@ -115,9 +111,9 @@ public async Task Update_CreateRoleAssignmentForResourceGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateRoleAssignmentForSubscription() + public async Task Update_CreateRoleAssignmentForResourceGroup() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForSubscription.json + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForResourceGroup.json // this example is just showing the usage of "RoleAssignments_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -127,7 +123,7 @@ public async Task Update_CreateRoleAssignmentForSubscription() // this example assumes you already have this RoleAssignmentResource created on azure // for more information of creating RoleAssignmentResource, please refer to the document of RoleAssignmentResource - string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; + string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/resourceGroups/testrg"; string roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; ResourceIdentifier roleAssignmentResourceId = RoleAssignmentResource.CreateResourceIdentifier(scope, roleAssignmentName); RoleAssignmentResource roleAssignment = client.GetRoleAssignmentResource(roleAssignmentResourceId); @@ -149,10 +145,10 @@ public async Task Update_CreateRoleAssignmentForSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRoleAssignment() + public async Task Update_CreateRoleAssignmentForSubscription() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_Delete.json - // this example is just showing the usage of "RoleAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2022-04-01/examples/RoleAssignments_CreateForSubscription.json + // this example is just showing the usage of "RoleAssignments_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -162,12 +158,16 @@ public async Task Delete_DeleteRoleAssignment() // this example assumes you already have this RoleAssignmentResource created on azure // for more information of creating RoleAssignmentResource, please refer to the document of RoleAssignmentResource string scope = "subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2"; - string roleAssignmentName = "b0f43c54-e787-4862-89b1-a653fa9cf747"; + string roleAssignmentName = "05c5a614-a7d6-4502-b150-c2fb455033ff"; ResourceIdentifier roleAssignmentResourceId = RoleAssignmentResource.CreateResourceIdentifier(scope, roleAssignmentName); RoleAssignmentResource roleAssignment = client.GetRoleAssignmentResource(roleAssignmentResourceId); // invoke the operation - ArmOperation lro = await roleAssignment.DeleteAsync(WaitUntil.Completed); + RoleAssignmentCreateOrUpdateContent content = new RoleAssignmentCreateOrUpdateContent(new ResourceIdentifier("/subscriptions/a925f2f7-5c63-4b7b-8799-25a5f97bc3b2/providers/Microsoft.Authorization/roleDefinitions/0b5fe924-9a61-425c-96af-cfe6e287ca2d"), Guid.Parse("ce2ce14e-85d7-4629-bdbc-454d0519d987")) + { + PrincipalType = RoleManagementPrincipalType.User, + }; + ArmOperation lro = await roleAssignment.UpdateAsync(WaitUntil.Completed, content); RoleAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleCollection.cs index e60e7ff189d11..2bddef804b4a5 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleCollection.cs @@ -27,13 +27,9 @@ public async Task Get_GetRoleAssignmentScheduleByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleCollection collection = client.GetRoleAssignmentSchedules(scopeId); + RoleAssignmentScheduleCollection collection = client.GetRoleAssignmentSchedules(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentScheduleName = "c9e264ff-3133-4776-a81a-ebc7c33c8ec6"; @@ -46,6 +42,36 @@ public async Task Get_GetRoleAssignmentScheduleByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetRoleAssignmentSchedulesByScope() + { + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleAssignmentSchedulesByScope.json + // this example is just showing the usage of "RoleAssignmentSchedules_ListForScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this RoleAssignmentScheduleResource + string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + RoleAssignmentScheduleCollection collection = client.GetRoleAssignmentSchedules(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + string filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + await foreach (RoleAssignmentScheduleResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleAssignmentScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetRoleAssignmentScheduleByName() @@ -58,13 +84,9 @@ public async Task Exists_GetRoleAssignmentScheduleByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleCollection collection = client.GetRoleAssignmentSchedules(scopeId); + RoleAssignmentScheduleCollection collection = client.GetRoleAssignmentSchedules(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentScheduleName = "c9e264ff-3133-4776-a81a-ebc7c33c8ec6"; @@ -85,13 +107,9 @@ public async Task GetIfExists_GetRoleAssignmentScheduleByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleCollection collection = client.GetRoleAssignmentSchedules(scopeId); + RoleAssignmentScheduleCollection collection = client.GetRoleAssignmentSchedules(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentScheduleName = "c9e264ff-3133-4776-a81a-ebc7c33c8ec6"; @@ -111,39 +129,5 @@ public async Task GetIfExists_GetRoleAssignmentScheduleByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRoleAssignmentSchedulesByScope() - { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleAssignmentSchedulesByScope.json - // this example is just showing the usage of "RoleAssignmentSchedules_ListForScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this RoleAssignmentScheduleResource - string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleCollection collection = client.GetRoleAssignmentSchedules(scopeId); - - // invoke the operation and iterate over the result - string filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; - await foreach (RoleAssignmentScheduleResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleAssignmentScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleInstanceCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleInstanceCollection.cs index cc57684bb61cf..7538636d72721 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleInstanceCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleInstanceCollection.cs @@ -17,67 +17,59 @@ public partial class Sample_RoleAssignmentScheduleInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRoleAssignmentScheduleInstancesByScope() + public async Task Get_GetRoleAssignmentScheduleInstanceByName() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleAssignmentScheduleInstancesByScope.json - // this example is just showing the usage of "RoleAssignmentScheduleInstances_ListForScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleAssignmentScheduleInstanceByName.json + // this example is just showing the usage of "RoleAssignmentScheduleInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleInstanceResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleInstanceCollection collection = client.GetRoleAssignmentScheduleInstances(scopeId); + RoleAssignmentScheduleInstanceCollection collection = client.GetRoleAssignmentScheduleInstances(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - string filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; - await foreach (RoleAssignmentScheduleInstanceResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleAssignmentScheduleInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string roleAssignmentScheduleInstanceName = "ed9b8180-cef7-4c77-a63c-b8566ecfc412"; + RoleAssignmentScheduleInstanceResource result = await collection.GetAsync(roleAssignmentScheduleInstanceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleAssignmentScheduleInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRoleAssignmentScheduleInstanceByName() + public async Task GetAll_GetRoleAssignmentScheduleInstancesByScope() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleAssignmentScheduleInstanceByName.json - // this example is just showing the usage of "RoleAssignmentScheduleInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleAssignmentScheduleInstancesByScope.json + // this example is just showing the usage of "RoleAssignmentScheduleInstances_ListForScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleInstanceResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleInstanceCollection collection = client.GetRoleAssignmentScheduleInstances(scopeId); + RoleAssignmentScheduleInstanceCollection collection = client.GetRoleAssignmentScheduleInstances(new ResourceIdentifier(scope)); - // invoke the operation - string roleAssignmentScheduleInstanceName = "ed9b8180-cef7-4c77-a63c-b8566ecfc412"; - RoleAssignmentScheduleInstanceResource result = await collection.GetAsync(roleAssignmentScheduleInstanceName); + // invoke the operation and iterate over the result + string filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + await foreach (RoleAssignmentScheduleInstanceResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleAssignmentScheduleInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleAssignmentScheduleInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -92,13 +84,9 @@ public async Task Exists_GetRoleAssignmentScheduleInstanceByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleInstanceResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleInstanceCollection collection = client.GetRoleAssignmentScheduleInstances(scopeId); + RoleAssignmentScheduleInstanceCollection collection = client.GetRoleAssignmentScheduleInstances(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentScheduleInstanceName = "ed9b8180-cef7-4c77-a63c-b8566ecfc412"; @@ -119,13 +107,9 @@ public async Task GetIfExists_GetRoleAssignmentScheduleInstanceByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleInstanceResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleInstanceCollection collection = client.GetRoleAssignmentScheduleInstances(scopeId); + RoleAssignmentScheduleInstanceCollection collection = client.GetRoleAssignmentScheduleInstances(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentScheduleInstanceName = "ed9b8180-cef7-4c77-a63c-b8566ecfc412"; diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleRequestCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleRequestCollection.cs index 3eb78961c8a8d..ccf7e1065ed41 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleRequestCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleRequestCollection.cs @@ -29,17 +29,13 @@ public async Task CreateOrUpdate_PutRoleAssignmentScheduleRequest() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleRequestResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleRequestCollection collection = client.GetRoleAssignmentScheduleRequests(scopeId); + RoleAssignmentScheduleRequestCollection collection = client.GetRoleAssignmentScheduleRequests(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentScheduleRequestName = "fea7a502-9a96-4806-a26f-eee560e52045"; - RoleAssignmentScheduleRequestData data = new RoleAssignmentScheduleRequestData() + RoleAssignmentScheduleRequestData data = new RoleAssignmentScheduleRequestData { RoleDefinitionId = new ResourceIdentifier("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"), PrincipalId = Guid.Parse("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"), @@ -49,7 +45,7 @@ public async Task CreateOrUpdate_PutRoleAssignmentScheduleRequest() ConditionVersion = "1.0", StartOn = DateTimeOffset.Parse("2020-09-09T21:35:27.91Z"), ExpirationType = RoleManagementScheduleExpirationType.AfterDuration, - EndOn = null, + EndOn = default, Duration = XmlConvert.ToTimeSpan("PT8H"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleAssignmentScheduleRequestName, data); @@ -74,13 +70,9 @@ public async Task Get_GetRoleAssignmentScheduleRequestByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleRequestResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleRequestCollection collection = client.GetRoleAssignmentScheduleRequests(scopeId); + RoleAssignmentScheduleRequestCollection collection = client.GetRoleAssignmentScheduleRequests(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentScheduleRequestName = "fea7a502-9a96-4806-a26f-eee560e52045"; @@ -93,6 +85,36 @@ public async Task Get_GetRoleAssignmentScheduleRequestByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetRoleAssignmentScheduleRequestByScope() + { + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleAssignmentScheduleRequestByScope.json + // this example is just showing the usage of "RoleAssignmentScheduleRequests_ListForScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this RoleAssignmentScheduleRequestResource + string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + RoleAssignmentScheduleRequestCollection collection = client.GetRoleAssignmentScheduleRequests(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + string filter = "assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')"; + await foreach (RoleAssignmentScheduleRequestResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleAssignmentScheduleRequestData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetRoleAssignmentScheduleRequestByName() @@ -105,13 +127,9 @@ public async Task Exists_GetRoleAssignmentScheduleRequestByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleRequestResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleRequestCollection collection = client.GetRoleAssignmentScheduleRequests(scopeId); + RoleAssignmentScheduleRequestCollection collection = client.GetRoleAssignmentScheduleRequests(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentScheduleRequestName = "fea7a502-9a96-4806-a26f-eee560e52045"; @@ -132,13 +150,9 @@ public async Task GetIfExists_GetRoleAssignmentScheduleRequestByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleAssignmentScheduleRequestResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleRequestCollection collection = client.GetRoleAssignmentScheduleRequests(scopeId); + RoleAssignmentScheduleRequestCollection collection = client.GetRoleAssignmentScheduleRequests(new ResourceIdentifier(scope)); // invoke the operation string roleAssignmentScheduleRequestName = "fea7a502-9a96-4806-a26f-eee560e52045"; @@ -158,39 +172,5 @@ public async Task GetIfExists_GetRoleAssignmentScheduleRequestByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRoleAssignmentScheduleRequestByScope() - { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleAssignmentScheduleRequestByScope.json - // this example is just showing the usage of "RoleAssignmentScheduleRequests_ListForScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this RoleAssignmentScheduleRequestResource - string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleAssignmentScheduleRequestCollection collection = client.GetRoleAssignmentScheduleRequests(scopeId); - - // invoke the operation and iterate over the result - string filter = "assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')"; - await foreach (RoleAssignmentScheduleRequestResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleAssignmentScheduleRequestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleRequestResource.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleRequestResource.cs index 4605a43cd9468..a9cc1c291b664 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleRequestResource.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleAssignmentScheduleRequestResource.cs @@ -19,10 +19,10 @@ public partial class Sample_RoleAssignmentScheduleRequestResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutRoleAssignmentScheduleRequest() + public async Task Get_GetRoleAssignmentScheduleRequestByName() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/PutRoleAssignmentScheduleRequest.json - // this example is just showing the usage of "RoleAssignmentScheduleRequests_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleAssignmentScheduleRequestByName.json + // this example is just showing the usage of "RoleAssignmentScheduleRequests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,21 +37,7 @@ public async Task Update_PutRoleAssignmentScheduleRequest() RoleAssignmentScheduleRequestResource roleAssignmentScheduleRequest = client.GetRoleAssignmentScheduleRequestResource(roleAssignmentScheduleRequestResourceId); // invoke the operation - RoleAssignmentScheduleRequestData data = new RoleAssignmentScheduleRequestData() - { - RoleDefinitionId = new ResourceIdentifier("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"), - PrincipalId = Guid.Parse("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"), - RequestType = RoleManagementScheduleRequestType.SelfActivate, - LinkedRoleEligibilityScheduleId = new ResourceIdentifier("b1477448-2cc6-4ceb-93b4-54a202a89413"), - Condition = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", - ConditionVersion = "1.0", - StartOn = DateTimeOffset.Parse("2020-09-09T21:35:27.91Z"), - ExpirationType = RoleManagementScheduleExpirationType.AfterDuration, - EndOn = null, - Duration = XmlConvert.ToTimeSpan("PT8H"), - }; - ArmOperation lro = await roleAssignmentScheduleRequest.UpdateAsync(WaitUntil.Completed, data); - RoleAssignmentScheduleRequestResource result = lro.Value; + RoleAssignmentScheduleRequestResource result = await roleAssignmentScheduleRequest.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -62,10 +48,10 @@ public async Task Update_PutRoleAssignmentScheduleRequest() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRoleAssignmentScheduleRequestByName() + public async Task Update_PutRoleAssignmentScheduleRequest() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleAssignmentScheduleRequestByName.json - // this example is just showing the usage of "RoleAssignmentScheduleRequests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/PutRoleAssignmentScheduleRequest.json + // this example is just showing the usage of "RoleAssignmentScheduleRequests_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,7 +66,21 @@ public async Task Get_GetRoleAssignmentScheduleRequestByName() RoleAssignmentScheduleRequestResource roleAssignmentScheduleRequest = client.GetRoleAssignmentScheduleRequestResource(roleAssignmentScheduleRequestResourceId); // invoke the operation - RoleAssignmentScheduleRequestResource result = await roleAssignmentScheduleRequest.GetAsync(); + RoleAssignmentScheduleRequestData data = new RoleAssignmentScheduleRequestData + { + RoleDefinitionId = new ResourceIdentifier("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"), + PrincipalId = Guid.Parse("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"), + RequestType = RoleManagementScheduleRequestType.SelfActivate, + LinkedRoleEligibilityScheduleId = new ResourceIdentifier("b1477448-2cc6-4ceb-93b4-54a202a89413"), + Condition = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + ConditionVersion = "1.0", + StartOn = DateTimeOffset.Parse("2020-09-09T21:35:27.91Z"), + ExpirationType = RoleManagementScheduleExpirationType.AfterDuration, + EndOn = default, + Duration = XmlConvert.ToTimeSpan("PT8H"), + }; + ArmOperation lro = await roleAssignmentScheduleRequest.UpdateAsync(WaitUntil.Completed, data); + RoleAssignmentScheduleRequestResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -134,7 +134,7 @@ public async Task Validate_ValidateRoleAssignmentScheduleRequestByName() RoleAssignmentScheduleRequestResource roleAssignmentScheduleRequest = client.GetRoleAssignmentScheduleRequestResource(roleAssignmentScheduleRequestResourceId); // invoke the operation - RoleAssignmentScheduleRequestData data = new RoleAssignmentScheduleRequestData() + RoleAssignmentScheduleRequestData data = new RoleAssignmentScheduleRequestData { RoleDefinitionId = new ResourceIdentifier("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"), PrincipalId = Guid.Parse("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"), @@ -144,7 +144,7 @@ public async Task Validate_ValidateRoleAssignmentScheduleRequestByName() ConditionVersion = "1.0", StartOn = DateTimeOffset.Parse("2020-09-09T21:35:27.91Z"), ExpirationType = RoleManagementScheduleExpirationType.AfterDuration, - EndOn = null, + EndOn = default, Duration = XmlConvert.ToTimeSpan("PT8H"), }; RoleAssignmentScheduleRequestResource result = await roleAssignmentScheduleRequest.ValidateAsync(data); diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleCollection.cs index 739e65c296e47..0cb9658977f16 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleCollection.cs @@ -27,13 +27,9 @@ public async Task Get_GetRoleEligibilityScheduleByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleCollection collection = client.GetRoleEligibilitySchedules(scopeId); + RoleEligibilityScheduleCollection collection = client.GetRoleEligibilitySchedules(new ResourceIdentifier(scope)); // invoke the operation string roleEligibilityScheduleName = "b1477448-2cc6-4ceb-93b4-54a202a89413"; @@ -46,6 +42,36 @@ public async Task Get_GetRoleEligibilityScheduleByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetRoleEligibilitySchedulesByScope() + { + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleEligibilitySchedulesByScope.json + // this example is just showing the usage of "RoleEligibilitySchedules_ListForScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this RoleEligibilityScheduleResource + string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + RoleEligibilityScheduleCollection collection = client.GetRoleEligibilitySchedules(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + string filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + await foreach (RoleEligibilityScheduleResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleEligibilityScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetRoleEligibilityScheduleByName() @@ -58,13 +84,9 @@ public async Task Exists_GetRoleEligibilityScheduleByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleCollection collection = client.GetRoleEligibilitySchedules(scopeId); + RoleEligibilityScheduleCollection collection = client.GetRoleEligibilitySchedules(new ResourceIdentifier(scope)); // invoke the operation string roleEligibilityScheduleName = "b1477448-2cc6-4ceb-93b4-54a202a89413"; @@ -85,13 +107,9 @@ public async Task GetIfExists_GetRoleEligibilityScheduleByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleCollection collection = client.GetRoleEligibilitySchedules(scopeId); + RoleEligibilityScheduleCollection collection = client.GetRoleEligibilitySchedules(new ResourceIdentifier(scope)); // invoke the operation string roleEligibilityScheduleName = "b1477448-2cc6-4ceb-93b4-54a202a89413"; @@ -111,39 +129,5 @@ public async Task GetIfExists_GetRoleEligibilityScheduleByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRoleEligibilitySchedulesByScope() - { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleEligibilitySchedulesByScope.json - // this example is just showing the usage of "RoleEligibilitySchedules_ListForScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this RoleEligibilityScheduleResource - string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleCollection collection = client.GetRoleEligibilitySchedules(scopeId); - - // invoke the operation and iterate over the result - string filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; - await foreach (RoleEligibilityScheduleResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleEligibilityScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleInstanceCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleInstanceCollection.cs index ac9933f9944e2..207718d5b4c67 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleInstanceCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleInstanceCollection.cs @@ -17,67 +17,59 @@ public partial class Sample_RoleEligibilityScheduleInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRoleEligibilityScheduleInstancesByScope() + public async Task Get_GetRoleEligibilityScheduleInstanceByName() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleEligibilityScheduleInstancesByScope.json - // this example is just showing the usage of "RoleEligibilityScheduleInstances_ListForScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleEligibilityScheduleInstanceByName.json + // this example is just showing the usage of "RoleEligibilityScheduleInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleInstanceResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleInstanceCollection collection = client.GetRoleEligibilityScheduleInstances(scopeId); + RoleEligibilityScheduleInstanceCollection collection = client.GetRoleEligibilityScheduleInstances(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - string filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; - await foreach (RoleEligibilityScheduleInstanceResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleEligibilityScheduleInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string roleEligibilityScheduleInstanceName = "21e4b59a-0499-4fe0-a3c3-43a3055b773a"; + RoleEligibilityScheduleInstanceResource result = await collection.GetAsync(roleEligibilityScheduleInstanceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleEligibilityScheduleInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRoleEligibilityScheduleInstanceByName() + public async Task GetAll_GetRoleEligibilityScheduleInstancesByScope() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleEligibilityScheduleInstanceByName.json - // this example is just showing the usage of "RoleEligibilityScheduleInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleEligibilityScheduleInstancesByScope.json + // this example is just showing the usage of "RoleEligibilityScheduleInstances_ListForScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleInstanceResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleInstanceCollection collection = client.GetRoleEligibilityScheduleInstances(scopeId); + RoleEligibilityScheduleInstanceCollection collection = client.GetRoleEligibilityScheduleInstances(new ResourceIdentifier(scope)); - // invoke the operation - string roleEligibilityScheduleInstanceName = "21e4b59a-0499-4fe0-a3c3-43a3055b773a"; - RoleEligibilityScheduleInstanceResource result = await collection.GetAsync(roleEligibilityScheduleInstanceName); + // invoke the operation and iterate over the result + string filter = "assignedTo('a3bb8764-cb92-4276-9d2a-ca1e895e55ea')"; + await foreach (RoleEligibilityScheduleInstanceResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleEligibilityScheduleInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleEligibilityScheduleInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -92,13 +84,9 @@ public async Task Exists_GetRoleEligibilityScheduleInstanceByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleInstanceResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleInstanceCollection collection = client.GetRoleEligibilityScheduleInstances(scopeId); + RoleEligibilityScheduleInstanceCollection collection = client.GetRoleEligibilityScheduleInstances(new ResourceIdentifier(scope)); // invoke the operation string roleEligibilityScheduleInstanceName = "21e4b59a-0499-4fe0-a3c3-43a3055b773a"; @@ -119,13 +107,9 @@ public async Task GetIfExists_GetRoleEligibilityScheduleInstanceByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleInstanceResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleInstanceCollection collection = client.GetRoleEligibilityScheduleInstances(scopeId); + RoleEligibilityScheduleInstanceCollection collection = client.GetRoleEligibilityScheduleInstances(new ResourceIdentifier(scope)); // invoke the operation string roleEligibilityScheduleInstanceName = "21e4b59a-0499-4fe0-a3c3-43a3055b773a"; diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleRequestCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleRequestCollection.cs index 0c71284d6e61b..4aee45641ff64 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleRequestCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleRequestCollection.cs @@ -29,17 +29,13 @@ public async Task CreateOrUpdate_PutRoleEligibilityScheduleRequest() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleRequestResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleRequestCollection collection = client.GetRoleEligibilityScheduleRequests(scopeId); + RoleEligibilityScheduleRequestCollection collection = client.GetRoleEligibilityScheduleRequests(new ResourceIdentifier(scope)); // invoke the operation string roleEligibilityScheduleRequestName = "64caffb6-55c0-4deb-a585-68e948ea1ad6"; - RoleEligibilityScheduleRequestData data = new RoleEligibilityScheduleRequestData() + RoleEligibilityScheduleRequestData data = new RoleEligibilityScheduleRequestData { RoleDefinitionId = new ResourceIdentifier("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"), PrincipalId = Guid.Parse("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"), @@ -48,7 +44,7 @@ public async Task CreateOrUpdate_PutRoleEligibilityScheduleRequest() ConditionVersion = "1.0", StartOn = DateTimeOffset.Parse("2020-09-09T21:31:27.91Z"), ExpirationType = RoleManagementScheduleExpirationType.AfterDuration, - EndOn = null, + EndOn = default, Duration = XmlConvert.ToTimeSpan("P365D"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleEligibilityScheduleRequestName, data); @@ -73,13 +69,9 @@ public async Task Get_GetRoleEligibilityScheduleRequestByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleRequestResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleRequestCollection collection = client.GetRoleEligibilityScheduleRequests(scopeId); + RoleEligibilityScheduleRequestCollection collection = client.GetRoleEligibilityScheduleRequests(new ResourceIdentifier(scope)); // invoke the operation string roleEligibilityScheduleRequestName = "64caffb6-55c0-4deb-a585-68e948ea1ad6"; @@ -92,6 +84,36 @@ public async Task Get_GetRoleEligibilityScheduleRequestByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetRoleEligibilityScheduleRequestByScope() + { + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleEligibilityScheduleRequestByScope.json + // this example is just showing the usage of "RoleEligibilityScheduleRequests_ListForScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this RoleEligibilityScheduleRequestResource + string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; + RoleEligibilityScheduleRequestCollection collection = client.GetRoleEligibilityScheduleRequests(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + string filter = "assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')"; + await foreach (RoleEligibilityScheduleRequestResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleEligibilityScheduleRequestData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetRoleEligibilityScheduleRequestByName() @@ -104,13 +126,9 @@ public async Task Exists_GetRoleEligibilityScheduleRequestByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleRequestResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleRequestCollection collection = client.GetRoleEligibilityScheduleRequests(scopeId); + RoleEligibilityScheduleRequestCollection collection = client.GetRoleEligibilityScheduleRequests(new ResourceIdentifier(scope)); // invoke the operation string roleEligibilityScheduleRequestName = "64caffb6-55c0-4deb-a585-68e948ea1ad6"; @@ -131,13 +149,9 @@ public async Task GetIfExists_GetRoleEligibilityScheduleRequestByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleEligibilityScheduleRequestResource string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleRequestCollection collection = client.GetRoleEligibilityScheduleRequests(scopeId); + RoleEligibilityScheduleRequestCollection collection = client.GetRoleEligibilityScheduleRequests(new ResourceIdentifier(scope)); // invoke the operation string roleEligibilityScheduleRequestName = "64caffb6-55c0-4deb-a585-68e948ea1ad6"; @@ -157,39 +171,5 @@ public async Task GetIfExists_GetRoleEligibilityScheduleRequestByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRoleEligibilityScheduleRequestByScope() - { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleEligibilityScheduleRequestByScope.json - // this example is just showing the usage of "RoleEligibilityScheduleRequests_ListForScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this RoleEligibilityScheduleRequestResource - string scope = "providers/Microsoft.Subscription/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleEligibilityScheduleRequestCollection collection = client.GetRoleEligibilityScheduleRequests(scopeId); - - // invoke the operation and iterate over the result - string filter = "assignedTo('A3BB8764-CB92-4276-9D2A-CA1E895E55EA')"; - await foreach (RoleEligibilityScheduleRequestResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleEligibilityScheduleRequestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleRequestResource.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleRequestResource.cs index 2b16952d67f6f..f09962b29ab32 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleRequestResource.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleEligibilityScheduleRequestResource.cs @@ -19,10 +19,10 @@ public partial class Sample_RoleEligibilityScheduleRequestResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutRoleEligibilityScheduleRequest() + public async Task Get_GetRoleEligibilityScheduleRequestByName() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/PutRoleEligibilityScheduleRequest.json - // this example is just showing the usage of "RoleEligibilityScheduleRequests_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleEligibilityScheduleRequestByName.json + // this example is just showing the usage of "RoleEligibilityScheduleRequests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,20 +37,7 @@ public async Task Update_PutRoleEligibilityScheduleRequest() RoleEligibilityScheduleRequestResource roleEligibilityScheduleRequest = client.GetRoleEligibilityScheduleRequestResource(roleEligibilityScheduleRequestResourceId); // invoke the operation - RoleEligibilityScheduleRequestData data = new RoleEligibilityScheduleRequestData() - { - RoleDefinitionId = new ResourceIdentifier("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"), - PrincipalId = Guid.Parse("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"), - RequestType = RoleManagementScheduleRequestType.AdminAssign, - Condition = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", - ConditionVersion = "1.0", - StartOn = DateTimeOffset.Parse("2020-09-09T21:31:27.91Z"), - ExpirationType = RoleManagementScheduleExpirationType.AfterDuration, - EndOn = null, - Duration = XmlConvert.ToTimeSpan("P365D"), - }; - ArmOperation lro = await roleEligibilityScheduleRequest.UpdateAsync(WaitUntil.Completed, data); - RoleEligibilityScheduleRequestResource result = lro.Value; + RoleEligibilityScheduleRequestResource result = await roleEligibilityScheduleRequest.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -61,10 +48,10 @@ public async Task Update_PutRoleEligibilityScheduleRequest() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRoleEligibilityScheduleRequestByName() + public async Task Update_PutRoleEligibilityScheduleRequest() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleEligibilityScheduleRequestByName.json - // this example is just showing the usage of "RoleEligibilityScheduleRequests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/PutRoleEligibilityScheduleRequest.json + // this example is just showing the usage of "RoleEligibilityScheduleRequests_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -79,7 +66,20 @@ public async Task Get_GetRoleEligibilityScheduleRequestByName() RoleEligibilityScheduleRequestResource roleEligibilityScheduleRequest = client.GetRoleEligibilityScheduleRequestResource(roleEligibilityScheduleRequestResourceId); // invoke the operation - RoleEligibilityScheduleRequestResource result = await roleEligibilityScheduleRequest.GetAsync(); + RoleEligibilityScheduleRequestData data = new RoleEligibilityScheduleRequestData + { + RoleDefinitionId = new ResourceIdentifier("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"), + PrincipalId = Guid.Parse("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"), + RequestType = RoleManagementScheduleRequestType.AdminAssign, + Condition = "@Resource[Microsoft.Storage/storageAccounts/blobServices/containers:ContainerName] StringEqualsIgnoreCase 'foo_storage_container'", + ConditionVersion = "1.0", + StartOn = DateTimeOffset.Parse("2020-09-09T21:31:27.91Z"), + ExpirationType = RoleManagementScheduleExpirationType.AfterDuration, + EndOn = default, + Duration = XmlConvert.ToTimeSpan("P365D"), + }; + ArmOperation lro = await roleEligibilityScheduleRequest.UpdateAsync(WaitUntil.Completed, data); + RoleEligibilityScheduleRequestResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -133,7 +133,7 @@ public async Task Validate_ValidateRoleEligibilityScheduleRequestByName() RoleEligibilityScheduleRequestResource roleEligibilityScheduleRequest = client.GetRoleEligibilityScheduleRequestResource(roleEligibilityScheduleRequestResourceId); // invoke the operation - RoleEligibilityScheduleRequestData data = new RoleEligibilityScheduleRequestData() + RoleEligibilityScheduleRequestData data = new RoleEligibilityScheduleRequestData { RoleDefinitionId = new ResourceIdentifier("/subscriptions/dfa2a084-766f-4003-8ae1-c4aeb893a99f/providers/Microsoft.Authorization/roleDefinitions/c8d4ff99-41c3-41a8-9f60-21dfdad59608"), PrincipalId = Guid.Parse("a3bb8764-cb92-4276-9d2a-ca1e895e55ea"), @@ -142,7 +142,7 @@ public async Task Validate_ValidateRoleEligibilityScheduleRequestByName() ConditionVersion = "1.0", StartOn = DateTimeOffset.Parse("2020-09-09T21:31:27.91Z"), ExpirationType = RoleManagementScheduleExpirationType.AfterDuration, - EndOn = null, + EndOn = default, Duration = XmlConvert.ToTimeSpan("P365D"), }; RoleEligibilityScheduleRequestResource result = await roleEligibilityScheduleRequest.ValidateAsync(data); diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyAssignmentCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyAssignmentCollection.cs index 70e46a99c05d2..86aa8f6a9c99f 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyAssignmentCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyAssignmentCollection.cs @@ -17,27 +17,30 @@ public partial class Sample_RoleManagementPolicyAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetConfigurations() + public async Task CreateOrUpdate_PutRoleManagementPolicyAssignment() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleManagementPolicyAssignmentByName.json - // this example is just showing the usage of "RoleManagementPolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/PutRoleManagementPolicyAssignment.json + // this example is just showing the usage of "RoleManagementPolicyAssignments_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleManagementPolicyAssignmentResource string scope = "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleManagementPolicyAssignmentCollection collection = client.GetRoleManagementPolicyAssignments(scopeId); + RoleManagementPolicyAssignmentCollection collection = client.GetRoleManagementPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string roleManagementPolicyAssignmentName = "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; - RoleManagementPolicyAssignmentResource result = await collection.GetAsync(roleManagementPolicyAssignmentName); + RoleManagementPolicyAssignmentData data = new RoleManagementPolicyAssignmentData + { + Scope = "/subscriptions/129ff972-28f8-46b8-a726-e497be039368", + RoleDefinitionId = new ResourceIdentifier("/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleDefinitions/a1705bd2-3a8f-45a5-8683-466fcfd5cc24"), + PolicyId = new ResourceIdentifier("/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleManagementPolicies/b959d571-f0b5-4042-88a7-01be6cb22db9"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleManagementPolicyAssignmentName, data); + RoleManagementPolicyAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -48,7 +51,7 @@ public async Task Get_GetConfigurations() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetConfigurations() + public async Task Get_GetConfigurations() { // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleManagementPolicyAssignmentByName.json // this example is just showing the usage of "RoleManagementPolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. @@ -58,129 +61,106 @@ public async Task Exists_GetConfigurations() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleManagementPolicyAssignmentResource string scope = "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleManagementPolicyAssignmentCollection collection = client.GetRoleManagementPolicyAssignments(scopeId); + RoleManagementPolicyAssignmentCollection collection = client.GetRoleManagementPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string roleManagementPolicyAssignmentName = "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; - bool result = await collection.ExistsAsync(roleManagementPolicyAssignmentName); + RoleManagementPolicyAssignmentResource result = await collection.GetAsync(roleManagementPolicyAssignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleManagementPolicyAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetConfigurations() + public async Task GetAll_GetRoleManagementPolicyAssignmentByScope() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleManagementPolicyAssignmentByName.json - // this example is just showing the usage of "RoleManagementPolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleManagementPolicyAssignmentByScope.json + // this example is just showing the usage of "RoleManagementPolicyAssignments_ListForScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleManagementPolicyAssignmentResource string scope = "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleManagementPolicyAssignmentCollection collection = client.GetRoleManagementPolicyAssignments(scopeId); - - // invoke the operation - string roleManagementPolicyAssignmentName = "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; - NullableResponse response = await collection.GetIfExistsAsync(roleManagementPolicyAssignmentName); - RoleManagementPolicyAssignmentResource result = response.HasValue ? response.Value : null; + RoleManagementPolicyAssignmentCollection collection = client.GetRoleManagementPolicyAssignments(new ResourceIdentifier(scope)); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (RoleManagementPolicyAssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RoleManagementPolicyAssignmentData resourceData = result.Data; + RoleManagementPolicyAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutRoleManagementPolicyAssignment() + public async Task Exists_GetConfigurations() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/PutRoleManagementPolicyAssignment.json - // this example is just showing the usage of "RoleManagementPolicyAssignments_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleManagementPolicyAssignmentByName.json + // this example is just showing the usage of "RoleManagementPolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleManagementPolicyAssignmentResource string scope = "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleManagementPolicyAssignmentCollection collection = client.GetRoleManagementPolicyAssignments(scopeId); + RoleManagementPolicyAssignmentCollection collection = client.GetRoleManagementPolicyAssignments(new ResourceIdentifier(scope)); // invoke the operation string roleManagementPolicyAssignmentName = "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; - RoleManagementPolicyAssignmentData data = new RoleManagementPolicyAssignmentData() - { - Scope = "/subscriptions/129ff972-28f8-46b8-a726-e497be039368", - RoleDefinitionId = new ResourceIdentifier("/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleDefinitions/a1705bd2-3a8f-45a5-8683-466fcfd5cc24"), - PolicyId = new ResourceIdentifier("/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleManagementPolicies/b959d571-f0b5-4042-88a7-01be6cb22db9"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, roleManagementPolicyAssignmentName, data); - RoleManagementPolicyAssignmentResource result = lro.Value; + bool result = await collection.ExistsAsync(roleManagementPolicyAssignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleManagementPolicyAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRoleManagementPolicyAssignmentByScope() + public async Task GetIfExists_GetConfigurations() { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleManagementPolicyAssignmentByScope.json - // this example is just showing the usage of "RoleManagementPolicyAssignments_ListForScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleManagementPolicyAssignmentByName.json + // this example is just showing the usage of "RoleManagementPolicyAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleManagementPolicyAssignmentResource string scope = "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleManagementPolicyAssignmentCollection collection = client.GetRoleManagementPolicyAssignments(scopeId); + RoleManagementPolicyAssignmentCollection collection = client.GetRoleManagementPolicyAssignments(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (RoleManagementPolicyAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string roleManagementPolicyAssignmentName = "b959d571-f0b5-4042-88a7-01be6cb22db9_a1705bd2-3a8f-45a5-8683-466fcfd5cc24"; + NullableResponse response = await collection.GetIfExistsAsync(roleManagementPolicyAssignmentName); + RoleManagementPolicyAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RoleManagementPolicyAssignmentData resourceData = item.Data; + RoleManagementPolicyAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyAssignmentResource.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyAssignmentResource.cs index 59264d6b08fcb..83030f7c91c5c 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyAssignmentResource.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyAssignmentResource.cs @@ -64,7 +64,7 @@ public async Task Update_PutRoleManagementPolicyAssignment() RoleManagementPolicyAssignmentResource roleManagementPolicyAssignment = client.GetRoleManagementPolicyAssignmentResource(roleManagementPolicyAssignmentResourceId); // invoke the operation - RoleManagementPolicyAssignmentData data = new RoleManagementPolicyAssignmentData() + RoleManagementPolicyAssignmentData data = new RoleManagementPolicyAssignmentData { Scope = "/subscriptions/129ff972-28f8-46b8-a726-e497be039368", RoleDefinitionId = new ResourceIdentifier("/subscriptions/129ff972-28f8-46b8-a726-e497be039368/providers/Microsoft.Authorization/roleDefinitions/a1705bd2-3a8f-45a5-8683-466fcfd5cc24"), diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyCollection.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyCollection.cs index 4a15cd391d859..97be7f353bc97 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyCollection.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyCollection.cs @@ -27,13 +27,9 @@ public async Task Get_GetRoleManagementPolicyByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleManagementPolicyResource string scope = "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleManagementPolicyCollection collection = client.GetRoleManagementPolicies(scopeId); + RoleManagementPolicyCollection collection = client.GetRoleManagementPolicies(new ResourceIdentifier(scope)); // invoke the operation string roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; @@ -46,6 +42,35 @@ public async Task Get_GetRoleManagementPolicyByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetRoleManagementPolicyByRoleDefinitionFilter() + { + // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleManagementPolicyByScope.json + // this example is just showing the usage of "RoleManagementPolicies_ListForScope" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this RoleManagementPolicyResource + string scope = "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; + RoleManagementPolicyCollection collection = client.GetRoleManagementPolicies(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (RoleManagementPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoleManagementPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetRoleManagementPolicyByName() @@ -58,13 +83,9 @@ public async Task Exists_GetRoleManagementPolicyByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleManagementPolicyResource string scope = "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleManagementPolicyCollection collection = client.GetRoleManagementPolicies(scopeId); + RoleManagementPolicyCollection collection = client.GetRoleManagementPolicies(new ResourceIdentifier(scope)); // invoke the operation string roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; @@ -85,13 +106,9 @@ public async Task GetIfExists_GetRoleManagementPolicyByName() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this RoleManagementPolicyResource string scope = "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleManagementPolicyCollection collection = client.GetRoleManagementPolicies(scopeId); + RoleManagementPolicyCollection collection = client.GetRoleManagementPolicies(new ResourceIdentifier(scope)); // invoke the operation string roleManagementPolicyName = "570c3619-7688-4b34-b290-2b8bb3ccab2a"; @@ -111,38 +128,5 @@ public async Task GetIfExists_GetRoleManagementPolicyByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRoleManagementPolicyByRoleDefinitionFilter() - { - // Generated from example definition: specification/authorization/resource-manager/Microsoft.Authorization/stable/2020-10-01/examples/GetRoleManagementPolicyByScope.json - // this example is just showing the usage of "RoleManagementPolicies_ListForScope" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this RoleManagementPolicyResource - string scope = "providers/Microsoft.Subscription/subscriptions/129ff972-28f8-46b8-a726-e497be039368"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - RoleManagementPolicyCollection collection = client.GetRoleManagementPolicies(scopeId); - - // invoke the operation and iterate over the result - await foreach (RoleManagementPolicyResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoleManagementPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyResource.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyResource.cs index d08173d9f8e5d..0bd1002908c91 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyResource.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_RoleManagementPolicyResource.cs @@ -66,64 +66,40 @@ public async Task Update_PatchPartialRoleManagementPolicy() RoleManagementPolicyResource roleManagementPolicy = client.GetRoleManagementPolicyResource(roleManagementPolicyResourceId); // invoke the operation - RoleManagementPolicyData data = new RoleManagementPolicyData() + RoleManagementPolicyData data = new RoleManagementPolicyData { - Rules = -{ -new RoleManagementPolicyExpirationRule() + Rules = {new RoleManagementPolicyExpirationRule { IsExpirationRequired = false, MaximumDuration = XmlConvert.ToTimeSpan("P180D"), Id = "Expiration_Admin_Eligibility", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Eligibility, -TargetObjects = -{ -}, -InheritableSettings = -{ +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -EnforcedSettings = -{ -}, -}, -},new RoleManagementPolicyNotificationRule() +}, new RoleManagementPolicyNotificationRule { NotificationDeliveryType = NotificationDeliveryType.Email, NotificationLevel = RoleManagementPolicyNotificationLevel.Critical, RecipientType = RoleManagementPolicyRecipientType.Admin, -NotificationRecipients = -{ -"admin_admin_eligible@test.com" -}, +NotificationRecipients = {"admin_admin_eligible@test.com"}, AreDefaultRecipientsEnabled = false, Id = "Notification_Admin_Admin_Eligibility", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Eligibility, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, -}, -} +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, +}}, }; RoleManagementPolicyResource result = await roleManagementPolicy.UpdateAsync(data); @@ -154,495 +130,297 @@ public async Task Update_PatchRoleManagementPolicy() RoleManagementPolicyResource roleManagementPolicy = client.GetRoleManagementPolicyResource(roleManagementPolicyResourceId); // invoke the operation - RoleManagementPolicyData data = new RoleManagementPolicyData() + RoleManagementPolicyData data = new RoleManagementPolicyData { - Rules = -{ -new RoleManagementPolicyExpirationRule() + Rules = {new RoleManagementPolicyExpirationRule { IsExpirationRequired = false, MaximumDuration = XmlConvert.ToTimeSpan("P180D"), Id = "Expiration_Admin_Eligibility", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Eligibility, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -},new RoleManagementPolicyNotificationRule() +}, new RoleManagementPolicyNotificationRule { NotificationDeliveryType = NotificationDeliveryType.Email, NotificationLevel = RoleManagementPolicyNotificationLevel.Critical, RecipientType = RoleManagementPolicyRecipientType.Admin, -NotificationRecipients = -{ -"admin_admin_eligible@test.com" -}, +NotificationRecipients = {"admin_admin_eligible@test.com"}, AreDefaultRecipientsEnabled = false, Id = "Notification_Admin_Admin_Eligibility", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Eligibility, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -}, -},new RoleManagementPolicyNotificationRule() +}, new RoleManagementPolicyNotificationRule { NotificationDeliveryType = NotificationDeliveryType.Email, NotificationLevel = RoleManagementPolicyNotificationLevel.Critical, RecipientType = RoleManagementPolicyRecipientType.Requestor, -NotificationRecipients = -{ -"requestor_admin_eligible@test.com" -}, +NotificationRecipients = {"requestor_admin_eligible@test.com"}, AreDefaultRecipientsEnabled = false, Id = "Notification_Requestor_Admin_Eligibility", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Eligibility, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -},new RoleManagementPolicyNotificationRule() +}, new RoleManagementPolicyNotificationRule { NotificationDeliveryType = NotificationDeliveryType.Email, NotificationLevel = RoleManagementPolicyNotificationLevel.Critical, RecipientType = RoleManagementPolicyRecipientType.Approver, -NotificationRecipients = -{ -"approver_admin_eligible@test.com" -}, +NotificationRecipients = {"approver_admin_eligible@test.com"}, AreDefaultRecipientsEnabled = false, Id = "Notification_Approver_Admin_Eligibility", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Eligibility, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -},new RoleManagementPolicyEnablementRule() +}, new RoleManagementPolicyEnablementRule { -EnablementRules = -{ -}, +EnablementRules = {}, Id = "Enablement_Admin_Eligibility", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Eligibility, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -}, -},new RoleManagementPolicyExpirationRule() +}, new RoleManagementPolicyExpirationRule { IsExpirationRequired = false, MaximumDuration = XmlConvert.ToTimeSpan("P90D"), Id = "Expiration_Admin_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -},new RoleManagementPolicyEnablementRule() +}, new RoleManagementPolicyEnablementRule { -EnablementRules = -{ -RoleAssignmentEnablementRuleType.Justification,RoleAssignmentEnablementRuleType.MultiFactorAuthentication -}, +EnablementRules = {RoleAssignmentEnablementRuleType.Justification, RoleAssignmentEnablementRuleType.MultiFactorAuthentication}, Id = "Enablement_Admin_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -}, -},new RoleManagementPolicyNotificationRule() +}, new RoleManagementPolicyNotificationRule { NotificationDeliveryType = NotificationDeliveryType.Email, NotificationLevel = RoleManagementPolicyNotificationLevel.Critical, RecipientType = RoleManagementPolicyRecipientType.Admin, -NotificationRecipients = -{ -"admin_admin_member@test.com" -}, +NotificationRecipients = {"admin_admin_member@test.com"}, AreDefaultRecipientsEnabled = false, Id = "Notification_Admin_Admin_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -},new RoleManagementPolicyNotificationRule() +}, new RoleManagementPolicyNotificationRule { NotificationDeliveryType = NotificationDeliveryType.Email, NotificationLevel = RoleManagementPolicyNotificationLevel.Critical, RecipientType = RoleManagementPolicyRecipientType.Requestor, -NotificationRecipients = -{ -"requestor_admin_member@test.com" -}, +NotificationRecipients = {"requestor_admin_member@test.com"}, AreDefaultRecipientsEnabled = false, Id = "Notification_Requestor_Admin_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -},new RoleManagementPolicyNotificationRule() +}, new RoleManagementPolicyNotificationRule { NotificationDeliveryType = NotificationDeliveryType.Email, NotificationLevel = RoleManagementPolicyNotificationLevel.Critical, RecipientType = RoleManagementPolicyRecipientType.Approver, -NotificationRecipients = -{ -"approver_admin_member@test.com" -}, +NotificationRecipients = {"approver_admin_member@test.com"}, AreDefaultRecipientsEnabled = false, Id = "Notification_Approver_Admin_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "Admin", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -}, -},new RoleManagementPolicyExpirationRule() +}, new RoleManagementPolicyExpirationRule { IsExpirationRequired = true, MaximumDuration = XmlConvert.ToTimeSpan("PT7H"), Id = "Expiration_EndUser_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "EndUser", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -},new RoleManagementPolicyEnablementRule() +}, new RoleManagementPolicyEnablementRule { -EnablementRules = -{ -RoleAssignmentEnablementRuleType.Justification,RoleAssignmentEnablementRuleType.MultiFactorAuthentication,RoleAssignmentEnablementRuleType.Ticketing -}, +EnablementRules = {RoleAssignmentEnablementRuleType.Justification, RoleAssignmentEnablementRuleType.MultiFactorAuthentication, RoleAssignmentEnablementRuleType.Ticketing}, Id = "Enablement_EndUser_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "EndUser", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -}, -},new RoleManagementPolicyApprovalRule() +}, new RoleManagementPolicyApprovalRule { -Settings = new RoleManagementApprovalSettings() +Settings = new RoleManagementApprovalSettings { IsApprovalRequired = true, IsApprovalRequiredForExtension = false, IsRequestorJustificationRequired = true, ApprovalMode = RoleManagementApprovalMode.SingleStage, -ApprovalStages = -{ -new RoleManagementApprovalStage() +ApprovalStages = {new RoleManagementApprovalStage { ApprovalStageTimeOutInDays = 1, IsApproverJustificationRequired = true, EscalationTimeInMinutes = 0, -PrimaryApprovers = -{ -new RoleManagementUserInfo() +PrimaryApprovers = {new RoleManagementUserInfo { UserType = RoleManagementUserType.Group, IsBackup = false, Id = "2385b0f3-5fa9-43cf-8ca4-b01dc97298cd", Description = "amansw_new_group", -},new RoleManagementUserInfo() +}, new RoleManagementUserInfo { UserType = RoleManagementUserType.Group, IsBackup = false, Id = "2f4913c9-d15b-406a-9946-1d66a28f2690", Description = "amansw_group", -} -}, +}}, IsEscalationEnabled = false, -EscalationApprovers = -{ -}, -} -}, +EscalationApprovers = {}, +}}, }, Id = "Approval_EndUser_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "EndUser", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -},new RoleManagementPolicyAuthenticationContextRule() +}, new RoleManagementPolicyAuthenticationContextRule { IsEnabled = false, ClaimValue = "", Id = "AuthenticationContext_EndUser_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "EndUser", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -}, -},new RoleManagementPolicyNotificationRule() +}, new RoleManagementPolicyNotificationRule { NotificationDeliveryType = NotificationDeliveryType.Email, NotificationLevel = RoleManagementPolicyNotificationLevel.Critical, RecipientType = RoleManagementPolicyRecipientType.Admin, -NotificationRecipients = -{ -"admin_enduser_member@test.com" -}, +NotificationRecipients = {"admin_enduser_member@test.com"}, AreDefaultRecipientsEnabled = false, Id = "Notification_Admin_EndUser_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "EndUser", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -},new RoleManagementPolicyNotificationRule() +}, new RoleManagementPolicyNotificationRule { NotificationDeliveryType = NotificationDeliveryType.Email, NotificationLevel = RoleManagementPolicyNotificationLevel.Critical, RecipientType = RoleManagementPolicyRecipientType.Requestor, -NotificationRecipients = -{ -"requestor_enduser_member@test.com" -}, +NotificationRecipients = {"requestor_enduser_member@test.com"}, AreDefaultRecipientsEnabled = false, Id = "Notification_Requestor_EndUser_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "EndUser", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, -},new RoleManagementPolicyNotificationRule() +}, new RoleManagementPolicyNotificationRule { NotificationDeliveryType = NotificationDeliveryType.Email, NotificationLevel = RoleManagementPolicyNotificationLevel.Critical, RecipientType = RoleManagementPolicyRecipientType.Approver, -NotificationRecipients = -{ -}, +NotificationRecipients = {}, AreDefaultRecipientsEnabled = true, Id = "Notification_Approver_EndUser_Assignment", -Target = new RoleManagementPolicyRuleTarget() +Target = new RoleManagementPolicyRuleTarget { Caller = "EndUser", -Operations = -{ -"All" -}, +Operations = {"All"}, Level = RoleManagementAssignmentLevel.Assignment, -TargetObjects = -{ -}, -InheritableSettings = -{ -}, -EnforcedSettings = -{ -}, -}, -} +TargetObjects = {}, +InheritableSettings = {}, +EnforcedSettings = {}, }, +}}, }; RoleManagementPolicyResource result = await roleManagementPolicy.UpdateAsync(data); diff --git a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index bbc64fd8df0e4..5eb15b6de253e 100644 --- a/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/authorization/Azure.ResourceManager.Authorization/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Authorization.Samples @@ -27,9 +28,7 @@ public async Task ElevateAccessGlobalAdministrator_ElevateAccessGlobalAdministra // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation await tenantResource.ElevateAccessGlobalAdministratorAsync(); diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageBestPracticeCollection.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageBestPracticeCollection.cs index 86ea7802fe6c4..1fc49c264913a 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageBestPracticeCollection.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageBestPracticeCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Automanage.Samples @@ -27,9 +28,7 @@ public async Task Get_GetAnAutomanageBestPractice() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this AutomanageBestPracticeResource AutomanageBestPracticeCollection collection = tenantResource.GetAutomanageBestPractices(); @@ -45,6 +44,36 @@ public async Task Get_GetAnAutomanageBestPractice() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAutomanageBestPractices() + { + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listBestPracticesByTenant.json + // this example is just showing the usage of "BestPractices_ListByTenant" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this AutomanageBestPracticeResource + AutomanageBestPracticeCollection collection = tenantResource.GetAutomanageBestPractices(); + + // invoke the operation and iterate over the result + await foreach (AutomanageBestPracticeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageBestPracticeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAnAutomanageBestPractice() @@ -57,9 +86,7 @@ public async Task Exists_GetAnAutomanageBestPractice() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this AutomanageBestPracticeResource AutomanageBestPracticeCollection collection = tenantResource.GetAutomanageBestPractices(); @@ -83,9 +110,7 @@ public async Task GetIfExists_GetAnAutomanageBestPractice() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this AutomanageBestPracticeResource AutomanageBestPracticeCollection collection = tenantResource.GetAutomanageBestPractices(); @@ -108,37 +133,5 @@ public async Task GetIfExists_GetAnAutomanageBestPractice() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAutomanageBestPractices() - { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listBestPracticesByTenant.json - // this example is just showing the usage of "BestPractices_ListByTenant" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this AutomanageBestPracticeResource - AutomanageBestPracticeCollection collection = tenantResource.GetAutomanageBestPractices(); - - // invoke the operation and iterate over the result - await foreach (AutomanageBestPracticeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageBestPracticeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileCollection.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileCollection.cs index d3e3a0fc577fb..35bb7f2e333f9 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileCollection.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateOrUpdateConfigurationProfile() string configurationProfileName = "customConfigurationProfile"; AutomanageConfigurationProfileData data = new AutomanageConfigurationProfileData(new AzureLocation("East US")) { - Configuration = BinaryData.FromObjectAsJson(new Dictionary() + Configuration = BinaryData.FromObjectAsJson(new Dictionary { ["Antimalware/Enable"] = "false", ["AzureSecurityCenter/Enable"] = "true", @@ -57,7 +57,7 @@ public async Task CreateOrUpdate_CreateOrUpdateConfigurationProfile() }), Tags = { -["Organization"] = "Administration", +["Organization"] = "Administration" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationProfileName, data); @@ -105,10 +105,10 @@ public async Task Get_GetAConfigurationProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAConfigurationProfile() + public async Task GetAll_ListConfigurationProfilesByResourceGroup() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfile.json - // this example is just showing the usage of "ConfigurationProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfilesByResourceGroup.json + // this example is just showing the usage of "ConfigurationProfiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,16 +125,22 @@ public async Task Exists_GetAConfigurationProfile() // get the collection of this AutomanageConfigurationProfileResource AutomanageConfigurationProfileCollection collection = resourceGroupResource.GetAutomanageConfigurationProfiles(); - // invoke the operation - string configurationProfileName = "customConfigurationProfile"; - bool result = await collection.ExistsAsync(configurationProfileName); + // invoke the operation and iterate over the result + await foreach (AutomanageConfigurationProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAConfigurationProfile() + public async Task Exists_GetAConfigurationProfile() { // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfile.json // this example is just showing the usage of "ConfigurationProfiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -156,29 +162,17 @@ public async Task GetIfExists_GetAConfigurationProfile() // invoke the operation string configurationProfileName = "customConfigurationProfile"; - NullableResponse response = await collection.GetIfExistsAsync(configurationProfileName); - AutomanageConfigurationProfileResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationProfileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConfigurationProfilesByResourceGroup() + public async Task GetIfExists_GetAConfigurationProfile() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfilesByResourceGroup.json - // this example is just showing the usage of "ConfigurationProfiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfile.json + // this example is just showing the usage of "ConfigurationProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,17 +189,23 @@ public async Task GetAll_ListConfigurationProfilesByResourceGroup() // get the collection of this AutomanageConfigurationProfileResource AutomanageConfigurationProfileCollection collection = resourceGroupResource.GetAutomanageConfigurationProfiles(); - // invoke the operation and iterate over the result - await foreach (AutomanageConfigurationProfileResource item in collection.GetAllAsync()) + // invoke the operation + string configurationProfileName = "customConfigurationProfile"; + NullableResponse response = await collection.GetIfExistsAsync(configurationProfileName); + AutomanageConfigurationProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileData resourceData = item.Data; + AutomanageConfigurationProfileData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileResource.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileResource.cs index eb8b4c9c3c278..ccfb7e2dbe2a4 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileResource.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Automanage.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Automanage.Samples @@ -95,9 +94,9 @@ public async Task Update_UpdateConfigurationProfile() AutomanageConfigurationProfileResource automanageConfigurationProfile = client.GetAutomanageConfigurationProfileResource(automanageConfigurationProfileResourceId); // invoke the operation - AutomanageConfigurationProfilePatch patch = new AutomanageConfigurationProfilePatch() + AutomanageConfigurationProfilePatch patch = new AutomanageConfigurationProfilePatch { - Configuration = BinaryData.FromObjectAsJson(new Dictionary() + Configuration = BinaryData.FromObjectAsJson(new Dictionary { ["Antimalware/Enable"] = "false", ["AzureSecurityCenter/Enable"] = "true", @@ -111,7 +110,7 @@ public async Task Update_UpdateConfigurationProfile() }), Tags = { -["Organization"] = "Administration", +["Organization"] = "Administration" }, }; AutomanageConfigurationProfileResource result = await automanageConfigurationProfile.UpdateAsync(patch); @@ -122,36 +121,5 @@ public async Task Update_UpdateConfigurationProfile() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAutomanageConfigurationProfiles_ListConfigurationProfilesBySubscription() - { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfilesBySubscription.json - // this example is just showing the usage of "ConfigurationProfiles_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "mySubscriptionId"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AutomanageConfigurationProfileResource item in subscriptionResource.GetAutomanageConfigurationProfilesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileVersionCollection.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileVersionCollection.cs index f4f32db0cbd20..9caefb03e5eb1 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileVersionCollection.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileVersionCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateOrUpdateConfigurationProfileVersion() string versionName = "version1"; AutomanageConfigurationProfileData data = new AutomanageConfigurationProfileData(new AzureLocation("East US")) { - Configuration = BinaryData.FromObjectAsJson(new Dictionary() + Configuration = BinaryData.FromObjectAsJson(new Dictionary { ["Antimalware/Enable"] = "false", ["AzureSecurityCenter/Enable"] = "true", @@ -57,7 +57,7 @@ public async Task CreateOrUpdate_CreateOrUpdateConfigurationProfileVersion() }), Tags = { -["Organization"] = "Administration", +["Organization"] = "Administration" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, versionName, data); @@ -106,10 +106,10 @@ public async Task Get_GetAConfigurationProfileVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAConfigurationProfileVersion() + public async Task GetAll_ListConfigurationProfileVersionsByConfigurationProfile() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileVersion.json - // this example is just showing the usage of "ConfigurationProfilesVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfileVersions.json + // this example is just showing the usage of "ConfigurationProfilesVersions_ListChildResources" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,16 +127,22 @@ public async Task Exists_GetAConfigurationProfileVersion() // get the collection of this AutomanageConfigurationProfileVersionResource AutomanageConfigurationProfileVersionCollection collection = automanageConfigurationProfile.GetAutomanageConfigurationProfileVersions(); - // invoke the operation - string versionName = "version1"; - bool result = await collection.ExistsAsync(versionName); + // invoke the operation and iterate over the result + await foreach (AutomanageConfigurationProfileVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAConfigurationProfileVersion() + public async Task Exists_GetAConfigurationProfileVersion() { // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileVersion.json // this example is just showing the usage of "ConfigurationProfilesVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -159,29 +165,17 @@ public async Task GetIfExists_GetAConfigurationProfileVersion() // invoke the operation string versionName = "version1"; - NullableResponse response = await collection.GetIfExistsAsync(versionName); - AutomanageConfigurationProfileVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(versionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConfigurationProfileVersionsByConfigurationProfile() + public async Task GetIfExists_GetAConfigurationProfileVersion() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfileVersions.json - // this example is just showing the usage of "ConfigurationProfilesVersions_ListChildResources" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileVersion.json + // this example is just showing the usage of "ConfigurationProfilesVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,17 +193,23 @@ public async Task GetAll_ListConfigurationProfileVersionsByConfigurationProfile( // get the collection of this AutomanageConfigurationProfileVersionResource AutomanageConfigurationProfileVersionCollection collection = automanageConfigurationProfile.GetAutomanageConfigurationProfileVersions(); - // invoke the operation and iterate over the result - await foreach (AutomanageConfigurationProfileVersionResource item in collection.GetAllAsync()) + // invoke the operation + string versionName = "version1"; + NullableResponse response = await collection.GetIfExistsAsync(versionName); + AutomanageConfigurationProfileVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileData resourceData = item.Data; + AutomanageConfigurationProfileData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileVersionResource.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileVersionResource.cs index 6d28589a9b697..23d0b35a181a2 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileVersionResource.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageConfigurationProfileVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomanageConfigurationProfileVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateConfigurationProfileVersion() + public async Task Get_GetAConfigurationProfileVersion() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/createOrUpdateConfigurationProfileVersion.json - // this example is just showing the usage of "ConfigurationProfilesVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileVersion.json + // this example is just showing the usage of "ConfigurationProfilesVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,27 +38,7 @@ public async Task Update_CreateOrUpdateConfigurationProfileVersion() AutomanageConfigurationProfileVersionResource automanageConfigurationProfileVersion = client.GetAutomanageConfigurationProfileVersionResource(automanageConfigurationProfileVersionResourceId); // invoke the operation - AutomanageConfigurationProfileData data = new AutomanageConfigurationProfileData(new AzureLocation("East US")) - { - Configuration = BinaryData.FromObjectAsJson(new Dictionary() - { - ["Antimalware/Enable"] = "false", - ["AzureSecurityCenter/Enable"] = "true", - ["Backup/Enable"] = "false", - ["BootDiagnostics/Enable"] = "true", - ["ChangeTrackingAndInventory/Enable"] = "true", - ["GuestConfiguration/Enable"] = "true", - ["LogAnalytics/Enable"] = "true", - ["UpdateManagement/Enable"] = "true", - ["VMInsights/Enable"] = "true" - }), - Tags = -{ -["Organization"] = "Administration", -}, - }; - ArmOperation lro = await automanageConfigurationProfileVersion.UpdateAsync(WaitUntil.Completed, data); - AutomanageConfigurationProfileVersionResource result = lro.Value; + AutomanageConfigurationProfileVersionResource result = await automanageConfigurationProfileVersion.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -69,10 +49,10 @@ public async Task Update_CreateOrUpdateConfigurationProfileVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAConfigurationProfileVersion() + public async Task Delete_DeleteAConfigurationProfileVersion() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileVersion.json - // this example is just showing the usage of "ConfigurationProfilesVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/deleteConfigurationProfileVersion.json + // this example is just showing the usage of "ConfigurationProfilesVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -81,29 +61,25 @@ public async Task Get_GetAConfigurationProfileVersion() // this example assumes you already have this AutomanageConfigurationProfileVersionResource created on azure // for more information of creating AutomanageConfigurationProfileVersionResource, please refer to the document of AutomanageConfigurationProfileVersionResource - string subscriptionId = "mySubscriptionId"; - string resourceGroupName = "myResourceGroupName"; + string subscriptionId = "subid"; + string resourceGroupName = "rg"; string configurationProfileName = "customConfigurationProfile"; string versionName = "version1"; ResourceIdentifier automanageConfigurationProfileVersionResourceId = AutomanageConfigurationProfileVersionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, configurationProfileName, versionName); AutomanageConfigurationProfileVersionResource automanageConfigurationProfileVersion = client.GetAutomanageConfigurationProfileVersionResource(automanageConfigurationProfileVersionResourceId); // invoke the operation - AutomanageConfigurationProfileVersionResource result = await automanageConfigurationProfileVersion.GetAsync(); + await automanageConfigurationProfileVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAConfigurationProfileVersion() + public async Task Update_CreateOrUpdateConfigurationProfileVersion() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/deleteConfigurationProfileVersion.json - // this example is just showing the usage of "ConfigurationProfilesVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/createOrUpdateConfigurationProfileVersion.json + // this example is just showing the usage of "ConfigurationProfilesVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,17 +88,41 @@ public async Task Delete_DeleteAConfigurationProfileVersion() // this example assumes you already have this AutomanageConfigurationProfileVersionResource created on azure // for more information of creating AutomanageConfigurationProfileVersionResource, please refer to the document of AutomanageConfigurationProfileVersionResource - string subscriptionId = "subid"; - string resourceGroupName = "rg"; + string subscriptionId = "mySubscriptionId"; + string resourceGroupName = "myResourceGroupName"; string configurationProfileName = "customConfigurationProfile"; string versionName = "version1"; ResourceIdentifier automanageConfigurationProfileVersionResourceId = AutomanageConfigurationProfileVersionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, configurationProfileName, versionName); AutomanageConfigurationProfileVersionResource automanageConfigurationProfileVersion = client.GetAutomanageConfigurationProfileVersionResource(automanageConfigurationProfileVersionResourceId); // invoke the operation - await automanageConfigurationProfileVersion.DeleteAsync(WaitUntil.Completed); + AutomanageConfigurationProfileData data = new AutomanageConfigurationProfileData(new AzureLocation("East US")) + { + Configuration = BinaryData.FromObjectAsJson(new Dictionary + { + ["Antimalware/Enable"] = "false", + ["AzureSecurityCenter/Enable"] = "true", + ["Backup/Enable"] = "false", + ["BootDiagnostics/Enable"] = "true", + ["ChangeTrackingAndInventory/Enable"] = "true", + ["GuestConfiguration/Enable"] = "true", + ["LogAnalytics/Enable"] = "true", + ["UpdateManagement/Enable"] = "true", + ["VMInsights/Enable"] = "true" + }), + Tags = +{ +["Organization"] = "Administration" +}, + }; + ArmOperation lro = await automanageConfigurationProfileVersion.UpdateAsync(WaitUntil.Completed, data); + AutomanageConfigurationProfileVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentCollection.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentCollection.cs index be297e2812e59..3be434bba1f96 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentCollection.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentCollection.cs @@ -16,41 +16,6 @@ namespace Azure.ResourceManager.Automanage.Samples { public partial class Sample_AutomanageHciClusterConfigurationProfileAssignmentCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConfigurationProfileAssignmentsByResourceGroupAndCluster() - { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfileAssignmentsByClusterName.json - // this example is just showing the usage of "ConfigurationProfileAssignments_ListByClusterName" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this AutomanageHciClusterConfigurationProfileAssignmentResource - string subscriptionId = "mySubscriptionId"; - string resourceGroupName = "myResourceGroupName"; - string clusterName = "myClusterName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.AzureStackHci/clusters/{2}", subscriptionId, resourceGroupName, clusterName)); - AutomanageHciClusterConfigurationProfileAssignmentCollection collection = client.GetAutomanageHciClusterConfigurationProfileAssignments(scopeId); - - // invoke the operation and iterate over the result - await foreach (AutomanageHciClusterConfigurationProfileAssignmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateAHCIConfigurationProfileAssignment() @@ -63,21 +28,18 @@ public async Task CreateOrUpdate_CreateOrUpdateAHCIConfigurationProfileAssignmen // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageHciClusterConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string clusterName = "myClusterName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.AzureStackHci/clusters/{2}", subscriptionId, resourceGroupName, clusterName)); - AutomanageHciClusterConfigurationProfileAssignmentCollection collection = client.GetAutomanageHciClusterConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}"; + AutomanageHciClusterConfigurationProfileAssignmentCollection collection = client.GetAutomanageHciClusterConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; - AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData() + AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData { - Properties = new AutomanageConfigurationProfileAssignmentProperties() + Properties = new AutomanageConfigurationProfileAssignmentProperties { ConfigurationProfile = new ResourceIdentifier("/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"), }, @@ -104,15 +66,12 @@ public async Task Get_GetAHCIConfigurationProfileAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageHciClusterConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string clusterName = "myClusterName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.AzureStackHci/clusters/{2}", subscriptionId, resourceGroupName, clusterName)); - AutomanageHciClusterConfigurationProfileAssignmentCollection collection = client.GetAutomanageHciClusterConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}"; + AutomanageHciClusterConfigurationProfileAssignmentCollection collection = client.GetAutomanageHciClusterConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; @@ -125,6 +84,38 @@ public async Task Get_GetAHCIConfigurationProfileAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListConfigurationProfileAssignmentsByResourceGroupAndCluster() + { + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfileAssignmentsByClusterName.json + // this example is just showing the usage of "ConfigurationProfileAssignments_ListByClusterName" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this AutomanageHciClusterConfigurationProfileAssignmentResource + string subscriptionId = "mySubscriptionId"; + string resourceGroupName = "myResourceGroupName"; + string clusterName = "myClusterName"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}"; + AutomanageHciClusterConfigurationProfileAssignmentCollection collection = client.GetAutomanageHciClusterConfigurationProfileAssignments(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (AutomanageHciClusterConfigurationProfileAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAHCIConfigurationProfileAssignment() @@ -137,15 +128,12 @@ public async Task Exists_GetAHCIConfigurationProfileAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageHciClusterConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string clusterName = "myClusterName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.AzureStackHci/clusters/{2}", subscriptionId, resourceGroupName, clusterName)); - AutomanageHciClusterConfigurationProfileAssignmentCollection collection = client.GetAutomanageHciClusterConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}"; + AutomanageHciClusterConfigurationProfileAssignmentCollection collection = client.GetAutomanageHciClusterConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; @@ -166,15 +154,12 @@ public async Task GetIfExists_GetAHCIConfigurationProfileAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageHciClusterConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string clusterName = "myClusterName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.AzureStackHci/clusters/{2}", subscriptionId, resourceGroupName, clusterName)); - AutomanageHciClusterConfigurationProfileAssignmentCollection collection = client.GetAutomanageHciClusterConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.AzureStackHci/clusters/{clusterName}"; + AutomanageHciClusterConfigurationProfileAssignmentCollection collection = client.GetAutomanageHciClusterConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentReportCollection.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentReportCollection.cs index 380d6e50af628..07a3fbf6741d5 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentReportCollection.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentReportCollection.cs @@ -52,10 +52,10 @@ public async Task Get_GetAReportForAHCIConfigurationProfileAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAReportForAHCIConfigurationProfileAssignment() + public async Task GetAll_ListReportsByHCIConfigurationProfilesAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getHCIReport.json - // this example is just showing the usage of "HCIReports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listReportsByconfigurationProfileHCIAssignment.json + // this example is just showing the usage of "HCIReports_ListByConfigurationProfileAssignments" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,16 +74,22 @@ public async Task Exists_GetAReportForAHCIConfigurationProfileAssignment() // get the collection of this AutomanageHciClusterConfigurationProfileAssignmentReportResource AutomanageHciClusterConfigurationProfileAssignmentReportCollection collection = automanageHciClusterConfigurationProfileAssignment.GetAutomanageHciClusterConfigurationProfileAssignmentReports(); - // invoke the operation - string reportName = "b4e9ee6b-1717-4ff0-a8d2-e6d72c33d5f4"; - bool result = await collection.ExistsAsync(reportName); + // invoke the operation and iterate over the result + await foreach (AutomanageHciClusterConfigurationProfileAssignmentReportResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileAssignmentReportData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAReportForAHCIConfigurationProfileAssignment() + public async Task Exists_GetAReportForAHCIConfigurationProfileAssignment() { // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getHCIReport.json // this example is just showing the usage of "HCIReports_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +113,17 @@ public async Task GetIfExists_GetAReportForAHCIConfigurationProfileAssignment() // invoke the operation string reportName = "b4e9ee6b-1717-4ff0-a8d2-e6d72c33d5f4"; - NullableResponse response = await collection.GetIfExistsAsync(reportName); - AutomanageHciClusterConfigurationProfileAssignmentReportResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(reportName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentReportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListReportsByHCIConfigurationProfilesAssignment() + public async Task GetIfExists_GetAReportForAHCIConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listReportsByconfigurationProfileHCIAssignment.json - // this example is just showing the usage of "HCIReports_ListByConfigurationProfileAssignments" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getHCIReport.json + // this example is just showing the usage of "HCIReports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,17 +142,23 @@ public async Task GetAll_ListReportsByHCIConfigurationProfilesAssignment() // get the collection of this AutomanageHciClusterConfigurationProfileAssignmentReportResource AutomanageHciClusterConfigurationProfileAssignmentReportCollection collection = automanageHciClusterConfigurationProfileAssignment.GetAutomanageHciClusterConfigurationProfileAssignmentReports(); - // invoke the operation and iterate over the result - await foreach (AutomanageHciClusterConfigurationProfileAssignmentReportResource item in collection.GetAllAsync()) + // invoke the operation + string reportName = "b4e9ee6b-1717-4ff0-a8d2-e6d72c33d5f4"; + NullableResponse response = await collection.GetIfExistsAsync(reportName); + AutomanageHciClusterConfigurationProfileAssignmentReportResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentReportData resourceData = item.Data; + AutomanageConfigurationProfileAssignmentReportData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentResource.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentResource.cs index 09e9790b2f9e5..0eb78b0ae2491 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentResource.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHciClusterConfigurationProfileAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomanageHciClusterConfigurationProfileAssignmentRe { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAHCIConfigurationProfileAssignment() + public async Task Get_GetAHCIConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/createOrUpdateConfigurationProfileHCIAssignment.json - // this example is just showing the usage of "ConfigurationProfileHCIAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileHCIAssignment.json + // this example is just showing the usage of "ConfigurationProfileHCIAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_CreateOrUpdateAHCIConfigurationProfileAssignment() AutomanageHciClusterConfigurationProfileAssignmentResource automanageHciClusterConfigurationProfileAssignment = client.GetAutomanageHciClusterConfigurationProfileAssignmentResource(automanageHciClusterConfigurationProfileAssignmentResourceId); // invoke the operation - AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData() - { - Properties = new AutomanageConfigurationProfileAssignmentProperties() - { - ConfigurationProfile = new ResourceIdentifier("/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"), - }, - }; - ArmOperation lro = await automanageHciClusterConfigurationProfileAssignment.UpdateAsync(WaitUntil.Completed, data); - AutomanageHciClusterConfigurationProfileAssignmentResource result = lro.Value; + AutomanageHciClusterConfigurationProfileAssignmentResource result = await automanageHciClusterConfigurationProfileAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +49,10 @@ public async Task Update_CreateOrUpdateAHCIConfigurationProfileAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAHCIConfigurationProfileAssignment() + public async Task Delete_DeleteAHCIConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileHCIAssignment.json - // this example is just showing the usage of "ConfigurationProfileHCIAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/deleteConfigurationProfileHCIAssignment.json + // this example is just showing the usage of "ConfigurationProfileHCIAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,21 +69,17 @@ public async Task Get_GetAHCIConfigurationProfileAssignment() AutomanageHciClusterConfigurationProfileAssignmentResource automanageHciClusterConfigurationProfileAssignment = client.GetAutomanageHciClusterConfigurationProfileAssignmentResource(automanageHciClusterConfigurationProfileAssignmentResourceId); // invoke the operation - AutomanageHciClusterConfigurationProfileAssignmentResource result = await automanageHciClusterConfigurationProfileAssignment.GetAsync(); + await automanageHciClusterConfigurationProfileAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAHCIConfigurationProfileAssignment() + public async Task Update_CreateOrUpdateAHCIConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/deleteConfigurationProfileHCIAssignment.json - // this example is just showing the usage of "ConfigurationProfileHCIAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/createOrUpdateConfigurationProfileHCIAssignment.json + // this example is just showing the usage of "ConfigurationProfileHCIAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DeleteAHCIConfigurationProfileAssignment() AutomanageHciClusterConfigurationProfileAssignmentResource automanageHciClusterConfigurationProfileAssignment = client.GetAutomanageHciClusterConfigurationProfileAssignmentResource(automanageHciClusterConfigurationProfileAssignmentResourceId); // invoke the operation - await automanageHciClusterConfigurationProfileAssignment.DeleteAsync(WaitUntil.Completed); + AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData + { + Properties = new AutomanageConfigurationProfileAssignmentProperties + { + ConfigurationProfile = new ResourceIdentifier("/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"), + }, + }; + ArmOperation lro = await automanageHciClusterConfigurationProfileAssignment.UpdateAsync(WaitUntil.Completed, data); + AutomanageHciClusterConfigurationProfileAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentCollection.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentCollection.cs index 89d7c21b61cf8..6b341f8ae3009 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentCollection.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentCollection.cs @@ -16,41 +16,6 @@ namespace Azure.ResourceManager.Automanage.Samples { public partial class Sample_AutomanageHcrpConfigurationProfileAssignmentCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConfigurationProfileAssignmentsByResourceGroupAndMachine() - { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfileAssignmentsByMachineName.json - // this example is just showing the usage of "ConfigurationProfileAssignments_ListByMachineName" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this AutomanageHcrpConfigurationProfileAssignmentResource - string subscriptionId = "mySubscriptionId"; - string resourceGroupName = "myResourceGroupName"; - string machineName = "myMachineName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridCompute/machines/{2}", subscriptionId, resourceGroupName, machineName)); - AutomanageHcrpConfigurationProfileAssignmentCollection collection = client.GetAutomanageHcrpConfigurationProfileAssignments(scopeId); - - // invoke the operation and iterate over the result - await foreach (AutomanageHcrpConfigurationProfileAssignmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateHCRPConfigurationProfileAssignment() @@ -63,21 +28,18 @@ public async Task CreateOrUpdate_CreateOrUpdateHCRPConfigurationProfileAssignmen // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageHcrpConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string machineName = "myMachineName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridCompute/machines/{2}", subscriptionId, resourceGroupName, machineName)); - AutomanageHcrpConfigurationProfileAssignmentCollection collection = client.GetAutomanageHcrpConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}"; + AutomanageHcrpConfigurationProfileAssignmentCollection collection = client.GetAutomanageHcrpConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; - AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData() + AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData { - Properties = new AutomanageConfigurationProfileAssignmentProperties() + Properties = new AutomanageConfigurationProfileAssignmentProperties { ConfigurationProfile = new ResourceIdentifier("/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"), }, @@ -104,15 +66,12 @@ public async Task Get_GetAHCRPConfigurationProfileAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageHcrpConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string machineName = "myMachineName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridCompute/machines/{2}", subscriptionId, resourceGroupName, machineName)); - AutomanageHcrpConfigurationProfileAssignmentCollection collection = client.GetAutomanageHcrpConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}"; + AutomanageHcrpConfigurationProfileAssignmentCollection collection = client.GetAutomanageHcrpConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; @@ -125,6 +84,38 @@ public async Task Get_GetAHCRPConfigurationProfileAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListConfigurationProfileAssignmentsByResourceGroupAndMachine() + { + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfileAssignmentsByMachineName.json + // this example is just showing the usage of "ConfigurationProfileAssignments_ListByMachineName" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this AutomanageHcrpConfigurationProfileAssignmentResource + string subscriptionId = "mySubscriptionId"; + string resourceGroupName = "myResourceGroupName"; + string machineName = "myMachineName"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}"; + AutomanageHcrpConfigurationProfileAssignmentCollection collection = client.GetAutomanageHcrpConfigurationProfileAssignments(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (AutomanageHcrpConfigurationProfileAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAHCRPConfigurationProfileAssignment() @@ -137,15 +128,12 @@ public async Task Exists_GetAHCRPConfigurationProfileAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageHcrpConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string machineName = "myMachineName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridCompute/machines/{2}", subscriptionId, resourceGroupName, machineName)); - AutomanageHcrpConfigurationProfileAssignmentCollection collection = client.GetAutomanageHcrpConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}"; + AutomanageHcrpConfigurationProfileAssignmentCollection collection = client.GetAutomanageHcrpConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; @@ -166,15 +154,12 @@ public async Task GetIfExists_GetAHCRPConfigurationProfileAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageHcrpConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string machineName = "myMachineName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.HybridCompute/machines/{2}", subscriptionId, resourceGroupName, machineName)); - AutomanageHcrpConfigurationProfileAssignmentCollection collection = client.GetAutomanageHcrpConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HybridCompute/machines/{machineName}"; + AutomanageHcrpConfigurationProfileAssignmentCollection collection = client.GetAutomanageHcrpConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentReportCollection.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentReportCollection.cs index 9c541392e7a26..91b2cdac56777 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentReportCollection.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentReportCollection.cs @@ -52,10 +52,10 @@ public async Task Get_GetAReportForAHCRPConfigurationProfileAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAReportForAHCRPConfigurationProfileAssignment() + public async Task GetAll_ListReportsByHCRPConfigurationProfilesAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getHCRPReport.json - // this example is just showing the usage of "HCRPReports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listReportsByconfigurationProfileHCRPAssignment.json + // this example is just showing the usage of "HCRPReports_ListByConfigurationProfileAssignments" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,16 +74,22 @@ public async Task Exists_GetAReportForAHCRPConfigurationProfileAssignment() // get the collection of this AutomanageHcrpConfigurationProfileAssignmentReportResource AutomanageHcrpConfigurationProfileAssignmentReportCollection collection = automanageHcrpConfigurationProfileAssignment.GetAutomanageHcrpConfigurationProfileAssignmentReports(); - // invoke the operation - string reportName = "b4e9ee6b-1717-4ff0-a8d2-e6d72c33d5f4"; - bool result = await collection.ExistsAsync(reportName); + // invoke the operation and iterate over the result + await foreach (AutomanageHcrpConfigurationProfileAssignmentReportResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileAssignmentReportData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAReportForAHCRPConfigurationProfileAssignment() + public async Task Exists_GetAReportForAHCRPConfigurationProfileAssignment() { // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getHCRPReport.json // this example is just showing the usage of "HCRPReports_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +113,17 @@ public async Task GetIfExists_GetAReportForAHCRPConfigurationProfileAssignment() // invoke the operation string reportName = "b4e9ee6b-1717-4ff0-a8d2-e6d72c33d5f4"; - NullableResponse response = await collection.GetIfExistsAsync(reportName); - AutomanageHcrpConfigurationProfileAssignmentReportResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(reportName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentReportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListReportsByHCRPConfigurationProfilesAssignment() + public async Task GetIfExists_GetAReportForAHCRPConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listReportsByconfigurationProfileHCRPAssignment.json - // this example is just showing the usage of "HCRPReports_ListByConfigurationProfileAssignments" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getHCRPReport.json + // this example is just showing the usage of "HCRPReports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,17 +142,23 @@ public async Task GetAll_ListReportsByHCRPConfigurationProfilesAssignment() // get the collection of this AutomanageHcrpConfigurationProfileAssignmentReportResource AutomanageHcrpConfigurationProfileAssignmentReportCollection collection = automanageHcrpConfigurationProfileAssignment.GetAutomanageHcrpConfigurationProfileAssignmentReports(); - // invoke the operation and iterate over the result - await foreach (AutomanageHcrpConfigurationProfileAssignmentReportResource item in collection.GetAllAsync()) + // invoke the operation + string reportName = "b4e9ee6b-1717-4ff0-a8d2-e6d72c33d5f4"; + NullableResponse response = await collection.GetIfExistsAsync(reportName); + AutomanageHcrpConfigurationProfileAssignmentReportResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentReportData resourceData = item.Data; + AutomanageConfigurationProfileAssignmentReportData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentResource.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentResource.cs index 0d99602edf0ee..9f7e798fed894 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentResource.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageHcrpConfigurationProfileAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomanageHcrpConfigurationProfileAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateHCRPConfigurationProfileAssignment() + public async Task Get_GetAHCRPConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/createOrUpdateConfigurationProfileHCRPAssignment.json - // this example is just showing the usage of "ConfigurationProfileHCRPAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileHCRPAssignment.json + // this example is just showing the usage of "ConfigurationProfileHCRPAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_CreateOrUpdateHCRPConfigurationProfileAssignment() AutomanageHcrpConfigurationProfileAssignmentResource automanageHcrpConfigurationProfileAssignment = client.GetAutomanageHcrpConfigurationProfileAssignmentResource(automanageHcrpConfigurationProfileAssignmentResourceId); // invoke the operation - AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData() - { - Properties = new AutomanageConfigurationProfileAssignmentProperties() - { - ConfigurationProfile = new ResourceIdentifier("/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"), - }, - }; - ArmOperation lro = await automanageHcrpConfigurationProfileAssignment.UpdateAsync(WaitUntil.Completed, data); - AutomanageHcrpConfigurationProfileAssignmentResource result = lro.Value; + AutomanageHcrpConfigurationProfileAssignmentResource result = await automanageHcrpConfigurationProfileAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +49,10 @@ public async Task Update_CreateOrUpdateHCRPConfigurationProfileAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAHCRPConfigurationProfileAssignment() + public async Task Delete_DeleteAHCRPConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileHCRPAssignment.json - // this example is just showing the usage of "ConfigurationProfileHCRPAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/deleteConfigurationProfileHCRPAssignment.json + // this example is just showing the usage of "ConfigurationProfileHCRPAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,21 +69,17 @@ public async Task Get_GetAHCRPConfigurationProfileAssignment() AutomanageHcrpConfigurationProfileAssignmentResource automanageHcrpConfigurationProfileAssignment = client.GetAutomanageHcrpConfigurationProfileAssignmentResource(automanageHcrpConfigurationProfileAssignmentResourceId); // invoke the operation - AutomanageHcrpConfigurationProfileAssignmentResource result = await automanageHcrpConfigurationProfileAssignment.GetAsync(); + await automanageHcrpConfigurationProfileAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAHCRPConfigurationProfileAssignment() + public async Task Update_CreateOrUpdateHCRPConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/deleteConfigurationProfileHCRPAssignment.json - // this example is just showing the usage of "ConfigurationProfileHCRPAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/createOrUpdateConfigurationProfileHCRPAssignment.json + // this example is just showing the usage of "ConfigurationProfileHCRPAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DeleteAHCRPConfigurationProfileAssignment() AutomanageHcrpConfigurationProfileAssignmentResource automanageHcrpConfigurationProfileAssignment = client.GetAutomanageHcrpConfigurationProfileAssignmentResource(automanageHcrpConfigurationProfileAssignmentResourceId); // invoke the operation - await automanageHcrpConfigurationProfileAssignment.DeleteAsync(WaitUntil.Completed); + AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData + { + Properties = new AutomanageConfigurationProfileAssignmentProperties + { + ConfigurationProfile = new ResourceIdentifier("/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"), + }, + }; + ArmOperation lro = await automanageHcrpConfigurationProfileAssignment.UpdateAsync(WaitUntil.Completed, data); + AutomanageHcrpConfigurationProfileAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentCollection.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentCollection.cs index 0c4019c55c0ed..f516ead1c3655 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentCollection.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentCollection.cs @@ -28,21 +28,18 @@ public async Task CreateOrUpdate_CreateOrUpdateConfigurationProfileAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageVmConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}", subscriptionId, resourceGroupName, vmName)); - AutomanageVmConfigurationProfileAssignmentCollection collection = client.GetAutomanageVmConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"; + AutomanageVmConfigurationProfileAssignmentCollection collection = client.GetAutomanageVmConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; - AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData() + AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData { - Properties = new AutomanageConfigurationProfileAssignmentProperties() + Properties = new AutomanageConfigurationProfileAssignmentProperties { ConfigurationProfile = new ResourceIdentifier("/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"), }, @@ -69,15 +66,12 @@ public async Task Get_GetAConfigurationProfileAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageVmConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}", subscriptionId, resourceGroupName, vmName)); - AutomanageVmConfigurationProfileAssignmentCollection collection = client.GetAutomanageVmConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"; + AutomanageVmConfigurationProfileAssignmentCollection collection = client.GetAutomanageVmConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; @@ -90,6 +84,38 @@ public async Task Get_GetAConfigurationProfileAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListConfigurationProfileAssignmentsByResourceGroupAndVirtualMachine() + { + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfileAssignmentsByVirtualMachines.json + // this example is just showing the usage of "ConfigurationProfileAssignments_ListByVirtualMachines" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this AutomanageVmConfigurationProfileAssignmentResource + string subscriptionId = "mySubscriptionId"; + string resourceGroupName = "myResourceGroupName"; + string vmName = "myVMName"; + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"; + AutomanageVmConfigurationProfileAssignmentCollection collection = client.GetAutomanageVmConfigurationProfileAssignments(new ResourceIdentifier(scope)); + + // invoke the operation and iterate over the result + await foreach (AutomanageVmConfigurationProfileAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAConfigurationProfileAssignment() @@ -102,15 +128,12 @@ public async Task Exists_GetAConfigurationProfileAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageVmConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}", subscriptionId, resourceGroupName, vmName)); - AutomanageVmConfigurationProfileAssignmentCollection collection = client.GetAutomanageVmConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"; + AutomanageVmConfigurationProfileAssignmentCollection collection = client.GetAutomanageVmConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; @@ -131,15 +154,12 @@ public async Task GetIfExists_GetAConfigurationProfileAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AutomanageVmConfigurationProfileAssignmentResource string subscriptionId = "mySubscriptionId"; string resourceGroupName = "myResourceGroupName"; string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}", subscriptionId, resourceGroupName, vmName)); - AutomanageVmConfigurationProfileAssignmentCollection collection = client.GetAutomanageVmConfigurationProfileAssignments(scopeId); + string scope = $"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}"; + AutomanageVmConfigurationProfileAssignmentCollection collection = client.GetAutomanageVmConfigurationProfileAssignments(new ResourceIdentifier(scope)); // invoke the operation string configurationProfileAssignmentName = "default"; @@ -159,40 +179,5 @@ public async Task GetIfExists_GetAConfigurationProfileAssignment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConfigurationProfileAssignmentsByResourceGroupAndVirtualMachine() - { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfileAssignmentsByVirtualMachines.json - // this example is just showing the usage of "ConfigurationProfileAssignments_ListByVirtualMachines" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this AutomanageVmConfigurationProfileAssignmentResource - string subscriptionId = "mySubscriptionId"; - string resourceGroupName = "myResourceGroupName"; - string vmName = "myVMName"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualMachines/{2}", subscriptionId, resourceGroupName, vmName)); - AutomanageVmConfigurationProfileAssignmentCollection collection = client.GetAutomanageVmConfigurationProfileAssignments(scopeId); - - // invoke the operation and iterate over the result - await foreach (AutomanageVmConfigurationProfileAssignmentResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentReportCollection.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentReportCollection.cs index 3116d51fc08af..c79a26116498a 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentReportCollection.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentReportCollection.cs @@ -52,10 +52,10 @@ public async Task Get_GetAReportForAConfigurationProfileAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAReportForAConfigurationProfileAssignment() + public async Task GetAll_ListReportsByConfigurationProfilesAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getReport.json - // this example is just showing the usage of "reports_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listReportsByconfigurationProfileAssignment.json + // this example is just showing the usage of "reports_ListByConfigurationProfileAssignments" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,16 +74,22 @@ public async Task Exists_GetAReportForAConfigurationProfileAssignment() // get the collection of this AutomanageVmConfigurationProfileAssignmentReportResource AutomanageVmConfigurationProfileAssignmentReportCollection collection = automanageVmConfigurationProfileAssignment.GetAutomanageVmConfigurationProfileAssignmentReports(); - // invoke the operation - string reportName = "b4e9ee6b-1717-4ff0-a8d2-e6d72c33d5f4"; - bool result = await collection.ExistsAsync(reportName); + // invoke the operation and iterate over the result + await foreach (AutomanageVmConfigurationProfileAssignmentReportResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileAssignmentReportData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAReportForAConfigurationProfileAssignment() + public async Task Exists_GetAReportForAConfigurationProfileAssignment() { // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getReport.json // this example is just showing the usage of "reports_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +113,17 @@ public async Task GetIfExists_GetAReportForAConfigurationProfileAssignment() // invoke the operation string reportName = "b4e9ee6b-1717-4ff0-a8d2-e6d72c33d5f4"; - NullableResponse response = await collection.GetIfExistsAsync(reportName); - AutomanageVmConfigurationProfileAssignmentReportResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(reportName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentReportData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListReportsByConfigurationProfilesAssignment() + public async Task GetIfExists_GetAReportForAConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listReportsByconfigurationProfileAssignment.json - // this example is just showing the usage of "reports_ListByConfigurationProfileAssignments" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getReport.json + // this example is just showing the usage of "reports_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,17 +142,23 @@ public async Task GetAll_ListReportsByConfigurationProfilesAssignment() // get the collection of this AutomanageVmConfigurationProfileAssignmentReportResource AutomanageVmConfigurationProfileAssignmentReportCollection collection = automanageVmConfigurationProfileAssignment.GetAutomanageVmConfigurationProfileAssignmentReports(); - // invoke the operation and iterate over the result - await foreach (AutomanageVmConfigurationProfileAssignmentReportResource item in collection.GetAllAsync()) + // invoke the operation + string reportName = "b4e9ee6b-1717-4ff0-a8d2-e6d72c33d5f4"; + NullableResponse response = await collection.GetIfExistsAsync(reportName); + AutomanageVmConfigurationProfileAssignmentReportResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentReportData resourceData = item.Data; + AutomanageConfigurationProfileAssignmentReportData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentResource.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentResource.cs index a3b737f1f2cff..95a2b865050d8 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentResource.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_AutomanageVmConfigurationProfileAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomanageVmConfigurationProfileAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateConfigurationProfileAssignment() + public async Task Get_GetAConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/createOrUpdateConfigurationProfileAssignment.json - // this example is just showing the usage of "ConfigurationProfileAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileAssignment.json + // this example is just showing the usage of "ConfigurationProfileAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_CreateOrUpdateConfigurationProfileAssignment() AutomanageVmConfigurationProfileAssignmentResource automanageVmConfigurationProfileAssignment = client.GetAutomanageVmConfigurationProfileAssignmentResource(automanageVmConfigurationProfileAssignmentResourceId); // invoke the operation - AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData() - { - Properties = new AutomanageConfigurationProfileAssignmentProperties() - { - ConfigurationProfile = new ResourceIdentifier("/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"), - }, - }; - ArmOperation lro = await automanageVmConfigurationProfileAssignment.UpdateAsync(WaitUntil.Completed, data); - AutomanageVmConfigurationProfileAssignmentResource result = lro.Value; + AutomanageVmConfigurationProfileAssignmentResource result = await automanageVmConfigurationProfileAssignment.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +49,10 @@ public async Task Update_CreateOrUpdateConfigurationProfileAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAConfigurationProfileAssignment() + public async Task Delete_DeleteAnConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/getConfigurationProfileAssignment.json - // this example is just showing the usage of "ConfigurationProfileAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/deleteConfigurationProfileAssignment.json + // this example is just showing the usage of "ConfigurationProfileAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,21 +69,17 @@ public async Task Get_GetAConfigurationProfileAssignment() AutomanageVmConfigurationProfileAssignmentResource automanageVmConfigurationProfileAssignment = client.GetAutomanageVmConfigurationProfileAssignmentResource(automanageVmConfigurationProfileAssignmentResourceId); // invoke the operation - AutomanageVmConfigurationProfileAssignmentResource result = await automanageVmConfigurationProfileAssignment.GetAsync(); + await automanageVmConfigurationProfileAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomanageConfigurationProfileAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnConfigurationProfileAssignment() + public async Task Update_CreateOrUpdateConfigurationProfileAssignment() { - // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/deleteConfigurationProfileAssignment.json - // this example is just showing the usage of "ConfigurationProfileAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/createOrUpdateConfigurationProfileAssignment.json + // this example is just showing the usage of "ConfigurationProfileAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_DeleteAnConfigurationProfileAssignment() AutomanageVmConfigurationProfileAssignmentResource automanageVmConfigurationProfileAssignment = client.GetAutomanageVmConfigurationProfileAssignmentResource(automanageVmConfigurationProfileAssignmentResourceId); // invoke the operation - await automanageVmConfigurationProfileAssignment.DeleteAsync(WaitUntil.Completed); + AutomanageConfigurationProfileAssignmentData data = new AutomanageConfigurationProfileAssignmentData + { + Properties = new AutomanageConfigurationProfileAssignmentProperties + { + ConfigurationProfile = new ResourceIdentifier("/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"), + }, + }; + ArmOperation lro = await automanageVmConfigurationProfileAssignment.UpdateAsync(WaitUntil.Completed, data); + AutomanageVmConfigurationProfileAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 89fc61e70fab3..ecb126f2f626a 100644 --- a/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/automanage/Azure.ResourceManager.Automanage/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.Automanage.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAutomanageConfigurationProfiles_ListConfigurationProfilesBySubscription() + { + // Generated from example definition: specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/examples/listConfigurationProfilesBySubscription.json + // this example is just showing the usage of "ConfigurationProfiles_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "mySubscriptionId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AutomanageConfigurationProfileResource item in subscriptionResource.GetAutomanageConfigurationProfilesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomanageConfigurationProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetServicePrincipals_ListServicePrincipalBySubscription() diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountCollection.cs index f62b5d72ea3dc..8f1f52018dfb9 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_CreateOrUpdateAutomationAccount() // invoke the operation string automationAccountName = "myAutomationAccount9"; - AutomationAccountCreateOrUpdateContent content = new AutomationAccountCreateOrUpdateContent() + AutomationAccountCreateOrUpdateContent content = new AutomationAccountCreateOrUpdateContent { Name = "myAutomationAccount9", Location = new AzureLocation("East US 2"), @@ -92,10 +92,10 @@ public async Task Get_GetAutomationAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAutomationAccount() + public async Task GetAll_ListAutomationAccountsByResourceGroup() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getAutomationAccount.json - // this example is just showing the usage of "AutomationAccount_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/listAutomationAccountsByResourceGroup.json + // this example is just showing the usage of "AutomationAccount_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_GetAutomationAccount() // get the collection of this AutomationAccountResource AutomationAccountCollection collection = resourceGroupResource.GetAutomationAccounts(); - // invoke the operation - string automationAccountName = "myAutomationAccount9"; - bool result = await collection.ExistsAsync(automationAccountName); + // invoke the operation and iterate over the result + await foreach (AutomationAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAutomationAccount() + public async Task Exists_GetAutomationAccount() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getAutomationAccount.json // this example is just showing the usage of "AutomationAccount_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,29 +149,17 @@ public async Task GetIfExists_GetAutomationAccount() // invoke the operation string automationAccountName = "myAutomationAccount9"; - NullableResponse response = await collection.GetIfExistsAsync(automationAccountName); - AutomationAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(automationAccountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAutomationAccountsByResourceGroup() + public async Task GetIfExists_GetAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/listAutomationAccountsByResourceGroup.json - // this example is just showing the usage of "AutomationAccount_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getAutomationAccount.json + // this example is just showing the usage of "AutomationAccount_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,17 +176,23 @@ public async Task GetAll_ListAutomationAccountsByResourceGroup() // get the collection of this AutomationAccountResource AutomationAccountCollection collection = resourceGroupResource.GetAutomationAccounts(); - // invoke the operation and iterate over the result - await foreach (AutomationAccountResource item in collection.GetAllAsync()) + // invoke the operation + string automationAccountName = "myAutomationAccount9"; + NullableResponse response = await collection.GetIfExistsAsync(automationAccountName); + AutomationAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationAccountData resourceData = item.Data; + AutomationAccountData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountModuleCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountModuleCollection.cs index d79abb5a7fbfd..0176de7352722 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountModuleCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountModuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationAccountModuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAModule() + public async Task CreateOrUpdate_CreateOrUpdateAModule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getModule.json - // this example is just showing the usage of "Module_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateModule.json + // this example is just showing the usage of "Module_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,14 @@ public async Task Get_GetAModule() // invoke the operation string moduleName = "OmsCompositeResources"; - AutomationAccountModuleResource result = await collection.GetAsync(moduleName); + AutomationAccountModuleCreateOrUpdateContent content = new AutomationAccountModuleCreateOrUpdateContent(new AutomationContentLink + { + Uri = new Uri("https://teststorage.blob.core.windows.net/dsccomposite/OmsCompositeResources.zip"), + ContentHash = new AutomationContentHash("sha265", "07E108A962B81DD9C9BAA89BB47C0F6EE52B29E83758B07795E408D258B2B87A"), + Version = "1.0.0.0", + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, moduleName, content); + AutomationAccountModuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +59,7 @@ public async Task Get_GetAModule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAModule() + public async Task Get_GetAModule() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getModule.json // this example is just showing the usage of "Module_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +82,21 @@ public async Task Exists_GetAModule() // invoke the operation string moduleName = "OmsCompositeResources"; - bool result = await collection.ExistsAsync(moduleName); + AutomationAccountModuleResource result = await collection.GetAsync(moduleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationModuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAModule() + public async Task GetAll_ListModulesByAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getModule.json - // this example is just showing the usage of "Module_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listModulesByAutomationAccount.json + // this example is just showing the usage of "Module_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +114,25 @@ public async Task GetIfExists_GetAModule() // get the collection of this AutomationAccountModuleResource AutomationAccountModuleCollection collection = automationAccount.GetAutomationAccountModules(); - // invoke the operation - string moduleName = "OmsCompositeResources"; - NullableResponse response = await collection.GetIfExistsAsync(moduleName); - AutomationAccountModuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationAccountModuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationModuleData resourceData = result.Data; + AutomationModuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAModule() + public async Task Exists_GetAModule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateModule.json - // this example is just showing the usage of "Module_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getModule.json + // this example is just showing the usage of "Module_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,28 +152,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAModule() // invoke the operation string moduleName = "OmsCompositeResources"; - AutomationAccountModuleCreateOrUpdateContent content = new AutomationAccountModuleCreateOrUpdateContent(new AutomationContentLink() - { - Uri = new Uri("https://teststorage.blob.core.windows.net/dsccomposite/OmsCompositeResources.zip"), - ContentHash = new AutomationContentHash("sha265", "07E108A962B81DD9C9BAA89BB47C0F6EE52B29E83758B07795E408D258B2B87A"), - Version = "1.0.0.0", - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, moduleName, content); - AutomationAccountModuleResource result = lro.Value; + bool result = await collection.ExistsAsync(moduleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationModuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListModulesByAutomationAccount() + public async Task GetIfExists_GetAModule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listModulesByAutomationAccount.json - // this example is just showing the usage of "Module_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getModule.json + // this example is just showing the usage of "Module_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_ListModulesByAutomationAccount() // get the collection of this AutomationAccountModuleResource AutomationAccountModuleCollection collection = automationAccount.GetAutomationAccountModules(); - // invoke the operation and iterate over the result - await foreach (AutomationAccountModuleResource item in collection.GetAllAsync()) + // invoke the operation + string moduleName = "OmsCompositeResources"; + NullableResponse response = await collection.GetIfExistsAsync(moduleName); + AutomationAccountModuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationModuleData resourceData = item.Data; + AutomationModuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountModuleResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountModuleResource.cs index e620cfb99b29e..705303f65975a 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountModuleResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountModuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationAccountModuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetActivity_GetActivityInAModule() + public async Task Get_GetAModule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getActivityInAModule.json - // this example is just showing the usage of "Activity_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getModule.json + // this example is just showing the usage of "Module_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,18 +38,21 @@ public async Task GetActivity_GetActivityInAModule() AutomationAccountModuleResource automationAccountModule = client.GetAutomationAccountModuleResource(automationAccountModuleResourceId); // invoke the operation - string activityName = "Add-AzureRmAccount"; - AutomationActivity result = await automationAccountModule.GetActivityAsync(activityName); + AutomationAccountModuleResource result = await automationAccountModule.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationModuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetActivities_ListActivitiesByAModule() + public async Task Delete_DeleteAModule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listActivitiesByModule.json - // this example is just showing the usage of "Activity_ListByModule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteModule.json + // this example is just showing the usage of "Module_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,21 +68,18 @@ public async Task GetActivities_ListActivitiesByAModule() ResourceIdentifier automationAccountModuleResourceId = AutomationAccountModuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, moduleName); AutomationAccountModuleResource automationAccountModule = client.GetAutomationAccountModuleResource(automationAccountModuleResourceId); - // invoke the operation and iterate over the result - await foreach (AutomationActivity item in automationAccountModule.GetActivitiesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + await automationAccountModule.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAModule() + public async Task Update_UpdateAModule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteModule.json - // this example is just showing the usage of "Module_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/updateModule.json + // this example is just showing the usage of "Module_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -90,23 +90,36 @@ public async Task Delete_DeleteAModule() // for more information of creating AutomationAccountModuleResource, please refer to the document of AutomationAccountModuleResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount33"; - string moduleName = "OmsCompositeResources"; + string automationAccountName = "MyAutomationAccount"; + string moduleName = "MyModule"; ResourceIdentifier automationAccountModuleResourceId = AutomationAccountModuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, moduleName); AutomationAccountModuleResource automationAccountModule = client.GetAutomationAccountModuleResource(automationAccountModuleResourceId); // invoke the operation - await automationAccountModule.DeleteAsync(WaitUntil.Completed); + AutomationAccountModulePatch patch = new AutomationAccountModulePatch + { + ContentLink = new AutomationContentLink + { + Uri = new Uri("https://teststorage.blob.core.windows.net/mycontainer/MyModule.zip"), + ContentHash = new AutomationContentHash("sha265", "07E108A962B81DD9C9BAA89BB47C0F6EE52B29E83758B07795E408D258B2B87A"), + Version = "1.0.0.0", + }, + }; + AutomationAccountModuleResource result = await automationAccountModule.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationModuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAModule() + public async Task GetActivity_GetActivityInAModule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getModule.json - // this example is just showing the usage of "Module_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getActivityInAModule.json + // this example is just showing the usage of "Activity_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -123,21 +136,18 @@ public async Task Get_GetAModule() AutomationAccountModuleResource automationAccountModule = client.GetAutomationAccountModuleResource(automationAccountModuleResourceId); // invoke the operation - AutomationAccountModuleResource result = await automationAccountModule.GetAsync(); + string activityName = "Add-AzureRmAccount"; + AutomationActivity result = await automationAccountModule.GetActivityAsync(activityName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationModuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAModule() + public async Task GetActivities_ListActivitiesByAModule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/updateModule.json - // this example is just showing the usage of "Module_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listActivitiesByModule.json + // this example is just showing the usage of "Activity_ListByModule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,28 +158,18 @@ public async Task Update_UpdateAModule() // for more information of creating AutomationAccountModuleResource, please refer to the document of AutomationAccountModuleResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "MyAutomationAccount"; - string moduleName = "MyModule"; + string automationAccountName = "myAutomationAccount33"; + string moduleName = "OmsCompositeResources"; ResourceIdentifier automationAccountModuleResourceId = AutomationAccountModuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, moduleName); AutomationAccountModuleResource automationAccountModule = client.GetAutomationAccountModuleResource(automationAccountModuleResourceId); - // invoke the operation - AutomationAccountModulePatch patch = new AutomationAccountModulePatch() + // invoke the operation and iterate over the result + await foreach (AutomationActivity item in automationAccountModule.GetActivitiesAsync()) { - ContentLink = new AutomationContentLink() - { - Uri = new Uri("https://teststorage.blob.core.windows.net/mycontainer/MyModule.zip"), - ContentHash = new AutomationContentHash("sha265", "07E108A962B81DD9C9BAA89BB47C0F6EE52B29E83758B07795E408D258B2B87A"), - Version = "1.0.0.0", - }, - }; - AutomationAccountModuleResource result = await automationAccountModule.UpdateAsync(patch); + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationModuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountPython2PackageCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountPython2PackageCollection.cs index a62f4d1f9a3f3..0bc60a8150c37 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountPython2PackageCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountPython2PackageCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationAccountPython2PackageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPython2Package() + public async Task CreateOrUpdate_CreateOrUpdateAPython2Package() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getPython2Package.json - // this example is just showing the usage of "Python2Package_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdatePython2Package.json + // this example is just showing the usage of "Python2Package_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_GetAPython2Package() // invoke the operation string packageName = "OmsCompositeResources"; - AutomationAccountPython2PackageResource result = await collection.GetAsync(packageName); + AutomationAccountPython2PackageCreateOrUpdateContent content = new AutomationAccountPython2PackageCreateOrUpdateContent(new AutomationContentLink + { + Uri = new Uri("https://teststorage.blob.core.windows.net/dsccomposite/OmsCompositeResources.zip"), + ContentHash = new AutomationContentHash("sha265", "07E108A962B81DD9C9BAA89BB47C0F6EE52B29E83758B07795E408D258B2B87A"), + Version = "1.0.0.0", + }) + { + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, packageName, content); + AutomationAccountPython2PackageResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +62,7 @@ public async Task Get_GetAPython2Package() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPython2Package() + public async Task Get_GetAPython2Package() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getPython2Package.json // this example is just showing the usage of "Python2Package_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +85,21 @@ public async Task Exists_GetAPython2Package() // invoke the operation string packageName = "OmsCompositeResources"; - bool result = await collection.ExistsAsync(packageName); + AutomationAccountPython2PackageResource result = await collection.GetAsync(packageName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationModuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPython2Package() + public async Task GetAll_ListPython2PackagesByAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getPython2Package.json - // this example is just showing the usage of "Python2Package_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listPython2PackagesByAutomationAccount.json + // this example is just showing the usage of "Python2Package_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +117,25 @@ public async Task GetIfExists_GetAPython2Package() // get the collection of this AutomationAccountPython2PackageResource AutomationAccountPython2PackageCollection collection = automationAccount.GetAutomationAccountPython2Packages(); - // invoke the operation - string packageName = "OmsCompositeResources"; - NullableResponse response = await collection.GetIfExistsAsync(packageName); - AutomationAccountPython2PackageResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationAccountPython2PackageResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationModuleData resourceData = result.Data; + AutomationModuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAPython2Package() + public async Task Exists_GetAPython2Package() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdatePython2Package.json - // this example is just showing the usage of "Python2Package_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getPython2Package.json + // this example is just showing the usage of "Python2Package_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,33 +155,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAPython2Package() // invoke the operation string packageName = "OmsCompositeResources"; - AutomationAccountPython2PackageCreateOrUpdateContent content = new AutomationAccountPython2PackageCreateOrUpdateContent(new AutomationContentLink() - { - Uri = new Uri("https://teststorage.blob.core.windows.net/dsccomposite/OmsCompositeResources.zip"), - ContentHash = new AutomationContentHash("sha265", "07E108A962B81DD9C9BAA89BB47C0F6EE52B29E83758B07795E408D258B2B87A"), - Version = "1.0.0.0", - }) - { - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, packageName, content); - AutomationAccountPython2PackageResource result = lro.Value; + bool result = await collection.ExistsAsync(packageName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationModuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPython2PackagesByAutomationAccount() + public async Task GetIfExists_GetAPython2Package() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listPython2PackagesByAutomationAccount.json - // this example is just showing the usage of "Python2Package_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getPython2Package.json + // this example is just showing the usage of "Python2Package_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,17 +183,23 @@ public async Task GetAll_ListPython2PackagesByAutomationAccount() // get the collection of this AutomationAccountPython2PackageResource AutomationAccountPython2PackageCollection collection = automationAccount.GetAutomationAccountPython2Packages(); - // invoke the operation and iterate over the result - await foreach (AutomationAccountPython2PackageResource item in collection.GetAllAsync()) + // invoke the operation + string packageName = "OmsCompositeResources"; + NullableResponse response = await collection.GetIfExistsAsync(packageName); + AutomationAccountPython2PackageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationModuleData resourceData = item.Data; + AutomationModuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountPython2PackageResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountPython2PackageResource.cs index 57d65b5a3e76d..34ba6e4bc43fc 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountPython2PackageResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountPython2PackageResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationAccountPython2PackageResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPython2Package() + public async Task Get_GetAPython2Package() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deletePython2Package.json - // this example is just showing the usage of "Python2Package_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getPython2Package.json + // this example is just showing the usage of "Python2Package_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteAPython2Package() AutomationAccountPython2PackageResource automationAccountPython2Package = client.GetAutomationAccountPython2PackageResource(automationAccountPython2PackageResourceId); // invoke the operation - await automationAccountPython2Package.DeleteAsync(WaitUntil.Completed); + AutomationAccountPython2PackageResource result = await automationAccountPython2Package.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationModuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAPython2Package() + public async Task Delete_DeleteAPython2Package() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getPython2Package.json - // this example is just showing the usage of "Python2Package_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deletePython2Package.json + // this example is just showing the usage of "Python2Package_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetAPython2Package() AutomationAccountPython2PackageResource automationAccountPython2Package = client.GetAutomationAccountPython2PackageResource(automationAccountPython2PackageResourceId); // invoke the operation - AutomationAccountPython2PackageResource result = await automationAccountPython2Package.GetAsync(); + await automationAccountPython2Package.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationModuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,11 +96,9 @@ public async Task Update_UpdateAModule() AutomationAccountPython2PackageResource automationAccountPython2Package = client.GetAutomationAccountPython2PackageResource(automationAccountPython2PackageResourceId); // invoke the operation - AutomationAccountPython2PackagePatch patch = new AutomationAccountPython2PackagePatch() + AutomationAccountPython2PackagePatch patch = new AutomationAccountPython2PackagePatch { - Tags = -{ -}, + Tags = { }, }; AutomationAccountPython2PackageResource result = await automationAccountPython2Package.UpdateAsync(patch); diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountResource.cs index c92d8f8281355..f599eaab8a49e 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationAccountResource.cs @@ -10,13 +10,104 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Automation.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Automation.Samples { public partial class Sample_AutomationAccountResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAutomationAccount() + { + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getAutomationAccount.json + // this example is just showing the usage of "AutomationAccount_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AutomationAccountResource created on azure + // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource + string subscriptionId = "subid"; + string resourceGroupName = "rg"; + string automationAccountName = "myAutomationAccount9"; + ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); + AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); + + // invoke the operation + AutomationAccountResource result = await automationAccount.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAutomationAccount() + { + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/deleteAutomationAccount.json + // this example is just showing the usage of "AutomationAccount_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AutomationAccountResource created on azure + // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource + string subscriptionId = "subid"; + string resourceGroupName = "rg"; + string automationAccountName = "myAutomationAccount9"; + ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); + AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); + + // invoke the operation + await automationAccount.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_UpdateAnAutomationAccount() + { + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/updateAutomationAccount.json + // this example is just showing the usage of "AutomationAccount_Update" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AutomationAccountResource created on azure + // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource + string subscriptionId = "subid"; + string resourceGroupName = "rg"; + string automationAccountName = "myAutomationAccount9"; + ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); + AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); + + // invoke the operation + AutomationAccountPatch patch = new AutomationAccountPatch + { + Name = "myAutomationAccount9", + Location = new AzureLocation("East US 2"), + Sku = new AutomationSku(AutomationSkuName.Free), + }; + AutomationAccountResource result = await automationAccount.UpdateAsync(patch); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task AutomationPrivateLinkResources_GetsPrivateEndpointConnection() @@ -217,129 +308,6 @@ public async Task GetAllNodeCountInformation_GetNodeSStatusCounts() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAnAutomationAccount() - { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/updateAutomationAccount.json - // this example is just showing the usage of "AutomationAccount_Update" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AutomationAccountResource created on azure - // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource - string subscriptionId = "subid"; - string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount9"; - ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); - AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); - - // invoke the operation - AutomationAccountPatch patch = new AutomationAccountPatch() - { - Name = "myAutomationAccount9", - Location = new AzureLocation("East US 2"), - Sku = new AutomationSku(AutomationSkuName.Free), - }; - AutomationAccountResource result = await automationAccount.UpdateAsync(patch); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAutomationAccount() - { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/deleteAutomationAccount.json - // this example is just showing the usage of "AutomationAccount_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AutomationAccountResource created on azure - // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource - string subscriptionId = "subid"; - string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount9"; - ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); - AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); - - // invoke the operation - await automationAccount.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAutomationAccount() - { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getAutomationAccount.json - // this example is just showing the usage of "AutomationAccount_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AutomationAccountResource created on azure - // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource - string subscriptionId = "subid"; - string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount9"; - ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); - AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); - - // invoke the operation - AutomationAccountResource result = await automationAccount.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAutomationAccounts_ListAutomationAccountsByResourceGroup() - { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/listAutomationAccountsBySubscription.json - // this example is just showing the usage of "AutomationAccount_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AutomationAccountResource item in subscriptionResource.GetAutomationAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetStatistics_GetStatisticsOfAnAutomationAccount() @@ -504,7 +472,7 @@ public async Task ConvertGraphRunbookContent_GetGraphicalRawRunbookContentFromGr AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // invoke the operation - GraphicalRunbookContent content = new GraphicalRunbookContent() + GraphicalRunbookContent content = new GraphicalRunbookContent { GraphRunbookJson = "", }; @@ -534,9 +502,9 @@ public async Task ConvertGraphRunbookContent_GetGraphicalRunbookContentFromRawCo AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // invoke the operation - GraphicalRunbookContent content = new GraphicalRunbookContent() + GraphicalRunbookContent content = new GraphicalRunbookContent { - RawContent = new RawGraphicalRunbookContent() + RawContent = new RawGraphicalRunbookContent { SchemaVersion = "1.10", RunbookDefinition = "AAEAAADAQAAAAAAAAAMAgAAAGJPcmNoZXN0cmF0b3IuR3JhcGhSdW5ib29rLk1vZGVsLCBWZXJzaW9uPTcuMy4wLjAsIEN1bHR....", diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCertificateCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCertificateCollection.cs index f3680b31314d2..0a281894f7748 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCertificateCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCertificateCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACertificate() + public async Task CreateOrUpdate_CreateOrUpdateACertificate() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCertificate.json - // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateCertificate.json + // this example is just showing the usage of "Certificate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task Get_GetACertificate() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount33"; + string automationAccountName = "myAutomationAccount18"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); @@ -41,7 +41,14 @@ public async Task Get_GetACertificate() // invoke the operation string certificateName = "testCert"; - AutomationCertificateResource result = await collection.GetAsync(certificateName); + AutomationCertificateCreateOrUpdateContent content = new AutomationCertificateCreateOrUpdateContent("testCert", "base 64 value of cert") + { + Description = "Sample Cert", + ThumbprintString = "thumbprint of cert", + IsExportable = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, content); + AutomationCertificateResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +59,7 @@ public async Task Get_GetACertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACertificate() + public async Task Get_GetACertificate() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCertificate.json // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +82,21 @@ public async Task Exists_GetACertificate() // invoke the operation string certificateName = "testCert"; - bool result = await collection.ExistsAsync(certificateName); + AutomationCertificateResource result = await collection.GetAsync(certificateName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACertificate() + public async Task GetAll_ListCertificates() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCertificate.json - // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listCertificatesByAutomationAccount.json + // this example is just showing the usage of "Certificate_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +114,25 @@ public async Task GetIfExists_GetACertificate() // get the collection of this AutomationCertificateResource AutomationCertificateCollection collection = automationAccount.GetAutomationCertificates(); - // invoke the operation - string certificateName = "testCert"; - NullableResponse response = await collection.GetIfExistsAsync(certificateName); - AutomationCertificateResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationCertificateResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationCertificateData resourceData = result.Data; + AutomationCertificateData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateACertificate() + public async Task Exists_GetACertificate() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateCertificate.json - // this example is just showing the usage of "Certificate_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCertificate.json + // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,7 +143,7 @@ public async Task CreateOrUpdate_CreateOrUpdateACertificate() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount18"; + string automationAccountName = "myAutomationAccount33"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); @@ -147,28 +152,17 @@ public async Task CreateOrUpdate_CreateOrUpdateACertificate() // invoke the operation string certificateName = "testCert"; - AutomationCertificateCreateOrUpdateContent content = new AutomationCertificateCreateOrUpdateContent("testCert", "base 64 value of cert") - { - Description = "Sample Cert", - ThumbprintString = "thumbprint of cert", - IsExportable = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, content); - AutomationCertificateResource result = lro.Value; + bool result = await collection.ExistsAsync(certificateName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCertificates() + public async Task GetIfExists_GetACertificate() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listCertificatesByAutomationAccount.json - // this example is just showing the usage of "Certificate_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCertificate.json + // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_ListCertificates() // get the collection of this AutomationCertificateResource AutomationCertificateCollection collection = automationAccount.GetAutomationCertificates(); - // invoke the operation and iterate over the result - await foreach (AutomationCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string certificateName = "testCert"; + NullableResponse response = await collection.GetIfExistsAsync(certificateName); + AutomationCertificateResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationCertificateData resourceData = item.Data; + AutomationCertificateData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCertificateResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCertificateResource.cs index 74fe82694b2ff..ded292887489a 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCertificateResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCertificateResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationCertificateResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACertificate() + public async Task Get_GetACertificate() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteCertificate.json - // this example is just showing the usage of "Certificate_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCertificate.json + // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteACertificate() AutomationCertificateResource automationCertificate = client.GetAutomationCertificateResource(automationCertificateResourceId); // invoke the operation - await automationCertificate.DeleteAsync(WaitUntil.Completed); + AutomationCertificateResource result = await automationCertificate.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACertificate() + public async Task Delete_DeleteACertificate() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCertificate.json - // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteCertificate.json + // this example is just showing the usage of "Certificate_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetACertificate() AutomationCertificateResource automationCertificate = client.GetAutomationCertificateResource(automationCertificateResourceId); // invoke the operation - AutomationCertificateResource result = await automationCertificate.GetAsync(); + await automationCertificate.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_UpdateACertificate() AutomationCertificateResource automationCertificate = client.GetAutomationCertificateResource(automationCertificateResourceId); // invoke the operation - AutomationCertificatePatch patch = new AutomationCertificatePatch() + AutomationCertificatePatch patch = new AutomationCertificatePatch { Name = "testCert", Description = "sample certificate. Description updated", diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionCollection.cs index a6e972fbef93e..f7eb8b4ff62b7 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAConnection() + public async Task CreateOrUpdate_CreateOrUpdateConnection() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnection.json - // this example is just showing the usage of "Connection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateConnection.json + // this example is just showing the usage of "Connection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,21 @@ public async Task Get_GetAConnection() AutomationConnectionCollection collection = automationAccount.GetAutomationConnections(); // invoke the operation - string connectionName = "myConnection"; - AutomationConnectionResource result = await collection.GetAsync(connectionName); + string connectionName = "mysConnection"; + AutomationConnectionCreateOrUpdateContent content = new AutomationConnectionCreateOrUpdateContent("mysConnection", new ConnectionTypeAssociationProperty + { + Name = "Azure", + }) + { + Description = "my description goes here", + FieldDefinitionValues = +{ +["AutomationCertificateName"] = "mysCertificateName", +["SubscriptionID"] = "subid" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionName, content); + AutomationConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +65,7 @@ public async Task Get_GetAConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAConnection() + public async Task Get_GetAConnection() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnection.json // this example is just showing the usage of "Connection_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +88,21 @@ public async Task Exists_GetAConnection() // invoke the operation string connectionName = "myConnection"; - bool result = await collection.ExistsAsync(connectionName); + AutomationConnectionResource result = await collection.GetAsync(connectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAConnection() + public async Task GetAll_ListConnectionsByAutomationAccountFirst100() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnection.json - // this example is just showing the usage of "Connection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listConnectionsByAutomationAccount_First100.json + // this example is just showing the usage of "Connection_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +120,25 @@ public async Task GetIfExists_GetAConnection() // get the collection of this AutomationConnectionResource AutomationConnectionCollection collection = automationAccount.GetAutomationConnections(); - // invoke the operation - string connectionName = "myConnection"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - AutomationConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationConnectionData resourceData = result.Data; + AutomationConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateConnection() + public async Task GetAll_ListConnectionsByAutomationAccountNext100() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateConnection.json - // this example is just showing the usage of "Connection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listConnectionsByAutomationAccount_Next100.json + // this example is just showing the usage of "Connection_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,36 +156,25 @@ public async Task CreateOrUpdate_CreateOrUpdateConnection() // get the collection of this AutomationConnectionResource AutomationConnectionCollection collection = automationAccount.GetAutomationConnections(); - // invoke the operation - string connectionName = "mysConnection"; - AutomationConnectionCreateOrUpdateContent content = new AutomationConnectionCreateOrUpdateContent("mysConnection", new ConnectionTypeAssociationProperty() - { - Name = "Azure", - }) + // invoke the operation and iterate over the result + await foreach (AutomationConnectionResource item in collection.GetAllAsync()) { - Description = "my description goes here", - FieldDefinitionValues = -{ -["AutomationCertificateName"] = "mysCertificateName", -["SubscriptionID"] = "subid", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionName, content); - AutomationConnectionResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConnectionsByAutomationAccountFirst100() + public async Task Exists_GetAConnection() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listConnectionsByAutomationAccount_First100.json - // this example is just showing the usage of "Connection_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnection.json + // this example is just showing the usage of "Connection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,25 +192,19 @@ public async Task GetAll_ListConnectionsByAutomationAccountFirst100() // get the collection of this AutomationConnectionResource AutomationConnectionCollection collection = automationAccount.GetAutomationConnections(); - // invoke the operation and iterate over the result - await foreach (AutomationConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string connectionName = "myConnection"; + bool result = await collection.ExistsAsync(connectionName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConnectionsByAutomationAccountNext100() + public async Task GetIfExists_GetAConnection() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listConnectionsByAutomationAccount_Next100.json - // this example is just showing the usage of "Connection_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnection.json + // this example is just showing the usage of "Connection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -228,17 +222,23 @@ public async Task GetAll_ListConnectionsByAutomationAccountNext100() // get the collection of this AutomationConnectionResource AutomationConnectionCollection collection = automationAccount.GetAutomationConnections(); - // invoke the operation and iterate over the result - await foreach (AutomationConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string connectionName = "myConnection"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + AutomationConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationConnectionData resourceData = item.Data; + AutomationConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionResource.cs index a39c9970c93cf..45db8c4a278b0 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnExistingConnection() + public async Task Get_GetAConnection() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteConnection.json - // this example is just showing the usage of "Connection_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnection.json + // this example is just showing the usage of "Connection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteAnExistingConnection() AutomationConnectionResource automationConnection = client.GetAutomationConnectionResource(automationConnectionResourceId); // invoke the operation - await automationConnection.DeleteAsync(WaitUntil.Completed); + AutomationConnectionResource result = await automationConnection.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAConnection() + public async Task Delete_DeleteAnExistingConnection() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnection.json - // this example is just showing the usage of "Connection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteConnection.json + // this example is just showing the usage of "Connection_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetAConnection() AutomationConnectionResource automationConnection = client.GetAutomationConnectionResource(automationConnectionResourceId); // invoke the operation - AutomationConnectionResource result = await automationConnection.GetAsync(); + await automationConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,14 +96,14 @@ public async Task Update_UpdateAConnection() AutomationConnectionResource automationConnection = client.GetAutomationConnectionResource(automationConnectionResourceId); // invoke the operation - AutomationConnectionPatch patch = new AutomationConnectionPatch() + AutomationConnectionPatch patch = new AutomationConnectionPatch { Name = "myConnection", Description = "my description goes here", FieldDefinitionValues = { ["AutomationCertificateName"] = "myCertificateName", -["SubscriptionID"] = "b5e4748c-f69a-467c-8749-e2f9c8cd3009", +["SubscriptionID"] = "b5e4748c-f69a-467c-8749-e2f9c8cd3009" }, }; AutomationConnectionResource result = await automationConnection.UpdateAsync(patch); diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionTypeCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionTypeCollection.cs index 3535d924d8e3f..ebe51494d27df 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionTypeCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionTypeCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AutomationConnectionTypeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetConnectionType() + public async Task CreateOrUpdate_CreateOrUpdateConnectionType() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnectionType.json - // this example is just showing the usage of "ConnectionType_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateConnectionType.json + // this example is just showing the usage of "ConnectionType_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,29 @@ public async Task Get_GetConnectionType() // invoke the operation string connectionTypeName = "myCT"; - AutomationConnectionTypeResource result = await collection.GetAsync(connectionTypeName); + AutomationConnectionTypeCreateOrUpdateContent content = new AutomationConnectionTypeCreateOrUpdateContent("myCT", new Dictionary + { + ["myBoolField"] = new AutomationConnectionFieldDefinition("bool") + { + IsEncrypted = false, + IsOptional = false, + }, + ["myStringField"] = new AutomationConnectionFieldDefinition("string") + { + IsEncrypted = false, + IsOptional = false, + }, + ["myStringFieldEncrypted"] = new AutomationConnectionFieldDefinition("string") + { + IsEncrypted = true, + IsOptional = false, + } + }) + { + IsGlobal = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionTypeName, content); + AutomationConnectionTypeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +75,7 @@ public async Task Get_GetConnectionType() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetConnectionType() + public async Task Get_GetConnectionType() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnectionType.json // this example is just showing the usage of "ConnectionType_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +98,21 @@ public async Task Exists_GetConnectionType() // invoke the operation string connectionTypeName = "myCT"; - bool result = await collection.ExistsAsync(connectionTypeName); + AutomationConnectionTypeResource result = await collection.GetAsync(connectionTypeName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationConnectionTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetConnectionType() + public async Task GetAll_GetConnectionTypesFirst100() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnectionType.json - // this example is just showing the usage of "ConnectionType_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getAllConnectionTypes_First100.json + // this example is just showing the usage of "ConnectionType_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,38 +123,32 @@ public async Task GetIfExists_GetConnectionType() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount22"; + string automationAccountName = "myAutomationAccount25"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // get the collection of this AutomationConnectionTypeResource AutomationConnectionTypeCollection collection = automationAccount.GetAutomationConnectionTypes(); - // invoke the operation - string connectionTypeName = "myCT"; - NullableResponse response = await collection.GetIfExistsAsync(connectionTypeName); - AutomationConnectionTypeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationConnectionTypeResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationConnectionTypeData resourceData = result.Data; + AutomationConnectionTypeData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateConnectionType() + public async Task GetAll_GetConnectionTypesNext100() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateConnectionType.json - // this example is just showing the usage of "ConnectionType_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getAllConnectionTypes_Next100.json + // this example is just showing the usage of "ConnectionType_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,52 +159,32 @@ public async Task CreateOrUpdate_CreateOrUpdateConnectionType() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount22"; + string automationAccountName = "myAutomationAccount25"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // get the collection of this AutomationConnectionTypeResource AutomationConnectionTypeCollection collection = automationAccount.GetAutomationConnectionTypes(); - // invoke the operation - string connectionTypeName = "myCT"; - AutomationConnectionTypeCreateOrUpdateContent content = new AutomationConnectionTypeCreateOrUpdateContent("myCT", new Dictionary() - { - ["myBoolField"] = new AutomationConnectionFieldDefinition("bool") - { - IsEncrypted = false, - IsOptional = false, - }, - ["myStringField"] = new AutomationConnectionFieldDefinition("string") - { - IsEncrypted = false, - IsOptional = false, - }, - ["myStringFieldEncrypted"] = new AutomationConnectionFieldDefinition("string") - { - IsEncrypted = true, - IsOptional = false, - }, - }) + // invoke the operation and iterate over the result + await foreach (AutomationConnectionTypeResource item in collection.GetAllAsync()) { - IsGlobal = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionTypeName, content); - AutomationConnectionTypeResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationConnectionTypeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationConnectionTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetConnectionTypesFirst100() + public async Task Exists_GetConnectionType() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getAllConnectionTypes_First100.json - // this example is just showing the usage of "ConnectionType_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnectionType.json + // this example is just showing the usage of "ConnectionType_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,32 +195,26 @@ public async Task GetAll_GetConnectionTypesFirst100() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount25"; + string automationAccountName = "myAutomationAccount22"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // get the collection of this AutomationConnectionTypeResource AutomationConnectionTypeCollection collection = automationAccount.GetAutomationConnectionTypes(); - // invoke the operation and iterate over the result - await foreach (AutomationConnectionTypeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationConnectionTypeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string connectionTypeName = "myCT"; + bool result = await collection.ExistsAsync(connectionTypeName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetConnectionTypesNext100() + public async Task GetIfExists_GetConnectionType() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getAllConnectionTypes_Next100.json - // this example is just showing the usage of "ConnectionType_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnectionType.json + // this example is just showing the usage of "ConnectionType_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -231,24 +225,30 @@ public async Task GetAll_GetConnectionTypesNext100() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount25"; + string automationAccountName = "myAutomationAccount22"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // get the collection of this AutomationConnectionTypeResource AutomationConnectionTypeCollection collection = automationAccount.GetAutomationConnectionTypes(); - // invoke the operation and iterate over the result - await foreach (AutomationConnectionTypeResource item in collection.GetAllAsync()) + // invoke the operation + string connectionTypeName = "myCT"; + NullableResponse response = await collection.GetIfExistsAsync(connectionTypeName); + AutomationConnectionTypeResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationConnectionTypeData resourceData = item.Data; + AutomationConnectionTypeData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionTypeResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionTypeResource.cs index 6bef7dbbda70d..2cfde41beb539 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionTypeResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationConnectionTypeResource.cs @@ -19,10 +19,10 @@ public partial class Sample_AutomationConnectionTypeResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnExistingConnectionType() + public async Task Get_GetConnectionType() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteConnectionType.json - // this example is just showing the usage of "ConnectionType_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnectionType.json + // this example is just showing the usage of "ConnectionType_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteAnExistingConnectionType() AutomationConnectionTypeResource automationConnectionType = client.GetAutomationConnectionTypeResource(automationConnectionTypeResourceId); // invoke the operation - await automationConnectionType.DeleteAsync(WaitUntil.Completed); + AutomationConnectionTypeResource result = await automationConnectionType.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationConnectionTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetConnectionType() + public async Task Delete_DeleteAnExistingConnectionType() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getConnectionType.json - // this example is just showing the usage of "ConnectionType_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteConnectionType.json + // this example is just showing the usage of "ConnectionType_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,13 +70,9 @@ public async Task Get_GetConnectionType() AutomationConnectionTypeResource automationConnectionType = client.GetAutomationConnectionTypeResource(automationConnectionTypeResourceId); // invoke the operation - AutomationConnectionTypeResource result = await automationConnectionType.GetAsync(); + await automationConnectionType.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationConnectionTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,7 +97,7 @@ public async Task Update_CreateOrUpdateConnectionType() AutomationConnectionTypeResource automationConnectionType = client.GetAutomationConnectionTypeResource(automationConnectionTypeResourceId); // invoke the operation - AutomationConnectionTypeCreateOrUpdateContent content = new AutomationConnectionTypeCreateOrUpdateContent("myCT", new Dictionary() + AutomationConnectionTypeCreateOrUpdateContent content = new AutomationConnectionTypeCreateOrUpdateContent("myCT", new Dictionary { ["myBoolField"] = new AutomationConnectionFieldDefinition("bool") { @@ -113,7 +113,7 @@ public async Task Update_CreateOrUpdateConnectionType() { IsEncrypted = true, IsOptional = false, - }, + } }) { IsGlobal = false, diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCredentialCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCredentialCollection.cs index d9295937cf74d..fd58a153baaa8 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCredentialCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCredentialCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationCredentialCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACredential() + public async Task CreateOrUpdate_CreateACredential() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCredential.json - // this example is just showing the usage of "Credential_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateCredential.json + // this example is just showing the usage of "Credential_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetACredential() // invoke the operation string credentialName = "myCredential"; - AutomationCredentialResource result = await collection.GetAsync(credentialName); + AutomationCredentialCreateOrUpdateContent content = new AutomationCredentialCreateOrUpdateContent("myCredential", "mylingaiah", "") + { + Description = "my description goes here", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, credentialName, content); + AutomationCredentialResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetACredential() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACredential() + public async Task Get_GetACredential() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCredential.json // this example is just showing the usage of "Credential_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetACredential() // invoke the operation string credentialName = "myCredential"; - bool result = await collection.ExistsAsync(credentialName); + AutomationCredentialResource result = await collection.GetAsync(credentialName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACredential() + public async Task GetAll_ListCredentialsByAutomationAccountFirst100() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCredential.json - // this example is just showing the usage of "Credential_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listCredentialsByAutomationAccount.json + // this example is just showing the usage of "Credential_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,38 +105,32 @@ public async Task GetIfExists_GetACredential() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount18"; + string automationAccountName = "myAutomationAccount20"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // get the collection of this AutomationCredentialResource AutomationCredentialCollection collection = automationAccount.GetAutomationCredentials(); - // invoke the operation - string credentialName = "myCredential"; - NullableResponse response = await collection.GetIfExistsAsync(credentialName); - AutomationCredentialResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationCredentialResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationCredentialData resourceData = result.Data; + AutomationCredentialData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateACredential() + public async Task GetAll_ListCredentialsByAutomationAccountNext100() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateCredential.json - // this example is just showing the usage of "Credential_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listCredentialsByAutomationAccount_next100_using_nextLink.json + // this example is just showing the usage of "Credential_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,35 +141,32 @@ public async Task CreateOrUpdate_CreateACredential() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount18"; + string automationAccountName = "myAutomationAccount20"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // get the collection of this AutomationCredentialResource AutomationCredentialCollection collection = automationAccount.GetAutomationCredentials(); - // invoke the operation - string credentialName = "myCredential"; - AutomationCredentialCreateOrUpdateContent content = new AutomationCredentialCreateOrUpdateContent("myCredential", "mylingaiah", "") + // invoke the operation and iterate over the result + await foreach (AutomationCredentialResource item in collection.GetAllAsync()) { - Description = "my description goes here", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, credentialName, content); - AutomationCredentialResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationCredentialData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCredentialsByAutomationAccountFirst100() + public async Task Exists_GetACredential() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listCredentialsByAutomationAccount.json - // this example is just showing the usage of "Credential_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCredential.json + // this example is just showing the usage of "Credential_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,32 +177,26 @@ public async Task GetAll_ListCredentialsByAutomationAccountFirst100() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount20"; + string automationAccountName = "myAutomationAccount18"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // get the collection of this AutomationCredentialResource AutomationCredentialCollection collection = automationAccount.GetAutomationCredentials(); - // invoke the operation and iterate over the result - await foreach (AutomationCredentialResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationCredentialData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string credentialName = "myCredential"; + bool result = await collection.ExistsAsync(credentialName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCredentialsByAutomationAccountNext100() + public async Task GetIfExists_GetACredential() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listCredentialsByAutomationAccount_next100_using_nextLink.json - // this example is just showing the usage of "Credential_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCredential.json + // this example is just showing the usage of "Credential_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,24 +207,30 @@ public async Task GetAll_ListCredentialsByAutomationAccountNext100() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount20"; + string automationAccountName = "myAutomationAccount18"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // get the collection of this AutomationCredentialResource AutomationCredentialCollection collection = automationAccount.GetAutomationCredentials(); - // invoke the operation and iterate over the result - await foreach (AutomationCredentialResource item in collection.GetAllAsync()) + // invoke the operation + string credentialName = "myCredential"; + NullableResponse response = await collection.GetIfExistsAsync(credentialName); + AutomationCredentialResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationCredentialData resourceData = item.Data; + AutomationCredentialData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCredentialResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCredentialResource.cs index c790df2270bc8..ac94273e261d1 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCredentialResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationCredentialResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationCredentialResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACredential() + public async Task Get_GetACredential() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteCredentialExisting.json - // this example is just showing the usage of "Credential_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCredential.json + // this example is just showing the usage of "Credential_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,23 +32,27 @@ public async Task Delete_DeleteACredential() // for more information of creating AutomationCredentialResource, please refer to the document of AutomationCredentialResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount20"; + string automationAccountName = "myAutomationAccount18"; string credentialName = "myCredential"; ResourceIdentifier automationCredentialResourceId = AutomationCredentialResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, credentialName); AutomationCredentialResource automationCredential = client.GetAutomationCredentialResource(automationCredentialResourceId); // invoke the operation - await automationCredential.DeleteAsync(WaitUntil.Completed); + AutomationCredentialResource result = await automationCredential.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACredential() + public async Task Delete_DeleteACredential() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCredential.json - // this example is just showing the usage of "Credential_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteCredentialExisting.json + // this example is just showing the usage of "Credential_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,19 +63,15 @@ public async Task Get_GetACredential() // for more information of creating AutomationCredentialResource, please refer to the document of AutomationCredentialResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount18"; + string automationAccountName = "myAutomationAccount20"; string credentialName = "myCredential"; ResourceIdentifier automationCredentialResourceId = AutomationCredentialResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, credentialName); AutomationCredentialResource automationCredential = client.GetAutomationCredentialResource(automationCredentialResourceId); // invoke the operation - AutomationCredentialResource result = await automationCredential.GetAsync(); + await automationCredential.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_UpdateACredential() AutomationCredentialResource automationCredential = client.GetAutomationCredentialResource(automationCredentialResourceId); // invoke the operation - AutomationCredentialPatch patch = new AutomationCredentialPatch() + AutomationCredentialPatch patch = new AutomationCredentialPatch { Name = "myCredential", UserName = "mylingaiah", diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobCollection.cs index 77f6aa4536f65..7418227e11b71 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationJobCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetJob() + public async Task CreateOrUpdate_CreateJob() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJob.json - // this example is just showing the usage of "Job_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/createJob.json + // this example is just showing the usage of "Job_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_GetJob() // invoke the operation string jobName = "foo"; - AutomationJobResource result = await collection.GetAsync(jobName); + AutomationJobCreateOrUpdateContent content = new AutomationJobCreateOrUpdateContent + { + RunbookName = "TestRunbook", + Parameters = +{ +["key01"] = "value01", +["key02"] = "value02" +}, + RunOn = "", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, content); + AutomationJobResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +63,7 @@ public async Task Get_GetJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetJob() + public async Task Get_GetJob() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJob.json // this example is just showing the usage of "Job_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +86,21 @@ public async Task Exists_GetJob() // invoke the operation string jobName = "foo"; - bool result = await collection.ExistsAsync(jobName); + AutomationJobResource result = await collection.GetAsync(jobName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetJob() + public async Task GetAll_ListJobsByAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJob.json - // this example is just showing the usage of "Job_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/listJobsByAutomationAccount.json + // this example is just showing the usage of "Job_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +118,21 @@ public async Task GetIfExists_GetJob() // get the collection of this AutomationJobResource AutomationJobCollection collection = automationAccount.GetAutomationJobs(); - // invoke the operation - string jobName = "foo"; - NullableResponse response = await collection.GetIfExistsAsync(jobName); - AutomationJobResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationJobCollectionItemData item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {item}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateJob() + public async Task Exists_GetJob() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/createJob.json - // this example is just showing the usage of "Job_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJob.json + // this example is just showing the usage of "Job_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,32 +152,17 @@ public async Task CreateOrUpdate_CreateJob() // invoke the operation string jobName = "foo"; - AutomationJobCreateOrUpdateContent content = new AutomationJobCreateOrUpdateContent() - { - RunbookName = "TestRunbook", - Parameters = -{ -["key01"] = "value01", -["key02"] = "value02", -}, - RunOn = "", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, content); - AutomationJobResource result = lro.Value; + bool result = await collection.ExistsAsync(jobName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListJobsByAutomationAccount() + public async Task GetIfExists_GetJob() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/listJobsByAutomationAccount.json - // this example is just showing the usage of "Job_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJob.json + // this example is just showing the usage of "Job_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,13 +180,23 @@ public async Task GetAll_ListJobsByAutomationAccount() // get the collection of this AutomationJobResource AutomationJobCollection collection = automationAccount.GetAutomationJobs(); - // invoke the operation and iterate over the result - await foreach (AutomationJobCollectionItemData item in collection.GetAllAsync()) + // invoke the operation + string jobName = "foo"; + NullableResponse response = await collection.GetIfExistsAsync(jobName); + AutomationJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Console.WriteLine($"Succeeded: {item}"); + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobResource.cs index 390cc209ed51b..9e4ab5311fba1 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationJobResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetOutput_GetJobOutput() + public async Task Get_GetJob() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJobOutput.json - // this example is just showing the usage of "Job_GetOutput" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJob.json + // this example is just showing the usage of "Job_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetOutput_GetJobOutput() AutomationJobResource automationJob = client.GetAutomationJobResource(automationJobResourceId); // invoke the operation - string result = await automationJob.GetOutputAsync(); + AutomationJobResource result = await automationJob.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetRunbookContent_GetJobRunbookContent() + public async Task Update_CreateJob() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJobRunbookContent.json - // this example is just showing the usage of "Job_GetRunbookContent" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/createJob.json + // this example is just showing the usage of "Job_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,17 +69,32 @@ public async Task GetRunbookContent_GetJobRunbookContent() AutomationJobResource automationJob = client.GetAutomationJobResource(automationJobResourceId); // invoke the operation - string result = await automationJob.GetRunbookContentAsync(); + AutomationJobCreateOrUpdateContent content = new AutomationJobCreateOrUpdateContent + { + RunbookName = "TestRunbook", + Parameters = +{ +["key01"] = "value01", +["key02"] = "value02" +}, + RunOn = "", + }; + ArmOperation lro = await automationJob.UpdateAsync(WaitUntil.Completed, content); + AutomationJobResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Suspend_SuspendJob() + public async Task GetOutput_GetJobOutput() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/suspendJob.json - // this example is just showing the usage of "Job_Suspend" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJobOutput.json + // this example is just showing the usage of "Job_GetOutput" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,17 +111,17 @@ public async Task Suspend_SuspendJob() AutomationJobResource automationJob = client.GetAutomationJobResource(automationJobResourceId); // invoke the operation - await automationJob.SuspendAsync(); + string result = await automationJob.GetOutputAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Stop_StopJob() + public async Task GetRunbookContent_GetJobRunbookContent() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/stopJob.json - // this example is just showing the usage of "Job_Stop" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJobRunbookContent.json + // this example is just showing the usage of "Job_GetRunbookContent" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -119,17 +138,17 @@ public async Task Stop_StopJob() AutomationJobResource automationJob = client.GetAutomationJobResource(automationJobResourceId); // invoke the operation - await automationJob.StopAsync(); + string result = await automationJob.GetRunbookContentAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetJob() + public async Task Suspend_SuspendJob() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/getJob.json - // this example is just showing the usage of "Job_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/suspendJob.json + // this example is just showing the usage of "Job_Suspend" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,21 +165,17 @@ public async Task Get_GetJob() AutomationJobResource automationJob = client.GetAutomationJobResource(automationJobResourceId); // invoke the operation - AutomationJobResource result = await automationJob.GetAsync(); + await automationJob.SuspendAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateJob() + public async Task Stop_StopJob() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/createJob.json - // this example is just showing the usage of "Job_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/job/stopJob.json + // this example is just showing the usage of "Job_Stop" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,24 +192,9 @@ public async Task Update_CreateJob() AutomationJobResource automationJob = client.GetAutomationJobResource(automationJobResourceId); // invoke the operation - AutomationJobCreateOrUpdateContent content = new AutomationJobCreateOrUpdateContent() - { - RunbookName = "TestRunbook", - Parameters = -{ -["key01"] = "value01", -["key02"] = "value02", -}, - RunOn = "", - }; - ArmOperation lro = await automationJob.UpdateAsync(WaitUntil.Completed, content); - AutomationJobResource result = lro.Value; + await automationJob.StopAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobScheduleCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobScheduleCollection.cs index ea153b240f039..e064cdd5c8b4c 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobScheduleCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobScheduleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationJobScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAJobSchedule() + public async Task CreateOrUpdate_CreateAJobSchedule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getJobSchedule.json - // this example is just showing the usage of "JobSchedule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createJobSchedule.json + // this example is just showing the usage of "JobSchedule_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,22 @@ public async Task Get_GetAJobSchedule() // invoke the operation Guid jobScheduleId = Guid.Parse("0fa462ba-3aa2-4138-83ca-9ebc3bc55cdc"); - AutomationJobScheduleResource result = await collection.GetAsync(jobScheduleId); + AutomationJobScheduleCreateOrUpdateContent content = new AutomationJobScheduleCreateOrUpdateContent(new ScheduleAssociationProperty + { + Name = "ScheduleNameGoesHere332204b5-debe-4348-a5c7-6357457189f2", + }, new RunbookAssociationProperty + { + Name = "TestRunbook", + }) + { + Parameters = +{ +["jobscheduletag01"] = "jobschedulevalue01", +["jobscheduletag02"] = "jobschedulevalue02" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobScheduleId, content); + AutomationJobScheduleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +67,7 @@ public async Task Get_GetAJobSchedule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAJobSchedule() + public async Task Get_GetAJobSchedule() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getJobSchedule.json // this example is just showing the usage of "JobSchedule_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +90,21 @@ public async Task Exists_GetAJobSchedule() // invoke the operation Guid jobScheduleId = Guid.Parse("0fa462ba-3aa2-4138-83ca-9ebc3bc55cdc"); - bool result = await collection.ExistsAsync(jobScheduleId); + AutomationJobScheduleResource result = await collection.GetAsync(jobScheduleId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationJobScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAJobSchedule() + public async Task GetAll_ListAllJobSchedulesByAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getJobSchedule.json - // this example is just showing the usage of "JobSchedule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listAllJobSchedulesByAutomationAccount.json + // this example is just showing the usage of "JobSchedule_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +122,25 @@ public async Task GetIfExists_GetAJobSchedule() // get the collection of this AutomationJobScheduleResource AutomationJobScheduleCollection collection = automationAccount.GetAutomationJobSchedules(); - // invoke the operation - Guid jobScheduleId = Guid.Parse("0fa462ba-3aa2-4138-83ca-9ebc3bc55cdc"); - NullableResponse response = await collection.GetIfExistsAsync(jobScheduleId); - AutomationJobScheduleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationJobScheduleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationJobScheduleData resourceData = result.Data; + AutomationJobScheduleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAJobSchedule() + public async Task Exists_GetAJobSchedule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createJobSchedule.json - // this example is just showing the usage of "JobSchedule_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getJobSchedule.json + // this example is just showing the usage of "JobSchedule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,36 +160,17 @@ public async Task CreateOrUpdate_CreateAJobSchedule() // invoke the operation Guid jobScheduleId = Guid.Parse("0fa462ba-3aa2-4138-83ca-9ebc3bc55cdc"); - AutomationJobScheduleCreateOrUpdateContent content = new AutomationJobScheduleCreateOrUpdateContent(new ScheduleAssociationProperty() - { - Name = "ScheduleNameGoesHere332204b5-debe-4348-a5c7-6357457189f2", - }, new RunbookAssociationProperty() - { - Name = "TestRunbook", - }) - { - Parameters = -{ -["jobscheduletag01"] = "jobschedulevalue01", -["jobscheduletag02"] = "jobschedulevalue02", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobScheduleId, content); - AutomationJobScheduleResource result = lro.Value; + bool result = await collection.ExistsAsync(jobScheduleId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationJobScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllJobSchedulesByAutomationAccount() + public async Task GetIfExists_GetAJobSchedule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listAllJobSchedulesByAutomationAccount.json - // this example is just showing the usage of "JobSchedule_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getJobSchedule.json + // this example is just showing the usage of "JobSchedule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -194,17 +188,23 @@ public async Task GetAll_ListAllJobSchedulesByAutomationAccount() // get the collection of this AutomationJobScheduleResource AutomationJobScheduleCollection collection = automationAccount.GetAutomationJobSchedules(); - // invoke the operation and iterate over the result - await foreach (AutomationJobScheduleResource item in collection.GetAllAsync()) + // invoke the operation + Guid jobScheduleId = Guid.Parse("0fa462ba-3aa2-4138-83ca-9ebc3bc55cdc"); + NullableResponse response = await collection.GetIfExistsAsync(jobScheduleId); + AutomationJobScheduleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationJobScheduleData resourceData = item.Data; + AutomationJobScheduleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobScheduleResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobScheduleResource.cs index 2cfdd093ebc35..3ee83fa861df5 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobScheduleResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationJobScheduleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationJobScheduleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAJobSchedule() + public async Task Get_GetAJobSchedule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteJobSchedule.json - // this example is just showing the usage of "JobSchedule_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getJobSchedule.json + // this example is just showing the usage of "JobSchedule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteAJobSchedule() AutomationJobScheduleResource automationJobSchedule = client.GetAutomationJobScheduleResource(automationJobScheduleResourceId); // invoke the operation - await automationJobSchedule.DeleteAsync(WaitUntil.Completed); + AutomationJobScheduleResource result = await automationJobSchedule.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationJobScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAJobSchedule() + public async Task Delete_DeleteAJobSchedule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getJobSchedule.json - // this example is just showing the usage of "JobSchedule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteJobSchedule.json + // this example is just showing the usage of "JobSchedule_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetAJobSchedule() AutomationJobScheduleResource automationJobSchedule = client.GetAutomationJobScheduleResource(automationJobScheduleResourceId); // invoke the operation - AutomationJobScheduleResource result = await automationJobSchedule.GetAsync(); + await automationJobSchedule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationJobScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,10 +96,10 @@ public async Task Update_CreateAJobSchedule() AutomationJobScheduleResource automationJobSchedule = client.GetAutomationJobScheduleResource(automationJobScheduleResourceId); // invoke the operation - AutomationJobScheduleCreateOrUpdateContent content = new AutomationJobScheduleCreateOrUpdateContent(new ScheduleAssociationProperty() + AutomationJobScheduleCreateOrUpdateContent content = new AutomationJobScheduleCreateOrUpdateContent(new ScheduleAssociationProperty { Name = "ScheduleNameGoesHere332204b5-debe-4348-a5c7-6357457189f2", - }, new RunbookAssociationProperty() + }, new RunbookAssociationProperty { Name = "TestRunbook", }) @@ -107,7 +107,7 @@ public async Task Update_CreateAJobSchedule() Parameters = { ["jobscheduletag01"] = "jobschedulevalue01", -["jobscheduletag02"] = "jobschedulevalue02", +["jobscheduletag02"] = "jobschedulevalue02" }, }; ArmOperation lro = await automationJobSchedule.UpdateAsync(WaitUntil.Completed, content); diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationPrivateEndpointConnectionCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationPrivateEndpointConnectionCollection.cs index a511e458cd477..600abe719878b 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationPrivateEndpointConnectionCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateEndpointConnection() + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionListGet.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_GetsPrivateEndpointConnection() // get the collection of this AutomationPrivateEndpointConnectionResource AutomationPrivateEndpointConnectionCollection collection = automationAccount.GetAutomationPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (AutomationPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "privateEndpointConnectionName"; + AutomationPrivateEndpointConnectionData data = new AutomationPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new AutomationPrivateLinkServiceConnectionStateProperty + { + Status = "Approved", + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + AutomationPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task GetAll_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionListGet.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_GetsPrivateEndpointConnection() // get the collection of this AutomationPrivateEndpointConnectionResource AutomationPrivateEndpointConnectionCollection collection = automationAccount.GetAutomationPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "privateEndpointConnectionName"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (AutomationPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task Exists_GetsPrivateEndpointConnection() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "privateEndpointConnectionName"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - AutomationPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // invoke the operation string privateEndpointConnectionName = "privateEndpointConnectionName"; - AutomationPrivateEndpointConnectionData data = new AutomationPrivateEndpointConnectionData() - { - ConnectionState = new AutomationPrivateLinkServiceConnectionStateProperty() - { - Status = "Approved", - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - AutomationPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + AutomationPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationPrivateEndpointConnectionResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationPrivateEndpointConnectionResource.cs index 89923c1013c69..130aa793f71e1 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationPrivateEndpointConnectionResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionDelete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName AutomationPrivateEndpointConnectionResource automationPrivateEndpointConnection = client.GetAutomationPrivateEndpointConnectionResource(automationPrivateEndpointConnectionResourceId); // invoke the operation - AutomationPrivateEndpointConnectionData data = new AutomationPrivateEndpointConnectionData() - { - ConnectionState = new AutomationPrivateLinkServiceConnectionStateProperty() - { - Status = "Approved", - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await automationPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - AutomationPrivateEndpointConnectionResource result = lro.Value; + await automationPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionDelete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() AutomationPrivateEndpointConnectionResource automationPrivateEndpointConnection = client.GetAutomationPrivateEndpointConnectionResource(automationPrivateEndpointConnectionResourceId); // invoke the operation - await automationPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + AutomationPrivateEndpointConnectionData data = new AutomationPrivateEndpointConnectionData + { + ConnectionState = new AutomationPrivateLinkServiceConnectionStateProperty + { + Status = "Approved", + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await automationPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + AutomationPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationRunbookCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationRunbookCollection.cs index ad77c11dd9dd6..a1418cdef89e5 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationRunbookCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationRunbookCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationRunbookCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRunbook() + public async Task CreateOrUpdate_CreateOrUpdateRunbookAndPublishIt() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbook.json - // this example is just showing the usage of "Runbook_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/createOrUpdateRunbook.json + // this example is just showing the usage of "Runbook_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,27 @@ public async Task Get_GetRunbook() // invoke the operation string runbookName = "Get-AzureVMTutorial"; - AutomationRunbookResource result = await collection.GetAsync(runbookName); + AutomationRunbookCreateOrUpdateContent content = new AutomationRunbookCreateOrUpdateContent(AutomationRunbookType.PowerShellWorkflow) + { + Name = "Get-AzureVMTutorial", + Location = new AzureLocation("East US 2"), + Tags = +{ +["tag01"] = "value01", +["tag02"] = "value02" +}, + IsLogVerboseEnabled = false, + IsLogProgressEnabled = true, + PublishContentLink = new AutomationContentLink + { + Uri = new Uri("https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1"), + ContentHash = new AutomationContentHash("SHA256", "115775B8FF2BE672D8A946BD0B489918C724DDE15A440373CA54461D53010A80"), + }, + Description = "Description of the Runbook", + LogActivityTrace = 1, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, runbookName, content); + AutomationRunbookResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +72,10 @@ public async Task Get_GetRunbook() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRunbook() + public async Task CreateOrUpdate_CreateRunbookAsDraft() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbook.json - // this example is just showing the usage of "Runbook_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/createRunbookAsDraft.json + // this example is just showing the usage of "Runbook_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +95,33 @@ public async Task Exists_GetRunbook() // invoke the operation string runbookName = "Get-AzureVMTutorial"; - bool result = await collection.ExistsAsync(runbookName); + AutomationRunbookCreateOrUpdateContent content = new AutomationRunbookCreateOrUpdateContent(AutomationRunbookType.PowerShellWorkflow) + { + Name = "Get-AzureVMTutorial", + Location = new AzureLocation("East US 2"), + Tags = +{ +["tag01"] = "value01", +["tag02"] = "value02" +}, + IsLogVerboseEnabled = false, + IsLogProgressEnabled = false, + Draft = new AutomationRunbookDraft(), + Description = "Description of the Runbook", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, runbookName, content); + AutomationRunbookResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationRunbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRunbook() + public async Task Get_GetRunbook() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbook.json // this example is just showing the usage of "Runbook_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +144,21 @@ public async Task GetIfExists_GetRunbook() // invoke the operation string runbookName = "Get-AzureVMTutorial"; - NullableResponse response = await collection.GetIfExistsAsync(runbookName); - AutomationRunbookResource result = response.HasValue ? response.Value : null; + AutomationRunbookResource result = await collection.GetAsync(runbookName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationRunbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationRunbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRunbookAndPublishIt() + public async Task GetAll_ListRunbooksByAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/createOrUpdateRunbook.json - // this example is just showing the usage of "Runbook_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/listRunbooksByAutomationAccount.json + // this example is just showing the usage of "Runbook_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,43 +176,25 @@ public async Task CreateOrUpdate_CreateOrUpdateRunbookAndPublishIt() // get the collection of this AutomationRunbookResource AutomationRunbookCollection collection = automationAccount.GetAutomationRunbooks(); - // invoke the operation - string runbookName = "Get-AzureVMTutorial"; - AutomationRunbookCreateOrUpdateContent content = new AutomationRunbookCreateOrUpdateContent(AutomationRunbookType.PowerShellWorkflow) + // invoke the operation and iterate over the result + await foreach (AutomationRunbookResource item in collection.GetAllAsync()) { - Name = "Get-AzureVMTutorial", - Location = new AzureLocation("East US 2"), - Tags = -{ -["tag01"] = "value01", -["tag02"] = "value02", -}, - IsLogVerboseEnabled = false, - IsLogProgressEnabled = true, - PublishContentLink = new AutomationContentLink() - { - Uri = new Uri("https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-automation-runbook-getvms/Runbooks/Get-AzureVMTutorial.ps1"), - ContentHash = new AutomationContentHash("SHA256", "115775B8FF2BE672D8A946BD0B489918C724DDE15A440373CA54461D53010A80"), - }, - Description = "Description of the Runbook", - LogActivityTrace = 1, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, runbookName, content); - AutomationRunbookResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationRunbookData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationRunbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateRunbookAsDraft() + public async Task Exists_GetRunbook() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/createRunbookAsDraft.json - // this example is just showing the usage of "Runbook_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbook.json + // this example is just showing the usage of "Runbook_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -201,36 +214,17 @@ public async Task CreateOrUpdate_CreateRunbookAsDraft() // invoke the operation string runbookName = "Get-AzureVMTutorial"; - AutomationRunbookCreateOrUpdateContent content = new AutomationRunbookCreateOrUpdateContent(AutomationRunbookType.PowerShellWorkflow) - { - Name = "Get-AzureVMTutorial", - Location = new AzureLocation("East US 2"), - Tags = -{ -["tag01"] = "value01", -["tag02"] = "value02", -}, - IsLogVerboseEnabled = false, - IsLogProgressEnabled = false, - Draft = new AutomationRunbookDraft(), - Description = "Description of the Runbook", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, runbookName, content); - AutomationRunbookResource result = lro.Value; + bool result = await collection.ExistsAsync(runbookName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationRunbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRunbooksByAutomationAccount() + public async Task GetIfExists_GetRunbook() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/listRunbooksByAutomationAccount.json - // this example is just showing the usage of "Runbook_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbook.json + // this example is just showing the usage of "Runbook_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -248,17 +242,23 @@ public async Task GetAll_ListRunbooksByAutomationAccount() // get the collection of this AutomationRunbookResource AutomationRunbookCollection collection = automationAccount.GetAutomationRunbooks(); - // invoke the operation and iterate over the result - await foreach (AutomationRunbookResource item in collection.GetAllAsync()) + // invoke the operation + string runbookName = "Get-AzureVMTutorial"; + NullableResponse response = await collection.GetIfExistsAsync(runbookName); + AutomationRunbookResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationRunbookData resourceData = item.Data; + AutomationRunbookData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationRunbookResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationRunbookResource.cs index d4a082dbf4710..90cea5497f7fa 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationRunbookResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationRunbookResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationRunbookResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetContentRunbookDraft_GetRunbookDraftContent() + public async Task Get_GetRunbook() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbookDraftContent.json - // this example is just showing the usage of "RunbookDraft_GetContent" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbook.json + // this example is just showing the usage of "Runbook_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetContentRunbookDraft_GetRunbookDraftContent() AutomationRunbookResource automationRunbook = client.GetAutomationRunbookResource(automationRunbookResourceId); // invoke the operation - string result = await automationRunbook.GetContentRunbookDraftAsync(); + AutomationRunbookResource result = await automationRunbook.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationRunbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetRunbookDraft_GetRunbookDraft() + public async Task Delete_DeleteARunbook() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbookDraft.json - // this example is just showing the usage of "RunbookDraft_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/deleteRunbook.json + // this example is just showing the usage of "Runbook_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,17 +69,17 @@ public async Task GetRunbookDraft_GetRunbookDraft() AutomationRunbookResource automationRunbook = client.GetAutomationRunbookResource(automationRunbookResourceId); // invoke the operation - AutomationRunbookDraft result = await automationRunbook.GetRunbookDraftAsync(); + await automationRunbook.DeleteAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task UndoEditRunbookDraft_UndoDraftEditToLastKnownPublishedState() + public async Task Update_UpdateRunbook() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/undoDraftEditToLastKnownPublishedState.json - // this example is just showing the usage of "RunbookDraft_UndoEdit" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/updateRunbook.json + // this example is just showing the usage of "Runbook_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,17 +96,28 @@ public async Task UndoEditRunbookDraft_UndoDraftEditToLastKnownPublishedState() AutomationRunbookResource automationRunbook = client.GetAutomationRunbookResource(automationRunbookResourceId); // invoke the operation - RunbookDraftUndoEditResult result = await automationRunbook.UndoEditRunbookDraftAsync(); + AutomationRunbookPatch patch = new AutomationRunbookPatch + { + Description = "Updated Description of the Runbook", + IsLogVerboseEnabled = false, + IsLogProgressEnabled = true, + LogActivityTrace = 1, + }; + AutomationRunbookResource result = await automationRunbook.UpdateAsync(patch); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationRunbookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Publish_PublishRunbookDraft() + public async Task GetContentRunbookDraft_GetRunbookDraftContent() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/publishRunbook.json - // this example is just showing the usage of "Runbook_Publish" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbookDraftContent.json + // this example is just showing the usage of "RunbookDraft_GetContent" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -119,17 +134,17 @@ public async Task Publish_PublishRunbookDraft() AutomationRunbookResource automationRunbook = client.GetAutomationRunbookResource(automationRunbookResourceId); // invoke the operation - await automationRunbook.PublishAsync(WaitUntil.Completed); + string result = await automationRunbook.GetContentRunbookDraftAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetContent_GetRunbookContent() + public async Task GetRunbookDraft_GetRunbookDraft() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbookContent.json - // this example is just showing the usage of "Runbook_GetContent" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbookDraft.json + // this example is just showing the usage of "RunbookDraft_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,17 +161,17 @@ public async Task GetContent_GetRunbookContent() AutomationRunbookResource automationRunbook = client.GetAutomationRunbookResource(automationRunbookResourceId); // invoke the operation - string result = await automationRunbook.GetContentAsync(); + AutomationRunbookDraft result = await automationRunbook.GetRunbookDraftAsync(); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRunbook() + public async Task UndoEditRunbookDraft_UndoDraftEditToLastKnownPublishedState() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbook.json - // this example is just showing the usage of "Runbook_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/undoDraftEditToLastKnownPublishedState.json + // this example is just showing the usage of "RunbookDraft_UndoEdit" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,21 +188,17 @@ public async Task Get_GetRunbook() AutomationRunbookResource automationRunbook = client.GetAutomationRunbookResource(automationRunbookResourceId); // invoke the operation - AutomationRunbookResource result = await automationRunbook.GetAsync(); + RunbookDraftUndoEditResult result = await automationRunbook.UndoEditRunbookDraftAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationRunbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateRunbook() + public async Task Publish_PublishRunbookDraft() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/updateRunbook.json - // this example is just showing the usage of "Runbook_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/publishRunbook.json + // this example is just showing the usage of "Runbook_Publish" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -204,28 +215,17 @@ public async Task Update_UpdateRunbook() AutomationRunbookResource automationRunbook = client.GetAutomationRunbookResource(automationRunbookResourceId); // invoke the operation - AutomationRunbookPatch patch = new AutomationRunbookPatch() - { - Description = "Updated Description of the Runbook", - IsLogVerboseEnabled = false, - IsLogProgressEnabled = true, - LogActivityTrace = 1, - }; - AutomationRunbookResource result = await automationRunbook.UpdateAsync(patch); + await automationRunbook.PublishAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationRunbookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteARunbook() + public async Task GetContent_GetRunbookContent() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/deleteRunbook.json - // this example is just showing the usage of "Runbook_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2018-06-30/examples/getRunbookContent.json + // this example is just showing the usage of "Runbook_GetContent" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -242,9 +242,9 @@ public async Task Delete_DeleteARunbook() AutomationRunbookResource automationRunbook = client.GetAutomationRunbookResource(automationRunbookResourceId); // invoke the operation - await automationRunbook.DeleteAsync(WaitUntil.Completed); + string result = await automationRunbook.GetContentAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -327,12 +327,12 @@ public async Task CreateTestJob_CreateTestJob() AutomationRunbookResource automationRunbook = client.GetAutomationRunbookResource(automationRunbookResourceId); // invoke the operation - RunbookTestJobCreateContent content = new RunbookTestJobCreateContent() + RunbookTestJobCreateContent content = new RunbookTestJobCreateContent { Parameters = { ["key01"] = "value01", -["key02"] = "value02", +["key02"] = "value02" }, RunOn = "", }; diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationScheduleCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationScheduleCollection.cs index 5d15192507c82..5f2cd3678f49d 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationScheduleCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationScheduleCollection.cs @@ -45,7 +45,7 @@ public async Task CreateOrUpdate_CreateOrUpdateASchedule() { Description = "my description of schedule goes here", ExpireOn = DateTimeOffset.Parse("2017-04-01T17:28:57.2494819Z"), - Interval = BinaryData.FromString("\"1\""), + Interval = BinaryData.FromObjectAsJson("1"), AdvancedSchedule = new AutomationAdvancedSchedule(), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scheduleName, content); @@ -94,10 +94,10 @@ public async Task Get_GetASchedule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASchedule() + public async Task GetAll_ListSchedulesByAutomationAccountFirst100() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getSchedule.json - // this example is just showing the usage of "Schedule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listSchedulesByAutomationAccount_First100.json + // this example is just showing the usage of "Schedule_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,19 +115,25 @@ public async Task Exists_GetASchedule() // get the collection of this AutomationScheduleResource AutomationScheduleCollection collection = automationAccount.GetAutomationSchedules(); - // invoke the operation - string scheduleName = "mySchedule"; - bool result = await collection.ExistsAsync(scheduleName); + // invoke the operation and iterate over the result + await foreach (AutomationScheduleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASchedule() + public async Task GetAll_ListSchedulesByAutomationAccountNext100() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getSchedule.json - // this example is just showing the usage of "Schedule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listSchedulesByAutomationAccount_Next100.json + // this example is just showing the usage of "Schedule_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,31 +151,25 @@ public async Task GetIfExists_GetASchedule() // get the collection of this AutomationScheduleResource AutomationScheduleCollection collection = automationAccount.GetAutomationSchedules(); - // invoke the operation - string scheduleName = "mySchedule"; - NullableResponse response = await collection.GetIfExistsAsync(scheduleName); - AutomationScheduleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationScheduleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationScheduleData resourceData = result.Data; + AutomationScheduleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSchedulesByAutomationAccountFirst100() + public async Task Exists_GetASchedule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listSchedulesByAutomationAccount_First100.json - // this example is just showing the usage of "Schedule_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getSchedule.json + // this example is just showing the usage of "Schedule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,25 +187,19 @@ public async Task GetAll_ListSchedulesByAutomationAccountFirst100() // get the collection of this AutomationScheduleResource AutomationScheduleCollection collection = automationAccount.GetAutomationSchedules(); - // invoke the operation and iterate over the result - await foreach (AutomationScheduleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scheduleName = "mySchedule"; + bool result = await collection.ExistsAsync(scheduleName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSchedulesByAutomationAccountNext100() + public async Task GetIfExists_GetASchedule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listSchedulesByAutomationAccount_Next100.json - // this example is just showing the usage of "Schedule_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getSchedule.json + // this example is just showing the usage of "Schedule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -223,17 +217,23 @@ public async Task GetAll_ListSchedulesByAutomationAccountNext100() // get the collection of this AutomationScheduleResource AutomationScheduleCollection collection = automationAccount.GetAutomationSchedules(); - // invoke the operation and iterate over the result - await foreach (AutomationScheduleResource item in collection.GetAllAsync()) + // invoke the operation + string scheduleName = "mySchedule"; + NullableResponse response = await collection.GetIfExistsAsync(scheduleName); + AutomationScheduleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationScheduleData resourceData = item.Data; + AutomationScheduleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationScheduleResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationScheduleResource.cs index d4297e6207186..417ae440e1a89 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationScheduleResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationScheduleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationScheduleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASchedule() + public async Task Get_GetASchedule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/updateSchedule.json - // this example is just showing the usage of "Schedule_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getSchedule.json + // this example is just showing the usage of "Schedule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,13 +38,7 @@ public async Task Update_UpdateASchedule() AutomationScheduleResource automationSchedule = client.GetAutomationScheduleResource(automationScheduleResourceId); // invoke the operation - AutomationSchedulePatch patch = new AutomationSchedulePatch() - { - Name = "mySchedule", - Description = "my updated description of schedule goes here", - IsEnabled = false, - }; - AutomationScheduleResource result = await automationSchedule.UpdateAsync(patch); + AutomationScheduleResource result = await automationSchedule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +49,10 @@ public async Task Update_UpdateASchedule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASchedule() + public async Task Delete_DeleteSchedule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getSchedule.json - // this example is just showing the usage of "Schedule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteSchedule.json + // this example is just showing the usage of "Schedule_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,21 +69,17 @@ public async Task Get_GetASchedule() AutomationScheduleResource automationSchedule = client.GetAutomationScheduleResource(automationScheduleResourceId); // invoke the operation - AutomationScheduleResource result = await automationSchedule.GetAsync(); + await automationSchedule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSchedule() + public async Task Update_UpdateASchedule() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteSchedule.json - // this example is just showing the usage of "Schedule_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/updateSchedule.json + // this example is just showing the usage of "Schedule_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +96,19 @@ public async Task Delete_DeleteSchedule() AutomationScheduleResource automationSchedule = client.GetAutomationScheduleResource(automationScheduleResourceId); // invoke the operation - await automationSchedule.DeleteAsync(WaitUntil.Completed); + AutomationSchedulePatch patch = new AutomationSchedulePatch + { + Name = "mySchedule", + Description = "my updated description of schedule goes here", + IsEnabled = false, + }; + AutomationScheduleResource result = await automationSchedule.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationSourceControlCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationSourceControlCollection.cs index 4d944f4f286f7..832f31695d4b4 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationSourceControlCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationSourceControlCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_CreateOrUpdateASourceControl() // invoke the operation string sourceControlName = "sampleSourceControl"; - AutomationSourceControlCreateOrUpdateContent content = new AutomationSourceControlCreateOrUpdateContent() + AutomationSourceControlCreateOrUpdateContent content = new AutomationSourceControlCreateOrUpdateContent { RepoUri = new Uri("https://sampleUser.visualstudio.com/myProject/_git/myRepository"), Branch = "master", @@ -49,7 +49,7 @@ public async Task CreateOrUpdate_CreateOrUpdateASourceControl() IsAutoSyncEnabled = true, IsAutoPublishRunbookEnabled = true, SourceType = SourceControlSourceType.VsoGit, - SecurityToken = new SourceControlSecurityTokenProperties() + SecurityToken = new SourceControlSecurityTokenProperties { AccessToken = "3a326f7a0dcd343ea58fee21f2fd5fb4c1234567", TokenType = SourceControlTokenType.PersonalAccessToken, @@ -102,10 +102,10 @@ public async Task Get_GetASourceControl() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetASourceControl() + public async Task GetAll_ListSourceControls() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/sourceControl/getSourceControl.json - // this example is just showing the usage of "SourceControl_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/sourceControl/getAllSourceControls.json + // this example is just showing the usage of "SourceControl_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -123,16 +123,22 @@ public async Task Exists_GetASourceControl() // get the collection of this AutomationSourceControlResource AutomationSourceControlCollection collection = automationAccount.GetAutomationSourceControls(); - // invoke the operation - string sourceControlName = "sampleSourceControl"; - bool result = await collection.ExistsAsync(sourceControlName); + // invoke the operation and iterate over the result + await foreach (AutomationSourceControlResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationSourceControlData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetASourceControl() + public async Task Exists_GetASourceControl() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/sourceControl/getSourceControl.json // this example is just showing the usage of "SourceControl_Get" operation, for the dependent resources, they will have to be created separately. @@ -155,29 +161,17 @@ public async Task GetIfExists_GetASourceControl() // invoke the operation string sourceControlName = "sampleSourceControl"; - NullableResponse response = await collection.GetIfExistsAsync(sourceControlName); - AutomationSourceControlResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sourceControlName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationSourceControlData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSourceControls() + public async Task GetIfExists_GetASourceControl() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/sourceControl/getAllSourceControls.json - // this example is just showing the usage of "SourceControl_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/sourceControl/getSourceControl.json + // this example is just showing the usage of "SourceControl_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,17 +189,23 @@ public async Task GetAll_ListSourceControls() // get the collection of this AutomationSourceControlResource AutomationSourceControlCollection collection = automationAccount.GetAutomationSourceControls(); - // invoke the operation and iterate over the result - await foreach (AutomationSourceControlResource item in collection.GetAllAsync()) + // invoke the operation + string sourceControlName = "sampleSourceControl"; + NullableResponse response = await collection.GetIfExistsAsync(sourceControlName); + AutomationSourceControlResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationSourceControlData resourceData = item.Data; + AutomationSourceControlData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationSourceControlResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationSourceControlResource.cs index 32fe070893aa2..0f226117b5a3a 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationSourceControlResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationSourceControlResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationSourceControlResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateASourceControl() + public async Task Get_GetASourceControl() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/sourceControl/updateSourceControl_patch.json - // this example is just showing the usage of "SourceControl_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/sourceControl/getSourceControl.json + // this example is just showing the usage of "SourceControl_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,20 +38,7 @@ public async Task Update_UpdateASourceControl() AutomationSourceControlResource automationSourceControl = client.GetAutomationSourceControlResource(automationSourceControlResourceId); // invoke the operation - AutomationSourceControlPatch patch = new AutomationSourceControlPatch() - { - Branch = "master", - FolderPath = "/folderOne/folderTwo", - IsAutoSyncEnabled = true, - IsAutoPublishRunbookEnabled = true, - SecurityToken = new SourceControlSecurityTokenProperties() - { - AccessToken = "3a326f7a0dcd343ea58fee21f2fd5fb4c1234567", - TokenType = SourceControlTokenType.PersonalAccessToken, - }, - Description = "my description", - }; - AutomationSourceControlResource result = await automationSourceControl.UpdateAsync(patch); + AutomationSourceControlResource result = await automationSourceControl.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +76,10 @@ public async Task Delete_DeleteASourceControl() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASourceControl() + public async Task Update_UpdateASourceControl() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/sourceControl/getSourceControl.json - // this example is just showing the usage of "SourceControl_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/sourceControl/updateSourceControl_patch.json + // this example is just showing the usage of "SourceControl_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,7 +96,20 @@ public async Task Get_GetASourceControl() AutomationSourceControlResource automationSourceControl = client.GetAutomationSourceControlResource(automationSourceControlResourceId); // invoke the operation - AutomationSourceControlResource result = await automationSourceControl.GetAsync(); + AutomationSourceControlPatch patch = new AutomationSourceControlPatch + { + Branch = "master", + FolderPath = "/folderOne/folderTwo", + IsAutoSyncEnabled = true, + IsAutoPublishRunbookEnabled = true, + SecurityToken = new SourceControlSecurityTokenProperties + { + AccessToken = "3a326f7a0dcd343ea58fee21f2fd5fb4c1234567", + TokenType = SourceControlTokenType.PersonalAccessToken, + }, + Description = "my description", + }; + AutomationSourceControlResource result = await automationSourceControl.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationVariableCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationVariableCollection.cs index 69138180c7967..ad229cf085e0f 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationVariableCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationVariableCollection.cs @@ -93,10 +93,10 @@ public async Task Get_GetAVariable() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAVariable() + public async Task GetAll_ListVariablesFirst100() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getVariable.json - // this example is just showing the usage of "Variable_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listVariables_First100.json + // this example is just showing the usage of "Variable_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,19 +114,25 @@ public async Task Exists_GetAVariable() // get the collection of this AutomationVariableResource AutomationVariableCollection collection = automationAccount.GetAutomationVariables(); - // invoke the operation - string variableName = "sampleVariable"; - bool result = await collection.ExistsAsync(variableName); + // invoke the operation and iterate over the result + await foreach (AutomationVariableResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationVariableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAVariable() + public async Task GetAll_ListVariablesNext100() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getVariable.json - // this example is just showing the usage of "Variable_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listVariables_Next100.json + // this example is just showing the usage of "Variable_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,31 +150,25 @@ public async Task GetIfExists_GetAVariable() // get the collection of this AutomationVariableResource AutomationVariableCollection collection = automationAccount.GetAutomationVariables(); - // invoke the operation - string variableName = "sampleVariable"; - NullableResponse response = await collection.GetIfExistsAsync(variableName); - AutomationVariableResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationVariableResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationVariableData resourceData = result.Data; + AutomationVariableData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVariablesFirst100() + public async Task Exists_GetAVariable() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listVariables_First100.json - // this example is just showing the usage of "Variable_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getVariable.json + // this example is just showing the usage of "Variable_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,25 +186,19 @@ public async Task GetAll_ListVariablesFirst100() // get the collection of this AutomationVariableResource AutomationVariableCollection collection = automationAccount.GetAutomationVariables(); - // invoke the operation and iterate over the result - await foreach (AutomationVariableResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationVariableData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string variableName = "sampleVariable"; + bool result = await collection.ExistsAsync(variableName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVariablesNext100() + public async Task GetIfExists_GetAVariable() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listVariables_Next100.json - // this example is just showing the usage of "Variable_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getVariable.json + // this example is just showing the usage of "Variable_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -222,17 +216,23 @@ public async Task GetAll_ListVariablesNext100() // get the collection of this AutomationVariableResource AutomationVariableCollection collection = automationAccount.GetAutomationVariables(); - // invoke the operation and iterate over the result - await foreach (AutomationVariableResource item in collection.GetAllAsync()) + // invoke the operation + string variableName = "sampleVariable"; + NullableResponse response = await collection.GetIfExistsAsync(variableName); + AutomationVariableResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationVariableData resourceData = item.Data; + AutomationVariableData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationVariableResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationVariableResource.cs index 793a78454a9cf..2e10369f9efbe 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationVariableResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationVariableResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationVariableResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAVariable() + public async Task Get_GetAVariable() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/updateVariable_patch.json - // this example is just showing the usage of "Variable_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getVariable.json + // this example is just showing the usage of "Variable_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,12 +38,7 @@ public async Task Update_UpdateAVariable() AutomationVariableResource automationVariable = client.GetAutomationVariableResource(automationVariableResourceId); // invoke the operation - AutomationVariablePatch patch = new AutomationVariablePatch() - { - Name = "sampleVariable", - Value = "\"ComputerName3.domain.com\"", - }; - AutomationVariableResource result = await automationVariable.UpdateAsync(patch); + AutomationVariableResource result = await automationVariable.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +76,10 @@ public async Task Delete_DeleteAVariable() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAVariable() + public async Task Update_UpdateAVariable() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getVariable.json - // this example is just showing the usage of "Variable_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/updateVariable_patch.json + // this example is just showing the usage of "Variable_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +96,12 @@ public async Task Get_GetAVariable() AutomationVariableResource automationVariable = client.GetAutomationVariableResource(automationVariableResourceId); // invoke the operation - AutomationVariableResource result = await automationVariable.GetAsync(); + AutomationVariablePatch patch = new AutomationVariablePatch + { + Name = "sampleVariable", + Value = "\"ComputerName3.domain.com\"", + }; + AutomationVariableResource result = await automationVariable.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWatcherCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWatcherCollection.cs index fdd9a2c5572db..dcaa00b5c2f39 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWatcherCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWatcherCollection.cs @@ -40,19 +40,15 @@ public async Task CreateOrUpdate_CreateOrUpdateWatcher() // invoke the operation string watcherName = "MyTestWatcher"; - AutomationWatcherData data = new AutomationWatcherData(null) + AutomationWatcherData data = new AutomationWatcherData(default) { - ETag = null, + ETag = default, ExecutionFrequencyInSeconds = 60L, ScriptName = "MyTestWatcherRunbook", - ScriptParameters = -{ -}, + ScriptParameters = { }, ScriptRunOn = "MyTestHybridWorkerGroup", Description = "This is a test watcher.", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, watcherName, data); AutomationWatcherResource result = lro.Value; @@ -100,10 +96,10 @@ public async Task Get_GetWatcher() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWatcher() + public async Task GetAll_ListWatchersByAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getWatcher.json - // this example is just showing the usage of "Watcher_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listWatchersByAutomationAccount.json + // this example is just showing the usage of "Watcher_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,16 +117,22 @@ public async Task Exists_GetWatcher() // get the collection of this AutomationWatcherResource AutomationWatcherCollection collection = automationAccount.GetAutomationWatchers(); - // invoke the operation - string watcherName = "MyTestWatcher"; - bool result = await collection.ExistsAsync(watcherName); + // invoke the operation and iterate over the result + await foreach (AutomationWatcherResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationWatcherData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWatcher() + public async Task Exists_GetWatcher() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getWatcher.json // this example is just showing the usage of "Watcher_Get" operation, for the dependent resources, they will have to be created separately. @@ -153,29 +155,17 @@ public async Task GetIfExists_GetWatcher() // invoke the operation string watcherName = "MyTestWatcher"; - NullableResponse response = await collection.GetIfExistsAsync(watcherName); - AutomationWatcherResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(watcherName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationWatcherData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWatchersByAutomationAccount() + public async Task GetIfExists_GetWatcher() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listWatchersByAutomationAccount.json - // this example is just showing the usage of "Watcher_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getWatcher.json + // this example is just showing the usage of "Watcher_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +183,23 @@ public async Task GetAll_ListWatchersByAutomationAccount() // get the collection of this AutomationWatcherResource AutomationWatcherCollection collection = automationAccount.GetAutomationWatchers(); - // invoke the operation and iterate over the result - await foreach (AutomationWatcherResource item in collection.GetAllAsync()) + // invoke the operation + string watcherName = "MyTestWatcher"; + NullableResponse response = await collection.GetIfExistsAsync(watcherName); + AutomationWatcherResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationWatcherData resourceData = item.Data; + AutomationWatcherData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWatcherResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWatcherResource.cs index ef6e76a922961..86ac023196ea0 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWatcherResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWatcherResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetWatcher() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateWatcher() + public async Task Delete_DeleteWatcher() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/updateWatcher.json - // this example is just showing the usage of "Watcher_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteWatcher.json + // this example is just showing the usage of "Watcher_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_UpdateWatcher() AutomationWatcherResource automationWatcher = client.GetAutomationWatcherResource(automationWatcherResourceId); // invoke the operation - AutomationWatcherPatch patch = new AutomationWatcherPatch() - { - Name = "MyTestWatcher", - ExecutionFrequencyInSeconds = 600L, - }; - AutomationWatcherResource result = await automationWatcher.UpdateAsync(patch); + await automationWatcher.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationWatcherData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWatcher() + public async Task Update_UpdateWatcher() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteWatcher.json - // this example is just showing the usage of "Watcher_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/updateWatcher.json + // this example is just showing the usage of "Watcher_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeleteWatcher() AutomationWatcherResource automationWatcher = client.GetAutomationWatcherResource(automationWatcherResourceId); // invoke the operation - await automationWatcher.DeleteAsync(WaitUntil.Completed); + AutomationWatcherPatch patch = new AutomationWatcherPatch + { + Name = "MyTestWatcher", + ExecutionFrequencyInSeconds = 600L, + }; + AutomationWatcherResource result = await automationWatcher.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationWatcherData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWebhookCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWebhookCollection.cs index 7af3eb6f9df1b..20e00ab222c0b 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWebhookCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWebhookCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationWebhookCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWebhook() + public async Task CreateOrUpdate_CreateOrUpdateWebhook() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/getWebhook.json - // this example is just showing the usage of "Webhook_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/createOrUpdateWebhook.json + // this example is just showing the usage of "Webhook_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_GetWebhook() // invoke the operation string webhookName = "TestWebhook"; - AutomationWebhookResource result = await collection.GetAsync(webhookName); + AutomationWebhookCreateOrUpdateContent content = new AutomationWebhookCreateOrUpdateContent("TestWebhook") + { + IsEnabled = true, + Uri = new Uri(""), + ExpireOn = DateTimeOffset.Parse("2018-03-29T22:18:13.7002872Z"), + RunbookName = "TestRunbook", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, webhookName, content); + AutomationWebhookResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_GetWebhook() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWebhook() + public async Task Get_GetWebhook() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/getWebhook.json // this example is just showing the usage of "Webhook_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +83,21 @@ public async Task Exists_GetWebhook() // invoke the operation string webhookName = "TestWebhook"; - bool result = await collection.ExistsAsync(webhookName); + AutomationWebhookResource result = await collection.GetAsync(webhookName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationWebhookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWebhook() + public async Task GetAll_ListWebhooksByAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/getWebhook.json - // this example is just showing the usage of "Webhook_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/listWebhooksByAutomationAccount.json + // this example is just showing the usage of "Webhook_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +115,25 @@ public async Task GetIfExists_GetWebhook() // get the collection of this AutomationWebhookResource AutomationWebhookCollection collection = automationAccount.GetAutomationWebhooks(); - // invoke the operation - string webhookName = "TestWebhook"; - NullableResponse response = await collection.GetIfExistsAsync(webhookName); - AutomationWebhookResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AutomationWebhookResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationWebhookData resourceData = result.Data; + AutomationWebhookData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWebhook() + public async Task Exists_GetWebhook() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/createOrUpdateWebhook.json - // this example is just showing the usage of "Webhook_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/getWebhook.json + // this example is just showing the usage of "Webhook_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,29 +153,17 @@ public async Task CreateOrUpdate_CreateOrUpdateWebhook() // invoke the operation string webhookName = "TestWebhook"; - AutomationWebhookCreateOrUpdateContent content = new AutomationWebhookCreateOrUpdateContent("TestWebhook") - { - IsEnabled = true, - Uri = new Uri(""), - ExpireOn = DateTimeOffset.Parse("2018-03-29T22:18:13.7002872Z"), - RunbookName = "TestRunbook", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, webhookName, content); - AutomationWebhookResource result = lro.Value; + bool result = await collection.ExistsAsync(webhookName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationWebhookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWebhooksByAutomationAccount() + public async Task GetIfExists_GetWebhook() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/listWebhooksByAutomationAccount.json - // this example is just showing the usage of "Webhook_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/getWebhook.json + // this example is just showing the usage of "Webhook_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +181,23 @@ public async Task GetAll_ListWebhooksByAutomationAccount() // get the collection of this AutomationWebhookResource AutomationWebhookCollection collection = automationAccount.GetAutomationWebhooks(); - // invoke the operation and iterate over the result - await foreach (AutomationWebhookResource item in collection.GetAllAsync()) + // invoke the operation + string webhookName = "TestWebhook"; + NullableResponse response = await collection.GetIfExistsAsync(webhookName); + AutomationWebhookResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AutomationWebhookData resourceData = item.Data; + AutomationWebhookData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWebhookResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWebhookResource.cs index 95f9f013e7909..73eafa77392c1 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWebhookResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_AutomationWebhookResource.cs @@ -18,10 +18,10 @@ public partial class Sample_AutomationWebhookResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWebhook() + public async Task Get_GetWebhook() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/deleteWebhook.json - // this example is just showing the usage of "Webhook_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/getWebhook.json + // this example is just showing the usage of "Webhook_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteWebhook() AutomationWebhookResource automationWebhook = client.GetAutomationWebhookResource(automationWebhookResourceId); // invoke the operation - await automationWebhook.DeleteAsync(WaitUntil.Completed); + AutomationWebhookResource result = await automationWebhook.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationWebhookData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWebhook() + public async Task Delete_DeleteWebhook() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/getWebhook.json - // this example is just showing the usage of "Webhook_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2015-10-31/examples/deleteWebhook.json + // this example is just showing the usage of "Webhook_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetWebhook() AutomationWebhookResource automationWebhook = client.GetAutomationWebhookResource(automationWebhookResourceId); // invoke the operation - AutomationWebhookResource result = await automationWebhook.GetAsync(); + await automationWebhook.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutomationWebhookData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_UpdateWebhook() AutomationWebhookResource automationWebhook = client.GetAutomationWebhookResource(automationWebhookResourceId); // invoke the operation - AutomationWebhookPatch patch = new AutomationWebhookPatch() + AutomationWebhookPatch patch = new AutomationWebhookPatch { Name = "TestWebhook", IsEnabled = false, diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscCompilationJobCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscCompilationJobCollection.cs index a22e87be017a9..e1919ece84000 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscCompilationJobCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscCompilationJobCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_CreateOrUpdateADSCCompilationJob() // invoke the operation string compilationJobName = "TestCompilationJob"; - DscCompilationJobCreateOrUpdateContent content = new DscCompilationJobCreateOrUpdateContent(new DscConfigurationAssociationProperty() + DscCompilationJobCreateOrUpdateContent content = new DscCompilationJobCreateOrUpdateContent(new DscConfigurationAssociationProperty { ConfigurationName = "SetupServer", }); @@ -91,10 +91,10 @@ public async Task Get_GetADSCCompilationJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADSCCompilationJob() + public async Task GetAll_ListDSCCompilationJobInAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCompilationJob.json - // this example is just showing the usage of "DscCompilationJob_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listCompilationJobsByAutomationAccount.json + // this example is just showing the usage of "DscCompilationJob_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_GetADSCCompilationJob() // get the collection of this DscCompilationJobResource DscCompilationJobCollection collection = automationAccount.GetDscCompilationJobs(); - // invoke the operation - string compilationJobName = "TestCompilationJob"; - bool result = await collection.ExistsAsync(compilationJobName); + // invoke the operation and iterate over the result + await foreach (DscCompilationJobResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscCompilationJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADSCCompilationJob() + public async Task Exists_GetADSCCompilationJob() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCompilationJob.json // this example is just showing the usage of "DscCompilationJob_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_GetADSCCompilationJob() // invoke the operation string compilationJobName = "TestCompilationJob"; - NullableResponse response = await collection.GetIfExistsAsync(compilationJobName); - DscCompilationJobResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(compilationJobName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscCompilationJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDSCCompilationJobInAutomationAccount() + public async Task GetIfExists_GetADSCCompilationJob() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listCompilationJobsByAutomationAccount.json - // this example is just showing the usage of "DscCompilationJob_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCompilationJob.json + // this example is just showing the usage of "DscCompilationJob_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListDSCCompilationJobInAutomationAccount() // get the collection of this DscCompilationJobResource DscCompilationJobCollection collection = automationAccount.GetDscCompilationJobs(); - // invoke the operation and iterate over the result - await foreach (DscCompilationJobResource item in collection.GetAllAsync()) + // invoke the operation + string compilationJobName = "TestCompilationJob"; + NullableResponse response = await collection.GetIfExistsAsync(compilationJobName); + DscCompilationJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DscCompilationJobData resourceData = item.Data; + DscCompilationJobData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscCompilationJobResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscCompilationJobResource.cs index faa7c7e045cb8..ec79f087afa27 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscCompilationJobResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscCompilationJobResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DscCompilationJobResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateADSCCompilationJob() + public async Task Get_GetADSCCompilationJob() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createCompilationJob.json - // this example is just showing the usage of "DscCompilationJob_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCompilationJob.json + // this example is just showing the usage of "DscCompilationJob_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,12 +38,7 @@ public async Task Update_CreateOrUpdateADSCCompilationJob() DscCompilationJobResource dscCompilationJob = client.GetDscCompilationJobResource(dscCompilationJobResourceId); // invoke the operation - DscCompilationJobCreateOrUpdateContent content = new DscCompilationJobCreateOrUpdateContent(new DscConfigurationAssociationProperty() - { - ConfigurationName = "SetupServer", - }); - ArmOperation lro = await dscCompilationJob.UpdateAsync(WaitUntil.Completed, content); - DscCompilationJobResource result = lro.Value; + DscCompilationJobResource result = await dscCompilationJob.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +49,10 @@ public async Task Update_CreateOrUpdateADSCCompilationJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADSCCompilationJob() + public async Task Update_CreateOrUpdateADSCCompilationJob() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getCompilationJob.json - // this example is just showing the usage of "DscCompilationJob_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createCompilationJob.json + // this example is just showing the usage of "DscCompilationJob_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,7 +69,12 @@ public async Task Get_GetADSCCompilationJob() DscCompilationJobResource dscCompilationJob = client.GetDscCompilationJobResource(dscCompilationJobResourceId); // invoke the operation - DscCompilationJobResource result = await dscCompilationJob.GetAsync(); + DscCompilationJobCreateOrUpdateContent content = new DscCompilationJobCreateOrUpdateContent(new DscConfigurationAssociationProperty + { + ConfigurationName = "SetupServer", + }); + ArmOperation lro = await dscCompilationJob.UpdateAsync(WaitUntil.Completed, content); + DscCompilationJobResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscConfigurationCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscConfigurationCollection.cs index 463cb59562903..25f0c06408fe5 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscConfigurationCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DscConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADSCConfiguration() + public async Task CreateOrUpdate_CreateOrUpdateConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getDscConfiguration.json - // this example is just showing the usage of "DscConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/createOrUpdateDscConfiguration.json + // this example is just showing the usage of "DscConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task Get_GetADSCConfiguration() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount33"; + string automationAccountName = "myAutomationAccount18"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); @@ -40,8 +40,20 @@ public async Task Get_GetADSCConfiguration() DscConfigurationCollection collection = automationAccount.GetDscConfigurations(); // invoke the operation - string configurationName = "TemplateBasic"; - DscConfigurationResource result = await collection.GetAsync(configurationName); + string configurationName = "SetupServer"; + DscConfigurationCreateOrUpdateContent content = new DscConfigurationCreateOrUpdateContent(new AutomationContentSource + { + Hash = new AutomationContentHash("sha256", "A9E5DB56BA21513F61E0B3868816FDC6D4DF5131F5617D7FF0D769674BD5072F"), + SourceType = AutomationContentSourceType.EmbeddedContent, + Value = "Configuration SetupServer {\r\n Node localhost {\r\n WindowsFeature IIS {\r\n Name = \"Web-Server\";\r\n Ensure = \"Present\"\r\n }\r\n }\r\n}", + }) + { + Name = "SetupServer", + Location = new AzureLocation("East US 2"), + Description = "sample configuration", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, content); + DscConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +64,7 @@ public async Task Get_GetADSCConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADSCConfiguration() + public async Task Get_GetADSCConfiguration() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getDscConfiguration.json // this example is just showing the usage of "DscConfiguration_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +87,21 @@ public async Task Exists_GetADSCConfiguration() // invoke the operation string configurationName = "TemplateBasic"; - bool result = await collection.ExistsAsync(configurationName); + DscConfigurationResource result = await collection.GetAsync(configurationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADSCConfiguration() + public async Task GetAll_GetDSCConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getDscConfiguration.json - // this example is just showing the usage of "DscConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getAllDscConfigurations.json + // this example is just showing the usage of "DscConfiguration_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +119,25 @@ public async Task GetIfExists_GetADSCConfiguration() // get the collection of this DscConfigurationResource DscConfigurationCollection collection = automationAccount.GetDscConfigurations(); - // invoke the operation - string configurationName = "TemplateBasic"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - DscConfigurationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DscConfigurationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DscConfigurationData resourceData = result.Data; + DscConfigurationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateConfiguration() + public async Task GetAll_ListPagedDSCConfigurationsWithNameFilter() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/createOrUpdateDscConfiguration.json - // this example is just showing the usage of "DscConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getPagedlDscConfigurationsWithNameFilter.json + // this example is just showing the usage of "DscConfiguration_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,41 +148,35 @@ public async Task CreateOrUpdate_CreateOrUpdateConfiguration() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount18"; + string automationAccountName = "myAutomationAccount33"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // get the collection of this DscConfigurationResource DscConfigurationCollection collection = automationAccount.GetDscConfigurations(); - // invoke the operation - string configurationName = "SetupServer"; - DscConfigurationCreateOrUpdateContent content = new DscConfigurationCreateOrUpdateContent(new AutomationContentSource() - { - Hash = new AutomationContentHash("sha256", "A9E5DB56BA21513F61E0B3868816FDC6D4DF5131F5617D7FF0D769674BD5072F"), - SourceType = AutomationContentSourceType.EmbeddedContent, - Value = "Configuration SetupServer {\r\n Node localhost {\r\n WindowsFeature IIS {\r\n Name = \"Web-Server\";\r\n Ensure = \"Present\"\r\n }\r\n }\r\n}", - }) + // invoke the operation and iterate over the result + string filter = "contains(name,'server')"; + int? skip = 0; + int? top = 2; + string inlinecount = "allpages"; + await foreach (DscConfigurationResource item in collection.GetAllAsync(filter: filter, skip: skip, top: top, inlinecount: inlinecount)) { - Name = "SetupServer", - Location = new AzureLocation("East US 2"), - Description = "sample configuration", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, content); - DscConfigurationResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetDSCConfiguration() + public async Task GetAll_ListPagedDSCConfigurationsWithNoFilter() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getAllDscConfigurations.json + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getPagedDscConfigurationsWithNoFilter.json // this example is just showing the usage of "DscConfiguration_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -192,7 +196,10 @@ public async Task GetAll_GetDSCConfiguration() DscConfigurationCollection collection = automationAccount.GetDscConfigurations(); // invoke the operation and iterate over the result - await foreach (DscConfigurationResource item in collection.GetAllAsync()) + int? skip = 0; + int? top = 3; + string inlinecount = "allpages"; + await foreach (DscConfigurationResource item in collection.GetAllAsync(skip: skip, top: top, inlinecount: inlinecount)) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -206,10 +213,10 @@ public async Task GetAll_GetDSCConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPagedDSCConfigurationsWithNameFilter() + public async Task Exists_GetADSCConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getPagedlDscConfigurationsWithNameFilter.json - // this example is just showing the usage of "DscConfiguration_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getDscConfiguration.json + // this example is just showing the usage of "DscConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -227,29 +234,19 @@ public async Task GetAll_ListPagedDSCConfigurationsWithNameFilter() // get the collection of this DscConfigurationResource DscConfigurationCollection collection = automationAccount.GetDscConfigurations(); - // invoke the operation and iterate over the result - string filter = "contains(name,'server')"; - int? skip = 0; - int? top = 2; - string inlinecount = "allpages"; - await foreach (DscConfigurationResource item in collection.GetAllAsync(filter: filter, skip: skip, top: top, inlinecount: inlinecount)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string configurationName = "TemplateBasic"; + bool result = await collection.ExistsAsync(configurationName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPagedDSCConfigurationsWithNoFilter() + public async Task GetIfExists_GetADSCConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getPagedDscConfigurationsWithNoFilter.json - // this example is just showing the usage of "DscConfiguration_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getDscConfiguration.json + // this example is just showing the usage of "DscConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -267,20 +264,23 @@ public async Task GetAll_ListPagedDSCConfigurationsWithNoFilter() // get the collection of this DscConfigurationResource DscConfigurationCollection collection = automationAccount.GetDscConfigurations(); - // invoke the operation and iterate over the result - int? skip = 0; - int? top = 3; - string inlinecount = "allpages"; - await foreach (DscConfigurationResource item in collection.GetAllAsync(skip: skip, top: top, inlinecount: inlinecount)) + // invoke the operation + string configurationName = "TemplateBasic"; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + DscConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DscConfigurationData resourceData = item.Data; + DscConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscConfigurationResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscConfigurationResource.cs index cbd08a965de98..a87b93b012cae 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscConfigurationResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscConfigurationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DscConfigurationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDSCConfiguration() + public async Task Get_GetADSCConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/deleteDscConfiguration.json - // this example is just showing the usage of "DscConfiguration_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getDscConfiguration.json + // this example is just showing the usage of "DscConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteDSCConfiguration() DscConfigurationResource dscConfiguration = client.GetDscConfigurationResource(dscConfigurationResourceId); // invoke the operation - await dscConfiguration.DeleteAsync(WaitUntil.Completed); + DscConfigurationResource result = await dscConfiguration.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADSCConfiguration() + public async Task Delete_DeleteDSCConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/getDscConfiguration.json - // this example is just showing the usage of "DscConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/deleteDscConfiguration.json + // this example is just showing the usage of "DscConfiguration_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetADSCConfiguration() DscConfigurationResource dscConfiguration = client.GetDscConfigurationResource(dscConfigurationResourceId); // invoke the operation - DscConfigurationResource result = await dscConfiguration.GetAsync(); + await dscConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_CreateOrUpdateConfiguration() DscConfigurationResource dscConfiguration = client.GetDscConfigurationResource(dscConfigurationResourceId); // invoke the operation - DscConfigurationPatch patch = new DscConfigurationPatch() + DscConfigurationPatch patch = new DscConfigurationPatch { Name = "SetupServer", Tags = { -["Hello"] = "World", +["Hello"] = "World" }, }; DscConfigurationResource result = await dscConfiguration.UpdateAsync(patch); diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeCollection.cs index d11df0e7bcec0..9ebde512c9b68 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeCollection.cs @@ -49,78 +49,6 @@ public async Task Get_GetANode() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetANode() - { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNode.json - // this example is just showing the usage of "DscNode_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AutomationAccountResource created on azure - // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource - string subscriptionId = "subid"; - string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount33"; - ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); - AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); - - // get the collection of this DscNodeResource - DscNodeCollection collection = automationAccount.GetDscNodes(); - - // invoke the operation - string nodeId = "nodeId"; - bool result = await collection.ExistsAsync(nodeId); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetANode() - { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNode.json - // this example is just showing the usage of "DscNode_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AutomationAccountResource created on azure - // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource - string subscriptionId = "subid"; - string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount33"; - ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); - AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); - - // get the collection of this DscNodeResource - DscNodeCollection collection = automationAccount.GetDscNodes(); - - // invoke the operation - string nodeId = "nodeId"; - NullableResponse response = await collection.GetIfExistsAsync(nodeId); - DscNodeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscNodeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListDSCNodesByAutomationAccount() @@ -435,5 +363,77 @@ public async Task GetAll_ListPagedDSCNodesWithFiltersSeparatedByAnd() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetANode() + { + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNode.json + // this example is just showing the usage of "DscNode_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AutomationAccountResource created on azure + // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource + string subscriptionId = "subid"; + string resourceGroupName = "rg"; + string automationAccountName = "myAutomationAccount33"; + ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); + AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); + + // get the collection of this DscNodeResource + DscNodeCollection collection = automationAccount.GetDscNodes(); + + // invoke the operation + string nodeId = "nodeId"; + bool result = await collection.ExistsAsync(nodeId); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetANode() + { + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNode.json + // this example is just showing the usage of "DscNode_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AutomationAccountResource created on azure + // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource + string subscriptionId = "subid"; + string resourceGroupName = "rg"; + string automationAccountName = "myAutomationAccount33"; + ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); + AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); + + // get the collection of this DscNodeResource + DscNodeCollection collection = automationAccount.GetDscNodes(); + + // invoke the operation + string nodeId = "nodeId"; + NullableResponse response = await collection.GetIfExistsAsync(nodeId); + DscNodeResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscNodeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeConfigurationCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeConfigurationCollection.cs index 170f6a5de6143..9986bf8a99060 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeConfigurationCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DscNodeConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADSCNodeConfiguration() + public async Task CreateOrUpdate_CreateNodeConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNodeConfiguration.json - // this example is just showing the usage of "DscNodeConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateDscNodeConfiguration.json + // this example is just showing the usage of "DscNodeConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task Get_GetADSCNodeConfiguration() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount33"; + string automationAccountName = "myAutomationAccount20"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); @@ -40,19 +40,28 @@ public async Task Get_GetADSCNodeConfiguration() DscNodeConfigurationCollection collection = automationAccount.GetDscNodeConfigurations(); // invoke the operation - string nodeConfigurationName = "SetupServer.localhost"; - DscNodeConfigurationResource result = await collection.GetAsync(nodeConfigurationName); + string nodeConfigurationName = "configName.nodeConfigName"; + DscNodeConfigurationCreateOrUpdateContent content = new DscNodeConfigurationCreateOrUpdateContent + { + Name = "configName.nodeConfigName", + Source = new AutomationContentSource + { + Hash = new AutomationContentHash("sha256", "6DE256A57F01BFA29B88696D5E77A383D6E61484C7686E8DB955FA10ACE9FFE5"), + SourceType = AutomationContentSourceType.EmbeddedContent, + Value = "\r\ninstance of MSFT_RoleResource as $MSFT_RoleResource1ref\r\n{\r\nResourceID = \"[WindowsFeature]IIS\";\r\n Ensure = \"Present\";\r\n SourceInfo = \"::3::32::WindowsFeature\";\r\n Name = \"Web-Server\";\r\n ModuleName = \"PsDesiredStateConfiguration\";\r\n\r\nModuleVersion = \"1.0\";\r\r\n ConfigurationName = \"configName\";\r\r\n};\r\ninstance of OMI_ConfigurationDocument\r\n\r\r\n {\r\n Version=\"2.0.0\";\r\n \r\r\n MinimumCompatibleVersion = \"1.0.0\";\r\n \r\r\n CompatibleVersionAdditionalProperties= {\"Omi_BaseResource:ConfigurationName\"};\r\n \r\r\n Author=\"weijiel\";\r\n \r\r\n GenerationDate=\"03/30/2017 13:40:25\";\r\n \r\r\n GenerationHost=\"TEST-BACKEND\";\r\n \r\r\n Name=\"configName\";\r\n\r\r\n };\r\n", + Version = "1.0", + }, + ConfigurationName = "configName", + IsIncrementNodeConfigurationBuildRequired = true, + }; + await collection.CreateOrUpdateAsync(WaitUntil.Completed, nodeConfigurationName, content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscNodeConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADSCNodeConfiguration() + public async Task Get_GetADSCNodeConfiguration() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNodeConfiguration.json // this example is just showing the usage of "DscNodeConfiguration_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +84,21 @@ public async Task Exists_GetADSCNodeConfiguration() // invoke the operation string nodeConfigurationName = "SetupServer.localhost"; - bool result = await collection.ExistsAsync(nodeConfigurationName); + DscNodeConfigurationResource result = await collection.GetAsync(nodeConfigurationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscNodeConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADSCNodeConfiguration() + public async Task GetAll_ListDSCNodeConfigurationsByAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNodeConfiguration.json - // this example is just showing the usage of "DscNodeConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listDscNodeConfigurations.json + // this example is just showing the usage of "DscNodeConfiguration_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +116,25 @@ public async Task GetIfExists_GetADSCNodeConfiguration() // get the collection of this DscNodeConfigurationResource DscNodeConfigurationCollection collection = automationAccount.GetDscNodeConfigurations(); - // invoke the operation - string nodeConfigurationName = "SetupServer.localhost"; - NullableResponse response = await collection.GetIfExistsAsync(nodeConfigurationName); - DscNodeConfigurationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DscNodeConfigurationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DscNodeConfigurationData resourceData = result.Data; + DscNodeConfigurationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNodeConfiguration() + public async Task GetAll_ListPagedDSCNodeConfigurationsByAutomationAccountWithNameFilter() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/createOrUpdateDscNodeConfiguration.json - // this example is just showing the usage of "DscNodeConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listPagedDscNodeConfigurationsWithNameFilter.json + // this example is just showing the usage of "DscNodeConfiguration_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,38 +145,35 @@ public async Task CreateOrUpdate_CreateNodeConfiguration() // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount20"; + string automationAccountName = "myAutomationAccount33"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); AutomationAccountResource automationAccount = client.GetAutomationAccountResource(automationAccountResourceId); // get the collection of this DscNodeConfigurationResource DscNodeConfigurationCollection collection = automationAccount.GetDscNodeConfigurations(); - // invoke the operation - string nodeConfigurationName = "configName.nodeConfigName"; - DscNodeConfigurationCreateOrUpdateContent content = new DscNodeConfigurationCreateOrUpdateContent() + // invoke the operation and iterate over the result + string filter = "contains('.localhost',name)"; + int? skip = 0; + int? top = 2; + string inlinecount = "allpages"; + await foreach (DscNodeConfigurationResource item in collection.GetAllAsync(filter: filter, skip: skip, top: top, inlinecount: inlinecount)) { - Name = "configName.nodeConfigName", - Source = new AutomationContentSource() - { - Hash = new AutomationContentHash("sha256", "6DE256A57F01BFA29B88696D5E77A383D6E61484C7686E8DB955FA10ACE9FFE5"), - SourceType = AutomationContentSourceType.EmbeddedContent, - Value = "\r\ninstance of MSFT_RoleResource as $MSFT_RoleResource1ref\r\n{\r\nResourceID = \"[WindowsFeature]IIS\";\r\n Ensure = \"Present\";\r\n SourceInfo = \"::3::32::WindowsFeature\";\r\n Name = \"Web-Server\";\r\n ModuleName = \"PsDesiredStateConfiguration\";\r\n\r\nModuleVersion = \"1.0\";\r\r\n ConfigurationName = \"configName\";\r\r\n};\r\ninstance of OMI_ConfigurationDocument\r\n\r\r\n {\r\n Version=\"2.0.0\";\r\n \r\r\n MinimumCompatibleVersion = \"1.0.0\";\r\n \r\r\n CompatibleVersionAdditionalProperties= {\"Omi_BaseResource:ConfigurationName\"};\r\n \r\r\n Author=\"weijiel\";\r\n \r\r\n GenerationDate=\"03/30/2017 13:40:25\";\r\n \r\r\n GenerationHost=\"TEST-BACKEND\";\r\n \r\r\n Name=\"configName\";\r\n\r\r\n };\r\n", - Version = "1.0", - }, - ConfigurationName = "configName", - IsIncrementNodeConfigurationBuildRequired = true, - }; - await collection.CreateOrUpdateAsync(WaitUntil.Completed, nodeConfigurationName, content); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscNodeConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDSCNodeConfigurationsByAutomationAccount() + public async Task GetAll_ListPagedDSCNodeConfigurationsByAutomationAccountWithNoFilter() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listDscNodeConfigurations.json + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listPagedDscNodeConfigurationsWithNoFilter.json // this example is just showing the usage of "DscNodeConfiguration_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -189,7 +193,10 @@ public async Task GetAll_ListDSCNodeConfigurationsByAutomationAccount() DscNodeConfigurationCollection collection = automationAccount.GetDscNodeConfigurations(); // invoke the operation and iterate over the result - await foreach (DscNodeConfigurationResource item in collection.GetAllAsync()) + int? skip = 0; + int? top = 4; + string inlinecount = "allpages"; + await foreach (DscNodeConfigurationResource item in collection.GetAllAsync(skip: skip, top: top, inlinecount: inlinecount)) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -203,10 +210,10 @@ public async Task GetAll_ListDSCNodeConfigurationsByAutomationAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPagedDSCNodeConfigurationsByAutomationAccountWithNameFilter() + public async Task Exists_GetADSCNodeConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listPagedDscNodeConfigurationsWithNameFilter.json - // this example is just showing the usage of "DscNodeConfiguration_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNodeConfiguration.json + // this example is just showing the usage of "DscNodeConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -224,29 +231,19 @@ public async Task GetAll_ListPagedDSCNodeConfigurationsByAutomationAccountWithNa // get the collection of this DscNodeConfigurationResource DscNodeConfigurationCollection collection = automationAccount.GetDscNodeConfigurations(); - // invoke the operation and iterate over the result - string filter = "contains('.localhost',name)"; - int? skip = 0; - int? top = 2; - string inlinecount = "allpages"; - await foreach (DscNodeConfigurationResource item in collection.GetAllAsync(filter: filter, skip: skip, top: top, inlinecount: inlinecount)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscNodeConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string nodeConfigurationName = "SetupServer.localhost"; + bool result = await collection.ExistsAsync(nodeConfigurationName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPagedDSCNodeConfigurationsByAutomationAccountWithNoFilter() + public async Task GetIfExists_GetADSCNodeConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/listPagedDscNodeConfigurationsWithNoFilter.json - // this example is just showing the usage of "DscNodeConfiguration_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNodeConfiguration.json + // this example is just showing the usage of "DscNodeConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -264,20 +261,23 @@ public async Task GetAll_ListPagedDSCNodeConfigurationsByAutomationAccountWithNo // get the collection of this DscNodeConfigurationResource DscNodeConfigurationCollection collection = automationAccount.GetDscNodeConfigurations(); - // invoke the operation and iterate over the result - int? skip = 0; - int? top = 4; - string inlinecount = "allpages"; - await foreach (DscNodeConfigurationResource item in collection.GetAllAsync(skip: skip, top: top, inlinecount: inlinecount)) + // invoke the operation + string nodeConfigurationName = "SetupServer.localhost"; + NullableResponse response = await collection.GetIfExistsAsync(nodeConfigurationName); + DscNodeConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DscNodeConfigurationData resourceData = item.Data; + DscNodeConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeConfigurationResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeConfigurationResource.cs index 71026523d1a2f..a4e1c3fe934ef 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeConfigurationResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeConfigurationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DscNodeConfigurationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteADSCNodeConfiguration() + public async Task Get_GetADSCNodeConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteDscNodeConfiguration.json - // this example is just showing the usage of "DscNodeConfiguration_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNodeConfiguration.json + // this example is just showing the usage of "DscNodeConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,23 +32,27 @@ public async Task Delete_DeleteADSCNodeConfiguration() // for more information of creating DscNodeConfigurationResource, please refer to the document of DscNodeConfigurationResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount20"; - string nodeConfigurationName = "configName.nodeConfigName"; + string automationAccountName = "myAutomationAccount33"; + string nodeConfigurationName = "SetupServer.localhost"; ResourceIdentifier dscNodeConfigurationResourceId = DscNodeConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, nodeConfigurationName); DscNodeConfigurationResource dscNodeConfiguration = client.GetDscNodeConfigurationResource(dscNodeConfigurationResourceId); // invoke the operation - await dscNodeConfiguration.DeleteAsync(WaitUntil.Completed); + DscNodeConfigurationResource result = await dscNodeConfiguration.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscNodeConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADSCNodeConfiguration() + public async Task Delete_DeleteADSCNodeConfiguration() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNodeConfiguration.json - // this example is just showing the usage of "DscNodeConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteDscNodeConfiguration.json + // this example is just showing the usage of "DscNodeConfiguration_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,19 +63,15 @@ public async Task Get_GetADSCNodeConfiguration() // for more information of creating DscNodeConfigurationResource, please refer to the document of DscNodeConfigurationResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount33"; - string nodeConfigurationName = "SetupServer.localhost"; + string automationAccountName = "myAutomationAccount20"; + string nodeConfigurationName = "configName.nodeConfigName"; ResourceIdentifier dscNodeConfigurationResourceId = DscNodeConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, nodeConfigurationName); DscNodeConfigurationResource dscNodeConfiguration = client.GetDscNodeConfigurationResource(dscNodeConfigurationResourceId); // invoke the operation - DscNodeConfigurationResource result = await dscNodeConfiguration.GetAsync(); + await dscNodeConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscNodeConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,10 +96,10 @@ public async Task Update_CreateNodeConfiguration() DscNodeConfigurationResource dscNodeConfiguration = client.GetDscNodeConfigurationResource(dscNodeConfigurationResourceId); // invoke the operation - DscNodeConfigurationCreateOrUpdateContent content = new DscNodeConfigurationCreateOrUpdateContent() + DscNodeConfigurationCreateOrUpdateContent content = new DscNodeConfigurationCreateOrUpdateContent { Name = "configName.nodeConfigName", - Source = new AutomationContentSource() + Source = new AutomationContentSource { Hash = new AutomationContentHash("sha256", "6DE256A57F01BFA29B88696D5E77A383D6E61484C7686E8DB955FA10ACE9FFE5"), SourceType = AutomationContentSourceType.EmbeddedContent, diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeResource.cs index 4a6a861d0d4e0..cb0d2a62b15db 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_DscNodeResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DscNodeResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteADSCNode() + public async Task Get_GetANode() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteDscNode.json - // this example is just showing the usage of "DscNode_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNode.json + // this example is just showing the usage of "DscNode_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,23 +32,27 @@ public async Task Delete_DeleteADSCNode() // for more information of creating DscNodeResource, please refer to the document of DscNodeResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount9"; - string nodeId = "e1243a76-a9bd-432f-bde3-ad8f317ee786"; + string automationAccountName = "myAutomationAccount33"; + string nodeId = "nodeId"; ResourceIdentifier dscNodeResourceId = DscNodeResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, nodeId); DscNodeResource dscNode = client.GetDscNodeResource(dscNodeResourceId); // invoke the operation - await dscNode.DeleteAsync(WaitUntil.Completed); + DscNodeResource result = await dscNode.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscNodeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetANode() + public async Task Delete_DeleteADSCNode() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/getDscNode.json - // this example is just showing the usage of "DscNode_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/preview/2020-01-13-preview/examples/deleteDscNode.json + // this example is just showing the usage of "DscNode_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,19 +63,15 @@ public async Task Get_GetANode() // for more information of creating DscNodeResource, please refer to the document of DscNodeResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount33"; - string nodeId = "nodeId"; + string automationAccountName = "myAutomationAccount9"; + string nodeId = "e1243a76-a9bd-432f-bde3-ad8f317ee786"; ResourceIdentifier dscNodeResourceId = DscNodeResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, nodeId); DscNodeResource dscNode = client.GetDscNodeResource(dscNodeResourceId); // invoke the operation - DscNodeResource result = await dscNode.GetAsync(); + await dscNode.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscNodeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_UpdateANode() DscNodeResource dscNode = client.GetDscNodeResource(dscNodeResourceId); // invoke the operation - DscNodePatch patch = new DscNodePatch() + DscNodePatch patch = new DscNodePatch { NodeId = "nodeId", DscNodeUpdateParametersName = "SetupServer.localhost", diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerCollection.cs index 7a29b20eef475..2f081053d6d81 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HybridRunbookWorkerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAV2HybridRunbookWorker() + public async Task CreateOrUpdate_CreateAV2HybridRunbookWorker() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getHybridRunbookWorker.json - // this example is just showing the usage of "HybridRunbookWorkers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/putHybridRunbookWorker.json + // this example is just showing the usage of "HybridRunbookWorkers_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,12 @@ public async Task Get_GetAV2HybridRunbookWorker() // invoke the operation string hybridRunbookWorkerId = "c010ad12-ef14-4a2a-aa9e-ef22c4745ddd"; - HybridRunbookWorkerResource result = await collection.GetAsync(hybridRunbookWorkerId); + HybridRunbookWorkerCreateOrUpdateContent content = new HybridRunbookWorkerCreateOrUpdateContent + { + VmResourceId = new ResourceIdentifier("/subscriptions/vmsubid/resourceGroups/vmrg/providers/Microsoft.Compute/virtualMachines/vmname"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hybridRunbookWorkerId, content); + HybridRunbookWorkerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +58,7 @@ public async Task Get_GetAV2HybridRunbookWorker() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAV2HybridRunbookWorker() + public async Task Get_GetAV2HybridRunbookWorker() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getHybridRunbookWorker.json // this example is just showing the usage of "HybridRunbookWorkers_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +82,21 @@ public async Task Exists_GetAV2HybridRunbookWorker() // invoke the operation string hybridRunbookWorkerId = "c010ad12-ef14-4a2a-aa9e-ef22c4745ddd"; - bool result = await collection.ExistsAsync(hybridRunbookWorkerId); + HybridRunbookWorkerResource result = await collection.GetAsync(hybridRunbookWorkerId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridRunbookWorkerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAV2HybridRunbookWorker() + public async Task GetAll_ListHybridWorkersByHybridRunbookWorkerGroup() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getHybridRunbookWorker.json - // this example is just showing the usage of "HybridRunbookWorkers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/listHybridRunbookWorker.json + // this example is just showing the usage of "HybridRunbookWorkers_ListByHybridRunbookWorkerGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +115,25 @@ public async Task GetIfExists_GetAV2HybridRunbookWorker() // get the collection of this HybridRunbookWorkerResource HybridRunbookWorkerCollection collection = hybridRunbookWorkerGroup.GetHybridRunbookWorkers(); - // invoke the operation - string hybridRunbookWorkerId = "c010ad12-ef14-4a2a-aa9e-ef22c4745ddd"; - NullableResponse response = await collection.GetIfExistsAsync(hybridRunbookWorkerId); - HybridRunbookWorkerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HybridRunbookWorkerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridRunbookWorkerData resourceData = result.Data; + HybridRunbookWorkerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAV2HybridRunbookWorker() + public async Task Exists_GetAV2HybridRunbookWorker() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/putHybridRunbookWorker.json - // this example is just showing the usage of "HybridRunbookWorkers_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getHybridRunbookWorker.json + // this example is just showing the usage of "HybridRunbookWorkers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,26 +154,17 @@ public async Task CreateOrUpdate_CreateAV2HybridRunbookWorker() // invoke the operation string hybridRunbookWorkerId = "c010ad12-ef14-4a2a-aa9e-ef22c4745ddd"; - HybridRunbookWorkerCreateOrUpdateContent content = new HybridRunbookWorkerCreateOrUpdateContent() - { - VmResourceId = new ResourceIdentifier("/subscriptions/vmsubid/resourceGroups/vmrg/providers/Microsoft.Compute/virtualMachines/vmname"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hybridRunbookWorkerId, content); - HybridRunbookWorkerResource result = lro.Value; + bool result = await collection.ExistsAsync(hybridRunbookWorkerId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridRunbookWorkerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListHybridWorkersByHybridRunbookWorkerGroup() + public async Task GetIfExists_GetAV2HybridRunbookWorker() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/listHybridRunbookWorker.json - // this example is just showing the usage of "HybridRunbookWorkers_ListByHybridRunbookWorkerGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getHybridRunbookWorker.json + // this example is just showing the usage of "HybridRunbookWorkers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_ListHybridWorkersByHybridRunbookWorkerGroup() // get the collection of this HybridRunbookWorkerResource HybridRunbookWorkerCollection collection = hybridRunbookWorkerGroup.GetHybridRunbookWorkers(); - // invoke the operation and iterate over the result - await foreach (HybridRunbookWorkerResource item in collection.GetAllAsync()) + // invoke the operation + string hybridRunbookWorkerId = "c010ad12-ef14-4a2a-aa9e-ef22c4745ddd"; + NullableResponse response = await collection.GetIfExistsAsync(hybridRunbookWorkerId); + HybridRunbookWorkerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridRunbookWorkerData resourceData = item.Data; + HybridRunbookWorkerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerGroupCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerGroupCollection.cs index 6ecf09fcdde59..deef419ba044f 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerGroupCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HybridRunbookWorkerGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAHybridWorkerGroup() + public async Task CreateOrUpdate_CreateAHybridWorkerGroup() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/getHybridRunbookWorkerGroup.json - // this example is just showing the usage of "HybridRunbookWorkerGroup_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/putHybridRunbookWorkerGroup.json + // this example is just showing the usage of "HybridRunbookWorkerGroup_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetAHybridWorkerGroup() // invoke the operation string hybridRunbookWorkerGroupName = "TestHybridGroup"; - HybridRunbookWorkerGroupResource result = await collection.GetAsync(hybridRunbookWorkerGroupName); + HybridRunbookWorkerGroupCreateOrUpdateContent content = new HybridRunbookWorkerGroupCreateOrUpdateContent + { + CredentialName = "myRunAsCredentialName", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hybridRunbookWorkerGroupName, content); + HybridRunbookWorkerGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetAHybridWorkerGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAHybridWorkerGroup() + public async Task Get_GetAHybridWorkerGroup() { // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/getHybridRunbookWorkerGroup.json // this example is just showing the usage of "HybridRunbookWorkerGroup_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetAHybridWorkerGroup() // invoke the operation string hybridRunbookWorkerGroupName = "TestHybridGroup"; - bool result = await collection.ExistsAsync(hybridRunbookWorkerGroupName); + HybridRunbookWorkerGroupResource result = await collection.GetAsync(hybridRunbookWorkerGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridRunbookWorkerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAHybridWorkerGroup() + public async Task GetAll_ListHybridWorkerGroupsByAutomationAccount() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/getHybridRunbookWorkerGroup.json - // this example is just showing the usage of "HybridRunbookWorkerGroup_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/listHybridRunbookWorkerGroup.json + // this example is just showing the usage of "HybridRunbookWorkerGroup_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetAHybridWorkerGroup() // get the collection of this HybridRunbookWorkerGroupResource HybridRunbookWorkerGroupCollection collection = automationAccount.GetHybridRunbookWorkerGroups(); - // invoke the operation - string hybridRunbookWorkerGroupName = "TestHybridGroup"; - NullableResponse response = await collection.GetIfExistsAsync(hybridRunbookWorkerGroupName); - HybridRunbookWorkerGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HybridRunbookWorkerGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridRunbookWorkerGroupData resourceData = result.Data; + HybridRunbookWorkerGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAHybridWorkerGroup() + public async Task Exists_GetAHybridWorkerGroup() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/putHybridRunbookWorkerGroup.json - // this example is just showing the usage of "HybridRunbookWorkerGroup_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/getHybridRunbookWorkerGroup.json + // this example is just showing the usage of "HybridRunbookWorkerGroup_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_CreateAHybridWorkerGroup() // invoke the operation string hybridRunbookWorkerGroupName = "TestHybridGroup"; - HybridRunbookWorkerGroupCreateOrUpdateContent content = new HybridRunbookWorkerGroupCreateOrUpdateContent() - { - CredentialName = "myRunAsCredentialName", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hybridRunbookWorkerGroupName, content); - HybridRunbookWorkerGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(hybridRunbookWorkerGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridRunbookWorkerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListHybridWorkerGroupsByAutomationAccount() + public async Task GetIfExists_GetAHybridWorkerGroup() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/listHybridRunbookWorkerGroup.json - // this example is just showing the usage of "HybridRunbookWorkerGroup_ListByAutomationAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/getHybridRunbookWorkerGroup.json + // this example is just showing the usage of "HybridRunbookWorkerGroup_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListHybridWorkerGroupsByAutomationAccount() // get the collection of this HybridRunbookWorkerGroupResource HybridRunbookWorkerGroupCollection collection = automationAccount.GetHybridRunbookWorkerGroups(); - // invoke the operation and iterate over the result - await foreach (HybridRunbookWorkerGroupResource item in collection.GetAllAsync()) + // invoke the operation + string hybridRunbookWorkerGroupName = "TestHybridGroup"; + NullableResponse response = await collection.GetIfExistsAsync(hybridRunbookWorkerGroupName); + HybridRunbookWorkerGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HybridRunbookWorkerGroupData resourceData = item.Data; + HybridRunbookWorkerGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerGroupResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerGroupResource.cs index 4b3be7d72a4ea..dd52d3d30f174 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerGroupResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerGroupResource.cs @@ -18,10 +18,10 @@ public partial class Sample_HybridRunbookWorkerGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAHybridWorkerGroup() + public async Task Get_GetAHybridWorkerGroup() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/deleteHybridRunbookWorkerGroup.json - // this example is just showing the usage of "HybridRunbookWorkerGroup_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/getHybridRunbookWorkerGroup.json + // this example is just showing the usage of "HybridRunbookWorkerGroup_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,23 +32,27 @@ public async Task Delete_DeleteAHybridWorkerGroup() // for more information of creating HybridRunbookWorkerGroupResource, please refer to the document of HybridRunbookWorkerGroupResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount20"; - string hybridRunbookWorkerGroupName = "myGroup"; + string automationAccountName = "testaccount"; + string hybridRunbookWorkerGroupName = "TestHybridGroup"; ResourceIdentifier hybridRunbookWorkerGroupResourceId = HybridRunbookWorkerGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName); HybridRunbookWorkerGroupResource hybridRunbookWorkerGroup = client.GetHybridRunbookWorkerGroupResource(hybridRunbookWorkerGroupResourceId); // invoke the operation - await hybridRunbookWorkerGroup.DeleteAsync(WaitUntil.Completed); + HybridRunbookWorkerGroupResource result = await hybridRunbookWorkerGroup.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridRunbookWorkerGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAHybridWorkerGroup() + public async Task Delete_DeleteAHybridWorkerGroup() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/getHybridRunbookWorkerGroup.json - // this example is just showing the usage of "HybridRunbookWorkerGroup_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2022-02-22/examples/deleteHybridRunbookWorkerGroup.json + // this example is just showing the usage of "HybridRunbookWorkerGroup_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,19 +63,15 @@ public async Task Get_GetAHybridWorkerGroup() // for more information of creating HybridRunbookWorkerGroupResource, please refer to the document of HybridRunbookWorkerGroupResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "testaccount"; - string hybridRunbookWorkerGroupName = "TestHybridGroup"; + string automationAccountName = "myAutomationAccount20"; + string hybridRunbookWorkerGroupName = "myGroup"; ResourceIdentifier hybridRunbookWorkerGroupResourceId = HybridRunbookWorkerGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName); HybridRunbookWorkerGroupResource hybridRunbookWorkerGroup = client.GetHybridRunbookWorkerGroupResource(hybridRunbookWorkerGroupResourceId); // invoke the operation - HybridRunbookWorkerGroupResource result = await hybridRunbookWorkerGroup.GetAsync(); + await hybridRunbookWorkerGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridRunbookWorkerGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_UpdateHybridWorkerGroup() HybridRunbookWorkerGroupResource hybridRunbookWorkerGroup = client.GetHybridRunbookWorkerGroupResource(hybridRunbookWorkerGroupResourceId); // invoke the operation - HybridRunbookWorkerGroupCreateOrUpdateContent content = new HybridRunbookWorkerGroupCreateOrUpdateContent() + HybridRunbookWorkerGroupCreateOrUpdateContent content = new HybridRunbookWorkerGroupCreateOrUpdateContent { CredentialName = "myRunAsCredentialUpdatedName", }; diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerResource.cs index c84349deb2568..04fb1a1d965cc 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_HybridRunbookWorkerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_HybridRunbookWorkerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAV2HybridRunbookWorker() + public async Task Get_GetAV2HybridRunbookWorker() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/deleteHybridRunbookWorker.json - // this example is just showing the usage of "HybridRunbookWorkers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getHybridRunbookWorker.json + // this example is just showing the usage of "HybridRunbookWorkers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,28 @@ public async Task Delete_DeleteAV2HybridRunbookWorker() // for more information of creating HybridRunbookWorkerResource, please refer to the document of HybridRunbookWorkerResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "myAutomationAccount20"; - string hybridRunbookWorkerGroupName = "myGroup"; + string automationAccountName = "testaccount"; + string hybridRunbookWorkerGroupName = "TestHybridGroup"; string hybridRunbookWorkerId = "c010ad12-ef14-4a2a-aa9e-ef22c4745ddd"; ResourceIdentifier hybridRunbookWorkerResourceId = HybridRunbookWorkerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName, hybridRunbookWorkerId); HybridRunbookWorkerResource hybridRunbookWorker = client.GetHybridRunbookWorkerResource(hybridRunbookWorkerResourceId); // invoke the operation - await hybridRunbookWorker.DeleteAsync(WaitUntil.Completed); + HybridRunbookWorkerResource result = await hybridRunbookWorker.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HybridRunbookWorkerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAV2HybridRunbookWorker() + public async Task Delete_DeleteAV2HybridRunbookWorker() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/getHybridRunbookWorker.json - // this example is just showing the usage of "HybridRunbookWorkers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/deleteHybridRunbookWorker.json + // this example is just showing the usage of "HybridRunbookWorkers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,20 +64,16 @@ public async Task Get_GetAV2HybridRunbookWorker() // for more information of creating HybridRunbookWorkerResource, please refer to the document of HybridRunbookWorkerResource string subscriptionId = "subid"; string resourceGroupName = "rg"; - string automationAccountName = "testaccount"; - string hybridRunbookWorkerGroupName = "TestHybridGroup"; + string automationAccountName = "myAutomationAccount20"; + string hybridRunbookWorkerGroupName = "myGroup"; string hybridRunbookWorkerId = "c010ad12-ef14-4a2a-aa9e-ef22c4745ddd"; ResourceIdentifier hybridRunbookWorkerResourceId = HybridRunbookWorkerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, hybridRunbookWorkerGroupName, hybridRunbookWorkerId); HybridRunbookWorkerResource hybridRunbookWorker = client.GetHybridRunbookWorkerResource(hybridRunbookWorkerResourceId); // invoke the operation - HybridRunbookWorkerResource result = await hybridRunbookWorker.GetAsync(); + await hybridRunbookWorker.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HybridRunbookWorkerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,7 +99,7 @@ public async Task Update_CreateAV2HybridRunbookWorker() HybridRunbookWorkerResource hybridRunbookWorker = client.GetHybridRunbookWorkerResource(hybridRunbookWorkerResourceId); // invoke the operation - HybridRunbookWorkerCreateOrUpdateContent content = new HybridRunbookWorkerCreateOrUpdateContent() + HybridRunbookWorkerCreateOrUpdateContent content = new HybridRunbookWorkerCreateOrUpdateContent { VmResourceId = new ResourceIdentifier("/subscriptions/vmsubid/resourceGroups/vmrg/providers/Microsoft.Compute/virtualMachines/vmname"), }; @@ -136,7 +136,7 @@ public async Task Move_MoveAV2HybridWorkerToADifferentGroup() HybridRunbookWorkerResource hybridRunbookWorker = client.GetHybridRunbookWorkerResource(hybridRunbookWorkerResourceId); // invoke the operation - HybridRunbookWorkerMoveContent content = new HybridRunbookWorkerMoveContent() + HybridRunbookWorkerMoveContent content = new HybridRunbookWorkerMoveContent { HybridRunbookWorkerGroupName = "TestHybridGroup2", }; diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SoftwareUpdateConfigurationCollection.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SoftwareUpdateConfigurationCollection.cs index 5a2088fa08ff7..4124288f31ab0 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SoftwareUpdateConfigurationCollection.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SoftwareUpdateConfigurationCollection.cs @@ -44,99 +44,67 @@ public async Task CreateOrUpdate_CreateSoftwareUpdateConfiguration() string softwareUpdateConfigurationName = "testpatch"; SoftwareUpdateConfigurationData data = new SoftwareUpdateConfigurationData(new SoftwareUpdateConfigurationSpecificProperties(SoftwareUpdateConfigurationOperatingSystemType.Windows) { - Windows = new WindowsUpdateConfigurationProperties() + Windows = new WindowsUpdateConfigurationProperties { IncludedUpdateClassifications = WindowsUpdateClassification.Critical, - ExcludedKBNumbers = -{ -"168934","168973" -}, + ExcludedKBNumbers = { "168934", "168973" }, RebootSetting = "IfRequired", }, Duration = XmlConvert.ToTimeSpan("PT2H0M"), - AzureVirtualMachines = -{ -"/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-01","/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-02","/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-03" -}, - NonAzureComputerNames = -{ -"box1.contoso.com","box2.contoso.com" -}, - Targets = new SoftwareUpdateConfigurationTargetProperties() + AzureVirtualMachines = { "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-01", "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-02", "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-03" }, + NonAzureComputerNames = { "box1.contoso.com", "box2.contoso.com" }, + Targets = new SoftwareUpdateConfigurationTargetProperties { - AzureQueries = + AzureQueries = {new AzureQueryProperties { -new AzureQueryProperties() -{ -Scope = -{ -"/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources","/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067" -}, -Locations = -{ -new AzureLocation("Japan East"),new AzureLocation("UK South") -}, -TagSettings = new QueryTagSettingsProperties() +Scope = {"/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources", "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067"}, +Locations = {new AzureLocation("Japan East"), new AzureLocation("UK South")}, +TagSettings = new QueryTagSettingsProperties { Tags = { -["tag1"] = new string[] -{ -"tag1Value1","tag1Value2","tag1Value3" -}, -["tag2"] = new string[] -{ -"tag2Value1","tag2Value2","tag2Value3" -}, +["tag1"] = {"tag1Value1", "tag1Value2", "tag1Value3"}, +["tag2"] = {"tag2Value1", "tag2Value2", "tag2Value3"} }, FilterOperator = QueryTagOperator.All, }, -} -}, - NonAzureQueries = -{ -new NonAzureQueryProperties() +}}, + NonAzureQueries = {new NonAzureQueryProperties { FunctionAlias = "SavedSearch1", WorkspaceId = "WorkspaceId1", -},new NonAzureQueryProperties() +}, new NonAzureQueryProperties { FunctionAlias = "SavedSearch2", WorkspaceId = "WorkspaceId2", -} -}, +}}, }, - }, new SoftwareUpdateConfigurationScheduleProperties() + }, new SoftwareUpdateConfigurationScheduleProperties { StartOn = DateTimeOffset.Parse("2017-10-19T12:22:57+00:00"), ExpireOn = DateTimeOffset.Parse("2018-11-09T11:22:57+00:00"), Interval = 1L, Frequency = AutomationScheduleFrequency.Hour, TimeZone = "America/Los_Angeles", - AdvancedSchedule = new AutomationAdvancedSchedule() + AdvancedSchedule = new AutomationAdvancedSchedule { - WeekDays = -{ -"Monday","Thursday" -}, + WeekDays = { "Monday", "Thursday" }, }, }) { - Tasks = new SoftwareUpdateConfigurationTasks() + Tasks = new SoftwareUpdateConfigurationTasks { - PreTask = new SoftwareUpdateConfigurationTaskProperties() + PreTask = new SoftwareUpdateConfigurationTaskProperties { Parameters = { -["COMPUTERNAME"] = "Computer1", +["COMPUTERNAME"] = "Computer1" }, Source = "HelloWorld", }, - PostTask = new SoftwareUpdateConfigurationTaskProperties() + PostTask = new SoftwareUpdateConfigurationTaskProperties { - Parameters = -{ -}, + Parameters = { }, Source = "GetCache", }, }, @@ -187,10 +155,10 @@ public async Task Get_GetSoftwareUpdateConfigurationByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSoftwareUpdateConfigurationByName() + public async Task GetAll_ListSoftwareUpdateConfigurations() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/getSoftwareUpdateConfigurationByName.json - // this example is just showing the usage of "SoftwareUpdateConfigurations_GetByName" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/listSoftwareUpdateConfigurations.json + // this example is just showing the usage of "SoftwareUpdateConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,7 +167,7 @@ public async Task Exists_GetSoftwareUpdateConfigurationByName() // this example assumes you already have this AutomationAccountResource created on azure // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource - string subscriptionId = "51766542-3ed7-4a72-a187-0c8ab644ddab"; + string subscriptionId = "1a7d4044-286c-4acb-969a-96639265bf2e"; string resourceGroupName = "mygroup"; string automationAccountName = "myaccount"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); @@ -208,19 +176,21 @@ public async Task Exists_GetSoftwareUpdateConfigurationByName() // get the collection of this SoftwareUpdateConfigurationResource SoftwareUpdateConfigurationCollection collection = automationAccount.GetSoftwareUpdateConfigurations(); - // invoke the operation - string softwareUpdateConfigurationName = "mypatch"; - bool result = await collection.ExistsAsync(softwareUpdateConfigurationName); + // invoke the operation and iterate over the result + await foreach (SoftwareUpdateConfigurationCollectionItem item in collection.GetAllAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSoftwareUpdateConfigurationByName() + public async Task GetAll_ListSoftwareUpdateConfigurationsTargetingASpecificAzureVirtualMachine() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/getSoftwareUpdateConfigurationByName.json - // this example is just showing the usage of "SoftwareUpdateConfigurations_GetByName" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/listSoftwareUpdateConfigurationsByVm.json + // this example is just showing the usage of "SoftwareUpdateConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -229,7 +199,7 @@ public async Task GetIfExists_GetSoftwareUpdateConfigurationByName() // this example assumes you already have this AutomationAccountResource created on azure // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource - string subscriptionId = "51766542-3ed7-4a72-a187-0c8ab644ddab"; + string subscriptionId = "1a7d4044-286c-4acb-969a-96639265bf2e"; string resourceGroupName = "mygroup"; string automationAccountName = "myaccount"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); @@ -238,31 +208,22 @@ public async Task GetIfExists_GetSoftwareUpdateConfigurationByName() // get the collection of this SoftwareUpdateConfigurationResource SoftwareUpdateConfigurationCollection collection = automationAccount.GetSoftwareUpdateConfigurations(); - // invoke the operation - string softwareUpdateConfigurationName = "mypatch"; - NullableResponse response = await collection.GetIfExistsAsync(softwareUpdateConfigurationName); - SoftwareUpdateConfigurationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string filter = "properties/updateConfiguration/azureVirtualMachines/any(m: m eq '/subscriptions/1a7d4044-286c-4acb-969a-96639265bf2e/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-01')"; + await foreach (SoftwareUpdateConfigurationCollectionItem item in collection.GetAllAsync(filter: filter)) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SoftwareUpdateConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {item}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSoftwareUpdateConfigurations() + public async Task Exists_GetSoftwareUpdateConfigurationByName() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/listSoftwareUpdateConfigurations.json - // this example is just showing the usage of "SoftwareUpdateConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/getSoftwareUpdateConfigurationByName.json + // this example is just showing the usage of "SoftwareUpdateConfigurations_GetByName" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -271,7 +232,7 @@ public async Task GetAll_ListSoftwareUpdateConfigurations() // this example assumes you already have this AutomationAccountResource created on azure // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource - string subscriptionId = "1a7d4044-286c-4acb-969a-96639265bf2e"; + string subscriptionId = "51766542-3ed7-4a72-a187-0c8ab644ddab"; string resourceGroupName = "mygroup"; string automationAccountName = "myaccount"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); @@ -280,21 +241,19 @@ public async Task GetAll_ListSoftwareUpdateConfigurations() // get the collection of this SoftwareUpdateConfigurationResource SoftwareUpdateConfigurationCollection collection = automationAccount.GetSoftwareUpdateConfigurations(); - // invoke the operation and iterate over the result - await foreach (SoftwareUpdateConfigurationCollectionItem item in collection.GetAllAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + string softwareUpdateConfigurationName = "mypatch"; + bool result = await collection.ExistsAsync(softwareUpdateConfigurationName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSoftwareUpdateConfigurationsTargetingASpecificAzureVirtualMachine() + public async Task GetIfExists_GetSoftwareUpdateConfigurationByName() { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/listSoftwareUpdateConfigurationsByVm.json - // this example is just showing the usage of "SoftwareUpdateConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/getSoftwareUpdateConfigurationByName.json + // this example is just showing the usage of "SoftwareUpdateConfigurations_GetByName" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -303,7 +262,7 @@ public async Task GetAll_ListSoftwareUpdateConfigurationsTargetingASpecificAzure // this example assumes you already have this AutomationAccountResource created on azure // for more information of creating AutomationAccountResource, please refer to the document of AutomationAccountResource - string subscriptionId = "1a7d4044-286c-4acb-969a-96639265bf2e"; + string subscriptionId = "51766542-3ed7-4a72-a187-0c8ab644ddab"; string resourceGroupName = "mygroup"; string automationAccountName = "myaccount"; ResourceIdentifier automationAccountResourceId = AutomationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName); @@ -312,14 +271,23 @@ public async Task GetAll_ListSoftwareUpdateConfigurationsTargetingASpecificAzure // get the collection of this SoftwareUpdateConfigurationResource SoftwareUpdateConfigurationCollection collection = automationAccount.GetSoftwareUpdateConfigurations(); - // invoke the operation and iterate over the result - string filter = "properties/updateConfiguration/azureVirtualMachines/any(m: m eq '/subscriptions/1a7d4044-286c-4acb-969a-96639265bf2e/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-01')"; - await foreach (SoftwareUpdateConfigurationCollectionItem item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string softwareUpdateConfigurationName = "mypatch"; + NullableResponse response = await collection.GetIfExistsAsync(softwareUpdateConfigurationName); + SoftwareUpdateConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Console.WriteLine($"Succeeded: {item}"); + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SoftwareUpdateConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SoftwareUpdateConfigurationResource.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SoftwareUpdateConfigurationResource.cs index 11ea5468bded5..8e287512c7584 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SoftwareUpdateConfigurationResource.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SoftwareUpdateConfigurationResource.cs @@ -17,6 +17,64 @@ namespace Azure.ResourceManager.Automation.Samples { public partial class Sample_SoftwareUpdateConfigurationResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetSoftwareUpdateConfigurationByName() + { + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/getSoftwareUpdateConfigurationByName.json + // this example is just showing the usage of "SoftwareUpdateConfigurations_GetByName" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SoftwareUpdateConfigurationResource created on azure + // for more information of creating SoftwareUpdateConfigurationResource, please refer to the document of SoftwareUpdateConfigurationResource + string subscriptionId = "51766542-3ed7-4a72-a187-0c8ab644ddab"; + string resourceGroupName = "mygroup"; + string automationAccountName = "myaccount"; + string softwareUpdateConfigurationName = "mypatch"; + ResourceIdentifier softwareUpdateConfigurationResourceId = SoftwareUpdateConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, softwareUpdateConfigurationName); + SoftwareUpdateConfigurationResource softwareUpdateConfiguration = client.GetSoftwareUpdateConfigurationResource(softwareUpdateConfigurationResourceId); + + // invoke the operation + SoftwareUpdateConfigurationResource result = await softwareUpdateConfiguration.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SoftwareUpdateConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteSoftwareUpdateConfiguration() + { + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/deleteSoftwareUpdateConfiguration.json + // this example is just showing the usage of "SoftwareUpdateConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SoftwareUpdateConfigurationResource created on azure + // for more information of creating SoftwareUpdateConfigurationResource, please refer to the document of SoftwareUpdateConfigurationResource + string subscriptionId = "51766542-3ed7-4a72-a187-0c8ab644ddab"; + string resourceGroupName = "mygroup"; + string automationAccountName = "myaccount"; + string softwareUpdateConfigurationName = "mypatch"; + ResourceIdentifier softwareUpdateConfigurationResourceId = SoftwareUpdateConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, softwareUpdateConfigurationName); + SoftwareUpdateConfigurationResource softwareUpdateConfiguration = client.GetSoftwareUpdateConfigurationResource(softwareUpdateConfigurationResourceId); + + // invoke the operation + await softwareUpdateConfiguration.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateSoftwareUpdateConfiguration() @@ -41,99 +99,67 @@ public async Task Update_CreateSoftwareUpdateConfiguration() // invoke the operation SoftwareUpdateConfigurationData data = new SoftwareUpdateConfigurationData(new SoftwareUpdateConfigurationSpecificProperties(SoftwareUpdateConfigurationOperatingSystemType.Windows) { - Windows = new WindowsUpdateConfigurationProperties() + Windows = new WindowsUpdateConfigurationProperties { IncludedUpdateClassifications = WindowsUpdateClassification.Critical, - ExcludedKBNumbers = -{ -"168934","168973" -}, + ExcludedKBNumbers = { "168934", "168973" }, RebootSetting = "IfRequired", }, Duration = XmlConvert.ToTimeSpan("PT2H0M"), - AzureVirtualMachines = -{ -"/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-01","/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-02","/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-03" -}, - NonAzureComputerNames = -{ -"box1.contoso.com","box2.contoso.com" -}, - Targets = new SoftwareUpdateConfigurationTargetProperties() + AzureVirtualMachines = { "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-01", "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-02", "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources/providers/Microsoft.Compute/virtualMachines/vm-03" }, + NonAzureComputerNames = { "box1.contoso.com", "box2.contoso.com" }, + Targets = new SoftwareUpdateConfigurationTargetProperties { - AzureQueries = -{ -new AzureQueryProperties() -{ -Scope = -{ -"/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources","/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067" -}, -Locations = + AzureQueries = {new AzureQueryProperties { -new AzureLocation("Japan East"),new AzureLocation("UK South") -}, -TagSettings = new QueryTagSettingsProperties() +Scope = {"/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067/resourceGroups/myresources", "/subscriptions/5ae68d89-69a4-454f-b5ce-e443cc4e0067"}, +Locations = {new AzureLocation("Japan East"), new AzureLocation("UK South")}, +TagSettings = new QueryTagSettingsProperties { Tags = { -["tag1"] = new string[] -{ -"tag1Value1","tag1Value2","tag1Value3" -}, -["tag2"] = new string[] -{ -"tag2Value1","tag2Value2","tag2Value3" -}, +["tag1"] = {"tag1Value1", "tag1Value2", "tag1Value3"}, +["tag2"] = {"tag2Value1", "tag2Value2", "tag2Value3"} }, FilterOperator = QueryTagOperator.All, }, -} -}, - NonAzureQueries = -{ -new NonAzureQueryProperties() +}}, + NonAzureQueries = {new NonAzureQueryProperties { FunctionAlias = "SavedSearch1", WorkspaceId = "WorkspaceId1", -},new NonAzureQueryProperties() +}, new NonAzureQueryProperties { FunctionAlias = "SavedSearch2", WorkspaceId = "WorkspaceId2", -} -}, +}}, }, - }, new SoftwareUpdateConfigurationScheduleProperties() + }, new SoftwareUpdateConfigurationScheduleProperties { StartOn = DateTimeOffset.Parse("2017-10-19T12:22:57+00:00"), ExpireOn = DateTimeOffset.Parse("2018-11-09T11:22:57+00:00"), Interval = 1L, Frequency = AutomationScheduleFrequency.Hour, TimeZone = "America/Los_Angeles", - AdvancedSchedule = new AutomationAdvancedSchedule() + AdvancedSchedule = new AutomationAdvancedSchedule { - WeekDays = -{ -"Monday","Thursday" -}, + WeekDays = { "Monday", "Thursday" }, }, }) { - Tasks = new SoftwareUpdateConfigurationTasks() + Tasks = new SoftwareUpdateConfigurationTasks { - PreTask = new SoftwareUpdateConfigurationTaskProperties() + PreTask = new SoftwareUpdateConfigurationTaskProperties { Parameters = { -["COMPUTERNAME"] = "Computer1", +["COMPUTERNAME"] = "Computer1" }, Source = "HelloWorld", }, - PostTask = new SoftwareUpdateConfigurationTaskProperties() + PostTask = new SoftwareUpdateConfigurationTaskProperties { - Parameters = -{ -}, + Parameters = { }, Source = "GetCache", }, }, @@ -147,63 +173,5 @@ public async Task Update_CreateSoftwareUpdateConfiguration() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetSoftwareUpdateConfigurationByName() - { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/getSoftwareUpdateConfigurationByName.json - // this example is just showing the usage of "SoftwareUpdateConfigurations_GetByName" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SoftwareUpdateConfigurationResource created on azure - // for more information of creating SoftwareUpdateConfigurationResource, please refer to the document of SoftwareUpdateConfigurationResource - string subscriptionId = "51766542-3ed7-4a72-a187-0c8ab644ddab"; - string resourceGroupName = "mygroup"; - string automationAccountName = "myaccount"; - string softwareUpdateConfigurationName = "mypatch"; - ResourceIdentifier softwareUpdateConfigurationResourceId = SoftwareUpdateConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, softwareUpdateConfigurationName); - SoftwareUpdateConfigurationResource softwareUpdateConfiguration = client.GetSoftwareUpdateConfigurationResource(softwareUpdateConfigurationResourceId); - - // invoke the operation - SoftwareUpdateConfigurationResource result = await softwareUpdateConfiguration.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SoftwareUpdateConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSoftwareUpdateConfiguration() - { - // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2019-06-01/examples/softwareUpdateConfiguration/deleteSoftwareUpdateConfiguration.json - // this example is just showing the usage of "SoftwareUpdateConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SoftwareUpdateConfigurationResource created on azure - // for more information of creating SoftwareUpdateConfigurationResource, please refer to the document of SoftwareUpdateConfigurationResource - string subscriptionId = "51766542-3ed7-4a72-a187-0c8ab644ddab"; - string resourceGroupName = "mygroup"; - string automationAccountName = "myaccount"; - string softwareUpdateConfigurationName = "mypatch"; - ResourceIdentifier softwareUpdateConfigurationResourceId = SoftwareUpdateConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, automationAccountName, softwareUpdateConfigurationName); - SoftwareUpdateConfigurationResource softwareUpdateConfiguration = client.GetSoftwareUpdateConfigurationResource(softwareUpdateConfigurationResourceId); - - // invoke the operation - await softwareUpdateConfiguration.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 596977d3e04d5..d722708986d12 100644 --- a/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/automation/Azure.ResourceManager.Automation/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.Automation.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAutomationAccounts_ListAutomationAccountsByResourceGroup() + { + // Generated from example definition: specification/automation/resource-manager/Microsoft.Automation/stable/2021-06-22/examples/listAutomationAccountsBySubscription.json + // this example is just showing the usage of "AutomationAccount_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AutomationAccountResource item in subscriptionResource.GetAutomationAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutomationAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetDeletedAutomationAccountsBySubscription_GetDeletedAutomationAccount() diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsCloudLinkCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsCloudLinkCollection.cs index 014632ddd0c3a..87be385c78c71 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsCloudLinkCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsCloudLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AvsCloudLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CloudLinksList() + public async Task CreateOrUpdate_CloudLinksCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_List.json - // this example is just showing the usage of "CloudLinks_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_CreateOrUpdate.json + // this example is just showing the usage of "CloudLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_CloudLinksList() // get the collection of this AvsCloudLinkResource AvsCloudLinkCollection collection = avsPrivateCloud.GetAvsCloudLinks(); - // invoke the operation and iterate over the result - await foreach (AvsCloudLinkResource item in collection.GetAllAsync()) + // invoke the operation + string cloudLinkName = "cloudLink1"; + AvsCloudLinkData data = new AvsCloudLinkData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsCloudLinkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + LinkedCloud = new ResourceIdentifier("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/mygroup/providers/Microsoft.AVS/privateClouds/cloud2"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudLinkName, data); + AvsCloudLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsCloudLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_CloudLinksGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CloudLinksGet() + public async Task GetAll_CloudLinksList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_Get.json - // this example is just showing the usage of "CloudLinks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_List.json + // this example is just showing the usage of "CloudLinks_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_CloudLinksGet() // get the collection of this AvsCloudLinkResource AvsCloudLinkCollection collection = avsPrivateCloud.GetAvsCloudLinks(); - // invoke the operation - string cloudLinkName = "cloudLink1"; - bool result = await collection.ExistsAsync(cloudLinkName); + // invoke the operation and iterate over the result + await foreach (AvsCloudLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsCloudLinkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CloudLinksGet() + public async Task Exists_CloudLinksGet() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_Get.json // this example is just showing the usage of "CloudLinks_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_CloudLinksGet() // invoke the operation string cloudLinkName = "cloudLink1"; - NullableResponse response = await collection.GetIfExistsAsync(cloudLinkName); - AvsCloudLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(cloudLinkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsCloudLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CloudLinksCreateOrUpdate() + public async Task GetIfExists_CloudLinksGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_CreateOrUpdate.json - // this example is just showing the usage of "CloudLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_Get.json + // this example is just showing the usage of "CloudLinks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_CloudLinksCreateOrUpdate() // invoke the operation string cloudLinkName = "cloudLink1"; - AvsCloudLinkData data = new AvsCloudLinkData() - { - LinkedCloud = new ResourceIdentifier("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/mygroup/providers/Microsoft.AVS/privateClouds/cloud2"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, cloudLinkName, data); - AvsCloudLinkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(cloudLinkName); + AvsCloudLinkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsCloudLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsCloudLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsCloudLinkResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsCloudLinkResource.cs index 6653ccf8a2d9a..392280ad5749a 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsCloudLinkResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsCloudLinkResource.cs @@ -48,10 +48,10 @@ public async Task Get_CloudLinksGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CloudLinksCreateOrUpdate() + public async Task Delete_CloudLinksDelete() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_CreateOrUpdate.json - // this example is just showing the usage of "CloudLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_Delete.json + // this example is just showing the usage of "CloudLinks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_CloudLinksCreateOrUpdate() AvsCloudLinkResource avsCloudLink = client.GetAvsCloudLinkResource(avsCloudLinkResourceId); // invoke the operation - AvsCloudLinkData data = new AvsCloudLinkData() - { - LinkedCloud = new ResourceIdentifier("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/mygroup/providers/Microsoft.AVS/privateClouds/cloud2"), - }; - ArmOperation lro = await avsCloudLink.UpdateAsync(WaitUntil.Completed, data); - AvsCloudLinkResource result = lro.Value; + await avsCloudLink.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsCloudLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CloudLinksDelete() + public async Task Update_CloudLinksCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_Delete.json - // this example is just showing the usage of "CloudLinks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/CloudLinks_CreateOrUpdate.json + // this example is just showing the usage of "CloudLinks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,18 @@ public async Task Delete_CloudLinksDelete() AvsCloudLinkResource avsCloudLink = client.GetAvsCloudLinkResource(avsCloudLinkResourceId); // invoke the operation - await avsCloudLink.DeleteAsync(WaitUntil.Completed); + AvsCloudLinkData data = new AvsCloudLinkData + { + LinkedCloud = new ResourceIdentifier("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/mygroup/providers/Microsoft.AVS/privateClouds/cloud2"), + }; + ArmOperation lro = await avsCloudLink.UpdateAsync(WaitUntil.Completed, data); + AvsCloudLinkResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsCloudLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudAddonCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudAddonCollection.cs index f40d6b830c342..0a6a63683da6c 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudAddonCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudAddonCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AvsPrivateCloudAddonCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AddonsList() + public async Task CreateOrUpdate_AddonsCreateOrUpdateArcReg() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_List.json - // this example is just showing the usage of "Addons_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_CreateOrUpdate_ArcReg.json + // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,31 @@ public async Task GetAll_AddonsList() // get the collection of this AvsPrivateCloudAddonResource AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); - // invoke the operation and iterate over the result - await foreach (AvsPrivateCloudAddonResource item in collection.GetAllAsync()) + // invoke the operation + string addonName = "arc"; + AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudAddonData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AddonArcProperties + { + VCenter = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg_test/providers/Microsoft.ConnectedVMwarevSphere/VCenters/test-vcenter", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addonName, data); + AvsPrivateCloudAddonResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AddonsGetArcReg() + public async Task CreateOrUpdate_AddonsCreateOrUpdateHCX() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_ArcReg.json - // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_CreateOrUpdate_HCX.json + // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,8 +82,13 @@ public async Task Get_AddonsGetArcReg() AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); // invoke the operation - string addonName = "arc"; - AvsPrivateCloudAddonResource result = await collection.GetAsync(addonName); + string addonName = "hcx"; + AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData + { + Properties = new AddonHcxProperties("VMware MaaS Cloud Provider (Enterprise)"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addonName, data); + AvsPrivateCloudAddonResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +99,10 @@ public async Task Get_AddonsGetArcReg() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AddonsGetArcReg() + public async Task CreateOrUpdate_AddonsCreateOrUpdateSRM() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_ArcReg.json - // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_CreateOrUpdate_SRM.json + // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,18 +121,30 @@ public async Task Exists_AddonsGetArcReg() AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); // invoke the operation - string addonName = "arc"; - bool result = await collection.ExistsAsync(addonName); + string addonName = "srm"; + AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData + { + Properties = new AddonSrmProperties + { + LicenseKey = "41915178-A8FF-4A4D-B683-6D735AF5E3F5", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addonName, data); + AvsPrivateCloudAddonResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AddonsGetArcReg() + public async Task CreateOrUpdate_AddonsCreateOrUpdateVR() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_ArcReg.json - // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_CreateOrUpdate_VR.json + // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,29 +163,26 @@ public async Task GetIfExists_AddonsGetArcReg() AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); // invoke the operation - string addonName = "arc"; - NullableResponse response = await collection.GetIfExistsAsync(addonName); - AvsPrivateCloudAddonResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string addonName = "vr"; + AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new AddonVrProperties(1), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addonName, data); + AvsPrivateCloudAddonResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AddonsGetHCX() + public async Task Get_AddonsGetArcReg() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_HCX.json + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_ArcReg.json // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -182,7 +202,7 @@ public async Task Get_AddonsGetHCX() AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); // invoke the operation - string addonName = "hcx"; + string addonName = "arc"; AvsPrivateCloudAddonResource result = await collection.GetAsync(addonName); // the variable result is a resource, you could call other operations on this instance as well @@ -194,7 +214,7 @@ public async Task Get_AddonsGetHCX() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AddonsGetHCX() + public async Task Get_AddonsGetHCX() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_HCX.json // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. @@ -217,16 +237,20 @@ public async Task Exists_AddonsGetHCX() // invoke the operation string addonName = "hcx"; - bool result = await collection.ExistsAsync(addonName); + AvsPrivateCloudAddonResource result = await collection.GetAsync(addonName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AddonsGetHCX() + public async Task Get_AddonsGetSRM() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_HCX.json + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_SRM.json // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -246,29 +270,21 @@ public async Task GetIfExists_AddonsGetHCX() AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); // invoke the operation - string addonName = "hcx"; - NullableResponse response = await collection.GetIfExistsAsync(addonName); - AvsPrivateCloudAddonResource result = response.HasValue ? response.Value : null; + string addonName = "srm"; + AvsPrivateCloudAddonResource result = await collection.GetAsync(addonName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AddonsGetSRM() + public async Task Get_AddonsGetVR() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_SRM.json + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_VR.json // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -288,7 +304,7 @@ public async Task Get_AddonsGetSRM() AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); // invoke the operation - string addonName = "srm"; + string addonName = "vr"; AvsPrivateCloudAddonResource result = await collection.GetAsync(addonName); // the variable result is a resource, you could call other operations on this instance as well @@ -300,10 +316,10 @@ public async Task Get_AddonsGetSRM() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AddonsGetSRM() + public async Task GetAll_AddonsList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_SRM.json - // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_List.json + // this example is just showing the usage of "Addons_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -321,18 +337,24 @@ public async Task Exists_AddonsGetSRM() // get the collection of this AvsPrivateCloudAddonResource AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); - // invoke the operation - string addonName = "srm"; - bool result = await collection.ExistsAsync(addonName); + // invoke the operation and iterate over the result + await foreach (AvsPrivateCloudAddonResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudAddonData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AddonsGetSRM() + public async Task Exists_AddonsGetArcReg() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_SRM.json + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_ArcReg.json // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -352,29 +374,17 @@ public async Task GetIfExists_AddonsGetSRM() AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); // invoke the operation - string addonName = "srm"; - NullableResponse response = await collection.GetIfExistsAsync(addonName); - AvsPrivateCloudAddonResource result = response.HasValue ? response.Value : null; + string addonName = "arc"; + bool result = await collection.ExistsAsync(addonName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AddonsGetVR() + public async Task Exists_AddonsGetHCX() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_VR.json + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_HCX.json // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -394,21 +404,17 @@ public async Task Get_AddonsGetVR() AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); // invoke the operation - string addonName = "vr"; - AvsPrivateCloudAddonResource result = await collection.GetAsync(addonName); + string addonName = "hcx"; + bool result = await collection.ExistsAsync(addonName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AddonsGetVR() + public async Task Exists_AddonsGetSRM() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_VR.json + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_SRM.json // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -428,7 +434,7 @@ public async Task Exists_AddonsGetVR() AvsPrivateCloudAddonCollection collection = avsPrivateCloud.GetAvsPrivateCloudAddons(); // invoke the operation - string addonName = "vr"; + string addonName = "srm"; bool result = await collection.ExistsAsync(addonName); Console.WriteLine($"Succeeded: {result}"); @@ -436,7 +442,7 @@ public async Task Exists_AddonsGetVR() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AddonsGetVR() + public async Task Exists_AddonsGetVR() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_VR.json // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. @@ -459,29 +465,17 @@ public async Task GetIfExists_AddonsGetVR() // invoke the operation string addonName = "vr"; - NullableResponse response = await collection.GetIfExistsAsync(addonName); - AvsPrivateCloudAddonResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(addonName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddonsCreateOrUpdateArcReg() + public async Task GetIfExists_AddonsGetArcReg() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_CreateOrUpdate_ArcReg.json - // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_ArcReg.json + // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -501,29 +495,29 @@ public async Task CreateOrUpdate_AddonsCreateOrUpdateArcReg() // invoke the operation string addonName = "arc"; - AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData() - { - Properties = new AddonArcProperties() - { - VCenter = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg_test/providers/Microsoft.ConnectedVMwarevSphere/VCenters/test-vcenter", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addonName, data); - AvsPrivateCloudAddonResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(addonName); + AvsPrivateCloudAddonResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddonsCreateOrUpdateHCX() + public async Task GetIfExists_AddonsGetHCX() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_CreateOrUpdate_HCX.json - // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_HCX.json + // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -543,26 +537,29 @@ public async Task CreateOrUpdate_AddonsCreateOrUpdateHCX() // invoke the operation string addonName = "hcx"; - AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData() - { - Properties = new AddonHcxProperties("VMware MaaS Cloud Provider (Enterprise)"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addonName, data); - AvsPrivateCloudAddonResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(addonName); + AvsPrivateCloudAddonResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddonsCreateOrUpdateSRM() + public async Task GetIfExists_AddonsGetSRM() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_CreateOrUpdate_SRM.json - // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_SRM.json + // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -582,29 +579,29 @@ public async Task CreateOrUpdate_AddonsCreateOrUpdateSRM() // invoke the operation string addonName = "srm"; - AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData() - { - Properties = new AddonSrmProperties() - { - LicenseKey = "41915178-A8FF-4A4D-B683-6D735AF5E3F5", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addonName, data); - AvsPrivateCloudAddonResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(addonName); + AvsPrivateCloudAddonResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AddonsCreateOrUpdateVR() + public async Task GetIfExists_AddonsGetVR() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_CreateOrUpdate_VR.json - // this example is just showing the usage of "Addons_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Get_VR.json + // this example is just showing the usage of "Addons_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -624,18 +621,21 @@ public async Task CreateOrUpdate_AddonsCreateOrUpdateVR() // invoke the operation string addonName = "vr"; - AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData() - { - Properties = new AddonVrProperties(1), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, addonName, data); - AvsPrivateCloudAddonResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(addonName); + AvsPrivateCloudAddonResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudAddonData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudAddonData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudAddonResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudAddonResource.cs index ac232a474502f..4ea30c3e71d23 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudAddonResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudAddonResource.cs @@ -140,6 +140,33 @@ public async Task Get_AddonsGetVR() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_AddonsDelete() + { + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Delete.json + // this example is just showing the usage of "Addons_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AvsPrivateCloudAddonResource created on azure + // for more information of creating AvsPrivateCloudAddonResource, please refer to the document of AvsPrivateCloudAddonResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "group1"; + string privateCloudName = "cloud1"; + string addonName = "srm"; + ResourceIdentifier avsPrivateCloudAddonResourceId = AvsPrivateCloudAddonResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, privateCloudName, addonName); + AvsPrivateCloudAddonResource avsPrivateCloudAddon = client.GetAvsPrivateCloudAddonResource(avsPrivateCloudAddonResourceId); + + // invoke the operation + await avsPrivateCloudAddon.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_AddonsCreateOrUpdateArcReg() @@ -162,9 +189,9 @@ public async Task Update_AddonsCreateOrUpdateArcReg() AvsPrivateCloudAddonResource avsPrivateCloudAddon = client.GetAvsPrivateCloudAddonResource(avsPrivateCloudAddonResourceId); // invoke the operation - AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData() + AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData { - Properties = new AddonArcProperties() + Properties = new AddonArcProperties { VCenter = "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg_test/providers/Microsoft.ConnectedVMwarevSphere/VCenters/test-vcenter", }, @@ -201,7 +228,7 @@ public async Task Update_AddonsCreateOrUpdateHCX() AvsPrivateCloudAddonResource avsPrivateCloudAddon = client.GetAvsPrivateCloudAddonResource(avsPrivateCloudAddonResourceId); // invoke the operation - AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData() + AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData { Properties = new AddonHcxProperties("VMware MaaS Cloud Provider (Enterprise)"), }; @@ -237,9 +264,9 @@ public async Task Update_AddonsCreateOrUpdateSRM() AvsPrivateCloudAddonResource avsPrivateCloudAddon = client.GetAvsPrivateCloudAddonResource(avsPrivateCloudAddonResourceId); // invoke the operation - AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData() + AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData { - Properties = new AddonSrmProperties() + Properties = new AddonSrmProperties { LicenseKey = "41915178-A8FF-4A4D-B683-6D735AF5E3F5", }, @@ -276,7 +303,7 @@ public async Task Update_AddonsCreateOrUpdateVR() AvsPrivateCloudAddonResource avsPrivateCloudAddon = client.GetAvsPrivateCloudAddonResource(avsPrivateCloudAddonResourceId); // invoke the operation - AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData() + AvsPrivateCloudAddonData data = new AvsPrivateCloudAddonData { Properties = new AddonVrProperties(1), }; @@ -289,32 +316,5 @@ public async Task Update_AddonsCreateOrUpdateVR() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_AddonsDelete() - { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Addons_Delete.json - // this example is just showing the usage of "Addons_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AvsPrivateCloudAddonResource created on azure - // for more information of creating AvsPrivateCloudAddonResource, please refer to the document of AvsPrivateCloudAddonResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "group1"; - string privateCloudName = "cloud1"; - string addonName = "srm"; - ResourceIdentifier avsPrivateCloudAddonResourceId = AvsPrivateCloudAddonResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, privateCloudName, addonName); - AvsPrivateCloudAddonResource avsPrivateCloudAddon = client.GetAvsPrivateCloudAddonResource(avsPrivateCloudAddonResourceId); - - // invoke the operation - await avsPrivateCloudAddon.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterCollection.cs index ae70618ad2327..f755f73e93547 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AvsPrivateCloudClusterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ClustersList() + public async Task CreateOrUpdate_ClustersCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_List.json - // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_CreateOrUpdate.json + // this example is just showing the usage of "Clusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ClustersList() // get the collection of this AvsPrivateCloudClusterResource AvsPrivateCloudClusterCollection collection = avsPrivateCloud.GetAvsPrivateCloudClusters(); - // invoke the operation and iterate over the result - await foreach (AvsPrivateCloudClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "cluster1"; + AvsPrivateCloudClusterData data = new AvsPrivateCloudClusterData(new AvsSku("AV20")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ClusterSize = 3, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); + AvsPrivateCloudClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_ClustersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ClustersGet() + public async Task GetAll_ClustersList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_Get.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_List.json + // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_ClustersGet() // get the collection of this AvsPrivateCloudClusterResource AvsPrivateCloudClusterCollection collection = avsPrivateCloud.GetAvsPrivateCloudClusters(); - // invoke the operation - string clusterName = "cluster1"; - bool result = await collection.ExistsAsync(clusterName); + // invoke the operation and iterate over the result + await foreach (AvsPrivateCloudClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ClustersGet() + public async Task Exists_ClustersGet() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_Get.json // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_ClustersGet() // invoke the operation string clusterName = "cluster1"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - AvsPrivateCloudClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ClustersCreateOrUpdate() + public async Task GetIfExists_ClustersGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_CreateOrUpdate.json - // this example is just showing the usage of "Clusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_Get.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_ClustersCreateOrUpdate() // invoke the operation string clusterName = "cluster1"; - AvsPrivateCloudClusterData data = new AvsPrivateCloudClusterData(new AvsSku("AV20")) - { - ClusterSize = 3, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); - AvsPrivateCloudClusterResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + AvsPrivateCloudClusterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterResource.cs index 18cb27382faf6..2fefff7379324 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterResource.cs @@ -49,10 +49,10 @@ public async Task Get_ClustersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ClustersUpdate() + public async Task Delete_ClustersDelete() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_Update.json - // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_Delete.json + // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_ClustersUpdate() AvsPrivateCloudClusterResource avsPrivateCloudCluster = client.GetAvsPrivateCloudClusterResource(avsPrivateCloudClusterResourceId); // invoke the operation - AvsPrivateCloudClusterPatch patch = new AvsPrivateCloudClusterPatch() - { - ClusterSize = 4, - }; - ArmOperation lro = await avsPrivateCloudCluster.UpdateAsync(WaitUntil.Completed, patch); - AvsPrivateCloudClusterResource result = lro.Value; + await avsPrivateCloudCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ClustersDelete() + public async Task Update_ClustersUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_Delete.json - // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Clusters_Update.json + // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_ClustersDelete() AvsPrivateCloudClusterResource avsPrivateCloudCluster = client.GetAvsPrivateCloudClusterResource(avsPrivateCloudClusterResourceId); // invoke the operation - await avsPrivateCloudCluster.DeleteAsync(WaitUntil.Completed); + AvsPrivateCloudClusterPatch patch = new AvsPrivateCloudClusterPatch + { + ClusterSize = 4, + }; + ArmOperation lro = await avsPrivateCloudCluster.UpdateAsync(WaitUntil.Completed, patch); + AvsPrivateCloudClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterVirtualMachineCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterVirtualMachineCollection.cs index f5ee6f1361c62..8af53082ba5cc 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterVirtualMachineCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterVirtualMachineCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AvsPrivateCloudClusterVirtualMachineCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualMachinesList() + public async Task Get_VirtualMachinesGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/VirtualMachines_List.json - // this example is just showing the usage of "VirtualMachines_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/VirtualMachines_Get.json + // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_VirtualMachinesList() // get the collection of this AvsPrivateCloudClusterVirtualMachineResource AvsPrivateCloudClusterVirtualMachineCollection collection = avsPrivateCloudCluster.GetAvsPrivateCloudClusterVirtualMachines(); - // invoke the operation and iterate over the result - await foreach (AvsPrivateCloudClusterVirtualMachineResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudClusterVirtualMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string virtualMachineId = "vm-209"; + AvsPrivateCloudClusterVirtualMachineResource result = await collection.GetAsync(virtualMachineId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudClusterVirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualMachinesGet() + public async Task GetAll_VirtualMachinesList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/VirtualMachines_Get.json - // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/VirtualMachines_List.json + // this example is just showing the usage of "VirtualMachines_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_VirtualMachinesGet() // get the collection of this AvsPrivateCloudClusterVirtualMachineResource AvsPrivateCloudClusterVirtualMachineCollection collection = avsPrivateCloudCluster.GetAvsPrivateCloudClusterVirtualMachines(); - // invoke the operation - string virtualMachineId = "vm-209"; - AvsPrivateCloudClusterVirtualMachineResource result = await collection.GetAsync(virtualMachineId); + // invoke the operation and iterate over the result + await foreach (AvsPrivateCloudClusterVirtualMachineResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudClusterVirtualMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudClusterVirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterVirtualMachineResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterVirtualMachineResource.cs index b43d31561a2a9..6ae43e56e9608 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterVirtualMachineResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudClusterVirtualMachineResource.cs @@ -71,7 +71,7 @@ public async Task RestrictMovement_VirtualMachinesRestrictMovement() AvsPrivateCloudClusterVirtualMachineResource avsPrivateCloudClusterVirtualMachine = client.GetAvsPrivateCloudClusterVirtualMachineResource(avsPrivateCloudClusterVirtualMachineResourceId); // invoke the operation - AvsPrivateCloudClusterVirtualMachineRestrictMovement restrictMovement = new AvsPrivateCloudClusterVirtualMachineRestrictMovement() + AvsPrivateCloudClusterVirtualMachineRestrictMovement restrictMovement = new AvsPrivateCloudClusterVirtualMachineRestrictMovement { RestrictMovement = VirtualMachineRestrictMovementState.Enabled, }; diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudCollection.cs index 170a0b8dc9fb0..8dc6fe001434e 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_AvsPrivateCloudCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateCloudsList() + public async Task CreateOrUpdate_PrivateCloudsCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_List.json - // this example is just showing the usage of "PrivateClouds_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_CreateOrUpdate.json + // this example is just showing the usage of "PrivateClouds_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,34 @@ public async Task GetAll_PrivateCloudsList() // get the collection of this AvsPrivateCloudResource AvsPrivateCloudCollection collection = resourceGroupResource.GetAvsPrivateClouds(); - // invoke the operation and iterate over the result - await foreach (AvsPrivateCloudResource item in collection.GetAllAsync()) + // invoke the operation + string privateCloudName = "cloud1"; + AvsPrivateCloudData data = new AvsPrivateCloudData(new AzureLocation("eastus2"), new AvsSku("AV36")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("SystemAssigned"), + ManagementCluster = new AvsManagementCluster + { + ClusterSize = 4, + }, + NetworkBlock = "192.168.48.0/22", + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateCloudName, data); + AvsPrivateCloudResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateCloudsListStretched() + public async Task CreateOrUpdate_PrivateCloudsCreateOrUpdateStretched() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_List_Stretched.json - // this example is just showing the usage of "PrivateClouds_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_CreateOrUpdate_Stretched.json + // this example is just showing the usage of "PrivateClouds_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +84,31 @@ public async Task GetAll_PrivateCloudsListStretched() // get the collection of this AvsPrivateCloudResource AvsPrivateCloudCollection collection = resourceGroupResource.GetAvsPrivateClouds(); - // invoke the operation and iterate over the result - await foreach (AvsPrivateCloudResource item in collection.GetAllAsync()) + // invoke the operation + string privateCloudName = "cloud1"; + AvsPrivateCloudData data = new AvsPrivateCloudData(new AzureLocation("eastus2"), new AvsSku("AV36")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ManagementCluster = new AvsManagementCluster + { + ClusterSize = 4, + }, + Availability = new PrivateCloudAvailabilityProperties + { + Strategy = AvailabilityStrategy.DualZone, + Zone = 1, + SecondaryZone = 2, + }, + NetworkBlock = "192.168.48.0/22", + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateCloudName, data); + AvsPrivateCloudResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -123,9 +146,9 @@ public async Task Get_PrivateCloudsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateCloudsGet() + public async Task Get_PrivateCloudsGetStretched() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get.json + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get_Stretched.json // this example is just showing the usage of "PrivateClouds_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -145,17 +168,21 @@ public async Task Exists_PrivateCloudsGet() // invoke the operation string privateCloudName = "cloud1"; - bool result = await collection.ExistsAsync(privateCloudName); + AvsPrivateCloudResource result = await collection.GetAsync(privateCloudName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateCloudsGet() + public async Task GetAll_PrivateCloudsList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get.json - // this example is just showing the usage of "PrivateClouds_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_List.json + // this example is just showing the usage of "PrivateClouds_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,31 +199,25 @@ public async Task GetIfExists_PrivateCloudsGet() // get the collection of this AvsPrivateCloudResource AvsPrivateCloudCollection collection = resourceGroupResource.GetAvsPrivateClouds(); - // invoke the operation - string privateCloudName = "cloud1"; - NullableResponse response = await collection.GetIfExistsAsync(privateCloudName); - AvsPrivateCloudResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (AvsPrivateCloudResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AvsPrivateCloudData resourceData = result.Data; + AvsPrivateCloudData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateCloudsGetStretched() + public async Task GetAll_PrivateCloudsListStretched() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get_Stretched.json - // this example is just showing the usage of "PrivateClouds_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_List_Stretched.json + // this example is just showing the usage of "PrivateClouds_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,22 +234,24 @@ public async Task Get_PrivateCloudsGetStretched() // get the collection of this AvsPrivateCloudResource AvsPrivateCloudCollection collection = resourceGroupResource.GetAvsPrivateClouds(); - // invoke the operation - string privateCloudName = "cloud1"; - AvsPrivateCloudResource result = await collection.GetAsync(privateCloudName); + // invoke the operation and iterate over the result + await foreach (AvsPrivateCloudResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateCloudsGetStretched() + public async Task Exists_PrivateCloudsGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get_Stretched.json + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get.json // this example is just showing the usage of "PrivateClouds_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -255,7 +278,7 @@ public async Task Exists_PrivateCloudsGetStretched() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateCloudsGetStretched() + public async Task Exists_PrivateCloudsGetStretched() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get_Stretched.json // this example is just showing the usage of "PrivateClouds_Get" operation, for the dependent resources, they will have to be created separately. @@ -277,29 +300,17 @@ public async Task GetIfExists_PrivateCloudsGetStretched() // invoke the operation string privateCloudName = "cloud1"; - NullableResponse response = await collection.GetIfExistsAsync(privateCloudName); - AvsPrivateCloudResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateCloudName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateCloudsCreateOrUpdate() + public async Task GetIfExists_PrivateCloudsGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_CreateOrUpdate.json - // this example is just showing the usage of "PrivateClouds_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get.json + // this example is just showing the usage of "PrivateClouds_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -318,34 +329,29 @@ public async Task CreateOrUpdate_PrivateCloudsCreateOrUpdate() // invoke the operation string privateCloudName = "cloud1"; - AvsPrivateCloudData data = new AvsPrivateCloudData(new AzureLocation("eastus2"), new AvsSku("AV36")) - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - ManagementCluster = new AvsManagementCluster() - { - ClusterSize = 4, - }, - NetworkBlock = "192.168.48.0/22", - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateCloudName, data); - AvsPrivateCloudResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateCloudName); + AvsPrivateCloudResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateCloudsCreateOrUpdateStretched() + public async Task GetIfExists_PrivateCloudsGetStretched() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_CreateOrUpdate_Stretched.json - // this example is just showing the usage of "PrivateClouds_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get_Stretched.json + // this example is just showing the usage of "PrivateClouds_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -364,31 +370,21 @@ public async Task CreateOrUpdate_PrivateCloudsCreateOrUpdateStretched() // invoke the operation string privateCloudName = "cloud1"; - AvsPrivateCloudData data = new AvsPrivateCloudData(new AzureLocation("eastus2"), new AvsSku("AV36")) - { - ManagementCluster = new AvsManagementCluster() - { - ClusterSize = 4, - }, - Availability = new PrivateCloudAvailabilityProperties() - { - Strategy = AvailabilityStrategy.DualZone, - Zone = 1, - SecondaryZone = 2, - }, - NetworkBlock = "192.168.48.0/22", - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateCloudName, data); - AvsPrivateCloudResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateCloudName); + AvsPrivateCloudResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudDatastoreCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudDatastoreCollection.cs index 8f987679471c6..1deb06b8f8cf4 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudDatastoreCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudDatastoreCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AvsPrivateCloudDatastoreCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DatastoresList() + public async Task CreateOrUpdate_DatastoresCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_List.json - // this example is just showing the usage of "Datastores_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_CreateOrUpdate.json + // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_DatastoresList() // get the collection of this AvsPrivateCloudDatastoreResource AvsPrivateCloudDatastoreCollection collection = avsPrivateCloudCluster.GetAvsPrivateCloudDatastores(); - // invoke the operation and iterate over the result - await foreach (AvsPrivateCloudDatastoreResource item in collection.GetAllAsync()) + // invoke the operation + string datastoreName = "datastore1"; + AvsPrivateCloudDatastoreData data = new AvsPrivateCloudDatastoreData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudDatastoreData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + NetAppVolumeId = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/ResourceGroup1/providers/Microsoft.NetApp/netAppAccounts/NetAppAccount1/capacityPools/CapacityPool1/volumes/NFSVol1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, datastoreName, data); + AvsPrivateCloudDatastoreResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudDatastoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_DatastoresGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DatastoresGet() + public async Task GetAll_DatastoresList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_Get.json - // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_List.json + // this example is just showing the usage of "Datastores_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +114,22 @@ public async Task Exists_DatastoresGet() // get the collection of this AvsPrivateCloudDatastoreResource AvsPrivateCloudDatastoreCollection collection = avsPrivateCloudCluster.GetAvsPrivateCloudDatastores(); - // invoke the operation - string datastoreName = "datastore1"; - bool result = await collection.ExistsAsync(datastoreName); + // invoke the operation and iterate over the result + await foreach (AvsPrivateCloudDatastoreResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudDatastoreData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DatastoresGet() + public async Task Exists_DatastoresGet() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_Get.json // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +153,17 @@ public async Task GetIfExists_DatastoresGet() // invoke the operation string datastoreName = "datastore1"; - NullableResponse response = await collection.GetIfExistsAsync(datastoreName); - AvsPrivateCloudDatastoreResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(datastoreName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudDatastoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DatastoresCreateOrUpdate() + public async Task GetIfExists_DatastoresGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_CreateOrUpdate.json - // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_Get.json + // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +184,21 @@ public async Task CreateOrUpdate_DatastoresCreateOrUpdate() // invoke the operation string datastoreName = "datastore1"; - AvsPrivateCloudDatastoreData data = new AvsPrivateCloudDatastoreData() - { - NetAppVolumeId = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/ResourceGroup1/providers/Microsoft.NetApp/netAppAccounts/NetAppAccount1/capacityPools/CapacityPool1/volumes/NFSVol1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, datastoreName, data); - AvsPrivateCloudDatastoreResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(datastoreName); + AvsPrivateCloudDatastoreResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudDatastoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudDatastoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudDatastoreResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudDatastoreResource.cs index bea906bca61a7..2b9cbe973f892 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudDatastoreResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudDatastoreResource.cs @@ -49,10 +49,10 @@ public async Task Get_DatastoresGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DatastoresCreateOrUpdate() + public async Task Delete_DatastoresDelete() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_CreateOrUpdate.json - // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_Delete.json + // this example is just showing the usage of "Datastores_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_DatastoresCreateOrUpdate() AvsPrivateCloudDatastoreResource avsPrivateCloudDatastore = client.GetAvsPrivateCloudDatastoreResource(avsPrivateCloudDatastoreResourceId); // invoke the operation - AvsPrivateCloudDatastoreData data = new AvsPrivateCloudDatastoreData() - { - NetAppVolumeId = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/ResourceGroup1/providers/Microsoft.NetApp/netAppAccounts/NetAppAccount1/capacityPools/CapacityPool1/volumes/NFSVol1"), - }; - ArmOperation lro = await avsPrivateCloudDatastore.UpdateAsync(WaitUntil.Completed, data); - AvsPrivateCloudDatastoreResource result = lro.Value; + await avsPrivateCloudDatastore.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudDatastoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DatastoresDelete() + public async Task Update_DatastoresCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_Delete.json - // this example is just showing the usage of "Datastores_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Datastores_CreateOrUpdate.json + // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +98,18 @@ public async Task Delete_DatastoresDelete() AvsPrivateCloudDatastoreResource avsPrivateCloudDatastore = client.GetAvsPrivateCloudDatastoreResource(avsPrivateCloudDatastoreResourceId); // invoke the operation - await avsPrivateCloudDatastore.DeleteAsync(WaitUntil.Completed); + AvsPrivateCloudDatastoreData data = new AvsPrivateCloudDatastoreData + { + NetAppVolumeId = new ResourceIdentifier("/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/ResourceGroup1/providers/Microsoft.NetApp/netAppAccounts/NetAppAccount1/capacityPools/CapacityPool1/volumes/NFSVol1"), + }; + ArmOperation lro = await avsPrivateCloudDatastore.UpdateAsync(WaitUntil.Completed, data); + AvsPrivateCloudDatastoreResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudDatastoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudResource.cs index 23a6f3ea54a4c..34413550de081 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_AvsPrivateCloudResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Avs.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Avs.Samples @@ -20,71 +19,39 @@ public partial class Sample_AvsPrivateCloudResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAvsPrivateClouds_PrivateCloudsListInSubscription() - { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_ListInSubscription.json - // this example is just showing the usage of "PrivateClouds_ListInSubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AvsPrivateCloudResource item in subscriptionResource.GetAvsPrivateCloudsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAvsPrivateClouds_PrivateCloudsListInSubscriptionStretched() + public async Task Get_PrivateCloudsGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_ListInSubscription_Stretched.json - // this example is just showing the usage of "PrivateClouds_ListInSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get.json + // this example is just showing the usage of "PrivateClouds_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this AvsPrivateCloudResource created on azure + // for more information of creating AvsPrivateCloudResource, please refer to the document of AvsPrivateCloudResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "group1"; + string privateCloudName = "cloud1"; + ResourceIdentifier avsPrivateCloudResourceId = AvsPrivateCloudResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, privateCloudName); + AvsPrivateCloudResource avsPrivateCloud = client.GetAvsPrivateCloudResource(avsPrivateCloudResourceId); - // invoke the operation and iterate over the result - await foreach (AvsPrivateCloudResource item in subscriptionResource.GetAvsPrivateCloudsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + AvsPrivateCloudResource result = await avsPrivateCloud.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateCloudsGet() + public async Task Get_PrivateCloudsGetStretched() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get.json + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get_Stretched.json // this example is just showing the usage of "PrivateClouds_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -112,10 +79,10 @@ public async Task Get_PrivateCloudsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateCloudsGetStretched() + public async Task Delete_PrivateCloudsDelete() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Get_Stretched.json - // this example is just showing the usage of "PrivateClouds_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Delete.json + // this example is just showing the usage of "PrivateClouds_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,13 +98,9 @@ public async Task Get_PrivateCloudsGetStretched() AvsPrivateCloudResource avsPrivateCloud = client.GetAvsPrivateCloudResource(avsPrivateCloudResourceId); // invoke the operation - AvsPrivateCloudResource result = await avsPrivateCloud.GetAsync(); + await avsPrivateCloud.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AvsPrivateCloudData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -161,17 +124,17 @@ public async Task Update_PrivateCloudsUpdate() AvsPrivateCloudResource avsPrivateCloud = client.GetAvsPrivateCloudResource(avsPrivateCloudResourceId); // invoke the operation - AvsPrivateCloudPatch patch = new AvsPrivateCloudPatch() + AvsPrivateCloudPatch patch = new AvsPrivateCloudPatch { Identity = new ManagedServiceIdentity("None"), - ManagementCluster = new AvsManagementCluster() + ManagementCluster = new AvsManagementCluster { ClusterSize = 4, }, - Encryption = new CustomerManagedEncryption() + Encryption = new CustomerManagedEncryption { Status = AvsEncryptionState.Enabled, - KeyVaultProperties = new AvsEncryptionKeyVaultProperties() + KeyVaultProperties = new AvsEncryptionKeyVaultProperties { KeyName = "keyname1", KeyVersion = "ver1.0", @@ -210,9 +173,9 @@ public async Task Update_PrivateCloudsUpdateStretched() AvsPrivateCloudResource avsPrivateCloud = client.GetAvsPrivateCloudResource(avsPrivateCloudResourceId); // invoke the operation - AvsPrivateCloudPatch patch = new AvsPrivateCloudPatch() + AvsPrivateCloudPatch patch = new AvsPrivateCloudPatch { - ManagementCluster = new AvsManagementCluster() + ManagementCluster = new AvsManagementCluster { ClusterSize = 4, }, @@ -227,32 +190,6 @@ public async Task Update_PrivateCloudsUpdateStretched() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateCloudsDelete() - { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_Delete.json - // this example is just showing the usage of "PrivateClouds_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AvsPrivateCloudResource created on azure - // for more information of creating AvsPrivateCloudResource, please refer to the document of AvsPrivateCloudResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "group1"; - string privateCloudName = "cloud1"; - ResourceIdentifier avsPrivateCloudResourceId = AvsPrivateCloudResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, privateCloudName); - AvsPrivateCloudResource avsPrivateCloud = client.GetAvsPrivateCloudResource(avsPrivateCloudResourceId); - - // invoke the operation - await avsPrivateCloud.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetAdminCredentials_PrivateCloudsListAdminCredentials() diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ExpressRouteAuthorizationCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ExpressRouteAuthorizationCollection.cs index e47bd215cf1ee..d3fbf08a0793d 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ExpressRouteAuthorizationCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ExpressRouteAuthorizationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ExpressRouteAuthorizationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AuthorizationsList() + public async Task CreateOrUpdate_AuthorizationsCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_List.json - // this example is just showing the usage of "Authorizations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_CreateOrUpdate.json + // this example is just showing the usage of "Authorizations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_AuthorizationsList() // get the collection of this ExpressRouteAuthorizationResource ExpressRouteAuthorizationCollection collection = avsPrivateCloud.GetExpressRouteAuthorizations(); - // invoke the operation and iterate over the result - await foreach (ExpressRouteAuthorizationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteAuthorizationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string authorizationName = "authorization1"; + ExpressRouteAuthorizationData data = new ExpressRouteAuthorizationData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationName, data); + ExpressRouteAuthorizationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_AuthorizationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AuthorizationsGet() + public async Task GetAll_AuthorizationsList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_Get.json - // this example is just showing the usage of "Authorizations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_List.json + // this example is just showing the usage of "Authorizations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_AuthorizationsGet() // get the collection of this ExpressRouteAuthorizationResource ExpressRouteAuthorizationCollection collection = avsPrivateCloud.GetExpressRouteAuthorizations(); - // invoke the operation - string authorizationName = "authorization1"; - bool result = await collection.ExistsAsync(authorizationName); + // invoke the operation and iterate over the result + await foreach (ExpressRouteAuthorizationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteAuthorizationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AuthorizationsGet() + public async Task Exists_AuthorizationsGet() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_Get.json // this example is just showing the usage of "Authorizations_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_AuthorizationsGet() // invoke the operation string authorizationName = "authorization1"; - NullableResponse response = await collection.GetIfExistsAsync(authorizationName); - ExpressRouteAuthorizationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(authorizationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteAuthorizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AuthorizationsCreateOrUpdate() + public async Task GetIfExists_AuthorizationsGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_CreateOrUpdate.json - // this example is just showing the usage of "Authorizations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_Get.json + // this example is just showing the usage of "Authorizations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_AuthorizationsCreateOrUpdate() // invoke the operation string authorizationName = "authorization1"; - ExpressRouteAuthorizationData data = new ExpressRouteAuthorizationData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationName, data); - ExpressRouteAuthorizationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(authorizationName); + ExpressRouteAuthorizationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteAuthorizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ExpressRouteAuthorizationResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ExpressRouteAuthorizationResource.cs index 272a824717af9..89599a692576d 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ExpressRouteAuthorizationResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ExpressRouteAuthorizationResource.cs @@ -48,10 +48,10 @@ public async Task Get_AuthorizationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AuthorizationsCreateOrUpdate() + public async Task Delete_AuthorizationsDelete() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_CreateOrUpdate.json - // this example is just showing the usage of "Authorizations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_Delete.json + // this example is just showing the usage of "Authorizations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,23 +68,17 @@ public async Task Update_AuthorizationsCreateOrUpdate() ExpressRouteAuthorizationResource expressRouteAuthorization = client.GetExpressRouteAuthorizationResource(expressRouteAuthorizationResourceId); // invoke the operation - ExpressRouteAuthorizationData data = new ExpressRouteAuthorizationData(); - ArmOperation lro = await expressRouteAuthorization.UpdateAsync(WaitUntil.Completed, data); - ExpressRouteAuthorizationResource result = lro.Value; + await expressRouteAuthorization.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteAuthorizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AuthorizationsDelete() + public async Task Update_AuthorizationsCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_Delete.json - // this example is just showing the usage of "Authorizations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/Authorizations_CreateOrUpdate.json + // this example is just showing the usage of "Authorizations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +95,15 @@ public async Task Delete_AuthorizationsDelete() ExpressRouteAuthorizationResource expressRouteAuthorization = client.GetExpressRouteAuthorizationResource(expressRouteAuthorizationResourceId); // invoke the operation - await expressRouteAuthorization.DeleteAsync(WaitUntil.Completed); + ExpressRouteAuthorizationData data = new ExpressRouteAuthorizationData(); + ArmOperation lro = await expressRouteAuthorization.UpdateAsync(WaitUntil.Completed, data); + ExpressRouteAuthorizationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_GlobalReachConnectionCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_GlobalReachConnectionCollection.cs index 039211615dd50..9640f2353d2a5 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_GlobalReachConnectionCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_GlobalReachConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_GlobalReachConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GlobalReachConnectionsList() + public async Task CreateOrUpdate_GlobalReachConnectionsCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_List.json - // this example is just showing the usage of "GlobalReachConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_CreateOrUpdate.json + // this example is just showing the usage of "GlobalReachConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_GlobalReachConnectionsList() // get the collection of this GlobalReachConnectionResource GlobalReachConnectionCollection collection = avsPrivateCloud.GetGlobalReachConnections(); - // invoke the operation and iterate over the result - await foreach (GlobalReachConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string globalReachConnectionName = "connection1"; + GlobalReachConnectionData data = new GlobalReachConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalReachConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AuthorizationKey = "01010101-0101-0101-0101-010101010101", + PeerExpressRouteCircuit = new ResourceIdentifier("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/mygroup/providers/Microsoft.Network/expressRouteCircuits/mypeer"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, globalReachConnectionName, data); + GlobalReachConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalReachConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_GlobalReachConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GlobalReachConnectionsGet() + public async Task GetAll_GlobalReachConnectionsList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_Get.json - // this example is just showing the usage of "GlobalReachConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_List.json + // this example is just showing the usage of "GlobalReachConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_GlobalReachConnectionsGet() // get the collection of this GlobalReachConnectionResource GlobalReachConnectionCollection collection = avsPrivateCloud.GetGlobalReachConnections(); - // invoke the operation - string globalReachConnectionName = "connection1"; - bool result = await collection.ExistsAsync(globalReachConnectionName); + // invoke the operation and iterate over the result + await foreach (GlobalReachConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalReachConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GlobalReachConnectionsGet() + public async Task Exists_GlobalReachConnectionsGet() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_Get.json // this example is just showing the usage of "GlobalReachConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_GlobalReachConnectionsGet() // invoke the operation string globalReachConnectionName = "connection1"; - NullableResponse response = await collection.GetIfExistsAsync(globalReachConnectionName); - GlobalReachConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(globalReachConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalReachConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GlobalReachConnectionsCreateOrUpdate() + public async Task GetIfExists_GlobalReachConnectionsGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_CreateOrUpdate.json - // this example is just showing the usage of "GlobalReachConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_Get.json + // this example is just showing the usage of "GlobalReachConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,19 +180,21 @@ public async Task CreateOrUpdate_GlobalReachConnectionsCreateOrUpdate() // invoke the operation string globalReachConnectionName = "connection1"; - GlobalReachConnectionData data = new GlobalReachConnectionData() - { - AuthorizationKey = "01010101-0101-0101-0101-010101010101", - PeerExpressRouteCircuit = new ResourceIdentifier("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/mygroup/providers/Microsoft.Network/expressRouteCircuits/mypeer"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, globalReachConnectionName, data); - GlobalReachConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(globalReachConnectionName); + GlobalReachConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalReachConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalReachConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_GlobalReachConnectionResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_GlobalReachConnectionResource.cs index 3fb83e3d643b7..51034d6993d47 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_GlobalReachConnectionResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_GlobalReachConnectionResource.cs @@ -48,10 +48,10 @@ public async Task Get_GlobalReachConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GlobalReachConnectionsCreateOrUpdate() + public async Task Delete_GlobalReachConnectionsDelete() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_CreateOrUpdate.json - // this example is just showing the usage of "GlobalReachConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_Delete.json + // this example is just showing the usage of "GlobalReachConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,27 +68,17 @@ public async Task Update_GlobalReachConnectionsCreateOrUpdate() GlobalReachConnectionResource globalReachConnection = client.GetGlobalReachConnectionResource(globalReachConnectionResourceId); // invoke the operation - GlobalReachConnectionData data = new GlobalReachConnectionData() - { - AuthorizationKey = "01010101-0101-0101-0101-010101010101", - PeerExpressRouteCircuit = new ResourceIdentifier("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/mygroup/providers/Microsoft.Network/expressRouteCircuits/mypeer"), - }; - ArmOperation lro = await globalReachConnection.UpdateAsync(WaitUntil.Completed, data); - GlobalReachConnectionResource result = lro.Value; + await globalReachConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - GlobalReachConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_GlobalReachConnectionsDelete() + public async Task Update_GlobalReachConnectionsCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_Delete.json - // this example is just showing the usage of "GlobalReachConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/GlobalReachConnections_CreateOrUpdate.json + // this example is just showing the usage of "GlobalReachConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +95,19 @@ public async Task Delete_GlobalReachConnectionsDelete() GlobalReachConnectionResource globalReachConnection = client.GetGlobalReachConnectionResource(globalReachConnectionResourceId); // invoke the operation - await globalReachConnection.DeleteAsync(WaitUntil.Completed); + GlobalReachConnectionData data = new GlobalReachConnectionData + { + AuthorizationKey = "01010101-0101-0101-0101-010101010101", + PeerExpressRouteCircuit = new ResourceIdentifier("/subscriptions/12341234-1234-1234-1234-123412341234/resourceGroups/mygroup/providers/Microsoft.Network/expressRouteCircuits/mypeer"), + }; + ArmOperation lro = await globalReachConnection.UpdateAsync(WaitUntil.Completed, data); + GlobalReachConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + GlobalReachConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_HcxEnterpriseSiteCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_HcxEnterpriseSiteCollection.cs index b4fbe50296e65..c879da920d4e6 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_HcxEnterpriseSiteCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_HcxEnterpriseSiteCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HcxEnterpriseSiteCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_HcxEnterpriseSitesList() + public async Task CreateOrUpdate_HcxEnterpriseSitesCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_List.json - // this example is just showing the usage of "HcxEnterpriseSites_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_CreateOrUpdate.json + // this example is just showing the usage of "HcxEnterpriseSites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_HcxEnterpriseSitesList() // get the collection of this HcxEnterpriseSiteResource HcxEnterpriseSiteCollection collection = avsPrivateCloud.GetHcxEnterpriseSites(); - // invoke the operation and iterate over the result - await foreach (HcxEnterpriseSiteResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HcxEnterpriseSiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string hcxEnterpriseSiteName = "site1"; + HcxEnterpriseSiteData data = new HcxEnterpriseSiteData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hcxEnterpriseSiteName, data); + HcxEnterpriseSiteResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HcxEnterpriseSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_HcxEnterpriseSitesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_HcxEnterpriseSitesGet() + public async Task GetAll_HcxEnterpriseSitesList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_Get.json - // this example is just showing the usage of "HcxEnterpriseSites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_List.json + // this example is just showing the usage of "HcxEnterpriseSites_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_HcxEnterpriseSitesGet() // get the collection of this HcxEnterpriseSiteResource HcxEnterpriseSiteCollection collection = avsPrivateCloud.GetHcxEnterpriseSites(); - // invoke the operation - string hcxEnterpriseSiteName = "site1"; - bool result = await collection.ExistsAsync(hcxEnterpriseSiteName); + // invoke the operation and iterate over the result + await foreach (HcxEnterpriseSiteResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HcxEnterpriseSiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HcxEnterpriseSitesGet() + public async Task Exists_HcxEnterpriseSitesGet() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_Get.json // this example is just showing the usage of "HcxEnterpriseSites_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_HcxEnterpriseSitesGet() // invoke the operation string hcxEnterpriseSiteName = "site1"; - NullableResponse response = await collection.GetIfExistsAsync(hcxEnterpriseSiteName); - HcxEnterpriseSiteResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(hcxEnterpriseSiteName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HcxEnterpriseSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_HcxEnterpriseSitesCreateOrUpdate() + public async Task GetIfExists_HcxEnterpriseSitesGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_CreateOrUpdate.json - // this example is just showing the usage of "HcxEnterpriseSites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_Get.json + // this example is just showing the usage of "HcxEnterpriseSites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_HcxEnterpriseSitesCreateOrUpdate() // invoke the operation string hcxEnterpriseSiteName = "site1"; - HcxEnterpriseSiteData data = new HcxEnterpriseSiteData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, hcxEnterpriseSiteName, data); - HcxEnterpriseSiteResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(hcxEnterpriseSiteName); + HcxEnterpriseSiteResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HcxEnterpriseSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HcxEnterpriseSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_HcxEnterpriseSiteResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_HcxEnterpriseSiteResource.cs index 07594630e3017..d64b015d47dcb 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_HcxEnterpriseSiteResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_HcxEnterpriseSiteResource.cs @@ -48,10 +48,10 @@ public async Task Get_HcxEnterpriseSitesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_HcxEnterpriseSitesCreateOrUpdate() + public async Task Delete_HcxEnterpriseSitesDelete() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_CreateOrUpdate.json - // this example is just showing the usage of "HcxEnterpriseSites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_Delete.json + // this example is just showing the usage of "HcxEnterpriseSites_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,23 +68,17 @@ public async Task Update_HcxEnterpriseSitesCreateOrUpdate() HcxEnterpriseSiteResource hcxEnterpriseSite = client.GetHcxEnterpriseSiteResource(hcxEnterpriseSiteResourceId); // invoke the operation - HcxEnterpriseSiteData data = new HcxEnterpriseSiteData(); - ArmOperation lro = await hcxEnterpriseSite.UpdateAsync(WaitUntil.Completed, data); - HcxEnterpriseSiteResource result = lro.Value; + await hcxEnterpriseSite.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HcxEnterpriseSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_HcxEnterpriseSitesDelete() + public async Task Update_HcxEnterpriseSitesCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_Delete.json - // this example is just showing the usage of "HcxEnterpriseSites_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/HcxEnterpriseSites_CreateOrUpdate.json + // this example is just showing the usage of "HcxEnterpriseSites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +95,15 @@ public async Task Delete_HcxEnterpriseSitesDelete() HcxEnterpriseSiteResource hcxEnterpriseSite = client.GetHcxEnterpriseSiteResource(hcxEnterpriseSiteResourceId); // invoke the operation - await hcxEnterpriseSite.DeleteAsync(WaitUntil.Completed); + HcxEnterpriseSiteData data = new HcxEnterpriseSiteData(); + ArmOperation lro = await hcxEnterpriseSite.UpdateAsync(WaitUntil.Completed, data); + HcxEnterpriseSiteResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HcxEnterpriseSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_IscsiPathResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_IscsiPathResource.cs index c4793c3c607b7..cc4a7e4f5b247 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_IscsiPathResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_IscsiPathResource.cs @@ -47,10 +47,10 @@ public async Task Get_IscsiPathsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_IscsiPathsCreateOrUpdate() + public async Task Delete_IscsiPathsDelete() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/IscsiPaths_CreateOrUpdate.json - // this example is just showing the usage of "IscsiPaths_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/IscsiPaths_Delete.json + // this example is just showing the usage of "IscsiPaths_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,26 +66,17 @@ public async Task CreateOrUpdate_IscsiPathsCreateOrUpdate() IscsiPathResource iscsiPath = client.GetIscsiPathResource(iscsiPathResourceId); // invoke the operation - IscsiPathData data = new IscsiPathData() - { - NetworkBlock = "192.168.0.0/24", - }; - ArmOperation lro = await iscsiPath.CreateOrUpdateAsync(WaitUntil.Completed, data); - IscsiPathResource result = lro.Value; + await iscsiPath.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IscsiPathData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_IscsiPathsDelete() + public async Task CreateOrUpdate_IscsiPathsCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/IscsiPaths_Delete.json - // this example is just showing the usage of "IscsiPaths_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/IscsiPaths_CreateOrUpdate.json + // this example is just showing the usage of "IscsiPaths_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +92,18 @@ public async Task Delete_IscsiPathsDelete() IscsiPathResource iscsiPath = client.GetIscsiPathResource(iscsiPathResourceId); // invoke the operation - await iscsiPath.DeleteAsync(WaitUntil.Completed); + IscsiPathData data = new IscsiPathData + { + NetworkBlock = "192.168.0.0/24", + }; + ArmOperation lro = await iscsiPath.CreateOrUpdateAsync(WaitUntil.Completed, data); + IscsiPathResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IscsiPathData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_PlacementPolicyCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_PlacementPolicyCollection.cs index 42e8d170153f6..e21e07392afc8 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_PlacementPolicyCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_PlacementPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PlacementPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PlacementPoliciesList() + public async Task CreateOrUpdate_PlacementPoliciesCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_List.json - // this example is just showing the usage of "PlacementPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_CreateOrUpdate.json + // this example is just showing the usage of "PlacementPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,24 @@ public async Task GetAll_PlacementPoliciesList() // get the collection of this PlacementPolicyResource PlacementPolicyCollection collection = avsPrivateCloudCluster.GetPlacementPolicies(); - // invoke the operation and iterate over the result - await foreach (PlacementPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string placementPolicyName = "policy1"; + PlacementPolicyData data = new PlacementPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlacementPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new VmHostPlacementPolicyProperties(new ResourceIdentifier[] { new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-128"), new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-256") }, new string[] { "fakehost22.nyc1.kubernetes.center", "fakehost23.nyc1.kubernetes.center", "fakehost24.nyc1.kubernetes.center" }, AvsPlacementPolicyAffinityType.AntiAffinity) + { + AffinityStrength = VmHostPlacementPolicyAffinityStrength.Must, + AzureHybridBenefitType = AzureHybridBenefitType.SqlHost, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, placementPolicyName, data); + PlacementPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlacementPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +97,10 @@ public async Task Get_PlacementPoliciesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PlacementPoliciesGet() + public async Task GetAll_PlacementPoliciesList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_Get.json - // this example is just showing the usage of "PlacementPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_List.json + // this example is just showing the usage of "PlacementPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +119,22 @@ public async Task Exists_PlacementPoliciesGet() // get the collection of this PlacementPolicyResource PlacementPolicyCollection collection = avsPrivateCloudCluster.GetPlacementPolicies(); - // invoke the operation - string placementPolicyName = "policy1"; - bool result = await collection.ExistsAsync(placementPolicyName); + // invoke the operation and iterate over the result + await foreach (PlacementPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlacementPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PlacementPoliciesGet() + public async Task Exists_PlacementPoliciesGet() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_Get.json // this example is just showing the usage of "PlacementPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +158,17 @@ public async Task GetIfExists_PlacementPoliciesGet() // invoke the operation string placementPolicyName = "policy1"; - NullableResponse response = await collection.GetIfExistsAsync(placementPolicyName); - PlacementPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(placementPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlacementPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PlacementPoliciesCreateOrUpdate() + public async Task GetIfExists_PlacementPoliciesGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_CreateOrUpdate.json - // this example is just showing the usage of "PlacementPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_Get.json + // this example is just showing the usage of "PlacementPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,28 +189,21 @@ public async Task CreateOrUpdate_PlacementPoliciesCreateOrUpdate() // invoke the operation string placementPolicyName = "policy1"; - PlacementPolicyData data = new PlacementPolicyData() - { - Properties = new VmHostPlacementPolicyProperties(new ResourceIdentifier[] + NullableResponse response = await collection.GetIfExistsAsync(placementPolicyName); + PlacementPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-128"),new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-256") - }, new string[] + Console.WriteLine("Succeeded with null as result"); + } + else { -"fakehost22.nyc1.kubernetes.center","fakehost23.nyc1.kubernetes.center","fakehost24.nyc1.kubernetes.center" - }, AvsPlacementPolicyAffinityType.AntiAffinity) - { - AffinityStrength = VmHostPlacementPolicyAffinityStrength.Must, - AzureHybridBenefitType = AzureHybridBenefitType.SqlHost, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, placementPolicyName, data); - PlacementPolicyResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlacementPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlacementPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_PlacementPolicyResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_PlacementPolicyResource.cs index ae728696eea2d..883c68646d912 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_PlacementPolicyResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_PlacementPolicyResource.cs @@ -50,10 +50,10 @@ public async Task Get_PlacementPoliciesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PlacementPoliciesUpdate() + public async Task Delete_PlacementPoliciesDelete() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_Update.json - // this example is just showing the usage of "PlacementPolicies_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_Delete.json + // this example is just showing the usage of "PlacementPolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,36 +71,17 @@ public async Task Update_PlacementPoliciesUpdate() PlacementPolicyResource placementPolicy = client.GetPlacementPolicyResource(placementPolicyResourceId); // invoke the operation - PlacementPolicyPatch patch = new PlacementPolicyPatch() - { - State = PlacementPolicyState.Disabled, - VmMembers = -{ -new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-128"),new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-256") -}, - HostMembers = -{ -"fakehost22.nyc1.kubernetes.center","fakehost23.nyc1.kubernetes.center","fakehost24.nyc1.kubernetes.center" -}, - AffinityStrength = VmHostPlacementPolicyAffinityStrength.Must, - AzureHybridBenefitType = AzureHybridBenefitType.SqlHost, - }; - ArmOperation lro = await placementPolicy.UpdateAsync(WaitUntil.Completed, patch); - PlacementPolicyResource result = lro.Value; + await placementPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PlacementPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PlacementPoliciesDelete() + public async Task Update_PlacementPoliciesUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_Delete.json - // this example is just showing the usage of "PlacementPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PlacementPolicies_Update.json + // this example is just showing the usage of "PlacementPolicies_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,9 +99,22 @@ public async Task Delete_PlacementPoliciesDelete() PlacementPolicyResource placementPolicy = client.GetPlacementPolicyResource(placementPolicyResourceId); // invoke the operation - await placementPolicy.DeleteAsync(WaitUntil.Completed); + PlacementPolicyPatch patch = new PlacementPolicyPatch + { + State = PlacementPolicyState.Disabled, + VmMembers = { new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-128"), new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/clusters/cluster1/virtualMachines/vm-256") }, + HostMembers = { "fakehost22.nyc1.kubernetes.center", "fakehost23.nyc1.kubernetes.center", "fakehost24.nyc1.kubernetes.center" }, + AffinityStrength = VmHostPlacementPolicyAffinityStrength.Must, + AzureHybridBenefitType = AzureHybridBenefitType.SqlHost, + }; + ArmOperation lro = await placementPolicy.UpdateAsync(WaitUntil.Completed, patch); + PlacementPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PlacementPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptCmdletCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptCmdletCollection.cs index 2f4890f7dea58..45bb7eb51b650 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptCmdletCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptCmdletCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ScriptCmdletCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScriptCmdletsList() + public async Task Get_ScriptCmdletsGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptCmdlets_List.json - // this example is just showing the usage of "ScriptCmdlets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptCmdlets_Get.json + // this example is just showing the usage of "ScriptCmdlets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ScriptCmdletsList() // get the collection of this ScriptCmdletResource ScriptCmdletCollection collection = scriptPackage.GetScriptCmdlets(); - // invoke the operation and iterate over the result - await foreach (ScriptCmdletResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScriptCmdletData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scriptCmdletName = "New-ExternalSsoDomain"; + ScriptCmdletResource result = await collection.GetAsync(scriptCmdletName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScriptCmdletData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ScriptCmdletsGet() + public async Task GetAll_ScriptCmdletsList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptCmdlets_Get.json - // this example is just showing the usage of "ScriptCmdlets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptCmdlets_List.json + // this example is just showing the usage of "ScriptCmdlets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_ScriptCmdletsGet() // get the collection of this ScriptCmdletResource ScriptCmdletCollection collection = scriptPackage.GetScriptCmdlets(); - // invoke the operation - string scriptCmdletName = "New-ExternalSsoDomain"; - ScriptCmdletResource result = await collection.GetAsync(scriptCmdletName); + // invoke the operation and iterate over the result + await foreach (ScriptCmdletResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScriptCmdletData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScriptCmdletData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptExecutionCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptExecutionCollection.cs index c0dea1a5ec3a3..7a6e4fb2f0af2 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptExecutionCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptExecutionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ScriptExecutionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScriptExecutionsList() + public async Task CreateOrUpdate_ScriptExecutionsCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_List.json - // this example is just showing the usage of "ScriptExecutions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_CreateOrUpdate.json + // this example is just showing the usage of "ScriptExecutions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,33 @@ public async Task GetAll_ScriptExecutionsList() // get the collection of this ScriptExecutionResource ScriptExecutionCollection collection = avsPrivateCloud.GetScriptExecutions(); - // invoke the operation and iterate over the result - await foreach (ScriptExecutionResource item in collection.GetAllAsync()) + // invoke the operation + string scriptExecutionName = "addSsoServer"; + ScriptExecutionData data = new ScriptExecutionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScriptExecutionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ScriptCmdletId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/scriptPackages/AVS.PowerCommands@1.0.0/scriptCmdlets/New-SsoExternalIdentitySource"), + Parameters = {new ScriptStringExecutionParameterDetails("DomainName") +{ +Value = "placeholderDomain.local", +}, new ScriptStringExecutionParameterDetails("BaseUserDN") +{ +Value = "DC=placeholder, DC=placeholder", +}}, + HiddenParameters = {new ScriptSecureStringExecutionParameterDetails("Password") +{ +SecureValue = "PlaceholderPassword", +}}, + Timeout = "P0Y0M0DT0H60M60S", + Retention = "P0Y0M60DT0H60M60S", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scriptExecutionName, data); + ScriptExecutionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScriptExecutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +104,10 @@ public async Task Get_ScriptExecutionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ScriptExecutionsGet() + public async Task GetAll_ScriptExecutionsList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_Get.json - // this example is just showing the usage of "ScriptExecutions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_List.json + // this example is just showing the usage of "ScriptExecutions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +125,22 @@ public async Task Exists_ScriptExecutionsGet() // get the collection of this ScriptExecutionResource ScriptExecutionCollection collection = avsPrivateCloud.GetScriptExecutions(); - // invoke the operation - string scriptExecutionName = "addSsoServer"; - bool result = await collection.ExistsAsync(scriptExecutionName); + // invoke the operation and iterate over the result + await foreach (ScriptExecutionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScriptExecutionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ScriptExecutionsGet() + public async Task Exists_ScriptExecutionsGet() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_Get.json // this example is just showing the usage of "ScriptExecutions_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +163,17 @@ public async Task GetIfExists_ScriptExecutionsGet() // invoke the operation string scriptExecutionName = "addSsoServer"; - NullableResponse response = await collection.GetIfExistsAsync(scriptExecutionName); - ScriptExecutionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(scriptExecutionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScriptExecutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ScriptExecutionsCreateOrUpdate() + public async Task GetIfExists_ScriptExecutionsGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_CreateOrUpdate.json - // this example is just showing the usage of "ScriptExecutions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_Get.json + // this example is just showing the usage of "ScriptExecutions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,37 +193,21 @@ public async Task CreateOrUpdate_ScriptExecutionsCreateOrUpdate() // invoke the operation string scriptExecutionName = "addSsoServer"; - ScriptExecutionData data = new ScriptExecutionData() - { - ScriptCmdletId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/scriptPackages/AVS.PowerCommands@1.0.0/scriptCmdlets/New-SsoExternalIdentitySource"), - Parameters = -{ -new ScriptStringExecutionParameterDetails("DomainName") -{ -Value = "placeholderDomain.local", -},new ScriptStringExecutionParameterDetails("BaseUserDN") -{ -Value = "DC=placeholder, DC=placeholder", -} -}, - HiddenParameters = -{ -new ScriptSecureStringExecutionParameterDetails("Password") -{ -SecureValue = "PlaceholderPassword", -} -}, - Timeout = "P0Y0M0DT0H60M60S", - Retention = "P0Y0M60DT0H60M60S", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scriptExecutionName, data); - ScriptExecutionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(scriptExecutionName); + ScriptExecutionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScriptExecutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScriptExecutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptExecutionResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptExecutionResource.cs index 1d1b3efbf2292..4abe44e96dc92 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptExecutionResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptExecutionResource.cs @@ -50,10 +50,10 @@ public async Task Get_ScriptExecutionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ScriptExecutionsCreateOrUpdate() + public async Task Delete_ScriptExecutionsDelete() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_CreateOrUpdate.json - // this example is just showing the usage of "ScriptExecutions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_Delete.json + // this example is just showing the usage of "ScriptExecutions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,45 +70,17 @@ public async Task Update_ScriptExecutionsCreateOrUpdate() ScriptExecutionResource scriptExecution = client.GetScriptExecutionResource(scriptExecutionResourceId); // invoke the operation - ScriptExecutionData data = new ScriptExecutionData() - { - ScriptCmdletId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/scriptPackages/AVS.PowerCommands@1.0.0/scriptCmdlets/New-SsoExternalIdentitySource"), - Parameters = -{ -new ScriptStringExecutionParameterDetails("DomainName") -{ -Value = "placeholderDomain.local", -},new ScriptStringExecutionParameterDetails("BaseUserDN") -{ -Value = "DC=placeholder, DC=placeholder", -} -}, - HiddenParameters = -{ -new ScriptSecureStringExecutionParameterDetails("Password") -{ -SecureValue = "PlaceholderPassword", -} -}, - Timeout = "P0Y0M0DT0H60M60S", - Retention = "P0Y0M60DT0H60M60S", - }; - ArmOperation lro = await scriptExecution.UpdateAsync(WaitUntil.Completed, data); - ScriptExecutionResource result = lro.Value; + await scriptExecution.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScriptExecutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ScriptExecutionsDelete() + public async Task Update_ScriptExecutionsCreateOrUpdate() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_Delete.json - // this example is just showing the usage of "ScriptExecutions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptExecutions_CreateOrUpdate.json + // this example is just showing the usage of "ScriptExecutions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,9 +97,31 @@ public async Task Delete_ScriptExecutionsDelete() ScriptExecutionResource scriptExecution = client.GetScriptExecutionResource(scriptExecutionResourceId); // invoke the operation - await scriptExecution.DeleteAsync(WaitUntil.Completed); + ScriptExecutionData data = new ScriptExecutionData + { + ScriptCmdletId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.AVS/privateClouds/cloud1/scriptPackages/AVS.PowerCommands@1.0.0/scriptCmdlets/New-SsoExternalIdentitySource"), + Parameters = {new ScriptStringExecutionParameterDetails("DomainName") +{ +Value = "placeholderDomain.local", +}, new ScriptStringExecutionParameterDetails("BaseUserDN") +{ +Value = "DC=placeholder, DC=placeholder", +}}, + HiddenParameters = {new ScriptSecureStringExecutionParameterDetails("Password") +{ +SecureValue = "PlaceholderPassword", +}}, + Timeout = "P0Y0M0DT0H60M60S", + Retention = "P0Y0M60DT0H60M60S", + }; + ArmOperation lro = await scriptExecution.UpdateAsync(WaitUntil.Completed, data); + ScriptExecutionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScriptExecutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -152,10 +146,7 @@ public async Task GetExecutionLogs_ScriptExecutionsGetExecutionLogs() ScriptExecutionResource scriptExecution = client.GetScriptExecutionResource(scriptExecutionResourceId); // invoke the operation - IEnumerable scriptOutputStreamType = new ScriptOutputStreamType[] - { -ScriptOutputStreamType.Information,new ScriptOutputStreamType("Warnings"),new ScriptOutputStreamType("Errors"),ScriptOutputStreamType.Output - }; + IEnumerable scriptOutputStreamType = new ScriptOutputStreamType[] { ScriptOutputStreamType.Information, new ScriptOutputStreamType("Warnings"), new ScriptOutputStreamType("Errors"), ScriptOutputStreamType.Output }; ScriptExecutionResource result = await scriptExecution.GetExecutionLogsAsync(scriptOutputStreamType: scriptOutputStreamType); // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptPackageCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptPackageCollection.cs index 9a144a736cc2e..e44083cd31442 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptPackageCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_ScriptPackageCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ScriptPackageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScriptPackagesList() + public async Task Get_ScriptPackagesGet() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptPackages_List.json - // this example is just showing the usage of "ScriptPackages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptPackages_Get.json + // this example is just showing the usage of "ScriptPackages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ScriptPackagesList() // get the collection of this ScriptPackageResource ScriptPackageCollection collection = avsPrivateCloud.GetScriptPackages(); - // invoke the operation and iterate over the result - await foreach (ScriptPackageResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScriptPackageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string scriptPackageName = "Microsoft.AVS.Management@3.0.48"; + ScriptPackageResource result = await collection.GetAsync(scriptPackageName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScriptPackageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ScriptPackagesGet() + public async Task GetAll_ScriptPackagesList() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptPackages_Get.json - // this example is just showing the usage of "ScriptPackages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/ScriptPackages_List.json + // this example is just showing the usage of "ScriptPackages_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_ScriptPackagesGet() // get the collection of this ScriptPackageResource ScriptPackageCollection collection = avsPrivateCloud.GetScriptPackages(); - // invoke the operation - string scriptPackageName = "Microsoft.AVS.Management@3.0.48"; - ScriptPackageResource result = await collection.GetAsync(scriptPackageName); + // invoke the operation and iterate over the result + await foreach (ScriptPackageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScriptPackageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScriptPackageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index dfe43b8340e05..a09f3b17dbbd1 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -92,5 +92,67 @@ public async Task CheckAvsTrialAvailability_LocationsCheckTrialAvailabilityWithS Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAvsPrivateClouds_PrivateCloudsListInSubscription() + { + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_ListInSubscription.json + // this example is just showing the usage of "PrivateClouds_ListInSubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AvsPrivateCloudResource item in subscriptionResource.GetAvsPrivateCloudsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAvsPrivateClouds_PrivateCloudsListInSubscriptionStretched() + { + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/PrivateClouds_ListInSubscription_Stretched.json + // this example is just showing the usage of "PrivateClouds_ListInSubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AvsPrivateCloudResource item in subscriptionResource.GetAvsPrivateCloudsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AvsPrivateCloudData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDhcpCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDhcpCollection.cs index 1ccf91c9a7461..bfd0760f0f7ed 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDhcpCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDhcpCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_WorkloadNetworkDhcpCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkloadNetworksListDhcp() + public async Task CreateOrUpdate_WorkloadNetworksCreateDhcp() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListDhcp.json - // this example is just showing the usage of "WorkloadNetworks_ListDhcp" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreateDhcp.json + // this example is just showing the usage of "WorkloadNetworks_CreateDhcp" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,26 @@ public async Task GetAll_WorkloadNetworksListDhcp() // get the collection of this WorkloadNetworkDhcpResource WorkloadNetworkDhcpCollection collection = workloadNetwork.GetWorkloadNetworkDhcps(); - // invoke the operation and iterate over the result - await foreach (WorkloadNetworkDhcpResource item in collection.GetAllAsync()) + // invoke the operation + string dhcpId = "dhcp1"; + WorkloadNetworkDhcpData data = new WorkloadNetworkDhcpData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDhcpData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new WorkloadNetworkDhcpServer + { + ServerAddress = "40.1.5.1/24", + LeaseTime = 86400L, + DisplayName = "dhcpConfigurations1", + Revision = 1L, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dhcpId, data); + WorkloadNetworkDhcpResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDhcpData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +97,10 @@ public async Task Get_WorkloadNetworksGetDhcp() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkloadNetworksGetDhcp() + public async Task GetAll_WorkloadNetworksListDhcp() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetDhcp.json - // this example is just showing the usage of "WorkloadNetworks_GetDhcp" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListDhcp.json + // this example is just showing the usage of "WorkloadNetworks_ListDhcp" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +118,22 @@ public async Task Exists_WorkloadNetworksGetDhcp() // get the collection of this WorkloadNetworkDhcpResource WorkloadNetworkDhcpCollection collection = workloadNetwork.GetWorkloadNetworkDhcps(); - // invoke the operation - string dhcpId = "dhcp1"; - bool result = await collection.ExistsAsync(dhcpId); + // invoke the operation and iterate over the result + await foreach (WorkloadNetworkDhcpResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDhcpData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkloadNetworksGetDhcp() + public async Task Exists_WorkloadNetworksGetDhcp() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetDhcp.json // this example is just showing the usage of "WorkloadNetworks_GetDhcp" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +156,17 @@ public async Task GetIfExists_WorkloadNetworksGetDhcp() // invoke the operation string dhcpId = "dhcp1"; - NullableResponse response = await collection.GetIfExistsAsync(dhcpId); - WorkloadNetworkDhcpResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dhcpId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDhcpData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkloadNetworksCreateDhcp() + public async Task GetIfExists_WorkloadNetworksGetDhcp() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreateDhcp.json - // this example is just showing the usage of "WorkloadNetworks_CreateDhcp" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetDhcp.json + // this example is just showing the usage of "WorkloadNetworks_GetDhcp" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,24 +186,21 @@ public async Task CreateOrUpdate_WorkloadNetworksCreateDhcp() // invoke the operation string dhcpId = "dhcp1"; - WorkloadNetworkDhcpData data = new WorkloadNetworkDhcpData() - { - Properties = new WorkloadNetworkDhcpServer() - { - ServerAddress = "40.1.5.1/24", - LeaseTime = 86400L, - DisplayName = "dhcpConfigurations1", - Revision = 1L, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dhcpId, data); - WorkloadNetworkDhcpResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dhcpId); + WorkloadNetworkDhcpResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDhcpData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDhcpData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDhcpResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDhcpResource.cs index 69fc6a733588c..1f9337b5b66a1 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDhcpResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDhcpResource.cs @@ -49,10 +49,10 @@ public async Task Get_WorkloadNetworksGetDhcp() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WorkloadNetworksUpdateDhcp() + public async Task Delete_WorkloadNetworksDeleteDhcp() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdateDhcp.json - // this example is just showing the usage of "WorkloadNetworks_UpdateDhcp" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeleteDhcp.json + // this example is just showing the usage of "WorkloadNetworks_DeleteDhcp" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,17 @@ public async Task Update_WorkloadNetworksUpdateDhcp() WorkloadNetworkDhcpResource workloadNetworkDhcp = client.GetWorkloadNetworkDhcpResource(workloadNetworkDhcpResourceId); // invoke the operation - WorkloadNetworkDhcpData data = new WorkloadNetworkDhcpData() - { - Properties = new WorkloadNetworkDhcpServer() - { - ServerAddress = "40.1.5.1/24", - LeaseTime = 86400L, - Revision = 1L, - }, - }; - ArmOperation lro = await workloadNetworkDhcp.UpdateAsync(WaitUntil.Completed, data); - WorkloadNetworkDhcpResource result = lro.Value; + await workloadNetworkDhcp.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDhcpData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WorkloadNetworksDeleteDhcp() + public async Task Update_WorkloadNetworksUpdateDhcp() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeleteDhcp.json - // this example is just showing the usage of "WorkloadNetworks_DeleteDhcp" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdateDhcp.json + // this example is just showing the usage of "WorkloadNetworks_UpdateDhcp" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +96,23 @@ public async Task Delete_WorkloadNetworksDeleteDhcp() WorkloadNetworkDhcpResource workloadNetworkDhcp = client.GetWorkloadNetworkDhcpResource(workloadNetworkDhcpResourceId); // invoke the operation - await workloadNetworkDhcp.DeleteAsync(WaitUntil.Completed); + WorkloadNetworkDhcpData data = new WorkloadNetworkDhcpData + { + Properties = new WorkloadNetworkDhcpServer + { + ServerAddress = "40.1.5.1/24", + LeaseTime = 86400L, + Revision = 1L, + }, + }; + ArmOperation lro = await workloadNetworkDhcp.UpdateAsync(WaitUntil.Completed, data); + WorkloadNetworkDhcpResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDhcpData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsServiceCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsServiceCollection.cs index b58f26ac87861..f5a25bdadc676 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsServiceCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsServiceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_WorkloadNetworkDnsServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkloadNetworksListDnsServices() + public async Task CreateOrUpdate_WorkloadNetworksCreateDnsService() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListDnsServices.json - // this example is just showing the usage of "WorkloadNetworks_ListDnsServices" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreateDnsService.json + // this example is just showing the usage of "WorkloadNetworks_CreateDnsService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,25 @@ public async Task GetAll_WorkloadNetworksListDnsServices() // get the collection of this WorkloadNetworkDnsServiceResource WorkloadNetworkDnsServiceCollection collection = workloadNetwork.GetWorkloadNetworkDnsServices(); - // invoke the operation and iterate over the result - await foreach (WorkloadNetworkDnsServiceResource item in collection.GetAllAsync()) + // invoke the operation + string dnsServiceId = "dnsService1"; + WorkloadNetworkDnsServiceData data = new WorkloadNetworkDnsServiceData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDnsServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "dnsService1", + DnsServiceIP = IPAddress.Parse("5.5.5.5"), + DefaultDnsZone = "defaultDnsZone1", + FqdnZones = { "fqdnZone1" }, + LogLevel = DnsServiceLogLevel.Info, + Revision = 1L, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dnsServiceId, data); + WorkloadNetworkDnsServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDnsServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +97,10 @@ public async Task Get_WorkloadNetworksGetDnsService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkloadNetworksGetDnsService() + public async Task GetAll_WorkloadNetworksListDnsServices() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetDnsService.json - // this example is just showing the usage of "WorkloadNetworks_GetDnsService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListDnsServices.json + // this example is just showing the usage of "WorkloadNetworks_ListDnsServices" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +118,22 @@ public async Task Exists_WorkloadNetworksGetDnsService() // get the collection of this WorkloadNetworkDnsServiceResource WorkloadNetworkDnsServiceCollection collection = workloadNetwork.GetWorkloadNetworkDnsServices(); - // invoke the operation - string dnsServiceId = "dnsService1"; - bool result = await collection.ExistsAsync(dnsServiceId); + // invoke the operation and iterate over the result + await foreach (WorkloadNetworkDnsServiceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDnsServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkloadNetworksGetDnsService() + public async Task Exists_WorkloadNetworksGetDnsService() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetDnsService.json // this example is just showing the usage of "WorkloadNetworks_GetDnsService" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +156,17 @@ public async Task GetIfExists_WorkloadNetworksGetDnsService() // invoke the operation string dnsServiceId = "dnsService1"; - NullableResponse response = await collection.GetIfExistsAsync(dnsServiceId); - WorkloadNetworkDnsServiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dnsServiceId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDnsServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkloadNetworksCreateDnsService() + public async Task GetIfExists_WorkloadNetworksGetDnsService() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreateDnsService.json - // this example is just showing the usage of "WorkloadNetworks_CreateDnsService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetDnsService.json + // this example is just showing the usage of "WorkloadNetworks_GetDnsService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,26 +186,21 @@ public async Task CreateOrUpdate_WorkloadNetworksCreateDnsService() // invoke the operation string dnsServiceId = "dnsService1"; - WorkloadNetworkDnsServiceData data = new WorkloadNetworkDnsServiceData() - { - DisplayName = "dnsService1", - DnsServiceIP = IPAddress.Parse("5.5.5.5"), - DefaultDnsZone = "defaultDnsZone1", - FqdnZones = -{ -"fqdnZone1" -}, - LogLevel = DnsServiceLogLevel.Info, - Revision = 1L, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dnsServiceId, data); - WorkloadNetworkDnsServiceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dnsServiceId); + WorkloadNetworkDnsServiceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDnsServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDnsServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsServiceResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsServiceResource.cs index a44de60b01c84..8926cb07fe01e 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsServiceResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsServiceResource.cs @@ -50,10 +50,10 @@ public async Task Get_WorkloadNetworksGetDnsService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WorkloadNetworksUpdateDnsService() + public async Task Delete_WorkloadNetworksDeleteDnsService() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdateDnsService.json - // this example is just showing the usage of "WorkloadNetworks_UpdateDnsService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeleteDnsService.json + // this example is just showing the usage of "WorkloadNetworks_DeleteDnsService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,34 +70,17 @@ public async Task Update_WorkloadNetworksUpdateDnsService() WorkloadNetworkDnsServiceResource workloadNetworkDnsService = client.GetWorkloadNetworkDnsServiceResource(workloadNetworkDnsServiceResourceId); // invoke the operation - WorkloadNetworkDnsServiceData data = new WorkloadNetworkDnsServiceData() - { - DisplayName = "dnsService1", - DnsServiceIP = IPAddress.Parse("5.5.5.5"), - DefaultDnsZone = "defaultDnsZone1", - FqdnZones = -{ -"fqdnZone1" -}, - LogLevel = DnsServiceLogLevel.Info, - Revision = 1L, - }; - ArmOperation lro = await workloadNetworkDnsService.UpdateAsync(WaitUntil.Completed, data); - WorkloadNetworkDnsServiceResource result = lro.Value; + await workloadNetworkDnsService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDnsServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WorkloadNetworksDeleteDnsService() + public async Task Update_WorkloadNetworksUpdateDnsService() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeleteDnsService.json - // this example is just showing the usage of "WorkloadNetworks_DeleteDnsService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdateDnsService.json + // this example is just showing the usage of "WorkloadNetworks_UpdateDnsService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +97,23 @@ public async Task Delete_WorkloadNetworksDeleteDnsService() WorkloadNetworkDnsServiceResource workloadNetworkDnsService = client.GetWorkloadNetworkDnsServiceResource(workloadNetworkDnsServiceResourceId); // invoke the operation - await workloadNetworkDnsService.DeleteAsync(WaitUntil.Completed); + WorkloadNetworkDnsServiceData data = new WorkloadNetworkDnsServiceData + { + DisplayName = "dnsService1", + DnsServiceIP = IPAddress.Parse("5.5.5.5"), + DefaultDnsZone = "defaultDnsZone1", + FqdnZones = { "fqdnZone1" }, + LogLevel = DnsServiceLogLevel.Info, + Revision = 1L, + }; + ArmOperation lro = await workloadNetworkDnsService.UpdateAsync(WaitUntil.Completed, data); + WorkloadNetworkDnsServiceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDnsServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsZoneCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsZoneCollection.cs index 5b5b19306eceb..b281c026e9508 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsZoneCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsZoneCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_WorkloadNetworkDnsZoneCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkloadNetworksListDnsZones() + public async Task CreateOrUpdate_WorkloadNetworksCreateDnsZone() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListDnsZones.json - // this example is just showing the usage of "WorkloadNetworks_ListDnsZones" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreateDnsZone.json + // this example is just showing the usage of "WorkloadNetworks_CreateDnsZone" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_WorkloadNetworksListDnsZones() // get the collection of this WorkloadNetworkDnsZoneResource WorkloadNetworkDnsZoneCollection collection = workloadNetwork.GetWorkloadNetworkDnsZones(); - // invoke the operation and iterate over the result - await foreach (WorkloadNetworkDnsZoneResource item in collection.GetAllAsync()) + // invoke the operation + string dnsZoneId = "dnsZone1"; + WorkloadNetworkDnsZoneData data = new WorkloadNetworkDnsZoneData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDnsZoneData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "dnsZone1", + Domain = { }, + DnsServerIPs = { IPAddress.Parse("1.1.1.1") }, + SourceIP = IPAddress.Parse("8.8.8.8"), + Revision = 1L, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneId, data); + WorkloadNetworkDnsZoneResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDnsZoneData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_WorkloadNetworksGetDnsZone() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkloadNetworksGetDnsZone() + public async Task GetAll_WorkloadNetworksListDnsZones() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetDnsZone.json - // this example is just showing the usage of "WorkloadNetworks_GetDnsZone" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListDnsZones.json + // this example is just showing the usage of "WorkloadNetworks_ListDnsZones" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_WorkloadNetworksGetDnsZone() // get the collection of this WorkloadNetworkDnsZoneResource WorkloadNetworkDnsZoneCollection collection = workloadNetwork.GetWorkloadNetworkDnsZones(); - // invoke the operation - string dnsZoneId = "dnsZone1"; - bool result = await collection.ExistsAsync(dnsZoneId); + // invoke the operation and iterate over the result + await foreach (WorkloadNetworkDnsZoneResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDnsZoneData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkloadNetworksGetDnsZone() + public async Task Exists_WorkloadNetworksGetDnsZone() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetDnsZone.json // this example is just showing the usage of "WorkloadNetworks_GetDnsZone" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_WorkloadNetworksGetDnsZone() // invoke the operation string dnsZoneId = "dnsZone1"; - NullableResponse response = await collection.GetIfExistsAsync(dnsZoneId); - WorkloadNetworkDnsZoneResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dnsZoneId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDnsZoneData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkloadNetworksCreateDnsZone() + public async Task GetIfExists_WorkloadNetworksGetDnsZone() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreateDnsZone.json - // this example is just showing the usage of "WorkloadNetworks_CreateDnsZone" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetDnsZone.json + // this example is just showing the usage of "WorkloadNetworks_GetDnsZone" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,27 +184,21 @@ public async Task CreateOrUpdate_WorkloadNetworksCreateDnsZone() // invoke the operation string dnsZoneId = "dnsZone1"; - WorkloadNetworkDnsZoneData data = new WorkloadNetworkDnsZoneData() - { - DisplayName = "dnsZone1", - Domain = -{ -}, - DnsServerIPs = -{ -IPAddress.Parse("1.1.1.1") -}, - SourceIP = IPAddress.Parse("8.8.8.8"), - Revision = 1L, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dnsZoneId, data); - WorkloadNetworkDnsZoneResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dnsZoneId); + WorkloadNetworkDnsZoneResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDnsZoneData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDnsZoneData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsZoneResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsZoneResource.cs index f5d7e57a06a73..9be1379dece36 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsZoneResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkDnsZoneResource.cs @@ -49,10 +49,10 @@ public async Task Get_WorkloadNetworksGetDnsZone() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WorkloadNetworksUpdateDnsZone() + public async Task Delete_WorkloadNetworksDeleteDnsZone() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdateDnsZone.json - // this example is just showing the usage of "WorkloadNetworks_UpdateDnsZone" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeleteDnsZone.json + // this example is just showing the usage of "WorkloadNetworks_DeleteDnsZone" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,35 +69,17 @@ public async Task Update_WorkloadNetworksUpdateDnsZone() WorkloadNetworkDnsZoneResource workloadNetworkDnsZone = client.GetWorkloadNetworkDnsZoneResource(workloadNetworkDnsZoneResourceId); // invoke the operation - WorkloadNetworkDnsZoneData data = new WorkloadNetworkDnsZoneData() - { - DisplayName = "dnsZone1", - Domain = -{ -}, - DnsServerIPs = -{ -IPAddress.Parse("1.1.1.1") -}, - SourceIP = IPAddress.Parse("8.8.8.8"), - Revision = 1L, - }; - ArmOperation lro = await workloadNetworkDnsZone.UpdateAsync(WaitUntil.Completed, data); - WorkloadNetworkDnsZoneResource result = lro.Value; + await workloadNetworkDnsZone.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkDnsZoneData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WorkloadNetworksDeleteDnsZone() + public async Task Update_WorkloadNetworksUpdateDnsZone() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeleteDnsZone.json - // this example is just showing the usage of "WorkloadNetworks_DeleteDnsZone" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdateDnsZone.json + // this example is just showing the usage of "WorkloadNetworks_UpdateDnsZone" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +96,22 @@ public async Task Delete_WorkloadNetworksDeleteDnsZone() WorkloadNetworkDnsZoneResource workloadNetworkDnsZone = client.GetWorkloadNetworkDnsZoneResource(workloadNetworkDnsZoneResourceId); // invoke the operation - await workloadNetworkDnsZone.DeleteAsync(WaitUntil.Completed); + WorkloadNetworkDnsZoneData data = new WorkloadNetworkDnsZoneData + { + DisplayName = "dnsZone1", + Domain = { }, + DnsServerIPs = { IPAddress.Parse("1.1.1.1") }, + SourceIP = IPAddress.Parse("8.8.8.8"), + Revision = 1L, + }; + ArmOperation lro = await workloadNetworkDnsZone.UpdateAsync(WaitUntil.Completed, data); + WorkloadNetworkDnsZoneResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkDnsZoneData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkGatewayCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkGatewayCollection.cs index 28c4ab2519e4e..e7437fb83191e 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkGatewayCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkGatewayCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkloadNetworkGatewayCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkloadNetworksListGateways() + public async Task Get_WorkloadNetworksGetGateway() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListGateways.json - // this example is just showing the usage of "WorkloadNetworks_ListGateways" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetGateway.json + // this example is just showing the usage of "WorkloadNetworks_GetGateway" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_WorkloadNetworksListGateways() // get the collection of this WorkloadNetworkGatewayResource WorkloadNetworkGatewayCollection collection = workloadNetwork.GetWorkloadNetworkGateways(); - // invoke the operation and iterate over the result - await foreach (WorkloadNetworkGatewayResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string gatewayId = "gateway1"; + WorkloadNetworkGatewayResource result = await collection.GetAsync(gatewayId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkloadNetworksGetGateway() + public async Task GetAll_WorkloadNetworksListGateways() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetGateway.json - // this example is just showing the usage of "WorkloadNetworks_GetGateway" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListGateways.json + // this example is just showing the usage of "WorkloadNetworks_ListGateways" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_WorkloadNetworksGetGateway() // get the collection of this WorkloadNetworkGatewayResource WorkloadNetworkGatewayCollection collection = workloadNetwork.GetWorkloadNetworkGateways(); - // invoke the operation - string gatewayId = "gateway1"; - WorkloadNetworkGatewayResource result = await collection.GetAsync(gatewayId); + // invoke the operation and iterate over the result + await foreach (WorkloadNetworkGatewayResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPortMirroringProfileCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPortMirroringProfileCollection.cs index b8cb57657ba41..ec57a79e0ab32 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPortMirroringProfileCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPortMirroringProfileCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_WorkloadNetworkPortMirroringProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkloadNetworksListPortMirroring() + public async Task CreateOrUpdate_WorkloadNetworksCreatePortMirroring() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListPortMirroring.json - // this example is just showing the usage of "WorkloadNetworks_ListPortMirroring" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreatePortMirroring.json + // this example is just showing the usage of "WorkloadNetworks_CreatePortMirroring" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_WorkloadNetworksListPortMirroring() // get the collection of this WorkloadNetworkPortMirroringProfileResource WorkloadNetworkPortMirroringProfileCollection collection = workloadNetwork.GetWorkloadNetworkPortMirroringProfiles(); - // invoke the operation and iterate over the result - await foreach (WorkloadNetworkPortMirroringProfileResource item in collection.GetAllAsync()) + // invoke the operation + string portMirroringId = "portMirroring1"; + WorkloadNetworkPortMirroringProfileData data = new WorkloadNetworkPortMirroringProfileData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkPortMirroringProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "portMirroring1", + Direction = PortMirroringProfileDirection.Bidirectional, + Source = "vmGroup1", + Destination = "vmGroup2", + Revision = 1L, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, portMirroringId, data); + WorkloadNetworkPortMirroringProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkPortMirroringProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_WorkloadNetworksGetPortMirroring() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkloadNetworksGetPortMirroring() + public async Task GetAll_WorkloadNetworksListPortMirroring() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetPortMirroring.json - // this example is just showing the usage of "WorkloadNetworks_GetPortMirroring" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListPortMirroring.json + // this example is just showing the usage of "WorkloadNetworks_ListPortMirroring" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_WorkloadNetworksGetPortMirroring() // get the collection of this WorkloadNetworkPortMirroringProfileResource WorkloadNetworkPortMirroringProfileCollection collection = workloadNetwork.GetWorkloadNetworkPortMirroringProfiles(); - // invoke the operation - string portMirroringId = "portMirroring1"; - bool result = await collection.ExistsAsync(portMirroringId); + // invoke the operation and iterate over the result + await foreach (WorkloadNetworkPortMirroringProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkPortMirroringProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkloadNetworksGetPortMirroring() + public async Task Exists_WorkloadNetworksGetPortMirroring() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetPortMirroring.json // this example is just showing the usage of "WorkloadNetworks_GetPortMirroring" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_WorkloadNetworksGetPortMirroring() // invoke the operation string portMirroringId = "portMirroring1"; - NullableResponse response = await collection.GetIfExistsAsync(portMirroringId); - WorkloadNetworkPortMirroringProfileResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(portMirroringId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkPortMirroringProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkloadNetworksCreatePortMirroring() + public async Task GetIfExists_WorkloadNetworksGetPortMirroring() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreatePortMirroring.json - // this example is just showing the usage of "WorkloadNetworks_CreatePortMirroring" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetPortMirroring.json + // this example is just showing the usage of "WorkloadNetworks_GetPortMirroring" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_WorkloadNetworksCreatePortMirroring() // invoke the operation string portMirroringId = "portMirroring1"; - WorkloadNetworkPortMirroringProfileData data = new WorkloadNetworkPortMirroringProfileData() - { - DisplayName = "portMirroring1", - Direction = PortMirroringProfileDirection.Bidirectional, - Source = "vmGroup1", - Destination = "vmGroup2", - Revision = 1L, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, portMirroringId, data); - WorkloadNetworkPortMirroringProfileResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(portMirroringId); + WorkloadNetworkPortMirroringProfileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkPortMirroringProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkPortMirroringProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPortMirroringProfileResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPortMirroringProfileResource.cs index c5860327f303d..ed693a6488619 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPortMirroringProfileResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPortMirroringProfileResource.cs @@ -49,10 +49,10 @@ public async Task Get_WorkloadNetworksGetPortMirroring() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WorkloadNetworksUpdatePortMirroring() + public async Task Delete_WorkloadNetworksDeletePortMirroring() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdatePortMirroring.json - // this example is just showing the usage of "WorkloadNetworks_UpdatePortMirroring" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeletePortMirroring.json + // this example is just showing the usage of "WorkloadNetworks_DeletePortMirroring" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_WorkloadNetworksUpdatePortMirroring() WorkloadNetworkPortMirroringProfileResource workloadNetworkPortMirroringProfile = client.GetWorkloadNetworkPortMirroringProfileResource(workloadNetworkPortMirroringProfileResourceId); // invoke the operation - WorkloadNetworkPortMirroringProfileData data = new WorkloadNetworkPortMirroringProfileData() - { - Direction = PortMirroringProfileDirection.Bidirectional, - Source = "vmGroup1", - Destination = "vmGroup2", - Revision = 1L, - }; - ArmOperation lro = await workloadNetworkPortMirroringProfile.UpdateAsync(WaitUntil.Completed, data); - WorkloadNetworkPortMirroringProfileResource result = lro.Value; + await workloadNetworkPortMirroringProfile.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkPortMirroringProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WorkloadNetworksDeletePortMirroring() + public async Task Update_WorkloadNetworksUpdatePortMirroring() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeletePortMirroring.json - // this example is just showing the usage of "WorkloadNetworks_DeletePortMirroring" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdatePortMirroring.json + // this example is just showing the usage of "WorkloadNetworks_UpdatePortMirroring" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_WorkloadNetworksDeletePortMirroring() WorkloadNetworkPortMirroringProfileResource workloadNetworkPortMirroringProfile = client.GetWorkloadNetworkPortMirroringProfileResource(workloadNetworkPortMirroringProfileResourceId); // invoke the operation - await workloadNetworkPortMirroringProfile.DeleteAsync(WaitUntil.Completed); + WorkloadNetworkPortMirroringProfileData data = new WorkloadNetworkPortMirroringProfileData + { + Direction = PortMirroringProfileDirection.Bidirectional, + Source = "vmGroup1", + Destination = "vmGroup2", + Revision = 1L, + }; + ArmOperation lro = await workloadNetworkPortMirroringProfile.UpdateAsync(WaitUntil.Completed, data); + WorkloadNetworkPortMirroringProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkPortMirroringProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPublicIPCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPublicIPCollection.cs index 5f23ea571c85a..05122e490c030 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPublicIPCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPublicIPCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkloadNetworkPublicIPCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkloadNetworksListPublicIPs() + public async Task CreateOrUpdate_WorkloadNetworksCreatePublicIP() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListPublicIPs.json - // this example is just showing the usage of "WorkloadNetworks_ListPublicIPs" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreatePublicIP.json + // this example is just showing the usage of "WorkloadNetworks_CreatePublicIP" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task GetAll_WorkloadNetworksListPublicIPs() // get the collection of this WorkloadNetworkPublicIPResource WorkloadNetworkPublicIPCollection collection = workloadNetwork.GetWorkloadNetworkPublicIPs(); - // invoke the operation and iterate over the result - await foreach (WorkloadNetworkPublicIPResource item in collection.GetAllAsync()) + // invoke the operation + string publicIPId = "publicIP1"; + WorkloadNetworkPublicIPData data = new WorkloadNetworkPublicIPData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkPublicIPData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "publicIP1", + NumberOfPublicIPs = 32L, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPId, data); + WorkloadNetworkPublicIPResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkPublicIPData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +91,10 @@ public async Task Get_WorkloadNetworksGetPublicIP() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkloadNetworksGetPublicIP() + public async Task GetAll_WorkloadNetworksListPublicIPs() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetPublicIP.json - // this example is just showing the usage of "WorkloadNetworks_GetPublicIP" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListPublicIPs.json + // this example is just showing the usage of "WorkloadNetworks_ListPublicIPs" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +112,22 @@ public async Task Exists_WorkloadNetworksGetPublicIP() // get the collection of this WorkloadNetworkPublicIPResource WorkloadNetworkPublicIPCollection collection = workloadNetwork.GetWorkloadNetworkPublicIPs(); - // invoke the operation - string publicIPId = "publicIP1"; - bool result = await collection.ExistsAsync(publicIPId); + // invoke the operation and iterate over the result + await foreach (WorkloadNetworkPublicIPResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkPublicIPData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkloadNetworksGetPublicIP() + public async Task Exists_WorkloadNetworksGetPublicIP() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetPublicIP.json // this example is just showing the usage of "WorkloadNetworks_GetPublicIP" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +150,17 @@ public async Task GetIfExists_WorkloadNetworksGetPublicIP() // invoke the operation string publicIPId = "publicIP1"; - NullableResponse response = await collection.GetIfExistsAsync(publicIPId); - WorkloadNetworkPublicIPResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(publicIPId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkPublicIPData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkloadNetworksCreatePublicIP() + public async Task GetIfExists_WorkloadNetworksGetPublicIP() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreatePublicIP.json - // this example is just showing the usage of "WorkloadNetworks_CreatePublicIP" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetPublicIP.json + // this example is just showing the usage of "WorkloadNetworks_GetPublicIP" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,19 +180,21 @@ public async Task CreateOrUpdate_WorkloadNetworksCreatePublicIP() // invoke the operation string publicIPId = "publicIP1"; - WorkloadNetworkPublicIPData data = new WorkloadNetworkPublicIPData() - { - DisplayName = "publicIP1", - NumberOfPublicIPs = 32L, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPId, data); - WorkloadNetworkPublicIPResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(publicIPId); + WorkloadNetworkPublicIPResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkPublicIPData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkPublicIPData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPublicIPResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPublicIPResource.cs index 112080face2bd..7cfb0ebbc630e 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPublicIPResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkPublicIPResource.cs @@ -48,10 +48,10 @@ public async Task Get_WorkloadNetworksGetPublicIP() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WorkloadNetworksCreatePublicIP() + public async Task Delete_WorkloadNetworksDeletePublicIP() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreatePublicIP.json - // this example is just showing the usage of "WorkloadNetworks_CreatePublicIP" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeletePublicIP.json + // this example is just showing the usage of "WorkloadNetworks_DeletePublicIP" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,27 +68,17 @@ public async Task Update_WorkloadNetworksCreatePublicIP() WorkloadNetworkPublicIPResource workloadNetworkPublicIP = client.GetWorkloadNetworkPublicIPResource(workloadNetworkPublicIPResourceId); // invoke the operation - WorkloadNetworkPublicIPData data = new WorkloadNetworkPublicIPData() - { - DisplayName = "publicIP1", - NumberOfPublicIPs = 32L, - }; - ArmOperation lro = await workloadNetworkPublicIP.UpdateAsync(WaitUntil.Completed, data); - WorkloadNetworkPublicIPResource result = lro.Value; + await workloadNetworkPublicIP.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkPublicIPData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WorkloadNetworksDeletePublicIP() + public async Task Update_WorkloadNetworksCreatePublicIP() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeletePublicIP.json - // this example is just showing the usage of "WorkloadNetworks_DeletePublicIP" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreatePublicIP.json + // this example is just showing the usage of "WorkloadNetworks_CreatePublicIP" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +95,19 @@ public async Task Delete_WorkloadNetworksDeletePublicIP() WorkloadNetworkPublicIPResource workloadNetworkPublicIP = client.GetWorkloadNetworkPublicIPResource(workloadNetworkPublicIPResourceId); // invoke the operation - await workloadNetworkPublicIP.DeleteAsync(WaitUntil.Completed); + WorkloadNetworkPublicIPData data = new WorkloadNetworkPublicIPData + { + DisplayName = "publicIP1", + NumberOfPublicIPs = 32L, + }; + ArmOperation lro = await workloadNetworkPublicIP.UpdateAsync(WaitUntil.Completed, data); + WorkloadNetworkPublicIPResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkPublicIPData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkSegmentCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkSegmentCollection.cs index 13ed8d0a9f242..a741a307dc4b0 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkSegmentCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkSegmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_WorkloadNetworkSegmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkloadNetworksListSegments() + public async Task CreateOrUpdate_WorkloadNetworksCreateSegments() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListSegments.json - // this example is just showing the usage of "WorkloadNetworks_ListSegments" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreateSegments.json + // this example is just showing the usage of "WorkloadNetworks_CreateSegments" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,27 @@ public async Task GetAll_WorkloadNetworksListSegments() // get the collection of this WorkloadNetworkSegmentResource WorkloadNetworkSegmentCollection collection = workloadNetwork.GetWorkloadNetworkSegments(); - // invoke the operation and iterate over the result - await foreach (WorkloadNetworkSegmentResource item in collection.GetAllAsync()) + // invoke the operation + string segmentId = "segment1"; + WorkloadNetworkSegmentData data = new WorkloadNetworkSegmentData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkSegmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "segment1", + ConnectedGateway = "/infra/tier-1s/gateway", + Subnet = new WorkloadNetworkSegmentSubnet + { + DhcpRanges = { "40.20.0.0-40.20.0.1" }, + GatewayAddress = "40.20.20.20/16", + }, + Revision = 1L, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, segmentId, data); + WorkloadNetworkSegmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkSegmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +98,10 @@ public async Task Get_WorkloadNetworksGetSegment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkloadNetworksGetSegment() + public async Task GetAll_WorkloadNetworksListSegments() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetSegment.json - // this example is just showing the usage of "WorkloadNetworks_GetSegment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListSegments.json + // this example is just showing the usage of "WorkloadNetworks_ListSegments" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +119,22 @@ public async Task Exists_WorkloadNetworksGetSegment() // get the collection of this WorkloadNetworkSegmentResource WorkloadNetworkSegmentCollection collection = workloadNetwork.GetWorkloadNetworkSegments(); - // invoke the operation - string segmentId = "segment1"; - bool result = await collection.ExistsAsync(segmentId); + // invoke the operation and iterate over the result + await foreach (WorkloadNetworkSegmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkSegmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkloadNetworksGetSegment() + public async Task Exists_WorkloadNetworksGetSegment() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetSegment.json // this example is just showing the usage of "WorkloadNetworks_GetSegment" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +157,17 @@ public async Task GetIfExists_WorkloadNetworksGetSegment() // invoke the operation string segmentId = "segment1"; - NullableResponse response = await collection.GetIfExistsAsync(segmentId); - WorkloadNetworkSegmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(segmentId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkSegmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkloadNetworksCreateSegments() + public async Task GetIfExists_WorkloadNetworksGetSegment() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreateSegments.json - // this example is just showing the usage of "WorkloadNetworks_CreateSegments" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetSegment.json + // this example is just showing the usage of "WorkloadNetworks_GetSegment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,28 +187,21 @@ public async Task CreateOrUpdate_WorkloadNetworksCreateSegments() // invoke the operation string segmentId = "segment1"; - WorkloadNetworkSegmentData data = new WorkloadNetworkSegmentData() - { - DisplayName = "segment1", - ConnectedGateway = "/infra/tier-1s/gateway", - Subnet = new WorkloadNetworkSegmentSubnet() - { - DhcpRanges = -{ -"40.20.0.0-40.20.0.1" -}, - GatewayAddress = "40.20.20.20/16", - }, - Revision = 1L, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, segmentId, data); - WorkloadNetworkSegmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(segmentId); + WorkloadNetworkSegmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkSegmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkSegmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkSegmentResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkSegmentResource.cs index f933a54708ce6..ddc503288bdc0 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkSegmentResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkSegmentResource.cs @@ -49,10 +49,10 @@ public async Task Get_WorkloadNetworksGetSegment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WorkloadNetworksUpdateSegments() + public async Task Delete_WorkloadNetworksDeleteSegment() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdateSegments.json - // this example is just showing the usage of "WorkloadNetworks_UpdateSegments" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeleteSegment.json + // this example is just showing the usage of "WorkloadNetworks_DeleteSegment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,35 +69,17 @@ public async Task Update_WorkloadNetworksUpdateSegments() WorkloadNetworkSegmentResource workloadNetworkSegment = client.GetWorkloadNetworkSegmentResource(workloadNetworkSegmentResourceId); // invoke the operation - WorkloadNetworkSegmentData data = new WorkloadNetworkSegmentData() - { - ConnectedGateway = "/infra/tier-1s/gateway", - Subnet = new WorkloadNetworkSegmentSubnet() - { - DhcpRanges = -{ -"40.20.0.0-40.20.0.1" -}, - GatewayAddress = "40.20.20.20/16", - }, - Revision = 1L, - }; - ArmOperation lro = await workloadNetworkSegment.UpdateAsync(WaitUntil.Completed, data); - WorkloadNetworkSegmentResource result = lro.Value; + await workloadNetworkSegment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkSegmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WorkloadNetworksDeleteSegment() + public async Task Update_WorkloadNetworksUpdateSegments() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeleteSegment.json - // this example is just showing the usage of "WorkloadNetworks_DeleteSegment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdateSegments.json + // this example is just showing the usage of "WorkloadNetworks_UpdateSegments" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +96,24 @@ public async Task Delete_WorkloadNetworksDeleteSegment() WorkloadNetworkSegmentResource workloadNetworkSegment = client.GetWorkloadNetworkSegmentResource(workloadNetworkSegmentResourceId); // invoke the operation - await workloadNetworkSegment.DeleteAsync(WaitUntil.Completed); + WorkloadNetworkSegmentData data = new WorkloadNetworkSegmentData + { + ConnectedGateway = "/infra/tier-1s/gateway", + Subnet = new WorkloadNetworkSegmentSubnet + { + DhcpRanges = { "40.20.0.0-40.20.0.1" }, + GatewayAddress = "40.20.20.20/16", + }, + Revision = 1L, + }; + ArmOperation lro = await workloadNetworkSegment.UpdateAsync(WaitUntil.Completed, data); + WorkloadNetworkSegmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkSegmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVirtualMachineCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVirtualMachineCollection.cs index a317a4363a9d1..7008c5527d7b1 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVirtualMachineCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVirtualMachineCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkloadNetworkVirtualMachineCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkloadNetworksListVirtualMachines() + public async Task Get_WorkloadNetworksGetVirtualMachine() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListVirtualMachines.json - // this example is just showing the usage of "WorkloadNetworks_ListVirtualMachines" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetVirtualMachine.json + // this example is just showing the usage of "WorkloadNetworks_GetVirtualMachine" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_WorkloadNetworksListVirtualMachines() // get the collection of this WorkloadNetworkVirtualMachineResource WorkloadNetworkVirtualMachineCollection collection = workloadNetwork.GetWorkloadNetworkVirtualMachines(); - // invoke the operation and iterate over the result - await foreach (WorkloadNetworkVirtualMachineResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkVirtualMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string virtualMachineId = "vm1"; + WorkloadNetworkVirtualMachineResource result = await collection.GetAsync(virtualMachineId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkVirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_WorkloadNetworksGetVirtualMachine() + public async Task GetAll_WorkloadNetworksListVirtualMachines() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetVirtualMachine.json - // this example is just showing the usage of "WorkloadNetworks_GetVirtualMachine" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListVirtualMachines.json + // this example is just showing the usage of "WorkloadNetworks_ListVirtualMachines" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_WorkloadNetworksGetVirtualMachine() // get the collection of this WorkloadNetworkVirtualMachineResource WorkloadNetworkVirtualMachineCollection collection = workloadNetwork.GetWorkloadNetworkVirtualMachines(); - // invoke the operation - string virtualMachineId = "vm1"; - WorkloadNetworkVirtualMachineResource result = await collection.GetAsync(virtualMachineId); + // invoke the operation and iterate over the result + await foreach (WorkloadNetworkVirtualMachineResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkVirtualMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkVirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVmGroupCollection.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVmGroupCollection.cs index 4e5e64fcd764a..54586b1fd94a4 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVmGroupCollection.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVmGroupCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_WorkloadNetworkVmGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WorkloadNetworksListVMGroups() + public async Task CreateOrUpdate_WorkloadNetworksCreateVMGroup() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListVMGroups.json - // this example is just showing the usage of "WorkloadNetworks_ListVmGroups" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreateVMGroup.json + // this example is just showing the usage of "WorkloadNetworks_CreateVmGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,22 @@ public async Task GetAll_WorkloadNetworksListVMGroups() // get the collection of this WorkloadNetworkVmGroupResource WorkloadNetworkVmGroupCollection collection = workloadNetwork.GetWorkloadNetworkVmGroups(); - // invoke the operation and iterate over the result - await foreach (WorkloadNetworkVmGroupResource item in collection.GetAllAsync()) + // invoke the operation + string vmGroupId = "vmGroup1"; + WorkloadNetworkVmGroupData data = new WorkloadNetworkVmGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkVmGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DisplayName = "vmGroup1", + Members = { "564d43da-fefc-2a3b-1d92-42855622fa50" }, + Revision = 1L, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmGroupId, data); + WorkloadNetworkVmGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkVmGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +92,10 @@ public async Task Get_WorkloadNetworksGetVMGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkloadNetworksGetVMGroup() + public async Task GetAll_WorkloadNetworksListVMGroups() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetVMGroup.json - // this example is just showing the usage of "WorkloadNetworks_GetVmGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_ListVMGroups.json + // this example is just showing the usage of "WorkloadNetworks_ListVmGroups" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +113,22 @@ public async Task Exists_WorkloadNetworksGetVMGroup() // get the collection of this WorkloadNetworkVmGroupResource WorkloadNetworkVmGroupCollection collection = workloadNetwork.GetWorkloadNetworkVmGroups(); - // invoke the operation - string vmGroupId = "vmGroup1"; - bool result = await collection.ExistsAsync(vmGroupId); + // invoke the operation and iterate over the result + await foreach (WorkloadNetworkVmGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkVmGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkloadNetworksGetVMGroup() + public async Task Exists_WorkloadNetworksGetVMGroup() { // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetVMGroup.json // this example is just showing the usage of "WorkloadNetworks_GetVmGroup" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +151,17 @@ public async Task GetIfExists_WorkloadNetworksGetVMGroup() // invoke the operation string vmGroupId = "vmGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(vmGroupId); - WorkloadNetworkVmGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vmGroupId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkVmGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkloadNetworksCreateVMGroup() + public async Task GetIfExists_WorkloadNetworksGetVMGroup() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_CreateVMGroup.json - // this example is just showing the usage of "WorkloadNetworks_CreateVmGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_GetVMGroup.json + // this example is just showing the usage of "WorkloadNetworks_GetVmGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,23 +181,21 @@ public async Task CreateOrUpdate_WorkloadNetworksCreateVMGroup() // invoke the operation string vmGroupId = "vmGroup1"; - WorkloadNetworkVmGroupData data = new WorkloadNetworkVmGroupData() - { - DisplayName = "vmGroup1", - Members = -{ -"564d43da-fefc-2a3b-1d92-42855622fa50" -}, - Revision = 1L, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vmGroupId, data); - WorkloadNetworkVmGroupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(vmGroupId); + WorkloadNetworkVmGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkVmGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkVmGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVmGroupResource.cs b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVmGroupResource.cs index 685fc5a165455..cbe0eb47895bd 100644 --- a/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVmGroupResource.cs +++ b/sdk/avs/Azure.ResourceManager.Avs/samples/Generated/Samples/Sample_WorkloadNetworkVmGroupResource.cs @@ -48,10 +48,10 @@ public async Task Get_WorkloadNetworksGetVMGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WorkloadNetworksUpdateVMGroup() + public async Task Delete_WorkloadNetworksDeleteVMGroup() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdateVMGroup.json - // this example is just showing the usage of "WorkloadNetworks_UpdateVmGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeleteVMGroup.json + // this example is just showing the usage of "WorkloadNetworks_DeleteVmGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,30 +68,17 @@ public async Task Update_WorkloadNetworksUpdateVMGroup() WorkloadNetworkVmGroupResource workloadNetworkVmGroup = client.GetWorkloadNetworkVmGroupResource(workloadNetworkVmGroupResourceId); // invoke the operation - WorkloadNetworkVmGroupData data = new WorkloadNetworkVmGroupData() - { - Members = -{ -"564d43da-fefc-2a3b-1d92-42855622fa50" -}, - Revision = 1L, - }; - ArmOperation lro = await workloadNetworkVmGroup.UpdateAsync(WaitUntil.Completed, data); - WorkloadNetworkVmGroupResource result = lro.Value; + await workloadNetworkVmGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WorkloadNetworkVmGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WorkloadNetworksDeleteVMGroup() + public async Task Update_WorkloadNetworksUpdateVMGroup() { - // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_DeleteVMGroup.json - // this example is just showing the usage of "WorkloadNetworks_DeleteVmGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/vmware/resource-manager/Microsoft.AVS/stable/2023-09-01/examples/WorkloadNetworks_UpdateVMGroup.json + // this example is just showing the usage of "WorkloadNetworks_UpdateVmGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +95,19 @@ public async Task Delete_WorkloadNetworksDeleteVMGroup() WorkloadNetworkVmGroupResource workloadNetworkVmGroup = client.GetWorkloadNetworkVmGroupResource(workloadNetworkVmGroupResourceId); // invoke the operation - await workloadNetworkVmGroup.DeleteAsync(WaitUntil.Completed); + WorkloadNetworkVmGroupData data = new WorkloadNetworkVmGroupData + { + Members = { "564d43da-fefc-2a3b-1d92-42855622fa50" }, + Revision = 1L, + }; + ArmOperation lro = await workloadNetworkVmGroup.UpdateAsync(WaitUntil.Completed, data); + WorkloadNetworkVmGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WorkloadNetworkVmGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeInstanceCollection.cs b/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeInstanceCollection.cs index c36fbcfd5586b..e88a00114724b 100644 --- a/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeInstanceCollection.cs +++ b/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeInstanceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LargeInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AzureLargeInstanceListByResourceGroup() + public async Task Get_AzureLargeInstanceGet() { - // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_ListByResourceGroup.json - // this example is just showing the usage of "AzureLargeInstance_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_Get.json + // this example is just showing the usage of "AzureLargeInstance_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_AzureLargeInstanceListByResourceGroup() // get the collection of this LargeInstanceResource LargeInstanceCollection collection = resourceGroupResource.GetLargeInstances(); - // invoke the operation and iterate over the result - await foreach (LargeInstanceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LargeInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string azureLargeInstanceName = "myAzureLargeInstance"; + LargeInstanceResource result = await collection.GetAsync(azureLargeInstanceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LargeInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AzureLargeInstanceGet() + public async Task GetAll_AzureLargeInstanceListByResourceGroup() { - // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_Get.json - // this example is just showing the usage of "AzureLargeInstance_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_ListByResourceGroup.json + // this example is just showing the usage of "AzureLargeInstance_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_AzureLargeInstanceGet() // get the collection of this LargeInstanceResource LargeInstanceCollection collection = resourceGroupResource.GetLargeInstances(); - // invoke the operation - string azureLargeInstanceName = "myAzureLargeInstance"; - LargeInstanceResource result = await collection.GetAsync(azureLargeInstanceName); + // invoke the operation and iterate over the result + await foreach (LargeInstanceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LargeInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LargeInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeInstanceResource.cs b/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeInstanceResource.cs index 3757a36ca6010..d9350f8e33f35 100644 --- a/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeInstanceResource.cs +++ b/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeInstanceResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.LargeInstance.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.LargeInstance.Samples { public partial class Sample_LargeInstanceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetLargeInstances_AzureLargeInstanceListBySubscription() - { - // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_ListBySubscription.json - // this example is just showing the usage of "AzureLargeInstance_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "f0f4887f-d13c-4943-a8ba-d7da28d2a3fd"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (LargeInstanceResource item in subscriptionResource.GetLargeInstancesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LargeInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_AzureLargeInstanceGet() diff --git a/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeStorageInstanceCollection.cs b/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeStorageInstanceCollection.cs index b6abc2bf88be9..d61dd1acb6f91 100644 --- a/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeStorageInstanceCollection.cs +++ b/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeStorageInstanceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LargeStorageInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AzureLargeStorageInstanceListByResourceGroup() + public async Task Get_AzureLargeStorageInstanceGet() { - // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_ListByResourceGroup.json - // this example is just showing the usage of "AzureLargeStorageInstance_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_Get.json + // this example is just showing the usage of "AzureLargeStorageInstance_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_AzureLargeStorageInstanceListByResourceGroup() // get the collection of this LargeStorageInstanceResource LargeStorageInstanceCollection collection = resourceGroupResource.GetLargeStorageInstances(); - // invoke the operation and iterate over the result - await foreach (LargeStorageInstanceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LargeStorageInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string azureLargeStorageInstanceName = "myAzureLargeStorageInstance"; + LargeStorageInstanceResource result = await collection.GetAsync(azureLargeStorageInstanceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LargeStorageInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AzureLargeStorageInstanceGet() + public async Task GetAll_AzureLargeStorageInstanceListByResourceGroup() { - // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_Get.json - // this example is just showing the usage of "AzureLargeStorageInstance_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_ListByResourceGroup.json + // this example is just showing the usage of "AzureLargeStorageInstance_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_AzureLargeStorageInstanceGet() // get the collection of this LargeStorageInstanceResource LargeStorageInstanceCollection collection = resourceGroupResource.GetLargeStorageInstances(); - // invoke the operation - string azureLargeStorageInstanceName = "myAzureLargeStorageInstance"; - LargeStorageInstanceResource result = await collection.GetAsync(azureLargeStorageInstanceName); + // invoke the operation and iterate over the result + await foreach (LargeStorageInstanceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LargeStorageInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LargeStorageInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeStorageInstanceResource.cs b/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeStorageInstanceResource.cs index 6abd9c0fff332..46e7ca1e77cd2 100644 --- a/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeStorageInstanceResource.cs +++ b/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_LargeStorageInstanceResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.LargeInstance.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.LargeInstance.Samples { public partial class Sample_LargeStorageInstanceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetLargeStorageInstances_AzureLargeStorageInstanceListBySubscription() - { - // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_ListBySubscription.json - // this example is just showing the usage of "AzureLargeStorageInstance_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "f0f4887f-d13c-4943-a8ba-d7da28d2a3fd"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (LargeStorageInstanceResource item in subscriptionResource.GetLargeStorageInstancesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LargeStorageInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_AzureLargeStorageInstanceGet() diff --git a/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..a1af908cbca89 --- /dev/null +++ b/sdk/azurelargeinstance/Azure.ResourceManager.LargeInstance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.LargeInstance.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetLargeInstances_AzureLargeInstanceListBySubscription() + { + // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeInstance_ListBySubscription.json + // this example is just showing the usage of "AzureLargeInstance_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "f0f4887f-d13c-4943-a8ba-d7da28d2a3fd"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (LargeInstanceResource item in subscriptionResource.GetLargeInstancesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LargeInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetLargeStorageInstances_AzureLargeStorageInstanceListBySubscription() + { + // Generated from example definition: specification/azurelargeinstance/resource-manager/Microsoft.AzureLargeInstance/preview/2023-07-20-preview/examples/AzureLargeStorageInstance_ListBySubscription.json + // this example is just showing the usage of "AzureLargeStorageInstance_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "f0f4887f-d13c-4943-a8ba-d7da28d2a3fd"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (LargeStorageInstanceResource item in subscriptionResource.GetLargeStorageInstancesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LargeStorageInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcExtensionCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcExtensionCollection.cs index a00229b864b7f..1f2c6f8ee6aed 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcExtensionCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcExtensionCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -18,10 +17,10 @@ public partial class Sample_ArcExtensionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExtensionsUnderArcSettingResource() + public async Task CreateOrUpdate_CreateArcExtension() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListExtensionsByArcSetting.json - // this example is just showing the usage of "Extensions_ListByArcSetting" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PutExtension.json + // this example is just showing the usage of "Extensions_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +39,31 @@ public async Task GetAll_ListExtensionsUnderArcSettingResource() // get the collection of this ArcExtensionResource ArcExtensionCollection collection = arcSetting.GetArcExtensions(); - // invoke the operation and iterate over the result - await foreach (ArcExtensionResource item in collection.GetAllAsync()) + // invoke the operation + string extensionName = "MicrosoftMonitoringAgent"; + ArcExtensionData data = new ArcExtensionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArcExtensionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Publisher = "Microsoft.Compute", + ArcExtensionType = "MicrosoftMonitoringAgent", + TypeHandlerVersion = "1.10", + Settings = BinaryData.FromObjectAsJson(new + { + workspaceId = "xx", + }), + ProtectedSettings = BinaryData.FromObjectAsJson(new + { + workspaceKey = "xx", + }), + EnableAutomaticUpgrade = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, extensionName, data); + ArcExtensionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArcExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +103,10 @@ public async Task Get_GetArcSettingsExtension() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetArcSettingsExtension() + public async Task GetAll_ListExtensionsUnderArcSettingResource() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetExtension.json - // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListExtensionsByArcSetting.json + // this example is just showing the usage of "Extensions_ListByArcSetting" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +125,22 @@ public async Task Exists_GetArcSettingsExtension() // get the collection of this ArcExtensionResource ArcExtensionCollection collection = arcSetting.GetArcExtensions(); - // invoke the operation - string extensionName = "MicrosoftMonitoringAgent"; - bool result = await collection.ExistsAsync(extensionName); + // invoke the operation and iterate over the result + await foreach (ArcExtensionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArcExtensionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetArcSettingsExtension() + public async Task Exists_GetArcSettingsExtension() { // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetExtension.json // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +164,17 @@ public async Task GetIfExists_GetArcSettingsExtension() // invoke the operation string extensionName = "MicrosoftMonitoringAgent"; - NullableResponse response = await collection.GetIfExistsAsync(extensionName); - ArcExtensionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(extensionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArcExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateArcExtension() + public async Task GetIfExists_GetArcSettingsExtension() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PutExtension.json - // this example is just showing the usage of "Extensions_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetExtension.json + // this example is just showing the usage of "Extensions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,29 +195,21 @@ public async Task CreateOrUpdate_CreateArcExtension() // invoke the operation string extensionName = "MicrosoftMonitoringAgent"; - ArcExtensionData data = new ArcExtensionData() - { - Publisher = "Microsoft.Compute", - ArcExtensionType = "MicrosoftMonitoringAgent", - TypeHandlerVersion = "1.10", - Settings = BinaryData.FromObjectAsJson(new Dictionary() - { - ["workspaceId"] = "xx" - }), - ProtectedSettings = BinaryData.FromObjectAsJson(new Dictionary() - { - ["workspaceKey"] = "xx" - }), - EnableAutomaticUpgrade = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, extensionName, data); - ArcExtensionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(extensionName); + ArcExtensionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArcExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArcExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcExtensionResource.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcExtensionResource.cs index 0e43ba917396b..c41e468314aa2 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcExtensionResource.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcExtensionResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -51,10 +50,10 @@ public async Task Get_GetArcSettingsExtension() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateArcExtension() + public async Task Delete_DeleteArcExtension() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PatchExtension.json - // this example is just showing the usage of "Extensions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteExtension.json + // this example is just showing the usage of "Extensions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,38 +71,17 @@ public async Task Update_UpdateArcExtension() ArcExtensionResource arcExtension = client.GetArcExtensionResource(arcExtensionResourceId); // invoke the operation - ArcExtensionPatch patch = new ArcExtensionPatch() - { - ExtensionParameters = new ArcExtensionPatchContent() - { - TypeHandlerVersion = "1.10", - IsAutomaticUpgradeEnabled = false, - Settings = BinaryData.FromObjectAsJson(new Dictionary() - { - ["workspaceId"] = "xx" - }), - ProtectedSettings = BinaryData.FromObjectAsJson(new Dictionary() - { - ["workspaceKey"] = "xx" - }), - }, - }; - ArmOperation lro = await arcExtension.UpdateAsync(WaitUntil.Completed, patch); - ArcExtensionResource result = lro.Value; + await arcExtension.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArcExtensionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteArcExtension() + public async Task Update_UpdateArcExtension() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteExtension.json - // this example is just showing the usage of "Extensions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PatchExtension.json + // this example is just showing the usage of "Extensions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,9 +99,30 @@ public async Task Delete_DeleteArcExtension() ArcExtensionResource arcExtension = client.GetArcExtensionResource(arcExtensionResourceId); // invoke the operation - await arcExtension.DeleteAsync(WaitUntil.Completed); + ArcExtensionPatch patch = new ArcExtensionPatch + { + ExtensionParameters = new ArcExtensionPatchContent + { + TypeHandlerVersion = "1.10", + IsAutomaticUpgradeEnabled = false, + Settings = BinaryData.FromObjectAsJson(new + { + workspaceId = "xx", + }), + ProtectedSettings = BinaryData.FromObjectAsJson(new + { + workspaceKey = "xx", + }), + }, + }; + ArmOperation lro = await arcExtension.UpdateAsync(WaitUntil.Completed, patch); + ArcExtensionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArcExtensionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -149,7 +148,7 @@ public async Task Upgrade_UpgradeMachineExtensions() ArcExtensionResource arcExtension = client.GetArcExtensionResource(arcExtensionResourceId); // invoke the operation - ArcExtensionUpgradeContent content = new ArcExtensionUpgradeContent() + ArcExtensionUpgradeContent content = new ArcExtensionUpgradeContent { TargetVersion = "1.0.18062.0", }; diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcSettingCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcSettingCollection.cs index 99964153855da..e2aa9b456c640 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcSettingCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcSettingCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ArcSettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListArcSettingResourcesByHCICluster() + public async Task CreateOrUpdate_CreateArcSetting() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListArcSettingsByCluster.json - // this example is just showing the usage of "ArcSettings_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PutArcSetting.json + // this example is just showing the usage of "ArcSettings_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_ListArcSettingResourcesByHCICluster() // get the collection of this ArcSettingResource ArcSettingCollection collection = hciCluster.GetArcSettings(); - // invoke the operation and iterate over the result - await foreach (ArcSettingResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArcSettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string arcSettingName = "default"; + ArcSettingData data = new ArcSettingData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, arcSettingName, data); + ArcSettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArcSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_GetArcSetting() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetArcSetting() + public async Task GetAll_ListArcSettingResourcesByHCICluster() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetArcSetting.json - // this example is just showing the usage of "ArcSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListArcSettingsByCluster.json + // this example is just showing the usage of "ArcSettings_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_GetArcSetting() // get the collection of this ArcSettingResource ArcSettingCollection collection = hciCluster.GetArcSettings(); - // invoke the operation - string arcSettingName = "default"; - bool result = await collection.ExistsAsync(arcSettingName); + // invoke the operation and iterate over the result + await foreach (ArcSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArcSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetArcSetting() + public async Task Exists_GetArcSetting() { // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetArcSetting.json // this example is just showing the usage of "ArcSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_GetArcSetting() // invoke the operation string arcSettingName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(arcSettingName); - ArcSettingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(arcSettingName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArcSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateArcSetting() + public async Task GetIfExists_GetArcSetting() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PutArcSetting.json - // this example is just showing the usage of "ArcSettings_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetArcSetting.json + // this example is just showing the usage of "ArcSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_CreateArcSetting() // invoke the operation string arcSettingName = "default"; - ArcSettingData data = new ArcSettingData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, arcSettingName, data); - ArcSettingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(arcSettingName); + ArcSettingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArcSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArcSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcSettingResource.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcSettingResource.cs index 43adeebd9f277..a43ec7e49b2ab 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcSettingResource.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_ArcSettingResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -50,10 +49,10 @@ public async Task Get_GetArcSetting() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchArcSetting() + public async Task Delete_DeleteArcSetting() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PatchArcSetting.json - // this example is just showing the usage of "ArcSettings_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteArcSetting.json + // this example is just showing the usage of "ArcSettings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,32 +69,17 @@ public async Task Update_PatchArcSetting() ArcSettingResource arcSetting = client.GetArcSettingResource(arcSettingResourceId); // invoke the operation - ArcSettingPatch patch = new ArcSettingPatch() - { - ConnectivityProperties = BinaryData.FromObjectAsJson(new Dictionary() - { - ["enabled"] = "true", - ["serviceConfigurations"] = new object[] { new Dictionary() -{ -["port"] = "6516", -["serviceName"] = "WAC"} } - }), - }; - ArcSettingResource result = await arcSetting.UpdateAsync(patch); + await arcSetting.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArcSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteArcSetting() + public async Task Update_PatchArcSetting() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteArcSetting.json - // this example is just showing the usage of "ArcSettings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PatchArcSetting.json + // this example is just showing the usage of "ArcSettings_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,9 +96,28 @@ public async Task Delete_DeleteArcSetting() ArcSettingResource arcSetting = client.GetArcSettingResource(arcSettingResourceId); // invoke the operation - await arcSetting.DeleteAsync(WaitUntil.Completed); + ArcSettingPatch patch = new ArcSettingPatch + { + ConnectivityProperties = BinaryData.FromObjectAsJson(new + { + enabled = "true", + serviceConfigurations = new object[] + { +new +{ +port = "6516", +serviceName = "WAC", +} + }, + }), + }; + ArcSettingResource result = await arcSetting.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArcSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterCollection.cs index 67da65fd9d99d..1bac981716e78 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_HciClusterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListClustersInAGivenResourceGroup() + public async Task CreateOrUpdate_CreateCluster() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListClustersByResourceGroup.json - // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/CreateCluster.json + // this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,23 @@ public async Task GetAll_ListClustersInAGivenResourceGroup() // get the collection of this HciClusterResource HciClusterCollection collection = resourceGroupResource.GetHciClusters(); - // invoke the operation and iterate over the result - await foreach (HciClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "myCluster"; + HciClusterData data = new HciClusterData(new AzureLocation("East US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CloudManagementEndpoint = "https://98294836-31be-4668-aeae-698667faf99b.waconazure.com", + AadClientId = Guid.Parse("24a6e53d-04e5-44d2-b7cc-1b732a847dfc"), + AadTenantId = Guid.Parse("7e589cc1-a8b6-4dff-91bd-5ec0fa18db94"), + TypeIdentityType = HciManagedServiceIdentityType.SystemAssigned, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); + HciClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +93,10 @@ public async Task Get_GetCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCluster() + public async Task GetAll_ListClustersInAGivenResourceGroup() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetCluster.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListClustersByResourceGroup.json + // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +113,22 @@ public async Task Exists_GetCluster() // get the collection of this HciClusterResource HciClusterCollection collection = resourceGroupResource.GetHciClusters(); - // invoke the operation - string clusterName = "myCluster"; - bool result = await collection.ExistsAsync(clusterName); + // invoke the operation and iterate over the result + await foreach (HciClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCluster() + public async Task Exists_GetCluster() { // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetCluster.json // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +150,17 @@ public async Task GetIfExists_GetCluster() // invoke the operation string clusterName = "myCluster"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - HciClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCluster() + public async Task GetIfExists_GetCluster() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/CreateCluster.json - // this example is just showing the usage of "Clusters_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetCluster.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,21 +179,21 @@ public async Task CreateOrUpdate_CreateCluster() // invoke the operation string clusterName = "myCluster"; - HciClusterData data = new HciClusterData(new AzureLocation("East US")) - { - CloudManagementEndpoint = "https://98294836-31be-4668-aeae-698667faf99b.waconazure.com", - AadClientId = Guid.Parse("24a6e53d-04e5-44d2-b7cc-1b732a847dfc"), - AadTenantId = Guid.Parse("7e589cc1-a8b6-4dff-91bd-5ec0fa18db94"), - TypeIdentityType = HciManagedServiceIdentityType.SystemAssigned, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); - HciClusterResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + HciClusterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterDeploymentSettingCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterDeploymentSettingCollection.cs index 17d9f653d41c3..4f313afd7ae21 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterDeploymentSettingCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterDeploymentSettingCollection.cs @@ -16,148 +16,6 @@ namespace Azure.ResourceManager.Hci.Samples { public partial class Sample_HciClusterDeploymentSettingCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDeploymentSettings() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListDeploymentSettingsByCluster.json - // this example is just showing the usage of "DeploymentSettings_ListByClusters" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HciClusterResource created on azure - // for more information of creating HciClusterResource, please refer to the document of HciClusterResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - string resourceGroupName = "test-rg"; - string clusterName = "myCluster"; - ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); - - // get the collection of this HciClusterDeploymentSettingResource - HciClusterDeploymentSettingCollection collection = hciCluster.GetHciClusterDeploymentSettings(); - - // invoke the operation and iterate over the result - await foreach (HciClusterDeploymentSettingResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterDeploymentSettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetDeploymentSettings() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetDeploymentSettings.json - // this example is just showing the usage of "DeploymentSettings_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HciClusterResource created on azure - // for more information of creating HciClusterResource, please refer to the document of HciClusterResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - string resourceGroupName = "test-rg"; - string clusterName = "myCluster"; - ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); - - // get the collection of this HciClusterDeploymentSettingResource - HciClusterDeploymentSettingCollection collection = hciCluster.GetHciClusterDeploymentSettings(); - - // invoke the operation - string deploymentSettingsName = "default"; - HciClusterDeploymentSettingResource result = await collection.GetAsync(deploymentSettingsName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterDeploymentSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDeploymentSettings() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetDeploymentSettings.json - // this example is just showing the usage of "DeploymentSettings_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HciClusterResource created on azure - // for more information of creating HciClusterResource, please refer to the document of HciClusterResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - string resourceGroupName = "test-rg"; - string clusterName = "myCluster"; - ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); - - // get the collection of this HciClusterDeploymentSettingResource - HciClusterDeploymentSettingCollection collection = hciCluster.GetHciClusterDeploymentSettings(); - - // invoke the operation - string deploymentSettingsName = "default"; - bool result = await collection.ExistsAsync(deploymentSettingsName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDeploymentSettings() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetDeploymentSettings.json - // this example is just showing the usage of "DeploymentSettings_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HciClusterResource created on azure - // for more information of creating HciClusterResource, please refer to the document of HciClusterResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - string resourceGroupName = "test-rg"; - string clusterName = "myCluster"; - ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); - - // get the collection of this HciClusterDeploymentSettingResource - HciClusterDeploymentSettingCollection collection = hciCluster.GetHciClusterDeploymentSettings(); - - // invoke the operation - string deploymentSettingsName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(deploymentSettingsName); - HciClusterDeploymentSettingResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterDeploymentSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateDeploymentSettings() @@ -183,19 +41,16 @@ public async Task CreateOrUpdate_CreateDeploymentSettings() // invoke the operation string deploymentSettingsName = "default"; - HciClusterDeploymentSettingData data = new HciClusterDeploymentSettingData() + HciClusterDeploymentSettingData data = new HciClusterDeploymentSettingData { - ArcNodeResourceIds = -{ -new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"),new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-2") -}, + ArcNodeResourceIds = { new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"), new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-2") }, DeploymentMode = EceDeploymentMode.Deploy, OperationType = HciClusterOperationType.ClusterProvisioning, DeploymentConfiguration = new HciClusterDeploymentConfiguration(new DeploymentSettingScaleUnits[] { -new DeploymentSettingScaleUnits(new HciClusterDeploymentInfo() +new DeploymentSettingScaleUnits(new HciClusterDeploymentInfo { -SecuritySettings = new HciClusterDeploymentSecuritySettings() +SecuritySettings = new HciClusterDeploymentSecuritySettings { IsHvciProtectionEnabled = true, IsDrtmProtectionEnabled = true, @@ -208,13 +63,13 @@ public async Task CreateOrUpdate_CreateDeploymentSettings() AreBitlockerDataVolumesEnabled = true, IsWdacEnforced = true, }, -Observability = new DeploymentSettingObservability() +Observability = new DeploymentSettingObservability { IsStreamingDataClientEnabled = true, IsEULocation = false, IsEpisodicDataUploadEnabled = true, }, -Cluster = new HciDeploymentCluster() +Cluster = new HciDeploymentCluster { Name = "testHCICluster", WitnessType = "Cloud", @@ -225,97 +80,70 @@ public async Task CreateOrUpdate_CreateDeploymentSettings() StorageConfigurationMode = "Express", NamingPrefix = "ms169", DomainFqdn = "ASZ1PLab8.nttest.microsoft.com", -InfrastructureNetwork = -{ -new DeploymentSettingInfrastructureNetwork() +InfrastructureNetwork = {new DeploymentSettingInfrastructureNetwork { SubnetMask = "255.255.248.0", Gateway = "255.255.248.0", -IPPools = -{ -new DeploymentSettingIPPools() +IPPools = {new DeploymentSettingIPPools { StartingAddress = "10.57.48.60", EndingAddress = "10.57.48.66", -} -}, -DnsServers = -{ -"10.57.50.90" -}, -} -}, -PhysicalNodes = -{ -new DeploymentSettingPhysicalNodes() +}}, +DnsServers = {"10.57.50.90"}, +}}, +PhysicalNodes = {new DeploymentSettingPhysicalNodes { Name = "ms169host", IPv4Address = "10.57.51.224", -},new DeploymentSettingPhysicalNodes() +}, new DeploymentSettingPhysicalNodes { Name = "ms154host", IPv4Address = "10.57.53.236", -} -}, -HostNetwork = new DeploymentSettingHostNetwork() +}}, +HostNetwork = new DeploymentSettingHostNetwork { -Intents = -{ -new DeploymentSettingIntents() +Intents = {new DeploymentSettingIntents { Name = "Compute_Management", -TrafficType = -{ -"Compute","Management" -}, -Adapter = -{ -"Port2" -}, +TrafficType = {"Compute", "Management"}, +Adapter = {"Port2"}, OverrideVirtualSwitchConfiguration = false, -VirtualSwitchConfigurationOverrides = new DeploymentSettingVirtualSwitchConfigurationOverrides() +VirtualSwitchConfigurationOverrides = new DeploymentSettingVirtualSwitchConfigurationOverrides { EnableIov = "True", LoadBalancingAlgorithm = "HyperVPort", }, OverrideQosPolicy = false, -QosPolicyOverrides = new DeploymentSettingQosPolicyOverrides() +QosPolicyOverrides = new DeploymentSettingQosPolicyOverrides { PriorityValue8021ActionCluster = "7", PriorityValue8021ActionSmb = "3", BandwidthPercentageSmb = "50", }, OverrideAdapterProperty = false, -AdapterPropertyOverrides = new DeploymentSettingAdapterPropertyOverrides() +AdapterPropertyOverrides = new DeploymentSettingAdapterPropertyOverrides { JumboPacket = "1514", NetworkDirect = "Enabled", NetworkDirectTechnology = "iWARP", }, -} -}, -StorageNetworks = -{ -new DeploymentSettingStorageNetworks() +}}, +StorageNetworks = {new DeploymentSettingStorageNetworks { Name = "Storage1Network", NetworkAdapterName = "Port3", VlanId = "5", -StorageAdapterIPInfo = -{ -new DeploymentSettingStorageAdapterIPInfo() +StorageAdapterIPInfo = {new DeploymentSettingStorageAdapterIPInfo { PhysicalNode = "string", IPv4Address = "10.57.48.60", SubnetMask = "255.255.248.0", -} -}, -} -}, +}}, +}}, StorageConnectivitySwitchless = true, EnableStorageAutoIP = false, }, -SdnIntegrationNetworkController = new DeploymentSettingNetworkController() +SdnIntegrationNetworkController = new DeploymentSettingNetworkController { MacAddressPoolStart = "00-0D-3A-1B-C7-21", MacAddressPoolStop = "00-0D-3A-1B-C7-29", @@ -323,26 +151,23 @@ public async Task CreateOrUpdate_CreateDeploymentSettings() }, AdouPath = "OU=ms169,DC=ASZ1PLab8,DC=nttest,DC=microsoft,DC=com", SecretsLocation = "/subscriptions/db4e2fdb-6d80-4e6e-b7cd-xxxxxxx/resourceGroups/test-rg/providers/Microsoft.KeyVault/vaults/abcd123", -Secrets = -{ -new EceDeploymentSecrets() +Secrets = {new EceDeploymentSecrets { SecretName = "cluster1-BmcAdminUser-f5bcc1d9-23af-4ae9-aca1-041d0f593a63", EceSecretName = new EceSecret("BMCAdminUserCred"), SecretLocation = new Uri("https://sclusterkvnirhci35.vault.azure.net/secrets/cluster-34232342-BmcAdminUser-f5bcc1d9-23af-4ae9-aca1-041d0f593a63/9276354aabfc492fa9b2cdbefb54ae4b"), -},new EceDeploymentSecrets() +}, new EceDeploymentSecrets { SecretName = "cluster2-AzureStackLCMUserCredential-f5bcc1d9-23af-4ae9-aca1-041d0f593a63", EceSecretName = EceSecret.AzureStackLcmUserCredential, SecretLocation = new Uri("https://sclusterkvnirhci35.vault.azure.net/secrets/cluster-34232342-AzureStackLCMUserCredential-f5bcc1d9-23af-4ae9-aca1-041d0f593a63/9276354aabfc492fa9b2cdbefb54ae4c"), -} -}, +}}, OptionalServicesCustomLocation = "customLocationName", }) { -SbePartnerInfo = new SbePartnerInfo() +SbePartnerInfo = new SbePartnerInfo { -SbeDeploymentInfo = new SbeDeploymentInfo() +SbeDeploymentInfo = new SbeDeploymentInfo { Version = "4.0.2309.13", Family = "Gen5", @@ -350,31 +175,25 @@ public async Task CreateOrUpdate_CreateDeploymentSettings() SbeManifestSource = "default", SbeManifestCreationOn = DateTimeOffset.Parse("2023-07-25T02:40:33Z"), }, -PartnerProperties = -{ -new SbePartnerProperties() +PartnerProperties = {new SbePartnerProperties { Name = "EnableBMCIpV6", Value = "false", -},new SbePartnerProperties() +}, new SbePartnerProperties { Name = "PhoneHomePort", Value = "1653", -},new SbePartnerProperties() +}, new SbePartnerProperties { Name = "BMCSecurityState", Value = "HighSecurity", -} -}, -CredentialList = -{ -new SbeCredentials() +}}, +CredentialList = {new SbeCredentials { SecretName = "cluster1-DownloadConnectorCred-f5bcc1d9-23af-4ae9-aca1-041d0f593a63", EceSecretName = "DownloadConnectorCred", SecretLocation = new Uri("https://sclusterkvnirhci35.vault.azure.net/secrets/cluster-34232342-DownloadConnectorCred-f5bcc1d9-23af-4ae9-aca1-041d0f593a63/9276354aabfc492fa9b2cdbefb54ae4b"), -} -}, +}}, }, } }) @@ -391,5 +210,147 @@ public async Task CreateOrUpdate_CreateDeploymentSettings() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetDeploymentSettings() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetDeploymentSettings.json + // this example is just showing the usage of "DeploymentSettings_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HciClusterResource created on azure + // for more information of creating HciClusterResource, please refer to the document of HciClusterResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + string resourceGroupName = "test-rg"; + string clusterName = "myCluster"; + ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); + + // get the collection of this HciClusterDeploymentSettingResource + HciClusterDeploymentSettingCollection collection = hciCluster.GetHciClusterDeploymentSettings(); + + // invoke the operation + string deploymentSettingsName = "default"; + HciClusterDeploymentSettingResource result = await collection.GetAsync(deploymentSettingsName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterDeploymentSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListDeploymentSettings() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListDeploymentSettingsByCluster.json + // this example is just showing the usage of "DeploymentSettings_ListByClusters" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HciClusterResource created on azure + // for more information of creating HciClusterResource, please refer to the document of HciClusterResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + string resourceGroupName = "test-rg"; + string clusterName = "myCluster"; + ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); + + // get the collection of this HciClusterDeploymentSettingResource + HciClusterDeploymentSettingCollection collection = hciCluster.GetHciClusterDeploymentSettings(); + + // invoke the operation and iterate over the result + await foreach (HciClusterDeploymentSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterDeploymentSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetDeploymentSettings() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetDeploymentSettings.json + // this example is just showing the usage of "DeploymentSettings_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HciClusterResource created on azure + // for more information of creating HciClusterResource, please refer to the document of HciClusterResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + string resourceGroupName = "test-rg"; + string clusterName = "myCluster"; + ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); + + // get the collection of this HciClusterDeploymentSettingResource + HciClusterDeploymentSettingCollection collection = hciCluster.GetHciClusterDeploymentSettings(); + + // invoke the operation + string deploymentSettingsName = "default"; + bool result = await collection.ExistsAsync(deploymentSettingsName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetDeploymentSettings() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetDeploymentSettings.json + // this example is just showing the usage of "DeploymentSettings_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HciClusterResource created on azure + // for more information of creating HciClusterResource, please refer to the document of HciClusterResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + string resourceGroupName = "test-rg"; + string clusterName = "myCluster"; + ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); + + // get the collection of this HciClusterDeploymentSettingResource + HciClusterDeploymentSettingCollection collection = hciCluster.GetHciClusterDeploymentSettings(); + + // invoke the operation + string deploymentSettingsName = "default"; + NullableResponse response = await collection.GetIfExistsAsync(deploymentSettingsName); + HciClusterDeploymentSettingResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterDeploymentSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterDeploymentSettingResource.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterDeploymentSettingResource.cs index 83a971c1b02f2..90dd3bfc8f585 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterDeploymentSettingResource.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterDeploymentSettingResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetDeploymentSettings() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteDeploymentSettings() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteDeploymentSettings.json + // this example is just showing the usage of "DeploymentSettings_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HciClusterDeploymentSettingResource created on azure + // for more information of creating HciClusterDeploymentSettingResource, please refer to the document of HciClusterDeploymentSettingResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + string resourceGroupName = "test-rg"; + string clusterName = "myCluster"; + string deploymentSettingsName = "default"; + ResourceIdentifier hciClusterDeploymentSettingResourceId = HciClusterDeploymentSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, deploymentSettingsName); + HciClusterDeploymentSettingResource hciClusterDeploymentSetting = client.GetHciClusterDeploymentSettingResource(hciClusterDeploymentSettingResourceId); + + // invoke the operation + await hciClusterDeploymentSetting.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateDeploymentSettings() @@ -69,19 +96,16 @@ public async Task Update_CreateDeploymentSettings() HciClusterDeploymentSettingResource hciClusterDeploymentSetting = client.GetHciClusterDeploymentSettingResource(hciClusterDeploymentSettingResourceId); // invoke the operation - HciClusterDeploymentSettingData data = new HciClusterDeploymentSettingData() + HciClusterDeploymentSettingData data = new HciClusterDeploymentSettingData { - ArcNodeResourceIds = -{ -new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"),new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-2") -}, + ArcNodeResourceIds = { new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"), new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-2") }, DeploymentMode = EceDeploymentMode.Deploy, OperationType = HciClusterOperationType.ClusterProvisioning, DeploymentConfiguration = new HciClusterDeploymentConfiguration(new DeploymentSettingScaleUnits[] { -new DeploymentSettingScaleUnits(new HciClusterDeploymentInfo() +new DeploymentSettingScaleUnits(new HciClusterDeploymentInfo { -SecuritySettings = new HciClusterDeploymentSecuritySettings() +SecuritySettings = new HciClusterDeploymentSecuritySettings { IsHvciProtectionEnabled = true, IsDrtmProtectionEnabled = true, @@ -94,13 +118,13 @@ public async Task Update_CreateDeploymentSettings() AreBitlockerDataVolumesEnabled = true, IsWdacEnforced = true, }, -Observability = new DeploymentSettingObservability() +Observability = new DeploymentSettingObservability { IsStreamingDataClientEnabled = true, IsEULocation = false, IsEpisodicDataUploadEnabled = true, }, -Cluster = new HciDeploymentCluster() +Cluster = new HciDeploymentCluster { Name = "testHCICluster", WitnessType = "Cloud", @@ -111,97 +135,70 @@ public async Task Update_CreateDeploymentSettings() StorageConfigurationMode = "Express", NamingPrefix = "ms169", DomainFqdn = "ASZ1PLab8.nttest.microsoft.com", -InfrastructureNetwork = -{ -new DeploymentSettingInfrastructureNetwork() +InfrastructureNetwork = {new DeploymentSettingInfrastructureNetwork { SubnetMask = "255.255.248.0", Gateway = "255.255.248.0", -IPPools = -{ -new DeploymentSettingIPPools() +IPPools = {new DeploymentSettingIPPools { StartingAddress = "10.57.48.60", EndingAddress = "10.57.48.66", -} -}, -DnsServers = -{ -"10.57.50.90" -}, -} -}, -PhysicalNodes = -{ -new DeploymentSettingPhysicalNodes() +}}, +DnsServers = {"10.57.50.90"}, +}}, +PhysicalNodes = {new DeploymentSettingPhysicalNodes { Name = "ms169host", IPv4Address = "10.57.51.224", -},new DeploymentSettingPhysicalNodes() +}, new DeploymentSettingPhysicalNodes { Name = "ms154host", IPv4Address = "10.57.53.236", -} -}, -HostNetwork = new DeploymentSettingHostNetwork() +}}, +HostNetwork = new DeploymentSettingHostNetwork { -Intents = -{ -new DeploymentSettingIntents() +Intents = {new DeploymentSettingIntents { Name = "Compute_Management", -TrafficType = -{ -"Compute","Management" -}, -Adapter = -{ -"Port2" -}, +TrafficType = {"Compute", "Management"}, +Adapter = {"Port2"}, OverrideVirtualSwitchConfiguration = false, -VirtualSwitchConfigurationOverrides = new DeploymentSettingVirtualSwitchConfigurationOverrides() +VirtualSwitchConfigurationOverrides = new DeploymentSettingVirtualSwitchConfigurationOverrides { EnableIov = "True", LoadBalancingAlgorithm = "HyperVPort", }, OverrideQosPolicy = false, -QosPolicyOverrides = new DeploymentSettingQosPolicyOverrides() +QosPolicyOverrides = new DeploymentSettingQosPolicyOverrides { PriorityValue8021ActionCluster = "7", PriorityValue8021ActionSmb = "3", BandwidthPercentageSmb = "50", }, OverrideAdapterProperty = false, -AdapterPropertyOverrides = new DeploymentSettingAdapterPropertyOverrides() +AdapterPropertyOverrides = new DeploymentSettingAdapterPropertyOverrides { JumboPacket = "1514", NetworkDirect = "Enabled", NetworkDirectTechnology = "iWARP", }, -} -}, -StorageNetworks = -{ -new DeploymentSettingStorageNetworks() +}}, +StorageNetworks = {new DeploymentSettingStorageNetworks { Name = "Storage1Network", NetworkAdapterName = "Port3", VlanId = "5", -StorageAdapterIPInfo = -{ -new DeploymentSettingStorageAdapterIPInfo() +StorageAdapterIPInfo = {new DeploymentSettingStorageAdapterIPInfo { PhysicalNode = "string", IPv4Address = "10.57.48.60", SubnetMask = "255.255.248.0", -} -}, -} -}, +}}, +}}, StorageConnectivitySwitchless = true, EnableStorageAutoIP = false, }, -SdnIntegrationNetworkController = new DeploymentSettingNetworkController() +SdnIntegrationNetworkController = new DeploymentSettingNetworkController { MacAddressPoolStart = "00-0D-3A-1B-C7-21", MacAddressPoolStop = "00-0D-3A-1B-C7-29", @@ -209,26 +206,23 @@ public async Task Update_CreateDeploymentSettings() }, AdouPath = "OU=ms169,DC=ASZ1PLab8,DC=nttest,DC=microsoft,DC=com", SecretsLocation = "/subscriptions/db4e2fdb-6d80-4e6e-b7cd-xxxxxxx/resourceGroups/test-rg/providers/Microsoft.KeyVault/vaults/abcd123", -Secrets = -{ -new EceDeploymentSecrets() +Secrets = {new EceDeploymentSecrets { SecretName = "cluster1-BmcAdminUser-f5bcc1d9-23af-4ae9-aca1-041d0f593a63", EceSecretName = new EceSecret("BMCAdminUserCred"), SecretLocation = new Uri("https://sclusterkvnirhci35.vault.azure.net/secrets/cluster-34232342-BmcAdminUser-f5bcc1d9-23af-4ae9-aca1-041d0f593a63/9276354aabfc492fa9b2cdbefb54ae4b"), -},new EceDeploymentSecrets() +}, new EceDeploymentSecrets { SecretName = "cluster2-AzureStackLCMUserCredential-f5bcc1d9-23af-4ae9-aca1-041d0f593a63", EceSecretName = EceSecret.AzureStackLcmUserCredential, SecretLocation = new Uri("https://sclusterkvnirhci35.vault.azure.net/secrets/cluster-34232342-AzureStackLCMUserCredential-f5bcc1d9-23af-4ae9-aca1-041d0f593a63/9276354aabfc492fa9b2cdbefb54ae4c"), -} -}, +}}, OptionalServicesCustomLocation = "customLocationName", }) { -SbePartnerInfo = new SbePartnerInfo() +SbePartnerInfo = new SbePartnerInfo { -SbeDeploymentInfo = new SbeDeploymentInfo() +SbeDeploymentInfo = new SbeDeploymentInfo { Version = "4.0.2309.13", Family = "Gen5", @@ -236,31 +230,25 @@ public async Task Update_CreateDeploymentSettings() SbeManifestSource = "default", SbeManifestCreationOn = DateTimeOffset.Parse("2023-07-25T02:40:33Z"), }, -PartnerProperties = -{ -new SbePartnerProperties() +PartnerProperties = {new SbePartnerProperties { Name = "EnableBMCIpV6", Value = "false", -},new SbePartnerProperties() +}, new SbePartnerProperties { Name = "PhoneHomePort", Value = "1653", -},new SbePartnerProperties() +}, new SbePartnerProperties { Name = "BMCSecurityState", Value = "HighSecurity", -} -}, -CredentialList = -{ -new SbeCredentials() +}}, +CredentialList = {new SbeCredentials { SecretName = "cluster1-DownloadConnectorCred-f5bcc1d9-23af-4ae9-aca1-041d0f593a63", EceSecretName = "DownloadConnectorCred", SecretLocation = new Uri("https://sclusterkvnirhci35.vault.azure.net/secrets/cluster-34232342-DownloadConnectorCred-f5bcc1d9-23af-4ae9-aca1-041d0f593a63/9276354aabfc492fa9b2cdbefb54ae4b"), -} -}, +}}, }, } }) @@ -277,32 +265,5 @@ public async Task Update_CreateDeploymentSettings() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDeploymentSettings() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteDeploymentSettings.json - // this example is just showing the usage of "DeploymentSettings_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HciClusterDeploymentSettingResource created on azure - // for more information of creating HciClusterDeploymentSettingResource, please refer to the document of HciClusterDeploymentSettingResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - string resourceGroupName = "test-rg"; - string clusterName = "myCluster"; - string deploymentSettingsName = "default"; - ResourceIdentifier hciClusterDeploymentSettingResourceId = HciClusterDeploymentSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, deploymentSettingsName); - HciClusterDeploymentSettingResource hciClusterDeploymentSetting = client.GetHciClusterDeploymentSettingResource(hciClusterDeploymentSettingResourceId); - - // invoke the operation - await hciClusterDeploymentSetting.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterOfferCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterOfferCollection.cs index 923e55a17deec..59a3c0a8b061a 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterOfferCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterOfferCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HciClusterOfferCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOfferResourcesByPublisherForTheHCICluster() + public async Task Get_GetOffer() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListOffersByPublisher.json - // this example is just showing the usage of "Offers_ListByPublisher" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetOffer.json + // this example is just showing the usage of "Offers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListOfferResourcesByPublisherForTheHCICluster() // get the collection of this HciClusterOfferResource HciClusterOfferCollection collection = hciClusterPublisher.GetHciClusterOffers(); - // invoke the operation and iterate over the result - await foreach (HciClusterOfferResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterOfferData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string offerName = "offer1"; + HciClusterOfferResource result = await collection.GetAsync(offerName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterOfferData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetOffer() + public async Task GetAll_ListOfferResourcesByPublisherForTheHCICluster() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetOffer.json - // this example is just showing the usage of "Offers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListOffersByPublisher.json + // this example is just showing the usage of "Offers_ListByPublisher" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetOffer() // get the collection of this HciClusterOfferResource HciClusterOfferCollection collection = hciClusterPublisher.GetHciClusterOffers(); - // invoke the operation - string offerName = "offer1"; - HciClusterOfferResource result = await collection.GetAsync(offerName); + // invoke the operation and iterate over the result + await foreach (HciClusterOfferResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterOfferData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterOfferData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterPublisherCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterPublisherCollection.cs index 391aafa56e37a..e885c97f1c65a 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterPublisherCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterPublisherCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HciClusterPublisherCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPublisherResourcesByHCICluster() + public async Task Get_GetPublisher() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListPublishersByCluster.json - // this example is just showing the usage of "Publishers_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetPublisher.json + // this example is just showing the usage of "Publishers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListPublisherResourcesByHCICluster() // get the collection of this HciClusterPublisherResource HciClusterPublisherCollection collection = hciCluster.GetHciClusterPublishers(); - // invoke the operation and iterate over the result - await foreach (HciClusterPublisherResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterPublisherData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string publisherName = "publisher1"; + HciClusterPublisherResource result = await collection.GetAsync(publisherName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterPublisherData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPublisher() + public async Task GetAll_ListPublisherResourcesByHCICluster() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetPublisher.json - // this example is just showing the usage of "Publishers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListPublishersByCluster.json + // this example is just showing the usage of "Publishers_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetPublisher() // get the collection of this HciClusterPublisherResource HciClusterPublisherCollection collection = hciCluster.GetHciClusterPublishers(); - // invoke the operation - string publisherName = "publisher1"; - HciClusterPublisherResource result = await collection.GetAsync(publisherName); + // invoke the operation and iterate over the result + await foreach (HciClusterPublisherResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterPublisherData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterPublisherData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterResource.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterResource.cs index 44a132cd46f99..33cffca4f1101 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterResource.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Hci.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Hci.Samples @@ -19,41 +18,40 @@ public partial class Sample_HciClusterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetHciClusters_ListClustersInAGivenSubscription() + public async Task Get_GetCluster() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListClustersBySubscription.json - // this example is just showing the usage of "Clusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetCluster.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this HciClusterResource created on azure + // for more information of creating HciClusterResource, please refer to the document of HciClusterResource string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "test-rg"; + string clusterName = "myCluster"; + ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); - // invoke the operation and iterate over the result - await foreach (HciClusterResource item in subscriptionResource.GetHciClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + HciClusterResource result = await hciCluster.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCluster() + public async Task Delete_DeleteCluster() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetCluster.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteCluster.json + // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,13 +67,9 @@ public async Task Get_GetCluster() HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); // invoke the operation - HciClusterResource result = await hciCluster.GetAsync(); + await hciCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,15 +93,15 @@ public async Task Update_UpdateCluster() HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); // invoke the operation - HciClusterPatch patch = new HciClusterPatch() + HciClusterPatch patch = new HciClusterPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, CloudManagementEndpoint = "https://98294836-31be-4668-aeae-698667faf99b.waconazure.com", - DesiredProperties = new HciClusterDesiredProperties() + DesiredProperties = new HciClusterDesiredProperties { WindowsServerSubscription = WindowsServerSubscription.Enabled, DiagnosticLevel = HciClusterDiagnosticLevel.Basic, @@ -123,32 +117,6 @@ public async Task Update_UpdateCluster() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteCluster() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteCluster.json - // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HciClusterResource created on azure - // for more information of creating HciClusterResource, please refer to the document of HciClusterResource - string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; - string resourceGroupName = "test-rg"; - string clusterName = "myCluster"; - ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); - - // invoke the operation - await hciCluster.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task UploadCertificate_UploadCertificate() @@ -170,12 +138,9 @@ public async Task UploadCertificate_UploadCertificate() HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); // invoke the operation - HciClusterCertificateContent content = new HciClusterCertificateContent() + HciClusterCertificateContent content = new HciClusterCertificateContent { - Certificates = -{ -"base64cert","base64cert" -}, + Certificates = { "base64cert", "base64cert" }, }; await hciCluster.UploadCertificateAsync(WaitUntil.Completed, content); @@ -230,7 +195,7 @@ public async Task ExtendSoftwareAssuranceBenefit_CreateClusterIdentity() HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); // invoke the operation - SoftwareAssuranceChangeContent content = new SoftwareAssuranceChangeContent() + SoftwareAssuranceChangeContent content = new SoftwareAssuranceChangeContent { SoftwareAssuranceIntent = SoftwareAssuranceIntent.Enable, }; @@ -265,7 +230,7 @@ public async Task TriggerLogCollection_TriggerLogCollection() HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); // invoke the operation - LogCollectionContent content = new LogCollectionContent() + LogCollectionContent content = new LogCollectionContent { Properties = new LogCollectionContentProperties(DateTimeOffset.Parse("2020-01-01T17:18:19.1234567Z"), DateTimeOffset.Parse("2021-01-01T17:18:19.1234567Z")), }; @@ -300,9 +265,9 @@ public async Task ConfigureRemoteSupport_ConfigureRemoteSupport() HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); // invoke the operation - RemoteSupportContent content = new RemoteSupportContent() + RemoteSupportContent content = new RemoteSupportContent { - Properties = new RemoteSupportContentProperties() + Properties = new RemoteSupportContentProperties { ExpireOn = DateTimeOffset.Parse("2020-01-01T17:18:19.1234567Z"), RemoteSupportType = RemoteSupportType.Enable, diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterSecuritySettingCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterSecuritySettingCollection.cs index 739eb9693fd29..35141b4142b46 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterSecuritySettingCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterSecuritySettingCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_HciClusterSecuritySettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecuritySettings() + public async Task CreateOrUpdate_CreateSecuritySettings() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListSecuritySettingsByCluster.json - // this example is just showing the usage of "SecuritySettings_ListByClusters" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PutSecuritySettings.json + // this example is just showing the usage of "SecuritySettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,22 @@ public async Task GetAll_ListSecuritySettings() // get the collection of this HciClusterSecuritySettingResource HciClusterSecuritySettingCollection collection = hciCluster.GetHciClusterSecuritySettings(); - // invoke the operation and iterate over the result - await foreach (HciClusterSecuritySettingResource item in collection.GetAllAsync()) + // invoke the operation + string securitySettingsName = "default"; + HciClusterSecuritySettingData data = new HciClusterSecuritySettingData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterSecuritySettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SecuredCoreComplianceAssignment = HciClusterComplianceAssignmentType.Audit, + WdacComplianceAssignment = HciClusterComplianceAssignmentType.ApplyAndAutoCorrect, + SmbEncryptionForIntraClusterTrafficComplianceAssignment = HciClusterComplianceAssignmentType.Audit, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securitySettingsName, data); + HciClusterSecuritySettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterSecuritySettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +93,10 @@ public async Task Get_GetSecuritySettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSecuritySettings() + public async Task GetAll_ListSecuritySettings() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetSecuritySettings.json - // this example is just showing the usage of "SecuritySettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListSecuritySettingsByCluster.json + // this example is just showing the usage of "SecuritySettings_ListByClusters" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +114,22 @@ public async Task Exists_GetSecuritySettings() // get the collection of this HciClusterSecuritySettingResource HciClusterSecuritySettingCollection collection = hciCluster.GetHciClusterSecuritySettings(); - // invoke the operation - string securitySettingsName = "default"; - bool result = await collection.ExistsAsync(securitySettingsName); + // invoke the operation and iterate over the result + await foreach (HciClusterSecuritySettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterSecuritySettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSecuritySettings() + public async Task Exists_GetSecuritySettings() { // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetSecuritySettings.json // this example is just showing the usage of "SecuritySettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +152,17 @@ public async Task GetIfExists_GetSecuritySettings() // invoke the operation string securitySettingsName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(securitySettingsName); - HciClusterSecuritySettingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(securitySettingsName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterSecuritySettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSecuritySettings() + public async Task GetIfExists_GetSecuritySettings() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PutSecuritySettings.json - // this example is just showing the usage of "SecuritySettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetSecuritySettings.json + // this example is just showing the usage of "SecuritySettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,20 +182,21 @@ public async Task CreateOrUpdate_CreateSecuritySettings() // invoke the operation string securitySettingsName = "default"; - HciClusterSecuritySettingData data = new HciClusterSecuritySettingData() - { - SecuredCoreComplianceAssignment = HciClusterComplianceAssignmentType.Audit, - WdacComplianceAssignment = HciClusterComplianceAssignmentType.ApplyAndAutoCorrect, - SmbEncryptionForIntraClusterTrafficComplianceAssignment = HciClusterComplianceAssignmentType.Audit, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securitySettingsName, data); - HciClusterSecuritySettingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(securitySettingsName); + HciClusterSecuritySettingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterSecuritySettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterSecuritySettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterSecuritySettingResource.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterSecuritySettingResource.cs index a387da5a2c54c..941fe8e7d30f0 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterSecuritySettingResource.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterSecuritySettingResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetSecuritySettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateSecuritySettings() + public async Task Delete_DeleteSecuritySettings() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PutSecuritySettings.json - // this example is just showing the usage of "SecuritySettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteSecuritySettings.json + // this example is just showing the usage of "SecuritySettings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,28 +69,17 @@ public async Task Update_CreateSecuritySettings() HciClusterSecuritySettingResource hciClusterSecuritySetting = client.GetHciClusterSecuritySettingResource(hciClusterSecuritySettingResourceId); // invoke the operation - HciClusterSecuritySettingData data = new HciClusterSecuritySettingData() - { - SecuredCoreComplianceAssignment = HciClusterComplianceAssignmentType.Audit, - WdacComplianceAssignment = HciClusterComplianceAssignmentType.ApplyAndAutoCorrect, - SmbEncryptionForIntraClusterTrafficComplianceAssignment = HciClusterComplianceAssignmentType.Audit, - }; - ArmOperation lro = await hciClusterSecuritySetting.UpdateAsync(WaitUntil.Completed, data); - HciClusterSecuritySettingResource result = lro.Value; + await hciClusterSecuritySetting.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterSecuritySettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSecuritySettings() + public async Task Update_CreateSecuritySettings() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteSecuritySettings.json - // this example is just showing the usage of "SecuritySettings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PutSecuritySettings.json + // this example is just showing the usage of "SecuritySettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +96,20 @@ public async Task Delete_DeleteSecuritySettings() HciClusterSecuritySettingResource hciClusterSecuritySetting = client.GetHciClusterSecuritySettingResource(hciClusterSecuritySettingResourceId); // invoke the operation - await hciClusterSecuritySetting.DeleteAsync(WaitUntil.Completed); + HciClusterSecuritySettingData data = new HciClusterSecuritySettingData + { + SecuredCoreComplianceAssignment = HciClusterComplianceAssignmentType.Audit, + WdacComplianceAssignment = HciClusterComplianceAssignmentType.ApplyAndAutoCorrect, + SmbEncryptionForIntraClusterTrafficComplianceAssignment = HciClusterComplianceAssignmentType.Audit, + }; + ArmOperation lro = await hciClusterSecuritySetting.UpdateAsync(WaitUntil.Completed, data); + HciClusterSecuritySettingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterSecuritySettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateCollection.cs index de914141c9d86..cea44a2eb882e 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateCollection.cs @@ -16,42 +16,6 @@ namespace Azure.ResourceManager.Hci.Samples { public partial class Sample_HciClusterUpdateCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAvailableUpdates() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListUpdates.json - // this example is just showing the usage of "Updates_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HciClusterResource created on azure - // for more information of creating HciClusterResource, please refer to the document of HciClusterResource - string subscriptionId = "b8d594e5-51f3-4c11-9c54-a7771b81c712"; - string resourceGroupName = "testrg"; - string clusterName = "testcluster"; - ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); - HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); - - // get the collection of this HciClusterUpdateResource - HciClusterUpdateCollection collection = hciCluster.GetHciClusterUpdates(); - - // invoke the operation and iterate over the result - await foreach (HciClusterUpdateResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterUpdateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_PutASpecificUpdate() @@ -77,20 +41,17 @@ public async Task CreateOrUpdate_PutASpecificUpdate() // invoke the operation string updateName = "Microsoft4.2203.2.32"; - HciClusterUpdateData data = new HciClusterUpdateData() + HciClusterUpdateData data = new HciClusterUpdateData { InstalledOn = DateTimeOffset.Parse("2022-04-06T14:08:18.254Z"), Description = "AzS Update 4.2203.2.32", State = HciUpdateState.Installed, - Prerequisites = -{ -new HciClusterUpdatePrerequisite() + Prerequisites = {new HciClusterUpdatePrerequisite { UpdateType = "update type", Version = "prerequisite version", PackageName = "update package name", -} -}, +}}, PackagePath = "\\\\SU1FileServer\\SU1_Infrastructure_2\\Updates\\Packages\\Microsoft4.2203.2.32", PackageSizeInMb = 18858, DisplayName = "AzS Update - 4.2203.2.32", @@ -147,6 +108,42 @@ public async Task Get_GetASpecificUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAvailableUpdates() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListUpdates.json + // this example is just showing the usage of "Updates_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HciClusterResource created on azure + // for more information of creating HciClusterResource, please refer to the document of HciClusterResource + string subscriptionId = "b8d594e5-51f3-4c11-9c54-a7771b81c712"; + string resourceGroupName = "testrg"; + string clusterName = "testcluster"; + ResourceIdentifier hciClusterResourceId = HciClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); + HciClusterResource hciCluster = client.GetHciClusterResource(hciClusterResourceId); + + // get the collection of this HciClusterUpdateResource + HciClusterUpdateCollection collection = hciCluster.GetHciClusterUpdates(); + + // invoke the operation and iterate over the result + await foreach (HciClusterUpdateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterUpdateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetASpecificUpdate() diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateResource.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateResource.cs index 738fb3c1ee13e..0e8d62fc98bb1 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateResource.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateResource.cs @@ -18,10 +18,10 @@ public partial class Sample_HciClusterUpdateResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Post_ListAvailableUpdates() + public async Task Get_GetASpecificUpdate() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PostUpdates.json - // this example is just showing the usage of "Updates_Post" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetUpdates.json + // this example is just showing the usage of "Updates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,13 @@ public async Task Post_ListAvailableUpdates() HciClusterUpdateResource hciClusterUpdate = client.GetHciClusterUpdateResource(hciClusterUpdateResourceId); // invoke the operation - await hciClusterUpdate.PostAsync(WaitUntil.Completed); + HciClusterUpdateResource result = await hciClusterUpdate.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterUpdateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,20 +96,17 @@ public async Task Update_PutASpecificUpdate() HciClusterUpdateResource hciClusterUpdate = client.GetHciClusterUpdateResource(hciClusterUpdateResourceId); // invoke the operation - HciClusterUpdateData data = new HciClusterUpdateData() + HciClusterUpdateData data = new HciClusterUpdateData { InstalledOn = DateTimeOffset.Parse("2022-04-06T14:08:18.254Z"), Description = "AzS Update 4.2203.2.32", State = HciUpdateState.Installed, - Prerequisites = -{ -new HciClusterUpdatePrerequisite() + Prerequisites = {new HciClusterUpdatePrerequisite { UpdateType = "update type", Version = "prerequisite version", PackageName = "update package name", -} -}, +}}, PackagePath = "\\\\SU1FileServer\\SU1_Infrastructure_2\\Updates\\Packages\\Microsoft4.2203.2.32", PackageSizeInMb = 18858, DisplayName = "AzS Update - 4.2203.2.32", @@ -130,10 +131,10 @@ public async Task Update_PutASpecificUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetASpecificUpdate() + public async Task Post_ListAvailableUpdates() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetUpdates.json - // this example is just showing the usage of "Updates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PostUpdates.json + // this example is just showing the usage of "Updates_Post" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,13 +151,9 @@ public async Task Get_GetASpecificUpdate() HciClusterUpdateResource hciClusterUpdate = client.GetHciClusterUpdateResource(hciClusterUpdateResourceId); // invoke the operation - HciClusterUpdateResource result = await hciClusterUpdate.GetAsync(); + await hciClusterUpdate.PostAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterUpdateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateRunCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateRunCollection.cs index 3e7bda243ac51..f77da7ecf65a2 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateRunCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateRunCollection.cs @@ -16,43 +16,6 @@ namespace Azure.ResourceManager.Hci.Samples { public partial class Sample_HciClusterUpdateRunCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListUpdateRunsUnderClusterResource() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListUpdateRuns.json - // this example is just showing the usage of "UpdateRuns_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HciClusterUpdateResource created on azure - // for more information of creating HciClusterUpdateResource, please refer to the document of HciClusterUpdateResource - string subscriptionId = "b8d594e5-51f3-4c11-9c54-a7771b81c712"; - string resourceGroupName = "testrg"; - string clusterName = "testcluster"; - string updateName = "Microsoft4.2203.2.32"; - ResourceIdentifier hciClusterUpdateResourceId = HciClusterUpdateResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, updateName); - HciClusterUpdateResource hciClusterUpdate = client.GetHciClusterUpdateResource(hciClusterUpdateResourceId); - - // get the collection of this HciClusterUpdateRunResource - HciClusterUpdateRunCollection collection = hciClusterUpdate.GetHciClusterUpdateRuns(); - - // invoke the operation and iterate over the result - await foreach (HciClusterUpdateRunResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterUpdateRunData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_GetUpdateRunsUnderClusterResource() @@ -79,7 +42,7 @@ public async Task CreateOrUpdate_GetUpdateRunsUnderClusterResource() // invoke the operation string updateRunName = "23b779ba-0d52-4a80-8571-45ca74664ec3"; - HciClusterUpdateRunData data = new HciClusterUpdateRunData() + HciClusterUpdateRunData data = new HciClusterUpdateRunData { NamePropertiesProgressName = "Unnamed step", Description = "Update Azure Stack.", @@ -88,9 +51,7 @@ public async Task CreateOrUpdate_GetUpdateRunsUnderClusterResource() StartOn = DateTimeOffset.Parse("2022-04-06T01:36:33.3876751+00:00"), EndOn = DateTimeOffset.Parse("2022-04-06T13:58:42.969006+00:00"), LastCompletedOn = DateTimeOffset.Parse("2022-04-06T13:58:42.969006+00:00"), - Steps = -{ -new HciUpdateStep() + Steps = {new HciUpdateStep { Name = "PreUpdate Cloud", Description = "Prepare for SSU update", @@ -99,11 +60,8 @@ public async Task CreateOrUpdate_GetUpdateRunsUnderClusterResource() StartOn = DateTimeOffset.Parse("2022-04-06T01:36:33.3876751+00:00"), EndOn = DateTimeOffset.Parse("2022-04-06T01:37:16.8728314+00:00"), LastUpdatedOn = DateTimeOffset.Parse("2022-04-06T01:37:16.8728314+00:00"), -Steps = -{ -}, -} -}, +Steps = {}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, updateRunName, data); HciClusterUpdateRunResource result = lro.Value; @@ -150,6 +108,43 @@ public async Task Get_GetUpdateRunsUnderClusterResource() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListUpdateRunsUnderClusterResource() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListUpdateRuns.json + // this example is just showing the usage of "UpdateRuns_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HciClusterUpdateResource created on azure + // for more information of creating HciClusterUpdateResource, please refer to the document of HciClusterUpdateResource + string subscriptionId = "b8d594e5-51f3-4c11-9c54-a7771b81c712"; + string resourceGroupName = "testrg"; + string clusterName = "testcluster"; + string updateName = "Microsoft4.2203.2.32"; + ResourceIdentifier hciClusterUpdateResourceId = HciClusterUpdateResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, updateName); + HciClusterUpdateResource hciClusterUpdate = client.GetHciClusterUpdateResource(hciClusterUpdateResourceId); + + // get the collection of this HciClusterUpdateRunResource + HciClusterUpdateRunCollection collection = hciClusterUpdate.GetHciClusterUpdateRuns(); + + // invoke the operation and iterate over the result + await foreach (HciClusterUpdateRunResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterUpdateRunData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetUpdateRunsUnderClusterResource() diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateRunResource.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateRunResource.cs index bb13bff9bcb1e..2008ad9438601 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateRunResource.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateRunResource.cs @@ -16,6 +16,38 @@ namespace Azure.ResourceManager.Hci.Samples { public partial class Sample_HciClusterUpdateRunResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetUpdateRunsUnderClusterResource() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetUpdateRuns.json + // this example is just showing the usage of "UpdateRuns_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HciClusterUpdateRunResource created on azure + // for more information of creating HciClusterUpdateRunResource, please refer to the document of HciClusterUpdateRunResource + string subscriptionId = "b8d594e5-51f3-4c11-9c54-a7771b81c712"; + string resourceGroupName = "testrg"; + string clusterName = "testcluster"; + string updateName = "Microsoft4.2203.2.32"; + string updateRunName = "23b779ba-0d52-4a80-8571-45ca74664ec3"; + ResourceIdentifier hciClusterUpdateRunResourceId = HciClusterUpdateRunResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, updateName, updateRunName); + HciClusterUpdateRunResource hciClusterUpdateRun = client.GetHciClusterUpdateRunResource(hciClusterUpdateRunResourceId); + + // invoke the operation + HciClusterUpdateRunResource result = await hciClusterUpdateRun.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterUpdateRunData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Delete_DeleteAnUpdate() @@ -67,7 +99,7 @@ public async Task Update_GetUpdateRunsUnderClusterResource() HciClusterUpdateRunResource hciClusterUpdateRun = client.GetHciClusterUpdateRunResource(hciClusterUpdateRunResourceId); // invoke the operation - HciClusterUpdateRunData data = new HciClusterUpdateRunData() + HciClusterUpdateRunData data = new HciClusterUpdateRunData { NamePropertiesProgressName = "Unnamed step", Description = "Update Azure Stack.", @@ -76,9 +108,7 @@ public async Task Update_GetUpdateRunsUnderClusterResource() StartOn = DateTimeOffset.Parse("2022-04-06T01:36:33.3876751+00:00"), EndOn = DateTimeOffset.Parse("2022-04-06T13:58:42.969006+00:00"), LastCompletedOn = DateTimeOffset.Parse("2022-04-06T13:58:42.969006+00:00"), - Steps = -{ -new HciUpdateStep() + Steps = {new HciUpdateStep { Name = "PreUpdate Cloud", Description = "Prepare for SSU update", @@ -87,11 +117,8 @@ public async Task Update_GetUpdateRunsUnderClusterResource() StartOn = DateTimeOffset.Parse("2022-04-06T01:36:33.3876751+00:00"), EndOn = DateTimeOffset.Parse("2022-04-06T01:37:16.8728314+00:00"), LastUpdatedOn = DateTimeOffset.Parse("2022-04-06T01:37:16.8728314+00:00"), -Steps = -{ -}, -} -}, +Steps = {}, +}}, }; ArmOperation lro = await hciClusterUpdateRun.UpdateAsync(WaitUntil.Completed, data); HciClusterUpdateRunResource result = lro.Value; @@ -102,37 +129,5 @@ public async Task Update_GetUpdateRunsUnderClusterResource() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetUpdateRunsUnderClusterResource() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetUpdateRuns.json - // this example is just showing the usage of "UpdateRuns_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HciClusterUpdateRunResource created on azure - // for more information of creating HciClusterUpdateRunResource, please refer to the document of HciClusterUpdateRunResource - string subscriptionId = "b8d594e5-51f3-4c11-9c54-a7771b81c712"; - string resourceGroupName = "testrg"; - string clusterName = "testcluster"; - string updateName = "Microsoft4.2203.2.32"; - string updateRunName = "23b779ba-0d52-4a80-8571-45ca74664ec3"; - ResourceIdentifier hciClusterUpdateRunResourceId = HciClusterUpdateRunResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, updateName, updateRunName); - HciClusterUpdateRunResource hciClusterUpdateRun = client.GetHciClusterUpdateRunResource(hciClusterUpdateRunResourceId); - - // invoke the operation - HciClusterUpdateRunResource result = await hciClusterUpdateRun.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterUpdateRunData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateSummaryResource.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateSummaryResource.cs index 90a7a28b4c849..0ada43e154a71 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateSummaryResource.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciClusterUpdateSummaryResource.cs @@ -18,10 +18,10 @@ public partial class Sample_HciClusterUpdateSummaryResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnUpdate() + public async Task Get_GetUpdateSummariesUnderClusterResource() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteUpdateSummaries.json - // this example is just showing the usage of "UpdateSummaries_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetUpdateSummaries.json + // this example is just showing the usage of "UpdateSummaries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task Delete_DeleteAnUpdate() HciClusterUpdateSummaryResource hciClusterUpdateSummary = client.GetHciClusterUpdateSummaryResource(hciClusterUpdateSummaryResourceId); // invoke the operation - await hciClusterUpdateSummary.DeleteAsync(WaitUntil.Completed); + HciClusterUpdateSummaryResource result = await hciClusterUpdateSummary.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterUpdateSummaryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutUpdateSummariesUnderClusterResource() + public async Task Delete_DeleteAnUpdate() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PutUpdateSummaries.json - // this example is just showing the usage of "UpdateSummaries_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteUpdateSummaries.json + // this example is just showing the usage of "UpdateSummaries_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,31 +67,17 @@ public async Task CreateOrUpdate_PutUpdateSummariesUnderClusterResource() HciClusterUpdateSummaryResource hciClusterUpdateSummary = client.GetHciClusterUpdateSummaryResource(hciClusterUpdateSummaryResourceId); // invoke the operation - HciClusterUpdateSummaryData data = new HciClusterUpdateSummaryData() - { - OemFamily = "DellEMC", - HardwareModel = "PowerEdge R730xd", - CurrentVersion = "4.2203.2.32", - LastUpdatedOn = DateTimeOffset.Parse("2022-04-06T14:08:18.254Z"), - LastCheckedOn = DateTimeOffset.Parse("2022-04-07T18:04:07Z"), - State = HciClusterUpdateState.AppliedSuccessfully, - }; - ArmOperation lro = await hciClusterUpdateSummary.CreateOrUpdateAsync(WaitUntil.Completed, data); - HciClusterUpdateSummaryResource result = lro.Value; + await hciClusterUpdateSummary.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciClusterUpdateSummaryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetUpdateSummariesUnderClusterResource() + public async Task CreateOrUpdate_PutUpdateSummariesUnderClusterResource() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetUpdateSummaries.json - // this example is just showing the usage of "UpdateSummaries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/PutUpdateSummaries.json + // this example is just showing the usage of "UpdateSummaries_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,7 +93,17 @@ public async Task Get_GetUpdateSummariesUnderClusterResource() HciClusterUpdateSummaryResource hciClusterUpdateSummary = client.GetHciClusterUpdateSummaryResource(hciClusterUpdateSummaryResourceId); // invoke the operation - HciClusterUpdateSummaryResource result = await hciClusterUpdateSummary.GetAsync(); + HciClusterUpdateSummaryData data = new HciClusterUpdateSummaryData + { + OemFamily = "DellEMC", + HardwareModel = "PowerEdge R730xd", + CurrentVersion = "4.2203.2.32", + LastUpdatedOn = DateTimeOffset.Parse("2022-04-06T14:08:18.254Z"), + LastCheckedOn = DateTimeOffset.Parse("2022-04-07T18:04:07Z"), + State = HciClusterUpdateState.AppliedSuccessfully, + }; + ArmOperation lro = await hciClusterUpdateSummary.CreateOrUpdateAsync(WaitUntil.Completed, data); + HciClusterUpdateSummaryResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciEdgeDeviceCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciEdgeDeviceCollection.cs index 68a2a8b6f01e8..666520f03a398 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciEdgeDeviceCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciEdgeDeviceCollection.cs @@ -18,35 +18,52 @@ public partial class Sample_HciEdgeDeviceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListEdgeDevices() + public async Task CreateOrUpdate_CreateHCIEdgeDevice() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListEdgeDevices.json - // this example is just showing the usage of "EdgeDevices_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/CreateHciEdgeDevice.json + // this example is just showing the usage of "EdgeDevices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this HciEdgeDeviceResource string resourceUri = "subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - HciEdgeDeviceCollection collection = client.GetHciEdgeDevices(scopeId); + HciEdgeDeviceCollection collection = client.GetHciEdgeDevices(new ResourceIdentifier(resourceUri)); - // invoke the operation and iterate over the result - await foreach (HciEdgeDeviceResource item in collection.GetAllAsync()) + // invoke the operation + string edgeDeviceName = "default"; + HciEdgeDeviceData data = new HciArcEnabledEdgeDevice { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciEdgeDeviceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new HciArcEnabledEdgeDeviceProperties + { + DeviceConfiguration = new HciEdgeDeviceConfiguration + { + NicDetails = {new HciEdgeDeviceNicDetail +{ +AdapterName = "ethernet", +InterfaceDescription = "NDIS 6.70 ", +ComponentId = "VMBUS{f8615163-df3e-46c5-913f-f2d2f965ed0g} ", +DriverVersion = "10.0.20348.1547 ", +IPv4Address = "10.10.10.10", +SubnetMask = "255.255.255.0", +DefaultGateway = "10.10.10.1", +DnsServers = {"100.10.10.1"}, +DefaultIsolationId = "0", +}}, + DeviceMetadata = "", + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, edgeDeviceName, data); + HciEdgeDeviceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciEdgeDeviceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -61,13 +78,9 @@ public async Task Get_GetEdgeDevice() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this HciEdgeDeviceResource string resourceUri = "subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - HciEdgeDeviceCollection collection = client.GetHciEdgeDevices(scopeId); + HciEdgeDeviceCollection collection = client.GetHciEdgeDevices(new ResourceIdentifier(resourceUri)); // invoke the operation string edgeDeviceName = "default"; @@ -80,6 +93,35 @@ public async Task Get_GetEdgeDevice() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListEdgeDevices() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListEdgeDevices.json + // this example is just showing the usage of "EdgeDevices_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this HciEdgeDeviceResource + string resourceUri = "subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"; + HciEdgeDeviceCollection collection = client.GetHciEdgeDevices(new ResourceIdentifier(resourceUri)); + + // invoke the operation and iterate over the result + await foreach (HciEdgeDeviceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciEdgeDeviceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetEdgeDevice() @@ -92,13 +134,9 @@ public async Task Exists_GetEdgeDevice() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this HciEdgeDeviceResource string resourceUri = "subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - HciEdgeDeviceCollection collection = client.GetHciEdgeDevices(scopeId); + HciEdgeDeviceCollection collection = client.GetHciEdgeDevices(new ResourceIdentifier(resourceUri)); // invoke the operation string edgeDeviceName = "default"; @@ -119,13 +157,9 @@ public async Task GetIfExists_GetEdgeDevice() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this HciEdgeDeviceResource string resourceUri = "subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - HciEdgeDeviceCollection collection = client.GetHciEdgeDevices(scopeId); + HciEdgeDeviceCollection collection = client.GetHciEdgeDevices(new ResourceIdentifier(resourceUri)); // invoke the operation string edgeDeviceName = "default"; @@ -145,65 +179,5 @@ public async Task GetIfExists_GetEdgeDevice() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateHCIEdgeDevice() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/CreateHciEdgeDevice.json - // this example is just showing the usage of "EdgeDevices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this HciEdgeDeviceResource - string resourceUri = "subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - HciEdgeDeviceCollection collection = client.GetHciEdgeDevices(scopeId); - - // invoke the operation - string edgeDeviceName = "default"; - HciEdgeDeviceData data = new HciArcEnabledEdgeDevice() - { - Properties = new HciArcEnabledEdgeDeviceProperties() - { - DeviceConfiguration = new HciEdgeDeviceConfiguration() - { - NicDetails = -{ -new HciEdgeDeviceNicDetail() -{ -AdapterName = "ethernet", -InterfaceDescription = "NDIS 6.70 ", -ComponentId = "VMBUS{f8615163-df3e-46c5-913f-f2d2f965ed0g} ", -DriverVersion = "10.0.20348.1547 ", -IPv4Address = "10.10.10.10", -SubnetMask = "255.255.255.0", -DefaultGateway = "10.10.10.1", -DnsServers = -{ -"100.10.10.1" -}, -DefaultIsolationId = "0", -} -}, - DeviceMetadata = "", - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, edgeDeviceName, data); - HciEdgeDeviceResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciEdgeDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciEdgeDeviceResource.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciEdgeDeviceResource.cs index c90d973236e54..259134149d72d 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciEdgeDeviceResource.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciEdgeDeviceResource.cs @@ -45,6 +45,31 @@ public async Task Get_GetEdgeDevice() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteEdgeDevices() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteEdgeDevices.json + // this example is just showing the usage of "EdgeDevices_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this HciEdgeDeviceResource created on azure + // for more information of creating HciEdgeDeviceResource, please refer to the document of HciEdgeDeviceResource + string resourceUri = "subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"; + string edgeDeviceName = "default"; + ResourceIdentifier hciEdgeDeviceResourceId = HciEdgeDeviceResource.CreateResourceIdentifier(resourceUri, edgeDeviceName); + HciEdgeDeviceResource hciEdgeDevice = client.GetHciEdgeDeviceResource(hciEdgeDeviceResourceId); + + // invoke the operation + await hciEdgeDevice.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateHCIEdgeDevice() @@ -65,15 +90,13 @@ public async Task Update_CreateHCIEdgeDevice() HciEdgeDeviceResource hciEdgeDevice = client.GetHciEdgeDeviceResource(hciEdgeDeviceResourceId); // invoke the operation - HciEdgeDeviceData data = new HciArcEnabledEdgeDevice() + HciEdgeDeviceData data = new HciArcEnabledEdgeDevice { - Properties = new HciArcEnabledEdgeDeviceProperties() + Properties = new HciArcEnabledEdgeDeviceProperties { - DeviceConfiguration = new HciEdgeDeviceConfiguration() + DeviceConfiguration = new HciEdgeDeviceConfiguration { - NicDetails = -{ -new HciEdgeDeviceNicDetail() + NicDetails = {new HciEdgeDeviceNicDetail { AdapterName = "ethernet", InterfaceDescription = "NDIS 6.70 ", @@ -82,13 +105,9 @@ public async Task Update_CreateHCIEdgeDevice() IPv4Address = "10.10.10.10", SubnetMask = "255.255.255.0", DefaultGateway = "10.10.10.1", -DnsServers = -{ -"100.10.10.1" -}, +DnsServers = {"100.10.10.1"}, DefaultIsolationId = "0", -} -}, +}}, DeviceMetadata = "", }, }, @@ -103,31 +122,6 @@ public async Task Update_CreateHCIEdgeDevice() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteEdgeDevices() - { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/DeleteEdgeDevices.json - // this example is just showing the usage of "EdgeDevices_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this HciEdgeDeviceResource created on azure - // for more information of creating HciEdgeDeviceResource, please refer to the document of HciEdgeDeviceResource - string resourceUri = "subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1"; - string edgeDeviceName = "default"; - ResourceIdentifier hciEdgeDeviceResourceId = HciEdgeDeviceResource.CreateResourceIdentifier(resourceUri, edgeDeviceName); - HciEdgeDeviceResource hciEdgeDevice = client.GetHciEdgeDeviceResource(hciEdgeDeviceResourceId); - - // invoke the operation - await hciEdgeDevice.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Validate_ValidateEdgeDevices() @@ -148,10 +142,7 @@ public async Task Validate_ValidateEdgeDevices() HciEdgeDeviceResource hciEdgeDevice = client.GetHciEdgeDeviceResource(hciEdgeDeviceResourceId); // invoke the operation - HciEdgeDeviceValidateContent content = new HciEdgeDeviceValidateContent(new ResourceIdentifier[] - { -new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1/edgeDevices/default"),new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-2/edgeDevices/default") - }) + HciEdgeDeviceValidateContent content = new HciEdgeDeviceValidateContent(new ResourceIdentifier[] { new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-1/edgeDevices/default"), new ResourceIdentifier("/subscriptions/fd3c3665-1729-4b7b-9a38-238e83b0f98b/resourceGroups/ArcInstance-rg/providers/Microsoft.HybridCompute/machines/Node-2/edgeDevices/default") }) { AdditionalInfo = "test", }; diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciSkuCollection.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciSkuCollection.cs index 21b1b7d64dd02..2206042be77b2 100644 --- a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciSkuCollection.cs +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_HciSkuCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HciSkuCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSKUResourcesByOfferForTheHCICluster() + public async Task Get_GetSku() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListSkusByOffer.json - // this example is just showing the usage of "Skus_ListByOffer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetSku.json + // this example is just showing the usage of "Skus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListSKUResourcesByOfferForTheHCICluster() // get the collection of this HciSkuResource HciSkuCollection collection = hciClusterOffer.GetHciSkus(); - // invoke the operation and iterate over the result - await foreach (HciSkuResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciSkuData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string skuName = "sku1"; + HciSkuResource result = await collection.GetAsync(skuName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSku() + public async Task GetAll_ListSKUResourcesByOfferForTheHCICluster() { - // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/GetSku.json - // this example is just showing the usage of "Skus_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListSkusByOffer.json + // this example is just showing the usage of "Skus_ListByOffer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetSku() // get the collection of this HciSkuResource HciSkuCollection collection = hciClusterOffer.GetHciSkus(); - // invoke the operation - string skuName = "sku1"; - HciSkuResource result = await collection.GetAsync(skuName); + // invoke the operation and iterate over the result + await foreach (HciSkuResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciSkuData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HciSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..b5e74bb29aa08 --- /dev/null +++ b/sdk/azurestackhci/Azure.ResourceManager.Hci/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Hci.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetHciClusters_ListClustersInAGivenSubscription() + { + // Generated from example definition: specification/azurestackhci/resource-manager/Microsoft.AzureStackHCI/StackHCI/stable/2024-04-01/examples/ListClustersBySubscription.json + // this example is just showing the usage of "Clusters_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "fd3c3665-1729-4b7b-9a38-238e83b0f98b"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (HciClusterResource item in subscriptionResource.GetHciClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HciClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCertificateCollection.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCertificateCollection.cs index af9bd83b5ef0f..a069e377c4867 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCertificateCollection.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCertificateCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BatchAccountCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCertificates() + public async Task CreateOrUpdate_CreateCertificateFull() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateList.json - // this example is just showing the usage of "Certificate_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateCreate_Full.json + // this example is just showing the usage of "Certificate_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,32 @@ public async Task GetAll_ListCertificates() // get the collection of this BatchAccountCertificateResource BatchAccountCertificateCollection collection = batchAccount.GetBatchAccountCertificates(); - // invoke the operation and iterate over the result - await foreach (BatchAccountCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"; + BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ThumbprintAlgorithm = "sha1", + ThumbprintString = "0a0e4f50d51beadeac1d35afc5116098e7902e6e", + Format = BatchAccountCertificateFormat.Pfx, + Data = BinaryData.FromObjectAsJson("MIIJsgIBAzCCCW4GCSqGSIb3DQE..."), + Password = "", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, content); + BatchAccountCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCertificatesFilterAndSelect() + public async Task CreateOrUpdate_CreateCertificateMinimalCer() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateListWithFilter.json - // this example is just showing the usage of "Certificate_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateCreate_MinimalCer.json + // this example is just showing the usage of "Certificate_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,26 +82,28 @@ public async Task GetAll_ListCertificatesFilterAndSelect() // get the collection of this BatchAccountCertificateResource BatchAccountCertificateCollection collection = batchAccount.GetBatchAccountCertificates(); - // invoke the operation and iterate over the result - string select = "properties/format,properties/provisioningState"; - string filter = "properties/provisioningStateTransitionTime gt '2017-05-01' or properties/provisioningState eq 'Failed'"; - await foreach (BatchAccountCertificateResource item in collection.GetAllAsync(select: select, filter: filter)) + // invoke the operation + string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"; + BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Format = BatchAccountCertificateFormat.Cer, + Data = BinaryData.FromObjectAsJson("MIICrjCCAZagAwI..."), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, content); + BatchAccountCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCertificateFull() + public async Task CreateOrUpdate_CreateCertificateMinimalPfx() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateCreate_Full.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateCreate_Minimal.json // this example is just showing the usage of "Certificate_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -115,12 +124,9 @@ public async Task CreateOrUpdate_CreateCertificateFull() // invoke the operation string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"; - BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent() + BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent { - ThumbprintAlgorithm = "sha1", - ThumbprintString = "0a0e4f50d51beadeac1d35afc5116098e7902e6e", - Format = BatchAccountCertificateFormat.Pfx, - Data = BinaryData.FromString("\"MIIJsgIBAzCCCW4GCSqGSIb3DQE...\""), + Data = BinaryData.FromObjectAsJson("MIIJsgIBAzCCCW4GCSqGSIb3DQE..."), Password = "", }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, content); @@ -135,10 +141,10 @@ public async Task CreateOrUpdate_CreateCertificateFull() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCertificateMinimalCer() + public async Task Get_GetCertificate() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateCreate_MinimalCer.json - // this example is just showing the usage of "Certificate_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGet.json + // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -158,13 +164,7 @@ public async Task CreateOrUpdate_CreateCertificateMinimalCer() // invoke the operation string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"; - BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent() - { - Format = BatchAccountCertificateFormat.Cer, - Data = BinaryData.FromString("\"MIICrjCCAZagAwI...\""), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, content); - BatchAccountCertificateResource result = lro.Value; + BatchAccountCertificateResource result = await collection.GetAsync(certificateName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -175,10 +175,10 @@ public async Task CreateOrUpdate_CreateCertificateMinimalCer() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCertificateMinimalPfx() + public async Task Get_GetCertificateWithDeletionError() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateCreate_Minimal.json - // this example is just showing the usage of "Certificate_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGetWithDeletionError.json + // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,13 +198,7 @@ public async Task CreateOrUpdate_CreateCertificateMinimalPfx() // invoke the operation string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"; - BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent() - { - Data = BinaryData.FromString("\"MIIJsgIBAzCCCW4GCSqGSIb3DQE...\""), - Password = "", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, content); - BatchAccountCertificateResource result = lro.Value; + BatchAccountCertificateResource result = await collection.GetAsync(certificateName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -215,10 +209,10 @@ public async Task CreateOrUpdate_CreateCertificateMinimalPfx() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCertificate() + public async Task GetAll_ListCertificates() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGet.json - // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateList.json + // this example is just showing the usage of "Certificate_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,23 +230,25 @@ public async Task Get_GetCertificate() // get the collection of this BatchAccountCertificateResource BatchAccountCertificateCollection collection = batchAccount.GetBatchAccountCertificates(); - // invoke the operation - string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"; - BatchAccountCertificateResource result = await collection.GetAsync(certificateName); + // invoke the operation and iterate over the result + await foreach (BatchAccountCertificateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCertificate() + public async Task GetAll_ListCertificatesFilterAndSelect() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGet.json - // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateListWithFilter.json + // this example is just showing the usage of "Certificate_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -270,16 +266,24 @@ public async Task Exists_GetCertificate() // get the collection of this BatchAccountCertificateResource BatchAccountCertificateCollection collection = batchAccount.GetBatchAccountCertificates(); - // invoke the operation - string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"; - bool result = await collection.ExistsAsync(certificateName); + // invoke the operation and iterate over the result + string select = "properties/format,properties/provisioningState"; + string filter = "properties/provisioningStateTransitionTime gt '2017-05-01' or properties/provisioningState eq 'Failed'"; + await foreach (BatchAccountCertificateResource item in collection.GetAllAsync(select: select, filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCertificate() + public async Task Exists_GetCertificate() { // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGet.json // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. @@ -302,26 +306,14 @@ public async Task GetIfExists_GetCertificate() // invoke the operation string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"; - NullableResponse response = await collection.GetIfExistsAsync(certificateName); - BatchAccountCertificateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(certificateName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCertificateWithDeletionError() + public async Task Exists_GetCertificateWithDeletionError() { // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGetWithDeletionError.json // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. @@ -344,20 +336,16 @@ public async Task Get_GetCertificateWithDeletionError() // invoke the operation string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"; - BatchAccountCertificateResource result = await collection.GetAsync(certificateName); + bool result = await collection.ExistsAsync(certificateName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCertificateWithDeletionError() + public async Task GetIfExists_GetCertificate() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGetWithDeletionError.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGet.json // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -378,9 +366,21 @@ public async Task Exists_GetCertificateWithDeletionError() // invoke the operation string certificateName = "sha1-0a0e4f50d51beadeac1d35afc5116098e7902e6e"; - bool result = await collection.ExistsAsync(certificateName); + NullableResponse response = await collection.GetIfExistsAsync(certificateName); + BatchAccountCertificateResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCertificateResource.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCertificateResource.cs index 4829756cf021a..ad9d900e1bfaa 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCertificateResource.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCertificateResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BatchAccountCertificateResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateCertificate() + public async Task Get_GetCertificate() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateUpdate.json - // this example is just showing the usage of "Certificate_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGet.json + // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,12 +38,7 @@ public async Task Update_UpdateCertificate() BatchAccountCertificateResource batchAccountCertificate = client.GetBatchAccountCertificateResource(batchAccountCertificateResourceId); // invoke the operation - BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent() - { - Data = BinaryData.FromString("\"MIIJsgIBAzCCCW4GCSqGSIb3DQE...\""), - Password = "", - }; - BatchAccountCertificateResource result = await batchAccountCertificate.UpdateAsync(content); + BatchAccountCertificateResource result = await batchAccountCertificate.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +49,10 @@ public async Task Update_UpdateCertificate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CertificateDelete() + public async Task Get_GetCertificateWithDeletionError() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateDelete.json - // this example is just showing the usage of "Certificate_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGetWithDeletionError.json + // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,17 +69,21 @@ public async Task Delete_CertificateDelete() BatchAccountCertificateResource batchAccountCertificate = client.GetBatchAccountCertificateResource(batchAccountCertificateResourceId); // invoke the operation - await batchAccountCertificate.DeleteAsync(WaitUntil.Completed); + BatchAccountCertificateResource result = await batchAccountCertificate.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCertificate() + public async Task Delete_CertificateDelete() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGet.json - // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateDelete.json + // this example is just showing the usage of "Certificate_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,21 +100,17 @@ public async Task Get_GetCertificate() BatchAccountCertificateResource batchAccountCertificate = client.GetBatchAccountCertificateResource(batchAccountCertificateResourceId); // invoke the operation - BatchAccountCertificateResource result = await batchAccountCertificate.GetAsync(); + await batchAccountCertificate.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCertificateWithDeletionError() + public async Task Update_UpdateCertificate() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateGetWithDeletionError.json - // this example is just showing the usage of "Certificate_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/CertificateUpdate.json + // this example is just showing the usage of "Certificate_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,7 +127,12 @@ public async Task Get_GetCertificateWithDeletionError() BatchAccountCertificateResource batchAccountCertificate = client.GetBatchAccountCertificateResource(batchAccountCertificateResourceId); // invoke the operation - BatchAccountCertificateResource result = await batchAccountCertificate.GetAsync(); + BatchAccountCertificateCreateOrUpdateContent content = new BatchAccountCertificateCreateOrUpdateContent + { + Data = BinaryData.FromObjectAsJson("MIIJsgIBAzCCCW4GCSqGSIb3DQE..."), + Password = "", + }; + BatchAccountCertificateResource result = await batchAccountCertificate.UpdateAsync(content); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCollection.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCollection.cs index 9e5160a734bc7..a652f1678df17 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCollection.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountCollection.cs @@ -165,7 +165,7 @@ public async Task CreateOrUpdate_BatchAccountCreateUserAssignedIdentity() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() }, }, AutoStorage = new BatchAccountAutoStorageBaseConfiguration(new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Storage/storageAccounts/samplestorage")), @@ -255,9 +255,9 @@ public async Task Get_BatchAccountGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BatchAccountGet() + public async Task Get_PrivateBatchAccountGet() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountGet.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateBatchAccountGet.json // this example is just showing the usage of "BatchAccount_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -277,17 +277,21 @@ public async Task Exists_BatchAccountGet() // invoke the operation string accountName = "sampleacct"; - bool result = await collection.ExistsAsync(accountName); + BatchAccountResource result = await collection.GetAsync(accountName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BatchAccountGet() + public async Task GetAll_BatchAccountListByResourceGroup() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountGet.json - // this example is just showing the usage of "BatchAccount_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountListByResourceGroup.json + // this example is just showing the usage of "BatchAccount_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -304,30 +308,24 @@ public async Task GetIfExists_BatchAccountGet() // get the collection of this BatchAccountResource BatchAccountCollection collection = resourceGroupResource.GetBatchAccounts(); - // invoke the operation - string accountName = "sampleacct"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - BatchAccountResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (BatchAccountResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BatchAccountData resourceData = result.Data; + BatchAccountData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateBatchAccountGet() + public async Task Exists_BatchAccountGet() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateBatchAccountGet.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountGet.json // this example is just showing the usage of "BatchAccount_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -347,13 +345,9 @@ public async Task Get_PrivateBatchAccountGet() // invoke the operation string accountName = "sampleacct"; - BatchAccountResource result = await collection.GetAsync(accountName); + bool result = await collection.ExistsAsync(accountName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -387,9 +381,9 @@ public async Task Exists_PrivateBatchAccountGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateBatchAccountGet() + public async Task GetIfExists_BatchAccountGet() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateBatchAccountGet.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountGet.json // this example is just showing the usage of "BatchAccount_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -428,10 +422,10 @@ public async Task GetIfExists_PrivateBatchAccountGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BatchAccountListByResourceGroup() + public async Task GetIfExists_PrivateBatchAccountGet() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountListByResourceGroup.json - // this example is just showing the usage of "BatchAccount_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateBatchAccountGet.json + // this example is just showing the usage of "BatchAccount_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -448,17 +442,23 @@ public async Task GetAll_BatchAccountListByResourceGroup() // get the collection of this BatchAccountResource BatchAccountCollection collection = resourceGroupResource.GetBatchAccounts(); - // invoke the operation and iterate over the result - await foreach (BatchAccountResource item in collection.GetAllAsync()) + // invoke the operation + string accountName = "sampleacct"; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + BatchAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BatchAccountData resourceData = item.Data; + BatchAccountData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountDetectorCollection.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountDetectorCollection.cs index c0e0830200cfc..c3167fbd771a6 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountDetectorCollection.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountDetectorCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_BatchAccountDetectorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDetectors() + public async Task Get_GetDetector() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/DetectorList.json - // this example is just showing the usage of "BatchAccount_ListDetectors" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/DetectorGet.json + // this example is just showing the usage of "BatchAccount_GetDetector" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListDetectors() // get the collection of this BatchAccountDetectorResource BatchAccountDetectorCollection collection = batchAccount.GetBatchAccountDetectors(); - // invoke the operation and iterate over the result - await foreach (BatchAccountDetectorResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountDetectorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string detectorId = "poolsAndNodes"; + BatchAccountDetectorResource result = await collection.GetAsync(detectorId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountDetectorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDetector() + public async Task GetAll_ListDetectors() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/DetectorGet.json - // this example is just showing the usage of "BatchAccount_GetDetector" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/DetectorList.json + // this example is just showing the usage of "BatchAccount_ListDetectors" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetDetector() // get the collection of this BatchAccountDetectorResource BatchAccountDetectorCollection collection = batchAccount.GetBatchAccountDetectors(); - // invoke the operation - string detectorId = "poolsAndNodes"; - BatchAccountDetectorResource result = await collection.GetAsync(detectorId); + // invoke the operation and iterate over the result + await foreach (BatchAccountDetectorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountDetectorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountDetectorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountPoolCollection.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountPoolCollection.cs index 67c17ac9654a8..4a06d5a7999e9 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountPoolCollection.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountPoolCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using System.Xml; using Azure.Core; @@ -19,80 +18,6 @@ namespace Azure.ResourceManager.Batch.Samples { public partial class Sample_BatchAccountPoolCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPool() - { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolList.json - // this example is just showing the usage of "Pool_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BatchAccountResource created on azure - // for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource - string subscriptionId = "subid"; - string resourceGroupName = "default-azurebatch-japaneast"; - string accountName = "sampleacct"; - ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId); - - // get the collection of this BatchAccountPoolResource - BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools(); - - // invoke the operation and iterate over the result - await foreach (BatchAccountPoolResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPoolWithFilter() - { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolListWithFilter.json - // this example is just showing the usage of "Pool_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BatchAccountResource created on azure - // for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource - string subscriptionId = "subid"; - string resourceGroupName = "default-azurebatch-japaneast"; - string accountName = "sampleacct"; - ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId); - - // get the collection of this BatchAccountPoolResource - BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools(); - - // invoke the operation and iterate over the result - string select = "properties/allocationState,properties/provisioningStateTransitionTime,properties/currentDedicatedNodes,properties/currentLowPriorityNodes"; - string filter = "startswith(name, 'po') or (properties/allocationState eq 'Steady' and properties/provisioningStateTransitionTime lt datetime'2017-02-02')"; - await foreach (BatchAccountPoolResource item in collection.GetAllAsync(select: select, filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreatePoolCustomImage() @@ -118,10 +43,10 @@ public async Task CreateOrUpdate_CreatePoolCustomImage() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "STANDARD_D4", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"), }, "batch.node.ubuntu 18.04"), @@ -161,10 +86,10 @@ public async Task CreateOrUpdate_CreatePoolFullVirtualMachineConfiguration() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "STANDARD_D4", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -173,60 +98,42 @@ public async Task CreateOrUpdate_CreatePoolFullVirtualMachineConfiguration() }, "batch.node.windows amd64") { IsAutomaticUpdateEnabled = false, - DataDisks = -{ -new BatchVmDataDisk(0,30) + DataDisks = {new BatchVmDataDisk(0, 30) { Caching = BatchDiskCachingType.ReadWrite, StorageAccountType = BatchStorageAccountType.PremiumLrs, -},new BatchVmDataDisk(1,200) +}, new BatchVmDataDisk(1, 200) { Caching = BatchDiskCachingType.None, StorageAccountType = BatchStorageAccountType.StandardLrs, -} -}, +}}, LicenseType = "Windows_Server", - DiskEncryptionTargets = -{ -BatchDiskEncryptionTarget.OSDisk,BatchDiskEncryptionTarget.TemporaryDisk -}, + DiskEncryptionTargets = { BatchDiskEncryptionTarget.OSDisk, BatchDiskEncryptionTarget.TemporaryDisk }, NodePlacementPolicy = BatchNodePlacementPolicyType.Zonal, - OSDisk = new BatchOSDisk() + OSDisk = new BatchOSDisk { EphemeralOSDiskPlacement = BatchDiffDiskPlacement.CacheDisk, }, }, - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { AutoScale = new BatchAccountAutoScaleSettings("$TargetDedicatedNodes=1") { EvaluationInterval = XmlConvert.ToTimeSpan("PT5M"), }, }, - NetworkConfiguration = new BatchNetworkConfiguration() + NetworkConfiguration = new BatchNetworkConfiguration { - EndpointInboundNatPools = -{ -new BatchInboundNatPool("testnat",BatchInboundEndpointProtocol.Tcp,12001,15000,15100) + EndpointInboundNatPools = {new BatchInboundNatPool("testnat", BatchInboundEndpointProtocol.Tcp, 12001, 15000, 15100) { -NetworkSecurityGroupRules = +NetworkSecurityGroupRules = {new BatchNetworkSecurityGroupRule(150, BatchNetworkSecurityGroupRuleAccess.Allow, "192.100.12.45") { -new BatchNetworkSecurityGroupRule(150,BatchNetworkSecurityGroupRuleAccess.Allow,"192.100.12.45") +SourcePortRanges = {"1", "2"}, +}, new BatchNetworkSecurityGroupRule(3500, BatchNetworkSecurityGroupRuleAccess.Deny, "*") { -SourcePortRanges = -{ -"1","2" -}, -},new BatchNetworkSecurityGroupRule(3500,BatchNetworkSecurityGroupRuleAccess.Deny,"*") -{ -SourcePortRanges = -{ -"*" -}, -} -}, -} -}, +SourcePortRanges = {"*"}, +}}, +}}, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data); @@ -264,17 +171,17 @@ public async Task CreateOrUpdate_CreatePoolMinimalVirtualMachineConfiguration() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "STANDARD_D4", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "Canonical", Offer = "UbuntuServer", Sku = "18.04-LTS", Version = "latest", }, "batch.node.ubuntu 18.04"), - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { AutoScale = new BatchAccountAutoScaleSettings("$TargetDedicatedNodes=1") { @@ -317,17 +224,17 @@ public async Task CreateOrUpdate_CreatePoolNoPublicIP() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "STANDARD_D4", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"), }, "batch.node.ubuntu 18.04"), - NetworkConfiguration = new BatchNetworkConfiguration() + NetworkConfiguration = new BatchNetworkConfiguration { SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"), - PublicIPAddressConfiguration = new BatchPublicIPAddressConfiguration() + PublicIPAddressConfiguration = new BatchPublicIPAddressConfiguration { Provision = BatchIPAddressProvisioningType.NoPublicIPAddresses, }, @@ -368,23 +275,20 @@ public async Task CreateOrUpdate_CreatePoolPublicIPs() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "STANDARD_D4", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/networking-group/providers/Microsoft.Compute/galleries/testgallery/images/testimagedef/versions/0.0.1"), }, "batch.node.ubuntu 18.04"), - NetworkConfiguration = new BatchNetworkConfiguration() + NetworkConfiguration = new BatchNetworkConfiguration { SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"), - PublicIPAddressConfiguration = new BatchPublicIPAddressConfiguration() + PublicIPAddressConfiguration = new BatchPublicIPAddressConfiguration { Provision = BatchIPAddressProvisioningType.UserManaged, - IPAddressIds = -{ -new ResourceIdentifier("/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135") -}, + IPAddressIds = { new ResourceIdentifier("/subscriptions/subid1/resourceGroups/rg13/providers/Microsoft.Network/publicIPAddresses/ip135") }, }, }, }; @@ -423,19 +327,19 @@ public async Task CreateOrUpdate_CreatePoolResourceTags() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "Standard_d4s_v3", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "Canonical", Offer = "UbuntuServer", Sku = "18_04-lts-gen2", Version = "latest", }, "batch.node.ubuntu 18.04"), - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { - FixedScale = new BatchAccountFixedScaleSettings() + FixedScale = new BatchAccountFixedScaleSettings { TargetDedicatedNodes = 1, TargetLowPriorityNodes = 0, @@ -444,7 +348,7 @@ public async Task CreateOrUpdate_CreatePoolResourceTags() ResourceTags = { ["TagName1"] = "TagValue1", -["TagName2"] = "TagValue2", +["TagName2"] = "TagValue2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data); @@ -482,10 +386,10 @@ public async Task CreateOrUpdate_CreatePoolSecurityProfile() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "Standard_d4s_v3", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "Canonical", Offer = "UbuntuServer", @@ -493,20 +397,20 @@ public async Task CreateOrUpdate_CreatePoolSecurityProfile() Version = "latest", }, "batch.node.ubuntu 18.04") { - SecurityProfile = new BatchSecurityProfile() + SecurityProfile = new BatchSecurityProfile { SecurityType = BatchSecurityType.TrustedLaunch, EncryptionAtHost = true, - UefiSettings = new BatchUefiSettings() + UefiSettings = new BatchUefiSettings { - IsSecureBootEnabled = null, + IsSecureBootEnabled = default, IsVTpmEnabled = false, }, }, }, - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { - FixedScale = new BatchAccountFixedScaleSettings() + FixedScale = new BatchAccountFixedScaleSettings { TargetDedicatedNodes = 1, TargetLowPriorityNodes = 0, @@ -548,19 +452,19 @@ public async Task CreateOrUpdate_CreatePoolTags() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "Standard_d4s_v3", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "Canonical", Offer = "0001-com-ubuntu-server-jammy", Sku = "22_04-lts", Version = "latest", }, "batch.node.ubuntu 22.04"), - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { - FixedScale = new BatchAccountFixedScaleSettings() + FixedScale = new BatchAccountFixedScaleSettings { TargetDedicatedNodes = 1, TargetLowPriorityNodes = 0, @@ -569,7 +473,7 @@ public async Task CreateOrUpdate_CreatePoolTags() Tags = { ["TagName1"] = "TagValue1", -["TagName2"] = "TagValue2", +["TagName2"] = "TagValue2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data); @@ -607,10 +511,10 @@ public async Task CreateOrUpdate_CreatePoolUpgradePolicy() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "Standard_d4s_v3", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -621,9 +525,9 @@ public async Task CreateOrUpdate_CreatePoolUpgradePolicy() IsAutomaticUpdateEnabled = false, NodePlacementPolicy = BatchNodePlacementPolicyType.Zonal, }, - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { - FixedScale = new BatchAccountFixedScaleSettings() + FixedScale = new BatchAccountFixedScaleSettings { TargetDedicatedNodes = 2, TargetLowPriorityNodes = 0, @@ -631,14 +535,14 @@ public async Task CreateOrUpdate_CreatePoolUpgradePolicy() }, UpgradePolicy = new UpgradePolicy(UpgradeMode.Automatic) { - AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy() + AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy { DisableAutomaticRollback = true, EnableAutomaticOSUpgrade = true, UseRollingUpgradePolicy = true, OSRollingUpgradeDeferral = true, }, - RollingUpgradePolicy = new RollingUpgradePolicy() + RollingUpgradePolicy = new RollingUpgradePolicy { EnableCrossZoneUpgrade = true, MaxBatchInstancePercent = 20, @@ -685,25 +589,25 @@ public async Task CreateOrUpdate_CreatePoolUserAssignedIdentities() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { [new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), -[new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity() }, }, VmSize = "STANDARD_D4", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "Canonical", Offer = "UbuntuServer", Sku = "18.04-LTS", Version = "latest", }, "batch.node.ubuntu 18.04"), - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { AutoScale = new BatchAccountAutoScaleSettings("$TargetDedicatedNodes=1") { @@ -746,31 +650,29 @@ public async Task CreateOrUpdate_CreatePoolVirtualMachineConfigurationExtensions // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "STANDARD_D4", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "Canonical", Offer = "0001-com-ubuntu-server-focal", Sku = "20_04-lts", }, "batch.node.ubuntu 20.04") { - Extensions = -{ -new BatchVmExtension("batchextension1","Microsoft.Azure.KeyVault","KeyVaultForLinux") + Extensions = {new BatchVmExtension("batchextension1", "Microsoft.Azure.KeyVault", "KeyVaultForLinux") { TypeHandlerVersion = "2.0", AutoUpgradeMinorVersion = true, EnableAutomaticUpgrade = true, -Settings = BinaryData.FromObjectAsJson(new Dictionary() +Settings = BinaryData.FromObjectAsJson(new { -["authenticationSettingsKey"] = "authenticationSettingsValue", -["secretsManagementSettingsKey"] = "secretsManagementSettingsValue"}), -} -}, +authenticationSettingsKey = "authenticationSettingsValue", +secretsManagementSettingsKey = "secretsManagementSettingsValue", +}), +}}, }, - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { AutoScale = new BatchAccountAutoScaleSettings("$TargetDedicatedNodes=1") { @@ -814,20 +716,20 @@ public async Task CreateOrUpdate_CreatePoolVirtualMachineConfigurationOSDisk() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "Standard_d2s_v3", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "microsoftwindowsserver", Offer = "windowsserver", Sku = "2022-datacenter-smalldisk", }, "batch.node.windows amd64") { - OSDisk = new BatchOSDisk() + OSDisk = new BatchOSDisk { Caching = BatchDiskCachingType.ReadWrite, - ManagedDisk = new ManagedDisk() + ManagedDisk = new ManagedDisk { StorageAccountType = BatchStorageAccountType.StandardSsdLrs, }, @@ -835,9 +737,9 @@ public async Task CreateOrUpdate_CreatePoolVirtualMachineConfigurationOSDisk() IsWriteAcceleratorEnabled = false, }, }, - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { - FixedScale = new BatchAccountFixedScaleSettings() + FixedScale = new BatchAccountFixedScaleSettings { TargetDedicatedNodes = 1, TargetLowPriorityNodes = 0, @@ -879,10 +781,10 @@ public async Task CreateOrUpdate_CreatePoolVirtualMachineConfigurationServiceArt // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "Standard_d4s_v3", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", @@ -893,9 +795,9 @@ public async Task CreateOrUpdate_CreatePoolVirtualMachineConfigurationServiceArt IsAutomaticUpdateEnabled = false, ServiceArtifactReferenceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Compute/galleries/myGallery/serviceArtifacts/myServiceArtifact/vmArtifactsProfiles/vmArtifactsProfile"), }, - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { - FixedScale = new BatchAccountFixedScaleSettings() + FixedScale = new BatchAccountFixedScaleSettings { TargetDedicatedNodes = 2, TargetLowPriorityNodes = 0, @@ -903,7 +805,7 @@ public async Task CreateOrUpdate_CreatePoolVirtualMachineConfigurationServiceArt }, UpgradePolicy = new UpgradePolicy(UpgradeMode.Automatic) { - AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy() + AutomaticOSUpgradePolicy = new AutomaticOSUpgradePolicy { EnableAutomaticOSUpgrade = true, }, @@ -944,25 +846,25 @@ public async Task CreateOrUpdate_CreatePoolAcceleratedNetworking() // invoke the operation string poolName = "testpool"; - BatchAccountPoolData data = new BatchAccountPoolData() + BatchAccountPoolData data = new BatchAccountPoolData { VmSize = "STANDARD_D1_V2", - DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference() + DeploymentVmConfiguration = new BatchVmConfiguration(new BatchImageReference { Publisher = "MicrosoftWindowsServer", Offer = "WindowsServer", Sku = "2016-datacenter-smalldisk", Version = "latest", }, "batch.node.windows amd64"), - ScaleSettings = new BatchAccountPoolScaleSettings() + ScaleSettings = new BatchAccountPoolScaleSettings { - FixedScale = new BatchAccountFixedScaleSettings() + FixedScale = new BatchAccountFixedScaleSettings { TargetDedicatedNodes = 1, TargetLowPriorityNodes = 0, }, }, - NetworkConfiguration = new BatchNetworkConfiguration() + NetworkConfiguration = new BatchNetworkConfiguration { SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1234/providers/Microsoft.Network/virtualNetworks/network1234/subnets/subnet123"), EnableAcceleratedNetworking = true, @@ -1014,9 +916,9 @@ public async Task Get_GetPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPool() + public async Task Get_GetPoolAcceleratedNetworking() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_AcceleratedNetworking.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1037,16 +939,20 @@ public async Task Exists_GetPool() // invoke the operation string poolName = "testpool"; - bool result = await collection.ExistsAsync(poolName); + BatchAccountPoolResource result = await collection.GetAsync(poolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPool() + public async Task Get_GetPoolSecurityProfile() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_SecurityProfile.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1067,28 +973,20 @@ public async Task GetIfExists_GetPool() // invoke the operation string poolName = "testpool"; - NullableResponse response = await collection.GetIfExistsAsync(poolName); - BatchAccountPoolResource result = response.HasValue ? response.Value : null; + BatchAccountPoolResource result = await collection.GetAsync(poolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolAcceleratedNetworking() + public async Task Get_GetPoolUpgradePolicy() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_AcceleratedNetworking.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_UpgradePolicy.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1120,9 +1018,9 @@ public async Task Get_GetPoolAcceleratedNetworking() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPoolAcceleratedNetworking() + public async Task Get_GetPoolVirtualMachineConfigurationExtensions() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_AcceleratedNetworking.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_Extensions.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1143,16 +1041,20 @@ public async Task Exists_GetPoolAcceleratedNetworking() // invoke the operation string poolName = "testpool"; - bool result = await collection.ExistsAsync(poolName); + BatchAccountPoolResource result = await collection.GetAsync(poolName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPoolAcceleratedNetworking() + public async Task Get_GetPoolVirtualMachineConfigurationOSDisk() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_AcceleratedNetworking.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_MangedOSDisk.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1173,28 +1075,20 @@ public async Task GetIfExists_GetPoolAcceleratedNetworking() // invoke the operation string poolName = "testpool"; - NullableResponse response = await collection.GetIfExistsAsync(poolName); - BatchAccountPoolResource result = response.HasValue ? response.Value : null; + BatchAccountPoolResource result = await collection.GetAsync(poolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolSecurityProfile() + public async Task Get_GetPoolVirtualMachineConfigurationServiceArtifactReference() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_SecurityProfile.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_ServiceArtifactReference.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1226,9 +1120,83 @@ public async Task Get_GetPoolSecurityProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPoolSecurityProfile() + public async Task GetAll_ListPool() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_SecurityProfile.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolList.json + // this example is just showing the usage of "Pool_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BatchAccountResource created on azure + // for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource + string subscriptionId = "subid"; + string resourceGroupName = "default-azurebatch-japaneast"; + string accountName = "sampleacct"; + ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId); + + // get the collection of this BatchAccountPoolResource + BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools(); + + // invoke the operation and iterate over the result + await foreach (BatchAccountPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListPoolWithFilter() + { + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolListWithFilter.json + // this example is just showing the usage of "Pool_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BatchAccountResource created on azure + // for more information of creating BatchAccountResource, please refer to the document of BatchAccountResource + string subscriptionId = "subid"; + string resourceGroupName = "default-azurebatch-japaneast"; + string accountName = "sampleacct"; + ResourceIdentifier batchAccountResourceId = BatchAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId); + + // get the collection of this BatchAccountPoolResource + BatchAccountPoolCollection collection = batchAccount.GetBatchAccountPools(); + + // invoke the operation and iterate over the result + string select = "properties/allocationState,properties/provisioningStateTransitionTime,properties/currentDedicatedNodes,properties/currentLowPriorityNodes"; + string filter = "startswith(name, 'po') or (properties/allocationState eq 'Steady' and properties/provisioningStateTransitionTime lt datetime'2017-02-02')"; + await foreach (BatchAccountPoolResource item in collection.GetAllAsync(select: select, filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetPool() + { + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1256,9 +1224,9 @@ public async Task Exists_GetPoolSecurityProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPoolSecurityProfile() + public async Task Exists_GetPoolAcceleratedNetworking() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_SecurityProfile.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_AcceleratedNetworking.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1279,28 +1247,16 @@ public async Task GetIfExists_GetPoolSecurityProfile() // invoke the operation string poolName = "testpool"; - NullableResponse response = await collection.GetIfExistsAsync(poolName); - BatchAccountPoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(poolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolUpgradePolicy() + public async Task Exists_GetPoolSecurityProfile() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_UpgradePolicy.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_SecurityProfile.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1321,13 +1277,9 @@ public async Task Get_GetPoolUpgradePolicy() // invoke the operation string poolName = "testpool"; - BatchAccountPoolResource result = await collection.GetAsync(poolName); + bool result = await collection.ExistsAsync(poolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -1362,9 +1314,9 @@ public async Task Exists_GetPoolUpgradePolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPoolUpgradePolicy() + public async Task Exists_GetPoolVirtualMachineConfigurationExtensions() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_UpgradePolicy.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_Extensions.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1385,28 +1337,16 @@ public async Task GetIfExists_GetPoolUpgradePolicy() // invoke the operation string poolName = "testpool"; - NullableResponse response = await collection.GetIfExistsAsync(poolName); - BatchAccountPoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(poolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolVirtualMachineConfigurationExtensions() + public async Task Exists_GetPoolVirtualMachineConfigurationOSDisk() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_Extensions.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_MangedOSDisk.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1427,20 +1367,16 @@ public async Task Get_GetPoolVirtualMachineConfigurationExtensions() // invoke the operation string poolName = "testpool"; - BatchAccountPoolResource result = await collection.GetAsync(poolName); + bool result = await collection.ExistsAsync(poolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPoolVirtualMachineConfigurationExtensions() + public async Task Exists_GetPoolVirtualMachineConfigurationServiceArtifactReference() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_Extensions.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_ServiceArtifactReference.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1468,9 +1404,9 @@ public async Task Exists_GetPoolVirtualMachineConfigurationExtensions() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPoolVirtualMachineConfigurationExtensions() + public async Task GetIfExists_GetPool() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_Extensions.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1510,9 +1446,9 @@ public async Task GetIfExists_GetPoolVirtualMachineConfigurationExtensions() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolVirtualMachineConfigurationOSDisk() + public async Task GetIfExists_GetPoolAcceleratedNetworking() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_MangedOSDisk.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_AcceleratedNetworking.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1533,20 +1469,28 @@ public async Task Get_GetPoolVirtualMachineConfigurationOSDisk() // invoke the operation string poolName = "testpool"; - BatchAccountPoolResource result = await collection.GetAsync(poolName); + NullableResponse response = await collection.GetIfExistsAsync(poolName); + BatchAccountPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPoolVirtualMachineConfigurationOSDisk() + public async Task GetIfExists_GetPoolSecurityProfile() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_MangedOSDisk.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_SecurityProfile.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1567,16 +1511,28 @@ public async Task Exists_GetPoolVirtualMachineConfigurationOSDisk() // invoke the operation string poolName = "testpool"; - bool result = await collection.ExistsAsync(poolName); + NullableResponse response = await collection.GetIfExistsAsync(poolName); + BatchAccountPoolResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPoolVirtualMachineConfigurationOSDisk() + public async Task GetIfExists_GetPoolUpgradePolicy() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_MangedOSDisk.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_UpgradePolicy.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1616,9 +1572,9 @@ public async Task GetIfExists_GetPoolVirtualMachineConfigurationOSDisk() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolVirtualMachineConfigurationServiceArtifactReference() + public async Task GetIfExists_GetPoolVirtualMachineConfigurationExtensions() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_ServiceArtifactReference.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_Extensions.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1639,20 +1595,28 @@ public async Task Get_GetPoolVirtualMachineConfigurationServiceArtifactReference // invoke the operation string poolName = "testpool"; - BatchAccountPoolResource result = await collection.GetAsync(poolName); + NullableResponse response = await collection.GetIfExistsAsync(poolName); + BatchAccountPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPoolVirtualMachineConfigurationServiceArtifactReference() + public async Task GetIfExists_GetPoolVirtualMachineConfigurationOSDisk() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_ServiceArtifactReference.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_MangedOSDisk.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -1673,9 +1637,21 @@ public async Task Exists_GetPoolVirtualMachineConfigurationServiceArtifactRefere // invoke the operation string poolName = "testpool"; - bool result = await collection.ExistsAsync(poolName); + NullableResponse response = await collection.GetIfExistsAsync(poolName); + BatchAccountPoolResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountPoolResource.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountPoolResource.cs index b057de027186c..a7a5934b68e1c 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountPoolResource.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountPoolResource.cs @@ -19,10 +19,10 @@ public partial class Sample_BatchAccountPoolResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatePoolEnableAutoscale() + public async Task Get_GetPool() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_EnableAutoScale.json - // this example is just showing the usage of "Pool_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet.json + // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,14 +39,7 @@ public async Task Update_UpdatePoolEnableAutoscale() BatchAccountPoolResource batchAccountPool = client.GetBatchAccountPoolResource(batchAccountPoolResourceId); // invoke the operation - BatchAccountPoolData data = new BatchAccountPoolData() - { - ScaleSettings = new BatchAccountPoolScaleSettings() - { - AutoScale = new BatchAccountAutoScaleSettings("$TargetDedicatedNodes=34"), - }, - }; - BatchAccountPoolResource result = await batchAccountPool.UpdateAsync(data); + BatchAccountPoolResource result = await batchAccountPool.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +50,10 @@ public async Task Update_UpdatePoolEnableAutoscale() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatePoolOtherProperties() + public async Task Get_GetPoolAcceleratedNetworking() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_OtherProperties.json - // this example is just showing the usage of "Pool_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_AcceleratedNetworking.json + // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,30 +70,7 @@ public async Task Update_UpdatePoolOtherProperties() BatchAccountPoolResource batchAccountPool = client.GetBatchAccountPoolResource(batchAccountPoolResourceId); // invoke the operation - BatchAccountPoolData data = new BatchAccountPoolData() - { - Metadata = -{ -new BatchAccountPoolMetadataItem("key1","value1") -}, - Certificates = -{ -new BatchCertificateReference(new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool/certificates/sha1-1234567")) -{ -StoreLocation = BatchCertificateStoreLocation.LocalMachine, -StoreName = "MY", -} -}, - ApplicationPackages = -{ -new BatchApplicationPackageReference(new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool/applications/app_1234")),new BatchApplicationPackageReference(new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool/applications/app_5678")) -{ -Version = "1.0", -} -}, - TargetNodeCommunicationMode = NodeCommunicationMode.Simplified, - }; - BatchAccountPoolResource result = await batchAccountPool.UpdateAsync(data); + BatchAccountPoolResource result = await batchAccountPool.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -111,10 +81,10 @@ public async Task Update_UpdatePoolOtherProperties() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatePoolRemoveStartTask() + public async Task Get_GetPoolSecurityProfile() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_RemoveStartTask.json - // this example is just showing the usage of "Pool_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_SecurityProfile.json + // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,11 +101,7 @@ public async Task Update_UpdatePoolRemoveStartTask() BatchAccountPoolResource batchAccountPool = client.GetBatchAccountPoolResource(batchAccountPoolResourceId); // invoke the operation - BatchAccountPoolData data = new BatchAccountPoolData() - { - StartTask = new BatchAccountPoolStartTask(), - }; - BatchAccountPoolResource result = await batchAccountPool.UpdateAsync(data); + BatchAccountPoolResource result = await batchAccountPool.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -146,10 +112,10 @@ public async Task Update_UpdatePoolRemoveStartTask() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatePoolResizePool() + public async Task Get_GetPoolUpgradePolicy() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_ResizePool.json - // this example is just showing the usage of "Pool_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_UpgradePolicy.json + // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -166,20 +132,7 @@ public async Task Update_UpdatePoolResizePool() BatchAccountPoolResource batchAccountPool = client.GetBatchAccountPoolResource(batchAccountPoolResourceId); // invoke the operation - BatchAccountPoolData data = new BatchAccountPoolData() - { - ScaleSettings = new BatchAccountPoolScaleSettings() - { - FixedScale = new BatchAccountFixedScaleSettings() - { - ResizeTimeout = XmlConvert.ToTimeSpan("PT8M"), - TargetDedicatedNodes = 5, - TargetLowPriorityNodes = 0, - NodeDeallocationOption = BatchNodeDeallocationOption.TaskCompletion, - }, - }, - }; - BatchAccountPoolResource result = await batchAccountPool.UpdateAsync(data); + BatchAccountPoolResource result = await batchAccountPool.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -190,10 +143,10 @@ public async Task Update_UpdatePoolResizePool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePool() + public async Task Get_GetPoolVirtualMachineConfigurationExtensions() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolDelete.json - // this example is just showing the usage of "Pool_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_Extensions.json + // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -210,16 +163,20 @@ public async Task Delete_DeletePool() BatchAccountPoolResource batchAccountPool = client.GetBatchAccountPoolResource(batchAccountPoolResourceId); // invoke the operation - await batchAccountPool.DeleteAsync(WaitUntil.Completed); + BatchAccountPoolResource result = await batchAccountPool.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPool() + public async Task Get_GetPoolVirtualMachineConfigurationOSDisk() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_MangedOSDisk.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -248,9 +205,9 @@ public async Task Get_GetPool() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolAcceleratedNetworking() + public async Task Get_GetPoolVirtualMachineConfigurationServiceArtifactReference() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_AcceleratedNetworking.json + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_ServiceArtifactReference.json // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -279,10 +236,10 @@ public async Task Get_GetPoolAcceleratedNetworking() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolSecurityProfile() + public async Task Delete_DeletePool() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_SecurityProfile.json - // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolDelete.json + // this example is just showing the usage of "Pool_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -299,21 +256,17 @@ public async Task Get_GetPoolSecurityProfile() BatchAccountPoolResource batchAccountPool = client.GetBatchAccountPoolResource(batchAccountPoolResourceId); // invoke the operation - BatchAccountPoolResource result = await batchAccountPool.GetAsync(); + await batchAccountPool.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolUpgradePolicy() + public async Task Update_UpdatePoolEnableAutoscale() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_UpgradePolicy.json - // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_EnableAutoScale.json + // this example is just showing the usage of "Pool_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -330,7 +283,14 @@ public async Task Get_GetPoolUpgradePolicy() BatchAccountPoolResource batchAccountPool = client.GetBatchAccountPoolResource(batchAccountPoolResourceId); // invoke the operation - BatchAccountPoolResource result = await batchAccountPool.GetAsync(); + BatchAccountPoolData data = new BatchAccountPoolData + { + ScaleSettings = new BatchAccountPoolScaleSettings + { + AutoScale = new BatchAccountAutoScaleSettings("$TargetDedicatedNodes=34"), + }, + }; + BatchAccountPoolResource result = await batchAccountPool.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -341,10 +301,10 @@ public async Task Get_GetPoolUpgradePolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolVirtualMachineConfigurationExtensions() + public async Task Update_UpdatePoolOtherProperties() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_Extensions.json - // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_OtherProperties.json + // this example is just showing the usage of "Pool_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -361,7 +321,21 @@ public async Task Get_GetPoolVirtualMachineConfigurationExtensions() BatchAccountPoolResource batchAccountPool = client.GetBatchAccountPoolResource(batchAccountPoolResourceId); // invoke the operation - BatchAccountPoolResource result = await batchAccountPool.GetAsync(); + BatchAccountPoolData data = new BatchAccountPoolData + { + Metadata = { new BatchAccountPoolMetadataItem("key1", "value1") }, + Certificates = {new BatchCertificateReference(new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool/certificates/sha1-1234567")) +{ +StoreLocation = BatchCertificateStoreLocation.LocalMachine, +StoreName = "MY", +}}, + ApplicationPackages = {new BatchApplicationPackageReference(new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool/applications/app_1234")), new BatchApplicationPackageReference(new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Batch/batchAccounts/sampleacct/pools/testpool/applications/app_5678")) +{ +Version = "1.0", +}}, + TargetNodeCommunicationMode = NodeCommunicationMode.Simplified, + }; + BatchAccountPoolResource result = await batchAccountPool.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -372,10 +346,10 @@ public async Task Get_GetPoolVirtualMachineConfigurationExtensions() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolVirtualMachineConfigurationOSDisk() + public async Task Update_UpdatePoolRemoveStartTask() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_MangedOSDisk.json - // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_RemoveStartTask.json + // this example is just showing the usage of "Pool_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -392,7 +366,11 @@ public async Task Get_GetPoolVirtualMachineConfigurationOSDisk() BatchAccountPoolResource batchAccountPool = client.GetBatchAccountPoolResource(batchAccountPoolResourceId); // invoke the operation - BatchAccountPoolResource result = await batchAccountPool.GetAsync(); + BatchAccountPoolData data = new BatchAccountPoolData + { + StartTask = new BatchAccountPoolStartTask(), + }; + BatchAccountPoolResource result = await batchAccountPool.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -403,10 +381,10 @@ public async Task Get_GetPoolVirtualMachineConfigurationOSDisk() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPoolVirtualMachineConfigurationServiceArtifactReference() + public async Task Update_UpdatePoolResizePool() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolGet_VirtualMachineConfiguration_ServiceArtifactReference.json - // this example is just showing the usage of "Pool_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PoolUpdate_ResizePool.json + // this example is just showing the usage of "Pool_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -423,7 +401,20 @@ public async Task Get_GetPoolVirtualMachineConfigurationServiceArtifactReference BatchAccountPoolResource batchAccountPool = client.GetBatchAccountPoolResource(batchAccountPoolResourceId); // invoke the operation - BatchAccountPoolResource result = await batchAccountPool.GetAsync(); + BatchAccountPoolData data = new BatchAccountPoolData + { + ScaleSettings = new BatchAccountPoolScaleSettings + { + FixedScale = new BatchAccountFixedScaleSettings + { + ResizeTimeout = XmlConvert.ToTimeSpan("PT8M"), + TargetDedicatedNodes = 5, + TargetLowPriorityNodes = 0, + NodeDeallocationOption = BatchNodeDeallocationOption.TaskCompletion, + }, + }, + }; + BatchAccountPoolResource result = await batchAccountPool.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountResource.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountResource.cs index dbd1d03e199d0..9bc4675b29c2f 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountResource.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchAccountResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Batch.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Batch.Samples @@ -19,10 +18,10 @@ public partial class Sample_BatchAccountResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BatchAccountUpdate() + public async Task Get_BatchAccountGet() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountUpdate.json - // this example is just showing the usage of "BatchAccount_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountGet.json + // this example is just showing the usage of "BatchAccount_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,11 +37,7 @@ public async Task Update_BatchAccountUpdate() BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId); // invoke the operation - BatchAccountPatch patch = new BatchAccountPatch() - { - AutoStorage = new BatchAccountAutoStorageBaseConfiguration(new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Storage/storageAccounts/samplestorage")), - }; - BatchAccountResource result = await batchAccount.UpdateAsync(patch); + BatchAccountResource result = await batchAccount.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +48,10 @@ public async Task Update_BatchAccountUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BatchAccountDelete() + public async Task Get_PrivateBatchAccountGet() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountDelete.json - // this example is just showing the usage of "BatchAccount_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateBatchAccountGet.json + // this example is just showing the usage of "BatchAccount_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,17 +67,21 @@ public async Task Delete_BatchAccountDelete() BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId); // invoke the operation - await batchAccount.DeleteAsync(WaitUntil.Completed); + BatchAccountResource result = await batchAccount.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BatchAccountGet() + public async Task Delete_BatchAccountDelete() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountGet.json - // this example is just showing the usage of "BatchAccount_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountDelete.json + // this example is just showing the usage of "BatchAccount_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,21 +97,17 @@ public async Task Get_BatchAccountGet() BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId); // invoke the operation - BatchAccountResource result = await batchAccount.GetAsync(); + await batchAccount.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateBatchAccountGet() + public async Task Update_BatchAccountUpdate() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateBatchAccountGet.json - // this example is just showing the usage of "BatchAccount_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountUpdate.json + // this example is just showing the usage of "BatchAccount_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -128,7 +123,11 @@ public async Task Get_PrivateBatchAccountGet() BatchAccountResource batchAccount = client.GetBatchAccountResource(batchAccountResourceId); // invoke the operation - BatchAccountResource result = await batchAccount.GetAsync(); + BatchAccountPatch patch = new BatchAccountPatch + { + AutoStorage = new BatchAccountAutoStorageBaseConfiguration(new ResourceIdentifier("/subscriptions/subid/resourceGroups/default-azurebatch-japaneast/providers/Microsoft.Storage/storageAccounts/samplestorage")), + }; + BatchAccountResource result = await batchAccount.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -137,37 +136,6 @@ public async Task Get_PrivateBatchAccountGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetBatchAccounts_BatchAccountList() - { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountList.json - // this example is just showing the usage of "BatchAccount_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (BatchAccountResource item in subscriptionResource.GetBatchAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task SynchronizeAutoStorageKeys_BatchAccountSynchronizeAutoStorageKeys() diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationCollection.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationCollection.cs index fc8ea5c77d096..f48730e8f52c6 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationCollection.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_ApplicationCreate() // invoke the operation string applicationName = "app1"; - BatchApplicationData data = new BatchApplicationData() + BatchApplicationData data = new BatchApplicationData { DisplayName = "myAppName", AllowUpdates = false, @@ -91,10 +91,10 @@ public async Task Get_ApplicationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApplicationGet() + public async Task GetAll_ApplicationList() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationGet.json - // this example is just showing the usage of "Application_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationList.json + // this example is just showing the usage of "Application_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_ApplicationGet() // get the collection of this BatchApplicationResource BatchApplicationCollection collection = batchAccount.GetBatchApplications(); - // invoke the operation - string applicationName = "app1"; - bool result = await collection.ExistsAsync(applicationName); + // invoke the operation and iterate over the result + await foreach (BatchApplicationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchApplicationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApplicationGet() + public async Task Exists_ApplicationGet() { // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationGet.json // this example is just showing the usage of "Application_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_ApplicationGet() // invoke the operation string applicationName = "app1"; - NullableResponse response = await collection.GetIfExistsAsync(applicationName); - BatchApplicationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(applicationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApplicationList() + public async Task GetIfExists_ApplicationGet() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationList.json - // this example is just showing the usage of "Application_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationGet.json + // this example is just showing the usage of "Application_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ApplicationList() // get the collection of this BatchApplicationResource BatchApplicationCollection collection = batchAccount.GetBatchApplications(); - // invoke the operation and iterate over the result - await foreach (BatchApplicationResource item in collection.GetAllAsync()) + // invoke the operation + string applicationName = "app1"; + NullableResponse response = await collection.GetIfExistsAsync(applicationName); + BatchApplicationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BatchApplicationData resourceData = item.Data; + BatchApplicationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationPackageCollection.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationPackageCollection.cs index 315fbbcc194f6..f571f391aa775 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationPackageCollection.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationPackageCollection.cs @@ -89,10 +89,10 @@ public async Task Get_ApplicationPackageGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApplicationPackageGet() + public async Task GetAll_ApplicationPackageList() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageGet.json - // this example is just showing the usage of "ApplicationPackage_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageList.json + // this example is just showing the usage of "ApplicationPackage_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +111,22 @@ public async Task Exists_ApplicationPackageGet() // get the collection of this BatchApplicationPackageResource BatchApplicationPackageCollection collection = batchApplication.GetBatchApplicationPackages(); - // invoke the operation - string versionName = "1"; - bool result = await collection.ExistsAsync(versionName); + // invoke the operation and iterate over the result + await foreach (BatchApplicationPackageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchApplicationPackageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApplicationPackageGet() + public async Task Exists_ApplicationPackageGet() { // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageGet.json // this example is just showing the usage of "ApplicationPackage_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_ApplicationPackageGet() // invoke the operation string versionName = "1"; - NullableResponse response = await collection.GetIfExistsAsync(versionName); - BatchApplicationPackageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(versionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchApplicationPackageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ApplicationPackageList() + public async Task GetIfExists_ApplicationPackageGet() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageList.json - // this example is just showing the usage of "ApplicationPackage_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageGet.json + // this example is just showing the usage of "ApplicationPackage_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_ApplicationPackageList() // get the collection of this BatchApplicationPackageResource BatchApplicationPackageCollection collection = batchApplication.GetBatchApplicationPackages(); - // invoke the operation and iterate over the result - await foreach (BatchApplicationPackageResource item in collection.GetAllAsync()) + // invoke the operation + string versionName = "1"; + NullableResponse response = await collection.GetIfExistsAsync(versionName); + BatchApplicationPackageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BatchApplicationPackageData resourceData = item.Data; + BatchApplicationPackageData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationPackageResource.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationPackageResource.cs index 1de2783f78eee..146d37bef6233 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationPackageResource.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationPackageResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BatchApplicationPackageResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Activate_ApplicationPackageActivate() + public async Task Get_ApplicationPackageGet() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageActivate.json - // this example is just showing the usage of "ApplicationPackage_Activate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageGet.json + // this example is just showing the usage of "ApplicationPackage_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,7 @@ public async Task Activate_ApplicationPackageActivate() BatchApplicationPackageResource batchApplicationPackage = client.GetBatchApplicationPackageResource(batchApplicationPackageResourceId); // invoke the operation - BatchApplicationPackageActivateContent content = new BatchApplicationPackageActivateContent("zip"); - BatchApplicationPackageResource result = await batchApplicationPackage.ActivateAsync(content); + BatchApplicationPackageResource result = await batchApplicationPackage.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +50,10 @@ public async Task Activate_ApplicationPackageActivate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApplicationPackageCreate() + public async Task Delete_ApplicationPackageDelete() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageCreate.json - // this example is just showing the usage of "ApplicationPackage_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageDelete.json + // this example is just showing the usage of "ApplicationPackage_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,23 +71,17 @@ public async Task Update_ApplicationPackageCreate() BatchApplicationPackageResource batchApplicationPackage = client.GetBatchApplicationPackageResource(batchApplicationPackageResourceId); // invoke the operation - BatchApplicationPackageData data = new BatchApplicationPackageData(); - ArmOperation lro = await batchApplicationPackage.UpdateAsync(WaitUntil.Completed, data); - BatchApplicationPackageResource result = lro.Value; + await batchApplicationPackage.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchApplicationPackageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApplicationPackageDelete() + public async Task Update_ApplicationPackageCreate() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageDelete.json - // this example is just showing the usage of "ApplicationPackage_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageCreate.json + // this example is just showing the usage of "ApplicationPackage_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,17 +99,23 @@ public async Task Delete_ApplicationPackageDelete() BatchApplicationPackageResource batchApplicationPackage = client.GetBatchApplicationPackageResource(batchApplicationPackageResourceId); // invoke the operation - await batchApplicationPackage.DeleteAsync(WaitUntil.Completed); + BatchApplicationPackageData data = new BatchApplicationPackageData(); + ArmOperation lro = await batchApplicationPackage.UpdateAsync(WaitUntil.Completed, data); + BatchApplicationPackageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchApplicationPackageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApplicationPackageGet() + public async Task Activate_ApplicationPackageActivate() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageGet.json - // this example is just showing the usage of "ApplicationPackage_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationPackageActivate.json + // this example is just showing the usage of "ApplicationPackage_Activate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,7 +133,8 @@ public async Task Get_ApplicationPackageGet() BatchApplicationPackageResource batchApplicationPackage = client.GetBatchApplicationPackageResource(batchApplicationPackageResourceId); // invoke the operation - BatchApplicationPackageResource result = await batchApplicationPackage.GetAsync(); + BatchApplicationPackageActivateContent content = new BatchApplicationPackageActivateContent("zip"); + BatchApplicationPackageResource result = await batchApplicationPackage.ActivateAsync(content); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationResource.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationResource.cs index 65d5547b48e1f..3c818cc6bc0b1 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationResource.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchApplicationResource.cs @@ -17,10 +17,10 @@ public partial class Sample_BatchApplicationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ApplicationDelete() + public async Task Get_ApplicationGet() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationDelete.json - // this example is just showing the usage of "Application_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationGet.json + // this example is just showing the usage of "Application_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task Delete_ApplicationDelete() BatchApplicationResource batchApplication = client.GetBatchApplicationResource(batchApplicationResourceId); // invoke the operation - await batchApplication.DeleteAsync(WaitUntil.Completed); + BatchApplicationResource result = await batchApplication.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchApplicationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApplicationGet() + public async Task Delete_ApplicationDelete() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationGet.json - // this example is just showing the usage of "Application_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/ApplicationDelete.json + // this example is just showing the usage of "Application_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +68,9 @@ public async Task Get_ApplicationGet() BatchApplicationResource batchApplication = client.GetBatchApplicationResource(batchApplicationResourceId); // invoke the operation - BatchApplicationResource result = await batchApplication.GetAsync(); + await batchApplication.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchApplicationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -95,7 +95,7 @@ public async Task Update_ApplicationUpdate() BatchApplicationResource batchApplication = client.GetBatchApplicationResource(batchApplicationResourceId); // invoke the operation - BatchApplicationData data = new BatchApplicationData() + BatchApplicationData data = new BatchApplicationData { DisplayName = "myAppName", AllowUpdates = true, diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateEndpointConnectionCollection.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateEndpointConnectionCollection.cs index ef8d316d3be37..cf6f27a4725f5 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateEndpointConnectionCollection.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateEndpointConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_BatchPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateEndpointConnections() + public async Task Get_GetPrivateEndpointConnection() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionsList.json - // this example is just showing the usage of "PrivateEndpointConnection_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListPrivateEndpointConnections() // get the collection of this BatchPrivateEndpointConnectionResource BatchPrivateEndpointConnectionCollection collection = batchAccount.GetBatchPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (BatchPrivateEndpointConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateEndpointConnectionName = "testprivateEndpointConnection5testprivateEndpointConnection5.24d6b4b5-e65c-4330-bbe9-3a290d62f8e0"; + BatchPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndpointConnection() + public async Task GetAll_ListPrivateEndpointConnections() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionsList.json + // this example is just showing the usage of "PrivateEndpointConnection_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetPrivateEndpointConnection() // get the collection of this BatchPrivateEndpointConnectionResource BatchPrivateEndpointConnectionCollection collection = batchAccount.GetBatchPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "testprivateEndpointConnection5testprivateEndpointConnection5.24d6b4b5-e65c-4330-bbe9-3a290d62f8e0"; - BatchPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (BatchPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateEndpointConnectionResource.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateEndpointConnectionResource.cs index 560d093d1a9ac..a460b9000b397 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateEndpointConnectionResource.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatePrivateEndpointConnection() + public async Task Delete_PrivateEndpointConnectionDelete() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnection_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionDelete.json + // this example is just showing the usage of "PrivateEndpointConnection_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,34 +64,22 @@ public async Task Update_UpdatePrivateEndpointConnection() string subscriptionId = "subid"; string resourceGroupName = "default-azurebatch-japaneast"; string accountName = "sampleacct"; - string privateEndpointConnectionName = "testprivateEndpointConnection5.24d6b4b5-e65c-4330-bbe9-3a290d62f8e0"; + string privateEndpointConnectionName = "testprivateEndpointConnection5testprivateEndpointConnection5.24d6b4b5-e65c-4330-bbe9-3a290d62f8e0"; ResourceIdentifier batchPrivateEndpointConnectionResourceId = BatchPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, privateEndpointConnectionName); BatchPrivateEndpointConnectionResource batchPrivateEndpointConnection = client.GetBatchPrivateEndpointConnectionResource(batchPrivateEndpointConnectionResourceId); // invoke the operation - BatchPrivateEndpointConnectionData data = new BatchPrivateEndpointConnectionData() - { - ConnectionState = new BatchPrivateLinkServiceConnectionState(BatchPrivateLinkServiceConnectionStatus.Approved) - { - Description = "Approved by xyz.abc@company.com", - }, - }; - ArmOperation lro = await batchPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - BatchPrivateEndpointConnectionResource result = lro.Value; + await batchPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateEndpointConnectionDelete() + public async Task Update_UpdatePrivateEndpointConnection() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionDelete.json - // this example is just showing the usage of "PrivateEndpointConnection_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnection_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,14 +91,26 @@ public async Task Delete_PrivateEndpointConnectionDelete() string subscriptionId = "subid"; string resourceGroupName = "default-azurebatch-japaneast"; string accountName = "sampleacct"; - string privateEndpointConnectionName = "testprivateEndpointConnection5testprivateEndpointConnection5.24d6b4b5-e65c-4330-bbe9-3a290d62f8e0"; + string privateEndpointConnectionName = "testprivateEndpointConnection5.24d6b4b5-e65c-4330-bbe9-3a290d62f8e0"; ResourceIdentifier batchPrivateEndpointConnectionResourceId = BatchPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, privateEndpointConnectionName); BatchPrivateEndpointConnectionResource batchPrivateEndpointConnection = client.GetBatchPrivateEndpointConnectionResource(batchPrivateEndpointConnectionResourceId); // invoke the operation - await batchPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + BatchPrivateEndpointConnectionData data = new BatchPrivateEndpointConnectionData + { + ConnectionState = new BatchPrivateLinkServiceConnectionState(BatchPrivateLinkServiceConnectionStatus.Approved) + { + Description = "Approved by xyz.abc@company.com", + }, + }; + ArmOperation lro = await batchPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + BatchPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateLinkResourceCollection.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateLinkResourceCollection.cs index f5e92b5da64ed..2eaf4bc4f9159 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateLinkResourceCollection.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_BatchPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_BatchPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateLinkResource() + public async Task Get_GetPrivateLinkResource() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateLinkResourcesList.json - // this example is just showing the usage of "PrivateLinkResource_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateLinkResourceGet.json + // this example is just showing the usage of "PrivateLinkResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListPrivateLinkResource() // get the collection of this BatchPrivateLinkResource BatchPrivateLinkResourceCollection collection = batchAccount.GetBatchPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (BatchPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateLinkResourceName = "batchAccount"; + BatchPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateLinkResource() + public async Task GetAll_ListPrivateLinkResource() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateLinkResourceGet.json - // this example is just showing the usage of "PrivateLinkResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/PrivateLinkResourcesList.json + // this example is just showing the usage of "PrivateLinkResource_ListByBatchAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetPrivateLinkResource() // get the collection of this BatchPrivateLinkResource BatchPrivateLinkResourceCollection collection = batchAccount.GetBatchPrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "batchAccount"; - BatchPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (BatchPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BatchPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs index cd7d315295073..9f5acb1f10fdd 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_NetworkSecurityPerimeterConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkSecurityPerimeterConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNspConfigurations() + public async Task Get_GetNspConfiguration() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/NspConfigurationsList.json - // this example is just showing the usage of "NetworkSecurityPerimeter_ListConfigurations" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/NspConfigurationGet.json + // this example is just showing the usage of "NetworkSecurityPerimeter_GetConfiguration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListNspConfigurations() // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = batchAccount.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string networkSecurityPerimeterConfigurationName = "00000000-0000-0000-0000-000000000000.sampleassociation"; + NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(networkSecurityPerimeterConfigurationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNspConfiguration() + public async Task GetAll_ListNspConfigurations() { - // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/NspConfigurationGet.json - // this example is just showing the usage of "NetworkSecurityPerimeter_GetConfiguration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/NspConfigurationsList.json + // this example is just showing the usage of "NetworkSecurityPerimeter_ListConfigurations" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetNspConfiguration() // get the collection of this NetworkSecurityPerimeterConfigurationResource NetworkSecurityPerimeterConfigurationCollection collection = batchAccount.GetNetworkSecurityPerimeterConfigurations(); - // invoke the operation - string networkSecurityPerimeterConfigurationName = "00000000-0000-0000-0000-000000000000.sampleassociation"; - NetworkSecurityPerimeterConfigurationResource result = await collection.GetAsync(networkSecurityPerimeterConfigurationName); + // invoke the operation and iterate over the result + await foreach (NetworkSecurityPerimeterConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityPerimeterConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityPerimeterConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 83e73b80af3d9..01fb1a6bda6ea 100644 --- a/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/batch/Azure.ResourceManager.Batch/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.Batch.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetBatchAccounts_BatchAccountList() + { + // Generated from example definition: specification/batch/resource-manager/Microsoft.Batch/stable/2024-07-01/examples/BatchAccountList.json + // this example is just showing the usage of "BatchAccount_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (BatchAccountResource item in subscriptionResource.GetBatchAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BatchAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetBatchQuotas_LocationGetQuotas() diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountCollection.cs index d8994ab75ef21..5af448ab41df4 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountCollection.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Billing.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Billing.Samples @@ -28,9 +29,7 @@ public async Task Get_BillingAccountWithExpandForPONumber() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); @@ -48,9 +47,9 @@ public async Task Get_BillingAccountWithExpandForPONumber() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingAccountWithExpandForPONumber() + public async Task Get_BillingAccountWithRegistrationNumberWithDefaultType() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithExpandForPONumber.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithDefaultType.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -58,25 +57,27 @@ public async Task Exists_BillingAccountWithExpandForPONumber() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation - string billingAccountName = "8608480"; - bool result = await collection.ExistsAsync(billingAccountName); + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + BillingAccountResource result = await collection.GetAsync(billingAccountName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingAccountWithExpandForPONumber() + public async Task Get_BillingAccountWithRegistrationNumberWithType() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithExpandForPONumber.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithType.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -84,37 +85,27 @@ public async Task GetIfExists_BillingAccountWithExpandForPONumber() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation - string billingAccountName = "8608480"; - NullableResponse response = await collection.GetIfExistsAsync(billingAccountName); - BillingAccountResource result = response.HasValue ? response.Value : null; + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + BillingAccountResource result = await collection.GetAsync(billingAccountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountWithRegistrationNumberWithDefaultType() + public async Task Get_BillingAccountsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithDefaultType.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGet.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -122,9 +113,7 @@ public async Task Get_BillingAccountWithRegistrationNumberWithDefaultType() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); @@ -142,9 +131,9 @@ public async Task Get_BillingAccountWithRegistrationNumberWithDefaultType() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingAccountWithRegistrationNumberWithDefaultType() + public async Task Get_BillingAccountsGetEA() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithDefaultType.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetEA.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -152,25 +141,27 @@ public async Task Exists_BillingAccountWithRegistrationNumberWithDefaultType() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - bool result = await collection.ExistsAsync(billingAccountName); + string billingAccountName = "6575495"; + BillingAccountResource result = await collection.GetAsync(billingAccountName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingAccountWithRegistrationNumberWithDefaultType() + public async Task Get_BillingAccountsGetWithExpand() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithDefaultType.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetWithExpand.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -178,93 +169,120 @@ public async Task GetIfExists_BillingAccountWithRegistrationNumberWithDefaultTyp // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - NullableResponse response = await collection.GetIfExistsAsync(billingAccountName); - BillingAccountResource result = response.HasValue ? response.Value : null; + BillingAccountResource result = await collection.GetAsync(billingAccountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_BillingAccountForLegacyAccountDetails() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountForLegacyAccountDetails.json + // this example is just showing the usage of "BillingAccounts_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this BillingAccountResource + BillingAccountCollection collection = tenantResource.GetBillingAccounts(); + + // invoke the operation and iterate over the result + BillingAccountCollectionGetAllOptions options = new BillingAccountCollectionGetAllOptions(); + await foreach (BillingAccountResource item in collection.GetAllAsync(options)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; + BillingAccountData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountWithRegistrationNumberWithType() + public async Task GetAll_BillingAccountsList() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithType.json - // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsList.json + // this example is just showing the usage of "BillingAccounts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); - // invoke the operation - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - BillingAccountResource result = await collection.GetAsync(billingAccountName); + // invoke the operation and iterate over the result + BillingAccountCollectionGetAllOptions options = new BillingAccountCollectionGetAllOptions(); + await foreach (BillingAccountResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingAccountWithRegistrationNumberWithType() + public async Task GetAll_BillingAccountsListWithExpandForPONumber() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithType.json - // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsListWithExpandForPONumber.json + // this example is just showing the usage of "BillingAccounts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); - // invoke the operation - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - bool result = await collection.ExistsAsync(billingAccountName); + // invoke the operation and iterate over the result + BillingAccountCollectionGetAllOptions options = new BillingAccountCollectionGetAllOptions { Expand = "soldTo,enrollmentDetails/poNumber" }; + await foreach (BillingAccountResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingAccountWithRegistrationNumberWithType() + public async Task Exists_BillingAccountWithExpandForPONumber() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithType.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithExpandForPONumber.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -272,37 +290,23 @@ public async Task GetIfExists_BillingAccountWithRegistrationNumberWithType() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - NullableResponse response = await collection.GetIfExistsAsync(billingAccountName); - BillingAccountResource result = response.HasValue ? response.Value : null; + string billingAccountName = "8608480"; + bool result = await collection.ExistsAsync(billingAccountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountsGet() + public async Task Exists_BillingAccountWithRegistrationNumberWithDefaultType() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGet.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithDefaultType.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -310,29 +314,23 @@ public async Task Get_BillingAccountsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - BillingAccountResource result = await collection.GetAsync(billingAccountName); + bool result = await collection.ExistsAsync(billingAccountName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingAccountsGet() + public async Task Exists_BillingAccountWithRegistrationNumberWithType() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGet.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithType.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -340,9 +338,7 @@ public async Task Exists_BillingAccountsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); @@ -356,7 +352,7 @@ public async Task Exists_BillingAccountsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingAccountsGet() + public async Task Exists_BillingAccountsGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGet.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -366,35 +362,21 @@ public async Task GetIfExists_BillingAccountsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - NullableResponse response = await collection.GetIfExistsAsync(billingAccountName); - BillingAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(billingAccountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountsGetEA() + public async Task Exists_BillingAccountsGetEA() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetEA.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -404,29 +386,23 @@ public async Task Get_BillingAccountsGetEA() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation string billingAccountName = "6575495"; - BillingAccountResource result = await collection.GetAsync(billingAccountName); + bool result = await collection.ExistsAsync(billingAccountName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingAccountsGetEA() + public async Task Exists_BillingAccountsGetWithExpand() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetEA.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetWithExpand.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -434,15 +410,13 @@ public async Task Exists_BillingAccountsGetEA() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation - string billingAccountName = "6575495"; + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; bool result = await collection.ExistsAsync(billingAccountName); Console.WriteLine($"Succeeded: {result}"); @@ -450,9 +424,9 @@ public async Task Exists_BillingAccountsGetEA() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingAccountsGetEA() + public async Task GetIfExists_BillingAccountWithExpandForPONumber() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetEA.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithExpandForPONumber.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -460,15 +434,13 @@ public async Task GetIfExists_BillingAccountsGetEA() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation - string billingAccountName = "6575495"; + string billingAccountName = "8608480"; NullableResponse response = await collection.GetIfExistsAsync(billingAccountName); BillingAccountResource result = response.HasValue ? response.Value : null; @@ -488,9 +460,9 @@ public async Task GetIfExists_BillingAccountsGetEA() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountsGetWithExpand() + public async Task GetIfExists_BillingAccountWithRegistrationNumberWithDefaultType() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetWithExpand.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithDefaultType.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -498,29 +470,35 @@ public async Task Get_BillingAccountsGetWithExpand() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - BillingAccountResource result = await collection.GetAsync(billingAccountName); + NullableResponse response = await collection.GetIfExistsAsync(billingAccountName); + BillingAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingAccountsGetWithExpand() + public async Task GetIfExists_BillingAccountWithRegistrationNumberWithType() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetWithExpand.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithType.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -528,25 +506,35 @@ public async Task Exists_BillingAccountsGetWithExpand() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); // invoke the operation string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - bool result = await collection.ExistsAsync(billingAccountName); + NullableResponse response = await collection.GetIfExistsAsync(billingAccountName); + BillingAccountResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingAccountsGetWithExpand() + public async Task GetIfExists_BillingAccountsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetWithExpand.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGet.json // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -554,9 +542,7 @@ public async Task GetIfExists_BillingAccountsGetWithExpand() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); @@ -582,101 +568,74 @@ public async Task GetIfExists_BillingAccountsGetWithExpand() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingAccountForLegacyAccountDetails() + public async Task GetIfExists_BillingAccountsGetEA() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountForLegacyAccountDetails.json - // this example is just showing the usage of "BillingAccounts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetEA.json + // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); - // invoke the operation and iterate over the result - BillingAccountCollectionGetAllOptions options = new BillingAccountCollectionGetAllOptions() { }; - await foreach (BillingAccountResource item in collection.GetAllAsync(options)) + // invoke the operation + string billingAccountName = "6575495"; + NullableResponse response = await collection.GetIfExistsAsync(billingAccountName); + BillingAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded with null as result"); } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingAccountsList() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsList.json - // this example is just showing the usage of "BillingAccounts_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this BillingAccountResource - BillingAccountCollection collection = tenantResource.GetBillingAccounts(); - - // invoke the operation and iterate over the result - BillingAccountCollectionGetAllOptions options = new BillingAccountCollectionGetAllOptions() { }; - await foreach (BillingAccountResource item in collection.GetAllAsync(options)) + else { - // the variable item is a resource, you could call other operations on this instance as well + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = item.Data; + BillingAccountData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingAccountsListWithExpandForPONumber() + public async Task GetIfExists_BillingAccountsGetWithExpand() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsListWithExpandForPONumber.json - // this example is just showing the usage of "BillingAccounts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetWithExpand.json + // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingAccountResource BillingAccountCollection collection = tenantResource.GetBillingAccounts(); - // invoke the operation and iterate over the result - BillingAccountCollectionGetAllOptions options = new BillingAccountCollectionGetAllOptions() { Expand = "soldTo,enrollmentDetails/poNumber" }; - await foreach (BillingAccountResource item in collection.GetAllAsync(options)) + // invoke the operation + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + NullableResponse response = await collection.GetIfExistsAsync(billingAccountName); + BillingAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = item.Data; + BillingAccountData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountPaymentMethodCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountPaymentMethodCollection.cs index 9d6df488d17a5..be0dd4be761a3 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountPaymentMethodCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountPaymentMethodCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_BillingAccountPaymentMethodCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PaymentMethodsListByBillingAccount() + public async Task Get_PaymentMethodGetAtBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsListByBillingAccount.json - // this example is just showing the usage of "PaymentMethods_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByBillingAccount.json + // this example is just showing the usage of "PaymentMethods_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,25 +36,23 @@ public async Task GetAll_PaymentMethodsListByBillingAccount() // get the collection of this BillingAccountPaymentMethodResource BillingAccountPaymentMethodCollection collection = billingAccount.GetBillingAccountPaymentMethods(); - // invoke the operation and iterate over the result - await foreach (BillingAccountPaymentMethodResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingPaymentMethodData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string paymentMethodName = "21dd9edc-af71-4d62-80ce-37151d475326"; + BillingAccountPaymentMethodResource result = await collection.GetAsync(paymentMethodName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingPaymentMethodData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PaymentMethodGetAtBillingProfile() + public async Task GetAll_PaymentMethodsListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByBillingAccount.json - // this example is just showing the usage of "PaymentMethods_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsListByBillingAccount.json + // this example is just showing the usage of "PaymentMethods_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,15 +68,17 @@ public async Task Get_PaymentMethodGetAtBillingProfile() // get the collection of this BillingAccountPaymentMethodResource BillingAccountPaymentMethodCollection collection = billingAccount.GetBillingAccountPaymentMethods(); - // invoke the operation - string paymentMethodName = "21dd9edc-af71-4d62-80ce-37151d475326"; - BillingAccountPaymentMethodResource result = await collection.GetAsync(paymentMethodName); + // invoke the operation and iterate over the result + await foreach (BillingAccountPaymentMethodResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingPaymentMethodData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingPaymentMethodData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountPolicyResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountPolicyResource.cs index e91ad401368a6..bc01f6815d44e 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountPolicyResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountPolicyResource.cs @@ -63,11 +63,11 @@ public async Task CreateOrUpdate_PoliciesPutByBillingAccount() BillingAccountPolicyResource billingAccountPolicy = client.GetBillingAccountPolicyResource(billingAccountPolicyResourceId); // invoke the operation - BillingAccountPolicyData data = new BillingAccountPolicyData() + BillingAccountPolicyData data = new BillingAccountPolicyData { - Properties = new BillingAccountPolicyProperties() + Properties = new BillingAccountPolicyProperties { - EnterpriseAgreementPolicies = new EnterpriseAgreementPolicies() + EnterpriseAgreementPolicies = new EnterpriseAgreementPolicies { AuthenticationType = EnrollmentAuthLevelState.OrganizationalAccountOnly, }, diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountResource.cs index 6c4977e55df17..c1be21412af76 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAccountResource.cs @@ -19,10 +19,10 @@ public partial class Sample_BillingAccountResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetBillingAccountAvailableBalance_AvailableBalanceGetByBillingAccount() + public async Task Get_BillingAccountWithExpandForPONumber() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/availableBalanceGetByBillingAccount.json - // this example is just showing the usage of "AvailableBalances_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithExpandForPONumber.json + // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,22 +31,26 @@ public async Task GetBillingAccountAvailableBalance_AvailableBalanceGetByBilling // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "8608480"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - BillingAvailableBalanceData result = await billingAccount.GetBillingAccountAvailableBalanceAsync(); + BillingAccountResource result = await billingAccount.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task AddPaymentTerms_PaymentTermsAdd() + public async Task Get_BillingAccountWithRegistrationNumberWithDefaultType() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermsAdd.json - // this example is just showing the usage of "BillingAccounts_AddPaymentTerms" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithDefaultType.json + // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -55,22 +59,12 @@ public async Task AddPaymentTerms_PaymentTermsAdd() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - IEnumerable arrayOfPaymentTerm = new BillingPaymentTerm[] - { -new BillingPaymentTerm() -{ -Term = "net10", -StartOn = DateTimeOffset.Parse("2023-01-05T22:39:34.2606750Z"), -EndOn = DateTimeOffset.Parse("2023-01-25T22:39:34.2606750Z"), -} - }; - ArmOperation lro = await billingAccount.AddPaymentTermsAsync(WaitUntil.Completed, arrayOfPaymentTerm); - BillingAccountResource result = lro.Value; + BillingAccountResource result = await billingAccount.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +75,10 @@ public async Task AddPaymentTerms_PaymentTermsAdd() [Test] [Ignore("Only validating compilation of examples")] - public async Task CancelPaymentTerms_PaymentTermsCancel() + public async Task Get_BillingAccountWithRegistrationNumberWithType() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermsCancel.json - // this example is just showing the usage of "BillingAccounts_CancelPaymentTerms" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithType.json + // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,14 +87,12 @@ public async Task CancelPaymentTerms_PaymentTermsCancel() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - DateTimeOffset dateTime = DateTimeOffset.Parse("2023-01-05T22:39:34.2606750Z"); - ArmOperation lro = await billingAccount.CancelPaymentTermsAsync(WaitUntil.Completed, dateTime); - BillingAccountResource result = lro.Value; + BillingAccountResource result = await billingAccount.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -111,10 +103,10 @@ public async Task CancelPaymentTerms_PaymentTermsCancel() [Test] [Ignore("Only validating compilation of examples")] - public async Task ConfirmTransition_BillingAccountsConfirmTransition() + public async Task Get_BillingAccountsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsConfirmTransition.json - // this example is just showing the usage of "BillingAccounts_ConfirmTransition" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGet.json + // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -128,17 +120,21 @@ public async Task ConfirmTransition_BillingAccountsConfirmTransition() BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - BillingTransitionDetails result = await billingAccount.ConfirmTransitionAsync(); + BillingAccountResource result = await billingAccount.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetInvoiceSectionsByCreateSubscriptionPermission_InvoiceSectionsWithCreateSubscriptionPermissionList() + public async Task Get_BillingAccountsGetEA() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsWithCreateSubscriptionPermissionList.json - // this example is just showing the usage of "BillingAccounts_ListInvoiceSectionsByCreateSubscriptionPermission" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetEA.json + // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,25 +143,26 @@ public async Task GetInvoiceSectionsByCreateSubscriptionPermission_InvoiceSectio // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "6575495"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); - // invoke the operation and iterate over the result - await foreach (InvoiceSectionWithCreateSubPermission item in billingAccount.GetInvoiceSectionsByCreateSubscriptionPermissionAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + BillingAccountResource result = await billingAccount.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidatePaymentTerms_PaymentTermInvalid() + public async Task Get_BillingAccountsGetWithExpand() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermInvalid.json - // this example is just showing the usage of "BillingAccounts_ValidatePaymentTerms" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetWithExpand.json + // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,31 +171,26 @@ public async Task ValidatePaymentTerms_PaymentTermInvalid() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - IEnumerable arrayOfPaymentTerm = new BillingPaymentTerm[] - { -new BillingPaymentTerm() -{ -Term = "net10", -StartOn = DateTimeOffset.Parse("2023-02-05T22:39:34.2606750Z"), -EndOn = DateTimeOffset.Parse("2023-01-25T22:39:34.2606750Z"), -} - }; - PaymentTermsEligibilityResult result = await billingAccount.ValidatePaymentTermsAsync(arrayOfPaymentTerm); + BillingAccountResource result = await billingAccount.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidatePaymentTerms_PaymentTermValid() + public async Task Update_BillingAccountUpdateWithPONumber() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermValid.json - // this example is just showing the usage of "BillingAccounts_ValidatePaymentTerms" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountUpdateWithPONumber.json + // this example is just showing the usage of "BillingAccounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -207,31 +199,37 @@ public async Task ValidatePaymentTerms_PaymentTermValid() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "6575495"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - IEnumerable arrayOfPaymentTerm = new BillingPaymentTerm[] + BillingAccountPatch patch = new BillingAccountPatch { -new BillingPaymentTerm() -{ -Term = "net10", -StartOn = DateTimeOffset.Parse("2023-01-05T22:39:34.2606750Z"), -EndOn = DateTimeOffset.Parse("2023-01-25T22:39:34.2606750Z"), -} + Properties = new BillingAccountProperties + { + EnrollmentDetails = new BillingAccountEnrollmentDetails + { + PoNumber = "poNumber123", + }, + }, }; - PaymentTermsEligibilityResult result = await billingAccount.ValidatePaymentTermsAsync(arrayOfPaymentTerm); + ArmOperation lro = await billingAccount.UpdateAsync(WaitUntil.Completed, patch); + BillingAccountResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountWithExpandForPONumber() + public async Task Update_BillingAccountsUpdate() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithExpandForPONumber.json - // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsUpdate.json + // this example is just showing the usage of "BillingAccounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -240,12 +238,27 @@ public async Task Get_BillingAccountWithExpandForPONumber() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "8608480"; + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - BillingAccountResource result = await billingAccount.GetAsync(); + BillingAccountPatch patch = new BillingAccountPatch + { + Properties = new BillingAccountProperties + { + DisplayName = "Test Account", + SoldTo = new BillingAddressDetails("1 Microsoft Way", "US") + { + City = "Redmond", + CompanyName = "Contoso", + PostalCode = "98052-8300", + Region = "WA", + }, + }, + }; + ArmOperation lro = await billingAccount.UpdateAsync(WaitUntil.Completed, patch); + BillingAccountResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -256,10 +269,10 @@ public async Task Get_BillingAccountWithExpandForPONumber() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountWithRegistrationNumberWithDefaultType() + public async Task GetBillingAccountAvailableBalance_AvailableBalanceGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithDefaultType.json - // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/availableBalanceGetByBillingAccount.json + // this example is just showing the usage of "AvailableBalances_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -268,26 +281,22 @@ public async Task Get_BillingAccountWithRegistrationNumberWithDefaultType() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - BillingAccountResource result = await billingAccount.GetAsync(); + BillingAvailableBalanceData result = await billingAccount.GetBillingAccountAvailableBalanceAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountWithRegistrationNumberWithType() + public async Task AddPaymentTerms_PaymentTermsAdd() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountWithRegistrationNumberWithType.json - // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermsAdd.json + // this example is just showing the usage of "BillingAccounts_AddPaymentTerms" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -296,12 +305,22 @@ public async Task Get_BillingAccountWithRegistrationNumberWithType() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - BillingAccountResource result = await billingAccount.GetAsync(); + IEnumerable arrayOfPaymentTerm = new BillingPaymentTerm[] + { +new BillingPaymentTerm +{ +Term = "net10", +StartOn = DateTimeOffset.Parse("2023-01-05T22:39:34.2606750Z"), +EndOn = DateTimeOffset.Parse("2023-01-25T22:39:34.2606750Z"), +} + }; + ArmOperation lro = await billingAccount.AddPaymentTermsAsync(WaitUntil.Completed, arrayOfPaymentTerm); + BillingAccountResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -312,10 +331,10 @@ public async Task Get_BillingAccountWithRegistrationNumberWithType() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountsGet() + public async Task CancelPaymentTerms_PaymentTermsCancel() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGet.json - // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermsCancel.json + // this example is just showing the usage of "BillingAccounts_CancelPaymentTerms" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -324,12 +343,14 @@ public async Task Get_BillingAccountsGet() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - BillingAccountResource result = await billingAccount.GetAsync(); + DateTimeOffset dateTime = DateTimeOffset.Parse("2023-01-05T22:39:34.2606750Z"); + ArmOperation lro = await billingAccount.CancelPaymentTermsAsync(WaitUntil.Completed, dateTime); + BillingAccountResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -340,10 +361,10 @@ public async Task Get_BillingAccountsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountsGetEA() + public async Task ConfirmTransition_BillingAccountsConfirmTransition() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetEA.json - // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsConfirmTransition.json + // this example is just showing the usage of "BillingAccounts_ConfirmTransition" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -352,26 +373,22 @@ public async Task Get_BillingAccountsGetEA() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "6575495"; + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - BillingAccountResource result = await billingAccount.GetAsync(); + BillingTransitionDetails result = await billingAccount.ConfirmTransitionAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingAccountsGetWithExpand() + public async Task GetInvoiceSectionsByCreateSubscriptionPermission_InvoiceSectionsWithCreateSubscriptionPermissionList() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsGetWithExpand.json - // this example is just showing the usage of "BillingAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsWithCreateSubscriptionPermissionList.json + // this example is just showing the usage of "BillingAccounts_ListInvoiceSectionsByCreateSubscriptionPermission" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -384,22 +401,21 @@ public async Task Get_BillingAccountsGetWithExpand() ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); - // invoke the operation - BillingAccountResource result = await billingAccount.GetAsync(); + // invoke the operation and iterate over the result + await foreach (InvoiceSectionWithCreateSubPermission item in billingAccount.GetInvoiceSectionsByCreateSubscriptionPermissionAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BillingAccountUpdateWithPONumber() + public async Task ValidatePaymentTerms_PaymentTermInvalid() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountUpdateWithPONumber.json - // this example is just showing the usage of "BillingAccounts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermInvalid.json + // this example is just showing the usage of "BillingAccounts_ValidatePaymentTerms" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -408,37 +424,31 @@ public async Task Update_BillingAccountUpdateWithPONumber() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "6575495"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - BillingAccountPatch patch = new BillingAccountPatch() + IEnumerable arrayOfPaymentTerm = new BillingPaymentTerm[] { - Properties = new BillingAccountProperties() - { - EnrollmentDetails = new BillingAccountEnrollmentDetails() - { - PoNumber = "poNumber123", - }, - }, +new BillingPaymentTerm +{ +Term = "net10", +StartOn = DateTimeOffset.Parse("2023-02-05T22:39:34.2606750Z"), +EndOn = DateTimeOffset.Parse("2023-01-25T22:39:34.2606750Z"), +} }; - ArmOperation lro = await billingAccount.UpdateAsync(WaitUntil.Completed, patch); - BillingAccountResource result = lro.Value; + PaymentTermsEligibilityResult result = await billingAccount.ValidatePaymentTermsAsync(arrayOfPaymentTerm); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BillingAccountsUpdate() + public async Task ValidatePaymentTerms_PaymentTermValid() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingAccountsUpdate.json - // this example is just showing the usage of "BillingAccounts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentTermValid.json + // this example is just showing the usage of "BillingAccounts_ValidatePaymentTerms" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -447,33 +457,23 @@ public async Task Update_BillingAccountsUpdate() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation - BillingAccountPatch patch = new BillingAccountPatch() + IEnumerable arrayOfPaymentTerm = new BillingPaymentTerm[] { - Properties = new BillingAccountProperties() - { - DisplayName = "Test Account", - SoldTo = new BillingAddressDetails("1 Microsoft Way", "US") - { - City = "Redmond", - CompanyName = "Contoso", - PostalCode = "98052-8300", - Region = "WA", - }, - }, +new BillingPaymentTerm +{ +Term = "net10", +StartOn = DateTimeOffset.Parse("2023-01-05T22:39:34.2606750Z"), +EndOn = DateTimeOffset.Parse("2023-01-25T22:39:34.2606750Z"), +} }; - ArmOperation lro = await billingAccount.UpdateAsync(WaitUntil.Completed, patch); - BillingAccountResource result = lro.Value; + PaymentTermsEligibilityResult result = await billingAccount.ValidatePaymentTermsAsync(arrayOfPaymentTerm); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -522,12 +522,9 @@ public async Task CheckAccessBillingPermissions_CheckAccessByBillingAccount() BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation and iterate over the result - BillingCheckAccessContent content = new BillingCheckAccessContent() + BillingCheckAccessContent content = new BillingCheckAccessContent { - Actions = -{ -"Microsoft.Billing/billingAccounts/read","Microsoft.Subscription/subscriptions/write" -}, + Actions = { "Microsoft.Billing/billingAccounts/read", "Microsoft.Subscription/subscriptions/write" }, }; await foreach (BillingCheckAccessResult item in billingAccount.CheckAccessBillingPermissionsAsync(content)) { @@ -556,7 +553,7 @@ public async Task GetBillingRequests_BillingRequestsListByBillingAccount() BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation and iterate over the result - BillingAccountResourceGetBillingRequestsOptions options = new BillingAccountResourceGetBillingRequestsOptions() { }; + BillingAccountResourceGetBillingRequestsOptions options = new BillingAccountResourceGetBillingRequestsOptions(); await foreach (BillingRequestResource item in billingAccount.GetBillingRequestsAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well @@ -645,7 +642,7 @@ public async Task GetByBillingAccountSavingsPlan_SavingsPlansList() BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation and iterate over the result - BillingAccountResourceGetByBillingAccountSavingsPlanOptions options = new BillingAccountResourceGetByBillingAccountSavingsPlanOptions() { Take = 3, SelectedState = "Succeeded", RefreshSummary = "true" }; + BillingAccountResourceGetByBillingAccountSavingsPlanOptions options = new BillingAccountResourceGetByBillingAccountSavingsPlanOptions { Take = 3, SelectedState = "Succeeded", RefreshSummary = "true" }; await foreach (BillingSavingsPlanModelResource item in billingAccount.GetByBillingAccountSavingsPlanAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well @@ -679,11 +676,12 @@ public async Task DownloadDocumentsByBillingAccountInvoice_InvoicesDownloadDocum // invoke the operation IEnumerable arrayOfDocumentDownloadRequest = new BillingDocumentDownloadRequestContent[] { -new BillingDocumentDownloadRequestContent() +new BillingDocumentDownloadRequestContent { DocumentName = "12345678", InvoiceName = "G123456789", -},new BillingDocumentDownloadRequestContent() +}, +new BillingDocumentDownloadRequestContent { DocumentName = "12345678", InvoiceName = "G987654321", @@ -714,7 +712,7 @@ public async Task GetReservations_ReservationsListByBillingAccount() BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); // invoke the operation and iterate over the result - BillingAccountResourceGetReservationsOptions options = new BillingAccountResourceGetReservationsOptions() { SelectedState = "Succeeded" }; + BillingAccountResourceGetReservationsOptions options = new BillingAccountResourceGetReservationsOptions { SelectedState = "Succeeded" }; await foreach (BillingReservationResource item in billingAccount.GetReservationsAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAgreementCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAgreementCollection.cs index d24145f410431..7509adb03a844 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAgreementCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAgreementCollection.cs @@ -49,10 +49,10 @@ public async Task Get_AgreementByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AgreementByName() + public async Task GetAll_AgreementsListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/agreementByName.json - // this example is just showing the usage of "Agreements_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/agreementsListByBillingAccount.json + // this example is just showing the usage of "Agreements_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,16 +68,23 @@ public async Task Exists_AgreementByName() // get the collection of this BillingAgreementResource BillingAgreementCollection collection = billingAccount.GetBillingAgreements(); - // invoke the operation - string agreementName = "ABC123"; - bool result = await collection.ExistsAsync(agreementName); + // invoke the operation and iterate over the result + string expand = "Participants"; + await foreach (BillingAgreementResource item in collection.GetAllAsync(expand: expand)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAgreementData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AgreementByName() + public async Task Exists_AgreementByName() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/agreementByName.json // this example is just showing the usage of "Agreements_Get" operation, for the dependent resources, they will have to be created separately. @@ -98,29 +105,17 @@ public async Task GetIfExists_AgreementByName() // invoke the operation string agreementName = "ABC123"; - NullableResponse response = await collection.GetIfExistsAsync(agreementName); - BillingAgreementResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(agreementName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAgreementData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AgreementsListByBillingAccount() + public async Task GetIfExists_AgreementByName() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/agreementsListByBillingAccount.json - // this example is just showing the usage of "Agreements_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/agreementByName.json + // this example is just showing the usage of "Agreements_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,18 +131,23 @@ public async Task GetAll_AgreementsListByBillingAccount() // get the collection of this BillingAgreementResource BillingAgreementCollection collection = billingAccount.GetBillingAgreements(); - // invoke the operation and iterate over the result - string expand = "Participants"; - await foreach (BillingAgreementResource item in collection.GetAllAsync(expand: expand)) + // invoke the operation + string agreementName = "ABC123"; + NullableResponse response = await collection.GetIfExistsAsync(agreementName); + BillingAgreementResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingAgreementData resourceData = item.Data; + BillingAgreementData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAssociatedTenantCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAssociatedTenantCollection.cs index 60e4f8f8cd500..afa52f950788f 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAssociatedTenantCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAssociatedTenantCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingAssociatedTenantCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AssociatedTenantsGet() + public async Task CreateOrUpdate_AssociatedTenantsCreateOrUpdate() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsGet.json - // this example is just showing the usage of "AssociatedTenants_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsCreateOrUpdate.json + // this example is just showing the usage of "AssociatedTenants_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,7 +39,17 @@ public async Task Get_AssociatedTenantsGet() // invoke the operation string associatedTenantName = "11111111-1111-1111-1111-111111111111"; - BillingAssociatedTenantResource result = await collection.GetAsync(associatedTenantName); + BillingAssociatedTenantData data = new BillingAssociatedTenantData + { + Properties = new BillingAssociatedTenantProperties + { + DisplayName = "Contoso Finance", + BillingManagementState = BillingManagementTenantState.Active, + ProvisioningManagementState = BillingProvisioningTenantState.Pending, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, associatedTenantName, data); + BillingAssociatedTenantResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,7 +60,7 @@ public async Task Get_AssociatedTenantsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AssociatedTenantsGet() + public async Task Get_AssociatedTenantsGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsGet.json // this example is just showing the usage of "AssociatedTenants_Get" operation, for the dependent resources, they will have to be created separately. @@ -71,17 +81,21 @@ public async Task Exists_AssociatedTenantsGet() // invoke the operation string associatedTenantName = "11111111-1111-1111-1111-111111111111"; - bool result = await collection.ExistsAsync(associatedTenantName); + BillingAssociatedTenantResource result = await collection.GetAsync(associatedTenantName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAssociatedTenantData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AssociatedTenantsGet() + public async Task GetAll_AssociatedTenantsListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsGet.json - // this example is just showing the usage of "AssociatedTenants_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsListByBillingAccount.json + // this example is just showing the usage of "AssociatedTenants_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,31 +111,26 @@ public async Task GetIfExists_AssociatedTenantsGet() // get the collection of this BillingAssociatedTenantResource BillingAssociatedTenantCollection collection = billingAccount.GetBillingAssociatedTenants(); - // invoke the operation - string associatedTenantName = "11111111-1111-1111-1111-111111111111"; - NullableResponse response = await collection.GetIfExistsAsync(associatedTenantName); - BillingAssociatedTenantResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + BillingAssociatedTenantCollectionGetAllOptions options = new BillingAssociatedTenantCollectionGetAllOptions(); + await foreach (BillingAssociatedTenantResource item in collection.GetAllAsync(options)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingAssociatedTenantData resourceData = result.Data; + BillingAssociatedTenantData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AssociatedTenantsCreateOrUpdate() + public async Task Exists_AssociatedTenantsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsCreateOrUpdate.json - // this example is just showing the usage of "AssociatedTenants_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsGet.json + // this example is just showing the usage of "AssociatedTenants_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,31 +148,17 @@ public async Task CreateOrUpdate_AssociatedTenantsCreateOrUpdate() // invoke the operation string associatedTenantName = "11111111-1111-1111-1111-111111111111"; - BillingAssociatedTenantData data = new BillingAssociatedTenantData() - { - Properties = new BillingAssociatedTenantProperties() - { - DisplayName = "Contoso Finance", - BillingManagementState = BillingManagementTenantState.Active, - ProvisioningManagementState = BillingProvisioningTenantState.Pending, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, associatedTenantName, data); - BillingAssociatedTenantResource result = lro.Value; + bool result = await collection.ExistsAsync(associatedTenantName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAssociatedTenantData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AssociatedTenantsListByBillingAccount() + public async Task GetIfExists_AssociatedTenantsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsListByBillingAccount.json - // this example is just showing the usage of "AssociatedTenants_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsGet.json + // this example is just showing the usage of "AssociatedTenants_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,18 +174,23 @@ public async Task GetAll_AssociatedTenantsListByBillingAccount() // get the collection of this BillingAssociatedTenantResource BillingAssociatedTenantCollection collection = billingAccount.GetBillingAssociatedTenants(); - // invoke the operation and iterate over the result - BillingAssociatedTenantCollectionGetAllOptions options = new BillingAssociatedTenantCollectionGetAllOptions() { }; - await foreach (BillingAssociatedTenantResource item in collection.GetAllAsync(options)) + // invoke the operation + string associatedTenantName = "11111111-1111-1111-1111-111111111111"; + NullableResponse response = await collection.GetIfExistsAsync(associatedTenantName); + BillingAssociatedTenantResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingAssociatedTenantData resourceData = item.Data; + BillingAssociatedTenantData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAssociatedTenantResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAssociatedTenantResource.cs index 99483ff68967c..3b9c3b9a9a27d 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAssociatedTenantResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingAssociatedTenantResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingAssociatedTenantResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AssociatedTenantsDelete() + public async Task Get_AssociatedTenantsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsDelete.json - // this example is just showing the usage of "AssociatedTenants_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsGet.json + // this example is just showing the usage of "AssociatedTenants_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,17 +36,21 @@ public async Task Delete_AssociatedTenantsDelete() BillingAssociatedTenantResource billingAssociatedTenant = client.GetBillingAssociatedTenantResource(billingAssociatedTenantResourceId); // invoke the operation - await billingAssociatedTenant.DeleteAsync(WaitUntil.Completed); + BillingAssociatedTenantResource result = await billingAssociatedTenant.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingAssociatedTenantData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AssociatedTenantsGet() + public async Task Delete_AssociatedTenantsDelete() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsGet.json - // this example is just showing the usage of "AssociatedTenants_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/associatedTenantsDelete.json + // this example is just showing the usage of "AssociatedTenants_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,13 +65,9 @@ public async Task Get_AssociatedTenantsGet() BillingAssociatedTenantResource billingAssociatedTenant = client.GetBillingAssociatedTenantResource(billingAssociatedTenantResourceId); // invoke the operation - BillingAssociatedTenantResource result = await billingAssociatedTenant.GetAsync(); + await billingAssociatedTenant.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingAssociatedTenantData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -90,9 +90,9 @@ public async Task Update_AssociatedTenantsCreateOrUpdate() BillingAssociatedTenantResource billingAssociatedTenant = client.GetBillingAssociatedTenantResource(billingAssociatedTenantResourceId); // invoke the operation - BillingAssociatedTenantData data = new BillingAssociatedTenantData() + BillingAssociatedTenantData data = new BillingAssociatedTenantData { - Properties = new BillingAssociatedTenantProperties() + Properties = new BillingAssociatedTenantProperties { DisplayName = "Contoso Finance", BillingManagementState = BillingManagementTenantState.Active, diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerCollection.cs index 8e2ecc7ed0283..18191f72d1689 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerCollection.cs @@ -50,10 +50,10 @@ public async Task Get_CustomersGetByBillingAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CustomersGetByBillingAccount() + public async Task GetAll_CustomersListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGetByBillingAccount.json - // this example is just showing the usage of "Customers_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersListByBillingAccount.json + // this example is just showing the usage of "Customers_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,19 +69,26 @@ public async Task Exists_CustomersGetByBillingAccount() // get the collection of this BillingCustomerResource BillingCustomerCollection collection = billingAccount.GetBillingCustomers(); - // invoke the operation - string customerName = "11111111-1111-1111-1111-111111111111"; - bool result = await collection.ExistsAsync(customerName); + // invoke the operation and iterate over the result + BillingCustomerCollectionGetAllOptions options = new BillingCustomerCollectionGetAllOptions(); + await foreach (BillingCustomerResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingCustomerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CustomersGetByBillingAccount() + public async Task GetAll_CustomersListByBillingAccountWithExpand() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGetByBillingAccount.json - // this example is just showing the usage of "Customers_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersListByBillingAccountWithExpand.json + // this example is just showing the usage of "Customers_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,31 +104,26 @@ public async Task GetIfExists_CustomersGetByBillingAccount() // get the collection of this BillingCustomerResource BillingCustomerCollection collection = billingAccount.GetBillingCustomers(); - // invoke the operation - string customerName = "11111111-1111-1111-1111-111111111111"; - NullableResponse response = await collection.GetIfExistsAsync(customerName); - BillingCustomerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + BillingCustomerCollectionGetAllOptions options = new BillingCustomerCollectionGetAllOptions { Expand = "enabledAzurePlans,resellers" }; + await foreach (BillingCustomerResource item in collection.GetAllAsync(options)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingCustomerData resourceData = result.Data; + BillingCustomerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CustomersListByBillingAccount() + public async Task Exists_CustomersGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersListByBillingAccount.json - // this example is just showing the usage of "Customers_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGetByBillingAccount.json + // this example is just showing the usage of "Customers_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,26 +139,19 @@ public async Task GetAll_CustomersListByBillingAccount() // get the collection of this BillingCustomerResource BillingCustomerCollection collection = billingAccount.GetBillingCustomers(); - // invoke the operation and iterate over the result - BillingCustomerCollectionGetAllOptions options = new BillingCustomerCollectionGetAllOptions() { }; - await foreach (BillingCustomerResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingCustomerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string customerName = "11111111-1111-1111-1111-111111111111"; + bool result = await collection.ExistsAsync(customerName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CustomersListByBillingAccountWithExpand() + public async Task GetIfExists_CustomersGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersListByBillingAccountWithExpand.json - // this example is just showing the usage of "Customers_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGetByBillingAccount.json + // this example is just showing the usage of "Customers_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,18 +167,23 @@ public async Task GetAll_CustomersListByBillingAccountWithExpand() // get the collection of this BillingCustomerResource BillingCustomerCollection collection = billingAccount.GetBillingCustomers(); - // invoke the operation and iterate over the result - BillingCustomerCollectionGetAllOptions options = new BillingCustomerCollectionGetAllOptions() { Expand = "enabledAzurePlans,resellers" }; - await foreach (BillingCustomerResource item in collection.GetAllAsync(options)) + // invoke the operation + string customerName = "11111111-1111-1111-1111-111111111111"; + NullableResponse response = await collection.GetIfExistsAsync(customerName); + BillingCustomerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingCustomerData resourceData = item.Data; + BillingCustomerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerPolicyResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerPolicyResource.cs index e01b515a4191c..770a36cc031e9 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerPolicyResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerPolicyResource.cs @@ -65,7 +65,7 @@ public async Task CreateOrUpdate_PoliciesPutByCustomerAtBillingAccount() BillingCustomerPolicyResource billingCustomerPolicy = client.GetBillingCustomerPolicyResource(billingCustomerPolicyResourceId); // invoke the operation - BillingCustomerPolicyData data = new BillingCustomerPolicyData() + BillingCustomerPolicyData data = new BillingCustomerPolicyData { Properties = new BillingCustomerPolicyProperties(ViewChargesPolicy.Allowed), }; diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerResource.cs index 4f382c5596b2d..f2d35b473910c 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerResource.cs @@ -16,6 +16,35 @@ namespace Azure.ResourceManager.Billing.Samples { public partial class Sample_BillingCustomerResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CustomersGetByBillingAccount() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGetByBillingAccount.json + // this example is just showing the usage of "Customers_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BillingCustomerResource created on azure + // for more information of creating BillingCustomerResource, please refer to the document of BillingCustomerResource + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string customerName = "11111111-1111-1111-1111-111111111111"; + ResourceIdentifier billingCustomerResourceId = BillingCustomerResource.CreateResourceIdentifier(billingAccountName, customerName); + BillingCustomerResource billingCustomer = client.GetBillingCustomerResource(billingCustomerResourceId); + + // invoke the operation + BillingCustomerResource result = await billingCustomer.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingCustomerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetBillingPermissionsByCustomerAtBillingAccount_BillingPermissionsListByCustomerAtBillingAccount() @@ -64,7 +93,7 @@ public async Task GetBillingSubscriptionsByCustomerAtBillingAccount_BillingSubsc BillingCustomerResource billingCustomer = client.GetBillingCustomerResource(billingCustomerResourceId); // invoke the operation and iterate over the result - BillingCustomerResourceGetBillingSubscriptionsByCustomerAtBillingAccountOptions options = new BillingCustomerResourceGetBillingSubscriptionsByCustomerAtBillingAccountOptions() { }; + BillingCustomerResourceGetBillingSubscriptionsByCustomerAtBillingAccountOptions options = new BillingCustomerResourceGetBillingSubscriptionsByCustomerAtBillingAccountOptions(); await foreach (BillingSubscriptionData item in billingCustomer.GetBillingSubscriptionsByCustomerAtBillingAccountAsync(options)) { // for demo we just print out the id @@ -74,35 +103,6 @@ public async Task GetBillingSubscriptionsByCustomerAtBillingAccount_BillingSubsc Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_CustomersGetByBillingAccount() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGetByBillingAccount.json - // this example is just showing the usage of "Customers_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BillingCustomerResource created on azure - // for more information of creating BillingCustomerResource, please refer to the document of BillingCustomerResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - string customerName = "11111111-1111-1111-1111-111111111111"; - ResourceIdentifier billingCustomerResourceId = BillingCustomerResource.CreateResourceIdentifier(billingAccountName, customerName); - BillingCustomerResource billingCustomer = client.GetBillingCustomerResource(billingCustomerResourceId); - - // invoke the operation - BillingCustomerResource result = await billingCustomer.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingCustomerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetProducts_ProductsListByCustomer() @@ -123,7 +123,7 @@ public async Task GetProducts_ProductsListByCustomer() BillingCustomerResource billingCustomer = client.GetBillingCustomerResource(billingCustomerResourceId); // invoke the operation and iterate over the result - BillingCustomerResourceGetProductsOptions options = new BillingCustomerResourceGetProductsOptions() { }; + BillingCustomerResourceGetProductsOptions options = new BillingCustomerResourceGetProductsOptions(); await foreach (BillingProductResource item in billingCustomer.GetProductsAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleAssignmentCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleAssignmentCollection.cs index 00d3ef355fbe9..2ae2af91ac6af 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleAssignmentCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleAssignmentCollection.cs @@ -51,10 +51,10 @@ public async Task Get_BillingRoleAssignmentGetByCustomer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleAssignmentGetByCustomer() + public async Task GetAll_BillingRoleAssignmentListByCustomer() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByCustomer.json - // this example is just showing the usage of "BillingRoleAssignments_GetByCustomer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByCustomer.json + // this example is just showing the usage of "BillingRoleAssignments_ListByCustomer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,7 +64,7 @@ public async Task Exists_BillingRoleAssignmentGetByCustomer() // this example assumes you already have this BillingProfileCustomerResource created on azure // for more information of creating BillingProfileCustomerResource, please refer to the document of BillingProfileCustomerResource string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"; - string billingProfileName = "xxxx-xxxx-xxx-xxx"; + string billingProfileName = "BKM6-54VH-BG7-PGB"; string customerName = "703ab484-dda2-4402-827b-a74513b61e2d"; ResourceIdentifier billingProfileCustomerResourceId = BillingProfileCustomerResource.CreateResourceIdentifier(billingAccountName, billingProfileName, customerName); BillingProfileCustomerResource billingProfileCustomer = client.GetBillingProfileCustomerResource(billingProfileCustomerResourceId); @@ -72,16 +72,22 @@ public async Task Exists_BillingRoleAssignmentGetByCustomer() // get the collection of this BillingCustomerRoleAssignmentResource BillingCustomerRoleAssignmentCollection collection = billingProfileCustomer.GetBillingCustomerRoleAssignments(); - // invoke the operation - string billingRoleAssignmentName = "30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; - bool result = await collection.ExistsAsync(billingRoleAssignmentName); + // invoke the operation and iterate over the result + await foreach (BillingCustomerRoleAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleAssignmentGetByCustomer() + public async Task Exists_BillingRoleAssignmentGetByCustomer() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByCustomer.json // this example is just showing the usage of "BillingRoleAssignments_GetByCustomer" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_BillingRoleAssignmentGetByCustomer() // invoke the operation string billingRoleAssignmentName = "30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; - NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); - BillingCustomerRoleAssignmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(billingRoleAssignmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleAssignmentListByCustomer() + public async Task GetIfExists_BillingRoleAssignmentGetByCustomer() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByCustomer.json - // this example is just showing the usage of "BillingRoleAssignments_ListByCustomer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByCustomer.json + // this example is just showing the usage of "BillingRoleAssignments_GetByCustomer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,7 +130,7 @@ public async Task GetAll_BillingRoleAssignmentListByCustomer() // this example assumes you already have this BillingProfileCustomerResource created on azure // for more information of creating BillingProfileCustomerResource, please refer to the document of BillingProfileCustomerResource string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"; - string billingProfileName = "BKM6-54VH-BG7-PGB"; + string billingProfileName = "xxxx-xxxx-xxx-xxx"; string customerName = "703ab484-dda2-4402-827b-a74513b61e2d"; ResourceIdentifier billingProfileCustomerResourceId = BillingProfileCustomerResource.CreateResourceIdentifier(billingAccountName, billingProfileName, customerName); BillingProfileCustomerResource billingProfileCustomer = client.GetBillingProfileCustomerResource(billingProfileCustomerResourceId); @@ -144,17 +138,23 @@ public async Task GetAll_BillingRoleAssignmentListByCustomer() // get the collection of this BillingCustomerRoleAssignmentResource BillingCustomerRoleAssignmentCollection collection = billingProfileCustomer.GetBillingCustomerRoleAssignments(); - // invoke the operation and iterate over the result - await foreach (BillingCustomerRoleAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string billingRoleAssignmentName = "30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; + NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); + BillingCustomerRoleAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = item.Data; + BillingRoleAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleAssignmentResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleAssignmentResource.cs index aae1d9716f8b8..814b6bf4575e3 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleAssignmentResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleAssignmentResource.cs @@ -17,10 +17,10 @@ public partial class Sample_BillingCustomerRoleAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BillingRoleAssignmentDeleteByCustomer() + public async Task Get_BillingRoleAssignmentGetByCustomer() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByCustomer.json - // this example is just showing the usage of "BillingRoleAssignments_DeleteByCustomer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByCustomer.json + // this example is just showing the usage of "BillingRoleAssignments_GetByCustomer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,24 +30,28 @@ public async Task Delete_BillingRoleAssignmentDeleteByCustomer() // this example assumes you already have this BillingCustomerRoleAssignmentResource created on azure // for more information of creating BillingCustomerRoleAssignmentResource, please refer to the document of BillingCustomerRoleAssignmentResource string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"; - string billingProfileName = "BKM6-54VH-BG7-PGB"; + string billingProfileName = "xxxx-xxxx-xxx-xxx"; string customerName = "703ab484-dda2-4402-827b-a74513b61e2d"; - string billingRoleAssignmentName = "30000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"; + string billingRoleAssignmentName = "30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; ResourceIdentifier billingCustomerRoleAssignmentResourceId = BillingCustomerRoleAssignmentResource.CreateResourceIdentifier(billingAccountName, billingProfileName, customerName, billingRoleAssignmentName); BillingCustomerRoleAssignmentResource billingCustomerRoleAssignment = client.GetBillingCustomerRoleAssignmentResource(billingCustomerRoleAssignmentResourceId); // invoke the operation - await billingCustomerRoleAssignment.DeleteAsync(WaitUntil.Completed); + BillingCustomerRoleAssignmentResource result = await billingCustomerRoleAssignment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingRoleAssignmentGetByCustomer() + public async Task Delete_BillingRoleAssignmentDeleteByCustomer() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByCustomer.json - // this example is just showing the usage of "BillingRoleAssignments_GetByCustomer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByCustomer.json + // this example is just showing the usage of "BillingRoleAssignments_DeleteByCustomer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -57,20 +61,16 @@ public async Task Get_BillingRoleAssignmentGetByCustomer() // this example assumes you already have this BillingCustomerRoleAssignmentResource created on azure // for more information of creating BillingCustomerRoleAssignmentResource, please refer to the document of BillingCustomerRoleAssignmentResource string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"; - string billingProfileName = "xxxx-xxxx-xxx-xxx"; + string billingProfileName = "BKM6-54VH-BG7-PGB"; string customerName = "703ab484-dda2-4402-827b-a74513b61e2d"; - string billingRoleAssignmentName = "30000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; + string billingRoleAssignmentName = "30000000-aaaa-bbbb-cccc-100000000000_00000000-0000-0000-0000-000000000000"; ResourceIdentifier billingCustomerRoleAssignmentResourceId = BillingCustomerRoleAssignmentResource.CreateResourceIdentifier(billingAccountName, billingProfileName, customerName, billingRoleAssignmentName); BillingCustomerRoleAssignmentResource billingCustomerRoleAssignment = client.GetBillingCustomerRoleAssignmentResource(billingCustomerRoleAssignmentResourceId); // invoke the operation - BillingCustomerRoleAssignmentResource result = await billingCustomerRoleAssignment.GetAsync(); + await billingCustomerRoleAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleDefinitionCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleDefinitionCollection.cs index bd6994c4633e7..1dc2663ebf3bd 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleDefinitionCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingCustomerRoleDefinitionCollection.cs @@ -51,10 +51,10 @@ public async Task Get_BillingRoleDefinitionGetByCustomer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleDefinitionGetByCustomer() + public async Task GetAll_BillingRoleDefinitionListByCustomer() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByCustomer.json - // this example is just showing the usage of "BillingRoleDefinition_GetByCustomer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByCustomer.json + // this example is just showing the usage of "BillingRoleDefinition_ListByCustomer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_BillingRoleDefinitionGetByCustomer() // get the collection of this BillingCustomerRoleDefinitionResource BillingCustomerRoleDefinitionCollection collection = billingProfileCustomer.GetBillingCustomerRoleDefinitions(); - // invoke the operation - string roleDefinitionName = "30000000-aaaa-bbbb-cccc-100000000000"; - bool result = await collection.ExistsAsync(roleDefinitionName); + // invoke the operation and iterate over the result + await foreach (BillingCustomerRoleDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleDefinitionGetByCustomer() + public async Task Exists_BillingRoleDefinitionGetByCustomer() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByCustomer.json // this example is just showing the usage of "BillingRoleDefinition_GetByCustomer" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_BillingRoleDefinitionGetByCustomer() // invoke the operation string roleDefinitionName = "30000000-aaaa-bbbb-cccc-100000000000"; - NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); - BillingCustomerRoleDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(roleDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleDefinitionListByCustomer() + public async Task GetIfExists_BillingRoleDefinitionGetByCustomer() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByCustomer.json - // this example is just showing the usage of "BillingRoleDefinition_ListByCustomer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByCustomer.json + // this example is just showing the usage of "BillingRoleDefinition_GetByCustomer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_BillingRoleDefinitionListByCustomer() // get the collection of this BillingCustomerRoleDefinitionResource BillingCustomerRoleDefinitionCollection collection = billingProfileCustomer.GetBillingCustomerRoleDefinitions(); - // invoke the operation and iterate over the result - await foreach (BillingCustomerRoleDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string roleDefinitionName = "30000000-aaaa-bbbb-cccc-100000000000"; + NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); + BillingCustomerRoleDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = item.Data; + BillingRoleDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentCollection.cs index 3b72d5e32ce91..7f23866070aff 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentCollection.cs @@ -49,10 +49,10 @@ public async Task Get_DepartmentGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DepartmentGet() + public async Task GetAll_DepartmentsListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/departmentGet.json - // this example is just showing the usage of "Departments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/departmentsListByBillingAccount.json + // this example is just showing the usage of "Departments_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,16 +68,22 @@ public async Task Exists_DepartmentGet() // get the collection of this BillingDepartmentResource BillingDepartmentCollection collection = billingAccount.GetBillingDepartments(); - // invoke the operation - string departmentName = "164821"; - bool result = await collection.ExistsAsync(departmentName); + // invoke the operation and iterate over the result + await foreach (BillingDepartmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingDepartmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DepartmentGet() + public async Task Exists_DepartmentGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/departmentGet.json // this example is just showing the usage of "Departments_Get" operation, for the dependent resources, they will have to be created separately. @@ -98,29 +104,17 @@ public async Task GetIfExists_DepartmentGet() // invoke the operation string departmentName = "164821"; - NullableResponse response = await collection.GetIfExistsAsync(departmentName); - BillingDepartmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(departmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingDepartmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DepartmentsListByBillingAccount() + public async Task GetIfExists_DepartmentGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/departmentsListByBillingAccount.json - // this example is just showing the usage of "Departments_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/departmentGet.json + // this example is just showing the usage of "Departments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,17 +130,23 @@ public async Task GetAll_DepartmentsListByBillingAccount() // get the collection of this BillingDepartmentResource BillingDepartmentCollection collection = billingAccount.GetBillingDepartments(); - // invoke the operation and iterate over the result - await foreach (BillingDepartmentResource item in collection.GetAllAsync()) + // invoke the operation + string departmentName = "164821"; + NullableResponse response = await collection.GetIfExistsAsync(departmentName); + BillingDepartmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingDepartmentData resourceData = item.Data; + BillingDepartmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentEnrollmentAccountCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentEnrollmentAccountCollection.cs index 2e55192a52393..56be754f1826a 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentEnrollmentAccountCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentEnrollmentAccountCollection.cs @@ -51,10 +51,10 @@ public async Task Get_EnrollmentAccountByDepartment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EnrollmentAccountByDepartment() + public async Task GetAll_EnrollmentAccountsListByDepartment() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountByDepartment.json - // this example is just showing the usage of "EnrollmentAccounts_GetByDepartment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountsListByDepartment.json + // this example is just showing the usage of "EnrollmentAccounts_ListByDepartment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,16 +71,23 @@ public async Task Exists_EnrollmentAccountByDepartment() // get the collection of this BillingDepartmentEnrollmentAccountResource BillingDepartmentEnrollmentAccountCollection collection = billingDepartment.GetBillingDepartmentEnrollmentAccounts(); - // invoke the operation - string enrollmentAccountName = "257698"; - bool result = await collection.ExistsAsync(enrollmentAccountName); + // invoke the operation and iterate over the result + BillingDepartmentEnrollmentAccountCollectionGetAllOptions options = new BillingDepartmentEnrollmentAccountCollectionGetAllOptions(); + await foreach (BillingDepartmentEnrollmentAccountResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingEnrollmentAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EnrollmentAccountByDepartment() + public async Task Exists_EnrollmentAccountByDepartment() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountByDepartment.json // this example is just showing the usage of "EnrollmentAccounts_GetByDepartment" operation, for the dependent resources, they will have to be created separately. @@ -102,29 +109,17 @@ public async Task GetIfExists_EnrollmentAccountByDepartment() // invoke the operation string enrollmentAccountName = "257698"; - NullableResponse response = await collection.GetIfExistsAsync(enrollmentAccountName); - BillingDepartmentEnrollmentAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(enrollmentAccountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingEnrollmentAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EnrollmentAccountsListByDepartment() + public async Task GetIfExists_EnrollmentAccountByDepartment() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountsListByDepartment.json - // this example is just showing the usage of "EnrollmentAccounts_ListByDepartment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountByDepartment.json + // this example is just showing the usage of "EnrollmentAccounts_GetByDepartment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,18 +136,23 @@ public async Task GetAll_EnrollmentAccountsListByDepartment() // get the collection of this BillingDepartmentEnrollmentAccountResource BillingDepartmentEnrollmentAccountCollection collection = billingDepartment.GetBillingDepartmentEnrollmentAccounts(); - // invoke the operation and iterate over the result - BillingDepartmentEnrollmentAccountCollectionGetAllOptions options = new BillingDepartmentEnrollmentAccountCollectionGetAllOptions() { }; - await foreach (BillingDepartmentEnrollmentAccountResource item in collection.GetAllAsync(options)) + // invoke the operation + string enrollmentAccountName = "257698"; + NullableResponse response = await collection.GetIfExistsAsync(enrollmentAccountName); + BillingDepartmentEnrollmentAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingEnrollmentAccountData resourceData = item.Data; + BillingEnrollmentAccountData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentResource.cs index 3a8a77c04102a..a63b94567cae4 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentResource.cs @@ -16,6 +16,35 @@ namespace Azure.ResourceManager.Billing.Samples { public partial class Sample_BillingDepartmentResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_DepartmentGet() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/departmentGet.json + // this example is just showing the usage of "Departments_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BillingDepartmentResource created on azure + // for more information of creating BillingDepartmentResource, please refer to the document of BillingDepartmentResource + string billingAccountName = "456598"; + string departmentName = "164821"; + ResourceIdentifier billingDepartmentResourceId = BillingDepartmentResource.CreateResourceIdentifier(billingAccountName, departmentName); + BillingDepartmentResource billingDepartment = client.GetBillingDepartmentResource(billingDepartmentResourceId); + + // invoke the operation + BillingDepartmentResource result = await billingDepartment.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingDepartmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetBillingPermissions_BillingPermissionsListByDepartment() @@ -64,12 +93,9 @@ public async Task CheckAccessBillingPermissions_CheckAccessByDepartment() BillingDepartmentResource billingDepartment = client.GetBillingDepartmentResource(billingDepartmentResourceId); // invoke the operation and iterate over the result - BillingCheckAccessContent content = new BillingCheckAccessContent() + BillingCheckAccessContent content = new BillingCheckAccessContent { - Actions = -{ -"Microsoft.Billing/billingAccounts/read","Microsoft.Subscription/subscriptions/write" -}, + Actions = { "Microsoft.Billing/billingAccounts/read", "Microsoft.Subscription/subscriptions/write" }, }; await foreach (BillingCheckAccessResult item in billingDepartment.CheckAccessBillingPermissionsAsync(content)) { @@ -78,34 +104,5 @@ public async Task CheckAccessBillingPermissions_CheckAccessByDepartment() Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_DepartmentGet() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/departmentGet.json - // this example is just showing the usage of "Departments_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BillingDepartmentResource created on azure - // for more information of creating BillingDepartmentResource, please refer to the document of BillingDepartmentResource - string billingAccountName = "456598"; - string departmentName = "164821"; - ResourceIdentifier billingDepartmentResourceId = BillingDepartmentResource.CreateResourceIdentifier(billingAccountName, departmentName); - BillingDepartmentResource billingDepartment = client.GetBillingDepartmentResource(billingDepartmentResourceId); - - // invoke the operation - BillingDepartmentResource result = await billingDepartment.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingDepartmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleAssignmentCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleAssignmentCollection.cs index 6e6658eb4f35e..83651a7d747c7 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleAssignmentCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleAssignmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingDepartmentRoleAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingRoleAssignmentGetByDepartment() + public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByDepartment() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByDepartment.json - // this example is just showing the usage of "BillingRoleAssignments_GetByDepartment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateOrUpdateByDepartment.json + // this example is just showing the usage of "BillingRoleAssignments_CreateOrUpdateByDepartment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task Get_BillingRoleAssignmentGetByDepartment() // this example assumes you already have this BillingDepartmentResource created on azure // for more information of creating BillingDepartmentResource, please refer to the document of BillingDepartmentResource string billingAccountName = "7898901"; - string departmentName = "225314"; + string departmentName = "12345"; ResourceIdentifier billingDepartmentResourceId = BillingDepartmentResource.CreateResourceIdentifier(billingAccountName, departmentName); BillingDepartmentResource billingDepartment = client.GetBillingDepartmentResource(billingDepartmentResourceId); @@ -40,7 +40,17 @@ public async Task Get_BillingRoleAssignmentGetByDepartment() // invoke the operation string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; - BillingDepartmentRoleAssignmentResource result = await collection.GetAsync(billingRoleAssignmentName); + BillingRoleAssignmentData data = new BillingRoleAssignmentData + { + Properties = new BillingRoleAssignmentProperties(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/7898901/departments/12345/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db")) + { + PrincipalId = "00000000-0000-0000-0000-000000000000", + PrincipalTenantId = Guid.Parse("076915e7-de10-4323-bb34-a58c904068bb"), + UserEmailAddress = "john@contoso.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, billingRoleAssignmentName, data); + BillingDepartmentRoleAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +61,7 @@ public async Task Get_BillingRoleAssignmentGetByDepartment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleAssignmentGetByDepartment() + public async Task Get_BillingRoleAssignmentGetByDepartment() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByDepartment.json // this example is just showing the usage of "BillingRoleAssignments_GetByDepartment" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +83,21 @@ public async Task Exists_BillingRoleAssignmentGetByDepartment() // invoke the operation string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; - bool result = await collection.ExistsAsync(billingRoleAssignmentName); + BillingDepartmentRoleAssignmentResource result = await collection.GetAsync(billingRoleAssignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleAssignmentGetByDepartment() + public async Task GetAll_BillingRoleAssignmentListByDepartment() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByDepartment.json - // this example is just showing the usage of "BillingRoleAssignments_GetByDepartment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByDepartment.json + // this example is just showing the usage of "BillingRoleAssignments_ListByDepartment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,39 +106,33 @@ public async Task GetIfExists_BillingRoleAssignmentGetByDepartment() // this example assumes you already have this BillingDepartmentResource created on azure // for more information of creating BillingDepartmentResource, please refer to the document of BillingDepartmentResource - string billingAccountName = "7898901"; - string departmentName = "225314"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"; + string departmentName = "12345"; ResourceIdentifier billingDepartmentResourceId = BillingDepartmentResource.CreateResourceIdentifier(billingAccountName, departmentName); BillingDepartmentResource billingDepartment = client.GetBillingDepartmentResource(billingDepartmentResourceId); // get the collection of this BillingDepartmentRoleAssignmentResource BillingDepartmentRoleAssignmentCollection collection = billingDepartment.GetBillingDepartmentRoleAssignments(); - // invoke the operation - string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; - NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); - BillingDepartmentRoleAssignmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (BillingDepartmentRoleAssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; + BillingRoleAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByDepartment() + public async Task Exists_BillingRoleAssignmentGetByDepartment() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateOrUpdateByDepartment.json - // this example is just showing the usage of "BillingRoleAssignments_CreateOrUpdateByDepartment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByDepartment.json + // this example is just showing the usage of "BillingRoleAssignments_GetByDepartment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,7 +142,7 @@ public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByDepartment // this example assumes you already have this BillingDepartmentResource created on azure // for more information of creating BillingDepartmentResource, please refer to the document of BillingDepartmentResource string billingAccountName = "7898901"; - string departmentName = "12345"; + string departmentName = "225314"; ResourceIdentifier billingDepartmentResourceId = BillingDepartmentResource.CreateResourceIdentifier(billingAccountName, departmentName); BillingDepartmentResource billingDepartment = client.GetBillingDepartmentResource(billingDepartmentResourceId); @@ -143,31 +151,17 @@ public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByDepartment // invoke the operation string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; - BillingRoleAssignmentData data = new BillingRoleAssignmentData() - { - Properties = new BillingRoleAssignmentProperties(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/7898901/departments/12345/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db")) - { - PrincipalId = "00000000-0000-0000-0000-000000000000", - PrincipalTenantId = Guid.Parse("076915e7-de10-4323-bb34-a58c904068bb"), - UserEmailAddress = "john@contoso.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, billingRoleAssignmentName, data); - BillingDepartmentRoleAssignmentResource result = lro.Value; + bool result = await collection.ExistsAsync(billingRoleAssignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleAssignmentListByDepartment() + public async Task GetIfExists_BillingRoleAssignmentGetByDepartment() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByDepartment.json - // this example is just showing the usage of "BillingRoleAssignments_ListByDepartment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByDepartment.json + // this example is just showing the usage of "BillingRoleAssignments_GetByDepartment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,25 +170,31 @@ public async Task GetAll_BillingRoleAssignmentListByDepartment() // this example assumes you already have this BillingDepartmentResource created on azure // for more information of creating BillingDepartmentResource, please refer to the document of BillingDepartmentResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"; - string departmentName = "12345"; + string billingAccountName = "7898901"; + string departmentName = "225314"; ResourceIdentifier billingDepartmentResourceId = BillingDepartmentResource.CreateResourceIdentifier(billingAccountName, departmentName); BillingDepartmentResource billingDepartment = client.GetBillingDepartmentResource(billingDepartmentResourceId); // get the collection of this BillingDepartmentRoleAssignmentResource BillingDepartmentRoleAssignmentCollection collection = billingDepartment.GetBillingDepartmentRoleAssignments(); - // invoke the operation and iterate over the result - await foreach (BillingDepartmentRoleAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; + NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); + BillingDepartmentRoleAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = item.Data; + BillingRoleAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleAssignmentResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleAssignmentResource.cs index e6d8244f29ce5..19c64f1d491ca 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleAssignmentResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingDepartmentRoleAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BillingRoleAssignmentDeleteByDepartment() + public async Task Get_BillingRoleAssignmentGetByDepartment() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByDepartment.json - // this example is just showing the usage of "BillingRoleAssignments_DeleteByDepartment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByDepartment.json + // this example is just showing the usage of "BillingRoleAssignments_GetByDepartment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,24 +30,28 @@ public async Task Delete_BillingRoleAssignmentDeleteByDepartment() // this example assumes you already have this BillingDepartmentRoleAssignmentResource created on azure // for more information of creating BillingDepartmentRoleAssignmentResource, please refer to the document of BillingDepartmentRoleAssignmentResource - string billingAccountName = "8608480"; - string departmentName = "123456"; + string billingAccountName = "7898901"; + string departmentName = "225314"; string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; ResourceIdentifier billingDepartmentRoleAssignmentResourceId = BillingDepartmentRoleAssignmentResource.CreateResourceIdentifier(billingAccountName, departmentName, billingRoleAssignmentName); BillingDepartmentRoleAssignmentResource billingDepartmentRoleAssignment = client.GetBillingDepartmentRoleAssignmentResource(billingDepartmentRoleAssignmentResourceId); // invoke the operation - await billingDepartmentRoleAssignment.DeleteAsync(WaitUntil.Completed); + BillingDepartmentRoleAssignmentResource result = await billingDepartmentRoleAssignment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingRoleAssignmentGetByDepartment() + public async Task Delete_BillingRoleAssignmentDeleteByDepartment() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByDepartment.json - // this example is just showing the usage of "BillingRoleAssignments_GetByDepartment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByDepartment.json + // this example is just showing the usage of "BillingRoleAssignments_DeleteByDepartment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -56,20 +60,16 @@ public async Task Get_BillingRoleAssignmentGetByDepartment() // this example assumes you already have this BillingDepartmentRoleAssignmentResource created on azure // for more information of creating BillingDepartmentRoleAssignmentResource, please refer to the document of BillingDepartmentRoleAssignmentResource - string billingAccountName = "7898901"; - string departmentName = "225314"; + string billingAccountName = "8608480"; + string departmentName = "123456"; string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; ResourceIdentifier billingDepartmentRoleAssignmentResourceId = BillingDepartmentRoleAssignmentResource.CreateResourceIdentifier(billingAccountName, departmentName, billingRoleAssignmentName); BillingDepartmentRoleAssignmentResource billingDepartmentRoleAssignment = client.GetBillingDepartmentRoleAssignmentResource(billingDepartmentRoleAssignmentResourceId); // invoke the operation - BillingDepartmentRoleAssignmentResource result = await billingDepartmentRoleAssignment.GetAsync(); + await billingDepartmentRoleAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -93,7 +93,7 @@ public async Task Update_BillingRoleAssignmentCreateOrUpdateByDepartment() BillingDepartmentRoleAssignmentResource billingDepartmentRoleAssignment = client.GetBillingDepartmentRoleAssignmentResource(billingDepartmentRoleAssignmentResourceId); // invoke the operation - BillingRoleAssignmentData data = new BillingRoleAssignmentData() + BillingRoleAssignmentData data = new BillingRoleAssignmentData { Properties = new BillingRoleAssignmentProperties(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/7898901/departments/12345/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db")) { diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleDefinitionCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleDefinitionCollection.cs index 8da02797cb9a7..6e57408c1db53 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleDefinitionCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingDepartmentRoleDefinitionCollection.cs @@ -50,10 +50,10 @@ public async Task Get_BillingRoleDefinitionGetByDepartment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleDefinitionGetByDepartment() + public async Task GetAll_BillingRoleDefinitionListByDepartment() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByDepartment.json - // this example is just showing the usage of "BillingRoleDefinition_GetByDepartment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByDepartment.json + // this example is just showing the usage of "BillingRoleDefinition_ListByDepartment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,16 +70,22 @@ public async Task Exists_BillingRoleDefinitionGetByDepartment() // get the collection of this BillingDepartmentRoleDefinitionResource BillingDepartmentRoleDefinitionCollection collection = billingDepartment.GetBillingDepartmentRoleDefinitions(); - // invoke the operation - string roleDefinitionName = "50000000-aaaa-bbbb-cccc-100000000000"; - bool result = await collection.ExistsAsync(roleDefinitionName); + // invoke the operation and iterate over the result + await foreach (BillingDepartmentRoleDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleDefinitionGetByDepartment() + public async Task Exists_BillingRoleDefinitionGetByDepartment() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByDepartment.json // this example is just showing the usage of "BillingRoleDefinition_GetByDepartment" operation, for the dependent resources, they will have to be created separately. @@ -101,29 +107,17 @@ public async Task GetIfExists_BillingRoleDefinitionGetByDepartment() // invoke the operation string roleDefinitionName = "50000000-aaaa-bbbb-cccc-100000000000"; - NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); - BillingDepartmentRoleDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(roleDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleDefinitionListByDepartment() + public async Task GetIfExists_BillingRoleDefinitionGetByDepartment() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByDepartment.json - // this example is just showing the usage of "BillingRoleDefinition_ListByDepartment" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByDepartment.json + // this example is just showing the usage of "BillingRoleDefinition_GetByDepartment" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,17 +134,23 @@ public async Task GetAll_BillingRoleDefinitionListByDepartment() // get the collection of this BillingDepartmentRoleDefinitionResource BillingDepartmentRoleDefinitionCollection collection = billingDepartment.GetBillingDepartmentRoleDefinitions(); - // invoke the operation and iterate over the result - await foreach (BillingDepartmentRoleDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string roleDefinitionName = "50000000-aaaa-bbbb-cccc-100000000000"; + NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); + BillingDepartmentRoleDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = item.Data; + BillingRoleDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountCollection.cs index 2465c78e0bf34..5cbcd87012427 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountCollection.cs @@ -50,10 +50,10 @@ public async Task Get_EnrollmentAccountGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EnrollmentAccountGet() + public async Task GetAll_EnrollmentAccountsListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountGet.json - // this example is just showing the usage of "EnrollmentAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountsListByBillingAccount.json + // this example is just showing the usage of "EnrollmentAccounts_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +69,23 @@ public async Task Exists_EnrollmentAccountGet() // get the collection of this BillingEnrollmentAccountResource BillingEnrollmentAccountCollection collection = billingAccount.GetBillingEnrollmentAccounts(); - // invoke the operation - string enrollmentAccountName = "257698"; - bool result = await collection.ExistsAsync(enrollmentAccountName); + // invoke the operation and iterate over the result + BillingEnrollmentAccountCollectionGetAllOptions options = new BillingEnrollmentAccountCollectionGetAllOptions(); + await foreach (BillingEnrollmentAccountResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingEnrollmentAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EnrollmentAccountGet() + public async Task Exists_EnrollmentAccountGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountGet.json // this example is just showing the usage of "EnrollmentAccounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +106,17 @@ public async Task GetIfExists_EnrollmentAccountGet() // invoke the operation string enrollmentAccountName = "257698"; - NullableResponse response = await collection.GetIfExistsAsync(enrollmentAccountName); - BillingEnrollmentAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(enrollmentAccountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingEnrollmentAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EnrollmentAccountsListByBillingAccount() + public async Task GetIfExists_EnrollmentAccountGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountsListByBillingAccount.json - // this example is just showing the usage of "EnrollmentAccounts_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountGet.json + // this example is just showing the usage of "EnrollmentAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,18 +132,23 @@ public async Task GetAll_EnrollmentAccountsListByBillingAccount() // get the collection of this BillingEnrollmentAccountResource BillingEnrollmentAccountCollection collection = billingAccount.GetBillingEnrollmentAccounts(); - // invoke the operation and iterate over the result - BillingEnrollmentAccountCollectionGetAllOptions options = new BillingEnrollmentAccountCollectionGetAllOptions() { }; - await foreach (BillingEnrollmentAccountResource item in collection.GetAllAsync(options)) + // invoke the operation + string enrollmentAccountName = "257698"; + NullableResponse response = await collection.GetIfExistsAsync(enrollmentAccountName); + BillingEnrollmentAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingEnrollmentAccountData resourceData = item.Data; + BillingEnrollmentAccountData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountResource.cs index 82cdecdc342e6..153832c84ae99 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountResource.cs @@ -16,6 +16,35 @@ namespace Azure.ResourceManager.Billing.Samples { public partial class Sample_BillingEnrollmentAccountResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_EnrollmentAccountGet() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountGet.json + // this example is just showing the usage of "EnrollmentAccounts_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BillingEnrollmentAccountResource created on azure + // for more information of creating BillingEnrollmentAccountResource, please refer to the document of BillingEnrollmentAccountResource + string billingAccountName = "6564892"; + string enrollmentAccountName = "257698"; + ResourceIdentifier billingEnrollmentAccountResourceId = BillingEnrollmentAccountResource.CreateResourceIdentifier(billingAccountName, enrollmentAccountName); + BillingEnrollmentAccountResource billingEnrollmentAccount = client.GetBillingEnrollmentAccountResource(billingEnrollmentAccountResourceId); + + // invoke the operation + BillingEnrollmentAccountResource result = await billingEnrollmentAccount.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingEnrollmentAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetBillingPermissions_BillingPermissionsListByEnrollmentAccount() @@ -64,12 +93,9 @@ public async Task CheckAccessBillingPermissions_CheckAccessByEnrollmentAccount() BillingEnrollmentAccountResource billingEnrollmentAccount = client.GetBillingEnrollmentAccountResource(billingEnrollmentAccountResourceId); // invoke the operation and iterate over the result - BillingCheckAccessContent content = new BillingCheckAccessContent() + BillingCheckAccessContent content = new BillingCheckAccessContent { - Actions = -{ -"Microsoft.Billing/billingAccounts/read","Microsoft.Subscription/subscriptions/write" -}, + Actions = { "Microsoft.Billing/billingAccounts/read", "Microsoft.Subscription/subscriptions/write" }, }; await foreach (BillingCheckAccessResult item in billingEnrollmentAccount.CheckAccessBillingPermissionsAsync(content)) { @@ -99,7 +125,7 @@ public async Task GetBillingSubscriptions_BillingSubscriptionsListByEnrollmentAc BillingEnrollmentAccountResource billingEnrollmentAccount = client.GetBillingEnrollmentAccountResource(billingEnrollmentAccountResourceId); // invoke the operation and iterate over the result - BillingEnrollmentAccountResourceGetBillingSubscriptionsOptions options = new BillingEnrollmentAccountResourceGetBillingSubscriptionsOptions() { }; + BillingEnrollmentAccountResourceGetBillingSubscriptionsOptions options = new BillingEnrollmentAccountResourceGetBillingSubscriptionsOptions(); await foreach (BillingSubscriptionData item in billingEnrollmentAccount.GetBillingSubscriptionsAsync(options)) { // for demo we just print out the id @@ -108,34 +134,5 @@ public async Task GetBillingSubscriptions_BillingSubscriptionsListByEnrollmentAc Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_EnrollmentAccountGet() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/enrollmentAccountGet.json - // this example is just showing the usage of "EnrollmentAccounts_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BillingEnrollmentAccountResource created on azure - // for more information of creating BillingEnrollmentAccountResource, please refer to the document of BillingEnrollmentAccountResource - string billingAccountName = "6564892"; - string enrollmentAccountName = "257698"; - ResourceIdentifier billingEnrollmentAccountResourceId = BillingEnrollmentAccountResource.CreateResourceIdentifier(billingAccountName, enrollmentAccountName); - BillingEnrollmentAccountResource billingEnrollmentAccount = client.GetBillingEnrollmentAccountResource(billingEnrollmentAccountResourceId); - - // invoke the operation - BillingEnrollmentAccountResource result = await billingEnrollmentAccount.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingEnrollmentAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleAssignmentCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleAssignmentCollection.cs index 243751aeb078c..5039a22c14641 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleAssignmentCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleAssignmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingEnrollmentAccountRoleAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingRoleAssignmentGetByEnrollmentAccount() + public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByEnrollmentAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByEnrollmentAccount.json - // this example is just showing the usage of "BillingRoleAssignments_GetByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateOrUpdateByEnrollmentAccount.json + // this example is just showing the usage of "BillingRoleAssignments_CreateOrUpdateByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task Get_BillingRoleAssignmentGetByEnrollmentAccount() // this example assumes you already have this BillingEnrollmentAccountResource created on azure // for more information of creating BillingEnrollmentAccountResource, please refer to the document of BillingEnrollmentAccountResource string billingAccountName = "7898901"; - string enrollmentAccountName = "225314"; + string enrollmentAccountName = "123456"; ResourceIdentifier billingEnrollmentAccountResourceId = BillingEnrollmentAccountResource.CreateResourceIdentifier(billingAccountName, enrollmentAccountName); BillingEnrollmentAccountResource billingEnrollmentAccount = client.GetBillingEnrollmentAccountResource(billingEnrollmentAccountResourceId); @@ -40,7 +40,17 @@ public async Task Get_BillingRoleAssignmentGetByEnrollmentAccount() // invoke the operation string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; - BillingEnrollmentAccountRoleAssignmentResource result = await collection.GetAsync(billingRoleAssignmentName); + BillingRoleAssignmentData data = new BillingRoleAssignmentData + { + Properties = new BillingRoleAssignmentProperties(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/123456/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db")) + { + PrincipalId = "00000000-0000-0000-0000-000000000000", + PrincipalTenantId = Guid.Parse("076915e7-de10-4323-bb34-a58c904068bb"), + UserEmailAddress = "john@contoso.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, billingRoleAssignmentName, data); + BillingEnrollmentAccountRoleAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +61,7 @@ public async Task Get_BillingRoleAssignmentGetByEnrollmentAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleAssignmentGetByEnrollmentAccount() + public async Task Get_BillingRoleAssignmentGetByEnrollmentAccount() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByEnrollmentAccount.json // this example is just showing the usage of "BillingRoleAssignments_GetByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +83,21 @@ public async Task Exists_BillingRoleAssignmentGetByEnrollmentAccount() // invoke the operation string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; - bool result = await collection.ExistsAsync(billingRoleAssignmentName); + BillingEnrollmentAccountRoleAssignmentResource result = await collection.GetAsync(billingRoleAssignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleAssignmentGetByEnrollmentAccount() + public async Task GetAll_BillingRoleAssignmentListByEnrollmentAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByEnrollmentAccount.json - // this example is just showing the usage of "BillingRoleAssignments_GetByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByEnrollmentAccount.json + // this example is just showing the usage of "BillingRoleAssignments_ListByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,39 +106,33 @@ public async Task GetIfExists_BillingRoleAssignmentGetByEnrollmentAccount() // this example assumes you already have this BillingEnrollmentAccountResource created on azure // for more information of creating BillingEnrollmentAccountResource, please refer to the document of BillingEnrollmentAccountResource - string billingAccountName = "7898901"; - string enrollmentAccountName = "225314"; + string billingAccountName = "6100092"; + string enrollmentAccountName = "123456"; ResourceIdentifier billingEnrollmentAccountResourceId = BillingEnrollmentAccountResource.CreateResourceIdentifier(billingAccountName, enrollmentAccountName); BillingEnrollmentAccountResource billingEnrollmentAccount = client.GetBillingEnrollmentAccountResource(billingEnrollmentAccountResourceId); // get the collection of this BillingEnrollmentAccountRoleAssignmentResource BillingEnrollmentAccountRoleAssignmentCollection collection = billingEnrollmentAccount.GetBillingEnrollmentAccountRoleAssignments(); - // invoke the operation - string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; - NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); - BillingEnrollmentAccountRoleAssignmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (BillingEnrollmentAccountRoleAssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; + BillingRoleAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByEnrollmentAccount() + public async Task Exists_BillingRoleAssignmentGetByEnrollmentAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateOrUpdateByEnrollmentAccount.json - // this example is just showing the usage of "BillingRoleAssignments_CreateOrUpdateByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByEnrollmentAccount.json + // this example is just showing the usage of "BillingRoleAssignments_GetByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,7 +142,7 @@ public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByEnrollment // this example assumes you already have this BillingEnrollmentAccountResource created on azure // for more information of creating BillingEnrollmentAccountResource, please refer to the document of BillingEnrollmentAccountResource string billingAccountName = "7898901"; - string enrollmentAccountName = "123456"; + string enrollmentAccountName = "225314"; ResourceIdentifier billingEnrollmentAccountResourceId = BillingEnrollmentAccountResource.CreateResourceIdentifier(billingAccountName, enrollmentAccountName); BillingEnrollmentAccountResource billingEnrollmentAccount = client.GetBillingEnrollmentAccountResource(billingEnrollmentAccountResourceId); @@ -143,31 +151,17 @@ public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByEnrollment // invoke the operation string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; - BillingRoleAssignmentData data = new BillingRoleAssignmentData() - { - Properties = new BillingRoleAssignmentProperties(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/123456/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db")) - { - PrincipalId = "00000000-0000-0000-0000-000000000000", - PrincipalTenantId = Guid.Parse("076915e7-de10-4323-bb34-a58c904068bb"), - UserEmailAddress = "john@contoso.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, billingRoleAssignmentName, data); - BillingEnrollmentAccountRoleAssignmentResource result = lro.Value; + bool result = await collection.ExistsAsync(billingRoleAssignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleAssignmentListByEnrollmentAccount() + public async Task GetIfExists_BillingRoleAssignmentGetByEnrollmentAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByEnrollmentAccount.json - // this example is just showing the usage of "BillingRoleAssignments_ListByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByEnrollmentAccount.json + // this example is just showing the usage of "BillingRoleAssignments_GetByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,25 +170,31 @@ public async Task GetAll_BillingRoleAssignmentListByEnrollmentAccount() // this example assumes you already have this BillingEnrollmentAccountResource created on azure // for more information of creating BillingEnrollmentAccountResource, please refer to the document of BillingEnrollmentAccountResource - string billingAccountName = "6100092"; - string enrollmentAccountName = "123456"; + string billingAccountName = "7898901"; + string enrollmentAccountName = "225314"; ResourceIdentifier billingEnrollmentAccountResourceId = BillingEnrollmentAccountResource.CreateResourceIdentifier(billingAccountName, enrollmentAccountName); BillingEnrollmentAccountResource billingEnrollmentAccount = client.GetBillingEnrollmentAccountResource(billingEnrollmentAccountResourceId); // get the collection of this BillingEnrollmentAccountRoleAssignmentResource BillingEnrollmentAccountRoleAssignmentCollection collection = billingEnrollmentAccount.GetBillingEnrollmentAccountRoleAssignments(); - // invoke the operation and iterate over the result - await foreach (BillingEnrollmentAccountRoleAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; + NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); + BillingEnrollmentAccountRoleAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = item.Data; + BillingRoleAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleAssignmentResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleAssignmentResource.cs index 072f2b50abd95..42dbe6c6480a8 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleAssignmentResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingEnrollmentAccountRoleAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BillingRoleAssignmentDeleteByEnrollmentAccount() + public async Task Get_BillingRoleAssignmentGetByEnrollmentAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByEnrollmentAccount.json - // this example is just showing the usage of "BillingRoleAssignments_DeleteByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByEnrollmentAccount.json + // this example is just showing the usage of "BillingRoleAssignments_GetByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,24 +30,28 @@ public async Task Delete_BillingRoleAssignmentDeleteByEnrollmentAccount() // this example assumes you already have this BillingEnrollmentAccountRoleAssignmentResource created on azure // for more information of creating BillingEnrollmentAccountRoleAssignmentResource, please refer to the document of BillingEnrollmentAccountRoleAssignmentResource - string billingAccountName = "8608480"; - string enrollmentAccountName = "123456"; + string billingAccountName = "7898901"; + string enrollmentAccountName = "225314"; string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; ResourceIdentifier billingEnrollmentAccountRoleAssignmentResourceId = BillingEnrollmentAccountRoleAssignmentResource.CreateResourceIdentifier(billingAccountName, enrollmentAccountName, billingRoleAssignmentName); BillingEnrollmentAccountRoleAssignmentResource billingEnrollmentAccountRoleAssignment = client.GetBillingEnrollmentAccountRoleAssignmentResource(billingEnrollmentAccountRoleAssignmentResourceId); // invoke the operation - await billingEnrollmentAccountRoleAssignment.DeleteAsync(WaitUntil.Completed); + BillingEnrollmentAccountRoleAssignmentResource result = await billingEnrollmentAccountRoleAssignment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingRoleAssignmentGetByEnrollmentAccount() + public async Task Delete_BillingRoleAssignmentDeleteByEnrollmentAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByEnrollmentAccount.json - // this example is just showing the usage of "BillingRoleAssignments_GetByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByEnrollmentAccount.json + // this example is just showing the usage of "BillingRoleAssignments_DeleteByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -56,20 +60,16 @@ public async Task Get_BillingRoleAssignmentGetByEnrollmentAccount() // this example assumes you already have this BillingEnrollmentAccountRoleAssignmentResource created on azure // for more information of creating BillingEnrollmentAccountRoleAssignmentResource, please refer to the document of BillingEnrollmentAccountRoleAssignmentResource - string billingAccountName = "7898901"; - string enrollmentAccountName = "225314"; + string billingAccountName = "8608480"; + string enrollmentAccountName = "123456"; string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; ResourceIdentifier billingEnrollmentAccountRoleAssignmentResourceId = BillingEnrollmentAccountRoleAssignmentResource.CreateResourceIdentifier(billingAccountName, enrollmentAccountName, billingRoleAssignmentName); BillingEnrollmentAccountRoleAssignmentResource billingEnrollmentAccountRoleAssignment = client.GetBillingEnrollmentAccountRoleAssignmentResource(billingEnrollmentAccountRoleAssignmentResourceId); // invoke the operation - BillingEnrollmentAccountRoleAssignmentResource result = await billingEnrollmentAccountRoleAssignment.GetAsync(); + await billingEnrollmentAccountRoleAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -93,7 +93,7 @@ public async Task Update_BillingRoleAssignmentCreateOrUpdateByEnrollmentAccount( BillingEnrollmentAccountRoleAssignmentResource billingEnrollmentAccountRoleAssignment = client.GetBillingEnrollmentAccountRoleAssignmentResource(billingEnrollmentAccountRoleAssignmentResourceId); // invoke the operation - BillingRoleAssignmentData data = new BillingRoleAssignmentData() + BillingRoleAssignmentData data = new BillingRoleAssignmentData { Properties = new BillingRoleAssignmentProperties(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/7898901/enrollmentAccounts/123456/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db")) { diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleDefinitionCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleDefinitionCollection.cs index 6dea24655cfde..c7e27511cf034 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleDefinitionCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingEnrollmentAccountRoleDefinitionCollection.cs @@ -50,10 +50,10 @@ public async Task Get_BillingRoleDefinitionGetByEnrollmentAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleDefinitionGetByEnrollmentAccount() + public async Task GetAll_BillingRoleDefinitionListByEnrollmentAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByEnrollmentAccount.json - // this example is just showing the usage of "BillingRoleDefinition_GetByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByEnrollmentAccount.json + // this example is just showing the usage of "BillingRoleDefinition_ListByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,16 +70,22 @@ public async Task Exists_BillingRoleDefinitionGetByEnrollmentAccount() // get the collection of this BillingEnrollmentAccountRoleDefinitionResource BillingEnrollmentAccountRoleDefinitionCollection collection = billingEnrollmentAccount.GetBillingEnrollmentAccountRoleDefinitions(); - // invoke the operation - string roleDefinitionName = "50000000-aaaa-bbbb-cccc-100000000000"; - bool result = await collection.ExistsAsync(roleDefinitionName); + // invoke the operation and iterate over the result + await foreach (BillingEnrollmentAccountRoleDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleDefinitionGetByEnrollmentAccount() + public async Task Exists_BillingRoleDefinitionGetByEnrollmentAccount() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByEnrollmentAccount.json // this example is just showing the usage of "BillingRoleDefinition_GetByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. @@ -101,29 +107,17 @@ public async Task GetIfExists_BillingRoleDefinitionGetByEnrollmentAccount() // invoke the operation string roleDefinitionName = "50000000-aaaa-bbbb-cccc-100000000000"; - NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); - BillingEnrollmentAccountRoleDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(roleDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleDefinitionListByEnrollmentAccount() + public async Task GetIfExists_BillingRoleDefinitionGetByEnrollmentAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByEnrollmentAccount.json - // this example is just showing the usage of "BillingRoleDefinition_ListByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByEnrollmentAccount.json + // this example is just showing the usage of "BillingRoleDefinition_GetByEnrollmentAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,17 +134,23 @@ public async Task GetAll_BillingRoleDefinitionListByEnrollmentAccount() // get the collection of this BillingEnrollmentAccountRoleDefinitionResource BillingEnrollmentAccountRoleDefinitionCollection collection = billingEnrollmentAccount.GetBillingEnrollmentAccountRoleDefinitions(); - // invoke the operation and iterate over the result - await foreach (BillingEnrollmentAccountRoleDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string roleDefinitionName = "50000000-aaaa-bbbb-cccc-100000000000"; + NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); + BillingEnrollmentAccountRoleDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = item.Data; + BillingRoleDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceCollection.cs index 51442708c1e35..30c8066673385 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceCollection.cs @@ -50,10 +50,10 @@ public async Task Get_InvoicesGetByBillingAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_InvoicesGetByBillingAccount() + public async Task GetAll_InvoicesListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesGetByBillingAccount.json - // this example is just showing the usage of "Invoices_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesListByBillingAccount.json + // this example is just showing the usage of "Invoices_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +69,23 @@ public async Task Exists_InvoicesGetByBillingAccount() // get the collection of this BillingInvoiceResource BillingInvoiceCollection collection = billingAccount.GetBillingInvoices(); - // invoke the operation - string invoiceName = "G123456789"; - bool result = await collection.ExistsAsync(invoiceName); + // invoke the operation and iterate over the result + BillingInvoiceCollectionGetAllOptions options = new BillingInvoiceCollectionGetAllOptions { PeriodStartDate = DateTimeOffset.Parse("2023-01-01"), PeriodEndDate = DateTimeOffset.Parse("2023-06-30") }; + await foreach (BillingInvoiceResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingInvoiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_InvoicesGetByBillingAccount() + public async Task Exists_InvoicesGetByBillingAccount() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesGetByBillingAccount.json // this example is just showing the usage of "Invoices_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +106,17 @@ public async Task GetIfExists_InvoicesGetByBillingAccount() // invoke the operation string invoiceName = "G123456789"; - NullableResponse response = await collection.GetIfExistsAsync(invoiceName); - BillingInvoiceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(invoiceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingInvoiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InvoicesListByBillingAccount() + public async Task GetIfExists_InvoicesGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesListByBillingAccount.json - // this example is just showing the usage of "Invoices_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesGetByBillingAccount.json + // this example is just showing the usage of "Invoices_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,18 +132,23 @@ public async Task GetAll_InvoicesListByBillingAccount() // get the collection of this BillingInvoiceResource BillingInvoiceCollection collection = billingAccount.GetBillingInvoices(); - // invoke the operation and iterate over the result - BillingInvoiceCollectionGetAllOptions options = new BillingInvoiceCollectionGetAllOptions() { PeriodStartDate = DateTimeOffset.Parse("2023-01-01"), PeriodEndDate = DateTimeOffset.Parse("2023-06-30") }; - await foreach (BillingInvoiceResource item in collection.GetAllAsync(options)) + // invoke the operation + string invoiceName = "G123456789"; + NullableResponse response = await collection.GetIfExistsAsync(invoiceName); + BillingInvoiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingInvoiceData resourceData = item.Data; + BillingInvoiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceResource.cs index 52ea630383994..53b525751655f 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingInvoiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Amend_InvoicesAmend() + public async Task Get_InvoicesGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesAmend.json - // this example is just showing the usage of "Invoices_Amend" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesGetByBillingAccount.json + // this example is just showing the usage of "Invoices_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,17 +36,21 @@ public async Task Amend_InvoicesAmend() BillingInvoiceResource billingInvoice = client.GetBillingInvoiceResource(billingInvoiceResourceId); // invoke the operation - await billingInvoice.AmendAsync(WaitUntil.Completed); + BillingInvoiceResource result = await billingInvoice.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingInvoiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task DownloadByBillingAccount_InvoicesDownloadByBillingAccount() + public async Task Amend_InvoicesAmend() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadByBillingAccount.json - // this example is just showing the usage of "Invoices_DownloadByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesAmend.json + // this example is just showing the usage of "Invoices_Amend" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,19 +65,17 @@ public async Task DownloadByBillingAccount_InvoicesDownloadByBillingAccount() BillingInvoiceResource billingInvoice = client.GetBillingInvoiceResource(billingInvoiceResourceId); // invoke the operation - string documentName = "12345678"; - ArmOperation lro = await billingInvoice.DownloadByBillingAccountAsync(WaitUntil.Completed, documentName: documentName); - BillingDocumentDownloadResult result = lro.Value; + await billingInvoice.AmendAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task DownloadSummaryByBillingAccount_InvoicesDownloadSummaryByBillingAccount() + public async Task DownloadByBillingAccount_InvoicesDownloadByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadSummaryByBillingAccount.json - // this example is just showing the usage of "Invoices_DownloadSummaryByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadByBillingAccount.json + // this example is just showing the usage of "Invoices_DownloadByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -82,13 +84,14 @@ public async Task DownloadSummaryByBillingAccount_InvoicesDownloadSummaryByBilli // this example assumes you already have this BillingInvoiceResource created on azure // for more information of creating BillingInvoiceResource, please refer to the document of BillingInvoiceResource - string billingAccountName = "123456789"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; string invoiceName = "G123456789"; ResourceIdentifier billingInvoiceResourceId = BillingInvoiceResource.CreateResourceIdentifier(billingAccountName, invoiceName); BillingInvoiceResource billingInvoice = client.GetBillingInvoiceResource(billingInvoiceResourceId); // invoke the operation - ArmOperation lro = await billingInvoice.DownloadSummaryByBillingAccountAsync(WaitUntil.Completed); + string documentName = "12345678"; + ArmOperation lro = await billingInvoice.DownloadByBillingAccountAsync(WaitUntil.Completed, documentName: documentName); BillingDocumentDownloadResult result = lro.Value; Console.WriteLine($"Succeeded: {result}"); @@ -96,10 +99,10 @@ public async Task DownloadSummaryByBillingAccount_InvoicesDownloadSummaryByBilli [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_InvoicesGetByBillingAccount() + public async Task DownloadSummaryByBillingAccount_InvoicesDownloadSummaryByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesGetByBillingAccount.json - // this example is just showing the usage of "Invoices_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadSummaryByBillingAccount.json + // this example is just showing the usage of "Invoices_DownloadSummaryByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,19 +111,16 @@ public async Task Get_InvoicesGetByBillingAccount() // this example assumes you already have this BillingInvoiceResource created on azure // for more information of creating BillingInvoiceResource, please refer to the document of BillingInvoiceResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "123456789"; string invoiceName = "G123456789"; ResourceIdentifier billingInvoiceResourceId = BillingInvoiceResource.CreateResourceIdentifier(billingAccountName, invoiceName); BillingInvoiceResource billingInvoice = client.GetBillingInvoiceResource(billingInvoiceResourceId); // invoke the operation - BillingInvoiceResource result = await billingInvoice.GetAsync(); + ArmOperation lro = await billingInvoice.DownloadSummaryByBillingAccountAsync(WaitUntil.Completed); + BillingDocumentDownloadResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingInvoiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -143,7 +143,7 @@ public async Task GetTransactions_TransactionsListByInvoice() BillingInvoiceResource billingInvoice = client.GetBillingInvoiceResource(billingInvoiceResourceId); // invoke the operation and iterate over the result - BillingInvoiceResourceGetTransactionsOptions options = new BillingInvoiceResourceGetTransactionsOptions() { }; + BillingInvoiceResourceGetTransactionsOptions options = new BillingInvoiceResourceGetTransactionsOptions(); await foreach (BillingTransactionData item in billingInvoice.GetTransactionsAsync(options)) { Console.WriteLine($"Succeeded: {item}"); diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionCollection.cs index 1436b180c824d..bcee138e198d4 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingInvoiceSectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_InvoiceSectionsGet() + public async Task CreateOrUpdate_InvoiceSectionsCreateOrUpdate() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsGet.json - // this example is just showing the usage of "InvoiceSections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsCreateOrUpdate.json + // this example is just showing the usage of "InvoiceSections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,21 @@ public async Task Get_InvoiceSectionsGet() BillingInvoiceSectionCollection collection = billingProfile.GetBillingInvoiceSections(); // invoke the operation - string invoiceSectionName = "yyyy-yyyy-yyy-yyy"; - BillingInvoiceSectionResource result = await collection.GetAsync(invoiceSectionName); + string invoiceSectionName = "invoice-section-1"; + BillingInvoiceSectionData data = new BillingInvoiceSectionData + { + Properties = new BillingInvoiceSectionProperties + { + DisplayName = "Invoice Section 1", + Tags = +{ +["costCategory"] = "Support", +["pcCode"] = "A123456" +}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, invoiceSectionName, data); + BillingInvoiceSectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +64,7 @@ public async Task Get_InvoiceSectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_InvoiceSectionsGet() + public async Task Get_InvoiceSectionsGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsGet.json // this example is just showing the usage of "InvoiceSections_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +86,21 @@ public async Task Exists_InvoiceSectionsGet() // invoke the operation string invoiceSectionName = "yyyy-yyyy-yyy-yyy"; - bool result = await collection.ExistsAsync(invoiceSectionName); + BillingInvoiceSectionResource result = await collection.GetAsync(invoiceSectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingInvoiceSectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_InvoiceSectionsGet() + public async Task GetAll_InvoiceSectionsListByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsGet.json - // this example is just showing the usage of "InvoiceSections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsListByBillingProfile.json + // this example is just showing the usage of "InvoiceSections_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +117,26 @@ public async Task GetIfExists_InvoiceSectionsGet() // get the collection of this BillingInvoiceSectionResource BillingInvoiceSectionCollection collection = billingProfile.GetBillingInvoiceSections(); - // invoke the operation - string invoiceSectionName = "yyyy-yyyy-yyy-yyy"; - NullableResponse response = await collection.GetIfExistsAsync(invoiceSectionName); - BillingInvoiceSectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + BillingInvoiceSectionCollectionGetAllOptions options = new BillingInvoiceSectionCollectionGetAllOptions { IncludeDeleted = true }; + await foreach (BillingInvoiceSectionResource item in collection.GetAllAsync(options)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingInvoiceSectionData resourceData = result.Data; + BillingInvoiceSectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_InvoiceSectionsCreateOrUpdate() + public async Task Exists_InvoiceSectionsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsCreateOrUpdate.json - // this example is just showing the usage of "InvoiceSections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsGet.json + // this example is just showing the usage of "InvoiceSections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,35 +154,18 @@ public async Task CreateOrUpdate_InvoiceSectionsCreateOrUpdate() BillingInvoiceSectionCollection collection = billingProfile.GetBillingInvoiceSections(); // invoke the operation - string invoiceSectionName = "invoice-section-1"; - BillingInvoiceSectionData data = new BillingInvoiceSectionData() - { - Properties = new BillingInvoiceSectionProperties() - { - DisplayName = "Invoice Section 1", - Tags = -{ -["costCategory"] = "Support", -["pcCode"] = "A123456", -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, invoiceSectionName, data); - BillingInvoiceSectionResource result = lro.Value; + string invoiceSectionName = "yyyy-yyyy-yyy-yyy"; + bool result = await collection.ExistsAsync(invoiceSectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingInvoiceSectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InvoiceSectionsListByBillingProfile() + public async Task GetIfExists_InvoiceSectionsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsListByBillingProfile.json - // this example is just showing the usage of "InvoiceSections_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsGet.json + // this example is just showing the usage of "InvoiceSections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +182,23 @@ public async Task GetAll_InvoiceSectionsListByBillingProfile() // get the collection of this BillingInvoiceSectionResource BillingInvoiceSectionCollection collection = billingProfile.GetBillingInvoiceSections(); - // invoke the operation and iterate over the result - BillingInvoiceSectionCollectionGetAllOptions options = new BillingInvoiceSectionCollectionGetAllOptions() { IncludeDeleted = true }; - await foreach (BillingInvoiceSectionResource item in collection.GetAllAsync(options)) + // invoke the operation + string invoiceSectionName = "yyyy-yyyy-yyy-yyy"; + NullableResponse response = await collection.GetIfExistsAsync(invoiceSectionName); + BillingInvoiceSectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingInvoiceSectionData resourceData = item.Data; + BillingInvoiceSectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionResource.cs index 1d501c17a94d3..5e6d298615c23 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionResource.cs @@ -16,6 +16,105 @@ namespace Azure.ResourceManager.Billing.Samples { public partial class Sample_BillingInvoiceSectionResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_InvoiceSectionsGet() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsGet.json + // this example is just showing the usage of "InvoiceSections_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BillingInvoiceSectionResource created on azure + // for more information of creating BillingInvoiceSectionResource, please refer to the document of BillingInvoiceSectionResource + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingProfileName = "xxxx-xxxx-xxx-xxx"; + string invoiceSectionName = "yyyy-yyyy-yyy-yyy"; + ResourceIdentifier billingInvoiceSectionResourceId = BillingInvoiceSectionResource.CreateResourceIdentifier(billingAccountName, billingProfileName, invoiceSectionName); + BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); + + // invoke the operation + BillingInvoiceSectionResource result = await billingInvoiceSection.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingInvoiceSectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_InvoiceSectionsDelete() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsDelete.json + // this example is just showing the usage of "InvoiceSections_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BillingInvoiceSectionResource created on azure + // for more information of creating BillingInvoiceSectionResource, please refer to the document of BillingInvoiceSectionResource + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingProfileName = "xxxx-xxxx-xxx-xxx"; + string invoiceSectionName = "yyyy-yyyy-yyy-yyy"; + ResourceIdentifier billingInvoiceSectionResourceId = BillingInvoiceSectionResource.CreateResourceIdentifier(billingAccountName, billingProfileName, invoiceSectionName); + BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); + + // invoke the operation + await billingInvoiceSection.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_InvoiceSectionsCreateOrUpdate() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsCreateOrUpdate.json + // this example is just showing the usage of "InvoiceSections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BillingInvoiceSectionResource created on azure + // for more information of creating BillingInvoiceSectionResource, please refer to the document of BillingInvoiceSectionResource + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingProfileName = "xxxx-xxxx-xxx-xxx"; + string invoiceSectionName = "invoice-section-1"; + ResourceIdentifier billingInvoiceSectionResourceId = BillingInvoiceSectionResource.CreateResourceIdentifier(billingAccountName, billingProfileName, invoiceSectionName); + BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); + + // invoke the operation + BillingInvoiceSectionData data = new BillingInvoiceSectionData + { + Properties = new BillingInvoiceSectionProperties + { + DisplayName = "Invoice Section 1", + Tags = +{ +["costCategory"] = "Support", +["pcCode"] = "A123456" +}, + }, + }; + ArmOperation lro = await billingInvoiceSection.UpdateAsync(WaitUntil.Completed, data); + BillingInvoiceSectionResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingInvoiceSectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetBillingPermissions_BillingPermissionsListByInvoiceSection() @@ -66,12 +165,9 @@ public async Task CheckAccessBillingPermissions_CheckAccessByInvoiceSection() BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); // invoke the operation and iterate over the result - BillingCheckAccessContent content = new BillingCheckAccessContent() + BillingCheckAccessContent content = new BillingCheckAccessContent { - Actions = -{ -"Microsoft.Billing/billingAccounts/read","Microsoft.Subscription/subscriptions/write" -}, + Actions = { "Microsoft.Billing/billingAccounts/read", "Microsoft.Subscription/subscriptions/write" }, }; await foreach (BillingCheckAccessResult item in billingInvoiceSection.CheckAccessBillingPermissionsAsync(content)) { @@ -102,7 +198,7 @@ public async Task GetBillingRequests_BillingRequestsListByInvoiceSection() BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); // invoke the operation and iterate over the result - BillingInvoiceSectionResourceGetBillingRequestsOptions options = new BillingInvoiceSectionResourceGetBillingRequestsOptions() { }; + BillingInvoiceSectionResourceGetBillingRequestsOptions options = new BillingInvoiceSectionResourceGetBillingRequestsOptions(); await foreach (BillingRequestResource item in billingInvoiceSection.GetBillingRequestsAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well @@ -197,7 +293,7 @@ public async Task GetBillingSubscriptions_BillingSubscriptionsListByInvoiceSecti BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); // invoke the operation and iterate over the result - BillingInvoiceSectionResourceGetBillingSubscriptionsOptions options = new BillingInvoiceSectionResourceGetBillingSubscriptionsOptions() { }; + BillingInvoiceSectionResourceGetBillingSubscriptionsOptions options = new BillingInvoiceSectionResourceGetBillingSubscriptionsOptions(); await foreach (BillingSubscriptionData item in billingInvoiceSection.GetBillingSubscriptionsAsync(options)) { // for demo we just print out the id @@ -259,105 +355,6 @@ public async Task ValidateDeleteEligibility_InvoiceSectionsValidateDeleteEligibi Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_InvoiceSectionsDelete() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsDelete.json - // this example is just showing the usage of "InvoiceSections_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BillingInvoiceSectionResource created on azure - // for more information of creating BillingInvoiceSectionResource, please refer to the document of BillingInvoiceSectionResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - string billingProfileName = "xxxx-xxxx-xxx-xxx"; - string invoiceSectionName = "yyyy-yyyy-yyy-yyy"; - ResourceIdentifier billingInvoiceSectionResourceId = BillingInvoiceSectionResource.CreateResourceIdentifier(billingAccountName, billingProfileName, invoiceSectionName); - BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); - - // invoke the operation - await billingInvoiceSection.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_InvoiceSectionsGet() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsGet.json - // this example is just showing the usage of "InvoiceSections_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BillingInvoiceSectionResource created on azure - // for more information of creating BillingInvoiceSectionResource, please refer to the document of BillingInvoiceSectionResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - string billingProfileName = "xxxx-xxxx-xxx-xxx"; - string invoiceSectionName = "yyyy-yyyy-yyy-yyy"; - ResourceIdentifier billingInvoiceSectionResourceId = BillingInvoiceSectionResource.CreateResourceIdentifier(billingAccountName, billingProfileName, invoiceSectionName); - BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); - - // invoke the operation - BillingInvoiceSectionResource result = await billingInvoiceSection.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingInvoiceSectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_InvoiceSectionsCreateOrUpdate() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoiceSectionsCreateOrUpdate.json - // this example is just showing the usage of "InvoiceSections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BillingInvoiceSectionResource created on azure - // for more information of creating BillingInvoiceSectionResource, please refer to the document of BillingInvoiceSectionResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - string billingProfileName = "xxxx-xxxx-xxx-xxx"; - string invoiceSectionName = "invoice-section-1"; - ResourceIdentifier billingInvoiceSectionResourceId = BillingInvoiceSectionResource.CreateResourceIdentifier(billingAccountName, billingProfileName, invoiceSectionName); - BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); - - // invoke the operation - BillingInvoiceSectionData data = new BillingInvoiceSectionData() - { - Properties = new BillingInvoiceSectionProperties() - { - DisplayName = "Invoice Section 1", - Tags = -{ -["costCategory"] = "Support", -["pcCode"] = "A123456", -}, - }, - }; - ArmOperation lro = await billingInvoiceSection.UpdateAsync(WaitUntil.Completed, data); - BillingInvoiceSectionResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingInvoiceSectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetProducts_ProductsListByInvoiceSection() @@ -379,7 +376,7 @@ public async Task GetProducts_ProductsListByInvoiceSection() BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); // invoke the operation and iterate over the result - BillingInvoiceSectionResourceGetProductsOptions options = new BillingInvoiceSectionResourceGetProductsOptions() { }; + BillingInvoiceSectionResourceGetProductsOptions options = new BillingInvoiceSectionResourceGetProductsOptions(); await foreach (BillingProductResource item in billingInvoiceSection.GetProductsAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well @@ -413,7 +410,10 @@ public async Task GetTransactions_TransactionsListByInvoiceSection() BillingInvoiceSectionResource billingInvoiceSection = client.GetBillingInvoiceSectionResource(billingInvoiceSectionResourceId); // invoke the operation and iterate over the result - BillingInvoiceSectionResourceGetTransactionsOptions options = new BillingInvoiceSectionResourceGetTransactionsOptions(periodStartDate: DateTimeOffset.Parse("2024-04-01"), periodEndDate: DateTimeOffset.Parse("2023-05-30"), type: TransactionType.Billed) { Filter = "properties/date gt '2020-10-01'", Search = "storage" }; + DateTimeOffset periodStartDate = DateTimeOffset.Parse("2024-04-01"); + DateTimeOffset periodEndDate = DateTimeOffset.Parse("2023-05-30"); + TransactionType type = TransactionType.Billed; + BillingInvoiceSectionResourceGetTransactionsOptions options = new BillingInvoiceSectionResourceGetTransactionsOptions(periodStartDate, periodEndDate, type) { Filter = "properties/date gt '2020-10-01'", Search = "storage" }; await foreach (BillingTransactionData item in billingInvoiceSection.GetTransactionsAsync(options)) { Console.WriteLine($"Succeeded: {item}"); diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleAssignmentCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleAssignmentCollection.cs index c72eff1271645..f1ae49626474f 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleAssignmentCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleAssignmentCollection.cs @@ -51,10 +51,10 @@ public async Task Get_BillingRoleAssignmentGetByInvoiceSection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleAssignmentGetByInvoiceSection() + public async Task GetAll_BillingRoleAssignmentListByInvoiceSection() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByInvoiceSection.json - // this example is just showing the usage of "BillingRoleAssignments_GetByInvoiceSection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByInvoiceSection.json + // this example is just showing the usage of "BillingRoleAssignments_ListByInvoiceSection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_BillingRoleAssignmentGetByInvoiceSection() // get the collection of this BillingInvoiceSectionRoleAssignmentResource BillingInvoiceSectionRoleAssignmentCollection collection = billingInvoiceSection.GetBillingInvoiceSectionRoleAssignments(); - // invoke the operation - string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; - bool result = await collection.ExistsAsync(billingRoleAssignmentName); + // invoke the operation and iterate over the result + await foreach (BillingInvoiceSectionRoleAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleAssignmentGetByInvoiceSection() + public async Task Exists_BillingRoleAssignmentGetByInvoiceSection() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByInvoiceSection.json // this example is just showing the usage of "BillingRoleAssignments_GetByInvoiceSection" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_BillingRoleAssignmentGetByInvoiceSection() // invoke the operation string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; - NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); - BillingInvoiceSectionRoleAssignmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(billingRoleAssignmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleAssignmentListByInvoiceSection() + public async Task GetIfExists_BillingRoleAssignmentGetByInvoiceSection() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByInvoiceSection.json - // this example is just showing the usage of "BillingRoleAssignments_ListByInvoiceSection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByInvoiceSection.json + // this example is just showing the usage of "BillingRoleAssignments_GetByInvoiceSection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_BillingRoleAssignmentListByInvoiceSection() // get the collection of this BillingInvoiceSectionRoleAssignmentResource BillingInvoiceSectionRoleAssignmentCollection collection = billingInvoiceSection.GetBillingInvoiceSectionRoleAssignments(); - // invoke the operation and iterate over the result - await foreach (BillingInvoiceSectionRoleAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; + NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); + BillingInvoiceSectionRoleAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = item.Data; + BillingRoleAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleAssignmentResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleAssignmentResource.cs index 2c8f1976e4b8a..0fe6c8bf4646b 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleAssignmentResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleAssignmentResource.cs @@ -17,10 +17,10 @@ public partial class Sample_BillingInvoiceSectionRoleAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BillingRoleAssignmentDeleteByInvoiceSection() + public async Task Get_BillingRoleAssignmentGetByInvoiceSection() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByInvoiceSection.json - // this example is just showing the usage of "BillingRoleAssignments_DeleteByInvoiceSection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByInvoiceSection.json + // this example is just showing the usage of "BillingRoleAssignments_GetByInvoiceSection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task Delete_BillingRoleAssignmentDeleteByInvoiceSection() BillingInvoiceSectionRoleAssignmentResource billingInvoiceSectionRoleAssignment = client.GetBillingInvoiceSectionRoleAssignmentResource(billingInvoiceSectionRoleAssignmentResourceId); // invoke the operation - await billingInvoiceSectionRoleAssignment.DeleteAsync(WaitUntil.Completed); + BillingInvoiceSectionRoleAssignmentResource result = await billingInvoiceSectionRoleAssignment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingRoleAssignmentGetByInvoiceSection() + public async Task Delete_BillingRoleAssignmentDeleteByInvoiceSection() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByInvoiceSection.json - // this example is just showing the usage of "BillingRoleAssignments_GetByInvoiceSection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByInvoiceSection.json + // this example is just showing the usage of "BillingRoleAssignments_DeleteByInvoiceSection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +68,9 @@ public async Task Get_BillingRoleAssignmentGetByInvoiceSection() BillingInvoiceSectionRoleAssignmentResource billingInvoiceSectionRoleAssignment = client.GetBillingInvoiceSectionRoleAssignmentResource(billingInvoiceSectionRoleAssignmentResourceId); // invoke the operation - BillingInvoiceSectionRoleAssignmentResource result = await billingInvoiceSectionRoleAssignment.GetAsync(); + await billingInvoiceSectionRoleAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleDefinitionCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleDefinitionCollection.cs index 72fe4135e99e2..57db71c7351f6 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleDefinitionCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingInvoiceSectionRoleDefinitionCollection.cs @@ -51,10 +51,10 @@ public async Task Get_BillingRoleDefinitionGetByInvoiceSection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleDefinitionGetByInvoiceSection() + public async Task GetAll_BillingRoleDefinitionListByInvoiceSection() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByInvoiceSection.json - // this example is just showing the usage of "BillingRoleDefinition_GetByInvoiceSection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByInvoiceSection.json + // this example is just showing the usage of "BillingRoleDefinition_ListByInvoiceSection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_BillingRoleDefinitionGetByInvoiceSection() // get the collection of this BillingInvoiceSectionRoleDefinitionResource BillingInvoiceSectionRoleDefinitionCollection collection = billingInvoiceSection.GetBillingInvoiceSectionRoleDefinitions(); - // invoke the operation - string roleDefinitionName = "30000000-aaaa-bbbb-cccc-100000000000"; - bool result = await collection.ExistsAsync(roleDefinitionName); + // invoke the operation and iterate over the result + await foreach (BillingInvoiceSectionRoleDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleDefinitionGetByInvoiceSection() + public async Task Exists_BillingRoleDefinitionGetByInvoiceSection() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByInvoiceSection.json // this example is just showing the usage of "BillingRoleDefinition_GetByInvoiceSection" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_BillingRoleDefinitionGetByInvoiceSection() // invoke the operation string roleDefinitionName = "30000000-aaaa-bbbb-cccc-100000000000"; - NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); - BillingInvoiceSectionRoleDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(roleDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleDefinitionListByInvoiceSection() + public async Task GetIfExists_BillingRoleDefinitionGetByInvoiceSection() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByInvoiceSection.json - // this example is just showing the usage of "BillingRoleDefinition_ListByInvoiceSection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByInvoiceSection.json + // this example is just showing the usage of "BillingRoleDefinition_GetByInvoiceSection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_BillingRoleDefinitionListByInvoiceSection() // get the collection of this BillingInvoiceSectionRoleDefinitionResource BillingInvoiceSectionRoleDefinitionCollection collection = billingInvoiceSection.GetBillingInvoiceSectionRoleDefinitions(); - // invoke the operation and iterate over the result - await foreach (BillingInvoiceSectionRoleDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string roleDefinitionName = "30000000-aaaa-bbbb-cccc-100000000000"; + NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); + BillingInvoiceSectionRoleDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = item.Data; + BillingRoleDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodCollection.cs index 5b7f188ce26cb..58b74bd234d64 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Billing.Samples @@ -17,64 +18,60 @@ public partial class Sample_BillingPaymentMethodCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPaymentMethodOwnedByUser() + public async Task Get_GetPaymentMethodOwnedByUser() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsListByUser.json - // this example is just showing the usage of "PaymentMethods_ListByUser" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByUser.json + // this example is just showing the usage of "PaymentMethods_GetByUser" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingPaymentMethodResource BillingPaymentMethodCollection collection = tenantResource.GetBillingPaymentMethods(); - // invoke the operation and iterate over the result - await foreach (BillingPaymentMethodResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingPaymentMethodData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string paymentMethodName = "ABCDABCDABC0"; + BillingPaymentMethodResource result = await collection.GetAsync(paymentMethodName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingPaymentMethodData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPaymentMethodOwnedByUser() + public async Task GetAll_ListPaymentMethodOwnedByUser() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByUser.json - // this example is just showing the usage of "PaymentMethods_GetByUser" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsListByUser.json + // this example is just showing the usage of "PaymentMethods_ListByUser" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingPaymentMethodResource BillingPaymentMethodCollection collection = tenantResource.GetBillingPaymentMethods(); - // invoke the operation - string paymentMethodName = "ABCDABCDABC0"; - BillingPaymentMethodResource result = await collection.GetAsync(paymentMethodName); + // invoke the operation and iterate over the result + await foreach (BillingPaymentMethodResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingPaymentMethodData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingPaymentMethodData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -89,9 +86,7 @@ public async Task Exists_GetPaymentMethodOwnedByUser() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingPaymentMethodResource BillingPaymentMethodCollection collection = tenantResource.GetBillingPaymentMethods(); @@ -115,9 +110,7 @@ public async Task GetIfExists_GetPaymentMethodOwnedByUser() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingPaymentMethodResource BillingPaymentMethodCollection collection = tenantResource.GetBillingPaymentMethods(); diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodLinkCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodLinkCollection.cs index 3fca22cbf973a..504dc5d30d71e 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodLinkCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodLinkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_BillingPaymentMethodLinkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PaymentMethodsListByBillingProfile() + public async Task Get_PaymentMethodsGetByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsListByBillingProfile.json - // this example is just showing the usage of "PaymentMethods_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByBillingProfile.json + // this example is just showing the usage of "PaymentMethods_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_PaymentMethodsListByBillingProfile() // get the collection of this BillingPaymentMethodLinkResource BillingPaymentMethodLinkCollection collection = billingProfile.GetBillingPaymentMethodLinks(); - // invoke the operation and iterate over the result - await foreach (BillingPaymentMethodLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingPaymentMethodLinkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string paymentMethodName = "ABCDABCDABC0"; + BillingPaymentMethodLinkResource result = await collection.GetAsync(paymentMethodName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingPaymentMethodLinkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PaymentMethodsGetByBillingProfile() + public async Task GetAll_PaymentMethodsListByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByBillingProfile.json - // this example is just showing the usage of "PaymentMethods_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsListByBillingProfile.json + // this example is just showing the usage of "PaymentMethods_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +70,17 @@ public async Task Get_PaymentMethodsGetByBillingProfile() // get the collection of this BillingPaymentMethodLinkResource BillingPaymentMethodLinkCollection collection = billingProfile.GetBillingPaymentMethodLinks(); - // invoke the operation - string paymentMethodName = "ABCDABCDABC0"; - BillingPaymentMethodLinkResource result = await collection.GetAsync(paymentMethodName); + // invoke the operation and iterate over the result + await foreach (BillingPaymentMethodLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingPaymentMethodLinkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingPaymentMethodLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodResource.cs index 95a28886ddb2c..77f93523022a6 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPaymentMethodResource.cs @@ -17,10 +17,10 @@ public partial class Sample_BillingPaymentMethodResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePaymentMethodOwnedByUser() + public async Task Get_GetPaymentMethodOwnedByUser() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsDeleteByUser.json - // this example is just showing the usage of "PaymentMethods_DeleteByUser" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByUser.json + // this example is just showing the usage of "PaymentMethods_GetByUser" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,17 +34,21 @@ public async Task Delete_DeletePaymentMethodOwnedByUser() BillingPaymentMethodResource billingPaymentMethod = client.GetBillingPaymentMethodResource(billingPaymentMethodResourceId); // invoke the operation - await billingPaymentMethod.DeleteAsync(WaitUntil.Completed); + BillingPaymentMethodResource result = await billingPaymentMethod.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingPaymentMethodData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPaymentMethodOwnedByUser() + public async Task Delete_DeletePaymentMethodOwnedByUser() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsGetByUser.json - // this example is just showing the usage of "PaymentMethods_GetByUser" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/paymentMethodsDeleteByUser.json + // this example is just showing the usage of "PaymentMethods_DeleteByUser" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -58,13 +62,9 @@ public async Task Get_GetPaymentMethodOwnedByUser() BillingPaymentMethodResource billingPaymentMethod = client.GetBillingPaymentMethodResource(billingPaymentMethodResourceId); // invoke the operation - BillingPaymentMethodResource result = await billingPaymentMethod.GetAsync(); + await billingPaymentMethod.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingPaymentMethodData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProductCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProductCollection.cs index e160c9bc13b02..70aabf88fc57b 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProductCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProductCollection.cs @@ -50,10 +50,10 @@ public async Task Get_ProductsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProductsGet() + public async Task GetAll_ProductsListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsGet.json - // this example is just showing the usage of "Products_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsListByBillingAccount.json + // this example is just showing the usage of "Products_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +69,23 @@ public async Task Exists_ProductsGet() // get the collection of this BillingProductResource BillingProductCollection collection = billingAccount.GetBillingProducts(); - // invoke the operation - string productName = "11111111-1111-1111-1111-111111111111"; - bool result = await collection.ExistsAsync(productName); + // invoke the operation and iterate over the result + BillingProductCollectionGetAllOptions options = new BillingProductCollectionGetAllOptions(); + await foreach (BillingProductResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingProductData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProductsGet() + public async Task Exists_ProductsGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsGet.json // this example is just showing the usage of "Products_Get" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +106,17 @@ public async Task GetIfExists_ProductsGet() // invoke the operation string productName = "11111111-1111-1111-1111-111111111111"; - NullableResponse response = await collection.GetIfExistsAsync(productName); - BillingProductResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(productName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProductsListByBillingAccount() + public async Task GetIfExists_ProductsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsListByBillingAccount.json - // this example is just showing the usage of "Products_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsGet.json + // this example is just showing the usage of "Products_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,18 +132,23 @@ public async Task GetAll_ProductsListByBillingAccount() // get the collection of this BillingProductResource BillingProductCollection collection = billingAccount.GetBillingProducts(); - // invoke the operation and iterate over the result - BillingProductCollectionGetAllOptions options = new BillingProductCollectionGetAllOptions() { }; - await foreach (BillingProductResource item in collection.GetAllAsync(options)) + // invoke the operation + string productName = "11111111-1111-1111-1111-111111111111"; + NullableResponse response = await collection.GetIfExistsAsync(productName); + BillingProductResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingProductData resourceData = item.Data; + BillingProductData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProductResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProductResource.cs index 601c1becb20df..c57090dca2b67 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProductResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProductResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingProductResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Move_ProductMove() + public async Task Get_ProductsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productMove.json - // this example is just showing the usage of "Products_Move" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsGet.json + // this example is just showing the usage of "Products_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,15 +30,13 @@ public async Task Move_ProductMove() // this example assumes you already have this BillingProductResource created on azure // for more information of creating BillingProductResource, please refer to the document of BillingProductResource - string billingAccountName = "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31"; - string productName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string productName = "11111111-1111-1111-1111-111111111111"; ResourceIdentifier billingProductResourceId = BillingProductResource.CreateResourceIdentifier(billingAccountName, productName); BillingProductResource billingProduct = client.GetBillingProductResource(billingProductResourceId); // invoke the operation - MoveProductContent content = new MoveProductContent(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB")); - ArmOperation lro = await billingProduct.MoveAsync(WaitUntil.Completed, content); - BillingProductResource result = lro.Value; + BillingProductResource result = await billingProduct.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,10 +47,10 @@ public async Task Move_ProductMove() [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateMoveEligibility_ProductValidateMoveFailure() + public async Task Update_ProductsUpdate() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productValidateMoveFailure.json - // this example is just showing the usage of "Products_ValidateMoveEligibility" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsUpdate.json + // this example is just showing the usage of "Products_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,24 +59,34 @@ public async Task ValidateMoveEligibility_ProductValidateMoveFailure() // this example assumes you already have this BillingProductResource created on azure // for more information of creating BillingProductResource, please refer to the document of BillingProductResource - string billingAccountName = "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31"; - string productName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string productName = "11111111-1111-1111-1111-111111111111"; ResourceIdentifier billingProductResourceId = BillingProductResource.CreateResourceIdentifier(billingAccountName, productName); BillingProductResource billingProduct = client.GetBillingProductResource(billingProductResourceId); // invoke the operation - MoveProductContent content = new MoveProductContent(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB")); - MoveProductEligibilityResult result = await billingProduct.ValidateMoveEligibilityAsync(content); + BillingProductPatch patch = new BillingProductPatch + { + Properties = new BillingProductProperties + { + AutoRenew = BillingSubscriptionAutoRenewState.On, + }, + }; + BillingProductResource result = await billingProduct.UpdateAsync(patch); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateMoveEligibility_ProductValidateMoveSuccess() + public async Task Move_ProductMove() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productValidateMoveSuccess.json - // this example is just showing the usage of "Products_ValidateMoveEligibility" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productMove.json + // this example is just showing the usage of "Products_Move" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,17 +102,22 @@ public async Task ValidateMoveEligibility_ProductValidateMoveSuccess() // invoke the operation MoveProductContent content = new MoveProductContent(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB")); - MoveProductEligibilityResult result = await billingProduct.ValidateMoveEligibilityAsync(content); + ArmOperation lro = await billingProduct.MoveAsync(WaitUntil.Completed, content); + BillingProductResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingProductData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ProductsGet() + public async Task ValidateMoveEligibility_ProductValidateMoveFailure() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsGet.json - // this example is just showing the usage of "Products_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productValidateMoveFailure.json + // this example is just showing the usage of "Products_ValidateMoveEligibility" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,27 +126,24 @@ public async Task Get_ProductsGet() // this example assumes you already have this BillingProductResource created on azure // for more information of creating BillingProductResource, please refer to the document of BillingProductResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - string productName = "11111111-1111-1111-1111-111111111111"; + string billingAccountName = "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31"; + string productName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; ResourceIdentifier billingProductResourceId = BillingProductResource.CreateResourceIdentifier(billingAccountName, productName); BillingProductResource billingProduct = client.GetBillingProductResource(billingProductResourceId); // invoke the operation - BillingProductResource result = await billingProduct.GetAsync(); + MoveProductContent content = new MoveProductContent(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB")); + MoveProductEligibilityResult result = await billingProduct.ValidateMoveEligibilityAsync(content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ProductsUpdate() + public async Task ValidateMoveEligibility_ProductValidateMoveSuccess() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productsUpdate.json - // this example is just showing the usage of "Products_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/productValidateMoveSuccess.json + // this example is just showing the usage of "Products_ValidateMoveEligibility" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,26 +152,16 @@ public async Task Update_ProductsUpdate() // this example assumes you already have this BillingProductResource created on azure // for more information of creating BillingProductResource, please refer to the document of BillingProductResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - string productName = "11111111-1111-1111-1111-111111111111"; + string billingAccountName = "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31"; + string productName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; ResourceIdentifier billingProductResourceId = BillingProductResource.CreateResourceIdentifier(billingAccountName, productName); BillingProductResource billingProduct = client.GetBillingProductResource(billingProductResourceId); // invoke the operation - BillingProductPatch patch = new BillingProductPatch() - { - Properties = new BillingProductProperties() - { - AutoRenew = BillingSubscriptionAutoRenewState.On, - }, - }; - BillingProductResource result = await billingProduct.UpdateAsync(patch); + MoveProductContent content = new MoveProductContent(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB")); + MoveProductEligibilityResult result = await billingProduct.ValidateMoveEligibilityAsync(content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingProductData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCollection.cs index 2148ac77ab6ca..ebd4a0753fe0e 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingProfilesGet() + public async Task CreateOrUpdate_BillingProfilesCreateOrUpdate() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesGet.json - // this example is just showing the usage of "BillingProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesCreateOrUpdate.json + // this example is just showing the usage of "BillingProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,7 +39,52 @@ public async Task Get_BillingProfilesGet() // invoke the operation string billingProfileName = "xxxx-xxxx-xxx-xxx"; - BillingProfileResource result = await collection.GetAsync(billingProfileName); + BillingProfileData data = new BillingProfileData + { + Properties = new BillingProfileProperties + { + BillTo = new BillingAddressDetails("Test Address1", "US") + { + AddressLine2 = "Test Address2", + AddressLine3 = "Test Address3", + City = "City", + CompanyName = "Contoso", + Email = "abc@contoso.com", + FirstName = "Test", + LastName = "User", + PhoneNumber = "000-000-0000", + PostalCode = "00000", + Region = "WA", + IsValidAddress = true, + }, + DisplayName = "Billing Profile 1", + EnabledAzurePlans = {new BillingAzurePlan +{ +SkuId = "0001", +}, new BillingAzurePlan +{ +SkuId = "0002", +}}, + IsInvoiceEmailOptIn = true, + PoNumber = "ABC12345", + ShipTo = new BillingAddressDetails("Test Address1", "US") + { + AddressLine2 = "Test Address2", + AddressLine3 = "Test Address3", + City = "City", + CompanyName = "Contoso", + Email = "abc@contoso.com", + FirstName = "Test", + LastName = "User", + PhoneNumber = "000-000-0000", + PostalCode = "00000", + Region = "WA", + IsValidAddress = true, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, billingProfileName, data); + BillingProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,7 +95,7 @@ public async Task Get_BillingProfilesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingProfilesGet() + public async Task Get_BillingProfilesGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesGet.json // this example is just showing the usage of "BillingProfiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -71,17 +116,21 @@ public async Task Exists_BillingProfilesGet() // invoke the operation string billingProfileName = "xxxx-xxxx-xxx-xxx"; - bool result = await collection.ExistsAsync(billingProfileName); + BillingProfileResource result = await collection.GetAsync(billingProfileName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingProfilesGet() + public async Task GetAll_BillingProfilesListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesGet.json - // this example is just showing the usage of "BillingProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesListByBillingAccount.json + // this example is just showing the usage of "BillingProfiles_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,31 +146,26 @@ public async Task GetIfExists_BillingProfilesGet() // get the collection of this BillingProfileResource BillingProfileCollection collection = billingAccount.GetBillingProfiles(); - // invoke the operation - string billingProfileName = "xxxx-xxxx-xxx-xxx"; - NullableResponse response = await collection.GetIfExistsAsync(billingProfileName); - BillingProfileResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + BillingProfileCollectionGetAllOptions options = new BillingProfileCollectionGetAllOptions(); + await foreach (BillingProfileResource item in collection.GetAllAsync(options)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingProfileData resourceData = result.Data; + BillingProfileData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BillingProfilesCreateOrUpdate() + public async Task Exists_BillingProfilesGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesCreateOrUpdate.json - // this example is just showing the usage of "BillingProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesGet.json + // this example is just showing the usage of "BillingProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,69 +183,17 @@ public async Task CreateOrUpdate_BillingProfilesCreateOrUpdate() // invoke the operation string billingProfileName = "xxxx-xxxx-xxx-xxx"; - BillingProfileData data = new BillingProfileData() - { - Properties = new BillingProfileProperties() - { - BillTo = new BillingAddressDetails("Test Address1", "US") - { - AddressLine2 = "Test Address2", - AddressLine3 = "Test Address3", - City = "City", - CompanyName = "Contoso", - Email = "abc@contoso.com", - FirstName = "Test", - LastName = "User", - PhoneNumber = "000-000-0000", - PostalCode = "00000", - Region = "WA", - IsValidAddress = true, - }, - DisplayName = "Billing Profile 1", - EnabledAzurePlans = -{ -new BillingAzurePlan() -{ -SkuId = "0001", -},new BillingAzurePlan() -{ -SkuId = "0002", -} -}, - IsInvoiceEmailOptIn = true, - PoNumber = "ABC12345", - ShipTo = new BillingAddressDetails("Test Address1", "US") - { - AddressLine2 = "Test Address2", - AddressLine3 = "Test Address3", - City = "City", - CompanyName = "Contoso", - Email = "abc@contoso.com", - FirstName = "Test", - LastName = "User", - PhoneNumber = "000-000-0000", - PostalCode = "00000", - Region = "WA", - IsValidAddress = true, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, billingProfileName, data); - BillingProfileResource result = lro.Value; + bool result = await collection.ExistsAsync(billingProfileName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingProfilesListByBillingAccount() + public async Task GetIfExists_BillingProfilesGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesListByBillingAccount.json - // this example is just showing the usage of "BillingProfiles_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesGet.json + // this example is just showing the usage of "BillingProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -217,18 +209,23 @@ public async Task GetAll_BillingProfilesListByBillingAccount() // get the collection of this BillingProfileResource BillingProfileCollection collection = billingAccount.GetBillingProfiles(); - // invoke the operation and iterate over the result - BillingProfileCollectionGetAllOptions options = new BillingProfileCollectionGetAllOptions() { }; - await foreach (BillingProfileResource item in collection.GetAllAsync(options)) + // invoke the operation + string billingProfileName = "xxxx-xxxx-xxx-xxx"; + NullableResponse response = await collection.GetIfExistsAsync(billingProfileName); + BillingProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingProfileData resourceData = item.Data; + BillingProfileData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCustomerCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCustomerCollection.cs index 762b2b44bd5eb..e91605685aea6 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCustomerCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCustomerCollection.cs @@ -51,10 +51,10 @@ public async Task Get_CustomersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CustomersGet() + public async Task GetAll_CustomersListByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGet.json - // this example is just showing the usage of "Customers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersListByBillingProfile.json + // this example is just showing the usage of "Customers_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,16 +71,23 @@ public async Task Exists_CustomersGet() // get the collection of this BillingProfileCustomerResource BillingProfileCustomerCollection collection = billingProfile.GetBillingProfileCustomers(); - // invoke the operation - string customerName = "11111111-1111-1111-1111-111111111111"; - bool result = await collection.ExistsAsync(customerName); + // invoke the operation and iterate over the result + BillingProfileCustomerCollectionGetAllOptions options = new BillingProfileCustomerCollectionGetAllOptions(); + await foreach (BillingProfileCustomerResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingCustomerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CustomersGet() + public async Task Exists_CustomersGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGet.json // this example is just showing the usage of "Customers_Get" operation, for the dependent resources, they will have to be created separately. @@ -102,29 +109,17 @@ public async Task GetIfExists_CustomersGet() // invoke the operation string customerName = "11111111-1111-1111-1111-111111111111"; - NullableResponse response = await collection.GetIfExistsAsync(customerName); - BillingProfileCustomerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(customerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingCustomerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CustomersListByBillingProfile() + public async Task GetIfExists_CustomersGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersListByBillingProfile.json - // this example is just showing the usage of "Customers_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGet.json + // this example is just showing the usage of "Customers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,18 +136,23 @@ public async Task GetAll_CustomersListByBillingProfile() // get the collection of this BillingProfileCustomerResource BillingProfileCustomerCollection collection = billingProfile.GetBillingProfileCustomers(); - // invoke the operation and iterate over the result - BillingProfileCustomerCollectionGetAllOptions options = new BillingProfileCustomerCollectionGetAllOptions() { }; - await foreach (BillingProfileCustomerResource item in collection.GetAllAsync(options)) + // invoke the operation + string customerName = "11111111-1111-1111-1111-111111111111"; + NullableResponse response = await collection.GetIfExistsAsync(customerName); + BillingProfileCustomerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingCustomerData resourceData = item.Data; + BillingCustomerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCustomerResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCustomerResource.cs index e40f57b30d99e..f883f4d638738 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCustomerResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileCustomerResource.cs @@ -16,6 +16,36 @@ namespace Azure.ResourceManager.Billing.Samples { public partial class Sample_BillingProfileCustomerResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_CustomersGet() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGet.json + // this example is just showing the usage of "Customers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BillingProfileCustomerResource created on azure + // for more information of creating BillingProfileCustomerResource, please refer to the document of BillingProfileCustomerResource + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingProfileName = "xxxx-xxxx-xxx-xxx"; + string customerName = "11111111-1111-1111-1111-111111111111"; + ResourceIdentifier billingProfileCustomerResourceId = BillingProfileCustomerResource.CreateResourceIdentifier(billingAccountName, billingProfileName, customerName); + BillingProfileCustomerResource billingProfileCustomer = client.GetBillingProfileCustomerResource(billingProfileCustomerResourceId); + + // invoke the operation + BillingProfileCustomerResource result = await billingProfileCustomer.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingCustomerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetBillingPermissions_BillingPermissionsListByCustomer() @@ -66,12 +96,9 @@ public async Task CheckAccessBillingPermissions_CheckAccessByCustomer() BillingProfileCustomerResource billingProfileCustomer = client.GetBillingProfileCustomerResource(billingProfileCustomerResourceId); // invoke the operation and iterate over the result - BillingCheckAccessContent content = new BillingCheckAccessContent() + BillingCheckAccessContent content = new BillingCheckAccessContent { - Actions = -{ -"Microsoft.Billing/billingAccounts/read","Microsoft.Subscription/subscriptions/write" -}, + Actions = { "Microsoft.Billing/billingAccounts/read", "Microsoft.Subscription/subscriptions/write" }, }; await foreach (BillingCheckAccessResult item in billingProfileCustomer.CheckAccessBillingPermissionsAsync(content)) { @@ -102,7 +129,7 @@ public async Task GetBillingRequests_BillingRequestsListByCustomer() BillingProfileCustomerResource billingProfileCustomer = client.GetBillingProfileCustomerResource(billingProfileCustomerResourceId); // invoke the operation and iterate over the result - BillingProfileCustomerResourceGetBillingRequestsOptions options = new BillingProfileCustomerResourceGetBillingRequestsOptions() { }; + BillingProfileCustomerResourceGetBillingRequestsOptions options = new BillingProfileCustomerResourceGetBillingRequestsOptions(); await foreach (BillingRequestResource item in billingProfileCustomer.GetBillingRequestsAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well @@ -197,7 +224,7 @@ public async Task GetBillingSubscriptions_BillingSubscriptionsListByCustomer() BillingProfileCustomerResource billingProfileCustomer = client.GetBillingProfileCustomerResource(billingProfileCustomerResourceId); // invoke the operation and iterate over the result - BillingProfileCustomerResourceGetBillingSubscriptionsOptions options = new BillingProfileCustomerResourceGetBillingSubscriptionsOptions() { }; + BillingProfileCustomerResourceGetBillingSubscriptionsOptions options = new BillingProfileCustomerResourceGetBillingSubscriptionsOptions(); await foreach (BillingSubscriptionData item in billingProfileCustomer.GetBillingSubscriptionsAsync(options)) { // for demo we just print out the id @@ -207,36 +234,6 @@ public async Task GetBillingSubscriptions_BillingSubscriptionsListByCustomer() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_CustomersGet() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/customersGet.json - // this example is just showing the usage of "Customers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BillingProfileCustomerResource created on azure - // for more information of creating BillingProfileCustomerResource, please refer to the document of BillingProfileCustomerResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - string billingProfileName = "xxxx-xxxx-xxx-xxx"; - string customerName = "11111111-1111-1111-1111-111111111111"; - ResourceIdentifier billingProfileCustomerResourceId = BillingProfileCustomerResource.CreateResourceIdentifier(billingAccountName, billingProfileName, customerName); - BillingProfileCustomerResource billingProfileCustomer = client.GetBillingProfileCustomerResource(billingProfileCustomerResourceId); - - // invoke the operation - BillingProfileCustomerResource result = await billingProfileCustomer.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingCustomerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdateByCustomerPolicy_PoliciesPutByCustomer() @@ -258,7 +255,7 @@ public async Task CreateOrUpdateByCustomerPolicy_PoliciesPutByCustomer() BillingProfileCustomerResource billingProfileCustomer = client.GetBillingProfileCustomerResource(billingProfileCustomerResourceId); // invoke the operation - BillingCustomerPolicyData data = new BillingCustomerPolicyData() + BillingCustomerPolicyData data = new BillingCustomerPolicyData { Properties = new BillingCustomerPolicyProperties(ViewChargesPolicy.Allowed), }; @@ -290,7 +287,10 @@ public async Task GetTransactions_TransactionsListByCustomer() BillingProfileCustomerResource billingProfileCustomer = client.GetBillingProfileCustomerResource(billingProfileCustomerResourceId); // invoke the operation and iterate over the result - BillingProfileCustomerResourceGetTransactionsOptions options = new BillingProfileCustomerResourceGetTransactionsOptions(periodStartDate: DateTimeOffset.Parse("2024-04-01"), periodEndDate: DateTimeOffset.Parse("2023-05-30"), type: TransactionType.Billed) { Filter = "properties/date gt '2020-10-01'", Search = "storage" }; + DateTimeOffset periodStartDate = DateTimeOffset.Parse("2024-04-01"); + DateTimeOffset periodEndDate = DateTimeOffset.Parse("2023-05-30"); + TransactionType type = TransactionType.Billed; + BillingProfileCustomerResourceGetTransactionsOptions options = new BillingProfileCustomerResourceGetTransactionsOptions(periodStartDate, periodEndDate, type) { Filter = "properties/date gt '2020-10-01'", Search = "storage" }; await foreach (BillingTransactionData item in billingProfileCustomer.GetTransactionsAsync(options)) { Console.WriteLine($"Succeeded: {item}"); diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfilePolicyResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfilePolicyResource.cs index 3090b27625b83..8c1aa697e2a22 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfilePolicyResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfilePolicyResource.cs @@ -65,9 +65,9 @@ public async Task CreateOrUpdate_PoliciesPutByBillingProfile() BillingProfilePolicyResource billingProfilePolicy = client.GetBillingProfilePolicyResource(billingProfilePolicyResourceId); // invoke the operation - BillingProfilePolicyData data = new BillingProfilePolicyData() + BillingProfilePolicyData data = new BillingProfilePolicyData { - Properties = new BillingProfilePolicyProperties() + Properties = new BillingProfilePolicyProperties { InvoiceSectionLabelManagement = InvoiceSectionLabelManagementPolicy.Allowed, MarketplacePurchases = MarketplacePurchasesPolicy.AllAllowed, diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileResource.cs index ea1ad5d3842ea..adc981e76257c 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingProfileResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetBillingProfileAvailableBalance_AvailableBalanceGetByBillingProfile() + public async Task Get_BillingProfilesGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/availableBalanceGetByBillingProfile.json - // this example is just showing the usage of "AvailableBalances_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesGet.json + // this example is just showing the usage of "BillingProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,17 +36,21 @@ public async Task GetBillingProfileAvailableBalance_AvailableBalanceGetByBilling BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // invoke the operation - BillingAvailableBalanceData result = await billingProfile.GetBillingProfileAvailableBalanceAsync(); + BillingProfileResource result = await billingProfile.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetBillingPermissions_BillingPermissionsListByBillingProfile() + public async Task Delete_BillingProfilesDelete() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPermissionsListByBillingProfile.json - // this example is just showing the usage of "BillingPermissions_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesDelete.json + // this example is just showing the usage of "BillingProfiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -55,26 +59,23 @@ public async Task GetBillingPermissions_BillingPermissionsListByBillingProfile() // this example assumes you already have this BillingProfileResource created on azure // for more information of creating BillingProfileResource, please refer to the document of BillingProfileResource - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; string billingProfileName = "xxxx-xxxx-xxx-xxx"; ResourceIdentifier billingProfileResourceId = BillingProfileResource.CreateResourceIdentifier(billingAccountName, billingProfileName); BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); - // invoke the operation and iterate over the result - await foreach (BillingPermission item in billingProfile.GetBillingPermissionsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + await billingProfile.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CheckAccessBillingPermissions_CheckAccessByBillingProfile() + public async Task Update_BillingProfilesCreateOrUpdate() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/checkAccessByBillingProfile.json - // this example is just showing the usage of "BillingPermissions_CheckAccessByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesCreateOrUpdate.json + // this example is just showing the usage of "BillingProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -83,33 +84,72 @@ public async Task CheckAccessBillingPermissions_CheckAccessByBillingProfile() // this example assumes you already have this BillingProfileResource created on azure // for more information of creating BillingProfileResource, please refer to the document of BillingProfileResource - string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; string billingProfileName = "xxxx-xxxx-xxx-xxx"; ResourceIdentifier billingProfileResourceId = BillingProfileResource.CreateResourceIdentifier(billingAccountName, billingProfileName); BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); - // invoke the operation and iterate over the result - BillingCheckAccessContent content = new BillingCheckAccessContent() + // invoke the operation + BillingProfileData data = new BillingProfileData { - Actions = + Properties = new BillingProfileProperties + { + BillTo = new BillingAddressDetails("Test Address1", "US") + { + AddressLine2 = "Test Address2", + AddressLine3 = "Test Address3", + City = "City", + CompanyName = "Contoso", + Email = "abc@contoso.com", + FirstName = "Test", + LastName = "User", + PhoneNumber = "000-000-0000", + PostalCode = "00000", + Region = "WA", + IsValidAddress = true, + }, + DisplayName = "Billing Profile 1", + EnabledAzurePlans = {new BillingAzurePlan +{ +SkuId = "0001", +}, new BillingAzurePlan { -"Microsoft.Billing/billingAccounts/read","Microsoft.Subscription/subscriptions/write" -}, +SkuId = "0002", +}}, + IsInvoiceEmailOptIn = true, + PoNumber = "ABC12345", + ShipTo = new BillingAddressDetails("Test Address1", "US") + { + AddressLine2 = "Test Address2", + AddressLine3 = "Test Address3", + City = "City", + CompanyName = "Contoso", + Email = "abc@contoso.com", + FirstName = "Test", + LastName = "User", + PhoneNumber = "000-000-0000", + PostalCode = "00000", + Region = "WA", + IsValidAddress = true, + }, + }, }; - await foreach (BillingCheckAccessResult item in billingProfile.CheckAccessBillingPermissionsAsync(content)) - { - Console.WriteLine($"Succeeded: {item}"); - } + ArmOperation lro = await billingProfile.UpdateAsync(WaitUntil.Completed, data); + BillingProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateDeleteEligibility_BillingProfilesValidateDeleteEligibilityFailure() + public async Task GetBillingProfileAvailableBalance_AvailableBalanceGetByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesValidateDeleteEligibilityFailure.json - // this example is just showing the usage of "BillingProfiles_ValidateDeleteEligibility" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/availableBalanceGetByBillingProfile.json + // this example is just showing the usage of "AvailableBalances_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -124,17 +164,17 @@ public async Task ValidateDeleteEligibility_BillingProfilesValidateDeleteEligibi BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // invoke the operation - DeleteBillingProfileEligibilityResult result = await billingProfile.ValidateDeleteEligibilityAsync(); + BillingAvailableBalanceData result = await billingProfile.GetBillingProfileAvailableBalanceAsync(); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateDeleteEligibility_BillingProfilesValidateDeleteEligibilitySuccess() + public async Task GetBillingPermissions_BillingPermissionsListByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesValidateDeleteEligibilitySuccess.json - // this example is just showing the usage of "BillingProfiles_ValidateDeleteEligibility" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingPermissionsListByBillingProfile.json + // this example is just showing the usage of "BillingPermissions_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,23 +183,26 @@ public async Task ValidateDeleteEligibility_BillingProfilesValidateDeleteEligibi // this example assumes you already have this BillingProfileResource created on azure // for more information of creating BillingProfileResource, please refer to the document of BillingProfileResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; string billingProfileName = "xxxx-xxxx-xxx-xxx"; ResourceIdentifier billingProfileResourceId = BillingProfileResource.CreateResourceIdentifier(billingAccountName, billingProfileName); BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); - // invoke the operation - DeleteBillingProfileEligibilityResult result = await billingProfile.ValidateDeleteEligibilityAsync(); + // invoke the operation and iterate over the result + await foreach (BillingPermission item in billingProfile.GetBillingPermissionsAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BillingProfilesDelete() + public async Task CheckAccessBillingPermissions_CheckAccessByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesDelete.json - // this example is just showing the usage of "BillingProfiles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/checkAccessByBillingProfile.json + // this example is just showing the usage of "BillingPermissions_CheckAccessByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -168,23 +211,30 @@ public async Task Delete_BillingProfilesDelete() // this example assumes you already have this BillingProfileResource created on azure // for more information of creating BillingProfileResource, please refer to the document of BillingProfileResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingAccountName = "10000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; string billingProfileName = "xxxx-xxxx-xxx-xxx"; ResourceIdentifier billingProfileResourceId = BillingProfileResource.CreateResourceIdentifier(billingAccountName, billingProfileName); BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); - // invoke the operation - await billingProfile.DeleteAsync(WaitUntil.Completed); + // invoke the operation and iterate over the result + BillingCheckAccessContent content = new BillingCheckAccessContent + { + Actions = { "Microsoft.Billing/billingAccounts/read", "Microsoft.Subscription/subscriptions/write" }, + }; + await foreach (BillingCheckAccessResult item in billingProfile.CheckAccessBillingPermissionsAsync(content)) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingProfilesGet() + public async Task ValidateDeleteEligibility_BillingProfilesValidateDeleteEligibilityFailure() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesGet.json - // this example is just showing the usage of "BillingProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesValidateDeleteEligibilityFailure.json + // this example is just showing the usage of "BillingProfiles_ValidateDeleteEligibility" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,21 +249,17 @@ public async Task Get_BillingProfilesGet() BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // invoke the operation - BillingProfileResource result = await billingProfile.GetAsync(); + DeleteBillingProfileEligibilityResult result = await billingProfile.ValidateDeleteEligibilityAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BillingProfilesCreateOrUpdate() + public async Task ValidateDeleteEligibility_BillingProfilesValidateDeleteEligibilitySuccess() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesCreateOrUpdate.json - // this example is just showing the usage of "BillingProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingProfilesValidateDeleteEligibilitySuccess.json + // this example is just showing the usage of "BillingProfiles_ValidateDeleteEligibility" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -228,61 +274,9 @@ public async Task Update_BillingProfilesCreateOrUpdate() BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // invoke the operation - BillingProfileData data = new BillingProfileData() - { - Properties = new BillingProfileProperties() - { - BillTo = new BillingAddressDetails("Test Address1", "US") - { - AddressLine2 = "Test Address2", - AddressLine3 = "Test Address3", - City = "City", - CompanyName = "Contoso", - Email = "abc@contoso.com", - FirstName = "Test", - LastName = "User", - PhoneNumber = "000-000-0000", - PostalCode = "00000", - Region = "WA", - IsValidAddress = true, - }, - DisplayName = "Billing Profile 1", - EnabledAzurePlans = -{ -new BillingAzurePlan() -{ -SkuId = "0001", -},new BillingAzurePlan() -{ -SkuId = "0002", -} -}, - IsInvoiceEmailOptIn = true, - PoNumber = "ABC12345", - ShipTo = new BillingAddressDetails("Test Address1", "US") - { - AddressLine2 = "Test Address2", - AddressLine3 = "Test Address3", - City = "City", - CompanyName = "Contoso", - Email = "abc@contoso.com", - FirstName = "Test", - LastName = "User", - PhoneNumber = "000-000-0000", - PostalCode = "00000", - Region = "WA", - IsValidAddress = true, - }, - }, - }; - ArmOperation lro = await billingProfile.UpdateAsync(WaitUntil.Completed, data); - BillingProfileResource result = lro.Value; + DeleteBillingProfileEligibilityResult result = await billingProfile.ValidateDeleteEligibilityAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -305,7 +299,7 @@ public async Task GetBillingRequests_BillingRequestsListByBillingProfile() BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // invoke the operation and iterate over the result - BillingProfileResourceGetBillingRequestsOptions options = new BillingProfileResourceGetBillingRequestsOptions() { }; + BillingProfileResourceGetBillingRequestsOptions options = new BillingProfileResourceGetBillingRequestsOptions(); await foreach (BillingRequestResource item in billingProfile.GetBillingRequestsAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well @@ -397,7 +391,7 @@ public async Task GetInvoices_InvoicesListByBillingProfile() BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // invoke the operation and iterate over the result - BillingProfileResourceGetInvoicesOptions options = new BillingProfileResourceGetInvoicesOptions() { PeriodStartDate = DateTimeOffset.Parse("2023-01-01"), PeriodEndDate = DateTimeOffset.Parse("2023-06-30") }; + BillingProfileResourceGetInvoicesOptions options = new BillingProfileResourceGetInvoicesOptions { PeriodStartDate = DateTimeOffset.Parse("2023-01-01"), PeriodEndDate = DateTimeOffset.Parse("2023-06-30") }; await foreach (BillingInvoiceData item in billingProfile.GetInvoicesAsync(options)) { // for demo we just print out the id @@ -427,7 +421,7 @@ public async Task GetProducts_ProductsListByBillingProfile() BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // invoke the operation and iterate over the result - BillingProfileResourceGetProductsOptions options = new BillingProfileResourceGetProductsOptions() { }; + BillingProfileResourceGetProductsOptions options = new BillingProfileResourceGetProductsOptions(); await foreach (BillingProductResource item in billingProfile.GetProductsAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well @@ -460,7 +454,7 @@ public async Task GetReservations_ReservationsListByBillingProfile() BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // invoke the operation and iterate over the result - BillingProfileResourceGetReservationsOptions options = new BillingProfileResourceGetReservationsOptions() { SelectedState = "Succeeded" }; + BillingProfileResourceGetReservationsOptions options = new BillingProfileResourceGetReservationsOptions { SelectedState = "Succeeded" }; await foreach (BillingReservationResource item in billingProfile.GetReservationsAsync(options)) { // the variable item is a resource, you could call other operations on this instance as well @@ -493,7 +487,10 @@ public async Task GetTransactions_TransactionsListByBillingProfile() BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // invoke the operation and iterate over the result - BillingProfileResourceGetTransactionsOptions options = new BillingProfileResourceGetTransactionsOptions(periodStartDate: DateTimeOffset.Parse("2024-04-01"), periodEndDate: DateTimeOffset.Parse("2023-05-30"), type: TransactionType.Billed) { Filter = "properties/date gt '2020-10-01'", Search = "storage" }; + DateTimeOffset periodStartDate = DateTimeOffset.Parse("2024-04-01"); + DateTimeOffset periodEndDate = DateTimeOffset.Parse("2023-05-30"); + TransactionType type = TransactionType.Billed; + BillingProfileResourceGetTransactionsOptions options = new BillingProfileResourceGetTransactionsOptions(periodStartDate, periodEndDate, type) { Filter = "properties/date gt '2020-10-01'", Search = "storage" }; await foreach (BillingTransactionData item in billingProfile.GetTransactionsAsync(options)) { Console.WriteLine($"Succeeded: {item}"); diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleAssignmentCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleAssignmentCollection.cs index ab2c5b3759f0f..7fa64649376a6 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleAssignmentCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleAssignmentCollection.cs @@ -50,10 +50,10 @@ public async Task Get_BillingRoleAssignmentGetByBillingProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleAssignmentGetByBillingProfile() + public async Task GetAll_BillingRoleAssignmentListByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingProfile.json - // this example is just showing the usage of "BillingRoleAssignments_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByBillingProfile.json + // this example is just showing the usage of "BillingRoleAssignments_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,16 +70,22 @@ public async Task Exists_BillingRoleAssignmentGetByBillingProfile() // get the collection of this BillingProfileRoleAssignmentResource BillingProfileRoleAssignmentCollection collection = billingProfile.GetBillingProfileRoleAssignments(); - // invoke the operation - string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; - bool result = await collection.ExistsAsync(billingRoleAssignmentName); + // invoke the operation and iterate over the result + await foreach (BillingProfileRoleAssignmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleAssignmentGetByBillingProfile() + public async Task Exists_BillingRoleAssignmentGetByBillingProfile() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingProfile.json // this example is just showing the usage of "BillingRoleAssignments_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. @@ -101,29 +107,17 @@ public async Task GetIfExists_BillingRoleAssignmentGetByBillingProfile() // invoke the operation string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; - NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); - BillingProfileRoleAssignmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(billingRoleAssignmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleAssignmentListByBillingProfile() + public async Task GetIfExists_BillingRoleAssignmentGetByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByBillingProfile.json - // this example is just showing the usage of "BillingRoleAssignments_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingProfile.json + // this example is just showing the usage of "BillingRoleAssignments_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,17 +134,23 @@ public async Task GetAll_BillingRoleAssignmentListByBillingProfile() // get the collection of this BillingProfileRoleAssignmentResource BillingProfileRoleAssignmentCollection collection = billingProfile.GetBillingProfileRoleAssignments(); - // invoke the operation and iterate over the result - await foreach (BillingProfileRoleAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; + NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); + BillingProfileRoleAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = item.Data; + BillingRoleAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleAssignmentResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleAssignmentResource.cs index a19776d11b946..ad0223566210f 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleAssignmentResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleAssignmentResource.cs @@ -17,10 +17,10 @@ public partial class Sample_BillingProfileRoleAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BillingRoleAssignmentDeleteByBillingProfile() + public async Task Get_BillingRoleAssignmentGetByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByBillingProfile.json - // this example is just showing the usage of "BillingRoleAssignments_DeleteByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingProfile.json + // this example is just showing the usage of "BillingRoleAssignments_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,23 +30,27 @@ public async Task Delete_BillingRoleAssignmentDeleteByBillingProfile() // this example assumes you already have this BillingProfileRoleAssignmentResource created on azure // for more information of creating BillingProfileRoleAssignmentResource, please refer to the document of BillingProfileRoleAssignmentResource string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"; - string billingProfileName = "BKM6-54VH-BG7-PGB"; + string billingProfileName = "xxxx-xxxx-xxx-xxx"; string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; ResourceIdentifier billingProfileRoleAssignmentResourceId = BillingProfileRoleAssignmentResource.CreateResourceIdentifier(billingAccountName, billingProfileName, billingRoleAssignmentName); BillingProfileRoleAssignmentResource billingProfileRoleAssignment = client.GetBillingProfileRoleAssignmentResource(billingProfileRoleAssignmentResourceId); // invoke the operation - await billingProfileRoleAssignment.DeleteAsync(WaitUntil.Completed); + BillingProfileRoleAssignmentResource result = await billingProfileRoleAssignment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingRoleAssignmentGetByBillingProfile() + public async Task Delete_BillingRoleAssignmentDeleteByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingProfile.json - // this example is just showing the usage of "BillingRoleAssignments_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByBillingProfile.json + // this example is just showing the usage of "BillingRoleAssignments_DeleteByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -56,19 +60,15 @@ public async Task Get_BillingRoleAssignmentGetByBillingProfile() // this example assumes you already have this BillingProfileRoleAssignmentResource created on azure // for more information of creating BillingProfileRoleAssignmentResource, please refer to the document of BillingProfileRoleAssignmentResource string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"; - string billingProfileName = "xxxx-xxxx-xxx-xxx"; + string billingProfileName = "BKM6-54VH-BG7-PGB"; string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; ResourceIdentifier billingProfileRoleAssignmentResourceId = BillingProfileRoleAssignmentResource.CreateResourceIdentifier(billingAccountName, billingProfileName, billingRoleAssignmentName); BillingProfileRoleAssignmentResource billingProfileRoleAssignment = client.GetBillingProfileRoleAssignmentResource(billingProfileRoleAssignmentResourceId); // invoke the operation - BillingProfileRoleAssignmentResource result = await billingProfileRoleAssignment.GetAsync(); + await billingProfileRoleAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleDefinitionCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleDefinitionCollection.cs index dea4c2823fed5..e452df82ce053 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleDefinitionCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileRoleDefinitionCollection.cs @@ -50,10 +50,10 @@ public async Task Get_BillingRoleDefinitionGetByBillingProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleDefinitionGetByBillingProfile() + public async Task GetAll_BillingRoleDefinitionListByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByBillingProfile.json - // this example is just showing the usage of "BillingRoleDefinition_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByBillingProfile.json + // this example is just showing the usage of "BillingRoleDefinition_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,16 +70,22 @@ public async Task Exists_BillingRoleDefinitionGetByBillingProfile() // get the collection of this BillingProfileRoleDefinitionResource BillingProfileRoleDefinitionCollection collection = billingProfile.GetBillingProfileRoleDefinitions(); - // invoke the operation - string roleDefinitionName = "40000000-aaaa-bbbb-cccc-100000000000"; - bool result = await collection.ExistsAsync(roleDefinitionName); + // invoke the operation and iterate over the result + await foreach (BillingProfileRoleDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleDefinitionGetByBillingProfile() + public async Task Exists_BillingRoleDefinitionGetByBillingProfile() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByBillingProfile.json // this example is just showing the usage of "BillingRoleDefinition_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. @@ -101,29 +107,17 @@ public async Task GetIfExists_BillingRoleDefinitionGetByBillingProfile() // invoke the operation string roleDefinitionName = "40000000-aaaa-bbbb-cccc-100000000000"; - NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); - BillingProfileRoleDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(roleDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleDefinitionListByBillingProfile() + public async Task GetIfExists_BillingRoleDefinitionGetByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByBillingProfile.json - // this example is just showing the usage of "BillingRoleDefinition_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByBillingProfile.json + // this example is just showing the usage of "BillingRoleDefinition_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,17 +134,23 @@ public async Task GetAll_BillingRoleDefinitionListByBillingProfile() // get the collection of this BillingProfileRoleDefinitionResource BillingProfileRoleDefinitionCollection collection = billingProfile.GetBillingProfileRoleDefinitions(); - // invoke the operation and iterate over the result - await foreach (BillingProfileRoleDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string roleDefinitionName = "40000000-aaaa-bbbb-cccc-100000000000"; + NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); + BillingProfileRoleDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = item.Data; + BillingRoleDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileSubscriptionCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileSubscriptionCollection.cs index 3558fda6a2d06..63558f5d56774 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileSubscriptionCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingProfileSubscriptionCollection.cs @@ -51,10 +51,10 @@ public async Task Get_BillingSubscriptionGetByBillingProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingSubscriptionGetByBillingProfile() + public async Task GetAll_BillingSubscriptionsListByBillingProfileEA() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionGetByBillingProfile.json - // this example is just showing the usage of "BillingSubscriptions_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByBillingProfileEA.json + // this example is just showing the usage of "BillingSubscriptions_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,19 +71,26 @@ public async Task Exists_BillingSubscriptionGetByBillingProfile() // get the collection of this BillingProfileSubscriptionResource BillingProfileSubscriptionCollection collection = billingProfile.GetBillingProfileSubscriptions(); - // invoke the operation - string billingSubscriptionName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; - bool result = await collection.ExistsAsync(billingSubscriptionName); + // invoke the operation and iterate over the result + BillingProfileSubscriptionCollectionGetAllOptions options = new BillingProfileSubscriptionCollectionGetAllOptions(); + await foreach (BillingProfileSubscriptionResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingSubscriptionGetByBillingProfile() + public async Task GetAll_BillingSubscriptionsListByBillingProfileMCA() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionGetByBillingProfile.json - // this example is just showing the usage of "BillingSubscriptions_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByBillingProfileMCA.json + // this example is just showing the usage of "BillingSubscriptions_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,39 +99,34 @@ public async Task GetIfExists_BillingSubscriptionGetByBillingProfile() // this example assumes you already have this BillingProfileResource created on azure // for more information of creating BillingProfileResource, please refer to the document of BillingProfileResource - string billingAccountName = "pcn.94077792"; - string billingProfileName = "6478903"; + string billingAccountName = "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31"; + string billingProfileName = "ea36e548-1505-41db-bebc-46fff3d37998"; ResourceIdentifier billingProfileResourceId = BillingProfileResource.CreateResourceIdentifier(billingAccountName, billingProfileName); BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // get the collection of this BillingProfileSubscriptionResource BillingProfileSubscriptionCollection collection = billingProfile.GetBillingProfileSubscriptions(); - // invoke the operation - string billingSubscriptionName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; - NullableResponse response = await collection.GetIfExistsAsync(billingSubscriptionName); - BillingProfileSubscriptionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + BillingProfileSubscriptionCollectionGetAllOptions options = new BillingProfileSubscriptionCollectionGetAllOptions(); + await foreach (BillingProfileSubscriptionResource item in collection.GetAllAsync(options)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingSubscriptionData resourceData = result.Data; + BillingSubscriptionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingSubscriptionsListByBillingProfileEA() + public async Task Exists_BillingSubscriptionGetByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByBillingProfileEA.json - // this example is just showing the usage of "BillingSubscriptions_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionGetByBillingProfile.json + // this example is just showing the usage of "BillingSubscriptions_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,26 +143,19 @@ public async Task GetAll_BillingSubscriptionsListByBillingProfileEA() // get the collection of this BillingProfileSubscriptionResource BillingProfileSubscriptionCollection collection = billingProfile.GetBillingProfileSubscriptions(); - // invoke the operation and iterate over the result - BillingProfileSubscriptionCollectionGetAllOptions options = new BillingProfileSubscriptionCollectionGetAllOptions() { }; - await foreach (BillingProfileSubscriptionResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingSubscriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string billingSubscriptionName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; + bool result = await collection.ExistsAsync(billingSubscriptionName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingSubscriptionsListByBillingProfileMCA() + public async Task GetIfExists_BillingSubscriptionGetByBillingProfile() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByBillingProfileMCA.json - // this example is just showing the usage of "BillingSubscriptions_ListByBillingProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionGetByBillingProfile.json + // this example is just showing the usage of "BillingSubscriptions_GetByBillingProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -169,26 +164,31 @@ public async Task GetAll_BillingSubscriptionsListByBillingProfileMCA() // this example assumes you already have this BillingProfileResource created on azure // for more information of creating BillingProfileResource, please refer to the document of BillingProfileResource - string billingAccountName = "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31"; - string billingProfileName = "ea36e548-1505-41db-bebc-46fff3d37998"; + string billingAccountName = "pcn.94077792"; + string billingProfileName = "6478903"; ResourceIdentifier billingProfileResourceId = BillingProfileResource.CreateResourceIdentifier(billingAccountName, billingProfileName); BillingProfileResource billingProfile = client.GetBillingProfileResource(billingProfileResourceId); // get the collection of this BillingProfileSubscriptionResource BillingProfileSubscriptionCollection collection = billingProfile.GetBillingProfileSubscriptions(); - // invoke the operation and iterate over the result - BillingProfileSubscriptionCollectionGetAllOptions options = new BillingProfileSubscriptionCollectionGetAllOptions() { }; - await foreach (BillingProfileSubscriptionResource item in collection.GetAllAsync(options)) + // invoke the operation + string billingSubscriptionName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; + NullableResponse response = await collection.GetIfExistsAsync(billingSubscriptionName); + BillingProfileSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingSubscriptionData resourceData = item.Data; + BillingSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPropertyResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPropertyResource.cs index 068dcc3c52ed8..b010759919baf 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPropertyResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingPropertyResource.cs @@ -119,9 +119,9 @@ public async Task Update_BillingPropertyPatchCostCenter() BillingPropertyResource billingProperty = client.GetBillingPropertyResource(billingPropertyResourceId); // invoke the operation - BillingPropertyData data = new BillingPropertyData() + BillingPropertyData data = new BillingPropertyData { - Properties = new BillingPropertyProperties() + Properties = new BillingPropertyProperties { CostCenter = "1010", }, @@ -154,9 +154,9 @@ public async Task Update_BillingPropertyPatchSubscriptionServiceUsageAddress() BillingPropertyResource billingProperty = client.GetBillingPropertyResource(billingPropertyResourceId); // invoke the operation - BillingPropertyData data = new BillingPropertyData() + BillingPropertyData data = new BillingPropertyData { - Properties = new BillingPropertyProperties() + Properties = new BillingPropertyProperties { SubscriptionServiceUsageAddress = new BillingAddressDetails("Address line 1", "US") { diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRequestCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRequestCollection.cs index e6b1861355e9d..316dc87d39e44 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRequestCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRequestCollection.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Billing.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Billing.Samples @@ -18,26 +19,39 @@ public partial class Sample_BillingRequestCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingRequestsGet() + public async Task CreateOrUpdate_BillingRequestsCreateOrUpdate() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsGet.json - // this example is just showing the usage of "BillingRequests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsCreateOrUpdate.json + // this example is just showing the usage of "BillingRequests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingRequestResource BillingRequestCollection collection = tenantResource.GetBillingRequests(); // invoke the operation string billingRequestName = "00000000-0000-0000-0000-000000000000"; - BillingRequestResource result = await collection.GetAsync(billingRequestName); + BillingRequestData data = new BillingRequestData + { + Properties = new BillingRequestProperties + { + AdditionalInformation = +{ +["RoleId"] = "40000000-aaaa-bbbb-cccc-200000000006" +}, + DecisionReason = "New team member", + RequestScope = "/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx", + Status = BillingRequestStatus.Pending, + RequestType = BillingRequestType.RoleAssignment, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, billingRequestName, data); + BillingRequestResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -48,7 +62,7 @@ public async Task Get_BillingRequestsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRequestsGet() + public async Task Get_BillingRequestsGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsGet.json // this example is just showing the usage of "BillingRequests_Get" operation, for the dependent resources, they will have to be created separately. @@ -58,167 +72,142 @@ public async Task Exists_BillingRequestsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingRequestResource BillingRequestCollection collection = tenantResource.GetBillingRequests(); // invoke the operation string billingRequestName = "00000000-0000-0000-0000-000000000000"; - bool result = await collection.ExistsAsync(billingRequestName); + BillingRequestResource result = await collection.GetAsync(billingRequestName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRequestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRequestsGet() + public async Task GetAll_BillingRequestsListByUser() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsGet.json - // this example is just showing the usage of "BillingRequests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsListByUser.json + // this example is just showing the usage of "BillingRequests_ListByUser" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingRequestResource BillingRequestCollection collection = tenantResource.GetBillingRequests(); - // invoke the operation - string billingRequestName = "00000000-0000-0000-0000-000000000000"; - NullableResponse response = await collection.GetIfExistsAsync(billingRequestName); - BillingRequestResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + BillingRequestCollectionGetAllOptions options = new BillingRequestCollectionGetAllOptions(); + await foreach (BillingRequestResource item in collection.GetAllAsync(options)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRequestData resourceData = result.Data; + BillingRequestData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BillingRequestsCreateOrUpdate() + public async Task GetAll_BillingRequestsListByUserWithFilter() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsCreateOrUpdate.json - // this example is just showing the usage of "BillingRequests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsListByUserWithFilter.json + // this example is just showing the usage of "BillingRequests_ListByUser" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingRequestResource BillingRequestCollection collection = tenantResource.GetBillingRequests(); - // invoke the operation - string billingRequestName = "00000000-0000-0000-0000-000000000000"; - BillingRequestData data = new BillingRequestData() + // invoke the operation and iterate over the result + BillingRequestCollectionGetAllOptions options = new BillingRequestCollectionGetAllOptions { Filter = "properties/status eq 'Approved'" }; + await foreach (BillingRequestResource item in collection.GetAllAsync(options)) { - Properties = new BillingRequestProperties() - { - AdditionalInformation = -{ -["RoleId"] = "40000000-aaaa-bbbb-cccc-200000000006", -}, - DecisionReason = "New team member", - RequestScope = "/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx", - Status = BillingRequestStatus.Pending, - RequestType = BillingRequestType.RoleAssignment, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, billingRequestName, data); - BillingRequestResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRequestData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRequestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRequestsListByUser() + public async Task Exists_BillingRequestsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsListByUser.json - // this example is just showing the usage of "BillingRequests_ListByUser" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsGet.json + // this example is just showing the usage of "BillingRequests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingRequestResource BillingRequestCollection collection = tenantResource.GetBillingRequests(); - // invoke the operation and iterate over the result - BillingRequestCollectionGetAllOptions options = new BillingRequestCollectionGetAllOptions() { }; - await foreach (BillingRequestResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRequestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string billingRequestName = "00000000-0000-0000-0000-000000000000"; + bool result = await collection.ExistsAsync(billingRequestName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRequestsListByUserWithFilter() + public async Task GetIfExists_BillingRequestsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsListByUserWithFilter.json - // this example is just showing the usage of "BillingRequests_ListByUser" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRequestsGet.json + // this example is just showing the usage of "BillingRequests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this BillingRequestResource BillingRequestCollection collection = tenantResource.GetBillingRequests(); - // invoke the operation and iterate over the result - BillingRequestCollectionGetAllOptions options = new BillingRequestCollectionGetAllOptions() { Filter = "properties/status eq 'Approved'" }; - await foreach (BillingRequestResource item in collection.GetAllAsync(options)) + // invoke the operation + string billingRequestName = "00000000-0000-0000-0000-000000000000"; + NullableResponse response = await collection.GetIfExistsAsync(billingRequestName); + BillingRequestResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRequestData resourceData = item.Data; + BillingRequestData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRequestResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRequestResource.cs index 7c5d4ef02552c..b1bc2fd0c6f92 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRequestResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRequestResource.cs @@ -63,13 +63,13 @@ public async Task Update_BillingRequestsCreateOrUpdate() BillingRequestResource billingRequest = client.GetBillingRequestResource(billingRequestResourceId); // invoke the operation - BillingRequestData data = new BillingRequestData() + BillingRequestData data = new BillingRequestData { - Properties = new BillingRequestProperties() + Properties = new BillingRequestProperties { AdditionalInformation = { -["RoleId"] = "40000000-aaaa-bbbb-cccc-200000000006", +["RoleId"] = "40000000-aaaa-bbbb-cccc-200000000006" }, DecisionReason = "New team member", RequestScope = "/providers/Microsoft.Billing/billingAccounts/00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31/billingProfiles/xxxx-xxxx-xxx-xxx", diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationCollection.cs index 5cf734609dcd1..899db912979db 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationCollection.cs @@ -50,9 +50,9 @@ public async Task Get_ReservationGetByBillingAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ReservationGetByBillingAccount() + public async Task Get_ReservationGetByBillingAccountManagementGroup() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccount.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountManagementGroup.json // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -72,16 +72,20 @@ public async Task Exists_ReservationGetByBillingAccount() // invoke the operation string reservationId = "30000000-0000-0000-0000-000000000000"; - bool result = await collection.ExistsAsync(reservationId); + BillingReservationResource result = await collection.GetAsync(reservationId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingReservationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ReservationGetByBillingAccount() + public async Task Get_ReservationGetByBillingAccountSingleResourceGroup() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccount.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleResourceGroup.json // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -101,28 +105,20 @@ public async Task GetIfExists_ReservationGetByBillingAccount() // invoke the operation string reservationId = "30000000-0000-0000-0000-000000000000"; - NullableResponse response = await collection.GetIfExistsAsync(reservationId); - BillingReservationResource result = response.HasValue ? response.Value : null; + BillingReservationResource result = await collection.GetAsync(reservationId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingReservationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingReservationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ReservationGetByBillingAccountManagementGroup() + public async Task Get_ReservationGetByBillingAccountSingleScope() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountManagementGroup.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleScope.json // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -153,10 +149,10 @@ public async Task Get_ReservationGetByBillingAccountManagementGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ReservationGetByBillingAccountManagementGroup() + public async Task GetAll_ReservationsGetFromOrderByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountManagementGroup.json - // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationsGetFromOrderByBillingAccount.json + // this example is just showing the usage of "Reservations_ListByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,18 +169,24 @@ public async Task Exists_ReservationGetByBillingAccountManagementGroup() // get the collection of this BillingReservationResource BillingReservationCollection collection = billingReservationOrder.GetBillingReservations(); - // invoke the operation - string reservationId = "30000000-0000-0000-0000-000000000000"; - bool result = await collection.ExistsAsync(reservationId); + // invoke the operation and iterate over the result + await foreach (BillingReservationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingReservationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ReservationGetByBillingAccountManagementGroup() + public async Task Exists_ReservationGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountManagementGroup.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccount.json // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -204,28 +206,16 @@ public async Task GetIfExists_ReservationGetByBillingAccountManagementGroup() // invoke the operation string reservationId = "30000000-0000-0000-0000-000000000000"; - NullableResponse response = await collection.GetIfExistsAsync(reservationId); - BillingReservationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(reservationId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingReservationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ReservationGetByBillingAccountSingleResourceGroup() + public async Task Exists_ReservationGetByBillingAccountManagementGroup() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleResourceGroup.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountManagementGroup.json // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -245,13 +235,9 @@ public async Task Get_ReservationGetByBillingAccountSingleResourceGroup() // invoke the operation string reservationId = "30000000-0000-0000-0000-000000000000"; - BillingReservationResource result = await collection.GetAsync(reservationId); + bool result = await collection.ExistsAsync(reservationId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingReservationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -285,9 +271,9 @@ public async Task Exists_ReservationGetByBillingAccountSingleResourceGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ReservationGetByBillingAccountSingleResourceGroup() + public async Task Exists_ReservationGetByBillingAccountSingleScope() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleResourceGroup.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleScope.json // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -307,28 +293,16 @@ public async Task GetIfExists_ReservationGetByBillingAccountSingleResourceGroup( // invoke the operation string reservationId = "30000000-0000-0000-0000-000000000000"; - NullableResponse response = await collection.GetIfExistsAsync(reservationId); - BillingReservationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(reservationId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingReservationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ReservationGetByBillingAccountSingleScope() + public async Task GetIfExists_ReservationGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleScope.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccount.json // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -348,20 +322,28 @@ public async Task Get_ReservationGetByBillingAccountSingleScope() // invoke the operation string reservationId = "30000000-0000-0000-0000-000000000000"; - BillingReservationResource result = await collection.GetAsync(reservationId); + NullableResponse response = await collection.GetIfExistsAsync(reservationId); + BillingReservationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingReservationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingReservationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ReservationGetByBillingAccountSingleScope() + public async Task GetIfExists_ReservationGetByBillingAccountManagementGroup() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleScope.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountManagementGroup.json // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -381,16 +363,28 @@ public async Task Exists_ReservationGetByBillingAccountSingleScope() // invoke the operation string reservationId = "30000000-0000-0000-0000-000000000000"; - bool result = await collection.ExistsAsync(reservationId); + NullableResponse response = await collection.GetIfExistsAsync(reservationId); + BillingReservationResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingReservationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ReservationGetByBillingAccountSingleScope() + public async Task GetIfExists_ReservationGetByBillingAccountSingleResourceGroup() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleScope.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleResourceGroup.json // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -429,10 +423,10 @@ public async Task GetIfExists_ReservationGetByBillingAccountSingleScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ReservationsGetFromOrderByBillingAccount() + public async Task GetIfExists_ReservationGetByBillingAccountSingleScope() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationsGetFromOrderByBillingAccount.json - // this example is just showing the usage of "Reservations_ListByReservationOrder" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationGetByBillingAccountSingleScope.json + // this example is just showing the usage of "Reservations_GetByReservationOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -449,17 +443,23 @@ public async Task GetAll_ReservationsGetFromOrderByBillingAccount() // get the collection of this BillingReservationResource BillingReservationCollection collection = billingReservationOrder.GetBillingReservations(); - // invoke the operation and iterate over the result - await foreach (BillingReservationResource item in collection.GetAllAsync()) + // invoke the operation + string reservationId = "30000000-0000-0000-0000-000000000000"; + NullableResponse response = await collection.GetIfExistsAsync(reservationId); + BillingReservationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingReservationData resourceData = item.Data; + BillingReservationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationOrderCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationOrderCollection.cs index 2776bfca9d5fe..6f1752c9d33ab 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationOrderCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationOrderCollection.cs @@ -49,9 +49,9 @@ public async Task Get_ReservationOrderGetByBillingAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ReservationOrderGetByBillingAccount() + public async Task Get_ReservationOrderGetByBillingAccountWithExpandPlanInformation() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrderGetByBillingAccount.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrderGetByBillingAccountWithExpandPlanInformation.json // this example is just showing the usage of "ReservationOrders_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -70,17 +70,21 @@ public async Task Exists_ReservationOrderGetByBillingAccount() // invoke the operation string reservationOrderId = "20000000-0000-0000-0000-000000000000"; - bool result = await collection.ExistsAsync(reservationOrderId); + BillingReservationOrderResource result = await collection.GetAsync(reservationOrderId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingReservationOrderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ReservationOrderGetByBillingAccount() + public async Task GetAll_ReservationOrderListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrderGetByBillingAccount.json - // this example is just showing the usage of "ReservationOrders_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrdersListByBillingAccount.json + // this example is just showing the usage of "ReservationOrders_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,30 +100,24 @@ public async Task GetIfExists_ReservationOrderGetByBillingAccount() // get the collection of this BillingReservationOrderResource BillingReservationOrderCollection collection = billingAccount.GetBillingReservationOrders(); - // invoke the operation - string reservationOrderId = "20000000-0000-0000-0000-000000000000"; - NullableResponse response = await collection.GetIfExistsAsync(reservationOrderId); - BillingReservationOrderResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (BillingReservationOrderResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingReservationOrderData resourceData = result.Data; + BillingReservationOrderData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ReservationOrderGetByBillingAccountWithExpandPlanInformation() + public async Task Exists_ReservationOrderGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrderGetByBillingAccountWithExpandPlanInformation.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrderGetByBillingAccount.json // this example is just showing the usage of "ReservationOrders_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -138,13 +136,9 @@ public async Task Get_ReservationOrderGetByBillingAccountWithExpandPlanInformati // invoke the operation string reservationOrderId = "20000000-0000-0000-0000-000000000000"; - BillingReservationOrderResource result = await collection.GetAsync(reservationOrderId); + bool result = await collection.ExistsAsync(reservationOrderId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingReservationOrderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -177,9 +171,9 @@ public async Task Exists_ReservationOrderGetByBillingAccountWithExpandPlanInform [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ReservationOrderGetByBillingAccountWithExpandPlanInformation() + public async Task GetIfExists_ReservationOrderGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrderGetByBillingAccountWithExpandPlanInformation.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrderGetByBillingAccount.json // this example is just showing the usage of "ReservationOrders_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -217,10 +211,10 @@ public async Task GetIfExists_ReservationOrderGetByBillingAccountWithExpandPlanI [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ReservationOrderListByBillingAccount() + public async Task GetIfExists_ReservationOrderGetByBillingAccountWithExpandPlanInformation() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrdersListByBillingAccount.json - // this example is just showing the usage of "ReservationOrders_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/reservationOrderGetByBillingAccountWithExpandPlanInformation.json + // this example is just showing the usage of "ReservationOrders_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,17 +230,23 @@ public async Task GetAll_ReservationOrderListByBillingAccount() // get the collection of this BillingReservationOrderResource BillingReservationOrderCollection collection = billingAccount.GetBillingReservationOrders(); - // invoke the operation and iterate over the result - await foreach (BillingReservationOrderResource item in collection.GetAllAsync()) + // invoke the operation + string reservationOrderId = "20000000-0000-0000-0000-000000000000"; + NullableResponse response = await collection.GetIfExistsAsync(reservationOrderId); + BillingReservationOrderResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingReservationOrderData resourceData = item.Data; + BillingReservationOrderData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationResource.cs index 62f13280a040b..e8eb6af7c691f 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingReservationResource.cs @@ -157,7 +157,7 @@ public async Task Update_ReservationUpdate() BillingReservationResource billingReservation = client.GetBillingReservationResource(billingReservationResourceId); // invoke the operation - BillingReservationPatch patch = new BillingReservationPatch() + BillingReservationPatch patch = new BillingReservationPatch { DisplayName = "NewName", }; diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleAssignmentCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleAssignmentCollection.cs index cea53d6760dd1..06242b09367b6 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleAssignmentCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleAssignmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingRoleAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingRoleAssignmentGetByBillingAccount() + public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingAccount.json - // this example is just showing the usage of "BillingRoleAssignments_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateOrUpdateByBillingAccount.json + // this example is just showing the usage of "BillingRoleAssignments_CreateOrUpdateByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task Get_BillingRoleAssignmentGetByBillingAccount() // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"; + string billingAccountName = "7898901"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); @@ -38,8 +38,18 @@ public async Task Get_BillingRoleAssignmentGetByBillingAccount() BillingRoleAssignmentCollection collection = billingAccount.GetBillingRoleAssignments(); // invoke the operation - string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; - BillingRoleAssignmentResource result = await collection.GetAsync(billingRoleAssignmentName); + string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; + BillingRoleAssignmentData data = new BillingRoleAssignmentData + { + Properties = new BillingRoleAssignmentProperties(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/7898901/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db")) + { + PrincipalId = "00000000-0000-0000-0000-000000000000", + PrincipalTenantId = Guid.Parse("076915e7-de10-4323-bb34-a58c904068bb"), + UserEmailAddress = "john@contoso.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, billingRoleAssignmentName, data); + BillingRoleAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,7 +60,7 @@ public async Task Get_BillingRoleAssignmentGetByBillingAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleAssignmentGetByBillingAccount() + public async Task Get_BillingRoleAssignmentGetByBillingAccount() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingAccount.json // this example is just showing the usage of "BillingRoleAssignments_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. @@ -71,17 +81,21 @@ public async Task Exists_BillingRoleAssignmentGetByBillingAccount() // invoke the operation string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; - bool result = await collection.ExistsAsync(billingRoleAssignmentName); + BillingRoleAssignmentResource result = await collection.GetAsync(billingRoleAssignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleAssignmentGetByBillingAccount() + public async Task GetAll_BillingRoleAssignmentListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingAccount.json - // this example is just showing the usage of "BillingRoleAssignments_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByBillingAccount.json + // this example is just showing the usage of "BillingRoleAssignments_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,31 +111,25 @@ public async Task GetIfExists_BillingRoleAssignmentGetByBillingAccount() // get the collection of this BillingRoleAssignmentResource BillingRoleAssignmentCollection collection = billingAccount.GetBillingRoleAssignments(); - // invoke the operation - string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; - NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); - BillingRoleAssignmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (BillingRoleAssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; + BillingRoleAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByBillingAccount() + public async Task Exists_BillingRoleAssignmentGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentCreateOrUpdateByBillingAccount.json - // this example is just showing the usage of "BillingRoleAssignments_CreateOrUpdateByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingAccount.json + // this example is just showing the usage of "BillingRoleAssignments_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,7 +138,7 @@ public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByBillingAcc // this example assumes you already have this BillingAccountResource created on azure // for more information of creating BillingAccountResource, please refer to the document of BillingAccountResource - string billingAccountName = "7898901"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2018-09-30"; ResourceIdentifier billingAccountResourceId = BillingAccountResource.CreateResourceIdentifier(billingAccountName); BillingAccountResource billingAccount = client.GetBillingAccountResource(billingAccountResourceId); @@ -138,32 +146,18 @@ public async Task CreateOrUpdate_BillingRoleAssignmentCreateOrUpdateByBillingAcc BillingRoleAssignmentCollection collection = billingAccount.GetBillingRoleAssignments(); // invoke the operation - string billingRoleAssignmentName = "9dfd08c2-62a3-4d47-85bd-1cdba1408402"; - BillingRoleAssignmentData data = new BillingRoleAssignmentData() - { - Properties = new BillingRoleAssignmentProperties(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/7898901/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db")) - { - PrincipalId = "00000000-0000-0000-0000-000000000000", - PrincipalTenantId = Guid.Parse("076915e7-de10-4323-bb34-a58c904068bb"), - UserEmailAddress = "john@contoso.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, billingRoleAssignmentName, data); - BillingRoleAssignmentResource result = lro.Value; + string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; + bool result = await collection.ExistsAsync(billingRoleAssignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleAssignmentListByBillingAccount() + public async Task GetIfExists_BillingRoleAssignmentGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentListByBillingAccount.json - // this example is just showing the usage of "BillingRoleAssignments_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingAccount.json + // this example is just showing the usage of "BillingRoleAssignments_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_BillingRoleAssignmentListByBillingAccount() // get the collection of this BillingRoleAssignmentResource BillingRoleAssignmentCollection collection = billingAccount.GetBillingRoleAssignments(); - // invoke the operation and iterate over the result - await foreach (BillingRoleAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string billingRoleAssignmentName = "10000000-aaaa-bbbb-cccc-100000000000_6fd330f6-7d26-4aff-b9cf-7bd699f965b9"; + NullableResponse response = await collection.GetIfExistsAsync(billingRoleAssignmentName); + BillingRoleAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = item.Data; + BillingRoleAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleAssignmentResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleAssignmentResource.cs index 21cbc1d63236b..2e5b011e89b37 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleAssignmentResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleAssignmentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingRoleAssignmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BillingRoleAssignmentDeleteByBillingAccount() + public async Task Get_BillingRoleAssignmentGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByBillingAccount.json - // this example is just showing the usage of "BillingRoleAssignments_DeleteByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingAccount.json + // this example is just showing the usage of "BillingRoleAssignments_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,17 +36,21 @@ public async Task Delete_BillingRoleAssignmentDeleteByBillingAccount() BillingRoleAssignmentResource billingRoleAssignment = client.GetBillingRoleAssignmentResource(billingRoleAssignmentResourceId); // invoke the operation - await billingRoleAssignment.DeleteAsync(WaitUntil.Completed); + BillingRoleAssignmentResource result = await billingRoleAssignment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingRoleAssignmentGetByBillingAccount() + public async Task Delete_BillingRoleAssignmentDeleteByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentGetByBillingAccount.json - // this example is just showing the usage of "BillingRoleAssignments_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleAssignmentDeleteByBillingAccount.json + // this example is just showing the usage of "BillingRoleAssignments_DeleteByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,13 +65,9 @@ public async Task Get_BillingRoleAssignmentGetByBillingAccount() BillingRoleAssignmentResource billingRoleAssignment = client.GetBillingRoleAssignmentResource(billingRoleAssignmentResourceId); // invoke the operation - BillingRoleAssignmentResource result = await billingRoleAssignment.GetAsync(); + await billingRoleAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -90,7 +90,7 @@ public async Task Update_BillingRoleAssignmentCreateOrUpdateByBillingAccount() BillingRoleAssignmentResource billingRoleAssignment = client.GetBillingRoleAssignmentResource(billingRoleAssignmentResourceId); // invoke the operation - BillingRoleAssignmentData data = new BillingRoleAssignmentData() + BillingRoleAssignmentData data = new BillingRoleAssignmentData { Properties = new BillingRoleAssignmentProperties(new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/7898901/billingRoleDefinitions/9f1983cb-2574-400c-87e9-34cf8e2280db")) { diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleDefinitionCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleDefinitionCollection.cs index 6bd002418c39a..af8dc71cf3246 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleDefinitionCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingRoleDefinitionCollection.cs @@ -49,10 +49,10 @@ public async Task Get_BillingRoleDefinitionGetByBillingAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingRoleDefinitionGetByBillingAccount() + public async Task GetAll_BillingRoleDefinitionListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByBillingAccount.json - // this example is just showing the usage of "BillingRoleDefinition_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByBillingAccount.json + // this example is just showing the usage of "BillingRoleDefinition_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,16 +68,22 @@ public async Task Exists_BillingRoleDefinitionGetByBillingAccount() // get the collection of this BillingRoleDefinitionResource BillingRoleDefinitionCollection collection = billingAccount.GetBillingRoleDefinitions(); - // invoke the operation - string roleDefinitionName = "50000000-aaaa-bbbb-cccc-100000000000"; - bool result = await collection.ExistsAsync(roleDefinitionName); + // invoke the operation and iterate over the result + await foreach (BillingRoleDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingRoleDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingRoleDefinitionGetByBillingAccount() + public async Task Exists_BillingRoleDefinitionGetByBillingAccount() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByBillingAccount.json // this example is just showing the usage of "BillingRoleDefinition_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. @@ -98,29 +104,17 @@ public async Task GetIfExists_BillingRoleDefinitionGetByBillingAccount() // invoke the operation string roleDefinitionName = "50000000-aaaa-bbbb-cccc-100000000000"; - NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); - BillingRoleDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(roleDefinitionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingRoleDefinitionListByBillingAccount() + public async Task GetIfExists_BillingRoleDefinitionGetByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionListByBillingAccount.json - // this example is just showing the usage of "BillingRoleDefinition_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingRoleDefinitionGetByBillingAccount.json + // this example is just showing the usage of "BillingRoleDefinition_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,17 +130,23 @@ public async Task GetAll_BillingRoleDefinitionListByBillingAccount() // get the collection of this BillingRoleDefinitionResource BillingRoleDefinitionCollection collection = billingAccount.GetBillingRoleDefinitions(); - // invoke the operation and iterate over the result - await foreach (BillingRoleDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string roleDefinitionName = "50000000-aaaa-bbbb-cccc-100000000000"; + NullableResponse response = await collection.GetIfExistsAsync(roleDefinitionName); + BillingRoleDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingRoleDefinitionData resourceData = item.Data; + BillingRoleDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSavingsPlanModelCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSavingsPlanModelCollection.cs index a2cb41ed204a8..34b4782c73274 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSavingsPlanModelCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSavingsPlanModelCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_BillingSavingsPlanModelCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SavingsPlansInOrderList() + public async Task Get_SavingsPlanGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlansListBySavingsPlanOrders.json - // this example is just showing the usage of "SavingsPlans_ListBySavingsPlanOrder" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanGetByBillingAccount.json + // this example is just showing the usage of "SavingsPlans_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,24 +37,22 @@ public async Task GetAll_SavingsPlansInOrderList() // get the collection of this BillingSavingsPlanModelResource BillingSavingsPlanModelCollection collection = savingsPlanOrderModel.GetBillingSavingsPlanModels(); - // invoke the operation and iterate over the result - await foreach (BillingSavingsPlanModelResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingSavingsPlanModelData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string savingsPlanId = "30000000-0000-0000-0000-000000000000"; + BillingSavingsPlanModelResource result = await collection.GetAsync(savingsPlanId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingSavingsPlanModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SavingsPlanGet() + public async Task Get_SavingsPlanGetExpandRenewProperties() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanGetByBillingAccount.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanGetExpandRenewPropertiesByBillingAccount.json // this example is just showing the usage of "SavingsPlans_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -85,10 +83,10 @@ public async Task Get_SavingsPlanGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SavingsPlanGet() + public async Task GetAll_SavingsPlansInOrderList() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanGetByBillingAccount.json - // this example is just showing the usage of "SavingsPlans_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlansListBySavingsPlanOrders.json + // this example is just showing the usage of "SavingsPlans_ListBySavingsPlanOrder" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,16 +103,22 @@ public async Task Exists_SavingsPlanGet() // get the collection of this BillingSavingsPlanModelResource BillingSavingsPlanModelCollection collection = savingsPlanOrderModel.GetBillingSavingsPlanModels(); - // invoke the operation - string savingsPlanId = "30000000-0000-0000-0000-000000000000"; - bool result = await collection.ExistsAsync(savingsPlanId); + // invoke the operation and iterate over the result + await foreach (BillingSavingsPlanModelResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingSavingsPlanModelData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SavingsPlanGet() + public async Task Exists_SavingsPlanGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanGetByBillingAccount.json // this example is just showing the usage of "SavingsPlans_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. @@ -136,26 +140,14 @@ public async Task GetIfExists_SavingsPlanGet() // invoke the operation string savingsPlanId = "30000000-0000-0000-0000-000000000000"; - NullableResponse response = await collection.GetIfExistsAsync(savingsPlanId); - BillingSavingsPlanModelResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(savingsPlanId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingSavingsPlanModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SavingsPlanGetExpandRenewProperties() + public async Task Exists_SavingsPlanGetExpandRenewProperties() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanGetExpandRenewPropertiesByBillingAccount.json // this example is just showing the usage of "SavingsPlans_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. @@ -177,20 +169,16 @@ public async Task Get_SavingsPlanGetExpandRenewProperties() // invoke the operation string savingsPlanId = "30000000-0000-0000-0000-000000000000"; - BillingSavingsPlanModelResource result = await collection.GetAsync(savingsPlanId); + bool result = await collection.ExistsAsync(savingsPlanId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingSavingsPlanModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SavingsPlanGetExpandRenewProperties() + public async Task GetIfExists_SavingsPlanGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanGetExpandRenewPropertiesByBillingAccount.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanGetByBillingAccount.json // this example is just showing the usage of "SavingsPlans_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -210,9 +198,21 @@ public async Task Exists_SavingsPlanGetExpandRenewProperties() // invoke the operation string savingsPlanId = "30000000-0000-0000-0000-000000000000"; - bool result = await collection.ExistsAsync(savingsPlanId); + NullableResponse response = await collection.GetIfExistsAsync(savingsPlanId); + BillingSavingsPlanModelResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingSavingsPlanModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSavingsPlanModelResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSavingsPlanModelResource.cs index aaf969a55d6d3..6ef616356d5cf 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSavingsPlanModelResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSavingsPlanModelResource.cs @@ -97,19 +97,19 @@ public async Task Update_SavingsPlanUpdate() BillingSavingsPlanModelResource billingSavingsPlanModel = client.GetBillingSavingsPlanModelResource(billingSavingsPlanModelResourceId); // invoke the operation - BillingSavingsPlanModelPatch patch = new BillingSavingsPlanModelPatch() + BillingSavingsPlanModelPatch patch = new BillingSavingsPlanModelPatch { - Properties = new SavingsPlanUpdateRequestProperties() + Properties = new SavingsPlanUpdateRequestProperties { DisplayName = "sp_newName", AppliedScopeType = BillingAppliedScopeType.ManagementGroup, - AppliedScopeProperties = new BillingAppliedScopeProperties() + AppliedScopeProperties = new BillingAppliedScopeProperties { TenantId = Guid.Parse("80000000-0000-0000-0000-000000000000"), ManagementGroupId = new ResourceIdentifier("/providers/Microsoft.Management/managementGroups/mg1"), }, IsRenewed = true, - RenewPurchaseProperties = new BillingPurchaseProperties() + RenewPurchaseProperties = new BillingPurchaseProperties { SkuName = "Compute_Savings_Plan", DisplayName = "sp_newName_renewed", @@ -117,13 +117,13 @@ public async Task Update_SavingsPlanUpdate() Term = BillingSavingsPlanTerm.P3Y, BillingPlan = BillingPlan.P1M, AppliedScopeType = BillingAppliedScopeType.ManagementGroup, - Commitment = new BillingBenefitCommitment() + Commitment = new BillingBenefitCommitment { Grain = BillingBenefitCommitmentGrain.Hourly, CurrencyCode = "USD", Amount = 0.001, }, - AppliedScopeProperties = new BillingAppliedScopeProperties() + AppliedScopeProperties = new BillingAppliedScopeProperties { TenantId = Guid.Parse("80000000-0000-0000-0000-000000000000"), ManagementGroupId = new ResourceIdentifier("/providers/Microsoft.Management/managementGroups/mg1"), @@ -162,19 +162,16 @@ public async Task ValidateUpdateByBillingAccount_SavingsPlanValidateUpdate() BillingSavingsPlanModelResource billingSavingsPlanModel = client.GetBillingSavingsPlanModelResource(billingSavingsPlanModelResourceId); // invoke the operation - SavingsPlanUpdateValidateContent content = new SavingsPlanUpdateValidateContent() + SavingsPlanUpdateValidateContent content = new SavingsPlanUpdateValidateContent { - Benefits = -{ -new SavingsPlanUpdateRequestProperties() + Benefits = {new SavingsPlanUpdateRequestProperties { AppliedScopeType = BillingAppliedScopeType.Single, -AppliedScopeProperties = new BillingAppliedScopeProperties() +AppliedScopeProperties = new BillingAppliedScopeProperties { SubscriptionId = "/subscriptions/50000000-0000-0000-0000-000000000000", }, -} -}, +}}, }; SavingsPlanValidateResult result = await billingSavingsPlanModel.ValidateUpdateByBillingAccountAsync(content); diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionAliasCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionAliasCollection.cs index 95aebadb11fbe..75995322383a7 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionAliasCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionAliasCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_BillingSubscriptionAliasCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingSubscriptionAliasGet() + public async Task CreateOrUpdate_BillingSubscriptionAliasCreateOrUpdate() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasGet.json - // this example is just showing the usage of "BillingSubscriptionsAliases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasCreateOrUpdate.json + // this example is just showing the usage of "BillingSubscriptionsAliases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,16 @@ public async Task Get_BillingSubscriptionAliasGet() // invoke the operation string aliasName = "c356b7c7-7545-4686-b843-c1a49cf853fc"; - BillingSubscriptionAliasResource result = await collection.GetAsync(aliasName); + BillingSubscriptionAliasData data = new BillingSubscriptionAliasData + { + BillingFrequency = "P1M", + DisplayName = "Subscription 3", + Quantity = 1L, + SkuId = "0001", + TermDuration = XmlConvert.ToTimeSpan("P1M"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, aliasName, data); + BillingSubscriptionAliasResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +60,7 @@ public async Task Get_BillingSubscriptionAliasGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingSubscriptionAliasGet() + public async Task Get_BillingSubscriptionAliasGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasGet.json // this example is just showing the usage of "BillingSubscriptionsAliases_Get" operation, for the dependent resources, they will have to be created separately. @@ -72,17 +81,21 @@ public async Task Exists_BillingSubscriptionAliasGet() // invoke the operation string aliasName = "c356b7c7-7545-4686-b843-c1a49cf853fc"; - bool result = await collection.ExistsAsync(aliasName); + BillingSubscriptionAliasResource result = await collection.GetAsync(aliasName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingSubscriptionAliasData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingSubscriptionAliasGet() + public async Task GetAll_BillingSubscriptionAliasList() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasGet.json - // this example is just showing the usage of "BillingSubscriptionsAliases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasList.json + // this example is just showing the usage of "BillingSubscriptionsAliases_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,31 +111,26 @@ public async Task GetIfExists_BillingSubscriptionAliasGet() // get the collection of this BillingSubscriptionAliasResource BillingSubscriptionAliasCollection collection = billingAccount.GetBillingSubscriptionAliases(); - // invoke the operation - string aliasName = "c356b7c7-7545-4686-b843-c1a49cf853fc"; - NullableResponse response = await collection.GetIfExistsAsync(aliasName); - BillingSubscriptionAliasResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + BillingSubscriptionAliasCollectionGetAllOptions options = new BillingSubscriptionAliasCollectionGetAllOptions(); + await foreach (BillingSubscriptionAliasResource item in collection.GetAllAsync(options)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingSubscriptionAliasData resourceData = result.Data; + BillingSubscriptionAliasData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BillingSubscriptionAliasCreateOrUpdate() + public async Task Exists_BillingSubscriptionAliasGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasCreateOrUpdate.json - // this example is just showing the usage of "BillingSubscriptionsAliases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasGet.json + // this example is just showing the usage of "BillingSubscriptionsAliases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,30 +148,17 @@ public async Task CreateOrUpdate_BillingSubscriptionAliasCreateOrUpdate() // invoke the operation string aliasName = "c356b7c7-7545-4686-b843-c1a49cf853fc"; - BillingSubscriptionAliasData data = new BillingSubscriptionAliasData() - { - BillingFrequency = "P1M", - DisplayName = "Subscription 3", - Quantity = 1L, - SkuId = "0001", - TermDuration = XmlConvert.ToTimeSpan("P1M"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, aliasName, data); - BillingSubscriptionAliasResource result = lro.Value; + bool result = await collection.ExistsAsync(aliasName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingSubscriptionAliasData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingSubscriptionAliasList() + public async Task GetIfExists_BillingSubscriptionAliasGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasList.json - // this example is just showing the usage of "BillingSubscriptionsAliases_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionAliasGet.json + // this example is just showing the usage of "BillingSubscriptionsAliases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,18 +174,23 @@ public async Task GetAll_BillingSubscriptionAliasList() // get the collection of this BillingSubscriptionAliasResource BillingSubscriptionAliasCollection collection = billingAccount.GetBillingSubscriptionAliases(); - // invoke the operation and iterate over the result - BillingSubscriptionAliasCollectionGetAllOptions options = new BillingSubscriptionAliasCollectionGetAllOptions() { }; - await foreach (BillingSubscriptionAliasResource item in collection.GetAllAsync(options)) + // invoke the operation + string aliasName = "c356b7c7-7545-4686-b843-c1a49cf853fc"; + NullableResponse response = await collection.GetIfExistsAsync(aliasName); + BillingSubscriptionAliasResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingSubscriptionAliasData resourceData = item.Data; + BillingSubscriptionAliasData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionAliasResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionAliasResource.cs index aa5536abe9495..9a3b7dae2212e 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionAliasResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionAliasResource.cs @@ -65,7 +65,7 @@ public async Task Update_BillingSubscriptionAliasCreateOrUpdate() BillingSubscriptionAliasResource billingSubscriptionAlias = client.GetBillingSubscriptionAliasResource(billingSubscriptionAliasResourceId); // invoke the operation - BillingSubscriptionAliasData data = new BillingSubscriptionAliasData() + BillingSubscriptionAliasData data = new BillingSubscriptionAliasData { BillingFrequency = "P1M", DisplayName = "Subscription 3", diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionCollection.cs index 4709a6247b806..060ff1c8b3160 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionCollection.cs @@ -50,10 +50,10 @@ public async Task Get_BillingSubscriptionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BillingSubscriptionsGet() + public async Task GetAll_BillingSubscriptionsListByBillingAccount() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsGet.json - // this example is just showing the usage of "BillingSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByBillingAccount.json + // this example is just showing the usage of "BillingSubscriptions_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +69,23 @@ public async Task Exists_BillingSubscriptionsGet() // get the collection of this BillingSubscriptionResource BillingSubscriptionCollection collection = billingAccount.GetBillingSubscriptions(); - // invoke the operation - string billingSubscriptionName = "11111111-1111-1111-1111-111111111111"; - bool result = await collection.ExistsAsync(billingSubscriptionName); + // invoke the operation and iterate over the result + BillingSubscriptionCollectionGetAllOptions options = new BillingSubscriptionCollectionGetAllOptions { IncludeDeleted = false, IncludeTenantSubscriptions = false }; + await foreach (BillingSubscriptionResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BillingSubscriptionsGet() + public async Task Exists_BillingSubscriptionsGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsGet.json // this example is just showing the usage of "BillingSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +106,17 @@ public async Task GetIfExists_BillingSubscriptionsGet() // invoke the operation string billingSubscriptionName = "11111111-1111-1111-1111-111111111111"; - NullableResponse response = await collection.GetIfExistsAsync(billingSubscriptionName); - BillingSubscriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(billingSubscriptionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BillingSubscriptionsListByBillingAccount() + public async Task GetIfExists_BillingSubscriptionsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsListByBillingAccount.json - // this example is just showing the usage of "BillingSubscriptions_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsGet.json + // this example is just showing the usage of "BillingSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,18 +132,23 @@ public async Task GetAll_BillingSubscriptionsListByBillingAccount() // get the collection of this BillingSubscriptionResource BillingSubscriptionCollection collection = billingAccount.GetBillingSubscriptions(); - // invoke the operation and iterate over the result - BillingSubscriptionCollectionGetAllOptions options = new BillingSubscriptionCollectionGetAllOptions() { IncludeDeleted = false, IncludeTenantSubscriptions = false }; - await foreach (BillingSubscriptionResource item in collection.GetAllAsync(options)) + // invoke the operation + string billingSubscriptionName = "11111111-1111-1111-1111-111111111111"; + NullableResponse response = await collection.GetIfExistsAsync(billingSubscriptionName); + BillingSubscriptionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingSubscriptionData resourceData = item.Data; + BillingSubscriptionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionResource.cs index aee9170d40fb5..b45d461b91320 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingSubscriptionResource.cs @@ -19,10 +19,10 @@ public partial class Sample_BillingSubscriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Cancel_BillingSubscriptionsCancel() + public async Task Get_BillingSubscriptionsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsCancel.json - // this example is just showing the usage of "BillingSubscriptions_Cancel" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsGet.json + // this example is just showing the usage of "BillingSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,21 +37,21 @@ public async Task Cancel_BillingSubscriptionsCancel() BillingSubscriptionResource billingSubscription = client.GetBillingSubscriptionResource(billingSubscriptionResourceId); // invoke the operation - CancelSubscriptionContent content = new CancelSubscriptionContent(CustomerSubscriptionCancellationReason.Compromise) - { - CustomerId = new ResourceIdentifier("11111111-1111-1111-1111-111111111111"), - }; - await billingSubscription.CancelAsync(WaitUntil.Completed, content); + BillingSubscriptionResource result = await billingSubscription.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Merge_BillingSubscriptionsMerge() + public async Task Delete_BillingSubscriptionsDelete() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsMerge.json - // this example is just showing the usage of "BillingSubscriptions_Merge" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsDelete.json + // this example is just showing the usage of "BillingSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,27 +66,17 @@ public async Task Merge_BillingSubscriptionsMerge() BillingSubscriptionResource billingSubscription = client.GetBillingSubscriptionResource(billingSubscriptionResourceId); // invoke the operation - BillingSubscriptionMergeContent content = new BillingSubscriptionMergeContent() - { - TargetBillingSubscriptionName = "22222222-2222-2222-2222-222222222222", - Quantity = 1, - }; - ArmOperation lro = await billingSubscription.MergeAsync(WaitUntil.Completed, content); - BillingSubscriptionResource result = lro.Value; + await billingSubscription.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Move_BillingSubscriptionMove() + public async Task Update_BillingSubscriptionsUpdate() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionMove.json - // this example is just showing the usage of "BillingSubscriptions_Move" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsUpdate.json + // this example is just showing the usage of "BillingSubscriptions_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,17 +85,17 @@ public async Task Move_BillingSubscriptionMove() // this example assumes you already have this BillingSubscriptionResource created on azure // for more information of creating BillingSubscriptionResource, please refer to the document of BillingSubscriptionResource - string billingAccountName = "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31"; - string billingSubscriptionName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingSubscriptionName = "11111111-1111-1111-1111-111111111111"; ResourceIdentifier billingSubscriptionResourceId = BillingSubscriptionResource.CreateResourceIdentifier(billingAccountName, billingSubscriptionName); BillingSubscriptionResource billingSubscription = client.GetBillingSubscriptionResource(billingSubscriptionResourceId); // invoke the operation - BillingSubscriptionMoveContent content = new BillingSubscriptionMoveContent() + BillingSubscriptionPatch patch = new BillingSubscriptionPatch { - DestinationInvoiceSectionId = new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + ConsumptionCostCenter = "ABC1234", }; - ArmOperation lro = await billingSubscription.MoveAsync(WaitUntil.Completed, content); + ArmOperation lro = await billingSubscription.UpdateAsync(WaitUntil.Completed, patch); BillingSubscriptionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -117,10 +107,10 @@ public async Task Move_BillingSubscriptionMove() [Test] [Ignore("Only validating compilation of examples")] - public async Task Split_BillingSubscriptionsSplit() + public async Task Cancel_BillingSubscriptionsCancel() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsSplit.json - // this example is just showing the usage of "BillingSubscriptions_Split" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsCancel.json + // this example is just showing the usage of "BillingSubscriptions_Cancel" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -135,30 +125,21 @@ public async Task Split_BillingSubscriptionsSplit() BillingSubscriptionResource billingSubscription = client.GetBillingSubscriptionResource(billingSubscriptionResourceId); // invoke the operation - BillingSubscriptionSplitContent content = new BillingSubscriptionSplitContent() + CancelSubscriptionContent content = new CancelSubscriptionContent(CustomerSubscriptionCancellationReason.Compromise) { - TargetProductTypeId = "XYZ56789", - TargetSkuId = "0001", - Quantity = 1, - TermDuration = XmlConvert.ToTimeSpan("P1M"), - BillingFrequency = "P1M", + CustomerId = new ResourceIdentifier("11111111-1111-1111-1111-111111111111"), }; - ArmOperation lro = await billingSubscription.SplitAsync(WaitUntil.Completed, content); - BillingSubscriptionResource result = lro.Value; + await billingSubscription.CancelAsync(WaitUntil.Completed, content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateMoveEligibility_BillingSubscriptionValidateMoveFailure() + public async Task Merge_BillingSubscriptionsMerge() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionValidateMoveFailure.json - // this example is just showing the usage of "BillingSubscriptions_ValidateMoveEligibility" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsMerge.json + // this example is just showing the usage of "BillingSubscriptions_Merge" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -167,27 +148,33 @@ public async Task ValidateMoveEligibility_BillingSubscriptionValidateMoveFailure // this example assumes you already have this BillingSubscriptionResource created on azure // for more information of creating BillingSubscriptionResource, please refer to the document of BillingSubscriptionResource - string billingAccountName = "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31"; - string billingSubscriptionName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; + string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; + string billingSubscriptionName = "11111111-1111-1111-1111-111111111111"; ResourceIdentifier billingSubscriptionResourceId = BillingSubscriptionResource.CreateResourceIdentifier(billingAccountName, billingSubscriptionName); BillingSubscriptionResource billingSubscription = client.GetBillingSubscriptionResource(billingSubscriptionResourceId); // invoke the operation - BillingSubscriptionMoveContent content = new BillingSubscriptionMoveContent() + BillingSubscriptionMergeContent content = new BillingSubscriptionMergeContent { - DestinationInvoiceSectionId = new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + TargetBillingSubscriptionName = "22222222-2222-2222-2222-222222222222", + Quantity = 1, }; - BillingSubscriptionValidateMoveEligibilityResult result = await billingSubscription.ValidateMoveEligibilityAsync(content); + ArmOperation lro = await billingSubscription.MergeAsync(WaitUntil.Completed, content); + BillingSubscriptionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateMoveEligibility_BillingSubscriptionValidateMoveSuccess() + public async Task Move_BillingSubscriptionMove() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionValidateMoveSuccess.json - // this example is just showing the usage of "BillingSubscriptions_ValidateMoveEligibility" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionMove.json + // this example is just showing the usage of "BillingSubscriptions_Move" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -202,21 +189,26 @@ public async Task ValidateMoveEligibility_BillingSubscriptionValidateMoveSuccess BillingSubscriptionResource billingSubscription = client.GetBillingSubscriptionResource(billingSubscriptionResourceId); // invoke the operation - BillingSubscriptionMoveContent content = new BillingSubscriptionMoveContent() + BillingSubscriptionMoveContent content = new BillingSubscriptionMoveContent { DestinationInvoiceSectionId = new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), }; - BillingSubscriptionValidateMoveEligibilityResult result = await billingSubscription.ValidateMoveEligibilityAsync(content); + ArmOperation lro = await billingSubscription.MoveAsync(WaitUntil.Completed, content); + BillingSubscriptionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BillingSubscriptionsDelete() + public async Task Split_BillingSubscriptionsSplit() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsDelete.json - // this example is just showing the usage of "BillingSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsSplit.json + // this example is just showing the usage of "BillingSubscriptions_Split" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -231,17 +223,30 @@ public async Task Delete_BillingSubscriptionsDelete() BillingSubscriptionResource billingSubscription = client.GetBillingSubscriptionResource(billingSubscriptionResourceId); // invoke the operation - await billingSubscription.DeleteAsync(WaitUntil.Completed); + BillingSubscriptionSplitContent content = new BillingSubscriptionSplitContent + { + TargetProductTypeId = "XYZ56789", + TargetSkuId = "0001", + Quantity = 1, + TermDuration = XmlConvert.ToTimeSpan("P1M"), + BillingFrequency = "P1M", + }; + ArmOperation lro = await billingSubscription.SplitAsync(WaitUntil.Completed, content); + BillingSubscriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_BillingSubscriptionsGet() + public async Task ValidateMoveEligibility_BillingSubscriptionValidateMoveFailure() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsGet.json - // this example is just showing the usage of "BillingSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionValidateMoveFailure.json + // this example is just showing the usage of "BillingSubscriptions_ValidateMoveEligibility" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -250,27 +255,27 @@ public async Task Get_BillingSubscriptionsGet() // this example assumes you already have this BillingSubscriptionResource created on azure // for more information of creating BillingSubscriptionResource, please refer to the document of BillingSubscriptionResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - string billingSubscriptionName = "11111111-1111-1111-1111-111111111111"; + string billingAccountName = "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31"; + string billingSubscriptionName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; ResourceIdentifier billingSubscriptionResourceId = BillingSubscriptionResource.CreateResourceIdentifier(billingAccountName, billingSubscriptionName); BillingSubscriptionResource billingSubscription = client.GetBillingSubscriptionResource(billingSubscriptionResourceId); // invoke the operation - BillingSubscriptionResource result = await billingSubscription.GetAsync(); + BillingSubscriptionMoveContent content = new BillingSubscriptionMoveContent + { + DestinationInvoiceSectionId = new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), + }; + BillingSubscriptionValidateMoveEligibilityResult result = await billingSubscription.ValidateMoveEligibilityAsync(content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BillingSubscriptionsUpdate() + public async Task ValidateMoveEligibility_BillingSubscriptionValidateMoveSuccess() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionsUpdate.json - // this example is just showing the usage of "BillingSubscriptions_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/billingSubscriptionValidateMoveSuccess.json + // this example is just showing the usage of "BillingSubscriptions_ValidateMoveEligibility" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -279,24 +284,19 @@ public async Task Update_BillingSubscriptionsUpdate() // this example assumes you already have this BillingSubscriptionResource created on azure // for more information of creating BillingSubscriptionResource, please refer to the document of BillingSubscriptionResource - string billingAccountName = "00000000-0000-0000-0000-000000000000:00000000-0000-0000-0000-000000000000_2019-05-31"; - string billingSubscriptionName = "11111111-1111-1111-1111-111111111111"; + string billingAccountName = "a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31"; + string billingSubscriptionName = "6b96d3f2-9008-4a9d-912f-f87744185aa3"; ResourceIdentifier billingSubscriptionResourceId = BillingSubscriptionResource.CreateResourceIdentifier(billingAccountName, billingSubscriptionName); BillingSubscriptionResource billingSubscription = client.GetBillingSubscriptionResource(billingSubscriptionResourceId); // invoke the operation - BillingSubscriptionPatch patch = new BillingSubscriptionPatch() + BillingSubscriptionMoveContent content = new BillingSubscriptionMoveContent { - ConsumptionCostCenter = "ABC1234", + DestinationInvoiceSectionId = new ResourceIdentifier("/providers/Microsoft.Billing/billingAccounts/a1a9c77e-4cec-4a6c-a089-867d973a6074:a80d3b1f-c626-4e5e-82ed-1173bd91c838_2019-05-31/billingProfiles/ea36e548-1505-41db-bebc-46fff3d37998/invoiceSections/Q7GV-UUVA-PJA-TGB"), }; - ArmOperation lro = await billingSubscription.UpdateAsync(WaitUntil.Completed, patch); - BillingSubscriptionResource result = lro.Value; + BillingSubscriptionValidateMoveEligibilityResult result = await billingSubscription.ValidateMoveEligibilityAsync(content); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingTransferDetailCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingTransferDetailCollection.cs index 4f5165a22fb7b..4cbe6f927562a 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingTransferDetailCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingTransferDetailCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BillingTransferDetailCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_TransferGet() + public async Task CreateOrUpdate_InitiateTransfer() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersGet.json - // this example is just showing the usage of "Transfers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersInitiate.json + // this example is just showing the usage of "Transfers_Initiate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_TransferGet() // invoke the operation string transferName = "aabb123"; - BillingTransferDetailResource result = await collection.GetAsync(transferName); + BillingTransferDetailCreateOrUpdateContent content = new BillingTransferDetailCreateOrUpdateContent + { + RecipientEmailId = "user@contoso.com", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, transferName, content); + BillingTransferDetailResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_TransferGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TransferGet() + public async Task Get_TransferGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersGet.json // this example is just showing the usage of "Transfers_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_TransferGet() // invoke the operation string transferName = "aabb123"; - bool result = await collection.ExistsAsync(transferName); + BillingTransferDetailResource result = await collection.GetAsync(transferName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingTransferDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TransferGet() + public async Task GetAll_TransfersList() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersGet.json - // this example is just showing the usage of "Transfers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersList.json + // this example is just showing the usage of "Transfers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_TransferGet() // get the collection of this BillingTransferDetailResource BillingTransferDetailCollection collection = billingInvoiceSection.GetBillingTransferDetails(); - // invoke the operation - string transferName = "aabb123"; - NullableResponse response = await collection.GetIfExistsAsync(transferName); - BillingTransferDetailResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (BillingTransferDetailResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingTransferDetailData resourceData = result.Data; + BillingTransferDetailData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_InitiateTransfer() + public async Task Exists_TransferGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersInitiate.json - // this example is just showing the usage of "Transfers_Initiate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersGet.json + // this example is just showing the usage of "Transfers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_InitiateTransfer() // invoke the operation string transferName = "aabb123"; - BillingTransferDetailCreateOrUpdateContent content = new BillingTransferDetailCreateOrUpdateContent() - { - RecipientEmailId = "user@contoso.com", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, transferName, content); - BillingTransferDetailResource result = lro.Value; + bool result = await collection.ExistsAsync(transferName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingTransferDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TransfersList() + public async Task GetIfExists_TransferGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersList.json - // this example is just showing the usage of "Transfers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/transfersGet.json + // this example is just showing the usage of "Transfers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_TransfersList() // get the collection of this BillingTransferDetailResource BillingTransferDetailCollection collection = billingInvoiceSection.GetBillingTransferDetails(); - // invoke the operation and iterate over the result - await foreach (BillingTransferDetailResource item in collection.GetAllAsync()) + // invoke the operation + string transferName = "aabb123"; + NullableResponse response = await collection.GetIfExistsAsync(transferName); + BillingTransferDetailResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BillingTransferDetailData resourceData = item.Data; + BillingTransferDetailData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingTransferDetailResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingTransferDetailResource.cs index a4f1225b7e814..5e345c520484e 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingTransferDetailResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_BillingTransferDetailResource.cs @@ -69,7 +69,7 @@ public async Task Update_InitiateTransfer() BillingTransferDetailResource billingTransferDetail = client.GetBillingTransferDetailResource(billingTransferDetailResourceId); // invoke the operation - BillingTransferDetailCreateOrUpdateContent content = new BillingTransferDetailCreateOrUpdateContent() + BillingTransferDetailCreateOrUpdateContent content = new BillingTransferDetailCreateOrUpdateContent { RecipientEmailId = "user@contoso.com", }; diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_DefaultBillingInvoiceCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_DefaultBillingInvoiceCollection.cs index 9bf7516e1a4cb..9b857a91d794b 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_DefaultBillingInvoiceCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_DefaultBillingInvoiceCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Billing.Samples @@ -27,9 +28,7 @@ public async Task Get_InvoicesGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DefaultBillingInvoiceResource DefaultBillingInvoiceCollection collection = tenantResource.GetDefaultBillingInvoices(); @@ -57,9 +56,7 @@ public async Task Exists_InvoicesGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DefaultBillingInvoiceResource DefaultBillingInvoiceCollection collection = tenantResource.GetDefaultBillingInvoices(); @@ -83,9 +80,7 @@ public async Task GetIfExists_InvoicesGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this DefaultBillingInvoiceResource DefaultBillingInvoiceCollection collection = tenantResource.GetDefaultBillingInvoices(); diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_PartnerTransferDetailCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_PartnerTransferDetailCollection.cs index c0aead6b4cdfe..16937336e7bf4 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_PartnerTransferDetailCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_PartnerTransferDetailCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PartnerTransferDetailCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PartnerTransferGet() + public async Task CreateOrUpdate_InitiatePartnerTransfer() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersGet.json - // this example is just showing the usage of "PartnerTransfers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersInitiate.json + // this example is just showing the usage of "PartnerTransfers_Initiate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_PartnerTransferGet() // invoke the operation string transferName = "aabb123"; - PartnerTransferDetailResource result = await collection.GetAsync(transferName); + PartnerTransferDetailCreateOrUpdateContent content = new PartnerTransferDetailCreateOrUpdateContent + { + RecipientEmailId = "user@contoso.com", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, transferName, content); + PartnerTransferDetailResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_PartnerTransferGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PartnerTransferGet() + public async Task Get_PartnerTransferGet() { // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersGet.json // this example is just showing the usage of "PartnerTransfers_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_PartnerTransferGet() // invoke the operation string transferName = "aabb123"; - bool result = await collection.ExistsAsync(transferName); + PartnerTransferDetailResource result = await collection.GetAsync(transferName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerTransferDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PartnerTransferGet() + public async Task GetAll_PartnerTransfersList() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersGet.json - // this example is just showing the usage of "PartnerTransfers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersList.json + // this example is just showing the usage of "PartnerTransfers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_PartnerTransferGet() // get the collection of this PartnerTransferDetailResource PartnerTransferDetailCollection collection = billingProfileCustomer.GetPartnerTransferDetails(); - // invoke the operation - string transferName = "aabb123"; - NullableResponse response = await collection.GetIfExistsAsync(transferName); - PartnerTransferDetailResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PartnerTransferDetailResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerTransferDetailData resourceData = result.Data; + PartnerTransferDetailData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_InitiatePartnerTransfer() + public async Task Exists_PartnerTransferGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersInitiate.json - // this example is just showing the usage of "PartnerTransfers_Initiate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersGet.json + // this example is just showing the usage of "PartnerTransfers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_InitiatePartnerTransfer() // invoke the operation string transferName = "aabb123"; - PartnerTransferDetailCreateOrUpdateContent content = new PartnerTransferDetailCreateOrUpdateContent() - { - RecipientEmailId = "user@contoso.com", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, transferName, content); - PartnerTransferDetailResource result = lro.Value; + bool result = await collection.ExistsAsync(transferName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerTransferDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PartnerTransfersList() + public async Task GetIfExists_PartnerTransferGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersList.json - // this example is just showing the usage of "PartnerTransfers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/partnerTransfersGet.json + // this example is just showing the usage of "PartnerTransfers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_PartnerTransfersList() // get the collection of this PartnerTransferDetailResource PartnerTransferDetailCollection collection = billingProfileCustomer.GetPartnerTransferDetails(); - // invoke the operation and iterate over the result - await foreach (PartnerTransferDetailResource item in collection.GetAllAsync()) + // invoke the operation + string transferName = "aabb123"; + NullableResponse response = await collection.GetIfExistsAsync(transferName); + PartnerTransferDetailResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PartnerTransferDetailData resourceData = item.Data; + PartnerTransferDetailData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_PartnerTransferDetailResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_PartnerTransferDetailResource.cs index 6e49dcd4c28f7..2d74175346f76 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_PartnerTransferDetailResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_PartnerTransferDetailResource.cs @@ -69,7 +69,7 @@ public async Task Update_InitiatePartnerTransfer() PartnerTransferDetailResource partnerTransferDetail = client.GetPartnerTransferDetailResource(partnerTransferDetailResourceId); // invoke the operation - PartnerTransferDetailCreateOrUpdateContent content = new PartnerTransferDetailCreateOrUpdateContent() + PartnerTransferDetailCreateOrUpdateContent content = new PartnerTransferDetailCreateOrUpdateContent { RecipientEmailId = "user@contoso.com", }; diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_RecipientTransferDetailCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_RecipientTransferDetailCollection.cs index e69c09e17c8e8..382cea33c19c5 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_RecipientTransferDetailCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_RecipientTransferDetailCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Billing.Samples @@ -27,9 +28,7 @@ public async Task Get_RecipientTransferGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this RecipientTransferDetailResource RecipientTransferDetailCollection collection = tenantResource.GetRecipientTransferDetails(); @@ -45,6 +44,36 @@ public async Task Get_RecipientTransferGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_RecipientTransfersList() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/recipientTransfersList.json + // this example is just showing the usage of "RecipientTransfers_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this RecipientTransferDetailResource + RecipientTransferDetailCollection collection = tenantResource.GetRecipientTransferDetails(); + + // invoke the operation and iterate over the result + await foreach (RecipientTransferDetailResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecipientTransferDetailData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_RecipientTransferGet() @@ -57,9 +86,7 @@ public async Task Exists_RecipientTransferGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this RecipientTransferDetailResource RecipientTransferDetailCollection collection = tenantResource.GetRecipientTransferDetails(); @@ -83,9 +110,7 @@ public async Task GetIfExists_RecipientTransferGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this RecipientTransferDetailResource RecipientTransferDetailCollection collection = tenantResource.GetRecipientTransferDetails(); @@ -108,37 +133,5 @@ public async Task GetIfExists_RecipientTransferGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_RecipientTransfersList() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/recipientTransfersList.json - // this example is just showing the usage of "RecipientTransfers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this RecipientTransferDetailResource - RecipientTransferDetailCollection collection = tenantResource.GetRecipientTransferDetails(); - - // invoke the operation and iterate over the result - await foreach (RecipientTransferDetailResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecipientTransferDetailData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_RecipientTransferDetailResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_RecipientTransferDetailResource.cs index 1e5087b855a2f..de31f82fdb59b 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_RecipientTransferDetailResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_RecipientTransferDetailResource.cs @@ -16,6 +16,34 @@ namespace Azure.ResourceManager.Billing.Samples { public partial class Sample_RecipientTransferDetailResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_RecipientTransferGet() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/recipientTransfersGet.json + // this example is just showing the usage of "RecipientTransfers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this RecipientTransferDetailResource created on azure + // for more information of creating RecipientTransferDetailResource, please refer to the document of RecipientTransferDetailResource + string transferName = "aabb123"; + ResourceIdentifier recipientTransferDetailResourceId = RecipientTransferDetailResource.CreateResourceIdentifier(transferName); + RecipientTransferDetailResource recipientTransferDetail = client.GetRecipientTransferDetailResource(recipientTransferDetailResourceId); + + // invoke the operation + RecipientTransferDetailResource result = await recipientTransferDetail.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RecipientTransferDetailData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Accept_AcceptTransfer() @@ -35,20 +63,17 @@ public async Task Accept_AcceptTransfer() RecipientTransferDetailResource recipientTransferDetail = client.GetRecipientTransferDetailResource(recipientTransferDetailResourceId); // invoke the operation - AcceptTransferContent content = new AcceptTransferContent() + AcceptTransferContent content = new AcceptTransferContent { - ProductDetails = -{ -new BillingProductDetails() + ProductDetails = {new BillingProductDetails { ProductType = BillingProductType.AzureSubscription, ProductId = "subscriptionId", -},new BillingProductDetails() +}, new BillingProductDetails { ProductType = BillingProductType.AzureReservation, ProductId = "reservedInstanceId", -} -}, +}}, }; RecipientTransferDetailResource result = await recipientTransferDetail.AcceptAsync(content); @@ -78,20 +103,17 @@ public async Task Validate_ValidateTransfer() RecipientTransferDetailResource recipientTransferDetail = client.GetRecipientTransferDetailResource(recipientTransferDetailResourceId); // invoke the operation and iterate over the result - AcceptTransferContent content = new AcceptTransferContent() + AcceptTransferContent content = new AcceptTransferContent { - ProductDetails = -{ -new BillingProductDetails() + ProductDetails = {new BillingProductDetails { ProductType = BillingProductType.AzureSubscription, ProductId = "subscriptionId", -},new BillingProductDetails() +}, new BillingProductDetails { ProductType = BillingProductType.AzureReservation, ProductId = "reservedInstanceId", -} -}, +}}, }; await foreach (BillingTransferValidationResult item in recipientTransferDetail.ValidateAsync(content)) { @@ -128,33 +150,5 @@ public async Task Decline_DeclineTransfer() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_RecipientTransferGet() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/recipientTransfersGet.json - // this example is just showing the usage of "RecipientTransfers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this RecipientTransferDetailResource created on azure - // for more information of creating RecipientTransferDetailResource, please refer to the document of RecipientTransferDetailResource - string transferName = "aabb123"; - ResourceIdentifier recipientTransferDetailResourceId = RecipientTransferDetailResource.CreateResourceIdentifier(transferName); - RecipientTransferDetailResource recipientTransferDetail = client.GetRecipientTransferDetailResource(recipientTransferDetailResourceId); - - // invoke the operation - RecipientTransferDetailResource result = await recipientTransferDetail.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RecipientTransferDetailData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SavingsPlanOrderModelCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SavingsPlanOrderModelCollection.cs index 7ce6cb9ff1e70..bffe075ee860c 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SavingsPlanOrderModelCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SavingsPlanOrderModelCollection.cs @@ -49,9 +49,9 @@ public async Task Get_SavingsPlanOrderGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SavingsPlanOrderGet() + public async Task Get_SavingsPlanOrderWithExpandedPaymentsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderGetByBillingAccount.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderExpandedScheduleGetByBillingAccount.json // this example is just showing the usage of "SavingsPlanOrders_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -70,17 +70,21 @@ public async Task Exists_SavingsPlanOrderGet() // invoke the operation string savingsPlanOrderId = "20000000-0000-0000-0000-000000000000"; - bool result = await collection.ExistsAsync(savingsPlanOrderId); + SavingsPlanOrderModelResource result = await collection.GetAsync(savingsPlanOrderId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SavingsPlanOrderModelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SavingsPlanOrderGet() + public async Task GetAll_SavingsPlanOrderList() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderGetByBillingAccount.json - // this example is just showing the usage of "SavingsPlanOrders_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderListByBillingAccount.json + // this example is just showing the usage of "SavingsPlanOrders_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,30 +100,24 @@ public async Task GetIfExists_SavingsPlanOrderGet() // get the collection of this SavingsPlanOrderModelResource SavingsPlanOrderModelCollection collection = billingAccount.GetSavingsPlanOrderModels(); - // invoke the operation - string savingsPlanOrderId = "20000000-0000-0000-0000-000000000000"; - NullableResponse response = await collection.GetIfExistsAsync(savingsPlanOrderId); - SavingsPlanOrderModelResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SavingsPlanOrderModelResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SavingsPlanOrderModelData resourceData = result.Data; + SavingsPlanOrderModelData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SavingsPlanOrderWithExpandedPaymentsGet() + public async Task Exists_SavingsPlanOrderGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderExpandedScheduleGetByBillingAccount.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderGetByBillingAccount.json // this example is just showing the usage of "SavingsPlanOrders_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -138,13 +136,9 @@ public async Task Get_SavingsPlanOrderWithExpandedPaymentsGet() // invoke the operation string savingsPlanOrderId = "20000000-0000-0000-0000-000000000000"; - SavingsPlanOrderModelResource result = await collection.GetAsync(savingsPlanOrderId); + bool result = await collection.ExistsAsync(savingsPlanOrderId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SavingsPlanOrderModelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -177,9 +171,9 @@ public async Task Exists_SavingsPlanOrderWithExpandedPaymentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SavingsPlanOrderWithExpandedPaymentsGet() + public async Task GetIfExists_SavingsPlanOrderGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderExpandedScheduleGetByBillingAccount.json + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderGetByBillingAccount.json // this example is just showing the usage of "SavingsPlanOrders_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -217,10 +211,10 @@ public async Task GetIfExists_SavingsPlanOrderWithExpandedPaymentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SavingsPlanOrderList() + public async Task GetIfExists_SavingsPlanOrderWithExpandedPaymentsGet() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderListByBillingAccount.json - // this example is just showing the usage of "SavingsPlanOrders_ListByBillingAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/savingsPlanOrderExpandedScheduleGetByBillingAccount.json + // this example is just showing the usage of "SavingsPlanOrders_GetByBillingAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,17 +230,23 @@ public async Task GetAll_SavingsPlanOrderList() // get the collection of this SavingsPlanOrderModelResource SavingsPlanOrderModelCollection collection = billingAccount.GetSavingsPlanOrderModels(); - // invoke the operation and iterate over the result - await foreach (SavingsPlanOrderModelResource item in collection.GetAllAsync()) + // invoke the operation + string savingsPlanOrderId = "20000000-0000-0000-0000-000000000000"; + NullableResponse response = await collection.GetIfExistsAsync(savingsPlanOrderId); + SavingsPlanOrderModelResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SavingsPlanOrderModelData resourceData = item.Data; + SavingsPlanOrderModelData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SubscriptionBillingInvoiceCollection.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SubscriptionBillingInvoiceCollection.cs index 9d74a596b6a03..77b6f58af112a 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SubscriptionBillingInvoiceCollection.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SubscriptionBillingInvoiceCollection.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Billing.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Billing.Samples @@ -28,9 +29,7 @@ public async Task Get_InvoicesGetByBillingSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SubscriptionBillingInvoiceResource string subscriptionId = "11111111-1111-1111-1111-111111111111"; @@ -47,6 +46,38 @@ public async Task Get_InvoicesGetByBillingSubscription() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_InvoicesListByBillingSubscription() + { + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesListByBillingSubscription.json + // this example is just showing the usage of "Invoices_ListByBillingSubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this SubscriptionBillingInvoiceResource + string subscriptionId = "11111111-1111-1111-1111-111111111111"; + SubscriptionBillingInvoiceCollection collection = tenantResource.GetSubscriptionBillingInvoices(subscriptionId); + + // invoke the operation and iterate over the result + SubscriptionBillingInvoiceCollectionGetAllOptions options = new SubscriptionBillingInvoiceCollectionGetAllOptions { PeriodStartDate = DateTimeOffset.Parse("2023-01-01"), PeriodEndDate = DateTimeOffset.Parse("2023-06-30") }; + await foreach (SubscriptionBillingInvoiceResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingInvoiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_InvoicesGetByBillingSubscription() @@ -59,9 +90,7 @@ public async Task Exists_InvoicesGetByBillingSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SubscriptionBillingInvoiceResource string subscriptionId = "11111111-1111-1111-1111-111111111111"; @@ -86,9 +115,7 @@ public async Task GetIfExists_InvoicesGetByBillingSubscription() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this SubscriptionBillingInvoiceResource string subscriptionId = "11111111-1111-1111-1111-111111111111"; @@ -112,39 +139,5 @@ public async Task GetIfExists_InvoicesGetByBillingSubscription() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_InvoicesListByBillingSubscription() - { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesListByBillingSubscription.json - // this example is just showing the usage of "Invoices_ListByBillingSubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this SubscriptionBillingInvoiceResource - string subscriptionId = "11111111-1111-1111-1111-111111111111"; - SubscriptionBillingInvoiceCollection collection = tenantResource.GetSubscriptionBillingInvoices(subscriptionId); - - // invoke the operation and iterate over the result - SubscriptionBillingInvoiceCollectionGetAllOptions options = new SubscriptionBillingInvoiceCollectionGetAllOptions() { PeriodStartDate = DateTimeOffset.Parse("2023-01-01"), PeriodEndDate = DateTimeOffset.Parse("2023-06-30") }; - await foreach (SubscriptionBillingInvoiceResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingInvoiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SubscriptionBillingInvoiceResource.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SubscriptionBillingInvoiceResource.cs index 6b5aa0886daed..278e1eeca68c2 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SubscriptionBillingInvoiceResource.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_SubscriptionBillingInvoiceResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SubscriptionBillingInvoiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task DownloadByBillingSubscription_InvoicesDownloadByBillingSubscription() + public async Task Get_InvoicesGetByBillingSubscription() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadByBillingSubscription.json - // this example is just showing the usage of "Invoices_DownloadByBillingSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesGetByBillingSubscription.json + // this example is just showing the usage of "Invoices_GetByBillingSubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,25 +30,27 @@ public async Task DownloadByBillingSubscription_InvoicesDownloadByBillingSubscri // this example assumes you already have this SubscriptionBillingInvoiceResource created on azure // for more information of creating SubscriptionBillingInvoiceResource, please refer to the document of SubscriptionBillingInvoiceResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "11111111-1111-1111-1111-111111111111"; string invoiceName = "E123456789"; ResourceIdentifier subscriptionBillingInvoiceResourceId = SubscriptionBillingInvoiceResource.CreateResourceIdentifier(subscriptionId, invoiceName); SubscriptionBillingInvoiceResource subscriptionBillingInvoice = client.GetSubscriptionBillingInvoiceResource(subscriptionBillingInvoiceResourceId); // invoke the operation - string documentName = "12345678"; - ArmOperation lro = await subscriptionBillingInvoice.DownloadByBillingSubscriptionAsync(WaitUntil.Completed, documentName: documentName); - BillingDocumentDownloadResult result = lro.Value; + SubscriptionBillingInvoiceResource result = await subscriptionBillingInvoice.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BillingInvoiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_InvoicesGetByBillingSubscription() + public async Task DownloadByBillingSubscription_InvoicesDownloadByBillingSubscription() { - // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesGetByBillingSubscription.json - // this example is just showing the usage of "Invoices_GetByBillingSubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/billing/resource-manager/Microsoft.Billing/stable/2024-04-01/examples/invoicesDownloadByBillingSubscription.json + // this example is just showing the usage of "Invoices_DownloadByBillingSubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -57,19 +59,17 @@ public async Task Get_InvoicesGetByBillingSubscription() // this example assumes you already have this SubscriptionBillingInvoiceResource created on azure // for more information of creating SubscriptionBillingInvoiceResource, please refer to the document of SubscriptionBillingInvoiceResource - string subscriptionId = "11111111-1111-1111-1111-111111111111"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; string invoiceName = "E123456789"; ResourceIdentifier subscriptionBillingInvoiceResourceId = SubscriptionBillingInvoiceResource.CreateResourceIdentifier(subscriptionId, invoiceName); SubscriptionBillingInvoiceResource subscriptionBillingInvoice = client.GetSubscriptionBillingInvoiceResource(subscriptionBillingInvoiceResourceId); // invoke the operation - SubscriptionBillingInvoiceResource result = await subscriptionBillingInvoice.GetAsync(); + string documentName = "12345678"; + ArmOperation lro = await subscriptionBillingInvoice.DownloadByBillingSubscriptionAsync(WaitUntil.Completed, documentName: documentName); + BillingDocumentDownloadResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BillingInvoiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index 92ca3e0da797c..0d475e5bf3488 100644 --- a/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/billing/Azure.ResourceManager.Billing/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -11,6 +11,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Billing.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Billing.Samples @@ -29,9 +30,7 @@ public async Task ValidateAddres_AddressValidateInvalid() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation BillingAddressDetails details = new BillingAddressDetails("1 Test", "us") @@ -57,9 +56,7 @@ public async Task ValidateAddres_AddressValidateValid() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation BillingAddressDetails details = new BillingAddressDetails("1 Test", "us") @@ -85,19 +82,18 @@ public async Task DownloadDocumentsByBillingSubscriptionInvoice_InvoicesDownload // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation string subscriptionId = "00000000-0000-0000-0000-000000000000"; IEnumerable arrayOfDocumentDownloadRequest = new BillingDocumentDownloadRequestContent[] { -new BillingDocumentDownloadRequestContent() +new BillingDocumentDownloadRequestContent { DocumentName = "12345678", InvoiceName = "E123456789", -},new BillingDocumentDownloadRequestContent() +}, +new BillingDocumentDownloadRequestContent { DocumentName = "12345678", InvoiceName = "E987654321", diff --git a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_AssignmentCollection.cs b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_AssignmentCollection.cs index d9be359a42f9b..38a77bf1d5621 100644 --- a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_AssignmentCollection.cs +++ b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_AssignmentCollection.cs @@ -27,13 +27,9 @@ public async Task Get_AssignmentAtManagementGroupScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AssignmentResource string resourceScope = "managementGroups/ContosoOnlineGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - AssignmentCollection collection = client.GetAssignments(scopeId); + AssignmentCollection collection = client.GetAssignments(new ResourceIdentifier(resourceScope)); // invoke the operation string assignmentName = "assignSimpleBlueprint"; @@ -48,9 +44,9 @@ public async Task Get_AssignmentAtManagementGroupScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AssignmentAtManagementGroupScope() + public async Task Get_AssignmentAtSubscriptionScope() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignment_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignment_Get.json // this example is just showing the usage of "Assignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -58,65 +54,84 @@ public async Task Exists_AssignmentAtManagementGroupScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AssignmentResource - string resourceScope = "managementGroups/ContosoOnlineGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - AssignmentCollection collection = client.GetAssignments(scopeId); + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + AssignmentCollection collection = client.GetAssignments(new ResourceIdentifier(resourceScope)); // invoke the operation string assignmentName = "assignSimpleBlueprint"; - bool result = await collection.ExistsAsync(assignmentName); + AssignmentResource result = await collection.GetAsync(assignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AssignmentAtManagementGroupScope() + public async Task GetAll_AssignmentAtManagementGroupScope() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignment_Get.json - // this example is just showing the usage of "Assignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignment_List.json + // this example is just showing the usage of "Assignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AssignmentResource string resourceScope = "managementGroups/ContosoOnlineGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - AssignmentCollection collection = client.GetAssignments(scopeId); + AssignmentCollection collection = client.GetAssignments(new ResourceIdentifier(resourceScope)); - // invoke the operation - string assignmentName = "assignSimpleBlueprint"; - NullableResponse response = await collection.GetIfExistsAsync(assignmentName); - AssignmentResource result = response.HasValue ? response.Value : null; - - if (result == null) + // invoke the operation and iterate over the result + await foreach (AssignmentResource item in collection.GetAllAsync()) { - Console.WriteLine("Succeeded with null as result"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - else + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_AssignmentAtSubscriptionScope() + { + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignment_List.json + // this example is just showing the usage of "Assignments_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this AssignmentResource + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + AssignmentCollection collection = client.GetAssignments(new ResourceIdentifier(resourceScope)); + + // invoke the operation and iterate over the result + await foreach (AssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AssignmentData resourceData = result.Data; + AssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AssignmentAtSubscriptionScope() + public async Task Exists_AssignmentAtManagementGroupScope() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignment_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignment_Get.json // this example is just showing the usage of "Assignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -124,23 +139,15 @@ public async Task Get_AssignmentAtSubscriptionScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AssignmentResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - AssignmentCollection collection = client.GetAssignments(scopeId); + string resourceScope = "managementGroups/ContosoOnlineGroup"; + AssignmentCollection collection = client.GetAssignments(new ResourceIdentifier(resourceScope)); // invoke the operation string assignmentName = "assignSimpleBlueprint"; - AssignmentResource result = await collection.GetAsync(assignmentName); + bool result = await collection.ExistsAsync(assignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -155,13 +162,9 @@ public async Task Exists_AssignmentAtSubscriptionScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AssignmentResource string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - AssignmentCollection collection = client.GetAssignments(scopeId); + AssignmentCollection collection = client.GetAssignments(new ResourceIdentifier(resourceScope)); // invoke the operation string assignmentName = "assignSimpleBlueprint"; @@ -172,9 +175,9 @@ public async Task Exists_AssignmentAtSubscriptionScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AssignmentAtSubscriptionScope() + public async Task GetIfExists_AssignmentAtManagementGroupScope() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignment_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignment_Get.json // this example is just showing the usage of "Assignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -182,13 +185,9 @@ public async Task GetIfExists_AssignmentAtSubscriptionScope() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AssignmentResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - AssignmentCollection collection = client.GetAssignments(scopeId); + string resourceScope = "managementGroups/ContosoOnlineGroup"; + AssignmentCollection collection = client.GetAssignments(new ResourceIdentifier(resourceScope)); // invoke the operation string assignmentName = "assignSimpleBlueprint"; @@ -211,68 +210,37 @@ public async Task GetIfExists_AssignmentAtSubscriptionScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AssignmentAtManagementGroupScope() + public async Task GetIfExists_AssignmentAtSubscriptionScope() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignment_List.json - // this example is just showing the usage of "Assignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignment_Get.json + // this example is just showing the usage of "Assignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this AssignmentResource - string resourceScope = "managementGroups/ContosoOnlineGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - AssignmentCollection collection = client.GetAssignments(scopeId); + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + AssignmentCollection collection = client.GetAssignments(new ResourceIdentifier(resourceScope)); - // invoke the operation and iterate over the result - await foreach (AssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string assignmentName = "assignSimpleBlueprint"; + NullableResponse response = await collection.GetIfExistsAsync(assignmentName); + AssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded with null as result"); } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_AssignmentAtSubscriptionScope() - { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignment_List.json - // this example is just showing the usage of "Assignments_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this AssignmentResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - AssignmentCollection collection = client.GetAssignments(scopeId); - - // invoke the operation and iterate over the result - await foreach (AssignmentResource item in collection.GetAllAsync()) + else { - // the variable item is a resource, you could call other operations on this instance as well + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AssignmentData resourceData = item.Data; + AssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_AssignmentOperationCollection.cs b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_AssignmentOperationCollection.cs index f4a245f0f0e73..d8df1064355d8 100644 --- a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_AssignmentOperationCollection.cs +++ b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_AssignmentOperationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_AssignmentOperationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AssignmentAtManagementGroupScope() + public async Task Get_AssignmentAtManagementGroupScope() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignmentOperation_List.json - // this example is just showing the usage of "AssignmentOperations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignmentOperation_Get.json + // this example is just showing the usage of "AssignmentOperations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_AssignmentAtManagementGroupScope() // get the collection of this AssignmentOperationResource AssignmentOperationCollection collection = assignment.GetAssignmentOperations(); - // invoke the operation and iterate over the result - await foreach (AssignmentOperationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssignmentOperationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string assignmentOperationName = "fb5d4dcb-7ce2-4087-ba7a-459aa74e5e0f"; + AssignmentOperationResource result = await collection.GetAsync(assignmentOperationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssignmentOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AssignmentAtSubscriptionScope() + public async Task Get_AssignmentAtSubscriptionScope() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignmentOperation_List.json - // this example is just showing the usage of "AssignmentOperations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignmentOperation_Get.json + // this example is just showing the usage of "AssignmentOperations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,25 +70,23 @@ public async Task GetAll_AssignmentAtSubscriptionScope() // get the collection of this AssignmentOperationResource AssignmentOperationCollection collection = assignment.GetAssignmentOperations(); - // invoke the operation and iterate over the result - await foreach (AssignmentOperationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssignmentOperationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string assignmentOperationName = "fb5d4dcb-7ce2-4087-ba7a-459aa74e5e0f"; + AssignmentOperationResource result = await collection.GetAsync(assignmentOperationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssignmentOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AssignmentAtManagementGroupScope() + public async Task GetAll_AssignmentAtManagementGroupScope() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignmentOperation_Get.json - // this example is just showing the usage of "AssignmentOperations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignmentOperation_List.json + // this example is just showing the usage of "AssignmentOperations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,23 +103,25 @@ public async Task Get_AssignmentAtManagementGroupScope() // get the collection of this AssignmentOperationResource AssignmentOperationCollection collection = assignment.GetAssignmentOperations(); - // invoke the operation - string assignmentOperationName = "fb5d4dcb-7ce2-4087-ba7a-459aa74e5e0f"; - AssignmentOperationResource result = await collection.GetAsync(assignmentOperationName); + // invoke the operation and iterate over the result + await foreach (AssignmentOperationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssignmentOperationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssignmentOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AssignmentAtManagementGroupScope() + public async Task GetAll_AssignmentAtSubscriptionScope() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignmentOperation_Get.json - // this example is just showing the usage of "AssignmentOperations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignmentOperation_List.json + // this example is just showing the usage of "AssignmentOperations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,7 +130,7 @@ public async Task Exists_AssignmentAtManagementGroupScope() // this example assumes you already have this AssignmentResource created on azure // for more information of creating AssignmentResource, please refer to the document of AssignmentResource - string resourceScope = "managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string assignmentName = "assignSimpleBlueprint"; ResourceIdentifier assignmentResourceId = AssignmentResource.CreateResourceIdentifier(resourceScope, assignmentName); AssignmentResource assignment = client.GetAssignmentResource(assignmentResourceId); @@ -140,16 +138,22 @@ public async Task Exists_AssignmentAtManagementGroupScope() // get the collection of this AssignmentOperationResource AssignmentOperationCollection collection = assignment.GetAssignmentOperations(); - // invoke the operation - string assignmentOperationName = "fb5d4dcb-7ce2-4087-ba7a-459aa74e5e0f"; - bool result = await collection.ExistsAsync(assignmentOperationName); + // invoke the operation and iterate over the result + await foreach (AssignmentOperationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssignmentOperationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AssignmentAtManagementGroupScope() + public async Task Exists_AssignmentAtManagementGroupScope() { // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignmentOperation_Get.json // this example is just showing the usage of "AssignmentOperations_Get" operation, for the dependent resources, they will have to be created separately. @@ -171,26 +175,14 @@ public async Task GetIfExists_AssignmentAtManagementGroupScope() // invoke the operation string assignmentOperationName = "fb5d4dcb-7ce2-4087-ba7a-459aa74e5e0f"; - NullableResponse response = await collection.GetIfExistsAsync(assignmentOperationName); - AssignmentOperationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(assignmentOperationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssignmentOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AssignmentAtSubscriptionScope() + public async Task Exists_AssignmentAtSubscriptionScope() { // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignmentOperation_Get.json // this example is just showing the usage of "AssignmentOperations_Get" operation, for the dependent resources, they will have to be created separately. @@ -212,20 +204,16 @@ public async Task Get_AssignmentAtSubscriptionScope() // invoke the operation string assignmentOperationName = "fb5d4dcb-7ce2-4087-ba7a-459aa74e5e0f"; - AssignmentOperationResource result = await collection.GetAsync(assignmentOperationName); + bool result = await collection.ExistsAsync(assignmentOperationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AssignmentOperationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AssignmentAtSubscriptionScope() + public async Task GetIfExists_AssignmentAtManagementGroupScope() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPAssignment/BlueprintAssignmentOperation_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPAssignment/BlueprintAssignmentOperation_Get.json // this example is just showing the usage of "AssignmentOperations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -235,7 +223,7 @@ public async Task Exists_AssignmentAtSubscriptionScope() // this example assumes you already have this AssignmentResource created on azure // for more information of creating AssignmentResource, please refer to the document of AssignmentResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "managementGroups/ContosoOnlineGroup"; string assignmentName = "assignSimpleBlueprint"; ResourceIdentifier assignmentResourceId = AssignmentResource.CreateResourceIdentifier(resourceScope, assignmentName); AssignmentResource assignment = client.GetAssignmentResource(assignmentResourceId); @@ -245,9 +233,21 @@ public async Task Exists_AssignmentAtSubscriptionScope() // invoke the operation string assignmentOperationName = "fb5d4dcb-7ce2-4087-ba7a-459aa74e5e0f"; - bool result = await collection.ExistsAsync(assignmentOperationName); + NullableResponse response = await collection.GetIfExistsAsync(assignmentOperationName); + AssignmentOperationResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AssignmentOperationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintArtifactCollection.cs b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintArtifactCollection.cs index 7cd27e483340a..cdf1d25cebb99 100644 --- a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintArtifactCollection.cs +++ b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintArtifactCollection.cs @@ -41,53 +41,62 @@ public async Task CreateOrUpdate_MGARMTemplateArtifact() // invoke the operation string artifactName = "storageTemplate"; - ArtifactData data = new TemplateArtifact(BinaryData.FromObjectAsJson(new Dictionary() + ArtifactData data = new TemplateArtifact(BinaryData.FromObjectAsJson(new { - ["contentVersion"] = "1.0.0.0", - ["outputs"] = new Dictionary() + contentVersion = "1.0.0.0", + outputs = new { - ["storageAccountName"] = new Dictionary() + storageAccountName = new { - ["type"] = "string", - ["value"] = "[variables('storageAccountName')]" - } + type = "string", + value = "[variables('storageAccountName')]", + }, }, - ["parameters"] = new Dictionary() + parameters = new { - ["storageAccountType"] = new Dictionary() + storageAccountType = new { - ["type"] = "string", - ["allowedValues"] = new object[] { "Standard_LRS", "Standard_GRS", "Standard_ZRS", "Premium_LRS" }, - ["defaultValue"] = "Standard_LRS", - ["metadata"] = new Dictionary() + type = "string", + allowedValues = new object[] + { +"Standard_LRS", +"Standard_GRS", +"Standard_ZRS", +"Premium_LRS" + }, + defaultValue = "Standard_LRS", + metadata = new { - ["description"] = "Storage Account type" - } - } + description = "Storage Account type", + }, + }, }, - ["resources"] = new object[] { new Dictionary() + resources = new object[] + { +new { -["name"] = "[variables('storageAccountName')]", -["type"] = "Microsoft.Storage/storageAccounts", -["apiVersion"] = "2016-01-01", -["kind"] = "Storage", -["location"] = "[resourceGroup().location]", -["properties"] = new Dictionary() +name = "[variables('storageAccountName')]", +type = "Microsoft.Storage/storageAccounts", +apiVersion = "2016-01-01", +kind = "Storage", +location = "[resourceGroup().location]", +properties = new object(), +sku = new { +name = "[parameters('storageAccountType')]", }, -["sku"] = new Dictionary() -{ -["name"] = "[parameters('storageAccountType')]"}} }, - ["variables"] = new Dictionary() +} + }, + variables = new { - ["storageAccountName"] = "[concat(uniquestring(resourceGroup().id), 'standardsa')]" - } - }), new Dictionary() + storageAccountName = "[concat(uniquestring(resourceGroup().id), 'standardsa')]", + }, + }), new Dictionary { - ["storageAccountType"] = new ParameterValue() + ["storageAccountType"] = new ParameterValue { - Value = BinaryData.FromString("\"[parameters('storageAccountType')]\""), - }, + Value = BinaryData.FromObjectAsJson("[parameters('storageAccountType')]"), + } }) { ResourceGroup = "storageRG", @@ -126,16 +135,16 @@ public async Task CreateOrUpdate_MGPolicyAssignmentArtifact() // invoke the operation string artifactName = "costCenterPolicy"; - ArtifactData data = new PolicyAssignmentArtifact("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62", new Dictionary() + ArtifactData data = new PolicyAssignmentArtifact("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62", new Dictionary { - ["tagName"] = new ParameterValue() + ["tagName"] = new ParameterValue { - Value = BinaryData.FromString("\"costCenter\""), + Value = BinaryData.FromObjectAsJson("costCenter"), }, - ["tagValue"] = new ParameterValue() + ["tagValue"] = new ParameterValue { - Value = BinaryData.FromString("\"[parameter('costCenter')]\""), - }, + Value = BinaryData.FromObjectAsJson("[parameter('costCenter')]"), + } }) { DisplayName = "force costCenter tag on all resources", @@ -174,7 +183,7 @@ public async Task CreateOrUpdate_MGRoleAssignmentArtifact() // invoke the operation string artifactName = "ownerAssignment"; - ArtifactData data = new RoleAssignmentArtifact("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", BinaryData.FromString("\"[parameters('owners')]\"")) + ArtifactData data = new RoleAssignmentArtifact("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", BinaryData.FromObjectAsJson("[parameters('owners')]")) { DisplayName = "enforce owners of given subscription", }; @@ -212,53 +221,62 @@ public async Task CreateOrUpdate_SubARMTemplateArtifact() // invoke the operation string artifactName = "storageTemplate"; - ArtifactData data = new TemplateArtifact(BinaryData.FromObjectAsJson(new Dictionary() + ArtifactData data = new TemplateArtifact(BinaryData.FromObjectAsJson(new { - ["contentVersion"] = "1.0.0.0", - ["outputs"] = new Dictionary() + contentVersion = "1.0.0.0", + outputs = new { - ["storageAccountName"] = new Dictionary() + storageAccountName = new { - ["type"] = "string", - ["value"] = "[variables('storageAccountName')]" - } + type = "string", + value = "[variables('storageAccountName')]", + }, }, - ["parameters"] = new Dictionary() + parameters = new { - ["storageAccountType"] = new Dictionary() + storageAccountType = new { - ["type"] = "string", - ["allowedValues"] = new object[] { "Standard_LRS", "Standard_GRS", "Standard_ZRS", "Premium_LRS" }, - ["defaultValue"] = "Standard_LRS", - ["metadata"] = new Dictionary() + type = "string", + allowedValues = new object[] + { +"Standard_LRS", +"Standard_GRS", +"Standard_ZRS", +"Premium_LRS" + }, + defaultValue = "Standard_LRS", + metadata = new { - ["description"] = "Storage Account type" - } - } + description = "Storage Account type", + }, + }, }, - ["resources"] = new object[] { new Dictionary() + resources = new object[] + { +new { -["name"] = "[variables('storageAccountName')]", -["type"] = "Microsoft.Storage/storageAccounts", -["apiVersion"] = "2016-01-01", -["kind"] = "Storage", -["location"] = "[resourceGroup().location]", -["properties"] = new Dictionary() +name = "[variables('storageAccountName')]", +type = "Microsoft.Storage/storageAccounts", +apiVersion = "2016-01-01", +kind = "Storage", +location = "[resourceGroup().location]", +properties = new object(), +sku = new { +name = "[parameters('storageAccountType')]", }, -["sku"] = new Dictionary() -{ -["name"] = "[parameters('storageAccountType')]"}} }, - ["variables"] = new Dictionary() +} + }, + variables = new { - ["storageAccountName"] = "[concat(uniquestring(resourceGroup().id), 'standardsa')]" - } - }), new Dictionary() + storageAccountName = "[concat(uniquestring(resourceGroup().id), 'standardsa')]", + }, + }), new Dictionary { - ["storageAccountType"] = new ParameterValue() + ["storageAccountType"] = new ParameterValue { - Value = BinaryData.FromString("\"[parameters('storageAccountType')]\""), - }, + Value = BinaryData.FromObjectAsJson("[parameters('storageAccountType')]"), + } }) { ResourceGroup = "storageRG", @@ -297,16 +315,16 @@ public async Task CreateOrUpdate_SubPolicyAssignmentArtifact() // invoke the operation string artifactName = "costCenterPolicy"; - ArtifactData data = new PolicyAssignmentArtifact("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62", new Dictionary() + ArtifactData data = new PolicyAssignmentArtifact("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62", new Dictionary { - ["tagName"] = new ParameterValue() + ["tagName"] = new ParameterValue { - Value = BinaryData.FromString("\"costCenter\""), + Value = BinaryData.FromObjectAsJson("costCenter"), }, - ["tagValue"] = new ParameterValue() + ["tagValue"] = new ParameterValue { - Value = BinaryData.FromString("\"[parameter('costCenter')]\""), - }, + Value = BinaryData.FromObjectAsJson("[parameter('costCenter')]"), + } }) { DisplayName = "force costCenter tag on all resources", @@ -345,7 +363,7 @@ public async Task CreateOrUpdate_SubRoleAssignmentArtifact() // invoke the operation string artifactName = "ownerAssignment"; - ArtifactData data = new RoleAssignmentArtifact("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", BinaryData.FromString("\"[parameters('owners')]\"")) + ArtifactData data = new RoleAssignmentArtifact("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", BinaryData.FromObjectAsJson("[parameters('owners')]")) { DisplayName = "enforce owners of given subscription", }; @@ -394,9 +412,9 @@ public async Task Get_MGARMTemplateArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MGARMTemplateArtifact() + public async Task Get_MGPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -415,17 +433,21 @@ public async Task Exists_MGARMTemplateArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "storageTemplate"; - bool result = await collection.ExistsAsync(artifactName); + string artifactName = "costCenterPolicy"; + BlueprintArtifactResource result = await collection.GetAsync(artifactName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MGARMTemplateArtifact() + public async Task Get_MGRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -444,29 +466,21 @@ public async Task GetIfExists_MGARMTemplateArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "storageTemplate"; - NullableResponse response = await collection.GetIfExistsAsync(artifactName); - BlueprintArtifactResource result = response.HasValue ? response.Value : null; + string artifactName = "ownerAssignment"; + BlueprintArtifactResource result = await collection.GetAsync(artifactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MGPolicyAssignmentArtifact() + public async Task Get_SubARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -476,7 +490,7 @@ public async Task Get_MGPolicyAssignmentArtifact() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -485,7 +499,7 @@ public async Task Get_MGPolicyAssignmentArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "costCenterPolicy"; + string artifactName = "storageTemplate"; BlueprintArtifactResource result = await collection.GetAsync(artifactName); // the variable result is a resource, you could call other operations on this instance as well @@ -497,9 +511,9 @@ public async Task Get_MGPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MGPolicyAssignmentArtifact() + public async Task Get_SubPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -509,7 +523,7 @@ public async Task Exists_MGPolicyAssignmentArtifact() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -519,16 +533,20 @@ public async Task Exists_MGPolicyAssignmentArtifact() // invoke the operation string artifactName = "costCenterPolicy"; - bool result = await collection.ExistsAsync(artifactName); + BlueprintArtifactResource result = await collection.GetAsync(artifactName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MGPolicyAssignmentArtifact() + public async Task Get_SubRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -538,7 +556,7 @@ public async Task GetIfExists_MGPolicyAssignmentArtifact() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -547,30 +565,22 @@ public async Task GetIfExists_MGPolicyAssignmentArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "costCenterPolicy"; - NullableResponse response = await collection.GetIfExistsAsync(artifactName); - BlueprintArtifactResource result = response.HasValue ? response.Value : null; + string artifactName = "ownerAssignment"; + BlueprintArtifactResource result = await collection.GetAsync(artifactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MGRoleAssignmentArtifact() + public async Task GetAll_MGArtifactList() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Get.json - // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Artifact_List.json + // this example is just showing the usage of "Artifacts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -587,23 +597,25 @@ public async Task Get_MGRoleAssignmentArtifact() // get the collection of this BlueprintArtifactResource BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); - // invoke the operation - string artifactName = "ownerAssignment"; - BlueprintArtifactResource result = await collection.GetAsync(artifactName); + // invoke the operation and iterate over the result + await foreach (BlueprintArtifactResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MGRoleAssignmentArtifact() + public async Task GetAll_SubArtifactList() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Get.json - // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Artifact_List.json + // this example is just showing the usage of "Artifacts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -612,7 +624,7 @@ public async Task Exists_MGRoleAssignmentArtifact() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -620,18 +632,24 @@ public async Task Exists_MGRoleAssignmentArtifact() // get the collection of this BlueprintArtifactResource BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); - // invoke the operation - string artifactName = "ownerAssignment"; - bool result = await collection.ExistsAsync(artifactName); + // invoke the operation and iterate over the result + await foreach (BlueprintArtifactResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MGRoleAssignmentArtifact() + public async Task Exists_MGARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -650,29 +668,17 @@ public async Task GetIfExists_MGRoleAssignmentArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "ownerAssignment"; - NullableResponse response = await collection.GetIfExistsAsync(artifactName); - BlueprintArtifactResource result = response.HasValue ? response.Value : null; + string artifactName = "storageTemplate"; + bool result = await collection.ExistsAsync(artifactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubARMTemplateArtifact() + public async Task Exists_MGPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -682,7 +688,7 @@ public async Task Get_SubARMTemplateArtifact() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -691,21 +697,17 @@ public async Task Get_SubARMTemplateArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "storageTemplate"; - BlueprintArtifactResource result = await collection.GetAsync(artifactName); + string artifactName = "costCenterPolicy"; + bool result = await collection.ExistsAsync(artifactName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SubARMTemplateArtifact() + public async Task Exists_MGRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -715,7 +717,7 @@ public async Task Exists_SubARMTemplateArtifact() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -724,7 +726,7 @@ public async Task Exists_SubARMTemplateArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "storageTemplate"; + string artifactName = "ownerAssignment"; bool result = await collection.ExistsAsync(artifactName); Console.WriteLine($"Succeeded: {result}"); @@ -732,7 +734,7 @@ public async Task Exists_SubARMTemplateArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SubARMTemplateArtifact() + public async Task Exists_SubARMTemplateArtifact() { // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. @@ -754,26 +756,14 @@ public async Task GetIfExists_SubARMTemplateArtifact() // invoke the operation string artifactName = "storageTemplate"; - NullableResponse response = await collection.GetIfExistsAsync(artifactName); - BlueprintArtifactResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(artifactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubPolicyAssignmentArtifact() + public async Task Exists_SubPolicyAssignmentArtifact() { // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. @@ -795,20 +785,16 @@ public async Task Get_SubPolicyAssignmentArtifact() // invoke the operation string artifactName = "costCenterPolicy"; - BlueprintArtifactResource result = await collection.GetAsync(artifactName); + bool result = await collection.ExistsAsync(artifactName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SubPolicyAssignmentArtifact() + public async Task Exists_SubRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -827,7 +813,7 @@ public async Task Exists_SubPolicyAssignmentArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "costCenterPolicy"; + string artifactName = "ownerAssignment"; bool result = await collection.ExistsAsync(artifactName); Console.WriteLine($"Succeeded: {result}"); @@ -835,9 +821,9 @@ public async Task Exists_SubPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SubPolicyAssignmentArtifact() + public async Task GetIfExists_MGARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -847,7 +833,7 @@ public async Task GetIfExists_SubPolicyAssignmentArtifact() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -856,7 +842,7 @@ public async Task GetIfExists_SubPolicyAssignmentArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "costCenterPolicy"; + string artifactName = "storageTemplate"; NullableResponse response = await collection.GetIfExistsAsync(artifactName); BlueprintArtifactResource result = response.HasValue ? response.Value : null; @@ -876,9 +862,9 @@ public async Task GetIfExists_SubPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubRoleAssignmentArtifact() + public async Task GetIfExists_MGPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -888,7 +874,7 @@ public async Task Get_SubRoleAssignmentArtifact() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -897,21 +883,29 @@ public async Task Get_SubRoleAssignmentArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "ownerAssignment"; - BlueprintArtifactResource result = await collection.GetAsync(artifactName); + string artifactName = "costCenterPolicy"; + NullableResponse response = await collection.GetIfExistsAsync(artifactName); + BlueprintArtifactResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SubRoleAssignmentArtifact() + public async Task GetIfExists_MGRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -921,7 +915,7 @@ public async Task Exists_SubRoleAssignmentArtifact() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -931,16 +925,28 @@ public async Task Exists_SubRoleAssignmentArtifact() // invoke the operation string artifactName = "ownerAssignment"; - bool result = await collection.ExistsAsync(artifactName); + NullableResponse response = await collection.GetIfExistsAsync(artifactName); + BlueprintArtifactResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SubRoleAssignmentArtifact() + public async Task GetIfExists_SubARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Get.json // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -959,7 +965,7 @@ public async Task GetIfExists_SubRoleAssignmentArtifact() BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); // invoke the operation - string artifactName = "ownerAssignment"; + string artifactName = "storageTemplate"; NullableResponse response = await collection.GetIfExistsAsync(artifactName); BlueprintArtifactResource result = response.HasValue ? response.Value : null; @@ -979,10 +985,10 @@ public async Task GetIfExists_SubRoleAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MGArtifactList() + public async Task GetIfExists_SubPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Artifact_List.json - // this example is just showing the usage of "Artifacts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Get.json + // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -991,7 +997,7 @@ public async Task GetAll_MGArtifactList() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -999,25 +1005,31 @@ public async Task GetAll_MGArtifactList() // get the collection of this BlueprintArtifactResource BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); - // invoke the operation and iterate over the result - await foreach (BlueprintArtifactResource item in collection.GetAllAsync()) + // invoke the operation + string artifactName = "costCenterPolicy"; + NullableResponse response = await collection.GetIfExistsAsync(artifactName); + BlueprintArtifactResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ArtifactData resourceData = item.Data; + ArtifactData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SubArtifactList() + public async Task GetIfExists_SubRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Artifact_List.json - // this example is just showing the usage of "Artifacts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Get.json + // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1034,17 +1046,23 @@ public async Task GetAll_SubArtifactList() // get the collection of this BlueprintArtifactResource BlueprintArtifactCollection collection = blueprint.GetBlueprintArtifacts(); - // invoke the operation and iterate over the result - await foreach (BlueprintArtifactResource item in collection.GetAllAsync()) + // invoke the operation + string artifactName = "ownerAssignment"; + NullableResponse response = await collection.GetIfExistsAsync(artifactName); + BlueprintArtifactResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ArtifactData resourceData = item.Data; + ArtifactData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintArtifactResource.cs b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintArtifactResource.cs index 276e86889c7cd..181f813175d14 100644 --- a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintArtifactResource.cs +++ b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintArtifactResource.cs @@ -19,10 +19,10 @@ public partial class Sample_BlueprintArtifactResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MGARMTemplateArtifact() + public async Task Get_MGARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Create.json - // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Get.json + // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,59 +38,7 @@ public async Task Update_MGARMTemplateArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArtifactData data = new TemplateArtifact(BinaryData.FromObjectAsJson(new Dictionary() - { - ["contentVersion"] = "1.0.0.0", - ["outputs"] = new Dictionary() - { - ["storageAccountName"] = new Dictionary() - { - ["type"] = "string", - ["value"] = "[variables('storageAccountName')]" - } - }, - ["parameters"] = new Dictionary() - { - ["storageAccountType"] = new Dictionary() - { - ["type"] = "string", - ["allowedValues"] = new object[] { "Standard_LRS", "Standard_GRS", "Standard_ZRS", "Premium_LRS" }, - ["defaultValue"] = "Standard_LRS", - ["metadata"] = new Dictionary() - { - ["description"] = "Storage Account type" - } - } - }, - ["resources"] = new object[] { new Dictionary() -{ -["name"] = "[variables('storageAccountName')]", -["type"] = "Microsoft.Storage/storageAccounts", -["apiVersion"] = "2016-01-01", -["kind"] = "Storage", -["location"] = "[resourceGroup().location]", -["properties"] = new Dictionary() -{ -}, -["sku"] = new Dictionary() -{ -["name"] = "[parameters('storageAccountType')]"}} }, - ["variables"] = new Dictionary() - { - ["storageAccountName"] = "[concat(uniquestring(resourceGroup().id), 'standardsa')]" - } - }), new Dictionary() - { - ["storageAccountType"] = new ParameterValue() - { - Value = BinaryData.FromString("\"[parameters('storageAccountType')]\""), - }, - }) - { - ResourceGroup = "storageRG", - }; - ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); - BlueprintArtifactResource result = lro.Value; + BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -101,10 +49,10 @@ public async Task Update_MGARMTemplateArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MGPolicyAssignmentArtifact() + public async Task Get_MGPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Create.json - // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Get.json + // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,22 +68,7 @@ public async Task Update_MGPolicyAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArtifactData data = new PolicyAssignmentArtifact("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62", new Dictionary() - { - ["tagName"] = new ParameterValue() - { - Value = BinaryData.FromString("\"costCenter\""), - }, - ["tagValue"] = new ParameterValue() - { - Value = BinaryData.FromString("\"[parameter('costCenter')]\""), - }, - }) - { - DisplayName = "force costCenter tag on all resources", - }; - ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); - BlueprintArtifactResource result = lro.Value; + BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -146,10 +79,10 @@ public async Task Update_MGPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_MGRoleAssignmentArtifact() + public async Task Get_MGRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Create.json - // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Get.json + // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -165,12 +98,7 @@ public async Task Update_MGRoleAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArtifactData data = new RoleAssignmentArtifact("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", BinaryData.FromString("\"[parameters('owners')]\"")) - { - DisplayName = "enforce owners of given subscription", - }; - ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); - BlueprintArtifactResource result = lro.Value; + BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -181,10 +109,10 @@ public async Task Update_MGRoleAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SubARMTemplateArtifact() + public async Task Get_SubARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Create.json - // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Get.json + // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -200,59 +128,7 @@ public async Task Update_SubARMTemplateArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArtifactData data = new TemplateArtifact(BinaryData.FromObjectAsJson(new Dictionary() - { - ["contentVersion"] = "1.0.0.0", - ["outputs"] = new Dictionary() - { - ["storageAccountName"] = new Dictionary() - { - ["type"] = "string", - ["value"] = "[variables('storageAccountName')]" - } - }, - ["parameters"] = new Dictionary() - { - ["storageAccountType"] = new Dictionary() - { - ["type"] = "string", - ["allowedValues"] = new object[] { "Standard_LRS", "Standard_GRS", "Standard_ZRS", "Premium_LRS" }, - ["defaultValue"] = "Standard_LRS", - ["metadata"] = new Dictionary() - { - ["description"] = "Storage Account type" - } - } - }, - ["resources"] = new object[] { new Dictionary() -{ -["name"] = "[variables('storageAccountName')]", -["type"] = "Microsoft.Storage/storageAccounts", -["apiVersion"] = "2016-01-01", -["kind"] = "Storage", -["location"] = "[resourceGroup().location]", -["properties"] = new Dictionary() -{ -}, -["sku"] = new Dictionary() -{ -["name"] = "[parameters('storageAccountType')]"}} }, - ["variables"] = new Dictionary() - { - ["storageAccountName"] = "[concat(uniquestring(resourceGroup().id), 'standardsa')]" - } - }), new Dictionary() - { - ["storageAccountType"] = new ParameterValue() - { - Value = BinaryData.FromString("\"[parameters('storageAccountType')]\""), - }, - }) - { - ResourceGroup = "storageRG", - }; - ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); - BlueprintArtifactResource result = lro.Value; + BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -263,10 +139,10 @@ public async Task Update_SubARMTemplateArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SubPolicyAssignmentArtifact() + public async Task Get_SubPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Create.json - // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Get.json + // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -282,22 +158,7 @@ public async Task Update_SubPolicyAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArtifactData data = new PolicyAssignmentArtifact("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62", new Dictionary() - { - ["tagName"] = new ParameterValue() - { - Value = BinaryData.FromString("\"costCenter\""), - }, - ["tagValue"] = new ParameterValue() - { - Value = BinaryData.FromString("\"[parameter('costCenter')]\""), - }, - }) - { - DisplayName = "force costCenter tag on all resources", - }; - ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); - BlueprintArtifactResource result = lro.Value; + BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -308,10 +169,10 @@ public async Task Update_SubPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SubRoleAssignmentArtifact() + public async Task Get_SubRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Create.json - // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Get.json + // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -327,12 +188,7 @@ public async Task Update_SubRoleAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArtifactData data = new RoleAssignmentArtifact("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", BinaryData.FromString("\"[parameters('owners')]\"")) - { - DisplayName = "enforce owners of given subscription", - }; - ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); - BlueprintArtifactResource result = lro.Value; + BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -343,10 +199,10 @@ public async Task Update_SubRoleAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MGARMTemplateArtifact() + public async Task Delete_MGARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Get.json - // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Delete.json + // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -362,7 +218,8 @@ public async Task Get_MGARMTemplateArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); + ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -373,10 +230,10 @@ public async Task Get_MGARMTemplateArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MGPolicyAssignmentArtifact() + public async Task Delete_MGPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Get.json - // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Delete.json + // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -392,7 +249,8 @@ public async Task Get_MGPolicyAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); + ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -403,10 +261,10 @@ public async Task Get_MGPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MGRoleAssignmentArtifact() + public async Task Delete_MGRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Get.json - // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Delete.json + // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -422,7 +280,8 @@ public async Task Get_MGRoleAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); + ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -433,10 +292,10 @@ public async Task Get_MGRoleAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubARMTemplateArtifact() + public async Task Delete_SubARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Get.json - // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Delete.json + // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -452,7 +311,8 @@ public async Task Get_SubARMTemplateArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); + ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -463,10 +323,10 @@ public async Task Get_SubARMTemplateArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubPolicyAssignmentArtifact() + public async Task Delete_SubPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Get.json - // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Delete.json + // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -482,7 +342,8 @@ public async Task Get_SubPolicyAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); + ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -493,10 +354,10 @@ public async Task Get_SubPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubRoleAssignmentArtifact() + public async Task Delete_SubRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Get.json - // this example is just showing the usage of "Artifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Delete.json + // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -512,7 +373,8 @@ public async Task Get_SubRoleAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - BlueprintArtifactResource result = await blueprintArtifact.GetAsync(); + ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -523,10 +385,10 @@ public async Task Get_SubRoleAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_MGARMTemplateArtifact() + public async Task Update_MGARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Delete.json - // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/ARMTemplateArtifact_Create.json + // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -542,7 +404,67 @@ public async Task Delete_MGARMTemplateArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + ArtifactData data = new TemplateArtifact(BinaryData.FromObjectAsJson(new + { + contentVersion = "1.0.0.0", + outputs = new + { + storageAccountName = new + { + type = "string", + value = "[variables('storageAccountName')]", + }, + }, + parameters = new + { + storageAccountType = new + { + type = "string", + allowedValues = new object[] + { +"Standard_LRS", +"Standard_GRS", +"Standard_ZRS", +"Premium_LRS" + }, + defaultValue = "Standard_LRS", + metadata = new + { + description = "Storage Account type", + }, + }, + }, + resources = new object[] + { +new +{ +name = "[variables('storageAccountName')]", +type = "Microsoft.Storage/storageAccounts", +apiVersion = "2016-01-01", +kind = "Storage", +location = "[resourceGroup().location]", +properties = new object(), +sku = new +{ +name = "[parameters('storageAccountType')]", +}, +} + }, + variables = new + { + storageAccountName = "[concat(uniquestring(resourceGroup().id), 'standardsa')]", + }, + }), new Dictionary + { + ["storageAccountType"] = new ParameterValue + { + Value = BinaryData.FromObjectAsJson("[parameters('storageAccountType')]"), + } + }) + { + ResourceGroup = "storageRG", + }; + ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -554,10 +476,10 @@ public async Task Delete_MGARMTemplateArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_MGPolicyAssignmentArtifact() + public async Task Update_MGPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Delete.json - // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/PolicyAssignmentArtifact_Create.json + // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -573,7 +495,21 @@ public async Task Delete_MGPolicyAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + ArtifactData data = new PolicyAssignmentArtifact("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62", new Dictionary + { + ["tagName"] = new ParameterValue + { + Value = BinaryData.FromObjectAsJson("costCenter"), + }, + ["tagValue"] = new ParameterValue + { + Value = BinaryData.FromObjectAsJson("[parameter('costCenter')]"), + } + }) + { + DisplayName = "force costCenter tag on all resources", + }; + ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -585,10 +521,10 @@ public async Task Delete_MGPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_MGRoleAssignmentArtifact() + public async Task Update_MGRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Delete.json - // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/RoleAssignmentArtifact_Create.json + // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -604,7 +540,11 @@ public async Task Delete_MGRoleAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + ArtifactData data = new RoleAssignmentArtifact("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", BinaryData.FromObjectAsJson("[parameters('owners')]")) + { + DisplayName = "enforce owners of given subscription", + }; + ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -616,10 +556,10 @@ public async Task Delete_MGRoleAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SubARMTemplateArtifact() + public async Task Update_SubARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Delete.json - // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/ARMTemplateArtifact_Create.json + // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -635,7 +575,67 @@ public async Task Delete_SubARMTemplateArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + ArtifactData data = new TemplateArtifact(BinaryData.FromObjectAsJson(new + { + contentVersion = "1.0.0.0", + outputs = new + { + storageAccountName = new + { + type = "string", + value = "[variables('storageAccountName')]", + }, + }, + parameters = new + { + storageAccountType = new + { + type = "string", + allowedValues = new object[] + { +"Standard_LRS", +"Standard_GRS", +"Standard_ZRS", +"Premium_LRS" + }, + defaultValue = "Standard_LRS", + metadata = new + { + description = "Storage Account type", + }, + }, + }, + resources = new object[] + { +new +{ +name = "[variables('storageAccountName')]", +type = "Microsoft.Storage/storageAccounts", +apiVersion = "2016-01-01", +kind = "Storage", +location = "[resourceGroup().location]", +properties = new object(), +sku = new +{ +name = "[parameters('storageAccountType')]", +}, +} + }, + variables = new + { + storageAccountName = "[concat(uniquestring(resourceGroup().id), 'standardsa')]", + }, + }), new Dictionary + { + ["storageAccountType"] = new ParameterValue + { + Value = BinaryData.FromObjectAsJson("[parameters('storageAccountType')]"), + } + }) + { + ResourceGroup = "storageRG", + }; + ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -647,10 +647,10 @@ public async Task Delete_SubARMTemplateArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SubPolicyAssignmentArtifact() + public async Task Update_SubPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Delete.json - // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/PolicyAssignmentArtifact_Create.json + // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -666,7 +666,21 @@ public async Task Delete_SubPolicyAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + ArtifactData data = new PolicyAssignmentArtifact("/providers/Microsoft.Authorization/policyDefinitions/1e30110a-5ceb-460c-a204-c1c3969c6d62", new Dictionary + { + ["tagName"] = new ParameterValue + { + Value = BinaryData.FromObjectAsJson("costCenter"), + }, + ["tagValue"] = new ParameterValue + { + Value = BinaryData.FromObjectAsJson("[parameter('costCenter')]"), + } + }) + { + DisplayName = "force costCenter tag on all resources", + }; + ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -678,10 +692,10 @@ public async Task Delete_SubPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SubRoleAssignmentArtifact() + public async Task Update_SubRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Delete.json - // this example is just showing the usage of "Artifacts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/RoleAssignmentArtifact_Create.json + // this example is just showing the usage of "Artifacts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -697,7 +711,11 @@ public async Task Delete_SubRoleAssignmentArtifact() BlueprintArtifactResource blueprintArtifact = client.GetBlueprintArtifactResource(blueprintArtifactResourceId); // invoke the operation - ArmOperation lro = await blueprintArtifact.DeleteAsync(WaitUntil.Completed); + ArtifactData data = new RoleAssignmentArtifact("/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", BinaryData.FromObjectAsJson("[parameters('owners')]")) + { + DisplayName = "enforce owners of given subscription", + }; + ArmOperation lro = await blueprintArtifact.UpdateAsync(WaitUntil.Completed, data); BlueprintArtifactResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintCollection.cs b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintCollection.cs index 7fd8e02aaf772..f334074d950ac 100644 --- a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintCollection.cs +++ b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintCollection.cs @@ -28,17 +28,13 @@ public async Task CreateOrUpdate_ManagementGroupBlueprint() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this BlueprintResource string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); // invoke the operation string blueprintName = "simpleBlueprint"; - BlueprintData data = new BlueprintData() + BlueprintData data = new BlueprintData { Description = "blueprint contains all artifact kinds {'template', 'rbac', 'policy'}", TargetScope = BlueprintTargetScope.Subscription, @@ -55,15 +51,15 @@ public async Task CreateOrUpdate_ManagementGroupBlueprint() ["storageAccountType"] = new ParameterDefinition(TemplateParameterType.String) { DisplayName = "storage account type.", -}, +} }, ResourceGroups = { -["storageRG"] = new ResourceGroupDefinition() +["storageRG"] = new ResourceGroupDefinition { DisplayName = "storage resource group", Description = "Contains storageAccounts that collect all shoebox logs.", -}, +} }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blueprintName, data); @@ -88,33 +84,29 @@ public async Task CreateOrUpdate_ResourceGroupWithTags() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this BlueprintResource string resourceScope = "providers/Microsoft.Management/managementGroups/{ManagementGroupId}"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); // invoke the operation string blueprintName = "simpleBlueprint"; - BlueprintData data = new BlueprintData() + BlueprintData data = new BlueprintData { Description = "An example blueprint containing an RG with two tags.", TargetScope = BlueprintTargetScope.Subscription, ResourceGroups = { -["myRGName"] = new ResourceGroupDefinition() +["myRGName"] = new ResourceGroupDefinition { Name = "myRGName", Location = new AzureLocation("westus"), Tags = { ["costcenter"] = "123456", -["nameOnlyTag"] = "", +["nameOnlyTag"] = "" }, DisplayName = "My Resource Group", -}, +} }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blueprintName, data); @@ -139,17 +131,13 @@ public async Task CreateOrUpdate_SubscriptionBlueprint() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this BlueprintResource string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); // invoke the operation string blueprintName = "simpleBlueprint"; - BlueprintData data = new BlueprintData() + BlueprintData data = new BlueprintData { Description = "blueprint contains all artifact kinds {'template', 'rbac', 'policy'}", TargetScope = BlueprintTargetScope.Subscription, @@ -166,15 +154,15 @@ public async Task CreateOrUpdate_SubscriptionBlueprint() ["storageAccountType"] = new ParameterDefinition(TemplateParameterType.String) { DisplayName = "storage account type.", -}, +} }, ResourceGroups = { -["storageRG"] = new ResourceGroupDefinition() +["storageRG"] = new ResourceGroupDefinition { DisplayName = "storage resource group", Description = "Contains storageAccounts that collect all shoebox logs.", -}, +} }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, blueprintName, data); @@ -199,13 +187,9 @@ public async Task Get_ManagementGroupBlueprint() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this BlueprintResource string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); // invoke the operation string blueprintName = "simpleBlueprint"; @@ -220,9 +204,9 @@ public async Task Get_ManagementGroupBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ManagementGroupBlueprint() + public async Task Get_SubscriptionBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_Get.json // this example is just showing the usage of "Blueprints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -230,65 +214,84 @@ public async Task Exists_ManagementGroupBlueprint() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); // invoke the operation string blueprintName = "simpleBlueprint"; - bool result = await collection.ExistsAsync(blueprintName); + BlueprintResource result = await collection.GetAsync(blueprintName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BlueprintData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ManagementGroupBlueprint() + public async Task GetAll_ManagementGroupBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_Get.json - // this example is just showing the usage of "Blueprints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_List.json + // this example is just showing the usage of "Blueprints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this BlueprintResource string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); - // invoke the operation - string blueprintName = "simpleBlueprint"; - NullableResponse response = await collection.GetIfExistsAsync(blueprintName); - BlueprintResource result = response.HasValue ? response.Value : null; - - if (result == null) + // invoke the operation and iterate over the result + await foreach (BlueprintResource item in collection.GetAllAsync()) { - Console.WriteLine("Succeeded with null as result"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BlueprintData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - else + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_SubscriptionBlueprint() + { + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_List.json + // this example is just showing the usage of "Blueprints_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this BlueprintResource + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); + + // invoke the operation and iterate over the result + await foreach (BlueprintResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BlueprintData resourceData = result.Data; + BlueprintData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubscriptionBlueprint() + public async Task Exists_ManagementGroupBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_Get.json // this example is just showing the usage of "Blueprints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -296,23 +299,15 @@ public async Task Get_SubscriptionBlueprint() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); // invoke the operation string blueprintName = "simpleBlueprint"; - BlueprintResource result = await collection.GetAsync(blueprintName); + bool result = await collection.ExistsAsync(blueprintName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BlueprintData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -327,13 +322,9 @@ public async Task Exists_SubscriptionBlueprint() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this BlueprintResource string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); // invoke the operation string blueprintName = "simpleBlueprint"; @@ -344,9 +335,9 @@ public async Task Exists_SubscriptionBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SubscriptionBlueprint() + public async Task GetIfExists_ManagementGroupBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_Get.json // this example is just showing the usage of "Blueprints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -354,13 +345,9 @@ public async Task GetIfExists_SubscriptionBlueprint() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); // invoke the operation string blueprintName = "simpleBlueprint"; @@ -383,68 +370,37 @@ public async Task GetIfExists_SubscriptionBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ManagementGroupBlueprint() + public async Task GetIfExists_SubscriptionBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_List.json - // this example is just showing the usage of "Blueprints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_Get.json + // this example is just showing the usage of "Blueprints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + BlueprintCollection collection = client.GetBlueprints(new ResourceIdentifier(resourceScope)); - // invoke the operation and iterate over the result - await foreach (BlueprintResource item in collection.GetAllAsync()) + // invoke the operation + string blueprintName = "simpleBlueprint"; + NullableResponse response = await collection.GetIfExistsAsync(blueprintName); + BlueprintResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BlueprintData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded with null as result"); } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_SubscriptionBlueprint() - { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_List.json - // this example is just showing the usage of "Blueprints_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceScope)); - BlueprintCollection collection = client.GetBlueprints(scopeId); - - // invoke the operation and iterate over the result - await foreach (BlueprintResource item in collection.GetAllAsync()) + else { - // the variable item is a resource, you could call other operations on this instance as well + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BlueprintData resourceData = item.Data; + BlueprintData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintResource.cs b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintResource.cs index 3cb74d105b022..f587ab56b24f9 100644 --- a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintResource.cs +++ b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BlueprintResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ManagementGroupBlueprint() + public async Task Get_ManagementGroupBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_Create.json - // this example is just showing the usage of "Blueprints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_Get.json + // this example is just showing the usage of "Blueprints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,36 +36,7 @@ public async Task Update_ManagementGroupBlueprint() BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); // invoke the operation - BlueprintData data = new BlueprintData() - { - Description = "blueprint contains all artifact kinds {'template', 'rbac', 'policy'}", - TargetScope = BlueprintTargetScope.Subscription, - Parameters = -{ -["costCenter"] = new ParameterDefinition(TemplateParameterType.String) -{ -DisplayName = "force cost center tag for all resources under given subscription.", -}, -["owners"] = new ParameterDefinition(TemplateParameterType.Array) -{ -DisplayName = "assign owners to subscription along with blueprint assignment.", -}, -["storageAccountType"] = new ParameterDefinition(TemplateParameterType.String) -{ -DisplayName = "storage account type.", -}, -}, - ResourceGroups = -{ -["storageRG"] = new ResourceGroupDefinition() -{ -DisplayName = "storage resource group", -Description = "Contains storageAccounts that collect all shoebox logs.", -}, -}, - }; - ArmOperation lro = await blueprint.UpdateAsync(WaitUntil.Completed, data); - BlueprintResource result = lro.Value; + BlueprintResource result = await blueprint.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -76,10 +47,10 @@ public async Task Update_ManagementGroupBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ResourceGroupWithTags() + public async Task Get_SubscriptionBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/ResourceGroupWithTags.json - // this example is just showing the usage of "Blueprints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_Get.json + // this example is just showing the usage of "Blueprints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -88,33 +59,13 @@ public async Task Update_ResourceGroupWithTags() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/{ManagementGroupId}"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); // invoke the operation - BlueprintData data = new BlueprintData() - { - Description = "An example blueprint containing an RG with two tags.", - TargetScope = BlueprintTargetScope.Subscription, - ResourceGroups = -{ -["myRGName"] = new ResourceGroupDefinition() -{ -Name = "myRGName", -Location = new AzureLocation("westus"), -Tags = -{ -["costcenter"] = "123456", -["nameOnlyTag"] = "", -}, -DisplayName = "My Resource Group", -}, -}, - }; - ArmOperation lro = await blueprint.UpdateAsync(WaitUntil.Completed, data); - BlueprintResource result = lro.Value; + BlueprintResource result = await blueprint.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -125,10 +76,10 @@ public async Task Update_ResourceGroupWithTags() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SubscriptionBlueprint() + public async Task Delete_ManagementGroupBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_Create.json - // this example is just showing the usage of "Blueprints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_Delete.json + // this example is just showing the usage of "Blueprints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,41 +88,13 @@ public async Task Update_SubscriptionBlueprint() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); // invoke the operation - BlueprintData data = new BlueprintData() - { - Description = "blueprint contains all artifact kinds {'template', 'rbac', 'policy'}", - TargetScope = BlueprintTargetScope.Subscription, - Parameters = -{ -["costCenter"] = new ParameterDefinition(TemplateParameterType.String) -{ -DisplayName = "force cost center tag for all resources under given subscription.", -}, -["owners"] = new ParameterDefinition(TemplateParameterType.Array) -{ -DisplayName = "assign owners to subscription along with blueprint assignment.", -}, -["storageAccountType"] = new ParameterDefinition(TemplateParameterType.String) -{ -DisplayName = "storage account type.", -}, -}, - ResourceGroups = -{ -["storageRG"] = new ResourceGroupDefinition() -{ -DisplayName = "storage resource group", -Description = "Contains storageAccounts that collect all shoebox logs.", -}, -}, - }; - ArmOperation lro = await blueprint.UpdateAsync(WaitUntil.Completed, data); + ArmOperation lro = await blueprint.DeleteAsync(WaitUntil.Completed); BlueprintResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -183,10 +106,10 @@ public async Task Update_SubscriptionBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ManagementGroupBlueprint() + public async Task Delete_SubscriptionBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_Get.json - // this example is just showing the usage of "Blueprints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_Delete.json + // this example is just showing the usage of "Blueprints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,13 +118,14 @@ public async Task Get_ManagementGroupBlueprint() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); // invoke the operation - BlueprintResource result = await blueprint.GetAsync(); + ArmOperation lro = await blueprint.DeleteAsync(WaitUntil.Completed); + BlueprintResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -212,10 +136,10 @@ public async Task Get_ManagementGroupBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubscriptionBlueprint() + public async Task Update_ManagementGroupBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_Get.json - // this example is just showing the usage of "Blueprints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_Create.json + // this example is just showing the usage of "Blueprints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -224,13 +148,42 @@ public async Task Get_SubscriptionBlueprint() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); // invoke the operation - BlueprintResource result = await blueprint.GetAsync(); + BlueprintData data = new BlueprintData + { + Description = "blueprint contains all artifact kinds {'template', 'rbac', 'policy'}", + TargetScope = BlueprintTargetScope.Subscription, + Parameters = +{ +["costCenter"] = new ParameterDefinition(TemplateParameterType.String) +{ +DisplayName = "force cost center tag for all resources under given subscription.", +}, +["owners"] = new ParameterDefinition(TemplateParameterType.Array) +{ +DisplayName = "assign owners to subscription along with blueprint assignment.", +}, +["storageAccountType"] = new ParameterDefinition(TemplateParameterType.String) +{ +DisplayName = "storage account type.", +} +}, + ResourceGroups = +{ +["storageRG"] = new ResourceGroupDefinition +{ +DisplayName = "storage resource group", +Description = "Contains storageAccounts that collect all shoebox logs.", +} +}, + }; + ArmOperation lro = await blueprint.UpdateAsync(WaitUntil.Completed, data); + BlueprintResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -241,10 +194,10 @@ public async Task Get_SubscriptionBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ManagementGroupBlueprint() + public async Task Update_ResourceGroupWithTags() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/Blueprint_Delete.json - // this example is just showing the usage of "Blueprints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/ResourceGroupWithTags.json + // this example is just showing the usage of "Blueprints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -253,13 +206,32 @@ public async Task Delete_ManagementGroupBlueprint() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "providers/Microsoft.Management/managementGroups/{ManagementGroupId}"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); // invoke the operation - ArmOperation lro = await blueprint.DeleteAsync(WaitUntil.Completed); + BlueprintData data = new BlueprintData + { + Description = "An example blueprint containing an RG with two tags.", + TargetScope = BlueprintTargetScope.Subscription, + ResourceGroups = +{ +["myRGName"] = new ResourceGroupDefinition +{ +Name = "myRGName", +Location = new AzureLocation("westus"), +Tags = +{ +["costcenter"] = "123456", +["nameOnlyTag"] = "" +}, +DisplayName = "My Resource Group", +} +}, + }; + ArmOperation lro = await blueprint.UpdateAsync(WaitUntil.Completed, data); BlueprintResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -271,10 +243,10 @@ public async Task Delete_ManagementGroupBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SubscriptionBlueprint() + public async Task Update_SubscriptionBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_Delete.json - // this example is just showing the usage of "Blueprints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/Blueprint_Create.json + // this example is just showing the usage of "Blueprints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -289,7 +261,35 @@ public async Task Delete_SubscriptionBlueprint() BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); // invoke the operation - ArmOperation lro = await blueprint.DeleteAsync(WaitUntil.Completed); + BlueprintData data = new BlueprintData + { + Description = "blueprint contains all artifact kinds {'template', 'rbac', 'policy'}", + TargetScope = BlueprintTargetScope.Subscription, + Parameters = +{ +["costCenter"] = new ParameterDefinition(TemplateParameterType.String) +{ +DisplayName = "force cost center tag for all resources under given subscription.", +}, +["owners"] = new ParameterDefinition(TemplateParameterType.Array) +{ +DisplayName = "assign owners to subscription along with blueprint assignment.", +}, +["storageAccountType"] = new ParameterDefinition(TemplateParameterType.String) +{ +DisplayName = "storage account type.", +} +}, + ResourceGroups = +{ +["storageRG"] = new ResourceGroupDefinition +{ +DisplayName = "storage resource group", +Description = "Contains storageAccounts that collect all shoebox logs.", +} +}, + }; + ArmOperation lro = await blueprint.UpdateAsync(WaitUntil.Completed, data); BlueprintResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintVersionArtifactCollection.cs b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintVersionArtifactCollection.cs index 5ff4c66e52a3a..618411272ff47 100644 --- a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintVersionArtifactCollection.cs +++ b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_BlueprintVersionArtifactCollection.cs @@ -51,9 +51,9 @@ public async Task Get_MGARMTemplateArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MGARMTemplateArtifact() + public async Task Get_MGPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedARMTemplateArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedPolicyAssignmentArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -73,17 +73,21 @@ public async Task Exists_MGARMTemplateArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "storageTemplate"; - bool result = await collection.ExistsAsync(artifactName); + string artifactName = "costCenterPolicy"; + BlueprintVersionArtifactResource result = await collection.GetAsync(artifactName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MGARMTemplateArtifact() + public async Task Get_MGRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedARMTemplateArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedRoleAssignmentArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -103,29 +107,21 @@ public async Task GetIfExists_MGARMTemplateArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "storageTemplate"; - NullableResponse response = await collection.GetIfExistsAsync(artifactName); - BlueprintVersionArtifactResource result = response.HasValue ? response.Value : null; + string artifactName = "ownerAssignment"; + BlueprintVersionArtifactResource result = await collection.GetAsync(artifactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MGPolicyAssignmentArtifact() + public async Task Get_SubARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedPolicyAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedARMTemplateArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -135,7 +131,7 @@ public async Task Get_MGPolicyAssignmentArtifact() // this example assumes you already have this PublishedBlueprintResource created on azure // for more information of creating PublishedBlueprintResource, please refer to the document of PublishedBlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; string versionId = "V2"; ResourceIdentifier publishedBlueprintResourceId = PublishedBlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName, versionId); @@ -145,7 +141,7 @@ public async Task Get_MGPolicyAssignmentArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "costCenterPolicy"; + string artifactName = "storageTemplate"; BlueprintVersionArtifactResource result = await collection.GetAsync(artifactName); // the variable result is a resource, you could call other operations on this instance as well @@ -157,9 +153,9 @@ public async Task Get_MGPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MGPolicyAssignmentArtifact() + public async Task Get_SubPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedPolicyAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedPolicyAssignmentArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -169,7 +165,7 @@ public async Task Exists_MGPolicyAssignmentArtifact() // this example assumes you already have this PublishedBlueprintResource created on azure // for more information of creating PublishedBlueprintResource, please refer to the document of PublishedBlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; string versionId = "V2"; ResourceIdentifier publishedBlueprintResourceId = PublishedBlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName, versionId); @@ -180,16 +176,20 @@ public async Task Exists_MGPolicyAssignmentArtifact() // invoke the operation string artifactName = "costCenterPolicy"; - bool result = await collection.ExistsAsync(artifactName); + BlueprintVersionArtifactResource result = await collection.GetAsync(artifactName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MGPolicyAssignmentArtifact() + public async Task Get_SubRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedPolicyAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedRoleAssignmentArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -199,7 +199,7 @@ public async Task GetIfExists_MGPolicyAssignmentArtifact() // this example assumes you already have this PublishedBlueprintResource created on azure // for more information of creating PublishedBlueprintResource, please refer to the document of PublishedBlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; string versionId = "V2"; ResourceIdentifier publishedBlueprintResourceId = PublishedBlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName, versionId); @@ -209,30 +209,22 @@ public async Task GetIfExists_MGPolicyAssignmentArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "costCenterPolicy"; - NullableResponse response = await collection.GetIfExistsAsync(artifactName); - BlueprintVersionArtifactResource result = response.HasValue ? response.Value : null; + string artifactName = "ownerAssignment"; + BlueprintVersionArtifactResource result = await collection.GetAsync(artifactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MGRoleAssignmentArtifact() + public async Task GetAll_MGArtifactList() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedRoleAssignmentArtifact_Get.json - // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedArtifact_List.json + // this example is just showing the usage of "PublishedArtifacts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -250,23 +242,25 @@ public async Task Get_MGRoleAssignmentArtifact() // get the collection of this BlueprintVersionArtifactResource BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); - // invoke the operation - string artifactName = "ownerAssignment"; - BlueprintVersionArtifactResource result = await collection.GetAsync(artifactName); + // invoke the operation and iterate over the result + await foreach (BlueprintVersionArtifactResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MGRoleAssignmentArtifact() + public async Task GetAll_SubArtifactList() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedRoleAssignmentArtifact_Get.json - // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedArtifact_List.json + // this example is just showing the usage of "PublishedArtifacts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -275,7 +269,7 @@ public async Task Exists_MGRoleAssignmentArtifact() // this example assumes you already have this PublishedBlueprintResource created on azure // for more information of creating PublishedBlueprintResource, please refer to the document of PublishedBlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; string versionId = "V2"; ResourceIdentifier publishedBlueprintResourceId = PublishedBlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName, versionId); @@ -284,18 +278,24 @@ public async Task Exists_MGRoleAssignmentArtifact() // get the collection of this BlueprintVersionArtifactResource BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); - // invoke the operation - string artifactName = "ownerAssignment"; - bool result = await collection.ExistsAsync(artifactName); + // invoke the operation and iterate over the result + await foreach (BlueprintVersionArtifactResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MGRoleAssignmentArtifact() + public async Task Exists_MGARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedRoleAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedARMTemplateArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -315,29 +315,17 @@ public async Task GetIfExists_MGRoleAssignmentArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "ownerAssignment"; - NullableResponse response = await collection.GetIfExistsAsync(artifactName); - BlueprintVersionArtifactResource result = response.HasValue ? response.Value : null; + string artifactName = "storageTemplate"; + bool result = await collection.ExistsAsync(artifactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubARMTemplateArtifact() + public async Task Exists_MGPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedARMTemplateArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedPolicyAssignmentArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -347,7 +335,7 @@ public async Task Get_SubARMTemplateArtifact() // this example assumes you already have this PublishedBlueprintResource created on azure // for more information of creating PublishedBlueprintResource, please refer to the document of PublishedBlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; string versionId = "V2"; ResourceIdentifier publishedBlueprintResourceId = PublishedBlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName, versionId); @@ -357,21 +345,17 @@ public async Task Get_SubARMTemplateArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "storageTemplate"; - BlueprintVersionArtifactResource result = await collection.GetAsync(artifactName); + string artifactName = "costCenterPolicy"; + bool result = await collection.ExistsAsync(artifactName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SubARMTemplateArtifact() + public async Task Exists_MGRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedARMTemplateArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedRoleAssignmentArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -381,7 +365,7 @@ public async Task Exists_SubARMTemplateArtifact() // this example assumes you already have this PublishedBlueprintResource created on azure // for more information of creating PublishedBlueprintResource, please refer to the document of PublishedBlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; string versionId = "V2"; ResourceIdentifier publishedBlueprintResourceId = PublishedBlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName, versionId); @@ -391,7 +375,7 @@ public async Task Exists_SubARMTemplateArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "storageTemplate"; + string artifactName = "ownerAssignment"; bool result = await collection.ExistsAsync(artifactName); Console.WriteLine($"Succeeded: {result}"); @@ -399,7 +383,7 @@ public async Task Exists_SubARMTemplateArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SubARMTemplateArtifact() + public async Task Exists_SubARMTemplateArtifact() { // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedARMTemplateArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. @@ -422,26 +406,14 @@ public async Task GetIfExists_SubARMTemplateArtifact() // invoke the operation string artifactName = "storageTemplate"; - NullableResponse response = await collection.GetIfExistsAsync(artifactName); - BlueprintVersionArtifactResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(artifactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubPolicyAssignmentArtifact() + public async Task Exists_SubPolicyAssignmentArtifact() { // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedPolicyAssignmentArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. @@ -464,20 +436,16 @@ public async Task Get_SubPolicyAssignmentArtifact() // invoke the operation string artifactName = "costCenterPolicy"; - BlueprintVersionArtifactResource result = await collection.GetAsync(artifactName); + bool result = await collection.ExistsAsync(artifactName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SubPolicyAssignmentArtifact() + public async Task Exists_SubRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedPolicyAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedRoleAssignmentArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -497,7 +465,7 @@ public async Task Exists_SubPolicyAssignmentArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "costCenterPolicy"; + string artifactName = "ownerAssignment"; bool result = await collection.ExistsAsync(artifactName); Console.WriteLine($"Succeeded: {result}"); @@ -505,9 +473,9 @@ public async Task Exists_SubPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SubPolicyAssignmentArtifact() + public async Task GetIfExists_MGARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedPolicyAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedARMTemplateArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -517,7 +485,7 @@ public async Task GetIfExists_SubPolicyAssignmentArtifact() // this example assumes you already have this PublishedBlueprintResource created on azure // for more information of creating PublishedBlueprintResource, please refer to the document of PublishedBlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; string versionId = "V2"; ResourceIdentifier publishedBlueprintResourceId = PublishedBlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName, versionId); @@ -527,7 +495,7 @@ public async Task GetIfExists_SubPolicyAssignmentArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "costCenterPolicy"; + string artifactName = "storageTemplate"; NullableResponse response = await collection.GetIfExistsAsync(artifactName); BlueprintVersionArtifactResource result = response.HasValue ? response.Value : null; @@ -547,9 +515,9 @@ public async Task GetIfExists_SubPolicyAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SubRoleAssignmentArtifact() + public async Task GetIfExists_MGPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedRoleAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedPolicyAssignmentArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -559,7 +527,7 @@ public async Task Get_SubRoleAssignmentArtifact() // this example assumes you already have this PublishedBlueprintResource created on azure // for more information of creating PublishedBlueprintResource, please refer to the document of PublishedBlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; string versionId = "V2"; ResourceIdentifier publishedBlueprintResourceId = PublishedBlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName, versionId); @@ -569,21 +537,29 @@ public async Task Get_SubRoleAssignmentArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "ownerAssignment"; - BlueprintVersionArtifactResource result = await collection.GetAsync(artifactName); + string artifactName = "costCenterPolicy"; + NullableResponse response = await collection.GetIfExistsAsync(artifactName); + BlueprintVersionArtifactResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ArtifactData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SubRoleAssignmentArtifact() + public async Task GetIfExists_MGRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedRoleAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedRoleAssignmentArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -593,7 +569,7 @@ public async Task Exists_SubRoleAssignmentArtifact() // this example assumes you already have this PublishedBlueprintResource created on azure // for more information of creating PublishedBlueprintResource, please refer to the document of PublishedBlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; string versionId = "V2"; ResourceIdentifier publishedBlueprintResourceId = PublishedBlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName, versionId); @@ -604,16 +580,28 @@ public async Task Exists_SubRoleAssignmentArtifact() // invoke the operation string artifactName = "ownerAssignment"; - bool result = await collection.ExistsAsync(artifactName); + NullableResponse response = await collection.GetIfExistsAsync(artifactName); + BlueprintVersionArtifactResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ArtifactData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SubRoleAssignmentArtifact() + public async Task GetIfExists_SubARMTemplateArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedRoleAssignmentArtifact_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedARMTemplateArtifact_Get.json // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -633,7 +621,7 @@ public async Task GetIfExists_SubRoleAssignmentArtifact() BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); // invoke the operation - string artifactName = "ownerAssignment"; + string artifactName = "storageTemplate"; NullableResponse response = await collection.GetIfExistsAsync(artifactName); BlueprintVersionArtifactResource result = response.HasValue ? response.Value : null; @@ -653,10 +641,10 @@ public async Task GetIfExists_SubRoleAssignmentArtifact() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MGArtifactList() + public async Task GetIfExists_SubPolicyAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedArtifact_List.json - // this example is just showing the usage of "PublishedArtifacts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedPolicyAssignmentArtifact_Get.json + // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -665,7 +653,7 @@ public async Task GetAll_MGArtifactList() // this example assumes you already have this PublishedBlueprintResource created on azure // for more information of creating PublishedBlueprintResource, please refer to the document of PublishedBlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; string versionId = "V2"; ResourceIdentifier publishedBlueprintResourceId = PublishedBlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName, versionId); @@ -674,25 +662,31 @@ public async Task GetAll_MGArtifactList() // get the collection of this BlueprintVersionArtifactResource BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); - // invoke the operation and iterate over the result - await foreach (BlueprintVersionArtifactResource item in collection.GetAllAsync()) + // invoke the operation + string artifactName = "costCenterPolicy"; + NullableResponse response = await collection.GetIfExistsAsync(artifactName); + BlueprintVersionArtifactResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ArtifactData resourceData = item.Data; + ArtifactData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SubArtifactList() + public async Task GetIfExists_SubRoleAssignmentArtifact() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedArtifact_List.json - // this example is just showing the usage of "PublishedArtifacts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedRoleAssignmentArtifact_Get.json + // this example is just showing the usage of "PublishedArtifacts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -710,17 +704,23 @@ public async Task GetAll_SubArtifactList() // get the collection of this BlueprintVersionArtifactResource BlueprintVersionArtifactCollection collection = publishedBlueprint.GetBlueprintVersionArtifacts(); - // invoke the operation and iterate over the result - await foreach (BlueprintVersionArtifactResource item in collection.GetAllAsync()) + // invoke the operation + string artifactName = "ownerAssignment"; + NullableResponse response = await collection.GetIfExistsAsync(artifactName); + BlueprintVersionArtifactResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ArtifactData resourceData = item.Data; + ArtifactData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_PublishedBlueprintCollection.cs b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_PublishedBlueprintCollection.cs index db56cb20a6516..1b3ddd3258905 100644 --- a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_PublishedBlueprintCollection.cs +++ b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_PublishedBlueprintCollection.cs @@ -120,9 +120,9 @@ public async Task Get_PublishedManagementGroupBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PublishedManagementGroupBlueprint() + public async Task Get_PublishedSubscriptionBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedBlueprint_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedBlueprint_Get.json // this example is just showing the usage of "PublishedBlueprints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -132,7 +132,7 @@ public async Task Exists_PublishedManagementGroupBlueprint() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; + string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -142,14 +142,18 @@ public async Task Exists_PublishedManagementGroupBlueprint() // invoke the operation string versionId = "v2"; - bool result = await collection.ExistsAsync(versionId); + PublishedBlueprintResource result = await collection.GetAsync(versionId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublishedBlueprintData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PublishedManagementGroupBlueprint() + public async Task Exists_PublishedManagementGroupBlueprint() { // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedBlueprint_Get.json // this example is just showing the usage of "PublishedBlueprints_Get" operation, for the dependent resources, they will have to be created separately. @@ -171,26 +175,14 @@ public async Task GetIfExists_PublishedManagementGroupBlueprint() // invoke the operation string versionId = "v2"; - NullableResponse response = await collection.GetIfExistsAsync(versionId); - PublishedBlueprintResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(versionId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublishedBlueprintData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PublishedSubscriptionBlueprint() + public async Task Exists_PublishedSubscriptionBlueprint() { // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedBlueprint_Get.json // this example is just showing the usage of "PublishedBlueprints_Get" operation, for the dependent resources, they will have to be created separately. @@ -212,20 +204,16 @@ public async Task Get_PublishedSubscriptionBlueprint() // invoke the operation string versionId = "v2"; - PublishedBlueprintResource result = await collection.GetAsync(versionId); + bool result = await collection.ExistsAsync(versionId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublishedBlueprintData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PublishedSubscriptionBlueprint() + public async Task GetIfExists_PublishedManagementGroupBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedBlueprint_Get.json + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedBlueprint_Get.json // this example is just showing the usage of "PublishedBlueprints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -235,7 +223,7 @@ public async Task Exists_PublishedSubscriptionBlueprint() // this example assumes you already have this BlueprintResource created on azure // for more information of creating BlueprintResource, please refer to the document of BlueprintResource - string resourceScope = "subscriptions/00000000-0000-0000-0000-000000000000"; + string resourceScope = "providers/Microsoft.Management/managementGroups/ContosoOnlineGroup"; string blueprintName = "simpleBlueprint"; ResourceIdentifier blueprintResourceId = BlueprintResource.CreateResourceIdentifier(resourceScope, blueprintName); BlueprintResource blueprint = client.GetBlueprintResource(blueprintResourceId); @@ -245,9 +233,21 @@ public async Task Exists_PublishedSubscriptionBlueprint() // invoke the operation string versionId = "v2"; - bool result = await collection.ExistsAsync(versionId); + NullableResponse response = await collection.GetIfExistsAsync(versionId); + PublishedBlueprintResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublishedBlueprintData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_PublishedBlueprintResource.cs b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_PublishedBlueprintResource.cs index 8dea0505b122d..75d3ab06228ee 100644 --- a/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_PublishedBlueprintResource.cs +++ b/sdk/blueprint/Azure.ResourceManager.Blueprint/samples/Generated/Samples/Sample_PublishedBlueprintResource.cs @@ -17,10 +17,10 @@ public partial class Sample_PublishedBlueprintResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PublishedManagementGroupBlueprintPublish() + public async Task Get_PublishedManagementGroupBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedBlueprint_Publish.json - // this example is just showing the usage of "PublishedBlueprints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedBlueprint_Get.json + // this example is just showing the usage of "PublishedBlueprints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,9 +36,7 @@ public async Task Update_PublishedManagementGroupBlueprintPublish() PublishedBlueprintResource publishedBlueprint = client.GetPublishedBlueprintResource(publishedBlueprintResourceId); // invoke the operation - PublishedBlueprintData data = new PublishedBlueprintData(); - ArmOperation lro = await publishedBlueprint.UpdateAsync(WaitUntil.Completed, data); - PublishedBlueprintResource result = lro.Value; + PublishedBlueprintResource result = await publishedBlueprint.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,10 +47,10 @@ public async Task Update_PublishedManagementGroupBlueprintPublish() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PublishedSubscriptionBlueprintPublish() + public async Task Get_PublishedSubscriptionBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedBlueprint_Publish.json - // this example is just showing the usage of "PublishedBlueprints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedBlueprint_Get.json + // this example is just showing the usage of "PublishedBlueprints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,9 +66,7 @@ public async Task Update_PublishedSubscriptionBlueprintPublish() PublishedBlueprintResource publishedBlueprint = client.GetPublishedBlueprintResource(publishedBlueprintResourceId); // invoke the operation - PublishedBlueprintData data = new PublishedBlueprintData(); - ArmOperation lro = await publishedBlueprint.UpdateAsync(WaitUntil.Completed, data); - PublishedBlueprintResource result = lro.Value; + PublishedBlueprintResource result = await publishedBlueprint.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +77,10 @@ public async Task Update_PublishedSubscriptionBlueprintPublish() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PublishedManagementGroupBlueprint() + public async Task Delete_PublishedManagementGroupBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedBlueprint_Get.json - // this example is just showing the usage of "PublishedBlueprints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedBlueprint_Delete.json + // this example is just showing the usage of "PublishedBlueprints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +96,8 @@ public async Task Get_PublishedManagementGroupBlueprint() PublishedBlueprintResource publishedBlueprint = client.GetPublishedBlueprintResource(publishedBlueprintResourceId); // invoke the operation - PublishedBlueprintResource result = await publishedBlueprint.GetAsync(); + ArmOperation lro = await publishedBlueprint.DeleteAsync(WaitUntil.Completed); + PublishedBlueprintResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -111,10 +108,10 @@ public async Task Get_PublishedManagementGroupBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PublishedSubscriptionBlueprint() + public async Task Delete_PublishedSubscriptionBlueprint() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedBlueprint_Get.json - // this example is just showing the usage of "PublishedBlueprints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedBlueprint_Delete.json + // this example is just showing the usage of "PublishedBlueprints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,7 +127,8 @@ public async Task Get_PublishedSubscriptionBlueprint() PublishedBlueprintResource publishedBlueprint = client.GetPublishedBlueprintResource(publishedBlueprintResourceId); // invoke the operation - PublishedBlueprintResource result = await publishedBlueprint.GetAsync(); + ArmOperation lro = await publishedBlueprint.DeleteAsync(WaitUntil.Completed); + PublishedBlueprintResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -141,10 +139,10 @@ public async Task Get_PublishedSubscriptionBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PublishedManagementGroupBlueprint() + public async Task Update_PublishedManagementGroupBlueprintPublish() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedBlueprint_Delete.json - // this example is just showing the usage of "PublishedBlueprints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/managementGroupBPDef/SealedBlueprint_Publish.json + // this example is just showing the usage of "PublishedBlueprints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -160,7 +158,8 @@ public async Task Delete_PublishedManagementGroupBlueprint() PublishedBlueprintResource publishedBlueprint = client.GetPublishedBlueprintResource(publishedBlueprintResourceId); // invoke the operation - ArmOperation lro = await publishedBlueprint.DeleteAsync(WaitUntil.Completed); + PublishedBlueprintData data = new PublishedBlueprintData(); + ArmOperation lro = await publishedBlueprint.UpdateAsync(WaitUntil.Completed, data); PublishedBlueprintResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -172,10 +171,10 @@ public async Task Delete_PublishedManagementGroupBlueprint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PublishedSubscriptionBlueprint() + public async Task Update_PublishedSubscriptionBlueprintPublish() { - // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedBlueprint_Delete.json - // this example is just showing the usage of "PublishedBlueprints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/blueprint/resource-manager/Microsoft.Blueprint/preview/2018-11-01-preview/examples/subscriptionBPDef/SealedBlueprint_Publish.json + // this example is just showing the usage of "PublishedBlueprints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,7 +190,8 @@ public async Task Delete_PublishedSubscriptionBlueprint() PublishedBlueprintResource publishedBlueprint = client.GetPublishedBlueprintResource(publishedBlueprintResourceId); // invoke the operation - ArmOperation lro = await publishedBlueprint.DeleteAsync(WaitUntil.Completed); + PublishedBlueprintData data = new PublishedBlueprintData(); + ArmOperation lro = await publishedBlueprint.UpdateAsync(WaitUntil.Completed, data); PublishedBlueprintResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well diff --git a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotChannelCollection.cs b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotChannelCollection.cs index e592f04a0f7b2..b955034b5ce66 100644 --- a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotChannelCollection.cs +++ b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotChannelCollection.cs @@ -43,7 +43,7 @@ public async Task CreateOrUpdate_CreateAlexaChannel() BotChannelName channelName = BotChannelName.AlexaChannel; BotChannelData data = new BotChannelData(new AzureLocation("global")) { - Properties = new AlexaChannel() + Properties = new AlexaChannel { Properties = new AlexaChannelProperties("XAlexaSkillIdX", true), }, @@ -85,7 +85,7 @@ public async Task CreateOrUpdate_CreateChannel() BotChannelName channelName = BotChannelName.EmailChannel; BotChannelData data = new BotChannelData(new AzureLocation("global")) { - Properties = new EmailChannel() + Properties = new EmailChannel { Properties = new EmailChannelProperties("a@b.com", true) { @@ -130,9 +130,9 @@ public async Task CreateOrUpdate_CreateDirectLineSpeechChannel() BotChannelName channelName = BotChannelName.DirectLineSpeechChannel; BotChannelData data = new BotChannelData(new AzureLocation("global")) { - Properties = new DirectLineSpeechChannel() + Properties = new DirectLineSpeechChannel { - Properties = new DirectLineSpeechChannelProperties() + Properties = new DirectLineSpeechChannelProperties { CognitiveServiceRegion = "XcognitiveServiceRegionX", CognitiveServiceSubscriptionKey = "XcognitiveServiceSubscriptionKeyX", @@ -177,7 +177,7 @@ public async Task CreateOrUpdate_CreateEmailChannel() BotChannelName channelName = BotChannelName.EmailChannel; BotChannelData data = new BotChannelData(new AzureLocation("global")) { - Properties = new EmailChannel() + Properties = new EmailChannel { Properties = new EmailChannelProperties("a@b.com", true) { @@ -223,11 +223,11 @@ public async Task CreateOrUpdate_CreateLineChannel() BotChannelName channelName = BotChannelName.LineChannel; BotChannelData data = new BotChannelData(new AzureLocation("global")) { - Properties = new LineChannel() + Properties = new LineChannel { Properties = new LineChannelProperties(new LineRegistration[] { -new LineRegistration() +new LineRegistration { ChannelSecret = "channelSecret", ChannelAccessToken = "channelAccessToken", @@ -281,9 +281,9 @@ public async Task Get_GetAlexaChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAlexaChannel() + public async Task Get_GetChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetAlexaChannel.json + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -303,17 +303,21 @@ public async Task Exists_GetAlexaChannel() BotChannelCollection collection = bot.GetBotChannels(); // invoke the operation - BotChannelName channelName = BotChannelName.AlexaChannel; - bool result = await collection.ExistsAsync(channelName); + BotChannelName channelName = BotChannelName.EmailChannel; + BotChannelResource result = await collection.GetAsync(channelName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotChannelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAlexaChannel() + public async Task Get_GetDirectLineSpeechChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetAlexaChannel.json + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetDirectLineSpeechChannel.json // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -333,29 +337,21 @@ public async Task GetIfExists_GetAlexaChannel() BotChannelCollection collection = bot.GetBotChannels(); // invoke the operation - BotChannelName channelName = BotChannelName.AlexaChannel; - NullableResponse response = await collection.GetIfExistsAsync(channelName); - BotChannelResource result = response.HasValue ? response.Value : null; + BotChannelName channelName = BotChannelName.DirectLineSpeechChannel; + BotChannelResource result = await collection.GetAsync(channelName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotChannelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotChannelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetChannel() + public async Task Get_GetLineChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -375,7 +371,7 @@ public async Task Get_GetChannel() BotChannelCollection collection = bot.GetBotChannels(); // invoke the operation - BotChannelName channelName = BotChannelName.EmailChannel; + BotChannelName channelName = BotChannelName.LineChannel; BotChannelResource result = await collection.GetAsync(channelName); // the variable result is a resource, you could call other operations on this instance as well @@ -387,10 +383,10 @@ public async Task Get_GetChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetChannel() + public async Task GetAll_ListChannelsByResourceGroup() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json - // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListChannelsByBotService.json + // this example is just showing the usage of "Channels_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -408,18 +404,24 @@ public async Task Exists_GetChannel() // get the collection of this BotChannelResource BotChannelCollection collection = bot.GetBotChannels(); - // invoke the operation - BotChannelName channelName = BotChannelName.EmailChannel; - bool result = await collection.ExistsAsync(channelName); + // invoke the operation and iterate over the result + await foreach (BotChannelResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotChannelData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetChannel() + public async Task Exists_GetAlexaChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetAlexaChannel.json // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -439,29 +441,17 @@ public async Task GetIfExists_GetChannel() BotChannelCollection collection = bot.GetBotChannels(); // invoke the operation - BotChannelName channelName = BotChannelName.EmailChannel; - NullableResponse response = await collection.GetIfExistsAsync(channelName); - BotChannelResource result = response.HasValue ? response.Value : null; + BotChannelName channelName = BotChannelName.AlexaChannel; + bool result = await collection.ExistsAsync(channelName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotChannelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDirectLineSpeechChannel() + public async Task Exists_GetChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetDirectLineSpeechChannel.json + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -481,14 +471,10 @@ public async Task Get_GetDirectLineSpeechChannel() BotChannelCollection collection = bot.GetBotChannels(); // invoke the operation - BotChannelName channelName = BotChannelName.DirectLineSpeechChannel; - BotChannelResource result = await collection.GetAsync(channelName); + BotChannelName channelName = BotChannelName.EmailChannel; + bool result = await collection.ExistsAsync(channelName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotChannelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -523,9 +509,9 @@ public async Task Exists_GetDirectLineSpeechChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDirectLineSpeechChannel() + public async Task Exists_GetLineChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetDirectLineSpeechChannel.json + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -545,29 +531,17 @@ public async Task GetIfExists_GetDirectLineSpeechChannel() BotChannelCollection collection = bot.GetBotChannels(); // invoke the operation - BotChannelName channelName = BotChannelName.DirectLineSpeechChannel; - NullableResponse response = await collection.GetIfExistsAsync(channelName); - BotChannelResource result = response.HasValue ? response.Value : null; + BotChannelName channelName = BotChannelName.LineChannel; + bool result = await collection.ExistsAsync(channelName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotChannelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetLineChannel() + public async Task GetIfExists_GetAlexaChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetAlexaChannel.json // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -587,21 +561,29 @@ public async Task Get_GetLineChannel() BotChannelCollection collection = bot.GetBotChannels(); // invoke the operation - BotChannelName channelName = BotChannelName.LineChannel; - BotChannelResource result = await collection.GetAsync(channelName); + BotChannelName channelName = BotChannelName.AlexaChannel; + NullableResponse response = await collection.GetIfExistsAsync(channelName); + BotChannelResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotChannelData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotChannelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetLineChannel() + public async Task GetIfExists_GetChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -621,17 +603,29 @@ public async Task Exists_GetLineChannel() BotChannelCollection collection = bot.GetBotChannels(); // invoke the operation - BotChannelName channelName = BotChannelName.LineChannel; - bool result = await collection.ExistsAsync(channelName); + BotChannelName channelName = BotChannelName.EmailChannel; + NullableResponse response = await collection.GetIfExistsAsync(channelName); + BotChannelResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotChannelData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetLineChannel() + public async Task GetIfExists_GetDirectLineSpeechChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetDirectLineSpeechChannel.json // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -651,7 +645,7 @@ public async Task GetIfExists_GetLineChannel() BotChannelCollection collection = bot.GetBotChannels(); // invoke the operation - BotChannelName channelName = BotChannelName.LineChannel; + BotChannelName channelName = BotChannelName.DirectLineSpeechChannel; NullableResponse response = await collection.GetIfExistsAsync(channelName); BotChannelResource result = response.HasValue ? response.Value : null; @@ -671,10 +665,10 @@ public async Task GetIfExists_GetLineChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListChannelsByResourceGroup() + public async Task GetIfExists_GetLineChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListChannelsByBotService.json - // this example is just showing the usage of "Channels_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json + // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -692,17 +686,23 @@ public async Task GetAll_ListChannelsByResourceGroup() // get the collection of this BotChannelResource BotChannelCollection collection = bot.GetBotChannels(); - // invoke the operation and iterate over the result - await foreach (BotChannelResource item in collection.GetAllAsync()) + // invoke the operation + BotChannelName channelName = BotChannelName.LineChannel; + NullableResponse response = await collection.GetIfExistsAsync(channelName); + BotChannelResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BotChannelData resourceData = item.Data; + BotChannelData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotChannelResource.cs b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotChannelResource.cs index 5a6a349b243c4..977516519f7cd 100644 --- a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotChannelResource.cs +++ b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotChannelResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BotChannelResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAlexaChannel() + public async Task Get_GetAlexaChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateAlexaChannel.json - // this example is just showing the usage of "Channels_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetAlexaChannel.json + // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,14 +38,7 @@ public async Task Update_UpdateAlexaChannel() BotChannelResource botChannel = client.GetBotChannelResource(botChannelResourceId); // invoke the operation - BotChannelData data = new BotChannelData(new AzureLocation("global")) - { - Properties = new AlexaChannel() - { - Properties = new AlexaChannelProperties("XAlexaSkillIdX", true), - }, - }; - BotChannelResource result = await botChannel.UpdateAsync(data); + BotChannelResource result = await botChannel.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -56,10 +49,10 @@ public async Task Update_UpdateAlexaChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateChannel() + public async Task Get_GetChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateChannel.json - // this example is just showing the usage of "Channels_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json + // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,17 +69,7 @@ public async Task Update_UpdateChannel() BotChannelResource botChannel = client.GetBotChannelResource(botChannelResourceId); // invoke the operation - BotChannelData data = new BotChannelData(new AzureLocation("global")) - { - Properties = new EmailChannel() - { - Properties = new EmailChannelProperties("a@b.com", true) - { - Password = "pwd", - }, - }, - }; - BotChannelResource result = await botChannel.UpdateAsync(data); + BotChannelResource result = await botChannel.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -97,10 +80,10 @@ public async Task Update_UpdateChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateDirectLineSpeechChannel() + public async Task Get_GetDirectLineSpeechChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateDirectLineSpeechChannel.json - // this example is just showing the usage of "Channels_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetDirectLineSpeechChannel.json + // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,19 +100,7 @@ public async Task Update_UpdateDirectLineSpeechChannel() BotChannelResource botChannel = client.GetBotChannelResource(botChannelResourceId); // invoke the operation - BotChannelData data = new BotChannelData(new AzureLocation("global")) - { - Properties = new DirectLineSpeechChannel() - { - Properties = new DirectLineSpeechChannelProperties() - { - CognitiveServiceRegion = "XcognitiveServiceRegionX", - CognitiveServiceSubscriptionKey = "XcognitiveServiceSubscriptionKeyX", - IsEnabled = true, - }, - }, - }; - BotChannelResource result = await botChannel.UpdateAsync(data); + BotChannelResource result = await botChannel.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -140,10 +111,10 @@ public async Task Update_UpdateDirectLineSpeechChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateLineChannel() + public async Task Get_GetLineChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateLineChannel.json - // this example is just showing the usage of "Channels_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json + // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -160,21 +131,7 @@ public async Task Update_UpdateLineChannel() BotChannelResource botChannel = client.GetBotChannelResource(botChannelResourceId); // invoke the operation - BotChannelData data = new BotChannelData(new AzureLocation("global")) - { - Properties = new LineChannel() - { - Properties = new LineChannelProperties(new LineRegistration[] - { -new LineRegistration() -{ -ChannelSecret = "channelSecret", -ChannelAccessToken = "channelAccessToken", -} - }), - }, - }; - BotChannelResource result = await botChannel.UpdateAsync(data); + BotChannelResource result = await botChannel.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -239,10 +196,10 @@ public async Task Delete_DeleteDirectLineSpeechChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAlexaChannel() + public async Task Update_UpdateAlexaChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetAlexaChannel.json - // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateAlexaChannel.json + // this example is just showing the usage of "Channels_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -259,7 +216,14 @@ public async Task Get_GetAlexaChannel() BotChannelResource botChannel = client.GetBotChannelResource(botChannelResourceId); // invoke the operation - BotChannelResource result = await botChannel.GetAsync(); + BotChannelData data = new BotChannelData(new AzureLocation("global")) + { + Properties = new AlexaChannel + { + Properties = new AlexaChannelProperties("XAlexaSkillIdX", true), + }, + }; + BotChannelResource result = await botChannel.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -270,10 +234,10 @@ public async Task Get_GetAlexaChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetChannel() + public async Task Update_UpdateChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetChannel.json - // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateChannel.json + // this example is just showing the usage of "Channels_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -290,7 +254,17 @@ public async Task Get_GetChannel() BotChannelResource botChannel = client.GetBotChannelResource(botChannelResourceId); // invoke the operation - BotChannelResource result = await botChannel.GetAsync(); + BotChannelData data = new BotChannelData(new AzureLocation("global")) + { + Properties = new EmailChannel + { + Properties = new EmailChannelProperties("a@b.com", true) + { + Password = "pwd", + }, + }, + }; + BotChannelResource result = await botChannel.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -301,10 +275,10 @@ public async Task Get_GetChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDirectLineSpeechChannel() + public async Task Update_UpdateDirectLineSpeechChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetDirectLineSpeechChannel.json - // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateDirectLineSpeechChannel.json + // this example is just showing the usage of "Channels_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -321,7 +295,19 @@ public async Task Get_GetDirectLineSpeechChannel() BotChannelResource botChannel = client.GetBotChannelResource(botChannelResourceId); // invoke the operation - BotChannelResource result = await botChannel.GetAsync(); + BotChannelData data = new BotChannelData(new AzureLocation("global")) + { + Properties = new DirectLineSpeechChannel + { + Properties = new DirectLineSpeechChannelProperties + { + CognitiveServiceRegion = "XcognitiveServiceRegionX", + CognitiveServiceSubscriptionKey = "XcognitiveServiceSubscriptionKeyX", + IsEnabled = true, + }, + }, + }; + BotChannelResource result = await botChannel.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -332,10 +318,10 @@ public async Task Get_GetDirectLineSpeechChannel() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetLineChannel() + public async Task Update_UpdateLineChannel() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetLineChannel.json - // this example is just showing the usage of "Channels_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateLineChannel.json + // this example is just showing the usage of "Channels_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -352,7 +338,21 @@ public async Task Get_GetLineChannel() BotChannelResource botChannel = client.GetBotChannelResource(botChannelResourceId); // invoke the operation - BotChannelResource result = await botChannel.GetAsync(); + BotChannelData data = new BotChannelData(new AzureLocation("global")) + { + Properties = new LineChannel + { + Properties = new LineChannelProperties(new LineRegistration[] + { +new LineRegistration +{ +ChannelSecret = "channelSecret", +ChannelAccessToken = "channelAccessToken", +} + }), + }, + }; + BotChannelResource result = await botChannel.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotCollection.cs b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotCollection.cs index 9d0c4a9956e28..10bc0f645329c 100644 --- a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotCollection.cs +++ b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotCollection.cs @@ -53,10 +53,7 @@ public async Task CreateOrUpdate_CreateBot() DeveloperAppInsightKey = "appinsightskey", DeveloperAppInsightsApiKey = "appinsightsapikey", DeveloperAppInsightsApplicationId = "appinsightsappid", - LuisAppIds = -{ -"luisappid1","luisappid2" -}, + LuisAppIds = { "luisappid1", "luisappid2" }, LuisKey = "luiskey", IsCmekEnabled = true, CmekKeyVaultUri = new Uri("https://myCmekKey"), @@ -70,7 +67,7 @@ public async Task CreateOrUpdate_CreateBot() Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -118,10 +115,10 @@ public async Task Get_GetBot() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetBot() + public async Task GetAll_ListBotsByResourceGroup() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetBot.json - // this example is just showing the usage of "Bots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListBotsByResourceGroup.json + // this example is just showing the usage of "Bots_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,16 +135,22 @@ public async Task Exists_GetBot() // get the collection of this BotResource BotCollection collection = resourceGroupResource.GetBots(); - // invoke the operation - string resourceName = "samplebotname"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (BotResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetBot() + public async Task Exists_GetBot() { // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetBot.json // this example is just showing the usage of "Bots_Get" operation, for the dependent resources, they will have to be created separately. @@ -169,29 +172,17 @@ public async Task GetIfExists_GetBot() // invoke the operation string resourceName = "samplebotname"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - BotResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBotsByResourceGroup() + public async Task GetIfExists_GetBot() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListBotsByResourceGroup.json - // this example is just showing the usage of "Bots_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetBot.json + // this example is just showing the usage of "Bots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -208,17 +199,23 @@ public async Task GetAll_ListBotsByResourceGroup() // get the collection of this BotResource BotCollection collection = resourceGroupResource.GetBots(); - // invoke the operation and iterate over the result - await foreach (BotResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "samplebotname"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + BotResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BotData resourceData = item.Data; + BotData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotConnectionSettingCollection.cs b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotConnectionSettingCollection.cs index 8631d2c3bab27..2b61729e928ff 100644 --- a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotConnectionSettingCollection.cs +++ b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotConnectionSettingCollection.cs @@ -43,24 +43,21 @@ public async Task CreateOrUpdate_CreateConnectionSetting() string connectionName = "sampleConnection"; BotConnectionSettingData data = new BotConnectionSettingData(new AzureLocation("West US")) { - Properties = new BotConnectionSettingProperties() + Properties = new BotConnectionSettingProperties { ClientId = "sampleclientid", ClientSecret = "samplesecret", Scopes = "samplescope", ServiceProviderId = "serviceproviderid", - Parameters = -{ -new BotConnectionSettingParameter() + Parameters = {new BotConnectionSettingParameter { Key = "key1", Value = "value1", -},new BotConnectionSettingParameter() +}, new BotConnectionSettingParameter { Key = "key2", Value = "value2", -} -}, +}}, }, ETag = new ETag("etag1"), }; @@ -110,10 +107,10 @@ public async Task Get_GetConnectionSetting() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetConnectionSetting() + public async Task GetAll_ListConnectionSettings() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetConnection.json - // this example is just showing the usage of "BotConnection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListConnectionsByBotService.json + // this example is just showing the usage of "BotConnection_ListByBotService" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -131,16 +128,22 @@ public async Task Exists_GetConnectionSetting() // get the collection of this BotConnectionSettingResource BotConnectionSettingCollection collection = bot.GetBotConnectionSettings(); - // invoke the operation - string connectionName = "sampleConnection"; - bool result = await collection.ExistsAsync(connectionName); + // invoke the operation and iterate over the result + await foreach (BotConnectionSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotConnectionSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetConnectionSetting() + public async Task Exists_GetConnectionSetting() { // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetConnection.json // this example is just showing the usage of "BotConnection_Get" operation, for the dependent resources, they will have to be created separately. @@ -163,29 +166,17 @@ public async Task GetIfExists_GetConnectionSetting() // invoke the operation string connectionName = "sampleConnection"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - BotConnectionSettingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(connectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotConnectionSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConnectionSettings() + public async Task GetIfExists_GetConnectionSetting() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListConnectionsByBotService.json - // this example is just showing the usage of "BotConnection_ListByBotService" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetConnection.json + // this example is just showing the usage of "BotConnection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -203,17 +194,23 @@ public async Task GetAll_ListConnectionSettings() // get the collection of this BotConnectionSettingResource BotConnectionSettingCollection collection = bot.GetBotConnectionSettings(); - // invoke the operation and iterate over the result - await foreach (BotConnectionSettingResource item in collection.GetAllAsync()) + // invoke the operation + string connectionName = "sampleConnection"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + BotConnectionSettingResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BotConnectionSettingData resourceData = item.Data; + BotConnectionSettingData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotConnectionSettingResource.cs b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotConnectionSettingResource.cs index e98b8e2e0c9b5..e33931188f274 100644 --- a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotConnectionSettingResource.cs +++ b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotConnectionSettingResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.BotService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.BotService.Samples @@ -19,37 +18,41 @@ public partial class Sample_BotConnectionSettingResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetBotConnectionServiceProviders_ListAuthServiceProviders() + public async Task Get_GetConnectionSetting() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListServiceProviders.json - // this example is just showing the usage of "BotConnection_ListServiceProviders" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetConnection.json + // this example is just showing the usage of "BotConnection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this BotConnectionSettingResource created on azure + // for more information of creating BotConnectionSettingResource, please refer to the document of BotConnectionSettingResource string subscriptionId = "subscription-id"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "OneResourceGroupName"; + string resourceName = "samplebotname"; + string connectionName = "sampleConnection"; + ResourceIdentifier botConnectionSettingResourceId = BotConnectionSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, connectionName); + BotConnectionSettingResource botConnectionSetting = client.GetBotConnectionSettingResource(botConnectionSettingResourceId); - // invoke the operation and iterate over the result - await foreach (BotServiceProvider item in subscriptionResource.GetBotConnectionServiceProvidersAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + // invoke the operation + BotConnectionSettingResource result = await botConnectionSetting.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotConnectionSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetWithSecrets_ListConnectionSettingWithSecrets() + public async Task Delete_DeleteConnectionSetting() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetConnection.json - // this example is just showing the usage of "BotConnection_ListWithSecrets" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteConnection.json + // this example is just showing the usage of "BotConnection_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,13 +69,9 @@ public async Task GetWithSecrets_ListConnectionSettingWithSecrets() BotConnectionSettingResource botConnectionSetting = client.GetBotConnectionSettingResource(botConnectionSettingResourceId); // invoke the operation - BotConnectionSettingResource result = await botConnectionSetting.GetWithSecretsAsync(); + await botConnectionSetting.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotConnectionSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,25 +98,22 @@ public async Task Update_UpdateConnectionSetting() // invoke the operation BotConnectionSettingData data = new BotConnectionSettingData(new AzureLocation("global")) { - Properties = new BotConnectionSettingProperties() + Properties = new BotConnectionSettingProperties { ClientId = "sampleclientid", ClientSecret = "samplesecret", Scopes = "samplescope", ServiceProviderId = "serviceproviderid", ServiceProviderDisplayName = "serviceProviderDisplayName", - Parameters = -{ -new BotConnectionSettingParameter() + Parameters = {new BotConnectionSettingParameter { Key = "key1", Value = "value1", -},new BotConnectionSettingParameter() +}, new BotConnectionSettingParameter { Key = "key2", Value = "value2", -} -}, +}}, }, ETag = new ETag("etag1"), }; @@ -132,10 +128,10 @@ public async Task Update_UpdateConnectionSetting() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetConnectionSetting() + public async Task GetWithSecrets_ListConnectionSettingWithSecrets() { // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetConnection.json - // this example is just showing the usage of "BotConnection_Get" operation, for the dependent resources, they will have to be created separately. + // this example is just showing the usage of "BotConnection_ListWithSecrets" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -152,7 +148,7 @@ public async Task Get_GetConnectionSetting() BotConnectionSettingResource botConnectionSetting = client.GetBotConnectionSettingResource(botConnectionSettingResourceId); // invoke the operation - BotConnectionSettingResource result = await botConnectionSetting.GetAsync(); + BotConnectionSettingResource result = await botConnectionSetting.GetWithSecretsAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -160,32 +156,5 @@ public async Task Get_GetConnectionSetting() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteConnectionSetting() - { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeleteConnection.json - // this example is just showing the usage of "BotConnection_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BotConnectionSettingResource created on azure - // for more information of creating BotConnectionSettingResource, please refer to the document of BotConnectionSettingResource - string subscriptionId = "subscription-id"; - string resourceGroupName = "OneResourceGroupName"; - string resourceName = "samplebotname"; - string connectionName = "sampleConnection"; - ResourceIdentifier botConnectionSettingResourceId = BotConnectionSettingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, connectionName); - BotConnectionSettingResource botConnectionSetting = client.GetBotConnectionSettingResource(botConnectionSettingResourceId); - - // invoke the operation - await botConnectionSetting.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotResource.cs b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotResource.cs index c5f6d515fd6b7..1432e581299b0 100644 --- a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotResource.cs +++ b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.BotService.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.BotService.Samples @@ -19,10 +18,10 @@ public partial class Sample_BotResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateBot() + public async Task Get_GetBot() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateBot.json - // this example is just showing the usage of "Bots_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetBot.json + // this example is just showing the usage of "Bots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,39 +37,7 @@ public async Task Update_UpdateBot() BotResource bot = client.GetBotResource(botResourceId); // invoke the operation - BotData data = new BotData(new AzureLocation("West US")) - { - Properties = new BotProperties("The Name of the bot", new Uri("http://mybot.coffee"), "msaappid") - { - Description = "The description of the bot", - IconUri = new Uri("http://myicon"), - MsaAppType = BotMsaAppType.UserAssignedMSI, - MsaAppTenantId = "msaapptenantid", - MsaAppMSIResourceId = new ResourceIdentifier("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), - DeveloperAppInsightKey = "appinsightskey", - DeveloperAppInsightsApiKey = "appinsightsapikey", - DeveloperAppInsightsApplicationId = "appinsightsappid", - LuisAppIds = -{ -"luisappid1","luisappid2" -}, - LuisKey = "luiskey", - IsCmekEnabled = true, - CmekKeyVaultUri = new Uri("https://myCmekKey"), - PublicNetworkAccess = BotServicePublicNetworkAccess.Enabled, - IsLocalAuthDisabled = true, - SchemaTransformationVersion = "1.0", - }, - Sku = new BotServiceSku(BotServiceSkuName.S1), - Kind = BotServiceKind.Sdk, - ETag = new ETag("etag1"), - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - BotResource result = await bot.UpdateAsync(data); + BotResource result = await bot.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -107,10 +74,10 @@ public async Task Delete_DeleteBot() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetBot() + public async Task Update_UpdateBot() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetBot.json - // this example is just showing the usage of "Bots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/UpdateBot.json + // this example is just showing the usage of "Bots_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -126,7 +93,36 @@ public async Task Get_GetBot() BotResource bot = client.GetBotResource(botResourceId); // invoke the operation - BotResource result = await bot.GetAsync(); + BotData data = new BotData(new AzureLocation("West US")) + { + Properties = new BotProperties("The Name of the bot", new Uri("http://mybot.coffee"), "msaappid") + { + Description = "The description of the bot", + IconUri = new Uri("http://myicon"), + MsaAppType = BotMsaAppType.UserAssignedMSI, + MsaAppTenantId = "msaapptenantid", + MsaAppMSIResourceId = new ResourceIdentifier("/subscriptions/foo/resourcegroups/bar/providers/microsoft.managedidentity/userassignedidentities/sampleId"), + DeveloperAppInsightKey = "appinsightskey", + DeveloperAppInsightsApiKey = "appinsightsapikey", + DeveloperAppInsightsApplicationId = "appinsightsappid", + LuisAppIds = { "luisappid1", "luisappid2" }, + LuisKey = "luiskey", + IsCmekEnabled = true, + CmekKeyVaultUri = new Uri("https://myCmekKey"), + PublicNetworkAccess = BotServicePublicNetworkAccess.Enabled, + IsLocalAuthDisabled = true, + SchemaTransformationVersion = "1.0", + }, + Sku = new BotServiceSku(BotServiceSkuName.S1), + Kind = BotServiceKind.Sdk, + ETag = new ETag("etag1"), + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + BotResource result = await bot.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -135,64 +131,6 @@ public async Task Get_GetBot() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetBots_ListBotsBySubscription() - { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListBotsBySubscription.json - // this example is just showing the usage of "Bots_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subscription-id"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (BotResource item in subscriptionResource.GetBotsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckBotServiceNameAvailability_CheckNameAvailability() - { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CheckNameAvailability.json - // this example is just showing the usage of "Bots_GetCheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // invoke the operation - BotServiceNameAvailabilityContent content = new BotServiceNameAvailabilityContent() - { - Name = "testbotname", - ResourceType = new ResourceType("string"), - }; - BotServiceNameAvailabilityResult result = await tenantResource.CheckBotServiceNameAvailabilityAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetBotChannelWithRegenerateKeys_RegenerateKeysForDirectLineChannelSite() diff --git a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotServicePrivateEndpointConnectionCollection.cs b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotServicePrivateEndpointConnectionCollection.cs index 6a87c84151dd3..fb863af897c7c 100644 --- a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotServicePrivateEndpointConnectionCollection.cs +++ b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotServicePrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BotServicePrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateEndpointConnections() + public async Task CreateOrUpdate_PutPrivateEndpointConnection() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListPrivateEndpointConnections.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,25 +31,32 @@ public async Task GetAll_ListPrivateEndpointConnections() // this example assumes you already have this BotResource created on azure // for more information of creating BotResource, please refer to the document of BotResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string resourceName = "sto2527"; + string resourceGroupName = "res7687"; + string resourceName = "sto9699"; ResourceIdentifier botResourceId = BotResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); BotResource bot = client.GetBotResource(botResourceId); // get the collection of this BotServicePrivateEndpointConnectionResource BotServicePrivateEndpointConnectionCollection collection = bot.GetBotServicePrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (BotServicePrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "{privateEndpointConnectionName}"; + BotServicePrivateEndpointConnectionData data = new BotServicePrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotServicePrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new BotServicePrivateLinkServiceConnectionState + { + Status = BotServicePrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + BotServicePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateEndpointConnection() + public async Task GetAll_ListPrivateEndpointConnections() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListPrivateEndpointConnections.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_GetPrivateEndpointConnection() // get the collection of this BotServicePrivateEndpointConnectionResource BotServicePrivateEndpointConnectionCollection collection = bot.GetBotServicePrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (BotServicePrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotServicePrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateEndpointConnection() + public async Task Exists_GetPrivateEndpointConnection() { // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_GetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - BotServicePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotServicePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutPrivateEndpointConnection() + public async Task GetIfExists_GetPrivateEndpointConnection() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/GetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -173,8 +174,8 @@ public async Task CreateOrUpdate_PutPrivateEndpointConnection() // this example assumes you already have this BotResource created on azure // for more information of creating BotResource, please refer to the document of BotResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; - string resourceName = "sto9699"; + string resourceGroupName = "res6977"; + string resourceName = "sto2527"; ResourceIdentifier botResourceId = BotResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName); BotResource bot = client.GetBotResource(botResourceId); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_PutPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - BotServicePrivateEndpointConnectionData data = new BotServicePrivateEndpointConnectionData() - { - ConnectionState = new BotServicePrivateLinkServiceConnectionState() - { - Status = BotServicePrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - BotServicePrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + BotServicePrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotServicePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotServicePrivateEndpointConnectionResource.cs b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotServicePrivateEndpointConnectionResource.cs index d9322963590af..5b4f9901494d9 100644 --- a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotServicePrivateEndpointConnectionResource.cs +++ b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_BotServicePrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PutPrivateEndpointConnection() + public async Task Delete_DeletePrivateEndpointConnection() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,37 +62,24 @@ public async Task Update_PutPrivateEndpointConnection() // this example assumes you already have this BotServicePrivateEndpointConnectionResource created on azure // for more information of creating BotServicePrivateEndpointConnectionResource, please refer to the document of BotServicePrivateEndpointConnectionResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res7687"; - string resourceName = "sto9699"; + string resourceGroupName = "res6977"; + string resourceName = "sto2527"; string privateEndpointConnectionName = "{privateEndpointConnectionName}"; ResourceIdentifier botServicePrivateEndpointConnectionResourceId = BotServicePrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, privateEndpointConnectionName); BotServicePrivateEndpointConnectionResource botServicePrivateEndpointConnection = client.GetBotServicePrivateEndpointConnectionResource(botServicePrivateEndpointConnectionResourceId); // invoke the operation - BotServicePrivateEndpointConnectionData data = new BotServicePrivateEndpointConnectionData() - { - ConnectionState = new BotServicePrivateLinkServiceConnectionState() - { - Status = BotServicePrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await botServicePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - BotServicePrivateEndpointConnectionResource result = lro.Value; + await botServicePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BotServicePrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateEndpointConnection() + public async Task Update_PutPrivateEndpointConnection() { - // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/DeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/PutPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateEndpointConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,16 +89,29 @@ public async Task Delete_DeletePrivateEndpointConnection() // this example assumes you already have this BotServicePrivateEndpointConnectionResource created on azure // for more information of creating BotServicePrivateEndpointConnectionResource, please refer to the document of BotServicePrivateEndpointConnectionResource string subscriptionId = "{subscription-id}"; - string resourceGroupName = "res6977"; - string resourceName = "sto2527"; + string resourceGroupName = "res7687"; + string resourceName = "sto9699"; string privateEndpointConnectionName = "{privateEndpointConnectionName}"; ResourceIdentifier botServicePrivateEndpointConnectionResourceId = BotServicePrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, resourceName, privateEndpointConnectionName); BotServicePrivateEndpointConnectionResource botServicePrivateEndpointConnection = client.GetBotServicePrivateEndpointConnectionResource(botServicePrivateEndpointConnectionResourceId); // invoke the operation - await botServicePrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + BotServicePrivateEndpointConnectionData data = new BotServicePrivateEndpointConnectionData + { + ConnectionState = new BotServicePrivateLinkServiceConnectionState + { + Status = BotServicePrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await botServicePrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + BotServicePrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotServicePrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 242e8c4fbb22b..fba99f5674d03 100644 --- a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,64 @@ namespace Azure.ResourceManager.BotService.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetBots_ListBotsBySubscription() + { + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListBotsBySubscription.json + // this example is just showing the usage of "Bots_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subscription-id"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (BotResource item in subscriptionResource.GetBotsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetBotConnectionServiceProviders_ListAuthServiceProviders() + { + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/ListServiceProviders.json + // this example is just showing the usage of "BotConnection_ListServiceProviders" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subscription-id"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (BotServiceProvider item in subscriptionResource.GetBotConnectionServiceProvidersAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetBotServiceQnAMakerEndpointKey_ListQnAMakerEndpointKeys() @@ -36,7 +94,7 @@ public async Task GetBotServiceQnAMakerEndpointKey_ListQnAMakerEndpointKeys() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - GetBotServiceQnAMakerEndpointKeyContent content = new GetBotServiceQnAMakerEndpointKeyContent() + GetBotServiceQnAMakerEndpointKeyContent content = new GetBotServiceQnAMakerEndpointKeyContent { Hostname = "https://xxx.cognitiveservices.azure.com/", Authkey = "testAuthKey", diff --git a/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_TenantResourceExtensions.cs new file mode 100644 index 0000000000000..5c443b3823232 --- /dev/null +++ b/sdk/botservice/Azure.ResourceManager.BotService/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.BotService.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.BotService.Samples +{ + public partial class Sample_TenantResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckBotServiceNameAvailability_CheckNameAvailability() + { + // Generated from example definition: specification/botservice/resource-manager/Microsoft.BotService/stable/2022-09-15/examples/CheckNameAvailability.json + // this example is just showing the usage of "Bots_GetCheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // invoke the operation + BotServiceNameAvailabilityContent content = new BotServiceNameAvailabilityContent + { + Name = "testbotname", + ResourceType = new ResourceType("string"), + }; + BotServiceNameAvailabilityResult result = await tenantResource.CheckBotServiceNameAvailabilityAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnCustomDomainCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnCustomDomainCollection.cs index 64b09c04ef7d3..c463fa82f17bf 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnCustomDomainCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnCustomDomainCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CdnCustomDomainCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CustomDomainsListByEndpoint() + public async Task CreateOrUpdate_CustomDomainsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_ListByEndpoint.json - // this example is just showing the usage of "CdnCustomDomains_ListByEndpoint" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Create.json + // this example is just showing the usage of "CdnCustomDomains_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_CustomDomainsListByEndpoint() // get the collection of this CdnCustomDomainResource CdnCustomDomainCollection collection = cdnEndpoint.GetCdnCustomDomains(); - // invoke the operation and iterate over the result - await foreach (CdnCustomDomainResource item in collection.GetAllAsync()) + // invoke the operation + string customDomainName = "www-someDomain-net"; + CdnCustomDomainCreateOrUpdateContent content = new CdnCustomDomainCreateOrUpdateContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnCustomDomainData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HostName = "www.someDomain.net", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, customDomainName, content); + CdnCustomDomainResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +93,10 @@ public async Task Get_CustomDomainsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_CustomDomainsGet() + public async Task GetAll_CustomDomainsListByEndpoint() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Get.json - // this example is just showing the usage of "CdnCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_ListByEndpoint.json + // this example is just showing the usage of "CdnCustomDomains_ListByEndpoint" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +115,22 @@ public async Task Exists_CustomDomainsGet() // get the collection of this CdnCustomDomainResource CdnCustomDomainCollection collection = cdnEndpoint.GetCdnCustomDomains(); - // invoke the operation - string customDomainName = "www-someDomain-net"; - bool result = await collection.ExistsAsync(customDomainName); + // invoke the operation and iterate over the result + await foreach (CdnCustomDomainResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnCustomDomainData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_CustomDomainsGet() + public async Task Exists_CustomDomainsGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Get.json // this example is just showing the usage of "CdnCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +154,17 @@ public async Task GetIfExists_CustomDomainsGet() // invoke the operation string customDomainName = "www-someDomain-net"; - NullableResponse response = await collection.GetIfExistsAsync(customDomainName); - CdnCustomDomainResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(customDomainName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CustomDomainsCreate() + public async Task GetIfExists_CustomDomainsGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Create.json - // this example is just showing the usage of "CdnCustomDomains_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Get.json + // this example is just showing the usage of "CdnCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,18 +185,21 @@ public async Task CreateOrUpdate_CustomDomainsCreate() // invoke the operation string customDomainName = "www-someDomain-net"; - CdnCustomDomainCreateOrUpdateContent content = new CdnCustomDomainCreateOrUpdateContent() - { - HostName = "www.someDomain.net", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, customDomainName, content); - CdnCustomDomainResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(customDomainName); + CdnCustomDomainResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnCustomDomainResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnCustomDomainResource.cs index e0d1d648c41a0..04eb45747b66f 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnCustomDomainResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnCustomDomainResource.cs @@ -50,10 +50,10 @@ public async Task Get_CustomDomainsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CustomDomainsCreate() + public async Task Delete_CustomDomainsDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Create.json - // this example is just showing the usage of "CdnCustomDomains_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Delete.json + // this example is just showing the usage of "CdnCustomDomains_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,26 +71,17 @@ public async Task Update_CustomDomainsCreate() CdnCustomDomainResource cdnCustomDomain = client.GetCdnCustomDomainResource(cdnCustomDomainResourceId); // invoke the operation - CdnCustomDomainCreateOrUpdateContent content = new CdnCustomDomainCreateOrUpdateContent() - { - HostName = "www.someDomain.net", - }; - ArmOperation lro = await cdnCustomDomain.UpdateAsync(WaitUntil.Completed, content); - CdnCustomDomainResource result = lro.Value; + await cdnCustomDomain.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_CustomDomainsDelete() + public async Task Update_CustomDomainsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Delete.json - // this example is just showing the usage of "CdnCustomDomains_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/CustomDomains_Create.json + // this example is just showing the usage of "CdnCustomDomains_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +99,18 @@ public async Task Delete_CustomDomainsDelete() CdnCustomDomainResource cdnCustomDomain = client.GetCdnCustomDomainResource(cdnCustomDomainResourceId); // invoke the operation - await cdnCustomDomain.DeleteAsync(WaitUntil.Completed); + CdnCustomDomainCreateOrUpdateContent content = new CdnCustomDomainCreateOrUpdateContent + { + HostName = "www.someDomain.net", + }; + ArmOperation lro = await cdnCustomDomain.UpdateAsync(WaitUntil.Completed, content); + CdnCustomDomainResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnEndpointCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnEndpointCollection.cs index e9d7e4fc7874d..def9b6841bedb 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnEndpointCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnEndpointCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CdnEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_EndpointsListByProfile() + public async Task CreateOrUpdate_EndpointsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_ListByProfile.json - // this example is just showing the usage of "CdnEndpoints_ListByProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Create.json + // this example is just showing the usage of "CdnEndpoints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_EndpointsListByProfile() // get the collection of this CdnEndpointResource CdnEndpointCollection collection = profile.GetCdnEndpoints(); - // invoke the operation and iterate over the result - await foreach (CdnEndpointResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string endpointName = "endpoint1"; + CdnEndpointData data = new CdnEndpointData(default); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); + CdnEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_EndpointsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_EndpointsGet() + public async Task GetAll_EndpointsListByProfile() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Get.json - // this example is just showing the usage of "CdnEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_ListByProfile.json + // this example is just showing the usage of "CdnEndpoints_ListByProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_EndpointsGet() // get the collection of this CdnEndpointResource CdnEndpointCollection collection = profile.GetCdnEndpoints(); - // invoke the operation - string endpointName = "endpoint1"; - bool result = await collection.ExistsAsync(endpointName); + // invoke the operation and iterate over the result + await foreach (CdnEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_EndpointsGet() + public async Task Exists_EndpointsGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Get.json // this example is just showing the usage of "CdnEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_EndpointsGet() // invoke the operation string endpointName = "endpoint1"; - NullableResponse response = await collection.GetIfExistsAsync(endpointName); - CdnEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(endpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EndpointsCreate() + public async Task GetIfExists_EndpointsGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Create.json - // this example is just showing the usage of "CdnEndpoints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Get.json + // this example is just showing the usage of "CdnEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_EndpointsCreate() // invoke the operation string endpointName = "endpoint1"; - CdnEndpointData data = new CdnEndpointData(new AzureLocation("placeholder")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); - CdnEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(endpointName); + CdnEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnEndpointResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnEndpointResource.cs index 78708ad22b662..2a175eb99bafe 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnEndpointResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnEndpointResource.cs @@ -49,10 +49,10 @@ public async Task Get_EndpointsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_EndpointsUpdate() + public async Task Delete_EndpointsDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Update.json - // this example is just showing the usage of "CdnEndpoints_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Delete.json + // this example is just showing the usage of "CdnEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_EndpointsUpdate() CdnEndpointResource cdnEndpoint = client.GetCdnEndpointResource(cdnEndpointResourceId); // invoke the operation - CdnEndpointPatch patch = new CdnEndpointPatch() - { - Tags = -{ -["additionalProperties"] = "Tag1", -}, - }; - ArmOperation lro = await cdnEndpoint.UpdateAsync(WaitUntil.Completed, patch); - CdnEndpointResource result = lro.Value; + await cdnEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_EndpointsDelete() + public async Task Update_EndpointsUpdate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Delete.json - // this example is just showing the usage of "CdnEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Endpoints_Update.json + // this example is just showing the usage of "CdnEndpoints_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_EndpointsDelete() CdnEndpointResource cdnEndpoint = client.GetCdnEndpointResource(cdnEndpointResourceId); // invoke the operation - await cdnEndpoint.DeleteAsync(WaitUntil.Completed); + CdnEndpointPatch patch = new CdnEndpointPatch + { + Tags = +{ +["additionalProperties"] = "Tag1" +}, + }; + ArmOperation lro = await cdnEndpoint.UpdateAsync(WaitUntil.Completed, patch); + CdnEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -199,10 +199,7 @@ public async Task PurgeContent_EndpointsPurgeContent() CdnEndpointResource cdnEndpoint = client.GetCdnEndpointResource(cdnEndpointResourceId); // invoke the operation - PurgeContent content = new PurgeContent(new string[] - { -"/folder1" - }); + PurgeContent content = new PurgeContent(new string[] { "/folder1" }); await cdnEndpoint.PurgeContentAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); @@ -230,10 +227,7 @@ public async Task LoadContent_EndpointsLoadContent() CdnEndpointResource cdnEndpoint = client.GetCdnEndpointResource(cdnEndpointResourceId); // invoke the operation - LoadContent content = new LoadContent(new string[] - { -"/folder1" - }); + LoadContent content = new LoadContent(new string[] { "/folder1" }); await cdnEndpoint.LoadContentAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginCollection.cs index ab2a08307d33b..02988800ba187 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_CdnOriginCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_OriginsListByEndpoint() + public async Task CreateOrUpdate_OriginsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_ListByEndpoint.json - // this example is just showing the usage of "CdnOrigins_ListByEndpoint" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Create.json + // this example is just showing the usage of "CdnOrigins_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,29 @@ public async Task GetAll_OriginsListByEndpoint() // get the collection of this CdnOriginResource CdnOriginCollection collection = cdnEndpoint.GetCdnOrigins(); - // invoke the operation and iterate over the result - await foreach (CdnOriginResource item in collection.GetAllAsync()) + // invoke the operation + string originName = "www-someDomain-net"; + CdnOriginData data = new CdnOriginData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnOriginData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HostName = "www.someDomain.net", + HttpPort = 80, + HttpsPort = 443, + OriginHostHeader = "www.someDomain.net", + Priority = 1, + Weight = 50, + Enabled = true, + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), + PrivateLinkLocation = "eastus", + PrivateLinkApprovalMessage = "Please approve the connection request for this Private Link", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, originName, data); + CdnOriginResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnOriginData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +101,10 @@ public async Task Get_OriginsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_OriginsGet() + public async Task GetAll_OriginsListByEndpoint() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Get.json - // this example is just showing the usage of "CdnOrigins_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_ListByEndpoint.json + // this example is just showing the usage of "CdnOrigins_ListByEndpoint" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +123,22 @@ public async Task Exists_OriginsGet() // get the collection of this CdnOriginResource CdnOriginCollection collection = cdnEndpoint.GetCdnOrigins(); - // invoke the operation - string originName = "www-someDomain-net"; - bool result = await collection.ExistsAsync(originName); + // invoke the operation and iterate over the result + await foreach (CdnOriginResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnOriginData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_OriginsGet() + public async Task Exists_OriginsGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Get.json // this example is just showing the usage of "CdnOrigins_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +162,17 @@ public async Task GetIfExists_OriginsGet() // invoke the operation string originName = "www-someDomain-net"; - NullableResponse response = await collection.GetIfExistsAsync(originName); - CdnOriginResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(originName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnOriginData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_OriginsCreate() + public async Task GetIfExists_OriginsGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Create.json - // this example is just showing the usage of "CdnOrigins_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Get.json + // this example is just showing the usage of "CdnOrigins_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,27 +193,21 @@ public async Task CreateOrUpdate_OriginsCreate() // invoke the operation string originName = "www-someDomain-net"; - CdnOriginData data = new CdnOriginData() - { - HostName = "www.someDomain.net", - HttpPort = 80, - HttpsPort = 443, - OriginHostHeader = "www.someDomain.net", - Priority = 1, - Weight = 50, - Enabled = true, - PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.Network/privateLinkServices/pls1"), - PrivateLinkLocation = "eastus", - PrivateLinkApprovalMessage = "Please approve the connection request for this Private Link", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, originName, data); - CdnOriginResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(originName); + CdnOriginResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnOriginData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnOriginData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginGroupCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginGroupCollection.cs index 9a192bde37247..0081b71ce2be0 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginGroupCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginGroupCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_CdnOriginGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_OriginsGroupsListByEndpoint() + public async Task CreateOrUpdate_OriginGroupsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_ListByEndpoint.json - // this example is just showing the usage of "CdnOriginGroups_ListByEndpoint" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Create.json + // this example is just showing the usage of "CdnOriginGroups_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,35 @@ public async Task GetAll_OriginsGroupsListByEndpoint() // get the collection of this CdnOriginGroupResource CdnOriginGroupCollection collection = cdnEndpoint.GetCdnOriginGroups(); - // invoke the operation and iterate over the result - await foreach (CdnOriginGroupResource item in collection.GetAllAsync()) + // invoke the operation + string originGroupName = "origingroup1"; + CdnOriginGroupData data = new CdnOriginGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnOriginGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HealthProbeSettings = new HealthProbeSettings + { + ProbePath = "/health.aspx", + ProbeRequestType = HealthProbeRequestType.Get, + ProbeProtocol = HealthProbeProtocol.Http, + ProbeIntervalInSeconds = 120, + }, + Origins = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/endpoints/endpoint1/origins/origin1"), +}}, + ResponseBasedOriginErrorDetectionSettings = new ResponseBasedOriginErrorDetectionSettings + { + ResponseBasedDetectedErrorType = ResponseBasedDetectedErrorType.TcpErrorsOnly, + ResponseBasedFailoverThresholdPercentage = 10, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, originGroupName, data); + CdnOriginGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnOriginGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +109,10 @@ public async Task Get_OriginGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_OriginGroupsGet() + public async Task GetAll_OriginsGroupsListByEndpoint() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Get.json - // this example is just showing the usage of "CdnOriginGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_ListByEndpoint.json + // this example is just showing the usage of "CdnOriginGroups_ListByEndpoint" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +131,22 @@ public async Task Exists_OriginGroupsGet() // get the collection of this CdnOriginGroupResource CdnOriginGroupCollection collection = cdnEndpoint.GetCdnOriginGroups(); - // invoke the operation - string originGroupName = "originGroup1"; - bool result = await collection.ExistsAsync(originGroupName); + // invoke the operation and iterate over the result + await foreach (CdnOriginGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnOriginGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_OriginGroupsGet() + public async Task Exists_OriginGroupsGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Get.json // this example is just showing the usage of "CdnOriginGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +170,17 @@ public async Task GetIfExists_OriginGroupsGet() // invoke the operation string originGroupName = "originGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(originGroupName); - CdnOriginGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(originGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnOriginGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_OriginGroupsCreate() + public async Task GetIfExists_OriginGroupsGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Create.json - // this example is just showing the usage of "CdnOriginGroups_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Get.json + // this example is just showing the usage of "CdnOriginGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,37 +200,22 @@ public async Task CreateOrUpdate_OriginGroupsCreate() CdnOriginGroupCollection collection = cdnEndpoint.GetCdnOriginGroups(); // invoke the operation - string originGroupName = "origingroup1"; - CdnOriginGroupData data = new CdnOriginGroupData() - { - HealthProbeSettings = new HealthProbeSettings() - { - ProbePath = "/health.aspx", - ProbeRequestType = HealthProbeRequestType.Get, - ProbeProtocol = HealthProbeProtocol.Http, - ProbeIntervalInSeconds = 120, - }, - Origins = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/endpoints/endpoint1/origins/origin1"), -} -}, - ResponseBasedOriginErrorDetectionSettings = new ResponseBasedOriginErrorDetectionSettings() - { - ResponseBasedDetectedErrorType = ResponseBasedDetectedErrorType.TcpErrorsOnly, - ResponseBasedFailoverThresholdPercentage = 10, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, originGroupName, data); - CdnOriginGroupResource result = lro.Value; + string originGroupName = "originGroup1"; + NullableResponse response = await collection.GetIfExistsAsync(originGroupName); + CdnOriginGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnOriginGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnOriginGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginGroupResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginGroupResource.cs index d823700929de2..34b87c0f3f221 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginGroupResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginGroupResource.cs @@ -51,10 +51,10 @@ public async Task Get_OriginGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_OriginGroupsUpdate() + public async Task Delete_OriginGroupsDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Update.json - // this example is just showing the usage of "CdnOriginGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Delete.json + // this example is just showing the usage of "CdnOriginGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,39 +72,17 @@ public async Task Update_OriginGroupsUpdate() CdnOriginGroupResource cdnOriginGroup = client.GetCdnOriginGroupResource(cdnOriginGroupResourceId); // invoke the operation - CdnOriginGroupPatch patch = new CdnOriginGroupPatch() - { - HealthProbeSettings = new HealthProbeSettings() - { - ProbePath = "/health.aspx", - ProbeRequestType = HealthProbeRequestType.Get, - ProbeProtocol = HealthProbeProtocol.Http, - ProbeIntervalInSeconds = 120, - }, - Origins = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/endpoints/endpoint1/origins/origin2"), -} -}, - }; - ArmOperation lro = await cdnOriginGroup.UpdateAsync(WaitUntil.Completed, patch); - CdnOriginGroupResource result = lro.Value; + await cdnOriginGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnOriginGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_OriginGroupsDelete() + public async Task Update_OriginGroupsUpdate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Delete.json - // this example is just showing the usage of "CdnOriginGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/OriginGroups_Update.json + // this example is just showing the usage of "CdnOriginGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,9 +100,28 @@ public async Task Delete_OriginGroupsDelete() CdnOriginGroupResource cdnOriginGroup = client.GetCdnOriginGroupResource(cdnOriginGroupResourceId); // invoke the operation - await cdnOriginGroup.DeleteAsync(WaitUntil.Completed); + CdnOriginGroupPatch patch = new CdnOriginGroupPatch + { + HealthProbeSettings = new HealthProbeSettings + { + ProbePath = "/health.aspx", + ProbeRequestType = HealthProbeRequestType.Get, + ProbeProtocol = HealthProbeProtocol.Http, + ProbeIntervalInSeconds = 120, + }, + Origins = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/endpoints/endpoint1/origins/origin2"), +}}, + }; + ArmOperation lro = await cdnOriginGroup.UpdateAsync(WaitUntil.Completed, patch); + CdnOriginGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnOriginGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginResource.cs index d5c7545d68a4b..4338971bc13dc 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnOriginResource.cs @@ -50,10 +50,10 @@ public async Task Get_OriginsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_OriginsUpdate() + public async Task Delete_OriginsDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Update.json - // this example is just showing the usage of "CdnOrigins_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Delete.json + // this example is just showing the usage of "CdnOrigins_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,37 +66,22 @@ public async Task Update_OriginsUpdate() string resourceGroupName = "RG"; string profileName = "profile1"; string endpointName = "endpoint1"; - string originName = "www-someDomain-net"; + string originName = "origin1"; ResourceIdentifier cdnOriginResourceId = CdnOriginResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointName, originName); CdnOriginResource cdnOrigin = client.GetCdnOriginResource(cdnOriginResourceId); // invoke the operation - CdnOriginPatch patch = new CdnOriginPatch() - { - HttpPort = 42, - HttpsPort = 43, - OriginHostHeader = "www.someDomain2.net", - Priority = 1, - Weight = 50, - Enabled = true, - PrivateLinkAlias = "APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice", - }; - ArmOperation lro = await cdnOrigin.UpdateAsync(WaitUntil.Completed, patch); - CdnOriginResource result = lro.Value; + await cdnOrigin.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnOriginData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_OriginsDelete() + public async Task Update_OriginsUpdate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Delete.json - // this example is just showing the usage of "CdnOrigins_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Origins_Update.json + // this example is just showing the usage of "CdnOrigins_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,14 +94,29 @@ public async Task Delete_OriginsDelete() string resourceGroupName = "RG"; string profileName = "profile1"; string endpointName = "endpoint1"; - string originName = "origin1"; + string originName = "www-someDomain-net"; ResourceIdentifier cdnOriginResourceId = CdnOriginResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointName, originName); CdnOriginResource cdnOrigin = client.GetCdnOriginResource(cdnOriginResourceId); // invoke the operation - await cdnOrigin.DeleteAsync(WaitUntil.Completed); + CdnOriginPatch patch = new CdnOriginPatch + { + HttpPort = 42, + HttpsPort = 43, + OriginHostHeader = "www.someDomain2.net", + Priority = 1, + Weight = 50, + Enabled = true, + PrivateLinkAlias = "APPSERVER.d84e61f0-0870-4d24-9746-7438fa0019d1.westus2.azure.privatelinkservice", + }; + ArmOperation lro = await cdnOrigin.UpdateAsync(WaitUntil.Completed, patch); + CdnOriginResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnOriginData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnWebApplicationFirewallPolicyCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnWebApplicationFirewallPolicyCollection.cs index a6b0d50a8af82..5336a99c9590b 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnWebApplicationFirewallPolicyCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnWebApplicationFirewallPolicyCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_CdnWebApplicationFirewallPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPoliciesInAResourceGroup() + public async Task CreateOrUpdate_CreatesSpecificPolicy() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafListPolicies.json - // this example is just showing the usage of "Policies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyCreateOrUpdate.json + // this example is just showing the usage of "Policies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,84 @@ public async Task GetAll_ListPoliciesInAResourceGroup() // get the collection of this CdnWebApplicationFirewallPolicyResource CdnWebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetCdnWebApplicationFirewallPolicies(); - // invoke the operation and iterate over the result - await foreach (CdnWebApplicationFirewallPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string policyName = "MicrosoftCdnWafPolicy"; + CdnWebApplicationFirewallPolicyData data = new CdnWebApplicationFirewallPolicyData(new AzureLocation("WestUs"), new CdnSku { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnWebApplicationFirewallPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Name = CdnSkuName.StandardMicrosoft, + }) + { + PolicySettings = new WafPolicySettings + { + DefaultRedirectUri = new Uri("http://www.bing.com"), + DefaultCustomBlockResponseStatusCode = PolicySettingsDefaultCustomBlockResponseStatusCode.TwoHundred, + DefaultCustomBlockResponseBody = BinaryData.FromObjectAsJson("PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg=="), + }, + RateLimitRules = {new RateLimitRule( + "RateLimitRule1", + 1, + new CustomRuleMatchCondition[] +{ +new CustomRuleMatchCondition(WafMatchVariable.RemoteAddr, MatchOperator.IPMatch, new string[]{"192.168.1.0/24", "10.0.0.0/24"}) +{ +Selector = null, +NegateCondition = false, +Transforms = {}, +} +}, + OverrideActionType.Block, + 1000, + 0) +{ +EnabledState = CustomRuleEnabledState.Enabled, +}}, + CustomRules = {new CustomRule("CustomRule1", 2, new CustomRuleMatchCondition[] +{ +new CustomRuleMatchCondition(WafMatchVariable.RemoteAddr, MatchOperator.GeoMatch, new string[]{"CH"}) +{ +Selector = null, +NegateCondition = false, +Transforms = {}, +}, +new CustomRuleMatchCondition(WafMatchVariable.RequestHeader, MatchOperator.Contains, new string[]{"windows"}) +{ +Selector = "UserAgent", +NegateCondition = false, +Transforms = {}, +}, +new CustomRuleMatchCondition(WafMatchVariable.QueryString, MatchOperator.Contains, new string[]{""}) +{ +Selector = "search", +NegateCondition = false, +Transforms = {TransformType.UriDecode, TransformType.Lowercase}, +} +}, OverrideActionType.Block) +{ +EnabledState = CustomRuleEnabledState.Enabled, +}}, + ManagedRuleSets = {new WafPolicyManagedRuleSet("DefaultRuleSet", "preview-1.0") +{ +RuleGroupOverrides = {new ManagedRuleGroupOverrideSetting("Group1") +{ +Rules = {new ManagedRuleOverrideSetting("GROUP1-0001") +{ +EnabledState = ManagedRuleSetupState.Enabled, +Action = OverrideActionType.Redirect, +}, new ManagedRuleOverrideSetting("GROUP1-0002") +{ +EnabledState = ManagedRuleSetupState.Disabled, +}}, +}}, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); + CdnWebApplicationFirewallPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnWebApplicationFirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +154,10 @@ public async Task Get_GetPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPolicy() + public async Task GetAll_ListPoliciesInAResourceGroup() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyGet.json - // this example is just showing the usage of "Policies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafListPolicies.json + // this example is just showing the usage of "Policies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +174,22 @@ public async Task Exists_GetPolicy() // get the collection of this CdnWebApplicationFirewallPolicyResource CdnWebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetCdnWebApplicationFirewallPolicies(); - // invoke the operation - string policyName = "MicrosoftCdnWafPolicy"; - bool result = await collection.ExistsAsync(policyName); + // invoke the operation and iterate over the result + await foreach (CdnWebApplicationFirewallPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnWebApplicationFirewallPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPolicy() + public async Task Exists_GetPolicy() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyGet.json // this example is just showing the usage of "Policies_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +211,17 @@ public async Task GetIfExists_GetPolicy() // invoke the operation string policyName = "MicrosoftCdnWafPolicy"; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - CdnWebApplicationFirewallPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(policyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnWebApplicationFirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesSpecificPolicy() + public async Task GetIfExists_GetPolicy() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyCreateOrUpdate.json - // this example is just showing the usage of "Policies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyGet.json + // this example is just showing the usage of "Policies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,110 +240,21 @@ public async Task CreateOrUpdate_CreatesSpecificPolicy() // invoke the operation string policyName = "MicrosoftCdnWafPolicy"; - CdnWebApplicationFirewallPolicyData data = new CdnWebApplicationFirewallPolicyData(new AzureLocation("WestUs"), new CdnSku() + NullableResponse response = await collection.GetIfExistsAsync(policyName); + CdnWebApplicationFirewallPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Name = CdnSkuName.StandardMicrosoft, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - PolicySettings = new WafPolicySettings() - { - DefaultRedirectUri = new Uri("http://www.bing.com"), - DefaultCustomBlockResponseStatusCode = PolicySettingsDefaultCustomBlockResponseStatusCode.TwoHundred, - DefaultCustomBlockResponseBody = BinaryData.FromString("\"PGh0bWw+CjxoZWFkZXI+PHRpdGxlPkhlbGxvPC90aXRsZT48L2hlYWRlcj4KPGJvZHk+CkhlbGxvIHdvcmxkCjwvYm9keT4KPC9odG1sPg==\""), - }, - RateLimitRules = -{ -new RateLimitRule("RateLimitRule1",1,new CustomRuleMatchCondition[] -{ -new CustomRuleMatchCondition(WafMatchVariable.RemoteAddr,MatchOperator.IPMatch,new string[] -{ -"192.168.1.0/24","10.0.0.0/24" -}) -{ -Selector = null, -NegateCondition = false, -Transforms = -{ -}, -} -},OverrideActionType.Block,1000,0) -{ -EnabledState = CustomRuleEnabledState.Enabled, -} -}, - CustomRules = -{ -new CustomRule("CustomRule1",2,new CustomRuleMatchCondition[] -{ -new CustomRuleMatchCondition(WafMatchVariable.RemoteAddr,MatchOperator.GeoMatch,new string[] -{ -"CH" -}) -{ -Selector = null, -NegateCondition = false, -Transforms = -{ -}, -},new CustomRuleMatchCondition(WafMatchVariable.RequestHeader,MatchOperator.Contains,new string[] -{ -"windows" -}) -{ -Selector = "UserAgent", -NegateCondition = false, -Transforms = -{ -}, -},new CustomRuleMatchCondition(WafMatchVariable.QueryString,MatchOperator.Contains,new string[] -{ -"" -}) -{ -Selector = "search", -NegateCondition = false, -Transforms = -{ -TransformType.UriDecode,TransformType.Lowercase -}, -} -},OverrideActionType.Block) -{ -EnabledState = CustomRuleEnabledState.Enabled, -} -}, - ManagedRuleSets = -{ -new WafPolicyManagedRuleSet("DefaultRuleSet","preview-1.0") -{ -RuleGroupOverrides = -{ -new ManagedRuleGroupOverrideSetting("Group1") -{ -Rules = -{ -new ManagedRuleOverrideSetting("GROUP1-0001") -{ -EnabledState = ManagedRuleSetupState.Enabled, -Action = OverrideActionType.Redirect, -},new ManagedRuleOverrideSetting("GROUP1-0002") -{ -EnabledState = ManagedRuleSetupState.Disabled, -} -}, -} -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, policyName, data); - CdnWebApplicationFirewallPolicyResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnWebApplicationFirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnWebApplicationFirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnWebApplicationFirewallPolicyResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnWebApplicationFirewallPolicyResource.cs index 6e39d4a8e4316..b637b928fbb9f 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnWebApplicationFirewallPolicyResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_CdnWebApplicationFirewallPolicyResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesSpecificPolicy() + public async Task Delete_DeleteProtectionPolicy() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPatchPolicy.json - // this example is just showing the usage of "Policies_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyDelete.json + // this example is just showing the usage of "Policies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,34 +62,22 @@ public async Task Update_CreatesSpecificPolicy() // for more information of creating CdnWebApplicationFirewallPolicyResource, please refer to the document of CdnWebApplicationFirewallPolicyResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string policyName = "MicrosoftCdnWafPolicy"; + string policyName = "Policy1"; ResourceIdentifier cdnWebApplicationFirewallPolicyResourceId = CdnWebApplicationFirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, policyName); CdnWebApplicationFirewallPolicyResource cdnWebApplicationFirewallPolicy = client.GetCdnWebApplicationFirewallPolicyResource(cdnWebApplicationFirewallPolicyResourceId); // invoke the operation - CdnWebApplicationFirewallPolicyPatch patch = new CdnWebApplicationFirewallPolicyPatch() - { - Tags = -{ -["foo"] = "bar", -}, - }; - ArmOperation lro = await cdnWebApplicationFirewallPolicy.UpdateAsync(WaitUntil.Completed, patch); - CdnWebApplicationFirewallPolicyResource result = lro.Value; + await cdnWebApplicationFirewallPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CdnWebApplicationFirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteProtectionPolicy() + public async Task Update_CreatesSpecificPolicy() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPolicyDelete.json - // this example is just showing the usage of "Policies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/WafPatchPolicy.json + // this example is just showing the usage of "Policies_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,14 +88,26 @@ public async Task Delete_DeleteProtectionPolicy() // for more information of creating CdnWebApplicationFirewallPolicyResource, please refer to the document of CdnWebApplicationFirewallPolicyResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string policyName = "Policy1"; + string policyName = "MicrosoftCdnWafPolicy"; ResourceIdentifier cdnWebApplicationFirewallPolicyResourceId = CdnWebApplicationFirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, policyName); CdnWebApplicationFirewallPolicyResource cdnWebApplicationFirewallPolicy = client.GetCdnWebApplicationFirewallPolicyResource(cdnWebApplicationFirewallPolicyResourceId); // invoke the operation - await cdnWebApplicationFirewallPolicy.DeleteAsync(WaitUntil.Completed); + CdnWebApplicationFirewallPolicyPatch patch = new CdnWebApplicationFirewallPolicyPatch + { + Tags = +{ +["foo"] = "bar" +}, + }; + ArmOperation lro = await cdnWebApplicationFirewallPolicy.UpdateAsync(WaitUntil.Completed, patch); + CdnWebApplicationFirewallPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CdnWebApplicationFirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorCustomDomainCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorCustomDomainCollection.cs index e0c048fdd1398..7330b9ede1467 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorCustomDomainCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorCustomDomainCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FrontDoorCustomDomainCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AFDCustomDomainsListByProfile() + public async Task CreateOrUpdate_AFDCustomDomainsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_ListByProfile.json - // this example is just showing the usage of "FrontDoorCustomDomains_ListByProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Create.json + // this example is just showing the usage of "FrontDoorCustomDomains_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_AFDCustomDomainsListByProfile() // get the collection of this FrontDoorCustomDomainResource FrontDoorCustomDomainCollection collection = profile.GetFrontDoorCustomDomains(); - // invoke the operation and iterate over the result - await foreach (FrontDoorCustomDomainResource item in collection.GetAllAsync()) + // invoke the operation + string customDomainName = "domain1"; + FrontDoorCustomDomainData data = new FrontDoorCustomDomainData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorCustomDomainData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TlsSettings = new FrontDoorCustomDomainHttpsContent(FrontDoorCertificateType.ManagedCertificate) + { + MinimumTlsVersion = FrontDoorMinimumTlsVersion.Tls1_2, + }, + DnsZoneId = new ResourceIdentifier(""), + HostName = "www.someDomain.net", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, customDomainName, data); + FrontDoorCustomDomainResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_AFDCustomDomainsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AFDCustomDomainsGet() + public async Task GetAll_AFDCustomDomainsListByProfile() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Get.json - // this example is just showing the usage of "FrontDoorCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_ListByProfile.json + // this example is just showing the usage of "FrontDoorCustomDomains_ListByProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_AFDCustomDomainsGet() // get the collection of this FrontDoorCustomDomainResource FrontDoorCustomDomainCollection collection = profile.GetFrontDoorCustomDomains(); - // invoke the operation - string customDomainName = "domain1"; - bool result = await collection.ExistsAsync(customDomainName); + // invoke the operation and iterate over the result + await foreach (FrontDoorCustomDomainResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorCustomDomainData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AFDCustomDomainsGet() + public async Task Exists_AFDCustomDomainsGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Get.json // this example is just showing the usage of "FrontDoorCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_AFDCustomDomainsGet() // invoke the operation string customDomainName = "domain1"; - NullableResponse response = await collection.GetIfExistsAsync(customDomainName); - FrontDoorCustomDomainResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(customDomainName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AFDCustomDomainsCreate() + public async Task GetIfExists_AFDCustomDomainsGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Create.json - // this example is just showing the usage of "FrontDoorCustomDomains_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Get.json + // this example is just showing the usage of "FrontDoorCustomDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_AFDCustomDomainsCreate() // invoke the operation string customDomainName = "domain1"; - FrontDoorCustomDomainData data = new FrontDoorCustomDomainData() - { - TlsSettings = new FrontDoorCustomDomainHttpsContent(FrontDoorCertificateType.ManagedCertificate) - { - MinimumTlsVersion = FrontDoorMinimumTlsVersion.Tls1_2, - }, - DnsZoneId = new ResourceIdentifier(""), - HostName = "www.someDomain.net", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, customDomainName, data); - FrontDoorCustomDomainResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(customDomainName); + FrontDoorCustomDomainResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorCustomDomainResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorCustomDomainResource.cs index 46cfc4c767885..5decd9ec0760d 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorCustomDomainResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorCustomDomainResource.cs @@ -49,10 +49,10 @@ public async Task Get_AFDCustomDomainsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AFDCustomDomainsUpdate() + public async Task Delete_AFDCustomDomainsDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Update.json - // this example is just showing the usage of "FrontDoorCustomDomains_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Delete.json + // this example is just showing the usage of "FrontDoorCustomDomains_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_AFDCustomDomainsUpdate() FrontDoorCustomDomainResource frontDoorCustomDomain = client.GetFrontDoorCustomDomainResource(frontDoorCustomDomainResourceId); // invoke the operation - FrontDoorCustomDomainPatch patch = new FrontDoorCustomDomainPatch() - { - TlsSettings = new FrontDoorCustomDomainHttpsContent(FrontDoorCertificateType.CustomerCertificate) - { - MinimumTlsVersion = FrontDoorMinimumTlsVersion.Tls1_2, - }, - DnsZoneId = new ResourceIdentifier(""), - }; - ArmOperation lro = await frontDoorCustomDomain.UpdateAsync(WaitUntil.Completed, patch); - FrontDoorCustomDomainResource result = lro.Value; + await frontDoorCustomDomain.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorCustomDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AFDCustomDomainsDelete() + public async Task Update_AFDCustomDomainsUpdate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Delete.json - // this example is just showing the usage of "FrontDoorCustomDomains_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDCustomDomains_Update.json + // this example is just showing the usage of "FrontDoorCustomDomains_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_AFDCustomDomainsDelete() FrontDoorCustomDomainResource frontDoorCustomDomain = client.GetFrontDoorCustomDomainResource(frontDoorCustomDomainResourceId); // invoke the operation - await frontDoorCustomDomain.DeleteAsync(WaitUntil.Completed); + FrontDoorCustomDomainPatch patch = new FrontDoorCustomDomainPatch + { + TlsSettings = new FrontDoorCustomDomainHttpsContent(FrontDoorCertificateType.CustomerCertificate) + { + MinimumTlsVersion = FrontDoorMinimumTlsVersion.Tls1_2, + }, + DnsZoneId = new ResourceIdentifier(""), + }; + ArmOperation lro = await frontDoorCustomDomain.UpdateAsync(WaitUntil.Completed, patch); + FrontDoorCustomDomainResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorCustomDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorEndpointCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorEndpointCollection.cs index bb6242d1c3b39..698f61cc11fe2 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorEndpointCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorEndpointCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_FrontDoorEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AFDEndpointsListByProfile() + public async Task CreateOrUpdate_AFDEndpointsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_ListByProfile.json - // this example is just showing the usage of "FrontDoorEndpoints_ListByProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Create.json + // this example is just showing the usage of "FrontDoorEndpoints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_AFDEndpointsListByProfile() // get the collection of this FrontDoorEndpointResource FrontDoorEndpointCollection collection = profile.GetFrontDoorEndpoints(); - // invoke the operation and iterate over the result - await foreach (FrontDoorEndpointResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string endpointName = "endpoint1"; + FrontDoorEndpointData data = new FrontDoorEndpointData(default); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); + FrontDoorEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_AFDEndpointsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AFDEndpointsGet() + public async Task GetAll_AFDEndpointsListByProfile() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Get.json - // this example is just showing the usage of "FrontDoorEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_ListByProfile.json + // this example is just showing the usage of "FrontDoorEndpoints_ListByProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_AFDEndpointsGet() // get the collection of this FrontDoorEndpointResource FrontDoorEndpointCollection collection = profile.GetFrontDoorEndpoints(); - // invoke the operation - string endpointName = "endpoint1"; - bool result = await collection.ExistsAsync(endpointName); + // invoke the operation and iterate over the result + await foreach (FrontDoorEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AFDEndpointsGet() + public async Task Exists_AFDEndpointsGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Get.json // this example is just showing the usage of "FrontDoorEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_AFDEndpointsGet() // invoke the operation string endpointName = "endpoint1"; - NullableResponse response = await collection.GetIfExistsAsync(endpointName); - FrontDoorEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(endpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AFDEndpointsCreate() + public async Task GetIfExists_AFDEndpointsGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Create.json - // this example is just showing the usage of "FrontDoorEndpoints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Get.json + // this example is just showing the usage of "FrontDoorEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_AFDEndpointsCreate() // invoke the operation string endpointName = "endpoint1"; - FrontDoorEndpointData data = new FrontDoorEndpointData(new AzureLocation("placeholder")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); - FrontDoorEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(endpointName); + FrontDoorEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorEndpointResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorEndpointResource.cs index cdf73a0527a93..58377afbb8126 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorEndpointResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorEndpointResource.cs @@ -49,10 +49,10 @@ public async Task Get_AFDEndpointsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AFDEndpointsUpdate() + public async Task Delete_AFDEndpointsDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Update.json - // this example is just showing the usage of "FrontDoorEndpoints_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Delete.json + // this example is just showing the usage of "FrontDoorEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_AFDEndpointsUpdate() FrontDoorEndpointResource frontDoorEndpoint = client.GetFrontDoorEndpointResource(frontDoorEndpointResourceId); // invoke the operation - FrontDoorEndpointPatch patch = new FrontDoorEndpointPatch() - { - Tags = -{ -}, - EnabledState = EnabledState.Enabled, - }; - ArmOperation lro = await frontDoorEndpoint.UpdateAsync(WaitUntil.Completed, patch); - FrontDoorEndpointResource result = lro.Value; + await frontDoorEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AFDEndpointsDelete() + public async Task Update_AFDEndpointsUpdate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Delete.json - // this example is just showing the usage of "FrontDoorEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDEndpoints_Update.json + // this example is just showing the usage of "FrontDoorEndpoints_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,19 @@ public async Task Delete_AFDEndpointsDelete() FrontDoorEndpointResource frontDoorEndpoint = client.GetFrontDoorEndpointResource(frontDoorEndpointResourceId); // invoke the operation - await frontDoorEndpoint.DeleteAsync(WaitUntil.Completed); + FrontDoorEndpointPatch patch = new FrontDoorEndpointPatch + { + Tags = { }, + EnabledState = EnabledState.Enabled, + }; + ArmOperation lro = await frontDoorEndpoint.UpdateAsync(WaitUntil.Completed, patch); + FrontDoorEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -135,15 +133,9 @@ public async Task PurgeContent_AFDEndpointsPurgeContent() FrontDoorEndpointResource frontDoorEndpoint = client.GetFrontDoorEndpointResource(frontDoorEndpointResourceId); // invoke the operation - FrontDoorPurgeContent content = new FrontDoorPurgeContent(new string[] + FrontDoorPurgeContent content = new FrontDoorPurgeContent(new string[] { "/folder1" }) { -"/folder1" - }) - { - Domains = -{ -"endpoint1-abcdefghijklmnop.z01.azurefd.net" -}, + Domains = { "endpoint1-abcdefghijklmnop.z01.azurefd.net" }, }; await frontDoorEndpoint.PurgeContentAsync(WaitUntil.Completed, content); diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginCollection.cs index 1afc0266a02d8..33a4c830e63b7 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FrontDoorOriginCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AFDOriginsListByOriginGroup() + public async Task CreateOrUpdate_AFDOriginsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_ListByOriginGroup.json - // this example is just showing the usage of "FrontDoorOrigins_ListByOriginGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Create.json + // this example is just showing the usage of "FrontDoorOrigins_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,24 @@ public async Task GetAll_AFDOriginsListByOriginGroup() // get the collection of this FrontDoorOriginResource FrontDoorOriginCollection collection = frontDoorOriginGroup.GetFrontDoorOrigins(); - // invoke the operation and iterate over the result - await foreach (FrontDoorOriginResource item in collection.GetAllAsync()) + // invoke the operation + string originName = "origin1"; + FrontDoorOriginData data = new FrontDoorOriginData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorOriginData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HostName = "host1.blob.core.windows.net", + HttpPort = 80, + HttpsPort = 443, + OriginHostHeader = "host1.foo.com", + EnabledState = EnabledState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, originName, data); + FrontDoorOriginResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorOriginData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +97,10 @@ public async Task Get_AFDOriginsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AFDOriginsGet() + public async Task GetAll_AFDOriginsListByOriginGroup() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Get.json - // this example is just showing the usage of "FrontDoorOrigins_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_ListByOriginGroup.json + // this example is just showing the usage of "FrontDoorOrigins_ListByOriginGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +119,22 @@ public async Task Exists_AFDOriginsGet() // get the collection of this FrontDoorOriginResource FrontDoorOriginCollection collection = frontDoorOriginGroup.GetFrontDoorOrigins(); - // invoke the operation - string originName = "origin1"; - bool result = await collection.ExistsAsync(originName); + // invoke the operation and iterate over the result + await foreach (FrontDoorOriginResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorOriginData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AFDOriginsGet() + public async Task Exists_AFDOriginsGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Get.json // this example is just showing the usage of "FrontDoorOrigins_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +158,17 @@ public async Task GetIfExists_AFDOriginsGet() // invoke the operation string originName = "origin1"; - NullableResponse response = await collection.GetIfExistsAsync(originName); - FrontDoorOriginResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(originName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorOriginData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AFDOriginsCreate() + public async Task GetIfExists_AFDOriginsGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Create.json - // this example is just showing the usage of "FrontDoorOrigins_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Get.json + // this example is just showing the usage of "FrontDoorOrigins_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,22 +189,21 @@ public async Task CreateOrUpdate_AFDOriginsCreate() // invoke the operation string originName = "origin1"; - FrontDoorOriginData data = new FrontDoorOriginData() - { - HostName = "host1.blob.core.windows.net", - HttpPort = 80, - HttpsPort = 443, - OriginHostHeader = "host1.foo.com", - EnabledState = EnabledState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, originName, data); - FrontDoorOriginResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(originName); + FrontDoorOriginResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorOriginData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorOriginData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginGroupCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginGroupCollection.cs index f9832cef5a5fd..e4dc0545d80e7 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginGroupCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FrontDoorOriginGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AFDOriginGroupsListByProfile() + public async Task CreateOrUpdate_AFDOriginGroupsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_ListByProfile.json - // this example is just showing the usage of "FrontDoorOriginGroups_ListByProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Create.json + // this example is just showing the usage of "FrontDoorOriginGroups_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,33 @@ public async Task GetAll_AFDOriginGroupsListByProfile() // get the collection of this FrontDoorOriginGroupResource FrontDoorOriginGroupCollection collection = profile.GetFrontDoorOriginGroups(); - // invoke the operation and iterate over the result - await foreach (FrontDoorOriginGroupResource item in collection.GetAllAsync()) + // invoke the operation + string originGroupName = "origingroup1"; + FrontDoorOriginGroupData data = new FrontDoorOriginGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorOriginGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + LoadBalancingSettings = new LoadBalancingSettings + { + SampleSize = 3, + SuccessfulSamplesRequired = 3, + AdditionalLatencyInMilliseconds = 1000, + }, + HealthProbeSettings = new HealthProbeSettings + { + ProbePath = "/path2", + ProbeRequestType = HealthProbeRequestType.NotSet, + ProbeProtocol = HealthProbeProtocol.NotSet, + ProbeIntervalInSeconds = 10, + }, + TrafficRestorationTimeInMinutes = 5, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, originGroupName, data); + FrontDoorOriginGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorOriginGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +104,10 @@ public async Task Get_AFDOriginGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AFDOriginGroupsGet() + public async Task GetAll_AFDOriginGroupsListByProfile() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Get.json - // this example is just showing the usage of "FrontDoorOriginGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_ListByProfile.json + // this example is just showing the usage of "FrontDoorOriginGroups_ListByProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +125,22 @@ public async Task Exists_AFDOriginGroupsGet() // get the collection of this FrontDoorOriginGroupResource FrontDoorOriginGroupCollection collection = profile.GetFrontDoorOriginGroups(); - // invoke the operation - string originGroupName = "origingroup1"; - bool result = await collection.ExistsAsync(originGroupName); + // invoke the operation and iterate over the result + await foreach (FrontDoorOriginGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorOriginGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AFDOriginGroupsGet() + public async Task Exists_AFDOriginGroupsGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Get.json // this example is just showing the usage of "FrontDoorOriginGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +163,17 @@ public async Task GetIfExists_AFDOriginGroupsGet() // invoke the operation string originGroupName = "origingroup1"; - NullableResponse response = await collection.GetIfExistsAsync(originGroupName); - FrontDoorOriginGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(originGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorOriginGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AFDOriginGroupsCreate() + public async Task GetIfExists_AFDOriginGroupsGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Create.json - // this example is just showing the usage of "FrontDoorOriginGroups_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Get.json + // this example is just showing the usage of "FrontDoorOriginGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,31 +193,21 @@ public async Task CreateOrUpdate_AFDOriginGroupsCreate() // invoke the operation string originGroupName = "origingroup1"; - FrontDoorOriginGroupData data = new FrontDoorOriginGroupData() - { - LoadBalancingSettings = new LoadBalancingSettings() - { - SampleSize = 3, - SuccessfulSamplesRequired = 3, - AdditionalLatencyInMilliseconds = 1000, - }, - HealthProbeSettings = new HealthProbeSettings() - { - ProbePath = "/path2", - ProbeRequestType = HealthProbeRequestType.NotSet, - ProbeProtocol = HealthProbeProtocol.NotSet, - ProbeIntervalInSeconds = 10, - }, - TrafficRestorationTimeInMinutes = 5, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, originGroupName, data); - FrontDoorOriginGroupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(originGroupName); + FrontDoorOriginGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorOriginGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorOriginGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginGroupResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginGroupResource.cs index 8e3c1c08c0fe4..50600cc1b6314 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginGroupResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginGroupResource.cs @@ -47,6 +47,33 @@ public async Task Get_AFDOriginGroupsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_AFDOriginGroupsDelete() + { + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Delete.json + // this example is just showing the usage of "FrontDoorOriginGroups_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this FrontDoorOriginGroupResource created on azure + // for more information of creating FrontDoorOriginGroupResource, please refer to the document of FrontDoorOriginGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "RG"; + string profileName = "profile1"; + string originGroupName = "origingroup1"; + ResourceIdentifier frontDoorOriginGroupResourceId = FrontDoorOriginGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, originGroupName); + FrontDoorOriginGroupResource frontDoorOriginGroup = client.GetFrontDoorOriginGroupResource(frontDoorOriginGroupResourceId); + + // invoke the operation + await frontDoorOriginGroup.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_AFDOriginGroupsUpdate() @@ -69,15 +96,15 @@ public async Task Update_AFDOriginGroupsUpdate() FrontDoorOriginGroupResource frontDoorOriginGroup = client.GetFrontDoorOriginGroupResource(frontDoorOriginGroupResourceId); // invoke the operation - FrontDoorOriginGroupPatch patch = new FrontDoorOriginGroupPatch() + FrontDoorOriginGroupPatch patch = new FrontDoorOriginGroupPatch { - LoadBalancingSettings = new LoadBalancingSettings() + LoadBalancingSettings = new LoadBalancingSettings { SampleSize = 3, SuccessfulSamplesRequired = 3, AdditionalLatencyInMilliseconds = 1000, }, - HealthProbeSettings = new HealthProbeSettings() + HealthProbeSettings = new HealthProbeSettings { ProbePath = "/path2", ProbeRequestType = HealthProbeRequestType.NotSet, @@ -96,33 +123,6 @@ public async Task Update_AFDOriginGroupsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_AFDOriginGroupsDelete() - { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOriginGroups_Delete.json - // this example is just showing the usage of "FrontDoorOriginGroups_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this FrontDoorOriginGroupResource created on azure - // for more information of creating FrontDoorOriginGroupResource, please refer to the document of FrontDoorOriginGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "RG"; - string profileName = "profile1"; - string originGroupName = "origingroup1"; - ResourceIdentifier frontDoorOriginGroupResourceId = FrontDoorOriginGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, originGroupName); - FrontDoorOriginGroupResource frontDoorOriginGroup = client.GetFrontDoorOriginGroupResource(frontDoorOriginGroupResourceId); - - // invoke the operation - await frontDoorOriginGroup.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetResourceUsages_AFDOriginGroupsListResourceUsage() diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginResource.cs index 2a5e53bb70731..094a880cdc99c 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorOriginResource.cs @@ -50,10 +50,10 @@ public async Task Get_AFDOriginsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AFDOriginsUpdate() + public async Task Delete_AFDOriginsDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Update.json - // this example is just showing the usage of "FrontDoorOrigins_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Delete.json + // this example is just showing the usage of "FrontDoorOrigins_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,29 +71,17 @@ public async Task Update_AFDOriginsUpdate() FrontDoorOriginResource frontDoorOrigin = client.GetFrontDoorOriginResource(frontDoorOriginResourceId); // invoke the operation - FrontDoorOriginPatch patch = new FrontDoorOriginPatch() - { - HostName = "host1.blob.core.windows.net", - HttpPort = 80, - HttpsPort = 443, - EnabledState = EnabledState.Enabled, - }; - ArmOperation lro = await frontDoorOrigin.UpdateAsync(WaitUntil.Completed, patch); - FrontDoorOriginResource result = lro.Value; + await frontDoorOrigin.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorOriginData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AFDOriginsDelete() + public async Task Update_AFDOriginsUpdate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Delete.json - // this example is just showing the usage of "FrontDoorOrigins_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDOrigins_Update.json + // this example is just showing the usage of "FrontDoorOrigins_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +99,21 @@ public async Task Delete_AFDOriginsDelete() FrontDoorOriginResource frontDoorOrigin = client.GetFrontDoorOriginResource(frontDoorOriginResourceId); // invoke the operation - await frontDoorOrigin.DeleteAsync(WaitUntil.Completed); + FrontDoorOriginPatch patch = new FrontDoorOriginPatch + { + HostName = "host1.blob.core.windows.net", + HttpPort = 80, + HttpsPort = 443, + EnabledState = EnabledState.Enabled, + }; + ArmOperation lro = await frontDoorOrigin.UpdateAsync(WaitUntil.Completed, patch); + FrontDoorOriginResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorOriginData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRouteCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRouteCollection.cs index 8b774a3fad536..5554ae10d4102 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRouteCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRouteCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_FrontDoorRouteCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RoutesListByEndpoint() + public async Task CreateOrUpdate_RoutesCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_ListByEndpoint.json - // this example is just showing the usage of "FrontDoorRoutes_ListByEndpoint" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Create.json + // this example is just showing the usage of "FrontDoorRoutes_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,45 @@ public async Task GetAll_RoutesListByEndpoint() // get the collection of this FrontDoorRouteResource FrontDoorRouteCollection collection = frontDoorEndpoint.GetFrontDoorRoutes(); - // invoke the operation and iterate over the result - await foreach (FrontDoorRouteResource item in collection.GetAllAsync()) + // invoke the operation + string routeName = "route1"; + FrontDoorRouteData data = new FrontDoorRouteData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRouteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CustomDomains = {new FrontDoorActivatedResourceInfo +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/customDomains/domain1"), +}}, + OriginGroupId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/originGroups/originGroup1"), + OriginPath = null, + RuleSets = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/ruleSets/ruleSet1"), +}}, + SupportedProtocols = { FrontDoorEndpointProtocol.Https, FrontDoorEndpointProtocol.Http }, + PatternsToMatch = { "/*" }, + CacheConfiguration = new FrontDoorRouteCacheConfiguration + { + QueryStringCachingBehavior = FrontDoorQueryStringCachingBehavior.IgnoreSpecifiedQueryStrings, + QueryParameters = "querystring=test", + CompressionSettings = new RouteCacheCompressionSettings + { + ContentTypesToCompress = { "text/html", "application/octet-stream" }, + IsCompressionEnabled = true, + }, + }, + ForwardingProtocol = ForwardingProtocol.MatchRequest, + LinkToDefaultDomain = LinkToDefaultDomain.Enabled, + HttpsRedirect = HttpsRedirect.Enabled, + EnabledState = EnabledState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeName, data); + FrontDoorRouteResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRouteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +119,10 @@ public async Task Get_RoutesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RoutesGet() + public async Task GetAll_RoutesListByEndpoint() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Get.json - // this example is just showing the usage of "FrontDoorRoutes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_ListByEndpoint.json + // this example is just showing the usage of "FrontDoorRoutes_ListByEndpoint" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +141,22 @@ public async Task Exists_RoutesGet() // get the collection of this FrontDoorRouteResource FrontDoorRouteCollection collection = frontDoorEndpoint.GetFrontDoorRoutes(); - // invoke the operation - string routeName = "route1"; - bool result = await collection.ExistsAsync(routeName); + // invoke the operation and iterate over the result + await foreach (FrontDoorRouteResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRouteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RoutesGet() + public async Task Exists_RoutesGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Get.json // this example is just showing the usage of "FrontDoorRoutes_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +180,17 @@ public async Task GetIfExists_RoutesGet() // invoke the operation string routeName = "route1"; - NullableResponse response = await collection.GetIfExistsAsync(routeName); - FrontDoorRouteResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(routeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRouteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RoutesCreate() + public async Task GetIfExists_RoutesGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Create.json - // this example is just showing the usage of "FrontDoorRoutes_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Get.json + // this example is just showing the usage of "FrontDoorRoutes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,58 +211,21 @@ public async Task CreateOrUpdate_RoutesCreate() // invoke the operation string routeName = "route1"; - FrontDoorRouteData data = new FrontDoorRouteData() - { - CustomDomains = -{ -new FrontDoorActivatedResourceInfo() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/customDomains/domain1"), -} -}, - OriginGroupId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/originGroups/originGroup1"), - OriginPath = null, - RuleSets = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/ruleSets/ruleSet1"), -} -}, - SupportedProtocols = -{ -FrontDoorEndpointProtocol.Https,FrontDoorEndpointProtocol.Http -}, - PatternsToMatch = -{ -"/*" -}, - CacheConfiguration = new FrontDoorRouteCacheConfiguration() - { - QueryStringCachingBehavior = FrontDoorQueryStringCachingBehavior.IgnoreSpecifiedQueryStrings, - QueryParameters = "querystring=test", - CompressionSettings = new RouteCacheCompressionSettings() - { - ContentTypesToCompress = -{ -"text/html","application/octet-stream" -}, - IsCompressionEnabled = true, - }, - }, - ForwardingProtocol = ForwardingProtocol.MatchRequest, - LinkToDefaultDomain = LinkToDefaultDomain.Enabled, - HttpsRedirect = HttpsRedirect.Enabled, - EnabledState = EnabledState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeName, data); - FrontDoorRouteResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(routeName); + FrontDoorRouteResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRouteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRouteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRouteResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRouteResource.cs index 393a0ba01d33b..bcb8607610ad0 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRouteResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRouteResource.cs @@ -49,6 +49,34 @@ public async Task Get_RoutesGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_RoutesDelete() + { + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Delete.json + // this example is just showing the usage of "FrontDoorRoutes_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this FrontDoorRouteResource created on azure + // for more information of creating FrontDoorRouteResource, please refer to the document of FrontDoorRouteResource + string subscriptionId = "subid"; + string resourceGroupName = "RG"; + string profileName = "profile1"; + string endpointName = "endpoint1"; + string routeName = "route1"; + ResourceIdentifier frontDoorRouteResourceId = FrontDoorRouteResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointName, routeName); + FrontDoorRouteResource frontDoorRoute = client.GetFrontDoorRouteResource(frontDoorRouteResourceId); + + // invoke the operation + await frontDoorRoute.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_RoutesUpdate() @@ -72,41 +100,26 @@ public async Task Update_RoutesUpdate() FrontDoorRouteResource frontDoorRoute = client.GetFrontDoorRouteResource(frontDoorRouteResourceId); // invoke the operation - FrontDoorRoutePatch patch = new FrontDoorRoutePatch() + FrontDoorRoutePatch patch = new FrontDoorRoutePatch { - CustomDomains = -{ -new FrontDoorActivatedResourceInfo() + CustomDomains = {new FrontDoorActivatedResourceInfo { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/customDomains/domain1"), -} -}, +}}, OriginGroupId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/originGroups/originGroup1"), OriginPath = null, - RuleSets = -{ -new WritableSubResource() + RuleSets = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/RG/providers/Microsoft.Cdn/profiles/profile1/ruleSets/ruleSet1"), -} -}, - SupportedProtocols = -{ -FrontDoorEndpointProtocol.Https,FrontDoorEndpointProtocol.Http -}, - PatternsToMatch = -{ -"/*" -}, - CacheConfiguration = new FrontDoorRouteCacheConfiguration() +}}, + SupportedProtocols = { FrontDoorEndpointProtocol.Https, FrontDoorEndpointProtocol.Http }, + PatternsToMatch = { "/*" }, + CacheConfiguration = new FrontDoorRouteCacheConfiguration { QueryStringCachingBehavior = FrontDoorQueryStringCachingBehavior.IgnoreQueryString, - CompressionSettings = new RouteCacheCompressionSettings() + CompressionSettings = new RouteCacheCompressionSettings { - ContentTypesToCompress = -{ -"text/html","application/octet-stream" -}, + ContentTypesToCompress = { "text/html", "application/octet-stream" }, IsCompressionEnabled = true, }, }, @@ -124,33 +137,5 @@ public async Task Update_RoutesUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_RoutesDelete() - { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Routes_Delete.json - // this example is just showing the usage of "FrontDoorRoutes_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this FrontDoorRouteResource created on azure - // for more information of creating FrontDoorRouteResource, please refer to the document of FrontDoorRouteResource - string subscriptionId = "subid"; - string resourceGroupName = "RG"; - string profileName = "profile1"; - string endpointName = "endpoint1"; - string routeName = "route1"; - ResourceIdentifier frontDoorRouteResourceId = FrontDoorRouteResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName, endpointName, routeName); - FrontDoorRouteResource frontDoorRoute = client.GetFrontDoorRouteResource(frontDoorRouteResourceId); - - // invoke the operation - await frontDoorRoute.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleCollection.cs index 221b557e34c2e..202579210b7d2 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FrontDoorRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RulesListByRuleSet() + public async Task CreateOrUpdate_RulesCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_ListByRuleSet.json - // this example is just showing the usage of "FrontDoorRules_ListByRuleSet" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Create.json + // this example is just showing the usage of "FrontDoorRules_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,29 @@ public async Task GetAll_RulesListByRuleSet() // get the collection of this FrontDoorRuleResource FrontDoorRuleCollection collection = frontDoorRuleSet.GetFrontDoorRules(); - // invoke the operation and iterate over the result - await foreach (FrontDoorRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleName = "rule1"; + FrontDoorRuleData data = new FrontDoorRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Order = 1, + Conditions = {new DeliveryRuleRequestMethodCondition(new RequestMethodMatchCondition(RequestMethodMatchConditionType.RequestMethodCondition, RequestMethodOperator.Equal) +{ +NegateCondition = false, +MatchValues = {RequestMethodMatchConditionMatchValue.Get}, +})}, + Actions = {new DeliveryRuleResponseHeaderAction(new HeaderActionProperties(HeaderActionType.HeaderAction, HeaderAction.Overwrite, "X-CDN") +{ +Value = "MSFT", +})}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + FrontDoorRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +102,10 @@ public async Task Get_RulesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RulesGet() + public async Task GetAll_RulesListByRuleSet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Get.json - // this example is just showing the usage of "FrontDoorRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_ListByRuleSet.json + // this example is just showing the usage of "FrontDoorRules_ListByRuleSet" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +124,22 @@ public async Task Exists_RulesGet() // get the collection of this FrontDoorRuleResource FrontDoorRuleCollection collection = frontDoorRuleSet.GetFrontDoorRules(); - // invoke the operation - string ruleName = "rule1"; - bool result = await collection.ExistsAsync(ruleName); + // invoke the operation and iterate over the result + await foreach (FrontDoorRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RulesGet() + public async Task Exists_RulesGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Get.json // this example is just showing the usage of "FrontDoorRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +163,17 @@ public async Task GetIfExists_RulesGet() // invoke the operation string ruleName = "rule1"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - FrontDoorRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RulesCreate() + public async Task GetIfExists_RulesGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Create.json - // this example is just showing the usage of "FrontDoorRules_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Get.json + // this example is just showing the usage of "FrontDoorRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,36 +194,21 @@ public async Task CreateOrUpdate_RulesCreate() // invoke the operation string ruleName = "rule1"; - FrontDoorRuleData data = new FrontDoorRuleData() - { - Order = 1, - Conditions = -{ -new DeliveryRuleRequestMethodCondition(new RequestMethodMatchCondition(RequestMethodMatchConditionType.RequestMethodCondition,RequestMethodOperator.Equal) -{ -NegateCondition = false, -MatchValues = -{ -RequestMethodMatchConditionMatchValue.Get -}, -}) -}, - Actions = -{ -new DeliveryRuleResponseHeaderAction(new HeaderActionProperties(HeaderActionType.HeaderAction,HeaderAction.Overwrite,"X-CDN") -{ -Value = "MSFT", -}) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - FrontDoorRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + FrontDoorRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleResource.cs index 6035362c15336..a046bb329b79f 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleResource.cs @@ -50,10 +50,10 @@ public async Task Get_RulesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RulesUpdate() + public async Task Delete_RulesDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Update.json - // this example is just showing the usage of "FrontDoorRules_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Delete.json + // this example is just showing the usage of "FrontDoorRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,33 +71,17 @@ public async Task Update_RulesUpdate() FrontDoorRuleResource frontDoorRule = client.GetFrontDoorRuleResource(frontDoorRuleResourceId); // invoke the operation - FrontDoorRulePatch patch = new FrontDoorRulePatch() - { - Order = 1, - Actions = -{ -new DeliveryRuleResponseHeaderAction(new HeaderActionProperties(HeaderActionType.HeaderAction,HeaderAction.Overwrite,"X-CDN") -{ -Value = "MSFT", -}) -}, - }; - ArmOperation lro = await frontDoorRule.UpdateAsync(WaitUntil.Completed, patch); - FrontDoorRuleResource result = lro.Value; + await frontDoorRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RulesDelete() + public async Task Update_RulesUpdate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Delete.json - // this example is just showing the usage of "FrontDoorRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Rules_Update.json + // this example is just showing the usage of "FrontDoorRules_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,9 +99,22 @@ public async Task Delete_RulesDelete() FrontDoorRuleResource frontDoorRule = client.GetFrontDoorRuleResource(frontDoorRuleResourceId); // invoke the operation - await frontDoorRule.DeleteAsync(WaitUntil.Completed); + FrontDoorRulePatch patch = new FrontDoorRulePatch + { + Order = 1, + Actions = {new DeliveryRuleResponseHeaderAction(new HeaderActionProperties(HeaderActionType.HeaderAction, HeaderAction.Overwrite, "X-CDN") +{ +Value = "MSFT", +})}, + }; + ArmOperation lro = await frontDoorRule.UpdateAsync(WaitUntil.Completed, patch); + FrontDoorRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleSetCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleSetCollection.cs index 3501f2421f138..32b4b2cbd2e83 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleSetCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleSetCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_FrontDoorRuleSetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RuleSetsListByProfile() + public async Task CreateOrUpdate_RuleSetsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_ListByProfile.json - // this example is just showing the usage of "FrontDoorRuleSets_ListByProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Create.json + // this example is just showing the usage of "FrontDoorRuleSets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,16 @@ public async Task GetAll_RuleSetsListByProfile() // get the collection of this FrontDoorRuleSetResource FrontDoorRuleSetCollection collection = profile.GetFrontDoorRuleSets(); - // invoke the operation and iterate over the result - await foreach (FrontDoorRuleSetResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRuleSetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string ruleSetName = "ruleSet1"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName); + FrontDoorRuleSetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRuleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +86,10 @@ public async Task Get_RuleSetsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RuleSetsGet() + public async Task GetAll_RuleSetsListByProfile() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Get.json - // this example is just showing the usage of "FrontDoorRuleSets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_ListByProfile.json + // this example is just showing the usage of "FrontDoorRuleSets_ListByProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +107,22 @@ public async Task Exists_RuleSetsGet() // get the collection of this FrontDoorRuleSetResource FrontDoorRuleSetCollection collection = profile.GetFrontDoorRuleSets(); - // invoke the operation - string ruleSetName = "ruleSet1"; - bool result = await collection.ExistsAsync(ruleSetName); + // invoke the operation and iterate over the result + await foreach (FrontDoorRuleSetResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRuleSetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RuleSetsGet() + public async Task Exists_RuleSetsGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Get.json // this example is just showing the usage of "FrontDoorRuleSets_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +145,17 @@ public async Task GetIfExists_RuleSetsGet() // invoke the operation string ruleSetName = "ruleSet1"; - NullableResponse response = await collection.GetIfExistsAsync(ruleSetName); - FrontDoorRuleSetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleSetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRuleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RuleSetsCreate() + public async Task GetIfExists_RuleSetsGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Create.json - // this example is just showing the usage of "FrontDoorRuleSets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Get.json + // this example is just showing the usage of "FrontDoorRuleSets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,14 +175,21 @@ public async Task CreateOrUpdate_RuleSetsCreate() // invoke the operation string ruleSetName = "ruleSet1"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName); - FrontDoorRuleSetResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleSetName); + FrontDoorRuleSetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRuleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRuleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleSetResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleSetResource.cs index 9713b6495f75e..39ffe8ae683da 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleSetResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorRuleSetResource.cs @@ -49,10 +49,10 @@ public async Task Get_RuleSetsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RuleSetsCreate() + public async Task Delete_RuleSetsDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Create.json - // this example is just showing the usage of "FrontDoorRuleSets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Delete.json + // this example is just showing the usage of "FrontDoorRuleSets_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,22 +69,17 @@ public async Task Update_RuleSetsCreate() FrontDoorRuleSetResource frontDoorRuleSet = client.GetFrontDoorRuleSetResource(frontDoorRuleSetResourceId); // invoke the operation - ArmOperation lro = await frontDoorRuleSet.UpdateAsync(WaitUntil.Completed); - FrontDoorRuleSetResource result = lro.Value; + await frontDoorRuleSet.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorRuleSetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RuleSetsDelete() + public async Task Update_RuleSetsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Delete.json - // this example is just showing the usage of "FrontDoorRuleSets_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/RuleSets_Create.json + // this example is just showing the usage of "FrontDoorRuleSets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +96,14 @@ public async Task Delete_RuleSetsDelete() FrontDoorRuleSetResource frontDoorRuleSet = client.GetFrontDoorRuleSetResource(frontDoorRuleSetResourceId); // invoke the operation - await frontDoorRuleSet.DeleteAsync(WaitUntil.Completed); + ArmOperation lro = await frontDoorRuleSet.UpdateAsync(WaitUntil.Completed); + FrontDoorRuleSetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorRuleSetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecretCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecretCollection.cs index 86ce600938e5c..28d2c6be9c377 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecretCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecretCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_FrontDoorSecretCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SecretsListByProfile() + public async Task CreateOrUpdate_SecretsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_ListByProfile.json - // this example is just showing the usage of "FrontDoorSecrets_ListByProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Create.json + // this example is just showing the usage of "FrontDoorSecrets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,27 @@ public async Task GetAll_SecretsListByProfile() // get the collection of this FrontDoorSecretResource FrontDoorSecretCollection collection = profile.GetFrontDoorSecrets(); - // invoke the operation and iterate over the result - await foreach (FrontDoorSecretResource item in collection.GetAllAsync()) + // invoke the operation + string secretName = "secret1"; + FrontDoorSecretData data = new FrontDoorSecretData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorSecretData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new CustomerCertificateProperties(new WritableSubResource + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.KeyVault/vault/kvName/secrets/certificatename"), + }) + { + SecretVersion = "abcdef1234578900abcdef1234567890", + UseLatestVersion = false, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, secretName, data); + FrontDoorSecretResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorSecretData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +99,10 @@ public async Task Get_SecretsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SecretsGet() + public async Task GetAll_SecretsListByProfile() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Get.json - // this example is just showing the usage of "FrontDoorSecrets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_ListByProfile.json + // this example is just showing the usage of "FrontDoorSecrets_ListByProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +120,22 @@ public async Task Exists_SecretsGet() // get the collection of this FrontDoorSecretResource FrontDoorSecretCollection collection = profile.GetFrontDoorSecrets(); - // invoke the operation - string secretName = "secret1"; - bool result = await collection.ExistsAsync(secretName); + // invoke the operation and iterate over the result + await foreach (FrontDoorSecretResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorSecretData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SecretsGet() + public async Task Exists_SecretsGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Get.json // this example is just showing the usage of "FrontDoorSecrets_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +158,17 @@ public async Task GetIfExists_SecretsGet() // invoke the operation string secretName = "secret1"; - NullableResponse response = await collection.GetIfExistsAsync(secretName); - FrontDoorSecretResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(secretName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorSecretData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SecretsCreate() + public async Task GetIfExists_SecretsGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Create.json - // this example is just showing the usage of "FrontDoorSecrets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Get.json + // this example is just showing the usage of "FrontDoorSecrets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,25 +188,21 @@ public async Task CreateOrUpdate_SecretsCreate() // invoke the operation string secretName = "secret1"; - FrontDoorSecretData data = new FrontDoorSecretData() - { - Properties = new CustomerCertificateProperties(new WritableSubResource() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.KeyVault/vault/kvName/secrets/certificatename"), - }) - { - SecretVersion = "abcdef1234578900abcdef1234567890", - UseLatestVersion = false, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, secretName, data); - FrontDoorSecretResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(secretName); + FrontDoorSecretResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorSecretData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorSecretData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecretResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecretResource.cs index cca2aaf6b32a9..0ca2d982b422a 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecretResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecretResource.cs @@ -50,10 +50,10 @@ public async Task Get_SecretsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SecretsCreate() + public async Task Delete_SecretsDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Create.json - // this example is just showing the usage of "FrontDoorSecrets_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Delete.json + // this example is just showing the usage of "FrontDoorSecrets_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,33 +70,17 @@ public async Task Update_SecretsCreate() FrontDoorSecretResource frontDoorSecret = client.GetFrontDoorSecretResource(frontDoorSecretResourceId); // invoke the operation - FrontDoorSecretData data = new FrontDoorSecretData() - { - Properties = new CustomerCertificateProperties(new WritableSubResource() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.KeyVault/vault/kvName/secrets/certificatename"), - }) - { - SecretVersion = "abcdef1234578900abcdef1234567890", - UseLatestVersion = false, - }, - }; - ArmOperation lro = await frontDoorSecret.UpdateAsync(WaitUntil.Completed, data); - FrontDoorSecretResource result = lro.Value; + await frontDoorSecret.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorSecretData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SecretsDelete() + public async Task Update_SecretsCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Delete.json - // this example is just showing the usage of "FrontDoorSecrets_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Secrets_Create.json + // this example is just showing the usage of "FrontDoorSecrets_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,9 +97,25 @@ public async Task Delete_SecretsDelete() FrontDoorSecretResource frontDoorSecret = client.GetFrontDoorSecretResource(frontDoorSecretResourceId); // invoke the operation - await frontDoorSecret.DeleteAsync(WaitUntil.Completed); + FrontDoorSecretData data = new FrontDoorSecretData + { + Properties = new CustomerCertificateProperties(new WritableSubResource + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.KeyVault/vault/kvName/secrets/certificatename"), + }) + { + SecretVersion = "abcdef1234578900abcdef1234567890", + UseLatestVersion = false, + }, + }; + ArmOperation lro = await frontDoorSecret.UpdateAsync(WaitUntil.Completed, data); + FrontDoorSecretResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorSecretData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecurityPolicyCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecurityPolicyCollection.cs index 0c981a5c64d65..a9694f2505b4c 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecurityPolicyCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecurityPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FrontDoorSecurityPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SecurityPoliciesListByProfile() + public async Task CreateOrUpdate_SecurityPoliciesCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_ListByProfile.json - // this example is just showing the usage of "FrontDoorSecurityPolicies_ListByProfile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Create.json + // this example is just showing the usage of "FrontDoorSecurityPolicies_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,34 @@ public async Task GetAll_SecurityPoliciesListByProfile() // get the collection of this FrontDoorSecurityPolicyResource FrontDoorSecurityPolicyCollection collection = profile.GetFrontDoorSecurityPolicies(); - // invoke the operation and iterate over the result - await foreach (FrontDoorSecurityPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string securityPolicyName = "securityPolicy1"; + FrontDoorSecurityPolicyData data = new FrontDoorSecurityPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorSecurityPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new SecurityPolicyWebApplicationFirewall + { + WafPolicyId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Network/frontdoorwebapplicationfirewallpolicies/wafTest"), + Associations = {new SecurityPolicyWebApplicationFirewallAssociation +{ +Domains = {new FrontDoorActivatedResourceInfo +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Cdn/profiles/profile1/customdomains/testdomain1"), +}, new FrontDoorActivatedResourceInfo +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Cdn/profiles/profile1/customdomains/testdomain2"), +}}, +PatternsToMatch = {"/*"}, +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityPolicyName, data); + FrontDoorSecurityPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorSecurityPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +105,10 @@ public async Task Get_SecurityPoliciesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SecurityPoliciesGet() + public async Task GetAll_SecurityPoliciesListByProfile() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Get.json - // this example is just showing the usage of "FrontDoorSecurityPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_ListByProfile.json + // this example is just showing the usage of "FrontDoorSecurityPolicies_ListByProfile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +126,22 @@ public async Task Exists_SecurityPoliciesGet() // get the collection of this FrontDoorSecurityPolicyResource FrontDoorSecurityPolicyCollection collection = profile.GetFrontDoorSecurityPolicies(); - // invoke the operation - string securityPolicyName = "securityPolicy1"; - bool result = await collection.ExistsAsync(securityPolicyName); + // invoke the operation and iterate over the result + await foreach (FrontDoorSecurityPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorSecurityPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SecurityPoliciesGet() + public async Task Exists_SecurityPoliciesGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Get.json // this example is just showing the usage of "FrontDoorSecurityPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +164,17 @@ public async Task GetIfExists_SecurityPoliciesGet() // invoke the operation string securityPolicyName = "securityPolicy1"; - NullableResponse response = await collection.GetIfExistsAsync(securityPolicyName); - FrontDoorSecurityPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(securityPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorSecurityPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SecurityPoliciesCreate() + public async Task GetIfExists_SecurityPoliciesGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Create.json - // this example is just showing the usage of "FrontDoorSecurityPolicies_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Get.json + // this example is just showing the usage of "FrontDoorSecurityPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,41 +194,21 @@ public async Task CreateOrUpdate_SecurityPoliciesCreate() // invoke the operation string securityPolicyName = "securityPolicy1"; - FrontDoorSecurityPolicyData data = new FrontDoorSecurityPolicyData() - { - Properties = new SecurityPolicyWebApplicationFirewall() - { - WafPolicyId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Network/frontdoorwebapplicationfirewallpolicies/wafTest"), - Associations = -{ -new SecurityPolicyWebApplicationFirewallAssociation() -{ -Domains = -{ -new FrontDoorActivatedResourceInfo() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Cdn/profiles/profile1/customdomains/testdomain1"), -},new FrontDoorActivatedResourceInfo() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Cdn/profiles/profile1/customdomains/testdomain2"), -} -}, -PatternsToMatch = -{ -"/*" -}, -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityPolicyName, data); - FrontDoorSecurityPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(securityPolicyName); + FrontDoorSecurityPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorSecurityPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorSecurityPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecurityPolicyResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecurityPolicyResource.cs index 76bf155345d35..d3f0d547ceecf 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecurityPolicyResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_FrontDoorSecurityPolicyResource.cs @@ -49,10 +49,10 @@ public async Task Get_SecurityPoliciesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SecurityPoliciesPatch() + public async Task Delete_SecurityPoliciesDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Patch.json - // this example is just showing the usage of "FrontDoorSecurityPolicies_Patch" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Delete.json + // this example is just showing the usage of "FrontDoorSecurityPolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,49 +69,17 @@ public async Task Update_SecurityPoliciesPatch() FrontDoorSecurityPolicyResource frontDoorSecurityPolicy = client.GetFrontDoorSecurityPolicyResource(frontDoorSecurityPolicyResourceId); // invoke the operation - FrontDoorSecurityPolicyPatch patch = new FrontDoorSecurityPolicyPatch() - { - Properties = new SecurityPolicyWebApplicationFirewall() - { - WafPolicyId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Network/frontdoorwebapplicationfirewallpolicies/wafTest"), - Associations = -{ -new SecurityPolicyWebApplicationFirewallAssociation() -{ -Domains = -{ -new FrontDoorActivatedResourceInfo() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Cdn/profiles/profile1/customdomains/testdomain1"), -},new FrontDoorActivatedResourceInfo() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Cdn/profiles/profile1/customdomains/testdomain2"), -} -}, -PatternsToMatch = -{ -"/*" -}, -} -}, - }, - }; - ArmOperation lro = await frontDoorSecurityPolicy.UpdateAsync(WaitUntil.Completed, patch); - FrontDoorSecurityPolicyResource result = lro.Value; + await frontDoorSecurityPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontDoorSecurityPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SecurityPoliciesDelete() + public async Task Update_SecurityPoliciesPatch() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Delete.json - // this example is just showing the usage of "FrontDoorSecurityPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/SecurityPolicies_Patch.json + // this example is just showing the usage of "FrontDoorSecurityPolicies_Patch" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -128,9 +96,32 @@ public async Task Delete_SecurityPoliciesDelete() FrontDoorSecurityPolicyResource frontDoorSecurityPolicy = client.GetFrontDoorSecurityPolicyResource(frontDoorSecurityPolicyResourceId); // invoke the operation - await frontDoorSecurityPolicy.DeleteAsync(WaitUntil.Completed); + FrontDoorSecurityPolicyPatch patch = new FrontDoorSecurityPolicyPatch + { + Properties = new SecurityPolicyWebApplicationFirewall + { + WafPolicyId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Network/frontdoorwebapplicationfirewallpolicies/wafTest"), + Associations = {new SecurityPolicyWebApplicationFirewallAssociation +{ +Domains = {new FrontDoorActivatedResourceInfo +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Cdn/profiles/profile1/customdomains/testdomain1"), +}, new FrontDoorActivatedResourceInfo +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Cdn/profiles/profile1/customdomains/testdomain2"), +}}, +PatternsToMatch = {"/*"}, +}}, + }, + }; + ArmOperation lro = await frontDoorSecurityPolicy.UpdateAsync(WaitUntil.Completed, patch); + FrontDoorSecurityPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontDoorSecurityPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ProfileCollection.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ProfileCollection.cs index 1757c7a87ac35..049fe08d5a673 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ProfileCollection.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ProfileCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ProfilesListByResourceGroup() + public async Task CreateOrUpdate_ProfilesCreate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_ListByResourceGroup.json - // this example is just showing the usage of "Profiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Create.json + // this example is just showing the usage of "Profiles_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ProfilesListByResourceGroup() // get the collection of this ProfileResource ProfileCollection collection = resourceGroupResource.GetProfiles(); - // invoke the operation and iterate over the result - await foreach (ProfileResource item in collection.GetAllAsync()) + // invoke the operation + string profileName = "profile1"; + ProfileData data = new ProfileData(new AzureLocation("global"), new CdnSku { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Name = CdnSkuName.PremiumAzureFrontDoor, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); + ProfileResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_ProfilesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ProfilesGet() + public async Task GetAll_ProfilesListByResourceGroup() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Get.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_ListByResourceGroup.json + // this example is just showing the usage of "Profiles_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +110,22 @@ public async Task Exists_ProfilesGet() // get the collection of this ProfileResource ProfileCollection collection = resourceGroupResource.GetProfiles(); - // invoke the operation - string profileName = "profile1"; - bool result = await collection.ExistsAsync(profileName); + // invoke the operation and iterate over the result + await foreach (ProfileResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ProfilesGet() + public async Task Exists_ProfilesGet() { // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Get.json // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +147,17 @@ public async Task GetIfExists_ProfilesGet() // invoke the operation string profileName = "profile1"; - NullableResponse response = await collection.GetIfExistsAsync(profileName); - ProfileResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(profileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ProfilesCreate() + public async Task GetIfExists_ProfilesGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Create.json - // this example is just showing the usage of "Profiles_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Get.json + // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,18 +176,21 @@ public async Task CreateOrUpdate_ProfilesCreate() // invoke the operation string profileName = "profile1"; - ProfileData data = new ProfileData(new AzureLocation("global"), new CdnSku() - { - Name = CdnSkuName.PremiumAzureFrontDoor, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, profileName, data); - ProfileResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(profileName); + ProfileResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ProfileResource.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ProfileResource.cs index c85783e1ade59..c01c3cf0be306 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ProfileResource.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ProfileResource.cs @@ -6,11 +6,11 @@ #nullable disable using System; +using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Cdn.Models; -using Azure.ResourceManager.Resources; using Azure.ResourceManager.Resources.Models; using NUnit.Framework; @@ -20,69 +20,10 @@ public partial class Sample_ProfileResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CheckEndpointNameAvailabilityFrontDoorProfile_CheckEndpointNameAvailability() - { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_CheckEndpointNameAvailability.json - // this example is just showing the usage of "FrontDoorProfiles_CheckEndpointNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ProfileResource created on azure - // for more information of creating ProfileResource, please refer to the document of ProfileResource - string subscriptionId = "subid"; - string resourceGroupName = "myResourceGroup"; - string profileName = "profile1"; - ResourceIdentifier profileResourceId = ProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - ProfileResource profile = client.GetProfileResource(profileResourceId); - - // invoke the operation - EndpointNameAvailabilityContent content = new EndpointNameAvailabilityContent("sampleName", CdnResourceType.FrontDoorEndpoints) - { - AutoGeneratedDomainNameLabelScope = DomainNameLabelScope.TenantReuse, - }; - EndpointNameAvailabilityResult result = await profile.CheckEndpointNameAvailabilityFrontDoorProfileAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetFrontDoorProfileResourceUsages_AFDProfilesListResourceUsage() - { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_ListResourceUsage.json - // this example is just showing the usage of "FrontDoorProfiles_ListResourceUsage" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ProfileResource created on azure - // for more information of creating ProfileResource, please refer to the document of ProfileResource - string subscriptionId = "subid"; - string resourceGroupName = "RG"; - string profileName = "profile1"; - ResourceIdentifier profileResourceId = ProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); - ProfileResource profile = client.GetProfileResource(profileResourceId); - - // invoke the operation and iterate over the result - await foreach (FrontDoorUsage item in profile.GetFrontDoorProfileResourceUsagesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckFrontDoorProfileHostNameAvailability_AFDProfilesCheckHostNameAvailability() + public async Task Get_ProfilesGet() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_CheckHostNameAvailability.json - // this example is just showing the usage of "FrontDoorProfiles_CheckHostNameAvailability" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Get.json + // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,18 +39,21 @@ public async Task CheckFrontDoorProfileHostNameAvailability_AFDProfilesCheckHost ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - HostNameAvailabilityContent content = new HostNameAvailabilityContent("www.someDomain.net"); - CdnNameAvailabilityResult result = await profile.CheckFrontDoorProfileHostNameAvailabilityAsync(content); + ProfileResource result = await profile.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateSecretFrontDoorProfile_ValidateSecret() + public async Task Delete_ProfilesDelete() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_ValidateSecret.json - // this example is just showing the usage of "FrontDoorProfiles_ValidateSecret" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Delete.json + // this example is just showing the usage of "Profiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,21 +69,17 @@ public async Task ValidateSecretFrontDoorProfile_ValidateSecret() ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - ValidateSecretContent content = new ValidateSecretContent(SecretType.CustomerCertificate, new WritableSubResource() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.KeyVault/vault/kvName/certificate/certName"), - }); - ValidateSecretResult result = await profile.ValidateSecretFrontDoorProfileAsync(content); + await profile.DeleteAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task UpgradeFrontDoorProfile_AFDProfilesUpgrade() + public async Task Update_ProfilesUpdate() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_Upgrade.json - // this example is just showing the usage of "FrontDoorProfiles_Upgrade" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Update.json + // this example is just showing the usage of "Profiles_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -155,14 +95,14 @@ public async Task UpgradeFrontDoorProfile_AFDProfilesUpgrade() ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - ProfileUpgradeContent content = new ProfileUpgradeContent(new ProfileChangeSkuWafMapping[] + ProfilePatch patch = new ProfilePatch { -new ProfileChangeSkuWafMapping("securityPolicy1",new WritableSubResource() + Tags = { -Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Network/frontdoorwebapplicationfirewallpolicies/waf2"), -}) - }); - ArmOperation lro = await profile.UpgradeFrontDoorProfileAsync(WaitUntil.Completed, content); +["additionalProperties"] = "Tag1" +}, + }; + ArmOperation lro = await profile.UpdateAsync(WaitUntil.Completed, patch); ProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well @@ -174,10 +114,10 @@ public async Task UpgradeFrontDoorProfile_AFDProfilesUpgrade() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLogAnalyticsRankings_LogAnalyticsGetLogAnalyticsRankings() + public async Task CheckEndpointNameAvailabilityFrontDoorProfile_CheckEndpointNameAvailability() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsRankings.json - // this example is just showing the usage of "LogAnalytics_GetLogAnalyticsRankings" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_CheckEndpointNameAvailability.json + // this example is just showing the usage of "FrontDoorProfiles_CheckEndpointNameAvailability" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,31 +127,27 @@ public async Task GetLogAnalyticsRankings_LogAnalyticsGetLogAnalyticsRankings() // this example assumes you already have this ProfileResource created on azure // for more information of creating ProfileResource, please refer to the document of ProfileResource string subscriptionId = "subid"; - string resourceGroupName = "RG"; + string resourceGroupName = "myResourceGroup"; string profileName = "profile1"; ResourceIdentifier profileResourceId = ProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - ProfileResourceGetLogAnalyticsRankingsOptions options = new ProfileResourceGetLogAnalyticsRankingsOptions(rankings: new LogRanking[] - { -LogRanking.Uri - }, metrics: new LogRankingMetric[] + EndpointNameAvailabilityContent content = new EndpointNameAvailabilityContent("sampleName", CdnResourceType.FrontDoorEndpoints) { -LogRankingMetric.ClientRequestCount - }, maxRanking: 5, dateTimeBegin: DateTimeOffset.Parse("2020-11-04T06:49:27.554Z"), dateTimeEnd: DateTimeOffset.Parse("2020-11-04T09:49:27.554Z")) - { }; - RankingsResponse result = await profile.GetLogAnalyticsRankingsAsync(options); + AutoGeneratedDomainNameLabelScope = DomainNameLabelScope.TenantReuse, + }; + EndpointNameAvailabilityResult result = await profile.CheckEndpointNameAvailabilityFrontDoorProfileAsync(content); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLogAnalyticsLocations_LogAnalyticsGetLogAnalyticsLocations() + public async Task GetFrontDoorProfileResourceUsages_AFDProfilesListResourceUsage() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsLocations.json - // this example is just showing the usage of "LogAnalytics_GetLogAnalyticsLocations" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_ListResourceUsage.json + // this example is just showing the usage of "FrontDoorProfiles_ListResourceUsage" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,18 +162,21 @@ public async Task GetLogAnalyticsLocations_LogAnalyticsGetLogAnalyticsLocations( ResourceIdentifier profileResourceId = ProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); ProfileResource profile = client.GetProfileResource(profileResourceId); - // invoke the operation - ContinentsResponse result = await profile.GetLogAnalyticsLocationsAsync(); + // invoke the operation and iterate over the result + await foreach (FrontDoorUsage item in profile.GetFrontDoorProfileResourceUsagesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLogAnalyticsResources_LogAnalyticsGetLogAnalyticsResources() + public async Task CheckFrontDoorProfileHostNameAvailability_AFDProfilesCheckHostNameAvailability() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsResources.json - // this example is just showing the usage of "LogAnalytics_GetLogAnalyticsResources" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_CheckHostNameAvailability.json + // this example is just showing the usage of "FrontDoorProfiles_CheckHostNameAvailability" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -253,17 +192,18 @@ public async Task GetLogAnalyticsResources_LogAnalyticsGetLogAnalyticsResources( ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - ResourcesResponse result = await profile.GetLogAnalyticsResourcesAsync(); + HostNameAvailabilityContent content = new HostNameAvailabilityContent("www.someDomain.net"); + CdnNameAvailabilityResult result = await profile.CheckFrontDoorProfileHostNameAvailabilityAsync(content); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetWafLogAnalyticsRankings_LogAnalyticsGetWafLogAnalyticsRankings() + public async Task ValidateSecretFrontDoorProfile_ValidateSecret() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetWafLogAnalyticsRankings.json - // this example is just showing the usage of "LogAnalytics_GetWafLogAnalyticsRankings" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_ValidateSecret.json + // this example is just showing the usage of "FrontDoorProfiles_ValidateSecret" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -279,56 +219,21 @@ public async Task GetWafLogAnalyticsRankings_LogAnalyticsGetWafLogAnalyticsRanki ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - ProfileResourceGetWafLogAnalyticsRankingsOptions options = new ProfileResourceGetWafLogAnalyticsRankingsOptions(metrics: new WafMetric[] - { -WafMetric.ClientRequestCount - }, dateTimeBegin: DateTimeOffset.Parse("2020-11-04T06:49:27.554Z"), dateTimeEnd: DateTimeOffset.Parse("2020-11-04T09:49:27.554Z"), maxRanking: 5, rankings: new WafRankingType[] + ValidateSecretContent content = new ValidateSecretContent(SecretType.CustomerCertificate, new WritableSubResource { -WafRankingType.RuleId - }) - { }; - WafRankingsResponse result = await profile.GetWafLogAnalyticsRankingsAsync(options); + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.KeyVault/vault/kvName/certificate/certName"), + }); + ValidateSecretResult result = await profile.ValidateSecretFrontDoorProfileAsync(content); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetProfiles_ProfilesList() - { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_List.json - // this example is just showing the usage of "Profiles_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ProfileResource item in subscriptionResource.GetProfilesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_ProfilesGet() + public async Task UpgradeFrontDoorProfile_AFDProfilesUpgrade() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Get.json - // this example is just showing the usage of "Profiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/AFDProfiles_Upgrade.json + // this example is just showing the usage of "FrontDoorProfiles_Upgrade" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -344,7 +249,15 @@ public async Task Get_ProfilesGet() ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - ProfileResource result = await profile.GetAsync(); + ProfileUpgradeContent content = new ProfileUpgradeContent(new ProfileChangeSkuWafMapping[] + { +new ProfileChangeSkuWafMapping("securityPolicy1", new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Network/frontdoorwebapplicationfirewallpolicies/waf2"), +}) + }); + ArmOperation lro = await profile.UpgradeFrontDoorProfileAsync(WaitUntil.Completed, content); + ProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -355,10 +268,10 @@ public async Task Get_ProfilesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ProfilesUpdate() + public async Task GetLogAnalyticsRankings_LogAnalyticsGetLogAnalyticsRankings() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Update.json - // this example is just showing the usage of "Profiles_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsRankings.json + // this example is just showing the usage of "LogAnalytics_GetLogAnalyticsRankings" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -374,29 +287,23 @@ public async Task Update_ProfilesUpdate() ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - ProfilePatch patch = new ProfilePatch() - { - Tags = -{ -["additionalProperties"] = "Tag1", -}, - }; - ArmOperation lro = await profile.UpdateAsync(WaitUntil.Completed, patch); - ProfileResource result = lro.Value; + IEnumerable rankings = new LogRanking[] { LogRanking.Uri }; + IEnumerable metrics = new LogRankingMetric[] { LogRankingMetric.ClientRequestCount }; + int maxRanking = 5; + DateTimeOffset dateTimeBegin = DateTimeOffset.Parse("2020-11-04T06:49:27.554Z"); + DateTimeOffset dateTimeEnd = DateTimeOffset.Parse("2020-11-04T09:49:27.554Z"); + ProfileResourceGetLogAnalyticsRankingsOptions options = new ProfileResourceGetLogAnalyticsRankingsOptions(rankings, metrics, maxRanking, dateTimeBegin, dateTimeEnd); + RankingsResponse result = await profile.GetLogAnalyticsRankingsAsync(options); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ProfilesDelete() + public async Task GetLogAnalyticsLocations_LogAnalyticsGetLogAnalyticsLocations() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Delete.json - // this example is just showing the usage of "Profiles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsLocations.json + // this example is just showing the usage of "LogAnalytics_GetLogAnalyticsLocations" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -412,70 +319,65 @@ public async Task Delete_ProfilesDelete() ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - await profile.DeleteAsync(WaitUntil.Completed); + ContinentsResponse result = await profile.GetLogAnalyticsLocationsAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CanMigrateProfile_ProfilesCanMigrate() + public async Task GetLogAnalyticsResources_LogAnalyticsGetLogAnalyticsResources() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_CanMigrate.json - // this example is just showing the usage of "Profiles_CanMigrate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetLogAnalyticsResources.json + // this example is just showing the usage of "LogAnalytics_GetLogAnalyticsResources" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + // this example assumes you already have this ProfileResource created on azure + // for more information of creating ProfileResource, please refer to the document of ProfileResource string subscriptionId = "subid"; string resourceGroupName = "RG"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + string profileName = "profile1"; + ResourceIdentifier profileResourceId = ProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); + ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - CanMigrateContent content = new CanMigrateContent(new WritableSubResource() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Network/frontdoors/frontdoorname"), - }); - ArmOperation lro = await resourceGroupResource.CanMigrateProfileAsync(WaitUntil.Completed, content); - CanMigrateResult result = lro.Value; + ResourcesResponse result = await profile.GetLogAnalyticsResourcesAsync(); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task MigrateProfile_ProfilesMigrate() + public async Task GetWafLogAnalyticsRankings_LogAnalyticsGetWafLogAnalyticsRankings() { - // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Migrate.json - // this example is just showing the usage of "Profiles_Migrate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/LogAnalytics_GetWafLogAnalyticsRankings.json + // this example is just showing the usage of "LogAnalytics_GetWafLogAnalyticsRankings" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + // this example assumes you already have this ProfileResource created on azure + // for more information of creating ProfileResource, please refer to the document of ProfileResource string subscriptionId = "subid"; string resourceGroupName = "RG"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + string profileName = "profile1"; + ResourceIdentifier profileResourceId = ProfileResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, profileName); + ProfileResource profile = client.GetProfileResource(profileResourceId); // invoke the operation - MigrationContent content = new MigrationContent(new CdnSku() - { - Name = CdnSkuName.StandardAzureFrontDoor, - }, new WritableSubResource() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Network/frontdoors/frontdoorname"), - }, "profile1"); - ArmOperation lro = await resourceGroupResource.MigrateProfileAsync(WaitUntil.Completed, content); - MigrateResult result = lro.Value; + IEnumerable metrics = new WafMetric[] { WafMetric.ClientRequestCount }; + DateTimeOffset dateTimeBegin = DateTimeOffset.Parse("2020-11-04T06:49:27.554Z"); + DateTimeOffset dateTimeEnd = DateTimeOffset.Parse("2020-11-04T09:49:27.554Z"); + int maxRanking = 5; + IEnumerable rankings = new WafRankingType[] { WafRankingType.RuleId }; + ProfileResourceGetWafLogAnalyticsRankingsOptions options = new ProfileResourceGetWafLogAnalyticsRankingsOptions(metrics, dateTimeBegin, dateTimeEnd, maxRanking, rankings); + WafRankingsResponse result = await profile.GetWafLogAnalyticsRankingsAsync(options); Console.WriteLine($"Succeeded: {result}"); } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index 2f30db5bc0d9c..3be1ccb0bf969 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -11,6 +11,7 @@ using Azure.Identity; using Azure.ResourceManager.Cdn.Models; using Azure.ResourceManager.Resources; +using Azure.ResourceManager.Resources.Models; using NUnit.Framework; namespace Azure.ResourceManager.Cdn.Samples @@ -45,5 +46,68 @@ public async Task CheckEndpointNameAvailability_CheckEndpointNameAvailability() Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CanMigrateProfile_ProfilesCanMigrate() + { + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_CanMigrate.json + // this example is just showing the usage of "Profiles_CanMigrate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "RG"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation + CanMigrateContent content = new CanMigrateContent(new WritableSubResource + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Network/frontdoors/frontdoorname"), + }); + ArmOperation lro = await resourceGroupResource.CanMigrateProfileAsync(WaitUntil.Completed, content); + CanMigrateResult result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task MigrateProfile_ProfilesMigrate() + { + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_Migrate.json + // this example is just showing the usage of "Profiles_Migrate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "RG"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation + MigrationContent content = new MigrationContent(new CdnSku + { + Name = CdnSkuName.StandardAzureFrontDoor, + }, new WritableSubResource + { + Id = new ResourceIdentifier("/subscriptions/subid/resourcegroups/RG/providers/Microsoft.Network/frontdoors/frontdoorname"), + }, "profile1"); + ArmOperation lro = await resourceGroupResource.MigrateProfileAsync(WaitUntil.Completed, content); + MigrateResult result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } } } diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 71cd2ef27e189..be8d97130240f 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -67,6 +67,37 @@ public async Task ValidateProbe_ValidateProbe() Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetProfiles_ProfilesList() + { + // Generated from example definition: specification/cdn/resource-manager/Microsoft.Cdn/stable/2024-02-01/examples/Profiles_List.json + // this example is just showing the usage of "Profiles_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ProfileResource item in subscriptionResource.GetProfilesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetResourceUsages_ResourceUsageList() diff --git a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index fe8e46143e37e..15365e7a0a5fe 100644 --- a/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/cdn/Azure.ResourceManager.Cdn/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Cdn.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Cdn.Samples @@ -28,9 +29,7 @@ public async Task CheckCdnNameAvailability_CheckNameAvailability() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation CdnNameAvailabilityContent content = new CdnNameAvailabilityContent("sampleName", CdnResourceType.Endpoints); @@ -51,9 +50,7 @@ public async Task GetEdgeNodes_EdgeNodesList() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (EdgeNode item in tenantResource.GetEdgeNodesAsync()) diff --git a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosCapabilityCollection.cs b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosCapabilityCollection.cs index ad3ef47e22557..05c4c232eb51d 100644 --- a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosCapabilityCollection.cs +++ b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosCapabilityCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ChaosCapabilityCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllCapabilitiesThatExtendAVirtualMachineTargetResource() + public async Task CreateOrUpdate_CreateUpdateACapabilityThatExtendsAVirtualMachineTargetResource() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListCapabilities.json - // this example is just showing the usage of "Capabilities_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/CreateUpdateCapability.json + // this example is just showing the usage of "Capabilities_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,17 @@ public async Task GetAll_ListAllCapabilitiesThatExtendAVirtualMachineTargetResou // get the collection of this ChaosCapabilityResource ChaosCapabilityCollection collection = chaosTarget.GetChaosCapabilities(); - // invoke the operation and iterate over the result - await foreach (ChaosCapabilityResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosCapabilityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string capabilityName = "Shutdown-1.0"; + ChaosCapabilityData data = new ChaosCapabilityData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, capabilityName, data); + ChaosCapabilityResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosCapabilityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -93,10 +93,10 @@ public async Task Get_GetACapabilityThatExtendsAVirtualMachineTargetResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetACapabilityThatExtendsAVirtualMachineTargetResource() + public async Task GetAll_ListAllCapabilitiesThatExtendAVirtualMachineTargetResource() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetCapability.json - // this example is just showing the usage of "Capabilities_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListCapabilities.json + // this example is just showing the usage of "Capabilities_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,16 +117,22 @@ public async Task Exists_GetACapabilityThatExtendsAVirtualMachineTargetResource( // get the collection of this ChaosCapabilityResource ChaosCapabilityCollection collection = chaosTarget.GetChaosCapabilities(); - // invoke the operation - string capabilityName = "Shutdown-1.0"; - bool result = await collection.ExistsAsync(capabilityName); + // invoke the operation and iterate over the result + await foreach (ChaosCapabilityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosCapabilityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetACapabilityThatExtendsAVirtualMachineTargetResource() + public async Task Exists_GetACapabilityThatExtendsAVirtualMachineTargetResource() { // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetCapability.json // this example is just showing the usage of "Capabilities_Get" operation, for the dependent resources, they will have to be created separately. @@ -152,29 +158,17 @@ public async Task GetIfExists_GetACapabilityThatExtendsAVirtualMachineTargetReso // invoke the operation string capabilityName = "Shutdown-1.0"; - NullableResponse response = await collection.GetIfExistsAsync(capabilityName); - ChaosCapabilityResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(capabilityName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosCapabilityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateUpdateACapabilityThatExtendsAVirtualMachineTargetResource() + public async Task GetIfExists_GetACapabilityThatExtendsAVirtualMachineTargetResource() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/CreateUpdateCapability.json - // this example is just showing the usage of "Capabilities_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetCapability.json + // this example is just showing the usage of "Capabilities_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -197,15 +191,21 @@ public async Task CreateOrUpdate_CreateUpdateACapabilityThatExtendsAVirtualMachi // invoke the operation string capabilityName = "Shutdown-1.0"; - ChaosCapabilityData data = new ChaosCapabilityData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, capabilityName, data); - ChaosCapabilityResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(capabilityName); + ChaosCapabilityResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosCapabilityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosCapabilityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosCapabilityTypeCollection.cs b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosCapabilityTypeCollection.cs index 6b193afe70f62..ad19b8b723d18 100644 --- a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosCapabilityTypeCollection.cs +++ b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosCapabilityTypeCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ChaosCapabilityTypeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllCapabilityTypesForAVirtualMachineTargetResourceOnWestus2Location() + public async Task Get_GetACapabilityTypeForAVirtualMachineTargetResourceOnWestus2Location() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListCapabilityTypes.json - // this example is just showing the usage of "CapabilityTypes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetCapabilityType.json + // this example is just showing the usage of "CapabilityTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListAllCapabilityTypesForAVirtualMachineTargetResourceO // get the collection of this ChaosCapabilityTypeResource ChaosCapabilityTypeCollection collection = chaosTargetType.GetChaosCapabilityTypes(); - // invoke the operation and iterate over the result - await foreach (ChaosCapabilityTypeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosCapabilityTypeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string capabilityTypeName = "Shutdown-1.0"; + ChaosCapabilityTypeResource result = await collection.GetAsync(capabilityTypeName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosCapabilityTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetACapabilityTypeForAVirtualMachineTargetResourceOnWestus2Location() + public async Task GetAll_ListAllCapabilityTypesForAVirtualMachineTargetResourceOnWestus2Location() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetCapabilityType.json - // this example is just showing the usage of "CapabilityTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListCapabilityTypes.json + // this example is just showing the usage of "CapabilityTypes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetACapabilityTypeForAVirtualMachineTargetResourceOnWestus // get the collection of this ChaosCapabilityTypeResource ChaosCapabilityTypeCollection collection = chaosTargetType.GetChaosCapabilityTypes(); - // invoke the operation - string capabilityTypeName = "Shutdown-1.0"; - ChaosCapabilityTypeResource result = await collection.GetAsync(capabilityTypeName); + // invoke the operation and iterate over the result + await foreach (ChaosCapabilityTypeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosCapabilityTypeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosCapabilityTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentCollection.cs b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentCollection.cs index 05ea01c6cea7d..3b612ed83a8c6 100644 --- a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentCollection.cs +++ b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentCollection.cs @@ -21,10 +21,10 @@ public partial class Sample_ChaosExperimentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllExperimentsInAResourceGroup() + public async Task CreateOrUpdate_CreateUpdateAExperimentInAResourceGroup() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListExperimentsInAResourceGroup.json - // this example is just showing the usage of "Experiments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/CreateUpdateExperiment.json + // this example is just showing the usage of "Experiments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,18 +41,38 @@ public async Task GetAll_ListAllExperimentsInAResourceGroup() // get the collection of this ChaosExperimentResource ChaosExperimentCollection collection = resourceGroupResource.GetChaosExperiments(); - // invoke the operation and iterate over the result - string continuationToken = null; - await foreach (ChaosExperimentResource item in collection.GetAllAsync(continuationToken: continuationToken)) + // invoke the operation + string experimentName = "exampleExperiment"; + ChaosExperimentData data = new ChaosExperimentData(new AzureLocation("eastus2euap"), new ChaosExperimentStep[] { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosExperimentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } +new ChaosExperimentStep("step1", new ChaosExperimentBranch[] +{ +new ChaosExperimentBranch("branch1", new ChaosExperimentAction[] +{ +new ChaosContinuousAction("urn:csci:microsoft:virtualMachine:shutdown/1.0", XmlConvert.ToTimeSpan("PT10M"), new ChaosKeyValuePair[] +{ +new ChaosKeyValuePair("abruptShutdown", "false") +}, "selector1") +}) +}) + }, new ChaosTargetSelector[] + { +new ChaosTargetListSelector("selector1", new ChaosTargetReference[] +{ +new ChaosTargetReference(ChaosTargetReferenceType.ChaosTarget, new ResourceIdentifier("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine")) +}) + }) + { + Identity = new ManagedServiceIdentity("SystemAssigned"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, experimentName, data); + ChaosExperimentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosExperimentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +110,10 @@ public async Task Get_GetAExperimentInAResourceGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAExperimentInAResourceGroup() + public async Task GetAll_ListAllExperimentsInAResourceGroup() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetExperiment.json - // this example is just showing the usage of "Experiments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListExperimentsInAResourceGroup.json + // this example is just showing the usage of "Experiments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +130,23 @@ public async Task Exists_GetAExperimentInAResourceGroup() // get the collection of this ChaosExperimentResource ChaosExperimentCollection collection = resourceGroupResource.GetChaosExperiments(); - // invoke the operation - string experimentName = "exampleExperiment"; - bool result = await collection.ExistsAsync(experimentName); + // invoke the operation and iterate over the result + string continuationToken = null; + await foreach (ChaosExperimentResource item in collection.GetAllAsync(continuationToken: continuationToken)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosExperimentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAExperimentInAResourceGroup() + public async Task Exists_GetAExperimentInAResourceGroup() { // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetExperiment.json // this example is just showing the usage of "Experiments_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +168,17 @@ public async Task GetIfExists_GetAExperimentInAResourceGroup() // invoke the operation string experimentName = "exampleExperiment"; - NullableResponse response = await collection.GetIfExistsAsync(experimentName); - ChaosExperimentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(experimentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosExperimentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateUpdateAExperimentInAResourceGroup() + public async Task GetIfExists_GetAExperimentInAResourceGroup() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/CreateUpdateExperiment.json - // this example is just showing the usage of "Experiments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetExperiment.json + // this example is just showing the usage of "Experiments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,36 +197,21 @@ public async Task CreateOrUpdate_CreateUpdateAExperimentInAResourceGroup() // invoke the operation string experimentName = "exampleExperiment"; - ChaosExperimentData data = new ChaosExperimentData(new AzureLocation("eastus2euap"), new ChaosExperimentStep[] - { -new ChaosExperimentStep("step1",new ChaosExperimentBranch[] -{ -new ChaosExperimentBranch("branch1",new ChaosExperimentAction[] -{ -new ChaosContinuousAction("urn:csci:microsoft:virtualMachine:shutdown/1.0",XmlConvert.ToTimeSpan("PT10M"),new ChaosKeyValuePair[] -{ -new ChaosKeyValuePair("abruptShutdown","false") -},"selector1") -}) -}) - }, new ChaosTargetSelector[] + NullableResponse response = await collection.GetIfExistsAsync(experimentName); + ChaosExperimentResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new ChaosTargetListSelector("selector1",new ChaosTargetReference[] -{ -new ChaosTargetReference(ChaosTargetReferenceType.ChaosTarget,new ResourceIdentifier("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.Compute/virtualMachines/exampleVM/providers/Microsoft.Chaos/targets/Microsoft-VirtualMachine")) -}) - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Identity = new ManagedServiceIdentity("SystemAssigned"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, experimentName, data); - ChaosExperimentResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosExperimentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosExperimentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentExecutionCollection.cs b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentExecutionCollection.cs index 5f83950e3416e..05e7b206e1731 100644 --- a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentExecutionCollection.cs +++ b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentExecutionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ChaosExperimentExecutionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllExecutionsOfAnExperiment() + public async Task Get_GetTheExecutionOfAExperiment() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListExperimentExecutions.json - // this example is just showing the usage of "Experiments_ListAllExecutions" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetExperimentExecution.json + // this example is just showing the usage of "Experiments_GetExecution" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListAllExecutionsOfAnExperiment() // get the collection of this ChaosExperimentExecutionResource ChaosExperimentExecutionCollection collection = chaosExperiment.GetChaosExperimentExecutions(); - // invoke the operation and iterate over the result - await foreach (ChaosExperimentExecutionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosExperimentExecutionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string executionId = "f24500ad-744e-4a26-864b-b76199eac333"; + ChaosExperimentExecutionResource result = await collection.GetAsync(executionId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosExperimentExecutionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetTheExecutionOfAExperiment() + public async Task GetAll_ListAllExecutionsOfAnExperiment() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetExperimentExecution.json - // this example is just showing the usage of "Experiments_GetExecution" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListExperimentExecutions.json + // this example is just showing the usage of "Experiments_ListAllExecutions" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetTheExecutionOfAExperiment() // get the collection of this ChaosExperimentExecutionResource ChaosExperimentExecutionCollection collection = chaosExperiment.GetChaosExperimentExecutions(); - // invoke the operation - string executionId = "f24500ad-744e-4a26-864b-b76199eac333"; - ChaosExperimentExecutionResource result = await collection.GetAsync(executionId); + // invoke the operation and iterate over the result + await foreach (ChaosExperimentExecutionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosExperimentExecutionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosExperimentExecutionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentResource.cs b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentResource.cs index 8bb798f786668..2596570569f06 100644 --- a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentResource.cs +++ b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosExperimentResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Chaos.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Chaos.Samples @@ -20,42 +19,10 @@ public partial class Sample_ChaosExperimentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetChaosExperiments_ListAllExperimentsInASubscription() - { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListExperimentsInASubscription.json - // this example is just showing the usage of "Experiments_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "6b052e15-03d3-4f17-b2e1-be7f07588291"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - string continuationToken = null; - await foreach (ChaosExperimentResource item in subscriptionResource.GetChaosExperimentsAsync(continuationToken: continuationToken)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosExperimentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAExperimentInAResourceGroup() + public async Task Get_GetAExperimentInAResourceGroup() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/DeleteExperiment.json - // this example is just showing the usage of "Experiments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetExperiment.json + // this example is just showing the usage of "Experiments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,17 +38,21 @@ public async Task Delete_DeleteAExperimentInAResourceGroup() ChaosExperimentResource chaosExperiment = client.GetChaosExperimentResource(chaosExperimentResourceId); // invoke the operation - await chaosExperiment.DeleteAsync(WaitUntil.Completed); + ChaosExperimentResource result = await chaosExperiment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosExperimentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAExperimentInAResourceGroup() + public async Task Delete_DeleteAExperimentInAResourceGroup() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetExperiment.json - // this example is just showing the usage of "Experiments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/DeleteExperiment.json + // this example is just showing the usage of "Experiments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,13 +68,9 @@ public async Task Get_GetAExperimentInAResourceGroup() ChaosExperimentResource chaosExperiment = client.GetChaosExperimentResource(chaosExperimentResourceId); // invoke the operation - ChaosExperimentResource result = await chaosExperiment.GetAsync(); + await chaosExperiment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosExperimentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -127,19 +94,19 @@ public async Task Update_UpdateAnExperimentInAResourceGroup() ChaosExperimentResource chaosExperiment = client.GetChaosExperimentResource(chaosExperimentResourceId); // invoke the operation - ChaosExperimentPatch patch = new ChaosExperimentPatch() + ChaosExperimentPatch patch = new ChaosExperimentPatch { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.ManagedIdentity/userAssignedIdentity/exampleUMI")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/6b052e15-03d3-4f17-b2e1-be7f07588291/resourceGroups/exampleRG/providers/Microsoft.ManagedIdentity/userAssignedIdentity/exampleUMI")] = new UserAssignedIdentity() }, }, Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, }; ArmOperation lro = await chaosExperiment.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetCollection.cs b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetCollection.cs index 23691498dc873..e52ec080f07d3 100644 --- a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetCollection.cs +++ b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ChaosTargetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllTargetsThatExtendAVirtualMachineResource() + public async Task CreateOrUpdate_CreateUpdateATargetThatExtendsAVirtualMachineResource() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListTargets.json - // this example is just showing the usage of "Targets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/CreateUpdateTarget.json + // this example is just showing the usage of "Targets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,18 +42,27 @@ public async Task GetAll_ListAllTargetsThatExtendAVirtualMachineResource() string parentResourceName = "exampleVM"; ChaosTargetCollection collection = resourceGroupResource.GetChaosTargets(parentProviderNamespace, parentResourceType, parentResourceName); - // invoke the operation and iterate over the result - string continuationToken = null; - await foreach (ChaosTargetResource item in collection.GetAllAsync(continuationToken: continuationToken)) + // invoke the operation + string targetName = "Microsoft-Agent"; + ChaosTargetData data = new ChaosTargetData(new Dictionary { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosTargetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ["identities"] = BinaryData.FromObjectAsJson(new object[] + { +new +{ +type = "CertificateSubjectIssuer", +subject = "CN=example.subject", +} + }) + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, targetName, data); + ChaosTargetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosTargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -94,10 +103,10 @@ public async Task Get_GetATargetThatExtendsAVirtualMachineResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetATargetThatExtendsAVirtualMachineResource() + public async Task GetAll_ListAllTargetsThatExtendAVirtualMachineResource() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetTarget.json - // this example is just showing the usage of "Targets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListTargets.json + // this example is just showing the usage of "Targets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,16 +126,23 @@ public async Task Exists_GetATargetThatExtendsAVirtualMachineResource() string parentResourceName = "exampleVM"; ChaosTargetCollection collection = resourceGroupResource.GetChaosTargets(parentProviderNamespace, parentResourceType, parentResourceName); - // invoke the operation - string targetName = "Microsoft-Agent"; - bool result = await collection.ExistsAsync(targetName); + // invoke the operation and iterate over the result + string continuationToken = null; + await foreach (ChaosTargetResource item in collection.GetAllAsync(continuationToken: continuationToken)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosTargetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetATargetThatExtendsAVirtualMachineResource() + public async Task Exists_GetATargetThatExtendsAVirtualMachineResource() { // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetTarget.json // this example is just showing the usage of "Targets_Get" operation, for the dependent resources, they will have to be created separately. @@ -151,29 +167,17 @@ public async Task GetIfExists_GetATargetThatExtendsAVirtualMachineResource() // invoke the operation string targetName = "Microsoft-Agent"; - NullableResponse response = await collection.GetIfExistsAsync(targetName); - ChaosTargetResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(targetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosTargetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateUpdateATargetThatExtendsAVirtualMachineResource() + public async Task GetIfExists_GetATargetThatExtendsAVirtualMachineResource() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/CreateUpdateTarget.json - // this example is just showing the usage of "Targets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetTarget.json + // this example is just showing the usage of "Targets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,21 +199,21 @@ public async Task CreateOrUpdate_CreateUpdateATargetThatExtendsAVirtualMachineRe // invoke the operation string targetName = "Microsoft-Agent"; - ChaosTargetData data = new ChaosTargetData(new Dictionary() - { - ["identities"] = BinaryData.FromObjectAsJson(new object[] { new Dictionary() -{ -["type"] = "CertificateSubjectIssuer", -["subject"] = "CN=example.subject"} }), - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, targetName, data); - ChaosTargetResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(targetName); + ChaosTargetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosTargetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosTargetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetResource.cs b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetResource.cs index 27bd7602b05e2..f7525989e395d 100644 --- a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetResource.cs +++ b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetResource.cs @@ -102,12 +102,16 @@ public async Task Update_CreateUpdateATargetThatExtendsAVirtualMachineResource() ChaosTargetResource chaosTarget = client.GetChaosTargetResource(chaosTargetResourceId); // invoke the operation - ChaosTargetData data = new ChaosTargetData(new Dictionary() + ChaosTargetData data = new ChaosTargetData(new Dictionary { - ["identities"] = BinaryData.FromObjectAsJson(new object[] { new Dictionary() + ["identities"] = BinaryData.FromObjectAsJson(new object[] + { +new { -["type"] = "CertificateSubjectIssuer", -["subject"] = "CN=example.subject"} }), +type = "CertificateSubjectIssuer", +subject = "CN=example.subject", +} + }) }); ArmOperation lro = await chaosTarget.UpdateAsync(WaitUntil.Completed, data); ChaosTargetResource result = lro.Value; diff --git a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetTypeCollection.cs b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetTypeCollection.cs index 010929c9571be..8003959865e43 100644 --- a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetTypeCollection.cs +++ b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_ChaosTargetTypeCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ChaosTargetTypeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllTargetTypesForWestus2Location() + public async Task Get_GetATargetTypeForWestus2Location() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListTargetTypes.json - // this example is just showing the usage of "TargetTypes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetTargetType.json + // this example is just showing the usage of "TargetTypes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,26 +38,23 @@ public async Task GetAll_ListAllTargetTypesForWestus2Location() string locationName = "westus2"; ChaosTargetTypeCollection collection = subscriptionResource.GetChaosTargetTypes(locationName); - // invoke the operation and iterate over the result - string continuationToken = null; - await foreach (ChaosTargetTypeResource item in collection.GetAllAsync(continuationToken: continuationToken)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosTargetTypeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string targetTypeName = "Microsoft-Agent"; + ChaosTargetTypeResource result = await collection.GetAsync(targetTypeName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosTargetTypeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetATargetTypeForWestus2Location() + public async Task GetAll_ListAllTargetTypesForWestus2Location() { - // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/GetTargetType.json - // this example is just showing the usage of "TargetTypes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListTargetTypes.json + // this example is just showing the usage of "TargetTypes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +71,18 @@ public async Task Get_GetATargetTypeForWestus2Location() string locationName = "westus2"; ChaosTargetTypeCollection collection = subscriptionResource.GetChaosTargetTypes(locationName); - // invoke the operation - string targetTypeName = "Microsoft-Agent"; - ChaosTargetTypeResource result = await collection.GetAsync(targetTypeName); + // invoke the operation and iterate over the result + string continuationToken = null; + await foreach (ChaosTargetTypeResource item in collection.GetAllAsync(continuationToken: continuationToken)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosTargetTypeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ChaosTargetTypeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..659f1e05c1ae5 --- /dev/null +++ b/sdk/chaos/Azure.ResourceManager.Chaos/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Chaos.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetChaosExperiments_ListAllExperimentsInASubscription() + { + // Generated from example definition: specification/chaos/resource-manager/Microsoft.Chaos/stable/2024-01-01/examples/ListExperimentsInASubscription.json + // this example is just showing the usage of "Experiments_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "6b052e15-03d3-4f17-b2e1-be7f07588291"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + string continuationToken = null; + await foreach (ChaosExperimentResource item in subscriptionResource.GetChaosExperimentsAsync(continuationToken: continuationToken)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ChaosExperimentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} From 5d1041350b62bde59ca34dcd9c1e0af71dc761fd Mon Sep 17 00:00:00 2001 From: azure-sdk Date: Thu, 21 Nov 2024 04:07:06 +0000 Subject: [PATCH 11/11] Update SDK code ku_ne_5 --- ...AttachedDatabaseConfigurationCollection.cs | 140 +- ...toAttachedDatabaseConfigurationResource.cs | 86 +- .../Samples/Sample_KustoClusterCollection.cs | 136 +- ...stoClusterPrincipalAssignmentCollection.cs | 96 +- ...KustoClusterPrincipalAssignmentResource.cs | 44 +- .../Samples/Sample_KustoClusterResource.cs | 141 +- .../Sample_KustoDataConnectionCollection.cs | 294 +-- .../Sample_KustoDataConnectionResource.cs | 62 +- .../Samples/Sample_KustoDatabaseCollection.cs | 196 +- ...toDatabasePrincipalAssignmentCollection.cs | 96 +- ...ustoDatabasePrincipalAssignmentResource.cs | 44 +- .../Samples/Sample_KustoDatabaseResource.cs | 113 +- ...e_KustoManagedPrivateEndpointCollection.cs | 100 +- ...ple_KustoManagedPrivateEndpointResource.cs | 42 +- ...ustoPrivateEndpointConnectionCollection.cs | 108 +- ..._KustoPrivateEndpointConnectionResource.cs | 50 +- ...mple_KustoPrivateLinkResourceCollection.cs | 48 +- .../Samples/Sample_KustoScriptCollection.cs | 106 +- .../Samples/Sample_KustoScriptResource.cs | 44 +- .../Sample_SandboxCustomImageCollection.cs | 100 +- .../Sample_SandboxCustomImageResource.cs | 42 +- .../Sample_SubscriptionResourceExtensions.cs | 84 + .../Generated/Samples/Sample_LabCollection.cs | 170 +- .../Samples/Sample_LabPlanCollection.cs | 144 +- .../Samples/Sample_LabPlanResource.cs | 80 +- .../Generated/Samples/Sample_LabResource.cs | 76 +- .../Sample_LabServicesScheduleCollection.cs | 110 +- .../Sample_LabServicesScheduleResource.cs | 42 +- .../Samples/Sample_LabUserCollection.cs | 96 +- .../Samples/Sample_LabUserResource.cs | 42 +- .../Sample_LabVirtualMachineCollection.cs | 48 +- ...Sample_LabVirtualMachineImageCollection.cs | 96 +- .../Sample_LabVirtualMachineImageResource.cs | 2 +- .../Sample_SubscriptionResourceExtensions.cs | 62 + .../Sample_LoadTestingQuotaCollection.cs | 48 +- .../Sample_LoadTestingQuotaResource.cs | 4 +- .../Samples/Sample_LoadTestingResource.cs | 86 +- .../Sample_LoadTestingResourceCollection.cs | 136 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + ...e_IntegrationAccountAgreementCollection.cs | 196 +- ...ple_IntegrationAccountAgreementResource.cs | 140 +- ...tionAccountAssemblyDefinitionCollection.cs | 101 +- ...rationAccountAssemblyDefinitionResource.cs | 43 +- ...tionAccountBatchConfigurationCollection.cs | 112 +- ...rationAccountBatchConfigurationResource.cs | 54 +- ...IntegrationAccountCertificateCollection.cs | 106 +- ...e_IntegrationAccountCertificateResource.cs | 48 +- .../Sample_IntegrationAccountCollection.cs | 96 +- .../Sample_IntegrationAccountMapCollection.cs | 139 +- .../Sample_IntegrationAccountMapResource.cs | 59 +- ...ple_IntegrationAccountPartnerCollection.cs | 110 +- ...ample_IntegrationAccountPartnerResource.cs | 56 +- .../Sample_IntegrationAccountResource.cs | 122 +- ...mple_IntegrationAccountSchemaCollection.cs | 119 +- ...Sample_IntegrationAccountSchemaResource.cs | 55 +- ...ple_IntegrationAccountSessionCollection.cs | 105 +- ...ample_IntegrationAccountSessionResource.cs | 47 +- ...IntegrationServiceEnvironmentCollection.cs | 165 +- ...nServiceEnvironmentManagedApiCollection.cs | 92 +- ...ionServiceEnvironmentManagedApiResource.cs | 32 +- ...e_IntegrationServiceEnvironmentResource.cs | 82 +- .../Samples/Sample_LogicWorkflowCollection.cs | 234 +-- .../Samples/Sample_LogicWorkflowResource.cs | 242 +-- ...Sample_LogicWorkflowRunActionCollection.cs | 48 +- ...icWorkflowRunActionRepetitionCollection.cs | 48 +- ...ctionRepetitionRequestHistoryCollection.cs | 48 +- ...rkflowRunActionRequestHistoryCollection.cs | 48 +- ...kflowRunActionScopeRepetitionCollection.cs | 48 +- .../Sample_LogicWorkflowRunCollection.cs | 48 +- .../Sample_LogicWorkflowTriggerCollection.cs | 48 +- ...e_LogicWorkflowTriggerHistoryCollection.cs | 48 +- .../Sample_LogicWorkflowTriggerResource.cs | 2 +- .../Sample_LogicWorkflowVersionCollection.cs | 48 +- .../Sample_LogicWorkflowVersionResource.cs | 2 +- .../Sample_ResourceGroupResourceExtensions.cs | 65 + .../Sample_SubscriptionResourceExtensions.cs | 112 + ...ple_OperationalizationClusterCollection.cs | 68 +- ...ample_OperationalizationClusterResource.cs | 74 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Sample_TenantResourceExtensions.cs | 5 +- ...ninRegistryComponentContainerCollection.cs | 112 +- ...arninRegistryComponentContainerResource.cs | 34 +- ...arninRegistryComponentVersionCollection.cs | 126 +- ...LearninRegistryComponentVersionResource.cs | 36 +- ...achineLearningBatchDeploymentCollection.cs | 211 +- ..._MachineLearningBatchDeploymentResource.cs | 34 +- ..._MachineLearningBatchEndpointCollection.cs | 144 +- ...le_MachineLearningBatchEndpointResource.cs | 53 +- ..._MachineLearningCodeContainerCollection.cs | 106 +- ...le_MachineLearningCodeContainerResource.cs | 32 +- ...le_MachineLearningCodeVersionCollection.cs | 120 +- ...mple_MachineLearningCodeVersionResource.cs | 38 +- ...ineLearningComponentContainerCollection.cs | 112 +- ...chineLearningComponentContainerResource.cs | 34 +- ...chineLearningComponentVersionCollection.cs | 126 +- ...MachineLearningComponentVersionResource.cs | 38 +- ...Sample_MachineLearningComputeCollection.cs | 767 ++++--- .../Sample_MachineLearningComputeResource.cs | 48 +- ..._MachineLearningDataContainerCollection.cs | 116 +- ...le_MachineLearningDataContainerResource.cs | 32 +- ...le_MachineLearningDataVersionCollection.cs | 120 +- ...mple_MachineLearningDataVersionResource.cs | 34 +- ...mple_MachineLearningDatastoreCollection.cs | 230 +- ...Sample_MachineLearningDatastoreResource.cs | 60 +- ...eLearningEnvironmentContainerCollection.cs | 120 +- ...ineLearningEnvironmentContainerResource.cs | 38 +- ...ineLearningEnvironmentVersionCollection.cs | 142 +- ...chineLearningEnvironmentVersionResource.cs | 38 +- ...Sample_MachineLearningFeatureCollection.cs | 50 +- ...neLearningFeatureSetContainerCollection.cs | 116 +- ...hineLearningFeatureSetContainerResource.cs | 34 +- ...hineLearningFeatureSetVersionCollection.cs | 193 +- ...achineLearningFeatureSetVersionResource.cs | 86 +- ...ngFeatureStoreEntityContainerCollection.cs | 116 +- ...ningFeatureStoreEntityContainerResource.cs | 34 +- ...ningFeaturestoreEntityVersionCollection.cs | 131 +- ...arningFeaturestoreEntityVersionResource.cs | 41 +- .../Sample_MachineLearningJobCollection.cs | 922 ++++---- .../Sample_MachineLearningJobResource.cs | 160 +- ...arningMarketplaceSubscriptionCollection.cs | 92 +- ...LearningMarketplaceSubscriptionResource.cs | 28 +- ...MachineLearningModelContainerCollection.cs | 106 +- ...e_MachineLearningModelContainerResource.cs | 32 +- ...e_MachineLearningModelVersionCollection.cs | 140 +- ...ple_MachineLearningModelVersionResource.cs | 42 +- ...chineLearningOnlineDeploymentCollection.cs | 432 ++-- ...MachineLearningOnlineDeploymentResource.cs | 66 +- ...MachineLearningOnlineEndpointCollection.cs | 152 +- ...e_MachineLearningOnlineEndpointResource.cs | 41 +- ...hineLearningOutboundRuleBasicCollection.cs | 102 +- ...achineLearningOutboundRuleBasicResource.cs | 34 +- ...ningPrivateEndpointConnectionCollection.cs | 104 +- ...arningPrivateEndpointConnectionResource.cs | 46 +- ...LearningRegistryCodeContainerCollection.cs | 106 +- ...neLearningRegistryCodeContainerResource.cs | 32 +- ...neLearningRegistryCodeVersionCollection.cs | 120 +- ...hineLearningRegistryCodeVersionResource.cs | 36 +- ...ample_MachineLearningRegistryCollection.cs | 452 ++-- ...LearningRegistryDataContainerCollection.cs | 116 +- ...neLearningRegistryDataContainerResource.cs | 32 +- ...neLearningRegistryDataVersionCollection.cs | 129 +- ...hineLearningRegistryDataVersionResource.cs | 39 +- ...gRegistryEnvironmentContainerCollection.cs | 120 +- ...ingRegistryEnvironmentContainerResource.cs | 38 +- ...ingRegistryEnvironmentVersionCollection.cs | 146 +- ...rningRegistryEnvironmentVersionResource.cs | 36 +- ...earningRegistryModelContainerCollection.cs | 106 +- ...eLearningRegistryModelContainerResource.cs | 32 +- ...eLearningRegistryModelVersionCollection.cs | 140 +- ...ineLearningRegistryModelVersionResource.cs | 42 +- .../Sample_MachineLearningRegistryResource.cs | 197 +- ...ample_MachineLearningScheduleCollection.cs | 130 +- .../Sample_MachineLearningScheduleResource.cs | 34 +- ...ineLearningServerlessEndpointCollection.cs | 134 +- ...chineLearningServerlessEndpointResource.cs | 43 +- ...mple_MachineLearningWorkspaceCollection.cs | 149 +- ...neLearningWorkspaceConnectionCollection.cs | 68 +- ...hineLearningWorkspaceConnectionResource.cs | 48 +- ...Sample_MachineLearningWorkspaceResource.cs | 76 +- .../Sample_SubscriptionResourceExtensions.cs | 73 +- ...Sample_MaintenanceApplyUpdateCollection.cs | 118 +- .../Sample_MaintenanceApplyUpdateResource.cs | 130 +- ...mple_MaintenanceConfigurationCollection.cs | 177 +- ...Sample_MaintenanceConfigurationResource.cs | 35 +- ...aintenancePublicConfigurationCollection.cs | 48 +- .../Sample_ResourceGroupResourceExtensions.cs | 209 +- .../Sample_SubscriptionResourceExtensions.cs | 124 +- .../Sample_ManagedNetworkCollection.cs | 166 +- .../Sample_ManagedNetworkGroupCollection.cs | 124 +- .../Sample_ManagedNetworkGroupResource.cs | 72 +- ...e_ManagedNetworkPeeringPolicyCollection.cs | 107 +- ...ple_ManagedNetworkPeeringPolicyResource.cs | 55 +- .../Samples/Sample_ManagedNetworkResource.cs | 38 +- .../Sample_ScopeAssignmentCollection.cs | 120 +- .../Samples/Sample_ScopeAssignmentResource.cs | 38 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Samples/Sample_NetworkDeviceCollection.cs | 64 +- ...Sample_NetworkDeviceInterfaceCollection.cs | 64 +- .../Sample_NetworkDeviceInterfaceResource.cs | 61 +- .../Samples/Sample_NetworkDeviceResource.cs | 91 +- .../Sample_NetworkDeviceSkuCollection.cs | 62 +- ...etworkFabricAccessControlListCollection.cs | 202 +- ..._NetworkFabricAccessControlListResource.cs | 233 +- .../Samples/Sample_NetworkFabricCollection.cs | 224 +- ...ample_NetworkFabricControllerCollection.cs | 78 +- .../Sample_NetworkFabricControllerResource.cs | 88 +- ..._NetworkFabricExternalNetworkCollection.cs | 114 +- ...le_NetworkFabricExternalNetworkResource.cs | 112 +- ...mple_NetworkFabricIPCommunityCollection.cs | 79 +- ...Sample_NetworkFabricIPCommunityResource.cs | 83 +- ...workFabricIPExtendedCommunityCollection.cs | 69 +- ...etworkFabricIPExtendedCommunityResource.cs | 82 +- .../Sample_NetworkFabricIPPrefixCollection.cs | 71 +- .../Sample_NetworkFabricIPPrefixResource.cs | 89 +- ..._NetworkFabricInternalNetworkCollection.cs | 128 +- ...le_NetworkFabricInternalNetworkResource.cs | 143 +- ..._NetworkFabricInternetGatewayCollection.cs | 62 +- ...le_NetworkFabricInternetGatewayResource.cs | 36 +- ...workFabricInternetGatewayRuleCollection.cs | 73 +- ...etworkFabricInternetGatewayRuleResource.cs | 74 +- ...etworkFabricL2IsolationDomainCollection.cs | 64 +- ..._NetworkFabricL2IsolationDomainResource.cs | 87 +- ...etworkFabricL3IsolationDomainCollection.cs | 80 +- ..._NetworkFabricL3IsolationDomainResource.cs | 111 +- ...le_NetworkFabricNeighborGroupCollection.cs | 76 +- ...mple_NetworkFabricNeighborGroupResource.cs | 92 +- .../Samples/Sample_NetworkFabricResource.cs | 190 +- ...mple_NetworkFabricRoutePolicyCollection.cs | 117 +- ...Sample_NetworkFabricRoutePolicyResource.cs | 148 +- .../Sample_NetworkFabricSkuCollection.cs | 62 +- .../Sample_NetworkPacketBrokerCollection.cs | 64 +- .../Sample_NetworkPacketBrokerResource.cs | 74 +- .../Samples/Sample_NetworkRackCollection.cs | 64 +- .../Samples/Sample_NetworkRackResource.cs | 74 +- .../Samples/Sample_NetworkTapCollection.cs | 73 +- .../Samples/Sample_NetworkTapResource.cs | 109 +- .../Sample_NetworkTapRuleCollection.cs | 179 +- .../Samples/Sample_NetworkTapRuleResource.cs | 203 +- ..._NetworkToNetworkInterconnectCollection.cs | 95 +- ...le_NetworkToNetworkInterconnectResource.cs | 103 +- .../Sample_SubscriptionResourceExtensions.cs | 546 +++++ ...e_FederatedIdentityCredentialCollection.cs | 71 +- ...ple_FederatedIdentityCredentialResource.cs | 53 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + .../Sample_UserAssignedIdentityCollection.cs | 72 +- .../Sample_UserAssignedIdentityResource.cs | 84 +- ...rvicesMarketplaceRegistrationCollection.cs | 74 +- ...ervicesRegistrationAssignmentCollection.cs | 170 +- ...dServicesRegistrationAssignmentResource.cs | 2 +- ...e_ManagedServicesRegistrationCollection.cs | 232 +- ...ple_ManagedServicesRegistrationResource.cs | 26 +- .../Sample_PartnerResponseCollection.cs | 73 +- .../Samples/Sample_PartnerResponseResource.cs | 28 +- .../Sample_TenantResourceExtensions.cs | 5 +- .../Samples/Sample_MapsAccountCollection.cs | 97 +- .../Samples/Sample_MapsAccountResource.cs | 144 +- .../Samples/Sample_MapsCreatorCollection.cs | 70 +- .../Samples/Sample_MapsCreatorResource.cs | 32 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + ...rketplaceAdminApprovalRequestCollection.cs | 112 +- ...MarketplaceAdminApprovalRequestResource.cs | 12 +- ...le_MarketplaceApprovalRequestCollection.cs | 92 +- ...mple_MarketplaceApprovalRequestResource.cs | 9 +- .../Samples/Sample_PrivateStoreCollection.cs | 99 +- ...le_PrivateStoreCollectionInfoCollection.cs | 107 +- ...mple_PrivateStoreCollectionInfoResource.cs | 149 +- .../Sample_PrivateStoreOfferCollection.cs | 101 +- .../Sample_PrivateStoreOfferResource.cs | 106 +- .../Samples/Sample_PrivateStoreResource.cs | 82 +- .../Sample_MarketplaceAgreementResource.cs | 24 +- ...mple_MarketplaceAgreementTermCollection.cs | 88 +- ...Sample_MarketplaceAgreementTermResource.cs | 2 +- .../Sample_ContentKeyPolicyCollection.cs | 324 ++- .../Sample_ContentKeyPolicyResource.cs | 9 +- .../Samples/Sample_MediaAssetCollection.cs | 212 +- .../Sample_MediaAssetFilterCollection.cs | 136 +- .../Sample_MediaAssetFilterResource.cs | 4 +- .../Samples/Sample_MediaAssetResource.cs | 4 +- .../Sample_MediaAssetTrackCollection.cs | 108 +- .../Samples/Sample_MediaAssetTrackResource.cs | 4 +- .../Samples/Sample_MediaJobCollection.cs | 165 +- .../Samples/Sample_MediaJobResource.cs | 7 +- .../Sample_MediaLiveEventCollection.cs | 150 +- .../Samples/Sample_MediaLiveEventResource.cs | 74 +- .../Sample_MediaLiveOutputCollection.cs | 106 +- .../Samples/Sample_MediaLiveOutputResource.cs | 48 +- .../Sample_MediaServicesAccountCollection.cs | 218 +- ...le_MediaServicesAccountFilterCollection.cs | 136 +- ...mple_MediaServicesAccountFilterResource.cs | 4 +- .../Sample_MediaServicesAccountResource.cs | 40 +- ...icesPrivateEndpointConnectionCollection.cs | 104 +- ...rvicesPrivateEndpointConnectionResource.cs | 46 +- ...iaServicesPrivateLinkResourceCollection.cs | 48 +- .../Sample_MediaTransformCollection.cs | 151 +- .../Samples/Sample_MediaTransformResource.cs | 9 +- .../Sample_StreamingEndpointCollection.cs | 156 +- .../Sample_StreamingEndpointResource.cs | 54 +- .../Sample_StreamingLocatorCollection.cs | 207 +- .../Sample_StreamingLocatorResource.cs | 71 +- .../Sample_StreamingPolicyCollection.cs | 400 ++-- .../Samples/Sample_StreamingPolicyResource.cs | 170 +- .../Sample_SubscriptionResourceExtensions.cs | 33 +- ...le_SapDiscoveryServerInstanceCollection.cs | 92 +- ...mple_SapDiscoveryServerInstanceResource.cs | 36 +- .../Sample_SapDiscoverySiteCollection.cs | 108 +- .../Sample_SapDiscoverySiteResource.cs | 74 +- .../Samples/Sample_SapInstanceCollection.cs | 104 +- .../Samples/Sample_SapInstanceResource.cs | 42 +- .../Sample_SubscriptionResourceExtensions.cs | 50 + ...Sample_RemoteRenderingAccountCollection.cs | 96 +- .../Sample_RemoteRenderingAccountResource.cs | 64 +- .../Sample_SpatialAnchorsAccountCollection.cs | 92 +- .../Sample_SpatialAnchorsAccountResource.cs | 64 +- .../Sample_SubscriptionResourceExtensions.cs | 62 + .../Sample_ExtendedUEInfoCollection.cs | 60 +- ...ple_MobileAttachedDataNetworkCollection.cs | 149 +- ...ample_MobileAttachedDataNetworkResource.cs | 32 +- .../Sample_MobileDataNetworkCollection.cs | 90 +- .../Sample_MobileDataNetworkResource.cs | 32 +- .../Samples/Sample_MobileNetworkCollection.cs | 131 +- ...bileNetworkDiagnosticsPackageCollection.cs | 62 +- ...MobileNetworkDiagnosticsPackageResource.cs | 38 +- ...le_MobileNetworkPacketCaptureCollection.cs | 69 +- ...mple_MobileNetworkPacketCaptureResource.cs | 55 +- .../Samples/Sample_MobileNetworkResource.cs | 64 +- .../Sample_MobileNetworkServiceCollection.cs | 152 +- .../Sample_MobileNetworkServiceResource.cs | 32 +- .../Sample_MobileNetworkSimCollection.cs | 125 +- .../Sample_MobileNetworkSimGroupCollection.cs | 118 +- .../Sample_MobileNetworkSimGroupResource.cs | 299 ++- ...Sample_MobileNetworkSimPolicyCollection.cs | 162 +- .../Sample_MobileNetworkSimPolicyResource.cs | 32 +- .../Sample_MobileNetworkSimResource.cs | 39 +- .../Sample_MobileNetworkSiteCollection.cs | 84 +- .../Sample_MobileNetworkSiteResource.cs | 32 +- .../Sample_MobileNetworkSliceCollection.cs | 96 +- .../Sample_MobileNetworkSliceResource.cs | 32 +- ...Sample_PacketCoreControlPlaneCollection.cs | 163 +- .../Sample_PacketCoreControlPlaneResource.cs | 66 +- .../Sample_PacketCoreDataPlaneCollection.cs | 90 +- .../Sample_PacketCoreDataPlaneResource.cs | 32 +- ...PacketCoreControlPlaneVersionCollection.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 112 + ...PacketCoreControlPlaneVersionCollection.cs | 75 +- .../Samples/Sample_MongoClusterCollection.cs | 196 +- ...mple_MongoClusterFirewallRuleCollection.cs | 90 +- ...Sample_MongoClusterFirewallRuleResource.cs | 38 +- ...lusterPrivateEndpointConnectionResource.cs | 50 +- ...ateEndpointConnectionResourceCollection.cs | 106 +- .../Samples/Sample_MongoClusterResource.cs | 168 +- .../Sample_SubscriptionResourceExtensions.cs | 111 + .../Samples/Sample_ActionGroupCollection.cs | 139 +- .../Samples/Sample_ActionGroupResource.cs | 111 +- .../Sample_ActivityLogAlertCollection.cs | 157 +- .../Sample_ActivityLogAlertResource.cs | 36 +- .../Samples/Sample_AlertRuleCollection.cs | 72 +- .../Samples/Sample_AlertRuleResource.cs | 138 +- .../Sample_AutoscaleSettingCollection.cs | 165 +- .../Sample_AutoscaleSettingResource.cs | 165 +- ...Sample_DataCollectionEndpointCollection.cs | 96 +- .../Sample_DataCollectionEndpointResource.cs | 78 +- ...DataCollectionRuleAssociationCollection.cs | 116 +- ...e_DataCollectionRuleAssociationResource.cs | 38 +- .../Sample_DataCollectionRuleCollection.cs | 263 +-- .../Sample_DataCollectionRuleResource.cs | 90 +- .../Sample_DiagnosticSettingCollection.cs | 316 ++- .../Sample_DiagnosticSettingResource.cs | 90 +- ...le_DiagnosticSettingsCategoryCollection.cs | 80 +- .../Samples/Sample_LogProfileCollection.cs | 106 +- .../Samples/Sample_LogProfileResource.cs | 50 +- .../Samples/Sample_MetricAlertCollection.cs | 1153 +++++----- .../Samples/Sample_MetricAlertResource.cs | 117 +- ...itorPrivateEndpointConnectionCollection.cs | 98 +- ...onitorPrivateEndpointConnectionResource.cs | 46 +- ...le_MonitorPrivateLinkResourceCollection.cs | 48 +- ...ample_MonitorPrivateLinkScopeCollection.cs | 138 +- .../Sample_MonitorPrivateLinkScopeResource.cs | 64 +- ...Sample_MonitorPrivateLinkScopedResource.cs | 38 +- ...itorPrivateLinkScopedResourceCollection.cs | 90 +- .../Sample_MonitorWorkspaceResource.cs | 78 +- ...mple_MonitorWorkspaceResourceCollection.cs | 96 +- .../Samples/Sample_PipelineGroupCollection.cs | 457 ++-- .../Samples/Sample_PipelineGroupResource.cs | 116 +- .../Sample_ScheduledQueryRuleCollection.cs | 381 ++-- .../Sample_ScheduledQueryRuleResource.cs | 68 +- .../Sample_SubscriptionResourceExtensions.cs | 360 +++- .../Sample_TenantResourceExtensions.cs | 21 +- ...mple_AdvancedThreatProtectionCollection.cs | 140 +- ...Sample_AdvancedThreatProtectionResource.cs | 4 +- .../Samples/Sample_MySqlAdvisorCollection.cs | 62 +- .../Samples/Sample_MySqlAdvisorResource.cs | 30 +- .../Sample_MySqlConfigurationCollection.cs | 72 +- .../Sample_MySqlConfigurationResource.cs | 28 +- .../Samples/Sample_MySqlDatabaseCollection.cs | 64 +- .../Samples/Sample_MySqlDatabaseResource.cs | 28 +- .../Sample_MySqlFirewallRuleCollection.cs | 62 +- .../Sample_MySqlFirewallRuleResource.cs | 20 +- ...lexibleServerAadAdministratorCollection.cs | 64 +- ...lFlexibleServerAadAdministratorResource.cs | 34 +- ...ple_MySqlFlexibleServerBackupCollection.cs | 62 +- ...ample_MySqlFlexibleServerBackupResource.cs | 22 +- ...e_MySqlFlexibleServerBackupV2Collection.cs | 62 +- ...ple_MySqlFlexibleServerBackupV2Resource.cs | 24 +- .../Sample_MySqlFlexibleServerCollection.cs | 158 +- ...qlFlexibleServerConfigurationCollection.cs | 76 +- ...ySqlFlexibleServerConfigurationResource.cs | 32 +- ...e_MySqlFlexibleServerDatabaseCollection.cs | 64 +- ...ple_MySqlFlexibleServerDatabaseResource.cs | 28 +- ...SqlFlexibleServerFirewallRuleCollection.cs | 62 +- ...MySqlFlexibleServerFirewallRuleResource.cs | 20 +- ...ySqlFlexibleServerMaintenanceCollection.cs | 62 +- ..._MySqlFlexibleServerMaintenanceResource.cs | 2 +- .../Sample_MySqlFlexibleServerResource.cs | 178 +- ...ySqlFlexibleServersCapabilityCollection.cs | 48 +- ...ySqlPrivateEndpointConnectionCollection.cs | 90 +- ..._MySqlPrivateEndpointConnectionResource.cs | 4 +- ...mple_MySqlPrivateLinkResourceCollection.cs | 48 +- .../Sample_MySqlQueryStatisticCollection.cs | 70 +- .../Sample_MySqlQueryTextCollection.cs | 65 +- ...ple_MySqlRecommendationActionCollection.cs | 62 +- ...Sample_MySqlServerAdministratorResource.cs | 44 +- .../Samples/Sample_MySqlServerCollection.cs | 102 +- .../Sample_MySqlServerKeyCollection.cs | 98 +- .../Samples/Sample_MySqlServerKeyResource.cs | 40 +- .../Samples/Sample_MySqlServerResource.cs | 62 +- ...ySqlServerSecurityAlertPolicyCollection.cs | 144 +- ..._MySqlServerSecurityAlertPolicyResource.cs | 14 +- ...ample_MySqlVirtualNetworkRuleCollection.cs | 92 +- .../Sample_MySqlVirtualNetworkRuleResource.cs | 40 +- .../Sample_MySqlWaitStatisticCollection.cs | 64 +- .../Sample_SubscriptionResourceExtensions.cs | 33 +- .../Sample_TenantResourceExtensions.cs | 5 +- .../Samples/Sample_CapacityPoolCollection.cs | 96 +- .../Samples/Sample_CapacityPoolResource.cs | 32 +- .../Samples/Sample_NetAppAccountCollection.cs | 147 +- .../Samples/Sample_NetAppAccountResource.cs | 36 +- .../Sample_NetAppBackupPolicyCollection.cs | 102 +- .../Sample_NetAppBackupPolicyResource.cs | 52 +- ...ample_NetAppBackupVaultBackupCollection.cs | 96 +- .../Sample_NetAppBackupVaultBackupResource.cs | 41 +- .../Sample_NetAppBackupVaultCollection.cs | 92 +- .../Sample_NetAppBackupVaultResource.cs | 48 +- .../Sample_NetAppSubvolumeInfoCollection.cs | 96 +- .../Sample_NetAppSubvolumeInfoResource.cs | 38 +- .../Samples/Sample_NetAppVolumeCollection.cs | 96 +- .../Sample_NetAppVolumeGroupCollection.cs | 740 +++---- .../Sample_NetAppVolumeGroupResource.cs | 370 +--- .../Sample_NetAppVolumeQuotaRuleCollection.cs | 100 +- .../Sample_NetAppVolumeQuotaRuleResource.cs | 38 +- .../Samples/Sample_NetAppVolumeResource.cs | 47 +- .../Sample_NetAppVolumeSnapshotCollection.cs | 92 +- .../Sample_NetAppVolumeSnapshotResource.cs | 37 +- .../Sample_RegionInfoResourceCollection.cs | 46 +- .../Sample_SnapshotPolicyCollection.cs | 146 +- .../Samples/Sample_SnapshotPolicyResource.cs | 62 +- .../Sample_SubscriptionResourceExtensions.cs | 31 + .../Sample_AdminRuleGroupCollection.cs | 101 +- .../Samples/Sample_AdminRuleGroupResource.cs | 45 +- .../Sample_ApplicationGatewayCollection.cs | 380 ++-- ...ewayPrivateEndpointConnectionCollection.cs | 66 +- ...atewayPrivateEndpointConnectionResource.cs | 56 +- .../Sample_ApplicationGatewayResource.cs | 250 +-- ...tionGatewayWafDynamicManifestCollection.cs | 60 +- ...mple_ApplicationSecurityGroupCollection.cs | 90 +- ...Sample_ApplicationSecurityGroupResource.cs | 64 +- .../Samples/Sample_AzureFirewallCollection.cs | 1871 +++++++---------- .../Samples/Sample_AzureFirewallResource.cs | 130 +- .../Sample_AzureWebCategoryCollection.cs | 62 +- .../Sample_BackendAddressPoolCollection.cs | 169 +- .../Sample_BackendAddressPoolResource.cs | 79 +- .../Samples/Sample_BaseAdminRuleCollection.cs | 234 +-- .../Samples/Sample_BaseAdminRuleResource.cs | 88 +- .../Samples/Sample_BastionHostCollection.cs | 317 ++- .../Samples/Sample_BastionHostResource.cs | 117 +- .../Samples/Sample_BgpConnectionCollection.cs | 94 +- .../Samples/Sample_BgpConnectionResource.cs | 42 +- .../Sample_CloudServiceSwapCollection.cs | 88 +- .../Sample_CloudServiceSwapResource.cs | 2 +- .../Sample_ConnectionMonitorCollection.cs | 202 +- .../Sample_ConnectionMonitorResource.cs | 4 +- ...ple_ConnectivityConfigurationCollection.cs | 122 +- ...ample_ConnectivityConfigurationResource.cs | 72 +- .../Sample_CustomIPPrefixCollection.cs | 92 +- .../Samples/Sample_CustomIPPrefixResource.cs | 64 +- .../Sample_DdosCustomPolicyCollection.cs | 72 +- .../Sample_DdosCustomPolicyResource.cs | 32 +- .../Sample_DdosProtectionPlanCollection.cs | 84 +- .../Sample_DdosProtectionPlanResource.cs | 64 +- .../Sample_DefaultSecurityRuleCollection.cs | 48 +- .../Sample_DscpConfigurationCollection.cs | 141 +- .../Sample_DscpConfigurationResource.cs | 201 +- ...ressRouteCircuitAuthorizationCollection.cs | 88 +- ...xpressRouteCircuitAuthorizationResource.cs | 28 +- .../Sample_ExpressRouteCircuitCollection.cs | 182 +- ...ExpressRouteCircuitConnectionCollection.cs | 104 +- ...e_ExpressRouteCircuitConnectionResource.cs | 36 +- ...le_ExpressRouteCircuitPeeringCollection.cs | 100 +- ...mple_ExpressRouteCircuitPeeringResource.cs | 34 +- .../Sample_ExpressRouteCircuitResource.cs | 64 +- ...Sample_ExpressRouteConnectionCollection.cs | 84 +- .../Sample_ExpressRouteConnectionResource.cs | 104 +- ...e_ExpressRouteCrossConnectionCollection.cs | 96 +- ...ssRouteCrossConnectionPeeringCollection.cs | 112 +- ...ressRouteCrossConnectionPeeringResource.cs | 114 +- ...ple_ExpressRouteCrossConnectionResource.cs | 36 +- .../Sample_ExpressRouteGatewayCollection.cs | 74 +- .../Sample_ExpressRouteGatewayResource.cs | 86 +- .../Sample_ExpressRouteLinkCollection.cs | 62 +- ...ExpressRoutePortAuthorizationCollection.cs | 88 +- ...e_ExpressRoutePortAuthorizationResource.cs | 28 +- .../Sample_ExpressRoutePortCollection.cs | 153 +- .../Sample_ExpressRoutePortResource.cs | 64 +- ...ple_ExpressRoutePortsLocationCollection.cs | 48 +- ...mple_ExpressRouteProviderPortCollection.cs | 62 +- ...Sample_ExpressRouteProviderPortResource.cs | 28 - .../Sample_FirewallPolicyCollection.cs | 272 ++- .../Sample_FirewallPolicyDraftResource.cs | 186 +- .../Samples/Sample_FirewallPolicyResource.cs | 82 +- ...wallPolicyRuleCollectionGroupCollection.cs | 681 +++--- ...lPolicyRuleCollectionGroupDraftResource.cs | 92 +- ...rewallPolicyRuleCollectionGroupResource.cs | 233 +- .../Samples/Sample_FlowLogCollection.cs | 68 +- .../Samples/Sample_FlowLogResource.cs | 60 +- ...ample_FrontendIPConfigurationCollection.cs | 48 +- .../Sample_HubIPConfigurationCollection.cs | 96 +- .../Sample_HubIPConfigurationResource.cs | 44 +- .../Samples/Sample_HubRouteTableCollection.cs | 77 +- .../Samples/Sample_HubRouteTableResource.cs | 57 +- ...e_HubVirtualNetworkConnectionCollection.cs | 103 +- ...ple_HubVirtualNetworkConnectionResource.cs | 107 +- .../Samples/Sample_IPAllocationCollection.cs | 102 +- .../Samples/Sample_IPAllocationResource.cs | 64 +- .../Samples/Sample_IPGroupCollection.cs | 103 +- .../Samples/Sample_IPGroupResource.cs | 74 +- .../Sample_InboundNatRuleCollection.cs | 108 +- .../Samples/Sample_InboundNatRuleResource.cs | 30 +- .../Sample_InboundSecurityRuleCollection.cs | 19 +- .../Sample_InboundSecurityRuleResource.cs | 53 +- .../Samples/Sample_LoadBalancerCollection.cs | 911 ++++---- .../Samples/Sample_LoadBalancerResource.cs | 115 +- .../Sample_LoadBalancingRuleCollection.cs | 48 +- .../Sample_LocalNetworkGatewayCollection.cs | 69 +- .../Sample_LocalNetworkGatewayResource.cs | 4 +- ...GroupNetworkManagerConnectionCollection.cs | 64 +- ...ntGroupNetworkManagerConnectionResource.cs | 46 +- .../Samples/Sample_NatGatewayCollection.cs | 118 +- .../Samples/Sample_NatGatewayResource.cs | 64 +- .../Samples/Sample_NetworkGroupCollection.cs | 92 +- .../Samples/Sample_NetworkGroupResource.cs | 42 +- ...mple_NetworkGroupStaticMemberCollection.cs | 90 +- ...Sample_NetworkGroupStaticMemberResource.cs | 46 +- .../Sample_NetworkInterfaceCollection.cs | 194 +- ...tworkInterfaceIPConfigurationCollection.cs | 52 +- .../Sample_NetworkInterfaceResource.cs | 64 +- ...workInterfaceTapConfigurationCollection.cs | 96 +- ...etworkInterfaceTapConfigurationResource.cs | 32 +- .../Sample_NetworkManagerCollection.cs | 115 +- .../Samples/Sample_NetworkManagerResource.cs | 164 +- ...rkManagerRoutingConfigurationCollection.cs | 96 +- ...workManagerRoutingConfigurationResource.cs | 38 +- ...ple_NetworkManagerRoutingRuleCollection.cs | 140 +- ...ample_NetworkManagerRoutingRuleResource.cs | 52 +- ...le_NetworkManagerRoutingRulesCollection.cs | 101 +- ...mple_NetworkManagerRoutingRulesResource.cs | 43 +- ...agerSecurityUserConfigurationCollection.cs | 96 +- ...anagerSecurityUserConfigurationResource.cs | 40 +- ...etworkManagerSecurityUserRuleCollection.cs | 136 +- ..._NetworkManagerSecurityUserRuleResource.cs | 80 +- ...tworkManagerSecurityUserRulesCollection.cs | 101 +- ...NetworkManagerSecurityUserRulesResource.cs | 45 +- ...workPrivateEndpointConnectionCollection.cs | 100 +- ...etworkPrivateEndpointConnectionResource.cs | 48 +- .../Sample_NetworkProfileCollection.cs | 174 +- .../Samples/Sample_NetworkProfileResource.cs | 68 +- .../Sample_NetworkSecurityGroupCollection.cs | 151 +- .../Sample_NetworkSecurityGroupResource.cs | 64 +- ...ample_NetworkVirtualApplianceCollection.cs | 271 ++- ...orkVirtualApplianceConnectionCollection.cs | 85 +- ...tworkVirtualApplianceConnectionResource.cs | 93 +- .../Sample_NetworkVirtualApplianceResource.cs | 64 +- ...le_NetworkVirtualApplianceSkuCollection.cs | 48 +- .../Sample_NetworkWatcherCollection.cs | 64 +- .../Samples/Sample_NetworkWatcherResource.cs | 70 +- .../Samples/Sample_OutboundRuleCollection.cs | 48 +- .../Samples/Sample_P2SVpnGatewayCollection.cs | 181 +- .../Samples/Sample_P2SVpnGatewayResource.cs | 92 +- .../Samples/Sample_PacketCaptureCollection.cs | 71 +- .../Samples/Sample_PacketCaptureResource.cs | 75 +- ...ExpressRouteCircuitConnectionCollection.cs | 62 +- ...olicySignaturesOverridesForIdpsResource.cs | 52 +- .../Sample_PrivateDnsZoneGroupCollection.cs | 99 +- .../Sample_PrivateDnsZoneGroupResource.cs | 37 +- .../Sample_PrivateEndpointCollection.cs | 381 ++-- .../Samples/Sample_PrivateEndpointResource.cs | 137 +- .../Sample_PrivateLinkServiceCollection.cs | 141 +- .../Sample_PrivateLinkServiceResource.cs | 93 +- .../Samples/Sample_ProbeCollection.cs | 48 +- .../Sample_PublicIPAddressCollection.cs | 196 +- .../Samples/Sample_PublicIPAddressResource.cs | 68 +- .../Sample_PublicIPPrefixCollection.cs | 148 +- .../Samples/Sample_PublicIPPrefixResource.cs | 64 +- .../Sample_ResourceGroupResourceExtensions.cs | 2 +- .../Samples/Sample_RouteCollection.cs | 92 +- .../Samples/Sample_RouteFilterCollection.cs | 118 +- .../Samples/Sample_RouteFilterResource.cs | 64 +- .../Sample_RouteFilterRuleCollection.cs | 101 +- .../Samples/Sample_RouteFilterRuleResource.cs | 39 +- .../Samples/Sample_RouteMapCollection.cs | 167 +- .../Samples/Sample_RouteMapResource.cs | 115 +- .../Generated/Samples/Sample_RouteResource.cs | 30 +- .../Samples/Sample_RouteTableCollection.cs | 141 +- .../Samples/Sample_RouteTableResource.cs | 64 +- .../Samples/Sample_RoutingIntentCollection.cs | 75 +- .../Samples/Sample_RoutingIntentResource.cs | 55 +- .../Sample_ScopeConnectionCollection.cs | 64 +- .../Samples/Sample_ScopeConnectionResource.cs | 50 +- ...le_SecurityAdminConfigurationCollection.cs | 101 +- ...mple_SecurityAdminConfigurationResource.cs | 45 +- ...ample_SecurityPartnerProviderCollection.cs | 102 +- .../Sample_SecurityPartnerProviderResource.cs | 64 +- .../Samples/Sample_SecurityRuleCollection.cs | 104 +- .../Samples/Sample_SecurityRuleResource.cs | 30 +- .../Sample_ServiceEndpointPolicyCollection.cs | 150 +- ...rviceEndpointPolicyDefinitionCollection.cs | 97 +- ...ServiceEndpointPolicyDefinitionResource.cs | 35 +- .../Sample_ServiceEndpointPolicyResource.cs | 68 +- .../Samples/Sample_SubnetCollection.cs | 336 ++- .../Samples/Sample_SubnetResource.cs | 68 +- ...ptionNetworkManagerConnectionCollection.cs | 64 +- ...riptionNetworkManagerConnectionResource.cs | 46 +- .../Sample_SubscriptionResourceExtensions.cs | 1661 ++++++++++++++- .../Sample_VirtualApplianceSiteCollection.cs | 102 +- .../Sample_VirtualApplianceSiteResource.cs | 32 +- .../Samples/Sample_VirtualHubCollection.cs | 108 +- .../Samples/Sample_VirtualHubResource.cs | 88 +- ...Sample_VirtualHubRouteTableV2Collection.cs | 134 +- .../Sample_VirtualHubRouteTableV2Resource.cs | 82 +- .../Sample_VirtualNetworkCollection.cs | 614 +++--- .../Sample_VirtualNetworkGatewayCollection.cs | 211 +- ...rtualNetworkGatewayConnectionCollection.cs | 117 +- ...VirtualNetworkGatewayConnectionResource.cs | 72 +- ..._VirtualNetworkGatewayNatRuleCollection.cs | 120 +- ...le_VirtualNetworkGatewayNatRuleResource.cs | 68 +- .../Sample_VirtualNetworkGatewayResource.cs | 25 +- .../Sample_VirtualNetworkPeeringCollection.cs | 524 +++-- .../Sample_VirtualNetworkPeeringResource.cs | 74 +- .../Samples/Sample_VirtualNetworkResource.cs | 174 +- .../Sample_VirtualNetworkTapCollection.cs | 102 +- .../Sample_VirtualNetworkTapResource.cs | 68 +- .../Samples/Sample_VirtualRouterCollection.cs | 100 +- .../Sample_VirtualRouterPeeringCollection.cs | 92 +- .../Sample_VirtualRouterPeeringResource.cs | 30 +- .../Samples/Sample_VirtualRouterResource.cs | 64 +- .../Samples/Sample_VirtualWanCollection.cs | 102 +- .../Samples/Sample_VirtualWanResource.cs | 117 +- .../Samples/Sample_VpnConnectionCollection.cs | 163 +- .../Samples/Sample_VpnConnectionResource.cs | 108 +- .../Samples/Sample_VpnGatewayCollection.cs | 223 +- .../Sample_VpnGatewayNatRuleCollection.cs | 116 +- .../Sample_VpnGatewayNatRuleResource.cs | 64 +- .../Samples/Sample_VpnGatewayResource.cs | 82 +- ...mple_VpnLinkConnectionSharedKeyResource.cs | 4 +- ...Sample_VpnServerConfigurationCollection.cs | 240 +-- ...erverConfigurationPolicyGroupCollection.cs | 73 +- ...nServerConfigurationPolicyGroupResource.cs | 53 +- .../Sample_VpnServerConfigurationResource.cs | 74 +- .../Samples/Sample_VpnSiteCollection.cs | 154 +- .../Samples/Sample_VpnSiteLinkCollection.cs | 62 +- .../Sample_VpnSiteLinkConnectionCollection.cs | 48 +- .../Sample_VpnSiteLinkConnectionResource.cs | 40 +- .../Samples/Sample_VpnSiteResource.cs | 74 +- ..._WebApplicationFirewallPolicyCollection.cs | 500 ++--- ...le_WebApplicationFirewallPolicyResource.cs | 298 +-- 653 files changed, 32902 insertions(+), 36957 deletions(-) create mode 100644 sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs create mode 100644 sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs create mode 100644 sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoAttachedDatabaseConfigurationCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoAttachedDatabaseConfigurationCollection.cs index 05b61a7030a1d..1ab3117cb5c9c 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoAttachedDatabaseConfigurationCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoAttachedDatabaseConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_KustoAttachedDatabaseConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoAttachedDatabaseConfigurationsListByCluster() + public async Task CreateOrUpdate_AttachedDatabaseConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsListByCluster.json - // this example is just showing the usage of "AttachedDatabaseConfigurations_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsCreateOrUpdate.json + // this example is just showing the usage of "AttachedDatabaseConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,33 @@ public async Task GetAll_KustoAttachedDatabaseConfigurationsListByCluster() // get the collection of this KustoAttachedDatabaseConfigurationResource KustoAttachedDatabaseConfigurationCollection collection = kustoCluster.GetKustoAttachedDatabaseConfigurations(); - // invoke the operation and iterate over the result - await foreach (KustoAttachedDatabaseConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string attachedDatabaseConfigurationName = "attachedDatabaseConfigurationsTest"; + KustoAttachedDatabaseConfigurationData data = new KustoAttachedDatabaseConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoAttachedDatabaseConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Location = new AzureLocation("westus"), + DatabaseName = "kustodatabase", + ClusterResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Kusto/Clusters/kustoCluster2"), + DefaultPrincipalsModificationKind = KustoDatabaseDefaultPrincipalsModificationKind.Union, + TableLevelSharingProperties = new KustoDatabaseTableLevelSharingProperties + { + TablesToInclude = { "Table1" }, + TablesToExclude = { "Table2" }, + ExternalTablesToInclude = { "ExternalTable1" }, + ExternalTablesToExclude = { "ExternalTable2" }, + MaterializedViewsToInclude = { "MaterializedViewTable1" }, + MaterializedViewsToExclude = { "MaterializedViewTable2" }, + }, + DatabaseNameOverride = "overridekustodatabase", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attachedDatabaseConfigurationName, data); + KustoAttachedDatabaseConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoAttachedDatabaseConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +104,10 @@ public async Task Get_AttachedDatabaseConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AttachedDatabaseConfigurationsGet() + public async Task GetAll_KustoAttachedDatabaseConfigurationsListByCluster() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsGet.json - // this example is just showing the usage of "AttachedDatabaseConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsListByCluster.json + // this example is just showing the usage of "AttachedDatabaseConfigurations_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +125,22 @@ public async Task Exists_AttachedDatabaseConfigurationsGet() // get the collection of this KustoAttachedDatabaseConfigurationResource KustoAttachedDatabaseConfigurationCollection collection = kustoCluster.GetKustoAttachedDatabaseConfigurations(); - // invoke the operation - string attachedDatabaseConfigurationName = "attachedDatabaseConfigurationsTest"; - bool result = await collection.ExistsAsync(attachedDatabaseConfigurationName); + // invoke the operation and iterate over the result + await foreach (KustoAttachedDatabaseConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoAttachedDatabaseConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AttachedDatabaseConfigurationsGet() + public async Task Exists_AttachedDatabaseConfigurationsGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsGet.json // this example is just showing the usage of "AttachedDatabaseConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +163,17 @@ public async Task GetIfExists_AttachedDatabaseConfigurationsGet() // invoke the operation string attachedDatabaseConfigurationName = "attachedDatabaseConfigurationsTest"; - NullableResponse response = await collection.GetIfExistsAsync(attachedDatabaseConfigurationName); - KustoAttachedDatabaseConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(attachedDatabaseConfigurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoAttachedDatabaseConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AttachedDatabaseConfigurationsCreateOrUpdate() + public async Task GetIfExists_AttachedDatabaseConfigurationsGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsCreateOrUpdate.json - // this example is just showing the usage of "AttachedDatabaseConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsGet.json + // this example is just showing the usage of "AttachedDatabaseConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,49 +193,21 @@ public async Task CreateOrUpdate_AttachedDatabaseConfigurationsCreateOrUpdate() // invoke the operation string attachedDatabaseConfigurationName = "attachedDatabaseConfigurationsTest"; - KustoAttachedDatabaseConfigurationData data = new KustoAttachedDatabaseConfigurationData() - { - Location = new AzureLocation("westus"), - DatabaseName = "kustodatabase", - ClusterResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Kusto/Clusters/kustoCluster2"), - DefaultPrincipalsModificationKind = KustoDatabaseDefaultPrincipalsModificationKind.Union, - TableLevelSharingProperties = new KustoDatabaseTableLevelSharingProperties() - { - TablesToInclude = -{ -"Table1" -}, - TablesToExclude = -{ -"Table2" -}, - ExternalTablesToInclude = -{ -"ExternalTable1" -}, - ExternalTablesToExclude = -{ -"ExternalTable2" -}, - MaterializedViewsToInclude = -{ -"MaterializedViewTable1" -}, - MaterializedViewsToExclude = -{ -"MaterializedViewTable2" -}, - }, - DatabaseNameOverride = "overridekustodatabase", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attachedDatabaseConfigurationName, data); - KustoAttachedDatabaseConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(attachedDatabaseConfigurationName); + KustoAttachedDatabaseConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoAttachedDatabaseConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoAttachedDatabaseConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoAttachedDatabaseConfigurationResource.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoAttachedDatabaseConfigurationResource.cs index cdb05fc55207a..54617fdaec473 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoAttachedDatabaseConfigurationResource.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoAttachedDatabaseConfigurationResource.cs @@ -49,10 +49,10 @@ public async Task Get_AttachedDatabaseConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_AttachedDatabaseConfigurationsCreateOrUpdate() + public async Task Delete_AttachedDatabaseConfigurationsDelete() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsCreateOrUpdate.json - // this example is just showing the usage of "AttachedDatabaseConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsDelete.json + // this example is just showing the usage of "AttachedDatabaseConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,63 +63,23 @@ public async Task Update_AttachedDatabaseConfigurationsCreateOrUpdate() // for more information of creating KustoAttachedDatabaseConfigurationResource, please refer to the document of KustoAttachedDatabaseConfigurationResource string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; - string clusterName = "kustoCluster2"; + string clusterName = "kustoCluster"; string attachedDatabaseConfigurationName = "attachedDatabaseConfigurationsTest"; ResourceIdentifier kustoAttachedDatabaseConfigurationResourceId = KustoAttachedDatabaseConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, attachedDatabaseConfigurationName); KustoAttachedDatabaseConfigurationResource kustoAttachedDatabaseConfiguration = client.GetKustoAttachedDatabaseConfigurationResource(kustoAttachedDatabaseConfigurationResourceId); // invoke the operation - KustoAttachedDatabaseConfigurationData data = new KustoAttachedDatabaseConfigurationData() - { - Location = new AzureLocation("westus"), - DatabaseName = "kustodatabase", - ClusterResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Kusto/Clusters/kustoCluster2"), - DefaultPrincipalsModificationKind = KustoDatabaseDefaultPrincipalsModificationKind.Union, - TableLevelSharingProperties = new KustoDatabaseTableLevelSharingProperties() - { - TablesToInclude = -{ -"Table1" -}, - TablesToExclude = -{ -"Table2" -}, - ExternalTablesToInclude = -{ -"ExternalTable1" -}, - ExternalTablesToExclude = -{ -"ExternalTable2" -}, - MaterializedViewsToInclude = -{ -"MaterializedViewTable1" -}, - MaterializedViewsToExclude = -{ -"MaterializedViewTable2" -}, - }, - DatabaseNameOverride = "overridekustodatabase", - }; - ArmOperation lro = await kustoAttachedDatabaseConfiguration.UpdateAsync(WaitUntil.Completed, data); - KustoAttachedDatabaseConfigurationResource result = lro.Value; + await kustoAttachedDatabaseConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoAttachedDatabaseConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_AttachedDatabaseConfigurationsDelete() + public async Task Update_AttachedDatabaseConfigurationsCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsDelete.json - // this example is just showing the usage of "AttachedDatabaseConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoAttachedDatabaseConfigurationsCreateOrUpdate.json + // this example is just showing the usage of "AttachedDatabaseConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,15 +90,37 @@ public async Task Delete_AttachedDatabaseConfigurationsDelete() // for more information of creating KustoAttachedDatabaseConfigurationResource, please refer to the document of KustoAttachedDatabaseConfigurationResource string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; - string clusterName = "kustoCluster"; + string clusterName = "kustoCluster2"; string attachedDatabaseConfigurationName = "attachedDatabaseConfigurationsTest"; ResourceIdentifier kustoAttachedDatabaseConfigurationResourceId = KustoAttachedDatabaseConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, attachedDatabaseConfigurationName); KustoAttachedDatabaseConfigurationResource kustoAttachedDatabaseConfiguration = client.GetKustoAttachedDatabaseConfigurationResource(kustoAttachedDatabaseConfigurationResourceId); // invoke the operation - await kustoAttachedDatabaseConfiguration.DeleteAsync(WaitUntil.Completed); + KustoAttachedDatabaseConfigurationData data = new KustoAttachedDatabaseConfigurationData + { + Location = new AzureLocation("westus"), + DatabaseName = "kustodatabase", + ClusterResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Kusto/Clusters/kustoCluster2"), + DefaultPrincipalsModificationKind = KustoDatabaseDefaultPrincipalsModificationKind.Union, + TableLevelSharingProperties = new KustoDatabaseTableLevelSharingProperties + { + TablesToInclude = { "Table1" }, + TablesToExclude = { "Table2" }, + ExternalTablesToInclude = { "ExternalTable1" }, + ExternalTablesToExclude = { "ExternalTable2" }, + MaterializedViewsToInclude = { "MaterializedViewTable1" }, + MaterializedViewsToExclude = { "MaterializedViewTable2" }, + }, + DatabaseNameOverride = "overridekustodatabase", + }; + ArmOperation lro = await kustoAttachedDatabaseConfiguration.UpdateAsync(WaitUntil.Completed, data); + KustoAttachedDatabaseConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoAttachedDatabaseConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterCollection.cs index 192cde6d9677f..fb825a045d0bc 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_KustoClusterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KustoClustersGet() + public async Task CreateOrUpdate_KustoClustersCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersGet.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersCreateOrUpdate.json + // this example is just showing the usage of "Clusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,32 @@ public async Task Get_KustoClustersGet() // invoke the operation string clusterName = "kustoCluster"; - KustoClusterResource result = await collection.GetAsync(clusterName); + KustoClusterData data = new KustoClusterData(new AzureLocation("westus"), new KustoSku(KustoSkuName.StandardL16asV3, KustoSkuTier.Standard) + { + Capacity = 2, + }) + { + Identity = new ManagedServiceIdentity("SystemAssigned"), + IsStreamingIngestEnabled = true, + IsPurgeEnabled = true, + LanguageExtensionsValue = {new KustoLanguageExtension +{ +LanguageExtensionName = KustoLanguageExtensionName.Python, +LanguageExtensionImageName = new KustoLanguageExtensionImageName("Python_Custom_Image"), +LanguageExtensionCustomImageName = "customImage8", +}, new KustoLanguageExtension +{ +LanguageExtensionName = KustoLanguageExtensionName.R, +LanguageExtensionImageName = KustoLanguageExtensionImageName.R, +}}, + IsDoubleEncryptionEnabled = false, + PublicNetworkAccess = KustoClusterPublicNetworkAccess.Enabled, + AllowedIPRangeList = { "0.0.0.0/0" }, + IsAutoStopEnabled = true, + PublicIPType = KustoClusterPublicIPType.DualStack, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); + KustoClusterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +78,7 @@ public async Task Get_KustoClustersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoClustersGet() + public async Task Get_KustoClustersGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersGet.json // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +100,21 @@ public async Task Exists_KustoClustersGet() // invoke the operation string clusterName = "kustoCluster"; - bool result = await collection.ExistsAsync(clusterName); + KustoClusterResource result = await collection.GetAsync(clusterName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoClustersGet() + public async Task GetAll_KustoClustersListByResourceGroup() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersGet.json - // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersListByResourceGroup.json + // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +131,25 @@ public async Task GetIfExists_KustoClustersGet() // get the collection of this KustoClusterResource KustoClusterCollection collection = resourceGroupResource.GetKustoClusters(); - // invoke the operation - string clusterName = "kustoCluster"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - KustoClusterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (KustoClusterResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KustoClusterData resourceData = result.Data; + KustoClusterData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoClustersCreateOrUpdate() + public async Task Exists_KustoClustersGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersCreateOrUpdate.json - // this example is just showing the usage of "Clusters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersGet.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,52 +168,17 @@ public async Task CreateOrUpdate_KustoClustersCreateOrUpdate() // invoke the operation string clusterName = "kustoCluster"; - KustoClusterData data = new KustoClusterData(new AzureLocation("westus"), new KustoSku(KustoSkuName.StandardL16asV3, KustoSkuTier.Standard) - { - Capacity = 2, - }) - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - IsStreamingIngestEnabled = true, - IsPurgeEnabled = true, - LanguageExtensionsValue = -{ -new KustoLanguageExtension() -{ -LanguageExtensionName = KustoLanguageExtensionName.Python, -LanguageExtensionImageName = new KustoLanguageExtensionImageName("Python_Custom_Image"), -LanguageExtensionCustomImageName = "customImage8", -},new KustoLanguageExtension() -{ -LanguageExtensionName = KustoLanguageExtensionName.R, -LanguageExtensionImageName = KustoLanguageExtensionImageName.R, -} -}, - IsDoubleEncryptionEnabled = false, - PublicNetworkAccess = KustoClusterPublicNetworkAccess.Enabled, - AllowedIPRangeList = -{ -"0.0.0.0/0" -}, - IsAutoStopEnabled = true, - PublicIPType = KustoClusterPublicIPType.DualStack, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); - KustoClusterResource result = lro.Value; + bool result = await collection.ExistsAsync(clusterName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoClustersListByResourceGroup() + public async Task GetIfExists_KustoClustersGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersListByResourceGroup.json - // this example is just showing the usage of "Clusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersGet.json + // this example is just showing the usage of "Clusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -207,17 +195,23 @@ public async Task GetAll_KustoClustersListByResourceGroup() // get the collection of this KustoClusterResource KustoClusterCollection collection = resourceGroupResource.GetKustoClusters(); - // invoke the operation and iterate over the result - await foreach (KustoClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "kustoCluster"; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + KustoClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KustoClusterData resourceData = item.Data; + KustoClusterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterPrincipalAssignmentCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterPrincipalAssignmentCollection.cs index 92628bb7bc77e..d4d5aced61925 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterPrincipalAssignmentCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterPrincipalAssignmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_KustoClusterPrincipalAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KustoClusterPrincipalAssignmentsGet() + public async Task CreateOrUpdate_KustoClusterPrincipalAssignmentsCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsGet.json - // this example is just showing the usage of "ClusterPrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsCreateOrUpdate.json + // this example is just showing the usage of "ClusterPrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_KustoClusterPrincipalAssignmentsGet() // invoke the operation string principalAssignmentName = "kustoprincipal1"; - KustoClusterPrincipalAssignmentResource result = await collection.GetAsync(principalAssignmentName); + KustoClusterPrincipalAssignmentData data = new KustoClusterPrincipalAssignmentData + { + ClusterPrincipalId = "87654321-1234-1234-1234-123456789123", + Role = KustoClusterPrincipalRole.AllDatabasesAdmin, + TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), + PrincipalType = KustoPrincipalAssignmentType.App, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, principalAssignmentName, data); + KustoClusterPrincipalAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_KustoClusterPrincipalAssignmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoClusterPrincipalAssignmentsGet() + public async Task Get_KustoClusterPrincipalAssignmentsGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsGet.json // this example is just showing the usage of "ClusterPrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +83,21 @@ public async Task Exists_KustoClusterPrincipalAssignmentsGet() // invoke the operation string principalAssignmentName = "kustoprincipal1"; - bool result = await collection.ExistsAsync(principalAssignmentName); + KustoClusterPrincipalAssignmentResource result = await collection.GetAsync(principalAssignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoClusterPrincipalAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoClusterPrincipalAssignmentsGet() + public async Task GetAll_KustoPrincipalAssignmentsList() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsGet.json - // this example is just showing the usage of "ClusterPrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsList.json + // this example is just showing the usage of "ClusterPrincipalAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +115,25 @@ public async Task GetIfExists_KustoClusterPrincipalAssignmentsGet() // get the collection of this KustoClusterPrincipalAssignmentResource KustoClusterPrincipalAssignmentCollection collection = kustoCluster.GetKustoClusterPrincipalAssignments(); - // invoke the operation - string principalAssignmentName = "kustoprincipal1"; - NullableResponse response = await collection.GetIfExistsAsync(principalAssignmentName); - KustoClusterPrincipalAssignmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (KustoClusterPrincipalAssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KustoClusterPrincipalAssignmentData resourceData = result.Data; + KustoClusterPrincipalAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoClusterPrincipalAssignmentsCreateOrUpdate() + public async Task Exists_KustoClusterPrincipalAssignmentsGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsCreateOrUpdate.json - // this example is just showing the usage of "ClusterPrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsGet.json + // this example is just showing the usage of "ClusterPrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,29 +153,17 @@ public async Task CreateOrUpdate_KustoClusterPrincipalAssignmentsCreateOrUpdate( // invoke the operation string principalAssignmentName = "kustoprincipal1"; - KustoClusterPrincipalAssignmentData data = new KustoClusterPrincipalAssignmentData() - { - ClusterPrincipalId = "87654321-1234-1234-1234-123456789123", - Role = KustoClusterPrincipalRole.AllDatabasesAdmin, - TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), - PrincipalType = KustoPrincipalAssignmentType.App, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, principalAssignmentName, data); - KustoClusterPrincipalAssignmentResource result = lro.Value; + bool result = await collection.ExistsAsync(principalAssignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoClusterPrincipalAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoPrincipalAssignmentsList() + public async Task GetIfExists_KustoClusterPrincipalAssignmentsGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsList.json - // this example is just showing the usage of "ClusterPrincipalAssignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsGet.json + // this example is just showing the usage of "ClusterPrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +181,23 @@ public async Task GetAll_KustoPrincipalAssignmentsList() // get the collection of this KustoClusterPrincipalAssignmentResource KustoClusterPrincipalAssignmentCollection collection = kustoCluster.GetKustoClusterPrincipalAssignments(); - // invoke the operation and iterate over the result - await foreach (KustoClusterPrincipalAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string principalAssignmentName = "kustoprincipal1"; + NullableResponse response = await collection.GetIfExistsAsync(principalAssignmentName); + KustoClusterPrincipalAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KustoClusterPrincipalAssignmentData resourceData = item.Data; + KustoClusterPrincipalAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterPrincipalAssignmentResource.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterPrincipalAssignmentResource.cs index 3a1325907d5fc..bec4ebe3688b1 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterPrincipalAssignmentResource.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterPrincipalAssignmentResource.cs @@ -49,10 +49,10 @@ public async Task Get_KustoClusterPrincipalAssignmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoClusterPrincipalAssignmentsCreateOrUpdate() + public async Task Delete_KustoClusterPrincipalAssignmentsDelete() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsCreateOrUpdate.json - // this example is just showing the usage of "ClusterPrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsDelete.json + // this example is just showing the usage of "ClusterPrincipalAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,29 +69,17 @@ public async Task Update_KustoClusterPrincipalAssignmentsCreateOrUpdate() KustoClusterPrincipalAssignmentResource kustoClusterPrincipalAssignment = client.GetKustoClusterPrincipalAssignmentResource(kustoClusterPrincipalAssignmentResourceId); // invoke the operation - KustoClusterPrincipalAssignmentData data = new KustoClusterPrincipalAssignmentData() - { - ClusterPrincipalId = "87654321-1234-1234-1234-123456789123", - Role = KustoClusterPrincipalRole.AllDatabasesAdmin, - TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), - PrincipalType = KustoPrincipalAssignmentType.App, - }; - ArmOperation lro = await kustoClusterPrincipalAssignment.UpdateAsync(WaitUntil.Completed, data); - KustoClusterPrincipalAssignmentResource result = lro.Value; + await kustoClusterPrincipalAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoClusterPrincipalAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoClusterPrincipalAssignmentsDelete() + public async Task Update_KustoClusterPrincipalAssignmentsCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsDelete.json - // this example is just showing the usage of "ClusterPrincipalAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClusterPrincipalAssignmentsCreateOrUpdate.json + // this example is just showing the usage of "ClusterPrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +96,21 @@ public async Task Delete_KustoClusterPrincipalAssignmentsDelete() KustoClusterPrincipalAssignmentResource kustoClusterPrincipalAssignment = client.GetKustoClusterPrincipalAssignmentResource(kustoClusterPrincipalAssignmentResourceId); // invoke the operation - await kustoClusterPrincipalAssignment.DeleteAsync(WaitUntil.Completed); + KustoClusterPrincipalAssignmentData data = new KustoClusterPrincipalAssignmentData + { + ClusterPrincipalId = "87654321-1234-1234-1234-123456789123", + Role = KustoClusterPrincipalRole.AllDatabasesAdmin, + TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), + PrincipalType = KustoPrincipalAssignmentType.App, + }; + ArmOperation lro = await kustoClusterPrincipalAssignment.UpdateAsync(WaitUntil.Completed, data); + KustoClusterPrincipalAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoClusterPrincipalAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterResource.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterResource.cs index 42b55c18de3d0..011d26da41c61 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterResource.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoClusterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Kusto.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Kusto.Samples @@ -49,10 +48,10 @@ public async Task Get_KustoClustersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoClustersUpdate() + public async Task Delete_KustoClustersDelete() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersUpdate.json - // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersDelete.json + // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,24 +67,17 @@ public async Task Update_KustoClustersUpdate() KustoClusterResource kustoCluster = client.GetKustoClusterResource(kustoClusterResourceId); // invoke the operation - KustoClusterPatch patch = new KustoClusterPatch(new AzureLocation("westus")); - string ifMatch = "*"; - ArmOperation lro = await kustoCluster.UpdateAsync(WaitUntil.Completed, patch, ifMatch: ifMatch); - KustoClusterResource result = lro.Value; + await kustoCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoClustersDelete() + public async Task Update_KustoClustersUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersDelete.json - // this example is just showing the usage of "Clusters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersUpdate.json + // this example is just showing the usage of "Clusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,9 +93,16 @@ public async Task Delete_KustoClustersDelete() KustoClusterResource kustoCluster = client.GetKustoClusterResource(kustoClusterResourceId); // invoke the operation - await kustoCluster.DeleteAsync(WaitUntil.Completed); + KustoClusterPatch patch = new KustoClusterPatch(new AzureLocation("westus")); + string ifMatch = "*"; + ArmOperation lro = await kustoCluster.UpdateAsync(WaitUntil.Completed, patch, ifMatch: ifMatch); + KustoClusterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -268,90 +267,6 @@ public async Task DiagnoseVirtualNetwork_KustoClusterDiagnoseVirtualNetwork() Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetKustoClusters_KustoClustersList() - { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersList.json - // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "12345678-1234-1234-1234-123456789098"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (KustoClusterResource item in subscriptionResource.GetKustoClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetKustoEligibleSkus_KustoClustersListSkus() - { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersListSkus.json - // this example is just showing the usage of "Clusters_ListSkus" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "12345678-1234-1234-1234-123456789098"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (KustoSkuDescription item in subscriptionResource.GetKustoEligibleSkusAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckKustoClusterNameAvailability_KustoClustersCheckNameAvailability() - { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersCheckNameAvailability.json - // this example is just showing the usage of "Clusters_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "12345678-1234-1234-1234-123456789098"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("westus"); - KustoClusterNameAvailabilityContent content = new KustoClusterNameAvailabilityContent("kustoCluster"); - KustoNameAvailabilityResult result = await subscriptionResource.CheckKustoClusterNameAvailabilityAsync(location, content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetAvailableSkus_KustoClustersListResourceSkus() @@ -460,18 +375,15 @@ public async Task AddLanguageExtensions_KustoClusterAddLanguageExtensions() KustoClusterResource kustoCluster = client.GetKustoClusterResource(kustoClusterResourceId); // invoke the operation - KustoLanguageExtensionList languageExtensionsToAdd = new KustoLanguageExtensionList() + KustoLanguageExtensionList languageExtensionsToAdd = new KustoLanguageExtensionList { - Value = -{ -new KustoLanguageExtension() + Value = {new KustoLanguageExtension { LanguageExtensionName = KustoLanguageExtensionName.Python, -},new KustoLanguageExtension() +}, new KustoLanguageExtension { LanguageExtensionName = KustoLanguageExtensionName.R, -} -}, +}}, }; await kustoCluster.AddLanguageExtensionsAsync(WaitUntil.Completed, languageExtensionsToAdd); @@ -499,18 +411,15 @@ public async Task RemoveLanguageExtensions_KustoClusterRemoveLanguageExtensions( KustoClusterResource kustoCluster = client.GetKustoClusterResource(kustoClusterResourceId); // invoke the operation - KustoLanguageExtensionList languageExtensionsToRemove = new KustoLanguageExtensionList() + KustoLanguageExtensionList languageExtensionsToRemove = new KustoLanguageExtensionList { - Value = -{ -new KustoLanguageExtension() + Value = {new KustoLanguageExtension { LanguageExtensionName = KustoLanguageExtensionName.Python, -},new KustoLanguageExtension() +}, new KustoLanguageExtension { LanguageExtensionName = KustoLanguageExtensionName.R, -} -}, +}}, }; await kustoCluster.RemoveLanguageExtensionsAsync(WaitUntil.Completed, languageExtensionsToRemove); diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDataConnectionCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDataConnectionCollection.cs index 9dba1aad37fa9..a953b6c408410 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDataConnectionCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDataConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_KustoDataConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoDatabasesListByCluster() + public async Task CreateOrUpdate_KustoDataConnectionsCosmosDbCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsListByDatabase.json - // this example is just showing the usage of "DataConnections_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCosmosDbCreateOrUpdate.json + // this example is just showing the usage of "DataConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,32 +33,42 @@ public async Task GetAll_KustoDatabasesListByCluster() string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; string clusterName = "kustoCluster"; - string databaseName = "KustoDatabase8"; + string databaseName = "KustoDatabase1"; ResourceIdentifier kustoDatabaseResourceId = KustoDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName); KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); // get the collection of this KustoDataConnectionResource KustoDataConnectionCollection collection = kustoDatabase.GetKustoDataConnections(); - // invoke the operation and iterate over the result - await foreach (KustoDataConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string dataConnectionName = "dataConnectionTest"; + KustoDataConnectionData data = new KustoCosmosDBDataConnection { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDataConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + TableName = "TestTable", + MappingRuleName = "TestMapping", + ManagedIdentityResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), + CosmosDBAccountResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.DocumentDb/databaseAccounts/cosmosDbAccountTest1"), + CosmosDBDatabase = "cosmosDbDatabaseTest", + CosmosDBContainer = "cosmosDbContainerTest", + RetrievalStartOn = DateTimeOffset.Parse("2022-07-29T12:00:00.6554616Z"), + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataConnectionName, data); + KustoDataConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDataConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KustoDataConnectionsCosmosDbGet() + public async Task CreateOrUpdate_KustoDataConnectionsCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCosmosDbGet.json - // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCreateOrUpdate.json + // this example is just showing the usage of "DataConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,7 +80,7 @@ public async Task Get_KustoDataConnectionsCosmosDbGet() string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; string clusterName = "kustoCluster"; - string databaseName = "KustoDatabase1"; + string databaseName = "KustoDatabase8"; ResourceIdentifier kustoDatabaseResourceId = KustoDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName); KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); @@ -79,7 +89,15 @@ public async Task Get_KustoDataConnectionsCosmosDbGet() // invoke the operation string dataConnectionName = "dataConnectionTest"; - KustoDataConnectionResource result = await collection.GetAsync(dataConnectionName); + KustoDataConnectionData data = new KustoEventHubDataConnection + { + EventHubResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest1"), + ConsumerGroup = "testConsumerGroup1", + ManagedIdentityResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataConnectionName, data); + KustoDataConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -90,10 +108,10 @@ public async Task Get_KustoDataConnectionsCosmosDbGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoDataConnectionsCosmosDbGet() + public async Task CreateOrUpdate_KustoDataConnectionsEventGridCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCosmosDbGet.json - // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsEventGridCreateOrUpdate.json + // this example is just showing the usage of "DataConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,7 +123,7 @@ public async Task Exists_KustoDataConnectionsCosmosDbGet() string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; string clusterName = "kustoCluster"; - string databaseName = "KustoDatabase1"; + string databaseName = "KustoDatabase8"; ResourceIdentifier kustoDatabaseResourceId = KustoDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName); KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); @@ -114,14 +132,34 @@ public async Task Exists_KustoDataConnectionsCosmosDbGet() // invoke the operation string dataConnectionName = "dataConnectionTest"; - bool result = await collection.ExistsAsync(dataConnectionName); + KustoDataConnectionData data = new KustoEventGridDataConnection + { + StorageAccountResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount"), + EventGridResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount/providers/Microsoft.EventGrid/eventSubscriptions/eventSubscriptionTest"), + EventHubResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest2"), + ConsumerGroup = "$Default", + TableName = "TestTable", + MappingRuleName = "TestMapping", + DataFormat = KustoEventGridDataFormat.Json, + IsFirstRecordIgnored = false, + BlobStorageEventType = BlobStorageEventType.MicrosoftStorageBlobCreated, + ManagedIdentityResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), + DatabaseRouting = KustoDatabaseRouting.Single, + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataConnectionName, data); + KustoDataConnectionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDataConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoDataConnectionsCosmosDbGet() + public async Task Get_KustoDataConnectionsCosmosDbGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCosmosDbGet.json // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,21 +183,13 @@ public async Task GetIfExists_KustoDataConnectionsCosmosDbGet() // invoke the operation string dataConnectionName = "dataConnectionTest"; - NullableResponse response = await collection.GetIfExistsAsync(dataConnectionName); - KustoDataConnectionResource result = response.HasValue ? response.Value : null; + KustoDataConnectionResource result = await collection.GetAsync(dataConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDataConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDataConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -199,9 +229,9 @@ public async Task Get_KustoDataConnectionsEventGridGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoDataConnectionsEventGridGet() + public async Task Get_KustoDataConnectionsGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsEventGridGet.json + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsGet.json // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -223,17 +253,21 @@ public async Task Exists_KustoDataConnectionsEventGridGet() // invoke the operation string dataConnectionName = "dataConnectionTest"; - bool result = await collection.ExistsAsync(dataConnectionName); + KustoDataConnectionResource result = await collection.GetAsync(dataConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDataConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoDataConnectionsEventGridGet() + public async Task GetAll_KustoDatabasesListByCluster() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsEventGridGet.json - // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsListByDatabase.json + // this example is just showing the usage of "DataConnections_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -252,30 +286,24 @@ public async Task GetIfExists_KustoDataConnectionsEventGridGet() // get the collection of this KustoDataConnectionResource KustoDataConnectionCollection collection = kustoDatabase.GetKustoDataConnections(); - // invoke the operation - string dataConnectionName = "dataConnectionTest"; - NullableResponse response = await collection.GetIfExistsAsync(dataConnectionName); - KustoDataConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (KustoDataConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KustoDataConnectionData resourceData = result.Data; + KustoDataConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KustoDataConnectionsGet() + public async Task Exists_KustoDataConnectionsCosmosDbGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsGet.json + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCosmosDbGet.json // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -288,7 +316,7 @@ public async Task Get_KustoDataConnectionsGet() string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; string clusterName = "kustoCluster"; - string databaseName = "KustoDatabase8"; + string databaseName = "KustoDatabase1"; ResourceIdentifier kustoDatabaseResourceId = KustoDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName); KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); @@ -297,20 +325,16 @@ public async Task Get_KustoDataConnectionsGet() // invoke the operation string dataConnectionName = "dataConnectionTest"; - KustoDataConnectionResource result = await collection.GetAsync(dataConnectionName); + bool result = await collection.ExistsAsync(dataConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDataConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoDataConnectionsGet() + public async Task Exists_KustoDataConnectionsEventGridGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsGet.json + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsEventGridGet.json // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -339,7 +363,7 @@ public async Task Exists_KustoDataConnectionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoDataConnectionsGet() + public async Task Exists_KustoDataConnectionsGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsGet.json // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -363,29 +387,17 @@ public async Task GetIfExists_KustoDataConnectionsGet() // invoke the operation string dataConnectionName = "dataConnectionTest"; - NullableResponse response = await collection.GetIfExistsAsync(dataConnectionName); - KustoDataConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDataConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoDataConnectionsCosmosDbCreateOrUpdate() + public async Task GetIfExists_KustoDataConnectionsCosmosDbGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCosmosDbCreateOrUpdate.json - // this example is just showing the usage of "DataConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCosmosDbGet.json + // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -406,33 +418,29 @@ public async Task CreateOrUpdate_KustoDataConnectionsCosmosDbCreateOrUpdate() // invoke the operation string dataConnectionName = "dataConnectionTest"; - KustoDataConnectionData data = new KustoCosmosDBDataConnection() - { - TableName = "TestTable", - MappingRuleName = "TestMapping", - ManagedIdentityResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), - CosmosDBAccountResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.DocumentDb/databaseAccounts/cosmosDbAccountTest1"), - CosmosDBDatabase = "cosmosDbDatabaseTest", - CosmosDBContainer = "cosmosDbContainerTest", - RetrievalStartOn = DateTimeOffset.Parse("2022-07-29T12:00:00.6554616Z"), - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataConnectionName, data); - KustoDataConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dataConnectionName); + KustoDataConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDataConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDataConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoDataConnectionsCreateOrUpdate() + public async Task GetIfExists_KustoDataConnectionsEventGridGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsCreateOrUpdate.json - // this example is just showing the usage of "DataConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsEventGridGet.json + // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -453,29 +461,29 @@ public async Task CreateOrUpdate_KustoDataConnectionsCreateOrUpdate() // invoke the operation string dataConnectionName = "dataConnectionTest"; - KustoDataConnectionData data = new KustoEventHubDataConnection() - { - EventHubResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest1"), - ConsumerGroup = "testConsumerGroup1", - ManagedIdentityResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataConnectionName, data); - KustoDataConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dataConnectionName); + KustoDataConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDataConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDataConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoDataConnectionsEventGridCreateOrUpdate() + public async Task GetIfExists_KustoDataConnectionsGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsEventGridCreateOrUpdate.json - // this example is just showing the usage of "DataConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsGet.json + // this example is just showing the usage of "DataConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -496,29 +504,21 @@ public async Task CreateOrUpdate_KustoDataConnectionsEventGridCreateOrUpdate() // invoke the operation string dataConnectionName = "dataConnectionTest"; - KustoDataConnectionData data = new KustoEventGridDataConnection() - { - StorageAccountResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount"), - EventGridResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount/providers/Microsoft.EventGrid/eventSubscriptions/eventSubscriptionTest"), - EventHubResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest2"), - ConsumerGroup = "$Default", - TableName = "TestTable", - MappingRuleName = "TestMapping", - DataFormat = KustoEventGridDataFormat.Json, - IsFirstRecordIgnored = false, - BlobStorageEventType = BlobStorageEventType.MicrosoftStorageBlobCreated, - ManagedIdentityResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), - DatabaseRouting = KustoDatabaseRouting.Single, - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataConnectionName, data); - KustoDataConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dataConnectionName); + KustoDataConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDataConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDataConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDataConnectionResource.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDataConnectionResource.cs index e7fa030dd6752..b4179a213c891 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDataConnectionResource.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDataConnectionResource.cs @@ -112,6 +112,34 @@ public async Task Get_KustoDataConnectionsGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_KustoDataConnectionsDelete() + { + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsDelete.json + // this example is just showing the usage of "DataConnections_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this KustoDataConnectionResource created on azure + // for more information of creating KustoDataConnectionResource, please refer to the document of KustoDataConnectionResource + string subscriptionId = "12345678-1234-1234-1234-123456789098"; + string resourceGroupName = "kustorptest"; + string clusterName = "kustoCluster"; + string databaseName = "KustoDatabase8"; + string dataConnectionName = "dataConnectionTest"; + ResourceIdentifier kustoDataConnectionResourceId = KustoDataConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName, dataConnectionName); + KustoDataConnectionResource kustoDataConnection = client.GetKustoDataConnectionResource(kustoDataConnectionResourceId); + + // invoke the operation + await kustoDataConnection.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_KustoDataConnectionsCosmosDbUpdate() @@ -135,7 +163,7 @@ public async Task Update_KustoDataConnectionsCosmosDbUpdate() KustoDataConnectionResource kustoDataConnection = client.GetKustoDataConnectionResource(kustoDataConnectionResourceId); // invoke the operation - KustoDataConnectionData data = new KustoCosmosDBDataConnection() + KustoDataConnectionData data = new KustoCosmosDBDataConnection { TableName = "TestTable", MappingRuleName = "TestMapping", @@ -179,7 +207,7 @@ public async Task Update_KustoDataConnectionsEventGridUpdate() KustoDataConnectionResource kustoDataConnection = client.GetKustoDataConnectionResource(kustoDataConnectionResourceId); // invoke the operation - KustoDataConnectionData data = new KustoEventGridDataConnection() + KustoDataConnectionData data = new KustoEventGridDataConnection { StorageAccountResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount"), EventGridResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount/providers/Microsoft.EventGrid/eventSubscriptions/eventSubscriptionTest"), @@ -227,7 +255,7 @@ public async Task Update_KustoDataConnectionsUpdate() KustoDataConnectionResource kustoDataConnection = client.GetKustoDataConnectionResource(kustoDataConnectionResourceId); // invoke the operation - KustoDataConnectionData data = new KustoEventHubDataConnection() + KustoDataConnectionData data = new KustoEventHubDataConnection { EventHubResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest1"), ConsumerGroup = "testConsumerGroup1", @@ -243,33 +271,5 @@ public async Task Update_KustoDataConnectionsUpdate() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoDataConnectionsDelete() - { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDataConnectionsDelete.json - // this example is just showing the usage of "DataConnections_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this KustoDataConnectionResource created on azure - // for more information of creating KustoDataConnectionResource, please refer to the document of KustoDataConnectionResource - string subscriptionId = "12345678-1234-1234-1234-123456789098"; - string resourceGroupName = "kustorptest"; - string clusterName = "kustoCluster"; - string databaseName = "KustoDatabase8"; - string dataConnectionName = "dataConnectionTest"; - ResourceIdentifier kustoDataConnectionResourceId = KustoDataConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName, dataConnectionName); - KustoDataConnectionResource kustoDataConnection = client.GetKustoDataConnectionResource(kustoDataConnectionResourceId); - - // invoke the operation - await kustoDataConnection.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabaseCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabaseCollection.cs index 1eb5ca98a598f..d09ac97bd4c13 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabaseCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabaseCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_KustoDatabaseCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoDatabasesListByCluster() + public async Task CreateOrUpdate_KustoReadOnlyDatabaseUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesListByCluster.json - // this example is just showing the usage of "Databases_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseReadonlyUpdate.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,29 @@ public async Task GetAll_KustoDatabasesListByCluster() // get the collection of this KustoDatabaseResource KustoDatabaseCollection collection = kustoCluster.GetKustoDatabases(); - // invoke the operation and iterate over the result - await foreach (KustoDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "kustoReadOnlyDatabase"; + KustoDatabaseData data = new KustoReadOnlyFollowingDatabase { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDatabaseData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HotCachePeriod = XmlConvert.ToTimeSpan("P1D"), + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); + KustoDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KustoDatabasesGet() + public async Task CreateOrUpdate_KustoReadWriteDatabaseCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesCreateOrUpdate.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,7 +82,14 @@ public async Task Get_KustoDatabasesGet() // invoke the operation string databaseName = "KustoDatabase8"; - KustoDatabaseResource result = await collection.GetAsync(databaseName); + KustoDatabaseData data = new KustoReadWriteDatabase + { + SoftDeletePeriod = XmlConvert.ToTimeSpan("P1D"), + Location = new AzureLocation("westus"), + }; + KustoDatabaseCallerRole? callerRole = KustoDatabaseCallerRole.Admin; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data, callerRole: callerRole); + KustoDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,7 +100,7 @@ public async Task Get_KustoDatabasesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoDatabasesGet() + public async Task Get_KustoDatabasesGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesGet.json // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. @@ -112,16 +123,20 @@ public async Task Exists_KustoDatabasesGet() // invoke the operation string databaseName = "KustoDatabase8"; - bool result = await collection.ExistsAsync(databaseName); + KustoDatabaseResource result = await collection.GetAsync(databaseName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoDatabasesGet() + public async Task Get_KustoSuspendedDatabasesGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesGet.json + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSuspendedDatabasesGet.json // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -141,30 +156,22 @@ public async Task GetIfExists_KustoDatabasesGet() KustoDatabaseCollection collection = kustoCluster.GetKustoDatabases(); // invoke the operation - string databaseName = "KustoDatabase8"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - KustoDatabaseResource result = response.HasValue ? response.Value : null; + string databaseName = "KustoDatabase9"; + KustoDatabaseResource result = await collection.GetAsync(databaseName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KustoSuspendedDatabasesGet() + public async Task GetAll_KustoDatabasesListByCluster() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSuspendedDatabasesGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesListByCluster.json + // this example is just showing the usage of "Databases_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,22 +189,24 @@ public async Task Get_KustoSuspendedDatabasesGet() // get the collection of this KustoDatabaseResource KustoDatabaseCollection collection = kustoCluster.GetKustoDatabases(); - // invoke the operation - string databaseName = "KustoDatabase9"; - KustoDatabaseResource result = await collection.GetAsync(databaseName); + // invoke the operation and iterate over the result + await foreach (KustoDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoSuspendedDatabasesGet() + public async Task Exists_KustoDatabasesGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSuspendedDatabasesGet.json + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesGet.json // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -217,7 +226,7 @@ public async Task Exists_KustoSuspendedDatabasesGet() KustoDatabaseCollection collection = kustoCluster.GetKustoDatabases(); // invoke the operation - string databaseName = "KustoDatabase9"; + string databaseName = "KustoDatabase8"; bool result = await collection.ExistsAsync(databaseName); Console.WriteLine($"Succeeded: {result}"); @@ -225,7 +234,7 @@ public async Task Exists_KustoSuspendedDatabasesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoSuspendedDatabasesGet() + public async Task Exists_KustoSuspendedDatabasesGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSuspendedDatabasesGet.json // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. @@ -248,29 +257,17 @@ public async Task GetIfExists_KustoSuspendedDatabasesGet() // invoke the operation string databaseName = "KustoDatabase9"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - KustoDatabaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(databaseName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoReadOnlyDatabaseUpdate() + public async Task GetIfExists_KustoDatabasesGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabaseReadonlyUpdate.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -289,28 +286,30 @@ public async Task CreateOrUpdate_KustoReadOnlyDatabaseUpdate() KustoDatabaseCollection collection = kustoCluster.GetKustoDatabases(); // invoke the operation - string databaseName = "kustoReadOnlyDatabase"; - KustoDatabaseData data = new KustoReadOnlyFollowingDatabase() - { - HotCachePeriod = XmlConvert.ToTimeSpan("P1D"), - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data); - KustoDatabaseResource result = lro.Value; + string databaseName = "KustoDatabase8"; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + KustoDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoReadWriteDatabaseCreateOrUpdate() + public async Task GetIfExists_KustoSuspendedDatabasesGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesCreateOrUpdate.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSuspendedDatabasesGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -329,21 +328,22 @@ public async Task CreateOrUpdate_KustoReadWriteDatabaseCreateOrUpdate() KustoDatabaseCollection collection = kustoCluster.GetKustoDatabases(); // invoke the operation - string databaseName = "KustoDatabase8"; - KustoDatabaseData data = new KustoReadWriteDatabase() - { - SoftDeletePeriod = XmlConvert.ToTimeSpan("P1D"), - Location = new AzureLocation("westus"), - }; - KustoDatabaseCallerRole? callerRole = KustoDatabaseCallerRole.Admin; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, databaseName, data, callerRole: callerRole); - KustoDatabaseResource result = lro.Value; + string databaseName = "KustoDatabase9"; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + KustoDatabaseResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabasePrincipalAssignmentCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabasePrincipalAssignmentCollection.cs index 00dc94a0efe29..7d7b03474b225 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabasePrincipalAssignmentCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabasePrincipalAssignmentCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_KustoDatabasePrincipalAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_KustoDatabasePrincipalAssignmentsGet() + public async Task CreateOrUpdate_KustoDatabasePrincipalAssignmentsCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsGet.json - // this example is just showing the usage of "DatabasePrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsCreateOrUpdate.json + // this example is just showing the usage of "DatabasePrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,15 @@ public async Task Get_KustoDatabasePrincipalAssignmentsGet() // invoke the operation string principalAssignmentName = "kustoprincipal1"; - KustoDatabasePrincipalAssignmentResource result = await collection.GetAsync(principalAssignmentName); + KustoDatabasePrincipalAssignmentData data = new KustoDatabasePrincipalAssignmentData + { + DatabasePrincipalId = "87654321-1234-1234-1234-123456789123", + Role = KustoDatabasePrincipalRole.Admin, + TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), + PrincipalType = KustoPrincipalAssignmentType.App, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, principalAssignmentName, data); + KustoDatabasePrincipalAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +61,7 @@ public async Task Get_KustoDatabasePrincipalAssignmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoDatabasePrincipalAssignmentsGet() + public async Task Get_KustoDatabasePrincipalAssignmentsGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsGet.json // this example is just showing the usage of "DatabasePrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +85,21 @@ public async Task Exists_KustoDatabasePrincipalAssignmentsGet() // invoke the operation string principalAssignmentName = "kustoprincipal1"; - bool result = await collection.ExistsAsync(principalAssignmentName); + KustoDatabasePrincipalAssignmentResource result = await collection.GetAsync(principalAssignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDatabasePrincipalAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoDatabasePrincipalAssignmentsGet() + public async Task GetAll_KustoPrincipalAssignmentsList() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsGet.json - // this example is just showing the usage of "DatabasePrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsList.json + // this example is just showing the usage of "DatabasePrincipalAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +118,25 @@ public async Task GetIfExists_KustoDatabasePrincipalAssignmentsGet() // get the collection of this KustoDatabasePrincipalAssignmentResource KustoDatabasePrincipalAssignmentCollection collection = kustoDatabase.GetKustoDatabasePrincipalAssignments(); - // invoke the operation - string principalAssignmentName = "kustoprincipal1"; - NullableResponse response = await collection.GetIfExistsAsync(principalAssignmentName); - KustoDatabasePrincipalAssignmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (KustoDatabasePrincipalAssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KustoDatabasePrincipalAssignmentData resourceData = result.Data; + KustoDatabasePrincipalAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoDatabasePrincipalAssignmentsCreateOrUpdate() + public async Task Exists_KustoDatabasePrincipalAssignmentsGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsCreateOrUpdate.json - // this example is just showing the usage of "DatabasePrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsGet.json + // this example is just showing the usage of "DatabasePrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,29 +157,17 @@ public async Task CreateOrUpdate_KustoDatabasePrincipalAssignmentsCreateOrUpdate // invoke the operation string principalAssignmentName = "kustoprincipal1"; - KustoDatabasePrincipalAssignmentData data = new KustoDatabasePrincipalAssignmentData() - { - DatabasePrincipalId = "87654321-1234-1234-1234-123456789123", - Role = KustoDatabasePrincipalRole.Admin, - TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), - PrincipalType = KustoPrincipalAssignmentType.App, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, principalAssignmentName, data); - KustoDatabasePrincipalAssignmentResource result = lro.Value; + bool result = await collection.ExistsAsync(principalAssignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDatabasePrincipalAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoPrincipalAssignmentsList() + public async Task GetIfExists_KustoDatabasePrincipalAssignmentsGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsList.json - // this example is just showing the usage of "DatabasePrincipalAssignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsGet.json + // this example is just showing the usage of "DatabasePrincipalAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,17 +186,23 @@ public async Task GetAll_KustoPrincipalAssignmentsList() // get the collection of this KustoDatabasePrincipalAssignmentResource KustoDatabasePrincipalAssignmentCollection collection = kustoDatabase.GetKustoDatabasePrincipalAssignments(); - // invoke the operation and iterate over the result - await foreach (KustoDatabasePrincipalAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string principalAssignmentName = "kustoprincipal1"; + NullableResponse response = await collection.GetIfExistsAsync(principalAssignmentName); + KustoDatabasePrincipalAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - KustoDatabasePrincipalAssignmentData resourceData = item.Data; + KustoDatabasePrincipalAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabasePrincipalAssignmentResource.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabasePrincipalAssignmentResource.cs index 25a5d40612ac7..915c691da4ddb 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabasePrincipalAssignmentResource.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabasePrincipalAssignmentResource.cs @@ -50,10 +50,10 @@ public async Task Get_KustoDatabasePrincipalAssignmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoDatabasePrincipalAssignmentsCreateOrUpdate() + public async Task Delete_KustoDatabasePrincipalAssignmentsDelete() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsCreateOrUpdate.json - // this example is just showing the usage of "DatabasePrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsDelete.json + // this example is just showing the usage of "DatabasePrincipalAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,29 +71,17 @@ public async Task Update_KustoDatabasePrincipalAssignmentsCreateOrUpdate() KustoDatabasePrincipalAssignmentResource kustoDatabasePrincipalAssignment = client.GetKustoDatabasePrincipalAssignmentResource(kustoDatabasePrincipalAssignmentResourceId); // invoke the operation - KustoDatabasePrincipalAssignmentData data = new KustoDatabasePrincipalAssignmentData() - { - DatabasePrincipalId = "87654321-1234-1234-1234-123456789123", - Role = KustoDatabasePrincipalRole.Admin, - TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), - PrincipalType = KustoPrincipalAssignmentType.App, - }; - ArmOperation lro = await kustoDatabasePrincipalAssignment.UpdateAsync(WaitUntil.Completed, data); - KustoDatabasePrincipalAssignmentResource result = lro.Value; + await kustoDatabasePrincipalAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDatabasePrincipalAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoDatabasePrincipalAssignmentsDelete() + public async Task Update_KustoDatabasePrincipalAssignmentsCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsDelete.json - // this example is just showing the usage of "DatabasePrincipalAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasePrincipalAssignmentsCreateOrUpdate.json + // this example is just showing the usage of "DatabasePrincipalAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +99,21 @@ public async Task Delete_KustoDatabasePrincipalAssignmentsDelete() KustoDatabasePrincipalAssignmentResource kustoDatabasePrincipalAssignment = client.GetKustoDatabasePrincipalAssignmentResource(kustoDatabasePrincipalAssignmentResourceId); // invoke the operation - await kustoDatabasePrincipalAssignment.DeleteAsync(WaitUntil.Completed); + KustoDatabasePrincipalAssignmentData data = new KustoDatabasePrincipalAssignmentData + { + DatabasePrincipalId = "87654321-1234-1234-1234-123456789123", + Role = KustoDatabasePrincipalRole.Admin, + TenantId = Guid.Parse("12345678-1234-1234-1234-123456789123"), + PrincipalType = KustoPrincipalAssignmentType.App, + }; + ArmOperation lro = await kustoDatabasePrincipalAssignment.UpdateAsync(WaitUntil.Completed, data); + KustoDatabasePrincipalAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDatabasePrincipalAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabaseResource.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabaseResource.cs index dfaa2dfa1234e..ec5209080a095 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabaseResource.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoDatabaseResource.cs @@ -81,10 +81,10 @@ public async Task Get_KustoSuspendedDatabasesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoDatabasesUpdate() + public async Task Delete_KustoDatabasesDelete() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesUpdate.json - // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesDelete.json + // this example is just showing the usage of "Databases_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,26 +101,17 @@ public async Task Update_KustoDatabasesUpdate() KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); // invoke the operation - KustoDatabaseData data = new KustoReadWriteDatabase() - { - HotCachePeriod = XmlConvert.ToTimeSpan("P1D"), - }; - ArmOperation lro = await kustoDatabase.UpdateAsync(WaitUntil.Completed, data); - KustoDatabaseResource result = lro.Value; + await kustoDatabase.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoDatabasesDelete() + public async Task Update_KustoDatabasesUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesDelete.json - // this example is just showing the usage of "Databases_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoDatabasesUpdate.json + // this example is just showing the usage of "Databases_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,9 +128,18 @@ public async Task Delete_KustoDatabasesDelete() KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); // invoke the operation - await kustoDatabase.DeleteAsync(WaitUntil.Completed); + KustoDatabaseData data = new KustoReadWriteDatabase + { + HotCachePeriod = XmlConvert.ToTimeSpan("P1D"), + }; + ArmOperation lro = await kustoDatabase.UpdateAsync(WaitUntil.Completed, data); + KustoDatabaseResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoDatabaseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -194,27 +194,24 @@ public async Task AddPrincipals_KustoDatabaseAddPrincipals() KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); // invoke the operation and iterate over the result - DatabasePrincipalList databasePrincipalsToAdd = new DatabasePrincipalList() + DatabasePrincipalList databasePrincipalsToAdd = new DatabasePrincipalList { - Value = -{ -new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Admin,"Some User",KustoDatabasePrincipalType.User) + Value = {new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Admin, "Some User", KustoDatabasePrincipalType.User) { Fqn = "aaduser=some_guid", Email = "user@microsoft.com", AppId = "", -},new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Viewer,"Kusto",KustoDatabasePrincipalType.Group) +}, new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Viewer, "Kusto", KustoDatabasePrincipalType.Group) { Fqn = "aadgroup=some_guid", Email = "kusto@microsoft.com", AppId = "", -},new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Admin,"SomeApp",KustoDatabasePrincipalType.App) +}, new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Admin, "SomeApp", KustoDatabasePrincipalType.App) { Fqn = "aadapp=some_guid_app_id", Email = "", AppId = "some_guid_app_id", -} -}, +}}, }; await foreach (KustoDatabasePrincipal item in kustoDatabase.AddPrincipalsAsync(databasePrincipalsToAdd)) { @@ -246,27 +243,24 @@ public async Task RemovePrincipals_KustoDatabaseRemovePrincipals() KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); // invoke the operation and iterate over the result - DatabasePrincipalList databasePrincipalsToRemove = new DatabasePrincipalList() + DatabasePrincipalList databasePrincipalsToRemove = new DatabasePrincipalList { - Value = -{ -new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Admin,"Some User",KustoDatabasePrincipalType.User) + Value = {new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Admin, "Some User", KustoDatabasePrincipalType.User) { Fqn = "aaduser=some_guid", Email = "user@microsoft.com", AppId = "", -},new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Viewer,"Kusto",KustoDatabasePrincipalType.Group) +}, new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Viewer, "Kusto", KustoDatabasePrincipalType.Group) { Fqn = "aadgroup=some_guid", Email = "kusto@microsoft.com", AppId = "", -},new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Admin,"SomeApp",KustoDatabasePrincipalType.App) +}, new KustoDatabasePrincipal(KustoDatabasePrincipalRole.Admin, "SomeApp", KustoDatabasePrincipalType.App) { Fqn = "aadapp=some_guid_app_id", Email = "", AppId = "some_guid_app_id", -} -}, +}}, }; await foreach (KustoDatabasePrincipal item in kustoDatabase.RemovePrincipalsAsync(databasePrincipalsToRemove)) { @@ -300,39 +294,16 @@ public async Task InviteFollowerDatabase_KustoDatabaseInviteFollower() // invoke the operation DatabaseInviteFollowerContent content = new DatabaseInviteFollowerContent("invitee@contoso.com") { - TableLevelSharingProperties = new KustoDatabaseTableLevelSharingProperties() + TableLevelSharingProperties = new KustoDatabaseTableLevelSharingProperties { - TablesToInclude = -{ -"Table1" -}, - TablesToExclude = -{ -"Table2" -}, - ExternalTablesToInclude = -{ -"ExternalTable*" -}, - ExternalTablesToExclude = -{ -}, - MaterializedViewsToInclude = -{ -"MaterializedViewTable1" -}, - MaterializedViewsToExclude = -{ -"MaterializedViewTable2" -}, - FunctionsToInclude = -{ -"functionsToInclude1" -}, - FunctionsToExclude = -{ -"functionsToExclude2" -}, + TablesToInclude = { "Table1" }, + TablesToExclude = { "Table2" }, + ExternalTablesToInclude = { "ExternalTable*" }, + ExternalTablesToExclude = { }, + MaterializedViewsToInclude = { "MaterializedViewTable1" }, + MaterializedViewsToExclude = { "MaterializedViewTable2" }, + FunctionsToInclude = { "functionsToInclude1" }, + FunctionsToExclude = { "functionsToExclude2" }, }, }; DatabaseInviteFollowerResult result = await kustoDatabase.InviteFollowerDatabaseAsync(content); @@ -418,10 +389,10 @@ public async Task ValidateDataConnection_KustoDataConnectionEventGridValidation( KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); // invoke the operation - DataConnectionValidationContent content = new DataConnectionValidationContent() + DataConnectionValidationContent content = new DataConnectionValidationContent { DataConnectionName = "dataConnectionTest", - Properties = new KustoEventGridDataConnection() + Properties = new KustoEventGridDataConnection { StorageAccountResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount"), EventGridResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/teststorageaccount/providers/Microsoft.EventGrid/eventSubscriptions/eventSubscriptionTest"), @@ -464,10 +435,10 @@ public async Task ValidateDataConnection_KustoDataConnectionValidation() KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); // invoke the operation - DataConnectionValidationContent content = new DataConnectionValidationContent() + DataConnectionValidationContent content = new DataConnectionValidationContent { DataConnectionName = "dataConnectionTest", - Properties = new KustoEventHubDataConnection() + Properties = new KustoEventHubDataConnection { EventHubResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.EventHub/namespaces/eventhubTestns1/eventhubs/eventhubTest1"), ConsumerGroup = "testConsumerGroup1", diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoManagedPrivateEndpointCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoManagedPrivateEndpointCollection.cs index 1c6a12bcfe61a..8bf830c48938f 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoManagedPrivateEndpointCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoManagedPrivateEndpointCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_KustoManagedPrivateEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoManagedPrivateEndpointsList() + public async Task CreateOrUpdate_KustoManagedPrivateEndpointsCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsList.json - // this example is just showing the usage of "ManagedPrivateEndpoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsCreateOrUpdate.json + // this example is just showing the usage of "ManagedPrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,22 @@ public async Task GetAll_KustoManagedPrivateEndpointsList() // get the collection of this KustoManagedPrivateEndpointResource KustoManagedPrivateEndpointCollection collection = kustoCluster.GetKustoManagedPrivateEndpoints(); - // invoke the operation and iterate over the result - await foreach (KustoManagedPrivateEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string managedPrivateEndpointName = "managedPrivateEndpointTest"; + KustoManagedPrivateEndpointData data = new KustoManagedPrivateEndpointData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoManagedPrivateEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/storageAccountTest"), + GroupId = "blob", + RequestMessage = "Please Approve.", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedPrivateEndpointName, data); + KustoManagedPrivateEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoManagedPrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +92,10 @@ public async Task Get_KustoManagedPrivateEndpointsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoManagedPrivateEndpointsGet() + public async Task GetAll_KustoManagedPrivateEndpointsList() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsGet.json - // this example is just showing the usage of "ManagedPrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsList.json + // this example is just showing the usage of "ManagedPrivateEndpoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +113,22 @@ public async Task Exists_KustoManagedPrivateEndpointsGet() // get the collection of this KustoManagedPrivateEndpointResource KustoManagedPrivateEndpointCollection collection = kustoCluster.GetKustoManagedPrivateEndpoints(); - // invoke the operation - string managedPrivateEndpointName = "managedPrivateEndpointTest"; - bool result = await collection.ExistsAsync(managedPrivateEndpointName); + // invoke the operation and iterate over the result + await foreach (KustoManagedPrivateEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoManagedPrivateEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoManagedPrivateEndpointsGet() + public async Task Exists_KustoManagedPrivateEndpointsGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsGet.json // this example is just showing the usage of "ManagedPrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +151,17 @@ public async Task GetIfExists_KustoManagedPrivateEndpointsGet() // invoke the operation string managedPrivateEndpointName = "managedPrivateEndpointTest"; - NullableResponse response = await collection.GetIfExistsAsync(managedPrivateEndpointName); - KustoManagedPrivateEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(managedPrivateEndpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoManagedPrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoManagedPrivateEndpointsCreateOrUpdate() + public async Task GetIfExists_KustoManagedPrivateEndpointsGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsCreateOrUpdate.json - // this example is just showing the usage of "ManagedPrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsGet.json + // this example is just showing the usage of "ManagedPrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,20 +181,21 @@ public async Task CreateOrUpdate_KustoManagedPrivateEndpointsCreateOrUpdate() // invoke the operation string managedPrivateEndpointName = "managedPrivateEndpointTest"; - KustoManagedPrivateEndpointData data = new KustoManagedPrivateEndpointData() - { - PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/storageAccountTest"), - GroupId = "blob", - RequestMessage = "Please Approve.", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedPrivateEndpointName, data); - KustoManagedPrivateEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(managedPrivateEndpointName); + KustoManagedPrivateEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoManagedPrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoManagedPrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoManagedPrivateEndpointResource.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoManagedPrivateEndpointResource.cs index a3d495ffb622f..1912da6689aa6 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoManagedPrivateEndpointResource.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoManagedPrivateEndpointResource.cs @@ -48,10 +48,10 @@ public async Task Get_KustoManagedPrivateEndpointsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoManagedPrivateEndpointsUpdate() + public async Task Delete_ManagedPrivateEndpointsDelete() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsUpdate.json - // this example is just showing the usage of "ManagedPrivateEndpoints_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsDelete.json + // this example is just showing the usage of "ManagedPrivateEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,28 +68,17 @@ public async Task Update_KustoManagedPrivateEndpointsUpdate() KustoManagedPrivateEndpointResource kustoManagedPrivateEndpoint = client.GetKustoManagedPrivateEndpointResource(kustoManagedPrivateEndpointResourceId); // invoke the operation - KustoManagedPrivateEndpointData data = new KustoManagedPrivateEndpointData() - { - PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/storageAccountTest"), - GroupId = "blob", - RequestMessage = "Please Approve Managed Private Endpoint Request.", - }; - ArmOperation lro = await kustoManagedPrivateEndpoint.UpdateAsync(WaitUntil.Completed, data); - KustoManagedPrivateEndpointResource result = lro.Value; + await kustoManagedPrivateEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoManagedPrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ManagedPrivateEndpointsDelete() + public async Task Update_KustoManagedPrivateEndpointsUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsDelete.json - // this example is just showing the usage of "ManagedPrivateEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoManagedPrivateEndpointsUpdate.json + // this example is just showing the usage of "ManagedPrivateEndpoints_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +95,20 @@ public async Task Delete_ManagedPrivateEndpointsDelete() KustoManagedPrivateEndpointResource kustoManagedPrivateEndpoint = client.GetKustoManagedPrivateEndpointResource(kustoManagedPrivateEndpointResourceId); // invoke the operation - await kustoManagedPrivateEndpoint.DeleteAsync(WaitUntil.Completed); + KustoManagedPrivateEndpointData data = new KustoManagedPrivateEndpointData + { + PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.Storage/storageAccounts/storageAccountTest"), + GroupId = "blob", + RequestMessage = "Please Approve Managed Private Endpoint Request.", + }; + ArmOperation lro = await kustoManagedPrivateEndpoint.UpdateAsync(WaitUntil.Completed, data); + KustoManagedPrivateEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoManagedPrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateEndpointConnectionCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateEndpointConnectionCollection.cs index 178d570956618..967d2bff4c30d 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateEndpointConnectionCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_KustoPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoPrivateEndpointConnectionsList() + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsList.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsCreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,31 @@ public async Task GetAll_KustoPrivateEndpointConnectionsList() // for more information of creating KustoClusterResource, please refer to the document of KustoClusterResource string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; - string clusterName = "kustoCluster"; + string clusterName = "kustoclusterrptest4"; ResourceIdentifier kustoClusterResourceId = KustoClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); KustoClusterResource kustoCluster = client.GetKustoClusterResource(kustoClusterResourceId); // get the collection of this KustoPrivateEndpointConnectionResource KustoPrivateEndpointConnectionCollection collection = kustoCluster.GetKustoPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (KustoPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "privateEndpointTest"; + KustoPrivateEndpointConnectionData data = new KustoPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new KustoPrivateLinkServiceConnectionStateProperty + { + Status = "Approved", + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + KustoPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task GetAll_KustoPrivateEndpointConnectionsList() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsList.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_GetsPrivateEndpointConnection() // get the collection of this KustoPrivateEndpointConnectionResource KustoPrivateEndpointConnectionCollection collection = kustoCluster.GetKustoPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "privateEndpointTest"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (KustoPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task Exists_GetsPrivateEndpointConnection() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "privateEndpointTest"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - KustoPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsCreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,7 +175,7 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // for more information of creating KustoClusterResource, please refer to the document of KustoClusterResource string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; - string clusterName = "kustoclusterrptest4"; + string clusterName = "kustoCluster"; ResourceIdentifier kustoClusterResourceId = KustoClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName); KustoClusterResource kustoCluster = client.GetKustoClusterResource(kustoClusterResourceId); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // invoke the operation string privateEndpointConnectionName = "privateEndpointTest"; - KustoPrivateEndpointConnectionData data = new KustoPrivateEndpointConnectionData() - { - ConnectionState = new KustoPrivateLinkServiceConnectionStateProperty() - { - Status = "Approved", - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - KustoPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + KustoPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateEndpointConnectionResource.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateEndpointConnectionResource.cs index fc055de9e56de..24724f97a2a8d 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateEndpointConnectionResource.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsCreateOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsDelete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,36 +63,23 @@ public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName // for more information of creating KustoPrivateEndpointConnectionResource, please refer to the document of KustoPrivateEndpointConnectionResource string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; - string clusterName = "kustoclusterrptest4"; + string clusterName = "kustoCluster"; string privateEndpointConnectionName = "privateEndpointTest"; ResourceIdentifier kustoPrivateEndpointConnectionResourceId = KustoPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, privateEndpointConnectionName); KustoPrivateEndpointConnectionResource kustoPrivateEndpointConnection = client.GetKustoPrivateEndpointConnectionResource(kustoPrivateEndpointConnectionResourceId); // invoke the operation - KustoPrivateEndpointConnectionData data = new KustoPrivateEndpointConnectionData() - { - ConnectionState = new KustoPrivateLinkServiceConnectionStateProperty() - { - Status = "Approved", - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await kustoPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - KustoPrivateEndpointConnectionResource result = lro.Value; + await kustoPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsDelete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateEndpointConnectionsCreateOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,15 +90,28 @@ public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() // for more information of creating KustoPrivateEndpointConnectionResource, please refer to the document of KustoPrivateEndpointConnectionResource string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; - string clusterName = "kustoCluster"; + string clusterName = "kustoclusterrptest4"; string privateEndpointConnectionName = "privateEndpointTest"; ResourceIdentifier kustoPrivateEndpointConnectionResourceId = KustoPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, privateEndpointConnectionName); KustoPrivateEndpointConnectionResource kustoPrivateEndpointConnection = client.GetKustoPrivateEndpointConnectionResource(kustoPrivateEndpointConnectionResourceId); // invoke the operation - await kustoPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + KustoPrivateEndpointConnectionData data = new KustoPrivateEndpointConnectionData + { + ConnectionState = new KustoPrivateLinkServiceConnectionStateProperty + { + Status = "Approved", + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await kustoPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + KustoPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateLinkResourceCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateLinkResourceCollection.cs index 7270ff9590e76..240c723dd5086 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateLinkResourceCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_KustoPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateEndpointConnections() + public async Task Get_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateLinkResourcesList.json - // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateLinkResourcesGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetsPrivateEndpointConnections() // get the collection of this KustoPrivateLinkResource KustoPrivateLinkResourceCollection collection = kustoCluster.GetKustoPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (KustoPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string privateLinkResourceName = "cluster"; + KustoPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateEndpointConnection() + public async Task GetAll_GetsPrivateEndpointConnections() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateLinkResourcesGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoPrivateLinkResourcesList.json + // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsPrivateEndpointConnection() // get the collection of this KustoPrivateLinkResource KustoPrivateLinkResourceCollection collection = kustoCluster.GetKustoPrivateLinkResources(); - // invoke the operation - string privateLinkResourceName = "cluster"; - KustoPrivateLinkResource result = await collection.GetAsync(privateLinkResourceName); + // invoke the operation and iterate over the result + await foreach (KustoPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoScriptCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoScriptCollection.cs index c94c4c55dc872..824a684710d47 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoScriptCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoScriptCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_KustoScriptCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoScriptsList() + public async Task CreateOrUpdate_KustoScriptsCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsListByDatabase.json - // this example is just showing the usage of "Scripts_ListByDatabase" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsCreateOrUpdate.json + // this example is just showing the usage of "Scripts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +32,30 @@ public async Task GetAll_KustoScriptsList() string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; string clusterName = "kustoCluster"; - string databaseName = "Kustodatabase8"; + string databaseName = "KustoDatabase8"; ResourceIdentifier kustoDatabaseResourceId = KustoDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName); KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); // get the collection of this KustoScriptResource KustoScriptCollection collection = kustoDatabase.GetKustoScripts(); - // invoke the operation and iterate over the result - await foreach (KustoScriptResource item in collection.GetAllAsync()) + // invoke the operation + string scriptName = "kustoScript"; + KustoScriptData data = new KustoScriptData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoScriptData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ScriptUri = new Uri("https://mysa.blob.core.windows.net/container/script.txt"), + ScriptUriSasToken = "?sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=********************************", + ForceUpdateTag = "2bcf3c21-ffd1-4444-b9dd-e52e00ee53fe", + ShouldContinueOnErrors = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scriptName, data); + KustoScriptResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoScriptData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +95,10 @@ public async Task Get_KustoScriptsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoScriptsGet() + public async Task GetAll_KustoScriptsList() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsGet.json - // this example is just showing the usage of "Scripts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsListByDatabase.json + // this example is just showing the usage of "Scripts_ListByDatabase" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +117,22 @@ public async Task Exists_KustoScriptsGet() // get the collection of this KustoScriptResource KustoScriptCollection collection = kustoDatabase.GetKustoScripts(); - // invoke the operation - string scriptName = "kustoScript"; - bool result = await collection.ExistsAsync(scriptName); + // invoke the operation and iterate over the result + await foreach (KustoScriptResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoScriptData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoScriptsGet() + public async Task Exists_KustoScriptsGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsGet.json // this example is just showing the usage of "Scripts_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +156,17 @@ public async Task GetIfExists_KustoScriptsGet() // invoke the operation string scriptName = "kustoScript"; - NullableResponse response = await collection.GetIfExistsAsync(scriptName); - KustoScriptResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(scriptName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoScriptData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoScriptsCreateOrUpdate() + public async Task GetIfExists_KustoScriptsGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsCreateOrUpdate.json - // this example is just showing the usage of "Scripts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsGet.json + // this example is just showing the usage of "Scripts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,7 +178,7 @@ public async Task CreateOrUpdate_KustoScriptsCreateOrUpdate() string subscriptionId = "12345678-1234-1234-1234-123456789098"; string resourceGroupName = "kustorptest"; string clusterName = "kustoCluster"; - string databaseName = "KustoDatabase8"; + string databaseName = "Kustodatabase8"; ResourceIdentifier kustoDatabaseResourceId = KustoDatabaseResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, clusterName, databaseName); KustoDatabaseResource kustoDatabase = client.GetKustoDatabaseResource(kustoDatabaseResourceId); @@ -187,21 +187,21 @@ public async Task CreateOrUpdate_KustoScriptsCreateOrUpdate() // invoke the operation string scriptName = "kustoScript"; - KustoScriptData data = new KustoScriptData() - { - ScriptUri = new Uri("https://mysa.blob.core.windows.net/container/script.txt"), - ScriptUriSasToken = "?sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=********************************", - ForceUpdateTag = "2bcf3c21-ffd1-4444-b9dd-e52e00ee53fe", - ShouldContinueOnErrors = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scriptName, data); - KustoScriptResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(scriptName); + KustoScriptResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoScriptData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoScriptData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoScriptResource.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoScriptResource.cs index 4602a28d00fc2..7d2200deb9c77 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoScriptResource.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_KustoScriptResource.cs @@ -49,10 +49,10 @@ public async Task Get_KustoScriptsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoScriptsUpdate() + public async Task Delete_KustoScriptsDelete() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsUpdate.json - // this example is just showing the usage of "Scripts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsDelete.json + // this example is just showing the usage of "Scripts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,29 +70,17 @@ public async Task Update_KustoScriptsUpdate() KustoScriptResource kustoScript = client.GetKustoScriptResource(kustoScriptResourceId); // invoke the operation - KustoScriptData data = new KustoScriptData() - { - ScriptUri = new Uri("https://mysa.blob.core.windows.net/container/script.txt"), - ScriptUriSasToken = "?sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=********************************", - ForceUpdateTag = "2bcf3c21-ffd1-4444-b9dd-e52e00ee53fe", - ShouldContinueOnErrors = true, - }; - ArmOperation lro = await kustoScript.UpdateAsync(WaitUntil.Completed, data); - KustoScriptResource result = lro.Value; + await kustoScript.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - KustoScriptData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_KustoScriptsDelete() + public async Task Update_KustoScriptsUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsDelete.json - // this example is just showing the usage of "Scripts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoScriptsUpdate.json + // this example is just showing the usage of "Scripts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +98,21 @@ public async Task Delete_KustoScriptsDelete() KustoScriptResource kustoScript = client.GetKustoScriptResource(kustoScriptResourceId); // invoke the operation - await kustoScript.DeleteAsync(WaitUntil.Completed); + KustoScriptData data = new KustoScriptData + { + ScriptUri = new Uri("https://mysa.blob.core.windows.net/container/script.txt"), + ScriptUriSasToken = "?sv=2019-02-02&st=2019-04-29T22%3A18%3A26Z&se=2019-04-30T02%3A23%3A26Z&sr=b&sp=rw&sip=168.1.5.60-168.1.5.70&spr=https&sig=********************************", + ForceUpdateTag = "2bcf3c21-ffd1-4444-b9dd-e52e00ee53fe", + ShouldContinueOnErrors = true, + }; + ArmOperation lro = await kustoScript.UpdateAsync(WaitUntil.Completed, data); + KustoScriptResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoScriptData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SandboxCustomImageCollection.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SandboxCustomImageCollection.cs index 7abe1e7d5e599..3746de04a3b06 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SandboxCustomImageCollection.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SandboxCustomImageCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SandboxCustomImageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_KustoSandboxCustomImagesListByCluster() + public async Task CreateOrUpdate_KustoSandboxCustomImagesCreateOrUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesList.json - // this example is just showing the usage of "SandboxCustomImages_ListByCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesCreateOrUpdate.json + // this example is just showing the usage of "SandboxCustomImages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,22 @@ public async Task GetAll_KustoSandboxCustomImagesListByCluster() // get the collection of this SandboxCustomImageResource SandboxCustomImageCollection collection = kustoCluster.GetSandboxCustomImages(); - // invoke the operation and iterate over the result - await foreach (SandboxCustomImageResource item in collection.GetAllAsync()) + // invoke the operation + string sandboxCustomImageName = "customImage8"; + SandboxCustomImageData data = new SandboxCustomImageData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SandboxCustomImageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Language = SandboxCustomImageLanguage.Python, + LanguageVersion = "3.10.8", + RequirementsFileContent = "Requests", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sandboxCustomImageName, data); + SandboxCustomImageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SandboxCustomImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +93,10 @@ public async Task Get_KustoSandboxCustomImagesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_KustoSandboxCustomImagesGet() + public async Task GetAll_KustoSandboxCustomImagesListByCluster() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesGet.json - // this example is just showing the usage of "SandboxCustomImages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesList.json + // this example is just showing the usage of "SandboxCustomImages_ListByCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +114,22 @@ public async Task Exists_KustoSandboxCustomImagesGet() // get the collection of this SandboxCustomImageResource SandboxCustomImageCollection collection = kustoCluster.GetSandboxCustomImages(); - // invoke the operation - string sandboxCustomImageName = "customImage8"; - bool result = await collection.ExistsAsync(sandboxCustomImageName); + // invoke the operation and iterate over the result + await foreach (SandboxCustomImageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SandboxCustomImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_KustoSandboxCustomImagesGet() + public async Task Exists_KustoSandboxCustomImagesGet() { // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesGet.json // this example is just showing the usage of "SandboxCustomImages_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +152,17 @@ public async Task GetIfExists_KustoSandboxCustomImagesGet() // invoke the operation string sandboxCustomImageName = "customImage8"; - NullableResponse response = await collection.GetIfExistsAsync(sandboxCustomImageName); - SandboxCustomImageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sandboxCustomImageName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SandboxCustomImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_KustoSandboxCustomImagesCreateOrUpdate() + public async Task GetIfExists_KustoSandboxCustomImagesGet() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesCreateOrUpdate.json - // this example is just showing the usage of "SandboxCustomImages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImagesGet.json + // this example is just showing the usage of "SandboxCustomImages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,20 +182,21 @@ public async Task CreateOrUpdate_KustoSandboxCustomImagesCreateOrUpdate() // invoke the operation string sandboxCustomImageName = "customImage8"; - SandboxCustomImageData data = new SandboxCustomImageData() - { - Language = SandboxCustomImageLanguage.Python, - LanguageVersion = "3.10.8", - RequirementsFileContent = "Requests", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sandboxCustomImageName, data); - SandboxCustomImageResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(sandboxCustomImageName); + SandboxCustomImageResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SandboxCustomImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SandboxCustomImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SandboxCustomImageResource.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SandboxCustomImageResource.cs index 89fbf1a5aeac3..65bffa4d6d388 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SandboxCustomImageResource.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SandboxCustomImageResource.cs @@ -49,10 +49,10 @@ public async Task Get_KustoSandboxCustomImagesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_KustoSandboxCustomImagesUpdate() + public async Task Delete_SandboxCustomImagesDelete() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImageUpdate.json - // this example is just showing the usage of "SandboxCustomImages_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImageDelete.json + // this example is just showing the usage of "SandboxCustomImages_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,28 +69,17 @@ public async Task Update_KustoSandboxCustomImagesUpdate() SandboxCustomImageResource sandboxCustomImage = client.GetSandboxCustomImageResource(sandboxCustomImageResourceId); // invoke the operation - SandboxCustomImageData data = new SandboxCustomImageData() - { - Language = SandboxCustomImageLanguage.Python, - LanguageVersion = "3.10.8", - RequirementsFileContent = "Requests", - }; - ArmOperation lro = await sandboxCustomImage.UpdateAsync(WaitUntil.Completed, data); - SandboxCustomImageResource result = lro.Value; + await sandboxCustomImage.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SandboxCustomImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SandboxCustomImagesDelete() + public async Task Update_KustoSandboxCustomImagesUpdate() { - // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImageDelete.json - // this example is just showing the usage of "SandboxCustomImages_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoSandboxCustomImageUpdate.json + // this example is just showing the usage of "SandboxCustomImages_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +96,20 @@ public async Task Delete_SandboxCustomImagesDelete() SandboxCustomImageResource sandboxCustomImage = client.GetSandboxCustomImageResource(sandboxCustomImageResourceId); // invoke the operation - await sandboxCustomImage.DeleteAsync(WaitUntil.Completed); + SandboxCustomImageData data = new SandboxCustomImageData + { + Language = SandboxCustomImageLanguage.Python, + LanguageVersion = "3.10.8", + RequirementsFileContent = "Requests", + }; + ArmOperation lro = await sandboxCustomImage.UpdateAsync(WaitUntil.Completed, data); + SandboxCustomImageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SandboxCustomImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 6c69358e552f8..ad9021eb3a226 100644 --- a/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/kusto/Azure.ResourceManager.Kusto/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,90 @@ namespace Azure.ResourceManager.Kusto.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetKustoClusters_KustoClustersList() + { + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersList.json + // this example is just showing the usage of "Clusters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "12345678-1234-1234-1234-123456789098"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (KustoClusterResource item in subscriptionResource.GetKustoClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + KustoClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetKustoEligibleSkus_KustoClustersListSkus() + { + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersListSkus.json + // this example is just showing the usage of "Clusters_ListSkus" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "12345678-1234-1234-1234-123456789098"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (KustoSkuDescription item in subscriptionResource.GetKustoEligibleSkusAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckKustoClusterNameAvailability_KustoClustersCheckNameAvailability() + { + // Generated from example definition: specification/azure-kusto/resource-manager/Microsoft.Kusto/stable/2023-08-15/examples/KustoClustersCheckNameAvailability.json + // this example is just showing the usage of "Clusters_CheckNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "12345678-1234-1234-1234-123456789098"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("westus"); + KustoClusterNameAvailabilityContent content = new KustoClusterNameAvailabilityContent("kustoCluster"); + KustoNameAvailabilityResult result = await subscriptionResource.CheckKustoClusterNameAvailabilityAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetSkus_KustoListRegionSkus() diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabCollection.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabCollection.cs index 2d6eeaabdd35d..100197d485212 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabCollection.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_LabCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListResourceGroupLabs() + public async Task CreateOrUpdate_PutLab() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/listResourceGroupLabs.json - // this example is just showing the usage of "Labs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/putLab.json + // this example is just showing the usage of "Labs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,57 @@ public async Task GetAll_ListResourceGroupLabs() // get the collection of this LabResource LabCollection collection = resourceGroupResource.GetLabs(); - // invoke the operation and iterate over the result - await foreach (LabResource item in collection.GetAllAsync()) + // invoke the operation + string labName = "testlab"; + LabData data = new LabData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AutoShutdownProfile = new LabAutoShutdownProfile + { + ShutdownOnDisconnect = LabServicesEnableState.Enabled, + ShutdownWhenNotConnected = LabServicesEnableState.Enabled, + ShutdownOnIdle = LabVirtualMachineShutdownOnIdleMode.UserAbsence, + DisconnectDelay = XmlConvert.ToTimeSpan("PT5M"), + NoConnectDelay = XmlConvert.ToTimeSpan("PT5M"), + IdleDelay = XmlConvert.ToTimeSpan("PT5M"), + }, + ConnectionProfile = new LabConnectionProfile + { + WebSshAccess = LabVirtualMachineConnectionType.None, + WebRdpAccess = LabVirtualMachineConnectionType.None, + ClientSshAccess = LabVirtualMachineConnectionType.Public, + ClientRdpAccess = LabVirtualMachineConnectionType.Public, + }, + VirtualMachineProfile = new LabVirtualMachineProfile(LabVirtualMachineCreateOption.TemplateVm, new LabVirtualMachineImageReference + { + Offer = "WindowsServer", + Publisher = "Microsoft", + Sku = "2019-Datacenter", + Version = "2019.0.20190410", + }, new LabServicesSku("Medium"), XmlConvert.ToTimeSpan("PT10H"), new LabVirtualMachineCredential("test-user")) + { + AdditionalCapabilitiesInstallGpuDrivers = LabServicesEnableState.Disabled, + UseSharedPassword = LabServicesEnableState.Disabled, + }, + SecurityProfile = new LabSecurityProfile + { + OpenAccess = LabServicesEnableState.Disabled, + }, + LabPlanId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.LabServices/labPlans/testlabplan"), + Title = "Test Lab", + Description = "This is a test lab.", + NetworkProfile = new LabNetworkProfile + { + SubnetId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/default"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, labName, data); + LabResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +128,10 @@ public async Task Get_GetLab() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetLab() + public async Task GetAll_ListResourceGroupLabs() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/getLab.json - // this example is just showing the usage of "Labs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/listResourceGroupLabs.json + // this example is just showing the usage of "Labs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +148,22 @@ public async Task Exists_GetLab() // get the collection of this LabResource LabCollection collection = resourceGroupResource.GetLabs(); - // invoke the operation - string labName = "testlab"; - bool result = await collection.ExistsAsync(labName); + // invoke the operation and iterate over the result + await foreach (LabResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetLab() + public async Task Exists_GetLab() { // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/getLab.json // this example is just showing the usage of "Labs_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +185,17 @@ public async Task GetIfExists_GetLab() // invoke the operation string labName = "testlab"; - NullableResponse response = await collection.GetIfExistsAsync(labName); - LabResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(labName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutLab() + public async Task GetIfExists_GetLab() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/putLab.json - // this example is just showing the usage of "Labs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/getLab.json + // this example is just showing the usage of "Labs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,55 +214,21 @@ public async Task CreateOrUpdate_PutLab() // invoke the operation string labName = "testlab"; - LabData data = new LabData(new AzureLocation("westus")) - { - AutoShutdownProfile = new LabAutoShutdownProfile() - { - ShutdownOnDisconnect = LabServicesEnableState.Enabled, - ShutdownWhenNotConnected = LabServicesEnableState.Enabled, - ShutdownOnIdle = LabVirtualMachineShutdownOnIdleMode.UserAbsence, - DisconnectDelay = XmlConvert.ToTimeSpan("PT5M"), - NoConnectDelay = XmlConvert.ToTimeSpan("PT5M"), - IdleDelay = XmlConvert.ToTimeSpan("PT5M"), - }, - ConnectionProfile = new LabConnectionProfile() - { - WebSshAccess = LabVirtualMachineConnectionType.None, - WebRdpAccess = LabVirtualMachineConnectionType.None, - ClientSshAccess = LabVirtualMachineConnectionType.Public, - ClientRdpAccess = LabVirtualMachineConnectionType.Public, - }, - VirtualMachineProfile = new LabVirtualMachineProfile(LabVirtualMachineCreateOption.TemplateVm, new LabVirtualMachineImageReference() - { - Offer = "WindowsServer", - Publisher = "Microsoft", - Sku = "2019-Datacenter", - Version = "2019.0.20190410", - }, new LabServicesSku("Medium"), XmlConvert.ToTimeSpan("PT10H"), new LabVirtualMachineCredential("test-user")) - { - AdditionalCapabilitiesInstallGpuDrivers = LabServicesEnableState.Disabled, - UseSharedPassword = LabServicesEnableState.Disabled, - }, - SecurityProfile = new LabSecurityProfile() - { - OpenAccess = LabServicesEnableState.Disabled, - }, - LabPlanId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.LabServices/labPlans/testlabplan"), - Title = "Test Lab", - Description = "This is a test lab.", - NetworkProfile = new LabNetworkProfile() - { - SubnetId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/default"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, labName, data); - LabResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(labName); + LabResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabPlanCollection.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabPlanCollection.cs index 916eee1e911ec..51d8d1a765c0b 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabPlanCollection.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabPlanCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_LabPlanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListResourceGroupLabPlans() + public async Task CreateOrUpdate_PutLabPlan() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/listResourceGroupLabPlans.json - // this example is just showing the usage of "LabPlans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/putLabPlan.json + // this example is just showing the usage of "LabPlans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,44 @@ public async Task GetAll_ListResourceGroupLabPlans() // get the collection of this LabPlanResource LabPlanCollection collection = resourceGroupResource.GetLabPlans(); - // invoke the operation and iterate over the result - await foreach (LabPlanResource item in collection.GetAllAsync()) + // invoke the operation + string labPlanName = "testlabplan"; + LabPlanData data = new LabPlanData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabPlanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DefaultConnectionProfile = new LabConnectionProfile + { + WebSshAccess = LabVirtualMachineConnectionType.None, + WebRdpAccess = LabVirtualMachineConnectionType.None, + ClientSshAccess = LabVirtualMachineConnectionType.Public, + ClientRdpAccess = LabVirtualMachineConnectionType.Public, + }, + DefaultAutoShutdownProfile = new LabAutoShutdownProfile + { + ShutdownOnDisconnect = LabServicesEnableState.Enabled, + ShutdownWhenNotConnected = LabServicesEnableState.Enabled, + ShutdownOnIdle = LabVirtualMachineShutdownOnIdleMode.UserAbsence, + DisconnectDelay = XmlConvert.ToTimeSpan("PT5M"), + NoConnectDelay = XmlConvert.ToTimeSpan("PT5M"), + IdleDelay = XmlConvert.ToTimeSpan("PT5M"), + }, + DefaultNetworkSubnetId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/default"), + SharedGalleryId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Compute/galleries/testsig"), + SupportInfo = new LabPlanSupportInfo + { + Uri = new Uri("help.contoso.com"), + Email = "help@contoso.com", + Phone = "+1-202-555-0123", + Instructions = "Contact support for help.", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, labPlanName, data); + LabPlanResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +115,10 @@ public async Task Get_GetLabPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetLabPlan() + public async Task GetAll_ListResourceGroupLabPlans() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/getLabPlan.json - // this example is just showing the usage of "LabPlans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/listResourceGroupLabPlans.json + // this example is just showing the usage of "LabPlans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +135,22 @@ public async Task Exists_GetLabPlan() // get the collection of this LabPlanResource LabPlanCollection collection = resourceGroupResource.GetLabPlans(); - // invoke the operation - string labPlanName = "testlabplan"; - bool result = await collection.ExistsAsync(labPlanName); + // invoke the operation and iterate over the result + await foreach (LabPlanResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabPlanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetLabPlan() + public async Task Exists_GetLabPlan() { // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/getLabPlan.json // this example is just showing the usage of "LabPlans_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +172,17 @@ public async Task GetIfExists_GetLabPlan() // invoke the operation string labPlanName = "testlabplan"; - NullableResponse response = await collection.GetIfExistsAsync(labPlanName); - LabPlanResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(labPlanName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutLabPlan() + public async Task GetIfExists_GetLabPlan() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/putLabPlan.json - // this example is just showing the usage of "LabPlans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/getLabPlan.json + // this example is just showing the usage of "LabPlans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,42 +201,21 @@ public async Task CreateOrUpdate_PutLabPlan() // invoke the operation string labPlanName = "testlabplan"; - LabPlanData data = new LabPlanData(new AzureLocation("westus")) - { - DefaultConnectionProfile = new LabConnectionProfile() - { - WebSshAccess = LabVirtualMachineConnectionType.None, - WebRdpAccess = LabVirtualMachineConnectionType.None, - ClientSshAccess = LabVirtualMachineConnectionType.Public, - ClientRdpAccess = LabVirtualMachineConnectionType.Public, - }, - DefaultAutoShutdownProfile = new LabAutoShutdownProfile() - { - ShutdownOnDisconnect = LabServicesEnableState.Enabled, - ShutdownWhenNotConnected = LabServicesEnableState.Enabled, - ShutdownOnIdle = LabVirtualMachineShutdownOnIdleMode.UserAbsence, - DisconnectDelay = XmlConvert.ToTimeSpan("PT5M"), - NoConnectDelay = XmlConvert.ToTimeSpan("PT5M"), - IdleDelay = XmlConvert.ToTimeSpan("PT5M"), - }, - DefaultNetworkSubnetId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Network/virtualNetworks/test-vnet/subnets/default"), - SharedGalleryId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Compute/galleries/testsig"), - SupportInfo = new LabPlanSupportInfo() - { - Uri = new Uri("help.contoso.com"), - Email = "help@contoso.com", - Phone = "+1-202-555-0123", - Instructions = "Contact support for help.", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, labPlanName, data); - LabPlanResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(labPlanName); + LabPlanResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabPlanResource.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabPlanResource.cs index cf5902b0093ae..a3e160cf0bfd8 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabPlanResource.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabPlanResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.LabServices.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.LabServices.Samples @@ -19,41 +18,40 @@ public partial class Sample_LabPlanResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLabPlans_ListLabPlans() + public async Task Get_GetLabPlan() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/listLabPlans.json - // this example is just showing the usage of "LabPlans_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/getLabPlan.json + // this example is just showing the usage of "LabPlans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this LabPlanResource created on azure + // for more information of creating LabPlanResource, please refer to the document of LabPlanResource string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "testrg123"; + string labPlanName = "testlabplan"; + ResourceIdentifier labPlanResourceId = LabPlanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, labPlanName); + LabPlanResource labPlan = client.GetLabPlanResource(labPlanResourceId); - // invoke the operation and iterate over the result - await foreach (LabPlanResource item in subscriptionResource.GetLabPlansAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabPlanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + LabPlanResource result = await labPlan.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetLabPlan() + public async Task Delete_DeleteLabPlan() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/getLabPlan.json - // this example is just showing the usage of "LabPlans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/deleteLabPlan.json + // this example is just showing the usage of "LabPlans_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,13 +67,9 @@ public async Task Get_GetLabPlan() LabPlanResource labPlan = client.GetLabPlanResource(labPlanResourceId); // invoke the operation - LabPlanResource result = await labPlan.GetAsync(); + await labPlan.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,9 +93,9 @@ public async Task Update_PatchLabPlan() LabPlanResource labPlan = client.GetLabPlanResource(labPlanResourceId); // invoke the operation - LabPlanPatch patch = new LabPlanPatch() + LabPlanPatch patch = new LabPlanPatch { - DefaultConnectionProfile = new LabConnectionProfile() + DefaultConnectionProfile = new LabConnectionProfile { WebSshAccess = LabVirtualMachineConnectionType.None, WebRdpAccess = LabVirtualMachineConnectionType.None, @@ -119,32 +113,6 @@ public async Task Update_PatchLabPlan() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteLabPlan() - { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/deleteLabPlan.json - // this example is just showing the usage of "LabPlans_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this LabPlanResource created on azure - // for more information of creating LabPlanResource, please refer to the document of LabPlanResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "testrg123"; - string labPlanName = "testlabplan"; - ResourceIdentifier labPlanResourceId = LabPlanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, labPlanName); - LabPlanResource labPlan = client.GetLabPlanResource(labPlanResourceId); - - // invoke the operation - await labPlan.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task SaveImage_SaveImageVirtualMachine() @@ -166,7 +134,7 @@ public async Task SaveImage_SaveImageVirtualMachine() LabPlanResource labPlan = client.GetLabPlanResource(labPlanResourceId); // invoke the operation - LabVirtualMachineImageContent content = new LabVirtualMachineImageContent() + LabVirtualMachineImageContent content = new LabVirtualMachineImageContent { Name = "Test Image", LabVirtualMachineId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.LabServices/labs/testlab/virtualMachines/template"), diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabResource.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabResource.cs index 5c6f36f4ddeda..e0a38b0afef45 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabResource.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.LabServices.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.LabServices.Samples { public partial class Sample_LabResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetLabs_ListLabs() - { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/listLabs.json - // this example is just showing the usage of "Labs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (LabResource item in subscriptionResource.GetLabsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetLab() @@ -80,10 +48,10 @@ public async Task Get_GetLab() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchLab() + public async Task Delete_DeleteLab() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/patchLab.json - // this example is just showing the usage of "Labs_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/deleteLab.json + // this example is just showing the usage of "Labs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,29 +67,17 @@ public async Task Update_PatchLab() LabResource lab = client.GetLabResource(labResourceId); // invoke the operation - LabPatch patch = new LabPatch() - { - SecurityProfile = new LabSecurityProfile() - { - OpenAccess = LabServicesEnableState.Enabled, - }, - }; - ArmOperation lro = await lab.UpdateAsync(WaitUntil.Completed, patch); - LabResource result = lro.Value; + await lab.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteLab() + public async Task Update_PatchLab() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/deleteLab.json - // this example is just showing the usage of "Labs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/patchLab.json + // this example is just showing the usage of "Labs_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,9 +93,21 @@ public async Task Delete_DeleteLab() LabResource lab = client.GetLabResource(labResourceId); // invoke the operation - await lab.DeleteAsync(WaitUntil.Completed); + LabPatch patch = new LabPatch + { + SecurityProfile = new LabSecurityProfile + { + OpenAccess = LabServicesEnableState.Enabled, + }, + }; + ArmOperation lro = await lab.UpdateAsync(WaitUntil.Completed, patch); + LabResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabServicesScheduleCollection.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabServicesScheduleCollection.cs index 596df5e2b5940..9f42ad8771c23 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabServicesScheduleCollection.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabServicesScheduleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LabServicesScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetListSchedule() + public async Task CreateOrUpdate_PutSchedule() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/listSchedule.json - // this example is just showing the usage of "Schedules_ListByLab" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/putSchedule.json + // this example is just showing the usage of "Schedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,27 @@ public async Task GetAll_GetListSchedule() // get the collection of this LabServicesScheduleResource LabServicesScheduleCollection collection = lab.GetLabServicesSchedules(); - // invoke the operation and iterate over the result - await foreach (LabServicesScheduleResource item in collection.GetAllAsync()) + // invoke the operation + string scheduleName = "schedule1"; + LabServicesScheduleData data = new LabServicesScheduleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabServicesScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StartOn = DateTimeOffset.Parse("2020-05-26T12:00:00Z"), + StopOn = DateTimeOffset.Parse("2020-05-26T18:00:00Z"), + RecurrencePattern = new LabServicesRecurrencePattern(LabServicesRecurrenceFrequency.Daily, DateTimeOffset.Parse("2020-08-14T23:59:59Z")) + { + Interval = 2, + }, + TimeZoneId = "America/Los_Angeles", + Notes = BinaryData.FromObjectAsJson("Schedule 1 for students"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scheduleName, data); + LabServicesScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabServicesScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +98,10 @@ public async Task Get_GetSchedule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSchedule() + public async Task GetAll_GetListSchedule() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/getSchedule.json - // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/listSchedule.json + // this example is just showing the usage of "Schedules_ListByLab" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +119,22 @@ public async Task Exists_GetSchedule() // get the collection of this LabServicesScheduleResource LabServicesScheduleCollection collection = lab.GetLabServicesSchedules(); - // invoke the operation - string scheduleName = "schedule1"; - bool result = await collection.ExistsAsync(scheduleName); + // invoke the operation and iterate over the result + await foreach (LabServicesScheduleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabServicesScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSchedule() + public async Task Exists_GetSchedule() { // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/getSchedule.json // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +157,17 @@ public async Task GetIfExists_GetSchedule() // invoke the operation string scheduleName = "schedule1"; - NullableResponse response = await collection.GetIfExistsAsync(scheduleName); - LabServicesScheduleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(scheduleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabServicesScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutSchedule() + public async Task GetIfExists_GetSchedule() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/putSchedule.json - // this example is just showing the usage of "Schedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/getSchedule.json + // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,25 +187,21 @@ public async Task CreateOrUpdate_PutSchedule() // invoke the operation string scheduleName = "schedule1"; - LabServicesScheduleData data = new LabServicesScheduleData() - { - StartOn = DateTimeOffset.Parse("2020-05-26T12:00:00Z"), - StopOn = DateTimeOffset.Parse("2020-05-26T18:00:00Z"), - RecurrencePattern = new LabServicesRecurrencePattern(LabServicesRecurrenceFrequency.Daily, DateTimeOffset.Parse("2020-08-14T23:59:59Z")) - { - Interval = 2, - }, - TimeZoneId = "America/Los_Angeles", - Notes = BinaryData.FromString("\"Schedule 1 for students\""), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scheduleName, data); - LabServicesScheduleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(scheduleName); + LabServicesScheduleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabServicesScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabServicesScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabServicesScheduleResource.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabServicesScheduleResource.cs index 8f0c4e0f1dc88..be2ec1448807b 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabServicesScheduleResource.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabServicesScheduleResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetSchedule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchSchedule() + public async Task Delete_DeleteSchedule() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/patchSchedule.json - // this example is just showing the usage of "Schedules_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/deleteSchedule.json + // this example is just showing the usage of "Schedules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,28 +69,17 @@ public async Task Update_PatchSchedule() LabServicesScheduleResource labServicesSchedule = client.GetLabServicesScheduleResource(labServicesScheduleResourceId); // invoke the operation - LabServicesSchedulePatch patch = new LabServicesSchedulePatch() - { - RecurrencePattern = new LabServicesRecurrencePattern(LabServicesRecurrenceFrequency.Daily, DateTimeOffset.Parse("2020-08-14T23:59:59Z")) - { - Interval = 2, - }, - }; - LabServicesScheduleResource result = await labServicesSchedule.UpdateAsync(patch); + await labServicesSchedule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabServicesScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSchedule() + public async Task Update_PatchSchedule() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/deleteSchedule.json - // this example is just showing the usage of "Schedules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Schedules/patchSchedule.json + // this example is just showing the usage of "Schedules_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +96,20 @@ public async Task Delete_DeleteSchedule() LabServicesScheduleResource labServicesSchedule = client.GetLabServicesScheduleResource(labServicesScheduleResourceId); // invoke the operation - await labServicesSchedule.DeleteAsync(WaitUntil.Completed); + LabServicesSchedulePatch patch = new LabServicesSchedulePatch + { + RecurrencePattern = new LabServicesRecurrencePattern(LabServicesRecurrenceFrequency.Daily, DateTimeOffset.Parse("2020-08-14T23:59:59Z")) + { + Interval = 2, + }, + }; + LabServicesScheduleResource result = await labServicesSchedule.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabServicesScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabUserCollection.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabUserCollection.cs index 087500cf1c483..6bbe224dd7f56 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabUserCollection.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabUserCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LabUserCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListUser() + public async Task CreateOrUpdate_PutUser() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/listUser.json - // this example is just showing the usage of "Users_ListByLab" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/putUser.json + // this example is just showing the usage of "Users_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ListUser() // get the collection of this LabUserResource LabUserCollection collection = lab.GetLabUsers(); - // invoke the operation and iterate over the result - await foreach (LabUserResource item in collection.GetAllAsync()) + // invoke the operation + string userName = "testuser"; + LabUserData data = new LabUserData("testuser@contoso.com") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabUserData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AdditionalUsageQuota = XmlConvert.ToTimeSpan("PT10H"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, userName, data); + LabUserResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_GetUser() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetUser() + public async Task GetAll_ListUser() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/getUser.json - // this example is just showing the usage of "Users_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/listUser.json + // this example is just showing the usage of "Users_ListByLab" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_GetUser() // get the collection of this LabUserResource LabUserCollection collection = lab.GetLabUsers(); - // invoke the operation - string userName = "testuser"; - bool result = await collection.ExistsAsync(userName); + // invoke the operation and iterate over the result + await foreach (LabUserResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabUserData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetUser() + public async Task Exists_GetUser() { // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/getUser.json // this example is just showing the usage of "Users_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_GetUser() // invoke the operation string userName = "testuser"; - NullableResponse response = await collection.GetIfExistsAsync(userName); - LabUserResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(userName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutUser() + public async Task GetIfExists_GetUser() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/putUser.json - // this example is just showing the usage of "Users_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/getUser.json + // this example is just showing the usage of "Users_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_PutUser() // invoke the operation string userName = "testuser"; - LabUserData data = new LabUserData("testuser@contoso.com") - { - AdditionalUsageQuota = XmlConvert.ToTimeSpan("PT10H"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, userName, data); - LabUserResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(userName); + LabUserResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabUserResource.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabUserResource.cs index 107bc0d230b1a..7111c614fe51a 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabUserResource.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabUserResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetUser() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchUser() + public async Task Delete_DeleteUser() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/patchUser.json - // this example is just showing the usage of "Users_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/deleteUser.json + // this example is just showing the usage of "Users_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,26 +70,17 @@ public async Task Update_PatchUser() LabUserResource labUser = client.GetLabUserResource(labUserResourceId); // invoke the operation - LabUserPatch patch = new LabUserPatch() - { - AdditionalUsageQuota = XmlConvert.ToTimeSpan("PT10H"), - }; - ArmOperation lro = await labUser.UpdateAsync(WaitUntil.Completed, patch); - LabUserResource result = lro.Value; + await labUser.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabUserData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteUser() + public async Task Update_PatchUser() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/deleteUser.json - // this example is just showing the usage of "Users_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Users/patchUser.json + // this example is just showing the usage of "Users_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +97,18 @@ public async Task Delete_DeleteUser() LabUserResource labUser = client.GetLabUserResource(labUserResourceId); // invoke the operation - await labUser.DeleteAsync(WaitUntil.Completed); + LabUserPatch patch = new LabUserPatch + { + AdditionalUsageQuota = XmlConvert.ToTimeSpan("PT10H"), + }; + ArmOperation lro = await labUser.UpdateAsync(WaitUntil.Completed, patch); + LabUserResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabUserData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -133,9 +133,9 @@ public async Task Invite_InviteUser() LabUserResource labUser = client.GetLabUserResource(labUserResourceId); // invoke the operation - LabUserInviteRequestContent content = new LabUserInviteRequestContent() + LabUserInviteRequestContent content = new LabUserInviteRequestContent { - Text = BinaryData.FromString("\"Invitation to lab testlab\""), + Text = BinaryData.FromObjectAsJson("Invitation to lab testlab"), }; await labUser.InviteAsync(WaitUntil.Completed, content); diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineCollection.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineCollection.cs index c85887b710e1a..9b7383e816913 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineCollection.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LabVirtualMachineCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualMachine() + public async Task Get_GetVirtualMachine() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/VirtualMachines/listVirtualMachine.json - // this example is just showing the usage of "VirtualMachines_ListByLab" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/VirtualMachines/getVirtualMachine.json + // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListVirtualMachine() // get the collection of this LabVirtualMachineResource LabVirtualMachineCollection collection = lab.GetLabVirtualMachines(); - // invoke the operation and iterate over the result - await foreach (LabVirtualMachineResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabVirtualMachineData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string virtualMachineName = "template"; + LabVirtualMachineResource result = await collection.GetAsync(virtualMachineName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabVirtualMachineData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualMachine() + public async Task GetAll_ListVirtualMachine() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/VirtualMachines/getVirtualMachine.json - // this example is just showing the usage of "VirtualMachines_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/VirtualMachines/listVirtualMachine.json + // this example is just showing the usage of "VirtualMachines_ListByLab" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetVirtualMachine() // get the collection of this LabVirtualMachineResource LabVirtualMachineCollection collection = lab.GetLabVirtualMachines(); - // invoke the operation - string virtualMachineName = "template"; - LabVirtualMachineResource result = await collection.GetAsync(virtualMachineName); + // invoke the operation and iterate over the result + await foreach (LabVirtualMachineResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabVirtualMachineData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabVirtualMachineData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineImageCollection.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineImageCollection.cs index 18bed3207405d..98485ef87c339 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineImageCollection.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineImageCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LabVirtualMachineImageCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListImages() + public async Task CreateOrUpdate_PutImage() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Images/listImages.json - // this example is just showing the usage of "Images_ListByLabPlan" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Images/putImage.json + // this example is just showing the usage of "Images_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ListImages() // get the collection of this LabVirtualMachineImageResource LabVirtualMachineImageCollection collection = labPlan.GetLabVirtualMachineImages(); - // invoke the operation and iterate over the result - await foreach (LabVirtualMachineImageResource item in collection.GetAllAsync()) + // invoke the operation + string imageName = "image1"; + LabVirtualMachineImageData data = new LabVirtualMachineImageData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabVirtualMachineImageData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EnabledState = LabServicesEnableState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, imageName, data); + LabVirtualMachineImageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabVirtualMachineImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_GetImage() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetImage() + public async Task GetAll_ListImages() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Images/getImage.json - // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Images/listImages.json + // this example is just showing the usage of "Images_ListByLabPlan" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_GetImage() // get the collection of this LabVirtualMachineImageResource LabVirtualMachineImageCollection collection = labPlan.GetLabVirtualMachineImages(); - // invoke the operation - string imageName = "image1"; - bool result = await collection.ExistsAsync(imageName); + // invoke the operation and iterate over the result + await foreach (LabVirtualMachineImageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabVirtualMachineImageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetImage() + public async Task Exists_GetImage() { // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Images/getImage.json // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_GetImage() // invoke the operation string imageName = "image1"; - NullableResponse response = await collection.GetIfExistsAsync(imageName); - LabVirtualMachineImageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(imageName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabVirtualMachineImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutImage() + public async Task GetIfExists_GetImage() { - // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Images/putImage.json - // this example is just showing the usage of "Images_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Images/getImage.json + // this example is just showing the usage of "Images_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_PutImage() // invoke the operation string imageName = "image1"; - LabVirtualMachineImageData data = new LabVirtualMachineImageData() - { - EnabledState = LabServicesEnableState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, imageName, data); - LabVirtualMachineImageResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(imageName); + LabVirtualMachineImageResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LabVirtualMachineImageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabVirtualMachineImageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineImageResource.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineImageResource.cs index 82a94f5c15af4..910511cb2179b 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineImageResource.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_LabVirtualMachineImageResource.cs @@ -69,7 +69,7 @@ public async Task Update_PatchImage() LabVirtualMachineImageResource labVirtualMachineImage = client.GetLabVirtualMachineImageResource(labVirtualMachineImageResourceId); // invoke the operation - LabVirtualMachineImagePatch patch = new LabVirtualMachineImagePatch() + LabVirtualMachineImagePatch patch = new LabVirtualMachineImagePatch { EnabledState = LabServicesEnableState.Enabled, }; diff --git a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 63af3dd5b4940..58df1d63103b8 100644 --- a/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/labservices/Azure.ResourceManager.LabServices/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,68 @@ namespace Azure.ResourceManager.LabServices.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetLabPlans_ListLabPlans() + { + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/LabPlans/listLabPlans.json + // this example is just showing the usage of "LabPlans_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (LabPlanResource item in subscriptionResource.GetLabPlansAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabPlanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetLabs_ListLabs() + { + // Generated from example definition: specification/labservices/resource-manager/Microsoft.LabServices/stable/2022-08-01/examples/Labs/listLabs.json + // this example is just showing the usage of "Labs_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (LabResource item in subscriptionResource.GetLabsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LabData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetSkus_ListSkus() diff --git a/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingQuotaCollection.cs b/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingQuotaCollection.cs index affdf903629cd..3198d60ad92c3 100644 --- a/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingQuotaCollection.cs +++ b/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingQuotaCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_LoadTestingQuotaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QuotasList() + public async Task Get_QuotasGet() { - // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_List.json - // this example is just showing the usage of "Quotas_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_Get.json + // this example is just showing the usage of "Quotas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_QuotasList() AzureLocation location = new AzureLocation("westus"); LoadTestingQuotaCollection collection = subscriptionResource.GetAllLoadTestingQuota(location); - // invoke the operation and iterate over the result - await foreach (LoadTestingQuotaResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadTestingQuotaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string quotaBucketName = "testQuotaBucket"; + LoadTestingQuotaResource result = await collection.GetAsync(quotaBucketName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadTestingQuotaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_QuotasGet() + public async Task GetAll_QuotasList() { - // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_Get.json - // this example is just showing the usage of "Quotas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_List.json + // this example is just showing the usage of "Quotas_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_QuotasGet() AzureLocation location = new AzureLocation("westus"); LoadTestingQuotaCollection collection = subscriptionResource.GetAllLoadTestingQuota(location); - // invoke the operation - string quotaBucketName = "testQuotaBucket"; - LoadTestingQuotaResource result = await collection.GetAsync(quotaBucketName); + // invoke the operation and iterate over the result + await foreach (LoadTestingQuotaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadTestingQuotaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadTestingQuotaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingQuotaResource.cs b/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingQuotaResource.cs index bf6a7702620bf..d308e905e12c2 100644 --- a/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingQuotaResource.cs +++ b/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingQuotaResource.cs @@ -67,12 +67,12 @@ public async Task CheckLoadTestingQuotaAvailability_QuotasCheckAvailability() LoadTestingQuotaResource loadTestingQuota = client.GetLoadTestingQuotaResource(loadTestingQuotaResourceId); // invoke the operation - LoadTestingQuotaBucketContent content = new LoadTestingQuotaBucketContent() + LoadTestingQuotaBucketContent content = new LoadTestingQuotaBucketContent { CurrentUsage = 20, CurrentQuota = 40, NewQuota = 50, - Dimensions = new LoadTestingQuotaBucketDimensions() + Dimensions = new LoadTestingQuotaBucketDimensions { SubscriptionId = "testsubscriptionId", Location = new AzureLocation("westus"), diff --git a/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingResource.cs b/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingResource.cs index 13f651393f771..7d931eff8dc6a 100644 --- a/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingResource.cs +++ b/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.LoadTesting.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.LoadTesting.Samples @@ -20,41 +19,40 @@ public partial class Sample_LoadTestingResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLoadTestingResources_LoadTestsListBySubscription() + public async Task Get_LoadTestsGet() { - // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListBySubscription.json - // this example is just showing the usage of "LoadTests_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json + // this example is just showing the usage of "LoadTests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this LoadTestingResource created on azure + // for more information of creating LoadTestingResource, please refer to the document of LoadTestingResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "dummyrg"; + string loadTestName = "myLoadTest"; + ResourceIdentifier loadTestingResourceId = LoadTestingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, loadTestName); + LoadTestingResource loadTestingResource = client.GetLoadTestingResource(loadTestingResourceId); - // invoke the operation and iterate over the result - await foreach (LoadTestingResource item in subscriptionResource.GetLoadTestingResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadTestingResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + LoadTestingResource result = await loadTestingResource.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadTestingResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LoadTestsGet() + public async Task Delete_LoadTestsDelete() { - // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json - // this example is just showing the usage of "LoadTests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Delete.json + // this example is just showing the usage of "LoadTests_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,13 +68,9 @@ public async Task Get_LoadTestsGet() LoadTestingResource loadTestingResource = client.GetLoadTestingResource(loadTestingResourceId); // invoke the operation - LoadTestingResource result = await loadTestingResource.GetAsync(); + await loadTestingResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadTestingResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,27 +94,27 @@ public async Task Update_LoadTestsUpdate() LoadTestingResource loadTestingResource = client.GetLoadTestingResource(loadTestingResourceId); // invoke the operation - LoadTestingResourcePatch patch = new LoadTestingResourcePatch() + LoadTestingResourcePatch patch = new LoadTestingResourcePatch { Tags = { ["Division"] = "LT", -["Team"] = "Dev Exp", +["Team"] = "Dev Exp" }, Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() }, }, Description = "This is new load test resource", - Encryption = new LoadTestingCmkEncryptionProperties() + Encryption = new LoadTestingCmkEncryptionProperties { - Identity = new LoadTestingCmkIdentity() + Identity = new LoadTestingCmkIdentity { IdentityType = LoadTestingCmkIdentityType.SystemAssigned, - ResourceId = null, + ResourceId = (ResourceIdentifier)null, }, KeyUri = new Uri("https://dummy.vault.azure.net/keys/dummykey1"), }, @@ -135,32 +129,6 @@ public async Task Update_LoadTestsUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_LoadTestsDelete() - { - // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Delete.json - // this example is just showing the usage of "LoadTests_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this LoadTestingResource created on azure - // for more information of creating LoadTestingResource, please refer to the document of LoadTestingResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "dummyrg"; - string loadTestName = "myLoadTest"; - ResourceIdentifier loadTestingResourceId = LoadTestingResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, loadTestName); - LoadTestingResource loadTestingResource = client.GetLoadTestingResource(loadTestingResourceId); - - // invoke the operation - await loadTestingResource.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetOutboundNetworkDependenciesEndpoints_ListOutboundNetworkDependencies() diff --git a/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingResourceCollection.cs b/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingResourceCollection.cs index 44860c0aa9069..dc5339e321a07 100644 --- a/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingResourceCollection.cs +++ b/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_LoadTestingResourceCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_LoadTestingResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LoadTestsListByResourceGroup() + public async Task CreateOrUpdate_LoadTestsCreateOrUpdate() { - // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListByResourceGroup.json - // this example is just showing the usage of "LoadTests_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_CreateOrUpdate.json + // this example is just showing the usage of "LoadTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,40 @@ public async Task GetAll_LoadTestsListByResourceGroup() // get the collection of this LoadTestingResource LoadTestingResourceCollection collection = resourceGroupResource.GetLoadTestingResources(); - // invoke the operation and iterate over the result - await foreach (LoadTestingResource item in collection.GetAllAsync()) + // invoke the operation + string loadTestName = "myLoadTest"; + LoadTestingResourceData data = new LoadTestingResourceData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadTestingResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() +}, + }, + Description = "This is new load test resource", + Encryption = new LoadTestingCmkEncryptionProperties + { + Identity = new LoadTestingCmkIdentity + { + IdentityType = LoadTestingCmkIdentityType.UserAssigned, + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + }, + KeyUri = new Uri("https://dummy.vault.azure.net/keys/dummykey1"), + }, + Tags = +{ +["Team"] = "Dev Exp" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadTestName, data); + LoadTestingResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadTestingResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +111,10 @@ public async Task Get_LoadTestsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LoadTestsGet() + public async Task GetAll_LoadTestsListByResourceGroup() { - // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json - // this example is just showing the usage of "LoadTests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListByResourceGroup.json + // this example is just showing the usage of "LoadTests_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +131,22 @@ public async Task Exists_LoadTestsGet() // get the collection of this LoadTestingResource LoadTestingResourceCollection collection = resourceGroupResource.GetLoadTestingResources(); - // invoke the operation - string loadTestName = "myLoadTest"; - bool result = await collection.ExistsAsync(loadTestName); + // invoke the operation and iterate over the result + await foreach (LoadTestingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadTestingResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LoadTestsGet() + public async Task Exists_LoadTestsGet() { // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json // this example is just showing the usage of "LoadTests_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +168,17 @@ public async Task GetIfExists_LoadTestsGet() // invoke the operation string loadTestName = "myLoadTest"; - NullableResponse response = await collection.GetIfExistsAsync(loadTestName); - LoadTestingResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(loadTestName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadTestingResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_LoadTestsCreateOrUpdate() + public async Task GetIfExists_LoadTestsGet() { - // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_CreateOrUpdate.json - // this example is just showing the usage of "LoadTests_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Get.json + // this example is just showing the usage of "LoadTests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,38 +197,21 @@ public async Task CreateOrUpdate_LoadTestsCreateOrUpdate() // invoke the operation string loadTestName = "myLoadTest"; - LoadTestingResourceData data = new LoadTestingResourceData(new AzureLocation("westus")) - { - Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), -}, - }, - Description = "This is new load test resource", - Encryption = new LoadTestingCmkEncryptionProperties() - { - Identity = new LoadTestingCmkIdentity() - { - IdentityType = LoadTestingCmkIdentityType.UserAssigned, - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), - }, - KeyUri = new Uri("https://dummy.vault.azure.net/keys/dummykey1"), - }, - Tags = -{ -["Team"] = "Dev Exp", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadTestName, data); - LoadTestingResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(loadTestName); + LoadTestingResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadTestingResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadTestingResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..cd9ac507e10ee --- /dev/null +++ b/sdk/loadtestservice/Azure.ResourceManager.LoadTesting/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.LoadTesting.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetLoadTestingResources_LoadTestsListBySubscription() + { + // Generated from example definition: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListBySubscription.json + // this example is just showing the usage of "LoadTests_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (LoadTestingResource item in subscriptionResource.GetLoadTestingResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadTestingResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAgreementCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAgreementCollection.cs index cbb6b22e007bc..5e73ecad56afa 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAgreementCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAgreementCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_IntegrationAccountAgreementCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAgreementsByIntegrationAccountName() + public async Task CreateOrUpdate_CreateOrUpdateAnAgreement() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAgreements_List.json - // this example is just showing the usage of "IntegrationAccountAgreements_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAgreements_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountAgreements_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +39,102 @@ public async Task GetAll_GetAgreementsByIntegrationAccountName() // get the collection of this IntegrationAccountAgreementResource IntegrationAccountAgreementCollection collection = integrationAccount.GetIntegrationAccountAgreements(); - // invoke the operation and iterate over the result - await foreach (IntegrationAccountAgreementResource item in collection.GetAllAsync()) + // invoke the operation + string agreementName = "testAgreement"; + IntegrationAccountAgreementData data = new IntegrationAccountAgreementData( + new AzureLocation("westus"), + IntegrationAccountAgreementType.AS2, + "HostPartner", + "GuestPartner", + new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), + new IntegrationAccountBusinessIdentity("AA", "AA"), + new IntegrationAccountAgreementContent + { + AS2 = new AS2AgreementContent(new AS2OneWayAgreement(new IntegrationAccountBusinessIdentity("AA", "AA"), new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), new AS2ProtocolSettings( + new AS2MessageConnectionSettings(true, true, true, true), + new AS2AcknowledgementConnectionSettings(true, true, true, true), + new AS2MdnSettings( + true, + true, + true, + true, + true, + AS2HashingAlgorithm.Sha1) + { + ReceiptDeliveryUri = new Uri("http://tempuri.org"), + DispositionNotificationTo = "http://tempuri.org", + MdnText = "Sample", + }, + new AS2SecuritySettings( + false, + true, + true, + true, + true, + true, + true), + new AS2ValidationSettings( + true, + false, + false, + true, + true, + 100, + true, + true, + AS2EncryptionAlgorithm.Aes128), + new AS2EnvelopeSettings(new ContentType("text/plain"), true, "Test", true, true), + new AS2ErrorSettings(true, true))), new AS2OneWayAgreement(new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), new IntegrationAccountBusinessIdentity("AA", "AA"), new AS2ProtocolSettings( + new AS2MessageConnectionSettings(true, true, true, true), + new AS2AcknowledgementConnectionSettings(true, true, true, true), + new AS2MdnSettings( + true, + true, + true, + true, + true, + AS2HashingAlgorithm.Sha1) + { + ReceiptDeliveryUri = new Uri("http://tempuri.org"), + DispositionNotificationTo = "http://tempuri.org", + MdnText = "Sample", + }, + new AS2SecuritySettings( + false, + true, + true, + true, + true, + true, + true), + new AS2ValidationSettings( + true, + false, + false, + true, + true, + 100, + true, + true, + AS2EncryptionAlgorithm.Aes128), + new AS2EnvelopeSettings(new ContentType("text/plain"), true, "Test", true, true), + new AS2ErrorSettings(true, true)))), + }) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountAgreementData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Metadata = BinaryData.FromObjectAsJson(new object()), + Tags = +{ +["IntegrationAccountAgreement"] = "" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agreementName, data); + IntegrationAccountAgreementResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountAgreementData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +173,10 @@ public async Task Get_GetAgreementByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAgreementByName() + public async Task GetAll_GetAgreementsByIntegrationAccountName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAgreements_Get.json - // this example is just showing the usage of "IntegrationAccountAgreements_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAgreements_List.json + // this example is just showing the usage of "IntegrationAccountAgreements_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +194,22 @@ public async Task Exists_GetAgreementByName() // get the collection of this IntegrationAccountAgreementResource IntegrationAccountAgreementCollection collection = integrationAccount.GetIntegrationAccountAgreements(); - // invoke the operation - string agreementName = "testAgreement"; - bool result = await collection.ExistsAsync(agreementName); + // invoke the operation and iterate over the result + await foreach (IntegrationAccountAgreementResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountAgreementData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAgreementByName() + public async Task Exists_GetAgreementByName() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAgreements_Get.json // this example is just showing the usage of "IntegrationAccountAgreements_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +232,17 @@ public async Task GetIfExists_GetAgreementByName() // invoke the operation string agreementName = "testAgreement"; - NullableResponse response = await collection.GetIfExistsAsync(agreementName); - IntegrationAccountAgreementResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(agreementName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountAgreementData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnAgreement() + public async Task GetIfExists_GetAgreementByName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAgreements_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountAgreements_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAgreements_Get.json + // this example is just showing the usage of "IntegrationAccountAgreements_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,37 +262,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAgreement() // invoke the operation string agreementName = "testAgreement"; - IntegrationAccountAgreementData data = new IntegrationAccountAgreementData(new AzureLocation("westus"), IntegrationAccountAgreementType.AS2, "HostPartner", "GuestPartner", new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), new IntegrationAccountBusinessIdentity("AA", "AA"), new IntegrationAccountAgreementContent() + NullableResponse response = await collection.GetIfExistsAsync(agreementName); + IntegrationAccountAgreementResource result = response.HasValue ? response.Value : null; + + if (result == null) { - AS2 = new AS2AgreementContent(new AS2OneWayAgreement(new IntegrationAccountBusinessIdentity("AA", "AA"), new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), new AS2ProtocolSettings(new AS2MessageConnectionSettings(true, true, true, true), new AS2AcknowledgementConnectionSettings(true, true, true, true), new AS2MdnSettings(true, true, true, true, true, AS2HashingAlgorithm.Sha1) - { - ReceiptDeliveryUri = new Uri("http://tempuri.org"), - DispositionNotificationTo = "http://tempuri.org", - MdnText = "Sample", - }, new AS2SecuritySettings(false, true, true, true, true, true, true), new AS2ValidationSettings(true, false, false, true, true, 100, true, true, AS2EncryptionAlgorithm.Aes128), new AS2EnvelopeSettings(new ContentType("text/plain"), true, "Test", true, true), new AS2ErrorSettings(true, true))), new AS2OneWayAgreement(new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), new IntegrationAccountBusinessIdentity("AA", "AA"), new AS2ProtocolSettings(new AS2MessageConnectionSettings(true, true, true, true), new AS2AcknowledgementConnectionSettings(true, true, true, true), new AS2MdnSettings(true, true, true, true, true, AS2HashingAlgorithm.Sha1) - { - ReceiptDeliveryUri = new Uri("http://tempuri.org"), - DispositionNotificationTo = "http://tempuri.org", - MdnText = "Sample", - }, new AS2SecuritySettings(false, true, true, true, true, true, true), new AS2ValidationSettings(true, false, false, true, true, 100, true, true, AS2EncryptionAlgorithm.Aes128), new AS2EnvelopeSettings(new ContentType("text/plain"), true, "Test", true, true), new AS2ErrorSettings(true, true)))), - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - Tags = -{ -["IntegrationAccountAgreement"] = "", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, agreementName, data); - IntegrationAccountAgreementResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountAgreementData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountAgreementData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAgreementResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAgreementResource.cs index de6b0d6c19a94..11d529523c556 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAgreementResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAgreementResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -48,6 +47,33 @@ public async Task Get_GetAgreementByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAnAgreement() + { + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAgreements_Delete.json + // this example is just showing the usage of "IntegrationAccountAgreements_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this IntegrationAccountAgreementResource created on azure + // for more information of creating IntegrationAccountAgreementResource, please refer to the document of IntegrationAccountAgreementResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "testResourceGroup"; + string integrationAccountName = "testIntegrationAccount"; + string agreementName = "testAgreement"; + ResourceIdentifier integrationAccountAgreementResourceId = IntegrationAccountAgreementResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, integrationAccountName, agreementName); + IntegrationAccountAgreementResource integrationAccountAgreement = client.GetIntegrationAccountAgreementResource(integrationAccountAgreementResourceId); + + // invoke the operation + await integrationAccountAgreement.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateAnAgreement() @@ -70,27 +96,90 @@ public async Task Update_CreateOrUpdateAnAgreement() IntegrationAccountAgreementResource integrationAccountAgreement = client.GetIntegrationAccountAgreementResource(integrationAccountAgreementResourceId); // invoke the operation - IntegrationAccountAgreementData data = new IntegrationAccountAgreementData(new AzureLocation("westus"), IntegrationAccountAgreementType.AS2, "HostPartner", "GuestPartner", new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), new IntegrationAccountBusinessIdentity("AA", "AA"), new IntegrationAccountAgreementContent() - { - AS2 = new AS2AgreementContent(new AS2OneWayAgreement(new IntegrationAccountBusinessIdentity("AA", "AA"), new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), new AS2ProtocolSettings(new AS2MessageConnectionSettings(true, true, true, true), new AS2AcknowledgementConnectionSettings(true, true, true, true), new AS2MdnSettings(true, true, true, true, true, AS2HashingAlgorithm.Sha1) + IntegrationAccountAgreementData data = new IntegrationAccountAgreementData( + new AzureLocation("westus"), + IntegrationAccountAgreementType.AS2, + "HostPartner", + "GuestPartner", + new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), + new IntegrationAccountBusinessIdentity("AA", "AA"), + new IntegrationAccountAgreementContent + { + AS2 = new AS2AgreementContent(new AS2OneWayAgreement(new IntegrationAccountBusinessIdentity("AA", "AA"), new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), new AS2ProtocolSettings( + new AS2MessageConnectionSettings(true, true, true, true), + new AS2AcknowledgementConnectionSettings(true, true, true, true), + new AS2MdnSettings( + true, + true, + true, + true, + true, + AS2HashingAlgorithm.Sha1) { ReceiptDeliveryUri = new Uri("http://tempuri.org"), DispositionNotificationTo = "http://tempuri.org", MdnText = "Sample", - }, new AS2SecuritySettings(false, true, true, true, true, true, true), new AS2ValidationSettings(true, false, false, true, true, 100, true, true, AS2EncryptionAlgorithm.Aes128), new AS2EnvelopeSettings(new ContentType("text/plain"), true, "Test", true, true), new AS2ErrorSettings(true, true))), new AS2OneWayAgreement(new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), new IntegrationAccountBusinessIdentity("AA", "AA"), new AS2ProtocolSettings(new AS2MessageConnectionSettings(true, true, true, true), new AS2AcknowledgementConnectionSettings(true, true, true, true), new AS2MdnSettings(true, true, true, true, true, AS2HashingAlgorithm.Sha1) + }, + new AS2SecuritySettings( + false, + true, + true, + true, + true, + true, + true), + new AS2ValidationSettings( + true, + false, + false, + true, + true, + 100, + true, + true, + AS2EncryptionAlgorithm.Aes128), + new AS2EnvelopeSettings(new ContentType("text/plain"), true, "Test", true, true), + new AS2ErrorSettings(true, true))), new AS2OneWayAgreement(new IntegrationAccountBusinessIdentity("ZZ", "ZZ"), new IntegrationAccountBusinessIdentity("AA", "AA"), new AS2ProtocolSettings( + new AS2MessageConnectionSettings(true, true, true, true), + new AS2AcknowledgementConnectionSettings(true, true, true, true), + new AS2MdnSettings( + true, + true, + true, + true, + true, + AS2HashingAlgorithm.Sha1) { ReceiptDeliveryUri = new Uri("http://tempuri.org"), DispositionNotificationTo = "http://tempuri.org", MdnText = "Sample", - }, new AS2SecuritySettings(false, true, true, true, true, true, true), new AS2ValidationSettings(true, false, false, true, true, 100, true, true, AS2EncryptionAlgorithm.Aes128), new AS2EnvelopeSettings(new ContentType("text/plain"), true, "Test", true, true), new AS2ErrorSettings(true, true)))), - }) + }, + new AS2SecuritySettings( + false, + true, + true, + true, + true, + true, + true), + new AS2ValidationSettings( + true, + false, + false, + true, + true, + 100, + true, + true, + AS2EncryptionAlgorithm.Aes128), + new AS2EnvelopeSettings(new ContentType("text/plain"), true, "Test", true, true), + new AS2ErrorSettings(true, true)))), + }) { - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), + Metadata = BinaryData.FromObjectAsJson(new object()), Tags = { -["IntegrationAccountAgreement"] = "", +["IntegrationAccountAgreement"] = "" }, }; ArmOperation lro = await integrationAccountAgreement.UpdateAsync(WaitUntil.Completed, data); @@ -103,33 +192,6 @@ public async Task Update_CreateOrUpdateAnAgreement() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnAgreement() - { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAgreements_Delete.json - // this example is just showing the usage of "IntegrationAccountAgreements_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this IntegrationAccountAgreementResource created on azure - // for more information of creating IntegrationAccountAgreementResource, please refer to the document of IntegrationAccountAgreementResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "testResourceGroup"; - string integrationAccountName = "testIntegrationAccount"; - string agreementName = "testAgreement"; - ResourceIdentifier integrationAccountAgreementResourceId = IntegrationAccountAgreementResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, integrationAccountName, agreementName); - IntegrationAccountAgreementResource integrationAccountAgreement = client.GetIntegrationAccountAgreementResource(integrationAccountAgreementResourceId); - - // invoke the operation - await integrationAccountAgreement.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetContentCallbackUrl_GetTheContentCallbackUrl() @@ -152,7 +214,7 @@ public async Task GetContentCallbackUrl_GetTheContentCallbackUrl() IntegrationAccountAgreementResource integrationAccountAgreement = client.GetIntegrationAccountAgreementResource(integrationAccountAgreementResourceId); // invoke the operation - ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo() + ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo { NotAfter = DateTimeOffset.Parse("2018-04-19T16:00:00Z"), KeyType = LogicKeyType.Primary, diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAssemblyDefinitionCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAssemblyDefinitionCollection.cs index 5b1e14abd23c8..67db70d716222 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAssemblyDefinitionCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAssemblyDefinitionCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_IntegrationAccountAssemblyDefinitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIntegrationAccountAssemblies() + public async Task CreateOrUpdate_CreateOrUpdateAnAccountAssembly() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_List.json - // this example is just showing the usage of "IntegrationAccountAssemblies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountAssemblies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +39,21 @@ public async Task GetAll_ListIntegrationAccountAssemblies() // get the collection of this IntegrationAccountAssemblyDefinitionResource IntegrationAccountAssemblyDefinitionCollection collection = integrationAccount.GetIntegrationAccountAssemblyDefinitions(); - // invoke the operation and iterate over the result - await foreach (IntegrationAccountAssemblyDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string assemblyArtifactName = "testAssembly"; + IntegrationAccountAssemblyDefinitionData data = new IntegrationAccountAssemblyDefinitionData(new AzureLocation("westus"), new IntegrationAccountAssemblyProperties("System.IdentityModel.Tokens.Jwt") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountAssemblyDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Content = BinaryData.FromObjectAsJson("Base64 encoded Assembly Content"), + Metadata = BinaryData.FromObjectAsJson(new object()), + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assemblyArtifactName, data); + IntegrationAccountAssemblyDefinitionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountAssemblyDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_GetAnIntegrationAccountAssembly() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnIntegrationAccountAssembly() + public async Task GetAll_ListIntegrationAccountAssemblies() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_Get.json - // this example is just showing the usage of "IntegrationAccountAssemblies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_List.json + // this example is just showing the usage of "IntegrationAccountAssemblies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +113,22 @@ public async Task Exists_GetAnIntegrationAccountAssembly() // get the collection of this IntegrationAccountAssemblyDefinitionResource IntegrationAccountAssemblyDefinitionCollection collection = integrationAccount.GetIntegrationAccountAssemblyDefinitions(); - // invoke the operation - string assemblyArtifactName = "testAssembly"; - bool result = await collection.ExistsAsync(assemblyArtifactName); + // invoke the operation and iterate over the result + await foreach (IntegrationAccountAssemblyDefinitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountAssemblyDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnIntegrationAccountAssembly() + public async Task Exists_GetAnIntegrationAccountAssembly() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_Get.json // this example is just showing the usage of "IntegrationAccountAssemblies_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +151,17 @@ public async Task GetIfExists_GetAnIntegrationAccountAssembly() // invoke the operation string assemblyArtifactName = "testAssembly"; - NullableResponse response = await collection.GetIfExistsAsync(assemblyArtifactName); - IntegrationAccountAssemblyDefinitionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(assemblyArtifactName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountAssemblyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnAccountAssembly() + public async Task GetIfExists_GetAnIntegrationAccountAssembly() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountAssemblies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_Get.json + // this example is just showing the usage of "IntegrationAccountAssemblies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,21 +181,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAccountAssembly() // invoke the operation string assemblyArtifactName = "testAssembly"; - IntegrationAccountAssemblyDefinitionData data = new IntegrationAccountAssemblyDefinitionData(new AzureLocation("westus"), new IntegrationAccountAssemblyProperties("System.IdentityModel.Tokens.Jwt") - { - Content = BinaryData.FromString("\"Base64 encoded Assembly Content\""), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assemblyArtifactName, data); - IntegrationAccountAssemblyDefinitionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(assemblyArtifactName); + IntegrationAccountAssemblyDefinitionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountAssemblyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountAssemblyDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAssemblyDefinitionResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAssemblyDefinitionResource.cs index 2f022dc1aa0f5..f21d32573dece 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAssemblyDefinitionResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountAssemblyDefinitionResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -50,10 +49,10 @@ public async Task Get_GetAnIntegrationAccountAssembly() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAnAccountAssembly() + public async Task Delete_DeleteAnIntegrationAccountAssembly() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountAssemblies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_Delete.json + // this example is just showing the usage of "IntegrationAccountAssemblies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,29 +69,17 @@ public async Task Update_CreateOrUpdateAnAccountAssembly() IntegrationAccountAssemblyDefinitionResource integrationAccountAssemblyDefinition = client.GetIntegrationAccountAssemblyDefinitionResource(integrationAccountAssemblyDefinitionResourceId); // invoke the operation - IntegrationAccountAssemblyDefinitionData data = new IntegrationAccountAssemblyDefinitionData(new AzureLocation("westus"), new IntegrationAccountAssemblyProperties("System.IdentityModel.Tokens.Jwt") - { - Content = BinaryData.FromString("\"Base64 encoded Assembly Content\""), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - }); - ArmOperation lro = await integrationAccountAssemblyDefinition.UpdateAsync(WaitUntil.Completed, data); - IntegrationAccountAssemblyDefinitionResource result = lro.Value; + await integrationAccountAssemblyDefinition.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountAssemblyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnIntegrationAccountAssembly() + public async Task Update_CreateOrUpdateAnAccountAssembly() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_Delete.json - // this example is just showing the usage of "IntegrationAccountAssemblies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountAssemblies_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountAssemblies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,19 @@ public async Task Delete_DeleteAnIntegrationAccountAssembly() IntegrationAccountAssemblyDefinitionResource integrationAccountAssemblyDefinition = client.GetIntegrationAccountAssemblyDefinitionResource(integrationAccountAssemblyDefinitionResourceId); // invoke the operation - await integrationAccountAssemblyDefinition.DeleteAsync(WaitUntil.Completed); + IntegrationAccountAssemblyDefinitionData data = new IntegrationAccountAssemblyDefinitionData(new AzureLocation("westus"), new IntegrationAccountAssemblyProperties("System.IdentityModel.Tokens.Jwt") + { + Content = BinaryData.FromObjectAsJson("Base64 encoded Assembly Content"), + Metadata = BinaryData.FromObjectAsJson(new object()), + }); + ArmOperation lro = await integrationAccountAssemblyDefinition.UpdateAsync(WaitUntil.Completed, data); + IntegrationAccountAssemblyDefinitionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountAssemblyDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountBatchConfigurationCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountBatchConfigurationCollection.cs index 20573e1f08013..ef79a333b9fcb 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountBatchConfigurationCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountBatchConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_IntegrationAccountBatchConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBatchConfigurations() + public async Task CreateOrUpdate_CreateOrUpdateABatchConfiguration() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_List.json - // this example is just showing the usage of "IntegrationAccountBatchConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountBatchConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,28 @@ public async Task GetAll_ListBatchConfigurations() // get the collection of this IntegrationAccountBatchConfigurationResource IntegrationAccountBatchConfigurationCollection collection = integrationAccount.GetIntegrationAccountBatchConfigurations(); - // invoke the operation and iterate over the result - await foreach (IntegrationAccountBatchConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string batchConfigurationName = "testBatchConfiguration"; + IntegrationAccountBatchConfigurationData data = new IntegrationAccountBatchConfigurationData(new AzureLocation("westus"), new IntegrationAccountBatchConfigurationProperties("DEFAULT", new IntegrationAccountBatchReleaseCriteria { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountBatchConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + MessageCount = 10, + BatchSize = 234567, + Recurrence = new LogicWorkflowTriggerRecurrence + { + Frequency = LogicWorkflowRecurrenceFrequency.Minute, + Interval = 1, + StartOn = DateTimeOffset.Parse("2017-03-24T11:43:00"), + TimeZone = "India Standard Time", + }, + })); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, batchConfigurationName, data); + IntegrationAccountBatchConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountBatchConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +99,10 @@ public async Task Get_GetABatchConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetABatchConfiguration() + public async Task GetAll_ListBatchConfigurations() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_Get.json - // this example is just showing the usage of "IntegrationAccountBatchConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_List.json + // this example is just showing the usage of "IntegrationAccountBatchConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +120,22 @@ public async Task Exists_GetABatchConfiguration() // get the collection of this IntegrationAccountBatchConfigurationResource IntegrationAccountBatchConfigurationCollection collection = integrationAccount.GetIntegrationAccountBatchConfigurations(); - // invoke the operation - string batchConfigurationName = "testBatchConfiguration"; - bool result = await collection.ExistsAsync(batchConfigurationName); + // invoke the operation and iterate over the result + await foreach (IntegrationAccountBatchConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountBatchConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetABatchConfiguration() + public async Task Exists_GetABatchConfiguration() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_Get.json // this example is just showing the usage of "IntegrationAccountBatchConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +158,17 @@ public async Task GetIfExists_GetABatchConfiguration() // invoke the operation string batchConfigurationName = "testBatchConfiguration"; - NullableResponse response = await collection.GetIfExistsAsync(batchConfigurationName); - IntegrationAccountBatchConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(batchConfigurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountBatchConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateABatchConfiguration() + public async Task GetIfExists_GetABatchConfiguration() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountBatchConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_Get.json + // this example is just showing the usage of "IntegrationAccountBatchConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +188,21 @@ public async Task CreateOrUpdate_CreateOrUpdateABatchConfiguration() // invoke the operation string batchConfigurationName = "testBatchConfiguration"; - IntegrationAccountBatchConfigurationData data = new IntegrationAccountBatchConfigurationData(new AzureLocation("westus"), new IntegrationAccountBatchConfigurationProperties("DEFAULT", new IntegrationAccountBatchReleaseCriteria() - { - MessageCount = 10, - BatchSize = 234567, - Recurrence = new LogicWorkflowTriggerRecurrence() - { - Frequency = LogicWorkflowRecurrenceFrequency.Minute, - Interval = 1, - StartOn = DateTimeOffset.Parse("2017-03-24T11:43:00"), - TimeZone = "India Standard Time", - }, - })); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, batchConfigurationName, data); - IntegrationAccountBatchConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(batchConfigurationName); + IntegrationAccountBatchConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountBatchConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountBatchConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountBatchConfigurationResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountBatchConfigurationResource.cs index 2878c2c28057a..5f84ab412041f 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountBatchConfigurationResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountBatchConfigurationResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetABatchConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateABatchConfiguration() + public async Task Delete_DeleteABatchConfiguration() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountBatchConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_Delete.json + // this example is just showing the usage of "IntegrationAccountBatchConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,34 +69,17 @@ public async Task Update_CreateOrUpdateABatchConfiguration() IntegrationAccountBatchConfigurationResource integrationAccountBatchConfiguration = client.GetIntegrationAccountBatchConfigurationResource(integrationAccountBatchConfigurationResourceId); // invoke the operation - IntegrationAccountBatchConfigurationData data = new IntegrationAccountBatchConfigurationData(new AzureLocation("westus"), new IntegrationAccountBatchConfigurationProperties("DEFAULT", new IntegrationAccountBatchReleaseCriteria() - { - MessageCount = 10, - BatchSize = 234567, - Recurrence = new LogicWorkflowTriggerRecurrence() - { - Frequency = LogicWorkflowRecurrenceFrequency.Minute, - Interval = 1, - StartOn = DateTimeOffset.Parse("2017-03-24T11:43:00"), - TimeZone = "India Standard Time", - }, - })); - ArmOperation lro = await integrationAccountBatchConfiguration.UpdateAsync(WaitUntil.Completed, data); - IntegrationAccountBatchConfigurationResource result = lro.Value; + await integrationAccountBatchConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountBatchConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteABatchConfiguration() + public async Task Update_CreateOrUpdateABatchConfiguration() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_Delete.json - // this example is just showing the usage of "IntegrationAccountBatchConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountBatchConfigurations_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountBatchConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,9 +96,26 @@ public async Task Delete_DeleteABatchConfiguration() IntegrationAccountBatchConfigurationResource integrationAccountBatchConfiguration = client.GetIntegrationAccountBatchConfigurationResource(integrationAccountBatchConfigurationResourceId); // invoke the operation - await integrationAccountBatchConfiguration.DeleteAsync(WaitUntil.Completed); + IntegrationAccountBatchConfigurationData data = new IntegrationAccountBatchConfigurationData(new AzureLocation("westus"), new IntegrationAccountBatchConfigurationProperties("DEFAULT", new IntegrationAccountBatchReleaseCriteria + { + MessageCount = 10, + BatchSize = 234567, + Recurrence = new LogicWorkflowTriggerRecurrence + { + Frequency = LogicWorkflowRecurrenceFrequency.Minute, + Interval = 1, + StartOn = DateTimeOffset.Parse("2017-03-24T11:43:00"), + TimeZone = "India Standard Time", + }, + })); + ArmOperation lro = await integrationAccountBatchConfiguration.UpdateAsync(WaitUntil.Completed, data); + IntegrationAccountBatchConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountBatchConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCertificateCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCertificateCollection.cs index 199153f21f63d..7fc2ea6e2b92a 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCertificateCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCertificateCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_IntegrationAccountCertificateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetCertificatesByIntegrationAccountName() + public async Task CreateOrUpdate_CreateOrUpdateACertificate() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_List.json - // this example is just showing the usage of "IntegrationAccountCertificates_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_GetCertificatesByIntegrationAccountName() // get the collection of this IntegrationAccountCertificateResource IntegrationAccountCertificateCollection collection = integrationAccount.GetIntegrationAccountCertificates(); - // invoke the operation and iterate over the result - await foreach (IntegrationAccountCertificateResource item in collection.GetAllAsync()) + // invoke the operation + string certificateName = "testCertificate"; + IntegrationAccountCertificateData data = new IntegrationAccountCertificateData(new AzureLocation("brazilsouth")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountCertificateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Key = new IntegrationAccountKeyVaultKeyReference("") + { + KeyVersion = "87d9764197604449b9b8eb7bd8710868", + ResourceId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testResourceGroup/providers/microsoft.keyvault/vaults/"), + }, + PublicCertificate = BinaryData.FromObjectAsJson(""), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); + IntegrationAccountCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetCertificateByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCertificateByName() + public async Task GetAll_GetCertificatesByIntegrationAccountName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_Get.json - // this example is just showing the usage of "IntegrationAccountCertificates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_List.json + // this example is just showing the usage of "IntegrationAccountCertificates_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetCertificateByName() // get the collection of this IntegrationAccountCertificateResource IntegrationAccountCertificateCollection collection = integrationAccount.GetIntegrationAccountCertificates(); - // invoke the operation - string certificateName = "testCertificate"; - bool result = await collection.ExistsAsync(certificateName); + // invoke the operation and iterate over the result + await foreach (IntegrationAccountCertificateResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountCertificateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCertificateByName() + public async Task Exists_GetCertificateByName() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_Get.json // this example is just showing the usage of "IntegrationAccountCertificates_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetCertificateByName() // invoke the operation string certificateName = "testCertificate"; - NullableResponse response = await collection.GetIfExistsAsync(certificateName); - IntegrationAccountCertificateResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(certificateName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateACertificate() + public async Task GetIfExists_GetCertificateByName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_Get.json + // this example is just showing the usage of "IntegrationAccountCertificates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateACertificate() // invoke the operation string certificateName = "testCertificate"; - IntegrationAccountCertificateData data = new IntegrationAccountCertificateData(new AzureLocation("brazilsouth")) - { - Key = new IntegrationAccountKeyVaultKeyReference("") - { - KeyVersion = "87d9764197604449b9b8eb7bd8710868", - ResourceId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testResourceGroup/providers/microsoft.keyvault/vaults/"), - }, - PublicCertificate = BinaryData.FromString("\"\""), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, certificateName, data); - IntegrationAccountCertificateResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(certificateName); + IntegrationAccountCertificateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCertificateResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCertificateResource.cs index f7c9074e885e8..431f02ff81bae 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCertificateResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCertificateResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetCertificateByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateACertificate() + public async Task Delete_DeleteACertificate() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_Delete.json + // this example is just showing the usage of "IntegrationAccountCertificates_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,17 @@ public async Task Update_CreateOrUpdateACertificate() IntegrationAccountCertificateResource integrationAccountCertificate = client.GetIntegrationAccountCertificateResource(integrationAccountCertificateResourceId); // invoke the operation - IntegrationAccountCertificateData data = new IntegrationAccountCertificateData(new AzureLocation("brazilsouth")) - { - Key = new IntegrationAccountKeyVaultKeyReference("") - { - KeyVersion = "87d9764197604449b9b8eb7bd8710868", - ResourceId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testResourceGroup/providers/microsoft.keyvault/vaults/"), - }, - PublicCertificate = BinaryData.FromString("\"\""), - }; - ArmOperation lro = await integrationAccountCertificate.UpdateAsync(WaitUntil.Completed, data); - IntegrationAccountCertificateResource result = lro.Value; + await integrationAccountCertificate.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountCertificateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteACertificate() + public async Task Update_CreateOrUpdateACertificate() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_Delete.json - // this example is just showing the usage of "IntegrationAccountCertificates_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountCertificates_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountCertificates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +96,23 @@ public async Task Delete_DeleteACertificate() IntegrationAccountCertificateResource integrationAccountCertificate = client.GetIntegrationAccountCertificateResource(integrationAccountCertificateResourceId); // invoke the operation - await integrationAccountCertificate.DeleteAsync(WaitUntil.Completed); + IntegrationAccountCertificateData data = new IntegrationAccountCertificateData(new AzureLocation("brazilsouth")) + { + Key = new IntegrationAccountKeyVaultKeyReference("") + { + KeyVersion = "87d9764197604449b9b8eb7bd8710868", + ResourceId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testResourceGroup/providers/microsoft.keyvault/vaults/"), + }, + PublicCertificate = BinaryData.FromObjectAsJson(""), + }; + ArmOperation lro = await integrationAccountCertificate.UpdateAsync(WaitUntil.Completed, data); + IntegrationAccountCertificateResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountCertificateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCollection.cs index ec2ff7555df80..f9ee709430c02 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_IntegrationAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIntegrationAccountsByResourceGroupName() + public async Task CreateOrUpdate_CreateOrUpdateAnIntegrationAccount() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_ListByResourceGroup.json - // this example is just showing the usage of "IntegrationAccounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ListIntegrationAccountsByResourceGroupName() // get the collection of this IntegrationAccountResource IntegrationAccountCollection collection = resourceGroupResource.GetIntegrationAccounts(); - // invoke the operation and iterate over the result - await foreach (IntegrationAccountResource item in collection.GetAllAsync()) + // invoke the operation + string integrationAccountName = "testIntegrationAccount"; + IntegrationAccountData data = new IntegrationAccountData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SkuName = IntegrationAccountSkuName.Standard, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, integrationAccountName, data); + IntegrationAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetIntegrationAccountByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetIntegrationAccountByName() + public async Task GetAll_ListIntegrationAccountsByResourceGroupName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_Get.json - // this example is just showing the usage of "IntegrationAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_ListByResourceGroup.json + // this example is just showing the usage of "IntegrationAccounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +110,22 @@ public async Task Exists_GetIntegrationAccountByName() // get the collection of this IntegrationAccountResource IntegrationAccountCollection collection = resourceGroupResource.GetIntegrationAccounts(); - // invoke the operation - string integrationAccountName = "testIntegrationAccount"; - bool result = await collection.ExistsAsync(integrationAccountName); + // invoke the operation and iterate over the result + await foreach (IntegrationAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetIntegrationAccountByName() + public async Task Exists_GetIntegrationAccountByName() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_Get.json // this example is just showing the usage of "IntegrationAccounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +147,17 @@ public async Task GetIfExists_GetIntegrationAccountByName() // invoke the operation string integrationAccountName = "testIntegrationAccount"; - NullableResponse response = await collection.GetIfExistsAsync(integrationAccountName); - IntegrationAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(integrationAccountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnIntegrationAccount() + public async Task GetIfExists_GetIntegrationAccountByName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_Get.json + // this example is just showing the usage of "IntegrationAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,18 +176,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAnIntegrationAccount() // invoke the operation string integrationAccountName = "testIntegrationAccount"; - IntegrationAccountData data = new IntegrationAccountData(new AzureLocation("westus")) - { - SkuName = IntegrationAccountSkuName.Standard, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, integrationAccountName, data); - IntegrationAccountResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(integrationAccountName); + IntegrationAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountMapCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountMapCollection.cs index 901efe22c3b6b..8cfaeda304835 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountMapCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountMapCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_IntegrationAccountMapCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetMapsByIntegrationAccountName() + public async Task CreateOrUpdate_CreateOrUpdateAMap() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_List.json - // this example is just showing the usage of "IntegrationAccountMaps_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +39,30 @@ public async Task GetAll_GetMapsByIntegrationAccountName() // get the collection of this IntegrationAccountMapResource IntegrationAccountMapCollection collection = integrationAccount.GetIntegrationAccountMaps(); - // invoke the operation and iterate over the result - await foreach (IntegrationAccountMapResource item in collection.GetAllAsync()) + // invoke the operation + string mapName = "testMap"; + IntegrationAccountMapData data = new IntegrationAccountMapData(new AzureLocation("westus"), IntegrationAccountMapType.Xslt) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountMapData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Content = BinaryData.FromObjectAsJson("\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), + ContentType = new ContentType("application/xml"), + Metadata = BinaryData.FromObjectAsJson(new object()), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mapName, data); + IntegrationAccountMapResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMapByName() + public async Task CreateOrUpdate_CreateOrUpdateAMapLargerThan4MB() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_Get.json - // this example is just showing the usage of "IntegrationAccountMaps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountLargeMaps_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,7 +71,7 @@ public async Task Get_GetMapByName() // this example assumes you already have this IntegrationAccountResource created on azure // for more information of creating IntegrationAccountResource, please refer to the document of IntegrationAccountResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = ""; string resourceGroupName = "testResourceGroup"; string integrationAccountName = "testIntegrationAccount"; ResourceIdentifier integrationAccountResourceId = IntegrationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, integrationAccountName); @@ -78,7 +82,13 @@ public async Task Get_GetMapByName() // invoke the operation string mapName = "testMap"; - IntegrationAccountMapResource result = await collection.GetAsync(mapName); + IntegrationAccountMapData data = new IntegrationAccountMapData(new AzureLocation("westus"), IntegrationAccountMapType.Xslt) + { + ContentType = new ContentType("application/xml"), + Metadata = BinaryData.FromObjectAsJson(new object()), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mapName, data); + IntegrationAccountMapResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,7 +99,7 @@ public async Task Get_GetMapByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMapByName() + public async Task Get_GetMapByName() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_Get.json // this example is just showing the usage of "IntegrationAccountMaps_Get" operation, for the dependent resources, they will have to be created separately. @@ -112,17 +122,21 @@ public async Task Exists_GetMapByName() // invoke the operation string mapName = "testMap"; - bool result = await collection.ExistsAsync(mapName); + IntegrationAccountMapResource result = await collection.GetAsync(mapName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMapByName() + public async Task GetAll_GetMapsByIntegrationAccountName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_Get.json - // this example is just showing the usage of "IntegrationAccountMaps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_List.json + // this example is just showing the usage of "IntegrationAccountMaps_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -140,31 +154,25 @@ public async Task GetIfExists_GetMapByName() // get the collection of this IntegrationAccountMapResource IntegrationAccountMapCollection collection = integrationAccount.GetIntegrationAccountMaps(); - // invoke the operation - string mapName = "testMap"; - NullableResponse response = await collection.GetIfExistsAsync(mapName); - IntegrationAccountMapResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (IntegrationAccountMapResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IntegrationAccountMapData resourceData = result.Data; + IntegrationAccountMapData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAMap() + public async Task Exists_GetMapByName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_Get.json + // this example is just showing the usage of "IntegrationAccountMaps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,30 +192,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAMap() // invoke the operation string mapName = "testMap"; - IntegrationAccountMapData data = new IntegrationAccountMapData(new AzureLocation("westus"), IntegrationAccountMapType.Xslt) - { - Content = BinaryData.FromString("\"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\""), - ContentType = new ContentType("application/xml"), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mapName, data); - IntegrationAccountMapResource result = lro.Value; + bool result = await collection.ExistsAsync(mapName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAMapLargerThan4MB() + public async Task GetIfExists_GetMapByName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountLargeMaps_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_Get.json + // this example is just showing the usage of "IntegrationAccountMaps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -216,7 +211,7 @@ public async Task CreateOrUpdate_CreateOrUpdateAMapLargerThan4MB() // this example assumes you already have this IntegrationAccountResource created on azure // for more information of creating IntegrationAccountResource, please refer to the document of IntegrationAccountResource - string subscriptionId = ""; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "testResourceGroup"; string integrationAccountName = "testIntegrationAccount"; ResourceIdentifier integrationAccountResourceId = IntegrationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, integrationAccountName); @@ -227,21 +222,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAMapLargerThan4MB() // invoke the operation string mapName = "testMap"; - IntegrationAccountMapData data = new IntegrationAccountMapData(new AzureLocation("westus"), IntegrationAccountMapType.Xslt) - { - ContentType = new ContentType("application/xml"), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mapName, data); - IntegrationAccountMapResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(mapName); + IntegrationAccountMapResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountMapResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountMapResource.cs index 44509b1e35b23..6d3cfb41542a1 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountMapResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountMapResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -50,10 +49,10 @@ public async Task Get_GetMapByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAMap() + public async Task Delete_DeleteAMap() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_Delete.json + // this example is just showing the usage of "IntegrationAccountMaps_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,29 +69,16 @@ public async Task Update_CreateOrUpdateAMap() IntegrationAccountMapResource integrationAccountMap = client.GetIntegrationAccountMapResource(integrationAccountMapResourceId); // invoke the operation - IntegrationAccountMapData data = new IntegrationAccountMapData(new AzureLocation("westus"), IntegrationAccountMapType.Xslt) - { - Content = BinaryData.FromString("\"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\""), - ContentType = new ContentType("application/xml"), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - }; - ArmOperation lro = await integrationAccountMap.UpdateAsync(WaitUntil.Completed, data); - IntegrationAccountMapResource result = lro.Value; + await integrationAccountMap.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAMapLargerThan4MB() + public async Task Update_CreateOrUpdateAMap() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountLargeMaps_CreateOrUpdate.json + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_CreateOrUpdate.json // this example is just showing the usage of "IntegrationAccountMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -102,7 +88,7 @@ public async Task Update_CreateOrUpdateAMapLargerThan4MB() // this example assumes you already have this IntegrationAccountMapResource created on azure // for more information of creating IntegrationAccountMapResource, please refer to the document of IntegrationAccountMapResource - string subscriptionId = ""; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "testResourceGroup"; string integrationAccountName = "testIntegrationAccount"; string mapName = "testMap"; @@ -112,10 +98,9 @@ public async Task Update_CreateOrUpdateAMapLargerThan4MB() // invoke the operation IntegrationAccountMapData data = new IntegrationAccountMapData(new AzureLocation("westus"), IntegrationAccountMapType.Xslt) { + Content = BinaryData.FromObjectAsJson("\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), ContentType = new ContentType("application/xml"), - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), + Metadata = BinaryData.FromObjectAsJson(new object()), }; ArmOperation lro = await integrationAccountMap.UpdateAsync(WaitUntil.Completed, data); IntegrationAccountMapResource result = lro.Value; @@ -129,10 +114,10 @@ public async Task Update_CreateOrUpdateAMapLargerThan4MB() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAMap() + public async Task Update_CreateOrUpdateAMapLargerThan4MB() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountMaps_Delete.json - // this example is just showing the usage of "IntegrationAccountMaps_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountLargeMaps_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,7 +126,7 @@ public async Task Delete_DeleteAMap() // this example assumes you already have this IntegrationAccountMapResource created on azure // for more information of creating IntegrationAccountMapResource, please refer to the document of IntegrationAccountMapResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = ""; string resourceGroupName = "testResourceGroup"; string integrationAccountName = "testIntegrationAccount"; string mapName = "testMap"; @@ -149,9 +134,19 @@ public async Task Delete_DeleteAMap() IntegrationAccountMapResource integrationAccountMap = client.GetIntegrationAccountMapResource(integrationAccountMapResourceId); // invoke the operation - await integrationAccountMap.DeleteAsync(WaitUntil.Completed); + IntegrationAccountMapData data = new IntegrationAccountMapData(new AzureLocation("westus"), IntegrationAccountMapType.Xslt) + { + ContentType = new ContentType("application/xml"), + Metadata = BinaryData.FromObjectAsJson(new object()), + }; + ArmOperation lro = await integrationAccountMap.UpdateAsync(WaitUntil.Completed, data); + IntegrationAccountMapResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -176,7 +171,7 @@ public async Task GetContentCallbackUrl_GetTheContentCallbackUrl() IntegrationAccountMapResource integrationAccountMap = client.GetIntegrationAccountMapResource(integrationAccountMapResourceId); // invoke the operation - ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo() + ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo { NotAfter = DateTimeOffset.Parse("2018-04-19T16:00:00Z"), KeyType = LogicKeyType.Primary, diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountPartnerCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountPartnerCollection.cs index 0c0912d5b74e7..62cac3a4e5142 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountPartnerCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountPartnerCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_IntegrationAccountPartnerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetPartnersByIntegrationAccountName() + public async Task CreateOrUpdate_CreateOrUpdateAPartner() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_List.json - // this example is just showing the usage of "IntegrationAccountPartners_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountPartners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +39,24 @@ public async Task GetAll_GetPartnersByIntegrationAccountName() // get the collection of this IntegrationAccountPartnerResource IntegrationAccountPartnerCollection collection = integrationAccount.GetIntegrationAccountPartners(); - // invoke the operation and iterate over the result - await foreach (IntegrationAccountPartnerResource item in collection.GetAllAsync()) + // invoke the operation + string partnerName = "testPartner"; + IntegrationAccountPartnerData data = new IntegrationAccountPartnerData(new AzureLocation("westus"), IntegrationAccountPartnerType.B2B, new IntegrationAccountPartnerContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountPartnerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + B2BBusinessIdentities = { new IntegrationAccountBusinessIdentity("AA", "ZZ") }, + }) + { + Metadata = BinaryData.FromObjectAsJson(new object()), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerName, data); + IntegrationAccountPartnerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountPartnerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +95,10 @@ public async Task Get_GetPartnerByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPartnerByName() + public async Task GetAll_GetPartnersByIntegrationAccountName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_Get.json - // this example is just showing the usage of "IntegrationAccountPartners_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_List.json + // this example is just showing the usage of "IntegrationAccountPartners_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +116,22 @@ public async Task Exists_GetPartnerByName() // get the collection of this IntegrationAccountPartnerResource IntegrationAccountPartnerCollection collection = integrationAccount.GetIntegrationAccountPartners(); - // invoke the operation - string partnerName = "testPartner"; - bool result = await collection.ExistsAsync(partnerName); + // invoke the operation and iterate over the result + await foreach (IntegrationAccountPartnerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountPartnerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPartnerByName() + public async Task Exists_GetPartnerByName() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_Get.json // this example is just showing the usage of "IntegrationAccountPartners_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +154,17 @@ public async Task GetIfExists_GetPartnerByName() // invoke the operation string partnerName = "testPartner"; - NullableResponse response = await collection.GetIfExistsAsync(partnerName); - IntegrationAccountPartnerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(partnerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountPartnerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAPartner() + public async Task GetIfExists_GetPartnerByName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountPartners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_Get.json + // this example is just showing the usage of "IntegrationAccountPartners_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,29 +184,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAPartner() // invoke the operation string partnerName = "testPartner"; - IntegrationAccountPartnerData data = new IntegrationAccountPartnerData(new AzureLocation("westus"), IntegrationAccountPartnerType.B2B, new IntegrationAccountPartnerContent() + NullableResponse response = await collection.GetIfExistsAsync(partnerName); + IntegrationAccountPartnerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - B2BBusinessIdentities = -{ -new IntegrationAccountBusinessIdentity("AA","ZZ") -}, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerName, data); - IntegrationAccountPartnerResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountPartnerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountPartnerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountPartnerResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountPartnerResource.cs index bad203a5e4334..89bbc3a9e204c 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountPartnerResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountPartnerResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -50,10 +49,10 @@ public async Task Get_GetPartnerByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAPartner() + public async Task Delete_DeleteAPartner() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountPartners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_Delete.json + // this example is just showing the usage of "IntegrationAccountPartners_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,37 +69,17 @@ public async Task Update_CreateOrUpdateAPartner() IntegrationAccountPartnerResource integrationAccountPartner = client.GetIntegrationAccountPartnerResource(integrationAccountPartnerResourceId); // invoke the operation - IntegrationAccountPartnerData data = new IntegrationAccountPartnerData(new AzureLocation("westus"), IntegrationAccountPartnerType.B2B, new IntegrationAccountPartnerContent() - { - B2BBusinessIdentities = -{ -new IntegrationAccountBusinessIdentity("AA","ZZ") -}, - }) - { - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - Tags = -{ -}, - }; - ArmOperation lro = await integrationAccountPartner.UpdateAsync(WaitUntil.Completed, data); - IntegrationAccountPartnerResource result = lro.Value; + await integrationAccountPartner.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountPartnerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPartner() + public async Task Update_CreateOrUpdateAPartner() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_Delete.json - // this example is just showing the usage of "IntegrationAccountPartners_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountPartners_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountPartners_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,9 +96,22 @@ public async Task Delete_DeleteAPartner() IntegrationAccountPartnerResource integrationAccountPartner = client.GetIntegrationAccountPartnerResource(integrationAccountPartnerResourceId); // invoke the operation - await integrationAccountPartner.DeleteAsync(WaitUntil.Completed); + IntegrationAccountPartnerData data = new IntegrationAccountPartnerData(new AzureLocation("westus"), IntegrationAccountPartnerType.B2B, new IntegrationAccountPartnerContent + { + B2BBusinessIdentities = { new IntegrationAccountBusinessIdentity("AA", "ZZ") }, + }) + { + Metadata = BinaryData.FromObjectAsJson(new object()), + Tags = { }, + }; + ArmOperation lro = await integrationAccountPartner.UpdateAsync(WaitUntil.Completed, data); + IntegrationAccountPartnerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountPartnerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -144,7 +136,7 @@ public async Task GetContentCallbackUrl_GetTheContentCallbackUrl() IntegrationAccountPartnerResource integrationAccountPartner = client.GetIntegrationAccountPartnerResource(integrationAccountPartnerResourceId); // invoke the operation - ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo() + ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo { NotAfter = DateTimeOffset.Parse("2018-04-19T16:00:00Z"), KeyType = LogicKeyType.Primary, diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountResource.cs index e90829127dca1..b435078e88f74 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountResource.cs @@ -6,49 +6,16 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Logic.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Logic.Samples { public partial class Sample_IntegrationAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIntegrationAccounts_ListIntegrationAccountsBySubscription() - { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_ListBySubscription.json - // this example is just showing the usage of "IntegrationAccounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (IntegrationAccountResource item in subscriptionResource.GetIntegrationAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetIntegrationAccountByName() @@ -81,10 +48,10 @@ public async Task Get_GetIntegrationAccountByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchAnIntegrationAccount() + public async Task Delete_DeleteAnIntegrationAccount() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_Update.json - // this example is just showing the usage of "IntegrationAccounts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_Delete.json + // this example is just showing the usage of "IntegrationAccounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,25 +67,17 @@ public async Task Update_PatchAnIntegrationAccount() IntegrationAccountResource integrationAccount = client.GetIntegrationAccountResource(integrationAccountResourceId); // invoke the operation - IntegrationAccountData data = new IntegrationAccountData(new AzureLocation("westus")) - { - SkuName = IntegrationAccountSkuName.Standard, - }; - IntegrationAccountResource result = await integrationAccount.UpdateAsync(data); + await integrationAccount.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnIntegrationAccount() + public async Task Update_PatchAnIntegrationAccount() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_Delete.json - // this example is just showing the usage of "IntegrationAccounts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_Update.json + // this example is just showing the usage of "IntegrationAccounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,9 +93,17 @@ public async Task Delete_DeleteAnIntegrationAccount() IntegrationAccountResource integrationAccount = client.GetIntegrationAccountResource(integrationAccountResourceId); // invoke the operation - await integrationAccount.DeleteAsync(WaitUntil.Completed); + IntegrationAccountData data = new IntegrationAccountData(new AzureLocation("westus")) + { + SkuName = IntegrationAccountSkuName.Standard, + }; + IntegrationAccountResource result = await integrationAccount.UpdateAsync(data); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -160,7 +127,7 @@ public async Task GetCallbackUrl_ListIntegrationAccountCallbackURL() IntegrationAccountResource integrationAccount = client.GetIntegrationAccountResource(integrationAccountResourceId); // invoke the operation - ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo() + ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo { NotAfter = DateTimeOffset.Parse("2017-03-05T08:00:00Z"), KeyType = LogicKeyType.Primary, @@ -191,7 +158,7 @@ public async Task GetKeyVaultKeys_GetIntegrationAccountCallbackURL() IntegrationAccountResource integrationAccount = client.GetIntegrationAccountResource(integrationAccountResourceId); // invoke the operation and iterate over the result - IntegrationAccountListKeyVaultKeyContent content = new IntegrationAccountListKeyVaultKeyContent(new IntegrationAccountKeyVaultNameReference() + IntegrationAccountListKeyVaultKeyContent content = new IntegrationAccountListKeyVaultKeyContent(new IntegrationAccountKeyVaultNameReference { Id = new ResourceIdentifier("subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.KeyVault/vaults/testKeyVault"), }) @@ -229,32 +196,35 @@ public async Task LogTrackingEvents_LogATrackedEvent() // invoke the operation IntegrationAccountTrackingEventsContent content = new IntegrationAccountTrackingEventsContent("Microsoft.Logic/workflows", new IntegrationAccountTrackingEvent[] { -new IntegrationAccountTrackingEvent(IntegrationAccountEventLevel.Informational,DateTimeOffset.Parse("2016-08-05T01:54:49.505567Z"),IntegrationAccountTrackingRecordType.AS2Message) +new IntegrationAccountTrackingEvent(IntegrationAccountEventLevel.Informational, DateTimeOffset.Parse("2016-08-05T01:54:49.505567Z"), IntegrationAccountTrackingRecordType.AS2Message) { -Record = BinaryData.FromObjectAsJson(new Dictionary() +Record = BinaryData.FromObjectAsJson(new { -["agreementProperties"] = new Dictionary() +agreementProperties = new { -["agreementName"] = "testAgreement", -["as2From"] = "testas2from", -["as2To"] = "testas2to", -["receiverPartnerName"] = "testPartner2", -["senderPartnerName"] = "testPartner1"}, -["messageProperties"] = new Dictionary() +agreementName = "testAgreement", +as2From = "testas2from", +as2To = "testas2to", +receiverPartnerName = "testPartner2", +senderPartnerName = "testPartner1", +}, +messageProperties = new { -["IsMessageEncrypted"] = "false", -["IsMessageSigned"] = "false", -["correlationMessageId"] = "Unique message identifier", -["direction"] = "Receive", -["dispositionType"] = "received-success", -["fileName"] = "test", -["isMdnExpected"] = "true", -["isMessageCompressed"] = "false", -["isMessageFailed"] = "false", -["isNrrEnabled"] = "true", -["mdnType"] = "Async", -["messageId"] = "12345"}}), -Error = new IntegrationAccountTrackingEventErrorInfo() +IsMessageEncrypted = "false", +IsMessageSigned = "false", +correlationMessageId = "Unique message identifier", +direction = "Receive", +dispositionType = "received-success", +fileName = "test", +isMdnExpected = "true", +isMessageCompressed = "false", +isMessageFailed = "false", +isNrrEnabled = "true", +mdnType = "Async", +messageId = "12345", +}, +}), +Error = new IntegrationAccountTrackingEventErrorInfo { Message = "Some error occurred", Code = "NotFound", @@ -287,7 +257,7 @@ public async Task RegenerateAccessKey_RegenerateAccessKey() IntegrationAccountResource integrationAccount = client.GetIntegrationAccountResource(integrationAccountResourceId); // invoke the operation - LogicWorkflowRegenerateActionContent content = new LogicWorkflowRegenerateActionContent() + LogicWorkflowRegenerateActionContent content = new LogicWorkflowRegenerateActionContent { KeyType = LogicKeyType.Primary, }; diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSchemaCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSchemaCollection.cs index 343d99902409c..9f49d5e7b7425 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSchemaCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSchemaCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_IntegrationAccountSchemaCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSchemasByIntegrationAccountName() + public async Task CreateOrUpdate_CreateOrUpdateSchema() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_List.json - // this example is just showing the usage of "IntegrationAccountSchemas_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountSchemas_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,26 +30,35 @@ public async Task GetAll_GetSchemasByIntegrationAccountName() // this example assumes you already have this IntegrationAccountResource created on azure // for more information of creating IntegrationAccountResource, please refer to the document of IntegrationAccountResource - string subscriptionId = ""; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroupName = "testResourceGroup"; - string integrationAccountName = ""; + string integrationAccountName = "testIntegrationAccount"; ResourceIdentifier integrationAccountResourceId = IntegrationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, integrationAccountName); IntegrationAccountResource integrationAccount = client.GetIntegrationAccountResource(integrationAccountResourceId); // get the collection of this IntegrationAccountSchemaResource IntegrationAccountSchemaCollection collection = integrationAccount.GetIntegrationAccountSchemas(); - // invoke the operation and iterate over the result - await foreach (IntegrationAccountSchemaResource item in collection.GetAllAsync()) + // invoke the operation + string schemaName = "testSchema"; + IntegrationAccountSchemaData data = new IntegrationAccountSchemaData(new AzureLocation("westus"), IntegrationAccountSchemaType.Xml) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountSchemaData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Metadata = BinaryData.FromObjectAsJson(new object()), + Content = BinaryData.FromObjectAsJson("\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), + ContentType = new ContentType("application/xml"), + Tags = +{ +["integrationAccountSchemaName"] = "IntegrationAccountSchema8120" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaName, data); + IntegrationAccountSchemaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +97,10 @@ public async Task Get_GetSchemaByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSchemaByName() + public async Task GetAll_GetSchemasByIntegrationAccountName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_Get.json - // this example is just showing the usage of "IntegrationAccountSchemas_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_List.json + // this example is just showing the usage of "IntegrationAccountSchemas_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,25 +109,31 @@ public async Task Exists_GetSchemaByName() // this example assumes you already have this IntegrationAccountResource created on azure // for more information of creating IntegrationAccountResource, please refer to the document of IntegrationAccountResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string subscriptionId = ""; string resourceGroupName = "testResourceGroup"; - string integrationAccountName = "testIntegrationAccount"; + string integrationAccountName = ""; ResourceIdentifier integrationAccountResourceId = IntegrationAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, integrationAccountName); IntegrationAccountResource integrationAccount = client.GetIntegrationAccountResource(integrationAccountResourceId); // get the collection of this IntegrationAccountSchemaResource IntegrationAccountSchemaCollection collection = integrationAccount.GetIntegrationAccountSchemas(); - // invoke the operation - string schemaName = "testSchema"; - bool result = await collection.ExistsAsync(schemaName); + // invoke the operation and iterate over the result + await foreach (IntegrationAccountSchemaResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountSchemaData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSchemaByName() + public async Task Exists_GetSchemaByName() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_Get.json // this example is just showing the usage of "IntegrationAccountSchemas_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +156,17 @@ public async Task GetIfExists_GetSchemaByName() // invoke the operation string schemaName = "testSchema"; - NullableResponse response = await collection.GetIfExistsAsync(schemaName); - IntegrationAccountSchemaResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(schemaName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateSchema() + public async Task GetIfExists_GetSchemaByName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountSchemas_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_Get.json + // this example is just showing the usage of "IntegrationAccountSchemas_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,26 +186,21 @@ public async Task CreateOrUpdate_CreateOrUpdateSchema() // invoke the operation string schemaName = "testSchema"; - IntegrationAccountSchemaData data = new IntegrationAccountSchemaData(new AzureLocation("westus"), IntegrationAccountSchemaType.Xml) - { - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - Content = BinaryData.FromString("\"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\""), - ContentType = new ContentType("application/xml"), - Tags = -{ -["integrationAccountSchemaName"] = "IntegrationAccountSchema8120", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, schemaName, data); - IntegrationAccountSchemaResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(schemaName); + IntegrationAccountSchemaResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSchemaResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSchemaResource.cs index 81b644b7df633..0b9926e2f1fd6 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSchemaResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSchemaResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -50,10 +49,10 @@ public async Task Get_GetSchemaByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateSchema() + public async Task Delete_DeleteASchemaByName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountSchemas_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_Delete.json + // this example is just showing the usage of "IntegrationAccountSchemas_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,34 +69,17 @@ public async Task Update_CreateOrUpdateSchema() IntegrationAccountSchemaResource integrationAccountSchema = client.GetIntegrationAccountSchemaResource(integrationAccountSchemaResourceId); // invoke the operation - IntegrationAccountSchemaData data = new IntegrationAccountSchemaData(new AzureLocation("westus"), IntegrationAccountSchemaType.Xml) - { - Metadata = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - Content = BinaryData.FromString("\"\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n\""), - ContentType = new ContentType("application/xml"), - Tags = -{ -["integrationAccountSchemaName"] = "IntegrationAccountSchema8120", -}, - }; - ArmOperation lro = await integrationAccountSchema.UpdateAsync(WaitUntil.Completed, data); - IntegrationAccountSchemaResource result = lro.Value; + await integrationAccountSchema.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountSchemaData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASchemaByName() + public async Task Update_CreateOrUpdateSchema() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_Delete.json - // this example is just showing the usage of "IntegrationAccountSchemas_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSchemas_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountSchemas_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +96,24 @@ public async Task Delete_DeleteASchemaByName() IntegrationAccountSchemaResource integrationAccountSchema = client.GetIntegrationAccountSchemaResource(integrationAccountSchemaResourceId); // invoke the operation - await integrationAccountSchema.DeleteAsync(WaitUntil.Completed); + IntegrationAccountSchemaData data = new IntegrationAccountSchemaData(new AzureLocation("westus"), IntegrationAccountSchemaType.Xml) + { + Metadata = BinaryData.FromObjectAsJson(new object()), + Content = BinaryData.FromObjectAsJson("\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n"), + ContentType = new ContentType("application/xml"), + Tags = +{ +["integrationAccountSchemaName"] = "IntegrationAccountSchema8120" +}, + }; + ArmOperation lro = await integrationAccountSchema.UpdateAsync(WaitUntil.Completed, data); + IntegrationAccountSchemaResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountSchemaData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -141,7 +138,7 @@ public async Task GetContentCallbackUrl_GetTheContentCallbackUrl() IntegrationAccountSchemaResource integrationAccountSchema = client.GetIntegrationAccountSchemaResource(integrationAccountSchemaResourceId); // invoke the operation - ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo() + ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo { NotAfter = DateTimeOffset.Parse("2018-04-19T16:00:00Z"), KeyType = LogicKeyType.Primary, diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSessionCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSessionCollection.cs index 1bb75e79aac8f..8b3be5495a9dd 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSessionCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSessionCollection.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -18,10 +17,10 @@ public partial class Sample_IntegrationAccountSessionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAListOfIntegrationAccountSessions() + public async Task CreateOrUpdate_CreateOrUpdateAnIntegrationAccountSession() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_List.json - // this example is just showing the usage of "IntegrationAccountSessions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountSessions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +38,24 @@ public async Task GetAll_GetAListOfIntegrationAccountSessions() // get the collection of this IntegrationAccountSessionResource IntegrationAccountSessionCollection collection = integrationAccount.GetIntegrationAccountSessions(); - // invoke the operation and iterate over the result - await foreach (IntegrationAccountSessionResource item in collection.GetAllAsync()) + // invoke the operation + string sessionName = "testsession123-ICN"; + IntegrationAccountSessionData data = new IntegrationAccountSessionData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountSessionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Content = BinaryData.FromObjectAsJson(new + { + controlNumber = "1234", + controlNumberChangedTime = "2017-02-21T22:30:11.9923759Z", + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sessionName, data); + IntegrationAccountSessionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountSessionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +94,10 @@ public async Task Get_GetAnIntegrationAccountSession() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnIntegrationAccountSession() + public async Task GetAll_GetAListOfIntegrationAccountSessions() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_Get.json - // this example is just showing the usage of "IntegrationAccountSessions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_List.json + // this example is just showing the usage of "IntegrationAccountSessions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +115,22 @@ public async Task Exists_GetAnIntegrationAccountSession() // get the collection of this IntegrationAccountSessionResource IntegrationAccountSessionCollection collection = integrationAccount.GetIntegrationAccountSessions(); - // invoke the operation - string sessionName = "testsession123-ICN"; - bool result = await collection.ExistsAsync(sessionName); + // invoke the operation and iterate over the result + await foreach (IntegrationAccountSessionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountSessionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnIntegrationAccountSession() + public async Task Exists_GetAnIntegrationAccountSession() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_Get.json // this example is just showing the usage of "IntegrationAccountSessions_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +153,17 @@ public async Task GetIfExists_GetAnIntegrationAccountSession() // invoke the operation string sessionName = "testsession123-ICN"; - NullableResponse response = await collection.GetIfExistsAsync(sessionName); - IntegrationAccountSessionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sessionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountSessionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnIntegrationAccountSession() + public async Task GetIfExists_GetAnIntegrationAccountSession() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountSessions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_Get.json + // this example is just showing the usage of "IntegrationAccountSessions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +183,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAnIntegrationAccountSession() // invoke the operation string sessionName = "testsession123-ICN"; - IntegrationAccountSessionData data = new IntegrationAccountSessionData(new AzureLocation("placeholder")) - { - Content = BinaryData.FromObjectAsJson(new Dictionary() - { - ["controlNumber"] = "1234", - ["controlNumberChangedTime"] = "2017-02-21T22:30:11.9923759Z" - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sessionName, data); - IntegrationAccountSessionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(sessionName); + IntegrationAccountSessionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountSessionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountSessionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSessionResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSessionResource.cs index 5af42e1e69180..94793f00a2eab 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSessionResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationAccountSessionResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -49,10 +48,10 @@ public async Task Get_GetAnIntegrationAccountSession() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAnIntegrationAccountSession() + public async Task Delete_DeleteAnIntegrationAccountSession() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_CreateOrUpdate.json - // this example is just showing the usage of "IntegrationAccountSessions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_Delete.json + // this example is just showing the usage of "IntegrationAccountSessions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +68,17 @@ public async Task Update_CreateOrUpdateAnIntegrationAccountSession() IntegrationAccountSessionResource integrationAccountSession = client.GetIntegrationAccountSessionResource(integrationAccountSessionResourceId); // invoke the operation - IntegrationAccountSessionData data = new IntegrationAccountSessionData(new AzureLocation("placeholder")) - { - Content = BinaryData.FromObjectAsJson(new Dictionary() - { - ["controlNumber"] = "1234", - ["controlNumberChangedTime"] = "2017-02-21T22:30:11.9923759Z" - }), - }; - ArmOperation lro = await integrationAccountSession.UpdateAsync(WaitUntil.Completed, data); - IntegrationAccountSessionResource result = lro.Value; + await integrationAccountSession.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationAccountSessionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnIntegrationAccountSession() + public async Task Update_CreateOrUpdateAnIntegrationAccountSession() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_Delete.json - // this example is just showing the usage of "IntegrationAccountSessions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccountSessions_CreateOrUpdate.json + // this example is just showing the usage of "IntegrationAccountSessions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +95,22 @@ public async Task Delete_DeleteAnIntegrationAccountSession() IntegrationAccountSessionResource integrationAccountSession = client.GetIntegrationAccountSessionResource(integrationAccountSessionResourceId); // invoke the operation - await integrationAccountSession.DeleteAsync(WaitUntil.Completed); + IntegrationAccountSessionData data = new IntegrationAccountSessionData(default) + { + Content = BinaryData.FromObjectAsJson(new + { + controlNumber = "1234", + controlNumberChangedTime = "2017-02-21T22:30:11.9923759Z", + }), + }; + ArmOperation lro = await integrationAccountSession.UpdateAsync(WaitUntil.Completed, data); + IntegrationAccountSessionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountSessionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentCollection.cs index 9f486dc270c51..d455c2df2bae1 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_IntegrationServiceEnvironmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIntegrationServiceEnvironmentsByResourceGroupName() + public async Task CreateOrUpdate_CreateOrUpdateAnIntegrationServiceEnvironment() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ListByResourceGroup.json - // this example is just showing the usage of "IntegrationServiceEnvironments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_Put.json + // this example is just showing the usage of "IntegrationServiceEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,53 @@ public async Task GetAll_ListIntegrationServiceEnvironmentsByResourceGroupName() // get the collection of this IntegrationServiceEnvironmentResource IntegrationServiceEnvironmentCollection collection = resourceGroupResource.GetIntegrationServiceEnvironments(); - // invoke the operation and iterate over the result - await foreach (IntegrationServiceEnvironmentResource item in collection.GetAllAsync()) + // invoke the operation + string integrationServiceEnvironmentName = "testIntegrationServiceEnvironment"; + IntegrationServiceEnvironmentData data = new IntegrationServiceEnvironmentData(new AzureLocation("brazilsouth")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationServiceEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new IntegrationServiceEnvironmentProperties + { + NetworkConfiguration = new IntegrationServiceNetworkConfiguration + { + EndpointType = IntegrationServiceEnvironmentAccessEndpointType.Internal, + Subnets = {new LogicResourceReference +{ +Id = new ResourceIdentifier("/subscriptions/f34b22a3-2202-4fb1-b040-1332bd928c84/resourceGroups/testResourceGroup/providers/Microsoft.Network/virtualNetworks/testVNET/subnets/s1"), +}, new LogicResourceReference +{ +Id = new ResourceIdentifier("/subscriptions/f34b22a3-2202-4fb1-b040-1332bd928c84/resourceGroups/testResourceGroup/providers/Microsoft.Network/virtualNetworks/testVNET/subnets/s2"), +}, new LogicResourceReference +{ +Id = new ResourceIdentifier("/subscriptions/f34b22a3-2202-4fb1-b040-1332bd928c84/resourceGroups/testResourceGroup/providers/Microsoft.Network/virtualNetworks/testVNET/subnets/s3"), +}, new LogicResourceReference +{ +Id = new ResourceIdentifier("/subscriptions/f34b22a3-2202-4fb1-b040-1332bd928c84/resourceGroups/testResourceGroup/providers/Microsoft.Network/virtualNetworks/testVNET/subnets/s4"), +}}, + }, + EncryptionKeyReference = new IntegrationServiceEnvironmenEncryptionKeyReference + { + KeyVault = new LogicResourceReference + { + Id = new ResourceIdentifier("/subscriptions/f34b22a3-2202-4fb1-b040-1332bd928c84/resourceGroups/testResourceGroup/providers/Microsoft.KeyVault/vaults/testKeyVault"), + }, + KeyName = "testKeyName", + KeyVersion = "13b261d30b984753869902d7f47f4d55", + }, + }, + Sku = new IntegrationServiceEnvironmentSku + { + Name = IntegrationServiceEnvironmentSkuName.Premium, + Capacity = 2, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, integrationServiceEnvironmentName, data); + IntegrationServiceEnvironmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationServiceEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +123,10 @@ public async Task Get_GetIntegrationServiceEnvironmentByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetIntegrationServiceEnvironmentByName() + public async Task GetAll_ListIntegrationServiceEnvironmentsByResourceGroupName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_Get.json - // this example is just showing the usage of "IntegrationServiceEnvironments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ListByResourceGroup.json + // this example is just showing the usage of "IntegrationServiceEnvironments_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +143,22 @@ public async Task Exists_GetIntegrationServiceEnvironmentByName() // get the collection of this IntegrationServiceEnvironmentResource IntegrationServiceEnvironmentCollection collection = resourceGroupResource.GetIntegrationServiceEnvironments(); - // invoke the operation - string integrationServiceEnvironmentName = "testIntegrationServiceEnvironment"; - bool result = await collection.ExistsAsync(integrationServiceEnvironmentName); + // invoke the operation and iterate over the result + await foreach (IntegrationServiceEnvironmentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationServiceEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetIntegrationServiceEnvironmentByName() + public async Task Exists_GetIntegrationServiceEnvironmentByName() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_Get.json // this example is just showing the usage of "IntegrationServiceEnvironments_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +180,17 @@ public async Task GetIfExists_GetIntegrationServiceEnvironmentByName() // invoke the operation string integrationServiceEnvironmentName = "testIntegrationServiceEnvironment"; - NullableResponse response = await collection.GetIfExistsAsync(integrationServiceEnvironmentName); - IntegrationServiceEnvironmentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(integrationServiceEnvironmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationServiceEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnIntegrationServiceEnvironment() + public async Task GetIfExists_GetIntegrationServiceEnvironmentByName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_Put.json - // this example is just showing the usage of "IntegrationServiceEnvironments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_Get.json + // this example is just showing the usage of "IntegrationServiceEnvironments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,54 +209,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAnIntegrationServiceEnvironment() // invoke the operation string integrationServiceEnvironmentName = "testIntegrationServiceEnvironment"; - IntegrationServiceEnvironmentData data = new IntegrationServiceEnvironmentData(new AzureLocation("brazilsouth")) - { - Properties = new IntegrationServiceEnvironmentProperties() - { - NetworkConfiguration = new IntegrationServiceNetworkConfiguration() - { - EndpointType = IntegrationServiceEnvironmentAccessEndpointType.Internal, - Subnets = -{ -new LogicResourceReference() -{ -Id = new ResourceIdentifier("/subscriptions/f34b22a3-2202-4fb1-b040-1332bd928c84/resourceGroups/testResourceGroup/providers/Microsoft.Network/virtualNetworks/testVNET/subnets/s1"), -},new LogicResourceReference() -{ -Id = new ResourceIdentifier("/subscriptions/f34b22a3-2202-4fb1-b040-1332bd928c84/resourceGroups/testResourceGroup/providers/Microsoft.Network/virtualNetworks/testVNET/subnets/s2"), -},new LogicResourceReference() -{ -Id = new ResourceIdentifier("/subscriptions/f34b22a3-2202-4fb1-b040-1332bd928c84/resourceGroups/testResourceGroup/providers/Microsoft.Network/virtualNetworks/testVNET/subnets/s3"), -},new LogicResourceReference() -{ -Id = new ResourceIdentifier("/subscriptions/f34b22a3-2202-4fb1-b040-1332bd928c84/resourceGroups/testResourceGroup/providers/Microsoft.Network/virtualNetworks/testVNET/subnets/s4"), -} -}, - }, - EncryptionKeyReference = new IntegrationServiceEnvironmenEncryptionKeyReference() - { - KeyVault = new LogicResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/f34b22a3-2202-4fb1-b040-1332bd928c84/resourceGroups/testResourceGroup/providers/Microsoft.KeyVault/vaults/testKeyVault"), - }, - KeyName = "testKeyName", - KeyVersion = "13b261d30b984753869902d7f47f4d55", - }, - }, - Sku = new IntegrationServiceEnvironmentSku() - { - Name = IntegrationServiceEnvironmentSkuName.Premium, - Capacity = 2, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, integrationServiceEnvironmentName, data); - IntegrationServiceEnvironmentResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(integrationServiceEnvironmentName); + IntegrationServiceEnvironmentResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationServiceEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationServiceEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentManagedApiCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentManagedApiCollection.cs index 29ae11ab260cc..0b178e1fb87f3 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentManagedApiCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentManagedApiCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_IntegrationServiceEnvironmentManagedApiCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheIntegrationServiceEnvironmentManagedApis() + public async Task CreateOrUpdate_GetsTheIntegrationServiceEnvironmentManagedApis() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_List.json - // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_Put.json + // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_GetsTheIntegrationServiceEnvironmentManagedApis() // get the collection of this IntegrationServiceEnvironmentManagedApiResource IntegrationServiceEnvironmentManagedApiCollection collection = integrationServiceEnvironment.GetIntegrationServiceEnvironmentManagedApis(); - // invoke the operation and iterate over the result - await foreach (IntegrationServiceEnvironmentManagedApiResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationServiceEnvironmentManagedApiData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string apiName = "servicebus"; + IntegrationServiceEnvironmentManagedApiData data = new IntegrationServiceEnvironmentManagedApiData(new AzureLocation("brazilsouth")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiName, data); + IntegrationServiceEnvironmentManagedApiResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationServiceEnvironmentManagedApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_GetsTheIntegrationServiceEnvironmentManagedApis() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheIntegrationServiceEnvironmentManagedApis() + public async Task GetAll_GetsTheIntegrationServiceEnvironmentManagedApis() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_Get.json - // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_List.json + // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_GetsTheIntegrationServiceEnvironmentManagedApis() // get the collection of this IntegrationServiceEnvironmentManagedApiResource IntegrationServiceEnvironmentManagedApiCollection collection = integrationServiceEnvironment.GetIntegrationServiceEnvironmentManagedApis(); - // invoke the operation - string apiName = "servicebus"; - bool result = await collection.ExistsAsync(apiName); + // invoke the operation and iterate over the result + await foreach (IntegrationServiceEnvironmentManagedApiResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationServiceEnvironmentManagedApiData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheIntegrationServiceEnvironmentManagedApis() + public async Task Exists_GetsTheIntegrationServiceEnvironmentManagedApis() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_Get.json // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_GetsTheIntegrationServiceEnvironmentManagedApis() // invoke the operation string apiName = "servicebus"; - NullableResponse response = await collection.GetIfExistsAsync(apiName); - IntegrationServiceEnvironmentManagedApiResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(apiName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationServiceEnvironmentManagedApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_GetsTheIntegrationServiceEnvironmentManagedApis() + public async Task GetIfExists_GetsTheIntegrationServiceEnvironmentManagedApis() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_Put.json - // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_Get.json + // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_GetsTheIntegrationServiceEnvironmentManagedApis // invoke the operation string apiName = "servicebus"; - IntegrationServiceEnvironmentManagedApiData data = new IntegrationServiceEnvironmentManagedApiData(new AzureLocation("brazilsouth")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, apiName, data); - IntegrationServiceEnvironmentManagedApiResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(apiName); + IntegrationServiceEnvironmentManagedApiResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationServiceEnvironmentManagedApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationServiceEnvironmentManagedApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentManagedApiResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentManagedApiResource.cs index 2437801670696..30b6c832b072a 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentManagedApiResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentManagedApiResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsTheIntegrationServiceEnvironmentManagedApis() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_GetsTheIntegrationServiceEnvironmentManagedApis() + public async Task Delete_DeletesTheIntegrationServiceEnvironmentManagedApis() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_Put.json - // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_Delete.json + // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,23 +69,17 @@ public async Task Update_GetsTheIntegrationServiceEnvironmentManagedApis() IntegrationServiceEnvironmentManagedApiResource integrationServiceEnvironmentManagedApi = client.GetIntegrationServiceEnvironmentManagedApiResource(integrationServiceEnvironmentManagedApiResourceId); // invoke the operation - IntegrationServiceEnvironmentManagedApiData data = new IntegrationServiceEnvironmentManagedApiData(new AzureLocation("brazilsouth")); - ArmOperation lro = await integrationServiceEnvironmentManagedApi.UpdateAsync(WaitUntil.Completed, data); - IntegrationServiceEnvironmentManagedApiResource result = lro.Value; + await integrationServiceEnvironmentManagedApi.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationServiceEnvironmentManagedApiData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesTheIntegrationServiceEnvironmentManagedApis() + public async Task Update_GetsTheIntegrationServiceEnvironmentManagedApis() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_Delete.json - // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ManagedApis_Put.json + // this example is just showing the usage of "IntegrationServiceEnvironmentManagedApis_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_DeletesTheIntegrationServiceEnvironmentManagedApis() IntegrationServiceEnvironmentManagedApiResource integrationServiceEnvironmentManagedApi = client.GetIntegrationServiceEnvironmentManagedApiResource(integrationServiceEnvironmentManagedApiResourceId); // invoke the operation - await integrationServiceEnvironmentManagedApi.DeleteAsync(WaitUntil.Completed); + IntegrationServiceEnvironmentManagedApiData data = new IntegrationServiceEnvironmentManagedApiData(new AzureLocation("brazilsouth")); + ArmOperation lro = await integrationServiceEnvironmentManagedApi.UpdateAsync(WaitUntil.Completed, data); + IntegrationServiceEnvironmentManagedApiResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationServiceEnvironmentManagedApiData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentResource.cs index 090acce281a8a..f0cf1c1ea66c0 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_IntegrationServiceEnvironmentResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Logic.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Logic.Samples @@ -20,41 +19,40 @@ public partial class Sample_IntegrationServiceEnvironmentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIntegrationServiceEnvironments_ListIntegrationServiceEnvironmentsBySubscription() + public async Task Get_GetIntegrationServiceEnvironmentByName() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ListBySubscription.json - // this example is just showing the usage of "IntegrationServiceEnvironments_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_Get.json + // this example is just showing the usage of "IntegrationServiceEnvironments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this IntegrationServiceEnvironmentResource created on azure + // for more information of creating IntegrationServiceEnvironmentResource, please refer to the document of IntegrationServiceEnvironmentResource string subscriptionId = "f34b22a3-2202-4fb1-b040-1332bd928c84"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroup = "testResourceGroup"; + string integrationServiceEnvironmentName = "testIntegrationServiceEnvironment"; + ResourceIdentifier integrationServiceEnvironmentResourceId = IntegrationServiceEnvironmentResource.CreateResourceIdentifier(subscriptionId, resourceGroup, integrationServiceEnvironmentName); + IntegrationServiceEnvironmentResource integrationServiceEnvironment = client.GetIntegrationServiceEnvironmentResource(integrationServiceEnvironmentResourceId); - // invoke the operation and iterate over the result - await foreach (IntegrationServiceEnvironmentResource item in subscriptionResource.GetIntegrationServiceEnvironmentsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationServiceEnvironmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + IntegrationServiceEnvironmentResource result = await integrationServiceEnvironment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationServiceEnvironmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetIntegrationServiceEnvironmentByName() + public async Task Delete_DeleteAnIntegrationAccount() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_Get.json - // this example is just showing the usage of "IntegrationServiceEnvironments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_Delete.json + // this example is just showing the usage of "IntegrationServiceEnvironments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,20 +61,16 @@ public async Task Get_GetIntegrationServiceEnvironmentByName() // this example assumes you already have this IntegrationServiceEnvironmentResource created on azure // for more information of creating IntegrationServiceEnvironmentResource, please refer to the document of IntegrationServiceEnvironmentResource - string subscriptionId = "f34b22a3-2202-4fb1-b040-1332bd928c84"; + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; string resourceGroup = "testResourceGroup"; string integrationServiceEnvironmentName = "testIntegrationServiceEnvironment"; ResourceIdentifier integrationServiceEnvironmentResourceId = IntegrationServiceEnvironmentResource.CreateResourceIdentifier(subscriptionId, resourceGroup, integrationServiceEnvironmentName); IntegrationServiceEnvironmentResource integrationServiceEnvironment = client.GetIntegrationServiceEnvironmentResource(integrationServiceEnvironmentResourceId); // invoke the operation - IntegrationServiceEnvironmentResource result = await integrationServiceEnvironment.GetAsync(); + await integrationServiceEnvironment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IntegrationServiceEnvironmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,16 +94,16 @@ public async Task Update_PatchAnIntegrationServiceEnvironment() IntegrationServiceEnvironmentResource integrationServiceEnvironment = client.GetIntegrationServiceEnvironmentResource(integrationServiceEnvironmentResourceId); // invoke the operation - IntegrationServiceEnvironmentData data = new IntegrationServiceEnvironmentData(new AzureLocation("placeholder")) + IntegrationServiceEnvironmentData data = new IntegrationServiceEnvironmentData(default) { - Sku = new IntegrationServiceEnvironmentSku() + Sku = new IntegrationServiceEnvironmentSku { Name = IntegrationServiceEnvironmentSkuName.Developer, Capacity = 0, }, Tags = { -["tag1"] = "value1", +["tag1"] = "value1" }, }; ArmOperation lro = await integrationServiceEnvironment.UpdateAsync(WaitUntil.Completed, data); @@ -122,32 +116,6 @@ public async Task Update_PatchAnIntegrationServiceEnvironment() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnIntegrationAccount() - { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_Delete.json - // this example is just showing the usage of "IntegrationServiceEnvironments_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this IntegrationServiceEnvironmentResource created on azure - // for more information of creating IntegrationServiceEnvironmentResource, please refer to the document of IntegrationServiceEnvironmentResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroup = "testResourceGroup"; - string integrationServiceEnvironmentName = "testIntegrationServiceEnvironment"; - ResourceIdentifier integrationServiceEnvironmentResourceId = IntegrationServiceEnvironmentResource.CreateResourceIdentifier(subscriptionId, resourceGroup, integrationServiceEnvironmentName); - IntegrationServiceEnvironmentResource integrationServiceEnvironment = client.GetIntegrationServiceEnvironmentResource(integrationServiceEnvironmentResourceId); - - // invoke the operation - await integrationServiceEnvironment.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Restart_RestartsAnIntegrationServiceEnvironment() diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowCollection.cs index 8cb1f6eedf06c..aefa8898eeb2f 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_LogicWorkflowCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllWorkflowsInAResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateAWorkflow() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_ListByResourceGroup.json - // this example is just showing the usage of "Workflows_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_CreateOrUpdate.json + // this example is just showing the usage of "Workflows_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,85 @@ public async Task GetAll_ListAllWorkflowsInAResourceGroup() // get the collection of this LogicWorkflowResource LogicWorkflowCollection collection = resourceGroupResource.GetLogicWorkflows(); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowResource item in collection.GetAllAsync()) + // invoke the operation + string workflowName = "test-workflow"; + LogicWorkflowData data = new LogicWorkflowData(new AzureLocation("brazilsouth")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IntegrationAccount = new LogicResourceReference + { + Id = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/integrationAccounts/test-integration-account"), + }, + Definition = BinaryData.FromObjectAsJson(new Dictionary + { + ["$schema"] = "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", + ["actions"] = new + { + Find_pet_by_ID = new + { + type = "ApiConnection", + inputs = new + { + path = "/pet/@{encodeURIComponent('1')}", + method = "get", + host = new + { + connection = new + { + name = "@parameters('$connections')['test-custom-connector']['connectionId']", + }, + }, + }, + runAfter = new object(), + }, + }, + ["contentVersion"] = "1.0.0.0", + ["outputs"] = new object(), + ["parameters"] = new Dictionary + { + ["$connections"] = new + { + type = "Object", + defaultValue = new object(), + } + }, + ["triggers"] = new + { + manual = new + { + type = "Request", + inputs = new + { + schema = new object(), + }, + kind = "Http", + }, + } + }), + Parameters = +{ +["$connections"] = new LogicWorkflowParameterInfo +{ +Value = BinaryData.FromObjectAsJson(new Dictionary +{ +["test-custom-connector"] = new +{ +connectionId = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Web/connections/test-custom-connector", +connectionName = "test-custom-connector", +id = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/providers/Microsoft.Web/locations/brazilsouth/managedApis/test-custom-connector", +} +}), +} +}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workflowName, data); + LogicWorkflowResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +156,10 @@ public async Task Get_GetAWorkflow() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAWorkflow() + public async Task GetAll_ListAllWorkflowsInAResourceGroup() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_Get.json - // this example is just showing the usage of "Workflows_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_ListByResourceGroup.json + // this example is just showing the usage of "Workflows_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +176,22 @@ public async Task Exists_GetAWorkflow() // get the collection of this LogicWorkflowResource LogicWorkflowCollection collection = resourceGroupResource.GetLogicWorkflows(); - // invoke the operation - string workflowName = "test-workflow"; - bool result = await collection.ExistsAsync(workflowName); + // invoke the operation and iterate over the result + await foreach (LogicWorkflowResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAWorkflow() + public async Task Exists_GetAWorkflow() { // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_Get.json // this example is just showing the usage of "Workflows_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +213,17 @@ public async Task GetIfExists_GetAWorkflow() // invoke the operation string workflowName = "test-workflow"; - NullableResponse response = await collection.GetIfExistsAsync(workflowName); - LogicWorkflowResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(workflowName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAWorkflow() + public async Task GetIfExists_GetAWorkflow() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_CreateOrUpdate.json - // this example is just showing the usage of "Workflows_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_Get.json + // this example is just showing the usage of "Workflows_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,91 +242,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAWorkflow() // invoke the operation string workflowName = "test-workflow"; - LogicWorkflowData data = new LogicWorkflowData(new AzureLocation("brazilsouth")) - { - IntegrationAccount = new LogicResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/integrationAccounts/test-integration-account"), - }, - Definition = BinaryData.FromObjectAsJson(new Dictionary() - { - ["$schema"] = "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", - ["actions"] = new Dictionary() - { - ["Find_pet_by_ID"] = new Dictionary() - { - ["type"] = "ApiConnection", - ["inputs"] = new Dictionary() - { - ["path"] = "/pet/@{encodeURIComponent('1')}", - ["method"] = "get", - ["host"] = new Dictionary() - { - ["connection"] = new Dictionary() - { - ["name"] = "@parameters('$connections')['test-custom-connector']['connectionId']" - } - } - }, - ["runAfter"] = new Dictionary() - { - } - } - }, - ["contentVersion"] = "1.0.0.0", - ["outputs"] = new Dictionary() - { - }, - ["parameters"] = new Dictionary() - { - ["$connections"] = new Dictionary() - { - ["type"] = "Object", - ["defaultValue"] = new Dictionary() - { - } - } - }, - ["triggers"] = new Dictionary() - { - ["manual"] = new Dictionary() - { - ["type"] = "Request", - ["inputs"] = new Dictionary() - { - ["schema"] = new Dictionary() - { - } - }, - ["kind"] = "Http" - } - } - }), - Parameters = -{ -["$connections"] = new LogicWorkflowParameterInfo() -{ -Value = BinaryData.FromObjectAsJson(new Dictionary() -{ -["test-custom-connector"] = new Dictionary() -{ -["connectionId"] = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Web/connections/test-custom-connector", -["connectionName"] = "test-custom-connector", -["id"] = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/providers/Microsoft.Web/locations/brazilsouth/managedApis/test-custom-connector"}}), -}, -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workflowName, data); - LogicWorkflowResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(workflowName); + LogicWorkflowResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowResource.cs index 0a16b240be36b..65d584d672c5c 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Logic.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Logic.Samples @@ -20,41 +19,40 @@ public partial class Sample_LogicWorkflowResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetLogicWorkflows_ListAllWorkflowsInASubscription() + public async Task Get_GetAWorkflow() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_ListBySubscription.json - // this example is just showing the usage of "Workflows_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_Get.json + // this example is just showing the usage of "Workflows_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this LogicWorkflowResource created on azure + // for more information of creating LogicWorkflowResource, please refer to the document of LogicWorkflowResource string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "test-resource-group"; + string workflowName = "test-workflow"; + ResourceIdentifier logicWorkflowResourceId = LogicWorkflowResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workflowName); + LogicWorkflowResource logicWorkflow = client.GetLogicWorkflowResource(logicWorkflowResourceId); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowResource item in subscriptionResource.GetLogicWorkflowsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + LogicWorkflowResource result = await logicWorkflow.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkflow() + public async Task Delete_DeleteAWorkflow() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_Get.json - // this example is just showing the usage of "Workflows_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_Delete.json + // this example is just showing the usage of "Workflows_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,13 +68,9 @@ public async Task Get_GetAWorkflow() LogicWorkflowResource logicWorkflow = client.GetLogicWorkflowResource(logicWorkflowResourceId); // invoke the operation - LogicWorkflowResource result = await logicWorkflow.GetAsync(); + await logicWorkflow.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -102,80 +96,72 @@ public async Task Update_CreateOrUpdateAWorkflow() // invoke the operation LogicWorkflowData data = new LogicWorkflowData(new AzureLocation("brazilsouth")) { - IntegrationAccount = new LogicResourceReference() + IntegrationAccount = new LogicResourceReference { Id = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/integrationAccounts/test-integration-account"), }, - Definition = BinaryData.FromObjectAsJson(new Dictionary() + Definition = BinaryData.FromObjectAsJson(new Dictionary { ["$schema"] = "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", - ["actions"] = new Dictionary() + ["actions"] = new { - ["Find_pet_by_ID"] = new Dictionary() + Find_pet_by_ID = new { - ["type"] = "ApiConnection", - ["inputs"] = new Dictionary() + type = "ApiConnection", + inputs = new { - ["path"] = "/pet/@{encodeURIComponent('1')}", - ["method"] = "get", - ["host"] = new Dictionary() + path = "/pet/@{encodeURIComponent('1')}", + method = "get", + host = new { - ["connection"] = new Dictionary() + connection = new { - ["name"] = "@parameters('$connections')['test-custom-connector']['connectionId']" - } - } + name = "@parameters('$connections')['test-custom-connector']['connectionId']", + }, + }, }, - ["runAfter"] = new Dictionary() - { - } - } + runAfter = new object(), + }, }, ["contentVersion"] = "1.0.0.0", - ["outputs"] = new Dictionary() + ["outputs"] = new object(), + ["parameters"] = new Dictionary { - }, - ["parameters"] = new Dictionary() - { - ["$connections"] = new Dictionary() + ["$connections"] = new { - ["type"] = "Object", - ["defaultValue"] = new Dictionary() - { - } + type = "Object", + defaultValue = new object(), } }, - ["triggers"] = new Dictionary() + ["triggers"] = new { - ["manual"] = new Dictionary() + manual = new { - ["type"] = "Request", - ["inputs"] = new Dictionary() + type = "Request", + inputs = new { - ["schema"] = new Dictionary() - { - } + schema = new object(), }, - ["kind"] = "Http" - } + kind = "Http", + }, } }), Parameters = { -["$connections"] = new LogicWorkflowParameterInfo() -{ -Value = BinaryData.FromObjectAsJson(new Dictionary() +["$connections"] = new LogicWorkflowParameterInfo { -["test-custom-connector"] = new Dictionary() +Value = BinaryData.FromObjectAsJson(new Dictionary { -["connectionId"] = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Web/connections/test-custom-connector", -["connectionName"] = "test-custom-connector", -["id"] = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/providers/Microsoft.Web/locations/brazilsouth/managedApis/test-custom-connector"}}), -}, -}, - Tags = +["test-custom-connector"] = new { +connectionId = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Web/connections/test-custom-connector", +connectionName = "test-custom-connector", +id = "/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/providers/Microsoft.Web/locations/brazilsouth/managedApis/test-custom-connector", +} +}), +} }, + Tags = { }, }; ArmOperation lro = await logicWorkflow.UpdateAsync(WaitUntil.Completed, data); LogicWorkflowResource result = lro.Value; @@ -187,32 +173,6 @@ public async Task Update_CreateOrUpdateAWorkflow() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAWorkflow() - { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_Delete.json - // this example is just showing the usage of "Workflows_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this LogicWorkflowResource created on azure - // for more information of creating LogicWorkflowResource, please refer to the document of LogicWorkflowResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "test-resource-group"; - string workflowName = "test-workflow"; - ResourceIdentifier logicWorkflowResourceId = LogicWorkflowResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workflowName); - LogicWorkflowResource logicWorkflow = client.GetLogicWorkflowResource(logicWorkflowResourceId); - - // invoke the operation - await logicWorkflow.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Disable_DisableAWorkflow() @@ -286,7 +246,7 @@ public async Task GenerateUpgradedDefinition_GenerateAnUpgradedDefinition() LogicWorkflowResource logicWorkflow = client.GetLogicWorkflowResource(logicWorkflowResourceId); // invoke the operation - GenerateUpgradedDefinitionContent content = new GenerateUpgradedDefinitionContent() + GenerateUpgradedDefinitionContent content = new GenerateUpgradedDefinitionContent { TargetSchemaVersion = "2016-06-01", }; @@ -316,7 +276,7 @@ public async Task GetCallbackUrl_GetCallbackUrl() LogicWorkflowResource logicWorkflow = client.GetLogicWorkflowResource(logicWorkflowResourceId); // invoke the operation - ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo() + ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo { NotAfter = DateTimeOffset.Parse("2018-04-19T16:00:00Z"), KeyType = LogicKeyType.Primary, @@ -373,7 +333,7 @@ public async Task Move_MoveAWorkflow() LogicWorkflowResource logicWorkflow = client.GetLogicWorkflowResource(logicWorkflowResourceId); // invoke the operation - LogicWorkflowReference move = new LogicWorkflowReference() + LogicWorkflowReference move = new LogicWorkflowReference { Id = new ResourceIdentifier("subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/newResourceGroup/providers/Microsoft.Logic/workflows/newWorkflowName"), }; @@ -403,7 +363,7 @@ public async Task RegenerateAccessKey_RegenerateTheCallbackURLAccessKeyForReques LogicWorkflowResource logicWorkflow = client.GetLogicWorkflowResource(logicWorkflowResourceId); // invoke the operation - LogicWorkflowRegenerateActionContent content = new LogicWorkflowRegenerateActionContent() + LogicWorkflowRegenerateActionContent content = new LogicWorkflowRegenerateActionContent { KeyType = LogicKeyType.Primary, }; @@ -435,88 +395,24 @@ public async Task ValidateByResourceGroup_ValidateAWorkflow() // invoke the operation LogicWorkflowData data = new LogicWorkflowData(new AzureLocation("brazilsouth")) { - IntegrationAccount = new LogicResourceReference() + IntegrationAccount = new LogicResourceReference { Id = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/integrationAccounts/test-integration-account"), }, - Definition = BinaryData.FromObjectAsJson(new Dictionary() + Definition = BinaryData.FromObjectAsJson(new Dictionary { ["$schema"] = "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", - ["actions"] = new Dictionary() - { - }, + ["actions"] = new object(), ["contentVersion"] = "1.0.0.0", - ["outputs"] = new Dictionary() - { - }, - ["parameters"] = new Dictionary() - { - }, - ["triggers"] = new Dictionary() - { - } + ["outputs"] = new object(), + ["parameters"] = new object(), + ["triggers"] = new object() }), - Tags = -{ -}, + Tags = { }, }; await logicWorkflow.ValidateByResourceGroupAsync(data); Console.WriteLine("Succeeded"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task ValidateByLocationWorkflow_ValidateAWorkflow() - { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_ValidateByLocation.json - // this example is just showing the usage of "Workflows_ValidateByLocation" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; - string resourceGroupName = "test-resource-group"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("brazilsouth"); - string workflowName = "test-workflow"; - LogicWorkflowData data = new LogicWorkflowData(new AzureLocation("brazilsouth")) - { - IntegrationAccount = new LogicResourceReference() - { - Id = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/integrationAccounts/test-integration-account"), - }, - Definition = BinaryData.FromObjectAsJson(new Dictionary() - { - ["$schema"] = "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", - ["actions"] = new Dictionary() - { - }, - ["contentVersion"] = "1.0.0.0", - ["outputs"] = new Dictionary() - { - }, - ["parameters"] = new Dictionary() - { - }, - ["triggers"] = new Dictionary() - { - } - }), - Tags = -{ -}, - }; - await resourceGroupResource.ValidateByLocationWorkflowAsync(location, workflowName, data); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionCollection.cs index 30547c6344d15..e7ab2f19312c4 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LogicWorkflowRunActionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAWorkflowRunActions() + public async Task Get_GetAWorkflowRunAction() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActions_List.json - // this example is just showing the usage of "WorkflowRunActions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActions_Get.json + // this example is just showing the usage of "WorkflowRunActions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListAWorkflowRunActions() // get the collection of this LogicWorkflowRunActionResource LogicWorkflowRunActionCollection collection = logicWorkflowRun.GetLogicWorkflowRunActions(); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowRunActionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRunActionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string actionName = "HTTP"; + LogicWorkflowRunActionResource result = await collection.GetAsync(actionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRunActionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkflowRunAction() + public async Task GetAll_ListAWorkflowRunActions() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActions_Get.json - // this example is just showing the usage of "WorkflowRunActions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActions_List.json + // this example is just showing the usage of "WorkflowRunActions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetAWorkflowRunAction() // get the collection of this LogicWorkflowRunActionResource LogicWorkflowRunActionCollection collection = logicWorkflowRun.GetLogicWorkflowRunActions(); - // invoke the operation - string actionName = "HTTP"; - LogicWorkflowRunActionResource result = await collection.GetAsync(actionName); + // invoke the operation and iterate over the result + await foreach (LogicWorkflowRunActionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRunActionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRunActionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRepetitionCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRepetitionCollection.cs index ba7eea99a2c17..e5ca28c7a5b57 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRepetitionCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRepetitionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LogicWorkflowRunActionRepetitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRepetitions() + public async Task Get_GetARepetition() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRepetitions_List.json - // this example is just showing the usage of "WorkflowRunActionRepetitions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRepetitions_Get.json + // this example is just showing the usage of "WorkflowRunActionRepetitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListRepetitions() // get the collection of this LogicWorkflowRunActionRepetitionResource LogicWorkflowRunActionRepetitionCollection collection = logicWorkflowRunAction.GetLogicWorkflowRunActionRepetitions(); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowRunActionRepetitionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRunActionRepetitionDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string repetitionName = "000001"; + LogicWorkflowRunActionRepetitionResource result = await collection.GetAsync(repetitionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRunActionRepetitionDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARepetition() + public async Task GetAll_ListRepetitions() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRepetitions_Get.json - // this example is just showing the usage of "WorkflowRunActionRepetitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRepetitions_List.json + // this example is just showing the usage of "WorkflowRunActionRepetitions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetARepetition() // get the collection of this LogicWorkflowRunActionRepetitionResource LogicWorkflowRunActionRepetitionCollection collection = logicWorkflowRunAction.GetLogicWorkflowRunActionRepetitions(); - // invoke the operation - string repetitionName = "000001"; - LogicWorkflowRunActionRepetitionResource result = await collection.GetAsync(repetitionName); + // invoke the operation and iterate over the result + await foreach (LogicWorkflowRunActionRepetitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRunActionRepetitionDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRunActionRepetitionDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRepetitionRequestHistoryCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRepetitionRequestHistoryCollection.cs index 57f5959ee6b66..5e6357412d83f 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRepetitionRequestHistoryCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRepetitionRequestHistoryCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LogicWorkflowRunActionRepetitionRequestHistoryCollec { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRepetitionRequestHistory() + public async Task Get_GetARepetitionRequestHistory() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRepetitionsRequestHistories_List.json - // this example is just showing the usage of "WorkflowRunActionRepetitionsRequestHistories_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRepetitionsRequestHistories_Get.json + // this example is just showing the usage of "WorkflowRunActionRepetitionsRequestHistories_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,23 @@ public async Task GetAll_ListRepetitionRequestHistory() // get the collection of this LogicWorkflowRunActionRepetitionRequestHistoryResource LogicWorkflowRunActionRepetitionRequestHistoryCollection collection = logicWorkflowRunActionRepetition.GetLogicWorkflowRunActionRepetitionRequestHistories(); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowRunActionRepetitionRequestHistoryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRequestHistoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string requestHistoryName = "08586611142732800686"; + LogicWorkflowRunActionRepetitionRequestHistoryResource result = await collection.GetAsync(requestHistoryName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRequestHistoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARepetitionRequestHistory() + public async Task GetAll_ListRepetitionRequestHistory() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRepetitionsRequestHistories_Get.json - // this example is just showing the usage of "WorkflowRunActionRepetitionsRequestHistories_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRepetitionsRequestHistories_List.json + // this example is just showing the usage of "WorkflowRunActionRepetitionsRequestHistories_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +78,17 @@ public async Task Get_GetARepetitionRequestHistory() // get the collection of this LogicWorkflowRunActionRepetitionRequestHistoryResource LogicWorkflowRunActionRepetitionRequestHistoryCollection collection = logicWorkflowRunActionRepetition.GetLogicWorkflowRunActionRepetitionRequestHistories(); - // invoke the operation - string requestHistoryName = "08586611142732800686"; - LogicWorkflowRunActionRepetitionRequestHistoryResource result = await collection.GetAsync(requestHistoryName); + // invoke the operation and iterate over the result + await foreach (LogicWorkflowRunActionRepetitionRequestHistoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRequestHistoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRequestHistoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRequestHistoryCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRequestHistoryCollection.cs index 281a77223583d..38f5af0621a0b 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRequestHistoryCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionRequestHistoryCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LogicWorkflowRunActionRequestHistoryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListARequestHistory() + public async Task Get_GetARequestHistory() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRequestHistories_List.json - // this example is just showing the usage of "WorkflowRunActionRequestHistories_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRequestHistories_Get.json + // this example is just showing the usage of "WorkflowRunActionRequestHistories_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListARequestHistory() // get the collection of this LogicWorkflowRunActionRequestHistoryResource LogicWorkflowRunActionRequestHistoryCollection collection = logicWorkflowRunAction.GetLogicWorkflowRunActionRequestHistories(); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowRunActionRequestHistoryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRequestHistoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string requestHistoryName = "08586611142732800686"; + LogicWorkflowRunActionRequestHistoryResource result = await collection.GetAsync(requestHistoryName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRequestHistoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARequestHistory() + public async Task GetAll_ListARequestHistory() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRequestHistories_Get.json - // this example is just showing the usage of "WorkflowRunActionRequestHistories_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionRequestHistories_List.json + // this example is just showing the usage of "WorkflowRunActionRequestHistories_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetARequestHistory() // get the collection of this LogicWorkflowRunActionRequestHistoryResource LogicWorkflowRunActionRequestHistoryCollection collection = logicWorkflowRunAction.GetLogicWorkflowRunActionRequestHistories(); - // invoke the operation - string requestHistoryName = "08586611142732800686"; - LogicWorkflowRunActionRequestHistoryResource result = await collection.GetAsync(requestHistoryName); + // invoke the operation and iterate over the result + await foreach (LogicWorkflowRunActionRequestHistoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRequestHistoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRequestHistoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionScopeRepetitionCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionScopeRepetitionCollection.cs index 1fa636875ac1f..4a2f57223a27a 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionScopeRepetitionCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunActionScopeRepetitionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LogicWorkflowRunActionScopeRepetitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheScopedRepetitions() + public async Task Get_GetAScopedRepetition() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionScopeRepetitions_List.json - // this example is just showing the usage of "WorkflowRunActionScopeRepetitions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionScopeRepetitions_Get.json + // this example is just showing the usage of "WorkflowRunActionScopeRepetitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,23 @@ public async Task GetAll_ListTheScopedRepetitions() // get the collection of this LogicWorkflowRunActionScopeRepetitionResource LogicWorkflowRunActionScopeRepetitionCollection collection = logicWorkflowRunAction.GetLogicWorkflowRunActionScopeRepetitions(); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowRunActionScopeRepetitionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRunActionRepetitionDefinitionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string repetitionName = "000000"; + LogicWorkflowRunActionScopeRepetitionResource result = await collection.GetAsync(repetitionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRunActionRepetitionDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAScopedRepetition() + public async Task GetAll_ListTheScopedRepetitions() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionScopeRepetitions_Get.json - // this example is just showing the usage of "WorkflowRunActionScopeRepetitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRunActionScopeRepetitions_List.json + // this example is just showing the usage of "WorkflowRunActionScopeRepetitions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,15 +76,17 @@ public async Task Get_GetAScopedRepetition() // get the collection of this LogicWorkflowRunActionScopeRepetitionResource LogicWorkflowRunActionScopeRepetitionCollection collection = logicWorkflowRunAction.GetLogicWorkflowRunActionScopeRepetitions(); - // invoke the operation - string repetitionName = "000000"; - LogicWorkflowRunActionScopeRepetitionResource result = await collection.GetAsync(repetitionName); + // invoke the operation and iterate over the result + await foreach (LogicWorkflowRunActionScopeRepetitionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRunActionRepetitionDefinitionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRunActionRepetitionDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunCollection.cs index 0e52d6d55374f..c807b59d86fe5 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowRunCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LogicWorkflowRunCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkflowRuns() + public async Task Get_GetARunForAWorkflow() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRuns_List.json - // this example is just showing the usage of "WorkflowRuns_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRuns_Get.json + // this example is just showing the usage of "WorkflowRuns_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListWorkflowRuns() // get the collection of this LogicWorkflowRunResource LogicWorkflowRunCollection collection = logicWorkflow.GetLogicWorkflowRuns(); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowRunResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRunData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string runName = "08586676746934337772206998657CU22"; + LogicWorkflowRunResource result = await collection.GetAsync(runName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRunData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetARunForAWorkflow() + public async Task GetAll_ListWorkflowRuns() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRuns_Get.json - // this example is just showing the usage of "WorkflowRuns_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowRuns_List.json + // this example is just showing the usage of "WorkflowRuns_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetARunForAWorkflow() // get the collection of this LogicWorkflowRunResource LogicWorkflowRunCollection collection = logicWorkflow.GetLogicWorkflowRuns(); - // invoke the operation - string runName = "08586676746934337772206998657CU22"; - LogicWorkflowRunResource result = await collection.GetAsync(runName); + // invoke the operation and iterate over the result + await foreach (LogicWorkflowRunResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowRunData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowRunData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerCollection.cs index d30a66304b71e..4dabecad43d95 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LogicWorkflowTriggerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkflowTriggers() + public async Task Get_GetAWorkflowTrigger() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowTriggers_List.json - // this example is just showing the usage of "WorkflowTriggers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowTriggers_Get.json + // this example is just showing the usage of "WorkflowTriggers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListWorkflowTriggers() // get the collection of this LogicWorkflowTriggerResource LogicWorkflowTriggerCollection collection = logicWorkflow.GetLogicWorkflowTriggers(); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowTriggerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowTriggerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string triggerName = "manual"; + LogicWorkflowTriggerResource result = await collection.GetAsync(triggerName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowTriggerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkflowTrigger() + public async Task GetAll_ListWorkflowTriggers() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowTriggers_Get.json - // this example is just showing the usage of "WorkflowTriggers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowTriggers_List.json + // this example is just showing the usage of "WorkflowTriggers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetAWorkflowTrigger() // get the collection of this LogicWorkflowTriggerResource LogicWorkflowTriggerCollection collection = logicWorkflow.GetLogicWorkflowTriggers(); - // invoke the operation - string triggerName = "manual"; - LogicWorkflowTriggerResource result = await collection.GetAsync(triggerName); + // invoke the operation and iterate over the result + await foreach (LogicWorkflowTriggerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowTriggerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowTriggerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerHistoryCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerHistoryCollection.cs index 16c9a98fd908a..7f9472c968cba 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerHistoryCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerHistoryCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LogicWorkflowTriggerHistoryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAWorkflowTriggerHistory() + public async Task Get_GetAWorkflowTriggerHistory() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowTriggerHistories_List.json - // this example is just showing the usage of "WorkflowTriggerHistories_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowTriggerHistories_Get.json + // this example is just showing the usage of "WorkflowTriggerHistories_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_ListAWorkflowTriggerHistory() // get the collection of this LogicWorkflowTriggerHistoryResource LogicWorkflowTriggerHistoryCollection collection = logicWorkflowTrigger.GetLogicWorkflowTriggerHistories(); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowTriggerHistoryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowTriggerHistoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string historyName = "08586676746934337772206998657CU22"; + LogicWorkflowTriggerHistoryResource result = await collection.GetAsync(historyName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowTriggerHistoryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkflowTriggerHistory() + public async Task GetAll_ListAWorkflowTriggerHistory() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowTriggerHistories_Get.json - // this example is just showing the usage of "WorkflowTriggerHistories_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowTriggerHistories_List.json + // this example is just showing the usage of "WorkflowTriggerHistories_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_GetAWorkflowTriggerHistory() // get the collection of this LogicWorkflowTriggerHistoryResource LogicWorkflowTriggerHistoryCollection collection = logicWorkflowTrigger.GetLogicWorkflowTriggerHistories(); - // invoke the operation - string historyName = "08586676746934337772206998657CU22"; - LogicWorkflowTriggerHistoryResource result = await collection.GetAsync(historyName); + // invoke the operation and iterate over the result + await foreach (LogicWorkflowTriggerHistoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowTriggerHistoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowTriggerHistoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerResource.cs index d22a626dec7c7..b8f46e221c687 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowTriggerResource.cs @@ -150,7 +150,7 @@ public async Task SetState_SetTriggerState() LogicWorkflowTriggerResource logicWorkflowTrigger = client.GetLogicWorkflowTriggerResource(logicWorkflowTriggerResourceId); // invoke the operation - LogicWorkflowTriggerStateActionContent content = new LogicWorkflowTriggerStateActionContent(new LogicWorkflowTriggerReference() + LogicWorkflowTriggerStateActionContent content = new LogicWorkflowTriggerStateActionContent(new LogicWorkflowTriggerReference { Id = new ResourceIdentifier("subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/sourceResGroup/providers/Microsoft.Logic/workflows/sourceWorkflow/triggers/sourceTrigger"), }); diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowVersionCollection.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowVersionCollection.cs index b90a682caba51..379510be326d7 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowVersionCollection.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowVersionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LogicWorkflowVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAWorkflowsVersions() + public async Task Get_GetAWorkflowVersion() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowVersions_List.json - // this example is just showing the usage of "WorkflowVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowVersions_Get.json + // this example is just showing the usage of "WorkflowVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_ListAWorkflowsVersions() // get the collection of this LogicWorkflowVersionResource LogicWorkflowVersionCollection collection = logicWorkflow.GetLogicWorkflowVersions(); - // invoke the operation and iterate over the result - await foreach (LogicWorkflowVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string versionId = "08586676824806722526"; + LogicWorkflowVersionResource result = await collection.GetAsync(versionId); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWorkflowVersion() + public async Task GetAll_ListAWorkflowsVersions() { - // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowVersions_Get.json - // this example is just showing the usage of "WorkflowVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/WorkflowVersions_List.json + // this example is just showing the usage of "WorkflowVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetAWorkflowVersion() // get the collection of this LogicWorkflowVersionResource LogicWorkflowVersionCollection collection = logicWorkflow.GetLogicWorkflowVersions(); - // invoke the operation - string versionId = "08586676824806722526"; - LogicWorkflowVersionResource result = await collection.GetAsync(versionId); + // invoke the operation and iterate over the result + await foreach (LogicWorkflowVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogicWorkflowVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowVersionResource.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowVersionResource.cs index 268660324ff48..45bd083f8a6d2 100644 --- a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowVersionResource.cs +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_LogicWorkflowVersionResource.cs @@ -70,7 +70,7 @@ public async Task GetCallbackUrlWorkflowVersionTrigger_GetTheCallbackUrlForATrig // invoke the operation string triggerName = "testTriggerName"; - ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo() + ListOperationCallbackUrlParameterInfo info = new ListOperationCallbackUrlParameterInfo { NotAfter = DateTimeOffset.Parse("2017-03-05T08:00:00Z"), KeyType = LogicKeyType.Primary, diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs new file mode 100644 index 0000000000000..25c84ed6619b4 --- /dev/null +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -0,0 +1,65 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Logic.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Logic.Samples +{ + public partial class Sample_ResourceGroupResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task ValidateByLocationWorkflow_ValidateAWorkflow() + { + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_ValidateByLocation.json + // this example is just showing the usage of "Workflows_ValidateByLocation" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + string resourceGroupName = "test-resource-group"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("brazilsouth"); + string workflowName = "test-workflow"; + LogicWorkflowData data = new LogicWorkflowData(new AzureLocation("brazilsouth")) + { + IntegrationAccount = new LogicResourceReference + { + Id = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/integrationAccounts/test-integration-account"), + }, + Definition = BinaryData.FromObjectAsJson(new Dictionary + { + ["$schema"] = "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", + ["actions"] = new object(), + ["contentVersion"] = "1.0.0.0", + ["outputs"] = new object(), + ["parameters"] = new object(), + ["triggers"] = new object() + }), + Tags = { }, + }; + await resourceGroupResource.ValidateByLocationWorkflowAsync(location, workflowName, data); + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..74e32740ffe14 --- /dev/null +++ b/sdk/logic/Azure.ResourceManager.Logic/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Logic.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetLogicWorkflows_ListAllWorkflowsInASubscription() + { + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/Workflows_ListBySubscription.json + // this example is just showing the usage of "Workflows_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (LogicWorkflowResource item in subscriptionResource.GetLogicWorkflowsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogicWorkflowData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIntegrationAccounts_ListIntegrationAccountsBySubscription() + { + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationAccounts_ListBySubscription.json + // this example is just showing the usage of "IntegrationAccounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "34adfa4f-cedf-4dc0-ba29-b6d1a69ab345"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (IntegrationAccountResource item in subscriptionResource.GetIntegrationAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIntegrationServiceEnvironments_ListIntegrationServiceEnvironmentsBySubscription() + { + // Generated from example definition: specification/logic/resource-manager/Microsoft.Logic/stable/2019-05-01/examples/IntegrationServiceEnvironments_ListBySubscription.json + // this example is just showing the usage of "IntegrationServiceEnvironments_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "f34b22a3-2202-4fb1-b040-1332bd928c84"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (IntegrationServiceEnvironmentResource item in subscriptionResource.GetIntegrationServiceEnvironmentsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IntegrationServiceEnvironmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_OperationalizationClusterCollection.cs b/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_OperationalizationClusterCollection.cs index bd9718f57e870..c64b1e36ccd55 100644 --- a/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_OperationalizationClusterCollection.cs +++ b/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_OperationalizationClusterCollection.cs @@ -49,9 +49,9 @@ public async Task CreateOrUpdate_PUTOperationalizationCluster() { OrchestratorServicePrincipal = new ServicePrincipalProperties("abcdefghijklmnopqrt", ""), }, - GlobalServiceConfiguration = new GlobalServiceConfiguration() + GlobalServiceConfiguration = new GlobalServiceConfiguration { - Ssl = new SslConfiguration() + Ssl = new SslConfiguration { Status = Status.Enabled, Cert = "afjdklq2131casfakld=", @@ -62,7 +62,7 @@ public async Task CreateOrUpdate_PUTOperationalizationCluster() Tags = { ["key1"] = "alpha", -["key2"] = "beta", +["key2"] = "beta" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, clusterName, data); @@ -110,10 +110,10 @@ public async Task Get_GETOperationalizationCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GETOperationalizationCluster() + public async Task GetAll_ListOperationalizationClustersByResourceGroup() { - // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_Get.json - // this example is just showing the usage of "OperationalizationClusters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_ListByResourceGroup.json + // this example is just showing the usage of "OperationalizationClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,16 +130,22 @@ public async Task Exists_GETOperationalizationCluster() // get the collection of this OperationalizationClusterResource OperationalizationClusterCollection collection = resourceGroupResource.GetOperationalizationClusters(); - // invoke the operation - string clusterName = "myCluster"; - bool result = await collection.ExistsAsync(clusterName); + // invoke the operation and iterate over the result + await foreach (OperationalizationClusterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalizationClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GETOperationalizationCluster() + public async Task Exists_GETOperationalizationCluster() { // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_Get.json // this example is just showing the usage of "OperationalizationClusters_Get" operation, for the dependent resources, they will have to be created separately. @@ -161,29 +167,17 @@ public async Task GetIfExists_GETOperationalizationCluster() // invoke the operation string clusterName = "myCluster"; - NullableResponse response = await collection.GetIfExistsAsync(clusterName); - OperationalizationClusterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(clusterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalizationClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOperationalizationClustersByResourceGroup() + public async Task GetIfExists_GETOperationalizationCluster() { - // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_ListByResourceGroup.json - // this example is just showing the usage of "OperationalizationClusters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_Get.json + // this example is just showing the usage of "OperationalizationClusters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -200,17 +194,23 @@ public async Task GetAll_ListOperationalizationClustersByResourceGroup() // get the collection of this OperationalizationClusterResource OperationalizationClusterCollection collection = resourceGroupResource.GetOperationalizationClusters(); - // invoke the operation and iterate over the result - await foreach (OperationalizationClusterResource item in collection.GetAllAsync()) + // invoke the operation + string clusterName = "myCluster"; + NullableResponse response = await collection.GetIfExistsAsync(clusterName); + OperationalizationClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - OperationalizationClusterData resourceData = item.Data; + OperationalizationClusterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_OperationalizationClusterResource.cs b/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_OperationalizationClusterResource.cs index 1c56405f78063..a774b5ec56271 100644 --- a/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_OperationalizationClusterResource.cs +++ b/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_OperationalizationClusterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.MachineLearningCompute.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MachineLearningCompute.Samples @@ -49,10 +48,10 @@ public async Task Get_GETOperationalizationCluster() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PATCHOperationalizationCluster() + public async Task Delete_DELETEOperationalizationCluster() { - // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_Update.json - // this example is just showing the usage of "OperationalizationClusters_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_Delete.json + // this example is just showing the usage of "OperationalizationClusters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,28 +67,17 @@ public async Task Update_PATCHOperationalizationCluster() OperationalizationClusterResource operationalizationCluster = client.GetOperationalizationClusterResource(operationalizationClusterResourceId); // invoke the operation - OperationalizationClusterPatch patch = new OperationalizationClusterPatch() - { - Tags = -{ -["key1"] = "value1", -}, - }; - OperationalizationClusterResource result = await operationalizationCluster.UpdateAsync(patch); + await operationalizationCluster.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalizationClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DELETEOperationalizationCluster() + public async Task Update_PATCHOperationalizationCluster() { - // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_Delete.json - // this example is just showing the usage of "OperationalizationClusters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_Update.json + // this example is just showing the usage of "OperationalizationClusters_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +93,20 @@ public async Task Delete_DELETEOperationalizationCluster() OperationalizationClusterResource operationalizationCluster = client.GetOperationalizationClusterResource(operationalizationClusterResourceId); // invoke the operation - await operationalizationCluster.DeleteAsync(WaitUntil.Completed); + OperationalizationClusterPatch patch = new OperationalizationClusterPatch + { + Tags = +{ +["key1"] = "value1" +}, + }; + OperationalizationClusterResource result = await operationalizationCluster.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalizationClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -188,36 +187,5 @@ public async Task UpdateSystemServices_UpdateSystemServicesInAnOperationalizatio Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetOperationalizationClusters_ListOperationalizationClustersBySubscription() - { - // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_ListBySubscription.json - // this example is just showing the usage of "OperationalizationClusters_ListBySubscriptionId" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (OperationalizationClusterResource item in subscriptionResource.GetOperationalizationClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OperationalizationClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..d5759df47e7fb --- /dev/null +++ b/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.MachineLearningCompute.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetOperationalizationClusters_ListOperationalizationClustersBySubscription() + { + // Generated from example definition: specification/machinelearningcompute/resource-manager/Microsoft.MachineLearningCompute/preview/2017-08-01-preview/examples/OperationalizationClusters_ListBySubscription.json + // this example is just showing the usage of "OperationalizationClusters_ListBySubscriptionId" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (OperationalizationClusterResource item in subscriptionResource.GetOperationalizationClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OperationalizationClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index fe5b85f5ca0c8..2a987fcbe105c 100644 --- a/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/machinelearningcompute/Azure.ResourceManager.MachineLearningCompute/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.MachineLearningCompute.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MachineLearningCompute.Samples @@ -28,9 +29,7 @@ public async Task GetAvailableOperationsMachineLearningComputes_MachineLearningC // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (ResourceOperation item in tenantResource.GetAvailableOperationsMachineLearningComputesAsync()) diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentContainerCollection.cs index 201d6a7194ece..0513f0c775fab 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearninRegistryComponentContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRegistryComponentContainer() + public async Task CreateOrUpdate_CreateOrUpdateRegistryComponentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/list.json - // this example is just showing the usage of "RegistryComponentContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/createOrUpdate.json + // this example is just showing the usage of "RegistryComponentContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,28 @@ public async Task GetAll_ListRegistryComponentContainer() // get the collection of this MachineLearninRegistryComponentContainerResource MachineLearninRegistryComponentContainerCollection collection = machineLearningRegistry.GetMachineLearninRegistryComponentContainers(); - // invoke the operation and iterate over the result - await foreach (MachineLearninRegistryComponentContainerResource item in collection.GetAllAsync()) + // invoke the operation + string componentName = "string"; + MachineLearningComponentContainerData data = new MachineLearningComponentContainerData(new MachineLearningComponentContainerProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, componentName, data); + MachineLearninRegistryComponentContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +99,10 @@ public async Task Get_GetRegistryComponentContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryComponentContainer() + public async Task GetAll_ListRegistryComponentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/get.json - // this example is just showing the usage of "RegistryComponentContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/list.json + // this example is just showing the usage of "RegistryComponentContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +120,22 @@ public async Task Exists_GetRegistryComponentContainer() // get the collection of this MachineLearninRegistryComponentContainerResource MachineLearninRegistryComponentContainerCollection collection = machineLearningRegistry.GetMachineLearninRegistryComponentContainers(); - // invoke the operation - string componentName = "string"; - bool result = await collection.ExistsAsync(componentName); + // invoke the operation and iterate over the result + await foreach (MachineLearninRegistryComponentContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryComponentContainer() + public async Task Exists_GetRegistryComponentContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/get.json // this example is just showing the usage of "RegistryComponentContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +158,17 @@ public async Task GetIfExists_GetRegistryComponentContainer() // invoke the operation string componentName = "string"; - NullableResponse response = await collection.GetIfExistsAsync(componentName); - MachineLearninRegistryComponentContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(componentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryComponentContainer() + public async Task GetIfExists_GetRegistryComponentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/createOrUpdate.json - // this example is just showing the usage of "RegistryComponentContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/get.json + // this example is just showing the usage of "RegistryComponentContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +188,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryComponentContainer() // invoke the operation string componentName = "string"; - MachineLearningComponentContainerData data = new MachineLearningComponentContainerData(new MachineLearningComponentContainerProperties() - { - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, componentName, data); - MachineLearninRegistryComponentContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(componentName); + MachineLearninRegistryComponentContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentContainerResource.cs index 33e73d658d767..a7246feac0471 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearninRegistryComponentContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistryComponentContainer() + public async Task Get_GetRegistryComponentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/delete.json - // this example is just showing the usage of "RegistryComponentContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/get.json + // this example is just showing the usage of "RegistryComponentContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteRegistryComponentContainer() MachineLearninRegistryComponentContainerResource machineLearninRegistryComponentContainer = client.GetMachineLearninRegistryComponentContainerResource(machineLearninRegistryComponentContainerResourceId); // invoke the operation - await machineLearninRegistryComponentContainer.DeleteAsync(WaitUntil.Completed); + MachineLearninRegistryComponentContainerResource result = await machineLearninRegistryComponentContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryComponentContainer() + public async Task Delete_DeleteRegistryComponentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/get.json - // this example is just showing the usage of "RegistryComponentContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentContainer/delete.json + // this example is just showing the usage of "RegistryComponentContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetRegistryComponentContainer() MachineLearninRegistryComponentContainerResource machineLearninRegistryComponentContainer = client.GetMachineLearninRegistryComponentContainerResource(machineLearninRegistryComponentContainerResourceId); // invoke the operation - MachineLearninRegistryComponentContainerResource result = await machineLearninRegistryComponentContainer.GetAsync(); + await machineLearninRegistryComponentContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,16 +96,16 @@ public async Task Update_CreateOrUpdateRegistryComponentContainer() MachineLearninRegistryComponentContainerResource machineLearninRegistryComponentContainer = client.GetMachineLearninRegistryComponentContainerResource(machineLearninRegistryComponentContainerResourceId); // invoke the operation - MachineLearningComponentContainerData data = new MachineLearningComponentContainerData(new MachineLearningComponentContainerProperties() + MachineLearningComponentContainerData data = new MachineLearningComponentContainerData(new MachineLearningComponentContainerProperties { Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearninRegistryComponentContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentVersionCollection.cs index cc9e896b691c8..58db8e3bd3f18 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentVersionCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MachineLearninRegistryComponentVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRegistryComponentVersion() + public async Task CreateOrUpdate_CreateOrUpdateRegistryComponentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/list.json - // this example is just showing the usage of "RegistryComponentVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/createOrUpdate.json + // this example is just showing the usage of "RegistryComponentVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,19 +41,33 @@ public async Task GetAll_ListRegistryComponentVersion() // get the collection of this MachineLearninRegistryComponentVersionResource MachineLearninRegistryComponentVersionCollection collection = machineLearninRegistryComponentContainer.GetMachineLearninRegistryComponentVersions(); - // invoke the operation and iterate over the result - string orderBy = "string"; - int? top = 1; - await foreach (MachineLearninRegistryComponentVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + // invoke the operation + string version = "string"; + MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(new MachineLearningComponentVersionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ComponentSpec = BinaryData.FromObjectAsJson(new Dictionary + { + ["8ced901b-d826-477d-bfef-329da9672513"] = null + }), + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearninRegistryComponentVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -93,10 +107,10 @@ public async Task Get_GetRegistryComponentVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryComponentVersion() + public async Task GetAll_ListRegistryComponentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/get.json - // this example is just showing the usage of "RegistryComponentVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/list.json + // this example is just showing the usage of "RegistryComponentVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +129,24 @@ public async Task Exists_GetRegistryComponentVersion() // get the collection of this MachineLearninRegistryComponentVersionResource MachineLearninRegistryComponentVersionCollection collection = machineLearninRegistryComponentContainer.GetMachineLearninRegistryComponentVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + string orderBy = "string"; + int? top = 1; + await foreach (MachineLearninRegistryComponentVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryComponentVersion() + public async Task Exists_GetRegistryComponentVersion() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/get.json // this example is just showing the usage of "RegistryComponentVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +170,17 @@ public async Task GetIfExists_GetRegistryComponentVersion() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearninRegistryComponentVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryComponentVersion() + public async Task GetIfExists_GetRegistryComponentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/createOrUpdate.json - // this example is just showing the usage of "RegistryComponentVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/get.json + // this example is just showing the usage of "RegistryComponentVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,31 +201,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryComponentVersion() // invoke the operation string version = "string"; - MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(new MachineLearningComponentVersionProperties() - { - ComponentSpec = BinaryData.FromObjectAsJson(new Dictionary() - { - ["8ced901b-d826-477d-bfef-329da9672513"] = null - }), - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearninRegistryComponentVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearninRegistryComponentVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentVersionResource.cs index f02e4c3e101ab..8471da2714e64 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearninRegistryComponentVersionResource.cs @@ -19,10 +19,10 @@ public partial class Sample_MachineLearninRegistryComponentVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistryComponentVersion() + public async Task Get_GetRegistryComponentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/delete.json - // this example is just showing the usage of "RegistryComponentVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/get.json + // this example is just showing the usage of "RegistryComponentVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,21 @@ public async Task Delete_DeleteRegistryComponentVersion() MachineLearninRegistryComponentVersionResource machineLearninRegistryComponentVersion = client.GetMachineLearninRegistryComponentVersionResource(machineLearninRegistryComponentVersionResourceId); // invoke the operation - await machineLearninRegistryComponentVersion.DeleteAsync(WaitUntil.Completed); + MachineLearninRegistryComponentVersionResource result = await machineLearninRegistryComponentVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryComponentVersion() + public async Task Delete_DeleteRegistryComponentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/get.json - // this example is just showing the usage of "RegistryComponentVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ComponentVersion/delete.json + // this example is just showing the usage of "RegistryComponentVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,13 +72,9 @@ public async Task Get_GetRegistryComponentVersion() MachineLearninRegistryComponentVersionResource machineLearninRegistryComponentVersion = client.GetMachineLearninRegistryComponentVersionResource(machineLearninRegistryComponentVersionResourceId); // invoke the operation - MachineLearninRegistryComponentVersionResource result = await machineLearninRegistryComponentVersion.GetAsync(); + await machineLearninRegistryComponentVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,9 +100,9 @@ public async Task Update_CreateOrUpdateRegistryComponentVersion() MachineLearninRegistryComponentVersionResource machineLearninRegistryComponentVersion = client.GetMachineLearninRegistryComponentVersionResource(machineLearninRegistryComponentVersionResourceId); // invoke the operation - MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(new MachineLearningComponentVersionProperties() + MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(new MachineLearningComponentVersionProperties { - ComponentSpec = BinaryData.FromObjectAsJson(new Dictionary() + ComponentSpec = BinaryData.FromObjectAsJson(new Dictionary { ["8ced901b-d826-477d-bfef-329da9672513"] = null }), @@ -110,11 +110,11 @@ public async Task Update_CreateOrUpdateRegistryComponentVersion() Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearninRegistryComponentVersion.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchDeploymentCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchDeploymentCollection.cs index d642e44016244..c529371360d7d 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchDeploymentCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchDeploymentCollection.cs @@ -21,10 +21,10 @@ public partial class Sample_MachineLearningBatchDeploymentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceBatchDeployment() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceBatchDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/list.json - // this example is just showing the usage of "BatchDeployments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/createOrUpdate.json + // this example is just showing the usage of "BatchDeployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,19 +43,76 @@ public async Task GetAll_ListWorkspaceBatchDeployment() // get the collection of this MachineLearningBatchDeploymentResource MachineLearningBatchDeploymentCollection collection = machineLearningBatchEndpoint.GetMachineLearningBatchDeployments(); - // invoke the operation and iterate over the result - string orderBy = "string"; - int? top = 1; - await foreach (MachineLearningBatchDeploymentResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + // invoke the operation + string deploymentName = "testDeploymentName"; + MachineLearningBatchDeploymentData data = new MachineLearningBatchDeploymentData(new AzureLocation("string"), new MachineLearningBatchDeploymentProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningBatchDeploymentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Compute = "string", + ErrorThreshold = 1, + RetrySettings = new MachineLearningBatchRetrySettings + { + MaxRetries = 1, + Timeout = XmlConvert.ToTimeSpan("PT5M"), + }, + MiniBatchSize = 1L, + LoggingLevel = MachineLearningBatchLoggingLevel.Info, + Model = new MachineLearningIdAssetReference(new ResourceIdentifier("string")), + MaxConcurrencyPerInstance = 1, + OutputAction = MachineLearningBatchOutputAction.SummaryOnly, + OutputFileName = "string", + Resources = new MachineLearningDeploymentResourceConfiguration + { + InstanceCount = 1, + InstanceType = "string", + Properties = +{ +["string"] = BinaryData.FromObjectAsJson(new Dictionary +{ +["cd3c37dc-2876-4ca4-8a54-21bd7619724a"] = null +}) +}, + }, + Description = "string", + Properties = +{ +["string"] = "string" +}, + CodeConfiguration = new MachineLearningCodeConfiguration("string") + { + CodeId = new ResourceIdentifier("string"), + }, + EnvironmentId = "string", + EnvironmentVariables = +{ +["string"] = "string" +}, + }) + { + Kind = "string", + Identity = new ManagedServiceIdentity("SystemAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("string")] = new UserAssignedIdentity() +}, + }, + Sku = new MachineLearningSku("string") + { + Tier = MachineLearningSkuTier.Free, + Size = "string", + Family = "string", + Capacity = 1, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); + MachineLearningBatchDeploymentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningBatchDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -95,10 +152,10 @@ public async Task Get_GetWorkspaceBatchDeployment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceBatchDeployment() + public async Task GetAll_ListWorkspaceBatchDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/get.json - // this example is just showing the usage of "BatchDeployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/list.json + // this example is just showing the usage of "BatchDeployments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,16 +174,24 @@ public async Task Exists_GetWorkspaceBatchDeployment() // get the collection of this MachineLearningBatchDeploymentResource MachineLearningBatchDeploymentCollection collection = machineLearningBatchEndpoint.GetMachineLearningBatchDeployments(); - // invoke the operation - string deploymentName = "testDeploymentName"; - bool result = await collection.ExistsAsync(deploymentName); + // invoke the operation and iterate over the result + string orderBy = "string"; + int? top = 1; + await foreach (MachineLearningBatchDeploymentResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningBatchDeploymentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceBatchDeployment() + public async Task Exists_GetWorkspaceBatchDeployment() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/get.json // this example is just showing the usage of "BatchDeployments_Get" operation, for the dependent resources, they will have to be created separately. @@ -150,29 +215,17 @@ public async Task GetIfExists_GetWorkspaceBatchDeployment() // invoke the operation string deploymentName = "testDeploymentName"; - NullableResponse response = await collection.GetIfExistsAsync(deploymentName); - MachineLearningBatchDeploymentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(deploymentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningBatchDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceBatchDeployment() + public async Task GetIfExists_GetWorkspaceBatchDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/createOrUpdate.json - // this example is just showing the usage of "BatchDeployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/get.json + // this example is just showing the usage of "BatchDeployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,75 +246,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceBatchDeployment() // invoke the operation string deploymentName = "testDeploymentName"; - MachineLearningBatchDeploymentData data = new MachineLearningBatchDeploymentData(new AzureLocation("string"), new MachineLearningBatchDeploymentProperties() + NullableResponse response = await collection.GetIfExistsAsync(deploymentName); + MachineLearningBatchDeploymentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Compute = "string", - ErrorThreshold = 1, - RetrySettings = new MachineLearningBatchRetrySettings() - { - MaxRetries = 1, - Timeout = XmlConvert.ToTimeSpan("PT5M"), - }, - MiniBatchSize = 1L, - LoggingLevel = MachineLearningBatchLoggingLevel.Info, - Model = new MachineLearningIdAssetReference(new ResourceIdentifier("string")), - MaxConcurrencyPerInstance = 1, - OutputAction = MachineLearningBatchOutputAction.SummaryOnly, - OutputFileName = "string", - Resources = new MachineLearningDeploymentResourceConfiguration() - { - InstanceCount = 1, - InstanceType = "string", - Properties = -{ -["string"] = BinaryData.FromObjectAsJson(new Dictionary() -{ -["cd3c37dc-2876-4ca4-8a54-21bd7619724a"] = null}), -}, - }, - Description = "string", - Properties = -{ -["string"] = "string", -}, - CodeConfiguration = new MachineLearningCodeConfiguration("string") - { - CodeId = new ResourceIdentifier("string"), - }, - EnvironmentId = "string", - EnvironmentVariables = -{ -["string"] = "string", -}, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Kind = "string", - Identity = new ManagedServiceIdentity("SystemAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), -}, - }, - Sku = new MachineLearningSku("string") - { - Tier = MachineLearningSkuTier.Free, - Size = "string", - Family = "string", - Capacity = 1, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); - MachineLearningBatchDeploymentResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningBatchDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningBatchDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchDeploymentResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchDeploymentResource.cs index 3d51c078a08b4..e90a49c6efa46 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchDeploymentResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchDeploymentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningBatchDeploymentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceBatchDeployment() + public async Task Get_GetWorkspaceBatchDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/delete.json - // this example is just showing the usage of "BatchDeployments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/get.json + // this example is just showing the usage of "BatchDeployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteWorkspaceBatchDeployment() MachineLearningBatchDeploymentResource machineLearningBatchDeployment = client.GetMachineLearningBatchDeploymentResource(machineLearningBatchDeploymentResourceId); // invoke the operation - await machineLearningBatchDeployment.DeleteAsync(WaitUntil.Completed); + MachineLearningBatchDeploymentResource result = await machineLearningBatchDeployment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningBatchDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceBatchDeployment() + public async Task Delete_DeleteWorkspaceBatchDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/get.json - // this example is just showing the usage of "BatchDeployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchDeployment/delete.json + // this example is just showing the usage of "BatchDeployments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetWorkspaceBatchDeployment() MachineLearningBatchDeploymentResource machineLearningBatchDeployment = client.GetMachineLearningBatchDeploymentResource(machineLearningBatchDeploymentResourceId); // invoke the operation - MachineLearningBatchDeploymentResource result = await machineLearningBatchDeployment.GetAsync(); + await machineLearningBatchDeployment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningBatchDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,12 +99,10 @@ public async Task Update_UpdateWorkspaceBatchDeployment() MachineLearningBatchDeploymentResource machineLearningBatchDeployment = client.GetMachineLearningBatchDeploymentResource(machineLearningBatchDeploymentResourceId); // invoke the operation - MachineLearningBatchDeploymentPatch patch = new MachineLearningBatchDeploymentPatch() + MachineLearningBatchDeploymentPatch patch = new MachineLearningBatchDeploymentPatch { PartialBatchDeploymentDescription = "string", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await machineLearningBatchDeployment.UpdateAsync(WaitUntil.Completed, patch); MachineLearningBatchDeploymentResource result = lro.Value; diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchEndpointCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchEndpointCollection.cs index 737b0e30394c2..23d577e2d6a77 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchEndpointCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchEndpointCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MachineLearningBatchEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceBatchEndpoint() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceBatchEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/list.json - // this example is just showing the usage of "BatchEndpoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/createOrUpdate.json + // this example is just showing the usage of "BatchEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,18 +40,43 @@ public async Task GetAll_ListWorkspaceBatchEndpoint() // get the collection of this MachineLearningBatchEndpointResource MachineLearningBatchEndpointCollection collection = machineLearningWorkspace.GetMachineLearningBatchEndpoints(); - // invoke the operation and iterate over the result - int? count = 1; - await foreach (MachineLearningBatchEndpointResource item in collection.GetAllAsync(count: count)) + // invoke the operation + string endpointName = "testEndpointName"; + MachineLearningBatchEndpointData data = new MachineLearningBatchEndpointData(new AzureLocation("string"), new MachineLearningBatchEndpointProperties(MachineLearningEndpointAuthMode.AmlToken) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningBatchEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DefaultsDeploymentName = "string", + Description = "string", + Properties = +{ +["string"] = "string" +}, + }) + { + Kind = "string", + Identity = new ManagedServiceIdentity("SystemAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("string")] = new UserAssignedIdentity() +}, + }, + Sku = new MachineLearningSku("string") + { + Tier = MachineLearningSkuTier.Free, + Size = "string", + Family = "string", + Capacity = 1, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); + MachineLearningBatchEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningBatchEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +115,10 @@ public async Task Get_GetWorkspaceBatchEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceBatchEndpoint() + public async Task GetAll_ListWorkspaceBatchEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/get.json - // this example is just showing the usage of "BatchEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/list.json + // this example is just showing the usage of "BatchEndpoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +136,23 @@ public async Task Exists_GetWorkspaceBatchEndpoint() // get the collection of this MachineLearningBatchEndpointResource MachineLearningBatchEndpointCollection collection = machineLearningWorkspace.GetMachineLearningBatchEndpoints(); - // invoke the operation - string endpointName = "testEndpointName"; - bool result = await collection.ExistsAsync(endpointName); + // invoke the operation and iterate over the result + int? count = 1; + await foreach (MachineLearningBatchEndpointResource item in collection.GetAllAsync(count: count)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningBatchEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceBatchEndpoint() + public async Task Exists_GetWorkspaceBatchEndpoint() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/get.json // this example is just showing the usage of "BatchEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,29 +175,17 @@ public async Task GetIfExists_GetWorkspaceBatchEndpoint() // invoke the operation string endpointName = "testEndpointName"; - NullableResponse response = await collection.GetIfExistsAsync(endpointName); - MachineLearningBatchEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(endpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningBatchEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceBatchEndpoint() + public async Task GetIfExists_GetWorkspaceBatchEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/createOrUpdate.json - // this example is just showing the usage of "BatchEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/get.json + // this example is just showing the usage of "BatchEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,43 +205,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceBatchEndpoint() // invoke the operation string endpointName = "testEndpointName"; - MachineLearningBatchEndpointData data = new MachineLearningBatchEndpointData(new AzureLocation("string"), new MachineLearningBatchEndpointProperties(MachineLearningEndpointAuthMode.AmlToken) + NullableResponse response = await collection.GetIfExistsAsync(endpointName); + MachineLearningBatchEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) { - DefaultsDeploymentName = "string", - Description = "string", - Properties = -{ -["string"] = "string", -}, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Kind = "string", - Identity = new ManagedServiceIdentity("SystemAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), -}, - }, - Sku = new MachineLearningSku("string") - { - Tier = MachineLearningSkuTier.Free, - Size = "string", - Family = "string", - Capacity = 1, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); - MachineLearningBatchEndpointResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningBatchEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningBatchEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchEndpointResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchEndpointResource.cs index 14b30ff9a3737..9c3d9fc0ca6e3 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchEndpointResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningBatchEndpointResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_MachineLearningBatchEndpointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceBatchEndpoint() + public async Task Get_GetWorkspaceBatchEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/delete.json - // this example is just showing the usage of "BatchEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/get.json + // this example is just showing the usage of "BatchEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,24 +31,28 @@ public async Task Delete_DeleteWorkspaceBatchEndpoint() // this example assumes you already have this MachineLearningBatchEndpointResource created on azure // for more information of creating MachineLearningBatchEndpointResource, please refer to the document of MachineLearningBatchEndpointResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "resourceGroup-1234"; - string workspaceName = "testworkspace"; - string endpointName = "testBatchEndpoint"; + string resourceGroupName = "test-rg"; + string workspaceName = "my-aml-workspace"; + string endpointName = "testEndpointName"; ResourceIdentifier machineLearningBatchEndpointResourceId = MachineLearningBatchEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, endpointName); MachineLearningBatchEndpointResource machineLearningBatchEndpoint = client.GetMachineLearningBatchEndpointResource(machineLearningBatchEndpointResourceId); // invoke the operation - await machineLearningBatchEndpoint.DeleteAsync(WaitUntil.Completed); + MachineLearningBatchEndpointResource result = await machineLearningBatchEndpoint.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningBatchEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceBatchEndpoint() + public async Task Delete_DeleteWorkspaceBatchEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/get.json - // this example is just showing the usage of "BatchEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/BatchEndpoint/delete.json + // this example is just showing the usage of "BatchEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,20 +62,16 @@ public async Task Get_GetWorkspaceBatchEndpoint() // this example assumes you already have this MachineLearningBatchEndpointResource created on azure // for more information of creating MachineLearningBatchEndpointResource, please refer to the document of MachineLearningBatchEndpointResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "test-rg"; - string workspaceName = "my-aml-workspace"; - string endpointName = "testEndpointName"; + string resourceGroupName = "resourceGroup-1234"; + string workspaceName = "testworkspace"; + string endpointName = "testBatchEndpoint"; ResourceIdentifier machineLearningBatchEndpointResourceId = MachineLearningBatchEndpointResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, endpointName); MachineLearningBatchEndpointResource machineLearningBatchEndpoint = client.GetMachineLearningBatchEndpointResource(machineLearningBatchEndpointResourceId); // invoke the operation - MachineLearningBatchEndpointResource result = await machineLearningBatchEndpoint.GetAsync(); + await machineLearningBatchEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningBatchEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,21 +96,17 @@ public async Task Update_UpdateWorkspaceBatchEndpoint() MachineLearningBatchEndpointResource machineLearningBatchEndpoint = client.GetMachineLearningBatchEndpointResource(machineLearningBatchEndpointResourceId); // invoke the operation - MachineLearningResourcePatchWithIdentity body = new MachineLearningResourcePatchWithIdentity() + MachineLearningResourcePatchWithIdentity body = new MachineLearningResourcePatchWithIdentity { - Identity = new MachineLearningPartialManagedServiceIdentity() + Identity = new MachineLearningPartialManagedServiceIdentity { ManagedServiceIdentityType = "SystemAssigned", UserAssignedIdentities = { -["string"] = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), +["string"] = BinaryData.FromObjectAsJson(new object()) }, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await machineLearningBatchEndpoint.UpdateAsync(WaitUntil.Completed, body); MachineLearningBatchEndpointResource result = lro.Value; diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeContainerCollection.cs index 8d6894ffd6a58..6d88e1214ff42 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningCodeContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceCodeContainer() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceCodeContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/list.json - // this example is just showing the usage of "CodeContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/createOrUpdate.json + // this example is just showing the usage of "CodeContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ListWorkspaceCodeContainer() // get the collection of this MachineLearningCodeContainerResource MachineLearningCodeContainerCollection collection = machineLearningWorkspace.GetMachineLearningCodeContainers(); - // invoke the operation and iterate over the result - await foreach (MachineLearningCodeContainerResource item in collection.GetAllAsync()) + // invoke the operation + string name = "testContainer"; + MachineLearningCodeContainerData data = new MachineLearningCodeContainerData(new MachineLearningCodeContainerProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningCodeContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetWorkspaceCodeContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceCodeContainer() + public async Task GetAll_ListWorkspaceCodeContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/get.json - // this example is just showing the usage of "CodeContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/list.json + // this example is just showing the usage of "CodeContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetWorkspaceCodeContainer() // get the collection of this MachineLearningCodeContainerResource MachineLearningCodeContainerCollection collection = machineLearningWorkspace.GetMachineLearningCodeContainers(); - // invoke the operation - string name = "testContainer"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (MachineLearningCodeContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceCodeContainer() + public async Task Exists_GetWorkspaceCodeContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/get.json // this example is just showing the usage of "CodeContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetWorkspaceCodeContainer() // invoke the operation string name = "testContainer"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningCodeContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceCodeContainer() + public async Task GetIfExists_GetWorkspaceCodeContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/createOrUpdate.json - // this example is just showing the usage of "CodeContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/get.json + // this example is just showing the usage of "CodeContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceCodeContainer() // invoke the operation string name = "testContainer"; - MachineLearningCodeContainerData data = new MachineLearningCodeContainerData(new MachineLearningCodeContainerProperties() - { - Description = "string", - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningCodeContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningCodeContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeContainerResource.cs index 6250fb42747dc..26b34413dcf44 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningCodeContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceCodeContainer() + public async Task Get_GetWorkspaceCodeContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/delete.json - // this example is just showing the usage of "CodeContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/get.json + // this example is just showing the usage of "CodeContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteWorkspaceCodeContainer() MachineLearningCodeContainerResource machineLearningCodeContainer = client.GetMachineLearningCodeContainerResource(machineLearningCodeContainerResourceId); // invoke the operation - await machineLearningCodeContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningCodeContainerResource result = await machineLearningCodeContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceCodeContainer() + public async Task Delete_DeleteWorkspaceCodeContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/get.json - // this example is just showing the usage of "CodeContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeContainer/delete.json + // this example is just showing the usage of "CodeContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetWorkspaceCodeContainer() MachineLearningCodeContainerResource machineLearningCodeContainer = client.GetMachineLearningCodeContainerResource(machineLearningCodeContainerResourceId); // invoke the operation - MachineLearningCodeContainerResource result = await machineLearningCodeContainer.GetAsync(); + await machineLearningCodeContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,13 +96,13 @@ public async Task Update_CreateOrUpdateWorkspaceCodeContainer() MachineLearningCodeContainerResource machineLearningCodeContainer = client.GetMachineLearningCodeContainerResource(machineLearningCodeContainerResourceId); // invoke the operation - MachineLearningCodeContainerData data = new MachineLearningCodeContainerData(new MachineLearningCodeContainerProperties() + MachineLearningCodeContainerData data = new MachineLearningCodeContainerData(new MachineLearningCodeContainerProperties { Description = "string", Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }); ArmOperation lro = await machineLearningCodeContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeVersionCollection.cs index d6b3f73068296..c60b122dbf1f2 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningCodeVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceCodeVersion() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceCodeVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/list.json - // this example is just showing the usage of "CodeVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/createOrUpdate.json + // this example is just showing the usage of "CodeVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,19 +40,30 @@ public async Task GetAll_ListWorkspaceCodeVersion() // get the collection of this MachineLearningCodeVersionResource MachineLearningCodeVersionCollection collection = machineLearningCodeContainer.GetMachineLearningCodeVersions(); - // invoke the operation and iterate over the result - string orderBy = "string"; - int? top = 1; - await foreach (MachineLearningCodeVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + // invoke the operation + string version = "string"; + MachineLearningCodeVersionData data = new MachineLearningCodeVersionData(new MachineLearningCodeVersionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CodeUri = new Uri("https://blobStorage/folderName"), + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningCodeVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +103,10 @@ public async Task Get_GetWorkspaceCodeVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceCodeVersion() + public async Task GetAll_ListWorkspaceCodeVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/get.json - // this example is just showing the usage of "CodeVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/list.json + // this example is just showing the usage of "CodeVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +125,24 @@ public async Task Exists_GetWorkspaceCodeVersion() // get the collection of this MachineLearningCodeVersionResource MachineLearningCodeVersionCollection collection = machineLearningCodeContainer.GetMachineLearningCodeVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + string orderBy = "string"; + int? top = 1; + await foreach (MachineLearningCodeVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceCodeVersion() + public async Task Exists_GetWorkspaceCodeVersion() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/get.json // this example is just showing the usage of "CodeVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,29 +166,17 @@ public async Task GetIfExists_GetWorkspaceCodeVersion() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningCodeVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceCodeVersion() + public async Task GetIfExists_GetWorkspaceCodeVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/createOrUpdate.json - // this example is just showing the usage of "CodeVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/get.json + // this example is just showing the usage of "CodeVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,28 +197,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceCodeVersion() // invoke the operation string version = "string"; - MachineLearningCodeVersionData data = new MachineLearningCodeVersionData(new MachineLearningCodeVersionProperties() - { - CodeUri = new Uri("https://blobStorage/folderName"), - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningCodeVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningCodeVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeVersionResource.cs index 17679352a12de..fb665408c991f 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningCodeVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningCodeVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceCodeVersion() + public async Task Get_GetWorkspaceCodeVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/delete.json - // this example is just showing the usage of "CodeVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/get.json + // this example is just showing the usage of "CodeVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteWorkspaceCodeVersion() MachineLearningCodeVersionResource machineLearningCodeVersion = client.GetMachineLearningCodeVersionResource(machineLearningCodeVersionResourceId); // invoke the operation - await machineLearningCodeVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningCodeVersionResource result = await machineLearningCodeVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceCodeVersion() + public async Task Delete_DeleteWorkspaceCodeVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/get.json - // this example is just showing the usage of "CodeVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/CodeVersion/delete.json + // this example is just showing the usage of "CodeVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetWorkspaceCodeVersion() MachineLearningCodeVersionResource machineLearningCodeVersion = client.GetMachineLearningCodeVersionResource(machineLearningCodeVersionResourceId); // invoke the operation - MachineLearningCodeVersionResource result = await machineLearningCodeVersion.GetAsync(); + await machineLearningCodeVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,18 +99,18 @@ public async Task Update_CreateOrUpdateWorkspaceCodeVersion() MachineLearningCodeVersionResource machineLearningCodeVersion = client.GetMachineLearningCodeVersionResource(machineLearningCodeVersionResourceId); // invoke the operation - MachineLearningCodeVersionData data = new MachineLearningCodeVersionData(new MachineLearningCodeVersionProperties() + MachineLearningCodeVersionData data = new MachineLearningCodeVersionData(new MachineLearningCodeVersionProperties { CodeUri = new Uri("https://blobStorage/folderName"), IsAnonymous = false, Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningCodeVersion.UpdateAsync(WaitUntil.Completed, data); @@ -146,7 +146,7 @@ public async Task Publish_PublishWorkspaceCodeVersion() MachineLearningCodeVersionResource machineLearningCodeVersion = client.GetMachineLearningCodeVersionResource(machineLearningCodeVersionResourceId); // invoke the operation - DestinationAssetContent content = new DestinationAssetContent() + DestinationAssetContent content = new DestinationAssetContent { RegistryName = "string", DestinationName = "string", @@ -180,7 +180,7 @@ public async Task CreateOrGetStartPendingUpload_CreateOrGetStartPendingUploadWor MachineLearningCodeVersionResource machineLearningCodeVersion = client.GetMachineLearningCodeVersionResource(machineLearningCodeVersionResourceId); // invoke the operation - PendingUploadRequestDto body = new PendingUploadRequestDto() + PendingUploadRequestDto body = new PendingUploadRequestDto { PendingUploadId = "string", PendingUploadType = PendingUploadType.None, diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentContainerCollection.cs index c86769cd2591b..83f70d318e6c7 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningComponentContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceComponentContainer() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceComponentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/list.json - // this example is just showing the usage of "ComponentContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/createOrUpdate.json + // this example is just showing the usage of "ComponentContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,28 @@ public async Task GetAll_ListWorkspaceComponentContainer() // get the collection of this MachineLearningComponentContainerResource MachineLearningComponentContainerCollection collection = machineLearningWorkspace.GetMachineLearningComponentContainers(); - // invoke the operation and iterate over the result - await foreach (MachineLearningComponentContainerResource item in collection.GetAllAsync()) + // invoke the operation + string name = "string"; + MachineLearningComponentContainerData data = new MachineLearningComponentContainerData(new MachineLearningComponentContainerProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningComponentContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +99,10 @@ public async Task Get_GetWorkspaceComponentContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceComponentContainer() + public async Task GetAll_ListWorkspaceComponentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/get.json - // this example is just showing the usage of "ComponentContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/list.json + // this example is just showing the usage of "ComponentContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +120,22 @@ public async Task Exists_GetWorkspaceComponentContainer() // get the collection of this MachineLearningComponentContainerResource MachineLearningComponentContainerCollection collection = machineLearningWorkspace.GetMachineLearningComponentContainers(); - // invoke the operation - string name = "string"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (MachineLearningComponentContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceComponentContainer() + public async Task Exists_GetWorkspaceComponentContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/get.json // this example is just showing the usage of "ComponentContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +158,17 @@ public async Task GetIfExists_GetWorkspaceComponentContainer() // invoke the operation string name = "string"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningComponentContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceComponentContainer() + public async Task GetIfExists_GetWorkspaceComponentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/createOrUpdate.json - // this example is just showing the usage of "ComponentContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/get.json + // this example is just showing the usage of "ComponentContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +188,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceComponentContainer() // invoke the operation string name = "string"; - MachineLearningComponentContainerData data = new MachineLearningComponentContainerData(new MachineLearningComponentContainerProperties() - { - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningComponentContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningComponentContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentContainerResource.cs index bd44df85958ab..a8272d0b94a85 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningComponentContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceComponentContainer() + public async Task Get_GetWorkspaceComponentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/delete.json - // this example is just showing the usage of "ComponentContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/get.json + // this example is just showing the usage of "ComponentContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteWorkspaceComponentContainer() MachineLearningComponentContainerResource machineLearningComponentContainer = client.GetMachineLearningComponentContainerResource(machineLearningComponentContainerResourceId); // invoke the operation - await machineLearningComponentContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningComponentContainerResource result = await machineLearningComponentContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceComponentContainer() + public async Task Delete_DeleteWorkspaceComponentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/get.json - // this example is just showing the usage of "ComponentContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentContainer/delete.json + // this example is just showing the usage of "ComponentContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetWorkspaceComponentContainer() MachineLearningComponentContainerResource machineLearningComponentContainer = client.GetMachineLearningComponentContainerResource(machineLearningComponentContainerResourceId); // invoke the operation - MachineLearningComponentContainerResource result = await machineLearningComponentContainer.GetAsync(); + await machineLearningComponentContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,16 +96,16 @@ public async Task Update_CreateOrUpdateWorkspaceComponentContainer() MachineLearningComponentContainerResource machineLearningComponentContainer = client.GetMachineLearningComponentContainerResource(machineLearningComponentContainerResourceId); // invoke the operation - MachineLearningComponentContainerData data = new MachineLearningComponentContainerData(new MachineLearningComponentContainerProperties() + MachineLearningComponentContainerData data = new MachineLearningComponentContainerData(new MachineLearningComponentContainerProperties { Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningComponentContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentVersionCollection.cs index 32d9bb34ab1b7..e2af88e882614 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentVersionCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MachineLearningComponentVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceComponentVersion() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceComponentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/list.json - // this example is just showing the usage of "ComponentVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/createOrUpdate.json + // this example is just showing the usage of "ComponentVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,19 +41,33 @@ public async Task GetAll_ListWorkspaceComponentVersion() // get the collection of this MachineLearningComponentVersionResource MachineLearningComponentVersionCollection collection = machineLearningComponentContainer.GetMachineLearningComponentVersions(); - // invoke the operation and iterate over the result - string orderBy = "string"; - int? top = 1; - await foreach (MachineLearningComponentVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + // invoke the operation + string version = "string"; + MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(new MachineLearningComponentVersionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ComponentSpec = BinaryData.FromObjectAsJson(new Dictionary + { + ["8ced901b-d826-477d-bfef-329da9672513"] = null + }), + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningComponentVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -93,10 +107,10 @@ public async Task Get_GetWorkspaceComponentVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceComponentVersion() + public async Task GetAll_ListWorkspaceComponentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/get.json - // this example is just showing the usage of "ComponentVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/list.json + // this example is just showing the usage of "ComponentVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +129,24 @@ public async Task Exists_GetWorkspaceComponentVersion() // get the collection of this MachineLearningComponentVersionResource MachineLearningComponentVersionCollection collection = machineLearningComponentContainer.GetMachineLearningComponentVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + string orderBy = "string"; + int? top = 1; + await foreach (MachineLearningComponentVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceComponentVersion() + public async Task Exists_GetWorkspaceComponentVersion() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/get.json // this example is just showing the usage of "ComponentVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +170,17 @@ public async Task GetIfExists_GetWorkspaceComponentVersion() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningComponentVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceComponentVersion() + public async Task GetIfExists_GetWorkspaceComponentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/createOrUpdate.json - // this example is just showing the usage of "ComponentVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/get.json + // this example is just showing the usage of "ComponentVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,31 +201,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceComponentVersion() // invoke the operation string version = "string"; - MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(new MachineLearningComponentVersionProperties() - { - ComponentSpec = BinaryData.FromObjectAsJson(new Dictionary() - { - ["8ced901b-d826-477d-bfef-329da9672513"] = null - }), - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningComponentVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningComponentVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentVersionResource.cs index 7b67039c1aca9..45f7bed807d25 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComponentVersionResource.cs @@ -19,10 +19,10 @@ public partial class Sample_MachineLearningComponentVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceComponentVersion() + public async Task Get_GetWorkspaceComponentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/delete.json - // this example is just showing the usage of "ComponentVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/get.json + // this example is just showing the usage of "ComponentVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,21 @@ public async Task Delete_DeleteWorkspaceComponentVersion() MachineLearningComponentVersionResource machineLearningComponentVersion = client.GetMachineLearningComponentVersionResource(machineLearningComponentVersionResourceId); // invoke the operation - await machineLearningComponentVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningComponentVersionResource result = await machineLearningComponentVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComponentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceComponentVersion() + public async Task Delete_DeleteWorkspaceComponentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/get.json - // this example is just showing the usage of "ComponentVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ComponentVersion/delete.json + // this example is just showing the usage of "ComponentVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,13 +72,9 @@ public async Task Get_GetWorkspaceComponentVersion() MachineLearningComponentVersionResource machineLearningComponentVersion = client.GetMachineLearningComponentVersionResource(machineLearningComponentVersionResourceId); // invoke the operation - MachineLearningComponentVersionResource result = await machineLearningComponentVersion.GetAsync(); + await machineLearningComponentVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComponentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -100,9 +100,9 @@ public async Task Update_CreateOrUpdateWorkspaceComponentVersion() MachineLearningComponentVersionResource machineLearningComponentVersion = client.GetMachineLearningComponentVersionResource(machineLearningComponentVersionResourceId); // invoke the operation - MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(new MachineLearningComponentVersionProperties() + MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(new MachineLearningComponentVersionProperties { - ComponentSpec = BinaryData.FromObjectAsJson(new Dictionary() + ComponentSpec = BinaryData.FromObjectAsJson(new Dictionary { ["8ced901b-d826-477d-bfef-329da9672513"] = null }), @@ -110,11 +110,11 @@ public async Task Update_CreateOrUpdateWorkspaceComponentVersion() Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningComponentVersion.UpdateAsync(WaitUntil.Completed, data); @@ -150,7 +150,7 @@ public async Task Publish_PublishWorkspaceComponentVersion() MachineLearningComponentVersionResource machineLearningComponentVersion = client.GetMachineLearningComponentVersionResource(machineLearningComponentVersionResourceId); // invoke the operation - DestinationAssetContent content = new DestinationAssetContent() + DestinationAssetContent content = new DestinationAssetContent { RegistryName = "string", DestinationName = "string", diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComputeCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComputeCollection.cs index 0b23d92c43e19..9d742d350e8e1 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComputeCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComputeCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MachineLearningComputeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetComputes() + public async Task CreateOrUpdate_AttachAKubernetesCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/list.json - // this example is just showing the usage of "Compute_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/KubernetesCompute.json + // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,59 @@ public async Task GetAll_GetComputes() // get the collection of this MachineLearningComputeResource MachineLearningComputeCollection collection = machineLearningWorkspace.GetMachineLearningComputes(); - // invoke the operation and iterate over the result - await foreach (MachineLearningComputeResource item in collection.GetAllAsync()) + // invoke the operation + string computeName = "compute123"; + MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new MachineLearningKubernetesCompute + { + Properties = new MachineLearningKubernetesProperties + { + Namespace = "default", + DefaultInstanceType = "defaultInstanceType", + InstanceTypes = +{ +["defaultInstanceType"] = new MachineLearningInstanceTypeSchema +{ +NodeSelector = {}, +Resources = new MachineLearningInstanceTypeSchemaResources +{ +Requests = +{ +["cpu"] = "1", +["memory"] = "4Gi", +["nvidia.com/gpu"] = null +}, +Limits = +{ +["cpu"] = "1", +["memory"] = "4Gi", +["nvidia.com/gpu"] = null +}, +}, +} +}, + }, + Description = "some compute", + ResourceId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/Microsoft.ContainerService/managedClusters/compute123-56826-c9b00420020b2"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); + MachineLearningComputeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAAKSCompute() + public async Task CreateOrUpdate_CreateAAMLCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AKSCompute.json - // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/BasicAmlCompute.json + // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,7 +112,29 @@ public async Task Get_GetAAKSCompute() // invoke the operation string computeName = "compute123"; - MachineLearningComputeResource result = await collection.GetAsync(computeName); + MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) + { + Properties = new AmlCompute + { + Properties = new AmlComputeProperties + { + OSType = MachineLearningOSType.Windows, + VmSize = "STANDARD_NC6", + VmPriority = MachineLearningVmPriority.Dedicated, + VirtualMachineImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myImageGallery/images/myImageDefinition/versions/0.0.1", + IsolatedNetwork = false, + ScaleSettings = new AmlComputeScaleSettings(1) + { + MinNodeCount = 0, + NodeIdleTimeBeforeScaleDown = XmlConvert.ToTimeSpan("PT5M"), + }, + RemoteLoginPortPublicAccess = MachineLearningRemoteLoginPortPublicAccess.NotSpecified, + EnableNodePublicIP = true, + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); + MachineLearningComputeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +145,10 @@ public async Task Get_GetAAKSCompute() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAAKSCompute() + public async Task CreateOrUpdate_CreateADataFactoryCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AKSCompute.json - // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/BasicDataFactoryCompute.json + // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,17 +168,26 @@ public async Task Exists_GetAAKSCompute() // invoke the operation string computeName = "compute123"; - bool result = await collection.ExistsAsync(computeName); + MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) + { + Properties = new MachineLearningDataFactoryCompute(), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); + MachineLearningComputeResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAAKSCompute() + public async Task CreateOrUpdate_CreateAnAKSCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AKSCompute.json - // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/BasicAKSCompute.json + // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,29 +207,26 @@ public async Task GetIfExists_GetAAKSCompute() // invoke the operation string computeName = "compute123"; - NullableResponse response = await collection.GetIfExistsAsync(computeName); - MachineLearningComputeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new MachineLearningAksCompute(), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); + MachineLearningComputeResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAAMLCompute() + public async Task CreateOrUpdate_CreateAnComputeInstanceCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AmlCompute.json - // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/ComputeInstance.json + // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,7 +246,61 @@ public async Task Get_GetAAMLCompute() // invoke the operation string computeName = "compute123"; - MachineLearningComputeResource result = await collection.GetAsync(computeName); + MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) + { + Properties = new MachineLearningComputeInstance + { + Properties = new MachineLearningComputeInstanceProperties + { + VmSize = "STANDARD_NC6", + SubnetId = new ResourceIdentifier("test-subnet-resource-id"), + ApplicationSharingPolicy = MachineLearningApplicationSharingPolicy.Personal, + SshSettings = new MachineLearningComputeInstanceSshSettings + { + SshPublicAccess = MachineLearningSshPublicAccess.Disabled, + }, + CustomServices = {new CustomService +{ +Name = "rstudio", +Image = new ImageSetting +{ +ImageType = ImageType.Docker, +Reference = "ghcr.io/azure/rocker-rstudio-ml-verse:latest", +}, +EnvironmentVariables = +{ +["test_variable"] = new EnvironmentVariable +{ +VariableType = EnvironmentVariableType.Local, +Value = "test_value", +} +}, +Docker = new DockerSetting +{ +Privileged = true, +}, +Endpoints = {new ContainerEndpoint +{ +Protocol = ContainerCommunicationProtocol.Http, +Name = "connect", +Target = 8787, +Published = 8787, +}}, +Volumes = {new VolumeDefinition +{ +DefinitionType = VolumeDefinitionType.Bind, +ReadOnly = false, +Source = "/home/azureuser/cloudfiles", +Target = "/home/azureuser/cloudfiles", +}}, +}}, + ComputeInstanceAuthorizationType = MachineLearningComputeInstanceAuthorizationType.Personal, + PersonalComputeInstanceAssignedUser = new MachineLearningComputeInstanceAssignedUser("00000000-0000-0000-0000-000000000000", Guid.Parse("00000000-0000-0000-0000-000000000000")), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); + MachineLearningComputeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -195,10 +311,10 @@ public async Task Get_GetAAMLCompute() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAAMLCompute() + public async Task CreateOrUpdate_CreateAnComputeInstanceComputeWithSchedules() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AmlCompute.json - // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/ComputeInstanceWithSchedules.json + // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -218,17 +334,39 @@ public async Task Exists_GetAAMLCompute() // invoke the operation string computeName = "compute123"; - bool result = await collection.ExistsAsync(computeName); + MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) + { + Properties = new MachineLearningComputeInstance + { + Properties = new MachineLearningComputeInstanceProperties + { + VmSize = "STANDARD_NC6", + ApplicationSharingPolicy = MachineLearningApplicationSharingPolicy.Personal, + SshSettings = new MachineLearningComputeInstanceSshSettings + { + SshPublicAccess = MachineLearningSshPublicAccess.Disabled, + }, + ComputeInstanceAuthorizationType = MachineLearningComputeInstanceAuthorizationType.Personal, + PersonalComputeInstanceAssignedUser = new MachineLearningComputeInstanceAssignedUser("00000000-0000-0000-0000-000000000000", Guid.Parse("00000000-0000-0000-0000-000000000000")), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); + MachineLearningComputeResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAAMLCompute() + public async Task CreateOrUpdate_CreateAnComputeInstanceComputeWithMinimalInputs() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AmlCompute.json - // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/ComputeInstanceMinimal.json + // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -248,29 +386,32 @@ public async Task GetIfExists_GetAAMLCompute() // invoke the operation string computeName = "compute123"; - NullableResponse response = await collection.GetIfExistsAsync(computeName); - MachineLearningComputeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new MachineLearningComputeInstance + { + Properties = new MachineLearningComputeInstanceProperties + { + VmSize = "STANDARD_NC6", + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); + MachineLearningComputeResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAKubernetesCompute() + public async Task CreateOrUpdate_UpdateAAMLCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/KubernetesCompute.json - // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/AmlCompute.json + // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -290,21 +431,37 @@ public async Task Get_GetAKubernetesCompute() // invoke the operation string computeName = "compute123"; - MachineLearningComputeResource result = await collection.GetAsync(computeName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) + { + Properties = new AmlCompute + { + Properties = new AmlComputeProperties + { + ScaleSettings = new AmlComputeScaleSettings(4) + { + MinNodeCount = 4, + NodeIdleTimeBeforeScaleDown = XmlConvert.ToTimeSpan("PT5M"), + }, + }, + Description = "some compute", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); + MachineLearningComputeResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAKubernetesCompute() + public async Task CreateOrUpdate_UpdateAnAKSCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/KubernetesCompute.json - // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/AKSCompute.json + // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -324,16 +481,33 @@ public async Task Exists_GetAKubernetesCompute() // invoke the operation string computeName = "compute123"; - bool result = await collection.ExistsAsync(computeName); + MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) + { + Properties = new MachineLearningAksCompute + { + Properties = new MachineLearningAksComputeProperties + { + AgentCount = 4, + }, + Description = "some compute", + ResourceId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/Microsoft.ContainerService/managedClusters/compute123-56826-c9b00420020b2"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); + MachineLearningComputeResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAKubernetesCompute() + public async Task Get_GetAAKSCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/KubernetesCompute.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AKSCompute.json // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -354,28 +528,20 @@ public async Task GetIfExists_GetAKubernetesCompute() // invoke the operation string computeName = "compute123"; - NullableResponse response = await collection.GetIfExistsAsync(computeName); - MachineLearningComputeResource result = response.HasValue ? response.Value : null; + MachineLearningComputeResource result = await collection.GetAsync(computeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnComputeInstance() + public async Task Get_GetAAMLCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/ComputeInstance.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AmlCompute.json // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -407,9 +573,9 @@ public async Task Get_GetAnComputeInstance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnComputeInstance() + public async Task Get_GetAKubernetesCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/ComputeInstance.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/KubernetesCompute.json // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -430,14 +596,18 @@ public async Task Exists_GetAnComputeInstance() // invoke the operation string computeName = "compute123"; - bool result = await collection.ExistsAsync(computeName); + MachineLearningComputeResource result = await collection.GetAsync(computeName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnComputeInstance() + public async Task Get_GetAnComputeInstance() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/ComputeInstance.json // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. @@ -460,29 +630,21 @@ public async Task GetIfExists_GetAnComputeInstance() // invoke the operation string computeName = "compute123"; - NullableResponse response = await collection.GetIfExistsAsync(computeName); - MachineLearningComputeResource result = response.HasValue ? response.Value : null; + MachineLearningComputeResource result = await collection.GetAsync(computeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AttachAKubernetesCompute() + public async Task GetAll_GetComputes() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/KubernetesCompute.json - // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/list.json + // this example is just showing the usage of "Compute_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -500,61 +662,25 @@ public async Task CreateOrUpdate_AttachAKubernetesCompute() // get the collection of this MachineLearningComputeResource MachineLearningComputeCollection collection = machineLearningWorkspace.GetMachineLearningComputes(); - // invoke the operation - string computeName = "compute123"; - MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) + // invoke the operation and iterate over the result + await foreach (MachineLearningComputeResource item in collection.GetAllAsync()) { - Properties = new MachineLearningKubernetesCompute() - { - Properties = new MachineLearningKubernetesProperties() - { - Namespace = "default", - DefaultInstanceType = "defaultInstanceType", - InstanceTypes = -{ -["defaultInstanceType"] = new MachineLearningInstanceTypeSchema() -{ -NodeSelector = -{ -}, -Resources = new MachineLearningInstanceTypeSchemaResources() -{ -Requests = -{ -["cpu"] = "1", -["memory"] = "4Gi", -["nvidia.com/gpu"] = null, -}, -Limits = -{ -["cpu"] = "1", -["memory"] = "4Gi", -["nvidia.com/gpu"] = null, -}, -}, -}, -}, - }, - Description = "some compute", - ResourceId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/Microsoft.ContainerService/managedClusters/compute123-56826-c9b00420020b2"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); - MachineLearningComputeResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAAMLCompute() + public async Task Exists_GetAAKSCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/BasicAmlCompute.json - // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AKSCompute.json + // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -574,43 +700,17 @@ public async Task CreateOrUpdate_CreateAAMLCompute() // invoke the operation string computeName = "compute123"; - MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) - { - Properties = new AmlCompute() - { - Properties = new AmlComputeProperties() - { - OSType = MachineLearningOSType.Windows, - VmSize = "STANDARD_NC6", - VmPriority = MachineLearningVmPriority.Dedicated, - VirtualMachineImageId = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Compute/galleries/myImageGallery/images/myImageDefinition/versions/0.0.1", - IsolatedNetwork = false, - ScaleSettings = new AmlComputeScaleSettings(1) - { - MinNodeCount = 0, - NodeIdleTimeBeforeScaleDown = XmlConvert.ToTimeSpan("PT5M"), - }, - RemoteLoginPortPublicAccess = MachineLearningRemoteLoginPortPublicAccess.NotSpecified, - EnableNodePublicIP = true, - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); - MachineLearningComputeResource result = lro.Value; + bool result = await collection.ExistsAsync(computeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADataFactoryCompute() + public async Task Exists_GetAAMLCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/BasicDataFactoryCompute.json - // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AmlCompute.json + // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -630,26 +730,17 @@ public async Task CreateOrUpdate_CreateADataFactoryCompute() // invoke the operation string computeName = "compute123"; - MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) - { - Properties = new MachineLearningDataFactoryCompute(), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); - MachineLearningComputeResource result = lro.Value; + bool result = await collection.ExistsAsync(computeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAKSCompute() + public async Task Exists_GetAKubernetesCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/BasicAKSCompute.json - // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/KubernetesCompute.json + // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -669,26 +760,17 @@ public async Task CreateOrUpdate_CreateAnAKSCompute() // invoke the operation string computeName = "compute123"; - MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) - { - Properties = new MachineLearningAksCompute(), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); - MachineLearningComputeResource result = lro.Value; + bool result = await collection.ExistsAsync(computeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnComputeInstanceCompute() + public async Task Exists_GetAnComputeInstance() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/ComputeInstance.json - // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/ComputeInstance.json + // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -708,84 +790,17 @@ public async Task CreateOrUpdate_CreateAnComputeInstanceCompute() // invoke the operation string computeName = "compute123"; - MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) - { - Properties = new MachineLearningComputeInstance() - { - Properties = new MachineLearningComputeInstanceProperties() - { - VmSize = "STANDARD_NC6", - SubnetId = new ResourceIdentifier("test-subnet-resource-id"), - ApplicationSharingPolicy = MachineLearningApplicationSharingPolicy.Personal, - SshSettings = new MachineLearningComputeInstanceSshSettings() - { - SshPublicAccess = MachineLearningSshPublicAccess.Disabled, - }, - CustomServices = -{ -new CustomService() -{ -Name = "rstudio", -Image = new ImageSetting() -{ -ImageType = ImageType.Docker, -Reference = "ghcr.io/azure/rocker-rstudio-ml-verse:latest", -}, -EnvironmentVariables = -{ -["test_variable"] = new EnvironmentVariable() -{ -VariableType = EnvironmentVariableType.Local, -Value = "test_value", -}, -}, -Docker = new DockerSetting() -{ -Privileged = true, -}, -Endpoints = -{ -new ContainerEndpoint() -{ -Protocol = ContainerCommunicationProtocol.Http, -Name = "connect", -Target = 8787, -Published = 8787, -} -}, -Volumes = -{ -new VolumeDefinition() -{ -DefinitionType = VolumeDefinitionType.Bind, -ReadOnly = false, -Source = "/home/azureuser/cloudfiles", -Target = "/home/azureuser/cloudfiles", -} -}, -} -}, - ComputeInstanceAuthorizationType = MachineLearningComputeInstanceAuthorizationType.Personal, - PersonalComputeInstanceAssignedUser = new MachineLearningComputeInstanceAssignedUser("00000000-0000-0000-0000-000000000000", Guid.Parse("00000000-0000-0000-0000-000000000000")), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); - MachineLearningComputeResource result = lro.Value; + bool result = await collection.ExistsAsync(computeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnComputeInstanceComputeWithSchedules() + public async Task GetIfExists_GetAAKSCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/ComputeInstanceWithSchedules.json - // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AKSCompute.json + // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -805,39 +820,29 @@ public async Task CreateOrUpdate_CreateAnComputeInstanceComputeWithSchedules() // invoke the operation string computeName = "compute123"; - MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) - { - Properties = new MachineLearningComputeInstance() - { - Properties = new MachineLearningComputeInstanceProperties() - { - VmSize = "STANDARD_NC6", - ApplicationSharingPolicy = MachineLearningApplicationSharingPolicy.Personal, - SshSettings = new MachineLearningComputeInstanceSshSettings() - { - SshPublicAccess = MachineLearningSshPublicAccess.Disabled, - }, - ComputeInstanceAuthorizationType = MachineLearningComputeInstanceAuthorizationType.Personal, - PersonalComputeInstanceAssignedUser = new MachineLearningComputeInstanceAssignedUser("00000000-0000-0000-0000-000000000000", Guid.Parse("00000000-0000-0000-0000-000000000000")), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); - MachineLearningComputeResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(computeName); + MachineLearningComputeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnComputeInstanceComputeWithMinimalInputs() + public async Task GetIfExists_GetAAMLCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/ComputeInstanceMinimal.json - // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/AmlCompute.json + // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -857,32 +862,29 @@ public async Task CreateOrUpdate_CreateAnComputeInstanceComputeWithMinimalInputs // invoke the operation string computeName = "compute123"; - MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) - { - Properties = new MachineLearningComputeInstance() - { - Properties = new MachineLearningComputeInstanceProperties() - { - VmSize = "STANDARD_NC6", - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); - MachineLearningComputeResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(computeName); + MachineLearningComputeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAAMLCompute() + public async Task GetIfExists_GetAKubernetesCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/AmlCompute.json - // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/KubernetesCompute.json + // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -902,37 +904,29 @@ public async Task CreateOrUpdate_UpdateAAMLCompute() // invoke the operation string computeName = "compute123"; - MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) - { - Properties = new AmlCompute() - { - Properties = new AmlComputeProperties() - { - ScaleSettings = new AmlComputeScaleSettings(4) - { - MinNodeCount = 4, - NodeIdleTimeBeforeScaleDown = XmlConvert.ToTimeSpan("PT5M"), - }, - }, - Description = "some compute", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); - MachineLearningComputeResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(computeName); + MachineLearningComputeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAnAKSCompute() + public async Task GetIfExists_GetAnComputeInstance() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/createOrUpdate/AKSCompute.json - // this example is just showing the usage of "Compute_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/get/ComputeInstance.json + // this example is just showing the usage of "Compute_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -952,26 +946,21 @@ public async Task CreateOrUpdate_UpdateAnAKSCompute() // invoke the operation string computeName = "compute123"; - MachineLearningComputeData data = new MachineLearningComputeData(new AzureLocation("eastus")) - { - Properties = new MachineLearningAksCompute() - { - Properties = new MachineLearningAksComputeProperties() - { - AgentCount = 4, - }, - Description = "some compute", - ResourceId = new ResourceIdentifier("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourcegroups/testrg123/providers/Microsoft.ContainerService/managedClusters/compute123-56826-c9b00420020b2"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, computeName, data); - MachineLearningComputeResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(computeName); + MachineLearningComputeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComputeResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComputeResource.cs index 2c2d887ac2325..f680e1762d3ac 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComputeResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningComputeResource.cs @@ -143,10 +143,10 @@ public async Task Get_GetAnComputeInstance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAAmlComputeCompute() + public async Task Delete_DeleteCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/patch.json - // this example is just showing the usage of "Compute_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/delete.json + // this example is just showing the usage of "Compute_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -163,30 +163,18 @@ public async Task Update_UpdateAAmlComputeCompute() MachineLearningComputeResource machineLearningCompute = client.GetMachineLearningComputeResource(machineLearningComputeResourceId); // invoke the operation - MachineLearningComputePatch patch = new MachineLearningComputePatch() - { - ScaleSettings = new AmlComputeScaleSettings(4) - { - MinNodeCount = 4, - NodeIdleTimeBeforeScaleDown = XmlConvert.ToTimeSpan("PT5M"), - }, - }; - ArmOperation lro = await machineLearningCompute.UpdateAsync(WaitUntil.Completed, patch); - MachineLearningComputeResource result = lro.Value; + MachineLearningUnderlyingResourceAction underlyingResourceAction = MachineLearningUnderlyingResourceAction.Delete; + await machineLearningCompute.DeleteAsync(WaitUntil.Completed, underlyingResourceAction); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningComputeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteCompute() + public async Task Update_UpdateAAmlComputeCompute() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/delete.json - // this example is just showing the usage of "Compute_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Compute/patch.json + // this example is just showing the usage of "Compute_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -203,10 +191,22 @@ public async Task Delete_DeleteCompute() MachineLearningComputeResource machineLearningCompute = client.GetMachineLearningComputeResource(machineLearningComputeResourceId); // invoke the operation - MachineLearningUnderlyingResourceAction underlyingResourceAction = MachineLearningUnderlyingResourceAction.Delete; - await machineLearningCompute.DeleteAsync(WaitUntil.Completed, underlyingResourceAction); + MachineLearningComputePatch patch = new MachineLearningComputePatch + { + ScaleSettings = new AmlComputeScaleSettings(4) + { + MinNodeCount = 4, + NodeIdleTimeBeforeScaleDown = XmlConvert.ToTimeSpan("PT5M"), + }, + }; + ArmOperation lro = await machineLearningCompute.UpdateAsync(WaitUntil.Completed, patch); + MachineLearningComputeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningComputeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataContainerCollection.cs index c52a96318f7cd..eefa24e3cfb15 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningDataContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceDataContainer() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceDataContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/list.json - // this example is just showing the usage of "DataContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/createOrUpdate.json + // this example is just showing the usage of "DataContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,30 @@ public async Task GetAll_ListWorkspaceDataContainer() // get the collection of this MachineLearningDataContainerResource MachineLearningDataContainerCollection collection = machineLearningWorkspace.GetMachineLearningDataContainers(); - // invoke the operation and iterate over the result - await foreach (MachineLearningDataContainerResource item in collection.GetAllAsync()) + // invoke the operation + string name = "datacontainer123"; + MachineLearningDataContainerData data = new MachineLearningDataContainerData(new MachineLearningDataContainerProperties(new MachineLearningDataType("UriFile")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + Properties = +{ +["properties1"] = "value1", +["properties2"] = "value2" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningDataContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +101,10 @@ public async Task Get_GetWorkspaceDataContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceDataContainer() + public async Task GetAll_ListWorkspaceDataContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/get.json - // this example is just showing the usage of "DataContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/list.json + // this example is just showing the usage of "DataContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +122,22 @@ public async Task Exists_GetWorkspaceDataContainer() // get the collection of this MachineLearningDataContainerResource MachineLearningDataContainerCollection collection = machineLearningWorkspace.GetMachineLearningDataContainers(); - // invoke the operation - string name = "datacontainer123"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (MachineLearningDataContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceDataContainer() + public async Task Exists_GetWorkspaceDataContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/get.json // this example is just showing the usage of "DataContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +160,17 @@ public async Task GetIfExists_GetWorkspaceDataContainer() // invoke the operation string name = "datacontainer123"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningDataContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceDataContainer() + public async Task GetIfExists_GetWorkspaceDataContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/createOrUpdate.json - // this example is just showing the usage of "DataContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/get.json + // this example is just showing the usage of "DataContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,28 +190,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceDataContainer() // invoke the operation string name = "datacontainer123"; - MachineLearningDataContainerData data = new MachineLearningDataContainerData(new MachineLearningDataContainerProperties(new MachineLearningDataType("UriFile")) - { - Description = "string", - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - Properties = -{ -["properties1"] = "value1", -["properties2"] = "value2", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningDataContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningDataContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataContainerResource.cs index d480c77e8033d..a06ac34fda940 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningDataContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceDataContainer() + public async Task Get_GetWorkspaceDataContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/delete.json - // this example is just showing the usage of "DataContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/get.json + // this example is just showing the usage of "DataContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteWorkspaceDataContainer() MachineLearningDataContainerResource machineLearningDataContainer = client.GetMachineLearningDataContainerResource(machineLearningDataContainerResourceId); // invoke the operation - await machineLearningDataContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningDataContainerResource result = await machineLearningDataContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceDataContainer() + public async Task Delete_DeleteWorkspaceDataContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/get.json - // this example is just showing the usage of "DataContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataContainer/delete.json + // this example is just showing the usage of "DataContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetWorkspaceDataContainer() MachineLearningDataContainerResource machineLearningDataContainer = client.GetMachineLearningDataContainerResource(machineLearningDataContainerResourceId); // invoke the operation - MachineLearningDataContainerResource result = await machineLearningDataContainer.GetAsync(); + await machineLearningDataContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -102,12 +102,12 @@ public async Task Update_CreateOrUpdateWorkspaceDataContainer() Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, Properties = { ["properties1"] = "value1", -["properties2"] = "value2", +["properties2"] = "value2" }, }); ArmOperation lro = await machineLearningDataContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataVersionCollection.cs index 03d731ce71897..1d995bd69725a 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningDataVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceDataVersionBase() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceDataVersionBase() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/list.json - // this example is just showing the usage of "DataVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/createOrUpdate.json + // this example is just showing the usage of "DataVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,20 +40,29 @@ public async Task GetAll_ListWorkspaceDataVersionBase() // get the collection of this MachineLearningDataVersionResource MachineLearningDataVersionCollection collection = machineLearningDataContainer.GetMachineLearningDataVersions(); - // invoke the operation and iterate over the result - string orderBy = "string"; - int? top = 1; - string tags = "string"; - await foreach (MachineLearningDataVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top, tags: tags)) + // invoke the operation + string version = "string"; + MachineLearningDataVersionData data = new MachineLearningDataVersionData(new MachineLearningUriFileDataVersion(new Uri("string")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningDataVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -93,10 +102,10 @@ public async Task Get_GetWorkspaceDataVersionBase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceDataVersionBase() + public async Task GetAll_ListWorkspaceDataVersionBase() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/get.json - // this example is just showing the usage of "DataVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/list.json + // this example is just showing the usage of "DataVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +124,25 @@ public async Task Exists_GetWorkspaceDataVersionBase() // get the collection of this MachineLearningDataVersionResource MachineLearningDataVersionCollection collection = machineLearningDataContainer.GetMachineLearningDataVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + string orderBy = "string"; + int? top = 1; + string tags = "string"; + await foreach (MachineLearningDataVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top, tags: tags)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceDataVersionBase() + public async Task Exists_GetWorkspaceDataVersionBase() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/get.json // this example is just showing the usage of "DataVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +166,17 @@ public async Task GetIfExists_GetWorkspaceDataVersionBase() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningDataVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceDataVersionBase() + public async Task GetIfExists_GetWorkspaceDataVersionBase() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/createOrUpdate.json - // this example is just showing the usage of "DataVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/get.json + // this example is just showing the usage of "DataVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,27 +197,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceDataVersionBase() // invoke the operation string version = "string"; - MachineLearningDataVersionData data = new MachineLearningDataVersionData(new MachineLearningUriFileDataVersion(new Uri("string")) - { - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningDataVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningDataVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataVersionResource.cs index a880d849a19b4..e2e9f306f1ce7 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDataVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningDataVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceDataVersionBase() + public async Task Get_GetWorkspaceDataVersionBase() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/delete.json - // this example is just showing the usage of "DataVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/get.json + // this example is just showing the usage of "DataVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteWorkspaceDataVersionBase() MachineLearningDataVersionResource machineLearningDataVersion = client.GetMachineLearningDataVersionResource(machineLearningDataVersionResourceId); // invoke the operation - await machineLearningDataVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningDataVersionResource result = await machineLearningDataVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceDataVersionBase() + public async Task Delete_DeleteWorkspaceDataVersionBase() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/get.json - // this example is just showing the usage of "DataVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/DataVersionBase/delete.json + // this example is just showing the usage of "DataVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetWorkspaceDataVersionBase() MachineLearningDataVersionResource machineLearningDataVersion = client.GetMachineLearningDataVersionResource(machineLearningDataVersionResourceId); // invoke the operation - MachineLearningDataVersionResource result = await machineLearningDataVersion.GetAsync(); + await machineLearningDataVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -105,11 +105,11 @@ public async Task Update_CreateOrUpdateWorkspaceDataVersionBase() Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningDataVersion.UpdateAsync(WaitUntil.Completed, data); @@ -145,7 +145,7 @@ public async Task Publish_PublishWorkspaceDataVersionBase() MachineLearningDataVersionResource machineLearningDataVersion = client.GetMachineLearningDataVersionResource(machineLearningDataVersionResourceId); // invoke the operation - DestinationAssetContent content = new DestinationAssetContent() + DestinationAssetContent content = new DestinationAssetContent { RegistryName = "string", DestinationName = "string", diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDatastoreCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDatastoreCollection.cs index f0b3789055096..cd1637fa64cca 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDatastoreCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDatastoreCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningDatastoreCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatastore() + public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureDataLakeGen1WServicePrincipal() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/get.json - // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/AzureDataLakeGen1WServicePrincipal/createOrUpdate.json + // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,25 @@ public async Task Get_GetDatastore() // invoke the operation string name = "string"; - MachineLearningDatastoreResource result = await collection.GetAsync(name); + MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureDataLakeGen1Datastore(new MachineLearningServicePrincipalDatastoreCredentials(Guid.Parse("00000000-1111-2222-3333-444444444444"), Guid.Parse("00000000-1111-2222-3333-444444444444"), new MachineLearningServicePrincipalDatastoreSecrets + { + ClientSecret = "string", + }) + { + AuthorityUri = new Uri("string"), + ResourceUri = new Uri("string"), + }, "string") + { + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = { }, + }); + bool? skipValidation = false; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data, skipValidation: skipValidation); + MachineLearningDatastoreResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +70,10 @@ public async Task Get_GetDatastore() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDatastore() + public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureDataLakeGen2WServicePrincipal() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/get.json - // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/AzureDataLakeGen2WServicePrincipal/createOrUpdate.json + // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +93,41 @@ public async Task Exists_GetDatastore() // invoke the operation string name = "string"; - bool result = await collection.ExistsAsync(name); + MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureDataLakeGen2Datastore(new MachineLearningServicePrincipalDatastoreCredentials(Guid.Parse("00000000-1111-2222-3333-444444444444"), Guid.Parse("00000000-1111-2222-3333-444444444444"), new MachineLearningServicePrincipalDatastoreSecrets + { + ClientSecret = "string", + }) + { + AuthorityUri = new Uri("string"), + ResourceUri = new Uri("string"), + }, "string", "string") + { + Endpoint = "string", + Protocol = "string", + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = { }, + }); + bool? skipValidation = false; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data, skipValidation: skipValidation); + MachineLearningDatastoreResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDatastoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDatastore() + public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureFileStoreWAccountKey() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/get.json - // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/AzureFileWAccountKey/createOrUpdate.json + // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,28 +147,36 @@ public async Task GetIfExists_GetDatastore() // invoke the operation string name = "string"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningDatastoreResource result = response.HasValue ? response.Value : null; - - if (result == null) + MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureFileDatastore(new MachineLearningAccountKeyDatastoreCredentials(new MachineLearningAccountKeyDatastoreSecrets { - Console.WriteLine("Succeeded with null as result"); - } - else + Key = "string", + }), "string", "string") { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDatastoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Endpoint = "string", + Protocol = "string", + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = { }, + }); + bool? skipValidation = false; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data, skipValidation: skipValidation); + MachineLearningDatastoreResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDatastoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureDataLakeGen1WServicePrincipal() + public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureBlobWAccountKey() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/AzureDataLakeGen1WServicePrincipal/createOrUpdate.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/AzureBlobWAccountKey/createOrUpdate.json // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -147,23 +197,21 @@ public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureDataLakeGen1WServic // invoke the operation string name = "string"; - MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureDataLakeGen1Datastore(new MachineLearningServicePrincipalDatastoreCredentials(Guid.Parse("00000000-1111-2222-3333-444444444444"), Guid.Parse("00000000-1111-2222-3333-444444444444"), new MachineLearningServicePrincipalDatastoreSecrets() - { - ClientSecret = "string", - }) + MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureBlobDatastore(new MachineLearningAccountKeyDatastoreCredentials(new MachineLearningAccountKeyDatastoreSecrets { - AuthorityUri = new Uri("string"), - ResourceUri = new Uri("string"), - }, "string") + Key = "string", + })) { + AccountName = "string", + ContainerName = "string", + Endpoint = "core.windows.net", + Protocol = "https", Description = "string", Tags = { -["string"] = "string", -}, - Properties = -{ +["string"] = "string" }, + Properties = { }, }); bool? skipValidation = false; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data, skipValidation: skipValidation); @@ -178,10 +226,10 @@ public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureDataLakeGen1WServic [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureDataLakeGen2WServicePrincipal() + public async Task Get_GetDatastore() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/AzureDataLakeGen2WServicePrincipal/createOrUpdate.json - // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/get.json + // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -201,29 +249,7 @@ public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureDataLakeGen2WServic // invoke the operation string name = "string"; - MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureDataLakeGen2Datastore(new MachineLearningServicePrincipalDatastoreCredentials(Guid.Parse("00000000-1111-2222-3333-444444444444"), Guid.Parse("00000000-1111-2222-3333-444444444444"), new MachineLearningServicePrincipalDatastoreSecrets() - { - ClientSecret = "string", - }) - { - AuthorityUri = new Uri("string"), - ResourceUri = new Uri("string"), - }, "string", "string") - { - Endpoint = "string", - Protocol = "string", - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -}, - }); - bool? skipValidation = false; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data, skipValidation: skipValidation); - MachineLearningDatastoreResource result = lro.Value; + MachineLearningDatastoreResource result = await collection.GetAsync(name); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -234,10 +260,10 @@ public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureDataLakeGen2WServic [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureFileStoreWAccountKey() + public async Task Exists_GetDatastore() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/AzureFileWAccountKey/createOrUpdate.json - // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/get.json + // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -257,39 +283,17 @@ public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureFileStoreWAccountKe // invoke the operation string name = "string"; - MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureFileDatastore(new MachineLearningAccountKeyDatastoreCredentials(new MachineLearningAccountKeyDatastoreSecrets() - { - Key = "string", - }), "string", "string") - { - Endpoint = "string", - Protocol = "string", - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -}, - }); - bool? skipValidation = false; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data, skipValidation: skipValidation); - MachineLearningDatastoreResource result = lro.Value; + bool result = await collection.ExistsAsync(name); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDatastoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureBlobWAccountKey() + public async Task GetIfExists_GetDatastore() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/AzureBlobWAccountKey/createOrUpdate.json - // this example is just showing the usage of "Datastores_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/get.json + // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -309,33 +313,21 @@ public async Task CreateOrUpdate_CreateOrUpdateDatastoreAzureBlobWAccountKey() // invoke the operation string name = "string"; - MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureBlobDatastore(new MachineLearningAccountKeyDatastoreCredentials(new MachineLearningAccountKeyDatastoreSecrets() + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningDatastoreResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Key = "string", - })) + Console.WriteLine("Succeeded with null as result"); + } + else { - AccountName = "string", - ContainerName = "string", - Endpoint = "core.windows.net", - Protocol = "https", - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -}, - }); - bool? skipValidation = false; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data, skipValidation: skipValidation); - MachineLearningDatastoreResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDatastoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDatastoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDatastoreResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDatastoreResource.cs index 2289ff868342d..d900efd6acbfa 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDatastoreResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningDatastoreResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningDatastoreResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDatastore() + public async Task Get_GetDatastore() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/delete.json - // this example is just showing the usage of "Datastores_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/get.json + // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteDatastore() MachineLearningDatastoreResource machineLearningDatastore = client.GetMachineLearningDatastoreResource(machineLearningDatastoreResourceId); // invoke the operation - await machineLearningDatastore.DeleteAsync(WaitUntil.Completed); + MachineLearningDatastoreResource result = await machineLearningDatastore.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDatastoreData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDatastore() + public async Task Delete_DeleteDatastore() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/get.json - // this example is just showing the usage of "Datastores_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Datastore/delete.json + // this example is just showing the usage of "Datastores_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetDatastore() MachineLearningDatastoreResource machineLearningDatastore = client.GetMachineLearningDatastoreResource(machineLearningDatastoreResourceId); // invoke the operation - MachineLearningDatastoreResource result = await machineLearningDatastore.GetAsync(); + await machineLearningDatastore.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDatastoreData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_CreateOrUpdateDatastoreAzureDataLakeGen1WServicePrincip MachineLearningDatastoreResource machineLearningDatastore = client.GetMachineLearningDatastoreResource(machineLearningDatastoreResourceId); // invoke the operation - MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureDataLakeGen1Datastore(new MachineLearningServicePrincipalDatastoreCredentials(Guid.Parse("00000000-1111-2222-3333-444444444444"), Guid.Parse("00000000-1111-2222-3333-444444444444"), new MachineLearningServicePrincipalDatastoreSecrets() + MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureDataLakeGen1Datastore(new MachineLearningServicePrincipalDatastoreCredentials(Guid.Parse("00000000-1111-2222-3333-444444444444"), Guid.Parse("00000000-1111-2222-3333-444444444444"), new MachineLearningServicePrincipalDatastoreSecrets { ClientSecret = "string", }) @@ -108,11 +108,9 @@ public async Task Update_CreateOrUpdateDatastoreAzureDataLakeGen1WServicePrincip Description = "string", Tags = { -["string"] = "string", -}, - Properties = -{ +["string"] = "string" }, + Properties = { }, }); bool? skipValidation = false; ArmOperation lro = await machineLearningDatastore.UpdateAsync(WaitUntil.Completed, data, skipValidation: skipValidation); @@ -147,7 +145,7 @@ public async Task Update_CreateOrUpdateDatastoreAzureDataLakeGen2WServicePrincip MachineLearningDatastoreResource machineLearningDatastore = client.GetMachineLearningDatastoreResource(machineLearningDatastoreResourceId); // invoke the operation - MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureDataLakeGen2Datastore(new MachineLearningServicePrincipalDatastoreCredentials(Guid.Parse("00000000-1111-2222-3333-444444444444"), Guid.Parse("00000000-1111-2222-3333-444444444444"), new MachineLearningServicePrincipalDatastoreSecrets() + MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureDataLakeGen2Datastore(new MachineLearningServicePrincipalDatastoreCredentials(Guid.Parse("00000000-1111-2222-3333-444444444444"), Guid.Parse("00000000-1111-2222-3333-444444444444"), new MachineLearningServicePrincipalDatastoreSecrets { ClientSecret = "string", }) @@ -161,11 +159,9 @@ public async Task Update_CreateOrUpdateDatastoreAzureDataLakeGen2WServicePrincip Description = "string", Tags = { -["string"] = "string", -}, - Properties = -{ +["string"] = "string" }, + Properties = { }, }); bool? skipValidation = false; ArmOperation lro = await machineLearningDatastore.UpdateAsync(WaitUntil.Completed, data, skipValidation: skipValidation); @@ -200,7 +196,7 @@ public async Task Update_CreateOrUpdateDatastoreAzureFileStoreWAccountKey() MachineLearningDatastoreResource machineLearningDatastore = client.GetMachineLearningDatastoreResource(machineLearningDatastoreResourceId); // invoke the operation - MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureFileDatastore(new MachineLearningAccountKeyDatastoreCredentials(new MachineLearningAccountKeyDatastoreSecrets() + MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureFileDatastore(new MachineLearningAccountKeyDatastoreCredentials(new MachineLearningAccountKeyDatastoreSecrets { Key = "string", }), "string", "string") @@ -210,11 +206,9 @@ public async Task Update_CreateOrUpdateDatastoreAzureFileStoreWAccountKey() Description = "string", Tags = { -["string"] = "string", -}, - Properties = -{ +["string"] = "string" }, + Properties = { }, }); bool? skipValidation = false; ArmOperation lro = await machineLearningDatastore.UpdateAsync(WaitUntil.Completed, data, skipValidation: skipValidation); @@ -249,7 +243,7 @@ public async Task Update_CreateOrUpdateDatastoreAzureBlobWAccountKey() MachineLearningDatastoreResource machineLearningDatastore = client.GetMachineLearningDatastoreResource(machineLearningDatastoreResourceId); // invoke the operation - MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureBlobDatastore(new MachineLearningAccountKeyDatastoreCredentials(new MachineLearningAccountKeyDatastoreSecrets() + MachineLearningDatastoreData data = new MachineLearningDatastoreData(new MachineLearningAzureBlobDatastore(new MachineLearningAccountKeyDatastoreCredentials(new MachineLearningAccountKeyDatastoreSecrets { Key = "string", })) @@ -261,11 +255,9 @@ public async Task Update_CreateOrUpdateDatastoreAzureBlobWAccountKey() Description = "string", Tags = { -["string"] = "string", -}, - Properties = -{ +["string"] = "string" }, + Properties = { }, }); bool? skipValidation = false; ArmOperation lro = await machineLearningDatastore.UpdateAsync(WaitUntil.Completed, data, skipValidation: skipValidation); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentContainerCollection.cs index fe825321ef13e..dd444952e7add 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningEnvironmentContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceEnvironmentContainer() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceEnvironmentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/list.json - // this example is just showing the usage of "EnvironmentContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/createOrUpdate.json + // this example is just showing the usage of "EnvironmentContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,32 @@ public async Task GetAll_ListWorkspaceEnvironmentContainer() // get the collection of this MachineLearningEnvironmentContainerResource MachineLearningEnvironmentContainerCollection collection = machineLearningWorkspace.GetMachineLearningEnvironmentContainers(); - // invoke the operation and iterate over the result - await foreach (MachineLearningEnvironmentContainerResource item in collection.GetAllAsync()) + // invoke the operation + string name = "testEnvironment"; + MachineLearningEnvironmentContainerData data = new MachineLearningEnvironmentContainerData(new MachineLearningEnvironmentContainerProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + Tags = +{ +["additionalProp1"] = "string", +["additionalProp2"] = "string", +["additionalProp3"] = "string" +}, + Properties = +{ +["additionalProp1"] = "string", +["additionalProp2"] = "string", +["additionalProp3"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningEnvironmentContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +103,10 @@ public async Task Get_GetWorkspaceEnvironmentContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceEnvironmentContainer() + public async Task GetAll_ListWorkspaceEnvironmentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/get.json - // this example is just showing the usage of "EnvironmentContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/list.json + // this example is just showing the usage of "EnvironmentContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +124,22 @@ public async Task Exists_GetWorkspaceEnvironmentContainer() // get the collection of this MachineLearningEnvironmentContainerResource MachineLearningEnvironmentContainerCollection collection = machineLearningWorkspace.GetMachineLearningEnvironmentContainers(); - // invoke the operation - string name = "testEnvironment"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (MachineLearningEnvironmentContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceEnvironmentContainer() + public async Task Exists_GetWorkspaceEnvironmentContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/get.json // this example is just showing the usage of "EnvironmentContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +162,17 @@ public async Task GetIfExists_GetWorkspaceEnvironmentContainer() // invoke the operation string name = "testEnvironment"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningEnvironmentContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceEnvironmentContainer() + public async Task GetIfExists_GetWorkspaceEnvironmentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/createOrUpdate.json - // this example is just showing the usage of "EnvironmentContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/get.json + // this example is just showing the usage of "EnvironmentContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,30 +192,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceEnvironmentContainer() // invoke the operation string name = "testEnvironment"; - MachineLearningEnvironmentContainerData data = new MachineLearningEnvironmentContainerData(new MachineLearningEnvironmentContainerProperties() - { - Description = "string", - Tags = -{ -["additionalProp1"] = "string", -["additionalProp2"] = "string", -["additionalProp3"] = "string", -}, - Properties = -{ -["additionalProp1"] = "string", -["additionalProp2"] = "string", -["additionalProp3"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningEnvironmentContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningEnvironmentContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentContainerResource.cs index 2f550c040513b..eadf82e4d38f4 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningEnvironmentContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceEnvironmentContainer() + public async Task Get_GetWorkspaceEnvironmentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/delete.json - // this example is just showing the usage of "EnvironmentContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/get.json + // this example is just showing the usage of "EnvironmentContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +33,26 @@ public async Task Delete_DeleteWorkspaceEnvironmentContainer() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "testrg123"; string workspaceName = "testworkspace"; - string name = "testContainer"; + string name = "testEnvironment"; ResourceIdentifier machineLearningEnvironmentContainerResourceId = MachineLearningEnvironmentContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, name); MachineLearningEnvironmentContainerResource machineLearningEnvironmentContainer = client.GetMachineLearningEnvironmentContainerResource(machineLearningEnvironmentContainerResourceId); // invoke the operation - await machineLearningEnvironmentContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningEnvironmentContainerResource result = await machineLearningEnvironmentContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceEnvironmentContainer() + public async Task Delete_DeleteWorkspaceEnvironmentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/get.json - // this example is just showing the usage of "EnvironmentContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentContainer/delete.json + // this example is just showing the usage of "EnvironmentContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,14 @@ public async Task Get_GetWorkspaceEnvironmentContainer() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "testrg123"; string workspaceName = "testworkspace"; - string name = "testEnvironment"; + string name = "testContainer"; ResourceIdentifier machineLearningEnvironmentContainerResourceId = MachineLearningEnvironmentContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, name); MachineLearningEnvironmentContainerResource machineLearningEnvironmentContainer = client.GetMachineLearningEnvironmentContainerResource(machineLearningEnvironmentContainerResourceId); // invoke the operation - MachineLearningEnvironmentContainerResource result = await machineLearningEnvironmentContainer.GetAsync(); + await machineLearningEnvironmentContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,20 +96,20 @@ public async Task Update_CreateOrUpdateWorkspaceEnvironmentContainer() MachineLearningEnvironmentContainerResource machineLearningEnvironmentContainer = client.GetMachineLearningEnvironmentContainerResource(machineLearningEnvironmentContainerResourceId); // invoke the operation - MachineLearningEnvironmentContainerData data = new MachineLearningEnvironmentContainerData(new MachineLearningEnvironmentContainerProperties() + MachineLearningEnvironmentContainerData data = new MachineLearningEnvironmentContainerData(new MachineLearningEnvironmentContainerProperties { Description = "string", Tags = { ["additionalProp1"] = "string", ["additionalProp2"] = "string", -["additionalProp3"] = "string", +["additionalProp3"] = "string" }, Properties = { ["additionalProp1"] = "string", ["additionalProp2"] = "string", -["additionalProp3"] = "string", +["additionalProp3"] = "string" }, }); ArmOperation lro = await machineLearningEnvironmentContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentVersionCollection.cs index 190370a6755c7..9cbd095fae070 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningEnvironmentVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceEnvironmentVersion() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceEnvironmentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/list.json - // this example is just showing the usage of "EnvironmentVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/createOrUpdate.json + // this example is just showing the usage of "EnvironmentVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,19 +40,41 @@ public async Task GetAll_ListWorkspaceEnvironmentVersion() // get the collection of this MachineLearningEnvironmentVersionResource MachineLearningEnvironmentVersionCollection collection = machineLearningEnvironmentContainer.GetMachineLearningEnvironmentVersions(); - // invoke the operation and iterate over the result - string orderBy = "string"; - int? top = 1; - await foreach (MachineLearningEnvironmentVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + // invoke the operation + string version = "string"; + MachineLearningEnvironmentVersionData data = new MachineLearningEnvironmentVersionData(new MachineLearningEnvironmentVersionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Image = "docker.io/tensorflow/serving:latest", + CondaFile = "string", + Build = new MachineLearningBuildContext(new Uri("https://storage-account.blob.core.windows.net/azureml/DockerBuildContext/95ddede6b9b8c4e90472db3acd0a8d28/")) + { + DockerfilePath = "prod/Dockerfile", + }, + InferenceConfig = new MachineLearningInferenceContainerProperties + { + LivenessRoute = new MachineLearningInferenceContainerRoute("string", 1), + ReadinessRoute = new MachineLearningInferenceContainerRoute("string", 1), + ScoringRoute = new MachineLearningInferenceContainerRoute("string", 1), + }, + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningEnvironmentVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +114,10 @@ public async Task Get_GetWorkspaceEnvironmentVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceEnvironmentVersion() + public async Task GetAll_ListWorkspaceEnvironmentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/get.json - // this example is just showing the usage of "EnvironmentVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/list.json + // this example is just showing the usage of "EnvironmentVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +136,24 @@ public async Task Exists_GetWorkspaceEnvironmentVersion() // get the collection of this MachineLearningEnvironmentVersionResource MachineLearningEnvironmentVersionCollection collection = machineLearningEnvironmentContainer.GetMachineLearningEnvironmentVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + string orderBy = "string"; + int? top = 1; + await foreach (MachineLearningEnvironmentVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceEnvironmentVersion() + public async Task Exists_GetWorkspaceEnvironmentVersion() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/get.json // this example is just showing the usage of "EnvironmentVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,29 +177,17 @@ public async Task GetIfExists_GetWorkspaceEnvironmentVersion() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningEnvironmentVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceEnvironmentVersion() + public async Task GetIfExists_GetWorkspaceEnvironmentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/createOrUpdate.json - // this example is just showing the usage of "EnvironmentVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/get.json + // this example is just showing the usage of "EnvironmentVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,39 +208,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceEnvironmentVersion() // invoke the operation string version = "string"; - MachineLearningEnvironmentVersionData data = new MachineLearningEnvironmentVersionData(new MachineLearningEnvironmentVersionProperties() - { - Image = "docker.io/tensorflow/serving:latest", - CondaFile = "string", - Build = new MachineLearningBuildContext(new Uri("https://storage-account.blob.core.windows.net/azureml/DockerBuildContext/95ddede6b9b8c4e90472db3acd0a8d28/")) - { - DockerfilePath = "prod/Dockerfile", - }, - InferenceConfig = new MachineLearningInferenceContainerProperties() - { - LivenessRoute = new MachineLearningInferenceContainerRoute("string", 1), - ReadinessRoute = new MachineLearningInferenceContainerRoute("string", 1), - ScoringRoute = new MachineLearningInferenceContainerRoute("string", 1), - }, - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningEnvironmentVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningEnvironmentVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentVersionResource.cs index 87b8109cf26e3..c91299bef7290 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningEnvironmentVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningEnvironmentVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceEnvironmentVersion() + public async Task Get_GetWorkspaceEnvironmentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/delete.json - // this example is just showing the usage of "EnvironmentVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/get.json + // this example is just showing the usage of "EnvironmentVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteWorkspaceEnvironmentVersion() MachineLearningEnvironmentVersionResource machineLearningEnvironmentVersion = client.GetMachineLearningEnvironmentVersionResource(machineLearningEnvironmentVersionResourceId); // invoke the operation - await machineLearningEnvironmentVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningEnvironmentVersionResource result = await machineLearningEnvironmentVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceEnvironmentVersion() + public async Task Delete_DeleteWorkspaceEnvironmentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/get.json - // this example is just showing the usage of "EnvironmentVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/EnvironmentVersion/delete.json + // this example is just showing the usage of "EnvironmentVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetWorkspaceEnvironmentVersion() MachineLearningEnvironmentVersionResource machineLearningEnvironmentVersion = client.GetMachineLearningEnvironmentVersionResource(machineLearningEnvironmentVersionResourceId); // invoke the operation - MachineLearningEnvironmentVersionResource result = await machineLearningEnvironmentVersion.GetAsync(); + await machineLearningEnvironmentVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,7 +99,7 @@ public async Task Update_CreateOrUpdateWorkspaceEnvironmentVersion() MachineLearningEnvironmentVersionResource machineLearningEnvironmentVersion = client.GetMachineLearningEnvironmentVersionResource(machineLearningEnvironmentVersionResourceId); // invoke the operation - MachineLearningEnvironmentVersionData data = new MachineLearningEnvironmentVersionData(new MachineLearningEnvironmentVersionProperties() + MachineLearningEnvironmentVersionData data = new MachineLearningEnvironmentVersionData(new MachineLearningEnvironmentVersionProperties { Image = "docker.io/tensorflow/serving:latest", CondaFile = "string", @@ -107,7 +107,7 @@ public async Task Update_CreateOrUpdateWorkspaceEnvironmentVersion() { DockerfilePath = "prod/Dockerfile", }, - InferenceConfig = new MachineLearningInferenceContainerProperties() + InferenceConfig = new MachineLearningInferenceContainerProperties { LivenessRoute = new MachineLearningInferenceContainerRoute("string", 1), ReadinessRoute = new MachineLearningInferenceContainerRoute("string", 1), @@ -117,11 +117,11 @@ public async Task Update_CreateOrUpdateWorkspaceEnvironmentVersion() Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningEnvironmentVersion.UpdateAsync(WaitUntil.Completed, data); @@ -157,7 +157,7 @@ public async Task Publish_PublishWorkspaceEnvironmentVersion() MachineLearningEnvironmentVersionResource machineLearningEnvironmentVersion = client.GetMachineLearningEnvironmentVersionResource(machineLearningEnvironmentVersionResourceId); // invoke the operation - DestinationAssetContent content = new DestinationAssetContent() + DestinationAssetContent content = new DestinationAssetContent { RegistryName = "string", DestinationName = "string", diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureCollection.cs index c95c2b1fe50da..2f50283ef9f0c 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningFeatureCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListFeature() + public async Task Get_GetFeature() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Feature/list.json - // this example is just showing the usage of "Features_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Feature/get.json + // this example is just showing the usage of "Features_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,26 +41,23 @@ public async Task GetAll_ListFeature() // get the collection of this MachineLearningFeatureResource MachineLearningFeatureCollection collection = machineLearningFeatureSetVersion.GetMachineLearningFeatures(); - // invoke the operation and iterate over the result - MachineLearningFeatureCollectionGetAllOptions options = new MachineLearningFeatureCollectionGetAllOptions() { Tags = "string", FeatureName = "string", Description = "string" }; - await foreach (MachineLearningFeatureResource item in collection.GetAllAsync(options)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string featureName = "string"; + MachineLearningFeatureResource result = await collection.GetAsync(featureName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFeature() + public async Task GetAll_ListFeature() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Feature/get.json - // this example is just showing the usage of "Features_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Feature/list.json + // this example is just showing the usage of "Features_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,15 +77,18 @@ public async Task Get_GetFeature() // get the collection of this MachineLearningFeatureResource MachineLearningFeatureCollection collection = machineLearningFeatureSetVersion.GetMachineLearningFeatures(); - // invoke the operation - string featureName = "string"; - MachineLearningFeatureResource result = await collection.GetAsync(featureName); + // invoke the operation and iterate over the result + MachineLearningFeatureCollectionGetAllOptions options = new MachineLearningFeatureCollectionGetAllOptions { Tags = "string", FeatureName = "string", Description = "string" }; + await foreach (MachineLearningFeatureResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetContainerCollection.cs index 4cf18eb1f6c61..a2d510364d9ec 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningFeatureSetContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceFeaturesetContainer() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturesetContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/list.json - // this example is just showing the usage of "FeaturesetContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/createOrUpdate.json + // this example is just showing the usage of "FeaturesetContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,18 +39,29 @@ public async Task GetAll_ListWorkspaceFeaturesetContainer() // get the collection of this MachineLearningFeatureSetContainerResource MachineLearningFeatureSetContainerCollection collection = machineLearningWorkspace.GetMachineLearningFeatureSetContainers(); - // invoke the operation and iterate over the result - MachineLearningFeatureSetContainerCollectionGetAllOptions options = new MachineLearningFeatureSetContainerCollectionGetAllOptions() { Tags = "string", ListViewType = MachineLearningListViewType.ArchivedOnly }; - await foreach (MachineLearningFeatureSetContainerResource item in collection.GetAllAsync(options)) + // invoke the operation + string name = "string"; + MachineLearningFeatureSetContainerData data = new MachineLearningFeatureSetContainerData(new MachineLearningFeatureSetContainerProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureSetContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsArchived = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningFeatureSetContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureSetContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +100,10 @@ public async Task Get_GetEntityWorkspaceFeaturesetContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetEntityWorkspaceFeaturesetContainer() + public async Task GetAll_ListWorkspaceFeaturesetContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/getEntity.json - // this example is just showing the usage of "FeaturesetContainers_GetEntity" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/list.json + // this example is just showing the usage of "FeaturesetContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +121,23 @@ public async Task Exists_GetEntityWorkspaceFeaturesetContainer() // get the collection of this MachineLearningFeatureSetContainerResource MachineLearningFeatureSetContainerCollection collection = machineLearningWorkspace.GetMachineLearningFeatureSetContainers(); - // invoke the operation - string name = "string"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + MachineLearningFeatureSetContainerCollectionGetAllOptions options = new MachineLearningFeatureSetContainerCollectionGetAllOptions { Tags = "string", ListViewType = MachineLearningListViewType.ArchivedOnly }; + await foreach (MachineLearningFeatureSetContainerResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureSetContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetEntityWorkspaceFeaturesetContainer() + public async Task Exists_GetEntityWorkspaceFeaturesetContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/getEntity.json // this example is just showing the usage of "FeaturesetContainers_GetEntity" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +160,17 @@ public async Task GetIfExists_GetEntityWorkspaceFeaturesetContainer() // invoke the operation string name = "string"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningFeatureSetContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureSetContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturesetContainer() + public async Task GetIfExists_GetEntityWorkspaceFeaturesetContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/createOrUpdate.json - // this example is just showing the usage of "FeaturesetContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/getEntity.json + // this example is just showing the usage of "FeaturesetContainers_GetEntity" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,27 +190,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturesetContainer() // invoke the operation string name = "string"; - MachineLearningFeatureSetContainerData data = new MachineLearningFeatureSetContainerData(new MachineLearningFeatureSetContainerProperties() - { - IsArchived = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningFeatureSetContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningFeatureSetContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureSetContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureSetContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetContainerResource.cs index 0726746708548..bcf2f022390b7 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningFeatureSetContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceFeaturesetContainer() + public async Task Get_GetEntityWorkspaceFeaturesetContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/delete.json - // this example is just showing the usage of "FeaturesetContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/getEntity.json + // this example is just showing the usage of "FeaturesetContainers_GetEntity" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteWorkspaceFeaturesetContainer() MachineLearningFeatureSetContainerResource machineLearningFeatureSetContainer = client.GetMachineLearningFeatureSetContainerResource(machineLearningFeatureSetContainerResourceId); // invoke the operation - await machineLearningFeatureSetContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningFeatureSetContainerResource result = await machineLearningFeatureSetContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureSetContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetEntityWorkspaceFeaturesetContainer() + public async Task Delete_DeleteWorkspaceFeaturesetContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/getEntity.json - // this example is just showing the usage of "FeaturesetContainers_GetEntity" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetContainer/delete.json + // this example is just showing the usage of "FeaturesetContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetEntityWorkspaceFeaturesetContainer() MachineLearningFeatureSetContainerResource machineLearningFeatureSetContainer = client.GetMachineLearningFeatureSetContainerResource(machineLearningFeatureSetContainerResourceId); // invoke the operation - MachineLearningFeatureSetContainerResource result = await machineLearningFeatureSetContainer.GetAsync(); + await machineLearningFeatureSetContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureSetContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,17 +96,17 @@ public async Task Update_CreateOrUpdateWorkspaceFeaturesetContainer() MachineLearningFeatureSetContainerResource machineLearningFeatureSetContainer = client.GetMachineLearningFeatureSetContainerResource(machineLearningFeatureSetContainerResourceId); // invoke the operation - MachineLearningFeatureSetContainerData data = new MachineLearningFeatureSetContainerData(new MachineLearningFeatureSetContainerProperties() + MachineLearningFeatureSetContainerData data = new MachineLearningFeatureSetContainerData(new MachineLearningFeatureSetContainerProperties { IsArchived = false, Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningFeatureSetContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetVersionCollection.cs index 52694d359fc66..35a2d3e11bc37 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningFeatureSetVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceFeaturesetVersion() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturesetVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/list.json - // this example is just showing the usage of "FeaturesetVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/createOrUpdate.json + // this example is just showing the usage of "FeaturesetVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,18 +40,58 @@ public async Task GetAll_ListWorkspaceFeaturesetVersion() // get the collection of this MachineLearningFeatureSetVersionResource MachineLearningFeatureSetVersionCollection collection = machineLearningFeatureSetContainer.GetMachineLearningFeatureSetVersions(); - // invoke the operation and iterate over the result - MachineLearningFeatureSetVersionCollectionGetAllOptions options = new MachineLearningFeatureSetVersionCollectionGetAllOptions() { Tags = "string", ListViewType = MachineLearningListViewType.All }; - await foreach (MachineLearningFeatureSetVersionResource item in collection.GetAllAsync(options)) + // invoke the operation + string version = "string"; + MachineLearningFeatureSetVersionData data = new MachineLearningFeatureSetVersionData(new MachineLearningFeatureSetVersionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureSetVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + SpecificationPath = "string", + MaterializationSettings = new MaterializationSettings + { + StoreType = MaterializationStoreType.Online, + Schedule = new MachineLearningRecurrenceTrigger(MachineLearningRecurrenceFrequency.Day, 1) + { + Schedule = new MachineLearningRecurrenceSchedule(new int[] { 1 }, new int[] { 1 }) + { + WeekDays = { MachineLearningDayOfWeek.Monday }, + MonthDays = { 1 }, + }, + EndTime = "string", + StartTime = "string", + TimeZone = "string", + }, + Notification = new NotificationSetting + { + Emails = { "string" }, + EmailOn = { EmailNotificationEnableType.JobFailed }, + }, + ResourceInstanceType = "string", + SparkConfiguration = +{ +["string"] = "string" +}, + }, + Stage = "string", + Entities = { "string" }, + IsArchived = false, + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningFeatureSetVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureSetVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +131,10 @@ public async Task Get_GetWorkspaceFeaturesetVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceFeaturesetVersion() + public async Task GetAll_ListWorkspaceFeaturesetVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/get.json - // this example is just showing the usage of "FeaturesetVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/list.json + // this example is just showing the usage of "FeaturesetVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +153,23 @@ public async Task Exists_GetWorkspaceFeaturesetVersion() // get the collection of this MachineLearningFeatureSetVersionResource MachineLearningFeatureSetVersionCollection collection = machineLearningFeatureSetContainer.GetMachineLearningFeatureSetVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + MachineLearningFeatureSetVersionCollectionGetAllOptions options = new MachineLearningFeatureSetVersionCollectionGetAllOptions { Tags = "string", ListViewType = MachineLearningListViewType.All }; + await foreach (MachineLearningFeatureSetVersionResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureSetVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceFeaturesetVersion() + public async Task Exists_GetWorkspaceFeaturesetVersion() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/get.json // this example is just showing the usage of "FeaturesetVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +193,17 @@ public async Task GetIfExists_GetWorkspaceFeaturesetVersion() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningFeatureSetVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureSetVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturesetVersion() + public async Task GetIfExists_GetWorkspaceFeaturesetVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/createOrUpdate.json - // this example is just showing the usage of "FeaturesetVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/get.json + // this example is just showing the usage of "FeaturesetVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,77 +224,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturesetVersion() // invoke the operation string version = "string"; - MachineLearningFeatureSetVersionData data = new MachineLearningFeatureSetVersionData(new MachineLearningFeatureSetVersionProperties() - { - SpecificationPath = "string", - MaterializationSettings = new MaterializationSettings() - { - StoreType = MaterializationStoreType.Online, - Schedule = new MachineLearningRecurrenceTrigger(MachineLearningRecurrenceFrequency.Day, 1) - { - Schedule = new MachineLearningRecurrenceSchedule(new int[] + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningFeatureSetVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { -1 - }, new int[] + Console.WriteLine("Succeeded with null as result"); + } + else { -1 - }) - { - WeekDays = -{ -MachineLearningDayOfWeek.Monday -}, - MonthDays = -{ -1 -}, - }, - EndTime = "string", - StartTime = "string", - TimeZone = "string", - }, - Notification = new NotificationSetting() - { - Emails = -{ -"string" -}, - EmailOn = -{ -EmailNotificationEnableType.JobFailed -}, - }, - ResourceInstanceType = "string", - SparkConfiguration = -{ -["string"] = "string", -}, - }, - Stage = "string", - Entities = -{ -"string" -}, - IsArchived = false, - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningFeatureSetVersionResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureSetVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureSetVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetVersionResource.cs index a912294ce4690..9a62134584b26 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureSetVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningFeatureSetVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceFeaturesetVersion() + public async Task Get_GetWorkspaceFeaturesetVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/delete.json - // this example is just showing the usage of "FeaturesetVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/get.json + // this example is just showing the usage of "FeaturesetVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteWorkspaceFeaturesetVersion() MachineLearningFeatureSetVersionResource machineLearningFeatureSetVersion = client.GetMachineLearningFeatureSetVersionResource(machineLearningFeatureSetVersionResourceId); // invoke the operation - await machineLearningFeatureSetVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningFeatureSetVersionResource result = await machineLearningFeatureSetVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureSetVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceFeaturesetVersion() + public async Task Delete_DeleteWorkspaceFeaturesetVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/get.json - // this example is just showing the usage of "FeaturesetVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturesetVersion/delete.json + // this example is just showing the usage of "FeaturesetVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetWorkspaceFeaturesetVersion() MachineLearningFeatureSetVersionResource machineLearningFeatureSetVersion = client.GetMachineLearningFeatureSetVersionResource(machineLearningFeatureSetVersionResourceId); // invoke the operation - MachineLearningFeatureSetVersionResource result = await machineLearningFeatureSetVersion.GetAsync(); + await machineLearningFeatureSetVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureSetVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,67 +99,46 @@ public async Task Update_CreateOrUpdateWorkspaceFeaturesetVersion() MachineLearningFeatureSetVersionResource machineLearningFeatureSetVersion = client.GetMachineLearningFeatureSetVersionResource(machineLearningFeatureSetVersionResourceId); // invoke the operation - MachineLearningFeatureSetVersionData data = new MachineLearningFeatureSetVersionData(new MachineLearningFeatureSetVersionProperties() + MachineLearningFeatureSetVersionData data = new MachineLearningFeatureSetVersionData(new MachineLearningFeatureSetVersionProperties { SpecificationPath = "string", - MaterializationSettings = new MaterializationSettings() + MaterializationSettings = new MaterializationSettings { StoreType = MaterializationStoreType.Online, Schedule = new MachineLearningRecurrenceTrigger(MachineLearningRecurrenceFrequency.Day, 1) { - Schedule = new MachineLearningRecurrenceSchedule(new int[] - { -1 - }, new int[] - { -1 - }) + Schedule = new MachineLearningRecurrenceSchedule(new int[] { 1 }, new int[] { 1 }) { - WeekDays = -{ -MachineLearningDayOfWeek.Monday -}, - MonthDays = -{ -1 -}, + WeekDays = { MachineLearningDayOfWeek.Monday }, + MonthDays = { 1 }, }, EndTime = "string", StartTime = "string", TimeZone = "string", }, - Notification = new NotificationSetting() + Notification = new NotificationSetting { - Emails = -{ -"string" -}, - EmailOn = -{ -EmailNotificationEnableType.JobFailed -}, + Emails = { "string" }, + EmailOn = { EmailNotificationEnableType.JobFailed }, }, ResourceInstanceType = "string", SparkConfiguration = { -["string"] = "string", +["string"] = "string" }, }, Stage = "string", - Entities = -{ -"string" -}, + Entities = { "string" }, IsArchived = false, IsAnonymous = false, Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningFeatureSetVersion.UpdateAsync(WaitUntil.Completed, data); @@ -195,28 +174,25 @@ public async Task Backfill_BackfillWorkspaceFeaturesetVersion() MachineLearningFeatureSetVersionResource machineLearningFeatureSetVersion = client.GetMachineLearningFeatureSetVersionResource(machineLearningFeatureSetVersionResourceId); // invoke the operation - FeatureSetVersionBackfillContent content = new FeatureSetVersionBackfillContent() + FeatureSetVersionBackfillContent content = new FeatureSetVersionBackfillContent { DisplayName = "string", Description = "string", - FeatureWindow = new FeatureWindow() + FeatureWindow = new FeatureWindow { FeatureWindowStart = DateTimeOffset.Parse("2020-01-01T12:34:56.999+00:51"), FeatureWindowEnd = DateTimeOffset.Parse("2020-01-01T12:34:56.999+00:51"), }, - DataAvailabilityStatus = -{ -DataAvailabilityStatus.None -}, + DataAvailabilityStatus = { DataAvailabilityStatus.None }, JobId = "string", Tags = { -["string"] = "string", +["string"] = "string" }, ResourceInstanceType = "string", SparkConfiguration = { -["string"] = "string", +["string"] = "string" }, }; ArmOperation lro = await machineLearningFeatureSetVersion.BackfillAsync(WaitUntil.Completed, content); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureStoreEntityContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureStoreEntityContainerCollection.cs index 53d198ec071d6..7388203eb1860 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureStoreEntityContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureStoreEntityContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningFeatureStoreEntityContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceFeaturestoreEntityContainer() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturestoreEntityContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/list.json - // this example is just showing the usage of "FeaturestoreEntityContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/createOrUpdate.json + // this example is just showing the usage of "FeaturestoreEntityContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,18 +39,29 @@ public async Task GetAll_ListWorkspaceFeaturestoreEntityContainer() // get the collection of this MachineLearningFeatureStoreEntityContainerResource MachineLearningFeatureStoreEntityContainerCollection collection = machineLearningWorkspace.GetMachineLearningFeatureStoreEntityContainers(); - // invoke the operation and iterate over the result - MachineLearningFeatureStoreEntityContainerCollectionGetAllOptions options = new MachineLearningFeatureStoreEntityContainerCollectionGetAllOptions() { Tags = "string", ListViewType = MachineLearningListViewType.All }; - await foreach (MachineLearningFeatureStoreEntityContainerResource item in collection.GetAllAsync(options)) + // invoke the operation + string name = "string"; + MachineLearningFeatureStoreEntityContainerData data = new MachineLearningFeatureStoreEntityContainerData(new MachineLearningFeatureStoreEntityContainerProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureStoreEntityContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsArchived = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningFeatureStoreEntityContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureStoreEntityContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +100,10 @@ public async Task Get_GetEntityWorkspaceFeaturestoreEntityContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetEntityWorkspaceFeaturestoreEntityContainer() + public async Task GetAll_ListWorkspaceFeaturestoreEntityContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/getEntity.json - // this example is just showing the usage of "FeaturestoreEntityContainers_GetEntity" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/list.json + // this example is just showing the usage of "FeaturestoreEntityContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +121,23 @@ public async Task Exists_GetEntityWorkspaceFeaturestoreEntityContainer() // get the collection of this MachineLearningFeatureStoreEntityContainerResource MachineLearningFeatureStoreEntityContainerCollection collection = machineLearningWorkspace.GetMachineLearningFeatureStoreEntityContainers(); - // invoke the operation - string name = "string"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + MachineLearningFeatureStoreEntityContainerCollectionGetAllOptions options = new MachineLearningFeatureStoreEntityContainerCollectionGetAllOptions { Tags = "string", ListViewType = MachineLearningListViewType.All }; + await foreach (MachineLearningFeatureStoreEntityContainerResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureStoreEntityContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetEntityWorkspaceFeaturestoreEntityContainer() + public async Task Exists_GetEntityWorkspaceFeaturestoreEntityContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/getEntity.json // this example is just showing the usage of "FeaturestoreEntityContainers_GetEntity" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +160,17 @@ public async Task GetIfExists_GetEntityWorkspaceFeaturestoreEntityContainer() // invoke the operation string name = "string"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningFeatureStoreEntityContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureStoreEntityContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturestoreEntityContainer() + public async Task GetIfExists_GetEntityWorkspaceFeaturestoreEntityContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/createOrUpdate.json - // this example is just showing the usage of "FeaturestoreEntityContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/getEntity.json + // this example is just showing the usage of "FeaturestoreEntityContainers_GetEntity" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,27 +190,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturestoreEntityContai // invoke the operation string name = "string"; - MachineLearningFeatureStoreEntityContainerData data = new MachineLearningFeatureStoreEntityContainerData(new MachineLearningFeatureStoreEntityContainerProperties() - { - IsArchived = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningFeatureStoreEntityContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningFeatureStoreEntityContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureStoreEntityContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureStoreEntityContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureStoreEntityContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureStoreEntityContainerResource.cs index 1935a4d18091e..425b2667f5cb5 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureStoreEntityContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeatureStoreEntityContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningFeatureStoreEntityContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceFeaturestoreEntityContainer() + public async Task Get_GetEntityWorkspaceFeaturestoreEntityContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/delete.json - // this example is just showing the usage of "FeaturestoreEntityContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/getEntity.json + // this example is just showing the usage of "FeaturestoreEntityContainers_GetEntity" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteWorkspaceFeaturestoreEntityContainer() MachineLearningFeatureStoreEntityContainerResource machineLearningFeatureStoreEntityContainer = client.GetMachineLearningFeatureStoreEntityContainerResource(machineLearningFeatureStoreEntityContainerResourceId); // invoke the operation - await machineLearningFeatureStoreEntityContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningFeatureStoreEntityContainerResource result = await machineLearningFeatureStoreEntityContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeatureStoreEntityContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetEntityWorkspaceFeaturestoreEntityContainer() + public async Task Delete_DeleteWorkspaceFeaturestoreEntityContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/getEntity.json - // this example is just showing the usage of "FeaturestoreEntityContainers_GetEntity" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityContainer/delete.json + // this example is just showing the usage of "FeaturestoreEntityContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetEntityWorkspaceFeaturestoreEntityContainer() MachineLearningFeatureStoreEntityContainerResource machineLearningFeatureStoreEntityContainer = client.GetMachineLearningFeatureStoreEntityContainerResource(machineLearningFeatureStoreEntityContainerResourceId); // invoke the operation - MachineLearningFeatureStoreEntityContainerResource result = await machineLearningFeatureStoreEntityContainer.GetAsync(); + await machineLearningFeatureStoreEntityContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeatureStoreEntityContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,17 +96,17 @@ public async Task Update_CreateOrUpdateWorkspaceFeaturestoreEntityContainer() MachineLearningFeatureStoreEntityContainerResource machineLearningFeatureStoreEntityContainer = client.GetMachineLearningFeatureStoreEntityContainerResource(machineLearningFeatureStoreEntityContainerResourceId); // invoke the operation - MachineLearningFeatureStoreEntityContainerData data = new MachineLearningFeatureStoreEntityContainerData(new MachineLearningFeatureStoreEntityContainerProperties() + MachineLearningFeatureStoreEntityContainerData data = new MachineLearningFeatureStoreEntityContainerData(new MachineLearningFeatureStoreEntityContainerProperties { IsArchived = false, Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningFeatureStoreEntityContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeaturestoreEntityVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeaturestoreEntityVersionCollection.cs index d2e2422aa6b2e..a0be4091d0a1e 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeaturestoreEntityVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeaturestoreEntityVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningFeaturestoreEntityVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceFeaturestoreEntityVersion() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturestoreEntityVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/list.json - // this example is just showing the usage of "FeaturestoreEntityVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/createOrUpdate.json + // this example is just showing the usage of "FeaturestoreEntityVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,18 +40,35 @@ public async Task GetAll_ListWorkspaceFeaturestoreEntityVersion() // get the collection of this MachineLearningFeaturestoreEntityVersionResource MachineLearningFeaturestoreEntityVersionCollection collection = machineLearningFeatureStoreEntityContainer.GetMachineLearningFeaturestoreEntityVersions(); - // invoke the operation and iterate over the result - MachineLearningFeaturestoreEntityVersionCollectionGetAllOptions options = new MachineLearningFeaturestoreEntityVersionCollectionGetAllOptions() { Tags = "string", ListViewType = MachineLearningListViewType.ActiveOnly }; - await foreach (MachineLearningFeaturestoreEntityVersionResource item in collection.GetAllAsync(options)) + // invoke the operation + string version = "string"; + MachineLearningFeaturestoreEntityVersionData data = new MachineLearningFeaturestoreEntityVersionData(new MachineLearningFeatureStoreEntityVersionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeaturestoreEntityVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IndexColumns = {new IndexColumn +{ +DataType = FeatureDataType.Datetime, +ColumnName = "string", +}}, + IsArchived = false, + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningFeaturestoreEntityVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeaturestoreEntityVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +108,10 @@ public async Task Get_GetWorkspaceFeaturestoreEntityVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceFeaturestoreEntityVersion() + public async Task GetAll_ListWorkspaceFeaturestoreEntityVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/get.json - // this example is just showing the usage of "FeaturestoreEntityVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/list.json + // this example is just showing the usage of "FeaturestoreEntityVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +130,23 @@ public async Task Exists_GetWorkspaceFeaturestoreEntityVersion() // get the collection of this MachineLearningFeaturestoreEntityVersionResource MachineLearningFeaturestoreEntityVersionCollection collection = machineLearningFeatureStoreEntityContainer.GetMachineLearningFeaturestoreEntityVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + MachineLearningFeaturestoreEntityVersionCollectionGetAllOptions options = new MachineLearningFeaturestoreEntityVersionCollectionGetAllOptions { Tags = "string", ListViewType = MachineLearningListViewType.ActiveOnly }; + await foreach (MachineLearningFeaturestoreEntityVersionResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeaturestoreEntityVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceFeaturestoreEntityVersion() + public async Task Exists_GetWorkspaceFeaturestoreEntityVersion() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/get.json // this example is just showing the usage of "FeaturestoreEntityVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +170,17 @@ public async Task GetIfExists_GetWorkspaceFeaturestoreEntityVersion() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningFeaturestoreEntityVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeaturestoreEntityVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturestoreEntityVersion() + public async Task GetIfExists_GetWorkspaceFeaturestoreEntityVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/createOrUpdate.json - // this example is just showing the usage of "FeaturestoreEntityVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/get.json + // this example is just showing the usage of "FeaturestoreEntityVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,36 +201,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceFeaturestoreEntityVersio // invoke the operation string version = "string"; - MachineLearningFeaturestoreEntityVersionData data = new MachineLearningFeaturestoreEntityVersionData(new MachineLearningFeatureStoreEntityVersionProperties() - { - IndexColumns = -{ -new IndexColumn() -{ -DataType = FeatureDataType.Datetime, -ColumnName = "string", -} -}, - IsArchived = false, - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningFeaturestoreEntityVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningFeaturestoreEntityVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeaturestoreEntityVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeaturestoreEntityVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeaturestoreEntityVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeaturestoreEntityVersionResource.cs index 7120c68b799ea..f40eddb656e02 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeaturestoreEntityVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningFeaturestoreEntityVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningFeaturestoreEntityVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceFeaturestoreEntityVersion() + public async Task Get_GetWorkspaceFeaturestoreEntityVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/delete.json - // this example is just showing the usage of "FeaturestoreEntityVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/get.json + // this example is just showing the usage of "FeaturestoreEntityVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteWorkspaceFeaturestoreEntityVersion() MachineLearningFeaturestoreEntityVersionResource machineLearningFeaturestoreEntityVersion = client.GetMachineLearningFeaturestoreEntityVersionResource(machineLearningFeaturestoreEntityVersionResourceId); // invoke the operation - await machineLearningFeaturestoreEntityVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningFeaturestoreEntityVersionResource result = await machineLearningFeaturestoreEntityVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningFeaturestoreEntityVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceFeaturestoreEntityVersion() + public async Task Delete_DeleteWorkspaceFeaturestoreEntityVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/get.json - // this example is just showing the usage of "FeaturestoreEntityVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/FeaturestoreEntityVersion/delete.json + // this example is just showing the usage of "FeaturestoreEntityVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetWorkspaceFeaturestoreEntityVersion() MachineLearningFeaturestoreEntityVersionResource machineLearningFeaturestoreEntityVersion = client.GetMachineLearningFeaturestoreEntityVersionResource(machineLearningFeaturestoreEntityVersionResourceId); // invoke the operation - MachineLearningFeaturestoreEntityVersionResource result = await machineLearningFeaturestoreEntityVersion.GetAsync(); + await machineLearningFeaturestoreEntityVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningFeaturestoreEntityVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,26 +99,23 @@ public async Task Update_CreateOrUpdateWorkspaceFeaturestoreEntityVersion() MachineLearningFeaturestoreEntityVersionResource machineLearningFeaturestoreEntityVersion = client.GetMachineLearningFeaturestoreEntityVersionResource(machineLearningFeaturestoreEntityVersionResourceId); // invoke the operation - MachineLearningFeaturestoreEntityVersionData data = new MachineLearningFeaturestoreEntityVersionData(new MachineLearningFeatureStoreEntityVersionProperties() + MachineLearningFeaturestoreEntityVersionData data = new MachineLearningFeaturestoreEntityVersionData(new MachineLearningFeatureStoreEntityVersionProperties { - IndexColumns = -{ -new IndexColumn() + IndexColumns = {new IndexColumn { DataType = FeatureDataType.Datetime, ColumnName = "string", -} -}, +}}, IsArchived = false, IsAnonymous = false, Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningFeaturestoreEntityVersion.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningJobCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningJobCollection.cs index 5150fe520ac9e..c031cb6f4391a 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningJobCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningJobCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_MachineLearningJobCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAutoMLJob() + public async Task CreateOrUpdate_CreateOrUpdateAutoMLJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/list.json - // this example is just showing the usage of "Jobs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/createOrUpdate.json + // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,94 @@ public async Task GetAll_ListAutoMLJob() // get the collection of this MachineLearningJobResource MachineLearningJobCollection collection = machineLearningWorkspace.GetMachineLearningJobs(); - // invoke the operation and iterate over the result - await foreach (MachineLearningJobResource item in collection.GetAllAsync()) + // invoke the operation + string id = "string"; + MachineLearningJobData data = new MachineLearningJobData(new AutoMLJob(new ImageClassification(new MachineLearningTableJobInput(new Uri("string")), new ImageLimitSettings { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + MaxTrials = 2, + }) + { + ModelSettings = new ImageModelSettingsClassification + { + ValidationCropSize = 2, + }, + SearchSpace = {new ImageModelDistributionSettingsClassification +{ +ValidationCropSize = "choice(2, 360)", +}}, + TargetColumnName = "string", + }) + { + Resources = new MachineLearningJobResourceConfiguration + { + InstanceCount = 1, + InstanceType = "string", + Properties = +{ +["string"] = BinaryData.FromObjectAsJson(new Dictionary +{ +["9bec0ab0-c62f-4fa9-a97c-7b24bbcc90ad"] = null +}) +}, + }, + EnvironmentId = "string", + EnvironmentVariables = +{ +["string"] = "string" +}, + Outputs = +{ +["string"] = new MachineLearningUriFileJobOutput +{ +Uri = new Uri("string"), +Mode = MachineLearningOutputDeliveryMode.ReadWriteMount, +Description = "string", +} +}, + DisplayName = "string", + ExperimentName = "string", + Services = +{ +["string"] = new MachineLearningJobService +{ +JobServiceType = "string", +Port = 1, +Endpoint = "string", +Properties = +{ +["string"] = "string" +}, +} +}, + ComputeId = new ResourceIdentifier("string"), + IsArchived = false, + Identity = new AmlToken(), + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); + MachineLearningJobResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCommandJob() + public async Task CreateOrUpdate_CreateOrUpdateCommandJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/list.json - // this example is just showing the usage of "Jobs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/createOrUpdate.json + // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,27 +146,95 @@ public async Task GetAll_ListCommandJob() // get the collection of this MachineLearningJobResource MachineLearningJobCollection collection = machineLearningWorkspace.GetMachineLearningJobs(); - // invoke the operation and iterate over the result - string jobType = "string"; - string tag = "string"; - await foreach (MachineLearningJobResource item in collection.GetAllAsync(jobType: jobType, tag: tag)) + // invoke the operation + string id = "string"; + MachineLearningJobData data = new MachineLearningJobData(new MachineLearningCommandJob("string", new ResourceIdentifier("string")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Resources = new MachineLearningJobResourceConfiguration + { + InstanceCount = 1, + InstanceType = "string", + Properties = +{ +["string"] = BinaryData.FromObjectAsJson(new Dictionary +{ +["e6b6493e-7d5e-4db3-be1e-306ec641327e"] = null +}) +}, + }, + CodeId = new ResourceIdentifier("string"), + Inputs = +{ +["string"] = new MachineLearningLiteralJobInput("string") +{ +Description = "string", +} +}, + Outputs = +{ +["string"] = new MachineLearningUriFileJobOutput +{ +Uri = new Uri("string"), +Mode = MachineLearningOutputDeliveryMode.ReadWriteMount, +Description = "string", +} +}, + Distribution = new TensorFlowDistributionConfiguration + { + WorkerCount = 1, + ParameterServerCount = 1, + }, + Limits = new MachineLearningCommandJobLimits + { + Timeout = XmlConvert.ToTimeSpan("PT5M"), + }, + EnvironmentVariables = +{ +["string"] = "string" +}, + DisplayName = "string", + ExperimentName = "string", + Services = +{ +["string"] = new MachineLearningJobService +{ +JobServiceType = "string", +Port = 1, +Endpoint = "string", +Properties = +{ +["string"] = "string" +}, +} +}, + ComputeId = new ResourceIdentifier("string"), + Identity = new AmlToken(), + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); + MachineLearningJobResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPipelineJob() + public async Task CreateOrUpdate_CreateOrUpdatePipelineJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/list.json - // this example is just showing the usage of "Jobs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/createOrUpdate.json + // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,27 +252,69 @@ public async Task GetAll_ListPipelineJob() // get the collection of this MachineLearningJobResource MachineLearningJobCollection collection = machineLearningWorkspace.GetMachineLearningJobs(); - // invoke the operation and iterate over the result - string jobType = "string"; - string tag = "string"; - await foreach (MachineLearningJobResource item in collection.GetAllAsync(jobType: jobType, tag: tag)) + // invoke the operation + string id = "string"; + MachineLearningJobData data = new MachineLearningJobData(new MachineLearningPipelineJob { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Settings = BinaryData.FromObjectAsJson(new object()), + Inputs = +{ +["string"] = new MachineLearningLiteralJobInput("string") +{ +Description = "string", +} +}, + Outputs = +{ +["string"] = new MachineLearningUriFileJobOutput +{ +Uri = new Uri("string"), +Mode = MachineLearningOutputDeliveryMode.Upload, +Description = "string", +} +}, + DisplayName = "string", + ExperimentName = "string", + Services = +{ +["string"] = new MachineLearningJobService +{ +JobServiceType = "string", +Port = 1, +Endpoint = "string", +Properties = +{ +["string"] = "string" +}, +} +}, + ComputeId = new ResourceIdentifier("string"), + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); + MachineLearningJobResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSweepJob() + public async Task CreateOrUpdate_CreateOrUpdateSweepJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/SweepJob/list.json - // this example is just showing the usage of "Jobs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/SweepJob/createOrUpdate.json + // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -153,29 +332,91 @@ public async Task GetAll_ListSweepJob() // get the collection of this MachineLearningJobResource MachineLearningJobCollection collection = machineLearningWorkspace.GetMachineLearningJobs(); - // invoke the operation and iterate over the result - string jobType = "string"; - string tag = "string"; - await foreach (MachineLearningJobResource item in collection.GetAllAsync(jobType: jobType, tag: tag)) + // invoke the operation + string id = "string"; + MachineLearningJobData data = new MachineLearningJobData(new MachineLearningSweepJob(BinaryData.FromObjectAsJson(new Dictionary { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAutoMLJob() - { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/get.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + ["string"] = new object() + }), new GridSamplingAlgorithm(), new MachineLearningObjective("string", MachineLearningGoal.Minimize), new MachineLearningTrialComponent("string", new ResourceIdentifier("string")) + { + CodeId = new ResourceIdentifier("string"), + EnvironmentVariables = +{ +["string"] = "string" +}, + Distribution = new MpiDistributionConfiguration + { + ProcessCountPerInstance = 1, + }, + Resources = new MachineLearningJobResourceConfiguration + { + InstanceCount = 1, + InstanceType = "string", + Properties = +{ +["string"] = BinaryData.FromObjectAsJson(new Dictionary +{ +["e6b6493e-7d5e-4db3-be1e-306ec641327e"] = null +}) +}, + }, + }) + { + Limits = new MachineLearningSweepJobLimits + { + MaxTotalTrials = 1, + MaxConcurrentTrials = 1, + TrialTimeout = XmlConvert.ToTimeSpan("PT1S"), + }, + EarlyTermination = new MedianStoppingPolicy + { + EvaluationInterval = 1, + DelayEvaluation = 1, + }, + DisplayName = "string", + ExperimentName = "string", + Services = +{ +["string"] = new MachineLearningJobService +{ +JobServiceType = "string", +Port = 1, +Endpoint = "string", +Properties = +{ +["string"] = "string" +}, +} +}, + ComputeId = new ResourceIdentifier("string"), + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); + MachineLearningJobResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAutoMLJob() + { + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/get.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); @@ -204,9 +445,9 @@ public async Task Get_GetAutoMLJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAutoMLJob() + public async Task Get_GetCommandJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -227,16 +468,20 @@ public async Task Exists_GetAutoMLJob() // invoke the operation string id = "string"; - bool result = await collection.ExistsAsync(id); + MachineLearningJobResource result = await collection.GetAsync(id); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAutoMLJob() + public async Task Get_GetPipelineJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -257,28 +502,20 @@ public async Task GetIfExists_GetAutoMLJob() // invoke the operation string id = "string"; - NullableResponse response = await collection.GetIfExistsAsync(id); - MachineLearningJobResource result = response.HasValue ? response.Value : null; + MachineLearningJobResource result = await collection.GetAsync(id); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCommandJob() + public async Task Get_GetSweepJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/SweepJob/get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -310,10 +547,10 @@ public async Task Get_GetCommandJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCommandJob() + public async Task GetAll_ListAutoMLJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/get.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/list.json + // this example is just showing the usage of "Jobs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -331,19 +568,25 @@ public async Task Exists_GetCommandJob() // get the collection of this MachineLearningJobResource MachineLearningJobCollection collection = machineLearningWorkspace.GetMachineLearningJobs(); - // invoke the operation - string id = "string"; - bool result = await collection.ExistsAsync(id); + // invoke the operation and iterate over the result + await foreach (MachineLearningJobResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCommandJob() + public async Task GetAll_ListCommandJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/get.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/list.json + // this example is just showing the usage of "Jobs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -361,31 +604,65 @@ public async Task GetIfExists_GetCommandJob() // get the collection of this MachineLearningJobResource MachineLearningJobCollection collection = machineLearningWorkspace.GetMachineLearningJobs(); - // invoke the operation - string id = "string"; - NullableResponse response = await collection.GetIfExistsAsync(id); - MachineLearningJobResource result = response.HasValue ? response.Value : null; - - if (result == null) + // invoke the operation and iterate over the result + string jobType = "string"; + string tag = "string"; + await foreach (MachineLearningJobResource item in collection.GetAllAsync(jobType: jobType, tag: tag)) { - Console.WriteLine("Succeeded with null as result"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - else + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListPipelineJob() + { + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/list.json + // this example is just showing the usage of "Jobs_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineLearningWorkspaceResource created on azure + // for more information of creating MachineLearningWorkspaceResource, please refer to the document of MachineLearningWorkspaceResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "test-rg"; + string workspaceName = "my-aml-workspace"; + ResourceIdentifier machineLearningWorkspaceResourceId = MachineLearningWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); + MachineLearningWorkspaceResource machineLearningWorkspace = client.GetMachineLearningWorkspaceResource(machineLearningWorkspaceResourceId); + + // get the collection of this MachineLearningJobResource + MachineLearningJobCollection collection = machineLearningWorkspace.GetMachineLearningJobs(); + + // invoke the operation and iterate over the result + string jobType = "string"; + string tag = "string"; + await foreach (MachineLearningJobResource item in collection.GetAllAsync(jobType: jobType, tag: tag)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = result.Data; + MachineLearningJobData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPipelineJob() + public async Task GetAll_ListSweepJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/get.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/SweepJob/list.json + // this example is just showing the usage of "Jobs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -403,22 +680,26 @@ public async Task Get_GetPipelineJob() // get the collection of this MachineLearningJobResource MachineLearningJobCollection collection = machineLearningWorkspace.GetMachineLearningJobs(); - // invoke the operation - string id = "string"; - MachineLearningJobResource result = await collection.GetAsync(id); + // invoke the operation and iterate over the result + string jobType = "string"; + string tag = "string"; + await foreach (MachineLearningJobResource item in collection.GetAllAsync(jobType: jobType, tag: tag)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPipelineJob() + public async Task Exists_GetAutoMLJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -446,9 +727,9 @@ public async Task Exists_GetPipelineJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPipelineJob() + public async Task Exists_GetCommandJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -469,28 +750,16 @@ public async Task GetIfExists_GetPipelineJob() // invoke the operation string id = "string"; - NullableResponse response = await collection.GetIfExistsAsync(id); - MachineLearningJobResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(id); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSweepJob() + public async Task Exists_GetPipelineJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/SweepJob/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -511,13 +780,9 @@ public async Task Get_GetSweepJob() // invoke the operation string id = "string"; - MachineLearningJobResource result = await collection.GetAsync(id); + bool result = await collection.ExistsAsync(id); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -552,9 +817,9 @@ public async Task Exists_GetSweepJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSweepJob() + public async Task GetIfExists_GetAutoMLJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/SweepJob/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -594,10 +859,10 @@ public async Task GetIfExists_GetSweepJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAutoMLJob() + public async Task GetIfExists_GetCommandJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/createOrUpdate.json - // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/get.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -617,94 +882,29 @@ public async Task CreateOrUpdate_CreateOrUpdateAutoMLJob() // invoke the operation string id = "string"; - MachineLearningJobData data = new MachineLearningJobData(new AutoMLJob(new ImageClassification(new MachineLearningTableJobInput(new Uri("string")), new ImageLimitSettings() - { - MaxTrials = 2, - }) + NullableResponse response = await collection.GetIfExistsAsync(id); + MachineLearningJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - ModelSettings = new ImageModelSettingsClassification() - { - ValidationCropSize = 2, - }, - SearchSpace = -{ -new ImageModelDistributionSettingsClassification() -{ -ValidationCropSize = "choice(2, 360)", -} -}, - TargetColumnName = "string", - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Resources = new MachineLearningJobResourceConfiguration() - { - InstanceCount = 1, - InstanceType = "string", - Properties = -{ -["string"] = BinaryData.FromObjectAsJson(new Dictionary() -{ -["9bec0ab0-c62f-4fa9-a97c-7b24bbcc90ad"] = null}), -}, - }, - EnvironmentId = "string", - EnvironmentVariables = -{ -["string"] = "string", -}, - Outputs = -{ -["string"] = new MachineLearningUriFileJobOutput() -{ -Uri = new Uri("string"), -Mode = MachineLearningOutputDeliveryMode.ReadWriteMount, -Description = "string", -}, -}, - DisplayName = "string", - ExperimentName = "string", - Services = -{ -["string"] = new MachineLearningJobService() -{ -JobServiceType = "string", -Port = 1, -Endpoint = "string", -Properties = -{ -["string"] = "string", -}, -}, -}, - ComputeId = new ResourceIdentifier("string"), - IsArchived = false, - Identity = new AmlToken(), - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); - MachineLearningJobResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateCommandJob() + public async Task GetIfExists_GetPipelineJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/createOrUpdate.json - // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/get.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -724,174 +924,29 @@ public async Task CreateOrUpdate_CreateOrUpdateCommandJob() // invoke the operation string id = "string"; - MachineLearningJobData data = new MachineLearningJobData(new MachineLearningCommandJob("string", new ResourceIdentifier("string")) - { - Resources = new MachineLearningJobResourceConfiguration() - { - InstanceCount = 1, - InstanceType = "string", - Properties = -{ -["string"] = BinaryData.FromObjectAsJson(new Dictionary() -{ -["e6b6493e-7d5e-4db3-be1e-306ec641327e"] = null}), -}, - }, - CodeId = new ResourceIdentifier("string"), - Inputs = -{ -["string"] = new MachineLearningLiteralJobInput("string") -{ -Description = "string", -}, -}, - Outputs = -{ -["string"] = new MachineLearningUriFileJobOutput() -{ -Uri = new Uri("string"), -Mode = MachineLearningOutputDeliveryMode.ReadWriteMount, -Description = "string", -}, -}, - Distribution = new TensorFlowDistributionConfiguration() - { - WorkerCount = 1, - ParameterServerCount = 1, - }, - Limits = new MachineLearningCommandJobLimits() - { - Timeout = XmlConvert.ToTimeSpan("PT5M"), - }, - EnvironmentVariables = -{ -["string"] = "string", -}, - DisplayName = "string", - ExperimentName = "string", - Services = -{ -["string"] = new MachineLearningJobService() -{ -JobServiceType = "string", -Port = 1, -Endpoint = "string", -Properties = -{ -["string"] = "string", -}, -}, -}, - ComputeId = new ResourceIdentifier("string"), - Identity = new AmlToken(), - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); - MachineLearningJobResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdatePipelineJob() - { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/createOrUpdate.json - // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MachineLearningWorkspaceResource created on azure - // for more information of creating MachineLearningWorkspaceResource, please refer to the document of MachineLearningWorkspaceResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "test-rg"; - string workspaceName = "my-aml-workspace"; - ResourceIdentifier machineLearningWorkspaceResourceId = MachineLearningWorkspaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName); - MachineLearningWorkspaceResource machineLearningWorkspace = client.GetMachineLearningWorkspaceResource(machineLearningWorkspaceResourceId); - - // get the collection of this MachineLearningJobResource - MachineLearningJobCollection collection = machineLearningWorkspace.GetMachineLearningJobs(); + NullableResponse response = await collection.GetIfExistsAsync(id); + MachineLearningJobResource result = response.HasValue ? response.Value : null; - // invoke the operation - string id = "string"; - MachineLearningJobData data = new MachineLearningJobData(new MachineLearningPipelineJob() + if (result == null) { - Settings = BinaryData.FromObjectAsJson(new Dictionary() - { - }), - Inputs = -{ -["string"] = new MachineLearningLiteralJobInput("string") -{ -Description = "string", -}, -}, - Outputs = -{ -["string"] = new MachineLearningUriFileJobOutput() -{ -Uri = new Uri("string"), -Mode = MachineLearningOutputDeliveryMode.Upload, -Description = "string", -}, -}, - DisplayName = "string", - ExperimentName = "string", - Services = -{ -["string"] = new MachineLearningJobService() -{ -JobServiceType = "string", -Port = 1, -Endpoint = "string", -Properties = -{ -["string"] = "string", -}, -}, -}, - ComputeId = new ResourceIdentifier("string"), - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); - MachineLearningJobResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateSweepJob() + public async Task GetIfExists_GetSweepJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/SweepJob/createOrUpdate.json - // this example is just showing the usage of "Jobs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/SweepJob/get.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -911,80 +966,21 @@ public async Task CreateOrUpdate_CreateOrUpdateSweepJob() // invoke the operation string id = "string"; - MachineLearningJobData data = new MachineLearningJobData(new MachineLearningSweepJob(BinaryData.FromObjectAsJson(new Dictionary() - { - ["string"] = new Dictionary() - { - } - }), new GridSamplingAlgorithm(), new MachineLearningObjective("string", MachineLearningGoal.Minimize), new MachineLearningTrialComponent("string", new ResourceIdentifier("string")) + NullableResponse response = await collection.GetIfExistsAsync(id); + MachineLearningJobResource result = response.HasValue ? response.Value : null; + + if (result == null) { - CodeId = new ResourceIdentifier("string"), - EnvironmentVariables = -{ -["string"] = "string", -}, - Distribution = new MpiDistributionConfiguration() - { - ProcessCountPerInstance = 1, - }, - Resources = new MachineLearningJobResourceConfiguration() - { - InstanceCount = 1, - InstanceType = "string", - Properties = -{ -["string"] = BinaryData.FromObjectAsJson(new Dictionary() -{ -["e6b6493e-7d5e-4db3-be1e-306ec641327e"] = null}), -}, - }, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Limits = new MachineLearningSweepJobLimits() - { - MaxTotalTrials = 1, - MaxConcurrentTrials = 1, - TrialTimeout = XmlConvert.ToTimeSpan("PT1S"), - }, - EarlyTermination = new MedianStoppingPolicy() - { - EvaluationInterval = 1, - DelayEvaluation = 1, - }, - DisplayName = "string", - ExperimentName = "string", - Services = -{ -["string"] = new MachineLearningJobService() -{ -JobServiceType = "string", -Port = 1, -Endpoint = "string", -Properties = -{ -["string"] = "string", -}, -}, -}, - ComputeId = new ResourceIdentifier("string"), - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, id, data); - MachineLearningJobResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningJobResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningJobResource.cs index 59f1edd74e5d7..883fc9b91591b 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningJobResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningJobResource.cs @@ -20,10 +20,10 @@ public partial class Sample_MachineLearningJobResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteJob() + public async Task Get_GetAutoMLJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/delete.json - // this example is just showing the usage of "Jobs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/get.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,21 +35,25 @@ public async Task Delete_DeleteJob() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "test-rg"; string workspaceName = "my-aml-workspace"; - string id = "http://subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/jobs/my-favorite-aml-job"; + string id = "string"; ResourceIdentifier machineLearningJobResourceId = MachineLearningJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, id); MachineLearningJobResource machineLearningJob = client.GetMachineLearningJobResource(machineLearningJobResourceId); // invoke the operation - await machineLearningJob.DeleteAsync(WaitUntil.Completed); + MachineLearningJobResource result = await machineLearningJob.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAutoMLJob() + public async Task Get_GetCommandJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/AutoMLJob/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -78,9 +82,9 @@ public async Task Get_GetAutoMLJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCommandJob() + public async Task Get_GetPipelineJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/CommandJob/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -109,9 +113,9 @@ public async Task Get_GetCommandJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPipelineJob() + public async Task Get_GetSweepJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/PipelineJob/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/SweepJob/get.json // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -140,10 +144,10 @@ public async Task Get_GetPipelineJob() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSweepJob() + public async Task Delete_DeleteJob() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/SweepJob/get.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Job/delete.json + // this example is just showing the usage of "Jobs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -155,18 +159,14 @@ public async Task Get_GetSweepJob() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "test-rg"; string workspaceName = "my-aml-workspace"; - string id = "string"; + string id = "http://subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.MachineLearningServices/workspaces/{workspaceName}/jobs/my-favorite-aml-job"; ResourceIdentifier machineLearningJobResourceId = MachineLearningJobResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, id); MachineLearningJobResource machineLearningJob = client.GetMachineLearningJobResource(machineLearningJobResourceId); // invoke the operation - MachineLearningJobResource result = await machineLearningJob.GetAsync(); + await machineLearningJob.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -191,64 +191,62 @@ public async Task Update_CreateOrUpdateAutoMLJob() MachineLearningJobResource machineLearningJob = client.GetMachineLearningJobResource(machineLearningJobResourceId); // invoke the operation - MachineLearningJobData data = new MachineLearningJobData(new AutoMLJob(new ImageClassification(new MachineLearningTableJobInput(new Uri("string")), new ImageLimitSettings() + MachineLearningJobData data = new MachineLearningJobData(new AutoMLJob(new ImageClassification(new MachineLearningTableJobInput(new Uri("string")), new ImageLimitSettings { MaxTrials = 2, }) { - ModelSettings = new ImageModelSettingsClassification() + ModelSettings = new ImageModelSettingsClassification { ValidationCropSize = 2, }, - SearchSpace = -{ -new ImageModelDistributionSettingsClassification() + SearchSpace = {new ImageModelDistributionSettingsClassification { ValidationCropSize = "choice(2, 360)", -} -}, +}}, TargetColumnName = "string", }) { - Resources = new MachineLearningJobResourceConfiguration() + Resources = new MachineLearningJobResourceConfiguration { InstanceCount = 1, InstanceType = "string", Properties = { -["string"] = BinaryData.FromObjectAsJson(new Dictionary() +["string"] = BinaryData.FromObjectAsJson(new Dictionary { -["9bec0ab0-c62f-4fa9-a97c-7b24bbcc90ad"] = null}), +["9bec0ab0-c62f-4fa9-a97c-7b24bbcc90ad"] = null +}) }, }, EnvironmentId = "string", EnvironmentVariables = { -["string"] = "string", +["string"] = "string" }, Outputs = { -["string"] = new MachineLearningUriFileJobOutput() +["string"] = new MachineLearningUriFileJobOutput { Uri = new Uri("string"), Mode = MachineLearningOutputDeliveryMode.ReadWriteMount, Description = "string", -}, +} }, DisplayName = "string", ExperimentName = "string", Services = { -["string"] = new MachineLearningJobService() +["string"] = new MachineLearningJobService { JobServiceType = "string", Port = 1, Endpoint = "string", Properties = { -["string"] = "string", -}, +["string"] = "string" }, +} }, ComputeId = new ResourceIdentifier("string"), IsArchived = false, @@ -256,11 +254,11 @@ public async Task Update_CreateOrUpdateAutoMLJob() Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningJob.UpdateAsync(WaitUntil.Completed, data); @@ -297,15 +295,16 @@ public async Task Update_CreateOrUpdateCommandJob() // invoke the operation MachineLearningJobData data = new MachineLearningJobData(new MachineLearningCommandJob("string", new ResourceIdentifier("string")) { - Resources = new MachineLearningJobResourceConfiguration() + Resources = new MachineLearningJobResourceConfiguration { InstanceCount = 1, InstanceType = "string", Properties = { -["string"] = BinaryData.FromObjectAsJson(new Dictionary() +["string"] = BinaryData.FromObjectAsJson(new Dictionary { -["e6b6493e-7d5e-4db3-be1e-306ec641327e"] = null}), +["e6b6493e-7d5e-4db3-be1e-306ec641327e"] = null +}) }, }, CodeId = new ResourceIdentifier("string"), @@ -314,55 +313,55 @@ public async Task Update_CreateOrUpdateCommandJob() ["string"] = new MachineLearningLiteralJobInput("string") { Description = "string", -}, +} }, Outputs = { -["string"] = new MachineLearningUriFileJobOutput() +["string"] = new MachineLearningUriFileJobOutput { Uri = new Uri("string"), Mode = MachineLearningOutputDeliveryMode.ReadWriteMount, Description = "string", +} }, -}, - Distribution = new TensorFlowDistributionConfiguration() + Distribution = new TensorFlowDistributionConfiguration { WorkerCount = 1, ParameterServerCount = 1, }, - Limits = new MachineLearningCommandJobLimits() + Limits = new MachineLearningCommandJobLimits { Timeout = XmlConvert.ToTimeSpan("PT5M"), }, EnvironmentVariables = { -["string"] = "string", +["string"] = "string" }, DisplayName = "string", ExperimentName = "string", Services = { -["string"] = new MachineLearningJobService() +["string"] = new MachineLearningJobService { JobServiceType = "string", Port = 1, Endpoint = "string", Properties = { -["string"] = "string", -}, +["string"] = "string" }, +} }, ComputeId = new ResourceIdentifier("string"), Identity = new AmlToken(), Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningJob.UpdateAsync(WaitUntil.Completed, data); @@ -397,51 +396,49 @@ public async Task Update_CreateOrUpdatePipelineJob() MachineLearningJobResource machineLearningJob = client.GetMachineLearningJobResource(machineLearningJobResourceId); // invoke the operation - MachineLearningJobData data = new MachineLearningJobData(new MachineLearningPipelineJob() + MachineLearningJobData data = new MachineLearningJobData(new MachineLearningPipelineJob { - Settings = BinaryData.FromObjectAsJson(new Dictionary() - { - }), + Settings = BinaryData.FromObjectAsJson(new object()), Inputs = { ["string"] = new MachineLearningLiteralJobInput("string") { Description = "string", -}, +} }, Outputs = { -["string"] = new MachineLearningUriFileJobOutput() +["string"] = new MachineLearningUriFileJobOutput { Uri = new Uri("string"), Mode = MachineLearningOutputDeliveryMode.Upload, Description = "string", -}, +} }, DisplayName = "string", ExperimentName = "string", Services = { -["string"] = new MachineLearningJobService() +["string"] = new MachineLearningJobService { JobServiceType = "string", Port = 1, Endpoint = "string", Properties = { -["string"] = "string", -}, +["string"] = "string" }, +} }, ComputeId = new ResourceIdentifier("string"), Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningJob.UpdateAsync(WaitUntil.Completed, data); @@ -476,42 +473,41 @@ public async Task Update_CreateOrUpdateSweepJob() MachineLearningJobResource machineLearningJob = client.GetMachineLearningJobResource(machineLearningJobResourceId); // invoke the operation - MachineLearningJobData data = new MachineLearningJobData(new MachineLearningSweepJob(BinaryData.FromObjectAsJson(new Dictionary() + MachineLearningJobData data = new MachineLearningJobData(new MachineLearningSweepJob(BinaryData.FromObjectAsJson(new Dictionary { - ["string"] = new Dictionary() - { - } + ["string"] = new object() }), new GridSamplingAlgorithm(), new MachineLearningObjective("string", MachineLearningGoal.Minimize), new MachineLearningTrialComponent("string", new ResourceIdentifier("string")) { CodeId = new ResourceIdentifier("string"), EnvironmentVariables = { -["string"] = "string", +["string"] = "string" }, - Distribution = new MpiDistributionConfiguration() + Distribution = new MpiDistributionConfiguration { ProcessCountPerInstance = 1, }, - Resources = new MachineLearningJobResourceConfiguration() + Resources = new MachineLearningJobResourceConfiguration { InstanceCount = 1, InstanceType = "string", Properties = { -["string"] = BinaryData.FromObjectAsJson(new Dictionary() +["string"] = BinaryData.FromObjectAsJson(new Dictionary { -["e6b6493e-7d5e-4db3-be1e-306ec641327e"] = null}), +["e6b6493e-7d5e-4db3-be1e-306ec641327e"] = null +}) }, }, }) { - Limits = new MachineLearningSweepJobLimits() + Limits = new MachineLearningSweepJobLimits { MaxTotalTrials = 1, MaxConcurrentTrials = 1, TrialTimeout = XmlConvert.ToTimeSpan("PT1S"), }, - EarlyTermination = new MedianStoppingPolicy() + EarlyTermination = new MedianStoppingPolicy { EvaluationInterval = 1, DelayEvaluation = 1, @@ -520,26 +516,26 @@ public async Task Update_CreateOrUpdateSweepJob() ExperimentName = "string", Services = { -["string"] = new MachineLearningJobService() +["string"] = new MachineLearningJobService { JobServiceType = "string", Port = 1, Endpoint = "string", Properties = { -["string"] = "string", -}, +["string"] = "string" }, +} }, ComputeId = new ResourceIdentifier("string"), Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningJob.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningMarketplaceSubscriptionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningMarketplaceSubscriptionCollection.cs index f7bcc8430684f..b6339366e627d 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningMarketplaceSubscriptionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningMarketplaceSubscriptionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningMarketplaceSubscriptionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceMarketplaceSubscription() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceMarketplaceSubscription() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/list.json - // this example is just showing the usage of "MarketplaceSubscriptions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/createOrUpdate.json + // this example is just showing the usage of "MarketplaceSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,17 @@ public async Task GetAll_ListWorkspaceMarketplaceSubscription() // get the collection of this MachineLearningMarketplaceSubscriptionResource MachineLearningMarketplaceSubscriptionCollection collection = machineLearningWorkspace.GetMachineLearningMarketplaceSubscriptions(); - // invoke the operation and iterate over the result - await foreach (MachineLearningMarketplaceSubscriptionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningMarketplaceSubscriptionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "string"; + MachineLearningMarketplaceSubscriptionData data = new MachineLearningMarketplaceSubscriptionData(new MachineLearningMarketplaceSubscriptionProperties("string")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningMarketplaceSubscriptionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningMarketplaceSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +88,10 @@ public async Task Get_GetWorkspaceMarketplaceSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceMarketplaceSubscription() + public async Task GetAll_ListWorkspaceMarketplaceSubscription() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/get.json - // this example is just showing the usage of "MarketplaceSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/list.json + // this example is just showing the usage of "MarketplaceSubscriptions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_GetWorkspaceMarketplaceSubscription() // get the collection of this MachineLearningMarketplaceSubscriptionResource MachineLearningMarketplaceSubscriptionCollection collection = machineLearningWorkspace.GetMachineLearningMarketplaceSubscriptions(); - // invoke the operation - string name = "string"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (MachineLearningMarketplaceSubscriptionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningMarketplaceSubscriptionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceMarketplaceSubscription() + public async Task Exists_GetWorkspaceMarketplaceSubscription() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/get.json // this example is just showing the usage of "MarketplaceSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_GetWorkspaceMarketplaceSubscription() // invoke the operation string name = "string"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningMarketplaceSubscriptionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningMarketplaceSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceMarketplaceSubscription() + public async Task GetIfExists_GetWorkspaceMarketplaceSubscription() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/createOrUpdate.json - // this example is just showing the usage of "MarketplaceSubscriptions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/get.json + // this example is just showing the usage of "MarketplaceSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,15 +177,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceMarketplaceSubscription( // invoke the operation string name = "string"; - MachineLearningMarketplaceSubscriptionData data = new MachineLearningMarketplaceSubscriptionData(new MachineLearningMarketplaceSubscriptionProperties("string")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningMarketplaceSubscriptionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningMarketplaceSubscriptionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningMarketplaceSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningMarketplaceSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningMarketplaceSubscriptionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningMarketplaceSubscriptionResource.cs index 2c3ca2be59fda..51d5acde4c0e5 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningMarketplaceSubscriptionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningMarketplaceSubscriptionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningMarketplaceSubscriptionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceMarketplaceSubscription() + public async Task Get_GetWorkspaceMarketplaceSubscription() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/delete.json - // this example is just showing the usage of "MarketplaceSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/get.json + // this example is just showing the usage of "MarketplaceSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteWorkspaceMarketplaceSubscription() MachineLearningMarketplaceSubscriptionResource machineLearningMarketplaceSubscription = client.GetMachineLearningMarketplaceSubscriptionResource(machineLearningMarketplaceSubscriptionResourceId); // invoke the operation - await machineLearningMarketplaceSubscription.DeleteAsync(WaitUntil.Completed); + MachineLearningMarketplaceSubscriptionResource result = await machineLearningMarketplaceSubscription.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningMarketplaceSubscriptionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceMarketplaceSubscription() + public async Task Delete_DeleteWorkspaceMarketplaceSubscription() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/get.json - // this example is just showing the usage of "MarketplaceSubscriptions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/MarketplaceSubscription/delete.json + // this example is just showing the usage of "MarketplaceSubscriptions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetWorkspaceMarketplaceSubscription() MachineLearningMarketplaceSubscriptionResource machineLearningMarketplaceSubscription = client.GetMachineLearningMarketplaceSubscriptionResource(machineLearningMarketplaceSubscriptionResourceId); // invoke the operation - MachineLearningMarketplaceSubscriptionResource result = await machineLearningMarketplaceSubscription.GetAsync(); + await machineLearningMarketplaceSubscription.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningMarketplaceSubscriptionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelContainerCollection.cs index b5375e13b3ab4..90f481e098e72 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningModelContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceModelContainer() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceModelContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/list.json - // this example is just showing the usage of "ModelContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/createOrUpdate.json + // this example is just showing the usage of "ModelContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ListWorkspaceModelContainer() // get the collection of this MachineLearningModelContainerResource MachineLearningModelContainerCollection collection = machineLearningWorkspace.GetMachineLearningModelContainers(); - // invoke the operation and iterate over the result - await foreach (MachineLearningModelContainerResource item in collection.GetAllAsync()) + // invoke the operation + string name = "testContainer"; + MachineLearningModelContainerData data = new MachineLearningModelContainerData(new MachineLearningModelContainerProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "Model container description", + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningModelContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetWorkspaceModelContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceModelContainer() + public async Task GetAll_ListWorkspaceModelContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/get.json - // this example is just showing the usage of "ModelContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/list.json + // this example is just showing the usage of "ModelContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetWorkspaceModelContainer() // get the collection of this MachineLearningModelContainerResource MachineLearningModelContainerCollection collection = machineLearningWorkspace.GetMachineLearningModelContainers(); - // invoke the operation - string name = "testContainer"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (MachineLearningModelContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceModelContainer() + public async Task Exists_GetWorkspaceModelContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/get.json // this example is just showing the usage of "ModelContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetWorkspaceModelContainer() // invoke the operation string name = "testContainer"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningModelContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceModelContainer() + public async Task GetIfExists_GetWorkspaceModelContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/createOrUpdate.json - // this example is just showing the usage of "ModelContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/get.json + // this example is just showing the usage of "ModelContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceModelContainer() // invoke the operation string name = "testContainer"; - MachineLearningModelContainerData data = new MachineLearningModelContainerData(new MachineLearningModelContainerProperties() - { - Description = "Model container description", - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningModelContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningModelContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelContainerResource.cs index 1e4b6d776f6ed..812e4e9ec3b3f 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningModelContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceModelContainer() + public async Task Get_GetWorkspaceModelContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/delete.json - // this example is just showing the usage of "ModelContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/get.json + // this example is just showing the usage of "ModelContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteWorkspaceModelContainer() MachineLearningModelContainerResource machineLearningModelContainer = client.GetMachineLearningModelContainerResource(machineLearningModelContainerResourceId); // invoke the operation - await machineLearningModelContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningModelContainerResource result = await machineLearningModelContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceModelContainer() + public async Task Delete_DeleteWorkspaceModelContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/get.json - // this example is just showing the usage of "ModelContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelContainer/delete.json + // this example is just showing the usage of "ModelContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetWorkspaceModelContainer() MachineLearningModelContainerResource machineLearningModelContainer = client.GetMachineLearningModelContainerResource(machineLearningModelContainerResourceId); // invoke the operation - MachineLearningModelContainerResource result = await machineLearningModelContainer.GetAsync(); + await machineLearningModelContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,13 +96,13 @@ public async Task Update_CreateOrUpdateWorkspaceModelContainer() MachineLearningModelContainerResource machineLearningModelContainer = client.GetMachineLearningModelContainerResource(machineLearningModelContainerResourceId); // invoke the operation - MachineLearningModelContainerData data = new MachineLearningModelContainerData(new MachineLearningModelContainerProperties() + MachineLearningModelContainerData data = new MachineLearningModelContainerData(new MachineLearningModelContainerProperties { Description = "Model container description", Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }); ArmOperation lro = await machineLearningModelContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelVersionCollection.cs index 3bfada15410ce..2c3b66e34efce 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningModelVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceModelVersion() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceModelVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/list.json - // this example is just showing the usage of "ModelVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/createOrUpdate.json + // this example is just showing the usage of "ModelVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,18 +40,41 @@ public async Task GetAll_ListWorkspaceModelVersion() // get the collection of this MachineLearningModelVersionResource MachineLearningModelVersionCollection collection = machineLearningModelContainer.GetMachineLearningModelVersions(); - // invoke the operation and iterate over the result - MachineLearningModelVersionCollectionGetAllOptions options = new MachineLearningModelVersionCollectionGetAllOptions() { OrderBy = "string", Top = 1, Version = "string", Description = "string", Offset = 1, Tags = "string", Properties = "string" }; - await foreach (MachineLearningModelVersionResource item in collection.GetAllAsync(options)) + // invoke the operation + string version = "string"; + MachineLearningModelVersionData data = new MachineLearningModelVersionData(new MachineLearningModelVersionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Flavors = +{ +["string"] = new MachineLearningFlavorData +{ +Data = +{ +["string"] = "string" +}, +} +}, + ModelType = "CustomModel", + ModelUri = new Uri("string"), + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningModelVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +114,10 @@ public async Task Get_GetWorkspaceModelVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceModelVersion() + public async Task GetAll_ListWorkspaceModelVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/get.json - // this example is just showing the usage of "ModelVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/list.json + // this example is just showing the usage of "ModelVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +136,23 @@ public async Task Exists_GetWorkspaceModelVersion() // get the collection of this MachineLearningModelVersionResource MachineLearningModelVersionCollection collection = machineLearningModelContainer.GetMachineLearningModelVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + MachineLearningModelVersionCollectionGetAllOptions options = new MachineLearningModelVersionCollectionGetAllOptions { OrderBy = "string", Top = 1, Version = "string", Description = "string", Offset = 1, Tags = "string", Properties = "string" }; + await foreach (MachineLearningModelVersionResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceModelVersion() + public async Task Exists_GetWorkspaceModelVersion() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/get.json // this example is just showing the usage of "ModelVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +176,17 @@ public async Task GetIfExists_GetWorkspaceModelVersion() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningModelVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceModelVersion() + public async Task GetIfExists_GetWorkspaceModelVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/createOrUpdate.json - // this example is just showing the usage of "ModelVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/get.json + // this example is just showing the usage of "ModelVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,39 +207,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceModelVersion() // invoke the operation string version = "string"; - MachineLearningModelVersionData data = new MachineLearningModelVersionData(new MachineLearningModelVersionProperties() - { - Flavors = -{ -["string"] = new MachineLearningFlavorData() -{ -Data = -{ -["string"] = "string", -}, -}, -}, - ModelType = "CustomModel", - ModelUri = new Uri("string"), - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningModelVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningModelVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelVersionResource.cs index 6223668ec2a01..acf95ef8fde56 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningModelVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningModelVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceModelVersion() + public async Task Get_GetWorkspaceModelVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/delete.json - // this example is just showing the usage of "ModelVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/get.json + // this example is just showing the usage of "ModelVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteWorkspaceModelVersion() MachineLearningModelVersionResource machineLearningModelVersion = client.GetMachineLearningModelVersionResource(machineLearningModelVersionResourceId); // invoke the operation - await machineLearningModelVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningModelVersionResource result = await machineLearningModelVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceModelVersion() + public async Task Delete_DeleteWorkspaceModelVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/get.json - // this example is just showing the usage of "ModelVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ModelVersion/delete.json + // this example is just showing the usage of "ModelVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetWorkspaceModelVersion() MachineLearningModelVersionResource machineLearningModelVersion = client.GetMachineLearningModelVersionResource(machineLearningModelVersionResourceId); // invoke the operation - MachineLearningModelVersionResource result = await machineLearningModelVersion.GetAsync(); + await machineLearningModelVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,17 +99,17 @@ public async Task Update_CreateOrUpdateWorkspaceModelVersion() MachineLearningModelVersionResource machineLearningModelVersion = client.GetMachineLearningModelVersionResource(machineLearningModelVersionResourceId); // invoke the operation - MachineLearningModelVersionData data = new MachineLearningModelVersionData(new MachineLearningModelVersionProperties() + MachineLearningModelVersionData data = new MachineLearningModelVersionData(new MachineLearningModelVersionProperties { Flavors = { -["string"] = new MachineLearningFlavorData() +["string"] = new MachineLearningFlavorData { Data = { -["string"] = "string", -}, +["string"] = "string" }, +} }, ModelType = "CustomModel", ModelUri = new Uri("string"), @@ -117,11 +117,11 @@ public async Task Update_CreateOrUpdateWorkspaceModelVersion() Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningModelVersion.UpdateAsync(WaitUntil.Completed, data); @@ -157,7 +157,7 @@ public async Task Publish_PublishWorkspaceModelVersion() MachineLearningModelVersionResource machineLearningModelVersion = client.GetMachineLearningModelVersionResource(machineLearningModelVersionResourceId); // invoke the operation - DestinationAssetContent content = new DestinationAssetContent() + DestinationAssetContent content = new DestinationAssetContent { RegistryName = "string", DestinationName = "string", diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineDeploymentCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineDeploymentCollection.cs index 876359610b5d1..16ee765d8ec98 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineDeploymentCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineDeploymentCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_MachineLearningOnlineDeploymentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListOnlineDeployments() + public async Task CreateOrUpdate_CreateOrUpdateKubernetesOnlineDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/list.json - // this example is just showing the usage of "OnlineDeployments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/KubernetesOnlineDeployment/createOrUpdate.json + // this example is just showing the usage of "OnlineDeployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,27 +42,93 @@ public async Task GetAll_ListOnlineDeployments() // get the collection of this MachineLearningOnlineDeploymentResource MachineLearningOnlineDeploymentCollection collection = machineLearningOnlineEndpoint.GetMachineLearningOnlineDeployments(); - // invoke the operation and iterate over the result - string orderBy = "string"; - int? top = 1; - await foreach (MachineLearningOnlineDeploymentResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + // invoke the operation + string deploymentName = "testDeploymentName"; + MachineLearningOnlineDeploymentData data = new MachineLearningOnlineDeploymentData(new AzureLocation("string"), new MachineLearningKubernetesOnlineDeployment { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineDeploymentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ContainerResourceRequirements = new MachineLearningContainerResourceRequirements + { + ContainerResourceRequests = new MachineLearningContainerResourceSettings + { + Cpu = "\"1\"", + Memory = "\"2Gi\"", + Gpu = "\"1\"", + }, + ContainerResourceLimits = new MachineLearningContainerResourceSettings + { + Cpu = "\"1\"", + Memory = "\"2Gi\"", + Gpu = "\"1\"", + }, + }, + ScaleSettings = new MachineLearningDefaultScaleSettings(), + RequestSettings = new MachineLearningOnlineRequestSettings + { + MaxQueueWait = XmlConvert.ToTimeSpan("PT5M"), + RequestTimeout = XmlConvert.ToTimeSpan("PT5M"), + MaxConcurrentRequestsPerInstance = 1, + }, + ModelMountPath = "string", + AppInsightsEnabled = false, + LivenessProbe = new MachineLearningProbeSettings + { + FailureThreshold = 1, + SuccessThreshold = 1, + Timeout = XmlConvert.ToTimeSpan("PT5M"), + Period = XmlConvert.ToTimeSpan("PT5M"), + InitialDelay = XmlConvert.ToTimeSpan("PT5M"), + }, + InstanceType = "string", + Model = "string", + Description = "string", + Properties = +{ +["string"] = "string" +}, + CodeConfiguration = new MachineLearningCodeConfiguration("string") + { + CodeId = new ResourceIdentifier("string"), + }, + EnvironmentId = "string", + EnvironmentVariables = +{ +["string"] = "string" +}, + }) + { + Kind = "string", + Identity = new ManagedServiceIdentity("SystemAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("string")] = new UserAssignedIdentity() +}, + }, + Sku = new MachineLearningSku("string") + { + Tier = MachineLearningSkuTier.Free, + Size = "string", + Family = "string", + Capacity = 1, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); + MachineLearningOnlineDeploymentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetKubernetesOnlineDeployment() + public async Task CreateOrUpdate_CreateOrUpdateManagedOnlineDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/KubernetesOnlineDeployment/get.json - // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/ManagedOnlineDeployment/createOrUpdate.json + // this example is just showing the usage of "OnlineDeployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -83,7 +149,70 @@ public async Task Get_GetKubernetesOnlineDeployment() // invoke the operation string deploymentName = "testDeploymentName"; - MachineLearningOnlineDeploymentResource result = await collection.GetAsync(deploymentName); + MachineLearningOnlineDeploymentData data = new MachineLearningOnlineDeploymentData(new AzureLocation("string"), new MachineLearningManagedOnlineDeployment + { + ScaleSettings = new MachineLearningDefaultScaleSettings(), + RequestSettings = new MachineLearningOnlineRequestSettings + { + MaxQueueWait = XmlConvert.ToTimeSpan("PT5M"), + RequestTimeout = XmlConvert.ToTimeSpan("PT5M"), + MaxConcurrentRequestsPerInstance = 1, + }, + ModelMountPath = "string", + AppInsightsEnabled = false, + LivenessProbe = new MachineLearningProbeSettings + { + FailureThreshold = 1, + SuccessThreshold = 1, + Timeout = XmlConvert.ToTimeSpan("PT5M"), + Period = XmlConvert.ToTimeSpan("PT5M"), + InitialDelay = XmlConvert.ToTimeSpan("PT5M"), + }, + ReadinessProbe = new MachineLearningProbeSettings + { + FailureThreshold = 30, + SuccessThreshold = 1, + Timeout = XmlConvert.ToTimeSpan("PT2S"), + Period = XmlConvert.ToTimeSpan("PT10S"), + InitialDelay = XmlConvert.ToTimeSpan("PT1S"), + }, + InstanceType = "string", + Model = "string", + Description = "string", + Properties = +{ +["string"] = "string" +}, + CodeConfiguration = new MachineLearningCodeConfiguration("string") + { + CodeId = new ResourceIdentifier("string"), + }, + EnvironmentId = "string", + EnvironmentVariables = +{ +["string"] = "string" +}, + }) + { + Kind = "string", + Identity = new ManagedServiceIdentity("SystemAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("string")] = new UserAssignedIdentity() +}, + }, + Sku = new MachineLearningSku("string") + { + Tier = MachineLearningSkuTier.Free, + Size = "string", + Family = "string", + Capacity = 1, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); + MachineLearningOnlineDeploymentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -94,7 +223,7 @@ public async Task Get_GetKubernetesOnlineDeployment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetKubernetesOnlineDeployment() + public async Task Get_GetKubernetesOnlineDeployment() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/KubernetesOnlineDeployment/get.json // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. @@ -118,16 +247,20 @@ public async Task Exists_GetKubernetesOnlineDeployment() // invoke the operation string deploymentName = "testDeploymentName"; - bool result = await collection.ExistsAsync(deploymentName); + MachineLearningOnlineDeploymentResource result = await collection.GetAsync(deploymentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetKubernetesOnlineDeployment() + public async Task Get_GetManagedOnlineDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/KubernetesOnlineDeployment/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/ManagedOnlineDeployment/get.json // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -149,29 +282,21 @@ public async Task GetIfExists_GetKubernetesOnlineDeployment() // invoke the operation string deploymentName = "testDeploymentName"; - NullableResponse response = await collection.GetIfExistsAsync(deploymentName); - MachineLearningOnlineDeploymentResource result = response.HasValue ? response.Value : null; + MachineLearningOnlineDeploymentResource result = await collection.GetAsync(deploymentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedOnlineDeployment() + public async Task GetAll_ListOnlineDeployments() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/ManagedOnlineDeployment/get.json - // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/list.json + // this example is just showing the usage of "OnlineDeployments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,22 +315,26 @@ public async Task Get_GetManagedOnlineDeployment() // get the collection of this MachineLearningOnlineDeploymentResource MachineLearningOnlineDeploymentCollection collection = machineLearningOnlineEndpoint.GetMachineLearningOnlineDeployments(); - // invoke the operation - string deploymentName = "testDeploymentName"; - MachineLearningOnlineDeploymentResource result = await collection.GetAsync(deploymentName); + // invoke the operation and iterate over the result + string orderBy = "string"; + int? top = 1; + await foreach (MachineLearningOnlineDeploymentResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineDeploymentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagedOnlineDeployment() + public async Task Exists_GetKubernetesOnlineDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/ManagedOnlineDeployment/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/KubernetesOnlineDeployment/get.json // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -234,7 +363,7 @@ public async Task Exists_GetManagedOnlineDeployment() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagedOnlineDeployment() + public async Task Exists_GetManagedOnlineDeployment() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/ManagedOnlineDeployment/get.json // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. @@ -258,29 +387,17 @@ public async Task GetIfExists_GetManagedOnlineDeployment() // invoke the operation string deploymentName = "testDeploymentName"; - NullableResponse response = await collection.GetIfExistsAsync(deploymentName); - MachineLearningOnlineDeploymentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(deploymentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateKubernetesOnlineDeployment() + public async Task GetIfExists_GetKubernetesOnlineDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/KubernetesOnlineDeployment/createOrUpdate.json - // this example is just showing the usage of "OnlineDeployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/KubernetesOnlineDeployment/get.json + // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -301,93 +418,29 @@ public async Task CreateOrUpdate_CreateOrUpdateKubernetesOnlineDeployment() // invoke the operation string deploymentName = "testDeploymentName"; - MachineLearningOnlineDeploymentData data = new MachineLearningOnlineDeploymentData(new AzureLocation("string"), new MachineLearningKubernetesOnlineDeployment() + NullableResponse response = await collection.GetIfExistsAsync(deploymentName); + MachineLearningOnlineDeploymentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - ContainerResourceRequirements = new MachineLearningContainerResourceRequirements() - { - ContainerResourceRequests = new MachineLearningContainerResourceSettings() - { - Cpu = "\"1\"", - Memory = "\"2Gi\"", - Gpu = "\"1\"", - }, - ContainerResourceLimits = new MachineLearningContainerResourceSettings() - { - Cpu = "\"1\"", - Memory = "\"2Gi\"", - Gpu = "\"1\"", - }, - }, - ScaleSettings = new MachineLearningDefaultScaleSettings(), - RequestSettings = new MachineLearningOnlineRequestSettings() - { - MaxQueueWait = XmlConvert.ToTimeSpan("PT5M"), - RequestTimeout = XmlConvert.ToTimeSpan("PT5M"), - MaxConcurrentRequestsPerInstance = 1, - }, - ModelMountPath = "string", - AppInsightsEnabled = false, - LivenessProbe = new MachineLearningProbeSettings() - { - FailureThreshold = 1, - SuccessThreshold = 1, - Timeout = XmlConvert.ToTimeSpan("PT5M"), - Period = XmlConvert.ToTimeSpan("PT5M"), - InitialDelay = XmlConvert.ToTimeSpan("PT5M"), - }, - InstanceType = "string", - Model = "string", - Description = "string", - Properties = -{ -["string"] = "string", -}, - CodeConfiguration = new MachineLearningCodeConfiguration("string") - { - CodeId = new ResourceIdentifier("string"), - }, - EnvironmentId = "string", - EnvironmentVariables = -{ -["string"] = "string", -}, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Kind = "string", - Identity = new ManagedServiceIdentity("SystemAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), -}, - }, - Sku = new MachineLearningSku("string") - { - Tier = MachineLearningSkuTier.Free, - Size = "string", - Family = "string", - Capacity = 1, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); - MachineLearningOnlineDeploymentResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateManagedOnlineDeployment() + public async Task GetIfExists_GetManagedOnlineDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/ManagedOnlineDeployment/createOrUpdate.json - // this example is just showing the usage of "OnlineDeployments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/ManagedOnlineDeployment/get.json + // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -408,78 +461,21 @@ public async Task CreateOrUpdate_CreateOrUpdateManagedOnlineDeployment() // invoke the operation string deploymentName = "testDeploymentName"; - MachineLearningOnlineDeploymentData data = new MachineLearningOnlineDeploymentData(new AzureLocation("string"), new MachineLearningManagedOnlineDeployment() + NullableResponse response = await collection.GetIfExistsAsync(deploymentName); + MachineLearningOnlineDeploymentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - ScaleSettings = new MachineLearningDefaultScaleSettings(), - RequestSettings = new MachineLearningOnlineRequestSettings() - { - MaxQueueWait = XmlConvert.ToTimeSpan("PT5M"), - RequestTimeout = XmlConvert.ToTimeSpan("PT5M"), - MaxConcurrentRequestsPerInstance = 1, - }, - ModelMountPath = "string", - AppInsightsEnabled = false, - LivenessProbe = new MachineLearningProbeSettings() - { - FailureThreshold = 1, - SuccessThreshold = 1, - Timeout = XmlConvert.ToTimeSpan("PT5M"), - Period = XmlConvert.ToTimeSpan("PT5M"), - InitialDelay = XmlConvert.ToTimeSpan("PT5M"), - }, - ReadinessProbe = new MachineLearningProbeSettings() - { - FailureThreshold = 30, - SuccessThreshold = 1, - Timeout = XmlConvert.ToTimeSpan("PT2S"), - Period = XmlConvert.ToTimeSpan("PT10S"), - InitialDelay = XmlConvert.ToTimeSpan("PT1S"), - }, - InstanceType = "string", - Model = "string", - Description = "string", - Properties = -{ -["string"] = "string", -}, - CodeConfiguration = new MachineLearningCodeConfiguration("string") - { - CodeId = new ResourceIdentifier("string"), - }, - EnvironmentId = "string", - EnvironmentVariables = -{ -["string"] = "string", -}, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Kind = "string", - Identity = new ManagedServiceIdentity("SystemAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), -}, - }, - Sku = new MachineLearningSku("string") - { - Tier = MachineLearningSkuTier.Free, - Size = "string", - Family = "string", - Capacity = 1, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); - MachineLearningOnlineDeploymentResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineDeploymentResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineDeploymentResource.cs index 12335158b90ce..f08b2246e4966 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineDeploymentResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineDeploymentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningOnlineDeploymentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceOnlineDeployment() + public async Task Get_GetKubernetesOnlineDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineDeployment/delete.json - // this example is just showing the usage of "OnlineDeployments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/KubernetesOnlineDeployment/get.json + // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,24 +31,28 @@ public async Task Delete_DeleteWorkspaceOnlineDeployment() // this example assumes you already have this MachineLearningOnlineDeploymentResource created on azure // for more information of creating MachineLearningOnlineDeploymentResource, please refer to the document of MachineLearningOnlineDeploymentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "testrg123"; - string workspaceName = "workspace123"; - string endpointName = "testEndpoint"; - string deploymentName = "testDeployment"; + string resourceGroupName = "test-rg"; + string workspaceName = "my-aml-workspace"; + string endpointName = "testEndpointName"; + string deploymentName = "testDeploymentName"; ResourceIdentifier machineLearningOnlineDeploymentResourceId = MachineLearningOnlineDeploymentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, endpointName, deploymentName); MachineLearningOnlineDeploymentResource machineLearningOnlineDeployment = client.GetMachineLearningOnlineDeploymentResource(machineLearningOnlineDeploymentResourceId); // invoke the operation - await machineLearningOnlineDeployment.DeleteAsync(WaitUntil.Completed); + MachineLearningOnlineDeploymentResource result = await machineLearningOnlineDeployment.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineDeploymentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetKubernetesOnlineDeployment() + public async Task Get_GetManagedOnlineDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/KubernetesOnlineDeployment/get.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/ManagedOnlineDeployment/get.json // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -78,10 +82,10 @@ public async Task Get_GetKubernetesOnlineDeployment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedOnlineDeployment() + public async Task Delete_DeleteWorkspaceOnlineDeployment() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/OnlineDeployment/ManagedOnlineDeployment/get.json - // this example is just showing the usage of "OnlineDeployments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineDeployment/delete.json + // this example is just showing the usage of "OnlineDeployments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,21 +95,17 @@ public async Task Get_GetManagedOnlineDeployment() // this example assumes you already have this MachineLearningOnlineDeploymentResource created on azure // for more information of creating MachineLearningOnlineDeploymentResource, please refer to the document of MachineLearningOnlineDeploymentResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "test-rg"; - string workspaceName = "my-aml-workspace"; - string endpointName = "testEndpointName"; - string deploymentName = "testDeploymentName"; + string resourceGroupName = "testrg123"; + string workspaceName = "workspace123"; + string endpointName = "testEndpoint"; + string deploymentName = "testDeployment"; ResourceIdentifier machineLearningOnlineDeploymentResourceId = MachineLearningOnlineDeploymentResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, endpointName, deploymentName); MachineLearningOnlineDeploymentResource machineLearningOnlineDeployment = client.GetMachineLearningOnlineDeploymentResource(machineLearningOnlineDeploymentResourceId); // invoke the operation - MachineLearningOnlineDeploymentResource result = await machineLearningOnlineDeployment.GetAsync(); + await machineLearningOnlineDeployment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineDeploymentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -131,9 +131,9 @@ public async Task Update_UpdateKubernetesOnlineDeployment() MachineLearningOnlineDeploymentResource machineLearningOnlineDeployment = client.GetMachineLearningOnlineDeploymentResource(machineLearningOnlineDeploymentResourceId); // invoke the operation - MachineLearningOnlineDeploymentPatch patch = new MachineLearningOnlineDeploymentPatch() + MachineLearningOnlineDeploymentPatch patch = new MachineLearningOnlineDeploymentPatch { - Sku = new MachineLearningSkuPatch() + Sku = new MachineLearningSkuPatch { Name = "string", Tier = MachineLearningSkuTier.Free, @@ -141,9 +141,7 @@ public async Task Update_UpdateKubernetesOnlineDeployment() Family = "string", Capacity = 1, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await machineLearningOnlineDeployment.UpdateAsync(WaitUntil.Completed, patch); MachineLearningOnlineDeploymentResource result = lro.Value; @@ -178,9 +176,9 @@ public async Task Update_UpdateManagedOnlineDeployment() MachineLearningOnlineDeploymentResource machineLearningOnlineDeployment = client.GetMachineLearningOnlineDeploymentResource(machineLearningOnlineDeploymentResourceId); // invoke the operation - MachineLearningOnlineDeploymentPatch patch = new MachineLearningOnlineDeploymentPatch() + MachineLearningOnlineDeploymentPatch patch = new MachineLearningOnlineDeploymentPatch { - Sku = new MachineLearningSkuPatch() + Sku = new MachineLearningSkuPatch { Name = "string", Tier = MachineLearningSkuTier.Free, @@ -188,9 +186,7 @@ public async Task Update_UpdateManagedOnlineDeployment() Family = "string", Capacity = 1, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await machineLearningOnlineDeployment.UpdateAsync(WaitUntil.Completed, patch); MachineLearningOnlineDeploymentResource result = lro.Value; @@ -225,7 +221,7 @@ public async Task GetLogs_GetOnlineDeploymentLogs() MachineLearningOnlineDeploymentResource machineLearningOnlineDeployment = client.GetMachineLearningOnlineDeploymentResource(machineLearningOnlineDeploymentResourceId); // invoke the operation - MachineLearningDeploymentLogsContent content = new MachineLearningDeploymentLogsContent() + MachineLearningDeploymentLogsContent content = new MachineLearningDeploymentLogsContent { ContainerType = MachineLearningContainerType.StorageInitializer, Tail = 0, diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineEndpointCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineEndpointCollection.cs index 3ae44f0a8750c..9647689c49b92 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineEndpointCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineEndpointCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MachineLearningOnlineEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceOnlineEndpoint() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceOnlineEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/list.json - // this example is just showing the usage of "OnlineEndpoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/createOrUpdate.json + // this example is just showing the usage of "OnlineEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,18 +40,47 @@ public async Task GetAll_ListWorkspaceOnlineEndpoint() // get the collection of this MachineLearningOnlineEndpointResource MachineLearningOnlineEndpointCollection collection = machineLearningWorkspace.GetMachineLearningOnlineEndpoints(); - // invoke the operation and iterate over the result - MachineLearningOnlineEndpointCollectionGetAllOptions options = new MachineLearningOnlineEndpointCollectionGetAllOptions() { Name = "string", Count = 1, ComputeType = MachineLearningEndpointComputeType.Managed, Tags = "string", Properties = "string", OrderBy = MachineLearningOrderString.CreatedAtDesc }; - await foreach (MachineLearningOnlineEndpointResource item in collection.GetAllAsync(options)) + // invoke the operation + string endpointName = "testEndpointName"; + MachineLearningOnlineEndpointData data = new MachineLearningOnlineEndpointData(new AzureLocation("string"), new MachineLearningOnlineEndpointProperties(MachineLearningEndpointAuthMode.AmlToken) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Compute = "string", + Traffic = +{ +["string"] = 1 +}, + Description = "string", + Properties = +{ +["string"] = "string" +}, + }) + { + Kind = "string", + Identity = new ManagedServiceIdentity("SystemAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("string")] = new UserAssignedIdentity() +}, + }, + Sku = new MachineLearningSku("string") + { + Tier = MachineLearningSkuTier.Free, + Size = "string", + Family = "string", + Capacity = 1, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); + MachineLearningOnlineEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +119,10 @@ public async Task Get_GetWorkspaceOnlineEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceOnlineEndpoint() + public async Task GetAll_ListWorkspaceOnlineEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/get.json - // this example is just showing the usage of "OnlineEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/list.json + // this example is just showing the usage of "OnlineEndpoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +140,23 @@ public async Task Exists_GetWorkspaceOnlineEndpoint() // get the collection of this MachineLearningOnlineEndpointResource MachineLearningOnlineEndpointCollection collection = machineLearningWorkspace.GetMachineLearningOnlineEndpoints(); - // invoke the operation - string endpointName = "testEndpointName"; - bool result = await collection.ExistsAsync(endpointName); + // invoke the operation and iterate over the result + MachineLearningOnlineEndpointCollectionGetAllOptions options = new MachineLearningOnlineEndpointCollectionGetAllOptions { Name = "string", Count = 1, ComputeType = MachineLearningEndpointComputeType.Managed, Tags = "string", Properties = "string", OrderBy = MachineLearningOrderString.CreatedAtDesc }; + await foreach (MachineLearningOnlineEndpointResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceOnlineEndpoint() + public async Task Exists_GetWorkspaceOnlineEndpoint() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/get.json // this example is just showing the usage of "OnlineEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,29 +179,17 @@ public async Task GetIfExists_GetWorkspaceOnlineEndpoint() // invoke the operation string endpointName = "testEndpointName"; - NullableResponse response = await collection.GetIfExistsAsync(endpointName); - MachineLearningOnlineEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(endpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceOnlineEndpoint() + public async Task GetIfExists_GetWorkspaceOnlineEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/createOrUpdate.json - // this example is just showing the usage of "OnlineEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/get.json + // this example is just showing the usage of "OnlineEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,47 +209,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceOnlineEndpoint() // invoke the operation string endpointName = "testEndpointName"; - MachineLearningOnlineEndpointData data = new MachineLearningOnlineEndpointData(new AzureLocation("string"), new MachineLearningOnlineEndpointProperties(MachineLearningEndpointAuthMode.AmlToken) + NullableResponse response = await collection.GetIfExistsAsync(endpointName); + MachineLearningOnlineEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Compute = "string", - Traffic = -{ -["string"] = 1, -}, - Description = "string", - Properties = -{ -["string"] = "string", -}, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Kind = "string", - Identity = new ManagedServiceIdentity("SystemAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), -}, - }, - Sku = new MachineLearningSku("string") - { - Tier = MachineLearningSkuTier.Free, - Size = "string", - Family = "string", - Capacity = 1, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); - MachineLearningOnlineEndpointResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineEndpointResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineEndpointResource.cs index 054830d762be0..0d10e6a2ddd24 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineEndpointResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOnlineEndpointResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_MachineLearningOnlineEndpointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceOnlineEndpoint() + public async Task Get_GetWorkspaceOnlineEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/delete.json - // this example is just showing the usage of "OnlineEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/get.json + // this example is just showing the usage of "OnlineEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +38,21 @@ public async Task Delete_DeleteWorkspaceOnlineEndpoint() MachineLearningOnlineEndpointResource machineLearningOnlineEndpoint = client.GetMachineLearningOnlineEndpointResource(machineLearningOnlineEndpointResourceId); // invoke the operation - await machineLearningOnlineEndpoint.DeleteAsync(WaitUntil.Completed); + MachineLearningOnlineEndpointResource result = await machineLearningOnlineEndpoint.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOnlineEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceOnlineEndpoint() + public async Task Delete_DeleteWorkspaceOnlineEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/get.json - // this example is just showing the usage of "OnlineEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/OnlineEndpoint/delete.json + // this example is just showing the usage of "OnlineEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,13 +69,9 @@ public async Task Get_GetWorkspaceOnlineEndpoint() MachineLearningOnlineEndpointResource machineLearningOnlineEndpoint = client.GetMachineLearningOnlineEndpointResource(machineLearningOnlineEndpointResourceId); // invoke the operation - MachineLearningOnlineEndpointResource result = await machineLearningOnlineEndpoint.GetAsync(); + await machineLearningOnlineEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOnlineEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,21 +96,17 @@ public async Task Update_UpdateWorkspaceOnlineEndpoint() MachineLearningOnlineEndpointResource machineLearningOnlineEndpoint = client.GetMachineLearningOnlineEndpointResource(machineLearningOnlineEndpointResourceId); // invoke the operation - MachineLearningResourcePatchWithIdentity body = new MachineLearningResourcePatchWithIdentity() + MachineLearningResourcePatchWithIdentity body = new MachineLearningResourcePatchWithIdentity { - Identity = new MachineLearningPartialManagedServiceIdentity() + Identity = new MachineLearningPartialManagedServiceIdentity { ManagedServiceIdentityType = "SystemAssigned", UserAssignedIdentities = { -["string"] = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), +["string"] = BinaryData.FromObjectAsJson(new object()) }, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await machineLearningOnlineEndpoint.UpdateAsync(WaitUntil.Completed, body); MachineLearningOnlineEndpointResource result = lro.Value; diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOutboundRuleBasicCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOutboundRuleBasicCollection.cs index 9b8c936818dc0..4bd018f68f12e 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOutboundRuleBasicCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOutboundRuleBasicCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningOutboundRuleBasicCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagedNetworkSettingsRule() + public async Task CreateOrUpdate_CreateOrUpdateManagedNetworkSettingsRule() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/listRule.json - // this example is just showing the usage of "ManagedNetworkSettingsRule_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/createOrUpdateRule.json + // this example is just showing the usage of "ManagedNetworkSettingsRule_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,22 @@ public async Task GetAll_ListManagedNetworkSettingsRule() // get the collection of this MachineLearningOutboundRuleBasicResource MachineLearningOutboundRuleBasicCollection collection = machineLearningWorkspace.GetMachineLearningOutboundRuleBasics(); - // invoke the operation and iterate over the result - await foreach (MachineLearningOutboundRuleBasicResource item in collection.GetAllAsync()) + // invoke the operation + string ruleName = "rule_name_1"; + MachineLearningOutboundRuleBasicData data = new MachineLearningOutboundRuleBasicData(new FqdnOutboundRule { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOutboundRuleBasicData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Destination = "destination_endpoint", + Category = OutboundRuleCategory.UserDefined, + Status = OutboundRuleStatus.Active, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + MachineLearningOutboundRuleBasicResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOutboundRuleBasicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +93,10 @@ public async Task Get_GetManagedNetworkSettingsRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagedNetworkSettingsRule() + public async Task GetAll_ListManagedNetworkSettingsRule() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/getRule.json - // this example is just showing the usage of "ManagedNetworkSettingsRule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/listRule.json + // this example is just showing the usage of "ManagedNetworkSettingsRule_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +114,22 @@ public async Task Exists_GetManagedNetworkSettingsRule() // get the collection of this MachineLearningOutboundRuleBasicResource MachineLearningOutboundRuleBasicCollection collection = machineLearningWorkspace.GetMachineLearningOutboundRuleBasics(); - // invoke the operation - string ruleName = "name_of_the_fqdn_rule"; - bool result = await collection.ExistsAsync(ruleName); + // invoke the operation and iterate over the result + await foreach (MachineLearningOutboundRuleBasicResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOutboundRuleBasicData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagedNetworkSettingsRule() + public async Task Exists_GetManagedNetworkSettingsRule() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/getRule.json // this example is just showing the usage of "ManagedNetworkSettingsRule_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +152,17 @@ public async Task GetIfExists_GetManagedNetworkSettingsRule() // invoke the operation string ruleName = "name_of_the_fqdn_rule"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - MachineLearningOutboundRuleBasicResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOutboundRuleBasicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateManagedNetworkSettingsRule() + public async Task GetIfExists_GetManagedNetworkSettingsRule() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/createOrUpdateRule.json - // this example is just showing the usage of "ManagedNetworkSettingsRule_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/getRule.json + // this example is just showing the usage of "ManagedNetworkSettingsRule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,21 +181,22 @@ public async Task CreateOrUpdate_CreateOrUpdateManagedNetworkSettingsRule() MachineLearningOutboundRuleBasicCollection collection = machineLearningWorkspace.GetMachineLearningOutboundRuleBasics(); // invoke the operation - string ruleName = "rule_name_1"; - MachineLearningOutboundRuleBasicData data = new MachineLearningOutboundRuleBasicData(new FqdnOutboundRule() - { - Destination = "destination_endpoint", - Category = OutboundRuleCategory.UserDefined, - Status = OutboundRuleStatus.Active, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - MachineLearningOutboundRuleBasicResource result = lro.Value; + string ruleName = "name_of_the_fqdn_rule"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + MachineLearningOutboundRuleBasicResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOutboundRuleBasicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOutboundRuleBasicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOutboundRuleBasicResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOutboundRuleBasicResource.cs index f726de50c9024..6b59e7e451bc8 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOutboundRuleBasicResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningOutboundRuleBasicResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningOutboundRuleBasicResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteManagedNetworkSettingsRule() + public async Task Get_GetManagedNetworkSettingsRule() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/deleteRule.json - // this example is just showing the usage of "ManagedNetworkSettingsRule_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/getRule.json + // this example is just showing the usage of "ManagedNetworkSettingsRule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +33,26 @@ public async Task Delete_DeleteManagedNetworkSettingsRule() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "test-rg"; string workspaceName = "aml-workspace-name"; - string ruleName = "rule-name"; + string ruleName = "name_of_the_fqdn_rule"; ResourceIdentifier machineLearningOutboundRuleBasicResourceId = MachineLearningOutboundRuleBasicResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, ruleName); MachineLearningOutboundRuleBasicResource machineLearningOutboundRuleBasic = client.GetMachineLearningOutboundRuleBasicResource(machineLearningOutboundRuleBasicResourceId); // invoke the operation - await machineLearningOutboundRuleBasic.DeleteAsync(WaitUntil.Completed); + MachineLearningOutboundRuleBasicResource result = await machineLearningOutboundRuleBasic.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningOutboundRuleBasicData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagedNetworkSettingsRule() + public async Task Delete_DeleteManagedNetworkSettingsRule() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/getRule.json - // this example is just showing the usage of "ManagedNetworkSettingsRule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/ManagedNetwork/deleteRule.json + // this example is just showing the usage of "ManagedNetworkSettingsRule_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,14 @@ public async Task Get_GetManagedNetworkSettingsRule() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "test-rg"; string workspaceName = "aml-workspace-name"; - string ruleName = "name_of_the_fqdn_rule"; + string ruleName = "rule-name"; ResourceIdentifier machineLearningOutboundRuleBasicResourceId = MachineLearningOutboundRuleBasicResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, workspaceName, ruleName); MachineLearningOutboundRuleBasicResource machineLearningOutboundRuleBasic = client.GetMachineLearningOutboundRuleBasicResource(machineLearningOutboundRuleBasicResourceId); // invoke the operation - MachineLearningOutboundRuleBasicResource result = await machineLearningOutboundRuleBasic.GetAsync(); + await machineLearningOutboundRuleBasic.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningOutboundRuleBasicData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_CreateOrUpdateManagedNetworkSettingsRule() MachineLearningOutboundRuleBasicResource machineLearningOutboundRuleBasic = client.GetMachineLearningOutboundRuleBasicResource(machineLearningOutboundRuleBasicResourceId); // invoke the operation - MachineLearningOutboundRuleBasicData data = new MachineLearningOutboundRuleBasicData(new FqdnOutboundRule() + MachineLearningOutboundRuleBasicData data = new MachineLearningOutboundRuleBasicData(new FqdnOutboundRule { Destination = "destination_endpoint", Category = OutboundRuleCategory.UserDefined, diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningPrivateEndpointConnectionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningPrivateEndpointConnectionCollection.cs index c8a7df8fc00ac..09a17290312a0 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningPrivateEndpointConnectionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StorageAccountListPrivateEndpointConnections() + public async Task CreateOrUpdate_WorkspacePutPrivateEndpointConnection() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/list.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/createOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_StorageAccountListPrivateEndpointConnections() // get the collection of this MachineLearningPrivateEndpointConnectionResource MachineLearningPrivateEndpointConnectionCollection collection = machineLearningWorkspace.GetMachineLearningPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (MachineLearningPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "{privateEndpointConnectionName}"; + MachineLearningPrivateEndpointConnectionData data = new MachineLearningPrivateEndpointConnectionData(default) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new MachineLearningPrivateLinkServiceConnectionState + { + Status = MachineLearningPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + MachineLearningPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_WorkspaceGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WorkspaceGetPrivateEndpointConnection() + public async Task GetAll_StorageAccountListPrivateEndpointConnections() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/get.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/list.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_WorkspaceGetPrivateEndpointConnection() // get the collection of this MachineLearningPrivateEndpointConnectionResource MachineLearningPrivateEndpointConnectionCollection collection = machineLearningWorkspace.GetMachineLearningPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (MachineLearningPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WorkspaceGetPrivateEndpointConnection() + public async Task Exists_WorkspaceGetPrivateEndpointConnection() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/get.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_WorkspaceGetPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - MachineLearningPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_WorkspacePutPrivateEndpointConnection() + public async Task GetIfExists_WorkspaceGetPrivateEndpointConnection() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/createOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/get.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_WorkspacePutPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "{privateEndpointConnectionName}"; - MachineLearningPrivateEndpointConnectionData data = new MachineLearningPrivateEndpointConnectionData(new AzureLocation("placeholder")) - { - ConnectionState = new MachineLearningPrivateLinkServiceConnectionState() - { - Status = MachineLearningPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - MachineLearningPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + MachineLearningPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningPrivateEndpointConnectionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningPrivateEndpointConnectionResource.cs index 3690c49782e7c..a3466fd0e8cb4 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningPrivateEndpointConnectionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_WorkspaceGetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_WorkspacePutPrivateEndpointConnection() + public async Task Delete_WorkspaceDeletePrivateEndpointConnection() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/createOrUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_WorkspacePutPrivateEndpointConnection() MachineLearningPrivateEndpointConnectionResource machineLearningPrivateEndpointConnection = client.GetMachineLearningPrivateEndpointConnectionResource(machineLearningPrivateEndpointConnectionResourceId); // invoke the operation - MachineLearningPrivateEndpointConnectionData data = new MachineLearningPrivateEndpointConnectionData(new AzureLocation("placeholder")) - { - ConnectionState = new MachineLearningPrivateLinkServiceConnectionState() - { - Status = MachineLearningPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }, - }; - ArmOperation lro = await machineLearningPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - MachineLearningPrivateEndpointConnectionResource result = lro.Value; + await machineLearningPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_WorkspaceDeletePrivateEndpointConnection() + public async Task Update_WorkspacePutPrivateEndpointConnection() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/PrivateEndpointConnection/createOrUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_WorkspaceDeletePrivateEndpointConnection() MachineLearningPrivateEndpointConnectionResource machineLearningPrivateEndpointConnection = client.GetMachineLearningPrivateEndpointConnectionResource(machineLearningPrivateEndpointConnectionResourceId); // invoke the operation - await machineLearningPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + MachineLearningPrivateEndpointConnectionData data = new MachineLearningPrivateEndpointConnectionData(default) + { + ConnectionState = new MachineLearningPrivateLinkServiceConnectionState + { + Status = MachineLearningPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }, + }; + ArmOperation lro = await machineLearningPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + MachineLearningPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeContainerCollection.cs index cd6335bd26341..ea401a5f90681 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryCodeContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRegistryCodeContainer() + public async Task CreateOrUpdate_CreateOrUpdateRegistryCodeContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/list.json - // this example is just showing the usage of "RegistryCodeContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/createOrUpdate.json + // this example is just showing the usage of "RegistryCodeContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ListRegistryCodeContainer() // get the collection of this MachineLearningRegistryCodeContainerResource MachineLearningRegistryCodeContainerCollection collection = machineLearningRegistry.GetMachineLearningRegistryCodeContainers(); - // invoke the operation and iterate over the result - await foreach (MachineLearningRegistryCodeContainerResource item in collection.GetAllAsync()) + // invoke the operation + string codeName = "testContainer"; + MachineLearningCodeContainerData data = new MachineLearningCodeContainerData(new MachineLearningCodeContainerProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, codeName, data); + MachineLearningRegistryCodeContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetRegistryCodeContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryCodeContainer() + public async Task GetAll_ListRegistryCodeContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/get.json - // this example is just showing the usage of "RegistryCodeContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/list.json + // this example is just showing the usage of "RegistryCodeContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetRegistryCodeContainer() // get the collection of this MachineLearningRegistryCodeContainerResource MachineLearningRegistryCodeContainerCollection collection = machineLearningRegistry.GetMachineLearningRegistryCodeContainers(); - // invoke the operation - string codeName = "testContainer"; - bool result = await collection.ExistsAsync(codeName); + // invoke the operation and iterate over the result + await foreach (MachineLearningRegistryCodeContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryCodeContainer() + public async Task Exists_GetRegistryCodeContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/get.json // this example is just showing the usage of "RegistryCodeContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetRegistryCodeContainer() // invoke the operation string codeName = "testContainer"; - NullableResponse response = await collection.GetIfExistsAsync(codeName); - MachineLearningRegistryCodeContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(codeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryCodeContainer() + public async Task GetIfExists_GetRegistryCodeContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/createOrUpdate.json - // this example is just showing the usage of "RegistryCodeContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/get.json + // this example is just showing the usage of "RegistryCodeContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryCodeContainer() // invoke the operation string codeName = "testContainer"; - MachineLearningCodeContainerData data = new MachineLearningCodeContainerData(new MachineLearningCodeContainerProperties() - { - Description = "string", - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, codeName, data); - MachineLearningRegistryCodeContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(codeName); + MachineLearningRegistryCodeContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeContainerResource.cs index f36bfa59cb873..d73db55bf3171 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryCodeContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistryCodeContainer() + public async Task Get_GetRegistryCodeContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/delete.json - // this example is just showing the usage of "RegistryCodeContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/get.json + // this example is just showing the usage of "RegistryCodeContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteRegistryCodeContainer() MachineLearningRegistryCodeContainerResource machineLearningRegistryCodeContainer = client.GetMachineLearningRegistryCodeContainerResource(machineLearningRegistryCodeContainerResourceId); // invoke the operation - await machineLearningRegistryCodeContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningRegistryCodeContainerResource result = await machineLearningRegistryCodeContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryCodeContainer() + public async Task Delete_DeleteRegistryCodeContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/get.json - // this example is just showing the usage of "RegistryCodeContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeContainer/delete.json + // this example is just showing the usage of "RegistryCodeContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetRegistryCodeContainer() MachineLearningRegistryCodeContainerResource machineLearningRegistryCodeContainer = client.GetMachineLearningRegistryCodeContainerResource(machineLearningRegistryCodeContainerResourceId); // invoke the operation - MachineLearningRegistryCodeContainerResource result = await machineLearningRegistryCodeContainer.GetAsync(); + await machineLearningRegistryCodeContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,13 +96,13 @@ public async Task Update_CreateOrUpdateRegistryCodeContainer() MachineLearningRegistryCodeContainerResource machineLearningRegistryCodeContainer = client.GetMachineLearningRegistryCodeContainerResource(machineLearningRegistryCodeContainerResourceId); // invoke the operation - MachineLearningCodeContainerData data = new MachineLearningCodeContainerData(new MachineLearningCodeContainerProperties() + MachineLearningCodeContainerData data = new MachineLearningCodeContainerData(new MachineLearningCodeContainerProperties { Description = "string", Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }); ArmOperation lro = await machineLearningRegistryCodeContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeVersionCollection.cs index f6fbf20f05cf3..6de20093646a4 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryCodeVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRegistryCodeVersion() + public async Task CreateOrUpdate_CreateOrUpdateRegistryCodeVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/list.json - // this example is just showing the usage of "RegistryCodeVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/createOrUpdate.json + // this example is just showing the usage of "RegistryCodeVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,19 +40,30 @@ public async Task GetAll_ListRegistryCodeVersion() // get the collection of this MachineLearningRegistryCodeVersionResource MachineLearningRegistryCodeVersionCollection collection = machineLearningRegistryCodeContainer.GetMachineLearningRegistryCodeVersions(); - // invoke the operation and iterate over the result - string orderBy = "string"; - int? top = 1; - await foreach (MachineLearningRegistryCodeVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + // invoke the operation + string version = "string"; + MachineLearningCodeVersionData data = new MachineLearningCodeVersionData(new MachineLearningCodeVersionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CodeUri = new Uri("https://blobStorage/folderName"), + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningRegistryCodeVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +103,10 @@ public async Task Get_GetRegistryCodeVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryCodeVersion() + public async Task GetAll_ListRegistryCodeVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/get.json - // this example is just showing the usage of "RegistryCodeVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/list.json + // this example is just showing the usage of "RegistryCodeVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +125,24 @@ public async Task Exists_GetRegistryCodeVersion() // get the collection of this MachineLearningRegistryCodeVersionResource MachineLearningRegistryCodeVersionCollection collection = machineLearningRegistryCodeContainer.GetMachineLearningRegistryCodeVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + string orderBy = "string"; + int? top = 1; + await foreach (MachineLearningRegistryCodeVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryCodeVersion() + public async Task Exists_GetRegistryCodeVersion() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/get.json // this example is just showing the usage of "RegistryCodeVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,29 +166,17 @@ public async Task GetIfExists_GetRegistryCodeVersion() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningRegistryCodeVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryCodeVersion() + public async Task GetIfExists_GetRegistryCodeVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/createOrUpdate.json - // this example is just showing the usage of "RegistryCodeVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/get.json + // this example is just showing the usage of "RegistryCodeVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,28 +197,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryCodeVersion() // invoke the operation string version = "string"; - MachineLearningCodeVersionData data = new MachineLearningCodeVersionData(new MachineLearningCodeVersionProperties() - { - CodeUri = new Uri("https://blobStorage/folderName"), - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningRegistryCodeVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningRegistryCodeVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeVersionResource.cs index afd0577d8cae3..32c2a649e06bc 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCodeVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryCodeVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistryCodeVersion() + public async Task Get_GetRegistryCodeVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/delete.json - // this example is just showing the usage of "RegistryCodeVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/get.json + // this example is just showing the usage of "RegistryCodeVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteRegistryCodeVersion() MachineLearningRegistryCodeVersionResource machineLearningRegistryCodeVersion = client.GetMachineLearningRegistryCodeVersionResource(machineLearningRegistryCodeVersionResourceId); // invoke the operation - await machineLearningRegistryCodeVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningRegistryCodeVersionResource result = await machineLearningRegistryCodeVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningCodeVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryCodeVersion() + public async Task Delete_DeleteRegistryCodeVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/get.json - // this example is just showing the usage of "RegistryCodeVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/CodeVersion/delete.json + // this example is just showing the usage of "RegistryCodeVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetRegistryCodeVersion() MachineLearningRegistryCodeVersionResource machineLearningRegistryCodeVersion = client.GetMachineLearningRegistryCodeVersionResource(machineLearningRegistryCodeVersionResourceId); // invoke the operation - MachineLearningRegistryCodeVersionResource result = await machineLearningRegistryCodeVersion.GetAsync(); + await machineLearningRegistryCodeVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningCodeVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,18 +99,18 @@ public async Task Update_CreateOrUpdateRegistryCodeVersion() MachineLearningRegistryCodeVersionResource machineLearningRegistryCodeVersion = client.GetMachineLearningRegistryCodeVersionResource(machineLearningRegistryCodeVersionResourceId); // invoke the operation - MachineLearningCodeVersionData data = new MachineLearningCodeVersionData(new MachineLearningCodeVersionProperties() + MachineLearningCodeVersionData data = new MachineLearningCodeVersionData(new MachineLearningCodeVersionProperties { CodeUri = new Uri("https://blobStorage/folderName"), IsAnonymous = false, Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningRegistryCodeVersion.UpdateAsync(WaitUntil.Completed, data); @@ -146,7 +146,7 @@ public async Task CreateOrGetStartPendingUpload_CreateOrGetStartPendingUploadReg MachineLearningRegistryCodeVersionResource machineLearningRegistryCodeVersion = client.GetMachineLearningRegistryCodeVersionResource(machineLearningRegistryCodeVersionResourceId); // invoke the operation - PendingUploadRequestDto body = new PendingUploadRequestDto() + PendingUploadRequestDto body = new PendingUploadRequestDto { PendingUploadId = "string", PendingUploadType = PendingUploadType.TemporaryBlobReference, diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCollection.cs index fa1b2005e12aa..dfe8d16d363d9 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_MachineLearningRegistryCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRegistriesWithSystemCreatedAccounts() + public async Task CreateOrUpdate_CreateOrUpdateRegistryWithSystemCreatedAccounts() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/list-SystemCreated.json - // this example is just showing the usage of "Registries_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/createOrUpdate-SystemCreated.json + // this example is just showing the usage of "Registries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,89 @@ public async Task GetAll_ListRegistriesWithSystemCreatedAccounts() // get the collection of this MachineLearningRegistryResource MachineLearningRegistryCollection collection = resourceGroupResource.GetMachineLearningRegistries(); - // invoke the operation and iterate over the result - await foreach (MachineLearningRegistryResource item in collection.GetAllAsync()) + // invoke the operation + string registryName = "string"; + MachineLearningRegistryData data = new MachineLearningRegistryData(new AzureLocation("string")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningRegistryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("string")] = new UserAssignedIdentity() +}, + }, + Kind = "string", + Sku = new MachineLearningSku("string") + { + Tier = MachineLearningSkuTier.Free, + Size = "string", + Family = "string", + Capacity = 1, + }, + DiscoveryUri = new Uri("string"), + IntellectualPropertyPublisher = "string", + ManagedResourceId = new ResourceIdentifier("string"), + MlFlowRegistryUri = new Uri("string"), + RegistryPrivateEndpointConnections = {new RegistryPrivateEndpointConnection +{ +Id = new ResourceIdentifier("string"), +Location = new AzureLocation("string"), +GroupIds = {"string"}, +PrivateEndpoint = new RegistryPrivateEndpoint +{ +SubnetArmId = new ResourceIdentifier("string"), +}, +RegistryPrivateLinkServiceConnectionState = new RegistryPrivateLinkServiceConnectionState +{ +ActionsRequired = "string", +Description = "string", +Status = EndpointServiceConnectionStatus.Approved, +}, +ProvisioningState = "string", +}}, + PublicNetworkAccess = "string", + RegionDetails = {new RegistryRegionArmDetails +{ +AcrDetails = {new RegistryAcrDetails +{ +SystemCreatedAcrAccount = new SystemCreatedAcrAccount +{ +AcrAccountName = "string", +AcrAccountSku = "string", +ArmResourceId = new ResourceIdentifier("string"), +}, +}}, +Location = new AzureLocation("string"), +StorageAccountDetails = {new StorageAccountDetails +{ +SystemCreatedStorageAccount = new SystemCreatedStorageAccount +{ +AllowBlobPublicAccess = false, +ArmResourceId = new ResourceIdentifier("string"), +StorageAccountHnsEnabled = false, +StorageAccountName = "string", +StorageAccountType = "string", +}, +}}, +}}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registryName, data); + MachineLearningRegistryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRegistriesWithUserCreatedAccounts() + public async Task CreateOrUpdate_CreateOrUpdateRegistryWithUserCreatedAccounts() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/list-UserCreated.json - // this example is just showing the usage of "Registries_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/createOrUpdate-UserCreated.json + // this example is just showing the usage of "Registries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +139,69 @@ public async Task GetAll_ListRegistriesWithUserCreatedAccounts() // get the collection of this MachineLearningRegistryResource MachineLearningRegistryCollection collection = resourceGroupResource.GetMachineLearningRegistries(); - // invoke the operation and iterate over the result - await foreach (MachineLearningRegistryResource item in collection.GetAllAsync()) + // invoke the operation + string registryName = "string"; + MachineLearningRegistryData data = new MachineLearningRegistryData(new AzureLocation("string")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningRegistryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("None") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("string")] = new UserAssignedIdentity() +}, + }, + Kind = "string", + Sku = new MachineLearningSku("string") + { + Tier = MachineLearningSkuTier.Free, + Size = "string", + Family = "string", + Capacity = 1, + }, + DiscoveryUri = new Uri("string"), + IntellectualPropertyPublisher = "string", + ManagedResourceId = new ResourceIdentifier("string"), + MlFlowRegistryUri = new Uri("string"), + RegistryPrivateEndpointConnections = {new RegistryPrivateEndpointConnection +{ +Id = new ResourceIdentifier("string"), +Location = new AzureLocation("string"), +GroupIds = {"string"}, +PrivateEndpoint = new RegistryPrivateEndpoint +{ +SubnetArmId = new ResourceIdentifier("string"), +}, +RegistryPrivateLinkServiceConnectionState = new RegistryPrivateLinkServiceConnectionState +{ +ActionsRequired = "string", +Description = "string", +Status = EndpointServiceConnectionStatus.Approved, +}, +ProvisioningState = "string", +}}, + PublicNetworkAccess = "string", + RegionDetails = {new RegistryRegionArmDetails +{ +AcrDetails = {new RegistryAcrDetails +{ +ArmResourceId = new ResourceIdentifier("string"), +}}, +Location = new AzureLocation("string"), +StorageAccountDetails = {new StorageAccountDetails +{ +ArmResourceId = new ResourceIdentifier("string"), +}}, +}}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registryName, data); + MachineLearningRegistryResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -123,9 +239,9 @@ public async Task Get_GetRegistryWithSystemCreatedAccounts() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryWithSystemCreatedAccounts() + public async Task Get_GetRegistryWithUserCreatedAccounts() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-SystemCreated.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-UserCreated.json // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -145,17 +261,21 @@ public async Task Exists_GetRegistryWithSystemCreatedAccounts() // invoke the operation string registryName = "string"; - bool result = await collection.ExistsAsync(registryName); + MachineLearningRegistryResource result = await collection.GetAsync(registryName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryWithSystemCreatedAccounts() + public async Task GetAll_ListRegistriesWithSystemCreatedAccounts() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-SystemCreated.json - // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/list-SystemCreated.json + // this example is just showing the usage of "Registries_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,31 +292,25 @@ public async Task GetIfExists_GetRegistryWithSystemCreatedAccounts() // get the collection of this MachineLearningRegistryResource MachineLearningRegistryCollection collection = resourceGroupResource.GetMachineLearningRegistries(); - // invoke the operation - string registryName = "string"; - NullableResponse response = await collection.GetIfExistsAsync(registryName); - MachineLearningRegistryResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MachineLearningRegistryResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MachineLearningRegistryData resourceData = result.Data; + MachineLearningRegistryData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryWithUserCreatedAccounts() + public async Task GetAll_ListRegistriesWithUserCreatedAccounts() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-UserCreated.json - // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/list-UserCreated.json + // this example is just showing the usage of "Registries_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,22 +327,24 @@ public async Task Get_GetRegistryWithUserCreatedAccounts() // get the collection of this MachineLearningRegistryResource MachineLearningRegistryCollection collection = resourceGroupResource.GetMachineLearningRegistries(); - // invoke the operation - string registryName = "string"; - MachineLearningRegistryResource result = await collection.GetAsync(registryName); + // invoke the operation and iterate over the result + await foreach (MachineLearningRegistryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningRegistryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryWithUserCreatedAccounts() + public async Task Exists_GetRegistryWithSystemCreatedAccounts() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-UserCreated.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-SystemCreated.json // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -255,7 +371,7 @@ public async Task Exists_GetRegistryWithUserCreatedAccounts() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryWithUserCreatedAccounts() + public async Task Exists_GetRegistryWithUserCreatedAccounts() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-UserCreated.json // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. @@ -277,29 +393,17 @@ public async Task GetIfExists_GetRegistryWithUserCreatedAccounts() // invoke the operation string registryName = "string"; - NullableResponse response = await collection.GetIfExistsAsync(registryName); - MachineLearningRegistryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(registryName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryWithSystemCreatedAccounts() + public async Task GetIfExists_GetRegistryWithSystemCreatedAccounts() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/createOrUpdate-SystemCreated.json - // this example is just showing the usage of "Registries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-SystemCreated.json + // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -318,104 +422,29 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryWithSystemCreatedAccounts // invoke the operation string registryName = "string"; - MachineLearningRegistryData data = new MachineLearningRegistryData(new AzureLocation("string")) - { - Identity = new ManagedServiceIdentity("None") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), -}, - }, - Kind = "string", - Sku = new MachineLearningSku("string") - { - Tier = MachineLearningSkuTier.Free, - Size = "string", - Family = "string", - Capacity = 1, - }, - DiscoveryUri = new Uri("string"), - IntellectualPropertyPublisher = "string", - ManagedResourceId = new ResourceIdentifier("string"), - MlFlowRegistryUri = new Uri("string"), - RegistryPrivateEndpointConnections = -{ -new RegistryPrivateEndpointConnection() -{ -Id = new ResourceIdentifier("string"), -Location = new AzureLocation("string"), -GroupIds = -{ -"string" -}, -PrivateEndpoint = new RegistryPrivateEndpoint() -{ -SubnetArmId = new ResourceIdentifier("string"), -}, -RegistryPrivateLinkServiceConnectionState = new RegistryPrivateLinkServiceConnectionState() -{ -ActionsRequired = "string", -Description = "string", -Status = EndpointServiceConnectionStatus.Approved, -}, -ProvisioningState = "string", -} -}, - PublicNetworkAccess = "string", - RegionDetails = -{ -new RegistryRegionArmDetails() -{ -AcrDetails = -{ -new RegistryAcrDetails() -{ -SystemCreatedAcrAccount = new SystemCreatedAcrAccount() -{ -AcrAccountName = "string", -AcrAccountSku = "string", -ArmResourceId = new ResourceIdentifier("string"), -}, -} -}, -Location = new AzureLocation("string"), -StorageAccountDetails = -{ -new StorageAccountDetails() -{ -SystemCreatedStorageAccount = new SystemCreatedStorageAccount() -{ -AllowBlobPublicAccess = false, -ArmResourceId = new ResourceIdentifier("string"), -StorageAccountHnsEnabled = false, -StorageAccountName = "string", -StorageAccountType = "string", -}, -} -}, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registryName, data); - MachineLearningRegistryResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(registryName); + MachineLearningRegistryResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryWithUserCreatedAccounts() + public async Task GetIfExists_GetRegistryWithUserCreatedAccounts() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/createOrUpdate-UserCreated.json - // this example is just showing the usage of "Registries_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-UserCreated.json + // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -434,84 +463,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryWithUserCreatedAccounts() // invoke the operation string registryName = "string"; - MachineLearningRegistryData data = new MachineLearningRegistryData(new AzureLocation("string")) - { - Identity = new ManagedServiceIdentity("None") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), -}, - }, - Kind = "string", - Sku = new MachineLearningSku("string") - { - Tier = MachineLearningSkuTier.Free, - Size = "string", - Family = "string", - Capacity = 1, - }, - DiscoveryUri = new Uri("string"), - IntellectualPropertyPublisher = "string", - ManagedResourceId = new ResourceIdentifier("string"), - MlFlowRegistryUri = new Uri("string"), - RegistryPrivateEndpointConnections = -{ -new RegistryPrivateEndpointConnection() -{ -Id = new ResourceIdentifier("string"), -Location = new AzureLocation("string"), -GroupIds = -{ -"string" -}, -PrivateEndpoint = new RegistryPrivateEndpoint() -{ -SubnetArmId = new ResourceIdentifier("string"), -}, -RegistryPrivateLinkServiceConnectionState = new RegistryPrivateLinkServiceConnectionState() -{ -ActionsRequired = "string", -Description = "string", -Status = EndpointServiceConnectionStatus.Approved, -}, -ProvisioningState = "string", -} -}, - PublicNetworkAccess = "string", - RegionDetails = -{ -new RegistryRegionArmDetails() -{ -AcrDetails = -{ -new RegistryAcrDetails() -{ -ArmResourceId = new ResourceIdentifier("string"), -} -}, -Location = new AzureLocation("string"), -StorageAccountDetails = -{ -new StorageAccountDetails() -{ -ArmResourceId = new ResourceIdentifier("string"), -} -}, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registryName, data); - MachineLearningRegistryResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(registryName); + MachineLearningRegistryResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataContainerCollection.cs index 9e2d67c3f83aa..ae0c90745cebf 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryDataContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RegistryListRegistryDataContainer() + public async Task CreateOrUpdate_CreateOrUpdateRegistryDataContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/registryList.json - // this example is just showing the usage of "RegistryDataContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/createOrUpdate.json + // this example is just showing the usage of "RegistryDataContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,18 +39,29 @@ public async Task GetAll_RegistryListRegistryDataContainer() // get the collection of this MachineLearningRegistryDataContainerResource MachineLearningRegistryDataContainerCollection collection = machineLearningRegistry.GetMachineLearningRegistryDataContainers(); - // invoke the operation and iterate over the result - MachineLearningListViewType? listViewType = MachineLearningListViewType.All; - await foreach (MachineLearningRegistryDataContainerResource item in collection.GetAllAsync(listViewType: listViewType)) + // invoke the operation + string name = "string"; + MachineLearningDataContainerData data = new MachineLearningDataContainerData(new MachineLearningDataContainerProperties(MachineLearningDataType.UriFolder) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IsArchived = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningRegistryDataContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +100,10 @@ public async Task Get_GetRegistryDataContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryDataContainer() + public async Task GetAll_RegistryListRegistryDataContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/get.json - // this example is just showing the usage of "RegistryDataContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/registryList.json + // this example is just showing the usage of "RegistryDataContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +121,23 @@ public async Task Exists_GetRegistryDataContainer() // get the collection of this MachineLearningRegistryDataContainerResource MachineLearningRegistryDataContainerCollection collection = machineLearningRegistry.GetMachineLearningRegistryDataContainers(); - // invoke the operation - string name = "string"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + MachineLearningListViewType? listViewType = MachineLearningListViewType.All; + await foreach (MachineLearningRegistryDataContainerResource item in collection.GetAllAsync(listViewType: listViewType)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryDataContainer() + public async Task Exists_GetRegistryDataContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/get.json // this example is just showing the usage of "RegistryDataContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +160,17 @@ public async Task GetIfExists_GetRegistryDataContainer() // invoke the operation string name = "string"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningRegistryDataContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryDataContainer() + public async Task GetIfExists_GetRegistryDataContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/createOrUpdate.json - // this example is just showing the usage of "RegistryDataContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/get.json + // this example is just showing the usage of "RegistryDataContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,27 +190,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryDataContainer() // invoke the operation string name = "string"; - MachineLearningDataContainerData data = new MachineLearningDataContainerData(new MachineLearningDataContainerProperties(MachineLearningDataType.UriFolder) - { - IsArchived = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningRegistryDataContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningRegistryDataContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataContainerResource.cs index 7076376ca0c6b..ad48e82a58d1d 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryDataContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistryDataContainer() + public async Task Get_GetRegistryDataContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/delete.json - // this example is just showing the usage of "RegistryDataContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/get.json + // this example is just showing the usage of "RegistryDataContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteRegistryDataContainer() MachineLearningRegistryDataContainerResource machineLearningRegistryDataContainer = client.GetMachineLearningRegistryDataContainerResource(machineLearningRegistryDataContainerResourceId); // invoke the operation - await machineLearningRegistryDataContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningRegistryDataContainerResource result = await machineLearningRegistryDataContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryDataContainer() + public async Task Delete_DeleteRegistryDataContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/get.json - // this example is just showing the usage of "RegistryDataContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataContainer/delete.json + // this example is just showing the usage of "RegistryDataContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetRegistryDataContainer() MachineLearningRegistryDataContainerResource machineLearningRegistryDataContainer = client.GetMachineLearningRegistryDataContainerResource(machineLearningRegistryDataContainerResourceId); // invoke the operation - MachineLearningRegistryDataContainerResource result = await machineLearningRegistryDataContainer.GetAsync(); + await machineLearningRegistryDataContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -102,11 +102,11 @@ public async Task Update_CreateOrUpdateRegistryDataContainer() Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningRegistryDataContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataVersionCollection.cs index 44a3ca68aa1e2..a568f1749caab 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryDataVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RegistryListRegistryDataVersionBase() + public async Task CreateOrUpdate_CreateOrUpdateRegistryDataVersionBase() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/registryList.json - // this example is just showing the usage of "RegistryDataVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/createOrUpdate.json + // this example is just showing the usage of "RegistryDataVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,21 +40,31 @@ public async Task GetAll_RegistryListRegistryDataVersionBase() // get the collection of this MachineLearningRegistryDataVersionResource MachineLearningRegistryDataVersionCollection collection = machineLearningRegistryDataContainer.GetMachineLearningRegistryDataVersions(); - // invoke the operation and iterate over the result - string orderBy = "string"; - int? top = 1; - string tags = "string"; - MachineLearningListViewType? listViewType = MachineLearningListViewType.ArchivedOnly; - await foreach (MachineLearningRegistryDataVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top, tags: tags, listViewType: listViewType)) + // invoke the operation + string version = "string"; + MachineLearningDataVersionData data = new MachineLearningDataVersionData(new MachineLearningTable(new Uri("string")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ReferencedUris = { new Uri("string") }, + IsArchived = false, + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningRegistryDataVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -94,10 +104,10 @@ public async Task Get_GetRegistryDataVersionBase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryDataVersionBase() + public async Task GetAll_RegistryListRegistryDataVersionBase() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/get.json - // this example is just showing the usage of "RegistryDataVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/registryList.json + // this example is just showing the usage of "RegistryDataVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,16 +126,26 @@ public async Task Exists_GetRegistryDataVersionBase() // get the collection of this MachineLearningRegistryDataVersionResource MachineLearningRegistryDataVersionCollection collection = machineLearningRegistryDataContainer.GetMachineLearningRegistryDataVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + string orderBy = "string"; + int? top = 1; + string tags = "string"; + MachineLearningListViewType? listViewType = MachineLearningListViewType.ArchivedOnly; + await foreach (MachineLearningRegistryDataVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top, tags: tags, listViewType: listViewType)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryDataVersionBase() + public async Task Exists_GetRegistryDataVersionBase() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/get.json // this example is just showing the usage of "RegistryDataVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +169,17 @@ public async Task GetIfExists_GetRegistryDataVersionBase() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningRegistryDataVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryDataVersionBase() + public async Task GetIfExists_GetRegistryDataVersionBase() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/createOrUpdate.json - // this example is just showing the usage of "RegistryDataVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/get.json + // this example is just showing the usage of "RegistryDataVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,32 +200,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryDataVersionBase() // invoke the operation string version = "string"; - MachineLearningDataVersionData data = new MachineLearningDataVersionData(new MachineLearningTable(new Uri("string")) - { - ReferencedUris = -{ -new Uri("string") -}, - IsArchived = false, - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningRegistryDataVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningRegistryDataVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataVersionResource.cs index b8c3878873f94..681d59970093a 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryDataVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryDataVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistryDataVersionBase() + public async Task Get_GetRegistryDataVersionBase() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/delete.json - // this example is just showing the usage of "RegistryDataVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/get.json + // this example is just showing the usage of "RegistryDataVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteRegistryDataVersionBase() MachineLearningRegistryDataVersionResource machineLearningRegistryDataVersion = client.GetMachineLearningRegistryDataVersionResource(machineLearningRegistryDataVersionResourceId); // invoke the operation - await machineLearningRegistryDataVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningRegistryDataVersionResource result = await machineLearningRegistryDataVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningDataVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryDataVersionBase() + public async Task Delete_DeleteRegistryDataVersionBase() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/get.json - // this example is just showing the usage of "RegistryDataVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/DataVersionBase/delete.json + // this example is just showing the usage of "RegistryDataVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetRegistryDataVersionBase() MachineLearningRegistryDataVersionResource machineLearningRegistryDataVersion = client.GetMachineLearningRegistryDataVersionResource(machineLearningRegistryDataVersionResourceId); // invoke the operation - MachineLearningRegistryDataVersionResource result = await machineLearningRegistryDataVersion.GetAsync(); + await machineLearningRegistryDataVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningDataVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -101,20 +101,17 @@ public async Task Update_CreateOrUpdateRegistryDataVersionBase() // invoke the operation MachineLearningDataVersionData data = new MachineLearningDataVersionData(new MachineLearningTable(new Uri("string")) { - ReferencedUris = -{ -new Uri("string") -}, + ReferencedUris = { new Uri("string") }, IsArchived = false, IsAnonymous = false, Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningRegistryDataVersion.UpdateAsync(WaitUntil.Completed, data); @@ -150,7 +147,7 @@ public async Task CreateOrGetStartPendingUpload_CreateOrGetStartPendingUploadReg MachineLearningRegistryDataVersionResource machineLearningRegistryDataVersion = client.GetMachineLearningRegistryDataVersionResource(machineLearningRegistryDataVersionResourceId); // invoke the operation - PendingUploadRequestDto body = new PendingUploadRequestDto() + PendingUploadRequestDto body = new PendingUploadRequestDto { PendingUploadId = "string", PendingUploadType = PendingUploadType.None, diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentContainerCollection.cs index 89063a6aa5cb6..921ce6001c923 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryEnvironmentContainerCollectio { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRegistryEnvironmentContainer() + public async Task CreateOrUpdate_CreateOrUpdateRegistryEnvironmentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/list.json - // this example is just showing the usage of "RegistryEnvironmentContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/createOrUpdate.json + // this example is just showing the usage of "RegistryEnvironmentContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,32 @@ public async Task GetAll_ListRegistryEnvironmentContainer() // get the collection of this MachineLearningRegistryEnvironmentContainerResource MachineLearningRegistryEnvironmentContainerCollection collection = machineLearningRegistry.GetMachineLearningRegistryEnvironmentContainers(); - // invoke the operation and iterate over the result - await foreach (MachineLearningRegistryEnvironmentContainerResource item in collection.GetAllAsync()) + // invoke the operation + string environmentName = "testEnvironment"; + MachineLearningEnvironmentContainerData data = new MachineLearningEnvironmentContainerData(new MachineLearningEnvironmentContainerProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "string", + Tags = +{ +["additionalProp1"] = "string", +["additionalProp2"] = "string", +["additionalProp3"] = "string" +}, + Properties = +{ +["additionalProp1"] = "string", +["additionalProp2"] = "string", +["additionalProp3"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, environmentName, data); + MachineLearningRegistryEnvironmentContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +103,10 @@ public async Task Get_GetRegistryEnvironmentContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryEnvironmentContainer() + public async Task GetAll_ListRegistryEnvironmentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/get.json - // this example is just showing the usage of "RegistryEnvironmentContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/list.json + // this example is just showing the usage of "RegistryEnvironmentContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +124,22 @@ public async Task Exists_GetRegistryEnvironmentContainer() // get the collection of this MachineLearningRegistryEnvironmentContainerResource MachineLearningRegistryEnvironmentContainerCollection collection = machineLearningRegistry.GetMachineLearningRegistryEnvironmentContainers(); - // invoke the operation - string environmentName = "testEnvironment"; - bool result = await collection.ExistsAsync(environmentName); + // invoke the operation and iterate over the result + await foreach (MachineLearningRegistryEnvironmentContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryEnvironmentContainer() + public async Task Exists_GetRegistryEnvironmentContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/get.json // this example is just showing the usage of "RegistryEnvironmentContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +162,17 @@ public async Task GetIfExists_GetRegistryEnvironmentContainer() // invoke the operation string environmentName = "testEnvironment"; - NullableResponse response = await collection.GetIfExistsAsync(environmentName); - MachineLearningRegistryEnvironmentContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(environmentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryEnvironmentContainer() + public async Task GetIfExists_GetRegistryEnvironmentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/createOrUpdate.json - // this example is just showing the usage of "RegistryEnvironmentContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/get.json + // this example is just showing the usage of "RegistryEnvironmentContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,30 +192,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryEnvironmentContainer() // invoke the operation string environmentName = "testEnvironment"; - MachineLearningEnvironmentContainerData data = new MachineLearningEnvironmentContainerData(new MachineLearningEnvironmentContainerProperties() - { - Description = "string", - Tags = -{ -["additionalProp1"] = "string", -["additionalProp2"] = "string", -["additionalProp3"] = "string", -}, - Properties = -{ -["additionalProp1"] = "string", -["additionalProp2"] = "string", -["additionalProp3"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, environmentName, data); - MachineLearningRegistryEnvironmentContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(environmentName); + MachineLearningRegistryEnvironmentContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentContainerResource.cs index d5720174a719e..85b451c881641 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryEnvironmentContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistryEnvironmentContainer() + public async Task Get_GetRegistryEnvironmentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/delete.json - // this example is just showing the usage of "RegistryEnvironmentContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/get.json + // this example is just showing the usage of "RegistryEnvironmentContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +33,26 @@ public async Task Delete_DeleteRegistryEnvironmentContainer() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "testrg123"; string registryName = "testregistry"; - string environmentName = "testContainer"; + string environmentName = "testEnvironment"; ResourceIdentifier machineLearningRegistryEnvironmentContainerResourceId = MachineLearningRegistryEnvironmentContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName, environmentName); MachineLearningRegistryEnvironmentContainerResource machineLearningRegistryEnvironmentContainer = client.GetMachineLearningRegistryEnvironmentContainerResource(machineLearningRegistryEnvironmentContainerResourceId); // invoke the operation - await machineLearningRegistryEnvironmentContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningRegistryEnvironmentContainerResource result = await machineLearningRegistryEnvironmentContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryEnvironmentContainer() + public async Task Delete_DeleteRegistryEnvironmentContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/get.json - // this example is just showing the usage of "RegistryEnvironmentContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentContainer/delete.json + // this example is just showing the usage of "RegistryEnvironmentContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,14 @@ public async Task Get_GetRegistryEnvironmentContainer() string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "testrg123"; string registryName = "testregistry"; - string environmentName = "testEnvironment"; + string environmentName = "testContainer"; ResourceIdentifier machineLearningRegistryEnvironmentContainerResourceId = MachineLearningRegistryEnvironmentContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName, environmentName); MachineLearningRegistryEnvironmentContainerResource machineLearningRegistryEnvironmentContainer = client.GetMachineLearningRegistryEnvironmentContainerResource(machineLearningRegistryEnvironmentContainerResourceId); // invoke the operation - MachineLearningRegistryEnvironmentContainerResource result = await machineLearningRegistryEnvironmentContainer.GetAsync(); + await machineLearningRegistryEnvironmentContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,20 +96,20 @@ public async Task Update_CreateOrUpdateRegistryEnvironmentContainer() MachineLearningRegistryEnvironmentContainerResource machineLearningRegistryEnvironmentContainer = client.GetMachineLearningRegistryEnvironmentContainerResource(machineLearningRegistryEnvironmentContainerResourceId); // invoke the operation - MachineLearningEnvironmentContainerData data = new MachineLearningEnvironmentContainerData(new MachineLearningEnvironmentContainerProperties() + MachineLearningEnvironmentContainerData data = new MachineLearningEnvironmentContainerData(new MachineLearningEnvironmentContainerProperties { Description = "string", Tags = { ["additionalProp1"] = "string", ["additionalProp2"] = "string", -["additionalProp3"] = "string", +["additionalProp3"] = "string" }, Properties = { ["additionalProp1"] = "string", ["additionalProp2"] = "string", -["additionalProp3"] = "string", +["additionalProp3"] = "string" }, }); ArmOperation lro = await machineLearningRegistryEnvironmentContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentVersionCollection.cs index ea2cc9151872c..d8527aaad0496 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryEnvironmentVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRegistryEnvironmentVersion() + public async Task CreateOrUpdate_CreateOrUpdateRegistryEnvironmentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/list.json - // this example is just showing the usage of "RegistryEnvironmentVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/createOrUpdate.json + // this example is just showing the usage of "RegistryEnvironmentVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task GetAll_ListRegistryEnvironmentVersion() // for more information of creating MachineLearningRegistryEnvironmentContainerResource, please refer to the document of MachineLearningRegistryEnvironmentContainerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "test-rg"; - string registryName = "my-aml-regsitry"; + string registryName = "my-aml-registry"; string environmentName = "string"; ResourceIdentifier machineLearningRegistryEnvironmentContainerResourceId = MachineLearningRegistryEnvironmentContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName, environmentName); MachineLearningRegistryEnvironmentContainerResource machineLearningRegistryEnvironmentContainer = client.GetMachineLearningRegistryEnvironmentContainerResource(machineLearningRegistryEnvironmentContainerResourceId); @@ -40,19 +40,41 @@ public async Task GetAll_ListRegistryEnvironmentVersion() // get the collection of this MachineLearningRegistryEnvironmentVersionResource MachineLearningRegistryEnvironmentVersionCollection collection = machineLearningRegistryEnvironmentContainer.GetMachineLearningRegistryEnvironmentVersions(); - // invoke the operation and iterate over the result - string orderBy = "string"; - int? top = 1; - await foreach (MachineLearningRegistryEnvironmentVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + // invoke the operation + string version = "string"; + MachineLearningEnvironmentVersionData data = new MachineLearningEnvironmentVersionData(new MachineLearningEnvironmentVersionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Image = "docker.io/tensorflow/serving:latest", + CondaFile = "string", + Build = new MachineLearningBuildContext(new Uri("https://storage-account.blob.core.windows.net/azureml/DockerBuildContext/95ddede6b9b8c4e90472db3acd0a8d28/")) + { + DockerfilePath = "prod/Dockerfile", + }, + InferenceConfig = new MachineLearningInferenceContainerProperties + { + LivenessRoute = new MachineLearningInferenceContainerRoute("string", 1), + ReadinessRoute = new MachineLearningInferenceContainerRoute("string", 1), + ScoringRoute = new MachineLearningInferenceContainerRoute("string", 1), + }, + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningRegistryEnvironmentVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +114,10 @@ public async Task Get_GetRegistryEnvironmentVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryEnvironmentVersion() + public async Task GetAll_ListRegistryEnvironmentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/get.json - // this example is just showing the usage of "RegistryEnvironmentVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/list.json + // this example is just showing the usage of "RegistryEnvironmentVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,7 +128,7 @@ public async Task Exists_GetRegistryEnvironmentVersion() // for more information of creating MachineLearningRegistryEnvironmentContainerResource, please refer to the document of MachineLearningRegistryEnvironmentContainerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; string resourceGroupName = "test-rg"; - string registryName = "my-aml-registry"; + string registryName = "my-aml-regsitry"; string environmentName = "string"; ResourceIdentifier machineLearningRegistryEnvironmentContainerResourceId = MachineLearningRegistryEnvironmentContainerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName, environmentName); MachineLearningRegistryEnvironmentContainerResource machineLearningRegistryEnvironmentContainer = client.GetMachineLearningRegistryEnvironmentContainerResource(machineLearningRegistryEnvironmentContainerResourceId); @@ -114,16 +136,24 @@ public async Task Exists_GetRegistryEnvironmentVersion() // get the collection of this MachineLearningRegistryEnvironmentVersionResource MachineLearningRegistryEnvironmentVersionCollection collection = machineLearningRegistryEnvironmentContainer.GetMachineLearningRegistryEnvironmentVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + string orderBy = "string"; + int? top = 1; + await foreach (MachineLearningRegistryEnvironmentVersionResource item in collection.GetAllAsync(orderBy: orderBy, top: top)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryEnvironmentVersion() + public async Task Exists_GetRegistryEnvironmentVersion() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/get.json // this example is just showing the usage of "RegistryEnvironmentVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,29 +177,17 @@ public async Task GetIfExists_GetRegistryEnvironmentVersion() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningRegistryEnvironmentVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryEnvironmentVersion() + public async Task GetIfExists_GetRegistryEnvironmentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/createOrUpdate.json - // this example is just showing the usage of "RegistryEnvironmentVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/get.json + // this example is just showing the usage of "RegistryEnvironmentVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,39 +208,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryEnvironmentVersion() // invoke the operation string version = "string"; - MachineLearningEnvironmentVersionData data = new MachineLearningEnvironmentVersionData(new MachineLearningEnvironmentVersionProperties() - { - Image = "docker.io/tensorflow/serving:latest", - CondaFile = "string", - Build = new MachineLearningBuildContext(new Uri("https://storage-account.blob.core.windows.net/azureml/DockerBuildContext/95ddede6b9b8c4e90472db3acd0a8d28/")) - { - DockerfilePath = "prod/Dockerfile", - }, - InferenceConfig = new MachineLearningInferenceContainerProperties() - { - LivenessRoute = new MachineLearningInferenceContainerRoute("string", 1), - ReadinessRoute = new MachineLearningInferenceContainerRoute("string", 1), - ScoringRoute = new MachineLearningInferenceContainerRoute("string", 1), - }, - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningRegistryEnvironmentVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningRegistryEnvironmentVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentVersionResource.cs index b1970e954c2d2..51fc16925cbe7 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryEnvironmentVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryEnvironmentVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistryEnvironmentVersion() + public async Task Get_GetRegistryEnvironmentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/delete.json - // this example is just showing the usage of "RegistryEnvironmentVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/get.json + // this example is just showing the usage of "RegistryEnvironmentVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteRegistryEnvironmentVersion() MachineLearningRegistryEnvironmentVersionResource machineLearningRegistryEnvironmentVersion = client.GetMachineLearningRegistryEnvironmentVersionResource(machineLearningRegistryEnvironmentVersionResourceId); // invoke the operation - await machineLearningRegistryEnvironmentVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningRegistryEnvironmentVersionResource result = await machineLearningRegistryEnvironmentVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningEnvironmentVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryEnvironmentVersion() + public async Task Delete_DeleteRegistryEnvironmentVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/get.json - // this example is just showing the usage of "RegistryEnvironmentVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/EnvironmentVersion/delete.json + // this example is just showing the usage of "RegistryEnvironmentVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetRegistryEnvironmentVersion() MachineLearningRegistryEnvironmentVersionResource machineLearningRegistryEnvironmentVersion = client.GetMachineLearningRegistryEnvironmentVersionResource(machineLearningRegistryEnvironmentVersionResourceId); // invoke the operation - MachineLearningRegistryEnvironmentVersionResource result = await machineLearningRegistryEnvironmentVersion.GetAsync(); + await machineLearningRegistryEnvironmentVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningEnvironmentVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,7 +99,7 @@ public async Task Update_CreateOrUpdateRegistryEnvironmentVersion() MachineLearningRegistryEnvironmentVersionResource machineLearningRegistryEnvironmentVersion = client.GetMachineLearningRegistryEnvironmentVersionResource(machineLearningRegistryEnvironmentVersionResourceId); // invoke the operation - MachineLearningEnvironmentVersionData data = new MachineLearningEnvironmentVersionData(new MachineLearningEnvironmentVersionProperties() + MachineLearningEnvironmentVersionData data = new MachineLearningEnvironmentVersionData(new MachineLearningEnvironmentVersionProperties { Image = "docker.io/tensorflow/serving:latest", CondaFile = "string", @@ -107,7 +107,7 @@ public async Task Update_CreateOrUpdateRegistryEnvironmentVersion() { DockerfilePath = "prod/Dockerfile", }, - InferenceConfig = new MachineLearningInferenceContainerProperties() + InferenceConfig = new MachineLearningInferenceContainerProperties { LivenessRoute = new MachineLearningInferenceContainerRoute("string", 1), ReadinessRoute = new MachineLearningInferenceContainerRoute("string", 1), @@ -117,11 +117,11 @@ public async Task Update_CreateOrUpdateRegistryEnvironmentVersion() Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningRegistryEnvironmentVersion.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelContainerCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelContainerCollection.cs index e88e996287492..3ebaafb23dd46 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelContainerCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelContainerCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryModelContainerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRegistryModelContainer() + public async Task CreateOrUpdate_CreateOrUpdateRegistryModelContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/list.json - // this example is just showing the usage of "RegistryModelContainers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/createOrUpdate.json + // this example is just showing the usage of "RegistryModelContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,25 @@ public async Task GetAll_ListRegistryModelContainer() // get the collection of this MachineLearningRegistryModelContainerResource MachineLearningRegistryModelContainerCollection collection = machineLearningRegistry.GetMachineLearningRegistryModelContainers(); - // invoke the operation and iterate over the result - await foreach (MachineLearningRegistryModelContainerResource item in collection.GetAllAsync()) + // invoke the operation + string modelName = "testContainer"; + MachineLearningModelContainerData data = new MachineLearningModelContainerData(new MachineLearningModelContainerProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelContainerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "Model container description", + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, modelName, data); + MachineLearningRegistryModelContainerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +96,10 @@ public async Task Get_GetRegistryModelContainer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryModelContainer() + public async Task GetAll_ListRegistryModelContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/get.json - // this example is just showing the usage of "RegistryModelContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/list.json + // this example is just showing the usage of "RegistryModelContainers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +117,22 @@ public async Task Exists_GetRegistryModelContainer() // get the collection of this MachineLearningRegistryModelContainerResource MachineLearningRegistryModelContainerCollection collection = machineLearningRegistry.GetMachineLearningRegistryModelContainers(); - // invoke the operation - string modelName = "testContainer"; - bool result = await collection.ExistsAsync(modelName); + // invoke the operation and iterate over the result + await foreach (MachineLearningRegistryModelContainerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelContainerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryModelContainer() + public async Task Exists_GetRegistryModelContainer() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/get.json // this example is just showing the usage of "RegistryModelContainers_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +155,17 @@ public async Task GetIfExists_GetRegistryModelContainer() // invoke the operation string modelName = "testContainer"; - NullableResponse response = await collection.GetIfExistsAsync(modelName); - MachineLearningRegistryModelContainerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(modelName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryModelContainer() + public async Task GetIfExists_GetRegistryModelContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/createOrUpdate.json - // this example is just showing the usage of "RegistryModelContainers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/get.json + // this example is just showing the usage of "RegistryModelContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,23 +185,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryModelContainer() // invoke the operation string modelName = "testContainer"; - MachineLearningModelContainerData data = new MachineLearningModelContainerData(new MachineLearningModelContainerProperties() - { - Description = "Model container description", - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, modelName, data); - MachineLearningRegistryModelContainerResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(modelName); + MachineLearningRegistryModelContainerResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelContainerResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelContainerResource.cs index 0c6ae28111389..e3a418512c64b 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelContainerResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelContainerResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryModelContainerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistryModelContainer() + public async Task Get_GetRegistryModelContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/delete.json - // this example is just showing the usage of "RegistryModelContainers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/get.json + // this example is just showing the usage of "RegistryModelContainers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteRegistryModelContainer() MachineLearningRegistryModelContainerResource machineLearningRegistryModelContainer = client.GetMachineLearningRegistryModelContainerResource(machineLearningRegistryModelContainerResourceId); // invoke the operation - await machineLearningRegistryModelContainer.DeleteAsync(WaitUntil.Completed); + MachineLearningRegistryModelContainerResource result = await machineLearningRegistryModelContainer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelContainerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryModelContainer() + public async Task Delete_DeleteRegistryModelContainer() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/get.json - // this example is just showing the usage of "RegistryModelContainers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelContainer/delete.json + // this example is just showing the usage of "RegistryModelContainers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetRegistryModelContainer() MachineLearningRegistryModelContainerResource machineLearningRegistryModelContainer = client.GetMachineLearningRegistryModelContainerResource(machineLearningRegistryModelContainerResourceId); // invoke the operation - MachineLearningRegistryModelContainerResource result = await machineLearningRegistryModelContainer.GetAsync(); + await machineLearningRegistryModelContainer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelContainerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,13 +96,13 @@ public async Task Update_CreateOrUpdateRegistryModelContainer() MachineLearningRegistryModelContainerResource machineLearningRegistryModelContainer = client.GetMachineLearningRegistryModelContainerResource(machineLearningRegistryModelContainerResourceId); // invoke the operation - MachineLearningModelContainerData data = new MachineLearningModelContainerData(new MachineLearningModelContainerProperties() + MachineLearningModelContainerData data = new MachineLearningModelContainerData(new MachineLearningModelContainerProperties { Description = "Model container description", Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }); ArmOperation lro = await machineLearningRegistryModelContainer.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelVersionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelVersionCollection.cs index d8cfc1e3e66ef..ab6eada75102e 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelVersionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelVersionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryModelVersionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRegistryModelVersion() + public async Task CreateOrUpdate_CreateOrUpdateRegistryModelVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/list.json - // this example is just showing the usage of "RegistryModelVersions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/createOrUpdate.json + // this example is just showing the usage of "RegistryModelVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,18 +40,41 @@ public async Task GetAll_ListRegistryModelVersion() // get the collection of this MachineLearningRegistryModelVersionResource MachineLearningRegistryModelVersionCollection collection = machineLearningRegistryModelContainer.GetMachineLearningRegistryModelVersions(); - // invoke the operation and iterate over the result - MachineLearningRegistryModelVersionCollectionGetAllOptions options = new MachineLearningRegistryModelVersionCollectionGetAllOptions() { OrderBy = "string", Top = 1, Version = "string", Description = "string", Tags = "string", Properties = "string" }; - await foreach (MachineLearningRegistryModelVersionResource item in collection.GetAllAsync(options)) + // invoke the operation + string version = "string"; + MachineLearningModelVersionData data = new MachineLearningModelVersionData(new MachineLearningModelVersionProperties { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Flavors = +{ +["string"] = new MachineLearningFlavorData +{ +Data = +{ +["string"] = "string" +}, +} +}, + ModelType = "CustomModel", + ModelUri = new Uri("string"), + IsAnonymous = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningRegistryModelVersionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +114,10 @@ public async Task Get_GetRegistryModelVersion() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistryModelVersion() + public async Task GetAll_ListRegistryModelVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/get.json - // this example is just showing the usage of "RegistryModelVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/list.json + // this example is just showing the usage of "RegistryModelVersions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +136,23 @@ public async Task Exists_GetRegistryModelVersion() // get the collection of this MachineLearningRegistryModelVersionResource MachineLearningRegistryModelVersionCollection collection = machineLearningRegistryModelContainer.GetMachineLearningRegistryModelVersions(); - // invoke the operation - string version = "string"; - bool result = await collection.ExistsAsync(version); + // invoke the operation and iterate over the result + MachineLearningRegistryModelVersionCollectionGetAllOptions options = new MachineLearningRegistryModelVersionCollectionGetAllOptions { OrderBy = "string", Top = 1, Version = "string", Description = "string", Tags = "string", Properties = "string" }; + await foreach (MachineLearningRegistryModelVersionResource item in collection.GetAllAsync(options)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistryModelVersion() + public async Task Exists_GetRegistryModelVersion() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/get.json // this example is just showing the usage of "RegistryModelVersions_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +176,17 @@ public async Task GetIfExists_GetRegistryModelVersion() // invoke the operation string version = "string"; - NullableResponse response = await collection.GetIfExistsAsync(version); - MachineLearningRegistryModelVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(version); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRegistryModelVersion() + public async Task GetIfExists_GetRegistryModelVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/createOrUpdate.json - // this example is just showing the usage of "RegistryModelVersions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/get.json + // this example is just showing the usage of "RegistryModelVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,39 +207,21 @@ public async Task CreateOrUpdate_CreateOrUpdateRegistryModelVersion() // invoke the operation string version = "string"; - MachineLearningModelVersionData data = new MachineLearningModelVersionData(new MachineLearningModelVersionProperties() - { - Flavors = -{ -["string"] = new MachineLearningFlavorData() -{ -Data = -{ -["string"] = "string", -}, -}, -}, - ModelType = "CustomModel", - ModelUri = new Uri("string"), - IsAnonymous = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, version, data); - MachineLearningRegistryModelVersionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(version); + MachineLearningRegistryModelVersionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelVersionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelVersionResource.cs index 1780806e3afca..ae01f8cdce142 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelVersionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryModelVersionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningRegistryModelVersionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistryModelVersion() + public async Task Get_GetRegistryModelVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/delete.json - // this example is just showing the usage of "RegistryModelVersions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/get.json + // this example is just showing the usage of "RegistryModelVersions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteRegistryModelVersion() MachineLearningRegistryModelVersionResource machineLearningRegistryModelVersion = client.GetMachineLearningRegistryModelVersionResource(machineLearningRegistryModelVersionResourceId); // invoke the operation - await machineLearningRegistryModelVersion.DeleteAsync(WaitUntil.Completed); + MachineLearningRegistryModelVersionResource result = await machineLearningRegistryModelVersion.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningModelVersionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryModelVersion() + public async Task Delete_DeleteRegistryModelVersion() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/get.json - // this example is just showing the usage of "RegistryModelVersions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registry/ModelVersion/delete.json + // this example is just showing the usage of "RegistryModelVersions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetRegistryModelVersion() MachineLearningRegistryModelVersionResource machineLearningRegistryModelVersion = client.GetMachineLearningRegistryModelVersionResource(machineLearningRegistryModelVersionResourceId); // invoke the operation - MachineLearningRegistryModelVersionResource result = await machineLearningRegistryModelVersion.GetAsync(); + await machineLearningRegistryModelVersion.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningModelVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,17 +99,17 @@ public async Task Update_CreateOrUpdateRegistryModelVersion() MachineLearningRegistryModelVersionResource machineLearningRegistryModelVersion = client.GetMachineLearningRegistryModelVersionResource(machineLearningRegistryModelVersionResourceId); // invoke the operation - MachineLearningModelVersionData data = new MachineLearningModelVersionData(new MachineLearningModelVersionProperties() + MachineLearningModelVersionData data = new MachineLearningModelVersionData(new MachineLearningModelVersionProperties { Flavors = { -["string"] = new MachineLearningFlavorData() +["string"] = new MachineLearningFlavorData { Data = { -["string"] = "string", -}, +["string"] = "string" }, +} }, ModelType = "CustomModel", ModelUri = new Uri("string"), @@ -117,11 +117,11 @@ public async Task Update_CreateOrUpdateRegistryModelVersion() Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningRegistryModelVersion.UpdateAsync(WaitUntil.Completed, data); @@ -157,7 +157,7 @@ public async Task CreateOrGetStartPendingUpload_CreateOrGetStartPendingUploadReg MachineLearningRegistryModelVersionResource machineLearningRegistryModelVersion = client.GetMachineLearningRegistryModelVersionResource(machineLearningRegistryModelVersionResourceId); // invoke the operation - PendingUploadRequestDto body = new PendingUploadRequestDto() + PendingUploadRequestDto body = new PendingUploadRequestDto { PendingUploadId = "string", PendingUploadType = PendingUploadType.TemporaryBlobReference, diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryResource.cs index 4b801b396d961..ed2dd89089629 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningRegistryResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.MachineLearning.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MachineLearning.Samples @@ -20,74 +19,10 @@ public partial class Sample_MachineLearningRegistryResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetBlobReferenceSasRegistryDataReference_GetBlobReferenceSASDataReference() - { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/DataReference/getBlobReferenceSAS.json - // this example is just showing the usage of "RegistryDataReferences_GetBlobReferenceSas" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MachineLearningRegistryResource created on azure - // for more information of creating MachineLearningRegistryResource, please refer to the document of MachineLearningRegistryResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "test-rg"; - string registryName = "registryName"; - ResourceIdentifier machineLearningRegistryResourceId = MachineLearningRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName); - MachineLearningRegistryResource machineLearningRegistry = client.GetMachineLearningRegistryResource(machineLearningRegistryResourceId); - - // invoke the operation - string name = "string"; - string version = "string"; - BlobReferenceSasContent content = new BlobReferenceSasContent() - { - AssetId = "string", - BlobUri = new Uri("https://www.contoso.com/example"), - }; - BlobReferenceSasResult result = await machineLearningRegistry.GetBlobReferenceSasRegistryDataReferenceAsync(name, version, content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMachineLearningRegistries_ListRegistriesBySubscription() - { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/listBySubscription.json - // this example is just showing the usage of "Registries_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MachineLearningRegistryResource item in subscriptionResource.GetMachineLearningRegistriesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningRegistryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRegistry() + public async Task Get_GetRegistryWithSystemCreatedAccounts() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/delete.json - // this example is just showing the usage of "Registries_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-SystemCreated.json + // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,16 +38,20 @@ public async Task Delete_DeleteRegistry() MachineLearningRegistryResource machineLearningRegistry = client.GetMachineLearningRegistryResource(machineLearningRegistryResourceId); // invoke the operation - await machineLearningRegistry.DeleteAsync(WaitUntil.Completed); + MachineLearningRegistryResource result = await machineLearningRegistry.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningRegistryData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryWithSystemCreatedAccounts() + public async Task Get_GetRegistryWithUserCreatedAccounts() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-SystemCreated.json + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-UserCreated.json // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -140,10 +79,10 @@ public async Task Get_GetRegistryWithSystemCreatedAccounts() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistryWithUserCreatedAccounts() + public async Task Delete_DeleteRegistry() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/get-UserCreated.json - // this example is just showing the usage of "Registries_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/delete.json + // this example is just showing the usage of "Registries_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -159,13 +98,9 @@ public async Task Get_GetRegistryWithUserCreatedAccounts() MachineLearningRegistryResource machineLearningRegistry = client.GetMachineLearningRegistryResource(machineLearningRegistryResourceId); // invoke the operation - MachineLearningRegistryResource result = await machineLearningRegistry.GetAsync(); + await machineLearningRegistry.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningRegistryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -189,16 +124,16 @@ public async Task Update_UpdateRegistryWithSystemCreatedAccounts() MachineLearningRegistryResource machineLearningRegistry = client.GetMachineLearningRegistryResource(machineLearningRegistryResourceId); // invoke the operation - MachineLearningRegistryPatch patch = new MachineLearningRegistryPatch() + MachineLearningRegistryPatch patch = new MachineLearningRegistryPatch { Identity = new ManagedServiceIdentity("SystemAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), +[new ResourceIdentifier("string")] = new UserAssignedIdentity() }, }, - Sku = new MachineLearningSkuPatch() + Sku = new MachineLearningSkuPatch { Name = "string", Tier = MachineLearningSkuTier.Basic, @@ -206,9 +141,7 @@ public async Task Update_UpdateRegistryWithSystemCreatedAccounts() Family = "string", Capacity = 1, }, - Tags = -{ -}, + Tags = { }, }; MachineLearningRegistryResource result = await machineLearningRegistry.UpdateAsync(patch); @@ -240,16 +173,16 @@ public async Task Update_UpdateRegistryWithUserCreatedAccounts() MachineLearningRegistryResource machineLearningRegistry = client.GetMachineLearningRegistryResource(machineLearningRegistryResourceId); // invoke the operation - MachineLearningRegistryPatch patch = new MachineLearningRegistryPatch() + MachineLearningRegistryPatch patch = new MachineLearningRegistryPatch { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), +[new ResourceIdentifier("string")] = new UserAssignedIdentity() }, }, - Sku = new MachineLearningSkuPatch() + Sku = new MachineLearningSkuPatch { Name = "string", Tier = MachineLearningSkuTier.Basic, @@ -257,9 +190,7 @@ public async Task Update_UpdateRegistryWithUserCreatedAccounts() Family = "string", Capacity = 1, }, - Tags = -{ -}, + Tags = { }, }; MachineLearningRegistryResource result = await machineLearningRegistry.UpdateAsync(patch); @@ -270,6 +201,39 @@ public async Task Update_UpdateRegistryWithUserCreatedAccounts() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetBlobReferenceSasRegistryDataReference_GetBlobReferenceSASDataReference() + { + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/DataReference/getBlobReferenceSAS.json + // this example is just showing the usage of "RegistryDataReferences_GetBlobReferenceSas" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MachineLearningRegistryResource created on azure + // for more information of creating MachineLearningRegistryResource, please refer to the document of MachineLearningRegistryResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + string resourceGroupName = "test-rg"; + string registryName = "registryName"; + ResourceIdentifier machineLearningRegistryResourceId = MachineLearningRegistryResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, registryName); + MachineLearningRegistryResource machineLearningRegistry = client.GetMachineLearningRegistryResource(machineLearningRegistryResourceId); + + // invoke the operation + string name = "string"; + string version = "string"; + BlobReferenceSasContent content = new BlobReferenceSasContent + { + AssetId = "string", + BlobUri = new Uri("https://www.contoso.com/example"), + }; + BlobReferenceSasResult result = await machineLearningRegistry.GetBlobReferenceSasRegistryDataReferenceAsync(name, version, content); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task RemoveRegions_RemoveRegionsFromRegistry() @@ -297,7 +261,7 @@ public async Task RemoveRegions_RemoveRegionsFromRegistry() { UserAssignedIdentities = { -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), +[new ResourceIdentifier("string")] = new UserAssignedIdentity() }, }, Kind = "string", @@ -312,53 +276,40 @@ public async Task RemoveRegions_RemoveRegionsFromRegistry() IntellectualPropertyPublisher = "string", ManagedResourceId = new ResourceIdentifier("string"), MlFlowRegistryUri = new Uri("string"), - RegistryPrivateEndpointConnections = -{ -new RegistryPrivateEndpointConnection() + RegistryPrivateEndpointConnections = {new RegistryPrivateEndpointConnection { Id = new ResourceIdentifier("string"), Location = new AzureLocation("string"), -GroupIds = -{ -"string" -}, -PrivateEndpoint = new RegistryPrivateEndpoint() +GroupIds = {"string"}, +PrivateEndpoint = new RegistryPrivateEndpoint { SubnetArmId = new ResourceIdentifier("string"), }, -RegistryPrivateLinkServiceConnectionState = new RegistryPrivateLinkServiceConnectionState() +RegistryPrivateLinkServiceConnectionState = new RegistryPrivateLinkServiceConnectionState { ActionsRequired = "string", Description = "string", Status = EndpointServiceConnectionStatus.Approved, }, ProvisioningState = "string", -} -}, +}}, PublicNetworkAccess = "string", - RegionDetails = -{ -new RegistryRegionArmDetails() + RegionDetails = {new RegistryRegionArmDetails { -AcrDetails = +AcrDetails = {new RegistryAcrDetails { -new RegistryAcrDetails() -{ -SystemCreatedAcrAccount = new SystemCreatedAcrAccount() +SystemCreatedAcrAccount = new SystemCreatedAcrAccount { AcrAccountName = "string", AcrAccountSku = "string", ArmResourceId = new ResourceIdentifier("string"), }, ArmResourceId = new ResourceIdentifier("string"), -} -}, +}}, Location = new AzureLocation("string"), -StorageAccountDetails = -{ -new StorageAccountDetails() +StorageAccountDetails = {new StorageAccountDetails { -SystemCreatedStorageAccount = new SystemCreatedStorageAccount() +SystemCreatedStorageAccount = new SystemCreatedStorageAccount { AllowBlobPublicAccess = false, ArmResourceId = new ResourceIdentifier("string"), @@ -367,13 +318,9 @@ public async Task RemoveRegions_RemoveRegionsFromRegistry() StorageAccountType = "string", }, ArmResourceId = new ResourceIdentifier("string"), -} -}, -} -}, - Tags = -{ -}, +}}, +}}, + Tags = { }, }; ArmOperation lro = await machineLearningRegistry.RemoveRegionsAsync(WaitUntil.Completed, data); MachineLearningRegistryResource result = lro.Value; diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningScheduleCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningScheduleCollection.cs index 57da82e429848..d6c8410aef117 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningScheduleCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningScheduleCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MachineLearningScheduleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSchedules() + public async Task CreateOrUpdate_CreateOrUpdateSchedule() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/list.json - // this example is just showing the usage of "Schedules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/createOrUpdate.json + // this example is just showing the usage of "Schedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,38 @@ public async Task GetAll_ListSchedules() // get the collection of this MachineLearningScheduleResource MachineLearningScheduleCollection collection = machineLearningWorkspace.GetMachineLearningSchedules(); - // invoke the operation and iterate over the result - await foreach (MachineLearningScheduleResource item in collection.GetAllAsync()) + // invoke the operation + string name = "string"; + MachineLearningScheduleData data = new MachineLearningScheduleData(new MachineLearningScheduleProperties(new CronTrigger("string") { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningScheduleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + EndTime = "string", + StartTime = "string", + TimeZone = "string", + }, new MachineLearningEndpointScheduleAction(BinaryData.FromObjectAsJson(new Dictionary + { + ["9965593e-526f-4b89-bb36-761138cf2794"] = null + }))) + { + DisplayName = "string", + IsEnabled = false, + Description = "string", + Tags = +{ +["string"] = "string" +}, + Properties = +{ +["string"] = "string" +}, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningScheduleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +110,10 @@ public async Task Get_GetSchedule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSchedule() + public async Task GetAll_ListSchedules() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/get.json - // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/list.json + // this example is just showing the usage of "Schedules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +131,22 @@ public async Task Exists_GetSchedule() // get the collection of this MachineLearningScheduleResource MachineLearningScheduleCollection collection = machineLearningWorkspace.GetMachineLearningSchedules(); - // invoke the operation - string name = "string"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (MachineLearningScheduleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningScheduleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSchedule() + public async Task Exists_GetSchedule() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/get.json // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +169,17 @@ public async Task GetIfExists_GetSchedule() // invoke the operation string name = "string"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningScheduleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateSchedule() + public async Task GetIfExists_GetSchedule() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/createOrUpdate.json - // this example is just showing the usage of "Schedules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/get.json + // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,36 +199,21 @@ public async Task CreateOrUpdate_CreateOrUpdateSchedule() // invoke the operation string name = "string"; - MachineLearningScheduleData data = new MachineLearningScheduleData(new MachineLearningScheduleProperties(new CronTrigger("string") - { - EndTime = "string", - StartTime = "string", - TimeZone = "string", - }, new MachineLearningEndpointScheduleAction(BinaryData.FromObjectAsJson(new Dictionary() + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningScheduleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - ["9965593e-526f-4b89-bb36-761138cf2794"] = null - }))) + Console.WriteLine("Succeeded with null as result"); + } + else { - DisplayName = "string", - IsEnabled = false, - Description = "string", - Tags = -{ -["string"] = "string", -}, - Properties = -{ -["string"] = "string", -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningScheduleResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningScheduleResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningScheduleResource.cs index a8684dfaa8195..66446f46c6d33 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningScheduleResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningScheduleResource.cs @@ -19,10 +19,10 @@ public partial class Sample_MachineLearningScheduleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSchedule() + public async Task Get_GetSchedule() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/delete.json - // this example is just showing the usage of "Schedules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/get.json + // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteSchedule() MachineLearningScheduleResource machineLearningSchedule = client.GetMachineLearningScheduleResource(machineLearningScheduleResourceId); // invoke the operation - await machineLearningSchedule.DeleteAsync(WaitUntil.Completed); + MachineLearningScheduleResource result = await machineLearningSchedule.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningScheduleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSchedule() + public async Task Delete_DeleteSchedule() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/get.json - // this example is just showing the usage of "Schedules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Schedule/delete.json + // this example is just showing the usage of "Schedules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,13 +70,9 @@ public async Task Get_GetSchedule() MachineLearningScheduleResource machineLearningSchedule = client.GetMachineLearningScheduleResource(machineLearningScheduleResourceId); // invoke the operation - MachineLearningScheduleResource result = await machineLearningSchedule.GetAsync(); + await machineLearningSchedule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningScheduleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -102,7 +102,7 @@ public async Task Update_CreateOrUpdateSchedule() EndTime = "string", StartTime = "string", TimeZone = "string", - }, new MachineLearningEndpointScheduleAction(BinaryData.FromObjectAsJson(new Dictionary() + }, new MachineLearningEndpointScheduleAction(BinaryData.FromObjectAsJson(new Dictionary { ["9965593e-526f-4b89-bb36-761138cf2794"] = null }))) @@ -112,11 +112,11 @@ public async Task Update_CreateOrUpdateSchedule() Description = "string", Tags = { -["string"] = "string", +["string"] = "string" }, Properties = { -["string"] = "string", +["string"] = "string" }, }); ArmOperation lro = await machineLearningSchedule.UpdateAsync(WaitUntil.Completed, data); diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningServerlessEndpointCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningServerlessEndpointCollection.cs index 5f4f53e462bdb..0be69f432b0a4 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningServerlessEndpointCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningServerlessEndpointCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MachineLearningServerlessEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceServerlessEndpoint() + public async Task CreateOrUpdate_CreateOrUpdateWorkspaceServerlessEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/list.json - // this example is just showing the usage of "ServerlessEndpoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/createOrUpdate.json + // this example is just showing the usage of "ServerlessEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,39 @@ public async Task GetAll_ListWorkspaceServerlessEndpoint() // get the collection of this MachineLearningServerlessEndpointResource MachineLearningServerlessEndpointCollection collection = machineLearningWorkspace.GetMachineLearningServerlessEndpoints(); - // invoke the operation and iterate over the result - await foreach (MachineLearningServerlessEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string name = "string"; + MachineLearningServerlessEndpointData data = new MachineLearningServerlessEndpointData(new AzureLocation("string"), new ServerlessEndpointProperties(ServerlessInferenceEndpointAuthMode.Key) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningServerlessEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ModelId = "string", + ContentSafetyStatus = ContentSafetyStatus.Enabled, + }) + { + Kind = "string", + Identity = new ManagedServiceIdentity("SystemAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("string")] = new UserAssignedIdentity() +}, + }, + Sku = new MachineLearningSku("string") + { + Tier = MachineLearningSkuTier.Standard, + Size = "string", + Family = "string", + Capacity = 1, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MachineLearningServerlessEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningServerlessEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +111,10 @@ public async Task Get_GetWorkspaceServerlessEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceServerlessEndpoint() + public async Task GetAll_ListWorkspaceServerlessEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/get.json - // this example is just showing the usage of "ServerlessEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/list.json + // this example is just showing the usage of "ServerlessEndpoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +132,22 @@ public async Task Exists_GetWorkspaceServerlessEndpoint() // get the collection of this MachineLearningServerlessEndpointResource MachineLearningServerlessEndpointCollection collection = machineLearningWorkspace.GetMachineLearningServerlessEndpoints(); - // invoke the operation - string name = "string"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (MachineLearningServerlessEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningServerlessEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceServerlessEndpoint() + public async Task Exists_GetWorkspaceServerlessEndpoint() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/get.json // this example is just showing the usage of "ServerlessEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +170,17 @@ public async Task GetIfExists_GetWorkspaceServerlessEndpoint() // invoke the operation string name = "string"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MachineLearningServerlessEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningServerlessEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateWorkspaceServerlessEndpoint() + public async Task GetIfExists_GetWorkspaceServerlessEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/createOrUpdate.json - // this example is just showing the usage of "ServerlessEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/get.json + // this example is just showing the usage of "ServerlessEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,39 +200,21 @@ public async Task CreateOrUpdate_CreateOrUpdateWorkspaceServerlessEndpoint() // invoke the operation string name = "string"; - MachineLearningServerlessEndpointData data = new MachineLearningServerlessEndpointData(new AzureLocation("string"), new ServerlessEndpointProperties(ServerlessInferenceEndpointAuthMode.Key) + NullableResponse response = await collection.GetIfExistsAsync(name); + MachineLearningServerlessEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) { - ModelId = "string", - ContentSafetyStatus = ContentSafetyStatus.Enabled, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Kind = "string", - Identity = new ManagedServiceIdentity("SystemAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("string")] = new UserAssignedIdentity(), -}, - }, - Sku = new MachineLearningSku("string") - { - Tier = MachineLearningSkuTier.Standard, - Size = "string", - Family = "string", - Capacity = 1, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MachineLearningServerlessEndpointResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningServerlessEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningServerlessEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningServerlessEndpointResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningServerlessEndpointResource.cs index 47363c25d611c..a47c890270046 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningServerlessEndpointResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningServerlessEndpointResource.cs @@ -6,7 +6,6 @@ #nullable disable using System; -using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -19,10 +18,10 @@ public partial class Sample_MachineLearningServerlessEndpointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceServerlessEndpoint() + public async Task Get_GetWorkspaceServerlessEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/delete.json - // this example is just showing the usage of "ServerlessEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/get.json + // this example is just showing the usage of "ServerlessEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +38,21 @@ public async Task Delete_DeleteWorkspaceServerlessEndpoint() MachineLearningServerlessEndpointResource machineLearningServerlessEndpoint = client.GetMachineLearningServerlessEndpointResource(machineLearningServerlessEndpointResourceId); // invoke the operation - await machineLearningServerlessEndpoint.DeleteAsync(WaitUntil.Completed); + MachineLearningServerlessEndpointResource result = await machineLearningServerlessEndpoint.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningServerlessEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceServerlessEndpoint() + public async Task Delete_DeleteWorkspaceServerlessEndpoint() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/get.json - // this example is just showing the usage of "ServerlessEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/ServerlessEndpoint/delete.json + // this example is just showing the usage of "ServerlessEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,13 +69,9 @@ public async Task Get_GetWorkspaceServerlessEndpoint() MachineLearningServerlessEndpointResource machineLearningServerlessEndpoint = client.GetMachineLearningServerlessEndpointResource(machineLearningServerlessEndpointResourceId); // invoke the operation - MachineLearningServerlessEndpointResource result = await machineLearningServerlessEndpoint.GetAsync(); + await machineLearningServerlessEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningServerlessEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -97,9 +96,9 @@ public async Task Update_UpdateWorkspaceServerlessEndpoint() MachineLearningServerlessEndpointResource machineLearningServerlessEndpoint = client.GetMachineLearningServerlessEndpointResource(machineLearningServerlessEndpointResourceId); // invoke the operation - MachineLearningServerlessEndpointPatch patch = new MachineLearningServerlessEndpointPatch() + MachineLearningServerlessEndpointPatch patch = new MachineLearningServerlessEndpointPatch { - Sku = new MachineLearningSkuPatch() + Sku = new MachineLearningSkuPatch { Name = "string", Tier = MachineLearningSkuTier.Premium, @@ -107,19 +106,15 @@ public async Task Update_UpdateWorkspaceServerlessEndpoint() Family = "string", Capacity = 1, }, - Identity = new MachineLearningPartialManagedServiceIdentity() + Identity = new MachineLearningPartialManagedServiceIdentity { ManagedServiceIdentityType = "None", UserAssignedIdentities = { -["string"] = BinaryData.FromObjectAsJson(new Dictionary() -{ -}), +["string"] = BinaryData.FromObjectAsJson(new object()) }, }, - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await machineLearningServerlessEndpoint.UpdateAsync(WaitUntil.Completed, patch); MachineLearningServerlessEndpointResource result = lro.Value; diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceCollection.cs index de0e72f8ae04f..2a7892c0b4dd1 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_MachineLearningWorkspaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspace() + public async Task CreateOrUpdate_CreateWorkspace() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/get.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/create.json + // this example is just showing the usage of "Workspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,40 @@ public async Task Get_GetWorkspace() // invoke the operation string workspaceName = "testworkspace"; - MachineLearningWorkspaceResource result = await collection.GetAsync(workspaceName); + MachineLearningWorkspaceData data = new MachineLearningWorkspaceData(new AzureLocation("eastus2euap")) + { + Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testuai")] = new UserAssignedIdentity() +}, + }, + Description = "test description", + FriendlyName = "HelloName", + KeyVault = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.KeyVault/vaults/testkv", + ApplicationInsights = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/microsoft.insights/components/testinsights", + ContainerRegistry = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.ContainerRegistry/registries/testRegistry", + StorageAccount = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/accountcrud-1234/providers/Microsoft.Storage/storageAccounts/testStorageAccount", + Encryption = new MachineLearningEncryptionSetting(MachineLearningEncryptionStatus.Enabled, new MachineLearningEncryptionKeyVaultProperties(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.KeyVault/vaults/testkv"), "https://testkv.vault.azure.net/keys/testkey/aabbccddee112233445566778899aabb") + { + IdentityClientId = "", + }) + { + UserAssignedIdentity = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testuai"), + }, + IsHbiWorkspace = false, + SharedPrivateLinkResources = {new MachineLearningSharedPrivateLinkResource +{ +Name = "testdbresource", +PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.DocumentDB/databaseAccounts/testdbresource/privateLinkResources/Sql"), +GroupId = "Sql", +RequestMessage = "Please approve", +Status = MachineLearningPrivateEndpointServiceConnectionStatus.Approved, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); + MachineLearningWorkspaceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +86,7 @@ public async Task Get_GetWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspace() + public async Task Get_GetWorkspace() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/get.json // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +108,21 @@ public async Task Exists_GetWorkspace() // invoke the operation string workspaceName = "testworkspace"; - bool result = await collection.ExistsAsync(workspaceName); + MachineLearningWorkspaceResource result = await collection.GetAsync(workspaceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningWorkspaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspace() + public async Task GetAll_GetWorkspacesByResourceGroup() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/get.json - // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/listByResourceGroup.json + // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +139,25 @@ public async Task GetIfExists_GetWorkspace() // get the collection of this MachineLearningWorkspaceResource MachineLearningWorkspaceCollection collection = resourceGroupResource.GetMachineLearningWorkspaces(); - // invoke the operation - string workspaceName = "testworkspace"; - NullableResponse response = await collection.GetIfExistsAsync(workspaceName); - MachineLearningWorkspaceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MachineLearningWorkspaceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MachineLearningWorkspaceData resourceData = result.Data; + MachineLearningWorkspaceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateWorkspace() + public async Task Exists_GetWorkspace() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/create.json - // this example is just showing the usage of "Workspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/get.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,57 +176,17 @@ public async Task CreateOrUpdate_CreateWorkspace() // invoke the operation string workspaceName = "testworkspace"; - MachineLearningWorkspaceData data = new MachineLearningWorkspaceData(new AzureLocation("eastus2euap")) - { - Identity = new ManagedServiceIdentity("SystemAssigned,UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testuai")] = new UserAssignedIdentity(), -}, - }, - Description = "test description", - FriendlyName = "HelloName", - KeyVault = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.KeyVault/vaults/testkv", - ApplicationInsights = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/microsoft.insights/components/testinsights", - ContainerRegistry = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.ContainerRegistry/registries/testRegistry", - StorageAccount = "/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/accountcrud-1234/providers/Microsoft.Storage/storageAccounts/testStorageAccount", - Encryption = new MachineLearningEncryptionSetting(MachineLearningEncryptionStatus.Enabled, new MachineLearningEncryptionKeyVaultProperties(new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.KeyVault/vaults/testkv"), "https://testkv.vault.azure.net/keys/testkey/aabbccddee112233445566778899aabb") - { - IdentityClientId = "", - }) - { - UserAssignedIdentity = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testuai"), - }, - IsHbiWorkspace = false, - SharedPrivateLinkResources = -{ -new MachineLearningSharedPrivateLinkResource() -{ -Name = "testdbresource", -PrivateLinkResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/workspace-1234/providers/Microsoft.DocumentDB/databaseAccounts/testdbresource/privateLinkResources/Sql"), -GroupId = "Sql", -RequestMessage = "Please approve", -Status = MachineLearningPrivateEndpointServiceConnectionStatus.Approved, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, workspaceName, data); - MachineLearningWorkspaceResource result = lro.Value; + bool result = await collection.ExistsAsync(workspaceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningWorkspaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetWorkspacesByResourceGroup() + public async Task GetIfExists_GetWorkspace() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/listByResourceGroup.json - // this example is just showing the usage of "Workspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/get.json + // this example is just showing the usage of "Workspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -212,17 +203,23 @@ public async Task GetAll_GetWorkspacesByResourceGroup() // get the collection of this MachineLearningWorkspaceResource MachineLearningWorkspaceCollection collection = resourceGroupResource.GetMachineLearningWorkspaces(); - // invoke the operation and iterate over the result - await foreach (MachineLearningWorkspaceResource item in collection.GetAllAsync()) + // invoke the operation + string workspaceName = "testworkspace"; + NullableResponse response = await collection.GetIfExistsAsync(workspaceName); + MachineLearningWorkspaceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MachineLearningWorkspaceData resourceData = item.Data; + MachineLearningWorkspaceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceConnectionCollection.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceConnectionCollection.cs index 8232448788a4d..528dfa61c9899 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceConnectionCollection.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceConnectionCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_CreateWorkspaceConnection() // invoke the operation string connectionName = "connection-1"; - MachineLearningWorkspaceConnectionData data = new MachineLearningWorkspaceConnectionData(new MachineLearningNoneAuthTypeWorkspaceConnection() + MachineLearningWorkspaceConnectionData data = new MachineLearningWorkspaceConnectionData(new MachineLearningNoneAuthTypeWorkspaceConnection { Category = MachineLearningConnectionCategory.ContainerRegistry, Target = "www.facebook.com", @@ -92,10 +92,10 @@ public async Task Get_GetWorkspaceConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetWorkspaceConnection() + public async Task GetAll_ListWorkspaceConnections() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/get.json - // this example is just showing the usage of "WorkspaceConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/list.json + // this example is just showing the usage of "WorkspaceConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +113,24 @@ public async Task Exists_GetWorkspaceConnection() // get the collection of this MachineLearningWorkspaceConnectionResource MachineLearningWorkspaceConnectionCollection collection = machineLearningWorkspace.GetMachineLearningWorkspaceConnections(); - // invoke the operation - string connectionName = "connection-1"; - bool result = await collection.ExistsAsync(connectionName); + // invoke the operation and iterate over the result + string target = "www.facebook.com"; + string category = "ContainerRegistry"; + await foreach (MachineLearningWorkspaceConnectionResource item in collection.GetAllAsync(target: target, category: category)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningWorkspaceConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetWorkspaceConnection() + public async Task Exists_GetWorkspaceConnection() { // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/get.json // this example is just showing the usage of "WorkspaceConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +153,17 @@ public async Task GetIfExists_GetWorkspaceConnection() // invoke the operation string connectionName = "connection-1"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - MachineLearningWorkspaceConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(connectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningWorkspaceConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListWorkspaceConnections() + public async Task GetIfExists_GetWorkspaceConnection() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/list.json - // this example is just showing the usage of "WorkspaceConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/get.json + // this example is just showing the usage of "WorkspaceConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,19 +181,23 @@ public async Task GetAll_ListWorkspaceConnections() // get the collection of this MachineLearningWorkspaceConnectionResource MachineLearningWorkspaceConnectionCollection collection = machineLearningWorkspace.GetMachineLearningWorkspaceConnections(); - // invoke the operation and iterate over the result - string target = "www.facebook.com"; - string category = "ContainerRegistry"; - await foreach (MachineLearningWorkspaceConnectionResource item in collection.GetAllAsync(target: target, category: category)) + // invoke the operation + string connectionName = "connection-1"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + MachineLearningWorkspaceConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MachineLearningWorkspaceConnectionData resourceData = item.Data; + MachineLearningWorkspaceConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceConnectionResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceConnectionResource.cs index 23cda589990d3..4d376afb27bf1 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceConnectionResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MachineLearningWorkspaceConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateWorkspaceConnection() + public async Task Get_GetWorkspaceConnection() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/create.json - // this example is just showing the usage of "WorkspaceConnections_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/get.json + // this example is just showing the usage of "WorkspaceConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,13 +38,7 @@ public async Task Update_CreateWorkspaceConnection() MachineLearningWorkspaceConnectionResource machineLearningWorkspaceConnection = client.GetMachineLearningWorkspaceConnectionResource(machineLearningWorkspaceConnectionResourceId); // invoke the operation - MachineLearningWorkspaceConnectionData data = new MachineLearningWorkspaceConnectionData(new MachineLearningNoneAuthTypeWorkspaceConnection() - { - Category = MachineLearningConnectionCategory.ContainerRegistry, - Target = "www.facebook.com", - }); - ArmOperation lro = await machineLearningWorkspaceConnection.UpdateAsync(WaitUntil.Completed, data); - MachineLearningWorkspaceConnectionResource result = lro.Value; + MachineLearningWorkspaceConnectionResource result = await machineLearningWorkspaceConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +49,10 @@ public async Task Update_CreateWorkspaceConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetWorkspaceConnection() + public async Task Delete_DeleteWorkspaceConnection() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/get.json - // this example is just showing the usage of "WorkspaceConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/delete.json + // this example is just showing the usage of "WorkspaceConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,21 +69,17 @@ public async Task Get_GetWorkspaceConnection() MachineLearningWorkspaceConnectionResource machineLearningWorkspaceConnection = client.GetMachineLearningWorkspaceConnectionResource(machineLearningWorkspaceConnectionResourceId); // invoke the operation - MachineLearningWorkspaceConnectionResource result = await machineLearningWorkspaceConnection.GetAsync(); + await machineLearningWorkspaceConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningWorkspaceConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteWorkspaceConnection() + public async Task Update_CreateWorkspaceConnection() { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/delete.json - // this example is just showing the usage of "WorkspaceConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/WorkspaceConnection/create.json + // this example is just showing the usage of "WorkspaceConnections_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +96,19 @@ public async Task Delete_DeleteWorkspaceConnection() MachineLearningWorkspaceConnectionResource machineLearningWorkspaceConnection = client.GetMachineLearningWorkspaceConnectionResource(machineLearningWorkspaceConnectionResourceId); // invoke the operation - await machineLearningWorkspaceConnection.DeleteAsync(WaitUntil.Completed); + MachineLearningWorkspaceConnectionData data = new MachineLearningWorkspaceConnectionData(new MachineLearningNoneAuthTypeWorkspaceConnection + { + Category = MachineLearningConnectionCategory.ContainerRegistry, + Target = "www.facebook.com", + }); + ArmOperation lro = await machineLearningWorkspaceConnection.UpdateAsync(WaitUntil.Completed, data); + MachineLearningWorkspaceConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningWorkspaceConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceResource.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceResource.cs index ed5ced4024a79..b027872ad57b9 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceResource.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_MachineLearningWorkspaceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.MachineLearning.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MachineLearning.Samples @@ -94,7 +93,7 @@ public async Task Update_UpdateWorkspace() MachineLearningWorkspaceResource machineLearningWorkspace = client.GetMachineLearningWorkspaceResource(machineLearningWorkspaceResourceId); // invoke the operation - MachineLearningWorkspacePatch patch = new MachineLearningWorkspacePatch() + MachineLearningWorkspacePatch patch = new MachineLearningWorkspacePatch { Description = "new description", FriendlyName = "New friendly name", @@ -131,37 +130,19 @@ public async Task Diagnose_DiagnoseWorkspace() MachineLearningWorkspaceResource machineLearningWorkspace = client.GetMachineLearningWorkspaceResource(machineLearningWorkspaceResourceId); // invoke the operation - MachineLearningWorkspaceDiagnoseContent content = new MachineLearningWorkspaceDiagnoseContent() + MachineLearningWorkspaceDiagnoseContent content = new MachineLearningWorkspaceDiagnoseContent { - Value = new MachineLearningWorkspaceDiagnoseProperties() + Value = new MachineLearningWorkspaceDiagnoseProperties { - Udr = -{ -}, - Nsg = -{ -}, - ResourceLock = -{ -}, - DnsResolution = -{ -}, - StorageAccount = -{ -}, - KeyVault = -{ -}, - ContainerRegistry = -{ -}, - ApplicationInsights = -{ -}, - Others = -{ -}, + Udr = { }, + Nsg = { }, + ResourceLock = { }, + DnsResolution = { }, + StorageAccount = { }, + KeyVault = { }, + ContainerRegistry = { }, + ApplicationInsights = { }, + Others = { }, }, }; ArmOperation lro = await machineLearningWorkspace.DiagnoseAsync(WaitUntil.Completed, content: content); @@ -222,37 +203,6 @@ public async Task ResyncKeys_ResyncWorkspaceKeys() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMachineLearningWorkspaces_GetWorkspacesBySubscription() - { - // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/listBySubscription.json - // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-1111-2222-3333-444444444444"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MachineLearningWorkspaceResource item in subscriptionResource.GetMachineLearningWorkspacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MachineLearningWorkspaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetNotebookAccessToken_ListWorkspaceKeys() @@ -437,7 +387,7 @@ public async Task ProvisionManagedNetworkManagedNetworkProvision_ProvisionManage MachineLearningWorkspaceResource machineLearningWorkspace = client.GetMachineLearningWorkspaceResource(machineLearningWorkspaceResourceId); // invoke the operation - ManagedNetworkProvisionContent content = new ManagedNetworkProvisionContent() + ManagedNetworkProvisionContent content = new ManagedNetworkProvisionContent { IncludeSpark = false, }; diff --git a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index f6df3333f75a0..1a10c85e1ff35 100644 --- a/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/machinelearningservices/Azure.ResourceManager.MachineLearning/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.MachineLearning.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMachineLearningWorkspaces_GetWorkspacesBySubscription() + { + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Workspace/listBySubscription.json + // this example is just showing the usage of "Workspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MachineLearningWorkspaceResource item in subscriptionResource.GetMachineLearningWorkspacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningWorkspaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetMachineLearningUsages_ListUsages() @@ -93,24 +124,21 @@ public async Task UpdateMachineLearningQuotas_UpdateQuotas() // invoke the operation and iterate over the result AzureLocation location = new AzureLocation("eastus"); - MachineLearningQuotaUpdateContent content = new MachineLearningQuotaUpdateContent() + MachineLearningQuotaUpdateContent content = new MachineLearningQuotaUpdateContent { - Value = -{ -new MachineLearningQuotaProperties() + Value = {new MachineLearningQuotaProperties { Id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.MachineLearningServices/workspaces/demo_workspace1/quotas/Standard_DSv2_Family_Cluster_Dedicated_vCPUs", QuotaBasePropertiesType = "Microsoft.MachineLearningServices/workspaces/quotas", Limit = 100L, Unit = MachineLearningQuotaUnit.Count, -},new MachineLearningQuotaProperties() +}, new MachineLearningQuotaProperties { Id = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg/providers/Microsoft.MachineLearningServices/workspaces/demo_workspace2/quotas/Standard_DSv2_Family_Cluster_Dedicated_vCPUs", QuotaBasePropertiesType = "Microsoft.MachineLearningServices/workspaces/quotas", Limit = 200L, Unit = MachineLearningQuotaUnit.Count, -} -}, +}}, }; await foreach (MachineLearningWorkspaceQuotaUpdate item in subscriptionResource.UpdateMachineLearningQuotasAsync(location, content)) { @@ -147,5 +175,36 @@ public async Task GetMachineLearningQuotas_ListWorkspaceQuotasByVMFamily() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMachineLearningRegistries_ListRegistriesBySubscription() + { + // Generated from example definition: specification/machinelearningservices/resource-manager/Microsoft.MachineLearningServices/stable/2024-04-01/examples/Registries/listBySubscription.json + // this example is just showing the usage of "Registries_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-1111-2222-3333-444444444444"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MachineLearningRegistryResource item in subscriptionResource.GetMachineLearningRegistriesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MachineLearningRegistryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceApplyUpdateCollection.cs b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceApplyUpdateCollection.cs index 059a94c987b07..fd2e1b2f05d51 100644 --- a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceApplyUpdateCollection.cs +++ b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceApplyUpdateCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MaintenanceApplyUpdateCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ApplyUpdatesGet() + public async Task CreateOrUpdate_ApplyUpdatesCreateOrUpdateOnlyNoCancellation() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_Get.json - // this example is just showing the usage of "ApplyUpdates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdateOnly_NoCancellation.json + // this example is just showing the usage of "ApplyUpdates_CreateOrUpdateOrCancel" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,8 +43,10 @@ public async Task Get_ApplyUpdatesGet() string providerName = "Microsoft.Compute"; string resourceType = "virtualMachineScaleSets"; string resourceName = "smdtest1"; - string applyUpdateName = "e9b9685d-78e4-44c4-a81c-64a14f9b87b6"; - MaintenanceApplyUpdateResource result = await collection.GetAsync(providerName, resourceType, resourceName, applyUpdateName); + string applyUpdateName = "20230901121200"; + MaintenanceApplyUpdateData data = new MaintenanceApplyUpdateData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerName, resourceType, resourceName, applyUpdateName, data); + MaintenanceApplyUpdateResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +57,10 @@ public async Task Get_ApplyUpdatesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ApplyUpdatesGet() + public async Task CreateOrUpdate_ApplyUpdatesCreateOrUpdateOrCancel() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_Get.json - // this example is just showing the usage of "ApplyUpdates_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdate_CancelMaintenance.json + // this example is just showing the usage of "ApplyUpdates_CreateOrUpdateOrCancel" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,18 +78,27 @@ public async Task Exists_ApplyUpdatesGet() MaintenanceApplyUpdateCollection collection = resourceGroupResource.GetMaintenanceApplyUpdates(); // invoke the operation - string providerName = "Microsoft.Compute"; - string resourceType = "virtualMachineScaleSets"; - string resourceName = "smdtest1"; - string applyUpdateName = "e9b9685d-78e4-44c4-a81c-64a14f9b87b6"; - bool result = await collection.ExistsAsync(providerName, resourceType, resourceName, applyUpdateName); + string providerName = "Microsoft.Maintenance"; + string resourceType = "maintenanceConfigurations"; + string resourceName = "maintenanceConfig1"; + string applyUpdateName = "20230901121200"; + MaintenanceApplyUpdateData data = new MaintenanceApplyUpdateData + { + Status = MaintenanceUpdateStatus.Cancel, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerName, resourceType, resourceName, applyUpdateName, data); + MaintenanceApplyUpdateResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceApplyUpdateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ApplyUpdatesGet() + public async Task Get_ApplyUpdatesGet() { // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_Get.json // this example is just showing the usage of "ApplyUpdates_Get" operation, for the dependent resources, they will have to be created separately. @@ -112,29 +123,21 @@ public async Task GetIfExists_ApplyUpdatesGet() string resourceType = "virtualMachineScaleSets"; string resourceName = "smdtest1"; string applyUpdateName = "e9b9685d-78e4-44c4-a81c-64a14f9b87b6"; - NullableResponse response = await collection.GetIfExistsAsync(providerName, resourceType, resourceName, applyUpdateName); - MaintenanceApplyUpdateResource result = response.HasValue ? response.Value : null; + MaintenanceApplyUpdateResource result = await collection.GetAsync(providerName, resourceType, resourceName, applyUpdateName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceApplyUpdateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceApplyUpdateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApplyUpdatesCreateOrUpdateOnlyNoCancellation() + public async Task Exists_ApplyUpdatesGet() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdateOnly_NoCancellation.json - // this example is just showing the usage of "ApplyUpdates_CreateOrUpdateOrCancel" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_Get.json + // this example is just showing the usage of "ApplyUpdates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -155,24 +158,18 @@ public async Task CreateOrUpdate_ApplyUpdatesCreateOrUpdateOnlyNoCancellation() string providerName = "Microsoft.Compute"; string resourceType = "virtualMachineScaleSets"; string resourceName = "smdtest1"; - string applyUpdateName = "20230901121200"; - MaintenanceApplyUpdateData data = new MaintenanceApplyUpdateData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerName, resourceType, resourceName, applyUpdateName, data); - MaintenanceApplyUpdateResource result = lro.Value; + string applyUpdateName = "e9b9685d-78e4-44c4-a81c-64a14f9b87b6"; + bool result = await collection.ExistsAsync(providerName, resourceType, resourceName, applyUpdateName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceApplyUpdateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApplyUpdatesCreateOrUpdateOrCancel() + public async Task GetIfExists_ApplyUpdatesGet() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdate_CancelMaintenance.json - // this example is just showing the usage of "ApplyUpdates_CreateOrUpdateOrCancel" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_Get.json + // this example is just showing the usage of "ApplyUpdates_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,22 +187,25 @@ public async Task CreateOrUpdate_ApplyUpdatesCreateOrUpdateOrCancel() MaintenanceApplyUpdateCollection collection = resourceGroupResource.GetMaintenanceApplyUpdates(); // invoke the operation - string providerName = "Microsoft.Maintenance"; - string resourceType = "maintenanceConfigurations"; - string resourceName = "maintenanceConfig1"; - string applyUpdateName = "20230901121200"; - MaintenanceApplyUpdateData data = new MaintenanceApplyUpdateData() - { - Status = MaintenanceUpdateStatus.Cancel, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, providerName, resourceType, resourceName, applyUpdateName, data); - MaintenanceApplyUpdateResource result = lro.Value; + string providerName = "Microsoft.Compute"; + string resourceType = "virtualMachineScaleSets"; + string resourceName = "smdtest1"; + string applyUpdateName = "e9b9685d-78e4-44c4-a81c-64a14f9b87b6"; + NullableResponse response = await collection.GetIfExistsAsync(providerName, resourceType, resourceName, applyUpdateName); + MaintenanceApplyUpdateResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceApplyUpdateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceApplyUpdateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceApplyUpdateResource.cs b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceApplyUpdateResource.cs index 925231ab6f0ea..ede8e6ade2cce 100644 --- a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceApplyUpdateResource.cs +++ b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceApplyUpdateResource.cs @@ -10,43 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Maintenance.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Maintenance.Samples { public partial class Sample_MaintenanceApplyUpdateResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApplyUpdatesByParent_ApplyUpdatesGetParent() - { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_GetParent.json - // this example is just showing the usage of "ApplyUpdates_GetParent" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "5b4b650e-28b9-4790-b3ab-ddbd88d727c4"; - string resourceGroupName = "examplerg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation - ResourceGroupResourceGetApplyUpdatesByParentOptions options = new ResourceGroupResourceGetApplyUpdatesByParentOptions(providerName: "Microsoft.Compute", resourceParentType: "virtualMachineScaleSets", resourceParentName: "smdtest1", resourceType: "virtualMachines", resourceName: "smdvm1", applyUpdateName: "e9b9685d-78e4-44c4-a81c-64a14f9b87b6") { }; - MaintenanceApplyUpdateResource result = await resourceGroupResource.GetApplyUpdatesByParentAsync(options); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceApplyUpdateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ApplyUpdatesGet() @@ -139,7 +108,7 @@ public async Task Update_ApplyUpdatesCreateOrUpdateOrCancel() MaintenanceApplyUpdateResource maintenanceApplyUpdate = client.GetMaintenanceApplyUpdateResource(maintenanceApplyUpdateResourceId); // invoke the operation - MaintenanceApplyUpdateData data = new MaintenanceApplyUpdateData() + MaintenanceApplyUpdateData data = new MaintenanceApplyUpdateData { Status = MaintenanceUpdateStatus.Cancel, }; @@ -152,102 +121,5 @@ public async Task Update_ApplyUpdatesCreateOrUpdateOrCancel() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdateApplyUpdateByParent_ApplyUpdatesCreateOrUpdateParent() - { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdateParent.json - // this example is just showing the usage of "ApplyUpdates_CreateOrUpdateParent" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "5b4b650e-28b9-4790-b3ab-ddbd88d727c4"; - string resourceGroupName = "examplerg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation - string providerName = "Microsoft.Compute"; - string resourceParentType = "virtualMachineScaleSets"; - string resourceParentName = "smdtest1"; - string resourceType = "virtualMachines"; - string resourceName = "smdvm1"; - MaintenanceApplyUpdateResource result = await resourceGroupResource.CreateOrUpdateApplyUpdateByParentAsync(providerName, resourceParentType, resourceParentName, resourceType, resourceName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceApplyUpdateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdateApplyUpdate_ApplyUpdatesCreateOrUpdate() - { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdate.json - // this example is just showing the usage of "ApplyUpdates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "5b4b650e-28b9-4790-b3ab-ddbd88d727c4"; - string resourceGroupName = "examplerg"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // invoke the operation - string providerName = "Microsoft.Compute"; - string resourceType = "virtualMachineScaleSets"; - string resourceName = "smdtest1"; - MaintenanceApplyUpdateResource result = await resourceGroupResource.CreateOrUpdateApplyUpdateAsync(providerName, resourceType, resourceName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceApplyUpdateData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMaintenanceApplyUpdates_ApplyUpdatesList() - { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_List.json - // this example is just showing the usage of "ApplyUpdates_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5b4b650e-28b9-4790-b3ab-ddbd88d727c4"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MaintenanceApplyUpdateResource item in subscriptionResource.GetMaintenanceApplyUpdatesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceApplyUpdateData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceConfigurationCollection.cs b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceConfigurationCollection.cs index 40ab339e6eb66..f13e9de08f89c 100644 --- a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceConfigurationCollection.cs +++ b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceConfigurationCollection.cs @@ -7,6 +7,7 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Maintenance.Models; @@ -19,10 +20,10 @@ public partial class Sample_MaintenanceConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MaintenanceConfigurationsGetForResource() + public async Task CreateOrUpdate_MaintenanceConfigurationsCreateOrUpdateForResource() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource.json - // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_CreateOrUpdateForResource.json + // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +42,19 @@ public async Task Get_MaintenanceConfigurationsGetForResource() // invoke the operation string resourceName = "configuration1"; - MaintenanceConfigurationResource result = await collection.GetAsync(resourceName); + MaintenanceConfigurationData data = new MaintenanceConfigurationData(new AzureLocation("westus2")) + { + Namespace = "Microsoft.Maintenance", + MaintenanceScope = MaintenanceScope.OSImage, + Visibility = MaintenanceConfigurationVisibility.Custom, + StartOn = DateTimeOffset.Parse("2020-04-30 08:00"), + ExpireOn = DateTimeOffset.Parse("9999-12-31 00:00"), + Duration = XmlConvert.ToTimeSpan("05:00"), + TimeZone = "Pacific Standard Time", + RecurEvery = "Day", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); + MaintenanceConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +65,7 @@ public async Task Get_MaintenanceConfigurationsGetForResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MaintenanceConfigurationsGetForResource() + public async Task Get_MaintenanceConfigurationsGetForResource() { // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource.json // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,16 +87,20 @@ public async Task Exists_MaintenanceConfigurationsGetForResource() // invoke the operation string resourceName = "configuration1"; - bool result = await collection.ExistsAsync(resourceName); + MaintenanceConfigurationResource result = await collection.GetAsync(resourceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MaintenanceConfigurationsGetForResource() + public async Task Get_MaintenanceConfigurationsGetForResourceGuestOSPatchLinux() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource.json + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchLinux.json // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -103,28 +120,20 @@ public async Task GetIfExists_MaintenanceConfigurationsGetForResource() // invoke the operation string resourceName = "configuration1"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - MaintenanceConfigurationResource result = response.HasValue ? response.Value : null; + MaintenanceConfigurationResource result = await collection.GetAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MaintenanceConfigurationsGetForResourceGuestOSPatchLinux() + public async Task Get_MaintenanceConfigurationsGetForResourceGuestOSPatchWindows() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchLinux.json + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchWindows.json // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -155,10 +164,10 @@ public async Task Get_MaintenanceConfigurationsGetForResourceGuestOSPatchLinux() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_MaintenanceConfigurationsGetForResourceGuestOSPatchLinux() + public async Task GetAll_MaintenanceConfigurationsResourceGroupList() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchLinux.json - // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurationsResourceGroup_List.json + // this example is just showing the usage of "MaintenanceConfigurationsForResourceGroup_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -175,18 +184,24 @@ public async Task Exists_MaintenanceConfigurationsGetForResourceGuestOSPatchLinu // get the collection of this MaintenanceConfigurationResource MaintenanceConfigurationCollection collection = resourceGroupResource.GetMaintenanceConfigurations(); - // invoke the operation - string resourceName = "configuration1"; - bool result = await collection.ExistsAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (MaintenanceConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MaintenanceConfigurationsGetForResourceGuestOSPatchLinux() + public async Task Exists_MaintenanceConfigurationsGetForResource() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchLinux.json + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource.json // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -206,28 +221,16 @@ public async Task GetIfExists_MaintenanceConfigurationsGetForResourceGuestOSPatc // invoke the operation string resourceName = "configuration1"; - NullableResponse response = await collection.GetIfExistsAsync(resourceName); - MaintenanceConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(resourceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_MaintenanceConfigurationsGetForResourceGuestOSPatchWindows() + public async Task Exists_MaintenanceConfigurationsGetForResourceGuestOSPatchLinux() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchWindows.json + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchLinux.json // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -247,13 +250,9 @@ public async Task Get_MaintenanceConfigurationsGetForResourceGuestOSPatchWindows // invoke the operation string resourceName = "configuration1"; - MaintenanceConfigurationResource result = await collection.GetAsync(resourceName); + bool result = await collection.ExistsAsync(resourceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -287,9 +286,9 @@ public async Task Exists_MaintenanceConfigurationsGetForResourceGuestOSPatchWind [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_MaintenanceConfigurationsGetForResourceGuestOSPatchWindows() + public async Task GetIfExists_MaintenanceConfigurationsGetForResource() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchWindows.json + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource.json // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -328,10 +327,10 @@ public async Task GetIfExists_MaintenanceConfigurationsGetForResourceGuestOSPatc [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_MaintenanceConfigurationsCreateOrUpdateForResource() + public async Task GetIfExists_MaintenanceConfigurationsGetForResourceGuestOSPatchLinux() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_CreateOrUpdateForResource.json - // this example is just showing the usage of "MaintenanceConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchLinux.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -350,33 +349,29 @@ public async Task CreateOrUpdate_MaintenanceConfigurationsCreateOrUpdateForResou // invoke the operation string resourceName = "configuration1"; - MaintenanceConfigurationData data = new MaintenanceConfigurationData(new AzureLocation("westus2")) - { - Namespace = "Microsoft.Maintenance", - MaintenanceScope = MaintenanceScope.OSImage, - Visibility = MaintenanceConfigurationVisibility.Custom, - StartOn = DateTimeOffset.Parse("2020-04-30 08:00"), - ExpireOn = DateTimeOffset.Parse("9999-12-31 00:00"), - Duration = TimeSpan.Parse("05:00"), - TimeZone = "Pacific Standard Time", - RecurEvery = "Day", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); - MaintenanceConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + MaintenanceConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_MaintenanceConfigurationsResourceGroupList() + public async Task GetIfExists_MaintenanceConfigurationsGetForResourceGuestOSPatchWindows() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurationsResourceGroup_List.json - // this example is just showing the usage of "MaintenanceConfigurationsForResourceGroup_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_GetForResource_GuestOSPatchWindows.json + // this example is just showing the usage of "MaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -393,17 +388,23 @@ public async Task GetAll_MaintenanceConfigurationsResourceGroupList() // get the collection of this MaintenanceConfigurationResource MaintenanceConfigurationCollection collection = resourceGroupResource.GetMaintenanceConfigurations(); - // invoke the operation and iterate over the result - await foreach (MaintenanceConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string resourceName = "configuration1"; + NullableResponse response = await collection.GetIfExistsAsync(resourceName); + MaintenanceConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MaintenanceConfigurationData resourceData = item.Data; + MaintenanceConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceConfigurationResource.cs b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceConfigurationResource.cs index 8ca11d25f84e9..70df289afbbe2 100644 --- a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceConfigurationResource.cs +++ b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenanceConfigurationResource.cs @@ -7,10 +7,10 @@ using System; using System.Threading.Tasks; +using System.Xml; using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Maintenance.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Maintenance.Samples @@ -161,7 +161,7 @@ public async Task Update_MaintenanceConfigurationsUpdateForResource() Visibility = MaintenanceConfigurationVisibility.Custom, StartOn = DateTimeOffset.Parse("2020-04-30 08:00"), ExpireOn = DateTimeOffset.Parse("9999-12-31 00:00"), - Duration = TimeSpan.Parse("05:00"), + Duration = XmlConvert.ToTimeSpan("05:00"), TimeZone = "Pacific Standard Time", RecurEvery = "Month Third Sunday", }; @@ -173,36 +173,5 @@ public async Task Update_MaintenanceConfigurationsUpdateForResource() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMaintenanceConfigurations_MaintenanceConfigurationsList() - { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_List.json - // this example is just showing the usage of "MaintenanceConfigurations_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "5b4b650e-28b9-4790-b3ab-ddbd88d727c4"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MaintenanceConfigurationResource item in subscriptionResource.GetMaintenanceConfigurationsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenancePublicConfigurationCollection.cs b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenancePublicConfigurationCollection.cs index ffd58d655b80f..b6d7f4a05421f 100644 --- a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenancePublicConfigurationCollection.cs +++ b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_MaintenancePublicConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MaintenancePublicConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PublicMaintenanceConfigurationsList() + public async Task Get_PublicMaintenanceConfigurationsGetForResource() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/PublicMaintenanceConfigurations_List.json - // this example is just showing the usage of "PublicMaintenanceConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/PublicMaintenanceConfigurations_GetForResource.json + // this example is just showing the usage of "PublicMaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_PublicMaintenanceConfigurationsList() // get the collection of this MaintenancePublicConfigurationResource MaintenancePublicConfigurationCollection collection = subscriptionResource.GetMaintenancePublicConfigurations(); - // invoke the operation and iterate over the result - await foreach (MaintenancePublicConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string resourceName = "configuration1"; + MaintenancePublicConfigurationResource result = await collection.GetAsync(resourceName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PublicMaintenanceConfigurationsGetForResource() + public async Task GetAll_PublicMaintenanceConfigurationsList() { - // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/PublicMaintenanceConfigurations_GetForResource.json - // this example is just showing the usage of "PublicMaintenanceConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/PublicMaintenanceConfigurations_List.json + // this example is just showing the usage of "PublicMaintenanceConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +69,17 @@ public async Task Get_PublicMaintenanceConfigurationsGetForResource() // get the collection of this MaintenancePublicConfigurationResource MaintenancePublicConfigurationCollection collection = subscriptionResource.GetMaintenancePublicConfigurations(); - // invoke the operation - string resourceName = "configuration1"; - MaintenancePublicConfigurationResource result = await collection.GetAsync(resourceName); + // invoke the operation and iterate over the result + await foreach (MaintenancePublicConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MaintenanceConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index 22d1f0ffc454d..c70bf0698c4c1 100644 --- a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -45,6 +45,114 @@ public async Task AcknowledgeScheduledEvent_ScheduledEventsAcknowledge() Console.WriteLine($"Succeeded: {result}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApplyUpdatesByParent_ApplyUpdatesGetParent() + { + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_GetParent.json + // this example is just showing the usage of "ApplyUpdates_GetParent" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "5b4b650e-28b9-4790-b3ab-ddbd88d727c4"; + string resourceGroupName = "examplerg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation + string providerName = "Microsoft.Compute"; + string resourceParentType = "virtualMachineScaleSets"; + string resourceParentName = "smdtest1"; + string resourceType = "virtualMachines"; + string resourceName = "smdvm1"; + string applyUpdateName = "e9b9685d-78e4-44c4-a81c-64a14f9b87b6"; + ResourceGroupResourceGetApplyUpdatesByParentOptions options = new ResourceGroupResourceGetApplyUpdatesByParentOptions( + providerName, + resourceParentType, + resourceParentName, + resourceType, + resourceName, + applyUpdateName); + MaintenanceApplyUpdateResource result = await resourceGroupResource.GetApplyUpdatesByParentAsync(options); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceApplyUpdateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdateApplyUpdateByParent_ApplyUpdatesCreateOrUpdateParent() + { + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdateParent.json + // this example is just showing the usage of "ApplyUpdates_CreateOrUpdateParent" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "5b4b650e-28b9-4790-b3ab-ddbd88d727c4"; + string resourceGroupName = "examplerg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation + string providerName = "Microsoft.Compute"; + string resourceParentType = "virtualMachineScaleSets"; + string resourceParentName = "smdtest1"; + string resourceType = "virtualMachines"; + string resourceName = "smdvm1"; + MaintenanceApplyUpdateResource result = await resourceGroupResource.CreateOrUpdateApplyUpdateByParentAsync(providerName, resourceParentType, resourceParentName, resourceType, resourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceApplyUpdateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdateApplyUpdate_ApplyUpdatesCreateOrUpdate() + { + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_CreateOrUpdate.json + // this example is just showing the usage of "ApplyUpdates_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "5b4b650e-28b9-4790-b3ab-ddbd88d727c4"; + string resourceGroupName = "examplerg"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // invoke the operation + string providerName = "Microsoft.Compute"; + string resourceType = "virtualMachineScaleSets"; + string resourceName = "smdtest1"; + MaintenanceApplyUpdateResource result = await resourceGroupResource.CreateOrUpdateApplyUpdateAsync(providerName, resourceType, resourceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceApplyUpdateData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetConfigurationAssignmentByParent_ConfigurationAssignmentsGetParent() @@ -65,7 +173,19 @@ public async Task GetConfigurationAssignmentByParent_ConfigurationAssignmentsGet ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // invoke the operation - ResourceGroupResourceGetConfigurationAssignmentByParentOptions options = new ResourceGroupResourceGetConfigurationAssignmentByParentOptions(providerName: "Microsoft.Compute", resourceParentType: "virtualMachineScaleSets", resourceParentName: "smdtest1", resourceType: "virtualMachines", resourceName: "smdvm1", configurationAssignmentName: "workervmPolicy") { }; + string providerName = "Microsoft.Compute"; + string resourceParentType = "virtualMachineScaleSets"; + string resourceParentName = "smdtest1"; + string resourceType = "virtualMachines"; + string resourceName = "smdvm1"; + string configurationAssignmentName = "workervmPolicy"; + ResourceGroupResourceGetConfigurationAssignmentByParentOptions options = new ResourceGroupResourceGetConfigurationAssignmentByParentOptions( + providerName, + resourceParentType, + resourceParentName, + resourceType, + resourceName, + configurationAssignmentName); MaintenanceConfigurationAssignmentData result = await resourceGroupResource.GetConfigurationAssignmentByParentAsync(options); Console.WriteLine($"Succeeded: {result}"); @@ -91,11 +211,24 @@ public async Task CreateOrUpdateConfigurationAssignmentByParent_ConfigurationAss ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // invoke the operation - ResourceGroupResourceCreateOrUpdateConfigurationAssignmentByParentOptions options = new ResourceGroupResourceCreateOrUpdateConfigurationAssignmentByParentOptions(providerName: "Microsoft.Compute", resourceParentType: "virtualMachineScaleSets", resourceParentName: "smdtest1", resourceType: "virtualMachines", resourceName: "smdvm1", configurationAssignmentName: "workervmPolicy", data: new MaintenanceConfigurationAssignmentData() + string providerName = "Microsoft.Compute"; + string resourceParentType = "virtualMachineScaleSets"; + string resourceParentName = "smdtest1"; + string resourceType = "virtualMachines"; + string resourceName = "smdvm1"; + string configurationAssignmentName = "workervmPolicy"; + MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData { MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/policy1"), - }) - { }; + }; + ResourceGroupResourceCreateOrUpdateConfigurationAssignmentByParentOptions options = new ResourceGroupResourceCreateOrUpdateConfigurationAssignmentByParentOptions( + providerName, + resourceParentType, + resourceParentName, + resourceType, + resourceName, + configurationAssignmentName, + data); MaintenanceConfigurationAssignmentData result = await resourceGroupResource.CreateOrUpdateConfigurationAssignmentByParentAsync(options); Console.WriteLine($"Succeeded: {result}"); @@ -121,7 +254,19 @@ public async Task DeleteConfigurationAssignmentByParent_ConfigurationAssignments ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // invoke the operation - ResourceGroupResourceDeleteConfigurationAssignmentByParentOptions options = new ResourceGroupResourceDeleteConfigurationAssignmentByParentOptions(providerName: "Microsoft.Compute", resourceParentType: "virtualMachineScaleSets", resourceParentName: "smdtest1", resourceType: "virtualMachines", resourceName: "smdvm1", configurationAssignmentName: "workervmConfiguration") { }; + string providerName = "Microsoft.Compute"; + string resourceParentType = "virtualMachineScaleSets"; + string resourceParentName = "smdtest1"; + string resourceType = "virtualMachines"; + string resourceName = "smdvm1"; + string configurationAssignmentName = "workervmConfiguration"; + ResourceGroupResourceDeleteConfigurationAssignmentByParentOptions options = new ResourceGroupResourceDeleteConfigurationAssignmentByParentOptions( + providerName, + resourceParentType, + resourceParentName, + resourceType, + resourceName, + configurationAssignmentName); MaintenanceConfigurationAssignmentData result = await resourceGroupResource.DeleteConfigurationAssignmentByParentAsync(options); Console.WriteLine($"Succeeded: {result}"); @@ -180,7 +325,7 @@ public async Task CreateOrUpdateConfigurationAssignment_ConfigurationAssignments string resourceType = "virtualMachineScaleSets"; string resourceName = "smdtest1"; string configurationAssignmentName = "workervmConfiguration"; - MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData() + MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData { MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), }; @@ -361,31 +506,19 @@ public async Task CreateOrUpdateConfigurationAssignmentByResourceGroup_Configura // invoke the operation string configurationAssignmentName = "workervmConfiguration"; - MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData() + MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData { MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - Filter = new MaintenanceConfigurationAssignmentFilter() + Filter = new MaintenanceConfigurationAssignmentFilter { - ResourceTypes = -{ -new ResourceType("Microsoft.HybridCompute/machines"),new ResourceType("Microsoft.Compute/virtualMachines") -}, - Locations = -{ -new AzureLocation("Japan East"),new AzureLocation("UK South") -}, - TagSettings = new VmTagSettings() + ResourceTypes = { new ResourceType("Microsoft.HybridCompute/machines"), new ResourceType("Microsoft.Compute/virtualMachines") }, + Locations = { new AzureLocation("Japan East"), new AzureLocation("UK South") }, + TagSettings = new VmTagSettings { Tags = { -["tag1"] = new string[] -{ -"tag1Value1","tag1Value2","tag1Value3" -}, -["tag2"] = new string[] -{ -"tag2Value1","tag2Value2","tag2Value3" -}, +["tag1"] = {"tag1Value1", "tag1Value2", "tag1Value3"}, +["tag2"] = {"tag2Value1", "tag2Value2", "tag2Value3"} }, FilterOperator = VmTagOperator.Any, }, @@ -417,31 +550,19 @@ public async Task UpdateConfigurationAssignmentByResourceGroup_ConfigurationAssi // invoke the operation string configurationAssignmentName = "workervmConfiguration"; - MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData() + MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData { MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - Filter = new MaintenanceConfigurationAssignmentFilter() + Filter = new MaintenanceConfigurationAssignmentFilter { - ResourceTypes = -{ -new ResourceType("Microsoft.HybridCompute/machines"),new ResourceType("Microsoft.Compute/virtualMachines") -}, - Locations = -{ -new AzureLocation("Japan East"),new AzureLocation("UK South") -}, - TagSettings = new VmTagSettings() + ResourceTypes = { new ResourceType("Microsoft.HybridCompute/machines"), new ResourceType("Microsoft.Compute/virtualMachines") }, + Locations = { new AzureLocation("Japan East"), new AzureLocation("UK South") }, + TagSettings = new VmTagSettings { Tags = { -["tag1"] = new string[] -{ -"tag1Value1","tag1Value2","tag1Value3" -}, -["tag2"] = new string[] -{ -"tag2Value1","tag2Value2","tag2Value3" -}, +["tag1"] = {"tag1Value1", "tag1Value2", "tag1Value3"}, +["tag2"] = {"tag2Value1", "tag2Value2", "tag2Value3"} }, FilterOperator = VmTagOperator.Any, }, diff --git a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index b8d920ec22c7f..89e689f330637 100644 --- a/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/maintenance/Azure.ResourceManager.Maintenance/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,68 @@ namespace Azure.ResourceManager.Maintenance.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMaintenanceApplyUpdates_ApplyUpdatesList() + { + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/ApplyUpdates_List.json + // this example is just showing the usage of "ApplyUpdates_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5b4b650e-28b9-4790-b3ab-ddbd88d727c4"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MaintenanceApplyUpdateResource item in subscriptionResource.GetMaintenanceApplyUpdatesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceApplyUpdateData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMaintenanceConfigurations_MaintenanceConfigurationsList() + { + // Generated from example definition: specification/maintenance/resource-manager/Microsoft.Maintenance/preview/2023-10-01-preview/examples/MaintenanceConfigurations_List.json + // this example is just showing the usage of "MaintenanceConfigurations_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "5b4b650e-28b9-4790-b3ab-ddbd88d727c4"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MaintenanceConfigurationResource item in subscriptionResource.GetMaintenanceConfigurationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MaintenanceConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetConfigurationAssignmentsBySubscription_ConfigurationAssignmentsResultWithinSubscriptionList() @@ -89,35 +151,20 @@ public async Task CreateOrUpdateConfigurationAssignmentBySubscription_Configurat // invoke the operation string configurationAssignmentName = "workervmConfiguration"; - MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData() + MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData { MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - Filter = new MaintenanceConfigurationAssignmentFilter() + Filter = new MaintenanceConfigurationAssignmentFilter { - ResourceTypes = -{ -new ResourceType("Microsoft.HybridCompute/machines"),new ResourceType("Microsoft.Compute/virtualMachines") -}, - ResourceGroups = -{ -"RG1","RG2" -}, - Locations = -{ -new AzureLocation("Japan East"),new AzureLocation("UK South") -}, - TagSettings = new VmTagSettings() + ResourceTypes = { new ResourceType("Microsoft.HybridCompute/machines"), new ResourceType("Microsoft.Compute/virtualMachines") }, + ResourceGroups = { "RG1", "RG2" }, + Locations = { new AzureLocation("Japan East"), new AzureLocation("UK South") }, + TagSettings = new VmTagSettings { Tags = { -["tag1"] = new string[] -{ -"tag1Value1","tag1Value2","tag1Value3" -}, -["tag2"] = new string[] -{ -"tag2Value1","tag2Value2","tag2Value3" -}, +["tag1"] = {"tag1Value1", "tag1Value2", "tag1Value3"}, +["tag2"] = {"tag2Value1", "tag2Value2", "tag2Value3"} }, FilterOperator = VmTagOperator.Any, }, @@ -148,35 +195,20 @@ public async Task UpdateConfigurationAssignmentBySubscription_ConfigurationAssig // invoke the operation string configurationAssignmentName = "workervmConfiguration"; - MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData() + MaintenanceConfigurationAssignmentData data = new MaintenanceConfigurationAssignmentData { MaintenanceConfigurationId = new ResourceIdentifier("/subscriptions/5b4b650e-28b9-4790-b3ab-ddbd88d727c4/resourcegroups/examplerg/providers/Microsoft.Maintenance/maintenanceConfigurations/configuration1"), - Filter = new MaintenanceConfigurationAssignmentFilter() + Filter = new MaintenanceConfigurationAssignmentFilter { - ResourceTypes = -{ -new ResourceType("Microsoft.HybridCompute/machines"),new ResourceType("Microsoft.Compute/virtualMachines") -}, - ResourceGroups = -{ -"RG1","RG2" -}, - Locations = -{ -new AzureLocation("Japan East"),new AzureLocation("UK South") -}, - TagSettings = new VmTagSettings() + ResourceTypes = { new ResourceType("Microsoft.HybridCompute/machines"), new ResourceType("Microsoft.Compute/virtualMachines") }, + ResourceGroups = { "RG1", "RG2" }, + Locations = { new AzureLocation("Japan East"), new AzureLocation("UK South") }, + TagSettings = new VmTagSettings { Tags = { -["tag1"] = new string[] -{ -"tag1Value1","tag1Value2","tag1Value3" -}, -["tag2"] = new string[] -{ -"tag2Value1","tag2Value2","tag2Value3" -}, +["tag1"] = {"tag1Value1", "tag1Value2", "tag1Value3"}, +["tag2"] = {"tag2Value1", "tag2Value2", "tag2Value3"} }, FilterOperator = VmTagOperator.Any, }, diff --git a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkCollection.cs b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkCollection.cs index 96262fe9c4f29..030a8af915941 100644 --- a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkCollection.cs +++ b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_ManagedNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ManagedNetworksGet() + public async Task CreateOrUpdate_ManagedNetworksPut() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksGet.json - // this example is just showing the usage of "ManagedNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksPut.json + // this example is just showing the usage of "ManagedNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,43 @@ public async Task Get_ManagedNetworksGet() // invoke the operation string managedNetworkName = "myManagedNetwork"; - ManagedNetworkResource result = await collection.GetAsync(managedNetworkName); + ManagedNetworkData data = new ManagedNetworkData(new AzureLocation("eastus")) + { + Scope = new Scope + { + ManagementGroups = {new WritableSubResource +{ +Id = new ResourceIdentifier("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/providers/Microsoft.Management/managementGroups/20000000-0002-0000-0000-000000000000"), +}}, + Subscriptions = {new WritableSubResource +{ +Id = new ResourceIdentifier("subscriptionA"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("subscriptionB"), +}}, + VirtualNetworks = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetB"), +}}, + Subnets = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetC/subnets/subnetA"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetC/subnets/subnetB"), +}}, + }, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedNetworkName, data); + ManagedNetworkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +89,7 @@ public async Task Get_ManagedNetworksGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ManagedNetworksGet() + public async Task Get_ManagedNetworksGet() { // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksGet.json // this example is just showing the usage of "ManagedNetworks_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +111,21 @@ public async Task Exists_ManagedNetworksGet() // invoke the operation string managedNetworkName = "myManagedNetwork"; - bool result = await collection.ExistsAsync(managedNetworkName); + ManagedNetworkResource result = await collection.GetAsync(managedNetworkName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ManagedNetworksGet() + public async Task GetAll_ManagedNetworksListByResourceGroup() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksGet.json - // this example is just showing the usage of "ManagedNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksListByResourceGroup.json + // this example is just showing the usage of "ManagedNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +142,25 @@ public async Task GetIfExists_ManagedNetworksGet() // get the collection of this ManagedNetworkResource ManagedNetworkCollection collection = resourceGroupResource.GetManagedNetworks(); - // invoke the operation - string managedNetworkName = "myManagedNetwork"; - NullableResponse response = await collection.GetIfExistsAsync(managedNetworkName); - ManagedNetworkResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedNetworkResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedNetworkData resourceData = result.Data; + ManagedNetworkData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ManagedNetworksPut() + public async Task Exists_ManagedNetworksGet() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksPut.json - // this example is just showing the usage of "ManagedNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksGet.json + // this example is just showing the usage of "ManagedNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,71 +179,17 @@ public async Task CreateOrUpdate_ManagedNetworksPut() // invoke the operation string managedNetworkName = "myManagedNetwork"; - ManagedNetworkData data = new ManagedNetworkData(new AzureLocation("eastus")) - { - Scope = new Scope() - { - ManagementGroups = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/providers/Microsoft.Management/managementGroups/20000000-0001-0000-0000-000000000000"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/providers/Microsoft.Management/managementGroups/20000000-0002-0000-0000-000000000000"), -} -}, - Subscriptions = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("subscriptionA"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("subscriptionB"), -} -}, - VirtualNetworks = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetB"), -} -}, - Subnets = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetC/subnets/subnetA"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetC/subnets/subnetB"), -} -}, - }, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedNetworkName, data); - ManagedNetworkResource result = lro.Value; + bool result = await collection.ExistsAsync(managedNetworkName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ManagedNetworksListByResourceGroup() + public async Task GetIfExists_ManagedNetworksGet() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksListByResourceGroup.json - // this example is just showing the usage of "ManagedNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksGet.json + // this example is just showing the usage of "ManagedNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,17 +206,23 @@ public async Task GetAll_ManagedNetworksListByResourceGroup() // get the collection of this ManagedNetworkResource ManagedNetworkCollection collection = resourceGroupResource.GetManagedNetworks(); - // invoke the operation and iterate over the result - await foreach (ManagedNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string managedNetworkName = "myManagedNetwork"; + NullableResponse response = await collection.GetIfExistsAsync(managedNetworkName); + ManagedNetworkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedNetworkData resourceData = item.Data; + ManagedNetworkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkGroupCollection.cs b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkGroupCollection.cs index fc8955845aa73..0681c16577b87 100644 --- a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkGroupCollection.cs +++ b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ManagedNetworkGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ManagementNetworkGroupsGet() + public async Task CreateOrUpdate_ManagementNetworkGroupsPut() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsGet.json - // this example is just showing the usage of "ManagedNetworkGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsPut.json + // this example is just showing the usage of "ManagedNetworkGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,24 @@ public async Task Get_ManagementNetworkGroupsGet() // invoke the operation string managedNetworkGroupName = "myManagedNetworkGroup1"; - ManagedNetworkGroupResource result = await collection.GetAsync(managedNetworkGroupName); + ManagedNetworkGroupData data = new ManagedNetworkGroupData + { + ManagementGroups = { }, + Subscriptions = { }, + VirtualNetworks = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetB"), +}}, + Subnets = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA/subnets/subnetA"), +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedNetworkGroupName, data); + ManagedNetworkGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +69,7 @@ public async Task Get_ManagementNetworkGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ManagementNetworkGroupsGet() + public async Task Get_ManagementNetworkGroupsGet() { // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsGet.json // this example is just showing the usage of "ManagedNetworkGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +92,21 @@ public async Task Exists_ManagementNetworkGroupsGet() // invoke the operation string managedNetworkGroupName = "myManagedNetworkGroup1"; - bool result = await collection.ExistsAsync(managedNetworkGroupName); + ManagedNetworkGroupResource result = await collection.GetAsync(managedNetworkGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedNetworkGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ManagementNetworkGroupsGet() + public async Task GetAll_ManagedNetworksGroupsListByManagedNetwork() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsGet.json - // this example is just showing the usage of "ManagedNetworkGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsListByManagedNetwork.json + // this example is just showing the usage of "ManagedNetworkGroups_ListByManagedNetwork" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +124,25 @@ public async Task GetIfExists_ManagementNetworkGroupsGet() // get the collection of this ManagedNetworkGroupResource ManagedNetworkGroupCollection collection = managedNetwork.GetManagedNetworkGroups(); - // invoke the operation - string managedNetworkGroupName = "myManagedNetworkGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(managedNetworkGroupName); - ManagedNetworkGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedNetworkGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedNetworkGroupData resourceData = result.Data; + ManagedNetworkGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ManagementNetworkGroupsPut() + public async Task Exists_ManagementNetworkGroupsGet() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsPut.json - // this example is just showing the usage of "ManagedNetworkGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsGet.json + // this example is just showing the usage of "ManagedNetworkGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,48 +162,17 @@ public async Task CreateOrUpdate_ManagementNetworkGroupsPut() // invoke the operation string managedNetworkGroupName = "myManagedNetworkGroup1"; - ManagedNetworkGroupData data = new ManagedNetworkGroupData() - { - ManagementGroups = -{ -}, - Subscriptions = -{ -}, - VirtualNetworks = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetB"), -} -}, - Subnets = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA/subnets/subnetA"), -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedNetworkGroupName, data); - ManagedNetworkGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(managedNetworkGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedNetworkGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ManagedNetworksGroupsListByManagedNetwork() + public async Task GetIfExists_ManagementNetworkGroupsGet() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsListByManagedNetwork.json - // this example is just showing the usage of "ManagedNetworkGroups_ListByManagedNetwork" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsGet.json + // this example is just showing the usage of "ManagedNetworkGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -206,17 +190,23 @@ public async Task GetAll_ManagedNetworksGroupsListByManagedNetwork() // get the collection of this ManagedNetworkGroupResource ManagedNetworkGroupCollection collection = managedNetwork.GetManagedNetworkGroups(); - // invoke the operation and iterate over the result - await foreach (ManagedNetworkGroupResource item in collection.GetAllAsync()) + // invoke the operation + string managedNetworkGroupName = "myManagedNetworkGroup1"; + NullableResponse response = await collection.GetIfExistsAsync(managedNetworkGroupName); + ManagedNetworkGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedNetworkGroupData resourceData = item.Data; + ManagedNetworkGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkGroupResource.cs b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkGroupResource.cs index f6220d71f428d..b3ed7262ac5b5 100644 --- a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkGroupResource.cs +++ b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkGroupResource.cs @@ -49,10 +49,10 @@ public async Task Get_ManagementNetworkGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ManagementNetworkGroupsPut() + public async Task Delete_ManagementNetworkGroupsDelete() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsPut.json - // this example is just showing the usage of "ManagedNetworkGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsDelete.json + // this example is just showing the usage of "ManagedNetworkGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,48 +69,17 @@ public async Task Update_ManagementNetworkGroupsPut() ManagedNetworkGroupResource managedNetworkGroup = client.GetManagedNetworkGroupResource(managedNetworkGroupResourceId); // invoke the operation - ManagedNetworkGroupData data = new ManagedNetworkGroupData() - { - ManagementGroups = -{ -}, - Subscriptions = -{ -}, - VirtualNetworks = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetB"), -} -}, - Subnets = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA/subnets/subnetA"), -} -}, - }; - ArmOperation lro = await managedNetworkGroup.UpdateAsync(WaitUntil.Completed, data); - ManagedNetworkGroupResource result = lro.Value; + await managedNetworkGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedNetworkGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ManagementNetworkGroupsDelete() + public async Task Update_ManagementNetworkGroupsPut() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsDelete.json - // this example is just showing the usage of "ManagedNetworkGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkGroup/ManagedNetworkGroupsPut.json + // this example is just showing the usage of "ManagedNetworkGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,9 +96,30 @@ public async Task Delete_ManagementNetworkGroupsDelete() ManagedNetworkGroupResource managedNetworkGroup = client.GetManagedNetworkGroupResource(managedNetworkGroupResourceId); // invoke the operation - await managedNetworkGroup.DeleteAsync(WaitUntil.Completed); + ManagedNetworkGroupData data = new ManagedNetworkGroupData + { + ManagementGroups = { }, + Subscriptions = { }, + VirtualNetworks = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetB"), +}}, + Subnets = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/VnetA/subnets/subnetA"), +}}, + }; + ArmOperation lro = await managedNetworkGroup.UpdateAsync(WaitUntil.Completed, data); + ManagedNetworkGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedNetworkGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkPeeringPolicyCollection.cs b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkPeeringPolicyCollection.cs index 429503fd510f7..491d322d05578 100644 --- a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkPeeringPolicyCollection.cs +++ b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkPeeringPolicyCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ManagedNetworkPeeringPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ManagedNetworkPeeringPoliciesGet() + public async Task CreateOrUpdate_ManagedNetworkPeeringPoliciesPut() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesGet.json - // this example is just showing the usage of "ManagedNetworkPeeringPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesPut.json + // this example is just showing the usage of "ManagedNetworkPeeringPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,19 @@ public async Task Get_ManagedNetworkPeeringPoliciesGet() // invoke the operation string managedNetworkPeeringPolicyName = "myHubAndSpoke"; - ManagedNetworkPeeringPolicyResource result = await collection.GetAsync(managedNetworkPeeringPolicyName); + ManagedNetworkPeeringPolicyData data = new ManagedNetworkPeeringPolicyData + { + Properties = new ManagedNetworkPeeringPolicyProperties(ConnectivityType.HubAndSpokeTopology) + { + HubId = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myHubVnet"), + Spokes = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork/managedNetworkGroups/myManagedNetworkGroup1"), +}}, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedNetworkPeeringPolicyName, data); + ManagedNetworkPeeringPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +65,7 @@ public async Task Get_ManagedNetworkPeeringPoliciesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ManagedNetworkPeeringPoliciesGet() + public async Task Get_ManagedNetworkPeeringPoliciesGet() { // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesGet.json // this example is just showing the usage of "ManagedNetworkPeeringPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +88,21 @@ public async Task Exists_ManagedNetworkPeeringPoliciesGet() // invoke the operation string managedNetworkPeeringPolicyName = "myHubAndSpoke"; - bool result = await collection.ExistsAsync(managedNetworkPeeringPolicyName); + ManagedNetworkPeeringPolicyResource result = await collection.GetAsync(managedNetworkPeeringPolicyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedNetworkPeeringPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ManagedNetworkPeeringPoliciesGet() + public async Task GetAll_ManagedNetworkPeeringPoliciesListByManagedNetwork() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesGet.json - // this example is just showing the usage of "ManagedNetworkPeeringPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesListByManagedNetwork.json + // this example is just showing the usage of "ManagedNetworkPeeringPolicies_ListByManagedNetwork" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,31 +120,25 @@ public async Task GetIfExists_ManagedNetworkPeeringPoliciesGet() // get the collection of this ManagedNetworkPeeringPolicyResource ManagedNetworkPeeringPolicyCollection collection = managedNetwork.GetManagedNetworkPeeringPolicies(); - // invoke the operation - string managedNetworkPeeringPolicyName = "myHubAndSpoke"; - NullableResponse response = await collection.GetIfExistsAsync(managedNetworkPeeringPolicyName); - ManagedNetworkPeeringPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedNetworkPeeringPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedNetworkPeeringPolicyData resourceData = result.Data; + ManagedNetworkPeeringPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ManagedNetworkPeeringPoliciesPut() + public async Task Exists_ManagedNetworkPeeringPoliciesGet() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesPut.json - // this example is just showing the usage of "ManagedNetworkPeeringPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesGet.json + // this example is just showing the usage of "ManagedNetworkPeeringPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,36 +158,17 @@ public async Task CreateOrUpdate_ManagedNetworkPeeringPoliciesPut() // invoke the operation string managedNetworkPeeringPolicyName = "myHubAndSpoke"; - ManagedNetworkPeeringPolicyData data = new ManagedNetworkPeeringPolicyData() - { - Properties = new ManagedNetworkPeeringPolicyProperties(ConnectivityType.HubAndSpokeTopology) - { - HubId = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myHubVnet"), - Spokes = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork/managedNetworkGroups/myManagedNetworkGroup1"), -} -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, managedNetworkPeeringPolicyName, data); - ManagedNetworkPeeringPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(managedNetworkPeeringPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedNetworkPeeringPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ManagedNetworkPeeringPoliciesListByManagedNetwork() + public async Task GetIfExists_ManagedNetworkPeeringPoliciesGet() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesListByManagedNetwork.json - // this example is just showing the usage of "ManagedNetworkPeeringPolicies_ListByManagedNetwork" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesGet.json + // this example is just showing the usage of "ManagedNetworkPeeringPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,17 +186,23 @@ public async Task GetAll_ManagedNetworkPeeringPoliciesListByManagedNetwork() // get the collection of this ManagedNetworkPeeringPolicyResource ManagedNetworkPeeringPolicyCollection collection = managedNetwork.GetManagedNetworkPeeringPolicies(); - // invoke the operation and iterate over the result - await foreach (ManagedNetworkPeeringPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string managedNetworkPeeringPolicyName = "myHubAndSpoke"; + NullableResponse response = await collection.GetIfExistsAsync(managedNetworkPeeringPolicyName); + ManagedNetworkPeeringPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedNetworkPeeringPolicyData resourceData = item.Data; + ManagedNetworkPeeringPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkPeeringPolicyResource.cs b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkPeeringPolicyResource.cs index 279a39dc4d727..9965c2d939352 100644 --- a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkPeeringPolicyResource.cs +++ b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkPeeringPolicyResource.cs @@ -50,10 +50,10 @@ public async Task Get_ManagedNetworkPeeringPoliciesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ManagedNetworkPeeringPoliciesPut() + public async Task Delete_ManagedNetworkPeeringPoliciesDelete() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesPut.json - // this example is just showing the usage of "ManagedNetworkPeeringPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesDelete.json + // this example is just showing the usage of "ManagedNetworkPeeringPolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,36 +70,17 @@ public async Task Update_ManagedNetworkPeeringPoliciesPut() ManagedNetworkPeeringPolicyResource managedNetworkPeeringPolicy = client.GetManagedNetworkPeeringPolicyResource(managedNetworkPeeringPolicyResourceId); // invoke the operation - ManagedNetworkPeeringPolicyData data = new ManagedNetworkPeeringPolicyData() - { - Properties = new ManagedNetworkPeeringPolicyProperties(ConnectivityType.HubAndSpokeTopology) - { - HubId = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myHubVnet"), - Spokes = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork/managedNetworkGroups/myManagedNetworkGroup1"), -} -}, - }, - }; - ArmOperation lro = await managedNetworkPeeringPolicy.UpdateAsync(WaitUntil.Completed, data); - ManagedNetworkPeeringPolicyResource result = lro.Value; + await managedNetworkPeeringPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedNetworkPeeringPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ManagedNetworkPeeringPoliciesDelete() + public async Task Update_ManagedNetworkPeeringPoliciesPut() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesDelete.json - // this example is just showing the usage of "ManagedNetworkPeeringPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetworkPeeringPolicy/ManagedNetworkPeeringPoliciesPut.json + // this example is just showing the usage of "ManagedNetworkPeeringPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,9 +97,25 @@ public async Task Delete_ManagedNetworkPeeringPoliciesDelete() ManagedNetworkPeeringPolicyResource managedNetworkPeeringPolicy = client.GetManagedNetworkPeeringPolicyResource(managedNetworkPeeringPolicyResourceId); // invoke the operation - await managedNetworkPeeringPolicy.DeleteAsync(WaitUntil.Completed); + ManagedNetworkPeeringPolicyData data = new ManagedNetworkPeeringPolicyData + { + Properties = new ManagedNetworkPeeringPolicyProperties(ConnectivityType.HubAndSpokeTopology) + { + HubId = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myHubVnet"), + Spokes = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptionB/resourceGroups/myResourceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork/managedNetworkGroups/myManagedNetworkGroup1"), +}}, + }, + }; + ArmOperation lro = await managedNetworkPeeringPolicy.UpdateAsync(WaitUntil.Completed, data); + ManagedNetworkPeeringPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedNetworkPeeringPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkResource.cs b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkResource.cs index 3435c6ca32c2d..149280acc5364 100644 --- a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkResource.cs +++ b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ManagedNetworkResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetwork.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetwork.Samples @@ -94,11 +93,9 @@ public async Task Update_ManagedNetworksPatch() ManagedNetworkResource managedNetwork = client.GetManagedNetworkResource(managedNetworkResourceId); // invoke the operation - ManagedNetworkPatch patch = new ManagedNetworkPatch() + ManagedNetworkPatch patch = new ManagedNetworkPatch { - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await managedNetwork.UpdateAsync(WaitUntil.Completed, patch); ManagedNetworkResource result = lro.Value; @@ -109,36 +106,5 @@ public async Task Update_ManagedNetworksPatch() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetManagedNetworks_ManagedNetworksListBySubscription() - { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksListBySubscription.json - // this example is just showing the usage of "ManagedNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subscriptionA"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ManagedNetworkResource item in subscriptionResource.GetManagedNetworksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ScopeAssignmentCollection.cs b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ScopeAssignmentCollection.cs index 1974a99029a93..5ca691cf0d872 100644 --- a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ScopeAssignmentCollection.cs +++ b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ScopeAssignmentCollection.cs @@ -17,27 +17,28 @@ public partial class Sample_ScopeAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ScopeAssignmentsGet() + public async Task CreateOrUpdate_ScopeAssignmentsPut() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsGet.json - // this example is just showing the usage of "ScopeAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsPut.json + // this example is just showing the usage of "ScopeAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ScopeAssignmentResource string scope = "subscriptions/subscriptionC"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScopeAssignmentCollection collection = client.GetScopeAssignments(scopeId); + ScopeAssignmentCollection collection = client.GetScopeAssignments(new ResourceIdentifier(scope)); // invoke the operation string scopeAssignmentName = "subscriptionCAssignment"; - ScopeAssignmentResource result = await collection.GetAsync(scopeAssignmentName); + ScopeAssignmentData data = new ScopeAssignmentData + { + AssignedManagedNetwork = "/subscriptions/subscriptionA/resourceGroups/myResourceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeAssignmentName, data); + ScopeAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -48,7 +49,7 @@ public async Task Get_ScopeAssignmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ScopeAssignmentsGet() + public async Task Get_ScopeAssignmentsGet() { // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsGet.json // this example is just showing the usage of "ScopeAssignments_Get" operation, for the dependent resources, they will have to be created separately. @@ -58,127 +59,106 @@ public async Task Exists_ScopeAssignmentsGet() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ScopeAssignmentResource string scope = "subscriptions/subscriptionC"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScopeAssignmentCollection collection = client.GetScopeAssignments(scopeId); + ScopeAssignmentCollection collection = client.GetScopeAssignments(new ResourceIdentifier(scope)); // invoke the operation string scopeAssignmentName = "subscriptionCAssignment"; - bool result = await collection.ExistsAsync(scopeAssignmentName); + ScopeAssignmentResource result = await collection.GetAsync(scopeAssignmentName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScopeAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ScopeAssignmentsGet() + public async Task GetAll_ScopeAssignmentsList() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsGet.json - // this example is just showing the usage of "ScopeAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsList.json + // this example is just showing the usage of "ScopeAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ScopeAssignmentResource string scope = "subscriptions/subscriptionC"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScopeAssignmentCollection collection = client.GetScopeAssignments(scopeId); - - // invoke the operation - string scopeAssignmentName = "subscriptionCAssignment"; - NullableResponse response = await collection.GetIfExistsAsync(scopeAssignmentName); - ScopeAssignmentResource result = response.HasValue ? response.Value : null; + ScopeAssignmentCollection collection = client.GetScopeAssignments(new ResourceIdentifier(scope)); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ScopeAssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScopeAssignmentData resourceData = result.Data; + ScopeAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ScopeAssignmentsPut() + public async Task Exists_ScopeAssignmentsGet() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsPut.json - // this example is just showing the usage of "ScopeAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsGet.json + // this example is just showing the usage of "ScopeAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ScopeAssignmentResource string scope = "subscriptions/subscriptionC"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScopeAssignmentCollection collection = client.GetScopeAssignments(scopeId); + ScopeAssignmentCollection collection = client.GetScopeAssignments(new ResourceIdentifier(scope)); // invoke the operation string scopeAssignmentName = "subscriptionCAssignment"; - ScopeAssignmentData data = new ScopeAssignmentData() - { - AssignedManagedNetwork = "/subscriptions/subscriptionA/resourceGroups/myResourceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeAssignmentName, data); - ScopeAssignmentResource result = lro.Value; + bool result = await collection.ExistsAsync(scopeAssignmentName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScopeAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ScopeAssignmentsList() + public async Task GetIfExists_ScopeAssignmentsGet() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsList.json - // this example is just showing the usage of "ScopeAssignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsGet.json + // this example is just showing the usage of "ScopeAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ScopeAssignmentResource string scope = "subscriptions/subscriptionC"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ScopeAssignmentCollection collection = client.GetScopeAssignments(scopeId); + ScopeAssignmentCollection collection = client.GetScopeAssignments(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - await foreach (ScopeAssignmentResource item in collection.GetAllAsync()) + // invoke the operation + string scopeAssignmentName = "subscriptionCAssignment"; + NullableResponse response = await collection.GetIfExistsAsync(scopeAssignmentName); + ScopeAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScopeAssignmentData resourceData = item.Data; + ScopeAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ScopeAssignmentResource.cs b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ScopeAssignmentResource.cs index c582cc4fec929..1386395fc56fe 100644 --- a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ScopeAssignmentResource.cs +++ b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_ScopeAssignmentResource.cs @@ -46,10 +46,10 @@ public async Task Get_ScopeAssignmentsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ScopeAssignmentsPut() + public async Task Delete_ScopeAssignmentsDelete() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsPut.json - // this example is just showing the usage of "ScopeAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsDelete.json + // this example is just showing the usage of "ScopeAssignments_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,26 +64,17 @@ public async Task Update_ScopeAssignmentsPut() ScopeAssignmentResource scopeAssignment = client.GetScopeAssignmentResource(scopeAssignmentResourceId); // invoke the operation - ScopeAssignmentData data = new ScopeAssignmentData() - { - AssignedManagedNetwork = "/subscriptions/subscriptionA/resourceGroups/myResourceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork", - }; - ArmOperation lro = await scopeAssignment.UpdateAsync(WaitUntil.Completed, data); - ScopeAssignmentResource result = lro.Value; + await scopeAssignment.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScopeAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ScopeAssignmentsDelete() + public async Task Update_ScopeAssignmentsPut() { - // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsDelete.json - // this example is just showing the usage of "ScopeAssignments_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ScopeAssignment/ScopeAssignmentsPut.json + // this example is just showing the usage of "ScopeAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,9 +89,18 @@ public async Task Delete_ScopeAssignmentsDelete() ScopeAssignmentResource scopeAssignment = client.GetScopeAssignmentResource(scopeAssignmentResourceId); // invoke the operation - await scopeAssignment.DeleteAsync(WaitUntil.Completed); + ScopeAssignmentData data = new ScopeAssignmentData + { + AssignedManagedNetwork = "/subscriptions/subscriptionA/resourceGroups/myResourceGroup/providers/Microsoft.ManagedNetwork/managedNetworks/myManagedNetwork", + }; + ArmOperation lro = await scopeAssignment.UpdateAsync(WaitUntil.Completed, data); + ScopeAssignmentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScopeAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..a64b022442e79 --- /dev/null +++ b/sdk/managednetwork/Azure.ResourceManager.ManagedNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ManagedNetwork.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetManagedNetworks_ManagedNetworksListBySubscription() + { + // Generated from example definition: specification/managednetwork/resource-manager/Microsoft.ManagedNetwork/preview/2019-06-01-preview/examples/ManagedNetwork/ManagedNetworksListBySubscription.json + // this example is just showing the usage of "ManagedNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subscriptionA"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ManagedNetworkResource item in subscriptionResource.GetManagedNetworksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceCollection.cs index d443f3cedbe5d..1c10eb5053c09 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceCollection.cs @@ -48,7 +48,7 @@ public async Task CreateOrUpdate_NetworkDevicesCreateMaximumSetGen() NetworkDeviceSku = "DeviceSku", Tags = { -["keyID"] = "KeyValue", +["keyID"] = "KeyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkDeviceName, data); @@ -96,10 +96,10 @@ public async Task Get_NetworkDevicesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkDevicesGetMaximumSetGen() + public async Task GetAll_NetworkDevicesListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkDevices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkDevices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,16 +116,22 @@ public async Task Exists_NetworkDevicesGetMaximumSetGen() // get the collection of this NetworkDeviceResource NetworkDeviceCollection collection = resourceGroupResource.GetNetworkDevices(); - // invoke the operation - string networkDeviceName = "example-device"; - bool result = await collection.ExistsAsync(networkDeviceName); + // invoke the operation and iterate over the result + await foreach (NetworkDeviceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkDeviceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkDevicesGetMaximumSetGen() + public async Task Exists_NetworkDevicesGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkDevices_Get" operation, for the dependent resources, they will have to be created separately. @@ -147,29 +153,17 @@ public async Task GetIfExists_NetworkDevicesGetMaximumSetGen() // invoke the operation string networkDeviceName = "example-device"; - NullableResponse response = await collection.GetIfExistsAsync(networkDeviceName); - NetworkDeviceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkDeviceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkDevicesListByResourceGroupMaximumSetGen() + public async Task GetIfExists_NetworkDevicesGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkDevices_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkDevices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_NetworkDevicesListByResourceGroupMaximumSetGen() // get the collection of this NetworkDeviceResource NetworkDeviceCollection collection = resourceGroupResource.GetNetworkDevices(); - // invoke the operation and iterate over the result - await foreach (NetworkDeviceResource item in collection.GetAllAsync()) + // invoke the operation + string networkDeviceName = "example-device"; + NullableResponse response = await collection.GetIfExistsAsync(networkDeviceName); + NetworkDeviceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkDeviceData resourceData = item.Data; + NetworkDeviceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceInterfaceCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceInterfaceCollection.cs index ec2e1af69e122..7ab996b194a58 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceInterfaceCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceInterfaceCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_NetworkInterfacesCreateMaximumSetGen() // invoke the operation string networkInterfaceName = "example-interface"; - NetworkDeviceInterfaceData data = new NetworkDeviceInterfaceData() + NetworkDeviceInterfaceData data = new NetworkDeviceInterfaceData { Annotation = "annotation", }; @@ -90,10 +90,10 @@ public async Task Get_NetworkInterfacesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkInterfacesGetMaximumSetGen() + public async Task GetAll_NetworkInterfacesListByNetworkDeviceMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkInterfaces_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkInterfaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkInterfaces_ListByNetworkDevice_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkInterfaces_ListByNetworkDevice" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +111,22 @@ public async Task Exists_NetworkInterfacesGetMaximumSetGen() // get the collection of this NetworkDeviceInterfaceResource NetworkDeviceInterfaceCollection collection = networkDevice.GetNetworkDeviceInterfaces(); - // invoke the operation - string networkInterfaceName = "example-interface"; - bool result = await collection.ExistsAsync(networkInterfaceName); + // invoke the operation and iterate over the result + await foreach (NetworkDeviceInterfaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkDeviceInterfaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkInterfacesGetMaximumSetGen() + public async Task Exists_NetworkInterfacesGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkInterfaces_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkInterfaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,29 +149,17 @@ public async Task GetIfExists_NetworkInterfacesGetMaximumSetGen() // invoke the operation string networkInterfaceName = "example-interface"; - NullableResponse response = await collection.GetIfExistsAsync(networkInterfaceName); - NetworkDeviceInterfaceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkInterfaceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkDeviceInterfaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkInterfacesListByNetworkDeviceMaximumSetGen() + public async Task GetIfExists_NetworkInterfacesGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkInterfaces_ListByNetworkDevice_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkInterfaces_ListByNetworkDevice" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkInterfaces_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkInterfaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_NetworkInterfacesListByNetworkDeviceMaximumSetGen() // get the collection of this NetworkDeviceInterfaceResource NetworkDeviceInterfaceCollection collection = networkDevice.GetNetworkDeviceInterfaces(); - // invoke the operation and iterate over the result - await foreach (NetworkDeviceInterfaceResource item in collection.GetAllAsync()) + // invoke the operation + string networkInterfaceName = "example-interface"; + NullableResponse response = await collection.GetIfExistsAsync(networkInterfaceName); + NetworkDeviceInterfaceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkDeviceInterfaceData resourceData = item.Data; + NetworkDeviceInterfaceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceInterfaceResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceInterfaceResource.cs index 118ce13d15605..504d68fd0d946 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceInterfaceResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceInterfaceResource.cs @@ -49,10 +49,10 @@ public async Task Get_NetworkInterfacesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NetworkInterfacesUpdateMaximumSetGen() + public async Task Delete_NetworkInterfacesDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkInterfaces_Update_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkInterfaces_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkInterfaces_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkInterfaces_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -61,34 +61,25 @@ public async Task Update_NetworkInterfacesUpdateMaximumSetGen() // this example assumes you already have this NetworkDeviceInterfaceResource created on azure // for more information of creating NetworkDeviceInterfaceResource, please refer to the document of NetworkDeviceInterfaceResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string networkDeviceName = "example-device"; - string networkInterfaceName = "example-interface"; + string subscriptionId = "94D0FD57-C08B-4CA3-A926-6B76D8B7B956"; + string resourceGroupName = "rgNetworkDevices"; + string networkDeviceName = "sjzd"; + string networkInterfaceName = "emrgu"; ResourceIdentifier networkDeviceInterfaceResourceId = NetworkDeviceInterfaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkDeviceName, networkInterfaceName); NetworkDeviceInterfaceResource networkDeviceInterface = client.GetNetworkDeviceInterfaceResource(networkDeviceInterfaceResourceId); // invoke the operation - NetworkDeviceInterfacePatch patch = new NetworkDeviceInterfacePatch() - { - Annotation = "annotation", - }; - ArmOperation lro = await networkDeviceInterface.UpdateAsync(WaitUntil.Completed, patch); - NetworkDeviceInterfaceResource result = lro.Value; + await networkDeviceInterface.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkDeviceInterfaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkInterfacesDeleteMaximumSetGen() + public async Task Update_NetworkInterfacesUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkInterfaces_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkInterfaces_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkInterfaces_Update_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkInterfaces_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,17 +88,26 @@ public async Task Delete_NetworkInterfacesDeleteMaximumSetGen() // this example assumes you already have this NetworkDeviceInterfaceResource created on azure // for more information of creating NetworkDeviceInterfaceResource, please refer to the document of NetworkDeviceInterfaceResource - string subscriptionId = "94D0FD57-C08B-4CA3-A926-6B76D8B7B956"; - string resourceGroupName = "rgNetworkDevices"; - string networkDeviceName = "sjzd"; - string networkInterfaceName = "emrgu"; + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string networkDeviceName = "example-device"; + string networkInterfaceName = "example-interface"; ResourceIdentifier networkDeviceInterfaceResourceId = NetworkDeviceInterfaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkDeviceName, networkInterfaceName); NetworkDeviceInterfaceResource networkDeviceInterface = client.GetNetworkDeviceInterfaceResource(networkDeviceInterfaceResourceId); // invoke the operation - await networkDeviceInterface.DeleteAsync(WaitUntil.Completed); + NetworkDeviceInterfacePatch patch = new NetworkDeviceInterfacePatch + { + Annotation = "annotation", + }; + ArmOperation lro = await networkDeviceInterface.UpdateAsync(WaitUntil.Completed, patch); + NetworkDeviceInterfaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkDeviceInterfaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -132,13 +132,10 @@ public async Task UpdateAdministrativeState_NetworkInterfacesUpdateAdministrativ NetworkDeviceInterfaceResource networkDeviceInterface = client.GetNetworkDeviceInterfaceResource(networkDeviceInterfaceResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkDeviceInterface.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceResource.cs index e4f8a321d66b0..072a39012b6c1 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -49,10 +48,10 @@ public async Task Get_NetworkDevicesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NetworkDevicesUpdateMaximumSetGen() + public async Task Delete_NetworkDevicesDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_Update_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkDevices_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkDevices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,32 +67,17 @@ public async Task Update_NetworkDevicesUpdateMaximumSetGen() NetworkDeviceResource networkDevice = client.GetNetworkDeviceResource(networkDeviceResourceId); // invoke the operation - NetworkDevicePatch patch = new NetworkDevicePatch() - { - Annotation = "annotation", - HostName = "NFA-Device", - SerialNumber = "Vendor;DCS-7280XXX-24;12.05;JPE2111XXXX", - Tags = -{ -["keyID"] = "KeyValue", -}, - }; - ArmOperation lro = await networkDevice.UpdateAsync(WaitUntil.Completed, patch); - NetworkDeviceResource result = lro.Value; + await networkDevice.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkDeviceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkDevicesDeleteMaximumSetGen() + public async Task Update_NetworkDevicesUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkDevices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_Update_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkDevices_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,40 +93,24 @@ public async Task Delete_NetworkDevicesDeleteMaximumSetGen() NetworkDeviceResource networkDevice = client.GetNetworkDeviceResource(networkDeviceResourceId); // invoke the operation - await networkDevice.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkDevices_NetworkDevicesListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkDevices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkDeviceResource item in subscriptionResource.GetNetworkDevicesAsync()) + NetworkDevicePatch patch = new NetworkDevicePatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkDeviceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Annotation = "annotation", + HostName = "NFA-Device", + SerialNumber = "Vendor;DCS-7280XXX-24;12.05;JPE2111XXXX", + Tags = +{ +["keyID"] = "KeyValue" +}, + }; + ArmOperation lro = await networkDevice.UpdateAsync(WaitUntil.Completed, patch); + NetworkDeviceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkDeviceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -166,7 +134,7 @@ public async Task Reboot_NetworkDevicesRebootMaximumSetGen() NetworkDeviceResource networkDevice = client.GetNetworkDeviceResource(networkDeviceResourceId); // invoke the operation - NetworkDeviceRebootContent content = new NetworkDeviceRebootContent() + NetworkDeviceRebootContent content = new NetworkDeviceRebootContent { RebootType = NetworkDeviceRebootType.GracefulRebootWithZtp, }; @@ -224,13 +192,10 @@ public async Task UpdateAdministrativeState_NetworkDevicesUpdateAdministrativeSt NetworkDeviceResource networkDevice = client.GetNetworkDeviceResource(networkDeviceResourceId); // invoke the operation - UpdateDeviceAdministrativeStateContent content = new UpdateDeviceAdministrativeStateContent() + UpdateDeviceAdministrativeStateContent content = new UpdateDeviceAdministrativeStateContent { State = NetworkDeviceAdministrativeState.Rma, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkDevice.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; @@ -259,7 +224,7 @@ public async Task Upgrade_NetworkDevicesUpgradeMaximumSetGen() NetworkDeviceResource networkDevice = client.GetNetworkDeviceResource(networkDeviceResourceId); // invoke the operation - NetworkFabricUpdateVersionContent content = new NetworkFabricUpdateVersionContent() + NetworkFabricUpdateVersionContent content = new NetworkFabricUpdateVersionContent { Version = "1.0.0", }; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceSkuCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceSkuCollection.cs index c372e2cf2e7f5..ba31c9a389a27 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceSkuCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkDeviceSkuCollection.cs @@ -50,10 +50,10 @@ public async Task Get_NetworkDeviceSkusGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkDeviceSkusGetMaximumSetGen() + public async Task GetAll_NetworkDeviceSkusListBySubscriptionMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDeviceSkus_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkDeviceSkus_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDeviceSkus_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkDeviceSkus_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +69,22 @@ public async Task Exists_NetworkDeviceSkusGetMaximumSetGen() // get the collection of this NetworkDeviceSkuResource NetworkDeviceSkuCollection collection = subscriptionResource.GetNetworkDeviceSkus(); - // invoke the operation - string networkDeviceSkuName = "example-deviceSku"; - bool result = await collection.ExistsAsync(networkDeviceSkuName); + // invoke the operation and iterate over the result + await foreach (NetworkDeviceSkuResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkDeviceSkuData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkDeviceSkusGetMaximumSetGen() + public async Task Exists_NetworkDeviceSkusGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDeviceSkus_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkDeviceSkus_Get" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +105,17 @@ public async Task GetIfExists_NetworkDeviceSkusGetMaximumSetGen() // invoke the operation string networkDeviceSkuName = "example-deviceSku"; - NullableResponse response = await collection.GetIfExistsAsync(networkDeviceSkuName); - NetworkDeviceSkuResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkDeviceSkuName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkDeviceSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkDeviceSkusListBySubscriptionMaximumSetGen() + public async Task GetIfExists_NetworkDeviceSkusGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDeviceSkus_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkDeviceSkus_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDeviceSkus_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkDeviceSkus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,17 +131,23 @@ public async Task GetAll_NetworkDeviceSkusListBySubscriptionMaximumSetGen() // get the collection of this NetworkDeviceSkuResource NetworkDeviceSkuCollection collection = subscriptionResource.GetNetworkDeviceSkus(); - // invoke the operation and iterate over the result - await foreach (NetworkDeviceSkuResource item in collection.GetAllAsync()) + // invoke the operation + string networkDeviceSkuName = "example-deviceSku"; + NullableResponse response = await collection.GetIfExistsAsync(networkDeviceSkuName); + NetworkDeviceSkuResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkDeviceSkuData resourceData = item.Data; + NetworkDeviceSkuData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricAccessControlListCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricAccessControlListCollection.cs index 6bbcac1c555cf..ac06471798769 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricAccessControlListCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricAccessControlListCollection.cs @@ -47,140 +47,68 @@ public async Task CreateOrUpdate_AccessControlListsCreateMaximumSetGen() ConfigurationType = NetworkFabricConfigurationType.File, AclsUri = new Uri("https://ACL-Storage-URL"), DefaultAction = CommunityActionType.Permit, - MatchConfigurations = -{ -new AccessControlListMatchConfiguration() + MatchConfigurations = {new AccessControlListMatchConfiguration { MatchConfigurationName = "example-match", SequenceNumber = 123L, IPAddressType = NetworkFabricIPAddressType.IPv4, -MatchConditions = -{ -new AccessControlListMatchCondition() -{ -EtherTypes = -{ -"0x1" -}, -Fragments = -{ -"0xff00-0xffff" -}, -IPLengths = +MatchConditions = {new AccessControlListMatchCondition { -"4094-9214" -}, -TtlValues = -{ -"23" -}, -DscpMarkings = -{ -"32" -}, +EtherTypes = {"0x1"}, +Fragments = {"0xff00-0xffff"}, +IPLengths = {"4094-9214"}, +TtlValues = {"23"}, +DscpMarkings = {"32"}, PortCondition = new AccessControlListPortCondition(Layer4Protocol.Tcp) { -Flags = -{ -"established" -}, +Flags = {"established"}, PortType = NetworkFabricPortType.SourcePort, -Ports = -{ -"1-20" +Ports = {"1-20"}, +PortGroupNames = {"example-portGroup"}, }, -PortGroupNames = +ProtocolTypes = {"TCP"}, +VlanMatchCondition = new VlanMatchCondition { -"example-portGroup" +Vlans = {"20-30"}, +InnerVlans = {"30"}, +VlanGroupNames = {"example-vlanGroup"}, }, -}, -ProtocolTypes = -{ -"TCP" -}, -VlanMatchCondition = new VlanMatchCondition() -{ -Vlans = -{ -"20-30" -}, -InnerVlans = -{ -"30" -}, -VlanGroupNames = -{ -"example-vlanGroup" -}, -}, -IPCondition = new IPMatchCondition() +IPCondition = new IPMatchCondition { SourceDestinationType = SourceDestinationType.SourceIP, PrefixType = IPMatchConditionPrefixType.Prefix, -IPPrefixValues = -{ -"10.20.20.20/12" +IPPrefixValues = {"10.20.20.20/12"}, +IPGroupNames = {"example-ipGroup"}, }, -IPGroupNames = -{ -"example-ipGroup" -}, -}, -} -}, -Actions = -{ -new AccessControlListAction() +}}, +Actions = {new AccessControlListAction { AclActionType = AclActionType.Count, CounterName = "example-counter", -} -}, -} -}, - DynamicMatchConfigurations = -{ -new CommonDynamicMatchConfiguration() +}}, +}}, + DynamicMatchConfigurations = {new CommonDynamicMatchConfiguration { -IPGroups = -{ -new MatchConfigurationIPGroupProperties() +IPGroups = {new MatchConfigurationIPGroupProperties { Name = "example-ipGroup", IPAddressType = NetworkFabricIPAddressType.IPv4, -IPPrefixes = -{ -"10.20.3.1/20" -}, -} -}, -VlanGroups = -{ -new VlanGroupProperties() +IPPrefixes = {"10.20.3.1/20"}, +}}, +VlanGroups = {new VlanGroupProperties { Name = "example-vlanGroup", -Vlans = -{ -"20-30" -}, -} -}, -PortGroups = -{ -new PortGroupProperties() +Vlans = {"20-30"}, +}}, +PortGroups = {new PortGroupProperties { Name = "example-portGroup", -Ports = -{ -"100-200" -}, -} -}, -} -}, +Ports = {"100-200"}, +}}, +}}, Tags = { -["keyID"] = "KeyValue", +["keyID"] = "KeyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accessControlListName, data); @@ -228,10 +156,10 @@ public async Task Get_AccessControlListsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AccessControlListsGetMaximumSetGen() + public async Task GetAll_AccessControlListsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/AccessControlLists_Get_MaximumSet_Gen.json - // this example is just showing the usage of "AccessControlLists_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/AccessControlLists_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "AccessControlLists_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -248,16 +176,22 @@ public async Task Exists_AccessControlListsGetMaximumSetGen() // get the collection of this NetworkFabricAccessControlListResource NetworkFabricAccessControlListCollection collection = resourceGroupResource.GetNetworkFabricAccessControlLists(); - // invoke the operation - string accessControlListName = "example-acl"; - bool result = await collection.ExistsAsync(accessControlListName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricAccessControlListResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricAccessControlListData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AccessControlListsGetMaximumSetGen() + public async Task Exists_AccessControlListsGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/AccessControlLists_Get_MaximumSet_Gen.json // this example is just showing the usage of "AccessControlLists_Get" operation, for the dependent resources, they will have to be created separately. @@ -279,29 +213,17 @@ public async Task GetIfExists_AccessControlListsGetMaximumSetGen() // invoke the operation string accessControlListName = "example-acl"; - NullableResponse response = await collection.GetIfExistsAsync(accessControlListName); - NetworkFabricAccessControlListResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accessControlListName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricAccessControlListData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AccessControlListsListByResourceGroupMaximumSetGen() + public async Task GetIfExists_AccessControlListsGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/AccessControlLists_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "AccessControlLists_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/AccessControlLists_Get_MaximumSet_Gen.json + // this example is just showing the usage of "AccessControlLists_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -318,17 +240,23 @@ public async Task GetAll_AccessControlListsListByResourceGroupMaximumSetGen() // get the collection of this NetworkFabricAccessControlListResource NetworkFabricAccessControlListCollection collection = resourceGroupResource.GetNetworkFabricAccessControlLists(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricAccessControlListResource item in collection.GetAllAsync()) + // invoke the operation + string accessControlListName = "example-acl"; + NullableResponse response = await collection.GetIfExistsAsync(accessControlListName); + NetworkFabricAccessControlListResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricAccessControlListData resourceData = item.Data; + NetworkFabricAccessControlListData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricAccessControlListResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricAccessControlListResource.cs index e9b73d6fc106f..a2019b417cfa4 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricAccessControlListResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricAccessControlListResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -47,6 +46,32 @@ public async Task Get_AccessControlListsGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_AccessControlListsDeleteMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/AccessControlLists_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "AccessControlLists_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkFabricAccessControlListResource created on azure + // for more information of creating NetworkFabricAccessControlListResource, please refer to the document of NetworkFabricAccessControlListResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string accessControlListName = "example-acl"; + ResourceIdentifier networkFabricAccessControlListResourceId = NetworkFabricAccessControlListResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accessControlListName); + NetworkFabricAccessControlListResource networkFabricAccessControlList = client.GetNetworkFabricAccessControlListResource(networkFabricAccessControlListResourceId); + + // invoke the operation + await networkFabricAccessControlList.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_AccessControlListsUpdateMaximumSetGen() @@ -68,146 +93,74 @@ public async Task Update_AccessControlListsUpdateMaximumSetGen() NetworkFabricAccessControlListResource networkFabricAccessControlList = client.GetNetworkFabricAccessControlListResource(networkFabricAccessControlListResourceId); // invoke the operation - NetworkFabricAccessControlListPatch patch = new NetworkFabricAccessControlListPatch() + NetworkFabricAccessControlListPatch patch = new NetworkFabricAccessControlListPatch { ConfigurationType = NetworkFabricConfigurationType.File, AclsUri = new Uri("https://microsoft.com/a"), DefaultAction = CommunityActionType.Permit, - MatchConfigurations = -{ -new AccessControlListMatchConfiguration() + MatchConfigurations = {new AccessControlListMatchConfiguration { MatchConfigurationName = "example-match", SequenceNumber = 123L, IPAddressType = NetworkFabricIPAddressType.IPv4, -MatchConditions = -{ -new AccessControlListMatchCondition() +MatchConditions = {new AccessControlListMatchCondition { -EtherTypes = -{ -"0x1" -}, -Fragments = -{ -"0xff00-0xffff" -}, -IPLengths = -{ -"4094-9214" -}, -TtlValues = -{ -"23" -}, -DscpMarkings = -{ -"32" -}, +EtherTypes = {"0x1"}, +Fragments = {"0xff00-0xffff"}, +IPLengths = {"4094-9214"}, +TtlValues = {"23"}, +DscpMarkings = {"32"}, PortCondition = new AccessControlListPortCondition(Layer4Protocol.Tcp) { -Flags = -{ -"established" -}, +Flags = {"established"}, PortType = NetworkFabricPortType.SourcePort, -Ports = -{ -"1-20" -}, -PortGroupNames = -{ -"example-portGroup" -}, +Ports = {"1-20"}, +PortGroupNames = {"example-portGroup"}, }, -ProtocolTypes = +ProtocolTypes = {"TCP"}, +VlanMatchCondition = new VlanMatchCondition { -"TCP" +Vlans = {"20-30"}, +InnerVlans = {"30"}, +VlanGroupNames = {"example-vlanGroup"}, }, -VlanMatchCondition = new VlanMatchCondition() -{ -Vlans = -{ -"20-30" -}, -InnerVlans = -{ -"30" -}, -VlanGroupNames = -{ -"example-vlanGroup" -}, -}, -IPCondition = new IPMatchCondition() +IPCondition = new IPMatchCondition { SourceDestinationType = SourceDestinationType.SourceIP, PrefixType = IPMatchConditionPrefixType.Prefix, -IPPrefixValues = -{ -"10.20.20.20/12" +IPPrefixValues = {"10.20.20.20/12"}, +IPGroupNames = {"example-ipGroup"}, }, -IPGroupNames = -{ -"example-ipGroup" -}, -}, -} -}, -Actions = -{ -new AccessControlListAction() +}}, +Actions = {new AccessControlListAction { AclActionType = AclActionType.Count, CounterName = "example-counter", -} -}, -} -}, - DynamicMatchConfigurations = +}}, +}}, + DynamicMatchConfigurations = {new CommonDynamicMatchConfiguration { -new CommonDynamicMatchConfiguration() -{ -IPGroups = -{ -new MatchConfigurationIPGroupProperties() +IPGroups = {new MatchConfigurationIPGroupProperties { Name = "example-ipGroup", IPAddressType = NetworkFabricIPAddressType.IPv4, -IPPrefixes = -{ -"10.20.3.1/20" -}, -} -}, -VlanGroups = -{ -new VlanGroupProperties() +IPPrefixes = {"10.20.3.1/20"}, +}}, +VlanGroups = {new VlanGroupProperties { Name = "example-vlanGroup", -Vlans = -{ -"20-30" -}, -} -}, -PortGroups = -{ -new PortGroupProperties() +Vlans = {"20-30"}, +}}, +PortGroups = {new PortGroupProperties { Name = "example-portGroup", -Ports = -{ -"100-200" -}, -} -}, -} -}, +Ports = {"100-200"}, +}}, +}}, Annotation = "annotation", Tags = { -["keyID"] = "KeyValue", +["keyID"] = "KeyValue" }, }; ArmOperation lro = await networkFabricAccessControlList.UpdateAsync(WaitUntil.Completed, patch); @@ -220,63 +173,6 @@ public async Task Update_AccessControlListsUpdateMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_AccessControlListsDeleteMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/AccessControlLists_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "AccessControlLists_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkFabricAccessControlListResource created on azure - // for more information of creating NetworkFabricAccessControlListResource, please refer to the document of NetworkFabricAccessControlListResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string accessControlListName = "example-acl"; - ResourceIdentifier networkFabricAccessControlListResourceId = NetworkFabricAccessControlListResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accessControlListName); - NetworkFabricAccessControlListResource networkFabricAccessControlList = client.GetNetworkFabricAccessControlListResource(networkFabricAccessControlListResourceId); - - // invoke the operation - await networkFabricAccessControlList.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricAccessControlLists_AccessControlListsListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/AccessControlLists_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "AccessControlLists_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricAccessControlListResource item in subscriptionResource.GetNetworkFabricAccessControlListsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricAccessControlListData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task UpdateAdministrativeState_AccessControlListsUpdateAdministrativeStateMaximumSetGen() @@ -298,13 +194,10 @@ public async Task UpdateAdministrativeState_AccessControlListsUpdateAdministrati NetworkFabricAccessControlListResource networkFabricAccessControlList = client.GetNetworkFabricAccessControlListResource(networkFabricAccessControlListResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabricAccessControlList.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricCollection.cs index 5a81bf673b22d..eede1ba29c006 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricCollection.cs @@ -41,119 +41,91 @@ public async Task CreateOrUpdate_NetworkFabricsCreateMaximumSetGen() // invoke the operation string networkFabricName = "example-fabric"; - NetworkFabricData data = new NetworkFabricData(new AzureLocation("eastuseuap"), "M4-A400-A100-C16-aa", new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkFabricControllers/example-fabricController"), 8, "10.18.0.0/19", 29249L, new TerminalServerConfiguration() - { - PrimaryIPv4Prefix = "10.0.0.12/30", - PrimaryIPv6Prefix = "4FFE:FFFF:0:CD30::a8/127", - SecondaryIPv4Prefix = "20.0.0.13/30", - SecondaryIPv6Prefix = "6FFE:FFFF:0:CD30::ac/127", - Username = "username", - Password = "xxxx", - SerialNumber = "123456", - }, new ManagementNetworkConfigurationProperties(new VpnConfigurationProperties(PeeringOption.OptionA) - { - NetworkToNetworkInterconnectId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkFabrics/example-fabric/networkToNetworkInterconnects/example-nni"), - OptionBProperties = new OptionBProperties() - { - ImportRouteTargets = -{ -"65046:10050" -}, - ExportRouteTargets = -{ -"65046:10050" -}, - RouteTargets = new RouteTargetInformation() - { - ImportIPv4RouteTargets = -{ -"65046:10039" -}, - ImportIPv6RouteTargets = -{ -"65046:10039" -}, - ExportIPv4RouteTargets = -{ -"65046:10039" -}, - ExportIPv6RouteTargets = -{ -"65046:10039" -}, - }, - }, - OptionAProperties = new VpnConfigurationOptionAProperties() + NetworkFabricData data = new NetworkFabricData( + new AzureLocation("eastuseuap"), + "M4-A400-A100-C16-aa", + new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkFabricControllers/example-fabricController"), + 8, + "10.18.0.0/19", + 29249L, + new TerminalServerConfiguration { PrimaryIPv4Prefix = "10.0.0.12/30", PrimaryIPv6Prefix = "4FFE:FFFF:0:CD30::a8/127", SecondaryIPv4Prefix = "20.0.0.13/30", SecondaryIPv6Prefix = "6FFE:FFFF:0:CD30::ac/127", - Mtu = 1501, - VlanId = 3001, - PeerAsn = 1235L, - BfdConfiguration = new BfdConfiguration() - { - IntervalInMilliSeconds = 300, - Multiplier = 10, - }, + Username = "username", + Password = "xxxx", + SerialNumber = "123456", }, - }, new VpnConfigurationProperties(PeeringOption.OptionA) - { - NetworkToNetworkInterconnectId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkFabrics/example-fabric/networkToNetworkInterconnects/example-nni"), - OptionBProperties = new OptionBProperties() + new ManagementNetworkConfigurationProperties(new VpnConfigurationProperties(PeeringOption.OptionA) { - ImportRouteTargets = -{ -"65046:10050" -}, - ExportRouteTargets = -{ -"65046:10050" -}, - RouteTargets = new RouteTargetInformation() + NetworkToNetworkInterconnectId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkFabrics/example-fabric/networkToNetworkInterconnects/example-nni"), + OptionBProperties = new OptionBProperties { - ImportIPv4RouteTargets = -{ -"65046:10039" -}, - ImportIPv6RouteTargets = -{ -"65046:10039" -}, - ExportIPv4RouteTargets = -{ -"65046:10039" -}, - ExportIPv6RouteTargets = -{ -"65046:10039" -}, + ImportRouteTargets = { "65046:10050" }, + ExportRouteTargets = { "65046:10050" }, + RouteTargets = new RouteTargetInformation + { + ImportIPv4RouteTargets = { "65046:10039" }, + ImportIPv6RouteTargets = { "65046:10039" }, + ExportIPv4RouteTargets = { "65046:10039" }, + ExportIPv6RouteTargets = { "65046:10039" }, + }, }, - }, - OptionAProperties = new VpnConfigurationOptionAProperties() + OptionAProperties = new VpnConfigurationOptionAProperties + { + PrimaryIPv4Prefix = "10.0.0.12/30", + PrimaryIPv6Prefix = "4FFE:FFFF:0:CD30::a8/127", + SecondaryIPv4Prefix = "20.0.0.13/30", + SecondaryIPv6Prefix = "6FFE:FFFF:0:CD30::ac/127", + Mtu = 1501, + VlanId = 3001, + PeerAsn = 1235L, + BfdConfiguration = new BfdConfiguration + { + IntervalInMilliSeconds = 300, + Multiplier = 10, + }, + }, + }, new VpnConfigurationProperties(PeeringOption.OptionA) { - PrimaryIPv4Prefix = "10.0.0.14/30", - PrimaryIPv6Prefix = "2FFE:FFFF:0:CD30::a7/126", - SecondaryIPv4Prefix = "10.0.0.15/30", - SecondaryIPv6Prefix = "2FFE:FFFF:0:CD30::ac/126", - Mtu = 1500, - VlanId = 3000, - PeerAsn = 61234L, - BfdConfiguration = new BfdConfiguration() + NetworkToNetworkInterconnectId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkFabrics/example-fabric/networkToNetworkInterconnects/example-nni"), + OptionBProperties = new OptionBProperties { - IntervalInMilliSeconds = 300, - Multiplier = 5, + ImportRouteTargets = { "65046:10050" }, + ExportRouteTargets = { "65046:10050" }, + RouteTargets = new RouteTargetInformation + { + ImportIPv4RouteTargets = { "65046:10039" }, + ImportIPv6RouteTargets = { "65046:10039" }, + ExportIPv4RouteTargets = { "65046:10039" }, + ExportIPv6RouteTargets = { "65046:10039" }, + }, }, - }, - })) + OptionAProperties = new VpnConfigurationOptionAProperties + { + PrimaryIPv4Prefix = "10.0.0.14/30", + PrimaryIPv6Prefix = "2FFE:FFFF:0:CD30::a7/126", + SecondaryIPv4Prefix = "10.0.0.15/30", + SecondaryIPv6Prefix = "2FFE:FFFF:0:CD30::ac/126", + Mtu = 1500, + VlanId = 3000, + PeerAsn = 61234L, + BfdConfiguration = new BfdConfiguration + { + IntervalInMilliSeconds = 300, + Multiplier = 5, + }, + }, + })) { Annotation = "annotation", RackCount = 4, IPv6Prefix = "3FFE:FFFF:0:CD40::/59", Tags = { -["keyID"] = "keyValue", +["keyID"] = "keyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkFabricName, data); @@ -201,10 +173,10 @@ public async Task Get_NetworkFabricsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkFabricsGetMaximumSetGen() + public async Task GetAll_NetworkFabricsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabrics_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabrics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabrics_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabrics_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -221,16 +193,22 @@ public async Task Exists_NetworkFabricsGetMaximumSetGen() // get the collection of this NetworkFabricResource NetworkFabricCollection collection = resourceGroupResource.GetNetworkFabrics(); - // invoke the operation - string networkFabricName = "example-fabric"; - bool result = await collection.ExistsAsync(networkFabricName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkFabricsGetMaximumSetGen() + public async Task Exists_NetworkFabricsGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabrics_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkFabrics_Get" operation, for the dependent resources, they will have to be created separately. @@ -252,29 +230,17 @@ public async Task GetIfExists_NetworkFabricsGetMaximumSetGen() // invoke the operation string networkFabricName = "example-fabric"; - NullableResponse response = await collection.GetIfExistsAsync(networkFabricName); - NetworkFabricResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkFabricName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkFabricsListByResourceGroupMaximumSetGen() + public async Task GetIfExists_NetworkFabricsGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabrics_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabrics_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabrics_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabrics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -291,17 +257,23 @@ public async Task GetAll_NetworkFabricsListByResourceGroupMaximumSetGen() // get the collection of this NetworkFabricResource NetworkFabricCollection collection = resourceGroupResource.GetNetworkFabrics(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricResource item in collection.GetAllAsync()) + // invoke the operation + string networkFabricName = "example-fabric"; + NullableResponse response = await collection.GetIfExistsAsync(networkFabricName); + NetworkFabricResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricData resourceData = item.Data; + NetworkFabricData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricControllerCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricControllerCollection.cs index 2609cc85fc315..9247ed54cf8c0 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricControllerCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricControllerCollection.cs @@ -44,21 +44,15 @@ public async Task CreateOrUpdate_NetworkFabricControllersCreateMaximumSetGen() NetworkFabricControllerData data = new NetworkFabricControllerData(new AzureLocation("eastus")) { Annotation = "annotation", - InfrastructureExpressRouteConnections = -{ -new ExpressRouteConnectionInformation(new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName")) + InfrastructureExpressRouteConnections = {new ExpressRouteConnectionInformation(new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName")) { ExpressRouteAuthorizationKey = "1234ABCD-0A1B-1234-5678-123456ABCDEF", -} -}, - WorkloadExpressRouteConnections = -{ -new ExpressRouteConnectionInformation(new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName")) +}}, + WorkloadExpressRouteConnections = {new ExpressRouteConnectionInformation(new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName")) { ExpressRouteAuthorizationKey = "xxxxx", -} -}, - ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration() +}}, + ManagedResourceGroupConfiguration = new ManagedResourceGroupConfiguration { Name = "managedResourceGroupName", Location = new AzureLocation("eastus"), @@ -113,10 +107,10 @@ public async Task Get_NetworkFabricControllersGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkFabricControllersGetMaximumSetGen() + public async Task GetAll_NetworkFabricControllersListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabricControllers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabricControllers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,16 +127,22 @@ public async Task Exists_NetworkFabricControllersGetMaximumSetGen() // get the collection of this NetworkFabricControllerResource NetworkFabricControllerCollection collection = resourceGroupResource.GetNetworkFabricControllers(); - // invoke the operation - string networkFabricControllerName = "example-networkController"; - bool result = await collection.ExistsAsync(networkFabricControllerName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricControllerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricControllerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkFabricControllersGetMaximumSetGen() + public async Task Exists_NetworkFabricControllersGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkFabricControllers_Get" operation, for the dependent resources, they will have to be created separately. @@ -164,29 +164,17 @@ public async Task GetIfExists_NetworkFabricControllersGetMaximumSetGen() // invoke the operation string networkFabricControllerName = "example-networkController"; - NullableResponse response = await collection.GetIfExistsAsync(networkFabricControllerName); - NetworkFabricControllerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkFabricControllerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricControllerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkFabricControllersListByResourceGroupMaximumSetGen() + public async Task GetIfExists_NetworkFabricControllersGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabricControllers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabricControllers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -203,17 +191,23 @@ public async Task GetAll_NetworkFabricControllersListByResourceGroupMaximumSetGe // get the collection of this NetworkFabricControllerResource NetworkFabricControllerCollection collection = resourceGroupResource.GetNetworkFabricControllers(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricControllerResource item in collection.GetAllAsync()) + // invoke the operation + string networkFabricControllerName = "example-networkController"; + NullableResponse response = await collection.GetIfExistsAsync(networkFabricControllerName); + NetworkFabricControllerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricControllerData resourceData = item.Data; + NetworkFabricControllerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricControllerResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricControllerResource.cs index bb5c65808fb90..65410696ad679 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricControllerResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricControllerResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -49,10 +48,10 @@ public async Task Get_NetworkFabricControllersGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NetworkFabricControllersUpdateMaximumSetGen() + public async Task Delete_NetworkFabricControllersDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_Update_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabricControllers_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabricControllers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,39 +67,17 @@ public async Task Update_NetworkFabricControllersUpdateMaximumSetGen() NetworkFabricControllerResource networkFabricController = client.GetNetworkFabricControllerResource(networkFabricControllerResourceId); // invoke the operation - NetworkFabricControllerPatch patch = new NetworkFabricControllerPatch() - { - InfrastructureExpressRouteConnections = -{ -new ExpressRouteConnectionInformation(new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName")) -{ -ExpressRouteAuthorizationKey = "xxxxxxx", -} -}, - WorkloadExpressRouteConnections = -{ -new ExpressRouteConnectionInformation(new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName")) -{ -ExpressRouteAuthorizationKey = "xxxxxxx", -} -}, - }; - ArmOperation lro = await networkFabricController.UpdateAsync(WaitUntil.Completed, patch); - NetworkFabricControllerResource result = lro.Value; + await networkFabricController.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricControllerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkFabricControllersDeleteMaximumSetGen() + public async Task Update_NetworkFabricControllersUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabricControllers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_Update_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabricControllers_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,40 +93,25 @@ public async Task Delete_NetworkFabricControllersDeleteMaximumSetGen() NetworkFabricControllerResource networkFabricController = client.GetNetworkFabricControllerResource(networkFabricControllerResourceId); // invoke the operation - await networkFabricController.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricControllers_NetworkFabricControllersListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabricControllers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricControllerResource item in subscriptionResource.GetNetworkFabricControllersAsync()) + NetworkFabricControllerPatch patch = new NetworkFabricControllerPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricControllerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + InfrastructureExpressRouteConnections = {new ExpressRouteConnectionInformation(new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName")) +{ +ExpressRouteAuthorizationKey = "xxxxxxx", +}}, + WorkloadExpressRouteConnections = {new ExpressRouteConnectionInformation(new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.Network/expressRouteCircuits/expressRouteCircuitName")) +{ +ExpressRouteAuthorizationKey = "xxxxxxx", +}}, + }; + ArmOperation lro = await networkFabricController.UpdateAsync(WaitUntil.Completed, patch); + NetworkFabricControllerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricControllerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricExternalNetworkCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricExternalNetworkCollection.cs index 36ac1ebaf3e99..ec6eb3ec4f1d0 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricExternalNetworkCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricExternalNetworkCollection.cs @@ -46,52 +46,34 @@ public async Task CreateOrUpdate_ExternalNetworksCreateMaximumSetGen() Annotation = "annotation", ImportRoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ExportRoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), - ImportRoutePolicy = new ImportRoutePolicy() + ImportRoutePolicy = new ImportRoutePolicy { ImportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ImportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), }, - ExportRoutePolicy = new ExportRoutePolicy() + ExportRoutePolicy = new ExportRoutePolicy { ExportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ExportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), }, - OptionBProperties = new L3OptionBProperties() + OptionBProperties = new L3OptionBProperties { - ImportRouteTargets = -{ -"65046:10039" -}, - ExportRouteTargets = -{ -"65046:10039" -}, - RouteTargets = new RouteTargetInformation() + ImportRouteTargets = { "65046:10039" }, + ExportRouteTargets = { "65046:10039" }, + RouteTargets = new RouteTargetInformation { - ImportIPv4RouteTargets = -{ -"65046:10039" -}, - ImportIPv6RouteTargets = -{ -"65046:10039" -}, - ExportIPv4RouteTargets = -{ -"65046:10039" -}, - ExportIPv6RouteTargets = -{ -"65046:10039" -}, + ImportIPv4RouteTargets = { "65046:10039" }, + ImportIPv6RouteTargets = { "65046:10039" }, + ExportIPv4RouteTargets = { "65046:10039" }, + ExportIPv6RouteTargets = { "65046:10039" }, }, }, - OptionAProperties = new ExternalNetworkOptionAProperties() + OptionAProperties = new ExternalNetworkOptionAProperties { Mtu = 1500, VlanId = 1001, PeerAsn = 65047L, - BfdConfiguration = new BfdConfiguration() + BfdConfiguration = new BfdConfiguration { IntervalInMilliSeconds = 300, Multiplier = 15, @@ -148,6 +130,42 @@ public async Task Get_ExternalNetworksGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ExternalNetworksListByL3IsolationDomainMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/ExternalNetworks_ListByL3IsolationDomain_MaximumSet_Gen.json + // this example is just showing the usage of "ExternalNetworks_ListByL3IsolationDomain" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkFabricL3IsolationDomainResource created on azure + // for more information of creating NetworkFabricL3IsolationDomainResource, please refer to the document of NetworkFabricL3IsolationDomainResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string l3IsolationDomainName = "example-l3domain"; + ResourceIdentifier networkFabricL3IsolationDomainResourceId = NetworkFabricL3IsolationDomainResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, l3IsolationDomainName); + NetworkFabricL3IsolationDomainResource networkFabricL3IsolationDomain = client.GetNetworkFabricL3IsolationDomainResource(networkFabricL3IsolationDomainResourceId); + + // get the collection of this NetworkFabricExternalNetworkResource + NetworkFabricExternalNetworkCollection collection = networkFabricL3IsolationDomain.GetNetworkFabricExternalNetworks(); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricExternalNetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricExternalNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_ExternalNetworksGetMaximumSetGen() @@ -219,41 +237,5 @@ public async Task GetIfExists_ExternalNetworksGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExternalNetworksListByL3IsolationDomainMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/ExternalNetworks_ListByL3IsolationDomain_MaximumSet_Gen.json - // this example is just showing the usage of "ExternalNetworks_ListByL3IsolationDomain" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkFabricL3IsolationDomainResource created on azure - // for more information of creating NetworkFabricL3IsolationDomainResource, please refer to the document of NetworkFabricL3IsolationDomainResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string l3IsolationDomainName = "example-l3domain"; - ResourceIdentifier networkFabricL3IsolationDomainResourceId = NetworkFabricL3IsolationDomainResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, l3IsolationDomainName); - NetworkFabricL3IsolationDomainResource networkFabricL3IsolationDomain = client.GetNetworkFabricL3IsolationDomainResource(networkFabricL3IsolationDomainResourceId); - - // get the collection of this NetworkFabricExternalNetworkResource - NetworkFabricExternalNetworkCollection collection = networkFabricL3IsolationDomain.GetNetworkFabricExternalNetworks(); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricExternalNetworkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricExternalNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricExternalNetworkResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricExternalNetworkResource.cs index 1cd7e94b1d596..cf82dad3c6bfc 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricExternalNetworkResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricExternalNetworkResource.cs @@ -47,6 +47,33 @@ public async Task Get_ExternalNetworksGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_ExternalNetworksDeleteMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/ExternalNetworks_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "ExternalNetworks_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkFabricExternalNetworkResource created on azure + // for more information of creating NetworkFabricExternalNetworkResource, please refer to the document of NetworkFabricExternalNetworkResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string l3IsolationDomainName = "example-l3domain"; + string externalNetworkName = "example-externalnetwork"; + ResourceIdentifier networkFabricExternalNetworkResourceId = NetworkFabricExternalNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, l3IsolationDomainName, externalNetworkName); + NetworkFabricExternalNetworkResource networkFabricExternalNetwork = client.GetNetworkFabricExternalNetworkResource(networkFabricExternalNetworkResourceId); + + // invoke the operation + await networkFabricExternalNetwork.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_ExternalNetworksUpdateMaximumSetGen() @@ -69,58 +96,40 @@ public async Task Update_ExternalNetworksUpdateMaximumSetGen() NetworkFabricExternalNetworkResource networkFabricExternalNetwork = client.GetNetworkFabricExternalNetworkResource(networkFabricExternalNetworkResourceId); // invoke the operation - NetworkFabricExternalNetworkPatch patch = new NetworkFabricExternalNetworkPatch() + NetworkFabricExternalNetworkPatch patch = new NetworkFabricExternalNetworkPatch { Annotation = "annotation1", ImportRoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ExportRoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), - ImportRoutePolicy = new ImportRoutePolicy() + ImportRoutePolicy = new ImportRoutePolicy { ImportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ImportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), }, - ExportRoutePolicy = new ExportRoutePolicy() + ExportRoutePolicy = new ExportRoutePolicy { ExportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ExportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), }, PeeringOption = PeeringOption.OptionA, - OptionBProperties = new L3OptionBProperties() + OptionBProperties = new L3OptionBProperties { - ImportRouteTargets = -{ -"65046:10039" -}, - ExportRouteTargets = -{ -"65046:10039" -}, - RouteTargets = new RouteTargetInformation() + ImportRouteTargets = { "65046:10039" }, + ExportRouteTargets = { "65046:10039" }, + RouteTargets = new RouteTargetInformation { - ImportIPv4RouteTargets = -{ -"65046:10039" -}, - ImportIPv6RouteTargets = -{ -"65046:10039" -}, - ExportIPv4RouteTargets = -{ -"65046:10039" -}, - ExportIPv6RouteTargets = -{ -"65046:10039" -}, + ImportIPv4RouteTargets = { "65046:10039" }, + ImportIPv6RouteTargets = { "65046:10039" }, + ExportIPv4RouteTargets = { "65046:10039" }, + ExportIPv6RouteTargets = { "65046:10039" }, }, }, - OptionAProperties = new ExternalNetworkPatchOptionAProperties() + OptionAProperties = new ExternalNetworkPatchOptionAProperties { Mtu = 1500, VlanId = 1001, PeerAsn = 65047L, - BfdConfiguration = new BfdConfiguration() + BfdConfiguration = new BfdConfiguration { IntervalInMilliSeconds = 300, Multiplier = 15, @@ -143,33 +152,6 @@ public async Task Update_ExternalNetworksUpdateMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_ExternalNetworksDeleteMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/ExternalNetworks_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "ExternalNetworks_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkFabricExternalNetworkResource created on azure - // for more information of creating NetworkFabricExternalNetworkResource, please refer to the document of NetworkFabricExternalNetworkResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string l3IsolationDomainName = "example-l3domain"; - string externalNetworkName = "example-externalnetwork"; - ResourceIdentifier networkFabricExternalNetworkResourceId = NetworkFabricExternalNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, l3IsolationDomainName, externalNetworkName); - NetworkFabricExternalNetworkResource networkFabricExternalNetwork = client.GetNetworkFabricExternalNetworkResource(networkFabricExternalNetworkResourceId); - - // invoke the operation - await networkFabricExternalNetwork.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task UpdateAdministrativeState_ExternalNetworksUpdateAdministrativeStateMaximumSetGen() @@ -192,13 +174,10 @@ public async Task UpdateAdministrativeState_ExternalNetworksUpdateAdministrative NetworkFabricExternalNetworkResource networkFabricExternalNetwork = client.GetNetworkFabricExternalNetworkResource(networkFabricExternalNetworkResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabricExternalNetwork.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; @@ -228,13 +207,10 @@ public async Task UpdateStaticRouteBfdAdministrativeState_ExternalNetworksUpdate NetworkFabricExternalNetworkResource networkFabricExternalNetwork = client.GetNetworkFabricExternalNetworkResource(networkFabricExternalNetworkResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabricExternalNetwork.UpdateStaticRouteBfdAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPCommunityCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPCommunityCollection.cs index 02b26454894bf..aca2f03922693 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPCommunityCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPCommunityCollection.cs @@ -44,22 +44,13 @@ public async Task CreateOrUpdate_IpCommunitiesCreateMaximumSetGen() NetworkFabricIPCommunityData data = new NetworkFabricIPCommunityData(new AzureLocation("eastus")) { Annotation = "annotation", - IPCommunityRules = + IPCommunityRules = {new IPCommunityRule(CommunityActionType.Permit, 4155123341L, new string[]{"1:1"}) { -new IPCommunityRule(CommunityActionType.Permit,4155123341L,new string[] -{ -"1:1" -}) -{ -WellKnownCommunities = -{ -WellKnownCommunity.Internet -}, -} -}, +WellKnownCommunities = {WellKnownCommunity.Internet}, +}}, Tags = { -["keyId"] = "KeyValue", +["keyId"] = "KeyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ipCommunityName, data); @@ -107,10 +98,10 @@ public async Task Get_IpCommunitiesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_IpCommunitiesGetMaximumSetGen() + public async Task GetAll_IpCommunitiesListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_Get_MaximumSet_Gen.json - // this example is just showing the usage of "IpCommunities_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "IpCommunities_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,16 +118,22 @@ public async Task Exists_IpCommunitiesGetMaximumSetGen() // get the collection of this NetworkFabricIPCommunityResource NetworkFabricIPCommunityCollection collection = resourceGroupResource.GetNetworkFabricIPCommunities(); - // invoke the operation - string ipCommunityName = "example-ipcommunity"; - bool result = await collection.ExistsAsync(ipCommunityName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricIPCommunityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricIPCommunityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_IpCommunitiesGetMaximumSetGen() + public async Task Exists_IpCommunitiesGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_Get_MaximumSet_Gen.json // this example is just showing the usage of "IpCommunities_Get" operation, for the dependent resources, they will have to be created separately. @@ -158,29 +155,17 @@ public async Task GetIfExists_IpCommunitiesGetMaximumSetGen() // invoke the operation string ipCommunityName = "example-ipcommunity"; - NullableResponse response = await collection.GetIfExistsAsync(ipCommunityName); - NetworkFabricIPCommunityResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ipCommunityName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricIPCommunityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_IpCommunitiesListByResourceGroupMaximumSetGen() + public async Task GetIfExists_IpCommunitiesGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "IpCommunities_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_Get_MaximumSet_Gen.json + // this example is just showing the usage of "IpCommunities_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -197,17 +182,23 @@ public async Task GetAll_IpCommunitiesListByResourceGroupMaximumSetGen() // get the collection of this NetworkFabricIPCommunityResource NetworkFabricIPCommunityCollection collection = resourceGroupResource.GetNetworkFabricIPCommunities(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricIPCommunityResource item in collection.GetAllAsync()) + // invoke the operation + string ipCommunityName = "example-ipcommunity"; + NullableResponse response = await collection.GetIfExistsAsync(ipCommunityName); + NetworkFabricIPCommunityResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricIPCommunityData resourceData = item.Data; + NetworkFabricIPCommunityData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPCommunityResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPCommunityResource.cs index 0b7f6f6a8a258..12fc969a3e2f4 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPCommunityResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPCommunityResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -49,10 +48,10 @@ public async Task Get_IpCommunitiesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_IpCommunitiesUpdateMaximumSetGen() + public async Task Delete_IpCommunitiesDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_Update_MaximumSet_Gen.json - // this example is just showing the usage of "IpCommunities_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "IpCommunities_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,38 +67,17 @@ public async Task Update_IpCommunitiesUpdateMaximumSetGen() NetworkFabricIPCommunityResource networkFabricIPCommunity = client.GetNetworkFabricIPCommunityResource(networkFabricIPCommunityResourceId); // invoke the operation - NetworkFabricIPCommunityPatch patch = new NetworkFabricIPCommunityPatch() - { - IPCommunityRules = -{ -new IPCommunityRule(CommunityActionType.Permit,4155123341L,new string[] -{ -"1:1" -}) -{ -WellKnownCommunities = -{ -WellKnownCommunity.Internet -}, -} -}, - }; - ArmOperation lro = await networkFabricIPCommunity.UpdateAsync(WaitUntil.Completed, patch); - NetworkFabricIPCommunityResource result = lro.Value; + await networkFabricIPCommunity.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricIPCommunityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_IpCommunitiesDeleteMaximumSetGen() + public async Task Update_IpCommunitiesUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "IpCommunities_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_Update_MaximumSet_Gen.json + // this example is just showing the usage of "IpCommunities_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,40 +93,21 @@ public async Task Delete_IpCommunitiesDeleteMaximumSetGen() NetworkFabricIPCommunityResource networkFabricIPCommunity = client.GetNetworkFabricIPCommunityResource(networkFabricIPCommunityResourceId); // invoke the operation - await networkFabricIPCommunity.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricIPCommunities_IpCommunitiesListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "IpCommunities_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricIPCommunityResource item in subscriptionResource.GetNetworkFabricIPCommunitiesAsync()) + NetworkFabricIPCommunityPatch patch = new NetworkFabricIPCommunityPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricIPCommunityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IPCommunityRules = {new IPCommunityRule(CommunityActionType.Permit, 4155123341L, new string[]{"1:1"}) +{ +WellKnownCommunities = {WellKnownCommunity.Internet}, +}}, + }; + ArmOperation lro = await networkFabricIPCommunity.UpdateAsync(WaitUntil.Completed, patch); + NetworkFabricIPCommunityResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricIPCommunityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPExtendedCommunityCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPExtendedCommunityCollection.cs index a83238dcc7ea3..14465a3f54ecf 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPExtendedCommunityCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPExtendedCommunityCollection.cs @@ -43,16 +43,13 @@ public async Task CreateOrUpdate_IpExtendedCommunitiesCreateMaximumSetGen() string ipExtendedCommunityName = "example-ipExtendedCommunity"; NetworkFabricIPExtendedCommunityData data = new NetworkFabricIPExtendedCommunityData(new AzureLocation("eastus"), new IPExtendedCommunityRule[] { -new IPExtendedCommunityRule(CommunityActionType.Permit,4155123341L,new string[] -{ -"1234:2345" -}) +new IPExtendedCommunityRule(CommunityActionType.Permit, 4155123341L, new string[]{"1234:2345"}) }) { Annotation = "annotation", Tags = { -["keyID"] = "KeyValue", +["keyID"] = "KeyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ipExtendedCommunityName, data); @@ -100,10 +97,10 @@ public async Task Get_IpExtendedCommunitiesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_IpExtendedCommunitiesGetMaximumSetGen() + public async Task GetAll_IpExtendedCommunitiesListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_Get_MaximumSet_Gen.json - // this example is just showing the usage of "IpExtendedCommunities_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "IpExtendedCommunities_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -120,16 +117,22 @@ public async Task Exists_IpExtendedCommunitiesGetMaximumSetGen() // get the collection of this NetworkFabricIPExtendedCommunityResource NetworkFabricIPExtendedCommunityCollection collection = resourceGroupResource.GetNetworkFabricIPExtendedCommunities(); - // invoke the operation - string ipExtendedCommunityName = "example-ipExtendedCommunity"; - bool result = await collection.ExistsAsync(ipExtendedCommunityName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricIPExtendedCommunityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricIPExtendedCommunityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_IpExtendedCommunitiesGetMaximumSetGen() + public async Task Exists_IpExtendedCommunitiesGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_Get_MaximumSet_Gen.json // this example is just showing the usage of "IpExtendedCommunities_Get" operation, for the dependent resources, they will have to be created separately. @@ -151,29 +154,17 @@ public async Task GetIfExists_IpExtendedCommunitiesGetMaximumSetGen() // invoke the operation string ipExtendedCommunityName = "example-ipExtendedCommunity"; - NullableResponse response = await collection.GetIfExistsAsync(ipExtendedCommunityName); - NetworkFabricIPExtendedCommunityResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ipExtendedCommunityName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricIPExtendedCommunityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_IpExtendedCommunitiesListByResourceGroupMaximumSetGen() + public async Task GetIfExists_IpExtendedCommunitiesGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "IpExtendedCommunities_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_Get_MaximumSet_Gen.json + // this example is just showing the usage of "IpExtendedCommunities_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +181,23 @@ public async Task GetAll_IpExtendedCommunitiesListByResourceGroupMaximumSetGen() // get the collection of this NetworkFabricIPExtendedCommunityResource NetworkFabricIPExtendedCommunityCollection collection = resourceGroupResource.GetNetworkFabricIPExtendedCommunities(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricIPExtendedCommunityResource item in collection.GetAllAsync()) + // invoke the operation + string ipExtendedCommunityName = "example-ipExtendedCommunity"; + NullableResponse response = await collection.GetIfExistsAsync(ipExtendedCommunityName); + NetworkFabricIPExtendedCommunityResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricIPExtendedCommunityData resourceData = item.Data; + NetworkFabricIPExtendedCommunityData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPExtendedCommunityResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPExtendedCommunityResource.cs index b675f8dff8f31..b566d8153479f 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPExtendedCommunityResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPExtendedCommunityResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -49,10 +48,10 @@ public async Task Get_IpExtendedCommunitiesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_IpExtendedCommunitiesUpdateMaximumSetGen() + public async Task Delete_IpExtendedCommunitiesDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_Update_MaximumSet_Gen.json - // this example is just showing the usage of "IpExtendedCommunities_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "IpExtendedCommunities_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,36 +67,17 @@ public async Task Update_IpExtendedCommunitiesUpdateMaximumSetGen() NetworkFabricIPExtendedCommunityResource networkFabricIPExtendedCommunity = client.GetNetworkFabricIPExtendedCommunityResource(networkFabricIPExtendedCommunityResourceId); // invoke the operation - NetworkFabricIPExtendedCommunityPatch patch = new NetworkFabricIPExtendedCommunityPatch() - { - IPExtendedCommunityRules = -{ -new IPExtendedCommunityRule(CommunityActionType.Permit,4155123341L,new string[] -{ -"1234:2345" -}) -}, - Tags = -{ -["keyID"] = "KeyValue", -}, - }; - ArmOperation lro = await networkFabricIPExtendedCommunity.UpdateAsync(WaitUntil.Completed, patch); - NetworkFabricIPExtendedCommunityResource result = lro.Value; + await networkFabricIPExtendedCommunity.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricIPExtendedCommunityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_IpExtendedCommunitiesDeleteMaximumSetGen() + public async Task Update_IpExtendedCommunitiesUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "IpExtendedCommunities_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_Update_MaximumSet_Gen.json + // this example is just showing the usage of "IpExtendedCommunities_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,40 +93,22 @@ public async Task Delete_IpExtendedCommunitiesDeleteMaximumSetGen() NetworkFabricIPExtendedCommunityResource networkFabricIPExtendedCommunity = client.GetNetworkFabricIPExtendedCommunityResource(networkFabricIPExtendedCommunityResourceId); // invoke the operation - await networkFabricIPExtendedCommunity.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricIPExtendedCommunities_IpExtendedCommunitiesListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "IpExtendedCommunities_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricIPExtendedCommunityResource item in subscriptionResource.GetNetworkFabricIPExtendedCommunitiesAsync()) + NetworkFabricIPExtendedCommunityPatch patch = new NetworkFabricIPExtendedCommunityPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricIPExtendedCommunityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IPExtendedCommunityRules = { new IPExtendedCommunityRule(CommunityActionType.Permit, 4155123341L, new string[] { "1234:2345" }) }, + Tags = +{ +["keyID"] = "KeyValue" +}, + }; + ArmOperation lro = await networkFabricIPExtendedCommunity.UpdateAsync(WaitUntil.Completed, patch); + NetworkFabricIPExtendedCommunityResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricIPExtendedCommunityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPPrefixCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPPrefixCollection.cs index 04990e8b03eeb..23b78ea564579 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPPrefixCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPPrefixCollection.cs @@ -44,17 +44,14 @@ public async Task CreateOrUpdate_IpPrefixesCreateMaximumSetGen() NetworkFabricIPPrefixData data = new NetworkFabricIPPrefixData(new AzureLocation("eastus")) { Annotation = "annotation", - IPPrefixRules = -{ -new IPPrefixRule(CommunityActionType.Permit,4155123341L,"10.10.10.10/30") + IPPrefixRules = {new IPPrefixRule(CommunityActionType.Permit, 4155123341L, "10.10.10.10/30") { Condition = IPPrefixRuleCondition.GreaterThanOrEqualTo, SubnetMaskLength = "10", -} -}, +}}, Tags = { -["keyID"] = "KeyValue", +["keyID"] = "KeyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ipPrefixName, data); @@ -102,10 +99,10 @@ public async Task Get_IpPrefixesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_IpPrefixesGetMaximumSetGen() + public async Task GetAll_IpPrefixesListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_Get_MaximumSet_Gen.json - // this example is just showing the usage of "IpPrefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "IpPrefixes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,16 +119,22 @@ public async Task Exists_IpPrefixesGetMaximumSetGen() // get the collection of this NetworkFabricIPPrefixResource NetworkFabricIPPrefixCollection collection = resourceGroupResource.GetNetworkFabricIPPrefixes(); - // invoke the operation - string ipPrefixName = "example-ipPrefix"; - bool result = await collection.ExistsAsync(ipPrefixName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricIPPrefixResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricIPPrefixData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_IpPrefixesGetMaximumSetGen() + public async Task Exists_IpPrefixesGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_Get_MaximumSet_Gen.json // this example is just showing the usage of "IpPrefixes_Get" operation, for the dependent resources, they will have to be created separately. @@ -153,29 +156,17 @@ public async Task GetIfExists_IpPrefixesGetMaximumSetGen() // invoke the operation string ipPrefixName = "example-ipPrefix"; - NullableResponse response = await collection.GetIfExistsAsync(ipPrefixName); - NetworkFabricIPPrefixResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ipPrefixName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricIPPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_IpPrefixesListByResourceGroupMaximumSetGen() + public async Task GetIfExists_IpPrefixesGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "IpPrefixes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_Get_MaximumSet_Gen.json + // this example is just showing the usage of "IpPrefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,17 +183,23 @@ public async Task GetAll_IpPrefixesListByResourceGroupMaximumSetGen() // get the collection of this NetworkFabricIPPrefixResource NetworkFabricIPPrefixCollection collection = resourceGroupResource.GetNetworkFabricIPPrefixes(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricIPPrefixResource item in collection.GetAllAsync()) + // invoke the operation + string ipPrefixName = "example-ipPrefix"; + NullableResponse response = await collection.GetIfExistsAsync(ipPrefixName); + NetworkFabricIPPrefixResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricIPPrefixData resourceData = item.Data; + NetworkFabricIPPrefixData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPPrefixResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPPrefixResource.cs index db9491271a709..18c607d5472cb 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPPrefixResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricIPPrefixResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -49,10 +48,10 @@ public async Task Get_IpPrefixesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_IpPrefixesUpdateMaximumSetGen() + public async Task Delete_IpPrefixesDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_Update_MaximumSet_Gen.json - // this example is just showing the usage of "IpPrefixes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "IpPrefixes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,38 +67,17 @@ public async Task Update_IpPrefixesUpdateMaximumSetGen() NetworkFabricIPPrefixResource networkFabricIPPrefix = client.GetNetworkFabricIPPrefixResource(networkFabricIPPrefixResourceId); // invoke the operation - NetworkFabricIPPrefixPatch patch = new NetworkFabricIPPrefixPatch() - { - Annotation = "annotation", - IPPrefixRules = -{ -new IPPrefixRule(CommunityActionType.Permit,4155123341L,"10.10.10.10/30") -{ -Condition = IPPrefixRuleCondition.GreaterThanOrEqualTo, -SubnetMaskLength = "10", -} -}, - Tags = -{ -["keyID"] = "KeyValue", -}, - }; - ArmOperation lro = await networkFabricIPPrefix.UpdateAsync(WaitUntil.Completed, patch); - NetworkFabricIPPrefixResource result = lro.Value; + await networkFabricIPPrefix.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricIPPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_IpPrefixesDeleteMaximumSetGen() + public async Task Update_IpPrefixesUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "IpPrefixes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_Update_MaximumSet_Gen.json + // this example is just showing the usage of "IpPrefixes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,40 +93,27 @@ public async Task Delete_IpPrefixesDeleteMaximumSetGen() NetworkFabricIPPrefixResource networkFabricIPPrefix = client.GetNetworkFabricIPPrefixResource(networkFabricIPPrefixResourceId); // invoke the operation - await networkFabricIPPrefix.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricIPPrefixes_IpPrefixesListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "IpPrefixes_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricIPPrefixResource item in subscriptionResource.GetNetworkFabricIPPrefixesAsync()) + NetworkFabricIPPrefixPatch patch = new NetworkFabricIPPrefixPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricIPPrefixData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Annotation = "annotation", + IPPrefixRules = {new IPPrefixRule(CommunityActionType.Permit, 4155123341L, "10.10.10.10/30") +{ +Condition = IPPrefixRuleCondition.GreaterThanOrEqualTo, +SubnetMaskLength = "10", +}}, + Tags = +{ +["keyID"] = "KeyValue" +}, + }; + ArmOperation lro = await networkFabricIPPrefix.UpdateAsync(WaitUntil.Completed, patch); + NetworkFabricIPPrefixResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricIPPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternalNetworkCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternalNetworkCollection.cs index 6aa8a47944be6..43f8806b338f9 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternalNetworkCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternalNetworkCollection.cs @@ -45,28 +45,22 @@ public async Task CreateOrUpdate_InternalNetworksCreateMaximumSetGen() { Annotation = "annotation", Mtu = 1500, - ConnectedIPv4Subnets = -{ -new ConnectedSubnet("10.0.0.0/24") + ConnectedIPv4Subnets = {new ConnectedSubnet("10.0.0.0/24") { Annotation = "annotation", -} -}, - ConnectedIPv6Subnets = -{ -new ConnectedSubnet("3FFE:FFFF:0:CD30::a0/29") +}}, + ConnectedIPv6Subnets = {new ConnectedSubnet("3FFE:FFFF:0:CD30::a0/29") { Annotation = "annotation", -} -}, +}}, ImportRoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ExportRoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), - ImportRoutePolicy = new ImportRoutePolicy() + ImportRoutePolicy = new ImportRoutePolicy { ImportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ImportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), }, - ExportRoutePolicy = new ExportRoutePolicy() + ExportRoutePolicy = new ExportRoutePolicy { ExportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ExportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), @@ -75,9 +69,9 @@ public async Task CreateOrUpdate_InternalNetworksCreateMaximumSetGen() EgressAclId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/accessControlLists/example-acl"), IsMonitoringEnabled = IsMonitoringEnabled.True, Extension = StaticRouteConfigurationExtension.NoExtension, - BgpConfiguration = new InternalNetworkBgpConfiguration() + BgpConfiguration = new InternalNetworkBgpConfiguration { - BfdConfiguration = new BfdConfiguration() + BfdConfiguration = new BfdConfiguration { IntervalInMilliSeconds = 300, Multiplier = 5, @@ -86,52 +80,28 @@ public async Task CreateOrUpdate_InternalNetworksCreateMaximumSetGen() AllowAS = 10, AllowASOverride = AllowASOverride.Enable, PeerAsn = 61234L, - IPv4ListenRangePrefixes = -{ -"10.1.0.0/25" -}, - IPv6ListenRangePrefixes = -{ -"2fff::/66" -}, - IPv4NeighborAddress = -{ -new NeighborAddress() + IPv4ListenRangePrefixes = { "10.1.0.0/25" }, + IPv6ListenRangePrefixes = { "2fff::/66" }, + IPv4NeighborAddress = {new NeighborAddress { Address = "10.1.0.0", -} -}, - IPv6NeighborAddress = -{ -new NeighborAddress() +}}, + IPv6NeighborAddress = {new NeighborAddress { Address = "2fff::", -} -}, +}}, Annotation = "annotation", }, - StaticRouteConfiguration = new InternalNetworkStaticRouteConfiguration() + StaticRouteConfiguration = new InternalNetworkStaticRouteConfiguration { Extension = StaticRouteConfigurationExtension.NoExtension, - BfdConfiguration = new BfdConfiguration() + BfdConfiguration = new BfdConfiguration { IntervalInMilliSeconds = 300, Multiplier = 15, }, - IPv4Routes = -{ -new StaticRouteProperties("jffgck",new string[] -{ -"10.0.0.1" -}) -}, - IPv6Routes = -{ -new StaticRouteProperties("2fff::/64",new string[] -{ -"3ffe::1" -}) -}, + IPv4Routes = { new StaticRouteProperties("jffgck", new string[] { "10.0.0.1" }) }, + IPv6Routes = { new StaticRouteProperties("2fff::/64", new string[] { "3ffe::1" }) }, }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, internalNetworkName, data); @@ -180,10 +150,10 @@ public async Task Get_InternalNetworksGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_InternalNetworksGetMaximumSetGen() + public async Task GetAll_InternalNetworksListByL3IsolationDomainMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternalNetworks_Get_MaximumSet_Gen.json - // this example is just showing the usage of "InternalNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternalNetworks_ListByL3IsolationDomain_MaximumSet_Gen.json + // this example is just showing the usage of "InternalNetworks_ListByL3IsolationDomain" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -201,16 +171,22 @@ public async Task Exists_InternalNetworksGetMaximumSetGen() // get the collection of this NetworkFabricInternalNetworkResource NetworkFabricInternalNetworkCollection collection = networkFabricL3IsolationDomain.GetNetworkFabricInternalNetworks(); - // invoke the operation - string internalNetworkName = "example-internalnetwork"; - bool result = await collection.ExistsAsync(internalNetworkName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricInternalNetworkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricInternalNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_InternalNetworksGetMaximumSetGen() + public async Task Exists_InternalNetworksGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternalNetworks_Get_MaximumSet_Gen.json // this example is just showing the usage of "InternalNetworks_Get" operation, for the dependent resources, they will have to be created separately. @@ -233,29 +209,17 @@ public async Task GetIfExists_InternalNetworksGetMaximumSetGen() // invoke the operation string internalNetworkName = "example-internalnetwork"; - NullableResponse response = await collection.GetIfExistsAsync(internalNetworkName); - NetworkFabricInternalNetworkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(internalNetworkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricInternalNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InternalNetworksListByL3IsolationDomainMaximumSetGen() + public async Task GetIfExists_InternalNetworksGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternalNetworks_ListByL3IsolationDomain_MaximumSet_Gen.json - // this example is just showing the usage of "InternalNetworks_ListByL3IsolationDomain" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternalNetworks_Get_MaximumSet_Gen.json + // this example is just showing the usage of "InternalNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -273,17 +237,23 @@ public async Task GetAll_InternalNetworksListByL3IsolationDomainMaximumSetGen() // get the collection of this NetworkFabricInternalNetworkResource NetworkFabricInternalNetworkCollection collection = networkFabricL3IsolationDomain.GetNetworkFabricInternalNetworks(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricInternalNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string internalNetworkName = "example-internalnetwork"; + NullableResponse response = await collection.GetIfExistsAsync(internalNetworkName); + NetworkFabricInternalNetworkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricInternalNetworkData resourceData = item.Data; + NetworkFabricInternalNetworkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternalNetworkResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternalNetworkResource.cs index a6bf8f3293742..d14833aa35b9a 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternalNetworkResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternalNetworkResource.cs @@ -47,6 +47,33 @@ public async Task Get_InternalNetworksGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_InternalNetworksDeleteMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternalNetworks_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "InternalNetworks_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkFabricInternalNetworkResource created on azure + // for more information of creating NetworkFabricInternalNetworkResource, please refer to the document of NetworkFabricInternalNetworkResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string l3IsolationDomainName = "example-l3domain"; + string internalNetworkName = "example-internalnetwork"; + ResourceIdentifier networkFabricInternalNetworkResourceId = NetworkFabricInternalNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, l3IsolationDomainName, internalNetworkName); + NetworkFabricInternalNetworkResource networkFabricInternalNetwork = client.GetNetworkFabricInternalNetworkResource(networkFabricInternalNetworkResourceId); + + // invoke the operation + await networkFabricInternalNetwork.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_InternalNetworksUpdateMaximumSetGen() @@ -69,32 +96,26 @@ public async Task Update_InternalNetworksUpdateMaximumSetGen() NetworkFabricInternalNetworkResource networkFabricInternalNetwork = client.GetNetworkFabricInternalNetworkResource(networkFabricInternalNetworkResourceId); // invoke the operation - NetworkFabricInternalNetworkPatch patch = new NetworkFabricInternalNetworkPatch() + NetworkFabricInternalNetworkPatch patch = new NetworkFabricInternalNetworkPatch { Annotation = "annotation", Mtu = 1500, - ConnectedIPv4Subnets = -{ -new ConnectedSubnet("10.0.0.0/24") + ConnectedIPv4Subnets = {new ConnectedSubnet("10.0.0.0/24") { Annotation = "annotation", -} -}, - ConnectedIPv6Subnets = -{ -new ConnectedSubnet("3FFE:FFFF:0:CD30::a0/29") +}}, + ConnectedIPv6Subnets = {new ConnectedSubnet("3FFE:FFFF:0:CD30::a0/29") { Annotation = "annotation", -} -}, +}}, ImportRoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ExportRoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), - ImportRoutePolicy = new ImportRoutePolicy() + ImportRoutePolicy = new ImportRoutePolicy { ImportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ImportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), }, - ExportRoutePolicy = new ExportRoutePolicy() + ExportRoutePolicy = new ExportRoutePolicy { ExportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), ExportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), @@ -102,9 +123,9 @@ public async Task Update_InternalNetworksUpdateMaximumSetGen() IngressAclId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/accessControlLists/example-acl"), EgressAclId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/accessControlLists/example-acl"), IsMonitoringEnabled = IsMonitoringEnabled.True, - BgpConfiguration = new BgpConfiguration() + BgpConfiguration = new BgpConfiguration { - BfdConfiguration = new BfdConfiguration() + BfdConfiguration = new BfdConfiguration { IntervalInMilliSeconds = 300, Multiplier = 5, @@ -113,51 +134,27 @@ public async Task Update_InternalNetworksUpdateMaximumSetGen() AllowAS = 10, AllowASOverride = AllowASOverride.Enable, PeerAsn = 61234L, - IPv4ListenRangePrefixes = -{ -"10.1.0.0/25" -}, - IPv6ListenRangePrefixes = -{ -"2fff::/66" -}, - IPv4NeighborAddress = -{ -new NeighborAddress() + IPv4ListenRangePrefixes = { "10.1.0.0/25" }, + IPv6ListenRangePrefixes = { "2fff::/66" }, + IPv4NeighborAddress = {new NeighborAddress { Address = "10.1.0.0", -} -}, - IPv6NeighborAddress = -{ -new NeighborAddress() +}}, + IPv6NeighborAddress = {new NeighborAddress { Address = "2fff::", -} -}, +}}, Annotation = "annotation", }, - StaticRouteConfiguration = new StaticRouteConfiguration() + StaticRouteConfiguration = new StaticRouteConfiguration { - BfdConfiguration = new BfdConfiguration() + BfdConfiguration = new BfdConfiguration { IntervalInMilliSeconds = 300, Multiplier = 15, }, - IPv4Routes = -{ -new StaticRouteProperties("20.20.20.20/25",new string[] -{ -"10.0.0.1" -}) -}, - IPv6Routes = -{ -new StaticRouteProperties("2fff::/64",new string[] -{ -"3ffe::1" -}) -}, + IPv4Routes = { new StaticRouteProperties("20.20.20.20/25", new string[] { "10.0.0.1" }) }, + IPv6Routes = { new StaticRouteProperties("2fff::/64", new string[] { "3ffe::1" }) }, }, }; ArmOperation lro = await networkFabricInternalNetwork.UpdateAsync(WaitUntil.Completed, patch); @@ -170,33 +167,6 @@ public async Task Update_InternalNetworksUpdateMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_InternalNetworksDeleteMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternalNetworks_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "InternalNetworks_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkFabricInternalNetworkResource created on azure - // for more information of creating NetworkFabricInternalNetworkResource, please refer to the document of NetworkFabricInternalNetworkResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string l3IsolationDomainName = "example-l3domain"; - string internalNetworkName = "example-internalnetwork"; - ResourceIdentifier networkFabricInternalNetworkResourceId = NetworkFabricInternalNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, l3IsolationDomainName, internalNetworkName); - NetworkFabricInternalNetworkResource networkFabricInternalNetwork = client.GetNetworkFabricInternalNetworkResource(networkFabricInternalNetworkResourceId); - - // invoke the operation - await networkFabricInternalNetwork.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task UpdateAdministrativeState_InternalNetworksUpdateAdministrativeStateMaximumSetGen() @@ -219,13 +189,10 @@ public async Task UpdateAdministrativeState_InternalNetworksUpdateAdministrative NetworkFabricInternalNetworkResource networkFabricInternalNetwork = client.GetNetworkFabricInternalNetworkResource(networkFabricInternalNetworkResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabricInternalNetwork.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; @@ -255,13 +222,10 @@ public async Task UpdateBgpAdministrativeState_InternalNetworksUpdateBgpAdminist NetworkFabricInternalNetworkResource networkFabricInternalNetwork = client.GetNetworkFabricInternalNetworkResource(networkFabricInternalNetworkResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabricInternalNetwork.UpdateBgpAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; @@ -291,13 +255,10 @@ public async Task UpdateStaticRouteBfdAdministrativeState_InternalNetworksUpdate NetworkFabricInternalNetworkResource networkFabricInternalNetwork = client.GetNetworkFabricInternalNetworkResource(networkFabricInternalNetworkResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabricInternalNetwork.UpdateStaticRouteBfdAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayCollection.cs index 52f3752324584..86980114f7ef1 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayCollection.cs @@ -51,10 +51,10 @@ public async Task Get_InternetGatewaysGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_InternetGatewaysGetMaximumSetGen() + public async Task GetAll_InternetGatewaysListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGateways_Get_MaximumSet_Gen.json - // this example is just showing the usage of "InternetGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGateways_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "InternetGateways_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,16 +71,22 @@ public async Task Exists_InternetGatewaysGetMaximumSetGen() // get the collection of this NetworkFabricInternetGatewayResource NetworkFabricInternetGatewayCollection collection = resourceGroupResource.GetNetworkFabricInternetGateways(); - // invoke the operation - string internetGatewayName = "example-internetGateway"; - bool result = await collection.ExistsAsync(internetGatewayName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricInternetGatewayResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricInternetGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_InternetGatewaysGetMaximumSetGen() + public async Task Exists_InternetGatewaysGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGateways_Get_MaximumSet_Gen.json // this example is just showing the usage of "InternetGateways_Get" operation, for the dependent resources, they will have to be created separately. @@ -102,29 +108,17 @@ public async Task GetIfExists_InternetGatewaysGetMaximumSetGen() // invoke the operation string internetGatewayName = "example-internetGateway"; - NullableResponse response = await collection.GetIfExistsAsync(internetGatewayName); - NetworkFabricInternetGatewayResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(internetGatewayName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricInternetGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InternetGatewaysListByResourceGroupMaximumSetGen() + public async Task GetIfExists_InternetGatewaysGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGateways_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "InternetGateways_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGateways_Get_MaximumSet_Gen.json + // this example is just showing the usage of "InternetGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,17 +135,23 @@ public async Task GetAll_InternetGatewaysListByResourceGroupMaximumSetGen() // get the collection of this NetworkFabricInternetGatewayResource NetworkFabricInternetGatewayCollection collection = resourceGroupResource.GetNetworkFabricInternetGateways(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricInternetGatewayResource item in collection.GetAllAsync()) + // invoke the operation + string internetGatewayName = "example-internetGateway"; + NullableResponse response = await collection.GetIfExistsAsync(internetGatewayName); + NetworkFabricInternetGatewayResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricInternetGatewayData resourceData = item.Data; + NetworkFabricInternetGatewayData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayResource.cs index fe7140c996878..5f3eeca9e7b4f 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -68,12 +67,12 @@ public async Task Update_InternetGatewaysUpdateMaximumSetGen() NetworkFabricInternetGatewayResource networkFabricInternetGateway = client.GetNetworkFabricInternetGatewayResource(networkFabricInternetGatewayResourceId); // invoke the operation - NetworkFabricInternetGatewayPatch patch = new NetworkFabricInternetGatewayPatch() + NetworkFabricInternetGatewayPatch patch = new NetworkFabricInternetGatewayPatch { InternetGatewayRuleId = new ResourceIdentifier("/subscriptions/xxxx-xxxx-xxxx-xxxx/providers/Microsoft.ManagedNetworkFabric/internetGatewayRules/example-internetGatewayRule"), Tags = { -["key81"] = "2345", +["key81"] = "2345" }, }; ArmOperation lro = await networkFabricInternetGateway.UpdateAsync(WaitUntil.Completed, patch); @@ -85,36 +84,5 @@ public async Task Update_InternetGatewaysUpdateMaximumSetGen() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricInternetGateways_InternetGatewaysListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGateways_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "InternetGateways_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricInternetGatewayResource item in subscriptionResource.GetNetworkFabricInternetGatewaysAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricInternetGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayRuleCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayRuleCollection.cs index 7bd0281a0fe59..0ad233cf0d42a 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayRuleCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayRuleCollection.cs @@ -41,15 +41,12 @@ public async Task CreateOrUpdate_InternetGatewayRulesCreateMaximumSetGen() // invoke the operation string internetGatewayRuleName = "example-internetGatewayRule"; - NetworkFabricInternetGatewayRuleData data = new NetworkFabricInternetGatewayRuleData(new AzureLocation("eastus"), new InternetGatewayRules(InternetGatewayRuleAction.Allow, new string[] - { -"10.10.10.10" - })) + NetworkFabricInternetGatewayRuleData data = new NetworkFabricInternetGatewayRuleData(new AzureLocation("eastus"), new InternetGatewayRules(InternetGatewayRuleAction.Allow, new string[] { "10.10.10.10" })) { Annotation = "annotationValue", Tags = { -["keyID"] = "keyValue", +["keyID"] = "keyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, internetGatewayRuleName, data); @@ -97,10 +94,10 @@ public async Task Get_InternetGatewayRulesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_InternetGatewayRulesGetMaximumSetGen() + public async Task GetAll_InternetGatewayRulesListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_Get_MaximumSet_Gen.json - // this example is just showing the usage of "InternetGatewayRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "InternetGatewayRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,23 +107,29 @@ public async Task Exists_InternetGatewayRulesGetMaximumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; + string resourceGroupName = "example-internetGatewayRule"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this NetworkFabricInternetGatewayRuleResource NetworkFabricInternetGatewayRuleCollection collection = resourceGroupResource.GetNetworkFabricInternetGatewayRules(); - // invoke the operation - string internetGatewayRuleName = "example-internetGatewayRule"; - bool result = await collection.ExistsAsync(internetGatewayRuleName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricInternetGatewayRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricInternetGatewayRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_InternetGatewayRulesGetMaximumSetGen() + public async Task Exists_InternetGatewayRulesGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_Get_MaximumSet_Gen.json // this example is just showing the usage of "InternetGatewayRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +151,17 @@ public async Task GetIfExists_InternetGatewayRulesGetMaximumSetGen() // invoke the operation string internetGatewayRuleName = "example-internetGatewayRule"; - NullableResponse response = await collection.GetIfExistsAsync(internetGatewayRuleName); - NetworkFabricInternetGatewayRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(internetGatewayRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricInternetGatewayRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InternetGatewayRulesListByResourceGroupMaximumSetGen() + public async Task GetIfExists_InternetGatewayRulesGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "InternetGatewayRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_Get_MaximumSet_Gen.json + // this example is just showing the usage of "InternetGatewayRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,24 +171,30 @@ public async Task GetAll_InternetGatewayRulesListByResourceGroupMaximumSetGen() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-internetGatewayRule"; + string resourceGroupName = "example-rg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this NetworkFabricInternetGatewayRuleResource NetworkFabricInternetGatewayRuleCollection collection = resourceGroupResource.GetNetworkFabricInternetGatewayRules(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricInternetGatewayRuleResource item in collection.GetAllAsync()) + // invoke the operation + string internetGatewayRuleName = "example-internetGatewayRule"; + NullableResponse response = await collection.GetIfExistsAsync(internetGatewayRuleName); + NetworkFabricInternetGatewayRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricInternetGatewayRuleData resourceData = item.Data; + NetworkFabricInternetGatewayRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayRuleResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayRuleResource.cs index 14448d5111878..0694250a55272 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayRuleResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricInternetGatewayRuleResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -49,10 +48,10 @@ public async Task Get_InternetGatewayRulesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_InternetGatewayRulesUpdateMaximumSetGen() + public async Task Delete_InternetGatewayRulesDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_Update_MaximumSet_Gen.json - // this example is just showing the usage of "InternetGatewayRules_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "InternetGatewayRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_InternetGatewayRulesUpdateMaximumSetGen() NetworkFabricInternetGatewayRuleResource networkFabricInternetGatewayRule = client.GetNetworkFabricInternetGatewayRuleResource(networkFabricInternetGatewayRuleResourceId); // invoke the operation - NetworkFabricInternetGatewayRulePatch patch = new NetworkFabricInternetGatewayRulePatch() - { - Tags = -{ -["key3311"] = "1234", -}, - }; - ArmOperation lro = await networkFabricInternetGatewayRule.UpdateAsync(WaitUntil.Completed, patch); - NetworkFabricInternetGatewayRuleResource result = lro.Value; + await networkFabricInternetGatewayRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricInternetGatewayRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_InternetGatewayRulesDeleteMaximumSetGen() + public async Task Update_InternetGatewayRulesUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "InternetGatewayRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_Update_MaximumSet_Gen.json + // this example is just showing the usage of "InternetGatewayRules_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_InternetGatewayRulesDeleteMaximumSetGen() NetworkFabricInternetGatewayRuleResource networkFabricInternetGatewayRule = client.GetNetworkFabricInternetGatewayRuleResource(networkFabricInternetGatewayRuleResourceId); // invoke the operation - await networkFabricInternetGatewayRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricInternetGatewayRules_InternetGatewayRulesListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "InternetGatewayRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricInternetGatewayRuleResource item in subscriptionResource.GetNetworkFabricInternetGatewayRulesAsync()) + NetworkFabricInternetGatewayRulePatch patch = new NetworkFabricInternetGatewayRulePatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricInternetGatewayRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key3311"] = "1234" +}, + }; + ArmOperation lro = await networkFabricInternetGatewayRule.UpdateAsync(WaitUntil.Completed, patch); + NetworkFabricInternetGatewayRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricInternetGatewayRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL2IsolationDomainCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL2IsolationDomainCollection.cs index 709649963f6d4..f72b107b6d436 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL2IsolationDomainCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL2IsolationDomainCollection.cs @@ -46,7 +46,7 @@ public async Task CreateOrUpdate_L2IsolationDomainsCreateMaximumSetGen() Mtu = 1500, Tags = { -["keyID"] = "keyValue", +["keyID"] = "keyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, l2IsolationDomainName, data); @@ -94,10 +94,10 @@ public async Task Get_L2IsolationDomainsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_L2IsolationDomainsGetMaximumSetGen() + public async Task GetAll_L2IsolationDomainsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_Get_MaximumSet_Gen.json - // this example is just showing the usage of "L2IsolationDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "L2IsolationDomains_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +114,22 @@ public async Task Exists_L2IsolationDomainsGetMaximumSetGen() // get the collection of this NetworkFabricL2IsolationDomainResource NetworkFabricL2IsolationDomainCollection collection = resourceGroupResource.GetNetworkFabricL2IsolationDomains(); - // invoke the operation - string l2IsolationDomainName = "example-l2Domain"; - bool result = await collection.ExistsAsync(l2IsolationDomainName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricL2IsolationDomainResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricL2IsolationDomainData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_L2IsolationDomainsGetMaximumSetGen() + public async Task Exists_L2IsolationDomainsGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_Get_MaximumSet_Gen.json // this example is just showing the usage of "L2IsolationDomains_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +151,17 @@ public async Task GetIfExists_L2IsolationDomainsGetMaximumSetGen() // invoke the operation string l2IsolationDomainName = "example-l2Domain"; - NullableResponse response = await collection.GetIfExistsAsync(l2IsolationDomainName); - NetworkFabricL2IsolationDomainResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(l2IsolationDomainName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricL2IsolationDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_L2IsolationDomainsListByResourceGroupMaximumSetGen() + public async Task GetIfExists_L2IsolationDomainsGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "L2IsolationDomains_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_Get_MaximumSet_Gen.json + // this example is just showing the usage of "L2IsolationDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_L2IsolationDomainsListByResourceGroupMaximumSetGen() // get the collection of this NetworkFabricL2IsolationDomainResource NetworkFabricL2IsolationDomainCollection collection = resourceGroupResource.GetNetworkFabricL2IsolationDomains(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricL2IsolationDomainResource item in collection.GetAllAsync()) + // invoke the operation + string l2IsolationDomainName = "example-l2Domain"; + NullableResponse response = await collection.GetIfExistsAsync(l2IsolationDomainName); + NetworkFabricL2IsolationDomainResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricL2IsolationDomainData resourceData = item.Data; + NetworkFabricL2IsolationDomainData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL2IsolationDomainResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL2IsolationDomainResource.cs index 9766e4cc3ae3d..f2799aada0b79 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL2IsolationDomainResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL2IsolationDomainResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -49,10 +48,10 @@ public async Task Get_L2IsolationDomainsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_L2IsolationDomainsUpdateMaximumSetGen() + public async Task Delete_L2IsolationDomainsDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_Update_MaximumSet_Gen.json - // this example is just showing the usage of "L2IsolationDomains_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "L2IsolationDomains_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,31 +67,17 @@ public async Task Update_L2IsolationDomainsUpdateMaximumSetGen() NetworkFabricL2IsolationDomainResource networkFabricL2IsolationDomain = client.GetNetworkFabricL2IsolationDomainResource(networkFabricL2IsolationDomainResourceId); // invoke the operation - NetworkFabricL2IsolationDomainPatch patch = new NetworkFabricL2IsolationDomainPatch() - { - Annotation = "annotation1", - Mtu = 6000, - Tags = -{ -["keyID"] = "keyValue", -}, - }; - ArmOperation lro = await networkFabricL2IsolationDomain.UpdateAsync(WaitUntil.Completed, patch); - NetworkFabricL2IsolationDomainResource result = lro.Value; + await networkFabricL2IsolationDomain.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricL2IsolationDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_L2IsolationDomainsDeleteMaximumSetGen() + public async Task Update_L2IsolationDomainsUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "L2IsolationDomains_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_Update_MaximumSet_Gen.json + // this example is just showing the usage of "L2IsolationDomains_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +93,23 @@ public async Task Delete_L2IsolationDomainsDeleteMaximumSetGen() NetworkFabricL2IsolationDomainResource networkFabricL2IsolationDomain = client.GetNetworkFabricL2IsolationDomainResource(networkFabricL2IsolationDomainResourceId); // invoke the operation - await networkFabricL2IsolationDomain.DeleteAsync(WaitUntil.Completed); + NetworkFabricL2IsolationDomainPatch patch = new NetworkFabricL2IsolationDomainPatch + { + Annotation = "annotation1", + Mtu = 6000, + Tags = +{ +["keyID"] = "keyValue" +}, + }; + ArmOperation lro = await networkFabricL2IsolationDomain.UpdateAsync(WaitUntil.Completed, patch); + NetworkFabricL2IsolationDomainResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricL2IsolationDomainData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -134,13 +133,10 @@ public async Task UpdateAdministrativeState_L2IsolationDomainsUpdateAdministrati NetworkFabricL2IsolationDomainResource networkFabricL2IsolationDomain = client.GetNetworkFabricL2IsolationDomainResource(networkFabricL2IsolationDomainResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabricL2IsolationDomain.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); DeviceUpdateCommonPostActionResult result = lro.Value; @@ -201,36 +197,5 @@ public async Task CommitConfiguration_L2IsolationDomainsCommitConfigurationMaxim Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricL2IsolationDomains_L2IsolationDomainsListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "L2IsolationDomains_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricL2IsolationDomainResource item in subscriptionResource.GetNetworkFabricL2IsolationDomainsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricL2IsolationDomainData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL3IsolationDomainCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL3IsolationDomainCollection.cs index 206626317bcfb..7a42dd78ddf2f 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL3IsolationDomainCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL3IsolationDomainCollection.cs @@ -46,21 +46,15 @@ public async Task CreateOrUpdate_L3IsolationDomainsCreateMaximumSetGen() Annotation = "annotation", RedistributeConnectedSubnets = RedistributeConnectedSubnet.True, RedistributeStaticRoutes = RedistributeStaticRoute.False, - AggregateRouteConfiguration = new AggregateRouteConfiguration() + AggregateRouteConfiguration = new AggregateRouteConfiguration { - IPv4Routes = -{ -new AggregateRoute("10.0.0.0/24") -}, - IPv6Routes = -{ -new AggregateRoute("3FFE:FFFF:0:CD30::a0/29") -}, + IPv4Routes = { new AggregateRoute("10.0.0.0/24") }, + IPv6Routes = { new AggregateRoute("3FFE:FFFF:0:CD30::a0/29") }, }, - ConnectedSubnetRoutePolicy = new ConnectedSubnetRoutePolicy() + ConnectedSubnetRoutePolicy = new ConnectedSubnetRoutePolicy { ExportRoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), - ExportRoutePolicy = new L3ExportRoutePolicy() + ExportRoutePolicy = new L3ExportRoutePolicy { ExportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy"), ExportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy"), @@ -68,7 +62,7 @@ public async Task CreateOrUpdate_L3IsolationDomainsCreateMaximumSetGen() }, Tags = { -["keyID"] = "KeyValue", +["keyID"] = "KeyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, l3IsolationDomainName, data); @@ -116,10 +110,10 @@ public async Task Get_L3IsolationDomainsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_L3IsolationDomainsGetMaximumSetGen() + public async Task GetAll_L3IsolationDomainsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L3IsolationDomains_Get_MaximumSet_Gen.json - // this example is just showing the usage of "L3IsolationDomains_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L3IsolationDomains_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "L3IsolationDomains_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,16 +130,22 @@ public async Task Exists_L3IsolationDomainsGetMaximumSetGen() // get the collection of this NetworkFabricL3IsolationDomainResource NetworkFabricL3IsolationDomainCollection collection = resourceGroupResource.GetNetworkFabricL3IsolationDomains(); - // invoke the operation - string l3IsolationDomainName = "example-l3domain"; - bool result = await collection.ExistsAsync(l3IsolationDomainName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricL3IsolationDomainResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricL3IsolationDomainData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_L3IsolationDomainsGetMaximumSetGen() + public async Task Exists_L3IsolationDomainsGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L3IsolationDomains_Get_MaximumSet_Gen.json // this example is just showing the usage of "L3IsolationDomains_Get" operation, for the dependent resources, they will have to be created separately. @@ -167,29 +167,17 @@ public async Task GetIfExists_L3IsolationDomainsGetMaximumSetGen() // invoke the operation string l3IsolationDomainName = "example-l3domain"; - NullableResponse response = await collection.GetIfExistsAsync(l3IsolationDomainName); - NetworkFabricL3IsolationDomainResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(l3IsolationDomainName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricL3IsolationDomainData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_L3IsolationDomainsListByResourceGroupMaximumSetGen() + public async Task GetIfExists_L3IsolationDomainsGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L3IsolationDomains_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "L3IsolationDomains_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L3IsolationDomains_Get_MaximumSet_Gen.json + // this example is just showing the usage of "L3IsolationDomains_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -206,17 +194,23 @@ public async Task GetAll_L3IsolationDomainsListByResourceGroupMaximumSetGen() // get the collection of this NetworkFabricL3IsolationDomainResource NetworkFabricL3IsolationDomainCollection collection = resourceGroupResource.GetNetworkFabricL3IsolationDomains(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricL3IsolationDomainResource item in collection.GetAllAsync()) + // invoke the operation + string l3IsolationDomainName = "example-l3domain"; + NullableResponse response = await collection.GetIfExistsAsync(l3IsolationDomainName); + NetworkFabricL3IsolationDomainResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricL3IsolationDomainData resourceData = item.Data; + NetworkFabricL3IsolationDomainData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL3IsolationDomainResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL3IsolationDomainResource.cs index 95a00f84ed4ce..ac1a7b833f861 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL3IsolationDomainResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricL3IsolationDomainResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -47,6 +46,32 @@ public async Task Get_L3IsolationDomainsGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_L3IsolationDomainsDeleteMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L3IsolationDomains_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "L3IsolationDomains_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkFabricL3IsolationDomainResource created on azure + // for more information of creating NetworkFabricL3IsolationDomainResource, please refer to the document of NetworkFabricL3IsolationDomainResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string l3IsolationDomainName = "example-l3domain"; + ResourceIdentifier networkFabricL3IsolationDomainResourceId = NetworkFabricL3IsolationDomainResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, l3IsolationDomainName); + NetworkFabricL3IsolationDomainResource networkFabricL3IsolationDomain = client.GetNetworkFabricL3IsolationDomainResource(networkFabricL3IsolationDomainResourceId); + + // invoke the operation + await networkFabricL3IsolationDomain.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_L3IsolationDomainsUpdateMaximumSetGen() @@ -68,26 +93,20 @@ public async Task Update_L3IsolationDomainsUpdateMaximumSetGen() NetworkFabricL3IsolationDomainResource networkFabricL3IsolationDomain = client.GetNetworkFabricL3IsolationDomainResource(networkFabricL3IsolationDomainResourceId); // invoke the operation - NetworkFabricL3IsolationDomainPatch patch = new NetworkFabricL3IsolationDomainPatch() + NetworkFabricL3IsolationDomainPatch patch = new NetworkFabricL3IsolationDomainPatch { Annotation = "annotation1", RedistributeConnectedSubnets = RedistributeConnectedSubnet.True, RedistributeStaticRoutes = RedistributeStaticRoute.False, - AggregateRouteConfiguration = new AggregateRouteConfiguration() + AggregateRouteConfiguration = new AggregateRouteConfiguration { - IPv4Routes = -{ -new AggregateRoute("10.0.0.0/24") -}, - IPv6Routes = -{ -new AggregateRoute("3FFE:FFFF:0:CD30::a0/29") -}, + IPv4Routes = { new AggregateRoute("10.0.0.0/24") }, + IPv6Routes = { new AggregateRoute("3FFE:FFFF:0:CD30::a0/29") }, }, - ConnectedSubnetRoutePolicy = new ConnectedSubnetRoutePolicy() + ConnectedSubnetRoutePolicy = new ConnectedSubnetRoutePolicy { ExportRoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/routePolicyName"), - ExportRoutePolicy = new L3ExportRoutePolicy() + ExportRoutePolicy = new L3ExportRoutePolicy { ExportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy1"), ExportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy1"), @@ -95,7 +114,7 @@ public async Task Update_L3IsolationDomainsUpdateMaximumSetGen() }, Tags = { -["key4953"] = "1234", +["key4953"] = "1234" }, }; ArmOperation lro = await networkFabricL3IsolationDomain.UpdateAsync(WaitUntil.Completed, patch); @@ -108,63 +127,6 @@ public async Task Update_L3IsolationDomainsUpdateMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_L3IsolationDomainsDeleteMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L3IsolationDomains_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "L3IsolationDomains_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkFabricL3IsolationDomainResource created on azure - // for more information of creating NetworkFabricL3IsolationDomainResource, please refer to the document of NetworkFabricL3IsolationDomainResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string l3IsolationDomainName = "example-l3domain"; - ResourceIdentifier networkFabricL3IsolationDomainResourceId = NetworkFabricL3IsolationDomainResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, l3IsolationDomainName); - NetworkFabricL3IsolationDomainResource networkFabricL3IsolationDomain = client.GetNetworkFabricL3IsolationDomainResource(networkFabricL3IsolationDomainResourceId); - - // invoke the operation - await networkFabricL3IsolationDomain.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricL3IsolationDomains_L3IsolationDomainsListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L3IsolationDomains_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "L3IsolationDomains_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricL3IsolationDomainResource item in subscriptionResource.GetNetworkFabricL3IsolationDomainsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricL3IsolationDomainData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task UpdateAdministrativeState_L3IsolationDomainsUpdateAdministrativeStateMaximumSetGen() @@ -186,13 +148,10 @@ public async Task UpdateAdministrativeState_L3IsolationDomainsUpdateAdministrati NetworkFabricL3IsolationDomainResource networkFabricL3IsolationDomain = client.GetNetworkFabricL3IsolationDomainResource(networkFabricL3IsolationDomainResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabricL3IsolationDomain.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); DeviceUpdateCommonPostActionResult result = lro.Value; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricNeighborGroupCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricNeighborGroupCollection.cs index f0c773fc0e2c9..989041b70e0f8 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricNeighborGroupCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricNeighborGroupCollection.cs @@ -45,20 +45,14 @@ public async Task CreateOrUpdate_NeighborGroupsCreateMaximumSetGen() NetworkFabricNeighborGroupData data = new NetworkFabricNeighborGroupData(new AzureLocation("eastus")) { Annotation = "annotation", - Destination = new NeighborGroupDestination() + Destination = new NeighborGroupDestination { - IPv4Addresses = -{ -IPAddress.Parse("10.10.10.10"),IPAddress.Parse("20.10.10.10"),IPAddress.Parse("30.10.10.10"),IPAddress.Parse("40.10.10.10"),IPAddress.Parse("50.10.10.10"),IPAddress.Parse("60.10.10.10"),IPAddress.Parse("70.10.10.10"),IPAddress.Parse("80.10.10.10"),IPAddress.Parse("90.10.10.10") -}, - IPv6Addresses = -{ -"2F::/100" -}, + IPv4Addresses = { IPAddress.Parse("10.10.10.10"), IPAddress.Parse("20.10.10.10"), IPAddress.Parse("30.10.10.10"), IPAddress.Parse("40.10.10.10"), IPAddress.Parse("50.10.10.10"), IPAddress.Parse("60.10.10.10"), IPAddress.Parse("70.10.10.10"), IPAddress.Parse("80.10.10.10"), IPAddress.Parse("90.10.10.10") }, + IPv6Addresses = { "2F::/100" }, }, Tags = { -["key8107"] = "1234", +["key8107"] = "1234" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, neighborGroupName, data); @@ -106,10 +100,10 @@ public async Task Get_NeighborGroupsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NeighborGroupsGetMaximumSetGen() + public async Task GetAll_NeighborGroupsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NeighborGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "NeighborGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -126,16 +120,22 @@ public async Task Exists_NeighborGroupsGetMaximumSetGen() // get the collection of this NetworkFabricNeighborGroupResource NetworkFabricNeighborGroupCollection collection = resourceGroupResource.GetNetworkFabricNeighborGroups(); - // invoke the operation - string neighborGroupName = "example-neighborGroup"; - bool result = await collection.ExistsAsync(neighborGroupName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricNeighborGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricNeighborGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NeighborGroupsGetMaximumSetGen() + public async Task Exists_NeighborGroupsGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_Get_MaximumSet_Gen.json // this example is just showing the usage of "NeighborGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -157,29 +157,17 @@ public async Task GetIfExists_NeighborGroupsGetMaximumSetGen() // invoke the operation string neighborGroupName = "example-neighborGroup"; - NullableResponse response = await collection.GetIfExistsAsync(neighborGroupName); - NetworkFabricNeighborGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(neighborGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricNeighborGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NeighborGroupsListByResourceGroupMaximumSetGen() + public async Task GetIfExists_NeighborGroupsGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "NeighborGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NeighborGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,17 +184,23 @@ public async Task GetAll_NeighborGroupsListByResourceGroupMaximumSetGen() // get the collection of this NetworkFabricNeighborGroupResource NetworkFabricNeighborGroupCollection collection = resourceGroupResource.GetNetworkFabricNeighborGroups(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricNeighborGroupResource item in collection.GetAllAsync()) + // invoke the operation + string neighborGroupName = "example-neighborGroup"; + NullableResponse response = await collection.GetIfExistsAsync(neighborGroupName); + NetworkFabricNeighborGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricNeighborGroupData resourceData = item.Data; + NetworkFabricNeighborGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricNeighborGroupResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricNeighborGroupResource.cs index 059f4f9e97107..ce9953c2b1a3d 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricNeighborGroupResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricNeighborGroupResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -50,10 +49,10 @@ public async Task Get_NeighborGroupsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NeighborGroupsUpdateMaximumSetGen() + public async Task Delete_NeighborGroupsDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_Update_MaximumSet_Gen.json - // this example is just showing the usage of "NeighborGroups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "NeighborGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,41 +68,17 @@ public async Task Update_NeighborGroupsUpdateMaximumSetGen() NetworkFabricNeighborGroupResource networkFabricNeighborGroup = client.GetNetworkFabricNeighborGroupResource(networkFabricNeighborGroupResourceId); // invoke the operation - NetworkFabricNeighborGroupPatch patch = new NetworkFabricNeighborGroupPatch() - { - Annotation = "Updating", - Destination = new NeighborGroupDestination() - { - IPv4Addresses = -{ -IPAddress.Parse("10.10.10.10"),IPAddress.Parse("20.10.10.10"),IPAddress.Parse("30.10.10.10"),IPAddress.Parse("40.10.10.10"),IPAddress.Parse("50.10.10.10"),IPAddress.Parse("60.10.10.10"),IPAddress.Parse("70.10.10.10"),IPAddress.Parse("80.10.10.10"),IPAddress.Parse("90.10.10.10") -}, - IPv6Addresses = -{ -"2F::/100" -}, - }, - Tags = -{ -["key8107"] = "2345", -}, - }; - ArmOperation lro = await networkFabricNeighborGroup.UpdateAsync(WaitUntil.Completed, patch); - NetworkFabricNeighborGroupResource result = lro.Value; + await networkFabricNeighborGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricNeighborGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NeighborGroupsDeleteMaximumSetGen() + public async Task Update_NeighborGroupsUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "NeighborGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_Update_MaximumSet_Gen.json + // this example is just showing the usage of "NeighborGroups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -119,40 +94,27 @@ public async Task Delete_NeighborGroupsDeleteMaximumSetGen() NetworkFabricNeighborGroupResource networkFabricNeighborGroup = client.GetNetworkFabricNeighborGroupResource(networkFabricNeighborGroupResourceId); // invoke the operation - await networkFabricNeighborGroup.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricNeighborGroups_NeighborGroupsListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "NeighborGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricNeighborGroupResource item in subscriptionResource.GetNetworkFabricNeighborGroupsAsync()) + NetworkFabricNeighborGroupPatch patch = new NetworkFabricNeighborGroupPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricNeighborGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Annotation = "Updating", + Destination = new NeighborGroupDestination + { + IPv4Addresses = { IPAddress.Parse("10.10.10.10"), IPAddress.Parse("20.10.10.10"), IPAddress.Parse("30.10.10.10"), IPAddress.Parse("40.10.10.10"), IPAddress.Parse("50.10.10.10"), IPAddress.Parse("60.10.10.10"), IPAddress.Parse("70.10.10.10"), IPAddress.Parse("80.10.10.10"), IPAddress.Parse("90.10.10.10") }, + IPv6Addresses = { "2F::/100" }, + }, + Tags = +{ +["key8107"] = "2345" +}, + }; + ArmOperation lro = await networkFabricNeighborGroup.UpdateAsync(WaitUntil.Completed, patch); + NetworkFabricNeighborGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricNeighborGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricResource.cs index d8b22adf3af36..77eff1186c1f4 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -47,6 +46,32 @@ public async Task Get_NetworkFabricsGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NetworkFabricsDeleteMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabrics_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabrics_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkFabricResource created on azure + // for more information of creating NetworkFabricResource, please refer to the document of NetworkFabricResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string networkFabricName = "example-fabric"; + ResourceIdentifier networkFabricResourceId = NetworkFabricResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkFabricName); + NetworkFabricResource networkFabric = client.GetNetworkFabricResource(networkFabricResourceId); + + // invoke the operation + await networkFabric.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_NetworkFabricsUpdateMaximumSetGen() @@ -68,7 +93,7 @@ public async Task Update_NetworkFabricsUpdateMaximumSetGen() NetworkFabricResource networkFabric = client.GetNetworkFabricResource(networkFabricResourceId); // invoke the operation - NetworkFabricPatch patch = new NetworkFabricPatch() + NetworkFabricPatch patch = new NetworkFabricPatch { Annotation = "annotation1", RackCount = 6, @@ -76,7 +101,7 @@ public async Task Update_NetworkFabricsUpdateMaximumSetGen() IPv4Prefix = "10.18.0.0/17", IPv6Prefix = "3FFE:FFFF:0:CD40::/60", FabricAsn = 12345L, - TerminalServerConfiguration = new NetworkFabricPatchablePropertiesTerminalServerConfiguration() + TerminalServerConfiguration = new NetworkFabricPatchablePropertiesTerminalServerConfiguration { PrimaryIPv4Prefix = "10.0.0.12/30", PrimaryIPv6Prefix = "4FFE:FFFF:0:CD30::a8/127", @@ -86,43 +111,25 @@ public async Task Update_NetworkFabricsUpdateMaximumSetGen() Password = "xxxxxxxx", SerialNumber = "1234567", }, - ManagementNetworkConfiguration = new ManagementNetworkConfigurationPatchableProperties() + ManagementNetworkConfiguration = new ManagementNetworkConfigurationPatchableProperties { - InfrastructureVpnConfiguration = new VpnConfigurationPatchableProperties() + InfrastructureVpnConfiguration = new VpnConfigurationPatchableProperties { NetworkToNetworkInterconnectId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkFabrics/example-fabric/networkToNetworkInterconnects/example-nni"), PeeringOption = PeeringOption.OptionB, - OptionBProperties = new OptionBProperties() + OptionBProperties = new OptionBProperties { - ImportRouteTargets = -{ -"65046:10050" -}, - ExportRouteTargets = -{ -"65046:10050" -}, - RouteTargets = new RouteTargetInformation() + ImportRouteTargets = { "65046:10050" }, + ExportRouteTargets = { "65046:10050" }, + RouteTargets = new RouteTargetInformation { - ImportIPv4RouteTargets = -{ -"65046:10050" -}, - ImportIPv6RouteTargets = -{ -"65046:10050" -}, - ExportIPv4RouteTargets = -{ -"65046:10050" -}, - ExportIPv6RouteTargets = -{ -"65046:10050" -}, + ImportIPv4RouteTargets = { "65046:10050" }, + ImportIPv6RouteTargets = { "65046:10050" }, + ExportIPv4RouteTargets = { "65046:10050" }, + ExportIPv6RouteTargets = { "65046:10050" }, }, }, - OptionAProperties = new VpnConfigurationPatchableOptionAProperties() + OptionAProperties = new VpnConfigurationPatchableOptionAProperties { PrimaryIPv4Prefix = "10.0.0.12/30", PrimaryIPv6Prefix = "4FFE:FFFF:0:CD30::a8/127", @@ -131,48 +138,30 @@ public async Task Update_NetworkFabricsUpdateMaximumSetGen() Mtu = 1501, VlanId = 3001, PeerAsn = 1235L, - BfdConfiguration = new BfdConfiguration() + BfdConfiguration = new BfdConfiguration { IntervalInMilliSeconds = 300, Multiplier = 10, }, }, }, - WorkloadVpnConfiguration = new VpnConfigurationPatchableProperties() + WorkloadVpnConfiguration = new VpnConfigurationPatchableProperties { NetworkToNetworkInterconnectId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkFabrics/example-fabric/networkToNetworkInterconnects/example-nni"), PeeringOption = PeeringOption.OptionA, - OptionBProperties = new OptionBProperties() + OptionBProperties = new OptionBProperties { - ImportRouteTargets = -{ -"65046:10050" -}, - ExportRouteTargets = -{ -"65046:10050" -}, - RouteTargets = new RouteTargetInformation() + ImportRouteTargets = { "65046:10050" }, + ExportRouteTargets = { "65046:10050" }, + RouteTargets = new RouteTargetInformation { - ImportIPv4RouteTargets = -{ -"65046:10050" -}, - ImportIPv6RouteTargets = -{ -"65046:10050" -}, - ExportIPv4RouteTargets = -{ -"65046:10050" -}, - ExportIPv6RouteTargets = -{ -"65046:10050" -}, + ImportIPv4RouteTargets = { "65046:10050" }, + ImportIPv6RouteTargets = { "65046:10050" }, + ExportIPv4RouteTargets = { "65046:10050" }, + ExportIPv6RouteTargets = { "65046:10050" }, }, }, - OptionAProperties = new VpnConfigurationPatchableOptionAProperties() + OptionAProperties = new VpnConfigurationPatchableOptionAProperties { PrimaryIPv4Prefix = "10.0.0.14/30", PrimaryIPv6Prefix = "2FFE:FFFF:0:CD30::a7/126", @@ -181,7 +170,7 @@ public async Task Update_NetworkFabricsUpdateMaximumSetGen() Mtu = 1500, VlanId = 3000, PeerAsn = 61234L, - BfdConfiguration = new BfdConfiguration() + BfdConfiguration = new BfdConfiguration { IntervalInMilliSeconds = 300, Multiplier = 5, @@ -191,7 +180,7 @@ public async Task Update_NetworkFabricsUpdateMaximumSetGen() }, Tags = { -["keyID"] = "KeyValue", +["keyID"] = "KeyValue" }, }; ArmOperation lro = await networkFabric.UpdateAsync(WaitUntil.Completed, patch); @@ -204,63 +193,6 @@ public async Task Update_NetworkFabricsUpdateMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkFabricsDeleteMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabrics_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabrics_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkFabricResource created on azure - // for more information of creating NetworkFabricResource, please refer to the document of NetworkFabricResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string networkFabricName = "example-fabric"; - ResourceIdentifier networkFabricResourceId = NetworkFabricResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkFabricName); - NetworkFabricResource networkFabric = client.GetNetworkFabricResource(networkFabricResourceId); - - // invoke the operation - await networkFabric.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabrics_NetworkFabricsListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabrics_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabrics_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricResource item in subscriptionResource.GetNetworkFabricsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Provision_NetworkFabricsProvisionMaximumSetGen() @@ -336,7 +268,7 @@ public async Task Upgrade_NetworkFabricsUpgradeMaximumSetGen() NetworkFabricResource networkFabric = client.GetNetworkFabricResource(networkFabricResourceId); // invoke the operation - NetworkFabricUpdateVersionContent content = new NetworkFabricUpdateVersionContent() + NetworkFabricUpdateVersionContent content = new NetworkFabricUpdateVersionContent { Version = "version1", }; @@ -394,13 +326,10 @@ public async Task UpdateWorkloadManagementBfdConfiguration_NetworkFabricsUpdateW NetworkFabricResource networkFabric = client.GetNetworkFabricResource(networkFabricResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabric.UpdateWorkloadManagementBfdConfigurationAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; @@ -429,13 +358,10 @@ public async Task UpdateInfraManagementBfdConfiguration_NetworkFabricsUpdateInfr NetworkFabricResource networkFabric = client.GetNetworkFabricResource(networkFabricResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabric.UpdateInfraManagementBfdConfigurationAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; @@ -464,7 +390,7 @@ public async Task ValidateConfiguration_NetworkFabricsValidateConfigurationMaxim NetworkFabricResource networkFabric = client.GetNetworkFabricResource(networkFabricResourceId); // invoke the operation - ValidateConfigurationContent content = new ValidateConfigurationContent() + ValidateConfigurationContent content = new ValidateConfigurationContent { ValidateAction = NetworkFabricValidateAction.Cabling, }; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricRoutePolicyCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricRoutePolicyCollection.cs index 4840c8aa485b0..b25f381cb1949 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricRoutePolicyCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricRoutePolicyCollection.cs @@ -45,62 +45,35 @@ public async Task CreateOrUpdate_RoutePoliciesCreateMaximumSetGen() { Annotation = "annotation", DefaultAction = CommunityActionType.Deny, - Statements = -{ -new RoutePolicyStatementProperties(7L,new StatementConditionProperties() + Statements = {new RoutePolicyStatementProperties(7L, new StatementConditionProperties { RoutePolicyConditionType = RoutePolicyConditionType.Or, IPPrefixId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipPrefixes/example-ipPrefix"), -IPExtendedCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity") -}, -IPCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity") -}, -},new StatementActionProperties(RoutePolicyActionType.Permit) +IPExtendedCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity")}, +IPCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity")}, +}, new StatementActionProperties(RoutePolicyActionType.Permit) { LocalPreference = 20L, -IPCommunityProperties = new ActionIPCommunityProperties() -{ -DeleteIPCommunityIds = +IPCommunityProperties = new ActionIPCommunityProperties { -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity") +DeleteIPCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity")}, +SetIPCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity")}, +AddIPCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity")}, }, -SetIPCommunityIds = +IPExtendedCommunityProperties = new ActionIPExtendedCommunityProperties { -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity") -}, -AddIPCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity") -}, -}, -IPExtendedCommunityProperties = new ActionIPExtendedCommunityProperties() -{ -DeleteIPExtendedCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity") -}, -SetIPExtendedCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity") -}, -AddIPExtendedCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity") -}, +DeleteIPExtendedCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity")}, +SetIPExtendedCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity")}, +AddIPExtendedCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity")}, }, }) { Annotation = "annotation", -} -}, +}}, AddressFamilyType = AddressFamilyType.IPv4, Tags = { -["keyID"] = "keyValue", +["keyID"] = "keyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routePolicyName, data); @@ -148,10 +121,10 @@ public async Task Get_RoutePoliciesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RoutePoliciesGetMaximumSetGen() + public async Task GetAll_RoutePoliciesListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/RoutePolicies_Get_MaximumSet_Gen.json - // this example is just showing the usage of "RoutePolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/RoutePolicies_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "RoutePolicies_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -168,16 +141,22 @@ public async Task Exists_RoutePoliciesGetMaximumSetGen() // get the collection of this NetworkFabricRoutePolicyResource NetworkFabricRoutePolicyCollection collection = resourceGroupResource.GetNetworkFabricRoutePolicies(); - // invoke the operation - string routePolicyName = "example-routePolicy"; - bool result = await collection.ExistsAsync(routePolicyName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricRoutePolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricRoutePolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RoutePoliciesGetMaximumSetGen() + public async Task Exists_RoutePoliciesGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/RoutePolicies_Get_MaximumSet_Gen.json // this example is just showing the usage of "RoutePolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -199,29 +178,17 @@ public async Task GetIfExists_RoutePoliciesGetMaximumSetGen() // invoke the operation string routePolicyName = "example-routePolicy"; - NullableResponse response = await collection.GetIfExistsAsync(routePolicyName); - NetworkFabricRoutePolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(routePolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricRoutePolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RoutePoliciesListByResourceGroupMaximumSetGen() + public async Task GetIfExists_RoutePoliciesGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/RoutePolicies_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "RoutePolicies_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/RoutePolicies_Get_MaximumSet_Gen.json + // this example is just showing the usage of "RoutePolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -238,17 +205,23 @@ public async Task GetAll_RoutePoliciesListByResourceGroupMaximumSetGen() // get the collection of this NetworkFabricRoutePolicyResource NetworkFabricRoutePolicyCollection collection = resourceGroupResource.GetNetworkFabricRoutePolicies(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricRoutePolicyResource item in collection.GetAllAsync()) + // invoke the operation + string routePolicyName = "example-routePolicy"; + NullableResponse response = await collection.GetIfExistsAsync(routePolicyName); + NetworkFabricRoutePolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricRoutePolicyData resourceData = item.Data; + NetworkFabricRoutePolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricRoutePolicyResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricRoutePolicyResource.cs index acdf90d26b8ed..d5a0cd5628d0d 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricRoutePolicyResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricRoutePolicyResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -47,6 +46,32 @@ public async Task Get_RoutePoliciesGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_RoutePoliciesDeleteMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/RoutePolicies_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "RoutePolicies_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkFabricRoutePolicyResource created on azure + // for more information of creating NetworkFabricRoutePolicyResource, please refer to the document of NetworkFabricRoutePolicyResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string routePolicyName = "example-routePolicy"; + ResourceIdentifier networkFabricRoutePolicyResourceId = NetworkFabricRoutePolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, routePolicyName); + NetworkFabricRoutePolicyResource networkFabricRoutePolicy = client.GetNetworkFabricRoutePolicyResource(networkFabricRoutePolicyResourceId); + + // invoke the operation + await networkFabricRoutePolicy.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_RoutePoliciesUpdateMaximumSetGen() @@ -68,64 +93,37 @@ public async Task Update_RoutePoliciesUpdateMaximumSetGen() NetworkFabricRoutePolicyResource networkFabricRoutePolicy = client.GetNetworkFabricRoutePolicyResource(networkFabricRoutePolicyResourceId); // invoke the operation - NetworkFabricRoutePolicyPatch patch = new NetworkFabricRoutePolicyPatch() + NetworkFabricRoutePolicyPatch patch = new NetworkFabricRoutePolicyPatch { DefaultAction = CommunityActionType.Deny, - Statements = -{ -new RoutePolicyStatementProperties(7L,new StatementConditionProperties() + Statements = {new RoutePolicyStatementProperties(7L, new StatementConditionProperties { RoutePolicyConditionType = RoutePolicyConditionType.Or, IPPrefixId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipPrefixes/example-ipPrefix"), -IPExtendedCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity") -}, -IPCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity") -}, -},new StatementActionProperties(RoutePolicyActionType.Permit) +IPExtendedCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity")}, +IPCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity")}, +}, new StatementActionProperties(RoutePolicyActionType.Permit) { LocalPreference = 20L, -IPCommunityProperties = new ActionIPCommunityProperties() -{ -DeleteIPCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity") -}, -SetIPCommunityIds = +IPCommunityProperties = new ActionIPCommunityProperties { -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity") +DeleteIPCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity")}, +SetIPCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity")}, +AddIPCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity")}, }, -AddIPCommunityIds = +IPExtendedCommunityProperties = new ActionIPExtendedCommunityProperties { -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipCommunities/example-ipCommunity") -}, -}, -IPExtendedCommunityProperties = new ActionIPExtendedCommunityProperties() -{ -DeleteIPExtendedCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity") -}, -SetIPExtendedCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity") -}, -AddIPExtendedCommunityIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity") -}, +DeleteIPExtendedCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity")}, +SetIPExtendedCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity")}, +AddIPExtendedCommunityIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/ipExtendedCommunities/example-ipExtendedCommunity")}, }, }) { Annotation = "annotation", -} -}, +}}, Tags = { -["keyID"] = "keyValue", +["keyID"] = "keyValue" }, }; ArmOperation lro = await networkFabricRoutePolicy.UpdateAsync(WaitUntil.Completed, patch); @@ -138,63 +136,6 @@ public async Task Update_RoutePoliciesUpdateMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_RoutePoliciesDeleteMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/RoutePolicies_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "RoutePolicies_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkFabricRoutePolicyResource created on azure - // for more information of creating NetworkFabricRoutePolicyResource, please refer to the document of NetworkFabricRoutePolicyResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string routePolicyName = "example-routePolicy"; - ResourceIdentifier networkFabricRoutePolicyResourceId = NetworkFabricRoutePolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, routePolicyName); - NetworkFabricRoutePolicyResource networkFabricRoutePolicy = client.GetNetworkFabricRoutePolicyResource(networkFabricRoutePolicyResourceId); - - // invoke the operation - await networkFabricRoutePolicy.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkFabricRoutePolicies_RoutePoliciesListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/RoutePolicies_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "RoutePolicies_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkFabricRoutePolicyResource item in subscriptionResource.GetNetworkFabricRoutePoliciesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricRoutePolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task UpdateAdministrativeState_RoutePoliciesUpdateAdministrativeStateMaximumSetGen() @@ -216,13 +157,10 @@ public async Task UpdateAdministrativeState_RoutePoliciesUpdateAdministrativeSta NetworkFabricRoutePolicyResource networkFabricRoutePolicy = client.GetNetworkFabricRoutePolicyResource(networkFabricRoutePolicyResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkFabricRoutePolicy.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); DeviceUpdateCommonPostActionResult result = lro.Value; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricSkuCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricSkuCollection.cs index dd56bf3c4e3f2..136b69ac4ddca 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricSkuCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkFabricSkuCollection.cs @@ -50,10 +50,10 @@ public async Task Get_NetworkFabricSkusGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkFabricSkusGetMaximumSetGen() + public async Task GetAll_NetworkFabricSkusListBySubscriptionMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricSkus_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabricSkus_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricSkus_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabricSkus_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +69,22 @@ public async Task Exists_NetworkFabricSkusGetMaximumSetGen() // get the collection of this NetworkFabricSkuResource NetworkFabricSkuCollection collection = subscriptionResource.GetNetworkFabricSkus(); - // invoke the operation - string networkFabricSkuName = "example-fabricsku"; - bool result = await collection.ExistsAsync(networkFabricSkuName); + // invoke the operation and iterate over the result + await foreach (NetworkFabricSkuResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricSkuData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkFabricSkusGetMaximumSetGen() + public async Task Exists_NetworkFabricSkusGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricSkus_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkFabricSkus_Get" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +105,17 @@ public async Task GetIfExists_NetworkFabricSkusGetMaximumSetGen() // invoke the operation string networkFabricSkuName = "example-fabricsku"; - NullableResponse response = await collection.GetIfExistsAsync(networkFabricSkuName); - NetworkFabricSkuResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkFabricSkuName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkFabricSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkFabricSkusListBySubscriptionMaximumSetGen() + public async Task GetIfExists_NetworkFabricSkusGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricSkus_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkFabricSkus_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricSkus_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabricSkus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,17 +131,23 @@ public async Task GetAll_NetworkFabricSkusListBySubscriptionMaximumSetGen() // get the collection of this NetworkFabricSkuResource NetworkFabricSkuCollection collection = subscriptionResource.GetNetworkFabricSkus(); - // invoke the operation and iterate over the result - await foreach (NetworkFabricSkuResource item in collection.GetAllAsync()) + // invoke the operation + string networkFabricSkuName = "example-fabricsku"; + NullableResponse response = await collection.GetIfExistsAsync(networkFabricSkuName); + NetworkFabricSkuResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkFabricSkuData resourceData = item.Data; + NetworkFabricSkuData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkPacketBrokerCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkPacketBrokerCollection.cs index 6189f735e17d6..ceeb67c50821f 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkPacketBrokerCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkPacketBrokerCollection.cs @@ -44,7 +44,7 @@ public async Task CreateOrUpdate_NetworkPacketBrokersCreateMaximumSetGen() { Tags = { -["key2806"] = "key", +["key2806"] = "key" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkPacketBrokerName, data); @@ -92,10 +92,10 @@ public async Task Get_NetworkPacketBrokersGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkPacketBrokersGetMaximumSetGen() + public async Task GetAll_NetworkPacketBrokersListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkPacketBrokers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkPacketBrokers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_NetworkPacketBrokersGetMaximumSetGen() // get the collection of this NetworkPacketBrokerResource NetworkPacketBrokerCollection collection = resourceGroupResource.GetNetworkPacketBrokers(); - // invoke the operation - string networkPacketBrokerName = "example-networkPacketBroker"; - bool result = await collection.ExistsAsync(networkPacketBrokerName); + // invoke the operation and iterate over the result + await foreach (NetworkPacketBrokerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkPacketBrokerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkPacketBrokersGetMaximumSetGen() + public async Task Exists_NetworkPacketBrokersGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkPacketBrokers_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,29 +149,17 @@ public async Task GetIfExists_NetworkPacketBrokersGetMaximumSetGen() // invoke the operation string networkPacketBrokerName = "example-networkPacketBroker"; - NullableResponse response = await collection.GetIfExistsAsync(networkPacketBrokerName); - NetworkPacketBrokerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkPacketBrokerName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkPacketBrokerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkPacketBrokersListByResourceGroupMaximumSetGen() + public async Task GetIfExists_NetworkPacketBrokersGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkPacketBrokers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkPacketBrokers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,17 +176,23 @@ public async Task GetAll_NetworkPacketBrokersListByResourceGroupMaximumSetGen() // get the collection of this NetworkPacketBrokerResource NetworkPacketBrokerCollection collection = resourceGroupResource.GetNetworkPacketBrokers(); - // invoke the operation and iterate over the result - await foreach (NetworkPacketBrokerResource item in collection.GetAllAsync()) + // invoke the operation + string networkPacketBrokerName = "example-networkPacketBroker"; + NullableResponse response = await collection.GetIfExistsAsync(networkPacketBrokerName); + NetworkPacketBrokerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkPacketBrokerData resourceData = item.Data; + NetworkPacketBrokerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkPacketBrokerResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkPacketBrokerResource.cs index 55ffb6d6cdb94..72b2cf16d1ab8 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkPacketBrokerResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkPacketBrokerResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -49,10 +48,10 @@ public async Task Get_NetworkPacketBrokersGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NetworkPacketBrokersUpdateMaximumSetGen() + public async Task Delete_NetworkPacketBrokersDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_Update_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkPacketBrokers_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkPacketBrokers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_NetworkPacketBrokersUpdateMaximumSetGen() NetworkPacketBrokerResource networkPacketBroker = client.GetNetworkPacketBrokerResource(networkPacketBrokerResourceId); // invoke the operation - NetworkPacketBrokerPatch patch = new NetworkPacketBrokerPatch() - { - Tags = -{ -["key8772"] = "1234", -}, - }; - ArmOperation lro = await networkPacketBroker.UpdateAsync(WaitUntil.Completed, patch); - NetworkPacketBrokerResource result = lro.Value; + await networkPacketBroker.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkPacketBrokerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkPacketBrokersDeleteMaximumSetGen() + public async Task Update_NetworkPacketBrokersUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkPacketBrokers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_Update_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkPacketBrokers_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_NetworkPacketBrokersDeleteMaximumSetGen() NetworkPacketBrokerResource networkPacketBroker = client.GetNetworkPacketBrokerResource(networkPacketBrokerResourceId); // invoke the operation - await networkPacketBroker.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkPacketBrokers_NetworkPacketBrokersListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkPacketBrokers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkPacketBrokerResource item in subscriptionResource.GetNetworkPacketBrokersAsync()) + NetworkPacketBrokerPatch patch = new NetworkPacketBrokerPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkPacketBrokerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key8772"] = "1234" +}, + }; + ArmOperation lro = await networkPacketBroker.UpdateAsync(WaitUntil.Completed, patch); + NetworkPacketBrokerResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkPacketBrokerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkRackCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkRackCollection.cs index d8b5fdb541553..7b9d65d67f9d9 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkRackCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkRackCollection.cs @@ -47,7 +47,7 @@ public async Task CreateOrUpdate_NetworkRacksCreateMaximumSetGen() NetworkRackType = NetworkRackType.Aggregate, Tags = { -["keyID"] = "keyValue", +["keyID"] = "keyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkRackName, data); @@ -95,10 +95,10 @@ public async Task Get_NetworkRacksGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkRacksGetMaximumSetGen() + public async Task GetAll_NetworkRacksListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkRacks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkRacks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +115,22 @@ public async Task Exists_NetworkRacksGetMaximumSetGen() // get the collection of this NetworkRackResource NetworkRackCollection collection = resourceGroupResource.GetNetworkRacks(); - // invoke the operation - string networkRackName = "example-rack"; - bool result = await collection.ExistsAsync(networkRackName); + // invoke the operation and iterate over the result + await foreach (NetworkRackResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkRackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkRacksGetMaximumSetGen() + public async Task Exists_NetworkRacksGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkRacks_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +152,17 @@ public async Task GetIfExists_NetworkRacksGetMaximumSetGen() // invoke the operation string networkRackName = "example-rack"; - NullableResponse response = await collection.GetIfExistsAsync(networkRackName); - NetworkRackResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkRackName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkRackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkRacksListByResourceGroupMaximumSetGen() + public async Task GetIfExists_NetworkRacksGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkRacks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkRacks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_NetworkRacksListByResourceGroupMaximumSetGen() // get the collection of this NetworkRackResource NetworkRackCollection collection = resourceGroupResource.GetNetworkRacks(); - // invoke the operation and iterate over the result - await foreach (NetworkRackResource item in collection.GetAllAsync()) + // invoke the operation + string networkRackName = "example-rack"; + NullableResponse response = await collection.GetIfExistsAsync(networkRackName); + NetworkRackResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkRackData resourceData = item.Data; + NetworkRackData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkRackResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkRackResource.cs index 48644efb29bcf..8f46a9163feb1 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkRackResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkRackResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -49,10 +48,10 @@ public async Task Get_NetworkRacksGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NetworkRacksUpdateMaximumSetGen() + public async Task Delete_NetworkRacksDeleteMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_Update_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkRacks_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkRacks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_NetworkRacksUpdateMaximumSetGen() NetworkRackResource networkRack = client.GetNetworkRackResource(networkRackResourceId); // invoke the operation - NetworkRackPatch patch = new NetworkRackPatch() - { - Tags = -{ -["keyID"] = "keyValue", -}, - }; - ArmOperation lro = await networkRack.UpdateAsync(WaitUntil.Completed, patch); - NetworkRackResource result = lro.Value; + await networkRack.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkRackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkRacksDeleteMaximumSetGen() + public async Task Update_NetworkRacksUpdateMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkRacks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_Update_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkRacks_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_NetworkRacksDeleteMaximumSetGen() NetworkRackResource networkRack = client.GetNetworkRackResource(networkRackResourceId); // invoke the operation - await networkRack.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkRacks_NetworkRacksListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkRacks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkRackResource item in subscriptionResource.GetNetworkRacksAsync()) + NetworkRackPatch patch = new NetworkRackPatch { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkRackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["keyID"] = "keyValue" +}, + }; + ArmOperation lro = await networkRack.UpdateAsync(WaitUntil.Completed, patch); + NetworkRackResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkRackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapCollection.cs index dd5c5cf842282..229663bb3b127 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapCollection.cs @@ -43,18 +43,15 @@ public async Task CreateOrUpdate_NetworkTapsCreateMaximumSetGen() string networkTapName = "example-networkTap"; NetworkTapData data = new NetworkTapData(new AzureLocation("eastuseuap"), new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkPacketBrokers/example-networkPacketBroker"), new NetworkTapPropertiesDestinationsItem[] { -new NetworkTapPropertiesDestinationsItem() +new NetworkTapPropertiesDestinationsItem { Name = "example-destinaionName", DestinationType = NetworkTapDestinationType.IsolationDomain, DestinationId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/l3IsloationDomains/example-l3Domain/internalNetworks/example-internalNetwork"), -IsolationDomainProperties = new IsolationDomainProperties() +IsolationDomainProperties = new IsolationDomainProperties { Encapsulation = IsolationDomainEncapsulationType.None, -NeighborGroupIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/neighborGroups/example-neighborGroup") -}, +NeighborGroupIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/neighborGroups/example-neighborGroup")}, }, DestinationTapRuleId = new ResourceIdentifier("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkTapRules/example-destinationTapRule"), } @@ -64,7 +61,7 @@ public async Task CreateOrUpdate_NetworkTapsCreateMaximumSetGen() PollingType = NetworkTapPollingType.Pull, Tags = { -["key6024"] = "1234", +["key6024"] = "1234" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkTapName, data); @@ -112,10 +109,10 @@ public async Task Get_NetworkTapsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkTapsGetMaximumSetGen() + public async Task GetAll_NetworkTapsListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTaps_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkTaps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTaps_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkTaps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,16 +129,22 @@ public async Task Exists_NetworkTapsGetMaximumSetGen() // get the collection of this NetworkTapResource NetworkTapCollection collection = resourceGroupResource.GetNetworkTaps(); - // invoke the operation - string networkTapName = "example-networkTap"; - bool result = await collection.ExistsAsync(networkTapName); + // invoke the operation and iterate over the result + await foreach (NetworkTapResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkTapData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkTapsGetMaximumSetGen() + public async Task Exists_NetworkTapsGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTaps_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkTaps_Get" operation, for the dependent resources, they will have to be created separately. @@ -163,29 +166,17 @@ public async Task GetIfExists_NetworkTapsGetMaximumSetGen() // invoke the operation string networkTapName = "example-networkTap"; - NullableResponse response = await collection.GetIfExistsAsync(networkTapName); - NetworkTapResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkTapName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkTapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkTapsListByResourceGroupMaximumSetGen() + public async Task GetIfExists_NetworkTapsGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTaps_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkTaps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTaps_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkTaps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -202,17 +193,23 @@ public async Task GetAll_NetworkTapsListByResourceGroupMaximumSetGen() // get the collection of this NetworkTapResource NetworkTapCollection collection = resourceGroupResource.GetNetworkTaps(); - // invoke the operation and iterate over the result - await foreach (NetworkTapResource item in collection.GetAllAsync()) + // invoke the operation + string networkTapName = "example-networkTap"; + NullableResponse response = await collection.GetIfExistsAsync(networkTapName); + NetworkTapResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkTapData resourceData = item.Data; + NetworkTapData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapResource.cs index fdbdd8eedfca3..9bbb40e4f1088 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -47,6 +46,32 @@ public async Task Get_NetworkTapsGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NetworkTapsDeleteMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTaps_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkTaps_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkTapResource created on azure + // for more information of creating NetworkTapResource, please refer to the document of NetworkTapResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string networkTapName = "example-networkTap"; + ResourceIdentifier networkTapResourceId = NetworkTapResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkTapName); + NetworkTapResource networkTap = client.GetNetworkTapResource(networkTapResourceId); + + // invoke the operation + await networkTap.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_NetworkTapsUpdateMaximumSetGen() @@ -68,31 +93,25 @@ public async Task Update_NetworkTapsUpdateMaximumSetGen() NetworkTapResource networkTap = client.GetNetworkTapResource(networkTapResourceId); // invoke the operation - NetworkTapPatch patch = new NetworkTapPatch() + NetworkTapPatch patch = new NetworkTapPatch { Annotation = "annotation1", PollingType = NetworkTapPollingType.Pull, - Destinations = -{ -new NetworkTapPatchableParametersDestinationsItem() + Destinations = {new NetworkTapPatchableParametersDestinationsItem { Name = "example-destinaionName", DestinationType = NetworkTapDestinationType.IsolationDomain, DestinationId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/l3IsloationDomains/example-l3Domain/internalNetworks/example-internalNetwork"), -IsolationDomainProperties = new IsolationDomainProperties() +IsolationDomainProperties = new IsolationDomainProperties { Encapsulation = IsolationDomainEncapsulationType.None, -NeighborGroupIds = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/neighborGroups/example-neighborGroup") -}, +NeighborGroupIds = {new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/neighborGroups/example-neighborGroup")}, }, DestinationTapRuleId = new ResourceIdentifier("/subscriptions/xxxx-xxxx-xxxx-xxxx/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkTapRules/example-destinationTapRule"), -} -}, +}}, Tags = { -["key6024"] = "1234", +["key6024"] = "1234" }, }; ArmOperation lro = await networkTap.UpdateAsync(WaitUntil.Completed, patch); @@ -105,63 +124,6 @@ public async Task Update_NetworkTapsUpdateMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkTapsDeleteMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTaps_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkTaps_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkTapResource created on azure - // for more information of creating NetworkTapResource, please refer to the document of NetworkTapResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string networkTapName = "example-networkTap"; - ResourceIdentifier networkTapResourceId = NetworkTapResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkTapName); - NetworkTapResource networkTap = client.GetNetworkTapResource(networkTapResourceId); - - // invoke the operation - await networkTap.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkTaps_NetworkTapsListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTaps_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkTaps_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkTapResource item in subscriptionResource.GetNetworkTapsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkTapData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task UpdateAdministrativeState_NetworkTapsUpdateAdministrativeStateMaximumSetGen() @@ -183,13 +145,10 @@ public async Task UpdateAdministrativeState_NetworkTapsUpdateAdministrativeState NetworkTapResource networkTap = client.GetNetworkTapResource(networkTapResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkTap.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); DeviceUpdateCommonPostActionResult result = lro.Value; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapRuleCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapRuleCollection.cs index b1926e79aa25e..bac8ce7e5d9d4 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapRuleCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapRuleCollection.cs @@ -46,128 +46,71 @@ public async Task CreateOrUpdate_NetworkTapRulesCreateMaximumSetGen() Annotation = "annotation", ConfigurationType = NetworkFabricConfigurationType.File, TapRulesUri = new Uri("https://microsoft.com/a"), - MatchConfigurations = -{ -new NetworkTapRuleMatchConfiguration() + MatchConfigurations = {new NetworkTapRuleMatchConfiguration { MatchConfigurationName = "config1", SequenceNumber = 10L, IPAddressType = NetworkFabricIPAddressType.IPv4, -MatchConditions = -{ -new NetworkTapRuleMatchCondition() +MatchConditions = {new NetworkTapRuleMatchCondition { EncapsulationType = NetworkTapEncapsulationType.None, PortCondition = new NetworkFabricPortCondition(Layer4Protocol.Tcp) { PortType = NetworkFabricPortType.SourcePort, -Ports = -{ -"100" -}, -PortGroupNames = -{ -"example-portGroup1" -}, -}, -ProtocolTypes = -{ -"TCP" -}, -VlanMatchCondition = new VlanMatchCondition() -{ -Vlans = -{ -"10" +Ports = {"100"}, +PortGroupNames = {"example-portGroup1"}, }, -InnerVlans = +ProtocolTypes = {"TCP"}, +VlanMatchCondition = new VlanMatchCondition { -"11-20" -}, -VlanGroupNames = -{ -"exmaple-vlanGroup" -}, +Vlans = {"10"}, +InnerVlans = {"11-20"}, +VlanGroupNames = {"exmaple-vlanGroup"}, }, -IPCondition = new IPMatchCondition() +IPCondition = new IPMatchCondition { SourceDestinationType = SourceDestinationType.SourceIP, PrefixType = IPMatchConditionPrefixType.Prefix, -IPPrefixValues = -{ -"10.10.10.10/20" -}, -IPGroupNames = -{ -"example-ipGroup" -}, +IPPrefixValues = {"10.10.10.10/20"}, +IPGroupNames = {"example-ipGroup"}, }, -} -}, -Actions = -{ -new NetworkTapRuleAction() +}}, +Actions = {new NetworkTapRuleAction { TapRuleActionType = TapRuleActionType.Drop, Truncate = "100", IsTimestampEnabled = NetworkFabricBooleanValue.True, DestinationId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/neighborGroups/example-neighborGroup"), MatchConfigurationName = "match1", -} -}, -} -}, - DynamicMatchConfigurations = -{ -new CommonDynamicMatchConfiguration() -{ -IPGroups = +}}, +}}, + DynamicMatchConfigurations = {new CommonDynamicMatchConfiguration { -new MatchConfigurationIPGroupProperties() +IPGroups = {new MatchConfigurationIPGroupProperties { Name = "example-ipGroup1", IPAddressType = NetworkFabricIPAddressType.IPv4, -IPPrefixes = -{ -"10.10.10.10/30" -}, -} -}, -VlanGroups = -{ -new VlanGroupProperties() +IPPrefixes = {"10.10.10.10/30"}, +}}, +VlanGroups = {new VlanGroupProperties { Name = "exmaple-vlanGroup", -Vlans = -{ -"10","100-200" -}, -} -}, -PortGroups = -{ -new PortGroupProperties() +Vlans = {"10", "100-200"}, +}}, +PortGroups = {new PortGroupProperties { Name = "example-portGroup1", -Ports = -{ -"100-200" -}, -},new PortGroupProperties() +Ports = {"100-200"}, +}, new PortGroupProperties { Name = "example-portGroup2", -Ports = -{ -"900","1000-2000" -}, -} -}, -} -}, +Ports = {"900", "1000-2000"}, +}}, +}}, PollingIntervalInSeconds = PollingIntervalInSecond.Thirty, Tags = { -["keyID"] = "keyValue", +["keyID"] = "keyValue" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkTapRuleName, data); @@ -215,10 +158,10 @@ public async Task Get_NetworkTapRulesGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkTapRulesGetMaximumSetGen() + public async Task GetAll_NetworkTapRulesListByResourceGroupMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTapRules_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkTapRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTapRules_ListByResourceGroup_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkTapRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -235,16 +178,22 @@ public async Task Exists_NetworkTapRulesGetMaximumSetGen() // get the collection of this NetworkTapRuleResource NetworkTapRuleCollection collection = resourceGroupResource.GetNetworkTapRules(); - // invoke the operation - string networkTapRuleName = "example-tapRule"; - bool result = await collection.ExistsAsync(networkTapRuleName); + // invoke the operation and iterate over the result + await foreach (NetworkTapRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkTapRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkTapRulesGetMaximumSetGen() + public async Task Exists_NetworkTapRulesGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTapRules_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkTapRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -266,29 +215,17 @@ public async Task GetIfExists_NetworkTapRulesGetMaximumSetGen() // invoke the operation string networkTapRuleName = "example-tapRule"; - NullableResponse response = await collection.GetIfExistsAsync(networkTapRuleName); - NetworkTapRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkTapRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkTapRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkTapRulesListByResourceGroupMaximumSetGen() + public async Task GetIfExists_NetworkTapRulesGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTapRules_ListByResourceGroup_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkTapRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTapRules_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkTapRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -305,17 +242,23 @@ public async Task GetAll_NetworkTapRulesListByResourceGroupMaximumSetGen() // get the collection of this NetworkTapRuleResource NetworkTapRuleCollection collection = resourceGroupResource.GetNetworkTapRules(); - // invoke the operation and iterate over the result - await foreach (NetworkTapRuleResource item in collection.GetAllAsync()) + // invoke the operation + string networkTapRuleName = "example-tapRule"; + NullableResponse response = await collection.GetIfExistsAsync(networkTapRuleName); + NetworkTapRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkTapRuleData resourceData = item.Data; + NetworkTapRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapRuleResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapRuleResource.cs index 999af63cb75b7..5ffc1a0a99afc 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapRuleResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkTapRuleResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedNetworkFabric.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedNetworkFabric.Samples @@ -47,6 +46,32 @@ public async Task Get_NetworkTapRulesGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NetworkTapRulesDeleteMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTapRules_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkTapRules_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkTapRuleResource created on azure + // for more information of creating NetworkTapRuleResource, please refer to the document of NetworkTapRuleResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string networkTapRuleName = "example-tapRule"; + ResourceIdentifier networkTapRuleResourceId = NetworkTapRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkTapRuleName); + NetworkTapRuleResource networkTapRule = client.GetNetworkTapRuleResource(networkTapRuleResourceId); + + // invoke the operation + await networkTapRule.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_NetworkTapRulesUpdateMaximumSetGen() @@ -68,125 +93,71 @@ public async Task Update_NetworkTapRulesUpdateMaximumSetGen() NetworkTapRuleResource networkTapRule = client.GetNetworkTapRuleResource(networkTapRuleResourceId); // invoke the operation - NetworkTapRulePatch patch = new NetworkTapRulePatch() + NetworkTapRulePatch patch = new NetworkTapRulePatch { Annotation = "annotation", ConfigurationType = NetworkFabricConfigurationType.File, TapRulesUri = new Uri("https://microsoft.com/amdsdx"), - MatchConfigurations = -{ -new NetworkTapRuleMatchConfiguration() + MatchConfigurations = {new NetworkTapRuleMatchConfiguration { MatchConfigurationName = "config1", SequenceNumber = 10L, IPAddressType = NetworkFabricIPAddressType.IPv4, -MatchConditions = -{ -new NetworkTapRuleMatchCondition() +MatchConditions = {new NetworkTapRuleMatchCondition { EncapsulationType = NetworkTapEncapsulationType.None, PortCondition = new NetworkFabricPortCondition(Layer4Protocol.Tcp) { PortType = NetworkFabricPortType.SourcePort, -Ports = -{ -"100" +Ports = {"100"}, +PortGroupNames = {"example-portGroup1"}, }, -PortGroupNames = +ProtocolTypes = {"TCP"}, +VlanMatchCondition = new VlanMatchCondition { -"example-portGroup1" +Vlans = {"10"}, +InnerVlans = {"11-20"}, +VlanGroupNames = {"exmaple-vlanGroup"}, }, -}, -ProtocolTypes = -{ -"TCP" -}, -VlanMatchCondition = new VlanMatchCondition() -{ -Vlans = -{ -"10" -}, -InnerVlans = -{ -"11-20" -}, -VlanGroupNames = -{ -"exmaple-vlanGroup" -}, -}, -IPCondition = new IPMatchCondition() +IPCondition = new IPMatchCondition { SourceDestinationType = SourceDestinationType.SourceIP, PrefixType = IPMatchConditionPrefixType.Prefix, -IPPrefixValues = -{ -"10.10.10.10/20" -}, -IPGroupNames = -{ -"example-ipGroup" +IPPrefixValues = {"10.10.10.10/20"}, +IPGroupNames = {"example-ipGroup"}, }, -}, -} -}, -Actions = -{ -new NetworkTapRuleAction() +}}, +Actions = {new NetworkTapRuleAction { TapRuleActionType = TapRuleActionType.Goto, Truncate = "100", IsTimestampEnabled = NetworkFabricBooleanValue.True, DestinationId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourcegroups/example-rg/providers/Microsoft.ManagedNetworkFabric/neighborGroups/example-neighborGroup"), MatchConfigurationName = "match1", -} -}, -} -}, - DynamicMatchConfigurations = -{ -new CommonDynamicMatchConfiguration() +}}, +}}, + DynamicMatchConfigurations = {new CommonDynamicMatchConfiguration { -IPGroups = -{ -new MatchConfigurationIPGroupProperties() +IPGroups = {new MatchConfigurationIPGroupProperties { Name = "example-ipGroup1", IPAddressType = NetworkFabricIPAddressType.IPv4, -IPPrefixes = -{ -"10.10.10.10/30" -}, -} -}, -VlanGroups = -{ -new VlanGroupProperties() +IPPrefixes = {"10.10.10.10/30"}, +}}, +VlanGroups = {new VlanGroupProperties { Name = "exmaple-vlanGroup", -Vlans = -{ -"10","100-200" -}, -} -}, -PortGroups = -{ -new PortGroupProperties() +Vlans = {"10", "100-200"}, +}}, +PortGroups = {new PortGroupProperties { Name = "example-portGroup1", -Ports = -{ -"100-200" -}, -} -}, -} -}, +Ports = {"100-200"}, +}}, +}}, Tags = { -["keyID"] = "keyValue", +["keyID"] = "keyValue" }, }; ArmOperation lro = await networkTapRule.UpdateAsync(WaitUntil.Completed, patch); @@ -199,63 +170,6 @@ public async Task Update_NetworkTapRulesUpdateMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkTapRulesDeleteMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTapRules_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkTapRules_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkTapRuleResource created on azure - // for more information of creating NetworkTapRuleResource, please refer to the document of NetworkTapRuleResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string networkTapRuleName = "example-tapRule"; - ResourceIdentifier networkTapRuleResourceId = NetworkTapRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkTapRuleName); - NetworkTapRuleResource networkTapRule = client.GetNetworkTapRuleResource(networkTapRuleResourceId); - - // invoke the operation - await networkTapRule.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkTapRules_NetworkTapRulesListBySubscriptionMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTapRules_ListBySubscription_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkTapRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkTapRuleResource item in subscriptionResource.GetNetworkTapRulesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkTapRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task UpdateAdministrativeState_NetworkTapRulesUpdateAdministrativeStateMaximumSetGen() @@ -277,13 +191,10 @@ public async Task UpdateAdministrativeState_NetworkTapRulesUpdateAdministrativeS NetworkTapRuleResource networkTapRule = client.GetNetworkTapRuleResource(networkTapRuleResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkTapRule.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkToNetworkInterconnectCollection.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkToNetworkInterconnectCollection.cs index 0cf6f522440ed..dd37479e377d9 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkToNetworkInterconnectCollection.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkToNetworkInterconnectCollection.cs @@ -45,15 +45,12 @@ public async Task CreateOrUpdate_NetworkToNetworkInterconnectsCreateMaximumSetGe { NniType = NniType.CE, IsManagementType = IsManagementType.True, - Layer2Configuration = new Layer2Configuration() + Layer2Configuration = new Layer2Configuration { Mtu = 1500, - Interfaces = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkDevices/example-networkDevice/networkInterfaces/example-networkInterface") -}, + Interfaces = { new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkDevices/example-networkDevice/networkInterfaces/example-networkInterface") }, }, - OptionBLayer3Configuration = new NetworkToNetworkInterconnectOptionBLayer3Configuration() + OptionBLayer3Configuration = new NetworkToNetworkInterconnectOptionBLayer3Configuration { PeerAsn = 61234L, VlanId = 1234, @@ -62,34 +59,22 @@ public async Task CreateOrUpdate_NetworkToNetworkInterconnectsCreateMaximumSetGe SecondaryIPv4Prefix = "40.0.0.14/30", SecondaryIPv6Prefix = "6FFE:FFFF:0:CD30::ac/127", }, - NpbStaticRouteConfiguration = new NpbStaticRouteConfiguration() + NpbStaticRouteConfiguration = new NpbStaticRouteConfiguration { - BfdConfiguration = new BfdConfiguration() + BfdConfiguration = new BfdConfiguration { IntervalInMilliSeconds = 300, Multiplier = 25, }, - IPv4Routes = -{ -new StaticRouteProperties("20.0.0.12/30",new string[] -{ -"21.20.20.20" -}) -}, - IPv6Routes = -{ -new StaticRouteProperties("3FFE:FFFF:0:CD30::ac/127",new string[] -{ -"4FFE:FFFF:0:CD30::ac" -}) -}, + IPv4Routes = { new StaticRouteProperties("20.0.0.12/30", new string[] { "21.20.20.20" }) }, + IPv6Routes = { new StaticRouteProperties("3FFE:FFFF:0:CD30::ac/127", new string[] { "4FFE:FFFF:0:CD30::ac" }) }, }, - ImportRoutePolicy = new ImportRoutePolicyInformation() + ImportRoutePolicy = new ImportRoutePolicyInformation { ImportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy"), ImportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy"), }, - ExportRoutePolicy = new ExportRoutePolicyInformation() + ExportRoutePolicy = new ExportRoutePolicyInformation { ExportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy"), ExportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy"), @@ -143,10 +128,10 @@ public async Task Get_NetworkToNetworkInterconnectsGetMaximumSetGen() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkToNetworkInterconnectsGetMaximumSetGen() + public async Task GetAll_NetworkToNetworkInterconnectsListByNetworkFabricMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkToNetworkInterconnects_Get_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkToNetworkInterconnects_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkToNetworkInterconnects_ListByNetworkFabric_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkToNetworkInterconnects_ListByNetworkFabric" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -164,16 +149,22 @@ public async Task Exists_NetworkToNetworkInterconnectsGetMaximumSetGen() // get the collection of this NetworkToNetworkInterconnectResource NetworkToNetworkInterconnectCollection collection = networkFabric.GetNetworkToNetworkInterconnects(); - // invoke the operation - string networkToNetworkInterconnectName = "example-nni"; - bool result = await collection.ExistsAsync(networkToNetworkInterconnectName); + // invoke the operation and iterate over the result + await foreach (NetworkToNetworkInterconnectResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkToNetworkInterconnectData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkToNetworkInterconnectsGetMaximumSetGen() + public async Task Exists_NetworkToNetworkInterconnectsGetMaximumSetGen() { // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkToNetworkInterconnects_Get_MaximumSet_Gen.json // this example is just showing the usage of "NetworkToNetworkInterconnects_Get" operation, for the dependent resources, they will have to be created separately. @@ -196,29 +187,17 @@ public async Task GetIfExists_NetworkToNetworkInterconnectsGetMaximumSetGen() // invoke the operation string networkToNetworkInterconnectName = "example-nni"; - NullableResponse response = await collection.GetIfExistsAsync(networkToNetworkInterconnectName); - NetworkToNetworkInterconnectResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkToNetworkInterconnectName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkToNetworkInterconnectData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkToNetworkInterconnectsListByNetworkFabricMaximumSetGen() + public async Task GetIfExists_NetworkToNetworkInterconnectsGetMaximumSetGen() { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkToNetworkInterconnects_ListByNetworkFabric_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkToNetworkInterconnects_ListByNetworkFabric" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkToNetworkInterconnects_Get_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkToNetworkInterconnects_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,17 +215,23 @@ public async Task GetAll_NetworkToNetworkInterconnectsListByNetworkFabricMaximum // get the collection of this NetworkToNetworkInterconnectResource NetworkToNetworkInterconnectCollection collection = networkFabric.GetNetworkToNetworkInterconnects(); - // invoke the operation and iterate over the result - await foreach (NetworkToNetworkInterconnectResource item in collection.GetAllAsync()) + // invoke the operation + string networkToNetworkInterconnectName = "example-nni"; + NullableResponse response = await collection.GetIfExistsAsync(networkToNetworkInterconnectName); + NetworkToNetworkInterconnectResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkToNetworkInterconnectData resourceData = item.Data; + NetworkToNetworkInterconnectData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkToNetworkInterconnectResource.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkToNetworkInterconnectResource.cs index 133d1edff342f..4b3a579bd0c11 100644 --- a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkToNetworkInterconnectResource.cs +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_NetworkToNetworkInterconnectResource.cs @@ -47,6 +47,33 @@ public async Task Get_NetworkToNetworkInterconnectsGetMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_NetworkToNetworkInterconnectsDeleteMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkToNetworkInterconnects_Delete_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkToNetworkInterconnects_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkToNetworkInterconnectResource created on azure + // for more information of creating NetworkToNetworkInterconnectResource, please refer to the document of NetworkToNetworkInterconnectResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + string resourceGroupName = "example-rg"; + string networkFabricName = "example-fabric"; + string networkToNetworkInterconnectName = "example-nni"; + ResourceIdentifier networkToNetworkInterconnectResourceId = NetworkToNetworkInterconnectResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkFabricName, networkToNetworkInterconnectName); + NetworkToNetworkInterconnectResource networkToNetworkInterconnect = client.GetNetworkToNetworkInterconnectResource(networkToNetworkInterconnectResourceId); + + // invoke the operation + await networkToNetworkInterconnect.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_NetworkToNetworkInterconnectsUpdateMaximumSetGen() @@ -69,17 +96,14 @@ public async Task Update_NetworkToNetworkInterconnectsUpdateMaximumSetGen() NetworkToNetworkInterconnectResource networkToNetworkInterconnect = client.GetNetworkToNetworkInterconnectResource(networkToNetworkInterconnectResourceId); // invoke the operation - NetworkToNetworkInterconnectPatch patch = new NetworkToNetworkInterconnectPatch() + NetworkToNetworkInterconnectPatch patch = new NetworkToNetworkInterconnectPatch { - Layer2Configuration = new Layer2Configuration() + Layer2Configuration = new Layer2Configuration { Mtu = 1500, - Interfaces = -{ -new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkDevices/example-networkDevice/networkInterfaces/example-networkInterface") -}, + Interfaces = { new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/networkDevices/example-networkDevice/networkInterfaces/example-networkInterface") }, }, - OptionBLayer3Configuration = new OptionBLayer3Configuration() + OptionBLayer3Configuration = new OptionBLayer3Configuration { PeerAsn = 2345L, VlanId = 1235, @@ -88,34 +112,22 @@ public async Task Update_NetworkToNetworkInterconnectsUpdateMaximumSetGen() SecondaryIPv4Prefix = "20.0.0.14/29", SecondaryIPv6Prefix = "6FFE:FFFF:0:CD30::ac/127", }, - NpbStaticRouteConfiguration = new NpbStaticRouteConfiguration() + NpbStaticRouteConfiguration = new NpbStaticRouteConfiguration { - BfdConfiguration = new BfdConfiguration() + BfdConfiguration = new BfdConfiguration { IntervalInMilliSeconds = 310, Multiplier = 15, }, - IPv4Routes = -{ -new StaticRouteProperties("20.0.0.11/30",new string[] -{ -"21.20.20.10" -}) -}, - IPv6Routes = -{ -new StaticRouteProperties("4FFE:FFFF:0:CD30::ac/127",new string[] -{ -"5FFE:FFFF:0:CD30::ac" -}) -}, + IPv4Routes = { new StaticRouteProperties("20.0.0.11/30", new string[] { "21.20.20.10" }) }, + IPv6Routes = { new StaticRouteProperties("4FFE:FFFF:0:CD30::ac/127", new string[] { "5FFE:FFFF:0:CD30::ac" }) }, }, - ImportRoutePolicy = new ImportRoutePolicyInformation() + ImportRoutePolicy = new ImportRoutePolicyInformation { ImportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy1"), ImportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy1"), }, - ExportRoutePolicy = new ExportRoutePolicyInformation() + ExportRoutePolicy = new ExportRoutePolicyInformation { ExportIPv4RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy1"), ExportIPv6RoutePolicyId = new ResourceIdentifier("/subscriptions/1234ABCD-0A1B-1234-5678-123456ABCDEF/resourceGroups/example-rg/providers/Microsoft.ManagedNetworkFabric/routePolicies/example-routePolicy1"), @@ -133,33 +145,6 @@ public async Task Update_NetworkToNetworkInterconnectsUpdateMaximumSetGen() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkToNetworkInterconnectsDeleteMaximumSetGen() - { - // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkToNetworkInterconnects_Delete_MaximumSet_Gen.json - // this example is just showing the usage of "NetworkToNetworkInterconnects_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkToNetworkInterconnectResource created on azure - // for more information of creating NetworkToNetworkInterconnectResource, please refer to the document of NetworkToNetworkInterconnectResource - string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; - string resourceGroupName = "example-rg"; - string networkFabricName = "example-fabric"; - string networkToNetworkInterconnectName = "example-nni"; - ResourceIdentifier networkToNetworkInterconnectResourceId = NetworkToNetworkInterconnectResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkFabricName, networkToNetworkInterconnectName); - NetworkToNetworkInterconnectResource networkToNetworkInterconnect = client.GetNetworkToNetworkInterconnectResource(networkToNetworkInterconnectResourceId); - - // invoke the operation - await networkToNetworkInterconnect.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task UpdateNpbStaticRouteBfdAdministrativeState_NetworkToNetworkInterconnectsUpdateNpbStaticRouteBfdAdministrativeStateMaximumSetGen() @@ -182,13 +167,10 @@ public async Task UpdateNpbStaticRouteBfdAdministrativeState_NetworkToNetworkInt NetworkToNetworkInterconnectResource networkToNetworkInterconnect = client.GetNetworkToNetworkInterconnectResource(networkToNetworkInterconnectResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkToNetworkInterconnect.UpdateNpbStaticRouteBfdAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; @@ -218,13 +200,10 @@ public async Task UpdateAdministrativeState_NetworkToNetworkInterconnectsUpdateA NetworkToNetworkInterconnectResource networkToNetworkInterconnect = client.GetNetworkToNetworkInterconnectResource(networkToNetworkInterconnectResourceId); // invoke the operation - UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent() + UpdateAdministrativeStateContent content = new UpdateAdministrativeStateContent { State = AdministrativeEnableState.Enable, - ResourceIds = -{ -new ResourceIdentifier("") -}, + ResourceIds = { new ResourceIdentifier("") }, }; ArmOperation lro = await networkToNetworkInterconnect.UpdateAdministrativeStateAsync(WaitUntil.Completed, content); StateUpdateCommonPostActionResult result = lro.Value; diff --git a/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..f98f51846a3e0 --- /dev/null +++ b/sdk/managednetworkfabric/Azure.ResourceManager.ManagedNetworkFabric/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,546 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ManagedNetworkFabric.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricAccessControlLists_AccessControlListsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/AccessControlLists_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "AccessControlLists_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricAccessControlListResource item in subscriptionResource.GetNetworkFabricAccessControlListsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricAccessControlListData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricInternetGateways_InternetGatewaysListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGateways_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "InternetGateways_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricInternetGatewayResource item in subscriptionResource.GetNetworkFabricInternetGatewaysAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricInternetGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricInternetGatewayRules_InternetGatewayRulesListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/InternetGatewayRules_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "InternetGatewayRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricInternetGatewayRuleResource item in subscriptionResource.GetNetworkFabricInternetGatewayRulesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricInternetGatewayRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricIPCommunities_IpCommunitiesListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpCommunities_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "IpCommunities_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricIPCommunityResource item in subscriptionResource.GetNetworkFabricIPCommunitiesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricIPCommunityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricIPExtendedCommunities_IpExtendedCommunitiesListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpExtendedCommunities_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "IpExtendedCommunities_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricIPExtendedCommunityResource item in subscriptionResource.GetNetworkFabricIPExtendedCommunitiesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricIPExtendedCommunityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricIPPrefixes_IpPrefixesListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/IpPrefixes_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "IpPrefixes_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricIPPrefixResource item in subscriptionResource.GetNetworkFabricIPPrefixesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricIPPrefixData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricL2IsolationDomains_L2IsolationDomainsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L2IsolationDomains_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "L2IsolationDomains_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricL2IsolationDomainResource item in subscriptionResource.GetNetworkFabricL2IsolationDomainsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricL2IsolationDomainData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricL3IsolationDomains_L3IsolationDomainsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/L3IsolationDomains_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "L3IsolationDomains_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricL3IsolationDomainResource item in subscriptionResource.GetNetworkFabricL3IsolationDomainsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricL3IsolationDomainData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricNeighborGroups_NeighborGroupsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NeighborGroups_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "NeighborGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricNeighborGroupResource item in subscriptionResource.GetNetworkFabricNeighborGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricNeighborGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkDevices_NetworkDevicesListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkDevices_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkDevices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkDeviceResource item in subscriptionResource.GetNetworkDevicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkDeviceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricControllers_NetworkFabricControllersListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabricControllers_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabricControllers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricControllerResource item in subscriptionResource.GetNetworkFabricControllersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricControllerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabrics_NetworkFabricsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkFabrics_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkFabrics_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricResource item in subscriptionResource.GetNetworkFabricsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkPacketBrokers_NetworkPacketBrokersListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkPacketBrokers_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkPacketBrokers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkPacketBrokerResource item in subscriptionResource.GetNetworkPacketBrokersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkPacketBrokerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkRacks_NetworkRacksListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkRacks_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkRacks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkRackResource item in subscriptionResource.GetNetworkRacksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkRackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkTapRules_NetworkTapRulesListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTapRules_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkTapRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkTapRuleResource item in subscriptionResource.GetNetworkTapRulesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkTapRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkTaps_NetworkTapsListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/NetworkTaps_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "NetworkTaps_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkTapResource item in subscriptionResource.GetNetworkTapsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkTapData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkFabricRoutePolicies_RoutePoliciesListBySubscriptionMaximumSetGen() + { + // Generated from example definition: specification/managednetworkfabric/resource-manager/Microsoft.ManagedNetworkFabric/stable/2023-06-15/examples/RoutePolicies_ListBySubscription_MaximumSet_Gen.json + // this example is just showing the usage of "RoutePolicies_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "1234ABCD-0A1B-1234-5678-123456ABCDEF"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkFabricRoutePolicyResource item in subscriptionResource.GetNetworkFabricRoutePoliciesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkFabricRoutePolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_FederatedIdentityCredentialCollection.cs b/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_FederatedIdentityCredentialCollection.cs index f933c4f8af9c2..22af996c5961f 100644 --- a/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_FederatedIdentityCredentialCollection.cs +++ b/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_FederatedIdentityCredentialCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_FederatedIdentityCredentialCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FederatedIdentityCredentialList() + public async Task CreateOrUpdate_FederatedIdentityCredentialCreate() { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialList.json - // this example is just showing the usage of "FederatedIdentityCredentials_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialCreate.json + // this example is just showing the usage of "FederatedIdentityCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,30 @@ public async Task GetAll_FederatedIdentityCredentialList() // get the collection of this FederatedIdentityCredentialResource FederatedIdentityCredentialCollection collection = userAssignedIdentity.GetFederatedIdentityCredentials(); - // invoke the operation and iterate over the result - await foreach (FederatedIdentityCredentialResource item in collection.GetAllAsync()) + // invoke the operation + string federatedIdentityCredentialResourceName = "ficResourceName"; + FederatedIdentityCredentialData data = new FederatedIdentityCredentialData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FederatedIdentityCredentialData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IssuerUri = new Uri("https://oidc.prod-aks.azure.com/TenantGUID/IssuerGUID"), + Subject = "system:serviceaccount:ns:svcaccount", + Audiences = { "api://AzureADTokenExchange" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, federatedIdentityCredentialResourceName, data); + FederatedIdentityCredentialResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FederatedIdentityCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_FederatedIdentityCredentialCreate() + public async Task Get_FederatedIdentityCredentialGet() { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialCreate.json - // this example is just showing the usage of "FederatedIdentityCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialGet.json + // this example is just showing the usage of "FederatedIdentityCredentials_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,17 +81,7 @@ public async Task CreateOrUpdate_FederatedIdentityCredentialCreate() // invoke the operation string federatedIdentityCredentialResourceName = "ficResourceName"; - FederatedIdentityCredentialData data = new FederatedIdentityCredentialData() - { - IssuerUri = new Uri("https://oidc.prod-aks.azure.com/TenantGUID/IssuerGUID"), - Subject = "system:serviceaccount:ns:svcaccount", - Audiences = -{ -"api://AzureADTokenExchange" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, federatedIdentityCredentialResourceName, data); - FederatedIdentityCredentialResource result = lro.Value; + FederatedIdentityCredentialResource result = await collection.GetAsync(federatedIdentityCredentialResourceName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -97,10 +92,10 @@ public async Task CreateOrUpdate_FederatedIdentityCredentialCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FederatedIdentityCredentialGet() + public async Task GetAll_FederatedIdentityCredentialList() { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialGet.json - // this example is just showing the usage of "FederatedIdentityCredentials_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialList.json + // this example is just showing the usage of "FederatedIdentityCredentials_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -118,15 +113,17 @@ public async Task Get_FederatedIdentityCredentialGet() // get the collection of this FederatedIdentityCredentialResource FederatedIdentityCredentialCollection collection = userAssignedIdentity.GetFederatedIdentityCredentials(); - // invoke the operation - string federatedIdentityCredentialResourceName = "ficResourceName"; - FederatedIdentityCredentialResource result = await collection.GetAsync(federatedIdentityCredentialResourceName); + // invoke the operation and iterate over the result + await foreach (FederatedIdentityCredentialResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FederatedIdentityCredentialData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FederatedIdentityCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_FederatedIdentityCredentialResource.cs b/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_FederatedIdentityCredentialResource.cs index 6c01fd739e6f9..99998cafee1ed 100644 --- a/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_FederatedIdentityCredentialResource.cs +++ b/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_FederatedIdentityCredentialResource.cs @@ -17,10 +17,10 @@ public partial class Sample_FederatedIdentityCredentialResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FederatedIdentityCredentialCreate() + public async Task Get_FederatedIdentityCredentialGet() { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialCreate.json - // this example is just showing the usage of "FederatedIdentityCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialGet.json + // this example is just showing the usage of "FederatedIdentityCredentials_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,7 @@ public async Task Update_FederatedIdentityCredentialCreate() FederatedIdentityCredentialResource federatedIdentityCredential = client.GetFederatedIdentityCredentialResource(federatedIdentityCredentialResourceId); // invoke the operation - FederatedIdentityCredentialData data = new FederatedIdentityCredentialData() - { - IssuerUri = new Uri("https://oidc.prod-aks.azure.com/TenantGUID/IssuerGUID"), - Subject = "system:serviceaccount:ns:svcaccount", - Audiences = -{ -"api://AzureADTokenExchange" -}, - }; - ArmOperation lro = await federatedIdentityCredential.UpdateAsync(WaitUntil.Completed, data); - FederatedIdentityCredentialResource result = lro.Value; + FederatedIdentityCredentialResource result = await federatedIdentityCredential.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +48,10 @@ public async Task Update_FederatedIdentityCredentialCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FederatedIdentityCredentialGet() + public async Task Delete_FederatedIdentityCredentialDelete() { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialGet.json - // this example is just showing the usage of "FederatedIdentityCredentials_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialDelete.json + // this example is just showing the usage of "FederatedIdentityCredentials_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -78,21 +68,17 @@ public async Task Get_FederatedIdentityCredentialGet() FederatedIdentityCredentialResource federatedIdentityCredential = client.GetFederatedIdentityCredentialResource(federatedIdentityCredentialResourceId); // invoke the operation - FederatedIdentityCredentialResource result = await federatedIdentityCredential.GetAsync(); + await federatedIdentityCredential.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FederatedIdentityCredentialData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_FederatedIdentityCredentialDelete() + public async Task Update_FederatedIdentityCredentialCreate() { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialDelete.json - // this example is just showing the usage of "FederatedIdentityCredentials_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/FederatedIdentityCredentialCreate.json + // this example is just showing the usage of "FederatedIdentityCredentials_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +95,20 @@ public async Task Delete_FederatedIdentityCredentialDelete() FederatedIdentityCredentialResource federatedIdentityCredential = client.GetFederatedIdentityCredentialResource(federatedIdentityCredentialResourceId); // invoke the operation - await federatedIdentityCredential.DeleteAsync(WaitUntil.Completed); + FederatedIdentityCredentialData data = new FederatedIdentityCredentialData + { + IssuerUri = new Uri("https://oidc.prod-aks.azure.com/TenantGUID/IssuerGUID"), + Subject = "system:serviceaccount:ns:svcaccount", + Audiences = { "api://AzureADTokenExchange" }, + }; + ArmOperation lro = await federatedIdentityCredential.UpdateAsync(WaitUntil.Completed, data); + FederatedIdentityCredentialResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FederatedIdentityCredentialData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..bf0f42b74d741 --- /dev/null +++ b/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.ManagedServiceIdentities.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetUserAssignedIdentities_IdentityListBySubscription() + { + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityListBySubscription.json + // this example is just showing the usage of "UserAssignedIdentities_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (UserAssignedIdentityResource item in subscriptionResource.GetUserAssignedIdentitiesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + UserAssignedIdentityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_UserAssignedIdentityCollection.cs b/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_UserAssignedIdentityCollection.cs index 10366e14ab87f..10e196eaf9425 100644 --- a/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_UserAssignedIdentityCollection.cs +++ b/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_UserAssignedIdentityCollection.cs @@ -16,41 +16,6 @@ namespace Azure.ResourceManager.ManagedServiceIdentities.Samples { public partial class Sample_UserAssignedIdentityCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_IdentityListByResourceGroup() - { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityListByResourceGroup.json - // this example is just showing the usage of "UserAssignedIdentities_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rgName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this UserAssignedIdentityResource - UserAssignedIdentityCollection collection = resourceGroupResource.GetUserAssignedIdentities(); - - // invoke the operation and iterate over the result - await foreach (UserAssignedIdentityResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - UserAssignedIdentityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_IdentityCreate() @@ -80,7 +45,7 @@ public async Task CreateOrUpdate_IdentityCreate() Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, resourceName, data); @@ -126,6 +91,41 @@ public async Task Get_IdentityGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_IdentityListByResourceGroup() + { + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityListByResourceGroup.json + // this example is just showing the usage of "UserAssignedIdentities_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rgName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this UserAssignedIdentityResource + UserAssignedIdentityCollection collection = resourceGroupResource.GetUserAssignedIdentities(); + + // invoke the operation and iterate over the result + await foreach (UserAssignedIdentityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + UserAssignedIdentityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_IdentityGet() diff --git a/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_UserAssignedIdentityResource.cs b/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_UserAssignedIdentityResource.cs index eb17438c994fa..3bfde1a4550a7 100644 --- a/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_UserAssignedIdentityResource.cs +++ b/sdk/managedserviceidentity/Azure.ResourceManager.ManagedServiceIdentities/samples/Generated/Samples/Sample_UserAssignedIdentityResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagedServiceIdentities.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagedServiceIdentities.Samples @@ -19,41 +18,10 @@ public partial class Sample_UserAssignedIdentityResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetUserAssignedIdentities_IdentityListBySubscription() - { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityListBySubscription.json - // this example is just showing the usage of "UserAssignedIdentities_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (UserAssignedIdentityResource item in subscriptionResource.GetUserAssignedIdentitiesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - UserAssignedIdentityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_IdentityUpdate() + public async Task Get_IdentityGet() { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityUpdate.json - // this example is just showing the usage of "UserAssignedIdentities_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityGet.json + // this example is just showing the usage of "UserAssignedIdentities_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,15 +37,7 @@ public async Task Update_IdentityUpdate() UserAssignedIdentityResource userAssignedIdentity = client.GetUserAssignedIdentityResource(userAssignedIdentityResourceId); // invoke the operation - UserAssignedIdentityPatch patch = new UserAssignedIdentityPatch(new AzureLocation("eastus")) - { - Tags = -{ -["key1"] = "value1", -["key2"] = "value2", -}, - }; - UserAssignedIdentityResource result = await userAssignedIdentity.UpdateAsync(patch); + UserAssignedIdentityResource result = await userAssignedIdentity.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +48,10 @@ public async Task Update_IdentityUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_IdentityGet() + public async Task Delete_IdentityDelete() { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityGet.json - // this example is just showing the usage of "UserAssignedIdentities_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityDelete.json + // this example is just showing the usage of "UserAssignedIdentities_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,21 +67,17 @@ public async Task Get_IdentityGet() UserAssignedIdentityResource userAssignedIdentity = client.GetUserAssignedIdentityResource(userAssignedIdentityResourceId); // invoke the operation - UserAssignedIdentityResource result = await userAssignedIdentity.GetAsync(); + await userAssignedIdentity.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - UserAssignedIdentityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_IdentityDelete() + public async Task Update_IdentityUpdate() { - // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityDelete.json - // this example is just showing the usage of "UserAssignedIdentities_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/msi/resource-manager/Microsoft.ManagedIdentity/stable/2023-01-31/examples/IdentityUpdate.json + // this example is just showing the usage of "UserAssignedIdentities_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,9 +93,21 @@ public async Task Delete_IdentityDelete() UserAssignedIdentityResource userAssignedIdentity = client.GetUserAssignedIdentityResource(userAssignedIdentityResourceId); // invoke the operation - await userAssignedIdentity.DeleteAsync(WaitUntil.Completed); + UserAssignedIdentityPatch patch = new UserAssignedIdentityPatch(new AzureLocation("eastus")) + { + Tags = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + }; + UserAssignedIdentityResource result = await userAssignedIdentity.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + UserAssignedIdentityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesMarketplaceRegistrationCollection.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesMarketplaceRegistrationCollection.cs index 634271fd5515f..6c7910422c0d5 100644 --- a/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesMarketplaceRegistrationCollection.cs +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesMarketplaceRegistrationCollection.cs @@ -17,67 +17,59 @@ public partial class Sample_ManagedServicesMarketplaceRegistrationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRegistrationDefinitions() + public async Task Get_GetRegistrationDefinitions() { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetMarketplaceRegistrationDefinitions.json - // this example is just showing the usage of "MarketplaceRegistrationDefinitions_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetMarketplaceRegistrationDefinition.json + // this example is just showing the usage of "MarketplaceRegistrationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesMarketplaceRegistrationResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesMarketplaceRegistrationCollection collection = client.GetManagedServicesMarketplaceRegistrations(scopeId); + ManagedServicesMarketplaceRegistrationCollection collection = client.GetManagedServicesMarketplaceRegistrations(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - string filter = "planIdentifier eq 'publisher.offerIdentifier.planName.version'"; - await foreach (ManagedServicesMarketplaceRegistrationResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServicesMarketplaceRegistrationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string marketplaceIdentifier = "publisher.product.planName.version"; + ManagedServicesMarketplaceRegistrationResource result = await collection.GetAsync(marketplaceIdentifier); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServicesMarketplaceRegistrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistrationDefinitions() + public async Task GetAll_GetRegistrationDefinitions() { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetMarketplaceRegistrationDefinition.json - // this example is just showing the usage of "MarketplaceRegistrationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetMarketplaceRegistrationDefinitions.json + // this example is just showing the usage of "MarketplaceRegistrationDefinitions_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesMarketplaceRegistrationResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesMarketplaceRegistrationCollection collection = client.GetManagedServicesMarketplaceRegistrations(scopeId); + ManagedServicesMarketplaceRegistrationCollection collection = client.GetManagedServicesMarketplaceRegistrations(new ResourceIdentifier(scope)); - // invoke the operation - string marketplaceIdentifier = "publisher.product.planName.version"; - ManagedServicesMarketplaceRegistrationResource result = await collection.GetAsync(marketplaceIdentifier); + // invoke the operation and iterate over the result + string filter = "planIdentifier eq 'publisher.offerIdentifier.planName.version'"; + await foreach (ManagedServicesMarketplaceRegistrationResource item in collection.GetAllAsync(filter: filter)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServicesMarketplaceRegistrationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServicesMarketplaceRegistrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -92,13 +84,9 @@ public async Task Exists_GetRegistrationDefinitions() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesMarketplaceRegistrationResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesMarketplaceRegistrationCollection collection = client.GetManagedServicesMarketplaceRegistrations(scopeId); + ManagedServicesMarketplaceRegistrationCollection collection = client.GetManagedServicesMarketplaceRegistrations(new ResourceIdentifier(scope)); // invoke the operation string marketplaceIdentifier = "publisher.product.planName.version"; @@ -119,13 +107,9 @@ public async Task GetIfExists_GetRegistrationDefinitions() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesMarketplaceRegistrationResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesMarketplaceRegistrationCollection collection = client.GetManagedServicesMarketplaceRegistrations(scopeId); + ManagedServicesMarketplaceRegistrationCollection collection = client.GetManagedServicesMarketplaceRegistrations(new ResourceIdentifier(scope)); // invoke the operation string marketplaceIdentifier = "publisher.product.planName.version"; diff --git a/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationAssignmentCollection.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationAssignmentCollection.cs index 7c0c008d9487d..3478befa2a511 100644 --- a/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationAssignmentCollection.cs +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationAssignmentCollection.cs @@ -18,27 +18,28 @@ public partial class Sample_ManagedServicesRegistrationAssignmentCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistrationAssignment() + public async Task CreateOrUpdate_PutRegistrationAssignment() { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignment.json - // this example is just showing the usage of "RegistrationAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/PutRegistrationAssignment.json + // this example is just showing the usage of "RegistrationAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationAssignmentResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(scopeId); + ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(new ResourceIdentifier(scope)); // invoke the operation string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; - ManagedServicesRegistrationAssignmentResource result = await collection.GetAsync(registrationAssignmentId); + ManagedServicesRegistrationAssignmentData data = new ManagedServicesRegistrationAssignmentData + { + Properties = new ManagedServicesRegistrationAssignmentProperties(new ResourceIdentifier("/subscriptions/0afefe50-734e-4610-8a82-a144ahf49dea/providers/Microsoft.ManagedServices/registrationDefinitions/26c128c2-fefa-4340-9bb1-6e081c90ada2")), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registrationAssignmentId, data); + ManagedServicesRegistrationAssignmentResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,7 +50,7 @@ public async Task Get_GetRegistrationAssignment() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistrationAssignment() + public async Task Get_GetRegistrationAssignment() { // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignment.json // this example is just showing the usage of "RegistrationAssignments_Get" operation, for the dependent resources, they will have to be created separately. @@ -59,101 +60,85 @@ public async Task Exists_GetRegistrationAssignment() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationAssignmentResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(scopeId); + ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(new ResourceIdentifier(scope)); // invoke the operation string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; - bool result = await collection.ExistsAsync(registrationAssignmentId); + ManagedServicesRegistrationAssignmentResource result = await collection.GetAsync(registrationAssignmentId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServicesRegistrationAssignmentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistrationAssignment() + public async Task GetAll_GetRegistrationAssignments() { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignment.json - // this example is just showing the usage of "RegistrationAssignments_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignments.json + // this example is just showing the usage of "RegistrationAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationAssignmentResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(scopeId); + ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(new ResourceIdentifier(scope)); - // invoke the operation - string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; - NullableResponse response = await collection.GetIfExistsAsync(registrationAssignmentId); - ManagedServicesRegistrationAssignmentResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ManagedServicesRegistrationAssignmentResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedServicesRegistrationAssignmentData resourceData = result.Data; + ManagedServicesRegistrationAssignmentData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutRegistrationAssignment() + public async Task GetAll_GetRegistrationAssignmentsWithManagedByTenantIdEqFilter() { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/PutRegistrationAssignment.json - // this example is just showing the usage of "RegistrationAssignments_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignmentsWithManagedByTenantIdEqFilter.json + // this example is just showing the usage of "RegistrationAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationAssignmentResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(scopeId); + ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(new ResourceIdentifier(scope)); - // invoke the operation - string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; - ManagedServicesRegistrationAssignmentData data = new ManagedServicesRegistrationAssignmentData() + // invoke the operation and iterate over the result + string filter = "$filter=managedByTenantId eq '83abe5cd-bcc3-441a-bd86-e6a75360cecc'"; + await foreach (ManagedServicesRegistrationAssignmentResource item in collection.GetAllAsync(filter: filter)) { - Properties = new ManagedServicesRegistrationAssignmentProperties(new ResourceIdentifier("/subscriptions/0afefe50-734e-4610-8a82-a144ahf49dea/providers/Microsoft.ManagedServices/registrationDefinitions/26c128c2-fefa-4340-9bb1-6e081c90ada2")), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, registrationAssignmentId, data); - ManagedServicesRegistrationAssignmentResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServicesRegistrationAssignmentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServicesRegistrationAssignmentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRegistrationAssignments() + public async Task GetAll_GetRegistrationAssignmentsWithManagedByTenantIdInFilter() { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignments.json + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignmentsWithManagedByTenantIdInFilter.json // this example is just showing the usage of "RegistrationAssignments_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -161,16 +146,13 @@ public async Task GetAll_GetRegistrationAssignments() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationAssignmentResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(scopeId); + ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result - await foreach (ManagedServicesRegistrationAssignmentResource item in collection.GetAllAsync()) + string filter = "$filter=managedByTenantId in (83abe5cd-bcc3-441a-bd86-e6a75360cec, de83f4a9-a76a-4025-a91a-91171923eac7)"; + await foreach (ManagedServicesRegistrationAssignmentResource item in collection.GetAllAsync(filter: filter)) { // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -184,70 +166,60 @@ public async Task GetAll_GetRegistrationAssignments() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRegistrationAssignmentsWithManagedByTenantIdEqFilter() + public async Task Exists_GetRegistrationAssignment() { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignmentsWithManagedByTenantIdEqFilter.json - // this example is just showing the usage of "RegistrationAssignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignment.json + // this example is just showing the usage of "RegistrationAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationAssignmentResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(scopeId); + ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - string filter = "$filter=managedByTenantId eq '83abe5cd-bcc3-441a-bd86-e6a75360cecc'"; - await foreach (ManagedServicesRegistrationAssignmentResource item in collection.GetAllAsync(filter: filter)) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServicesRegistrationAssignmentData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + bool result = await collection.ExistsAsync(registrationAssignmentId); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetRegistrationAssignmentsWithManagedByTenantIdInFilter() + public async Task GetIfExists_GetRegistrationAssignment() { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignmentsWithManagedByTenantIdInFilter.json - // this example is just showing the usage of "RegistrationAssignments_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationAssignment.json + // this example is just showing the usage of "RegistrationAssignments_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationAssignmentResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(scopeId); + ManagedServicesRegistrationAssignmentCollection collection = client.GetManagedServicesRegistrationAssignments(new ResourceIdentifier(scope)); - // invoke the operation and iterate over the result - string filter = "$filter=managedByTenantId in (83abe5cd-bcc3-441a-bd86-e6a75360cec, de83f4a9-a76a-4025-a91a-91171923eac7)"; - await foreach (ManagedServicesRegistrationAssignmentResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string registrationAssignmentId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + NullableResponse response = await collection.GetIfExistsAsync(registrationAssignmentId); + ManagedServicesRegistrationAssignmentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ManagedServicesRegistrationAssignmentData resourceData = item.Data; + ManagedServicesRegistrationAssignmentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationAssignmentResource.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationAssignmentResource.cs index 0be4bf709c0ae..d19166b9d7185 100644 --- a/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationAssignmentResource.cs +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationAssignmentResource.cs @@ -90,7 +90,7 @@ public async Task Update_PutRegistrationAssignment() ManagedServicesRegistrationAssignmentResource managedServicesRegistrationAssignment = client.GetManagedServicesRegistrationAssignmentResource(managedServicesRegistrationAssignmentResourceId); // invoke the operation - ManagedServicesRegistrationAssignmentData data = new ManagedServicesRegistrationAssignmentData() + ManagedServicesRegistrationAssignmentData data = new ManagedServicesRegistrationAssignmentData { Properties = new ManagedServicesRegistrationAssignmentProperties(new ResourceIdentifier("/subscriptions/0afefe50-734e-4610-8a82-a144ahf49dea/providers/Microsoft.ManagedServices/registrationDefinitions/26c128c2-fefa-4340-9bb1-6e081c90ada2")), }; diff --git a/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationCollection.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationCollection.cs index 5ed52f29c1378..a06ec83558c42 100644 --- a/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationCollection.cs +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationCollection.cs @@ -17,103 +17,6 @@ namespace Azure.ResourceManager.ManagedServices.Samples { public partial class Sample_ManagedServicesRegistrationCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetRegistrationDefinition() - { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationDefinition.json - // this example is just showing the usage of "RegistrationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ManagedServicesRegistrationResource - string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(scopeId); - - // invoke the operation - string registrationId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; - ManagedServicesRegistrationResource result = await collection.GetAsync(registrationId); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServicesRegistrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRegistrationDefinition() - { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationDefinition.json - // this example is just showing the usage of "RegistrationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ManagedServicesRegistrationResource - string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(scopeId); - - // invoke the operation - string registrationId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; - bool result = await collection.ExistsAsync(registrationId); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRegistrationDefinition() - { - // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationDefinition.json - // this example is just showing the usage of "RegistrationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this ManagedServicesRegistrationResource - string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(scopeId); - - // invoke the operation - string registrationId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; - NullableResponse response = await collection.GetIfExistsAsync(registrationId); - ManagedServicesRegistrationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ManagedServicesRegistrationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_PutRegistrationDefinition() @@ -126,52 +29,40 @@ public async Task CreateOrUpdate_PutRegistrationDefinition() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(scopeId); + ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(new ResourceIdentifier(scope)); // invoke the operation string registrationId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; - ManagedServicesRegistrationData data = new ManagedServicesRegistrationData() + ManagedServicesRegistrationData data = new ManagedServicesRegistrationData { Properties = new ManagedServicesRegistrationProperties(new ManagedServicesAuthorization[] { -new ManagedServicesAuthorization(Guid.Parse("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc"),"acdd72a7-3385-48ef-bd42-f606fba81ae7") +new ManagedServicesAuthorization(Guid.Parse("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc"), "acdd72a7-3385-48ef-bd42-f606fba81ae7") { PrincipalIdDisplayName = "Support User", -},new ManagedServicesAuthorization(Guid.Parse("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc"),"18d7d88d-d35e-4fb5-a5c3-7773c20a72d9") +}, +new ManagedServicesAuthorization(Guid.Parse("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc"), "18d7d88d-d35e-4fb5-a5c3-7773c20a72d9") { PrincipalIdDisplayName = "User Access Administrator", -DelegatedRoleDefinitionIds = -{ -Guid.Parse("b24988ac-6180-42a0-ab88-20f7382dd24c") -}, +DelegatedRoleDefinitionIds = {Guid.Parse("b24988ac-6180-42a0-ab88-20f7382dd24c")}, } }, Guid.Parse("83abe5cd-bcc3-441a-bd86-e6a75360cecc")) { Description = "Tes1t", - EligibleAuthorizations = -{ -new ManagedServicesEligibleAuthorization(Guid.Parse("3e0ed8c6-e902-4fc5-863c-e3ddbb2ae2a2"),"ae349356-3a1b-4a5e-921d-050484c6347e") + EligibleAuthorizations = {new ManagedServicesEligibleAuthorization(Guid.Parse("3e0ed8c6-e902-4fc5-863c-e3ddbb2ae2a2"), "ae349356-3a1b-4a5e-921d-050484c6347e") { PrincipalIdDisplayName = "Support User", JustInTimeAccessPolicy = new ManagedServicesJustInTimeAccessPolicy(MultiFactorAuthProvider.Azure) { MaximumActivationDuration = XmlConvert.ToTimeSpan("PT8H"), -ManagedByTenantApprovers = -{ -new ManagedServicesEligibleApprover(Guid.Parse("d9b22cd6-6407-43cc-8c60-07c56df0b51a")) +ManagedByTenantApprovers = {new ManagedServicesEligibleApprover(Guid.Parse("d9b22cd6-6407-43cc-8c60-07c56df0b51a")) { PrincipalIdDisplayName = "Approver Group", -} -}, -}, -} +}}, }, +}}, RegistrationDefinitionName = "DefinitionName", }, Plan = new ManagedServicesPlan("addesai-plan", "marketplace-test", "test", "1.0.0"), @@ -186,6 +77,33 @@ public async Task CreateOrUpdate_PutRegistrationDefinition() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetRegistrationDefinition() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationDefinition.json + // this example is just showing the usage of "RegistrationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ManagedServicesRegistrationResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(new ResourceIdentifier(scope)); + + // invoke the operation + string registrationId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + ManagedServicesRegistrationResource result = await collection.GetAsync(registrationId); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServicesRegistrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_GetRegistrationDefinitions() @@ -198,13 +116,9 @@ public async Task GetAll_GetRegistrationDefinitions() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(scopeId); + ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result await foreach (ManagedServicesRegistrationResource item in collection.GetAllAsync()) @@ -231,13 +145,9 @@ public async Task GetAll_GetRegistrationDefinitionsWithManagedByTenantIdEqFilter // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(scopeId); + ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result string filter = "$filter=managedByTenantId eq '83ace5cd-bcc3-441a-hd86-e6a75360cecc'"; @@ -265,13 +175,9 @@ public async Task GetAll_GetRegistrationDefinitionsWithManagedByTenantIdInFilter // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this ManagedServicesRegistrationResource string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", scope)); - ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(scopeId); + ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(new ResourceIdentifier(scope)); // invoke the operation and iterate over the result string filter = "$filter=managedByTenantId in (83ace5cd-bcc3-441a-hd86-e6a75360cecc, de83f4a9-a76a-4025-a91a-91171923eac7)"; @@ -286,5 +192,63 @@ public async Task GetAll_GetRegistrationDefinitionsWithManagedByTenantIdInFilter Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetRegistrationDefinition() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationDefinition.json + // this example is just showing the usage of "RegistrationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ManagedServicesRegistrationResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(new ResourceIdentifier(scope)); + + // invoke the operation + string registrationId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + bool result = await collection.ExistsAsync(registrationId); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetRegistrationDefinition() + { + // Generated from example definition: specification/managedservices/resource-manager/Microsoft.ManagedServices/stable/2022-10-01/examples/GetRegistrationDefinition.json + // this example is just showing the usage of "RegistrationDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this ManagedServicesRegistrationResource + string scope = "subscription/0afefe50-734e-4610-8a82-a144ahf49dea"; + ManagedServicesRegistrationCollection collection = client.GetManagedServicesRegistrations(new ResourceIdentifier(scope)); + + // invoke the operation + string registrationId = "26c128c2-fefa-4340-9bb1-6e081c90ada2"; + NullableResponse response = await collection.GetIfExistsAsync(registrationId); + ManagedServicesRegistrationResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ManagedServicesRegistrationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationResource.cs b/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationResource.cs index 67e901c96e01e..4606ac90bc0fb 100644 --- a/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationResource.cs +++ b/sdk/managedservices/Azure.ResourceManager.ManagedServices/samples/Generated/Samples/Sample_ManagedServicesRegistrationResource.cs @@ -91,42 +91,34 @@ public async Task Update_PutRegistrationDefinition() ManagedServicesRegistrationResource managedServicesRegistration = client.GetManagedServicesRegistrationResource(managedServicesRegistrationResourceId); // invoke the operation - ManagedServicesRegistrationData data = new ManagedServicesRegistrationData() + ManagedServicesRegistrationData data = new ManagedServicesRegistrationData { Properties = new ManagedServicesRegistrationProperties(new ManagedServicesAuthorization[] { -new ManagedServicesAuthorization(Guid.Parse("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc"),"acdd72a7-3385-48ef-bd42-f606fba81ae7") +new ManagedServicesAuthorization(Guid.Parse("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc"), "acdd72a7-3385-48ef-bd42-f606fba81ae7") { PrincipalIdDisplayName = "Support User", -},new ManagedServicesAuthorization(Guid.Parse("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc"),"18d7d88d-d35e-4fb5-a5c3-7773c20a72d9") +}, +new ManagedServicesAuthorization(Guid.Parse("f98d86a2-4cc4-4e9d-ad47-b3e80a1bcdfc"), "18d7d88d-d35e-4fb5-a5c3-7773c20a72d9") { PrincipalIdDisplayName = "User Access Administrator", -DelegatedRoleDefinitionIds = -{ -Guid.Parse("b24988ac-6180-42a0-ab88-20f7382dd24c") -}, +DelegatedRoleDefinitionIds = {Guid.Parse("b24988ac-6180-42a0-ab88-20f7382dd24c")}, } }, Guid.Parse("83abe5cd-bcc3-441a-bd86-e6a75360cecc")) { Description = "Tes1t", - EligibleAuthorizations = -{ -new ManagedServicesEligibleAuthorization(Guid.Parse("3e0ed8c6-e902-4fc5-863c-e3ddbb2ae2a2"),"ae349356-3a1b-4a5e-921d-050484c6347e") + EligibleAuthorizations = {new ManagedServicesEligibleAuthorization(Guid.Parse("3e0ed8c6-e902-4fc5-863c-e3ddbb2ae2a2"), "ae349356-3a1b-4a5e-921d-050484c6347e") { PrincipalIdDisplayName = "Support User", JustInTimeAccessPolicy = new ManagedServicesJustInTimeAccessPolicy(MultiFactorAuthProvider.Azure) { MaximumActivationDuration = XmlConvert.ToTimeSpan("PT8H"), -ManagedByTenantApprovers = -{ -new ManagedServicesEligibleApprover(Guid.Parse("d9b22cd6-6407-43cc-8c60-07c56df0b51a")) +ManagedByTenantApprovers = {new ManagedServicesEligibleApprover(Guid.Parse("d9b22cd6-6407-43cc-8c60-07c56df0b51a")) { PrincipalIdDisplayName = "Approver Group", -} -}, -}, -} +}}, }, +}}, RegistrationDefinitionName = "DefinitionName", }, Plan = new ManagedServicesPlan("addesai-plan", "marketplace-test", "test", "1.0.0"), diff --git a/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_PartnerResponseCollection.cs b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_PartnerResponseCollection.cs index 4b9962e3f54fb..aa2b8b52a3e20 100644 --- a/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_PartnerResponseCollection.cs +++ b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_PartnerResponseCollection.cs @@ -9,12 +9,42 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagementPartner.Samples { public partial class Sample_PartnerResponseCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_PutPartnerDetails() + { + // Generated from example definition: specification/managementpartner/resource-manager/Microsoft.ManagementPartner/preview/2018-02-01/examples/PutPartnerDetails.json + // this example is just showing the usage of "Partner_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this PartnerResponseResource + PartnerResponseCollection collection = tenantResource.GetPartnerResponses(); + + // invoke the operation + string partnerId = "123456"; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerId); + PartnerResponseResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerResponseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetPartnerDetails() @@ -27,9 +57,7 @@ public async Task Get_GetPartnerDetails() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PartnerResponseResource PartnerResponseCollection collection = tenantResource.GetPartnerResponses(); @@ -57,9 +85,7 @@ public async Task Exists_GetPartnerDetails() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PartnerResponseResource PartnerResponseCollection collection = tenantResource.GetPartnerResponses(); @@ -83,9 +109,7 @@ public async Task GetIfExists_GetPartnerDetails() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PartnerResponseResource PartnerResponseCollection collection = tenantResource.GetPartnerResponses(); @@ -108,36 +132,5 @@ public async Task GetIfExists_GetPartnerDetails() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutPartnerDetails() - { - // Generated from example definition: specification/managementpartner/resource-manager/Microsoft.ManagementPartner/preview/2018-02-01/examples/PutPartnerDetails.json - // this example is just showing the usage of "Partner_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this PartnerResponseResource - PartnerResponseCollection collection = tenantResource.GetPartnerResponses(); - - // invoke the operation - string partnerId = "123456"; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, partnerId); - PartnerResponseResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerResponseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_PartnerResponseResource.cs b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_PartnerResponseResource.cs index f9a9a7f753f26..f86a95d22b5b8 100644 --- a/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_PartnerResponseResource.cs +++ b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_PartnerResponseResource.cs @@ -45,10 +45,10 @@ public async Task Get_GetPartnerDetails() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchPartnerDetails() + public async Task Delete_DeletePartnerDetails() { - // Generated from example definition: specification/managementpartner/resource-manager/Microsoft.ManagementPartner/preview/2018-02-01/examples/PatchPartnerDetails.json - // this example is just showing the usage of "Partner_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementpartner/resource-manager/Microsoft.ManagementPartner/preview/2018-02-01/examples/DeletePartnerDetails.json + // this example is just showing the usage of "Partner_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,21 +62,17 @@ public async Task Update_PatchPartnerDetails() PartnerResponseResource partnerResponse = client.GetPartnerResponseResource(partnerResponseResourceId); // invoke the operation - PartnerResponseResource result = await partnerResponse.UpdateAsync(); + await partnerResponse.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PartnerResponseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePartnerDetails() + public async Task Update_PatchPartnerDetails() { - // Generated from example definition: specification/managementpartner/resource-manager/Microsoft.ManagementPartner/preview/2018-02-01/examples/DeletePartnerDetails.json - // this example is just showing the usage of "Partner_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/managementpartner/resource-manager/Microsoft.ManagementPartner/preview/2018-02-01/examples/PatchPartnerDetails.json + // this example is just showing the usage of "Partner_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -90,9 +86,13 @@ public async Task Delete_DeletePartnerDetails() PartnerResponseResource partnerResponse = client.GetPartnerResponseResource(partnerResponseResourceId); // invoke the operation - await partnerResponse.DeleteAsync(WaitUntil.Completed); + PartnerResponseResource result = await partnerResponse.UpdateAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PartnerResponseData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index 3c59bf29451df..eeaa7e57f53c9 100644 --- a/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/managementpartner/Azure.ResourceManager.ManagementPartner/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.ManagementPartner.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.ManagementPartner.Samples @@ -28,9 +29,7 @@ public async Task GetOperations_GetOperations() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (OperationResponse item in tenantResource.GetOperationsAsync()) diff --git a/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsAccountCollection.cs b/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsAccountCollection.cs index 3bf262843bd12..e158eb68aaf45 100644 --- a/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsAccountCollection.cs +++ b/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsAccountCollection.cs @@ -49,20 +49,17 @@ public async Task CreateOrUpdate_CreateAccountWithManagedIdentities() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName")] = new UserAssignedIdentity() }, }, - Properties = new MapsAccountProperties() + Properties = new MapsAccountProperties { DisableLocalAuth = false, - LinkedResources = -{ -new MapsLinkedResource("myBatchStorageAccount","/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.Storage/accounts/mystorageacc"),new MapsLinkedResource("myBlobDataSource","/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.Storage/accounts/mystorageacc") -}, + LinkedResources = { new MapsLinkedResource("myBatchStorageAccount", "/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.Storage/accounts/mystorageacc"), new MapsLinkedResource("myBlobDataSource", "/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.Storage/accounts/mystorageacc") }, }, Tags = { -["test"] = "true", +["test"] = "true" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); @@ -102,20 +99,14 @@ public async Task CreateOrUpdate_CreateGen1Account() MapsAccountData data = new MapsAccountData(new AzureLocation("eastus"), new MapsSku(MapsSkuName.S0)) { Kind = MapsAccountKind.Gen1, - Properties = new MapsAccountProperties() + Properties = new MapsAccountProperties { DisableLocalAuth = false, - CorsRulesValue = -{ -new MapsCorsRule(new string[] -{ -"http://www.contoso.com","http://www.fabrikam.com" -}) -}, + CorsRulesValue = { new MapsCorsRule(new string[] { "http://www.contoso.com", "http://www.fabrikam.com" }) }, }, Tags = { -["test"] = "true", +["test"] = "true" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); @@ -155,20 +146,14 @@ public async Task CreateOrUpdate_CreateGen2Account() MapsAccountData data = new MapsAccountData(new AzureLocation("eastus"), new MapsSku(MapsSkuName.G2)) { Kind = MapsAccountKind.Gen2, - Properties = new MapsAccountProperties() + Properties = new MapsAccountProperties { DisableLocalAuth = true, - CorsRulesValue = -{ -new MapsCorsRule(new string[] -{ -"http://www.contoso.com","http://www.fabrikam.com" -}) -}, + CorsRulesValue = { new MapsCorsRule(new string[] { "http://www.contoso.com", "http://www.fabrikam.com" }) }, }, Tags = { -["test"] = "true", +["test"] = "true" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); @@ -216,10 +201,10 @@ public async Task Get_GetAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAccount() + public async Task GetAll_ListAccountsByResourceGroup() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetAccount.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/ListAccountsByResourceGroup.json + // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,16 +221,22 @@ public async Task Exists_GetAccount() // get the collection of this MapsAccountResource MapsAccountCollection collection = resourceGroupResource.GetMapsAccounts(); - // invoke the operation - string accountName = "myMapsAccount"; - bool result = await collection.ExistsAsync(accountName); + // invoke the operation and iterate over the result + await foreach (MapsAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MapsAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAccount() + public async Task Exists_GetAccount() { // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetAccount.json // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -267,29 +258,17 @@ public async Task GetIfExists_GetAccount() // invoke the operation string accountName = "myMapsAccount"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - MapsAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MapsAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAccountsByResourceGroup() + public async Task GetIfExists_GetAccount() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/ListAccountsByResourceGroup.json - // this example is just showing the usage of "Accounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetAccount.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -306,17 +285,23 @@ public async Task GetAll_ListAccountsByResourceGroup() // get the collection of this MapsAccountResource MapsAccountCollection collection = resourceGroupResource.GetMapsAccounts(); - // invoke the operation and iterate over the result - await foreach (MapsAccountResource item in collection.GetAllAsync()) + // invoke the operation + string accountName = "myMapsAccount"; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + MapsAccountResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MapsAccountData resourceData = item.Data; + MapsAccountData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsAccountResource.cs b/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsAccountResource.cs index 42f242b3950b0..c2c9a066ebcb0 100644 --- a/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsAccountResource.cs +++ b/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsAccountResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Maps.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Maps.Samples @@ -20,10 +19,10 @@ public partial class Sample_MapsAccountResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAccountManagedIdentities() + public async Task Get_GetAccount() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateAccountManagedIdentity.json - // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetAccount.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,23 +38,7 @@ public async Task Update_UpdateAccountManagedIdentities() MapsAccountResource mapsAccount = client.GetMapsAccountResource(mapsAccountResourceId); // invoke the operation - MapsAccountPatch patch = new MapsAccountPatch() - { - Kind = MapsAccountKind.Gen2, - Sku = new MapsSku(MapsSkuName.G2), - Identity = new ManagedServiceIdentity("SystemAssigned, UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName")] = new UserAssignedIdentity(), -}, - }, - LinkedResources = -{ -new MapsLinkedResource("myBatchStorageAccount","/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/accounts/{storageName}") -}, - }; - MapsAccountResource result = await mapsAccount.UpdateAsync(patch); + MapsAccountResource result = await mapsAccount.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -66,10 +49,10 @@ public async Task Update_UpdateAccountManagedIdentities() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAccountTags() + public async Task Delete_DeleteAccount() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateAccount.json - // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/DeleteAccount.json + // this example is just showing the usage of "Accounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -85,27 +68,16 @@ public async Task Update_UpdateAccountTags() MapsAccountResource mapsAccount = client.GetMapsAccountResource(mapsAccountResourceId); // invoke the operation - MapsAccountPatch patch = new MapsAccountPatch() - { - Tags = -{ -["specialTag"] = "true", -}, - }; - MapsAccountResource result = await mapsAccount.UpdateAsync(patch); + await mapsAccount.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MapsAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateToGen1Account() + public async Task Update_UpdateAccountManagedIdentities() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateAccountGen1.json + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateAccountManagedIdentity.json // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -122,10 +94,18 @@ public async Task Update_UpdateToGen1Account() MapsAccountResource mapsAccount = client.GetMapsAccountResource(mapsAccountResourceId); // invoke the operation - MapsAccountPatch patch = new MapsAccountPatch() + MapsAccountPatch patch = new MapsAccountPatch { - Kind = MapsAccountKind.Gen1, - Sku = new MapsSku(MapsSkuName.S1), + Kind = MapsAccountKind.Gen2, + Sku = new MapsSku(MapsSkuName.G2), + Identity = new ManagedServiceIdentity("SystemAssigned, UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/21a9967a-e8a9-4656-a70b-96ff1c4d05a0/resourceGroups/myResourceGroup/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identityName")] = new UserAssignedIdentity() +}, + }, + LinkedResources = { new MapsLinkedResource("myBatchStorageAccount", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/accounts/{storageName}") }, }; MapsAccountResource result = await mapsAccount.UpdateAsync(patch); @@ -138,9 +118,9 @@ public async Task Update_UpdateToGen1Account() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateToGen2Account() + public async Task Update_UpdateAccountTags() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateAccountGen2.json + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateAccount.json // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -157,10 +137,12 @@ public async Task Update_UpdateToGen2Account() MapsAccountResource mapsAccount = client.GetMapsAccountResource(mapsAccountResourceId); // invoke the operation - MapsAccountPatch patch = new MapsAccountPatch() + MapsAccountPatch patch = new MapsAccountPatch { - Kind = MapsAccountKind.Gen2, - Sku = new MapsSku(MapsSkuName.G2), + Tags = +{ +["specialTag"] = "true" +}, }; MapsAccountResource result = await mapsAccount.UpdateAsync(patch); @@ -173,10 +155,10 @@ public async Task Update_UpdateToGen2Account() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAccount() + public async Task Update_UpdateToGen1Account() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/DeleteAccount.json - // this example is just showing the usage of "Accounts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateAccountGen1.json + // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,17 +174,26 @@ public async Task Delete_DeleteAccount() MapsAccountResource mapsAccount = client.GetMapsAccountResource(mapsAccountResourceId); // invoke the operation - await mapsAccount.DeleteAsync(WaitUntil.Completed); + MapsAccountPatch patch = new MapsAccountPatch + { + Kind = MapsAccountKind.Gen1, + Sku = new MapsSku(MapsSkuName.S1), + }; + MapsAccountResource result = await mapsAccount.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MapsAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAccount() + public async Task Update_UpdateToGen2Account() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetAccount.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateAccountGen2.json + // this example is just showing the usage of "Accounts_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -218,7 +209,12 @@ public async Task Get_GetAccount() MapsAccountResource mapsAccount = client.GetMapsAccountResource(mapsAccountResourceId); // invoke the operation - MapsAccountResource result = await mapsAccount.GetAsync(); + MapsAccountPatch patch = new MapsAccountPatch + { + Kind = MapsAccountKind.Gen2, + Sku = new MapsSku(MapsSkuName.G2), + }; + MapsAccountResource result = await mapsAccount.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -227,37 +223,6 @@ public async Task Get_GetAccount() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMapsAccounts_ListAccountsBySubscription() - { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/ListAccountsBySubscription.json - // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "21a9967a-e8a9-4656-a70b-96ff1c4d05a0"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MapsAccountResource item in subscriptionResource.GetMapsAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MapsAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSas_ListAccountSas() @@ -281,10 +246,7 @@ public async Task GetSas_ListAccountSas() // invoke the operation MapsAccountSasContent content = new MapsAccountSasContent(MapsSigningKey.PrimaryKey, "e917f87b-324d-4728-98ed-e31d311a7d65", 500, "2017-05-24T10:42:03.1567373Z", "2017-05-24T11:42:03.1567373Z") { - Regions = -{ -"eastus" -}, + Regions = { "eastus" }, }; MapsAccountSasToken result = await mapsAccount.GetSasAsync(content); diff --git a/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsCreatorCollection.cs b/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsCreatorCollection.cs index ac9f8d5e9ce01..a2c4aa3f84a29 100644 --- a/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsCreatorCollection.cs +++ b/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsCreatorCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MapsCreatorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListCreatorResourcesByAccount() + public async Task CreateOrUpdate_CreateCreatorResource() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/ListMapsCreatorsByAccount.json - // this example is just showing the usage of "Creators_ListByAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/CreateMapsCreator.json + // this example is just showing the usage of "Creators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,31 @@ public async Task GetAll_ListCreatorResourcesByAccount() // get the collection of this MapsCreatorResource MapsCreatorCollection collection = mapsAccount.GetMapsCreators(); - // invoke the operation and iterate over the result - await foreach (MapsCreatorResource item in collection.GetAllAsync()) + // invoke the operation + string creatorName = "myCreator"; + MapsCreatorData data = new MapsCreatorData(new AzureLocation("eastus2"), new MapsCreatorProperties(5)) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MapsCreatorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["test"] = "true" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, creatorName, data); + MapsCreatorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MapsCreatorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCreatorResource() + public async Task Get_GetCreatorResource() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/CreateMapsCreator.json - // this example is just showing the usage of "Creators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetMapsCreator.json + // this example is just showing the usage of "Creators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,15 +83,7 @@ public async Task CreateOrUpdate_CreateCreatorResource() // invoke the operation string creatorName = "myCreator"; - MapsCreatorData data = new MapsCreatorData(new AzureLocation("eastus2"), new MapsCreatorProperties(5)) - { - Tags = -{ -["test"] = "true", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, creatorName, data); - MapsCreatorResource result = lro.Value; + MapsCreatorResource result = await collection.GetAsync(creatorName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -96,10 +94,10 @@ public async Task CreateOrUpdate_CreateCreatorResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCreatorResource() + public async Task GetAll_ListCreatorResourcesByAccount() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetMapsCreator.json - // this example is just showing the usage of "Creators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/ListMapsCreatorsByAccount.json + // this example is just showing the usage of "Creators_ListByAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,15 +115,17 @@ public async Task Get_GetCreatorResource() // get the collection of this MapsCreatorResource MapsCreatorCollection collection = mapsAccount.GetMapsCreators(); - // invoke the operation - string creatorName = "myCreator"; - MapsCreatorResource result = await collection.GetAsync(creatorName); + // invoke the operation and iterate over the result + await foreach (MapsCreatorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MapsCreatorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MapsCreatorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsCreatorResource.cs b/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsCreatorResource.cs index 8664a2d601e6b..99125e88cdf32 100644 --- a/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsCreatorResource.cs +++ b/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_MapsCreatorResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MapsCreatorResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateCreatorResource() + public async Task Get_GetCreatorResource() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateMapsCreator.json - // this example is just showing the usage of "Creators_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetMapsCreator.json + // this example is just showing the usage of "Creators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,15 +38,7 @@ public async Task Update_UpdateCreatorResource() MapsCreatorResource mapsCreator = client.GetMapsCreatorResource(mapsCreatorResourceId); // invoke the operation - MapsCreatorPatch patch = new MapsCreatorPatch() - { - Tags = -{ -["specialTag"] = "true", -}, - StorageUnits = 10, - }; - MapsCreatorResource result = await mapsCreator.UpdateAsync(patch); + MapsCreatorResource result = await mapsCreator.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -84,10 +76,10 @@ public async Task Delete_DeleteCreatorResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCreatorResource() + public async Task Update_UpdateCreatorResource() { - // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/GetMapsCreator.json - // this example is just showing the usage of "Creators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/UpdateMapsCreator.json + // this example is just showing the usage of "Creators_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,7 +96,15 @@ public async Task Get_GetCreatorResource() MapsCreatorResource mapsCreator = client.GetMapsCreatorResource(mapsCreatorResourceId); // invoke the operation - MapsCreatorResource result = await mapsCreator.GetAsync(); + MapsCreatorPatch patch = new MapsCreatorPatch + { + Tags = +{ +["specialTag"] = "true" +}, + StorageUnits = 10, + }; + MapsCreatorResource result = await mapsCreator.UpdateAsync(patch); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..e626f950d8ebe --- /dev/null +++ b/sdk/maps/Azure.ResourceManager.Maps/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.Maps.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMapsAccounts_ListAccountsBySubscription() + { + // Generated from example definition: specification/maps/resource-manager/Microsoft.Maps/preview/2021-12-01-preview/examples/ListAccountsBySubscription.json + // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "21a9967a-e8a9-4656-a70b-96ff1c4d05a0"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MapsAccountResource item in subscriptionResource.GetMapsAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MapsAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceAdminApprovalRequestCollection.cs b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceAdminApprovalRequestCollection.cs index fa0fced9f6579..6fa8ef2d06420 100644 --- a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceAdminApprovalRequestCollection.cs +++ b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceAdminApprovalRequestCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MarketplaceAdminApprovalRequestCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AdminRequestApprovalsList() + public async Task CreateOrUpdate_UpdateAdminRequestApproval() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/AdminRequestApprovalsList.json - // this example is just showing the usage of "PrivateStore_AdminRequestApprovalsList" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/UpdateAdminRequestApproval.json + // this example is just showing the usage of "PrivateStore_UpdateAdminRequestApproval" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,24 @@ public async Task GetAll_AdminRequestApprovalsList() // get the collection of this MarketplaceAdminApprovalRequestResource MarketplaceAdminApprovalRequestCollection collection = privateStore.GetMarketplaceAdminApprovalRequests(); - // invoke the operation and iterate over the result - await foreach (MarketplaceAdminApprovalRequestResource item in collection.GetAllAsync()) + // invoke the operation + string adminRequestApprovalId = "marketplacetestthirdparty.md-test-third-party-2"; + MarketplaceAdminApprovalRequestData data = new MarketplaceAdminApprovalRequestData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MarketplaceAdminApprovalRequestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PublisherId = "marketplacetestthirdparty", + AdminAction = MarketplaceAdminAction.Approved, + ApprovedPlans = { "testPlan" }, + Comment = "I'm ok with that", + CollectionIds = { Guid.Parse("f8ee227e-85d7-477d-abbf-854d6decaf70"), Guid.Parse("39246ad6-c521-4fed-8de7-77dede2e873f") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, adminRequestApprovalId, data); + MarketplaceAdminApprovalRequestResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MarketplaceAdminApprovalRequestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -85,10 +92,10 @@ public async Task Get_GetAdminRequestApproval() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAdminRequestApproval() + public async Task GetAll_AdminRequestApprovalsList() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetAdminRequestApproval.json - // this example is just showing the usage of "PrivateStore_GetAdminRequestApproval" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/AdminRequestApprovalsList.json + // this example is just showing the usage of "PrivateStore_AdminRequestApprovalsList" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,17 +111,22 @@ public async Task Exists_GetAdminRequestApproval() // get the collection of this MarketplaceAdminApprovalRequestResource MarketplaceAdminApprovalRequestCollection collection = privateStore.GetMarketplaceAdminApprovalRequests(); - // invoke the operation - string adminRequestApprovalId = "marketplacetestthirdparty.md-test-third-party-2"; - string publisherId = "marketplacetestthirdparty"; - bool result = await collection.ExistsAsync(adminRequestApprovalId, publisherId); + // invoke the operation and iterate over the result + await foreach (MarketplaceAdminApprovalRequestResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MarketplaceAdminApprovalRequestData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAdminRequestApproval() + public async Task Exists_GetAdminRequestApproval() { // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetAdminRequestApproval.json // this example is just showing the usage of "PrivateStore_GetAdminRequestApproval" operation, for the dependent resources, they will have to be created separately. @@ -136,29 +148,17 @@ public async Task GetIfExists_GetAdminRequestApproval() // invoke the operation string adminRequestApprovalId = "marketplacetestthirdparty.md-test-third-party-2"; string publisherId = "marketplacetestthirdparty"; - NullableResponse response = await collection.GetIfExistsAsync(adminRequestApprovalId, publisherId); - MarketplaceAdminApprovalRequestResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(adminRequestApprovalId, publisherId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MarketplaceAdminApprovalRequestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAdminRequestApproval() + public async Task GetIfExists_GetAdminRequestApproval() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/UpdateAdminRequestApproval.json - // this example is just showing the usage of "PrivateStore_UpdateAdminRequestApproval" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetAdminRequestApproval.json + // this example is just showing the usage of "PrivateStore_GetAdminRequestApproval" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,28 +176,22 @@ public async Task CreateOrUpdate_UpdateAdminRequestApproval() // invoke the operation string adminRequestApprovalId = "marketplacetestthirdparty.md-test-third-party-2"; - MarketplaceAdminApprovalRequestData data = new MarketplaceAdminApprovalRequestData() - { - PublisherId = "marketplacetestthirdparty", - AdminAction = MarketplaceAdminAction.Approved, - ApprovedPlans = -{ -"testPlan" -}, - Comment = "I'm ok with that", - CollectionIds = -{ -Guid.Parse("f8ee227e-85d7-477d-abbf-854d6decaf70"),Guid.Parse("39246ad6-c521-4fed-8de7-77dede2e873f") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, adminRequestApprovalId, data); - MarketplaceAdminApprovalRequestResource result = lro.Value; + string publisherId = "marketplacetestthirdparty"; + NullableResponse response = await collection.GetIfExistsAsync(adminRequestApprovalId, publisherId); + MarketplaceAdminApprovalRequestResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MarketplaceAdminApprovalRequestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MarketplaceAdminApprovalRequestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceAdminApprovalRequestResource.cs b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceAdminApprovalRequestResource.cs index 5eb17a9df046f..dd8cd4ccce2f2 100644 --- a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceAdminApprovalRequestResource.cs +++ b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceAdminApprovalRequestResource.cs @@ -66,19 +66,13 @@ public async Task Update_UpdateAdminRequestApproval() MarketplaceAdminApprovalRequestResource marketplaceAdminApprovalRequest = client.GetMarketplaceAdminApprovalRequestResource(marketplaceAdminApprovalRequestResourceId); // invoke the operation - MarketplaceAdminApprovalRequestData data = new MarketplaceAdminApprovalRequestData() + MarketplaceAdminApprovalRequestData data = new MarketplaceAdminApprovalRequestData { PublisherId = "marketplacetestthirdparty", AdminAction = MarketplaceAdminAction.Approved, - ApprovedPlans = -{ -"testPlan" -}, + ApprovedPlans = { "testPlan" }, Comment = "I'm ok with that", - CollectionIds = -{ -Guid.Parse("f8ee227e-85d7-477d-abbf-854d6decaf70"),Guid.Parse("39246ad6-c521-4fed-8de7-77dede2e873f") -}, + CollectionIds = { Guid.Parse("f8ee227e-85d7-477d-abbf-854d6decaf70"), Guid.Parse("39246ad6-c521-4fed-8de7-77dede2e873f") }, }; ArmOperation lro = await marketplaceAdminApprovalRequest.UpdateAsync(WaitUntil.Completed, data); MarketplaceAdminApprovalRequestResource result = lro.Value; diff --git a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceApprovalRequestCollection.cs b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceApprovalRequestCollection.cs index 17bd6fe896acc..6ed255cf9999d 100644 --- a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceApprovalRequestCollection.cs +++ b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceApprovalRequestCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MarketplaceApprovalRequestCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetApprovalRequestsList() + public async Task CreateOrUpdate_CreateApprovalRequest() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetApprovalRequestsList.json - // this example is just showing the usage of "PrivateStore_GetApprovalRequestsList" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/CreateApprovalRequest.json + // this example is just showing the usage of "PrivateStore_CreateApprovalRequest" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,17 +36,17 @@ public async Task GetAll_GetApprovalRequestsList() // get the collection of this MarketplaceApprovalRequestResource MarketplaceApprovalRequestCollection collection = privateStore.GetMarketplaceApprovalRequests(); - // invoke the operation and iterate over the result - await foreach (MarketplaceApprovalRequestResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MarketplaceApprovalRequestData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string requestApprovalId = "marketplacetestthirdparty.md-test-third-party-2"; + MarketplaceApprovalRequestData data = new MarketplaceApprovalRequestData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, requestApprovalId, data); + MarketplaceApprovalRequestResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MarketplaceApprovalRequestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -83,10 +83,10 @@ public async Task Get_GetApprovalRequest() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetApprovalRequest() + public async Task GetAll_GetApprovalRequestsList() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetRequestApproval.json - // this example is just showing the usage of "PrivateStore_GetRequestApproval" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetApprovalRequestsList.json + // this example is just showing the usage of "PrivateStore_GetApprovalRequestsList" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,16 +102,22 @@ public async Task Exists_GetApprovalRequest() // get the collection of this MarketplaceApprovalRequestResource MarketplaceApprovalRequestCollection collection = privateStore.GetMarketplaceApprovalRequests(); - // invoke the operation - string requestApprovalId = "marketplacetestthirdparty.md-test-third-party-2"; - bool result = await collection.ExistsAsync(requestApprovalId); + // invoke the operation and iterate over the result + await foreach (MarketplaceApprovalRequestResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MarketplaceApprovalRequestData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetApprovalRequest() + public async Task Exists_GetApprovalRequest() { // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetRequestApproval.json // this example is just showing the usage of "PrivateStore_GetRequestApproval" operation, for the dependent resources, they will have to be created separately. @@ -132,29 +138,17 @@ public async Task GetIfExists_GetApprovalRequest() // invoke the operation string requestApprovalId = "marketplacetestthirdparty.md-test-third-party-2"; - NullableResponse response = await collection.GetIfExistsAsync(requestApprovalId); - MarketplaceApprovalRequestResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(requestApprovalId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MarketplaceApprovalRequestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateApprovalRequest() + public async Task GetIfExists_GetApprovalRequest() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/CreateApprovalRequest.json - // this example is just showing the usage of "PrivateStore_CreateApprovalRequest" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetRequestApproval.json + // this example is just showing the usage of "PrivateStore_GetRequestApproval" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -172,15 +166,21 @@ public async Task CreateOrUpdate_CreateApprovalRequest() // invoke the operation string requestApprovalId = "marketplacetestthirdparty.md-test-third-party-2"; - MarketplaceApprovalRequestData data = new MarketplaceApprovalRequestData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, requestApprovalId, data); - MarketplaceApprovalRequestResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(requestApprovalId); + MarketplaceApprovalRequestResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MarketplaceApprovalRequestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MarketplaceApprovalRequestData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceApprovalRequestResource.cs b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceApprovalRequestResource.cs index 7e0529e5f5553..cf171f006a83f 100644 --- a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceApprovalRequestResource.cs +++ b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_MarketplaceApprovalRequestResource.cs @@ -96,13 +96,10 @@ public async Task QueryApprovalRequest_QueryRequestApproval() MarketplaceApprovalRequestResource marketplaceApprovalRequest = client.GetMarketplaceApprovalRequestResource(marketplaceApprovalRequestResourceId); // invoke the operation - QueryApprovalRequestContent content = new QueryApprovalRequestContent() + QueryApprovalRequestContent content = new QueryApprovalRequestContent { PublisherId = "marketplacetestthirdparty", - PlanIds = -{ -"testPlanA","testPlanB","*" -}, + PlanIds = { "testPlanA", "testPlanB", "*" }, }; QueryApprovalRequestResult result = await marketplaceApprovalRequest.QueryApprovalRequestAsync(content: content); @@ -129,7 +126,7 @@ public async Task WithdrawPlan_WithdrawPlan() MarketplaceApprovalRequestResource marketplaceApprovalRequest = client.GetMarketplaceApprovalRequestResource(marketplaceApprovalRequestResourceId); // invoke the operation - WithdrawPlanContent content = new WithdrawPlanContent() + WithdrawPlanContent content = new WithdrawPlanContent { PlanId = "*", PublisherId = "marketplacetestthirdparty", diff --git a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollection.cs b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollection.cs index bfbcad14c094e..56a1cbe23bd60 100644 --- a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollection.cs +++ b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollection.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Marketplace.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Marketplace.Samples @@ -18,32 +19,29 @@ public partial class Sample_PrivateStoreCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetPrivateStores() + public async Task CreateOrUpdate_PrivateStoresUpdate() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStores.json - // this example is just showing the usage of "PrivateStore_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PrivateStores_update.json + // this example is just showing the usage of "PrivateStore_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PrivateStoreResource PrivateStoreCollection collection = tenantResource.GetPrivateStores(); - // invoke the operation and iterate over the result - await foreach (PrivateStoreResource item in collection.GetAllAsync()) + // invoke the operation + Guid privateStoreId = Guid.Parse("a0e28e55-90c4-41d8-8e34-bb7ef7775406"); + PrivateStoreData data = new PrivateStoreData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateStoreData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Availability = PrivateStoreAvailability.Disabled, + ETag = new ETag("\"9301f4fd-0000-0100-0000-5e248b350345\""), + }; + await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateStoreId, data); Console.WriteLine("Succeeded"); } @@ -60,9 +58,7 @@ public async Task Get_GetPrivateStore() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PrivateStoreResource PrivateStoreCollection collection = tenantResource.GetPrivateStores(); @@ -78,6 +74,36 @@ public async Task Get_GetPrivateStore() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetPrivateStores() + { + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStores.json + // this example is just showing the usage of "PrivateStore_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this PrivateStoreResource + PrivateStoreCollection collection = tenantResource.GetPrivateStores(); + + // invoke the operation and iterate over the result + await foreach (PrivateStoreResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateStoreData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetPrivateStore() @@ -90,9 +116,7 @@ public async Task Exists_GetPrivateStore() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PrivateStoreResource PrivateStoreCollection collection = tenantResource.GetPrivateStores(); @@ -116,9 +140,7 @@ public async Task GetIfExists_GetPrivateStore() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this PrivateStoreResource PrivateStoreCollection collection = tenantResource.GetPrivateStores(); @@ -141,36 +163,5 @@ public async Task GetIfExists_GetPrivateStore() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateStoresUpdate() - { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PrivateStores_update.json - // this example is just showing the usage of "PrivateStore_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this PrivateStoreResource - PrivateStoreCollection collection = tenantResource.GetPrivateStores(); - - // invoke the operation - Guid privateStoreId = Guid.Parse("a0e28e55-90c4-41d8-8e34-bb7ef7775406"); - PrivateStoreData data = new PrivateStoreData() - { - Availability = PrivateStoreAvailability.Disabled, - ETag = new ETag("\"9301f4fd-0000-0100-0000-5e248b350345\""), - }; - await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateStoreId, data); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollectionInfoCollection.cs b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollectionInfoCollection.cs index 5092959a1c09d..d908fbfd43b82 100644 --- a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollectionInfoCollection.cs +++ b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollectionInfoCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_PrivateStoreCollectionInfoCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetPrivateStoreCollectionsList() + public async Task CreateOrUpdate_CreatePrivateStoreCollection() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreCollectionsList.json - // this example is just showing the usage of "PrivateStoreCollection_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/CreatePrivateStoreCollection.json + // this example is just showing the usage of "PrivateStoreCollection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,17 +36,23 @@ public async Task GetAll_GetPrivateStoreCollectionsList() // get the collection of this PrivateStoreCollectionInfoResource PrivateStoreCollectionInfoCollection collection = privateStore.GetPrivateStoreCollectionInfos(); - // invoke the operation and iterate over the result - await foreach (PrivateStoreCollectionInfoResource item in collection.GetAllAsync()) + // invoke the operation + Guid collectionId = Guid.Parse("d0f5aa2c-ecc3-4d87-906a-f8c486dcc4f1"); + PrivateStoreCollectionInfoData info = new PrivateStoreCollectionInfoData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateStoreCollectionInfoData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + CollectionName = "Test Collection", + Claim = "", + AreAllSubscriptionsSelected = false, + SubscriptionsList = { "b340914e-353d-453a-85fb-8f9b65b51f91", "f2baa04d-5bfc-461b-b6d8-61b403c9ec48" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, collectionId, info); + PrivateStoreCollectionInfoResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateStoreCollectionInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -83,10 +89,10 @@ public async Task Get_GetPrivateStoreCollection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateStoreCollection() + public async Task GetAll_GetPrivateStoreCollectionsList() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreCollection.json - // this example is just showing the usage of "PrivateStoreCollection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreCollectionsList.json + // this example is just showing the usage of "PrivateStoreCollection_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,16 +108,22 @@ public async Task Exists_GetPrivateStoreCollection() // get the collection of this PrivateStoreCollectionInfoResource PrivateStoreCollectionInfoCollection collection = privateStore.GetPrivateStoreCollectionInfos(); - // invoke the operation - Guid collectionId = Guid.Parse("56a1a02d-8cf8-45df-bf37-d5f7120fcb3d"); - bool result = await collection.ExistsAsync(collectionId); + // invoke the operation and iterate over the result + await foreach (PrivateStoreCollectionInfoResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateStoreCollectionInfoData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateStoreCollection() + public async Task Exists_GetPrivateStoreCollection() { // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreCollection.json // this example is just showing the usage of "PrivateStoreCollection_Get" operation, for the dependent resources, they will have to be created separately. @@ -132,29 +144,17 @@ public async Task GetIfExists_GetPrivateStoreCollection() // invoke the operation Guid collectionId = Guid.Parse("56a1a02d-8cf8-45df-bf37-d5f7120fcb3d"); - NullableResponse response = await collection.GetIfExistsAsync(collectionId); - PrivateStoreCollectionInfoResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(collectionId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateStoreCollectionInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePrivateStoreCollection() + public async Task GetIfExists_GetPrivateStoreCollection() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/CreatePrivateStoreCollection.json - // this example is just showing the usage of "PrivateStoreCollection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreCollection.json + // this example is just showing the usage of "PrivateStoreCollection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -171,25 +171,22 @@ public async Task CreateOrUpdate_CreatePrivateStoreCollection() PrivateStoreCollectionInfoCollection collection = privateStore.GetPrivateStoreCollectionInfos(); // invoke the operation - Guid collectionId = Guid.Parse("d0f5aa2c-ecc3-4d87-906a-f8c486dcc4f1"); - PrivateStoreCollectionInfoData info = new PrivateStoreCollectionInfoData() - { - CollectionName = "Test Collection", - Claim = "", - AreAllSubscriptionsSelected = false, - SubscriptionsList = -{ -"b340914e-353d-453a-85fb-8f9b65b51f91","f2baa04d-5bfc-461b-b6d8-61b403c9ec48" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, collectionId, info); - PrivateStoreCollectionInfoResource result = lro.Value; + Guid collectionId = Guid.Parse("56a1a02d-8cf8-45df-bf37-d5f7120fcb3d"); + NullableResponse response = await collection.GetIfExistsAsync(collectionId); + PrivateStoreCollectionInfoResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateStoreCollectionInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateStoreCollectionInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollectionInfoResource.cs b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollectionInfoResource.cs index ce354cfaa91f1..e4b0344e9af84 100644 --- a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollectionInfoResource.cs +++ b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreCollectionInfoResource.cs @@ -18,10 +18,10 @@ public partial class Sample_PrivateStoreCollectionInfoResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task SetCollectionRules_SetCollectionRules() + public async Task Get_GetPrivateStoreCollection() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/SetCollectionRules.json - // this example is just showing the usage of "SetCollectionRules" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreCollection.json + // this example is just showing the usage of "PrivateStoreCollection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,55 +36,21 @@ public async Task SetCollectionRules_SetCollectionRules() PrivateStoreCollectionInfoResource privateStoreCollectionInfo = client.GetPrivateStoreCollectionInfoResource(privateStoreCollectionInfoResourceId); // invoke the operation - SetRulesContent content = new SetRulesContent() - { - Value = -{ -new MarketplaceRule() -{ -RuleType = MarketplaceRuleType.PrivateProducts, -} -}, - }; - await privateStoreCollectionInfo.SetCollectionRulesAsync(content: content); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task QueryRules_GetCollectionRules() - { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetCollectionRules.json - // this example is just showing the usage of "QueryRules" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PrivateStoreCollectionInfoResource created on azure - // for more information of creating PrivateStoreCollectionInfoResource, please refer to the document of PrivateStoreCollectionInfoResource - Guid privateStoreId = Guid.Parse("a0e28e55-90c4-41d8-8e34-bb7ef7775406"); - Guid collectionId = Guid.Parse("56a1a02d-8cf8-45df-bf37-d5f7120fcb3d"); - ResourceIdentifier privateStoreCollectionInfoResourceId = PrivateStoreCollectionInfoResource.CreateResourceIdentifier(privateStoreId, collectionId); - PrivateStoreCollectionInfoResource privateStoreCollectionInfo = client.GetPrivateStoreCollectionInfoResource(privateStoreCollectionInfoResourceId); - - // invoke the operation and iterate over the result - await foreach (MarketplaceRule item in privateStoreCollectionInfo.QueryRulesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + PrivateStoreCollectionInfoResource result = await privateStoreCollectionInfo.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateStoreCollectionInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateStoreCollection() + public async Task Delete_DeletePrivateStoreCollection() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreCollection.json - // this example is just showing the usage of "PrivateStoreCollection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/DeletePrivateStoreCollection.json + // this example is just showing the usage of "PrivateStoreCollection_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,18 +60,14 @@ public async Task Get_GetPrivateStoreCollection() // this example assumes you already have this PrivateStoreCollectionInfoResource created on azure // for more information of creating PrivateStoreCollectionInfoResource, please refer to the document of PrivateStoreCollectionInfoResource Guid privateStoreId = Guid.Parse("a0e28e55-90c4-41d8-8e34-bb7ef7775406"); - Guid collectionId = Guid.Parse("56a1a02d-8cf8-45df-bf37-d5f7120fcb3d"); + Guid collectionId = Guid.Parse("d0f5aa2c-ecc3-4d87-906a-f8c486dcc4f1"); ResourceIdentifier privateStoreCollectionInfoResourceId = PrivateStoreCollectionInfoResource.CreateResourceIdentifier(privateStoreId, collectionId); PrivateStoreCollectionInfoResource privateStoreCollectionInfo = client.GetPrivateStoreCollectionInfoResource(privateStoreCollectionInfoResourceId); // invoke the operation - PrivateStoreCollectionInfoResource result = await privateStoreCollectionInfo.GetAsync(); + await privateStoreCollectionInfo.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateStoreCollectionInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -128,15 +90,12 @@ public async Task Update_CreatePrivateStoreCollection() PrivateStoreCollectionInfoResource privateStoreCollectionInfo = client.GetPrivateStoreCollectionInfoResource(privateStoreCollectionInfoResourceId); // invoke the operation - PrivateStoreCollectionInfoData info = new PrivateStoreCollectionInfoData() + PrivateStoreCollectionInfoData info = new PrivateStoreCollectionInfoData { CollectionName = "Test Collection", Claim = "", AreAllSubscriptionsSelected = false, - SubscriptionsList = -{ -"b340914e-353d-453a-85fb-8f9b65b51f91","f2baa04d-5bfc-461b-b6d8-61b403c9ec48" -}, + SubscriptionsList = { "b340914e-353d-453a-85fb-8f9b65b51f91", "f2baa04d-5bfc-461b-b6d8-61b403c9ec48" }, }; ArmOperation lro = await privateStoreCollectionInfo.UpdateAsync(WaitUntil.Completed, info); PrivateStoreCollectionInfoResource result = lro.Value; @@ -150,10 +109,10 @@ public async Task Update_CreatePrivateStoreCollection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateStoreCollection() + public async Task SetCollectionRules_SetCollectionRules() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/DeletePrivateStoreCollection.json - // this example is just showing the usage of "PrivateStoreCollection_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/SetCollectionRules.json + // this example is just showing the usage of "SetCollectionRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -163,22 +122,29 @@ public async Task Delete_DeletePrivateStoreCollection() // this example assumes you already have this PrivateStoreCollectionInfoResource created on azure // for more information of creating PrivateStoreCollectionInfoResource, please refer to the document of PrivateStoreCollectionInfoResource Guid privateStoreId = Guid.Parse("a0e28e55-90c4-41d8-8e34-bb7ef7775406"); - Guid collectionId = Guid.Parse("d0f5aa2c-ecc3-4d87-906a-f8c486dcc4f1"); + Guid collectionId = Guid.Parse("56a1a02d-8cf8-45df-bf37-d5f7120fcb3d"); ResourceIdentifier privateStoreCollectionInfoResourceId = PrivateStoreCollectionInfoResource.CreateResourceIdentifier(privateStoreId, collectionId); PrivateStoreCollectionInfoResource privateStoreCollectionInfo = client.GetPrivateStoreCollectionInfoResource(privateStoreCollectionInfoResourceId); // invoke the operation - await privateStoreCollectionInfo.DeleteAsync(WaitUntil.Completed); + SetRulesContent content = new SetRulesContent + { + Value = {new MarketplaceRule +{ +RuleType = MarketplaceRuleType.PrivateProducts, +}}, + }; + await privateStoreCollectionInfo.SetCollectionRulesAsync(content: content); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PostPrivateStoreCollection() + public async Task QueryRules_GetCollectionRules() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PostPrivateStoreCollection.json - // this example is just showing the usage of "PrivateStoreCollection_Post" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetCollectionRules.json + // this example is just showing the usage of "QueryRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,8 +158,11 @@ public async Task Delete_PostPrivateStoreCollection() ResourceIdentifier privateStoreCollectionInfoResourceId = PrivateStoreCollectionInfoResource.CreateResourceIdentifier(privateStoreId, collectionId); PrivateStoreCollectionInfoResource privateStoreCollectionInfo = client.GetPrivateStoreCollectionInfoResource(privateStoreCollectionInfoResourceId); - // invoke the operation - await privateStoreCollectionInfo.DeleteAsync(); + // invoke the operation and iterate over the result + await foreach (MarketplaceRule item in privateStoreCollectionInfo.QueryRulesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } Console.WriteLine("Succeeded"); } @@ -218,17 +187,11 @@ public async Task TransferOffers_TransferOffers() PrivateStoreCollectionInfoResource privateStoreCollectionInfo = client.GetPrivateStoreCollectionInfoResource(privateStoreCollectionInfoResourceId); // invoke the operation - TransferOffersContent content = new TransferOffersContent() + TransferOffersContent content = new TransferOffersContent { - TargetCollections = -{ -"c752f021-1c37-4af5-b82f-74c51c27b44a","f47ef1c7-e908-4f39-ae29-db181634ad8d" -}, + TargetCollections = { "c752f021-1c37-4af5-b82f-74c51c27b44a", "f47ef1c7-e908-4f39-ae29-db181634ad8d" }, Operation = "copy", - OfferIdsList = -{ -"marketplacetestthirdparty.md-test-third-party-2","marketplacetestthirdparty.md-test-third-party-3" -}, + OfferIdsList = { "marketplacetestthirdparty.md-test-third-party-2", "marketplacetestthirdparty.md-test-third-party-3" }, }; TransferOffersResult result = await privateStoreCollectionInfo.TransferOffersAsync(content: content); @@ -313,12 +276,9 @@ public async Task GetPrivateStoreCollectionOffersByContexts_GetPrivateStoreColle PrivateStoreCollectionInfoResource privateStoreCollectionInfo = client.GetPrivateStoreCollectionInfoResource(privateStoreCollectionInfoResourceId); // invoke the operation and iterate over the result - CollectionOffersByAllContextsPayload payload = new CollectionOffersByAllContextsPayload() + CollectionOffersByAllContextsPayload payload = new CollectionOffersByAllContextsPayload { - SubscriptionIds = -{ -"b340914e-353d-453a-85fb-8f9b65b51f91","f2baa04d-5bfc-461b-b6d8-61b403c9ec48" -}, + SubscriptionIds = { "b340914e-353d-453a-85fb-8f9b65b51f91", "f2baa04d-5bfc-461b-b6d8-61b403c9ec48" }, }; await foreach (CollectionOffersByContext item in privateStoreCollectionInfo.GetPrivateStoreCollectionOffersByContextsAsync(payload: payload)) { @@ -327,5 +287,30 @@ public async Task GetPrivateStoreCollectionOffersByContexts_GetPrivateStoreColle Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_PostPrivateStoreCollection() + { + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PostPrivateStoreCollection.json + // this example is just showing the usage of "PrivateStoreCollection_Post" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PrivateStoreCollectionInfoResource created on azure + // for more information of creating PrivateStoreCollectionInfoResource, please refer to the document of PrivateStoreCollectionInfoResource + Guid privateStoreId = Guid.Parse("a0e28e55-90c4-41d8-8e34-bb7ef7775406"); + Guid collectionId = Guid.Parse("56a1a02d-8cf8-45df-bf37-d5f7120fcb3d"); + ResourceIdentifier privateStoreCollectionInfoResourceId = PrivateStoreCollectionInfoResource.CreateResourceIdentifier(privateStoreId, collectionId); + PrivateStoreCollectionInfoResource privateStoreCollectionInfo = client.GetPrivateStoreCollectionInfoResource(privateStoreCollectionInfoResourceId); + + // invoke the operation + await privateStoreCollectionInfo.DeleteAsync(); + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreOfferCollection.cs b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreOfferCollection.cs index f1b8807aa0319..5ef8fb141c69f 100644 --- a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreOfferCollection.cs +++ b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreOfferCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_PrivateStoreOfferCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetPrivateStoreOffers() + public async Task CreateOrUpdate_PrivateStoreOfferUpdate() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreOffers.json - // this example is just showing the usage of "PrivateStoreCollectionOffer_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PrivateStoreOffer_update.json + // this example is just showing the usage of "PrivateStoreCollectionOffer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task GetAll_GetPrivateStoreOffers() // get the collection of this PrivateStoreOfferResource PrivateStoreOfferCollection collection = privateStoreCollectionInfo.GetPrivateStoreOffers(); - // invoke the operation and iterate over the result - await foreach (PrivateStoreOfferResource item in collection.GetAllAsync()) + // invoke the operation + string offerId = "marketplacetestthirdparty.md-test-third-party-2"; + PrivateStoreOfferData data = new PrivateStoreOfferData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateStoreOfferData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ETag = new ETag("\"9301f4fd-0000-0100-0000-5e248b350666\""), + SpecificPlanIdsLimitation = { "0001", "0002" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, offerId, data); + PrivateStoreOfferResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateStoreOfferData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -85,10 +89,10 @@ public async Task Get_GetPrivateStoreCollectionOffer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateStoreCollectionOffer() + public async Task GetAll_GetPrivateStoreOffers() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreCollectionOffer.json - // this example is just showing the usage of "PrivateStoreCollectionOffer_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreOffers.json + // this example is just showing the usage of "PrivateStoreCollectionOffer_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,16 +109,22 @@ public async Task Exists_GetPrivateStoreCollectionOffer() // get the collection of this PrivateStoreOfferResource PrivateStoreOfferCollection collection = privateStoreCollectionInfo.GetPrivateStoreOffers(); - // invoke the operation - string offerId = "marketplacetestthirdparty.md-test-third-party-2"; - bool result = await collection.ExistsAsync(offerId); + // invoke the operation and iterate over the result + await foreach (PrivateStoreOfferResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateStoreOfferData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateStoreCollectionOffer() + public async Task Exists_GetPrivateStoreCollectionOffer() { // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreCollectionOffer.json // this example is just showing the usage of "PrivateStoreCollectionOffer_Get" operation, for the dependent resources, they will have to be created separately. @@ -136,29 +146,17 @@ public async Task GetIfExists_GetPrivateStoreCollectionOffer() // invoke the operation string offerId = "marketplacetestthirdparty.md-test-third-party-2"; - NullableResponse response = await collection.GetIfExistsAsync(offerId); - PrivateStoreOfferResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(offerId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateStoreOfferData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateStoreOfferUpdate() + public async Task GetIfExists_GetPrivateStoreCollectionOffer() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PrivateStoreOffer_update.json - // this example is just showing the usage of "PrivateStoreCollectionOffer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/GetPrivateStoreCollectionOffer.json + // this example is just showing the usage of "PrivateStoreCollectionOffer_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,22 +175,21 @@ public async Task CreateOrUpdate_PrivateStoreOfferUpdate() // invoke the operation string offerId = "marketplacetestthirdparty.md-test-third-party-2"; - PrivateStoreOfferData data = new PrivateStoreOfferData() - { - ETag = new ETag("\"9301f4fd-0000-0100-0000-5e248b350666\""), - SpecificPlanIdsLimitation = -{ -"0001","0002" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, offerId, data); - PrivateStoreOfferResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(offerId); + PrivateStoreOfferResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateStoreOfferData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateStoreOfferData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreOfferResource.cs b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreOfferResource.cs index 131332ba4f6e2..cb12742ecf2e3 100644 --- a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreOfferResource.cs +++ b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreOfferResource.cs @@ -46,45 +46,6 @@ public async Task Get_GetPrivateStoreCollectionOffer() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateStoreOfferUpdate() - { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PrivateStoreOffer_update.json - // this example is just showing the usage of "PrivateStoreCollectionOffer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PrivateStoreOfferResource created on azure - // for more information of creating PrivateStoreOfferResource, please refer to the document of PrivateStoreOfferResource - Guid privateStoreId = Guid.Parse("a0e28e55-90c4-41d8-8e34-bb7ef7775406"); - Guid collectionId = Guid.Parse("56a1a02d-8cf8-45df-bf37-d5f7120fcb3d"); - string offerId = "marketplacetestthirdparty.md-test-third-party-2"; - ResourceIdentifier privateStoreOfferResourceId = PrivateStoreOfferResource.CreateResourceIdentifier(privateStoreId, collectionId, offerId); - PrivateStoreOfferResource privateStoreOffer = client.GetPrivateStoreOfferResource(privateStoreOfferResourceId); - - // invoke the operation - PrivateStoreOfferData data = new PrivateStoreOfferData() - { - ETag = new ETag("\"9301f4fd-0000-0100-0000-5e248b350666\""), - SpecificPlanIdsLimitation = -{ -"0001","0002" -}, - }; - ArmOperation lro = await privateStoreOffer.UpdateAsync(WaitUntil.Completed, data); - PrivateStoreOfferResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateStoreOfferData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Delete_DeletePrivateStoreOffer() @@ -113,10 +74,10 @@ public async Task Delete_DeletePrivateStoreOffer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PostPrivateStoreCollectionOffer() + public async Task Update_PrivateStoreOfferUpdate() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PostPrivateStoreCollectionOffer.json - // this example is just showing the usage of "PrivateStoreCollectionOffer_Post" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PrivateStoreOffer_update.json + // this example is just showing the usage of "PrivateStoreCollectionOffer_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -132,9 +93,19 @@ public async Task Delete_PostPrivateStoreCollectionOffer() PrivateStoreOfferResource privateStoreOffer = client.GetPrivateStoreOfferResource(privateStoreOfferResourceId); // invoke the operation - await privateStoreOffer.DeleteAsync(); + PrivateStoreOfferData data = new PrivateStoreOfferData + { + ETag = new ETag("\"9301f4fd-0000-0100-0000-5e248b350666\""), + SpecificPlanIdsLimitation = { "0001", "0002" }, + }; + ArmOperation lro = await privateStoreOffer.UpdateAsync(WaitUntil.Completed, data); + PrivateStoreOfferResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateStoreOfferData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -158,28 +129,19 @@ public async Task UpsertOfferWithMultiContext_UpsertOfferWithMultiContext() PrivateStoreOfferResource privateStoreOffer = client.GetPrivateStoreOfferResource(privateStoreOfferResourceId); // invoke the operation - MultiContextAndPlansContent content = new MultiContextAndPlansContent() + MultiContextAndPlansContent content = new MultiContextAndPlansContent { OfferId = "contoso.logger", ETag = new ETag("\"9301f4fd-0000-0100-0000-5e248b350332\""), - PlansContext = -{ -new ContextAndPlansDetails() + PlansContext = {new ContextAndPlansDetails { Context = "a5edbe7d-9f73-47fd-834a-0d6142f4c7a1", -PlanIds = -{ -"log4db","log4file" -}, -},new ContextAndPlansDetails() +PlanIds = {"log4db", "log4file"}, +}, new ContextAndPlansDetails { Context = "45b604af-19bb-448e-a761-4a6be7374b2f", -PlanIds = -{ -"log4web" -}, -} -}, +PlanIds = {"log4web"}, +}}, }; PrivateStoreOfferResource result = await privateStoreOffer.UpsertOfferWithMultiContextAsync(content: content); @@ -189,5 +151,31 @@ public async Task UpsertOfferWithMultiContext_UpsertOfferWithMultiContext() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_PostPrivateStoreCollectionOffer() + { + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PostPrivateStoreCollectionOffer.json + // this example is just showing the usage of "PrivateStoreCollectionOffer_Post" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this PrivateStoreOfferResource created on azure + // for more information of creating PrivateStoreOfferResource, please refer to the document of PrivateStoreOfferResource + Guid privateStoreId = Guid.Parse("a0e28e55-90c4-41d8-8e34-bb7ef7775406"); + Guid collectionId = Guid.Parse("56a1a02d-8cf8-45df-bf37-d5f7120fcb3d"); + string offerId = "marketplacetestthirdparty.md-test-third-party-2"; + ResourceIdentifier privateStoreOfferResourceId = PrivateStoreOfferResource.CreateResourceIdentifier(privateStoreId, collectionId, offerId); + PrivateStoreOfferResource privateStoreOffer = client.GetPrivateStoreOfferResource(privateStoreOfferResourceId); + + // invoke the operation + await privateStoreOffer.DeleteAsync(); + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreResource.cs b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreResource.cs index a93023a508b2e..cc4f557e63ec5 100644 --- a/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreResource.cs +++ b/sdk/marketplace/Azure.ResourceManager.Marketplace/samples/Generated/Samples/Sample_PrivateStoreResource.cs @@ -46,10 +46,10 @@ public async Task Get_GetPrivateStore() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PrivateStoresUpdate() + public async Task Delete_DeletePrivateStores() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PrivateStores_update.json - // this example is just showing the usage of "PrivateStore_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/DeletePrivateStore.json + // this example is just showing the usage of "PrivateStore_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,22 +63,17 @@ public async Task Update_PrivateStoresUpdate() PrivateStoreResource privateStore = client.GetPrivateStoreResource(privateStoreResourceId); // invoke the operation - PrivateStoreData data = new PrivateStoreData() - { - Availability = PrivateStoreAvailability.Disabled, - ETag = new ETag("\"9301f4fd-0000-0100-0000-5e248b350345\""), - }; - await privateStore.UpdateAsync(WaitUntil.Completed, data); + await privateStore.DeleteAsync(WaitUntil.Completed); Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateStores() + public async Task Update_PrivateStoresUpdate() { - // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/DeletePrivateStore.json - // this example is just showing the usage of "PrivateStore_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplace/resource-manager/Microsoft.Marketplace/stable/2023-01-01/examples/PrivateStores_update.json + // this example is just showing the usage of "PrivateStore_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,7 +87,12 @@ public async Task Delete_DeletePrivateStores() PrivateStoreResource privateStore = client.GetPrivateStoreResource(privateStoreResourceId); // invoke the operation - await privateStore.DeleteAsync(WaitUntil.Completed); + PrivateStoreData data = new PrivateStoreData + { + Availability = PrivateStoreAvailability.Disabled, + ETag = new ETag("\"9301f4fd-0000-0100-0000-5e248b350345\""), + }; + await privateStore.UpdateAsync(WaitUntil.Completed, data); Console.WriteLine("Succeeded"); } @@ -167,16 +167,10 @@ public async Task QueryUserOffers_QueryUserOffers() PrivateStoreResource privateStore = client.GetPrivateStoreResource(privateStoreResourceId); // invoke the operation and iterate over the result - QueryUserOffersContent content = new QueryUserOffersContent() + QueryUserOffersContent content = new QueryUserOffersContent { - OfferIds = -{ -"contoso.logger","contoso.monitor" -}, - SubscriptionIds = -{ -"b340914e-353d-453a-85fb-8f9b65b51f91" -}, + OfferIds = { "contoso.logger", "contoso.monitor" }, + SubscriptionIds = { "b340914e-353d-453a-85fb-8f9b65b51f91" }, }; await foreach (PrivateStoreOfferResult item in privateStore.QueryUserOffersAsync(content: content)) { @@ -229,12 +223,9 @@ public async Task FetchCollectionsToSubscriptionsMapping_CollectionsToSubscripti PrivateStoreResource privateStore = client.GetPrivateStoreResource(privateStoreResourceId); // invoke the operation - CollectionsToSubscriptionsMappingContent content = new CollectionsToSubscriptionsMappingContent() + CollectionsToSubscriptionsMappingContent content = new CollectionsToSubscriptionsMappingContent { - CollectionsToSubscriptionsMappingSubscriptionIds = -{ -"b340914e-353d-453a-85fb-8f9b65b51f91","f2baa04d-5bfc-461b-b6d8-61b403c9ec48" -}, + CollectionsToSubscriptionsMappingSubscriptionIds = { "b340914e-353d-453a-85fb-8f9b65b51f91", "f2baa04d-5bfc-461b-b6d8-61b403c9ec48" }, }; CollectionsToSubscriptionsMappingResult result = await privateStore.FetchCollectionsToSubscriptionsMappingAsync(content: content); @@ -260,17 +251,11 @@ public async Task QueryApprovedPlans_QueryApprovedPlans() PrivateStoreResource privateStore = client.GetPrivateStoreResource(privateStoreResourceId); // invoke the operation - QueryApprovedPlansContent content = new QueryApprovedPlansContent() + QueryApprovedPlansContent content = new QueryApprovedPlansContent { OfferId = "marketplacetestthirdparty.md-test-third-party-2", - PlanIds = -{ -"testPlanA","testPlanB","testPlanC" -}, - SubscriptionIds = -{ -"85e3e079-c718-4e4c-abbe-f72fceba8305","7752d461-4bf1-4185-8b56-8a3f11486ac6" -}, + PlanIds = { "testPlanA", "testPlanB", "testPlanC" }, + SubscriptionIds = { "85e3e079-c718-4e4c-abbe-f72fceba8305", "7752d461-4bf1-4185-8b56-8a3f11486ac6" }, }; QueryApprovedPlansResult result = await privateStore.QueryApprovedPlansAsync(content: content); @@ -296,12 +281,9 @@ public async Task PerformActionOnBulkCollections_BulkCollectionsAction() PrivateStoreResource privateStore = client.GetPrivateStoreResource(privateStoreResourceId); // invoke the operation - BulkCollectionsActionContent content = new BulkCollectionsActionContent() + BulkCollectionsActionContent content = new BulkCollectionsActionContent { - CollectionIds = -{ -Guid.Parse("c752f021-1c37-4af5-b82f-74c51c27b44a"),Guid.Parse("f47ef1c7-e908-4f39-ae29-db181634ad8d") -}, + CollectionIds = { Guid.Parse("c752f021-1c37-4af5-b82f-74c51c27b44a"), Guid.Parse("f47ef1c7-e908-4f39-ae29-db181634ad8d") }, Action = "EnableCollections", }; BulkCollectionsActionResult result = await privateStore.PerformActionOnBulkCollectionsAsync(content: content); @@ -353,18 +335,13 @@ public async Task AcknowledgeOfferNotification_AcknowledgeNotification() // invoke the operation string offerId = "marketplacetestthirdparty.md-test-third-party-2"; - AcknowledgeOfferNotificationContent content = new AcknowledgeOfferNotificationContent() + AcknowledgeOfferNotificationContent content = new AcknowledgeOfferNotificationContent { IsAcknowledgeActionFlagEnabled = false, IsDismissActionFlagEnabled = false, IsRemoveOfferActionFlagEnabled = false, - AddPlans = -{ -}, - RemovePlans = -{ -"testPlanA" -}, + AddPlans = { }, + RemovePlans = { "testPlanA" }, }; await privateStore.AcknowledgeOfferNotificationAsync(offerId, content: content); @@ -489,12 +466,9 @@ public async Task QueryUserRules_QueryUserRules() PrivateStoreResource privateStore = client.GetPrivateStoreResource(privateStoreResourceId); // invoke the operation and iterate over the result - QueryUserRulesContent content = new QueryUserRulesContent() + QueryUserRulesContent content = new QueryUserRulesContent { - SubscriptionIds = -{ -"b340914e-353d-453a-85fb-8f9b65b51f91" -}, + SubscriptionIds = { "b340914e-353d-453a-85fb-8f9b65b51f91" }, }; await foreach (MarketplaceRule item in privateStore.QueryUserRulesAsync(content: content)) { diff --git a/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementResource.cs b/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementResource.cs index eb10d28a2db39..a25e03178aa89 100644 --- a/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementResource.cs +++ b/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementResource.cs @@ -17,10 +17,10 @@ public partial class Sample_MarketplaceAgreementResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Sign_SetMarketplaceTerms() + public async Task Get_SetMarketplaceTerms() { - // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/SignMarketplaceTerms.json - // this example is just showing the usage of "MarketplaceAgreements_Sign" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/GetAgreementMarketplaceTerms.json + // this example is just showing the usage of "MarketplaceAgreements_GetAgreement" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,7 +37,7 @@ public async Task Sign_SetMarketplaceTerms() MarketplaceAgreementResource marketplaceAgreement = client.GetMarketplaceAgreementResource(marketplaceAgreementResourceId); // invoke the operation - MarketplaceAgreementResource result = await marketplaceAgreement.SignAsync(); + MarketplaceAgreementResource result = await marketplaceAgreement.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -48,10 +48,10 @@ public async Task Sign_SetMarketplaceTerms() [Test] [Ignore("Only validating compilation of examples")] - public async Task Cancel_SetMarketplaceTerms() + public async Task Sign_SetMarketplaceTerms() { - // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/CancelMarketplaceTerms.json - // this example is just showing the usage of "MarketplaceAgreements_Cancel" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/SignMarketplaceTerms.json + // this example is just showing the usage of "MarketplaceAgreements_Sign" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,7 +68,7 @@ public async Task Cancel_SetMarketplaceTerms() MarketplaceAgreementResource marketplaceAgreement = client.GetMarketplaceAgreementResource(marketplaceAgreementResourceId); // invoke the operation - MarketplaceAgreementResource result = await marketplaceAgreement.CancelAsync(); + MarketplaceAgreementResource result = await marketplaceAgreement.SignAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -79,10 +79,10 @@ public async Task Cancel_SetMarketplaceTerms() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_SetMarketplaceTerms() + public async Task Cancel_SetMarketplaceTerms() { - // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/GetAgreementMarketplaceTerms.json - // this example is just showing the usage of "MarketplaceAgreements_GetAgreement" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/CancelMarketplaceTerms.json + // this example is just showing the usage of "MarketplaceAgreements_Cancel" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,7 +99,7 @@ public async Task Get_SetMarketplaceTerms() MarketplaceAgreementResource marketplaceAgreement = client.GetMarketplaceAgreementResource(marketplaceAgreementResourceId); // invoke the operation - MarketplaceAgreementResource result = await marketplaceAgreement.GetAsync(); + MarketplaceAgreementResource result = await marketplaceAgreement.CancelAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementTermCollection.cs b/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementTermCollection.cs index 275723374cd16..5cab2aa1985ba 100644 --- a/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementTermCollection.cs +++ b/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementTermCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MarketplaceAgreementTermCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMarketplaceTerms() + public async Task CreateOrUpdate_SetMarketplaceTerms() { - // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/GetMarketplaceTerms.json - // this example is just showing the usage of "MarketplaceAgreements_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/SetMarketplaceTerms.json + // this example is just showing the usage of "MarketplaceAgreements_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -43,7 +43,20 @@ public async Task Get_GetMarketplaceTerms() string publisherId = "pubid"; string offerId = "offid"; string planId = "planid"; - MarketplaceAgreementTermResource result = await collection.GetAsync(offerType, publisherId, offerId, planId); + MarketplaceAgreementTermData data = new MarketplaceAgreementTermData + { + Publisher = "pubid", + Product = "offid", + Plan = "planid", + LicenseTextLink = new Uri("test.licenseLink"), + PrivacyPolicyLink = new Uri("test.privacyPolicyLink"), + MarketplaceTermsLink = new Uri("test.marketplaceTermsLink"), + RetrievedOn = DateTimeOffset.Parse("2017-08-15T11:33:07.12132Z"), + Signature = "ASDFSDAFWEFASDGWERLWER", + IsAccepted = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, offerType, publisherId, offerId, planId, data); + MarketplaceAgreementTermResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,7 +67,7 @@ public async Task Get_GetMarketplaceTerms() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMarketplaceTerms() + public async Task Get_GetMarketplaceTerms() { // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/GetMarketplaceTerms.json // this example is just showing the usage of "MarketplaceAgreements_Get" operation, for the dependent resources, they will have to be created separately. @@ -78,14 +91,18 @@ public async Task Exists_GetMarketplaceTerms() string publisherId = "pubid"; string offerId = "offid"; string planId = "planid"; - bool result = await collection.ExistsAsync(offerType, publisherId, offerId, planId); + MarketplaceAgreementTermResource result = await collection.GetAsync(offerType, publisherId, offerId, planId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MarketplaceAgreementTermData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMarketplaceTerms() + public async Task Exists_GetMarketplaceTerms() { // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/GetMarketplaceTerms.json // this example is just showing the usage of "MarketplaceAgreements_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,29 +126,17 @@ public async Task GetIfExists_GetMarketplaceTerms() string publisherId = "pubid"; string offerId = "offid"; string planId = "planid"; - NullableResponse response = await collection.GetIfExistsAsync(offerType, publisherId, offerId, planId); - MarketplaceAgreementTermResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(offerType, publisherId, offerId, planId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MarketplaceAgreementTermData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SetMarketplaceTerms() + public async Task GetIfExists_GetMarketplaceTerms() { - // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/SetMarketplaceTerms.json - // this example is just showing the usage of "MarketplaceAgreements_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/marketplaceordering/resource-manager/Microsoft.MarketplaceOrdering/stable/2021-01-01/examples/GetMarketplaceTerms.json + // this example is just showing the usage of "MarketplaceAgreements_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -152,26 +157,21 @@ public async Task CreateOrUpdate_SetMarketplaceTerms() string publisherId = "pubid"; string offerId = "offid"; string planId = "planid"; - MarketplaceAgreementTermData data = new MarketplaceAgreementTermData() - { - Publisher = "pubid", - Product = "offid", - Plan = "planid", - LicenseTextLink = new Uri("test.licenseLink"), - PrivacyPolicyLink = new Uri("test.privacyPolicyLink"), - MarketplaceTermsLink = new Uri("test.marketplaceTermsLink"), - RetrievedOn = DateTimeOffset.Parse("2017-08-15T11:33:07.12132Z"), - Signature = "ASDFSDAFWEFASDGWERLWER", - IsAccepted = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, offerType, publisherId, offerId, planId, data); - MarketplaceAgreementTermResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(offerType, publisherId, offerId, planId); + MarketplaceAgreementTermResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MarketplaceAgreementTermData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MarketplaceAgreementTermData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementTermResource.cs b/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementTermResource.cs index 43e686287e529..5795596ab5e96 100644 --- a/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementTermResource.cs +++ b/sdk/marketplaceordering/Azure.ResourceManager.MarketplaceOrdering/samples/Generated/Samples/Sample_MarketplaceAgreementTermResource.cs @@ -71,7 +71,7 @@ public async Task Update_SetMarketplaceTerms() MarketplaceAgreementTermResource marketplaceAgreementTerm = client.GetMarketplaceAgreementTermResource(marketplaceAgreementTermResourceId); // invoke the operation - MarketplaceAgreementTermData data = new MarketplaceAgreementTermData() + MarketplaceAgreementTermData data = new MarketplaceAgreementTermData { Publisher = "pubid", Product = "offid", diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_ContentKeyPolicyCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_ContentKeyPolicyCollection.cs index 033263245e5d4..1d03cff05b864 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_ContentKeyPolicyCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_ContentKeyPolicyCollection.cs @@ -6,6 +6,7 @@ #nullable disable using System; +using System.Text; using System.Threading.Tasks; using Azure.Core; using Azure.Identity; @@ -18,10 +19,10 @@ public partial class Sample_ContentKeyPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsContentKeyPoliciesOrderedByLastModified() + public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithClearKeyOptionAndTokenRestriction() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-list-by-lastModified.json - // this example is just showing the usage of "ContentKeyPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-create-nodrm-token.json + // this example is just showing the usage of "ContentKeyPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,26 +40,32 @@ public async Task GetAll_ListsContentKeyPoliciesOrderedByLastModified() // get the collection of this ContentKeyPolicyResource ContentKeyPolicyCollection collection = mediaServicesAccount.GetContentKeyPolicies(); - // invoke the operation and iterate over the result - string orderby = "properties/lastModified"; - await foreach (ContentKeyPolicyResource item in collection.GetAllAsync(orderby: orderby)) + // invoke the operation + string contentKeyPolicyName = "PolicyWithClearKeyOptionAndSwtTokenRestriction"; + ContentKeyPolicyData data = new ContentKeyPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContentKeyPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "ArmPolicyDescription", + Options = {new ContentKeyPolicyOption(new ContentKeyPolicyClearKeyConfiguration(), new ContentKeyPolicyTokenRestriction("urn:issuer", "urn:audience", new ContentKeyPolicySymmetricTokenKey(Encoding.UTF8.GetBytes("AAAAAAAAAAAAAAAAAAAAAA==")), ContentKeyPolicyRestrictionTokenType.Swt)) +{ +Name = "ClearKeyOption", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contentKeyPolicyName, data); + ContentKeyPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContentKeyPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsContentKeyPoliciesWithCreatedAndLastModifiedFilters() + public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithPlayReadyOptionAndOpenRestriction() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-list-in-date-range.json - // this example is just showing the usage of "ContentKeyPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-create-playready-open.json + // this example is just showing the usage of "ContentKeyPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,26 +83,43 @@ public async Task GetAll_ListsContentKeyPoliciesWithCreatedAndLastModifiedFilter // get the collection of this ContentKeyPolicyResource ContentKeyPolicyCollection collection = mediaServicesAccount.GetContentKeyPolicies(); - // invoke the operation and iterate over the result - string filter = "properties/lastModified gt 2016-06-01 and properties/created lt 2013-07-01"; - await foreach (ContentKeyPolicyResource item in collection.GetAllAsync(filter: filter)) + // invoke the operation + string contentKeyPolicyName = "PolicyWithPlayReadyOptionAndOpenRestriction"; + ContentKeyPolicyData data = new ContentKeyPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContentKeyPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "ArmPolicyDescription", + Options = {new ContentKeyPolicyOption(new ContentKeyPolicyPlayReadyConfiguration(new ContentKeyPolicyPlayReadyLicense[] +{ +new ContentKeyPolicyPlayReadyLicense(true, ContentKeyPolicyPlayReadyLicenseType.Persistent, new ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader(), ContentKeyPolicyPlayReadyContentType.UltraVioletDownload) +{ +SecurityLevel = PlayReadySecurityLevel.SL150, +BeginOn = DateTimeOffset.Parse("2017-10-16T18:22:53.46Z"), +PlayRight = new ContentKeyPolicyPlayReadyPlayRight(false, true, false, ContentKeyPolicyPlayReadyUnknownOutputPassingOption.NotAllowed) +{ +ScmsRestriction = 2, +}, +} +}), new ContentKeyPolicyOpenRestriction()) +{ +Name = "ArmPolicyOptionName", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contentKeyPolicyName, data); + ContentKeyPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContentKeyPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsAllContentKeyPolicies() + public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithWidevineOptionAndTokenRestriction() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-list-all.json - // this example is just showing the usage of "ContentKeyPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-create-widevine-token.json + // this example is just showing the usage of "ContentKeyPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,25 +137,35 @@ public async Task GetAll_ListsAllContentKeyPolicies() // get the collection of this ContentKeyPolicyResource ContentKeyPolicyCollection collection = mediaServicesAccount.GetContentKeyPolicies(); - // invoke the operation and iterate over the result - await foreach (ContentKeyPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string contentKeyPolicyName = "PolicyWithWidevineOptionAndJwtTokenRestriction"; + ContentKeyPolicyData data = new ContentKeyPolicyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContentKeyPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "ArmPolicyDescription", + Options = {new ContentKeyPolicyOption(new ContentKeyPolicyWidevineConfiguration("{\"allowed_track_types\":\"SD_HD\",\"content_key_specs\":[{\"track_type\":\"SD\",\"security_level\":1,\"required_output_protection\":{\"hdcp\":\"HDCP_V2\"}}],\"policy_overrides\":{\"can_play\":true,\"can_persist\":true,\"can_renew\":false}}"), new ContentKeyPolicyTokenRestriction("urn:issuer", "urn:audience", new ContentKeyPolicyRsaTokenKey(Encoding.UTF8.GetBytes("AQAB"), Encoding.UTF8.GetBytes("AQAD")), ContentKeyPolicyRestrictionTokenType.Jwt) +{ +AlternateVerificationKeys = {new ContentKeyPolicySymmetricTokenKey(Encoding.UTF8.GetBytes("AAAAAAAAAAAAAAAAAAAAAA=="))}, +}) +{ +Name = "widevineoption", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contentKeyPolicyName, data); + ContentKeyPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContentKeyPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAContentKeyPolicyByName() + public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithMultipleOptions() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-get-by-name.json - // this example is just showing the usage of "ContentKeyPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-create-multiple-options.json + // this example is just showing the usage of "ContentKeyPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,8 +184,20 @@ public async Task Get_GetAContentKeyPolicyByName() ContentKeyPolicyCollection collection = mediaServicesAccount.GetContentKeyPolicies(); // invoke the operation - string contentKeyPolicyName = "PolicyWithMultipleOptions"; - ContentKeyPolicyResource result = await collection.GetAsync(contentKeyPolicyName); + string contentKeyPolicyName = "PolicyCreatedWithMultipleOptions"; + ContentKeyPolicyData data = new ContentKeyPolicyData + { + Description = "ArmPolicyDescription", + Options = {new ContentKeyPolicyOption(new ContentKeyPolicyClearKeyConfiguration(), new ContentKeyPolicyTokenRestriction("urn:issuer", "urn:audience", new ContentKeyPolicySymmetricTokenKey(Encoding.UTF8.GetBytes("AAAAAAAAAAAAAAAAAAAAAA==")), ContentKeyPolicyRestrictionTokenType.Swt)) +{ +Name = "ClearKeyOption", +}, new ContentKeyPolicyOption(new ContentKeyPolicyWidevineConfiguration("{\"allowed_track_types\":\"SD_HD\",\"content_key_specs\":[{\"track_type\":\"SD\",\"security_level\":1,\"required_output_protection\":{\"hdcp\":\"HDCP_V2\"}}],\"policy_overrides\":{\"can_play\":true,\"can_persist\":true,\"can_renew\":false}}"), new ContentKeyPolicyOpenRestriction()) +{ +Name = "widevineoption", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contentKeyPolicyName, data); + ContentKeyPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -162,7 +208,7 @@ public async Task Get_GetAContentKeyPolicyByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAContentKeyPolicyByName() + public async Task Get_GetAContentKeyPolicyByName() { // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-get-by-name.json // this example is just showing the usage of "ContentKeyPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -185,17 +231,21 @@ public async Task Exists_GetAContentKeyPolicyByName() // invoke the operation string contentKeyPolicyName = "PolicyWithMultipleOptions"; - bool result = await collection.ExistsAsync(contentKeyPolicyName); + ContentKeyPolicyResource result = await collection.GetAsync(contentKeyPolicyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContentKeyPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAContentKeyPolicyByName() + public async Task GetAll_ListsContentKeyPoliciesOrderedByLastModified() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-get-by-name.json - // this example is just showing the usage of "ContentKeyPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-list-by-lastModified.json + // this example is just showing the usage of "ContentKeyPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,31 +263,26 @@ public async Task GetIfExists_GetAContentKeyPolicyByName() // get the collection of this ContentKeyPolicyResource ContentKeyPolicyCollection collection = mediaServicesAccount.GetContentKeyPolicies(); - // invoke the operation - string contentKeyPolicyName = "PolicyWithMultipleOptions"; - NullableResponse response = await collection.GetIfExistsAsync(contentKeyPolicyName); - ContentKeyPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string orderby = "properties/lastModified"; + await foreach (ContentKeyPolicyResource item in collection.GetAllAsync(orderby: orderby)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ContentKeyPolicyData resourceData = result.Data; + ContentKeyPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithClearKeyOptionAndTokenRestriction() + public async Task GetAll_ListsContentKeyPoliciesWithCreatedAndLastModifiedFilters() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-create-nodrm-token.json - // this example is just showing the usage of "ContentKeyPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-list-in-date-range.json + // this example is just showing the usage of "ContentKeyPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -255,35 +300,26 @@ public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithClearKeyOptionAndTo // get the collection of this ContentKeyPolicyResource ContentKeyPolicyCollection collection = mediaServicesAccount.GetContentKeyPolicies(); - // invoke the operation - string contentKeyPolicyName = "PolicyWithClearKeyOptionAndSwtTokenRestriction"; - ContentKeyPolicyData data = new ContentKeyPolicyData() + // invoke the operation and iterate over the result + string filter = "properties/lastModified gt 2016-06-01 and properties/created lt 2013-07-01"; + await foreach (ContentKeyPolicyResource item in collection.GetAllAsync(filter: filter)) { - Description = "ArmPolicyDescription", - Options = -{ -new ContentKeyPolicyOption(new ContentKeyPolicyClearKeyConfiguration(),new ContentKeyPolicyTokenRestriction("urn:issuer","urn:audience",new ContentKeyPolicySymmetricTokenKey(Convert.FromBase64String("AAAAAAAAAAAAAAAAAAAAAA==")),ContentKeyPolicyRestrictionTokenType.Swt)) -{ -Name = "ClearKeyOption", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contentKeyPolicyName, data); - ContentKeyPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContentKeyPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContentKeyPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithPlayReadyOptionAndOpenRestriction() + public async Task GetAll_ListsAllContentKeyPolicies() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-create-playready-open.json - // this example is just showing the usage of "ContentKeyPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-list-all.json + // this example is just showing the usage of "ContentKeyPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -301,46 +337,25 @@ public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithPlayReadyOptionAndO // get the collection of this ContentKeyPolicyResource ContentKeyPolicyCollection collection = mediaServicesAccount.GetContentKeyPolicies(); - // invoke the operation - string contentKeyPolicyName = "PolicyWithPlayReadyOptionAndOpenRestriction"; - ContentKeyPolicyData data = new ContentKeyPolicyData() + // invoke the operation and iterate over the result + await foreach (ContentKeyPolicyResource item in collection.GetAllAsync()) { - Description = "ArmPolicyDescription", - Options = -{ -new ContentKeyPolicyOption(new ContentKeyPolicyPlayReadyConfiguration(new ContentKeyPolicyPlayReadyLicense[] -{ -new ContentKeyPolicyPlayReadyLicense(true,ContentKeyPolicyPlayReadyLicenseType.Persistent,new ContentKeyPolicyPlayReadyContentEncryptionKeyFromHeader(),ContentKeyPolicyPlayReadyContentType.UltraVioletDownload) -{ -SecurityLevel = PlayReadySecurityLevel.SL150, -BeginOn = DateTimeOffset.Parse("2017-10-16T18:22:53.46Z"), -PlayRight = new ContentKeyPolicyPlayReadyPlayRight(false,true,false,ContentKeyPolicyPlayReadyUnknownOutputPassingOption.NotAllowed) -{ -ScmsRestriction = 2, -}, -} -}),new ContentKeyPolicyOpenRestriction()) -{ -Name = "ArmPolicyOptionName", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contentKeyPolicyName, data); - ContentKeyPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContentKeyPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContentKeyPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithWidevineOptionAndTokenRestriction() + public async Task Exists_GetAContentKeyPolicyByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-create-widevine-token.json - // this example is just showing the usage of "ContentKeyPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-get-by-name.json + // this example is just showing the usage of "ContentKeyPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -359,40 +374,18 @@ public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithWidevineOptionAndTo ContentKeyPolicyCollection collection = mediaServicesAccount.GetContentKeyPolicies(); // invoke the operation - string contentKeyPolicyName = "PolicyWithWidevineOptionAndJwtTokenRestriction"; - ContentKeyPolicyData data = new ContentKeyPolicyData() - { - Description = "ArmPolicyDescription", - Options = -{ -new ContentKeyPolicyOption(new ContentKeyPolicyWidevineConfiguration("{\"allowed_track_types\":\"SD_HD\",\"content_key_specs\":[{\"track_type\":\"SD\",\"security_level\":1,\"required_output_protection\":{\"hdcp\":\"HDCP_V2\"}}],\"policy_overrides\":{\"can_play\":true,\"can_persist\":true,\"can_renew\":false}}"),new ContentKeyPolicyTokenRestriction("urn:issuer","urn:audience",new ContentKeyPolicyRsaTokenKey(Convert.FromBase64String("AQAB"),Convert.FromBase64String("AQAD")),ContentKeyPolicyRestrictionTokenType.Jwt) -{ -AlternateVerificationKeys = -{ -new ContentKeyPolicySymmetricTokenKey(Convert.FromBase64String("AAAAAAAAAAAAAAAAAAAAAA==")) -}, -}) -{ -Name = "widevineoption", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contentKeyPolicyName, data); - ContentKeyPolicyResource result = lro.Value; + string contentKeyPolicyName = "PolicyWithMultipleOptions"; + bool result = await collection.ExistsAsync(contentKeyPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContentKeyPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithMultipleOptions() + public async Task GetIfExists_GetAContentKeyPolicyByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-create-multiple-options.json - // this example is just showing the usage of "ContentKeyPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/content-key-policies-get-by-name.json + // this example is just showing the usage of "ContentKeyPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -411,29 +404,22 @@ public async Task CreateOrUpdate_CreatesAContentKeyPolicyWithMultipleOptions() ContentKeyPolicyCollection collection = mediaServicesAccount.GetContentKeyPolicies(); // invoke the operation - string contentKeyPolicyName = "PolicyCreatedWithMultipleOptions"; - ContentKeyPolicyData data = new ContentKeyPolicyData() - { - Description = "ArmPolicyDescription", - Options = -{ -new ContentKeyPolicyOption(new ContentKeyPolicyClearKeyConfiguration(),new ContentKeyPolicyTokenRestriction("urn:issuer","urn:audience",new ContentKeyPolicySymmetricTokenKey(Convert.FromBase64String("AAAAAAAAAAAAAAAAAAAAAA==")),ContentKeyPolicyRestrictionTokenType.Swt)) -{ -Name = "ClearKeyOption", -},new ContentKeyPolicyOption(new ContentKeyPolicyWidevineConfiguration("{\"allowed_track_types\":\"SD_HD\",\"content_key_specs\":[{\"track_type\":\"SD\",\"security_level\":1,\"required_output_protection\":{\"hdcp\":\"HDCP_V2\"}}],\"policy_overrides\":{\"can_play\":true,\"can_persist\":true,\"can_renew\":false}}"),new ContentKeyPolicyOpenRestriction()) -{ -Name = "widevineoption", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, contentKeyPolicyName, data); - ContentKeyPolicyResource result = lro.Value; + string contentKeyPolicyName = "PolicyWithMultipleOptions"; + NullableResponse response = await collection.GetIfExistsAsync(contentKeyPolicyName); + ContentKeyPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ContentKeyPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ContentKeyPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_ContentKeyPolicyResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_ContentKeyPolicyResource.cs index eae58016fba6b..58e5f7dcac5a9 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_ContentKeyPolicyResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_ContentKeyPolicyResource.cs @@ -96,16 +96,13 @@ public async Task Update_UpdateAContentKeyPolicy() ContentKeyPolicyResource contentKeyPolicy = client.GetContentKeyPolicyResource(contentKeyPolicyResourceId); // invoke the operation - ContentKeyPolicyData data = new ContentKeyPolicyData() + ContentKeyPolicyData data = new ContentKeyPolicyData { Description = "Updated Policy", - Options = -{ -new ContentKeyPolicyOption(new ContentKeyPolicyClearKeyConfiguration(),new ContentKeyPolicyOpenRestriction()) + Options = {new ContentKeyPolicyOption(new ContentKeyPolicyClearKeyConfiguration(), new ContentKeyPolicyOpenRestriction()) { Name = "ClearKeyOption", -} -}, +}}, }; ContentKeyPolicyResource result = await contentKeyPolicy.UpdateAsync(data); diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetCollection.cs index b61d24078a117..4bf372c543b47 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MediaAssetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAssetCreatedInADateRange() + public async Task CreateOrUpdate_CreateAnAsset() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-list-in-date-range.json - // this example is just showing the usage of "Assets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-create.json + // this example is just showing the usage of "Assets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,27 +38,29 @@ public async Task GetAll_ListAssetCreatedInADateRange() // get the collection of this MediaAssetResource MediaAssetCollection collection = mediaServicesAccount.GetMediaAssets(); - // invoke the operation and iterate over the result - string filter = "properties/created gt 2012-06-01 and properties/created lt 2013-07-01"; - string orderby = "properties/created"; - await foreach (MediaAssetResource item in collection.GetAllAsync(filter: filter, orderby: orderby)) + // invoke the operation + string assetName = "ClimbingMountLogan"; + MediaAssetData data = new MediaAssetData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "A documentary showing the ascent of Mount Logan", + StorageAccountName = "storage0", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetName, data); + MediaAssetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAssetOrderedByDate() + public async Task CreateOrUpdate_CreateAnAssetWithEncryptionScope() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-list-by-date.json - // this example is just showing the usage of "Assets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-create-with-encryption-scope.json + // this example is just showing the usage of "Assets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,26 +78,30 @@ public async Task GetAll_ListAssetOrderedByDate() // get the collection of this MediaAssetResource MediaAssetCollection collection = mediaServicesAccount.GetMediaAssets(); - // invoke the operation and iterate over the result - string orderby = "properties/created"; - await foreach (MediaAssetResource item in collection.GetAllAsync(orderby: orderby)) + // invoke the operation + string assetName = "ClimbingMountLogan"; + MediaAssetData data = new MediaAssetData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "A documentary showing the ascent of Mount Logan", + StorageAccountName = "storage0", + EncryptionScope = "encryptionScope1", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetName, data); + MediaAssetResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllAssets() + public async Task Get_GetAnAssetByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-list-all.json - // this example is just showing the usage of "Assets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-get-by-name.json + // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,25 +119,23 @@ public async Task GetAll_ListAllAssets() // get the collection of this MediaAssetResource MediaAssetCollection collection = mediaServicesAccount.GetMediaAssets(); - // invoke the operation and iterate over the result - await foreach (MediaAssetResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string assetName = "ClimbingMountAdams"; + MediaAssetResource result = await collection.GetAsync(assetName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAssetByName() + public async Task GetAll_ListAssetCreatedInADateRange() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-get-by-name.json - // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-list-in-date-range.json + // this example is just showing the usage of "Assets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -149,23 +153,27 @@ public async Task Get_GetAnAssetByName() // get the collection of this MediaAssetResource MediaAssetCollection collection = mediaServicesAccount.GetMediaAssets(); - // invoke the operation - string assetName = "ClimbingMountAdams"; - MediaAssetResource result = await collection.GetAsync(assetName); + // invoke the operation and iterate over the result + string filter = "properties/created gt 2012-06-01 and properties/created lt 2013-07-01"; + string orderby = "properties/created"; + await foreach (MediaAssetResource item in collection.GetAllAsync(filter: filter, orderby: orderby)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAssetByName() + public async Task GetAll_ListAssetOrderedByDate() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-get-by-name.json - // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-list-by-date.json + // this example is just showing the usage of "Assets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,19 +191,26 @@ public async Task Exists_GetAnAssetByName() // get the collection of this MediaAssetResource MediaAssetCollection collection = mediaServicesAccount.GetMediaAssets(); - // invoke the operation - string assetName = "ClimbingMountAdams"; - bool result = await collection.ExistsAsync(assetName); + // invoke the operation and iterate over the result + string orderby = "properties/created"; + await foreach (MediaAssetResource item in collection.GetAllAsync(orderby: orderby)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAssetByName() + public async Task GetAll_ListAllAssets() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-get-by-name.json - // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-list-all.json + // this example is just showing the usage of "Assets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,31 +228,25 @@ public async Task GetIfExists_GetAnAssetByName() // get the collection of this MediaAssetResource MediaAssetCollection collection = mediaServicesAccount.GetMediaAssets(); - // invoke the operation - string assetName = "ClimbingMountAdams"; - NullableResponse response = await collection.GetIfExistsAsync(assetName); - MediaAssetResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MediaAssetResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MediaAssetData resourceData = result.Data; + MediaAssetData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAsset() + public async Task Exists_GetAnAssetByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-create.json - // this example is just showing the usage of "Assets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-get-by-name.json + // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -256,28 +265,18 @@ public async Task CreateOrUpdate_CreateAnAsset() MediaAssetCollection collection = mediaServicesAccount.GetMediaAssets(); // invoke the operation - string assetName = "ClimbingMountLogan"; - MediaAssetData data = new MediaAssetData() - { - Description = "A documentary showing the ascent of Mount Logan", - StorageAccountName = "storage0", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetName, data); - MediaAssetResource result = lro.Value; + string assetName = "ClimbingMountAdams"; + bool result = await collection.ExistsAsync(assetName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAssetWithEncryptionScope() + public async Task GetIfExists_GetAnAssetByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-create-with-encryption-scope.json - // this example is just showing the usage of "Assets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assets-get-by-name.json + // this example is just showing the usage of "Assets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -296,21 +295,22 @@ public async Task CreateOrUpdate_CreateAnAssetWithEncryptionScope() MediaAssetCollection collection = mediaServicesAccount.GetMediaAssets(); // invoke the operation - string assetName = "ClimbingMountLogan"; - MediaAssetData data = new MediaAssetData() - { - Description = "A documentary showing the ascent of Mount Logan", - StorageAccountName = "storage0", - EncryptionScope = "encryptionScope1", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, assetName, data); - MediaAssetResource result = lro.Value; + string assetName = "ClimbingMountAdams"; + NullableResponse response = await collection.GetIfExistsAsync(assetName); + MediaAssetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetFilterCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetFilterCollection.cs index 851872d81634f..d8acd2c511fec 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetFilterCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetFilterCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MediaAssetFilterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllAssetFilters() + public async Task CreateOrUpdate_CreateAnAssetFilter() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assetFilters-list-all.json - // this example is just showing the usage of "AssetFilters_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assetFilters-create.json + // this example is just showing the usage of "AssetFilters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,39 @@ public async Task GetAll_ListAllAssetFilters() // get the collection of this MediaAssetFilterResource MediaAssetFilterCollection collection = mediaAsset.GetMediaAssetFilters(); - // invoke the operation and iterate over the result - await foreach (MediaAssetFilterResource item in collection.GetAllAsync()) + // invoke the operation + string filterName = "newAssetFilter"; + MediaAssetFilterData data = new MediaAssetFilterData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetFilterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PresentationTimeRange = new PresentationTimeRange + { + StartTimestamp = 0L, + EndTimestamp = 170000000L, + PresentationWindowDuration = 9223372036854775000L, + LiveBackoffDuration = 0L, + Timescale = 10000000L, + ForceEndTimestamp = false, + }, + FirstQualityBitrate = 128000, + Tracks = {new FilterTrackSelection(new FilterTrackPropertyCondition[] +{ +new FilterTrackPropertyCondition(FilterTrackPropertyType.Type, "Audio", FilterTrackPropertyCompareOperation.Equal), +new FilterTrackPropertyCondition(FilterTrackPropertyType.Language, "en", FilterTrackPropertyCompareOperation.NotEqual), +new FilterTrackPropertyCondition(FilterTrackPropertyType.FourCC, "EC-3", FilterTrackPropertyCompareOperation.NotEqual) +}), new FilterTrackSelection(new FilterTrackPropertyCondition[] +{ +new FilterTrackPropertyCondition(FilterTrackPropertyType.Type, "Video", FilterTrackPropertyCompareOperation.Equal), +new FilterTrackPropertyCondition(FilterTrackPropertyType.Bitrate, "3000000-5000000", FilterTrackPropertyCompareOperation.Equal) +})}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, filterName, data); + MediaAssetFilterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetFilterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +112,10 @@ public async Task Get_GetAnAssetFilterByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAssetFilterByName() + public async Task GetAll_ListAllAssetFilters() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assetFilters-get-by-name.json - // this example is just showing the usage of "AssetFilters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assetFilters-list-all.json + // this example is just showing the usage of "AssetFilters_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +134,22 @@ public async Task Exists_GetAnAssetFilterByName() // get the collection of this MediaAssetFilterResource MediaAssetFilterCollection collection = mediaAsset.GetMediaAssetFilters(); - // invoke the operation - string filterName = "assetFilterWithTimeWindowAndTrack"; - bool result = await collection.ExistsAsync(filterName); + // invoke the operation and iterate over the result + await foreach (MediaAssetFilterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetFilterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAssetFilterByName() + public async Task Exists_GetAnAssetFilterByName() { // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assetFilters-get-by-name.json // this example is just showing the usage of "AssetFilters_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +173,17 @@ public async Task GetIfExists_GetAnAssetFilterByName() // invoke the operation string filterName = "assetFilterWithTimeWindowAndTrack"; - NullableResponse response = await collection.GetIfExistsAsync(filterName); - MediaAssetFilterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(filterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetFilterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAssetFilter() + public async Task GetIfExists_GetAnAssetFilterByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assetFilters-create.json - // this example is just showing the usage of "AssetFilters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/assetFilters-get-by-name.json + // this example is just showing the usage of "AssetFilters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,38 +203,22 @@ public async Task CreateOrUpdate_CreateAnAssetFilter() MediaAssetFilterCollection collection = mediaAsset.GetMediaAssetFilters(); // invoke the operation - string filterName = "newAssetFilter"; - MediaAssetFilterData data = new MediaAssetFilterData() - { - PresentationTimeRange = new PresentationTimeRange() - { - StartTimestamp = 0L, - EndTimestamp = 170000000L, - PresentationWindowDuration = 9223372036854775000L, - LiveBackoffDuration = 0L, - Timescale = 10000000L, - ForceEndTimestamp = false, - }, - FirstQualityBitrate = 128000, - Tracks = -{ -new FilterTrackSelection(new FilterTrackPropertyCondition[] -{ -new FilterTrackPropertyCondition(FilterTrackPropertyType.Type,"Audio",FilterTrackPropertyCompareOperation.Equal),new FilterTrackPropertyCondition(FilterTrackPropertyType.Language,"en",FilterTrackPropertyCompareOperation.NotEqual),new FilterTrackPropertyCondition(FilterTrackPropertyType.FourCC,"EC-3",FilterTrackPropertyCompareOperation.NotEqual) -}),new FilterTrackSelection(new FilterTrackPropertyCondition[] -{ -new FilterTrackPropertyCondition(FilterTrackPropertyType.Type,"Video",FilterTrackPropertyCompareOperation.Equal),new FilterTrackPropertyCondition(FilterTrackPropertyType.Bitrate,"3000000-5000000",FilterTrackPropertyCompareOperation.Equal) -}) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, filterName, data); - MediaAssetFilterResource result = lro.Value; + string filterName = "assetFilterWithTimeWindowAndTrack"; + NullableResponse response = await collection.GetIfExistsAsync(filterName); + MediaAssetFilterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetFilterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetFilterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetFilterResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetFilterResource.cs index 0a0e69cea9e14..d2b2a82fe45e1 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetFilterResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetFilterResource.cs @@ -99,9 +99,9 @@ public async Task Update_UpdateAnAssetFilter() MediaAssetFilterResource mediaAssetFilter = client.GetMediaAssetFilterResource(mediaAssetFilterResourceId); // invoke the operation - MediaAssetFilterData data = new MediaAssetFilterData() + MediaAssetFilterData data = new MediaAssetFilterData { - PresentationTimeRange = new PresentationTimeRange() + PresentationTimeRange = new PresentationTimeRange { StartTimestamp = 10L, EndTimestamp = 170000000L, diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetResource.cs index 147f7276eb250..c415ad33ae41a 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetResource.cs @@ -96,7 +96,7 @@ public async Task Update_UpdateAnAsset() MediaAssetResource mediaAsset = client.GetMediaAssetResource(mediaAssetResourceId); // invoke the operation - MediaAssetData data = new MediaAssetData() + MediaAssetData data = new MediaAssetData { Description = "A documentary showing the ascent of Mount Baker in HD", }; @@ -131,7 +131,7 @@ public async Task GetStorageContainerUris_ListAssetSASURLs() MediaAssetResource mediaAsset = client.GetMediaAssetResource(mediaAssetResourceId); // invoke the operation and iterate over the result - MediaAssetStorageContainerSasContent content = new MediaAssetStorageContainerSasContent() + MediaAssetStorageContainerSasContent content = new MediaAssetStorageContainerSasContent { Permissions = MediaAssetContainerPermission.ReadWrite, ExpireOn = DateTimeOffset.Parse("2018-01-01T10:00:00.007Z"), diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetTrackCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetTrackCollection.cs index 8810bd2d81b0d..bc37465abc064 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetTrackCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetTrackCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MediaAssetTrackCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsAllTracks() + public async Task CreateOrUpdate_CreatesATrack() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/asset-tracks-list-all.json - // this example is just showing the usage of "Tracks_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/asset-tracks-create.json + // this example is just showing the usage of "Tracks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,25 @@ public async Task GetAll_ListsAllTracks() // get the collection of this MediaAssetTrackResource MediaAssetTrackCollection collection = mediaAsset.GetMediaAssetTracks(); - // invoke the operation and iterate over the result - await foreach (MediaAssetTrackResource item in collection.GetAllAsync()) + // invoke the operation + string trackName = "text3"; + MediaAssetTrackData data = new MediaAssetTrackData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetTrackData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Track = new TextTrack + { + FileName = "text3.ttml", + DisplayName = "A new track", + PlayerVisibility = PlayerVisibility.Visible, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, trackName, data); + MediaAssetTrackResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetTrackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +98,10 @@ public async Task Get_GetATrackByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetATrackByName() + public async Task GetAll_ListsAllTracks() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/asset-tracks-get-by-name.json - // this example is just showing the usage of "Tracks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/asset-tracks-list-all.json + // this example is just showing the usage of "Tracks_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +120,22 @@ public async Task Exists_GetATrackByName() // get the collection of this MediaAssetTrackResource MediaAssetTrackCollection collection = mediaAsset.GetMediaAssetTracks(); - // invoke the operation - string trackName = "text1"; - bool result = await collection.ExistsAsync(trackName); + // invoke the operation and iterate over the result + await foreach (MediaAssetTrackResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetTrackData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetATrackByName() + public async Task Exists_GetATrackByName() { // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/asset-tracks-get-by-name.json // this example is just showing the usage of "Tracks_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +159,17 @@ public async Task GetIfExists_GetATrackByName() // invoke the operation string trackName = "text1"; - NullableResponse response = await collection.GetIfExistsAsync(trackName); - MediaAssetTrackResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(trackName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetTrackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesATrack() + public async Task GetIfExists_GetATrackByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/asset-tracks-create.json - // this example is just showing the usage of "Tracks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/asset-tracks-get-by-name.json + // this example is just showing the usage of "Tracks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,24 +189,22 @@ public async Task CreateOrUpdate_CreatesATrack() MediaAssetTrackCollection collection = mediaAsset.GetMediaAssetTracks(); // invoke the operation - string trackName = "text3"; - MediaAssetTrackData data = new MediaAssetTrackData() - { - Track = new TextTrack() - { - FileName = "text3.ttml", - DisplayName = "A new track", - PlayerVisibility = PlayerVisibility.Visible, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, trackName, data); - MediaAssetTrackResource result = lro.Value; + string trackName = "text1"; + NullableResponse response = await collection.GetIfExistsAsync(trackName); + MediaAssetTrackResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaAssetTrackData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaAssetTrackData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetTrackResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetTrackResource.cs index c7832f397cc55..36ff7c2e0cfd1 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetTrackResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaAssetTrackResource.cs @@ -99,9 +99,9 @@ public async Task Update_UpdateATrack() MediaAssetTrackResource mediaAssetTrack = client.GetMediaAssetTrackResource(mediaAssetTrackResourceId); // invoke the operation - MediaAssetTrackData data = new MediaAssetTrackData() + MediaAssetTrackData data = new MediaAssetTrackData { - Track = new TextTrack() + Track = new TextTrack { DisplayName = "A new name", }, diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaJobCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaJobCollection.cs index 1b045314d176c..81eef5b645734 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaJobCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaJobCollection.cs @@ -16,6 +16,87 @@ namespace Azure.ResourceManager.Media.Samples { public partial class Sample_MediaJobCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateAJob() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-create.json + // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MediaTransformResource created on azure + // for more information of creating MediaTransformResource, please refer to the document of MediaTransformResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "contosoresources"; + string accountName = "contosomedia"; + string transformName = "exampleTransform"; + ResourceIdentifier mediaTransformResourceId = MediaTransformResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, transformName); + MediaTransformResource mediaTransform = client.GetMediaTransformResource(mediaTransformResourceId); + + // get the collection of this MediaJobResource + MediaJobCollection collection = mediaTransform.GetMediaJobs(); + + // invoke the operation + string jobName = "job1"; + MediaJobData data = new MediaJobData + { + Input = new MediaJobInputAsset("job1-InputAsset"), + Outputs = { new MediaJobOutputAsset("job1-OutputAsset") }, + CorrelationData = +{ +["Key 2"] = "Value 2", +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); + MediaJobResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAJobByName() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-get-by-name.json + // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MediaTransformResource created on azure + // for more information of creating MediaTransformResource, please refer to the document of MediaTransformResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "contosoresources"; + string accountName = "contosomedia"; + string transformName = "exampleTransform"; + ResourceIdentifier mediaTransformResourceId = MediaTransformResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, transformName); + MediaTransformResource mediaTransform = client.GetMediaTransformResource(mediaTransformResourceId); + + // get the collection of this MediaJobResource + MediaJobCollection collection = mediaTransform.GetMediaJobs(); + + // invoke the operation + string jobName = "job1"; + MediaJobResource result = await collection.GetAsync(jobName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaJobData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListsJobsForTheTransformFilterByCreated() @@ -284,41 +365,6 @@ public async Task GetAll_ListsAllOfTheJobsForTheTransform() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAJobByName() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-get-by-name.json - // this example is just showing the usage of "Jobs_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MediaTransformResource created on azure - // for more information of creating MediaTransformResource, please refer to the document of MediaTransformResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "contosoresources"; - string accountName = "contosomedia"; - string transformName = "exampleTransform"; - ResourceIdentifier mediaTransformResourceId = MediaTransformResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, transformName); - MediaTransformResource mediaTransform = client.GetMediaTransformResource(mediaTransformResourceId); - - // get the collection of this MediaJobResource - MediaJobCollection collection = mediaTransform.GetMediaJobs(); - - // invoke the operation - string jobName = "job1"; - MediaJobResource result = await collection.GetAsync(jobName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAJobByName() @@ -392,54 +438,5 @@ public async Task GetIfExists_GetAJobByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAJob() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/jobs-create.json - // this example is just showing the usage of "Jobs_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MediaTransformResource created on azure - // for more information of creating MediaTransformResource, please refer to the document of MediaTransformResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "contosoresources"; - string accountName = "contosomedia"; - string transformName = "exampleTransform"; - ResourceIdentifier mediaTransformResourceId = MediaTransformResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, transformName); - MediaTransformResource mediaTransform = client.GetMediaTransformResource(mediaTransformResourceId); - - // get the collection of this MediaJobResource - MediaJobCollection collection = mediaTransform.GetMediaJobs(); - - // invoke the operation - string jobName = "job1"; - MediaJobData data = new MediaJobData() - { - Input = new MediaJobInputAsset("job1-InputAsset"), - Outputs = -{ -new MediaJobOutputAsset("job1-OutputAsset") -}, - CorrelationData = -{ -["Key 2"] = "Value 2", -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, jobName, data); - MediaJobResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaJobData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaJobResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaJobResource.cs index 4582c9280f7ba..55456a0020100 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaJobResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaJobResource.cs @@ -99,14 +99,11 @@ public async Task Update_UpdateAJob() MediaJobResource mediaJob = client.GetMediaJobResource(mediaJobResourceId); // invoke the operation - MediaJobData data = new MediaJobData() + MediaJobData data = new MediaJobData { Description = "Example job to illustrate update.", Input = new MediaJobInputAsset("job1-InputAsset"), - Outputs = -{ -new MediaJobOutputAsset("job1-OutputAsset") -}, + Outputs = { new MediaJobOutputAsset("job1-OutputAsset") }, Priority = MediaJobPriority.High, }; MediaJobResource result = await mediaJob.UpdateAsync(data); diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveEventCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveEventCollection.cs index 9eeb81dd5f86f..a3e8df6245e08 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveEventCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveEventCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_MediaLiveEventCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllLiveEvents() + public async Task CreateOrUpdate_CreateALiveEvent() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-list-all.json - // this example is just showing the usage of "LiveEvents_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-create.json + // this example is just showing the usage of "LiveEvents_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,44 @@ public async Task GetAll_ListAllLiveEvents() // get the collection of this MediaLiveEventResource MediaLiveEventCollection collection = mediaServicesAccount.GetMediaLiveEvents(); - // invoke the operation and iterate over the result - await foreach (MediaLiveEventResource item in collection.GetAllAsync()) + // invoke the operation + string liveEventName = "myLiveEvent1"; + MediaLiveEventData data = new MediaLiveEventData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaLiveEventData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "test event 1", + Input = new LiveEventInput(LiveEventInputProtocol.Rtmp) + { + IPAllowedIPs = {new IPRange +{ +Name = "AllowAll", +Address = IPAddress.Parse("0.0.0.0"), +SubnetPrefixLength = 0, +}}, + KeyFrameIntervalDuration = XmlConvert.ToTimeSpan("PT6S"), + }, + Preview = new LiveEventPreview + { + IPAllowedIPs = {new IPRange +{ +Name = "AllowAll", +Address = IPAddress.Parse("0.0.0.0"), +SubnetPrefixLength = 0, +}}, + }, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, liveEventName, data); + MediaLiveEventResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaLiveEventData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +117,10 @@ public async Task Get_GetALiveEventByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetALiveEventByName() + public async Task GetAll_ListAllLiveEvents() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-list-by-name.json - // this example is just showing the usage of "LiveEvents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-list-all.json + // this example is just showing the usage of "LiveEvents_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +138,22 @@ public async Task Exists_GetALiveEventByName() // get the collection of this MediaLiveEventResource MediaLiveEventCollection collection = mediaServicesAccount.GetMediaLiveEvents(); - // invoke the operation - string liveEventName = "myLiveEvent1"; - bool result = await collection.ExistsAsync(liveEventName); + // invoke the operation and iterate over the result + await foreach (MediaLiveEventResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaLiveEventData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetALiveEventByName() + public async Task Exists_GetALiveEventByName() { // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-list-by-name.json // this example is just showing the usage of "LiveEvents_Get" operation, for the dependent resources, they will have to be created separately. @@ -143,29 +176,17 @@ public async Task GetIfExists_GetALiveEventByName() // invoke the operation string liveEventName = "myLiveEvent1"; - NullableResponse response = await collection.GetIfExistsAsync(liveEventName); - MediaLiveEventResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(liveEventName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaLiveEventData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateALiveEvent() + public async Task GetIfExists_GetALiveEventByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-create.json - // this example is just showing the usage of "LiveEvents_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-list-by-name.json + // this example is just showing the usage of "LiveEvents_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,48 +206,21 @@ public async Task CreateOrUpdate_CreateALiveEvent() // invoke the operation string liveEventName = "myLiveEvent1"; - MediaLiveEventData data = new MediaLiveEventData(new AzureLocation("West US")) - { - Description = "test event 1", - Input = new LiveEventInput(LiveEventInputProtocol.Rtmp) - { - IPAllowedIPs = -{ -new IPRange() -{ -Name = "AllowAll", -Address = IPAddress.Parse("0.0.0.0"), -SubnetPrefixLength = 0, -} -}, - KeyFrameIntervalDuration = XmlConvert.ToTimeSpan("PT6S"), - }, - Preview = new LiveEventPreview() - { - IPAllowedIPs = -{ -new IPRange() -{ -Name = "AllowAll", -Address = IPAddress.Parse("0.0.0.0"), -SubnetPrefixLength = 0, -} -}, - }, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, liveEventName, data); - MediaLiveEventResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(liveEventName); + MediaLiveEventResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaLiveEventData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaLiveEventData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveEventResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveEventResource.cs index 31533681d503b..2595415b047c5 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveEventResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveEventResource.cs @@ -49,6 +49,33 @@ public async Task Get_GetALiveEventByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteALiveEvent() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-delete.json + // this example is just showing the usage of "LiveEvents_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MediaLiveEventResource created on azure + // for more information of creating MediaLiveEventResource, please refer to the document of MediaLiveEventResource + string subscriptionId = "0a6ec948-5a62-437d-b9df-934dc7c1b722"; + string resourceGroupName = "mediaresources"; + string accountName = "slitestmedia10"; + string liveEventName = "myLiveEvent1"; + ResourceIdentifier mediaLiveEventResourceId = MediaLiveEventResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, liveEventName); + MediaLiveEventResource mediaLiveEvent = client.GetMediaLiveEventResource(mediaLiveEventResourceId); + + // invoke the operation + await mediaLiveEvent.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_UpdateALiveEvent() @@ -76,32 +103,26 @@ public async Task Update_UpdateALiveEvent() Description = "test event updated", Input = new LiveEventInput(LiveEventInputProtocol.FragmentedMp4) { - IPAllowedIPs = -{ -new IPRange() + IPAllowedIPs = {new IPRange { Name = "AllowOne", Address = IPAddress.Parse("192.1.1.0"), -} -}, +}}, KeyFrameIntervalDuration = XmlConvert.ToTimeSpan("PT6S"), }, - Preview = new LiveEventPreview() + Preview = new LiveEventPreview { - IPAllowedIPs = -{ -new IPRange() + IPAllowedIPs = {new IPRange { Name = "AllowOne", Address = IPAddress.Parse("192.1.1.0"), -} -}, +}}, }, Tags = { ["tag1"] = "value1", ["tag2"] = "value2", -["tag3"] = "value3", +["tag3"] = "value3" }, }; ArmOperation lro = await mediaLiveEvent.UpdateAsync(WaitUntil.Completed, data); @@ -114,33 +135,6 @@ public async Task Update_UpdateALiveEvent() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteALiveEvent() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveevent-delete.json - // this example is just showing the usage of "LiveEvents_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MediaLiveEventResource created on azure - // for more information of creating MediaLiveEventResource, please refer to the document of MediaLiveEventResource - string subscriptionId = "0a6ec948-5a62-437d-b9df-934dc7c1b722"; - string resourceGroupName = "mediaresources"; - string accountName = "slitestmedia10"; - string liveEventName = "myLiveEvent1"; - ResourceIdentifier mediaLiveEventResourceId = MediaLiveEventResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, liveEventName); - MediaLiveEventResource mediaLiveEvent = client.GetMediaLiveEventResource(mediaLiveEventResourceId); - - // invoke the operation - await mediaLiveEvent.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Allocate_AllocateALiveEvent() @@ -217,7 +211,7 @@ public async Task Stop_StopALiveEvent() MediaLiveEventResource mediaLiveEvent = client.GetMediaLiveEventResource(mediaLiveEventResourceId); // invoke the operation - LiveEventActionContent content = new LiveEventActionContent() + LiveEventActionContent content = new LiveEventActionContent { RemoveOutputsOnStop = false, }; diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveOutputCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveOutputCollection.cs index e53a32a78c004..4c4a23efac4e3 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveOutputCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveOutputCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MediaLiveOutputCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllLiveOutputs() + public async Task CreateOrUpdate_CreateALiveOutput() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-list-all.json - // this example is just showing the usage of "LiveOutputs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-create.json + // this example is just showing the usage of "LiveOutputs_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,25 @@ public async Task GetAll_ListAllLiveOutputs() // get the collection of this MediaLiveOutputResource MediaLiveOutputCollection collection = mediaLiveEvent.GetMediaLiveOutputs(); - // invoke the operation and iterate over the result - await foreach (MediaLiveOutputResource item in collection.GetAllAsync()) + // invoke the operation + string liveOutputName = "myLiveOutput1"; + MediaLiveOutputData data = new MediaLiveOutputData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaLiveOutputData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "test live output 1", + AssetName = "6f3264f5-a189-48b4-a29a-a40f22575212", + ArchiveWindowLength = XmlConvert.ToTimeSpan("PT5M"), + RewindWindowLength = XmlConvert.ToTimeSpan("PT4M"), + ManifestName = "testmanifest", + HlsFragmentsPerTsSegment = 5, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, liveOutputName, data); + MediaLiveOutputResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaLiveOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +98,10 @@ public async Task Get_GetALiveOutputByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetALiveOutputByName() + public async Task GetAll_ListAllLiveOutputs() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-list-by-name.json - // this example is just showing the usage of "LiveOutputs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-list-all.json + // this example is just showing the usage of "LiveOutputs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +120,22 @@ public async Task Exists_GetALiveOutputByName() // get the collection of this MediaLiveOutputResource MediaLiveOutputCollection collection = mediaLiveEvent.GetMediaLiveOutputs(); - // invoke the operation - string liveOutputName = "myLiveOutput1"; - bool result = await collection.ExistsAsync(liveOutputName); + // invoke the operation and iterate over the result + await foreach (MediaLiveOutputResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaLiveOutputData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetALiveOutputByName() + public async Task Exists_GetALiveOutputByName() { // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-list-by-name.json // this example is just showing the usage of "LiveOutputs_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +159,17 @@ public async Task GetIfExists_GetALiveOutputByName() // invoke the operation string liveOutputName = "myLiveOutput1"; - NullableResponse response = await collection.GetIfExistsAsync(liveOutputName); - MediaLiveOutputResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(liveOutputName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaLiveOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateALiveOutput() + public async Task GetIfExists_GetALiveOutputByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-create.json - // this example is just showing the usage of "LiveOutputs_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-list-by-name.json + // this example is just showing the usage of "LiveOutputs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,23 +190,21 @@ public async Task CreateOrUpdate_CreateALiveOutput() // invoke the operation string liveOutputName = "myLiveOutput1"; - MediaLiveOutputData data = new MediaLiveOutputData() - { - Description = "test live output 1", - AssetName = "6f3264f5-a189-48b4-a29a-a40f22575212", - ArchiveWindowLength = XmlConvert.ToTimeSpan("PT5M"), - RewindWindowLength = XmlConvert.ToTimeSpan("PT4M"), - ManifestName = "testmanifest", - HlsFragmentsPerTsSegment = 5, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, liveOutputName, data); - MediaLiveOutputResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(liveOutputName); + MediaLiveOutputResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaLiveOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaLiveOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveOutputResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveOutputResource.cs index f236f310f7e0b..d02b67e67f360 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveOutputResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaLiveOutputResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetALiveOutputByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateALiveOutput() + public async Task Delete_DeleteALiveOutput() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-create.json - // this example is just showing the usage of "LiveOutputs_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-delete.json + // this example is just showing the usage of "LiveOutputs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,31 +71,17 @@ public async Task Update_CreateALiveOutput() MediaLiveOutputResource mediaLiveOutput = client.GetMediaLiveOutputResource(mediaLiveOutputResourceId); // invoke the operation - MediaLiveOutputData data = new MediaLiveOutputData() - { - Description = "test live output 1", - AssetName = "6f3264f5-a189-48b4-a29a-a40f22575212", - ArchiveWindowLength = XmlConvert.ToTimeSpan("PT5M"), - RewindWindowLength = XmlConvert.ToTimeSpan("PT4M"), - ManifestName = "testmanifest", - HlsFragmentsPerTsSegment = 5, - }; - ArmOperation lro = await mediaLiveOutput.UpdateAsync(WaitUntil.Completed, data); - MediaLiveOutputResource result = lro.Value; + await mediaLiveOutput.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaLiveOutputData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteALiveOutput() + public async Task Update_CreateALiveOutput() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-delete.json - // this example is just showing the usage of "LiveOutputs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/liveoutput-create.json + // this example is just showing the usage of "LiveOutputs_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,9 +99,23 @@ public async Task Delete_DeleteALiveOutput() MediaLiveOutputResource mediaLiveOutput = client.GetMediaLiveOutputResource(mediaLiveOutputResourceId); // invoke the operation - await mediaLiveOutput.DeleteAsync(WaitUntil.Completed); + MediaLiveOutputData data = new MediaLiveOutputData + { + Description = "test live output 1", + AssetName = "6f3264f5-a189-48b4-a29a-a40f22575212", + ArchiveWindowLength = XmlConvert.ToTimeSpan("PT5M"), + RewindWindowLength = XmlConvert.ToTimeSpan("PT4M"), + ManifestName = "testmanifest", + HlsFragmentsPerTsSegment = 5, + }; + ArmOperation lro = await mediaLiveOutput.UpdateAsync(WaitUntil.Completed, data); + MediaLiveOutputResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaLiveOutputData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountCollection.cs index 739121773cce4..12195ee4cc6ab 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_MediaServicesAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllMediaServicesAccounts() + public async Task CreateOrUpdate_CreateAMediaServicesAccount() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/accounts-list-all-accounts.json - // this example is just showing the usage of "Mediaservices_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/async-accounts-create.json + // this example is just showing the usage of "Mediaservices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,25 +40,36 @@ public async Task GetAll_ListAllMediaServicesAccounts() // get the collection of this MediaServicesAccountResource MediaServicesAccountCollection collection = resourceGroupResource.GetMediaServicesAccounts(); - // invoke the operation and iterate over the result - await foreach (MediaServicesAccountResource item in collection.GetAllAsync()) + // invoke the operation + string accountName = "contososports"; + MediaServicesAccountData data = new MediaServicesAccountData(new AzureLocation("South Central US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + StorageAccounts = {new MediaServicesStorageAccount(MediaServicesStorageAccountType.Primary) +{ +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Storage/storageAccounts/teststorageaccount"), +}}, + Tags = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + MediaServicesAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAMediaServicesAccountByName() + public async Task CreateOrUpdate_CreateAMediaServicesAccountManagedIdentity() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/accounts-get-by-name.json - // this example is just showing the usage of "Mediaservices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/async-accounts-create-managed-identity.json + // this example is just showing the usage of "Mediaservices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,8 +87,46 @@ public async Task Get_GetAMediaServicesAccountByName() MediaServicesAccountCollection collection = resourceGroupResource.GetMediaServicesAccounts(); // invoke the operation - string accountName = "contosotv"; - MediaServicesAccountResource result = await collection.GetAsync(accountName); + string accountName = "contososports"; + MediaServicesAccountData data = new MediaServicesAccountData(new AzureLocation("South Central US")) + { + Identity = new ManagedServiceIdentity("UserAssigned") + { + UserAssignedIdentities = +{ +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity() +}, + }, + StorageAccounts = {new MediaServicesStorageAccount(MediaServicesStorageAccountType.Primary) +{ +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Storage/storageAccounts/contososportsstore"), +Identity = new ResourceIdentity(false) +{ +UserAssignedIdentity = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", +}, +}}, + StorageAuthentication = MediaStorageAuthentication.ManagedIdentity, + Encryption = new AccountEncryption(AccountEncryptionKeyType.CustomerKey) + { + Identity = new ResourceIdentity(false) + { + UserAssignedIdentity = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", + }, + }, + KeyDeliveryAccessControl = new MediaAccessControl + { + DefaultAction = IPAccessControlDefaultAction.Allow, + }, + PublicNetworkAccess = MediaServicesPublicNetworkAccess.Enabled, + Tags = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + MediaServicesAccountResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,7 +137,7 @@ public async Task Get_GetAMediaServicesAccountByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAMediaServicesAccountByName() + public async Task Get_GetAMediaServicesAccountByName() { // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/accounts-get-by-name.json // this example is just showing the usage of "Mediaservices_Get" operation, for the dependent resources, they will have to be created separately. @@ -110,17 +159,21 @@ public async Task Exists_GetAMediaServicesAccountByName() // invoke the operation string accountName = "contosotv"; - bool result = await collection.ExistsAsync(accountName); + MediaServicesAccountResource result = await collection.GetAsync(accountName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAMediaServicesAccountByName() + public async Task GetAll_ListAllMediaServicesAccounts() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/accounts-get-by-name.json - // this example is just showing the usage of "Mediaservices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/accounts-list-all-accounts.json + // this example is just showing the usage of "Mediaservices_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,31 +190,25 @@ public async Task GetIfExists_GetAMediaServicesAccountByName() // get the collection of this MediaServicesAccountResource MediaServicesAccountCollection collection = resourceGroupResource.GetMediaServicesAccounts(); - // invoke the operation - string accountName = "contosotv"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - MediaServicesAccountResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MediaServicesAccountResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MediaServicesAccountData resourceData = result.Data; + MediaServicesAccountData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAMediaServicesAccount() + public async Task Exists_GetAMediaServicesAccountByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/async-accounts-create.json - // this example is just showing the usage of "Mediaservices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/accounts-get-by-name.json + // this example is just showing the usage of "Mediaservices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,38 +226,18 @@ public async Task CreateOrUpdate_CreateAMediaServicesAccount() MediaServicesAccountCollection collection = resourceGroupResource.GetMediaServicesAccounts(); // invoke the operation - string accountName = "contososports"; - MediaServicesAccountData data = new MediaServicesAccountData(new AzureLocation("South Central US")) - { - StorageAccounts = -{ -new MediaServicesStorageAccount(MediaServicesStorageAccountType.Primary) -{ -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Storage/storageAccounts/teststorageaccount"), -} -}, - Tags = -{ -["key1"] = "value1", -["key2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); - MediaServicesAccountResource result = lro.Value; + string accountName = "contosotv"; + bool result = await collection.ExistsAsync(accountName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAMediaServicesAccountManagedIdentity() + public async Task GetIfExists_GetAMediaServicesAccountByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/async-accounts-create-managed-identity.json - // this example is just showing the usage of "Mediaservices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/accounts-get-by-name.json + // this example is just showing the usage of "Mediaservices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -228,55 +255,22 @@ public async Task CreateOrUpdate_CreateAMediaServicesAccountManagedIdentity() MediaServicesAccountCollection collection = resourceGroupResource.GetMediaServicesAccounts(); // invoke the operation - string accountName = "contososports"; - MediaServicesAccountData data = new MediaServicesAccountData(new AzureLocation("South Central US")) - { - Identity = new ManagedServiceIdentity("UserAssigned") - { - UserAssignedIdentities = -{ -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), -[new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id2")] = new UserAssignedIdentity(), -}, - }, - StorageAccounts = -{ -new MediaServicesStorageAccount(MediaServicesStorageAccountType.Primary) -{ -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.Storage/storageAccounts/contososportsstore"), -Identity = new ResourceIdentity(false) -{ -UserAssignedIdentity = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", -}, -} -}, - StorageAuthentication = MediaStorageAuthentication.ManagedIdentity, - Encryption = new AccountEncryption(AccountEncryptionKeyType.CustomerKey) - { - Identity = new ResourceIdentity(false) - { - UserAssignedIdentity = "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/contosorg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1", - }, - }, - KeyDeliveryAccessControl = new MediaAccessControl() - { - DefaultAction = IPAccessControlDefaultAction.Allow, - }, - PublicNetworkAccess = MediaServicesPublicNetworkAccess.Enabled, - Tags = -{ -["key1"] = "value1", -["key2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); - MediaServicesAccountResource result = lro.Value; + string accountName = "contosotv"; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + MediaServicesAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountFilterCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountFilterCollection.cs index 48b63078282e7..3b12d8b37676c 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountFilterCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountFilterCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MediaServicesAccountFilterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllAccountFilters() + public async Task CreateOrUpdate_CreateAnAccountFilter() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/accountFilters-list-all.json - // this example is just showing the usage of "AccountFilters_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/accountFilters-create.json + // this example is just showing the usage of "AccountFilters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,39 @@ public async Task GetAll_ListAllAccountFilters() // get the collection of this MediaServicesAccountFilterResource MediaServicesAccountFilterCollection collection = mediaServicesAccount.GetMediaServicesAccountFilters(); - // invoke the operation and iterate over the result - await foreach (MediaServicesAccountFilterResource item in collection.GetAllAsync()) + // invoke the operation + string filterName = "newAccountFilter"; + MediaServicesAccountFilterData data = new MediaServicesAccountFilterData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesAccountFilterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PresentationTimeRange = new PresentationTimeRange + { + StartTimestamp = 0L, + EndTimestamp = 170000000L, + PresentationWindowDuration = 9223372036854775000L, + LiveBackoffDuration = 0L, + Timescale = 10000000L, + ForceEndTimestamp = false, + }, + FirstQualityBitrate = 128000, + Tracks = {new FilterTrackSelection(new FilterTrackPropertyCondition[] +{ +new FilterTrackPropertyCondition(FilterTrackPropertyType.Type, "Audio", FilterTrackPropertyCompareOperation.Equal), +new FilterTrackPropertyCondition(FilterTrackPropertyType.Language, "en", FilterTrackPropertyCompareOperation.NotEqual), +new FilterTrackPropertyCondition(FilterTrackPropertyType.FourCC, "EC-3", FilterTrackPropertyCompareOperation.NotEqual) +}), new FilterTrackSelection(new FilterTrackPropertyCondition[] +{ +new FilterTrackPropertyCondition(FilterTrackPropertyType.Type, "Video", FilterTrackPropertyCompareOperation.Equal), +new FilterTrackPropertyCondition(FilterTrackPropertyType.Bitrate, "3000000-5000000", FilterTrackPropertyCompareOperation.Equal) +})}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, filterName, data); + MediaServicesAccountFilterResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesAccountFilterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +110,10 @@ public async Task Get_GetAnAccountFilterByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAccountFilterByName() + public async Task GetAll_ListAllAccountFilters() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/accountFilters-get-by-name.json - // this example is just showing the usage of "AccountFilters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/accountFilters-list-all.json + // this example is just showing the usage of "AccountFilters_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +131,22 @@ public async Task Exists_GetAnAccountFilterByName() // get the collection of this MediaServicesAccountFilterResource MediaServicesAccountFilterCollection collection = mediaServicesAccount.GetMediaServicesAccountFilters(); - // invoke the operation - string filterName = "accountFilterWithTrack"; - bool result = await collection.ExistsAsync(filterName); + // invoke the operation and iterate over the result + await foreach (MediaServicesAccountFilterResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesAccountFilterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAccountFilterByName() + public async Task Exists_GetAnAccountFilterByName() { // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/accountFilters-get-by-name.json // this example is just showing the usage of "AccountFilters_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +169,17 @@ public async Task GetIfExists_GetAnAccountFilterByName() // invoke the operation string filterName = "accountFilterWithTrack"; - NullableResponse response = await collection.GetIfExistsAsync(filterName); - MediaServicesAccountFilterResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(filterName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesAccountFilterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAccountFilter() + public async Task GetIfExists_GetAnAccountFilterByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/accountFilters-create.json - // this example is just showing the usage of "AccountFilters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/accountFilters-get-by-name.json + // this example is just showing the usage of "AccountFilters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,38 +198,22 @@ public async Task CreateOrUpdate_CreateAnAccountFilter() MediaServicesAccountFilterCollection collection = mediaServicesAccount.GetMediaServicesAccountFilters(); // invoke the operation - string filterName = "newAccountFilter"; - MediaServicesAccountFilterData data = new MediaServicesAccountFilterData() - { - PresentationTimeRange = new PresentationTimeRange() - { - StartTimestamp = 0L, - EndTimestamp = 170000000L, - PresentationWindowDuration = 9223372036854775000L, - LiveBackoffDuration = 0L, - Timescale = 10000000L, - ForceEndTimestamp = false, - }, - FirstQualityBitrate = 128000, - Tracks = -{ -new FilterTrackSelection(new FilterTrackPropertyCondition[] -{ -new FilterTrackPropertyCondition(FilterTrackPropertyType.Type,"Audio",FilterTrackPropertyCompareOperation.Equal),new FilterTrackPropertyCondition(FilterTrackPropertyType.Language,"en",FilterTrackPropertyCompareOperation.NotEqual),new FilterTrackPropertyCondition(FilterTrackPropertyType.FourCC,"EC-3",FilterTrackPropertyCompareOperation.NotEqual) -}),new FilterTrackSelection(new FilterTrackPropertyCondition[] -{ -new FilterTrackPropertyCondition(FilterTrackPropertyType.Type,"Video",FilterTrackPropertyCompareOperation.Equal),new FilterTrackPropertyCondition(FilterTrackPropertyType.Bitrate,"3000000-5000000",FilterTrackPropertyCompareOperation.Equal) -}) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, filterName, data); - MediaServicesAccountFilterResource result = lro.Value; + string filterName = "accountFilterWithTrack"; + NullableResponse response = await collection.GetIfExistsAsync(filterName); + MediaServicesAccountFilterResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesAccountFilterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesAccountFilterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountFilterResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountFilterResource.cs index b988fae7b9f36..65eb7937a89ec 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountFilterResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountFilterResource.cs @@ -96,9 +96,9 @@ public async Task Update_UpdateAnAccountFilter() MediaServicesAccountFilterResource mediaServicesAccountFilter = client.GetMediaServicesAccountFilterResource(mediaServicesAccountFilterResourceId); // invoke the operation - MediaServicesAccountFilterData data = new MediaServicesAccountFilterData() + MediaServicesAccountFilterData data = new MediaServicesAccountFilterData { - PresentationTimeRange = new PresentationTimeRange() + PresentationTimeRange = new PresentationTimeRange { StartTimestamp = 10L, EndTimestamp = 170000000L, diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountResource.cs index 7d55abb9323fd..93e6dfdf9a74e 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesAccountResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Media.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Media.Samples @@ -94,11 +93,11 @@ public async Task Update_UpdateAMediaServicesAccounts() MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); // invoke the operation - MediaServicesAccountPatch patch = new MediaServicesAccountPatch() + MediaServicesAccountPatch patch = new MediaServicesAccountPatch { Tags = { -["key1"] = "value3", +["key1"] = "value3" }, }; ArmOperation lro = await mediaServicesAccount.UpdateAsync(WaitUntil.Completed, patch); @@ -132,7 +131,7 @@ public async Task SyncStorageKeys_SynchronizesStorageAccountKeys() MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); // invoke the operation - SyncStorageKeysContent content = new SyncStorageKeysContent() + SyncStorageKeysContent content = new SyncStorageKeysContent { Id = "contososportsstore", }; @@ -162,7 +161,7 @@ public async Task GetEdgePolicies_ListTheMediaEdgePolicies() MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); // invoke the operation - EdgePoliciesRequestContent content = new EdgePoliciesRequestContent() + EdgePoliciesRequestContent content = new EdgePoliciesRequestContent { DeviceId = "contosiothubhost_contosoiotdevice", }; @@ -170,36 +169,5 @@ public async Task GetEdgePolicies_ListTheMediaEdgePolicies() Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMediaServicesAccounts_ListAllMediaServicesAccounts() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/accounts-subscription-list-all-accounts.json - // this example is just showing the usage of "Mediaservices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MediaServicesAccountResource item in subscriptionResource.GetMediaServicesAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateEndpointConnectionCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateEndpointConnectionCollection.cs index f050725caf21f..26822470b9cb1 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateEndpointConnectionCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MediaServicesPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetAllPrivateEndpointConnections() + public async Task CreateOrUpdate_UpdatePrivateEndpointConnection() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-list.json - // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-put.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_GetAllPrivateEndpointConnections() // get the collection of this MediaServicesPrivateEndpointConnectionResource MediaServicesPrivateEndpointConnectionCollection collection = mediaServicesAccount.GetMediaServicesPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (MediaServicesPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string name = "connectionName1"; + MediaServicesPrivateEndpointConnectionData data = new MediaServicesPrivateEndpointConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesPrivateEndpointConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ConnectionState = new MediaPrivateLinkServiceConnectionState + { + Status = MediaPrivateEndpointServiceConnectionStatus.Approved, + Description = "Test description.", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MediaServicesPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateEndpointConnection() + public async Task GetAll_GetAllPrivateEndpointConnections() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-get-by-name.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-list.json + // this example is just showing the usage of "PrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_GetPrivateEndpointConnection() // get the collection of this MediaServicesPrivateEndpointConnectionResource MediaServicesPrivateEndpointConnectionCollection collection = mediaServicesAccount.GetMediaServicesPrivateEndpointConnections(); - // invoke the operation - string name = "connectionName1"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (MediaServicesPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateEndpointConnection() + public async Task Exists_GetPrivateEndpointConnection() { // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-get-by-name.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_GetPrivateEndpointConnection() // invoke the operation string name = "connectionName1"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MediaServicesPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdatePrivateEndpointConnection() + public async Task GetIfExists_GetPrivateEndpointConnection() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-put.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-get-by-name.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +184,21 @@ public async Task CreateOrUpdate_UpdatePrivateEndpointConnection() // invoke the operation string name = "connectionName1"; - MediaServicesPrivateEndpointConnectionData data = new MediaServicesPrivateEndpointConnectionData() - { - ConnectionState = new MediaPrivateLinkServiceConnectionState() - { - Status = MediaPrivateEndpointServiceConnectionStatus.Approved, - Description = "Test description.", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MediaServicesPrivateEndpointConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(name); + MediaServicesPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateEndpointConnectionResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateEndpointConnectionResource.cs index 47969eba78ec6..7751a8b41f4b7 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateEndpointConnectionResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatePrivateEndpointConnection() + public async Task Delete_DeletePrivateEndpointConnection() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-put.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-delete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_UpdatePrivateEndpointConnection() MediaServicesPrivateEndpointConnectionResource mediaServicesPrivateEndpointConnection = client.GetMediaServicesPrivateEndpointConnectionResource(mediaServicesPrivateEndpointConnectionResourceId); // invoke the operation - MediaServicesPrivateEndpointConnectionData data = new MediaServicesPrivateEndpointConnectionData() - { - ConnectionState = new MediaPrivateLinkServiceConnectionState() - { - Status = MediaPrivateEndpointServiceConnectionStatus.Approved, - Description = "Test description.", - }, - }; - ArmOperation lro = await mediaServicesPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - MediaServicesPrivateEndpointConnectionResource result = lro.Value; + await mediaServicesPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateEndpointConnection() + public async Task Update_UpdatePrivateEndpointConnection() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-delete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-endpoint-connection-put.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_DeletePrivateEndpointConnection() MediaServicesPrivateEndpointConnectionResource mediaServicesPrivateEndpointConnection = client.GetMediaServicesPrivateEndpointConnectionResource(mediaServicesPrivateEndpointConnectionResourceId); // invoke the operation - await mediaServicesPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + MediaServicesPrivateEndpointConnectionData data = new MediaServicesPrivateEndpointConnectionData + { + ConnectionState = new MediaPrivateLinkServiceConnectionState + { + Status = MediaPrivateEndpointServiceConnectionStatus.Approved, + Description = "Test description.", + }, + }; + ArmOperation lro = await mediaServicesPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + MediaServicesPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateLinkResourceCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateLinkResourceCollection.cs index aab5081eb4d7b..3641fe78cd640 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateLinkResourceCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaServicesPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MediaServicesPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetListOfAllGroupIDs() + public async Task Get_GetDetailsOfAGroupID() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-link-resources-list.json - // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-link-resources-get-by-name.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetListOfAllGroupIDs() // get the collection of this MediaServicesPrivateLinkResource MediaServicesPrivateLinkResourceCollection collection = mediaServicesAccount.GetMediaServicesPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (MediaServicesPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string name = "keydelivery"; + MediaServicesPrivateLinkResource result = await collection.GetAsync(name); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDetailsOfAGroupID() + public async Task GetAll_GetListOfAllGroupIDs() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-link-resources-get-by-name.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/private-link-resources-list.json + // this example is just showing the usage of "PrivateLinkResources_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetDetailsOfAGroupID() // get the collection of this MediaServicesPrivateLinkResource MediaServicesPrivateLinkResourceCollection collection = mediaServicesAccount.GetMediaServicesPrivateLinkResources(); - // invoke the operation - string name = "keydelivery"; - MediaServicesPrivateLinkResource result = await collection.GetAsync(name); + // invoke the operation and iterate over the result + await foreach (MediaServicesPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaServicesPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaTransformCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaTransformCollection.cs index 99600123126ad..bd70949d36e67 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaTransformCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaTransformCollection.cs @@ -16,6 +16,80 @@ namespace Azure.ResourceManager.Media.Samples { public partial class Sample_MediaTransformCollection { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CreateOrUpdate_CreateOrUpdateATransform() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-create.json + // this example is just showing the usage of "Transforms_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MediaServicesAccountResource created on azure + // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "contosoresources"; + string accountName = "contosomedia"; + ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); + + // get the collection of this MediaTransformResource + MediaTransformCollection collection = mediaServicesAccount.GetMediaTransforms(); + + // invoke the operation + string transformName = "createdTransform"; + MediaTransformData data = new MediaTransformData + { + Description = "Example Transform to illustrate create and update.", + Outputs = { new MediaTransformOutput(new BuiltInStandardEncoderPreset(EncoderNamedPreset.AdaptiveStreaming)) }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, transformName, data); + MediaTransformResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaTransformData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetATransformByName() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-get-by-name.json + // this example is just showing the usage of "Transforms_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MediaServicesAccountResource created on azure + // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "contosoresources"; + string accountName = "contosomedia"; + ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); + + // get the collection of this MediaTransformResource + MediaTransformCollection collection = mediaServicesAccount.GetMediaTransforms(); + + // invoke the operation + string transformName = "sampleTransform"; + MediaTransformResource result = await collection.GetAsync(transformName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaTransformData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListsTheTransforms() @@ -166,40 +240,6 @@ public async Task GetAll_ListsTheTransformsFilterByName() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetATransformByName() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-get-by-name.json - // this example is just showing the usage of "Transforms_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MediaServicesAccountResource created on azure - // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "contosoresources"; - string accountName = "contosomedia"; - ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); - - // get the collection of this MediaTransformResource - MediaTransformCollection collection = mediaServicesAccount.GetMediaTransforms(); - - // invoke the operation - string transformName = "sampleTransform"; - MediaTransformResource result = await collection.GetAsync(transformName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaTransformData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetATransformByName() @@ -271,48 +311,5 @@ public async Task GetIfExists_GetATransformByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateATransform() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Encoding/stable/2022-07-01/examples/transforms-create.json - // this example is just showing the usage of "Transforms_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MediaServicesAccountResource created on azure - // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "contosoresources"; - string accountName = "contosomedia"; - ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); - - // get the collection of this MediaTransformResource - MediaTransformCollection collection = mediaServicesAccount.GetMediaTransforms(); - - // invoke the operation - string transformName = "createdTransform"; - MediaTransformData data = new MediaTransformData() - { - Description = "Example Transform to illustrate create and update.", - Outputs = -{ -new MediaTransformOutput(new BuiltInStandardEncoderPreset(EncoderNamedPreset.AdaptiveStreaming)) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, transformName, data); - MediaTransformResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MediaTransformData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaTransformResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaTransformResource.cs index e65c6a09620b3..23dac71650619 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaTransformResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_MediaTransformResource.cs @@ -96,16 +96,13 @@ public async Task Update_UpdateATransform() MediaTransformResource mediaTransform = client.GetMediaTransformResource(mediaTransformResourceId); // invoke the operation - MediaTransformData data = new MediaTransformData() + MediaTransformData data = new MediaTransformData { Description = "Example transform to illustrate update.", - Outputs = -{ -new MediaTransformOutput(new BuiltInStandardEncoderPreset(EncoderNamedPreset.H264MultipleBitrate720P)) + Outputs = {new MediaTransformOutput(new BuiltInStandardEncoderPreset(EncoderNamedPreset.H264MultipleBitrate720P)) { RelativePriority = MediaJobPriority.High, -} -}, +}}, }; MediaTransformResource result = await mediaTransform.UpdateAsync(data); diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingEndpointCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingEndpointCollection.cs index f2cd027994f59..220a836f6f815 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingEndpointCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingEndpointCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_StreamingEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllStreamingEndpoints() + public async Task CreateOrUpdate_CreateAStreamingEndpoint() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-all.json - // this example is just showing the usage of "StreamingEndpoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-create.json + // this example is just showing the usage of "StreamingEndpoints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,47 @@ public async Task GetAll_ListAllStreamingEndpoints() // get the collection of this StreamingEndpointResource StreamingEndpointCollection collection = mediaServicesAccount.GetStreamingEndpoints(); - // invoke the operation and iterate over the result - await foreach (StreamingEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string streamingEndpointName = "myStreamingEndpoint1"; + StreamingEndpointData data = new StreamingEndpointData(new AzureLocation("West US")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "test event 1", + ScaleUnits = 1, + AvailabilitySetName = "availableset", + AccessControl = new StreamingEndpointAccessControl + { + AkamaiSignatureHeaderAuthenticationKeyList = {new AkamaiSignatureHeaderAuthenticationKey +{ +Identifier = "id1", +Base64Key = "dGVzdGlkMQ==", +ExpireOn = DateTimeOffset.Parse("2029-12-31T16:00:00-08:00"), +}, new AkamaiSignatureHeaderAuthenticationKey +{ +Identifier = "id2", +Base64Key = "dGVzdGlkMQ==", +ExpireOn = DateTimeOffset.Parse("2030-12-31T16:00:00-08:00"), +}}, + AllowedIPs = {new IPRange +{ +Name = "AllowedIp", +Address = IPAddress.Parse("192.168.1.1"), +}}, + }, + IsCdnEnabled = false, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingEndpointName, data); + StreamingEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +119,10 @@ public async Task Get_GetAStreamingEndpointByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAStreamingEndpointByName() + public async Task GetAll_ListAllStreamingEndpoints() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-by-name.json - // this example is just showing the usage of "StreamingEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-all.json + // this example is just showing the usage of "StreamingEndpoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,16 +140,22 @@ public async Task Exists_GetAStreamingEndpointByName() // get the collection of this StreamingEndpointResource StreamingEndpointCollection collection = mediaServicesAccount.GetStreamingEndpoints(); - // invoke the operation - string streamingEndpointName = "myStreamingEndpoint1"; - bool result = await collection.ExistsAsync(streamingEndpointName); + // invoke the operation and iterate over the result + await foreach (StreamingEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAStreamingEndpointByName() + public async Task Exists_GetAStreamingEndpointByName() { // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-by-name.json // this example is just showing the usage of "StreamingEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -142,29 +178,17 @@ public async Task GetIfExists_GetAStreamingEndpointByName() // invoke the operation string streamingEndpointName = "myStreamingEndpoint1"; - NullableResponse response = await collection.GetIfExistsAsync(streamingEndpointName); - StreamingEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(streamingEndpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAStreamingEndpoint() + public async Task GetIfExists_GetAStreamingEndpointByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-create.json - // this example is just showing the usage of "StreamingEndpoints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-list-by-name.json + // this example is just showing the usage of "StreamingEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,51 +208,21 @@ public async Task CreateOrUpdate_CreateAStreamingEndpoint() // invoke the operation string streamingEndpointName = "myStreamingEndpoint1"; - StreamingEndpointData data = new StreamingEndpointData(new AzureLocation("West US")) - { - Description = "test event 1", - ScaleUnits = 1, - AvailabilitySetName = "availableset", - AccessControl = new StreamingEndpointAccessControl() - { - AkamaiSignatureHeaderAuthenticationKeyList = -{ -new AkamaiSignatureHeaderAuthenticationKey() -{ -Identifier = "id1", -Base64Key = "dGVzdGlkMQ==", -ExpireOn = DateTimeOffset.Parse("2029-12-31T16:00:00-08:00"), -},new AkamaiSignatureHeaderAuthenticationKey() -{ -Identifier = "id2", -Base64Key = "dGVzdGlkMQ==", -ExpireOn = DateTimeOffset.Parse("2030-12-31T16:00:00-08:00"), -} -}, - AllowedIPs = -{ -new IPRange() -{ -Name = "AllowedIp", -Address = IPAddress.Parse("192.168.1.1"), -} -}, - }, - IsCdnEnabled = false, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingEndpointName, data); - StreamingEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(streamingEndpointName); + StreamingEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingEndpointResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingEndpointResource.cs index 4b6877c58c016..b369205555bb4 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingEndpointResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingEndpointResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAStreamingEndpointByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAStreamingEndpoint() + public async Task Delete_DeleteAStreamingEndpoint() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-update.json - // this example is just showing the usage of "StreamingEndpoints_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-delete.json + // this example is just showing the usage of "StreamingEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,33 +69,17 @@ public async Task Update_UpdateAStreamingEndpoint() StreamingEndpointResource streamingEndpoint = client.GetStreamingEndpointResource(streamingEndpointResourceId); // invoke the operation - StreamingEndpointData data = new StreamingEndpointData(new AzureLocation("West US")) - { - Description = "test event 2", - ScaleUnits = 5, - AvailabilitySetName = "availableset", - Tags = -{ -["tag3"] = "value3", -["tag5"] = "value5", -}, - }; - ArmOperation lro = await streamingEndpoint.UpdateAsync(WaitUntil.Completed, data); - StreamingEndpointResource result = lro.Value; + await streamingEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAStreamingEndpoint() + public async Task Update_UpdateAStreamingEndpoint() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-delete.json - // this example is just showing the usage of "StreamingEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Streaming/stable/2022-08-01/examples/streamingendpoint-update.json + // this example is just showing the usage of "StreamingEndpoints_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,9 +96,25 @@ public async Task Delete_DeleteAStreamingEndpoint() StreamingEndpointResource streamingEndpoint = client.GetStreamingEndpointResource(streamingEndpointResourceId); // invoke the operation - await streamingEndpoint.DeleteAsync(WaitUntil.Completed); + StreamingEndpointData data = new StreamingEndpointData(new AzureLocation("West US")) + { + Description = "test event 2", + ScaleUnits = 5, + AvailabilitySetName = "availableset", + Tags = +{ +["tag3"] = "value3", +["tag5"] = "value5" +}, + }; + ArmOperation lro = await streamingEndpoint.UpdateAsync(WaitUntil.Completed, data); + StreamingEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -223,7 +223,7 @@ public async Task Scale_ScaleAStreamingEndpoint() StreamingEndpointResource streamingEndpoint = client.GetStreamingEndpointResource(streamingEndpointResourceId); // invoke the operation - StreamingEntityScaleUnit streamingEntityScaleUnit = new StreamingEntityScaleUnit() + StreamingEntityScaleUnit streamingEntityScaleUnit = new StreamingEntityScaleUnit { ScaleUnit = 5, }; diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingLocatorCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingLocatorCollection.cs index 43dfc404afce3..162c8e550f4f8 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingLocatorCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingLocatorCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_StreamingLocatorCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsStreamingLocators() + public async Task CreateOrUpdate_CreatesAStreamingLocatorWithClearStreaming() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-list.json - // this example is just showing the usage of "StreamingLocators_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-create-clear.json + // this example is just showing the usage of "StreamingLocators_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,29 @@ public async Task GetAll_ListsStreamingLocators() // get the collection of this StreamingLocatorResource StreamingLocatorCollection collection = mediaServicesAccount.GetStreamingLocators(); - // invoke the operation and iterate over the result - await foreach (StreamingLocatorResource item in collection.GetAllAsync()) + // invoke the operation + string streamingLocatorName = "UserCreatedClearStreamingLocator"; + StreamingLocatorData data = new StreamingLocatorData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingLocatorData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AssetName = "ClimbingMountRainier", + StreamingPolicyName = "clearStreamingPolicy", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingLocatorName, data); + StreamingLocatorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingLocatorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAStreamingLocatorByName() + public async Task CreateOrUpdate_CreatesAStreamingLocatorWithSecureStreaming() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-get-by-name.json - // this example is just showing the usage of "StreamingLocators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-create-secure.json + // this example is just showing the usage of "StreamingLocators_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,8 +80,16 @@ public async Task Get_GetAStreamingLocatorByName() StreamingLocatorCollection collection = mediaServicesAccount.GetStreamingLocators(); // invoke the operation - string streamingLocatorName = "clearStreamingLocator"; - StreamingLocatorResource result = await collection.GetAsync(streamingLocatorName); + string streamingLocatorName = "UserCreatedSecureStreamingLocator"; + StreamingLocatorData data = new StreamingLocatorData + { + AssetName = "ClimbingMountRainier", + StartOn = DateTimeOffset.Parse("2018-03-01T00:00:00Z"), + EndOn = DateTimeOffset.Parse("2028-12-31T23:59:59.9999999Z"), + StreamingPolicyName = "UserCreatedSecureStreamingPolicy", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingLocatorName, data); + StreamingLocatorResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +100,10 @@ public async Task Get_GetAStreamingLocatorByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAStreamingLocatorByName() + public async Task CreateOrUpdate_CreatesAStreamingLocatorWithUserDefinedContentKeys() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-get-by-name.json - // this example is just showing the usage of "StreamingLocators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-create-secure-userDefinedContentKeys.json + // this example is just showing the usage of "StreamingLocators_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,15 +122,39 @@ public async Task Exists_GetAStreamingLocatorByName() StreamingLocatorCollection collection = mediaServicesAccount.GetStreamingLocators(); // invoke the operation - string streamingLocatorName = "clearStreamingLocator"; - bool result = await collection.ExistsAsync(streamingLocatorName); + string streamingLocatorName = "UserCreatedSecureStreamingLocatorWithUserDefinedContentKeys"; + StreamingLocatorData data = new StreamingLocatorData + { + AssetName = "ClimbingMountRainier", + StreamingLocatorId = Guid.Parse("90000000-0000-0000-0000-00000000000A"), + StreamingPolicyName = "secureStreamingPolicy", + ContentKeys = {new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000001")) +{ +LabelReferenceInStreamingPolicy = "aesDefaultKey", +Value = "1UqLohAfWsEGkULYxHjYZg==", +}, new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000004")) +{ +LabelReferenceInStreamingPolicy = "cencDefaultKey", +Value = "4UqLohAfWsEGkULYxHjYZg==", +}, new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000007")) +{ +LabelReferenceInStreamingPolicy = "cbcsDefaultKey", +Value = "7UqLohAfWsEGkULYxHjYZg==", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingLocatorName, data); + StreamingLocatorResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingLocatorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAStreamingLocatorByName() + public async Task Get_GetAStreamingLocatorByName() { // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-get-by-name.json // this example is just showing the usage of "StreamingLocators_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +177,21 @@ public async Task GetIfExists_GetAStreamingLocatorByName() // invoke the operation string streamingLocatorName = "clearStreamingLocator"; - NullableResponse response = await collection.GetIfExistsAsync(streamingLocatorName); - StreamingLocatorResource result = response.HasValue ? response.Value : null; + StreamingLocatorResource result = await collection.GetAsync(streamingLocatorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingLocatorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingLocatorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAStreamingLocatorWithClearStreaming() + public async Task GetAll_ListsStreamingLocators() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-create-clear.json - // this example is just showing the usage of "StreamingLocators_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-list.json + // this example is just showing the usage of "StreamingLocators_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,29 +209,25 @@ public async Task CreateOrUpdate_CreatesAStreamingLocatorWithClearStreaming() // get the collection of this StreamingLocatorResource StreamingLocatorCollection collection = mediaServicesAccount.GetStreamingLocators(); - // invoke the operation - string streamingLocatorName = "UserCreatedClearStreamingLocator"; - StreamingLocatorData data = new StreamingLocatorData() + // invoke the operation and iterate over the result + await foreach (StreamingLocatorResource item in collection.GetAllAsync()) { - AssetName = "ClimbingMountRainier", - StreamingPolicyName = "clearStreamingPolicy", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingLocatorName, data); - StreamingLocatorResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingLocatorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingLocatorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAStreamingLocatorWithSecureStreaming() + public async Task Exists_GetAStreamingLocatorByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-create-secure.json - // this example is just showing the usage of "StreamingLocators_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-get-by-name.json + // this example is just showing the usage of "StreamingLocators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -222,30 +246,18 @@ public async Task CreateOrUpdate_CreatesAStreamingLocatorWithSecureStreaming() StreamingLocatorCollection collection = mediaServicesAccount.GetStreamingLocators(); // invoke the operation - string streamingLocatorName = "UserCreatedSecureStreamingLocator"; - StreamingLocatorData data = new StreamingLocatorData() - { - AssetName = "ClimbingMountRainier", - StartOn = DateTimeOffset.Parse("2018-03-01T00:00:00Z"), - EndOn = DateTimeOffset.Parse("2028-12-31T23:59:59.9999999Z"), - StreamingPolicyName = "UserCreatedSecureStreamingPolicy", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingLocatorName, data); - StreamingLocatorResource result = lro.Value; + string streamingLocatorName = "clearStreamingLocator"; + bool result = await collection.ExistsAsync(streamingLocatorName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingLocatorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAStreamingLocatorWithUserDefinedContentKeys() + public async Task GetIfExists_GetAStreamingLocatorByName() { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-create-secure-userDefinedContentKeys.json - // this example is just showing the usage of "StreamingLocators_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-get-by-name.json + // this example is just showing the usage of "StreamingLocators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -264,37 +276,22 @@ public async Task CreateOrUpdate_CreatesAStreamingLocatorWithUserDefinedContentK StreamingLocatorCollection collection = mediaServicesAccount.GetStreamingLocators(); // invoke the operation - string streamingLocatorName = "UserCreatedSecureStreamingLocatorWithUserDefinedContentKeys"; - StreamingLocatorData data = new StreamingLocatorData() - { - AssetName = "ClimbingMountRainier", - StreamingLocatorId = Guid.Parse("90000000-0000-0000-0000-00000000000A"), - StreamingPolicyName = "secureStreamingPolicy", - ContentKeys = -{ -new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000001")) -{ -LabelReferenceInStreamingPolicy = "aesDefaultKey", -Value = "1UqLohAfWsEGkULYxHjYZg==", -},new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000004")) -{ -LabelReferenceInStreamingPolicy = "cencDefaultKey", -Value = "4UqLohAfWsEGkULYxHjYZg==", -},new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000007")) -{ -LabelReferenceInStreamingPolicy = "cbcsDefaultKey", -Value = "7UqLohAfWsEGkULYxHjYZg==", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, streamingLocatorName, data); - StreamingLocatorResource result = lro.Value; + string streamingLocatorName = "clearStreamingLocator"; + NullableResponse response = await collection.GetIfExistsAsync(streamingLocatorName); + StreamingLocatorResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingLocatorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingLocatorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingLocatorResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingLocatorResource.cs index c2e9ae0bf19b9..0e5127cf7a578 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingLocatorResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingLocatorResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetAStreamingLocatorByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAStreamingLocator() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-delete.json + // this example is just showing the usage of "StreamingLocators_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this StreamingLocatorResource created on azure + // for more information of creating StreamingLocatorResource, please refer to the document of StreamingLocatorResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "contosorg"; + string accountName = "contosomedia"; + string streamingLocatorName = "clearStreamingLocator"; + ResourceIdentifier streamingLocatorResourceId = StreamingLocatorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, streamingLocatorName); + StreamingLocatorResource streamingLocator = client.GetStreamingLocatorResource(streamingLocatorResourceId); + + // invoke the operation + await streamingLocator.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreatesAStreamingLocatorWithClearStreaming() @@ -69,7 +96,7 @@ public async Task Update_CreatesAStreamingLocatorWithClearStreaming() StreamingLocatorResource streamingLocator = client.GetStreamingLocatorResource(streamingLocatorResourceId); // invoke the operation - StreamingLocatorData data = new StreamingLocatorData() + StreamingLocatorData data = new StreamingLocatorData { AssetName = "ClimbingMountRainier", StreamingPolicyName = "clearStreamingPolicy", @@ -106,7 +133,7 @@ public async Task Update_CreatesAStreamingLocatorWithSecureStreaming() StreamingLocatorResource streamingLocator = client.GetStreamingLocatorResource(streamingLocatorResourceId); // invoke the operation - StreamingLocatorData data = new StreamingLocatorData() + StreamingLocatorData data = new StreamingLocatorData { AssetName = "ClimbingMountRainier", StartOn = DateTimeOffset.Parse("2018-03-01T00:00:00Z"), @@ -145,27 +172,24 @@ public async Task Update_CreatesAStreamingLocatorWithUserDefinedContentKeys() StreamingLocatorResource streamingLocator = client.GetStreamingLocatorResource(streamingLocatorResourceId); // invoke the operation - StreamingLocatorData data = new StreamingLocatorData() + StreamingLocatorData data = new StreamingLocatorData { AssetName = "ClimbingMountRainier", StreamingLocatorId = Guid.Parse("90000000-0000-0000-0000-00000000000A"), StreamingPolicyName = "secureStreamingPolicy", - ContentKeys = -{ -new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000001")) + ContentKeys = {new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000001")) { LabelReferenceInStreamingPolicy = "aesDefaultKey", Value = "1UqLohAfWsEGkULYxHjYZg==", -},new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000004")) +}, new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000004")) { LabelReferenceInStreamingPolicy = "cencDefaultKey", Value = "4UqLohAfWsEGkULYxHjYZg==", -},new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000007")) +}, new StreamingLocatorContentKey(Guid.Parse("60000000-0000-0000-0000-000000000007")) { LabelReferenceInStreamingPolicy = "cbcsDefaultKey", Value = "7UqLohAfWsEGkULYxHjYZg==", -} -}, +}}, }; ArmOperation lro = await streamingLocator.UpdateAsync(WaitUntil.Completed, data); StreamingLocatorResource result = lro.Value; @@ -177,33 +201,6 @@ public async Task Update_CreatesAStreamingLocatorWithUserDefinedContentKeys() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAStreamingLocator() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-locators-delete.json - // this example is just showing the usage of "StreamingLocators_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this StreamingLocatorResource created on azure - // for more information of creating StreamingLocatorResource, please refer to the document of StreamingLocatorResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "contosorg"; - string accountName = "contosomedia"; - string streamingLocatorName = "clearStreamingLocator"; - ResourceIdentifier streamingLocatorResourceId = StreamingLocatorResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, streamingLocatorName); - StreamingLocatorResource streamingLocator = client.GetStreamingLocatorResource(streamingLocatorResourceId); - - // invoke the operation - await streamingLocator.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetContentKeys_ListContentKeys() diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingPolicyCollection.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingPolicyCollection.cs index cf513926e57d7..82412f8cec52d 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingPolicyCollection.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingPolicyCollection.cs @@ -16,148 +16,6 @@ namespace Azure.ResourceManager.Media.Samples { public partial class Sample_StreamingPolicyCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsStreamingPolicies() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-policies-list.json - // this example is just showing the usage of "StreamingPolicies_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MediaServicesAccountResource created on azure - // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "contosorg"; - string accountName = "contosomedia"; - ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); - - // get the collection of this StreamingPolicyResource - StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies(); - - // invoke the operation and iterate over the result - await foreach (StreamingPolicyResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAStreamingPolicyByName() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-policy-get-by-name.json - // this example is just showing the usage of "StreamingPolicies_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MediaServicesAccountResource created on azure - // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "contosorg"; - string accountName = "contosomedia"; - ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); - - // get the collection of this StreamingPolicyResource - StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies(); - - // invoke the operation - string streamingPolicyName = "clearStreamingPolicy"; - StreamingPolicyResource result = await collection.GetAsync(streamingPolicyName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAStreamingPolicyByName() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-policy-get-by-name.json - // this example is just showing the usage of "StreamingPolicies_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MediaServicesAccountResource created on azure - // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "contosorg"; - string accountName = "contosomedia"; - ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); - - // get the collection of this StreamingPolicyResource - StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies(); - - // invoke the operation - string streamingPolicyName = "clearStreamingPolicy"; - bool result = await collection.ExistsAsync(streamingPolicyName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAStreamingPolicyByName() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-policy-get-by-name.json - // this example is just showing the usage of "StreamingPolicies_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MediaServicesAccountResource created on azure - // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "contosorg"; - string accountName = "contosomedia"; - ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); - - // get the collection of this StreamingPolicyResource - StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies(); - - // invoke the operation - string streamingPolicyName = "clearStreamingPolicy"; - NullableResponse response = await collection.GetIfExistsAsync(streamingPolicyName); - StreamingPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - StreamingPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreatesAStreamingPolicyWithClearKeyEncryptionInCommonEncryptionCbcs() @@ -183,15 +41,15 @@ public async Task CreateOrUpdate_CreatesAStreamingPolicyWithClearKeyEncryptionIn // invoke the operation string streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly"; - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithMultipleOptions", - CommonEncryptionCbcs = new CommonEncryptionCbcs() + CommonEncryptionCbcs = new CommonEncryptionCbcs { EnabledProtocols = new MediaEnabledProtocols(false, false, true, false), - ContentKeys = new StreamingPolicyContentKeys() + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cbcsDefaultKey", }, @@ -234,28 +92,22 @@ public async Task CreateOrUpdate_CreatesAStreamingPolicyWithClearKeyEncryptionIn // invoke the operation string streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly"; - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithPlayReadyOptionAndOpenRestriction", - CommonEncryptionCenc = new CommonEncryptionCenc() + CommonEncryptionCenc = new CommonEncryptionCenc { EnabledProtocols = new MediaEnabledProtocols(false, true, false, true), - ClearTracks = -{ -new MediaTrackSelection() -{ -TrackSelections = + ClearTracks = {new MediaTrackSelection { -new TrackPropertyCondition(TrackPropertyType.FourCC,TrackPropertyCompareOperation.Equal) +TrackSelections = {new TrackPropertyCondition(TrackPropertyType.FourCC, TrackPropertyCompareOperation.Equal) { Value = "hev1", -} -}, -} -}, - ContentKeys = new StreamingPolicyContentKeys() +}}, +}}, + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cencDefaultKey", }, @@ -298,7 +150,7 @@ public async Task CreateOrUpdate_CreatesAStreamingPolicyWithClearStreaming() // invoke the operation string streamingPolicyName = "clearStreamingPolicy"; - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { NoEncryptionEnabledProtocols = new MediaEnabledProtocols(true, true, true, true), }; @@ -337,20 +189,20 @@ public async Task CreateOrUpdate_CreatesAStreamingPolicyWithCommonEncryptionCbcs // invoke the operation string streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCbcsOnly"; - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithMultipleOptions", - CommonEncryptionCbcs = new CommonEncryptionCbcs() + CommonEncryptionCbcs = new CommonEncryptionCbcs { EnabledProtocols = new MediaEnabledProtocols(false, false, true, false), - ContentKeys = new StreamingPolicyContentKeys() + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cbcsDefaultKey", }, }, - Drm = new CbcsDrmConfiguration() + Drm = new CbcsDrmConfiguration { FairPlay = new StreamingPolicyFairPlayConfiguration(true) { @@ -394,35 +246,29 @@ public async Task CreateOrUpdate_CreatesAStreamingPolicyWithCommonEncryptionCenc // invoke the operation string streamingPolicyName = "UserCreatedSecureStreamingPolicyWithCommonEncryptionCencOnly"; - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithPlayReadyOptionAndOpenRestriction", - CommonEncryptionCenc = new CommonEncryptionCenc() + CommonEncryptionCenc = new CommonEncryptionCenc { EnabledProtocols = new MediaEnabledProtocols(false, true, false, true), - ClearTracks = -{ -new MediaTrackSelection() -{ -TrackSelections = + ClearTracks = {new MediaTrackSelection { -new TrackPropertyCondition(TrackPropertyType.FourCC,TrackPropertyCompareOperation.Equal) +TrackSelections = {new TrackPropertyCondition(TrackPropertyType.FourCC, TrackPropertyCompareOperation.Equal) { Value = "hev1", -} -}, -} -}, - ContentKeys = new StreamingPolicyContentKeys() +}}, +}}, + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cencDefaultKey", }, }, - Drm = new CencDrmConfiguration() + Drm = new CencDrmConfiguration { - PlayReady = new StreamingPolicyPlayReadyConfiguration() + PlayReady = new StreamingPolicyPlayReadyConfiguration { CustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}", PlayReadyCustomAttributes = "PlayReady CustomAttributes", @@ -466,15 +312,15 @@ public async Task CreateOrUpdate_CreatesAStreamingPolicyWithEnvelopeEncryptionOn // invoke the operation string streamingPolicyName = "UserCreatedSecureStreamingPolicyWithEnvelopeEncryptionOnly"; - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithClearKeyOptionAndTokenRestriction", - EnvelopeEncryption = new EnvelopeEncryption() + EnvelopeEncryption = new EnvelopeEncryption { EnabledProtocols = new MediaEnabledProtocols(false, true, true, true), - ContentKeys = new StreamingPolicyContentKeys() + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "aesDefaultKey", }, @@ -517,47 +363,41 @@ public async Task CreateOrUpdate_CreatesAStreamingPolicyWithSecureStreaming() // invoke the operation string streamingPolicyName = "UserCreatedSecureStreamingPolicy"; - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithMultipleOptions", - EnvelopeEncryption = new EnvelopeEncryption() + EnvelopeEncryption = new EnvelopeEncryption { EnabledProtocols = new MediaEnabledProtocols(false, true, true, true), - ContentKeys = new StreamingPolicyContentKeys() + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "aesDefaultKey", }, }, CustomKeyAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}", }, - CommonEncryptionCenc = new CommonEncryptionCenc() + CommonEncryptionCenc = new CommonEncryptionCenc { EnabledProtocols = new MediaEnabledProtocols(false, true, false, true), - ClearTracks = -{ -new MediaTrackSelection() + ClearTracks = {new MediaTrackSelection { -TrackSelections = -{ -new TrackPropertyCondition(TrackPropertyType.FourCC,TrackPropertyCompareOperation.Equal) +TrackSelections = {new TrackPropertyCondition(TrackPropertyType.FourCC, TrackPropertyCompareOperation.Equal) { Value = "hev1", -} -}, -} -}, - ContentKeys = new StreamingPolicyContentKeys() +}}, +}}, + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cencDefaultKey", }, }, - Drm = new CencDrmConfiguration() + Drm = new CencDrmConfiguration { - PlayReady = new StreamingPolicyPlayReadyConfiguration() + PlayReady = new StreamingPolicyPlayReadyConfiguration { CustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}", PlayReadyCustomAttributes = "PlayReady CustomAttributes", @@ -565,17 +405,17 @@ public async Task CreateOrUpdate_CreatesAStreamingPolicyWithSecureStreaming() WidevineCustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId", }, }, - CommonEncryptionCbcs = new CommonEncryptionCbcs() + CommonEncryptionCbcs = new CommonEncryptionCbcs { EnabledProtocols = new MediaEnabledProtocols(false, false, true, false), - ContentKeys = new StreamingPolicyContentKeys() + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cbcsDefaultKey", }, }, - Drm = new CbcsDrmConfiguration() + Drm = new CbcsDrmConfiguration { FairPlay = new StreamingPolicyFairPlayConfiguration(true) { @@ -593,5 +433,147 @@ public async Task CreateOrUpdate_CreatesAStreamingPolicyWithSecureStreaming() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAStreamingPolicyByName() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-policy-get-by-name.json + // this example is just showing the usage of "StreamingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MediaServicesAccountResource created on azure + // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "contosorg"; + string accountName = "contosomedia"; + ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); + + // get the collection of this StreamingPolicyResource + StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies(); + + // invoke the operation + string streamingPolicyName = "clearStreamingPolicy"; + StreamingPolicyResource result = await collection.GetAsync(streamingPolicyName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListsStreamingPolicies() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-policies-list.json + // this example is just showing the usage of "StreamingPolicies_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MediaServicesAccountResource created on azure + // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "contosorg"; + string accountName = "contosomedia"; + ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); + + // get the collection of this StreamingPolicyResource + StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies(); + + // invoke the operation and iterate over the result + await foreach (StreamingPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetAStreamingPolicyByName() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-policy-get-by-name.json + // this example is just showing the usage of "StreamingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MediaServicesAccountResource created on azure + // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "contosorg"; + string accountName = "contosomedia"; + ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); + + // get the collection of this StreamingPolicyResource + StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies(); + + // invoke the operation + string streamingPolicyName = "clearStreamingPolicy"; + bool result = await collection.ExistsAsync(streamingPolicyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetAStreamingPolicyByName() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-policy-get-by-name.json + // this example is just showing the usage of "StreamingPolicies_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MediaServicesAccountResource created on azure + // for more information of creating MediaServicesAccountResource, please refer to the document of MediaServicesAccountResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "contosorg"; + string accountName = "contosomedia"; + ResourceIdentifier mediaServicesAccountResourceId = MediaServicesAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + MediaServicesAccountResource mediaServicesAccount = client.GetMediaServicesAccountResource(mediaServicesAccountResourceId); + + // get the collection of this StreamingPolicyResource + StreamingPolicyCollection collection = mediaServicesAccount.GetStreamingPolicies(); + + // invoke the operation + string streamingPolicyName = "clearStreamingPolicy"; + NullableResponse response = await collection.GetIfExistsAsync(streamingPolicyName); + StreamingPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + StreamingPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingPolicyResource.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingPolicyResource.cs index ec460a009ed84..4cead8272c0d2 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingPolicyResource.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_StreamingPolicyResource.cs @@ -47,6 +47,33 @@ public async Task Get_GetAStreamingPolicyByName() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAStreamingPolicy() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-policies-delete.json + // this example is just showing the usage of "StreamingPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this StreamingPolicyResource created on azure + // for more information of creating StreamingPolicyResource, please refer to the document of StreamingPolicyResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "contosorg"; + string accountName = "contosomedia"; + string streamingPolicyName = "secureStreamingPolicyWithCommonEncryptionCbcsOnly"; + ResourceIdentifier streamingPolicyResourceId = StreamingPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, streamingPolicyName); + StreamingPolicyResource streamingPolicy = client.GetStreamingPolicyResource(streamingPolicyResourceId); + + // invoke the operation + await streamingPolicy.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreatesAStreamingPolicyWithClearKeyEncryptionInCommonEncryptionCbcs() @@ -69,15 +96,15 @@ public async Task Update_CreatesAStreamingPolicyWithClearKeyEncryptionInCommonEn StreamingPolicyResource streamingPolicy = client.GetStreamingPolicyResource(streamingPolicyResourceId); // invoke the operation - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithMultipleOptions", - CommonEncryptionCbcs = new CommonEncryptionCbcs() + CommonEncryptionCbcs = new CommonEncryptionCbcs { EnabledProtocols = new MediaEnabledProtocols(false, false, true, false), - ContentKeys = new StreamingPolicyContentKeys() + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cbcsDefaultKey", }, @@ -117,28 +144,22 @@ public async Task Update_CreatesAStreamingPolicyWithClearKeyEncryptionInCommonEn StreamingPolicyResource streamingPolicy = client.GetStreamingPolicyResource(streamingPolicyResourceId); // invoke the operation - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithPlayReadyOptionAndOpenRestriction", - CommonEncryptionCenc = new CommonEncryptionCenc() + CommonEncryptionCenc = new CommonEncryptionCenc { EnabledProtocols = new MediaEnabledProtocols(false, true, false, true), - ClearTracks = -{ -new MediaTrackSelection() -{ -TrackSelections = + ClearTracks = {new MediaTrackSelection { -new TrackPropertyCondition(TrackPropertyType.FourCC,TrackPropertyCompareOperation.Equal) +TrackSelections = {new TrackPropertyCondition(TrackPropertyType.FourCC, TrackPropertyCompareOperation.Equal) { Value = "hev1", -} -}, -} -}, - ContentKeys = new StreamingPolicyContentKeys() +}}, +}}, + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cencDefaultKey", }, @@ -178,7 +199,7 @@ public async Task Update_CreatesAStreamingPolicyWithClearStreaming() StreamingPolicyResource streamingPolicy = client.GetStreamingPolicyResource(streamingPolicyResourceId); // invoke the operation - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { NoEncryptionEnabledProtocols = new MediaEnabledProtocols(true, true, true, true), }; @@ -214,20 +235,20 @@ public async Task Update_CreatesAStreamingPolicyWithCommonEncryptionCbcsOnly() StreamingPolicyResource streamingPolicy = client.GetStreamingPolicyResource(streamingPolicyResourceId); // invoke the operation - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithMultipleOptions", - CommonEncryptionCbcs = new CommonEncryptionCbcs() + CommonEncryptionCbcs = new CommonEncryptionCbcs { EnabledProtocols = new MediaEnabledProtocols(false, false, true, false), - ContentKeys = new StreamingPolicyContentKeys() + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cbcsDefaultKey", }, }, - Drm = new CbcsDrmConfiguration() + Drm = new CbcsDrmConfiguration { FairPlay = new StreamingPolicyFairPlayConfiguration(true) { @@ -268,35 +289,29 @@ public async Task Update_CreatesAStreamingPolicyWithCommonEncryptionCencOnly() StreamingPolicyResource streamingPolicy = client.GetStreamingPolicyResource(streamingPolicyResourceId); // invoke the operation - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithPlayReadyOptionAndOpenRestriction", - CommonEncryptionCenc = new CommonEncryptionCenc() + CommonEncryptionCenc = new CommonEncryptionCenc { EnabledProtocols = new MediaEnabledProtocols(false, true, false, true), - ClearTracks = -{ -new MediaTrackSelection() -{ -TrackSelections = + ClearTracks = {new MediaTrackSelection { -new TrackPropertyCondition(TrackPropertyType.FourCC,TrackPropertyCompareOperation.Equal) +TrackSelections = {new TrackPropertyCondition(TrackPropertyType.FourCC, TrackPropertyCompareOperation.Equal) { Value = "hev1", -} -}, -} -}, - ContentKeys = new StreamingPolicyContentKeys() +}}, +}}, + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cencDefaultKey", }, }, - Drm = new CencDrmConfiguration() + Drm = new CencDrmConfiguration { - PlayReady = new StreamingPolicyPlayReadyConfiguration() + PlayReady = new StreamingPolicyPlayReadyConfiguration { CustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}", PlayReadyCustomAttributes = "PlayReady CustomAttributes", @@ -337,15 +352,15 @@ public async Task Update_CreatesAStreamingPolicyWithEnvelopeEncryptionOnly() StreamingPolicyResource streamingPolicy = client.GetStreamingPolicyResource(streamingPolicyResourceId); // invoke the operation - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithClearKeyOptionAndTokenRestriction", - EnvelopeEncryption = new EnvelopeEncryption() + EnvelopeEncryption = new EnvelopeEncryption { EnabledProtocols = new MediaEnabledProtocols(false, true, true, true), - ContentKeys = new StreamingPolicyContentKeys() + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "aesDefaultKey", }, @@ -385,47 +400,41 @@ public async Task Update_CreatesAStreamingPolicyWithSecureStreaming() StreamingPolicyResource streamingPolicy = client.GetStreamingPolicyResource(streamingPolicyResourceId); // invoke the operation - StreamingPolicyData data = new StreamingPolicyData() + StreamingPolicyData data = new StreamingPolicyData { DefaultContentKeyPolicyName = "PolicyWithMultipleOptions", - EnvelopeEncryption = new EnvelopeEncryption() + EnvelopeEncryption = new EnvelopeEncryption { EnabledProtocols = new MediaEnabledProtocols(false, true, true, true), - ContentKeys = new StreamingPolicyContentKeys() + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "aesDefaultKey", }, }, CustomKeyAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/envelope/{ContentKeyId}", }, - CommonEncryptionCenc = new CommonEncryptionCenc() + CommonEncryptionCenc = new CommonEncryptionCenc { EnabledProtocols = new MediaEnabledProtocols(false, true, false, true), - ClearTracks = -{ -new MediaTrackSelection() + ClearTracks = {new MediaTrackSelection { -TrackSelections = -{ -new TrackPropertyCondition(TrackPropertyType.FourCC,TrackPropertyCompareOperation.Equal) +TrackSelections = {new TrackPropertyCondition(TrackPropertyType.FourCC, TrackPropertyCompareOperation.Equal) { Value = "hev1", -} -}, -} -}, - ContentKeys = new StreamingPolicyContentKeys() +}}, +}}, + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cencDefaultKey", }, }, - Drm = new CencDrmConfiguration() + Drm = new CencDrmConfiguration { - PlayReady = new StreamingPolicyPlayReadyConfiguration() + PlayReady = new StreamingPolicyPlayReadyConfiguration { CustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/playready/{ContentKeyId}", PlayReadyCustomAttributes = "PlayReady CustomAttributes", @@ -433,17 +442,17 @@ public async Task Update_CreatesAStreamingPolicyWithSecureStreaming() WidevineCustomLicenseAcquisitionUriTemplate = "https://contoso.com/{AssetAlternativeId}/widevine/{ContentKeyId", }, }, - CommonEncryptionCbcs = new CommonEncryptionCbcs() + CommonEncryptionCbcs = new CommonEncryptionCbcs { EnabledProtocols = new MediaEnabledProtocols(false, false, true, false), - ContentKeys = new StreamingPolicyContentKeys() + ContentKeys = new StreamingPolicyContentKeys { - DefaultKey = new EncryptionSchemeDefaultKey() + DefaultKey = new EncryptionSchemeDefaultKey { Label = "cbcsDefaultKey", }, }, - Drm = new CbcsDrmConfiguration() + Drm = new CbcsDrmConfiguration { FairPlay = new StreamingPolicyFairPlayConfiguration(true) { @@ -461,32 +470,5 @@ public async Task Update_CreatesAStreamingPolicyWithSecureStreaming() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAStreamingPolicy() - { - // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Metadata/stable/2023-01-01/examples/streaming-policies-delete.json - // this example is just showing the usage of "StreamingPolicies_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this StreamingPolicyResource created on azure - // for more information of creating StreamingPolicyResource, please refer to the document of StreamingPolicyResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "contosorg"; - string accountName = "contosomedia"; - string streamingPolicyName = "secureStreamingPolicyWithCommonEncryptionCbcsOnly"; - ResourceIdentifier streamingPolicyResourceId = StreamingPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, streamingPolicyName); - StreamingPolicyResource streamingPolicy = client.GetStreamingPolicyResource(streamingPolicyResourceId); - - // invoke the operation - await streamingPolicy.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 442622612197c..cb01d5841d2e5 100644 --- a/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/mediaservices/Azure.ResourceManager.Media/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.Media.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMediaServicesAccounts_ListAllMediaServicesAccounts() + { + // Generated from example definition: specification/mediaservices/resource-manager/Microsoft.Media/Accounts/stable/2023-01-01/examples/accounts-subscription-list-all-accounts.json + // this example is just showing the usage of "Mediaservices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MediaServicesAccountResource item in subscriptionResource.GetMediaServicesAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MediaServicesAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task CheckMediaServicesNameAvailability_CheckNameAvailability() @@ -37,7 +68,7 @@ public async Task CheckMediaServicesNameAvailability_CheckNameAvailability() // invoke the operation AzureLocation locationName = new AzureLocation("japanwest"); - MediaServicesNameAvailabilityContent content = new MediaServicesNameAvailabilityContent() + MediaServicesNameAvailabilityContent content = new MediaServicesNameAvailabilityContent { Name = "contosotv", ResourceType = "Microsoft.Media/mediaservices", diff --git a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoveryServerInstanceCollection.cs b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoveryServerInstanceCollection.cs index c79fd7360cdc3..84e2cf43a2982 100644 --- a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoveryServerInstanceCollection.cs +++ b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoveryServerInstanceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SapDiscoveryServerInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheServerInstanceResourcesForTheGivenSAPInstanceResource() + public async Task CreateOrUpdate_CreatesTheServerInstanceResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_List.json - // this example is just showing the usage of "ServerInstances_ListBySapInstance" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_Create.json + // this example is just showing the usage of "ServerInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,17 @@ public async Task GetAll_ListsTheServerInstanceResourcesForTheGivenSAPInstanceRe // get the collection of this SapDiscoveryServerInstanceResource SapDiscoveryServerInstanceCollection collection = sapInstance.GetSapDiscoveryServerInstances(); - // invoke the operation and iterate over the result - await foreach (SapDiscoveryServerInstanceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDiscoveryServerInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string serverInstanceName = "APP_SapServer1"; + SapDiscoveryServerInstanceData data = new SapDiscoveryServerInstanceData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverInstanceName, data); + SapDiscoveryServerInstanceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDiscoveryServerInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +89,10 @@ public async Task Get_GETAServerInstanceResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GETAServerInstanceResource() + public async Task GetAll_ListsTheServerInstanceResourcesForTheGivenSAPInstanceResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_Get.json - // this example is just showing the usage of "ServerInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_List.json + // this example is just showing the usage of "ServerInstances_ListBySapInstance" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +111,22 @@ public async Task Exists_GETAServerInstanceResource() // get the collection of this SapDiscoveryServerInstanceResource SapDiscoveryServerInstanceCollection collection = sapInstance.GetSapDiscoveryServerInstances(); - // invoke the operation - string serverInstanceName = "APP_SapServer1"; - bool result = await collection.ExistsAsync(serverInstanceName); + // invoke the operation and iterate over the result + await foreach (SapDiscoveryServerInstanceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDiscoveryServerInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GETAServerInstanceResource() + public async Task Exists_GETAServerInstanceResource() { // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_Get.json // this example is just showing the usage of "ServerInstances_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_GETAServerInstanceResource() // invoke the operation string serverInstanceName = "APP_SapServer1"; - NullableResponse response = await collection.GetIfExistsAsync(serverInstanceName); - SapDiscoveryServerInstanceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serverInstanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDiscoveryServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesTheServerInstanceResource() + public async Task GetIfExists_GETAServerInstanceResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_Create.json - // this example is just showing the usage of "ServerInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_Get.json + // this example is just showing the usage of "ServerInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,15 +181,21 @@ public async Task CreateOrUpdate_CreatesTheServerInstanceResource() // invoke the operation string serverInstanceName = "APP_SapServer1"; - SapDiscoveryServerInstanceData data = new SapDiscoveryServerInstanceData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverInstanceName, data); - SapDiscoveryServerInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(serverInstanceName); + SapDiscoveryServerInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDiscoveryServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDiscoveryServerInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoveryServerInstanceResource.cs b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoveryServerInstanceResource.cs index 7d62dd76cbfdb..88d055d80f365 100644 --- a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoveryServerInstanceResource.cs +++ b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoveryServerInstanceResource.cs @@ -50,10 +50,10 @@ public async Task Get_GETAServerInstanceResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesTheServerInstanceResource() + public async Task Delete_DeletesTheServerInstanceResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_Update.json - // this example is just showing the usage of "ServerInstances_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_Delete.json + // this example is just showing the usage of "ServerInstances_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,25 +71,17 @@ public async Task Update_UpdatesTheServerInstanceResource() SapDiscoveryServerInstanceResource sapDiscoveryServerInstance = client.GetSapDiscoveryServerInstanceResource(sapDiscoveryServerInstanceResourceId); // invoke the operation - SapDiscoveryServerInstancePatch patch = new SapDiscoveryServerInstancePatch() - { - Properties = new ServerInstanceProperties(), - }; - SapDiscoveryServerInstanceResource result = await sapDiscoveryServerInstance.UpdateAsync(patch); + await sapDiscoveryServerInstance.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDiscoveryServerInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesTheServerInstanceResource() + public async Task Update_UpdatesTheServerInstanceResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_Delete.json - // this example is just showing the usage of "ServerInstances_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/ServerInstances_Update.json + // this example is just showing the usage of "ServerInstances_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +99,17 @@ public async Task Delete_DeletesTheServerInstanceResource() SapDiscoveryServerInstanceResource sapDiscoveryServerInstance = client.GetSapDiscoveryServerInstanceResource(sapDiscoveryServerInstanceResourceId); // invoke the operation - await sapDiscoveryServerInstance.DeleteAsync(WaitUntil.Completed); + SapDiscoveryServerInstancePatch patch = new SapDiscoveryServerInstancePatch + { + Properties = new ServerInstanceProperties(), + }; + SapDiscoveryServerInstanceResource result = await sapDiscoveryServerInstance.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDiscoveryServerInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoverySiteCollection.cs b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoverySiteCollection.cs index 39504266922b5..871041020d489 100644 --- a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoverySiteCollection.cs +++ b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoverySiteCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SapDiscoverySiteCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSAPMigrationDiscoverySiteResourcesByResourceGroup() + public async Task CreateOrUpdate_CreateResourceForImportBasedInput() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_ListByResourceGroup.json - // this example is just showing the usage of "SapDiscoverySites_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_Create.json + // this example is just showing the usage of "SapDiscoverySites_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,26 @@ public async Task GetAll_ListSAPMigrationDiscoverySiteResourcesByResourceGroup() // get the collection of this SapDiscoverySiteResource SapDiscoverySiteCollection collection = resourceGroupResource.GetSapDiscoverySites(); - // invoke the operation and iterate over the result - await foreach (SapDiscoverySiteResource item in collection.GetAllAsync()) + // invoke the operation + string sapDiscoverySiteName = "SampleSite"; + SapDiscoverySiteData data = new SapDiscoverySiteData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDiscoverySiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + MasterSiteId = "MasterSiteIdResourceId", + MigrateProjectId = "MigrateProjectId", + Tags = +{ +["property1"] = "value1", +["property2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapDiscoverySiteName, data); + SapDiscoverySiteResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDiscoverySiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +95,10 @@ public async Task Get_GETASAPMigrationDiscoverySiteResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GETASAPMigrationDiscoverySiteResource() + public async Task GetAll_ListSAPMigrationDiscoverySiteResourcesByResourceGroup() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_Get.json - // this example is just showing the usage of "SapDiscoverySites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_ListByResourceGroup.json + // this example is just showing the usage of "SapDiscoverySites_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +115,22 @@ public async Task Exists_GETASAPMigrationDiscoverySiteResource() // get the collection of this SapDiscoverySiteResource SapDiscoverySiteCollection collection = resourceGroupResource.GetSapDiscoverySites(); - // invoke the operation - string sapDiscoverySiteName = "SampleSite"; - bool result = await collection.ExistsAsync(sapDiscoverySiteName); + // invoke the operation and iterate over the result + await foreach (SapDiscoverySiteResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDiscoverySiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GETASAPMigrationDiscoverySiteResource() + public async Task Exists_GETASAPMigrationDiscoverySiteResource() { // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_Get.json // this example is just showing the usage of "SapDiscoverySites_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +152,17 @@ public async Task GetIfExists_GETASAPMigrationDiscoverySiteResource() // invoke the operation string sapDiscoverySiteName = "SampleSite"; - NullableResponse response = await collection.GetIfExistsAsync(sapDiscoverySiteName); - SapDiscoverySiteResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sapDiscoverySiteName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDiscoverySiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateResourceForImportBasedInput() + public async Task GetIfExists_GETASAPMigrationDiscoverySiteResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_Create.json - // this example is just showing the usage of "SapDiscoverySites_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_Get.json + // this example is just showing the usage of "SapDiscoverySites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,24 +181,21 @@ public async Task CreateOrUpdate_CreateResourceForImportBasedInput() // invoke the operation string sapDiscoverySiteName = "SampleSite"; - SapDiscoverySiteData data = new SapDiscoverySiteData(new AzureLocation("eastus")) - { - MasterSiteId = "MasterSiteIdResourceId", - MigrateProjectId = "MigrateProjectId", - Tags = -{ -["property1"] = "value1", -["property2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapDiscoverySiteName, data); - SapDiscoverySiteResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(sapDiscoverySiteName); + SapDiscoverySiteResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDiscoverySiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDiscoverySiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoverySiteResource.cs b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoverySiteResource.cs index 302bbafcaeb7e..119e5c9ade91f 100644 --- a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoverySiteResource.cs +++ b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapDiscoverySiteResource.cs @@ -11,44 +11,12 @@ using Azure.Identity; using Azure.ResourceManager.MigrationDiscoverySap.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MigrationDiscoverySap.Samples { public partial class Sample_SapDiscoverySiteResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSapDiscoverySites_ListSAPMigrationDiscoverySiteResourcesInASubscription() - { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_ListBySubscription.json - // this example is just showing the usage of "SapDiscoverySites_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "6d875e77-e412-4d7d-9af4-8895278b4443"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SapDiscoverySiteResource item in subscriptionResource.GetSapDiscoverySitesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDiscoverySiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GETASAPMigrationDiscoverySiteResource() @@ -81,10 +49,10 @@ public async Task Get_GETASAPMigrationDiscoverySiteResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesASAPMigrationDiscoverySiteResource() + public async Task Delete_DeletesASAPMigrationDiscoverySiteResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_Update.json - // this example is just showing the usage of "SapDiscoverySites_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_Delete.json + // this example is just showing the usage of "SapDiscoverySites_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,28 +68,17 @@ public async Task Update_UpdatesASAPMigrationDiscoverySiteResource() SapDiscoverySiteResource sapDiscoverySite = client.GetSapDiscoverySiteResource(sapDiscoverySiteResourceId); // invoke the operation - SapDiscoverySitePatch patch = new SapDiscoverySitePatch() - { - Tags = -{ -["tag1"] = "value1", -}, - }; - SapDiscoverySiteResource result = await sapDiscoverySite.UpdateAsync(patch); + await sapDiscoverySite.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapDiscoverySiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesASAPMigrationDiscoverySiteResource() + public async Task Update_UpdatesASAPMigrationDiscoverySiteResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_Delete.json - // this example is just showing the usage of "SapDiscoverySites_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_Update.json + // this example is just showing the usage of "SapDiscoverySites_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,9 +94,20 @@ public async Task Delete_DeletesASAPMigrationDiscoverySiteResource() SapDiscoverySiteResource sapDiscoverySite = client.GetSapDiscoverySiteResource(sapDiscoverySiteResourceId); // invoke the operation - await sapDiscoverySite.DeleteAsync(WaitUntil.Completed); + SapDiscoverySitePatch patch = new SapDiscoverySitePatch + { + Tags = +{ +["tag1"] = "value1" +}, + }; + SapDiscoverySiteResource result = await sapDiscoverySite.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDiscoverySiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapInstanceCollection.cs b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapInstanceCollection.cs index 46d2c1f8b319a..9327d7ef23efd 100644 --- a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapInstanceCollection.cs +++ b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapInstanceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_SapInstanceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheSAPInstanceResourcesForTheGivenSAPMigrationDiscoverySiteResource() + public async Task CreateOrUpdate_CreatesTheSAPInstanceResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_List.json - // this example is just showing the usage of "SapInstances_ListBySapDiscoverySite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_Create.json + // this example is just showing the usage of "SapInstances_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,24 @@ public async Task GetAll_ListsTheSAPInstanceResourcesForTheGivenSAPMigrationDisc // get the collection of this SapInstanceResource SapInstanceCollection collection = sapDiscoverySite.GetSapInstances(); - // invoke the operation and iterate over the result - await foreach (SapInstanceResource item in collection.GetAllAsync()) + // invoke the operation + string sapInstanceName = "MPP_MPP"; + SapInstanceData data = new SapInstanceData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapInstanceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["property1"] = "value1", +["property2"] = "value2" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapInstanceName, data); + SapInstanceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +94,10 @@ public async Task Get_GETASAPInstanceResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GETASAPInstanceResource() + public async Task GetAll_ListsTheSAPInstanceResourcesForTheGivenSAPMigrationDiscoverySiteResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_Get.json - // this example is just showing the usage of "SapInstances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_List.json + // this example is just showing the usage of "SapInstances_ListBySapDiscoverySite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +115,22 @@ public async Task Exists_GETASAPInstanceResource() // get the collection of this SapInstanceResource SapInstanceCollection collection = sapDiscoverySite.GetSapInstances(); - // invoke the operation - string sapInstanceName = "MPP_MPP"; - bool result = await collection.ExistsAsync(sapInstanceName); + // invoke the operation and iterate over the result + await foreach (SapInstanceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapInstanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GETASAPInstanceResource() + public async Task Exists_GETASAPInstanceResource() { // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_Get.json // this example is just showing the usage of "SapInstances_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +153,17 @@ public async Task GetIfExists_GETASAPInstanceResource() // invoke the operation string sapInstanceName = "MPP_MPP"; - NullableResponse response = await collection.GetIfExistsAsync(sapInstanceName); - SapInstanceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(sapInstanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesTheSAPInstanceResource() + public async Task GetIfExists_GETASAPInstanceResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_Create.json - // this example is just showing the usage of "SapInstances_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_Get.json + // this example is just showing the usage of "SapInstances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,22 +183,21 @@ public async Task CreateOrUpdate_CreatesTheSAPInstanceResource() // invoke the operation string sapInstanceName = "MPP_MPP"; - SapInstanceData data = new SapInstanceData(new AzureLocation("eastus")) - { - Tags = -{ -["property1"] = "value1", -["property2"] = "value2", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sapInstanceName, data); - SapInstanceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(sapInstanceName); + SapInstanceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapInstanceResource.cs b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapInstanceResource.cs index 63eb514147a2d..bbb101bb8cf3c 100644 --- a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapInstanceResource.cs +++ b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SapInstanceResource.cs @@ -49,10 +49,10 @@ public async Task Get_GETASAPInstanceResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesTheSAPInstanceResource() + public async Task Delete_DeletesTheSAPInstanceResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_Update.json - // this example is just showing the usage of "SapInstances_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_Delete.json + // this example is just showing the usage of "SapInstances_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,28 +69,17 @@ public async Task Update_UpdatesTheSAPInstanceResource() SapInstanceResource sapInstance = client.GetSapInstanceResource(sapInstanceResourceId); // invoke the operation - SapInstancePatch patch = new SapInstancePatch() - { - Tags = -{ -["tag1"] = "value1", -}, - }; - SapInstanceResource result = await sapInstance.UpdateAsync(patch); + await sapInstance.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SapInstanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesTheSAPInstanceResource() + public async Task Update_UpdatesTheSAPInstanceResource() { - // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_Delete.json - // this example is just showing the usage of "SapInstances_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPInstances_Update.json + // this example is just showing the usage of "SapInstances_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +96,20 @@ public async Task Delete_DeletesTheSAPInstanceResource() SapInstanceResource sapInstance = client.GetSapInstanceResource(sapInstanceResourceId); // invoke the operation - await sapInstance.DeleteAsync(WaitUntil.Completed); + SapInstancePatch patch = new SapInstancePatch + { + Tags = +{ +["tag1"] = "value1" +}, + }; + SapInstanceResource result = await sapInstance.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapInstanceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..39813dedac5b8 --- /dev/null +++ b/sdk/migrationdiscoverysap/Azure.ResourceManager.MigrationDiscoverySap/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.MigrationDiscoverySap.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSapDiscoverySites_ListSAPMigrationDiscoverySiteResourcesInASubscription() + { + // Generated from example definition: specification/workloads/resource-manager/Microsoft.Workloads/SAPDiscoverySites/preview/2023-10-01-preview/examples/SAPDiscoverySites_ListBySubscription.json + // this example is just showing the usage of "SapDiscoverySites_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "6d875e77-e412-4d7d-9af4-8895278b4443"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SapDiscoverySiteResource item in subscriptionResource.GetSapDiscoverySitesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SapDiscoverySiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_RemoteRenderingAccountCollection.cs b/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_RemoteRenderingAccountCollection.cs index 6b29d00776c24..c58b33c5148ac 100644 --- a/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_RemoteRenderingAccountCollection.cs +++ b/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_RemoteRenderingAccountCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_RemoteRenderingAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRemoteRenderingAccountsByResourceGroup() + public async Task CreateOrUpdate_CreateRemoteRenderingAccount() { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/GetByResourceGroup.json - // this example is just showing the usage of "RemoteRenderingAccounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/Put.json + // this example is just showing the usage of "RemoteRenderingAccounts_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ListRemoteRenderingAccountsByResourceGroup() // get the collection of this RemoteRenderingAccountResource RemoteRenderingAccountCollection collection = resourceGroupResource.GetRemoteRenderingAccounts(); - // invoke the operation and iterate over the result - await foreach (RemoteRenderingAccountResource item in collection.GetAllAsync()) + // invoke the operation + string accountName = "MyAccount"; + RemoteRenderingAccountData data = new RemoteRenderingAccountData(new AzureLocation("eastus2euap")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemoteRenderingAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Identity = new ManagedServiceIdentity("SystemAssigned"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + RemoteRenderingAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemoteRenderingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetRemoteRenderingAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRemoteRenderingAccount() + public async Task GetAll_ListRemoteRenderingAccountsByResourceGroup() { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/Get.json - // this example is just showing the usage of "RemoteRenderingAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/GetByResourceGroup.json + // this example is just showing the usage of "RemoteRenderingAccounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +110,22 @@ public async Task Exists_GetRemoteRenderingAccount() // get the collection of this RemoteRenderingAccountResource RemoteRenderingAccountCollection collection = resourceGroupResource.GetRemoteRenderingAccounts(); - // invoke the operation - string accountName = "MyAccount"; - bool result = await collection.ExistsAsync(accountName); + // invoke the operation and iterate over the result + await foreach (RemoteRenderingAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemoteRenderingAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRemoteRenderingAccount() + public async Task Exists_GetRemoteRenderingAccount() { // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/Get.json // this example is just showing the usage of "RemoteRenderingAccounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +147,17 @@ public async Task GetIfExists_GetRemoteRenderingAccount() // invoke the operation string accountName = "MyAccount"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - RemoteRenderingAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemoteRenderingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateRemoteRenderingAccount() + public async Task GetIfExists_GetRemoteRenderingAccount() { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/Put.json - // this example is just showing the usage of "RemoteRenderingAccounts_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/Get.json + // this example is just showing the usage of "RemoteRenderingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,18 +176,21 @@ public async Task CreateOrUpdate_CreateRemoteRenderingAccount() // invoke the operation string accountName = "MyAccount"; - RemoteRenderingAccountData data = new RemoteRenderingAccountData(new AzureLocation("eastus2euap")) - { - Identity = new ManagedServiceIdentity("SystemAssigned"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); - RemoteRenderingAccountResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + RemoteRenderingAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemoteRenderingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemoteRenderingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_RemoteRenderingAccountResource.cs b/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_RemoteRenderingAccountResource.cs index 1ecd5d0c87b27..7651249872f54 100644 --- a/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_RemoteRenderingAccountResource.cs +++ b/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_RemoteRenderingAccountResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.MixedReality.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MixedReality.Samples @@ -20,41 +19,10 @@ public partial class Sample_RemoteRenderingAccountResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetRemoteRenderingAccounts_ListRemoteRenderingAccountsBySubscription() - { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/GetBySubscription.json - // this example is just showing the usage of "RemoteRenderingAccounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (RemoteRenderingAccountResource item in subscriptionResource.GetRemoteRenderingAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemoteRenderingAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRemoteRenderingAccount() + public async Task Get_GetRemoteRenderingAccount() { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/Delete.json - // this example is just showing the usage of "RemoteRenderingAccounts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/Get.json + // this example is just showing the usage of "RemoteRenderingAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,17 +38,21 @@ public async Task Delete_DeleteRemoteRenderingAccount() RemoteRenderingAccountResource remoteRenderingAccount = client.GetRemoteRenderingAccountResource(remoteRenderingAccountResourceId); // invoke the operation - await remoteRenderingAccount.DeleteAsync(WaitUntil.Completed); + RemoteRenderingAccountResource result = await remoteRenderingAccount.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemoteRenderingAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRemoteRenderingAccount() + public async Task Delete_DeleteRemoteRenderingAccount() { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/Get.json - // this example is just showing the usage of "RemoteRenderingAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/Delete.json + // this example is just showing the usage of "RemoteRenderingAccounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,13 +68,9 @@ public async Task Get_GetRemoteRenderingAccount() RemoteRenderingAccountResource remoteRenderingAccount = client.GetRemoteRenderingAccountResource(remoteRenderingAccountResourceId); // invoke the operation - RemoteRenderingAccountResource result = await remoteRenderingAccount.GetAsync(); + await remoteRenderingAccount.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RemoteRenderingAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -132,7 +100,7 @@ public async Task Update_UpdateRemoteRenderingAccount() Tags = { ["hero"] = "romeo", -["heroine"] = "juliet", +["heroine"] = "juliet" }, }; RemoteRenderingAccountResource result = await remoteRenderingAccount.UpdateAsync(data); @@ -191,7 +159,7 @@ public async Task RegenerateKeys_RegenerateRemoteRenderingAccountKeys() RemoteRenderingAccountResource remoteRenderingAccount = client.GetRemoteRenderingAccountResource(remoteRenderingAccountResourceId); // invoke the operation - MixedRealityAccountKeyRegenerateContent content = new MixedRealityAccountKeyRegenerateContent() + MixedRealityAccountKeyRegenerateContent content = new MixedRealityAccountKeyRegenerateContent { Serial = MixedRealityAccountKeySerial.Primary, }; diff --git a/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SpatialAnchorsAccountCollection.cs b/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SpatialAnchorsAccountCollection.cs index 58338761cc140..49bc3bdf6e321 100644 --- a/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SpatialAnchorsAccountCollection.cs +++ b/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SpatialAnchorsAccountCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SpatialAnchorsAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSpatialAnchorAccountsByResourceGroup() + public async Task CreateOrUpdate_CreateSpatialAnchorAccount() { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/GetByResourceGroup.json - // this example is just showing the usage of "SpatialAnchorsAccounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/Put.json + // this example is just showing the usage of "SpatialAnchorsAccounts_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_ListSpatialAnchorAccountsByResourceGroup() // get the collection of this SpatialAnchorsAccountResource SpatialAnchorsAccountCollection collection = resourceGroupResource.GetSpatialAnchorsAccounts(); - // invoke the operation and iterate over the result - await foreach (SpatialAnchorsAccountResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpatialAnchorsAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string accountName = "MyAccount"; + SpatialAnchorsAccountData data = new SpatialAnchorsAccountData(new AzureLocation("eastus2euap")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + SpatialAnchorsAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpatialAnchorsAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +86,10 @@ public async Task Get_GetSpatialAnchorsAccount() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSpatialAnchorsAccount() + public async Task GetAll_ListSpatialAnchorAccountsByResourceGroup() { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/Get.json - // this example is just showing the usage of "SpatialAnchorsAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/GetByResourceGroup.json + // this example is just showing the usage of "SpatialAnchorsAccounts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +106,22 @@ public async Task Exists_GetSpatialAnchorsAccount() // get the collection of this SpatialAnchorsAccountResource SpatialAnchorsAccountCollection collection = resourceGroupResource.GetSpatialAnchorsAccounts(); - // invoke the operation - string accountName = "MyAccount"; - bool result = await collection.ExistsAsync(accountName); + // invoke the operation and iterate over the result + await foreach (SpatialAnchorsAccountResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpatialAnchorsAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSpatialAnchorsAccount() + public async Task Exists_GetSpatialAnchorsAccount() { // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/Get.json // this example is just showing the usage of "SpatialAnchorsAccounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +143,17 @@ public async Task GetIfExists_GetSpatialAnchorsAccount() // invoke the operation string accountName = "MyAccount"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - SpatialAnchorsAccountResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(accountName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpatialAnchorsAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSpatialAnchorAccount() + public async Task GetIfExists_GetSpatialAnchorsAccount() { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/Put.json - // this example is just showing the usage of "SpatialAnchorsAccounts_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/Get.json + // this example is just showing the usage of "SpatialAnchorsAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -178,15 +172,21 @@ public async Task CreateOrUpdate_CreateSpatialAnchorAccount() // invoke the operation string accountName = "MyAccount"; - SpatialAnchorsAccountData data = new SpatialAnchorsAccountData(new AzureLocation("eastus2euap")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); - SpatialAnchorsAccountResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + SpatialAnchorsAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpatialAnchorsAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpatialAnchorsAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SpatialAnchorsAccountResource.cs b/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SpatialAnchorsAccountResource.cs index a49c7d7f33c23..3631a3cde6700 100644 --- a/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SpatialAnchorsAccountResource.cs +++ b/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SpatialAnchorsAccountResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.MixedReality.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MixedReality.Samples @@ -19,41 +18,10 @@ public partial class Sample_SpatialAnchorsAccountResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetSpatialAnchorsAccounts_ListSpatialAnchorsAccountsBySubscription() - { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/GetBySubscription.json - // this example is just showing the usage of "SpatialAnchorsAccounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SpatialAnchorsAccountResource item in subscriptionResource.GetSpatialAnchorsAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpatialAnchorsAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSpatialAnchorsAccount() + public async Task Get_GetSpatialAnchorsAccount() { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/Delete.json - // this example is just showing the usage of "SpatialAnchorsAccounts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/Get.json + // this example is just showing the usage of "SpatialAnchorsAccounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,17 +37,21 @@ public async Task Delete_DeleteSpatialAnchorsAccount() SpatialAnchorsAccountResource spatialAnchorsAccount = client.GetSpatialAnchorsAccountResource(spatialAnchorsAccountResourceId); // invoke the operation - await spatialAnchorsAccount.DeleteAsync(WaitUntil.Completed); + SpatialAnchorsAccountResource result = await spatialAnchorsAccount.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpatialAnchorsAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSpatialAnchorsAccount() + public async Task Delete_DeleteSpatialAnchorsAccount() { - // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/Get.json - // this example is just showing the usage of "SpatialAnchorsAccounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/Delete.json + // this example is just showing the usage of "SpatialAnchorsAccounts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,13 +67,9 @@ public async Task Get_GetSpatialAnchorsAccount() SpatialAnchorsAccountResource spatialAnchorsAccount = client.GetSpatialAnchorsAccountResource(spatialAnchorsAccountResourceId); // invoke the operation - SpatialAnchorsAccountResource result = await spatialAnchorsAccount.GetAsync(); + await spatialAnchorsAccount.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SpatialAnchorsAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -130,7 +98,7 @@ public async Task Update_UpdateSpatialAnchorsAccount() Tags = { ["hero"] = "romeo", -["heroine"] = "juliet", +["heroine"] = "juliet" }, }; SpatialAnchorsAccountResource result = await spatialAnchorsAccount.UpdateAsync(data); @@ -189,7 +157,7 @@ public async Task RegenerateKeys_RegenerateSpatialAnchorsAccountKeys() SpatialAnchorsAccountResource spatialAnchorsAccount = client.GetSpatialAnchorsAccountResource(spatialAnchorsAccountResourceId); // invoke the operation - MixedRealityAccountKeyRegenerateContent content = new MixedRealityAccountKeyRegenerateContent() + MixedRealityAccountKeyRegenerateContent content = new MixedRealityAccountKeyRegenerateContent { Serial = MixedRealityAccountKeySerial.Primary, }; diff --git a/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 052574cce10bb..26afd8a89e442 100644 --- a/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/mixedreality/Azure.ResourceManager.MixedReality/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -42,5 +42,67 @@ public async Task CheckMixedRealityNameAvailability_CheckLocalNameAvailability() Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSpatialAnchorsAccounts_ListSpatialAnchorsAccountsBySubscription() + { + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/spatial-anchors/GetBySubscription.json + // this example is just showing the usage of "SpatialAnchorsAccounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SpatialAnchorsAccountResource item in subscriptionResource.GetSpatialAnchorsAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SpatialAnchorsAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetRemoteRenderingAccounts_ListRemoteRenderingAccountsBySubscription() + { + // Generated from example definition: specification/mixedreality/resource-manager/Microsoft.MixedReality/stable/2021-01-01/examples/remote-rendering/GetBySubscription.json + // this example is just showing the usage of "RemoteRenderingAccounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (RemoteRenderingAccountResource item in subscriptionResource.GetRemoteRenderingAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RemoteRenderingAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_ExtendedUEInfoCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_ExtendedUEInfoCollection.cs index 92a93c626ca6c..7078f29d49f24 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_ExtendedUEInfoCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_ExtendedUEInfoCollection.cs @@ -51,9 +51,9 @@ public async Task Get_GetUEInformation4G() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetUEInformation4G() + public async Task Get_GetUEInformation5G() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ExtendedUeInfo4GGet.json + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ExtendedUeInfo5GGet.json // this example is just showing the usage of "ExtendedUeInformation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -74,14 +74,18 @@ public async Task Exists_GetUEInformation4G() // invoke the operation string ueId = "84449105622"; - bool result = await collection.ExistsAsync(ueId); + ExtendedUEInfoResource result = await collection.GetAsync(ueId); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedUEInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetUEInformation4G() + public async Task Exists_GetUEInformation4G() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ExtendedUeInfo4GGet.json // this example is just showing the usage of "ExtendedUeInformation_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,26 +108,14 @@ public async Task GetIfExists_GetUEInformation4G() // invoke the operation string ueId = "84449105622"; - NullableResponse response = await collection.GetIfExistsAsync(ueId); - ExtendedUEInfoResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ueId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedUEInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetUEInformation5G() + public async Task Exists_GetUEInformation5G() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ExtendedUeInfo5GGet.json // this example is just showing the usage of "ExtendedUeInformation_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,20 +138,16 @@ public async Task Get_GetUEInformation5G() // invoke the operation string ueId = "84449105622"; - ExtendedUEInfoResource result = await collection.GetAsync(ueId); + bool result = await collection.ExistsAsync(ueId); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExtendedUEInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetUEInformation5G() + public async Task GetIfExists_GetUEInformation4G() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ExtendedUeInfo5GGet.json + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ExtendedUeInfo4GGet.json // this example is just showing the usage of "ExtendedUeInformation_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -180,9 +168,21 @@ public async Task Exists_GetUEInformation5G() // invoke the operation string ueId = "84449105622"; - bool result = await collection.ExistsAsync(ueId); + NullableResponse response = await collection.GetIfExistsAsync(ueId); + ExtendedUEInfoResource result = response.HasValue ? response.Value : null; - Console.WriteLine($"Succeeded: {result}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExtendedUEInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileAttachedDataNetworkCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileAttachedDataNetworkCollection.cs index 9a5b8797a8ac4..92be1a26b0374 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileAttachedDataNetworkCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileAttachedDataNetworkCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileAttachedDataNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAttachedDataNetwork() + public async Task CreateOrUpdate_CreateAttachedDataNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkGet.json - // this example is just showing the usage of "AttachedDataNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkCreate.json + // this example is just showing the usage of "AttachedDataNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,37 @@ public async Task Get_GetAttachedDataNetwork() // invoke the operation string attachedDataNetworkName = "TestAttachedDataNetwork"; - MobileAttachedDataNetworkResource result = await collection.GetAsync(attachedDataNetworkName); + MobileAttachedDataNetworkData data = new MobileAttachedDataNetworkData(new AzureLocation("eastus"), new MobileNetworkInterfaceProperties + { + Name = "N6", + }, new string[] { "1.1.1.1" }) + { + NaptConfiguration = new NaptConfiguration + { + Enabled = NaptState.Enabled, + PortRange = new MobileNetworkPortRange + { + MinPort = 1024, + MaxPort = 49999, + }, + PortReuseHoldTime = new MobileNetworkPortReuseHoldTimes + { + Tcp = 120, + Udp = 60, + }, + PinholeLimits = 65536, + PinholeTimeouts = new PinholeTimeouts + { + Tcp = 180, + Udp = 30, + Icmp = 30, + }, + }, + UserEquipmentAddressPoolPrefix = { "2.2.0.0/16" }, + UserEquipmentStaticAddressPoolPrefix = { "2.4.0.0/16" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attachedDataNetworkName, data); + MobileAttachedDataNetworkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +83,7 @@ public async Task Get_GetAttachedDataNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAttachedDataNetwork() + public async Task Get_GetAttachedDataNetwork() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkGet.json // this example is just showing the usage of "AttachedDataNetworks_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +107,21 @@ public async Task Exists_GetAttachedDataNetwork() // invoke the operation string attachedDataNetworkName = "TestAttachedDataNetwork"; - bool result = await collection.ExistsAsync(attachedDataNetworkName); + MobileAttachedDataNetworkResource result = await collection.GetAsync(attachedDataNetworkName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileAttachedDataNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAttachedDataNetwork() + public async Task GetAll_ListAttachedDataNetworksInADataPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkGet.json - // this example is just showing the usage of "AttachedDataNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkListByPacketCoreDataPlane.json + // this example is just showing the usage of "AttachedDataNetworks_ListByPacketCoreDataPlane" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +140,25 @@ public async Task GetIfExists_GetAttachedDataNetwork() // get the collection of this MobileAttachedDataNetworkResource MobileAttachedDataNetworkCollection collection = packetCoreDataPlane.GetMobileAttachedDataNetworks(); - // invoke the operation - string attachedDataNetworkName = "TestAttachedDataNetwork"; - NullableResponse response = await collection.GetIfExistsAsync(attachedDataNetworkName); - MobileAttachedDataNetworkResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MobileAttachedDataNetworkResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileAttachedDataNetworkData resourceData = result.Data; + MobileAttachedDataNetworkData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAttachedDataNetwork() + public async Task Exists_GetAttachedDataNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkCreate.json - // this example is just showing the usage of "AttachedDataNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkGet.json + // this example is just showing the usage of "AttachedDataNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,60 +179,17 @@ public async Task CreateOrUpdate_CreateAttachedDataNetwork() // invoke the operation string attachedDataNetworkName = "TestAttachedDataNetwork"; - MobileAttachedDataNetworkData data = new MobileAttachedDataNetworkData(new AzureLocation("eastus"), new MobileNetworkInterfaceProperties() - { - Name = "N6", - }, new string[] - { -"1.1.1.1" - }) - { - NaptConfiguration = new NaptConfiguration() - { - Enabled = NaptState.Enabled, - PortRange = new MobileNetworkPortRange() - { - MinPort = 1024, - MaxPort = 49999, - }, - PortReuseHoldTime = new MobileNetworkPortReuseHoldTimes() - { - Tcp = 120, - Udp = 60, - }, - PinholeLimits = 65536, - PinholeTimeouts = new PinholeTimeouts() - { - Tcp = 180, - Udp = 30, - Icmp = 30, - }, - }, - UserEquipmentAddressPoolPrefix = -{ -"2.2.0.0/16" -}, - UserEquipmentStaticAddressPoolPrefix = -{ -"2.4.0.0/16" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, attachedDataNetworkName, data); - MobileAttachedDataNetworkResource result = lro.Value; + bool result = await collection.ExistsAsync(attachedDataNetworkName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileAttachedDataNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAttachedDataNetworksInADataPlane() + public async Task GetIfExists_GetAttachedDataNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkListByPacketCoreDataPlane.json - // this example is just showing the usage of "AttachedDataNetworks_ListByPacketCoreDataPlane" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkGet.json + // this example is just showing the usage of "AttachedDataNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -223,17 +208,23 @@ public async Task GetAll_ListAttachedDataNetworksInADataPlane() // get the collection of this MobileAttachedDataNetworkResource MobileAttachedDataNetworkCollection collection = packetCoreDataPlane.GetMobileAttachedDataNetworks(); - // invoke the operation and iterate over the result - await foreach (MobileAttachedDataNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string attachedDataNetworkName = "TestAttachedDataNetwork"; + NullableResponse response = await collection.GetIfExistsAsync(attachedDataNetworkName); + MobileAttachedDataNetworkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileAttachedDataNetworkData resourceData = item.Data; + MobileAttachedDataNetworkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileAttachedDataNetworkResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileAttachedDataNetworkResource.cs index 8b24a6924844f..161969a244d97 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileAttachedDataNetworkResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileAttachedDataNetworkResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileAttachedDataNetworkResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAttachedDataNetworkResource() + public async Task Get_GetAttachedDataNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkDelete.json - // this example is just showing the usage of "AttachedDataNetworks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkGet.json + // this example is just showing the usage of "AttachedDataNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task Delete_DeleteAttachedDataNetworkResource() MobileAttachedDataNetworkResource mobileAttachedDataNetwork = client.GetMobileAttachedDataNetworkResource(mobileAttachedDataNetworkResourceId); // invoke the operation - await mobileAttachedDataNetwork.DeleteAsync(WaitUntil.Completed); + MobileAttachedDataNetworkResource result = await mobileAttachedDataNetwork.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileAttachedDataNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAttachedDataNetwork() + public async Task Delete_DeleteAttachedDataNetworkResource() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkGet.json - // this example is just showing the usage of "AttachedDataNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/AttachedDataNetworkDelete.json + // this example is just showing the usage of "AttachedDataNetworks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,13 +71,9 @@ public async Task Get_GetAttachedDataNetwork() MobileAttachedDataNetworkResource mobileAttachedDataNetwork = client.GetMobileAttachedDataNetworkResource(mobileAttachedDataNetworkResourceId); // invoke the operation - MobileAttachedDataNetworkResource result = await mobileAttachedDataNetwork.GetAsync(); + await mobileAttachedDataNetwork.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileAttachedDataNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,12 +99,12 @@ public async Task Update_UpdateAttachedDataNetworkTags() MobileAttachedDataNetworkResource mobileAttachedDataNetwork = client.GetMobileAttachedDataNetworkResource(mobileAttachedDataNetworkResourceId); // invoke the operation - MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch() + MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; MobileAttachedDataNetworkResource result = await mobileAttachedDataNetwork.UpdateAsync(patch); diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileDataNetworkCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileDataNetworkCollection.cs index e121e3d94be51..647352b2d79eb 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileDataNetworkCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileDataNetworkCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MobileDataNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDataNetwork() + public async Task CreateOrUpdate_CreateDataNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkGet.json - // this example is just showing the usage of "DataNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkCreate.json + // this example is just showing the usage of "DataNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetDataNetwork() // invoke the operation string dataNetworkName = "testDataNetwork"; - MobileDataNetworkResource result = await collection.GetAsync(dataNetworkName); + MobileDataNetworkData data = new MobileDataNetworkData(new AzureLocation("eastus")) + { + Description = "myFavouriteDataNetwork", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataNetworkName, data); + MobileDataNetworkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetDataNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDataNetwork() + public async Task Get_GetDataNetwork() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkGet.json // this example is just showing the usage of "DataNetworks_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +79,21 @@ public async Task Exists_GetDataNetwork() // invoke the operation string dataNetworkName = "testDataNetwork"; - bool result = await collection.ExistsAsync(dataNetworkName); + MobileDataNetworkResource result = await collection.GetAsync(dataNetworkName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileDataNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDataNetwork() + public async Task GetAll_ListDataNetworksInAMobileNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkGet.json - // this example is just showing the usage of "DataNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkListByMobileNetwork.json + // this example is just showing the usage of "DataNetworks_ListByMobileNetwork" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +111,25 @@ public async Task GetIfExists_GetDataNetwork() // get the collection of this MobileDataNetworkResource MobileDataNetworkCollection collection = mobileNetwork.GetMobileDataNetworks(); - // invoke the operation - string dataNetworkName = "testDataNetwork"; - NullableResponse response = await collection.GetIfExistsAsync(dataNetworkName); - MobileDataNetworkResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MobileDataNetworkResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileDataNetworkData resourceData = result.Data; + MobileDataNetworkData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateDataNetwork() + public async Task Exists_GetDataNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkCreate.json - // this example is just showing the usage of "DataNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkGet.json + // this example is just showing the usage of "DataNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,26 +149,17 @@ public async Task CreateOrUpdate_CreateDataNetwork() // invoke the operation string dataNetworkName = "testDataNetwork"; - MobileDataNetworkData data = new MobileDataNetworkData(new AzureLocation("eastus")) - { - Description = "myFavouriteDataNetwork", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataNetworkName, data); - MobileDataNetworkResource result = lro.Value; + bool result = await collection.ExistsAsync(dataNetworkName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileDataNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDataNetworksInAMobileNetwork() + public async Task GetIfExists_GetDataNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkListByMobileNetwork.json - // this example is just showing the usage of "DataNetworks_ListByMobileNetwork" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkGet.json + // this example is just showing the usage of "DataNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_ListDataNetworksInAMobileNetwork() // get the collection of this MobileDataNetworkResource MobileDataNetworkCollection collection = mobileNetwork.GetMobileDataNetworks(); - // invoke the operation and iterate over the result - await foreach (MobileDataNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string dataNetworkName = "testDataNetwork"; + NullableResponse response = await collection.GetIfExistsAsync(dataNetworkName); + MobileDataNetworkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileDataNetworkData resourceData = item.Data; + MobileDataNetworkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileDataNetworkResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileDataNetworkResource.cs index cbd1783729d2b..f009c263c195f 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileDataNetworkResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileDataNetworkResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileDataNetworkResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDataNetwork() + public async Task Get_GetDataNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkDelete.json - // this example is just showing the usage of "DataNetworks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkGet.json + // this example is just showing the usage of "DataNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteDataNetwork() MobileDataNetworkResource mobileDataNetwork = client.GetMobileDataNetworkResource(mobileDataNetworkResourceId); // invoke the operation - await mobileDataNetwork.DeleteAsync(WaitUntil.Completed); + MobileDataNetworkResource result = await mobileDataNetwork.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileDataNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDataNetwork() + public async Task Delete_DeleteDataNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkGet.json - // this example is just showing the usage of "DataNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DataNetworkDelete.json + // this example is just showing the usage of "DataNetworks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetDataNetwork() MobileDataNetworkResource mobileDataNetwork = client.GetMobileDataNetworkResource(mobileDataNetworkResourceId); // invoke the operation - MobileDataNetworkResource result = await mobileDataNetwork.GetAsync(); + await mobileDataNetwork.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileDataNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_UpdateDataNetworkTags() MobileDataNetworkResource mobileDataNetwork = client.GetMobileDataNetworkResource(mobileDataNetworkResourceId); // invoke the operation - MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch() + MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; MobileDataNetworkResource result = await mobileDataNetwork.UpdateAsync(patch); diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkCollection.cs index 15327648b50cc..298be423db2a7 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MobileNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMobileNetwork() + public async Task CreateOrUpdate_CreateMobileNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkGet.json - // this example is just showing the usage of "MobileNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkCreate.json + // this example is just showing the usage of "MobileNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,28 @@ public async Task Get_GetMobileNetwork() // invoke the operation string mobileNetworkName = "testMobileNetwork"; - MobileNetworkResource result = await collection.GetAsync(mobileNetworkName); + MobileNetworkData data = new MobileNetworkData(new AzureLocation("eastus"), new MobileNetworkPlmnId("001", "01")) + { + PublicLandMobileNetworks = {new PublicLandMobileNetwork("001", "01") +{ +HomeNetworkPublicKeys = new PublicLandMobileNetworkHomeNetworkPublicKeys +{ +ProfileA = {new HomeNetworkPublicKey(1) +{ +Uri = new Uri("https://contosovault.vault.azure.net/secrets/exampleHnpk"), +}, new HomeNetworkPublicKey(2) +{ +Uri = new Uri("https://contosovault.vault.azure.net/secrets/exampleHnpk2/5e4876e9140e4e16bfe6e2cf92e0cbd2"), +}}, +ProfileB = {new HomeNetworkPublicKey(1) +{ +Uri = new Uri("https://contosovault.vault.azure.net/secrets/exampleHnpkProfileB"), +}}, +}, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mobileNetworkName, data); + MobileNetworkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +73,7 @@ public async Task Get_GetMobileNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMobileNetwork() + public async Task Get_GetMobileNetwork() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkGet.json // this example is just showing the usage of "MobileNetworks_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +95,21 @@ public async Task Exists_GetMobileNetwork() // invoke the operation string mobileNetworkName = "testMobileNetwork"; - bool result = await collection.ExistsAsync(mobileNetworkName); + MobileNetworkResource result = await collection.GetAsync(mobileNetworkName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMobileNetwork() + public async Task GetAll_ListMobileNetworksInResourceGroup() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkGet.json - // this example is just showing the usage of "MobileNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkListByResourceGroup.json + // this example is just showing the usage of "MobileNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +126,25 @@ public async Task GetIfExists_GetMobileNetwork() // get the collection of this MobileNetworkResource MobileNetworkCollection collection = resourceGroupResource.GetMobileNetworks(); - // invoke the operation - string mobileNetworkName = "testMobileNetwork"; - NullableResponse response = await collection.GetIfExistsAsync(mobileNetworkName); - MobileNetworkResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MobileNetworkResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkData resourceData = result.Data; + MobileNetworkData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateMobileNetwork() + public async Task Exists_GetMobileNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkCreate.json - // this example is just showing the usage of "MobileNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkGet.json + // this example is just showing the usage of "MobileNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,51 +163,17 @@ public async Task CreateOrUpdate_CreateMobileNetwork() // invoke the operation string mobileNetworkName = "testMobileNetwork"; - MobileNetworkData data = new MobileNetworkData(new AzureLocation("eastus"), new MobileNetworkPlmnId("001", "01")) - { - PublicLandMobileNetworks = -{ -new PublicLandMobileNetwork("001","01") -{ -HomeNetworkPublicKeys = new PublicLandMobileNetworkHomeNetworkPublicKeys() -{ -ProfileA = -{ -new HomeNetworkPublicKey(1) -{ -Uri = new Uri("https://contosovault.vault.azure.net/secrets/exampleHnpk"), -},new HomeNetworkPublicKey(2) -{ -Uri = new Uri("https://contosovault.vault.azure.net/secrets/exampleHnpk2/5e4876e9140e4e16bfe6e2cf92e0cbd2"), -} -}, -ProfileB = -{ -new HomeNetworkPublicKey(1) -{ -Uri = new Uri("https://contosovault.vault.azure.net/secrets/exampleHnpkProfileB"), -} -}, -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mobileNetworkName, data); - MobileNetworkResource result = lro.Value; + bool result = await collection.ExistsAsync(mobileNetworkName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListMobileNetworksInResourceGroup() + public async Task GetIfExists_GetMobileNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkListByResourceGroup.json - // this example is just showing the usage of "MobileNetworks_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkGet.json + // this example is just showing the usage of "MobileNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -205,17 +190,23 @@ public async Task GetAll_ListMobileNetworksInResourceGroup() // get the collection of this MobileNetworkResource MobileNetworkCollection collection = resourceGroupResource.GetMobileNetworks(); - // invoke the operation and iterate over the result - await foreach (MobileNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string mobileNetworkName = "testMobileNetwork"; + NullableResponse response = await collection.GetIfExistsAsync(mobileNetworkName); + MobileNetworkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkData resourceData = item.Data; + MobileNetworkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkDiagnosticsPackageCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkDiagnosticsPackageCollection.cs index 2edc0702eb645..9dade6ce5f3e8 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkDiagnosticsPackageCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkDiagnosticsPackageCollection.cs @@ -86,10 +86,10 @@ public async Task Get_GetDiagnosticsPackage() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDiagnosticsPackage() + public async Task GetAll_ListDiagnosticsPackagesUnderAPacketCoreControlPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageGet.json - // this example is just showing the usage of "DiagnosticsPackages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageListByPacketCoreControlPlane.json + // this example is just showing the usage of "DiagnosticsPackages_ListByPacketCoreControlPlane" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +107,22 @@ public async Task Exists_GetDiagnosticsPackage() // get the collection of this MobileNetworkDiagnosticsPackageResource MobileNetworkDiagnosticsPackageCollection collection = packetCoreControlPlane.GetMobileNetworkDiagnosticsPackages(); - // invoke the operation - string diagnosticsPackageName = "dp1"; - bool result = await collection.ExistsAsync(diagnosticsPackageName); + // invoke the operation and iterate over the result + await foreach (MobileNetworkDiagnosticsPackageResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkDiagnosticsPackageData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDiagnosticsPackage() + public async Task Exists_GetDiagnosticsPackage() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageGet.json // this example is just showing the usage of "DiagnosticsPackages_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +145,17 @@ public async Task GetIfExists_GetDiagnosticsPackage() // invoke the operation string diagnosticsPackageName = "dp1"; - NullableResponse response = await collection.GetIfExistsAsync(diagnosticsPackageName); - MobileNetworkDiagnosticsPackageResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(diagnosticsPackageName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkDiagnosticsPackageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDiagnosticsPackagesUnderAPacketCoreControlPlane() + public async Task GetIfExists_GetDiagnosticsPackage() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageListByPacketCoreControlPlane.json - // this example is just showing the usage of "DiagnosticsPackages_ListByPacketCoreControlPlane" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageGet.json + // this example is just showing the usage of "DiagnosticsPackages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_ListDiagnosticsPackagesUnderAPacketCoreControlPlane() // get the collection of this MobileNetworkDiagnosticsPackageResource MobileNetworkDiagnosticsPackageCollection collection = packetCoreControlPlane.GetMobileNetworkDiagnosticsPackages(); - // invoke the operation and iterate over the result - await foreach (MobileNetworkDiagnosticsPackageResource item in collection.GetAllAsync()) + // invoke the operation + string diagnosticsPackageName = "dp1"; + NullableResponse response = await collection.GetIfExistsAsync(diagnosticsPackageName); + MobileNetworkDiagnosticsPackageResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkDiagnosticsPackageData resourceData = item.Data; + MobileNetworkDiagnosticsPackageData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkDiagnosticsPackageResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkDiagnosticsPackageResource.cs index 98b2c0b4a2054..581098d263db5 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkDiagnosticsPackageResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkDiagnosticsPackageResource.cs @@ -17,10 +17,10 @@ public partial class Sample_MobileNetworkDiagnosticsPackageResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateDiagnosticsPackage() + public async Task Get_GetDiagnosticsPackage() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageCreate.json - // this example is just showing the usage of "DiagnosticsPackages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageGet.json + // this example is just showing the usage of "DiagnosticsPackages_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,8 +37,7 @@ public async Task Update_CreateDiagnosticsPackage() MobileNetworkDiagnosticsPackageResource mobileNetworkDiagnosticsPackage = client.GetMobileNetworkDiagnosticsPackageResource(mobileNetworkDiagnosticsPackageResourceId); // invoke the operation - ArmOperation lro = await mobileNetworkDiagnosticsPackage.UpdateAsync(WaitUntil.Completed); - MobileNetworkDiagnosticsPackageResource result = lro.Value; + MobileNetworkDiagnosticsPackageResource result = await mobileNetworkDiagnosticsPackage.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,10 +48,10 @@ public async Task Update_CreateDiagnosticsPackage() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDiagnosticsPackage() + public async Task Delete_DeleteDiagnosticsPackage() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageGet.json - // this example is just showing the usage of "DiagnosticsPackages_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageDelete.json + // this example is just showing the usage of "DiagnosticsPackages_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,21 +68,17 @@ public async Task Get_GetDiagnosticsPackage() MobileNetworkDiagnosticsPackageResource mobileNetworkDiagnosticsPackage = client.GetMobileNetworkDiagnosticsPackageResource(mobileNetworkDiagnosticsPackageResourceId); // invoke the operation - MobileNetworkDiagnosticsPackageResource result = await mobileNetworkDiagnosticsPackage.GetAsync(); + await mobileNetworkDiagnosticsPackage.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkDiagnosticsPackageData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDiagnosticsPackage() + public async Task Update_CreateDiagnosticsPackage() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageDelete.json - // this example is just showing the usage of "DiagnosticsPackages_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/DiagnosticsPackageCreate.json + // this example is just showing the usage of "DiagnosticsPackages_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,9 +95,14 @@ public async Task Delete_DeleteDiagnosticsPackage() MobileNetworkDiagnosticsPackageResource mobileNetworkDiagnosticsPackage = client.GetMobileNetworkDiagnosticsPackageResource(mobileNetworkDiagnosticsPackageResourceId); // invoke the operation - await mobileNetworkDiagnosticsPackage.DeleteAsync(WaitUntil.Completed); + ArmOperation lro = await mobileNetworkDiagnosticsPackage.UpdateAsync(WaitUntil.Completed); + MobileNetworkDiagnosticsPackageResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkDiagnosticsPackageData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkPacketCaptureCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkPacketCaptureCollection.cs index 674124259a345..a3e5615db10d9 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkPacketCaptureCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkPacketCaptureCollection.cs @@ -40,12 +40,9 @@ public async Task CreateOrUpdate_CreatePacketCapture() // invoke the operation string packetCaptureName = "pc1"; - MobileNetworkPacketCaptureData data = new MobileNetworkPacketCaptureData() + MobileNetworkPacketCaptureData data = new MobileNetworkPacketCaptureData { - NetworkInterfaces = -{ -"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP","/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP","/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestADN" -}, + NetworkInterfaces = { "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP", "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP", "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestADN" }, BytesToCapturePerPacket = 10000L, TotalBytesPerSession = 100000L, TimeLimitInSeconds = 100, @@ -96,10 +93,10 @@ public async Task Get_GetPacketCaptureSession() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPacketCaptureSession() + public async Task GetAll_ListPacketCaptureSessionsUnderAPacketCoreControlPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureGet.json - // this example is just showing the usage of "PacketCaptures_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureListByPacketCoreControlPlane.json + // this example is just showing the usage of "PacketCaptures_ListByPacketCoreControlPlane" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,16 +114,22 @@ public async Task Exists_GetPacketCaptureSession() // get the collection of this MobileNetworkPacketCaptureResource MobileNetworkPacketCaptureCollection collection = packetCoreControlPlane.GetMobileNetworkPacketCaptures(); - // invoke the operation - string packetCaptureName = "pc1"; - bool result = await collection.ExistsAsync(packetCaptureName); + // invoke the operation and iterate over the result + await foreach (MobileNetworkPacketCaptureResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkPacketCaptureData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPacketCaptureSession() + public async Task Exists_GetPacketCaptureSession() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureGet.json // this example is just showing the usage of "PacketCaptures_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +152,17 @@ public async Task GetIfExists_GetPacketCaptureSession() // invoke the operation string packetCaptureName = "pc1"; - NullableResponse response = await collection.GetIfExistsAsync(packetCaptureName); - MobileNetworkPacketCaptureResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(packetCaptureName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkPacketCaptureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPacketCaptureSessionsUnderAPacketCoreControlPlane() + public async Task GetIfExists_GetPacketCaptureSession() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureListByPacketCoreControlPlane.json - // this example is just showing the usage of "PacketCaptures_ListByPacketCoreControlPlane" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureGet.json + // this example is just showing the usage of "PacketCaptures_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +180,23 @@ public async Task GetAll_ListPacketCaptureSessionsUnderAPacketCoreControlPlane() // get the collection of this MobileNetworkPacketCaptureResource MobileNetworkPacketCaptureCollection collection = packetCoreControlPlane.GetMobileNetworkPacketCaptures(); - // invoke the operation and iterate over the result - await foreach (MobileNetworkPacketCaptureResource item in collection.GetAllAsync()) + // invoke the operation + string packetCaptureName = "pc1"; + NullableResponse response = await collection.GetIfExistsAsync(packetCaptureName); + MobileNetworkPacketCaptureResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkPacketCaptureData resourceData = item.Data; + MobileNetworkPacketCaptureData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkPacketCaptureResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkPacketCaptureResource.cs index dd65221fdc294..12a849a9aa9a7 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkPacketCaptureResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkPacketCaptureResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileNetworkPacketCaptureResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatePacketCapture() + public async Task Get_GetPacketCaptureSession() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureCreate.json - // this example is just showing the usage of "PacketCaptures_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureGet.json + // this example is just showing the usage of "PacketCaptures_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,18 +38,7 @@ public async Task Update_CreatePacketCapture() MobileNetworkPacketCaptureResource mobileNetworkPacketCapture = client.GetMobileNetworkPacketCaptureResource(mobileNetworkPacketCaptureResourceId); // invoke the operation - MobileNetworkPacketCaptureData data = new MobileNetworkPacketCaptureData() - { - NetworkInterfaces = -{ -"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP","/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP","/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestADN" -}, - BytesToCapturePerPacket = 10000L, - TotalBytesPerSession = 100000L, - TimeLimitInSeconds = 100, - }; - ArmOperation lro = await mobileNetworkPacketCapture.UpdateAsync(WaitUntil.Completed, data); - MobileNetworkPacketCaptureResource result = lro.Value; + MobileNetworkPacketCaptureResource result = await mobileNetworkPacketCapture.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -60,10 +49,10 @@ public async Task Update_CreatePacketCapture() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPacketCaptureSession() + public async Task Delete_DeletePacketCapture() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureGet.json - // this example is just showing the usage of "PacketCaptures_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureDelete.json + // this example is just showing the usage of "PacketCaptures_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -80,21 +69,17 @@ public async Task Get_GetPacketCaptureSession() MobileNetworkPacketCaptureResource mobileNetworkPacketCapture = client.GetMobileNetworkPacketCaptureResource(mobileNetworkPacketCaptureResourceId); // invoke the operation - MobileNetworkPacketCaptureResource result = await mobileNetworkPacketCapture.GetAsync(); + await mobileNetworkPacketCapture.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkPacketCaptureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePacketCapture() + public async Task Update_CreatePacketCapture() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureDelete.json - // this example is just showing the usage of "PacketCaptures_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCaptureCreate.json + // this example is just showing the usage of "PacketCaptures_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +96,21 @@ public async Task Delete_DeletePacketCapture() MobileNetworkPacketCaptureResource mobileNetworkPacketCapture = client.GetMobileNetworkPacketCaptureResource(mobileNetworkPacketCaptureResourceId); // invoke the operation - await mobileNetworkPacketCapture.DeleteAsync(WaitUntil.Completed); + MobileNetworkPacketCaptureData data = new MobileNetworkPacketCaptureData + { + NetworkInterfaces = { "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP", "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP", "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestADN" }, + BytesToCapturePerPacket = 10000L, + TotalBytesPerSession = 100000L, + TimeLimitInSeconds = 100, + }; + ArmOperation lro = await mobileNetworkPacketCapture.UpdateAsync(WaitUntil.Completed, data); + MobileNetworkPacketCaptureResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkPacketCaptureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkResource.cs index dfd0d0d3d264a..29dd0cfadf952 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.MobileNetwork.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MobileNetwork.Samples @@ -19,10 +18,10 @@ public partial class Sample_MobileNetworkResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteMobileNetwork() + public async Task Get_GetMobileNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkDelete.json - // this example is just showing the usage of "MobileNetworks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkGet.json + // this example is just showing the usage of "MobileNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteMobileNetwork() MobileNetworkResource mobileNetwork = client.GetMobileNetworkResource(mobileNetworkResourceId); // invoke the operation - await mobileNetwork.DeleteAsync(WaitUntil.Completed); + MobileNetworkResource result = await mobileNetwork.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMobileNetwork() + public async Task Delete_DeleteMobileNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkGet.json - // this example is just showing the usage of "MobileNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkDelete.json + // this example is just showing the usage of "MobileNetworks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetMobileNetwork() MobileNetworkResource mobileNetwork = client.GetMobileNetworkResource(mobileNetworkResourceId); // invoke the operation - MobileNetworkResource result = await mobileNetwork.GetAsync(); + await mobileNetwork.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateMobileNetworkTags() MobileNetworkResource mobileNetwork = client.GetMobileNetworkResource(mobileNetworkResourceId); // invoke the operation - MobileNetworkResourcePatch patch = new MobileNetworkResourcePatch() + MobileNetworkResourcePatch patch = new MobileNetworkResourcePatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; MobileNetworkResource result = await mobileNetwork.UpdateAsync(patch); @@ -111,37 +110,6 @@ public async Task Update_UpdateMobileNetworkTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMobileNetworks_ListMobileNetworksInASubscription() - { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkListBySubscription.json - // this example is just showing the usage of "MobileNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MobileNetworkResource item in subscriptionResource.GetMobileNetworksAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetSimGroups_ListSIMGroupsInAMobileNetwork() diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkServiceCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkServiceCollection.cs index 125b267904117..d86c0bed8dc38 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkServiceCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkServiceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileNetworkServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetService() + public async Task CreateOrUpdate_CreateService() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceGet.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceCreate.json + // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,37 @@ public async Task Get_GetService() // invoke the operation string serviceName = "TestService"; - MobileNetworkServiceResource result = await collection.GetAsync(serviceName); + MobileNetworkServiceData data = new MobileNetworkServiceData(new AzureLocation("eastus"), 255, new PccRuleConfiguration[] + { +new PccRuleConfiguration("default-rule", 255, new MobileNetworkServiceDataFlowTemplate[] +{ +new MobileNetworkServiceDataFlowTemplate("IP-to-server", MobileNetworkSdfDirectionS.Uplink, new string[]{"ip"}, new string[]{"10.3.4.0/24"}) +{ +Ports = {}, +} +}) +{ +RuleQosPolicy = new PccRuleQosPolicy(new Ambr("500 Mbps", "1 Gbps")) +{ +FiveQi = 9, +AllocationAndRetentionPriorityLevel = 9, +PreemptionCapability = MobileNetworkPreemptionCapability.NotPreempt, +PreemptionVulnerability = MobileNetworkPreemptionVulnerability.Preemptable, +}, +TrafficControl = MobileNetworkTrafficControlPermission.Enabled, +} + }) + { + ServiceQosPolicy = new MobileNetworkQosPolicy(new Ambr("500 Mbps", "1 Gbps")) + { + FiveQi = 9, + AllocationAndRetentionPriorityLevel = 9, + PreemptionCapability = MobileNetworkPreemptionCapability.NotPreempt, + PreemptionVulnerability = MobileNetworkPreemptionVulnerability.Preemptable, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); + MobileNetworkServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +82,7 @@ public async Task Get_GetService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetService() + public async Task Get_GetService() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceGet.json // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +105,21 @@ public async Task Exists_GetService() // invoke the operation string serviceName = "TestService"; - bool result = await collection.ExistsAsync(serviceName); + MobileNetworkServiceResource result = await collection.GetAsync(serviceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetService() + public async Task GetAll_ListServicesInAMobileNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceGet.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceListByMobileNetwork.json + // this example is just showing the usage of "Services_ListByMobileNetwork" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,7 +129,7 @@ public async Task GetIfExists_GetService() // this example assumes you already have this MobileNetworkResource created on azure // for more information of creating MobileNetworkResource, please refer to the document of MobileNetworkResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; + string resourceGroupName = "testResourceGroupName"; string mobileNetworkName = "testMobileNetwork"; ResourceIdentifier mobileNetworkResourceId = MobileNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, mobileNetworkName); MobileNetworkResource mobileNetwork = client.GetMobileNetworkResource(mobileNetworkResourceId); @@ -103,31 +137,25 @@ public async Task GetIfExists_GetService() // get the collection of this MobileNetworkServiceResource MobileNetworkServiceCollection collection = mobileNetwork.GetMobileNetworkServices(); - // invoke the operation - string serviceName = "TestService"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - MobileNetworkServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MobileNetworkServiceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkServiceData resourceData = result.Data; + MobileNetworkServiceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateService() + public async Task Exists_GetService() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceCreate.json - // this example is just showing the usage of "Services_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceGet.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,59 +175,17 @@ public async Task CreateOrUpdate_CreateService() // invoke the operation string serviceName = "TestService"; - MobileNetworkServiceData data = new MobileNetworkServiceData(new AzureLocation("eastus"), 255, new PccRuleConfiguration[] - { -new PccRuleConfiguration("default-rule",255,new MobileNetworkServiceDataFlowTemplate[] -{ -new MobileNetworkServiceDataFlowTemplate("IP-to-server",MobileNetworkSdfDirectionS.Uplink,new string[] -{ -"ip" -},new string[] -{ -"10.3.4.0/24" -}) -{ -Ports = -{ -}, -} -}) -{ -RuleQosPolicy = new PccRuleQosPolicy(new Ambr("500 Mbps","1 Gbps")) -{ -FiveQi = 9, -AllocationAndRetentionPriorityLevel = 9, -PreemptionCapability = MobileNetworkPreemptionCapability.NotPreempt, -PreemptionVulnerability = MobileNetworkPreemptionVulnerability.Preemptable, -}, -TrafficControl = MobileNetworkTrafficControlPermission.Enabled, -} - }) - { - ServiceQosPolicy = new MobileNetworkQosPolicy(new Ambr("500 Mbps", "1 Gbps")) - { - FiveQi = 9, - AllocationAndRetentionPriorityLevel = 9, - PreemptionCapability = MobileNetworkPreemptionCapability.NotPreempt, - PreemptionVulnerability = MobileNetworkPreemptionVulnerability.Preemptable, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); - MobileNetworkServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(serviceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListServicesInAMobileNetwork() + public async Task GetIfExists_GetService() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceListByMobileNetwork.json - // this example is just showing the usage of "Services_ListByMobileNetwork" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceGet.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -209,7 +195,7 @@ public async Task GetAll_ListServicesInAMobileNetwork() // this example assumes you already have this MobileNetworkResource created on azure // for more information of creating MobileNetworkResource, please refer to the document of MobileNetworkResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "testResourceGroupName"; + string resourceGroupName = "rg1"; string mobileNetworkName = "testMobileNetwork"; ResourceIdentifier mobileNetworkResourceId = MobileNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, mobileNetworkName); MobileNetworkResource mobileNetwork = client.GetMobileNetworkResource(mobileNetworkResourceId); @@ -217,17 +203,23 @@ public async Task GetAll_ListServicesInAMobileNetwork() // get the collection of this MobileNetworkServiceResource MobileNetworkServiceCollection collection = mobileNetwork.GetMobileNetworkServices(); - // invoke the operation and iterate over the result - await foreach (MobileNetworkServiceResource item in collection.GetAllAsync()) + // invoke the operation + string serviceName = "TestService"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + MobileNetworkServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkServiceData resourceData = item.Data; + MobileNetworkServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkServiceResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkServiceResource.cs index aad79f2353666..72dd3fee3f271 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkServiceResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkServiceResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileNetworkServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteService() + public async Task Get_GetService() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceDelete.json - // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceGet.json + // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteService() MobileNetworkServiceResource mobileNetworkService = client.GetMobileNetworkServiceResource(mobileNetworkServiceResourceId); // invoke the operation - await mobileNetworkService.DeleteAsync(WaitUntil.Completed); + MobileNetworkServiceResource result = await mobileNetworkService.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetService() + public async Task Delete_DeleteService() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceGet.json - // this example is just showing the usage of "Services_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/ServiceDelete.json + // this example is just showing the usage of "Services_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetService() MobileNetworkServiceResource mobileNetworkService = client.GetMobileNetworkServiceResource(mobileNetworkServiceResourceId); // invoke the operation - MobileNetworkServiceResource result = await mobileNetworkService.GetAsync(); + await mobileNetworkService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_UpdateServiceTags() MobileNetworkServiceResource mobileNetworkService = client.GetMobileNetworkServiceResource(mobileNetworkServiceResourceId); // invoke the operation - MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch() + MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; MobileNetworkServiceResource result = await mobileNetworkService.UpdateAsync(patch); diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimCollection.cs index a19b401b2540d..03701e8ed8406 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileNetworkSimCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSIM() + public async Task CreateOrUpdate_CreateSIM() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGet.json - // this example is just showing the usage of "Sims_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimCreate.json + // this example is just showing the usage of "Sims_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,7 +31,7 @@ public async Task Get_GetSIM() // this example assumes you already have this MobileNetworkSimGroupResource created on azure // for more information of creating MobileNetworkSimGroupResource, please refer to the document of MobileNetworkSimGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "testResourceGroupName"; + string resourceGroupName = "rg1"; string simGroupName = "testSimGroup"; ResourceIdentifier mobileNetworkSimGroupResourceId = MobileNetworkSimGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName); MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); @@ -40,8 +40,23 @@ public async Task Get_GetSIM() MobileNetworkSimCollection collection = mobileNetworkSimGroup.GetMobileNetworkSims(); // invoke the operation - string simName = "testSimName"; - MobileNetworkSimResource result = await collection.GetAsync(simName); + string simName = "testSim"; + MobileNetworkSimData data = new MobileNetworkSimData("00000") + { + IntegratedCircuitCardIdentifier = "8900000000000000000", + DeviceType = "Video camera", + SimPolicyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy"), + StaticIPConfiguration = {new SimStaticIPProperties +{ +AttachedDataNetworkId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), +SliceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), +StaticIPIPv4Address = "2.4.0.1", +}}, + AuthenticationKey = "00000000000000000000000000000000", + OperatorKeyCode = "00000000000000000000000000000000", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, simName, data); + MobileNetworkSimResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +67,7 @@ public async Task Get_GetSIM() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSIM() + public async Task Get_GetSIM() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGet.json // this example is just showing the usage of "Sims_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +90,21 @@ public async Task Exists_GetSIM() // invoke the operation string simName = "testSimName"; - bool result = await collection.ExistsAsync(simName); + MobileNetworkSimResource result = await collection.GetAsync(simName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSimData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSIM() + public async Task GetAll_ListSIMsInASIMGroup() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGet.json - // this example is just showing the usage of "Sims_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimListBySimGroup.json + // this example is just showing the usage of "Sims_ListByGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,7 +114,7 @@ public async Task GetIfExists_GetSIM() // this example assumes you already have this MobileNetworkSimGroupResource created on azure // for more information of creating MobileNetworkSimGroupResource, please refer to the document of MobileNetworkSimGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "testResourceGroupName"; + string resourceGroupName = "rg1"; string simGroupName = "testSimGroup"; ResourceIdentifier mobileNetworkSimGroupResourceId = MobileNetworkSimGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName); MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); @@ -103,31 +122,25 @@ public async Task GetIfExists_GetSIM() // get the collection of this MobileNetworkSimResource MobileNetworkSimCollection collection = mobileNetworkSimGroup.GetMobileNetworkSims(); - // invoke the operation - string simName = "testSimName"; - NullableResponse response = await collection.GetIfExistsAsync(simName); - MobileNetworkSimResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MobileNetworkSimResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkSimData resourceData = result.Data; + MobileNetworkSimData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSIM() + public async Task Exists_GetSIM() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimCreate.json - // this example is just showing the usage of "Sims_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGet.json + // this example is just showing the usage of "Sims_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,7 +150,7 @@ public async Task CreateOrUpdate_CreateSIM() // this example assumes you already have this MobileNetworkSimGroupResource created on azure // for more information of creating MobileNetworkSimGroupResource, please refer to the document of MobileNetworkSimGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; + string resourceGroupName = "testResourceGroupName"; string simGroupName = "testSimGroup"; ResourceIdentifier mobileNetworkSimGroupResourceId = MobileNetworkSimGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName); MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); @@ -146,40 +159,18 @@ public async Task CreateOrUpdate_CreateSIM() MobileNetworkSimCollection collection = mobileNetworkSimGroup.GetMobileNetworkSims(); // invoke the operation - string simName = "testSim"; - MobileNetworkSimData data = new MobileNetworkSimData("00000") - { - IntegratedCircuitCardIdentifier = "8900000000000000000", - DeviceType = "Video camera", - SimPolicyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy"), - StaticIPConfiguration = -{ -new SimStaticIPProperties() -{ -AttachedDataNetworkId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), -SliceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), -StaticIPIPv4Address = "2.4.0.1", -} -}, - AuthenticationKey = "00000000000000000000000000000000", - OperatorKeyCode = "00000000000000000000000000000000", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, simName, data); - MobileNetworkSimResource result = lro.Value; + string simName = "testSimName"; + bool result = await collection.ExistsAsync(simName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSimData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSIMsInASIMGroup() + public async Task GetIfExists_GetSIM() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimListBySimGroup.json - // this example is just showing the usage of "Sims_ListByGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGet.json + // this example is just showing the usage of "Sims_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,7 +180,7 @@ public async Task GetAll_ListSIMsInASIMGroup() // this example assumes you already have this MobileNetworkSimGroupResource created on azure // for more information of creating MobileNetworkSimGroupResource, please refer to the document of MobileNetworkSimGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; + string resourceGroupName = "testResourceGroupName"; string simGroupName = "testSimGroup"; ResourceIdentifier mobileNetworkSimGroupResourceId = MobileNetworkSimGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName); MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); @@ -197,17 +188,23 @@ public async Task GetAll_ListSIMsInASIMGroup() // get the collection of this MobileNetworkSimResource MobileNetworkSimCollection collection = mobileNetworkSimGroup.GetMobileNetworkSims(); - // invoke the operation and iterate over the result - await foreach (MobileNetworkSimResource item in collection.GetAllAsync()) + // invoke the operation + string simName = "testSimName"; + NullableResponse response = await collection.GetIfExistsAsync(simName); + MobileNetworkSimResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkSimData resourceData = item.Data; + MobileNetworkSimData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimGroupCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimGroupCollection.cs index 1165c9272954f..3c509528e35bf 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimGroupCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimGroupCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_MobileNetworkSimGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSIMGroup() + public async Task CreateOrUpdate_CreateSIMGroup() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupGet.json - // this example is just showing the usage of "SimGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupCreate.json + // this example is just showing the usage of "SimGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,7 +33,7 @@ public async Task Get_GetSIMGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "testResourceGroupName"; + string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -41,8 +41,21 @@ public async Task Get_GetSIMGroup() MobileNetworkSimGroupCollection collection = resourceGroupResource.GetMobileNetworkSimGroups(); // invoke the operation - string simGroupName = "testSimGroupName"; - MobileNetworkSimGroupResource result = await collection.GetAsync(simGroupName); + string simGroupName = "testSimGroup"; + MobileNetworkSimGroupData data = new MobileNetworkSimGroupData(new AzureLocation("eastus")) + { + UserAssignedIdentity = new MobileNetworkManagedServiceIdentity(MobileNetworkManagedServiceIdentityType.UserAssigned) + { + UserAssignedIdentities = +{ +["/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity"] = new UserAssignedIdentity() +}, + }, + KeyUri = new Uri("https://contosovault.vault.azure.net/keys/azureKey"), + MobileNetworkId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, simGroupName, data); + MobileNetworkSimGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +66,7 @@ public async Task Get_GetSIMGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSIMGroup() + public async Task Get_GetSIMGroup() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupGet.json // this example is just showing the usage of "SimGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +88,21 @@ public async Task Exists_GetSIMGroup() // invoke the operation string simGroupName = "testSimGroupName"; - bool result = await collection.ExistsAsync(simGroupName); + MobileNetworkSimGroupResource result = await collection.GetAsync(simGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSimGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSIMGroup() + public async Task GetAll_ListSIMGroupsInAResourceGroup() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupGet.json - // this example is just showing the usage of "SimGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupListByResourceGroup.json + // this example is just showing the usage of "SimGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,38 +112,32 @@ public async Task GetIfExists_GetSIMGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "testResourceGroupName"; + string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this MobileNetworkSimGroupResource MobileNetworkSimGroupCollection collection = resourceGroupResource.GetMobileNetworkSimGroups(); - // invoke the operation - string simGroupName = "testSimGroupName"; - NullableResponse response = await collection.GetIfExistsAsync(simGroupName); - MobileNetworkSimGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MobileNetworkSimGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkSimGroupData resourceData = result.Data; + MobileNetworkSimGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSIMGroup() + public async Task Exists_GetSIMGroup() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupCreate.json - // this example is just showing the usage of "SimGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupGet.json + // this example is just showing the usage of "SimGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,7 +147,7 @@ public async Task CreateOrUpdate_CreateSIMGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; + string resourceGroupName = "testResourceGroupName"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -144,35 +155,18 @@ public async Task CreateOrUpdate_CreateSIMGroup() MobileNetworkSimGroupCollection collection = resourceGroupResource.GetMobileNetworkSimGroups(); // invoke the operation - string simGroupName = "testSimGroup"; - MobileNetworkSimGroupData data = new MobileNetworkSimGroupData(new AzureLocation("eastus")) - { - UserAssignedIdentity = new MobileNetworkManagedServiceIdentity(MobileNetworkManagedServiceIdentityType.UserAssigned) - { - UserAssignedIdentities = -{ -["/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity"] = new UserAssignedIdentity(), -}, - }, - KeyUri = new Uri("https://contosovault.vault.azure.net/keys/azureKey"), - MobileNetworkId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, simGroupName, data); - MobileNetworkSimGroupResource result = lro.Value; + string simGroupName = "testSimGroupName"; + bool result = await collection.ExistsAsync(simGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSimGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSIMGroupsInAResourceGroup() + public async Task GetIfExists_GetSIMGroup() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupListByResourceGroup.json - // this example is just showing the usage of "SimGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupGet.json + // this example is just showing the usage of "SimGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,24 +176,30 @@ public async Task GetAll_ListSIMGroupsInAResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; + string resourceGroupName = "testResourceGroupName"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this MobileNetworkSimGroupResource MobileNetworkSimGroupCollection collection = resourceGroupResource.GetMobileNetworkSimGroups(); - // invoke the operation and iterate over the result - await foreach (MobileNetworkSimGroupResource item in collection.GetAllAsync()) + // invoke the operation + string simGroupName = "testSimGroupName"; + NullableResponse response = await collection.GetIfExistsAsync(simGroupName); + MobileNetworkSimGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkSimGroupData resourceData = item.Data; + MobileNetworkSimGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimGroupResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimGroupResource.cs index 0d97b1401df3a..0cc717abf138f 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimGroupResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimGroupResource.cs @@ -11,13 +11,113 @@ using Azure.Identity; using Azure.ResourceManager.MobileNetwork.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MobileNetwork.Samples { public partial class Sample_MobileNetworkSimGroupResource { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetSIMGroup() + { + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupGet.json + // this example is just showing the usage of "SimGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MobileNetworkSimGroupResource created on azure + // for more information of creating MobileNetworkSimGroupResource, please refer to the document of MobileNetworkSimGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "testResourceGroupName"; + string simGroupName = "testSimGroupName"; + ResourceIdentifier mobileNetworkSimGroupResourceId = MobileNetworkSimGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName); + MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); + + // invoke the operation + MobileNetworkSimGroupResource result = await mobileNetworkSimGroup.GetAsync(); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSimGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteSIMGroup() + { + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupDelete.json + // this example is just showing the usage of "SimGroups_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MobileNetworkSimGroupResource created on azure + // for more information of creating MobileNetworkSimGroupResource, please refer to the document of MobileNetworkSimGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "testResourceGroupName"; + string simGroupName = "testSimGroup"; + ResourceIdentifier mobileNetworkSimGroupResourceId = MobileNetworkSimGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName); + MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); + + // invoke the operation + await mobileNetworkSimGroup.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Update_PatchSIMGroup() + { + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupPatch.json + // this example is just showing the usage of "SimGroups_UpdateTags" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MobileNetworkSimGroupResource created on azure + // for more information of creating MobileNetworkSimGroupResource, please refer to the document of MobileNetworkSimGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string simGroupName = "testSimGroup"; + ResourceIdentifier mobileNetworkSimGroupResourceId = MobileNetworkSimGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName); + MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); + + // invoke the operation + MobileNetworkResourcePatch patch = new MobileNetworkResourcePatch + { + UserAssignedIdentity = new MobileNetworkManagedServiceIdentity(MobileNetworkManagedServiceIdentityType.UserAssigned) + { + UserAssignedIdentities = +{ +["/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity"] = new UserAssignedIdentity() +}, + }, + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + MobileNetworkSimGroupResource result = await mobileNetworkSimGroup.UpdateAsync(patch); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSimGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task BulkUploadSim_BulkUploadSIMsInASIMGroup() @@ -41,36 +141,31 @@ public async Task BulkUploadSim_BulkUploadSIMsInASIMGroup() // invoke the operation SimUploadList simUploadList = new SimUploadList(new SimNameAndProperties[] { -new SimNameAndProperties("testSim","00000") +new SimNameAndProperties("testSim", "00000") { IntegratedCircuitCardIdentifier = "8900000000000000000", DeviceType = "Video camera", SimPolicyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy"), -StaticIPConfiguration = -{ -new SimStaticIPProperties() +StaticIPConfiguration = {new SimStaticIPProperties { AttachedDataNetworkId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), SliceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), StaticIPIPv4Address = "2.4.0.1", -} -}, +}}, AuthenticationKey = "00000000000000000000000000000000", OperatorKeyCode = "00000000000000000000000000000000", -},new SimNameAndProperties("testSim2","00000") +}, +new SimNameAndProperties("testSim2", "00000") { IntegratedCircuitCardIdentifier = "8900000000000000001", DeviceType = "Video camera", SimPolicyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy"), -StaticIPConfiguration = -{ -new SimStaticIPProperties() +StaticIPConfiguration = {new SimStaticIPProperties { AttachedDataNetworkId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), SliceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), StaticIPIPv4Address = "2.4.0.2", -} -}, +}}, AuthenticationKey = "00000000000000000000000000000000", OperatorKeyCode = "00000000000000000000000000000000", } @@ -102,10 +197,7 @@ public async Task BulkDeleteSim_BulkDeleteSIMsFromASIMGroup() MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); // invoke the operation - SimDeleteList simDeleteList = new SimDeleteList(new string[] - { -"testSim","testSim2" - }); + SimDeleteList simDeleteList = new SimDeleteList(new string[] { "testSim", "testSim2" }); ArmOperation lro = await mobileNetworkSimGroup.BulkDeleteSimAsync(WaitUntil.Completed, simDeleteList); AsyncOperationStatus result = lro.Value; @@ -133,37 +225,38 @@ public async Task BulkUploadEncryptedSim_BulkUploadEncryptedSIMsToASIMGroup() MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); // invoke the operation - EncryptedSimUploadList encryptedSimUploadList = new EncryptedSimUploadList(1, 1, "ABC123", "ABC123", "ABC123", new SimNameAndEncryptedProperties[] + EncryptedSimUploadList encryptedSimUploadList = new EncryptedSimUploadList( + 1, + 1, + "ABC123", + "ABC123", + "ABC123", + new SimNameAndEncryptedProperties[] { -new SimNameAndEncryptedProperties("testSim","00000") +new SimNameAndEncryptedProperties("testSim", "00000") { IntegratedCircuitCardIdentifier = "8900000000000000000", DeviceType = "Video camera", SimPolicyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy"), -StaticIPConfiguration = -{ -new SimStaticIPProperties() +StaticIPConfiguration = {new SimStaticIPProperties { AttachedDataNetworkId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), SliceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), StaticIPIPv4Address = "2.4.0.1", -} -}, +}}, EncryptedCredentials = "ABC123", -},new SimNameAndEncryptedProperties("testSim2","00000") +}, +new SimNameAndEncryptedProperties("testSim2", "00000") { IntegratedCircuitCardIdentifier = "8900000000000000001", DeviceType = "Video camera", SimPolicyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy"), -StaticIPConfiguration = -{ -new SimStaticIPProperties() +StaticIPConfiguration = {new SimStaticIPProperties { AttachedDataNetworkId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), SliceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), StaticIPIPv4Address = "2.4.0.2", -} -}, +}}, EncryptedCredentials = "ABC123", } }); @@ -194,12 +287,9 @@ public async Task MoveSim_MoveListOfSIMsToTargetSIMGroup() MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); // invoke the operation - SimMoveContent content = new SimMoveContent() + SimMoveContent content = new SimMoveContent { - Sims = -{ -"testSim","testSim2" -}, + Sims = { "testSim", "testSim2" }, }; ArmOperation lro = await mobileNetworkSimGroup.MoveSimAsync(WaitUntil.Completed, content); AsyncOperationStatus result = lro.Value; @@ -228,149 +318,14 @@ public async Task CloneSim_CloneListOfSIMsToTargetSIMGroup() MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); // invoke the operation - SimCloneContent content = new SimCloneContent() + SimCloneContent content = new SimCloneContent { - Sims = -{ -"testSim","testSim2" -}, + Sims = { "testSim", "testSim2" }, }; ArmOperation lro = await mobileNetworkSimGroup.CloneSimAsync(WaitUntil.Completed, content); AsyncOperationStatus result = lro.Value; Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSIMGroup() - { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupDelete.json - // this example is just showing the usage of "SimGroups_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MobileNetworkSimGroupResource created on azure - // for more information of creating MobileNetworkSimGroupResource, please refer to the document of MobileNetworkSimGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "testResourceGroupName"; - string simGroupName = "testSimGroup"; - ResourceIdentifier mobileNetworkSimGroupResourceId = MobileNetworkSimGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName); - MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); - - // invoke the operation - await mobileNetworkSimGroup.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetSIMGroup() - { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupGet.json - // this example is just showing the usage of "SimGroups_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MobileNetworkSimGroupResource created on azure - // for more information of creating MobileNetworkSimGroupResource, please refer to the document of MobileNetworkSimGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "testResourceGroupName"; - string simGroupName = "testSimGroupName"; - ResourceIdentifier mobileNetworkSimGroupResourceId = MobileNetworkSimGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName); - MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); - - // invoke the operation - MobileNetworkSimGroupResource result = await mobileNetworkSimGroup.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSimGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_PatchSIMGroup() - { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupPatch.json - // this example is just showing the usage of "SimGroups_UpdateTags" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MobileNetworkSimGroupResource created on azure - // for more information of creating MobileNetworkSimGroupResource, please refer to the document of MobileNetworkSimGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string simGroupName = "testSimGroup"; - ResourceIdentifier mobileNetworkSimGroupResourceId = MobileNetworkSimGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName); - MobileNetworkSimGroupResource mobileNetworkSimGroup = client.GetMobileNetworkSimGroupResource(mobileNetworkSimGroupResourceId); - - // invoke the operation - MobileNetworkResourcePatch patch = new MobileNetworkResourcePatch() - { - UserAssignedIdentity = new MobileNetworkManagedServiceIdentity(MobileNetworkManagedServiceIdentityType.UserAssigned) - { - UserAssignedIdentities = -{ -["/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity"] = new UserAssignedIdentity(), -}, - }, - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - MobileNetworkSimGroupResource result = await mobileNetworkSimGroup.UpdateAsync(patch); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSimGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMobileNetworkSimGroups_ListSIMGroupsInASubscription() - { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupListBySubscription.json - // this example is just showing the usage of "SimGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MobileNetworkSimGroupResource item in subscriptionResource.GetMobileNetworkSimGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSimGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimPolicyCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimPolicyCollection.cs index 5606a3ea7a6dc..2d2c9c1109114 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimPolicyCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimPolicyCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MobileNetworkSimPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSIMPolicy() + public async Task CreateOrUpdate_CreateSIMPolicy() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyGet.json - // this example is just showing the usage of "SimPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyCreate.json + // this example is just showing the usage of "SimPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,45 @@ public async Task Get_GetSIMPolicy() // invoke the operation string simPolicyName = "testPolicy"; - MobileNetworkSimPolicyResource result = await collection.GetAsync(simPolicyName); + MobileNetworkSimPolicyData data = new MobileNetworkSimPolicyData(new AzureLocation("eastus"), new Ambr("500 Mbps", "1 Gbps"), new WritableSubResource + { + Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), + }, new MobileNetworkSliceConfiguration[] + { +new MobileNetworkSliceConfiguration(new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), +}, new DataNetworkConfiguration[] +{ +new DataNetworkConfiguration(new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), +}, new Ambr("500 Mbps", "1 Gbps"), new WritableSubResource[] +{ +new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/testService"), +} +}) +{ +FiveQi = 9, +AllocationAndRetentionPriorityLevel = 9, +PreemptionCapability = MobileNetworkPreemptionCapability.NotPreempt, +PreemptionVulnerability = MobileNetworkPreemptionVulnerability.Preemptable, +DefaultSessionType = MobileNetworkPduSessionType.IPv4, +AdditionalAllowedSessionTypes = {}, +MaximumNumberOfBufferedPackets = 200, +} +}) + }) + { + RegistrationTimer = 3240, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, simPolicyName, data); + MobileNetworkSimPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +91,7 @@ public async Task Get_GetSIMPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSIMPolicy() + public async Task Get_GetSIMPolicy() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyGet.json // this example is just showing the usage of "SimPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +114,21 @@ public async Task Exists_GetSIMPolicy() // invoke the operation string simPolicyName = "testPolicy"; - bool result = await collection.ExistsAsync(simPolicyName); + MobileNetworkSimPolicyResource result = await collection.GetAsync(simPolicyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSimPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSIMPolicy() + public async Task GetAll_ListSIMPoliciesInAMobileNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyGet.json - // this example is just showing the usage of "SimPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyListByMobileNetwork.json + // this example is just showing the usage of "SimPolicies_ListByMobileNetwork" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,7 +138,7 @@ public async Task GetIfExists_GetSIMPolicy() // this example assumes you already have this MobileNetworkResource created on azure // for more information of creating MobileNetworkResource, please refer to the document of MobileNetworkResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; + string resourceGroupName = "testResourceGroupName"; string mobileNetworkName = "testMobileNetwork"; ResourceIdentifier mobileNetworkResourceId = MobileNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, mobileNetworkName); MobileNetworkResource mobileNetwork = client.GetMobileNetworkResource(mobileNetworkResourceId); @@ -104,31 +146,25 @@ public async Task GetIfExists_GetSIMPolicy() // get the collection of this MobileNetworkSimPolicyResource MobileNetworkSimPolicyCollection collection = mobileNetwork.GetMobileNetworkSimPolicies(); - // invoke the operation - string simPolicyName = "testPolicy"; - NullableResponse response = await collection.GetIfExistsAsync(simPolicyName); - MobileNetworkSimPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MobileNetworkSimPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkSimPolicyData resourceData = result.Data; + MobileNetworkSimPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSIMPolicy() + public async Task Exists_GetSIMPolicy() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyCreate.json - // this example is just showing the usage of "SimPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyGet.json + // this example is just showing the usage of "SimPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,61 +184,17 @@ public async Task CreateOrUpdate_CreateSIMPolicy() // invoke the operation string simPolicyName = "testPolicy"; - MobileNetworkSimPolicyData data = new MobileNetworkSimPolicyData(new AzureLocation("eastus"), new Ambr("500 Mbps", "1 Gbps"), new WritableSubResource() - { - Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), - }, new MobileNetworkSliceConfiguration[] - { -new MobileNetworkSliceConfiguration(new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), -},new DataNetworkConfiguration[] -{ -new DataNetworkConfiguration(new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/dataNetworks/testdataNetwork"), -},new Ambr("500 Mbps","1 Gbps"),new WritableSubResource[] -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/services/testService"), -} -}) -{ -FiveQi = 9, -AllocationAndRetentionPriorityLevel = 9, -PreemptionCapability = MobileNetworkPreemptionCapability.NotPreempt, -PreemptionVulnerability = MobileNetworkPreemptionVulnerability.Preemptable, -DefaultSessionType = MobileNetworkPduSessionType.IPv4, -AdditionalAllowedSessionTypes = -{ -}, -MaximumNumberOfBufferedPackets = 200, -} -}) - }) - { - RegistrationTimer = 3240, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, simPolicyName, data); - MobileNetworkSimPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(simPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSimPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSIMPoliciesInAMobileNetwork() + public async Task GetIfExists_GetSIMPolicy() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyListByMobileNetwork.json - // this example is just showing the usage of "SimPolicies_ListByMobileNetwork" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyGet.json + // this example is just showing the usage of "SimPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -212,7 +204,7 @@ public async Task GetAll_ListSIMPoliciesInAMobileNetwork() // this example assumes you already have this MobileNetworkResource created on azure // for more information of creating MobileNetworkResource, please refer to the document of MobileNetworkResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "testResourceGroupName"; + string resourceGroupName = "rg1"; string mobileNetworkName = "testMobileNetwork"; ResourceIdentifier mobileNetworkResourceId = MobileNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, mobileNetworkName); MobileNetworkResource mobileNetwork = client.GetMobileNetworkResource(mobileNetworkResourceId); @@ -220,17 +212,23 @@ public async Task GetAll_ListSIMPoliciesInAMobileNetwork() // get the collection of this MobileNetworkSimPolicyResource MobileNetworkSimPolicyCollection collection = mobileNetwork.GetMobileNetworkSimPolicies(); - // invoke the operation and iterate over the result - await foreach (MobileNetworkSimPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string simPolicyName = "testPolicy"; + NullableResponse response = await collection.GetIfExistsAsync(simPolicyName); + MobileNetworkSimPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkSimPolicyData resourceData = item.Data; + MobileNetworkSimPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimPolicyResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimPolicyResource.cs index a1eda3ba6e5ce..c1bebbff80083 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimPolicyResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileNetworkSimPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSIMPolicy() + public async Task Get_GetSIMPolicy() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyDelete.json - // this example is just showing the usage of "SimPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyGet.json + // this example is just showing the usage of "SimPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteSIMPolicy() MobileNetworkSimPolicyResource mobileNetworkSimPolicy = client.GetMobileNetworkSimPolicyResource(mobileNetworkSimPolicyResourceId); // invoke the operation - await mobileNetworkSimPolicy.DeleteAsync(WaitUntil.Completed); + MobileNetworkSimPolicyResource result = await mobileNetworkSimPolicy.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSimPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSIMPolicy() + public async Task Delete_DeleteSIMPolicy() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyGet.json - // this example is just showing the usage of "SimPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimPolicyDelete.json + // this example is just showing the usage of "SimPolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetSIMPolicy() MobileNetworkSimPolicyResource mobileNetworkSimPolicy = client.GetMobileNetworkSimPolicyResource(mobileNetworkSimPolicyResourceId); // invoke the operation - MobileNetworkSimPolicyResource result = await mobileNetworkSimPolicy.GetAsync(); + await mobileNetworkSimPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSimPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_UpdateSIMPolicyTags() MobileNetworkSimPolicyResource mobileNetworkSimPolicy = client.GetMobileNetworkSimPolicyResource(mobileNetworkSimPolicyResourceId); // invoke the operation - MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch() + MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; MobileNetworkSimPolicyResource result = await mobileNetworkSimPolicy.UpdateAsync(patch); diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimResource.cs index 1c8ca29fee866..e465807e78990 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSimResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileNetworkSimResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSIM() + public async Task Get_GetSIM() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimDelete.json - // this example is just showing the usage of "Sims_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGet.json + // this example is just showing the usage of "Sims_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +33,26 @@ public async Task Delete_DeleteSIM() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "testResourceGroupName"; string simGroupName = "testSimGroup"; - string simName = "testSim"; + string simName = "testSimName"; ResourceIdentifier mobileNetworkSimResourceId = MobileNetworkSimResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName, simName); MobileNetworkSimResource mobileNetworkSim = client.GetMobileNetworkSimResource(mobileNetworkSimResourceId); // invoke the operation - await mobileNetworkSim.DeleteAsync(WaitUntil.Completed); + MobileNetworkSimResource result = await mobileNetworkSim.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSimData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSIM() + public async Task Delete_DeleteSIM() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGet.json - // this example is just showing the usage of "Sims_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimDelete.json + // this example is just showing the usage of "Sims_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,14 @@ public async Task Get_GetSIM() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "testResourceGroupName"; string simGroupName = "testSimGroup"; - string simName = "testSimName"; + string simName = "testSim"; ResourceIdentifier mobileNetworkSimResourceId = MobileNetworkSimResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, simGroupName, simName); MobileNetworkSimResource mobileNetworkSim = client.GetMobileNetworkSimResource(mobileNetworkSimResourceId); // invoke the operation - MobileNetworkSimResource result = await mobileNetworkSim.GetAsync(); + await mobileNetworkSim.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSimData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -101,15 +101,12 @@ public async Task Update_CreateSIM() IntegratedCircuitCardIdentifier = "8900000000000000000", DeviceType = "Video camera", SimPolicyId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/simPolicies/MySimPolicy"), - StaticIPConfiguration = -{ -new SimStaticIPProperties() + StaticIPConfiguration = {new SimStaticIPProperties { AttachedDataNetworkId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/packetCoreControlPlanes/TestPacketCoreCP/packetCoreDataPlanes/TestPacketCoreDP/attachedDataNetworks/TestAttachedDataNetwork"), SliceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/slices/testSlice"), StaticIPIPv4Address = "2.4.0.1", -} -}, +}}, AuthenticationKey = "00000000000000000000000000000000", OperatorKeyCode = "00000000000000000000000000000000", }; diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSiteCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSiteCollection.cs index 6d2e698d88317..235c778469a3f 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSiteCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSiteCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MobileNetworkSiteCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMobileNetworkSite() + public async Task CreateOrUpdate_CreateMobileNetworkSite() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteGet.json - // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteCreate.json + // this example is just showing the usage of "Sites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,9 @@ public async Task Get_GetMobileNetworkSite() // invoke the operation string siteName = "testSite"; - MobileNetworkSiteResource result = await collection.GetAsync(siteName); + MobileNetworkSiteData data = new MobileNetworkSiteData(new AzureLocation("testLocation")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, siteName, data); + MobileNetworkSiteResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_GetMobileNetworkSite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetMobileNetworkSite() + public async Task Get_GetMobileNetworkSite() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteGet.json // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +76,21 @@ public async Task Exists_GetMobileNetworkSite() // invoke the operation string siteName = "testSite"; - bool result = await collection.ExistsAsync(siteName); + MobileNetworkSiteResource result = await collection.GetAsync(siteName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetMobileNetworkSite() + public async Task GetAll_ListMobileNetworkSitesInAMobileNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteGet.json - // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteListByMobileNetwork.json + // this example is just showing the usage of "Sites_ListByMobileNetwork" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +108,25 @@ public async Task GetIfExists_GetMobileNetworkSite() // get the collection of this MobileNetworkSiteResource MobileNetworkSiteCollection collection = mobileNetwork.GetMobileNetworkSites(); - // invoke the operation - string siteName = "testSite"; - NullableResponse response = await collection.GetIfExistsAsync(siteName); - MobileNetworkSiteResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MobileNetworkSiteResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkSiteData resourceData = result.Data; + MobileNetworkSiteData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateMobileNetworkSite() + public async Task Exists_GetMobileNetworkSite() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteCreate.json - // this example is just showing the usage of "Sites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteGet.json + // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,23 +146,17 @@ public async Task CreateOrUpdate_CreateMobileNetworkSite() // invoke the operation string siteName = "testSite"; - MobileNetworkSiteData data = new MobileNetworkSiteData(new AzureLocation("testLocation")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, siteName, data); - MobileNetworkSiteResource result = lro.Value; + bool result = await collection.ExistsAsync(siteName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListMobileNetworkSitesInAMobileNetwork() + public async Task GetIfExists_GetMobileNetworkSite() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteListByMobileNetwork.json - // this example is just showing the usage of "Sites_ListByMobileNetwork" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteGet.json + // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_ListMobileNetworkSitesInAMobileNetwork() // get the collection of this MobileNetworkSiteResource MobileNetworkSiteCollection collection = mobileNetwork.GetMobileNetworkSites(); - // invoke the operation and iterate over the result - await foreach (MobileNetworkSiteResource item in collection.GetAllAsync()) + // invoke the operation + string siteName = "testSite"; + NullableResponse response = await collection.GetIfExistsAsync(siteName); + MobileNetworkSiteResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkSiteData resourceData = item.Data; + MobileNetworkSiteData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSiteResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSiteResource.cs index a50fbb4362857..673a0e711d2b5 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSiteResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSiteResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileNetworkSiteResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteMobileNetworkSite() + public async Task Get_GetMobileNetworkSite() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteDelete.json - // this example is just showing the usage of "Sites_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteGet.json + // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteMobileNetworkSite() MobileNetworkSiteResource mobileNetworkSite = client.GetMobileNetworkSiteResource(mobileNetworkSiteResourceId); // invoke the operation - await mobileNetworkSite.DeleteAsync(WaitUntil.Completed); + MobileNetworkSiteResource result = await mobileNetworkSite.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetMobileNetworkSite() + public async Task Delete_DeleteMobileNetworkSite() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteGet.json - // this example is just showing the usage of "Sites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SiteDelete.json + // this example is just showing the usage of "Sites_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetMobileNetworkSite() MobileNetworkSiteResource mobileNetworkSite = client.GetMobileNetworkSiteResource(mobileNetworkSiteResourceId); // invoke the operation - MobileNetworkSiteResource result = await mobileNetworkSite.GetAsync(); + await mobileNetworkSite.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_UpdateMobileNetworkSiteTags() MobileNetworkSiteResource mobileNetworkSite = client.GetMobileNetworkSiteResource(mobileNetworkSiteResourceId); // invoke the operation - MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch() + MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; MobileNetworkSiteResource result = await mobileNetworkSite.UpdateAsync(patch); diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSliceCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSliceCollection.cs index 621f06f644082..87cedb39f0855 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSliceCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSliceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileNetworkSliceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSlice() + public async Task CreateOrUpdate_CreateNetworkSlice() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceGet.json - // this example is just showing the usage of "Slices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceCreate.json + // this example is just showing the usage of "Slices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_GetNetworkSlice() // invoke the operation string sliceName = "testSlice"; - MobileNetworkSliceResource result = await collection.GetAsync(sliceName); + MobileNetworkSliceData data = new MobileNetworkSliceData(new AzureLocation("eastus"), new Snssai(1) + { + Sd = "1abcde", + }) + { + Description = "myFavouriteSlice", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sliceName, data); + MobileNetworkSliceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_GetNetworkSlice() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkSlice() + public async Task Get_GetNetworkSlice() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceGet.json // this example is just showing the usage of "Slices_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +83,21 @@ public async Task Exists_GetNetworkSlice() // invoke the operation string sliceName = "testSlice"; - bool result = await collection.ExistsAsync(sliceName); + MobileNetworkSliceResource result = await collection.GetAsync(sliceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSliceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkSlice() + public async Task GetAll_ListNetworkSlicesInAMobileNetwork() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceGet.json - // this example is just showing the usage of "Slices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceListByMobileNetwork.json + // this example is just showing the usage of "Slices_ListByMobileNetwork" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +115,25 @@ public async Task GetIfExists_GetNetworkSlice() // get the collection of this MobileNetworkSliceResource MobileNetworkSliceCollection collection = mobileNetwork.GetMobileNetworkSlices(); - // invoke the operation - string sliceName = "testSlice"; - NullableResponse response = await collection.GetIfExistsAsync(sliceName); - MobileNetworkSliceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MobileNetworkSliceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkSliceData resourceData = result.Data; + MobileNetworkSliceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkSlice() + public async Task Exists_GetNetworkSlice() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceCreate.json - // this example is just showing the usage of "Slices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceGet.json + // this example is just showing the usage of "Slices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,29 +153,17 @@ public async Task CreateOrUpdate_CreateNetworkSlice() // invoke the operation string sliceName = "testSlice"; - MobileNetworkSliceData data = new MobileNetworkSliceData(new AzureLocation("eastus"), new Snssai(1) - { - Sd = "1abcde", - }) - { - Description = "myFavouriteSlice", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, sliceName, data); - MobileNetworkSliceResource result = lro.Value; + bool result = await collection.ExistsAsync(sliceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSliceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNetworkSlicesInAMobileNetwork() + public async Task GetIfExists_GetNetworkSlice() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceListByMobileNetwork.json - // this example is just showing the usage of "Slices_ListByMobileNetwork" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceGet.json + // this example is just showing the usage of "Slices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +181,23 @@ public async Task GetAll_ListNetworkSlicesInAMobileNetwork() // get the collection of this MobileNetworkSliceResource MobileNetworkSliceCollection collection = mobileNetwork.GetMobileNetworkSlices(); - // invoke the operation and iterate over the result - await foreach (MobileNetworkSliceResource item in collection.GetAllAsync()) + // invoke the operation + string sliceName = "testSlice"; + NullableResponse response = await collection.GetIfExistsAsync(sliceName); + MobileNetworkSliceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MobileNetworkSliceData resourceData = item.Data; + MobileNetworkSliceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSliceResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSliceResource.cs index d6b26d9a90ba7..df28864e13ab2 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSliceResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_MobileNetworkSliceResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MobileNetworkSliceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkSlice() + public async Task Get_GetNetworkSlice() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceDelete.json - // this example is just showing the usage of "Slices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceGet.json + // this example is just showing the usage of "Slices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteNetworkSlice() MobileNetworkSliceResource mobileNetworkSlice = client.GetMobileNetworkSliceResource(mobileNetworkSliceResourceId); // invoke the operation - await mobileNetworkSlice.DeleteAsync(WaitUntil.Completed); + MobileNetworkSliceResource result = await mobileNetworkSlice.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSliceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSlice() + public async Task Delete_DeleteNetworkSlice() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceGet.json - // this example is just showing the usage of "Slices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SliceDelete.json + // this example is just showing the usage of "Slices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetNetworkSlice() MobileNetworkSliceResource mobileNetworkSlice = client.GetMobileNetworkSliceResource(mobileNetworkSliceResourceId); // invoke the operation - MobileNetworkSliceResource result = await mobileNetworkSlice.GetAsync(); + await mobileNetworkSlice.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MobileNetworkSliceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_UpdateNetworkSliceTags() MobileNetworkSliceResource mobileNetworkSlice = client.GetMobileNetworkSliceResource(mobileNetworkSliceResourceId); // invoke the operation - MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch() + MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; MobileNetworkSliceResource result = await mobileNetworkSlice.UpdateAsync(patch); diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreControlPlaneCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreControlPlaneCollection.cs index acd40a744d83e..6e207d960101a 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreControlPlaneCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreControlPlaneCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_PacketCoreControlPlaneCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPacketCoreControlPlane() + public async Task CreateOrUpdate_CreatePacketCoreControlPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneGet.json - // this example is just showing the usage of "PacketCoreControlPlanes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneCreate.json + // this example is just showing the usage of "PacketCoreControlPlanes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,50 @@ public async Task Get_GetPacketCoreControlPlane() // invoke the operation string packetCoreControlPlaneName = "TestPacketCoreCP"; - PacketCoreControlPlaneResource result = await collection.GetAsync(packetCoreControlPlaneName); + PacketCoreControlPlaneData data = new PacketCoreControlPlaneData( + new AzureLocation("eastus"), + new WritableSubResource[] + { +new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), +} + }, + new MobileNetworkPlatformConfiguration(MobileNetworkPlatformType.AKSHCI) + { + AzureStackEdgeDeviceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), + ConnectedClusterId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Kubernetes/connectedClusters/TestConnectedCluster"), + CustomLocationId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ExtendedLocation/customLocations/TestCustomLocation"), + }, + new MobileNetworkInterfaceProperties + { + Name = "N2", + }, + MobileNetworkBillingSku.G0, + new MobileNetworkLocalDiagnosticsAccessConfiguration(MobileNetworkAuthenticationType.Aad) + { + HttpsServerCertificate = new MobileNetworkHttpsServerCertificate(new Uri("https://contosovault.vault.azure.net/certificates/ingress")), + }) + { + Installation = new MobileNetworkInstallation + { + DesiredState = DesiredInstallationState.Installed, + }, + CoreNetworkTechnology = MobileNetworkCoreNetworkType.FiveGC, + Version = "0.2.0", + UEMtu = 1600, + EventHub = new MobileNetworkEventHubConfiguration(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.EventHub/namespaces/contosoNamespace/eventHubs/contosoHub")) + { + ReportingInterval = 60, + }, + Signaling = new PacketCoreSignalingConfiguration + { + NasRerouteMacroMmeGroupId = 1024, + NasEncryption = { MobileNetworkNasEncryptionType.NEA2EEA2, MobileNetworkNasEncryptionType.NEA1EEA1, MobileNetworkNasEncryptionType.NEA0EEA0 }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, packetCoreControlPlaneName, data); + PacketCoreControlPlaneResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +96,7 @@ public async Task Get_GetPacketCoreControlPlane() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPacketCoreControlPlane() + public async Task Get_GetPacketCoreControlPlane() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneGet.json // this example is just showing the usage of "PacketCoreControlPlanes_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +118,21 @@ public async Task Exists_GetPacketCoreControlPlane() // invoke the operation string packetCoreControlPlaneName = "TestPacketCoreCP"; - bool result = await collection.ExistsAsync(packetCoreControlPlaneName); + PacketCoreControlPlaneResource result = await collection.GetAsync(packetCoreControlPlaneName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PacketCoreControlPlaneData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPacketCoreControlPlane() + public async Task GetAll_ListPacketCoreControlPlanesInResourceGroup() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneGet.json - // this example is just showing the usage of "PacketCoreControlPlanes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneListByResourceGroup.json + // this example is just showing the usage of "PacketCoreControlPlanes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +149,25 @@ public async Task GetIfExists_GetPacketCoreControlPlane() // get the collection of this PacketCoreControlPlaneResource PacketCoreControlPlaneCollection collection = resourceGroupResource.GetPacketCoreControlPlanes(); - // invoke the operation - string packetCoreControlPlaneName = "TestPacketCoreCP"; - NullableResponse response = await collection.GetIfExistsAsync(packetCoreControlPlaneName); - PacketCoreControlPlaneResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PacketCoreControlPlaneResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PacketCoreControlPlaneData resourceData = result.Data; + PacketCoreControlPlaneData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePacketCoreControlPlane() + public async Task Exists_GetPacketCoreControlPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneCreate.json - // this example is just showing the usage of "PacketCoreControlPlanes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneGet.json + // this example is just showing the usage of "PacketCoreControlPlanes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,61 +186,17 @@ public async Task CreateOrUpdate_CreatePacketCoreControlPlane() // invoke the operation string packetCoreControlPlaneName = "TestPacketCoreCP"; - PacketCoreControlPlaneData data = new PacketCoreControlPlaneData(new AzureLocation("eastus"), new WritableSubResource[] - { -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.MobileNetwork/mobileNetworks/testMobileNetwork/sites/testSite"), -} - }, new MobileNetworkPlatformConfiguration(MobileNetworkPlatformType.AKSHCI) - { - AzureStackEdgeDeviceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.DataBoxEdge/dataBoxEdgeDevices/TestAzureStackEdgeDevice"), - ConnectedClusterId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Kubernetes/connectedClusters/TestConnectedCluster"), - CustomLocationId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.ExtendedLocation/customLocations/TestCustomLocation"), - }, new MobileNetworkInterfaceProperties() - { - Name = "N2", - }, MobileNetworkBillingSku.G0, new MobileNetworkLocalDiagnosticsAccessConfiguration(MobileNetworkAuthenticationType.Aad) - { - HttpsServerCertificate = new MobileNetworkHttpsServerCertificate(new Uri("https://contosovault.vault.azure.net/certificates/ingress")), - }) - { - Installation = new MobileNetworkInstallation() - { - DesiredState = DesiredInstallationState.Installed, - }, - CoreNetworkTechnology = MobileNetworkCoreNetworkType.FiveGC, - Version = "0.2.0", - UEMtu = 1600, - EventHub = new MobileNetworkEventHubConfiguration(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.EventHub/namespaces/contosoNamespace/eventHubs/contosoHub")) - { - ReportingInterval = 60, - }, - Signaling = new PacketCoreSignalingConfiguration() - { - NasRerouteMacroMmeGroupId = 1024, - NasEncryption = -{ -MobileNetworkNasEncryptionType.NEA2EEA2,MobileNetworkNasEncryptionType.NEA1EEA1,MobileNetworkNasEncryptionType.NEA0EEA0 -}, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, packetCoreControlPlaneName, data); - PacketCoreControlPlaneResource result = lro.Value; + bool result = await collection.ExistsAsync(packetCoreControlPlaneName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PacketCoreControlPlaneData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPacketCoreControlPlanesInResourceGroup() + public async Task GetIfExists_GetPacketCoreControlPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneListByResourceGroup.json - // this example is just showing the usage of "PacketCoreControlPlanes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneGet.json + // this example is just showing the usage of "PacketCoreControlPlanes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -216,17 +213,23 @@ public async Task GetAll_ListPacketCoreControlPlanesInResourceGroup() // get the collection of this PacketCoreControlPlaneResource PacketCoreControlPlaneCollection collection = resourceGroupResource.GetPacketCoreControlPlanes(); - // invoke the operation and iterate over the result - await foreach (PacketCoreControlPlaneResource item in collection.GetAllAsync()) + // invoke the operation + string packetCoreControlPlaneName = "TestPacketCoreCP"; + NullableResponse response = await collection.GetIfExistsAsync(packetCoreControlPlaneName); + PacketCoreControlPlaneResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PacketCoreControlPlaneData resourceData = item.Data; + PacketCoreControlPlaneData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreControlPlaneResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreControlPlaneResource.cs index c808ce59ef62e..d83c3351878f1 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreControlPlaneResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreControlPlaneResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.MobileNetwork.Models; using Azure.ResourceManager.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MobileNetwork.Samples @@ -20,10 +19,10 @@ public partial class Sample_PacketCoreControlPlaneResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePacketCoreControlPlane() + public async Task Get_GetPacketCoreControlPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneDelete.json - // this example is just showing the usage of "PacketCoreControlPlanes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneGet.json + // this example is just showing the usage of "PacketCoreControlPlanes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +38,21 @@ public async Task Delete_DeletePacketCoreControlPlane() PacketCoreControlPlaneResource packetCoreControlPlane = client.GetPacketCoreControlPlaneResource(packetCoreControlPlaneResourceId); // invoke the operation - await packetCoreControlPlane.DeleteAsync(WaitUntil.Completed); + PacketCoreControlPlaneResource result = await packetCoreControlPlane.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PacketCoreControlPlaneData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPacketCoreControlPlane() + public async Task Delete_DeletePacketCoreControlPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneGet.json - // this example is just showing the usage of "PacketCoreControlPlanes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneDelete.json + // this example is just showing the usage of "PacketCoreControlPlanes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +68,9 @@ public async Task Get_GetPacketCoreControlPlane() PacketCoreControlPlaneResource packetCoreControlPlane = client.GetPacketCoreControlPlaneResource(packetCoreControlPlaneResourceId); // invoke the operation - PacketCoreControlPlaneResource result = await packetCoreControlPlane.GetAsync(); + await packetCoreControlPlane.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PacketCoreControlPlaneData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -95,19 +94,19 @@ public async Task Update_PatchPacketCoreControlPlane() PacketCoreControlPlaneResource packetCoreControlPlane = client.GetPacketCoreControlPlaneResource(packetCoreControlPlaneResourceId); // invoke the operation - MobileNetworkResourcePatch patch = new MobileNetworkResourcePatch() + MobileNetworkResourcePatch patch = new MobileNetworkResourcePatch { UserAssignedIdentity = new MobileNetworkManagedServiceIdentity(MobileNetworkManagedServiceIdentityType.UserAssigned) { UserAssignedIdentities = { -["/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity"] = new UserAssignedIdentity(), +["/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/testUserAssignedManagedIdentity"] = new UserAssignedIdentity() }, }, Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; PacketCoreControlPlaneResource result = await packetCoreControlPlane.UpdateAsync(patch); @@ -119,37 +118,6 @@ public async Task Update_PatchPacketCoreControlPlane() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPacketCoreControlPlanes_ListPacketCoreControlPlanesInASubscription() - { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneListBySubscription.json - // this example is just showing the usage of "PacketCoreControlPlanes_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PacketCoreControlPlaneResource item in subscriptionResource.GetPacketCoreControlPlanesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PacketCoreControlPlaneData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Rollback_RollbackPacketCoreControlPlane() diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreDataPlaneCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreDataPlaneCollection.cs index 367d896d9f144..7f4d0757015bf 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreDataPlaneCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreDataPlaneCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PacketCoreDataPlaneCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPacketCoreDataPlane() + public async Task CreateOrUpdate_CreatePacketCoreDataPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneGet.json - // this example is just showing the usage of "PacketCoreDataPlanes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneCreate.json + // this example is just showing the usage of "PacketCoreDataPlanes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetPacketCoreDataPlane() // invoke the operation string packetCoreDataPlaneName = "testPacketCoreDP"; - PacketCoreDataPlaneResource result = await collection.GetAsync(packetCoreDataPlaneName); + PacketCoreDataPlaneData data = new PacketCoreDataPlaneData(new AzureLocation("eastus"), new MobileNetworkInterfaceProperties + { + Name = "N3", + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, packetCoreDataPlaneName, data); + PacketCoreDataPlaneResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetPacketCoreDataPlane() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPacketCoreDataPlane() + public async Task Get_GetPacketCoreDataPlane() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneGet.json // this example is just showing the usage of "PacketCoreDataPlanes_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetPacketCoreDataPlane() // invoke the operation string packetCoreDataPlaneName = "testPacketCoreDP"; - bool result = await collection.ExistsAsync(packetCoreDataPlaneName); + PacketCoreDataPlaneResource result = await collection.GetAsync(packetCoreDataPlaneName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PacketCoreDataPlaneData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPacketCoreDataPlane() + public async Task GetAll_ListPacketCoreDataPlanesInAControlPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneGet.json - // this example is just showing the usage of "PacketCoreDataPlanes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneListByPacketCoreControlPlane.json + // this example is just showing the usage of "PacketCoreDataPlanes_ListByPacketCoreControlPlane" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetPacketCoreDataPlane() // get the collection of this PacketCoreDataPlaneResource PacketCoreDataPlaneCollection collection = packetCoreControlPlane.GetPacketCoreDataPlanes(); - // invoke the operation - string packetCoreDataPlaneName = "testPacketCoreDP"; - NullableResponse response = await collection.GetIfExistsAsync(packetCoreDataPlaneName); - PacketCoreDataPlaneResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PacketCoreDataPlaneResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PacketCoreDataPlaneData resourceData = result.Data; + PacketCoreDataPlaneData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePacketCoreDataPlane() + public async Task Exists_GetPacketCoreDataPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneCreate.json - // this example is just showing the usage of "PacketCoreDataPlanes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneGet.json + // this example is just showing the usage of "PacketCoreDataPlanes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_CreatePacketCoreDataPlane() // invoke the operation string packetCoreDataPlaneName = "testPacketCoreDP"; - PacketCoreDataPlaneData data = new PacketCoreDataPlaneData(new AzureLocation("eastus"), new MobileNetworkInterfaceProperties() - { - Name = "N3", - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, packetCoreDataPlaneName, data); - PacketCoreDataPlaneResource result = lro.Value; + bool result = await collection.ExistsAsync(packetCoreDataPlaneName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PacketCoreDataPlaneData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPacketCoreDataPlanesInAControlPlane() + public async Task GetIfExists_GetPacketCoreDataPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneListByPacketCoreControlPlane.json - // this example is just showing the usage of "PacketCoreDataPlanes_ListByPacketCoreControlPlane" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneGet.json + // this example is just showing the usage of "PacketCoreDataPlanes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListPacketCoreDataPlanesInAControlPlane() // get the collection of this PacketCoreDataPlaneResource PacketCoreDataPlaneCollection collection = packetCoreControlPlane.GetPacketCoreDataPlanes(); - // invoke the operation and iterate over the result - await foreach (PacketCoreDataPlaneResource item in collection.GetAllAsync()) + // invoke the operation + string packetCoreDataPlaneName = "testPacketCoreDP"; + NullableResponse response = await collection.GetIfExistsAsync(packetCoreDataPlaneName); + PacketCoreDataPlaneResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PacketCoreDataPlaneData resourceData = item.Data; + PacketCoreDataPlaneData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreDataPlaneResource.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreDataPlaneResource.cs index 4a4ba0e859de7..cc08ee81d4836 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreDataPlaneResource.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_PacketCoreDataPlaneResource.cs @@ -18,10 +18,10 @@ public partial class Sample_PacketCoreDataPlaneResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePacketCoreDataPlane() + public async Task Get_GetPacketCoreDataPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneDelete.json - // this example is just showing the usage of "PacketCoreDataPlanes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneGet.json + // this example is just showing the usage of "PacketCoreDataPlanes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeletePacketCoreDataPlane() PacketCoreDataPlaneResource packetCoreDataPlane = client.GetPacketCoreDataPlaneResource(packetCoreDataPlaneResourceId); // invoke the operation - await packetCoreDataPlane.DeleteAsync(WaitUntil.Completed); + PacketCoreDataPlaneResource result = await packetCoreDataPlane.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PacketCoreDataPlaneData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPacketCoreDataPlane() + public async Task Delete_DeletePacketCoreDataPlane() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneGet.json - // this example is just showing the usage of "PacketCoreDataPlanes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreDataPlaneDelete.json + // this example is just showing the usage of "PacketCoreDataPlanes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetPacketCoreDataPlane() PacketCoreDataPlaneResource packetCoreDataPlane = client.GetPacketCoreDataPlaneResource(packetCoreDataPlaneResourceId); // invoke the operation - PacketCoreDataPlaneResource result = await packetCoreDataPlane.GetAsync(); + await packetCoreDataPlane.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PacketCoreDataPlaneData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,12 +96,12 @@ public async Task Update_UpdatePacketCoreDataPlaneTags() PacketCoreDataPlaneResource packetCoreDataPlane = client.GetPacketCoreDataPlaneResource(packetCoreDataPlaneResourceId); // invoke the operation - MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch() + MobileNetworkTagsPatch patch = new MobileNetworkTagsPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; PacketCoreDataPlaneResource result = await packetCoreDataPlane.UpdateAsync(patch); diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_SubscriptionPacketCoreControlPlaneVersionCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_SubscriptionPacketCoreControlPlaneVersionCollection.cs index 11c95f3e37e20..54e20f1077b13 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_SubscriptionPacketCoreControlPlaneVersionCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_SubscriptionPacketCoreControlPlaneVersionCollection.cs @@ -50,10 +50,10 @@ public async Task Get_GetPacketCoreControlPlaneVersionBySubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPacketCoreControlPlaneVersionBySubscription() + public async Task GetAll_GetSupportedPacketCoreControlPlaneVersionsBySubscription() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneVersionGetBySubscription.json - // this example is just showing the usage of "PacketCoreControlPlaneVersions_GetBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneVersionListBySubscription.json + // this example is just showing the usage of "PacketCoreControlPlaneVersions_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +69,22 @@ public async Task Exists_GetPacketCoreControlPlaneVersionBySubscription() // get the collection of this SubscriptionPacketCoreControlPlaneVersionResource SubscriptionPacketCoreControlPlaneVersionCollection collection = subscriptionResource.GetSubscriptionPacketCoreControlPlaneVersions(); - // invoke the operation - string versionName = "2404.0-1"; - bool result = await collection.ExistsAsync(versionName); + // invoke the operation and iterate over the result + await foreach (SubscriptionPacketCoreControlPlaneVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PacketCoreControlPlaneVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPacketCoreControlPlaneVersionBySubscription() + public async Task Exists_GetPacketCoreControlPlaneVersionBySubscription() { // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneVersionGetBySubscription.json // this example is just showing the usage of "PacketCoreControlPlaneVersions_GetBySubscription" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +105,17 @@ public async Task GetIfExists_GetPacketCoreControlPlaneVersionBySubscription() // invoke the operation string versionName = "2404.0-1"; - NullableResponse response = await collection.GetIfExistsAsync(versionName); - SubscriptionPacketCoreControlPlaneVersionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(versionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PacketCoreControlPlaneVersionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSupportedPacketCoreControlPlaneVersionsBySubscription() + public async Task GetIfExists_GetPacketCoreControlPlaneVersionBySubscription() { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneVersionListBySubscription.json - // this example is just showing the usage of "PacketCoreControlPlaneVersions_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneVersionGetBySubscription.json + // this example is just showing the usage of "PacketCoreControlPlaneVersions_GetBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,17 +131,23 @@ public async Task GetAll_GetSupportedPacketCoreControlPlaneVersionsBySubscriptio // get the collection of this SubscriptionPacketCoreControlPlaneVersionResource SubscriptionPacketCoreControlPlaneVersionCollection collection = subscriptionResource.GetSubscriptionPacketCoreControlPlaneVersions(); - // invoke the operation and iterate over the result - await foreach (SubscriptionPacketCoreControlPlaneVersionResource item in collection.GetAllAsync()) + // invoke the operation + string versionName = "2404.0-1"; + NullableResponse response = await collection.GetIfExistsAsync(versionName); + SubscriptionPacketCoreControlPlaneVersionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PacketCoreControlPlaneVersionData resourceData = item.Data; + PacketCoreControlPlaneVersionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..c12cf65746c24 --- /dev/null +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,112 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.MobileNetwork.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMobileNetworks_ListMobileNetworksInASubscription() + { + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/MobileNetworkListBySubscription.json + // this example is just showing the usage of "MobileNetworks_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MobileNetworkResource item in subscriptionResource.GetMobileNetworksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPacketCoreControlPlanes_ListPacketCoreControlPlanesInASubscription() + { + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneListBySubscription.json + // this example is just showing the usage of "PacketCoreControlPlanes_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PacketCoreControlPlaneResource item in subscriptionResource.GetPacketCoreControlPlanesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PacketCoreControlPlaneData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMobileNetworkSimGroups_ListSIMGroupsInASubscription() + { + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/SimGroupListBySubscription.json + // this example is just showing the usage of "SimGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MobileNetworkSimGroupResource item in subscriptionResource.GetMobileNetworkSimGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MobileNetworkSimGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + } +} diff --git a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_TenantPacketCoreControlPlaneVersionCollection.cs b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_TenantPacketCoreControlPlaneVersionCollection.cs index d14535bbe7815..6a2a2196d2e4a 100644 --- a/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_TenantPacketCoreControlPlaneVersionCollection.cs +++ b/sdk/mobilenetwork/Azure.ResourceManager.MobileNetwork/samples/Generated/Samples/Sample_TenantPacketCoreControlPlaneVersionCollection.cs @@ -9,6 +9,7 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MobileNetwork.Samples @@ -27,9 +28,7 @@ public async Task Get_GetPacketCoreControlPlaneVersion() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantPacketCoreControlPlaneVersionResource TenantPacketCoreControlPlaneVersionCollection collection = tenantResource.GetTenantPacketCoreControlPlaneVersions(); @@ -45,6 +44,36 @@ public async Task Get_GetPacketCoreControlPlaneVersion() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetSupportedPacketCoreControlPlaneVersions() + { + // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneVersionList.json + // this example is just showing the usage of "PacketCoreControlPlaneVersions_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + + // get the collection of this TenantPacketCoreControlPlaneVersionResource + TenantPacketCoreControlPlaneVersionCollection collection = tenantResource.GetTenantPacketCoreControlPlaneVersions(); + + // invoke the operation and iterate over the result + await foreach (TenantPacketCoreControlPlaneVersionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PacketCoreControlPlaneVersionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetPacketCoreControlPlaneVersion() @@ -57,9 +86,7 @@ public async Task Exists_GetPacketCoreControlPlaneVersion() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantPacketCoreControlPlaneVersionResource TenantPacketCoreControlPlaneVersionCollection collection = tenantResource.GetTenantPacketCoreControlPlaneVersions(); @@ -83,9 +110,7 @@ public async Task GetIfExists_GetPacketCoreControlPlaneVersion() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // get the collection of this TenantPacketCoreControlPlaneVersionResource TenantPacketCoreControlPlaneVersionCollection collection = tenantResource.GetTenantPacketCoreControlPlaneVersions(); @@ -108,37 +133,5 @@ public async Task GetIfExists_GetPacketCoreControlPlaneVersion() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSupportedPacketCoreControlPlaneVersions() - { - // Generated from example definition: specification/mobilenetwork/resource-manager/Microsoft.MobileNetwork/stable/2024-04-01/examples/PacketCoreControlPlaneVersionList.json - // this example is just showing the usage of "PacketCoreControlPlaneVersions_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; - - // get the collection of this TenantPacketCoreControlPlaneVersionResource - TenantPacketCoreControlPlaneVersionCollection collection = tenantResource.GetTenantPacketCoreControlPlaneVersions(); - - // invoke the operation and iterate over the result - await foreach (TenantPacketCoreControlPlaneVersionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PacketCoreControlPlaneVersionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterCollection.cs b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterCollection.cs index 50a9f9f6b61a1..3a1dea587e91f 100644 --- a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterCollection.cs +++ b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MongoClusterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAMongoClusterResource() + public async Task CreateOrUpdate_CreatesANewMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_Get.json - // this example is just showing the usage of "MongoCluster_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_Create.json + // this example is just showing the usage of "MongoCluster_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,24 @@ public async Task Get_GetsAMongoClusterResource() // invoke the operation string mongoClusterName = "myMongoCluster"; - MongoClusterResource result = await collection.GetAsync(mongoClusterName); + MongoClusterData data = new MongoClusterData(new AzureLocation("westus2")) + { + Properties = new MongoClusterProperties + { + Administrator = new MongoClusterAdministratorProperties + { + UserName = "mongoAdmin", + Password = "password", + }, + ServerVersion = "5.0", + HighAvailabilityTargetMode = HighAvailabilityMode.SameZone, + StorageSizeGb = 128L, + ShardingShardCount = 1, + ComputeTier = "M30", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mongoClusterName, data); + MongoClusterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +69,10 @@ public async Task Get_GetsAMongoClusterResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAMongoClusterResource() + public async Task CreateOrUpdate_CreatesAReplicaMongoClusterResourceFromASourceResource() { - // Generated from example definition: 2024-07-01/MongoClusters_Get.json - // this example is just showing the usage of "MongoCluster_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_CreateGeoReplica.json + // this example is just showing the usage of "MongoCluster_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,18 +90,31 @@ public async Task Exists_GetsAMongoClusterResource() MongoClusterCollection collection = resourceGroupResource.GetMongoClusters(); // invoke the operation - string mongoClusterName = "myMongoCluster"; - bool result = await collection.ExistsAsync(mongoClusterName); + string mongoClusterName = "myReplicaMongoCluster"; + MongoClusterData data = new MongoClusterData(new AzureLocation("centralus")) + { + Properties = new MongoClusterProperties + { + CreateMode = MongoClusterCreateMode.GeoReplica, + ReplicaParameters = new MongoClusterReplicaContent(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/mySourceMongoCluster"), new AzureLocation("eastus")), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mongoClusterName, data); + MongoClusterResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAMongoClusterResource() + public async Task CreateOrUpdate_CreatesAMongoClusterResourceFromAPointInTimeRestore() { - // Generated from example definition: 2024-07-01/MongoClusters_Get.json - // this example is just showing the usage of "MongoCluster_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_CreatePITR.json + // this example is just showing the usage of "MongoCluster_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,29 +133,34 @@ public async Task GetIfExists_GetsAMongoClusterResource() // invoke the operation string mongoClusterName = "myMongoCluster"; - NullableResponse response = await collection.GetIfExistsAsync(mongoClusterName); - MongoClusterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + MongoClusterData data = new MongoClusterData(new AzureLocation("westus2")) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new MongoClusterProperties + { + CreateMode = MongoClusterCreateMode.PointInTimeRestore, + RestoreParameters = new MongoClusterRestoreContent + { + PointInTimeUTC = DateTimeOffset.Parse("2023-01-13T20:07:35Z"), + SourceResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myOtherMongoCluster"), + }, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mongoClusterName, data); + MongoClusterResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoClusterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesANewMongoClusterResource() + public async Task Get_GetsAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_Create.json - // this example is just showing the usage of "MongoCluster_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_Get.json + // this example is just showing the usage of "MongoCluster_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,24 +179,7 @@ public async Task CreateOrUpdate_CreatesANewMongoClusterResource() // invoke the operation string mongoClusterName = "myMongoCluster"; - MongoClusterData data = new MongoClusterData(new AzureLocation("westus2")) - { - Properties = new MongoClusterProperties() - { - Administrator = new MongoClusterAdministratorProperties() - { - UserName = "mongoAdmin", - Password = "password", - }, - ServerVersion = "5.0", - HighAvailabilityTargetMode = HighAvailabilityMode.SameZone, - StorageSizeGb = 128L, - ShardingShardCount = 1, - ComputeTier = "M30", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mongoClusterName, data); - MongoClusterResource result = lro.Value; + MongoClusterResource result = await collection.GetAsync(mongoClusterName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -172,10 +190,10 @@ public async Task CreateOrUpdate_CreatesANewMongoClusterResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAReplicaMongoClusterResourceFromASourceResource() + public async Task GetAll_ListsTheMongoClusterResourcesInAResourceGroup() { - // Generated from example definition: 2024-07-01/MongoClusters_CreateGeoReplica.json - // this example is just showing the usage of "MongoCluster_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_ListByResourceGroup.json + // this example is just showing the usage of "MongoCluster_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,32 +210,25 @@ public async Task CreateOrUpdate_CreatesAReplicaMongoClusterResourceFromASourceR // get the collection of this MongoClusterResource MongoClusterCollection collection = resourceGroupResource.GetMongoClusters(); - // invoke the operation - string mongoClusterName = "myReplicaMongoCluster"; - MongoClusterData data = new MongoClusterData(new AzureLocation("centralus")) + // invoke the operation and iterate over the result + await foreach (MongoClusterResource item in collection.GetAllAsync()) { - Properties = new MongoClusterProperties() - { - CreateMode = MongoClusterCreateMode.GeoReplica, - ReplicaParameters = new MongoClusterReplicaContent(new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/mySourceMongoCluster"), new AzureLocation("eastus")), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mongoClusterName, data); - MongoClusterResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAMongoClusterResourceFromAPointInTimeRestore() + public async Task Exists_GetsAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_CreatePITR.json - // this example is just showing the usage of "MongoCluster_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_Get.json + // this example is just showing the usage of "MongoCluster_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,34 +247,17 @@ public async Task CreateOrUpdate_CreatesAMongoClusterResourceFromAPointInTimeRes // invoke the operation string mongoClusterName = "myMongoCluster"; - MongoClusterData data = new MongoClusterData(new AzureLocation("westus2")) - { - Properties = new MongoClusterProperties() - { - CreateMode = MongoClusterCreateMode.PointInTimeRestore, - RestoreParameters = new MongoClusterRestoreContent() - { - PointInTimeUTC = DateTimeOffset.Parse("2023-01-13T20:07:35Z"), - SourceResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestResourceGroup/providers/Microsoft.DocumentDB/mongoClusters/myOtherMongoCluster"), - }, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, mongoClusterName, data); - MongoClusterResource result = lro.Value; + bool result = await collection.ExistsAsync(mongoClusterName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoClusterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsTheMongoClusterResourcesInAResourceGroup() + public async Task GetIfExists_GetsAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_ListByResourceGroup.json - // this example is just showing the usage of "MongoCluster_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_Get.json + // this example is just showing the usage of "MongoCluster_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -280,17 +274,23 @@ public async Task GetAll_ListsTheMongoClusterResourcesInAResourceGroup() // get the collection of this MongoClusterResource MongoClusterCollection collection = resourceGroupResource.GetMongoClusters(); - // invoke the operation and iterate over the result - await foreach (MongoClusterResource item in collection.GetAllAsync()) + // invoke the operation + string mongoClusterName = "myMongoCluster"; + NullableResponse response = await collection.GetIfExistsAsync(mongoClusterName); + MongoClusterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MongoClusterData resourceData = item.Data; + MongoClusterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterFirewallRuleCollection.cs b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterFirewallRuleCollection.cs index ae84ce078f5bf..f95bd4dccd14c 100644 --- a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterFirewallRuleCollection.cs +++ b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterFirewallRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MongoClusterFirewallRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAFirewallRuleOnAMongoClusterResource() + public async Task CreateOrUpdate_CreatesAFirewallRuleOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleGet.json - // this example is just showing the usage of "FirewallRule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleCreate.json + // this example is just showing the usage of "FirewallRule_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetsAFirewallRuleOnAMongoClusterResource() // invoke the operation string firewallRuleName = "rule1"; - MongoClusterFirewallRuleResource result = await collection.GetAsync(firewallRuleName); + MongoClusterFirewallRuleData data = new MongoClusterFirewallRuleData + { + Properties = new MongoClusterFirewallRuleProperties("0.0.0.0", "255.255.255.255"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data); + MongoClusterFirewallRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetsAFirewallRuleOnAMongoClusterResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAFirewallRuleOnAMongoClusterResource() + public async Task Get_GetsAFirewallRuleOnAMongoClusterResource() { // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleGet.json // this example is just showing the usage of "FirewallRule_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetsAFirewallRuleOnAMongoClusterResource() // invoke the operation string firewallRuleName = "rule1"; - bool result = await collection.ExistsAsync(firewallRuleName); + MongoClusterFirewallRuleResource result = await collection.GetAsync(firewallRuleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoClusterFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAFirewallRuleOnAMongoClusterResource() + public async Task GetAll_ListTheFirewallRulesOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleGet.json - // this example is just showing the usage of "FirewallRule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleList.json + // this example is just showing the usage of "FirewallRule_ListByMongoCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetsAFirewallRuleOnAMongoClusterResource() // get the collection of this MongoClusterFirewallRuleResource MongoClusterFirewallRuleCollection collection = mongoCluster.GetMongoClusterFirewallRules(); - // invoke the operation - string firewallRuleName = "rule1"; - NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); - MongoClusterFirewallRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MongoClusterFirewallRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MongoClusterFirewallRuleData resourceData = result.Data; + MongoClusterFirewallRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAFirewallRuleOnAMongoClusterResource() + public async Task Exists_GetsAFirewallRuleOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleCreate.json - // this example is just showing the usage of "FirewallRule_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleGet.json + // this example is just showing the usage of "FirewallRule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_CreatesAFirewallRuleOnAMongoClusterResource() // invoke the operation string firewallRuleName = "rule1"; - MongoClusterFirewallRuleData data = new MongoClusterFirewallRuleData() - { - Properties = new MongoClusterFirewallRuleProperties("0.0.0.0", "255.255.255.255"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallRuleName, data); - MongoClusterFirewallRuleResource result = lro.Value; + bool result = await collection.ExistsAsync(firewallRuleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoClusterFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheFirewallRulesOnAMongoClusterResource() + public async Task GetIfExists_GetsAFirewallRuleOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleList.json - // this example is just showing the usage of "FirewallRule_ListByMongoCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleGet.json + // this example is just showing the usage of "FirewallRule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListTheFirewallRulesOnAMongoClusterResource() // get the collection of this MongoClusterFirewallRuleResource MongoClusterFirewallRuleCollection collection = mongoCluster.GetMongoClusterFirewallRules(); - // invoke the operation and iterate over the result - await foreach (MongoClusterFirewallRuleResource item in collection.GetAllAsync()) + // invoke the operation + string firewallRuleName = "rule1"; + NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); + MongoClusterFirewallRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MongoClusterFirewallRuleData resourceData = item.Data; + MongoClusterFirewallRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterFirewallRuleResource.cs b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterFirewallRuleResource.cs index 002816c8ff1d1..d4aa354b7aaf2 100644 --- a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterFirewallRuleResource.cs +++ b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterFirewallRuleResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsAFirewallRuleOnAMongoClusterResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesAFirewallRuleOnAMongoClusterResource() + public async Task Delete_DeletesAFirewallRuleOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleCreate.json - // this example is just showing the usage of "FirewallRule_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleDelete.json + // this example is just showing the usage of "FirewallRule_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,26 +69,17 @@ public async Task Update_CreatesAFirewallRuleOnAMongoClusterResource() MongoClusterFirewallRuleResource mongoClusterFirewallRule = client.GetMongoClusterFirewallRuleResource(mongoClusterFirewallRuleResourceId); // invoke the operation - MongoClusterFirewallRuleData data = new MongoClusterFirewallRuleData() - { - Properties = new MongoClusterFirewallRuleProperties("0.0.0.0", "255.255.255.255"), - }; - ArmOperation lro = await mongoClusterFirewallRule.UpdateAsync(WaitUntil.Completed, data); - MongoClusterFirewallRuleResource result = lro.Value; + await mongoClusterFirewallRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoClusterFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAFirewallRuleOnAMongoClusterResource() + public async Task Update_CreatesAFirewallRuleOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleDelete.json - // this example is just showing the usage of "FirewallRule_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_FirewallRuleCreate.json + // this example is just showing the usage of "FirewallRule_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +96,18 @@ public async Task Delete_DeletesAFirewallRuleOnAMongoClusterResource() MongoClusterFirewallRuleResource mongoClusterFirewallRule = client.GetMongoClusterFirewallRuleResource(mongoClusterFirewallRuleResourceId); // invoke the operation - await mongoClusterFirewallRule.DeleteAsync(WaitUntil.Completed); + MongoClusterFirewallRuleData data = new MongoClusterFirewallRuleData + { + Properties = new MongoClusterFirewallRuleProperties("0.0.0.0", "255.255.255.255"), + }; + ArmOperation lro = await mongoClusterFirewallRule.UpdateAsync(WaitUntil.Completed, data); + MongoClusterFirewallRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoClusterFirewallRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterPrivateEndpointConnectionResource.cs b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterPrivateEndpointConnectionResource.cs index 6b31cea44c63c..b613f615940ed 100644 --- a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterPrivateEndpointConnectionResource.cs +++ b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetAPrivateEndpointConnectionOnAMongoClusterResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApprovesAPrivateEndpointConnectionOnAMongoClusterResource() + public async Task Delete_DeleteAPrivateEndpointConnectionOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionPut.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionDelete.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,35 +64,22 @@ public async Task Update_ApprovesAPrivateEndpointConnectionOnAMongoClusterResour string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "TestGroup"; string mongoClusterName = "myMongoCluster"; - string privateEndpointConnectionName = "pecTest"; + string privateEndpointConnectionName = "pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"; ResourceIdentifier mongoClusterPrivateEndpointConnectionResourceId = MongoClusterPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, mongoClusterName, privateEndpointConnectionName); MongoClusterPrivateEndpointConnectionResource mongoClusterPrivateEndpointConnectionResource = client.GetMongoClusterPrivateEndpointConnectionResource(mongoClusterPrivateEndpointConnectionResourceId); // invoke the operation - MongoClusterPrivateEndpointConnectionResourceData data = new MongoClusterPrivateEndpointConnectionResourceData() - { - Properties = new MongoClusterPrivateEndpointConnectionProperties(new MongoClusterPrivateLinkServiceConnectionState() - { - Status = MongoClusterPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }), - }; - ArmOperation lro = await mongoClusterPrivateEndpointConnectionResource.UpdateAsync(WaitUntil.Completed, data); - MongoClusterPrivateEndpointConnectionResource result = lro.Value; + await mongoClusterPrivateEndpointConnectionResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoClusterPrivateEndpointConnectionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAPrivateEndpointConnectionOnAMongoClusterResource() + public async Task Update_ApprovesAPrivateEndpointConnectionOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionDelete.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionPut.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,14 +91,27 @@ public async Task Delete_DeleteAPrivateEndpointConnectionOnAMongoClusterResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "TestGroup"; string mongoClusterName = "myMongoCluster"; - string privateEndpointConnectionName = "pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"; + string privateEndpointConnectionName = "pecTest"; ResourceIdentifier mongoClusterPrivateEndpointConnectionResourceId = MongoClusterPrivateEndpointConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, mongoClusterName, privateEndpointConnectionName); MongoClusterPrivateEndpointConnectionResource mongoClusterPrivateEndpointConnectionResource = client.GetMongoClusterPrivateEndpointConnectionResource(mongoClusterPrivateEndpointConnectionResourceId); // invoke the operation - await mongoClusterPrivateEndpointConnectionResource.DeleteAsync(WaitUntil.Completed); + MongoClusterPrivateEndpointConnectionResourceData data = new MongoClusterPrivateEndpointConnectionResourceData + { + Properties = new MongoClusterPrivateEndpointConnectionProperties(new MongoClusterPrivateLinkServiceConnectionState + { + Status = MongoClusterPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }), + }; + ArmOperation lro = await mongoClusterPrivateEndpointConnectionResource.UpdateAsync(WaitUntil.Completed, data); + MongoClusterPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoClusterPrivateEndpointConnectionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterPrivateEndpointConnectionResourceCollection.cs b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterPrivateEndpointConnectionResourceCollection.cs index 4e3767d1bd995..f0480e5f26486 100644 --- a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterPrivateEndpointConnectionResourceCollection.cs +++ b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterPrivateEndpointConnectionResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MongoClusterPrivateEndpointConnectionResourceCollect { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsThePrivateEndpointConnectionResourcesOnAMongoClusterResource() + public async Task CreateOrUpdate_ApprovesAPrivateEndpointConnectionOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionList.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_ListByMongoCluster" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionPut.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,24 @@ public async Task GetAll_ListsThePrivateEndpointConnectionResourcesOnAMongoClust // get the collection of this MongoClusterPrivateEndpointConnectionResource MongoClusterPrivateEndpointConnectionResourceCollection collection = mongoCluster.GetMongoClusterPrivateEndpointConnectionResources(); - // invoke the operation and iterate over the result - await foreach (MongoClusterPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "pecTest"; + MongoClusterPrivateEndpointConnectionResourceData data = new MongoClusterPrivateEndpointConnectionResourceData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoClusterPrivateEndpointConnectionResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Properties = new MongoClusterPrivateEndpointConnectionProperties(new MongoClusterPrivateLinkServiceConnectionState + { + Status = MongoClusterPrivateEndpointServiceConnectionStatus.Approved, + Description = "Auto-Approved", + }), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + MongoClusterPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoClusterPrivateEndpointConnectionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +95,10 @@ public async Task Get_GetAPrivateEndpointConnectionOnAMongoClusterResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAPrivateEndpointConnectionOnAMongoClusterResource() + public async Task GetAll_ListsThePrivateEndpointConnectionResourcesOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionList.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_ListByMongoCluster" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +116,22 @@ public async Task Exists_GetAPrivateEndpointConnectionOnAMongoClusterResource() // get the collection of this MongoClusterPrivateEndpointConnectionResource MongoClusterPrivateEndpointConnectionResourceCollection collection = mongoCluster.GetMongoClusterPrivateEndpointConnectionResources(); - // invoke the operation - string privateEndpointConnectionName = "pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + // invoke the operation and iterate over the result + await foreach (MongoClusterPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoClusterPrivateEndpointConnectionResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAPrivateEndpointConnectionOnAMongoClusterResource() + public async Task Exists_GetAPrivateEndpointConnectionOnAMongoClusterResource() { // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionGet.json // this example is just showing the usage of "PrivateEndpointConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +154,17 @@ public async Task GetIfExists_GetAPrivateEndpointConnectionOnAMongoClusterResour // invoke the operation string privateEndpointConnectionName = "pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - MongoClusterPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoClusterPrivateEndpointConnectionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApprovesAPrivateEndpointConnectionOnAMongoClusterResource() + public async Task GetIfExists_GetAPrivateEndpointConnectionOnAMongoClusterResource() { - // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionPut.json - // this example is just showing the usage of "PrivateEndpointConnectionResource_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: 2024-07-01/MongoClusters_PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnectionResource_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,23 +183,22 @@ public async Task CreateOrUpdate_ApprovesAPrivateEndpointConnectionOnAMongoClust MongoClusterPrivateEndpointConnectionResourceCollection collection = mongoCluster.GetMongoClusterPrivateEndpointConnectionResources(); // invoke the operation - string privateEndpointConnectionName = "pecTest"; - MongoClusterPrivateEndpointConnectionResourceData data = new MongoClusterPrivateEndpointConnectionResourceData() - { - Properties = new MongoClusterPrivateEndpointConnectionProperties(new MongoClusterPrivateLinkServiceConnectionState() - { - Status = MongoClusterPrivateEndpointServiceConnectionStatus.Approved, - Description = "Auto-Approved", - }), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - MongoClusterPrivateEndpointConnectionResource result = lro.Value; + string privateEndpointConnectionName = "pecTest.5d393f64-ef64-46d0-9959-308321c44ac0"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + MongoClusterPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoClusterPrivateEndpointConnectionResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoClusterPrivateEndpointConnectionResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterResource.cs b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterResource.cs index 1a4a93e755170..89dc0e9ea8fee 100644 --- a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterResource.cs +++ b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_MongoClusterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.MongoCluster.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MongoCluster.Samples @@ -47,6 +46,32 @@ public async Task Get_GetsAMongoClusterResource() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeletesAMongoClusterResource() + { + // Generated from example definition: 2024-07-01/MongoClusters_Delete.json + // this example is just showing the usage of "MongoCluster_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MongoClusterResource created on azure + // for more information of creating MongoClusterResource, please refer to the document of MongoClusterResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + string resourceGroupName = "TestResourceGroup"; + string mongoClusterName = "myMongoCluster"; + ResourceIdentifier mongoClusterResourceId = MongoClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, mongoClusterName); + MongoClusterResource mongoCluster = client.GetMongoClusterResource(mongoClusterResourceId); + + // invoke the operation + await mongoCluster.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_UpdatesTheDiskSizeOnAMongoClusterResource() @@ -68,9 +93,9 @@ public async Task Update_UpdatesTheDiskSizeOnAMongoClusterResource() MongoClusterResource mongoCluster = client.GetMongoClusterResource(mongoClusterResourceId); // invoke the operation - MongoClusterPatch patch = new MongoClusterPatch() + MongoClusterPatch patch = new MongoClusterPatch { - Properties = new MongoClusterUpdateProperties() + Properties = new MongoClusterUpdateProperties { StorageSizeGb = 256L, }, @@ -106,9 +131,9 @@ public async Task Update_DisablesPublicNetworkAccessOnAMongoClusterResourceWithA MongoClusterResource mongoCluster = client.GetMongoClusterResource(mongoClusterResourceId); // invoke the operation - MongoClusterPatch patch = new MongoClusterPatch() + MongoClusterPatch patch = new MongoClusterPatch { - Properties = new MongoClusterUpdateProperties() + Properties = new MongoClusterUpdateProperties { PublicNetworkAccess = MongoClusterPublicNetworkAccess.Disabled, }, @@ -144,11 +169,11 @@ public async Task Update_ResetsTheAdministratorLoginPassword() MongoClusterResource mongoCluster = client.GetMongoClusterResource(mongoClusterResourceId); // invoke the operation - MongoClusterPatch patch = new MongoClusterPatch() + MongoClusterPatch patch = new MongoClusterPatch { - Properties = new MongoClusterUpdateProperties() + Properties = new MongoClusterUpdateProperties { - Administrator = new MongoClusterAdministratorProperties() + Administrator = new MongoClusterAdministratorProperties { UserName = "mongoAdmin", Password = "password", @@ -186,11 +211,11 @@ public async Task Update_UpdatesAMongoClusterResource() MongoClusterResource mongoCluster = client.GetMongoClusterResource(mongoClusterResourceId); // invoke the operation - MongoClusterPatch patch = new MongoClusterPatch() + MongoClusterPatch patch = new MongoClusterPatch { - Properties = new MongoClusterUpdateProperties() + Properties = new MongoClusterUpdateProperties { - Administrator = new MongoClusterAdministratorProperties() + Administrator = new MongoClusterAdministratorProperties { UserName = "mongoAdmin", }, @@ -200,9 +225,7 @@ public async Task Update_UpdatesAMongoClusterResource() StorageSizeGb = 256L, ShardingShardCount = 4, ComputeTier = "M50", - PreviewFeatures = -{ -}, + PreviewFeatures = { }, }, }; ArmOperation lro = await mongoCluster.UpdateAsync(WaitUntil.Completed, patch); @@ -215,63 +238,6 @@ public async Task Update_UpdatesAMongoClusterResource() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAMongoClusterResource() - { - // Generated from example definition: 2024-07-01/MongoClusters_Delete.json - // this example is just showing the usage of "MongoCluster_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MongoClusterResource created on azure - // for more information of creating MongoClusterResource, please refer to the document of MongoClusterResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestResourceGroup"; - string mongoClusterName = "myMongoCluster"; - ResourceIdentifier mongoClusterResourceId = MongoClusterResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, mongoClusterName); - MongoClusterResource mongoCluster = client.GetMongoClusterResource(mongoClusterResourceId); - - // invoke the operation - await mongoCluster.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMongoClusters_ListsTheMongoClusterResourcesInASubscription() - { - // Generated from example definition: 2024-07-01/MongoClusters_List.json - // this example is just showing the usage of "MongoCluster_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MongoClusterResource item in subscriptionResource.GetMongoClustersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MongoClusterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetConnectionStrings_ListTheAvailableConnectionStringsForTheMongoClusterResource() @@ -298,66 +264,6 @@ public async Task GetConnectionStrings_ListTheAvailableConnectionStringsForTheMo Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckMongoClusterNameAvailability_ChecksAndConfirmsTheMongoClusterNameIsAvailabilityForUse() - { - // Generated from example definition: 2024-07-01/MongoClusters_NameAvailability.json - // this example is just showing the usage of "MongoClusters_CheckMongoClusterNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("westus2"); - MongoClusterNameAvailabilityContent content = new MongoClusterNameAvailabilityContent() - { - Name = "newmongocluster", - ResourceType = "Microsoft.DocumentDB/mongoClusters", - }; - MongoClusterNameAvailabilityResult result = await subscriptionResource.CheckMongoClusterNameAvailabilityAsync(location, content); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckMongoClusterNameAvailability_ChecksAndReturnsThatTheMongoClusterNameIsAlreadyInUse() - { - // Generated from example definition: 2024-07-01/MongoClusters_NameAvailability_AlreadyExists.json - // this example is just showing the usage of "MongoClusters_CheckMongoClusterNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("westus2"); - MongoClusterNameAvailabilityContent content = new MongoClusterNameAvailabilityContent() - { - Name = "existingmongocluster", - ResourceType = "Microsoft.DocumentDB/mongoClusters", - }; - MongoClusterNameAvailabilityResult result = await subscriptionResource.CheckMongoClusterNameAvailabilityAsync(location, content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Promote_PromotesAReplicaMongoClusterResourceToAPrimaryRole() diff --git a/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs new file mode 100644 index 0000000000000..30d2c455dea68 --- /dev/null +++ b/sdk/mongocluster/Azure.ResourceManager.MongoCluster/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -0,0 +1,111 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Identity; +using Azure.ResourceManager.MongoCluster.Models; +using Azure.ResourceManager.Resources; +using NUnit.Framework; + +namespace Azure.ResourceManager.MongoCluster.Samples +{ + public partial class Sample_SubscriptionResourceExtensions + { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMongoClusters_ListsTheMongoClusterResourcesInASubscription() + { + // Generated from example definition: 2024-07-01/MongoClusters_List.json + // this example is just showing the usage of "MongoCluster_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MongoClusterResource item in subscriptionResource.GetMongoClustersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MongoClusterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckMongoClusterNameAvailability_ChecksAndConfirmsTheMongoClusterNameIsAvailabilityForUse() + { + // Generated from example definition: 2024-07-01/MongoClusters_NameAvailability.json + // this example is just showing the usage of "MongoClusters_CheckMongoClusterNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("westus2"); + MongoClusterNameAvailabilityContent content = new MongoClusterNameAvailabilityContent + { + Name = "newmongocluster", + ResourceType = "Microsoft.DocumentDB/mongoClusters", + }; + MongoClusterNameAvailabilityResult result = await subscriptionResource.CheckMongoClusterNameAvailabilityAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckMongoClusterNameAvailability_ChecksAndReturnsThatTheMongoClusterNameIsAlreadyInUse() + { + // Generated from example definition: 2024-07-01/MongoClusters_NameAvailability_AlreadyExists.json + // this example is just showing the usage of "MongoClusters_CheckMongoClusterNameAvailability" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("westus2"); + MongoClusterNameAvailabilityContent content = new MongoClusterNameAvailabilityContent + { + Name = "existingmongocluster", + ResourceType = "Microsoft.DocumentDB/mongoClusters", + }; + MongoClusterNameAvailabilityResult result = await subscriptionResource.CheckMongoClusterNameAvailabilityAsync(location, content); + + Console.WriteLine($"Succeeded: {result}"); + } + } +} diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActionGroupCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActionGroupCollection.cs index 98bff33b211a4..f7d4a697d4f58 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActionGroupCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActionGroupCollection.cs @@ -45,86 +45,51 @@ public async Task CreateOrUpdate_CreateOrUpdateAnActionGroup() { GroupShortName = "sample", IsEnabled = true, - EmailReceivers = -{ -new MonitorEmailReceiver("John Doe's email","johndoe@email.com") + EmailReceivers = {new MonitorEmailReceiver("John Doe's email", "johndoe@email.com") { UseCommonAlertSchema = false, -},new MonitorEmailReceiver("Jane Smith's email","janesmith@email.com") +}, new MonitorEmailReceiver("Jane Smith's email", "janesmith@email.com") { UseCommonAlertSchema = true, -} -}, - SmsReceivers = -{ -new MonitorSmsReceiver("John Doe's mobile","1","1234567890"),new MonitorSmsReceiver("Jane Smith's mobile","1","0987654321") -}, - WebhookReceivers = -{ -new MonitorWebhookReceiver("Sample webhook 1",new Uri("http://www.example.com/webhook1")) +}}, + SmsReceivers = { new MonitorSmsReceiver("John Doe's mobile", "1", "1234567890"), new MonitorSmsReceiver("Jane Smith's mobile", "1", "0987654321") }, + WebhookReceivers = {new MonitorWebhookReceiver("Sample webhook 1", new Uri("http://www.example.com/webhook1")) { UseCommonAlertSchema = true, -},new MonitorWebhookReceiver("Sample webhook 2",new Uri("http://www.example.com/webhook2")) +}, new MonitorWebhookReceiver("Sample webhook 2", new Uri("http://www.example.com/webhook2")) { UseCommonAlertSchema = true, UseAadAuth = true, ObjectId = "d3bb868c-fe44-452c-aa26-769a6538c808", IdentifierUri = new Uri("http://someidentifier/d7811ba3-7996-4a93-99b6-6b2f3f355f8a"), TenantId = Guid.Parse("68a4459a-ccb8-493c-b9da-dd30457d1b84"), -} -}, - ItsmReceivers = -{ -new MonitorItsmReceiver("Sample itsm","5def922a-3ed4-49c1-b9fd-05ec533819a3|55dfd1f8-7e59-4f89-bf56-4c82f5ace23c","a3b9076c-ce8e-434e-85b4-aff10cb3c8f1","{\"PayloadRevision\":0,\"WorkItemType\":\"Incident\",\"UseTemplate\":false,\"WorkItemData\":\"{}\",\"CreateOneWIPerCI\":false}",new AzureLocation("westcentralus")) -}, - AzureAppPushReceivers = -{ -new MonitorAzureAppPushReceiver("Sample azureAppPush","johndoe@email.com") -}, - AutomationRunbookReceivers = -{ -new MonitorAutomationRunbookReceiver(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest"),"Sample runbook",new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest/webhooks/Alert1510184037084"),false) +}}, + ItsmReceivers = { new MonitorItsmReceiver("Sample itsm", "5def922a-3ed4-49c1-b9fd-05ec533819a3|55dfd1f8-7e59-4f89-bf56-4c82f5ace23c", "a3b9076c-ce8e-434e-85b4-aff10cb3c8f1", "{\"PayloadRevision\":0,\"WorkItemType\":\"Incident\",\"UseTemplate\":false,\"WorkItemData\":\"{}\",\"CreateOneWIPerCI\":false}", new AzureLocation("westcentralus")) }, + AzureAppPushReceivers = { new MonitorAzureAppPushReceiver("Sample azureAppPush", "johndoe@email.com") }, + AutomationRunbookReceivers = {new MonitorAutomationRunbookReceiver(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest"), "Sample runbook", new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest/webhooks/Alert1510184037084"), false) { Name = "testRunbook", ServiceUri = new Uri(""), UseCommonAlertSchema = true, -} -}, - VoiceReceivers = -{ -new MonitorVoiceReceiver("Sample voice","1","1234567890") -}, - LogicAppReceivers = -{ -new MonitorLogicAppReceiver("Sample logicApp",new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/testLogicApp"),new Uri("https://prod-27.northcentralus.logic.azure.com/workflows/68e572e818e5457ba898763b7db90877/triggers/manual/paths/invoke/azns/test?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Abpsb72UYJxPPvmDo937uzofupO5r_vIeWEx7KVHo7w")) +}}, + VoiceReceivers = { new MonitorVoiceReceiver("Sample voice", "1", "1234567890") }, + LogicAppReceivers = {new MonitorLogicAppReceiver("Sample logicApp", new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/testLogicApp"), new Uri("https://prod-27.northcentralus.logic.azure.com/workflows/68e572e818e5457ba898763b7db90877/triggers/manual/paths/invoke/azns/test?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Abpsb72UYJxPPvmDo937uzofupO5r_vIeWEx7KVHo7w")) { UseCommonAlertSchema = false, -} -}, - AzureFunctionReceivers = -{ -new MonitorAzureFunctionReceiver("Sample azureFunction",new ResourceIdentifier("/subscriptions/5def922a-3ed4-49c1-b9fd-05ec533819a3/resourceGroups/aznsTest/providers/Microsoft.Web/sites/testFunctionApp"),"HttpTriggerCSharp1",new Uri("http://test.me")) +}}, + AzureFunctionReceivers = {new MonitorAzureFunctionReceiver("Sample azureFunction", new ResourceIdentifier("/subscriptions/5def922a-3ed4-49c1-b9fd-05ec533819a3/resourceGroups/aznsTest/providers/Microsoft.Web/sites/testFunctionApp"), "HttpTriggerCSharp1", new Uri("http://test.me")) { UseCommonAlertSchema = true, -} -}, - ArmRoleReceivers = -{ -new MonitorArmRoleReceiver("Sample armRole","8e3af657-a8ff-443c-a75c-2fe8c4bcb635") +}}, + ArmRoleReceivers = {new MonitorArmRoleReceiver("Sample armRole", "8e3af657-a8ff-443c-a75c-2fe8c4bcb635") { UseCommonAlertSchema = true, -} -}, - EventHubReceivers = -{ -new MonitorEventHubReceiver("Sample eventHub","testEventHubNameSpace","testEventHub","187f412d-1758-44d9-b052-169e2564721d") +}}, + EventHubReceivers = {new MonitorEventHubReceiver("Sample eventHub", "testEventHubNameSpace", "testEventHub", "187f412d-1758-44d9-b052-169e2564721d") { TenantId = Guid.Parse("68a4459a-ccb8-493c-b9da-dd30457d1b84"), -} -}, - Tags = -{ -}, +}}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, actionGroupName, data); ActionGroupResource result = lro.Value; @@ -171,10 +136,10 @@ public async Task Get_GetAnActionGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnActionGroup() + public async Task GetAll_ListActionGroupsAtResourceGroupLevel() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/getActionGroup.json - // this example is just showing the usage of "ActionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/listActionGroups.json + // this example is just showing the usage of "ActionGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,16 +156,22 @@ public async Task Exists_GetAnActionGroup() // get the collection of this ActionGroupResource ActionGroupCollection collection = resourceGroupResource.GetActionGroups(); - // invoke the operation - string actionGroupName = "SampleActionGroup"; - bool result = await collection.ExistsAsync(actionGroupName); + // invoke the operation and iterate over the result + await foreach (ActionGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ActionGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnActionGroup() + public async Task Exists_GetAnActionGroup() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/getActionGroup.json // this example is just showing the usage of "ActionGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -222,29 +193,17 @@ public async Task GetIfExists_GetAnActionGroup() // invoke the operation string actionGroupName = "SampleActionGroup"; - NullableResponse response = await collection.GetIfExistsAsync(actionGroupName); - ActionGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(actionGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ActionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListActionGroupsAtResourceGroupLevel() + public async Task GetIfExists_GetAnActionGroup() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/listActionGroups.json - // this example is just showing the usage of "ActionGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/getActionGroup.json + // this example is just showing the usage of "ActionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -261,17 +220,23 @@ public async Task GetAll_ListActionGroupsAtResourceGroupLevel() // get the collection of this ActionGroupResource ActionGroupCollection collection = resourceGroupResource.GetActionGroups(); - // invoke the operation and iterate over the result - await foreach (ActionGroupResource item in collection.GetAllAsync()) + // invoke the operation + string actionGroupName = "SampleActionGroup"; + NullableResponse response = await collection.GetIfExistsAsync(actionGroupName); + ActionGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ActionGroupData resourceData = item.Data; + ActionGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActionGroupResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActionGroupResource.cs index eaa00761ad166..4d68471e3acbc 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActionGroupResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActionGroupResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples @@ -94,12 +93,12 @@ public async Task Update_PatchAnActionGroup() ActionGroupResource actionGroup = client.GetActionGroupResource(actionGroupResourceId); // invoke the operation - ActionGroupPatch patch = new ActionGroupPatch() + ActionGroupPatch patch = new ActionGroupPatch { Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, IsEnabled = false, }; @@ -135,86 +134,53 @@ public async Task CreateNotifications_CreateNotificationsAtResourceGroupLevel() // invoke the operation NotificationContent content = new NotificationContent("budget") { - EmailReceivers = -{ -new MonitorEmailReceiver("John Doe's email","johndoe@email.com") + EmailReceivers = {new MonitorEmailReceiver("John Doe's email", "johndoe@email.com") { UseCommonAlertSchema = false, -},new MonitorEmailReceiver("Jane Smith's email","janesmith@email.com") +}, new MonitorEmailReceiver("Jane Smith's email", "janesmith@email.com") { UseCommonAlertSchema = true, -} -}, - SmsReceivers = -{ -new MonitorSmsReceiver("John Doe's mobile","1","1234567890"),new MonitorSmsReceiver("Jane Smith's mobile","1","0987654321") -}, - WebhookReceivers = -{ -new MonitorWebhookReceiver("Sample webhook 1",new Uri("http://www.example.com/webhook1")) +}}, + SmsReceivers = { new MonitorSmsReceiver("John Doe's mobile", "1", "1234567890"), new MonitorSmsReceiver("Jane Smith's mobile", "1", "0987654321") }, + WebhookReceivers = {new MonitorWebhookReceiver("Sample webhook 1", new Uri("http://www.example.com/webhook1")) { UseCommonAlertSchema = true, -},new MonitorWebhookReceiver("Sample webhook 2",new Uri("http://www.example.com/webhook2")) +}, new MonitorWebhookReceiver("Sample webhook 2", new Uri("http://www.example.com/webhook2")) { UseCommonAlertSchema = true, UseAadAuth = true, ObjectId = "d3bb868c-fe44-452c-aa26-769a6538c808", IdentifierUri = new Uri("http://someidentifier/d7811ba3-7996-4a93-99b6-6b2f3f355f8a"), TenantId = Guid.Parse("68a4459a-ccb8-493c-b9da-dd30457d1b84"), -} -}, - ItsmReceivers = -{ -new MonitorItsmReceiver("Sample itsm","5def922a-3ed4-49c1-b9fd-05ec533819a3|55dfd1f8-7e59-4f89-bf56-4c82f5ace23c","a3b9076c-ce8e-434e-85b4-aff10cb3c8f1","{\"PayloadRevision\":0,\"WorkItemType\":\"Incident\",\"UseTemplate\":false,\"WorkItemData\":\"{}\",\"CreateOneWIPerCI\":false}",new AzureLocation("westcentralus")) -}, - AzureAppPushReceivers = -{ -new MonitorAzureAppPushReceiver("Sample azureAppPush","johndoe@email.com") -}, - AutomationRunbookReceivers = -{ -new MonitorAutomationRunbookReceiver(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest"),"Sample runbook",new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest/webhooks/Alert1510184037084"),false) +}}, + ItsmReceivers = { new MonitorItsmReceiver("Sample itsm", "5def922a-3ed4-49c1-b9fd-05ec533819a3|55dfd1f8-7e59-4f89-bf56-4c82f5ace23c", "a3b9076c-ce8e-434e-85b4-aff10cb3c8f1", "{\"PayloadRevision\":0,\"WorkItemType\":\"Incident\",\"UseTemplate\":false,\"WorkItemData\":\"{}\",\"CreateOneWIPerCI\":false}", new AzureLocation("westcentralus")) }, + AzureAppPushReceivers = { new MonitorAzureAppPushReceiver("Sample azureAppPush", "johndoe@email.com") }, + AutomationRunbookReceivers = {new MonitorAutomationRunbookReceiver(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest"), "Sample runbook", new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/runbookTest/providers/Microsoft.Automation/automationAccounts/runbooktest/webhooks/Alert1510184037084"), false) { Name = "testRunbook", ServiceUri = new Uri("http://test.me"), UseCommonAlertSchema = true, -} -}, - VoiceReceivers = -{ -new MonitorVoiceReceiver("Sample voice","1","1234567890") -}, - LogicAppReceivers = -{ -new MonitorLogicAppReceiver("Sample logicApp",new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/testLogicApp"),new Uri("https://prod-27.northcentralus.logic.azure.com/workflows/68e572e818e5457ba898763b7db90877/triggers/manual/paths/invoke/azns/test?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Abpsb72UYJxPPvmDo937uzofupO5r_vIeWEx7KVHo7w")) +}}, + VoiceReceivers = { new MonitorVoiceReceiver("Sample voice", "1", "1234567890") }, + LogicAppReceivers = {new MonitorLogicAppReceiver("Sample logicApp", new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/testLogicApp"), new Uri("https://prod-27.northcentralus.logic.azure.com/workflows/68e572e818e5457ba898763b7db90877/triggers/manual/paths/invoke/azns/test?api-version=2016-10-01&sp=%2Ftriggers%2Fmanual%2Frun&sv=1.0&sig=Abpsb72UYJxPPvmDo937uzofupO5r_vIeWEx7KVHo7w")) { UseCommonAlertSchema = false, -} -}, - AzureFunctionReceivers = -{ -new MonitorAzureFunctionReceiver("Sample azureFunction",new ResourceIdentifier("/subscriptions/5def922a-3ed4-49c1-b9fd-05ec533819a3/resourceGroups/aznsTest/providers/Microsoft.Web/sites/testFunctionApp"),"HttpTriggerCSharp1",new Uri("http://test.me")) +}}, + AzureFunctionReceivers = {new MonitorAzureFunctionReceiver("Sample azureFunction", new ResourceIdentifier("/subscriptions/5def922a-3ed4-49c1-b9fd-05ec533819a3/resourceGroups/aznsTest/providers/Microsoft.Web/sites/testFunctionApp"), "HttpTriggerCSharp1", new Uri("http://test.me")) { UseCommonAlertSchema = true, -} -}, - ArmRoleReceivers = -{ -new MonitorArmRoleReceiver("ArmRole-Common","11111111-1111-1111-1111-111111111111") +}}, + ArmRoleReceivers = {new MonitorArmRoleReceiver("ArmRole-Common", "11111111-1111-1111-1111-111111111111") { UseCommonAlertSchema = true, -},new MonitorArmRoleReceiver("ArmRole-nonCommon","11111111-1111-1111-1111-111111111111") +}, new MonitorArmRoleReceiver("ArmRole-nonCommon", "11111111-1111-1111-1111-111111111111") { UseCommonAlertSchema = false, -} -}, - EventHubReceivers = -{ -new MonitorEventHubReceiver("Sample eventHub","testEventHubNameSpace","testEventHub","187f412d-1758-44d9-b052-169e2564721d") +}}, + EventHubReceivers = {new MonitorEventHubReceiver("Sample eventHub", "testEventHubNameSpace", "testEventHub", "187f412d-1758-44d9-b052-169e2564721d") { TenantId = Guid.Parse("68a4459a-ccb8-493c-b9da-dd30457d1b84"), -} -}, +}}, }; ArmOperation lro = await actionGroup.CreateNotificationsAsync(WaitUntil.Completed, content); NotificationStatus result = lro.Value; @@ -249,37 +215,6 @@ public async Task GetNotificationStatus_GetNotificationDetailsAtResourceGroupLev Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetActionGroups_ListActionGroupsAtSubscriptionLevel() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/listActionGroups.json - // this example is just showing the usage of "ActionGroups_ListBySubscriptionId" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "187f412d-1758-44d9-b052-169e2564721d"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ActionGroupResource item in subscriptionResource.GetActionGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ActionGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task EnableReceiver_EnableTheReceiver() diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActivityLogAlertCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActivityLogAlertCollection.cs index 9e6145719a58d..732dd3640488a 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActivityLogAlertCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActivityLogAlertCollection.cs @@ -43,37 +43,26 @@ public async Task CreateOrUpdate_CreateOrUpdateAnActivityLogAlertRule() string activityLogAlertName = "SampleActivityLogAlertRule"; ActivityLogAlertData data = new ActivityLogAlertData(new AzureLocation("Global")) { - Scopes = -{ -"/subscriptions/187f412d-1758-44d9-b052-169e2564721d" -}, - ConditionAllOf = -{ -new ActivityLogAlertAnyOfOrLeafCondition() + Scopes = { "/subscriptions/187f412d-1758-44d9-b052-169e2564721d" }, + ConditionAllOf = {new ActivityLogAlertAnyOfOrLeafCondition { Field = "category", EqualsValue = "Administrative", -},new ActivityLogAlertAnyOfOrLeafCondition() +}, new ActivityLogAlertAnyOfOrLeafCondition { Field = "level", EqualsValue = "Error", -} -}, - ActionsActionGroups = -{ -new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")) +}}, + ActionsActionGroups = {new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")) { WebhookProperties = { -["sampleWebhookProperty"] = "SamplePropertyValue", -}, -} +["sampleWebhookProperty"] = "SamplePropertyValue" }, +}}, IsEnabled = true, Description = "Description of sample Activity Log Alert rule.", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, activityLogAlertName, data); ActivityLogAlertResource result = lro.Value; @@ -111,47 +100,33 @@ public async Task CreateOrUpdate_CreateOrUpdateAnActivityLogAlertRuleWithAnyOfCo string activityLogAlertName = "SampleActivityLogAlertRuleWithAnyOfCondition"; ActivityLogAlertData data = new ActivityLogAlertData(new AzureLocation("Global")) { - Scopes = -{ -"subscriptions/187f412d-1758-44d9-b052-169e2564721d" -}, - ConditionAllOf = -{ -new ActivityLogAlertAnyOfOrLeafCondition() + Scopes = { "subscriptions/187f412d-1758-44d9-b052-169e2564721d" }, + ConditionAllOf = {new ActivityLogAlertAnyOfOrLeafCondition { Field = "category", EqualsValue = "ServiceHealth", -},new ActivityLogAlertAnyOfOrLeafCondition() +}, new ActivityLogAlertAnyOfOrLeafCondition { -AnyOf = -{ -new AlertRuleLeafCondition() +AnyOf = {new AlertRuleLeafCondition { Field = "properties.incidentType", EqualsValue = "Incident", -},new AlertRuleLeafCondition() +}, new AlertRuleLeafCondition { Field = "properties.incidentType", EqualsValue = "Maintenance", -} -}, -} -}, - ActionsActionGroups = -{ -new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")) +}}, +}}, + ActionsActionGroups = {new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")) { WebhookProperties = { -["sampleWebhookProperty"] = "SamplePropertyValue", -}, -} +["sampleWebhookProperty"] = "SamplePropertyValue" }, +}}, IsEnabled = true, Description = "Description of sample Activity Log Alert rule with 'anyOf' condition.", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, activityLogAlertName, data); ActivityLogAlertResource result = lro.Value; @@ -189,40 +164,26 @@ public async Task CreateOrUpdate_CreateOrUpdateAnActivityLogAlertRuleWithContain string activityLogAlertName = "SampleActivityLogAlertRuleWithContainsAny"; ActivityLogAlertData data = new ActivityLogAlertData(new AzureLocation("Global")) { - Scopes = -{ -"subscriptions/187f412d-1758-44d9-b052-169e2564721d" -}, - ConditionAllOf = -{ -new ActivityLogAlertAnyOfOrLeafCondition() + Scopes = { "subscriptions/187f412d-1758-44d9-b052-169e2564721d" }, + ConditionAllOf = {new ActivityLogAlertAnyOfOrLeafCondition { Field = "category", EqualsValue = "ServiceHealth", -},new ActivityLogAlertAnyOfOrLeafCondition() +}, new ActivityLogAlertAnyOfOrLeafCondition { Field = "properties.impactedServices[*].ImpactedRegions[*].RegionName", -ContainsAny = -{ -"North Europe","West Europe" -}, -} -}, - ActionsActionGroups = -{ -new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")) +ContainsAny = {"North Europe", "West Europe"}, +}}, + ActionsActionGroups = {new ActivityLogAlertActionGroup(new ResourceIdentifier("/subscriptions/187f412d-1758-44d9-b052-169e2564721d/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/actionGroups/SampleActionGroup")) { WebhookProperties = { -["sampleWebhookProperty"] = "SamplePropertyValue", -}, -} +["sampleWebhookProperty"] = "SamplePropertyValue" }, +}}, IsEnabled = true, Description = "Description of sample Activity Log Alert rule with 'containsAny'.", - Tags = -{ -}, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, activityLogAlertName, data); ActivityLogAlertResource result = lro.Value; @@ -269,10 +230,10 @@ public async Task Get_GetAnActivityLogAlertRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnActivityLogAlertRule() + public async Task GetAll_ListActivityLogAlerts() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_Get.json - // this example is just showing the usage of "ActivityLogAlerts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_ListByResourceGroupName.json + // this example is just showing the usage of "ActivityLogAlerts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -289,16 +250,22 @@ public async Task Exists_GetAnActivityLogAlertRule() // get the collection of this ActivityLogAlertResource ActivityLogAlertCollection collection = resourceGroupResource.GetActivityLogAlerts(); - // invoke the operation - string activityLogAlertName = "SampleActivityLogAlertRule"; - bool result = await collection.ExistsAsync(activityLogAlertName); + // invoke the operation and iterate over the result + await foreach (ActivityLogAlertResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ActivityLogAlertData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnActivityLogAlertRule() + public async Task Exists_GetAnActivityLogAlertRule() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_Get.json // this example is just showing the usage of "ActivityLogAlerts_Get" operation, for the dependent resources, they will have to be created separately. @@ -320,29 +287,17 @@ public async Task GetIfExists_GetAnActivityLogAlertRule() // invoke the operation string activityLogAlertName = "SampleActivityLogAlertRule"; - NullableResponse response = await collection.GetIfExistsAsync(activityLogAlertName); - ActivityLogAlertResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(activityLogAlertName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ActivityLogAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListActivityLogAlerts() + public async Task GetIfExists_GetAnActivityLogAlertRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_ListByResourceGroupName.json - // this example is just showing the usage of "ActivityLogAlerts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_Get.json + // this example is just showing the usage of "ActivityLogAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -359,17 +314,23 @@ public async Task GetAll_ListActivityLogAlerts() // get the collection of this ActivityLogAlertResource ActivityLogAlertCollection collection = resourceGroupResource.GetActivityLogAlerts(); - // invoke the operation and iterate over the result - await foreach (ActivityLogAlertResource item in collection.GetAllAsync()) + // invoke the operation + string activityLogAlertName = "SampleActivityLogAlertRule"; + NullableResponse response = await collection.GetIfExistsAsync(activityLogAlertName); + ActivityLogAlertResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ActivityLogAlertData resourceData = item.Data; + ActivityLogAlertData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActivityLogAlertResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActivityLogAlertResource.cs index d831756be05ac..bf4230461cda9 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActivityLogAlertResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ActivityLogAlertResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples @@ -94,12 +93,12 @@ public async Task Update_PatchAnActivityLogAlertRule() ActivityLogAlertResource activityLogAlert = client.GetActivityLogAlertResource(activityLogAlertResourceId); // invoke the operation - ActivityLogAlertPatch patch = new ActivityLogAlertPatch() + ActivityLogAlertPatch patch = new ActivityLogAlertPatch { Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, IsEnabled = false, }; @@ -111,36 +110,5 @@ public async Task Update_PatchAnActivityLogAlertRule() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetActivityLogAlerts_GetListOfAllActivityLogAlertRulesUnderASubscription() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_ListBySubscriptionId.json - // this example is just showing the usage of "ActivityLogAlerts_ListBySubscriptionId" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "187f412d-1758-44d9-b052-169e2564721d"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ActivityLogAlertResource item in subscriptionResource.GetActivityLogAlertsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ActivityLogAlertData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AlertRuleCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AlertRuleCollection.cs index 74e33bd653457..5b68d0ccdb0d6 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AlertRuleCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AlertRuleCollection.cs @@ -46,7 +46,7 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAlertRule() { WindowSize = XmlConvert.ToTimeSpan("PT5M"), TimeAggregation = ThresholdRuleConditionTimeAggregationType.Total, - DataSource = new RuleMetricDataSource() + DataSource = new RuleMetricDataSource { MetricName = "Requests", ResourceId = new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest"), @@ -54,12 +54,8 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAlertRule() }) { Description = "Pura Vida", - Actions = -{ -}, - Tags = -{ -}, + Actions = { }, + Tags = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); AlertRuleResource result = lro.Value; @@ -106,10 +102,10 @@ public async Task Get_GetAnAlertRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAlertRule() + public async Task GetAll_ListAlertRules() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getAlertRule.json - // this example is just showing the usage of "AlertRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/listAlertRule.json + // this example is just showing the usage of "AlertRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -126,16 +122,22 @@ public async Task Exists_GetAnAlertRule() // get the collection of this AlertRuleResource AlertRuleCollection collection = resourceGroupResource.GetAlertRules(); - // invoke the operation - string ruleName = "chiricutin"; - bool result = await collection.ExistsAsync(ruleName); + // invoke the operation and iterate over the result + await foreach (AlertRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAlertRule() + public async Task Exists_GetAnAlertRule() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getAlertRule.json // this example is just showing the usage of "AlertRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -157,29 +159,17 @@ public async Task GetIfExists_GetAnAlertRule() // invoke the operation string ruleName = "chiricutin"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - AlertRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AlertRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAlertRules() + public async Task GetIfExists_GetAnAlertRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/listAlertRule.json - // this example is just showing the usage of "AlertRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getAlertRule.json + // this example is just showing the usage of "AlertRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,17 +186,23 @@ public async Task GetAll_ListAlertRules() // get the collection of this AlertRuleResource AlertRuleCollection collection = resourceGroupResource.GetAlertRules(); - // invoke the operation and iterate over the result - await foreach (AlertRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleName = "chiricutin"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + AlertRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AlertRuleData resourceData = item.Data; + AlertRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AlertRuleResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AlertRuleResource.cs index 29d797ee0da9a..3d6afcdc4591a 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AlertRuleResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AlertRuleResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples @@ -20,10 +19,10 @@ public partial class Sample_AlertRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAlertRuleIncident_GetASingleAlertRuleIncident() + public async Task Get_GetAnAlertRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getAlertRuleIncident.json - // this example is just showing the usage of "AlertRuleIncidents_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getAlertRule.json + // this example is just showing the usage of "AlertRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -34,44 +33,18 @@ public async Task GetAlertRuleIncident_GetASingleAlertRuleIncident() // for more information of creating AlertRuleResource, please refer to the document of AlertRuleResource string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; string resourceGroupName = "Rac46PostSwapRG"; - string ruleName = "myRuleName"; + string ruleName = "chiricutin"; ResourceIdentifier alertRuleResourceId = AlertRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, ruleName); AlertRuleResource alertRule = client.GetAlertRuleResource(alertRuleResourceId); // invoke the operation - string incidentName = "Website_started"; - MonitorIncident result = await alertRule.GetAlertRuleIncidentAsync(incidentName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAlertRuleIncidents_ListAlertRuleIncidents() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/listAlertRuleIncidents.json - // this example is just showing the usage of "AlertRuleIncidents_ListByAlertRule" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AlertRuleResource created on azure - // for more information of creating AlertRuleResource, please refer to the document of AlertRuleResource - string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; - string resourceGroupName = "Rac46PostSwapRG"; - string ruleName = "myRuleName"; - ResourceIdentifier alertRuleResourceId = AlertRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, ruleName); - AlertRuleResource alertRule = client.GetAlertRuleResource(alertRuleResourceId); - - // invoke the operation and iterate over the result - await foreach (MonitorIncident item in alertRule.GetAlertRuleIncidentsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } + AlertRuleResource result = await alertRule.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -100,36 +73,6 @@ public async Task Delete_DeleteAnAlertRule() Console.WriteLine("Succeeded"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAlertRule() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getAlertRule.json - // this example is just showing the usage of "AlertRules_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this AlertRuleResource created on azure - // for more information of creating AlertRuleResource, please refer to the document of AlertRuleResource - string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; - string resourceGroupName = "Rac46PostSwapRG"; - string ruleName = "chiricutin"; - ResourceIdentifier alertRuleResourceId = AlertRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, ruleName); - AlertRuleResource alertRule = client.GetAlertRuleResource(alertRuleResourceId); - - // invoke the operation - AlertRuleResource result = await alertRule.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AlertRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Update_PatchAnAlertRule() @@ -151,11 +94,11 @@ public async Task Update_PatchAnAlertRule() AlertRuleResource alertRule = client.GetAlertRuleResource(alertRuleResourceId); // invoke the operation - AlertRulePatch patch = new AlertRulePatch() + AlertRulePatch patch = new AlertRulePatch { Tags = { -["$type"] = "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary", +["$type"] = "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary" }, Name = "chiricutin", Description = "Pura Vida", @@ -164,15 +107,13 @@ public async Task Update_PatchAnAlertRule() { WindowSize = XmlConvert.ToTimeSpan("PT5M"), TimeAggregation = ThresholdRuleConditionTimeAggregationType.Total, - DataSource = new RuleMetricDataSource() + DataSource = new RuleMetricDataSource { MetricName = "Requests", ResourceId = new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/Rac46PostSwapRG/providers/Microsoft.Web/sites/leoalerttest"), }, }, - Actions = -{ -}, + Actions = { }, }; AlertRuleResource result = await alertRule.UpdateAsync(patch); @@ -185,30 +126,55 @@ public async Task Update_PatchAnAlertRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAlertRules_ListAlertRules() + public async Task GetAlertRuleIncident_GetASingleAlertRuleIncident() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getAlertRuleIncident.json + // this example is just showing the usage of "AlertRuleIncidents_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this AlertRuleResource created on azure + // for more information of creating AlertRuleResource, please refer to the document of AlertRuleResource + string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; + string resourceGroupName = "Rac46PostSwapRG"; + string ruleName = "myRuleName"; + ResourceIdentifier alertRuleResourceId = AlertRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, ruleName); + AlertRuleResource alertRule = client.GetAlertRuleResource(alertRuleResourceId); + + // invoke the operation + string incidentName = "Website_started"; + MonitorIncident result = await alertRule.GetAlertRuleIncidentAsync(incidentName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAlertRuleIncidents_ListAlertRuleIncidents() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/listAlertRuleBySubscription.json - // this example is just showing the usage of "AlertRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/listAlertRuleIncidents.json + // this example is just showing the usage of "AlertRuleIncidents_ListByAlertRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this AlertRuleResource created on azure + // for more information of creating AlertRuleResource, please refer to the document of AlertRuleResource string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "Rac46PostSwapRG"; + string ruleName = "myRuleName"; + ResourceIdentifier alertRuleResourceId = AlertRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, ruleName); + AlertRuleResource alertRule = client.GetAlertRuleResource(alertRuleResourceId); // invoke the operation and iterate over the result - await foreach (AlertRuleResource item in subscriptionResource.GetAlertRulesAsync()) + await foreach (MonitorIncident item in alertRule.GetAlertRuleIncidentsAsync()) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AlertRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {item}"); } Console.WriteLine("Succeeded"); diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AutoscaleSettingCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AutoscaleSettingCollection.cs index 1c9e3cee149b2..50f6e48fb2b9f 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AutoscaleSettingCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AutoscaleSettingCollection.cs @@ -18,41 +18,6 @@ namespace Azure.ResourceManager.Monitor.Samples { public partial class Sample_AutoscaleSettingCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAutoscaleSettings() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/listAutoscaleSetting.json - // this example is just showing the usage of "AutoscaleSettings_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; - string resourceGroupName = "TestingMetricsScaleSet"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this AutoscaleSettingResource - AutoscaleSettingCollection collection = resourceGroupResource.GetAutoscaleSettings(); - - // invoke the operation and iterate over the result - await foreach (AutoscaleSettingResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoscaleSettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateAnAutoscaleSetting() @@ -79,89 +44,104 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAutoscaleSetting() string autoscaleSettingName = "MySetting"; AutoscaleSettingData data = new AutoscaleSettingData(new AzureLocation("West US"), new AutoscaleProfile[] { -new AutoscaleProfile("adios",new MonitorScaleCapacity(1,10,1),new AutoscaleRule[] +new AutoscaleProfile("adios", new MonitorScaleCapacity(1, 10, 1), new AutoscaleRule[] { -new AutoscaleRule(new MetricTrigger("Percentage CPU",new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"),XmlConvert.ToTimeSpan("PT1M"),MetricStatisticType.Average,XmlConvert.ToTimeSpan("PT5M"),MetricTriggerTimeAggregationType.Average,MetricTriggerComparisonOperation.GreaterThan,10) +new AutoscaleRule(new MetricTrigger( + "Percentage CPU", + new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"), + XmlConvert.ToTimeSpan("PT1M"), + MetricStatisticType.Average, + XmlConvert.ToTimeSpan("PT5M"), + MetricTriggerTimeAggregationType.Average, + MetricTriggerComparisonOperation.GreaterThan, + 10) { IsDividedPerInstance = false, -},new MonitorScaleAction(MonitorScaleDirection.Increase,MonitorScaleType.ChangeCount,XmlConvert.ToTimeSpan("PT5M")) +}, new MonitorScaleAction(MonitorScaleDirection.Increase, MonitorScaleType.ChangeCount, XmlConvert.ToTimeSpan("PT5M")) { Value = "1", -}),new AutoscaleRule(new MetricTrigger("Percentage CPU",new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"),XmlConvert.ToTimeSpan("PT2M"),MetricStatisticType.Average,XmlConvert.ToTimeSpan("PT5M"),MetricTriggerTimeAggregationType.Average,MetricTriggerComparisonOperation.GreaterThan,15) +}), +new AutoscaleRule(new MetricTrigger( + "Percentage CPU", + new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"), + XmlConvert.ToTimeSpan("PT2M"), + MetricStatisticType.Average, + XmlConvert.ToTimeSpan("PT5M"), + MetricTriggerTimeAggregationType.Average, + MetricTriggerComparisonOperation.GreaterThan, + 15) { IsDividedPerInstance = false, -},new MonitorScaleAction(MonitorScaleDirection.Decrease,MonitorScaleType.ChangeCount,XmlConvert.ToTimeSpan("PT6M")) +}, new MonitorScaleAction(MonitorScaleDirection.Decrease, MonitorScaleType.ChangeCount, XmlConvert.ToTimeSpan("PT6M")) { Value = "2", }) }) { -FixedDate = new MonitorTimeWindow(DateTimeOffset.Parse("2015-03-05T14:00:00Z"),DateTimeOffset.Parse("2015-03-05T14:30:00Z")) +FixedDate = new MonitorTimeWindow(DateTimeOffset.Parse("2015-03-05T14:00:00Z"), DateTimeOffset.Parse("2015-03-05T14:30:00Z")) { TimeZone = "UTC", }, -},new AutoscaleProfile("saludos",new MonitorScaleCapacity(1,10,1),new AutoscaleRule[] +}, +new AutoscaleProfile("saludos", new MonitorScaleCapacity(1, 10, 1), new AutoscaleRule[] { -new AutoscaleRule(new MetricTrigger("Percentage CPU",new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"),XmlConvert.ToTimeSpan("PT1M"),MetricStatisticType.Average,XmlConvert.ToTimeSpan("PT5M"),MetricTriggerTimeAggregationType.Average,MetricTriggerComparisonOperation.GreaterThan,10) +new AutoscaleRule(new MetricTrigger( + "Percentage CPU", + new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"), + XmlConvert.ToTimeSpan("PT1M"), + MetricStatisticType.Average, + XmlConvert.ToTimeSpan("PT5M"), + MetricTriggerTimeAggregationType.Average, + MetricTriggerComparisonOperation.GreaterThan, + 10) { IsDividedPerInstance = false, -},new MonitorScaleAction(MonitorScaleDirection.Increase,MonitorScaleType.ChangeCount,XmlConvert.ToTimeSpan("PT5M")) +}, new MonitorScaleAction(MonitorScaleDirection.Increase, MonitorScaleType.ChangeCount, XmlConvert.ToTimeSpan("PT5M")) { Value = "1", -}),new AutoscaleRule(new MetricTrigger("Percentage CPU",new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"),XmlConvert.ToTimeSpan("PT2M"),MetricStatisticType.Average,XmlConvert.ToTimeSpan("PT5M"),MetricTriggerTimeAggregationType.Average,MetricTriggerComparisonOperation.GreaterThan,15) +}), +new AutoscaleRule(new MetricTrigger( + "Percentage CPU", + new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"), + XmlConvert.ToTimeSpan("PT2M"), + MetricStatisticType.Average, + XmlConvert.ToTimeSpan("PT5M"), + MetricTriggerTimeAggregationType.Average, + MetricTriggerComparisonOperation.GreaterThan, + 15) { IsDividedPerInstance = false, -},new MonitorScaleAction(MonitorScaleDirection.Decrease,MonitorScaleType.ChangeCount,XmlConvert.ToTimeSpan("PT6M")) +}, new MonitorScaleAction(MonitorScaleDirection.Decrease, MonitorScaleType.ChangeCount, XmlConvert.ToTimeSpan("PT6M")) { Value = "2", }) }) { -Recurrence = new MonitorRecurrence(RecurrenceFrequency.Week,new RecurrentSchedule("UTC",new MonitorDayOfWeek[] -{ -new MonitorDayOfWeek("1") -},new int[] -{ -5 -},new int[] -{ -15 -})), +Recurrence = new MonitorRecurrence(RecurrenceFrequency.Week, new RecurrentSchedule("UTC", new MonitorDayOfWeek[]{new MonitorDayOfWeek("1")}, new int[]{5}, new int[]{15})), } }) { - Notifications = -{ -new AutoscaleNotification() + Notifications = {new AutoscaleNotification { -Email = new EmailNotification() +Email = new EmailNotification { SendToSubscriptionAdministrator = true, SendToSubscriptionCoAdministrators = true, -CustomEmails = -{ -"gu@ms.com","ge@ns.net" -}, +CustomEmails = {"gu@ms.com", "ge@ns.net"}, }, -Webhooks = -{ -new WebhookNotification() +Webhooks = {new WebhookNotification { ServiceUri = new Uri("http://myservice.com"), -Properties = -{ -}, -} -}, -} -}, +Properties = {}, +}}, +}}, IsEnabled = true, PredictiveAutoscalePolicy = new PredictiveAutoscalePolicy(PredictiveAutoscalePolicyScaleMode.Enabled), TargetResourceId = new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"), Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, autoscaleSettingName, data); @@ -207,6 +187,41 @@ public async Task Get_GetAnAutoscaleSetting() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAutoscaleSettings() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/listAutoscaleSetting.json + // this example is just showing the usage of "AutoscaleSettings_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; + string resourceGroupName = "TestingMetricsScaleSet"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AutoscaleSettingResource + AutoscaleSettingCollection collection = resourceGroupResource.GetAutoscaleSettings(); + + // invoke the operation and iterate over the result + await foreach (AutoscaleSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoscaleSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAnAutoscaleSetting() diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AutoscaleSettingResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AutoscaleSettingResource.cs index 1eea8bb244817..5d65b2c201141 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AutoscaleSettingResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_AutoscaleSettingResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples @@ -20,10 +19,10 @@ public partial class Sample_AutoscaleSettingResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnAutoscaleSetting() + public async Task Get_GetAnAutoscaleSetting() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/deleteAutoscaleSetting.json - // this example is just showing the usage of "AutoscaleSettings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/getAutoscaleSetting.json + // this example is just showing the usage of "AutoscaleSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +38,21 @@ public async Task Delete_DeleteAnAutoscaleSetting() AutoscaleSettingResource autoscaleSetting = client.GetAutoscaleSettingResource(autoscaleSettingResourceId); // invoke the operation - await autoscaleSetting.DeleteAsync(WaitUntil.Completed); + AutoscaleSettingResource result = await autoscaleSetting.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoscaleSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAutoscaleSetting() + public async Task Delete_DeleteAnAutoscaleSetting() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/getAutoscaleSetting.json - // this example is just showing the usage of "AutoscaleSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/deleteAutoscaleSetting.json + // this example is just showing the usage of "AutoscaleSettings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +68,9 @@ public async Task Get_GetAnAutoscaleSetting() AutoscaleSettingResource autoscaleSetting = client.GetAutoscaleSettingResource(autoscaleSettingResourceId); // invoke the operation - AutoscaleSettingResource result = await autoscaleSetting.GetAsync(); + await autoscaleSetting.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoscaleSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -95,89 +94,100 @@ public async Task Update_PatchAnAutoscaleSetting() AutoscaleSettingResource autoscaleSetting = client.GetAutoscaleSettingResource(autoscaleSettingResourceId); // invoke the operation - AutoscaleSettingPatch patch = new AutoscaleSettingPatch() + AutoscaleSettingPatch patch = new AutoscaleSettingPatch { Tags = { -["key1"] = "value1", +["key1"] = "value1" }, - Profiles = -{ -new AutoscaleProfile("adios",new MonitorScaleCapacity(1,10,1),new AutoscaleRule[] -{ -new AutoscaleRule(new MetricTrigger("Percentage CPU",new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"),XmlConvert.ToTimeSpan("PT1M"),MetricStatisticType.Average,XmlConvert.ToTimeSpan("PT5M"),MetricTriggerTimeAggregationType.Average,MetricTriggerComparisonOperation.GreaterThan,10) + Profiles = {new AutoscaleProfile("adios", new MonitorScaleCapacity(1, 10, 1), new AutoscaleRule[] +{ +new AutoscaleRule(new MetricTrigger( + "Percentage CPU", + new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"), + XmlConvert.ToTimeSpan("PT1M"), + MetricStatisticType.Average, + XmlConvert.ToTimeSpan("PT5M"), + MetricTriggerTimeAggregationType.Average, + MetricTriggerComparisonOperation.GreaterThan, + 10) { IsDividedPerInstance = false, -},new MonitorScaleAction(MonitorScaleDirection.Increase,MonitorScaleType.ChangeCount,XmlConvert.ToTimeSpan("PT5M")) +}, new MonitorScaleAction(MonitorScaleDirection.Increase, MonitorScaleType.ChangeCount, XmlConvert.ToTimeSpan("PT5M")) { Value = "1", -}),new AutoscaleRule(new MetricTrigger("Percentage CPU",new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"),XmlConvert.ToTimeSpan("PT2M"),MetricStatisticType.Average,XmlConvert.ToTimeSpan("PT5M"),MetricTriggerTimeAggregationType.Average,MetricTriggerComparisonOperation.GreaterThan,15) +}), +new AutoscaleRule(new MetricTrigger( + "Percentage CPU", + new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"), + XmlConvert.ToTimeSpan("PT2M"), + MetricStatisticType.Average, + XmlConvert.ToTimeSpan("PT5M"), + MetricTriggerTimeAggregationType.Average, + MetricTriggerComparisonOperation.GreaterThan, + 15) { IsDividedPerInstance = false, -},new MonitorScaleAction(MonitorScaleDirection.Decrease,MonitorScaleType.ChangeCount,XmlConvert.ToTimeSpan("PT6M")) +}, new MonitorScaleAction(MonitorScaleDirection.Decrease, MonitorScaleType.ChangeCount, XmlConvert.ToTimeSpan("PT6M")) { Value = "2", }) }) { -FixedDate = new MonitorTimeWindow(DateTimeOffset.Parse("2015-03-05T14:00:00Z"),DateTimeOffset.Parse("2015-03-05T14:30:00Z")) +FixedDate = new MonitorTimeWindow(DateTimeOffset.Parse("2015-03-05T14:00:00Z"), DateTimeOffset.Parse("2015-03-05T14:30:00Z")) { TimeZone = "UTC", }, -},new AutoscaleProfile("saludos",new MonitorScaleCapacity(1,10,1),new AutoscaleRule[] -{ -new AutoscaleRule(new MetricTrigger("Percentage CPU",new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"),XmlConvert.ToTimeSpan("PT1M"),MetricStatisticType.Average,XmlConvert.ToTimeSpan("PT5M"),MetricTriggerTimeAggregationType.Average,MetricTriggerComparisonOperation.GreaterThan,10) +}, new AutoscaleProfile("saludos", new MonitorScaleCapacity(1, 10, 1), new AutoscaleRule[] +{ +new AutoscaleRule(new MetricTrigger( + "Percentage CPU", + new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"), + XmlConvert.ToTimeSpan("PT1M"), + MetricStatisticType.Average, + XmlConvert.ToTimeSpan("PT5M"), + MetricTriggerTimeAggregationType.Average, + MetricTriggerComparisonOperation.GreaterThan, + 10) { IsDividedPerInstance = false, -},new MonitorScaleAction(MonitorScaleDirection.Increase,MonitorScaleType.ChangeCount,XmlConvert.ToTimeSpan("PT5M")) +}, new MonitorScaleAction(MonitorScaleDirection.Increase, MonitorScaleType.ChangeCount, XmlConvert.ToTimeSpan("PT5M")) { Value = "1", -}),new AutoscaleRule(new MetricTrigger("Percentage CPU",new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"),XmlConvert.ToTimeSpan("PT2M"),MetricStatisticType.Average,XmlConvert.ToTimeSpan("PT5M"),MetricTriggerTimeAggregationType.Average,MetricTriggerComparisonOperation.GreaterThan,15) +}), +new AutoscaleRule(new MetricTrigger( + "Percentage CPU", + new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"), + XmlConvert.ToTimeSpan("PT2M"), + MetricStatisticType.Average, + XmlConvert.ToTimeSpan("PT5M"), + MetricTriggerTimeAggregationType.Average, + MetricTriggerComparisonOperation.GreaterThan, + 15) { IsDividedPerInstance = false, -},new MonitorScaleAction(MonitorScaleDirection.Decrease,MonitorScaleType.ChangeCount,XmlConvert.ToTimeSpan("PT6M")) +}, new MonitorScaleAction(MonitorScaleDirection.Decrease, MonitorScaleType.ChangeCount, XmlConvert.ToTimeSpan("PT6M")) { Value = "2", }) }) { -Recurrence = new MonitorRecurrence(RecurrenceFrequency.Week,new RecurrentSchedule("UTC",new MonitorDayOfWeek[] +Recurrence = new MonitorRecurrence(RecurrenceFrequency.Week, new RecurrentSchedule("UTC", new MonitorDayOfWeek[]{new MonitorDayOfWeek("1")}, new int[]{5}, new int[]{15})), +}}, + Notifications = {new AutoscaleNotification { -new MonitorDayOfWeek("1") -},new int[] -{ -5 -},new int[] -{ -15 -})), -} -}, - Notifications = -{ -new AutoscaleNotification() -{ -Email = new EmailNotification() +Email = new EmailNotification { SendToSubscriptionAdministrator = true, SendToSubscriptionCoAdministrators = true, -CustomEmails = -{ -"gu@ms.com","ge@ns.net" -}, +CustomEmails = {"gu@ms.com", "ge@ns.net"}, }, -Webhooks = -{ -new WebhookNotification() +Webhooks = {new WebhookNotification { ServiceUri = new Uri("http://myservice.com"), -Properties = -{ -}, -} -}, -} -}, +Properties = {}, +}}, +}}, IsEnabled = true, PredictiveAutoscalePolicy = new PredictiveAutoscalePolicy(PredictiveAutoscalePolicyScaleMode.Enabled), TargetResourceId = new ResourceIdentifier("/subscriptions/b67f7fec-69fc-4974-9099-a26bd6ffeda3/resourceGroups/TestingMetricsScaleSet/providers/Microsoft.Compute/virtualMachineScaleSets/testingsc"), @@ -191,37 +201,6 @@ public async Task Update_PatchAnAutoscaleSetting() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAutoscaleSettings_ListAutoscaleSettingsBySubs() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/listAutoscaleSettingBySubscription.json - // this example is just showing the usage of "AutoscaleSettings_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AutoscaleSettingResource item in subscriptionResource.GetAutoscaleSettingsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AutoscaleSettingData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetPredictiveMetric_GetMetricForData() diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionEndpointCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionEndpointCollection.cs index 4f82d99dcbd88..3f1558725eab9 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionEndpointCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionEndpointCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DataCollectionEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDataCollectionEndpointsByResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateDataCollectionEndpoint() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsListByResourceGroup.json - // this example is just showing the usage of "DataCollectionEndpoints_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsCreate.json + // this example is just showing the usage of "DataCollectionEndpoints_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ListDataCollectionEndpointsByResourceGroup() // get the collection of this DataCollectionEndpointResource DataCollectionEndpointCollection collection = resourceGroupResource.GetDataCollectionEndpoints(); - // invoke the operation and iterate over the result - await foreach (DataCollectionEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string dataCollectionEndpointName = "myCollectionEndpoint"; + DataCollectionEndpointData data = new DataCollectionEndpointData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PublicNetworkAccess = MonitorPublicNetworkAccess.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataCollectionEndpointName, data); + DataCollectionEndpointResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetDataCollectionEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDataCollectionEndpoint() + public async Task GetAll_ListDataCollectionEndpointsByResourceGroup() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsGet.json - // this example is just showing the usage of "DataCollectionEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsListByResourceGroup.json + // this example is just showing the usage of "DataCollectionEndpoints_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +110,22 @@ public async Task Exists_GetDataCollectionEndpoint() // get the collection of this DataCollectionEndpointResource DataCollectionEndpointCollection collection = resourceGroupResource.GetDataCollectionEndpoints(); - // invoke the operation - string dataCollectionEndpointName = "myCollectionEndpoint"; - bool result = await collection.ExistsAsync(dataCollectionEndpointName); + // invoke the operation and iterate over the result + await foreach (DataCollectionEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDataCollectionEndpoint() + public async Task Exists_GetDataCollectionEndpoint() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsGet.json // this example is just showing the usage of "DataCollectionEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +147,17 @@ public async Task GetIfExists_GetDataCollectionEndpoint() // invoke the operation string dataCollectionEndpointName = "myCollectionEndpoint"; - NullableResponse response = await collection.GetIfExistsAsync(dataCollectionEndpointName); - DataCollectionEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataCollectionEndpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDataCollectionEndpoint() + public async Task GetIfExists_GetDataCollectionEndpoint() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsCreate.json - // this example is just showing the usage of "DataCollectionEndpoints_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsGet.json + // this example is just showing the usage of "DataCollectionEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,18 +176,21 @@ public async Task CreateOrUpdate_CreateOrUpdateDataCollectionEndpoint() // invoke the operation string dataCollectionEndpointName = "myCollectionEndpoint"; - DataCollectionEndpointData data = new DataCollectionEndpointData(new AzureLocation("eastus")) - { - PublicNetworkAccess = MonitorPublicNetworkAccess.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataCollectionEndpointName, data); - DataCollectionEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dataCollectionEndpointName); + DataCollectionEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionEndpointResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionEndpointResource.cs index f0f43406bc8b8..ef7f0437213a4 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionEndpointResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionEndpointResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples { public partial class Sample_DataCollectionEndpointResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDataCollectionEndpoints_ListDataCollectionEndpointsBySubscription() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsListBySubscription.json - // this example is just showing the usage of "DataCollectionEndpoints_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "703362b3-f278-4e4b-9179-c76eaf41ffc2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DataCollectionEndpointResource item in subscriptionResource.GetDataCollectionEndpointsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetDataCollectionEndpoint() @@ -80,10 +48,10 @@ public async Task Get_GetDataCollectionEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateDataCollectionEndpoint() + public async Task Delete_DeleteDataCollectionEndpoint() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsUpdate.json - // this example is just showing the usage of "DataCollectionEndpoints_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsDelete.json + // this example is just showing the usage of "DataCollectionEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,30 +67,17 @@ public async Task Update_UpdateDataCollectionEndpoint() DataCollectionEndpointResource dataCollectionEndpoint = client.GetDataCollectionEndpointResource(dataCollectionEndpointResourceId); // invoke the operation - ResourceForUpdate body = new ResourceForUpdate() - { - Tags = -{ -["tag1"] = "A", -["tag2"] = "B", -["tag3"] = "C", -}, - }; - DataCollectionEndpointResource result = await dataCollectionEndpoint.UpdateAsync(body); + await dataCollectionEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDataCollectionEndpoint() + public async Task Update_UpdateDataCollectionEndpoint() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsDelete.json - // this example is just showing the usage of "DataCollectionEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsUpdate.json + // this example is just showing the usage of "DataCollectionEndpoints_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,9 +93,22 @@ public async Task Delete_DeleteDataCollectionEndpoint() DataCollectionEndpointResource dataCollectionEndpoint = client.GetDataCollectionEndpointResource(dataCollectionEndpointResourceId); // invoke the operation - await dataCollectionEndpoint.DeleteAsync(WaitUntil.Completed); + ResourceForUpdate body = new ResourceForUpdate + { + Tags = +{ +["tag1"] = "A", +["tag2"] = "B", +["tag3"] = "C" +}, + }; + DataCollectionEndpointResource result = await dataCollectionEndpoint.UpdateAsync(body); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleAssociationCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleAssociationCollection.cs index 02ded994f996f..fd36ce54d2851 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleAssociationCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleAssociationCollection.cs @@ -17,35 +17,34 @@ public partial class Sample_DataCollectionRuleAssociationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAssociationsForSpecifiedResource() + public async Task CreateOrUpdate_CreateOrUpdateAssociation() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRuleAssociationsListByResource.json - // this example is just showing the usage of "DataCollectionRuleAssociations_ListByResource" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRuleAssociationsCreate.json + // this example is just showing the usage of "DataCollectionRuleAssociations_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DataCollectionRuleAssociationResource string resourceUri = "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DataCollectionRuleAssociationCollection collection = client.GetDataCollectionRuleAssociations(scopeId); + DataCollectionRuleAssociationCollection collection = client.GetDataCollectionRuleAssociations(new ResourceIdentifier(resourceUri)); - // invoke the operation and iterate over the result - await foreach (DataCollectionRuleAssociationResource item in collection.GetAllAsync()) + // invoke the operation + string associationName = "myAssociation"; + DataCollectionRuleAssociationData data = new DataCollectionRuleAssociationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionRuleAssociationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DataCollectionRuleId = new ResourceIdentifier("/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Insights/dataCollectionRules/myCollectionRule"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, associationName, data); + DataCollectionRuleAssociationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionRuleAssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -60,13 +59,9 @@ public async Task Get_GetAssociation() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DataCollectionRuleAssociationResource string resourceUri = "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DataCollectionRuleAssociationCollection collection = client.GetDataCollectionRuleAssociations(scopeId); + DataCollectionRuleAssociationCollection collection = client.GetDataCollectionRuleAssociations(new ResourceIdentifier(resourceUri)); // invoke the operation string associationName = "myAssociation"; @@ -79,6 +74,35 @@ public async Task Get_GetAssociation() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListAssociationsForSpecifiedResource() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRuleAssociationsListByResource.json + // this example is just showing the usage of "DataCollectionRuleAssociations_ListByResource" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this DataCollectionRuleAssociationResource + string resourceUri = "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"; + DataCollectionRuleAssociationCollection collection = client.GetDataCollectionRuleAssociations(new ResourceIdentifier(resourceUri)); + + // invoke the operation and iterate over the result + await foreach (DataCollectionRuleAssociationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionRuleAssociationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetAssociation() @@ -91,13 +115,9 @@ public async Task Exists_GetAssociation() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DataCollectionRuleAssociationResource string resourceUri = "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DataCollectionRuleAssociationCollection collection = client.GetDataCollectionRuleAssociations(scopeId); + DataCollectionRuleAssociationCollection collection = client.GetDataCollectionRuleAssociations(new ResourceIdentifier(resourceUri)); // invoke the operation string associationName = "myAssociation"; @@ -118,13 +138,9 @@ public async Task GetIfExists_GetAssociation() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DataCollectionRuleAssociationResource string resourceUri = "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DataCollectionRuleAssociationCollection collection = client.GetDataCollectionRuleAssociations(scopeId); + DataCollectionRuleAssociationCollection collection = client.GetDataCollectionRuleAssociations(new ResourceIdentifier(resourceUri)); // invoke the operation string associationName = "myAssociation"; @@ -144,41 +160,5 @@ public async Task GetIfExists_GetAssociation() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAssociation() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRuleAssociationsCreate.json - // this example is just showing the usage of "DataCollectionRuleAssociations_Create" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this DataCollectionRuleAssociationResource - string resourceUri = "subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVm"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DataCollectionRuleAssociationCollection collection = client.GetDataCollectionRuleAssociations(scopeId); - - // invoke the operation - string associationName = "myAssociation"; - DataCollectionRuleAssociationData data = new DataCollectionRuleAssociationData() - { - DataCollectionRuleId = new ResourceIdentifier("/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Insights/dataCollectionRules/myCollectionRule"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, associationName, data); - DataCollectionRuleAssociationResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionRuleAssociationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleAssociationResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleAssociationResource.cs index 335ac6c92eb7d..f821a2569c654 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleAssociationResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleAssociationResource.cs @@ -46,10 +46,10 @@ public async Task Get_GetAssociation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAssociation() + public async Task Delete_DeleteAssociation() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRuleAssociationsCreate.json - // this example is just showing the usage of "DataCollectionRuleAssociations_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRuleAssociationsDelete.json + // this example is just showing the usage of "DataCollectionRuleAssociations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,26 +64,17 @@ public async Task Update_CreateOrUpdateAssociation() DataCollectionRuleAssociationResource dataCollectionRuleAssociation = client.GetDataCollectionRuleAssociationResource(dataCollectionRuleAssociationResourceId); // invoke the operation - DataCollectionRuleAssociationData data = new DataCollectionRuleAssociationData() - { - DataCollectionRuleId = new ResourceIdentifier("/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Insights/dataCollectionRules/myCollectionRule"), - }; - ArmOperation lro = await dataCollectionRuleAssociation.UpdateAsync(WaitUntil.Completed, data); - DataCollectionRuleAssociationResource result = lro.Value; + await dataCollectionRuleAssociation.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionRuleAssociationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAssociation() + public async Task Update_CreateOrUpdateAssociation() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRuleAssociationsDelete.json - // this example is just showing the usage of "DataCollectionRuleAssociations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRuleAssociationsCreate.json + // this example is just showing the usage of "DataCollectionRuleAssociations_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,9 +89,18 @@ public async Task Delete_DeleteAssociation() DataCollectionRuleAssociationResource dataCollectionRuleAssociation = client.GetDataCollectionRuleAssociationResource(dataCollectionRuleAssociationResourceId); // invoke the operation - await dataCollectionRuleAssociation.DeleteAsync(WaitUntil.Completed); + DataCollectionRuleAssociationData data = new DataCollectionRuleAssociationData + { + DataCollectionRuleId = new ResourceIdentifier("/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.Insights/dataCollectionRules/myCollectionRule"), + }; + ArmOperation lro = await dataCollectionRuleAssociation.UpdateAsync(WaitUntil.Completed, data); + DataCollectionRuleAssociationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionRuleAssociationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleCollection.cs index 60dd7545e8bd4..b8880a2583b54 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_DataCollectionRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDataCollectionRulesByResourceGroup() + public async Task CreateOrUpdate_CreateOrUpdateDataCollectionRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesListByResourceGroup.json - // this example is just showing the usage of "DataCollectionRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesCreate.json + // this example is just showing the usage of "DataCollectionRules_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,72 @@ public async Task GetAll_ListDataCollectionRulesByResourceGroup() // get the collection of this DataCollectionRuleResource DataCollectionRuleCollection collection = resourceGroupResource.GetDataCollectionRules(); - // invoke the operation and iterate over the result - await foreach (DataCollectionRuleResource item in collection.GetAllAsync()) + // invoke the operation + string dataCollectionRuleName = "myCollectionRule"; + DataCollectionRuleData data = new DataCollectionRuleData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DataSources = new DataCollectionRuleDataSources + { + PerformanceCounters = {new PerfCounterDataSource +{ +Streams = {PerfCounterDataSourceStream.MicrosoftPerf}, +SamplingFrequencyInSeconds = 15, +CounterSpecifiers = {"\\Processor(_Total)\\% Processor Time", "\\Memory\\Committed Bytes", "\\LogicalDisk(_Total)\\Free Megabytes", "\\PhysicalDisk(_Total)\\Avg. Disk Queue Length"}, +Name = "cloudTeamCoreCounters", +}, new PerfCounterDataSource +{ +Streams = {PerfCounterDataSourceStream.MicrosoftPerf}, +SamplingFrequencyInSeconds = 30, +CounterSpecifiers = {"\\Process(_Total)\\Thread Count"}, +Name = "appTeamExtraCounters", +}}, + WindowsEventLogs = {new WindowsEventLogDataSource +{ +Streams = {WindowsEventLogDataSourceStream.MicrosoftWindowsEvent}, +XPathQueries = {"Security!"}, +Name = "cloudSecurityTeamEvents", +}, new WindowsEventLogDataSource +{ +Streams = {WindowsEventLogDataSourceStream.MicrosoftWindowsEvent}, +XPathQueries = {"System![System[(Level = 1 or Level = 2 or Level = 3)]]", "Application!*[System[(Level = 1 or Level = 2 or Level = 3)]]"}, +Name = "appTeam1AppEvents", +}}, + Syslog = {new SyslogDataSource +{ +Streams = {SyslogDataSourceStream.MicrosoftSyslog}, +FacilityNames = {SyslogDataSourceFacilityName.Cron}, +LogLevels = {SyslogDataSourceLogLevel.Debug, SyslogDataSourceLogLevel.Critical, SyslogDataSourceLogLevel.Emergency}, +Name = "cronSyslog", +}, new SyslogDataSource +{ +Streams = {SyslogDataSourceStream.MicrosoftSyslog}, +FacilityNames = {SyslogDataSourceFacilityName.Syslog}, +LogLevels = {SyslogDataSourceLogLevel.Alert, SyslogDataSourceLogLevel.Critical, SyslogDataSourceLogLevel.Emergency}, +Name = "syslogBase", +}}, + }, + Destinations = new DataCollectionRuleDestinations + { + LogAnalytics = {new LogAnalyticsDestination +{ +WorkspaceResourceId = new ResourceIdentifier("/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/centralTeamWorkspace"), +Name = "centralWorkspace", +}}, + }, + DataFlows = {new DataFlow +{ +Streams = {DataFlowStream.MicrosoftPerf, DataFlowStream.MicrosoftSyslog, DataFlowStream.MicrosoftWindowsEvent}, +Destinations = {"centralWorkspace"}, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataCollectionRuleName, data); + DataCollectionRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +142,10 @@ public async Task Get_GetDataCollectionRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDataCollectionRule() + public async Task GetAll_ListDataCollectionRulesByResourceGroup() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesGet.json - // this example is just showing the usage of "DataCollectionRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesListByResourceGroup.json + // this example is just showing the usage of "DataCollectionRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +162,22 @@ public async Task Exists_GetDataCollectionRule() // get the collection of this DataCollectionRuleResource DataCollectionRuleCollection collection = resourceGroupResource.GetDataCollectionRules(); - // invoke the operation - string dataCollectionRuleName = "myCollectionRule"; - bool result = await collection.ExistsAsync(dataCollectionRuleName); + // invoke the operation and iterate over the result + await foreach (DataCollectionRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDataCollectionRule() + public async Task Exists_GetDataCollectionRule() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesGet.json // this example is just showing the usage of "DataCollectionRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +199,17 @@ public async Task GetIfExists_GetDataCollectionRule() // invoke the operation string dataCollectionRuleName = "myCollectionRule"; - NullableResponse response = await collection.GetIfExistsAsync(dataCollectionRuleName); - DataCollectionRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dataCollectionRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateDataCollectionRule() + public async Task GetIfExists_GetDataCollectionRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesCreate.json - // this example is just showing the usage of "DataCollectionRules_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesGet.json + // this example is just showing the usage of "DataCollectionRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,133 +228,21 @@ public async Task CreateOrUpdate_CreateOrUpdateDataCollectionRule() // invoke the operation string dataCollectionRuleName = "myCollectionRule"; - DataCollectionRuleData data = new DataCollectionRuleData(new AzureLocation("eastus")) - { - DataSources = new DataCollectionRuleDataSources() - { - PerformanceCounters = -{ -new PerfCounterDataSource() -{ -Streams = -{ -PerfCounterDataSourceStream.MicrosoftPerf -}, -SamplingFrequencyInSeconds = 15, -CounterSpecifiers = -{ -"\\Processor(_Total)\\% Processor Time","\\Memory\\Committed Bytes","\\LogicalDisk(_Total)\\Free Megabytes","\\PhysicalDisk(_Total)\\Avg. Disk Queue Length" -}, -Name = "cloudTeamCoreCounters", -},new PerfCounterDataSource() -{ -Streams = -{ -PerfCounterDataSourceStream.MicrosoftPerf -}, -SamplingFrequencyInSeconds = 30, -CounterSpecifiers = -{ -"\\Process(_Total)\\Thread Count" -}, -Name = "appTeamExtraCounters", -} -}, - WindowsEventLogs = -{ -new WindowsEventLogDataSource() -{ -Streams = -{ -WindowsEventLogDataSourceStream.MicrosoftWindowsEvent -}, -XPathQueries = -{ -"Security!" -}, -Name = "cloudSecurityTeamEvents", -},new WindowsEventLogDataSource() -{ -Streams = -{ -WindowsEventLogDataSourceStream.MicrosoftWindowsEvent -}, -XPathQueries = -{ -"System![System[(Level = 1 or Level = 2 or Level = 3)]]","Application!*[System[(Level = 1 or Level = 2 or Level = 3)]]" -}, -Name = "appTeam1AppEvents", -} -}, - Syslog = -{ -new SyslogDataSource() -{ -Streams = -{ -SyslogDataSourceStream.MicrosoftSyslog -}, -FacilityNames = -{ -SyslogDataSourceFacilityName.Cron -}, -LogLevels = -{ -SyslogDataSourceLogLevel.Debug,SyslogDataSourceLogLevel.Critical,SyslogDataSourceLogLevel.Emergency -}, -Name = "cronSyslog", -},new SyslogDataSource() -{ -Streams = -{ -SyslogDataSourceStream.MicrosoftSyslog -}, -FacilityNames = -{ -SyslogDataSourceFacilityName.Syslog -}, -LogLevels = -{ -SyslogDataSourceLogLevel.Alert,SyslogDataSourceLogLevel.Critical,SyslogDataSourceLogLevel.Emergency -}, -Name = "syslogBase", -} -}, - }, - Destinations = new DataCollectionRuleDestinations() - { - LogAnalytics = -{ -new LogAnalyticsDestination() -{ -WorkspaceResourceId = new ResourceIdentifier("/subscriptions/703362b3-f278-4e4b-9179-c76eaf41ffc2/resourceGroups/myResourceGroup/providers/Microsoft.OperationalInsights/workspaces/centralTeamWorkspace"), -Name = "centralWorkspace", -} -}, - }, - DataFlows = -{ -new DataFlow() -{ -Streams = -{ -DataFlowStream.MicrosoftPerf,DataFlowStream.MicrosoftSyslog,DataFlowStream.MicrosoftWindowsEvent -}, -Destinations = -{ -"centralWorkspace" -}, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dataCollectionRuleName, data); - DataCollectionRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(dataCollectionRuleName); + DataCollectionRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleResource.cs index f738cca0037b0..d5909c76f6b5b 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DataCollectionRuleResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples @@ -19,10 +18,10 @@ public partial class Sample_DataCollectionRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetDataCollectionRuleAssociationsByRule_ListAssociationsForSpecifiedDataCollectionRule() + public async Task Get_GetDataCollectionRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRuleAssociationsListByRule.json - // this example is just showing the usage of "DataCollectionRuleAssociations_ListByRule" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesGet.json + // this example is just showing the usage of "DataCollectionRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,56 +36,22 @@ public async Task GetDataCollectionRuleAssociationsByRule_ListAssociationsForSpe ResourceIdentifier dataCollectionRuleResourceId = DataCollectionRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, dataCollectionRuleName); DataCollectionRuleResource dataCollectionRule = client.GetDataCollectionRuleResource(dataCollectionRuleResourceId); - // invoke the operation and iterate over the result - await foreach (DataCollectionRuleAssociationResource item in dataCollectionRule.GetDataCollectionRuleAssociationsByRuleAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionRuleAssociationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDataCollectionRules_ListDataCollectionRulesBySubscription() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesListBySubscription.json - // this example is just showing the usage of "DataCollectionRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "703362b3-f278-4e4b-9179-c76eaf41ffc2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DataCollectionRuleResource item in subscriptionResource.GetDataCollectionRulesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + DataCollectionRuleResource result = await dataCollectionRule.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDataCollectionRule() + public async Task Delete_DeleteDataCollectionRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesGet.json - // this example is just showing the usage of "DataCollectionRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesDelete.json + // this example is just showing the usage of "DataCollectionRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,13 +67,9 @@ public async Task Get_GetDataCollectionRule() DataCollectionRuleResource dataCollectionRule = client.GetDataCollectionRuleResource(dataCollectionRuleResourceId); // invoke the operation - DataCollectionRuleResource result = await dataCollectionRule.GetAsync(); + await dataCollectionRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DataCollectionRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -132,13 +93,13 @@ public async Task Update_UpdateDataCollectionRule() DataCollectionRuleResource dataCollectionRule = client.GetDataCollectionRuleResource(dataCollectionRuleResourceId); // invoke the operation - ResourceForUpdate body = new ResourceForUpdate() + ResourceForUpdate body = new ResourceForUpdate { Tags = { ["tag1"] = "A", ["tag2"] = "B", -["tag3"] = "C", +["tag3"] = "C" }, }; DataCollectionRuleResource result = await dataCollectionRule.UpdateAsync(body); @@ -152,10 +113,10 @@ public async Task Update_UpdateDataCollectionRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDataCollectionRule() + public async Task GetDataCollectionRuleAssociationsByRule_ListAssociationsForSpecifiedDataCollectionRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesDelete.json - // this example is just showing the usage of "DataCollectionRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRuleAssociationsListByRule.json + // this example is just showing the usage of "DataCollectionRuleAssociations_ListByRule" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -170,8 +131,15 @@ public async Task Delete_DeleteDataCollectionRule() ResourceIdentifier dataCollectionRuleResourceId = DataCollectionRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, dataCollectionRuleName); DataCollectionRuleResource dataCollectionRule = client.GetDataCollectionRuleResource(dataCollectionRuleResourceId); - // invoke the operation - await dataCollectionRule.DeleteAsync(WaitUntil.Completed); + // invoke the operation and iterate over the result + await foreach (DataCollectionRuleAssociationResource item in dataCollectionRule.GetDataCollectionRuleAssociationsByRuleAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionRuleAssociationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } Console.WriteLine("Succeeded"); } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingCollection.cs index 3e75466c9712d..17ffd3fa9bcb8 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingCollection.cs @@ -18,27 +18,43 @@ public partial class Sample_DiagnosticSettingCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsTheDiagnosticSetting() + public async Task CreateOrUpdate_CreatesOrUpdatesTheDiagnosticSetting() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json - // this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/createOrUpdateDiagnosticSetting.json + // this example is just showing the usage of "DiagnosticSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingCollection collection = client.GetDiagnosticSettings(scopeId); + DiagnosticSettingCollection collection = client.GetDiagnosticSettings(new ResourceIdentifier(resourceUri)); // invoke the operation string name = "mysetting"; - DiagnosticSettingResource result = await collection.GetAsync(name); + DiagnosticSettingData data = new DiagnosticSettingData + { + StorageAccountId = new ResourceIdentifier("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1"), + EventHubAuthorizationRuleId = new ResourceIdentifier("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule"), + EventHubName = "myeventhub", + Metrics = {new MetricSettings(true) +{ +Category = "WorkflowMetrics", +RetentionPolicy = new RetentionPolicy(false, 0), +}}, + Logs = {new LogSettings(true) +{ +CategoryGroup = "allLogs", +RetentionPolicy = new RetentionPolicy(false, 0), +}}, + WorkspaceId = new ResourceIdentifier(""), + MarketplacePartnerId = new ResourceIdentifier("/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1"), + LogAnalyticsDestinationType = "Dedicated", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DiagnosticSettingResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,34 +65,54 @@ public async Task Get_GetsTheDiagnosticSetting() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheDiagnosticSetting() + public async Task CreateOrUpdate_CreatesOrUpdatesTheDiagnosticSettingForCategory() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json - // this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/createOrUpdateDiagnosticSettingCategory.json + // this example is just showing the usage of "DiagnosticSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingCollection collection = client.GetDiagnosticSettings(scopeId); + DiagnosticSettingCollection collection = client.GetDiagnosticSettings(new ResourceIdentifier(resourceUri)); // invoke the operation string name = "mysetting"; - bool result = await collection.ExistsAsync(name); + DiagnosticSettingData data = new DiagnosticSettingData + { + StorageAccountId = new ResourceIdentifier("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1"), + EventHubAuthorizationRuleId = new ResourceIdentifier("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule"), + EventHubName = "myeventhub", + Metrics = {new MetricSettings(true) +{ +Category = "WorkflowMetrics", +RetentionPolicy = new RetentionPolicy(false, 0), +}}, + Logs = {new LogSettings(true) +{ +Category = "WorkflowRuntime", +RetentionPolicy = new RetentionPolicy(false, 0), +}}, + WorkspaceId = new ResourceIdentifier(""), + MarketplacePartnerId = new ResourceIdentifier("/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1"), + LogAnalyticsDestinationType = "Dedicated", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + DiagnosticSettingResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheDiagnosticSetting() + public async Task Get_GetsTheDiagnosticSetting() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json // this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -86,31 +122,19 @@ public async Task GetIfExists_GetsTheDiagnosticSetting() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingCollection collection = client.GetDiagnosticSettings(scopeId); + DiagnosticSettingCollection collection = client.GetDiagnosticSettings(new ResourceIdentifier(resourceUri)); // invoke the operation string name = "mysetting"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DiagnosticSettingResource result = response.HasValue ? response.Value : null; + DiagnosticSettingResource result = await collection.GetAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticSettingData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -125,13 +149,9 @@ public async Task Get_GetsTheDiagnosticSettingForCategory() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingCollection collection = client.GetDiagnosticSettings(scopeId); + DiagnosticSettingCollection collection = client.GetDiagnosticSettings(new ResourceIdentifier(resourceUri)); // invoke the operation string name = "mysetting"; @@ -146,248 +166,176 @@ public async Task Get_GetsTheDiagnosticSettingForCategory() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsTheDiagnosticSettingForCategory() + public async Task GetAll_GetsTheDiagnosticSetting() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json - // this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/listDiagnosticSettings.json + // this example is just showing the usage of "DiagnosticSettings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingCollection collection = client.GetDiagnosticSettings(scopeId); + DiagnosticSettingCollection collection = client.GetDiagnosticSettings(new ResourceIdentifier(resourceUri)); - // invoke the operation - string name = "mysetting"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (DiagnosticSettingResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsTheDiagnosticSettingForCategory() + public async Task GetAll_GetsTheDiagnosticSettingForCategory() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json - // this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/listDiagnosticSettingsCategory.json + // this example is just showing the usage of "DiagnosticSettings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingCollection collection = client.GetDiagnosticSettings(scopeId); + DiagnosticSettingCollection collection = client.GetDiagnosticSettings(new ResourceIdentifier(resourceUri)); - // invoke the operation - string name = "mysetting"; - NullableResponse response = await collection.GetIfExistsAsync(name); - DiagnosticSettingResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DiagnosticSettingResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DiagnosticSettingData resourceData = result.Data; + DiagnosticSettingData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesTheDiagnosticSetting() + public async Task Exists_GetsTheDiagnosticSetting() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/createOrUpdateDiagnosticSetting.json - // this example is just showing the usage of "DiagnosticSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json + // this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingCollection collection = client.GetDiagnosticSettings(scopeId); + DiagnosticSettingCollection collection = client.GetDiagnosticSettings(new ResourceIdentifier(resourceUri)); // invoke the operation string name = "mysetting"; - DiagnosticSettingData data = new DiagnosticSettingData() - { - StorageAccountId = new ResourceIdentifier("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1"), - EventHubAuthorizationRuleId = new ResourceIdentifier("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule"), - EventHubName = "myeventhub", - Metrics = -{ -new MetricSettings(true) -{ -Category = "WorkflowMetrics", -RetentionPolicy = new RetentionPolicy(false,0), -} -}, - Logs = -{ -new LogSettings(true) -{ -CategoryGroup = "allLogs", -RetentionPolicy = new RetentionPolicy(false,0), -} -}, - WorkspaceId = new ResourceIdentifier(""), - MarketplacePartnerId = new ResourceIdentifier("/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1"), - LogAnalyticsDestinationType = "Dedicated", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DiagnosticSettingResource result = lro.Value; + bool result = await collection.ExistsAsync(name); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesTheDiagnosticSettingForCategory() + public async Task Exists_GetsTheDiagnosticSettingForCategory() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/createOrUpdateDiagnosticSettingCategory.json - // this example is just showing the usage of "DiagnosticSettings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json + // this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingCollection collection = client.GetDiagnosticSettings(scopeId); + DiagnosticSettingCollection collection = client.GetDiagnosticSettings(new ResourceIdentifier(resourceUri)); // invoke the operation string name = "mysetting"; - DiagnosticSettingData data = new DiagnosticSettingData() - { - StorageAccountId = new ResourceIdentifier("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1"), - EventHubAuthorizationRuleId = new ResourceIdentifier("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule"), - EventHubName = "myeventhub", - Metrics = -{ -new MetricSettings(true) -{ -Category = "WorkflowMetrics", -RetentionPolicy = new RetentionPolicy(false,0), -} -}, - Logs = -{ -new LogSettings(true) -{ -Category = "WorkflowRuntime", -RetentionPolicy = new RetentionPolicy(false,0), -} -}, - WorkspaceId = new ResourceIdentifier(""), - MarketplacePartnerId = new ResourceIdentifier("/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1"), - LogAnalyticsDestinationType = "Dedicated", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - DiagnosticSettingResource result = lro.Value; + bool result = await collection.ExistsAsync(name); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticSettingData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheDiagnosticSetting() + public async Task GetIfExists_GetsTheDiagnosticSetting() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/listDiagnosticSettings.json - // this example is just showing the usage of "DiagnosticSettings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSetting.json + // this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingCollection collection = client.GetDiagnosticSettings(scopeId); + DiagnosticSettingCollection collection = client.GetDiagnosticSettings(new ResourceIdentifier(resourceUri)); - // invoke the operation and iterate over the result - await foreach (DiagnosticSettingResource item in collection.GetAllAsync()) + // invoke the operation + string name = "mysetting"; + NullableResponse response = await collection.GetIfExistsAsync(name); + DiagnosticSettingResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DiagnosticSettingData resourceData = item.Data; + DiagnosticSettingData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheDiagnosticSettingForCategory() + public async Task GetIfExists_GetsTheDiagnosticSettingForCategory() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/listDiagnosticSettingsCategory.json - // this example is just showing the usage of "DiagnosticSettings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/getDiagnosticSettingCategory.json + // this example is just showing the usage of "DiagnosticSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingCollection collection = client.GetDiagnosticSettings(scopeId); + DiagnosticSettingCollection collection = client.GetDiagnosticSettings(new ResourceIdentifier(resourceUri)); - // invoke the operation and iterate over the result - await foreach (DiagnosticSettingResource item in collection.GetAllAsync()) + // invoke the operation + string name = "mysetting"; + NullableResponse response = await collection.GetIfExistsAsync(name); + DiagnosticSettingResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DiagnosticSettingData resourceData = item.Data; + DiagnosticSettingData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingResource.cs index f81d7cd1c0fb8..68ebf84d8aeb0 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingResource.cs @@ -74,6 +74,31 @@ public async Task Get_GetsTheDiagnosticSettingForCategory() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeletesTheDiagnosticSetting() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/deleteDiagnosticSetting.json + // this example is just showing the usage of "DiagnosticSettings_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this DiagnosticSettingResource created on azure + // for more information of creating DiagnosticSettingResource, please refer to the document of DiagnosticSettingResource + string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; + string name = "mysetting"; + ResourceIdentifier diagnosticSettingResourceId = DiagnosticSettingResource.CreateResourceIdentifier(resourceUri, name); + DiagnosticSettingResource diagnosticSetting = client.GetDiagnosticSettingResource(diagnosticSettingResourceId); + + // invoke the operation + await diagnosticSetting.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreatesOrUpdatesTheDiagnosticSetting() @@ -94,27 +119,21 @@ public async Task Update_CreatesOrUpdatesTheDiagnosticSetting() DiagnosticSettingResource diagnosticSetting = client.GetDiagnosticSettingResource(diagnosticSettingResourceId); // invoke the operation - DiagnosticSettingData data = new DiagnosticSettingData() + DiagnosticSettingData data = new DiagnosticSettingData { StorageAccountId = new ResourceIdentifier("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1"), EventHubAuthorizationRuleId = new ResourceIdentifier("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule"), EventHubName = "myeventhub", - Metrics = -{ -new MetricSettings(true) + Metrics = {new MetricSettings(true) { Category = "WorkflowMetrics", -RetentionPolicy = new RetentionPolicy(false,0), -} -}, - Logs = -{ -new LogSettings(true) +RetentionPolicy = new RetentionPolicy(false, 0), +}}, + Logs = {new LogSettings(true) { CategoryGroup = "allLogs", -RetentionPolicy = new RetentionPolicy(false,0), -} -}, +RetentionPolicy = new RetentionPolicy(false, 0), +}}, WorkspaceId = new ResourceIdentifier(""), MarketplacePartnerId = new ResourceIdentifier("/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1"), LogAnalyticsDestinationType = "Dedicated", @@ -149,27 +168,21 @@ public async Task Update_CreatesOrUpdatesTheDiagnosticSettingForCategory() DiagnosticSettingResource diagnosticSetting = client.GetDiagnosticSettingResource(diagnosticSettingResourceId); // invoke the operation - DiagnosticSettingData data = new DiagnosticSettingData() + DiagnosticSettingData data = new DiagnosticSettingData { StorageAccountId = new ResourceIdentifier("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/apptest/providers/Microsoft.Storage/storageAccounts/appteststorage1"), EventHubAuthorizationRuleId = new ResourceIdentifier("/subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourceGroups/montest/providers/microsoft.eventhub/namespaces/mynamespace/authorizationrules/myrule"), EventHubName = "myeventhub", - Metrics = -{ -new MetricSettings(true) + Metrics = {new MetricSettings(true) { Category = "WorkflowMetrics", -RetentionPolicy = new RetentionPolicy(false,0), -} -}, - Logs = -{ -new LogSettings(true) +RetentionPolicy = new RetentionPolicy(false, 0), +}}, + Logs = {new LogSettings(true) { Category = "WorkflowRuntime", -RetentionPolicy = new RetentionPolicy(false,0), -} -}, +RetentionPolicy = new RetentionPolicy(false, 0), +}}, WorkspaceId = new ResourceIdentifier(""), MarketplacePartnerId = new ResourceIdentifier("/subscriptions/abcdeabc-1234-1234-ab12-123a1234567a/resourceGroups/test-rg/providers/Microsoft.Datadog/monitors/dd1"), LogAnalyticsDestinationType = "Dedicated", @@ -183,30 +196,5 @@ public async Task Update_CreatesOrUpdatesTheDiagnosticSettingForCategory() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesTheDiagnosticSetting() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/deleteDiagnosticSetting.json - // this example is just showing the usage of "DiagnosticSettings_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this DiagnosticSettingResource created on azure - // for more information of creating DiagnosticSettingResource, please refer to the document of DiagnosticSettingResource - string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - string name = "mysetting"; - ResourceIdentifier diagnosticSettingResourceId = DiagnosticSettingResource.CreateResourceIdentifier(resourceUri, name); - DiagnosticSettingResource diagnosticSetting = client.GetDiagnosticSettingResource(diagnosticSettingResourceId); - - // invoke the operation - await diagnosticSetting.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingsCategoryCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingsCategoryCollection.cs index 1e62b88248dee..3615863646eee 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingsCategoryCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_DiagnosticSettingsCategoryCollection.cs @@ -27,13 +27,9 @@ public async Task Get_GetsTheDiagnosticSetting() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingsCategoryResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingsCategoryCollection collection = client.GetDiagnosticSettingsCategories(scopeId); + DiagnosticSettingsCategoryCollection collection = client.GetDiagnosticSettingsCategories(new ResourceIdentifier(resourceUri)); // invoke the operation string name = "WorkflowRuntime"; @@ -46,6 +42,35 @@ public async Task Get_GetsTheDiagnosticSetting() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_GetsTheDiagnosticSetting() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/listDiagnosticSettingsCategories.json + // this example is just showing the usage of "DiagnosticSettingsCategory_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // get the collection of this DiagnosticSettingsCategoryResource + string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; + DiagnosticSettingsCategoryCollection collection = client.GetDiagnosticSettingsCategories(new ResourceIdentifier(resourceUri)); + + // invoke the operation and iterate over the result + await foreach (DiagnosticSettingsCategoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DiagnosticSettingsCategoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_GetsTheDiagnosticSetting() @@ -58,13 +83,9 @@ public async Task Exists_GetsTheDiagnosticSetting() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingsCategoryResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingsCategoryCollection collection = client.GetDiagnosticSettingsCategories(scopeId); + DiagnosticSettingsCategoryCollection collection = client.GetDiagnosticSettingsCategories(new ResourceIdentifier(resourceUri)); // invoke the operation string name = "WorkflowRuntime"; @@ -85,13 +106,9 @@ public async Task GetIfExists_GetsTheDiagnosticSetting() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - // get the collection of this DiagnosticSettingsCategoryResource string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingsCategoryCollection collection = client.GetDiagnosticSettingsCategories(scopeId); + DiagnosticSettingsCategoryCollection collection = client.GetDiagnosticSettingsCategories(new ResourceIdentifier(resourceUri)); // invoke the operation string name = "WorkflowRuntime"; @@ -111,38 +128,5 @@ public async Task GetIfExists_GetsTheDiagnosticSetting() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsTheDiagnosticSetting() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-05-01-preview/examples/listDiagnosticSettingsCategories.json - // this example is just showing the usage of "DiagnosticSettingsCategory_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ArmResource created on azure - // for more information of creating ArmResource, please refer to the document of ArmResource - - // get the collection of this DiagnosticSettingsCategoryResource - string resourceUri = "subscriptions/1a66ce04-b633-4a0b-b2bc-a912ec8986a6/resourcegroups/viruela1/providers/microsoft.logic/workflows/viruela6"; - ResourceIdentifier scopeId = new ResourceIdentifier(string.Format("/{0}", resourceUri)); - DiagnosticSettingsCategoryCollection collection = client.GetDiagnosticSettingsCategories(scopeId); - - // invoke the operation and iterate over the result - await foreach (DiagnosticSettingsCategoryResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DiagnosticSettingsCategoryData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_LogProfileCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_LogProfileCollection.cs index e65d77c1c5b12..ff67170bf6cd3 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_LogProfileCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_LogProfileCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_LogProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetLogProfile() + public async Task CreateOrUpdate_CreateOrUpdateALogProfile() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getLogProfile.json - // this example is just showing the usage of "LogProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/createOrUpdateLogProfile.json + // this example is just showing the usage of "LogProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,15 @@ public async Task Get_GetLogProfile() LogProfileCollection collection = subscriptionResource.GetLogProfiles(); // invoke the operation - string logProfileName = "default"; - LogProfileResource result = await collection.GetAsync(logProfileName); + string logProfileName = "Rac46PostSwapRG"; + LogProfileData data = new LogProfileData(new AzureLocation(""), new AzureLocation[] { new AzureLocation("global") }, new string[] { "Write", "Delete", "Action" }, new RetentionPolicy(true, 3)) + { + StorageAccountId = new ResourceIdentifier("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/JohnKemTest/providers/Microsoft.Storage/storageAccounts/johnkemtest8162"), + ServiceBusRuleId = new ResourceIdentifier(""), + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, logProfileName, data); + LogProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +58,7 @@ public async Task Get_GetLogProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetLogProfile() + public async Task Get_GetLogProfile() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getLogProfile.json // this example is just showing the usage of "LogProfiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -72,17 +79,21 @@ public async Task Exists_GetLogProfile() // invoke the operation string logProfileName = "default"; - bool result = await collection.ExistsAsync(logProfileName); + LogProfileResource result = await collection.GetAsync(logProfileName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetLogProfile() + public async Task GetAll_ListLogProfiles() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getLogProfile.json - // this example is just showing the usage of "LogProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/listLogProfile.json + // this example is just showing the usage of "LogProfiles_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,31 +109,25 @@ public async Task GetIfExists_GetLogProfile() // get the collection of this LogProfileResource LogProfileCollection collection = subscriptionResource.GetLogProfiles(); - // invoke the operation - string logProfileName = "default"; - NullableResponse response = await collection.GetIfExistsAsync(logProfileName); - LogProfileResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (LogProfileResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LogProfileData resourceData = result.Data; + LogProfileData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateALogProfile() + public async Task Exists_GetLogProfile() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/createOrUpdateLogProfile.json - // this example is just showing the usage of "LogProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getLogProfile.json + // this example is just showing the usage of "LogProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,37 +144,18 @@ public async Task CreateOrUpdate_CreateOrUpdateALogProfile() LogProfileCollection collection = subscriptionResource.GetLogProfiles(); // invoke the operation - string logProfileName = "Rac46PostSwapRG"; - LogProfileData data = new LogProfileData(new AzureLocation(""), new AzureLocation[] - { -new AzureLocation("global") - }, new string[] - { -"Write","Delete","Action" - }, new RetentionPolicy(true, 3)) - { - StorageAccountId = new ResourceIdentifier("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/JohnKemTest/providers/Microsoft.Storage/storageAccounts/johnkemtest8162"), - ServiceBusRuleId = new ResourceIdentifier(""), - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, logProfileName, data); - LogProfileResource result = lro.Value; + string logProfileName = "default"; + bool result = await collection.ExistsAsync(logProfileName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListLogProfiles() + public async Task GetIfExists_GetLogProfile() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/listLogProfile.json - // this example is just showing the usage of "LogProfiles_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getLogProfile.json + // this example is just showing the usage of "LogProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +171,23 @@ public async Task GetAll_ListLogProfiles() // get the collection of this LogProfileResource LogProfileCollection collection = subscriptionResource.GetLogProfiles(); - // invoke the operation and iterate over the result - await foreach (LogProfileResource item in collection.GetAllAsync()) + // invoke the operation + string logProfileName = "default"; + NullableResponse response = await collection.GetIfExistsAsync(logProfileName); + LogProfileResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LogProfileData resourceData = item.Data; + LogProfileData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_LogProfileResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_LogProfileResource.cs index 6703f891bc49f..d326cbbdb22a2 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_LogProfileResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_LogProfileResource.cs @@ -18,10 +18,10 @@ public partial class Sample_LogProfileResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteLogProfile() + public async Task Get_GetLogProfile() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/deleteLogProfile.json - // this example is just showing the usage of "LogProfiles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getLogProfile.json + // this example is just showing the usage of "LogProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,23 +30,27 @@ public async Task Delete_DeleteLogProfile() // this example assumes you already have this LogProfileResource created on azure // for more information of creating LogProfileResource, please refer to the document of LogProfileResource - string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; - string logProfileName = "Rac46PostSwapRG"; + string subscriptionId = "df602c9c-7aa0-407d-a6fb-eb20c8bd1192"; + string logProfileName = "default"; ResourceIdentifier logProfileResourceId = LogProfileResource.CreateResourceIdentifier(subscriptionId, logProfileName); LogProfileResource logProfile = client.GetLogProfileResource(logProfileResourceId); // invoke the operation - await logProfile.DeleteAsync(WaitUntil.Completed); + LogProfileResource result = await logProfile.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LogProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetLogProfile() + public async Task Delete_DeleteLogProfile() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getLogProfile.json - // this example is just showing the usage of "LogProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/deleteLogProfile.json + // this example is just showing the usage of "LogProfiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -55,19 +59,15 @@ public async Task Get_GetLogProfile() // this example assumes you already have this LogProfileResource created on azure // for more information of creating LogProfileResource, please refer to the document of LogProfileResource - string subscriptionId = "df602c9c-7aa0-407d-a6fb-eb20c8bd1192"; - string logProfileName = "default"; + string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; + string logProfileName = "Rac46PostSwapRG"; ResourceIdentifier logProfileResourceId = LogProfileResource.CreateResourceIdentifier(subscriptionId, logProfileName); LogProfileResource logProfile = client.GetLogProfileResource(logProfileResourceId); // invoke the operation - LogProfileResource result = await logProfile.GetAsync(); + await logProfile.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LogProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -90,22 +90,16 @@ public async Task Update_PatchALogProfile() LogProfileResource logProfile = client.GetLogProfileResource(logProfileResourceId); // invoke the operation - LogProfilePatch patch = new LogProfilePatch() + LogProfilePatch patch = new LogProfilePatch { Tags = { -["key1"] = "value1", +["key1"] = "value1" }, StorageAccountId = new ResourceIdentifier("/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/resourceGroups/JohnKemTest/providers/Microsoft.Storage/storageAccounts/johnkemtest8162"), ServiceBusRuleId = new ResourceIdentifier(""), - Locations = -{ -new AzureLocation("global") -}, - Categories = -{ -"Write","Delete","Action" -}, + Locations = { new AzureLocation("global") }, + Categories = { "Write", "Delete", "Action" }, RetentionPolicy = new RetentionPolicy(true, 3), }; LogProfileResource result = await logProfile.UpdateAsync(patch); diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MetricAlertCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MetricAlertCollection.cs index 7b1713e53624b..887c9fa1d16c1 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MetricAlertCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MetricAlertCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_MetricAlertCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListMetricAlertRules() + public async Task CreateOrUpdate_CreateOrUpdateADynamicAlertRuleForMultipleResources() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/listMetricAlert.json - // this example is just showing the usage of "MetricAlerts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateDynamicMetricAlertMultipleResource.json + // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,7 +32,7 @@ public async Task GetAll_ListMetricAlertRules() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -40,25 +40,61 @@ public async Task GetAll_ListMetricAlertRules() // get the collection of this MetricAlertResource MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); - // invoke the operation and iterate over the result - await foreach (MetricAlertResource item in collection.GetAllAsync()) + // invoke the operation + string ruleName = "MetricAlertOnMultipleResources"; + MetricAlertData data = new MetricAlertData( + new AzureLocation("global"), + 3, + true, + new string[] { "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1", "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2" }, + XmlConvert.ToTimeSpan("PT1M"), + XmlConvert.ToTimeSpan("PT15M"), + new MetricAlertMultipleResourceMultipleMetricCriteria + { + AllOf = {new DynamicMetricCriteria( + "High_CPU_80", + "Percentage CPU", + MetricCriteriaTimeAggregationType.Average, + DynamicThresholdOperator.GreaterOrLessThan, + DynamicThresholdSensitivity.Medium, + new DynamicThresholdFailingPeriods(4, 4)) +{ +MetricNamespace = "microsoft.compute/virtualmachines", +Dimensions = {}, +}}, + }) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "This is the description of the rule1", + TargetResourceType = new ResourceType("Microsoft.Compute/virtualMachines"), + TargetResourceRegion = new AzureLocation("southcentralus"), + IsAutoMitigateEnabled = true, + Actions = {new MetricAlertAction +{ +ActionGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), +WebHookProperties = +{ +["key11"] = "value11", +["key12"] = "value12" +}, +}}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + MetricAlertResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADynamicAlertRuleForMultipleResources() + public async Task CreateOrUpdate_CreateOrUpdateADynamicAlertRuleForSingleResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertMultipleResource.json - // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateDynamicMetricAlertSingleResource.json + // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,8 +112,45 @@ public async Task Get_GetADynamicAlertRuleForMultipleResources() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertOnMultipleResources"; - MetricAlertResource result = await collection.GetAsync(ruleName); + string ruleName = "chiricutin"; + MetricAlertData data = new MetricAlertData( + new AzureLocation("global"), + 3, + true, + new string[] { "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" }, + XmlConvert.ToTimeSpan("PT1M"), + XmlConvert.ToTimeSpan("PT15M"), + new MetricAlertMultipleResourceMultipleMetricCriteria + { + AllOf = {new DynamicMetricCriteria( + "High_CPU_80", + "Percentage CPU", + MetricCriteriaTimeAggregationType.Average, + DynamicThresholdOperator.GreaterOrLessThan, + DynamicThresholdSensitivity.Medium, + new DynamicThresholdFailingPeriods(4, 4)) +{ +IgnoreDataBefore = DateTimeOffset.Parse("2019-04-04T21:00:00.000Z"), +MetricNamespace = "microsoft.compute/virtualmachines", +Dimensions = {}, +}}, + }) + { + Description = "This is the description of the rule1", + IsAutoMitigateEnabled = true, + Actions = {new MetricAlertAction +{ +ActionGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), +WebHookProperties = +{ +["key11"] = "value11", +["key12"] = "value12" +}, +}}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + MetricAlertResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -88,10 +161,10 @@ public async Task Get_GetADynamicAlertRuleForMultipleResources() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADynamicAlertRuleForMultipleResources() + public async Task CreateOrUpdate_CreateOrUpdateAWebTestAlertRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertMultipleResource.json - // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateWebTestMetricAlert.json + // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,8 +173,8 @@ public async Task Exists_GetADynamicAlertRuleForMultipleResources() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "gigtest"; + string subscriptionId = "12345678-1234-1234-1234-123456789101"; + string resourceGroupName = "rg-example"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -109,18 +182,40 @@ public async Task Exists_GetADynamicAlertRuleForMultipleResources() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertOnMultipleResources"; - bool result = await collection.ExistsAsync(ruleName); + string ruleName = "webtest-name-example"; + MetricAlertData data = new MetricAlertData( + new AzureLocation("global"), + 4, + true, + new string[] { "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example", "/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example" }, + XmlConvert.ToTimeSpan("PT1M"), + XmlConvert.ToTimeSpan("PT15M"), + new WebtestLocationAvailabilityCriteria(new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example"), new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example"), 2)) + { + Description = "Automatically created alert rule for availability test \"component-example\" a", + Actions = { }, + Tags = +{ +["hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example"] = "Resource", +["hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example"] = "Resource" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + MetricAlertResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADynamicAlertRuleForMultipleResources() + public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleForMultipleResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertMultipleResource.json - // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertMultipleResource.json + // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,7 +224,7 @@ public async Task GetIfExists_GetADynamicAlertRuleForMultipleResources() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -139,29 +234,53 @@ public async Task GetIfExists_GetADynamicAlertRuleForMultipleResources() // invoke the operation string ruleName = "MetricAlertOnMultipleResources"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - MetricAlertResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + MetricAlertData data = new MetricAlertData( + new AzureLocation("global"), + 3, + true, + new string[] { "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1", "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2" }, + XmlConvert.ToTimeSpan("PT1M"), + XmlConvert.ToTimeSpan("PT15M"), + new MetricAlertMultipleResourceMultipleMetricCriteria + { + AllOf = {new MetricCriteria("High_CPU_80", "Percentage CPU", MetricCriteriaTimeAggregationType.Average, MetricCriteriaOperator.GreaterThan, 80.5) +{ +MetricNamespace = "microsoft.compute/virtualmachines", +Dimensions = {}, +}}, + }) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "This is the description of the rule1", + TargetResourceType = new ResourceType("Microsoft.Compute/virtualMachines"), + TargetResourceRegion = new AzureLocation("southcentralus"), + IsAutoMitigateEnabled = true, + Actions = {new MetricAlertAction +{ +ActionGroupId = new ResourceIdentifier("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), +WebHookProperties = +{ +["key11"] = "value11", +["key12"] = "value12" +}, +}}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + MetricAlertResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADynamicAlertRuleForSingleResource() + public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleForSingleResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertSingleResource.json - // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertSingleResource.json + // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -170,7 +289,7 @@ public async Task Get_GetADynamicAlertRuleForSingleResource() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -180,7 +299,36 @@ public async Task Get_GetADynamicAlertRuleForSingleResource() // invoke the operation string ruleName = "chiricutin"; - MetricAlertResource result = await collection.GetAsync(ruleName); + MetricAlertData data = new MetricAlertData( + new AzureLocation("global"), + 3, + true, + new string[] { "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" }, + XmlConvert.ToTimeSpan("Pt1m"), + XmlConvert.ToTimeSpan("Pt15m"), + new MetricAlertSingleResourceMultipleMetricCriteria + { + AllOf = {new MetricCriteria("High_CPU_80", "\\Processor(_Total)\\% Processor Time", MetricCriteriaTimeAggregationType.Average, MetricCriteriaOperator.GreaterThan, 80.5) +{ +Dimensions = {}, +}}, + }) + { + Description = "This is the description of the rule1", + IsAutoMitigateEnabled = true, + Actions = {new MetricAlertAction +{ +ActionGroupId = new ResourceIdentifier("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), +WebHookProperties = +{ +["key11"] = "value11", +["key12"] = "value12" +}, +}}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + MetricAlertResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -191,10 +339,10 @@ public async Task Get_GetADynamicAlertRuleForSingleResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADynamicAlertRuleForSingleResource() + public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleOnResourceGroupS() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertSingleResource.json - // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertResourceGroup.json + // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -203,8 +351,8 @@ public async Task Exists_GetADynamicAlertRuleForSingleResource() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "gigtest"; + string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; + string resourceGroupName = "gigtest1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -212,18 +360,54 @@ public async Task Exists_GetADynamicAlertRuleForSingleResource() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "chiricutin"; - bool result = await collection.ExistsAsync(ruleName); + string ruleName = "MetricAlertAtResourceGroupLevel"; + MetricAlertData data = new MetricAlertData( + new AzureLocation("global"), + 3, + true, + new string[] { "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1", "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2" }, + XmlConvert.ToTimeSpan("PT1M"), + XmlConvert.ToTimeSpan("PT15M"), + new MetricAlertMultipleResourceMultipleMetricCriteria + { + AllOf = {new MetricCriteria("High_CPU_80", "Percentage CPU", MetricCriteriaTimeAggregationType.Average, MetricCriteriaOperator.GreaterThan, 80.5) +{ +MetricNamespace = "microsoft.compute/virtualmachines", +Dimensions = {}, +}}, + }) + { + Description = "This is the description of the rule1", + TargetResourceType = new ResourceType("Microsoft.Compute/virtualMachines"), + TargetResourceRegion = new AzureLocation("southcentralus"), + IsAutoMitigateEnabled = true, + Actions = {new MetricAlertAction +{ +ActionGroupId = new ResourceIdentifier("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), +WebHookProperties = +{ +["key11"] = "value11", +["key12"] = "value12" +}, +}}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + MetricAlertResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADynamicAlertRuleForSingleResource() + public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleOnSubscription() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertSingleResource.json - // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertSubscription.json + // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -232,7 +416,7 @@ public async Task GetIfExists_GetADynamicAlertRuleForSingleResource() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -241,30 +425,54 @@ public async Task GetIfExists_GetADynamicAlertRuleForSingleResource() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "chiricutin"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - MetricAlertResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string ruleName = "MetricAlertAtSubscriptionLevel"; + MetricAlertData data = new MetricAlertData( + new AzureLocation("global"), + 3, + true, + new string[] { "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7" }, + XmlConvert.ToTimeSpan("PT1M"), + XmlConvert.ToTimeSpan("PT15M"), + new MetricAlertMultipleResourceMultipleMetricCriteria + { + AllOf = {new MetricCriteria("High_CPU_80", "Percentage CPU", MetricCriteriaTimeAggregationType.Average, MetricCriteriaOperator.GreaterThan, 80.5) +{ +MetricNamespace = "microsoft.compute/virtualmachines", +Dimensions = {}, +}}, + }) { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "This is the description of the rule1", + TargetResourceType = new ResourceType("Microsoft.Compute/virtualMachines"), + TargetResourceRegion = new AzureLocation("southcentralus"), + IsAutoMitigateEnabled = true, + Actions = {new MetricAlertAction +{ +ActionGroupId = new ResourceIdentifier("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), +WebHookProperties = +{ +["key11"] = "value11", +["key12"] = "value12" +}, +}}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + MetricAlertResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAWebTestAlertRule() + public async Task CreateOrUpdate_CreateOrUpdateAnAlertRulesWithDimensions() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getWebTestMetricAlert.json - // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertWithDimensions.json + // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -273,8 +481,8 @@ public async Task Get_GetAWebTestAlertRule() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "12345678-1234-1234-1234-123456789101"; - string resourceGroupName = "rg-example"; + string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; + string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -282,21 +490,51 @@ public async Task Get_GetAWebTestAlertRule() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "webtest-name-example"; - MetricAlertResource result = await collection.GetAsync(ruleName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - + string ruleName = "MetricAlertOnMultipleDimensions"; + MetricAlertData data = new MetricAlertData( + new AzureLocation("global"), + 3, + true, + new string[] { "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource" }, + XmlConvert.ToTimeSpan("PT1H"), + XmlConvert.ToTimeSpan("P1D"), + new MetricAlertMultipleResourceMultipleMetricCriteria + { + AllOf = {new MetricCriteria("Metric1", "Availability", MetricCriteriaTimeAggregationType.Average, MetricCriteriaOperator.GreaterThan, 55) +{ +MetricNamespace = "Microsoft.KeyVault/vaults", +Dimensions = {new MetricDimension("ActivityName", "Include", new string[]{"*"}), new MetricDimension("StatusCode", "Include", new string[]{"200"})}, +}}, + }) + { + Description = "This is the description of the rule1", + IsAutoMitigateEnabled = true, + Actions = {new MetricAlertAction +{ +ActionGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), +WebHookProperties = +{ +["key11"] = "value11", +["key12"] = "value12" +}, +}}, + Tags = { }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + MetricAlertResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAWebTestAlertRule() + public async Task Get_GetADynamicAlertRuleForMultipleResources() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getWebTestMetricAlert.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertMultipleResource.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -306,8 +544,8 @@ public async Task Exists_GetAWebTestAlertRule() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "12345678-1234-1234-1234-123456789101"; - string resourceGroupName = "rg-example"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -315,17 +553,21 @@ public async Task Exists_GetAWebTestAlertRule() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "webtest-name-example"; - bool result = await collection.ExistsAsync(ruleName); + string ruleName = "MetricAlertOnMultipleResources"; + MetricAlertResource result = await collection.GetAsync(ruleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAWebTestAlertRule() + public async Task Get_GetADynamicAlertRuleForSingleResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getWebTestMetricAlert.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertSingleResource.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -335,8 +577,8 @@ public async Task GetIfExists_GetAWebTestAlertRule() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "12345678-1234-1234-1234-123456789101"; - string resourceGroupName = "rg-example"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -344,29 +586,21 @@ public async Task GetIfExists_GetAWebTestAlertRule() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "webtest-name-example"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - MetricAlertResource result = response.HasValue ? response.Value : null; + string ruleName = "chiricutin"; + MetricAlertResource result = await collection.GetAsync(ruleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAlertRuleForMultipleResources() + public async Task Get_GetAWebTestAlertRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertMultipleResource.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getWebTestMetricAlert.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -376,8 +610,8 @@ public async Task Get_GetAnAlertRuleForMultipleResources() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - string resourceGroupName = "gigtest"; + string subscriptionId = "12345678-1234-1234-1234-123456789101"; + string resourceGroupName = "rg-example"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -385,7 +619,7 @@ public async Task Get_GetAnAlertRuleForMultipleResources() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertOnMultipleResources"; + string ruleName = "webtest-name-example"; MetricAlertResource result = await collection.GetAsync(ruleName); // the variable result is a resource, you could call other operations on this instance as well @@ -397,7 +631,7 @@ public async Task Get_GetAnAlertRuleForMultipleResources() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAlertRuleForMultipleResources() + public async Task Get_GetAnAlertRuleForMultipleResources() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertMultipleResource.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. @@ -419,16 +653,20 @@ public async Task Exists_GetAnAlertRuleForMultipleResources() // invoke the operation string ruleName = "MetricAlertOnMultipleResources"; - bool result = await collection.ExistsAsync(ruleName); + MetricAlertResource result = await collection.GetAsync(ruleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAlertRuleForMultipleResources() + public async Task Get_GetAnAlertRuleForSingleResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertMultipleResource.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSingleResource.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -447,29 +685,21 @@ public async Task GetIfExists_GetAnAlertRuleForMultipleResources() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertOnMultipleResources"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - MetricAlertResource result = response.HasValue ? response.Value : null; + string ruleName = "chiricutin"; + MetricAlertResource result = await collection.GetAsync(ruleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAlertRuleForSingleResource() + public async Task Get_GetAnAlertRuleOnResourceGroupS() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSingleResource.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertResourceGroup.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -480,7 +710,7 @@ public async Task Get_GetAnAlertRuleForSingleResource() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - string resourceGroupName = "gigtest"; + string resourceGroupName = "gigtest1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -488,7 +718,7 @@ public async Task Get_GetAnAlertRuleForSingleResource() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "chiricutin"; + string ruleName = "MetricAlertAtResourceGroupLevel"; MetricAlertResource result = await collection.GetAsync(ruleName); // the variable result is a resource, you could call other operations on this instance as well @@ -500,9 +730,9 @@ public async Task Get_GetAnAlertRuleForSingleResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAlertRuleForSingleResource() + public async Task Get_GetAnAlertRuleOnSubscription() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSingleResource.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSubscription.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -521,18 +751,22 @@ public async Task Exists_GetAnAlertRuleForSingleResource() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "chiricutin"; - bool result = await collection.ExistsAsync(ruleName); + string ruleName = "MetricAlertAtSubscriptionLevel"; + MetricAlertResource result = await collection.GetAsync(ruleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAlertRuleForSingleResource() + public async Task GetAll_ListMetricAlertRules() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSingleResource.json - // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/listMetricAlert.json + // this example is just showing the usage of "MetricAlerts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -549,30 +783,24 @@ public async Task GetIfExists_GetAnAlertRuleForSingleResource() // get the collection of this MetricAlertResource MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); - // invoke the operation - string ruleName = "chiricutin"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - MetricAlertResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MetricAlertResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; + MetricAlertData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAlertRuleOnResourceGroupS() + public async Task Exists_GetADynamicAlertRuleForMultipleResources() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertResourceGroup.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertMultipleResource.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -582,8 +810,8 @@ public async Task Get_GetAnAlertRuleOnResourceGroupS() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - string resourceGroupName = "gigtest1"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -591,21 +819,17 @@ public async Task Get_GetAnAlertRuleOnResourceGroupS() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertAtResourceGroupLevel"; - MetricAlertResource result = await collection.GetAsync(ruleName); + string ruleName = "MetricAlertOnMultipleResources"; + bool result = await collection.ExistsAsync(ruleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAlertRuleOnResourceGroupS() + public async Task Exists_GetADynamicAlertRuleForSingleResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertResourceGroup.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertSingleResource.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -615,8 +839,8 @@ public async Task Exists_GetAnAlertRuleOnResourceGroupS() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - string resourceGroupName = "gigtest1"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -624,7 +848,7 @@ public async Task Exists_GetAnAlertRuleOnResourceGroupS() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertAtResourceGroupLevel"; + string ruleName = "chiricutin"; bool result = await collection.ExistsAsync(ruleName); Console.WriteLine($"Succeeded: {result}"); @@ -632,9 +856,9 @@ public async Task Exists_GetAnAlertRuleOnResourceGroupS() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAlertRuleOnResourceGroupS() + public async Task Exists_GetAWebTestAlertRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertResourceGroup.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getWebTestMetricAlert.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -644,8 +868,8 @@ public async Task GetIfExists_GetAnAlertRuleOnResourceGroupS() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - string resourceGroupName = "gigtest1"; + string subscriptionId = "12345678-1234-1234-1234-123456789101"; + string resourceGroupName = "rg-example"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -653,29 +877,17 @@ public async Task GetIfExists_GetAnAlertRuleOnResourceGroupS() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertAtResourceGroupLevel"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - MetricAlertResource result = response.HasValue ? response.Value : null; + string ruleName = "webtest-name-example"; + bool result = await collection.ExistsAsync(ruleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAlertRuleOnSubscription() + public async Task Exists_GetAnAlertRuleForMultipleResources() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSubscription.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertMultipleResource.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -694,21 +906,17 @@ public async Task Get_GetAnAlertRuleOnSubscription() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertAtSubscriptionLevel"; - MetricAlertResource result = await collection.GetAsync(ruleName); + string ruleName = "MetricAlertOnMultipleResources"; + bool result = await collection.ExistsAsync(ruleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAlertRuleOnSubscription() + public async Task Exists_GetAnAlertRuleForSingleResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSubscription.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSingleResource.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -727,7 +935,7 @@ public async Task Exists_GetAnAlertRuleOnSubscription() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertAtSubscriptionLevel"; + string ruleName = "chiricutin"; bool result = await collection.ExistsAsync(ruleName); Console.WriteLine($"Succeeded: {result}"); @@ -735,9 +943,9 @@ public async Task Exists_GetAnAlertRuleOnSubscription() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAlertRuleOnSubscription() + public async Task Exists_GetAnAlertRuleOnResourceGroupS() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSubscription.json + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertResourceGroup.json // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -748,7 +956,7 @@ public async Task GetIfExists_GetAnAlertRuleOnSubscription() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - string resourceGroupName = "gigtest"; + string resourceGroupName = "gigtest1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -756,30 +964,18 @@ public async Task GetIfExists_GetAnAlertRuleOnSubscription() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertAtSubscriptionLevel"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - MetricAlertResource result = response.HasValue ? response.Value : null; + string ruleName = "MetricAlertAtResourceGroupLevel"; + bool result = await collection.ExistsAsync(ruleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateADynamicAlertRuleForMultipleResources() + public async Task Exists_GetAnAlertRuleOnSubscription() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateDynamicMetricAlertMultipleResource.json - // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSubscription.json + // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -788,7 +984,7 @@ public async Task CreateOrUpdate_CreateOrUpdateADynamicAlertRuleForMultipleResou // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -797,60 +993,18 @@ public async Task CreateOrUpdate_CreateOrUpdateADynamicAlertRuleForMultipleResou MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertOnMultipleResources"; - MetricAlertData data = new MetricAlertData(new AzureLocation("global"), 3, true, new string[] - { -"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1","/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2" - }, XmlConvert.ToTimeSpan("PT1M"), XmlConvert.ToTimeSpan("PT15M"), new MetricAlertMultipleResourceMultipleMetricCriteria() - { - AllOf = - { -new DynamicMetricCriteria("High_CPU_80","Percentage CPU",MetricCriteriaTimeAggregationType.Average,DynamicThresholdOperator.GreaterOrLessThan,DynamicThresholdSensitivity.Medium,new DynamicThresholdFailingPeriods(4,4)) -{ -MetricNamespace = "microsoft.compute/virtualmachines", -Dimensions = -{ -}, -} - }, - }) - { - Description = "This is the description of the rule1", - TargetResourceType = new ResourceType("Microsoft.Compute/virtualMachines"), - TargetResourceRegion = new AzureLocation("southcentralus"), - IsAutoMitigateEnabled = true, - Actions = -{ -new MetricAlertAction() -{ -ActionGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), -WebHookProperties = -{ -["key11"] = "value11", -["key12"] = "value12", -}, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - MetricAlertResource result = lro.Value; + string ruleName = "MetricAlertAtSubscriptionLevel"; + bool result = await collection.ExistsAsync(ruleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateADynamicAlertRuleForSingleResource() + public async Task GetIfExists_GetADynamicAlertRuleForMultipleResources() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateDynamicMetricAlertSingleResource.json - // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertMultipleResource.json + // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -868,59 +1022,30 @@ public async Task CreateOrUpdate_CreateOrUpdateADynamicAlertRuleForSingleResourc MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "chiricutin"; - MetricAlertData data = new MetricAlertData(new AzureLocation("global"), 3, true, new string[] - { -"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" - }, XmlConvert.ToTimeSpan("PT1M"), XmlConvert.ToTimeSpan("PT15M"), new MetricAlertMultipleResourceMultipleMetricCriteria() - { - AllOf = + string ruleName = "MetricAlertOnMultipleResources"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + MetricAlertResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new DynamicMetricCriteria("High_CPU_80","Percentage CPU",MetricCriteriaTimeAggregationType.Average,DynamicThresholdOperator.GreaterOrLessThan,DynamicThresholdSensitivity.Medium,new DynamicThresholdFailingPeriods(4,4)) -{ -IgnoreDataBefore = DateTimeOffset.Parse("2019-04-04T21:00:00.000Z"), -MetricNamespace = "microsoft.compute/virtualmachines", -Dimensions = -{ -}, -} - }, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "This is the description of the rule1", - IsAutoMitigateEnabled = true, - Actions = -{ -new MetricAlertAction() -{ -ActionGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), -WebHookProperties = -{ -["key11"] = "value11", -["key12"] = "value12", -}, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - MetricAlertResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAWebTestAlertRule() + public async Task GetIfExists_GetADynamicAlertRuleForSingleResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateWebTestMetricAlert.json - // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getDynamicMetricAlertSingleResource.json + // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -929,8 +1054,8 @@ public async Task CreateOrUpdate_CreateOrUpdateAWebTestAlertRule() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "12345678-1234-1234-1234-123456789101"; - string resourceGroupName = "rg-example"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -938,38 +1063,30 @@ public async Task CreateOrUpdate_CreateOrUpdateAWebTestAlertRule() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "webtest-name-example"; - MetricAlertData data = new MetricAlertData(new AzureLocation("global"), 4, true, new string[] + string ruleName = "chiricutin"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + MetricAlertResource result = response.HasValue ? response.Value : null; + + if (result == null) { -"/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example","/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example" - }, XmlConvert.ToTimeSpan("PT1M"), XmlConvert.ToTimeSpan("PT15M"), new WebtestLocationAvailabilityCriteria(new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example"), new ResourceIdentifier("/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example"), 2)) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "Automatically created alert rule for availability test \"component-example\" a", - Actions = -{ -}, - Tags = -{ -["hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/components/webtest-name-example"] = "Resource", -["hidden-link:/subscriptions/12345678-1234-1234-1234-123456789101/resourcegroups/rg-example/providers/microsoft.insights/webtests/component-example"] = "Resource", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - MetricAlertResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleForMultipleResource() + public async Task GetIfExists_GetAWebTestAlertRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertMultipleResource.json - // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getWebTestMetricAlert.json + // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -978,8 +1095,8 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleForMultipleResource() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - string resourceGroupName = "gigtest"; + string subscriptionId = "12345678-1234-1234-1234-123456789101"; + string resourceGroupName = "rg-example"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -987,60 +1104,30 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleForMultipleResource() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertOnMultipleResources"; - MetricAlertData data = new MetricAlertData(new AzureLocation("global"), 3, true, new string[] - { -"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme1","/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme2" - }, XmlConvert.ToTimeSpan("PT1M"), XmlConvert.ToTimeSpan("PT15M"), new MetricAlertMultipleResourceMultipleMetricCriteria() - { - AllOf = + string ruleName = "webtest-name-example"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + MetricAlertResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new MetricCriteria("High_CPU_80","Percentage CPU",MetricCriteriaTimeAggregationType.Average,MetricCriteriaOperator.GreaterThan,80.5) -{ -MetricNamespace = "microsoft.compute/virtualmachines", -Dimensions = -{ -}, -} - }, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "This is the description of the rule1", - TargetResourceType = new ResourceType("Microsoft.Compute/virtualMachines"), - TargetResourceRegion = new AzureLocation("southcentralus"), - IsAutoMitigateEnabled = true, - Actions = -{ -new MetricAlertAction() -{ -ActionGroupId = new ResourceIdentifier("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), -WebHookProperties = -{ -["key11"] = "value11", -["key12"] = "value12", -}, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - MetricAlertResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleForSingleResource() + public async Task GetIfExists_GetAnAlertRuleForMultipleResources() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertSingleResource.json - // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertMultipleResource.json + // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1058,57 +1145,30 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleForSingleResource() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "chiricutin"; - MetricAlertData data = new MetricAlertData(new AzureLocation("global"), 3, true, new string[] - { -"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" - }, XmlConvert.ToTimeSpan("Pt1m"), XmlConvert.ToTimeSpan("Pt15m"), new MetricAlertSingleResourceMultipleMetricCriteria() - { - AllOf = + string ruleName = "MetricAlertOnMultipleResources"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + MetricAlertResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new MetricCriteria("High_CPU_80","\\Processor(_Total)\\% Processor Time",MetricCriteriaTimeAggregationType.Average,MetricCriteriaOperator.GreaterThan,80.5) -{ -Dimensions = -{ -}, -} - }, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "This is the description of the rule1", - IsAutoMitigateEnabled = true, - Actions = -{ -new MetricAlertAction() -{ -ActionGroupId = new ResourceIdentifier("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), -WebHookProperties = -{ -["key11"] = "value11", -["key12"] = "value12", -}, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - MetricAlertResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleOnResourceGroupS() + public async Task GetIfExists_GetAnAlertRuleForSingleResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertResourceGroup.json - // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSingleResource.json + // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1118,7 +1178,7 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleOnResourceGroupS() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - string resourceGroupName = "gigtest1"; + string resourceGroupName = "gigtest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -1126,60 +1186,30 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleOnResourceGroupS() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertAtResourceGroupLevel"; - MetricAlertData data = new MetricAlertData(new AzureLocation("global"), 3, true, new string[] - { -"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest1","/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest2" - }, XmlConvert.ToTimeSpan("PT1M"), XmlConvert.ToTimeSpan("PT15M"), new MetricAlertMultipleResourceMultipleMetricCriteria() - { - AllOf = + string ruleName = "chiricutin"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + MetricAlertResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new MetricCriteria("High_CPU_80","Percentage CPU",MetricCriteriaTimeAggregationType.Average,MetricCriteriaOperator.GreaterThan,80.5) -{ -MetricNamespace = "microsoft.compute/virtualmachines", -Dimensions = -{ -}, -} - }, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "This is the description of the rule1", - TargetResourceType = new ResourceType("Microsoft.Compute/virtualMachines"), - TargetResourceRegion = new AzureLocation("southcentralus"), - IsAutoMitigateEnabled = true, - Actions = -{ -new MetricAlertAction() -{ -ActionGroupId = new ResourceIdentifier("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), -WebHookProperties = -{ -["key11"] = "value11", -["key12"] = "value12", -}, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - MetricAlertResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleOnSubscription() + public async Task GetIfExists_GetAnAlertRuleOnResourceGroupS() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertSubscription.json - // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertResourceGroup.json + // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1189,7 +1219,7 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleOnSubscription() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - string resourceGroupName = "gigtest"; + string resourceGroupName = "gigtest1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -1197,60 +1227,30 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAlertRuleOnSubscription() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertAtSubscriptionLevel"; - MetricAlertData data = new MetricAlertData(new AzureLocation("global"), 3, true, new string[] - { -"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7" - }, XmlConvert.ToTimeSpan("PT1M"), XmlConvert.ToTimeSpan("PT15M"), new MetricAlertMultipleResourceMultipleMetricCriteria() - { - AllOf = + string ruleName = "MetricAlertAtResourceGroupLevel"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + MetricAlertResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new MetricCriteria("High_CPU_80","Percentage CPU",MetricCriteriaTimeAggregationType.Average,MetricCriteriaOperator.GreaterThan,80.5) -{ -MetricNamespace = "microsoft.compute/virtualmachines", -Dimensions = -{ -}, -} - }, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "This is the description of the rule1", - TargetResourceType = new ResourceType("Microsoft.Compute/virtualMachines"), - TargetResourceRegion = new AzureLocation("southcentralus"), - IsAutoMitigateEnabled = true, - Actions = -{ -new MetricAlertAction() -{ -ActionGroupId = new ResourceIdentifier("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), -WebHookProperties = -{ -["key11"] = "value11", -["key12"] = "value12", -}, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - MetricAlertResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnAlertRulesWithDimensions() + public async Task GetIfExists_GetAnAlertRuleOnSubscription() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/createOrUpdateMetricAlertWithDimensions.json - // this example is just showing the usage of "MetricAlerts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/getMetricAlertSubscription.json + // this example is just showing the usage of "MetricAlerts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1268,57 +1268,22 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAlertRulesWithDimensions() MetricAlertCollection collection = resourceGroupResource.GetMetricAlerts(); // invoke the operation - string ruleName = "MetricAlertOnMultipleDimensions"; - MetricAlertData data = new MetricAlertData(new AzureLocation("global"), 3, true, new string[] - { -"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.KeyVault/vaults/keyVaultResource" - }, XmlConvert.ToTimeSpan("PT1H"), XmlConvert.ToTimeSpan("P1D"), new MetricAlertMultipleResourceMultipleMetricCriteria() - { - AllOf = + string ruleName = "MetricAlertAtSubscriptionLevel"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + MetricAlertResource result = response.HasValue ? response.Value : null; + + if (result == null) { -new MetricCriteria("Metric1","Availability",MetricCriteriaTimeAggregationType.Average,MetricCriteriaOperator.GreaterThan,55) -{ -MetricNamespace = "Microsoft.KeyVault/vaults", -Dimensions = -{ -new MetricDimension("ActivityName","Include",new string[] -{ -"*" -}),new MetricDimension("StatusCode","Include",new string[] -{ -"200" -}) -}, -} - }, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Description = "This is the description of the rule1", - IsAutoMitigateEnabled = true, - Actions = -{ -new MetricAlertAction() -{ -ActionGroupId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), -WebHookProperties = -{ -["key11"] = "value11", -["key12"] = "value12", -}, -} -}, - Tags = -{ -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - MetricAlertResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MetricAlertResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MetricAlertResource.cs index 0548cec1fa8a8..16d4219e66be7 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MetricAlertResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MetricAlertResource.cs @@ -11,44 +11,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples { public partial class Sample_MetricAlertResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMetricAlerts_ListMetricAlertRules() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/listMetricAlert.json - // this example is just showing the usage of "MetricAlerts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MetricAlertResource item in subscriptionResource.GetMetricAlertsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MetricAlertData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetADynamicAlertRuleForMultipleResources() @@ -259,6 +227,32 @@ public async Task Get_GetAnAlertRuleOnSubscription() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeleteAnAlertRule() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/deleteMetricAlert.json + // this example is just showing the usage of "MetricAlerts_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this MetricAlertResource created on azure + // for more information of creating MetricAlertResource, please refer to the document of MetricAlertResource + string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; + string resourceGroupName = "gigtest"; + string ruleName = "chiricutin"; + ResourceIdentifier metricAlertResourceId = MetricAlertResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, ruleName); + MetricAlertResource metricAlert = client.GetMetricAlertResource(metricAlertResourceId); + + // invoke the operation + await metricAlert.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateOrUpdateAnAlertRule() @@ -280,45 +274,32 @@ public async Task Update_CreateOrUpdateAnAlertRule() MetricAlertResource metricAlert = client.GetMetricAlertResource(metricAlertResourceId); // invoke the operation - MetricAlertPatch patch = new MetricAlertPatch() + MetricAlertPatch patch = new MetricAlertPatch { - Tags = -{ -}, + Tags = { }, Description = "This is the description of the rule1", Severity = 3, IsEnabled = true, - Scopes = -{ -"/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" -}, + Scopes = { "/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourceGroups/gigtest/providers/Microsoft.Compute/virtualMachines/gigwadme" }, EvaluationFrequency = XmlConvert.ToTimeSpan("Pt1m"), WindowSize = XmlConvert.ToTimeSpan("Pt15m"), - Criteria = new MetricAlertSingleResourceMultipleMetricCriteria() + Criteria = new MetricAlertSingleResourceMultipleMetricCriteria { - AllOf = -{ -new MetricCriteria("High_CPU_80","\\Processor(_Total)\\% Processor Time",MetricCriteriaTimeAggregationType.Average,MetricCriteriaOperator.GreaterThan,80.5) -{ -Dimensions = + AllOf = {new MetricCriteria("High_CPU_80", "\\Processor(_Total)\\% Processor Time", MetricCriteriaTimeAggregationType.Average, MetricCriteriaOperator.GreaterThan, 80.5) { -}, -} -}, +Dimensions = {}, +}}, }, IsAutoMitigateEnabled = true, - Actions = -{ -new MetricAlertAction() + Actions = {new MetricAlertAction { ActionGroupId = new ResourceIdentifier("/subscriptions/14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7/resourcegroups/gigtest/providers/microsoft.insights/actiongroups/group2"), WebHookProperties = { ["key11"] = "value11", -["key12"] = "value12", -}, -} +["key12"] = "value12" }, +}}, }; MetricAlertResource result = await metricAlert.UpdateAsync(patch); @@ -329,32 +310,6 @@ public async Task Update_CreateOrUpdateAnAlertRule() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAnAlertRule() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/deleteMetricAlert.json - // this example is just showing the usage of "MetricAlerts_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this MetricAlertResource created on azure - // for more information of creating MetricAlertResource, please refer to the document of MetricAlertResource - string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; - string resourceGroupName = "gigtest"; - string ruleName = "chiricutin"; - ResourceIdentifier metricAlertResourceId = MetricAlertResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, ruleName); - MetricAlertResource metricAlert = client.GetMetricAlertResource(metricAlertResourceId); - - // invoke the operation - await metricAlert.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetAllMetricAlertsStatus_GetAnAlertRuleStatus() diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateEndpointConnectionCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateEndpointConnectionCollection.cs index 47d81c9e36a32..444dff79e2060 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateEndpointConnectionCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MonitorPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateEndpointConnection() + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - MonitorPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + MonitorPrivateEndpointConnectionData data = new MonitorPrivateEndpointConnectionData + { + ConnectionState = new MonitorPrivateLinkServiceConnectionState + { + Status = MonitorPrivateEndpointServiceConnectionStatus.Approved, + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + MonitorPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +61,7 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task Get_GetsPrivateEndpointConnection() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +84,21 @@ public async Task Exists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + MonitorPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAPrivateLinkScope() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionList.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +116,25 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // get the collection of this MonitorPrivateEndpointConnectionResource MonitorPrivateEndpointConnectionCollection collection = monitorPrivateLinkScope.GetMonitorPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - MonitorPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MonitorPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MonitorPrivateEndpointConnectionData resourceData = result.Data; + MonitorPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Exists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,30 +154,17 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - MonitorPrivateEndpointConnectionData data = new MonitorPrivateEndpointConnectionData() - { - ConnectionState = new MonitorPrivateLinkServiceConnectionState() - { - Status = MonitorPrivateEndpointServiceConnectionStatus.Approved, - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - MonitorPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAPrivateLinkScope() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionList.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAPrivateLinkScope // get the collection of this MonitorPrivateEndpointConnectionResource MonitorPrivateEndpointConnectionCollection collection = monitorPrivateLinkScope.GetMonitorPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (MonitorPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + MonitorPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MonitorPrivateEndpointConnectionData resourceData = item.Data; + MonitorPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateEndpointConnectionResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateEndpointConnectionResource.cs index 36c030873399c..289435b7b0d07 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateEndpointConnectionResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionDelete.json + // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,17 @@ public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName MonitorPrivateEndpointConnectionResource monitorPrivateEndpointConnection = client.GetMonitorPrivateEndpointConnectionResource(monitorPrivateEndpointConnectionResourceId); // invoke the operation - MonitorPrivateEndpointConnectionData data = new MonitorPrivateEndpointConnectionData() - { - ConnectionState = new MonitorPrivateLinkServiceConnectionState() - { - Status = MonitorPrivateEndpointServiceConnectionStatus.Approved, - Description = "Approved by johndoe@contoso.com", - }, - }; - ArmOperation lro = await monitorPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - MonitorPrivateEndpointConnectionResource result = lro.Value; + await monitorPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() + public async Task Update_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionDelete.json - // this example is just showing the usage of "PrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,9 +96,22 @@ public async Task Delete_DeletesAPrivateEndpointConnectionWithAGivenName() MonitorPrivateEndpointConnectionResource monitorPrivateEndpointConnection = client.GetMonitorPrivateEndpointConnectionResource(monitorPrivateEndpointConnectionResourceId); // invoke the operation - await monitorPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + MonitorPrivateEndpointConnectionData data = new MonitorPrivateEndpointConnectionData + { + ConnectionState = new MonitorPrivateLinkServiceConnectionState + { + Status = MonitorPrivateEndpointServiceConnectionStatus.Approved, + Description = "Approved by johndoe@contoso.com", + }, + }; + ArmOperation lro = await monitorPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + MonitorPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkResourceCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkResourceCollection.cs index 11e5fda72762d..bb26ca977096e 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkResourceCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MonitorPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateEndpointConnection() + public async Task Get_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopePrivateLinkResourceListGet.json - // this example is just showing the usage of "PrivateLinkResources_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopePrivateLinkResourceGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetsPrivateEndpointConnection() // get the collection of this MonitorPrivateLinkResource MonitorPrivateLinkResourceCollection collection = monitorPrivateLinkScope.GetMonitorPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (MonitorPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "azuremonitor"; + MonitorPrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateEndpointConnection() + public async Task GetAll_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopePrivateLinkResourceGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopePrivateLinkResourceListGet.json + // this example is just showing the usage of "PrivateLinkResources_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsPrivateEndpointConnection() // get the collection of this MonitorPrivateLinkResource MonitorPrivateLinkResourceCollection collection = monitorPrivateLinkScope.GetMonitorPrivateLinkResources(); - // invoke the operation - string groupName = "azuremonitor"; - MonitorPrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (MonitorPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopeCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopeCollection.cs index cd5e6459b0347..b9985ef2397f5 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopeCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopeCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_MonitorPrivateLinkScopeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PrivateLinkScopeListByResourceGroup() + public async Task CreateOrUpdate_PrivateLinkScopeCreate() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesListByResourceGroup.json - // this example is just showing the usage of "PrivateLinkScopes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesCreate.json + // this example is just showing the usage of "PrivateLinkScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,28 @@ public async Task GetAll_PrivateLinkScopeListByResourceGroup() // get the collection of this MonitorPrivateLinkScopeResource MonitorPrivateLinkScopeCollection collection = resourceGroupResource.GetMonitorPrivateLinkScopes(); - // invoke the operation and iterate over the result - await foreach (MonitorPrivateLinkScopeResource item in collection.GetAllAsync()) + // invoke the operation + string scopeName = "my-privatelinkscope"; + MonitorPrivateLinkScopeData data = new MonitorPrivateLinkScopeData(new AzureLocation("Global"), new MonitorPrivateLinkAccessModeSettings(MonitorPrivateLinkAccessMode.Open, MonitorPrivateLinkAccessMode.Open) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateLinkScopeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Exclusions = { }, + }); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeName, data); + MonitorPrivateLinkScopeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateLinkScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkScopeGet() + public async Task CreateOrUpdate_PrivateLinkScopeUpdate() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesGet.json - // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesUpdate.json + // this example is just showing the usage of "PrivateLinkScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +79,18 @@ public async Task Get_PrivateLinkScopeGet() // invoke the operation string scopeName = "my-privatelinkscope"; - MonitorPrivateLinkScopeResource result = await collection.GetAsync(scopeName); + MonitorPrivateLinkScopeData data = new MonitorPrivateLinkScopeData(new AzureLocation("Global"), new MonitorPrivateLinkAccessModeSettings(MonitorPrivateLinkAccessMode.Open, MonitorPrivateLinkAccessMode.Open) + { + Exclusions = { }, + }) + { + Tags = +{ +["Tag1"] = "Value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeName, data); + MonitorPrivateLinkScopeResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +101,7 @@ public async Task Get_PrivateLinkScopeGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PrivateLinkScopeGet() + public async Task Get_PrivateLinkScopeGet() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesGet.json // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,17 +123,21 @@ public async Task Exists_PrivateLinkScopeGet() // invoke the operation string scopeName = "my-privatelinkscope"; - bool result = await collection.ExistsAsync(scopeName); + MonitorPrivateLinkScopeResource result = await collection.GetAsync(scopeName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateLinkScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PrivateLinkScopeGet() + public async Task GetAll_PrivateLinkScopeListByResourceGroup() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesGet.json - // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesListByResourceGroup.json + // this example is just showing the usage of "PrivateLinkScopes_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,31 +154,25 @@ public async Task GetIfExists_PrivateLinkScopeGet() // get the collection of this MonitorPrivateLinkScopeResource MonitorPrivateLinkScopeCollection collection = resourceGroupResource.GetMonitorPrivateLinkScopes(); - // invoke the operation - string scopeName = "my-privatelinkscope"; - NullableResponse response = await collection.GetIfExistsAsync(scopeName); - MonitorPrivateLinkScopeResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MonitorPrivateLinkScopeResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MonitorPrivateLinkScopeData resourceData = result.Data; + MonitorPrivateLinkScopeData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateLinkScopeCreate() + public async Task Exists_PrivateLinkScopeGet() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesCreate.json - // this example is just showing the usage of "PrivateLinkScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesGet.json + // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,28 +191,17 @@ public async Task CreateOrUpdate_PrivateLinkScopeCreate() // invoke the operation string scopeName = "my-privatelinkscope"; - MonitorPrivateLinkScopeData data = new MonitorPrivateLinkScopeData(new AzureLocation("Global"), new MonitorPrivateLinkAccessModeSettings(MonitorPrivateLinkAccessMode.Open, MonitorPrivateLinkAccessMode.Open) - { - Exclusions = -{ -}, - }); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeName, data); - MonitorPrivateLinkScopeResource result = lro.Value; + bool result = await collection.ExistsAsync(scopeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateLinkScopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PrivateLinkScopeUpdate() + public async Task GetIfExists_PrivateLinkScopeGet() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesUpdate.json - // this example is just showing the usage of "PrivateLinkScopes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesGet.json + // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -219,26 +220,21 @@ public async Task CreateOrUpdate_PrivateLinkScopeUpdate() // invoke the operation string scopeName = "my-privatelinkscope"; - MonitorPrivateLinkScopeData data = new MonitorPrivateLinkScopeData(new AzureLocation("Global"), new MonitorPrivateLinkAccessModeSettings(MonitorPrivateLinkAccessMode.Open, MonitorPrivateLinkAccessMode.Open) + NullableResponse response = await collection.GetIfExistsAsync(scopeName); + MonitorPrivateLinkScopeResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Exclusions = -{ -}, - }) + Console.WriteLine("Succeeded with null as result"); + } + else { - Tags = -{ -["Tag1"] = "Value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, scopeName, data); - MonitorPrivateLinkScopeResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateLinkScopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateLinkScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopeResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopeResource.cs index 71657d3171227..4a8e7a188d8f3 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopeResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopeResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples @@ -19,41 +18,10 @@ public partial class Sample_MonitorPrivateLinkScopeResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetMonitorPrivateLinkScopes_PrivateLinkScopesListJson() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesList.json - // this example is just showing the usage of "PrivateLinkScopes_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MonitorPrivateLinkScopeResource item in subscriptionResource.GetMonitorPrivateLinkScopesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateLinkScopeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_PrivateLinkScopesDelete() + public async Task Get_PrivateLinkScopeGet() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesDelete.json - // this example is just showing the usage of "PrivateLinkScopes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesGet.json + // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,17 +37,21 @@ public async Task Delete_PrivateLinkScopesDelete() MonitorPrivateLinkScopeResource monitorPrivateLinkScope = client.GetMonitorPrivateLinkScopeResource(monitorPrivateLinkScopeResourceId); // invoke the operation - await monitorPrivateLinkScope.DeleteAsync(WaitUntil.Completed); + MonitorPrivateLinkScopeResource result = await monitorPrivateLinkScope.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateLinkScopeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_PrivateLinkScopeGet() + public async Task Delete_PrivateLinkScopesDelete() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesGet.json - // this example is just showing the usage of "PrivateLinkScopes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesDelete.json + // this example is just showing the usage of "PrivateLinkScopes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,13 +67,9 @@ public async Task Get_PrivateLinkScopeGet() MonitorPrivateLinkScopeResource monitorPrivateLinkScope = client.GetMonitorPrivateLinkScopeResource(monitorPrivateLinkScopeResourceId); // invoke the operation - MonitorPrivateLinkScopeResource result = await monitorPrivateLinkScope.GetAsync(); + await monitorPrivateLinkScope.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateLinkScopeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -125,12 +93,12 @@ public async Task Update_PrivateLinkScopeUpdateTagsOnly() MonitorPrivateLinkScopeResource monitorPrivateLinkScope = client.GetMonitorPrivateLinkScopeResource(monitorPrivateLinkScopeResourceId); // invoke the operation - MonitorPrivateLinkScopePatch patch = new MonitorPrivateLinkScopePatch() + MonitorPrivateLinkScopePatch patch = new MonitorPrivateLinkScopePatch { Tags = { ["Tag1"] = "Value1", -["Tag2"] = "Value2", +["Tag2"] = "Value2" }, }; MonitorPrivateLinkScopeResource result = await monitorPrivateLinkScope.UpdateAsync(patch); diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopedResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopedResource.cs index c214623d28046..09c7216452a59 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopedResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopedResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetsPrivateLinkScopedResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAScopedResourceInAPrivateLinkScope() + public async Task Delete_DeletesAScopedResourceWithAGivenName() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceUpdate.json - // this example is just showing the usage of "PrivateLinkScopedResources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceDelete.json + // this example is just showing the usage of "PrivateLinkScopedResources_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_UpdateAScopedResourceInAPrivateLinkScope() MonitorPrivateLinkScopedResource monitorPrivateLinkScopedResource = client.GetMonitorPrivateLinkScopedResource(monitorPrivateLinkScopedResourceId); // invoke the operation - MonitorPrivateLinkScopedResourceData data = new MonitorPrivateLinkScopedResourceData() - { - LinkedResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/components/my-component"), - }; - ArmOperation lro = await monitorPrivateLinkScopedResource.UpdateAsync(WaitUntil.Completed, data); - MonitorPrivateLinkScopedResource result = lro.Value; + await monitorPrivateLinkScopedResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateLinkScopedResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAScopedResourceWithAGivenName() + public async Task Update_UpdateAScopedResourceInAPrivateLinkScope() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceDelete.json - // this example is just showing the usage of "PrivateLinkScopedResources_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceUpdate.json + // this example is just showing the usage of "PrivateLinkScopedResources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,18 @@ public async Task Delete_DeletesAScopedResourceWithAGivenName() MonitorPrivateLinkScopedResource monitorPrivateLinkScopedResource = client.GetMonitorPrivateLinkScopedResource(monitorPrivateLinkScopedResourceId); // invoke the operation - await monitorPrivateLinkScopedResource.DeleteAsync(WaitUntil.Completed); + MonitorPrivateLinkScopedResourceData data = new MonitorPrivateLinkScopedResourceData + { + LinkedResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/components/my-component"), + }; + ArmOperation lro = await monitorPrivateLinkScopedResource.UpdateAsync(WaitUntil.Completed, data); + MonitorPrivateLinkScopedResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateLinkScopedResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopedResourceCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopedResourceCollection.cs index 287530da85eb9..f6765a956b93d 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopedResourceCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorPrivateLinkScopedResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MonitorPrivateLinkScopedResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateLinkScopedResource() + public async Task CreateOrUpdate_UpdateAScopedResourceInAPrivateLinkScope() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceGet.json - // this example is just showing the usage of "PrivateLinkScopedResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceUpdate.json + // this example is just showing the usage of "PrivateLinkScopedResources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetsPrivateLinkScopedResource() // invoke the operation string name = "scoped-resource-name"; - MonitorPrivateLinkScopedResource result = await collection.GetAsync(name); + MonitorPrivateLinkScopedResourceData data = new MonitorPrivateLinkScopedResourceData + { + LinkedResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/components/my-component"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); + MonitorPrivateLinkScopedResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetsPrivateLinkScopedResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateLinkScopedResource() + public async Task Get_GetsPrivateLinkScopedResource() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceGet.json // this example is just showing the usage of "PrivateLinkScopedResources_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +79,21 @@ public async Task Exists_GetsPrivateLinkScopedResource() // invoke the operation string name = "scoped-resource-name"; - bool result = await collection.ExistsAsync(name); + MonitorPrivateLinkScopedResource result = await collection.GetAsync(name); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateLinkScopedResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateLinkScopedResource() + public async Task GetAll_GetsListOfScopedResourcesInAPrivateLinkScope() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceGet.json - // this example is just showing the usage of "PrivateLinkScopedResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceList.json + // this example is just showing the usage of "PrivateLinkScopedResources_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +111,25 @@ public async Task GetIfExists_GetsPrivateLinkScopedResource() // get the collection of this MonitorPrivateLinkScopedResource MonitorPrivateLinkScopedResourceCollection collection = monitorPrivateLinkScope.GetMonitorPrivateLinkScopedResources(); - // invoke the operation - string name = "scoped-resource-name"; - NullableResponse response = await collection.GetIfExistsAsync(name); - MonitorPrivateLinkScopedResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MonitorPrivateLinkScopedResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MonitorPrivateLinkScopedResourceData resourceData = result.Data; + MonitorPrivateLinkScopedResourceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAScopedResourceInAPrivateLinkScope() + public async Task Exists_GetsPrivateLinkScopedResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceUpdate.json - // this example is just showing the usage of "PrivateLinkScopedResources_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceGet.json + // this example is just showing the usage of "PrivateLinkScopedResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,26 +149,17 @@ public async Task CreateOrUpdate_UpdateAScopedResourceInAPrivateLinkScope() // invoke the operation string name = "scoped-resource-name"; - MonitorPrivateLinkScopedResourceData data = new MonitorPrivateLinkScopedResourceData() - { - LinkedResourceId = new ResourceIdentifier("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/MyResourceGroup/providers/Microsoft.Insights/components/my-component"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, name, data); - MonitorPrivateLinkScopedResource result = lro.Value; + bool result = await collection.ExistsAsync(name); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorPrivateLinkScopedResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfScopedResourcesInAPrivateLinkScope() + public async Task GetIfExists_GetsPrivateLinkScopedResource() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceList.json - // this example is just showing the usage of "PrivateLinkScopedResources_ListByPrivateLinkScope" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopedResourceGet.json + // this example is just showing the usage of "PrivateLinkScopedResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_GetsListOfScopedResourcesInAPrivateLinkScope() // get the collection of this MonitorPrivateLinkScopedResource MonitorPrivateLinkScopedResourceCollection collection = monitorPrivateLinkScope.GetMonitorPrivateLinkScopedResources(); - // invoke the operation and iterate over the result - await foreach (MonitorPrivateLinkScopedResource item in collection.GetAllAsync()) + // invoke the operation + string name = "scoped-resource-name"; + NullableResponse response = await collection.GetIfExistsAsync(name); + MonitorPrivateLinkScopedResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MonitorPrivateLinkScopedResourceData resourceData = item.Data; + MonitorPrivateLinkScopedResourceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorWorkspaceResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorWorkspaceResource.cs index c29167808f909..38be28f33dd91 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorWorkspaceResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorWorkspaceResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples { public partial class Sample_MonitorWorkspaceResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMonitorWorkspaceResources_ListAzureMonitorWorkspacesBySubscription() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspacesListBySubscription.json - // this example is just showing the usage of "AzureMonitorWorkspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "703362b3-f278-4e4b-9179-c76eaf41ffc2"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MonitorWorkspaceResource item in subscriptionResource.GetMonitorWorkspaceResourcesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorWorkspaceResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_RetrievesAnAzureMonitorWorkspace() @@ -80,10 +48,10 @@ public async Task Get_RetrievesAnAzureMonitorWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdatesAnAzureMonitorWorkspace() + public async Task Delete_DeletesAnAzureMonitorWorkspaceAsynchronously() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspaceUpdate.json - // this example is just showing the usage of "AzureMonitorWorkspaces_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspaceDelete.json + // this example is just showing the usage of "AzureMonitorWorkspaces_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,30 +67,17 @@ public async Task Update_UpdatesAnAzureMonitorWorkspace() MonitorWorkspaceResource monitorWorkspaceResource = client.GetMonitorWorkspaceResource(monitorWorkspaceResourceId); // invoke the operation - MonitorWorkspaceResourcePatch patch = new MonitorWorkspaceResourcePatch() - { - Tags = -{ -["tag1"] = "A", -["tag2"] = "B", -["tag3"] = "C", -}, - }; - MonitorWorkspaceResource result = await monitorWorkspaceResource.UpdateAsync(patch); + await monitorWorkspaceResource.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorWorkspaceResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAnAzureMonitorWorkspaceAsynchronously() + public async Task Update_UpdatesAnAzureMonitorWorkspace() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspaceDelete.json - // this example is just showing the usage of "AzureMonitorWorkspaces_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspaceUpdate.json + // this example is just showing the usage of "AzureMonitorWorkspaces_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,9 +93,22 @@ public async Task Delete_DeletesAnAzureMonitorWorkspaceAsynchronously() MonitorWorkspaceResource monitorWorkspaceResource = client.GetMonitorWorkspaceResource(monitorWorkspaceResourceId); // invoke the operation - await monitorWorkspaceResource.DeleteAsync(WaitUntil.Completed); + MonitorWorkspaceResourcePatch patch = new MonitorWorkspaceResourcePatch + { + Tags = +{ +["tag1"] = "A", +["tag2"] = "B", +["tag3"] = "C" +}, + }; + MonitorWorkspaceResource result = await monitorWorkspaceResource.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorWorkspaceResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorWorkspaceResourceCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorWorkspaceResourceCollection.cs index fb1788caee8ab..adf2ef2fc5877 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorWorkspaceResourceCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_MonitorWorkspaceResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MonitorWorkspaceResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAzureMonitorWorkspacesByResourceGroup() + public async Task CreateOrUpdate_CreatesAnAzureMonitorWorkspace() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspacesListByResourceGroup.json - // this example is just showing the usage of "AzureMonitorWorkspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspaceCreate.json + // this example is just showing the usage of "AzureMonitorWorkspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task GetAll_ListAzureMonitorWorkspacesByResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "703362b3-f278-4e4b-9179-c76eaf41ffc2"; + string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -38,17 +38,17 @@ public async Task GetAll_ListAzureMonitorWorkspacesByResourceGroup() // get the collection of this MonitorWorkspaceResource MonitorWorkspaceResourceCollection collection = resourceGroupResource.GetMonitorWorkspaceResources(); - // invoke the operation and iterate over the result - await foreach (MonitorWorkspaceResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorWorkspaceResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string azureMonitorWorkspaceName = "myAzureMonitorWorkspace"; + MonitorWorkspaceResourceData data = new MonitorWorkspaceResourceData(new AzureLocation("eastus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureMonitorWorkspaceName, data); + MonitorWorkspaceResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorWorkspaceResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -86,10 +86,10 @@ public async Task Get_RetrievesAnAzureMonitorWorkspace() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrievesAnAzureMonitorWorkspace() + public async Task GetAll_ListAzureMonitorWorkspacesByResourceGroup() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspaceGet.json - // this example is just showing the usage of "AzureMonitorWorkspaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspacesListByResourceGroup.json + // this example is just showing the usage of "AzureMonitorWorkspaces_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +106,22 @@ public async Task Exists_RetrievesAnAzureMonitorWorkspace() // get the collection of this MonitorWorkspaceResource MonitorWorkspaceResourceCollection collection = resourceGroupResource.GetMonitorWorkspaceResources(); - // invoke the operation - string azureMonitorWorkspaceName = "myAzureMonitorWorkspace"; - bool result = await collection.ExistsAsync(azureMonitorWorkspaceName); + // invoke the operation and iterate over the result + await foreach (MonitorWorkspaceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorWorkspaceResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrievesAnAzureMonitorWorkspace() + public async Task Exists_RetrievesAnAzureMonitorWorkspace() { // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspaceGet.json // this example is just showing the usage of "AzureMonitorWorkspaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -137,29 +143,17 @@ public async Task GetIfExists_RetrievesAnAzureMonitorWorkspace() // invoke the operation string azureMonitorWorkspaceName = "myAzureMonitorWorkspace"; - NullableResponse response = await collection.GetIfExistsAsync(azureMonitorWorkspaceName); - MonitorWorkspaceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(azureMonitorWorkspaceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorWorkspaceResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesAnAzureMonitorWorkspace() + public async Task GetIfExists_RetrievesAnAzureMonitorWorkspace() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspaceCreate.json - // this example is just showing the usage of "AzureMonitorWorkspaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspaceGet.json + // this example is just showing the usage of "AzureMonitorWorkspaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -168,7 +162,7 @@ public async Task CreateOrUpdate_CreatesAnAzureMonitorWorkspace() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string subscriptionId = "703362b3-f278-4e4b-9179-c76eaf41ffc2"; string resourceGroupName = "myResourceGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -178,15 +172,21 @@ public async Task CreateOrUpdate_CreatesAnAzureMonitorWorkspace() // invoke the operation string azureMonitorWorkspaceName = "myAzureMonitorWorkspace"; - MonitorWorkspaceResourceData data = new MonitorWorkspaceResourceData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureMonitorWorkspaceName, data); - MonitorWorkspaceResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(azureMonitorWorkspaceName); + MonitorWorkspaceResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MonitorWorkspaceResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorWorkspaceResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_PipelineGroupCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_PipelineGroupCollection.cs index 08fb1269fa71b..561202317f137 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_PipelineGroupCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_PipelineGroupCollection.cs @@ -18,144 +18,6 @@ namespace Azure.ResourceManager.Monitor.Samples { public partial class Sample_PipelineGroupCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPipelineGroupsByResourceGroup() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupListByResourceGroup.json - // this example is just showing the usage of "PipelineGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PipelineGroupResource - PipelineGroupCollection collection = resourceGroupResource.GetPipelineGroups(); - - // invoke the operation and iterate over the result - await foreach (PipelineGroupResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PipelineGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_RetrievesAPipelineGroupInstanceByName() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupGet.json - // this example is just showing the usage of "PipelineGroups_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PipelineGroupResource - PipelineGroupCollection collection = resourceGroupResource.GetPipelineGroups(); - - // invoke the operation - string pipelineGroupName = "plGroup1"; - PipelineGroupResource result = await collection.GetAsync(pipelineGroupName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PipelineGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_RetrievesAPipelineGroupInstanceByName() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupGet.json - // this example is just showing the usage of "PipelineGroups_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PipelineGroupResource - PipelineGroupCollection collection = resourceGroupResource.GetPipelineGroups(); - - // invoke the operation - string pipelineGroupName = "plGroup1"; - bool result = await collection.ExistsAsync(pipelineGroupName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RetrievesAPipelineGroupInstanceByName() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupGet.json - // this example is just showing the usage of "PipelineGroups_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this PipelineGroupResource - PipelineGroupCollection collection = resourceGroupResource.GetPipelineGroups(); - - // invoke the operation - string pipelineGroupName = "plGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(pipelineGroupName); - PipelineGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PipelineGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateAPipelineGroupInstanceUsingUDPReceiver() @@ -182,59 +44,45 @@ public async Task CreateOrUpdate_CreateAPipelineGroupInstanceUsingUDPReceiver() string pipelineGroupName = "plGroup1"; PipelineGroupData data = new PipelineGroupData(new AzureLocation("eastus2")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/myTestCustomLocation", }, - Receivers = -{ -new PipelineGroupReceiver(PipelineGroupReceiverType.Udp,"udp-receiver1") + Receivers = {new PipelineGroupReceiver(PipelineGroupReceiverType.Udp, "udp-receiver1") { Udp = new UdpReceiver("0.0.0.0:518") { Encoding = StreamEncodingType.Utf8, }, -} -}, - Processors = +}}, + Processors = { }, + Exporters = {new PipelineGroupExporter(PipelineGroupExporterType.AzureMonitorWorkspaceLogs, "my-workspace-logs-exporter1") { -}, - Exporters = -{ -new PipelineGroupExporter(PipelineGroupExporterType.AzureMonitorWorkspaceLogs,"my-workspace-logs-exporter1") -{ -AzureMonitorWorkspaceLogs = new MonitorWorkspaceLogsExporter(new MonitorWorkspaceLogsApiConfig(new Uri("https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com"),"Custom-MyTableRawData_CL","dcr-00000000000000000000000000000000",new MonitorWorkspaceLogsSchemaMap(new MonitorWorkspaceLogsRecordMap[] +AzureMonitorWorkspaceLogs = new MonitorWorkspaceLogsExporter(new MonitorWorkspaceLogsApiConfig(new Uri("https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com"), "Custom-MyTableRawData_CL", "dcr-00000000000000000000000000000000", new MonitorWorkspaceLogsSchemaMap(new MonitorWorkspaceLogsRecordMap[] { -new MonitorWorkspaceLogsRecordMap("body","Body"),new MonitorWorkspaceLogsRecordMap("severity_text","SeverityText"),new MonitorWorkspaceLogsRecordMap("time_unix_nano","TimeGenerated") +new MonitorWorkspaceLogsRecordMap("body", "Body"), +new MonitorWorkspaceLogsRecordMap("severity_text", "SeverityText"), +new MonitorWorkspaceLogsRecordMap("time_unix_nano", "TimeGenerated") }))) { -Concurrency = new MonitorWorkspaceLogsExporterConcurrencyConfiguration() +Concurrency = new MonitorWorkspaceLogsExporterConcurrencyConfiguration { WorkerCount = 4, BatchQueueSize = 100, }, }, -} -}, +}}, Service = new PipelineGroupService(new PipelineGroupServicePipeline[] { -new PipelineGroupServicePipeline("MyPipelineForLogs1",PipelineGroupServicePipelineType.Logs,new string[] +new PipelineGroupServicePipeline("MyPipelineForLogs1", PipelineGroupServicePipelineType.Logs, new string[]{"udp-receiver1"}, new string[]{"my-workspace-logs-exporter1"}) { -"udp-receiver1" -},new string[] -{ -"my-workspace-logs-exporter1" -}) -{ -Processors = -{ -}, +Processors = {}, } }), Tags = { ["tag1"] = "A", -["tag2"] = "B", +["tag2"] = "B" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pipelineGroupName, data); @@ -273,58 +121,42 @@ public async Task CreateOrUpdate_CreateAPipelineGroupInstanceUsingASyslogReceive string pipelineGroupName = "plGroup1"; PipelineGroupData data = new PipelineGroupData(new AzureLocation("eastus2")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/myTestCustomLocation", }, - Receivers = -{ -new PipelineGroupReceiver(PipelineGroupReceiverType.Syslog,"syslog-receiver1") + Receivers = {new PipelineGroupReceiver(PipelineGroupReceiverType.Syslog, "syslog-receiver1") { Syslog = new SyslogReceiver("0.0.0.0:514"), -} -}, - Processors = -{ -new PipelineGroupProcessor(PipelineGroupProcessorType.Batch,"batch-processor1") -}, - Exporters = +}}, + Processors = { new PipelineGroupProcessor(PipelineGroupProcessorType.Batch, "batch-processor1") }, + Exporters = {new PipelineGroupExporter(PipelineGroupExporterType.AzureMonitorWorkspaceLogs, "my-workspace-logs-exporter1") { -new PipelineGroupExporter(PipelineGroupExporterType.AzureMonitorWorkspaceLogs,"my-workspace-logs-exporter1") +AzureMonitorWorkspaceLogs = new MonitorWorkspaceLogsExporter(new MonitorWorkspaceLogsApiConfig(new Uri("https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com"), "Custom-MyTableRawData_CL", "dcr-00000000000000000000000000000000", new MonitorWorkspaceLogsSchemaMap(new MonitorWorkspaceLogsRecordMap[] { -AzureMonitorWorkspaceLogs = new MonitorWorkspaceLogsExporter(new MonitorWorkspaceLogsApiConfig(new Uri("https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com"),"Custom-MyTableRawData_CL","dcr-00000000000000000000000000000000",new MonitorWorkspaceLogsSchemaMap(new MonitorWorkspaceLogsRecordMap[] -{ -new MonitorWorkspaceLogsRecordMap("body","Body"),new MonitorWorkspaceLogsRecordMap("severity_text","SeverityText"),new MonitorWorkspaceLogsRecordMap("time_unix_nano","TimeGenerated") +new MonitorWorkspaceLogsRecordMap("body", "Body"), +new MonitorWorkspaceLogsRecordMap("severity_text", "SeverityText"), +new MonitorWorkspaceLogsRecordMap("time_unix_nano", "TimeGenerated") }))) { -Concurrency = new MonitorWorkspaceLogsExporterConcurrencyConfiguration() +Concurrency = new MonitorWorkspaceLogsExporterConcurrencyConfiguration { WorkerCount = 4, BatchQueueSize = 100, }, }, -} -}, +}}, Service = new PipelineGroupService(new PipelineGroupServicePipeline[] { -new PipelineGroupServicePipeline("MyPipelineForLogs1",PipelineGroupServicePipelineType.Logs,new string[] -{ -"syslog-receiver1" -},new string[] -{ -"my-workspace-logs-exporter1" -}) -{ -Processors = +new PipelineGroupServicePipeline("MyPipelineForLogs1", PipelineGroupServicePipelineType.Logs, new string[]{"syslog-receiver1"}, new string[]{"my-workspace-logs-exporter1"}) { -"batch-processor1" -}, +Processors = {"batch-processor1"}, } }), Tags = { ["tag1"] = "A", -["tag2"] = "B", +["tag2"] = "B" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pipelineGroupName, data); @@ -363,63 +195,47 @@ public async Task CreateOrUpdate_CreateAPipelineGroupInstanceUsingASyslogReceive string pipelineGroupName = "plGroup1"; PipelineGroupData data = new PipelineGroupData(new AzureLocation("eastus2")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/myTestCustomLocation", }, - Receivers = -{ -new PipelineGroupReceiver(PipelineGroupReceiverType.Syslog,"syslog-receiver1") + Receivers = {new PipelineGroupReceiver(PipelineGroupReceiverType.Syslog, "syslog-receiver1") { Syslog = new SyslogReceiver("0.0.0.0:514"), -} -}, - Processors = -{ -new PipelineGroupProcessor(PipelineGroupProcessorType.Batch,"batch-processor1") -}, - Exporters = +}}, + Processors = { new PipelineGroupProcessor(PipelineGroupProcessorType.Batch, "batch-processor1") }, + Exporters = {new PipelineGroupExporter(PipelineGroupExporterType.AzureMonitorWorkspaceLogs, "my-workspace-logs-exporter1") { -new PipelineGroupExporter(PipelineGroupExporterType.AzureMonitorWorkspaceLogs,"my-workspace-logs-exporter1") +AzureMonitorWorkspaceLogs = new MonitorWorkspaceLogsExporter(new MonitorWorkspaceLogsApiConfig(new Uri("https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com"), "Custom-MyTableRawData_CL", "dcr-00000000000000000000000000000000", new MonitorWorkspaceLogsSchemaMap(new MonitorWorkspaceLogsRecordMap[] { -AzureMonitorWorkspaceLogs = new MonitorWorkspaceLogsExporter(new MonitorWorkspaceLogsApiConfig(new Uri("https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com"),"Custom-MyTableRawData_CL","dcr-00000000000000000000000000000000",new MonitorWorkspaceLogsSchemaMap(new MonitorWorkspaceLogsRecordMap[] -{ -new MonitorWorkspaceLogsRecordMap("body","Body"),new MonitorWorkspaceLogsRecordMap("severity_text","SeverityText"),new MonitorWorkspaceLogsRecordMap("time_unix_nano","TimeGenerated") +new MonitorWorkspaceLogsRecordMap("body", "Body"), +new MonitorWorkspaceLogsRecordMap("severity_text", "SeverityText"), +new MonitorWorkspaceLogsRecordMap("time_unix_nano", "TimeGenerated") }))) { -Concurrency = new MonitorWorkspaceLogsExporterConcurrencyConfiguration() +Concurrency = new MonitorWorkspaceLogsExporterConcurrencyConfiguration { WorkerCount = 4, BatchQueueSize = 100, }, -Cache = new MonitorWorkspaceLogsExporterCacheConfiguration() +Cache = new MonitorWorkspaceLogsExporterCacheConfiguration { MaxStorageUsage = 100, RetentionPeriod = 10, }, }, -} -}, +}}, Service = new PipelineGroupService(new PipelineGroupServicePipeline[] { -new PipelineGroupServicePipeline("MyPipelineForLogs1",PipelineGroupServicePipelineType.Logs,new string[] +new PipelineGroupServicePipeline("MyPipelineForLogs1", PipelineGroupServicePipelineType.Logs, new string[]{"syslog-receiver1"}, new string[]{"my-workspace-logs-exporter1"}) { -"syslog-receiver1" -},new string[] -{ -"my-workspace-logs-exporter1" -}) -{ -Processors = -{ -"batch-processor1" -}, +Processors = {"batch-processor1"}, } }), Tags = { ["tag1"] = "A", -["tag2"] = "B", +["tag2"] = "B" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pipelineGroupName, data); @@ -458,66 +274,49 @@ public async Task CreateOrUpdate_CreateAPipelineGroupInstanceUsingASyslogReceive string pipelineGroupName = "plGroup1"; PipelineGroupData data = new PipelineGroupData(new AzureLocation("eastus2")) { - ExtendedLocation = new ExtendedLocation() + ExtendedLocation = new ExtendedLocation { Name = "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/microsoft.extendedlocation/customlocations/myTestCustomLocation", }, - Receivers = -{ -new PipelineGroupReceiver(PipelineGroupReceiverType.Syslog,"syslog-receiver1") + Receivers = {new PipelineGroupReceiver(PipelineGroupReceiverType.Syslog, "syslog-receiver1") { Syslog = new SyslogReceiver("0.0.0.0:514"), -} -}, - Processors = -{ -}, - Exporters = +}}, + Processors = { }, + Exporters = {new PipelineGroupExporter(PipelineGroupExporterType.AzureMonitorWorkspaceLogs, "my-workspace-logs-exporter1") { -new PipelineGroupExporter(PipelineGroupExporterType.AzureMonitorWorkspaceLogs,"my-workspace-logs-exporter1") +AzureMonitorWorkspaceLogs = new MonitorWorkspaceLogsExporter(new MonitorWorkspaceLogsApiConfig(new Uri("https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com"), "Custom-MyTableRawData_CL", "dcr-00000000000000000000000000000000", new MonitorWorkspaceLogsSchemaMap(new MonitorWorkspaceLogsRecordMap[] { -AzureMonitorWorkspaceLogs = new MonitorWorkspaceLogsExporter(new MonitorWorkspaceLogsApiConfig(new Uri("https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com"),"Custom-MyTableRawData_CL","dcr-00000000000000000000000000000000",new MonitorWorkspaceLogsSchemaMap(new MonitorWorkspaceLogsRecordMap[] -{ -new MonitorWorkspaceLogsRecordMap("body","Body"),new MonitorWorkspaceLogsRecordMap("severity_text","SeverityText"),new MonitorWorkspaceLogsRecordMap("time_unix_nano","TimeGenerated") +new MonitorWorkspaceLogsRecordMap("body", "Body"), +new MonitorWorkspaceLogsRecordMap("severity_text", "SeverityText"), +new MonitorWorkspaceLogsRecordMap("time_unix_nano", "TimeGenerated") }))) { -Concurrency = new MonitorWorkspaceLogsExporterConcurrencyConfiguration() +Concurrency = new MonitorWorkspaceLogsExporterConcurrencyConfiguration { WorkerCount = 4, BatchQueueSize = 100, }, }, -} -}, +}}, Service = new PipelineGroupService(new PipelineGroupServicePipeline[] { -new PipelineGroupServicePipeline("MyPipelineForLogs1",PipelineGroupServicePipelineType.Logs,new string[] -{ -"syslog-receiver1" -},new string[] -{ -"my-workspace-logs-exporter1" -}) -{ -Processors = +new PipelineGroupServicePipeline("MyPipelineForLogs1", PipelineGroupServicePipelineType.Logs, new string[]{"syslog-receiver1"}, new string[]{"my-workspace-logs-exporter1"}) { -}, +Processors = {}, } }), - NetworkingConfigurations = -{ -new PipelineGroupNetworkingConfiguration(PipelineGroupExternalNetworkingMode.LoadBalancerOnly,new PipelineGroupNetworkingRoute[] + NetworkingConfigurations = {new PipelineGroupNetworkingConfiguration(PipelineGroupExternalNetworkingMode.LoadBalancerOnly, new PipelineGroupNetworkingRoute[] { new PipelineGroupNetworkingRoute("syslog-receiver1") }) { Host = "azuremonitorpipeline.contoso.com", -} -}, +}}, Tags = { ["tag1"] = "A", -["tag2"] = "B", +["tag2"] = "B" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, pipelineGroupName, data); @@ -529,5 +328,143 @@ public async Task CreateOrUpdate_CreateAPipelineGroupInstanceUsingASyslogReceive // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_RetrievesAPipelineGroupInstanceByName() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupGet.json + // this example is just showing the usage of "PipelineGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PipelineGroupResource + PipelineGroupCollection collection = resourceGroupResource.GetPipelineGroups(); + + // invoke the operation + string pipelineGroupName = "plGroup1"; + PipelineGroupResource result = await collection.GetAsync(pipelineGroupName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PipelineGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListPipelineGroupsByResourceGroup() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupListByResourceGroup.json + // this example is just showing the usage of "PipelineGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PipelineGroupResource + PipelineGroupCollection collection = resourceGroupResource.GetPipelineGroups(); + + // invoke the operation and iterate over the result + await foreach (PipelineGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PipelineGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_RetrievesAPipelineGroupInstanceByName() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupGet.json + // this example is just showing the usage of "PipelineGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PipelineGroupResource + PipelineGroupCollection collection = resourceGroupResource.GetPipelineGroups(); + + // invoke the operation + string pipelineGroupName = "plGroup1"; + bool result = await collection.ExistsAsync(pipelineGroupName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_RetrievesAPipelineGroupInstanceByName() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupGet.json + // this example is just showing the usage of "PipelineGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this PipelineGroupResource + PipelineGroupCollection collection = resourceGroupResource.GetPipelineGroups(); + + // invoke the operation + string pipelineGroupName = "plGroup1"; + NullableResponse response = await collection.GetIfExistsAsync(pipelineGroupName); + PipelineGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PipelineGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_PipelineGroupResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_PipelineGroupResource.cs index 54e315102411f..bc941d4ad4b56 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_PipelineGroupResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_PipelineGroupResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples @@ -19,41 +18,40 @@ public partial class Sample_PipelineGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetPipelineGroups_ListPipelineGroupsBySubscription() + public async Task Get_RetrievesAPipelineGroupInstanceByName() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupListBySubscription.json - // this example is just showing the usage of "PipelineGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupGet.json + // this example is just showing the usage of "PipelineGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this PipelineGroupResource created on azure + // for more information of creating PipelineGroupResource, please refer to the document of PipelineGroupResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "myResourceGroup"; + string pipelineGroupName = "plGroup1"; + ResourceIdentifier pipelineGroupResourceId = PipelineGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, pipelineGroupName); + PipelineGroupResource pipelineGroup = client.GetPipelineGroupResource(pipelineGroupResourceId); - // invoke the operation and iterate over the result - await foreach (PipelineGroupResource item in subscriptionResource.GetPipelineGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PipelineGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + PipelineGroupResource result = await pipelineGroup.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PipelineGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RetrievesAPipelineGroupInstanceByName() + public async Task Delete_DeletesAPipelineGroupInstance() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupGet.json - // this example is just showing the usage of "PipelineGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupDelete.json + // this example is just showing the usage of "PipelineGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,13 +67,9 @@ public async Task Get_RetrievesAPipelineGroupInstanceByName() PipelineGroupResource pipelineGroup = client.GetPipelineGroupResource(pipelineGroupResourceId); // invoke the operation - PipelineGroupResource result = await pipelineGroup.GetAsync(); + await pipelineGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PipelineGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,54 +93,40 @@ public async Task Update_UpdatesAPipelineGroupInstance() PipelineGroupResource pipelineGroup = client.GetPipelineGroupResource(pipelineGroupResourceId); // invoke the operation - PipelineGroupPatch patch = new PipelineGroupPatch() + PipelineGroupPatch patch = new PipelineGroupPatch { Tags = { ["tag1"] = "A", -["tag2"] = "B", +["tag2"] = "B" }, Replicas = 3, - Receivers = -{ -new PipelineGroupReceiver(PipelineGroupReceiverType.Syslog,"syslog-receiver1") + Receivers = {new PipelineGroupReceiver(PipelineGroupReceiverType.Syslog, "syslog-receiver1") { Syslog = new SyslogReceiver("0.0.0.0:514"), -} -}, - Processors = +}}, + Processors = { }, + Exporters = {new PipelineGroupExporter(PipelineGroupExporterType.AzureMonitorWorkspaceLogs, "my-workspace-logs-exporter1") { -}, - Exporters = -{ -new PipelineGroupExporter(PipelineGroupExporterType.AzureMonitorWorkspaceLogs,"my-workspace-logs-exporter1") -{ -AzureMonitorWorkspaceLogs = new MonitorWorkspaceLogsExporter(new MonitorWorkspaceLogsApiConfig(new Uri("https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com"),"Custom-MyTableRawData_CL","dcr-00000000000000000000000000000000",new MonitorWorkspaceLogsSchemaMap(new MonitorWorkspaceLogsRecordMap[] +AzureMonitorWorkspaceLogs = new MonitorWorkspaceLogsExporter(new MonitorWorkspaceLogsApiConfig(new Uri("https://logs-myingestion-eb0s.eastus-1.ingest.monitor.azure.com"), "Custom-MyTableRawData_CL", "dcr-00000000000000000000000000000000", new MonitorWorkspaceLogsSchemaMap(new MonitorWorkspaceLogsRecordMap[] { -new MonitorWorkspaceLogsRecordMap("body","Body"),new MonitorWorkspaceLogsRecordMap("severity_text","SeverityText"),new MonitorWorkspaceLogsRecordMap("time_unix_nano","TimeGenerated") +new MonitorWorkspaceLogsRecordMap("body", "Body"), +new MonitorWorkspaceLogsRecordMap("severity_text", "SeverityText"), +new MonitorWorkspaceLogsRecordMap("time_unix_nano", "TimeGenerated") }))) { -Concurrency = new MonitorWorkspaceLogsExporterConcurrencyConfiguration() +Concurrency = new MonitorWorkspaceLogsExporterConcurrencyConfiguration { WorkerCount = 4, BatchQueueSize = 100, }, }, -} -}, +}}, Service = new PipelineGroupService(new PipelineGroupServicePipeline[] { -new PipelineGroupServicePipeline("MyPipelineForLogs1",PipelineGroupServicePipelineType.Logs,new string[] +new PipelineGroupServicePipeline("MyPipelineForLogs1", PipelineGroupServicePipelineType.Logs, new string[]{"syslog-receiver1"}, new string[]{"my-workspace-logs-exporter1"}) { -"syslog-receiver1" -},new string[] -{ -"my-workspace-logs-exporter1" -}) -{ -Processors = -{ -}, +Processors = {}, } }), }; @@ -159,31 +139,5 @@ public async Task Update_UpdatesAPipelineGroupInstance() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAPipelineGroupInstance() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupDelete.json - // this example is just showing the usage of "PipelineGroups_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this PipelineGroupResource created on azure - // for more information of creating PipelineGroupResource, please refer to the document of PipelineGroupResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - string pipelineGroupName = "plGroup1"; - ResourceIdentifier pipelineGroupResourceId = PipelineGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, pipelineGroupName); - PipelineGroupResource pipelineGroup = client.GetPipelineGroupResource(pipelineGroupResourceId); - - // invoke the operation - await pipelineGroup.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ScheduledQueryRuleCollection.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ScheduledQueryRuleCollection.cs index 580d2b725d424..160eb9b343603 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ScheduledQueryRuleCollection.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ScheduledQueryRuleCollection.cs @@ -18,144 +18,6 @@ namespace Azure.ResourceManager.Monitor.Samples { public partial class Sample_ScheduledQueryRuleCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListScheduledQueryRulesByResourceGroup() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/listScheduledQueryRulesByResourceGroup.json - // this example is just showing the usage of "ScheduledQueryRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "dd4bfc94-a096-412b-9c43-4bd13e35afbc"; - string resourceGroupName = "QueryResourceGroupName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ScheduledQueryRuleResource - ScheduledQueryRuleCollection collection = resourceGroupResource.GetScheduledQueryRules(); - - // invoke the operation and iterate over the result - await foreach (ScheduledQueryRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScheduledQueryRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAScheduledQueryRuleForSingleResource() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/getScheduledQueryRule.json - // this example is just showing the usage of "ScheduledQueryRules_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "dd4bfc94-a096-412b-9c43-4bd13e35afbc"; - string resourceGroupName = "QueryResourceGroupName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ScheduledQueryRuleResource - ScheduledQueryRuleCollection collection = resourceGroupResource.GetScheduledQueryRules(); - - // invoke the operation - string ruleName = "perf"; - ScheduledQueryRuleResource result = await collection.GetAsync(ruleName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScheduledQueryRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAScheduledQueryRuleForSingleResource() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/getScheduledQueryRule.json - // this example is just showing the usage of "ScheduledQueryRules_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "dd4bfc94-a096-412b-9c43-4bd13e35afbc"; - string resourceGroupName = "QueryResourceGroupName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ScheduledQueryRuleResource - ScheduledQueryRuleCollection collection = resourceGroupResource.GetScheduledQueryRules(); - - // invoke the operation - string ruleName = "perf"; - bool result = await collection.ExistsAsync(ruleName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAScheduledQueryRuleForSingleResource() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/getScheduledQueryRule.json - // this example is just showing the usage of "ScheduledQueryRules_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "dd4bfc94-a096-412b-9c43-4bd13e35afbc"; - string resourceGroupName = "QueryResourceGroupName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ScheduledQueryRuleResource - ScheduledQueryRuleCollection collection = resourceGroupResource.GetScheduledQueryRules(); - - // invoke the operation - string ruleName = "perf"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - ScheduledQueryRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScheduledQueryRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateOrUpdateAScheduledQueryRuleForSingleResource() @@ -185,50 +47,32 @@ public async Task CreateOrUpdate_CreateOrUpdateAScheduledQueryRuleForSingleResou Description = "Performance rule", Severity = AlertSeverity.Four, IsEnabled = true, - Scopes = -{ -"/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1/providers/Microsoft.Compute/virtualMachines/vm1" -}, + Scopes = { "/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1/providers/Microsoft.Compute/virtualMachines/vm1" }, EvaluationFrequency = XmlConvert.ToTimeSpan("PT5M"), WindowSize = XmlConvert.ToTimeSpan("PT10M"), - CriteriaAllOf = -{ -new ScheduledQueryRuleCondition() + CriteriaAllOf = {new ScheduledQueryRuleCondition { Query = "Perf | where ObjectName == \"Processor\"", TimeAggregation = ScheduledQueryRuleTimeAggregationType.Average, MetricMeasureColumn = "% Processor Time", ResourceIdColumn = "resourceId", -Dimensions = -{ -new MonitorDimension("ComputerIp",MonitorDimensionOperator.Exclude,new string[] -{ -"192.168.1.1" -}),new MonitorDimension("OSType",MonitorDimensionOperator.Include,new string[] -{ -"*" -}) -}, +Dimensions = {new MonitorDimension("ComputerIp", MonitorDimensionOperator.Exclude, new string[]{"192.168.1.1"}), new MonitorDimension("OSType", MonitorDimensionOperator.Include, new string[]{"*"})}, Operator = MonitorConditionOperator.GreaterThan, Threshold = 70, -FailingPeriods = new ConditionFailingPeriods() +FailingPeriods = new ConditionFailingPeriods { NumberOfEvaluationPeriods = 1L, MinFailingPeriodsToAlert = 1L, }, -} -}, +}}, MuteActionsDuration = XmlConvert.ToTimeSpan("PT30M"), - Actions = new ScheduledQueryRuleActions() + Actions = new ScheduledQueryRuleActions { - ActionGroups = -{ -"/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup" -}, + ActionGroups = { "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup" }, CustomProperties = { ["key11"] = "value11", -["key12"] = "value12", +["key12"] = "value12" }, }, CheckWorkspaceAlertsStorageConfigured = true, @@ -274,45 +118,31 @@ public async Task CreateOrUpdate_CreateOrUpdateAScheduledQueryRuleOnResourceGrou Description = "Health check rule", Severity = AlertSeverity.Four, IsEnabled = true, - Scopes = -{ -"/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1" -}, + Scopes = { "/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147/resourceGroups/scopeResourceGroup1" }, EvaluationFrequency = XmlConvert.ToTimeSpan("PT5M"), WindowSize = XmlConvert.ToTimeSpan("PT10M"), - TargetResourceTypes = -{ -"Microsoft.Compute/virtualMachines" -}, - CriteriaAllOf = -{ -new ScheduledQueryRuleCondition() + TargetResourceTypes = { "Microsoft.Compute/virtualMachines" }, + CriteriaAllOf = {new ScheduledQueryRuleCondition { Query = "Heartbeat", TimeAggregation = ScheduledQueryRuleTimeAggregationType.Count, -Dimensions = -{ -}, +Dimensions = {}, Operator = MonitorConditionOperator.GreaterThan, Threshold = 360, -FailingPeriods = new ConditionFailingPeriods() +FailingPeriods = new ConditionFailingPeriods { NumberOfEvaluationPeriods = 1L, MinFailingPeriodsToAlert = 1L, }, -} -}, +}}, MuteActionsDuration = XmlConvert.ToTimeSpan("PT30M"), - Actions = new ScheduledQueryRuleActions() + Actions = new ScheduledQueryRuleActions { - ActionGroups = -{ -"/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup" -}, + ActionGroups = { "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup" }, CustomProperties = { ["key11"] = "value11", -["key12"] = "value12", +["key12"] = "value12" }, }, CheckWorkspaceAlertsStorageConfigured = true, @@ -358,54 +188,33 @@ public async Task CreateOrUpdate_CreateOrUpdateAScheduledQueryRuleOnSubscription Description = "Performance rule", Severity = AlertSeverity.Four, IsEnabled = true, - Scopes = -{ -"/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147" -}, + Scopes = { "/subscriptions/aaf177ed-1330-a9f2-80ea-fd3d7783b147" }, EvaluationFrequency = XmlConvert.ToTimeSpan("PT5M"), WindowSize = XmlConvert.ToTimeSpan("PT10M"), - TargetResourceTypes = -{ -"Microsoft.Compute/virtualMachines" -}, - CriteriaAllOf = -{ -new ScheduledQueryRuleCondition() + TargetResourceTypes = { "Microsoft.Compute/virtualMachines" }, + CriteriaAllOf = {new ScheduledQueryRuleCondition { Query = "Perf | where ObjectName == \"Processor\"", TimeAggregation = ScheduledQueryRuleTimeAggregationType.Average, MetricMeasureColumn = "% Processor Time", ResourceIdColumn = "resourceId", -Dimensions = -{ -new MonitorDimension("ComputerIp",MonitorDimensionOperator.Exclude,new string[] -{ -"192.168.1.1" -}),new MonitorDimension("OSType",MonitorDimensionOperator.Include,new string[] -{ -"*" -}) -}, +Dimensions = {new MonitorDimension("ComputerIp", MonitorDimensionOperator.Exclude, new string[]{"192.168.1.1"}), new MonitorDimension("OSType", MonitorDimensionOperator.Include, new string[]{"*"})}, Operator = MonitorConditionOperator.GreaterThan, Threshold = 70, -FailingPeriods = new ConditionFailingPeriods() +FailingPeriods = new ConditionFailingPeriods { NumberOfEvaluationPeriods = 1L, MinFailingPeriodsToAlert = 1L, }, -} -}, +}}, MuteActionsDuration = XmlConvert.ToTimeSpan("PT30M"), - Actions = new ScheduledQueryRuleActions() + Actions = new ScheduledQueryRuleActions { - ActionGroups = -{ -"/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup" -}, + ActionGroups = { "/subscriptions/1cf177ed-1330-4692-80ea-fd3d7783b147/resourcegroups/sqrapi/providers/microsoft.insights/actiongroups/myactiongroup" }, CustomProperties = { ["key11"] = "value11", -["key12"] = "value12", +["key12"] = "value12" }, }, CheckWorkspaceAlertsStorageConfigured = true, @@ -421,5 +230,143 @@ public async Task CreateOrUpdate_CreateOrUpdateAScheduledQueryRuleOnSubscription // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetAScheduledQueryRuleForSingleResource() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/getScheduledQueryRule.json + // this example is just showing the usage of "ScheduledQueryRules_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "dd4bfc94-a096-412b-9c43-4bd13e35afbc"; + string resourceGroupName = "QueryResourceGroupName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ScheduledQueryRuleResource + ScheduledQueryRuleCollection collection = resourceGroupResource.GetScheduledQueryRules(); + + // invoke the operation + string ruleName = "perf"; + ScheduledQueryRuleResource result = await collection.GetAsync(ruleName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScheduledQueryRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListScheduledQueryRulesByResourceGroup() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/listScheduledQueryRulesByResourceGroup.json + // this example is just showing the usage of "ScheduledQueryRules_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "dd4bfc94-a096-412b-9c43-4bd13e35afbc"; + string resourceGroupName = "QueryResourceGroupName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ScheduledQueryRuleResource + ScheduledQueryRuleCollection collection = resourceGroupResource.GetScheduledQueryRules(); + + // invoke the operation and iterate over the result + await foreach (ScheduledQueryRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScheduledQueryRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetAScheduledQueryRuleForSingleResource() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/getScheduledQueryRule.json + // this example is just showing the usage of "ScheduledQueryRules_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "dd4bfc94-a096-412b-9c43-4bd13e35afbc"; + string resourceGroupName = "QueryResourceGroupName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ScheduledQueryRuleResource + ScheduledQueryRuleCollection collection = resourceGroupResource.GetScheduledQueryRules(); + + // invoke the operation + string ruleName = "perf"; + bool result = await collection.ExistsAsync(ruleName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetAScheduledQueryRuleForSingleResource() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/getScheduledQueryRule.json + // this example is just showing the usage of "ScheduledQueryRules_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "dd4bfc94-a096-412b-9c43-4bd13e35afbc"; + string resourceGroupName = "QueryResourceGroupName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ScheduledQueryRuleResource + ScheduledQueryRuleCollection collection = resourceGroupResource.GetScheduledQueryRules(); + + // invoke the operation + string ruleName = "perf"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + ScheduledQueryRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScheduledQueryRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ScheduledQueryRuleResource.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ScheduledQueryRuleResource.cs index 9a9dba37f1b62..b7039fefa46e1 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ScheduledQueryRuleResource.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_ScheduledQueryRuleResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples { public partial class Sample_ScheduledQueryRuleResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetScheduledQueryRules_ListScheduledQueryRulesBySubscription() - { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/listScheduledQueryRulesBySubscription.json - // this example is just showing the usage of "ScheduledQueryRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "dd4bfc94-a096-412b-9c43-4bd13e35afbc"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ScheduledQueryRuleResource item in subscriptionResource.GetScheduledQueryRulesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScheduledQueryRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetAScheduledQueryRuleForSingleResource() @@ -80,10 +48,10 @@ public async Task Get_GetAScheduledQueryRuleForSingleResource() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAScheduledQueryRule() + public async Task Delete_DeleteAScheduledQueryRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/patchScheduledQueryRule.json - // this example is just showing the usage of "ScheduledQueryRules_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/deleteScheduledQueryRule.json + // this example is just showing the usage of "ScheduledQueryRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,25 +67,17 @@ public async Task Update_CreateOrUpdateAScheduledQueryRule() ScheduledQueryRuleResource scheduledQueryRule = client.GetScheduledQueryRuleResource(scheduledQueryRuleResourceId); // invoke the operation - ScheduledQueryRulePatch patch = new ScheduledQueryRulePatch() - { - IsEnabled = false, - }; - ScheduledQueryRuleResource result = await scheduledQueryRule.UpdateAsync(patch); + await scheduledQueryRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScheduledQueryRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAScheduledQueryRule() + public async Task Update_CreateOrUpdateAScheduledQueryRule() { - // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/deleteScheduledQueryRule.json - // this example is just showing the usage of "ScheduledQueryRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/patchScheduledQueryRule.json + // this example is just showing the usage of "ScheduledQueryRules_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,9 +93,17 @@ public async Task Delete_DeleteAScheduledQueryRule() ScheduledQueryRuleResource scheduledQueryRule = client.GetScheduledQueryRuleResource(scheduledQueryRuleResourceId); // invoke the operation - await scheduledQueryRule.DeleteAsync(WaitUntil.Completed); + ScheduledQueryRulePatch patch = new ScheduledQueryRulePatch + { + IsEnabled = false, + }; + ScheduledQueryRuleResource result = await scheduledQueryRule.UpdateAsync(patch); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScheduledQueryRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 8e82e880b9a28..f12fdfa2b2415 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -18,6 +18,99 @@ namespace Azure.ResourceManager.Monitor.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAutoscaleSettings_ListAutoscaleSettingsBySubs() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-10-01/examples/listAutoscaleSettingBySubscription.json + // this example is just showing the usage of "AutoscaleSettings_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AutoscaleSettingResource item in subscriptionResource.GetAutoscaleSettingsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AutoscaleSettingData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAlertRules_ListAlertRules() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/listAlertRuleBySubscription.json + // this example is just showing the usage of "AlertRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "b67f7fec-69fc-4974-9099-a26bd6ffeda3"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (AlertRuleResource item in subscriptionResource.GetAlertRulesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AlertRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetActionGroups_ListActionGroupsAtSubscriptionLevel() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2023-01-01/examples/listActionGroups.json + // this example is just showing the usage of "ActionGroups_ListBySubscriptionId" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "187f412d-1758-44d9-b052-169e2564721d"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ActionGroupResource item in subscriptionResource.GetActionGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ActionGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetActivityLogs_GetActivityLogsWithFilter() @@ -94,7 +187,8 @@ public async Task GetMonitorMetrics_GetSubscriptionLevelMetricData() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - SubscriptionResourceGetMonitorMetricsOptions options = new SubscriptionResourceGetMonitorMetricsOptions(region: "westus2") { Timespan = "2021-06-08T19:00:00Z/2021-06-12T01:00:00Z", Interval = XmlConvert.ToTimeSpan("PT6H"), Metricnames = "Data Disk Max Burst IOPS", Aggregation = "count", Top = 10, Orderby = "count desc", Filter = "LUN eq '0' and Microsoft.ResourceId eq '*'", Metricnamespace = "microsoft.compute/virtualmachines", AutoAdjustTimegrain = true, ValidateDimensions = false }; + string region = "westus2"; + SubscriptionResourceGetMonitorMetricsOptions options = new SubscriptionResourceGetMonitorMetricsOptions(region) { Timespan = "2021-06-08T19:00:00Z/2021-06-12T01:00:00Z", Interval = XmlConvert.ToTimeSpan("PT6H"), Metricnames = "Data Disk Max Burst IOPS", Aggregation = "count", Top = 10, Orderby = "count desc", Filter = "LUN eq '0' and Microsoft.ResourceId eq '*'", Metricnamespace = "microsoft.compute/virtualmachines", AutoAdjustTimegrain = true, ValidateDimensions = false }; await foreach (SubscriptionMonitorMetric item in subscriptionResource.GetMonitorMetricsAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -122,7 +216,8 @@ public async Task GetMonitorMetrics_GetSubscriptionLevelMetricMetadata() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - SubscriptionResourceGetMonitorMetricsOptions options = new SubscriptionResourceGetMonitorMetricsOptions(region: "westus2") { Timespan = "2021-06-10T02:23:16.129Z/2021-06-12T02:23:16.129Z", Metricnames = "Data Disk Max Burst IOPS", Filter = "LUN eq '0'", Metricnamespace = "microsoft.compute/virtualmachines" }; + string region = "westus2"; + SubscriptionResourceGetMonitorMetricsOptions options = new SubscriptionResourceGetMonitorMetricsOptions(region) { Timespan = "2021-06-10T02:23:16.129Z/2021-06-12T02:23:16.129Z", Metricnames = "Data Disk Max Burst IOPS", Filter = "LUN eq '0'", Metricnamespace = "microsoft.compute/virtualmachines" }; await foreach (SubscriptionMonitorMetric item in subscriptionResource.GetMonitorMetricsAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -150,7 +245,8 @@ public async Task GetMonitorMetricsWithPost_PostRequestForSubscriptionLevelMetri SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - SubscriptionResourceGetMonitorMetricsWithPostOptions options = new SubscriptionResourceGetMonitorMetricsWithPostOptions(region: "westus2") { Timespan = "2021-06-08T19:00:00Z/2021-06-12T01:00:00Z", Interval = XmlConvert.ToTimeSpan("PT6H"), Metricnames = "Data Disk Max Burst IOPS", Aggregation = "count", Top = 10, Orderby = "count desc", Filter = "LUN eq '0' and Microsoft.ResourceId eq '*'", Metricnamespace = "microsoft.compute/virtualmachines", AutoAdjustTimegrain = true, ValidateDimensions = false }; + string region = "westus2"; + SubscriptionResourceGetMonitorMetricsWithPostOptions options = new SubscriptionResourceGetMonitorMetricsWithPostOptions(region) { Timespan = "2021-06-08T19:00:00Z/2021-06-12T01:00:00Z", Interval = XmlConvert.ToTimeSpan("PT6H"), Metricnames = "Data Disk Max Burst IOPS", Aggregation = "count", Top = 10, Orderby = "count desc", Filter = "LUN eq '0' and Microsoft.ResourceId eq '*'", Metricnamespace = "microsoft.compute/virtualmachines", AutoAdjustTimegrain = true, ValidateDimensions = false }; await foreach (SubscriptionMonitorMetric item in subscriptionResource.GetMonitorMetricsWithPostAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -178,11 +274,12 @@ public async Task GetMonitorMetricsWithPost_PostRequestForSubscriptionLevelMetri SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - SubscriptionResourceGetMonitorMetricsWithPostOptions options = new SubscriptionResourceGetMonitorMetricsWithPostOptions(region: "westus2") + string region = "westus2"; + SubscriptionResourceGetMonitorMetricsWithPostOptions options = new SubscriptionResourceGetMonitorMetricsWithPostOptions(region) { - Content = new SubscriptionResourceGetMonitorMetricsWithPostContent() + Content = new SubscriptionResourceGetMonitorMetricsWithPostContent { - Timespan = TimeSpan.Parse("2021-06-08T19:00:00Z/2021-06-12T01:00:00Z"), + Timespan = XmlConvert.ToTimeSpan("2021-06-08T19:00:00Z/2021-06-12T01:00:00Z"), Interval = XmlConvert.ToTimeSpan("PT6H"), MetricNames = "Data Disk Max Burst IOPS", Aggregation = "count", @@ -222,7 +319,8 @@ public async Task GetMonitorMetricsWithPost_PostRequestForSubscriptionLevelMetri SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - SubscriptionResourceGetMonitorMetricsWithPostOptions options = new SubscriptionResourceGetMonitorMetricsWithPostOptions(region: "westus2") { Timespan = "2021-06-10T02:23:16.129Z/2021-06-12T02:23:16.129Z", Metricnames = "Data Disk Max Burst IOPS", Filter = "LUN eq '0'", Metricnamespace = "microsoft.compute/virtualmachines" }; + string region = "westus2"; + SubscriptionResourceGetMonitorMetricsWithPostOptions options = new SubscriptionResourceGetMonitorMetricsWithPostOptions(region) { Timespan = "2021-06-10T02:23:16.129Z/2021-06-12T02:23:16.129Z", Metricnames = "Data Disk Max Burst IOPS", Filter = "LUN eq '0'", Metricnamespace = "microsoft.compute/virtualmachines" }; await foreach (SubscriptionMonitorMetric item in subscriptionResource.GetMonitorMetricsWithPostAsync(options)) { Console.WriteLine($"Succeeded: {item}"); @@ -230,5 +328,253 @@ public async Task GetMonitorMetricsWithPost_PostRequestForSubscriptionLevelMetri Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMetricAlerts_ListMetricAlertRules() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2018-03-01/examples/listMetricAlert.json + // this example is just showing the usage of "MetricAlerts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "14ddf0c5-77c5-4b53-84f6-e1fa43ad68f7"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MetricAlertResource item in subscriptionResource.GetMetricAlertsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MetricAlertData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetScheduledQueryRules_ListScheduledQueryRulesBySubscription() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-15/examples/listScheduledQueryRulesBySubscription.json + // this example is just showing the usage of "ScheduledQueryRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "dd4bfc94-a096-412b-9c43-4bd13e35afbc"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ScheduledQueryRuleResource item in subscriptionResource.GetScheduledQueryRulesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScheduledQueryRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMonitorPrivateLinkScopes_PrivateLinkScopesListJson() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/preview/2021-07-01-preview/examples/PrivateLinkScopesList.json + // this example is just showing the usage of "PrivateLinkScopes_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "86dc51d3-92ed-4d7e-947a-775ea79b4919"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MonitorPrivateLinkScopeResource item in subscriptionResource.GetMonitorPrivateLinkScopesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorPrivateLinkScopeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetActivityLogAlerts_GetListOfAllActivityLogAlertRulesUnderASubscription() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2020-10-01/examples/ActivityLogAlertRule_ListBySubscriptionId.json + // this example is just showing the usage of "ActivityLogAlerts_ListBySubscriptionId" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "187f412d-1758-44d9-b052-169e2564721d"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ActivityLogAlertResource item in subscriptionResource.GetActivityLogAlertsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ActivityLogAlertData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataCollectionEndpoints_ListDataCollectionEndpointsBySubscription() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionEndpointsListBySubscription.json + // this example is just showing the usage of "DataCollectionEndpoints_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "703362b3-f278-4e4b-9179-c76eaf41ffc2"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataCollectionEndpointResource item in subscriptionResource.GetDataCollectionEndpointsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetDataCollectionRules_ListDataCollectionRulesBySubscription() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2022-06-01/examples/DataCollectionRulesListBySubscription.json + // this example is just showing the usage of "DataCollectionRules_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "703362b3-f278-4e4b-9179-c76eaf41ffc2"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (DataCollectionRuleResource item in subscriptionResource.GetDataCollectionRulesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DataCollectionRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMonitorWorkspaceResources_ListAzureMonitorWorkspacesBySubscription() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/AzureMonitorWorkspacesListBySubscription.json + // this example is just showing the usage of "AzureMonitorWorkspaces_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "703362b3-f278-4e4b-9179-c76eaf41ffc2"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MonitorWorkspaceResource item in subscriptionResource.GetMonitorWorkspaceResourcesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MonitorWorkspaceResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPipelineGroups_ListPipelineGroupsBySubscription() + { + // Generated from example definition: specification/monitor/resource-manager/Microsoft.Monitor/preview/2023-10-01-preview/examples/PipelineGroupListBySubscription.json + // this example is just showing the usage of "PipelineGroups_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PipelineGroupResource item in subscriptionResource.GetPipelineGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PipelineGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index f1445d3e32709..4adc820413c7f 100644 --- a/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/monitor/Azure.ResourceManager.Monitor/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Monitor.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Monitor.Samples @@ -28,9 +29,7 @@ public async Task GetEventCategories_GetEventCategories() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (MonitorLocalizableString item in tenantResource.GetEventCategoriesAsync()) @@ -53,9 +52,7 @@ public async Task GetTenantActivityLogs_GetTenantActivityLogsWithFilter() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result string filter = "eventTimestamp ge '2015-01-21T20:00:00Z' and eventTimestamp le '2015-01-23T20:00:00Z' and resourceGroupName eq 'MSSupportGroup'"; @@ -79,9 +76,7 @@ public async Task GetTenantActivityLogs_GetTenantActivityLogsWithFilterAndSelect // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result string filter = "eventTimestamp ge '2015-01-21T20:00:00Z' and eventTimestamp le '2015-01-23T20:00:00Z' and resourceGroupName eq 'MSSupportGroup'"; @@ -106,9 +101,7 @@ public async Task GetTenantActivityLogs_GetTenantActivityLogsWithSelect() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result string select = "eventName,id,resourceGroupName,resourceProviderName,operationName,status,eventTimestamp,correlationId,submissionTimestamp,level"; @@ -132,9 +125,7 @@ public async Task GetTenantActivityLogs_GetTenantActivityLogsWithoutFilterOrSele // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation and iterate over the result await foreach (EventDataInfo item in tenantResource.GetTenantActivityLogsAsync()) diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_AdvancedThreatProtectionCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_AdvancedThreatProtectionCollection.cs index 2ad590494ffba..17ea8713374e9 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_AdvancedThreatProtectionCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_AdvancedThreatProtectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AdvancedThreatProtectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_DisableAServerSAdvancedThreatProtectionSettingsWithAllParametersUsingPUT() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsGet.json - // this example is just showing the usage of "AdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsPutDisabled.json + // this example is just showing the usage of "AdvancedThreatProtectionSettings_UpdatePut" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,8 +31,8 @@ public async Task Get_GetAServerSAdvancedThreatProtectionSettings() // this example assumes you already have this MySqlFlexibleServerResource created on azure // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-6852"; - string serverName = "threatprotection-2080"; + string resourceGroupName = "threatprotection-4799"; + string serverName = "threatprotection-6440"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); @@ -41,7 +41,12 @@ public async Task Get_GetAServerSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - AdvancedThreatProtectionResource result = await collection.GetAsync(advancedThreatProtectionName); + AdvancedThreatProtectionData data = new AdvancedThreatProtectionData + { + State = AdvancedThreatProtectionState.Disabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); + AdvancedThreatProtectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +57,10 @@ public async Task Get_GetAServerSAdvancedThreatProtectionSettings() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerSAdvancedThreatProtectionSettings() + public async Task CreateOrUpdate_EnableAServerSAdvancedThreatProtectionSettingsUsingPUT() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsGet.json - // this example is just showing the usage of "AdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsPutEnabled.json + // this example is just showing the usage of "AdvancedThreatProtectionSettings_UpdatePut" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,8 +70,8 @@ public async Task Exists_GetAServerSAdvancedThreatProtectionSettings() // this example assumes you already have this MySqlFlexibleServerResource created on azure // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-6852"; - string serverName = "threatprotection-2080"; + string resourceGroupName = "threatprotection-4799"; + string serverName = "threatprotection-6440"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); @@ -75,14 +80,23 @@ public async Task Exists_GetAServerSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - bool result = await collection.ExistsAsync(advancedThreatProtectionName); + AdvancedThreatProtectionData data = new AdvancedThreatProtectionData + { + State = AdvancedThreatProtectionState.Enabled, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); + AdvancedThreatProtectionResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerSAdvancedThreatProtectionSettings() + public async Task Get_GetAServerSAdvancedThreatProtectionSettings() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsGet.json // this example is just showing the usage of "AdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +119,21 @@ public async Task GetIfExists_GetAServerSAdvancedThreatProtectionSettings() // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - NullableResponse response = await collection.GetIfExistsAsync(advancedThreatProtectionName); - AdvancedThreatProtectionResource result = response.HasValue ? response.Value : null; + AdvancedThreatProtectionResource result = await collection.GetAsync(advancedThreatProtectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdvancedThreatProtectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_DisableAServerSAdvancedThreatProtectionSettingsWithAllParametersUsingPUT() + public async Task GetAll_GetListOfServerSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsPutDisabled.json - // this example is just showing the usage of "AdvancedThreatProtectionSettings_UpdatePut" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsList.json + // this example is just showing the usage of "AdvancedThreatProtectionSettings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,36 +143,33 @@ public async Task CreateOrUpdate_DisableAServerSAdvancedThreatProtectionSettings // this example assumes you already have this MySqlFlexibleServerResource created on azure // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-4799"; - string serverName = "threatprotection-6440"; + string resourceGroupName = "threatprotection-6852"; + string serverName = "threatprotection-2080"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // get the collection of this AdvancedThreatProtectionResource AdvancedThreatProtectionCollection collection = mySqlFlexibleServer.GetAdvancedThreatProtections(); - // invoke the operation - AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - AdvancedThreatProtectionData data = new AdvancedThreatProtectionData() + // invoke the operation and iterate over the result + await foreach (AdvancedThreatProtectionResource item in collection.GetAllAsync()) { - State = AdvancedThreatProtectionState.Disabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); - AdvancedThreatProtectionResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdvancedThreatProtectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_EnableAServerSAdvancedThreatProtectionSettingsUsingPUT() + public async Task Exists_GetAServerSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsPutEnabled.json - // this example is just showing the usage of "AdvancedThreatProtectionSettings_UpdatePut" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsGet.json + // this example is just showing the usage of "AdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,8 +179,8 @@ public async Task CreateOrUpdate_EnableAServerSAdvancedThreatProtectionSettingsU // this example assumes you already have this MySqlFlexibleServerResource created on azure // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "00000000-1111-2222-3333-444444444444"; - string resourceGroupName = "threatprotection-4799"; - string serverName = "threatprotection-6440"; + string resourceGroupName = "threatprotection-6852"; + string serverName = "threatprotection-2080"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); @@ -186,26 +189,17 @@ public async Task CreateOrUpdate_EnableAServerSAdvancedThreatProtectionSettingsU // invoke the operation AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; - AdvancedThreatProtectionData data = new AdvancedThreatProtectionData() - { - State = AdvancedThreatProtectionState.Enabled, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, advancedThreatProtectionName, data); - AdvancedThreatProtectionResource result = lro.Value; + bool result = await collection.ExistsAsync(advancedThreatProtectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdvancedThreatProtectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetListOfServerSAdvancedThreatProtectionSettings() + public async Task GetIfExists_GetAServerSAdvancedThreatProtectionSettings() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsList.json - // this example is just showing the usage of "AdvancedThreatProtectionSettings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/AdvancedThreatProtectionSettingsGet.json + // this example is just showing the usage of "AdvancedThreatProtectionSettings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -223,17 +217,23 @@ public async Task GetAll_GetListOfServerSAdvancedThreatProtectionSettings() // get the collection of this AdvancedThreatProtectionResource AdvancedThreatProtectionCollection collection = mySqlFlexibleServer.GetAdvancedThreatProtections(); - // invoke the operation and iterate over the result - await foreach (AdvancedThreatProtectionResource item in collection.GetAllAsync()) + // invoke the operation + AdvancedThreatProtectionName advancedThreatProtectionName = AdvancedThreatProtectionName.Default; + NullableResponse response = await collection.GetIfExistsAsync(advancedThreatProtectionName); + AdvancedThreatProtectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AdvancedThreatProtectionData resourceData = item.Data; + AdvancedThreatProtectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_AdvancedThreatProtectionResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_AdvancedThreatProtectionResource.cs index 2618ba14650a3..23b70962a5510 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_AdvancedThreatProtectionResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_AdvancedThreatProtectionResource.cs @@ -69,7 +69,7 @@ public async Task Update_DisableAServerSAdvancedThreatProtectionSettingsWithAllP AdvancedThreatProtectionResource advancedThreatProtection = client.GetAdvancedThreatProtectionResource(advancedThreatProtectionResourceId); // invoke the operation - AdvancedThreatProtectionPatch patch = new AdvancedThreatProtectionPatch() + AdvancedThreatProtectionPatch patch = new AdvancedThreatProtectionPatch { State = AdvancedThreatProtectionState.Disabled, }; @@ -105,7 +105,7 @@ public async Task Update_EnableAServerSAdvancedThreatProtectionSettings() AdvancedThreatProtectionResource advancedThreatProtection = client.GetAdvancedThreatProtectionResource(advancedThreatProtectionResourceId); // invoke the operation - AdvancedThreatProtectionPatch patch = new AdvancedThreatProtectionPatch() + AdvancedThreatProtectionPatch patch = new AdvancedThreatProtectionPatch { State = AdvancedThreatProtectionState.Enabled, }; diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlAdvisorCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlAdvisorCollection.cs index 1caa70f6af440..89b0ec6c86ebc 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlAdvisorCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlAdvisorCollection.cs @@ -51,10 +51,10 @@ public async Task Get_AdvisorsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AdvisorsGet() + public async Task GetAll_AdvisorsListByServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/AdvisorsGet.json - // this example is just showing the usage of "Advisors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/AdvisorsListByServer.json + // this example is just showing the usage of "Advisors_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_AdvisorsGet() // get the collection of this MySqlAdvisorResource MySqlAdvisorCollection collection = mySqlServer.GetMySqlAdvisors(); - // invoke the operation - string advisorName = "Index"; - bool result = await collection.ExistsAsync(advisorName); + // invoke the operation and iterate over the result + await foreach (MySqlAdvisorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlAdvisorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AdvisorsGet() + public async Task Exists_AdvisorsGet() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/AdvisorsGet.json // this example is just showing the usage of "Advisors_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_AdvisorsGet() // invoke the operation string advisorName = "Index"; - NullableResponse response = await collection.GetIfExistsAsync(advisorName); - MySqlAdvisorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(advisorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlAdvisorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AdvisorsListByServer() + public async Task GetIfExists_AdvisorsGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/AdvisorsListByServer.json - // this example is just showing the usage of "Advisors_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/AdvisorsGet.json + // this example is just showing the usage of "Advisors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_AdvisorsListByServer() // get the collection of this MySqlAdvisorResource MySqlAdvisorCollection collection = mySqlServer.GetMySqlAdvisors(); - // invoke the operation and iterate over the result - await foreach (MySqlAdvisorResource item in collection.GetAllAsync()) + // invoke the operation + string advisorName = "Index"; + NullableResponse response = await collection.GetIfExistsAsync(advisorName); + MySqlAdvisorResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlAdvisorData resourceData = item.Data; + MySqlAdvisorData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlAdvisorResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlAdvisorResource.cs index de9b381b0dd3a..1208f145208e5 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlAdvisorResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlAdvisorResource.cs @@ -17,10 +17,10 @@ public partial class Sample_MySqlAdvisorResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateRecommendedActionSession_RecommendedActionSessionCreate() + public async Task Get_AdvisorsGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/RecommendedActionSessionCreate.json - // this example is just showing the usage of "CreateRecommendedActionSession" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/AdvisorsGet.json + // this example is just showing the usage of "Advisors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,18 +37,21 @@ public async Task CreateRecommendedActionSession_RecommendedActionSessionCreate( MySqlAdvisorResource mySqlAdvisor = client.GetMySqlAdvisorResource(mySqlAdvisorResourceId); // invoke the operation - string databaseName = "someDatabaseName"; - await mySqlAdvisor.CreateRecommendedActionSessionAsync(WaitUntil.Completed, databaseName); + MySqlAdvisorResource result = await mySqlAdvisor.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlAdvisorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AdvisorsGet() + public async Task CreateRecommendedActionSession_RecommendedActionSessionCreate() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/AdvisorsGet.json - // this example is just showing the usage of "Advisors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/RecommendedActionSessionCreate.json + // this example is just showing the usage of "CreateRecommendedActionSession" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +68,10 @@ public async Task Get_AdvisorsGet() MySqlAdvisorResource mySqlAdvisor = client.GetMySqlAdvisorResource(mySqlAdvisorResourceId); // invoke the operation - MySqlAdvisorResource result = await mySqlAdvisor.GetAsync(); + string databaseName = "someDatabaseName"; + await mySqlAdvisor.CreateRecommendedActionSessionAsync(WaitUntil.Completed, databaseName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlAdvisorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlConfigurationCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlConfigurationCollection.cs index f1af29e1fb03e..30d84cd9bd174 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlConfigurationCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlConfigurationCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_ConfigurationCreateOrUpdate() // invoke the operation string configurationName = "event_scheduler"; - MySqlConfigurationData data = new MySqlConfigurationData() + MySqlConfigurationData data = new MySqlConfigurationData { Value = "off", Source = "user-override", @@ -91,10 +91,10 @@ public async Task Get_ConfigurationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConfigurationGet() + public async Task GetAll_ConfigurationList() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ConfigurationGet.json - // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ConfigurationListByServer.json + // this example is just showing the usage of "Configurations_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,24 +104,30 @@ public async Task Exists_ConfigurationGet() // this example assumes you already have this MySqlServerResource created on azure // for more information of creating MySqlServerResource, please refer to the document of MySqlServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; + string resourceGroupName = "testrg"; + string serverName = "mysqltestsvc1"; ResourceIdentifier mySqlServerResourceId = MySqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlServerResource mySqlServer = client.GetMySqlServerResource(mySqlServerResourceId); // get the collection of this MySqlConfigurationResource MySqlConfigurationCollection collection = mySqlServer.GetMySqlConfigurations(); - // invoke the operation - string configurationName = "event_scheduler"; - bool result = await collection.ExistsAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (MySqlConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConfigurationGet() + public async Task Exists_ConfigurationGet() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ConfigurationGet.json // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_ConfigurationGet() // invoke the operation string configurationName = "event_scheduler"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - MySqlConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConfigurationList() + public async Task GetIfExists_ConfigurationGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ConfigurationListByServer.json - // this example is just showing the usage of "Configurations_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ConfigurationGet.json + // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,25 +170,31 @@ public async Task GetAll_ConfigurationList() // this example assumes you already have this MySqlServerResource created on azure // for more information of creating MySqlServerResource, please refer to the document of MySqlServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "mysqltestsvc1"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; ResourceIdentifier mySqlServerResourceId = MySqlServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlServerResource mySqlServer = client.GetMySqlServerResource(mySqlServerResourceId); // get the collection of this MySqlConfigurationResource MySqlConfigurationCollection collection = mySqlServer.GetMySqlConfigurations(); - // invoke the operation and iterate over the result - await foreach (MySqlConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string configurationName = "event_scheduler"; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + MySqlConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlConfigurationData resourceData = item.Data; + MySqlConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlConfigurationResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlConfigurationResource.cs index 55dedd5a17363..f967a7397bdb4 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlConfigurationResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlConfigurationResource.cs @@ -17,10 +17,10 @@ public partial class Sample_MySqlConfigurationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConfigurationCreateOrUpdate() + public async Task Get_ConfigurationGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ConfigurationCreateOrUpdate.json - // this example is just showing the usage of "Configurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ConfigurationGet.json + // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,13 +37,7 @@ public async Task Update_ConfigurationCreateOrUpdate() MySqlConfigurationResource mySqlConfiguration = client.GetMySqlConfigurationResource(mySqlConfigurationResourceId); // invoke the operation - MySqlConfigurationData data = new MySqlConfigurationData() - { - Value = "off", - Source = "user-override", - }; - ArmOperation lro = await mySqlConfiguration.UpdateAsync(WaitUntil.Completed, data); - MySqlConfigurationResource result = lro.Value; + MySqlConfigurationResource result = await mySqlConfiguration.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -54,10 +48,10 @@ public async Task Update_ConfigurationCreateOrUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConfigurationGet() + public async Task Update_ConfigurationCreateOrUpdate() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ConfigurationGet.json - // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ConfigurationCreateOrUpdate.json + // this example is just showing the usage of "Configurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,7 +68,13 @@ public async Task Get_ConfigurationGet() MySqlConfigurationResource mySqlConfiguration = client.GetMySqlConfigurationResource(mySqlConfigurationResourceId); // invoke the operation - MySqlConfigurationResource result = await mySqlConfiguration.GetAsync(); + MySqlConfigurationData data = new MySqlConfigurationData + { + Value = "off", + Source = "user-override", + }; + ArmOperation lro = await mySqlConfiguration.UpdateAsync(WaitUntil.Completed, data); + MySqlConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlDatabaseCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlDatabaseCollection.cs index 264330831933d..c0640c96a513a 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlDatabaseCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlDatabaseCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_DatabaseCreate() // invoke the operation string databaseName = "db1"; - MySqlDatabaseData data = new MySqlDatabaseData() + MySqlDatabaseData data = new MySqlDatabaseData { Charset = "utf8", Collation = "utf8_general_ci", @@ -91,10 +91,10 @@ public async Task Get_DatabaseGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_DatabaseGet() + public async Task GetAll_DatabaseList() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/DatabaseGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/DatabaseListByServer.json + // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_DatabaseGet() // get the collection of this MySqlDatabaseResource MySqlDatabaseCollection collection = mySqlServer.GetMySqlDatabases(); - // invoke the operation - string databaseName = "db1"; - bool result = await collection.ExistsAsync(databaseName); + // invoke the operation and iterate over the result + await foreach (MySqlDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_DatabaseGet() + public async Task Exists_DatabaseGet() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/DatabaseGet.json // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_DatabaseGet() // invoke the operation string databaseName = "db1"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - MySqlDatabaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(databaseName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DatabaseList() + public async Task GetIfExists_DatabaseGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/DatabaseListByServer.json - // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/DatabaseGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_DatabaseList() // get the collection of this MySqlDatabaseResource MySqlDatabaseCollection collection = mySqlServer.GetMySqlDatabases(); - // invoke the operation and iterate over the result - await foreach (MySqlDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "db1"; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + MySqlDatabaseResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlDatabaseData resourceData = item.Data; + MySqlDatabaseData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlDatabaseResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlDatabaseResource.cs index 9244d36383c43..9770e730556ab 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlDatabaseResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlDatabaseResource.cs @@ -17,10 +17,10 @@ public partial class Sample_MySqlDatabaseResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_DatabaseCreate() + public async Task Get_DatabaseGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/DatabaseCreate.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/DatabaseGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,13 +37,7 @@ public async Task Update_DatabaseCreate() MySqlDatabaseResource mySqlDatabase = client.GetMySqlDatabaseResource(mySqlDatabaseResourceId); // invoke the operation - MySqlDatabaseData data = new MySqlDatabaseData() - { - Charset = "utf8", - Collation = "utf8_general_ci", - }; - ArmOperation lro = await mySqlDatabase.UpdateAsync(WaitUntil.Completed, data); - MySqlDatabaseResource result = lro.Value; + MySqlDatabaseResource result = await mySqlDatabase.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +75,10 @@ public async Task Delete_DatabaseDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DatabaseGet() + public async Task Update_DatabaseCreate() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/DatabaseGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/DatabaseCreate.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +95,13 @@ public async Task Get_DatabaseGet() MySqlDatabaseResource mySqlDatabase = client.GetMySqlDatabaseResource(mySqlDatabaseResourceId); // invoke the operation - MySqlDatabaseResource result = await mySqlDatabase.GetAsync(); + MySqlDatabaseData data = new MySqlDatabaseData + { + Charset = "utf8", + Collation = "utf8_general_ci", + }; + ArmOperation lro = await mySqlDatabase.UpdateAsync(WaitUntil.Completed, data); + MySqlDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFirewallRuleCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFirewallRuleCollection.cs index f4daa768a4bb2..fbc8e6eb886ca 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFirewallRuleCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFirewallRuleCollection.cs @@ -88,10 +88,10 @@ public async Task Get_FirewallRuleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_FirewallRuleGet() + public async Task GetAll_FirewallRuleList() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/FirewallRuleListByServer.json + // this example is just showing the usage of "FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_FirewallRuleGet() // get the collection of this MySqlFirewallRuleResource MySqlFirewallRuleCollection collection = mySqlServer.GetMySqlFirewallRules(); - // invoke the operation - string firewallRuleName = "rule1"; - bool result = await collection.ExistsAsync(firewallRuleName); + // invoke the operation and iterate over the result + await foreach (MySqlFirewallRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFirewallRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_FirewallRuleGet() + public async Task Exists_FirewallRuleGet() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/FirewallRuleGet.json // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_FirewallRuleGet() // invoke the operation string firewallRuleName = "rule1"; - NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); - MySqlFirewallRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(firewallRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_FirewallRuleList() + public async Task GetIfExists_FirewallRuleGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/FirewallRuleListByServer.json - // this example is just showing the usage of "FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_FirewallRuleList() // get the collection of this MySqlFirewallRuleResource MySqlFirewallRuleCollection collection = mySqlServer.GetMySqlFirewallRules(); - // invoke the operation and iterate over the result - await foreach (MySqlFirewallRuleResource item in collection.GetAllAsync()) + // invoke the operation + string firewallRuleName = "rule1"; + NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); + MySqlFirewallRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFirewallRuleData resourceData = item.Data; + MySqlFirewallRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFirewallRuleResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFirewallRuleResource.cs index 2daa019de658c..b5b4ee5efa950 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFirewallRuleResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFirewallRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MySqlFirewallRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_FirewallRuleCreate() + public async Task Get_FirewallRuleGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/FirewallRuleCreate.json - // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Update_FirewallRuleCreate() MySqlFirewallRuleResource mySqlFirewallRule = client.GetMySqlFirewallRuleResource(mySqlFirewallRuleResourceId); // invoke the operation - MySqlFirewallRuleData data = new MySqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); - ArmOperation lro = await mySqlFirewallRule.UpdateAsync(WaitUntil.Completed, data); - MySqlFirewallRuleResource result = lro.Value; + MySqlFirewallRuleResource result = await mySqlFirewallRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -78,10 +76,10 @@ public async Task Delete_FirewallRuleDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_FirewallRuleGet() + public async Task Update_FirewallRuleCreate() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/FirewallRuleCreate.json + // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,7 +96,9 @@ public async Task Get_FirewallRuleGet() MySqlFirewallRuleResource mySqlFirewallRule = client.GetMySqlFirewallRuleResource(mySqlFirewallRuleResourceId); // invoke the operation - MySqlFirewallRuleResource result = await mySqlFirewallRule.GetAsync(); + MySqlFirewallRuleData data = new MySqlFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await mySqlFirewallRule.UpdateAsync(WaitUntil.Completed, data); + MySqlFirewallRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerAadAdministratorCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerAadAdministratorCollection.cs index 626ba0217a2e8..152b1259361a7 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerAadAdministratorCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerAadAdministratorCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_CreateAnAzureAdAdministrator() // invoke the operation MySqlFlexibleServerAdministratorName administratorName = MySqlFlexibleServerAdministratorName.ActiveDirectory; - MySqlFlexibleServerAadAdministratorData data = new MySqlFlexibleServerAadAdministratorData() + MySqlFlexibleServerAadAdministratorData data = new MySqlFlexibleServerAadAdministratorData { AdministratorType = MySqlFlexibleServerAdministratorType.ActiveDirectory, Login = "bob@contoso.com", @@ -95,10 +95,10 @@ public async Task Get_GetAnAzureAdAdministrator() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAnAzureAdAdministrator() + public async Task GetAll_ListAzureADAdministratorsInAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/stable/2023-12-30/examples/AzureADAdministratorGet.json - // this example is just showing the usage of "AzureADAdministrators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/stable/2023-12-30/examples/AzureADAdministratorsListByServer.json + // this example is just showing the usage of "AzureADAdministrators_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,16 +116,22 @@ public async Task Exists_GetAnAzureAdAdministrator() // get the collection of this MySqlFlexibleServerAadAdministratorResource MySqlFlexibleServerAadAdministratorCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerAadAdministrators(); - // invoke the operation - MySqlFlexibleServerAdministratorName administratorName = MySqlFlexibleServerAdministratorName.ActiveDirectory; - bool result = await collection.ExistsAsync(administratorName); + // invoke the operation and iterate over the result + await foreach (MySqlFlexibleServerAadAdministratorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerAadAdministratorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAnAzureAdAdministrator() + public async Task Exists_GetAnAzureAdAdministrator() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/stable/2023-12-30/examples/AzureADAdministratorGet.json // this example is just showing the usage of "AzureADAdministrators_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +154,17 @@ public async Task GetIfExists_GetAnAzureAdAdministrator() // invoke the operation MySqlFlexibleServerAdministratorName administratorName = MySqlFlexibleServerAdministratorName.ActiveDirectory; - NullableResponse response = await collection.GetIfExistsAsync(administratorName); - MySqlFlexibleServerAadAdministratorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(administratorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerAadAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAzureADAdministratorsInAServer() + public async Task GetIfExists_GetAnAzureAdAdministrator() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/stable/2023-12-30/examples/AzureADAdministratorsListByServer.json - // this example is just showing the usage of "AzureADAdministrators_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/stable/2023-12-30/examples/AzureADAdministratorGet.json + // this example is just showing the usage of "AzureADAdministrators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_ListAzureADAdministratorsInAServer() // get the collection of this MySqlFlexibleServerAadAdministratorResource MySqlFlexibleServerAadAdministratorCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerAadAdministrators(); - // invoke the operation and iterate over the result - await foreach (MySqlFlexibleServerAadAdministratorResource item in collection.GetAllAsync()) + // invoke the operation + MySqlFlexibleServerAdministratorName administratorName = MySqlFlexibleServerAdministratorName.ActiveDirectory; + NullableResponse response = await collection.GetIfExistsAsync(administratorName); + MySqlFlexibleServerAadAdministratorResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFlexibleServerAadAdministratorData resourceData = item.Data; + MySqlFlexibleServerAadAdministratorData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerAadAdministratorResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerAadAdministratorResource.cs index 7bc0ec4500fea..6a8187c563966 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerAadAdministratorResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerAadAdministratorResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MySqlFlexibleServerAadAdministratorResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAnAzureAdAdministrator() + public async Task Get_GetAnAzureAdAdministrator() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/stable/2023-12-30/examples/AzureADAdministratorCreate.json - // this example is just showing the usage of "AzureADAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/stable/2023-12-30/examples/AzureADAdministratorGet.json + // this example is just showing the usage of "AzureADAdministrators_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,7 @@ public async Task Update_CreateAnAzureAdAdministrator() MySqlFlexibleServerAadAdministratorResource mySqlFlexibleServerAadAdministrator = client.GetMySqlFlexibleServerAadAdministratorResource(mySqlFlexibleServerAadAdministratorResourceId); // invoke the operation - MySqlFlexibleServerAadAdministratorData data = new MySqlFlexibleServerAadAdministratorData() - { - AdministratorType = MySqlFlexibleServerAdministratorType.ActiveDirectory, - Login = "bob@contoso.com", - Sid = "c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c", - TenantId = Guid.Parse("c12b7025-bfe2-46c1-b463-993b5e4cd467"), - IdentityResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/test-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi"), - }; - ArmOperation lro = await mySqlFlexibleServerAadAdministrator.UpdateAsync(WaitUntil.Completed, data); - MySqlFlexibleServerAadAdministratorResource result = lro.Value; + MySqlFlexibleServerAadAdministratorResource result = await mySqlFlexibleServerAadAdministrator.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,10 +76,10 @@ public async Task Delete_DeleteAnAzureAdAdministrator() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAnAzureAdAdministrator() + public async Task Update_CreateAnAzureAdAdministrator() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/stable/2023-12-30/examples/AzureADAdministratorGet.json - // this example is just showing the usage of "AzureADAdministrators_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/AAD/stable/2023-12-30/examples/AzureADAdministratorCreate.json + // this example is just showing the usage of "AzureADAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,7 +96,16 @@ public async Task Get_GetAnAzureAdAdministrator() MySqlFlexibleServerAadAdministratorResource mySqlFlexibleServerAadAdministrator = client.GetMySqlFlexibleServerAadAdministratorResource(mySqlFlexibleServerAadAdministratorResourceId); // invoke the operation - MySqlFlexibleServerAadAdministratorResource result = await mySqlFlexibleServerAadAdministrator.GetAsync(); + MySqlFlexibleServerAadAdministratorData data = new MySqlFlexibleServerAadAdministratorData + { + AdministratorType = MySqlFlexibleServerAdministratorType.ActiveDirectory, + Login = "bob@contoso.com", + Sid = "c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c", + TenantId = Guid.Parse("c12b7025-bfe2-46c1-b463-993b5e4cd467"), + IdentityResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/test-group/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-umi"), + }; + ArmOperation lro = await mySqlFlexibleServerAadAdministrator.UpdateAsync(WaitUntil.Completed, data); + MySqlFlexibleServerAadAdministratorResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupCollection.cs index f45ce69c57bbb..7b7cbba2f47c4 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupCollection.cs @@ -86,10 +86,10 @@ public async Task Get_GetABackupForAServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetABackupForAServer() + public async Task GetAll_ListBackupsForAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupGet.json - // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupsListByServer.json + // this example is just showing the usage of "Backups_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +107,22 @@ public async Task Exists_GetABackupForAServer() // get the collection of this MySqlFlexibleServerBackupResource MySqlFlexibleServerBackupCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerBackups(); - // invoke the operation - string backupName = "daily_20210615T160516"; - bool result = await collection.ExistsAsync(backupName); + // invoke the operation and iterate over the result + await foreach (MySqlFlexibleServerBackupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerBackupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetABackupForAServer() + public async Task Exists_GetABackupForAServer() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupGet.json // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. @@ -139,29 +145,17 @@ public async Task GetIfExists_GetABackupForAServer() // invoke the operation string backupName = "daily_20210615T160516"; - NullableResponse response = await collection.GetIfExistsAsync(backupName); - MySqlFlexibleServerBackupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(backupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBackupsForAServer() + public async Task GetIfExists_GetABackupForAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupsListByServer.json - // this example is just showing the usage of "Backups_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupGet.json + // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_ListBackupsForAServer() // get the collection of this MySqlFlexibleServerBackupResource MySqlFlexibleServerBackupCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerBackups(); - // invoke the operation and iterate over the result - await foreach (MySqlFlexibleServerBackupResource item in collection.GetAllAsync()) + // invoke the operation + string backupName = "daily_20210615T160516"; + NullableResponse response = await collection.GetIfExistsAsync(backupName); + MySqlFlexibleServerBackupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFlexibleServerBackupData resourceData = item.Data; + MySqlFlexibleServerBackupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupResource.cs index 1647d919ca7d7..362899de933ab 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupResource.cs @@ -17,10 +17,10 @@ public partial class Sample_MySqlFlexibleServerBackupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateBackupForAServer() + public async Task Get_GetABackupForAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupPut.json - // this example is just showing the usage of "Backups_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupGet.json + // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,13 +32,12 @@ public async Task Update_CreateBackupForAServer() string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "TestGroup"; string serverName = "mysqltestserver"; - string backupName = "mybackup"; + string backupName = "daily_20210615T160516"; ResourceIdentifier mySqlFlexibleServerBackupResourceId = MySqlFlexibleServerBackupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); MySqlFlexibleServerBackupResource mySqlFlexibleServerBackup = client.GetMySqlFlexibleServerBackupResource(mySqlFlexibleServerBackupResourceId); // invoke the operation - ArmOperation lro = await mySqlFlexibleServerBackup.UpdateAsync(WaitUntil.Completed); - MySqlFlexibleServerBackupResource result = lro.Value; + MySqlFlexibleServerBackupResource result = await mySqlFlexibleServerBackup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -49,10 +48,10 @@ public async Task Update_CreateBackupForAServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetABackupForAServer() + public async Task Update_CreateBackupForAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupGet.json - // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupPut.json + // this example is just showing the usage of "Backups_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,12 +63,13 @@ public async Task Get_GetABackupForAServer() string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "TestGroup"; string serverName = "mysqltestserver"; - string backupName = "daily_20210615T160516"; + string backupName = "mybackup"; ResourceIdentifier mySqlFlexibleServerBackupResourceId = MySqlFlexibleServerBackupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); MySqlFlexibleServerBackupResource mySqlFlexibleServerBackup = client.GetMySqlFlexibleServerBackupResource(mySqlFlexibleServerBackupResourceId); // invoke the operation - MySqlFlexibleServerBackupResource result = await mySqlFlexibleServerBackup.GetAsync(); + ArmOperation lro = await mySqlFlexibleServerBackup.UpdateAsync(WaitUntil.Completed); + MySqlFlexibleServerBackupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupV2Collection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupV2Collection.cs index 81281de55f4f1..bf07bdc1d4110 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupV2Collection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupV2Collection.cs @@ -87,10 +87,10 @@ public async Task Get_GetABackupForAServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetABackupForAServer() + public async Task GetAll_ListBackupsForAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/LongRunningBackupGet.json - // this example is just showing the usage of "LongRunningBackups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/LongRunningBackupsListByServer.json + // this example is just showing the usage of "LongRunningBackups_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_GetABackupForAServer() // get the collection of this MySqlFlexibleServerBackupV2Resource MySqlFlexibleServerBackupV2Collection collection = mySqlFlexibleServer.GetMySqlFlexibleServerBackupV2s(); - // invoke the operation - string backupName = "daily_20210615T160516"; - bool result = await collection.ExistsAsync(backupName); + // invoke the operation and iterate over the result + await foreach (MySqlFlexibleServerBackupV2Resource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerBackupV2Data resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetABackupForAServer() + public async Task Exists_GetABackupForAServer() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/LongRunningBackupGet.json // this example is just showing the usage of "LongRunningBackups_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_GetABackupForAServer() // invoke the operation string backupName = "daily_20210615T160516"; - NullableResponse response = await collection.GetIfExistsAsync(backupName); - MySqlFlexibleServerBackupV2Resource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(backupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerBackupV2Data resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListBackupsForAServer() + public async Task GetIfExists_GetABackupForAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/LongRunningBackupsListByServer.json - // this example is just showing the usage of "LongRunningBackups_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/LongRunningBackupGet.json + // this example is just showing the usage of "LongRunningBackups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_ListBackupsForAServer() // get the collection of this MySqlFlexibleServerBackupV2Resource MySqlFlexibleServerBackupV2Collection collection = mySqlFlexibleServer.GetMySqlFlexibleServerBackupV2s(); - // invoke the operation and iterate over the result - await foreach (MySqlFlexibleServerBackupV2Resource item in collection.GetAllAsync()) + // invoke the operation + string backupName = "daily_20210615T160516"; + NullableResponse response = await collection.GetIfExistsAsync(backupName); + MySqlFlexibleServerBackupV2Resource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFlexibleServerBackupV2Data resourceData = item.Data; + MySqlFlexibleServerBackupV2Data resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupV2Resource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupV2Resource.cs index b907889a9ee79..c7e572a2cdd89 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupV2Resource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerBackupV2Resource.cs @@ -17,10 +17,10 @@ public partial class Sample_MySqlFlexibleServerBackupV2Resource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateBackupForAServer() + public async Task Get_GetABackupForAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/LongRunningBackup.json - // this example is just showing the usage of "LongRunningBackup_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/LongRunningBackupGet.json + // this example is just showing the usage of "LongRunningBackups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,14 +32,12 @@ public async Task Update_CreateBackupForAServer() string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "TestGroup"; string serverName = "mysqltestserver"; - string backupName = "testback"; + string backupName = "daily_20210615T160516"; ResourceIdentifier mySqlFlexibleServerBackupV2ResourceId = MySqlFlexibleServerBackupV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); MySqlFlexibleServerBackupV2Resource mySqlFlexibleServerBackupV2 = client.GetMySqlFlexibleServerBackupV2Resource(mySqlFlexibleServerBackupV2ResourceId); // invoke the operation - MySqlFlexibleServerBackupV2Data data = new MySqlFlexibleServerBackupV2Data(); - ArmOperation lro = await mySqlFlexibleServerBackupV2.UpdateAsync(WaitUntil.Completed, data); - MySqlFlexibleServerBackupV2Resource result = lro.Value; + MySqlFlexibleServerBackupV2Resource result = await mySqlFlexibleServerBackupV2.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -50,10 +48,10 @@ public async Task Update_CreateBackupForAServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetABackupForAServer() + public async Task Update_CreateBackupForAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/LongRunningBackupGet.json - // this example is just showing the usage of "LongRunningBackups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/LongRunningBackup.json + // this example is just showing the usage of "LongRunningBackup_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,12 +63,14 @@ public async Task Get_GetABackupForAServer() string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "TestGroup"; string serverName = "mysqltestserver"; - string backupName = "daily_20210615T160516"; + string backupName = "testback"; ResourceIdentifier mySqlFlexibleServerBackupV2ResourceId = MySqlFlexibleServerBackupV2Resource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, backupName); MySqlFlexibleServerBackupV2Resource mySqlFlexibleServerBackupV2 = client.GetMySqlFlexibleServerBackupV2Resource(mySqlFlexibleServerBackupV2ResourceId); // invoke the operation - MySqlFlexibleServerBackupV2Resource result = await mySqlFlexibleServerBackupV2.GetAsync(); + MySqlFlexibleServerBackupV2Data data = new MySqlFlexibleServerBackupV2Data(); + ArmOperation lro = await mySqlFlexibleServerBackupV2.UpdateAsync(WaitUntil.Completed, data); + MySqlFlexibleServerBackupV2Resource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerCollection.cs index f5c99069e434a..53a471cb1da72 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerCollection.cs @@ -50,26 +50,26 @@ public async Task CreateOrUpdate_CreateANewServer() Version = MySqlFlexibleServerVersion.Ver5_7, AvailabilityZone = "1", CreateMode = MySqlFlexibleServerCreateMode.Default, - Storage = new MySqlFlexibleServerStorage() + Storage = new MySqlFlexibleServerStorage { StorageSizeInGB = 100, Iops = 600, AutoGrow = MySqlFlexibleServerEnableStatusEnum.Disabled, }, - Backup = new MySqlFlexibleServerBackupProperties() + Backup = new MySqlFlexibleServerBackupProperties { BackupRetentionDays = 7, BackupIntervalHours = 24, GeoRedundantBackup = MySqlFlexibleServerEnableStatusEnum.Disabled, }, - HighAvailability = new MySqlFlexibleServerHighAvailability() + HighAvailability = new MySqlFlexibleServerHighAvailability { Mode = MySqlFlexibleServerHighAvailabilityMode.ZoneRedundant, StandbyAvailabilityZone = "3", }, Tags = { -["num"] = "1", +["num"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); @@ -153,7 +153,7 @@ public async Task CreateOrUpdate_CreateAServerAsAPointInTimeRestore() RestorePointInTime = DateTimeOffset.Parse("2021-06-24T00:00:37.467Z"), Tags = { -["num"] = "1", +["num"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); @@ -196,7 +196,7 @@ public async Task CreateOrUpdate_CreateAServerWithByok() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity() }, }, Sku = new MySqlFlexibleServerSku("Standard_D2ds_v4", MySqlFlexibleServerSkuTier.GeneralPurpose), @@ -205,7 +205,7 @@ public async Task CreateOrUpdate_CreateAServerWithByok() Version = MySqlFlexibleServerVersion.Ver5_7, AvailabilityZone = "1", CreateMode = MySqlFlexibleServerCreateMode.Default, - DataEncryption = new MySqlFlexibleServerDataEncryption() + DataEncryption = new MySqlFlexibleServerDataEncryption { PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity"), PrimaryKeyUri = new Uri("https://test.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a"), @@ -213,26 +213,26 @@ public async Task CreateOrUpdate_CreateAServerWithByok() GeoBackupKeyUri = new Uri("https://test-geo.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a"), EncryptionType = MySqlFlexibleServerDataEncryptionType.AzureKeyVault, }, - Storage = new MySqlFlexibleServerStorage() + Storage = new MySqlFlexibleServerStorage { StorageSizeInGB = 100, Iops = 600, AutoGrow = MySqlFlexibleServerEnableStatusEnum.Disabled, }, - Backup = new MySqlFlexibleServerBackupProperties() + Backup = new MySqlFlexibleServerBackupProperties { BackupRetentionDays = 7, BackupIntervalHours = 24, GeoRedundantBackup = MySqlFlexibleServerEnableStatusEnum.Disabled, }, - HighAvailability = new MySqlFlexibleServerHighAvailability() + HighAvailability = new MySqlFlexibleServerHighAvailability { Mode = MySqlFlexibleServerHighAvailabilityMode.ZoneRedundant, StandbyAvailabilityZone = "3", }, Tags = { -["num"] = "1", +["num"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, data); @@ -280,9 +280,9 @@ public async Task Get_GetAServer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServer() + public async Task Get_GetAServerWithVnet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGet.json + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGetWithVnet.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -302,17 +302,21 @@ public async Task Exists_GetAServer() // invoke the operation string serverName = "mysqltestserver"; - bool result = await collection.ExistsAsync(serverName); + MySqlFlexibleServerResource result = await collection.GetAsync(serverName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServer() + public async Task GetAll_ListServersInAResourceGroup() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServersListByResourceGroup.json + // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -322,38 +326,32 @@ public async Task GetIfExists_GetAServer() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; + string resourceGroupName = "TestGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this MySqlFlexibleServerResource MySqlFlexibleServerCollection collection = resourceGroupResource.GetMySqlFlexibleServers(); - // invoke the operation - string serverName = "mysqltestserver"; - NullableResponse response = await collection.GetIfExistsAsync(serverName); - MySqlFlexibleServerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MySqlFlexibleServerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFlexibleServerData resourceData = result.Data; + MySqlFlexibleServerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerWithVnet() + public async Task GetReplicas_ListReplicasForAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGetWithVnet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ReplicasListByServer.json + // this example is just showing the usage of "Replicas_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -363,29 +361,32 @@ public async Task Get_GetAServerWithVnet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; + string resourceGroupName = "TestGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this MySqlFlexibleServerResource MySqlFlexibleServerCollection collection = resourceGroupResource.GetMySqlFlexibleServers(); - // invoke the operation + // invoke the operation and iterate over the result string serverName = "mysqltestserver"; - MySqlFlexibleServerResource result = await collection.GetAsync(serverName); + await foreach (MySqlFlexibleServerResource item in collection.GetReplicasAsync(serverName)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerWithVnet() + public async Task Exists_GetAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGetWithVnet.json + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGet.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -412,7 +413,7 @@ public async Task Exists_GetAServerWithVnet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerWithVnet() + public async Task Exists_GetAServerWithVnet() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGetWithVnet.json // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. @@ -434,29 +435,17 @@ public async Task GetIfExists_GetAServerWithVnet() // invoke the operation string serverName = "mysqltestserver"; - NullableResponse response = await collection.GetIfExistsAsync(serverName); - MySqlFlexibleServerResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(serverName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListServersInAResourceGroup() + public async Task GetIfExists_GetAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServersListByResourceGroup.json - // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -466,32 +455,38 @@ public async Task GetAll_ListServersInAResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; + string resourceGroupName = "testrg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this MySqlFlexibleServerResource MySqlFlexibleServerCollection collection = resourceGroupResource.GetMySqlFlexibleServers(); - // invoke the operation and iterate over the result - await foreach (MySqlFlexibleServerResource item in collection.GetAllAsync()) + // invoke the operation + string serverName = "mysqltestserver"; + NullableResponse response = await collection.GetIfExistsAsync(serverName); + MySqlFlexibleServerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFlexibleServerData resourceData = item.Data; + MySqlFlexibleServerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetReplicas_ListReplicasForAServer() + public async Task GetIfExists_GetAServerWithVnet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ReplicasListByServer.json - // this example is just showing the usage of "Replicas_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGetWithVnet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -501,25 +496,30 @@ public async Task GetReplicas_ListReplicasForAServer() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; + string resourceGroupName = "testrg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this MySqlFlexibleServerResource MySqlFlexibleServerCollection collection = resourceGroupResource.GetMySqlFlexibleServers(); - // invoke the operation and iterate over the result + // invoke the operation string serverName = "mysqltestserver"; - await foreach (MySqlFlexibleServerResource item in collection.GetReplicasAsync(serverName)) + NullableResponse response = await collection.GetIfExistsAsync(serverName); + MySqlFlexibleServerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFlexibleServerData resourceData = item.Data; + MySqlFlexibleServerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerConfigurationCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerConfigurationCollection.cs index 5cd97ba8ea6f2..22e08c61add28 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerConfigurationCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerConfigurationCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_ConfigurationCreateOrUpdate() // invoke the operation string configurationName = "event_scheduler"; - MySqlFlexibleServerConfigurationData data = new MySqlFlexibleServerConfigurationData() + MySqlFlexibleServerConfigurationData data = new MySqlFlexibleServerConfigurationData { Value = "off", Source = MySqlFlexibleServerConfigurationSource.UserOverride, @@ -92,10 +92,10 @@ public async Task Get_GetAConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAConfiguration() + public async Task GetAll_ListAllConfigurationsForAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationGet.json - // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationsListByServer.json + // this example is just showing the usage of "Configurations_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,24 +105,32 @@ public async Task Exists_GetAConfiguration() // this example assumes you already have this MySqlFlexibleServerResource created on azure // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; - string serverName = "testserver"; + string resourceGroupName = "testrg"; + string serverName = "mysqltestserver"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // get the collection of this MySqlFlexibleServerConfigurationResource MySqlFlexibleServerConfigurationCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerConfigurations(); - // invoke the operation - string configurationName = "event_scheduler"; - bool result = await collection.ExistsAsync(configurationName); + // invoke the operation and iterate over the result + int? page = 1; + int? pageSize = 8; + await foreach (MySqlFlexibleServerConfigurationResource item in collection.GetAllAsync(page: page, pageSize: pageSize)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAConfiguration() + public async Task Exists_GetAConfiguration() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationGet.json // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +153,17 @@ public async Task GetIfExists_GetAConfiguration() // invoke the operation string configurationName = "event_scheduler"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - MySqlFlexibleServerConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllConfigurationsForAServer() + public async Task GetIfExists_GetAConfiguration() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationsListByServer.json - // this example is just showing the usage of "Configurations_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationGet.json + // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,27 +173,31 @@ public async Task GetAll_ListAllConfigurationsForAServer() // this example assumes you already have this MySqlFlexibleServerResource created on azure // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "mysqltestserver"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // get the collection of this MySqlFlexibleServerConfigurationResource MySqlFlexibleServerConfigurationCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerConfigurations(); - // invoke the operation and iterate over the result - int? page = 1; - int? pageSize = 8; - await foreach (MySqlFlexibleServerConfigurationResource item in collection.GetAllAsync(page: page, pageSize: pageSize)) + // invoke the operation + string configurationName = "event_scheduler"; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + MySqlFlexibleServerConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFlexibleServerConfigurationData resourceData = item.Data; + MySqlFlexibleServerConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerConfigurationResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerConfigurationResource.cs index d868161258910..61c67450c629e 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerConfigurationResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerConfigurationResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MySqlFlexibleServerConfigurationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateAUserConfiguration() + public async Task Get_GetAConfiguration() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationUpdate.json - // this example is just showing the usage of "Configurations_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationGet.json + // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,20 +31,14 @@ public async Task Update_UpdateAUserConfiguration() // this example assumes you already have this MySqlFlexibleServerConfigurationResource created on azure // for more information of creating MySqlFlexibleServerConfigurationResource, please refer to the document of MySqlFlexibleServerConfigurationResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; + string resourceGroupName = "TestGroup"; string serverName = "testserver"; string configurationName = "event_scheduler"; ResourceIdentifier mySqlFlexibleServerConfigurationResourceId = MySqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); MySqlFlexibleServerConfigurationResource mySqlFlexibleServerConfiguration = client.GetMySqlFlexibleServerConfigurationResource(mySqlFlexibleServerConfigurationResourceId); // invoke the operation - MySqlFlexibleServerConfigurationData data = new MySqlFlexibleServerConfigurationData() - { - Value = "on", - Source = MySqlFlexibleServerConfigurationSource.UserOverride, - }; - ArmOperation lro = await mySqlFlexibleServerConfiguration.UpdateAsync(WaitUntil.Completed, data); - MySqlFlexibleServerConfigurationResource result = lro.Value; + MySqlFlexibleServerConfigurationResource result = await mySqlFlexibleServerConfiguration.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +49,10 @@ public async Task Update_UpdateAUserConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAConfiguration() + public async Task Update_UpdateAUserConfiguration() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationGet.json - // this example is just showing the usage of "Configurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationUpdate.json + // this example is just showing the usage of "Configurations_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,14 +62,20 @@ public async Task Get_GetAConfiguration() // this example assumes you already have this MySqlFlexibleServerConfigurationResource created on azure // for more information of creating MySqlFlexibleServerConfigurationResource, please refer to the document of MySqlFlexibleServerConfigurationResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; + string resourceGroupName = "testrg"; string serverName = "testserver"; string configurationName = "event_scheduler"; ResourceIdentifier mySqlFlexibleServerConfigurationResourceId = MySqlFlexibleServerConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName, configurationName); MySqlFlexibleServerConfigurationResource mySqlFlexibleServerConfiguration = client.GetMySqlFlexibleServerConfigurationResource(mySqlFlexibleServerConfigurationResourceId); // invoke the operation - MySqlFlexibleServerConfigurationResource result = await mySqlFlexibleServerConfiguration.GetAsync(); + MySqlFlexibleServerConfigurationData data = new MySqlFlexibleServerConfigurationData + { + Value = "on", + Source = MySqlFlexibleServerConfigurationSource.UserOverride, + }; + ArmOperation lro = await mySqlFlexibleServerConfiguration.UpdateAsync(WaitUntil.Completed, data); + MySqlFlexibleServerConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerDatabaseCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerDatabaseCollection.cs index fa79ec72777b6..b8b97582803c0 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerDatabaseCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerDatabaseCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_CreateADatabase() // invoke the operation string databaseName = "db1"; - MySqlFlexibleServerDatabaseData data = new MySqlFlexibleServerDatabaseData() + MySqlFlexibleServerDatabaseData data = new MySqlFlexibleServerDatabaseData { Charset = "utf8", Collation = "utf8_general_ci", @@ -91,10 +91,10 @@ public async Task Get_GetADatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetADatabase() + public async Task GetAll_ListDatabasesInAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/stable/2023-12-30/examples/DatabaseGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/stable/2023-12-30/examples/DatabasesListByServer.json + // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +112,22 @@ public async Task Exists_GetADatabase() // get the collection of this MySqlFlexibleServerDatabaseResource MySqlFlexibleServerDatabaseCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerDatabases(); - // invoke the operation - string databaseName = "db1"; - bool result = await collection.ExistsAsync(databaseName); + // invoke the operation and iterate over the result + await foreach (MySqlFlexibleServerDatabaseResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerDatabaseData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetADatabase() + public async Task Exists_GetADatabase() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/stable/2023-12-30/examples/DatabaseGet.json // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +150,17 @@ public async Task GetIfExists_GetADatabase() // invoke the operation string databaseName = "db1"; - NullableResponse response = await collection.GetIfExistsAsync(databaseName); - MySqlFlexibleServerDatabaseResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(databaseName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerDatabaseData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDatabasesInAServer() + public async Task GetIfExists_GetADatabase() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/stable/2023-12-30/examples/DatabasesListByServer.json - // this example is just showing the usage of "Databases_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/stable/2023-12-30/examples/DatabaseGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListDatabasesInAServer() // get the collection of this MySqlFlexibleServerDatabaseResource MySqlFlexibleServerDatabaseCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerDatabases(); - // invoke the operation and iterate over the result - await foreach (MySqlFlexibleServerDatabaseResource item in collection.GetAllAsync()) + // invoke the operation + string databaseName = "db1"; + NullableResponse response = await collection.GetIfExistsAsync(databaseName); + MySqlFlexibleServerDatabaseResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFlexibleServerDatabaseData resourceData = item.Data; + MySqlFlexibleServerDatabaseData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerDatabaseResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerDatabaseResource.cs index 2e1bdcefaf13f..1286a4fd565ad 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerDatabaseResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerDatabaseResource.cs @@ -17,10 +17,10 @@ public partial class Sample_MySqlFlexibleServerDatabaseResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateADatabase() + public async Task Get_GetADatabase() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/stable/2023-12-30/examples/DatabaseCreate.json - // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/stable/2023-12-30/examples/DatabaseGet.json + // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,13 +37,7 @@ public async Task Update_CreateADatabase() MySqlFlexibleServerDatabaseResource mySqlFlexibleServerDatabase = client.GetMySqlFlexibleServerDatabaseResource(mySqlFlexibleServerDatabaseResourceId); // invoke the operation - MySqlFlexibleServerDatabaseData data = new MySqlFlexibleServerDatabaseData() - { - Charset = "utf8", - Collation = "utf8_general_ci", - }; - ArmOperation lro = await mySqlFlexibleServerDatabase.UpdateAsync(WaitUntil.Completed, data); - MySqlFlexibleServerDatabaseResource result = lro.Value; + MySqlFlexibleServerDatabaseResource result = await mySqlFlexibleServerDatabase.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +75,10 @@ public async Task Delete_DeleteADatabase() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetADatabase() + public async Task Update_CreateADatabase() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/stable/2023-12-30/examples/DatabaseGet.json - // this example is just showing the usage of "Databases_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Databases/stable/2023-12-30/examples/DatabaseCreate.json + // this example is just showing the usage of "Databases_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,7 +95,13 @@ public async Task Get_GetADatabase() MySqlFlexibleServerDatabaseResource mySqlFlexibleServerDatabase = client.GetMySqlFlexibleServerDatabaseResource(mySqlFlexibleServerDatabaseResourceId); // invoke the operation - MySqlFlexibleServerDatabaseResource result = await mySqlFlexibleServerDatabase.GetAsync(); + MySqlFlexibleServerDatabaseData data = new MySqlFlexibleServerDatabaseData + { + Charset = "utf8", + Collation = "utf8_general_ci", + }; + ArmOperation lro = await mySqlFlexibleServerDatabase.UpdateAsync(WaitUntil.Completed, data); + MySqlFlexibleServerDatabaseResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerFirewallRuleCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerFirewallRuleCollection.cs index d3f9b1f603b0b..5ed10228414c4 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerFirewallRuleCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerFirewallRuleCollection.cs @@ -88,10 +88,10 @@ public async Task Get_GetAFirewallRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAFirewallRule() + public async Task GetAll_ListAllFirewallRulesInAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/stable/2023-12-30/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/stable/2023-12-30/examples/FirewallRulesListByServer.json + // this example is just showing the usage of "FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_GetAFirewallRule() // get the collection of this MySqlFlexibleServerFirewallRuleResource MySqlFlexibleServerFirewallRuleCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerFirewallRules(); - // invoke the operation - string firewallRuleName = "rule1"; - bool result = await collection.ExistsAsync(firewallRuleName); + // invoke the operation and iterate over the result + await foreach (MySqlFlexibleServerFirewallRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerFirewallRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAFirewallRule() + public async Task Exists_GetAFirewallRule() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/stable/2023-12-30/examples/FirewallRuleGet.json // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +147,17 @@ public async Task GetIfExists_GetAFirewallRule() // invoke the operation string firewallRuleName = "rule1"; - NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); - MySqlFlexibleServerFirewallRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(firewallRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerFirewallRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllFirewallRulesInAServer() + public async Task GetIfExists_GetAFirewallRule() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/stable/2023-12-30/examples/FirewallRulesListByServer.json - // this example is just showing the usage of "FirewallRules_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/stable/2023-12-30/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +175,23 @@ public async Task GetAll_ListAllFirewallRulesInAServer() // get the collection of this MySqlFlexibleServerFirewallRuleResource MySqlFlexibleServerFirewallRuleCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerFirewallRules(); - // invoke the operation and iterate over the result - await foreach (MySqlFlexibleServerFirewallRuleResource item in collection.GetAllAsync()) + // invoke the operation + string firewallRuleName = "rule1"; + NullableResponse response = await collection.GetIfExistsAsync(firewallRuleName); + MySqlFlexibleServerFirewallRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFlexibleServerFirewallRuleData resourceData = item.Data; + MySqlFlexibleServerFirewallRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerFirewallRuleResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerFirewallRuleResource.cs index 53e534ead2856..87af959aa49cf 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerFirewallRuleResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerFirewallRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_MySqlFlexibleServerFirewallRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAFirewallRule() + public async Task Get_GetAFirewallRule() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/stable/2023-12-30/examples/FirewallRuleCreate.json - // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/stable/2023-12-30/examples/FirewallRuleGet.json + // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,9 +38,7 @@ public async Task Update_CreateAFirewallRule() MySqlFlexibleServerFirewallRuleResource mySqlFlexibleServerFirewallRule = client.GetMySqlFlexibleServerFirewallRuleResource(mySqlFlexibleServerFirewallRuleResourceId); // invoke the operation - MySqlFlexibleServerFirewallRuleData data = new MySqlFlexibleServerFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); - ArmOperation lro = await mySqlFlexibleServerFirewallRule.UpdateAsync(WaitUntil.Completed, data); - MySqlFlexibleServerFirewallRuleResource result = lro.Value; + MySqlFlexibleServerFirewallRuleResource result = await mySqlFlexibleServerFirewallRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -78,10 +76,10 @@ public async Task Delete_DeleteAFirewallRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAFirewallRule() + public async Task Update_CreateAFirewallRule() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/stable/2023-12-30/examples/FirewallRuleGet.json - // this example is just showing the usage of "FirewallRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Firewall/stable/2023-12-30/examples/FirewallRuleCreate.json + // this example is just showing the usage of "FirewallRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,7 +96,9 @@ public async Task Get_GetAFirewallRule() MySqlFlexibleServerFirewallRuleResource mySqlFlexibleServerFirewallRule = client.GetMySqlFlexibleServerFirewallRuleResource(mySqlFlexibleServerFirewallRuleResourceId); // invoke the operation - MySqlFlexibleServerFirewallRuleResource result = await mySqlFlexibleServerFirewallRule.GetAsync(); + MySqlFlexibleServerFirewallRuleData data = new MySqlFlexibleServerFirewallRuleData(IPAddress.Parse("0.0.0.0"), IPAddress.Parse("255.255.255.255")); + ArmOperation lro = await mySqlFlexibleServerFirewallRule.UpdateAsync(WaitUntil.Completed, data); + MySqlFlexibleServerFirewallRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerMaintenanceCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerMaintenanceCollection.cs index bbb7e329a05f1..5df2523ca2cc1 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerMaintenanceCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerMaintenanceCollection.cs @@ -51,10 +51,10 @@ public async Task Get_ReadAMaintenance() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ReadAMaintenance() + public async Task GetAll_ListMaintenancesOnAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Maintenance/stable/2023-12-30/examples/MaintenanceRead.json - // this example is just showing the usage of "Maintenances_Read" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Maintenance/stable/2023-12-30/examples/MaintenancesListByServer.json + // this example is just showing the usage of "Maintenances_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_ReadAMaintenance() // get the collection of this MySqlFlexibleServerMaintenanceResource MySqlFlexibleServerMaintenanceCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerMaintenances(); - // invoke the operation - string maintenanceName = "_T9Q-TS8"; - bool result = await collection.ExistsAsync(maintenanceName); + // invoke the operation and iterate over the result + await foreach (MySqlFlexibleServerMaintenanceResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerMaintenanceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ReadAMaintenance() + public async Task Exists_ReadAMaintenance() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Maintenance/stable/2023-12-30/examples/MaintenanceRead.json // this example is just showing the usage of "Maintenances_Read" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_ReadAMaintenance() // invoke the operation string maintenanceName = "_T9Q-TS8"; - NullableResponse response = await collection.GetIfExistsAsync(maintenanceName); - MySqlFlexibleServerMaintenanceResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(maintenanceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerMaintenanceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListMaintenancesOnAServer() + public async Task GetIfExists_ReadAMaintenance() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Maintenance/stable/2023-12-30/examples/MaintenancesListByServer.json - // this example is just showing the usage of "Maintenances_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Maintenance/stable/2023-12-30/examples/MaintenanceRead.json + // this example is just showing the usage of "Maintenances_Read" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ListMaintenancesOnAServer() // get the collection of this MySqlFlexibleServerMaintenanceResource MySqlFlexibleServerMaintenanceCollection collection = mySqlFlexibleServer.GetMySqlFlexibleServerMaintenances(); - // invoke the operation and iterate over the result - await foreach (MySqlFlexibleServerMaintenanceResource item in collection.GetAllAsync()) + // invoke the operation + string maintenanceName = "_T9Q-TS8"; + NullableResponse response = await collection.GetIfExistsAsync(maintenanceName); + MySqlFlexibleServerMaintenanceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlFlexibleServerMaintenanceData resourceData = item.Data; + MySqlFlexibleServerMaintenanceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerMaintenanceResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerMaintenanceResource.cs index cf7e538528677..7d47c1fcd6992 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerMaintenanceResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerMaintenanceResource.cs @@ -69,7 +69,7 @@ public async Task Update_UpdateMaintenanceOnAServer() MySqlFlexibleServerMaintenanceResource mySqlFlexibleServerMaintenance = client.GetMySqlFlexibleServerMaintenanceResource(mySqlFlexibleServerMaintenanceResourceId); // invoke the operation - MySqlFlexibleServerMaintenancePatch patch = new MySqlFlexibleServerMaintenancePatch() + MySqlFlexibleServerMaintenancePatch patch = new MySqlFlexibleServerMaintenancePatch { MaintenanceStartOn = DateTimeOffset.Parse("2024-01-20T00:00:00"), }; diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerResource.cs index 59a2873be9f86..6a3b3098f990d 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServerResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.MySql.FlexibleServers.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MySql.FlexibleServers.Samples @@ -20,10 +19,10 @@ public partial class Sample_MySqlFlexibleServerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateBackupAndExport_CreateAndExportBackup() + public async Task Get_GetAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupAndExport.json - // this example is just showing the usage of "BackupAndExport_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,28 +32,27 @@ public async Task CreateBackupAndExport_CreateAndExportBackup() // this example assumes you already have this MySqlFlexibleServerResource created on azure // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; + string resourceGroupName = "testrg"; string serverName = "mysqltestserver"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - MySqlFlexibleServerBackupAndExportContent content = new MySqlFlexibleServerBackupAndExportContent(new MySqlFlexibleServerBackupSettings("customer-backup-name"), new MySqlFlexibleServerFullBackupStoreDetails(new string[] - { -"sasuri1","sasuri2" - })); - ArmOperation lro = await mySqlFlexibleServer.CreateBackupAndExportAsync(WaitUntil.Completed, content); - MySqlFlexibleServerBackupAndExportResult result = lro.Value; + MySqlFlexibleServerResource result = await mySqlFlexibleServer.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task ValidateBackup_ValidateBackup() + public async Task Get_GetAServerWithVnet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/ValidateBackup.json - // this example is just showing the usage of "BackupAndExport_ValidateBackup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGetWithVnet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,23 +62,27 @@ public async Task ValidateBackup_ValidateBackup() // this example assumes you already have this MySqlFlexibleServerResource created on azure // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; + string resourceGroupName = "testrg"; string serverName = "mysqltestserver"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - MySqlFlexibleServerValidateBackupResult result = await mySqlFlexibleServer.ValidateBackupAsync(); + MySqlFlexibleServerResource result = await mySqlFlexibleServer.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task UpdateConfigurations_ConfigurationList() + public async Task Delete_DeleteAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationsBatchUpdate.json - // this example is just showing the usage of "Configurations_BatchUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerDelete.json + // this example is just showing the usage of "Servers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -90,32 +92,15 @@ public async Task UpdateConfigurations_ConfigurationList() // this example assumes you already have this MySqlFlexibleServerResource created on azure // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; - string serverName = "mysqltestserver"; + string resourceGroupName = "TestGroup"; + string serverName = "testserver"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - MySqlFlexibleServerConfigurationListForBatchUpdate mySqlFlexibleServerConfigurationListForBatchUpdate = new MySqlFlexibleServerConfigurationListForBatchUpdate() - { - Values = -{ -new MySqlFlexibleServerConfigurationForBatchUpdate() -{ -Name = "event_scheduler", -Value = "OFF", -},new MySqlFlexibleServerConfigurationForBatchUpdate() -{ -Name = "div_precision_increment", -Value = "8", -} -}, - ResetAllToDefault = MySqlFlexibleServerConfigurationResetAllToDefault.False, - }; - ArmOperation lro = await mySqlFlexibleServer.UpdateConfigurationsAsync(WaitUntil.Completed, mySqlFlexibleServerConfigurationListForBatchUpdate); - MySqlFlexibleServerConfigurations result = lro.Value; + await mySqlFlexibleServer.DeleteAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] @@ -139,16 +124,16 @@ public async Task Update_UpdateAServer() MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - MySqlFlexibleServerPatch patch = new MySqlFlexibleServerPatch() + MySqlFlexibleServerPatch patch = new MySqlFlexibleServerPatch { - Storage = new MySqlFlexibleServerStorage() + Storage = new MySqlFlexibleServerStorage { StorageSizeInGB = 30, Iops = 200, AutoGrow = MySqlFlexibleServerEnableStatusEnum.Disabled, AutoIoScaling = MySqlFlexibleServerEnableStatusEnum.Disabled, }, - Network = new MySqlFlexibleServerNetwork() + Network = new MySqlFlexibleServerNetwork { PublicNetworkAccess = MySqlFlexibleServerEnableStatusEnum.Disabled, }, @@ -184,9 +169,9 @@ public async Task Update_UpdateServerCustomerMaintenanceWindow() MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - MySqlFlexibleServerPatch patch = new MySqlFlexibleServerPatch() + MySqlFlexibleServerPatch patch = new MySqlFlexibleServerPatch { - MaintenanceWindow = new MySqlFlexibleServerMaintenanceWindow() + MaintenanceWindow = new MySqlFlexibleServerMaintenanceWindow { CustomWindow = "Enabled", StartHour = 8, @@ -225,16 +210,16 @@ public async Task Update_UpdateServerWithByok() MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - MySqlFlexibleServerPatch patch = new MySqlFlexibleServerPatch() + MySqlFlexibleServerPatch patch = new MySqlFlexibleServerPatch { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity")] = new UserAssignedIdentity() }, }, - DataEncryption = new MySqlFlexibleServerDataEncryption() + DataEncryption = new MySqlFlexibleServerDataEncryption { PrimaryUserAssignedIdentityId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/test-identity"), PrimaryKeyUri = new Uri("https://test.vault.azure.net/keys/key/c8a92236622244c0a4fdb892666f671a"), @@ -255,10 +240,10 @@ public async Task Update_UpdateServerWithByok() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAServer() + public async Task CreateBackupAndExport_CreateAndExportBackup() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerDelete.json - // this example is just showing the usage of "Servers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/BackupAndExport.json + // this example is just showing the usage of "BackupAndExport_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -269,22 +254,24 @@ public async Task Delete_DeleteAServer() // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; string resourceGroupName = "TestGroup"; - string serverName = "testserver"; + string serverName = "mysqltestserver"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - await mySqlFlexibleServer.DeleteAsync(WaitUntil.Completed); + MySqlFlexibleServerBackupAndExportContent content = new MySqlFlexibleServerBackupAndExportContent(new MySqlFlexibleServerBackupSettings("customer-backup-name"), new MySqlFlexibleServerFullBackupStoreDetails(new string[] { "sasuri1", "sasuri2" })); + ArmOperation lro = await mySqlFlexibleServer.CreateBackupAndExportAsync(WaitUntil.Completed, content); + MySqlFlexibleServerBackupAndExportResult result = lro.Value; - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServer() + public async Task ValidateBackup_ValidateBackup() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Backups/stable/2023-12-30/examples/ValidateBackup.json + // this example is just showing the usage of "BackupAndExport_ValidateBackup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -294,27 +281,23 @@ public async Task Get_GetAServer() // this example assumes you already have this MySqlFlexibleServerResource created on azure // for more information of creating MySqlFlexibleServerResource, please refer to the document of MySqlFlexibleServerResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; + string resourceGroupName = "TestGroup"; string serverName = "mysqltestserver"; ResourceIdentifier mySqlFlexibleServerResourceId = MySqlFlexibleServerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serverName); MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - MySqlFlexibleServerResource result = await mySqlFlexibleServer.GetAsync(); + MySqlFlexibleServerValidateBackupResult result = await mySqlFlexibleServer.ValidateBackupAsync(); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerWithVnet() + public async Task UpdateConfigurations_ConfigurationList() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServerGetWithVnet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/Configurations/stable/2023-12-30/examples/ConfigurationsBatchUpdate.json + // this example is just showing the usage of "Configurations_BatchUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -330,44 +313,23 @@ public async Task Get_GetAServerWithVnet() MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - MySqlFlexibleServerResource result = await mySqlFlexibleServer.GetAsync(); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMySqlFlexibleServers_ListServersInASubscription() - { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServersList.json - // this example is just showing the usage of "Servers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MySqlFlexibleServerResource item in subscriptionResource.GetMySqlFlexibleServersAsync()) + MySqlFlexibleServerConfigurationListForBatchUpdate mySqlFlexibleServerConfigurationListForBatchUpdate = new MySqlFlexibleServerConfigurationListForBatchUpdate { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Values = {new MySqlFlexibleServerConfigurationForBatchUpdate +{ +Name = "event_scheduler", +Value = "OFF", +}, new MySqlFlexibleServerConfigurationForBatchUpdate +{ +Name = "div_precision_increment", +Value = "8", +}}, + ResetAllToDefault = MySqlFlexibleServerConfigurationResetAllToDefault.False, + }; + ArmOperation lro = await mySqlFlexibleServer.UpdateConfigurationsAsync(WaitUntil.Completed, mySqlFlexibleServerConfigurationListForBatchUpdate); + MySqlFlexibleServerConfigurations result = lro.Value; - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -417,7 +379,7 @@ public async Task ValidateEstimateHighAvailability_ValidateAValidationAndEstimat MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - HighAvailabilityValidationEstimation highAvailabilityValidationEstimation = new HighAvailabilityValidationEstimation() + HighAvailabilityValidationEstimation highAvailabilityValidationEstimation = new HighAvailabilityValidationEstimation { ExpectedStandbyAvailabilityZone = "1", }; @@ -447,7 +409,7 @@ public async Task Restart_RestartAServer() MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - MySqlFlexibleServerRestartParameter mySqlFlexibleServerRestartParameter = new MySqlFlexibleServerRestartParameter() + MySqlFlexibleServerRestartParameter mySqlFlexibleServerRestartParameter = new MySqlFlexibleServerRestartParameter { RestartWithFailover = MySqlFlexibleServerEnableStatusEnum.Enabled, MaxFailoverSeconds = 60, @@ -530,7 +492,7 @@ public async Task ResetGtid_ResetGTIDOnAServer() MySqlFlexibleServerResource mySqlFlexibleServer = client.GetMySqlFlexibleServerResource(mySqlFlexibleServerResourceId); // invoke the operation - MySqlFlexibleServerGtidSetContent content = new MySqlFlexibleServerGtidSetContent() + MySqlFlexibleServerGtidSetContent content = new MySqlFlexibleServerGtidSetContent { GtidSet = "4aff5b51-97ba-11ed-a955-002248036acc:1-16", }; diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServersCapabilityCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServersCapabilityCollection.cs index c132086fca40d..9f5d0561f9e11 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServersCapabilityCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlFlexibleServersCapabilityCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MySqlFlexibleServersCapabilityCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_CapabilitySetsResult() + public async Task Get_CapabilityResult() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/ServiceOperations/stable/2023-12-30/examples/CapabilitySetListByLocation.json - // this example is just showing the usage of "LocationBasedCapabilitySet_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/ServiceOperations/stable/2023-12-30/examples/CapabilitySetByLocation.json + // this example is just showing the usage of "LocationBasedCapabilitySet_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_CapabilitySetsResult() AzureLocation locationName = new AzureLocation("WestUS"); MySqlFlexibleServersCapabilityCollection collection = subscriptionResource.GetMySqlFlexibleServersCapabilities(locationName); - // invoke the operation and iterate over the result - await foreach (MySqlFlexibleServersCapabilityResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServersCapabilityData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string capabilitySetName = "default"; + MySqlFlexibleServersCapabilityResource result = await collection.GetAsync(capabilitySetName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServersCapabilityData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CapabilityResult() + public async Task GetAll_CapabilitySetsResult() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/ServiceOperations/stable/2023-12-30/examples/CapabilitySetByLocation.json - // this example is just showing the usage of "LocationBasedCapabilitySet_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/ServiceOperations/stable/2023-12-30/examples/CapabilitySetListByLocation.json + // this example is just showing the usage of "LocationBasedCapabilitySet_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +71,17 @@ public async Task Get_CapabilityResult() AzureLocation locationName = new AzureLocation("WestUS"); MySqlFlexibleServersCapabilityCollection collection = subscriptionResource.GetMySqlFlexibleServersCapabilities(locationName); - // invoke the operation - string capabilitySetName = "default"; - MySqlFlexibleServersCapabilityResource result = await collection.GetAsync(capabilitySetName); + // invoke the operation and iterate over the result + await foreach (MySqlFlexibleServersCapabilityResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServersCapabilityData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlFlexibleServersCapabilityData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateEndpointConnectionCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateEndpointConnectionCollection.cs index b77e358b58b9b..abb03d07bf7f3 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateEndpointConnectionCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MySqlPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsPrivateEndpointConnection() + public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - MySqlPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); + MySqlPrivateEndpointConnectionData data = new MySqlPrivateEndpointConnectionData + { + ConnectionState = new MySqlPrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); + MySqlPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_GetsPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsPrivateEndpointConnection() + public async Task Get_GetsPrivateEndpointConnection() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +80,21 @@ public async Task Exists_GetsPrivateEndpointConnection() // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - bool result = await collection.ExistsAsync(privateEndpointConnectionName); + MySqlPrivateEndpointConnectionResource result = await collection.GetAsync(privateEndpointConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsPrivateEndpointConnection() + public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json - // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateEndpointConnectionList.json + // this example is just showing the usage of "PrivateEndpointConnections_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +112,25 @@ public async Task GetIfExists_GetsPrivateEndpointConnection() // get the collection of this MySqlPrivateEndpointConnectionResource MySqlPrivateEndpointConnectionCollection collection = mySqlServer.GetMySqlPrivateEndpointConnections(); - // invoke the operation - string privateEndpointConnectionName = "private-endpoint-connection-name"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); - MySqlPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MySqlPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlPrivateEndpointConnectionData resourceData = result.Data; + MySqlPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAGivenName() + public async Task Exists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "PrivateEndpointConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,26 +150,17 @@ public async Task CreateOrUpdate_ApproveOrRejectAPrivateEndpointConnectionWithAG // invoke the operation string privateEndpointConnectionName = "private-endpoint-connection-name"; - MySqlPrivateEndpointConnectionData data = new MySqlPrivateEndpointConnectionData() - { - ConnectionState = new MySqlPrivateLinkServiceConnectionStateProperty("Approved", "Approved by johndoe@contoso.com"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointConnectionName, data); - MySqlPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() + public async Task GetIfExists_GetsPrivateEndpointConnection() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateEndpointConnectionList.json - // this example is just showing the usage of "PrivateEndpointConnections_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateEndpointConnectionGet.json + // this example is just showing the usage of "PrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_GetsListOfPrivateEndpointConnectionsOnAServer() // get the collection of this MySqlPrivateEndpointConnectionResource MySqlPrivateEndpointConnectionCollection collection = mySqlServer.GetMySqlPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (MySqlPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointConnectionName = "private-endpoint-connection-name"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointConnectionName); + MySqlPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlPrivateEndpointConnectionData resourceData = item.Data; + MySqlPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateEndpointConnectionResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateEndpointConnectionResource.cs index 6c9765aaad70e..d60d8a456add5 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateEndpointConnectionResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateEndpointConnectionResource.cs @@ -96,12 +96,12 @@ public async Task Update_UpdatePrivateEndpointConnectionTags() MySqlPrivateEndpointConnectionResource mySqlPrivateEndpointConnection = client.GetMySqlPrivateEndpointConnectionResource(mySqlPrivateEndpointConnectionResourceId); // invoke the operation - MySqlPrivateEndpointConnectionPatch patch = new MySqlPrivateEndpointConnectionPatch() + MySqlPrivateEndpointConnectionPatch patch = new MySqlPrivateEndpointConnectionPatch { Tags = { ["key1"] = "val1", -["key2"] = "val2", +["key2"] = "val2" }, }; ArmOperation lro = await mySqlPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateLinkResourceCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateLinkResourceCollection.cs index 8f57ac08ada6a..930bbf49ed082 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateLinkResourceCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlPrivateLinkResourceCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MySqlPrivateLinkResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsPrivateLinkResourcesForMySQL() + public async Task Get_GetsAPrivateLinkResourceForMySQL() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateLinkResourcesList.json - // this example is just showing the usage of "PrivateLinkResources_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateLinkResourcesGet.json + // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_GetsPrivateLinkResourcesForMySQL() // get the collection of this MySqlPrivateLinkResource MySqlPrivateLinkResourceCollection collection = mySqlServer.GetMySqlPrivateLinkResources(); - // invoke the operation and iterate over the result - await foreach (MySqlPrivateLinkResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlPrivateLinkResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string groupName = "plr"; + MySqlPrivateLinkResource result = await collection.GetAsync(groupName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlPrivateLinkResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAPrivateLinkResourceForMySQL() + public async Task GetAll_GetsPrivateLinkResourcesForMySQL() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateLinkResourcesGet.json - // this example is just showing the usage of "PrivateLinkResources_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/PrivateLinkResourcesList.json + // this example is just showing the usage of "PrivateLinkResources_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_GetsAPrivateLinkResourceForMySQL() // get the collection of this MySqlPrivateLinkResource MySqlPrivateLinkResourceCollection collection = mySqlServer.GetMySqlPrivateLinkResources(); - // invoke the operation - string groupName = "plr"; - MySqlPrivateLinkResource result = await collection.GetAsync(groupName); + // invoke the operation and iterate over the result + await foreach (MySqlPrivateLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlPrivateLinkResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlPrivateLinkResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlQueryStatisticCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlQueryStatisticCollection.cs index 9470b142427a2..f565531e2d0e6 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlQueryStatisticCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlQueryStatisticCollection.cs @@ -52,10 +52,10 @@ public async Task Get_TopQueryStatisticsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_TopQueryStatisticsGet() + public async Task GetAll_TopQueryStatisticsListByServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/TopQueryStatisticsGet.json - // this example is just showing the usage of "TopQueryStatistics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/TopQueryStatisticsListByServer.json + // this example is just showing the usage of "TopQueryStatistics_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,16 +73,29 @@ public async Task Exists_TopQueryStatisticsGet() // get the collection of this MySqlQueryStatisticResource MySqlQueryStatisticCollection collection = mySqlServer.GetMySqlQueryStatistics(); - // invoke the operation - string queryStatisticId = "66-636923268000000000-636923277000000000-avg-duration"; - bool result = await collection.ExistsAsync(queryStatisticId); + // invoke the operation and iterate over the result + MySqlTopQueryStatisticsInput input = new MySqlTopQueryStatisticsInput( + 5, + "avg", + "duration", + DateTimeOffset.Parse("2019-05-01T20:00:00.000Z"), + DateTimeOffset.Parse("2019-05-07T20:00:00.000Z"), + "PT15M"); + await foreach (MySqlQueryStatisticResource item in collection.GetAllAsync(input)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlQueryStatisticData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_TopQueryStatisticsGet() + public async Task Exists_TopQueryStatisticsGet() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/TopQueryStatisticsGet.json // this example is just showing the usage of "TopQueryStatistics_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +118,17 @@ public async Task GetIfExists_TopQueryStatisticsGet() // invoke the operation string queryStatisticId = "66-636923268000000000-636923277000000000-avg-duration"; - NullableResponse response = await collection.GetIfExistsAsync(queryStatisticId); - MySqlQueryStatisticResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(queryStatisticId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlQueryStatisticData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_TopQueryStatisticsListByServer() + public async Task GetIfExists_TopQueryStatisticsGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/TopQueryStatisticsListByServer.json - // this example is just showing the usage of "TopQueryStatistics_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/TopQueryStatisticsGet.json + // this example is just showing the usage of "TopQueryStatistics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,18 +146,23 @@ public async Task GetAll_TopQueryStatisticsListByServer() // get the collection of this MySqlQueryStatisticResource MySqlQueryStatisticCollection collection = mySqlServer.GetMySqlQueryStatistics(); - // invoke the operation and iterate over the result - MySqlTopQueryStatisticsInput input = new MySqlTopQueryStatisticsInput(5, "avg", "duration", DateTimeOffset.Parse("2019-05-01T20:00:00.000Z"), DateTimeOffset.Parse("2019-05-07T20:00:00.000Z"), "PT15M"); - await foreach (MySqlQueryStatisticResource item in collection.GetAllAsync(input)) + // invoke the operation + string queryStatisticId = "66-636923268000000000-636923277000000000-avg-duration"; + NullableResponse response = await collection.GetIfExistsAsync(queryStatisticId); + MySqlQueryStatisticResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlQueryStatisticData resourceData = item.Data; + MySqlQueryStatisticData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlQueryTextCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlQueryTextCollection.cs index db73023159a99..81c4a44aa2c94 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlQueryTextCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlQueryTextCollection.cs @@ -52,10 +52,10 @@ public async Task Get_QueryTextsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_QueryTextsGet() + public async Task GetAll_QueryTextsListByServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/QueryTextsGet.json - // this example is just showing the usage of "QueryTexts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/QueryTextsListByServer.json + // this example is just showing the usage of "QueryTexts_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,16 +73,23 @@ public async Task Exists_QueryTextsGet() // get the collection of this MySqlQueryTextResource MySqlQueryTextCollection collection = mySqlServer.GetMySqlQueryTexts(); - // invoke the operation - string queryId = "1"; - bool result = await collection.ExistsAsync(queryId); + // invoke the operation and iterate over the result + IEnumerable queryIds = new string[] { "1", "2" }; + await foreach (MySqlQueryTextResource item in collection.GetAllAsync(queryIds)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlQueryTextData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_QueryTextsGet() + public async Task Exists_QueryTextsGet() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/QueryTextsGet.json // this example is just showing the usage of "QueryTexts_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +112,17 @@ public async Task GetIfExists_QueryTextsGet() // invoke the operation string queryId = "1"; - NullableResponse response = await collection.GetIfExistsAsync(queryId); - MySqlQueryTextResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(queryId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlQueryTextData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_QueryTextsListByServer() + public async Task GetIfExists_QueryTextsGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/QueryTextsListByServer.json - // this example is just showing the usage of "QueryTexts_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/QueryTextsGet.json + // this example is just showing the usage of "QueryTexts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,21 +140,23 @@ public async Task GetAll_QueryTextsListByServer() // get the collection of this MySqlQueryTextResource MySqlQueryTextCollection collection = mySqlServer.GetMySqlQueryTexts(); - // invoke the operation and iterate over the result - IEnumerable queryIds = new string[] + // invoke the operation + string queryId = "1"; + NullableResponse response = await collection.GetIfExistsAsync(queryId); + MySqlQueryTextResource result = response.HasValue ? response.Value : null; + + if (result == null) { -"1","2" - }; - await foreach (MySqlQueryTextResource item in collection.GetAllAsync(queryIds)) + Console.WriteLine("Succeeded with null as result"); + } + else { - // the variable item is a resource, you could call other operations on this instance as well + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlQueryTextData resourceData = item.Data; + MySqlQueryTextData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlRecommendationActionCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlRecommendationActionCollection.cs index b81088aa7d837..b25ce3715d7e4 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlRecommendationActionCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlRecommendationActionCollection.cs @@ -52,10 +52,10 @@ public async Task Get_RecommendedActionsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RecommendedActionsGet() + public async Task GetAll_RecommendedActionsListByServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/RecommendedActionsGet.json - // this example is just showing the usage of "RecommendedActions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/RecommendedActionsListByServer.json + // this example is just showing the usage of "RecommendedActions_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,16 +74,22 @@ public async Task Exists_RecommendedActionsGet() // get the collection of this MySqlRecommendationActionResource MySqlRecommendationActionCollection collection = mySqlAdvisor.GetMySqlRecommendationActions(); - // invoke the operation - string recommendedActionName = "Index-1"; - bool result = await collection.ExistsAsync(recommendedActionName); + // invoke the operation and iterate over the result + await foreach (MySqlRecommendationActionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlRecommendationActionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RecommendedActionsGet() + public async Task Exists_RecommendedActionsGet() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/RecommendedActionsGet.json // this example is just showing the usage of "RecommendedActions_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +113,17 @@ public async Task GetIfExists_RecommendedActionsGet() // invoke the operation string recommendedActionName = "Index-1"; - NullableResponse response = await collection.GetIfExistsAsync(recommendedActionName); - MySqlRecommendationActionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(recommendedActionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlRecommendationActionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RecommendedActionsListByServer() + public async Task GetIfExists_RecommendedActionsGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/RecommendedActionsListByServer.json - // this example is just showing the usage of "RecommendedActions_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/RecommendedActionsGet.json + // this example is just showing the usage of "RecommendedActions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,17 +142,23 @@ public async Task GetAll_RecommendedActionsListByServer() // get the collection of this MySqlRecommendationActionResource MySqlRecommendationActionCollection collection = mySqlAdvisor.GetMySqlRecommendationActions(); - // invoke the operation and iterate over the result - await foreach (MySqlRecommendationActionResource item in collection.GetAllAsync()) + // invoke the operation + string recommendedActionName = "Index-1"; + NullableResponse response = await collection.GetIfExistsAsync(recommendedActionName); + MySqlRecommendationActionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlRecommendationActionData resourceData = item.Data; + MySqlRecommendationActionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerAdministratorResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerAdministratorResource.cs index f3b468e5ffb2d..e86feba95cf8f 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerAdministratorResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerAdministratorResource.cs @@ -48,10 +48,10 @@ public async Task Get_ServerAdministratorGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ServerAdministratorCreate() + public async Task Delete_ServerAdministratorsDelete() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerAdminCreateUpdate.json - // this example is just showing the usage of "ServerAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerAdminDelete.json + // this example is just showing the usage of "ServerAdministrators_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,29 +67,17 @@ public async Task CreateOrUpdate_ServerAdministratorCreate() MySqlServerAdministratorResource mySqlServerAdministrator = client.GetMySqlServerAdministratorResource(mySqlServerAdministratorResourceId); // invoke the operation - MySqlServerAdministratorData data = new MySqlServerAdministratorData() - { - AdministratorType = MySqlAdministratorType.ActiveDirectory, - LoginAccountName = "bob@contoso.com", - SecureId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), - }; - ArmOperation lro = await mySqlServerAdministrator.CreateOrUpdateAsync(WaitUntil.Completed, data); - MySqlServerAdministratorResource result = lro.Value; + await mySqlServerAdministrator.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlServerAdministratorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ServerAdministratorsDelete() + public async Task CreateOrUpdate_ServerAdministratorCreate() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerAdminDelete.json - // this example is just showing the usage of "ServerAdministrators_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerAdminCreateUpdate.json + // this example is just showing the usage of "ServerAdministrators_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +93,21 @@ public async Task Delete_ServerAdministratorsDelete() MySqlServerAdministratorResource mySqlServerAdministrator = client.GetMySqlServerAdministratorResource(mySqlServerAdministratorResourceId); // invoke the operation - await mySqlServerAdministrator.DeleteAsync(WaitUntil.Completed); + MySqlServerAdministratorData data = new MySqlServerAdministratorData + { + AdministratorType = MySqlAdministratorType.ActiveDirectory, + LoginAccountName = "bob@contoso.com", + SecureId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + TenantId = Guid.Parse("c6b82b90-a647-49cb-8a62-0d2d3cb7ac7c"), + }; + ArmOperation lro = await mySqlServerAdministrator.CreateOrUpdateAsync(WaitUntil.Completed, data); + MySqlServerAdministratorResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlServerAdministratorData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerCollection.cs index 3922c03d00810..9e6158c5bcef3 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerCollection.cs @@ -51,7 +51,7 @@ public async Task CreateOrUpdate_CreateADatabaseAsAPointInTimeRestore() }, Tags = { -["ElasticServer"] = "1", +["ElasticServer"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); @@ -91,7 +91,7 @@ public async Task CreateOrUpdate_CreateANewServer() MySqlServerCreateOrUpdateContent content = new MySqlServerCreateOrUpdateContent(new MySqlServerPropertiesForDefaultCreate("cloudsa", "") { SslEnforcement = MySqlSslEnforcementEnum.Enabled, - StorageProfile = new MySqlStorageProfile() + StorageProfile = new MySqlStorageProfile { BackupRetentionDays = 7, GeoRedundantBackup = MySqlGeoRedundantBackup.Enabled, @@ -107,7 +107,7 @@ public async Task CreateOrUpdate_CreateANewServer() }, Tags = { -["ElasticServer"] = "1", +["ElasticServer"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); @@ -189,7 +189,7 @@ public async Task CreateOrUpdate_CreateAServerAsAGeoRestore() }, Tags = { -["ElasticServer"] = "1", +["ElasticServer"] = "1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serverName, content); @@ -237,10 +237,10 @@ public async Task Get_ServerGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ServerGet() + public async Task GetAll_ServerListByResourceGroup() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerListByResourceGroup.json + // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -257,19 +257,25 @@ public async Task Exists_ServerGet() // get the collection of this MySqlServerResource MySqlServerCollection collection = resourceGroupResource.GetMySqlServers(); - // invoke the operation - string serverName = "mysqltestsvc4"; - bool result = await collection.ExistsAsync(serverName); + // invoke the operation and iterate over the result + await foreach (MySqlServerResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ServerGet() + public async Task GetReplicas_ReplicasListByServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ReplicasListByServer.json + // this example is just showing the usage of "Replicas_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -279,38 +285,33 @@ public async Task GetIfExists_ServerGet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "testrg"; + string resourceGroupName = "TestGroup"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this MySqlServerResource MySqlServerCollection collection = resourceGroupResource.GetMySqlServers(); - // invoke the operation - string serverName = "mysqltestsvc4"; - NullableResponse response = await collection.GetIfExistsAsync(serverName); - MySqlServerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + string serverName = "testmaster"; + await foreach (MySqlServerResource item in collection.GetReplicasAsync(serverName)) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlServerData resourceData = result.Data; + MySqlServerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ServerListByResourceGroup() + public async Task Exists_ServerGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerListByResourceGroup.json - // this example is just showing the usage of "Servers_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -327,25 +328,19 @@ public async Task GetAll_ServerListByResourceGroup() // get the collection of this MySqlServerResource MySqlServerCollection collection = resourceGroupResource.GetMySqlServers(); - // invoke the operation and iterate over the result - await foreach (MySqlServerResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string serverName = "mysqltestsvc4"; + bool result = await collection.ExistsAsync(serverName); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetReplicas_ReplicasListByServer() + public async Task GetIfExists_ServerGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ReplicasListByServer.json - // this example is just showing the usage of "Replicas_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -355,25 +350,30 @@ public async Task GetReplicas_ReplicasListByServer() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - string resourceGroupName = "TestGroup"; + string resourceGroupName = "testrg"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); // get the collection of this MySqlServerResource MySqlServerCollection collection = resourceGroupResource.GetMySqlServers(); - // invoke the operation and iterate over the result - string serverName = "testmaster"; - await foreach (MySqlServerResource item in collection.GetReplicasAsync(serverName)) + // invoke the operation + string serverName = "mysqltestsvc4"; + NullableResponse response = await collection.GetIfExistsAsync(serverName); + MySqlServerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlServerData resourceData = item.Data; + MySqlServerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerKeyCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerKeyCollection.cs index 8dd70ee59247b..eb3634ddc8025 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerKeyCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerKeyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MySqlServerKeyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheKeysForAMySQLServer() + public async Task CreateOrUpdate_CreatesOrUpdatesAMySQLServerKey() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyList.json - // this example is just showing the usage of "ServerKeys_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyCreateOrUpdate.json + // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ListTheKeysForAMySQLServer() // get the collection of this MySqlServerKeyResource MySqlServerKeyCollection collection = mySqlServer.GetMySqlServerKeys(); - // invoke the operation and iterate over the result - await foreach (MySqlServerKeyResource item in collection.GetAllAsync()) + // invoke the operation + string keyName = "someVault_someKey_01234567890123456789012345678901"; + MySqlServerKeyData data = new MySqlServerKeyData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlServerKeyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServerKeyType = MySqlServerKeyType.AzureKeyVault, + Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, data); + MySqlServerKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlServerKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_GetTheMySQLServerKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetTheMySQLServerKey() + public async Task GetAll_ListTheKeysForAMySQLServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyGet.json - // this example is just showing the usage of "ServerKeys_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyList.json + // this example is just showing the usage of "ServerKeys_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +113,22 @@ public async Task Exists_GetTheMySQLServerKey() // get the collection of this MySqlServerKeyResource MySqlServerKeyCollection collection = mySqlServer.GetMySqlServerKeys(); - // invoke the operation - string keyName = "someVault_someKey_01234567890123456789012345678901"; - bool result = await collection.ExistsAsync(keyName); + // invoke the operation and iterate over the result + await foreach (MySqlServerKeyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlServerKeyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetTheMySQLServerKey() + public async Task Exists_GetTheMySQLServerKey() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyGet.json // this example is just showing the usage of "ServerKeys_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_GetTheMySQLServerKey() // invoke the operation string keyName = "someVault_someKey_01234567890123456789012345678901"; - NullableResponse response = await collection.GetIfExistsAsync(keyName); - MySqlServerKeyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(keyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlServerKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatesOrUpdatesAMySQLServerKey() + public async Task GetIfExists_GetTheMySQLServerKey() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyCreateOrUpdate.json - // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyGet.json + // this example is just showing the usage of "ServerKeys_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,19 +181,21 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAMySQLServerKey() // invoke the operation string keyName = "someVault_someKey_01234567890123456789012345678901"; - MySqlServerKeyData data = new MySqlServerKeyData() - { - ServerKeyType = MySqlServerKeyType.AzureKeyVault, - Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, keyName, data); - MySqlServerKeyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(keyName); + MySqlServerKeyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlServerKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlServerKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerKeyResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerKeyResource.cs index b2a24a5ea03a0..6a663008b11c5 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerKeyResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerKeyResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetTheMySQLServerKey() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatesOrUpdatesAMySQLServerKey() + public async Task Delete_DeleteTheMySQLServerKey() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyCreateOrUpdate.json - // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyDelete.json + // this example is just showing the usage of "ServerKeys_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,27 +69,17 @@ public async Task Update_CreatesOrUpdatesAMySQLServerKey() MySqlServerKeyResource mySqlServerKey = client.GetMySqlServerKeyResource(mySqlServerKeyResourceId); // invoke the operation - MySqlServerKeyData data = new MySqlServerKeyData() - { - ServerKeyType = MySqlServerKeyType.AzureKeyVault, - Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), - }; - ArmOperation lro = await mySqlServerKey.UpdateAsync(WaitUntil.Completed, data); - MySqlServerKeyResource result = lro.Value; + await mySqlServerKey.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlServerKeyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteTheMySQLServerKey() + public async Task Update_CreatesOrUpdatesAMySQLServerKey() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyDelete.json - // this example is just showing the usage of "ServerKeys_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2020-01-01/examples/ServerKeyCreateOrUpdate.json + // this example is just showing the usage of "ServerKeys_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +96,19 @@ public async Task Delete_DeleteTheMySQLServerKey() MySqlServerKeyResource mySqlServerKey = client.GetMySqlServerKeyResource(mySqlServerKeyResourceId); // invoke the operation - await mySqlServerKey.DeleteAsync(WaitUntil.Completed); + MySqlServerKeyData data = new MySqlServerKeyData + { + ServerKeyType = MySqlServerKeyType.AzureKeyVault, + Uri = new Uri("https://someVault.vault.azure.net/keys/someKey/01234567890123456789012345678901"), + }; + ArmOperation lro = await mySqlServerKey.UpdateAsync(WaitUntil.Completed, data); + MySqlServerKeyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlServerKeyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerResource.cs index 7636ccc416dc2..4575815c39010 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.MySql.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MySql.Samples @@ -19,10 +18,10 @@ public partial class Sample_MySqlServerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ServerUpdate() + public async Task Get_ServerGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerUpdate.json - // this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerGet.json + // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,13 +37,7 @@ public async Task Update_ServerUpdate() MySqlServerResource mySqlServer = client.GetMySqlServerResource(mySqlServerResourceId); // invoke the operation - MySqlServerPatch patch = new MySqlServerPatch() - { - AdministratorLoginPassword = "", - SslEnforcement = MySqlSslEnforcementEnum.Disabled, - }; - ArmOperation lro = await mySqlServer.UpdateAsync(WaitUntil.Completed, patch); - MySqlServerResource result = lro.Value; + MySqlServerResource result = await mySqlServer.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -81,10 +74,10 @@ public async Task Delete_ServerDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ServerGet() + public async Task Update_ServerUpdate() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerGet.json - // this example is just showing the usage of "Servers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerUpdate.json + // this example is just showing the usage of "Servers_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,7 +93,13 @@ public async Task Get_ServerGet() MySqlServerResource mySqlServer = client.GetMySqlServerResource(mySqlServerResourceId); // invoke the operation - MySqlServerResource result = await mySqlServer.GetAsync(); + MySqlServerPatch patch = new MySqlServerPatch + { + AdministratorLoginPassword = "", + SslEnforcement = MySqlSslEnforcementEnum.Disabled, + }; + ArmOperation lro = await mySqlServer.UpdateAsync(WaitUntil.Completed, patch); + MySqlServerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -109,37 +108,6 @@ public async Task Get_ServerGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetMySqlServers_ServerList() - { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerList.json - // this example is just showing the usage of "Servers_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (MySqlServerResource item in subscriptionResource.GetMySqlServersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlServerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Restart_ServerRestart() @@ -377,7 +345,7 @@ public async Task Upgrade_ServerUpgrade() MySqlServerResource mySqlServer = client.GetMySqlServerResource(mySqlServerResourceId); // invoke the operation - MySqlServerUpgradeContent content = new MySqlServerUpgradeContent() + MySqlServerUpgradeContent content = new MySqlServerUpgradeContent { TargetServerVersion = "5.7", }; diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerSecurityAlertPolicyCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerSecurityAlertPolicyCollection.cs index 286ff50bf5ca0..e8e563e27d076 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerSecurityAlertPolicyCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerSecurityAlertPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_MySqlServerSecurityAlertPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAServerSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsGet.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsCreateMax.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_GetAServerSThreatDetectionPolicy() // invoke the operation MySqlSecurityAlertPolicyName securityAlertPolicyName = MySqlSecurityAlertPolicyName.Default; - MySqlServerSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); + MySqlServerSecurityAlertPolicyData data = new MySqlServerSecurityAlertPolicyData + { + State = MySqlServerSecurityAlertPolicyState.Enabled, + DisabledAlerts = { "Access_Anomaly", "Usage_Anomaly" }, + EmailAddresses = { "testSecurityAlert@microsoft.com" }, + SendToEmailAccountAdmins = true, + StorageEndpoint = "https://mystorage.blob.core.windows.net", + StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", + RetentionDays = 5, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + MySqlServerSecurityAlertPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +63,10 @@ public async Task Get_GetAServerSThreatDetectionPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAServerSThreatDetectionPolicy() + public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsGet.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsCreateMin.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,14 +86,24 @@ public async Task Exists_GetAServerSThreatDetectionPolicy() // invoke the operation MySqlSecurityAlertPolicyName securityAlertPolicyName = MySqlSecurityAlertPolicyName.Default; - bool result = await collection.ExistsAsync(securityAlertPolicyName); + MySqlServerSecurityAlertPolicyData data = new MySqlServerSecurityAlertPolicyData + { + State = MySqlServerSecurityAlertPolicyState.Disabled, + SendToEmailAccountAdmins = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); + MySqlServerSecurityAlertPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAServerSThreatDetectionPolicy() + public async Task Get_GetAServerSThreatDetectionPolicy() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsGet.json // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +126,21 @@ public async Task GetIfExists_GetAServerSThreatDetectionPolicy() // invoke the operation MySqlSecurityAlertPolicyName securityAlertPolicyName = MySqlSecurityAlertPolicyName.Default; - NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); - MySqlServerSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + MySqlServerSecurityAlertPolicyResource result = await collection.GetAsync(securityAlertPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlServerSecurityAlertPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParameters() + public async Task GetAll_ListTheServerSThreatDetectionPolicies() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsCreateMax.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsListByServer.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,40 +158,25 @@ public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithAllParam // get the collection of this MySqlServerSecurityAlertPolicyResource MySqlServerSecurityAlertPolicyCollection collection = mySqlServer.GetMySqlServerSecurityAlertPolicies(); - // invoke the operation - MySqlSecurityAlertPolicyName securityAlertPolicyName = MySqlSecurityAlertPolicyName.Default; - MySqlServerSecurityAlertPolicyData data = new MySqlServerSecurityAlertPolicyData() + // invoke the operation and iterate over the result + await foreach (MySqlServerSecurityAlertPolicyResource item in collection.GetAllAsync()) { - State = MySqlServerSecurityAlertPolicyState.Enabled, - DisabledAlerts = -{ -"Access_Anomaly","Usage_Anomaly" -}, - EmailAddresses = -{ -"testSecurityAlert@microsoft.com" -}, - SendToEmailAccountAdmins = true, - StorageEndpoint = "https://mystorage.blob.core.windows.net", - StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", - RetentionDays = 5, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - MySqlServerSecurityAlertPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlServerSecurityAlertPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalParameters() + public async Task Exists_GetAServerSThreatDetectionPolicy() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsCreateMin.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsGet.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -198,27 +196,17 @@ public async Task CreateOrUpdate_UpdateAServerSThreatDetectionPolicyWithMinimalP // invoke the operation MySqlSecurityAlertPolicyName securityAlertPolicyName = MySqlSecurityAlertPolicyName.Default; - MySqlServerSecurityAlertPolicyData data = new MySqlServerSecurityAlertPolicyData() - { - State = MySqlServerSecurityAlertPolicyState.Disabled, - SendToEmailAccountAdmins = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityAlertPolicyName, data); - MySqlServerSecurityAlertPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(securityAlertPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlServerSecurityAlertPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListTheServerSThreatDetectionPolicies() + public async Task GetIfExists_GetAServerSThreatDetectionPolicy() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsListByServer.json - // this example is just showing the usage of "ServerSecurityAlertPolicies_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/ServerSecurityAlertsGet.json + // this example is just showing the usage of "ServerSecurityAlertPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -236,17 +224,23 @@ public async Task GetAll_ListTheServerSThreatDetectionPolicies() // get the collection of this MySqlServerSecurityAlertPolicyResource MySqlServerSecurityAlertPolicyCollection collection = mySqlServer.GetMySqlServerSecurityAlertPolicies(); - // invoke the operation and iterate over the result - await foreach (MySqlServerSecurityAlertPolicyResource item in collection.GetAllAsync()) + // invoke the operation + MySqlSecurityAlertPolicyName securityAlertPolicyName = MySqlSecurityAlertPolicyName.Default; + NullableResponse response = await collection.GetIfExistsAsync(securityAlertPolicyName); + MySqlServerSecurityAlertPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlServerSecurityAlertPolicyData resourceData = item.Data; + MySqlServerSecurityAlertPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerSecurityAlertPolicyResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerSecurityAlertPolicyResource.cs index 484a4b61a338f..1b3aaee06a89f 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerSecurityAlertPolicyResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlServerSecurityAlertPolicyResource.cs @@ -69,17 +69,11 @@ public async Task Update_UpdateAServerSThreatDetectionPolicyWithAllParameters() MySqlServerSecurityAlertPolicyResource mySqlServerSecurityAlertPolicy = client.GetMySqlServerSecurityAlertPolicyResource(mySqlServerSecurityAlertPolicyResourceId); // invoke the operation - MySqlServerSecurityAlertPolicyData data = new MySqlServerSecurityAlertPolicyData() + MySqlServerSecurityAlertPolicyData data = new MySqlServerSecurityAlertPolicyData { State = MySqlServerSecurityAlertPolicyState.Enabled, - DisabledAlerts = -{ -"Access_Anomaly","Usage_Anomaly" -}, - EmailAddresses = -{ -"testSecurityAlert@microsoft.com" -}, + DisabledAlerts = { "Access_Anomaly", "Usage_Anomaly" }, + EmailAddresses = { "testSecurityAlert@microsoft.com" }, SendToEmailAccountAdmins = true, StorageEndpoint = "https://mystorage.blob.core.windows.net", StorageAccountAccessKey = "sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==", @@ -117,7 +111,7 @@ public async Task Update_UpdateAServerSThreatDetectionPolicyWithMinimalParameter MySqlServerSecurityAlertPolicyResource mySqlServerSecurityAlertPolicy = client.GetMySqlServerSecurityAlertPolicyResource(mySqlServerSecurityAlertPolicyResourceId); // invoke the operation - MySqlServerSecurityAlertPolicyData data = new MySqlServerSecurityAlertPolicyData() + MySqlServerSecurityAlertPolicyData data = new MySqlServerSecurityAlertPolicyData { State = MySqlServerSecurityAlertPolicyState.Disabled, SendToEmailAccountAdmins = true, diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlVirtualNetworkRuleCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlVirtualNetworkRuleCollection.cs index 1213a0aba54fc..fc81465aa767f 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlVirtualNetworkRuleCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlVirtualNetworkRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_MySqlVirtualNetworkRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAVirtualNetworkRule() + public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesGet.json - // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesCreateOrUpdate.json + // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,13 @@ public async Task Get_GetsAVirtualNetworkRule() // invoke the operation string virtualNetworkRuleName = "vnet-firewall-rule"; - MySqlVirtualNetworkRuleResource result = await collection.GetAsync(virtualNetworkRuleName); + MySqlVirtualNetworkRuleData data = new MySqlVirtualNetworkRuleData + { + VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + IgnoreMissingVnetServiceEndpoint = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkRuleName, data); + MySqlVirtualNetworkRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +57,7 @@ public async Task Get_GetsAVirtualNetworkRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAVirtualNetworkRule() + public async Task Get_GetsAVirtualNetworkRule() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesGet.json // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +80,21 @@ public async Task Exists_GetsAVirtualNetworkRule() // invoke the operation string virtualNetworkRuleName = "vnet-firewall-rule"; - bool result = await collection.ExistsAsync(virtualNetworkRuleName); + MySqlVirtualNetworkRuleResource result = await collection.GetAsync(virtualNetworkRuleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlVirtualNetworkRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAVirtualNetworkRule() + public async Task GetAll_ListVirtualNetworkRules() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesGet.json - // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesList.json + // this example is just showing the usage of "VirtualNetworkRules_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +112,25 @@ public async Task GetIfExists_GetsAVirtualNetworkRule() // get the collection of this MySqlVirtualNetworkRuleResource MySqlVirtualNetworkRuleCollection collection = mySqlServer.GetMySqlVirtualNetworkRules(); - // invoke the operation - string virtualNetworkRuleName = "vnet-firewall-rule"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkRuleName); - MySqlVirtualNetworkRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (MySqlVirtualNetworkRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlVirtualNetworkRuleData resourceData = result.Data; + MySqlVirtualNetworkRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() + public async Task Exists_GetsAVirtualNetworkRule() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesCreateOrUpdate.json - // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesGet.json + // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,27 +150,17 @@ public async Task CreateOrUpdate_CreateOrUpdateAVirtualNetworkRule() // invoke the operation string virtualNetworkRuleName = "vnet-firewall-rule"; - MySqlVirtualNetworkRuleData data = new MySqlVirtualNetworkRuleData() - { - VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), - IgnoreMissingVnetServiceEndpoint = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkRuleName, data); - MySqlVirtualNetworkRuleResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualNetworkRuleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlVirtualNetworkRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworkRules() + public async Task GetIfExists_GetsAVirtualNetworkRule() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesList.json - // this example is just showing the usage of "VirtualNetworkRules_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesGet.json + // this example is just showing the usage of "VirtualNetworkRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListVirtualNetworkRules() // get the collection of this MySqlVirtualNetworkRuleResource MySqlVirtualNetworkRuleCollection collection = mySqlServer.GetMySqlVirtualNetworkRules(); - // invoke the operation and iterate over the result - await foreach (MySqlVirtualNetworkRuleResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkRuleName = "vnet-firewall-rule"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkRuleName); + MySqlVirtualNetworkRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlVirtualNetworkRuleData resourceData = item.Data; + MySqlVirtualNetworkRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlVirtualNetworkRuleResource.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlVirtualNetworkRuleResource.cs index 0d1ceffbd743d..88f3d8e0ba6da 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlVirtualNetworkRuleResource.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlVirtualNetworkRuleResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetsAVirtualNetworkRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAVirtualNetworkRule() + public async Task Delete_DeleteAVirtualNetworkRule() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesCreateOrUpdate.json - // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesDelete.json + // this example is just showing the usage of "VirtualNetworkRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,27 +68,17 @@ public async Task Update_CreateOrUpdateAVirtualNetworkRule() MySqlVirtualNetworkRuleResource mySqlVirtualNetworkRule = client.GetMySqlVirtualNetworkRuleResource(mySqlVirtualNetworkRuleResourceId); // invoke the operation - MySqlVirtualNetworkRuleData data = new MySqlVirtualNetworkRuleData() - { - VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), - IgnoreMissingVnetServiceEndpoint = false, - }; - ArmOperation lro = await mySqlVirtualNetworkRule.UpdateAsync(WaitUntil.Completed, data); - MySqlVirtualNetworkRuleResource result = lro.Value; + await mySqlVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlVirtualNetworkRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAVirtualNetworkRule() + public async Task Update_CreateOrUpdateAVirtualNetworkRule() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesDelete.json - // this example is just showing the usage of "VirtualNetworkRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2017-12-01/examples/VirtualNetworkRulesCreateOrUpdate.json + // this example is just showing the usage of "VirtualNetworkRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,9 +95,19 @@ public async Task Delete_DeleteAVirtualNetworkRule() MySqlVirtualNetworkRuleResource mySqlVirtualNetworkRule = client.GetMySqlVirtualNetworkRuleResource(mySqlVirtualNetworkRuleResourceId); // invoke the operation - await mySqlVirtualNetworkRule.DeleteAsync(WaitUntil.Completed); + MySqlVirtualNetworkRuleData data = new MySqlVirtualNetworkRuleData + { + VirtualNetworkSubnetId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/TestGroup/providers/Microsoft.Network/virtualNetworks/testvnet/subnets/testsubnet"), + IgnoreMissingVnetServiceEndpoint = false, + }; + ArmOperation lro = await mySqlVirtualNetworkRule.UpdateAsync(WaitUntil.Completed, data); + MySqlVirtualNetworkRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlVirtualNetworkRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlWaitStatisticCollection.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlWaitStatisticCollection.cs index 8694162fe184c..a189ec8a64972 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlWaitStatisticCollection.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_MySqlWaitStatisticCollection.cs @@ -52,10 +52,10 @@ public async Task Get_WaitStatisticsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_WaitStatisticsGet() + public async Task GetAll_WaitStatisticsListByServer() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/WaitStatisticsGet.json - // this example is just showing the usage of "WaitStatistics_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/WaitStatisticsListByServer.json + // this example is just showing the usage of "WaitStatistics_ListByServer" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,16 +73,23 @@ public async Task Exists_WaitStatisticsGet() // get the collection of this MySqlWaitStatisticResource MySqlWaitStatisticCollection collection = mySqlServer.GetMySqlWaitStatistics(); - // invoke the operation - string waitStatisticsId = "636927606000000000-636927615000000000-send-wait/io/socket/sql/client_connection-2--0"; - bool result = await collection.ExistsAsync(waitStatisticsId); + // invoke the operation and iterate over the result + MySqlWaitStatisticsInput input = new MySqlWaitStatisticsInput(DateTimeOffset.Parse("2019-05-01T20:00:00.000Z"), DateTimeOffset.Parse("2019-05-07T20:00:00.000Z"), "PT15M"); + await foreach (MySqlWaitStatisticResource item in collection.GetAllAsync(input)) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlWaitStatisticData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_WaitStatisticsGet() + public async Task Exists_WaitStatisticsGet() { // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/WaitStatisticsGet.json // this example is just showing the usage of "WaitStatistics_Get" operation, for the dependent resources, they will have to be created separately. @@ -105,29 +112,17 @@ public async Task GetIfExists_WaitStatisticsGet() // invoke the operation string waitStatisticsId = "636927606000000000-636927615000000000-send-wait/io/socket/sql/client_connection-2--0"; - NullableResponse response = await collection.GetIfExistsAsync(waitStatisticsId); - MySqlWaitStatisticResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(waitStatisticsId); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - MySqlWaitStatisticData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_WaitStatisticsListByServer() + public async Task GetIfExists_WaitStatisticsGet() { - // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/WaitStatisticsListByServer.json - // this example is just showing the usage of "WaitStatistics_ListByServer" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/legacy/stable/2018-06-01/examples/WaitStatisticsGet.json + // this example is just showing the usage of "WaitStatistics_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,18 +140,23 @@ public async Task GetAll_WaitStatisticsListByServer() // get the collection of this MySqlWaitStatisticResource MySqlWaitStatisticCollection collection = mySqlServer.GetMySqlWaitStatistics(); - // invoke the operation and iterate over the result - MySqlWaitStatisticsInput input = new MySqlWaitStatisticsInput(DateTimeOffset.Parse("2019-05-01T20:00:00.000Z"), DateTimeOffset.Parse("2019-05-07T20:00:00.000Z"), "PT15M"); - await foreach (MySqlWaitStatisticResource item in collection.GetAllAsync(input)) + // invoke the operation + string waitStatisticsId = "636927606000000000-636927615000000000-send-wait/io/socket/sql/client_connection-2--0"; + NullableResponse response = await collection.GetIfExistsAsync(waitStatisticsId); + MySqlWaitStatisticResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - MySqlWaitStatisticData resourceData = item.Data; + MySqlWaitStatisticData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index ffd87ab98324c..89935669b3f93 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -17,6 +17,37 @@ namespace Azure.ResourceManager.MySql.FlexibleServers.Samples { public partial class Sample_SubscriptionResourceExtensions { + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetMySqlFlexibleServers_ListServersInASubscription() + { + // Generated from example definition: specification/mysql/resource-manager/Microsoft.DBforMySQL/FlexibleServers/stable/2023-12-30/examples/ServersList.json + // this example is just showing the usage of "Servers_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (MySqlFlexibleServerResource item in subscriptionResource.GetMySqlFlexibleServersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + MySqlFlexibleServerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetLocationBasedCapabilities_CapabilitiesList() @@ -65,7 +96,7 @@ public async Task ExecuteCheckVirtualNetworkSubnetUsage_CheckVirtualNetworkSubne // invoke the operation AzureLocation locationName = new AzureLocation("WestUS"); - MySqlFlexibleServerVirtualNetworkSubnetUsageParameter mySqlFlexibleServerVirtualNetworkSubnetUsageParameter = new MySqlFlexibleServerVirtualNetworkSubnetUsageParameter() + MySqlFlexibleServerVirtualNetworkSubnetUsageParameter mySqlFlexibleServerVirtualNetworkSubnetUsageParameter = new MySqlFlexibleServerVirtualNetworkSubnetUsageParameter { VirtualNetworkResourceId = new ResourceIdentifier("/subscriptions/ffffffff-ffff-ffff-ffff-ffffffffffff/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworks/testvnet"), }; diff --git a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_TenantResourceExtensions.cs b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_TenantResourceExtensions.cs index fc7277af102cc..d62b8f6e4adab 100644 --- a/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_TenantResourceExtensions.cs +++ b/sdk/mysql/Azure.ResourceManager.MySql/samples/Generated/Samples/Sample_TenantResourceExtensions.cs @@ -10,6 +10,7 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.MySql.FlexibleServers.Models; +using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.MySql.FlexibleServers.Samples @@ -28,9 +29,7 @@ public async Task ExecuteGetPrivateDnsZoneSuffix_GetPrivateDnsZoneSuffix() // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this TenantResource created on azure - // for more information of creating TenantResource, please refer to the document of TenantResource - var tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; + TenantResource tenantResource = client.GetTenants().GetAllAsync().GetAsyncEnumerator().Current; // invoke the operation MySqlFlexibleServerPrivateDnsZoneSuffixResponse result = await tenantResource.ExecuteGetPrivateDnsZoneSuffixAsync(); diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_CapacityPoolCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_CapacityPoolCollection.cs index 9f142edc59238..8d3997c0f8902 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_CapacityPoolCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_CapacityPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CapacityPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_PoolsList() + public async Task CreateOrUpdate_PoolsCreateOrUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_List.json - // this example is just showing the usage of "Pools_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_CreateOrUpdate.json + // this example is just showing the usage of "Pools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_PoolsList() // get the collection of this CapacityPoolResource CapacityPoolCollection collection = netAppAccount.GetCapacityPools(); - // invoke the operation and iterate over the result - await foreach (CapacityPoolResource item in collection.GetAllAsync()) + // invoke the operation + string poolName = "pool1"; + CapacityPoolData data = new CapacityPoolData(new AzureLocation("eastus"), 4398046511104L, NetAppFileServiceLevel.Premium) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CapacityPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + QosType = CapacityPoolQosType.Auto, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data); + CapacityPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CapacityPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +91,10 @@ public async Task Get_PoolsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PoolsGet() + public async Task GetAll_PoolsList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_Get.json - // this example is just showing the usage of "Pools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_List.json + // this example is just showing the usage of "Pools_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +112,22 @@ public async Task Exists_PoolsGet() // get the collection of this CapacityPoolResource CapacityPoolCollection collection = netAppAccount.GetCapacityPools(); - // invoke the operation - string poolName = "pool1"; - bool result = await collection.ExistsAsync(poolName); + // invoke the operation and iterate over the result + await foreach (CapacityPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CapacityPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PoolsGet() + public async Task Exists_PoolsGet() { // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_Get.json // this example is just showing the usage of "Pools_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +150,17 @@ public async Task GetIfExists_PoolsGet() // invoke the operation string poolName = "pool1"; - NullableResponse response = await collection.GetIfExistsAsync(poolName); - CapacityPoolResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(poolName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CapacityPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PoolsCreateOrUpdate() + public async Task GetIfExists_PoolsGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_CreateOrUpdate.json - // this example is just showing the usage of "Pools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_Get.json + // this example is just showing the usage of "Pools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,18 +180,21 @@ public async Task CreateOrUpdate_PoolsCreateOrUpdate() // invoke the operation string poolName = "pool1"; - CapacityPoolData data = new CapacityPoolData(new AzureLocation("eastus"), 4398046511104L, NetAppFileServiceLevel.Premium) - { - QosType = CapacityPoolQosType.Auto, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, poolName, data); - CapacityPoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(poolName); + CapacityPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CapacityPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CapacityPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_CapacityPoolResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_CapacityPoolResource.cs index c2cd2ecc4af70..cb66445c2239e 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_CapacityPoolResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_CapacityPoolResource.cs @@ -49,10 +49,10 @@ public async Task Get_PoolsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PoolsUpdate() + public async Task Delete_PoolsDelete() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_Update.json - // this example is just showing the usage of "Pools_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_Delete.json + // this example is just showing the usage of "Pools_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,23 +69,17 @@ public async Task Update_PoolsUpdate() CapacityPoolResource capacityPool = client.GetCapacityPoolResource(capacityPoolResourceId); // invoke the operation - CapacityPoolPatch patch = new CapacityPoolPatch(new AzureLocation("placeholder")); - ArmOperation lro = await capacityPool.UpdateAsync(WaitUntil.Completed, patch); - CapacityPoolResource result = lro.Value; + await capacityPool.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CapacityPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_PoolsDelete() + public async Task Update_PoolsUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_Delete.json - // this example is just showing the usage of "Pools_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Pools_Update.json + // this example is just showing the usage of "Pools_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,9 +96,15 @@ public async Task Delete_PoolsDelete() CapacityPoolResource capacityPool = client.GetCapacityPoolResource(capacityPoolResourceId); // invoke the operation - await capacityPool.DeleteAsync(WaitUntil.Completed); + CapacityPoolPatch patch = new CapacityPoolPatch(default); + ArmOperation lro = await capacityPool.UpdateAsync(WaitUntil.Completed, patch); + CapacityPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CapacityPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppAccountCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppAccountCollection.cs index 069401f91a9a0..62ca33c85ae19 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppAccountCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppAccountCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetAppAccountCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_AccountsList() + public async Task CreateOrUpdate_AccountsCreateOrUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_List.json - // this example is just showing the usage of "Accounts_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_CreateOrUpdate.json + // this example is just showing the usage of "Accounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,25 @@ public async Task GetAll_AccountsList() // get the collection of this NetAppAccountResource NetAppAccountCollection collection = resourceGroupResource.GetNetAppAccounts(); - // invoke the operation and iterate over the result - await foreach (NetAppAccountResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string accountName = "account1"; + NetAppAccountData data = new NetAppAccountData(new AzureLocation("eastus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + NetAppAccountResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_AccountsGet() + public async Task CreateOrUpdate_AccountsCreateOrUpdateWithActiveDirectory() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_Get.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_CreateOrUpdateAD.json + // this example is just showing the usage of "Accounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,7 +76,24 @@ public async Task Get_AccountsGet() // invoke the operation string accountName = "account1"; - NetAppAccountResource result = await collection.GetAsync(accountName); + NetAppAccountData data = new NetAppAccountData(new AzureLocation("eastus")) + { + ActiveDirectories = {new NetAppAccountActiveDirectory +{ +Username = "ad_user_name", +Password = "ad_password", +Domain = "10.10.10.3", +Dns = "10.10.10.3", +SmbServerName = "SMBServer", +OrganizationalUnit = "OU=Engineering", +Site = "SiteName", +IsAesEncryptionEnabled = true, +IsLdapSigningEnabled = false, +IsLdapOverTlsEnabled = false, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); + NetAppAccountResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -87,7 +104,7 @@ public async Task Get_AccountsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_AccountsGet() + public async Task Get_AccountsGet() { // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_Get.json // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. @@ -109,17 +126,21 @@ public async Task Exists_AccountsGet() // invoke the operation string accountName = "account1"; - bool result = await collection.ExistsAsync(accountName); + NetAppAccountResource result = await collection.GetAsync(accountName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_AccountsGet() + public async Task GetAll_AccountsList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_Get.json - // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_List.json + // this example is just showing the usage of "Accounts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,31 +157,25 @@ public async Task GetIfExists_AccountsGet() // get the collection of this NetAppAccountResource NetAppAccountCollection collection = resourceGroupResource.GetNetAppAccounts(); - // invoke the operation - string accountName = "account1"; - NullableResponse response = await collection.GetIfExistsAsync(accountName); - NetAppAccountResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NetAppAccountResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetAppAccountData resourceData = result.Data; + NetAppAccountData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AccountsCreateOrUpdate() + public async Task Exists_AccountsGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_CreateOrUpdate.json - // this example is just showing the usage of "Accounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_Get.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,23 +194,17 @@ public async Task CreateOrUpdate_AccountsCreateOrUpdate() // invoke the operation string accountName = "account1"; - NetAppAccountData data = new NetAppAccountData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); - NetAppAccountResource result = lro.Value; + bool result = await collection.ExistsAsync(accountName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_AccountsCreateOrUpdateWithActiveDirectory() + public async Task GetIfExists_AccountsGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_CreateOrUpdateAD.json - // this example is just showing the usage of "Accounts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_Get.json + // this example is just showing the usage of "Accounts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -214,33 +223,21 @@ public async Task CreateOrUpdate_AccountsCreateOrUpdateWithActiveDirectory() // invoke the operation string accountName = "account1"; - NetAppAccountData data = new NetAppAccountData(new AzureLocation("eastus")) - { - ActiveDirectories = -{ -new NetAppAccountActiveDirectory() -{ -Username = "ad_user_name", -Password = "ad_password", -Domain = "10.10.10.3", -Dns = "10.10.10.3", -SmbServerName = "SMBServer", -OrganizationalUnit = "OU=Engineering", -Site = "SiteName", -IsAesEncryptionEnabled = true, -IsLdapSigningEnabled = false, -IsLdapOverTlsEnabled = false, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, accountName, data); - NetAppAccountResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(accountName); + NetAppAccountResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppAccountData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppAccountData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppAccountResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppAccountResource.cs index cf549a8970340..4eb38595b5d0a 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppAccountResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppAccountResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.NetApp.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.NetApp.Samples { public partial class Sample_NetAppAccountResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetAppAccounts_AccountsList() - { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_List.json - // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetAppAccountResource item in subscriptionResource.GetNetAppAccountsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppAccountData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_AccountsGet() @@ -125,11 +93,11 @@ public async Task Update_AccountsUpdate() NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); // invoke the operation - NetAppAccountPatch patch = new NetAppAccountPatch(new AzureLocation("placeholder")) + NetAppAccountPatch patch = new NetAppAccountPatch(default) { Tags = { -["Tag1"] = "Value1", +["Tag1"] = "Value1" }, }; ArmOperation lro = await netAppAccount.UpdateAsync(WaitUntil.Completed, patch); diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupPolicyCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupPolicyCollection.cs index b443bd9e05c0a..7ad8d28516ff0 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupPolicyCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupPolicyCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetAppBackupPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BackupPoliciesList() + public async Task CreateOrUpdate_BackupPoliciesCreate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_List.json - // this example is just showing the usage of "BackupPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_Create.json + // this example is just showing the usage of "BackupPolicies_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,23 @@ public async Task GetAll_BackupPoliciesList() // get the collection of this NetAppBackupPolicyResource NetAppBackupPolicyCollection collection = netAppAccount.GetNetAppBackupPolicies(); - // invoke the operation and iterate over the result - await foreach (NetAppBackupPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string backupPolicyName = "backupPolicyName"; + NetAppBackupPolicyData data = new NetAppBackupPolicyData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + DailyBackupsToKeep = 10, + WeeklyBackupsToKeep = 10, + MonthlyBackupsToKeep = 10, + IsEnabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backupPolicyName, data); + NetAppBackupPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +93,10 @@ public async Task Get_BackupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BackupsGet() + public async Task GetAll_BackupPoliciesList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_Get.json - // this example is just showing the usage of "BackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_List.json + // this example is just showing the usage of "BackupPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +114,22 @@ public async Task Exists_BackupsGet() // get the collection of this NetAppBackupPolicyResource NetAppBackupPolicyCollection collection = netAppAccount.GetNetAppBackupPolicies(); - // invoke the operation - string backupPolicyName = "backupPolicyName"; - bool result = await collection.ExistsAsync(backupPolicyName); + // invoke the operation and iterate over the result + await foreach (NetAppBackupPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BackupsGet() + public async Task Exists_BackupsGet() { // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_Get.json // this example is just showing the usage of "BackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +152,17 @@ public async Task GetIfExists_BackupsGet() // invoke the operation string backupPolicyName = "backupPolicyName"; - NullableResponse response = await collection.GetIfExistsAsync(backupPolicyName); - NetAppBackupPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(backupPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BackupPoliciesCreate() + public async Task GetIfExists_BackupsGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_Create.json - // this example is just showing the usage of "BackupPolicies_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_Get.json + // this example is just showing the usage of "BackupPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,21 +182,21 @@ public async Task CreateOrUpdate_BackupPoliciesCreate() // invoke the operation string backupPolicyName = "backupPolicyName"; - NetAppBackupPolicyData data = new NetAppBackupPolicyData(new AzureLocation("westus")) - { - DailyBackupsToKeep = 10, - WeeklyBackupsToKeep = 10, - MonthlyBackupsToKeep = 10, - IsEnabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backupPolicyName, data); - NetAppBackupPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(backupPolicyName); + NetAppBackupPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupPolicyResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupPolicyResource.cs index 6c25403de41b7..9b82b627358f9 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupPolicyResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupPolicyResource.cs @@ -49,10 +49,10 @@ public async Task Get_BackupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BackupPoliciesUpdate() + public async Task Delete_BackupPoliciesDelete() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_Update.json - // this example is just showing the usage of "BackupPolicies_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_Delete.json + // this example is just showing the usage of "BackupPolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,36 +62,24 @@ public async Task Update_BackupPoliciesUpdate() // this example assumes you already have this NetAppBackupPolicyResource created on azure // for more information of creating NetAppBackupPolicyResource, please refer to the document of NetAppBackupPolicyResource string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "myRG"; - string accountName = "account1"; + string resourceGroupName = "resourceGroup"; + string accountName = "accountName"; string backupPolicyName = "backupPolicyName"; ResourceIdentifier netAppBackupPolicyResourceId = NetAppBackupPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, backupPolicyName); NetAppBackupPolicyResource netAppBackupPolicy = client.GetNetAppBackupPolicyResource(netAppBackupPolicyResourceId); // invoke the operation - NetAppBackupPolicyPatch patch = new NetAppBackupPolicyPatch(new AzureLocation("westus")) - { - DailyBackupsToKeep = 5, - WeeklyBackupsToKeep = 10, - MonthlyBackupsToKeep = 10, - IsEnabled = false, - }; - ArmOperation lro = await netAppBackupPolicy.UpdateAsync(WaitUntil.Completed, patch); - NetAppBackupPolicyResource result = lro.Value; + await netAppBackupPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BackupPoliciesDelete() + public async Task Update_BackupPoliciesUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_Delete.json - // this example is just showing the usage of "BackupPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupPolicies_Update.json + // this example is just showing the usage of "BackupPolicies_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,16 +89,28 @@ public async Task Delete_BackupPoliciesDelete() // this example assumes you already have this NetAppBackupPolicyResource created on azure // for more information of creating NetAppBackupPolicyResource, please refer to the document of NetAppBackupPolicyResource string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "resourceGroup"; - string accountName = "accountName"; + string resourceGroupName = "myRG"; + string accountName = "account1"; string backupPolicyName = "backupPolicyName"; ResourceIdentifier netAppBackupPolicyResourceId = NetAppBackupPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, backupPolicyName); NetAppBackupPolicyResource netAppBackupPolicy = client.GetNetAppBackupPolicyResource(netAppBackupPolicyResourceId); // invoke the operation - await netAppBackupPolicy.DeleteAsync(WaitUntil.Completed); + NetAppBackupPolicyPatch patch = new NetAppBackupPolicyPatch(new AzureLocation("westus")) + { + DailyBackupsToKeep = 5, + WeeklyBackupsToKeep = 10, + MonthlyBackupsToKeep = 10, + IsEnabled = false, + }; + ArmOperation lro = await netAppBackupPolicy.UpdateAsync(WaitUntil.Completed, patch); + NetAppBackupPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultBackupCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultBackupCollection.cs index a1e0c39a6f5d5..513a172a2db67 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultBackupCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultBackupCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetAppBackupVaultBackupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BackupsList() + public async Task CreateOrUpdate_BackupsUnderBackupVaultCreate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_List.json - // this example is just showing the usage of "Backups_ListByVault" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_Create.json + // this example is just showing the usage of "Backups_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_BackupsList() // get the collection of this NetAppBackupVaultBackupResource NetAppBackupVaultBackupCollection collection = netAppBackupVault.GetNetAppBackupVaultBackups(); - // invoke the operation and iterate over the result - await foreach (NetAppBackupVaultBackupResource item in collection.GetAllAsync()) + // invoke the operation + string backupName = "backup1"; + NetAppBackupData data = new NetAppBackupData(new ResourceIdentifier("/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPool/pool1/volumes/volume1")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Label = "myLabel", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backupName, data); + NetAppBackupVaultBackupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -89,10 +92,10 @@ public async Task Get_BackupsUnderBackupVaultGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BackupsUnderBackupVaultGet() + public async Task GetAll_BackupsList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_Get.json - // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_List.json + // this example is just showing the usage of "Backups_ListByVault" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,16 +114,22 @@ public async Task Exists_BackupsUnderBackupVaultGet() // get the collection of this NetAppBackupVaultBackupResource NetAppBackupVaultBackupCollection collection = netAppBackupVault.GetNetAppBackupVaultBackups(); - // invoke the operation - string backupName = "backup1"; - bool result = await collection.ExistsAsync(backupName); + // invoke the operation and iterate over the result + await foreach (NetAppBackupVaultBackupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BackupsUnderBackupVaultGet() + public async Task Exists_BackupsUnderBackupVaultGet() { // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_Get.json // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. @@ -144,29 +153,17 @@ public async Task GetIfExists_BackupsUnderBackupVaultGet() // invoke the operation string backupName = "backup1"; - NullableResponse response = await collection.GetIfExistsAsync(backupName); - NetAppBackupVaultBackupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(backupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BackupsUnderBackupVaultCreate() + public async Task GetIfExists_BackupsUnderBackupVaultGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_Create.json - // this example is just showing the usage of "Backups_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_Get.json + // this example is just showing the usage of "Backups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,18 +184,21 @@ public async Task CreateOrUpdate_BackupsUnderBackupVaultCreate() // invoke the operation string backupName = "backup1"; - NetAppBackupData data = new NetAppBackupData(new ResourceIdentifier("/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPool/pool1/volumes/volume1")) - { - Label = "myLabel", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backupName, data); - NetAppBackupVaultBackupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(backupName); + NetAppBackupVaultBackupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultBackupResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultBackupResource.cs index 115687db6bd94..9686d969aa88c 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultBackupResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultBackupResource.cs @@ -50,10 +50,10 @@ public async Task Get_BackupsUnderBackupVaultGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BackupsUnderBackupVaultUpdate() + public async Task Delete_BackupsUnderBackupVaultDelete() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_Update.json - // this example is just showing the usage of "Backups_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_Delete.json + // this example is just showing the usage of "Backups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,7 +63,7 @@ public async Task Update_BackupsUnderBackupVaultUpdate() // this example assumes you already have this NetAppBackupVaultBackupResource created on azure // for more information of creating NetAppBackupVaultBackupResource, please refer to the document of NetAppBackupVaultBackupResource string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "myRG"; + string resourceGroupName = "resourceGroup"; string accountName = "account1"; string backupVaultName = "backupVault1"; string backupName = "backup1"; @@ -71,23 +71,17 @@ public async Task Update_BackupsUnderBackupVaultUpdate() NetAppBackupVaultBackupResource netAppBackupVaultBackup = client.GetNetAppBackupVaultBackupResource(netAppBackupVaultBackupResourceId); // invoke the operation - NetAppBackupVaultBackupPatch patch = new NetAppBackupVaultBackupPatch(); - ArmOperation lro = await netAppBackupVaultBackup.UpdateAsync(WaitUntil.Completed, patch); - NetAppBackupVaultBackupResource result = lro.Value; + await netAppBackupVaultBackup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BackupsUnderBackupVaultDelete() + public async Task Update_BackupsUnderBackupVaultUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_Delete.json - // this example is just showing the usage of "Backups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupsUnderBackupVault_Update.json + // this example is just showing the usage of "Backups_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -97,7 +91,7 @@ public async Task Delete_BackupsUnderBackupVaultDelete() // this example assumes you already have this NetAppBackupVaultBackupResource created on azure // for more information of creating NetAppBackupVaultBackupResource, please refer to the document of NetAppBackupVaultBackupResource string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "resourceGroup"; + string resourceGroupName = "myRG"; string accountName = "account1"; string backupVaultName = "backupVault1"; string backupName = "backup1"; @@ -105,9 +99,15 @@ public async Task Delete_BackupsUnderBackupVaultDelete() NetAppBackupVaultBackupResource netAppBackupVaultBackup = client.GetNetAppBackupVaultBackupResource(netAppBackupVaultBackupResourceId); // invoke the operation - await netAppBackupVaultBackup.DeleteAsync(WaitUntil.Completed); + NetAppBackupVaultBackupPatch patch = new NetAppBackupVaultBackupPatch(); + ArmOperation lro = await netAppBackupVaultBackup.UpdateAsync(WaitUntil.Completed, patch); + NetAppBackupVaultBackupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -133,10 +133,7 @@ public async Task RestoreFilesBackupsUnderBackupVault_BackupsSingleFileRestore() NetAppBackupVaultBackupResource netAppBackupVaultBackup = client.GetNetAppBackupVaultBackupResource(netAppBackupVaultBackupResourceId); // invoke the operation - NetAppVolumeBackupBackupRestoreFilesContent content = new NetAppVolumeBackupBackupRestoreFilesContent(new string[] - { -"/dir1/customer1.db","/dir1/customer2.db" - }, new ResourceIdentifier("/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1/volumes/volume1")); + NetAppVolumeBackupBackupRestoreFilesContent content = new NetAppVolumeBackupBackupRestoreFilesContent(new string[] { "/dir1/customer1.db", "/dir1/customer2.db" }, new ResourceIdentifier("/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1/volumes/volume1")); await netAppBackupVaultBackup.RestoreFilesBackupsUnderBackupVaultAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultCollection.cs index aa33534c445cc..d152b29fb1326 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetAppBackupVaultCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_BackupVaultsList() + public async Task CreateOrUpdate_BackupVaultCreateOrUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_List.json - // this example is just showing the usage of "BackupVaults_ListByNetAppAccount" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_Create.json + // this example is just showing the usage of "BackupVaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,17 @@ public async Task GetAll_BackupVaultsList() // get the collection of this NetAppBackupVaultResource NetAppBackupVaultCollection collection = netAppAccount.GetNetAppBackupVaults(); - // invoke the operation and iterate over the result - await foreach (NetAppBackupVaultResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupVaultData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string backupVaultName = "backupVault1"; + NetAppBackupVaultData data = new NetAppBackupVaultData(new AzureLocation("eastus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backupVaultName, data); + NetAppBackupVaultResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupVaultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +87,10 @@ public async Task Get_BackupVaultsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_BackupVaultsGet() + public async Task GetAll_BackupVaultsList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_Get.json - // this example is just showing the usage of "BackupVaults_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_List.json + // this example is just showing the usage of "BackupVaults_ListByNetAppAccount" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +108,22 @@ public async Task Exists_BackupVaultsGet() // get the collection of this NetAppBackupVaultResource NetAppBackupVaultCollection collection = netAppAccount.GetNetAppBackupVaults(); - // invoke the operation - string backupVaultName = "backupVault1"; - bool result = await collection.ExistsAsync(backupVaultName); + // invoke the operation and iterate over the result + await foreach (NetAppBackupVaultResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupVaultData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_BackupVaultsGet() + public async Task Exists_BackupVaultsGet() { // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_Get.json // this example is just showing the usage of "BackupVaults_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_BackupVaultsGet() // invoke the operation string backupVaultName = "backupVault1"; - NullableResponse response = await collection.GetIfExistsAsync(backupVaultName); - NetAppBackupVaultResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(backupVaultName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupVaultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_BackupVaultCreateOrUpdate() + public async Task GetIfExists_BackupVaultsGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_Create.json - // this example is just showing the usage of "BackupVaults_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_Get.json + // this example is just showing the usage of "BackupVaults_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,15 +176,21 @@ public async Task CreateOrUpdate_BackupVaultCreateOrUpdate() // invoke the operation string backupVaultName = "backupVault1"; - NetAppBackupVaultData data = new NetAppBackupVaultData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backupVaultName, data); - NetAppBackupVaultResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(backupVaultName); + NetAppBackupVaultResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupVaultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupVaultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultResource.cs index 8255b837e55bd..fdc966844811e 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppBackupVaultResource.cs @@ -49,10 +49,10 @@ public async Task Get_BackupVaultsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_BackupVaultsUpdate() + public async Task Delete_BackupVaultsDelete() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_Update.json - // this example is just showing the usage of "BackupVaults_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_Delete.json + // this example is just showing the usage of "BackupVaults_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,36 +62,24 @@ public async Task Update_BackupVaultsUpdate() // this example assumes you already have this NetAppBackupVaultResource created on azure // for more information of creating NetAppBackupVaultResource, please refer to the document of NetAppBackupVaultResource string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "myRG"; + string resourceGroupName = "resourceGroup"; string accountName = "account1"; string backupVaultName = "backupVault1"; ResourceIdentifier netAppBackupVaultResourceId = NetAppBackupVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, backupVaultName); NetAppBackupVaultResource netAppBackupVault = client.GetNetAppBackupVaultResource(netAppBackupVaultResourceId); // invoke the operation - NetAppBackupVaultPatch patch = new NetAppBackupVaultPatch() - { - Tags = -{ -["Tag1"] = "Value1", -}, - }; - ArmOperation lro = await netAppBackupVault.UpdateAsync(WaitUntil.Completed, patch); - NetAppBackupVaultResource result = lro.Value; + await netAppBackupVault.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppBackupVaultData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BackupVaultsDelete() + public async Task Update_BackupVaultsUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_Delete.json - // this example is just showing the usage of "BackupVaults_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/BackupVaults_Update.json + // this example is just showing the usage of "BackupVaults_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,16 +89,28 @@ public async Task Delete_BackupVaultsDelete() // this example assumes you already have this NetAppBackupVaultResource created on azure // for more information of creating NetAppBackupVaultResource, please refer to the document of NetAppBackupVaultResource string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "resourceGroup"; + string resourceGroupName = "myRG"; string accountName = "account1"; string backupVaultName = "backupVault1"; ResourceIdentifier netAppBackupVaultResourceId = NetAppBackupVaultResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, backupVaultName); NetAppBackupVaultResource netAppBackupVault = client.GetNetAppBackupVaultResource(netAppBackupVaultResourceId); // invoke the operation - await netAppBackupVault.DeleteAsync(WaitUntil.Completed); + NetAppBackupVaultPatch patch = new NetAppBackupVaultPatch + { + Tags = +{ +["Tag1"] = "Value1" +}, + }; + ArmOperation lro = await netAppBackupVault.UpdateAsync(WaitUntil.Completed, patch); + NetAppBackupVaultResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppBackupVaultData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppSubvolumeInfoCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppSubvolumeInfoCollection.cs index 3f9590502d7c1..dbe9b1bb6795e 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppSubvolumeInfoCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppSubvolumeInfoCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetAppSubvolumeInfoCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SubvolumesList() + public async Task CreateOrUpdate_SubvolumesCreate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_List.json - // this example is just showing the usage of "Subvolumes_ListByVolume" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_Create.json + // this example is just showing the usage of "Subvolumes_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_SubvolumesList() // get the collection of this NetAppSubvolumeInfoResource NetAppSubvolumeInfoCollection collection = netAppVolume.GetNetAppSubvolumeInfos(); - // invoke the operation and iterate over the result - await foreach (NetAppSubvolumeInfoResource item in collection.GetAllAsync()) + // invoke the operation + string subvolumeName = "subvolume1"; + NetAppSubvolumeInfoData info = new NetAppSubvolumeInfoData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppSubvolumeInfoData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Path = "/subvolumePath", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subvolumeName, info); + NetAppSubvolumeInfoResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppSubvolumeInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +94,10 @@ public async Task Get_SubvolumesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SubvolumesGet() + public async Task GetAll_SubvolumesList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_Get.json - // this example is just showing the usage of "Subvolumes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_List.json + // this example is just showing the usage of "Subvolumes_ListByVolume" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +117,22 @@ public async Task Exists_SubvolumesGet() // get the collection of this NetAppSubvolumeInfoResource NetAppSubvolumeInfoCollection collection = netAppVolume.GetNetAppSubvolumeInfos(); - // invoke the operation - string subvolumeName = "subvolume1"; - bool result = await collection.ExistsAsync(subvolumeName); + // invoke the operation and iterate over the result + await foreach (NetAppSubvolumeInfoResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppSubvolumeInfoData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SubvolumesGet() + public async Task Exists_SubvolumesGet() { // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_Get.json // this example is just showing the usage of "Subvolumes_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +157,17 @@ public async Task GetIfExists_SubvolumesGet() // invoke the operation string subvolumeName = "subvolume1"; - NullableResponse response = await collection.GetIfExistsAsync(subvolumeName); - NetAppSubvolumeInfoResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(subvolumeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppSubvolumeInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SubvolumesCreate() + public async Task GetIfExists_SubvolumesGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_Create.json - // this example is just showing the usage of "Subvolumes_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_Get.json + // this example is just showing the usage of "Subvolumes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,18 +189,21 @@ public async Task CreateOrUpdate_SubvolumesCreate() // invoke the operation string subvolumeName = "subvolume1"; - NetAppSubvolumeInfoData info = new NetAppSubvolumeInfoData() - { - Path = "/subvolumePath", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subvolumeName, info); - NetAppSubvolumeInfoResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(subvolumeName); + NetAppSubvolumeInfoResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppSubvolumeInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppSubvolumeInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppSubvolumeInfoResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppSubvolumeInfoResource.cs index 6510e5208e332..5b6eecadebdda 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppSubvolumeInfoResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppSubvolumeInfoResource.cs @@ -51,10 +51,10 @@ public async Task Get_SubvolumesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SubvolumesUpdate() + public async Task Delete_SubvolumesDelete() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_Update.json - // this example is just showing the usage of "Subvolumes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_Delete.json + // this example is just showing the usage of "Subvolumes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,26 +73,17 @@ public async Task Update_SubvolumesUpdate() NetAppSubvolumeInfoResource netAppSubvolumeInfo = client.GetNetAppSubvolumeInfoResource(netAppSubvolumeInfoResourceId); // invoke the operation - NetAppSubvolumeInfoPatch patch = new NetAppSubvolumeInfoPatch() - { - Path = "/subvolumePath", - }; - ArmOperation lro = await netAppSubvolumeInfo.UpdateAsync(WaitUntil.Completed, patch); - NetAppSubvolumeInfoResource result = lro.Value; + await netAppSubvolumeInfo.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppSubvolumeInfoData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SubvolumesDelete() + public async Task Update_SubvolumesUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_Delete.json - // this example is just showing the usage of "Subvolumes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Subvolumes_Update.json + // this example is just showing the usage of "Subvolumes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +102,18 @@ public async Task Delete_SubvolumesDelete() NetAppSubvolumeInfoResource netAppSubvolumeInfo = client.GetNetAppSubvolumeInfoResource(netAppSubvolumeInfoResourceId); // invoke the operation - await netAppSubvolumeInfo.DeleteAsync(WaitUntil.Completed); + NetAppSubvolumeInfoPatch patch = new NetAppSubvolumeInfoPatch + { + Path = "/subvolumePath", + }; + ArmOperation lro = await netAppSubvolumeInfo.UpdateAsync(WaitUntil.Completed, patch); + NetAppSubvolumeInfoResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppSubvolumeInfoData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeCollection.cs index dcf37a72fb124..8027d66a2f50f 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetAppVolumeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VolumesList() + public async Task CreateOrUpdate_VolumesCreateOrUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_List.json - // this example is just showing the usage of "Volumes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_CreateOrUpdate.json + // this example is just showing the usage of "Volumes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,20 @@ public async Task GetAll_VolumesList() // get the collection of this NetAppVolumeResource NetAppVolumeCollection collection = capacityPool.GetNetAppVolumes(); - // invoke the operation and iterate over the result - await foreach (NetAppVolumeResource item in collection.GetAllAsync()) + // invoke the operation + string volumeName = "volume1"; + NetAppVolumeData data = new NetAppVolumeData(new AzureLocation("eastus"), "my-unique-file-path", 107374182400L, new ResourceIdentifier("/subscriptions/9760acf5-4638-11e7-9bdb-020073ca7778/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServiceLevel = NetAppFileServiceLevel.Premium, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, volumeName, data); + NetAppVolumeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +93,10 @@ public async Task Get_VolumesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VolumesGet() + public async Task GetAll_VolumesList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_Get.json - // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_List.json + // this example is just showing the usage of "Volumes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +115,22 @@ public async Task Exists_VolumesGet() // get the collection of this NetAppVolumeResource NetAppVolumeCollection collection = capacityPool.GetNetAppVolumes(); - // invoke the operation - string volumeName = "volume1"; - bool result = await collection.ExistsAsync(volumeName); + // invoke the operation and iterate over the result + await foreach (NetAppVolumeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VolumesGet() + public async Task Exists_VolumesGet() { // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_Get.json // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +154,17 @@ public async Task GetIfExists_VolumesGet() // invoke the operation string volumeName = "volume1"; - NullableResponse response = await collection.GetIfExistsAsync(volumeName); - NetAppVolumeResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(volumeName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VolumesCreateOrUpdate() + public async Task GetIfExists_VolumesGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_CreateOrUpdate.json - // this example is just showing the usage of "Volumes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_Get.json + // this example is just showing the usage of "Volumes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,18 +185,21 @@ public async Task CreateOrUpdate_VolumesCreateOrUpdate() // invoke the operation string volumeName = "volume1"; - NetAppVolumeData data = new NetAppVolumeData(new AzureLocation("eastus"), "my-unique-file-path", 107374182400L, new ResourceIdentifier("/subscriptions/9760acf5-4638-11e7-9bdb-020073ca7778/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) - { - ServiceLevel = NetAppFileServiceLevel.Premium, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, volumeName, data); - NetAppVolumeResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(volumeName); + NetAppVolumeResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeGroupCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeGroupCollection.cs index a9a4a8cd64ba5..37694e33600b7 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeGroupCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeGroupCollection.cs @@ -16,218 +16,6 @@ namespace Azure.ResourceManager.NetApp.Samples { public partial class Sample_NetAppVolumeGroupCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_VolumeGroupsGetOracle() - { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_Oracle.json - // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetAppAccountResource created on azure - // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource - string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "myRG"; - string accountName = "account1"; - ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); - - // get the collection of this NetAppVolumeGroupResource - NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); - - // invoke the operation - string volumeGroupName = "group1"; - NetAppVolumeGroupResource result = await collection.GetAsync(volumeGroupName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_VolumeGroupsGetOracle() - { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_Oracle.json - // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetAppAccountResource created on azure - // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource - string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "myRG"; - string accountName = "account1"; - ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); - - // get the collection of this NetAppVolumeGroupResource - NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); - - // invoke the operation - string volumeGroupName = "group1"; - bool result = await collection.ExistsAsync(volumeGroupName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VolumeGroupsGetOracle() - { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_Oracle.json - // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetAppAccountResource created on azure - // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource - string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "myRG"; - string accountName = "account1"; - ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); - - // get the collection of this NetAppVolumeGroupResource - NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); - - // invoke the operation - string volumeGroupName = "group1"; - NullableResponse response = await collection.GetIfExistsAsync(volumeGroupName); - NetAppVolumeGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_VolumeGroupsGetSapHana() - { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_SapHana.json - // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetAppAccountResource created on azure - // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource - string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "myRG"; - string accountName = "account1"; - ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); - - // get the collection of this NetAppVolumeGroupResource - NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); - - // invoke the operation - string volumeGroupName = "group1"; - NetAppVolumeGroupResource result = await collection.GetAsync(volumeGroupName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_VolumeGroupsGetSapHana() - { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_SapHana.json - // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetAppAccountResource created on azure - // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource - string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "myRG"; - string accountName = "account1"; - ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); - - // get the collection of this NetAppVolumeGroupResource - NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); - - // invoke the operation - string volumeGroupName = "group1"; - bool result = await collection.ExistsAsync(volumeGroupName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VolumeGroupsGetSapHana() - { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_SapHana.json - // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetAppAccountResource created on azure - // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource - string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "myRG"; - string accountName = "account1"; - ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); - NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); - - // get the collection of this NetAppVolumeGroupResource - NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); - - // invoke the operation - string volumeGroupName = "group1"; - NullableResponse response = await collection.GetIfExistsAsync(volumeGroupName); - NetAppVolumeGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_VolumeGroupsCreateOracle() @@ -253,28 +41,21 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() // invoke the operation string volumeGroupName = "group1"; - NetAppVolumeGroupData data = new NetAppVolumeGroupData() + NetAppVolumeGroupData data = new NetAppVolumeGroupData { Location = new AzureLocation("westus"), - GroupMetaData = new NetAppVolumeGroupMetadata() + GroupMetaData = new NetAppVolumeGroupMetadata { GroupDescription = "Volume group", ApplicationType = NetAppApplicationType.Oracle, ApplicationIdentifier = "OR2", }, - Volumes = -{ -new NetAppVolumeGroupVolume("test-ora-data1",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) + Volumes = {new NetAppVolumeGroupVolume("test-ora-data1", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data1", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -290,26 +71,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data1", -},new NetAppVolumeGroupVolume("test-ora-data2",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data2", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data2", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -325,26 +97,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data2", -},new NetAppVolumeGroupVolume("test-ora-data3",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data3", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data3", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -360,26 +123,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data3", -},new NetAppVolumeGroupVolume("test-ora-data4",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data4", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data4", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -395,26 +149,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data4", -},new NetAppVolumeGroupVolume("test-ora-data5",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data5", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data5", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -430,26 +175,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data5", -},new NetAppVolumeGroupVolume("test-ora-data6",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data6", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data6", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -465,26 +201,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data6", -},new NetAppVolumeGroupVolume("test-ora-data7",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data7", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data7", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -500,26 +227,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data7", -},new NetAppVolumeGroupVolume("test-ora-data8",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data8", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data8", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -535,26 +253,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data8", -},new NetAppVolumeGroupVolume("test-ora-log",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-log", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-log", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -570,26 +279,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-log", -},new NetAppVolumeGroupVolume("test-ora-log-mirror",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-log-mirror", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-log-mirror", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -605,26 +305,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-log-mirror", -},new NetAppVolumeGroupVolume("test-ora-binary",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-binary", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-binary", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -640,26 +331,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-binary", -},new NetAppVolumeGroupVolume("test-ora-backup",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-backup", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-backup", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -675,17 +357,12 @@ public async Task CreateOrUpdate_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-backup", -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, volumeGroupName, data); NetAppVolumeGroupResource result = lro.Value; @@ -722,24 +399,20 @@ public async Task CreateOrUpdate_VolumeGroupsCreateSapHana() // invoke the operation string volumeGroupName = "group1"; - NetAppVolumeGroupData data = new NetAppVolumeGroupData() + NetAppVolumeGroupData data = new NetAppVolumeGroupData { Location = new AzureLocation("westus"), - GroupMetaData = new NetAppVolumeGroupMetadata() + GroupMetaData = new NetAppVolumeGroupMetadata { GroupDescription = "Volume group", ApplicationType = NetAppApplicationType.SapHana, ApplicationIdentifier = "SH9", }, - Volumes = -{ -new NetAppVolumeGroupVolume("test-data-mnt00001",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) + Volumes = {new NetAppVolumeGroupVolume("test-data-mnt00001", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-data-mnt00001", ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -755,23 +428,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateSapHana() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/cys_sjain_fcp_rg/providers/Microsoft.Compute/proximityPlacementGroups/svlqa_sjain_multivolume_ppg"), VolumeSpecName = "data", -},new NetAppVolumeGroupVolume("test-log-mnt00001",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-log-mnt00001", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-log-mnt00001", ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -787,23 +454,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateSapHana() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/cys_sjain_fcp_rg/providers/Microsoft.Compute/proximityPlacementGroups/svlqa_sjain_multivolume_ppg"), VolumeSpecName = "log", -},new NetAppVolumeGroupVolume("test-shared",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-shared", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-shared", ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -819,23 +480,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateSapHana() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/cys_sjain_fcp_rg/providers/Microsoft.Compute/proximityPlacementGroups/svlqa_sjain_multivolume_ppg"), VolumeSpecName = "shared", -},new NetAppVolumeGroupVolume("test-data-backup",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-data-backup", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-data-backup", ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -851,23 +506,17 @@ public async Task CreateOrUpdate_VolumeGroupsCreateSapHana() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/cys_sjain_fcp_rg/providers/Microsoft.Compute/proximityPlacementGroups/svlqa_sjain_multivolume_ppg"), VolumeSpecName = "data-backup", -},new NetAppVolumeGroupVolume("test-log-backup",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-log-backup", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-log-backup", ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -883,18 +532,13 @@ public async Task CreateOrUpdate_VolumeGroupsCreateSapHana() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/cys_sjain_fcp_rg/providers/Microsoft.Compute/proximityPlacementGroups/svlqa_sjain_multivolume_ppg"), VolumeSpecName = "log-backup", -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, volumeGroupName, data); NetAppVolumeGroupResource result = lro.Value; @@ -905,5 +549,217 @@ public async Task CreateOrUpdate_VolumeGroupsCreateSapHana() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_VolumeGroupsGetOracle() + { + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_Oracle.json + // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetAppAccountResource created on azure + // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource + string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; + string resourceGroupName = "myRG"; + string accountName = "account1"; + ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); + + // get the collection of this NetAppVolumeGroupResource + NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); + + // invoke the operation + string volumeGroupName = "group1"; + NetAppVolumeGroupResource result = await collection.GetAsync(volumeGroupName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_VolumeGroupsGetSapHana() + { + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_SapHana.json + // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetAppAccountResource created on azure + // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource + string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; + string resourceGroupName = "myRG"; + string accountName = "account1"; + ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); + + // get the collection of this NetAppVolumeGroupResource + NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); + + // invoke the operation + string volumeGroupName = "group1"; + NetAppVolumeGroupResource result = await collection.GetAsync(volumeGroupName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_VolumeGroupsGetOracle() + { + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_Oracle.json + // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetAppAccountResource created on azure + // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource + string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; + string resourceGroupName = "myRG"; + string accountName = "account1"; + ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); + + // get the collection of this NetAppVolumeGroupResource + NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); + + // invoke the operation + string volumeGroupName = "group1"; + bool result = await collection.ExistsAsync(volumeGroupName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_VolumeGroupsGetSapHana() + { + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_SapHana.json + // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetAppAccountResource created on azure + // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource + string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; + string resourceGroupName = "myRG"; + string accountName = "account1"; + ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); + + // get the collection of this NetAppVolumeGroupResource + NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); + + // invoke the operation + string volumeGroupName = "group1"; + bool result = await collection.ExistsAsync(volumeGroupName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_VolumeGroupsGetOracle() + { + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_Oracle.json + // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetAppAccountResource created on azure + // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource + string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; + string resourceGroupName = "myRG"; + string accountName = "account1"; + ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); + + // get the collection of this NetAppVolumeGroupResource + NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); + + // invoke the operation + string volumeGroupName = "group1"; + NullableResponse response = await collection.GetIfExistsAsync(volumeGroupName); + NetAppVolumeGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_VolumeGroupsGetSapHana() + { + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Get_SapHana.json + // this example is just showing the usage of "VolumeGroups_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetAppAccountResource created on azure + // for more information of creating NetAppAccountResource, please refer to the document of NetAppAccountResource + string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; + string resourceGroupName = "myRG"; + string accountName = "account1"; + ResourceIdentifier netAppAccountResourceId = NetAppAccountResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName); + NetAppAccountResource netAppAccount = client.GetNetAppAccountResource(netAppAccountResourceId); + + // get the collection of this NetAppVolumeGroupResource + NetAppVolumeGroupCollection collection = netAppAccount.GetNetAppVolumeGroups(); + + // invoke the operation + string volumeGroupName = "group1"; + NullableResponse response = await collection.GetIfExistsAsync(volumeGroupName); + NetAppVolumeGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeGroupResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeGroupResource.cs index 29759a1923ef9..b88d8aa718dba 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeGroupResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeGroupResource.cs @@ -78,6 +78,33 @@ public async Task Get_VolumeGroupsGetSapHana() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_VolumeGroupsDelete() + { + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Delete.json + // this example is just showing the usage of "VolumeGroups_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetAppVolumeGroupResource created on azure + // for more information of creating NetAppVolumeGroupResource, please refer to the document of NetAppVolumeGroupResource + string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; + string resourceGroupName = "myRG"; + string accountName = "account1"; + string volumeGroupName = "group1"; + ResourceIdentifier netAppVolumeGroupResourceId = NetAppVolumeGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, volumeGroupName); + NetAppVolumeGroupResource netAppVolumeGroup = client.GetNetAppVolumeGroupResource(netAppVolumeGroupResourceId); + + // invoke the operation + await netAppVolumeGroup.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_VolumeGroupsCreateOracle() @@ -100,28 +127,21 @@ public async Task Update_VolumeGroupsCreateOracle() NetAppVolumeGroupResource netAppVolumeGroup = client.GetNetAppVolumeGroupResource(netAppVolumeGroupResourceId); // invoke the operation - NetAppVolumeGroupData data = new NetAppVolumeGroupData() + NetAppVolumeGroupData data = new NetAppVolumeGroupData { Location = new AzureLocation("westus"), - GroupMetaData = new NetAppVolumeGroupMetadata() + GroupMetaData = new NetAppVolumeGroupMetadata { GroupDescription = "Volume group", ApplicationType = NetAppApplicationType.Oracle, ApplicationIdentifier = "OR2", }, - Volumes = -{ -new NetAppVolumeGroupVolume("test-ora-data1",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) + Volumes = {new NetAppVolumeGroupVolume("test-ora-data1", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data1", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -137,26 +157,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data1", -},new NetAppVolumeGroupVolume("test-ora-data2",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data2", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data2", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -172,26 +183,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data2", -},new NetAppVolumeGroupVolume("test-ora-data3",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data3", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data3", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -207,26 +209,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data3", -},new NetAppVolumeGroupVolume("test-ora-data4",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data4", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data4", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -242,26 +235,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data4", -},new NetAppVolumeGroupVolume("test-ora-data5",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data5", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data5", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -277,26 +261,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data5", -},new NetAppVolumeGroupVolume("test-ora-data6",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data6", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data6", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -312,26 +287,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data6", -},new NetAppVolumeGroupVolume("test-ora-data7",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data7", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data7", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -347,26 +313,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data7", -},new NetAppVolumeGroupVolume("test-ora-data8",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-data8", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-data8", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -382,26 +339,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-data8", -},new NetAppVolumeGroupVolume("test-ora-log",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-log", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-log", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -417,26 +365,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-log", -},new NetAppVolumeGroupVolume("test-ora-log-mirror",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-log-mirror", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-log-mirror", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -452,26 +391,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-log-mirror", -},new NetAppVolumeGroupVolume("test-ora-binary",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-binary", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-binary", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -487,26 +417,17 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-binary", -},new NetAppVolumeGroupVolume("test-ora-backup",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-ora-backup", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-ora-backup", -Zones = -{ -"1" -}, +Zones = {"1"}, ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -522,17 +443,12 @@ public async Task Update_VolumeGroupsCreateOracle() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), VolumeSpecName = "ora-backup", -} -}, +}}, }; ArmOperation lro = await netAppVolumeGroup.UpdateAsync(WaitUntil.Completed, data); NetAppVolumeGroupResource result = lro.Value; @@ -566,24 +482,20 @@ public async Task Update_VolumeGroupsCreateSapHana() NetAppVolumeGroupResource netAppVolumeGroup = client.GetNetAppVolumeGroupResource(netAppVolumeGroupResourceId); // invoke the operation - NetAppVolumeGroupData data = new NetAppVolumeGroupData() + NetAppVolumeGroupData data = new NetAppVolumeGroupData { Location = new AzureLocation("westus"), - GroupMetaData = new NetAppVolumeGroupMetadata() + GroupMetaData = new NetAppVolumeGroupMetadata { GroupDescription = "Volume group", ApplicationType = NetAppApplicationType.SapHana, ApplicationIdentifier = "SH9", }, - Volumes = -{ -new NetAppVolumeGroupVolume("test-data-mnt00001",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) + Volumes = {new NetAppVolumeGroupVolume("test-data-mnt00001", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-data-mnt00001", ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -599,23 +511,17 @@ public async Task Update_VolumeGroupsCreateSapHana() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/cys_sjain_fcp_rg/providers/Microsoft.Compute/proximityPlacementGroups/svlqa_sjain_multivolume_ppg"), VolumeSpecName = "data", -},new NetAppVolumeGroupVolume("test-log-mnt00001",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-log-mnt00001", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-log-mnt00001", ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -631,23 +537,17 @@ public async Task Update_VolumeGroupsCreateSapHana() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/cys_sjain_fcp_rg/providers/Microsoft.Compute/proximityPlacementGroups/svlqa_sjain_multivolume_ppg"), VolumeSpecName = "log", -},new NetAppVolumeGroupVolume("test-shared",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-shared", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-shared", ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -663,23 +563,17 @@ public async Task Update_VolumeGroupsCreateSapHana() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/cys_sjain_fcp_rg/providers/Microsoft.Compute/proximityPlacementGroups/svlqa_sjain_multivolume_ppg"), VolumeSpecName = "shared", -},new NetAppVolumeGroupVolume("test-data-backup",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-data-backup", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-data-backup", ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -695,23 +589,17 @@ public async Task Update_VolumeGroupsCreateSapHana() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/cys_sjain_fcp_rg/providers/Microsoft.Compute/proximityPlacementGroups/svlqa_sjain_multivolume_ppg"), VolumeSpecName = "data-backup", -},new NetAppVolumeGroupVolume("test-log-backup",107374182400L,new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) +}, new NetAppVolumeGroupVolume("test-log-backup", 107374182400L, new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRP/providers/Microsoft.Network/virtualNetworks/testvnet3/subnets/testsubnet3")) { Name = "test-log-backup", ServiceLevel = NetAppFileServiceLevel.Premium, -ExportRules = -{ -new NetAppVolumeExportPolicyRule() +ExportRules = {new NetAppVolumeExportPolicyRule { RuleIndex = 1, IsUnixReadOnly = true, @@ -727,18 +615,13 @@ public async Task Update_VolumeGroupsCreateSapHana() AllowNfsV41Protocol = true, AllowedClients = "0.0.0.0/0", HasRootAccess = true, -} -}, -ProtocolTypes = -{ -"NFSv4.1" -}, +}}, +ProtocolTypes = {"NFSv4.1"}, ThroughputMibps = 10, CapacityPoolResourceId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1"), ProximityPlacementGroupId = new ResourceIdentifier("/subscriptions/d633cc2e-722b-4ae1-b636-bbd9e4c60ed9/resourceGroups/cys_sjain_fcp_rg/providers/Microsoft.Compute/proximityPlacementGroups/svlqa_sjain_multivolume_ppg"), VolumeSpecName = "log-backup", -} -}, +}}, }; ArmOperation lro = await netAppVolumeGroup.UpdateAsync(WaitUntil.Completed, data); NetAppVolumeGroupResource result = lro.Value; @@ -749,32 +632,5 @@ public async Task Update_VolumeGroupsCreateSapHana() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_VolumeGroupsDelete() - { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeGroups_Delete.json - // this example is just showing the usage of "VolumeGroups_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetAppVolumeGroupResource created on azure - // for more information of creating NetAppVolumeGroupResource, please refer to the document of NetAppVolumeGroupResource - string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "myRG"; - string accountName = "account1"; - string volumeGroupName = "group1"; - ResourceIdentifier netAppVolumeGroupResourceId = NetAppVolumeGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, volumeGroupName); - NetAppVolumeGroupResource netAppVolumeGroup = client.GetNetAppVolumeGroupResource(netAppVolumeGroupResourceId); - - // invoke the operation - await netAppVolumeGroup.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeQuotaRuleCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeQuotaRuleCollection.cs index d49e63fbe488c..d8f5a6f9f2e11 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeQuotaRuleCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeQuotaRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetAppVolumeQuotaRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VolumeQuotaRulesList() + public async Task CreateOrUpdate_VolumeQuotaRulesCreate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_List.json - // this example is just showing the usage of "VolumeQuotaRules_ListByVolume" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_Create.json + // this example is just showing the usage of "VolumeQuotaRules_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,22 @@ public async Task GetAll_VolumeQuotaRulesList() // get the collection of this NetAppVolumeQuotaRuleResource NetAppVolumeQuotaRuleCollection collection = netAppVolume.GetNetAppVolumeQuotaRules(); - // invoke the operation and iterate over the result - await foreach (NetAppVolumeQuotaRuleResource item in collection.GetAllAsync()) + // invoke the operation + string volumeQuotaRuleName = "rule-0004"; + NetAppVolumeQuotaRuleData data = new NetAppVolumeQuotaRuleData(new AzureLocation("westus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeQuotaRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + QuotaSizeInKiBs = 100005L, + QuotaType = NetAppVolumeQuotaType.IndividualUserQuota, + QuotaTarget = "1821", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, volumeQuotaRuleName, data); + NetAppVolumeQuotaRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeQuotaRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +97,10 @@ public async Task Get_VolumeQuotaRulesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VolumeQuotaRulesGet() + public async Task GetAll_VolumeQuotaRulesList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_Get.json - // this example is just showing the usage of "VolumeQuotaRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_List.json + // this example is just showing the usage of "VolumeQuotaRules_ListByVolume" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +120,22 @@ public async Task Exists_VolumeQuotaRulesGet() // get the collection of this NetAppVolumeQuotaRuleResource NetAppVolumeQuotaRuleCollection collection = netAppVolume.GetNetAppVolumeQuotaRules(); - // invoke the operation - string volumeQuotaRuleName = "rule-0004"; - bool result = await collection.ExistsAsync(volumeQuotaRuleName); + // invoke the operation and iterate over the result + await foreach (NetAppVolumeQuotaRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeQuotaRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VolumeQuotaRulesGet() + public async Task Exists_VolumeQuotaRulesGet() { // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_Get.json // this example is just showing the usage of "VolumeQuotaRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +160,17 @@ public async Task GetIfExists_VolumeQuotaRulesGet() // invoke the operation string volumeQuotaRuleName = "rule-0004"; - NullableResponse response = await collection.GetIfExistsAsync(volumeQuotaRuleName); - NetAppVolumeQuotaRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(volumeQuotaRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeQuotaRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VolumeQuotaRulesCreate() + public async Task GetIfExists_VolumeQuotaRulesGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_Create.json - // this example is just showing the usage of "VolumeQuotaRules_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_Get.json + // this example is just showing the usage of "VolumeQuotaRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,20 +192,21 @@ public async Task CreateOrUpdate_VolumeQuotaRulesCreate() // invoke the operation string volumeQuotaRuleName = "rule-0004"; - NetAppVolumeQuotaRuleData data = new NetAppVolumeQuotaRuleData(new AzureLocation("westus")) - { - QuotaSizeInKiBs = 100005L, - QuotaType = NetAppVolumeQuotaType.IndividualUserQuota, - QuotaTarget = "1821", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, volumeQuotaRuleName, data); - NetAppVolumeQuotaRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(volumeQuotaRuleName); + NetAppVolumeQuotaRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeQuotaRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeQuotaRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeQuotaRuleResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeQuotaRuleResource.cs index 4f978769a8648..6400ce17c0592 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeQuotaRuleResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeQuotaRuleResource.cs @@ -51,10 +51,10 @@ public async Task Get_VolumeQuotaRulesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VolumeQuotaRulesUpdate() + public async Task Delete_VolumeQuotaRulesDelete() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_Update.json - // this example is just showing the usage of "VolumeQuotaRules_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_Delete.json + // this example is just showing the usage of "VolumeQuotaRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,26 +73,17 @@ public async Task Update_VolumeQuotaRulesUpdate() NetAppVolumeQuotaRuleResource netAppVolumeQuotaRule = client.GetNetAppVolumeQuotaRuleResource(netAppVolumeQuotaRuleResourceId); // invoke the operation - NetAppVolumeQuotaRulePatch patch = new NetAppVolumeQuotaRulePatch() - { - QuotaSizeInKiBs = 100009L, - }; - ArmOperation lro = await netAppVolumeQuotaRule.UpdateAsync(WaitUntil.Completed, patch); - NetAppVolumeQuotaRuleResource result = lro.Value; + await netAppVolumeQuotaRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeQuotaRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VolumeQuotaRulesDelete() + public async Task Update_VolumeQuotaRulesUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_Delete.json - // this example is just showing the usage of "VolumeQuotaRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/VolumeQuotaRules_Update.json + // this example is just showing the usage of "VolumeQuotaRules_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -111,9 +102,18 @@ public async Task Delete_VolumeQuotaRulesDelete() NetAppVolumeQuotaRuleResource netAppVolumeQuotaRule = client.GetNetAppVolumeQuotaRuleResource(netAppVolumeQuotaRuleResourceId); // invoke the operation - await netAppVolumeQuotaRule.DeleteAsync(WaitUntil.Completed); + NetAppVolumeQuotaRulePatch patch = new NetAppVolumeQuotaRulePatch + { + QuotaSizeInKiBs = 100009L, + }; + ArmOperation lro = await netAppVolumeQuotaRule.UpdateAsync(WaitUntil.Completed, patch); + NetAppVolumeQuotaRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeQuotaRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeResource.cs index 2f0f4d473f8c8..0705532883926 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeResource.cs @@ -51,10 +51,10 @@ public async Task Get_VolumesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VolumesUpdate() + public async Task Delete_VolumesDelete() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_Update.json - // this example is just showing the usage of "Volumes_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_Delete.json + // this example is just showing the usage of "Volumes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,23 +72,17 @@ public async Task Update_VolumesUpdate() NetAppVolumeResource netAppVolume = client.GetNetAppVolumeResource(netAppVolumeResourceId); // invoke the operation - NetAppVolumePatch patch = new NetAppVolumePatch(new AzureLocation("placeholder")); - ArmOperation lro = await netAppVolume.UpdateAsync(WaitUntil.Completed, patch); - NetAppVolumeResource result = lro.Value; + await netAppVolume.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VolumesDelete() + public async Task Update_VolumesUpdate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_Delete.json - // this example is just showing the usage of "Volumes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Volumes_Update.json + // this example is just showing the usage of "Volumes_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +100,15 @@ public async Task Delete_VolumesDelete() NetAppVolumeResource netAppVolume = client.GetNetAppVolumeResource(netAppVolumeResourceId); // invoke the operation - await netAppVolume.DeleteAsync(WaitUntil.Completed); + NetAppVolumePatch patch = new NetAppVolumePatch(default); + ArmOperation lro = await netAppVolume.UpdateAsync(WaitUntil.Completed, patch); + NetAppVolumeResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -167,7 +167,7 @@ public async Task Revert_VolumesRevert() NetAppVolumeResource netAppVolume = client.GetNetAppVolumeResource(netAppVolumeResourceId); // invoke the operation - NetAppVolumeRevertContent content = new NetAppVolumeRevertContent() + NetAppVolumeRevertContent content = new NetAppVolumeRevertContent { SnapshotId = "/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/myRG/providers/Microsoft.NetApp/netAppAccounts/account1/capacityPools/pool1/volumes/volume1/snapshots/snapshot1", }; @@ -227,7 +227,7 @@ public async Task BreakFileLocks_VolumesBreakFileLocks() NetAppVolumeResource netAppVolume = client.GetNetAppVolumeResource(netAppVolumeResourceId); // invoke the operation - NetAppVolumeBreakFileLocksContent content = new NetAppVolumeBreakFileLocksContent() + NetAppVolumeBreakFileLocksContent content = new NetAppVolumeBreakFileLocksContent { ClientIP = IPAddress.Parse("101.102.103.104"), ConfirmRunningDisruptiveOperation = true, @@ -290,7 +290,7 @@ public async Task BreakReplication_VolumesBreakReplication() NetAppVolumeResource netAppVolume = client.GetNetAppVolumeResource(netAppVolumeResourceId); // invoke the operation - NetAppVolumeBreakReplicationContent content = new NetAppVolumeBreakReplicationContent() + NetAppVolumeBreakReplicationContent content = new NetAppVolumeBreakReplicationContent { ForceBreakReplication = false, }; @@ -322,7 +322,7 @@ public async Task ReestablishReplication_VolumesReestablishReplication() NetAppVolumeResource netAppVolume = client.GetNetAppVolumeResource(netAppVolumeResourceId); // invoke the operation - NetAppVolumeReestablishReplicationContent content = new NetAppVolumeReestablishReplicationContent() + NetAppVolumeReestablishReplicationContent content = new NetAppVolumeReestablishReplicationContent { SourceVolumeId = new ResourceIdentifier("/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/mySourceRG/providers/Microsoft.NetApp/netAppAccounts/sourceAccount1/capacityPools/sourcePool1/volumes/sourceVolume1"), }; @@ -469,7 +469,7 @@ public async Task AuthorizeReplication_VolumesAuthorizeReplication() NetAppVolumeResource netAppVolume = client.GetNetAppVolumeResource(netAppVolumeResourceId); // invoke the operation - NetAppVolumeAuthorizeReplicationContent content = new NetAppVolumeAuthorizeReplicationContent() + NetAppVolumeAuthorizeReplicationContent content = new NetAppVolumeAuthorizeReplicationContent { RemoteVolumeResourceId = new ResourceIdentifier("/subscriptions/D633CC2E-722B-4AE1-B636-BBD9E4C60ED9/resourceGroups/myRemoteRG/providers/Microsoft.NetApp/netAppAccounts/remoteAccount1/capacityPools/remotePool1/volumes/remoteVolume1"), }; @@ -529,10 +529,7 @@ public async Task PeerExternalCluster_VolumesPeerExternalCluster() NetAppVolumeResource netAppVolume = client.GetNetAppVolumeResource(netAppVolumeResourceId); // invoke the operation - PeerClusterForVolumeMigrationContent content = new PeerClusterForVolumeMigrationContent(new string[] - { -"0.0.0.1","0.0.0.2","0.0.0.3","0.0.0.4","0.0.0.5","0.0.0.6" - }); + PeerClusterForVolumeMigrationContent content = new PeerClusterForVolumeMigrationContent(new string[] { "0.0.0.1", "0.0.0.2", "0.0.0.3", "0.0.0.4", "0.0.0.5", "0.0.0.6" }); ArmOperation lro = await netAppVolume.PeerExternalClusterAsync(WaitUntil.Completed, content); ClusterPeerCommandResult result = lro.Value; diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeSnapshotCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeSnapshotCollection.cs index 3082a6ecabf47..a3924180b44d3 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeSnapshotCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeSnapshotCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetAppVolumeSnapshotCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SnapshotsList() + public async Task CreateOrUpdate_SnapshotsCreate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_List.json - // this example is just showing the usage of "Snapshots_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_Create.json + // this example is just showing the usage of "Snapshots_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,17 @@ public async Task GetAll_SnapshotsList() // get the collection of this NetAppVolumeSnapshotResource NetAppVolumeSnapshotCollection collection = netAppVolume.GetNetAppVolumeSnapshots(); - // invoke the operation and iterate over the result - await foreach (NetAppVolumeSnapshotResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeSnapshotData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string snapshotName = "snapshot1"; + NetAppVolumeSnapshotData data = new NetAppVolumeSnapshotData(new AzureLocation("eastus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, snapshotName, data); + NetAppVolumeSnapshotResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -91,10 +91,10 @@ public async Task Get_SnapshotsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SnapshotsGet() + public async Task GetAll_SnapshotsList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_Get.json - // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_List.json + // this example is just showing the usage of "Snapshots_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,16 +114,22 @@ public async Task Exists_SnapshotsGet() // get the collection of this NetAppVolumeSnapshotResource NetAppVolumeSnapshotCollection collection = netAppVolume.GetNetAppVolumeSnapshots(); - // invoke the operation - string snapshotName = "snapshot1"; - bool result = await collection.ExistsAsync(snapshotName); + // invoke the operation and iterate over the result + await foreach (NetAppVolumeSnapshotResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeSnapshotData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SnapshotsGet() + public async Task Exists_SnapshotsGet() { // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_Get.json // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. @@ -148,29 +154,17 @@ public async Task GetIfExists_SnapshotsGet() // invoke the operation string snapshotName = "snapshot1"; - NullableResponse response = await collection.GetIfExistsAsync(snapshotName); - NetAppVolumeSnapshotResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(snapshotName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeSnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SnapshotsCreate() + public async Task GetIfExists_SnapshotsGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_Create.json - // this example is just showing the usage of "Snapshots_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_Get.json + // this example is just showing the usage of "Snapshots_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -192,15 +186,21 @@ public async Task CreateOrUpdate_SnapshotsCreate() // invoke the operation string snapshotName = "snapshot1"; - NetAppVolumeSnapshotData data = new NetAppVolumeSnapshotData(new AzureLocation("eastus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, snapshotName, data); - NetAppVolumeSnapshotResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(snapshotName); + NetAppVolumeSnapshotResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeSnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeSnapshotResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeSnapshotResource.cs index 621d5fa0f0566..e37c81935c3e8 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeSnapshotResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_NetAppVolumeSnapshotResource.cs @@ -51,10 +51,10 @@ public async Task Get_SnapshotsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_SnapshotsCreate() + public async Task Delete_SnapshotsDelete() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_Create.json - // this example is just showing the usage of "Snapshots_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_Delete.json + // this example is just showing the usage of "Snapshots_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,23 +73,17 @@ public async Task Update_SnapshotsCreate() NetAppVolumeSnapshotResource netAppVolumeSnapshot = client.GetNetAppVolumeSnapshotResource(netAppVolumeSnapshotResourceId); // invoke the operation - NetAppVolumeSnapshotData data = new NetAppVolumeSnapshotData(new AzureLocation("eastus")); - ArmOperation lro = await netAppVolumeSnapshot.UpdateAsync(WaitUntil.Completed, data); - NetAppVolumeSnapshotResource result = lro.Value; + await netAppVolumeSnapshot.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetAppVolumeSnapshotData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_SnapshotsDelete() + public async Task Update_SnapshotsCreate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_Delete.json - // this example is just showing the usage of "Snapshots_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Snapshots_Create.json + // this example is just showing the usage of "Snapshots_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +102,15 @@ public async Task Delete_SnapshotsDelete() NetAppVolumeSnapshotResource netAppVolumeSnapshot = client.GetNetAppVolumeSnapshotResource(netAppVolumeSnapshotResourceId); // invoke the operation - await netAppVolumeSnapshot.DeleteAsync(WaitUntil.Completed); + NetAppVolumeSnapshotData data = new NetAppVolumeSnapshotData(new AzureLocation("eastus")); + ArmOperation lro = await netAppVolumeSnapshot.UpdateAsync(WaitUntil.Completed, data); + NetAppVolumeSnapshotResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppVolumeSnapshotData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -137,10 +137,7 @@ public async Task RestoreFiles_SnapshotsSingleFileRestore() NetAppVolumeSnapshotResource netAppVolumeSnapshot = client.GetNetAppVolumeSnapshotResource(netAppVolumeSnapshotResourceId); // invoke the operation - NetAppVolumeSnapshotRestoreFilesContent content = new NetAppVolumeSnapshotRestoreFilesContent(new string[] - { -"/dir1/customer1.db","/dir1/customer2.db" - }); + NetAppVolumeSnapshotRestoreFilesContent content = new NetAppVolumeSnapshotRestoreFilesContent(new string[] { "/dir1/customer1.db", "/dir1/customer2.db" }); await netAppVolumeSnapshot.RestoreFilesAsync(WaitUntil.Completed, content); Console.WriteLine("Succeeded"); diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_RegionInfoResourceCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_RegionInfoResourceCollection.cs index 68e3145fb8548..9e5cfeb5fa17c 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_RegionInfoResourceCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_RegionInfoResourceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RegionInfoResourceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RegionInfosList() + public async Task Get_RegionInfosGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/RegionInfos_List.json - // this example is just showing the usage of "NetAppResourceRegionInfos_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/RegionInfos_Get.json + // this example is just showing the usage of "NetAppResourceRegionInfos_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,22 @@ public async Task GetAll_RegionInfosList() AzureLocation location = new AzureLocation("eastus"); RegionInfoResourceCollection collection = subscriptionResource.GetRegionInfoResources(location); - // invoke the operation and iterate over the result - await foreach (RegionInfoResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RegionInfoResourceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + RegionInfoResource result = await collection.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegionInfoResourceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RegionInfosGet() + public async Task GetAll_RegionInfosList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/RegionInfos_Get.json - // this example is just showing the usage of "NetAppResourceRegionInfos_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/RegionInfos_List.json + // this example is just showing the usage of "NetAppResourceRegionInfos_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,14 +70,17 @@ public async Task Get_RegionInfosGet() AzureLocation location = new AzureLocation("eastus"); RegionInfoResourceCollection collection = subscriptionResource.GetRegionInfoResources(location); - // invoke the operation - RegionInfoResource result = await collection.GetAsync(); + // invoke the operation and iterate over the result + await foreach (RegionInfoResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RegionInfoResourceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RegionInfoResourceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SnapshotPolicyCollection.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SnapshotPolicyCollection.cs index 180890aa1f064..7aea74cb13f82 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SnapshotPolicyCollection.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SnapshotPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SnapshotPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_SnapshotPoliciesList() + public async Task CreateOrUpdate_SnapshotPoliciesCreate() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/SnapshotPolicies_List.json - // this example is just showing the usage of "SnapshotPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/SnapshotPolicies_Create.json + // this example is just showing the usage of "SnapshotPolicies_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,45 @@ public async Task GetAll_SnapshotPoliciesList() // get the collection of this SnapshotPolicyResource SnapshotPolicyCollection collection = netAppAccount.GetSnapshotPolicies(); - // invoke the operation and iterate over the result - await foreach (SnapshotPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string snapshotPolicyName = "snapshotPolicyName"; + SnapshotPolicyData data = new SnapshotPolicyData(new AzureLocation("eastus")) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SnapshotPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + HourlySchedule = new SnapshotPolicyHourlySchedule + { + SnapshotsToKeep = 2, + Minute = 50, + }, + DailySchedule = new SnapshotPolicyDailySchedule + { + SnapshotsToKeep = 4, + Hour = 14, + Minute = 30, + }, + WeeklySchedule = new SnapshotPolicyWeeklySchedule + { + SnapshotsToKeep = 3, + Day = "Wednesday", + Hour = 14, + Minute = 45, + }, + MonthlySchedule = new SnapshotPolicyMonthlySchedule + { + SnapshotsToKeep = 5, + DaysOfMonth = "10,11,12", + Hour = 14, + Minute = 15, + }, + IsEnabled = true, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, snapshotPolicyName, data); + SnapshotPolicyResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SnapshotPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +116,10 @@ public async Task Get_SnapshotPoliciesGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_SnapshotPoliciesGet() + public async Task GetAll_SnapshotPoliciesList() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/SnapshotPolicies_Get.json - // this example is just showing the usage of "SnapshotPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/SnapshotPolicies_List.json + // this example is just showing the usage of "SnapshotPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +137,22 @@ public async Task Exists_SnapshotPoliciesGet() // get the collection of this SnapshotPolicyResource SnapshotPolicyCollection collection = netAppAccount.GetSnapshotPolicies(); - // invoke the operation - string snapshotPolicyName = "snapshotPolicyName"; - bool result = await collection.ExistsAsync(snapshotPolicyName); + // invoke the operation and iterate over the result + await foreach (SnapshotPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SnapshotPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_SnapshotPoliciesGet() + public async Task Exists_SnapshotPoliciesGet() { // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/SnapshotPolicies_Get.json // this example is just showing the usage of "SnapshotPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +175,17 @@ public async Task GetIfExists_SnapshotPoliciesGet() // invoke the operation string snapshotPolicyName = "snapshotPolicyName"; - NullableResponse response = await collection.GetIfExistsAsync(snapshotPolicyName); - SnapshotPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(snapshotPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SnapshotPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SnapshotPoliciesCreate() + public async Task GetIfExists_SnapshotPoliciesGet() { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/SnapshotPolicies_Create.json - // this example is just showing the usage of "SnapshotPolicies_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/SnapshotPolicies_Get.json + // this example is just showing the usage of "SnapshotPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,43 +205,21 @@ public async Task CreateOrUpdate_SnapshotPoliciesCreate() // invoke the operation string snapshotPolicyName = "snapshotPolicyName"; - SnapshotPolicyData data = new SnapshotPolicyData(new AzureLocation("eastus")) - { - HourlySchedule = new SnapshotPolicyHourlySchedule() - { - SnapshotsToKeep = 2, - Minute = 50, - }, - DailySchedule = new SnapshotPolicyDailySchedule() - { - SnapshotsToKeep = 4, - Hour = 14, - Minute = 30, - }, - WeeklySchedule = new SnapshotPolicyWeeklySchedule() - { - SnapshotsToKeep = 3, - Day = "Wednesday", - Hour = 14, - Minute = 45, - }, - MonthlySchedule = new SnapshotPolicyMonthlySchedule() - { - SnapshotsToKeep = 5, - DaysOfMonth = "10,11,12", - Hour = 14, - Minute = 15, - }, - IsEnabled = true, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, snapshotPolicyName, data); - SnapshotPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(snapshotPolicyName); + SnapshotPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SnapshotPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SnapshotPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SnapshotPolicyResource.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SnapshotPolicyResource.cs index b44bac74f72be..ec8d8f12c5e27 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SnapshotPolicyResource.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SnapshotPolicyResource.cs @@ -47,6 +47,33 @@ public async Task Get_SnapshotPoliciesGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_SnapshotPoliciesDelete() + { + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/SnapshotPolicies_Delete.json + // this example is just showing the usage of "SnapshotPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SnapshotPolicyResource created on azure + // for more information of creating SnapshotPolicyResource, please refer to the document of SnapshotPolicyResource + string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; + string resourceGroupName = "resourceGroup"; + string accountName = "accountName"; + string snapshotPolicyName = "snapshotPolicyName"; + ResourceIdentifier snapshotPolicyResourceId = SnapshotPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, snapshotPolicyName); + SnapshotPolicyResource snapshotPolicy = client.GetSnapshotPolicyResource(snapshotPolicyResourceId); + + // invoke the operation + await snapshotPolicy.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_SnapshotPoliciesUpdate() @@ -71,25 +98,25 @@ public async Task Update_SnapshotPoliciesUpdate() // invoke the operation SnapshotPolicyPatch patch = new SnapshotPolicyPatch(new AzureLocation("eastus")) { - HourlySchedule = new SnapshotPolicyHourlySchedule() + HourlySchedule = new SnapshotPolicyHourlySchedule { SnapshotsToKeep = 2, Minute = 50, }, - DailySchedule = new SnapshotPolicyDailySchedule() + DailySchedule = new SnapshotPolicyDailySchedule { SnapshotsToKeep = 4, Hour = 14, Minute = 30, }, - WeeklySchedule = new SnapshotPolicyWeeklySchedule() + WeeklySchedule = new SnapshotPolicyWeeklySchedule { SnapshotsToKeep = 3, Day = "Wednesday", Hour = 14, Minute = 45, }, - MonthlySchedule = new SnapshotPolicyMonthlySchedule() + MonthlySchedule = new SnapshotPolicyMonthlySchedule { SnapshotsToKeep = 5, DaysOfMonth = "10,11,12", @@ -108,33 +135,6 @@ public async Task Update_SnapshotPoliciesUpdate() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_SnapshotPoliciesDelete() - { - // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/SnapshotPolicies_Delete.json - // this example is just showing the usage of "SnapshotPolicies_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SnapshotPolicyResource created on azure - // for more information of creating SnapshotPolicyResource, please refer to the document of SnapshotPolicyResource - string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; - string resourceGroupName = "resourceGroup"; - string accountName = "accountName"; - string snapshotPolicyName = "snapshotPolicyName"; - ResourceIdentifier snapshotPolicyResourceId = SnapshotPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, accountName, snapshotPolicyName); - SnapshotPolicyResource snapshotPolicy = client.GetSnapshotPolicyResource(snapshotPolicyResourceId); - - // invoke the operation - await snapshotPolicy.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetVolumes_SnapshotPoliciesListVolumes() diff --git a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index 8032b0ec95265..ad10581256b57 100644 --- a/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/netapp/Azure.ResourceManager.NetApp/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -226,5 +226,36 @@ public async Task GetNetAppQuotaLimit_QuotaLimits() Console.WriteLine($"Succeeded: {result}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetAppAccounts_AccountsList() + { + // Generated from example definition: specification/netapp/resource-manager/Microsoft.NetApp/stable/2024-07-01/examples/Accounts_List.json + // this example is just showing the usage of "Accounts_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "D633CC2E-722B-4AE1-B636-BBD9E4C60ED9"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetAppAccountResource item in subscriptionResource.GetNetAppAccountsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetAppAccountData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AdminRuleGroupCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AdminRuleGroupCollection.cs index 0010d2a744b79..4dbdb5fddeb74 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AdminRuleGroupCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AdminRuleGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_AdminRuleGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecurityAdminRuleCollections() + public async Task CreateOrUpdate_CreateOrUpdateAnAdminRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionList.json - // this example is just showing the usage of "AdminRuleCollections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionPut.json + // this example is just showing the usage of "AdminRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,21 @@ public async Task GetAll_ListSecurityAdminRuleCollections() // get the collection of this AdminRuleGroupResource AdminRuleGroupCollection collection = securityAdminConfiguration.GetAdminRuleGroups(); - // invoke the operation and iterate over the result - await foreach (AdminRuleGroupResource item in collection.GetAllAsync()) + // invoke the operation + string ruleCollectionName = "testRuleCollection"; + AdminRuleGroupData data = new AdminRuleGroupData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdminRuleGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "A sample policy", + AppliesToGroups = { new NetworkManagerSecurityGroupItem(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup")) }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionName, data); + AdminRuleGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdminRuleGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +94,10 @@ public async Task Get_GetsSecurityAdminRuleCollection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsSecurityAdminRuleCollection() + public async Task GetAll_ListSecurityAdminRuleCollections() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionGet.json - // this example is just showing the usage of "AdminRuleCollections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionList.json + // this example is just showing the usage of "AdminRuleCollections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +116,22 @@ public async Task Exists_GetsSecurityAdminRuleCollection() // get the collection of this AdminRuleGroupResource AdminRuleGroupCollection collection = securityAdminConfiguration.GetAdminRuleGroups(); - // invoke the operation - string ruleCollectionName = "testRuleCollection"; - bool result = await collection.ExistsAsync(ruleCollectionName); + // invoke the operation and iterate over the result + await foreach (AdminRuleGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdminRuleGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsSecurityAdminRuleCollection() + public async Task Exists_GetsSecurityAdminRuleCollection() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionGet.json // this example is just showing the usage of "AdminRuleCollections_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +155,17 @@ public async Task GetIfExists_GetsSecurityAdminRuleCollection() // invoke the operation string ruleCollectionName = "testRuleCollection"; - NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionName); - AdminRuleGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleCollectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdminRuleGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateAnAdminRuleCollection() + public async Task GetIfExists_GetsSecurityAdminRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionPut.json - // this example is just showing the usage of "AdminRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionGet.json + // this example is just showing the usage of "AdminRuleCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,22 +186,21 @@ public async Task CreateOrUpdate_CreateOrUpdateAnAdminRuleCollection() // invoke the operation string ruleCollectionName = "testRuleCollection"; - AdminRuleGroupData data = new AdminRuleGroupData() - { - Description = "A sample policy", - AppliesToGroups = -{ -new NetworkManagerSecurityGroupItem(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup")) -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionName, data); - AdminRuleGroupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionName); + AdminRuleGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdminRuleGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdminRuleGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AdminRuleGroupResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AdminRuleGroupResource.cs index 8a91366e500c6..5f3742f648b7a 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AdminRuleGroupResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AdminRuleGroupResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetsSecurityAdminRuleCollection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateAnAdminRuleCollection() + public async Task Delete_DeletesAnAdminRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionPut.json - // this example is just showing the usage of "AdminRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionDelete.json + // this example is just showing the usage of "AdminRuleCollections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,30 +71,18 @@ public async Task Update_CreateOrUpdateAnAdminRuleCollection() AdminRuleGroupResource adminRuleGroup = client.GetAdminRuleGroupResource(adminRuleGroupResourceId); // invoke the operation - AdminRuleGroupData data = new AdminRuleGroupData() - { - Description = "A sample policy", - AppliesToGroups = -{ -new NetworkManagerSecurityGroupItem(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup")) -}, - }; - ArmOperation lro = await adminRuleGroup.UpdateAsync(WaitUntil.Completed, data); - AdminRuleGroupResource result = lro.Value; + bool? force = false; + await adminRuleGroup.DeleteAsync(WaitUntil.Completed, force: force); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AdminRuleGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAnAdminRuleCollection() + public async Task Update_CreateOrUpdateAnAdminRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionDelete.json - // this example is just showing the usage of "AdminRuleCollections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleCollectionPut.json + // this example is just showing the usage of "AdminRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,10 +100,19 @@ public async Task Delete_DeletesAnAdminRuleCollection() AdminRuleGroupResource adminRuleGroup = client.GetAdminRuleGroupResource(adminRuleGroupResourceId); // invoke the operation - bool? force = false; - await adminRuleGroup.DeleteAsync(WaitUntil.Completed, force: force); + AdminRuleGroupData data = new AdminRuleGroupData + { + Description = "A sample policy", + AppliesToGroups = { new NetworkManagerSecurityGroupItem(new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup")) }, + }; + ArmOperation lro = await adminRuleGroup.UpdateAsync(WaitUntil.Completed, data); + AdminRuleGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AdminRuleGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayCollection.cs index 8e5d51ec165a5..f02a7a33e3a52 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayCollection.cs @@ -19,109 +19,6 @@ namespace Azure.ResourceManager.Network.Samples { public partial class Sample_ApplicationGatewayCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetApplicationGateway() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayGet.json - // this example is just showing the usage of "ApplicationGateways_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ApplicationGatewayResource - ApplicationGatewayCollection collection = resourceGroupResource.GetApplicationGateways(); - - // invoke the operation - string applicationGatewayName = "appgw"; - ApplicationGatewayResource result = await collection.GetAsync(applicationGatewayName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetApplicationGateway() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayGet.json - // this example is just showing the usage of "ApplicationGateways_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ApplicationGatewayResource - ApplicationGatewayCollection collection = resourceGroupResource.GetApplicationGateways(); - - // invoke the operation - string applicationGatewayName = "appgw"; - bool result = await collection.ExistsAsync(applicationGatewayName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetApplicationGateway() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayGet.json - // this example is just showing the usage of "ApplicationGateways_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ApplicationGatewayResource - ApplicationGatewayCollection collection = resourceGroupResource.GetApplicationGateways(); - - // invoke the operation - string applicationGatewayName = "appgw"; - NullableResponse response = await collection.GetIfExistsAsync(applicationGatewayName); - ApplicationGatewayResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateApplicationGateway() @@ -146,127 +43,95 @@ public async Task CreateOrUpdate_CreateApplicationGateway() // invoke the operation string applicationGatewayName = "appgw"; - ApplicationGatewayData data = new ApplicationGatewayData() + ApplicationGatewayData data = new ApplicationGatewayData { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity() }, }, - Sku = new ApplicationGatewaySku() + Sku = new ApplicationGatewaySku { Name = ApplicationGatewaySkuName.StandardV2, Tier = ApplicationGatewayTier.StandardV2, Capacity = 3, }, - GatewayIPConfigurations = -{ -new ApplicationGatewayIPConfiguration() + GatewayIPConfigurations = {new ApplicationGatewayIPConfiguration { SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet/subnets/appgwsubnet"), Name = "appgwipc", -} -}, - TrustedRootCertificates = -{ -new ApplicationGatewayTrustedRootCertificate() +}}, + TrustedRootCertificates = {new ApplicationGatewayTrustedRootCertificate { -Data = BinaryData.FromString("\"****\""), +Data = BinaryData.FromObjectAsJson("****"), Name = "rootcert", -},new ApplicationGatewayTrustedRootCertificate() +}, new ApplicationGatewayTrustedRootCertificate { KeyVaultSecretId = "https://kv/secret", Name = "rootcert1", -} -}, - TrustedClientCertificates = +}}, + TrustedClientCertificates = {new ApplicationGatewayTrustedClientCertificate { -new ApplicationGatewayTrustedClientCertificate() -{ -Data = BinaryData.FromString("\"****\""), +Data = BinaryData.FromObjectAsJson("****"), Name = "clientcert", -} -}, - SslCertificates = -{ -new ApplicationGatewaySslCertificate() +}}, + SslCertificates = {new ApplicationGatewaySslCertificate { -Data = BinaryData.FromString("\"****\""), +Data = BinaryData.FromObjectAsJson("****"), Password = "****", Name = "sslcert", -},new ApplicationGatewaySslCertificate() +}, new ApplicationGatewaySslCertificate { KeyVaultSecretId = "https://kv/secret", Name = "sslcert2", -} -}, - FrontendIPConfigurations = -{ -new ApplicationGatewayFrontendIPConfiguration() +}}, + FrontendIPConfigurations = {new ApplicationGatewayFrontendIPConfiguration { PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/appgwpip"), Name = "appgwfip", -} -}, - FrontendPorts = -{ -new ApplicationGatewayFrontendPort() +}}, + FrontendPorts = {new ApplicationGatewayFrontendPort { Port = 443, Name = "appgwfp", -},new ApplicationGatewayFrontendPort() +}, new ApplicationGatewayFrontendPort { Port = 80, Name = "appgwfp80", -} -}, - BackendAddressPools = +}}, + BackendAddressPools = {new ApplicationGatewayBackendAddressPool { -new ApplicationGatewayBackendAddressPool() -{ -BackendAddresses = -{ -new ApplicationGatewayBackendAddress() +BackendAddresses = {new ApplicationGatewayBackendAddress { IPAddress = "10.0.1.1", -},new ApplicationGatewayBackendAddress() +}, new ApplicationGatewayBackendAddress { IPAddress = "10.0.1.2", -} -}, +}}, Name = "appgwpool", -},new ApplicationGatewayBackendAddressPool() +}, new ApplicationGatewayBackendAddressPool { -BackendAddresses = -{ -new ApplicationGatewayBackendAddress() +BackendAddresses = {new ApplicationGatewayBackendAddress { IPAddress = "10.0.0.1", -},new ApplicationGatewayBackendAddress() +}, new ApplicationGatewayBackendAddress { IPAddress = "10.0.0.2", -} -}, +}}, Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationGateways/appgw/backendAddressPools/appgwpool1"), Name = "appgwpool1", -} -}, - BackendHttpSettingsCollection = -{ -new ApplicationGatewayBackendHttpSettings() +}}, + BackendHttpSettingsCollection = {new ApplicationGatewayBackendHttpSettings { Port = 80, Protocol = ApplicationGatewayProtocol.Http, CookieBasedAffinity = ApplicationGatewayCookieBasedAffinity.Disabled, RequestTimeoutInSeconds = 30, Name = "appgwbhs", -} -}, - HttpListeners = -{ -new ApplicationGatewayHttpListener() +}}, + HttpListeners = {new ApplicationGatewayHttpListener { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationGateways/appgw/frontendIPConfigurations/appgwfip"), FrontendPortId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationGateways/appgw/frontendPorts/appgwfp"), @@ -275,44 +140,32 @@ public async Task CreateOrUpdate_CreateApplicationGateway() SslProfileId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationGateways/appgw/sslProfiles/sslProfile1"), RequireServerNameIndication = false, Name = "appgwhl", -},new ApplicationGatewayHttpListener() +}, new ApplicationGatewayHttpListener { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationGateways/appgw/frontendIPConfigurations/appgwfip"), FrontendPortId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationGateways/appgw/frontendPorts/appgwfp80"), Protocol = ApplicationGatewayProtocol.Http, Name = "appgwhttplistener", -} -}, - SslProfiles = -{ -new ApplicationGatewaySslProfile() -{ -TrustedClientCertificates = +}}, + SslProfiles = {new ApplicationGatewaySslProfile { -new WritableSubResource() +TrustedClientCertificates = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationGateways/appgw/trustedClientCertificates/clientcert"), -} -}, -SslPolicy = new ApplicationGatewaySslPolicy() +}}, +SslPolicy = new ApplicationGatewaySslPolicy { PolicyType = ApplicationGatewaySslPolicyType.Custom, -CipherSuites = -{ -ApplicationGatewaySslCipherSuite.TlsECDiffieHellmanRsaWithAes128CbcSha256 -}, +CipherSuites = {ApplicationGatewaySslCipherSuite.TlsECDiffieHellmanRsaWithAes128CbcSha256}, MinProtocolVersion = ApplicationGatewaySslProtocol.Tls1_1, }, -ClientAuthConfiguration = new ApplicationGatewayClientAuthConfiguration() +ClientAuthConfiguration = new ApplicationGatewayClientAuthConfiguration { VerifyClientCertIssuerDN = true, }, Name = "sslProfile1", -} -}, - RequestRoutingRules = -{ -new ApplicationGatewayRequestRoutingRule() +}}, + RequestRoutingRules = {new ApplicationGatewayRequestRoutingRule { RuleType = ApplicationGatewayRequestRoutingRuleType.Basic, Priority = 10, @@ -321,57 +174,41 @@ public async Task CreateOrUpdate_CreateApplicationGateway() HttpListenerId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationGateways/appgw/httpListeners/appgwhl"), RewriteRuleSetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/applicationGateways/appgw/rewriteRuleSets/rewriteRuleSet1"), Name = "appgwrule", -} -}, - RewriteRuleSets = -{ -new ApplicationGatewayRewriteRuleSet() +}}, + RewriteRuleSets = {new ApplicationGatewayRewriteRuleSet { -RewriteRules = -{ -new ApplicationGatewayRewriteRule() +RewriteRules = {new ApplicationGatewayRewriteRule { Name = "Set X-Forwarded-For", RuleSequence = 102, -Conditions = -{ -new ApplicationGatewayRewriteRuleCondition() +Conditions = {new ApplicationGatewayRewriteRuleCondition { Variable = "http_req_Authorization", Pattern = "^Bearer", IgnoreCase = true, Negate = false, -} -}, -ActionSet = new ApplicationGatewayRewriteRuleActionSet() +}}, +ActionSet = new ApplicationGatewayRewriteRuleActionSet { -RequestHeaderConfigurations = -{ -new ApplicationGatewayHeaderConfiguration() +RequestHeaderConfigurations = {new ApplicationGatewayHeaderConfiguration { HeaderName = "X-Forwarded-For", HeaderValue = "{var_add_x_forwarded_for_proxy}", -} -}, -ResponseHeaderConfigurations = -{ -new ApplicationGatewayHeaderConfiguration() +}}, +ResponseHeaderConfigurations = {new ApplicationGatewayHeaderConfiguration { HeaderName = "Strict-Transport-Security", HeaderValue = "max-age=31536000", -} -}, -UrlConfiguration = new ApplicationGatewayUrlConfiguration() +}}, +UrlConfiguration = new ApplicationGatewayUrlConfiguration { ModifiedPath = "/abc", }, }, -} -}, +}}, Name = "rewriteRuleSet1", -} -}, - GlobalConfiguration = new ApplicationGatewayGlobalConfiguration() +}}, + GlobalConfiguration = new ApplicationGatewayGlobalConfiguration { EnableRequestBuffering = true, EnableResponseBuffering = true, @@ -388,6 +225,39 @@ public async Task CreateOrUpdate_CreateApplicationGateway() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetApplicationGateway() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayGet.json + // this example is just showing the usage of "ApplicationGateways_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ApplicationGatewayResource + ApplicationGatewayCollection collection = resourceGroupResource.GetApplicationGateways(); + + // invoke the operation + string applicationGatewayName = "appgw"; + ApplicationGatewayResource result = await collection.GetAsync(applicationGatewayName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListsAllApplicationGatewaysInAResourceGroup() @@ -422,5 +292,75 @@ public async Task GetAll_ListsAllApplicationGatewaysInAResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetApplicationGateway() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayGet.json + // this example is just showing the usage of "ApplicationGateways_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ApplicationGatewayResource + ApplicationGatewayCollection collection = resourceGroupResource.GetApplicationGateways(); + + // invoke the operation + string applicationGatewayName = "appgw"; + bool result = await collection.ExistsAsync(applicationGatewayName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetApplicationGateway() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayGet.json + // this example is just showing the usage of "ApplicationGateways_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ApplicationGatewayResource + ApplicationGatewayCollection collection = resourceGroupResource.GetApplicationGateways(); + + // invoke the operation + string applicationGatewayName = "appgw"; + NullableResponse response = await collection.GetIfExistsAsync(applicationGatewayName); + ApplicationGatewayResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayPrivateEndpointConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayPrivateEndpointConnectionCollection.cs index 879037545fa78..4c1c70b66b6de 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayPrivateEndpointConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayPrivateEndpointConnectionCollection.cs @@ -41,9 +41,9 @@ public async Task CreateOrUpdate_UpdateApplicationGatewayPrivateEndpointConnecti // invoke the operation string connectionName = "connection1"; - ApplicationGatewayPrivateEndpointConnectionData data = new ApplicationGatewayPrivateEndpointConnectionData() + ApplicationGatewayPrivateEndpointConnectionData data = new ApplicationGatewayPrivateEndpointConnectionData { - ConnectionState = new NetworkPrivateLinkServiceConnectionState() + ConnectionState = new NetworkPrivateLinkServiceConnectionState { Status = "Approved", Description = "approved it for some reason.", @@ -96,10 +96,10 @@ public async Task Get_GetApplicationGatewayPrivateEndpointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetApplicationGatewayPrivateEndpointConnection() + public async Task GetAll_ListsAllPrivateEndpointConnectionsOnApplicationGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionGet.json - // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionList.json + // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -117,16 +117,22 @@ public async Task Exists_GetApplicationGatewayPrivateEndpointConnection() // get the collection of this ApplicationGatewayPrivateEndpointConnectionResource ApplicationGatewayPrivateEndpointConnectionCollection collection = applicationGateway.GetApplicationGatewayPrivateEndpointConnections(); - // invoke the operation - string connectionName = "connection1"; - bool result = await collection.ExistsAsync(connectionName); + // invoke the operation and iterate over the result + await foreach (ApplicationGatewayPrivateEndpointConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationGatewayPrivateEndpointConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetApplicationGatewayPrivateEndpointConnection() + public async Task Exists_GetApplicationGatewayPrivateEndpointConnection() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionGet.json // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +155,17 @@ public async Task GetIfExists_GetApplicationGatewayPrivateEndpointConnection() // invoke the operation string connectionName = "connection1"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - ApplicationGatewayPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(connectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationGatewayPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsAllPrivateEndpointConnectionsOnApplicationGateway() + public async Task GetIfExists_GetApplicationGatewayPrivateEndpointConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionList.json - // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionGet.json + // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_ListsAllPrivateEndpointConnectionsOnApplicationGateway( // get the collection of this ApplicationGatewayPrivateEndpointConnectionResource ApplicationGatewayPrivateEndpointConnectionCollection collection = applicationGateway.GetApplicationGatewayPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (ApplicationGatewayPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string connectionName = "connection1"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + ApplicationGatewayPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApplicationGatewayPrivateEndpointConnectionData resourceData = item.Data; + ApplicationGatewayPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayPrivateEndpointConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayPrivateEndpointConnectionResource.cs index 0504bdee5eb65..18493d7030571 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayPrivateEndpointConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayPrivateEndpointConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ApplicationGatewayPrivateEndpointConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteApplicationGatewayPrivateEndpointConnection() + public async Task Get_GetApplicationGatewayPrivateEndpointConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionDelete.json - // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionGet.json + // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteApplicationGatewayPrivateEndpointConnection() ApplicationGatewayPrivateEndpointConnectionResource applicationGatewayPrivateEndpointConnection = client.GetApplicationGatewayPrivateEndpointConnectionResource(applicationGatewayPrivateEndpointConnectionResourceId); // invoke the operation - await applicationGatewayPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + ApplicationGatewayPrivateEndpointConnectionResource result = await applicationGatewayPrivateEndpointConnection.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationGatewayPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateApplicationGatewayPrivateEndpointConnection() + public async Task Delete_DeleteApplicationGatewayPrivateEndpointConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionUpdate.json - // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionDelete.json + // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,31 +69,17 @@ public async Task Update_UpdateApplicationGatewayPrivateEndpointConnection() ApplicationGatewayPrivateEndpointConnectionResource applicationGatewayPrivateEndpointConnection = client.GetApplicationGatewayPrivateEndpointConnectionResource(applicationGatewayPrivateEndpointConnectionResourceId); // invoke the operation - ApplicationGatewayPrivateEndpointConnectionData data = new ApplicationGatewayPrivateEndpointConnectionData() - { - ConnectionState = new NetworkPrivateLinkServiceConnectionState() - { - Status = "Approved", - Description = "approved it for some reason.", - }, - Name = "connection1", - }; - ArmOperation lro = await applicationGatewayPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - ApplicationGatewayPrivateEndpointConnectionResource result = lro.Value; + await applicationGatewayPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationGatewayPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetApplicationGatewayPrivateEndpointConnection() + public async Task Update_UpdateApplicationGatewayPrivateEndpointConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionGet.json - // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayPrivateEndpointConnectionUpdate.json + // this example is just showing the usage of "ApplicationGatewayPrivateEndpointConnections_Update" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,7 +96,17 @@ public async Task Get_GetApplicationGatewayPrivateEndpointConnection() ApplicationGatewayPrivateEndpointConnectionResource applicationGatewayPrivateEndpointConnection = client.GetApplicationGatewayPrivateEndpointConnectionResource(applicationGatewayPrivateEndpointConnectionResourceId); // invoke the operation - ApplicationGatewayPrivateEndpointConnectionResource result = await applicationGatewayPrivateEndpointConnection.GetAsync(); + ApplicationGatewayPrivateEndpointConnectionData data = new ApplicationGatewayPrivateEndpointConnectionData + { + ConnectionState = new NetworkPrivateLinkServiceConnectionState + { + Status = "Approved", + Description = "approved it for some reason.", + }, + Name = "connection1", + }; + ArmOperation lro = await applicationGatewayPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + ApplicationGatewayPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayResource.cs index a37bac8c040be..e9323ee61c0f4 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_ApplicationGatewayResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteApplicationGateway() + public async Task Get_GetApplicationGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayDelete.json - // this example is just showing the usage of "ApplicationGateways_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayGet.json + // this example is just showing the usage of "ApplicationGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteApplicationGateway() ApplicationGatewayResource applicationGateway = client.GetApplicationGatewayResource(applicationGatewayResourceId); // invoke the operation - await applicationGateway.DeleteAsync(WaitUntil.Completed); + ApplicationGatewayResource result = await applicationGateway.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetApplicationGateway() + public async Task Delete_DeleteApplicationGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayGet.json - // this example is just showing the usage of "ApplicationGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayDelete.json + // this example is just showing the usage of "ApplicationGateways_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetApplicationGateway() ApplicationGatewayResource applicationGateway = client.GetApplicationGatewayResource(applicationGatewayResourceId); // invoke the operation - ApplicationGatewayResource result = await applicationGateway.GetAsync(); + await applicationGateway.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateApplicationGatewayTags() ApplicationGatewayResource applicationGateway = client.GetApplicationGatewayResource(applicationGatewayResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ApplicationGatewayResource result = await applicationGateway.UpdateAsync(networkTagsObject); @@ -111,37 +110,6 @@ public async Task Update_UpdateApplicationGatewayTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApplicationGateways_ListsAllApplicationGatewaysInASubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayListAll.json - // this example is just showing the usage of "ApplicationGateways_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ApplicationGatewayResource item in subscriptionResource.GetApplicationGatewaysAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Start_StartApplicationGateway() @@ -242,7 +210,7 @@ public async Task BackendHealthOnDemand_TestBackendHealth() ApplicationGatewayResource applicationGateway = client.GetApplicationGatewayResource(applicationGatewayResourceId); // invoke the operation - ApplicationGatewayOnDemandProbe probeRequest = new ApplicationGatewayOnDemandProbe() + ApplicationGatewayOnDemandProbe probeRequest = new ApplicationGatewayOnDemandProbe { Protocol = ApplicationGatewayProtocol.Http, Path = "/", @@ -257,190 +225,6 @@ public async Task BackendHealthOnDemand_TestBackendHealth() Console.WriteLine($"Succeeded: {result}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAvailableServerVariablesApplicationGateways_GetAvailableServerVariables() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableServerVariablesGet.json - // this example is just showing the usage of "ApplicationGateways_ListAvailableServerVariables" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "72f988bf-86f1-41af-91ab-2d7cd0dddd4"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (string item in subscriptionResource.GetAvailableServerVariablesApplicationGatewaysAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAvailableRequestHeadersApplicationGateways_GetAvailableRequestHeaders() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableRequestHeadersGet.json - // this example is just showing the usage of "ApplicationGateways_ListAvailableRequestHeaders" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "72f988bf-86f1-41af-91ab-2d7cd0dddd4"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (string item in subscriptionResource.GetAvailableRequestHeadersApplicationGatewaysAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAvailableResponseHeadersApplicationGateways_GetAvailableResponseHeaders() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableResponseHeadersGet.json - // this example is just showing the usage of "ApplicationGateways_ListAvailableResponseHeaders" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "72f988bf-86f1-41af-91ab-2d7cd0dddd4"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (string item in subscriptionResource.GetAvailableResponseHeadersApplicationGatewaysAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAppGatewayAvailableWafRuleSets_GetAvailableWafRuleSets() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableWafRuleSetsGet.json - // this example is just showing the usage of "ApplicationGateways_ListAvailableWafRuleSets" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ApplicationGatewayFirewallRuleSet item in subscriptionResource.GetAppGatewayAvailableWafRuleSetsAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApplicationGatewayAvailableSslOptions_GetAvailableSslOptions() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableSslOptionsGet.json - // this example is just showing the usage of "ApplicationGateways_ListAvailableSslOptions" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - ApplicationGatewayAvailableSslOptionsInfo result = await subscriptionResource.GetApplicationGatewayAvailableSslOptionsAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApplicationGatewayAvailableSslPredefinedPolicies_GetAvailableSslPredefinedPolicies() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableSslOptionsPredefinedPoliciesGet.json - // this example is just showing the usage of "ApplicationGateways_ListAvailableSslPredefinedPolicies" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ApplicationGatewaySslPredefinedPolicy item in subscriptionResource.GetApplicationGatewayAvailableSslPredefinedPoliciesAsync()) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApplicationGatewaySslPredefinedPolicy_GetAvailableSslPredefinedPolicyByName() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableSslOptionsPredefinedPolicyGet.json - // this example is just showing the usage of "ApplicationGateways_GetSslPredefinedPolicy" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - string predefinedPolicyName = "AppGwSslPolicy20150501"; - ApplicationGatewaySslPredefinedPolicy result = await subscriptionResource.GetApplicationGatewaySslPredefinedPolicyAsync(predefinedPolicyName); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetApplicationGatewayPrivateLinkResources_ListsAllPrivateLinkResourcesOnApplicationGateway() diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayWafDynamicManifestCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayWafDynamicManifestCollection.cs index 44602d46ba642..196f3dd8cd2ae 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayWafDynamicManifestCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationGatewayWafDynamicManifestCollection.cs @@ -50,10 +50,10 @@ public async Task Get_GetsWAFDefaultManifest() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsWAFDefaultManifest() + public async Task GetAll_GetsWAFManifests() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/GetApplicationGatewayWafDynamicManifestsDefault.json - // this example is just showing the usage of "ApplicationGatewayWafDynamicManifestsDefault_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/GetApplicationGatewayWafDynamicManifests.json + // this example is just showing the usage of "ApplicationGatewayWafDynamicManifests_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,15 +70,22 @@ public async Task Exists_GetsWAFDefaultManifest() AzureLocation location = new AzureLocation("westus"); ApplicationGatewayWafDynamicManifestCollection collection = subscriptionResource.GetApplicationGatewayWafDynamicManifests(location); - // invoke the operation - bool result = await collection.ExistsAsync(); + // invoke the operation and iterate over the result + await foreach (ApplicationGatewayWafDynamicManifestResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationGatewayWafDynamicManifestData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsWAFDefaultManifest() + public async Task Exists_GetsWAFDefaultManifest() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/GetApplicationGatewayWafDynamicManifestsDefault.json // this example is just showing the usage of "ApplicationGatewayWafDynamicManifestsDefault_Get" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +106,17 @@ public async Task GetIfExists_GetsWAFDefaultManifest() ApplicationGatewayWafDynamicManifestCollection collection = subscriptionResource.GetApplicationGatewayWafDynamicManifests(location); // invoke the operation - NullableResponse response = await collection.GetIfExistsAsync(); - ApplicationGatewayWafDynamicManifestResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationGatewayWafDynamicManifestData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetsWAFManifests() + public async Task GetIfExists_GetsWAFDefaultManifest() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/GetApplicationGatewayWafDynamicManifests.json - // this example is just showing the usage of "ApplicationGatewayWafDynamicManifests_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/GetApplicationGatewayWafDynamicManifestsDefault.json + // this example is just showing the usage of "ApplicationGatewayWafDynamicManifestsDefault_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,17 +133,22 @@ public async Task GetAll_GetsWAFManifests() AzureLocation location = new AzureLocation("westus"); ApplicationGatewayWafDynamicManifestCollection collection = subscriptionResource.GetApplicationGatewayWafDynamicManifests(location); - // invoke the operation and iterate over the result - await foreach (ApplicationGatewayWafDynamicManifestResource item in collection.GetAllAsync()) + // invoke the operation + NullableResponse response = await collection.GetIfExistsAsync(); + ApplicationGatewayWafDynamicManifestResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApplicationGatewayWafDynamicManifestData resourceData = item.Data; + ApplicationGatewayWafDynamicManifestData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationSecurityGroupCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationSecurityGroupCollection.cs index d9edd7250a6d0..2a989d43f916f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationSecurityGroupCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationSecurityGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ApplicationSecurityGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetApplicationSecurityGroup() + public async Task CreateOrUpdate_CreateApplicationSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupGet.json - // this example is just showing the usage of "ApplicationSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupCreate.json + // this example is just showing the usage of "ApplicationSecurityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetApplicationSecurityGroup() // invoke the operation string applicationSecurityGroupName = "test-asg"; - ApplicationSecurityGroupResource result = await collection.GetAsync(applicationSecurityGroupName); + ApplicationSecurityGroupData data = new ApplicationSecurityGroupData + { + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationSecurityGroupName, data); + ApplicationSecurityGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetApplicationSecurityGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetApplicationSecurityGroup() + public async Task Get_GetApplicationSecurityGroup() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupGet.json // this example is just showing the usage of "ApplicationSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +78,21 @@ public async Task Exists_GetApplicationSecurityGroup() // invoke the operation string applicationSecurityGroupName = "test-asg"; - bool result = await collection.ExistsAsync(applicationSecurityGroupName); + ApplicationSecurityGroupResource result = await collection.GetAsync(applicationSecurityGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationSecurityGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetApplicationSecurityGroup() + public async Task GetAll_ListLoadBalancersInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupGet.json - // this example is just showing the usage of "ApplicationSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupList.json + // this example is just showing the usage of "ApplicationSecurityGroups_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +109,25 @@ public async Task GetIfExists_GetApplicationSecurityGroup() // get the collection of this ApplicationSecurityGroupResource ApplicationSecurityGroupCollection collection = resourceGroupResource.GetApplicationSecurityGroups(); - // invoke the operation - string applicationSecurityGroupName = "test-asg"; - NullableResponse response = await collection.GetIfExistsAsync(applicationSecurityGroupName); - ApplicationSecurityGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ApplicationSecurityGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApplicationSecurityGroupData resourceData = result.Data; + ApplicationSecurityGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateApplicationSecurityGroup() + public async Task Exists_GetApplicationSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupCreate.json - // this example is just showing the usage of "ApplicationSecurityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupGet.json + // this example is just showing the usage of "ApplicationSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,26 +146,17 @@ public async Task CreateOrUpdate_CreateApplicationSecurityGroup() // invoke the operation string applicationSecurityGroupName = "test-asg"; - ApplicationSecurityGroupData data = new ApplicationSecurityGroupData() - { - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, applicationSecurityGroupName, data); - ApplicationSecurityGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(applicationSecurityGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationSecurityGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListLoadBalancersInResourceGroup() + public async Task GetIfExists_GetApplicationSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupList.json - // this example is just showing the usage of "ApplicationSecurityGroups_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupGet.json + // this example is just showing the usage of "ApplicationSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_ListLoadBalancersInResourceGroup() // get the collection of this ApplicationSecurityGroupResource ApplicationSecurityGroupCollection collection = resourceGroupResource.GetApplicationSecurityGroups(); - // invoke the operation and iterate over the result - await foreach (ApplicationSecurityGroupResource item in collection.GetAllAsync()) + // invoke the operation + string applicationSecurityGroupName = "test-asg"; + NullableResponse response = await collection.GetIfExistsAsync(applicationSecurityGroupName); + ApplicationSecurityGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ApplicationSecurityGroupData resourceData = item.Data; + ApplicationSecurityGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationSecurityGroupResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationSecurityGroupResource.cs index 0712755b5cc37..105be38161c8f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationSecurityGroupResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ApplicationSecurityGroupResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_ApplicationSecurityGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteApplicationSecurityGroup() + public async Task Get_GetApplicationSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupDelete.json - // this example is just showing the usage of "ApplicationSecurityGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupGet.json + // this example is just showing the usage of "ApplicationSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteApplicationSecurityGroup() ApplicationSecurityGroupResource applicationSecurityGroup = client.GetApplicationSecurityGroupResource(applicationSecurityGroupResourceId); // invoke the operation - await applicationSecurityGroup.DeleteAsync(WaitUntil.Completed); + ApplicationSecurityGroupResource result = await applicationSecurityGroup.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationSecurityGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetApplicationSecurityGroup() + public async Task Delete_DeleteApplicationSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupGet.json - // this example is just showing the usage of "ApplicationSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupDelete.json + // this example is just showing the usage of "ApplicationSecurityGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetApplicationSecurityGroup() ApplicationSecurityGroupResource applicationSecurityGroup = client.GetApplicationSecurityGroupResource(applicationSecurityGroupResourceId); // invoke the operation - ApplicationSecurityGroupResource result = await applicationSecurityGroup.GetAsync(); + await applicationSecurityGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationSecurityGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateApplicationSecurityGroupTags() ApplicationSecurityGroupResource applicationSecurityGroup = client.GetApplicationSecurityGroupResource(applicationSecurityGroupResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ApplicationSecurityGroupResource result = await applicationSecurityGroup.UpdateAsync(networkTagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdateApplicationSecurityGroupTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetApplicationSecurityGroups_ListAllApplicationSecurityGroups() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupListAll.json - // this example is just showing the usage of "ApplicationSecurityGroups_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ApplicationSecurityGroupResource item in subscriptionResource.GetApplicationSecurityGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ApplicationSecurityGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureFirewallCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureFirewallCollection.cs index 2dee92c9936f0..b5dc96ecc52d6 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureFirewallCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureFirewallCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_AzureFirewallCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureFirewall() + public async Task CreateOrUpdate_CreateAzureFirewall() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGet.json - // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPut.json + // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,100 @@ public async Task Get_GetAzureFirewall() // invoke the operation string azureFirewallName = "azurefirewall"; - AzureFirewallResource result = await collection.GetAsync(azureFirewallName); + AzureFirewallData data = new AzureFirewallData + { + Zones = { }, + ApplicationRuleCollections = {new AzureFirewallApplicationRuleCollectionData +{ +Priority = 110, +ActionType = AzureFirewallRCActionType.Deny, +Rules = {new AzureFirewallApplicationRule +{ +Name = "rule1", +Description = "Deny inbound rule", +SourceAddresses = {"216.58.216.164", "10.0.0.0/24"}, +Protocols = {new AzureFirewallApplicationRuleProtocol +{ +ProtocolType = AzureFirewallApplicationRuleProtocolType.Https, +Port = 443, +}}, +TargetFqdns = {"www.test.com"}, +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/applicationRuleCollections/apprulecoll"), +Name = "apprulecoll", +}}, + NatRuleCollections = {new AzureFirewallNatRuleCollectionData +{ +Priority = 112, +ActionType = AzureFirewallNatRCActionType.Dnat, +Rules = {new AzureFirewallNatRule +{ +Name = "DNAT-HTTPS-traffic", +Description = "D-NAT all outbound web traffic for inspection", +SourceAddresses = {"*"}, +DestinationAddresses = {"1.2.3.4"}, +DestinationPorts = {"443"}, +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +TranslatedAddress = "1.2.3.5", +TranslatedPort = "8443", +}, new AzureFirewallNatRule +{ +Name = "DNAT-HTTP-traffic-With-FQDN", +Description = "D-NAT all inbound web traffic for inspection", +SourceAddresses = {"*"}, +DestinationAddresses = {"1.2.3.4"}, +DestinationPorts = {"80"}, +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +TranslatedPort = "880", +TranslatedFqdn = "internalhttpserver", +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/natRuleCollections/natrulecoll"), +Name = "natrulecoll", +}}, + NetworkRuleCollections = {new AzureFirewallNetworkRuleCollectionData +{ +Priority = 112, +ActionType = AzureFirewallRCActionType.Deny, +Rules = {new AzureFirewallNetworkRule +{ +Name = "L4-traffic", +Description = "Block traffic based on source IPs and ports", +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +SourceAddresses = {"192.168.1.1-192.168.1.12", "10.1.4.12-10.1.4.255"}, +DestinationAddresses = {"*"}, +DestinationPorts = {"443-444", "8443"}, +}, new AzureFirewallNetworkRule +{ +Name = "L4-traffic-with-FQDN", +Description = "Block traffic based on source IPs and ports to amazon", +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +SourceAddresses = {"10.2.4.12-10.2.4.255"}, +DestinationPorts = {"443-444", "8443"}, +DestinationFqdns = {"www.amazon.com"}, +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/networkRuleCollections/netrulecoll"), +Name = "netrulecoll", +}}, + IPConfigurations = {new AzureFirewallIPConfiguration +{ +SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallSubnet"), +PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), +Name = "azureFirewallIpConfiguration", +}}, + ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, + Sku = new AzureFirewallSku + { + Name = AzureFirewallSkuName.AzfwVnet, + Tier = AzureFirewallSkuTier.Standard, + }, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); + AzureFirewallResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +145,10 @@ public async Task Get_GetAzureFirewall() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureFirewall() + public async Task CreateOrUpdate_CreateAzureFirewallWithAdditionalProperties() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGet.json - // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPutWithAdditionalProperties.json + // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,17 +167,119 @@ public async Task Exists_GetAzureFirewall() // invoke the operation string azureFirewallName = "azurefirewall"; - bool result = await collection.ExistsAsync(azureFirewallName); + AzureFirewallData data = new AzureFirewallData + { + Zones = { }, + ApplicationRuleCollections = {new AzureFirewallApplicationRuleCollectionData +{ +Priority = 110, +ActionType = AzureFirewallRCActionType.Deny, +Rules = {new AzureFirewallApplicationRule +{ +Name = "rule1", +Description = "Deny inbound rule", +SourceAddresses = {"216.58.216.164", "10.0.0.0/24"}, +Protocols = {new AzureFirewallApplicationRuleProtocol +{ +ProtocolType = AzureFirewallApplicationRuleProtocolType.Https, +Port = 443, +}}, +TargetFqdns = {"www.test.com"}, +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/applicationRuleCollections/apprulecoll"), +Name = "apprulecoll", +}}, + NatRuleCollections = {new AzureFirewallNatRuleCollectionData +{ +Priority = 112, +ActionType = AzureFirewallNatRCActionType.Dnat, +Rules = {new AzureFirewallNatRule +{ +Name = "DNAT-HTTPS-traffic", +Description = "D-NAT all outbound web traffic for inspection", +SourceAddresses = {"*"}, +DestinationAddresses = {"1.2.3.4"}, +DestinationPorts = {"443"}, +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +TranslatedAddress = "1.2.3.5", +TranslatedPort = "8443", +}, new AzureFirewallNatRule +{ +Name = "DNAT-HTTP-traffic-With-FQDN", +Description = "D-NAT all inbound web traffic for inspection", +SourceAddresses = {"*"}, +DestinationAddresses = {"1.2.3.4"}, +DestinationPorts = {"80"}, +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +TranslatedPort = "880", +TranslatedFqdn = "internalhttpserver", +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/natRuleCollections/natrulecoll"), +Name = "natrulecoll", +}}, + NetworkRuleCollections = {new AzureFirewallNetworkRuleCollectionData +{ +Priority = 112, +ActionType = AzureFirewallRCActionType.Deny, +Rules = {new AzureFirewallNetworkRule +{ +Name = "L4-traffic", +Description = "Block traffic based on source IPs and ports", +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +SourceAddresses = {"192.168.1.1-192.168.1.12", "10.1.4.12-10.1.4.255"}, +DestinationAddresses = {"*"}, +DestinationPorts = {"443-444", "8443"}, +}, new AzureFirewallNetworkRule +{ +Name = "L4-traffic-with-FQDN", +Description = "Block traffic based on source IPs and ports to amazon", +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +SourceAddresses = {"10.2.4.12-10.2.4.255"}, +DestinationPorts = {"443-444", "8443"}, +DestinationFqdns = {"www.amazon.com"}, +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/networkRuleCollections/netrulecoll"), +Name = "netrulecoll", +}}, + IPConfigurations = {new AzureFirewallIPConfiguration +{ +SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallSubnet"), +PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), +Name = "azureFirewallIpConfiguration", +}}, + ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, + Sku = new AzureFirewallSku + { + Name = AzureFirewallSkuName.AzfwVnet, + Tier = AzureFirewallSkuTier.Standard, + }, + AdditionalProperties = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); + AzureFirewallResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureFirewall() + public async Task CreateOrUpdate_CreateAzureFirewallWithIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGet.json - // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPutWithIpGroups.json + // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,48 +298,100 @@ public async Task GetIfExists_GetAzureFirewall() // invoke the operation string azureFirewallName = "azurefirewall"; - NullableResponse response = await collection.GetIfExistsAsync(azureFirewallName); - AzureFirewallResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + AzureFirewallData data = new AzureFirewallData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureFirewallWithAdditionalProperties() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithAdditionalProperties.json - // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this AzureFirewallResource - AzureFirewallCollection collection = resourceGroupResource.GetAzureFirewalls(); - - // invoke the operation - string azureFirewallName = "azurefirewall"; - AzureFirewallResource result = await collection.GetAsync(azureFirewallName); + Zones = { }, + ApplicationRuleCollections = {new AzureFirewallApplicationRuleCollectionData +{ +Priority = 110, +ActionType = AzureFirewallRCActionType.Deny, +Rules = {new AzureFirewallApplicationRule +{ +Name = "rule1", +Description = "Deny inbound rule", +SourceAddresses = {"216.58.216.164", "10.0.0.0/24"}, +Protocols = {new AzureFirewallApplicationRuleProtocol +{ +ProtocolType = AzureFirewallApplicationRuleProtocolType.Https, +Port = 443, +}}, +TargetFqdns = {"www.test.com"}, +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/applicationRuleCollections/apprulecoll"), +Name = "apprulecoll", +}}, + NatRuleCollections = {new AzureFirewallNatRuleCollectionData +{ +Priority = 112, +ActionType = AzureFirewallNatRCActionType.Dnat, +Rules = {new AzureFirewallNatRule +{ +Name = "DNAT-HTTPS-traffic", +Description = "D-NAT all outbound web traffic for inspection", +SourceAddresses = {"*"}, +DestinationAddresses = {"1.2.3.4"}, +DestinationPorts = {"443"}, +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +TranslatedAddress = "1.2.3.5", +TranslatedPort = "8443", +}, new AzureFirewallNatRule +{ +Name = "DNAT-HTTP-traffic-With-FQDN", +Description = "D-NAT all inbound web traffic for inspection", +SourceAddresses = {"*"}, +DestinationAddresses = {"1.2.3.4"}, +DestinationPorts = {"80"}, +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +TranslatedPort = "880", +TranslatedFqdn = "internalhttpserver", +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/natRuleCollections/natrulecoll"), +Name = "natrulecoll", +}}, + NetworkRuleCollections = {new AzureFirewallNetworkRuleCollectionData +{ +Priority = 112, +ActionType = AzureFirewallRCActionType.Deny, +Rules = {new AzureFirewallNetworkRule +{ +Name = "L4-traffic", +Description = "Block traffic based on source IPs and ports", +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +SourceAddresses = {"192.168.1.1-192.168.1.12", "10.1.4.12-10.1.4.255"}, +DestinationAddresses = {"*"}, +DestinationPorts = {"443-444", "8443"}, +}, new AzureFirewallNetworkRule +{ +Name = "L4-traffic-with-FQDN", +Description = "Block traffic based on source IPs and ports to amazon", +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +SourceAddresses = {"10.2.4.12-10.2.4.255"}, +DestinationPorts = {"443-444", "8443"}, +DestinationFqdns = {"www.amazon.com"}, +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/networkRuleCollections/netrulecoll"), +Name = "netrulecoll", +}}, + IPConfigurations = {new AzureFirewallIPConfiguration +{ +SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallSubnet"), +PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), +Name = "azureFirewallIpConfiguration", +}}, + ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, + Sku = new AzureFirewallSku + { + Name = AzureFirewallSkuName.AzfwVnet, + Tier = AzureFirewallSkuTier.Standard, + }, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); + AzureFirewallResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -155,10 +402,10 @@ public async Task Get_GetAzureFirewallWithAdditionalProperties() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureFirewallWithAdditionalProperties() + public async Task CreateOrUpdate_CreateAzureFirewallWithZones() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithAdditionalProperties.json - // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPutWithZones.json + // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -177,58 +424,114 @@ public async Task Exists_GetAzureFirewallWithAdditionalProperties() // invoke the operation string azureFirewallName = "azurefirewall"; - bool result = await collection.ExistsAsync(azureFirewallName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureFirewallWithAdditionalProperties() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithAdditionalProperties.json - // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this AzureFirewallResource - AzureFirewallCollection collection = resourceGroupResource.GetAzureFirewalls(); - - // invoke the operation - string azureFirewallName = "azurefirewall"; - NullableResponse response = await collection.GetIfExistsAsync(azureFirewallName); - AzureFirewallResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + AzureFirewallData data = new AzureFirewallData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Zones = { "1", "2", "3" }, + ApplicationRuleCollections = {new AzureFirewallApplicationRuleCollectionData +{ +Priority = 110, +ActionType = AzureFirewallRCActionType.Deny, +Rules = {new AzureFirewallApplicationRule +{ +Name = "rule1", +Description = "Deny inbound rule", +SourceAddresses = {"216.58.216.164", "10.0.0.0/24"}, +Protocols = {new AzureFirewallApplicationRuleProtocol +{ +ProtocolType = AzureFirewallApplicationRuleProtocolType.Https, +Port = 443, +}}, +TargetFqdns = {"www.test.com"}, +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/applicationRuleCollections/apprulecoll"), +Name = "apprulecoll", +}}, + NatRuleCollections = {new AzureFirewallNatRuleCollectionData +{ +Priority = 112, +ActionType = AzureFirewallNatRCActionType.Dnat, +Rules = {new AzureFirewallNatRule +{ +Name = "DNAT-HTTPS-traffic", +Description = "D-NAT all outbound web traffic for inspection", +SourceAddresses = {"*"}, +DestinationAddresses = {"1.2.3.4"}, +DestinationPorts = {"443"}, +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +TranslatedAddress = "1.2.3.5", +TranslatedPort = "8443", +}, new AzureFirewallNatRule +{ +Name = "DNAT-HTTP-traffic-With-FQDN", +Description = "D-NAT all inbound web traffic for inspection", +SourceAddresses = {"*"}, +DestinationAddresses = {"1.2.3.4"}, +DestinationPorts = {"80"}, +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +TranslatedPort = "880", +TranslatedFqdn = "internalhttpserver", +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/natRuleCollections/natrulecoll"), +Name = "natrulecoll", +}}, + NetworkRuleCollections = {new AzureFirewallNetworkRuleCollectionData +{ +Priority = 112, +ActionType = AzureFirewallRCActionType.Deny, +Rules = {new AzureFirewallNetworkRule +{ +Name = "L4-traffic", +Description = "Block traffic based on source IPs and ports", +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +SourceAddresses = {"192.168.1.1-192.168.1.12", "10.1.4.12-10.1.4.255"}, +DestinationAddresses = {"*"}, +DestinationPorts = {"443-444", "8443"}, +}, new AzureFirewallNetworkRule +{ +Name = "L4-traffic-with-FQDN", +Description = "Block traffic based on source IPs and ports to amazon", +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +SourceAddresses = {"10.2.4.12-10.2.4.255"}, +DestinationPorts = {"443-444", "8443"}, +DestinationFqdns = {"www.amazon.com"}, +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/networkRuleCollections/netrulecoll"), +Name = "netrulecoll", +}}, + IPConfigurations = {new AzureFirewallIPConfiguration +{ +SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallSubnet"), +PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), +Name = "azureFirewallIpConfiguration", +}}, + ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, + Sku = new AzureFirewallSku + { + Name = AzureFirewallSkuName.AzfwVnet, + Tier = AzureFirewallSkuTier.Standard, + }, + Location = new AzureLocation("West US 2"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); + AzureFirewallResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureFirewallWithIpGroups() + public async Task CreateOrUpdate_CreateAzureFirewallWithManagementSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithIpGroups.json - // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPutWithMgmtSubnet.json + // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -247,7 +550,106 @@ public async Task Get_GetAzureFirewallWithIpGroups() // invoke the operation string azureFirewallName = "azurefirewall"; - AzureFirewallResource result = await collection.GetAsync(azureFirewallName); + AzureFirewallData data = new AzureFirewallData + { + Zones = { }, + ApplicationRuleCollections = {new AzureFirewallApplicationRuleCollectionData +{ +Priority = 110, +ActionType = AzureFirewallRCActionType.Deny, +Rules = {new AzureFirewallApplicationRule +{ +Name = "rule1", +Description = "Deny inbound rule", +SourceAddresses = {"216.58.216.164", "10.0.0.0/24"}, +Protocols = {new AzureFirewallApplicationRuleProtocol +{ +ProtocolType = AzureFirewallApplicationRuleProtocolType.Https, +Port = 443, +}}, +TargetFqdns = {"www.test.com"}, +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/applicationRuleCollections/apprulecoll"), +Name = "apprulecoll", +}}, + NatRuleCollections = {new AzureFirewallNatRuleCollectionData +{ +Priority = 112, +ActionType = AzureFirewallNatRCActionType.Dnat, +Rules = {new AzureFirewallNatRule +{ +Name = "DNAT-HTTPS-traffic", +Description = "D-NAT all outbound web traffic for inspection", +SourceAddresses = {"*"}, +DestinationAddresses = {"1.2.3.4"}, +DestinationPorts = {"443"}, +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +TranslatedAddress = "1.2.3.5", +TranslatedPort = "8443", +}, new AzureFirewallNatRule +{ +Name = "DNAT-HTTP-traffic-With-FQDN", +Description = "D-NAT all inbound web traffic for inspection", +SourceAddresses = {"*"}, +DestinationAddresses = {"1.2.3.4"}, +DestinationPorts = {"80"}, +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +TranslatedPort = "880", +TranslatedFqdn = "internalhttpserver", +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/natRuleCollections/natrulecoll"), +Name = "natrulecoll", +}}, + NetworkRuleCollections = {new AzureFirewallNetworkRuleCollectionData +{ +Priority = 112, +ActionType = AzureFirewallRCActionType.Deny, +Rules = {new AzureFirewallNetworkRule +{ +Name = "L4-traffic", +Description = "Block traffic based on source IPs and ports", +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +SourceAddresses = {"192.168.1.1-192.168.1.12", "10.1.4.12-10.1.4.255"}, +DestinationAddresses = {"*"}, +DestinationPorts = {"443-444", "8443"}, +}, new AzureFirewallNetworkRule +{ +Name = "L4-traffic-with-FQDN", +Description = "Block traffic based on source IPs and ports to amazon", +Protocols = {AzureFirewallNetworkRuleProtocol.Tcp}, +SourceAddresses = {"10.2.4.12-10.2.4.255"}, +DestinationPorts = {"443-444", "8443"}, +DestinationFqdns = {"www.amazon.com"}, +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/networkRuleCollections/netrulecoll"), +Name = "netrulecoll", +}}, + IPConfigurations = {new AzureFirewallIPConfiguration +{ +SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallSubnet"), +PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), +Name = "azureFirewallIpConfiguration", +}}, + ManagementIPConfiguration = new AzureFirewallIPConfiguration + { + SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallManagementSubnet"), + PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/managementPipName"), + Name = "azureFirewallMgmtIpConfiguration", + }, + ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, + Sku = new AzureFirewallSku + { + Name = AzureFirewallSkuName.AzfwVnet, + Tier = AzureFirewallSkuTier.Standard, + }, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); + AzureFirewallResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -258,10 +660,10 @@ public async Task Get_GetAzureFirewallWithIpGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureFirewallWithIpGroups() + public async Task CreateOrUpdate_CreateAzureFirewallInVirtualHub() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithIpGroups.json - // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPutInHub.json + // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -280,16 +682,46 @@ public async Task Exists_GetAzureFirewallWithIpGroups() // invoke the operation string azureFirewallName = "azurefirewall"; - bool result = await collection.ExistsAsync(azureFirewallName); + AzureFirewallData data = new AzureFirewallData + { + Zones = { }, + ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, + VirtualHubId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1"), + FirewallPolicyId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/firewallPolicies/policy1"), + HubIPAddresses = new HubIPAddresses + { + PublicIPs = new HubPublicIPAddresses + { + Addresses = { }, + Count = 1, + }, + }, + Sku = new AzureFirewallSku + { + Name = AzureFirewallSkuName.AzfwHub, + Tier = AzureFirewallSkuTier.Standard, + }, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); + AzureFirewallResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureFirewallWithIpGroups() + public async Task Get_GetAzureFirewall() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithIpGroups.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGet.json // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -309,28 +741,20 @@ public async Task GetIfExists_GetAzureFirewallWithIpGroups() // invoke the operation string azureFirewallName = "azurefirewall"; - NullableResponse response = await collection.GetIfExistsAsync(azureFirewallName); - AzureFirewallResource result = response.HasValue ? response.Value : null; + AzureFirewallResource result = await collection.GetAsync(azureFirewallName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureFirewallWithZones() + public async Task Get_GetAzureFirewallWithAdditionalProperties() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithZones.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithAdditionalProperties.json // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -361,9 +785,9 @@ public async Task Get_GetAzureFirewallWithZones() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureFirewallWithZones() + public async Task Get_GetAzureFirewallWithIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithZones.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithIpGroups.json // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -383,14 +807,18 @@ public async Task Exists_GetAzureFirewallWithZones() // invoke the operation string azureFirewallName = "azurefirewall"; - bool result = await collection.ExistsAsync(azureFirewallName); + AzureFirewallResource result = await collection.GetAsync(azureFirewallName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureFirewallWithZones() + public async Task Get_GetAzureFirewallWithZones() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithZones.json // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. @@ -412,21 +840,13 @@ public async Task GetIfExists_GetAzureFirewallWithZones() // invoke the operation string azureFirewallName = "azurefirewall"; - NullableResponse response = await collection.GetIfExistsAsync(azureFirewallName); - AzureFirewallResource result = response.HasValue ? response.Value : null; + AzureFirewallResource result = await collection.GetAsync(azureFirewallName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -464,10 +884,10 @@ public async Task Get_GetAzureFirewallWithManagementSubnet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureFirewallWithManagementSubnet() + public async Task GetAll_ListAllAzureFirewallsForAGivenResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithMgmtSubnet.json - // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallListByResourceGroup.json + // this example is just showing the usage of "AzureFirewalls_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -484,18 +904,24 @@ public async Task Exists_GetAzureFirewallWithManagementSubnet() // get the collection of this AzureFirewallResource AzureFirewallCollection collection = resourceGroupResource.GetAzureFirewalls(); - // invoke the operation - string azureFirewallName = "azurefirewall"; - bool result = await collection.ExistsAsync(azureFirewallName); - - Console.WriteLine($"Succeeded: {result}"); + // invoke the operation and iterate over the result + await foreach (AzureFirewallResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureFirewallWithManagementSubnet() + public async Task Exists_GetAzureFirewall() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithMgmtSubnet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGet.json // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -515,29 +941,17 @@ public async Task GetIfExists_GetAzureFirewallWithManagementSubnet() // invoke the operation string azureFirewallName = "azurefirewall"; - NullableResponse response = await collection.GetIfExistsAsync(azureFirewallName); - AzureFirewallResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(azureFirewallName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAzureFirewall() + public async Task Exists_GetAzureFirewallWithAdditionalProperties() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPut.json - // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithAdditionalProperties.json + // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -556,194 +970,17 @@ public async Task CreateOrUpdate_CreateAzureFirewall() // invoke the operation string azureFirewallName = "azurefirewall"; - AzureFirewallData data = new AzureFirewallData() - { - Zones = -{ -}, - ApplicationRuleCollections = -{ -new AzureFirewallApplicationRuleCollectionData() -{ -Priority = 110, -ActionType = AzureFirewallRCActionType.Deny, -Rules = -{ -new AzureFirewallApplicationRule() -{ -Name = "rule1", -Description = "Deny inbound rule", -SourceAddresses = -{ -"216.58.216.164","10.0.0.0/24" -}, -Protocols = -{ -new AzureFirewallApplicationRuleProtocol() -{ -ProtocolType = AzureFirewallApplicationRuleProtocolType.Https, -Port = 443, -} -}, -TargetFqdns = -{ -"www.test.com" -}, -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/applicationRuleCollections/apprulecoll"), -Name = "apprulecoll", -} -}, - NatRuleCollections = -{ -new AzureFirewallNatRuleCollectionData() -{ -Priority = 112, -ActionType = AzureFirewallNatRCActionType.Dnat, -Rules = -{ -new AzureFirewallNatRule() -{ -Name = "DNAT-HTTPS-traffic", -Description = "D-NAT all outbound web traffic for inspection", -SourceAddresses = -{ -"*" -}, -DestinationAddresses = -{ -"1.2.3.4" -}, -DestinationPorts = -{ -"443" -}, -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -TranslatedAddress = "1.2.3.5", -TranslatedPort = "8443", -},new AzureFirewallNatRule() -{ -Name = "DNAT-HTTP-traffic-With-FQDN", -Description = "D-NAT all inbound web traffic for inspection", -SourceAddresses = -{ -"*" -}, -DestinationAddresses = -{ -"1.2.3.4" -}, -DestinationPorts = -{ -"80" -}, -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -TranslatedPort = "880", -TranslatedFqdn = "internalhttpserver", -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/natRuleCollections/natrulecoll"), -Name = "natrulecoll", -} -}, - NetworkRuleCollections = -{ -new AzureFirewallNetworkRuleCollectionData() -{ -Priority = 112, -ActionType = AzureFirewallRCActionType.Deny, -Rules = -{ -new AzureFirewallNetworkRule() -{ -Name = "L4-traffic", -Description = "Block traffic based on source IPs and ports", -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -SourceAddresses = -{ -"192.168.1.1-192.168.1.12","10.1.4.12-10.1.4.255" -}, -DestinationAddresses = -{ -"*" -}, -DestinationPorts = -{ -"443-444","8443" -}, -},new AzureFirewallNetworkRule() -{ -Name = "L4-traffic-with-FQDN", -Description = "Block traffic based on source IPs and ports to amazon", -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -SourceAddresses = -{ -"10.2.4.12-10.2.4.255" -}, -DestinationPorts = -{ -"443-444","8443" -}, -DestinationFqdns = -{ -"www.amazon.com" -}, -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/networkRuleCollections/netrulecoll"), -Name = "netrulecoll", -} -}, - IPConfigurations = -{ -new AzureFirewallIPConfiguration() -{ -SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallSubnet"), -PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), -Name = "azureFirewallIpConfiguration", -} -}, - ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, - Sku = new AzureFirewallSku() - { - Name = AzureFirewallSkuName.AzfwVnet, - Tier = AzureFirewallSkuTier.Standard, - }, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); - AzureFirewallResource result = lro.Value; + bool result = await collection.ExistsAsync(azureFirewallName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAzureFirewallWithAdditionalProperties() + public async Task Exists_GetAzureFirewallWithIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPutWithAdditionalProperties.json - // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithIpGroups.json + // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -762,199 +999,17 @@ public async Task CreateOrUpdate_CreateAzureFirewallWithAdditionalProperties() // invoke the operation string azureFirewallName = "azurefirewall"; - AzureFirewallData data = new AzureFirewallData() - { - Zones = -{ -}, - ApplicationRuleCollections = -{ -new AzureFirewallApplicationRuleCollectionData() -{ -Priority = 110, -ActionType = AzureFirewallRCActionType.Deny, -Rules = -{ -new AzureFirewallApplicationRule() -{ -Name = "rule1", -Description = "Deny inbound rule", -SourceAddresses = -{ -"216.58.216.164","10.0.0.0/24" -}, -Protocols = -{ -new AzureFirewallApplicationRuleProtocol() -{ -ProtocolType = AzureFirewallApplicationRuleProtocolType.Https, -Port = 443, -} -}, -TargetFqdns = -{ -"www.test.com" -}, -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/applicationRuleCollections/apprulecoll"), -Name = "apprulecoll", -} -}, - NatRuleCollections = -{ -new AzureFirewallNatRuleCollectionData() -{ -Priority = 112, -ActionType = AzureFirewallNatRCActionType.Dnat, -Rules = -{ -new AzureFirewallNatRule() -{ -Name = "DNAT-HTTPS-traffic", -Description = "D-NAT all outbound web traffic for inspection", -SourceAddresses = -{ -"*" -}, -DestinationAddresses = -{ -"1.2.3.4" -}, -DestinationPorts = -{ -"443" -}, -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -TranslatedAddress = "1.2.3.5", -TranslatedPort = "8443", -},new AzureFirewallNatRule() -{ -Name = "DNAT-HTTP-traffic-With-FQDN", -Description = "D-NAT all inbound web traffic for inspection", -SourceAddresses = -{ -"*" -}, -DestinationAddresses = -{ -"1.2.3.4" -}, -DestinationPorts = -{ -"80" -}, -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -TranslatedPort = "880", -TranslatedFqdn = "internalhttpserver", -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/natRuleCollections/natrulecoll"), -Name = "natrulecoll", -} -}, - NetworkRuleCollections = -{ -new AzureFirewallNetworkRuleCollectionData() -{ -Priority = 112, -ActionType = AzureFirewallRCActionType.Deny, -Rules = -{ -new AzureFirewallNetworkRule() -{ -Name = "L4-traffic", -Description = "Block traffic based on source IPs and ports", -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -SourceAddresses = -{ -"192.168.1.1-192.168.1.12","10.1.4.12-10.1.4.255" -}, -DestinationAddresses = -{ -"*" -}, -DestinationPorts = -{ -"443-444","8443" -}, -},new AzureFirewallNetworkRule() -{ -Name = "L4-traffic-with-FQDN", -Description = "Block traffic based on source IPs and ports to amazon", -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -SourceAddresses = -{ -"10.2.4.12-10.2.4.255" -}, -DestinationPorts = -{ -"443-444","8443" -}, -DestinationFqdns = -{ -"www.amazon.com" -}, -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/networkRuleCollections/netrulecoll"), -Name = "netrulecoll", -} -}, - IPConfigurations = -{ -new AzureFirewallIPConfiguration() -{ -SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallSubnet"), -PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), -Name = "azureFirewallIpConfiguration", -} -}, - ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, - Sku = new AzureFirewallSku() - { - Name = AzureFirewallSkuName.AzfwVnet, - Tier = AzureFirewallSkuTier.Standard, - }, - AdditionalProperties = -{ -["key1"] = "value1", -["key2"] = "value2", -}, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); - AzureFirewallResource result = lro.Value; + bool result = await collection.ExistsAsync(azureFirewallName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAzureFirewallWithIpGroups() + public async Task Exists_GetAzureFirewallWithZones() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPutWithIpGroups.json - // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithZones.json + // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -973,194 +1028,17 @@ public async Task CreateOrUpdate_CreateAzureFirewallWithIpGroups() // invoke the operation string azureFirewallName = "azurefirewall"; - AzureFirewallData data = new AzureFirewallData() - { - Zones = -{ -}, - ApplicationRuleCollections = -{ -new AzureFirewallApplicationRuleCollectionData() -{ -Priority = 110, -ActionType = AzureFirewallRCActionType.Deny, -Rules = -{ -new AzureFirewallApplicationRule() -{ -Name = "rule1", -Description = "Deny inbound rule", -SourceAddresses = -{ -"216.58.216.164","10.0.0.0/24" -}, -Protocols = -{ -new AzureFirewallApplicationRuleProtocol() -{ -ProtocolType = AzureFirewallApplicationRuleProtocolType.Https, -Port = 443, -} -}, -TargetFqdns = -{ -"www.test.com" -}, -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/applicationRuleCollections/apprulecoll"), -Name = "apprulecoll", -} -}, - NatRuleCollections = -{ -new AzureFirewallNatRuleCollectionData() -{ -Priority = 112, -ActionType = AzureFirewallNatRCActionType.Dnat, -Rules = -{ -new AzureFirewallNatRule() -{ -Name = "DNAT-HTTPS-traffic", -Description = "D-NAT all outbound web traffic for inspection", -SourceAddresses = -{ -"*" -}, -DestinationAddresses = -{ -"1.2.3.4" -}, -DestinationPorts = -{ -"443" -}, -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -TranslatedAddress = "1.2.3.5", -TranslatedPort = "8443", -},new AzureFirewallNatRule() -{ -Name = "DNAT-HTTP-traffic-With-FQDN", -Description = "D-NAT all inbound web traffic for inspection", -SourceAddresses = -{ -"*" -}, -DestinationAddresses = -{ -"1.2.3.4" -}, -DestinationPorts = -{ -"80" -}, -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -TranslatedPort = "880", -TranslatedFqdn = "internalhttpserver", -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/natRuleCollections/natrulecoll"), -Name = "natrulecoll", -} -}, - NetworkRuleCollections = -{ -new AzureFirewallNetworkRuleCollectionData() -{ -Priority = 112, -ActionType = AzureFirewallRCActionType.Deny, -Rules = -{ -new AzureFirewallNetworkRule() -{ -Name = "L4-traffic", -Description = "Block traffic based on source IPs and ports", -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -SourceAddresses = -{ -"192.168.1.1-192.168.1.12","10.1.4.12-10.1.4.255" -}, -DestinationAddresses = -{ -"*" -}, -DestinationPorts = -{ -"443-444","8443" -}, -},new AzureFirewallNetworkRule() -{ -Name = "L4-traffic-with-FQDN", -Description = "Block traffic based on source IPs and ports to amazon", -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -SourceAddresses = -{ -"10.2.4.12-10.2.4.255" -}, -DestinationPorts = -{ -"443-444","8443" -}, -DestinationFqdns = -{ -"www.amazon.com" -}, -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/networkRuleCollections/netrulecoll"), -Name = "netrulecoll", -} -}, - IPConfigurations = -{ -new AzureFirewallIPConfiguration() -{ -SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallSubnet"), -PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), -Name = "azureFirewallIpConfiguration", -} -}, - ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, - Sku = new AzureFirewallSku() - { - Name = AzureFirewallSkuName.AzfwVnet, - Tier = AzureFirewallSkuTier.Standard, - }, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); - AzureFirewallResource result = lro.Value; + bool result = await collection.ExistsAsync(azureFirewallName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAzureFirewallWithZones() + public async Task Exists_GetAzureFirewallWithManagementSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPutWithZones.json - // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithMgmtSubnet.json + // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1179,195 +1057,99 @@ public async Task CreateOrUpdate_CreateAzureFirewallWithZones() // invoke the operation string azureFirewallName = "azurefirewall"; - AzureFirewallData data = new AzureFirewallData() + bool result = await collection.ExistsAsync(azureFirewallName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetAzureFirewall() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGet.json + // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AzureFirewallResource + AzureFirewallCollection collection = resourceGroupResource.GetAzureFirewalls(); + + // invoke the operation + string azureFirewallName = "azurefirewall"; + NullableResponse response = await collection.GetIfExistsAsync(azureFirewallName); + AzureFirewallResource result = response.HasValue ? response.Value : null; + + if (result == null) { - Zones = -{ -"1","2","3" -}, - ApplicationRuleCollections = -{ -new AzureFirewallApplicationRuleCollectionData() -{ -Priority = 110, -ActionType = AzureFirewallRCActionType.Deny, -Rules = -{ -new AzureFirewallApplicationRule() -{ -Name = "rule1", -Description = "Deny inbound rule", -SourceAddresses = -{ -"216.58.216.164","10.0.0.0/24" -}, -Protocols = -{ -new AzureFirewallApplicationRuleProtocol() -{ -ProtocolType = AzureFirewallApplicationRuleProtocolType.Https, -Port = 443, -} -}, -TargetFqdns = -{ -"www.test.com" -}, -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/applicationRuleCollections/apprulecoll"), -Name = "apprulecoll", -} -}, - NatRuleCollections = -{ -new AzureFirewallNatRuleCollectionData() -{ -Priority = 112, -ActionType = AzureFirewallNatRCActionType.Dnat, -Rules = -{ -new AzureFirewallNatRule() -{ -Name = "DNAT-HTTPS-traffic", -Description = "D-NAT all outbound web traffic for inspection", -SourceAddresses = -{ -"*" -}, -DestinationAddresses = -{ -"1.2.3.4" -}, -DestinationPorts = -{ -"443" -}, -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -TranslatedAddress = "1.2.3.5", -TranslatedPort = "8443", -},new AzureFirewallNatRule() -{ -Name = "DNAT-HTTP-traffic-With-FQDN", -Description = "D-NAT all inbound web traffic for inspection", -SourceAddresses = -{ -"*" -}, -DestinationAddresses = -{ -"1.2.3.4" -}, -DestinationPorts = -{ -"80" -}, -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -TranslatedPort = "880", -TranslatedFqdn = "internalhttpserver", -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/natRuleCollections/natrulecoll"), -Name = "natrulecoll", -} -}, - NetworkRuleCollections = -{ -new AzureFirewallNetworkRuleCollectionData() -{ -Priority = 112, -ActionType = AzureFirewallRCActionType.Deny, -Rules = -{ -new AzureFirewallNetworkRule() -{ -Name = "L4-traffic", -Description = "Block traffic based on source IPs and ports", -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -SourceAddresses = -{ -"192.168.1.1-192.168.1.12","10.1.4.12-10.1.4.255" -}, -DestinationAddresses = -{ -"*" -}, -DestinationPorts = -{ -"443-444","8443" -}, -},new AzureFirewallNetworkRule() -{ -Name = "L4-traffic-with-FQDN", -Description = "Block traffic based on source IPs and ports to amazon", -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -SourceAddresses = -{ -"10.2.4.12-10.2.4.255" -}, -DestinationPorts = -{ -"443-444","8443" -}, -DestinationFqdns = -{ -"www.amazon.com" -}, -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/networkRuleCollections/netrulecoll"), -Name = "netrulecoll", -} -}, - IPConfigurations = -{ -new AzureFirewallIPConfiguration() -{ -SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallSubnet"), -PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), -Name = "azureFirewallIpConfiguration", -} -}, - ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, - Sku = new AzureFirewallSku() - { - Name = AzureFirewallSkuName.AzfwVnet, - Tier = AzureFirewallSkuTier.Standard, - }, - Location = new AzureLocation("West US 2"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); - AzureFirewallResource result = lro.Value; + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetAzureFirewallWithAdditionalProperties() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithAdditionalProperties.json + // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this AzureFirewallResource + AzureFirewallCollection collection = resourceGroupResource.GetAzureFirewalls(); + + // invoke the operation + string azureFirewallName = "azurefirewall"; + NullableResponse response = await collection.GetIfExistsAsync(azureFirewallName); + AzureFirewallResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAzureFirewallWithManagementSubnet() + public async Task GetIfExists_GetAzureFirewallWithIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPutWithMgmtSubnet.json - // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithIpGroups.json + // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1386,200 +1168,29 @@ public async Task CreateOrUpdate_CreateAzureFirewallWithManagementSubnet() // invoke the operation string azureFirewallName = "azurefirewall"; - AzureFirewallData data = new AzureFirewallData() - { - Zones = -{ -}, - ApplicationRuleCollections = -{ -new AzureFirewallApplicationRuleCollectionData() -{ -Priority = 110, -ActionType = AzureFirewallRCActionType.Deny, -Rules = -{ -new AzureFirewallApplicationRule() -{ -Name = "rule1", -Description = "Deny inbound rule", -SourceAddresses = -{ -"216.58.216.164","10.0.0.0/24" -}, -Protocols = -{ -new AzureFirewallApplicationRuleProtocol() -{ -ProtocolType = AzureFirewallApplicationRuleProtocolType.Https, -Port = 443, -} -}, -TargetFqdns = -{ -"www.test.com" -}, -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/applicationRuleCollections/apprulecoll"), -Name = "apprulecoll", -} -}, - NatRuleCollections = -{ -new AzureFirewallNatRuleCollectionData() -{ -Priority = 112, -ActionType = AzureFirewallNatRCActionType.Dnat, -Rules = -{ -new AzureFirewallNatRule() -{ -Name = "DNAT-HTTPS-traffic", -Description = "D-NAT all outbound web traffic for inspection", -SourceAddresses = -{ -"*" -}, -DestinationAddresses = -{ -"1.2.3.4" -}, -DestinationPorts = -{ -"443" -}, -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -TranslatedAddress = "1.2.3.5", -TranslatedPort = "8443", -},new AzureFirewallNatRule() -{ -Name = "DNAT-HTTP-traffic-With-FQDN", -Description = "D-NAT all inbound web traffic for inspection", -SourceAddresses = -{ -"*" -}, -DestinationAddresses = -{ -"1.2.3.4" -}, -DestinationPorts = -{ -"80" -}, -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -TranslatedPort = "880", -TranslatedFqdn = "internalhttpserver", -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/natRuleCollections/natrulecoll"), -Name = "natrulecoll", -} -}, - NetworkRuleCollections = -{ -new AzureFirewallNetworkRuleCollectionData() -{ -Priority = 112, -ActionType = AzureFirewallRCActionType.Deny, -Rules = -{ -new AzureFirewallNetworkRule() -{ -Name = "L4-traffic", -Description = "Block traffic based on source IPs and ports", -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -SourceAddresses = -{ -"192.168.1.1-192.168.1.12","10.1.4.12-10.1.4.255" -}, -DestinationAddresses = -{ -"*" -}, -DestinationPorts = -{ -"443-444","8443" -}, -},new AzureFirewallNetworkRule() -{ -Name = "L4-traffic-with-FQDN", -Description = "Block traffic based on source IPs and ports to amazon", -Protocols = -{ -AzureFirewallNetworkRuleProtocol.Tcp -}, -SourceAddresses = -{ -"10.2.4.12-10.2.4.255" -}, -DestinationPorts = -{ -"443-444","8443" -}, -DestinationFqdns = -{ -"www.amazon.com" -}, -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azurefirewall/networkRuleCollections/netrulecoll"), -Name = "netrulecoll", -} -}, - IPConfigurations = -{ -new AzureFirewallIPConfiguration() -{ -SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallSubnet"), -PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), -Name = "azureFirewallIpConfiguration", -} -}, - ManagementIPConfiguration = new AzureFirewallIPConfiguration() - { - SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/AzureFirewallManagementSubnet"), - PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/managementPipName"), - Name = "azureFirewallMgmtIpConfiguration", - }, - ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, - Sku = new AzureFirewallSku() - { - Name = AzureFirewallSkuName.AzfwVnet, - Tier = AzureFirewallSkuTier.Standard, - }, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); - AzureFirewallResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(azureFirewallName); + AzureFirewallResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAzureFirewallInVirtualHub() + public async Task GetIfExists_GetAzureFirewallWithZones() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallPutInHub.json - // this example is just showing the usage of "AzureFirewalls_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithZones.json + // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1598,51 +1209,29 @@ public async Task CreateOrUpdate_CreateAzureFirewallInVirtualHub() // invoke the operation string azureFirewallName = "azurefirewall"; - AzureFirewallData data = new AzureFirewallData() - { - Zones = -{ -}, - ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, - VirtualHubId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1"), - FirewallPolicyId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/firewallPolicies/policy1"), - HubIPAddresses = new HubIPAddresses() - { - PublicIPs = new HubPublicIPAddresses() - { - Addresses = -{ -}, - Count = 1, - }, - }, - Sku = new AzureFirewallSku() - { - Name = AzureFirewallSkuName.AzfwHub, - Tier = AzureFirewallSkuTier.Standard, - }, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, azureFirewallName, data); - AzureFirewallResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(azureFirewallName); + AzureFirewallResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllAzureFirewallsForAGivenResourceGroup() + public async Task GetIfExists_GetAzureFirewallWithManagementSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallListByResourceGroup.json - // this example is just showing the usage of "AzureFirewalls_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithMgmtSubnet.json + // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -1659,17 +1248,23 @@ public async Task GetAll_ListAllAzureFirewallsForAGivenResourceGroup() // get the collection of this AzureFirewallResource AzureFirewallCollection collection = resourceGroupResource.GetAzureFirewalls(); - // invoke the operation and iterate over the result - await foreach (AzureFirewallResource item in collection.GetAllAsync()) + // invoke the operation + string azureFirewallName = "azurefirewall"; + NullableResponse response = await collection.GetIfExistsAsync(azureFirewallName); + AzureFirewallResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = item.Data; + AzureFirewallData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureFirewallResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureFirewallResource.cs index 9873ea3bb15d5..9f1f7e0809723 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureFirewallResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureFirewallResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_AzureFirewallResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteAzureFirewall() + public async Task Get_GetAzureFirewall() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallDelete.json - // this example is just showing the usage of "AzureFirewalls_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGet.json + // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +37,20 @@ public async Task Delete_DeleteAzureFirewall() AzureFirewallResource azureFirewall = client.GetAzureFirewallResource(azureFirewallResourceId); // invoke the operation - await azureFirewall.DeleteAsync(WaitUntil.Completed); + AzureFirewallResource result = await azureFirewall.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureFirewall() + public async Task Get_GetAzureFirewallWithAdditionalProperties() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithAdditionalProperties.json // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -75,9 +78,9 @@ public async Task Get_GetAzureFirewall() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureFirewallWithAdditionalProperties() + public async Task Get_GetAzureFirewallWithIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithAdditionalProperties.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithIpGroups.json // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -105,9 +108,9 @@ public async Task Get_GetAzureFirewallWithAdditionalProperties() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureFirewallWithIpGroups() + public async Task Get_GetAzureFirewallWithZones() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithIpGroups.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithZones.json // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -135,9 +138,9 @@ public async Task Get_GetAzureFirewallWithIpGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureFirewallWithZones() + public async Task Get_GetAzureFirewallWithManagementSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithZones.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithMgmtSubnet.json // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -165,10 +168,10 @@ public async Task Get_GetAzureFirewallWithZones() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetAzureFirewallWithManagementSubnet() + public async Task Delete_DeleteAzureFirewall() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallGetWithMgmtSubnet.json - // this example is just showing the usage of "AzureFirewalls_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallDelete.json + // this example is just showing the usage of "AzureFirewalls_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,13 +187,9 @@ public async Task Get_GetAzureFirewallWithManagementSubnet() AzureFirewallResource azureFirewall = client.GetAzureFirewallResource(azureFirewallResourceId); // invoke the operation - AzureFirewallResource result = await azureFirewall.GetAsync(); + await azureFirewall.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -214,12 +213,12 @@ public async Task Update_UpdateAzureFirewallTags() AzureFirewallResource azureFirewall = client.GetAzureFirewallResource(azureFirewallResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await azureFirewall.UpdateAsync(WaitUntil.Completed, networkTagsObject); @@ -232,37 +231,6 @@ public async Task Update_UpdateAzureFirewallTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAzureFirewalls_ListAllAzureFirewallsForAGivenSubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallListBySubscription.json - // this example is just showing the usage of "AzureFirewalls_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (AzureFirewallResource item in subscriptionResource.GetAzureFirewallsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureFirewallData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetLearnedPrefixes_AzureFirewallListLearnedPrefixes() @@ -311,55 +279,31 @@ public async Task PacketCapture_AzureFirewallPacketCapture() AzureFirewallResource azureFirewall = client.GetAzureFirewallResource(azureFirewallResourceId); // invoke the operation - FirewallPacketCaptureRequestContent content = new FirewallPacketCaptureRequestContent() + FirewallPacketCaptureRequestContent content = new FirewallPacketCaptureRequestContent { DurationInSeconds = 300, NumberOfPacketsToCapture = 5000, SasUri = new Uri("someSASURL"), FileName = "azureFirewallPacketCapture", Protocol = AzureFirewallNetworkRuleProtocol.Any, - Flags = -{ -new AzureFirewallPacketCaptureFlags() + Flags = {new AzureFirewallPacketCaptureFlags { FlagsType = AzureFirewallPacketCaptureFlagsType.Syn, -},new AzureFirewallPacketCaptureFlags() +}, new AzureFirewallPacketCaptureFlags { FlagsType = AzureFirewallPacketCaptureFlagsType.Fin, -} -}, - Filters = -{ -new AzureFirewallPacketCaptureRule() +}}, + Filters = {new AzureFirewallPacketCaptureRule { -Sources = +Sources = {"20.1.1.0"}, +Destinations = {"20.1.2.0"}, +DestinationPorts = {"4500"}, +}, new AzureFirewallPacketCaptureRule { -"20.1.1.0" -}, -Destinations = -{ -"20.1.2.0" -}, -DestinationPorts = -{ -"4500" -}, -},new AzureFirewallPacketCaptureRule() -{ -Sources = -{ -"10.1.1.0","10.1.1.1" -}, -Destinations = -{ -"10.1.2.0" -}, -DestinationPorts = -{ -"123","80" -}, -} -}, +Sources = {"10.1.1.0", "10.1.1.1"}, +Destinations = {"10.1.2.0"}, +DestinationPorts = {"123", "80"}, +}}, }; await azureFirewall.PacketCaptureAsync(WaitUntil.Completed, content); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureWebCategoryCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureWebCategoryCollection.cs index 8954cd668ddf4..70ab3628216bf 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureWebCategoryCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_AzureWebCategoryCollection.cs @@ -50,10 +50,10 @@ public async Task Get_GetAzureWebCategoryByName() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetAzureWebCategoryByName() + public async Task GetAll_ListAllAzureWebCategoriesForAGivenSubscription() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureWebCategoryGet.json - // this example is just showing the usage of "WebCategories_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureWebCategoriesListBySubscription.json + // this example is just showing the usage of "WebCategories_ListBySubscription" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +69,22 @@ public async Task Exists_GetAzureWebCategoryByName() // get the collection of this AzureWebCategoryResource AzureWebCategoryCollection collection = subscriptionResource.GetAzureWebCategories(); - // invoke the operation - string name = "Arts"; - bool result = await collection.ExistsAsync(name); + // invoke the operation and iterate over the result + await foreach (AzureWebCategoryResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureWebCategoryData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetAzureWebCategoryByName() + public async Task Exists_GetAzureWebCategoryByName() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureWebCategoryGet.json // this example is just showing the usage of "WebCategories_Get" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +105,17 @@ public async Task GetIfExists_GetAzureWebCategoryByName() // invoke the operation string name = "Arts"; - NullableResponse response = await collection.GetIfExistsAsync(name); - AzureWebCategoryResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(name); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - AzureWebCategoryData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllAzureWebCategoriesForAGivenSubscription() + public async Task GetIfExists_GetAzureWebCategoryByName() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureWebCategoriesListBySubscription.json - // this example is just showing the usage of "WebCategories_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureWebCategoryGet.json + // this example is just showing the usage of "WebCategories_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,17 +131,23 @@ public async Task GetAll_ListAllAzureWebCategoriesForAGivenSubscription() // get the collection of this AzureWebCategoryResource AzureWebCategoryCollection collection = subscriptionResource.GetAzureWebCategories(); - // invoke the operation and iterate over the result - await foreach (AzureWebCategoryResource item in collection.GetAllAsync()) + // invoke the operation + string name = "Arts"; + NullableResponse response = await collection.GetIfExistsAsync(name); + AzureWebCategoryResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - AzureWebCategoryData resourceData = item.Data; + AzureWebCategoryData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BackendAddressPoolCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BackendAddressPoolCollection.cs index 1da353ea479f8..52056e2f02fe6 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BackendAddressPoolCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BackendAddressPoolCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BackendAddressPoolCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LoadBalancerWithBackendAddressPoolContainingBackendAddresses() + public async Task CreateOrUpdate_UpdateLoadBalancerBackendPoolWithBackendAddressesContainingVirtualNetworkAndIPAddress() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolListWithBackendAddressesPoolType.json - // this example is just showing the usage of "LoadBalancerBackendAddressPools_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolWithBackendAddressesPut.json + // this example is just showing the usage of "LoadBalancerBackendAddressPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,38 @@ public async Task GetAll_LoadBalancerWithBackendAddressPoolContainingBackendAddr // get the collection of this BackendAddressPoolResource BackendAddressPoolCollection collection = loadBalancer.GetBackendAddressPools(); - // invoke the operation and iterate over the result - await foreach (BackendAddressPoolResource item in collection.GetAllAsync()) + // invoke the operation + string backendAddressPoolName = "backend"; + BackendAddressPoolData data = new BackendAddressPoolData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackendAddressPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + LoadBalancerBackendAddresses = {new LoadBalancerBackendAddress +{ +Name = "address1", +VirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb"), +IPAddress = "10.0.0.4", +}, new LoadBalancerBackendAddress +{ +Name = "address2", +VirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb"), +IPAddress = "10.0.0.5", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backendAddressPoolName, data); + BackendAddressPoolResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackendAddressPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LoadBalancerBackendAddressPoolList() + public async Task Get_LoadBalancerWithBackendAddressPoolWithBackendAddresses() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerBackendAddressPoolList.json - // this example is just showing the usage of "LoadBalancerBackendAddressPools_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolWithBackendAddressesGet.json + // this example is just showing the usage of "LoadBalancerBackendAddressPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,24 +88,22 @@ public async Task GetAll_LoadBalancerBackendAddressPoolList() // get the collection of this BackendAddressPoolResource BackendAddressPoolCollection collection = loadBalancer.GetBackendAddressPools(); - // invoke the operation and iterate over the result - await foreach (BackendAddressPoolResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackendAddressPoolData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string backendAddressPoolName = "backend"; + BackendAddressPoolResource result = await collection.GetAsync(backendAddressPoolName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackendAddressPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LoadBalancerWithBackendAddressPoolWithBackendAddresses() + public async Task Get_LoadBalancerBackendAddressPoolGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolWithBackendAddressesGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerBackendAddressPoolGet.json // this example is just showing the usage of "LoadBalancerBackendAddressPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -124,10 +135,10 @@ public async Task Get_LoadBalancerWithBackendAddressPoolWithBackendAddresses() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_LoadBalancerWithBackendAddressPoolWithBackendAddresses() + public async Task GetAll_LoadBalancerWithBackendAddressPoolContainingBackendAddresses() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolWithBackendAddressesGet.json - // this example is just showing the usage of "LoadBalancerBackendAddressPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolListWithBackendAddressesPoolType.json + // this example is just showing the usage of "LoadBalancerBackendAddressPools_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,19 +156,25 @@ public async Task Exists_LoadBalancerWithBackendAddressPoolWithBackendAddresses( // get the collection of this BackendAddressPoolResource BackendAddressPoolCollection collection = loadBalancer.GetBackendAddressPools(); - // invoke the operation - string backendAddressPoolName = "backend"; - bool result = await collection.ExistsAsync(backendAddressPoolName); + // invoke the operation and iterate over the result + await foreach (BackendAddressPoolResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackendAddressPoolData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LoadBalancerWithBackendAddressPoolWithBackendAddresses() + public async Task GetAll_LoadBalancerBackendAddressPoolList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolWithBackendAddressesGet.json - // this example is just showing the usage of "LoadBalancerBackendAddressPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerBackendAddressPoolList.json + // this example is just showing the usage of "LoadBalancerBackendAddressPools_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -175,30 +192,24 @@ public async Task GetIfExists_LoadBalancerWithBackendAddressPoolWithBackendAddre // get the collection of this BackendAddressPoolResource BackendAddressPoolCollection collection = loadBalancer.GetBackendAddressPools(); - // invoke the operation - string backendAddressPoolName = "backend"; - NullableResponse response = await collection.GetIfExistsAsync(backendAddressPoolName); - BackendAddressPoolResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (BackendAddressPoolResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BackendAddressPoolData resourceData = result.Data; + BackendAddressPoolData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LoadBalancerBackendAddressPoolGet() + public async Task Exists_LoadBalancerWithBackendAddressPoolWithBackendAddresses() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerBackendAddressPoolGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolWithBackendAddressesGet.json // this example is just showing the usage of "LoadBalancerBackendAddressPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -219,13 +230,9 @@ public async Task Get_LoadBalancerBackendAddressPoolGet() // invoke the operation string backendAddressPoolName = "backend"; - BackendAddressPoolResource result = await collection.GetAsync(backendAddressPoolName); + bool result = await collection.ExistsAsync(backendAddressPoolName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackendAddressPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -260,9 +267,9 @@ public async Task Exists_LoadBalancerBackendAddressPoolGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_LoadBalancerBackendAddressPoolGet() + public async Task GetIfExists_LoadBalancerWithBackendAddressPoolWithBackendAddresses() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerBackendAddressPoolGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolWithBackendAddressesGet.json // this example is just showing the usage of "LoadBalancerBackendAddressPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -302,10 +309,10 @@ public async Task GetIfExists_LoadBalancerBackendAddressPoolGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateLoadBalancerBackendPoolWithBackendAddressesContainingVirtualNetworkAndIPAddress() + public async Task GetIfExists_LoadBalancerBackendAddressPoolGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolWithBackendAddressesPut.json - // this example is just showing the usage of "LoadBalancerBackendAddressPools_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerBackendAddressPoolGet.json + // this example is just showing the usage of "LoadBalancerBackendAddressPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -325,31 +332,21 @@ public async Task CreateOrUpdate_UpdateLoadBalancerBackendPoolWithBackendAddress // invoke the operation string backendAddressPoolName = "backend"; - BackendAddressPoolData data = new BackendAddressPoolData() - { - LoadBalancerBackendAddresses = -{ -new LoadBalancerBackendAddress() -{ -Name = "address1", -VirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb"), -IPAddress = "10.0.0.4", -},new LoadBalancerBackendAddress() -{ -Name = "address2", -VirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb"), -IPAddress = "10.0.0.5", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, backendAddressPoolName, data); - BackendAddressPoolResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(backendAddressPoolName); + BackendAddressPoolResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackendAddressPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackendAddressPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BackendAddressPoolResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BackendAddressPoolResource.cs index b6805a46ea320..4aaa6adf098c4 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BackendAddressPoolResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BackendAddressPoolResource.cs @@ -18,10 +18,10 @@ public partial class Sample_BackendAddressPoolResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetInboundNatRulePortMappingsLoadBalancer_QueryInboundNATRulePortMapping() + public async Task Get_LoadBalancerWithBackendAddressPoolWithBackendAddresses() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/QueryInboundNatRulePortMapping.json - // this example is just showing the usage of "LoadBalancers_ListInboundNatRulePortMappings" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolWithBackendAddressesGet.json + // this example is just showing the usage of "LoadBalancerBackendAddressPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,28 +31,27 @@ public async Task GetInboundNatRulePortMappingsLoadBalancer_QueryInboundNATRuleP // this example assumes you already have this BackendAddressPoolResource created on azure // for more information of creating BackendAddressPoolResource, please refer to the document of BackendAddressPoolResource string subscriptionId = "subid"; - string groupName = "rg1"; - string loadBalancerName = "lb1"; - string backendPoolName = "bp1"; - ResourceIdentifier backendAddressPoolResourceId = BackendAddressPoolResource.CreateResourceIdentifier(subscriptionId, groupName, loadBalancerName, backendPoolName); + string resourceGroupName = "testrg"; + string loadBalancerName = "lb"; + string backendAddressPoolName = "backend"; + ResourceIdentifier backendAddressPoolResourceId = BackendAddressPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, loadBalancerName, backendAddressPoolName); BackendAddressPoolResource backendAddressPool = client.GetBackendAddressPoolResource(backendAddressPoolResourceId); // invoke the operation - QueryInboundNatRulePortMappingContent content = new QueryInboundNatRulePortMappingContent() - { - IPAddress = "10.0.0.4", - }; - ArmOperation lro = await backendAddressPool.GetInboundNatRulePortMappingsLoadBalancerAsync(WaitUntil.Completed, content); - BackendAddressInboundNatRulePortMappings result = lro.Value; + BackendAddressPoolResource result = await backendAddressPool.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BackendAddressPoolData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LoadBalancerWithBackendAddressPoolWithBackendAddresses() + public async Task Get_LoadBalancerBackendAddressPoolGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LBBackendAddressPoolWithBackendAddressesGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerBackendAddressPoolGet.json // this example is just showing the usage of "LoadBalancerBackendAddressPools_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -81,10 +80,10 @@ public async Task Get_LoadBalancerWithBackendAddressPoolWithBackendAddresses() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LoadBalancerBackendAddressPoolGet() + public async Task Delete_BackendAddressPoolDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerBackendAddressPoolGet.json - // this example is just showing the usage of "LoadBalancerBackendAddressPools_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerBackendAddressPoolDelete.json + // this example is just showing the usage of "LoadBalancerBackendAddressPools_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,13 +100,9 @@ public async Task Get_LoadBalancerBackendAddressPoolGet() BackendAddressPoolResource backendAddressPool = client.GetBackendAddressPoolResource(backendAddressPoolResourceId); // invoke the operation - BackendAddressPoolResource result = await backendAddressPool.GetAsync(); + await backendAddressPool.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BackendAddressPoolData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -132,22 +127,19 @@ public async Task Update_UpdateLoadBalancerBackendPoolWithBackendAddressesContai BackendAddressPoolResource backendAddressPool = client.GetBackendAddressPoolResource(backendAddressPoolResourceId); // invoke the operation - BackendAddressPoolData data = new BackendAddressPoolData() + BackendAddressPoolData data = new BackendAddressPoolData { - LoadBalancerBackendAddresses = -{ -new LoadBalancerBackendAddress() + LoadBalancerBackendAddresses = {new LoadBalancerBackendAddress { Name = "address1", VirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb"), IPAddress = "10.0.0.4", -},new LoadBalancerBackendAddress() +}, new LoadBalancerBackendAddress { Name = "address2", VirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb"), IPAddress = "10.0.0.5", -} -}, +}}, }; ArmOperation lro = await backendAddressPool.UpdateAsync(WaitUntil.Completed, data); BackendAddressPoolResource result = lro.Value; @@ -161,10 +153,10 @@ public async Task Update_UpdateLoadBalancerBackendPoolWithBackendAddressesContai [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_BackendAddressPoolDelete() + public async Task GetInboundNatRulePortMappingsLoadBalancer_QueryInboundNATRulePortMapping() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerBackendAddressPoolDelete.json - // this example is just showing the usage of "LoadBalancerBackendAddressPools_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/QueryInboundNatRulePortMapping.json + // this example is just showing the usage of "LoadBalancers_ListInboundNatRulePortMappings" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,16 +166,21 @@ public async Task Delete_BackendAddressPoolDelete() // this example assumes you already have this BackendAddressPoolResource created on azure // for more information of creating BackendAddressPoolResource, please refer to the document of BackendAddressPoolResource string subscriptionId = "subid"; - string resourceGroupName = "testrg"; - string loadBalancerName = "lb"; - string backendAddressPoolName = "backend"; - ResourceIdentifier backendAddressPoolResourceId = BackendAddressPoolResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, loadBalancerName, backendAddressPoolName); + string groupName = "rg1"; + string loadBalancerName = "lb1"; + string backendPoolName = "bp1"; + ResourceIdentifier backendAddressPoolResourceId = BackendAddressPoolResource.CreateResourceIdentifier(subscriptionId, groupName, loadBalancerName, backendPoolName); BackendAddressPoolResource backendAddressPool = client.GetBackendAddressPoolResource(backendAddressPoolResourceId); // invoke the operation - await backendAddressPool.DeleteAsync(WaitUntil.Completed); + QueryInboundNatRulePortMappingContent content = new QueryInboundNatRulePortMappingContent + { + IPAddress = "10.0.0.4", + }; + ArmOperation lro = await backendAddressPool.GetInboundNatRulePortMappingsLoadBalancerAsync(WaitUntil.Completed, content); + BackendAddressInboundNatRulePortMappings result = lro.Value; - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BaseAdminRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BaseAdminRuleCollection.cs index dbb66f1327e15..7a2963435c679 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BaseAdminRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BaseAdminRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_BaseAdminRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecurityAdminRules() + public async Task CreateOrUpdate_CreateADefaultAdminRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleList.json - // this example is just showing the usage of "AdminRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerDefaultAdminRulePut.json + // this example is just showing the usage of "AdminRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,28 @@ public async Task GetAll_ListSecurityAdminRules() // get the collection of this BaseAdminRuleResource BaseAdminRuleCollection collection = adminRuleGroup.GetBaseAdminRules(); - // invoke the operation and iterate over the result - await foreach (BaseAdminRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleName = "SampleDefaultAdminRule"; + BaseAdminRuleData data = new NetworkDefaultAdminRule { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BaseAdminRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Flag = "AllowVnetInbound", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + BaseAdminRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BaseAdminRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsSecurityAdminRule() + public async Task CreateOrUpdate_CreateAnAdminRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleGet.json - // this example is just showing the usage of "AdminRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRulePut.json + // this example is just showing the usage of "AdminRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -81,7 +84,28 @@ public async Task Get_GetsSecurityAdminRule() // invoke the operation string ruleName = "SampleAdminRule"; - BaseAdminRuleResource result = await collection.GetAsync(ruleName); + BaseAdminRuleData data = new NetworkAdminRule + { + Description = "This is Sample Admin Rule", + Protocol = SecurityConfigurationRuleProtocol.Tcp, + Sources = {new AddressPrefixItem +{ +AddressPrefix = "Internet", +AddressPrefixType = AddressPrefixType.ServiceTag, +}}, + Destinations = {new AddressPrefixItem +{ +AddressPrefix = "*", +AddressPrefixType = AddressPrefixType.IPPrefix, +}}, + SourcePortRanges = { "0-65535" }, + DestinationPortRanges = { "22" }, + Access = SecurityConfigurationRuleAccess.Deny, + Priority = 1, + Direction = SecurityConfigurationRuleDirection.Inbound, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + BaseAdminRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,7 +116,7 @@ public async Task Get_GetsSecurityAdminRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsSecurityAdminRule() + public async Task Get_GetsSecurityAdminRule() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleGet.json // this example is just showing the usage of "AdminRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -117,16 +141,20 @@ public async Task Exists_GetsSecurityAdminRule() // invoke the operation string ruleName = "SampleAdminRule"; - bool result = await collection.ExistsAsync(ruleName); + BaseAdminRuleResource result = await collection.GetAsync(ruleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BaseAdminRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsSecurityAdminRule() + public async Task Get_GetsSecurityDefaultAdminRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerDefaultAdminRuleGet.json // this example is just showing the usage of "AdminRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -148,30 +176,22 @@ public async Task GetIfExists_GetsSecurityAdminRule() BaseAdminRuleCollection collection = adminRuleGroup.GetBaseAdminRules(); // invoke the operation - string ruleName = "SampleAdminRule"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - BaseAdminRuleResource result = response.HasValue ? response.Value : null; + string ruleName = "SampleDefaultAdminRule"; + BaseAdminRuleResource result = await collection.GetAsync(ruleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BaseAdminRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BaseAdminRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsSecurityDefaultAdminRule() + public async Task GetAll_ListSecurityAdminRules() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerDefaultAdminRuleGet.json - // this example is just showing the usage of "AdminRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleList.json + // this example is just showing the usage of "AdminRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,22 +211,24 @@ public async Task Get_GetsSecurityDefaultAdminRule() // get the collection of this BaseAdminRuleResource BaseAdminRuleCollection collection = adminRuleGroup.GetBaseAdminRules(); - // invoke the operation - string ruleName = "SampleDefaultAdminRule"; - BaseAdminRuleResource result = await collection.GetAsync(ruleName); + // invoke the operation and iterate over the result + await foreach (BaseAdminRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BaseAdminRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BaseAdminRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsSecurityDefaultAdminRule() + public async Task Exists_GetsSecurityAdminRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerDefaultAdminRuleGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleGet.json // this example is just showing the usage of "AdminRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -228,7 +250,7 @@ public async Task Exists_GetsSecurityDefaultAdminRule() BaseAdminRuleCollection collection = adminRuleGroup.GetBaseAdminRules(); // invoke the operation - string ruleName = "SampleDefaultAdminRule"; + string ruleName = "SampleAdminRule"; bool result = await collection.ExistsAsync(ruleName); Console.WriteLine($"Succeeded: {result}"); @@ -236,7 +258,7 @@ public async Task Exists_GetsSecurityDefaultAdminRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsSecurityDefaultAdminRule() + public async Task Exists_GetsSecurityDefaultAdminRule() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerDefaultAdminRuleGet.json // this example is just showing the usage of "AdminRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -261,29 +283,17 @@ public async Task GetIfExists_GetsSecurityDefaultAdminRule() // invoke the operation string ruleName = "SampleDefaultAdminRule"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - BaseAdminRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BaseAdminRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADefaultAdminRule() + public async Task GetIfExists_GetsSecurityAdminRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerDefaultAdminRulePut.json - // this example is just showing the usage of "AdminRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleGet.json + // this example is just showing the usage of "AdminRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -304,27 +314,30 @@ public async Task CreateOrUpdate_CreateADefaultAdminRule() BaseAdminRuleCollection collection = adminRuleGroup.GetBaseAdminRules(); // invoke the operation - string ruleName = "SampleDefaultAdminRule"; - BaseAdminRuleData data = new NetworkDefaultAdminRule() - { - Flag = "AllowVnetInbound", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - BaseAdminRuleResource result = lro.Value; + string ruleName = "SampleAdminRule"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + BaseAdminRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BaseAdminRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BaseAdminRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnAdminRule() + public async Task GetIfExists_GetsSecurityDefaultAdminRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRulePut.json - // this example is just showing the usage of "AdminRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerDefaultAdminRuleGet.json + // this example is just showing the usage of "AdminRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -345,47 +358,22 @@ public async Task CreateOrUpdate_CreateAnAdminRule() BaseAdminRuleCollection collection = adminRuleGroup.GetBaseAdminRules(); // invoke the operation - string ruleName = "SampleAdminRule"; - BaseAdminRuleData data = new NetworkAdminRule() - { - Description = "This is Sample Admin Rule", - Protocol = SecurityConfigurationRuleProtocol.Tcp, - Sources = -{ -new AddressPrefixItem() -{ -AddressPrefix = "Internet", -AddressPrefixType = AddressPrefixType.ServiceTag, -} -}, - Destinations = -{ -new AddressPrefixItem() -{ -AddressPrefix = "*", -AddressPrefixType = AddressPrefixType.IPPrefix, -} -}, - SourcePortRanges = -{ -"0-65535" -}, - DestinationPortRanges = -{ -"22" -}, - Access = SecurityConfigurationRuleAccess.Deny, - Priority = 1, - Direction = SecurityConfigurationRuleDirection.Inbound, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - BaseAdminRuleResource result = lro.Value; + string ruleName = "SampleDefaultAdminRule"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + BaseAdminRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BaseAdminRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BaseAdminRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BaseAdminRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BaseAdminRuleResource.cs index c45853c5d35da..effc0f128cb7f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BaseAdminRuleResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BaseAdminRuleResource.cs @@ -82,6 +82,36 @@ public async Task Get_GetsSecurityDefaultAdminRule() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_DeletesAnAdminRule() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleDelete.json + // this example is just showing the usage of "AdminRules_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this BaseAdminRuleResource created on azure + // for more information of creating BaseAdminRuleResource, please refer to the document of BaseAdminRuleResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "rg1"; + string networkManagerName = "testNetworkManager"; + string configurationName = "myTestSecurityConfig"; + string ruleCollectionName = "testRuleCollection"; + string ruleName = "SampleAdminRule"; + ResourceIdentifier baseAdminRuleResourceId = BaseAdminRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName, configurationName, ruleCollectionName, ruleName); + BaseAdminRuleResource baseAdminRule = client.GetBaseAdminRuleResource(baseAdminRuleResourceId); + + // invoke the operation + bool? force = false; + await baseAdminRule.DeleteAsync(WaitUntil.Completed, force: force); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_CreateADefaultAdminRule() @@ -106,7 +136,7 @@ public async Task Update_CreateADefaultAdminRule() BaseAdminRuleResource baseAdminRule = client.GetBaseAdminRuleResource(baseAdminRuleResourceId); // invoke the operation - BaseAdminRuleData data = new NetworkDefaultAdminRule() + BaseAdminRuleData data = new NetworkDefaultAdminRule { Flag = "AllowVnetInbound", }; @@ -144,34 +174,22 @@ public async Task Update_CreateAnAdminRule() BaseAdminRuleResource baseAdminRule = client.GetBaseAdminRuleResource(baseAdminRuleResourceId); // invoke the operation - BaseAdminRuleData data = new NetworkAdminRule() + BaseAdminRuleData data = new NetworkAdminRule { Description = "This is Sample Admin Rule", Protocol = SecurityConfigurationRuleProtocol.Tcp, - Sources = -{ -new AddressPrefixItem() + Sources = {new AddressPrefixItem { AddressPrefix = "Internet", AddressPrefixType = AddressPrefixType.ServiceTag, -} -}, - Destinations = -{ -new AddressPrefixItem() +}}, + Destinations = {new AddressPrefixItem { AddressPrefix = "*", AddressPrefixType = AddressPrefixType.IPPrefix, -} -}, - SourcePortRanges = -{ -"0-65535" -}, - DestinationPortRanges = -{ -"22" -}, +}}, + SourcePortRanges = { "0-65535" }, + DestinationPortRanges = { "22" }, Access = SecurityConfigurationRuleAccess.Deny, Priority = 1, Direction = SecurityConfigurationRuleDirection.Inbound, @@ -185,35 +203,5 @@ public async Task Update_CreateAnAdminRule() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAnAdminRule() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerAdminRuleDelete.json - // this example is just showing the usage of "AdminRules_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this BaseAdminRuleResource created on azure - // for more information of creating BaseAdminRuleResource, please refer to the document of BaseAdminRuleResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string networkManagerName = "testNetworkManager"; - string configurationName = "myTestSecurityConfig"; - string ruleCollectionName = "testRuleCollection"; - string ruleName = "SampleAdminRule"; - ResourceIdentifier baseAdminRuleResourceId = BaseAdminRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName, configurationName, ruleCollectionName, ruleName); - BaseAdminRuleResource baseAdminRule = client.GetBaseAdminRuleResource(baseAdminRuleResourceId); - - // invoke the operation - bool? force = false; - await baseAdminRule.DeleteAsync(WaitUntil.Completed, force: force); - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BastionHostCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BastionHostCollection.cs index fa822078d0564..2683e4c909dc0 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BastionHostCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BastionHostCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_BastionHostCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetBastionHost() + public async Task CreateOrUpdate_CreateBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGet.json - // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostPut.json + // this example is just showing the usage of "BastionHosts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,18 @@ public async Task Get_GetBastionHost() BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); // invoke the operation - string bastionHostName = "bastionhosttenant'"; - BastionHostResource result = await collection.GetAsync(bastionHostName); + string bastionHostName = "bastionhosttenant"; + BastionHostData data = new BastionHostData + { + IPConfigurations = {new BastionHostIPConfiguration +{ +SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/BastionHostSubnet"), +PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), +Name = "bastionHostIpConfiguration", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bastionHostName, data); + BastionHostResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +62,10 @@ public async Task Get_GetBastionHost() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetBastionHost() + public async Task CreateOrUpdate_CreateBastionHostWithZones() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGet.json - // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostPutWithZones.json + // this example is just showing the usage of "BastionHosts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,18 +83,32 @@ public async Task Exists_GetBastionHost() BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); // invoke the operation - string bastionHostName = "bastionhosttenant'"; - bool result = await collection.ExistsAsync(bastionHostName); + string bastionHostName = "bastionhosttenant"; + BastionHostData data = new BastionHostData + { + IPConfigurations = {new BastionHostIPConfiguration +{ +SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/BastionHostSubnet"), +PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), +Name = "bastionHostIpConfiguration", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bastionHostName, data); + BastionHostResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BastionHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetBastionHost() + public async Task CreateOrUpdate_CreateDeveloperBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGet.json - // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperPut.json + // this example is just showing the usage of "BastionHosts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,7 +118,7 @@ public async Task GetIfExists_GetBastionHost() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; + string resourceGroupName = "rg2"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -102,29 +126,31 @@ public async Task GetIfExists_GetBastionHost() BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); // invoke the operation - string bastionHostName = "bastionhosttenant'"; - NullableResponse response = await collection.GetIfExistsAsync(bastionHostName); - BastionHostResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string bastionHostName = "bastionhostdeveloper"; + BastionHostData data = new BastionHostData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BastionHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + IPConfigurations = { }, + VirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/vnet2"), + NetworkAclsIPRules = {new BastionHostIPRule +{ +AddressPrefix = "1.1.1.1/16", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bastionHostName, data); + BastionHostResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BastionHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetBastionHostWithZones() + public async Task Get_GetBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGetWithZones.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGet.json // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -155,7 +181,7 @@ public async Task Get_GetBastionHostWithZones() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetBastionHostWithZones() + public async Task Get_GetBastionHostWithZones() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGetWithZones.json // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. @@ -177,16 +203,20 @@ public async Task Exists_GetBastionHostWithZones() // invoke the operation string bastionHostName = "bastionhosttenant'"; - bool result = await collection.ExistsAsync(bastionHostName); + BastionHostResource result = await collection.GetAsync(bastionHostName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BastionHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetBastionHostWithZones() + public async Task Get_GetDeveloperBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGetWithZones.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperGet.json // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -205,30 +235,22 @@ public async Task GetIfExists_GetBastionHostWithZones() BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); // invoke the operation - string bastionHostName = "bastionhosttenant'"; - NullableResponse response = await collection.GetIfExistsAsync(bastionHostName); - BastionHostResource result = response.HasValue ? response.Value : null; + string bastionHostName = "bastionhostdeveloper'"; + BastionHostResource result = await collection.GetAsync(bastionHostName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BastionHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BastionHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDeveloperBastionHost() + public async Task GetAll_ListAllBastionHostsForAGivenResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperGet.json - // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostListByResourceGroup.json + // this example is just showing the usage of "BastionHosts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -245,22 +267,24 @@ public async Task Get_GetDeveloperBastionHost() // get the collection of this BastionHostResource BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); - // invoke the operation - string bastionHostName = "bastionhostdeveloper'"; - BastionHostResource result = await collection.GetAsync(bastionHostName); + // invoke the operation and iterate over the result + await foreach (BastionHostResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BastionHostData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BastionHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDeveloperBastionHost() + public async Task Exists_GetBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGet.json // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -279,7 +303,7 @@ public async Task Exists_GetDeveloperBastionHost() BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); // invoke the operation - string bastionHostName = "bastionhostdeveloper'"; + string bastionHostName = "bastionhosttenant'"; bool result = await collection.ExistsAsync(bastionHostName); Console.WriteLine($"Succeeded: {result}"); @@ -287,9 +311,9 @@ public async Task Exists_GetDeveloperBastionHost() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDeveloperBastionHost() + public async Task Exists_GetBastionHostWithZones() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGetWithZones.json // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -308,30 +332,18 @@ public async Task GetIfExists_GetDeveloperBastionHost() BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); // invoke the operation - string bastionHostName = "bastionhostdeveloper'"; - NullableResponse response = await collection.GetIfExistsAsync(bastionHostName); - BastionHostResource result = response.HasValue ? response.Value : null; + string bastionHostName = "bastionhosttenant'"; + bool result = await collection.ExistsAsync(bastionHostName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BastionHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateBastionHost() + public async Task Exists_GetDeveloperBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostPut.json - // this example is just showing the usage of "BastionHosts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperGet.json + // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -349,35 +361,18 @@ public async Task CreateOrUpdate_CreateBastionHost() BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); // invoke the operation - string bastionHostName = "bastionhosttenant"; - BastionHostData data = new BastionHostData() - { - IPConfigurations = -{ -new BastionHostIPConfiguration() -{ -SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/BastionHostSubnet"), -PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), -Name = "bastionHostIpConfiguration", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bastionHostName, data); - BastionHostResource result = lro.Value; + string bastionHostName = "bastionhostdeveloper'"; + bool result = await collection.ExistsAsync(bastionHostName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BastionHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateBastionHostWithZones() + public async Task GetIfExists_GetBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostPutWithZones.json - // this example is just showing the usage of "BastionHosts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGet.json + // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -395,35 +390,30 @@ public async Task CreateOrUpdate_CreateBastionHostWithZones() BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); // invoke the operation - string bastionHostName = "bastionhosttenant"; - BastionHostData data = new BastionHostData() - { - IPConfigurations = -{ -new BastionHostIPConfiguration() -{ -SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet2/subnets/BastionHostSubnet"), -PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pipName"), -Name = "bastionHostIpConfiguration", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bastionHostName, data); - BastionHostResource result = lro.Value; + string bastionHostName = "bastionhosttenant'"; + NullableResponse response = await collection.GetIfExistsAsync(bastionHostName); + BastionHostResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BastionHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BastionHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateDeveloperBastionHost() + public async Task GetIfExists_GetBastionHostWithZones() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperPut.json - // this example is just showing the usage of "BastionHosts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGetWithZones.json + // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -433,7 +423,7 @@ public async Task CreateOrUpdate_CreateDeveloperBastionHost() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource string subscriptionId = "subid"; - string resourceGroupName = "rg2"; + string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -441,37 +431,30 @@ public async Task CreateOrUpdate_CreateDeveloperBastionHost() BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); // invoke the operation - string bastionHostName = "bastionhostdeveloper"; - BastionHostData data = new BastionHostData() - { - IPConfigurations = -{ -}, - VirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/virtualNetworks/vnet2"), - NetworkAclsIPRules = -{ -new BastionHostIPRule() -{ -AddressPrefix = "1.1.1.1/16", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, bastionHostName, data); - BastionHostResource result = lro.Value; + string bastionHostName = "bastionhosttenant'"; + NullableResponse response = await collection.GetIfExistsAsync(bastionHostName); + BastionHostResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BastionHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BastionHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllBastionHostsForAGivenResourceGroup() + public async Task GetIfExists_GetDeveloperBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostListByResourceGroup.json - // this example is just showing the usage of "BastionHosts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperGet.json + // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -488,17 +471,23 @@ public async Task GetAll_ListAllBastionHostsForAGivenResourceGroup() // get the collection of this BastionHostResource BastionHostCollection collection = resourceGroupResource.GetBastionHosts(); - // invoke the operation and iterate over the result - await foreach (BastionHostResource item in collection.GetAllAsync()) + // invoke the operation + string bastionHostName = "bastionhostdeveloper'"; + NullableResponse response = await collection.GetIfExistsAsync(bastionHostName); + BastionHostResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BastionHostData resourceData = item.Data; + BastionHostData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BastionHostResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BastionHostResource.cs index 10f03bd771073..12730789d2965 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BastionHostResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BastionHostResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_BastionHostResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteBastionHost() + public async Task Get_GetBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDelete.json - // this example is just showing the usage of "BastionHosts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGet.json + // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +32,26 @@ public async Task Delete_DeleteBastionHost() // for more information of creating BastionHostResource, please refer to the document of BastionHostResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string bastionHostName = "bastionhosttenant"; + string bastionHostName = "bastionhosttenant'"; ResourceIdentifier bastionHostResourceId = BastionHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, bastionHostName); BastionHostResource bastionHost = client.GetBastionHostResource(bastionHostResourceId); // invoke the operation - await bastionHost.DeleteAsync(WaitUntil.Completed); + BastionHostResource result = await bastionHost.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BastionHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDeveloperBastionHost() + public async Task Get_GetBastionHostWithZones() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperDelete.json - // this example is just showing the usage of "BastionHosts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGetWithZones.json + // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -58,22 +61,26 @@ public async Task Delete_DeleteDeveloperBastionHost() // this example assumes you already have this BastionHostResource created on azure // for more information of creating BastionHostResource, please refer to the document of BastionHostResource string subscriptionId = "subid"; - string resourceGroupName = "rg2"; - string bastionHostName = "bastionhostdeveloper"; + string resourceGroupName = "rg1"; + string bastionHostName = "bastionhosttenant'"; ResourceIdentifier bastionHostResourceId = BastionHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, bastionHostName); BastionHostResource bastionHost = client.GetBastionHostResource(bastionHostResourceId); // invoke the operation - await bastionHost.DeleteAsync(WaitUntil.Completed); + BastionHostResource result = await bastionHost.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BastionHostData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetBastionHost() + public async Task Get_GetDeveloperBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperGet.json // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -85,7 +92,7 @@ public async Task Get_GetBastionHost() // for more information of creating BastionHostResource, please refer to the document of BastionHostResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string bastionHostName = "bastionhosttenant'"; + string bastionHostName = "bastionhostdeveloper'"; ResourceIdentifier bastionHostResourceId = BastionHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, bastionHostName); BastionHostResource bastionHost = client.GetBastionHostResource(bastionHostResourceId); @@ -101,10 +108,10 @@ public async Task Get_GetBastionHost() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetBastionHostWithZones() + public async Task Delete_DeleteBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostGetWithZones.json - // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDelete.json + // this example is just showing the usage of "BastionHosts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,26 +122,22 @@ public async Task Get_GetBastionHostWithZones() // for more information of creating BastionHostResource, please refer to the document of BastionHostResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string bastionHostName = "bastionhosttenant'"; + string bastionHostName = "bastionhosttenant"; ResourceIdentifier bastionHostResourceId = BastionHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, bastionHostName); BastionHostResource bastionHost = client.GetBastionHostResource(bastionHostResourceId); // invoke the operation - BastionHostResource result = await bastionHost.GetAsync(); + await bastionHost.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BastionHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDeveloperBastionHost() + public async Task Delete_DeleteDeveloperBastionHost() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperGet.json - // this example is just showing the usage of "BastionHosts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostDeveloperDelete.json + // this example is just showing the usage of "BastionHosts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,19 +147,15 @@ public async Task Get_GetDeveloperBastionHost() // this example assumes you already have this BastionHostResource created on azure // for more information of creating BastionHostResource, please refer to the document of BastionHostResource string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string bastionHostName = "bastionhostdeveloper'"; + string resourceGroupName = "rg2"; + string bastionHostName = "bastionhostdeveloper"; ResourceIdentifier bastionHostResourceId = BastionHostResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, bastionHostName); BastionHostResource bastionHost = client.GetBastionHostResource(bastionHostResourceId); // invoke the operation - BastionHostResource result = await bastionHost.GetAsync(); + await bastionHost.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BastionHostData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -180,12 +179,12 @@ public async Task Update_PatchBastionHost() BastionHostResource bastionHost = client.GetBastionHostResource(bastionHostResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await bastionHost.UpdateAsync(WaitUntil.Completed, networkTagsObject); @@ -198,37 +197,6 @@ public async Task Update_PatchBastionHost() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetBastionHosts_ListAllBastionHostsForAGivenSubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostListBySubscription.json - // this example is just showing the usage of "BastionHosts_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (BastionHostResource item in subscriptionResource.GetBastionHostsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BastionHostData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task DeleteBastionShareableLinkByToken_DeleteBastionShareableLinksForTheRequestVMs() @@ -250,12 +218,9 @@ public async Task DeleteBastionShareableLinkByToken_DeleteBastionShareableLinksF BastionHostResource bastionHost = client.GetBastionHostResource(bastionHostResourceId); // invoke the operation - BastionShareableLinkTokenListContent content = new BastionShareableLinkTokenListContent() + BastionShareableLinkTokenListContent content = new BastionShareableLinkTokenListContent { - Tokens = -{ -"abcd1234-efgh-hijk-5678-abcdefgh1234","dcba4321-hgfe-kjih-8765-hgfedcba4321" -}, + Tokens = { "abcd1234-efgh-hijk-5678-abcdefgh1234", "dcba4321-hgfe-kjih-8765-hgfedcba4321" }, }; await bastionHost.DeleteBastionShareableLinkByTokenAsync(WaitUntil.Completed, content); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BgpConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BgpConnectionCollection.cs index 0f97ce872073e..2c37fecd3ce3e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BgpConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BgpConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_BgpConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualHubVirtualHubRouteTableV2Get() + public async Task CreateOrUpdate_VirtualHubRouteTableV2Put() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionGet.json - // this example is just showing the usage of "VirtualHubBgpConnection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionPut.json + // this example is just showing the usage of "VirtualHubBgpConnection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,14 @@ public async Task Get_VirtualHubVirtualHubRouteTableV2Get() // invoke the operation string connectionName = "conn1"; - BgpConnectionResource result = await collection.GetAsync(connectionName); + BgpConnectionData data = new BgpConnectionData + { + PeerAsn = 20000L, + PeerIP = "192.168.1.5", + HubVirtualNetworkConnectionId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubVirtualNetworkConnections/hubVnetConn1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionName, data); + BgpConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +58,7 @@ public async Task Get_VirtualHubVirtualHubRouteTableV2Get() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualHubVirtualHubRouteTableV2Get() + public async Task Get_VirtualHubVirtualHubRouteTableV2Get() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionGet.json // this example is just showing the usage of "VirtualHubBgpConnection_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +81,21 @@ public async Task Exists_VirtualHubVirtualHubRouteTableV2Get() // invoke the operation string connectionName = "conn1"; - bool result = await collection.ExistsAsync(connectionName); + BgpConnectionResource result = await collection.GetAsync(connectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BgpConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualHubVirtualHubRouteTableV2Get() + public async Task GetAll_VirtualHubRouteTableV2List() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionGet.json - // this example is just showing the usage of "VirtualHubBgpConnection_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionList.json + // this example is just showing the usage of "VirtualHubBgpConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +113,25 @@ public async Task GetIfExists_VirtualHubVirtualHubRouteTableV2Get() // get the collection of this BgpConnectionResource BgpConnectionCollection collection = virtualHub.GetBgpConnections(); - // invoke the operation - string connectionName = "conn1"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - BgpConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (BgpConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BgpConnectionData resourceData = result.Data; + BgpConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VirtualHubRouteTableV2Put() + public async Task Exists_VirtualHubVirtualHubRouteTableV2Get() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionPut.json - // this example is just showing the usage of "VirtualHubBgpConnection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionGet.json + // this example is just showing the usage of "VirtualHubBgpConnection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,28 +151,17 @@ public async Task CreateOrUpdate_VirtualHubRouteTableV2Put() // invoke the operation string connectionName = "conn1"; - BgpConnectionData data = new BgpConnectionData() - { - PeerAsn = 20000L, - PeerIP = "192.168.1.5", - HubVirtualNetworkConnectionId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubVirtualNetworkConnections/hubVnetConn1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionName, data); - BgpConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(connectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BgpConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualHubRouteTableV2List() + public async Task GetIfExists_VirtualHubVirtualHubRouteTableV2Get() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionList.json - // this example is just showing the usage of "VirtualHubBgpConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionGet.json + // this example is just showing the usage of "VirtualHubBgpConnection_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_VirtualHubRouteTableV2List() // get the collection of this BgpConnectionResource BgpConnectionCollection collection = virtualHub.GetBgpConnections(); - // invoke the operation and iterate over the result - await foreach (BgpConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string connectionName = "conn1"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + BgpConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - BgpConnectionData resourceData = item.Data; + BgpConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BgpConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BgpConnectionResource.cs index 9b7969077961c..8cda52f9169f0 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BgpConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_BgpConnectionResource.cs @@ -50,10 +50,10 @@ public async Task Get_VirtualHubVirtualHubRouteTableV2Get() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VirtualHubRouteTableV2Put() + public async Task Delete_VirtualHubRouteTableV2Delete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionPut.json - // this example is just showing the usage of "VirtualHubBgpConnection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionDelete.json + // this example is just showing the usage of "VirtualHubBgpConnection_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -70,28 +70,17 @@ public async Task Update_VirtualHubRouteTableV2Put() BgpConnectionResource bgpConnection = client.GetBgpConnectionResource(bgpConnectionResourceId); // invoke the operation - BgpConnectionData data = new BgpConnectionData() - { - PeerAsn = 20000L, - PeerIP = "192.168.1.5", - HubVirtualNetworkConnectionId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubVirtualNetworkConnections/hubVnetConn1"), - }; - ArmOperation lro = await bgpConnection.UpdateAsync(WaitUntil.Completed, data); - BgpConnectionResource result = lro.Value; + await bgpConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - BgpConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VirtualHubRouteTableV2Delete() + public async Task Update_VirtualHubRouteTableV2Put() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionDelete.json - // this example is just showing the usage of "VirtualHubBgpConnection_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubBgpConnectionPut.json + // this example is just showing the usage of "VirtualHubBgpConnection_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,9 +97,20 @@ public async Task Delete_VirtualHubRouteTableV2Delete() BgpConnectionResource bgpConnection = client.GetBgpConnectionResource(bgpConnectionResourceId); // invoke the operation - await bgpConnection.DeleteAsync(WaitUntil.Completed); + BgpConnectionData data = new BgpConnectionData + { + PeerAsn = 20000L, + PeerIP = "192.168.1.5", + HubVirtualNetworkConnectionId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubVirtualNetworkConnections/hubVnetConn1"), + }; + ArmOperation lro = await bgpConnection.UpdateAsync(WaitUntil.Completed, data); + BgpConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BgpConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CloudServiceSwapCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CloudServiceSwapCollection.cs index a6976dddfddf2..c05249e26dee2 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CloudServiceSwapCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CloudServiceSwapCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_CloudServiceSwapCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSwapResource() + public async Task CreateOrUpdate_PutVipSwapOperation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CloudServiceSwapGet.json - // this example is just showing the usage of "VipSwap_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CloudServiceSwapPut.json + // this example is just showing the usage of "VipSwap_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,18 +41,18 @@ public async Task Get_GetSwapResource() CloudServiceSwapCollection collection = resourceGroupResource.GetCloudServiceSwaps(resourceName); // invoke the operation - CloudServiceSwapResource result = await collection.GetAsync(); + CloudServiceSwapData data = new CloudServiceSwapData + { + CloudServiceSwapSlotType = SwapSlotType.Production, + }; + await collection.CreateOrUpdateAsync(WaitUntil.Completed, data); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CloudServiceSwapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSwapResource() + public async Task Get_GetSwapResource() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CloudServiceSwapGet.json // this example is just showing the usage of "VipSwap_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +74,21 @@ public async Task Exists_GetSwapResource() CloudServiceSwapCollection collection = resourceGroupResource.GetCloudServiceSwaps(resourceName); // invoke the operation - bool result = await collection.ExistsAsync(); + CloudServiceSwapResource result = await collection.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CloudServiceSwapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSwapResource() + public async Task GetAll_GetSwapResourceList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CloudServiceSwapGet.json - // this example is just showing the usage of "VipSwap_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CloudServiceSwapList.json + // this example is just showing the usage of "VipSwap_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,30 +106,25 @@ public async Task GetIfExists_GetSwapResource() string resourceName = "testCloudService"; CloudServiceSwapCollection collection = resourceGroupResource.GetCloudServiceSwaps(resourceName); - // invoke the operation - NullableResponse response = await collection.GetIfExistsAsync(); - CloudServiceSwapResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CloudServiceSwapResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CloudServiceSwapData resourceData = result.Data; + CloudServiceSwapData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutVipSwapOperation() + public async Task Exists_GetSwapResource() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CloudServiceSwapPut.json - // this example is just showing the usage of "VipSwap_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CloudServiceSwapGet.json + // this example is just showing the usage of "VipSwap_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,21 +143,17 @@ public async Task CreateOrUpdate_PutVipSwapOperation() CloudServiceSwapCollection collection = resourceGroupResource.GetCloudServiceSwaps(resourceName); // invoke the operation - CloudServiceSwapData data = new CloudServiceSwapData() - { - CloudServiceSwapSlotType = SwapSlotType.Production, - }; - await collection.CreateOrUpdateAsync(WaitUntil.Completed, data); + bool result = await collection.ExistsAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetSwapResourceList() + public async Task GetIfExists_GetSwapResource() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CloudServiceSwapList.json - // this example is just showing the usage of "VipSwap_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CloudServiceSwapGet.json + // this example is just showing the usage of "VipSwap_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,17 +171,22 @@ public async Task GetAll_GetSwapResourceList() string resourceName = "testCloudService"; CloudServiceSwapCollection collection = resourceGroupResource.GetCloudServiceSwaps(resourceName); - // invoke the operation and iterate over the result - await foreach (CloudServiceSwapResource item in collection.GetAllAsync()) + // invoke the operation + NullableResponse response = await collection.GetIfExistsAsync(); + CloudServiceSwapResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CloudServiceSwapData resourceData = item.Data; + CloudServiceSwapData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CloudServiceSwapResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CloudServiceSwapResource.cs index 7deaed06484af..c712c334a862a 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CloudServiceSwapResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CloudServiceSwapResource.cs @@ -67,7 +67,7 @@ public async Task Update_PutVipSwapOperation() CloudServiceSwapResource cloudServiceSwap = client.GetCloudServiceSwapResource(cloudServiceSwapResourceId); // invoke the operation - CloudServiceSwapData data = new CloudServiceSwapData() + CloudServiceSwapData data = new CloudServiceSwapData { CloudServiceSwapSlotType = SwapSlotType.Production, }; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectionMonitorCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectionMonitorCollection.cs index 8aab0de9dea27..33f70c7680788 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectionMonitorCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectionMonitorCollection.cs @@ -41,43 +41,25 @@ public async Task CreateOrUpdate_CreateConnectionMonitorV1() // invoke the operation string connectionMonitorName = "cm1"; - ConnectionMonitorCreateOrUpdateContent content = new ConnectionMonitorCreateOrUpdateContent() + ConnectionMonitorCreateOrUpdateContent content = new ConnectionMonitorCreateOrUpdateContent { Location = new AzureLocation("eastus"), - Endpoints = -{ -new ConnectionMonitorEndpoint("source") + Endpoints = {new ConnectionMonitorEndpoint("source") { ResourceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Compute/virtualMachines/ct1"), -},new ConnectionMonitorEndpoint("destination") +}, new ConnectionMonitorEndpoint("destination") { Address = "bing.com", -} -}, - TestConfigurations = -{ -new ConnectionMonitorTestConfiguration("tcp",ConnectionMonitorTestConfigurationProtocol.Tcp) +}}, + TestConfigurations = {new ConnectionMonitorTestConfiguration("tcp", ConnectionMonitorTestConfigurationProtocol.Tcp) { TestFrequencySec = 60, -TcpConfiguration = new ConnectionMonitorTcpConfiguration() +TcpConfiguration = new ConnectionMonitorTcpConfiguration { Port = 80, }, -} -}, - TestGroups = -{ -new ConnectionMonitorTestGroup("tg",new string[] -{ -"tcp" -},new string[] -{ -"source" -},new string[] -{ -"destination" -}) -}, +}}, + TestGroups = { new ConnectionMonitorTestGroup("tg", new string[] { "tcp" }, new string[] { "source" }, new string[] { "destination" }) }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionMonitorName, content); ConnectionMonitorResource result = lro.Value; @@ -114,67 +96,44 @@ public async Task CreateOrUpdate_CreateConnectionMonitorV2() // invoke the operation string connectionMonitorName = "cm1"; - ConnectionMonitorCreateOrUpdateContent content = new ConnectionMonitorCreateOrUpdateContent() + ConnectionMonitorCreateOrUpdateContent content = new ConnectionMonitorCreateOrUpdateContent { - Endpoints = -{ -new ConnectionMonitorEndpoint("vm1") + Endpoints = {new ConnectionMonitorEndpoint("vm1") { ResourceId = new ResourceIdentifier("/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/NwRgIrinaCentralUSEUAP/providers/Microsoft.Compute/virtualMachines/vm1"), -},new ConnectionMonitorEndpoint("CanaryWorkspaceVamshi") +}, new ConnectionMonitorEndpoint("CanaryWorkspaceVamshi") { ResourceId = new ResourceIdentifier("/subscriptions/96e68903-0a56-4819-9987-8d08ad6a1f99/resourceGroups/vasamudrRG/providers/Microsoft.OperationalInsights/workspaces/vasamudrWorkspace"), -Filter = new ConnectionMonitorEndpointFilter() +Filter = new ConnectionMonitorEndpointFilter { FilterType = ConnectionMonitorEndpointFilterType.Include, -Items = -{ -new ConnectionMonitorEndpointFilterItem() +Items = {new ConnectionMonitorEndpointFilterItem { ItemType = ConnectionMonitorEndpointFilterItemType.AgentAddress, Address = "npmuser", -} +}}, }, -}, -},new ConnectionMonitorEndpoint("bing") +}, new ConnectionMonitorEndpoint("bing") { Address = "bing.com", -},new ConnectionMonitorEndpoint("google") +}, new ConnectionMonitorEndpoint("google") { Address = "google.com", -} -}, - TestConfigurations = -{ -new ConnectionMonitorTestConfiguration("testConfig1",ConnectionMonitorTestConfigurationProtocol.Tcp) +}}, + TestConfigurations = {new ConnectionMonitorTestConfiguration("testConfig1", ConnectionMonitorTestConfigurationProtocol.Tcp) { TestFrequencySec = 60, -TcpConfiguration = new ConnectionMonitorTcpConfiguration() +TcpConfiguration = new ConnectionMonitorTcpConfiguration { Port = 80, DisableTraceRoute = false, }, -} -}, - TestGroups = -{ -new ConnectionMonitorTestGroup("test1",new string[] -{ -"testConfig1" -},new string[] -{ -"vm1","CanaryWorkspaceVamshi" -},new string[] -{ -"bing","google" -}) +}}, + TestGroups = {new ConnectionMonitorTestGroup("test1", new string[]{"testConfig1"}, new string[]{"vm1", "CanaryWorkspaceVamshi"}, new string[]{"bing", "google"}) { Disable = false, -} -}, - Outputs = -{ -}, +}}, + Outputs = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionMonitorName, content); ConnectionMonitorResource result = lro.Value; @@ -211,70 +170,47 @@ public async Task CreateOrUpdate_CreateConnectionMonitorWithArcNetwork() // invoke the operation string connectionMonitorName = "cm1"; - ConnectionMonitorCreateOrUpdateContent content = new ConnectionMonitorCreateOrUpdateContent() + ConnectionMonitorCreateOrUpdateContent content = new ConnectionMonitorCreateOrUpdateContent { - Endpoints = -{ -new ConnectionMonitorEndpoint("vm1") + Endpoints = {new ConnectionMonitorEndpoint("vm1") { EndpointType = ConnectionMonitorEndpointType.AzureVm, ResourceId = new ResourceIdentifier("/subscriptions/9cece3e3-0f7d-47ca-af0e-9772773f90b7/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/TESTVM"), -},new ConnectionMonitorEndpoint("bing") +}, new ConnectionMonitorEndpoint("bing") { EndpointType = ConnectionMonitorEndpointType.ExternalAddress, Address = "bing.com", -},new ConnectionMonitorEndpoint("google") +}, new ConnectionMonitorEndpoint("google") { EndpointType = ConnectionMonitorEndpointType.ExternalAddress, Address = "google.com", -},new ConnectionMonitorEndpoint("ArcBasedNetwork") +}, new ConnectionMonitorEndpoint("ArcBasedNetwork") { EndpointType = ConnectionMonitorEndpointType.AzureArcNetwork, -Scope = new ConnectionMonitorEndpointScope() +Scope = new ConnectionMonitorEndpointScope { -Include = -{ -new ConnectionMonitorEndpointScopeItem() +Include = {new ConnectionMonitorEndpointScopeItem { Address = "172.21.128.0/20", -} -}, +}}, }, LocationDetailsRegion = "eastus", SubscriptionId = Guid.Parse("9cece3e3-0f7d-47ca-af0e-9772773f90b7"), -} -}, - TestConfigurations = -{ -new ConnectionMonitorTestConfiguration("testConfig1",ConnectionMonitorTestConfigurationProtocol.Tcp) +}}, + TestConfigurations = {new ConnectionMonitorTestConfiguration("testConfig1", ConnectionMonitorTestConfigurationProtocol.Tcp) { TestFrequencySec = 60, -TcpConfiguration = new ConnectionMonitorTcpConfiguration() +TcpConfiguration = new ConnectionMonitorTcpConfiguration { Port = 80, DisableTraceRoute = false, }, -} -}, - TestGroups = -{ -new ConnectionMonitorTestGroup("test1",new string[] -{ -"testConfig1" -},new string[] -{ -"vm1","ArcBasedNetwork" -},new string[] -{ -"bing","google" -}) +}}, + TestGroups = {new ConnectionMonitorTestGroup("test1", new string[]{"testConfig1"}, new string[]{"vm1", "ArcBasedNetwork"}, new string[]{"bing", "google"}) { Disable = false, -} -}, - Outputs = -{ -}, +}}, + Outputs = { }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionMonitorName, content); ConnectionMonitorResource result = lro.Value; @@ -322,10 +258,10 @@ public async Task Get_GetConnectionMonitor() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetConnectionMonitor() + public async Task GetAll_ListConnectionMonitors() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherConnectionMonitorGet.json - // this example is just showing the usage of "ConnectionMonitors_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherConnectionMonitorList.json + // this example is just showing the usage of "ConnectionMonitors_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -343,16 +279,22 @@ public async Task Exists_GetConnectionMonitor() // get the collection of this ConnectionMonitorResource ConnectionMonitorCollection collection = networkWatcher.GetConnectionMonitors(); - // invoke the operation - string connectionMonitorName = "cm1"; - bool result = await collection.ExistsAsync(connectionMonitorName); + // invoke the operation and iterate over the result + await foreach (ConnectionMonitorResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectionMonitorData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetConnectionMonitor() + public async Task Exists_GetConnectionMonitor() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherConnectionMonitorGet.json // this example is just showing the usage of "ConnectionMonitors_Get" operation, for the dependent resources, they will have to be created separately. @@ -375,29 +317,17 @@ public async Task GetIfExists_GetConnectionMonitor() // invoke the operation string connectionMonitorName = "cm1"; - NullableResponse response = await collection.GetIfExistsAsync(connectionMonitorName); - ConnectionMonitorResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(connectionMonitorName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectionMonitorData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConnectionMonitors() + public async Task GetIfExists_GetConnectionMonitor() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherConnectionMonitorList.json - // this example is just showing the usage of "ConnectionMonitors_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherConnectionMonitorGet.json + // this example is just showing the usage of "ConnectionMonitors_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -415,17 +345,23 @@ public async Task GetAll_ListConnectionMonitors() // get the collection of this ConnectionMonitorResource ConnectionMonitorCollection collection = networkWatcher.GetConnectionMonitors(); - // invoke the operation and iterate over the result - await foreach (ConnectionMonitorResource item in collection.GetAllAsync()) + // invoke the operation + string connectionMonitorName = "cm1"; + NullableResponse response = await collection.GetIfExistsAsync(connectionMonitorName); + ConnectionMonitorResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectionMonitorData resourceData = item.Data; + ConnectionMonitorData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectionMonitorResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectionMonitorResource.cs index 2a0f3aa26c9c0..746c0e6558bec 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectionMonitorResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectionMonitorResource.cs @@ -96,12 +96,12 @@ public async Task Update_UpdateConnectionMonitorTags() ConnectionMonitorResource connectionMonitor = client.GetConnectionMonitorResource(connectionMonitorResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ConnectionMonitorResource result = await connectionMonitor.UpdateAsync(networkTagsObject); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectivityConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectivityConfigurationCollection.cs index 2194533fe1164..34b420e0672ac 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectivityConfigurationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectivityConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ConnectivityConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConnectivityConfigurationsGet() + public async Task CreateOrUpdate_ConnectivityConfigurationsPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationGet.json - // this example is just showing the usage of "ConnectivityConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationPut.json + // this example is just showing the usage of "ConnectivityConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,25 @@ public async Task Get_ConnectivityConfigurationsGet() // invoke the operation string configurationName = "myTestConnectivityConfig"; - ConnectivityConfigurationResource result = await collection.GetAsync(configurationName); + ConnectivityConfigurationData data = new ConnectivityConfigurationData + { + Description = "Sample Configuration", + ConnectivityTopology = ConnectivityTopology.HubAndSpoke, + Hubs = {new ConnectivityHub +{ +ResourceId = new ResourceIdentifier("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myTestConnectivityConfig"), +ResourceType = new ResourceType("Microsoft.Network/virtualNetworks"), +}}, + IsGlobal = GlobalMeshSupportFlag.True, + AppliesToGroups = {new ConnectivityGroupItem("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/group1", GroupConnectivity.None) +{ +UseHubGateway = HubGatewayUsageFlag.True, +IsGlobal = GlobalMeshSupportFlag.False, +}}, + DeleteExistingPeering = DeleteExistingPeering.True, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + ConnectivityConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +70,7 @@ public async Task Get_ConnectivityConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConnectivityConfigurationsGet() + public async Task Get_ConnectivityConfigurationsGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationGet.json // this example is just showing the usage of "ConnectivityConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +93,21 @@ public async Task Exists_ConnectivityConfigurationsGet() // invoke the operation string configurationName = "myTestConnectivityConfig"; - bool result = await collection.ExistsAsync(configurationName); + ConnectivityConfigurationResource result = await collection.GetAsync(configurationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectivityConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConnectivityConfigurationsGet() + public async Task GetAll_ConnectivityConfigurationsList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationGet.json - // this example is just showing the usage of "ConnectivityConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationList.json + // this example is just showing the usage of "ConnectivityConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +125,25 @@ public async Task GetIfExists_ConnectivityConfigurationsGet() // get the collection of this ConnectivityConfigurationResource ConnectivityConfigurationCollection collection = networkManager.GetConnectivityConfigurations(); - // invoke the operation - string configurationName = "myTestConnectivityConfig"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - ConnectivityConfigurationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ConnectivityConfigurationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectivityConfigurationData resourceData = result.Data; + ConnectivityConfigurationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ConnectivityConfigurationsPut() + public async Task Exists_ConnectivityConfigurationsGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationPut.json - // this example is just showing the usage of "ConnectivityConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationGet.json + // this example is just showing the usage of "ConnectivityConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,45 +163,17 @@ public async Task CreateOrUpdate_ConnectivityConfigurationsPut() // invoke the operation string configurationName = "myTestConnectivityConfig"; - ConnectivityConfigurationData data = new ConnectivityConfigurationData() - { - Description = "Sample Configuration", - ConnectivityTopology = ConnectivityTopology.HubAndSpoke, - Hubs = -{ -new ConnectivityHub() -{ -ResourceId = new ResourceIdentifier("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myTestConnectivityConfig"), -ResourceType = new ResourceType("Microsoft.Network/virtualNetworks"), -} -}, - IsGlobal = GlobalMeshSupportFlag.True, - AppliesToGroups = -{ -new ConnectivityGroupItem("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/group1",GroupConnectivity.None) -{ -UseHubGateway = HubGatewayUsageFlag.True, -IsGlobal = GlobalMeshSupportFlag.False, -} -}, - DeleteExistingPeering = DeleteExistingPeering.True, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - ConnectivityConfigurationResource result = lro.Value; + bool result = await collection.ExistsAsync(configurationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectivityConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConnectivityConfigurationsList() + public async Task GetIfExists_ConnectivityConfigurationsGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationList.json - // this example is just showing the usage of "ConnectivityConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationGet.json + // this example is just showing the usage of "ConnectivityConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -203,17 +191,23 @@ public async Task GetAll_ConnectivityConfigurationsList() // get the collection of this ConnectivityConfigurationResource ConnectivityConfigurationCollection collection = networkManager.GetConnectivityConfigurations(); - // invoke the operation and iterate over the result - await foreach (ConnectivityConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string configurationName = "myTestConnectivityConfig"; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + ConnectivityConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ConnectivityConfigurationData resourceData = item.Data; + ConnectivityConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectivityConfigurationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectivityConfigurationResource.cs index 3f05ade434199..67bd9df015fc5 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectivityConfigurationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ConnectivityConfigurationResource.cs @@ -49,10 +49,10 @@ public async Task Get_ConnectivityConfigurationsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConnectivityConfigurationsPut() + public async Task Delete_ConnectivityConfigurationsDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationPut.json - // this example is just showing the usage of "ConnectivityConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationDelete.json + // this example is just showing the usage of "ConnectivityConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,45 +69,18 @@ public async Task Update_ConnectivityConfigurationsPut() ConnectivityConfigurationResource connectivityConfiguration = client.GetConnectivityConfigurationResource(connectivityConfigurationResourceId); // invoke the operation - ConnectivityConfigurationData data = new ConnectivityConfigurationData() - { - Description = "Sample Configuration", - ConnectivityTopology = ConnectivityTopology.HubAndSpoke, - Hubs = -{ -new ConnectivityHub() -{ -ResourceId = new ResourceIdentifier("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myTestConnectivityConfig"), -ResourceType = new ResourceType("Microsoft.Network/virtualNetworks"), -} -}, - IsGlobal = GlobalMeshSupportFlag.True, - AppliesToGroups = -{ -new ConnectivityGroupItem("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/group1",GroupConnectivity.None) -{ -UseHubGateway = HubGatewayUsageFlag.True, -IsGlobal = GlobalMeshSupportFlag.False, -} -}, - DeleteExistingPeering = DeleteExistingPeering.True, - }; - ArmOperation lro = await connectivityConfiguration.UpdateAsync(WaitUntil.Completed, data); - ConnectivityConfigurationResource result = lro.Value; + bool? force = false; + await connectivityConfiguration.DeleteAsync(WaitUntil.Completed, force: force); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ConnectivityConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ConnectivityConfigurationsDelete() + public async Task Update_ConnectivityConfigurationsPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationDelete.json - // this example is just showing the usage of "ConnectivityConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectivityConfigurationPut.json + // this example is just showing the usage of "ConnectivityConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -124,10 +97,31 @@ public async Task Delete_ConnectivityConfigurationsDelete() ConnectivityConfigurationResource connectivityConfiguration = client.GetConnectivityConfigurationResource(connectivityConfigurationResourceId); // invoke the operation - bool? force = false; - await connectivityConfiguration.DeleteAsync(WaitUntil.Completed, force: force); + ConnectivityConfigurationData data = new ConnectivityConfigurationData + { + Description = "Sample Configuration", + ConnectivityTopology = ConnectivityTopology.HubAndSpoke, + Hubs = {new ConnectivityHub +{ +ResourceId = new ResourceIdentifier("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/virtualNetworks/myTestConnectivityConfig"), +ResourceType = new ResourceType("Microsoft.Network/virtualNetworks"), +}}, + IsGlobal = GlobalMeshSupportFlag.True, + AppliesToGroups = {new ConnectivityGroupItem("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/group1", GroupConnectivity.None) +{ +UseHubGateway = HubGatewayUsageFlag.True, +IsGlobal = GlobalMeshSupportFlag.False, +}}, + DeleteExistingPeering = DeleteExistingPeering.True, + }; + ArmOperation lro = await connectivityConfiguration.UpdateAsync(WaitUntil.Completed, data); + ConnectivityConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ConnectivityConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CustomIPPrefixCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CustomIPPrefixCollection.cs index 7df4dcbeac707..51d337731cbbe 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CustomIPPrefixCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CustomIPPrefixCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_CustomIPPrefixCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCustomIPPrefix() + public async Task CreateOrUpdate_CreateCustomIPPrefixAllocationMethod() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixGet.json - // this example is just showing the usage of "CustomIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixCreateCustomizedValues.json + // this example is just showing the usage of "CustomIPPrefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,13 @@ public async Task Get_GetCustomIPPrefix() // invoke the operation string customIPPrefixName = "test-customipprefix"; - CustomIPPrefixResource result = await collection.GetAsync(customIPPrefixName); + CustomIPPrefixData data = new CustomIPPrefixData + { + Cidr = "0.0.0.0/24", + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, customIPPrefixName, data); + CustomIPPrefixResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +57,7 @@ public async Task Get_GetCustomIPPrefix() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetCustomIPPrefix() + public async Task Get_GetCustomIPPrefix() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixGet.json // this example is just showing the usage of "CustomIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +79,21 @@ public async Task Exists_GetCustomIPPrefix() // invoke the operation string customIPPrefixName = "test-customipprefix"; - bool result = await collection.ExistsAsync(customIPPrefixName); + CustomIPPrefixResource result = await collection.GetAsync(customIPPrefixName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomIPPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetCustomIPPrefix() + public async Task GetAll_ListResourceGroupCustomIPPrefixes() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixGet.json - // this example is just showing the usage of "CustomIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixList.json + // this example is just showing the usage of "CustomIPPrefixes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +110,25 @@ public async Task GetIfExists_GetCustomIPPrefix() // get the collection of this CustomIPPrefixResource CustomIPPrefixCollection collection = resourceGroupResource.GetCustomIPPrefixes(); - // invoke the operation - string customIPPrefixName = "test-customipprefix"; - NullableResponse response = await collection.GetIfExistsAsync(customIPPrefixName); - CustomIPPrefixResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (CustomIPPrefixResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CustomIPPrefixData resourceData = result.Data; + CustomIPPrefixData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateCustomIPPrefixAllocationMethod() + public async Task Exists_GetCustomIPPrefix() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixCreateCustomizedValues.json - // this example is just showing the usage of "CustomIPPrefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixGet.json + // this example is just showing the usage of "CustomIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,27 +147,17 @@ public async Task CreateOrUpdate_CreateCustomIPPrefixAllocationMethod() // invoke the operation string customIPPrefixName = "test-customipprefix"; - CustomIPPrefixData data = new CustomIPPrefixData() - { - Cidr = "0.0.0.0/24", - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, customIPPrefixName, data); - CustomIPPrefixResource result = lro.Value; + bool result = await collection.ExistsAsync(customIPPrefixName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomIPPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListResourceGroupCustomIPPrefixes() + public async Task GetIfExists_GetCustomIPPrefix() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixList.json - // this example is just showing the usage of "CustomIPPrefixes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixGet.json + // this example is just showing the usage of "CustomIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_ListResourceGroupCustomIPPrefixes() // get the collection of this CustomIPPrefixResource CustomIPPrefixCollection collection = resourceGroupResource.GetCustomIPPrefixes(); - // invoke the operation and iterate over the result - await foreach (CustomIPPrefixResource item in collection.GetAllAsync()) + // invoke the operation + string customIPPrefixName = "test-customipprefix"; + NullableResponse response = await collection.GetIfExistsAsync(customIPPrefixName); + CustomIPPrefixResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - CustomIPPrefixData resourceData = item.Data; + CustomIPPrefixData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CustomIPPrefixResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CustomIPPrefixResource.cs index 5266573cdfdc9..ba390dd8e83c7 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CustomIPPrefixResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_CustomIPPrefixResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_CustomIPPrefixResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteCustomIPPrefix() + public async Task Get_GetCustomIPPrefix() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixDelete.json - // this example is just showing the usage of "CustomIPPrefixes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixGet.json + // this example is just showing the usage of "CustomIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteCustomIPPrefix() CustomIPPrefixResource customIPPrefix = client.GetCustomIPPrefixResource(customIPPrefixResourceId); // invoke the operation - await customIPPrefix.DeleteAsync(WaitUntil.Completed); + CustomIPPrefixResource result = await customIPPrefix.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomIPPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetCustomIPPrefix() + public async Task Delete_DeleteCustomIPPrefix() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixGet.json - // this example is just showing the usage of "CustomIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixDelete.json + // this example is just showing the usage of "CustomIPPrefixes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetCustomIPPrefix() CustomIPPrefixResource customIPPrefix = client.GetCustomIPPrefixResource(customIPPrefixResourceId); // invoke the operation - CustomIPPrefixResource result = await customIPPrefix.GetAsync(); + await customIPPrefix.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomIPPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdatePublicIPAddressTags() CustomIPPrefixResource customIPPrefix = client.GetCustomIPPrefixResource(customIPPrefixResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; CustomIPPrefixResource result = await customIPPrefix.UpdateAsync(networkTagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdatePublicIPAddressTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetCustomIPPrefixes_ListAllCustomIPPrefixes() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixListAll.json - // this example is just showing the usage of "CustomIPPrefixes_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (CustomIPPrefixResource item in subscriptionResource.GetCustomIPPrefixesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - CustomIPPrefixData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosCustomPolicyCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosCustomPolicyCollection.cs index b289cd9aed6aa..35f6c7adce210 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosCustomPolicyCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosCustomPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DdosCustomPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDDoSCustomPolicy() + public async Task CreateOrUpdate_CreateDDoSCustomPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosCustomPolicyGet.json - // this example is just showing the usage of "DdosCustomPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosCustomPolicyCreate.json + // this example is just showing the usage of "DdosCustomPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,12 @@ public async Task Get_GetDDoSCustomPolicy() // invoke the operation string ddosCustomPolicyName = "test-ddos-custom-policy"; - DdosCustomPolicyResource result = await collection.GetAsync(ddosCustomPolicyName); + DdosCustomPolicyData data = new DdosCustomPolicyData + { + Location = new AzureLocation("centraluseuap"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ddosCustomPolicyName, data); + DdosCustomPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +56,7 @@ public async Task Get_GetDDoSCustomPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDDoSCustomPolicy() + public async Task Get_GetDDoSCustomPolicy() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosCustomPolicyGet.json // this example is just showing the usage of "DdosCustomPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,14 +78,18 @@ public async Task Exists_GetDDoSCustomPolicy() // invoke the operation string ddosCustomPolicyName = "test-ddos-custom-policy"; - bool result = await collection.ExistsAsync(ddosCustomPolicyName); + DdosCustomPolicyResource result = await collection.GetAsync(ddosCustomPolicyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DdosCustomPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDDoSCustomPolicy() + public async Task Exists_GetDDoSCustomPolicy() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosCustomPolicyGet.json // this example is just showing the usage of "DdosCustomPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -102,29 +111,17 @@ public async Task GetIfExists_GetDDoSCustomPolicy() // invoke the operation string ddosCustomPolicyName = "test-ddos-custom-policy"; - NullableResponse response = await collection.GetIfExistsAsync(ddosCustomPolicyName); - DdosCustomPolicyResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ddosCustomPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DdosCustomPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateDDoSCustomPolicy() + public async Task GetIfExists_GetDDoSCustomPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosCustomPolicyCreate.json - // this example is just showing the usage of "DdosCustomPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosCustomPolicyGet.json + // this example is just showing the usage of "DdosCustomPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,18 +140,21 @@ public async Task CreateOrUpdate_CreateDDoSCustomPolicy() // invoke the operation string ddosCustomPolicyName = "test-ddos-custom-policy"; - DdosCustomPolicyData data = new DdosCustomPolicyData() - { - Location = new AzureLocation("centraluseuap"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ddosCustomPolicyName, data); - DdosCustomPolicyResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ddosCustomPolicyName); + DdosCustomPolicyResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DdosCustomPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DdosCustomPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosCustomPolicyResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosCustomPolicyResource.cs index 9d67433add852..f5bf15b14909e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosCustomPolicyResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosCustomPolicyResource.cs @@ -18,10 +18,10 @@ public partial class Sample_DdosCustomPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDDoSCustomPolicy() + public async Task Get_GetDDoSCustomPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosCustomPolicyDelete.json - // this example is just showing the usage of "DdosCustomPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosCustomPolicyGet.json + // this example is just showing the usage of "DdosCustomPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task Delete_DeleteDDoSCustomPolicy() DdosCustomPolicyResource ddosCustomPolicy = client.GetDdosCustomPolicyResource(ddosCustomPolicyResourceId); // invoke the operation - await ddosCustomPolicy.DeleteAsync(WaitUntil.Completed); + DdosCustomPolicyResource result = await ddosCustomPolicy.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DdosCustomPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDDoSCustomPolicy() + public async Task Delete_DeleteDDoSCustomPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosCustomPolicyGet.json - // this example is just showing the usage of "DdosCustomPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosCustomPolicyDelete.json + // this example is just showing the usage of "DdosCustomPolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,13 +67,9 @@ public async Task Get_GetDDoSCustomPolicy() DdosCustomPolicyResource ddosCustomPolicy = client.GetDdosCustomPolicyResource(ddosCustomPolicyResourceId); // invoke the operation - DdosCustomPolicyResource result = await ddosCustomPolicy.GetAsync(); + await ddosCustomPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DdosCustomPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -93,12 +93,12 @@ public async Task Update_DDoSCustomPolicyUpdateTags() DdosCustomPolicyResource ddosCustomPolicy = client.GetDdosCustomPolicyResource(ddosCustomPolicyResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; DdosCustomPolicyResource result = await ddosCustomPolicy.UpdateAsync(networkTagsObject); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosProtectionPlanCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosProtectionPlanCollection.cs index fd7ad1a413190..3abf9e92b0572 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosProtectionPlanCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosProtectionPlanCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_DdosProtectionPlanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDDoSProtectionPlan() + public async Task CreateOrUpdate_CreateDDoSProtectionPlan() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanGet.json - // this example is just showing the usage of "DdosProtectionPlans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanCreate.json + // this example is just showing the usage of "DdosProtectionPlans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,9 @@ public async Task Get_GetDDoSProtectionPlan() // invoke the operation string ddosProtectionPlanName = "test-plan"; - DdosProtectionPlanResource result = await collection.GetAsync(ddosProtectionPlanName); + DdosProtectionPlanData data = new DdosProtectionPlanData(new AzureLocation("westus")); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ddosProtectionPlanName, data); + DdosProtectionPlanResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_GetDDoSProtectionPlan() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDDoSProtectionPlan() + public async Task Get_GetDDoSProtectionPlan() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanGet.json // this example is just showing the usage of "DdosProtectionPlans_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +75,21 @@ public async Task Exists_GetDDoSProtectionPlan() // invoke the operation string ddosProtectionPlanName = "test-plan"; - bool result = await collection.ExistsAsync(ddosProtectionPlanName); + DdosProtectionPlanResource result = await collection.GetAsync(ddosProtectionPlanName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DdosProtectionPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDDoSProtectionPlan() + public async Task GetAll_ListDDoSProtectionPlansInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanGet.json - // this example is just showing the usage of "DdosProtectionPlans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanList.json + // this example is just showing the usage of "DdosProtectionPlans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +106,25 @@ public async Task GetIfExists_GetDDoSProtectionPlan() // get the collection of this DdosProtectionPlanResource DdosProtectionPlanCollection collection = resourceGroupResource.GetDdosProtectionPlans(); - // invoke the operation - string ddosProtectionPlanName = "test-plan"; - NullableResponse response = await collection.GetIfExistsAsync(ddosProtectionPlanName); - DdosProtectionPlanResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (DdosProtectionPlanResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DdosProtectionPlanData resourceData = result.Data; + DdosProtectionPlanData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateDDoSProtectionPlan() + public async Task Exists_GetDDoSProtectionPlan() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanCreate.json - // this example is just showing the usage of "DdosProtectionPlans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanGet.json + // this example is just showing the usage of "DdosProtectionPlans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,23 +143,17 @@ public async Task CreateOrUpdate_CreateDDoSProtectionPlan() // invoke the operation string ddosProtectionPlanName = "test-plan"; - DdosProtectionPlanData data = new DdosProtectionPlanData(new AzureLocation("westus")); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ddosProtectionPlanName, data); - DdosProtectionPlanResource result = lro.Value; + bool result = await collection.ExistsAsync(ddosProtectionPlanName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DdosProtectionPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListDDoSProtectionPlansInResourceGroup() + public async Task GetIfExists_GetDDoSProtectionPlan() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanList.json - // this example is just showing the usage of "DdosProtectionPlans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanGet.json + // this example is just showing the usage of "DdosProtectionPlans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -176,17 +170,23 @@ public async Task GetAll_ListDDoSProtectionPlansInResourceGroup() // get the collection of this DdosProtectionPlanResource DdosProtectionPlanCollection collection = resourceGroupResource.GetDdosProtectionPlans(); - // invoke the operation and iterate over the result - await foreach (DdosProtectionPlanResource item in collection.GetAllAsync()) + // invoke the operation + string ddosProtectionPlanName = "test-plan"; + NullableResponse response = await collection.GetIfExistsAsync(ddosProtectionPlanName); + DdosProtectionPlanResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DdosProtectionPlanData resourceData = item.Data; + DdosProtectionPlanData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosProtectionPlanResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosProtectionPlanResource.cs index cabe3afc6efa6..95720cc76ddae 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosProtectionPlanResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DdosProtectionPlanResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_DdosProtectionPlanResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteDDoSProtectionPlan() + public async Task Get_GetDDoSProtectionPlan() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanDelete.json - // this example is just showing the usage of "DdosProtectionPlans_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanGet.json + // this example is just showing the usage of "DdosProtectionPlans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteDDoSProtectionPlan() DdosProtectionPlanResource ddosProtectionPlan = client.GetDdosProtectionPlanResource(ddosProtectionPlanResourceId); // invoke the operation - await ddosProtectionPlan.DeleteAsync(WaitUntil.Completed); + DdosProtectionPlanResource result = await ddosProtectionPlan.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DdosProtectionPlanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDDoSProtectionPlan() + public async Task Delete_DeleteDDoSProtectionPlan() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanGet.json - // this example is just showing the usage of "DdosProtectionPlans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanDelete.json + // this example is just showing the usage of "DdosProtectionPlans_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetDDoSProtectionPlan() DdosProtectionPlanResource ddosProtectionPlan = client.GetDdosProtectionPlanResource(ddosProtectionPlanResourceId); // invoke the operation - DdosProtectionPlanResource result = await ddosProtectionPlan.GetAsync(); + await ddosProtectionPlan.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DdosProtectionPlanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_DDoSProtectionPlanUpdateTags() DdosProtectionPlanResource ddosProtectionPlan = client.GetDdosProtectionPlanResource(ddosProtectionPlanResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; DdosProtectionPlanResource result = await ddosProtectionPlan.UpdateAsync(networkTagsObject); @@ -110,36 +109,5 @@ public async Task Update_DDoSProtectionPlanUpdateTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDdosProtectionPlans_ListAllDDoSProtectionPlans() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanListAll.json - // this example is just showing the usage of "DdosProtectionPlans_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DdosProtectionPlanResource item in subscriptionResource.GetDdosProtectionPlansAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DdosProtectionPlanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DefaultSecurityRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DefaultSecurityRuleCollection.cs index 7d7f35c58def3..9066f326579a1 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DefaultSecurityRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DefaultSecurityRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_DefaultSecurityRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_DefaultSecurityRuleList() + public async Task Get_DefaultSecurityRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DefaultSecurityRuleList.json - // this example is just showing the usage of "DefaultSecurityRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DefaultSecurityRuleGet.json + // this example is just showing the usage of "DefaultSecurityRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_DefaultSecurityRuleList() // get the collection of this DefaultSecurityRuleResource DefaultSecurityRuleCollection collection = networkSecurityGroup.GetDefaultSecurityRules(); - // invoke the operation and iterate over the result - await foreach (DefaultSecurityRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string defaultSecurityRuleName = "AllowVnetInBound"; + DefaultSecurityRuleResource result = await collection.GetAsync(defaultSecurityRuleName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_DefaultSecurityRuleGet() + public async Task GetAll_DefaultSecurityRuleList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DefaultSecurityRuleGet.json - // this example is just showing the usage of "DefaultSecurityRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DefaultSecurityRuleList.json + // this example is just showing the usage of "DefaultSecurityRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_DefaultSecurityRuleGet() // get the collection of this DefaultSecurityRuleResource DefaultSecurityRuleCollection collection = networkSecurityGroup.GetDefaultSecurityRules(); - // invoke the operation - string defaultSecurityRuleName = "AllowVnetInBound"; - DefaultSecurityRuleResource result = await collection.GetAsync(defaultSecurityRuleName); + // invoke the operation and iterate over the result + await foreach (DefaultSecurityRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DscpConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DscpConfigurationCollection.cs index 522e7ec42e547..d3852ff16c64f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DscpConfigurationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DscpConfigurationCollection.cs @@ -41,94 +41,61 @@ public async Task CreateOrUpdate_CreateDSCPConfiguration() // invoke the operation string dscpConfigurationName = "mydscpconfig"; - DscpConfigurationData data = new DscpConfigurationData() + DscpConfigurationData data = new DscpConfigurationData { - QosDefinitionCollection = + QosDefinitionCollection = {new DscpQosDefinition { -new DscpQosDefinition() -{ -Markings = -{ -1 -}, -SourceIPRanges = -{ -new QosIPRange() +Markings = {1}, +SourceIPRanges = {new QosIPRange { StartIP = "127.0.0.1", EndIP = "127.0.0.2", -} -}, -DestinationIPRanges = -{ -new QosIPRange() +}}, +DestinationIPRanges = {new QosIPRange { StartIP = "127.0.10.1", EndIP = "127.0.10.2", -} -}, -SourcePortRanges = -{ -new QosPortRange() +}}, +SourcePortRanges = {new QosPortRange { Start = 10, End = 11, -},new QosPortRange() +}, new QosPortRange { Start = 20, End = 21, -} -}, -DestinationPortRanges = -{ -new QosPortRange() +}}, +DestinationPortRanges = {new QosPortRange { Start = 15, End = 15, -} -}, +}}, Protocol = ProtocolType.Tcp, -},new DscpQosDefinition() -{ -Markings = +}, new DscpQosDefinition { -2 -}, -SourceIPRanges = -{ -new QosIPRange() +Markings = {2}, +SourceIPRanges = {new QosIPRange { StartIP = "12.0.0.1", EndIP = "12.0.0.2", -} -}, -DestinationIPRanges = -{ -new QosIPRange() +}}, +DestinationIPRanges = {new QosIPRange { StartIP = "12.0.10.1", EndIP = "12.0.10.2", -} -}, -SourcePortRanges = -{ -new QosPortRange() +}}, +SourcePortRanges = {new QosPortRange { Start = 11, End = 12, -} -}, -DestinationPortRanges = -{ -new QosPortRange() +}}, +DestinationPortRanges = {new QosPortRange { Start = 51, End = 52, -} -}, +}}, Protocol = ProtocolType.Udp, -} -}, +}}, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, dscpConfigurationName, data); @@ -176,10 +143,10 @@ public async Task Get_GetDscpConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetDscpConfiguration() + public async Task GetAll_GetDscpConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationGet.json - // this example is just showing the usage of "DscpConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationList.json + // this example is just showing the usage of "DscpConfiguration_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,16 +163,22 @@ public async Task Exists_GetDscpConfiguration() // get the collection of this DscpConfigurationResource DscpConfigurationCollection collection = resourceGroupResource.GetDscpConfigurations(); - // invoke the operation - string dscpConfigurationName = "mydscpConfig"; - bool result = await collection.ExistsAsync(dscpConfigurationName); + // invoke the operation and iterate over the result + await foreach (DscpConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscpConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetDscpConfiguration() + public async Task Exists_GetDscpConfiguration() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationGet.json // this example is just showing the usage of "DscpConfiguration_Get" operation, for the dependent resources, they will have to be created separately. @@ -227,29 +200,17 @@ public async Task GetIfExists_GetDscpConfiguration() // invoke the operation string dscpConfigurationName = "mydscpConfig"; - NullableResponse response = await collection.GetIfExistsAsync(dscpConfigurationName); - DscpConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(dscpConfigurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscpConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_GetDscpConfiguration() + public async Task GetIfExists_GetDscpConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationList.json - // this example is just showing the usage of "DscpConfiguration_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationGet.json + // this example is just showing the usage of "DscpConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -266,17 +227,23 @@ public async Task GetAll_GetDscpConfiguration() // get the collection of this DscpConfigurationResource DscpConfigurationCollection collection = resourceGroupResource.GetDscpConfigurations(); - // invoke the operation and iterate over the result - await foreach (DscpConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string dscpConfigurationName = "mydscpConfig"; + NullableResponse response = await collection.GetIfExistsAsync(dscpConfigurationName); + DscpConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - DscpConfigurationData resourceData = item.Data; + DscpConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DscpConfigurationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DscpConfigurationResource.cs index 1eaaaf6110ee6..ec9f62a4b8366 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DscpConfigurationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_DscpConfigurationResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_DscpConfigurationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateDSCPConfiguration() + public async Task Get_GetDscpConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationCreate.json - // this example is just showing the usage of "DscpConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationGet.json + // this example is just showing the usage of "DscpConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,103 +32,12 @@ public async Task Update_CreateDSCPConfiguration() // for more information of creating DscpConfigurationResource, please refer to the document of DscpConfigurationResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string dscpConfigurationName = "mydscpconfig"; + string dscpConfigurationName = "mydscpConfig"; ResourceIdentifier dscpConfigurationResourceId = DscpConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, dscpConfigurationName); DscpConfigurationResource dscpConfiguration = client.GetDscpConfigurationResource(dscpConfigurationResourceId); // invoke the operation - DscpConfigurationData data = new DscpConfigurationData() - { - QosDefinitionCollection = -{ -new DscpQosDefinition() -{ -Markings = -{ -1 -}, -SourceIPRanges = -{ -new QosIPRange() -{ -StartIP = "127.0.0.1", -EndIP = "127.0.0.2", -} -}, -DestinationIPRanges = -{ -new QosIPRange() -{ -StartIP = "127.0.10.1", -EndIP = "127.0.10.2", -} -}, -SourcePortRanges = -{ -new QosPortRange() -{ -Start = 10, -End = 11, -},new QosPortRange() -{ -Start = 20, -End = 21, -} -}, -DestinationPortRanges = -{ -new QosPortRange() -{ -Start = 15, -End = 15, -} -}, -Protocol = ProtocolType.Tcp, -},new DscpQosDefinition() -{ -Markings = -{ -2 -}, -SourceIPRanges = -{ -new QosIPRange() -{ -StartIP = "12.0.0.1", -EndIP = "12.0.0.2", -} -}, -DestinationIPRanges = -{ -new QosIPRange() -{ -StartIP = "12.0.10.1", -EndIP = "12.0.10.2", -} -}, -SourcePortRanges = -{ -new QosPortRange() -{ -Start = 11, -End = 12, -} -}, -DestinationPortRanges = -{ -new QosPortRange() -{ -Start = 51, -End = 52, -} -}, -Protocol = ProtocolType.Udp, -} -}, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await dscpConfiguration.UpdateAsync(WaitUntil.Completed, data); - DscpConfigurationResource result = lro.Value; + DscpConfigurationResource result = await dscpConfiguration.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -166,10 +74,10 @@ public async Task Delete_DeleteDSCPConfiguration() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetDscpConfiguration() + public async Task Update_CreateDSCPConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationGet.json - // this example is just showing the usage of "DscpConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationCreate.json + // this example is just showing the usage of "DscpConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,12 +88,70 @@ public async Task Get_GetDscpConfiguration() // for more information of creating DscpConfigurationResource, please refer to the document of DscpConfigurationResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string dscpConfigurationName = "mydscpConfig"; + string dscpConfigurationName = "mydscpconfig"; ResourceIdentifier dscpConfigurationResourceId = DscpConfigurationResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, dscpConfigurationName); DscpConfigurationResource dscpConfiguration = client.GetDscpConfigurationResource(dscpConfigurationResourceId); // invoke the operation - DscpConfigurationResource result = await dscpConfiguration.GetAsync(); + DscpConfigurationData data = new DscpConfigurationData + { + QosDefinitionCollection = {new DscpQosDefinition +{ +Markings = {1}, +SourceIPRanges = {new QosIPRange +{ +StartIP = "127.0.0.1", +EndIP = "127.0.0.2", +}}, +DestinationIPRanges = {new QosIPRange +{ +StartIP = "127.0.10.1", +EndIP = "127.0.10.2", +}}, +SourcePortRanges = {new QosPortRange +{ +Start = 10, +End = 11, +}, new QosPortRange +{ +Start = 20, +End = 21, +}}, +DestinationPortRanges = {new QosPortRange +{ +Start = 15, +End = 15, +}}, +Protocol = ProtocolType.Tcp, +}, new DscpQosDefinition +{ +Markings = {2}, +SourceIPRanges = {new QosIPRange +{ +StartIP = "12.0.0.1", +EndIP = "12.0.0.2", +}}, +DestinationIPRanges = {new QosIPRange +{ +StartIP = "12.0.10.1", +EndIP = "12.0.10.2", +}}, +SourcePortRanges = {new QosPortRange +{ +Start = 11, +End = 12, +}}, +DestinationPortRanges = {new QosPortRange +{ +Start = 51, +End = 52, +}}, +Protocol = ProtocolType.Udp, +}}, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await dscpConfiguration.UpdateAsync(WaitUntil.Completed, data); + DscpConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -193,36 +159,5 @@ public async Task Get_GetDscpConfiguration() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetDscpConfigurations_ListAllNetworkInterfaces() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationListAll.json - // this example is just showing the usage of "DscpConfiguration_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (DscpConfigurationResource item in subscriptionResource.GetDscpConfigurationsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - DscpConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitAuthorizationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitAuthorizationCollection.cs index 39a5ad904c81f..428e07cbb3528 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitAuthorizationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitAuthorizationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ExpressRouteCircuitAuthorizationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExpressRouteCircuitAuthorization() + public async Task CreateOrUpdate_CreateExpressRouteCircuitAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationGet.json - // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationCreate.json + // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,10 @@ public async Task Get_GetExpressRouteCircuitAuthorization() ExpressRouteCircuitAuthorizationCollection collection = expressRouteCircuit.GetExpressRouteCircuitAuthorizations(); // invoke the operation - string authorizationName = "authorizationName"; - ExpressRouteCircuitAuthorizationResource result = await collection.GetAsync(authorizationName); + string authorizationName = "authorizatinName"; + ExpressRouteCircuitAuthorizationData data = new ExpressRouteCircuitAuthorizationData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationName, data); + ExpressRouteCircuitAuthorizationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_GetExpressRouteCircuitAuthorization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetExpressRouteCircuitAuthorization() + public async Task Get_GetExpressRouteCircuitAuthorization() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationGet.json // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +76,21 @@ public async Task Exists_GetExpressRouteCircuitAuthorization() // invoke the operation string authorizationName = "authorizationName"; - bool result = await collection.ExistsAsync(authorizationName); + ExpressRouteCircuitAuthorizationResource result = await collection.GetAsync(authorizationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetExpressRouteCircuitAuthorization() + public async Task GetAll_ListExpressRouteCircuitAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationGet.json - // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationList.json + // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +108,25 @@ public async Task GetIfExists_GetExpressRouteCircuitAuthorization() // get the collection of this ExpressRouteCircuitAuthorizationResource ExpressRouteCircuitAuthorizationCollection collection = expressRouteCircuit.GetExpressRouteCircuitAuthorizations(); - // invoke the operation - string authorizationName = "authorizationName"; - NullableResponse response = await collection.GetIfExistsAsync(authorizationName); - ExpressRouteCircuitAuthorizationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ExpressRouteCircuitAuthorizationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRouteCircuitAuthorizationData resourceData = result.Data; + ExpressRouteCircuitAuthorizationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateExpressRouteCircuitAuthorization() + public async Task Exists_GetExpressRouteCircuitAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationCreate.json - // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationGet.json + // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,24 +145,18 @@ public async Task CreateOrUpdate_CreateExpressRouteCircuitAuthorization() ExpressRouteCircuitAuthorizationCollection collection = expressRouteCircuit.GetExpressRouteCircuitAuthorizations(); // invoke the operation - string authorizationName = "authorizatinName"; - ExpressRouteCircuitAuthorizationData data = new ExpressRouteCircuitAuthorizationData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationName, data); - ExpressRouteCircuitAuthorizationResource result = lro.Value; + string authorizationName = "authorizationName"; + bool result = await collection.ExistsAsync(authorizationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitAuthorizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExpressRouteCircuitAuthorization() + public async Task GetIfExists_GetExpressRouteCircuitAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationList.json - // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationGet.json + // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_ListExpressRouteCircuitAuthorization() // get the collection of this ExpressRouteCircuitAuthorizationResource ExpressRouteCircuitAuthorizationCollection collection = expressRouteCircuit.GetExpressRouteCircuitAuthorizations(); - // invoke the operation and iterate over the result - await foreach (ExpressRouteCircuitAuthorizationResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationName = "authorizationName"; + NullableResponse response = await collection.GetIfExistsAsync(authorizationName); + ExpressRouteCircuitAuthorizationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRouteCircuitAuthorizationData resourceData = item.Data; + ExpressRouteCircuitAuthorizationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitAuthorizationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitAuthorizationResource.cs index 8fe457709b1d1..eeac44a4999c6 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitAuthorizationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitAuthorizationResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ExpressRouteCircuitAuthorizationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteExpressRouteCircuitAuthorization() + public async Task Get_GetExpressRouteCircuitAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationDelete.json - // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationGet.json + // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task Delete_DeleteExpressRouteCircuitAuthorization() ExpressRouteCircuitAuthorizationResource expressRouteCircuitAuthorization = client.GetExpressRouteCircuitAuthorizationResource(expressRouteCircuitAuthorizationResourceId); // invoke the operation - await expressRouteCircuitAuthorization.DeleteAsync(WaitUntil.Completed); + ExpressRouteCircuitAuthorizationResource result = await expressRouteCircuitAuthorization.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExpressRouteCircuitAuthorization() + public async Task Delete_DeleteExpressRouteCircuitAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationGet.json - // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitAuthorizationDelete.json + // this example is just showing the usage of "ExpressRouteCircuitAuthorizations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +68,9 @@ public async Task Get_GetExpressRouteCircuitAuthorization() ExpressRouteCircuitAuthorizationResource expressRouteCircuitAuthorization = client.GetExpressRouteCircuitAuthorizationResource(expressRouteCircuitAuthorizationResourceId); // invoke the operation - ExpressRouteCircuitAuthorizationResource result = await expressRouteCircuitAuthorization.GetAsync(); + await expressRouteCircuitAuthorization.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitAuthorizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitCollection.cs index a730743ba87cc..92268fd1a25d8 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ExpressRouteCircuitCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExpressRouteCircuit() + public async Task CreateOrUpdate_CreateExpressRouteCircuit() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitGet.json - // this example is just showing the usage of "ExpressRouteCircuits_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitCreate.json + // this example is just showing the usage of "ExpressRouteCircuits_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,27 @@ public async Task Get_GetExpressRouteCircuit() // invoke the operation string circuitName = "circuitName"; - ExpressRouteCircuitResource result = await collection.GetAsync(circuitName); + ExpressRouteCircuitData data = new ExpressRouteCircuitData + { + Sku = new ExpressRouteCircuitSku + { + Name = "Standard_MeteredData", + Tier = ExpressRouteCircuitSkuTier.Standard, + Family = ExpressRouteCircuitSkuFamily.MeteredData, + }, + AllowClassicOperations = false, + Authorizations = { }, + Peerings = { }, + ServiceProviderProperties = new ExpressRouteCircuitServiceProviderProperties + { + ServiceProviderName = "Equinix", + PeeringLocation = "Silicon Valley", + BandwidthInMbps = 200, + }, + Location = new AzureLocation("Brazil South"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, circuitName, data); + ExpressRouteCircuitResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +72,10 @@ public async Task Get_GetExpressRouteCircuit() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetExpressRouteCircuit() + public async Task CreateOrUpdate_CreateExpressRouteCircuitOnExpressRoutePort() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitGet.json - // this example is just showing the usage of "ExpressRouteCircuits_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitCreateOnExpressRoutePort.json + // this example is just showing the usage of "ExpressRouteCircuits_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,15 +93,34 @@ public async Task Exists_GetExpressRouteCircuit() ExpressRouteCircuitCollection collection = resourceGroupResource.GetExpressRouteCircuits(); // invoke the operation - string circuitName = "circuitName"; - bool result = await collection.ExistsAsync(circuitName); + string circuitName = "expressRouteCircuit1"; + ExpressRouteCircuitData data = new ExpressRouteCircuitData + { + Sku = new ExpressRouteCircuitSku + { + Name = "Premium_MeteredData", + Tier = ExpressRouteCircuitSkuTier.Premium, + Family = ExpressRouteCircuitSkuFamily.MeteredData, + }, + ExpressRoutePortId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRoutePorts/portName"), + BandwidthInGbps = 10, + AuthorizationKey = "b0be57f5-1fba-463b-adec-ffe767354cdd", + EnableDirectPortRateLimit = false, + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, circuitName, data); + ExpressRouteCircuitResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetExpressRouteCircuit() + public async Task Get_GetExpressRouteCircuit() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitGet.json // this example is just showing the usage of "ExpressRouteCircuits_Get" operation, for the dependent resources, they will have to be created separately. @@ -103,29 +142,21 @@ public async Task GetIfExists_GetExpressRouteCircuit() // invoke the operation string circuitName = "circuitName"; - NullableResponse response = await collection.GetIfExistsAsync(circuitName); - ExpressRouteCircuitResource result = response.HasValue ? response.Value : null; + ExpressRouteCircuitResource result = await collection.GetAsync(circuitName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateExpressRouteCircuit() + public async Task GetAll_ListExpressRouteCircuitsInAResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitCreate.json - // this example is just showing the usage of "ExpressRouteCircuits_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitListByResourceGroup.json + // this example is just showing the usage of "ExpressRouteCircuits_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,47 +173,25 @@ public async Task CreateOrUpdate_CreateExpressRouteCircuit() // get the collection of this ExpressRouteCircuitResource ExpressRouteCircuitCollection collection = resourceGroupResource.GetExpressRouteCircuits(); - // invoke the operation - string circuitName = "circuitName"; - ExpressRouteCircuitData data = new ExpressRouteCircuitData() + // invoke the operation and iterate over the result + await foreach (ExpressRouteCircuitResource item in collection.GetAllAsync()) { - Sku = new ExpressRouteCircuitSku() - { - Name = "Standard_MeteredData", - Tier = ExpressRouteCircuitSkuTier.Standard, - Family = ExpressRouteCircuitSkuFamily.MeteredData, - }, - AllowClassicOperations = false, - Authorizations = -{ -}, - Peerings = -{ -}, - ServiceProviderProperties = new ExpressRouteCircuitServiceProviderProperties() - { - ServiceProviderName = "Equinix", - PeeringLocation = "Silicon Valley", - BandwidthInMbps = 200, - }, - Location = new AzureLocation("Brazil South"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, circuitName, data); - ExpressRouteCircuitResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateExpressRouteCircuitOnExpressRoutePort() + public async Task Exists_GetExpressRouteCircuit() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitCreateOnExpressRoutePort.json - // this example is just showing the usage of "ExpressRouteCircuits_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitGet.json + // this example is just showing the usage of "ExpressRouteCircuits_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -200,37 +209,18 @@ public async Task CreateOrUpdate_CreateExpressRouteCircuitOnExpressRoutePort() ExpressRouteCircuitCollection collection = resourceGroupResource.GetExpressRouteCircuits(); // invoke the operation - string circuitName = "expressRouteCircuit1"; - ExpressRouteCircuitData data = new ExpressRouteCircuitData() - { - Sku = new ExpressRouteCircuitSku() - { - Name = "Premium_MeteredData", - Tier = ExpressRouteCircuitSkuTier.Premium, - Family = ExpressRouteCircuitSkuFamily.MeteredData, - }, - ExpressRoutePortId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRoutePorts/portName"), - BandwidthInGbps = 10, - AuthorizationKey = "b0be57f5-1fba-463b-adec-ffe767354cdd", - EnableDirectPortRateLimit = false, - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, circuitName, data); - ExpressRouteCircuitResource result = lro.Value; + string circuitName = "circuitName"; + bool result = await collection.ExistsAsync(circuitName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExpressRouteCircuitsInAResourceGroup() + public async Task GetIfExists_GetExpressRouteCircuit() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitListByResourceGroup.json - // this example is just showing the usage of "ExpressRouteCircuits_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitGet.json + // this example is just showing the usage of "ExpressRouteCircuits_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -247,17 +237,23 @@ public async Task GetAll_ListExpressRouteCircuitsInAResourceGroup() // get the collection of this ExpressRouteCircuitResource ExpressRouteCircuitCollection collection = resourceGroupResource.GetExpressRouteCircuits(); - // invoke the operation and iterate over the result - await foreach (ExpressRouteCircuitResource item in collection.GetAllAsync()) + // invoke the operation + string circuitName = "circuitName"; + NullableResponse response = await collection.GetIfExistsAsync(circuitName); + ExpressRouteCircuitResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRouteCircuitData resourceData = item.Data; + ExpressRouteCircuitData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitConnectionCollection.cs index d639553eee011..47ec0dbff77ab 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ExpressRouteCircuitConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExpressRouteCircuitConnectionGet() + public async Task CreateOrUpdate_ExpressRouteCircuitConnectionCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionGet.json - // this example is just showing the usage of "ExpressRouteCircuitConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionCreate.json + // this example is just showing the usage of "ExpressRouteCircuitConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,19 @@ public async Task Get_ExpressRouteCircuitConnectionGet() // invoke the operation string connectionName = "circuitConnectionUSAUS"; - ExpressRouteCircuitConnectionResource result = await collection.GetAsync(connectionName); + ExpressRouteCircuitConnectionData data = new ExpressRouteCircuitConnectionData + { + ExpressRouteCircuitPeeringId = new ResourceIdentifier("/subscriptions/subid1/resourceGroups/dedharcktinit/providers/Microsoft.Network/expressRouteCircuits/dedharcktlocal/peerings/AzurePrivatePeering"), + PeerExpressRouteCircuitPeeringId = new ResourceIdentifier("/subscriptions/subid2/resourceGroups/dedharcktpeer/providers/Microsoft.Network/expressRouteCircuits/dedharcktremote/peerings/AzurePrivatePeering"), + AddressPrefix = "10.0.0.0/29", + AuthorizationKey = "946a1918-b7a2-4917-b43c-8c4cdaee006a", + IPv6CircuitConnectionConfig = new IPv6CircuitConnectionConfig + { + AddressPrefix = "aa:bb::/125", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionName, data); + ExpressRouteCircuitConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +65,7 @@ public async Task Get_ExpressRouteCircuitConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExpressRouteCircuitConnectionGet() + public async Task Get_ExpressRouteCircuitConnectionGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionGet.json // this example is just showing the usage of "ExpressRouteCircuitConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -77,17 +89,21 @@ public async Task Exists_ExpressRouteCircuitConnectionGet() // invoke the operation string connectionName = "circuitConnectionUSAUS"; - bool result = await collection.ExistsAsync(connectionName); + ExpressRouteCircuitConnectionResource result = await collection.GetAsync(connectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExpressRouteCircuitConnectionGet() + public async Task GetAll_ListExpressRouteCircuitConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionGet.json - // this example is just showing the usage of "ExpressRouteCircuitConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionList.json + // this example is just showing the usage of "ExpressRouteCircuitConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,31 +122,25 @@ public async Task GetIfExists_ExpressRouteCircuitConnectionGet() // get the collection of this ExpressRouteCircuitConnectionResource ExpressRouteCircuitConnectionCollection collection = expressRouteCircuitPeering.GetExpressRouteCircuitConnections(); - // invoke the operation - string connectionName = "circuitConnectionUSAUS"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - ExpressRouteCircuitConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ExpressRouteCircuitConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRouteCircuitConnectionData resourceData = result.Data; + ExpressRouteCircuitConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ExpressRouteCircuitConnectionCreate() + public async Task Exists_ExpressRouteCircuitConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionCreate.json - // this example is just showing the usage of "ExpressRouteCircuitConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionGet.json + // this example is just showing the usage of "ExpressRouteCircuitConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -151,33 +161,17 @@ public async Task CreateOrUpdate_ExpressRouteCircuitConnectionCreate() // invoke the operation string connectionName = "circuitConnectionUSAUS"; - ExpressRouteCircuitConnectionData data = new ExpressRouteCircuitConnectionData() - { - ExpressRouteCircuitPeeringId = new ResourceIdentifier("/subscriptions/subid1/resourceGroups/dedharcktinit/providers/Microsoft.Network/expressRouteCircuits/dedharcktlocal/peerings/AzurePrivatePeering"), - PeerExpressRouteCircuitPeeringId = new ResourceIdentifier("/subscriptions/subid2/resourceGroups/dedharcktpeer/providers/Microsoft.Network/expressRouteCircuits/dedharcktremote/peerings/AzurePrivatePeering"), - AddressPrefix = "10.0.0.0/29", - AuthorizationKey = "946a1918-b7a2-4917-b43c-8c4cdaee006a", - IPv6CircuitConnectionConfig = new IPv6CircuitConnectionConfig() - { - AddressPrefix = "aa:bb::/125", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionName, data); - ExpressRouteCircuitConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(connectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExpressRouteCircuitConnection() + public async Task GetIfExists_ExpressRouteCircuitConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionList.json - // this example is just showing the usage of "ExpressRouteCircuitConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionGet.json + // this example is just showing the usage of "ExpressRouteCircuitConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,17 +190,23 @@ public async Task GetAll_ListExpressRouteCircuitConnection() // get the collection of this ExpressRouteCircuitConnectionResource ExpressRouteCircuitConnectionCollection collection = expressRouteCircuitPeering.GetExpressRouteCircuitConnections(); - // invoke the operation and iterate over the result - await foreach (ExpressRouteCircuitConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string connectionName = "circuitConnectionUSAUS"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + ExpressRouteCircuitConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRouteCircuitConnectionData resourceData = item.Data; + ExpressRouteCircuitConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitConnectionResource.cs index 2cb25a85ee9d5..c6b88a455f633 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitConnectionResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ExpressRouteCircuitConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteExpressRouteCircuit() + public async Task Get_ExpressRouteCircuitConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionDelete.json - // this example is just showing the usage of "ExpressRouteCircuitConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionGet.json + // this example is just showing the usage of "ExpressRouteCircuitConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -30,7 +30,7 @@ public async Task Delete_DeleteExpressRouteCircuit() // this example assumes you already have this ExpressRouteCircuitConnectionResource created on azure // for more information of creating ExpressRouteCircuitConnectionResource, please refer to the document of ExpressRouteCircuitConnectionResource - string subscriptionId = "subid"; + string subscriptionId = "subid1"; string resourceGroupName = "rg1"; string circuitName = "ExpressRouteARMCircuitA"; string peeringName = "AzurePrivatePeering"; @@ -39,17 +39,21 @@ public async Task Delete_DeleteExpressRouteCircuit() ExpressRouteCircuitConnectionResource expressRouteCircuitConnection = client.GetExpressRouteCircuitConnectionResource(expressRouteCircuitConnectionResourceId); // invoke the operation - await expressRouteCircuitConnection.DeleteAsync(WaitUntil.Completed); + ExpressRouteCircuitConnectionResource result = await expressRouteCircuitConnection.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExpressRouteCircuitConnectionGet() + public async Task Delete_DeleteExpressRouteCircuit() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionGet.json - // this example is just showing the usage of "ExpressRouteCircuitConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitConnectionDelete.json + // this example is just showing the usage of "ExpressRouteCircuitConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -58,7 +62,7 @@ public async Task Get_ExpressRouteCircuitConnectionGet() // this example assumes you already have this ExpressRouteCircuitConnectionResource created on azure // for more information of creating ExpressRouteCircuitConnectionResource, please refer to the document of ExpressRouteCircuitConnectionResource - string subscriptionId = "subid1"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; string circuitName = "ExpressRouteARMCircuitA"; string peeringName = "AzurePrivatePeering"; @@ -67,13 +71,9 @@ public async Task Get_ExpressRouteCircuitConnectionGet() ExpressRouteCircuitConnectionResource expressRouteCircuitConnection = client.GetExpressRouteCircuitConnectionResource(expressRouteCircuitConnectionResourceId); // invoke the operation - ExpressRouteCircuitConnectionResource result = await expressRouteCircuitConnection.GetAsync(); + await expressRouteCircuitConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,13 +99,13 @@ public async Task Update_ExpressRouteCircuitConnectionCreate() ExpressRouteCircuitConnectionResource expressRouteCircuitConnection = client.GetExpressRouteCircuitConnectionResource(expressRouteCircuitConnectionResourceId); // invoke the operation - ExpressRouteCircuitConnectionData data = new ExpressRouteCircuitConnectionData() + ExpressRouteCircuitConnectionData data = new ExpressRouteCircuitConnectionData { ExpressRouteCircuitPeeringId = new ResourceIdentifier("/subscriptions/subid1/resourceGroups/dedharcktinit/providers/Microsoft.Network/expressRouteCircuits/dedharcktlocal/peerings/AzurePrivatePeering"), PeerExpressRouteCircuitPeeringId = new ResourceIdentifier("/subscriptions/subid2/resourceGroups/dedharcktpeer/providers/Microsoft.Network/expressRouteCircuits/dedharcktremote/peerings/AzurePrivatePeering"), AddressPrefix = "10.0.0.0/29", AuthorizationKey = "946a1918-b7a2-4917-b43c-8c4cdaee006a", - IPv6CircuitConnectionConfig = new IPv6CircuitConnectionConfig() + IPv6CircuitConnectionConfig = new IPv6CircuitConnectionConfig { AddressPrefix = "aa:bb::/125", }, diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitPeeringCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitPeeringCollection.cs index 4194e68b3f0a8..d6c473ac6e4a5 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitPeeringCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitPeeringCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ExpressRouteCircuitPeeringCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExpressRouteCircuitPeering() + public async Task CreateOrUpdate_CreateExpressRouteCircuitPeerings() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringGet.json - // this example is just showing the usage of "ExpressRouteCircuitPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringCreate.json + // this example is just showing the usage of "ExpressRouteCircuitPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,16 @@ public async Task Get_GetExpressRouteCircuitPeering() ExpressRouteCircuitPeeringCollection collection = expressRouteCircuit.GetExpressRouteCircuitPeerings(); // invoke the operation - string peeringName = "MicrosoftPeering"; - ExpressRouteCircuitPeeringResource result = await collection.GetAsync(peeringName); + string peeringName = "AzurePrivatePeering"; + ExpressRouteCircuitPeeringData data = new ExpressRouteCircuitPeeringData + { + PeerASN = 200L, + PrimaryPeerAddressPrefix = "192.168.16.252/30", + SecondaryPeerAddressPrefix = "192.168.18.252/30", + VlanId = 200, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peeringName, data); + ExpressRouteCircuitPeeringResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +59,7 @@ public async Task Get_GetExpressRouteCircuitPeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetExpressRouteCircuitPeering() + public async Task Get_GetExpressRouteCircuitPeering() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringGet.json // this example is just showing the usage of "ExpressRouteCircuitPeerings_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +82,21 @@ public async Task Exists_GetExpressRouteCircuitPeering() // invoke the operation string peeringName = "MicrosoftPeering"; - bool result = await collection.ExistsAsync(peeringName); + ExpressRouteCircuitPeeringResource result = await collection.GetAsync(peeringName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetExpressRouteCircuitPeering() + public async Task GetAll_ListExpressRouteCircuitPeerings() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringGet.json - // this example is just showing the usage of "ExpressRouteCircuitPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringList.json + // this example is just showing the usage of "ExpressRouteCircuitPeerings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +114,25 @@ public async Task GetIfExists_GetExpressRouteCircuitPeering() // get the collection of this ExpressRouteCircuitPeeringResource ExpressRouteCircuitPeeringCollection collection = expressRouteCircuit.GetExpressRouteCircuitPeerings(); - // invoke the operation - string peeringName = "MicrosoftPeering"; - NullableResponse response = await collection.GetIfExistsAsync(peeringName); - ExpressRouteCircuitPeeringResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ExpressRouteCircuitPeeringResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRouteCircuitPeeringData resourceData = result.Data; + ExpressRouteCircuitPeeringData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateExpressRouteCircuitPeerings() + public async Task Exists_GetExpressRouteCircuitPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringCreate.json - // this example is just showing the usage of "ExpressRouteCircuitPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringGet.json + // this example is just showing the usage of "ExpressRouteCircuitPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,30 +151,18 @@ public async Task CreateOrUpdate_CreateExpressRouteCircuitPeerings() ExpressRouteCircuitPeeringCollection collection = expressRouteCircuit.GetExpressRouteCircuitPeerings(); // invoke the operation - string peeringName = "AzurePrivatePeering"; - ExpressRouteCircuitPeeringData data = new ExpressRouteCircuitPeeringData() - { - PeerASN = 200L, - PrimaryPeerAddressPrefix = "192.168.16.252/30", - SecondaryPeerAddressPrefix = "192.168.18.252/30", - VlanId = 200, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peeringName, data); - ExpressRouteCircuitPeeringResource result = lro.Value; + string peeringName = "MicrosoftPeering"; + bool result = await collection.ExistsAsync(peeringName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExpressRouteCircuitPeerings() + public async Task GetIfExists_GetExpressRouteCircuitPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringList.json - // this example is just showing the usage of "ExpressRouteCircuitPeerings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringGet.json + // this example is just showing the usage of "ExpressRouteCircuitPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_ListExpressRouteCircuitPeerings() // get the collection of this ExpressRouteCircuitPeeringResource ExpressRouteCircuitPeeringCollection collection = expressRouteCircuit.GetExpressRouteCircuitPeerings(); - // invoke the operation and iterate over the result - await foreach (ExpressRouteCircuitPeeringResource item in collection.GetAllAsync()) + // invoke the operation + string peeringName = "MicrosoftPeering"; + NullableResponse response = await collection.GetIfExistsAsync(peeringName); + ExpressRouteCircuitPeeringResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRouteCircuitPeeringData resourceData = item.Data; + ExpressRouteCircuitPeeringData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitPeeringResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitPeeringResource.cs index a5aeb2aba3392..a2e01947df542 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitPeeringResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitPeeringResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ExpressRouteCircuitPeeringResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteExpressRouteCircuitPeerings() + public async Task Get_GetExpressRouteCircuitPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringDelete.json - // this example is just showing the usage of "ExpressRouteCircuitPeerings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringGet.json + // this example is just showing the usage of "ExpressRouteCircuitPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +33,26 @@ public async Task Delete_DeleteExpressRouteCircuitPeerings() string subscriptionId = "subid"; string resourceGroupName = "rg1"; string circuitName = "circuitName"; - string peeringName = "peeringName"; + string peeringName = "MicrosoftPeering"; ResourceIdentifier expressRouteCircuitPeeringResourceId = ExpressRouteCircuitPeeringResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, circuitName, peeringName); ExpressRouteCircuitPeeringResource expressRouteCircuitPeering = client.GetExpressRouteCircuitPeeringResource(expressRouteCircuitPeeringResourceId); // invoke the operation - await expressRouteCircuitPeering.DeleteAsync(WaitUntil.Completed); + ExpressRouteCircuitPeeringResource result = await expressRouteCircuitPeering.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExpressRouteCircuitPeering() + public async Task Delete_DeleteExpressRouteCircuitPeerings() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringGet.json - // this example is just showing the usage of "ExpressRouteCircuitPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitPeeringDelete.json + // this example is just showing the usage of "ExpressRouteCircuitPeerings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,14 @@ public async Task Get_GetExpressRouteCircuitPeering() string subscriptionId = "subid"; string resourceGroupName = "rg1"; string circuitName = "circuitName"; - string peeringName = "MicrosoftPeering"; + string peeringName = "peeringName"; ResourceIdentifier expressRouteCircuitPeeringResourceId = ExpressRouteCircuitPeeringResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, circuitName, peeringName); ExpressRouteCircuitPeeringResource expressRouteCircuitPeering = client.GetExpressRouteCircuitPeeringResource(expressRouteCircuitPeeringResourceId); // invoke the operation - ExpressRouteCircuitPeeringResource result = await expressRouteCircuitPeering.GetAsync(); + await expressRouteCircuitPeering.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_CreateExpressRouteCircuitPeerings() ExpressRouteCircuitPeeringResource expressRouteCircuitPeering = client.GetExpressRouteCircuitPeeringResource(expressRouteCircuitPeeringResourceId); // invoke the operation - ExpressRouteCircuitPeeringData data = new ExpressRouteCircuitPeeringData() + ExpressRouteCircuitPeeringData data = new ExpressRouteCircuitPeeringData { PeerASN = 200L, PrimaryPeerAddressPrefix = "192.168.16.252/30", diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitResource.cs index 061305e6b2e84..b8de2329b961e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCircuitResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_ExpressRouteCircuitResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteExpressRouteCircuit() + public async Task Get_GetExpressRouteCircuit() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitDelete.json - // this example is just showing the usage of "ExpressRouteCircuits_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitGet.json + // this example is just showing the usage of "ExpressRouteCircuits_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteExpressRouteCircuit() ExpressRouteCircuitResource expressRouteCircuit = client.GetExpressRouteCircuitResource(expressRouteCircuitResourceId); // invoke the operation - await expressRouteCircuit.DeleteAsync(WaitUntil.Completed); + ExpressRouteCircuitResource result = await expressRouteCircuit.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExpressRouteCircuit() + public async Task Delete_DeleteExpressRouteCircuit() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitGet.json - // this example is just showing the usage of "ExpressRouteCircuits_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitDelete.json + // this example is just showing the usage of "ExpressRouteCircuits_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetExpressRouteCircuit() ExpressRouteCircuitResource expressRouteCircuit = client.GetExpressRouteCircuitResource(expressRouteCircuitResourceId); // invoke the operation - ExpressRouteCircuitResource result = await expressRouteCircuit.GetAsync(); + await expressRouteCircuit.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateExpressRouteCircuitTags() ExpressRouteCircuitResource expressRouteCircuit = client.GetExpressRouteCircuitResource(expressRouteCircuitResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ExpressRouteCircuitResource result = await expressRouteCircuit.UpdateAsync(networkTagsObject); @@ -136,36 +135,5 @@ public async Task GetStats_GetExpressRouteCircuitTrafficStats() Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetExpressRouteCircuits_ListExpressRouteCircuitsInASubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitListBySubscription.json - // this example is just showing the usage of "ExpressRouteCircuits_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ExpressRouteCircuitResource item in subscriptionResource.GetExpressRouteCircuitsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCircuitData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteConnectionCollection.cs index 6ce28f19dbd07..450f9a11cb0ca 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteConnectionCollection.cs @@ -42,33 +42,27 @@ public async Task CreateOrUpdate_ExpressRouteConnectionCreate() // invoke the operation string connectionName = "connectionName"; - ExpressRouteConnectionData data = new ExpressRouteConnectionData() + ExpressRouteConnectionData data = new ExpressRouteConnectionData { ExpressRouteCircuitPeeringId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/expressRouteCircuits/circuitName/peerings/AzurePrivatePeering"), AuthorizationKey = "authorizationKey", RoutingWeight = 2, - RoutingConfiguration = new RoutingConfiguration() + RoutingConfiguration = new RoutingConfiguration { AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), - PropagatedRouteTables = new PropagatedRouteTable() + PropagatedRouteTables = new PropagatedRouteTable { - Labels = -{ -"label1","label2" -}, - Ids = -{ -new WritableSubResource() + Labels = { "label1", "label2" }, + Ids = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), -},new WritableSubResource() +}, new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable2"), -},new WritableSubResource() +}, new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable3"), -} -}, +}}, }, InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), @@ -122,10 +116,10 @@ public async Task Get_ExpressRouteConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExpressRouteConnectionGet() + public async Task GetAll_ExpressRouteConnectionList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionGet.json - // this example is just showing the usage of "ExpressRouteConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionList.json + // this example is just showing the usage of "ExpressRouteConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,16 +137,22 @@ public async Task Exists_ExpressRouteConnectionGet() // get the collection of this ExpressRouteConnectionResource ExpressRouteConnectionCollection collection = expressRouteGateway.GetExpressRouteConnections(); - // invoke the operation - string connectionName = "connectionName"; - bool result = await collection.ExistsAsync(connectionName); + // invoke the operation and iterate over the result + await foreach (ExpressRouteConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExpressRouteConnectionGet() + public async Task Exists_ExpressRouteConnectionGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionGet.json // this example is just showing the usage of "ExpressRouteConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -175,29 +175,17 @@ public async Task GetIfExists_ExpressRouteConnectionGet() // invoke the operation string connectionName = "connectionName"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - ExpressRouteConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(connectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExpressRouteConnectionList() + public async Task GetIfExists_ExpressRouteConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionList.json - // this example is just showing the usage of "ExpressRouteConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionGet.json + // this example is just showing the usage of "ExpressRouteConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -215,17 +203,23 @@ public async Task GetAll_ExpressRouteConnectionList() // get the collection of this ExpressRouteConnectionResource ExpressRouteConnectionCollection collection = expressRouteGateway.GetExpressRouteConnections(); - // invoke the operation and iterate over the result - await foreach (ExpressRouteConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string connectionName = "connectionName"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + ExpressRouteConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRouteConnectionData resourceData = item.Data; + ExpressRouteConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteConnectionResource.cs index e6827d067acab..06ba3db8ca1ad 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteConnectionResource.cs @@ -19,10 +19,10 @@ public partial class Sample_ExpressRouteConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ExpressRouteConnectionCreate() + public async Task Get_ExpressRouteConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionCreate.json - // this example is just showing the usage of "ExpressRouteConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionGet.json + // this example is just showing the usage of "ExpressRouteConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,48 +33,13 @@ public async Task Update_ExpressRouteConnectionCreate() // for more information of creating ExpressRouteConnectionResource, please refer to the document of ExpressRouteConnectionResource string subscriptionId = "subid"; string resourceGroupName = "resourceGroupName"; - string expressRouteGatewayName = "gateway-2"; + string expressRouteGatewayName = "expressRouteGatewayName"; string connectionName = "connectionName"; ResourceIdentifier expressRouteConnectionResourceId = ExpressRouteConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, expressRouteGatewayName, connectionName); ExpressRouteConnectionResource expressRouteConnection = client.GetExpressRouteConnectionResource(expressRouteConnectionResourceId); // invoke the operation - ExpressRouteConnectionData data = new ExpressRouteConnectionData() - { - ExpressRouteCircuitPeeringId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/expressRouteCircuits/circuitName/peerings/AzurePrivatePeering"), - AuthorizationKey = "authorizationKey", - RoutingWeight = 2, - RoutingConfiguration = new RoutingConfiguration() - { - AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), - PropagatedRouteTables = new PropagatedRouteTable() - { - Labels = -{ -"label1","label2" -}, - Ids = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable2"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable3"), -} -}, - }, - InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), - OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), - }, - Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/expressRouteGateways/gateway-2/expressRouteConnections/connectionName"), - Name = "connectionName", - }; - ArmOperation lro = await expressRouteConnection.UpdateAsync(WaitUntil.Completed, data); - ExpressRouteConnectionResource result = lro.Value; + ExpressRouteConnectionResource result = await expressRouteConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -85,10 +50,10 @@ public async Task Update_ExpressRouteConnectionCreate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExpressRouteConnectionGet() + public async Task Delete_ExpressRouteConnectionDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionGet.json - // this example is just showing the usage of "ExpressRouteConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionDelete.json + // this example is just showing the usage of "ExpressRouteConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,21 +70,17 @@ public async Task Get_ExpressRouteConnectionGet() ExpressRouteConnectionResource expressRouteConnection = client.GetExpressRouteConnectionResource(expressRouteConnectionResourceId); // invoke the operation - ExpressRouteConnectionResource result = await expressRouteConnection.GetAsync(); + await expressRouteConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ExpressRouteConnectionDelete() + public async Task Update_ExpressRouteConnectionCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionDelete.json - // this example is just showing the usage of "ExpressRouteConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteConnectionCreate.json + // this example is just showing the usage of "ExpressRouteConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -130,15 +91,48 @@ public async Task Delete_ExpressRouteConnectionDelete() // for more information of creating ExpressRouteConnectionResource, please refer to the document of ExpressRouteConnectionResource string subscriptionId = "subid"; string resourceGroupName = "resourceGroupName"; - string expressRouteGatewayName = "expressRouteGatewayName"; + string expressRouteGatewayName = "gateway-2"; string connectionName = "connectionName"; ResourceIdentifier expressRouteConnectionResourceId = ExpressRouteConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, expressRouteGatewayName, connectionName); ExpressRouteConnectionResource expressRouteConnection = client.GetExpressRouteConnectionResource(expressRouteConnectionResourceId); // invoke the operation - await expressRouteConnection.DeleteAsync(WaitUntil.Completed); + ExpressRouteConnectionData data = new ExpressRouteConnectionData + { + ExpressRouteCircuitPeeringId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/expressRouteCircuits/circuitName/peerings/AzurePrivatePeering"), + AuthorizationKey = "authorizationKey", + RoutingWeight = 2, + RoutingConfiguration = new RoutingConfiguration + { + AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), + PropagatedRouteTables = new PropagatedRouteTable + { + Labels = { "label1", "label2" }, + Ids = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable2"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable3"), +}}, + }, + InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), + OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), + }, + Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/expressRouteGateways/gateway-2/expressRouteConnections/connectionName"), + Name = "connectionName", + }; + ArmOperation lro = await expressRouteConnection.UpdateAsync(WaitUntil.Completed, data); + ExpressRouteConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionCollection.cs index 203d4747160b7..770eeea0e4ff6 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ExpressRouteCrossConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExpressRouteCrossConnectionListByResourceGroup() + public async Task CreateOrUpdate_UpdateExpressRouteCrossConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionListByResourceGroup.json - // this example is just showing the usage of "ExpressRouteCrossConnections_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionUpdate.json + // this example is just showing the usage of "ExpressRouteCrossConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,20 @@ public async Task GetAll_ExpressRouteCrossConnectionListByResourceGroup() // get the collection of this ExpressRouteCrossConnectionResource ExpressRouteCrossConnectionCollection collection = resourceGroupResource.GetExpressRouteCrossConnections(); - // invoke the operation and iterate over the result - await foreach (ExpressRouteCrossConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string crossConnectionName = ""; + ExpressRouteCrossConnectionData data = new ExpressRouteCrossConnectionData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCrossConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + ServiceProviderProvisioningState = ServiceProviderProvisioningState.NotProvisioned, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, crossConnectionName, data); + ExpressRouteCrossConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCrossConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetExpressRouteCrossConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetExpressRouteCrossConnection() + public async Task GetAll_ExpressRouteCrossConnectionListByResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionGet.json - // this example is just showing the usage of "ExpressRouteCrossConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionListByResourceGroup.json + // this example is just showing the usage of "ExpressRouteCrossConnections_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,16 +110,22 @@ public async Task Exists_GetExpressRouteCrossConnection() // get the collection of this ExpressRouteCrossConnectionResource ExpressRouteCrossConnectionCollection collection = resourceGroupResource.GetExpressRouteCrossConnections(); - // invoke the operation - string crossConnectionName = ""; - bool result = await collection.ExistsAsync(crossConnectionName); + // invoke the operation and iterate over the result + await foreach (ExpressRouteCrossConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCrossConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetExpressRouteCrossConnection() + public async Task Exists_GetExpressRouteCrossConnection() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionGet.json // this example is just showing the usage of "ExpressRouteCrossConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -138,29 +147,17 @@ public async Task GetIfExists_GetExpressRouteCrossConnection() // invoke the operation string crossConnectionName = ""; - NullableResponse response = await collection.GetIfExistsAsync(crossConnectionName); - ExpressRouteCrossConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(crossConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCrossConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_UpdateExpressRouteCrossConnection() + public async Task GetIfExists_GetExpressRouteCrossConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionUpdate.json - // this example is just showing the usage of "ExpressRouteCrossConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionGet.json + // this example is just showing the usage of "ExpressRouteCrossConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,18 +176,21 @@ public async Task CreateOrUpdate_UpdateExpressRouteCrossConnection() // invoke the operation string crossConnectionName = ""; - ExpressRouteCrossConnectionData data = new ExpressRouteCrossConnectionData() - { - ServiceProviderProvisioningState = ServiceProviderProvisioningState.NotProvisioned, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, crossConnectionName, data); - ExpressRouteCrossConnectionResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(crossConnectionName); + ExpressRouteCrossConnectionResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCrossConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCrossConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionPeeringCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionPeeringCollection.cs index d7bdab194bace..f71bed588cc3f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionPeeringCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionPeeringCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ExpressRouteCrossConnectionPeeringCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExpressRouteCrossConnectionBgpPeeringList() + public async Task CreateOrUpdate_ExpressRouteCrossConnectionBgpPeeringCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringList.json - // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringCreate.json + // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,28 @@ public async Task GetAll_ExpressRouteCrossConnectionBgpPeeringList() // get the collection of this ExpressRouteCrossConnectionPeeringResource ExpressRouteCrossConnectionPeeringCollection collection = expressRouteCrossConnection.GetExpressRouteCrossConnectionPeerings(); - // invoke the operation and iterate over the result - await foreach (ExpressRouteCrossConnectionPeeringResource item in collection.GetAllAsync()) + // invoke the operation + string peeringName = "AzurePrivatePeering"; + ExpressRouteCrossConnectionPeeringData data = new ExpressRouteCrossConnectionPeeringData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCrossConnectionPeeringData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + PeerASN = 200L, + PrimaryPeerAddressPrefix = "192.168.16.252/30", + SecondaryPeerAddressPrefix = "192.168.18.252/30", + VlanId = 200, + IPv6PeeringConfig = new IPv6ExpressRouteCircuitPeeringConfig + { + PrimaryPeerAddressPrefix = "3FFE:FFFF:0:CD30::/126", + SecondaryPeerAddressPrefix = "3FFE:FFFF:0:CD30::4/126", + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peeringName, data); + ExpressRouteCrossConnectionPeeringResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCrossConnectionPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +99,10 @@ public async Task Get_GetExpressRouteCrossConnectionBgpPeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetExpressRouteCrossConnectionBgpPeering() + public async Task GetAll_ExpressRouteCrossConnectionBgpPeeringList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringGet.json - // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringList.json + // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +120,22 @@ public async Task Exists_GetExpressRouteCrossConnectionBgpPeering() // get the collection of this ExpressRouteCrossConnectionPeeringResource ExpressRouteCrossConnectionPeeringCollection collection = expressRouteCrossConnection.GetExpressRouteCrossConnectionPeerings(); - // invoke the operation - string peeringName = "AzurePrivatePeering"; - bool result = await collection.ExistsAsync(peeringName); + // invoke the operation and iterate over the result + await foreach (ExpressRouteCrossConnectionPeeringResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCrossConnectionPeeringData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetExpressRouteCrossConnectionBgpPeering() + public async Task Exists_GetExpressRouteCrossConnectionBgpPeering() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringGet.json // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +158,17 @@ public async Task GetIfExists_GetExpressRouteCrossConnectionBgpPeering() // invoke the operation string peeringName = "AzurePrivatePeering"; - NullableResponse response = await collection.GetIfExistsAsync(peeringName); - ExpressRouteCrossConnectionPeeringResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(peeringName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCrossConnectionPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ExpressRouteCrossConnectionBgpPeeringCreate() + public async Task GetIfExists_GetExpressRouteCrossConnectionBgpPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringCreate.json - // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringGet.json + // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +188,21 @@ public async Task CreateOrUpdate_ExpressRouteCrossConnectionBgpPeeringCreate() // invoke the operation string peeringName = "AzurePrivatePeering"; - ExpressRouteCrossConnectionPeeringData data = new ExpressRouteCrossConnectionPeeringData() - { - PeerASN = 200L, - PrimaryPeerAddressPrefix = "192.168.16.252/30", - SecondaryPeerAddressPrefix = "192.168.18.252/30", - VlanId = 200, - IPv6PeeringConfig = new IPv6ExpressRouteCircuitPeeringConfig() - { - PrimaryPeerAddressPrefix = "3FFE:FFFF:0:CD30::/126", - SecondaryPeerAddressPrefix = "3FFE:FFFF:0:CD30::4/126", - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peeringName, data); - ExpressRouteCrossConnectionPeeringResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(peeringName); + ExpressRouteCrossConnectionPeeringResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCrossConnectionPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCrossConnectionPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionPeeringResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionPeeringResource.cs index 40eea9d22cb1f..634e2c855315a 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionPeeringResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionPeeringResource.cs @@ -18,10 +18,10 @@ public partial class Sample_ExpressRouteCrossConnectionPeeringResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetArpTableExpressRouteCrossConnection_GetExpressRouteCrossConnectionsArpTable() + public async Task Get_GetExpressRouteCrossConnectionBgpPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionsArpTable.json - // this example is just showing the usage of "ExpressRouteCrossConnections_ListArpTable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringGet.json + // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,19 +38,21 @@ public async Task GetArpTableExpressRouteCrossConnection_GetExpressRouteCrossCon ExpressRouteCrossConnectionPeeringResource expressRouteCrossConnectionPeering = client.GetExpressRouteCrossConnectionPeeringResource(expressRouteCrossConnectionPeeringResourceId); // invoke the operation - string devicePath = "primary"; - ArmOperation lro = await expressRouteCrossConnectionPeering.GetArpTableExpressRouteCrossConnectionAsync(WaitUntil.Completed, devicePath); - ExpressRouteCircuitsArpTableListResult result = lro.Value; + ExpressRouteCrossConnectionPeeringResource result = await expressRouteCrossConnectionPeering.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCrossConnectionPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetRoutesTableSummaryExpressRouteCrossConnection_GetExpressRouteCrossConnectionsRouteTableSummary() + public async Task Delete_DeleteExpressRouteCrossConnectionBgpPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionsRouteTableSummary.json - // this example is just showing the usage of "ExpressRouteCrossConnections_ListRoutesTableSummary" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringDelete.json + // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,19 +69,17 @@ public async Task GetRoutesTableSummaryExpressRouteCrossConnection_GetExpressRou ExpressRouteCrossConnectionPeeringResource expressRouteCrossConnectionPeering = client.GetExpressRouteCrossConnectionPeeringResource(expressRouteCrossConnectionPeeringResourceId); // invoke the operation - string devicePath = "primary"; - ArmOperation lro = await expressRouteCrossConnectionPeering.GetRoutesTableSummaryExpressRouteCrossConnectionAsync(WaitUntil.Completed, devicePath); - ExpressRouteCrossConnectionsRoutesTableSummaryListResult result = lro.Value; + await expressRouteCrossConnectionPeering.DeleteAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetRoutesTableExpressRouteCrossConnection_GetExpressRouteCrossConnectionsRouteTable() + public async Task Update_ExpressRouteCrossConnectionBgpPeeringCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionsRouteTable.json - // this example is just showing the usage of "ExpressRouteCrossConnections_ListRoutesTable" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringCreate.json + // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -96,19 +96,34 @@ public async Task GetRoutesTableExpressRouteCrossConnection_GetExpressRouteCross ExpressRouteCrossConnectionPeeringResource expressRouteCrossConnectionPeering = client.GetExpressRouteCrossConnectionPeeringResource(expressRouteCrossConnectionPeeringResourceId); // invoke the operation - string devicePath = "primary"; - ArmOperation lro = await expressRouteCrossConnectionPeering.GetRoutesTableExpressRouteCrossConnectionAsync(WaitUntil.Completed, devicePath); - ExpressRouteCircuitsRoutesTableListResult result = lro.Value; + ExpressRouteCrossConnectionPeeringData data = new ExpressRouteCrossConnectionPeeringData + { + PeerASN = 200L, + PrimaryPeerAddressPrefix = "192.168.16.252/30", + SecondaryPeerAddressPrefix = "192.168.18.252/30", + VlanId = 200, + IPv6PeeringConfig = new IPv6ExpressRouteCircuitPeeringConfig + { + PrimaryPeerAddressPrefix = "3FFE:FFFF:0:CD30::/126", + SecondaryPeerAddressPrefix = "3FFE:FFFF:0:CD30::4/126", + }, + }; + ArmOperation lro = await expressRouteCrossConnectionPeering.UpdateAsync(WaitUntil.Completed, data); + ExpressRouteCrossConnectionPeeringResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCrossConnectionPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteExpressRouteCrossConnectionBgpPeering() + public async Task GetArpTableExpressRouteCrossConnection_GetExpressRouteCrossConnectionsArpTable() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringDelete.json - // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionsArpTable.json + // this example is just showing the usage of "ExpressRouteCrossConnections_ListArpTable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,17 +140,19 @@ public async Task Delete_DeleteExpressRouteCrossConnectionBgpPeering() ExpressRouteCrossConnectionPeeringResource expressRouteCrossConnectionPeering = client.GetExpressRouteCrossConnectionPeeringResource(expressRouteCrossConnectionPeeringResourceId); // invoke the operation - await expressRouteCrossConnectionPeering.DeleteAsync(WaitUntil.Completed); + string devicePath = "primary"; + ArmOperation lro = await expressRouteCrossConnectionPeering.GetArpTableExpressRouteCrossConnectionAsync(WaitUntil.Completed, devicePath); + ExpressRouteCircuitsArpTableListResult result = lro.Value; - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExpressRouteCrossConnectionBgpPeering() + public async Task GetRoutesTableSummaryExpressRouteCrossConnection_GetExpressRouteCrossConnectionsRouteTableSummary() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringGet.json - // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionsRouteTableSummary.json + // this example is just showing the usage of "ExpressRouteCrossConnections_ListRoutesTableSummary" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -152,21 +169,19 @@ public async Task Get_GetExpressRouteCrossConnectionBgpPeering() ExpressRouteCrossConnectionPeeringResource expressRouteCrossConnectionPeering = client.GetExpressRouteCrossConnectionPeeringResource(expressRouteCrossConnectionPeeringResourceId); // invoke the operation - ExpressRouteCrossConnectionPeeringResource result = await expressRouteCrossConnectionPeering.GetAsync(); + string devicePath = "primary"; + ArmOperation lro = await expressRouteCrossConnectionPeering.GetRoutesTableSummaryExpressRouteCrossConnectionAsync(WaitUntil.Completed, devicePath); + ExpressRouteCrossConnectionsRoutesTableSummaryListResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCrossConnectionPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ExpressRouteCrossConnectionBgpPeeringCreate() + public async Task GetRoutesTableExpressRouteCrossConnection_GetExpressRouteCrossConnectionsRouteTable() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionBgpPeeringCreate.json - // this example is just showing the usage of "ExpressRouteCrossConnectionPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionsRouteTable.json + // this example is just showing the usage of "ExpressRouteCrossConnections_ListRoutesTable" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,26 +198,11 @@ public async Task Update_ExpressRouteCrossConnectionBgpPeeringCreate() ExpressRouteCrossConnectionPeeringResource expressRouteCrossConnectionPeering = client.GetExpressRouteCrossConnectionPeeringResource(expressRouteCrossConnectionPeeringResourceId); // invoke the operation - ExpressRouteCrossConnectionPeeringData data = new ExpressRouteCrossConnectionPeeringData() - { - PeerASN = 200L, - PrimaryPeerAddressPrefix = "192.168.16.252/30", - SecondaryPeerAddressPrefix = "192.168.18.252/30", - VlanId = 200, - IPv6PeeringConfig = new IPv6ExpressRouteCircuitPeeringConfig() - { - PrimaryPeerAddressPrefix = "3FFE:FFFF:0:CD30::/126", - SecondaryPeerAddressPrefix = "3FFE:FFFF:0:CD30::4/126", - }, - }; - ArmOperation lro = await expressRouteCrossConnectionPeering.UpdateAsync(WaitUntil.Completed, data); - ExpressRouteCrossConnectionPeeringResource result = lro.Value; + string devicePath = "primary"; + ArmOperation lro = await expressRouteCrossConnectionPeering.GetRoutesTableExpressRouteCrossConnectionAsync(WaitUntil.Completed, devicePath); + ExpressRouteCircuitsRoutesTableListResult result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCrossConnectionPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionResource.cs index b0ab13376438e..940037be991b9 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteCrossConnectionResource.cs @@ -10,44 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples { public partial class Sample_ExpressRouteCrossConnectionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetExpressRouteCrossConnections_ExpressRouteCrossConnectionList() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionList.json - // this example is just showing the usage of "ExpressRouteCrossConnections_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ExpressRouteCrossConnectionResource item in subscriptionResource.GetExpressRouteCrossConnectionsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteCrossConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetExpressRouteCrossConnection() @@ -99,12 +67,12 @@ public async Task Update_UpdateExpressRouteCrossConnectionTags() ExpressRouteCrossConnectionResource expressRouteCrossConnection = client.GetExpressRouteCrossConnectionResource(expressRouteCrossConnectionResourceId); // invoke the operation - NetworkTagsObject crossConnectionParameters = new NetworkTagsObject() + NetworkTagsObject crossConnectionParameters = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ExpressRouteCrossConnectionResource result = await expressRouteCrossConnection.UpdateAsync(crossConnectionParameters); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteGatewayCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteGatewayCollection.cs index 2fd15d39bc86f..1c2a6c1e6fd31 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteGatewayCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteGatewayCollection.cs @@ -17,41 +17,6 @@ namespace Azure.ResourceManager.Network.Samples { public partial class Sample_ExpressRouteGatewayCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExpressRouteGatewayListByResourceGroup() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteGatewayListByResourceGroup.json - // this example is just showing the usage of "ExpressRouteGateways_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "resourceGroupName"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this ExpressRouteGatewayResource - ExpressRouteGatewayCollection collection = resourceGroupResource.GetExpressRouteGateways(); - - // invoke the operation and iterate over the result - await foreach (ExpressRouteGatewayResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_ExpressRouteGatewayCreate() @@ -76,9 +41,9 @@ public async Task CreateOrUpdate_ExpressRouteGatewayCreate() // invoke the operation string expressRouteGatewayName = "gateway-2"; - ExpressRouteGatewayData data = new ExpressRouteGatewayData() + ExpressRouteGatewayData data = new ExpressRouteGatewayData { - AutoScaleBounds = new ExpressRouteGatewayPropertiesAutoScaleConfigurationBounds() + AutoScaleBounds = new ExpressRouteGatewayPropertiesAutoScaleConfigurationBounds { Min = 3, }, @@ -129,6 +94,41 @@ public async Task Get_ExpressRouteGatewayGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ExpressRouteGatewayListByResourceGroup() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteGatewayListByResourceGroup.json + // this example is just showing the usage of "ExpressRouteGateways_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "resourceGroupName"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this ExpressRouteGatewayResource + ExpressRouteGatewayCollection collection = resourceGroupResource.GetExpressRouteGateways(); + + // invoke the operation and iterate over the result + await foreach (ExpressRouteGatewayResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Exists_ExpressRouteGatewayGet() diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteGatewayResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteGatewayResource.cs index 9cacc21ce3b7a..1446d10ecc157 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteGatewayResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteGatewayResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,41 +18,10 @@ public partial class Sample_ExpressRouteGatewayResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetExpressRouteGateways_ExpressRouteGatewayListBySubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteGatewayListBySubscription.json - // this example is just showing the usage of "ExpressRouteGateways_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ExpressRouteGatewayResource item in subscriptionResource.GetExpressRouteGatewaysAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_ExpressRouteGatewayUpdate() + public async Task Get_ExpressRouteGatewayGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteGatewayUpdateTags.json - // this example is just showing the usage of "ExpressRouteGateways_UpdateTags" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteGatewayGet.json + // this example is just showing the usage of "ExpressRouteGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +37,7 @@ public async Task Update_ExpressRouteGatewayUpdate() ExpressRouteGatewayResource expressRouteGateway = client.GetExpressRouteGatewayResource(expressRouteGatewayResourceId); // invoke the operation - NetworkTagsObject expressRouteGatewayParameters = new NetworkTagsObject() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await expressRouteGateway.UpdateAsync(WaitUntil.Completed, expressRouteGatewayParameters); - ExpressRouteGatewayResource result = lro.Value; + ExpressRouteGatewayResource result = await expressRouteGateway.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -89,10 +48,10 @@ public async Task Update_ExpressRouteGatewayUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExpressRouteGatewayGet() + public async Task Delete_ExpressRouteGatewayDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteGatewayGet.json - // this example is just showing the usage of "ExpressRouteGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteGatewayDelete.json + // this example is just showing the usage of "ExpressRouteGateways_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,21 +67,17 @@ public async Task Get_ExpressRouteGatewayGet() ExpressRouteGatewayResource expressRouteGateway = client.GetExpressRouteGatewayResource(expressRouteGatewayResourceId); // invoke the operation - ExpressRouteGatewayResource result = await expressRouteGateway.GetAsync(); + await expressRouteGateway.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ExpressRouteGatewayDelete() + public async Task Update_ExpressRouteGatewayUpdate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteGatewayDelete.json - // this example is just showing the usage of "ExpressRouteGateways_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteGatewayUpdateTags.json + // this example is just showing the usage of "ExpressRouteGateways_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -138,9 +93,22 @@ public async Task Delete_ExpressRouteGatewayDelete() ExpressRouteGatewayResource expressRouteGateway = client.GetExpressRouteGatewayResource(expressRouteGatewayResourceId); // invoke the operation - await expressRouteGateway.DeleteAsync(WaitUntil.Completed); + NetworkTagsObject expressRouteGatewayParameters = new NetworkTagsObject + { + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await expressRouteGateway.UpdateAsync(WaitUntil.Completed, expressRouteGatewayParameters); + ExpressRouteGatewayResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteLinkCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteLinkCollection.cs index 4e2dc45455c90..f53fe0ce8a8e5 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteLinkCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteLinkCollection.cs @@ -51,10 +51,10 @@ public async Task Get_ExpressRouteLinkGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExpressRouteLinkGet() + public async Task GetAll_ExpressRouteLinkGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteLinkGet.json - // this example is just showing the usage of "ExpressRouteLinks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteLinkList.json + // this example is just showing the usage of "ExpressRouteLinks_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_ExpressRouteLinkGet() // get the collection of this ExpressRouteLinkResource ExpressRouteLinkCollection collection = expressRoutePort.GetExpressRouteLinks(); - // invoke the operation - string linkName = "linkName"; - bool result = await collection.ExistsAsync(linkName); + // invoke the operation and iterate over the result + await foreach (ExpressRouteLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteLinkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExpressRouteLinkGet() + public async Task Exists_ExpressRouteLinkGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteLinkGet.json // this example is just showing the usage of "ExpressRouteLinks_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_ExpressRouteLinkGet() // invoke the operation string linkName = "linkName"; - NullableResponse response = await collection.GetIfExistsAsync(linkName); - ExpressRouteLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(linkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExpressRouteLinkGet() + public async Task GetIfExists_ExpressRouteLinkGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteLinkList.json - // this example is just showing the usage of "ExpressRouteLinks_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteLinkGet.json + // this example is just showing the usage of "ExpressRouteLinks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_ExpressRouteLinkGet() // get the collection of this ExpressRouteLinkResource ExpressRouteLinkCollection collection = expressRoutePort.GetExpressRouteLinks(); - // invoke the operation and iterate over the result - await foreach (ExpressRouteLinkResource item in collection.GetAllAsync()) + // invoke the operation + string linkName = "linkName"; + NullableResponse response = await collection.GetIfExistsAsync(linkName); + ExpressRouteLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRouteLinkData resourceData = item.Data; + ExpressRouteLinkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortAuthorizationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortAuthorizationCollection.cs index fd02fe7dc1daa..6928341ec2fed 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortAuthorizationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortAuthorizationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ExpressRoutePortAuthorizationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExpressRoutePortAuthorization() + public async Task CreateOrUpdate_CreateExpressRoutePortAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationGet.json - // this example is just showing the usage of "ExpressRoutePortAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationCreate.json + // this example is just showing the usage of "ExpressRoutePortAuthorizations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,10 @@ public async Task Get_GetExpressRoutePortAuthorization() ExpressRoutePortAuthorizationCollection collection = expressRoutePort.GetExpressRoutePortAuthorizations(); // invoke the operation - string authorizationName = "authorizationName"; - ExpressRoutePortAuthorizationResource result = await collection.GetAsync(authorizationName); + string authorizationName = "authorizatinName"; + ExpressRoutePortAuthorizationData data = new ExpressRoutePortAuthorizationData(); + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationName, data); + ExpressRoutePortAuthorizationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +53,7 @@ public async Task Get_GetExpressRoutePortAuthorization() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetExpressRoutePortAuthorization() + public async Task Get_GetExpressRoutePortAuthorization() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationGet.json // this example is just showing the usage of "ExpressRoutePortAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +76,21 @@ public async Task Exists_GetExpressRoutePortAuthorization() // invoke the operation string authorizationName = "authorizationName"; - bool result = await collection.ExistsAsync(authorizationName); + ExpressRoutePortAuthorizationResource result = await collection.GetAsync(authorizationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRoutePortAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetExpressRoutePortAuthorization() + public async Task GetAll_ListExpressRoutePortAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationGet.json - // this example is just showing the usage of "ExpressRoutePortAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationList.json + // this example is just showing the usage of "ExpressRoutePortAuthorizations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +108,25 @@ public async Task GetIfExists_GetExpressRoutePortAuthorization() // get the collection of this ExpressRoutePortAuthorizationResource ExpressRoutePortAuthorizationCollection collection = expressRoutePort.GetExpressRoutePortAuthorizations(); - // invoke the operation - string authorizationName = "authorizationName"; - NullableResponse response = await collection.GetIfExistsAsync(authorizationName); - ExpressRoutePortAuthorizationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ExpressRoutePortAuthorizationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRoutePortAuthorizationData resourceData = result.Data; + ExpressRoutePortAuthorizationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateExpressRoutePortAuthorization() + public async Task Exists_GetExpressRoutePortAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationCreate.json - // this example is just showing the usage of "ExpressRoutePortAuthorizations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationGet.json + // this example is just showing the usage of "ExpressRoutePortAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,24 +145,18 @@ public async Task CreateOrUpdate_CreateExpressRoutePortAuthorization() ExpressRoutePortAuthorizationCollection collection = expressRoutePort.GetExpressRoutePortAuthorizations(); // invoke the operation - string authorizationName = "authorizatinName"; - ExpressRoutePortAuthorizationData data = new ExpressRoutePortAuthorizationData(); - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, authorizationName, data); - ExpressRoutePortAuthorizationResource result = lro.Value; + string authorizationName = "authorizationName"; + bool result = await collection.ExistsAsync(authorizationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRoutePortAuthorizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListExpressRoutePortAuthorization() + public async Task GetIfExists_GetExpressRoutePortAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationList.json - // this example is just showing the usage of "ExpressRoutePortAuthorizations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationGet.json + // this example is just showing the usage of "ExpressRoutePortAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,17 +174,23 @@ public async Task GetAll_ListExpressRoutePortAuthorization() // get the collection of this ExpressRoutePortAuthorizationResource ExpressRoutePortAuthorizationCollection collection = expressRoutePort.GetExpressRoutePortAuthorizations(); - // invoke the operation and iterate over the result - await foreach (ExpressRoutePortAuthorizationResource item in collection.GetAllAsync()) + // invoke the operation + string authorizationName = "authorizationName"; + NullableResponse response = await collection.GetIfExistsAsync(authorizationName); + ExpressRoutePortAuthorizationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRoutePortAuthorizationData resourceData = item.Data; + ExpressRoutePortAuthorizationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortAuthorizationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortAuthorizationResource.cs index 551dc9a329b17..0a7ca330bcd3b 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortAuthorizationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortAuthorizationResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ExpressRoutePortAuthorizationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteExpressRoutePortAuthorization() + public async Task Get_GetExpressRoutePortAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationDelete.json - // this example is just showing the usage of "ExpressRoutePortAuthorizations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationGet.json + // this example is just showing the usage of "ExpressRoutePortAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task Delete_DeleteExpressRoutePortAuthorization() ExpressRoutePortAuthorizationResource expressRoutePortAuthorization = client.GetExpressRoutePortAuthorizationResource(expressRoutePortAuthorizationResourceId); // invoke the operation - await expressRoutePortAuthorization.DeleteAsync(WaitUntil.Completed); + ExpressRoutePortAuthorizationResource result = await expressRoutePortAuthorization.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRoutePortAuthorizationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetExpressRoutePortAuthorization() + public async Task Delete_DeleteExpressRoutePortAuthorization() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationGet.json - // this example is just showing the usage of "ExpressRoutePortAuthorizations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortAuthorizationDelete.json + // this example is just showing the usage of "ExpressRoutePortAuthorizations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +68,9 @@ public async Task Get_GetExpressRoutePortAuthorization() ExpressRoutePortAuthorizationResource expressRoutePortAuthorization = client.GetExpressRoutePortAuthorizationResource(expressRoutePortAuthorizationResourceId); // invoke the operation - ExpressRoutePortAuthorizationResource result = await expressRoutePortAuthorization.GetAsync(); + await expressRoutePortAuthorization.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRoutePortAuthorizationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortCollection.cs index 7b12567e888b6..7af256a131539 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_ExpressRoutePortCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExpressRoutePortGet() + public async Task CreateOrUpdate_ExpressRoutePortCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortGet.json - // this example is just showing the usage of "ExpressRoutePorts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortCreate.json + // this example is just showing the usage of "ExpressRoutePorts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,16 @@ public async Task Get_ExpressRoutePortGet() // invoke the operation string expressRoutePortName = "portName"; - ExpressRoutePortResource result = await collection.GetAsync(expressRoutePortName); + ExpressRoutePortData data = new ExpressRoutePortData + { + PeeringLocation = "peeringLocationName", + BandwidthInGbps = 100, + Encapsulation = ExpressRoutePortsEncapsulation.QinQ, + BillingType = ExpressRoutePortsBillingType.UnlimitedData, + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, expressRoutePortName, data); + ExpressRoutePortResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +61,10 @@ public async Task Get_ExpressRoutePortGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExpressRoutePortGet() + public async Task CreateOrUpdate_ExpressRoutePortUpdateLink() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortGet.json - // this example is just showing the usage of "ExpressRoutePorts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortUpdateLink.json + // this example is just showing the usage of "ExpressRoutePorts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,14 +83,32 @@ public async Task Exists_ExpressRoutePortGet() // invoke the operation string expressRoutePortName = "portName"; - bool result = await collection.ExistsAsync(expressRoutePortName); + ExpressRoutePortData data = new ExpressRoutePortData + { + PeeringLocation = "peeringLocationName", + BandwidthInGbps = 100, + Encapsulation = ExpressRoutePortsEncapsulation.QinQ, + Links = {new ExpressRouteLinkData +{ +AdminState = ExpressRouteLinkAdminState.Enabled, +Name = "link1", +}}, + BillingType = ExpressRoutePortsBillingType.UnlimitedData, + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, expressRoutePortName, data); + ExpressRoutePortResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRoutePortData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExpressRoutePortGet() + public async Task Get_ExpressRoutePortGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortGet.json // this example is just showing the usage of "ExpressRoutePorts_Get" operation, for the dependent resources, they will have to be created separately. @@ -103,29 +130,21 @@ public async Task GetIfExists_ExpressRoutePortGet() // invoke the operation string expressRoutePortName = "portName"; - NullableResponse response = await collection.GetIfExistsAsync(expressRoutePortName); - ExpressRoutePortResource result = response.HasValue ? response.Value : null; + ExpressRoutePortResource result = await collection.GetAsync(expressRoutePortName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRoutePortData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRoutePortData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ExpressRoutePortCreate() + public async Task GetAll_ExpressRoutePortListByResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortCreate.json - // this example is just showing the usage of "ExpressRoutePorts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortListByResourceGroup.json + // this example is just showing the usage of "ExpressRoutePorts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,32 +161,25 @@ public async Task CreateOrUpdate_ExpressRoutePortCreate() // get the collection of this ExpressRoutePortResource ExpressRoutePortCollection collection = resourceGroupResource.GetExpressRoutePorts(); - // invoke the operation - string expressRoutePortName = "portName"; - ExpressRoutePortData data = new ExpressRoutePortData() + // invoke the operation and iterate over the result + await foreach (ExpressRoutePortResource item in collection.GetAllAsync()) { - PeeringLocation = "peeringLocationName", - BandwidthInGbps = 100, - Encapsulation = ExpressRoutePortsEncapsulation.QinQ, - BillingType = ExpressRoutePortsBillingType.UnlimitedData, - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, expressRoutePortName, data); - ExpressRoutePortResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRoutePortData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRoutePortData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ExpressRoutePortUpdateLink() + public async Task Exists_ExpressRoutePortGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortUpdateLink.json - // this example is just showing the usage of "ExpressRoutePorts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortGet.json + // this example is just showing the usage of "ExpressRoutePorts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,38 +198,17 @@ public async Task CreateOrUpdate_ExpressRoutePortUpdateLink() // invoke the operation string expressRoutePortName = "portName"; - ExpressRoutePortData data = new ExpressRoutePortData() - { - PeeringLocation = "peeringLocationName", - BandwidthInGbps = 100, - Encapsulation = ExpressRoutePortsEncapsulation.QinQ, - Links = -{ -new ExpressRouteLinkData() -{ -AdminState = ExpressRouteLinkAdminState.Enabled, -Name = "link1", -} -}, - BillingType = ExpressRoutePortsBillingType.UnlimitedData, - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, expressRoutePortName, data); - ExpressRoutePortResource result = lro.Value; + bool result = await collection.ExistsAsync(expressRoutePortName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRoutePortData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExpressRoutePortListByResourceGroup() + public async Task GetIfExists_ExpressRoutePortGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortListByResourceGroup.json - // this example is just showing the usage of "ExpressRoutePorts_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortGet.json + // this example is just showing the usage of "ExpressRoutePorts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -234,17 +225,23 @@ public async Task GetAll_ExpressRoutePortListByResourceGroup() // get the collection of this ExpressRoutePortResource ExpressRoutePortCollection collection = resourceGroupResource.GetExpressRoutePorts(); - // invoke the operation and iterate over the result - await foreach (ExpressRoutePortResource item in collection.GetAllAsync()) + // invoke the operation + string expressRoutePortName = "portName"; + NullableResponse response = await collection.GetIfExistsAsync(expressRoutePortName); + ExpressRoutePortResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRoutePortData resourceData = item.Data; + ExpressRoutePortData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortResource.cs index 4581800ad6e45..af0ebc13284dc 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_ExpressRoutePortResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_ExpressRoutePortDelete() + public async Task Get_ExpressRoutePortGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortDelete.json - // this example is just showing the usage of "ExpressRoutePorts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortGet.json + // this example is just showing the usage of "ExpressRoutePorts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_ExpressRoutePortDelete() ExpressRoutePortResource expressRoutePort = client.GetExpressRoutePortResource(expressRoutePortResourceId); // invoke the operation - await expressRoutePort.DeleteAsync(WaitUntil.Completed); + ExpressRoutePortResource result = await expressRoutePort.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRoutePortData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExpressRoutePortGet() + public async Task Delete_ExpressRoutePortDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortGet.json - // this example is just showing the usage of "ExpressRoutePorts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortDelete.json + // this example is just showing the usage of "ExpressRoutePorts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_ExpressRoutePortGet() ExpressRoutePortResource expressRoutePort = client.GetExpressRoutePortResource(expressRoutePortResourceId); // invoke the operation - ExpressRoutePortResource result = await expressRoutePort.GetAsync(); + await expressRoutePort.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRoutePortData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_ExpressRoutePortUpdateTags() ExpressRoutePortResource expressRoutePort = client.GetExpressRoutePortResource(expressRoutePortResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ExpressRoutePortResource result = await expressRoutePort.UpdateAsync(networkTagsObject); @@ -111,37 +110,6 @@ public async Task Update_ExpressRoutePortUpdateTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetExpressRoutePorts_ExpressRoutePortList() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortList.json - // this example is just showing the usage of "ExpressRoutePorts_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ExpressRoutePortResource item in subscriptionResource.GetExpressRoutePortsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRoutePortData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GenerateLoa_GenerateExpressRoutePortLOA() diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortsLocationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortsLocationCollection.cs index ba3c6a55f3d48..763f95fcc51d3 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortsLocationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRoutePortsLocationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ExpressRoutePortsLocationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExpressRoutePortsLocationList() + public async Task Get_ExpressRoutePortsLocationGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortsLocationList.json - // this example is just showing the usage of "ExpressRoutePortsLocations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortsLocationGet.json + // this example is just showing the usage of "ExpressRoutePortsLocations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_ExpressRoutePortsLocationList() // get the collection of this ExpressRoutePortsLocationResource ExpressRoutePortsLocationCollection collection = subscriptionResource.GetExpressRoutePortsLocations(); - // invoke the operation and iterate over the result - await foreach (ExpressRoutePortsLocationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRoutePortsLocationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string locationName = "locationName"; + ExpressRoutePortsLocationResource result = await collection.GetAsync(locationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRoutePortsLocationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ExpressRoutePortsLocationGet() + public async Task GetAll_ExpressRoutePortsLocationList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortsLocationGet.json - // this example is just showing the usage of "ExpressRoutePortsLocations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortsLocationList.json + // this example is just showing the usage of "ExpressRoutePortsLocations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +69,17 @@ public async Task Get_ExpressRoutePortsLocationGet() // get the collection of this ExpressRoutePortsLocationResource ExpressRoutePortsLocationCollection collection = subscriptionResource.GetExpressRoutePortsLocations(); - // invoke the operation - string locationName = "locationName"; - ExpressRoutePortsLocationResource result = await collection.GetAsync(locationName); + // invoke the operation and iterate over the result + await foreach (ExpressRoutePortsLocationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRoutePortsLocationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRoutePortsLocationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteProviderPortCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteProviderPortCollection.cs index f9e16c03e19b4..05b14fa736dbf 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteProviderPortCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteProviderPortCollection.cs @@ -50,10 +50,10 @@ public async Task Get_ExpressRouteProviderPort() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ExpressRouteProviderPort() + public async Task GetAll_ExpressRouteProviderPortList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/expressRouteProviderPort.json - // this example is just showing the usage of "ExpressRouteProviderPort" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/expressRouteProviderPortList.json + // this example is just showing the usage of "ExpressRouteProviderPortsLocation_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,16 +69,22 @@ public async Task Exists_ExpressRouteProviderPort() // get the collection of this ExpressRouteProviderPortResource ExpressRouteProviderPortCollection collection = subscriptionResource.GetExpressRouteProviderPorts(); - // invoke the operation - string providerport = "abc"; - bool result = await collection.ExistsAsync(providerport); + // invoke the operation and iterate over the result + await foreach (ExpressRouteProviderPortResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteProviderPortData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ExpressRouteProviderPort() + public async Task Exists_ExpressRouteProviderPort() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/expressRouteProviderPort.json // this example is just showing the usage of "ExpressRouteProviderPort" operation, for the dependent resources, they will have to be created separately. @@ -99,29 +105,17 @@ public async Task GetIfExists_ExpressRouteProviderPort() // invoke the operation string providerport = "abc"; - NullableResponse response = await collection.GetIfExistsAsync(providerport); - ExpressRouteProviderPortResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(providerport); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ExpressRouteProviderPortData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ExpressRouteProviderPortList() + public async Task GetIfExists_ExpressRouteProviderPort() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/expressRouteProviderPortList.json - // this example is just showing the usage of "ExpressRouteProviderPortsLocation_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/expressRouteProviderPort.json + // this example is just showing the usage of "ExpressRouteProviderPort" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,17 +131,23 @@ public async Task GetAll_ExpressRouteProviderPortList() // get the collection of this ExpressRouteProviderPortResource ExpressRouteProviderPortCollection collection = subscriptionResource.GetExpressRouteProviderPorts(); - // invoke the operation and iterate over the result - await foreach (ExpressRouteProviderPortResource item in collection.GetAllAsync()) + // invoke the operation + string providerport = "abc"; + NullableResponse response = await collection.GetIfExistsAsync(providerport); + ExpressRouteProviderPortResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ExpressRouteProviderPortData resourceData = item.Data; + ExpressRouteProviderPortData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteProviderPortResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteProviderPortResource.cs index d4a79bd284840..791e094d8cdb9 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteProviderPortResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ExpressRouteProviderPortResource.cs @@ -9,40 +9,12 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples { public partial class Sample_ExpressRouteProviderPortResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task CheckDnsNameAvailability_CheckDnsNameAvailability() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CheckDnsNameAvailability.json - // this example is just showing the usage of "CheckDnsNameAvailability" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("westus"); - string domainNameLabel = "testdns"; - DnsNameAvailabilityResult result = await subscriptionResource.CheckDnsNameAvailabilityAsync(location, domainNameLabel); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_ExpressRouteProviderPort() diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyCollection.cs index d7eb2a8944e7a..d2bc70d9a3f8c 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_FirewallPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicy() + public async Task CreateOrUpdate_CreateFirewallPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyGet.json - // this example is just showing the usage of "FirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyPut.json + // this example is just showing the usage of "FirewallPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,88 @@ public async Task Get_GetFirewallPolicy() // invoke the operation string firewallPolicyName = "firewallPolicy"; - FirewallPolicyResource result = await collection.GetAsync(firewallPolicyName); + FirewallPolicyData data = new FirewallPolicyData + { + ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, + ThreatIntelWhitelist = new FirewallPolicyThreatIntelWhitelist + { + IPAddresses = { "20.3.4.5" }, + Fqdns = { "*.microsoft.com" }, + }, + Insights = new FirewallPolicyInsights + { + IsEnabled = true, + RetentionDays = 100, + LogAnalyticsResources = new FirewallPolicyLogAnalyticsResources + { + Workspaces = {new FirewallPolicyLogAnalyticsWorkspace +{ +Region = "westus", +WorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/workspace1"), +}, new FirewallPolicyLogAnalyticsWorkspace +{ +Region = "eastus", +WorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/workspace2"), +}}, + DefaultWorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/defaultWorkspace"), + }, + }, + Snat = new FirewallPolicySnat + { + PrivateRanges = { "IANAPrivateRanges" }, + }, + AllowSqlRedirect = true, + DnsSettings = new DnsSettings + { + Servers = { "30.3.4.5" }, + EnableProxy = true, + RequireProxyForNetworkRules = false, + }, + ExplicitProxy = new FirewallPolicyExplicitProxy + { + EnableExplicitProxy = true, + HttpPort = 8087, + HttpsPort = 8087, + EnablePacFile = true, + PacFilePort = 8087, + PacFile = "https://tinawstorage.file.core.windows.net/?sv=2020-02-10&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2021-06-04T07:01:12Z&st=2021-06-03T23:01:12Z&sip=68.65.171.11&spr=https&sig=Plsa0RRVpGbY0IETZZOT6znOHcSro71LLTTbzquYPgs%3D", + }, + IntrusionDetection = new FirewallPolicyIntrusionDetection + { + Mode = FirewallPolicyIntrusionDetectionStateType.Alert, + Profile = new FirewallPolicyIntrusionDetectionProfileType("Balanced"), + Configuration = new FirewallPolicyIntrusionDetectionConfiguration + { + SignatureOverrides = {new FirewallPolicyIntrusionDetectionSignatureSpecification +{ +Id = "2525004", +Mode = FirewallPolicyIntrusionDetectionStateType.Deny, +}}, + BypassTrafficSettings = {new FirewallPolicyIntrusionDetectionBypassTrafficSpecifications +{ +Name = "bypassRule1", +Description = "Rule 1", +Protocol = FirewallPolicyIntrusionDetectionProtocol.Tcp, +SourceAddresses = {"1.2.3.4"}, +DestinationAddresses = {"5.6.7.8"}, +DestinationPorts = {"*"}, +}}, + }, + }, + TransportSecurityCertificateAuthority = new FirewallPolicyCertificateAuthority + { + KeyVaultSecretId = "https://kv/secret", + Name = "clientcert", + }, + SkuTier = FirewallPolicySkuTier.Premium, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallPolicyName, data); + FirewallPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +133,7 @@ public async Task Get_GetFirewallPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFirewallPolicy() + public async Task Get_GetFirewallPolicy() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyGet.json // this example is just showing the usage of "FirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +155,21 @@ public async Task Exists_GetFirewallPolicy() // invoke the operation string firewallPolicyName = "firewallPolicy"; - bool result = await collection.ExistsAsync(firewallPolicyName); + FirewallPolicyResource result = await collection.GetAsync(firewallPolicyName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFirewallPolicy() + public async Task GetAll_ListAllFirewallPoliciesForAGivenResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyGet.json - // this example is just showing the usage of "FirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyListByResourceGroup.json + // this example is just showing the usage of "FirewallPolicies_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +186,25 @@ public async Task GetIfExists_GetFirewallPolicy() // get the collection of this FirewallPolicyResource FirewallPolicyCollection collection = resourceGroupResource.GetFirewallPolicies(); - // invoke the operation - string firewallPolicyName = "firewallPolicy"; - NullableResponse response = await collection.GetIfExistsAsync(firewallPolicyName); - FirewallPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (FirewallPolicyResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FirewallPolicyData resourceData = result.Data; + FirewallPolicyData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFirewallPolicy() + public async Task Exists_GetFirewallPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyPut.json - // this example is just showing the usage of "FirewallPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyGet.json + // this example is just showing the usage of "FirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,132 +223,17 @@ public async Task CreateOrUpdate_CreateFirewallPolicy() // invoke the operation string firewallPolicyName = "firewallPolicy"; - FirewallPolicyData data = new FirewallPolicyData() - { - ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, - ThreatIntelWhitelist = new FirewallPolicyThreatIntelWhitelist() - { - IPAddresses = -{ -"20.3.4.5" -}, - Fqdns = -{ -"*.microsoft.com" -}, - }, - Insights = new FirewallPolicyInsights() - { - IsEnabled = true, - RetentionDays = 100, - LogAnalyticsResources = new FirewallPolicyLogAnalyticsResources() - { - Workspaces = -{ -new FirewallPolicyLogAnalyticsWorkspace() -{ -Region = "westus", -WorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/workspace1"), -},new FirewallPolicyLogAnalyticsWorkspace() -{ -Region = "eastus", -WorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/workspace2"), -} -}, - DefaultWorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/defaultWorkspace"), - }, - }, - Snat = new FirewallPolicySnat() - { - PrivateRanges = -{ -"IANAPrivateRanges" -}, - }, - AllowSqlRedirect = true, - DnsSettings = new DnsSettings() - { - Servers = -{ -"30.3.4.5" -}, - EnableProxy = true, - RequireProxyForNetworkRules = false, - }, - ExplicitProxy = new FirewallPolicyExplicitProxy() - { - EnableExplicitProxy = true, - HttpPort = 8087, - HttpsPort = 8087, - EnablePacFile = true, - PacFilePort = 8087, - PacFile = "https://tinawstorage.file.core.windows.net/?sv=2020-02-10&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2021-06-04T07:01:12Z&st=2021-06-03T23:01:12Z&sip=68.65.171.11&spr=https&sig=Plsa0RRVpGbY0IETZZOT6znOHcSro71LLTTbzquYPgs%3D", - }, - IntrusionDetection = new FirewallPolicyIntrusionDetection() - { - Mode = FirewallPolicyIntrusionDetectionStateType.Alert, - Profile = new FirewallPolicyIntrusionDetectionProfileType("Balanced"), - Configuration = new FirewallPolicyIntrusionDetectionConfiguration() - { - SignatureOverrides = -{ -new FirewallPolicyIntrusionDetectionSignatureSpecification() -{ -Id = "2525004", -Mode = FirewallPolicyIntrusionDetectionStateType.Deny, -} -}, - BypassTrafficSettings = -{ -new FirewallPolicyIntrusionDetectionBypassTrafficSpecifications() -{ -Name = "bypassRule1", -Description = "Rule 1", -Protocol = FirewallPolicyIntrusionDetectionProtocol.Tcp, -SourceAddresses = -{ -"1.2.3.4" -}, -DestinationAddresses = -{ -"5.6.7.8" -}, -DestinationPorts = -{ -"*" -}, -} -}, - }, - }, - TransportSecurityCertificateAuthority = new FirewallPolicyCertificateAuthority() - { - KeyVaultSecretId = "https://kv/secret", - Name = "clientcert", - }, - SkuTier = FirewallPolicySkuTier.Premium, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, firewallPolicyName, data); - FirewallPolicyResource result = lro.Value; + bool result = await collection.ExistsAsync(firewallPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllFirewallPoliciesForAGivenResourceGroup() + public async Task GetIfExists_GetFirewallPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyListByResourceGroup.json - // this example is just showing the usage of "FirewallPolicies_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyGet.json + // this example is just showing the usage of "FirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -286,17 +250,23 @@ public async Task GetAll_ListAllFirewallPoliciesForAGivenResourceGroup() // get the collection of this FirewallPolicyResource FirewallPolicyCollection collection = resourceGroupResource.GetFirewallPolicies(); - // invoke the operation and iterate over the result - await foreach (FirewallPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string firewallPolicyName = "firewallPolicy"; + NullableResponse response = await collection.GetIfExistsAsync(firewallPolicyName); + FirewallPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FirewallPolicyData resourceData = item.Data; + FirewallPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyDraftResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyDraftResource.cs index 28f8484049def..c4a7a67e09afd 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyDraftResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyDraftResource.cs @@ -18,10 +18,10 @@ public partial class Sample_FirewallPolicyDraftResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateFirewallPolicyDraft() + public async Task Get_GetFirewallPolicyDraft() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyDraftPut.json - // this example is just showing the usage of "FirewallPolicyDrafts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyDraftGet.json + // this example is just showing the usage of "FirewallPolicyDrafts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,107 +37,7 @@ public async Task CreateOrUpdate_CreateOrUpdateFirewallPolicyDraft() FirewallPolicyDraftResource firewallPolicyDraft = client.GetFirewallPolicyDraftResource(firewallPolicyDraftResourceId); // invoke the operation - FirewallPolicyDraftData data = new FirewallPolicyDraftData() - { - ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, - ThreatIntelWhitelist = new FirewallPolicyThreatIntelWhitelist() - { - IPAddresses = -{ -"20.3.4.5" -}, - Fqdns = -{ -"*.microsoft.com" -}, - }, - Insights = new FirewallPolicyInsights() - { - IsEnabled = true, - RetentionDays = 100, - LogAnalyticsResources = new FirewallPolicyLogAnalyticsResources() - { - Workspaces = -{ -new FirewallPolicyLogAnalyticsWorkspace() -{ -Region = "westus", -WorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/workspace1"), -},new FirewallPolicyLogAnalyticsWorkspace() -{ -Region = "eastus", -WorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/workspace2"), -} -}, - DefaultWorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/defaultWorkspace"), - }, - }, - Snat = new FirewallPolicySnat() - { - PrivateRanges = -{ -"IANAPrivateRanges" -}, - }, - AllowSqlRedirect = true, - DnsSettings = new DnsSettings() - { - Servers = -{ -"30.3.4.5" -}, - EnableProxy = true, - RequireProxyForNetworkRules = false, - }, - ExplicitProxy = new FirewallPolicyExplicitProxy() - { - EnableExplicitProxy = true, - HttpPort = 8087, - HttpsPort = 8087, - EnablePacFile = true, - PacFilePort = 8087, - PacFile = "https://tinawstorage.file.core.windows.net/?sv=2020-02-10&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2021-06-04T07:01:12Z&st=2021-06-03T23:01:12Z&sip=68.65.171.11&spr=https&sig=Plsa0RRVpGbY0IETZZOT6znOHcSro71LLTTbzquYPgs%3D", - }, - IntrusionDetection = new FirewallPolicyIntrusionDetection() - { - Mode = FirewallPolicyIntrusionDetectionStateType.Alert, - Profile = new FirewallPolicyIntrusionDetectionProfileType("Balanced"), - Configuration = new FirewallPolicyIntrusionDetectionConfiguration() - { - SignatureOverrides = -{ -new FirewallPolicyIntrusionDetectionSignatureSpecification() -{ -Id = "2525004", -Mode = FirewallPolicyIntrusionDetectionStateType.Deny, -} -}, - BypassTrafficSettings = -{ -new FirewallPolicyIntrusionDetectionBypassTrafficSpecifications() -{ -Name = "bypassRule1", -Description = "Rule 1", -Protocol = FirewallPolicyIntrusionDetectionProtocol.Tcp, -SourceAddresses = -{ -"1.2.3.4" -}, -DestinationAddresses = -{ -"5.6.7.8" -}, -DestinationPorts = -{ -"*" -}, -} -}, - }, - }, - }; - ArmOperation lro = await firewallPolicyDraft.CreateOrUpdateAsync(WaitUntil.Completed, data); - FirewallPolicyDraftResource result = lro.Value; + FirewallPolicyDraftResource result = await firewallPolicyDraft.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -174,10 +74,10 @@ public async Task Delete_DeleteFirewallPolicyDraft() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicyDraft() + public async Task CreateOrUpdate_CreateOrUpdateFirewallPolicyDraft() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyDraftGet.json - // this example is just showing the usage of "FirewallPolicyDrafts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyDraftPut.json + // this example is just showing the usage of "FirewallPolicyDrafts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,7 +93,77 @@ public async Task Get_GetFirewallPolicyDraft() FirewallPolicyDraftResource firewallPolicyDraft = client.GetFirewallPolicyDraftResource(firewallPolicyDraftResourceId); // invoke the operation - FirewallPolicyDraftResource result = await firewallPolicyDraft.GetAsync(); + FirewallPolicyDraftData data = new FirewallPolicyDraftData + { + ThreatIntelMode = AzureFirewallThreatIntelMode.Alert, + ThreatIntelWhitelist = new FirewallPolicyThreatIntelWhitelist + { + IPAddresses = { "20.3.4.5" }, + Fqdns = { "*.microsoft.com" }, + }, + Insights = new FirewallPolicyInsights + { + IsEnabled = true, + RetentionDays = 100, + LogAnalyticsResources = new FirewallPolicyLogAnalyticsResources + { + Workspaces = {new FirewallPolicyLogAnalyticsWorkspace +{ +Region = "westus", +WorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/workspace1"), +}, new FirewallPolicyLogAnalyticsWorkspace +{ +Region = "eastus", +WorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/workspace2"), +}}, + DefaultWorkspaceIdId = new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/microsoft.operationalinsights/workspaces/defaultWorkspace"), + }, + }, + Snat = new FirewallPolicySnat + { + PrivateRanges = { "IANAPrivateRanges" }, + }, + AllowSqlRedirect = true, + DnsSettings = new DnsSettings + { + Servers = { "30.3.4.5" }, + EnableProxy = true, + RequireProxyForNetworkRules = false, + }, + ExplicitProxy = new FirewallPolicyExplicitProxy + { + EnableExplicitProxy = true, + HttpPort = 8087, + HttpsPort = 8087, + EnablePacFile = true, + PacFilePort = 8087, + PacFile = "https://tinawstorage.file.core.windows.net/?sv=2020-02-10&ss=bfqt&srt=sco&sp=rwdlacuptfx&se=2021-06-04T07:01:12Z&st=2021-06-03T23:01:12Z&sip=68.65.171.11&spr=https&sig=Plsa0RRVpGbY0IETZZOT6znOHcSro71LLTTbzquYPgs%3D", + }, + IntrusionDetection = new FirewallPolicyIntrusionDetection + { + Mode = FirewallPolicyIntrusionDetectionStateType.Alert, + Profile = new FirewallPolicyIntrusionDetectionProfileType("Balanced"), + Configuration = new FirewallPolicyIntrusionDetectionConfiguration + { + SignatureOverrides = {new FirewallPolicyIntrusionDetectionSignatureSpecification +{ +Id = "2525004", +Mode = FirewallPolicyIntrusionDetectionStateType.Deny, +}}, + BypassTrafficSettings = {new FirewallPolicyIntrusionDetectionBypassTrafficSpecifications +{ +Name = "bypassRule1", +Description = "Rule 1", +Protocol = FirewallPolicyIntrusionDetectionProtocol.Tcp, +SourceAddresses = {"1.2.3.4"}, +DestinationAddresses = {"5.6.7.8"}, +DestinationPorts = {"*"}, +}}, + }, + }, + }; + ArmOperation lro = await firewallPolicyDraft.CreateOrUpdateAsync(WaitUntil.Completed, data); + FirewallPolicyDraftResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyResource.cs index 3fc30f9ba642a..642e6d1e9fd60 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_FirewallPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteFirewallPolicy() + public async Task Get_GetFirewallPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyDelete.json - // this example is just showing the usage of "FirewallPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyGet.json + // this example is just showing the usage of "FirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteFirewallPolicy() FirewallPolicyResource firewallPolicy = client.GetFirewallPolicyResource(firewallPolicyResourceId); // invoke the operation - await firewallPolicy.DeleteAsync(WaitUntil.Completed); + FirewallPolicyResource result = await firewallPolicy.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicy() + public async Task Delete_DeleteFirewallPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyGet.json - // this example is just showing the usage of "FirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyDelete.json + // this example is just showing the usage of "FirewallPolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetFirewallPolicy() FirewallPolicyResource firewallPolicy = client.GetFirewallPolicyResource(firewallPolicyResourceId); // invoke the operation - FirewallPolicyResource result = await firewallPolicy.GetAsync(); + await firewallPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateFirewallPolicyTags() FirewallPolicyResource firewallPolicy = client.GetFirewallPolicyResource(firewallPolicyResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, }; FirewallPolicyResource result = await firewallPolicy.UpdateAsync(networkTagsObject); @@ -111,37 +110,6 @@ public async Task Update_UpdateFirewallPolicyTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetFirewallPolicies_ListAllFirewallPoliciesForAGivenSubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyListBySubscription.json - // this example is just showing the usage of "FirewallPolicies_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (FirewallPolicyResource item in subscriptionResource.GetFirewallPoliciesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetFirewallPolicyIdpsSignature_QuerySignatureOverrides() @@ -163,21 +131,15 @@ public async Task GetFirewallPolicyIdpsSignature_QuerySignatureOverrides() FirewallPolicyResource firewallPolicy = client.GetFirewallPolicyResource(firewallPolicyResourceId); // invoke the operation - IdpsQueryContent content = new IdpsQueryContent() + IdpsQueryContent content = new IdpsQueryContent { - Filters = -{ -new IdpsQueryFilterItems() + Filters = {new IdpsQueryFilterItems { Field = "Mode", -Values = -{ -"Deny" -}, -} -}, +Values = {"Deny"}, +}}, Search = "", - OrderBy = new IdpsQueryOrderBy() + OrderBy = new IdpsQueryOrderBy { Field = "severity", Order = FirewallPolicyIdpsQuerySortOrder.Ascending, @@ -211,7 +173,7 @@ public async Task GetFirewallPolicyIdpsSignaturesFilterValue_QuerySignatureOverr FirewallPolicyResource firewallPolicy = client.GetFirewallPolicyResource(firewallPolicyResourceId); // invoke the operation - SignatureOverridesFilterValuesQueryContent content = new SignatureOverridesFilterValuesQueryContent() + SignatureOverridesFilterValuesQueryContent content = new SignatureOverridesFilterValuesQueryContent { FilterName = "severity", }; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupCollection.cs index f307d21a81f1d..197c8b3bfce41 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_FirewallPolicyRuleCollectionGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicyNatRuleCollectionGroup() + public async Task CreateOrUpdate_CreateFirewallPolicyNatRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyNatRuleCollectionGroupGet.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyNatRuleCollectionGroupPut.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,29 @@ public async Task Get_GetFirewallPolicyNatRuleCollectionGroup() // invoke the operation string ruleCollectionGroupName = "ruleCollectionGroup1"; - FirewallPolicyRuleCollectionGroupResource result = await collection.GetAsync(ruleCollectionGroupName); + FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData + { + Priority = 100, + RuleCollections = {new FirewallPolicyNatRuleCollectionInfo +{ +ActionType = FirewallPolicyNatRuleCollectionActionType.Dnat, +Rules = {new NatRule +{ +IPProtocols = {FirewallPolicyRuleNetworkProtocol.Tcp, FirewallPolicyRuleNetworkProtocol.Udp}, +SourceAddresses = {"2.2.2.2"}, +DestinationAddresses = {"152.23.32.23"}, +DestinationPorts = {"8080"}, +TranslatedPort = "8080", +SourceIPGroups = {}, +TranslatedFqdn = "internalhttp.server.net", +Name = "nat-rule1", +}}, +Name = "Example-Nat-Rule-Collection", +Priority = 100, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionGroupName, data); + FirewallPolicyRuleCollectionGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +74,10 @@ public async Task Get_GetFirewallPolicyNatRuleCollectionGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFirewallPolicyNatRuleCollectionGroup() + public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyNatRuleCollectionGroupGet.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupPut.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +97,40 @@ public async Task Exists_GetFirewallPolicyNatRuleCollectionGroup() // invoke the operation string ruleCollectionGroupName = "ruleCollectionGroup1"; - bool result = await collection.ExistsAsync(ruleCollectionGroupName); + FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData + { + Priority = 100, + RuleCollections = {new FirewallPolicyFilterRuleCollectionInfo +{ +ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, +Rules = {new NetworkRule +{ +IPProtocols = {FirewallPolicyRuleNetworkProtocol.Tcp}, +SourceAddresses = {"10.1.25.0/24"}, +DestinationAddresses = {"*"}, +DestinationPorts = {"*"}, +Name = "network-rule1", +}}, +Name = "Example-Filter-Rule-Collection", +Priority = 100, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionGroupName, data); + FirewallPolicyRuleCollectionGroupResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFirewallPolicyNatRuleCollectionGroup() + public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroupWithIPGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyNatRuleCollectionGroupGet.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsPut.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,29 +150,39 @@ public async Task GetIfExists_GetFirewallPolicyNatRuleCollectionGroup() // invoke the operation string ruleCollectionGroupName = "ruleCollectionGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionGroupName); - FirewallPolicyRuleCollectionGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Priority = 110, + RuleCollections = {new FirewallPolicyFilterRuleCollectionInfo +{ +ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, +Rules = {new NetworkRule +{ +IPProtocols = {FirewallPolicyRuleNetworkProtocol.Tcp}, +DestinationPorts = {"*"}, +SourceIPGroups = {"/subscriptions/subid/providers/Microsoft.Network/resourceGroup/rg1/ipGroups/ipGroups1"}, +DestinationIPGroups = {"/subscriptions/subid/providers/Microsoft.Network/resourceGroup/rg1/ipGroups/ipGroups2"}, +Name = "network-1", +}}, +Name = "Example-Filter-Rule-Collection", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionGroupName, data); + FirewallPolicyRuleCollectionGroupResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicyRuleCollectionGroup() + public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroupWithWebCategories() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupGet.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesPut.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,7 +191,7 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroup() // this example assumes you already have this FirewallPolicyResource created on azure // for more information of creating FirewallPolicyResource, please refer to the document of FirewallPolicyResource - string subscriptionId = "subid"; + string subscriptionId = "e747cc13-97d4-4a79-b463-42d7f4e558f2"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; ResourceIdentifier firewallPolicyResourceId = FirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallPolicyName); @@ -147,7 +202,29 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroup() // invoke the operation string ruleCollectionGroupName = "ruleCollectionGroup1"; - FirewallPolicyRuleCollectionGroupResource result = await collection.GetAsync(ruleCollectionGroupName); + FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData + { + Priority = 110, + RuleCollections = {new FirewallPolicyFilterRuleCollectionInfo +{ +ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, +Rules = {new ApplicationRule +{ +SourceAddresses = {"216.58.216.164", "10.0.0.0/24"}, +Protocols = {new FirewallPolicyRuleApplicationProtocol +{ +ProtocolType = FirewallPolicyRuleApplicationProtocolType.Https, +Port = 443, +}}, +WebCategories = {"Hacking"}, +Name = "rule1", +Description = "Deny inbound rule", +}}, +Name = "Example-Filter-Rule-Collection", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionGroupName, data); + FirewallPolicyRuleCollectionGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -158,10 +235,10 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFirewallPolicyRuleCollectionGroup() + public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroupWithHttpHeaderToInsert() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupGet.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithHttpHeadersToInsert.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -170,7 +247,7 @@ public async Task Exists_GetFirewallPolicyRuleCollectionGroup() // this example assumes you already have this FirewallPolicyResource created on azure // for more information of creating FirewallPolicyResource, please refer to the document of FirewallPolicyResource - string subscriptionId = "subid"; + string subscriptionId = "e747cc13-97d4-4a79-b463-42d7f4e558f2"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; ResourceIdentifier firewallPolicyResourceId = FirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallPolicyName); @@ -181,16 +258,47 @@ public async Task Exists_GetFirewallPolicyRuleCollectionGroup() // invoke the operation string ruleCollectionGroupName = "ruleCollectionGroup1"; - bool result = await collection.ExistsAsync(ruleCollectionGroupName); + FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData + { + Priority = 110, + RuleCollections = {new FirewallPolicyFilterRuleCollectionInfo +{ +ActionType = FirewallPolicyFilterRuleCollectionActionType.Allow, +Rules = {new ApplicationRule +{ +SourceAddresses = {"216.58.216.164", "10.0.0.0/24"}, +Protocols = {new FirewallPolicyRuleApplicationProtocol +{ +ProtocolType = FirewallPolicyRuleApplicationProtocolType.Http, +Port = 80, +}}, +FqdnTags = {"WindowsVirtualDesktop"}, +HttpHeadersToInsert = {new FirewallPolicyHttpHeaderToInsert +{ +HeaderName = "Restrict-Access-To-Tenants", +HeaderValue = "contoso.com,fabrikam.onmicrosoft.com", +}}, +Name = "rule1", +Description = "Insert trusted tenants header", +}}, +Name = "Example-Filter-Rule-Collection", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionGroupName, data); + FirewallPolicyRuleCollectionGroupResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroup() + public async Task Get_GetFirewallPolicyNatRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyNatRuleCollectionGroupGet.json // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -211,28 +319,20 @@ public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroup() // invoke the operation string ruleCollectionGroupName = "ruleCollectionGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionGroupName); - FirewallPolicyRuleCollectionGroupResource result = response.HasValue ? response.Value : null; + FirewallPolicyRuleCollectionGroupResource result = await collection.GetAsync(ruleCollectionGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicyRuleCollectionGroupWithIpGroups() + public async Task Get_GetFirewallPolicyRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupGet.json // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -252,7 +352,7 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroupWithIpGroups() FirewallPolicyRuleCollectionGroupCollection collection = firewallPolicy.GetFirewallPolicyRuleCollectionGroups(); // invoke the operation - string ruleCollectionGroupName = "ruleGroup1"; + string ruleCollectionGroupName = "ruleCollectionGroup1"; FirewallPolicyRuleCollectionGroupResource result = await collection.GetAsync(ruleCollectionGroupName); // the variable result is a resource, you could call other operations on this instance as well @@ -264,7 +364,7 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroupWithIpGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFirewallPolicyRuleCollectionGroupWithIpGroups() + public async Task Get_GetFirewallPolicyRuleCollectionGroupWithIpGroups() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsGet.json // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -287,16 +387,20 @@ public async Task Exists_GetFirewallPolicyRuleCollectionGroupWithIpGroups() // invoke the operation string ruleCollectionGroupName = "ruleGroup1"; - bool result = await collection.ExistsAsync(ruleCollectionGroupName); + FirewallPolicyRuleCollectionGroupResource result = await collection.GetAsync(ruleCollectionGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroupWithIpGroups() + public async Task Get_GetFirewallPolicyRuleCollectionGroupWithWebCategories() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesGet.json // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -306,7 +410,7 @@ public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroupWithIpGroups() // this example assumes you already have this FirewallPolicyResource created on azure // for more information of creating FirewallPolicyResource, please refer to the document of FirewallPolicyResource - string subscriptionId = "subid"; + string subscriptionId = "e747cc13-97d4-4a79-b463-42d7f4e558f2"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; ResourceIdentifier firewallPolicyResourceId = FirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallPolicyName); @@ -316,30 +420,22 @@ public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroupWithIpGroups() FirewallPolicyRuleCollectionGroupCollection collection = firewallPolicy.GetFirewallPolicyRuleCollectionGroups(); // invoke the operation - string ruleCollectionGroupName = "ruleGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionGroupName); - FirewallPolicyRuleCollectionGroupResource result = response.HasValue ? response.Value : null; + string ruleCollectionGroupName = "ruleCollectionGroup1"; + FirewallPolicyRuleCollectionGroupResource result = await collection.GetAsync(ruleCollectionGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicyRuleCollectionGroupWithWebCategories() + public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupWithWebCategories() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesGet.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesList.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -357,23 +453,25 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroupWithWebCategories() // get the collection of this FirewallPolicyRuleCollectionGroupResource FirewallPolicyRuleCollectionGroupCollection collection = firewallPolicy.GetFirewallPolicyRuleCollectionGroups(); - // invoke the operation - string ruleCollectionGroupName = "ruleCollectionGroup1"; - FirewallPolicyRuleCollectionGroupResource result = await collection.GetAsync(ruleCollectionGroupName); + // invoke the operation and iterate over the result + await foreach (FirewallPolicyRuleCollectionGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFirewallPolicyRuleCollectionGroupWithWebCategories() + public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupsForAGivenFirewallPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesGet.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupList.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -382,7 +480,7 @@ public async Task Exists_GetFirewallPolicyRuleCollectionGroupWithWebCategories() // this example assumes you already have this FirewallPolicyResource created on azure // for more information of creating FirewallPolicyResource, please refer to the document of FirewallPolicyResource - string subscriptionId = "e747cc13-97d4-4a79-b463-42d7f4e558f2"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; ResourceIdentifier firewallPolicyResourceId = FirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallPolicyName); @@ -391,19 +489,25 @@ public async Task Exists_GetFirewallPolicyRuleCollectionGroupWithWebCategories() // get the collection of this FirewallPolicyRuleCollectionGroupResource FirewallPolicyRuleCollectionGroupCollection collection = firewallPolicy.GetFirewallPolicyRuleCollectionGroups(); - // invoke the operation - string ruleCollectionGroupName = "ruleCollectionGroup1"; - bool result = await collection.ExistsAsync(ruleCollectionGroupName); + // invoke the operation and iterate over the result + await foreach (FirewallPolicyRuleCollectionGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroupWithWebCategories() + public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupsWithIpGroupsForAGivenFirewallPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesGet.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsList.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -412,7 +516,7 @@ public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroupWithWebCategor // this example assumes you already have this FirewallPolicyResource created on azure // for more information of creating FirewallPolicyResource, please refer to the document of FirewallPolicyResource - string subscriptionId = "e747cc13-97d4-4a79-b463-42d7f4e558f2"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; ResourceIdentifier firewallPolicyResourceId = FirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallPolicyName); @@ -421,31 +525,25 @@ public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroupWithWebCategor // get the collection of this FirewallPolicyRuleCollectionGroupResource FirewallPolicyRuleCollectionGroupCollection collection = firewallPolicy.GetFirewallPolicyRuleCollectionGroups(); - // invoke the operation - string ruleCollectionGroupName = "ruleCollectionGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionGroupName); - FirewallPolicyRuleCollectionGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (FirewallPolicyRuleCollectionGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; + FirewallPolicyRuleCollectionGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFirewallPolicyNatRuleCollectionGroup() + public async Task Exists_GetFirewallPolicyNatRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyNatRuleCollectionGroupPut.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyNatRuleCollectionGroupGet.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -465,63 +563,17 @@ public async Task CreateOrUpdate_CreateFirewallPolicyNatRuleCollectionGroup() // invoke the operation string ruleCollectionGroupName = "ruleCollectionGroup1"; - FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData() - { - Priority = 100, - RuleCollections = -{ -new FirewallPolicyNatRuleCollectionInfo() -{ -ActionType = FirewallPolicyNatRuleCollectionActionType.Dnat, -Rules = -{ -new NatRule() -{ -IPProtocols = -{ -FirewallPolicyRuleNetworkProtocol.Tcp,FirewallPolicyRuleNetworkProtocol.Udp -}, -SourceAddresses = -{ -"2.2.2.2" -}, -DestinationAddresses = -{ -"152.23.32.23" -}, -DestinationPorts = -{ -"8080" -}, -TranslatedPort = "8080", -SourceIPGroups = -{ -}, -TranslatedFqdn = "internalhttp.server.net", -Name = "nat-rule1", -} -}, -Name = "Example-Nat-Rule-Collection", -Priority = 100, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionGroupName, data); - FirewallPolicyRuleCollectionGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(ruleCollectionGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroup() + public async Task Exists_GetFirewallPolicyRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupPut.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupGet.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -541,58 +593,17 @@ public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroup() // invoke the operation string ruleCollectionGroupName = "ruleCollectionGroup1"; - FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData() - { - Priority = 100, - RuleCollections = -{ -new FirewallPolicyFilterRuleCollectionInfo() -{ -ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, -Rules = -{ -new NetworkRule() -{ -IPProtocols = -{ -FirewallPolicyRuleNetworkProtocol.Tcp -}, -SourceAddresses = -{ -"10.1.25.0/24" -}, -DestinationAddresses = -{ -"*" -}, -DestinationPorts = -{ -"*" -}, -Name = "network-rule1", -} -}, -Name = "Example-Filter-Rule-Collection", -Priority = 100, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionGroupName, data); - FirewallPolicyRuleCollectionGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(ruleCollectionGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroupWithIPGroups() + public async Task Exists_GetFirewallPolicyRuleCollectionGroupWithIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsPut.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsGet.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -611,58 +622,18 @@ public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroupWithIPGr FirewallPolicyRuleCollectionGroupCollection collection = firewallPolicy.GetFirewallPolicyRuleCollectionGroups(); // invoke the operation - string ruleCollectionGroupName = "ruleCollectionGroup1"; - FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData() - { - Priority = 110, - RuleCollections = -{ -new FirewallPolicyFilterRuleCollectionInfo() -{ -ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, -Rules = -{ -new NetworkRule() -{ -IPProtocols = -{ -FirewallPolicyRuleNetworkProtocol.Tcp -}, -DestinationPorts = -{ -"*" -}, -SourceIPGroups = -{ -"/subscriptions/subid/providers/Microsoft.Network/resourceGroup/rg1/ipGroups/ipGroups1" -}, -DestinationIPGroups = -{ -"/subscriptions/subid/providers/Microsoft.Network/resourceGroup/rg1/ipGroups/ipGroups2" -}, -Name = "network-1", -} -}, -Name = "Example-Filter-Rule-Collection", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionGroupName, data); - FirewallPolicyRuleCollectionGroupResource result = lro.Value; + string ruleCollectionGroupName = "ruleGroup1"; + bool result = await collection.ExistsAsync(ruleCollectionGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroupWithWebCategories() + public async Task Exists_GetFirewallPolicyRuleCollectionGroupWithWebCategories() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesPut.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesGet.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -682,58 +653,17 @@ public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroupWithWebC // invoke the operation string ruleCollectionGroupName = "ruleCollectionGroup1"; - FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData() - { - Priority = 110, - RuleCollections = -{ -new FirewallPolicyFilterRuleCollectionInfo() -{ -ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, -Rules = -{ -new ApplicationRule() -{ -SourceAddresses = -{ -"216.58.216.164","10.0.0.0/24" -}, -Protocols = -{ -new FirewallPolicyRuleApplicationProtocol() -{ -ProtocolType = FirewallPolicyRuleApplicationProtocolType.Https, -Port = 443, -} -}, -WebCategories = -{ -"Hacking" -}, -Name = "rule1", -Description = "Deny inbound rule", -} -}, -Name = "Example-Filter-Rule-Collection", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionGroupName, data); - FirewallPolicyRuleCollectionGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(ruleCollectionGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroupWithHttpHeaderToInsert() + public async Task GetIfExists_GetFirewallPolicyNatRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithHttpHeadersToInsert.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyNatRuleCollectionGroupGet.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -742,7 +672,7 @@ public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroupWithHttp // this example assumes you already have this FirewallPolicyResource created on azure // for more information of creating FirewallPolicyResource, please refer to the document of FirewallPolicyResource - string subscriptionId = "e747cc13-97d4-4a79-b463-42d7f4e558f2"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; ResourceIdentifier firewallPolicyResourceId = FirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallPolicyName); @@ -753,66 +683,29 @@ public async Task CreateOrUpdate_CreateFirewallPolicyRuleCollectionGroupWithHttp // invoke the operation string ruleCollectionGroupName = "ruleCollectionGroup1"; - FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData() - { - Priority = 110, - RuleCollections = -{ -new FirewallPolicyFilterRuleCollectionInfo() -{ -ActionType = FirewallPolicyFilterRuleCollectionActionType.Allow, -Rules = -{ -new ApplicationRule() -{ -SourceAddresses = -{ -"216.58.216.164","10.0.0.0/24" -}, -Protocols = -{ -new FirewallPolicyRuleApplicationProtocol() -{ -ProtocolType = FirewallPolicyRuleApplicationProtocolType.Http, -Port = 80, -} -}, -FqdnTags = -{ -"WindowsVirtualDesktop" -}, -HttpHeadersToInsert = -{ -new FirewallPolicyHttpHeaderToInsert() -{ -HeaderName = "Restrict-Access-To-Tenants", -HeaderValue = "contoso.com,fabrikam.onmicrosoft.com", -} -}, -Name = "rule1", -Description = "Insert trusted tenants header", -} -}, -Name = "Example-Filter-Rule-Collection", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionGroupName, data); - FirewallPolicyRuleCollectionGroupResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionGroupName); + FirewallPolicyRuleCollectionGroupResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupWithWebCategories() + public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesList.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupGet.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -821,7 +714,7 @@ public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupWithWebCategori // this example assumes you already have this FirewallPolicyResource created on azure // for more information of creating FirewallPolicyResource, please refer to the document of FirewallPolicyResource - string subscriptionId = "e747cc13-97d4-4a79-b463-42d7f4e558f2"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; ResourceIdentifier firewallPolicyResourceId = FirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallPolicyName); @@ -830,25 +723,31 @@ public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupWithWebCategori // get the collection of this FirewallPolicyRuleCollectionGroupResource FirewallPolicyRuleCollectionGroupCollection collection = firewallPolicy.GetFirewallPolicyRuleCollectionGroups(); - // invoke the operation and iterate over the result - await foreach (FirewallPolicyRuleCollectionGroupResource item in collection.GetAllAsync()) + // invoke the operation + string ruleCollectionGroupName = "ruleCollectionGroup1"; + NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionGroupName); + FirewallPolicyRuleCollectionGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = item.Data; + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupsForAGivenFirewallPolicy() + public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroupWithIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupList.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsGet.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -866,25 +765,31 @@ public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupsForAGivenFirew // get the collection of this FirewallPolicyRuleCollectionGroupResource FirewallPolicyRuleCollectionGroupCollection collection = firewallPolicy.GetFirewallPolicyRuleCollectionGroups(); - // invoke the operation and iterate over the result - await foreach (FirewallPolicyRuleCollectionGroupResource item in collection.GetAllAsync()) + // invoke the operation + string ruleCollectionGroupName = "ruleGroup1"; + NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionGroupName); + FirewallPolicyRuleCollectionGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = item.Data; + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupsWithIpGroupsForAGivenFirewallPolicy() + public async Task GetIfExists_GetFirewallPolicyRuleCollectionGroupWithWebCategories() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsList.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesGet.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -893,7 +798,7 @@ public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupsWithIpGroupsFo // this example assumes you already have this FirewallPolicyResource created on azure // for more information of creating FirewallPolicyResource, please refer to the document of FirewallPolicyResource - string subscriptionId = "subid"; + string subscriptionId = "e747cc13-97d4-4a79-b463-42d7f4e558f2"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; ResourceIdentifier firewallPolicyResourceId = FirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallPolicyName); @@ -902,17 +807,23 @@ public async Task GetAll_ListAllFirewallPolicyRuleCollectionGroupsWithIpGroupsFo // get the collection of this FirewallPolicyRuleCollectionGroupResource FirewallPolicyRuleCollectionGroupCollection collection = firewallPolicy.GetFirewallPolicyRuleCollectionGroups(); - // invoke the operation and iterate over the result - await foreach (FirewallPolicyRuleCollectionGroupResource item in collection.GetAllAsync()) + // invoke the operation + string ruleCollectionGroupName = "ruleCollectionGroup1"; + NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionGroupName); + FirewallPolicyRuleCollectionGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = item.Data; + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupDraftResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupDraftResource.cs index cc80d8acbe298..ea30c85a83b81 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupDraftResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupDraftResource.cs @@ -18,10 +18,10 @@ public partial class Sample_FirewallPolicyRuleCollectionGroupDraftResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteFirewallRuleCollectionGroupDraft() + public async Task Get_GetRuleCollectionGroupDraft() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupDraftDelete.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroupDrafts_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupDraftGet.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroupDrafts_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteFirewallRuleCollectionGroupDraft() FirewallPolicyRuleCollectionGroupDraftResource firewallPolicyRuleCollectionGroupDraft = client.GetFirewallPolicyRuleCollectionGroupDraftResource(firewallPolicyRuleCollectionGroupDraftResourceId); // invoke the operation - await firewallPolicyRuleCollectionGroupDraft.DeleteAsync(WaitUntil.Completed); + FirewallPolicyRuleCollectionGroupDraftResource result = await firewallPolicyRuleCollectionGroupDraft.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupDraftData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateRuleCollectionGroupDraft() + public async Task Delete_DeleteFirewallRuleCollectionGroupDraft() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupDraftPut.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroupDrafts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupDraftDelete.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroupDrafts_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,58 +69,17 @@ public async Task CreateOrUpdate_CreateOrUpdateRuleCollectionGroupDraft() FirewallPolicyRuleCollectionGroupDraftResource firewallPolicyRuleCollectionGroupDraft = client.GetFirewallPolicyRuleCollectionGroupDraftResource(firewallPolicyRuleCollectionGroupDraftResourceId); // invoke the operation - FirewallPolicyRuleCollectionGroupDraftData data = new FirewallPolicyRuleCollectionGroupDraftData() - { - Priority = 100, - RuleCollections = -{ -new FirewallPolicyFilterRuleCollectionInfo() -{ -ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, -Rules = -{ -new NetworkRule() -{ -IPProtocols = -{ -FirewallPolicyRuleNetworkProtocol.Tcp -}, -SourceAddresses = -{ -"10.1.25.0/24" -}, -DestinationAddresses = -{ -"*" -}, -DestinationPorts = -{ -"*" -}, -Name = "network-rule1", -} -}, -Name = "Example-Filter-Rule-Collection", -Priority = 100, -} -}, - }; - ArmOperation lro = await firewallPolicyRuleCollectionGroupDraft.CreateOrUpdateAsync(WaitUntil.Completed, data); - FirewallPolicyRuleCollectionGroupDraftResource result = lro.Value; + await firewallPolicyRuleCollectionGroupDraft.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupDraftData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRuleCollectionGroupDraft() + public async Task CreateOrUpdate_CreateOrUpdateRuleCollectionGroupDraft() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupDraftGet.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroupDrafts_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupDraftPut.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroupDrafts_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -133,7 +96,26 @@ public async Task Get_GetRuleCollectionGroupDraft() FirewallPolicyRuleCollectionGroupDraftResource firewallPolicyRuleCollectionGroupDraft = client.GetFirewallPolicyRuleCollectionGroupDraftResource(firewallPolicyRuleCollectionGroupDraftResourceId); // invoke the operation - FirewallPolicyRuleCollectionGroupDraftResource result = await firewallPolicyRuleCollectionGroupDraft.GetAsync(); + FirewallPolicyRuleCollectionGroupDraftData data = new FirewallPolicyRuleCollectionGroupDraftData + { + Priority = 100, + RuleCollections = {new FirewallPolicyFilterRuleCollectionInfo +{ +ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, +Rules = {new NetworkRule +{ +IPProtocols = {FirewallPolicyRuleNetworkProtocol.Tcp}, +SourceAddresses = {"10.1.25.0/24"}, +DestinationAddresses = {"*"}, +DestinationPorts = {"*"}, +Name = "network-rule1", +}}, +Name = "Example-Filter-Rule-Collection", +Priority = 100, +}}, + }; + ArmOperation lro = await firewallPolicyRuleCollectionGroupDraft.CreateOrUpdateAsync(WaitUntil.Completed, data); + FirewallPolicyRuleCollectionGroupDraftResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupResource.cs index 26162668b0256..f4e629c8b1e80 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FirewallPolicyRuleCollectionGroupResource.cs @@ -18,10 +18,10 @@ public partial class Sample_FirewallPolicyRuleCollectionGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteFirewallPolicyRuleCollectionGroup() + public async Task Get_GetFirewallPolicyNatRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupDelete.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyNatRuleCollectionGroupGet.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,20 @@ public async Task Delete_DeleteFirewallPolicyRuleCollectionGroup() FirewallPolicyRuleCollectionGroupResource firewallPolicyRuleCollectionGroup = client.GetFirewallPolicyRuleCollectionGroupResource(firewallPolicyRuleCollectionGroupResourceId); // invoke the operation - await firewallPolicyRuleCollectionGroup.DeleteAsync(WaitUntil.Completed); + FirewallPolicyRuleCollectionGroupResource result = await firewallPolicyRuleCollectionGroup.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyRuleCollectionGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicyNatRuleCollectionGroup() + public async Task Get_GetFirewallPolicyRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyNatRuleCollectionGroupGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupGet.json // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -76,9 +80,9 @@ public async Task Get_GetFirewallPolicyNatRuleCollectionGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicyRuleCollectionGroup() + public async Task Get_GetFirewallPolicyRuleCollectionGroupWithIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsGet.json // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -91,7 +95,7 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroup() string subscriptionId = "subid"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; - string ruleCollectionGroupName = "ruleCollectionGroup1"; + string ruleCollectionGroupName = "ruleGroup1"; ResourceIdentifier firewallPolicyRuleCollectionGroupResourceId = FirewallPolicyRuleCollectionGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallPolicyName, ruleCollectionGroupName); FirewallPolicyRuleCollectionGroupResource firewallPolicyRuleCollectionGroup = client.GetFirewallPolicyRuleCollectionGroupResource(firewallPolicyRuleCollectionGroupResourceId); @@ -107,9 +111,9 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicyRuleCollectionGroupWithIpGroups() + public async Task Get_GetFirewallPolicyRuleCollectionGroupWithWebCategories() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithIpGroupsGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesGet.json // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -119,10 +123,10 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroupWithIpGroups() // this example assumes you already have this FirewallPolicyRuleCollectionGroupResource created on azure // for more information of creating FirewallPolicyRuleCollectionGroupResource, please refer to the document of FirewallPolicyRuleCollectionGroupResource - string subscriptionId = "subid"; + string subscriptionId = "e747cc13-97d4-4a79-b463-42d7f4e558f2"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; - string ruleCollectionGroupName = "ruleGroup1"; + string ruleCollectionGroupName = "ruleCollectionGroup1"; ResourceIdentifier firewallPolicyRuleCollectionGroupResourceId = FirewallPolicyRuleCollectionGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, firewallPolicyName, ruleCollectionGroupName); FirewallPolicyRuleCollectionGroupResource firewallPolicyRuleCollectionGroup = client.GetFirewallPolicyRuleCollectionGroupResource(firewallPolicyRuleCollectionGroupResourceId); @@ -138,10 +142,10 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroupWithIpGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFirewallPolicyRuleCollectionGroupWithWebCategories() + public async Task Delete_DeleteFirewallPolicyRuleCollectionGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupWithWebCategoriesGet.json - // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyRuleCollectionGroupDelete.json + // this example is just showing the usage of "FirewallPolicyRuleCollectionGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,7 +154,7 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroupWithWebCategories() // this example assumes you already have this FirewallPolicyRuleCollectionGroupResource created on azure // for more information of creating FirewallPolicyRuleCollectionGroupResource, please refer to the document of FirewallPolicyRuleCollectionGroupResource - string subscriptionId = "e747cc13-97d4-4a79-b463-42d7f4e558f2"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; string firewallPolicyName = "firewallPolicy"; string ruleCollectionGroupName = "ruleCollectionGroup1"; @@ -158,13 +162,9 @@ public async Task Get_GetFirewallPolicyRuleCollectionGroupWithWebCategories() FirewallPolicyRuleCollectionGroupResource firewallPolicyRuleCollectionGroup = client.GetFirewallPolicyRuleCollectionGroupResource(firewallPolicyRuleCollectionGroupResourceId); // invoke the operation - FirewallPolicyRuleCollectionGroupResource result = await firewallPolicyRuleCollectionGroup.GetAsync(); + await firewallPolicyRuleCollectionGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FirewallPolicyRuleCollectionGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -189,46 +189,26 @@ public async Task Update_CreateFirewallPolicyNatRuleCollectionGroup() FirewallPolicyRuleCollectionGroupResource firewallPolicyRuleCollectionGroup = client.GetFirewallPolicyRuleCollectionGroupResource(firewallPolicyRuleCollectionGroupResourceId); // invoke the operation - FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData() + FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData { Priority = 100, - RuleCollections = -{ -new FirewallPolicyNatRuleCollectionInfo() + RuleCollections = {new FirewallPolicyNatRuleCollectionInfo { ActionType = FirewallPolicyNatRuleCollectionActionType.Dnat, -Rules = -{ -new NatRule() -{ -IPProtocols = -{ -FirewallPolicyRuleNetworkProtocol.Tcp,FirewallPolicyRuleNetworkProtocol.Udp -}, -SourceAddresses = +Rules = {new NatRule { -"2.2.2.2" -}, -DestinationAddresses = -{ -"152.23.32.23" -}, -DestinationPorts = -{ -"8080" -}, +IPProtocols = {FirewallPolicyRuleNetworkProtocol.Tcp, FirewallPolicyRuleNetworkProtocol.Udp}, +SourceAddresses = {"2.2.2.2"}, +DestinationAddresses = {"152.23.32.23"}, +DestinationPorts = {"8080"}, TranslatedPort = "8080", -SourceIPGroups = -{ -}, +SourceIPGroups = {}, TranslatedFqdn = "internalhttp.server.net", Name = "nat-rule1", -} -}, +}}, Name = "Example-Nat-Rule-Collection", Priority = 100, -} -}, +}}, }; ArmOperation lro = await firewallPolicyRuleCollectionGroup.UpdateAsync(WaitUntil.Completed, data); FirewallPolicyRuleCollectionGroupResource result = lro.Value; @@ -262,41 +242,23 @@ public async Task Update_CreateFirewallPolicyRuleCollectionGroup() FirewallPolicyRuleCollectionGroupResource firewallPolicyRuleCollectionGroup = client.GetFirewallPolicyRuleCollectionGroupResource(firewallPolicyRuleCollectionGroupResourceId); // invoke the operation - FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData() + FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData { Priority = 100, - RuleCollections = -{ -new FirewallPolicyFilterRuleCollectionInfo() + RuleCollections = {new FirewallPolicyFilterRuleCollectionInfo { ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, -Rules = +Rules = {new NetworkRule { -new NetworkRule() -{ -IPProtocols = -{ -FirewallPolicyRuleNetworkProtocol.Tcp -}, -SourceAddresses = -{ -"10.1.25.0/24" -}, -DestinationAddresses = -{ -"*" -}, -DestinationPorts = -{ -"*" -}, +IPProtocols = {FirewallPolicyRuleNetworkProtocol.Tcp}, +SourceAddresses = {"10.1.25.0/24"}, +DestinationAddresses = {"*"}, +DestinationPorts = {"*"}, Name = "network-rule1", -} -}, +}}, Name = "Example-Filter-Rule-Collection", Priority = 100, -} -}, +}}, }; ArmOperation lro = await firewallPolicyRuleCollectionGroup.UpdateAsync(WaitUntil.Completed, data); FirewallPolicyRuleCollectionGroupResource result = lro.Value; @@ -330,40 +292,22 @@ public async Task Update_CreateFirewallPolicyRuleCollectionGroupWithIPGroups() FirewallPolicyRuleCollectionGroupResource firewallPolicyRuleCollectionGroup = client.GetFirewallPolicyRuleCollectionGroupResource(firewallPolicyRuleCollectionGroupResourceId); // invoke the operation - FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData() + FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData { Priority = 110, - RuleCollections = -{ -new FirewallPolicyFilterRuleCollectionInfo() + RuleCollections = {new FirewallPolicyFilterRuleCollectionInfo { ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, -Rules = -{ -new NetworkRule() -{ -IPProtocols = -{ -FirewallPolicyRuleNetworkProtocol.Tcp -}, -DestinationPorts = +Rules = {new NetworkRule { -"*" -}, -SourceIPGroups = -{ -"/subscriptions/subid/providers/Microsoft.Network/resourceGroup/rg1/ipGroups/ipGroups1" -}, -DestinationIPGroups = -{ -"/subscriptions/subid/providers/Microsoft.Network/resourceGroup/rg1/ipGroups/ipGroups2" -}, +IPProtocols = {FirewallPolicyRuleNetworkProtocol.Tcp}, +DestinationPorts = {"*"}, +SourceIPGroups = {"/subscriptions/subid/providers/Microsoft.Network/resourceGroup/rg1/ipGroups/ipGroups1"}, +DestinationIPGroups = {"/subscriptions/subid/providers/Microsoft.Network/resourceGroup/rg1/ipGroups/ipGroups2"}, Name = "network-1", -} -}, +}}, Name = "Example-Filter-Rule-Collection", -} -}, +}}, }; ArmOperation lro = await firewallPolicyRuleCollectionGroup.UpdateAsync(WaitUntil.Completed, data); FirewallPolicyRuleCollectionGroupResource result = lro.Value; @@ -397,41 +341,26 @@ public async Task Update_CreateFirewallPolicyRuleCollectionGroupWithWebCategorie FirewallPolicyRuleCollectionGroupResource firewallPolicyRuleCollectionGroup = client.GetFirewallPolicyRuleCollectionGroupResource(firewallPolicyRuleCollectionGroupResourceId); // invoke the operation - FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData() + FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData { Priority = 110, - RuleCollections = -{ -new FirewallPolicyFilterRuleCollectionInfo() + RuleCollections = {new FirewallPolicyFilterRuleCollectionInfo { ActionType = FirewallPolicyFilterRuleCollectionActionType.Deny, -Rules = -{ -new ApplicationRule() +Rules = {new ApplicationRule { -SourceAddresses = -{ -"216.58.216.164","10.0.0.0/24" -}, -Protocols = -{ -new FirewallPolicyRuleApplicationProtocol() +SourceAddresses = {"216.58.216.164", "10.0.0.0/24"}, +Protocols = {new FirewallPolicyRuleApplicationProtocol { ProtocolType = FirewallPolicyRuleApplicationProtocolType.Https, Port = 443, -} -}, -WebCategories = -{ -"Hacking" -}, +}}, +WebCategories = {"Hacking"}, Name = "rule1", Description = "Deny inbound rule", -} -}, +}}, Name = "Example-Filter-Rule-Collection", -} -}, +}}, }; ArmOperation lro = await firewallPolicyRuleCollectionGroup.UpdateAsync(WaitUntil.Completed, data); FirewallPolicyRuleCollectionGroupResource result = lro.Value; @@ -465,49 +394,31 @@ public async Task Update_CreateFirewallPolicyRuleCollectionGroupWithHttpHeaderTo FirewallPolicyRuleCollectionGroupResource firewallPolicyRuleCollectionGroup = client.GetFirewallPolicyRuleCollectionGroupResource(firewallPolicyRuleCollectionGroupResourceId); // invoke the operation - FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData() + FirewallPolicyRuleCollectionGroupData data = new FirewallPolicyRuleCollectionGroupData { Priority = 110, - RuleCollections = -{ -new FirewallPolicyFilterRuleCollectionInfo() + RuleCollections = {new FirewallPolicyFilterRuleCollectionInfo { ActionType = FirewallPolicyFilterRuleCollectionActionType.Allow, -Rules = -{ -new ApplicationRule() +Rules = {new ApplicationRule { -SourceAddresses = -{ -"216.58.216.164","10.0.0.0/24" -}, -Protocols = -{ -new FirewallPolicyRuleApplicationProtocol() +SourceAddresses = {"216.58.216.164", "10.0.0.0/24"}, +Protocols = {new FirewallPolicyRuleApplicationProtocol { ProtocolType = FirewallPolicyRuleApplicationProtocolType.Http, Port = 80, -} -}, -FqdnTags = -{ -"WindowsVirtualDesktop" -}, -HttpHeadersToInsert = -{ -new FirewallPolicyHttpHeaderToInsert() +}}, +FqdnTags = {"WindowsVirtualDesktop"}, +HttpHeadersToInsert = {new FirewallPolicyHttpHeaderToInsert { HeaderName = "Restrict-Access-To-Tenants", HeaderValue = "contoso.com,fabrikam.onmicrosoft.com", -} -}, +}}, Name = "rule1", Description = "Insert trusted tenants header", -} -}, +}}, Name = "Example-Filter-Rule-Collection", -} -}, +}}, }; ArmOperation lro = await firewallPolicyRuleCollectionGroup.UpdateAsync(WaitUntil.Completed, data); FirewallPolicyRuleCollectionGroupResource result = lro.Value; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FlowLogCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FlowLogCollection.cs index dae21ae0ff9d7..44cebde66529a 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FlowLogCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FlowLogCollection.cs @@ -42,20 +42,20 @@ public async Task CreateOrUpdate_CreateOrUpdateFlowLog() // invoke the operation string flowLogName = "fl"; - FlowLogData data = new FlowLogData() + FlowLogData data = new FlowLogData { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() }, }, TargetResourceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkSecurityGroups/desmondcentral-nsg"), StorageId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Storage/storageAccounts/nwtest1mgvbfmqsigdxe"), EnabledFilteringCriteria = "srcIP=158.255.7.8 || dstPort=56891", Enabled = true, - Format = new FlowLogProperties() + Format = new FlowLogProperties { FormatType = FlowLogFormatType.Json, Version = 1, @@ -108,10 +108,10 @@ public async Task Get_GetFlowLog() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetFlowLog() + public async Task GetAll_ListConnectionMonitors() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogGet.json - // this example is just showing the usage of "FlowLogs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogList.json + // this example is just showing the usage of "FlowLogs_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -129,16 +129,22 @@ public async Task Exists_GetFlowLog() // get the collection of this FlowLogResource FlowLogCollection collection = networkWatcher.GetFlowLogs(); - // invoke the operation - string flowLogName = "flowLog1"; - bool result = await collection.ExistsAsync(flowLogName); + // invoke the operation and iterate over the result + await foreach (FlowLogResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FlowLogData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetFlowLog() + public async Task Exists_GetFlowLog() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogGet.json // this example is just showing the usage of "FlowLogs_Get" operation, for the dependent resources, they will have to be created separately. @@ -161,29 +167,17 @@ public async Task GetIfExists_GetFlowLog() // invoke the operation string flowLogName = "flowLog1"; - NullableResponse response = await collection.GetIfExistsAsync(flowLogName); - FlowLogResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(flowLogName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FlowLogData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListConnectionMonitors() + public async Task GetIfExists_GetFlowLog() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogList.json - // this example is just showing the usage of "FlowLogs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogGet.json + // this example is just showing the usage of "FlowLogs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -201,17 +195,23 @@ public async Task GetAll_ListConnectionMonitors() // get the collection of this FlowLogResource FlowLogCollection collection = networkWatcher.GetFlowLogs(); - // invoke the operation and iterate over the result - await foreach (FlowLogResource item in collection.GetAllAsync()) + // invoke the operation + string flowLogName = "flowLog1"; + NullableResponse response = await collection.GetIfExistsAsync(flowLogName); + FlowLogResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - FlowLogData resourceData = item.Data; + FlowLogData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FlowLogResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FlowLogResource.cs index a8ece5cf9e640..af61680664055 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FlowLogResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FlowLogResource.cs @@ -18,10 +18,10 @@ public partial class Sample_FlowLogResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateFlowLogTags() + public async Task Get_GetFlowLog() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogUpdateTags.json - // this example is just showing the usage of "FlowLogs_UpdateTags" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogGet.json + // this example is just showing the usage of "FlowLogs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -32,21 +32,13 @@ public async Task Update_UpdateFlowLogTags() // for more information of creating FlowLogResource, please refer to the document of FlowLogResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string networkWatcherName = "nw"; - string flowLogName = "fl"; + string networkWatcherName = "nw1"; + string flowLogName = "flowLog1"; ResourceIdentifier flowLogResourceId = FlowLogResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkWatcherName, flowLogName); FlowLogResource flowLog = client.GetFlowLogResource(flowLogResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - FlowLogResource result = await flowLog.UpdateAsync(networkTagsObject); + FlowLogResource result = await flowLog.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -57,10 +49,10 @@ public async Task Update_UpdateFlowLogTags() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetFlowLog() + public async Task Delete_DeleteFlowLog() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogGet.json - // this example is just showing the usage of "FlowLogs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogDelete.json + // this example is just showing the usage of "FlowLogs_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,26 +64,22 @@ public async Task Get_GetFlowLog() string subscriptionId = "subid"; string resourceGroupName = "rg1"; string networkWatcherName = "nw1"; - string flowLogName = "flowLog1"; + string flowLogName = "fl"; ResourceIdentifier flowLogResourceId = FlowLogResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkWatcherName, flowLogName); FlowLogResource flowLog = client.GetFlowLogResource(flowLogResourceId); // invoke the operation - FlowLogResource result = await flowLog.GetAsync(); + await flowLog.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FlowLogData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteFlowLog() + public async Task Update_UpdateFlowLogTags() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogDelete.json - // this example is just showing the usage of "FlowLogs_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherFlowLogUpdateTags.json + // this example is just showing the usage of "FlowLogs_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,15 +90,27 @@ public async Task Delete_DeleteFlowLog() // for more information of creating FlowLogResource, please refer to the document of FlowLogResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string networkWatcherName = "nw1"; + string networkWatcherName = "nw"; string flowLogName = "fl"; ResourceIdentifier flowLogResourceId = FlowLogResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkWatcherName, flowLogName); FlowLogResource flowLog = client.GetFlowLogResource(flowLogResourceId); // invoke the operation - await flowLog.DeleteAsync(WaitUntil.Completed); + NetworkTagsObject networkTagsObject = new NetworkTagsObject + { + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + FlowLogResource result = await flowLog.UpdateAsync(networkTagsObject); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FlowLogData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FrontendIPConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FrontendIPConfigurationCollection.cs index ba8c0b9ee5ba7..e6871cc2fa480 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FrontendIPConfigurationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_FrontendIPConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_FrontendIPConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LoadBalancerFrontendIPConfigurationList() + public async Task Get_LoadBalancerFrontendIPConfigurationGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerFrontendIPConfigurationList.json - // this example is just showing the usage of "LoadBalancerFrontendIPConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerFrontendIPConfigurationGet.json + // this example is just showing the usage of "LoadBalancerFrontendIPConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_LoadBalancerFrontendIPConfigurationList() // get the collection of this FrontendIPConfigurationResource FrontendIPConfigurationCollection collection = loadBalancer.GetFrontendIPConfigurations(); - // invoke the operation and iterate over the result - await foreach (FrontendIPConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontendIPConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string frontendIPConfigurationName = "frontend"; + FrontendIPConfigurationResource result = await collection.GetAsync(frontendIPConfigurationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontendIPConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LoadBalancerFrontendIPConfigurationGet() + public async Task GetAll_LoadBalancerFrontendIPConfigurationList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerFrontendIPConfigurationGet.json - // this example is just showing the usage of "LoadBalancerFrontendIPConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerFrontendIPConfigurationList.json + // this example is just showing the usage of "LoadBalancerFrontendIPConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_LoadBalancerFrontendIPConfigurationGet() // get the collection of this FrontendIPConfigurationResource FrontendIPConfigurationCollection collection = loadBalancer.GetFrontendIPConfigurations(); - // invoke the operation - string frontendIPConfigurationName = "frontend"; - FrontendIPConfigurationResource result = await collection.GetAsync(frontendIPConfigurationName); + // invoke the operation and iterate over the result + await foreach (FrontendIPConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FrontendIPConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - FrontendIPConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubIPConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubIPConfigurationCollection.cs index a929655821efa..1c11abc965195 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubIPConfigurationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubIPConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_HubIPConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualHubVirtualHubRouteTableV2Get() + public async Task CreateOrUpdate_VirtualHubIpConfigurationPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationGet.json - // this example is just showing the usage of "VirtualHubIpConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationPut.json + // this example is just showing the usage of "VirtualHubIpConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,15 @@ public async Task Get_VirtualHubVirtualHubRouteTableV2Get() // invoke the operation string ipConfigName = "ipconfig1"; - HubIPConfigurationResource result = await collection.GetAsync(ipConfigName); + HubIPConfigurationData data = new HubIPConfigurationData + { + Subnet = new SubnetData + { + Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ipConfigName, data); + HubIPConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +59,7 @@ public async Task Get_VirtualHubVirtualHubRouteTableV2Get() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualHubVirtualHubRouteTableV2Get() + public async Task Get_VirtualHubVirtualHubRouteTableV2Get() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationGet.json // this example is just showing the usage of "VirtualHubIpConfiguration_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +82,21 @@ public async Task Exists_VirtualHubVirtualHubRouteTableV2Get() // invoke the operation string ipConfigName = "ipconfig1"; - bool result = await collection.ExistsAsync(ipConfigName); + HubIPConfigurationResource result = await collection.GetAsync(ipConfigName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HubIPConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualHubVirtualHubRouteTableV2Get() + public async Task GetAll_VirtualHubRouteTableV2List() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationGet.json - // this example is just showing the usage of "VirtualHubIpConfiguration_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationList.json + // this example is just showing the usage of "VirtualHubIpConfiguration_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +114,25 @@ public async Task GetIfExists_VirtualHubVirtualHubRouteTableV2Get() // get the collection of this HubIPConfigurationResource HubIPConfigurationCollection collection = virtualHub.GetHubIPConfigurations(); - // invoke the operation - string ipConfigName = "ipconfig1"; - NullableResponse response = await collection.GetIfExistsAsync(ipConfigName); - HubIPConfigurationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (HubIPConfigurationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HubIPConfigurationData resourceData = result.Data; + HubIPConfigurationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VirtualHubIpConfigurationPut() + public async Task Exists_VirtualHubVirtualHubRouteTableV2Get() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationPut.json - // this example is just showing the usage of "VirtualHubIpConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationGet.json + // this example is just showing the usage of "VirtualHubIpConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,29 +152,17 @@ public async Task CreateOrUpdate_VirtualHubIpConfigurationPut() // invoke the operation string ipConfigName = "ipconfig1"; - HubIPConfigurationData data = new HubIPConfigurationData() - { - Subnet = new SubnetData() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ipConfigName, data); - HubIPConfigurationResource result = lro.Value; + bool result = await collection.ExistsAsync(ipConfigName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HubIPConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualHubRouteTableV2List() + public async Task GetIfExists_VirtualHubVirtualHubRouteTableV2Get() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationList.json - // this example is just showing the usage of "VirtualHubIpConfiguration_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationGet.json + // this example is just showing the usage of "VirtualHubIpConfiguration_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_VirtualHubRouteTableV2List() // get the collection of this HubIPConfigurationResource HubIPConfigurationCollection collection = virtualHub.GetHubIPConfigurations(); - // invoke the operation and iterate over the result - await foreach (HubIPConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string ipConfigName = "ipconfig1"; + NullableResponse response = await collection.GetIfExistsAsync(ipConfigName); + HubIPConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HubIPConfigurationData resourceData = item.Data; + HubIPConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubIPConfigurationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubIPConfigurationResource.cs index ed88f60917899..451363a3b8157 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubIPConfigurationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubIPConfigurationResource.cs @@ -48,10 +48,10 @@ public async Task Get_VirtualHubVirtualHubRouteTableV2Get() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VirtualHubIpConfigurationPut() + public async Task Delete_VirtualHubIpConfigurationDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationPut.json - // this example is just showing the usage of "VirtualHubIpConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationDelete.json + // this example is just showing the usage of "VirtualHubIpConfiguration_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +68,17 @@ public async Task Update_VirtualHubIpConfigurationPut() HubIPConfigurationResource hubIPConfiguration = client.GetHubIPConfigurationResource(hubIPConfigurationResourceId); // invoke the operation - HubIPConfigurationData data = new HubIPConfigurationData() - { - Subnet = new SubnetData() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), - }, - }; - ArmOperation lro = await hubIPConfiguration.UpdateAsync(WaitUntil.Completed, data); - HubIPConfigurationResource result = lro.Value; + await hubIPConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HubIPConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VirtualHubIpConfigurationDelete() + public async Task Update_VirtualHubIpConfigurationPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationDelete.json - // this example is just showing the usage of "VirtualHubIpConfiguration_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubIpConfigurationPut.json + // this example is just showing the usage of "VirtualHubIpConfiguration_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +95,21 @@ public async Task Delete_VirtualHubIpConfigurationDelete() HubIPConfigurationResource hubIPConfiguration = client.GetHubIPConfigurationResource(hubIPConfigurationResourceId); // invoke the operation - await hubIPConfiguration.DeleteAsync(WaitUntil.Completed); + HubIPConfigurationData data = new HubIPConfigurationData + { + Subnet = new SubnetData + { + Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/subnet1"), + }, + }; + ArmOperation lro = await hubIPConfiguration.UpdateAsync(WaitUntil.Completed, data); + HubIPConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HubIPConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubRouteTableCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubRouteTableCollection.cs index c266a31d97a6c..cfedd6d54b95d 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubRouteTableCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubRouteTableCollection.cs @@ -41,19 +41,10 @@ public async Task CreateOrUpdate_RouteTablePut() // invoke the operation string routeTableName = "hubRouteTable1"; - HubRouteTableData data = new HubRouteTableData() + HubRouteTableData data = new HubRouteTableData { - Routes = -{ -new HubRoute("route1","CIDR",new string[] -{ -"10.0.0.0/8","20.0.0.0/8","30.0.0.0/8" -},"ResourceId","/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azureFirewall1") -}, - Labels = -{ -"label1","label2" -}, + Routes = { new HubRoute("route1", "CIDR", new string[] { "10.0.0.0/8", "20.0.0.0/8", "30.0.0.0/8" }, "ResourceId", "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azureFirewall1") }, + Labels = { "label1", "label2" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeTableName, data); HubRouteTableResource result = lro.Value; @@ -101,10 +92,10 @@ public async Task Get_RouteTableGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RouteTableGet() + public async Task GetAll_RouteTableList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTableGet.json - // this example is just showing the usage of "HubRouteTables_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTableList.json + // this example is just showing the usage of "HubRouteTables_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -122,16 +113,22 @@ public async Task Exists_RouteTableGet() // get the collection of this HubRouteTableResource HubRouteTableCollection collection = virtualHub.GetHubRouteTables(); - // invoke the operation - string routeTableName = "hubRouteTable1"; - bool result = await collection.ExistsAsync(routeTableName); + // invoke the operation and iterate over the result + await foreach (HubRouteTableResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HubRouteTableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RouteTableGet() + public async Task Exists_RouteTableGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTableGet.json // this example is just showing the usage of "HubRouteTables_Get" operation, for the dependent resources, they will have to be created separately. @@ -154,29 +151,17 @@ public async Task GetIfExists_RouteTableGet() // invoke the operation string routeTableName = "hubRouteTable1"; - NullableResponse response = await collection.GetIfExistsAsync(routeTableName); - HubRouteTableResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(routeTableName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HubRouteTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RouteTableList() + public async Task GetIfExists_RouteTableGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTableList.json - // this example is just showing the usage of "HubRouteTables_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTableGet.json + // this example is just showing the usage of "HubRouteTables_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -194,17 +179,23 @@ public async Task GetAll_RouteTableList() // get the collection of this HubRouteTableResource HubRouteTableCollection collection = virtualHub.GetHubRouteTables(); - // invoke the operation and iterate over the result - await foreach (HubRouteTableResource item in collection.GetAllAsync()) + // invoke the operation + string routeTableName = "hubRouteTable1"; + NullableResponse response = await collection.GetIfExistsAsync(routeTableName); + HubRouteTableResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HubRouteTableData resourceData = item.Data; + HubRouteTableData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubRouteTableResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubRouteTableResource.cs index e55d1f616b7f2..1b141b743c86a 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubRouteTableResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubRouteTableResource.cs @@ -18,10 +18,10 @@ public partial class Sample_HubRouteTableResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RouteTablePut() + public async Task Get_RouteTableGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTablePut.json - // this example is just showing the usage of "HubRouteTables_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTableGet.json + // this example is just showing the usage of "HubRouteTables_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,22 +38,7 @@ public async Task Update_RouteTablePut() HubRouteTableResource hubRouteTable = client.GetHubRouteTableResource(hubRouteTableResourceId); // invoke the operation - HubRouteTableData data = new HubRouteTableData() - { - Routes = -{ -new HubRoute("route1","CIDR",new string[] -{ -"10.0.0.0/8","20.0.0.0/8","30.0.0.0/8" -},"ResourceId","/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azureFirewall1") -}, - Labels = -{ -"label1","label2" -}, - }; - ArmOperation lro = await hubRouteTable.UpdateAsync(WaitUntil.Completed, data); - HubRouteTableResource result = lro.Value; + HubRouteTableResource result = await hubRouteTable.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -64,10 +49,10 @@ public async Task Update_RouteTablePut() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RouteTableGet() + public async Task Delete_RouteTableDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTableGet.json - // this example is just showing the usage of "HubRouteTables_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTableDelete.json + // this example is just showing the usage of "HubRouteTables_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -84,21 +69,17 @@ public async Task Get_RouteTableGet() HubRouteTableResource hubRouteTable = client.GetHubRouteTableResource(hubRouteTableResourceId); // invoke the operation - HubRouteTableResource result = await hubRouteTable.GetAsync(); + await hubRouteTable.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HubRouteTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RouteTableDelete() + public async Task Update_RouteTablePut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTableDelete.json - // this example is just showing the usage of "HubRouteTables_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubRouteTablePut.json + // this example is just showing the usage of "HubRouteTables_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,9 +96,19 @@ public async Task Delete_RouteTableDelete() HubRouteTableResource hubRouteTable = client.GetHubRouteTableResource(hubRouteTableResourceId); // invoke the operation - await hubRouteTable.DeleteAsync(WaitUntil.Completed); + HubRouteTableData data = new HubRouteTableData + { + Routes = { new HubRoute("route1", "CIDR", new string[] { "10.0.0.0/8", "20.0.0.0/8", "30.0.0.0/8" }, "ResourceId", "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azureFirewall1") }, + Labels = { "label1", "label2" }, + }; + ArmOperation lro = await hubRouteTable.UpdateAsync(WaitUntil.Completed, data); + HubRouteTableResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HubRouteTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubVirtualNetworkConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubVirtualNetworkConnectionCollection.cs index 61ee42bc8fedf..6a92cb50eb46c 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubVirtualNetworkConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubVirtualNetworkConnectionCollection.cs @@ -42,53 +42,38 @@ public async Task CreateOrUpdate_HubVirtualNetworkConnectionPut() // invoke the operation string connectionName = "connection1"; - HubVirtualNetworkConnectionData data = new HubVirtualNetworkConnectionData() + HubVirtualNetworkConnectionData data = new HubVirtualNetworkConnectionData { RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/SpokeVnet1"), EnableInternetSecurity = false, - RoutingConfiguration = new RoutingConfiguration() + RoutingConfiguration = new RoutingConfiguration { AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), - PropagatedRouteTables = new PropagatedRouteTable() + PropagatedRouteTables = new PropagatedRouteTable { - Labels = -{ -"label1","label2" -}, - Ids = -{ -new WritableSubResource() + Labels = { "label1", "label2" }, + Ids = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), -} -}, +}}, }, - VnetRoutes = new VnetRoute() + VnetRoutes = new VnetRoute { - StaticRoutesConfig = new StaticRoutesConfig() + StaticRoutesConfig = new StaticRoutesConfig { VnetLocalRouteOverrideCriteria = VnetLocalRouteOverrideCriterion.Equal, }, - StaticRoutes = -{ -new StaticRoute() + StaticRoutes = {new StaticRoute { Name = "route1", -AddressPrefixes = -{ -"10.1.0.0/16","10.2.0.0/16" -}, +AddressPrefixes = {"10.1.0.0/16", "10.2.0.0/16"}, NextHopIPAddress = "10.0.0.68", -},new StaticRoute() +}, new StaticRoute { Name = "route2", -AddressPrefixes = -{ -"10.3.0.0/16","10.4.0.0/16" -}, +AddressPrefixes = {"10.3.0.0/16", "10.4.0.0/16"}, NextHopIPAddress = "10.0.0.65", -} -}, +}}, }, InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), @@ -140,10 +125,10 @@ public async Task Get_HubVirtualNetworkConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_HubVirtualNetworkConnectionGet() + public async Task GetAll_HubVirtualNetworkConnectionList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubVirtualNetworkConnectionGet.json - // this example is just showing the usage of "HubVirtualNetworkConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubVirtualNetworkConnectionList.json + // this example is just showing the usage of "HubVirtualNetworkConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -161,16 +146,22 @@ public async Task Exists_HubVirtualNetworkConnectionGet() // get the collection of this HubVirtualNetworkConnectionResource HubVirtualNetworkConnectionCollection collection = virtualHub.GetHubVirtualNetworkConnections(); - // invoke the operation - string connectionName = "connection1"; - bool result = await collection.ExistsAsync(connectionName); + // invoke the operation and iterate over the result + await foreach (HubVirtualNetworkConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + HubVirtualNetworkConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_HubVirtualNetworkConnectionGet() + public async Task Exists_HubVirtualNetworkConnectionGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubVirtualNetworkConnectionGet.json // this example is just showing the usage of "HubVirtualNetworkConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -193,29 +184,17 @@ public async Task GetIfExists_HubVirtualNetworkConnectionGet() // invoke the operation string connectionName = "connection1"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - HubVirtualNetworkConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(connectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - HubVirtualNetworkConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_HubVirtualNetworkConnectionList() + public async Task GetIfExists_HubVirtualNetworkConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubVirtualNetworkConnectionList.json - // this example is just showing the usage of "HubVirtualNetworkConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubVirtualNetworkConnectionGet.json + // this example is just showing the usage of "HubVirtualNetworkConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -233,17 +212,23 @@ public async Task GetAll_HubVirtualNetworkConnectionList() // get the collection of this HubVirtualNetworkConnectionResource HubVirtualNetworkConnectionCollection collection = virtualHub.GetHubVirtualNetworkConnections(); - // invoke the operation and iterate over the result - await foreach (HubVirtualNetworkConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string connectionName = "connection1"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + HubVirtualNetworkConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - HubVirtualNetworkConnectionData resourceData = item.Data; + HubVirtualNetworkConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubVirtualNetworkConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubVirtualNetworkConnectionResource.cs index 8574e9c19cf74..38f78f05eb828 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubVirtualNetworkConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_HubVirtualNetworkConnectionResource.cs @@ -19,10 +19,10 @@ public partial class Sample_HubVirtualNetworkConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_HubVirtualNetworkConnectionPut() + public async Task Get_HubVirtualNetworkConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubVirtualNetworkConnectionPut.json - // this example is just showing the usage of "HubVirtualNetworkConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubVirtualNetworkConnectionGet.json + // this example is just showing the usage of "HubVirtualNetworkConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,60 +39,7 @@ public async Task Update_HubVirtualNetworkConnectionPut() HubVirtualNetworkConnectionResource hubVirtualNetworkConnection = client.GetHubVirtualNetworkConnectionResource(hubVirtualNetworkConnectionResourceId); // invoke the operation - HubVirtualNetworkConnectionData data = new HubVirtualNetworkConnectionData() - { - RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/SpokeVnet1"), - EnableInternetSecurity = false, - RoutingConfiguration = new RoutingConfiguration() - { - AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), - PropagatedRouteTables = new PropagatedRouteTable() - { - Labels = -{ -"label1","label2" -}, - Ids = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), -} -}, - }, - VnetRoutes = new VnetRoute() - { - StaticRoutesConfig = new StaticRoutesConfig() - { - VnetLocalRouteOverrideCriteria = VnetLocalRouteOverrideCriterion.Equal, - }, - StaticRoutes = -{ -new StaticRoute() -{ -Name = "route1", -AddressPrefixes = -{ -"10.1.0.0/16","10.2.0.0/16" -}, -NextHopIPAddress = "10.0.0.68", -},new StaticRoute() -{ -Name = "route2", -AddressPrefixes = -{ -"10.3.0.0/16","10.4.0.0/16" -}, -NextHopIPAddress = "10.0.0.65", -} -}, - }, - InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), - OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), - }, - }; - ArmOperation lro = await hubVirtualNetworkConnection.UpdateAsync(WaitUntil.Completed, data); - HubVirtualNetworkConnectionResource result = lro.Value; + HubVirtualNetworkConnectionResource result = await hubVirtualNetworkConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -130,10 +77,10 @@ public async Task Delete_HubVirtualNetworkConnectionDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_HubVirtualNetworkConnectionGet() + public async Task Update_HubVirtualNetworkConnectionPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubVirtualNetworkConnectionGet.json - // this example is just showing the usage of "HubVirtualNetworkConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/HubVirtualNetworkConnectionPut.json + // this example is just showing the usage of "HubVirtualNetworkConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,7 +97,45 @@ public async Task Get_HubVirtualNetworkConnectionGet() HubVirtualNetworkConnectionResource hubVirtualNetworkConnection = client.GetHubVirtualNetworkConnectionResource(hubVirtualNetworkConnectionResourceId); // invoke the operation - HubVirtualNetworkConnectionResource result = await hubVirtualNetworkConnection.GetAsync(); + HubVirtualNetworkConnectionData data = new HubVirtualNetworkConnectionData + { + RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/SpokeVnet1"), + EnableInternetSecurity = false, + RoutingConfiguration = new RoutingConfiguration + { + AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), + PropagatedRouteTables = new PropagatedRouteTable + { + Labels = { "label1", "label2" }, + Ids = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), +}}, + }, + VnetRoutes = new VnetRoute + { + StaticRoutesConfig = new StaticRoutesConfig + { + VnetLocalRouteOverrideCriteria = VnetLocalRouteOverrideCriterion.Equal, + }, + StaticRoutes = {new StaticRoute +{ +Name = "route1", +AddressPrefixes = {"10.1.0.0/16", "10.2.0.0/16"}, +NextHopIPAddress = "10.0.0.68", +}, new StaticRoute +{ +Name = "route2", +AddressPrefixes = {"10.3.0.0/16", "10.4.0.0/16"}, +NextHopIPAddress = "10.0.0.65", +}}, + }, + InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), + OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), + }, + }; + ArmOperation lro = await hubVirtualNetworkConnection.UpdateAsync(WaitUntil.Completed, data); + HubVirtualNetworkConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPAllocationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPAllocationCollection.cs index 0c96b78a680c1..f5827922f1eb1 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPAllocationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPAllocationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_IPAllocationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetIpAllocation() + public async Task CreateOrUpdate_CreateIpAllocation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationGet.json - // this example is just showing the usage of "IpAllocations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationCreate.json + // this example is just showing the usage of "IpAllocations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_GetIpAllocation() // invoke the operation string ipAllocationName = "test-ipallocation"; - IPAllocationResource result = await collection.GetAsync(ipAllocationName); + IPAllocationData data = new IPAllocationData + { + IPAllocationType = NetworkIPAllocationType.Hypernet, + Prefix = "3.2.5.0/24", + AllocationTags = +{ +["VNetID"] = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/HypernetVnet1" +}, + Location = new AzureLocation("centraluseuap"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ipAllocationName, data); + IPAllocationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +63,7 @@ public async Task Get_GetIpAllocation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetIpAllocation() + public async Task Get_GetIpAllocation() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationGet.json // this example is just showing the usage of "IpAllocations_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +85,21 @@ public async Task Exists_GetIpAllocation() // invoke the operation string ipAllocationName = "test-ipallocation"; - bool result = await collection.ExistsAsync(ipAllocationName); + IPAllocationResource result = await collection.GetAsync(ipAllocationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IPAllocationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetIpAllocation() + public async Task GetAll_ListIpAllocationsInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationGet.json - // this example is just showing the usage of "IpAllocations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationListByResourceGroup.json + // this example is just showing the usage of "IpAllocations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +116,25 @@ public async Task GetIfExists_GetIpAllocation() // get the collection of this IPAllocationResource IPAllocationCollection collection = resourceGroupResource.GetIPAllocations(); - // invoke the operation - string ipAllocationName = "test-ipallocation"; - NullableResponse response = await collection.GetIfExistsAsync(ipAllocationName); - IPAllocationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (IPAllocationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IPAllocationData resourceData = result.Data; + IPAllocationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateIpAllocation() + public async Task Exists_GetIpAllocation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationCreate.json - // this example is just showing the usage of "IpAllocations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationGet.json + // this example is just showing the usage of "IpAllocations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,32 +153,17 @@ public async Task CreateOrUpdate_CreateIpAllocation() // invoke the operation string ipAllocationName = "test-ipallocation"; - IPAllocationData data = new IPAllocationData() - { - IPAllocationType = NetworkIPAllocationType.Hypernet, - Prefix = "3.2.5.0/24", - AllocationTags = -{ -["VNetID"] = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/HypernetVnet1", -}, - Location = new AzureLocation("centraluseuap"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ipAllocationName, data); - IPAllocationResource result = lro.Value; + bool result = await collection.ExistsAsync(ipAllocationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IPAllocationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListIpAllocationsInResourceGroup() + public async Task GetIfExists_GetIpAllocation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationListByResourceGroup.json - // this example is just showing the usage of "IpAllocations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationGet.json + // this example is just showing the usage of "IpAllocations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_ListIpAllocationsInResourceGroup() // get the collection of this IPAllocationResource IPAllocationCollection collection = resourceGroupResource.GetIPAllocations(); - // invoke the operation and iterate over the result - await foreach (IPAllocationResource item in collection.GetAllAsync()) + // invoke the operation + string ipAllocationName = "test-ipallocation"; + NullableResponse response = await collection.GetIfExistsAsync(ipAllocationName); + IPAllocationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IPAllocationData resourceData = item.Data; + IPAllocationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPAllocationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPAllocationResource.cs index a224ae336521a..6f8c0b358b2a6 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPAllocationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPAllocationResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_IPAllocationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteIpAllocation() + public async Task Get_GetIpAllocation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationDelete.json - // this example is just showing the usage of "IpAllocations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationGet.json + // this example is just showing the usage of "IpAllocations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteIpAllocation() IPAllocationResource ipAllocation = client.GetIPAllocationResource(ipAllocationResourceId); // invoke the operation - await ipAllocation.DeleteAsync(WaitUntil.Completed); + IPAllocationResource result = await ipAllocation.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IPAllocationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetIpAllocation() + public async Task Delete_DeleteIpAllocation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationGet.json - // this example is just showing the usage of "IpAllocations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationDelete.json + // this example is just showing the usage of "IpAllocations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetIpAllocation() IPAllocationResource ipAllocation = client.GetIPAllocationResource(ipAllocationResourceId); // invoke the operation - IPAllocationResource result = await ipAllocation.GetAsync(); + await ipAllocation.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IPAllocationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateVirtualNetworkTags() IPAllocationResource ipAllocation = client.GetIPAllocationResource(ipAllocationResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; IPAllocationResource result = await ipAllocation.UpdateAsync(networkTagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdateVirtualNetworkTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIPAllocations_ListAllIpAllocations() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationList.json - // this example is just showing the usage of "IpAllocations_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (IPAllocationResource item in subscriptionResource.GetIPAllocationsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IPAllocationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPGroupCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPGroupCollection.cs index caa55bb12e36e..1f89c564d5f9a 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPGroupCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_IPGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetIpGroups() + public async Task CreateOrUpdate_CreateOrUpdateIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsGet.json - // this example is just showing the usage of "IpGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsCreate.json + // this example is just showing the usage of "IpGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,17 @@ public async Task Get_GetIpGroups() // invoke the operation string ipGroupsName = "ipGroups1"; - IPGroupResource result = await collection.GetAsync(ipGroupsName); + IPGroupData data = new IPGroupData + { + IPAddresses = { "13.64.39.16/32", "40.74.146.80/31", "40.74.147.32/28" }, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ipGroupsName, data); + IPGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +61,7 @@ public async Task Get_GetIpGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetIpGroups() + public async Task Get_GetIpGroups() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsGet.json // this example is just showing the usage of "IpGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +83,21 @@ public async Task Exists_GetIpGroups() // invoke the operation string ipGroupsName = "ipGroups1"; - bool result = await collection.ExistsAsync(ipGroupsName); + IPGroupResource result = await collection.GetAsync(ipGroupsName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IPGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetIpGroups() + public async Task GetAll_ListByResourceGroupIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsGet.json - // this example is just showing the usage of "IpGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsListByResourceGroup.json + // this example is just showing the usage of "IpGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +114,25 @@ public async Task GetIfExists_GetIpGroups() // get the collection of this IPGroupResource IPGroupCollection collection = resourceGroupResource.GetIPGroups(); - // invoke the operation - string ipGroupsName = "ipGroups1"; - NullableResponse response = await collection.GetIfExistsAsync(ipGroupsName); - IPGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (IPGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IPGroupData resourceData = result.Data; + IPGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateIpGroups() + public async Task Exists_GetIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsCreate.json - // this example is just showing the usage of "IpGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsGet.json + // this example is just showing the usage of "IpGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,34 +151,17 @@ public async Task CreateOrUpdate_CreateOrUpdateIpGroups() // invoke the operation string ipGroupsName = "ipGroups1"; - IPGroupData data = new IPGroupData() - { - IPAddresses = -{ -"13.64.39.16/32","40.74.146.80/31","40.74.147.32/28" -}, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ipGroupsName, data); - IPGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(ipGroupsName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IPGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListByResourceGroupIpGroups() + public async Task GetIfExists_GetIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsListByResourceGroup.json - // this example is just showing the usage of "IpGroups_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsGet.json + // this example is just showing the usage of "IpGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -187,17 +178,23 @@ public async Task GetAll_ListByResourceGroupIpGroups() // get the collection of this IPGroupResource IPGroupCollection collection = resourceGroupResource.GetIPGroups(); - // invoke the operation and iterate over the result - await foreach (IPGroupResource item in collection.GetAllAsync()) + // invoke the operation + string ipGroupsName = "ipGroups1"; + NullableResponse response = await collection.GetIfExistsAsync(ipGroupsName); + IPGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - IPGroupData resourceData = item.Data; + IPGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPGroupResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPGroupResource.cs index 2d9e5311517ac..6cfa0a7167325 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPGroupResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_IPGroupResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -49,10 +48,10 @@ public async Task Get_GetIpGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_UpdateIpGroups() + public async Task Delete_DeleteIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsUpdateTags.json - // this example is just showing the usage of "IpGroups_UpdateGroups" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsDelete.json + // this example is just showing the usage of "IpGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_UpdateIpGroups() IPGroupResource ipGroup = client.GetIPGroupResource(ipGroupResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() - { - Tags = -{ -["key1"] = "value1", -["key2"] = "value2", -}, - }; - IPGroupResource result = await ipGroup.UpdateAsync(networkTagsObject); + await ipGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IPGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteIpGroups() + public async Task Update_UpdateIpGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsDelete.json - // this example is just showing the usage of "IpGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsUpdateTags.json + // this example is just showing the usage of "IpGroups_UpdateGroups" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_DeleteIpGroups() IPGroupResource ipGroup = client.GetIPGroupResource(ipGroupResourceId); // invoke the operation - await ipGroup.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIPGroups_ListIpGroups() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsListBySubscription.json - // this example is just showing the usage of "IpGroups_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subId"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (IPGroupResource item in subscriptionResource.GetIPGroupsAsync()) + NetworkTagsObject networkTagsObject = new NetworkTagsObject { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - IPGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + }; + IPGroupResource result = await ipGroup.UpdateAsync(networkTagsObject); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IPGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundNatRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundNatRuleCollection.cs index 1ef838de510fc..b37a303c58108 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundNatRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundNatRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_InboundNatRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_InboundNatRuleList() + public async Task CreateOrUpdate_InboundNatRuleCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleList.json - // this example is just showing the usage of "InboundNatRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleCreate.json + // this example is just showing the usage of "InboundNatRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,26 @@ public async Task GetAll_InboundNatRuleList() // get the collection of this InboundNatRuleResource InboundNatRuleCollection collection = loadBalancer.GetInboundNatRules(); - // invoke the operation and iterate over the result - await foreach (InboundNatRuleResource item in collection.GetAllAsync()) + // invoke the operation + string inboundNatRuleName = "natRule1.1"; + InboundNatRuleData data = new InboundNatRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InboundNatRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/loadBalancers/lb1/frontendIPConfigurations/ip1"), + Protocol = LoadBalancingTransportProtocol.Tcp, + FrontendPort = 3390, + BackendPort = 3389, + IdleTimeoutInMinutes = 4, + EnableFloatingIP = false, + EnableTcpReset = false, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, inboundNatRuleName, data); + InboundNatRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InboundNatRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +97,10 @@ public async Task Get_InboundNatRuleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_InboundNatRuleGet() + public async Task GetAll_InboundNatRuleList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleGet.json - // this example is just showing the usage of "InboundNatRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleList.json + // this example is just showing the usage of "InboundNatRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +118,22 @@ public async Task Exists_InboundNatRuleGet() // get the collection of this InboundNatRuleResource InboundNatRuleCollection collection = loadBalancer.GetInboundNatRules(); - // invoke the operation - string inboundNatRuleName = "natRule1.1"; - bool result = await collection.ExistsAsync(inboundNatRuleName); + // invoke the operation and iterate over the result + await foreach (InboundNatRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InboundNatRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_InboundNatRuleGet() + public async Task Exists_InboundNatRuleGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleGet.json // this example is just showing the usage of "InboundNatRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +156,17 @@ public async Task GetIfExists_InboundNatRuleGet() // invoke the operation string inboundNatRuleName = "natRule1.1"; - NullableResponse response = await collection.GetIfExistsAsync(inboundNatRuleName); - InboundNatRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(inboundNatRuleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InboundNatRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_InboundNatRuleCreate() + public async Task GetIfExists_InboundNatRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleCreate.json - // this example is just showing the usage of "InboundNatRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleGet.json + // this example is just showing the usage of "InboundNatRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,24 +186,21 @@ public async Task CreateOrUpdate_InboundNatRuleCreate() // invoke the operation string inboundNatRuleName = "natRule1.1"; - InboundNatRuleData data = new InboundNatRuleData() - { - FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/loadBalancers/lb1/frontendIPConfigurations/ip1"), - Protocol = LoadBalancingTransportProtocol.Tcp, - FrontendPort = 3390, - BackendPort = 3389, - IdleTimeoutInMinutes = 4, - EnableFloatingIP = false, - EnableTcpReset = false, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, inboundNatRuleName, data); - InboundNatRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(inboundNatRuleName); + InboundNatRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InboundNatRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InboundNatRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundNatRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundNatRuleResource.cs index 656b78786bb89..caa1da5ab6c6c 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundNatRuleResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundNatRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_InboundNatRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_InboundNatRuleDelete() + public async Task Get_InboundNatRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleDelete.json - // this example is just showing the usage of "InboundNatRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleGet.json + // this example is just showing the usage of "InboundNatRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_InboundNatRuleDelete() InboundNatRuleResource inboundNatRule = client.GetInboundNatRuleResource(inboundNatRuleResourceId); // invoke the operation - await inboundNatRule.DeleteAsync(WaitUntil.Completed); + InboundNatRuleResource result = await inboundNatRule.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + InboundNatRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_InboundNatRuleGet() + public async Task Delete_InboundNatRuleDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleGet.json - // this example is just showing the usage of "InboundNatRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundNatRuleDelete.json + // this example is just showing the usage of "InboundNatRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_InboundNatRuleGet() InboundNatRuleResource inboundNatRule = client.GetInboundNatRuleResource(inboundNatRuleResourceId); // invoke the operation - InboundNatRuleResource result = await inboundNatRule.GetAsync(); + await inboundNatRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - InboundNatRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_InboundNatRuleCreate() InboundNatRuleResource inboundNatRule = client.GetInboundNatRuleResource(inboundNatRuleResourceId); // invoke the operation - InboundNatRuleData data = new InboundNatRuleData() + InboundNatRuleData data = new InboundNatRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/loadBalancers/lb1/frontendIPConfigurations/ip1"), Protocol = LoadBalancingTransportProtocol.Tcp, diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundSecurityRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundSecurityRuleCollection.cs index ff7ed4fc7094c..28f4462053a5e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundSecurityRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundSecurityRuleCollection.cs @@ -41,27 +41,18 @@ public async Task CreateOrUpdate_CreateNetworkVirtualApplianceInboundSecurityRul // invoke the operation string ruleCollectionName = "rule1"; - InboundSecurityRuleData data = new InboundSecurityRuleData() + InboundSecurityRuleData data = new InboundSecurityRuleData { RuleType = InboundSecurityRuleType.Permanent, - Rules = -{ -new InboundSecurityRules() + Rules = {new InboundSecurityRules { Name = "inboundRule1", Protocol = InboundSecurityRulesProtocol.Tcp, SourceAddressPrefix = "50.20.121.5/32", DestinationPortRange = 22, -DestinationPortRanges = -{ -"80-100" -}, -AppliesOn = -{ -"slbip1" -}, -} -}, +DestinationPortRanges = {"80-100"}, +AppliesOn = {"slbip1"}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionName, data); InboundSecurityRuleResource result = lro.Value; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundSecurityRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundSecurityRuleResource.cs index 98f8a723095fa..89a5e9afb9493 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundSecurityRuleResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_InboundSecurityRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_InboundSecurityRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateNetworkVirtualApplianceInboundSecurityRules() + public async Task Get_CreateNetworkVirtualApplianceInboundSecurityRules() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundSecurityRulePut.json - // this example is just showing the usage of "InboundSecurityRule_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundSecurityRuleGet.json + // this example is just showing the usage of "InboundSecurityRule_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,30 +38,7 @@ public async Task Update_CreateNetworkVirtualApplianceInboundSecurityRules() InboundSecurityRuleResource inboundSecurityRule = client.GetInboundSecurityRuleResource(inboundSecurityRuleResourceId); // invoke the operation - InboundSecurityRuleData data = new InboundSecurityRuleData() - { - RuleType = InboundSecurityRuleType.Permanent, - Rules = -{ -new InboundSecurityRules() -{ -Name = "inboundRule1", -Protocol = InboundSecurityRulesProtocol.Tcp, -SourceAddressPrefix = "50.20.121.5/32", -DestinationPortRange = 22, -DestinationPortRanges = -{ -"80-100" -}, -AppliesOn = -{ -"slbip1" -}, -} -}, - }; - ArmOperation lro = await inboundSecurityRule.UpdateAsync(WaitUntil.Completed, data); - InboundSecurityRuleResource result = lro.Value; + InboundSecurityRuleResource result = await inboundSecurityRule.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -72,10 +49,10 @@ public async Task Update_CreateNetworkVirtualApplianceInboundSecurityRules() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_CreateNetworkVirtualApplianceInboundSecurityRules() + public async Task Update_CreateNetworkVirtualApplianceInboundSecurityRules() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundSecurityRuleGet.json - // this example is just showing the usage of "InboundSecurityRule_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/InboundSecurityRulePut.json + // this example is just showing the usage of "InboundSecurityRule_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,7 +69,21 @@ public async Task Get_CreateNetworkVirtualApplianceInboundSecurityRules() InboundSecurityRuleResource inboundSecurityRule = client.GetInboundSecurityRuleResource(inboundSecurityRuleResourceId); // invoke the operation - InboundSecurityRuleResource result = await inboundSecurityRule.GetAsync(); + InboundSecurityRuleData data = new InboundSecurityRuleData + { + RuleType = InboundSecurityRuleType.Permanent, + Rules = {new InboundSecurityRules +{ +Name = "inboundRule1", +Protocol = InboundSecurityRulesProtocol.Tcp, +SourceAddressPrefix = "50.20.121.5/32", +DestinationPortRange = 22, +DestinationPortRanges = {"80-100"}, +AppliesOn = {"slbip1"}, +}}, + }; + ArmOperation lro = await inboundSecurityRule.UpdateAsync(WaitUntil.Completed, data); + InboundSecurityRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancerCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancerCollection.cs index 4fef9c953a6c3..72488d1f22789 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancerCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancerCollection.cs @@ -18,212 +18,6 @@ namespace Azure.ResourceManager.Network.Samples { public partial class Sample_LoadBalancerCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetLoadBalancer() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGet.json - // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this LoadBalancerResource - LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); - - // invoke the operation - string loadBalancerName = "lb"; - LoadBalancerResource result = await collection.GetAsync(loadBalancerName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadBalancerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetLoadBalancer() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGet.json - // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this LoadBalancerResource - LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); - - // invoke the operation - string loadBalancerName = "lb"; - bool result = await collection.ExistsAsync(loadBalancerName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetLoadBalancer() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGet.json - // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this LoadBalancerResource - LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); - - // invoke the operation - string loadBalancerName = "lb"; - NullableResponse response = await collection.GetIfExistsAsync(loadBalancerName); - LoadBalancerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadBalancerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetLoadBalancerWithInboundNATRulePortMapping() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGetInboundNatRulePortMapping.json - // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this LoadBalancerResource - LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); - - // invoke the operation - string loadBalancerName = "lb"; - LoadBalancerResource result = await collection.GetAsync(loadBalancerName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadBalancerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetLoadBalancerWithInboundNATRulePortMapping() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGetInboundNatRulePortMapping.json - // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this LoadBalancerResource - LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); - - // invoke the operation - string loadBalancerName = "lb"; - bool result = await collection.ExistsAsync(loadBalancerName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetLoadBalancerWithInboundNATRulePortMapping() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGetInboundNatRulePortMapping.json - // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this LoadBalancerResource - LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); - - // invoke the operation - string loadBalancerName = "lb"; - NullableResponse response = await collection.GetIfExistsAsync(loadBalancerName); - LoadBalancerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadBalancerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateLoadBalancer() @@ -248,29 +42,21 @@ public async Task CreateOrUpdate_CreateLoadBalancer() // invoke the operation string loadBalancerName = "lb"; - LoadBalancerData data = new LoadBalancerData() + LoadBalancerData data = new LoadBalancerData { - FrontendIPConfigurations = + FrontendIPConfigurations = {new FrontendIPConfigurationData { -new FrontendIPConfigurationData() -{ -Subnet = new SubnetData() +Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), }, Name = "fe-lb", -} -}, - BackendAddressPools = -{ -new BackendAddressPoolData() +}}, + BackendAddressPools = {new BackendAddressPoolData { Name = "be-lb", -} -}, - LoadBalancingRules = -{ -new LoadBalancingRuleData() +}}, + LoadBalancingRules = {new LoadBalancingRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), BackendAddressPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb"), @@ -283,11 +69,8 @@ public async Task CreateOrUpdate_CreateLoadBalancer() EnableFloatingIP = true, EnableTcpReset = false, Name = "rulelb", -} -}, - Probes = -{ -new ProbeData() +}}, + Probes = {new ProbeData { Protocol = ProbeProtocol.Http, Port = 80, @@ -296,11 +79,8 @@ public async Task CreateOrUpdate_CreateLoadBalancer() ProbeThreshold = 1, RequestPath = "healthcheck.aspx", Name = "probe-lb", -} -}, - InboundNatRules = -{ -new InboundNatRuleData() +}}, + InboundNatRules = {new InboundNatRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), Protocol = LoadBalancingTransportProtocol.Tcp, @@ -310,11 +90,8 @@ public async Task CreateOrUpdate_CreateLoadBalancer() EnableFloatingIP = true, EnableTcpReset = false, Name = "in-nat-rule", -} -}, - InboundNatPools = -{ -}, +}}, + InboundNatPools = { }, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); @@ -351,37 +128,26 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithFrontendIPInZone1() // invoke the operation string loadBalancerName = "lb"; - LoadBalancerData data = new LoadBalancerData() + LoadBalancerData data = new LoadBalancerData { - Sku = new LoadBalancerSku() + Sku = new LoadBalancerSku { Name = LoadBalancerSkuName.Standard, }, - FrontendIPConfigurations = -{ -new FrontendIPConfigurationData() + FrontendIPConfigurations = {new FrontendIPConfigurationData { -Zones = -{ -"1" -}, -Subnet = new SubnetData() +Zones = {"1"}, +Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), }, Name = "fe-lb", -} -}, - BackendAddressPools = -{ -new BackendAddressPoolData() +}}, + BackendAddressPools = {new BackendAddressPoolData { Name = "be-lb", -} -}, - LoadBalancingRules = -{ -new LoadBalancingRuleData() +}}, + LoadBalancingRules = {new LoadBalancingRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), BackendAddressPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb"), @@ -393,11 +159,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithFrontendIPInZone1() IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "rulelb", -} -}, - Probes = -{ -new ProbeData() +}}, + Probes = {new ProbeData { Protocol = ProbeProtocol.Http, Port = 80, @@ -406,11 +169,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithFrontendIPInZone1() ProbeThreshold = 1, RequestPath = "healthcheck.aspx", Name = "probe-lb", -} -}, - InboundNatRules = -{ -new InboundNatRuleData() +}}, + InboundNatRules = {new InboundNatRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), Protocol = LoadBalancingTransportProtocol.Tcp, @@ -419,14 +179,9 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithFrontendIPInZone1() IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "in-nat-rule", -} -}, - InboundNatPools = -{ -}, - OutboundRules = -{ -}, +}}, + InboundNatPools = { }, + OutboundRules = { }, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); @@ -463,34 +218,26 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGatewayLoadBalancerConsum // invoke the operation string loadBalancerName = "lb"; - LoadBalancerData data = new LoadBalancerData() + LoadBalancerData data = new LoadBalancerData { - Sku = new LoadBalancerSku() + Sku = new LoadBalancerSku { Name = LoadBalancerSkuName.Standard, }, - FrontendIPConfigurations = + FrontendIPConfigurations = {new FrontendIPConfigurationData { -new FrontendIPConfigurationData() -{ -Subnet = new SubnetData() +Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), }, GatewayLoadBalancerId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb-provider"), Name = "fe-lb", -} -}, - BackendAddressPools = -{ -new BackendAddressPoolData() +}}, + BackendAddressPools = {new BackendAddressPoolData { Name = "be-lb", -} -}, - LoadBalancingRules = -{ -new LoadBalancingRuleData() +}}, + LoadBalancingRules = {new LoadBalancingRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), BackendAddressPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb"), @@ -502,11 +249,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGatewayLoadBalancerConsum IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "rulelb", -} -}, - Probes = -{ -new ProbeData() +}}, + Probes = {new ProbeData { Protocol = ProbeProtocol.Http, Port = 80, @@ -515,11 +259,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGatewayLoadBalancerConsum ProbeThreshold = 1, RequestPath = "healthcheck.aspx", Name = "probe-lb", -} -}, - InboundNatRules = -{ -new InboundNatRuleData() +}}, + InboundNatRules = {new InboundNatRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), Protocol = LoadBalancingTransportProtocol.Tcp, @@ -528,14 +269,9 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGatewayLoadBalancerConsum IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "in-nat-rule", -} -}, - InboundNatPools = -{ -}, - OutboundRules = -{ -}, +}}, + InboundNatPools = { }, + OutboundRules = { }, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); @@ -572,58 +308,44 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGatewayLoadBalancerProvid // invoke the operation string loadBalancerName = "lb"; - LoadBalancerData data = new LoadBalancerData() + LoadBalancerData data = new LoadBalancerData { - Sku = new LoadBalancerSku() + Sku = new LoadBalancerSku { Name = LoadBalancerSkuName.Gateway, }, - FrontendIPConfigurations = -{ -new FrontendIPConfigurationData() + FrontendIPConfigurations = {new FrontendIPConfigurationData { -Subnet = new SubnetData() +Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), }, Name = "fe-lb", -} -}, - BackendAddressPools = -{ -new BackendAddressPoolData() +}}, + BackendAddressPools = {new BackendAddressPoolData { -TunnelInterfaces = -{ -new GatewayLoadBalancerTunnelInterface() +TunnelInterfaces = {new GatewayLoadBalancerTunnelInterface { Port = 15000, Identifier = 900, Protocol = GatewayLoadBalancerTunnelProtocol.Vxlan, InterfaceType = GatewayLoadBalancerTunnelInterfaceType.Internal, -},new GatewayLoadBalancerTunnelInterface() +}, new GatewayLoadBalancerTunnelInterface { Port = 15001, Identifier = 901, Protocol = GatewayLoadBalancerTunnelProtocol.Vxlan, InterfaceType = GatewayLoadBalancerTunnelInterfaceType.Internal, -} -}, +}}, Name = "be-lb", -} -}, - LoadBalancingRules = -{ -new LoadBalancingRuleData() +}}, + LoadBalancingRules = {new LoadBalancingRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), -BackendAddressPools = -{ -new WritableSubResource() +BackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb"), -} -}, +}}, ProbeId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb"), Protocol = LoadBalancingTransportProtocol.All, LoadDistribution = LoadDistribution.Default, @@ -632,11 +354,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGatewayLoadBalancerProvid IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "rulelb", -} -}, - Probes = -{ -new ProbeData() +}}, + Probes = {new ProbeData { Protocol = ProbeProtocol.Http, Port = 80, @@ -645,14 +364,9 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGatewayLoadBalancerProvid ProbeThreshold = 1, RequestPath = "healthcheck.aspx", Name = "probe-lb", -} -}, - InboundNatPools = -{ -}, - OutboundRules = -{ -}, +}}, + InboundNatPools = { }, + OutboundRules = { }, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); @@ -689,48 +403,37 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGatewayLoadBalancerProvid // invoke the operation string loadBalancerName = "lb"; - LoadBalancerData data = new LoadBalancerData() + LoadBalancerData data = new LoadBalancerData { - Sku = new LoadBalancerSku() + Sku = new LoadBalancerSku { Name = LoadBalancerSkuName.Gateway, }, - FrontendIPConfigurations = -{ -new FrontendIPConfigurationData() + FrontendIPConfigurations = {new FrontendIPConfigurationData { -Subnet = new SubnetData() +Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), }, Name = "fe-lb", -} -}, - BackendAddressPools = -{ -new BackendAddressPoolData() +}}, + BackendAddressPools = {new BackendAddressPoolData { Name = "be-lb1", -},new BackendAddressPoolData() +}, new BackendAddressPoolData { Name = "be-lb2", -} -}, - LoadBalancingRules = -{ -new LoadBalancingRuleData() +}}, + LoadBalancingRules = {new LoadBalancingRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), -BackendAddressPools = -{ -new WritableSubResource() +BackendAddressPools = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb1"), -},new WritableSubResource() +}, new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb2"), -} -}, +}}, ProbeId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/probes/probe-lb"), Protocol = LoadBalancingTransportProtocol.All, LoadDistribution = LoadDistribution.Default, @@ -739,11 +442,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGatewayLoadBalancerProvid IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "rulelb", -} -}, - Probes = -{ -new ProbeData() +}}, + Probes = {new ProbeData { Protocol = ProbeProtocol.Http, Port = 80, @@ -752,14 +452,9 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGatewayLoadBalancerProvid ProbeThreshold = 1, RequestPath = "healthcheck.aspx", Name = "probe-lb", -} -}, - InboundNatPools = -{ -}, - OutboundRules = -{ -}, +}}, + InboundNatPools = { }, + OutboundRules = { }, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); @@ -796,42 +491,31 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGlobalTierAndOneRegionalL // invoke the operation string loadBalancerName = "lb"; - LoadBalancerData data = new LoadBalancerData() + LoadBalancerData data = new LoadBalancerData { - Sku = new LoadBalancerSku() + Sku = new LoadBalancerSku { Name = LoadBalancerSkuName.Standard, Tier = LoadBalancerSkuTier.Global, }, - FrontendIPConfigurations = -{ -new FrontendIPConfigurationData() + FrontendIPConfigurations = {new FrontendIPConfigurationData { -Subnet = new SubnetData() +Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), }, Name = "fe-lb", -} -}, - BackendAddressPools = -{ -new BackendAddressPoolData() -{ -LoadBalancerBackendAddresses = +}}, + BackendAddressPools = {new BackendAddressPoolData { -new LoadBalancerBackendAddress() +LoadBalancerBackendAddresses = {new LoadBalancerBackendAddress { Name = "regional-lb1-address", LoadBalancerFrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/regional-lb-rg1/providers/Microsoft.Network/loadBalancers/regional-lb/frontendIPConfigurations/fe-rlb"), -} -}, +}}, Name = "be-lb", -} -}, - LoadBalancingRules = -{ -new LoadBalancingRuleData() +}}, + LoadBalancingRules = {new LoadBalancingRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), BackendAddressPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb"), @@ -843,11 +527,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGlobalTierAndOneRegionalL IdleTimeoutInMinutes = 15, EnableFloatingIP = false, Name = "rulelb", -} -}, - Probes = -{ -new ProbeData() +}}, + Probes = {new ProbeData { Protocol = ProbeProtocol.Http, Port = 80, @@ -856,8 +537,7 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithGlobalTierAndOneRegionalL ProbeThreshold = 1, RequestPath = "healthcheck.aspx", Name = "probe-lb", -} -}, +}}, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); @@ -894,33 +574,25 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithStandardSKU() // invoke the operation string loadBalancerName = "lb"; - LoadBalancerData data = new LoadBalancerData() + LoadBalancerData data = new LoadBalancerData { - Sku = new LoadBalancerSku() + Sku = new LoadBalancerSku { Name = LoadBalancerSkuName.Standard, }, - FrontendIPConfigurations = -{ -new FrontendIPConfigurationData() + FrontendIPConfigurations = {new FrontendIPConfigurationData { -Subnet = new SubnetData() +Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), }, Name = "fe-lb", -} -}, - BackendAddressPools = -{ -new BackendAddressPoolData() +}}, + BackendAddressPools = {new BackendAddressPoolData { Name = "be-lb", -} -}, - LoadBalancingRules = -{ -new LoadBalancingRuleData() +}}, + LoadBalancingRules = {new LoadBalancingRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), BackendAddressPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb"), @@ -932,11 +604,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithStandardSKU() IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "rulelb", -} -}, - Probes = -{ -new ProbeData() +}}, + Probes = {new ProbeData { Protocol = ProbeProtocol.Http, Port = 80, @@ -945,11 +614,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithStandardSKU() ProbeThreshold = 1, RequestPath = "healthcheck.aspx", Name = "probe-lb", -} -}, - InboundNatRules = -{ -new InboundNatRuleData() +}}, + InboundNatRules = {new InboundNatRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), Protocol = LoadBalancingTransportProtocol.Tcp, @@ -958,14 +624,9 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithStandardSKU() IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "in-nat-rule", -} -}, - InboundNatPools = -{ -}, - OutboundRules = -{ -}, +}}, + InboundNatPools = { }, + OutboundRules = { }, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); @@ -1002,35 +663,27 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithSyncModePropertyOnPool() // invoke the operation string loadBalancerName = "lb"; - LoadBalancerData data = new LoadBalancerData() + LoadBalancerData data = new LoadBalancerData { - Sku = new LoadBalancerSku() + Sku = new LoadBalancerSku { Name = LoadBalancerSkuName.Standard, }, - FrontendIPConfigurations = + FrontendIPConfigurations = {new FrontendIPConfigurationData { -new FrontendIPConfigurationData() -{ -Subnet = new SubnetData() +Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), }, Name = "fe-lb", -} -}, - BackendAddressPools = -{ -new BackendAddressPoolData() +}}, + BackendAddressPools = {new BackendAddressPoolData { VirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb"), SyncMode = BackendAddressSyncMode.Automatic, Name = "be-lb", -} -}, - LoadBalancingRules = -{ -new LoadBalancingRuleData() +}}, + LoadBalancingRules = {new LoadBalancingRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), BackendAddressPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb"), @@ -1042,11 +695,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithSyncModePropertyOnPool() IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "rulelb", -} -}, - Probes = -{ -new ProbeData() +}}, + Probes = {new ProbeData { Protocol = ProbeProtocol.Http, Port = 80, @@ -1055,11 +705,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithSyncModePropertyOnPool() ProbeThreshold = 1, RequestPath = "healthcheck.aspx", Name = "probe-lb", -} -}, - InboundNatRules = -{ -new InboundNatRuleData() +}}, + InboundNatRules = {new InboundNatRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), Protocol = LoadBalancingTransportProtocol.Tcp, @@ -1068,14 +715,9 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithSyncModePropertyOnPool() IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "in-nat-rule", -} -}, - InboundNatPools = -{ -}, - OutboundRules = -{ -}, +}}, + InboundNatPools = { }, + OutboundRules = { }, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); @@ -1112,43 +754,28 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithInboundNatPool() // invoke the operation string loadBalancerName = "lb"; - LoadBalancerData data = new LoadBalancerData() + LoadBalancerData data = new LoadBalancerData { - Sku = new LoadBalancerSku() + Sku = new LoadBalancerSku { Name = LoadBalancerSkuName.Standard, }, - FrontendIPConfigurations = + FrontendIPConfigurations = {new FrontendIPConfigurationData { -new FrontendIPConfigurationData() -{ -Zones = -{ -}, +Zones = {}, PrivateIPAllocationMethod = NetworkIPAllocationMethod.Dynamic, -Subnet = new SubnetData() +Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/lbvnet/subnets/lbsubnet"), }, Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/test"), Name = "test", -} -}, - BackendAddressPools = -{ -}, - LoadBalancingRules = -{ -}, - Probes = -{ -}, - InboundNatRules = -{ -}, - InboundNatPools = -{ -new LoadBalancerInboundNatPool() +}}, + BackendAddressPools = { }, + LoadBalancingRules = { }, + Probes = { }, + InboundNatRules = { }, + InboundNatPools = {new LoadBalancerInboundNatPool { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/test"), Protocol = LoadBalancingTransportProtocol.Tcp, @@ -1160,11 +787,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithInboundNatPool() EnableTcpReset = true, Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/inboundNatPools/test"), Name = "test", -} -}, - OutboundRules = -{ -}, +}}, + OutboundRules = { }, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); @@ -1201,33 +825,25 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithOutboundRules() // invoke the operation string loadBalancerName = "lb"; - LoadBalancerData data = new LoadBalancerData() + LoadBalancerData data = new LoadBalancerData { - Sku = new LoadBalancerSku() + Sku = new LoadBalancerSku { Name = LoadBalancerSkuName.Standard, }, - FrontendIPConfigurations = -{ -new FrontendIPConfigurationData() + FrontendIPConfigurations = {new FrontendIPConfigurationData { -PublicIPAddress = new PublicIPAddressData() +PublicIPAddress = new PublicIPAddressData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pip"), }, Name = "fe-lb", -} -}, - BackendAddressPools = -{ -new BackendAddressPoolData() +}}, + BackendAddressPools = {new BackendAddressPoolData { Name = "be-lb", -} -}, - LoadBalancingRules = -{ -new LoadBalancingRuleData() +}}, + LoadBalancingRules = {new LoadBalancingRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), BackendAddressPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb"), @@ -1240,11 +856,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithOutboundRules() EnableFloatingIP = true, DisableOutboundSnat = true, Name = "rulelb", -} -}, - Probes = -{ -new ProbeData() +}}, + Probes = {new ProbeData { Protocol = ProbeProtocol.Http, Port = 80, @@ -1253,11 +866,8 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithOutboundRules() ProbeThreshold = 1, RequestPath = "healthcheck.aspx", Name = "probe-lb", -} -}, - InboundNatRules = -{ -new InboundNatRuleData() +}}, + InboundNatRules = {new InboundNatRuleData { FrontendIPConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), Protocol = LoadBalancingTransportProtocol.Tcp, @@ -1266,27 +876,18 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithOutboundRules() IdleTimeoutInMinutes = 15, EnableFloatingIP = true, Name = "in-nat-rule", -} -}, - InboundNatPools = -{ -}, - OutboundRules = -{ -new OutboundRuleData() +}}, + InboundNatPools = { }, + OutboundRules = {new OutboundRuleData { -FrontendIPConfigurations = -{ -new WritableSubResource() +FrontendIPConfigurations = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), -} -}, +}}, BackendAddressPoolId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/backendAddressPools/be-lb"), Protocol = LoadBalancerOutboundRuleProtocol.All, Name = "rule1", -} -}, +}}, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, loadBalancerName, data); @@ -1299,6 +900,72 @@ public async Task CreateOrUpdate_CreateLoadBalancerWithOutboundRules() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetLoadBalancer() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGet.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this LoadBalancerResource + LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); + + // invoke the operation + string loadBalancerName = "lb"; + LoadBalancerResource result = await collection.GetAsync(loadBalancerName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetLoadBalancerWithInboundNATRulePortMapping() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGetInboundNatRulePortMapping.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this LoadBalancerResource + LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); + + // invoke the operation + string loadBalancerName = "lb"; + LoadBalancerResource result = await collection.GetAsync(loadBalancerName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListLoadBalancersInResourceGroup() @@ -1333,5 +1000,145 @@ public async Task GetAll_ListLoadBalancersInResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetLoadBalancer() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGet.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this LoadBalancerResource + LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); + + // invoke the operation + string loadBalancerName = "lb"; + bool result = await collection.ExistsAsync(loadBalancerName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetLoadBalancerWithInboundNATRulePortMapping() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGetInboundNatRulePortMapping.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this LoadBalancerResource + LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); + + // invoke the operation + string loadBalancerName = "lb"; + bool result = await collection.ExistsAsync(loadBalancerName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetLoadBalancer() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGet.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this LoadBalancerResource + LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); + + // invoke the operation + string loadBalancerName = "lb"; + NullableResponse response = await collection.GetIfExistsAsync(loadBalancerName); + LoadBalancerResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetLoadBalancerWithInboundNATRulePortMapping() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGetInboundNatRulePortMapping.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this LoadBalancerResource + LoadBalancerCollection collection = resourceGroupResource.GetLoadBalancers(); + + // invoke the operation + string loadBalancerName = "lb"; + NullableResponse response = await collection.GetIfExistsAsync(loadBalancerName); + LoadBalancerResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancerResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancerResource.cs index 24c5f69e917df..92dcda4fecbaf 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancerResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancerResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_LoadBalancerResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteLoadBalancer() + public async Task Get_GetLoadBalancer() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerDelete.json - // this example is just showing the usage of "LoadBalancers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGet.json + // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +37,20 @@ public async Task Delete_DeleteLoadBalancer() LoadBalancerResource loadBalancer = client.GetLoadBalancerResource(loadBalancerResourceId); // invoke the operation - await loadBalancer.DeleteAsync(WaitUntil.Completed); + LoadBalancerResource result = await loadBalancer.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadBalancerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetLoadBalancer() + public async Task Get_GetLoadBalancerWithInboundNATRulePortMapping() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGetInboundNatRulePortMapping.json // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -75,10 +78,10 @@ public async Task Get_GetLoadBalancer() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetLoadBalancerWithInboundNATRulePortMapping() + public async Task Delete_DeleteLoadBalancer() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerGetInboundNatRulePortMapping.json - // this example is just showing the usage of "LoadBalancers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerDelete.json + // this example is just showing the usage of "LoadBalancers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,13 +97,9 @@ public async Task Get_GetLoadBalancerWithInboundNATRulePortMapping() LoadBalancerResource loadBalancer = client.GetLoadBalancerResource(loadBalancerResourceId); // invoke the operation - LoadBalancerResource result = await loadBalancer.GetAsync(); + await loadBalancer.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadBalancerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -124,12 +123,12 @@ public async Task Update_UpdateLoadBalancerTags() LoadBalancerResource loadBalancer = client.GetLoadBalancerResource(loadBalancerResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; LoadBalancerResource result = await loadBalancer.UpdateAsync(networkTagsObject); @@ -141,77 +140,6 @@ public async Task Update_UpdateLoadBalancerTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetLoadBalancers_ListAllLoadBalancers() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerListAll.json - // this example is just showing the usage of "LoadBalancers_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (LoadBalancerResource item in subscriptionResource.GetLoadBalancersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadBalancerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task SwapPublicIPAddressesLoadBalancer_SwapVIPsBetweenTwoLoadBalancers() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancersSwapPublicIpAddresses.json - // this example is just showing the usage of "LoadBalancers_SwapPublicIPAddresses" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation - AzureLocation location = new AzureLocation("westus"); - LoadBalancerVipSwapContent content = new LoadBalancerVipSwapContent() - { - FrontendIPConfigurations = -{ -new LoadBalancerVipSwapRequestFrontendIPConfiguration() -{ -Id = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb1/frontendIPConfigurations/lbfe1", -PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/publicIPAddresses/pip2"), -},new LoadBalancerVipSwapRequestFrontendIPConfiguration() -{ -Id = "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/loadBalancers/lb2/frontendIPConfigurations/lbfe2", -PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pip1"), -} -}, - }; - await subscriptionResource.SwapPublicIPAddressesLoadBalancerAsync(WaitUntil.Completed, location, content); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task MigrateToIPBased_MigrateLoadBalancerToIPBased() @@ -233,12 +161,9 @@ public async Task MigrateToIPBased_MigrateLoadBalancerToIPBased() LoadBalancerResource loadBalancer = client.GetLoadBalancerResource(loadBalancerResourceId); // invoke the operation - MigrateLoadBalancerToIPBasedContent content = new MigrateLoadBalancerToIPBasedContent() + MigrateLoadBalancerToIPBasedContent content = new MigrateLoadBalancerToIPBasedContent { - Pools = -{ -"pool1","pool2" -}, + Pools = { "pool1", "pool2" }, }; MigrateLoadBalancerToIPBasedResult result = await loadBalancer.MigrateToIPBasedAsync(content: content); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancingRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancingRuleCollection.cs index ed56059b0cdb3..f7c1b1c3deece 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancingRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LoadBalancingRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_LoadBalancingRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LoadBalancerLoadBalancingRuleList() + public async Task Get_LoadBalancerLoadBalancingRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerLoadBalancingRuleList.json - // this example is just showing the usage of "LoadBalancerLoadBalancingRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerLoadBalancingRuleGet.json + // this example is just showing the usage of "LoadBalancerLoadBalancingRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_LoadBalancerLoadBalancingRuleList() // get the collection of this LoadBalancingRuleResource LoadBalancingRuleCollection collection = loadBalancer.GetLoadBalancingRules(); - // invoke the operation and iterate over the result - await foreach (LoadBalancingRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadBalancingRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string loadBalancingRuleName = "rule1"; + LoadBalancingRuleResource result = await collection.GetAsync(loadBalancingRuleName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadBalancingRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LoadBalancerLoadBalancingRuleGet() + public async Task GetAll_LoadBalancerLoadBalancingRuleList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerLoadBalancingRuleGet.json - // this example is just showing the usage of "LoadBalancerLoadBalancingRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerLoadBalancingRuleList.json + // this example is just showing the usage of "LoadBalancerLoadBalancingRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_LoadBalancerLoadBalancingRuleGet() // get the collection of this LoadBalancingRuleResource LoadBalancingRuleCollection collection = loadBalancer.GetLoadBalancingRules(); - // invoke the operation - string loadBalancingRuleName = "rule1"; - LoadBalancingRuleResource result = await collection.GetAsync(loadBalancingRuleName); + // invoke the operation and iterate over the result + await foreach (LoadBalancingRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadBalancingRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LoadBalancingRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LocalNetworkGatewayCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LocalNetworkGatewayCollection.cs index 406f6e0a3548b..a28e587a998fe 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LocalNetworkGatewayCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LocalNetworkGatewayCollection.cs @@ -40,12 +40,9 @@ public async Task CreateOrUpdate_CreateLocalNetworkGateway() // invoke the operation string localNetworkGatewayName = "localgw"; - LocalNetworkGatewayData data = new LocalNetworkGatewayData() + LocalNetworkGatewayData data = new LocalNetworkGatewayData { - LocalNetworkAddressPrefixes = -{ -"10.1.0.0/16" -}, + LocalNetworkAddressPrefixes = { "10.1.0.0/16" }, GatewayIPAddress = "11.12.13.14", Fqdn = "site1.contoso.com", Location = new AzureLocation("Central US"), @@ -95,10 +92,10 @@ public async Task Get_GetLocalNetworkGateway() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetLocalNetworkGateway() + public async Task GetAll_ListLocalNetworkGateways() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LocalNetworkGatewayGet.json - // this example is just showing the usage of "LocalNetworkGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LocalNetworkGatewayList.json + // this example is just showing the usage of "LocalNetworkGateways_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +112,22 @@ public async Task Exists_GetLocalNetworkGateway() // get the collection of this LocalNetworkGatewayResource LocalNetworkGatewayCollection collection = resourceGroupResource.GetLocalNetworkGateways(); - // invoke the operation - string localNetworkGatewayName = "localgw"; - bool result = await collection.ExistsAsync(localNetworkGatewayName); + // invoke the operation and iterate over the result + await foreach (LocalNetworkGatewayResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LocalNetworkGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetLocalNetworkGateway() + public async Task Exists_GetLocalNetworkGateway() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LocalNetworkGatewayGet.json // this example is just showing the usage of "LocalNetworkGateways_Get" operation, for the dependent resources, they will have to be created separately. @@ -146,29 +149,17 @@ public async Task GetIfExists_GetLocalNetworkGateway() // invoke the operation string localNetworkGatewayName = "localgw"; - NullableResponse response = await collection.GetIfExistsAsync(localNetworkGatewayName); - LocalNetworkGatewayResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(localNetworkGatewayName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - LocalNetworkGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListLocalNetworkGateways() + public async Task GetIfExists_GetLocalNetworkGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LocalNetworkGatewayList.json - // this example is just showing the usage of "LocalNetworkGateways_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LocalNetworkGatewayGet.json + // this example is just showing the usage of "LocalNetworkGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +176,23 @@ public async Task GetAll_ListLocalNetworkGateways() // get the collection of this LocalNetworkGatewayResource LocalNetworkGatewayCollection collection = resourceGroupResource.GetLocalNetworkGateways(); - // invoke the operation and iterate over the result - await foreach (LocalNetworkGatewayResource item in collection.GetAllAsync()) + // invoke the operation + string localNetworkGatewayName = "localgw"; + NullableResponse response = await collection.GetIfExistsAsync(localNetworkGatewayName); + LocalNetworkGatewayResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - LocalNetworkGatewayData resourceData = item.Data; + LocalNetworkGatewayData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LocalNetworkGatewayResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LocalNetworkGatewayResource.cs index fdadecd8ecf64..4d0aca931145e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LocalNetworkGatewayResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_LocalNetworkGatewayResource.cs @@ -93,12 +93,12 @@ public async Task Update_UpdateLocalNetworkGatewayTags() LocalNetworkGatewayResource localNetworkGateway = client.GetLocalNetworkGatewayResource(localNetworkGatewayResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; LocalNetworkGatewayResource result = await localNetworkGateway.UpdateAsync(networkTagsObject); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ManagementGroupNetworkManagerConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ManagementGroupNetworkManagerConnectionCollection.cs index 076ca46fc9a9d..f20f2cf5116b7 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ManagementGroupNetworkManagerConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ManagementGroupNetworkManagerConnectionCollection.cs @@ -39,7 +39,7 @@ public async Task CreateOrUpdate_CreateOrUpdateManagementGroupNetworkManagerConn // invoke the operation string networkManagerConnectionName = "TestNMConnection"; - NetworkManagerConnectionData data = new NetworkManagerConnectionData() + NetworkManagerConnectionData data = new NetworkManagerConnectionData { NetworkManagerId = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroup/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager"), }; @@ -87,10 +87,10 @@ public async Task Get_GetManagementGroupNetworkManagerConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetManagementGroupNetworkManagerConnection() + public async Task GetAll_ListManagementGroupNetworkManagerConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupGet.json - // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupList.json + // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +106,22 @@ public async Task Exists_GetManagementGroupNetworkManagerConnection() // get the collection of this ManagementGroupNetworkManagerConnectionResource ManagementGroupNetworkManagerConnectionCollection collection = managementGroupResource.GetManagementGroupNetworkManagerConnections(); - // invoke the operation - string networkManagerConnectionName = "TestNMConnection"; - bool result = await collection.ExistsAsync(networkManagerConnectionName); + // invoke the operation and iterate over the result + await foreach (ManagementGroupNetworkManagerConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetManagementGroupNetworkManagerConnection() + public async Task Exists_GetManagementGroupNetworkManagerConnection() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupGet.json // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -136,29 +142,17 @@ public async Task GetIfExists_GetManagementGroupNetworkManagerConnection() // invoke the operation string networkManagerConnectionName = "TestNMConnection"; - NullableResponse response = await collection.GetIfExistsAsync(networkManagerConnectionName); - ManagementGroupNetworkManagerConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkManagerConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListManagementGroupNetworkManagerConnection() + public async Task GetIfExists_GetManagementGroupNetworkManagerConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupList.json - // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupGet.json + // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,17 +168,23 @@ public async Task GetAll_ListManagementGroupNetworkManagerConnection() // get the collection of this ManagementGroupNetworkManagerConnectionResource ManagementGroupNetworkManagerConnectionCollection collection = managementGroupResource.GetManagementGroupNetworkManagerConnections(); - // invoke the operation and iterate over the result - await foreach (ManagementGroupNetworkManagerConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string networkManagerConnectionName = "TestNMConnection"; + NullableResponse response = await collection.GetIfExistsAsync(networkManagerConnectionName); + ManagementGroupNetworkManagerConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkManagerConnectionData resourceData = item.Data; + NetworkManagerConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ManagementGroupNetworkManagerConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ManagementGroupNetworkManagerConnectionResource.cs index fd33c40f7aa58..65de754f3d0fa 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ManagementGroupNetworkManagerConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ManagementGroupNetworkManagerConnectionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ManagementGroupNetworkManagerConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateManagementGroupNetworkManagerConnection() + public async Task Get_GetManagementGroupNetworkManagerConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupPut.json - // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupGet.json + // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,12 +35,7 @@ public async Task Update_CreateOrUpdateManagementGroupNetworkManagerConnection() ManagementGroupNetworkManagerConnectionResource managementGroupNetworkManagerConnection = client.GetManagementGroupNetworkManagerConnectionResource(managementGroupNetworkManagerConnectionResourceId); // invoke the operation - NetworkManagerConnectionData data = new NetworkManagerConnectionData() - { - NetworkManagerId = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroup/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager"), - }; - ArmOperation lro = await managementGroupNetworkManagerConnection.UpdateAsync(WaitUntil.Completed, data); - ManagementGroupNetworkManagerConnectionResource result = lro.Value; + ManagementGroupNetworkManagerConnectionResource result = await managementGroupNetworkManagerConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +46,10 @@ public async Task Update_CreateOrUpdateManagementGroupNetworkManagerConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetManagementGroupNetworkManagerConnection() + public async Task Delete_DeleteManagementGroupNetworkManagerConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupGet.json - // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupDelete.json + // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,21 +64,17 @@ public async Task Get_GetManagementGroupNetworkManagerConnection() ManagementGroupNetworkManagerConnectionResource managementGroupNetworkManagerConnection = client.GetManagementGroupNetworkManagerConnectionResource(managementGroupNetworkManagerConnectionResourceId); // invoke the operation - ManagementGroupNetworkManagerConnectionResource result = await managementGroupNetworkManagerConnection.GetAsync(); + await managementGroupNetworkManagerConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteManagementGroupNetworkManagerConnection() + public async Task Update_CreateOrUpdateManagementGroupNetworkManagerConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupDelete.json - // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionManagementGroupPut.json + // this example is just showing the usage of "ManagementGroupNetworkManagerConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,9 +89,18 @@ public async Task Delete_DeleteManagementGroupNetworkManagerConnection() ManagementGroupNetworkManagerConnectionResource managementGroupNetworkManagerConnection = client.GetManagementGroupNetworkManagerConnectionResource(managementGroupNetworkManagerConnectionResourceId); // invoke the operation - await managementGroupNetworkManagerConnection.DeleteAsync(WaitUntil.Completed); + NetworkManagerConnectionData data = new NetworkManagerConnectionData + { + NetworkManagerId = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroup/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager"), + }; + ArmOperation lro = await managementGroupNetworkManagerConnection.UpdateAsync(WaitUntil.Completed, data); + ManagementGroupNetworkManagerConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NatGatewayCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NatGatewayCollection.cs index 5b68d6cac4430..68c06f340cd34 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NatGatewayCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NatGatewayCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_NatGatewayCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNatGateway() + public async Task CreateOrUpdate_CreateNatGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayGet.json - // this example is just showing the usage of "NatGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayCreateOrUpdate.json + // this example is just showing the usage of "NatGateways_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,8 +41,22 @@ public async Task Get_GetNatGateway() NatGatewayCollection collection = resourceGroupResource.GetNatGateways(); // invoke the operation - string natGatewayName = "test-natGateway"; - NatGatewayResource result = await collection.GetAsync(natGatewayName); + string natGatewayName = "test-natgateway"; + NatGatewayData data = new NatGatewayData + { + SkuName = NatGatewaySkuName.Standard, + PublicIPAddresses = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/PublicIpAddress1"), +}}, + PublicIPPrefixes = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPPrefixes/PublicIpPrefix1"), +}}, + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, natGatewayName, data); + NatGatewayResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +67,7 @@ public async Task Get_GetNatGateway() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNatGateway() + public async Task Get_GetNatGateway() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayGet.json // this example is just showing the usage of "NatGateways_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +89,21 @@ public async Task Exists_GetNatGateway() // invoke the operation string natGatewayName = "test-natGateway"; - bool result = await collection.ExistsAsync(natGatewayName); + NatGatewayResource result = await collection.GetAsync(natGatewayName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NatGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNatGateway() + public async Task GetAll_ListNatGatewaysInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayGet.json - // this example is just showing the usage of "NatGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayList.json + // this example is just showing the usage of "NatGateways_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +120,25 @@ public async Task GetIfExists_GetNatGateway() // get the collection of this NatGatewayResource NatGatewayCollection collection = resourceGroupResource.GetNatGateways(); - // invoke the operation - string natGatewayName = "test-natGateway"; - NullableResponse response = await collection.GetIfExistsAsync(natGatewayName); - NatGatewayResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NatGatewayResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NatGatewayData resourceData = result.Data; + NatGatewayData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNatGateway() + public async Task Exists_GetNatGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayCreateOrUpdate.json - // this example is just showing the usage of "NatGateways_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayGet.json + // this example is just showing the usage of "NatGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,42 +156,18 @@ public async Task CreateOrUpdate_CreateNatGateway() NatGatewayCollection collection = resourceGroupResource.GetNatGateways(); // invoke the operation - string natGatewayName = "test-natgateway"; - NatGatewayData data = new NatGatewayData() - { - SkuName = NatGatewaySkuName.Standard, - PublicIPAddresses = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/PublicIpAddress1"), -} -}, - PublicIPPrefixes = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPPrefixes/PublicIpPrefix1"), -} -}, - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, natGatewayName, data); - NatGatewayResource result = lro.Value; + string natGatewayName = "test-natGateway"; + bool result = await collection.ExistsAsync(natGatewayName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NatGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNatGatewaysInResourceGroup() + public async Task GetIfExists_GetNatGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayList.json - // this example is just showing the usage of "NatGateways_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayGet.json + // this example is just showing the usage of "NatGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,17 +184,23 @@ public async Task GetAll_ListNatGatewaysInResourceGroup() // get the collection of this NatGatewayResource NatGatewayCollection collection = resourceGroupResource.GetNatGateways(); - // invoke the operation and iterate over the result - await foreach (NatGatewayResource item in collection.GetAllAsync()) + // invoke the operation + string natGatewayName = "test-natGateway"; + NullableResponse response = await collection.GetIfExistsAsync(natGatewayName); + NatGatewayResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NatGatewayData resourceData = item.Data; + NatGatewayData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NatGatewayResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NatGatewayResource.cs index 06e6aaf8584ff..3145817b2b703 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NatGatewayResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NatGatewayResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_NatGatewayResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNatGateway() + public async Task Get_GetNatGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayDelete.json - // this example is just showing the usage of "NatGateways_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayGet.json + // this example is just showing the usage of "NatGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteNatGateway() NatGatewayResource natGateway = client.GetNatGatewayResource(natGatewayResourceId); // invoke the operation - await natGateway.DeleteAsync(WaitUntil.Completed); + NatGatewayResource result = await natGateway.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NatGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNatGateway() + public async Task Delete_DeleteNatGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayGet.json - // this example is just showing the usage of "NatGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayDelete.json + // this example is just showing the usage of "NatGateways_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetNatGateway() NatGatewayResource natGateway = client.GetNatGatewayResource(natGatewayResourceId); // invoke the operation - NatGatewayResource result = await natGateway.GetAsync(); + await natGateway.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NatGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateNatGatewayTags() NatGatewayResource natGateway = client.GetNatGatewayResource(natGatewayResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NatGatewayResource result = await natGateway.UpdateAsync(networkTagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdateNatGatewayTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNatGateways_ListAllNatGateways() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayListAll.json - // this example is just showing the usage of "NatGateways_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NatGatewayResource item in subscriptionResource.GetNatGatewaysAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NatGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupCollection.cs index a403b8ed1906b..535b623f7f9ed 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NetworkGroupsGet() + public async Task CreateOrUpdate_NetworkGroupsPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupGet.json - // this example is just showing the usage of "NetworkGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupPut.json + // this example is just showing the usage of "NetworkGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,13 @@ public async Task Get_NetworkGroupsGet() // invoke the operation string networkGroupName = "testNetworkGroup"; - NetworkGroupResource result = await collection.GetAsync(networkGroupName); + NetworkGroupData data = new NetworkGroupData + { + Description = "A sample group", + MemberType = NetworkGroupMemberType.VirtualNetwork, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkGroupName, data); + NetworkGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +58,7 @@ public async Task Get_NetworkGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkGroupsGet() + public async Task Get_NetworkGroupsGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupGet.json // this example is just showing the usage of "NetworkGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +81,21 @@ public async Task Exists_NetworkGroupsGet() // invoke the operation string networkGroupName = "testNetworkGroup"; - bool result = await collection.ExistsAsync(networkGroupName); + NetworkGroupResource result = await collection.GetAsync(networkGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkGroupsGet() + public async Task GetAll_NetworkGroupsList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupGet.json - // this example is just showing the usage of "NetworkGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupList.json + // this example is just showing the usage of "NetworkGroups_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +113,25 @@ public async Task GetIfExists_NetworkGroupsGet() // get the collection of this NetworkGroupResource NetworkGroupCollection collection = networkManager.GetNetworkGroups(); - // invoke the operation - string networkGroupName = "testNetworkGroup"; - NullableResponse response = await collection.GetIfExistsAsync(networkGroupName); - NetworkGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NetworkGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkGroupData resourceData = result.Data; + NetworkGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NetworkGroupsPut() + public async Task Exists_NetworkGroupsGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupPut.json - // this example is just showing the usage of "NetworkGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupGet.json + // this example is just showing the usage of "NetworkGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,27 +151,17 @@ public async Task CreateOrUpdate_NetworkGroupsPut() // invoke the operation string networkGroupName = "testNetworkGroup"; - NetworkGroupData data = new NetworkGroupData() - { - Description = "A sample group", - MemberType = NetworkGroupMemberType.VirtualNetwork, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkGroupName, data); - NetworkGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(networkGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkGroupsList() + public async Task GetIfExists_NetworkGroupsGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupList.json - // this example is just showing the usage of "NetworkGroups_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupGet.json + // this example is just showing the usage of "NetworkGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_NetworkGroupsList() // get the collection of this NetworkGroupResource NetworkGroupCollection collection = networkManager.GetNetworkGroups(); - // invoke the operation and iterate over the result - await foreach (NetworkGroupResource item in collection.GetAllAsync()) + // invoke the operation + string networkGroupName = "testNetworkGroup"; + NullableResponse response = await collection.GetIfExistsAsync(networkGroupName); + NetworkGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkGroupData resourceData = item.Data; + NetworkGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupResource.cs index 5839308478c23..8ae06e44f3896 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupResource.cs @@ -49,10 +49,10 @@ public async Task Get_NetworkGroupsGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NetworkGroupsPut() + public async Task Delete_NetworkGroupsDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupPut.json - // this example is just showing the usage of "NetworkGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupDelete.json + // this example is just showing the usage of "NetworkGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,27 +69,18 @@ public async Task Update_NetworkGroupsPut() NetworkGroupResource networkGroup = client.GetNetworkGroupResource(networkGroupResourceId); // invoke the operation - NetworkGroupData data = new NetworkGroupData() - { - Description = "A sample group", - MemberType = NetworkGroupMemberType.VirtualNetwork, - }; - ArmOperation lro = await networkGroup.UpdateAsync(WaitUntil.Completed, data); - NetworkGroupResource result = lro.Value; + bool? force = false; + await networkGroup.DeleteAsync(WaitUntil.Completed, force: force); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkGroupsDelete() + public async Task Update_NetworkGroupsPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupDelete.json - // this example is just showing the usage of "NetworkGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGroupPut.json + // this example is just showing the usage of "NetworkGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,10 +97,19 @@ public async Task Delete_NetworkGroupsDelete() NetworkGroupResource networkGroup = client.GetNetworkGroupResource(networkGroupResourceId); // invoke the operation - bool? force = false; - await networkGroup.DeleteAsync(WaitUntil.Completed, force: force); + NetworkGroupData data = new NetworkGroupData + { + Description = "A sample group", + MemberType = NetworkGroupMemberType.VirtualNetwork, + }; + ArmOperation lro = await networkGroup.UpdateAsync(WaitUntil.Completed, data); + NetworkGroupResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupStaticMemberCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupStaticMemberCollection.cs index ec278f5879124..09afe4853eb0e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupStaticMemberCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupStaticMemberCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkGroupStaticMemberCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_StaticMembersGet() + public async Task CreateOrUpdate_StaticMemberPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberGet.json - // this example is just showing the usage of "StaticMembers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberPut.json + // this example is just showing the usage of "StaticMembers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_StaticMembersGet() // invoke the operation string staticMemberName = "testStaticMember"; - NetworkGroupStaticMemberResource result = await collection.GetAsync(staticMemberName); + NetworkGroupStaticMemberData data = new NetworkGroupStaticMemberData + { + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroup/rg1/providers/Microsoft.Network/virtualnetworks/vnet1"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, staticMemberName, data); + NetworkGroupStaticMemberResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +57,7 @@ public async Task Get_StaticMembersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_StaticMembersGet() + public async Task Get_StaticMembersGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberGet.json // this example is just showing the usage of "StaticMembers_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +81,21 @@ public async Task Exists_StaticMembersGet() // invoke the operation string staticMemberName = "testStaticMember"; - bool result = await collection.ExistsAsync(staticMemberName); + NetworkGroupStaticMemberResource result = await collection.GetAsync(staticMemberName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkGroupStaticMemberData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_StaticMembersGet() + public async Task GetAll_StaticMembersList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberGet.json - // this example is just showing the usage of "StaticMembers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberList.json + // this example is just showing the usage of "StaticMembers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,31 +114,25 @@ public async Task GetIfExists_StaticMembersGet() // get the collection of this NetworkGroupStaticMemberResource NetworkGroupStaticMemberCollection collection = networkGroup.GetNetworkGroupStaticMembers(); - // invoke the operation - string staticMemberName = "testStaticMember"; - NullableResponse response = await collection.GetIfExistsAsync(staticMemberName); - NetworkGroupStaticMemberResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NetworkGroupStaticMemberResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkGroupStaticMemberData resourceData = result.Data; + NetworkGroupStaticMemberData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_StaticMemberPut() + public async Task Exists_StaticMembersGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberPut.json - // this example is just showing the usage of "StaticMembers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberGet.json + // this example is just showing the usage of "StaticMembers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -150,26 +153,17 @@ public async Task CreateOrUpdate_StaticMemberPut() // invoke the operation string staticMemberName = "testStaticMember"; - NetworkGroupStaticMemberData data = new NetworkGroupStaticMemberData() - { - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroup/rg1/providers/Microsoft.Network/virtualnetworks/vnet1"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, staticMemberName, data); - NetworkGroupStaticMemberResource result = lro.Value; + bool result = await collection.ExistsAsync(staticMemberName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkGroupStaticMemberData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_StaticMembersList() + public async Task GetIfExists_StaticMembersGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberList.json - // this example is just showing the usage of "StaticMembers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberGet.json + // this example is just showing the usage of "StaticMembers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +182,23 @@ public async Task GetAll_StaticMembersList() // get the collection of this NetworkGroupStaticMemberResource NetworkGroupStaticMemberCollection collection = networkGroup.GetNetworkGroupStaticMembers(); - // invoke the operation and iterate over the result - await foreach (NetworkGroupStaticMemberResource item in collection.GetAllAsync()) + // invoke the operation + string staticMemberName = "testStaticMember"; + NullableResponse response = await collection.GetIfExistsAsync(staticMemberName); + NetworkGroupStaticMemberResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkGroupStaticMemberData resourceData = item.Data; + NetworkGroupStaticMemberData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupStaticMemberResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupStaticMemberResource.cs index 97288e06f50ee..4e7c82a5398bc 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupStaticMemberResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkGroupStaticMemberResource.cs @@ -49,10 +49,10 @@ public async Task Get_StaticMembersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_StaticMemberPut() + public async Task Delete_StaticMembersDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberPut.json - // this example is just showing the usage of "StaticMembers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberDelete.json + // this example is just showing the usage of "StaticMembers_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -62,34 +62,25 @@ public async Task Update_StaticMemberPut() // this example assumes you already have this NetworkGroupStaticMemberResource created on azure // for more information of creating NetworkGroupStaticMemberResource, please refer to the document of NetworkGroupStaticMemberResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "rg1"; - string networkManagerName = "testNetworkManager"; + string resourceGroupName = "SampleRG"; + string networkManagerName = "TestNM"; string networkGroupName = "testNetworkGroup"; string staticMemberName = "testStaticMember"; ResourceIdentifier networkGroupStaticMemberResourceId = NetworkGroupStaticMemberResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName, networkGroupName, staticMemberName); NetworkGroupStaticMemberResource networkGroupStaticMember = client.GetNetworkGroupStaticMemberResource(networkGroupStaticMemberResourceId); // invoke the operation - NetworkGroupStaticMemberData data = new NetworkGroupStaticMemberData() - { - ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroup/rg1/providers/Microsoft.Network/virtualnetworks/vnet1"), - }; - ArmOperation lro = await networkGroupStaticMember.UpdateAsync(WaitUntil.Completed, data); - NetworkGroupStaticMemberResource result = lro.Value; + await networkGroupStaticMember.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkGroupStaticMemberData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_StaticMembersDelete() + public async Task Update_StaticMemberPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberDelete.json - // this example is just showing the usage of "StaticMembers_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerStaticMemberPut.json + // this example is just showing the usage of "StaticMembers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -99,17 +90,26 @@ public async Task Delete_StaticMembersDelete() // this example assumes you already have this NetworkGroupStaticMemberResource created on azure // for more information of creating NetworkGroupStaticMemberResource, please refer to the document of NetworkGroupStaticMemberResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "SampleRG"; - string networkManagerName = "TestNM"; + string resourceGroupName = "rg1"; + string networkManagerName = "testNetworkManager"; string networkGroupName = "testNetworkGroup"; string staticMemberName = "testStaticMember"; ResourceIdentifier networkGroupStaticMemberResourceId = NetworkGroupStaticMemberResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName, networkGroupName, staticMemberName); NetworkGroupStaticMemberResource networkGroupStaticMember = client.GetNetworkGroupStaticMemberResource(networkGroupStaticMemberResourceId); // invoke the operation - await networkGroupStaticMember.DeleteAsync(WaitUntil.Completed); + NetworkGroupStaticMemberData data = new NetworkGroupStaticMemberData + { + ResourceId = new ResourceIdentifier("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroup/rg1/providers/Microsoft.Network/virtualnetworks/vnet1"), + }; + ArmOperation lro = await networkGroupStaticMember.UpdateAsync(WaitUntil.Completed, data); + NetworkGroupStaticMemberResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkGroupStaticMemberData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceCollection.cs index 109e2b4a4d50a..dc6d5bc733812 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkInterfaceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkInterface() + public async Task CreateOrUpdate_CreateNetworkInterface() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceGet.json - // this example is just showing the usage of "NetworkInterfaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceCreate.json + // this example is just showing the usage of "NetworkInterfaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,30 @@ public async Task Get_GetNetworkInterface() // invoke the operation string networkInterfaceName = "test-nic"; - NetworkInterfaceResource result = await collection.GetAsync(networkInterfaceName); + NetworkInterfaceData data = new NetworkInterfaceData + { + IPConfigurations = {new NetworkInterfaceIPConfigurationData +{ +Subnet = new SubnetData +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/rg1-vnet/subnets/default"), +}, +PublicIPAddress = new PublicIPAddressData +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/test-ip"), +}, +Name = "ipconfig1", +}, new NetworkInterfaceIPConfigurationData +{ +PrivateIPAddressPrefixLength = 28, +Name = "ipconfig2", +}}, + EnableAcceleratedNetworking = true, + DisableTcpStateTracking = true, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkInterfaceName, data); + NetworkInterfaceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +74,10 @@ public async Task Get_GetNetworkInterface() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkInterface() + public async Task CreateOrUpdate_CreateNetworkInterfaceWithGatewayLoadBalancerConsumerConfigured() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceGet.json - // this example is just showing the usage of "NetworkInterfaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceCreateGatewayLoadBalancerConsumer.json + // this example is just showing the usage of "NetworkInterfaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,14 +96,37 @@ public async Task Exists_GetNetworkInterface() // invoke the operation string networkInterfaceName = "test-nic"; - bool result = await collection.ExistsAsync(networkInterfaceName); + NetworkInterfaceData data = new NetworkInterfaceData + { + IPConfigurations = {new NetworkInterfaceIPConfigurationData +{ +GatewayLoadBalancerId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb-provider"), +Subnet = new SubnetData +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/rg1-vnet/subnets/default"), +}, +PublicIPAddress = new PublicIPAddressData +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/test-ip"), +}, +Name = "ipconfig1", +}}, + EnableAcceleratedNetworking = true, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkInterfaceName, data); + NetworkInterfaceResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkInterfaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkInterface() + public async Task Get_GetNetworkInterface() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceGet.json // this example is just showing the usage of "NetworkInterfaces_Get" operation, for the dependent resources, they will have to be created separately. @@ -102,29 +148,21 @@ public async Task GetIfExists_GetNetworkInterface() // invoke the operation string networkInterfaceName = "test-nic"; - NullableResponse response = await collection.GetIfExistsAsync(networkInterfaceName); - NetworkInterfaceResource result = response.HasValue ? response.Value : null; + NetworkInterfaceResource result = await collection.GetAsync(networkInterfaceName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkInterfaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkInterfaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkInterface() + public async Task GetAll_ListNetworkInterfacesInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceCreate.json - // this example is just showing the usage of "NetworkInterfaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceList.json + // this example is just showing the usage of "NetworkInterfaces_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,49 +179,25 @@ public async Task CreateOrUpdate_CreateNetworkInterface() // get the collection of this NetworkInterfaceResource NetworkInterfaceCollection collection = resourceGroupResource.GetNetworkInterfaces(); - // invoke the operation - string networkInterfaceName = "test-nic"; - NetworkInterfaceData data = new NetworkInterfaceData() + // invoke the operation and iterate over the result + await foreach (NetworkInterfaceResource item in collection.GetAllAsync()) { - IPConfigurations = -{ -new NetworkInterfaceIPConfigurationData() -{ -Subnet = new SubnetData() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/rg1-vnet/subnets/default"), -}, -PublicIPAddress = new PublicIPAddressData() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/test-ip"), -}, -Name = "ipconfig1", -},new NetworkInterfaceIPConfigurationData() -{ -PrivateIPAddressPrefixLength = 28, -Name = "ipconfig2", -} -}, - EnableAcceleratedNetworking = true, - DisableTcpStateTracking = true, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkInterfaceName, data); - NetworkInterfaceResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkInterfaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkInterfaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkInterfaceWithGatewayLoadBalancerConsumerConfigured() + public async Task Exists_GetNetworkInterface() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceCreateGatewayLoadBalancerConsumer.json - // this example is just showing the usage of "NetworkInterfaces_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceGet.json + // this example is just showing the usage of "NetworkInterfaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -202,43 +216,17 @@ public async Task CreateOrUpdate_CreateNetworkInterfaceWithGatewayLoadBalancerCo // invoke the operation string networkInterfaceName = "test-nic"; - NetworkInterfaceData data = new NetworkInterfaceData() - { - IPConfigurations = -{ -new NetworkInterfaceIPConfigurationData() -{ -GatewayLoadBalancerId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb-provider"), -Subnet = new SubnetData() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/rg1-vnet/subnets/default"), -}, -PublicIPAddress = new PublicIPAddressData() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/test-ip"), -}, -Name = "ipconfig1", -} -}, - EnableAcceleratedNetworking = true, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkInterfaceName, data); - NetworkInterfaceResource result = lro.Value; + bool result = await collection.ExistsAsync(networkInterfaceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkInterfaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNetworkInterfacesInResourceGroup() + public async Task GetIfExists_GetNetworkInterface() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceList.json - // this example is just showing the usage of "NetworkInterfaces_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceGet.json + // this example is just showing the usage of "NetworkInterfaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -255,17 +243,23 @@ public async Task GetAll_ListNetworkInterfacesInResourceGroup() // get the collection of this NetworkInterfaceResource NetworkInterfaceCollection collection = resourceGroupResource.GetNetworkInterfaces(); - // invoke the operation and iterate over the result - await foreach (NetworkInterfaceResource item in collection.GetAllAsync()) + // invoke the operation + string networkInterfaceName = "test-nic"; + NullableResponse response = await collection.GetIfExistsAsync(networkInterfaceName); + NetworkInterfaceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkInterfaceData resourceData = item.Data; + NetworkInterfaceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceIPConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceIPConfigurationCollection.cs index 72c69f824cd45..03de8c9172d58 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceIPConfigurationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceIPConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkInterfaceIPConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkInterfaceIPConfigurationList() + public async Task Get_NetworkInterfaceIPConfigurationGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceIPConfigurationList.json - // this example is just showing the usage of "NetworkInterfaceIPConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceIPConfigurationGet.json + // this example is just showing the usage of "NetworkInterfaceIPConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,32 +31,30 @@ public async Task GetAll_NetworkInterfaceIPConfigurationList() // for more information of creating NetworkInterfaceResource, please refer to the document of NetworkInterfaceResource string subscriptionId = "subid"; string resourceGroupName = "testrg"; - string networkInterfaceName = "nic1"; + string networkInterfaceName = "mynic"; ResourceIdentifier networkInterfaceResourceId = NetworkInterfaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkInterfaceName); NetworkInterfaceResource networkInterface = client.GetNetworkInterfaceResource(networkInterfaceResourceId); // get the collection of this NetworkInterfaceIPConfigurationResource NetworkInterfaceIPConfigurationCollection collection = networkInterface.GetNetworkInterfaceIPConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkInterfaceIPConfigurationResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkInterfaceIPConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string ipConfigurationName = "ipconfig1"; + NetworkInterfaceIPConfigurationResource result = await collection.GetAsync(ipConfigurationName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkInterfaceIPConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NetworkInterfaceIPConfigurationGet() + public async Task GetAll_NetworkInterfaceIPConfigurationList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceIPConfigurationGet.json - // this example is just showing the usage of "NetworkInterfaceIPConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceIPConfigurationList.json + // this example is just showing the usage of "NetworkInterfaceIPConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -67,22 +65,24 @@ public async Task Get_NetworkInterfaceIPConfigurationGet() // for more information of creating NetworkInterfaceResource, please refer to the document of NetworkInterfaceResource string subscriptionId = "subid"; string resourceGroupName = "testrg"; - string networkInterfaceName = "mynic"; + string networkInterfaceName = "nic1"; ResourceIdentifier networkInterfaceResourceId = NetworkInterfaceResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkInterfaceName); NetworkInterfaceResource networkInterface = client.GetNetworkInterfaceResource(networkInterfaceResourceId); // get the collection of this NetworkInterfaceIPConfigurationResource NetworkInterfaceIPConfigurationCollection collection = networkInterface.GetNetworkInterfaceIPConfigurations(); - // invoke the operation - string ipConfigurationName = "ipconfig1"; - NetworkInterfaceIPConfigurationResource result = await collection.GetAsync(ipConfigurationName); + // invoke the operation and iterate over the result + await foreach (NetworkInterfaceIPConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkInterfaceIPConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkInterfaceIPConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceResource.cs index 22555a94bfa0d..7732f1a013f77 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_NetworkInterfaceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkInterface() + public async Task Get_GetNetworkInterface() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceDelete.json - // this example is just showing the usage of "NetworkInterfaces_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceGet.json + // this example is just showing the usage of "NetworkInterfaces_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteNetworkInterface() NetworkInterfaceResource networkInterface = client.GetNetworkInterfaceResource(networkInterfaceResourceId); // invoke the operation - await networkInterface.DeleteAsync(WaitUntil.Completed); + NetworkInterfaceResource result = await networkInterface.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkInterfaceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkInterface() + public async Task Delete_DeleteNetworkInterface() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceGet.json - // this example is just showing the usage of "NetworkInterfaces_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceDelete.json + // this example is just showing the usage of "NetworkInterfaces_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetNetworkInterface() NetworkInterfaceResource networkInterface = client.GetNetworkInterfaceResource(networkInterfaceResourceId); // invoke the operation - NetworkInterfaceResource result = await networkInterface.GetAsync(); + await networkInterface.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkInterfaceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateNetworkInterfaceTags() NetworkInterfaceResource networkInterface = client.GetNetworkInterfaceResource(networkInterfaceResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NetworkInterfaceResource result = await networkInterface.UpdateAsync(networkTagsObject); @@ -111,37 +110,6 @@ public async Task Update_UpdateNetworkInterfaceTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkInterfaces_ListAllNetworkInterfaces() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceListAll.json - // this example is just showing the usage of "NetworkInterfaces_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkInterfaceResource item in subscriptionResource.GetNetworkInterfacesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkInterfaceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetEffectiveRouteTable_ShowNetworkInterfaceEffectiveRouteTables() diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceTapConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceTapConfigurationCollection.cs index 8a28d74d27446..d98638ea2b178 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceTapConfigurationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceTapConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkInterfaceTapConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkInterfaceTapConfigurations() + public async Task CreateOrUpdate_CreateNetworkInterfaceTapConfigurations() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationGet.json - // this example is just showing the usage of "NetworkInterfaceTapConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationCreate.json + // this example is just showing the usage of "NetworkInterfaceTapConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,15 @@ public async Task Get_GetNetworkInterfaceTapConfigurations() // invoke the operation string tapConfigurationName = "tapconfiguration1"; - NetworkInterfaceTapConfigurationResource result = await collection.GetAsync(tapConfigurationName); + NetworkInterfaceTapConfigurationData data = new NetworkInterfaceTapConfigurationData + { + VirtualNetworkTap = new VirtualNetworkTapData + { + Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworkTaps/testvtap"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tapConfigurationName, data); + NetworkInterfaceTapConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +59,7 @@ public async Task Get_GetNetworkInterfaceTapConfigurations() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkInterfaceTapConfigurations() + public async Task Get_GetNetworkInterfaceTapConfigurations() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationGet.json // this example is just showing the usage of "NetworkInterfaceTapConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +82,21 @@ public async Task Exists_GetNetworkInterfaceTapConfigurations() // invoke the operation string tapConfigurationName = "tapconfiguration1"; - bool result = await collection.ExistsAsync(tapConfigurationName); + NetworkInterfaceTapConfigurationResource result = await collection.GetAsync(tapConfigurationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkInterfaceTapConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkInterfaceTapConfigurations() + public async Task GetAll_ListVirtualNetworkTapConfigurations() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationGet.json - // this example is just showing the usage of "NetworkInterfaceTapConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationList.json + // this example is just showing the usage of "NetworkInterfaceTapConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +114,25 @@ public async Task GetIfExists_GetNetworkInterfaceTapConfigurations() // get the collection of this NetworkInterfaceTapConfigurationResource NetworkInterfaceTapConfigurationCollection collection = networkInterface.GetNetworkInterfaceTapConfigurations(); - // invoke the operation - string tapConfigurationName = "tapconfiguration1"; - NullableResponse response = await collection.GetIfExistsAsync(tapConfigurationName); - NetworkInterfaceTapConfigurationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NetworkInterfaceTapConfigurationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkInterfaceTapConfigurationData resourceData = result.Data; + NetworkInterfaceTapConfigurationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkInterfaceTapConfigurations() + public async Task Exists_GetNetworkInterfaceTapConfigurations() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationCreate.json - // this example is just showing the usage of "NetworkInterfaceTapConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationGet.json + // this example is just showing the usage of "NetworkInterfaceTapConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,29 +152,17 @@ public async Task CreateOrUpdate_CreateNetworkInterfaceTapConfigurations() // invoke the operation string tapConfigurationName = "tapconfiguration1"; - NetworkInterfaceTapConfigurationData data = new NetworkInterfaceTapConfigurationData() - { - VirtualNetworkTap = new VirtualNetworkTapData() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworkTaps/testvtap"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tapConfigurationName, data); - NetworkInterfaceTapConfigurationResource result = lro.Value; + bool result = await collection.ExistsAsync(tapConfigurationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkInterfaceTapConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworkTapConfigurations() + public async Task GetIfExists_GetNetworkInterfaceTapConfigurations() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationList.json - // this example is just showing the usage of "NetworkInterfaceTapConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationGet.json + // this example is just showing the usage of "NetworkInterfaceTapConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_ListVirtualNetworkTapConfigurations() // get the collection of this NetworkInterfaceTapConfigurationResource NetworkInterfaceTapConfigurationCollection collection = networkInterface.GetNetworkInterfaceTapConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkInterfaceTapConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string tapConfigurationName = "tapconfiguration1"; + NullableResponse response = await collection.GetIfExistsAsync(tapConfigurationName); + NetworkInterfaceTapConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkInterfaceTapConfigurationData resourceData = item.Data; + NetworkInterfaceTapConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceTapConfigurationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceTapConfigurationResource.cs index db7336d807d07..6b021bbd5d33f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceTapConfigurationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkInterfaceTapConfigurationResource.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkInterfaceTapConfigurationResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteTapConfiguration() + public async Task Get_GetNetworkInterfaceTapConfigurations() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationDelete.json - // this example is just showing the usage of "NetworkInterfaceTapConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationGet.json + // this example is just showing the usage of "NetworkInterfaceTapConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task Delete_DeleteTapConfiguration() NetworkInterfaceTapConfigurationResource networkInterfaceTapConfiguration = client.GetNetworkInterfaceTapConfigurationResource(networkInterfaceTapConfigurationResourceId); // invoke the operation - await networkInterfaceTapConfiguration.DeleteAsync(WaitUntil.Completed); + NetworkInterfaceTapConfigurationResource result = await networkInterfaceTapConfiguration.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkInterfaceTapConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkInterfaceTapConfigurations() + public async Task Delete_DeleteTapConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationGet.json - // this example is just showing the usage of "NetworkInterfaceTapConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceTapConfigurationDelete.json + // this example is just showing the usage of "NetworkInterfaceTapConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +68,9 @@ public async Task Get_GetNetworkInterfaceTapConfigurations() NetworkInterfaceTapConfigurationResource networkInterfaceTapConfiguration = client.GetNetworkInterfaceTapConfigurationResource(networkInterfaceTapConfigurationResourceId); // invoke the operation - NetworkInterfaceTapConfigurationResource result = await networkInterfaceTapConfiguration.GetAsync(); + await networkInterfaceTapConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkInterfaceTapConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -95,9 +95,9 @@ public async Task Update_CreateNetworkInterfaceTapConfigurations() NetworkInterfaceTapConfigurationResource networkInterfaceTapConfiguration = client.GetNetworkInterfaceTapConfigurationResource(networkInterfaceTapConfigurationResourceId); // invoke the operation - NetworkInterfaceTapConfigurationData data = new NetworkInterfaceTapConfigurationData() + NetworkInterfaceTapConfigurationData data = new NetworkInterfaceTapConfigurationData { - VirtualNetworkTap = new VirtualNetworkTapData() + VirtualNetworkTap = new VirtualNetworkTapData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/testrg/providers/Microsoft.Network/virtualNetworkTaps/testvtap"), }, diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerCollection.cs index 30770289fafe5..9e4d291437fbc 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkManagerCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NetworkManagersGet() + public async Task CreateOrUpdate_PutNetworkManager() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGet.json - // this example is just showing the usage of "NetworkManagers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerPut.json + // this example is just showing the usage of "NetworkManagers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,19 @@ public async Task Get_NetworkManagersGet() NetworkManagerCollection collection = resourceGroupResource.GetNetworkManagers(); // invoke the operation - string networkManagerName = "testNetworkManager"; - NetworkManagerResource result = await collection.GetAsync(networkManagerName); + string networkManagerName = "TestNetworkManager"; + NetworkManagerData data = new NetworkManagerData + { + Description = "My Test Network Manager", + NetworkManagerScopes = new NetworkManagerPropertiesNetworkManagerScopes + { + ManagementGroups = { "/Microsoft.Management/testmg" }, + Subscriptions = { "/subscriptions/00000000-0000-0000-0000-000000000000" }, + }, + NetworkManagerScopeAccesses = { NetworkConfigurationDeploymentType.Connectivity }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkManagerName, data); + NetworkManagerResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +63,7 @@ public async Task Get_NetworkManagersGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkManagersGet() + public async Task Get_NetworkManagersGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGet.json // this example is just showing the usage of "NetworkManagers_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +85,21 @@ public async Task Exists_NetworkManagersGet() // invoke the operation string networkManagerName = "testNetworkManager"; - bool result = await collection.ExistsAsync(networkManagerName); + NetworkManagerResource result = await collection.GetAsync(networkManagerName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkManagersGet() + public async Task GetAll_ListNetworkManager() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGet.json - // this example is just showing the usage of "NetworkManagers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerList.json + // this example is just showing the usage of "NetworkManagers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +116,25 @@ public async Task GetIfExists_NetworkManagersGet() // get the collection of this NetworkManagerResource NetworkManagerCollection collection = resourceGroupResource.GetNetworkManagers(); - // invoke the operation - string networkManagerName = "testNetworkManager"; - NullableResponse response = await collection.GetIfExistsAsync(networkManagerName); - NetworkManagerResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NetworkManagerResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkManagerData resourceData = result.Data; + NetworkManagerData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutNetworkManager() + public async Task Exists_NetworkManagersGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerPut.json - // this example is just showing the usage of "NetworkManagers_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGet.json + // this example is just showing the usage of "NetworkManagers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,42 +152,18 @@ public async Task CreateOrUpdate_PutNetworkManager() NetworkManagerCollection collection = resourceGroupResource.GetNetworkManagers(); // invoke the operation - string networkManagerName = "TestNetworkManager"; - NetworkManagerData data = new NetworkManagerData() - { - Description = "My Test Network Manager", - NetworkManagerScopes = new NetworkManagerPropertiesNetworkManagerScopes() - { - ManagementGroups = -{ -"/Microsoft.Management/testmg" -}, - Subscriptions = -{ -"/subscriptions/00000000-0000-0000-0000-000000000000" -}, - }, - NetworkManagerScopeAccesses = -{ -NetworkConfigurationDeploymentType.Connectivity -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkManagerName, data); - NetworkManagerResource result = lro.Value; + string networkManagerName = "testNetworkManager"; + bool result = await collection.ExistsAsync(networkManagerName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNetworkManager() + public async Task GetIfExists_NetworkManagersGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerList.json - // this example is just showing the usage of "NetworkManagers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerGet.json + // this example is just showing the usage of "NetworkManagers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -195,17 +180,23 @@ public async Task GetAll_ListNetworkManager() // get the collection of this NetworkManagerResource NetworkManagerCollection collection = resourceGroupResource.GetNetworkManagers(); - // invoke the operation and iterate over the result - await foreach (NetworkManagerResource item in collection.GetAllAsync()) + // invoke the operation + string networkManagerName = "testNetworkManager"; + NullableResponse response = await collection.GetIfExistsAsync(networkManagerName); + NetworkManagerResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkManagerData resourceData = item.Data; + NetworkManagerData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerResource.cs index 589a1a9a99caa..8ad10f665a7c6 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerResource.cs @@ -10,87 +10,12 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples { public partial class Sample_NetworkManagerResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetActiveConnectivityConfigurations_ListActiveConnectivityConfigurations() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerActiveConnectivityConfigurationsList.json - // this example is just showing the usage of "ListActiveConnectivityConfigurations" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkManagerResource created on azure - // for more information of creating NetworkManagerResource, please refer to the document of NetworkManagerResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - string networkManagerName = "testNetworkManager"; - ResourceIdentifier networkManagerResourceId = NetworkManagerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName); - NetworkManagerResource networkManager = client.GetNetworkManagerResource(networkManagerResourceId); - - // invoke the operation and iterate over the result - ActiveConfigurationContent content = new ActiveConfigurationContent() - { - Regions = -{ -new AzureLocation("westus") -}, - SkipToken = "fakeSkipTokenCode", - }; - await foreach (ActiveConnectivityConfiguration item in networkManager.GetActiveConnectivityConfigurationsAsync(content)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetActiveSecurityAdminRules_ListActiveSecurityAdminRules() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerActiveSecurityAdminRulesList.json - // this example is just showing the usage of "ListActiveSecurityAdminRules" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this NetworkManagerResource created on azure - // for more information of creating NetworkManagerResource, please refer to the document of NetworkManagerResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - string networkManagerName = "testNetworkManager"; - ResourceIdentifier networkManagerResourceId = NetworkManagerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName); - NetworkManagerResource networkManager = client.GetNetworkManagerResource(networkManagerResourceId); - - // invoke the operation and iterate over the result - ActiveConfigurationContent content = new ActiveConfigurationContent() - { - Regions = -{ -new AzureLocation("westus") -}, - SkipToken = "fakeSkipTokenCode", - }; - await foreach (ActiveBaseSecurityAdminRule item in networkManager.GetActiveSecurityAdminRulesAsync(content)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_NetworkManagersGet() @@ -169,12 +94,12 @@ public async Task Update_NetworkManagesPatch() NetworkManagerResource networkManager = client.GetNetworkManagerResource(networkManagerResourceId); // invoke the operation - NetworkManagerPatch patch = new NetworkManagerPatch() + NetworkManagerPatch patch = new NetworkManagerPatch { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NetworkManagerResource result = await networkManager.UpdateAsync(patch); @@ -188,30 +113,67 @@ public async Task Update_NetworkManagesPatch() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetNetworkManagers_NetworkManagersList() + public async Task GetActiveConnectivityConfigurations_ListActiveConnectivityConfigurations() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerActiveConnectivityConfigurationsList.json + // this example is just showing the usage of "ListActiveConnectivityConfigurations" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this NetworkManagerResource created on azure + // for more information of creating NetworkManagerResource, please refer to the document of NetworkManagerResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + string networkManagerName = "testNetworkManager"; + ResourceIdentifier networkManagerResourceId = NetworkManagerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName); + NetworkManagerResource networkManager = client.GetNetworkManagerResource(networkManagerResourceId); + + // invoke the operation and iterate over the result + ActiveConfigurationContent content = new ActiveConfigurationContent + { + Regions = { new AzureLocation("westus") }, + SkipToken = "fakeSkipTokenCode", + }; + await foreach (ActiveConnectivityConfiguration item in networkManager.GetActiveConnectivityConfigurationsAsync(content)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetActiveSecurityAdminRules_ListActiveSecurityAdminRules() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerListAll.json - // this example is just showing the usage of "NetworkManagers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerActiveSecurityAdminRulesList.json + // this example is just showing the usage of "ListActiveSecurityAdminRules" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this NetworkManagerResource created on azure + // for more information of creating NetworkManagerResource, please refer to the document of NetworkManagerResource string subscriptionId = "00000000-0000-0000-0000-000000000000"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "myResourceGroup"; + string networkManagerName = "testNetworkManager"; + ResourceIdentifier networkManagerResourceId = NetworkManagerResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName); + NetworkManagerResource networkManager = client.GetNetworkManagerResource(networkManagerResourceId); // invoke the operation and iterate over the result - await foreach (NetworkManagerResource item in subscriptionResource.GetNetworkManagersAsync()) + ActiveConfigurationContent content = new ActiveConfigurationContent + { + Regions = { new AzureLocation("westus") }, + SkipToken = "fakeSkipTokenCode", + }; + await foreach (ActiveBaseSecurityAdminRule item in networkManager.GetActiveSecurityAdminRulesAsync(content)) { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {item}"); } Console.WriteLine("Succeeded"); @@ -238,15 +200,9 @@ public async Task PostNetworkManagerCommit_NetworkManageCommitPost() NetworkManagerResource networkManager = client.GetNetworkManagerResource(networkManagerResourceId); // invoke the operation - NetworkManagerCommit networkManagerCommit = new NetworkManagerCommit(new string[] + NetworkManagerCommit networkManagerCommit = new NetworkManagerCommit(new string[] { "useast" }, NetworkConfigurationDeploymentType.SecurityAdmin) { -"useast" - }, NetworkConfigurationDeploymentType.SecurityAdmin) - { - ConfigurationIds = -{ -"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resoureGroupSample/providers/Microsoft.Network/networkManagers/testNetworkManager/securityAdminConfigurations/SampleSecurityAdminConfig" -}, + ConfigurationIds = { "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/resoureGroupSample/providers/Microsoft.Network/networkManagers/testNetworkManager/securityAdminConfigurations/SampleSecurityAdminConfig" }, }; ArmOperation lro = await networkManager.PostNetworkManagerCommitAsync(WaitUntil.Completed, networkManagerCommit); NetworkManagerCommit result = lro.Value; @@ -275,16 +231,10 @@ public async Task GetNetworkManagerDeploymentStatus_NetworkManagerDeploymentStat NetworkManagerResource networkManager = client.GetNetworkManagerResource(networkManagerResourceId); // invoke the operation and iterate over the result - NetworkManagerDeploymentStatusContent content = new NetworkManagerDeploymentStatusContent() + NetworkManagerDeploymentStatusContent content = new NetworkManagerDeploymentStatusContent { - Regions = -{ -"eastus","westus" -}, - DeploymentTypes = -{ -NetworkConfigurationDeploymentType.Connectivity,new NetworkConfigurationDeploymentType("AdminPolicy") -}, + Regions = { "eastus", "westus" }, + DeploymentTypes = { NetworkConfigurationDeploymentType.Connectivity, new NetworkConfigurationDeploymentType("AdminPolicy") }, SkipToken = "FakeSkipTokenCode", }; await foreach (NetworkManagerDeploymentStatus item in networkManager.GetNetworkManagerDeploymentStatusAsync(content)) diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingConfigurationCollection.cs index dd23320c5e8b8..1069603575de2 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingConfigurationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkManagerRoutingConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRoutingConfigurationsInANetworkManager() + public async Task CreateOrUpdate_CreateNetworkManagerRoutingConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationList.json - // this example is just showing the usage of "NetworkManagerRoutingConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationPut.json + // this example is just showing the usage of "NetworkManagerRoutingConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ListRoutingConfigurationsInANetworkManager() // get the collection of this NetworkManagerRoutingConfigurationResource NetworkManagerRoutingConfigurationCollection collection = networkManager.GetNetworkManagerRoutingConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkManagerRoutingConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string configurationName = "myTestRoutingConfig"; + NetworkManagerRoutingConfigurationData data = new NetworkManagerRoutingConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "A sample policy", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + NetworkManagerRoutingConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetRoutingConfigurations() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRoutingConfigurations() + public async Task GetAll_ListRoutingConfigurationsInANetworkManager() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationGet.json - // this example is just showing the usage of "NetworkManagerRoutingConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationList.json + // this example is just showing the usage of "NetworkManagerRoutingConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_GetRoutingConfigurations() // get the collection of this NetworkManagerRoutingConfigurationResource NetworkManagerRoutingConfigurationCollection collection = networkManager.GetNetworkManagerRoutingConfigurations(); - // invoke the operation - string configurationName = "myTestRoutingConfig"; - bool result = await collection.ExistsAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (NetworkManagerRoutingConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRoutingConfigurations() + public async Task Exists_GetRoutingConfigurations() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationGet.json // this example is just showing the usage of "NetworkManagerRoutingConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_GetRoutingConfigurations() // invoke the operation string configurationName = "myTestRoutingConfig"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - NetworkManagerRoutingConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkManagerRoutingConfiguration() + public async Task GetIfExists_GetRoutingConfigurations() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationPut.json - // this example is just showing the usage of "NetworkManagerRoutingConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationGet.json + // this example is just showing the usage of "NetworkManagerRoutingConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_CreateNetworkManagerRoutingConfiguration() // invoke the operation string configurationName = "myTestRoutingConfig"; - NetworkManagerRoutingConfigurationData data = new NetworkManagerRoutingConfigurationData() - { - Description = "A sample policy", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - NetworkManagerRoutingConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + NetworkManagerRoutingConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingConfigurationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingConfigurationResource.cs index 5562a181bdbf5..dedb11aac8977 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingConfigurationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingConfigurationResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetRoutingConfigurations() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateNetworkManagerRoutingConfiguration() + public async Task Delete_DeleteNetworkManagerRoutingConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationPut.json - // this example is just showing the usage of "NetworkManagerRoutingConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationDelete.json + // this example is just showing the usage of "NetworkManagerRoutingConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,17 @@ public async Task Update_CreateNetworkManagerRoutingConfiguration() NetworkManagerRoutingConfigurationResource networkManagerRoutingConfiguration = client.GetNetworkManagerRoutingConfigurationResource(networkManagerRoutingConfigurationResourceId); // invoke the operation - NetworkManagerRoutingConfigurationData data = new NetworkManagerRoutingConfigurationData() - { - Description = "A sample policy", - }; - ArmOperation lro = await networkManagerRoutingConfiguration.UpdateAsync(WaitUntil.Completed, data); - NetworkManagerRoutingConfigurationResource result = lro.Value; + await networkManagerRoutingConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkManagerRoutingConfiguration() + public async Task Update_CreateNetworkManagerRoutingConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationDelete.json - // this example is just showing the usage of "NetworkManagerRoutingConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingConfigurationPut.json + // this example is just showing the usage of "NetworkManagerRoutingConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,9 +95,18 @@ public async Task Delete_DeleteNetworkManagerRoutingConfiguration() NetworkManagerRoutingConfigurationResource networkManagerRoutingConfiguration = client.GetNetworkManagerRoutingConfigurationResource(networkManagerRoutingConfigurationResourceId); // invoke the operation - await networkManagerRoutingConfiguration.DeleteAsync(WaitUntil.Completed); + NetworkManagerRoutingConfigurationData data = new NetworkManagerRoutingConfigurationData + { + Description = "A sample policy", + }; + ArmOperation lro = await networkManagerRoutingConfiguration.UpdateAsync(WaitUntil.Completed, data); + NetworkManagerRoutingConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRuleCollection.cs index 6c3763c4caa4f..081b23942070f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkManagerRoutingRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRoutingRules() + public async Task CreateOrUpdate_CreateADefaultRoutingRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleList.json - // this example is just showing the usage of "RoutingRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRulePut.json + // this example is just showing the usage of "RoutingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,25 +41,30 @@ public async Task GetAll_ListRoutingRules() // get the collection of this NetworkManagerRoutingRuleResource NetworkManagerRoutingRuleCollection collection = networkManagerRoutingRules.GetNetworkManagerRoutingRules(); - // invoke the operation and iterate over the result - await foreach (NetworkManagerRoutingRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleName = "SampleRoutingRule"; + NetworkManagerRoutingRuleData data = new NetworkManagerRoutingRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "This is Sample Routing Rule", + Destination = new RoutingRuleRouteDestination(RoutingRuleDestinationType.AddressPrefix, "10.0.0.0/16"), + NextHop = new RoutingRuleNextHop(RoutingRuleNextHopType.VirtualNetworkGateway), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + NetworkManagerRoutingRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsRoutingRule() + public async Task CreateOrUpdate_CreateAnRoutingRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleGet.json - // this example is just showing the usage of "RoutingRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRulePut.json + // this example is just showing the usage of "RoutingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,7 +76,7 @@ public async Task Get_GetsRoutingRule() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string networkManagerName = "testNetworkManager"; - string configurationName = "myTestSecurityConfig"; + string configurationName = "myTestRoutingConfig"; string ruleCollectionName = "testRuleCollection"; ResourceIdentifier networkManagerRoutingRulesResourceId = NetworkManagerRoutingRulesResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName, configurationName, ruleCollectionName); NetworkManagerRoutingRulesResource networkManagerRoutingRules = client.GetNetworkManagerRoutingRulesResource(networkManagerRoutingRulesResourceId); @@ -81,7 +86,14 @@ public async Task Get_GetsRoutingRule() // invoke the operation string ruleName = "SampleRoutingRule"; - NetworkManagerRoutingRuleResource result = await collection.GetAsync(ruleName); + NetworkManagerRoutingRuleData data = new NetworkManagerRoutingRuleData + { + Description = "This is Sample Routing Rule", + Destination = new RoutingRuleRouteDestination(RoutingRuleDestinationType.AddressPrefix, "10.0.0.0/16"), + NextHop = new RoutingRuleNextHop(RoutingRuleNextHopType.VirtualNetworkGateway), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + NetworkManagerRoutingRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -92,7 +104,7 @@ public async Task Get_GetsRoutingRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsRoutingRule() + public async Task Get_GetsRoutingRule() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleGet.json // this example is just showing the usage of "RoutingRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -117,17 +129,21 @@ public async Task Exists_GetsRoutingRule() // invoke the operation string ruleName = "SampleRoutingRule"; - bool result = await collection.ExistsAsync(ruleName); + NetworkManagerRoutingRuleResource result = await collection.GetAsync(ruleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsRoutingRule() + public async Task GetAll_ListRoutingRules() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleGet.json - // this example is just showing the usage of "RoutingRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleList.json + // this example is just showing the usage of "RoutingRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -139,7 +155,7 @@ public async Task GetIfExists_GetsRoutingRule() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string networkManagerName = "testNetworkManager"; - string configurationName = "myTestSecurityConfig"; + string configurationName = "myTestRoutingConfig"; string ruleCollectionName = "testRuleCollection"; ResourceIdentifier networkManagerRoutingRulesResourceId = NetworkManagerRoutingRulesResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName, configurationName, ruleCollectionName); NetworkManagerRoutingRulesResource networkManagerRoutingRules = client.GetNetworkManagerRoutingRulesResource(networkManagerRoutingRulesResourceId); @@ -147,31 +163,25 @@ public async Task GetIfExists_GetsRoutingRule() // get the collection of this NetworkManagerRoutingRuleResource NetworkManagerRoutingRuleCollection collection = networkManagerRoutingRules.GetNetworkManagerRoutingRules(); - // invoke the operation - string ruleName = "SampleRoutingRule"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - NetworkManagerRoutingRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NetworkManagerRoutingRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkManagerRoutingRuleData resourceData = result.Data; + NetworkManagerRoutingRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateADefaultRoutingRule() + public async Task Exists_GetsRoutingRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRulePut.json - // this example is just showing the usage of "RoutingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleGet.json + // this example is just showing the usage of "RoutingRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,7 +193,7 @@ public async Task CreateOrUpdate_CreateADefaultRoutingRule() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string networkManagerName = "testNetworkManager"; - string configurationName = "myTestRoutingConfig"; + string configurationName = "myTestSecurityConfig"; string ruleCollectionName = "testRuleCollection"; ResourceIdentifier networkManagerRoutingRulesResourceId = NetworkManagerRoutingRulesResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName, configurationName, ruleCollectionName); NetworkManagerRoutingRulesResource networkManagerRoutingRules = client.GetNetworkManagerRoutingRulesResource(networkManagerRoutingRulesResourceId); @@ -193,28 +203,17 @@ public async Task CreateOrUpdate_CreateADefaultRoutingRule() // invoke the operation string ruleName = "SampleRoutingRule"; - NetworkManagerRoutingRuleData data = new NetworkManagerRoutingRuleData() - { - Description = "This is Sample Routing Rule", - Destination = new RoutingRuleRouteDestination(RoutingRuleDestinationType.AddressPrefix, "10.0.0.0/16"), - NextHop = new RoutingRuleNextHop(RoutingRuleNextHopType.VirtualNetworkGateway), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - NetworkManagerRoutingRuleResource result = lro.Value; + bool result = await collection.ExistsAsync(ruleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateAnRoutingRule() + public async Task GetIfExists_GetsRoutingRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRulePut.json - // this example is just showing the usage of "RoutingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleGet.json + // this example is just showing the usage of "RoutingRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -226,7 +225,7 @@ public async Task CreateOrUpdate_CreateAnRoutingRule() string subscriptionId = "00000000-0000-0000-0000-000000000000"; string resourceGroupName = "rg1"; string networkManagerName = "testNetworkManager"; - string configurationName = "myTestRoutingConfig"; + string configurationName = "myTestSecurityConfig"; string ruleCollectionName = "testRuleCollection"; ResourceIdentifier networkManagerRoutingRulesResourceId = NetworkManagerRoutingRulesResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName, configurationName, ruleCollectionName); NetworkManagerRoutingRulesResource networkManagerRoutingRules = client.GetNetworkManagerRoutingRulesResource(networkManagerRoutingRulesResourceId); @@ -236,20 +235,21 @@ public async Task CreateOrUpdate_CreateAnRoutingRule() // invoke the operation string ruleName = "SampleRoutingRule"; - NetworkManagerRoutingRuleData data = new NetworkManagerRoutingRuleData() - { - Description = "This is Sample Routing Rule", - Destination = new RoutingRuleRouteDestination(RoutingRuleDestinationType.AddressPrefix, "10.0.0.0/16"), - NextHop = new RoutingRuleNextHop(RoutingRuleNextHopType.VirtualNetworkGateway), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - NetworkManagerRoutingRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + NetworkManagerRoutingRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRuleResource.cs index f9ec5ed61c50d..892c147667ccd 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRuleResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRuleResource.cs @@ -51,10 +51,10 @@ public async Task Get_GetsRoutingRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateADefaultRoutingRule() + public async Task Delete_DeletesARoutingRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRulePut.json - // this example is just showing the usage of "RoutingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleDelete.json + // this example is just showing the usage of "RoutingRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,30 +68,20 @@ public async Task Update_CreateADefaultRoutingRule() string networkManagerName = "testNetworkManager"; string configurationName = "myTestRoutingConfig"; string ruleCollectionName = "testRuleCollection"; - string ruleName = "SampleRoutingRule"; + string ruleName = "sampleRule"; ResourceIdentifier networkManagerRoutingRuleResourceId = NetworkManagerRoutingRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName, configurationName, ruleCollectionName, ruleName); NetworkManagerRoutingRuleResource networkManagerRoutingRule = client.GetNetworkManagerRoutingRuleResource(networkManagerRoutingRuleResourceId); // invoke the operation - NetworkManagerRoutingRuleData data = new NetworkManagerRoutingRuleData() - { - Description = "This is Sample Routing Rule", - Destination = new RoutingRuleRouteDestination(RoutingRuleDestinationType.AddressPrefix, "10.0.0.0/16"), - NextHop = new RoutingRuleNextHop(RoutingRuleNextHopType.VirtualNetworkGateway), - }; - ArmOperation lro = await networkManagerRoutingRule.UpdateAsync(WaitUntil.Completed, data); - NetworkManagerRoutingRuleResource result = lro.Value; + bool? force = false; + await networkManagerRoutingRule.DeleteAsync(WaitUntil.Completed, force: force); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateAnRoutingRule() + public async Task Update_CreateADefaultRoutingRule() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRulePut.json // this example is just showing the usage of "RoutingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. @@ -113,7 +103,7 @@ public async Task Update_CreateAnRoutingRule() NetworkManagerRoutingRuleResource networkManagerRoutingRule = client.GetNetworkManagerRoutingRuleResource(networkManagerRoutingRuleResourceId); // invoke the operation - NetworkManagerRoutingRuleData data = new NetworkManagerRoutingRuleData() + NetworkManagerRoutingRuleData data = new NetworkManagerRoutingRuleData { Description = "This is Sample Routing Rule", Destination = new RoutingRuleRouteDestination(RoutingRuleDestinationType.AddressPrefix, "10.0.0.0/16"), @@ -131,10 +121,10 @@ public async Task Update_CreateAnRoutingRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesARoutingRule() + public async Task Update_CreateAnRoutingRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleDelete.json - // this example is just showing the usage of "RoutingRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRulePut.json + // this example is just showing the usage of "RoutingRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,15 +138,25 @@ public async Task Delete_DeletesARoutingRule() string networkManagerName = "testNetworkManager"; string configurationName = "myTestRoutingConfig"; string ruleCollectionName = "testRuleCollection"; - string ruleName = "sampleRule"; + string ruleName = "SampleRoutingRule"; ResourceIdentifier networkManagerRoutingRuleResourceId = NetworkManagerRoutingRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, networkManagerName, configurationName, ruleCollectionName, ruleName); NetworkManagerRoutingRuleResource networkManagerRoutingRule = client.GetNetworkManagerRoutingRuleResource(networkManagerRoutingRuleResourceId); // invoke the operation - bool? force = false; - await networkManagerRoutingRule.DeleteAsync(WaitUntil.Completed, force: force); + NetworkManagerRoutingRuleData data = new NetworkManagerRoutingRuleData + { + Description = "This is Sample Routing Rule", + Destination = new RoutingRuleRouteDestination(RoutingRuleDestinationType.AddressPrefix, "10.0.0.0/16"), + NextHop = new RoutingRuleNextHop(RoutingRuleNextHopType.VirtualNetworkGateway), + }; + ArmOperation lro = await networkManagerRoutingRule.UpdateAsync(WaitUntil.Completed, data); + NetworkManagerRoutingRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRulesCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRulesCollection.cs index 0b76464395260..7db8df7e0ea08 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRulesCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRulesCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkManagerRoutingRulesCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRoutingRuleCollections() + public async Task CreateOrUpdate_CreateOrUpdateARoutingRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionList.json - // this example is just showing the usage of "RoutingRuleCollections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionPut.json + // this example is just showing the usage of "RoutingRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,21 @@ public async Task GetAll_ListRoutingRuleCollections() // get the collection of this NetworkManagerRoutingRulesResource NetworkManagerRoutingRulesCollection collection = networkManagerRoutingConfiguration.GetAllNetworkManagerRoutingRules(); - // invoke the operation and iterate over the result - await foreach (NetworkManagerRoutingRulesResource item in collection.GetAllAsync()) + // invoke the operation + string ruleCollectionName = "testRuleCollection"; + NetworkManagerRoutingRulesData data = new NetworkManagerRoutingRulesData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingRulesData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "A sample policy", + AppliesTo = { new NetworkManagerRoutingGroupItem("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionName, data); + NetworkManagerRoutingRulesResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingRulesData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +94,10 @@ public async Task Get_GetsRoutingRuleCollection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsRoutingRuleCollection() + public async Task GetAll_ListRoutingRuleCollections() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionGet.json - // this example is just showing the usage of "RoutingRuleCollections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionList.json + // this example is just showing the usage of "RoutingRuleCollections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +116,22 @@ public async Task Exists_GetsRoutingRuleCollection() // get the collection of this NetworkManagerRoutingRulesResource NetworkManagerRoutingRulesCollection collection = networkManagerRoutingConfiguration.GetAllNetworkManagerRoutingRules(); - // invoke the operation - string ruleCollectionName = "testRuleCollection"; - bool result = await collection.ExistsAsync(ruleCollectionName); + // invoke the operation and iterate over the result + await foreach (NetworkManagerRoutingRulesResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingRulesData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsRoutingRuleCollection() + public async Task Exists_GetsRoutingRuleCollection() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionGet.json // this example is just showing the usage of "RoutingRuleCollections_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +155,17 @@ public async Task GetIfExists_GetsRoutingRuleCollection() // invoke the operation string ruleCollectionName = "testRuleCollection"; - NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionName); - NetworkManagerRoutingRulesResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleCollectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingRulesData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateARoutingRuleCollection() + public async Task GetIfExists_GetsRoutingRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionPut.json - // this example is just showing the usage of "RoutingRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionGet.json + // this example is just showing the usage of "RoutingRuleCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,22 +186,21 @@ public async Task CreateOrUpdate_CreateOrUpdateARoutingRuleCollection() // invoke the operation string ruleCollectionName = "testRuleCollection"; - NetworkManagerRoutingRulesData data = new NetworkManagerRoutingRulesData() - { - Description = "A sample policy", - AppliesTo = -{ -new NetworkManagerRoutingGroupItem("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionName, data); - NetworkManagerRoutingRulesResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionName); + NetworkManagerRoutingRulesResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingRulesData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingRulesData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRulesResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRulesResource.cs index 7c6a32f4c5ee7..24f41c370f524 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRulesResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerRoutingRulesResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetsRoutingRuleCollection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateARoutingRuleCollection() + public async Task Delete_DeletesAnRoutingRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionPut.json - // this example is just showing the usage of "RoutingRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionDelete.json + // this example is just showing the usage of "RoutingRuleCollections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,30 +71,17 @@ public async Task Update_CreateOrUpdateARoutingRuleCollection() NetworkManagerRoutingRulesResource networkManagerRoutingRules = client.GetNetworkManagerRoutingRulesResource(networkManagerRoutingRulesResourceId); // invoke the operation - NetworkManagerRoutingRulesData data = new NetworkManagerRoutingRulesData() - { - Description = "A sample policy", - AppliesTo = -{ -new NetworkManagerRoutingGroupItem("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup") -}, - }; - ArmOperation lro = await networkManagerRoutingRules.UpdateAsync(WaitUntil.Completed, data); - NetworkManagerRoutingRulesResource result = lro.Value; + await networkManagerRoutingRules.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerRoutingRulesData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAnRoutingRuleCollection() + public async Task Update_CreateOrUpdateARoutingRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionDelete.json - // this example is just showing the usage of "RoutingRuleCollections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerRoutingRuleCollectionPut.json + // this example is just showing the usage of "RoutingRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,9 +99,19 @@ public async Task Delete_DeletesAnRoutingRuleCollection() NetworkManagerRoutingRulesResource networkManagerRoutingRules = client.GetNetworkManagerRoutingRulesResource(networkManagerRoutingRulesResourceId); // invoke the operation - await networkManagerRoutingRules.DeleteAsync(WaitUntil.Completed); + NetworkManagerRoutingRulesData data = new NetworkManagerRoutingRulesData + { + Description = "A sample policy", + AppliesTo = { new NetworkManagerRoutingGroupItem("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup") }, + }; + ArmOperation lro = await networkManagerRoutingRules.UpdateAsync(WaitUntil.Completed, data); + NetworkManagerRoutingRulesResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerRoutingRulesData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserConfigurationCollection.cs index 1daff060a071b..cf8e79c5d745e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserConfigurationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserConfigurationCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_NetworkManagerSecurityUserConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecurityUserConfigurationsInANetworkManager() + public async Task CreateOrUpdate_CreateNetworkManagerSecurityUserConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationList.json - // this example is just showing the usage of "SecurityUserConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationPut.json + // this example is just showing the usage of "SecurityUserConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,20 @@ public async Task GetAll_ListSecurityUserConfigurationsInANetworkManager() // get the collection of this NetworkManagerSecurityUserConfigurationResource NetworkManagerSecurityUserConfigurationCollection collection = networkManager.GetNetworkManagerSecurityUserConfigurations(); - // invoke the operation and iterate over the result - await foreach (NetworkManagerSecurityUserConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string configurationName = "myTestSecurityConfig"; + NetworkManagerSecurityUserConfigurationData data = new NetworkManagerSecurityUserConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "A sample policy", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + NetworkManagerSecurityUserConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -87,10 +90,10 @@ public async Task Get_GetSecurityUserConfigurations() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSecurityUserConfigurations() + public async Task GetAll_ListSecurityUserConfigurationsInANetworkManager() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationGet.json - // this example is just showing the usage of "SecurityUserConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationList.json + // this example is just showing the usage of "SecurityUserConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -108,16 +111,22 @@ public async Task Exists_GetSecurityUserConfigurations() // get the collection of this NetworkManagerSecurityUserConfigurationResource NetworkManagerSecurityUserConfigurationCollection collection = networkManager.GetNetworkManagerSecurityUserConfigurations(); - // invoke the operation - string configurationName = "myTestSecurityConfig"; - bool result = await collection.ExistsAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (NetworkManagerSecurityUserConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSecurityUserConfigurations() + public async Task Exists_GetSecurityUserConfigurations() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationGet.json // this example is just showing the usage of "SecurityUserConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +149,17 @@ public async Task GetIfExists_GetSecurityUserConfigurations() // invoke the operation string configurationName = "myTestSecurityConfig"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - NetworkManagerSecurityUserConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkManagerSecurityUserConfiguration() + public async Task GetIfExists_GetSecurityUserConfigurations() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationPut.json - // this example is just showing the usage of "SecurityUserConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationGet.json + // this example is just showing the usage of "SecurityUserConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,18 +179,21 @@ public async Task CreateOrUpdate_CreateNetworkManagerSecurityUserConfiguration() // invoke the operation string configurationName = "myTestSecurityConfig"; - NetworkManagerSecurityUserConfigurationData data = new NetworkManagerSecurityUserConfigurationData() - { - Description = "A sample policy", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - NetworkManagerSecurityUserConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + NetworkManagerSecurityUserConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserConfigurationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserConfigurationResource.cs index ba4513f654ea8..900391e76ea2f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserConfigurationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserConfigurationResource.cs @@ -48,10 +48,10 @@ public async Task Get_GetSecurityUserConfigurations() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateNetworkManagerSecurityUserConfiguration() + public async Task Delete_DeleteNetworkManagerSecurityUserConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationPut.json - // this example is just showing the usage of "SecurityUserConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationDelete.json + // this example is just showing the usage of "SecurityUserConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,26 +68,18 @@ public async Task Update_CreateNetworkManagerSecurityUserConfiguration() NetworkManagerSecurityUserConfigurationResource networkManagerSecurityUserConfiguration = client.GetNetworkManagerSecurityUserConfigurationResource(networkManagerSecurityUserConfigurationResourceId); // invoke the operation - NetworkManagerSecurityUserConfigurationData data = new NetworkManagerSecurityUserConfigurationData() - { - Description = "A sample policy", - }; - ArmOperation lro = await networkManagerSecurityUserConfiguration.UpdateAsync(WaitUntil.Completed, data); - NetworkManagerSecurityUserConfigurationResource result = lro.Value; + bool? force = false; + await networkManagerSecurityUserConfiguration.DeleteAsync(WaitUntil.Completed, force: force); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkManagerSecurityUserConfiguration() + public async Task Update_CreateNetworkManagerSecurityUserConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationDelete.json - // this example is just showing the usage of "SecurityUserConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserConfigurationPut.json + // this example is just showing the usage of "SecurityUserConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,10 +96,18 @@ public async Task Delete_DeleteNetworkManagerSecurityUserConfiguration() NetworkManagerSecurityUserConfigurationResource networkManagerSecurityUserConfiguration = client.GetNetworkManagerSecurityUserConfigurationResource(networkManagerSecurityUserConfigurationResourceId); // invoke the operation - bool? force = false; - await networkManagerSecurityUserConfiguration.DeleteAsync(WaitUntil.Completed, force: force); + NetworkManagerSecurityUserConfigurationData data = new NetworkManagerSecurityUserConfigurationData + { + Description = "A sample policy", + }; + ArmOperation lro = await networkManagerSecurityUserConfiguration.UpdateAsync(WaitUntil.Completed, data); + NetworkManagerSecurityUserConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRuleCollection.cs index bf2d8c561df87..690016dbf3345 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkManagerSecurityUserRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecurityUserRules() + public async Task CreateOrUpdate_CreateASecurityUserRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleList.json - // this example is just showing the usage of "SecurityUserRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRulePut.json + // this example is just showing the usage of "SecurityUserRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,17 +41,34 @@ public async Task GetAll_ListSecurityUserRules() // get the collection of this NetworkManagerSecurityUserRuleResource NetworkManagerSecurityUserRuleCollection collection = networkManagerSecurityUserRules.GetNetworkManagerSecurityUserRules(); - // invoke the operation and iterate over the result - await foreach (NetworkManagerSecurityUserRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleName = "SampleUserRule"; + NetworkManagerSecurityUserRuleData data = new NetworkManagerSecurityUserRuleData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "Sample User Rule", + Protocol = SecurityConfigurationRuleProtocol.Tcp, + Sources = {new AddressPrefixItem +{ +AddressPrefix = "*", +AddressPrefixType = AddressPrefixType.IPPrefix, +}}, + Destinations = {new AddressPrefixItem +{ +AddressPrefix = "*", +AddressPrefixType = AddressPrefixType.IPPrefix, +}}, + SourcePortRanges = { "0-65535" }, + DestinationPortRanges = { "22" }, + Direction = SecurityConfigurationRuleDirection.Inbound, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + NetworkManagerSecurityUserRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -92,10 +109,10 @@ public async Task Get_GetsASecurityUserRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsASecurityUserRule() + public async Task GetAll_ListSecurityUserRules() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleGet.json - // this example is just showing the usage of "SecurityUserRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleList.json + // this example is just showing the usage of "SecurityUserRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -115,16 +132,22 @@ public async Task Exists_GetsASecurityUserRule() // get the collection of this NetworkManagerSecurityUserRuleResource NetworkManagerSecurityUserRuleCollection collection = networkManagerSecurityUserRules.GetNetworkManagerSecurityUserRules(); - // invoke the operation - string ruleName = "SampleUserRule"; - bool result = await collection.ExistsAsync(ruleName); + // invoke the operation and iterate over the result + await foreach (NetworkManagerSecurityUserRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsASecurityUserRule() + public async Task Exists_GetsASecurityUserRule() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleGet.json // this example is just showing the usage of "SecurityUserRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -149,29 +172,17 @@ public async Task GetIfExists_GetsASecurityUserRule() // invoke the operation string ruleName = "SampleUserRule"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - NetworkManagerSecurityUserRuleResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateASecurityUserRule() + public async Task GetIfExists_GetsASecurityUserRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRulePut.json - // this example is just showing the usage of "SecurityUserRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleGet.json + // this example is just showing the usage of "SecurityUserRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,44 +204,21 @@ public async Task CreateOrUpdate_CreateASecurityUserRule() // invoke the operation string ruleName = "SampleUserRule"; - NetworkManagerSecurityUserRuleData data = new NetworkManagerSecurityUserRuleData() - { - Description = "Sample User Rule", - Protocol = SecurityConfigurationRuleProtocol.Tcp, - Sources = -{ -new AddressPrefixItem() -{ -AddressPrefix = "*", -AddressPrefixType = AddressPrefixType.IPPrefix, -} -}, - Destinations = -{ -new AddressPrefixItem() -{ -AddressPrefix = "*", -AddressPrefixType = AddressPrefixType.IPPrefix, -} -}, - SourcePortRanges = -{ -"0-65535" -}, - DestinationPortRanges = -{ -"22" -}, - Direction = SecurityConfigurationRuleDirection.Inbound, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - NetworkManagerSecurityUserRuleResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + NetworkManagerSecurityUserRuleResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRuleResource.cs index 43f36fd6db643..658dff07a880e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRuleResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRuleResource.cs @@ -51,10 +51,10 @@ public async Task Get_GetsASecurityUserRule() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateASecurityUserRule() + public async Task Delete_DeleteASecurityUserRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRulePut.json - // this example is just showing the usage of "SecurityUserRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleDelete.json + // this example is just showing the usage of "SecurityUserRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,52 +73,18 @@ public async Task Update_CreateASecurityUserRule() NetworkManagerSecurityUserRuleResource networkManagerSecurityUserRule = client.GetNetworkManagerSecurityUserRuleResource(networkManagerSecurityUserRuleResourceId); // invoke the operation - NetworkManagerSecurityUserRuleData data = new NetworkManagerSecurityUserRuleData() - { - Description = "Sample User Rule", - Protocol = SecurityConfigurationRuleProtocol.Tcp, - Sources = -{ -new AddressPrefixItem() -{ -AddressPrefix = "*", -AddressPrefixType = AddressPrefixType.IPPrefix, -} -}, - Destinations = -{ -new AddressPrefixItem() -{ -AddressPrefix = "*", -AddressPrefixType = AddressPrefixType.IPPrefix, -} -}, - SourcePortRanges = -{ -"0-65535" -}, - DestinationPortRanges = -{ -"22" -}, - Direction = SecurityConfigurationRuleDirection.Inbound, - }; - ArmOperation lro = await networkManagerSecurityUserRule.UpdateAsync(WaitUntil.Completed, data); - NetworkManagerSecurityUserRuleResource result = lro.Value; + bool? force = false; + await networkManagerSecurityUserRule.DeleteAsync(WaitUntil.Completed, force: force); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteASecurityUserRule() + public async Task Update_CreateASecurityUserRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleDelete.json - // this example is just showing the usage of "SecurityUserRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRulePut.json + // this example is just showing the usage of "SecurityUserRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -137,10 +103,32 @@ public async Task Delete_DeleteASecurityUserRule() NetworkManagerSecurityUserRuleResource networkManagerSecurityUserRule = client.GetNetworkManagerSecurityUserRuleResource(networkManagerSecurityUserRuleResourceId); // invoke the operation - bool? force = false; - await networkManagerSecurityUserRule.DeleteAsync(WaitUntil.Completed, force: force); + NetworkManagerSecurityUserRuleData data = new NetworkManagerSecurityUserRuleData + { + Description = "Sample User Rule", + Protocol = SecurityConfigurationRuleProtocol.Tcp, + Sources = {new AddressPrefixItem +{ +AddressPrefix = "*", +AddressPrefixType = AddressPrefixType.IPPrefix, +}}, + Destinations = {new AddressPrefixItem +{ +AddressPrefix = "*", +AddressPrefixType = AddressPrefixType.IPPrefix, +}}, + SourcePortRanges = { "0-65535" }, + DestinationPortRanges = { "22" }, + Direction = SecurityConfigurationRuleDirection.Inbound, + }; + ArmOperation lro = await networkManagerSecurityUserRule.UpdateAsync(WaitUntil.Completed, data); + NetworkManagerSecurityUserRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRulesCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRulesCollection.cs index 74705df129cd9..7f38df1ab09fe 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRulesCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRulesCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkManagerSecurityUserRulesCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRuleCollectionsInASecurityConfiguration() + public async Task CreateOrUpdate_CreateOrUpdateASecurityUserRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionList.json - // this example is just showing the usage of "SecurityUserRuleCollections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionPut.json + // this example is just showing the usage of "SecurityUserRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,17 +40,21 @@ public async Task GetAll_ListRuleCollectionsInASecurityConfiguration() // get the collection of this NetworkManagerSecurityUserRulesResource NetworkManagerSecurityUserRulesCollection collection = networkManagerSecurityUserConfiguration.GetAllNetworkManagerSecurityUserRules(); - // invoke the operation and iterate over the result - await foreach (NetworkManagerSecurityUserRulesResource item in collection.GetAllAsync()) + // invoke the operation + string ruleCollectionName = "testRuleCollection"; + NetworkManagerSecurityUserRulesData data = new NetworkManagerSecurityUserRulesData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserRulesData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "A sample policy", + AppliesToGroups = { new SecurityUserGroupItem("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionName, data); + NetworkManagerSecurityUserRulesResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserRulesData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -90,10 +94,10 @@ public async Task Get_GetsSecurityUserRuleCollection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsSecurityUserRuleCollection() + public async Task GetAll_ListRuleCollectionsInASecurityConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionGet.json - // this example is just showing the usage of "SecurityUserRuleCollections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionList.json + // this example is just showing the usage of "SecurityUserRuleCollections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,16 +116,22 @@ public async Task Exists_GetsSecurityUserRuleCollection() // get the collection of this NetworkManagerSecurityUserRulesResource NetworkManagerSecurityUserRulesCollection collection = networkManagerSecurityUserConfiguration.GetAllNetworkManagerSecurityUserRules(); - // invoke the operation - string ruleCollectionName = "testRuleCollection"; - bool result = await collection.ExistsAsync(ruleCollectionName); + // invoke the operation and iterate over the result + await foreach (NetworkManagerSecurityUserRulesResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserRulesData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsSecurityUserRuleCollection() + public async Task Exists_GetsSecurityUserRuleCollection() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionGet.json // this example is just showing the usage of "SecurityUserRuleCollections_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +155,17 @@ public async Task GetIfExists_GetsSecurityUserRuleCollection() // invoke the operation string ruleCollectionName = "testRuleCollection"; - NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionName); - NetworkManagerSecurityUserRulesResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(ruleCollectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserRulesData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateOrUpdateASecurityUserRuleCollection() + public async Task GetIfExists_GetsSecurityUserRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionPut.json - // this example is just showing the usage of "SecurityUserRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionGet.json + // this example is just showing the usage of "SecurityUserRuleCollections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,22 +186,21 @@ public async Task CreateOrUpdate_CreateOrUpdateASecurityUserRuleCollection() // invoke the operation string ruleCollectionName = "testRuleCollection"; - NetworkManagerSecurityUserRulesData data = new NetworkManagerSecurityUserRulesData() - { - Description = "A sample policy", - AppliesToGroups = -{ -new SecurityUserGroupItem("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleCollectionName, data); - NetworkManagerSecurityUserRulesResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(ruleCollectionName); + NetworkManagerSecurityUserRulesResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserRulesData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserRulesData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRulesResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRulesResource.cs index 16fd87df02945..d1dceeddccc33 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRulesResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkManagerSecurityUserRulesResource.cs @@ -50,10 +50,10 @@ public async Task Get_GetsSecurityUserRuleCollection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateASecurityUserRuleCollection() + public async Task Delete_DeletesASecurityUserRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionPut.json - // this example is just showing the usage of "SecurityUserRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionDelete.json + // this example is just showing the usage of "SecurityUserRuleCollections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,30 +71,18 @@ public async Task Update_CreateOrUpdateASecurityUserRuleCollection() NetworkManagerSecurityUserRulesResource networkManagerSecurityUserRules = client.GetNetworkManagerSecurityUserRulesResource(networkManagerSecurityUserRulesResourceId); // invoke the operation - NetworkManagerSecurityUserRulesData data = new NetworkManagerSecurityUserRulesData() - { - Description = "A sample policy", - AppliesToGroups = -{ -new SecurityUserGroupItem("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup") -}, - }; - ArmOperation lro = await networkManagerSecurityUserRules.UpdateAsync(WaitUntil.Completed, data); - NetworkManagerSecurityUserRulesResource result = lro.Value; + bool? force = false; + await networkManagerSecurityUserRules.DeleteAsync(WaitUntil.Completed, force: force); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerSecurityUserRulesData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesASecurityUserRuleCollection() + public async Task Update_CreateOrUpdateASecurityUserRuleCollection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionDelete.json - // this example is just showing the usage of "SecurityUserRuleCollections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityUserRuleCollectionPut.json + // this example is just showing the usage of "SecurityUserRuleCollections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -112,10 +100,19 @@ public async Task Delete_DeletesASecurityUserRuleCollection() NetworkManagerSecurityUserRulesResource networkManagerSecurityUserRules = client.GetNetworkManagerSecurityUserRulesResource(networkManagerSecurityUserRulesResourceId); // invoke the operation - bool? force = false; - await networkManagerSecurityUserRules.DeleteAsync(WaitUntil.Completed, force: force); + NetworkManagerSecurityUserRulesData data = new NetworkManagerSecurityUserRulesData + { + Description = "A sample policy", + AppliesToGroups = { new SecurityUserGroupItem("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager/networkGroups/testGroup") }, + }; + ArmOperation lro = await networkManagerSecurityUserRules.UpdateAsync(WaitUntil.Completed, data); + NetworkManagerSecurityUserRulesResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerSecurityUserRulesData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkPrivateEndpointConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkPrivateEndpointConnectionCollection.cs index 1bfa4a12135d1..c2a28195a7d79 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkPrivateEndpointConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkPrivateEndpointConnectionCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkPrivateEndpointConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndPointConnection() + public async Task CreateOrUpdate_ApproveOrRejectPrivateEndPointConnectionForAPrivateLinkService() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateLinkServices_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceUpdatePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateLinkServices_UpdatePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,17 @@ public async Task Get_GetPrivateEndPointConnection() // invoke the operation string peConnectionName = "testPlePeConnection"; - NetworkPrivateEndpointConnectionResource result = await collection.GetAsync(peConnectionName); + NetworkPrivateEndpointConnectionData data = new NetworkPrivateEndpointConnectionData + { + ConnectionState = new NetworkPrivateLinkServiceConnectionState + { + Status = "Approved", + Description = "approved it for some reason.", + }, + Name = "testPlePeConnection", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peConnectionName, data); + NetworkPrivateEndpointConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +62,7 @@ public async Task Get_GetPrivateEndPointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateEndPointConnection() + public async Task Get_GetPrivateEndPointConnection() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGetPrivateEndpointConnection.json // this example is just showing the usage of "PrivateLinkServices_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +85,21 @@ public async Task Exists_GetPrivateEndPointConnection() // invoke the operation string peConnectionName = "testPlePeConnection"; - bool result = await collection.ExistsAsync(peConnectionName); + NetworkPrivateEndpointConnectionResource result = await collection.GetAsync(peConnectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateEndPointConnection() + public async Task GetAll_ListPrivateLinkServiceInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGetPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateLinkServices_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceListPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateLinkServices_ListPrivateEndpointConnections" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +117,25 @@ public async Task GetIfExists_GetPrivateEndPointConnection() // get the collection of this NetworkPrivateEndpointConnectionResource NetworkPrivateEndpointConnectionCollection collection = privateLinkService.GetNetworkPrivateEndpointConnections(); - // invoke the operation - string peConnectionName = "testPlePeConnection"; - NullableResponse response = await collection.GetIfExistsAsync(peConnectionName); - NetworkPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (NetworkPrivateEndpointConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkPrivateEndpointConnectionData resourceData = result.Data; + NetworkPrivateEndpointConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_ApproveOrRejectPrivateEndPointConnectionForAPrivateLinkService() + public async Task Exists_GetPrivateEndPointConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceUpdatePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateLinkServices_UpdatePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateLinkServices_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,31 +155,17 @@ public async Task CreateOrUpdate_ApproveOrRejectPrivateEndPointConnectionForAPri // invoke the operation string peConnectionName = "testPlePeConnection"; - NetworkPrivateEndpointConnectionData data = new NetworkPrivateEndpointConnectionData() - { - ConnectionState = new NetworkPrivateLinkServiceConnectionState() - { - Status = "Approved", - Description = "approved it for some reason.", - }, - Name = "testPlePeConnection", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peConnectionName, data); - NetworkPrivateEndpointConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(peConnectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateLinkServiceInResourceGroup() + public async Task GetIfExists_GetPrivateEndPointConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceListPrivateEndpointConnection.json - // this example is just showing the usage of "PrivateLinkServices_ListPrivateEndpointConnections" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGetPrivateEndpointConnection.json + // this example is just showing the usage of "PrivateLinkServices_GetPrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +183,23 @@ public async Task GetAll_ListPrivateLinkServiceInResourceGroup() // get the collection of this NetworkPrivateEndpointConnectionResource NetworkPrivateEndpointConnectionCollection collection = privateLinkService.GetNetworkPrivateEndpointConnections(); - // invoke the operation and iterate over the result - await foreach (NetworkPrivateEndpointConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string peConnectionName = "testPlePeConnection"; + NullableResponse response = await collection.GetIfExistsAsync(peConnectionName); + NetworkPrivateEndpointConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkPrivateEndpointConnectionData resourceData = item.Data; + NetworkPrivateEndpointConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkPrivateEndpointConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkPrivateEndpointConnectionResource.cs index d3bee760f6c4d..5d83f4a1cad21 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkPrivateEndpointConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkPrivateEndpointConnectionResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetPrivateEndPointConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ApproveOrRejectPrivateEndPointConnectionForAPrivateLinkService() + public async Task Delete_DeletePrivateEndPointConnectionForAPrivateLinkService() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceUpdatePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateLinkServices_UpdatePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceDeletePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateLinkServices_DeletePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,31 +69,17 @@ public async Task Update_ApproveOrRejectPrivateEndPointConnectionForAPrivateLink NetworkPrivateEndpointConnectionResource networkPrivateEndpointConnection = client.GetNetworkPrivateEndpointConnectionResource(networkPrivateEndpointConnectionResourceId); // invoke the operation - NetworkPrivateEndpointConnectionData data = new NetworkPrivateEndpointConnectionData() - { - ConnectionState = new NetworkPrivateLinkServiceConnectionState() - { - Status = "Approved", - Description = "approved it for some reason.", - }, - Name = "testPlePeConnection", - }; - ArmOperation lro = await networkPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); - NetworkPrivateEndpointConnectionResource result = lro.Value; + await networkPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkPrivateEndpointConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateEndPointConnectionForAPrivateLinkService() + public async Task Update_ApproveOrRejectPrivateEndPointConnectionForAPrivateLinkService() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceDeletePrivateEndpointConnection.json - // this example is just showing the usage of "PrivateLinkServices_DeletePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceUpdatePrivateEndpointConnection.json + // this example is just showing the usage of "PrivateLinkServices_UpdatePrivateEndpointConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -110,9 +96,23 @@ public async Task Delete_DeletePrivateEndPointConnectionForAPrivateLinkService() NetworkPrivateEndpointConnectionResource networkPrivateEndpointConnection = client.GetNetworkPrivateEndpointConnectionResource(networkPrivateEndpointConnectionResourceId); // invoke the operation - await networkPrivateEndpointConnection.DeleteAsync(WaitUntil.Completed); + NetworkPrivateEndpointConnectionData data = new NetworkPrivateEndpointConnectionData + { + ConnectionState = new NetworkPrivateLinkServiceConnectionState + { + Status = "Approved", + Description = "approved it for some reason.", + }, + Name = "testPlePeConnection", + }; + ArmOperation lro = await networkPrivateEndpointConnection.UpdateAsync(WaitUntil.Completed, data); + NetworkPrivateEndpointConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkPrivateEndpointConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkProfileCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkProfileCollection.cs index a1abbef01dbf2..e4380deda69b8 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkProfileCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkProfileCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkProfileCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkProfile() + public async Task CreateOrUpdate_CreateNetworkProfileDefaults() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetConfigOnly.json - // this example is just showing the usage of "NetworkProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileCreateConfigOnly.json + // this example is just showing the usage of "NetworkProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,24 @@ public async Task Get_GetNetworkProfile() // invoke the operation string networkProfileName = "networkProfile1"; - NetworkProfileResource result = await collection.GetAsync(networkProfileName); + NetworkProfileData data = new NetworkProfileData + { + ContainerNetworkInterfaceConfigurations = {new ContainerNetworkInterfaceConfiguration +{ +IPConfigurations = {new NetworkIPConfigurationProfile +{ +Subnet = new SubnetData +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/networkProfileVnet/subnets/networkProfileSubnet1"), +}, +Name = "ipconfig1", +}}, +Name = "eth1", +}}, + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkProfileName, data); + NetworkProfileResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +69,7 @@ public async Task Get_GetNetworkProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkProfile() + public async Task Get_GetNetworkProfile() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetConfigOnly.json // this example is just showing the usage of "NetworkProfiles_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,16 +91,20 @@ public async Task Exists_GetNetworkProfile() // invoke the operation string networkProfileName = "networkProfile1"; - bool result = await collection.ExistsAsync(networkProfileName); + NetworkProfileResource result = await collection.GetAsync(networkProfileName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkProfile() + public async Task Get_GetNetworkProfileWithContainerNetworkInterfaces() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetConfigOnly.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetWithContainerNic.json // this example is just showing the usage of "NetworkProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -103,28 +124,55 @@ public async Task GetIfExists_GetNetworkProfile() // invoke the operation string networkProfileName = "networkProfile1"; - NullableResponse response = await collection.GetIfExistsAsync(networkProfileName); - NetworkProfileResource result = response.HasValue ? response.Value : null; + NetworkProfileResource result = await collection.GetAsync(networkProfileName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListResourceGroupNetworkProfiles() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileList.json + // this example is just showing the usage of "NetworkProfiles_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkProfileResource + NetworkProfileCollection collection = resourceGroupResource.GetNetworkProfiles(); + + // invoke the operation and iterate over the result + await foreach (NetworkProfileResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkProfileData resourceData = result.Data; + NetworkProfileData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkProfileWithContainerNetworkInterfaces() + public async Task Exists_GetNetworkProfile() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetWithContainerNic.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetConfigOnly.json // this example is just showing the usage of "NetworkProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -144,13 +192,9 @@ public async Task Get_GetNetworkProfileWithContainerNetworkInterfaces() // invoke the operation string networkProfileName = "networkProfile1"; - NetworkProfileResource result = await collection.GetAsync(networkProfileName); + bool result = await collection.ExistsAsync(networkProfileName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -184,9 +228,9 @@ public async Task Exists_GetNetworkProfileWithContainerNetworkInterfaces() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkProfileWithContainerNetworkInterfaces() + public async Task GetIfExists_GetNetworkProfile() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetWithContainerNic.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetConfigOnly.json // this example is just showing the usage of "NetworkProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -225,10 +269,10 @@ public async Task GetIfExists_GetNetworkProfileWithContainerNetworkInterfaces() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkProfileDefaults() + public async Task GetIfExists_GetNetworkProfileWithContainerNetworkInterfaces() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileCreateConfigOnly.json - // this example is just showing the usage of "NetworkProfiles_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetWithContainerNic.json + // this example is just showing the usage of "NetworkProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -247,71 +291,21 @@ public async Task CreateOrUpdate_CreateNetworkProfileDefaults() // invoke the operation string networkProfileName = "networkProfile1"; - NetworkProfileData data = new NetworkProfileData() - { - ContainerNetworkInterfaceConfigurations = -{ -new ContainerNetworkInterfaceConfiguration() -{ -IPConfigurations = -{ -new NetworkIPConfigurationProfile() -{ -Subnet = new SubnetData() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/networkProfileVnet/subnets/networkProfileSubnet1"), -}, -Name = "ipconfig1", -} -}, -Name = "eth1", -} -}, - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkProfileName, data); - NetworkProfileResource result = lro.Value; - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListResourceGroupNetworkProfiles() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileList.json - // this example is just showing the usage of "NetworkProfiles_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this NetworkProfileResource - NetworkProfileCollection collection = resourceGroupResource.GetNetworkProfiles(); + NullableResponse response = await collection.GetIfExistsAsync(networkProfileName); + NetworkProfileResource result = response.HasValue ? response.Value : null; - // invoke the operation and iterate over the result - await foreach (NetworkProfileResource item in collection.GetAllAsync()) + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkProfileData resourceData = item.Data; + NetworkProfileData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkProfileResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkProfileResource.cs index 4e3da8949f570..fe2c2cd18b00f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkProfileResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkProfileResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_NetworkProfileResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkProfile() + public async Task Get_GetNetworkProfile() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileDelete.json - // this example is just showing the usage of "NetworkProfiles_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetConfigOnly.json + // this example is just showing the usage of "NetworkProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +37,20 @@ public async Task Delete_DeleteNetworkProfile() NetworkProfileResource networkProfile = client.GetNetworkProfileResource(networkProfileResourceId); // invoke the operation - await networkProfile.DeleteAsync(WaitUntil.Completed); + NetworkProfileResource result = await networkProfile.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkProfileData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkProfile() + public async Task Get_GetNetworkProfileWithContainerNetworkInterfaces() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetConfigOnly.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetWithContainerNic.json // this example is just showing the usage of "NetworkProfiles_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -75,10 +78,10 @@ public async Task Get_GetNetworkProfile() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkProfileWithContainerNetworkInterfaces() + public async Task Delete_DeleteNetworkProfile() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileGetWithContainerNic.json - // this example is just showing the usage of "NetworkProfiles_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileDelete.json + // this example is just showing the usage of "NetworkProfiles_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -94,13 +97,9 @@ public async Task Get_GetNetworkProfileWithContainerNetworkInterfaces() NetworkProfileResource networkProfile = client.GetNetworkProfileResource(networkProfileResourceId); // invoke the operation - NetworkProfileResource result = await networkProfile.GetAsync(); + await networkProfile.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkProfileData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -124,12 +123,12 @@ public async Task Update_UpdateNetworkProfileTags() NetworkProfileResource networkProfile = client.GetNetworkProfileResource(networkProfileResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NetworkProfileResource result = await networkProfile.UpdateAsync(networkTagsObject); @@ -140,36 +139,5 @@ public async Task Update_UpdateNetworkProfileTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkProfiles_ListAllNetworkProfiles() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileListAll.json - // this example is just showing the usage of "NetworkProfiles_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkProfileResource item in subscriptionResource.GetNetworkProfilesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkProfileData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityGroupCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityGroupCollection.cs index 4184b8fc837a5..586e162109a90 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityGroupCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityGroupCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkSecurityGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSecurityGroup() + public async Task CreateOrUpdate_CreateNetworkSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupGet.json - // this example is just showing the usage of "NetworkSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupCreate.json + // this example is just showing the usage of "NetworkSecurityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetNetworkSecurityGroup() // invoke the operation string networkSecurityGroupName = "testnsg"; - NetworkSecurityGroupResource result = await collection.GetAsync(networkSecurityGroupName); + NetworkSecurityGroupData data = new NetworkSecurityGroupData + { + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkSecurityGroupName, data); + NetworkSecurityGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +57,10 @@ public async Task Get_GetNetworkSecurityGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkSecurityGroup() + public async Task CreateOrUpdate_CreateNetworkSecurityGroupWithRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupGet.json - // this example is just showing the usage of "NetworkSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupCreateWithRule.json + // this example is just showing the usage of "NetworkSecurityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,14 +79,35 @@ public async Task Exists_GetNetworkSecurityGroup() // invoke the operation string networkSecurityGroupName = "testnsg"; - bool result = await collection.ExistsAsync(networkSecurityGroupName); + NetworkSecurityGroupData data = new NetworkSecurityGroupData + { + SecurityRules = {new SecurityRuleData +{ +Protocol = SecurityRuleProtocol.Asterisk, +SourcePortRange = "*", +DestinationPortRange = "80", +SourceAddressPrefix = "*", +DestinationAddressPrefix = "*", +Access = SecurityRuleAccess.Allow, +Priority = 130, +Direction = SecurityRuleDirection.Inbound, +Name = "rule1", +}}, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkSecurityGroupName, data); + NetworkSecurityGroupResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkSecurityGroup() + public async Task Get_GetNetworkSecurityGroup() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupGet.json // this example is just showing the usage of "NetworkSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -103,29 +129,21 @@ public async Task GetIfExists_GetNetworkSecurityGroup() // invoke the operation string networkSecurityGroupName = "testnsg"; - NullableResponse response = await collection.GetIfExistsAsync(networkSecurityGroupName); - NetworkSecurityGroupResource result = response.HasValue ? response.Value : null; + NetworkSecurityGroupResource result = await collection.GetAsync(networkSecurityGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkSecurityGroup() + public async Task GetAll_ListNetworkSecurityGroupsInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupCreate.json - // this example is just showing the usage of "NetworkSecurityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupList.json + // this example is just showing the usage of "NetworkSecurityGroups_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,28 +160,25 @@ public async Task CreateOrUpdate_CreateNetworkSecurityGroup() // get the collection of this NetworkSecurityGroupResource NetworkSecurityGroupCollection collection = resourceGroupResource.GetNetworkSecurityGroups(); - // invoke the operation - string networkSecurityGroupName = "testnsg"; - NetworkSecurityGroupData data = new NetworkSecurityGroupData() + // invoke the operation and iterate over the result + await foreach (NetworkSecurityGroupResource item in collection.GetAllAsync()) { - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkSecurityGroupName, data); - NetworkSecurityGroupResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkSecurityGroupWithRule() + public async Task Exists_GetNetworkSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupCreateWithRule.json - // this example is just showing the usage of "NetworkSecurityGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupGet.json + // this example is just showing the usage of "NetworkSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,41 +197,17 @@ public async Task CreateOrUpdate_CreateNetworkSecurityGroupWithRule() // invoke the operation string networkSecurityGroupName = "testnsg"; - NetworkSecurityGroupData data = new NetworkSecurityGroupData() - { - SecurityRules = -{ -new SecurityRuleData() -{ -Protocol = SecurityRuleProtocol.Asterisk, -SourcePortRange = "*", -DestinationPortRange = "80", -SourceAddressPrefix = "*", -DestinationAddressPrefix = "*", -Access = SecurityRuleAccess.Allow, -Priority = 130, -Direction = SecurityRuleDirection.Inbound, -Name = "rule1", -} -}, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkSecurityGroupName, data); - NetworkSecurityGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(networkSecurityGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNetworkSecurityGroupsInResourceGroup() + public async Task GetIfExists_GetNetworkSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupList.json - // this example is just showing the usage of "NetworkSecurityGroups_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupGet.json + // this example is just showing the usage of "NetworkSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -233,17 +224,23 @@ public async Task GetAll_ListNetworkSecurityGroupsInResourceGroup() // get the collection of this NetworkSecurityGroupResource NetworkSecurityGroupCollection collection = resourceGroupResource.GetNetworkSecurityGroups(); - // invoke the operation and iterate over the result - await foreach (NetworkSecurityGroupResource item in collection.GetAllAsync()) + // invoke the operation + string networkSecurityGroupName = "testnsg"; + NullableResponse response = await collection.GetIfExistsAsync(networkSecurityGroupName); + NetworkSecurityGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkSecurityGroupData resourceData = item.Data; + NetworkSecurityGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityGroupResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityGroupResource.cs index f37465ee47bde..ec2b0d9bbbbc9 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityGroupResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkSecurityGroupResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_NetworkSecurityGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkSecurityGroup() + public async Task Get_GetNetworkSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupDelete.json - // this example is just showing the usage of "NetworkSecurityGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupGet.json + // this example is just showing the usage of "NetworkSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteNetworkSecurityGroup() NetworkSecurityGroupResource networkSecurityGroup = client.GetNetworkSecurityGroupResource(networkSecurityGroupResourceId); // invoke the operation - await networkSecurityGroup.DeleteAsync(WaitUntil.Completed); + NetworkSecurityGroupResource result = await networkSecurityGroup.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSecurityGroup() + public async Task Delete_DeleteNetworkSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupGet.json - // this example is just showing the usage of "NetworkSecurityGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupDelete.json + // this example is just showing the usage of "NetworkSecurityGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetNetworkSecurityGroup() NetworkSecurityGroupResource networkSecurityGroup = client.GetNetworkSecurityGroupResource(networkSecurityGroupResourceId); // invoke the operation - NetworkSecurityGroupResource result = await networkSecurityGroup.GetAsync(); + await networkSecurityGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateNetworkSecurityGroupTags() NetworkSecurityGroupResource networkSecurityGroup = client.GetNetworkSecurityGroupResource(networkSecurityGroupResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NetworkSecurityGroupResource result = await networkSecurityGroup.UpdateAsync(networkTagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdateNetworkSecurityGroupTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkSecurityGroups_ListAllNetworkSecurityGroups() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupListAll.json - // this example is just showing the usage of "NetworkSecurityGroups_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkSecurityGroupResource item in subscriptionResource.GetNetworkSecurityGroupsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkSecurityGroupData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceCollection.cs index 7d80dd3120e9f..5c244a3645c01 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceCollection.cs @@ -19,109 +19,6 @@ namespace Azure.ResourceManager.Network.Samples { public partial class Sample_NetworkVirtualApplianceCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkVirtualAppliance() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceGet.json - // this example is just showing the usage of "NetworkVirtualAppliances_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this NetworkVirtualApplianceResource - NetworkVirtualApplianceCollection collection = resourceGroupResource.GetNetworkVirtualAppliances(); - - // invoke the operation - string networkVirtualApplianceName = "nva"; - NetworkVirtualApplianceResource result = await collection.GetAsync(networkVirtualApplianceName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkVirtualApplianceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkVirtualAppliance() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceGet.json - // this example is just showing the usage of "NetworkVirtualAppliances_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this NetworkVirtualApplianceResource - NetworkVirtualApplianceCollection collection = resourceGroupResource.GetNetworkVirtualAppliances(); - - // invoke the operation - string networkVirtualApplianceName = "nva"; - bool result = await collection.ExistsAsync(networkVirtualApplianceName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkVirtualAppliance() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceGet.json - // this example is just showing the usage of "NetworkVirtualAppliances_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this NetworkVirtualApplianceResource - NetworkVirtualApplianceCollection collection = resourceGroupResource.GetNetworkVirtualAppliances(); - - // invoke the operation - string networkVirtualApplianceName = "nva"; - NullableResponse response = await collection.GetIfExistsAsync(networkVirtualApplianceName); - NetworkVirtualApplianceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkVirtualApplianceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreateNetworkVirtualAppliance() @@ -146,84 +43,63 @@ public async Task CreateOrUpdate_CreateNetworkVirtualAppliance() // invoke the operation string networkVirtualApplianceName = "nva"; - NetworkVirtualApplianceData data = new NetworkVirtualApplianceData() + NetworkVirtualApplianceData data = new NetworkVirtualApplianceData { Identity = new ManagedServiceIdentity("UserAssigned") { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/subid/resourcegroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/identity1")] = new UserAssignedIdentity() }, }, - NvaSku = new VirtualApplianceSkuProperties() + NvaSku = new VirtualApplianceSkuProperties { Vendor = "Cisco SDWAN", BundledScaleUnit = "1", MarketPlaceVersion = "12.1", }, - BootStrapConfigurationBlobs = -{ -"https://csrncvhdstorage1.blob.core.windows.net/csrncvhdstoragecont/csrbootstrapconfig" -}, + BootStrapConfigurationBlobs = { "https://csrncvhdstorage1.blob.core.windows.net/csrncvhdstoragecont/csrbootstrapconfig" }, VirtualHubId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1"), - CloudInitConfigurationBlobs = -{ -"https://csrncvhdstorage1.blob.core.windows.net/csrncvhdstoragecont/csrcloudinitconfig" -}, + CloudInitConfigurationBlobs = { "https://csrncvhdstorage1.blob.core.windows.net/csrncvhdstoragecont/csrcloudinitconfig" }, VirtualApplianceAsn = 10000L, - NetworkInterfaceConfigurations = -{ -new VirtualApplianceNetworkInterfaceConfiguration() + NetworkInterfaceConfigurations = {new VirtualApplianceNetworkInterfaceConfiguration { NicType = NicTypeInRequest.PublicNic, -VirtualApplianceNetworkInterfaceIPConfigurations = -{ -new VirtualApplianceIPConfiguration() +VirtualApplianceNetworkInterfaceIPConfigurations = {new VirtualApplianceIPConfiguration { Name = "publicnicipconfig", IsPrimary = true, -},new VirtualApplianceIPConfiguration() +}, new VirtualApplianceIPConfiguration { Name = "publicnicipconfig-2", IsPrimary = false, -} -}, -},new VirtualApplianceNetworkInterfaceConfiguration() +}}, +}, new VirtualApplianceNetworkInterfaceConfiguration { NicType = NicTypeInRequest.PrivateNic, -VirtualApplianceNetworkInterfaceIPConfigurations = -{ -new VirtualApplianceIPConfiguration() +VirtualApplianceNetworkInterfaceIPConfigurations = {new VirtualApplianceIPConfiguration { Name = "privatenicipconfig", IsPrimary = true, -},new VirtualApplianceIPConfiguration() +}, new VirtualApplianceIPConfiguration { Name = "privatenicipconfig-2", IsPrimary = false, -} -}, -} -}, - AdditionalNics = -{ -new VirtualApplianceAdditionalNicProperties() +}}, +}}, + AdditionalNics = {new VirtualApplianceAdditionalNicProperties { Name = "exrsdwan", HasPublicIP = true, -} -}, - InternetIngressPublicIPs = -{ -new WritableSubResource() +}}, + InternetIngressPublicIPs = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/{{subscriptionId}}/resourceGroups/{{rg}}/providers/Microsoft.Network/publicIPAddresses/slbip"), -} -}, +}}, Location = new AzureLocation("West US"), Tags = { -["key1"] = "value1", +["key1"] = "value1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkVirtualApplianceName, data); @@ -260,17 +136,17 @@ public async Task CreateOrUpdate_CreateSaaSNetworkVirtualAppliance() // invoke the operation string networkVirtualApplianceName = "nva"; - NetworkVirtualApplianceData data = new NetworkVirtualApplianceData() + NetworkVirtualApplianceData data = new NetworkVirtualApplianceData { VirtualHubId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1"), - Delegation = new VirtualApplianceDelegationProperties() + Delegation = new VirtualApplianceDelegationProperties { ServiceName = "PaloAltoNetworks.Cloudngfw/firewalls", }, Location = new AzureLocation("West US"), Tags = { -["key1"] = "value1", +["key1"] = "value1" }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, networkVirtualApplianceName, data); @@ -283,6 +159,39 @@ public async Task CreateOrUpdate_CreateSaaSNetworkVirtualAppliance() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetNetworkVirtualAppliance() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceGet.json + // this example is just showing the usage of "NetworkVirtualAppliances_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkVirtualApplianceResource + NetworkVirtualApplianceCollection collection = resourceGroupResource.GetNetworkVirtualAppliances(); + + // invoke the operation + string networkVirtualApplianceName = "nva"; + NetworkVirtualApplianceResource result = await collection.GetAsync(networkVirtualApplianceName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkVirtualApplianceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task GetAll_ListAllNetworkVirtualApplianceForAGivenResourceGroup() @@ -317,5 +226,75 @@ public async Task GetAll_ListAllNetworkVirtualApplianceForAGivenResourceGroup() Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetNetworkVirtualAppliance() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceGet.json + // this example is just showing the usage of "NetworkVirtualAppliances_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkVirtualApplianceResource + NetworkVirtualApplianceCollection collection = resourceGroupResource.GetNetworkVirtualAppliances(); + + // invoke the operation + string networkVirtualApplianceName = "nva"; + bool result = await collection.ExistsAsync(networkVirtualApplianceName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetNetworkVirtualAppliance() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceGet.json + // this example is just showing the usage of "NetworkVirtualAppliances_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this NetworkVirtualApplianceResource + NetworkVirtualApplianceCollection collection = resourceGroupResource.GetNetworkVirtualAppliances(); + + // invoke the operation + string networkVirtualApplianceName = "nva"; + NullableResponse response = await collection.GetIfExistsAsync(networkVirtualApplianceName); + NetworkVirtualApplianceResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkVirtualApplianceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceConnectionCollection.cs index 07f2c1eb9144b..23876fd16f1e3 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceConnectionCollection.cs @@ -42,32 +42,23 @@ public async Task CreateOrUpdate_NetworkVirtualApplianceConnectionPut() // invoke the operation string connectionName = "connection1"; - NetworkVirtualApplianceConnectionData data = new NetworkVirtualApplianceConnectionData() + NetworkVirtualApplianceConnectionData data = new NetworkVirtualApplianceConnectionData { NamePropertiesName = "connection1", Asn = 64512L, TunnelIdentifier = 0L, - BgpPeerAddress = -{ -"169.254.16.13","169.254.16.14" -}, + BgpPeerAddress = { "169.254.16.13", "169.254.16.14" }, EnableInternetSecurity = false, - ConnectionRoutingConfiguration = new RoutingConfiguration() + ConnectionRoutingConfiguration = new RoutingConfiguration { AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), - PropagatedRouteTables = new PropagatedRouteTable() + PropagatedRouteTables = new PropagatedRouteTable { - Labels = -{ -"label1" -}, - Ids = -{ -new WritableSubResource() + Labels = { "label1" }, + Ids = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), -} -}, +}}, }, InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), @@ -120,10 +111,10 @@ public async Task Get_NetworkVirtualApplianceConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NetworkVirtualApplianceConnectionGet() + public async Task GetAll_NetworkVirtualApplianceConnectionList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionGet.json - // this example is just showing the usage of "NetworkVirtualApplianceConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionList.json + // this example is just showing the usage of "NetworkVirtualApplianceConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,16 +132,22 @@ public async Task Exists_NetworkVirtualApplianceConnectionGet() // get the collection of this NetworkVirtualApplianceConnectionResource NetworkVirtualApplianceConnectionCollection collection = networkVirtualAppliance.GetNetworkVirtualApplianceConnections(); - // invoke the operation - string connectionName = "connection1"; - bool result = await collection.ExistsAsync(connectionName); + // invoke the operation and iterate over the result + await foreach (NetworkVirtualApplianceConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkVirtualApplianceConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NetworkVirtualApplianceConnectionGet() + public async Task Exists_NetworkVirtualApplianceConnectionGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionGet.json // this example is just showing the usage of "NetworkVirtualApplianceConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -173,29 +170,17 @@ public async Task GetIfExists_NetworkVirtualApplianceConnectionGet() // invoke the operation string connectionName = "connection1"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - NetworkVirtualApplianceConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(connectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkVirtualApplianceConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkVirtualApplianceConnectionList() + public async Task GetIfExists_NetworkVirtualApplianceConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionList.json - // this example is just showing the usage of "NetworkVirtualApplianceConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionGet.json + // this example is just showing the usage of "NetworkVirtualApplianceConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,17 +198,23 @@ public async Task GetAll_NetworkVirtualApplianceConnectionList() // get the collection of this NetworkVirtualApplianceConnectionResource NetworkVirtualApplianceConnectionCollection collection = networkVirtualAppliance.GetNetworkVirtualApplianceConnections(); - // invoke the operation and iterate over the result - await foreach (NetworkVirtualApplianceConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string connectionName = "connection1"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + NetworkVirtualApplianceConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkVirtualApplianceConnectionData resourceData = item.Data; + NetworkVirtualApplianceConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceConnectionResource.cs index 21866d534634f..0735ab4b59b9e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceConnectionResource.cs @@ -19,10 +19,10 @@ public partial class Sample_NetworkVirtualApplianceConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NetworkVirtualApplianceConnectionPut() + public async Task Get_NetworkVirtualApplianceConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionPut.json - // this example is just showing the usage of "NetworkVirtualApplianceConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionGet.json + // this example is just showing the usage of "NetworkVirtualApplianceConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,40 +39,7 @@ public async Task Update_NetworkVirtualApplianceConnectionPut() NetworkVirtualApplianceConnectionResource networkVirtualApplianceConnection = client.GetNetworkVirtualApplianceConnectionResource(networkVirtualApplianceConnectionResourceId); // invoke the operation - NetworkVirtualApplianceConnectionData data = new NetworkVirtualApplianceConnectionData() - { - NamePropertiesName = "connection1", - Asn = 64512L, - TunnelIdentifier = 0L, - BgpPeerAddress = -{ -"169.254.16.13","169.254.16.14" -}, - EnableInternetSecurity = false, - ConnectionRoutingConfiguration = new RoutingConfiguration() - { - AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), - PropagatedRouteTables = new PropagatedRouteTable() - { - Labels = -{ -"label1" -}, - Ids = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), -} -}, - }, - InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), - OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), - }, - Name = "connection1", - }; - ArmOperation lro = await networkVirtualApplianceConnection.UpdateAsync(WaitUntil.Completed, data); - NetworkVirtualApplianceConnectionResource result = lro.Value; + NetworkVirtualApplianceConnectionResource result = await networkVirtualApplianceConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -83,10 +50,10 @@ public async Task Update_NetworkVirtualApplianceConnectionPut() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NetworkVirtualApplianceConnectionGet() + public async Task Delete_NetworkVirtualApplianceConnectionDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionGet.json - // this example is just showing the usage of "NetworkVirtualApplianceConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionDelete.json + // this example is just showing the usage of "NetworkVirtualApplianceConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,21 +70,17 @@ public async Task Get_NetworkVirtualApplianceConnectionGet() NetworkVirtualApplianceConnectionResource networkVirtualApplianceConnection = client.GetNetworkVirtualApplianceConnectionResource(networkVirtualApplianceConnectionResourceId); // invoke the operation - NetworkVirtualApplianceConnectionResource result = await networkVirtualApplianceConnection.GetAsync(); + await networkVirtualApplianceConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkVirtualApplianceConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NetworkVirtualApplianceConnectionDelete() + public async Task Update_NetworkVirtualApplianceConnectionPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionDelete.json - // this example is just showing the usage of "NetworkVirtualApplianceConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceConnectionPut.json + // this example is just showing the usage of "NetworkVirtualApplianceConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,9 +97,37 @@ public async Task Delete_NetworkVirtualApplianceConnectionDelete() NetworkVirtualApplianceConnectionResource networkVirtualApplianceConnection = client.GetNetworkVirtualApplianceConnectionResource(networkVirtualApplianceConnectionResourceId); // invoke the operation - await networkVirtualApplianceConnection.DeleteAsync(WaitUntil.Completed); + NetworkVirtualApplianceConnectionData data = new NetworkVirtualApplianceConnectionData + { + NamePropertiesName = "connection1", + Asn = 64512L, + TunnelIdentifier = 0L, + BgpPeerAddress = { "169.254.16.13", "169.254.16.14" }, + EnableInternetSecurity = false, + ConnectionRoutingConfiguration = new RoutingConfiguration + { + AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), + PropagatedRouteTables = new PropagatedRouteTable + { + Labels = { "label1" }, + Ids = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), +}}, + }, + InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), + OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), + }, + Name = "connection1", + }; + ArmOperation lro = await networkVirtualApplianceConnection.UpdateAsync(WaitUntil.Completed, data); + NetworkVirtualApplianceConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkVirtualApplianceConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceResource.cs index edf2c13bf80b0..046664fb2c3e1 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_NetworkVirtualApplianceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkVirtualAppliance() + public async Task Get_GetNetworkVirtualAppliance() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceDelete.json - // this example is just showing the usage of "NetworkVirtualAppliances_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceGet.json + // this example is just showing the usage of "NetworkVirtualAppliances_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteNetworkVirtualAppliance() NetworkVirtualApplianceResource networkVirtualAppliance = client.GetNetworkVirtualApplianceResource(networkVirtualApplianceResourceId); // invoke the operation - await networkVirtualAppliance.DeleteAsync(WaitUntil.Completed); + NetworkVirtualApplianceResource result = await networkVirtualAppliance.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkVirtualApplianceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkVirtualAppliance() + public async Task Delete_DeleteNetworkVirtualAppliance() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceGet.json - // this example is just showing the usage of "NetworkVirtualAppliances_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceDelete.json + // this example is just showing the usage of "NetworkVirtualAppliances_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetNetworkVirtualAppliance() NetworkVirtualApplianceResource networkVirtualAppliance = client.GetNetworkVirtualApplianceResource(networkVirtualApplianceResourceId); // invoke the operation - NetworkVirtualApplianceResource result = await networkVirtualAppliance.GetAsync(); + await networkVirtualAppliance.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkVirtualApplianceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateNetworkVirtualAppliance() NetworkVirtualApplianceResource networkVirtualAppliance = client.GetNetworkVirtualApplianceResource(networkVirtualApplianceResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, }; NetworkVirtualApplianceResource result = await networkVirtualAppliance.UpdateAsync(networkTagsObject); @@ -164,36 +163,5 @@ public async Task Restart_RestartSpecificNetworkVirtualApplianceVMsInVMScaleSet( Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkVirtualAppliances_ListAllNetworkVirtualAppliancesForAGivenSubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceListBySubscription.json - // this example is just showing the usage of "NetworkVirtualAppliances_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkVirtualApplianceResource item in subscriptionResource.GetNetworkVirtualAppliancesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkVirtualApplianceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceSkuCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceSkuCollection.cs index 5bd1fe0ebb8b5..8b442e0946a45 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceSkuCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkVirtualApplianceSkuCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_NetworkVirtualApplianceSkuCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NetworkVirtualApplianceSkuListResult() + public async Task Get_NetworkVirtualApplianceSkuGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSkuList.json - // this example is just showing the usage of "VirtualApplianceSkus_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSkuGet.json + // this example is just showing the usage of "VirtualApplianceSkus_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,25 +37,23 @@ public async Task GetAll_NetworkVirtualApplianceSkuListResult() // get the collection of this NetworkVirtualApplianceSkuResource NetworkVirtualApplianceSkuCollection collection = subscriptionResource.GetNetworkVirtualApplianceSkus(); - // invoke the operation and iterate over the result - await foreach (NetworkVirtualApplianceSkuResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkVirtualApplianceSkuData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string skuName = "ciscoSdwan"; + NetworkVirtualApplianceSkuResource result = await collection.GetAsync(skuName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkVirtualApplianceSkuData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NetworkVirtualApplianceSkuGet() + public async Task GetAll_NetworkVirtualApplianceSkuListResult() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSkuGet.json - // this example is just showing the usage of "VirtualApplianceSkus_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSkuList.json + // this example is just showing the usage of "VirtualApplianceSkus_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -71,15 +69,17 @@ public async Task Get_NetworkVirtualApplianceSkuGet() // get the collection of this NetworkVirtualApplianceSkuResource NetworkVirtualApplianceSkuCollection collection = subscriptionResource.GetNetworkVirtualApplianceSkus(); - // invoke the operation - string skuName = "ciscoSdwan"; - NetworkVirtualApplianceSkuResource result = await collection.GetAsync(skuName); + // invoke the operation and iterate over the result + await foreach (NetworkVirtualApplianceSkuResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkVirtualApplianceSkuData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkVirtualApplianceSkuData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkWatcherCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkWatcherCollection.cs index 8981973510793..f1ba0f7cd2635 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkWatcherCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkWatcherCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_CreateNetworkWatcher() // invoke the operation string networkWatcherName = "nw1"; - NetworkWatcherData data = new NetworkWatcherData() + NetworkWatcherData data = new NetworkWatcherData { Location = new AzureLocation("eastus"), }; @@ -89,10 +89,10 @@ public async Task Get_GetNetworkWatcher() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkWatcher() + public async Task GetAll_ListNetworkWatchers() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherGet.json - // this example is just showing the usage of "NetworkWatchers_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherList.json + // this example is just showing the usage of "NetworkWatchers_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +109,22 @@ public async Task Exists_GetNetworkWatcher() // get the collection of this NetworkWatcherResource NetworkWatcherCollection collection = resourceGroupResource.GetNetworkWatchers(); - // invoke the operation - string networkWatcherName = "nw1"; - bool result = await collection.ExistsAsync(networkWatcherName); + // invoke the operation and iterate over the result + await foreach (NetworkWatcherResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkWatcherData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkWatcher() + public async Task Exists_GetNetworkWatcher() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherGet.json // this example is just showing the usage of "NetworkWatchers_Get" operation, for the dependent resources, they will have to be created separately. @@ -140,29 +146,17 @@ public async Task GetIfExists_GetNetworkWatcher() // invoke the operation string networkWatcherName = "nw1"; - NullableResponse response = await collection.GetIfExistsAsync(networkWatcherName); - NetworkWatcherResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkWatcherName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkWatcherData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNetworkWatchers() + public async Task GetIfExists_GetNetworkWatcher() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherList.json - // this example is just showing the usage of "NetworkWatchers_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherGet.json + // this example is just showing the usage of "NetworkWatchers_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -179,17 +173,23 @@ public async Task GetAll_ListNetworkWatchers() // get the collection of this NetworkWatcherResource NetworkWatcherCollection collection = resourceGroupResource.GetNetworkWatchers(); - // invoke the operation and iterate over the result - await foreach (NetworkWatcherResource item in collection.GetAllAsync()) + // invoke the operation + string networkWatcherName = "nw1"; + NullableResponse response = await collection.GetIfExistsAsync(networkWatcherName); + NetworkWatcherResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkWatcherData resourceData = item.Data; + NetworkWatcherData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkWatcherResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkWatcherResource.cs index f921456154793..e6f276dd724e4 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkWatcherResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_NetworkWatcherResource.cs @@ -11,7 +11,6 @@ using Azure.Identity; using Azure.ResourceManager.Models; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -95,12 +94,12 @@ public async Task Update_UpdateNetworkWatcherTags() NetworkWatcherResource networkWatcher = client.GetNetworkWatcherResource(networkWatcherResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; NetworkWatcherResource result = await networkWatcher.UpdateAsync(networkTagsObject); @@ -112,37 +111,6 @@ public async Task Update_UpdateNetworkWatcherTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkWatchers_ListAllNetworkWatchers() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherListAll.json - // this example is just showing the usage of "NetworkWatchers_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (NetworkWatcherResource item in subscriptionResource.GetNetworkWatchersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkWatcherData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task GetTopology_GetTopology() @@ -164,7 +132,7 @@ public async Task GetTopology_GetTopology() NetworkWatcherResource networkWatcher = client.GetNetworkWatcherResource(networkWatcherResourceId); // invoke the operation - TopologyContent content = new TopologyContent() + TopologyContent content = new TopologyContent { TargetResourceGroupName = "rg2", }; @@ -194,7 +162,14 @@ public async Task VerifyIPFlow_IpFlowVerify() NetworkWatcherResource networkWatcher = client.GetNetworkWatcherResource(networkWatcherResourceId); // invoke the operation - VerificationIPFlowContent content = new VerificationIPFlowContent(new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1"), NetworkTrafficDirection.Outbound, IPFlowProtocol.Tcp, "80", "80", "10.2.0.4", "121.10.1.1"); + VerificationIPFlowContent content = new VerificationIPFlowContent( + new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1"), + NetworkTrafficDirection.Outbound, + IPFlowProtocol.Tcp, + "80", + "80", + "10.2.0.4", + "121.10.1.1"); ArmOperation lro = await networkWatcher.VerifyIPFlowAsync(WaitUntil.Completed, content); VerificationIPFlowResult result = lro.Value; @@ -343,7 +318,7 @@ public async Task SetFlowLogConfiguration_ConfigureFlowLog() { UserAssignedIdentities = { -[new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity(), +[new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1")] = new UserAssignedIdentity() }, }, }; @@ -402,7 +377,7 @@ public async Task CheckConnectivity_CheckConnectivity() NetworkWatcherResource networkWatcher = client.GetNetworkWatcherResource(networkWatcherResourceId); // invoke the operation - ConnectivityContent content = new ConnectivityContent(new ConnectivitySource(new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1")), new ConnectivityDestination() + ConnectivityContent content = new ConnectivityContent(new ConnectivitySource(new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1")), new ConnectivityDestination { Address = "192.168.100.4", Port = 3389, @@ -442,14 +417,8 @@ public async Task GetAzureReachabilityReport_GetAzureReachabilityReport() State = "washington", }, DateTimeOffset.Parse("2017-09-07T00:00:00Z"), DateTimeOffset.Parse("2017-09-10T00:00:00Z")) { - Providers = -{ -"Frontier Communications of America, Inc. - ASN 5650" -}, - AzureLocations = -{ -new AzureLocation("West US") -}, + Providers = { "Frontier Communications of America, Inc. - ASN 5650" }, + AzureLocations = { new AzureLocation("West US") }, }; ArmOperation lro = await networkWatcher.GetAzureReachabilityReportAsync(WaitUntil.Completed, content); AzureReachabilityReport result = lro.Value; @@ -478,12 +447,9 @@ public async Task GetAvailableProviders_GetAvailableProvidersList() NetworkWatcherResource networkWatcher = client.GetNetworkWatcherResource(networkWatcherResourceId); // invoke the operation - AvailableProvidersListContent content = new AvailableProvidersListContent() + AvailableProvidersListContent content = new AvailableProvidersListContent { - AzureLocations = -{ -new AzureLocation("West US") -}, + AzureLocations = { new AzureLocation("West US") }, Country = "United States", State = "washington", City = "seattle", @@ -517,7 +483,7 @@ public async Task GetNetworkConfigurationDiagnostic_NetworkConfigurationDiagnost // invoke the operation NetworkConfigurationDiagnosticContent content = new NetworkConfigurationDiagnosticContent(new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1"), new NetworkConfigurationDiagnosticProfile[] { -new NetworkConfigurationDiagnosticProfile(NetworkTrafficDirection.Inbound,"TCP","10.1.0.4","12.11.12.14","12100") +new NetworkConfigurationDiagnosticProfile(NetworkTrafficDirection.Inbound, "TCP", "10.1.0.4", "12.11.12.14", "12100") }); ArmOperation lro = await networkWatcher.GetNetworkConfigurationDiagnosticAsync(WaitUntil.Completed, content); NetworkConfigurationDiagnosticResponse result = lro.Value; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_OutboundRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_OutboundRuleCollection.cs index 401dd01f27186..704c54978e18b 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_OutboundRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_OutboundRuleCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_OutboundRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LoadBalancerOutboundRuleList() + public async Task Get_LoadBalancerOutboundRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerOutboundRuleList.json - // this example is just showing the usage of "LoadBalancerOutboundRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerOutboundRuleGet.json + // this example is just showing the usage of "LoadBalancerOutboundRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_LoadBalancerOutboundRuleList() // get the collection of this OutboundRuleResource OutboundRuleCollection collection = loadBalancer.GetOutboundRules(); - // invoke the operation and iterate over the result - await foreach (OutboundRuleResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OutboundRuleData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string outboundRuleName = "rule1"; + OutboundRuleResource result = await collection.GetAsync(outboundRuleName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OutboundRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LoadBalancerOutboundRuleGet() + public async Task GetAll_LoadBalancerOutboundRuleList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerOutboundRuleGet.json - // this example is just showing the usage of "LoadBalancerOutboundRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerOutboundRuleList.json + // this example is just showing the usage of "LoadBalancerOutboundRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_LoadBalancerOutboundRuleGet() // get the collection of this OutboundRuleResource OutboundRuleCollection collection = loadBalancer.GetOutboundRules(); - // invoke the operation - string outboundRuleName = "rule1"; - OutboundRuleResource result = await collection.GetAsync(outboundRuleName); + // invoke the operation and iterate over the result + await foreach (OutboundRuleResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + OutboundRuleData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - OutboundRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_P2SVpnGatewayCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_P2SVpnGatewayCollection.cs index a97114e2b1e9d..995acfe08b497 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_P2SVpnGatewayCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_P2SVpnGatewayCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_P2SVpnGatewayCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_P2SVpnGatewayGet() + public async Task CreateOrUpdate_P2SVpnGatewayPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayGet.json - // this example is just showing the usage of "P2sVpnGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayPut.json + // this example is just showing the usage of "P2sVpnGateways_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,49 @@ public async Task Get_P2SVpnGatewayGet() // invoke the operation string gatewayName = "p2sVpnGateway1"; - P2SVpnGatewayResource result = await collection.GetAsync(gatewayName); + P2SVpnGatewayData data = new P2SVpnGatewayData + { + VirtualHubId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1"), + P2SConnectionConfigurations = {new P2SConnectionConfiguration +{ +VpnClientAddressPrefixes = {"101.3.0.0/16"}, +RoutingConfiguration = new RoutingConfiguration +{ +AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), +PropagatedRouteTables = new PropagatedRouteTable +{ +Labels = {"label1", "label2"}, +Ids = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable2"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable3"), +}}, +}, +VnetRoutes = new VnetRoute +{ +StaticRoutes = {}, +}, +}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/p2sVpnGateways/p2sVpnGateway1/p2sConnectionConfigurations/P2SConnectionConfig1"), +Name = "P2SConnectionConfig1", +}}, + VpnGatewayScaleUnit = 1, + VpnServerConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfiguration1"), + CustomDnsServers = { "1.1.1.1", "2.2.2.2" }, + IsRoutingPreferenceInternet = false, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gatewayName, data); + P2SVpnGatewayResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +95,7 @@ public async Task Get_P2SVpnGatewayGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_P2SVpnGatewayGet() + public async Task Get_P2SVpnGatewayGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayGet.json // this example is just showing the usage of "P2sVpnGateways_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +117,21 @@ public async Task Exists_P2SVpnGatewayGet() // invoke the operation string gatewayName = "p2sVpnGateway1"; - bool result = await collection.ExistsAsync(gatewayName); + P2SVpnGatewayResource result = await collection.GetAsync(gatewayName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + P2SVpnGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_P2SVpnGatewayGet() + public async Task GetAll_P2SVpnGatewayListByResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayGet.json - // this example is just showing the usage of "P2sVpnGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayListByResourceGroup.json + // this example is just showing the usage of "P2sVpnGateways_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +148,25 @@ public async Task GetIfExists_P2SVpnGatewayGet() // get the collection of this P2SVpnGatewayResource P2SVpnGatewayCollection collection = resourceGroupResource.GetP2SVpnGateways(); - // invoke the operation - string gatewayName = "p2sVpnGateway1"; - NullableResponse response = await collection.GetIfExistsAsync(gatewayName); - P2SVpnGatewayResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (P2SVpnGatewayResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - P2SVpnGatewayData resourceData = result.Data; + P2SVpnGatewayData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_P2SVpnGatewayPut() + public async Task Exists_P2SVpnGatewayGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayPut.json - // this example is just showing the usage of "P2sVpnGateways_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayGet.json + // this example is just showing the usage of "P2sVpnGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,80 +185,17 @@ public async Task CreateOrUpdate_P2SVpnGatewayPut() // invoke the operation string gatewayName = "p2sVpnGateway1"; - P2SVpnGatewayData data = new P2SVpnGatewayData() - { - VirtualHubId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1"), - P2SConnectionConfigurations = -{ -new P2SConnectionConfiguration() -{ -VpnClientAddressPrefixes = -{ -"101.3.0.0/16" -}, -RoutingConfiguration = new RoutingConfiguration() -{ -AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), -PropagatedRouteTables = new PropagatedRouteTable() -{ -Labels = -{ -"label1","label2" -}, -Ids = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable2"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable3"), -} -}, -}, -VnetRoutes = new VnetRoute() -{ -StaticRoutes = -{ -}, -}, -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/p2sVpnGateways/p2sVpnGateway1/p2sConnectionConfigurations/P2SConnectionConfig1"), -Name = "P2SConnectionConfig1", -} -}, - VpnGatewayScaleUnit = 1, - VpnServerConfigurationId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfiguration1"), - CustomDnsServers = -{ -"1.1.1.1","2.2.2.2" -}, - IsRoutingPreferenceInternet = false, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gatewayName, data); - P2SVpnGatewayResource result = lro.Value; + bool result = await collection.ExistsAsync(gatewayName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - P2SVpnGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_P2SVpnGatewayListByResourceGroup() + public async Task GetIfExists_P2SVpnGatewayGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayListByResourceGroup.json - // this example is just showing the usage of "P2sVpnGateways_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayGet.json + // this example is just showing the usage of "P2sVpnGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -235,17 +212,23 @@ public async Task GetAll_P2SVpnGatewayListByResourceGroup() // get the collection of this P2SVpnGatewayResource P2SVpnGatewayCollection collection = resourceGroupResource.GetP2SVpnGateways(); - // invoke the operation and iterate over the result - await foreach (P2SVpnGatewayResource item in collection.GetAllAsync()) + // invoke the operation + string gatewayName = "p2sVpnGateway1"; + NullableResponse response = await collection.GetIfExistsAsync(gatewayName); + P2SVpnGatewayResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - P2SVpnGatewayData resourceData = item.Data; + P2SVpnGatewayData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_P2SVpnGatewayResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_P2SVpnGatewayResource.cs index 4e025c3f60317..eece2f69fda30 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_P2SVpnGatewayResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_P2SVpnGatewayResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -49,10 +48,10 @@ public async Task Get_P2SVpnGatewayGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_P2SVpnGatewayUpdate() + public async Task Delete_P2SVpnGatewayDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayUpdateTags.json - // this example is just showing the usage of "P2sVpnGateways_UpdateTags" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayDelete.json + // this example is just showing the usage of "P2sVpnGateways_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,30 +67,17 @@ public async Task Update_P2SVpnGatewayUpdate() P2SVpnGatewayResource p2sVpnGateway = client.GetP2SVpnGatewayResource(p2sVpnGatewayResourceId); // invoke the operation - NetworkTagsObject p2sVpnGatewayParameters = new NetworkTagsObject() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await p2sVpnGateway.UpdateAsync(WaitUntil.Completed, p2sVpnGatewayParameters); - P2SVpnGatewayResource result = lro.Value; + await p2sVpnGateway.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - P2SVpnGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_P2SVpnGatewayDelete() + public async Task Update_P2SVpnGatewayUpdate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayDelete.json - // this example is just showing the usage of "P2sVpnGateways_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayUpdateTags.json + // this example is just showing the usage of "P2sVpnGateways_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,40 +93,22 @@ public async Task Delete_P2SVpnGatewayDelete() P2SVpnGatewayResource p2sVpnGateway = client.GetP2SVpnGatewayResource(p2sVpnGatewayResourceId); // invoke the operation - await p2sVpnGateway.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetP2SVpnGateways_P2SVpnGatewayListBySubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayList.json - // this example is just showing the usage of "P2sVpnGateways_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (P2SVpnGatewayResource item in subscriptionResource.GetP2SVpnGatewaysAsync()) + NetworkTagsObject p2sVpnGatewayParameters = new NetworkTagsObject { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - P2SVpnGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await p2sVpnGateway.UpdateAsync(WaitUntil.Completed, p2sVpnGatewayParameters); + P2SVpnGatewayResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + P2SVpnGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -195,7 +163,7 @@ public async Task GenerateVpnProfile_GenerateP2SVpnGatewayVPNProfile() P2SVpnGatewayResource p2sVpnGateway = client.GetP2SVpnGatewayResource(p2sVpnGatewayResourceId); // invoke the operation - P2SVpnProfileContent content = new P2SVpnProfileContent() + P2SVpnProfileContent content = new P2SVpnProfileContent { AuthenticationMethod = NetworkAuthenticationMethod.Eaptls, }; @@ -257,12 +225,9 @@ public async Task GetP2SVpnConnectionHealthDetailed_P2SVpnGatewayGetConnectionHe P2SVpnGatewayResource p2sVpnGateway = client.GetP2SVpnGatewayResource(p2sVpnGatewayResourceId); // invoke the operation - P2SVpnConnectionHealthContent content = new P2SVpnConnectionHealthContent() + P2SVpnConnectionHealthContent content = new P2SVpnConnectionHealthContent { - VpnUserNamesFilter = -{ -"vpnUser1","vpnUser2" -}, + VpnUserNamesFilter = { "vpnUser1", "vpnUser2" }, OutputBlobSasUri = new Uri("https://blobcortextesturl.blob.core.windows.net/folderforconfig/p2sconnectionhealths?sp=rw&se=2018-01-10T03%3A42%3A04Z&sv=2017-04-17&sig=WvXrT5bDmDFfgHs%2Brz%2BjAu123eRCNE9BO0eQYcPDT7pY%3D&sr=b"), }; ArmOperation lro = await p2sVpnGateway.GetP2SVpnConnectionHealthDetailedAsync(WaitUntil.Completed, content); @@ -292,12 +257,9 @@ public async Task DisconnectP2SVpnConnections_DisconnectVpnConnectionsFromP2sVpn P2SVpnGatewayResource p2sVpnGateway = client.GetP2SVpnGatewayResource(p2sVpnGatewayResourceId); // invoke the operation - P2SVpnConnectionRequest request = new P2SVpnConnectionRequest() + P2SVpnConnectionRequest request = new P2SVpnConnectionRequest { - VpnConnectionIds = -{ -"vpnconnId1","vpnconnId2" -}, + VpnConnectionIds = { "vpnconnId1", "vpnconnId2" }, }; await p2sVpnGateway.DisconnectP2SVpnConnectionsAsync(WaitUntil.Completed, request); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PacketCaptureCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PacketCaptureCollection.cs index b80bb7514243b..0bd151d10db65 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PacketCaptureCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PacketCaptureCollection.cs @@ -41,7 +41,7 @@ public async Task CreateOrUpdate_CreatePacketCapture() // invoke the operation string packetCaptureName = "pc1"; - PacketCaptureCreateOrUpdateContent content = new PacketCaptureCreateOrUpdateContent("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1", new PacketCaptureStorageLocation() + PacketCaptureCreateOrUpdateContent content = new PacketCaptureCreateOrUpdateContent("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1", new PacketCaptureStorageLocation { StorageId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Storage/storageAccounts/pcstore"), StoragePath = "https://mytestaccountname.blob.core.windows.net/capture/pc1.cap", @@ -51,15 +51,12 @@ public async Task CreateOrUpdate_CreatePacketCapture() BytesToCapturePerPacket = 10000L, TotalBytesPerSession = 100000L, TimeLimitInSeconds = 100, - Filters = -{ -new PacketCaptureFilter() + Filters = {new PacketCaptureFilter { Protocol = PcProtocol.Tcp, LocalIPAddress = "10.0.0.4", LocalPort = "80", -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, packetCaptureName, content); PacketCaptureResource result = lro.Value; @@ -107,10 +104,10 @@ public async Task Get_GetPacketCapture() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPacketCapture() + public async Task GetAll_ListPacketCaptures() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCaptureGet.json - // this example is just showing the usage of "PacketCaptures_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCapturesList.json + // this example is just showing the usage of "PacketCaptures_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -128,16 +125,22 @@ public async Task Exists_GetPacketCapture() // get the collection of this PacketCaptureResource PacketCaptureCollection collection = networkWatcher.GetPacketCaptures(); - // invoke the operation - string packetCaptureName = "pc1"; - bool result = await collection.ExistsAsync(packetCaptureName); + // invoke the operation and iterate over the result + await foreach (PacketCaptureResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PacketCaptureData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPacketCapture() + public async Task Exists_GetPacketCapture() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCaptureGet.json // this example is just showing the usage of "PacketCaptures_Get" operation, for the dependent resources, they will have to be created separately. @@ -160,29 +163,17 @@ public async Task GetIfExists_GetPacketCapture() // invoke the operation string packetCaptureName = "pc1"; - NullableResponse response = await collection.GetIfExistsAsync(packetCaptureName); - PacketCaptureResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(packetCaptureName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PacketCaptureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPacketCaptures() + public async Task GetIfExists_GetPacketCapture() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCapturesList.json - // this example is just showing the usage of "PacketCaptures_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCaptureGet.json + // this example is just showing the usage of "PacketCaptures_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -200,17 +191,23 @@ public async Task GetAll_ListPacketCaptures() // get the collection of this PacketCaptureResource PacketCaptureCollection collection = networkWatcher.GetPacketCaptures(); - // invoke the operation and iterate over the result - await foreach (PacketCaptureResource item in collection.GetAllAsync()) + // invoke the operation + string packetCaptureName = "pc1"; + NullableResponse response = await collection.GetIfExistsAsync(packetCaptureName); + PacketCaptureResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PacketCaptureData resourceData = item.Data; + PacketCaptureData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PacketCaptureResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PacketCaptureResource.cs index 046122d331979..18a033be8b10e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PacketCaptureResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PacketCaptureResource.cs @@ -18,10 +18,10 @@ public partial class Sample_PacketCaptureResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreatePacketCapture() + public async Task Get_GetPacketCapture() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCaptureCreate.json - // this example is just showing the usage of "PacketCaptures_Create" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCaptureGet.json + // this example is just showing the usage of "PacketCaptures_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,28 +38,7 @@ public async Task Update_CreatePacketCapture() PacketCaptureResource packetCapture = client.GetPacketCaptureResource(packetCaptureResourceId); // invoke the operation - PacketCaptureCreateOrUpdateContent content = new PacketCaptureCreateOrUpdateContent("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1", new PacketCaptureStorageLocation() - { - StorageId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Storage/storageAccounts/pcstore"), - StoragePath = "https://mytestaccountname.blob.core.windows.net/capture/pc1.cap", - FilePath = "D:\\capture\\pc1.cap", - }) - { - BytesToCapturePerPacket = 10000L, - TotalBytesPerSession = 100000L, - TimeLimitInSeconds = 100, - Filters = -{ -new PacketCaptureFilter() -{ -Protocol = PcProtocol.Tcp, -LocalIPAddress = "10.0.0.4", -LocalPort = "80", -} -}, - }; - ArmOperation lro = await packetCapture.UpdateAsync(WaitUntil.Completed, content); - PacketCaptureResource result = lro.Value; + PacketCaptureResource result = await packetCapture.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -70,10 +49,10 @@ public async Task Update_CreatePacketCapture() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPacketCapture() + public async Task Delete_DeletePacketCapture() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCaptureGet.json - // this example is just showing the usage of "PacketCaptures_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCaptureDelete.json + // this example is just showing the usage of "PacketCaptures_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -90,21 +69,17 @@ public async Task Get_GetPacketCapture() PacketCaptureResource packetCapture = client.GetPacketCaptureResource(packetCaptureResourceId); // invoke the operation - PacketCaptureResource result = await packetCapture.GetAsync(); + await packetCapture.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PacketCaptureData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePacketCapture() + public async Task Update_CreatePacketCapture() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCaptureDelete.json - // this example is just showing the usage of "PacketCaptures_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherPacketCaptureCreate.json + // this example is just showing the usage of "PacketCaptures_Create" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,9 +96,31 @@ public async Task Delete_DeletePacketCapture() PacketCaptureResource packetCapture = client.GetPacketCaptureResource(packetCaptureResourceId); // invoke the operation - await packetCapture.DeleteAsync(WaitUntil.Completed); + PacketCaptureCreateOrUpdateContent content = new PacketCaptureCreateOrUpdateContent("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Compute/virtualMachines/vm1", new PacketCaptureStorageLocation + { + StorageId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Storage/storageAccounts/pcstore"), + StoragePath = "https://mytestaccountname.blob.core.windows.net/capture/pc1.cap", + FilePath = "D:\\capture\\pc1.cap", + }) + { + BytesToCapturePerPacket = 10000L, + TotalBytesPerSession = 100000L, + TimeLimitInSeconds = 100, + Filters = {new PacketCaptureFilter +{ +Protocol = PcProtocol.Tcp, +LocalIPAddress = "10.0.0.4", +LocalPort = "80", +}}, + }; + ArmOperation lro = await packetCapture.UpdateAsync(WaitUntil.Completed, content); + PacketCaptureResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PacketCaptureData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PeerExpressRouteCircuitConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PeerExpressRouteCircuitConnectionCollection.cs index b85f8df96795b..72f141c729d7a 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PeerExpressRouteCircuitConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PeerExpressRouteCircuitConnectionCollection.cs @@ -52,10 +52,10 @@ public async Task Get_PeerExpressRouteCircuitConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_PeerExpressRouteCircuitConnectionGet() + public async Task GetAll_ListPeerExpressRouteCircuitConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PeerExpressRouteCircuitConnectionGet.json - // this example is just showing the usage of "PeerExpressRouteCircuitConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PeerExpressRouteCircuitConnectionList.json + // this example is just showing the usage of "PeerExpressRouteCircuitConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,16 +74,22 @@ public async Task Exists_PeerExpressRouteCircuitConnectionGet() // get the collection of this PeerExpressRouteCircuitConnectionResource PeerExpressRouteCircuitConnectionCollection collection = expressRouteCircuitPeering.GetPeerExpressRouteCircuitConnections(); - // invoke the operation - string connectionName = "60aee347-e889-4a42-8c1b-0aae8b1e4013"; - bool result = await collection.ExistsAsync(connectionName); + // invoke the operation and iterate over the result + await foreach (PeerExpressRouteCircuitConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PeerExpressRouteCircuitConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_PeerExpressRouteCircuitConnectionGet() + public async Task Exists_PeerExpressRouteCircuitConnectionGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PeerExpressRouteCircuitConnectionGet.json // this example is just showing the usage of "PeerExpressRouteCircuitConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -107,29 +113,17 @@ public async Task GetIfExists_PeerExpressRouteCircuitConnectionGet() // invoke the operation string connectionName = "60aee347-e889-4a42-8c1b-0aae8b1e4013"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - PeerExpressRouteCircuitConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(connectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PeerExpressRouteCircuitConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPeerExpressRouteCircuitConnection() + public async Task GetIfExists_PeerExpressRouteCircuitConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PeerExpressRouteCircuitConnectionList.json - // this example is just showing the usage of "PeerExpressRouteCircuitConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PeerExpressRouteCircuitConnectionGet.json + // this example is just showing the usage of "PeerExpressRouteCircuitConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,17 +142,23 @@ public async Task GetAll_ListPeerExpressRouteCircuitConnection() // get the collection of this PeerExpressRouteCircuitConnectionResource PeerExpressRouteCircuitConnectionCollection collection = expressRouteCircuitPeering.GetPeerExpressRouteCircuitConnections(); - // invoke the operation and iterate over the result - await foreach (PeerExpressRouteCircuitConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string connectionName = "60aee347-e889-4a42-8c1b-0aae8b1e4013"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + PeerExpressRouteCircuitConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PeerExpressRouteCircuitConnectionData resourceData = item.Data; + PeerExpressRouteCircuitConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PolicySignaturesOverridesForIdpsResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PolicySignaturesOverridesForIdpsResource.cs index 3101fb5e40b03..753fe498b0daa 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PolicySignaturesOverridesForIdpsResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PolicySignaturesOverridesForIdpsResource.cs @@ -17,10 +17,10 @@ public partial class Sample_PolicySignaturesOverridesForIdpsResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_PatchSignatureOverrides() + public async Task Get_GetSignatureOverrides() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicySignatureOverridesPatch.json - // this example is just showing the usage of "FirewallPolicyIdpsSignaturesOverrides_Patch" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicySignatureOverridesGet.json + // this example is just showing the usage of "FirewallPolicyIdpsSignaturesOverrides_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -36,18 +36,7 @@ public async Task Update_PatchSignatureOverrides() PolicySignaturesOverridesForIdpsResource policySignaturesOverridesForIdps = client.GetPolicySignaturesOverridesForIdpsResource(policySignaturesOverridesForIdpsResourceId); // invoke the operation - PolicySignaturesOverridesForIdpsData data = new PolicySignaturesOverridesForIdpsData() - { - Name = "default", - Id = new ResourceIdentifier("/subscriptions/e747cc13-97d4-4a79-b463-42d7f4e558f2/resourceGroups/rg1/providers/Microsoft.Network/firewallPolicies/firewallPolicy/signatureOverrides/default"), - ResourceType = new ResourceType("Microsoft.Network/firewallPolicies/signatureOverrides"), - Signatures = -{ -["2000105"] = "Off", -["2000106"] = "Deny", -}, - }; - PolicySignaturesOverridesForIdpsResource result = await policySignaturesOverridesForIdps.UpdateAsync(data); + PolicySignaturesOverridesForIdpsResource result = await policySignaturesOverridesForIdps.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -58,10 +47,10 @@ public async Task Update_PatchSignatureOverrides() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_PutSignatureOverrides() + public async Task Update_PatchSignatureOverrides() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicySignatureOverridesPut.json - // this example is just showing the usage of "FirewallPolicyIdpsSignaturesOverrides_Put" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicySignatureOverridesPatch.json + // this example is just showing the usage of "FirewallPolicyIdpsSignaturesOverrides_Patch" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -77,7 +66,7 @@ public async Task CreateOrUpdate_PutSignatureOverrides() PolicySignaturesOverridesForIdpsResource policySignaturesOverridesForIdps = client.GetPolicySignaturesOverridesForIdpsResource(policySignaturesOverridesForIdpsResourceId); // invoke the operation - PolicySignaturesOverridesForIdpsData data = new PolicySignaturesOverridesForIdpsData() + PolicySignaturesOverridesForIdpsData data = new PolicySignaturesOverridesForIdpsData { Name = "default", Id = new ResourceIdentifier("/subscriptions/e747cc13-97d4-4a79-b463-42d7f4e558f2/resourceGroups/rg1/providers/Microsoft.Network/firewallPolicies/firewallPolicy/signatureOverrides/default"), @@ -85,11 +74,10 @@ public async Task CreateOrUpdate_PutSignatureOverrides() Signatures = { ["2000105"] = "Off", -["2000106"] = "Deny", +["2000106"] = "Deny" }, }; - ArmOperation lro = await policySignaturesOverridesForIdps.CreateOrUpdateAsync(WaitUntil.Completed, data); - PolicySignaturesOverridesForIdpsResource result = lro.Value; + PolicySignaturesOverridesForIdpsResource result = await policySignaturesOverridesForIdps.UpdateAsync(data); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -100,10 +88,10 @@ public async Task CreateOrUpdate_PutSignatureOverrides() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSignatureOverrides() + public async Task CreateOrUpdate_PutSignatureOverrides() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicySignatureOverridesGet.json - // this example is just showing the usage of "FirewallPolicyIdpsSignaturesOverrides_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicySignatureOverridesPut.json + // this example is just showing the usage of "FirewallPolicyIdpsSignaturesOverrides_Put" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -119,7 +107,19 @@ public async Task Get_GetSignatureOverrides() PolicySignaturesOverridesForIdpsResource policySignaturesOverridesForIdps = client.GetPolicySignaturesOverridesForIdpsResource(policySignaturesOverridesForIdpsResourceId); // invoke the operation - PolicySignaturesOverridesForIdpsResource result = await policySignaturesOverridesForIdps.GetAsync(); + PolicySignaturesOverridesForIdpsData data = new PolicySignaturesOverridesForIdpsData + { + Name = "default", + Id = new ResourceIdentifier("/subscriptions/e747cc13-97d4-4a79-b463-42d7f4e558f2/resourceGroups/rg1/providers/Microsoft.Network/firewallPolicies/firewallPolicy/signatureOverrides/default"), + ResourceType = new ResourceType("Microsoft.Network/firewallPolicies/signatureOverrides"), + Signatures = +{ +["2000105"] = "Off", +["2000106"] = "Deny" +}, + }; + ArmOperation lro = await policySignaturesOverridesForIdps.CreateOrUpdateAsync(WaitUntil.Completed, data); + PolicySignaturesOverridesForIdpsResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateDnsZoneGroupCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateDnsZoneGroupCollection.cs index 73b10138870b0..aa4a93351c064 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateDnsZoneGroupCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateDnsZoneGroupCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_PrivateDnsZoneGroupCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateDnsZoneGroup() + public async Task CreateOrUpdate_CreatePrivateDnsZoneGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupGet.json - // this example is just showing the usage of "PrivateDnsZoneGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupCreate.json + // this example is just showing the usage of "PrivateDnsZoneGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,15 @@ public async Task Get_GetPrivateDnsZoneGroup() // invoke the operation string privateDnsZoneGroupName = "testPdnsgroup"; - PrivateDnsZoneGroupResource result = await collection.GetAsync(privateDnsZoneGroupName); + PrivateDnsZoneGroupData data = new PrivateDnsZoneGroupData + { + PrivateDnsZoneConfigs = {new PrivateDnsZoneConfig +{ +PrivateDnsZoneId = "/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateDnsZones/zone1.com", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateDnsZoneGroupName, data); + PrivateDnsZoneGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +60,7 @@ public async Task Get_GetPrivateDnsZoneGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateDnsZoneGroup() + public async Task Get_GetPrivateDnsZoneGroup() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupGet.json // this example is just showing the usage of "PrivateDnsZoneGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +83,21 @@ public async Task Exists_GetPrivateDnsZoneGroup() // invoke the operation string privateDnsZoneGroupName = "testPdnsgroup"; - bool result = await collection.ExistsAsync(privateDnsZoneGroupName); + PrivateDnsZoneGroupResource result = await collection.GetAsync(privateDnsZoneGroupName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateDnsZoneGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateDnsZoneGroup() + public async Task GetAll_ListPrivateEndpointsInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupGet.json - // this example is just showing the usage of "PrivateDnsZoneGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupList.json + // this example is just showing the usage of "PrivateDnsZoneGroups_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +115,25 @@ public async Task GetIfExists_GetPrivateDnsZoneGroup() // get the collection of this PrivateDnsZoneGroupResource PrivateDnsZoneGroupCollection collection = privateEndpoint.GetPrivateDnsZoneGroups(); - // invoke the operation - string privateDnsZoneGroupName = "testPdnsgroup"; - NullableResponse response = await collection.GetIfExistsAsync(privateDnsZoneGroupName); - PrivateDnsZoneGroupResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PrivateDnsZoneGroupResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PrivateDnsZoneGroupData resourceData = result.Data; + PrivateDnsZoneGroupData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePrivateDnsZoneGroup() + public async Task Exists_GetPrivateDnsZoneGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupCreate.json - // this example is just showing the usage of "PrivateDnsZoneGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupGet.json + // this example is just showing the usage of "PrivateDnsZoneGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,32 +153,17 @@ public async Task CreateOrUpdate_CreatePrivateDnsZoneGroup() // invoke the operation string privateDnsZoneGroupName = "testPdnsgroup"; - PrivateDnsZoneGroupData data = new PrivateDnsZoneGroupData() - { - PrivateDnsZoneConfigs = -{ -new PrivateDnsZoneConfig() -{ -PrivateDnsZoneId = "/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateDnsZones/zone1.com", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateDnsZoneGroupName, data); - PrivateDnsZoneGroupResource result = lro.Value; + bool result = await collection.ExistsAsync(privateDnsZoneGroupName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateDnsZoneGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateEndpointsInResourceGroup() + public async Task GetIfExists_GetPrivateDnsZoneGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupList.json - // this example is just showing the usage of "PrivateDnsZoneGroups_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupGet.json + // this example is just showing the usage of "PrivateDnsZoneGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +181,23 @@ public async Task GetAll_ListPrivateEndpointsInResourceGroup() // get the collection of this PrivateDnsZoneGroupResource PrivateDnsZoneGroupCollection collection = privateEndpoint.GetPrivateDnsZoneGroups(); - // invoke the operation and iterate over the result - await foreach (PrivateDnsZoneGroupResource item in collection.GetAllAsync()) + // invoke the operation + string privateDnsZoneGroupName = "testPdnsgroup"; + NullableResponse response = await collection.GetIfExistsAsync(privateDnsZoneGroupName); + PrivateDnsZoneGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PrivateDnsZoneGroupData resourceData = item.Data; + PrivateDnsZoneGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateDnsZoneGroupResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateDnsZoneGroupResource.cs index bf0769637fcec..218adfea5122f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateDnsZoneGroupResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateDnsZoneGroupResource.cs @@ -18,10 +18,10 @@ public partial class Sample_PrivateDnsZoneGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateDnsZoneGroup() + public async Task Get_GetPrivateDnsZoneGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupDelete.json - // this example is just showing the usage of "PrivateDnsZoneGroups_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupGet.json + // this example is just showing the usage of "PrivateDnsZoneGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeletePrivateDnsZoneGroup() PrivateDnsZoneGroupResource privateDnsZoneGroup = client.GetPrivateDnsZoneGroupResource(privateDnsZoneGroupResourceId); // invoke the operation - await privateDnsZoneGroup.DeleteAsync(WaitUntil.Completed); + PrivateDnsZoneGroupResource result = await privateDnsZoneGroup.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateDnsZoneGroupData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateDnsZoneGroup() + public async Task Delete_DeletePrivateDnsZoneGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupGet.json - // this example is just showing the usage of "PrivateDnsZoneGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDnsZoneGroupDelete.json + // this example is just showing the usage of "PrivateDnsZoneGroups_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetPrivateDnsZoneGroup() PrivateDnsZoneGroupResource privateDnsZoneGroup = client.GetPrivateDnsZoneGroupResource(privateDnsZoneGroupResourceId); // invoke the operation - PrivateDnsZoneGroupResource result = await privateDnsZoneGroup.GetAsync(); + await privateDnsZoneGroup.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateDnsZoneGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,15 +96,12 @@ public async Task Update_CreatePrivateDnsZoneGroup() PrivateDnsZoneGroupResource privateDnsZoneGroup = client.GetPrivateDnsZoneGroupResource(privateDnsZoneGroupResourceId); // invoke the operation - PrivateDnsZoneGroupData data = new PrivateDnsZoneGroupData() + PrivateDnsZoneGroupData data = new PrivateDnsZoneGroupData { - PrivateDnsZoneConfigs = -{ -new PrivateDnsZoneConfig() + PrivateDnsZoneConfigs = {new PrivateDnsZoneConfig { PrivateDnsZoneId = "/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateDnsZones/zone1.com", -} -}, +}}, }; ArmOperation lro = await privateDnsZoneGroup.UpdateAsync(WaitUntil.Completed, data); PrivateDnsZoneGroupResource result = lro.Value; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateEndpointCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateEndpointCollection.cs index f178518f185a2..ebab8de50e9be 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateEndpointCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateEndpointCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_PrivateEndpointCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndpoint() + public async Task CreateOrUpdate_CreatePrivateEndpoint() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGet.json - // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointCreate.json + // this example is just showing the usage of "PrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,30 @@ public async Task Get_GetPrivateEndpoint() // invoke the operation string privateEndpointName = "testPe"; - PrivateEndpointResource result = await collection.GetAsync(privateEndpointName); + PrivateEndpointData data = new PrivateEndpointData + { + Subnet = new SubnetData + { + Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + }, + PrivateLinkServiceConnections = {new NetworkPrivateLinkServiceConnection +{ +PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), +GroupIds = {"groupIdFromResource"}, +RequestMessage = "Please approve my connection.", +}}, + IPConfigurations = {new PrivateEndpointIPConfiguration +{ +Name = "pestaticconfig", +GroupId = "file", +MemberName = "file", +PrivateIPAddress = IPAddress.Parse("192.168.0.6"), +}}, + CustomNetworkInterfaceName = "testPeNic", + Location = new AzureLocation("eastus2euap"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointName, data); + PrivateEndpointResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,10 +76,10 @@ public async Task Get_GetPrivateEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateEndpoint() + public async Task CreateOrUpdate_CreatePrivateEndpointWithApplicationSecurityGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGet.json - // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointCreateWithASG.json + // this example is just showing the usage of "PrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +98,40 @@ public async Task Exists_GetPrivateEndpoint() // invoke the operation string privateEndpointName = "testPe"; - bool result = await collection.ExistsAsync(privateEndpointName); + PrivateEndpointData data = new PrivateEndpointData + { + Subnet = new SubnetData + { + Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + }, + PrivateLinkServiceConnections = {new NetworkPrivateLinkServiceConnection +{ +PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), +GroupIds = {"groupIdFromResource"}, +RequestMessage = "Please approve my connection.", +}}, + ApplicationSecurityGroups = {new ApplicationSecurityGroupData +{ +Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/provders/Microsoft.Network/applicationSecurityGroup/asg1"), +}}, + Location = new AzureLocation("eastus2euap"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointName, data); + PrivateEndpointResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateEndpoint() + public async Task CreateOrUpdate_CreatePrivateEndpointWithManualApprovalConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGet.json - // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointCreateForManualApproval.json + // this example is just showing the usage of "PrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,28 +150,43 @@ public async Task GetIfExists_GetPrivateEndpoint() // invoke the operation string privateEndpointName = "testPe"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointName); - PrivateEndpointResource result = response.HasValue ? response.Value : null; - - if (result == null) + PrivateEndpointData data = new PrivateEndpointData { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Subnet = new SubnetData + { + Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), + }, + ManualPrivateLinkServiceConnections = {new NetworkPrivateLinkServiceConnection +{ +PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), +GroupIds = {"groupIdFromResource"}, +RequestMessage = "Please manually approve my connection.", +}}, + IPConfigurations = {new PrivateEndpointIPConfiguration +{ +Name = "pestaticconfig", +GroupId = "file", +MemberName = "file", +PrivateIPAddress = IPAddress.Parse("192.168.0.5"), +}}, + CustomNetworkInterfaceName = "testPeNic", + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointName, data); + PrivateEndpointResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndpointWithApplicationSecurityGroups() + public async Task Get_GetPrivateEndpoint() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetWithASG.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGet.json // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -156,7 +217,7 @@ public async Task Get_GetPrivateEndpointWithApplicationSecurityGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateEndpointWithApplicationSecurityGroups() + public async Task Get_GetPrivateEndpointWithApplicationSecurityGroups() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetWithASG.json // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. @@ -178,16 +239,20 @@ public async Task Exists_GetPrivateEndpointWithApplicationSecurityGroups() // invoke the operation string privateEndpointName = "testPe"; - bool result = await collection.ExistsAsync(privateEndpointName); + PrivateEndpointResource result = await collection.GetAsync(privateEndpointName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateEndpointWithApplicationSecurityGroups() + public async Task Get_GetPrivateEndpointWithManualApprovalConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetWithASG.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetForManualApproval.json // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -207,29 +272,21 @@ public async Task GetIfExists_GetPrivateEndpointWithApplicationSecurityGroups() // invoke the operation string privateEndpointName = "testPe"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointName); - PrivateEndpointResource result = response.HasValue ? response.Value : null; + PrivateEndpointResource result = await collection.GetAsync(privateEndpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndpointWithManualApprovalConnection() + public async Task GetAll_ListPrivateEndpointsInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetForManualApproval.json - // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointList.json + // this example is just showing the usage of "PrivateEndpoints_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -246,22 +303,24 @@ public async Task Get_GetPrivateEndpointWithManualApprovalConnection() // get the collection of this PrivateEndpointResource PrivateEndpointCollection collection = resourceGroupResource.GetPrivateEndpoints(); - // invoke the operation - string privateEndpointName = "testPe"; - PrivateEndpointResource result = await collection.GetAsync(privateEndpointName); + // invoke the operation and iterate over the result + await foreach (PrivateEndpointResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateEndpointWithManualApprovalConnection() + public async Task Exists_GetPrivateEndpoint() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetForManualApproval.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGet.json // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -288,9 +347,9 @@ public async Task Exists_GetPrivateEndpointWithManualApprovalConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateEndpointWithManualApprovalConnection() + public async Task Exists_GetPrivateEndpointWithApplicationSecurityGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetForManualApproval.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetWithASG.json // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -310,29 +369,17 @@ public async Task GetIfExists_GetPrivateEndpointWithManualApprovalConnection() // invoke the operation string privateEndpointName = "testPe"; - NullableResponse response = await collection.GetIfExistsAsync(privateEndpointName); - PrivateEndpointResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(privateEndpointName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePrivateEndpoint() + public async Task Exists_GetPrivateEndpointWithManualApprovalConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointCreate.json - // this example is just showing the usage of "PrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetForManualApproval.json + // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -351,53 +398,17 @@ public async Task CreateOrUpdate_CreatePrivateEndpoint() // invoke the operation string privateEndpointName = "testPe"; - PrivateEndpointData data = new PrivateEndpointData() - { - Subnet = new SubnetData() - { - Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - }, - PrivateLinkServiceConnections = -{ -new NetworkPrivateLinkServiceConnection() -{ -PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), -GroupIds = -{ -"groupIdFromResource" -}, -RequestMessage = "Please approve my connection.", -} -}, - IPConfigurations = -{ -new PrivateEndpointIPConfiguration() -{ -Name = "pestaticconfig", -GroupId = "file", -MemberName = "file", -PrivateIPAddress = IPAddress.Parse("192.168.0.6"), -} -}, - CustomNetworkInterfaceName = "testPeNic", - Location = new AzureLocation("eastus2euap"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointName, data); - PrivateEndpointResource result = lro.Value; + bool result = await collection.ExistsAsync(privateEndpointName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePrivateEndpointWithApplicationSecurityGroups() + public async Task GetIfExists_GetPrivateEndpoint() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointCreateWithASG.json - // this example is just showing the usage of "PrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGet.json + // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -416,49 +427,29 @@ public async Task CreateOrUpdate_CreatePrivateEndpointWithApplicationSecurityGro // invoke the operation string privateEndpointName = "testPe"; - PrivateEndpointData data = new PrivateEndpointData() - { - Subnet = new SubnetData() - { - Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - }, - PrivateLinkServiceConnections = -{ -new NetworkPrivateLinkServiceConnection() -{ -PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), -GroupIds = -{ -"groupIdFromResource" -}, -RequestMessage = "Please approve my connection.", -} -}, - ApplicationSecurityGroups = -{ -new ApplicationSecurityGroupData() -{ -Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/provders/Microsoft.Network/applicationSecurityGroup/asg1"), -} -}, - Location = new AzureLocation("eastus2euap"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointName, data); - PrivateEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointName); + PrivateEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePrivateEndpointWithManualApprovalConnection() + public async Task GetIfExists_GetPrivateEndpointWithApplicationSecurityGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointCreateForManualApproval.json - // this example is just showing the usage of "PrivateEndpoints_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetWithASG.json + // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -477,53 +468,29 @@ public async Task CreateOrUpdate_CreatePrivateEndpointWithManualApprovalConnecti // invoke the operation string privateEndpointName = "testPe"; - PrivateEndpointData data = new PrivateEndpointData() - { - Subnet = new SubnetData() - { - Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), - }, - ManualPrivateLinkServiceConnections = -{ -new NetworkPrivateLinkServiceConnection() -{ -PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), -GroupIds = -{ -"groupIdFromResource" -}, -RequestMessage = "Please manually approve my connection.", -} -}, - IPConfigurations = -{ -new PrivateEndpointIPConfiguration() -{ -Name = "pestaticconfig", -GroupId = "file", -MemberName = "file", -PrivateIPAddress = IPAddress.Parse("192.168.0.5"), -} -}, - CustomNetworkInterfaceName = "testPeNic", - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, privateEndpointName, data); - PrivateEndpointResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointName); + PrivateEndpointResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateEndpointsInResourceGroup() + public async Task GetIfExists_GetPrivateEndpointWithManualApprovalConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointList.json - // this example is just showing the usage of "PrivateEndpoints_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetForManualApproval.json + // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -540,17 +507,23 @@ public async Task GetAll_ListPrivateEndpointsInResourceGroup() // get the collection of this PrivateEndpointResource PrivateEndpointCollection collection = resourceGroupResource.GetPrivateEndpoints(); - // invoke the operation and iterate over the result - await foreach (PrivateEndpointResource item in collection.GetAllAsync()) + // invoke the operation + string privateEndpointName = "testPe"; + NullableResponse response = await collection.GetIfExistsAsync(privateEndpointName); + PrivateEndpointResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PrivateEndpointData resourceData = item.Data; + PrivateEndpointData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateEndpointResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateEndpointResource.cs index 85b4cf80dafd4..cca9c70a790c7 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateEndpointResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateEndpointResource.cs @@ -11,7 +11,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -20,10 +19,10 @@ public partial class Sample_PrivateEndpointResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateEndpoint() + public async Task Get_GetPrivateEndpoint() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDelete.json - // this example is just showing the usage of "PrivateEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGet.json + // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,16 +38,20 @@ public async Task Delete_DeletePrivateEndpoint() PrivateEndpointResource privateEndpoint = client.GetPrivateEndpointResource(privateEndpointResourceId); // invoke the operation - await privateEndpoint.DeleteAsync(WaitUntil.Completed); + PrivateEndpointResource result = await privateEndpoint.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateEndpointData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndpoint() + public async Task Get_GetPrivateEndpointWithApplicationSecurityGroups() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetWithASG.json // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -76,9 +79,9 @@ public async Task Get_GetPrivateEndpoint() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndpointWithApplicationSecurityGroups() + public async Task Get_GetPrivateEndpointWithManualApprovalConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetWithASG.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetForManualApproval.json // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -106,10 +109,10 @@ public async Task Get_GetPrivateEndpointWithApplicationSecurityGroups() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateEndpointWithManualApprovalConnection() + public async Task Delete_DeletePrivateEndpoint() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointGetForManualApproval.json - // this example is just showing the usage of "PrivateEndpoints_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointDelete.json + // this example is just showing the usage of "PrivateEndpoints_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -125,13 +128,9 @@ public async Task Get_GetPrivateEndpointWithManualApprovalConnection() PrivateEndpointResource privateEndpoint = client.GetPrivateEndpointResource(privateEndpointResourceId); // invoke the operation - PrivateEndpointResource result = await privateEndpoint.GetAsync(); + await privateEndpoint.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateEndpointData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -155,34 +154,25 @@ public async Task Update_CreatePrivateEndpoint() PrivateEndpointResource privateEndpoint = client.GetPrivateEndpointResource(privateEndpointResourceId); // invoke the operation - PrivateEndpointData data = new PrivateEndpointData() + PrivateEndpointData data = new PrivateEndpointData { - Subnet = new SubnetData() + Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), }, - PrivateLinkServiceConnections = -{ -new NetworkPrivateLinkServiceConnection() + PrivateLinkServiceConnections = {new NetworkPrivateLinkServiceConnection { PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), -GroupIds = -{ -"groupIdFromResource" -}, +GroupIds = {"groupIdFromResource"}, RequestMessage = "Please approve my connection.", -} -}, - IPConfigurations = -{ -new PrivateEndpointIPConfiguration() +}}, + IPConfigurations = {new PrivateEndpointIPConfiguration { Name = "pestaticconfig", GroupId = "file", MemberName = "file", PrivateIPAddress = IPAddress.Parse("192.168.0.6"), -} -}, +}}, CustomNetworkInterfaceName = "testPeNic", Location = new AzureLocation("eastus2euap"), }; @@ -217,31 +207,22 @@ public async Task Update_CreatePrivateEndpointWithApplicationSecurityGroups() PrivateEndpointResource privateEndpoint = client.GetPrivateEndpointResource(privateEndpointResourceId); // invoke the operation - PrivateEndpointData data = new PrivateEndpointData() + PrivateEndpointData data = new PrivateEndpointData { - Subnet = new SubnetData() + Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), }, - PrivateLinkServiceConnections = -{ -new NetworkPrivateLinkServiceConnection() + PrivateLinkServiceConnections = {new NetworkPrivateLinkServiceConnection { PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), -GroupIds = -{ -"groupIdFromResource" -}, +GroupIds = {"groupIdFromResource"}, RequestMessage = "Please approve my connection.", -} -}, - ApplicationSecurityGroups = -{ -new ApplicationSecurityGroupData() +}}, + ApplicationSecurityGroups = {new ApplicationSecurityGroupData { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/provders/Microsoft.Network/applicationSecurityGroup/asg1"), -} -}, +}}, Location = new AzureLocation("eastus2euap"), }; ArmOperation lro = await privateEndpoint.UpdateAsync(WaitUntil.Completed, data); @@ -275,34 +256,25 @@ public async Task Update_CreatePrivateEndpointWithManualApprovalConnection() PrivateEndpointResource privateEndpoint = client.GetPrivateEndpointResource(privateEndpointResourceId); // invoke the operation - PrivateEndpointData data = new PrivateEndpointData() + PrivateEndpointData data = new PrivateEndpointData { - Subnet = new SubnetData() + Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/myVnet/subnets/mySubnet"), }, - ManualPrivateLinkServiceConnections = -{ -new NetworkPrivateLinkServiceConnection() + ManualPrivateLinkServiceConnections = {new NetworkPrivateLinkServiceConnection { PrivateLinkServiceId = new ResourceIdentifier("/subscriptions/subId/resourceGroups/rg1/providers/Microsoft.Network/privateLinkServices/testPls"), -GroupIds = -{ -"groupIdFromResource" -}, +GroupIds = {"groupIdFromResource"}, RequestMessage = "Please manually approve my connection.", -} -}, - IPConfigurations = -{ -new PrivateEndpointIPConfiguration() +}}, + IPConfigurations = {new PrivateEndpointIPConfiguration { Name = "pestaticconfig", GroupId = "file", MemberName = "file", PrivateIPAddress = IPAddress.Parse("192.168.0.5"), -} -}, +}}, CustomNetworkInterfaceName = "testPeNic", Location = new AzureLocation("eastus"), }; @@ -315,36 +287,5 @@ public async Task Update_CreatePrivateEndpointWithManualApprovalConnection() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPrivateEndpoints_ListAllPrivateEndpoints() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointListAll.json - // this example is just showing the usage of "PrivateEndpoints_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subId"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PrivateEndpointResource item in subscriptionResource.GetPrivateEndpointsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateEndpointData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateLinkServiceCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateLinkServiceCollection.cs index 07e178ca85731..70832d93e0ac5 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateLinkServiceCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateLinkServiceCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_PrivateLinkServiceCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateLinkService() + public async Task CreateOrUpdate_CreatePrivateLinkService() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGet.json - // this example is just showing the usage of "PrivateLinkServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceCreate.json + // this example is just showing the usage of "PrivateLinkServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,30 @@ public async Task Get_GetPrivateLinkService() // invoke the operation string serviceName = "testPls"; - PrivateLinkServiceResource result = await collection.GetAsync(serviceName); + PrivateLinkServiceData data = new PrivateLinkServiceData + { + LoadBalancerFrontendIPConfigurations = {new FrontendIPConfigurationData +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), +}}, + IPConfigurations = {new PrivateLinkServiceIPConfiguration +{ +PrivateIPAddress = "10.0.1.4", +PrivateIPAllocationMethod = NetworkIPAllocationMethod.Static, +Subnet = new SubnetData +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), +}, +PrivateIPAddressVersion = NetworkIPVersion.IPv4, +Name = "fe-lb", +}}, + VisibilitySubscriptions = { "subscription1", "subscription2", "subscription3" }, + AutoApprovalSubscriptions = { "subscription1", "subscription2" }, + Fqdns = { "fqdn1", "fqdn2", "fqdn3" }, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); + PrivateLinkServiceResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +75,7 @@ public async Task Get_GetPrivateLinkService() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPrivateLinkService() + public async Task Get_GetPrivateLinkService() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGet.json // this example is just showing the usage of "PrivateLinkServices_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +97,21 @@ public async Task Exists_GetPrivateLinkService() // invoke the operation string serviceName = "testPls"; - bool result = await collection.ExistsAsync(serviceName); + PrivateLinkServiceResource result = await collection.GetAsync(serviceName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateLinkServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPrivateLinkService() + public async Task GetAll_ListPrivateLinkServiceInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGet.json - // this example is just showing the usage of "PrivateLinkServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceList.json + // this example is just showing the usage of "PrivateLinkServices_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +128,25 @@ public async Task GetIfExists_GetPrivateLinkService() // get the collection of this PrivateLinkServiceResource PrivateLinkServiceCollection collection = resourceGroupResource.GetPrivateLinkServices(); - // invoke the operation - string serviceName = "testPls"; - NullableResponse response = await collection.GetIfExistsAsync(serviceName); - PrivateLinkServiceResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (PrivateLinkServiceResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PrivateLinkServiceData resourceData = result.Data; + PrivateLinkServiceData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePrivateLinkService() + public async Task Exists_GetPrivateLinkService() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceCreate.json - // this example is just showing the usage of "PrivateLinkServices_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGet.json + // this example is just showing the usage of "PrivateLinkServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,59 +165,17 @@ public async Task CreateOrUpdate_CreatePrivateLinkService() // invoke the operation string serviceName = "testPls"; - PrivateLinkServiceData data = new PrivateLinkServiceData() - { - LoadBalancerFrontendIPConfigurations = -{ -new FrontendIPConfigurationData() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), -} -}, - IPConfigurations = -{ -new PrivateLinkServiceIPConfiguration() -{ -PrivateIPAddress = "10.0.1.4", -PrivateIPAllocationMethod = NetworkIPAllocationMethod.Static, -Subnet = new SubnetData() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), -}, -PrivateIPAddressVersion = NetworkIPVersion.IPv4, -Name = "fe-lb", -} -}, - VisibilitySubscriptions = -{ -"subscription1","subscription2","subscription3" -}, - AutoApprovalSubscriptions = -{ -"subscription1","subscription2" -}, - Fqdns = -{ -"fqdn1","fqdn2","fqdn3" -}, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceName, data); - PrivateLinkServiceResource result = lro.Value; + bool result = await collection.ExistsAsync(serviceName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateLinkServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPrivateLinkServiceInResourceGroup() + public async Task GetIfExists_GetPrivateLinkService() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceList.json - // this example is just showing the usage of "PrivateLinkServices_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGet.json + // this example is just showing the usage of "PrivateLinkServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -213,17 +192,23 @@ public async Task GetAll_ListPrivateLinkServiceInResourceGroup() // get the collection of this PrivateLinkServiceResource PrivateLinkServiceCollection collection = resourceGroupResource.GetPrivateLinkServices(); - // invoke the operation and iterate over the result - await foreach (PrivateLinkServiceResource item in collection.GetAllAsync()) + // invoke the operation + string serviceName = "testPls"; + NullableResponse response = await collection.GetIfExistsAsync(serviceName); + PrivateLinkServiceResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PrivateLinkServiceData resourceData = item.Data; + PrivateLinkServiceData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateLinkServiceResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateLinkServiceResource.cs index fd8f4dc58f132..2895dee388f07 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateLinkServiceResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PrivateLinkServiceResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_PrivateLinkServiceResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePrivateLinkService() + public async Task Get_GetPrivateLinkService() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceDelete.json - // this example is just showing the usage of "PrivateLinkServices_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGet.json + // this example is just showing the usage of "PrivateLinkServices_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeletePrivateLinkService() PrivateLinkServiceResource privateLinkService = client.GetPrivateLinkServiceResource(privateLinkServiceResourceId); // invoke the operation - await privateLinkService.DeleteAsync(WaitUntil.Completed); + PrivateLinkServiceResource result = await privateLinkService.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateLinkServiceData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPrivateLinkService() + public async Task Delete_DeletePrivateLinkService() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceGet.json - // this example is just showing the usage of "PrivateLinkServices_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceDelete.json + // this example is just showing the usage of "PrivateLinkServices_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetPrivateLinkService() PrivateLinkServiceResource privateLinkService = client.GetPrivateLinkServiceResource(privateLinkServiceResourceId); // invoke the operation - PrivateLinkServiceResource result = await privateLinkService.GetAsync(); + await privateLinkService.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateLinkServiceData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,41 +93,26 @@ public async Task Update_CreatePrivateLinkService() PrivateLinkServiceResource privateLinkService = client.GetPrivateLinkServiceResource(privateLinkServiceResourceId); // invoke the operation - PrivateLinkServiceData data = new PrivateLinkServiceData() + PrivateLinkServiceData data = new PrivateLinkServiceData { - LoadBalancerFrontendIPConfigurations = -{ -new FrontendIPConfigurationData() + LoadBalancerFrontendIPConfigurations = {new FrontendIPConfigurationData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb/frontendIPConfigurations/fe-lb"), -} -}, - IPConfigurations = -{ -new PrivateLinkServiceIPConfiguration() +}}, + IPConfigurations = {new PrivateLinkServiceIPConfiguration { PrivateIPAddress = "10.0.1.4", PrivateIPAllocationMethod = NetworkIPAllocationMethod.Static, -Subnet = new SubnetData() +Subnet = new SubnetData { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnetlb/subnets/subnetlb"), }, PrivateIPAddressVersion = NetworkIPVersion.IPv4, Name = "fe-lb", -} -}, - VisibilitySubscriptions = -{ -"subscription1","subscription2","subscription3" -}, - AutoApprovalSubscriptions = -{ -"subscription1","subscription2" -}, - Fqdns = -{ -"fqdn1","fqdn2","fqdn3" -}, +}}, + VisibilitySubscriptions = { "subscription1", "subscription2", "subscription3" }, + AutoApprovalSubscriptions = { "subscription1", "subscription2" }, + Fqdns = { "fqdn1", "fqdn2", "fqdn3" }, Location = new AzureLocation("eastus"), }; ArmOperation lro = await privateLinkService.UpdateAsync(WaitUntil.Completed, data); @@ -140,36 +124,5 @@ public async Task Update_CreatePrivateLinkService() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPrivateLinkServices_ListAllPrivateListService() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceListAll.json - // this example is just showing the usage of "PrivateLinkServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subId"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PrivateLinkServiceResource item in subscriptionResource.GetPrivateLinkServicesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PrivateLinkServiceData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ProbeCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ProbeCollection.cs index a05940176d91b..d9333fa0ceb69 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ProbeCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ProbeCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ProbeCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_LoadBalancerProbeList() + public async Task Get_LoadBalancerProbeGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerProbeList.json - // this example is just showing the usage of "LoadBalancerProbes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerProbeGet.json + // this example is just showing the usage of "LoadBalancerProbes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,25 +38,23 @@ public async Task GetAll_LoadBalancerProbeList() // get the collection of this ProbeResource ProbeCollection collection = loadBalancer.GetProbes(); - // invoke the operation and iterate over the result - await foreach (ProbeResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProbeData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string probeName = "probe1"; + ProbeResource result = await collection.GetAsync(probeName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProbeData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_LoadBalancerProbeGet() + public async Task GetAll_LoadBalancerProbeList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerProbeGet.json - // this example is just showing the usage of "LoadBalancerProbes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerProbeList.json + // this example is just showing the usage of "LoadBalancerProbes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,15 +72,17 @@ public async Task Get_LoadBalancerProbeGet() // get the collection of this ProbeResource ProbeCollection collection = loadBalancer.GetProbes(); - // invoke the operation - string probeName = "probe1"; - ProbeResource result = await collection.GetAsync(probeName); + // invoke the operation and iterate over the result + await foreach (ProbeResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ProbeData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ProbeData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPAddressCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPAddressCollection.cs index 30713160a7e2f..66194d68d17cc 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPAddressCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPAddressCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_PublicIPAddressCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPublicIPAddress() + public async Task CreateOrUpdate_CreatePublicIPAddressDNS() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressGet.json - // this example is just showing the usage of "PublicIPAddresses_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressCreateDns.json + // this example is just showing the usage of "PublicIPAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,17 @@ public async Task Get_GetPublicIPAddress() PublicIPAddressCollection collection = resourceGroupResource.GetPublicIPAddresses(); // invoke the operation - string publicIPAddressName = "testDNS-ip"; - PublicIPAddressResource result = await collection.GetAsync(publicIPAddressName); + string publicIPAddressName = "test-ip"; + PublicIPAddressData data = new PublicIPAddressData + { + DnsSettings = new PublicIPAddressDnsSettings + { + DomainNameLabel = "dnslbl", + }, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPAddressName, data); + PublicIPAddressResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +61,10 @@ public async Task Get_GetPublicIPAddress() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPublicIPAddress() + public async Task CreateOrUpdate_CreatePublicIPAddressDNSWithDomainNameLabelScope() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressGet.json - // this example is just showing the usage of "PublicIPAddresses_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressCreateDnsWithDomainNameLabelScope.json + // this example is just showing the usage of "PublicIPAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -73,18 +82,32 @@ public async Task Exists_GetPublicIPAddress() PublicIPAddressCollection collection = resourceGroupResource.GetPublicIPAddresses(); // invoke the operation - string publicIPAddressName = "testDNS-ip"; - bool result = await collection.ExistsAsync(publicIPAddressName); + string publicIPAddressName = "test-ip"; + PublicIPAddressData data = new PublicIPAddressData + { + DnsSettings = new PublicIPAddressDnsSettings + { + DomainNameLabel = "dnslbl", + DomainNameLabelScope = PublicIPAddressDnsSettingsDomainNameLabelScope.TenantReuse, + }, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPAddressName, data); + PublicIPAddressResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicIPAddressData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPublicIPAddress() + public async Task CreateOrUpdate_CreatePublicIPAddressAllocationMethod() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressGet.json - // this example is just showing the usage of "PublicIPAddresses_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressCreateCustomizedValues.json + // this example is just showing the usage of "PublicIPAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,29 +125,34 @@ public async Task GetIfExists_GetPublicIPAddress() PublicIPAddressCollection collection = resourceGroupResource.GetPublicIPAddresses(); // invoke the operation - string publicIPAddressName = "testDNS-ip"; - NullableResponse response = await collection.GetIfExistsAsync(publicIPAddressName); - PublicIPAddressResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string publicIPAddressName = "test-ip"; + PublicIPAddressData data = new PublicIPAddressData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicIPAddressData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Sku = new PublicIPAddressSku + { + Name = PublicIPAddressSkuName.Standard, + Tier = PublicIPAddressSkuTier.Global, + }, + PublicIPAllocationMethod = NetworkIPAllocationMethod.Static, + PublicIPAddressVersion = NetworkIPVersion.IPv4, + IdleTimeoutInMinutes = 10, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPAddressName, data); + PublicIPAddressResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicIPAddressData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePublicIPAddressDNS() + public async Task CreateOrUpdate_CreatePublicIPAddressDefaults() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressCreateDns.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressCreateDefaults.json // this example is just showing the usage of "PublicIPAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -144,12 +172,8 @@ public async Task CreateOrUpdate_CreatePublicIPAddressDNS() // invoke the operation string publicIPAddressName = "test-ip"; - PublicIPAddressData data = new PublicIPAddressData() + PublicIPAddressData data = new PublicIPAddressData { - DnsSettings = new PublicIPAddressDnsSettings() - { - DomainNameLabel = "dnslbl", - }, Location = new AzureLocation("eastus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPAddressName, data); @@ -164,10 +188,10 @@ public async Task CreateOrUpdate_CreatePublicIPAddressDNS() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePublicIPAddressDNSWithDomainNameLabelScope() + public async Task Get_GetPublicIPAddress() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressCreateDnsWithDomainNameLabelScope.json - // this example is just showing the usage of "PublicIPAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressGet.json + // this example is just showing the usage of "PublicIPAddresses_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,18 +209,8 @@ public async Task CreateOrUpdate_CreatePublicIPAddressDNSWithDomainNameLabelScop PublicIPAddressCollection collection = resourceGroupResource.GetPublicIPAddresses(); // invoke the operation - string publicIPAddressName = "test-ip"; - PublicIPAddressData data = new PublicIPAddressData() - { - DnsSettings = new PublicIPAddressDnsSettings() - { - DomainNameLabel = "dnslbl", - DomainNameLabelScope = PublicIPAddressDnsSettingsDomainNameLabelScope.TenantReuse, - }, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPAddressName, data); - PublicIPAddressResource result = lro.Value; + string publicIPAddressName = "testDNS-ip"; + PublicIPAddressResource result = await collection.GetAsync(publicIPAddressName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -207,10 +221,10 @@ public async Task CreateOrUpdate_CreatePublicIPAddressDNSWithDomainNameLabelScop [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePublicIPAddressAllocationMethod() + public async Task GetAll_ListResourceGroupPublicIPAddresses() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressCreateCustomizedValues.json - // this example is just showing the usage of "PublicIPAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressList.json + // this example is just showing the usage of "PublicIPAddresses_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -227,36 +241,25 @@ public async Task CreateOrUpdate_CreatePublicIPAddressAllocationMethod() // get the collection of this PublicIPAddressResource PublicIPAddressCollection collection = resourceGroupResource.GetPublicIPAddresses(); - // invoke the operation - string publicIPAddressName = "test-ip"; - PublicIPAddressData data = new PublicIPAddressData() + // invoke the operation and iterate over the result + await foreach (PublicIPAddressResource item in collection.GetAllAsync()) { - Sku = new PublicIPAddressSku() - { - Name = PublicIPAddressSkuName.Standard, - Tier = PublicIPAddressSkuTier.Global, - }, - PublicIPAllocationMethod = NetworkIPAllocationMethod.Static, - PublicIPAddressVersion = NetworkIPVersion.IPv4, - IdleTimeoutInMinutes = 10, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPAddressName, data); - PublicIPAddressResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicIPAddressData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicIPAddressData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePublicIPAddressDefaults() + public async Task Exists_GetPublicIPAddress() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressCreateDefaults.json - // this example is just showing the usage of "PublicIPAddresses_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressGet.json + // this example is just showing the usage of "PublicIPAddresses_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -274,27 +277,18 @@ public async Task CreateOrUpdate_CreatePublicIPAddressDefaults() PublicIPAddressCollection collection = resourceGroupResource.GetPublicIPAddresses(); // invoke the operation - string publicIPAddressName = "test-ip"; - PublicIPAddressData data = new PublicIPAddressData() - { - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPAddressName, data); - PublicIPAddressResource result = lro.Value; + string publicIPAddressName = "testDNS-ip"; + bool result = await collection.ExistsAsync(publicIPAddressName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicIPAddressData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListResourceGroupPublicIPAddresses() + public async Task GetIfExists_GetPublicIPAddress() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressList.json - // this example is just showing the usage of "PublicIPAddresses_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressGet.json + // this example is just showing the usage of "PublicIPAddresses_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -311,17 +305,23 @@ public async Task GetAll_ListResourceGroupPublicIPAddresses() // get the collection of this PublicIPAddressResource PublicIPAddressCollection collection = resourceGroupResource.GetPublicIPAddresses(); - // invoke the operation and iterate over the result - await foreach (PublicIPAddressResource item in collection.GetAllAsync()) + // invoke the operation + string publicIPAddressName = "testDNS-ip"; + NullableResponse response = await collection.GetIfExistsAsync(publicIPAddressName); + PublicIPAddressResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PublicIPAddressData resourceData = item.Data; + PublicIPAddressData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPAddressResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPAddressResource.cs index 45edf5fcab395..f10341030dbcd 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPAddressResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPAddressResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_PublicIPAddressResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePublicIPAddress() + public async Task Get_GetPublicIPAddress() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressDelete.json - // this example is just showing the usage of "PublicIPAddresses_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressGet.json + // this example is just showing the usage of "PublicIPAddresses_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +32,26 @@ public async Task Delete_DeletePublicIPAddress() // for more information of creating PublicIPAddressResource, please refer to the document of PublicIPAddressResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string publicIPAddressName = "test-ip"; + string publicIPAddressName = "testDNS-ip"; ResourceIdentifier publicIPAddressResourceId = PublicIPAddressResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publicIPAddressName); PublicIPAddressResource publicIPAddress = client.GetPublicIPAddressResource(publicIPAddressResourceId); // invoke the operation - await publicIPAddress.DeleteAsync(WaitUntil.Completed); + PublicIPAddressResource result = await publicIPAddress.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicIPAddressData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPublicIPAddress() + public async Task Delete_DeletePublicIPAddress() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressGet.json - // this example is just showing the usage of "PublicIPAddresses_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressDelete.json + // this example is just showing the usage of "PublicIPAddresses_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,18 +62,14 @@ public async Task Get_GetPublicIPAddress() // for more information of creating PublicIPAddressResource, please refer to the document of PublicIPAddressResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string publicIPAddressName = "testDNS-ip"; + string publicIPAddressName = "test-ip"; ResourceIdentifier publicIPAddressResourceId = PublicIPAddressResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, publicIPAddressName); PublicIPAddressResource publicIPAddress = client.GetPublicIPAddressResource(publicIPAddressResourceId); // invoke the operation - PublicIPAddressResource result = await publicIPAddress.GetAsync(); + await publicIPAddress.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicIPAddressData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdatePublicIPAddressTags() PublicIPAddressResource publicIPAddress = client.GetPublicIPAddressResource(publicIPAddressResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; PublicIPAddressResource result = await publicIPAddress.UpdateAsync(networkTagsObject); @@ -111,37 +110,6 @@ public async Task Update_UpdatePublicIPAddressTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPublicIPAddresses_ListAllPublicIPAddresses() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressListAll.json - // this example is just showing the usage of "PublicIPAddresses_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PublicIPAddressResource item in subscriptionResource.GetPublicIPAddressesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicIPAddressData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task DdosProtectionStatus_GetDdosProtectionStatusOfAPublicIPAddress() diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPPrefixCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPPrefixCollection.cs index 13663d79dee45..cc9bc92d94605 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPPrefixCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPPrefixCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_PublicIPPrefixCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPublicIPPrefix() + public async Task CreateOrUpdate_CreatePublicIPPrefixAllocationMethod() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixGet.json - // this example is just showing the usage of "PublicIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixCreateCustomizedValues.json + // this example is just showing the usage of "PublicIPPrefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,19 @@ public async Task Get_GetPublicIPPrefix() // invoke the operation string publicIPPrefixName = "test-ipprefix"; - PublicIPPrefixResource result = await collection.GetAsync(publicIPPrefixName); + PublicIPPrefixData data = new PublicIPPrefixData + { + Sku = new PublicIPPrefixSku + { + Name = PublicIPPrefixSkuName.Standard, + Tier = PublicIPPrefixSkuTier.Regional, + }, + PublicIPAddressVersion = NetworkIPVersion.IPv4, + PrefixLength = 30, + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPPrefixName, data); + PublicIPPrefixResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +64,10 @@ public async Task Get_GetPublicIPPrefix() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPublicIPPrefix() + public async Task CreateOrUpdate_CreatePublicIPPrefixDefaults() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixGet.json - // this example is just showing the usage of "PublicIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixCreateDefaults.json + // this example is just showing the usage of "PublicIPPrefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,14 +86,28 @@ public async Task Exists_GetPublicIPPrefix() // invoke the operation string publicIPPrefixName = "test-ipprefix"; - bool result = await collection.ExistsAsync(publicIPPrefixName); + PublicIPPrefixData data = new PublicIPPrefixData + { + Sku = new PublicIPPrefixSku + { + Name = PublicIPPrefixSkuName.Standard, + }, + PrefixLength = 30, + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPPrefixName, data); + PublicIPPrefixResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicIPPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPublicIPPrefix() + public async Task Get_GetPublicIPPrefix() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixGet.json // this example is just showing the usage of "PublicIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. @@ -103,29 +129,21 @@ public async Task GetIfExists_GetPublicIPPrefix() // invoke the operation string publicIPPrefixName = "test-ipprefix"; - NullableResponse response = await collection.GetIfExistsAsync(publicIPPrefixName); - PublicIPPrefixResource result = response.HasValue ? response.Value : null; + PublicIPPrefixResource result = await collection.GetAsync(publicIPPrefixName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicIPPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicIPPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePublicIPPrefixAllocationMethod() + public async Task GetAll_ListResourceGroupPublicIPPrefixes() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixCreateCustomizedValues.json - // this example is just showing the usage of "PublicIPPrefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixList.json + // this example is just showing the usage of "PublicIPPrefixes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,35 +160,25 @@ public async Task CreateOrUpdate_CreatePublicIPPrefixAllocationMethod() // get the collection of this PublicIPPrefixResource PublicIPPrefixCollection collection = resourceGroupResource.GetPublicIPPrefixes(); - // invoke the operation - string publicIPPrefixName = "test-ipprefix"; - PublicIPPrefixData data = new PublicIPPrefixData() + // invoke the operation and iterate over the result + await foreach (PublicIPPrefixResource item in collection.GetAllAsync()) { - Sku = new PublicIPPrefixSku() - { - Name = PublicIPPrefixSkuName.Standard, - Tier = PublicIPPrefixSkuTier.Regional, - }, - PublicIPAddressVersion = NetworkIPVersion.IPv4, - PrefixLength = 30, - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPPrefixName, data); - PublicIPPrefixResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicIPPrefixData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicIPPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePublicIPPrefixDefaults() + public async Task Exists_GetPublicIPPrefix() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixCreateDefaults.json - // this example is just showing the usage of "PublicIPPrefixes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixGet.json + // this example is just showing the usage of "PublicIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,31 +197,17 @@ public async Task CreateOrUpdate_CreatePublicIPPrefixDefaults() // invoke the operation string publicIPPrefixName = "test-ipprefix"; - PublicIPPrefixData data = new PublicIPPrefixData() - { - Sku = new PublicIPPrefixSku() - { - Name = PublicIPPrefixSkuName.Standard, - }, - PrefixLength = 30, - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, publicIPPrefixName, data); - PublicIPPrefixResource result = lro.Value; + bool result = await collection.ExistsAsync(publicIPPrefixName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicIPPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListResourceGroupPublicIPPrefixes() + public async Task GetIfExists_GetPublicIPPrefix() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixList.json - // this example is just showing the usage of "PublicIPPrefixes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixGet.json + // this example is just showing the usage of "PublicIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -230,17 +224,23 @@ public async Task GetAll_ListResourceGroupPublicIPPrefixes() // get the collection of this PublicIPPrefixResource PublicIPPrefixCollection collection = resourceGroupResource.GetPublicIPPrefixes(); - // invoke the operation and iterate over the result - await foreach (PublicIPPrefixResource item in collection.GetAllAsync()) + // invoke the operation + string publicIPPrefixName = "test-ipprefix"; + NullableResponse response = await collection.GetIfExistsAsync(publicIPPrefixName); + PublicIPPrefixResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - PublicIPPrefixData resourceData = item.Data; + PublicIPPrefixData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPPrefixResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPPrefixResource.cs index 2cf08f814ca7d..931d78499e8b2 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPPrefixResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_PublicIPPrefixResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_PublicIPPrefixResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePublicIPPrefix() + public async Task Get_GetPublicIPPrefix() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixDelete.json - // this example is just showing the usage of "PublicIPPrefixes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixGet.json + // this example is just showing the usage of "PublicIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeletePublicIPPrefix() PublicIPPrefixResource publicIPPrefix = client.GetPublicIPPrefixResource(publicIPPrefixResourceId); // invoke the operation - await publicIPPrefix.DeleteAsync(WaitUntil.Completed); + PublicIPPrefixResource result = await publicIPPrefix.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicIPPrefixData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPublicIPPrefix() + public async Task Delete_DeletePublicIPPrefix() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixGet.json - // this example is just showing the usage of "PublicIPPrefixes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixDelete.json + // this example is just showing the usage of "PublicIPPrefixes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetPublicIPPrefix() PublicIPPrefixResource publicIPPrefix = client.GetPublicIPPrefixResource(publicIPPrefixResourceId); // invoke the operation - PublicIPPrefixResource result = await publicIPPrefix.GetAsync(); + await publicIPPrefix.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicIPPrefixData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdatePublicIPPrefixTags() PublicIPPrefixResource publicIPPrefix = client.GetPublicIPPrefixResource(publicIPPrefixResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; PublicIPPrefixResource result = await publicIPPrefix.UpdateAsync(networkTagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdatePublicIPPrefixTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetPublicIPPrefixes_ListAllPublicIPPrefixes() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixListAll.json - // this example is just showing the usage of "PublicIPPrefixes_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (PublicIPPrefixResource item in subscriptionResource.GetPublicIPPrefixesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - PublicIPPrefixData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs index 2a78a8337c8e6..699677b817231 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ResourceGroupResourceExtensions.cs @@ -125,7 +125,7 @@ public async Task CheckPrivateLinkServiceVisibilityByResourceGroupPrivateLinkSer // invoke the operation AzureLocation location = new AzureLocation("westus"); - CheckPrivateLinkServiceVisibilityRequest checkPrivateLinkServiceVisibilityRequest = new CheckPrivateLinkServiceVisibilityRequest() + CheckPrivateLinkServiceVisibilityRequest checkPrivateLinkServiceVisibilityRequest = new CheckPrivateLinkServiceVisibilityRequest { PrivateLinkServiceAlias = "mypls.00000000-0000-0000-0000-000000000000.azure.privatelinkservice", }; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteCollection.cs index 5fbce2a029b6f..50971356e6d44 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RouteCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRoute() + public async Task CreateOrUpdate_CreateRoute() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteGet.json - // this example is just showing the usage of "Routes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteCreate.json + // this example is just showing the usage of "Routes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,13 @@ public async Task Get_GetRoute() // invoke the operation string routeName = "route1"; - RouteResource result = await collection.GetAsync(routeName); + RouteData data = new RouteData + { + AddressPrefix = "10.0.3.0/24", + NextHopType = RouteNextHopType.VirtualNetworkGateway, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeName, data); + RouteResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +58,7 @@ public async Task Get_GetRoute() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRoute() + public async Task Get_GetRoute() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteGet.json // this example is just showing the usage of "Routes_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +81,21 @@ public async Task Exists_GetRoute() // invoke the operation string routeName = "route1"; - bool result = await collection.ExistsAsync(routeName); + RouteResource result = await collection.GetAsync(routeName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRoute() + public async Task GetAll_ListRoutes() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteGet.json - // this example is just showing the usage of "Routes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteList.json + // this example is just showing the usage of "Routes_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +113,25 @@ public async Task GetIfExists_GetRoute() // get the collection of this RouteResource RouteCollection collection = routeTable.GetRoutes(); - // invoke the operation - string routeName = "route1"; - NullableResponse response = await collection.GetIfExistsAsync(routeName); - RouteResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (RouteResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RouteData resourceData = result.Data; + RouteData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateRoute() + public async Task Exists_GetRoute() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteCreate.json - // this example is just showing the usage of "Routes_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteGet.json + // this example is just showing the usage of "Routes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,27 +151,17 @@ public async Task CreateOrUpdate_CreateRoute() // invoke the operation string routeName = "route1"; - RouteData data = new RouteData() - { - AddressPrefix = "10.0.3.0/24", - NextHopType = RouteNextHopType.VirtualNetworkGateway, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeName, data); - RouteResource result = lro.Value; + bool result = await collection.ExistsAsync(routeName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRoutes() + public async Task GetIfExists_GetRoute() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteList.json - // this example is just showing the usage of "Routes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteGet.json + // this example is just showing the usage of "Routes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_ListRoutes() // get the collection of this RouteResource RouteCollection collection = routeTable.GetRoutes(); - // invoke the operation and iterate over the result - await foreach (RouteResource item in collection.GetAllAsync()) + // invoke the operation + string routeName = "route1"; + NullableResponse response = await collection.GetIfExistsAsync(routeName); + RouteResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RouteData resourceData = item.Data; + RouteData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterCollection.cs index e02f8b501836d..e87f13fb61973 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_RouteFilterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RouteFilterGet() + public async Task CreateOrUpdate_RouteFilterCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterGet.json - // this example is just showing the usage of "RouteFilters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterCreate.json + // this example is just showing the usage of "RouteFilters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,23 @@ public async Task Get_RouteFilterGet() // invoke the operation string routeFilterName = "filterName"; - RouteFilterResource result = await collection.GetAsync(routeFilterName); + RouteFilterData data = new RouteFilterData + { + Rules = {new RouteFilterRuleData +{ +Access = NetworkAccess.Allow, +RouteFilterRuleType = RouteFilterRuleType.Community, +Communities = {"12076:5030", "12076:5040"}, +Name = "ruleName", +}}, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeFilterName, data); + RouteFilterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +68,7 @@ public async Task Get_RouteFilterGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RouteFilterGet() + public async Task Get_RouteFilterGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterGet.json // this example is just showing the usage of "RouteFilters_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +90,21 @@ public async Task Exists_RouteFilterGet() // invoke the operation string routeFilterName = "filterName"; - bool result = await collection.ExistsAsync(routeFilterName); + RouteFilterResource result = await collection.GetAsync(routeFilterName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteFilterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RouteFilterGet() + public async Task GetAll_RouteFilterListByResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterGet.json - // this example is just showing the usage of "RouteFilters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterListByResourceGroup.json + // this example is just showing the usage of "RouteFilters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +121,25 @@ public async Task GetIfExists_RouteFilterGet() // get the collection of this RouteFilterResource RouteFilterCollection collection = resourceGroupResource.GetRouteFilters(); - // invoke the operation - string routeFilterName = "filterName"; - NullableResponse response = await collection.GetIfExistsAsync(routeFilterName); - RouteFilterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (RouteFilterResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RouteFilterData resourceData = result.Data; + RouteFilterData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RouteFilterCreate() + public async Task Exists_RouteFilterGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterCreate.json - // this example is just showing the usage of "RouteFilters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterGet.json + // this example is just showing the usage of "RouteFilters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,43 +158,17 @@ public async Task CreateOrUpdate_RouteFilterCreate() // invoke the operation string routeFilterName = "filterName"; - RouteFilterData data = new RouteFilterData() - { - Rules = -{ -new RouteFilterRuleData() -{ -Access = NetworkAccess.Allow, -RouteFilterRuleType = RouteFilterRuleType.Community, -Communities = -{ -"12076:5030","12076:5040" -}, -Name = "ruleName", -} -}, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeFilterName, data); - RouteFilterResource result = lro.Value; + bool result = await collection.ExistsAsync(routeFilterName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteFilterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RouteFilterListByResourceGroup() + public async Task GetIfExists_RouteFilterGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterListByResourceGroup.json - // this example is just showing the usage of "RouteFilters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterGet.json + // this example is just showing the usage of "RouteFilters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -197,17 +185,23 @@ public async Task GetAll_RouteFilterListByResourceGroup() // get the collection of this RouteFilterResource RouteFilterCollection collection = resourceGroupResource.GetRouteFilters(); - // invoke the operation and iterate over the result - await foreach (RouteFilterResource item in collection.GetAllAsync()) + // invoke the operation + string routeFilterName = "filterName"; + NullableResponse response = await collection.GetIfExistsAsync(routeFilterName); + RouteFilterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RouteFilterData resourceData = item.Data; + RouteFilterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterResource.cs index e9f0090d9df1f..9fb336f48f81e 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_RouteFilterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RouteFilterDelete() + public async Task Get_RouteFilterGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterDelete.json - // this example is just showing the usage of "RouteFilters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterGet.json + // this example is just showing the usage of "RouteFilters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_RouteFilterDelete() RouteFilterResource routeFilter = client.GetRouteFilterResource(routeFilterResourceId); // invoke the operation - await routeFilter.DeleteAsync(WaitUntil.Completed); + RouteFilterResource result = await routeFilter.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteFilterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RouteFilterGet() + public async Task Delete_RouteFilterDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterGet.json - // this example is just showing the usage of "RouteFilters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterDelete.json + // this example is just showing the usage of "RouteFilters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_RouteFilterGet() RouteFilterResource routeFilter = client.GetRouteFilterResource(routeFilterResourceId); // invoke the operation - RouteFilterResource result = await routeFilter.GetAsync(); + await routeFilter.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteFilterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,11 +93,11 @@ public async Task Update_UpdateRouteFilterTags() RouteFilterResource routeFilter = client.GetRouteFilterResource(routeFilterResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { -["key1"] = "value1", +["key1"] = "value1" }, }; RouteFilterResource result = await routeFilter.UpdateAsync(networkTagsObject); @@ -109,36 +108,5 @@ public async Task Update_UpdateRouteFilterTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetRouteFilters_RouteFilterList() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterList.json - // this example is just showing the usage of "RouteFilters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (RouteFilterResource item in subscriptionResource.GetRouteFiltersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteFilterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterRuleCollection.cs index 6d8e44e277bb6..ebef894a5b1f3 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RouteFilterRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RouteFilterRuleGet() + public async Task CreateOrUpdate_RouteFilterRuleCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleGet.json - // this example is just showing the usage of "RouteFilterRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleCreate.json + // this example is just showing the usage of "RouteFilterRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,8 +40,15 @@ public async Task Get_RouteFilterRuleGet() RouteFilterRuleCollection collection = routeFilter.GetRouteFilterRules(); // invoke the operation - string ruleName = "filterName"; - RouteFilterRuleResource result = await collection.GetAsync(ruleName); + string ruleName = "ruleName"; + RouteFilterRuleData data = new RouteFilterRuleData + { + Access = NetworkAccess.Allow, + RouteFilterRuleType = RouteFilterRuleType.Community, + Communities = { "12076:5030", "12076:5040" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); + RouteFilterRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +59,7 @@ public async Task Get_RouteFilterRuleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RouteFilterRuleGet() + public async Task Get_RouteFilterRuleGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleGet.json // this example is just showing the usage of "RouteFilterRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +82,21 @@ public async Task Exists_RouteFilterRuleGet() // invoke the operation string ruleName = "filterName"; - bool result = await collection.ExistsAsync(ruleName); + RouteFilterRuleResource result = await collection.GetAsync(ruleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteFilterRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RouteFilterRuleGet() + public async Task GetAll_RouteFilterRuleListByRouteFilter() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleGet.json - // this example is just showing the usage of "RouteFilterRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleListByRouteFilter.json + // this example is just showing the usage of "RouteFilterRules_ListByRouteFilter" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +114,25 @@ public async Task GetIfExists_RouteFilterRuleGet() // get the collection of this RouteFilterRuleResource RouteFilterRuleCollection collection = routeFilter.GetRouteFilterRules(); - // invoke the operation - string ruleName = "filterName"; - NullableResponse response = await collection.GetIfExistsAsync(ruleName); - RouteFilterRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (RouteFilterRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RouteFilterRuleData resourceData = result.Data; + RouteFilterRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RouteFilterRuleCreate() + public async Task Exists_RouteFilterRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleCreate.json - // this example is just showing the usage of "RouteFilterRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleGet.json + // this example is just showing the usage of "RouteFilterRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,32 +151,18 @@ public async Task CreateOrUpdate_RouteFilterRuleCreate() RouteFilterRuleCollection collection = routeFilter.GetRouteFilterRules(); // invoke the operation - string ruleName = "ruleName"; - RouteFilterRuleData data = new RouteFilterRuleData() - { - Access = NetworkAccess.Allow, - RouteFilterRuleType = RouteFilterRuleType.Community, - Communities = -{ -"12076:5030","12076:5040" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, ruleName, data); - RouteFilterRuleResource result = lro.Value; + string ruleName = "filterName"; + bool result = await collection.ExistsAsync(ruleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteFilterRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RouteFilterRuleListByRouteFilter() + public async Task GetIfExists_RouteFilterRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleListByRouteFilter.json - // this example is just showing the usage of "RouteFilterRules_ListByRouteFilter" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleGet.json + // this example is just showing the usage of "RouteFilterRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -189,17 +180,23 @@ public async Task GetAll_RouteFilterRuleListByRouteFilter() // get the collection of this RouteFilterRuleResource RouteFilterRuleCollection collection = routeFilter.GetRouteFilterRules(); - // invoke the operation and iterate over the result - await foreach (RouteFilterRuleResource item in collection.GetAllAsync()) + // invoke the operation + string ruleName = "filterName"; + NullableResponse response = await collection.GetIfExistsAsync(ruleName); + RouteFilterRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RouteFilterRuleData resourceData = item.Data; + RouteFilterRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterRuleResource.cs index 41bc3e9f2af4a..494c053150e58 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterRuleResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteFilterRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RouteFilterRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RouteFilterRuleDelete() + public async Task Get_RouteFilterRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleDelete.json - // this example is just showing the usage of "RouteFilterRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleGet.json + // this example is just showing the usage of "RouteFilterRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +33,26 @@ public async Task Delete_RouteFilterRuleDelete() string subscriptionId = "subid"; string resourceGroupName = "rg1"; string routeFilterName = "filterName"; - string ruleName = "ruleName"; + string ruleName = "filterName"; ResourceIdentifier routeFilterRuleResourceId = RouteFilterRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, routeFilterName, ruleName); RouteFilterRuleResource routeFilterRule = client.GetRouteFilterRuleResource(routeFilterRuleResourceId); // invoke the operation - await routeFilterRule.DeleteAsync(WaitUntil.Completed); + RouteFilterRuleResource result = await routeFilterRule.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteFilterRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RouteFilterRuleGet() + public async Task Delete_RouteFilterRuleDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleGet.json - // this example is just showing the usage of "RouteFilterRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterRuleDelete.json + // this example is just showing the usage of "RouteFilterRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -60,18 +64,14 @@ public async Task Get_RouteFilterRuleGet() string subscriptionId = "subid"; string resourceGroupName = "rg1"; string routeFilterName = "filterName"; - string ruleName = "filterName"; + string ruleName = "ruleName"; ResourceIdentifier routeFilterRuleResourceId = RouteFilterRuleResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, routeFilterName, ruleName); RouteFilterRuleResource routeFilterRule = client.GetRouteFilterRuleResource(routeFilterRuleResourceId); // invoke the operation - RouteFilterRuleResource result = await routeFilterRule.GetAsync(); + await routeFilterRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteFilterRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,14 +96,11 @@ public async Task Update_RouteFilterRuleCreate() RouteFilterRuleResource routeFilterRule = client.GetRouteFilterRuleResource(routeFilterRuleResourceId); // invoke the operation - RouteFilterRuleData data = new RouteFilterRuleData() + RouteFilterRuleData data = new RouteFilterRuleData { Access = NetworkAccess.Allow, RouteFilterRuleType = RouteFilterRuleType.Community, - Communities = -{ -"12076:5030","12076:5040" -}, + Communities = { "12076:5030", "12076:5040" }, }; ArmOperation lro = await routeFilterRule.UpdateAsync(WaitUntil.Completed, data); RouteFilterRuleResource result = lro.Value; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteMapCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteMapCollection.cs index f10a5eb03110a..1d1e641e4e42f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteMapCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteMapCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_RouteMapCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RouteMapGet() + public async Task CreateOrUpdate_RouteMapPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapGet.json - // this example is just showing the usage of "RouteMaps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapPut.json + // this example is just showing the usage of "RouteMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,35 @@ public async Task Get_RouteMapGet() // invoke the operation string routeMapName = "routeMap1"; - RouteMapResource result = await collection.GetAsync(routeMapName); + RouteMapData data = new RouteMapData + { + AssociatedInboundConnections = { "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteGateways/exrGateway1/expressRouteConnections/exrConn1" }, + AssociatedOutboundConnections = { }, + Rules = {new RouteMapRule +{ +Name = "rule1", +MatchCriteria = {new RouteCriterion +{ +RoutePrefix = {"10.0.0.0/8"}, +Community = {}, +AsPath = {}, +MatchCondition = RouteMapMatchCondition.Contains, +}}, +Actions = {new RouteMapAction +{ +ActionType = RouteMapActionType.Add, +Parameters = {new RouteMapActionParameter +{ +RoutePrefix = {}, +Community = {}, +AsPath = {"22334"}, +}}, +}}, +NextStepIfMatched = RouteMapNextStepBehavior.Continue, +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeMapName, data); + RouteMapResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +80,7 @@ public async Task Get_RouteMapGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RouteMapGet() + public async Task Get_RouteMapGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapGet.json // this example is just showing the usage of "RouteMaps_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +103,21 @@ public async Task Exists_RouteMapGet() // invoke the operation string routeMapName = "routeMap1"; - bool result = await collection.ExistsAsync(routeMapName); + RouteMapResource result = await collection.GetAsync(routeMapName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RouteMapGet() + public async Task GetAll_RouteMapList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapGet.json - // this example is just showing the usage of "RouteMaps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapList.json + // this example is just showing the usage of "RouteMaps_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +135,25 @@ public async Task GetIfExists_RouteMapGet() // get the collection of this RouteMapResource RouteMapCollection collection = virtualHub.GetRouteMaps(); - // invoke the operation - string routeMapName = "routeMap1"; - NullableResponse response = await collection.GetIfExistsAsync(routeMapName); - RouteMapResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (RouteMapResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RouteMapData resourceData = result.Data; + RouteMapData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_RouteMapPut() + public async Task Exists_RouteMapGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapPut.json - // this example is just showing the usage of "RouteMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapGet.json + // this example is just showing the usage of "RouteMaps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,80 +173,17 @@ public async Task CreateOrUpdate_RouteMapPut() // invoke the operation string routeMapName = "routeMap1"; - RouteMapData data = new RouteMapData() - { - AssociatedInboundConnections = -{ -"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteGateways/exrGateway1/expressRouteConnections/exrConn1" -}, - AssociatedOutboundConnections = -{ -}, - Rules = -{ -new RouteMapRule() -{ -Name = "rule1", -MatchCriteria = -{ -new RouteCriterion() -{ -RoutePrefix = -{ -"10.0.0.0/8" -}, -Community = -{ -}, -AsPath = -{ -}, -MatchCondition = RouteMapMatchCondition.Contains, -} -}, -Actions = -{ -new RouteMapAction() -{ -ActionType = RouteMapActionType.Add, -Parameters = -{ -new RouteMapActionParameter() -{ -RoutePrefix = -{ -}, -Community = -{ -}, -AsPath = -{ -"22334" -}, -} -}, -} -}, -NextStepIfMatched = RouteMapNextStepBehavior.Continue, -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeMapName, data); - RouteMapResource result = lro.Value; + bool result = await collection.ExistsAsync(routeMapName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RouteMapList() + public async Task GetIfExists_RouteMapGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapList.json - // this example is just showing the usage of "RouteMaps_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapGet.json + // this example is just showing the usage of "RouteMaps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -238,17 +201,23 @@ public async Task GetAll_RouteMapList() // get the collection of this RouteMapResource RouteMapCollection collection = virtualHub.GetRouteMaps(); - // invoke the operation and iterate over the result - await foreach (RouteMapResource item in collection.GetAllAsync()) + // invoke the operation + string routeMapName = "routeMap1"; + NullableResponse response = await collection.GetIfExistsAsync(routeMapName); + RouteMapResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RouteMapData resourceData = item.Data; + RouteMapData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteMapResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteMapResource.cs index 71592d3196610..7baadb57dacdd 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteMapResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteMapResource.cs @@ -49,10 +49,10 @@ public async Task Get_RouteMapGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RouteMapPut() + public async Task Delete_RouteMapDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapPut.json - // this example is just showing the usage of "RouteMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapDelete.json + // this example is just showing the usage of "RouteMaps_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,80 +69,17 @@ public async Task Update_RouteMapPut() RouteMapResource routeMap = client.GetRouteMapResource(routeMapResourceId); // invoke the operation - RouteMapData data = new RouteMapData() - { - AssociatedInboundConnections = -{ -"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteGateways/exrGateway1/expressRouteConnections/exrConn1" -}, - AssociatedOutboundConnections = -{ -}, - Rules = -{ -new RouteMapRule() -{ -Name = "rule1", -MatchCriteria = -{ -new RouteCriterion() -{ -RoutePrefix = -{ -"10.0.0.0/8" -}, -Community = -{ -}, -AsPath = -{ -}, -MatchCondition = RouteMapMatchCondition.Contains, -} -}, -Actions = -{ -new RouteMapAction() -{ -ActionType = RouteMapActionType.Add, -Parameters = -{ -new RouteMapActionParameter() -{ -RoutePrefix = -{ -}, -Community = -{ -}, -AsPath = -{ -"22334" -}, -} -}, -} -}, -NextStepIfMatched = RouteMapNextStepBehavior.Continue, -} -}, - }; - ArmOperation lro = await routeMap.UpdateAsync(WaitUntil.Completed, data); - RouteMapResource result = lro.Value; + await routeMap.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteMapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RouteMapDelete() + public async Task Update_RouteMapPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapDelete.json - // this example is just showing the usage of "RouteMaps_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteMapPut.json + // this example is just showing the usage of "RouteMaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -159,9 +96,41 @@ public async Task Delete_RouteMapDelete() RouteMapResource routeMap = client.GetRouteMapResource(routeMapResourceId); // invoke the operation - await routeMap.DeleteAsync(WaitUntil.Completed); + RouteMapData data = new RouteMapData + { + AssociatedInboundConnections = { "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteGateways/exrGateway1/expressRouteConnections/exrConn1" }, + AssociatedOutboundConnections = { }, + Rules = {new RouteMapRule +{ +Name = "rule1", +MatchCriteria = {new RouteCriterion +{ +RoutePrefix = {"10.0.0.0/8"}, +Community = {}, +AsPath = {}, +MatchCondition = RouteMapMatchCondition.Contains, +}}, +Actions = {new RouteMapAction +{ +ActionType = RouteMapActionType.Add, +Parameters = {new RouteMapActionParameter +{ +RoutePrefix = {}, +Community = {}, +AsPath = {"22334"}, +}}, +}}, +NextStepIfMatched = RouteMapNextStepBehavior.Continue, +}}, + }; + ArmOperation lro = await routeMap.UpdateAsync(WaitUntil.Completed, data); + RouteMapResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteMapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteResource.cs index 92b2d23274b5e..723fe5611b4c6 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RouteResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRoute() + public async Task Get_GetRoute() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteDelete.json - // this example is just showing the usage of "Routes_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteGet.json + // this example is just showing the usage of "Routes_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteRoute() RouteResource route = client.GetRouteResource(routeResourceId); // invoke the operation - await route.DeleteAsync(WaitUntil.Completed); + RouteResource result = await route.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRoute() + public async Task Delete_DeleteRoute() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteGet.json - // this example is just showing the usage of "Routes_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableRouteDelete.json + // this example is just showing the usage of "Routes_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetRoute() RouteResource route = client.GetRouteResource(routeResourceId); // invoke the operation - RouteResource result = await route.GetAsync(); + await route.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_CreateRoute() RouteResource route = client.GetRouteResource(routeResourceId); // invoke the operation - RouteData data = new RouteData() + RouteData data = new RouteData { AddressPrefix = "10.0.3.0/24", NextHopType = RouteNextHopType.VirtualNetworkGateway, diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteTableCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteTableCollection.cs index 8d2206a5d5620..4bba790178cbc 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteTableCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteTableCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_RouteTableCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRouteTable() + public async Task CreateOrUpdate_CreateRouteTable() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableGet.json - // this example is just showing the usage of "RouteTables_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableCreate.json + // this example is just showing the usage of "RouteTables_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetRouteTable() // invoke the operation string routeTableName = "testrt"; - RouteTableResource result = await collection.GetAsync(routeTableName); + RouteTableData data = new RouteTableData + { + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeTableName, data); + RouteTableResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +57,10 @@ public async Task Get_GetRouteTable() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetRouteTable() + public async Task CreateOrUpdate_CreateRouteTableWithRoute() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableGet.json - // this example is just showing the usage of "RouteTables_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableCreateWithRoute.json + // this example is just showing the usage of "RouteTables_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,14 +79,30 @@ public async Task Exists_GetRouteTable() // invoke the operation string routeTableName = "testrt"; - bool result = await collection.ExistsAsync(routeTableName); + RouteTableData data = new RouteTableData + { + Routes = {new RouteData +{ +AddressPrefix = "10.0.3.0/24", +NextHopType = RouteNextHopType.VirtualNetworkGateway, +Name = "route1", +}}, + DisableBgpRoutePropagation = true, + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeTableName, data); + RouteTableResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetRouteTable() + public async Task Get_GetRouteTable() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableGet.json // this example is just showing the usage of "RouteTables_Get" operation, for the dependent resources, they will have to be created separately. @@ -103,29 +124,21 @@ public async Task GetIfExists_GetRouteTable() // invoke the operation string routeTableName = "testrt"; - NullableResponse response = await collection.GetIfExistsAsync(routeTableName); - RouteTableResource result = response.HasValue ? response.Value : null; + RouteTableResource result = await collection.GetAsync(routeTableName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateRouteTable() + public async Task GetAll_ListRouteTablesInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableCreate.json - // this example is just showing the usage of "RouteTables_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableList.json + // this example is just showing the usage of "RouteTables_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,28 +155,25 @@ public async Task CreateOrUpdate_CreateRouteTable() // get the collection of this RouteTableResource RouteTableCollection collection = resourceGroupResource.GetRouteTables(); - // invoke the operation - string routeTableName = "testrt"; - RouteTableData data = new RouteTableData() + // invoke the operation and iterate over the result + await foreach (RouteTableResource item in collection.GetAllAsync()) { - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeTableName, data); - RouteTableResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteTableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateRouteTableWithRoute() + public async Task Exists_GetRouteTable() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableCreateWithRoute.json - // this example is just showing the usage of "RouteTables_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableGet.json + // this example is just showing the usage of "RouteTables_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -182,36 +192,17 @@ public async Task CreateOrUpdate_CreateRouteTableWithRoute() // invoke the operation string routeTableName = "testrt"; - RouteTableData data = new RouteTableData() - { - Routes = -{ -new RouteData() -{ -AddressPrefix = "10.0.3.0/24", -NextHopType = RouteNextHopType.VirtualNetworkGateway, -Name = "route1", -} -}, - DisableBgpRoutePropagation = true, - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeTableName, data); - RouteTableResource result = lro.Value; + bool result = await collection.ExistsAsync(routeTableName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListRouteTablesInResourceGroup() + public async Task GetIfExists_GetRouteTable() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableList.json - // this example is just showing the usage of "RouteTables_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableGet.json + // this example is just showing the usage of "RouteTables_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -228,17 +219,23 @@ public async Task GetAll_ListRouteTablesInResourceGroup() // get the collection of this RouteTableResource RouteTableCollection collection = resourceGroupResource.GetRouteTables(); - // invoke the operation and iterate over the result - await foreach (RouteTableResource item in collection.GetAllAsync()) + // invoke the operation + string routeTableName = "testrt"; + NullableResponse response = await collection.GetIfExistsAsync(routeTableName); + RouteTableResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RouteTableData resourceData = item.Data; + RouteTableData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteTableResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteTableResource.cs index ceefb75131286..fb4cec5d615f2 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteTableResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RouteTableResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_RouteTableResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteRouteTable() + public async Task Get_GetRouteTable() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableDelete.json - // this example is just showing the usage of "RouteTables_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableGet.json + // this example is just showing the usage of "RouteTables_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteRouteTable() RouteTableResource routeTable = client.GetRouteTableResource(routeTableResourceId); // invoke the operation - await routeTable.DeleteAsync(WaitUntil.Completed); + RouteTableResource result = await routeTable.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteTableData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetRouteTable() + public async Task Delete_DeleteRouteTable() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableGet.json - // this example is just showing the usage of "RouteTables_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableDelete.json + // this example is just showing the usage of "RouteTables_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetRouteTable() RouteTableResource routeTable = client.GetRouteTableResource(routeTableResourceId); // invoke the operation - RouteTableResource result = await routeTable.GetAsync(); + await routeTable.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteTableData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateRouteTableTags() RouteTableResource routeTable = client.GetRouteTableResource(routeTableResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; RouteTableResource result = await routeTable.UpdateAsync(networkTagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdateRouteTableTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetRouteTables_ListAllRouteTables() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableListAll.json - // this example is just showing the usage of "RouteTables_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (RouteTableResource item in subscriptionResource.GetRouteTablesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RouteTableData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RoutingIntentCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RoutingIntentCollection.cs index 092a6b0101731..cab1f0d90083c 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RoutingIntentCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RoutingIntentCollection.cs @@ -41,18 +41,9 @@ public async Task CreateOrUpdate_RouteTablePut() // invoke the operation string routingIntentName = "Intent1"; - RoutingIntentData data = new RoutingIntentData() + RoutingIntentData data = new RoutingIntentData { - RoutingPolicies = -{ -new RoutingPolicy("InternetTraffic",new string[] -{ -"Internet" -},"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azfw1"),new RoutingPolicy("PrivateTrafficPolicy",new string[] -{ -"PrivateTraffic" -},"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azfw1") -}, + RoutingPolicies = { new RoutingPolicy("InternetTraffic", new string[] { "Internet" }, "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azfw1"), new RoutingPolicy("PrivateTrafficPolicy", new string[] { "PrivateTraffic" }, "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azfw1") }, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routingIntentName, data); RoutingIntentResource result = lro.Value; @@ -100,10 +91,10 @@ public async Task Get_RouteTableGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_RouteTableGet() + public async Task GetAll_RoutingIntentList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentGet.json - // this example is just showing the usage of "RoutingIntent_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentList.json + // this example is just showing the usage of "RoutingIntent_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,16 +112,22 @@ public async Task Exists_RouteTableGet() // get the collection of this RoutingIntentResource RoutingIntentCollection collection = virtualHub.GetRoutingIntents(); - // invoke the operation - string routingIntentName = "Intent1"; - bool result = await collection.ExistsAsync(routingIntentName); + // invoke the operation and iterate over the result + await foreach (RoutingIntentResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoutingIntentData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_RouteTableGet() + public async Task Exists_RouteTableGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentGet.json // this example is just showing the usage of "RoutingIntent_Get" operation, for the dependent resources, they will have to be created separately. @@ -153,29 +150,17 @@ public async Task GetIfExists_RouteTableGet() // invoke the operation string routingIntentName = "Intent1"; - NullableResponse response = await collection.GetIfExistsAsync(routingIntentName); - RoutingIntentResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(routingIntentName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoutingIntentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_RoutingIntentList() + public async Task GetIfExists_RouteTableGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentList.json - // this example is just showing the usage of "RoutingIntent_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentGet.json + // this example is just showing the usage of "RoutingIntent_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -193,17 +178,23 @@ public async Task GetAll_RoutingIntentList() // get the collection of this RoutingIntentResource RoutingIntentCollection collection = virtualHub.GetRoutingIntents(); - // invoke the operation and iterate over the result - await foreach (RoutingIntentResource item in collection.GetAllAsync()) + // invoke the operation + string routingIntentName = "Intent1"; + NullableResponse response = await collection.GetIfExistsAsync(routingIntentName); + RoutingIntentResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - RoutingIntentData resourceData = item.Data; + RoutingIntentData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RoutingIntentResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RoutingIntentResource.cs index 6d43aa9609c35..df71df15461e5 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RoutingIntentResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_RoutingIntentResource.cs @@ -18,10 +18,10 @@ public partial class Sample_RoutingIntentResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_RouteTablePut() + public async Task Get_RouteTableGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentPut.json - // this example is just showing the usage of "RoutingIntent_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentGet.json + // this example is just showing the usage of "RoutingIntent_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,21 +38,7 @@ public async Task Update_RouteTablePut() RoutingIntentResource routingIntent = client.GetRoutingIntentResource(routingIntentResourceId); // invoke the operation - RoutingIntentData data = new RoutingIntentData() - { - RoutingPolicies = -{ -new RoutingPolicy("InternetTraffic",new string[] -{ -"Internet" -},"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azfw1"),new RoutingPolicy("PrivateTrafficPolicy",new string[] -{ -"PrivateTraffic" -},"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azfw1") -}, - }; - ArmOperation lro = await routingIntent.UpdateAsync(WaitUntil.Completed, data); - RoutingIntentResource result = lro.Value; + RoutingIntentResource result = await routingIntent.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -63,10 +49,10 @@ public async Task Update_RouteTablePut() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_RouteTableGet() + public async Task Delete_RouteTableDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentGet.json - // this example is just showing the usage of "RoutingIntent_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentDelete.json + // this example is just showing the usage of "RoutingIntent_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -83,21 +69,17 @@ public async Task Get_RouteTableGet() RoutingIntentResource routingIntent = client.GetRoutingIntentResource(routingIntentResourceId); // invoke the operation - RoutingIntentResource result = await routingIntent.GetAsync(); + await routingIntent.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - RoutingIntentData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_RouteTableDelete() + public async Task Update_RouteTablePut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentDelete.json - // this example is just showing the usage of "RoutingIntent_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RoutingIntentPut.json + // this example is just showing the usage of "RoutingIntent_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -114,9 +96,18 @@ public async Task Delete_RouteTableDelete() RoutingIntentResource routingIntent = client.GetRoutingIntentResource(routingIntentResourceId); // invoke the operation - await routingIntent.DeleteAsync(WaitUntil.Completed); + RoutingIntentData data = new RoutingIntentData + { + RoutingPolicies = { new RoutingPolicy("InternetTraffic", new string[] { "Internet" }, "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azfw1"), new RoutingPolicy("PrivateTrafficPolicy", new string[] { "PrivateTraffic" }, "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/azureFirewalls/azfw1") }, + }; + ArmOperation lro = await routingIntent.UpdateAsync(WaitUntil.Completed, data); + RoutingIntentResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RoutingIntentData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ScopeConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ScopeConnectionCollection.cs index 99a23f38b81f1..0838fbf2d45cb 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ScopeConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ScopeConnectionCollection.cs @@ -40,7 +40,7 @@ public async Task CreateOrUpdate_CreateOrUpdateNetworkManagerScopeConnection() // invoke the operation string scopeConnectionName = "TestScopeConnection"; - ScopeConnectionData data = new ScopeConnectionData() + ScopeConnectionData data = new ScopeConnectionData { TenantId = Guid.Parse("6babcaad-604b-40ac-a9d7-9fd97c0b779f"), ResourceId = new ResourceIdentifier("subscriptions/f0dc2b34-dfad-40e4-83e0-2309fed8d00b"), @@ -92,10 +92,10 @@ public async Task Get_GetNetworkManagerScopeConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkManagerScopeConnection() + public async Task GetAll_ListNetworkManagerScopeConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionGet.json - // this example is just showing the usage of "ScopeConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionList.json + // this example is just showing the usage of "ScopeConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -113,16 +113,22 @@ public async Task Exists_GetNetworkManagerScopeConnection() // get the collection of this ScopeConnectionResource ScopeConnectionCollection collection = networkManager.GetScopeConnections(); - // invoke the operation - string scopeConnectionName = "TestScopeConnection"; - bool result = await collection.ExistsAsync(scopeConnectionName); + // invoke the operation and iterate over the result + await foreach (ScopeConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScopeConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkManagerScopeConnection() + public async Task Exists_GetNetworkManagerScopeConnection() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionGet.json // this example is just showing the usage of "ScopeConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -145,29 +151,17 @@ public async Task GetIfExists_GetNetworkManagerScopeConnection() // invoke the operation string scopeConnectionName = "TestScopeConnection"; - NullableResponse response = await collection.GetIfExistsAsync(scopeConnectionName); - ScopeConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(scopeConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScopeConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNetworkManagerScopeConnection() + public async Task GetIfExists_GetNetworkManagerScopeConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionList.json - // this example is just showing the usage of "ScopeConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionGet.json + // this example is just showing the usage of "ScopeConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_ListNetworkManagerScopeConnection() // get the collection of this ScopeConnectionResource ScopeConnectionCollection collection = networkManager.GetScopeConnections(); - // invoke the operation and iterate over the result - await foreach (ScopeConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string scopeConnectionName = "TestScopeConnection"; + NullableResponse response = await collection.GetIfExistsAsync(scopeConnectionName); + ScopeConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ScopeConnectionData resourceData = item.Data; + ScopeConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ScopeConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ScopeConnectionResource.cs index 103830f218295..1febd9efbd4fc 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ScopeConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ScopeConnectionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ScopeConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateNetworkManagerScopeConnection() + public async Task Get_GetNetworkManagerScopeConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionPut.json - // this example is just showing the usage of "ScopeConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionGet.json + // this example is just showing the usage of "ScopeConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,14 +37,7 @@ public async Task Update_CreateOrUpdateNetworkManagerScopeConnection() ScopeConnectionResource scopeConnection = client.GetScopeConnectionResource(scopeConnectionResourceId); // invoke the operation - ScopeConnectionData data = new ScopeConnectionData() - { - TenantId = Guid.Parse("6babcaad-604b-40ac-a9d7-9fd97c0b779f"), - ResourceId = new ResourceIdentifier("subscriptions/f0dc2b34-dfad-40e4-83e0-2309fed8d00b"), - Description = "This is a scope connection to a cross tenant subscription.", - }; - ArmOperation lro = await scopeConnection.UpdateAsync(WaitUntil.Completed, data); - ScopeConnectionResource result = lro.Value; + ScopeConnectionResource result = await scopeConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -55,10 +48,10 @@ public async Task Update_CreateOrUpdateNetworkManagerScopeConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkManagerScopeConnection() + public async Task Delete_DeleteNetworkManagerScopeConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionGet.json - // this example is just showing the usage of "ScopeConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionDelete.json + // this example is just showing the usage of "ScopeConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,21 +68,17 @@ public async Task Get_GetNetworkManagerScopeConnection() ScopeConnectionResource scopeConnection = client.GetScopeConnectionResource(scopeConnectionResourceId); // invoke the operation - ScopeConnectionResource result = await scopeConnection.GetAsync(); + await scopeConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ScopeConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkManagerScopeConnection() + public async Task Update_CreateOrUpdateNetworkManagerScopeConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionDelete.json - // this example is just showing the usage of "ScopeConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerScopeConnectionPut.json + // this example is just showing the usage of "ScopeConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,9 +95,20 @@ public async Task Delete_DeleteNetworkManagerScopeConnection() ScopeConnectionResource scopeConnection = client.GetScopeConnectionResource(scopeConnectionResourceId); // invoke the operation - await scopeConnection.DeleteAsync(WaitUntil.Completed); + ScopeConnectionData data = new ScopeConnectionData + { + TenantId = Guid.Parse("6babcaad-604b-40ac-a9d7-9fd97c0b779f"), + ResourceId = new ResourceIdentifier("subscriptions/f0dc2b34-dfad-40e4-83e0-2309fed8d00b"), + Description = "This is a scope connection to a cross tenant subscription.", + }; + ArmOperation lro = await scopeConnection.UpdateAsync(WaitUntil.Completed, data); + ScopeConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ScopeConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityAdminConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityAdminConfigurationCollection.cs index 54d14ff4b76fb..b73d99413fd18 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityAdminConfigurationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityAdminConfigurationCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SecurityAdminConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSecurityAdminConfigurationsInANetworkManager() + public async Task CreateOrUpdate_CreateNetworkManagerSecurityAdminConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationList.json - // this example is just showing the usage of "SecurityAdminConfigurations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationPut.json + // this example is just showing the usage of "SecurityAdminConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,17 +39,21 @@ public async Task GetAll_ListSecurityAdminConfigurationsInANetworkManager() // get the collection of this SecurityAdminConfigurationResource SecurityAdminConfigurationCollection collection = networkManager.GetSecurityAdminConfigurations(); - // invoke the operation and iterate over the result - await foreach (SecurityAdminConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string configurationName = "myTestSecurityConfig"; + SecurityAdminConfigurationData data = new SecurityAdminConfigurationData { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAdminConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Description = "A sample policy", + ApplyOnNetworkIntentPolicyBasedServices = { NetworkIntentPolicyBasedService.None }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); + SecurityAdminConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAdminConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -88,10 +92,10 @@ public async Task Get_GetSecurityAdminConfigurations() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSecurityAdminConfigurations() + public async Task GetAll_ListSecurityAdminConfigurationsInANetworkManager() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationGet.json - // this example is just showing the usage of "SecurityAdminConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationList.json + // this example is just showing the usage of "SecurityAdminConfigurations_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,16 +113,22 @@ public async Task Exists_GetSecurityAdminConfigurations() // get the collection of this SecurityAdminConfigurationResource SecurityAdminConfigurationCollection collection = networkManager.GetSecurityAdminConfigurations(); - // invoke the operation - string configurationName = "myTestSecurityConfig"; - bool result = await collection.ExistsAsync(configurationName); + // invoke the operation and iterate over the result + await foreach (SecurityAdminConfigurationResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAdminConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSecurityAdminConfigurations() + public async Task Exists_GetSecurityAdminConfigurations() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationGet.json // this example is just showing the usage of "SecurityAdminConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -141,29 +151,17 @@ public async Task GetIfExists_GetSecurityAdminConfigurations() // invoke the operation string configurationName = "myTestSecurityConfig"; - NullableResponse response = await collection.GetIfExistsAsync(configurationName); - SecurityAdminConfigurationResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAdminConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkManagerSecurityAdminConfiguration() + public async Task GetIfExists_GetSecurityAdminConfigurations() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationPut.json - // this example is just showing the usage of "SecurityAdminConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationGet.json + // this example is just showing the usage of "SecurityAdminConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,22 +181,21 @@ public async Task CreateOrUpdate_CreateNetworkManagerSecurityAdminConfiguration( // invoke the operation string configurationName = "myTestSecurityConfig"; - SecurityAdminConfigurationData data = new SecurityAdminConfigurationData() - { - Description = "A sample policy", - ApplyOnNetworkIntentPolicyBasedServices = -{ -NetworkIntentPolicyBasedService.None -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationName, data); - SecurityAdminConfigurationResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(configurationName); + SecurityAdminConfigurationResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAdminConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAdminConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityAdminConfigurationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityAdminConfigurationResource.cs index 327b8f6c0b0e4..41f64191a33f9 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityAdminConfigurationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityAdminConfigurationResource.cs @@ -49,10 +49,10 @@ public async Task Get_GetSecurityAdminConfigurations() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateNetworkManagerSecurityAdminConfiguration() + public async Task Delete_DeleteNetworkManagerSecurityAdminConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationPut.json - // this example is just showing the usage of "SecurityAdminConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationDelete.json + // this example is just showing the usage of "SecurityAdminConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,30 +69,18 @@ public async Task Update_CreateNetworkManagerSecurityAdminConfiguration() SecurityAdminConfigurationResource securityAdminConfiguration = client.GetSecurityAdminConfigurationResource(securityAdminConfigurationResourceId); // invoke the operation - SecurityAdminConfigurationData data = new SecurityAdminConfigurationData() - { - Description = "A sample policy", - ApplyOnNetworkIntentPolicyBasedServices = -{ -NetworkIntentPolicyBasedService.None -}, - }; - ArmOperation lro = await securityAdminConfiguration.UpdateAsync(WaitUntil.Completed, data); - SecurityAdminConfigurationResource result = lro.Value; + bool? force = false; + await securityAdminConfiguration.DeleteAsync(WaitUntil.Completed, force: force); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityAdminConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkManagerSecurityAdminConfiguration() + public async Task Update_CreateNetworkManagerSecurityAdminConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationDelete.json - // this example is just showing the usage of "SecurityAdminConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerSecurityAdminConfigurationPut.json + // this example is just showing the usage of "SecurityAdminConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -109,10 +97,19 @@ public async Task Delete_DeleteNetworkManagerSecurityAdminConfiguration() SecurityAdminConfigurationResource securityAdminConfiguration = client.GetSecurityAdminConfigurationResource(securityAdminConfigurationResourceId); // invoke the operation - bool? force = false; - await securityAdminConfiguration.DeleteAsync(WaitUntil.Completed, force: force); + SecurityAdminConfigurationData data = new SecurityAdminConfigurationData + { + Description = "A sample policy", + ApplyOnNetworkIntentPolicyBasedServices = { NetworkIntentPolicyBasedService.None }, + }; + ArmOperation lro = await securityAdminConfiguration.UpdateAsync(WaitUntil.Completed, data); + SecurityAdminConfigurationResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityAdminConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityPartnerProviderCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityPartnerProviderCollection.cs index 0319d19bdde89..9484000a9ed59 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityPartnerProviderCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityPartnerProviderCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_SecurityPartnerProviderCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityPartnerProvider() + public async Task CreateOrUpdate_CreateSecurityPartnerProvider() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderGet.json - // this example is just showing the usage of "SecurityPartnerProviders_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderPut.json + // this example is just showing the usage of "SecurityPartnerProviders_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_GetSecurityPartnerProvider() // invoke the operation string securityPartnerProviderName = "securityPartnerProvider"; - SecurityPartnerProviderResource result = await collection.GetAsync(securityPartnerProviderName); + SecurityPartnerProviderData data = new SecurityPartnerProviderData + { + SecurityProviderName = SecurityProviderName.ZScaler, + VirtualHubId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1"), + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityPartnerProviderName, data); + SecurityPartnerProviderResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +63,7 @@ public async Task Get_GetSecurityPartnerProvider() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSecurityPartnerProvider() + public async Task Get_GetSecurityPartnerProvider() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderGet.json // this example is just showing the usage of "SecurityPartnerProviders_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +85,21 @@ public async Task Exists_GetSecurityPartnerProvider() // invoke the operation string securityPartnerProviderName = "securityPartnerProvider"; - bool result = await collection.ExistsAsync(securityPartnerProviderName); + SecurityPartnerProviderResource result = await collection.GetAsync(securityPartnerProviderName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityPartnerProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSecurityPartnerProvider() + public async Task GetAll_ListAllSecurityPartnerProvidersForAGivenResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderGet.json - // this example is just showing the usage of "SecurityPartnerProviders_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderListByResourceGroup.json + // this example is just showing the usage of "SecurityPartnerProviders_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +116,25 @@ public async Task GetIfExists_GetSecurityPartnerProvider() // get the collection of this SecurityPartnerProviderResource SecurityPartnerProviderCollection collection = resourceGroupResource.GetSecurityPartnerProviders(); - // invoke the operation - string securityPartnerProviderName = "securityPartnerProvider"; - NullableResponse response = await collection.GetIfExistsAsync(securityPartnerProviderName); - SecurityPartnerProviderResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SecurityPartnerProviderResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SecurityPartnerProviderData resourceData = result.Data; + SecurityPartnerProviderData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSecurityPartnerProvider() + public async Task Exists_GetSecurityPartnerProvider() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderPut.json - // this example is just showing the usage of "SecurityPartnerProviders_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderGet.json + // this example is just showing the usage of "SecurityPartnerProviders_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,32 +153,17 @@ public async Task CreateOrUpdate_CreateSecurityPartnerProvider() // invoke the operation string securityPartnerProviderName = "securityPartnerProvider"; - SecurityPartnerProviderData data = new SecurityPartnerProviderData() - { - SecurityProviderName = SecurityProviderName.ZScaler, - VirtualHubId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1"), - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityPartnerProviderName, data); - SecurityPartnerProviderResource result = lro.Value; + bool result = await collection.ExistsAsync(securityPartnerProviderName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityPartnerProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllSecurityPartnerProvidersForAGivenResourceGroup() + public async Task GetIfExists_GetSecurityPartnerProvider() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderListByResourceGroup.json - // this example is just showing the usage of "SecurityPartnerProviders_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderGet.json + // this example is just showing the usage of "SecurityPartnerProviders_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_ListAllSecurityPartnerProvidersForAGivenResourceGroup() // get the collection of this SecurityPartnerProviderResource SecurityPartnerProviderCollection collection = resourceGroupResource.GetSecurityPartnerProviders(); - // invoke the operation and iterate over the result - await foreach (SecurityPartnerProviderResource item in collection.GetAllAsync()) + // invoke the operation + string securityPartnerProviderName = "securityPartnerProvider"; + NullableResponse response = await collection.GetIfExistsAsync(securityPartnerProviderName); + SecurityPartnerProviderResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SecurityPartnerProviderData resourceData = item.Data; + SecurityPartnerProviderData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityPartnerProviderResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityPartnerProviderResource.cs index 6e0a18834ae96..1d2b9a18fe00b 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityPartnerProviderResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityPartnerProviderResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_SecurityPartnerProviderResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSecurityPartnerProvider() + public async Task Get_GetSecurityPartnerProvider() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderDelete.json - // this example is just showing the usage of "SecurityPartnerProviders_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderGet.json + // this example is just showing the usage of "SecurityPartnerProviders_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +37,21 @@ public async Task Delete_DeleteSecurityPartnerProvider() SecurityPartnerProviderResource securityPartnerProvider = client.GetSecurityPartnerProviderResource(securityPartnerProviderResourceId); // invoke the operation - await securityPartnerProvider.DeleteAsync(WaitUntil.Completed); + SecurityPartnerProviderResource result = await securityPartnerProvider.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityPartnerProviderData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSecurityPartnerProvider() + public async Task Delete_DeleteSecurityPartnerProvider() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderGet.json - // this example is just showing the usage of "SecurityPartnerProviders_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderDelete.json + // this example is just showing the usage of "SecurityPartnerProviders_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +67,9 @@ public async Task Get_GetSecurityPartnerProvider() SecurityPartnerProviderResource securityPartnerProvider = client.GetSecurityPartnerProviderResource(securityPartnerProviderResourceId); // invoke the operation - SecurityPartnerProviderResource result = await securityPartnerProvider.GetAsync(); + await securityPartnerProvider.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityPartnerProviderData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateSecurityPartnerProviderTags() SecurityPartnerProviderResource securityPartnerProvider = client.GetSecurityPartnerProviderResource(securityPartnerProviderResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; SecurityPartnerProviderResource result = await securityPartnerProvider.UpdateAsync(networkTagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdateSecurityPartnerProviderTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetSecurityPartnerProviders_ListAllSecurityPartnerProvidersForAGivenSubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderListBySubscription.json - // this example is just showing the usage of "SecurityPartnerProviders_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (SecurityPartnerProviderResource item in subscriptionResource.GetSecurityPartnerProvidersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityPartnerProviderData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityRuleCollection.cs index 42f77edb05925..6d5c7be54694f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SecurityRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSecurityRuleInNetworkSecurityGroup() + public async Task CreateOrUpdate_CreateSecurityRule() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleGet.json - // this example is just showing the usage of "SecurityRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleCreate.json + // this example is just showing the usage of "SecurityRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,19 @@ public async Task Get_GetNetworkSecurityRuleInNetworkSecurityGroup() // invoke the operation string securityRuleName = "rule1"; - SecurityRuleResource result = await collection.GetAsync(securityRuleName); + SecurityRuleData data = new SecurityRuleData + { + Protocol = SecurityRuleProtocol.Asterisk, + SourcePortRange = "*", + DestinationPortRange = "8080", + SourceAddressPrefix = "10.0.0.0/8", + DestinationAddressPrefix = "11.0.0.0/8", + Access = SecurityRuleAccess.Deny, + Priority = 100, + Direction = SecurityRuleDirection.Outbound, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityRuleName, data); + SecurityRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +64,7 @@ public async Task Get_GetNetworkSecurityRuleInNetworkSecurityGroup() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkSecurityRuleInNetworkSecurityGroup() + public async Task Get_GetNetworkSecurityRuleInNetworkSecurityGroup() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleGet.json // this example is just showing the usage of "SecurityRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +87,21 @@ public async Task Exists_GetNetworkSecurityRuleInNetworkSecurityGroup() // invoke the operation string securityRuleName = "rule1"; - bool result = await collection.ExistsAsync(securityRuleName); + SecurityRuleResource result = await collection.GetAsync(securityRuleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkSecurityRuleInNetworkSecurityGroup() + public async Task GetAll_ListNetworkSecurityRulesInNetworkSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleGet.json - // this example is just showing the usage of "SecurityRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleList.json + // this example is just showing the usage of "SecurityRules_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +119,25 @@ public async Task GetIfExists_GetNetworkSecurityRuleInNetworkSecurityGroup() // get the collection of this SecurityRuleResource SecurityRuleCollection collection = networkSecurityGroup.GetSecurityRules(); - // invoke the operation - string securityRuleName = "rule1"; - NullableResponse response = await collection.GetIfExistsAsync(securityRuleName); - SecurityRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SecurityRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SecurityRuleData resourceData = result.Data; + SecurityRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSecurityRule() + public async Task Exists_GetNetworkSecurityRuleInNetworkSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleCreate.json - // this example is just showing the usage of "SecurityRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleGet.json + // this example is just showing the usage of "SecurityRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,33 +157,17 @@ public async Task CreateOrUpdate_CreateSecurityRule() // invoke the operation string securityRuleName = "rule1"; - SecurityRuleData data = new SecurityRuleData() - { - Protocol = SecurityRuleProtocol.Asterisk, - SourcePortRange = "*", - DestinationPortRange = "8080", - SourceAddressPrefix = "10.0.0.0/8", - DestinationAddressPrefix = "11.0.0.0/8", - Access = SecurityRuleAccess.Deny, - Priority = 100, - Direction = SecurityRuleDirection.Outbound, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, securityRuleName, data); - SecurityRuleResource result = lro.Value; + bool result = await collection.ExistsAsync(securityRuleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListNetworkSecurityRulesInNetworkSecurityGroup() + public async Task GetIfExists_GetNetworkSecurityRuleInNetworkSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleList.json - // this example is just showing the usage of "SecurityRules_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleGet.json + // this example is just showing the usage of "SecurityRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -191,17 +185,23 @@ public async Task GetAll_ListNetworkSecurityRulesInNetworkSecurityGroup() // get the collection of this SecurityRuleResource SecurityRuleCollection collection = networkSecurityGroup.GetSecurityRules(); - // invoke the operation and iterate over the result - await foreach (SecurityRuleResource item in collection.GetAllAsync()) + // invoke the operation + string securityRuleName = "rule1"; + NullableResponse response = await collection.GetIfExistsAsync(securityRuleName); + SecurityRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SecurityRuleData resourceData = item.Data; + SecurityRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityRuleResource.cs index fc5799891fadf..7552b889a1d68 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityRuleResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SecurityRuleResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SecurityRuleResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkSecurityRuleFromNetworkSecurityGroup() + public async Task Get_GetNetworkSecurityRuleInNetworkSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleDelete.json - // this example is just showing the usage of "SecurityRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleGet.json + // this example is just showing the usage of "SecurityRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteNetworkSecurityRuleFromNetworkSecurityGroup() SecurityRuleResource securityRule = client.GetSecurityRuleResource(securityRuleResourceId); // invoke the operation - await securityRule.DeleteAsync(WaitUntil.Completed); + SecurityRuleResource result = await securityRule.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkSecurityRuleInNetworkSecurityGroup() + public async Task Delete_DeleteNetworkSecurityRuleFromNetworkSecurityGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleGet.json - // this example is just showing the usage of "SecurityRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupRuleDelete.json + // this example is just showing the usage of "SecurityRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetNetworkSecurityRuleInNetworkSecurityGroup() SecurityRuleResource securityRule = client.GetSecurityRuleResource(securityRuleResourceId); // invoke the operation - SecurityRuleResource result = await securityRule.GetAsync(); + await securityRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SecurityRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,7 +96,7 @@ public async Task Update_CreateSecurityRule() SecurityRuleResource securityRule = client.GetSecurityRuleResource(securityRuleResourceId); // invoke the operation - SecurityRuleData data = new SecurityRuleData() + SecurityRuleData data = new SecurityRuleData { Protocol = SecurityRuleProtocol.Asterisk, SourcePortRange = "*", diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyCollection.cs index e13862e5abb25..b563eb2bcc707 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_ServiceEndpointPolicyCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServiceEndPointPolicy() + public async Task CreateOrUpdate_CreateServiceEndpointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyGet.json - // this example is just showing the usage of "ServiceEndpointPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyCreate.json + // this example is just showing the usage of "ServiceEndpointPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,13 @@ public async Task Get_GetServiceEndPointPolicy() ServiceEndpointPolicyCollection collection = resourceGroupResource.GetServiceEndpointPolicies(); // invoke the operation - string serviceEndpointPolicyName = "testServiceEndpointPolicy"; - ServiceEndpointPolicyResource result = await collection.GetAsync(serviceEndpointPolicyName); + string serviceEndpointPolicyName = "testPolicy"; + ServiceEndpointPolicyData data = new ServiceEndpointPolicyData + { + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceEndpointPolicyName, data); + ServiceEndpointPolicyResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +56,10 @@ public async Task Get_GetServiceEndPointPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetServiceEndPointPolicy() + public async Task CreateOrUpdate_CreateServiceEndpointPolicyWithDefinition() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyGet.json - // this example is just showing the usage of "ServiceEndpointPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyCreateWithDefinition.json + // this example is just showing the usage of "ServiceEndpointPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,15 +77,31 @@ public async Task Exists_GetServiceEndPointPolicy() ServiceEndpointPolicyCollection collection = resourceGroupResource.GetServiceEndpointPolicies(); // invoke the operation - string serviceEndpointPolicyName = "testServiceEndpointPolicy"; - bool result = await collection.ExistsAsync(serviceEndpointPolicyName); + string serviceEndpointPolicyName = "testPolicy"; + ServiceEndpointPolicyData data = new ServiceEndpointPolicyData + { + ServiceEndpointPolicyDefinitions = {new ServiceEndpointPolicyDefinitionData +{ +Description = "Storage Service EndpointPolicy Definition", +Service = "Microsoft.Storage", +ServiceResources = {new ResourceIdentifier("/subscriptions/subid1"), new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg"), new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg/providers/Microsoft.Storage/storageAccounts/stAccount")}, +Name = "StorageServiceEndpointPolicyDefinition", +}}, + Location = new AzureLocation("westus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceEndpointPolicyName, data); + ServiceEndpointPolicyResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceEndpointPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetServiceEndPointPolicy() + public async Task Get_GetServiceEndPointPolicy() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyGet.json // this example is just showing the usage of "ServiceEndpointPolicies_Get" operation, for the dependent resources, they will have to be created separately. @@ -102,29 +123,21 @@ public async Task GetIfExists_GetServiceEndPointPolicy() // invoke the operation string serviceEndpointPolicyName = "testServiceEndpointPolicy"; - NullableResponse response = await collection.GetIfExistsAsync(serviceEndpointPolicyName); - ServiceEndpointPolicyResource result = response.HasValue ? response.Value : null; + ServiceEndpointPolicyResource result = await collection.GetAsync(serviceEndpointPolicyName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceEndpointPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceEndpointPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateServiceEndpointPolicy() + public async Task GetAll_ListResourceGroupServiceEndpointPolicies() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyCreate.json - // this example is just showing the usage of "ServiceEndpointPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyList.json + // this example is just showing the usage of "ServiceEndpointPolicies_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -141,28 +154,25 @@ public async Task CreateOrUpdate_CreateServiceEndpointPolicy() // get the collection of this ServiceEndpointPolicyResource ServiceEndpointPolicyCollection collection = resourceGroupResource.GetServiceEndpointPolicies(); - // invoke the operation - string serviceEndpointPolicyName = "testPolicy"; - ServiceEndpointPolicyData data = new ServiceEndpointPolicyData() + // invoke the operation and iterate over the result + await foreach (ServiceEndpointPolicyResource item in collection.GetAllAsync()) { - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceEndpointPolicyName, data); - ServiceEndpointPolicyResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceEndpointPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceEndpointPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateServiceEndpointPolicyWithDefinition() + public async Task Exists_GetServiceEndPointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyCreateWithDefinition.json - // this example is just showing the usage of "ServiceEndpointPolicies_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyGet.json + // this example is just showing the usage of "ServiceEndpointPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -180,40 +190,18 @@ public async Task CreateOrUpdate_CreateServiceEndpointPolicyWithDefinition() ServiceEndpointPolicyCollection collection = resourceGroupResource.GetServiceEndpointPolicies(); // invoke the operation - string serviceEndpointPolicyName = "testPolicy"; - ServiceEndpointPolicyData data = new ServiceEndpointPolicyData() - { - ServiceEndpointPolicyDefinitions = -{ -new ServiceEndpointPolicyDefinitionData() -{ -Description = "Storage Service EndpointPolicy Definition", -Service = "Microsoft.Storage", -ServiceResources = -{ -new ResourceIdentifier("/subscriptions/subid1"),new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg"),new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg/providers/Microsoft.Storage/storageAccounts/stAccount") -}, -Name = "StorageServiceEndpointPolicyDefinition", -} -}, - Location = new AzureLocation("westus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceEndpointPolicyName, data); - ServiceEndpointPolicyResource result = lro.Value; + string serviceEndpointPolicyName = "testServiceEndpointPolicy"; + bool result = await collection.ExistsAsync(serviceEndpointPolicyName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceEndpointPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListResourceGroupServiceEndpointPolicies() + public async Task GetIfExists_GetServiceEndPointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyList.json - // this example is just showing the usage of "ServiceEndpointPolicies_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyGet.json + // this example is just showing the usage of "ServiceEndpointPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -230,17 +218,23 @@ public async Task GetAll_ListResourceGroupServiceEndpointPolicies() // get the collection of this ServiceEndpointPolicyResource ServiceEndpointPolicyCollection collection = resourceGroupResource.GetServiceEndpointPolicies(); - // invoke the operation and iterate over the result - await foreach (ServiceEndpointPolicyResource item in collection.GetAllAsync()) + // invoke the operation + string serviceEndpointPolicyName = "testServiceEndpointPolicy"; + NullableResponse response = await collection.GetIfExistsAsync(serviceEndpointPolicyName); + ServiceEndpointPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceEndpointPolicyData resourceData = item.Data; + ServiceEndpointPolicyData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyDefinitionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyDefinitionCollection.cs index 0feb943b5df56..5ae649e741eac 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyDefinitionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyDefinitionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceEndpointPolicyDefinitionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServiceEndpointDefinitionInServiceEndpointPolicy() + public async Task CreateOrUpdate_CreateServiceEndpointPolicyDefinition() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionGet.json - // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionCreate.json + // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,14 @@ public async Task Get_GetServiceEndpointDefinitionInServiceEndpointPolicy() // invoke the operation string serviceEndpointPolicyDefinitionName = "testDefinition"; - ServiceEndpointPolicyDefinitionResource result = await collection.GetAsync(serviceEndpointPolicyDefinitionName); + ServiceEndpointPolicyDefinitionData data = new ServiceEndpointPolicyDefinitionData + { + Description = "Storage Service EndpointPolicy Definition", + Service = "Microsoft.Storage", + ServiceResources = { new ResourceIdentifier("/subscriptions/subid1"), new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg"), new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg/providers/Microsoft.Storage/storageAccounts/stAccount") }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceEndpointPolicyDefinitionName, data); + ServiceEndpointPolicyDefinitionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +58,7 @@ public async Task Get_GetServiceEndpointDefinitionInServiceEndpointPolicy() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetServiceEndpointDefinitionInServiceEndpointPolicy() + public async Task Get_GetServiceEndpointDefinitionInServiceEndpointPolicy() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionGet.json // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +81,21 @@ public async Task Exists_GetServiceEndpointDefinitionInServiceEndpointPolicy() // invoke the operation string serviceEndpointPolicyDefinitionName = "testDefinition"; - bool result = await collection.ExistsAsync(serviceEndpointPolicyDefinitionName); + ServiceEndpointPolicyDefinitionResource result = await collection.GetAsync(serviceEndpointPolicyDefinitionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceEndpointPolicyDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetServiceEndpointDefinitionInServiceEndpointPolicy() + public async Task GetAll_ListServiceEndpointDefinitionsInServiceEndPointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionGet.json - // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionList.json + // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +113,25 @@ public async Task GetIfExists_GetServiceEndpointDefinitionInServiceEndpointPolic // get the collection of this ServiceEndpointPolicyDefinitionResource ServiceEndpointPolicyDefinitionCollection collection = serviceEndpointPolicy.GetServiceEndpointPolicyDefinitions(); - // invoke the operation - string serviceEndpointPolicyDefinitionName = "testDefinition"; - NullableResponse response = await collection.GetIfExistsAsync(serviceEndpointPolicyDefinitionName); - ServiceEndpointPolicyDefinitionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (ServiceEndpointPolicyDefinitionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceEndpointPolicyDefinitionData resourceData = result.Data; + ServiceEndpointPolicyDefinitionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateServiceEndpointPolicyDefinition() + public async Task Exists_GetServiceEndpointDefinitionInServiceEndpointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionCreate.json - // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionGet.json + // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,31 +151,17 @@ public async Task CreateOrUpdate_CreateServiceEndpointPolicyDefinition() // invoke the operation string serviceEndpointPolicyDefinitionName = "testDefinition"; - ServiceEndpointPolicyDefinitionData data = new ServiceEndpointPolicyDefinitionData() - { - Description = "Storage Service EndpointPolicy Definition", - Service = "Microsoft.Storage", - ServiceResources = -{ -new ResourceIdentifier("/subscriptions/subid1"),new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg"),new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg/providers/Microsoft.Storage/storageAccounts/stAccount") -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, serviceEndpointPolicyDefinitionName, data); - ServiceEndpointPolicyDefinitionResource result = lro.Value; + bool result = await collection.ExistsAsync(serviceEndpointPolicyDefinitionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceEndpointPolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListServiceEndpointDefinitionsInServiceEndPointPolicy() + public async Task GetIfExists_GetServiceEndpointDefinitionInServiceEndpointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionList.json - // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionGet.json + // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,17 +179,23 @@ public async Task GetAll_ListServiceEndpointDefinitionsInServiceEndPointPolicy() // get the collection of this ServiceEndpointPolicyDefinitionResource ServiceEndpointPolicyDefinitionCollection collection = serviceEndpointPolicy.GetServiceEndpointPolicyDefinitions(); - // invoke the operation and iterate over the result - await foreach (ServiceEndpointPolicyDefinitionResource item in collection.GetAllAsync()) + // invoke the operation + string serviceEndpointPolicyDefinitionName = "testDefinition"; + NullableResponse response = await collection.GetIfExistsAsync(serviceEndpointPolicyDefinitionName); + ServiceEndpointPolicyDefinitionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - ServiceEndpointPolicyDefinitionData resourceData = item.Data; + ServiceEndpointPolicyDefinitionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyDefinitionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyDefinitionResource.cs index 8480c3b2b5a7c..5659159c6a0a4 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyDefinitionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyDefinitionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_ServiceEndpointPolicyDefinitionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteServiceEndpointPolicyDefinitionsFromServiceEndpointPolicy() + public async Task Get_GetServiceEndpointDefinitionInServiceEndpointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionDelete.json - // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionGet.json + // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task Delete_DeleteServiceEndpointPolicyDefinitionsFromServiceEndpoi ServiceEndpointPolicyDefinitionResource serviceEndpointPolicyDefinition = client.GetServiceEndpointPolicyDefinitionResource(serviceEndpointPolicyDefinitionResourceId); // invoke the operation - await serviceEndpointPolicyDefinition.DeleteAsync(WaitUntil.Completed); + ServiceEndpointPolicyDefinitionResource result = await serviceEndpointPolicyDefinition.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceEndpointPolicyDefinitionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServiceEndpointDefinitionInServiceEndpointPolicy() + public async Task Delete_DeleteServiceEndpointPolicyDefinitionsFromServiceEndpointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionGet.json - // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDefinitionDelete.json + // this example is just showing the usage of "ServiceEndpointPolicyDefinitions_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +68,9 @@ public async Task Get_GetServiceEndpointDefinitionInServiceEndpointPolicy() ServiceEndpointPolicyDefinitionResource serviceEndpointPolicyDefinition = client.GetServiceEndpointPolicyDefinitionResource(serviceEndpointPolicyDefinitionResourceId); // invoke the operation - ServiceEndpointPolicyDefinitionResource result = await serviceEndpointPolicyDefinition.GetAsync(); + await serviceEndpointPolicyDefinition.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceEndpointPolicyDefinitionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -95,14 +95,11 @@ public async Task Update_CreateServiceEndpointPolicyDefinition() ServiceEndpointPolicyDefinitionResource serviceEndpointPolicyDefinition = client.GetServiceEndpointPolicyDefinitionResource(serviceEndpointPolicyDefinitionResourceId); // invoke the operation - ServiceEndpointPolicyDefinitionData data = new ServiceEndpointPolicyDefinitionData() + ServiceEndpointPolicyDefinitionData data = new ServiceEndpointPolicyDefinitionData { Description = "Storage Service EndpointPolicy Definition", Service = "Microsoft.Storage", - ServiceResources = -{ -new ResourceIdentifier("/subscriptions/subid1"),new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg"),new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg/providers/Microsoft.Storage/storageAccounts/stAccount") -}, + ServiceResources = { new ResourceIdentifier("/subscriptions/subid1"), new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg"), new ResourceIdentifier("/subscriptions/subid1/resourceGroups/storageRg/providers/Microsoft.Storage/storageAccounts/stAccount") }, }; ArmOperation lro = await serviceEndpointPolicyDefinition.UpdateAsync(WaitUntil.Completed, data); ServiceEndpointPolicyDefinitionResource result = lro.Value; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyResource.cs index 86f86237a5c6c..4a5ed70cefbdd 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_ServiceEndpointPolicyResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_ServiceEndpointPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteServiceEndpointPolicy() + public async Task Get_GetServiceEndPointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDelete.json - // this example is just showing the usage of "ServiceEndpointPolicies_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyGet.json + // this example is just showing the usage of "ServiceEndpointPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +32,26 @@ public async Task Delete_DeleteServiceEndpointPolicy() // for more information of creating ServiceEndpointPolicyResource, please refer to the document of ServiceEndpointPolicyResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string serviceEndpointPolicyName = "serviceEndpointPolicy1"; + string serviceEndpointPolicyName = "testServiceEndpointPolicy"; ResourceIdentifier serviceEndpointPolicyResourceId = ServiceEndpointPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceEndpointPolicyName); ServiceEndpointPolicyResource serviceEndpointPolicy = client.GetServiceEndpointPolicyResource(serviceEndpointPolicyResourceId); // invoke the operation - await serviceEndpointPolicy.DeleteAsync(WaitUntil.Completed); + ServiceEndpointPolicyResource result = await serviceEndpointPolicy.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceEndpointPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetServiceEndPointPolicy() + public async Task Delete_DeleteServiceEndpointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyGet.json - // this example is just showing the usage of "ServiceEndpointPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyDelete.json + // this example is just showing the usage of "ServiceEndpointPolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,18 +62,14 @@ public async Task Get_GetServiceEndPointPolicy() // for more information of creating ServiceEndpointPolicyResource, please refer to the document of ServiceEndpointPolicyResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string serviceEndpointPolicyName = "testServiceEndpointPolicy"; + string serviceEndpointPolicyName = "serviceEndpointPolicy1"; ResourceIdentifier serviceEndpointPolicyResourceId = ServiceEndpointPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, serviceEndpointPolicyName); ServiceEndpointPolicyResource serviceEndpointPolicy = client.GetServiceEndpointPolicyResource(serviceEndpointPolicyResourceId); // invoke the operation - ServiceEndpointPolicyResource result = await serviceEndpointPolicy.GetAsync(); + await serviceEndpointPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceEndpointPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateServiceEndpointPolicyTags() ServiceEndpointPolicyResource serviceEndpointPolicy = client.GetServiceEndpointPolicyResource(serviceEndpointPolicyResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ServiceEndpointPolicyResource result = await serviceEndpointPolicy.UpdateAsync(networkTagsObject); @@ -110,36 +109,5 @@ public async Task Update_UpdateServiceEndpointPolicyTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetServiceEndpointPoliciesByServiceEndpointPolicy_ListAllServiceEndpointPolicy() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyListAll.json - // this example is just showing the usage of "ServiceEndpointPolicies_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (ServiceEndpointPolicyResource item in subscriptionResource.GetServiceEndpointPoliciesByServiceEndpointPolicyAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - ServiceEndpointPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubnetCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubnetCollection.cs index 1578f751b12b3..fa9eadf0ff345 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubnetCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubnetCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_SubnetCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSubnet() + public async Task CreateOrUpdate_CreateSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGet.json - // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetCreate.json + // this example is just showing the usage of "Subnets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,12 @@ public async Task Get_GetSubnet() // invoke the operation string subnetName = "subnet1"; - SubnetResource result = await collection.GetAsync(subnetName); + SubnetData data = new SubnetData + { + AddressPrefix = "10.0.0.0/16", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, data); + SubnetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +57,10 @@ public async Task Get_GetSubnet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSubnet() + public async Task CreateOrUpdate_CreateSubnetWithADelegation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGet.json - // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetCreateWithDelegation.json + // this example is just showing the usage of "Subnets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,7 +69,7 @@ public async Task Exists_GetSubnet() // this example assumes you already have this VirtualNetworkResource created on azure // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource - string subscriptionId = "subid"; + string subscriptionId = "subId"; string resourceGroupName = "subnet-test"; string virtualNetworkName = "vnetname"; ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); @@ -75,17 +80,26 @@ public async Task Exists_GetSubnet() // invoke the operation string subnetName = "subnet1"; - bool result = await collection.ExistsAsync(subnetName); + SubnetData data = new SubnetData + { + AddressPrefix = "10.0.0.0/16", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, data); + SubnetResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubnetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSubnet() + public async Task CreateOrUpdate_CreateSubnetWithServiceEndpoints() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGet.json - // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetCreateServiceEndpoint.json + // this example is just showing the usage of "Subnets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,29 +119,30 @@ public async Task GetIfExists_GetSubnet() // invoke the operation string subnetName = "subnet1"; - NullableResponse response = await collection.GetIfExistsAsync(subnetName); - SubnetResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + SubnetData data = new SubnetData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubnetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AddressPrefix = "10.0.0.0/16", + ServiceEndpoints = {new ServiceEndpointProperties +{ +Service = "Microsoft.Storage", +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, data); + SubnetResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubnetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSubnetWithADelegation() + public async Task CreateOrUpdate_CreateSubnetWithServiceEndpointsWithNetworkIdentifier() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithDelegation.json - // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetCreateServiceEndpointNetworkIdentifier.json + // this example is just showing the usage of "Subnets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,7 +151,7 @@ public async Task Get_GetSubnetWithADelegation() // this example assumes you already have this VirtualNetworkResource created on azure // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; string resourceGroupName = "subnet-test"; string virtualNetworkName = "vnetname"; ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); @@ -147,7 +162,17 @@ public async Task Get_GetSubnetWithADelegation() // invoke the operation string subnetName = "subnet1"; - SubnetResource result = await collection.GetAsync(subnetName); + SubnetData data = new SubnetData + { + AddressPrefix = "10.0.0.0/16", + ServiceEndpoints = {new ServiceEndpointProperties +{ +Service = "Microsoft.Storage", +NetworkIdentifierId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/subnet-test/providers/Microsoft.Network/publicIPAddresses/test-ip"), +}}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, data); + SubnetResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -158,10 +183,10 @@ public async Task Get_GetSubnetWithADelegation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSubnetWithADelegation() + public async Task CreateOrUpdate_CreateSubnetWithSharingScope() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithDelegation.json - // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetCreateWithSharingScope.json + // this example is just showing the usage of "Subnets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -170,7 +195,7 @@ public async Task Exists_GetSubnetWithADelegation() // this example assumes you already have this VirtualNetworkResource created on azure // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; string resourceGroupName = "subnet-test"; string virtualNetworkName = "vnetname"; ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); @@ -181,16 +206,25 @@ public async Task Exists_GetSubnetWithADelegation() // invoke the operation string subnetName = "subnet1"; - bool result = await collection.ExistsAsync(subnetName); + SubnetData data = new SubnetData + { + AddressPrefix = "10.0.0.0/16", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, data); + SubnetResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubnetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSubnetWithADelegation() + public async Task Get_GetSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithDelegation.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGet.json // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -200,7 +234,7 @@ public async Task GetIfExists_GetSubnetWithADelegation() // this example assumes you already have this VirtualNetworkResource created on azure // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; string resourceGroupName = "subnet-test"; string virtualNetworkName = "vnetname"; ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); @@ -211,28 +245,20 @@ public async Task GetIfExists_GetSubnetWithADelegation() // invoke the operation string subnetName = "subnet1"; - NullableResponse response = await collection.GetIfExistsAsync(subnetName); - SubnetResource result = response.HasValue ? response.Value : null; + SubnetResource result = await collection.GetAsync(subnetName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubnetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubnetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSubnetWithSharingScope() + public async Task Get_GetSubnetWithADelegation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithSharingScope.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithDelegation.json // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -242,7 +268,7 @@ public async Task Get_GetSubnetWithSharingScope() // this example assumes you already have this VirtualNetworkResource created on azure // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource - string subscriptionId = "subid"; + string subscriptionId = "subId"; string resourceGroupName = "subnet-test"; string virtualNetworkName = "vnetname"; ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); @@ -264,7 +290,7 @@ public async Task Get_GetSubnetWithSharingScope() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSubnetWithSharingScope() + public async Task Get_GetSubnetWithSharingScope() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithSharingScope.json // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. @@ -287,17 +313,21 @@ public async Task Exists_GetSubnetWithSharingScope() // invoke the operation string subnetName = "subnet1"; - bool result = await collection.ExistsAsync(subnetName); + SubnetResource result = await collection.GetAsync(subnetName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubnetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSubnetWithSharingScope() + public async Task GetAll_ListSubnets() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithSharingScope.json - // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetList.json + // this example is just showing the usage of "Subnets_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -315,31 +345,25 @@ public async Task GetIfExists_GetSubnetWithSharingScope() // get the collection of this SubnetResource SubnetCollection collection = virtualNetwork.GetSubnets(); - // invoke the operation - string subnetName = "subnet1"; - NullableResponse response = await collection.GetIfExistsAsync(subnetName); - SubnetResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (SubnetResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SubnetData resourceData = result.Data; + SubnetData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSubnet() + public async Task Exists_GetSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetCreate.json - // this example is just showing the usage of "Subnets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGet.json + // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -359,26 +383,17 @@ public async Task CreateOrUpdate_CreateSubnet() // invoke the operation string subnetName = "subnet1"; - SubnetData data = new SubnetData() - { - AddressPrefix = "10.0.0.0/16", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, data); - SubnetResource result = lro.Value; + bool result = await collection.ExistsAsync(subnetName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubnetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSubnetWithADelegation() + public async Task Exists_GetSubnetWithADelegation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetCreateWithDelegation.json - // this example is just showing the usage of "Subnets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithDelegation.json + // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -398,26 +413,17 @@ public async Task CreateOrUpdate_CreateSubnetWithADelegation() // invoke the operation string subnetName = "subnet1"; - SubnetData data = new SubnetData() - { - AddressPrefix = "10.0.0.0/16", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, data); - SubnetResource result = lro.Value; + bool result = await collection.ExistsAsync(subnetName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubnetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSubnetWithServiceEndpoints() + public async Task Exists_GetSubnetWithSharingScope() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetCreateServiceEndpoint.json - // this example is just showing the usage of "Subnets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithSharingScope.json + // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -437,33 +443,17 @@ public async Task CreateOrUpdate_CreateSubnetWithServiceEndpoints() // invoke the operation string subnetName = "subnet1"; - SubnetData data = new SubnetData() - { - AddressPrefix = "10.0.0.0/16", - ServiceEndpoints = -{ -new ServiceEndpointProperties() -{ -Service = "Microsoft.Storage", -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, data); - SubnetResource result = lro.Value; + bool result = await collection.ExistsAsync(subnetName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubnetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSubnetWithServiceEndpointsWithNetworkIdentifier() + public async Task GetIfExists_GetSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetCreateServiceEndpointNetworkIdentifier.json - // this example is just showing the usage of "Subnets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGet.json + // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -483,34 +473,29 @@ public async Task CreateOrUpdate_CreateSubnetWithServiceEndpointsWithNetworkIden // invoke the operation string subnetName = "subnet1"; - SubnetData data = new SubnetData() - { - AddressPrefix = "10.0.0.0/16", - ServiceEndpoints = -{ -new ServiceEndpointProperties() -{ -Service = "Microsoft.Storage", -NetworkIdentifierId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/subnet-test/providers/Microsoft.Network/publicIPAddresses/test-ip"), -} -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, data); - SubnetResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(subnetName); + SubnetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubnetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubnetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSubnetWithSharingScope() + public async Task GetIfExists_GetSubnetWithADelegation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetCreateWithSharingScope.json - // this example is just showing the usage of "Subnets_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithDelegation.json + // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -519,7 +504,7 @@ public async Task CreateOrUpdate_CreateSubnetWithSharingScope() // this example assumes you already have this VirtualNetworkResource created on azure // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource - string subscriptionId = "subid"; + string subscriptionId = "subId"; string resourceGroupName = "subnet-test"; string virtualNetworkName = "vnetname"; ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); @@ -530,26 +515,29 @@ public async Task CreateOrUpdate_CreateSubnetWithSharingScope() // invoke the operation string subnetName = "subnet1"; - SubnetData data = new SubnetData() - { - AddressPrefix = "10.0.0.0/16", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, subnetName, data); - SubnetResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(subnetName); + SubnetResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubnetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubnetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSubnets() + public async Task GetIfExists_GetSubnetWithSharingScope() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetList.json - // this example is just showing the usage of "Subnets_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithSharingScope.json + // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -567,17 +555,23 @@ public async Task GetAll_ListSubnets() // get the collection of this SubnetResource SubnetCollection collection = virtualNetwork.GetSubnets(); - // invoke the operation and iterate over the result - await foreach (SubnetResource item in collection.GetAllAsync()) + // invoke the operation + string subnetName = "subnet1"; + NullableResponse response = await collection.GetIfExistsAsync(subnetName); + SubnetResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - SubnetData resourceData = item.Data; + SubnetData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubnetResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubnetResource.cs index f8a0b4ddbe60f..93f7ad2e60e31 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubnetResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubnetResource.cs @@ -18,10 +18,10 @@ public partial class Sample_SubnetResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSubnet() + public async Task Get_GetSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetDelete.json - // this example is just showing the usage of "Subnets_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGet.json + // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,20 @@ public async Task Delete_DeleteSubnet() SubnetResource subnet = client.GetSubnetResource(subnetResourceId); // invoke the operation - await subnet.DeleteAsync(WaitUntil.Completed); + SubnetResource result = await subnet.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SubnetData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSubnet() + public async Task Get_GetSubnetWithADelegation() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithDelegation.json // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -57,7 +61,7 @@ public async Task Get_GetSubnet() // this example assumes you already have this SubnetResource created on azure // for more information of creating SubnetResource, please refer to the document of SubnetResource - string subscriptionId = "subid"; + string subscriptionId = "subId"; string resourceGroupName = "subnet-test"; string virtualNetworkName = "vnetname"; string subnetName = "subnet1"; @@ -76,9 +80,9 @@ public async Task Get_GetSubnet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSubnetWithADelegation() + public async Task Get_GetSubnetWithSharingScope() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithDelegation.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithSharingScope.json // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -88,7 +92,7 @@ public async Task Get_GetSubnetWithADelegation() // this example assumes you already have this SubnetResource created on azure // for more information of creating SubnetResource, please refer to the document of SubnetResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; string resourceGroupName = "subnet-test"; string virtualNetworkName = "vnetname"; string subnetName = "subnet1"; @@ -107,10 +111,10 @@ public async Task Get_GetSubnetWithADelegation() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSubnetWithSharingScope() + public async Task Delete_DeleteSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetGetWithSharingScope.json - // this example is just showing the usage of "Subnets_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SubnetDelete.json + // this example is just showing the usage of "Subnets_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,13 +131,9 @@ public async Task Get_GetSubnetWithSharingScope() SubnetResource subnet = client.GetSubnetResource(subnetResourceId); // invoke the operation - SubnetResource result = await subnet.GetAsync(); + await subnet.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - SubnetData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -158,7 +158,7 @@ public async Task Update_CreateSubnet() SubnetResource subnet = client.GetSubnetResource(subnetResourceId); // invoke the operation - SubnetData data = new SubnetData() + SubnetData data = new SubnetData { AddressPrefix = "10.0.0.0/16", }; @@ -194,7 +194,7 @@ public async Task Update_CreateSubnetWithADelegation() SubnetResource subnet = client.GetSubnetResource(subnetResourceId); // invoke the operation - SubnetData data = new SubnetData() + SubnetData data = new SubnetData { AddressPrefix = "10.0.0.0/16", }; @@ -230,16 +230,13 @@ public async Task Update_CreateSubnetWithServiceEndpoints() SubnetResource subnet = client.GetSubnetResource(subnetResourceId); // invoke the operation - SubnetData data = new SubnetData() + SubnetData data = new SubnetData { AddressPrefix = "10.0.0.0/16", - ServiceEndpoints = -{ -new ServiceEndpointProperties() + ServiceEndpoints = {new ServiceEndpointProperties { Service = "Microsoft.Storage", -} -}, +}}, }; ArmOperation lro = await subnet.UpdateAsync(WaitUntil.Completed, data); SubnetResource result = lro.Value; @@ -273,17 +270,14 @@ public async Task Update_CreateSubnetWithServiceEndpointsWithNetworkIdentifier() SubnetResource subnet = client.GetSubnetResource(subnetResourceId); // invoke the operation - SubnetData data = new SubnetData() + SubnetData data = new SubnetData { AddressPrefix = "10.0.0.0/16", - ServiceEndpoints = -{ -new ServiceEndpointProperties() + ServiceEndpoints = {new ServiceEndpointProperties { Service = "Microsoft.Storage", NetworkIdentifierId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/subnet-test/providers/Microsoft.Network/publicIPAddresses/test-ip"), -} -}, +}}, }; ArmOperation lro = await subnet.UpdateAsync(WaitUntil.Completed, data); SubnetResource result = lro.Value; @@ -317,7 +311,7 @@ public async Task Update_CreateSubnetWithSharingScope() SubnetResource subnet = client.GetSubnetResource(subnetResourceId); // invoke the operation - SubnetData data = new SubnetData() + SubnetData data = new SubnetData { AddressPrefix = "10.0.0.0/16", }; @@ -353,7 +347,7 @@ public async Task PrepareNetworkPolicies_PrepareNetworkPolicies() SubnetResource subnet = client.GetSubnetResource(subnetResourceId); // invoke the operation - PrepareNetworkPoliciesContent content = new PrepareNetworkPoliciesContent() + PrepareNetworkPoliciesContent content = new PrepareNetworkPoliciesContent { ServiceName = "Microsoft.Sql/managedInstances", }; @@ -384,7 +378,7 @@ public async Task UnprepareNetworkPolicies_UnprepareNetworkPolicies() SubnetResource subnet = client.GetSubnetResource(subnetResourceId); // invoke the operation - UnprepareNetworkPoliciesContent content = new UnprepareNetworkPoliciesContent() + UnprepareNetworkPoliciesContent content = new UnprepareNetworkPoliciesContent { ServiceName = "Microsoft.Sql/managedInstances", }; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionNetworkManagerConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionNetworkManagerConnectionCollection.cs index f7a763fc070db..949389bcc6d21 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionNetworkManagerConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionNetworkManagerConnectionCollection.cs @@ -39,7 +39,7 @@ public async Task CreateOrUpdate_CreateOrUpdateSubscriptionNetworkManagerConnect // invoke the operation string networkManagerConnectionName = "TestNMConnection"; - NetworkManagerConnectionData data = new NetworkManagerConnectionData() + NetworkManagerConnectionData data = new NetworkManagerConnectionData { NetworkManagerId = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroup/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager"), }; @@ -87,10 +87,10 @@ public async Task Get_GetSubscriptionNetworkManagerConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSubscriptionNetworkManagerConnection() + public async Task GetAll_ListSubscriptionNetworkManagerConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionGet.json - // this example is just showing the usage of "SubscriptionNetworkManagerConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionList.json + // this example is just showing the usage of "SubscriptionNetworkManagerConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,16 +106,22 @@ public async Task Exists_GetSubscriptionNetworkManagerConnection() // get the collection of this SubscriptionNetworkManagerConnectionResource SubscriptionNetworkManagerConnectionCollection collection = subscriptionResource.GetSubscriptionNetworkManagerConnections(); - // invoke the operation - string networkManagerConnectionName = "TestNMConnection"; - bool result = await collection.ExistsAsync(networkManagerConnectionName); + // invoke the operation and iterate over the result + await foreach (SubscriptionNetworkManagerConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSubscriptionNetworkManagerConnection() + public async Task Exists_GetSubscriptionNetworkManagerConnection() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionGet.json // this example is just showing the usage of "SubscriptionNetworkManagerConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -136,29 +142,17 @@ public async Task GetIfExists_GetSubscriptionNetworkManagerConnection() // invoke the operation string networkManagerConnectionName = "TestNMConnection"; - NullableResponse response = await collection.GetIfExistsAsync(networkManagerConnectionName); - SubscriptionNetworkManagerConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(networkManagerConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListSubscriptionNetworkManagerConnection() + public async Task GetIfExists_GetSubscriptionNetworkManagerConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionList.json - // this example is just showing the usage of "SubscriptionNetworkManagerConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionGet.json + // this example is just showing the usage of "SubscriptionNetworkManagerConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,17 +168,23 @@ public async Task GetAll_ListSubscriptionNetworkManagerConnection() // get the collection of this SubscriptionNetworkManagerConnectionResource SubscriptionNetworkManagerConnectionCollection collection = subscriptionResource.GetSubscriptionNetworkManagerConnections(); - // invoke the operation and iterate over the result - await foreach (SubscriptionNetworkManagerConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string networkManagerConnectionName = "TestNMConnection"; + NullableResponse response = await collection.GetIfExistsAsync(networkManagerConnectionName); + SubscriptionNetworkManagerConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - NetworkManagerConnectionData resourceData = item.Data; + NetworkManagerConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionNetworkManagerConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionNetworkManagerConnectionResource.cs index d9e885396a052..f1c0f0c5cfde7 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionNetworkManagerConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionNetworkManagerConnectionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_SubscriptionNetworkManagerConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_CreateOrUpdateSubscriptionNetworkManagerConnection() + public async Task Get_GetSubscriptionNetworkManagerConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionPut.json - // this example is just showing the usage of "SubscriptionNetworkManagerConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionGet.json + // this example is just showing the usage of "SubscriptionNetworkManagerConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -35,12 +35,7 @@ public async Task Update_CreateOrUpdateSubscriptionNetworkManagerConnection() SubscriptionNetworkManagerConnectionResource subscriptionNetworkManagerConnection = client.GetSubscriptionNetworkManagerConnectionResource(subscriptionNetworkManagerConnectionResourceId); // invoke the operation - NetworkManagerConnectionData data = new NetworkManagerConnectionData() - { - NetworkManagerId = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroup/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager"), - }; - ArmOperation lro = await subscriptionNetworkManagerConnection.UpdateAsync(WaitUntil.Completed, data); - SubscriptionNetworkManagerConnectionResource result = lro.Value; + SubscriptionNetworkManagerConnectionResource result = await subscriptionNetworkManagerConnection.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,10 +46,10 @@ public async Task Update_CreateOrUpdateSubscriptionNetworkManagerConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSubscriptionNetworkManagerConnection() + public async Task Delete_DeleteSubscriptionNetworkManagerConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionGet.json - // this example is just showing the usage of "SubscriptionNetworkManagerConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionDelete.json + // this example is just showing the usage of "SubscriptionNetworkManagerConnections_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,21 +64,17 @@ public async Task Get_GetSubscriptionNetworkManagerConnection() SubscriptionNetworkManagerConnectionResource subscriptionNetworkManagerConnection = client.GetSubscriptionNetworkManagerConnectionResource(subscriptionNetworkManagerConnectionResourceId); // invoke the operation - SubscriptionNetworkManagerConnectionResource result = await subscriptionNetworkManagerConnection.GetAsync(); + await subscriptionNetworkManagerConnection.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - NetworkManagerConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteSubscriptionNetworkManagerConnection() + public async Task Update_CreateOrUpdateSubscriptionNetworkManagerConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionDelete.json - // this example is just showing the usage of "SubscriptionNetworkManagerConnections_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerConnectionSubscriptionPut.json + // this example is just showing the usage of "SubscriptionNetworkManagerConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -98,9 +89,18 @@ public async Task Delete_DeleteSubscriptionNetworkManagerConnection() SubscriptionNetworkManagerConnectionResource subscriptionNetworkManagerConnection = client.GetSubscriptionNetworkManagerConnectionResource(subscriptionNetworkManagerConnectionResourceId); // invoke the operation - await subscriptionNetworkManagerConnection.DeleteAsync(WaitUntil.Completed); + NetworkManagerConnectionData data = new NetworkManagerConnectionData + { + NetworkManagerId = new ResourceIdentifier("/subscriptions/subscriptionC/resourceGroup/rg1/providers/Microsoft.Network/networkManagers/testNetworkManager"), + }; + ArmOperation lro = await subscriptionNetworkManagerConnection.UpdateAsync(WaitUntil.Completed, data); + SubscriptionNetworkManagerConnectionResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs index f8f02644b4edc..135d6e9ea3272 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_SubscriptionResourceExtensions.cs @@ -19,10 +19,10 @@ public partial class Sample_SubscriptionResourceExtensions { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAvailableDelegations_GetAvailableDelegations() + public async Task GetApplicationGateways_ListsAllApplicationGatewaysInASubscription() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AvailableDelegationsSubscriptionGet.json - // this example is just showing the usage of "AvailableDelegations_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayListAll.json + // this example is just showing the usage of "ApplicationGateways_ListAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -31,13 +31,43 @@ public async Task GetAvailableDelegations_GetAvailableDelegations() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("westcentralus"); - await foreach (AvailableDelegation item in subscriptionResource.GetAvailableDelegationsAsync(location)) + await foreach (ApplicationGatewayResource item in subscriptionResource.GetApplicationGatewaysAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAvailableServerVariablesApplicationGateways_GetAvailableServerVariables() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableServerVariablesGet.json + // this example is just showing the usage of "ApplicationGateways_ListAvailableServerVariables" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "72f988bf-86f1-41af-91ab-2d7cd0dddd4"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (string item in subscriptionResource.GetAvailableServerVariablesApplicationGatewaysAsync()) { Console.WriteLine($"Succeeded: {item}"); } @@ -47,10 +77,10 @@ public async Task GetAvailableDelegations_GetAvailableDelegations() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAvailableServiceAliases_GetAvailableServiceAliases() + public async Task GetAvailableRequestHeadersApplicationGateways_GetAvailableRequestHeaders() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AvailableServiceAliasesList.json - // this example is just showing the usage of "AvailableServiceAliases_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableRequestHeadersGet.json + // this example is just showing the usage of "ApplicationGateways_ListAvailableRequestHeaders" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,13 +89,12 @@ public async Task GetAvailableServiceAliases_GetAvailableServiceAliases() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subId"; + string subscriptionId = "72f988bf-86f1-41af-91ab-2d7cd0dddd4"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("westcentralus"); - await foreach (AvailableServiceAlias item in subscriptionResource.GetAvailableServiceAliasesAsync(location)) + await foreach (string item in subscriptionResource.GetAvailableRequestHeadersApplicationGatewaysAsync()) { Console.WriteLine($"Succeeded: {item}"); } @@ -75,10 +104,37 @@ public async Task GetAvailableServiceAliases_GetAvailableServiceAliases() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAzureFirewallFqdnTags_ListAllAzureFirewallFQDNTagsForAGivenSubscription() + public async Task GetAvailableResponseHeadersApplicationGateways_GetAvailableResponseHeaders() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallFqdnTagsListBySubscription.json - // this example is just showing the usage of "AzureFirewallFqdnTags_ListAll" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableResponseHeadersGet.json + // this example is just showing the usage of "ApplicationGateways_ListAvailableResponseHeaders" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "72f988bf-86f1-41af-91ab-2d7cd0dddd4"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (string item in subscriptionResource.GetAvailableResponseHeadersApplicationGatewaysAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAppGatewayAvailableWafRuleSets_GetAvailableWafRuleSets() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableWafRuleSetsGet.json + // this example is just showing the usage of "ApplicationGateways_ListAvailableWafRuleSets" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -92,7 +148,7 @@ public async Task GetAzureFirewallFqdnTags_ListAllAzureFirewallFQDNTagsForAGiven SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - await foreach (AzureFirewallFqdnTag item in subscriptionResource.GetAzureFirewallFqdnTagsAsync()) + await foreach (ApplicationGatewayFirewallRuleSet item in subscriptionResource.GetAppGatewayAvailableWafRuleSetsAsync()) { Console.WriteLine($"Succeeded: {item}"); } @@ -102,10 +158,34 @@ public async Task GetAzureFirewallFqdnTags_ListAllAzureFirewallFQDNTagsForAGiven [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAvailableEndpointServices_EndpointServicesList() + public async Task GetApplicationGatewayAvailableSslOptions_GetAvailableSslOptions() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/EndpointServicesList.json - // this example is just showing the usage of "AvailableEndpointServices_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableSslOptionsGet.json + // this example is just showing the usage of "ApplicationGateways_ListAvailableSslOptions" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + ApplicationGatewayAvailableSslOptionsInfo result = await subscriptionResource.GetApplicationGatewayAvailableSslOptionsAsync(); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApplicationGatewayAvailableSslPredefinedPolicies_GetAvailableSslPredefinedPolicies() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableSslOptionsPredefinedPoliciesGet.json + // this example is just showing the usage of "ApplicationGateways_ListAvailableSslPredefinedPolicies" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -119,8 +199,7 @@ public async Task GetAvailableEndpointServices_EndpointServicesList() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("westus"); - await foreach (EndpointServiceResult item in subscriptionResource.GetAvailableEndpointServicesAsync(location)) + await foreach (ApplicationGatewaySslPredefinedPolicy item in subscriptionResource.GetApplicationGatewayAvailableSslPredefinedPoliciesAsync()) { Console.WriteLine($"Succeeded: {item}"); } @@ -130,10 +209,35 @@ public async Task GetAvailableEndpointServices_EndpointServicesList() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetExpressRouteServiceProviders_ListExpressRouteProviders() + public async Task GetApplicationGatewaySslPredefinedPolicy_GetAvailableSslPredefinedPolicyByName() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteProviderList.json - // this example is just showing the usage of "ExpressRouteServiceProviders_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationGatewayAvailableSslOptionsPredefinedPolicyGet.json + // this example is just showing the usage of "ApplicationGateways_GetSslPredefinedPolicy" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + string predefinedPolicyName = "AppGwSslPolicy20150501"; + ApplicationGatewaySslPredefinedPolicy result = await subscriptionResource.GetApplicationGatewaySslPredefinedPolicyAsync(predefinedPolicyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetApplicationSecurityGroups_ListAllApplicationSecurityGroups() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ApplicationSecurityGroupListAll.json + // this example is just showing the usage of "ApplicationSecurityGroups_ListAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,7 +251,39 @@ public async Task GetExpressRouteServiceProviders_ListExpressRouteProviders() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - await foreach (ExpressRouteServiceProvider item in subscriptionResource.GetExpressRouteServiceProvidersAsync()) + await foreach (ApplicationSecurityGroupResource item in subscriptionResource.GetApplicationSecurityGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ApplicationSecurityGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAvailableDelegations_GetAvailableDelegations() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AvailableDelegationsSubscriptionGet.json + // this example is just showing the usage of "AvailableDelegations_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("westcentralus"); + await foreach (AvailableDelegation item in subscriptionResource.GetAvailableDelegationsAsync(location)) { Console.WriteLine($"Succeeded: {item}"); } @@ -157,10 +293,10 @@ public async Task GetExpressRouteServiceProviders_ListExpressRouteProviders() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAvailablePrivateEndpointTypes_GetAvailablePrivateEndpointTypes() + public async Task GetAvailableServiceAliases_GetAvailableServiceAliases() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AvailablePrivateEndpointTypesGet.json - // this example is just showing the usage of "AvailablePrivateEndpointTypes_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AvailableServiceAliasesList.json + // this example is just showing the usage of "AvailableServiceAliases_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -174,8 +310,8 @@ public async Task GetAvailablePrivateEndpointTypes_GetAvailablePrivateEndpointTy SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("regionName"); - await foreach (AvailablePrivateEndpointType item in subscriptionResource.GetAvailablePrivateEndpointTypesAsync(location)) + AzureLocation location = new AzureLocation("westcentralus"); + await foreach (AvailableServiceAlias item in subscriptionResource.GetAvailableServiceAliasesAsync(location)) { Console.WriteLine($"Succeeded: {item}"); } @@ -185,10 +321,10 @@ public async Task GetAvailablePrivateEndpointTypes_GetAvailablePrivateEndpointTy [Test] [Ignore("Only validating compilation of examples")] - public async Task CheckPrivateLinkServiceVisibilityPrivateLinkService_CheckPrivateLinkServiceVisibility() + public async Task GetAzureFirewalls_ListAllAzureFirewallsForAGivenSubscription() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CheckPrivateLinkServiceVisibility.json - // this example is just showing the usage of "PrivateLinkServices_CheckPrivateLinkServiceVisibility" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallListBySubscription.json + // this example is just showing the usage of "AzureFirewalls_ListAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -201,24 +337,25 @@ public async Task CheckPrivateLinkServiceVisibilityPrivateLinkService_CheckPriva ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - // invoke the operation - AzureLocation location = new AzureLocation("westus"); - CheckPrivateLinkServiceVisibilityRequest checkPrivateLinkServiceVisibilityRequest = new CheckPrivateLinkServiceVisibilityRequest() + // invoke the operation and iterate over the result + await foreach (AzureFirewallResource item in subscriptionResource.GetAzureFirewallsAsync()) { - PrivateLinkServiceAlias = "mypls.00000000-0000-0000-0000-000000000000.azure.privatelinkservice", - }; - ArmOperation lro = await subscriptionResource.CheckPrivateLinkServiceVisibilityPrivateLinkServiceAsync(WaitUntil.Completed, location, checkPrivateLinkServiceVisibilityRequest); - PrivateLinkServiceVisibility result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + AzureFirewallData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAutoApprovedPrivateLinkServicesPrivateLinkServices_GetListOfPrivateLinkServiceIdThatCanBeLinkedToAPrivateEndPointWithAutoApproved() + public async Task GetAzureFirewallFqdnTags_ListAllAzureFirewallFQDNTagsForAGivenSubscription() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AutoApprovedPrivateLinkServicesGet.json - // this example is just showing the usage of "PrivateLinkServices_ListAutoApprovedPrivateLinkServices" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AzureFirewallFqdnTagsListBySubscription.json + // this example is just showing the usage of "AzureFirewallFqdnTags_ListAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -227,13 +364,12 @@ public async Task GetAutoApprovedPrivateLinkServicesPrivateLinkServices_GetListO // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("regionName"); - await foreach (AutoApprovedPrivateLinkService item in subscriptionResource.GetAutoApprovedPrivateLinkServicesPrivateLinkServicesAsync(location)) + await foreach (AzureFirewallFqdnTag item in subscriptionResource.GetAzureFirewallFqdnTagsAsync()) { Console.WriteLine($"Succeeded: {item}"); } @@ -243,10 +379,10 @@ public async Task GetAutoApprovedPrivateLinkServicesPrivateLinkServices_GetListO [Test] [Ignore("Only validating compilation of examples")] - public async Task GetBgpServiceCommunities_ServiceCommunityList() + public async Task GetBastionHosts_ListAllBastionHostsForAGivenSubscription() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceCommunityList.json - // this example is just showing the usage of "BgpServiceCommunities_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/BastionHostListBySubscription.json + // this example is just showing the usage of "BastionHosts_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -260,9 +396,13 @@ public async Task GetBgpServiceCommunities_ServiceCommunityList() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - await foreach (BgpServiceCommunity item in subscriptionResource.GetBgpServiceCommunitiesAsync()) + await foreach (BastionHostResource item in subscriptionResource.GetBastionHostsAsync()) { - Console.WriteLine($"Succeeded: {item}"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + BastionHostData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } Console.WriteLine("Succeeded"); @@ -270,10 +410,10 @@ public async Task GetBgpServiceCommunities_ServiceCommunityList() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetServiceTag_GetListOfServiceTags() + public async Task CheckDnsNameAvailability_CheckDnsNameAvailability() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceTagsList.json - // this example is just showing the usage of "ServiceTags_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CheckDnsNameAvailability.json + // this example is just showing the usage of "CheckDnsNameAvailability" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -282,23 +422,24 @@ public async Task GetServiceTag_GetListOfServiceTags() // this example assumes you already have this SubscriptionResource created on azure // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation - AzureLocation location = new AzureLocation("westcentralus"); - ServiceTagsListResult result = await subscriptionResource.GetServiceTagAsync(location); + AzureLocation location = new AzureLocation("westus"); + string domainNameLabel = "testdns"; + DnsNameAvailabilityResult result = await subscriptionResource.CheckDnsNameAvailabilityAsync(location, domainNameLabel); Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAllServiceTagInformation_GetListOfServiceTags() + public async Task GetCustomIPPrefixes_ListAllCustomIPPrefixes() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceTagInformationListResult.json - // this example is just showing the usage of "ServiceTagInformation_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CustomIpPrefixListAll.json + // this example is just showing the usage of "CustomIPPrefixes_ListAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -312,10 +453,13 @@ public async Task GetAllServiceTagInformation_GetListOfServiceTags() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("westeurope"); - await foreach (ServiceTagInformation item in subscriptionResource.GetAllServiceTagInformationAsync(location)) + await foreach (CustomIPPrefixResource item in subscriptionResource.GetCustomIPPrefixesAsync()) { - Console.WriteLine($"Succeeded: {item}"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + CustomIPPrefixData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } Console.WriteLine("Succeeded"); @@ -323,10 +467,10 @@ public async Task GetAllServiceTagInformation_GetListOfServiceTags() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAllServiceTagInformation_GetListOfServiceTagsWithNoAddressPrefixes() + public async Task GetDdosProtectionPlans_ListAllDDoSProtectionPlans() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceTagInformationListResultWithNoAddressPrefixes.json - // this example is just showing the usage of "ServiceTagInformation_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DdosProtectionPlanListAll.json + // this example is just showing the usage of "DdosProtectionPlans_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -340,11 +484,13 @@ public async Task GetAllServiceTagInformation_GetListOfServiceTagsWithNoAddressP SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("westeurope"); - bool? noAddressPrefixes = true; - await foreach (ServiceTagInformation item in subscriptionResource.GetAllServiceTagInformationAsync(location, noAddressPrefixes: noAddressPrefixes)) + await foreach (DdosProtectionPlanResource item in subscriptionResource.GetDdosProtectionPlansAsync()) { - Console.WriteLine($"Succeeded: {item}"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DdosProtectionPlanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } Console.WriteLine("Succeeded"); @@ -352,10 +498,10 @@ public async Task GetAllServiceTagInformation_GetListOfServiceTagsWithNoAddressP [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAllServiceTagInformation_GetListOfServiceTagsWithTagName() + public async Task GetDscpConfigurations_ListAllNetworkInterfaces() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceTagInformationListResultWithTagname.json - // this example is just showing the usage of "ServiceTagInformation_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/DscpConfigurationListAll.json + // this example is just showing the usage of "DscpConfiguration_ListAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -369,11 +515,13 @@ public async Task GetAllServiceTagInformation_GetListOfServiceTagsWithTagName() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("westeurope"); - string tagName = "ApiManagement"; - await foreach (ServiceTagInformation item in subscriptionResource.GetAllServiceTagInformationAsync(location, tagName: tagName)) + await foreach (DscpConfigurationResource item in subscriptionResource.GetDscpConfigurationsAsync()) { - Console.WriteLine($"Succeeded: {item}"); + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + DscpConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } Console.WriteLine("Succeeded"); @@ -381,10 +529,10 @@ public async Task GetAllServiceTagInformation_GetListOfServiceTagsWithTagName() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetUsages_ListUsages() + public async Task GetAvailableEndpointServices_EndpointServicesList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/UsageList.json - // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/EndpointServicesList.json + // this example is just showing the usage of "AvailableEndpointServices_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -399,7 +547,7 @@ public async Task GetUsages_ListUsages() // invoke the operation and iterate over the result AzureLocation location = new AzureLocation("westus"); - await foreach (NetworkUsage item in subscriptionResource.GetUsagesAsync(location)) + await foreach (EndpointServiceResult item in subscriptionResource.GetAvailableEndpointServicesAsync(location)) { Console.WriteLine($"Succeeded: {item}"); } @@ -409,10 +557,10 @@ public async Task GetUsages_ListUsages() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetUsages_ListUsagesSpacedLocation() + public async Task GetExpressRouteCircuits_ListExpressRouteCircuitsInASubscription() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/UsageListSpacedLocation.json - // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCircuitListBySubscription.json + // this example is just showing the usage of "ExpressRouteCircuits_ListAll" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -426,13 +574,1352 @@ public async Task GetUsages_ListUsagesSpacedLocation() SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); // invoke the operation and iterate over the result - AzureLocation location = new AzureLocation("West US"); - await foreach (NetworkUsage item in subscriptionResource.GetUsagesAsync(location)) + await foreach (ExpressRouteCircuitResource item in subscriptionResource.GetExpressRouteCircuitsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCircuitData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetExpressRouteServiceProviders_ListExpressRouteProviders() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteProviderList.json + // this example is just showing the usage of "ExpressRouteServiceProviders_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ExpressRouteServiceProvider item in subscriptionResource.GetExpressRouteServiceProvidersAsync()) { Console.WriteLine($"Succeeded: {item}"); } Console.WriteLine("Succeeded"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetExpressRouteCrossConnections_ExpressRouteCrossConnectionList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteCrossConnectionList.json + // this example is just showing the usage of "ExpressRouteCrossConnections_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ExpressRouteCrossConnectionResource item in subscriptionResource.GetExpressRouteCrossConnectionsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteCrossConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetExpressRoutePorts_ExpressRoutePortList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRoutePortList.json + // this example is just showing the usage of "ExpressRoutePorts_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ExpressRoutePortResource item in subscriptionResource.GetExpressRoutePortsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRoutePortData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetFirewallPolicies_ListAllFirewallPoliciesForAGivenSubscription() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/FirewallPolicyListBySubscription.json + // this example is just showing the usage of "FirewallPolicies_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (FirewallPolicyResource item in subscriptionResource.GetFirewallPoliciesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + FirewallPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIPAllocations_ListAllIpAllocations() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpAllocationList.json + // this example is just showing the usage of "IpAllocations_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (IPAllocationResource item in subscriptionResource.GetIPAllocationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IPAllocationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIPGroups_ListIpGroups() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/IpGroupsListBySubscription.json + // this example is just showing the usage of "IpGroups_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (IPGroupResource item in subscriptionResource.GetIPGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + IPGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetLoadBalancers_ListAllLoadBalancers() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancerListAll.json + // this example is just showing the usage of "LoadBalancers_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (LoadBalancerResource item in subscriptionResource.GetLoadBalancersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + LoadBalancerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task SwapPublicIPAddressesLoadBalancer_SwapVIPsBetweenTwoLoadBalancers() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/LoadBalancersSwapPublicIpAddresses.json + // this example is just showing the usage of "LoadBalancers_SwapPublicIPAddresses" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("westus"); + LoadBalancerVipSwapContent content = new LoadBalancerVipSwapContent + { + FrontendIPConfigurations = {new LoadBalancerVipSwapRequestFrontendIPConfiguration +{ +Id = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/loadBalancers/lb1/frontendIPConfigurations/lbfe1", +PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/publicIPAddresses/pip2"), +}, new LoadBalancerVipSwapRequestFrontendIPConfiguration +{ +Id = "/subscriptions/subid/resourceGroups/rg2/providers/Microsoft.Network/loadBalancers/lb2/frontendIPConfigurations/lbfe2", +PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/pip1"), +}}, + }; + await subscriptionResource.SwapPublicIPAddressesLoadBalancerAsync(WaitUntil.Completed, location, content); + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNatGateways_ListAllNatGateways() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatGatewayListAll.json + // this example is just showing the usage of "NatGateways_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NatGatewayResource item in subscriptionResource.GetNatGatewaysAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NatGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkInterfaces_ListAllNetworkInterfaces() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkInterfaceListAll.json + // this example is just showing the usage of "NetworkInterfaces_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkInterfaceResource item in subscriptionResource.GetNetworkInterfacesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkInterfaceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkManagers_NetworkManagersList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerListAll.json + // this example is just showing the usage of "NetworkManagers_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkManagerResource item in subscriptionResource.GetNetworkManagersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkManagerData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkProfiles_ListAllNetworkProfiles() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkProfileListAll.json + // this example is just showing the usage of "NetworkProfiles_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkProfileResource item in subscriptionResource.GetNetworkProfilesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkProfileData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkSecurityGroups_ListAllNetworkSecurityGroups() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkSecurityGroupListAll.json + // this example is just showing the usage of "NetworkSecurityGroups_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkSecurityGroupResource item in subscriptionResource.GetNetworkSecurityGroupsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkSecurityGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkVirtualAppliances_ListAllNetworkVirtualAppliancesForAGivenSubscription() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceListBySubscription.json + // this example is just showing the usage of "NetworkVirtualAppliances_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkVirtualApplianceResource item in subscriptionResource.GetNetworkVirtualAppliancesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkVirtualApplianceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkWatchers_ListAllNetworkWatchers() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkWatcherListAll.json + // this example is just showing the usage of "NetworkWatchers_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (NetworkWatcherResource item in subscriptionResource.GetNetworkWatchersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + NetworkWatcherData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPrivateEndpoints_ListAllPrivateEndpoints() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateEndpointListAll.json + // this example is just showing the usage of "PrivateEndpoints_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PrivateEndpointResource item in subscriptionResource.GetPrivateEndpointsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateEndpointData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAvailablePrivateEndpointTypes_GetAvailablePrivateEndpointTypes() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AvailablePrivateEndpointTypesGet.json + // this example is just showing the usage of "AvailablePrivateEndpointTypes_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("regionName"); + await foreach (AvailablePrivateEndpointType item in subscriptionResource.GetAvailablePrivateEndpointTypesAsync(location)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPrivateLinkServices_ListAllPrivateListService() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PrivateLinkServiceListAll.json + // this example is just showing the usage of "PrivateLinkServices_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PrivateLinkServiceResource item in subscriptionResource.GetPrivateLinkServicesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PrivateLinkServiceData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task CheckPrivateLinkServiceVisibilityPrivateLinkService_CheckPrivateLinkServiceVisibility() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/CheckPrivateLinkServiceVisibility.json + // this example is just showing the usage of "PrivateLinkServices_CheckPrivateLinkServiceVisibility" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("westus"); + CheckPrivateLinkServiceVisibilityRequest checkPrivateLinkServiceVisibilityRequest = new CheckPrivateLinkServiceVisibilityRequest + { + PrivateLinkServiceAlias = "mypls.00000000-0000-0000-0000-000000000000.azure.privatelinkservice", + }; + ArmOperation lro = await subscriptionResource.CheckPrivateLinkServiceVisibilityPrivateLinkServiceAsync(WaitUntil.Completed, location, checkPrivateLinkServiceVisibilityRequest); + PrivateLinkServiceVisibility result = lro.Value; + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAutoApprovedPrivateLinkServicesPrivateLinkServices_GetListOfPrivateLinkServiceIdThatCanBeLinkedToAPrivateEndPointWithAutoApproved() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/AutoApprovedPrivateLinkServicesGet.json + // this example is just showing the usage of "PrivateLinkServices_ListAutoApprovedPrivateLinkServices" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("regionName"); + await foreach (AutoApprovedPrivateLinkService item in subscriptionResource.GetAutoApprovedPrivateLinkServicesPrivateLinkServicesAsync(location)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPublicIPAddresses_ListAllPublicIPAddresses() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpAddressListAll.json + // this example is just showing the usage of "PublicIPAddresses_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PublicIPAddressResource item in subscriptionResource.GetPublicIPAddressesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicIPAddressData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetPublicIPPrefixes_ListAllPublicIPPrefixes() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/PublicIpPrefixListAll.json + // this example is just showing the usage of "PublicIPPrefixes_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (PublicIPPrefixResource item in subscriptionResource.GetPublicIPPrefixesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + PublicIPPrefixData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetRouteFilters_RouteFilterList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteFilterList.json + // this example is just showing the usage of "RouteFilters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (RouteFilterResource item in subscriptionResource.GetRouteFiltersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteFilterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetRouteTables_ListAllRouteTables() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/RouteTableListAll.json + // this example is just showing the usage of "RouteTables_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (RouteTableResource item in subscriptionResource.GetRouteTablesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + RouteTableData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetSecurityPartnerProviders_ListAllSecurityPartnerProvidersForAGivenSubscription() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/SecurityPartnerProviderListBySubscription.json + // this example is just showing the usage of "SecurityPartnerProviders_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (SecurityPartnerProviderResource item in subscriptionResource.GetSecurityPartnerProvidersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + SecurityPartnerProviderData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetBgpServiceCommunities_ServiceCommunityList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceCommunityList.json + // this example is just showing the usage of "BgpServiceCommunities_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (BgpServiceCommunity item in subscriptionResource.GetBgpServiceCommunitiesAsync()) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetServiceEndpointPoliciesByServiceEndpointPolicy_ListAllServiceEndpointPolicy() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceEndpointPolicyListAll.json + // this example is just showing the usage of "ServiceEndpointPolicies_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ServiceEndpointPolicyResource item in subscriptionResource.GetServiceEndpointPoliciesByServiceEndpointPolicyAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ServiceEndpointPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetServiceTag_GetListOfServiceTags() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceTagsList.json + // this example is just showing the usage of "ServiceTags_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subId"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation + AzureLocation location = new AzureLocation("westcentralus"); + ServiceTagsListResult result = await subscriptionResource.GetServiceTagAsync(location); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAllServiceTagInformation_GetListOfServiceTags() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceTagInformationListResult.json + // this example is just showing the usage of "ServiceTagInformation_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("westeurope"); + await foreach (ServiceTagInformation item in subscriptionResource.GetAllServiceTagInformationAsync(location)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAllServiceTagInformation_GetListOfServiceTagsWithNoAddressPrefixes() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceTagInformationListResultWithNoAddressPrefixes.json + // this example is just showing the usage of "ServiceTagInformation_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("westeurope"); + bool? noAddressPrefixes = true; + await foreach (ServiceTagInformation item in subscriptionResource.GetAllServiceTagInformationAsync(location, noAddressPrefixes: noAddressPrefixes)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAllServiceTagInformation_GetListOfServiceTagsWithTagName() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ServiceTagInformationListResultWithTagname.json + // this example is just showing the usage of "ServiceTagInformation_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("westeurope"); + string tagName = "ApiManagement"; + await foreach (ServiceTagInformation item in subscriptionResource.GetAllServiceTagInformationAsync(location, tagName: tagName)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetUsages_ListUsages() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/UsageList.json + // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("westus"); + await foreach (NetworkUsage item in subscriptionResource.GetUsagesAsync(location)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetUsages_ListUsagesSpacedLocation() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/UsageListSpacedLocation.json + // this example is just showing the usage of "Usages_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + AzureLocation location = new AzureLocation("West US"); + await foreach (NetworkUsage item in subscriptionResource.GetUsagesAsync(location)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualNetworks_ListAllVirtualNetworks() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkListAll.json + // this example is just showing the usage of "VirtualNetworks_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VirtualNetworkResource item in subscriptionResource.GetVirtualNetworksAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualNetworkTaps_ListAllVirtualNetworkTaps() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapListAll.json + // this example is just showing the usage of "VirtualNetworkTaps_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VirtualNetworkTapResource item in subscriptionResource.GetVirtualNetworkTapsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkTapData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualRouters_ListAllVirtualRoutersForAGivenSubscription() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterListBySubscription.json + // this example is just showing the usage of "VirtualRouters_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VirtualRouterResource item in subscriptionResource.GetVirtualRoutersAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualRouterData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualWans_VirtualWANList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANList.json + // this example is just showing the usage of "VirtualWans_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VirtualWanResource item in subscriptionResource.GetVirtualWansAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualWanData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVpnSites_VpnSiteList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteList.json + // this example is just showing the usage of "VpnSites_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VpnSiteResource item in subscriptionResource.GetVpnSitesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnSiteData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVpnServerConfigurations_VpnServerConfigurationList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationList.json + // this example is just showing the usage of "VpnServerConfigurations_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VpnServerConfigurationResource item in subscriptionResource.GetVpnServerConfigurationsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnServerConfigurationData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVirtualHubs_VirtualHubList() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubList.json + // this example is just showing the usage of "VirtualHubs_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VirtualHubResource item in subscriptionResource.GetVirtualHubsAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualHubData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetVpnGateways_VpnGatewayListBySubscription() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayList.json + // this example is just showing the usage of "VpnGateways_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (VpnGatewayResource item in subscriptionResource.GetVpnGatewaysAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetP2SVpnGateways_P2SVpnGatewayListBySubscription() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/P2SVpnGatewayList.json + // this example is just showing the usage of "P2sVpnGateways_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (P2SVpnGatewayResource item in subscriptionResource.GetP2SVpnGatewaysAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + P2SVpnGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetExpressRouteGateways_ExpressRouteGatewayListBySubscription() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ExpressRouteGatewayListBySubscription.json + // this example is just showing the usage of "ExpressRouteGateways_ListBySubscription" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (ExpressRouteGatewayResource item in subscriptionResource.GetExpressRouteGatewaysAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + ExpressRouteGatewayData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetWebApplicationFirewallPolicies_ListsAllWAFPoliciesInASubscription() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafListAllPolicies.json + // this example is just showing the usage of "WebApplicationFirewallPolicies_ListAll" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this SubscriptionResource created on azure + // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + string subscriptionId = "subid"; + ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); + SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + + // invoke the operation and iterate over the result + await foreach (WebApplicationFirewallPolicyResource item in subscriptionResource.GetWebApplicationFirewallPoliciesAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebApplicationFirewallPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualApplianceSiteCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualApplianceSiteCollection.cs index 212358faf1fe6..c91ac163cf3c0 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualApplianceSiteCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualApplianceSiteCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualApplianceSiteCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkVirtualApplianceSite() + public async Task CreateOrUpdate_CreateNetworkVirtualApplianceSite() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteGet.json - // this example is just showing the usage of "VirtualApplianceSites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSitePut.json + // this example is just showing the usage of "VirtualApplianceSites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,18 @@ public async Task Get_GetNetworkVirtualApplianceSite() // invoke the operation string siteName = "site1"; - VirtualApplianceSiteResource result = await collection.GetAsync(siteName); + VirtualApplianceSiteData data = new VirtualApplianceSiteData + { + AddressPrefix = "192.168.1.0/24", + O365BreakOutCategories = new BreakOutCategoryPolicies + { + Allow = true, + Optimize = true, + Default = true, + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, siteName, data); + VirtualApplianceSiteResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +63,7 @@ public async Task Get_GetNetworkVirtualApplianceSite() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetNetworkVirtualApplianceSite() + public async Task Get_GetNetworkVirtualApplianceSite() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteGet.json // this example is just showing the usage of "VirtualApplianceSites_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +86,21 @@ public async Task Exists_GetNetworkVirtualApplianceSite() // invoke the operation string siteName = "site1"; - bool result = await collection.ExistsAsync(siteName); + VirtualApplianceSiteResource result = await collection.GetAsync(siteName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualApplianceSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetNetworkVirtualApplianceSite() + public async Task GetAll_ListAllNetworkVirtualApplianceSitesForAGivenNetworkVirtualAppliance() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteGet.json - // this example is just showing the usage of "VirtualApplianceSites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteList.json + // this example is just showing the usage of "VirtualApplianceSites_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +118,25 @@ public async Task GetIfExists_GetNetworkVirtualApplianceSite() // get the collection of this VirtualApplianceSiteResource VirtualApplianceSiteCollection collection = networkVirtualAppliance.GetVirtualApplianceSites(); - // invoke the operation - string siteName = "site1"; - NullableResponse response = await collection.GetIfExistsAsync(siteName); - VirtualApplianceSiteResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualApplianceSiteResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualApplianceSiteData resourceData = result.Data; + VirtualApplianceSiteData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateNetworkVirtualApplianceSite() + public async Task Exists_GetNetworkVirtualApplianceSite() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSitePut.json - // this example is just showing the usage of "VirtualApplianceSites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteGet.json + // this example is just showing the usage of "VirtualApplianceSites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,32 +156,17 @@ public async Task CreateOrUpdate_CreateNetworkVirtualApplianceSite() // invoke the operation string siteName = "site1"; - VirtualApplianceSiteData data = new VirtualApplianceSiteData() - { - AddressPrefix = "192.168.1.0/24", - O365BreakOutCategories = new BreakOutCategoryPolicies() - { - Allow = true, - Optimize = true, - Default = true, - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, siteName, data); - VirtualApplianceSiteResource result = lro.Value; + bool result = await collection.ExistsAsync(siteName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualApplianceSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllNetworkVirtualApplianceSitesForAGivenNetworkVirtualAppliance() + public async Task GetIfExists_GetNetworkVirtualApplianceSite() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteList.json - // this example is just showing the usage of "VirtualApplianceSites_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteGet.json + // this example is just showing the usage of "VirtualApplianceSites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -190,17 +184,23 @@ public async Task GetAll_ListAllNetworkVirtualApplianceSitesForAGivenNetworkVirt // get the collection of this VirtualApplianceSiteResource VirtualApplianceSiteCollection collection = networkVirtualAppliance.GetVirtualApplianceSites(); - // invoke the operation and iterate over the result - await foreach (VirtualApplianceSiteResource item in collection.GetAllAsync()) + // invoke the operation + string siteName = "site1"; + NullableResponse response = await collection.GetIfExistsAsync(siteName); + VirtualApplianceSiteResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualApplianceSiteData resourceData = item.Data; + VirtualApplianceSiteData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualApplianceSiteResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualApplianceSiteResource.cs index 332586fcfd726..9927fd9d181ea 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualApplianceSiteResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualApplianceSiteResource.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualApplianceSiteResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteNetworkVirtualApplianceSite() + public async Task Get_GetNetworkVirtualApplianceSite() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteDelete.json - // this example is just showing the usage of "VirtualApplianceSites_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteGet.json + // this example is just showing the usage of "VirtualApplianceSites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task Delete_DeleteNetworkVirtualApplianceSite() VirtualApplianceSiteResource virtualApplianceSite = client.GetVirtualApplianceSiteResource(virtualApplianceSiteResourceId); // invoke the operation - await virtualApplianceSite.DeleteAsync(WaitUntil.Completed); + VirtualApplianceSiteResource result = await virtualApplianceSite.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualApplianceSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetNetworkVirtualApplianceSite() + public async Task Delete_DeleteNetworkVirtualApplianceSite() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteGet.json - // this example is just showing the usage of "VirtualApplianceSites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkVirtualApplianceSiteDelete.json + // this example is just showing the usage of "VirtualApplianceSites_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -65,13 +69,9 @@ public async Task Get_GetNetworkVirtualApplianceSite() VirtualApplianceSiteResource virtualApplianceSite = client.GetVirtualApplianceSiteResource(virtualApplianceSiteResourceId); // invoke the operation - VirtualApplianceSiteResource result = await virtualApplianceSite.GetAsync(); + await virtualApplianceSite.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualApplianceSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -96,10 +96,10 @@ public async Task Update_CreateNetworkVirtualApplianceSite() VirtualApplianceSiteResource virtualApplianceSite = client.GetVirtualApplianceSiteResource(virtualApplianceSiteResourceId); // invoke the operation - VirtualApplianceSiteData data = new VirtualApplianceSiteData() + VirtualApplianceSiteData data = new VirtualApplianceSiteData { AddressPrefix = "192.168.1.0/24", - O365BreakOutCategories = new BreakOutCategoryPolicies() + O365BreakOutCategories = new BreakOutCategoryPolicies { Allow = true, Optimize = true, diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubCollection.cs index 53f64b4ebcf12..a6c9ad8a7d7b0 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualHubCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualHubGet() + public async Task CreateOrUpdate_VirtualHubPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubGet.json - // this example is just showing the usage of "VirtualHubs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubPut.json + // this example is just showing the usage of "VirtualHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,20 @@ public async Task Get_VirtualHubGet() VirtualHubCollection collection = resourceGroupResource.GetVirtualHubs(); // invoke the operation - string virtualHubName = "virtualHub1"; - VirtualHubResource result = await collection.GetAsync(virtualHubName); + string virtualHubName = "virtualHub2"; + VirtualHubData data = new VirtualHubData + { + VirtualWanId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualWans/virtualWan1"), + AddressPrefix = "10.168.0.0/24", + Sku = "Basic", + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualHubName, data); + VirtualHubResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +63,7 @@ public async Task Get_VirtualHubGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualHubGet() + public async Task Get_VirtualHubGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubGet.json // this example is just showing the usage of "VirtualHubs_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +85,21 @@ public async Task Exists_VirtualHubGet() // invoke the operation string virtualHubName = "virtualHub1"; - bool result = await collection.ExistsAsync(virtualHubName); + VirtualHubResource result = await collection.GetAsync(virtualHubName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualHubGet() + public async Task GetAll_VirtualHubListByResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubGet.json - // this example is just showing the usage of "VirtualHubs_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubListByResourceGroup.json + // this example is just showing the usage of "VirtualHubs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +116,25 @@ public async Task GetIfExists_VirtualHubGet() // get the collection of this VirtualHubResource VirtualHubCollection collection = resourceGroupResource.GetVirtualHubs(); - // invoke the operation - string virtualHubName = "virtualHub1"; - NullableResponse response = await collection.GetIfExistsAsync(virtualHubName); - VirtualHubResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualHubResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualHubData resourceData = result.Data; + VirtualHubData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VirtualHubPut() + public async Task Exists_VirtualHubGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubPut.json - // this example is just showing the usage of "VirtualHubs_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubGet.json + // this example is just showing the usage of "VirtualHubs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,34 +152,18 @@ public async Task CreateOrUpdate_VirtualHubPut() VirtualHubCollection collection = resourceGroupResource.GetVirtualHubs(); // invoke the operation - string virtualHubName = "virtualHub2"; - VirtualHubData data = new VirtualHubData() - { - VirtualWanId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualWans/virtualWan1"), - AddressPrefix = "10.168.0.0/24", - Sku = "Basic", - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualHubName, data); - VirtualHubResource result = lro.Value; + string virtualHubName = "virtualHub1"; + bool result = await collection.ExistsAsync(virtualHubName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualHubListByResourceGroup() + public async Task GetIfExists_VirtualHubGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubListByResourceGroup.json - // this example is just showing the usage of "VirtualHubs_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubGet.json + // this example is just showing the usage of "VirtualHubs_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -186,17 +180,23 @@ public async Task GetAll_VirtualHubListByResourceGroup() // get the collection of this VirtualHubResource VirtualHubCollection collection = resourceGroupResource.GetVirtualHubs(); - // invoke the operation and iterate over the result - await foreach (VirtualHubResource item in collection.GetAllAsync()) + // invoke the operation + string virtualHubName = "virtualHub1"; + NullableResponse response = await collection.GetIfExistsAsync(virtualHubName); + VirtualHubResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualHubData resourceData = item.Data; + VirtualHubData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubResource.cs index e55ac52d7105e..134693aea8cdd 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -47,44 +46,6 @@ public async Task Get_VirtualHubGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Update_VirtualHubUpdate() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubUpdateTags.json - // this example is just showing the usage of "VirtualHubs_UpdateTags" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualHubResource created on azure - // for more information of creating VirtualHubResource, please refer to the document of VirtualHubResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string virtualHubName = "virtualHub2"; - ResourceIdentifier virtualHubResourceId = VirtualHubResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualHubName); - VirtualHubResource virtualHub = client.GetVirtualHubResource(virtualHubResourceId); - - // invoke the operation - NetworkTagsObject virtualHubParameters = new NetworkTagsObject() - { - Tags = -{ -["key1"] = "value1", -["key2"] = "value2", -}, - }; - VirtualHubResource result = await virtualHub.UpdateAsync(virtualHubParameters); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualHubData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Delete_VirtualHubDelete() @@ -113,33 +74,40 @@ public async Task Delete_VirtualHubDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetVirtualHubs_VirtualHubList() + public async Task Update_VirtualHubUpdate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubList.json - // this example is just showing the usage of "VirtualHubs_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubUpdateTags.json + // this example is just showing the usage of "VirtualHubs_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this VirtualHubResource created on azure + // for more information of creating VirtualHubResource, please refer to the document of VirtualHubResource string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rg1"; + string virtualHubName = "virtualHub2"; + ResourceIdentifier virtualHubResourceId = VirtualHubResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualHubName); + VirtualHubResource virtualHub = client.GetVirtualHubResource(virtualHubResourceId); - // invoke the operation and iterate over the result - await foreach (VirtualHubResource item in subscriptionResource.GetVirtualHubsAsync()) + // invoke the operation + NetworkTagsObject virtualHubParameters = new NetworkTagsObject { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualHubData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + }; + VirtualHubResource result = await virtualHub.UpdateAsync(virtualHubParameters); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualHubData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -163,7 +131,7 @@ public async Task GetVirtualHubEffectiveRoutes_EffectiveRoutesForAConnectionReso VirtualHubResource virtualHub = client.GetVirtualHubResource(virtualHubResourceId); // invoke the operation - EffectiveRoutesContent content = new EffectiveRoutesContent() + EffectiveRoutesContent content = new EffectiveRoutesContent { ResourceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/resourceGroupName/providers/Microsoft.Network/expressRouteGateways/expressRouteGatewayName/expressRouteConnections/connectionName"), VirtualWanResourceType = "ExpressRouteConnection", @@ -195,7 +163,7 @@ public async Task GetVirtualHubEffectiveRoutes_EffectiveRoutesForARouteTableReso VirtualHubResource virtualHub = client.GetVirtualHubResource(virtualHubResourceId); // invoke the operation - EffectiveRoutesContent content = new EffectiveRoutesContent() + EffectiveRoutesContent content = new EffectiveRoutesContent { ResourceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/hubRouteTables/hubRouteTable1"), VirtualWanResourceType = "RouteTable", @@ -227,7 +195,7 @@ public async Task GetVirtualHubEffectiveRoutes_EffectiveRoutesForTheVirtualHub() VirtualHubResource virtualHub = client.GetVirtualHubResource(virtualHubResourceId); // invoke the operation - EffectiveRoutesContent content = null; + EffectiveRoutesContent content = default; ArmOperation lro = await virtualHub.GetVirtualHubEffectiveRoutesAsync(WaitUntil.Completed, content: content); VirtualHubEffectiveRouteList result = lro.Value; @@ -255,7 +223,7 @@ public async Task GetVirtualHubInboundRoutes_InboundRoutesForTheVirtualHubOnAPar VirtualHubResource virtualHub = client.GetVirtualHubResource(virtualHubResourceId); // invoke the operation - VirtualHubInboundRoutesContent content = new VirtualHubInboundRoutesContent() + VirtualHubInboundRoutesContent content = new VirtualHubInboundRoutesContent { ResourceUri = new Uri("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteGateways/exrGw1/expressRouteConnections/exrConn1"), ConnectionType = "ExpressRouteConnection", @@ -287,7 +255,7 @@ public async Task GetVirtualHubOutboundRoutes_OutboundRoutesForTheVirtualHubOnAP VirtualHubResource virtualHub = client.GetVirtualHubResource(virtualHubResourceId); // invoke the operation - VirtualHubOutboundRoutesContent content = new VirtualHubOutboundRoutesContent() + VirtualHubOutboundRoutesContent content = new VirtualHubOutboundRoutesContent { ResourceUri = new Uri("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/expressRouteGateways/exrGw1/expressRouteConnections/exrConn1"), ConnectionType = "ExpressRouteConnection", diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubRouteTableV2Collection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubRouteTableV2Collection.cs index 96176b16d1418..03ed2b63bc794 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubRouteTableV2Collection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubRouteTableV2Collection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualHubRouteTableV2Collection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualHubVirtualHubRouteTableV2Get() + public async Task CreateOrUpdate_VirtualHubRouteTableV2Put() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Get.json - // this example is just showing the usage of "VirtualHubRouteTableV2s_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Put.json + // this example is just showing the usage of "VirtualHubRouteTableV2s_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,25 @@ public async Task Get_VirtualHubVirtualHubRouteTableV2Get() // invoke the operation string routeTableName = "virtualHubRouteTable1a"; - VirtualHubRouteTableV2Resource result = await collection.GetAsync(routeTableName); + VirtualHubRouteTableV2Data data = new VirtualHubRouteTableV2Data + { + Routes = {new VirtualHubRouteV2 +{ +DestinationType = "CIDR", +Destinations = {"20.10.0.0/16", "20.20.0.0/16"}, +NextHopType = "IPAddress", +NextHops = {"10.0.0.68"}, +}, new VirtualHubRouteV2 +{ +DestinationType = "CIDR", +Destinations = {"0.0.0.0/0"}, +NextHopType = "IPAddress", +NextHops = {"10.0.0.68"}, +}}, + AttachedConnections = { "All_Vnets" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeTableName, data); + VirtualHubRouteTableV2Resource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +70,7 @@ public async Task Get_VirtualHubVirtualHubRouteTableV2Get() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualHubVirtualHubRouteTableV2Get() + public async Task Get_VirtualHubVirtualHubRouteTableV2Get() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Get.json // this example is just showing the usage of "VirtualHubRouteTableV2s_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +93,21 @@ public async Task Exists_VirtualHubVirtualHubRouteTableV2Get() // invoke the operation string routeTableName = "virtualHubRouteTable1a"; - bool result = await collection.ExistsAsync(routeTableName); + VirtualHubRouteTableV2Resource result = await collection.GetAsync(routeTableName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualHubRouteTableV2Data resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualHubVirtualHubRouteTableV2Get() + public async Task GetAll_VirtualHubRouteTableV2List() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Get.json - // this example is just showing the usage of "VirtualHubRouteTableV2s_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2List.json + // this example is just showing the usage of "VirtualHubRouteTableV2s_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +125,25 @@ public async Task GetIfExists_VirtualHubVirtualHubRouteTableV2Get() // get the collection of this VirtualHubRouteTableV2Resource VirtualHubRouteTableV2Collection collection = virtualHub.GetVirtualHubRouteTableV2s(); - // invoke the operation - string routeTableName = "virtualHubRouteTable1a"; - NullableResponse response = await collection.GetIfExistsAsync(routeTableName); - VirtualHubRouteTableV2Resource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualHubRouteTableV2Resource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualHubRouteTableV2Data resourceData = result.Data; + VirtualHubRouteTableV2Data resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VirtualHubRouteTableV2Put() + public async Task Exists_VirtualHubVirtualHubRouteTableV2Get() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Put.json - // this example is just showing the usage of "VirtualHubRouteTableV2s_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Get.json + // this example is just showing the usage of "VirtualHubRouteTableV2s_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,57 +163,17 @@ public async Task CreateOrUpdate_VirtualHubRouteTableV2Put() // invoke the operation string routeTableName = "virtualHubRouteTable1a"; - VirtualHubRouteTableV2Data data = new VirtualHubRouteTableV2Data() - { - Routes = -{ -new VirtualHubRouteV2() -{ -DestinationType = "CIDR", -Destinations = -{ -"20.10.0.0/16","20.20.0.0/16" -}, -NextHopType = "IPAddress", -NextHops = -{ -"10.0.0.68" -}, -},new VirtualHubRouteV2() -{ -DestinationType = "CIDR", -Destinations = -{ -"0.0.0.0/0" -}, -NextHopType = "IPAddress", -NextHops = -{ -"10.0.0.68" -}, -} -}, - AttachedConnections = -{ -"All_Vnets" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, routeTableName, data); - VirtualHubRouteTableV2Resource result = lro.Value; + bool result = await collection.ExistsAsync(routeTableName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualHubRouteTableV2Data resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualHubRouteTableV2List() + public async Task GetIfExists_VirtualHubVirtualHubRouteTableV2Get() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2List.json - // this example is just showing the usage of "VirtualHubRouteTableV2s_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Get.json + // this example is just showing the usage of "VirtualHubRouteTableV2s_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -215,17 +191,23 @@ public async Task GetAll_VirtualHubRouteTableV2List() // get the collection of this VirtualHubRouteTableV2Resource VirtualHubRouteTableV2Collection collection = virtualHub.GetVirtualHubRouteTableV2s(); - // invoke the operation and iterate over the result - await foreach (VirtualHubRouteTableV2Resource item in collection.GetAllAsync()) + // invoke the operation + string routeTableName = "virtualHubRouteTable1a"; + NullableResponse response = await collection.GetIfExistsAsync(routeTableName); + VirtualHubRouteTableV2Resource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualHubRouteTableV2Data resourceData = item.Data; + VirtualHubRouteTableV2Data resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubRouteTableV2Resource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubRouteTableV2Resource.cs index 72f24ae124348..de3d5631980b0 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubRouteTableV2Resource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualHubRouteTableV2Resource.cs @@ -49,10 +49,10 @@ public async Task Get_VirtualHubVirtualHubRouteTableV2Get() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VirtualHubRouteTableV2Put() + public async Task Delete_VirtualHubRouteTableV2Delete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Put.json - // this example is just showing the usage of "VirtualHubRouteTableV2s_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Delete.json + // this example is just showing the usage of "VirtualHubRouteTableV2s_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,57 +69,17 @@ public async Task Update_VirtualHubRouteTableV2Put() VirtualHubRouteTableV2Resource virtualHubRouteTableV2 = client.GetVirtualHubRouteTableV2Resource(virtualHubRouteTableV2ResourceId); // invoke the operation - VirtualHubRouteTableV2Data data = new VirtualHubRouteTableV2Data() - { - Routes = -{ -new VirtualHubRouteV2() -{ -DestinationType = "CIDR", -Destinations = -{ -"20.10.0.0/16","20.20.0.0/16" -}, -NextHopType = "IPAddress", -NextHops = -{ -"10.0.0.68" -}, -},new VirtualHubRouteV2() -{ -DestinationType = "CIDR", -Destinations = -{ -"0.0.0.0/0" -}, -NextHopType = "IPAddress", -NextHops = -{ -"10.0.0.68" -}, -} -}, - AttachedConnections = -{ -"All_Vnets" -}, - }; - ArmOperation lro = await virtualHubRouteTableV2.UpdateAsync(WaitUntil.Completed, data); - VirtualHubRouteTableV2Resource result = lro.Value; + await virtualHubRouteTableV2.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualHubRouteTableV2Data resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VirtualHubRouteTableV2Delete() + public async Task Update_VirtualHubRouteTableV2Put() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Delete.json - // this example is just showing the usage of "VirtualHubRouteTableV2s_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualHubRouteTableV2Put.json + // this example is just showing the usage of "VirtualHubRouteTableV2s_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -136,9 +96,31 @@ public async Task Delete_VirtualHubRouteTableV2Delete() VirtualHubRouteTableV2Resource virtualHubRouteTableV2 = client.GetVirtualHubRouteTableV2Resource(virtualHubRouteTableV2ResourceId); // invoke the operation - await virtualHubRouteTableV2.DeleteAsync(WaitUntil.Completed); + VirtualHubRouteTableV2Data data = new VirtualHubRouteTableV2Data + { + Routes = {new VirtualHubRouteV2 +{ +DestinationType = "CIDR", +Destinations = {"20.10.0.0/16", "20.20.0.0/16"}, +NextHopType = "IPAddress", +NextHops = {"10.0.0.68"}, +}, new VirtualHubRouteV2 +{ +DestinationType = "CIDR", +Destinations = {"0.0.0.0/0"}, +NextHopType = "IPAddress", +NextHops = {"10.0.0.68"}, +}}, + AttachedConnections = { "All_Vnets" }, + }; + ArmOperation lro = await virtualHubRouteTableV2.UpdateAsync(WaitUntil.Completed, data); + VirtualHubRouteTableV2Resource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualHubRouteTableV2Data resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkCollection.cs index a58131c9ee591..c434efb87bcde 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_VirtualNetworkCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetwork() + public async Task CreateOrUpdate_CreateVirtualNetwork() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGet.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreate.json + // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,14 @@ public async Task Get_GetVirtualNetwork() // invoke the operation string virtualNetworkName = "test-vnet"; - VirtualNetworkResource result = await collection.GetAsync(virtualNetworkName); + VirtualNetworkData data = new VirtualNetworkData + { + AddressPrefixes = { "10.0.0.0/16" }, + FlowTimeoutInMinutes = 10, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); + VirtualNetworkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +59,10 @@ public async Task Get_GetVirtualNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetwork() + public async Task CreateOrUpdate_CreateVirtualNetworkWithBgpCommunities() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGet.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateWithBgpCommunities.json + // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -74,17 +81,33 @@ public async Task Exists_GetVirtualNetwork() // invoke the operation string virtualNetworkName = "test-vnet"; - bool result = await collection.ExistsAsync(virtualNetworkName); + VirtualNetworkData data = new VirtualNetworkData + { + AddressPrefixes = { "10.0.0.0/16" }, + Subnets = {new SubnetData +{ +AddressPrefix = "10.0.0.0/24", +Name = "test-1", +}}, + BgpCommunities = new VirtualNetworkBgpCommunities("12076:20000"), + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); + VirtualNetworkResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetwork() + public async Task CreateOrUpdate_CreateVirtualNetworkWithDelegatedSubnets() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGet.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateSubnetWithDelegation.json + // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -93,7 +116,7 @@ public async Task GetIfExists_GetVirtualNetwork() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; + string subscriptionId = "subId"; string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -103,29 +126,37 @@ public async Task GetIfExists_GetVirtualNetwork() // invoke the operation string virtualNetworkName = "test-vnet"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); - VirtualNetworkResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + VirtualNetworkData data = new VirtualNetworkData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AddressPrefixes = { "10.0.0.0/16" }, + Subnets = {new SubnetData +{ +AddressPrefix = "10.0.0.0/24", +Delegations = {new ServiceDelegation +{ +ServiceName = "Microsoft.Sql/managedInstances", +Name = "myDelegation", +}}, +Name = "test-1", +}}, + Location = new AzureLocation("westcentralus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); + VirtualNetworkResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkWithADelegatedSubnet() + public async Task CreateOrUpdate_CreateVirtualNetworkWithEncryption() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithSubnetDelegation.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateWithEncryption.json + // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -134,7 +165,7 @@ public async Task Get_GetVirtualNetworkWithADelegatedSubnet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -144,7 +175,22 @@ public async Task Get_GetVirtualNetworkWithADelegatedSubnet() // invoke the operation string virtualNetworkName = "test-vnet"; - VirtualNetworkResource result = await collection.GetAsync(virtualNetworkName); + VirtualNetworkData data = new VirtualNetworkData + { + AddressPrefixes = { "10.0.0.0/16" }, + Subnets = {new SubnetData +{ +AddressPrefix = "10.0.0.0/24", +Name = "test-1", +}}, + Encryption = new VirtualNetworkEncryption(true) + { + Enforcement = VirtualNetworkEncryptionEnforcement.AllowUnencrypted, + }, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); + VirtualNetworkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -155,10 +201,10 @@ public async Task Get_GetVirtualNetworkWithADelegatedSubnet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetworkWithADelegatedSubnet() + public async Task CreateOrUpdate_CreateVirtualNetworkWithServiceEndpoints() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithSubnetDelegation.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateServiceEndpoints.json + // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -167,8 +213,8 @@ public async Task Exists_GetVirtualNetworkWithADelegatedSubnet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subId"; - string resourceGroupName = "rg1"; + string subscriptionId = "subid"; + string resourceGroupName = "vnetTest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -176,18 +222,37 @@ public async Task Exists_GetVirtualNetworkWithADelegatedSubnet() VirtualNetworkCollection collection = resourceGroupResource.GetVirtualNetworks(); // invoke the operation - string virtualNetworkName = "test-vnet"; - bool result = await collection.ExistsAsync(virtualNetworkName); + string virtualNetworkName = "vnet1"; + VirtualNetworkData data = new VirtualNetworkData + { + AddressPrefixes = { "10.0.0.0/16" }, + Subnets = {new SubnetData +{ +AddressPrefix = "10.0.0.0/16", +ServiceEndpoints = {new ServiceEndpointProperties +{ +Service = "Microsoft.Storage", +}}, +Name = "test-1", +}}, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); + VirtualNetworkResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetworkWithADelegatedSubnet() + public async Task CreateOrUpdate_CreateVirtualNetworkWithServiceEndpointsAndServiceEndpointPolicy() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithSubnetDelegation.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateServiceEndpointPolicy.json + // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -196,8 +261,8 @@ public async Task GetIfExists_GetVirtualNetworkWithADelegatedSubnet() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subId"; - string resourceGroupName = "rg1"; + string subscriptionId = "subid"; + string resourceGroupName = "vnetTest"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -205,30 +270,41 @@ public async Task GetIfExists_GetVirtualNetworkWithADelegatedSubnet() VirtualNetworkCollection collection = resourceGroupResource.GetVirtualNetworks(); // invoke the operation - string virtualNetworkName = "test-vnet"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); - VirtualNetworkResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + string virtualNetworkName = "vnet1"; + VirtualNetworkData data = new VirtualNetworkData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AddressPrefixes = { "10.0.0.0/16" }, + Subnets = {new SubnetData +{ +AddressPrefix = "10.0.0.0/16", +ServiceEndpoints = {new ServiceEndpointProperties +{ +Service = "Microsoft.Storage", +}}, +ServiceEndpointPolicies = {new ServiceEndpointPolicyData +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/vnetTest/providers/Microsoft.Network/serviceEndpointPolicies/ServiceEndpointPolicy1"), +}}, +Name = "test-1", +}}, + Location = new AzureLocation("eastus2euap"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); + VirtualNetworkResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkWithServiceAssociationLinks() + public async Task CreateOrUpdate_CreateVirtualNetworkWithSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithServiceAssociationLink.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateSubnet.json + // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -237,7 +313,7 @@ public async Task Get_GetVirtualNetworkWithServiceAssociationLinks() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -247,7 +323,18 @@ public async Task Get_GetVirtualNetworkWithServiceAssociationLinks() // invoke the operation string virtualNetworkName = "test-vnet"; - VirtualNetworkResource result = await collection.GetAsync(virtualNetworkName); + VirtualNetworkData data = new VirtualNetworkData + { + AddressPrefixes = { "10.0.0.0/16" }, + Subnets = {new SubnetData +{ +AddressPrefix = "10.0.0.0/24", +Name = "test-1", +}}, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); + VirtualNetworkResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -258,10 +345,10 @@ public async Task Get_GetVirtualNetworkWithServiceAssociationLinks() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetworkWithServiceAssociationLinks() + public async Task CreateOrUpdate_CreateVirtualNetworkWithSubnetContainingAddressPrefixes() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithServiceAssociationLink.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateSubnetWithAddressPrefixes.json + // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -270,7 +357,7 @@ public async Task Exists_GetVirtualNetworkWithServiceAssociationLinks() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -280,16 +367,31 @@ public async Task Exists_GetVirtualNetworkWithServiceAssociationLinks() // invoke the operation string virtualNetworkName = "test-vnet"; - bool result = await collection.ExistsAsync(virtualNetworkName); + VirtualNetworkData data = new VirtualNetworkData + { + AddressPrefixes = { "10.0.0.0/16" }, + Subnets = {new SubnetData +{ +AddressPrefixes = {"10.0.0.0/28", "10.0.1.0/28"}, +Name = "test-2", +}}, + Location = new AzureLocation("eastus"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); + VirtualNetworkResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetworkWithServiceAssociationLinks() + public async Task Get_GetVirtualNetwork() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithServiceAssociationLink.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGet.json // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -299,7 +401,7 @@ public async Task GetIfExists_GetVirtualNetworkWithServiceAssociationLinks() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -309,29 +411,21 @@ public async Task GetIfExists_GetVirtualNetworkWithServiceAssociationLinks() // invoke the operation string virtualNetworkName = "test-vnet"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); - VirtualNetworkResource result = response.HasValue ? response.Value : null; + VirtualNetworkResource result = await collection.GetAsync(virtualNetworkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetwork() + public async Task Get_GetVirtualNetworkWithADelegatedSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreate.json - // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithSubnetDelegation.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -340,7 +434,7 @@ public async Task CreateOrUpdate_CreateVirtualNetwork() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; + string subscriptionId = "subId"; string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -350,17 +444,7 @@ public async Task CreateOrUpdate_CreateVirtualNetwork() // invoke the operation string virtualNetworkName = "test-vnet"; - VirtualNetworkData data = new VirtualNetworkData() - { - AddressPrefixes = -{ -"10.0.0.0/16" -}, - FlowTimeoutInMinutes = 10, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); - VirtualNetworkResource result = lro.Value; + VirtualNetworkResource result = await collection.GetAsync(virtualNetworkName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -371,10 +455,10 @@ public async Task CreateOrUpdate_CreateVirtualNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkWithBgpCommunities() + public async Task Get_GetVirtualNetworkWithServiceAssociationLinks() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateWithBgpCommunities.json - // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithServiceAssociationLink.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -383,7 +467,7 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithBgpCommunities() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; + string subscriptionId = "subId"; string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -393,25 +477,7 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithBgpCommunities() // invoke the operation string virtualNetworkName = "test-vnet"; - VirtualNetworkData data = new VirtualNetworkData() - { - AddressPrefixes = -{ -"10.0.0.0/16" -}, - Subnets = -{ -new SubnetData() -{ -AddressPrefix = "10.0.0.0/24", -Name = "test-1", -} -}, - BgpCommunities = new VirtualNetworkBgpCommunities("12076:20000"), - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); - VirtualNetworkResource result = lro.Value; + VirtualNetworkResource result = await collection.GetAsync(virtualNetworkName); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -422,10 +488,10 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithBgpCommunities() [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkWithDelegatedSubnets() + public async Task GetAll_ListVirtualNetworksInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateSubnetWithDelegation.json - // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkList.json + // this example is just showing the usage of "VirtualNetworks_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -434,7 +500,7 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithDelegatedSubnets() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -442,48 +508,25 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithDelegatedSubnets() // get the collection of this VirtualNetworkResource VirtualNetworkCollection collection = resourceGroupResource.GetVirtualNetworks(); - // invoke the operation - string virtualNetworkName = "test-vnet"; - VirtualNetworkData data = new VirtualNetworkData() + // invoke the operation and iterate over the result + await foreach (VirtualNetworkResource item in collection.GetAllAsync()) { - AddressPrefixes = -{ -"10.0.0.0/16" -}, - Subnets = -{ -new SubnetData() -{ -AddressPrefix = "10.0.0.0/24", -Delegations = -{ -new ServiceDelegation() -{ -ServiceName = "Microsoft.Sql/managedInstances", -Name = "myDelegation", -} -}, -Name = "test-1", -} -}, - Location = new AzureLocation("westcentralus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); - VirtualNetworkResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkWithEncryption() + public async Task Exists_GetVirtualNetwork() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateWithEncryption.json - // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGet.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -502,42 +545,17 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithEncryption() // invoke the operation string virtualNetworkName = "test-vnet"; - VirtualNetworkData data = new VirtualNetworkData() - { - AddressPrefixes = -{ -"10.0.0.0/16" -}, - Subnets = -{ -new SubnetData() -{ -AddressPrefix = "10.0.0.0/24", -Name = "test-1", -} -}, - Encryption = new VirtualNetworkEncryption(true) - { - Enforcement = VirtualNetworkEncryptionEnforcement.AllowUnencrypted, - }, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); - VirtualNetworkResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualNetworkName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkWithServiceEndpoints() + public async Task Exists_GetVirtualNetworkWithADelegatedSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateServiceEndpoints.json - // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithSubnetDelegation.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -546,8 +564,8 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithServiceEndpoints() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "vnetTest"; + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -555,46 +573,18 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithServiceEndpoints() VirtualNetworkCollection collection = resourceGroupResource.GetVirtualNetworks(); // invoke the operation - string virtualNetworkName = "vnet1"; - VirtualNetworkData data = new VirtualNetworkData() - { - AddressPrefixes = -{ -"10.0.0.0/16" -}, - Subnets = -{ -new SubnetData() -{ -AddressPrefix = "10.0.0.0/16", -ServiceEndpoints = -{ -new ServiceEndpointProperties() -{ -Service = "Microsoft.Storage", -} -}, -Name = "test-1", -} -}, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); - VirtualNetworkResource result = lro.Value; + string virtualNetworkName = "test-vnet"; + bool result = await collection.ExistsAsync(virtualNetworkName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkWithServiceEndpointsAndServiceEndpointPolicy() + public async Task Exists_GetVirtualNetworkWithServiceAssociationLinks() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateServiceEndpointPolicy.json - // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithServiceAssociationLink.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -603,8 +593,8 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithServiceEndpointsAndServ // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "vnetTest"; + string subscriptionId = "subId"; + string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -612,53 +602,18 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithServiceEndpointsAndServ VirtualNetworkCollection collection = resourceGroupResource.GetVirtualNetworks(); // invoke the operation - string virtualNetworkName = "vnet1"; - VirtualNetworkData data = new VirtualNetworkData() - { - AddressPrefixes = -{ -"10.0.0.0/16" -}, - Subnets = -{ -new SubnetData() -{ -AddressPrefix = "10.0.0.0/16", -ServiceEndpoints = -{ -new ServiceEndpointProperties() -{ -Service = "Microsoft.Storage", -} -}, -ServiceEndpointPolicies = -{ -new ServiceEndpointPolicyData() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/vnetTest/providers/Microsoft.Network/serviceEndpointPolicies/ServiceEndpointPolicy1"), -} -}, -Name = "test-1", -} -}, - Location = new AzureLocation("eastus2euap"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); - VirtualNetworkResource result = lro.Value; + string virtualNetworkName = "test-vnet"; + bool result = await collection.ExistsAsync(virtualNetworkName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkWithSubnet() + public async Task GetIfExists_GetVirtualNetwork() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateSubnet.json - // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGet.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -677,38 +632,29 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithSubnet() // invoke the operation string virtualNetworkName = "test-vnet"; - VirtualNetworkData data = new VirtualNetworkData() - { - AddressPrefixes = -{ -"10.0.0.0/16" -}, - Subnets = -{ -new SubnetData() -{ -AddressPrefix = "10.0.0.0/24", -Name = "test-1", -} -}, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); - VirtualNetworkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); + VirtualNetworkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkWithSubnetContainingAddressPrefixes() + public async Task GetIfExists_GetVirtualNetworkWithADelegatedSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkCreateSubnetWithAddressPrefixes.json - // this example is just showing the usage of "VirtualNetworks_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithSubnetDelegation.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -717,7 +663,7 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithSubnetContainingAddress // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; + string subscriptionId = "subId"; string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -727,41 +673,29 @@ public async Task CreateOrUpdate_CreateVirtualNetworkWithSubnetContainingAddress // invoke the operation string virtualNetworkName = "test-vnet"; - VirtualNetworkData data = new VirtualNetworkData() - { - AddressPrefixes = -{ -"10.0.0.0/16" -}, - Subnets = -{ -new SubnetData() -{ -AddressPrefixes = -{ -"10.0.0.0/28","10.0.1.0/28" -}, -Name = "test-2", -} -}, - Location = new AzureLocation("eastus"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkName, data); - VirtualNetworkResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); + VirtualNetworkResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworksInResourceGroup() + public async Task GetIfExists_GetVirtualNetworkWithServiceAssociationLinks() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkList.json - // this example is just showing the usage of "VirtualNetworks_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithServiceAssociationLink.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -770,7 +704,7 @@ public async Task GetAll_ListVirtualNetworksInResourceGroup() // this example assumes you already have this ResourceGroupResource created on azure // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; + string subscriptionId = "subId"; string resourceGroupName = "rg1"; ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); @@ -778,17 +712,23 @@ public async Task GetAll_ListVirtualNetworksInResourceGroup() // get the collection of this VirtualNetworkResource VirtualNetworkCollection collection = resourceGroupResource.GetVirtualNetworks(); - // invoke the operation and iterate over the result - await foreach (VirtualNetworkResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkName = "test-vnet"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkName); + VirtualNetworkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = item.Data; + VirtualNetworkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayCollection.cs index e627cf37a2452..1ebe7611b1ae5 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayCollection.cs @@ -41,106 +41,75 @@ public async Task CreateOrUpdate_UpdateVirtualNetworkGateway() // invoke the operation string virtualNetworkGatewayName = "vpngw"; - VirtualNetworkGatewayData data = new VirtualNetworkGatewayData() + VirtualNetworkGatewayData data = new VirtualNetworkGatewayData { - IPConfigurations = -{ -new VirtualNetworkGatewayIPConfiguration() + IPConfigurations = {new VirtualNetworkGatewayIPConfiguration { PrivateIPAllocationMethod = NetworkIPAllocationMethod.Dynamic, SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/GatewaySubnet"), PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/gwpip"), Name = "gwipconfig1", -} -}, +}}, GatewayType = VirtualNetworkGatewayType.Vpn, VpnType = VpnType.RouteBased, EnableBgp = false, Active = false, DisableIPSecReplayProtection = false, - Sku = new VirtualNetworkGatewaySku() + Sku = new VirtualNetworkGatewaySku { Name = VirtualNetworkGatewaySkuName.VpnGw1, Tier = VirtualNetworkGatewaySkuTier.VpnGw1, }, - VpnClientConfiguration = new VpnClientConfiguration() + VpnClientConfiguration = new VpnClientConfiguration { - VpnClientRootCertificates = -{ -}, - VpnClientRevokedCertificates = -{ -}, - VpnClientProtocols = -{ -VpnClientProtocol.OpenVpn -}, - RadiusServers = -{ -new RadiusServer("10.2.0.0") + VpnClientRootCertificates = { }, + VpnClientRevokedCertificates = { }, + VpnClientProtocols = { VpnClientProtocol.OpenVpn }, + RadiusServers = {new RadiusServer("10.2.0.0") { RadiusServerScore = 20L, RadiusServerSecret = "radiusServerSecret", -} -}, +}}, }, - BgpSettings = new BgpSettings() + BgpSettings = new BgpSettings { Asn = 65515L, BgpPeeringAddress = "10.0.1.30", PeerWeight = 0, }, - CustomRoutesAddressPrefixes = -{ -"101.168.0.6/32" -}, + CustomRoutesAddressPrefixes = { "101.168.0.6/32" }, EnableDnsForwarding = true, - NatRules = -{ -new VirtualNetworkGatewayNatRuleData() + NatRules = {new VirtualNetworkGatewayNatRuleData { VpnNatRuleType = VpnNatRuleType.Static, Mode = VpnNatRuleMode.EgressSnat, -InternalMappings = -{ -new VpnNatRuleMapping() +InternalMappings = {new VpnNatRuleMapping { AddressSpace = "10.10.0.0/24", -} -}, -ExternalMappings = -{ -new VpnNatRuleMapping() +}}, +ExternalMappings = {new VpnNatRuleMapping { AddressSpace = "50.0.0.0/24", -} -}, +}}, IPConfigurationId = "", Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/natRules/natRule1"), Name = "natRule1", -},new VirtualNetworkGatewayNatRuleData() +}, new VirtualNetworkGatewayNatRuleData { VpnNatRuleType = VpnNatRuleType.Static, Mode = VpnNatRuleMode.IngressSnat, -InternalMappings = -{ -new VpnNatRuleMapping() +InternalMappings = {new VpnNatRuleMapping { AddressSpace = "20.10.0.0/24", -} -}, -ExternalMappings = -{ -new VpnNatRuleMapping() +}}, +ExternalMappings = {new VpnNatRuleMapping { AddressSpace = "30.0.0.0/24", -} -}, +}}, IPConfigurationId = "", Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/natRules/natRule2"), Name = "natRule2", -} -}, +}}, EnableBgpRouteTranslationForNat = false, AllowVirtualWanTraffic = false, AllowRemoteVnetTraffic = false, @@ -180,76 +149,58 @@ public async Task CreateOrUpdate_UpdateVirtualNetworkScalableGateway() // invoke the operation string virtualNetworkGatewayName = "ergw"; - VirtualNetworkGatewayData data = new VirtualNetworkGatewayData() + VirtualNetworkGatewayData data = new VirtualNetworkGatewayData { - IPConfigurations = -{ -new VirtualNetworkGatewayIPConfiguration() + IPConfigurations = {new VirtualNetworkGatewayIPConfiguration { PrivateIPAllocationMethod = NetworkIPAllocationMethod.Static, SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/GatewaySubnet"), PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/gwpip"), Name = "gwipconfig1", -} -}, +}}, GatewayType = VirtualNetworkGatewayType.ExpressRoute, VpnType = VpnType.PolicyBased, EnableBgp = false, Active = false, DisableIPSecReplayProtection = false, - Sku = new VirtualNetworkGatewaySku() + Sku = new VirtualNetworkGatewaySku { Name = VirtualNetworkGatewaySkuName.ErGwScale, Tier = VirtualNetworkGatewaySkuTier.ErGwScale, }, - VpnClientConfiguration = null, - BgpSettings = null, - NatRules = -{ -new VirtualNetworkGatewayNatRuleData() + VpnClientConfiguration = default, + BgpSettings = default, + NatRules = {new VirtualNetworkGatewayNatRuleData { VpnNatRuleType = VpnNatRuleType.Static, Mode = VpnNatRuleMode.EgressSnat, -InternalMappings = -{ -new VpnNatRuleMapping() +InternalMappings = {new VpnNatRuleMapping { AddressSpace = "10.10.0.0/24", -} -}, -ExternalMappings = -{ -new VpnNatRuleMapping() +}}, +ExternalMappings = {new VpnNatRuleMapping { AddressSpace = "50.0.0.0/24", -} -}, +}}, IPConfigurationId = "", Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/ergw/natRules/natRule1"), Name = "natRule1", -},new VirtualNetworkGatewayNatRuleData() +}, new VirtualNetworkGatewayNatRuleData { VpnNatRuleType = VpnNatRuleType.Static, Mode = VpnNatRuleMode.IngressSnat, -InternalMappings = -{ -new VpnNatRuleMapping() +InternalMappings = {new VpnNatRuleMapping { AddressSpace = "20.10.0.0/24", -} -}, -ExternalMappings = -{ -new VpnNatRuleMapping() +}}, +ExternalMappings = {new VpnNatRuleMapping { AddressSpace = "30.0.0.0/24", -} -}, +}}, IPConfigurationId = "", Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/ergw/natRules/natRule2"), Name = "natRule2", -} -}, +}}, EnableBgpRouteTranslationForNat = false, AllowVirtualWanTraffic = false, AllowRemoteVnetTraffic = false, @@ -300,9 +251,9 @@ public async Task Get_GetVirtualNetworkGateway() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetworkGateway() + public async Task Get_GetVirtualNetworkScalableGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkScalableGatewayGet.json // this example is just showing the usage of "VirtualNetworkGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -321,18 +272,22 @@ public async Task Exists_GetVirtualNetworkGateway() VirtualNetworkGatewayCollection collection = resourceGroupResource.GetVirtualNetworkGateways(); // invoke the operation - string virtualNetworkGatewayName = "vpngw"; - bool result = await collection.ExistsAsync(virtualNetworkGatewayName); + string virtualNetworkGatewayName = "ergw"; + VirtualNetworkGatewayResource result = await collection.GetAsync(virtualNetworkGatewayName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetworkGateway() + public async Task GetAll_ListVirtualNetworkGatewaysinResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayGet.json - // this example is just showing the usage of "VirtualNetworkGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayList.json + // this example is just showing the usage of "VirtualNetworkGateways_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -349,30 +304,24 @@ public async Task GetIfExists_GetVirtualNetworkGateway() // get the collection of this VirtualNetworkGatewayResource VirtualNetworkGatewayCollection collection = resourceGroupResource.GetVirtualNetworkGateways(); - // invoke the operation - string virtualNetworkGatewayName = "vpngw"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkGatewayName); - VirtualNetworkGatewayResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualNetworkGatewayResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkGatewayData resourceData = result.Data; + VirtualNetworkGatewayData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkScalableGateway() + public async Task Exists_GetVirtualNetworkGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkScalableGatewayGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayGet.json // this example is just showing the usage of "VirtualNetworkGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -391,14 +340,10 @@ public async Task Get_GetVirtualNetworkScalableGateway() VirtualNetworkGatewayCollection collection = resourceGroupResource.GetVirtualNetworkGateways(); // invoke the operation - string virtualNetworkGatewayName = "ergw"; - VirtualNetworkGatewayResource result = await collection.GetAsync(virtualNetworkGatewayName); + string virtualNetworkGatewayName = "vpngw"; + bool result = await collection.ExistsAsync(virtualNetworkGatewayName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -432,9 +377,9 @@ public async Task Exists_GetVirtualNetworkScalableGateway() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetworkScalableGateway() + public async Task GetIfExists_GetVirtualNetworkGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkScalableGatewayGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayGet.json // this example is just showing the usage of "VirtualNetworkGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -453,7 +398,7 @@ public async Task GetIfExists_GetVirtualNetworkScalableGateway() VirtualNetworkGatewayCollection collection = resourceGroupResource.GetVirtualNetworkGateways(); // invoke the operation - string virtualNetworkGatewayName = "ergw"; + string virtualNetworkGatewayName = "vpngw"; NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkGatewayName); VirtualNetworkGatewayResource result = response.HasValue ? response.Value : null; @@ -473,10 +418,10 @@ public async Task GetIfExists_GetVirtualNetworkScalableGateway() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworkGatewaysinResourceGroup() + public async Task GetIfExists_GetVirtualNetworkScalableGateway() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayList.json - // this example is just showing the usage of "VirtualNetworkGateways_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkScalableGatewayGet.json + // this example is just showing the usage of "VirtualNetworkGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -493,17 +438,23 @@ public async Task GetAll_ListVirtualNetworkGatewaysinResourceGroup() // get the collection of this VirtualNetworkGatewayResource VirtualNetworkGatewayCollection collection = resourceGroupResource.GetVirtualNetworkGateways(); - // invoke the operation and iterate over the result - await foreach (VirtualNetworkGatewayResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkGatewayName = "ergw"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkGatewayName); + VirtualNetworkGatewayResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkGatewayData resourceData = item.Data; + VirtualNetworkGatewayData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayConnectionCollection.cs index 87f299bb8af8e..fde20683a66e2 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayConnectionCollection.cs @@ -42,29 +42,26 @@ public async Task CreateOrUpdate_CreateVirtualNetworkGatewayConnectionS2S() // invoke the operation string virtualNetworkGatewayConnectionName = "connS2S"; - VirtualNetworkGatewayConnectionData data = new VirtualNetworkGatewayConnectionData(new VirtualNetworkGatewayData() + VirtualNetworkGatewayConnectionData data = new VirtualNetworkGatewayConnectionData(new VirtualNetworkGatewayData { - IPConfigurations = -{ -new VirtualNetworkGatewayIPConfiguration() + IPConfigurations = {new VirtualNetworkGatewayIPConfiguration { PrivateIPAllocationMethod = NetworkIPAllocationMethod.Dynamic, SubnetId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworks/vnet1/subnets/GatewaySubnet"), PublicIPAddressId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/publicIPAddresses/gwpip"), Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/ipConfigurations/gwipconfig1"), Name = "gwipconfig1", -} -}, +}}, GatewayType = VirtualNetworkGatewayType.Vpn, VpnType = VpnType.RouteBased, EnableBgp = false, Active = false, - Sku = new VirtualNetworkGatewaySku() + Sku = new VirtualNetworkGatewaySku { Name = VirtualNetworkGatewaySkuName.VpnGw1, Tier = VirtualNetworkGatewaySkuTier.VpnGw1, }, - BgpSettings = new BgpSettings() + BgpSettings = new BgpSettings { Asn = 65514L, BgpPeeringAddress = "10.0.1.30", @@ -72,55 +69,35 @@ public async Task CreateOrUpdate_CreateVirtualNetworkGatewayConnectionS2S() }, Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw"), Location = new AzureLocation("centralus"), - Tags = -{ -}, + Tags = { }, }, VirtualNetworkGatewayConnectionType.IPsec) { - LocalNetworkGateway2 = new LocalNetworkGatewayData() + LocalNetworkGateway2 = new LocalNetworkGatewayData { - LocalNetworkAddressPrefixes = -{ -"10.1.0.0/16" -}, + LocalNetworkAddressPrefixes = { "10.1.0.0/16" }, GatewayIPAddress = "x.x.x.x", Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/localNetworkGateways/localgw"), Location = new AzureLocation("centralus"), - Tags = -{ -}, + Tags = { }, }, - IngressNatRules = -{ -new WritableSubResource() + IngressNatRules = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/natRules/natRule1"), -} -}, - EgressNatRules = -{ -new WritableSubResource() +}}, + EgressNatRules = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/natRules/natRule2"), -} -}, +}}, ConnectionProtocol = VirtualNetworkGatewayConnectionProtocol.IkeV2, RoutingWeight = 0, DpdTimeoutSeconds = 30, ConnectionMode = VirtualNetworkGatewayConnectionMode.Default, SharedKey = "Abc123", EnableBgp = false, - GatewayCustomBgpIPAddresses = -{ -new GatewayCustomBgpIPAddressIPConfiguration("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/ipConfigurations/default","169.254.21.1"),new GatewayCustomBgpIPAddressIPConfiguration("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/ipConfigurations/ActiveActive","169.254.21.3") -}, + GatewayCustomBgpIPAddresses = { new GatewayCustomBgpIPAddressIPConfiguration("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/ipConfigurations/default", "169.254.21.1"), new GatewayCustomBgpIPAddressIPConfiguration("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vpngw/ipConfigurations/ActiveActive", "169.254.21.3") }, UsePolicyBasedTrafficSelectors = false, - IPsecPolicies = -{ -}, - TrafficSelectorPolicies = -{ -}, + IPsecPolicies = { }, + TrafficSelectorPolicies = { }, Location = new AzureLocation("centralus"), }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkGatewayConnectionName, data); @@ -168,10 +145,10 @@ public async Task Get_GetVirtualNetworkGatewayConnection() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetworkGatewayConnection() + public async Task GetAll_ListVirtualNetworkGatewayConnectionsinResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayConnectionGet.json - // this example is just showing the usage of "VirtualNetworkGatewayConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayConnectionsList.json + // this example is just showing the usage of "VirtualNetworkGatewayConnections_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -188,16 +165,22 @@ public async Task Exists_GetVirtualNetworkGatewayConnection() // get the collection of this VirtualNetworkGatewayConnectionResource VirtualNetworkGatewayConnectionCollection collection = resourceGroupResource.GetVirtualNetworkGatewayConnections(); - // invoke the operation - string virtualNetworkGatewayConnectionName = "connS2S"; - bool result = await collection.ExistsAsync(virtualNetworkGatewayConnectionName); + // invoke the operation and iterate over the result + await foreach (VirtualNetworkGatewayConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkGatewayConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetworkGatewayConnection() + public async Task Exists_GetVirtualNetworkGatewayConnection() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayConnectionGet.json // this example is just showing the usage of "VirtualNetworkGatewayConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -219,29 +202,17 @@ public async Task GetIfExists_GetVirtualNetworkGatewayConnection() // invoke the operation string virtualNetworkGatewayConnectionName = "connS2S"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkGatewayConnectionName); - VirtualNetworkGatewayConnectionResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(virtualNetworkGatewayConnectionName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkGatewayConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworkGatewayConnectionsinResourceGroup() + public async Task GetIfExists_GetVirtualNetworkGatewayConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayConnectionsList.json - // this example is just showing the usage of "VirtualNetworkGatewayConnections_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayConnectionGet.json + // this example is just showing the usage of "VirtualNetworkGatewayConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -258,17 +229,23 @@ public async Task GetAll_ListVirtualNetworkGatewayConnectionsinResourceGroup() // get the collection of this VirtualNetworkGatewayConnectionResource VirtualNetworkGatewayConnectionCollection collection = resourceGroupResource.GetVirtualNetworkGatewayConnections(); - // invoke the operation and iterate over the result - await foreach (VirtualNetworkGatewayConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkGatewayConnectionName = "connS2S"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkGatewayConnectionName); + VirtualNetworkGatewayConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkGatewayConnectionData resourceData = item.Data; + VirtualNetworkGatewayConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayConnectionResource.cs index 2abb320139a7a..ad0a5cd64e046 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayConnectionResource.cs @@ -16,38 +16,6 @@ namespace Azure.ResourceManager.Network.Samples { public partial class Sample_VirtualNetworkGatewayConnectionResource { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task VpnDeviceConfigurationScript_GetVPNDeviceConfigurationScript() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayVpnDeviceConfigurationScript.json - // this example is just showing the usage of "VirtualNetworkGateways_VpnDeviceConfigurationScript" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualNetworkGatewayConnectionResource created on azure - // for more information of creating VirtualNetworkGatewayConnectionResource, please refer to the document of VirtualNetworkGatewayConnectionResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string virtualNetworkGatewayConnectionName = "vpngw"; - ResourceIdentifier virtualNetworkGatewayConnectionResourceId = VirtualNetworkGatewayConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkGatewayConnectionName); - VirtualNetworkGatewayConnectionResource virtualNetworkGatewayConnection = client.GetVirtualNetworkGatewayConnectionResource(virtualNetworkGatewayConnectionResourceId); - - // invoke the operation - VpnDeviceScriptContent content = new VpnDeviceScriptContent() - { - Vendor = "Cisco", - DeviceFamily = "ISR", - FirmwareVersion = "IOS 15.1 (Preview)", - }; - string result = await virtualNetworkGatewayConnection.VpnDeviceConfigurationScriptAsync(content); - - Console.WriteLine($"Succeeded: {result}"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task Get_GetVirtualNetworkGatewayConnection() @@ -125,12 +93,12 @@ public async Task Update_UpdateVirtualNetworkGatewayConnectionTags() VirtualNetworkGatewayConnectionResource virtualNetworkGatewayConnection = client.GetVirtualNetworkGatewayConnectionResource(virtualNetworkGatewayConnectionResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await virtualNetworkGatewayConnection.UpdateAsync(WaitUntil.Completed, networkTagsObject); @@ -143,6 +111,38 @@ public async Task Update_UpdateVirtualNetworkGatewayConnectionTags() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task VpnDeviceConfigurationScript_GetVPNDeviceConfigurationScript() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayVpnDeviceConfigurationScript.json + // this example is just showing the usage of "VirtualNetworkGateways_VpnDeviceConfigurationScript" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualNetworkGatewayConnectionResource created on azure + // for more information of creating VirtualNetworkGatewayConnectionResource, please refer to the document of VirtualNetworkGatewayConnectionResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string virtualNetworkGatewayConnectionName = "vpngw"; + ResourceIdentifier virtualNetworkGatewayConnectionResourceId = VirtualNetworkGatewayConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkGatewayConnectionName); + VirtualNetworkGatewayConnectionResource virtualNetworkGatewayConnection = client.GetVirtualNetworkGatewayConnectionResource(virtualNetworkGatewayConnectionResourceId); + + // invoke the operation + VpnDeviceScriptContent content = new VpnDeviceScriptContent + { + Vendor = "Cisco", + DeviceFamily = "ISR", + FirmwareVersion = "IOS 15.1 (Preview)", + }; + string result = await virtualNetworkGatewayConnection.VpnDeviceConfigurationScriptAsync(content); + + Console.WriteLine($"Succeeded: {result}"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task SetSharedKey_SetVirtualNetworkGatewayConnectionSharedKey() @@ -246,7 +246,7 @@ public async Task StartPacketCapture_StartPacketCaptureOnVirtualNetworkGatewayCo VirtualNetworkGatewayConnectionResource virtualNetworkGatewayConnection = client.GetVirtualNetworkGatewayConnectionResource(virtualNetworkGatewayConnectionResourceId); // invoke the operation - VpnPacketCaptureStartContent content = new VpnPacketCaptureStartContent() + VpnPacketCaptureStartContent content = new VpnPacketCaptureStartContent { FilterData = "{'TracingFlags': 11,'MaxPacketBufferSize': 120,'MaxFileSize': 200,'Filters': [{'SourceSubnets': ['20.1.1.0/24'],'DestinationSubnets': ['10.1.1.0/24'],'SourcePort': [500],'DestinationPort': [4500],'Protocol': 6,'TcpFlags': 16,'CaptureSingleDirectionTrafficOnly': true}]}", }; @@ -304,7 +304,7 @@ public async Task StopPacketCapture_StopPacketCaptureOnVirtualNetworkGatewayConn VirtualNetworkGatewayConnectionResource virtualNetworkGatewayConnection = client.GetVirtualNetworkGatewayConnectionResource(virtualNetworkGatewayConnectionResourceId); // invoke the operation - VpnPacketCaptureStopContent content = new VpnPacketCaptureStopContent() + VpnPacketCaptureStopContent content = new VpnPacketCaptureStopContent { SasUri = new Uri("https://teststorage.blob.core.windows.net/?sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2019-09-13T07:44:05Z&st=2019-09-06T23:44:05Z&spr=https&sig=V1h9D1riltvZMI69d6ihENnFo%2FrCvTqGgjO2lf%2FVBhE%3D"), }; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayNatRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayNatRuleCollection.cs index e8496dc35bf00..b278947f90bf3 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayNatRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayNatRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualNetworkGatewayNatRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualNetworkGatewayNatRuleGet() + public async Task CreateOrUpdate_VirtualNetworkGatewayNatRulePut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRuleGet.json - // this example is just showing the usage of "VirtualNetworkGatewayNatRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRulePut.json + // this example is just showing the usage of "VirtualNetworkGatewayNatRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,24 @@ public async Task Get_VirtualNetworkGatewayNatRuleGet() // invoke the operation string natRuleName = "natRule1"; - VirtualNetworkGatewayNatRuleResource result = await collection.GetAsync(natRuleName); + VirtualNetworkGatewayNatRuleData data = new VirtualNetworkGatewayNatRuleData + { + VpnNatRuleType = VpnNatRuleType.Static, + Mode = VpnNatRuleMode.EgressSnat, + InternalMappings = {new VpnNatRuleMapping +{ +AddressSpace = "10.4.0.0/24", +PortRange = "200-300", +}}, + ExternalMappings = {new VpnNatRuleMapping +{ +AddressSpace = "192.168.21.0/24", +PortRange = "300-400", +}}, + IPConfigurationId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/gateway1/ipConfigurations/default", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, natRuleName, data); + VirtualNetworkGatewayNatRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +69,7 @@ public async Task Get_VirtualNetworkGatewayNatRuleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualNetworkGatewayNatRuleGet() + public async Task Get_VirtualNetworkGatewayNatRuleGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRuleGet.json // this example is just showing the usage of "VirtualNetworkGatewayNatRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +92,21 @@ public async Task Exists_VirtualNetworkGatewayNatRuleGet() // invoke the operation string natRuleName = "natRule1"; - bool result = await collection.ExistsAsync(natRuleName); + VirtualNetworkGatewayNatRuleResource result = await collection.GetAsync(natRuleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkGatewayNatRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualNetworkGatewayNatRuleGet() + public async Task GetAll_VirtualNetworkGatewayNatRuleList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRuleGet.json - // this example is just showing the usage of "VirtualNetworkGatewayNatRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRuleList.json + // this example is just showing the usage of "VirtualNetworkGatewayNatRules_ListByVirtualNetworkGateway" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +124,25 @@ public async Task GetIfExists_VirtualNetworkGatewayNatRuleGet() // get the collection of this VirtualNetworkGatewayNatRuleResource VirtualNetworkGatewayNatRuleCollection collection = virtualNetworkGateway.GetVirtualNetworkGatewayNatRules(); - // invoke the operation - string natRuleName = "natRule1"; - NullableResponse response = await collection.GetIfExistsAsync(natRuleName); - VirtualNetworkGatewayNatRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualNetworkGatewayNatRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkGatewayNatRuleData resourceData = result.Data; + VirtualNetworkGatewayNatRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VirtualNetworkGatewayNatRulePut() + public async Task Exists_VirtualNetworkGatewayNatRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRulePut.json - // this example is just showing the usage of "VirtualNetworkGatewayNatRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRuleGet.json + // this example is just showing the usage of "VirtualNetworkGatewayNatRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,44 +162,17 @@ public async Task CreateOrUpdate_VirtualNetworkGatewayNatRulePut() // invoke the operation string natRuleName = "natRule1"; - VirtualNetworkGatewayNatRuleData data = new VirtualNetworkGatewayNatRuleData() - { - VpnNatRuleType = VpnNatRuleType.Static, - Mode = VpnNatRuleMode.EgressSnat, - InternalMappings = -{ -new VpnNatRuleMapping() -{ -AddressSpace = "10.4.0.0/24", -PortRange = "200-300", -} -}, - ExternalMappings = -{ -new VpnNatRuleMapping() -{ -AddressSpace = "192.168.21.0/24", -PortRange = "300-400", -} -}, - IPConfigurationId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/gateway1/ipConfigurations/default", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, natRuleName, data); - VirtualNetworkGatewayNatRuleResource result = lro.Value; + bool result = await collection.ExistsAsync(natRuleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkGatewayNatRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualNetworkGatewayNatRuleList() + public async Task GetIfExists_VirtualNetworkGatewayNatRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRuleList.json - // this example is just showing the usage of "VirtualNetworkGatewayNatRules_ListByVirtualNetworkGateway" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRuleGet.json + // this example is just showing the usage of "VirtualNetworkGatewayNatRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -202,17 +190,23 @@ public async Task GetAll_VirtualNetworkGatewayNatRuleList() // get the collection of this VirtualNetworkGatewayNatRuleResource VirtualNetworkGatewayNatRuleCollection collection = virtualNetworkGateway.GetVirtualNetworkGatewayNatRules(); - // invoke the operation and iterate over the result - await foreach (VirtualNetworkGatewayNatRuleResource item in collection.GetAllAsync()) + // invoke the operation + string natRuleName = "natRule1"; + NullableResponse response = await collection.GetIfExistsAsync(natRuleName); + VirtualNetworkGatewayNatRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkGatewayNatRuleData resourceData = item.Data; + VirtualNetworkGatewayNatRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayNatRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayNatRuleResource.cs index 7ee8c1a0e5ec4..40d136006d6e8 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayNatRuleResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayNatRuleResource.cs @@ -49,10 +49,10 @@ public async Task Get_VirtualNetworkGatewayNatRuleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VirtualNetworkGatewayNatRulePut() + public async Task Delete_VirtualNetworkGatewayNatRuleDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRulePut.json - // this example is just showing the usage of "VirtualNetworkGatewayNatRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRuleDelete.json + // this example is just showing the usage of "VirtualNetworkGatewayNatRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,44 +69,17 @@ public async Task Update_VirtualNetworkGatewayNatRulePut() VirtualNetworkGatewayNatRuleResource virtualNetworkGatewayNatRule = client.GetVirtualNetworkGatewayNatRuleResource(virtualNetworkGatewayNatRuleResourceId); // invoke the operation - VirtualNetworkGatewayNatRuleData data = new VirtualNetworkGatewayNatRuleData() - { - VpnNatRuleType = VpnNatRuleType.Static, - Mode = VpnNatRuleMode.EgressSnat, - InternalMappings = -{ -new VpnNatRuleMapping() -{ -AddressSpace = "10.4.0.0/24", -PortRange = "200-300", -} -}, - ExternalMappings = -{ -new VpnNatRuleMapping() -{ -AddressSpace = "192.168.21.0/24", -PortRange = "300-400", -} -}, - IPConfigurationId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/gateway1/ipConfigurations/default", - }; - ArmOperation lro = await virtualNetworkGatewayNatRule.UpdateAsync(WaitUntil.Completed, data); - VirtualNetworkGatewayNatRuleResource result = lro.Value; + await virtualNetworkGatewayNatRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkGatewayNatRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VirtualNetworkGatewayNatRuleDelete() + public async Task Update_VirtualNetworkGatewayNatRulePut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRuleDelete.json - // this example is just showing the usage of "VirtualNetworkGatewayNatRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGatewayNatRulePut.json + // this example is just showing the usage of "VirtualNetworkGatewayNatRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -123,9 +96,30 @@ public async Task Delete_VirtualNetworkGatewayNatRuleDelete() VirtualNetworkGatewayNatRuleResource virtualNetworkGatewayNatRule = client.GetVirtualNetworkGatewayNatRuleResource(virtualNetworkGatewayNatRuleResourceId); // invoke the operation - await virtualNetworkGatewayNatRule.DeleteAsync(WaitUntil.Completed); + VirtualNetworkGatewayNatRuleData data = new VirtualNetworkGatewayNatRuleData + { + VpnNatRuleType = VpnNatRuleType.Static, + Mode = VpnNatRuleMode.EgressSnat, + InternalMappings = {new VpnNatRuleMapping +{ +AddressSpace = "10.4.0.0/24", +PortRange = "200-300", +}}, + ExternalMappings = {new VpnNatRuleMapping +{ +AddressSpace = "192.168.21.0/24", +PortRange = "300-400", +}}, + IPConfigurationId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/gateway1/ipConfigurations/default", + }; + ArmOperation lro = await virtualNetworkGatewayNatRule.UpdateAsync(WaitUntil.Completed, data); + VirtualNetworkGatewayNatRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkGatewayNatRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayResource.cs index 5679247d6deca..32c43bc154355 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkGatewayResource.cs @@ -123,12 +123,12 @@ public async Task Update_UpdateVirtualNetworkGatewayTags() VirtualNetworkGatewayResource virtualNetworkGateway = client.GetVirtualNetworkGatewayResource(virtualNetworkGatewayResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; ArmOperation lro = await virtualNetworkGateway.UpdateAsync(WaitUntil.Completed, networkTagsObject); @@ -439,7 +439,15 @@ public async Task SetVpnclientIPsecParameters_SetVirtualNetworkGatewayVpnClientI VirtualNetworkGatewayResource virtualNetworkGateway = client.GetVirtualNetworkGatewayResource(virtualNetworkGatewayResourceId); // invoke the operation - VpnClientIPsecParameters vpnclientIPsecParams = new VpnClientIPsecParameters(86473, 429497, IPsecEncryption.Aes256, IPsecIntegrity.Sha256, IkeEncryption.Aes256, IkeIntegrity.Sha384, DHGroup.DHGroup2, PfsGroup.Pfs2); + VpnClientIPsecParameters vpnclientIPsecParams = new VpnClientIPsecParameters( + 86473, + 429497, + IPsecEncryption.Aes256, + IPsecIntegrity.Sha256, + IkeEncryption.Aes256, + IkeIntegrity.Sha384, + DHGroup.DHGroup2, + PfsGroup.Pfs2); ArmOperation lro = await virtualNetworkGateway.SetVpnclientIPsecParametersAsync(WaitUntil.Completed, vpnclientIPsecParams); VpnClientIPsecParameters result = lro.Value; @@ -494,7 +502,7 @@ public async Task StartPacketCapture_StartPacketCaptureOnVirtualNetworkGatewayWi VirtualNetworkGatewayResource virtualNetworkGateway = client.GetVirtualNetworkGatewayResource(virtualNetworkGatewayResourceId); // invoke the operation - VpnPacketCaptureStartContent content = new VpnPacketCaptureStartContent() + VpnPacketCaptureStartContent content = new VpnPacketCaptureStartContent { FilterData = "{'TracingFlags': 11,'MaxPacketBufferSize': 120,'MaxFileSize': 200,'Filters': [{'SourceSubnets': ['20.1.1.0/24'],'DestinationSubnets': ['10.1.1.0/24'],'SourcePort': [500],'DestinationPort': [4500],'Protocol': 6,'TcpFlags': 16,'CaptureSingleDirectionTrafficOnly': true}]}", }; @@ -552,7 +560,7 @@ public async Task StopPacketCapture_StopPacketCaptureOnVirtualNetworkGateway() VirtualNetworkGatewayResource virtualNetworkGateway = client.GetVirtualNetworkGatewayResource(virtualNetworkGatewayResourceId); // invoke the operation - VpnPacketCaptureStopContent content = new VpnPacketCaptureStopContent() + VpnPacketCaptureStopContent content = new VpnPacketCaptureStopContent { SasUri = new Uri("https://teststorage.blob.core.windows.net/?sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2019-09-13T07:44:05Z&st=2019-09-06T23:44:05Z&spr=https&sig=V1h9D1riltvZMI69d6ihENnFo%2FrCvTqGgjO2lf%2FVBhE%3D"), }; @@ -610,12 +618,9 @@ public async Task DisconnectVirtualNetworkGatewayVpnConnections_DisconnectVpnCon VirtualNetworkGatewayResource virtualNetworkGateway = client.GetVirtualNetworkGatewayResource(virtualNetworkGatewayResourceId); // invoke the operation - P2SVpnConnectionRequest request = new P2SVpnConnectionRequest() + P2SVpnConnectionRequest request = new P2SVpnConnectionRequest { - VpnConnectionIds = -{ -"vpnconnId1","vpnconnId2" -}, + VpnConnectionIds = { "vpnconnId1", "vpnconnId2" }, }; await virtualNetworkGateway.DisconnectVirtualNetworkGatewayVpnConnectionsAsync(WaitUntil.Completed, request); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkPeeringCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkPeeringCollection.cs index cf1a87fa36aee..1ad5922b8de81 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkPeeringCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkPeeringCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualNetworkPeeringCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetV6SubnetPeering() + public async Task CreateOrUpdate_CreateV6SubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringGet.json - // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringCreate.json + // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,20 @@ public async Task Get_GetV6SubnetPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - VirtualNetworkPeeringResource result = await collection.GetAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData + { + AllowVirtualNetworkAccess = true, + AllowForwardedTraffic = true, + AllowGatewayTransit = false, + UseRemoteGateways = false, + RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), + AreCompleteVnetsPeered = false, + EnableOnlyIPv6Peering = true, + LocalSubnetNames = { "Subnet1", "Subnet4" }, + RemoteSubnetNames = { "Subnet2" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data); + VirtualNetworkPeeringResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,10 +65,10 @@ public async Task Get_GetV6SubnetPeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetV6SubnetPeering() + public async Task CreateOrUpdate_CreatePeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringGet.json - // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringCreate.json + // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -75,17 +88,30 @@ public async Task Exists_GetV6SubnetPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - bool result = await collection.ExistsAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData + { + AllowVirtualNetworkAccess = true, + AllowForwardedTraffic = true, + AllowGatewayTransit = false, + UseRemoteGateways = false, + RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data); + VirtualNetworkPeeringResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetV6SubnetPeering() + public async Task CreateOrUpdate_CreatePeeringWithRemoteVirtualNetworkEncryption() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringGet.json - // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringCreateWithRemoteVirtualNetworkEncryption.json + // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -105,29 +131,30 @@ public async Task GetIfExists_GetV6SubnetPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkPeeringName); - VirtualNetworkPeeringResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AllowVirtualNetworkAccess = true, + AllowForwardedTraffic = true, + AllowGatewayTransit = false, + UseRemoteGateways = false, + RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data); + VirtualNetworkPeeringResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPeering() + public async Task CreateOrUpdate_CreateSubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGet.json - // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringCreate.json + // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,7 +174,20 @@ public async Task Get_GetPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - VirtualNetworkPeeringResource result = await collection.GetAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData + { + AllowVirtualNetworkAccess = true, + AllowForwardedTraffic = true, + AllowGatewayTransit = false, + UseRemoteGateways = false, + RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), + AreCompleteVnetsPeered = false, + EnableOnlyIPv6Peering = false, + LocalSubnetNames = { "Subnet1", "Subnet4" }, + RemoteSubnetNames = { "Subnet2" }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data); + VirtualNetworkPeeringResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -158,10 +198,10 @@ public async Task Get_GetPeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPeering() + public async Task CreateOrUpdate_SyncPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGet.json - // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringSync.json + // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -181,17 +221,31 @@ public async Task Exists_GetPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - bool result = await collection.ExistsAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData + { + AllowVirtualNetworkAccess = true, + AllowForwardedTraffic = true, + AllowGatewayTransit = false, + UseRemoteGateways = false, + RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), + }; + SyncRemoteAddressSpace? syncRemoteAddressSpace = SyncRemoteAddressSpace.True; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data, syncRemoteAddressSpace: syncRemoteAddressSpace); + VirtualNetworkPeeringResource result = lro.Value; - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPeering() + public async Task CreateOrUpdate_SyncV6SubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGet.json - // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringSync.json + // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -211,29 +265,33 @@ public async Task GetIfExists_GetPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkPeeringName); - VirtualNetworkPeeringResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + AllowVirtualNetworkAccess = true, + AllowForwardedTraffic = true, + AllowGatewayTransit = false, + UseRemoteGateways = false, + RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), + AreCompleteVnetsPeered = false, + EnableOnlyIPv6Peering = true, + }; + SyncRemoteAddressSpace? syncRemoteAddressSpace = SyncRemoteAddressSpace.True; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data, syncRemoteAddressSpace: syncRemoteAddressSpace); + VirtualNetworkPeeringResource result = lro.Value; + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPeeringWithRemoteVirtualNetworkEncryption() + public async Task CreateOrUpdate_SyncSubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json - // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringSync.json + // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -253,7 +311,19 @@ public async Task Get_GetPeeringWithRemoteVirtualNetworkEncryption() // invoke the operation string virtualNetworkPeeringName = "peer"; - VirtualNetworkPeeringResource result = await collection.GetAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData + { + AllowVirtualNetworkAccess = true, + AllowForwardedTraffic = true, + AllowGatewayTransit = false, + UseRemoteGateways = false, + RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), + AreCompleteVnetsPeered = false, + EnableOnlyIPv6Peering = false, + }; + SyncRemoteAddressSpace? syncRemoteAddressSpace = SyncRemoteAddressSpace.True; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data, syncRemoteAddressSpace: syncRemoteAddressSpace); + VirtualNetworkPeeringResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -264,9 +334,9 @@ public async Task Get_GetPeeringWithRemoteVirtualNetworkEncryption() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetPeeringWithRemoteVirtualNetworkEncryption() + public async Task Get_GetV6SubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringGet.json // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -287,16 +357,20 @@ public async Task Exists_GetPeeringWithRemoteVirtualNetworkEncryption() // invoke the operation string virtualNetworkPeeringName = "peer"; - bool result = await collection.ExistsAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringResource result = await collection.GetAsync(virtualNetworkPeeringName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetPeeringWithRemoteVirtualNetworkEncryption() + public async Task Get_GetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGet.json // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -317,28 +391,20 @@ public async Task GetIfExists_GetPeeringWithRemoteVirtualNetworkEncryption() // invoke the operation string virtualNetworkPeeringName = "peer"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkPeeringName); - VirtualNetworkPeeringResource result = response.HasValue ? response.Value : null; + VirtualNetworkPeeringResource result = await collection.GetAsync(virtualNetworkPeeringName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSubnetPeering() + public async Task Get_GetPeeringWithRemoteVirtualNetworkEncryption() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -370,7 +436,7 @@ public async Task Get_GetSubnetPeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetSubnetPeering() + public async Task Get_GetSubnetPeering() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringGet.json // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. @@ -393,17 +459,21 @@ public async Task Exists_GetSubnetPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - bool result = await collection.ExistsAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringResource result = await collection.GetAsync(virtualNetworkPeeringName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetSubnetPeering() + public async Task GetAll_ListPeerings() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringGet.json - // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringList.json + // this example is just showing the usage of "VirtualNetworkPeerings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -421,31 +491,25 @@ public async Task GetIfExists_GetSubnetPeering() // get the collection of this VirtualNetworkPeeringResource VirtualNetworkPeeringCollection collection = virtualNetwork.GetVirtualNetworkPeerings(); - // invoke the operation - string virtualNetworkPeeringName = "peer"; - NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkPeeringName); - VirtualNetworkPeeringResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualNetworkPeeringResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; + VirtualNetworkPeeringData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateV6SubnetPeering() + public async Task GetAll_ListPeeringsWithRemoteVirtualNetworkEncryption() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringCreate.json - // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringListWithRemoteVirtualNetworkEncryption.json + // this example is just showing the usage of "VirtualNetworkPeerings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -463,42 +527,25 @@ public async Task CreateOrUpdate_CreateV6SubnetPeering() // get the collection of this VirtualNetworkPeeringResource VirtualNetworkPeeringCollection collection = virtualNetwork.GetVirtualNetworkPeerings(); - // invoke the operation - string virtualNetworkPeeringName = "peer"; - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() + // invoke the operation and iterate over the result + await foreach (VirtualNetworkPeeringResource item in collection.GetAllAsync()) { - AllowVirtualNetworkAccess = true, - AllowForwardedTraffic = true, - AllowGatewayTransit = false, - UseRemoteGateways = false, - RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), - AreCompleteVnetsPeered = false, - EnableOnlyIPv6Peering = true, - LocalSubnetNames = -{ -"Subnet1","Subnet4" -}, - RemoteSubnetNames = -{ -"Subnet2" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data); - VirtualNetworkPeeringResource result = lro.Value; + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePeering() + public async Task Exists_GetV6SubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringCreate.json - // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringGet.json + // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -518,30 +565,17 @@ public async Task CreateOrUpdate_CreatePeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() - { - AllowVirtualNetworkAccess = true, - AllowForwardedTraffic = true, - AllowGatewayTransit = false, - UseRemoteGateways = false, - RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data); - VirtualNetworkPeeringResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualNetworkPeeringName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreatePeeringWithRemoteVirtualNetworkEncryption() + public async Task Exists_GetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringCreateWithRemoteVirtualNetworkEncryption.json - // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGet.json + // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -561,30 +595,17 @@ public async Task CreateOrUpdate_CreatePeeringWithRemoteVirtualNetworkEncryption // invoke the operation string virtualNetworkPeeringName = "peer"; - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() - { - AllowVirtualNetworkAccess = true, - AllowForwardedTraffic = true, - AllowGatewayTransit = false, - UseRemoteGateways = false, - RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data); - VirtualNetworkPeeringResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualNetworkPeeringName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateSubnetPeering() + public async Task Exists_GetPeeringWithRemoteVirtualNetworkEncryption() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringCreate.json - // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json + // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -604,40 +625,17 @@ public async Task CreateOrUpdate_CreateSubnetPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() - { - AllowVirtualNetworkAccess = true, - AllowForwardedTraffic = true, - AllowGatewayTransit = false, - UseRemoteGateways = false, - RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), - AreCompleteVnetsPeered = false, - EnableOnlyIPv6Peering = false, - LocalSubnetNames = -{ -"Subnet1","Subnet4" -}, - RemoteSubnetNames = -{ -"Subnet2" -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data); - VirtualNetworkPeeringResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualNetworkPeeringName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SyncPeering() + public async Task Exists_GetSubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringSync.json - // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringGet.json + // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -657,31 +655,17 @@ public async Task CreateOrUpdate_SyncPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() - { - AllowVirtualNetworkAccess = true, - AllowForwardedTraffic = true, - AllowGatewayTransit = false, - UseRemoteGateways = false, - RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), - }; - SyncRemoteAddressSpace? syncRemoteAddressSpace = SyncRemoteAddressSpace.True; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data, syncRemoteAddressSpace: syncRemoteAddressSpace); - VirtualNetworkPeeringResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualNetworkPeeringName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SyncV6SubnetPeering() + public async Task GetIfExists_GetV6SubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringSync.json - // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringGet.json + // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -701,33 +685,29 @@ public async Task CreateOrUpdate_SyncV6SubnetPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() - { - AllowVirtualNetworkAccess = true, - AllowForwardedTraffic = true, - AllowGatewayTransit = false, - UseRemoteGateways = false, - RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), - AreCompleteVnetsPeered = false, - EnableOnlyIPv6Peering = true, - }; - SyncRemoteAddressSpace? syncRemoteAddressSpace = SyncRemoteAddressSpace.True; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data, syncRemoteAddressSpace: syncRemoteAddressSpace); - VirtualNetworkPeeringResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_SyncSubnetPeering() + public async Task GetIfExists_GetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringSync.json - // this example is just showing the usage of "VirtualNetworkPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGet.json + // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -747,33 +727,29 @@ public async Task CreateOrUpdate_SyncSubnetPeering() // invoke the operation string virtualNetworkPeeringName = "peer"; - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() - { - AllowVirtualNetworkAccess = true, - AllowForwardedTraffic = true, - AllowGatewayTransit = false, - UseRemoteGateways = false, - RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), - AreCompleteVnetsPeered = false, - EnableOnlyIPv6Peering = false, - }; - SyncRemoteAddressSpace? syncRemoteAddressSpace = SyncRemoteAddressSpace.True; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualNetworkPeeringName, data, syncRemoteAddressSpace: syncRemoteAddressSpace); - VirtualNetworkPeeringResource result = lro.Value; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringResource result = response.HasValue ? response.Value : null; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPeerings() + public async Task GetIfExists_GetPeeringWithRemoteVirtualNetworkEncryption() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringList.json - // this example is just showing the usage of "VirtualNetworkPeerings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json + // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -791,25 +767,31 @@ public async Task GetAll_ListPeerings() // get the collection of this VirtualNetworkPeeringResource VirtualNetworkPeeringCollection collection = virtualNetwork.GetVirtualNetworkPeerings(); - // invoke the operation and iterate over the result - await foreach (VirtualNetworkPeeringResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkPeeringName = "peer"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = item.Data; + VirtualNetworkPeeringData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListPeeringsWithRemoteVirtualNetworkEncryption() + public async Task GetIfExists_GetSubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringListWithRemoteVirtualNetworkEncryption.json - // this example is just showing the usage of "VirtualNetworkPeerings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringGet.json + // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -827,17 +809,23 @@ public async Task GetAll_ListPeeringsWithRemoteVirtualNetworkEncryption() // get the collection of this VirtualNetworkPeeringResource VirtualNetworkPeeringCollection collection = virtualNetwork.GetVirtualNetworkPeerings(); - // invoke the operation and iterate over the result - await foreach (VirtualNetworkPeeringResource item in collection.GetAllAsync()) + // invoke the operation + string virtualNetworkPeeringName = "peer"; + NullableResponse response = await collection.GetIfExistsAsync(virtualNetworkPeeringName); + VirtualNetworkPeeringResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = item.Data; + VirtualNetworkPeeringData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkPeeringResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkPeeringResource.cs index 05e19eecf499f..efece466fe8d0 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkPeeringResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkPeeringResource.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualNetworkPeeringResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletePeering() + public async Task Get_GetV6SubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringDelete.json - // this example is just showing the usage of "VirtualNetworkPeerings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringGet.json + // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,16 +38,20 @@ public async Task Delete_DeletePeering() VirtualNetworkPeeringResource virtualNetworkPeering = client.GetVirtualNetworkPeeringResource(virtualNetworkPeeringResourceId); // invoke the operation - await virtualNetworkPeering.DeleteAsync(WaitUntil.Completed); + VirtualNetworkPeeringResource result = await virtualNetworkPeering.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetV6SubnetPeering() + public async Task Get_GetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkV6SubnetPeeringGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGet.json // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -76,9 +80,9 @@ public async Task Get_GetV6SubnetPeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPeering() + public async Task Get_GetPeeringWithRemoteVirtualNetworkEncryption() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -107,9 +111,9 @@ public async Task Get_GetPeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetPeeringWithRemoteVirtualNetworkEncryption() + public async Task Get_GetSubnetPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringGetWithRemoteVirtualNetworkEncryption.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringGet.json // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -138,10 +142,10 @@ public async Task Get_GetPeeringWithRemoteVirtualNetworkEncryption() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetSubnetPeering() + public async Task Delete_DeletePeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkSubnetPeeringGet.json - // this example is just showing the usage of "VirtualNetworkPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkPeeringDelete.json + // this example is just showing the usage of "VirtualNetworkPeerings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -158,13 +162,9 @@ public async Task Get_GetSubnetPeering() VirtualNetworkPeeringResource virtualNetworkPeering = client.GetVirtualNetworkPeeringResource(virtualNetworkPeeringResourceId); // invoke the operation - VirtualNetworkPeeringResource result = await virtualNetworkPeering.GetAsync(); + await virtualNetworkPeering.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -189,7 +189,7 @@ public async Task Update_CreateV6SubnetPeering() VirtualNetworkPeeringResource virtualNetworkPeering = client.GetVirtualNetworkPeeringResource(virtualNetworkPeeringResourceId); // invoke the operation - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData { AllowVirtualNetworkAccess = true, AllowForwardedTraffic = true, @@ -198,14 +198,8 @@ public async Task Update_CreateV6SubnetPeering() RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), AreCompleteVnetsPeered = false, EnableOnlyIPv6Peering = true, - LocalSubnetNames = -{ -"Subnet1","Subnet4" -}, - RemoteSubnetNames = -{ -"Subnet2" -}, + LocalSubnetNames = { "Subnet1", "Subnet4" }, + RemoteSubnetNames = { "Subnet2" }, }; ArmOperation lro = await virtualNetworkPeering.UpdateAsync(WaitUntil.Completed, data); VirtualNetworkPeeringResource result = lro.Value; @@ -239,7 +233,7 @@ public async Task Update_CreatePeering() VirtualNetworkPeeringResource virtualNetworkPeering = client.GetVirtualNetworkPeeringResource(virtualNetworkPeeringResourceId); // invoke the operation - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData { AllowVirtualNetworkAccess = true, AllowForwardedTraffic = true, @@ -279,7 +273,7 @@ public async Task Update_CreatePeeringWithRemoteVirtualNetworkEncryption() VirtualNetworkPeeringResource virtualNetworkPeering = client.GetVirtualNetworkPeeringResource(virtualNetworkPeeringResourceId); // invoke the operation - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData { AllowVirtualNetworkAccess = true, AllowForwardedTraffic = true, @@ -319,7 +313,7 @@ public async Task Update_CreateSubnetPeering() VirtualNetworkPeeringResource virtualNetworkPeering = client.GetVirtualNetworkPeeringResource(virtualNetworkPeeringResourceId); // invoke the operation - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData { AllowVirtualNetworkAccess = true, AllowForwardedTraffic = true, @@ -328,14 +322,8 @@ public async Task Update_CreateSubnetPeering() RemoteVirtualNetworkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/peerTest/providers/Microsoft.Network/virtualNetworks/vnet2"), AreCompleteVnetsPeered = false, EnableOnlyIPv6Peering = false, - LocalSubnetNames = -{ -"Subnet1","Subnet4" -}, - RemoteSubnetNames = -{ -"Subnet2" -}, + LocalSubnetNames = { "Subnet1", "Subnet4" }, + RemoteSubnetNames = { "Subnet2" }, }; ArmOperation lro = await virtualNetworkPeering.UpdateAsync(WaitUntil.Completed, data); VirtualNetworkPeeringResource result = lro.Value; @@ -369,7 +357,7 @@ public async Task Update_SyncPeering() VirtualNetworkPeeringResource virtualNetworkPeering = client.GetVirtualNetworkPeeringResource(virtualNetworkPeeringResourceId); // invoke the operation - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData { AllowVirtualNetworkAccess = true, AllowForwardedTraffic = true, @@ -410,7 +398,7 @@ public async Task Update_SyncV6SubnetPeering() VirtualNetworkPeeringResource virtualNetworkPeering = client.GetVirtualNetworkPeeringResource(virtualNetworkPeeringResourceId); // invoke the operation - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData { AllowVirtualNetworkAccess = true, AllowForwardedTraffic = true, @@ -453,7 +441,7 @@ public async Task Update_SyncSubnetPeering() VirtualNetworkPeeringResource virtualNetworkPeering = client.GetVirtualNetworkPeeringResource(virtualNetworkPeeringResourceId); // invoke the operation - VirtualNetworkPeeringData data = new VirtualNetworkPeeringData() + VirtualNetworkPeeringData data = new VirtualNetworkPeeringData { AllowVirtualNetworkAccess = true, AllowForwardedTraffic = true, diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkResource.cs index 488623691bd7c..4ea83fb014bb4 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,76 +18,10 @@ public partial class Sample_VirtualNetworkResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetNetworkManagerEffectiveConnectivityConfigurations_ListEffectiveConnectivityConfiguration() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerEffectiveConnectivityConfigurationsList.json - // this example is just showing the usage of "ListNetworkManagerEffectiveConnectivityConfigurations" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualNetworkResource created on azure - // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - string virtualNetworkName = "testVirtualNetwork"; - ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); - VirtualNetworkResource virtualNetwork = client.GetVirtualNetworkResource(virtualNetworkResourceId); - - // invoke the operation and iterate over the result - NetworkManagementQueryContent content = new NetworkManagementQueryContent() - { - SkipToken = "FakeSkipTokenCode", - }; - await foreach (EffectiveConnectivityConfiguration item in virtualNetwork.GetNetworkManagerEffectiveConnectivityConfigurationsAsync(content)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetNetworkManagerEffectiveSecurityAdminRules_ListEffectiveSecurityAdminRules() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerEffectiveSecurityAdminRulesList.json - // this example is just showing the usage of "ListNetworkManagerEffectiveSecurityAdminRules" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualNetworkResource created on azure - // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource - string subscriptionId = "00000000-0000-0000-0000-000000000000"; - string resourceGroupName = "myResourceGroup"; - string virtualNetworkName = "testVirtualNetwork"; - ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); - VirtualNetworkResource virtualNetwork = client.GetVirtualNetworkResource(virtualNetworkResourceId); - - // invoke the operation and iterate over the result - NetworkManagementQueryContent content = new NetworkManagementQueryContent() - { - SkipToken = "FakeSkipTokenCode", - }; - await foreach (EffectiveBaseSecurityAdminRule item in virtualNetwork.GetNetworkManagerEffectiveSecurityAdminRulesAsync(content)) - { - Console.WriteLine($"Succeeded: {item}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualNetwork() + public async Task Get_GetVirtualNetwork() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkDelete.json - // this example is just showing the usage of "VirtualNetworks_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGet.json + // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,16 +37,20 @@ public async Task Delete_DeleteVirtualNetwork() VirtualNetworkResource virtualNetwork = client.GetVirtualNetworkResource(virtualNetworkResourceId); // invoke the operation - await virtualNetwork.DeleteAsync(WaitUntil.Completed); + VirtualNetworkResource result = await virtualNetwork.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetwork() + public async Task Get_GetVirtualNetworkWithADelegatedSubnet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGet.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithSubnetDelegation.json // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -123,7 +60,7 @@ public async Task Get_GetVirtualNetwork() // this example assumes you already have this VirtualNetworkResource created on azure // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource - string subscriptionId = "subid"; + string subscriptionId = "subId"; string resourceGroupName = "rg1"; string virtualNetworkName = "test-vnet"; ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); @@ -141,9 +78,9 @@ public async Task Get_GetVirtualNetwork() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkWithADelegatedSubnet() + public async Task Get_GetVirtualNetworkWithServiceAssociationLinks() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithSubnetDelegation.json + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithServiceAssociationLink.json // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line @@ -171,10 +108,10 @@ public async Task Get_GetVirtualNetworkWithADelegatedSubnet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkWithServiceAssociationLinks() + public async Task Delete_DeleteVirtualNetwork() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkGetWithServiceAssociationLink.json - // this example is just showing the usage of "VirtualNetworks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkDelete.json + // this example is just showing the usage of "VirtualNetworks_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,20 +120,16 @@ public async Task Get_GetVirtualNetworkWithServiceAssociationLinks() // this example assumes you already have this VirtualNetworkResource created on azure // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource - string subscriptionId = "subId"; + string subscriptionId = "subid"; string resourceGroupName = "rg1"; string virtualNetworkName = "test-vnet"; ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); VirtualNetworkResource virtualNetwork = client.GetVirtualNetworkResource(virtualNetworkResourceId); // invoke the operation - VirtualNetworkResource result = await virtualNetwork.GetAsync(); + await virtualNetwork.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -220,12 +153,12 @@ public async Task Update_UpdateVirtualNetworkTags() VirtualNetworkResource virtualNetwork = client.GetVirtualNetworkResource(virtualNetworkResourceId); // invoke the operation - NetworkTagsObject networkTagsObject = new NetworkTagsObject() + NetworkTagsObject networkTagsObject = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; VirtualNetworkResource result = await virtualNetwork.UpdateAsync(networkTagsObject); @@ -239,30 +172,65 @@ public async Task Update_UpdateVirtualNetworkTags() [Test] [Ignore("Only validating compilation of examples")] - public async Task GetVirtualNetworks_ListAllVirtualNetworks() + public async Task GetNetworkManagerEffectiveConnectivityConfigurations_ListEffectiveConnectivityConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkListAll.json - // this example is just showing the usage of "VirtualNetworks_ListAll" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerEffectiveConnectivityConfigurationsList.json + // this example is just showing the usage of "ListNetworkManagerEffectiveConnectivityConfigurations" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + // this example assumes you already have this VirtualNetworkResource created on azure + // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + string virtualNetworkName = "testVirtualNetwork"; + ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); + VirtualNetworkResource virtualNetwork = client.GetVirtualNetworkResource(virtualNetworkResourceId); + + // invoke the operation and iterate over the result + NetworkManagementQueryContent content = new NetworkManagementQueryContent + { + SkipToken = "FakeSkipTokenCode", + }; + await foreach (EffectiveConnectivityConfiguration item in virtualNetwork.GetNetworkManagerEffectiveConnectivityConfigurationsAsync(content)) + { + Console.WriteLine($"Succeeded: {item}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetNetworkManagerEffectiveSecurityAdminRules_ListEffectiveSecurityAdminRules() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NetworkManagerEffectiveSecurityAdminRulesList.json + // this example is just showing the usage of "ListNetworkManagerEffectiveSecurityAdminRules" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VirtualNetworkResource created on azure + // for more information of creating VirtualNetworkResource, please refer to the document of VirtualNetworkResource + string subscriptionId = "00000000-0000-0000-0000-000000000000"; + string resourceGroupName = "myResourceGroup"; + string virtualNetworkName = "testVirtualNetwork"; + ResourceIdentifier virtualNetworkResourceId = VirtualNetworkResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualNetworkName); + VirtualNetworkResource virtualNetwork = client.GetVirtualNetworkResource(virtualNetworkResourceId); // invoke the operation and iterate over the result - await foreach (VirtualNetworkResource item in subscriptionResource.GetVirtualNetworksAsync()) + NetworkManagementQueryContent content = new NetworkManagementQueryContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + SkipToken = "FakeSkipTokenCode", + }; + await foreach (EffectiveBaseSecurityAdminRule item in virtualNetwork.GetNetworkManagerEffectiveSecurityAdminRulesAsync(content)) + { + Console.WriteLine($"Succeeded: {item}"); } Console.WriteLine("Succeeded"); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkTapCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkTapCollection.cs index 8921ed73e32e6..5c5bb05c79fde 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkTapCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkTapCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualNetworkTapCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkTap() + public async Task CreateOrUpdate_CreateVirtualNetworkTap() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapGet.json - // this example is just showing the usage of "VirtualNetworkTaps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapCreate.json + // this example is just showing the usage of "VirtualNetworkTaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,8 +39,17 @@ public async Task Get_GetVirtualNetworkTap() VirtualNetworkTapCollection collection = resourceGroupResource.GetVirtualNetworkTaps(); // invoke the operation - string tapName = "testvtap"; - VirtualNetworkTapResource result = await collection.GetAsync(tapName); + string tapName = "test-vtap"; + VirtualNetworkTapData data = new VirtualNetworkTapData + { + DestinationNetworkInterfaceIPConfiguration = new NetworkInterfaceIPConfigurationData + { + Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/testNetworkInterface/ipConfigurations/ipconfig1"), + }, + Location = new AzureLocation("centraluseuap"), + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tapName, data); + VirtualNetworkTapResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +60,7 @@ public async Task Get_GetVirtualNetworkTap() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualNetworkTap() + public async Task Get_GetVirtualNetworkTap() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapGet.json // this example is just showing the usage of "VirtualNetworkTaps_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +82,21 @@ public async Task Exists_GetVirtualNetworkTap() // invoke the operation string tapName = "testvtap"; - bool result = await collection.ExistsAsync(tapName); + VirtualNetworkTapResource result = await collection.GetAsync(tapName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkTapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualNetworkTap() + public async Task GetAll_ListVirtualNetworkTapsInResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapGet.json - // this example is just showing the usage of "VirtualNetworkTaps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapList.json + // this example is just showing the usage of "VirtualNetworkTaps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +113,25 @@ public async Task GetIfExists_GetVirtualNetworkTap() // get the collection of this VirtualNetworkTapResource VirtualNetworkTapCollection collection = resourceGroupResource.GetVirtualNetworkTaps(); - // invoke the operation - string tapName = "testvtap"; - NullableResponse response = await collection.GetIfExistsAsync(tapName); - VirtualNetworkTapResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualNetworkTapResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkTapData resourceData = result.Data; + VirtualNetworkTapData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualNetworkTap() + public async Task Exists_GetVirtualNetworkTap() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapCreate.json - // this example is just showing the usage of "VirtualNetworkTaps_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapGet.json + // this example is just showing the usage of "VirtualNetworkTaps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -142,31 +149,18 @@ public async Task CreateOrUpdate_CreateVirtualNetworkTap() VirtualNetworkTapCollection collection = resourceGroupResource.GetVirtualNetworkTaps(); // invoke the operation - string tapName = "test-vtap"; - VirtualNetworkTapData data = new VirtualNetworkTapData() - { - DestinationNetworkInterfaceIPConfiguration = new NetworkInterfaceIPConfigurationData() - { - Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/networkInterfaces/testNetworkInterface/ipConfigurations/ipconfig1"), - }, - Location = new AzureLocation("centraluseuap"), - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, tapName, data); - VirtualNetworkTapResource result = lro.Value; + string tapName = "testvtap"; + bool result = await collection.ExistsAsync(tapName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkTapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListVirtualNetworkTapsInResourceGroup() + public async Task GetIfExists_GetVirtualNetworkTap() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapList.json - // this example is just showing the usage of "VirtualNetworkTaps_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapGet.json + // this example is just showing the usage of "VirtualNetworkTaps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -183,17 +177,23 @@ public async Task GetAll_ListVirtualNetworkTapsInResourceGroup() // get the collection of this VirtualNetworkTapResource VirtualNetworkTapCollection collection = resourceGroupResource.GetVirtualNetworkTaps(); - // invoke the operation and iterate over the result - await foreach (VirtualNetworkTapResource item in collection.GetAllAsync()) + // invoke the operation + string tapName = "testvtap"; + NullableResponse response = await collection.GetIfExistsAsync(tapName); + VirtualNetworkTapResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualNetworkTapData resourceData = item.Data; + VirtualNetworkTapData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkTapResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkTapResource.cs index 8b1613f727263..c9c0402b19cd7 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkTapResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualNetworkTapResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,10 +18,10 @@ public partial class Sample_VirtualNetworkTapResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualNetworkTapResource() + public async Task Get_GetVirtualNetworkTap() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapDelete.json - // this example is just showing the usage of "VirtualNetworkTaps_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapGet.json + // this example is just showing the usage of "VirtualNetworkTaps_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -33,22 +32,26 @@ public async Task Delete_DeleteVirtualNetworkTapResource() // for more information of creating VirtualNetworkTapResource, please refer to the document of VirtualNetworkTapResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string tapName = "test-vtap"; + string tapName = "testvtap"; ResourceIdentifier virtualNetworkTapResourceId = VirtualNetworkTapResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, tapName); VirtualNetworkTapResource virtualNetworkTap = client.GetVirtualNetworkTapResource(virtualNetworkTapResourceId); // invoke the operation - await virtualNetworkTap.DeleteAsync(WaitUntil.Completed); + VirtualNetworkTapResource result = await virtualNetworkTap.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualNetworkTapData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualNetworkTap() + public async Task Delete_DeleteVirtualNetworkTapResource() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapGet.json - // this example is just showing the usage of "VirtualNetworkTaps_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapDelete.json + // this example is just showing the usage of "VirtualNetworkTaps_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -59,18 +62,14 @@ public async Task Get_GetVirtualNetworkTap() // for more information of creating VirtualNetworkTapResource, please refer to the document of VirtualNetworkTapResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string tapName = "testvtap"; + string tapName = "test-vtap"; ResourceIdentifier virtualNetworkTapResourceId = VirtualNetworkTapResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, tapName); VirtualNetworkTapResource virtualNetworkTap = client.GetVirtualNetworkTapResource(virtualNetworkTapResourceId); // invoke the operation - VirtualNetworkTapResource result = await virtualNetworkTap.GetAsync(); + await virtualNetworkTap.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkTapData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -94,12 +93,12 @@ public async Task Update_UpdateVirtualNetworkTapTags() VirtualNetworkTapResource virtualNetworkTap = client.GetVirtualNetworkTapResource(virtualNetworkTapResourceId); // invoke the operation - NetworkTagsObject tapParameters = new NetworkTagsObject() + NetworkTagsObject tapParameters = new NetworkTagsObject { Tags = { ["tag1"] = "value1", -["tag2"] = "value2", +["tag2"] = "value2" }, }; VirtualNetworkTapResource result = await virtualNetworkTap.UpdateAsync(tapParameters); @@ -110,36 +109,5 @@ public async Task Update_UpdateVirtualNetworkTapTags() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVirtualNetworkTaps_ListAllVirtualNetworkTaps() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualNetworkTapListAll.json - // this example is just showing the usage of "VirtualNetworkTaps_ListAll" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VirtualNetworkTapResource item in subscriptionResource.GetVirtualNetworkTapsAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualNetworkTapData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterCollection.cs index dc751f0ee7b75..fd6cabfbcf378 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualRouterCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualRouter() + public async Task CreateOrUpdate_CreateVirtualRouter() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterGet.json - // this example is just showing the usage of "VirtualRouters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPut.json + // this example is just showing the usage of "VirtualRouters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,17 @@ public async Task Get_GetVirtualRouter() // invoke the operation string virtualRouterName = "virtualRouter"; - VirtualRouterResource result = await collection.GetAsync(virtualRouterName); + VirtualRouterData data = new VirtualRouterData + { + HostedGatewayId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vnetGateway"), + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualRouterName, data); + VirtualRouterResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +61,7 @@ public async Task Get_GetVirtualRouter() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualRouter() + public async Task Get_GetVirtualRouter() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterGet.json // this example is just showing the usage of "VirtualRouters_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +83,21 @@ public async Task Exists_GetVirtualRouter() // invoke the operation string virtualRouterName = "virtualRouter"; - bool result = await collection.ExistsAsync(virtualRouterName); + VirtualRouterResource result = await collection.GetAsync(virtualRouterName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualRouterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualRouter() + public async Task GetAll_ListAllVirtualRouterForAGivenResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterGet.json - // this example is just showing the usage of "VirtualRouters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterListByResourceGroup.json + // this example is just showing the usage of "VirtualRouters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +114,25 @@ public async Task GetIfExists_GetVirtualRouter() // get the collection of this VirtualRouterResource VirtualRouterCollection collection = resourceGroupResource.GetVirtualRouters(); - // invoke the operation - string virtualRouterName = "virtualRouter"; - NullableResponse response = await collection.GetIfExistsAsync(virtualRouterName); - VirtualRouterResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualRouterResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualRouterData resourceData = result.Data; + VirtualRouterData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualRouter() + public async Task Exists_GetVirtualRouter() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPut.json - // this example is just showing the usage of "VirtualRouters_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterGet.json + // this example is just showing the usage of "VirtualRouters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,31 +151,17 @@ public async Task CreateOrUpdate_CreateVirtualRouter() // invoke the operation string virtualRouterName = "virtualRouter"; - VirtualRouterData data = new VirtualRouterData() - { - HostedGatewayId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vnetGateway"), - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualRouterName, data); - VirtualRouterResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualRouterName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualRouterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllVirtualRouterForAGivenResourceGroup() + public async Task GetIfExists_GetVirtualRouter() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterListByResourceGroup.json - // this example is just showing the usage of "VirtualRouters_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterGet.json + // this example is just showing the usage of "VirtualRouters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListAllVirtualRouterForAGivenResourceGroup() // get the collection of this VirtualRouterResource VirtualRouterCollection collection = resourceGroupResource.GetVirtualRouters(); - // invoke the operation and iterate over the result - await foreach (VirtualRouterResource item in collection.GetAllAsync()) + // invoke the operation + string virtualRouterName = "virtualRouter"; + NullableResponse response = await collection.GetIfExistsAsync(virtualRouterName); + VirtualRouterResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualRouterData resourceData = item.Data; + VirtualRouterData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterPeeringCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterPeeringCollection.cs index a08bc88e88072..1b474e544c7ed 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterPeeringCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterPeeringCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_VirtualRouterPeeringCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualRouterPeering() + public async Task CreateOrUpdate_CreateVirtualRouterPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringGet.json - // this example is just showing the usage of "VirtualRouterPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringPut.json + // this example is just showing the usage of "VirtualRouterPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,13 @@ public async Task Get_GetVirtualRouterPeering() // invoke the operation string peeringName = "peering1"; - VirtualRouterPeeringResource result = await collection.GetAsync(peeringName); + VirtualRouterPeeringData data = new VirtualRouterPeeringData + { + PeerAsn = 20000L, + PeerIP = "192.168.1.5", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peeringName, data); + VirtualRouterPeeringResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +57,7 @@ public async Task Get_GetVirtualRouterPeering() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_GetVirtualRouterPeering() + public async Task Get_GetVirtualRouterPeering() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringGet.json // this example is just showing the usage of "VirtualRouterPeerings_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +80,21 @@ public async Task Exists_GetVirtualRouterPeering() // invoke the operation string peeringName = "peering1"; - bool result = await collection.ExistsAsync(peeringName); + VirtualRouterPeeringResource result = await collection.GetAsync(peeringName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualRouterPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetVirtualRouterPeering() + public async Task GetAll_ListAllVirtualRouterPeeringsForAGivenVirtualRouter() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringGet.json - // this example is just showing the usage of "VirtualRouterPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringList.json + // this example is just showing the usage of "VirtualRouterPeerings_List" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +112,25 @@ public async Task GetIfExists_GetVirtualRouterPeering() // get the collection of this VirtualRouterPeeringResource VirtualRouterPeeringCollection collection = virtualRouter.GetVirtualRouterPeerings(); - // invoke the operation - string peeringName = "peering1"; - NullableResponse response = await collection.GetIfExistsAsync(peeringName); - VirtualRouterPeeringResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualRouterPeeringResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualRouterPeeringData resourceData = result.Data; + VirtualRouterPeeringData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_CreateVirtualRouterPeering() + public async Task Exists_GetVirtualRouterPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringPut.json - // this example is just showing the usage of "VirtualRouterPeerings_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringGet.json + // this example is just showing the usage of "VirtualRouterPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -146,27 +150,17 @@ public async Task CreateOrUpdate_CreateVirtualRouterPeering() // invoke the operation string peeringName = "peering1"; - VirtualRouterPeeringData data = new VirtualRouterPeeringData() - { - PeerAsn = 20000L, - PeerIP = "192.168.1.5", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, peeringName, data); - VirtualRouterPeeringResource result = lro.Value; + bool result = await collection.ExistsAsync(peeringName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualRouterPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListAllVirtualRouterPeeringsForAGivenVirtualRouter() + public async Task GetIfExists_GetVirtualRouterPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringList.json - // this example is just showing the usage of "VirtualRouterPeerings_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringGet.json + // this example is just showing the usage of "VirtualRouterPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -184,17 +178,23 @@ public async Task GetAll_ListAllVirtualRouterPeeringsForAGivenVirtualRouter() // get the collection of this VirtualRouterPeeringResource VirtualRouterPeeringCollection collection = virtualRouter.GetVirtualRouterPeerings(); - // invoke the operation and iterate over the result - await foreach (VirtualRouterPeeringResource item in collection.GetAllAsync()) + // invoke the operation + string peeringName = "peering1"; + NullableResponse response = await collection.GetIfExistsAsync(peeringName); + VirtualRouterPeeringResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualRouterPeeringData resourceData = item.Data; + VirtualRouterPeeringData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterPeeringResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterPeeringResource.cs index 0e0c643e9e440..36de8ec585e93 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterPeeringResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterPeeringResource.cs @@ -17,10 +17,10 @@ public partial class Sample_VirtualRouterPeeringResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualRouterPeering() + public async Task Get_GetVirtualRouterPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringDelete.json - // this example is just showing the usage of "VirtualRouterPeerings_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringGet.json + // this example is just showing the usage of "VirtualRouterPeerings_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +37,21 @@ public async Task Delete_DeleteVirtualRouterPeering() VirtualRouterPeeringResource virtualRouterPeering = client.GetVirtualRouterPeeringResource(virtualRouterPeeringResourceId); // invoke the operation - await virtualRouterPeering.DeleteAsync(WaitUntil.Completed); + VirtualRouterPeeringResource result = await virtualRouterPeering.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualRouterPeeringData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualRouterPeering() + public async Task Delete_DeleteVirtualRouterPeering() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringGet.json - // this example is just showing the usage of "VirtualRouterPeerings_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterPeeringDelete.json + // this example is just showing the usage of "VirtualRouterPeerings_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,13 +68,9 @@ public async Task Get_GetVirtualRouterPeering() VirtualRouterPeeringResource virtualRouterPeering = client.GetVirtualRouterPeeringResource(virtualRouterPeeringResourceId); // invoke the operation - VirtualRouterPeeringResource result = await virtualRouterPeering.GetAsync(); + await virtualRouterPeering.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualRouterPeeringData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -95,7 +95,7 @@ public async Task Update_CreateVirtualRouterPeering() VirtualRouterPeeringResource virtualRouterPeering = client.GetVirtualRouterPeeringResource(virtualRouterPeeringResourceId); // invoke the operation - VirtualRouterPeeringData data = new VirtualRouterPeeringData() + VirtualRouterPeeringData data = new VirtualRouterPeeringData { PeerAsn = 20000L, PeerIP = "192.168.1.5", diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterResource.cs index 9f2c3e3ee70bc..c21c2da4da3b6 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualRouterResource.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Identity; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -18,10 +17,10 @@ public partial class Sample_VirtualRouterResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_DeleteVirtualRouter() + public async Task Get_GetVirtualRouter() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterDelete.json - // this example is just showing the usage of "VirtualRouters_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterGet.json + // this example is just showing the usage of "VirtualRouters_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -37,17 +36,21 @@ public async Task Delete_DeleteVirtualRouter() VirtualRouterResource virtualRouter = client.GetVirtualRouterResource(virtualRouterResourceId); // invoke the operation - await virtualRouter.DeleteAsync(WaitUntil.Completed); + VirtualRouterResource result = await virtualRouter.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualRouterData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetVirtualRouter() + public async Task Delete_DeleteVirtualRouter() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterGet.json - // this example is just showing the usage of "VirtualRouters_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterDelete.json + // this example is just showing the usage of "VirtualRouters_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -63,13 +66,9 @@ public async Task Get_GetVirtualRouter() VirtualRouterResource virtualRouter = client.GetVirtualRouterResource(virtualRouterResourceId); // invoke the operation - VirtualRouterResource result = await virtualRouter.GetAsync(); + await virtualRouter.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualRouterData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -93,13 +92,13 @@ public async Task Update_CreateVirtualRouter() VirtualRouterResource virtualRouter = client.GetVirtualRouterResource(virtualRouterResourceId); // invoke the operation - VirtualRouterData data = new VirtualRouterData() + VirtualRouterData data = new VirtualRouterData { HostedGatewayId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/vnetGateway"), Location = new AzureLocation("West US"), Tags = { -["key1"] = "value1", +["key1"] = "value1" }, }; ArmOperation lro = await virtualRouter.UpdateAsync(WaitUntil.Completed, data); @@ -111,36 +110,5 @@ public async Task Update_CreateVirtualRouter() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVirtualRouters_ListAllVirtualRoutersForAGivenSubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualRouterListBySubscription.json - // this example is just showing the usage of "VirtualRouters_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VirtualRouterResource item in subscriptionResource.GetVirtualRoutersAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualRouterData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualWanCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualWanCollection.cs index b0cd2d83ab7e0..53516df4ae8ad 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualWanCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualWanCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VirtualWanCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualWANGet() + public async Task CreateOrUpdate_VirtualWANCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANGet.json - // this example is just showing the usage of "VirtualWans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANPut.json + // this example is just showing the usage of "VirtualWans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -40,7 +40,18 @@ public async Task Get_VirtualWANGet() // invoke the operation string virtualWanName = "wan1"; - VirtualWanResource result = await collection.GetAsync(virtualWanName); + VirtualWanData data = new VirtualWanData + { + DisableVpnEncryption = false, + VirtualWanType = "Basic", + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualWanName, data); + VirtualWanResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -51,7 +62,7 @@ public async Task Get_VirtualWANGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VirtualWANGet() + public async Task Get_VirtualWANGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANGet.json // this example is just showing the usage of "VirtualWans_Get" operation, for the dependent resources, they will have to be created separately. @@ -73,17 +84,21 @@ public async Task Exists_VirtualWANGet() // invoke the operation string virtualWanName = "wan1"; - bool result = await collection.ExistsAsync(virtualWanName); + VirtualWanResource result = await collection.GetAsync(virtualWanName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualWanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VirtualWANGet() + public async Task GetAll_VirtualWANListByResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANGet.json - // this example is just showing the usage of "VirtualWans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANListByResourceGroup.json + // this example is just showing the usage of "VirtualWans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -100,31 +115,25 @@ public async Task GetIfExists_VirtualWANGet() // get the collection of this VirtualWanResource VirtualWanCollection collection = resourceGroupResource.GetVirtualWans(); - // invoke the operation - string virtualWanName = "wan1"; - NullableResponse response = await collection.GetIfExistsAsync(virtualWanName); - VirtualWanResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VirtualWanResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualWanData resourceData = result.Data; + VirtualWanData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VirtualWANCreate() + public async Task Exists_VirtualWANGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANPut.json - // this example is just showing the usage of "VirtualWans_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANGet.json + // this example is just showing the usage of "VirtualWans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -143,32 +152,17 @@ public async Task CreateOrUpdate_VirtualWANCreate() // invoke the operation string virtualWanName = "wan1"; - VirtualWanData data = new VirtualWanData() - { - DisableVpnEncryption = false, - VirtualWanType = "Basic", - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, virtualWanName, data); - VirtualWanResource result = lro.Value; + bool result = await collection.ExistsAsync(virtualWanName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualWanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VirtualWANListByResourceGroup() + public async Task GetIfExists_VirtualWANGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANListByResourceGroup.json - // this example is just showing the usage of "VirtualWans_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANGet.json + // this example is just showing the usage of "VirtualWans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -185,17 +179,23 @@ public async Task GetAll_VirtualWANListByResourceGroup() // get the collection of this VirtualWanResource VirtualWanCollection collection = resourceGroupResource.GetVirtualWans(); - // invoke the operation and iterate over the result - await foreach (VirtualWanResource item in collection.GetAllAsync()) + // invoke the operation + string virtualWanName = "wan1"; + NullableResponse response = await collection.GetIfExistsAsync(virtualWanName); + VirtualWanResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VirtualWanData resourceData = item.Data; + VirtualWanData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualWanResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualWanResource.cs index ce0ade205dd37..9f037b7ac0fec 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualWanResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VirtualWanResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,36 +18,10 @@ public partial class Sample_VirtualWanResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task SupportedSecurityProviders_SupportedSecurityProviders() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWanSupportedSecurityProviders.json - // this example is just showing the usage of "SupportedSecurityProviders" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VirtualWanResource created on azure - // for more information of creating VirtualWanResource, please refer to the document of VirtualWanResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string virtualWanName = "wan1"; - ResourceIdentifier virtualWanResourceId = VirtualWanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualWanName); - VirtualWanResource virtualWan = client.GetVirtualWanResource(virtualWanResourceId); - - // invoke the operation - VirtualWanSecurityProviders result = await virtualWan.SupportedSecurityProvidersAsync(); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GenerateVirtualWanVpnServerConfigurationVpnProfile_GenerateVirtualWanVpnServerConfigurationVpnProfile() + public async Task Get_VirtualWANGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/GenerateVirtualWanVpnServerConfigurationVpnProfile.json - // this example is just showing the usage of "Generatevirtualwanvpnserverconfigurationvpnprofile" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANGet.json + // this example is just showing the usage of "VirtualWans_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -64,23 +37,21 @@ public async Task GenerateVirtualWanVpnServerConfigurationVpnProfile_GenerateVir VirtualWanResource virtualWan = client.GetVirtualWanResource(virtualWanResourceId); // invoke the operation - VirtualWanVpnProfileContent content = new VirtualWanVpnProfileContent() - { - VpnServerConfigurationResourceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnServerConfigurations/vpnconfig1"), - AuthenticationMethod = NetworkAuthenticationMethod.Eaptls, - }; - ArmOperation lro = await virtualWan.GenerateVirtualWanVpnServerConfigurationVpnProfileAsync(WaitUntil.Completed, content); - VpnProfileResponse result = lro.Value; + VirtualWanResource result = await virtualWan.GetAsync(); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VirtualWanData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VirtualWANGet() + public async Task Delete_VirtualWANDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANGet.json - // this example is just showing the usage of "VirtualWans_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANDelete.json + // this example is just showing the usage of "VirtualWans_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -91,18 +62,14 @@ public async Task Get_VirtualWANGet() // for more information of creating VirtualWanResource, please refer to the document of VirtualWanResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string virtualWanName = "wan1"; + string virtualWanName = "virtualWan1"; ResourceIdentifier virtualWanResourceId = VirtualWanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualWanName); VirtualWanResource virtualWan = client.GetVirtualWanResource(virtualWanResourceId); // invoke the operation - VirtualWanResource result = await virtualWan.GetAsync(); + await virtualWan.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualWanData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -126,12 +93,12 @@ public async Task Update_VirtualWANUpdate() VirtualWanResource virtualWan = client.GetVirtualWanResource(virtualWanResourceId); // invoke the operation - NetworkTagsObject wanParameters = new NetworkTagsObject() + NetworkTagsObject wanParameters = new NetworkTagsObject { Tags = { ["key1"] = "value1", -["key2"] = "value2", +["key2"] = "value2" }, }; VirtualWanResource result = await virtualWan.UpdateAsync(wanParameters); @@ -145,10 +112,10 @@ public async Task Update_VirtualWANUpdate() [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VirtualWANDelete() + public async Task SupportedSecurityProviders_SupportedSecurityProviders() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANDelete.json - // this example is just showing the usage of "VirtualWans_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWanSupportedSecurityProviders.json + // this example is just showing the usage of "SupportedSecurityProviders" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -159,45 +126,46 @@ public async Task Delete_VirtualWANDelete() // for more information of creating VirtualWanResource, please refer to the document of VirtualWanResource string subscriptionId = "subid"; string resourceGroupName = "rg1"; - string virtualWanName = "virtualWan1"; + string virtualWanName = "wan1"; ResourceIdentifier virtualWanResourceId = VirtualWanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualWanName); VirtualWanResource virtualWan = client.GetVirtualWanResource(virtualWanResourceId); // invoke the operation - await virtualWan.DeleteAsync(WaitUntil.Completed); + VirtualWanSecurityProviders result = await virtualWan.SupportedSecurityProvidersAsync(); - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetVirtualWans_VirtualWANList() + public async Task GenerateVirtualWanVpnServerConfigurationVpnProfile_GenerateVirtualWanVpnServerConfigurationVpnProfile() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VirtualWANList.json - // this example is just showing the usage of "VirtualWans_List" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/GenerateVirtualWanVpnServerConfigurationVpnProfile.json + // this example is just showing the usage of "Generatevirtualwanvpnserverconfigurationvpnprofile" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this VirtualWanResource created on azure + // for more information of creating VirtualWanResource, please refer to the document of VirtualWanResource string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rg1"; + string virtualWanName = "wan1"; + ResourceIdentifier virtualWanResourceId = VirtualWanResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, virtualWanName); + VirtualWanResource virtualWan = client.GetVirtualWanResource(virtualWanResourceId); - // invoke the operation and iterate over the result - await foreach (VirtualWanResource item in subscriptionResource.GetVirtualWansAsync()) + // invoke the operation + VirtualWanVpnProfileContent content = new VirtualWanVpnProfileContent { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VirtualWanData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + VpnServerConfigurationResourceId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnServerConfigurations/vpnconfig1"), + AuthenticationMethod = NetworkAuthenticationMethod.Eaptls, + }; + ArmOperation lro = await virtualWan.GenerateVirtualWanVpnServerConfigurationVpnProfileAsync(WaitUntil.Completed, content); + VpnProfileResponse result = lro.Value; - Console.WriteLine("Succeeded"); + Console.WriteLine($"Succeeded: {result}"); } [Test] @@ -223,10 +191,7 @@ public async Task DownloadVpnSitesConfiguration_VpnSitesConfigurationDownload() // invoke the operation GetVpnSitesConfigurationContent content = new GetVpnSitesConfigurationContent(new Uri("https://blobcortextesturl.blob.core.windows.net/folderforconfig/vpnFile?sp=rw&se=2018-01-10T03%3A42%3A04Z&sv=2017-04-17&sig=WvXrT5bDmDFfgHs%2Brz%2BjAu123eRCNE9BO0eQYcPDT7pY%3D&sr=b")) { - VpnSites = -{ -"/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/abc" -}, + VpnSites = { "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/abc" }, }; await virtualWan.DownloadVpnSitesConfigurationAsync(WaitUntil.Completed, content); diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnConnectionCollection.cs index 6555420d74231..66f7bc3105eab 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnConnectionCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_VpnConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VpnConnectionGet() + public async Task CreateOrUpdate_VpnConnectionPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionGet.json - // this example is just showing the usage of "VpnConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionPut.json + // this example is just showing the usage of "VpnConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,43 @@ public async Task Get_VpnConnectionGet() // invoke the operation string connectionName = "vpnConnection1"; - VpnConnectionResource result = await collection.GetAsync(connectionName); + VpnConnectionData data = new VpnConnectionData + { + RemoteVpnSiteId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/vpnSite1"), + TrafficSelectorPolicies = { }, + VpnLinkConnections = {new VpnSiteLinkConnectionData +{ +VpnSiteLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/vpnSite1/vpnSiteLinks/siteLink1"), +VpnLinkConnectionMode = VpnLinkConnectionMode.Default, +VpnConnectionProtocolType = VirtualNetworkGatewayConnectionProtocol.IkeV2, +ConnectionBandwidth = 200, +SharedKey = "key", +UsePolicyBasedTrafficSelectors = false, +Name = "Connection-Link1", +}}, + RoutingConfiguration = new RoutingConfiguration + { + AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), + PropagatedRouteTables = new PropagatedRouteTable + { + Labels = { "label1", "label2" }, + Ids = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable2"), +}, new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable3"), +}}, + }, + InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), + OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), + }, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionName, data); + VpnConnectionResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +89,7 @@ public async Task Get_VpnConnectionGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VpnConnectionGet() + public async Task Get_VpnConnectionGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionGet.json // this example is just showing the usage of "VpnConnections_Get" operation, for the dependent resources, they will have to be created separately. @@ -76,17 +112,21 @@ public async Task Exists_VpnConnectionGet() // invoke the operation string connectionName = "vpnConnection1"; - bool result = await collection.ExistsAsync(connectionName); + VpnConnectionResource result = await collection.GetAsync(connectionName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VpnConnectionGet() + public async Task GetAll_VpnConnectionList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionGet.json - // this example is just showing the usage of "VpnConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionList.json + // this example is just showing the usage of "VpnConnections_ListByVpnGateway" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -104,31 +144,25 @@ public async Task GetIfExists_VpnConnectionGet() // get the collection of this VpnConnectionResource VpnConnectionCollection collection = vpnGateway.GetVpnConnections(); - // invoke the operation - string connectionName = "vpnConnection1"; - NullableResponse response = await collection.GetIfExistsAsync(connectionName); - VpnConnectionResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VpnConnectionResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnConnectionData resourceData = result.Data; + VpnConnectionData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VpnConnectionPut() + public async Task Exists_VpnConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionPut.json - // this example is just showing the usage of "VpnConnections_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionGet.json + // this example is just showing the usage of "VpnConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -148,68 +182,17 @@ public async Task CreateOrUpdate_VpnConnectionPut() // invoke the operation string connectionName = "vpnConnection1"; - VpnConnectionData data = new VpnConnectionData() - { - RemoteVpnSiteId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/vpnSite1"), - TrafficSelectorPolicies = -{ -}, - VpnLinkConnections = -{ -new VpnSiteLinkConnectionData() -{ -VpnSiteLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/vpnSite1/vpnSiteLinks/siteLink1"), -VpnLinkConnectionMode = VpnLinkConnectionMode.Default, -VpnConnectionProtocolType = VirtualNetworkGatewayConnectionProtocol.IkeV2, -ConnectionBandwidth = 200, -SharedKey = "key", -UsePolicyBasedTrafficSelectors = false, -Name = "Connection-Link1", -} -}, - RoutingConfiguration = new RoutingConfiguration() - { - AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), - PropagatedRouteTables = new PropagatedRouteTable() - { - Labels = -{ -"label1","label2" -}, - Ids = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable2"), -},new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable3"), -} -}, - }, - InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), - OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), - }, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, connectionName, data); - VpnConnectionResource result = lro.Value; + bool result = await collection.ExistsAsync(connectionName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VpnConnectionList() + public async Task GetIfExists_VpnConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionList.json - // this example is just showing the usage of "VpnConnections_ListByVpnGateway" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionGet.json + // this example is just showing the usage of "VpnConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -227,17 +210,23 @@ public async Task GetAll_VpnConnectionList() // get the collection of this VpnConnectionResource VpnConnectionCollection collection = vpnGateway.GetVpnConnections(); - // invoke the operation and iterate over the result - await foreach (VpnConnectionResource item in collection.GetAllAsync()) + // invoke the operation + string connectionName = "vpnConnection1"; + NullableResponse response = await collection.GetIfExistsAsync(connectionName); + VpnConnectionResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnConnectionData resourceData = item.Data; + VpnConnectionData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnConnectionResource.cs index cc0944cc304aa..f85446ecd9d43 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnConnectionResource.cs @@ -48,6 +48,33 @@ public async Task Get_VpnConnectionGet() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Delete_VpnConnectionDelete() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionDelete.json + // this example is just showing the usage of "VpnConnections_Delete" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this VpnConnectionResource created on azure + // for more information of creating VpnConnectionResource, please refer to the document of VpnConnectionResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + string gatewayName = "gateway1"; + string connectionName = "vpnConnection1"; + ResourceIdentifier vpnConnectionResourceId = VpnConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, gatewayName, connectionName); + VpnConnectionResource vpnConnection = client.GetVpnConnectionResource(vpnConnectionResourceId); + + // invoke the operation + await vpnConnection.DeleteAsync(WaitUntil.Completed); + + Console.WriteLine("Succeeded"); + } + [Test] [Ignore("Only validating compilation of examples")] public async Task Update_VpnConnectionPut() @@ -70,15 +97,11 @@ public async Task Update_VpnConnectionPut() VpnConnectionResource vpnConnection = client.GetVpnConnectionResource(vpnConnectionResourceId); // invoke the operation - VpnConnectionData data = new VpnConnectionData() + VpnConnectionData data = new VpnConnectionData { RemoteVpnSiteId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/vpnSite1"), - TrafficSelectorPolicies = -{ -}, - VpnLinkConnections = -{ -new VpnSiteLinkConnectionData() + TrafficSelectorPolicies = { }, + VpnLinkConnections = {new VpnSiteLinkConnectionData { VpnSiteLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/vpnSite1/vpnSiteLinks/siteLink1"), VpnLinkConnectionMode = VpnLinkConnectionMode.Default, @@ -87,30 +110,23 @@ public async Task Update_VpnConnectionPut() SharedKey = "key", UsePolicyBasedTrafficSelectors = false, Name = "Connection-Link1", -} -}, - RoutingConfiguration = new RoutingConfiguration() +}}, + RoutingConfiguration = new RoutingConfiguration { AssociatedRouteTableId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), - PropagatedRouteTables = new PropagatedRouteTable() + PropagatedRouteTables = new PropagatedRouteTable { - Labels = -{ -"label1","label2" -}, - Ids = -{ -new WritableSubResource() + Labels = { "label1", "label2" }, + Ids = {new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable1"), -},new WritableSubResource() +}, new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable2"), -},new WritableSubResource() +}, new WritableSubResource { Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/hub1/hubRouteTables/hubRouteTable3"), -} -}, +}}, }, InboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap1"), OutboundRouteMapId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1/routeMaps/routeMap2"), @@ -126,33 +142,6 @@ public async Task Update_VpnConnectionPut() Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_VpnConnectionDelete() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnConnectionDelete.json - // this example is just showing the usage of "VpnConnections_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this VpnConnectionResource created on azure - // for more information of creating VpnConnectionResource, please refer to the document of VpnConnectionResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string gatewayName = "gateway1"; - string connectionName = "vpnConnection1"; - ResourceIdentifier vpnConnectionResourceId = VpnConnectionResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, gatewayName, connectionName); - VpnConnectionResource vpnConnection = client.GetVpnConnectionResource(vpnConnectionResourceId); - - // invoke the operation - await vpnConnection.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - [Test] [Ignore("Only validating compilation of examples")] public async Task StartPacketCapture_StartPacketCaptureOnVpnConnectionWithFilter() @@ -175,13 +164,10 @@ public async Task StartPacketCapture_StartPacketCaptureOnVpnConnectionWithFilter VpnConnectionResource vpnConnection = client.GetVpnConnectionResource(vpnConnectionResourceId); // invoke the operation - VpnConnectionPacketCaptureStartContent content = new VpnConnectionPacketCaptureStartContent() + VpnConnectionPacketCaptureStartContent content = new VpnConnectionPacketCaptureStartContent { FilterData = "{'TracingFlags': 11,'MaxPacketBufferSize': 120,'MaxFileSize': 200,'Filters': [{'SourceSubnets': ['20.1.1.0/24'],'DestinationSubnets': ['10.1.1.0/24'],'SourcePort': [500],'DestinationPort': [4500],'Protocol': 6,'TcpFlags': 16,'CaptureSingleDirectionTrafficOnly': true}]}", - LinkConnectionNames = -{ -"siteLink1","siteLink2" -}, + LinkConnectionNames = { "siteLink1", "siteLink2" }, }; ArmOperation lro = await vpnConnection.StartPacketCaptureAsync(WaitUntil.Completed, content: content); string result = lro.Value; @@ -211,12 +197,9 @@ public async Task StartPacketCapture_StartPacketCaptureOnVpnConnectionWithoutFil VpnConnectionResource vpnConnection = client.GetVpnConnectionResource(vpnConnectionResourceId); // invoke the operation - VpnConnectionPacketCaptureStartContent content = new VpnConnectionPacketCaptureStartContent() + VpnConnectionPacketCaptureStartContent content = new VpnConnectionPacketCaptureStartContent { - LinkConnectionNames = -{ -"siteLink1","siteLink2" -}, + LinkConnectionNames = { "siteLink1", "siteLink2" }, }; ArmOperation lro = await vpnConnection.StartPacketCaptureAsync(WaitUntil.Completed, content: content); string result = lro.Value; @@ -246,13 +229,10 @@ public async Task StopPacketCapture_StartPacketCaptureOnVpnConnectionWithoutFilt VpnConnectionResource vpnConnection = client.GetVpnConnectionResource(vpnConnectionResourceId); // invoke the operation - VpnConnectionPacketCaptureStopContent content = new VpnConnectionPacketCaptureStopContent() + VpnConnectionPacketCaptureStopContent content = new VpnConnectionPacketCaptureStopContent { SasUri = new Uri("https://teststorage.blob.core.windows.net/?sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2019-09-13T07:44:05Z&st=2019-09-06T23:44:05Z&spr=https&sig=V1h9D1riltvZMI69d6ihENnFo%2FrCvTqGgjO2lf%2FVBhE%3D"), - LinkConnectionNames = -{ -"vpnSiteLink1","vpnSiteLink2" -}, + LinkConnectionNames = { "vpnSiteLink1", "vpnSiteLink2" }, }; ArmOperation lro = await vpnConnection.StopPacketCaptureAsync(WaitUntil.Completed, content: content); string result = lro.Value; diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayCollection.cs index 36f5ef9901ecc..86ea8387849d7 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayCollection.cs @@ -20,10 +20,10 @@ public partial class Sample_VpnGatewayCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VpnGatewayGet() + public async Task CreateOrUpdate_VpnGatewayPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayGet.json - // this example is just showing the usage of "VpnGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayPut.json + // this example is just showing the usage of "VpnGateways_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -42,7 +42,65 @@ public async Task Get_VpnGatewayGet() // invoke the operation string gatewayName = "gateway1"; - VpnGatewayResource result = await collection.GetAsync(gatewayName); + VpnGatewayData data = new VpnGatewayData + { + VirtualHubId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1"), + Connections = {new VpnConnectionData +{ +RemoteVpnSiteId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/vpnSite1"), +VpnLinkConnections = {new VpnSiteLinkConnectionData +{ +VpnSiteLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/vpnSite1/vpnSiteLinks/siteLink1"), +VpnConnectionProtocolType = VirtualNetworkGatewayConnectionProtocol.IkeV2, +ConnectionBandwidth = 200, +SharedKey = "key", +EgressNatRules = {new WritableSubResource +{ +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnGateways/gateway1/natRules/nat03"), +}}, +Name = "Connection-Link1", +}}, +Name = "vpnConnection1", +}}, + BgpSettings = new BgpSettings + { + Asn = 65515L, + PeerWeight = 0, + BgpPeeringAddresses = {new NetworkIPConfigurationBgpPeeringAddress +{ +IPConfigurationId = "Instance0", +CustomBgpIPAddresses = {"169.254.21.5"}, +}, new NetworkIPConfigurationBgpPeeringAddress +{ +IPConfigurationId = "Instance1", +CustomBgpIPAddresses = {"169.254.21.10"}, +}}, + }, + EnableBgpRouteTranslationForNat = false, + IsRoutingPreferenceInternet = false, + NatRules = {new VpnGatewayNatRuleData +{ +VpnNatRuleType = VpnNatRuleType.Static, +Mode = VpnNatRuleMode.EgressSnat, +InternalMappings = {new VpnNatRuleMapping +{ +AddressSpace = "0.0.0.0/26", +}}, +ExternalMappings = {new VpnNatRuleMapping +{ +AddressSpace = "192.168.0.0/26", +}}, +IPConfigurationId = "", +Name = "nat03", +}}, + Location = new AzureLocation("westcentralus"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gatewayName, data); + VpnGatewayResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -53,7 +111,7 @@ public async Task Get_VpnGatewayGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VpnGatewayGet() + public async Task Get_VpnGatewayGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayGet.json // this example is just showing the usage of "VpnGateways_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +133,21 @@ public async Task Exists_VpnGatewayGet() // invoke the operation string gatewayName = "gateway1"; - bool result = await collection.ExistsAsync(gatewayName); + VpnGatewayResource result = await collection.GetAsync(gatewayName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VpnGatewayGet() + public async Task GetAll_VpnGatewayListByResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayGet.json - // this example is just showing the usage of "VpnGateways_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayListByResourceGroup.json + // this example is just showing the usage of "VpnGateways_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -102,31 +164,25 @@ public async Task GetIfExists_VpnGatewayGet() // get the collection of this VpnGatewayResource VpnGatewayCollection collection = resourceGroupResource.GetVpnGateways(); - // invoke the operation - string gatewayName = "gateway1"; - NullableResponse response = await collection.GetIfExistsAsync(gatewayName); - VpnGatewayResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VpnGatewayResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnGatewayData resourceData = result.Data; + VpnGatewayData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VpnGatewayPut() + public async Task Exists_VpnGatewayGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayPut.json - // this example is just showing the usage of "VpnGateways_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayGet.json + // this example is just showing the usage of "VpnGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -145,106 +201,17 @@ public async Task CreateOrUpdate_VpnGatewayPut() // invoke the operation string gatewayName = "gateway1"; - VpnGatewayData data = new VpnGatewayData() - { - VirtualHubId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualHubs/virtualHub1"), - Connections = -{ -new VpnConnectionData() -{ -RemoteVpnSiteId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/vpnSite1"), -VpnLinkConnections = -{ -new VpnSiteLinkConnectionData() -{ -VpnSiteLinkId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnSites/vpnSite1/vpnSiteLinks/siteLink1"), -VpnConnectionProtocolType = VirtualNetworkGatewayConnectionProtocol.IkeV2, -ConnectionBandwidth = 200, -SharedKey = "key", -EgressNatRules = -{ -new WritableSubResource() -{ -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnGateways/gateway1/natRules/nat03"), -} -}, -Name = "Connection-Link1", -} -}, -Name = "vpnConnection1", -} -}, - BgpSettings = new BgpSettings() - { - Asn = 65515L, - PeerWeight = 0, - BgpPeeringAddresses = -{ -new NetworkIPConfigurationBgpPeeringAddress() -{ -IPConfigurationId = "Instance0", -CustomBgpIPAddresses = -{ -"169.254.21.5" -}, -},new NetworkIPConfigurationBgpPeeringAddress() -{ -IPConfigurationId = "Instance1", -CustomBgpIPAddresses = -{ -"169.254.21.10" -}, -} -}, - }, - EnableBgpRouteTranslationForNat = false, - IsRoutingPreferenceInternet = false, - NatRules = -{ -new VpnGatewayNatRuleData() -{ -VpnNatRuleType = VpnNatRuleType.Static, -Mode = VpnNatRuleMode.EgressSnat, -InternalMappings = -{ -new VpnNatRuleMapping() -{ -AddressSpace = "0.0.0.0/26", -} -}, -ExternalMappings = -{ -new VpnNatRuleMapping() -{ -AddressSpace = "192.168.0.0/26", -} -}, -IPConfigurationId = "", -Name = "nat03", -} -}, - Location = new AzureLocation("westcentralus"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, gatewayName, data); - VpnGatewayResource result = lro.Value; + bool result = await collection.ExistsAsync(gatewayName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VpnGatewayListByResourceGroup() + public async Task GetIfExists_VpnGatewayGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayListByResourceGroup.json - // this example is just showing the usage of "VpnGateways_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayGet.json + // this example is just showing the usage of "VpnGateways_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -261,17 +228,23 @@ public async Task GetAll_VpnGatewayListByResourceGroup() // get the collection of this VpnGatewayResource VpnGatewayCollection collection = resourceGroupResource.GetVpnGateways(); - // invoke the operation and iterate over the result - await foreach (VpnGatewayResource item in collection.GetAllAsync()) + // invoke the operation + string gatewayName = "gateway1"; + NullableResponse response = await collection.GetIfExistsAsync(gatewayName); + VpnGatewayResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnGatewayData resourceData = item.Data; + VpnGatewayData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayNatRuleCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayNatRuleCollection.cs index c3ea078e3d72b..932e72791dbcb 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayNatRuleCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayNatRuleCollection.cs @@ -18,10 +18,10 @@ public partial class Sample_VpnGatewayNatRuleCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_NatRuleGet() + public async Task CreateOrUpdate_NatRulePut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRuleGet.json - // this example is just showing the usage of "NatRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRulePut.json + // this example is just showing the usage of "NatRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,22 @@ public async Task Get_NatRuleGet() // invoke the operation string natRuleName = "natRule1"; - VpnGatewayNatRuleResource result = await collection.GetAsync(natRuleName); + VpnGatewayNatRuleData data = new VpnGatewayNatRuleData + { + VpnNatRuleType = VpnNatRuleType.Static, + Mode = VpnNatRuleMode.EgressSnat, + InternalMappings = {new VpnNatRuleMapping +{ +AddressSpace = "10.4.0.0/24", +}}, + ExternalMappings = {new VpnNatRuleMapping +{ +AddressSpace = "192.168.21.0/24", +}}, + IPConfigurationId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/cloudnet1-VNG/ipConfigurations/default", + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, natRuleName, data); + VpnGatewayNatRuleResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +67,7 @@ public async Task Get_NatRuleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_NatRuleGet() + public async Task Get_NatRuleGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRuleGet.json // this example is just showing the usage of "NatRules_Get" operation, for the dependent resources, they will have to be created separately. @@ -75,17 +90,21 @@ public async Task Exists_NatRuleGet() // invoke the operation string natRuleName = "natRule1"; - bool result = await collection.ExistsAsync(natRuleName); + VpnGatewayNatRuleResource result = await collection.GetAsync(natRuleName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnGatewayNatRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_NatRuleGet() + public async Task GetAll_NatRuleList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRuleGet.json - // this example is just showing the usage of "NatRules_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRuleList.json + // this example is just showing the usage of "NatRules_ListByVpnGateway" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -103,31 +122,25 @@ public async Task GetIfExists_NatRuleGet() // get the collection of this VpnGatewayNatRuleResource VpnGatewayNatRuleCollection collection = vpnGateway.GetVpnGatewayNatRules(); - // invoke the operation - string natRuleName = "natRule1"; - NullableResponse response = await collection.GetIfExistsAsync(natRuleName); - VpnGatewayNatRuleResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VpnGatewayNatRuleResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnGatewayNatRuleData resourceData = result.Data; + VpnGatewayNatRuleData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_NatRulePut() + public async Task Exists_NatRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRulePut.json - // this example is just showing the usage of "NatRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRuleGet.json + // this example is just showing the usage of "NatRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -147,42 +160,17 @@ public async Task CreateOrUpdate_NatRulePut() // invoke the operation string natRuleName = "natRule1"; - VpnGatewayNatRuleData data = new VpnGatewayNatRuleData() - { - VpnNatRuleType = VpnNatRuleType.Static, - Mode = VpnNatRuleMode.EgressSnat, - InternalMappings = -{ -new VpnNatRuleMapping() -{ -AddressSpace = "10.4.0.0/24", -} -}, - ExternalMappings = -{ -new VpnNatRuleMapping() -{ -AddressSpace = "192.168.21.0/24", -} -}, - IPConfigurationId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/cloudnet1-VNG/ipConfigurations/default", - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, natRuleName, data); - VpnGatewayNatRuleResource result = lro.Value; + bool result = await collection.ExistsAsync(natRuleName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnGatewayNatRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_NatRuleList() + public async Task GetIfExists_NatRuleGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRuleList.json - // this example is just showing the usage of "NatRules_ListByVpnGateway" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRuleGet.json + // this example is just showing the usage of "NatRules_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -200,17 +188,23 @@ public async Task GetAll_NatRuleList() // get the collection of this VpnGatewayNatRuleResource VpnGatewayNatRuleCollection collection = vpnGateway.GetVpnGatewayNatRules(); - // invoke the operation and iterate over the result - await foreach (VpnGatewayNatRuleResource item in collection.GetAllAsync()) + // invoke the operation + string natRuleName = "natRule1"; + NullableResponse response = await collection.GetIfExistsAsync(natRuleName); + VpnGatewayNatRuleResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnGatewayNatRuleData resourceData = item.Data; + VpnGatewayNatRuleData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayNatRuleResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayNatRuleResource.cs index f02bce4d0ca28..a2df09594aede 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayNatRuleResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayNatRuleResource.cs @@ -49,10 +49,10 @@ public async Task Get_NatRuleGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_NatRulePut() + public async Task Delete_NatRuleDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRulePut.json - // this example is just showing the usage of "NatRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRuleDelete.json + // this example is just showing the usage of "NatRules_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,42 +69,17 @@ public async Task Update_NatRulePut() VpnGatewayNatRuleResource vpnGatewayNatRule = client.GetVpnGatewayNatRuleResource(vpnGatewayNatRuleResourceId); // invoke the operation - VpnGatewayNatRuleData data = new VpnGatewayNatRuleData() - { - VpnNatRuleType = VpnNatRuleType.Static, - Mode = VpnNatRuleMode.EgressSnat, - InternalMappings = -{ -new VpnNatRuleMapping() -{ -AddressSpace = "10.4.0.0/24", -} -}, - ExternalMappings = -{ -new VpnNatRuleMapping() -{ -AddressSpace = "192.168.21.0/24", -} -}, - IPConfigurationId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/cloudnet1-VNG/ipConfigurations/default", - }; - ArmOperation lro = await vpnGatewayNatRule.UpdateAsync(WaitUntil.Completed, data); - VpnGatewayNatRuleResource result = lro.Value; + await vpnGatewayNatRule.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnGatewayNatRuleData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_NatRuleDelete() + public async Task Update_NatRulePut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRuleDelete.json - // this example is just showing the usage of "NatRules_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/NatRulePut.json + // this example is just showing the usage of "NatRules_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -121,9 +96,28 @@ public async Task Delete_NatRuleDelete() VpnGatewayNatRuleResource vpnGatewayNatRule = client.GetVpnGatewayNatRuleResource(vpnGatewayNatRuleResourceId); // invoke the operation - await vpnGatewayNatRule.DeleteAsync(WaitUntil.Completed); + VpnGatewayNatRuleData data = new VpnGatewayNatRuleData + { + VpnNatRuleType = VpnNatRuleType.Static, + Mode = VpnNatRuleMode.EgressSnat, + InternalMappings = {new VpnNatRuleMapping +{ +AddressSpace = "10.4.0.0/24", +}}, + ExternalMappings = {new VpnNatRuleMapping +{ +AddressSpace = "192.168.21.0/24", +}}, + IPConfigurationId = "/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualNetworkGateways/cloudnet1-VNG/ipConfigurations/default", + }; + ArmOperation lro = await vpnGatewayNatRule.UpdateAsync(WaitUntil.Completed, data); + VpnGatewayNatRuleResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnGatewayNatRuleData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayResource.cs index ff889e649c9fe..d3a2f95cafb67 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnGatewayResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -49,10 +48,10 @@ public async Task Get_VpnGatewayGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VpnGatewayUpdate() + public async Task Delete_VpnGatewayDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayUpdateTags.json - // this example is just showing the usage of "VpnGateways_UpdateTags" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayDelete.json + // this example is just showing the usage of "VpnGateways_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,30 +67,17 @@ public async Task Update_VpnGatewayUpdate() VpnGatewayResource vpnGateway = client.GetVpnGatewayResource(vpnGatewayResourceId); // invoke the operation - NetworkTagsObject vpnGatewayParameters = new NetworkTagsObject() - { - Tags = -{ -["tag1"] = "value1", -["tag2"] = "value2", -}, - }; - ArmOperation lro = await vpnGateway.UpdateAsync(WaitUntil.Completed, vpnGatewayParameters); - VpnGatewayResource result = lro.Value; + await vpnGateway.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnGatewayData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VpnGatewayDelete() + public async Task Update_VpnGatewayUpdate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayDelete.json - // this example is just showing the usage of "VpnGateways_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayUpdateTags.json + // this example is just showing the usage of "VpnGateways_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -107,9 +93,22 @@ public async Task Delete_VpnGatewayDelete() VpnGatewayResource vpnGateway = client.GetVpnGatewayResource(vpnGatewayResourceId); // invoke the operation - await vpnGateway.DeleteAsync(WaitUntil.Completed); + NetworkTagsObject vpnGatewayParameters = new NetworkTagsObject + { + Tags = +{ +["tag1"] = "value1", +["tag2"] = "value2" +}, + }; + ArmOperation lro = await vpnGateway.UpdateAsync(WaitUntil.Completed, vpnGatewayParameters); + VpnGatewayResource result = lro.Value; - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnGatewayData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] @@ -164,7 +163,7 @@ public async Task StartPacketCapture_StartPacketCaptureOnVpnGatewayWithFilter() VpnGatewayResource vpnGateway = client.GetVpnGatewayResource(vpnGatewayResourceId); // invoke the operation - VpnGatewayPacketCaptureStartContent content = new VpnGatewayPacketCaptureStartContent() + VpnGatewayPacketCaptureStartContent content = new VpnGatewayPacketCaptureStartContent { FilterData = "{'TracingFlags': 11,'MaxPacketBufferSize': 120,'MaxFileSize': 200,'Filters': [{'SourceSubnets': ['20.1.1.0/24'],'DestinationSubnets': ['10.1.1.0/24'],'SourcePort': [500],'DestinationPort': [4500],'Protocol': 6,'TcpFlags': 16,'CaptureSingleDirectionTrafficOnly': true}]}", }; @@ -222,7 +221,7 @@ public async Task StopPacketCapture_StopPacketCaptureOnVpnGateway() VpnGatewayResource vpnGateway = client.GetVpnGatewayResource(vpnGatewayResourceId); // invoke the operation - VpnGatewayPacketCaptureStopContent content = new VpnGatewayPacketCaptureStopContent() + VpnGatewayPacketCaptureStopContent content = new VpnGatewayPacketCaptureStopContent { SasUri = new Uri("https://teststorage.blob.core.windows.net/?sv=2018-03-28&ss=bfqt&srt=sco&sp=rwdlacup&se=2019-09-13T07:44:05Z&st=2019-09-06T23:44:05Z&spr=https&sig=V1h9D1riltvZMI69d6ihENnFo%2FrCvTqGgjO2lf%2FVBhE%3D"), }; @@ -231,36 +230,5 @@ public async Task StopPacketCapture_StopPacketCaptureOnVpnGateway() Console.WriteLine($"Succeeded: {result}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVpnGateways_VpnGatewayListBySubscription() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnGatewayList.json - // this example is just showing the usage of "VpnGateways_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VpnGatewayResource item in subscriptionResource.GetVpnGatewaysAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnGatewayData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnLinkConnectionSharedKeyResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnLinkConnectionSharedKeyResource.cs index 85c561e59797b..3aa39f2710ec2 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnLinkConnectionSharedKeyResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnLinkConnectionSharedKeyResource.cs @@ -71,9 +71,9 @@ public async Task CreateOrUpdate_VpnSiteLinkConnectionDefaultSharedKeyPut() VpnLinkConnectionSharedKeyResource vpnLinkConnectionSharedKey = client.GetVpnLinkConnectionSharedKeyResource(vpnLinkConnectionSharedKeyResourceId); // invoke the operation - VpnLinkConnectionSharedKeyData data = new VpnLinkConnectionSharedKeyData() + VpnLinkConnectionSharedKeyData data = new VpnLinkConnectionSharedKeyData { - Properties = new VpnLinkConnectionSharedKeyProperties() + Properties = new VpnLinkConnectionSharedKeyProperties { SharedKey = "ABCDEF123456", }, diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationCollection.cs index 6b19f5b0e6e71..213121bc111e8 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_VpnServerConfigurationCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VpnServerConfigurationGet() + public async Task CreateOrUpdate_VpnServerConfigurationCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationGet.json - // this example is just showing the usage of "VpnServerConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationPut.json + // this example is just showing the usage of "VpnServerConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,76 @@ public async Task Get_VpnServerConfigurationGet() // invoke the operation string vpnServerConfigurationName = "vpnServerConfiguration1"; - VpnServerConfigurationResource result = await collection.GetAsync(vpnServerConfigurationName); + VpnServerConfigurationData data = new VpnServerConfigurationData + { + VpnProtocols = { VpnGatewayTunnelingProtocol.IkeV2 }, + VpnClientRootCertificates = {new VpnServerConfigVpnClientRootCertificate +{ +Name = "vpnServerConfigVpnClientRootCert1", +PublicCertData = BinaryData.FromObjectAsJson("MIIC5zCCAc+gAwIBAgIQErQ0Hk4aDJxIA+Q5RagB+jANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDDAtQMlNSb290Q2VydDAeFw0xNzEyMTQyMTA3MzhaFw0xODEyMTQyMTI3MzhaMBYxFDASBgNVBAMMC1AyU1Jvb3RDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArP7/NQXmW7cQ/ZR1mv3Y3I29Lt7HTOqzo/1KUOoVH3NItbQIRAQbwKy3UWrOFz4eGNX2GWtNRMdCyWsKeqy9Ltsdfcm1IbKXkl84DFeU/ZacXu4Dl3xX3gV5du4TLZjEowJELyur11Ea2YcjPRQ/FzAF9/hGuboS1HZQEPLx4FdUs9OxCYOtc0MxBCwLfVTTRqarb0Ne+arNYd4kCzIhAke1nOyKAJBda5ZL+VHy3S5S8qGlD46jm8HXugmAkUygS4oIIXOmj/1O9sNAi3LN60zufSzCmP8Rm/iUGX+DHAGGiXxwZOKQLEDaZXKqoHjMPP0XudmSWwOIbyeQVrLhkwIDAQABozEwLzAOBgNVHQ8BAf8EBAMCAgQwHQYDVR0OBBYEFEfeNU2trYxNLF9ONmuJUsT13pKDMA0GCSqGSIb3DQEBCwUAA4IBAQBmM6RJzsGGipxyMhimHKN2xlkejhVsgBoTAhOU0llW9aUSwINJ9zFUGgI8IzUFy1VG776fchHp0LMRmPSIUYk5btEPxbsrPtumPuMH8EQGrS+Rt4pD+78c8H1fEPkq5CmDl/PKu4JoFGv+aFcE+Od0hlILstIF10Qysf++QXDolKfzJa/56bgMeYKFiju73loiRM57ns8ddXpfLl792UVpRkFU62LNns6Y1LKTwapmUF4IvIuAIzd6LZNOQng64LAKXtKnViJ1JQiXwf4CEzhgvAti3/ejpb3U90hsrUcyZi6wBv9bZLcAJRWpz61JNYliM1d1grSwQDKGXNQE4xuN"), +}}, + VpnClientRevokedCertificates = {new VpnServerConfigVpnClientRevokedCertificate +{ +Name = "vpnServerConfigVpnClientRevokedCert1", +Thumbprint = "83FFBFC8848B5A5836C94D0112367E16148A286F", +}}, + RadiusServerRootCertificates = {new VpnServerConfigRadiusServerRootCertificate +{ +Name = "vpnServerConfigRadiusServerRootCer1", +PublicCertData = BinaryData.FromObjectAsJson("MIIC5zCCAc+gAwIBAgIQErQ0Hk4aDJxIA+Q5RagB+jANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDDAtQMlNSb290Q2VydDAeFw0xNzEyMTQyMTA3MzhaFw0xODEyMTQyMTI3MzhaMBYxFDASBgNVBAMMC1AyU1Jvb3RDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArP7/NQXmW7cQ/ZR1mv3Y3I29Lt7HTOqzo/1KUOoVH3NItbQIRAQbwKy3UWrOFz4eGNX2GWtNRMdCyWsKeqy9Ltsdfcm1IbKXkl84DFeU/ZacXu4Dl3xX3gV5du4TLZjEowJELyur11Ea2YcjPRQ/FzAF9/hGuboS1HZQEPLx4FdUs9OxCYOtc0MxBCwLfVTTRqarb0Ne+arNYd4kCzIhAke1nOyKAJBda5ZL+VHy3S5S8qGlD46jm8HXugmAkUygS4oIIXOmj/1O9sNAi3LN60zufSzCmP8Rm/iUGX+DHAGGiXxwZOKQLEDaZXKqoHjMPP0XudmSWwOIbyeQVrLhkwIDAQABozEwLzAOBgNVHQ8BAf8EBAMCAgQwHQYDVR0OBBYEFEfeNU2trYxNLF9ONmuJUsT13pKDMA0GCSqGSIb3DQEBCwUAA4IBAQBmM6RJzsGGipxyMhimHKN2xlkejhVsgBoTAhOU0llW9aUSwINJ9zFUGgI8IzUFy1VG776fchHp0LMRmPSIUYk5btEPxbsrPtumPuMH8EQGrS+Rt4pD+78c8H1fEPkq5CmDl/PKu4JoFGv+aFcE+Od0hlILstIF10Qysf++QXDolKfzJa/56bgMeYKFiju73loiRM57ns8ddXpfLl792UVpRkFU62LNns6Y1LKTwapmUF4IvIuAIzd6LZNOQng64LAKXtKnViJ1JQiXwf4CEzhgvAti3/ejpb3U90hsrUcyZi6wBv9bZLcAJRWpz61JNYliM1d1grSwQDKGXNQE4xuM"), +}}, + RadiusClientRootCertificates = {new VpnServerConfigRadiusClientRootCertificate +{ +Name = "vpnServerConfigRadiusClientRootCert1", +Thumbprint = "83FFBFC8848B5A5836C94D0112367E16148A286F", +}}, + VpnClientIPsecPolicies = {new IPsecPolicy( + 86472, + 429497, + IPsecEncryption.Aes256, + IPsecIntegrity.Sha256, + IkeEncryption.Aes256, + IkeIntegrity.Sha384, + DHGroup.DHGroup14, + PfsGroup.Pfs14)}, + RadiusServers = {new RadiusServer("10.0.0.0") +{ +RadiusServerScore = 25L, +RadiusServerSecret = "radiusServerSecret", +}}, + ConfigurationPolicyGroups = {new VpnServerConfigurationPolicyGroupData +{ +IsDefault = true, +Priority = 0, +PolicyMembers = {new VpnServerConfigurationPolicyGroupMember +{ +Name = "policy1", +AttributeType = VpnPolicyMemberAttributeType.RadiusAzureGroupId, +AttributeValue = "6ad1bd08", +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfiguration1/vpnServerConfigurationPolicyGroups/policyGroup1"), +Name = "policyGroup1", +}, new VpnServerConfigurationPolicyGroupData +{ +IsDefault = true, +Priority = 0, +PolicyMembers = {new VpnServerConfigurationPolicyGroupMember +{ +Name = "policy2", +AttributeType = VpnPolicyMemberAttributeType.CertificateGroupId, +AttributeValue = "red.com", +}}, +Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfiguration1/vpnServerConfigurationPolicyGroups/policyGroup2"), +Name = "policyGroup2", +}}, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vpnServerConfigurationName, data); + VpnServerConfigurationResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +121,7 @@ public async Task Get_VpnServerConfigurationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VpnServerConfigurationGet() + public async Task Get_VpnServerConfigurationGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationGet.json // this example is just showing the usage of "VpnServerConfigurations_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +143,21 @@ public async Task Exists_VpnServerConfigurationGet() // invoke the operation string vpnServerConfigurationName = "vpnServerConfiguration1"; - bool result = await collection.ExistsAsync(vpnServerConfigurationName); + VpnServerConfigurationResource result = await collection.GetAsync(vpnServerConfigurationName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VpnServerConfigurationGet() + public async Task GetAll_VpnServerConfigurationListByResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationGet.json - // this example is just showing the usage of "VpnServerConfigurations_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationListByResourceGroup.json + // this example is just showing the usage of "VpnServerConfigurations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +174,25 @@ public async Task GetIfExists_VpnServerConfigurationGet() // get the collection of this VpnServerConfigurationResource VpnServerConfigurationCollection collection = resourceGroupResource.GetVpnServerConfigurations(); - // invoke the operation - string vpnServerConfigurationName = "vpnServerConfiguration1"; - NullableResponse response = await collection.GetIfExistsAsync(vpnServerConfigurationName); - VpnServerConfigurationResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VpnServerConfigurationResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnServerConfigurationData resourceData = result.Data; + VpnServerConfigurationData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VpnServerConfigurationCreate() + public async Task Exists_VpnServerConfigurationGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationPut.json - // this example is just showing the usage of "VpnServerConfigurations_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationGet.json + // this example is just showing the usage of "VpnServerConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,112 +211,17 @@ public async Task CreateOrUpdate_VpnServerConfigurationCreate() // invoke the operation string vpnServerConfigurationName = "vpnServerConfiguration1"; - VpnServerConfigurationData data = new VpnServerConfigurationData() - { - VpnProtocols = -{ -VpnGatewayTunnelingProtocol.IkeV2 -}, - VpnClientRootCertificates = -{ -new VpnServerConfigVpnClientRootCertificate() -{ -Name = "vpnServerConfigVpnClientRootCert1", -PublicCertData = BinaryData.FromString("\"MIIC5zCCAc+gAwIBAgIQErQ0Hk4aDJxIA+Q5RagB+jANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDDAtQMlNSb290Q2VydDAeFw0xNzEyMTQyMTA3MzhaFw0xODEyMTQyMTI3MzhaMBYxFDASBgNVBAMMC1AyU1Jvb3RDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArP7/NQXmW7cQ/ZR1mv3Y3I29Lt7HTOqzo/1KUOoVH3NItbQIRAQbwKy3UWrOFz4eGNX2GWtNRMdCyWsKeqy9Ltsdfcm1IbKXkl84DFeU/ZacXu4Dl3xX3gV5du4TLZjEowJELyur11Ea2YcjPRQ/FzAF9/hGuboS1HZQEPLx4FdUs9OxCYOtc0MxBCwLfVTTRqarb0Ne+arNYd4kCzIhAke1nOyKAJBda5ZL+VHy3S5S8qGlD46jm8HXugmAkUygS4oIIXOmj/1O9sNAi3LN60zufSzCmP8Rm/iUGX+DHAGGiXxwZOKQLEDaZXKqoHjMPP0XudmSWwOIbyeQVrLhkwIDAQABozEwLzAOBgNVHQ8BAf8EBAMCAgQwHQYDVR0OBBYEFEfeNU2trYxNLF9ONmuJUsT13pKDMA0GCSqGSIb3DQEBCwUAA4IBAQBmM6RJzsGGipxyMhimHKN2xlkejhVsgBoTAhOU0llW9aUSwINJ9zFUGgI8IzUFy1VG776fchHp0LMRmPSIUYk5btEPxbsrPtumPuMH8EQGrS+Rt4pD+78c8H1fEPkq5CmDl/PKu4JoFGv+aFcE+Od0hlILstIF10Qysf++QXDolKfzJa/56bgMeYKFiju73loiRM57ns8ddXpfLl792UVpRkFU62LNns6Y1LKTwapmUF4IvIuAIzd6LZNOQng64LAKXtKnViJ1JQiXwf4CEzhgvAti3/ejpb3U90hsrUcyZi6wBv9bZLcAJRWpz61JNYliM1d1grSwQDKGXNQE4xuN\""), -} -}, - VpnClientRevokedCertificates = -{ -new VpnServerConfigVpnClientRevokedCertificate() -{ -Name = "vpnServerConfigVpnClientRevokedCert1", -Thumbprint = "83FFBFC8848B5A5836C94D0112367E16148A286F", -} -}, - RadiusServerRootCertificates = -{ -new VpnServerConfigRadiusServerRootCertificate() -{ -Name = "vpnServerConfigRadiusServerRootCer1", -PublicCertData = BinaryData.FromString("\"MIIC5zCCAc+gAwIBAgIQErQ0Hk4aDJxIA+Q5RagB+jANBgkqhkiG9w0BAQsFADAWMRQwEgYDVQQDDAtQMlNSb290Q2VydDAeFw0xNzEyMTQyMTA3MzhaFw0xODEyMTQyMTI3MzhaMBYxFDASBgNVBAMMC1AyU1Jvb3RDZXJ0MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArP7/NQXmW7cQ/ZR1mv3Y3I29Lt7HTOqzo/1KUOoVH3NItbQIRAQbwKy3UWrOFz4eGNX2GWtNRMdCyWsKeqy9Ltsdfcm1IbKXkl84DFeU/ZacXu4Dl3xX3gV5du4TLZjEowJELyur11Ea2YcjPRQ/FzAF9/hGuboS1HZQEPLx4FdUs9OxCYOtc0MxBCwLfVTTRqarb0Ne+arNYd4kCzIhAke1nOyKAJBda5ZL+VHy3S5S8qGlD46jm8HXugmAkUygS4oIIXOmj/1O9sNAi3LN60zufSzCmP8Rm/iUGX+DHAGGiXxwZOKQLEDaZXKqoHjMPP0XudmSWwOIbyeQVrLhkwIDAQABozEwLzAOBgNVHQ8BAf8EBAMCAgQwHQYDVR0OBBYEFEfeNU2trYxNLF9ONmuJUsT13pKDMA0GCSqGSIb3DQEBCwUAA4IBAQBmM6RJzsGGipxyMhimHKN2xlkejhVsgBoTAhOU0llW9aUSwINJ9zFUGgI8IzUFy1VG776fchHp0LMRmPSIUYk5btEPxbsrPtumPuMH8EQGrS+Rt4pD+78c8H1fEPkq5CmDl/PKu4JoFGv+aFcE+Od0hlILstIF10Qysf++QXDolKfzJa/56bgMeYKFiju73loiRM57ns8ddXpfLl792UVpRkFU62LNns6Y1LKTwapmUF4IvIuAIzd6LZNOQng64LAKXtKnViJ1JQiXwf4CEzhgvAti3/ejpb3U90hsrUcyZi6wBv9bZLcAJRWpz61JNYliM1d1grSwQDKGXNQE4xuM\""), -} -}, - RadiusClientRootCertificates = -{ -new VpnServerConfigRadiusClientRootCertificate() -{ -Name = "vpnServerConfigRadiusClientRootCert1", -Thumbprint = "83FFBFC8848B5A5836C94D0112367E16148A286F", -} -}, - VpnClientIPsecPolicies = -{ -new IPsecPolicy(86472,429497,IPsecEncryption.Aes256,IPsecIntegrity.Sha256,IkeEncryption.Aes256,IkeIntegrity.Sha384,DHGroup.DHGroup14,PfsGroup.Pfs14) -}, - RadiusServers = -{ -new RadiusServer("10.0.0.0") -{ -RadiusServerScore = 25L, -RadiusServerSecret = "radiusServerSecret", -} -}, - ConfigurationPolicyGroups = -{ -new VpnServerConfigurationPolicyGroupData() -{ -IsDefault = true, -Priority = 0, -PolicyMembers = -{ -new VpnServerConfigurationPolicyGroupMember() -{ -Name = "policy1", -AttributeType = VpnPolicyMemberAttributeType.RadiusAzureGroupId, -AttributeValue = "6ad1bd08", -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfiguration1/vpnServerConfigurationPolicyGroups/policyGroup1"), -Name = "policyGroup1", -},new VpnServerConfigurationPolicyGroupData() -{ -IsDefault = true, -Priority = 0, -PolicyMembers = -{ -new VpnServerConfigurationPolicyGroupMember() -{ -Name = "policy2", -AttributeType = VpnPolicyMemberAttributeType.CertificateGroupId, -AttributeValue = "red.com", -} -}, -Id = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/vpnServerConfigurations/vpnServerConfiguration1/vpnServerConfigurationPolicyGroups/policyGroup2"), -Name = "policyGroup2", -} -}, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vpnServerConfigurationName, data); - VpnServerConfigurationResource result = lro.Value; + bool result = await collection.ExistsAsync(vpnServerConfigurationName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VpnServerConfigurationListByResourceGroup() + public async Task GetIfExists_VpnServerConfigurationGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationListByResourceGroup.json - // this example is just showing the usage of "VpnServerConfigurations_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationGet.json + // this example is just showing the usage of "VpnServerConfigurations_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -266,17 +238,23 @@ public async Task GetAll_VpnServerConfigurationListByResourceGroup() // get the collection of this VpnServerConfigurationResource VpnServerConfigurationCollection collection = resourceGroupResource.GetVpnServerConfigurations(); - // invoke the operation and iterate over the result - await foreach (VpnServerConfigurationResource item in collection.GetAllAsync()) + // invoke the operation + string vpnServerConfigurationName = "vpnServerConfiguration1"; + NullableResponse response = await collection.GetIfExistsAsync(vpnServerConfigurationName); + VpnServerConfigurationResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnServerConfigurationData resourceData = item.Data; + VpnServerConfigurationData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationPolicyGroupCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationPolicyGroupCollection.cs index d6842ff6b0135..198362bf2978f 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationPolicyGroupCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationPolicyGroupCollection.cs @@ -41,24 +41,21 @@ public async Task CreateOrUpdate_ConfigurationPolicyGroupPut() // invoke the operation string configurationPolicyGroupName = "policyGroup1"; - VpnServerConfigurationPolicyGroupData data = new VpnServerConfigurationPolicyGroupData() + VpnServerConfigurationPolicyGroupData data = new VpnServerConfigurationPolicyGroupData { IsDefault = true, Priority = 0, - PolicyMembers = -{ -new VpnServerConfigurationPolicyGroupMember() + PolicyMembers = {new VpnServerConfigurationPolicyGroupMember { Name = "policy1", AttributeType = VpnPolicyMemberAttributeType.RadiusAzureGroupId, AttributeValue = "6ad1bd08", -},new VpnServerConfigurationPolicyGroupMember() +}, new VpnServerConfigurationPolicyGroupMember { Name = "policy2", AttributeType = VpnPolicyMemberAttributeType.CertificateGroupId, AttributeValue = "red.com", -} -}, +}}, }; ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, configurationPolicyGroupName, data); VpnServerConfigurationPolicyGroupResource result = lro.Value; @@ -106,10 +103,10 @@ public async Task Get_ConfigurationPolicyGroupGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_ConfigurationPolicyGroupGet() + public async Task GetAll_ConfigurationPolicyGroupListByVpnServerConfiguration() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ConfigurationPolicyGroupGet.json - // this example is just showing the usage of "ConfigurationPolicyGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ConfigurationPolicyGroupListByVpnServerConfiguration.json + // this example is just showing the usage of "configurationPolicyGroups_ListByVpnServerConfiguration" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -127,16 +124,22 @@ public async Task Exists_ConfigurationPolicyGroupGet() // get the collection of this VpnServerConfigurationPolicyGroupResource VpnServerConfigurationPolicyGroupCollection collection = vpnServerConfiguration.GetVpnServerConfigurationPolicyGroups(); - // invoke the operation - string configurationPolicyGroupName = "policyGroup1"; - bool result = await collection.ExistsAsync(configurationPolicyGroupName); + // invoke the operation and iterate over the result + await foreach (VpnServerConfigurationPolicyGroupResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnServerConfigurationPolicyGroupData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_ConfigurationPolicyGroupGet() + public async Task Exists_ConfigurationPolicyGroupGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ConfigurationPolicyGroupGet.json // this example is just showing the usage of "ConfigurationPolicyGroups_Get" operation, for the dependent resources, they will have to be created separately. @@ -159,29 +162,17 @@ public async Task GetIfExists_ConfigurationPolicyGroupGet() // invoke the operation string configurationPolicyGroupName = "policyGroup1"; - NullableResponse response = await collection.GetIfExistsAsync(configurationPolicyGroupName); - VpnServerConfigurationPolicyGroupResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(configurationPolicyGroupName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnServerConfigurationPolicyGroupData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_ConfigurationPolicyGroupListByVpnServerConfiguration() + public async Task GetIfExists_ConfigurationPolicyGroupGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ConfigurationPolicyGroupListByVpnServerConfiguration.json - // this example is just showing the usage of "configurationPolicyGroups_ListByVpnServerConfiguration" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ConfigurationPolicyGroupGet.json + // this example is just showing the usage of "ConfigurationPolicyGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -199,17 +190,23 @@ public async Task GetAll_ConfigurationPolicyGroupListByVpnServerConfiguration() // get the collection of this VpnServerConfigurationPolicyGroupResource VpnServerConfigurationPolicyGroupCollection collection = vpnServerConfiguration.GetVpnServerConfigurationPolicyGroups(); - // invoke the operation and iterate over the result - await foreach (VpnServerConfigurationPolicyGroupResource item in collection.GetAllAsync()) + // invoke the operation + string configurationPolicyGroupName = "policyGroup1"; + NullableResponse response = await collection.GetIfExistsAsync(configurationPolicyGroupName); + VpnServerConfigurationPolicyGroupResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnServerConfigurationPolicyGroupData resourceData = item.Data; + VpnServerConfigurationPolicyGroupData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationPolicyGroupResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationPolicyGroupResource.cs index f0310936ba98c..1832da0f255a6 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationPolicyGroupResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationPolicyGroupResource.cs @@ -18,10 +18,10 @@ public partial class Sample_VpnServerConfigurationPolicyGroupResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_ConfigurationPolicyGroupPut() + public async Task Get_ConfigurationPolicyGroupGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ConfigurationPolicyGroupPut.json - // this example is just showing the usage of "ConfigurationPolicyGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ConfigurationPolicyGroupGet.json + // this example is just showing the usage of "ConfigurationPolicyGroups_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,27 +38,7 @@ public async Task Update_ConfigurationPolicyGroupPut() VpnServerConfigurationPolicyGroupResource vpnServerConfigurationPolicyGroup = client.GetVpnServerConfigurationPolicyGroupResource(vpnServerConfigurationPolicyGroupResourceId); // invoke the operation - VpnServerConfigurationPolicyGroupData data = new VpnServerConfigurationPolicyGroupData() - { - IsDefault = true, - Priority = 0, - PolicyMembers = -{ -new VpnServerConfigurationPolicyGroupMember() -{ -Name = "policy1", -AttributeType = VpnPolicyMemberAttributeType.RadiusAzureGroupId, -AttributeValue = "6ad1bd08", -},new VpnServerConfigurationPolicyGroupMember() -{ -Name = "policy2", -AttributeType = VpnPolicyMemberAttributeType.CertificateGroupId, -AttributeValue = "red.com", -} -}, - }; - ArmOperation lro = await vpnServerConfigurationPolicyGroup.UpdateAsync(WaitUntil.Completed, data); - VpnServerConfigurationPolicyGroupResource result = lro.Value; + VpnServerConfigurationPolicyGroupResource result = await vpnServerConfigurationPolicyGroup.GetAsync(); // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -96,10 +76,10 @@ public async Task Delete_ConfigurationPolicyGroupDelete() [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_ConfigurationPolicyGroupGet() + public async Task Update_ConfigurationPolicyGroupPut() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ConfigurationPolicyGroupGet.json - // this example is just showing the usage of "ConfigurationPolicyGroups_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/ConfigurationPolicyGroupPut.json + // this example is just showing the usage of "ConfigurationPolicyGroups_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -116,7 +96,24 @@ public async Task Get_ConfigurationPolicyGroupGet() VpnServerConfigurationPolicyGroupResource vpnServerConfigurationPolicyGroup = client.GetVpnServerConfigurationPolicyGroupResource(vpnServerConfigurationPolicyGroupResourceId); // invoke the operation - VpnServerConfigurationPolicyGroupResource result = await vpnServerConfigurationPolicyGroup.GetAsync(); + VpnServerConfigurationPolicyGroupData data = new VpnServerConfigurationPolicyGroupData + { + IsDefault = true, + Priority = 0, + PolicyMembers = {new VpnServerConfigurationPolicyGroupMember +{ +Name = "policy1", +AttributeType = VpnPolicyMemberAttributeType.RadiusAzureGroupId, +AttributeValue = "6ad1bd08", +}, new VpnServerConfigurationPolicyGroupMember +{ +Name = "policy2", +AttributeType = VpnPolicyMemberAttributeType.CertificateGroupId, +AttributeValue = "red.com", +}}, + }; + ArmOperation lro = await vpnServerConfigurationPolicyGroup.UpdateAsync(WaitUntil.Completed, data); + VpnServerConfigurationPolicyGroupResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationResource.cs index f8f97cceab92b..44de29c6cb445 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnServerConfigurationResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -49,10 +48,10 @@ public async Task Get_VpnServerConfigurationGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VpnServerConfigurationUpdate() + public async Task Delete_VpnServerConfigurationDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationUpdateTags.json - // this example is just showing the usage of "VpnServerConfigurations_UpdateTags" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationDelete.json + // this example is just showing the usage of "VpnServerConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_VpnServerConfigurationUpdate() VpnServerConfigurationResource vpnServerConfiguration = client.GetVpnServerConfigurationResource(vpnServerConfigurationResourceId); // invoke the operation - NetworkTagsObject vpnServerConfigurationParameters = new NetworkTagsObject() - { - Tags = -{ -["key1"] = "value1", -["key2"] = "value2", -}, - }; - VpnServerConfigurationResource result = await vpnServerConfiguration.UpdateAsync(vpnServerConfigurationParameters); + await vpnServerConfiguration.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnServerConfigurationData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VpnServerConfigurationDelete() + public async Task Update_VpnServerConfigurationUpdate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationDelete.json - // this example is just showing the usage of "VpnServerConfigurations_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationUpdateTags.json + // this example is just showing the usage of "VpnServerConfigurations_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_VpnServerConfigurationDelete() VpnServerConfigurationResource vpnServerConfiguration = client.GetVpnServerConfigurationResource(vpnServerConfigurationResourceId); // invoke the operation - await vpnServerConfiguration.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVpnServerConfigurations_VpnServerConfigurationList() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnServerConfigurationList.json - // this example is just showing the usage of "VpnServerConfigurations_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VpnServerConfigurationResource item in subscriptionResource.GetVpnServerConfigurationsAsync()) + NetworkTagsObject vpnServerConfigurationParameters = new NetworkTagsObject { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnServerConfigurationData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + }; + VpnServerConfigurationResource result = await vpnServerConfiguration.UpdateAsync(vpnServerConfigurationParameters); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnServerConfigurationData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteCollection.cs index 62a2da677eb4e..8ef4e5da3f1ac 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteCollection.cs @@ -19,10 +19,10 @@ public partial class Sample_VpnSiteCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VpnSiteGet() + public async Task CreateOrUpdate_VpnSiteCreate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteGet.json - // this example is just showing the usage of "VpnSites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSitePut.json + // this example is just showing the usage of "VpnSites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -41,7 +41,41 @@ public async Task Get_VpnSiteGet() // invoke the operation string vpnSiteName = "vpnSite1"; - VpnSiteResource result = await collection.GetAsync(vpnSiteName); + VpnSiteData data = new VpnSiteData + { + VirtualWanId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualWANs/wan1"), + AddressPrefixes = { "10.0.0.0/16" }, + IsSecuritySite = false, + VpnSiteLinks = {new VpnSiteLinkData +{ +LinkProperties = new VpnLinkProviderProperties +{ +LinkProviderName = "vendor1", +LinkSpeedInMbps = 0, +}, +IPAddress = "50.50.50.56", +Fqdn = "link1.vpnsite1.contoso.com", +BgpProperties = new VpnLinkBgpSettings +{ +Asn = 1234L, +BgpPeeringAddress = "192.168.0.0", +}, +Name = "vpnSiteLink1", +}}, + O365BreakOutCategories = new O365BreakOutCategoryPolicies + { + Allow = true, + Optimize = true, + Default = false, + }, + Location = new AzureLocation("West US"), + Tags = +{ +["key1"] = "value1" +}, + }; + ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vpnSiteName, data); + VpnSiteResource result = lro.Value; // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance @@ -52,7 +86,7 @@ public async Task Get_VpnSiteGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VpnSiteGet() + public async Task Get_VpnSiteGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteGet.json // this example is just showing the usage of "VpnSites_Get" operation, for the dependent resources, they will have to be created separately. @@ -74,17 +108,21 @@ public async Task Exists_VpnSiteGet() // invoke the operation string vpnSiteName = "vpnSite1"; - bool result = await collection.ExistsAsync(vpnSiteName); + VpnSiteResource result = await collection.GetAsync(vpnSiteName); - Console.WriteLine($"Succeeded: {result}"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VpnSiteGet() + public async Task GetAll_VpnSiteListByResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteGet.json - // this example is just showing the usage of "VpnSites_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteListByResourceGroup.json + // this example is just showing the usage of "VpnSites_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -101,31 +139,25 @@ public async Task GetIfExists_VpnSiteGet() // get the collection of this VpnSiteResource VpnSiteCollection collection = resourceGroupResource.GetVpnSites(); - // invoke the operation - string vpnSiteName = "vpnSite1"; - NullableResponse response = await collection.GetIfExistsAsync(vpnSiteName); - VpnSiteResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else + // invoke the operation and iterate over the result + await foreach (VpnSiteResource item in collection.GetAllAsync()) { - // the variable result is a resource, you could call other operations on this instance as well + // the variable item is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnSiteData resourceData = result.Data; + VpnSiteData resourceData = item.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task CreateOrUpdate_VpnSiteCreate() + public async Task Exists_VpnSiteGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSitePut.json - // this example is just showing the usage of "VpnSites_CreateOrUpdate" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteGet.json + // this example is just showing the usage of "VpnSites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,61 +176,17 @@ public async Task CreateOrUpdate_VpnSiteCreate() // invoke the operation string vpnSiteName = "vpnSite1"; - VpnSiteData data = new VpnSiteData() - { - VirtualWanId = new ResourceIdentifier("/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.Network/virtualWANs/wan1"), - AddressPrefixes = -{ -"10.0.0.0/16" -}, - IsSecuritySite = false, - VpnSiteLinks = -{ -new VpnSiteLinkData() -{ -LinkProperties = new VpnLinkProviderProperties() -{ -LinkProviderName = "vendor1", -LinkSpeedInMbps = 0, -}, -IPAddress = "50.50.50.56", -Fqdn = "link1.vpnsite1.contoso.com", -BgpProperties = new VpnLinkBgpSettings() -{ -Asn = 1234L, -BgpPeeringAddress = "192.168.0.0", -}, -Name = "vpnSiteLink1", -} -}, - O365BreakOutCategories = new O365BreakOutCategoryPolicies() - { - Allow = true, - Optimize = true, - Default = false, - }, - Location = new AzureLocation("West US"), - Tags = -{ -["key1"] = "value1", -}, - }; - ArmOperation lro = await collection.CreateOrUpdateAsync(WaitUntil.Completed, vpnSiteName, data); - VpnSiteResource result = lro.Value; + bool result = await collection.ExistsAsync(vpnSiteName); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VpnSiteListByResourceGroup() + public async Task GetIfExists_VpnSiteGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteListByResourceGroup.json - // this example is just showing the usage of "VpnSites_ListByResourceGroup" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteGet.json + // this example is just showing the usage of "VpnSites_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -215,17 +203,23 @@ public async Task GetAll_VpnSiteListByResourceGroup() // get the collection of this VpnSiteResource VpnSiteCollection collection = resourceGroupResource.GetVpnSites(); - // invoke the operation and iterate over the result - await foreach (VpnSiteResource item in collection.GetAllAsync()) + // invoke the operation + string vpnSiteName = "vpnSite1"; + NullableResponse response = await collection.GetIfExistsAsync(vpnSiteName); + VpnSiteResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnSiteData resourceData = item.Data; + VpnSiteData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkCollection.cs index f6b02efd61d8b..6eebde7d8c830 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkCollection.cs @@ -51,10 +51,10 @@ public async Task Get_VpnSiteGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Exists_VpnSiteGet() + public async Task GetAll_VpnSiteLinkListByVpnSite() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkGet.json - // this example is just showing the usage of "VpnSiteLinks_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkListByVpnSite.json + // this example is just showing the usage of "VpnSiteLinks_ListByVpnSite" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -72,16 +72,22 @@ public async Task Exists_VpnSiteGet() // get the collection of this VpnSiteLinkResource VpnSiteLinkCollection collection = vpnSite.GetVpnSiteLinks(); - // invoke the operation - string vpnSiteLinkName = "vpnSiteLink1"; - bool result = await collection.ExistsAsync(vpnSiteLinkName); + // invoke the operation and iterate over the result + await foreach (VpnSiteLinkResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnSiteLinkData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_VpnSiteGet() + public async Task Exists_VpnSiteGet() { // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkGet.json // this example is just showing the usage of "VpnSiteLinks_Get" operation, for the dependent resources, they will have to be created separately. @@ -104,29 +110,17 @@ public async Task GetIfExists_VpnSiteGet() // invoke the operation string vpnSiteLinkName = "vpnSiteLink1"; - NullableResponse response = await collection.GetIfExistsAsync(vpnSiteLinkName); - VpnSiteLinkResource result = response.HasValue ? response.Value : null; + bool result = await collection.ExistsAsync(vpnSiteLinkName); - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnSiteLinkData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Console.WriteLine($"Succeeded: {result}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VpnSiteLinkListByVpnSite() + public async Task GetIfExists_VpnSiteGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkListByVpnSite.json - // this example is just showing the usage of "VpnSiteLinks_ListByVpnSite" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkGet.json + // this example is just showing the usage of "VpnSiteLinks_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -144,17 +138,23 @@ public async Task GetAll_VpnSiteLinkListByVpnSite() // get the collection of this VpnSiteLinkResource VpnSiteLinkCollection collection = vpnSite.GetVpnSiteLinks(); - // invoke the operation and iterate over the result - await foreach (VpnSiteLinkResource item in collection.GetAllAsync()) + // invoke the operation + string vpnSiteLinkName = "vpnSiteLink1"; + NullableResponse response = await collection.GetIfExistsAsync(vpnSiteLinkName); + VpnSiteLinkResource result = response.HasValue ? response.Value : null; + + if (result == null) { - // the variable item is a resource, you could call other operations on this instance as well + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well // but just for demo, we get its data from this resource instance - VpnSiteLinkData resourceData = item.Data; + VpnSiteLinkData resourceData = result.Data; // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - Console.WriteLine("Succeeded"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkConnectionCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkConnectionCollection.cs index f853ba007916f..aa4c7283d3fef 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkConnectionCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkConnectionCollection.cs @@ -17,10 +17,10 @@ public partial class Sample_VpnSiteLinkConnectionCollection { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetAll_VpnSiteLinkConnectionList() + public async Task Get_VpnSiteLinkConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkConnectionList.json - // this example is just showing the usage of "VpnLinkConnections_ListByVpnConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkConnectionGet.json + // this example is just showing the usage of "VpnSiteLinkConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -39,25 +39,23 @@ public async Task GetAll_VpnSiteLinkConnectionList() // get the collection of this VpnSiteLinkConnectionResource VpnSiteLinkConnectionCollection collection = vpnConnection.GetVpnSiteLinkConnections(); - // invoke the operation and iterate over the result - await foreach (VpnSiteLinkConnectionResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnSiteLinkConnectionData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + string linkConnectionName = "Connection-Link1"; + VpnSiteLinkConnectionResource result = await collection.GetAsync(linkConnectionName); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnSiteLinkConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VpnSiteLinkConnectionGet() + public async Task GetAll_VpnSiteLinkConnectionList() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkConnectionGet.json - // this example is just showing the usage of "VpnSiteLinkConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkConnectionList.json + // this example is just showing the usage of "VpnLinkConnections_ListByVpnConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -76,15 +74,17 @@ public async Task Get_VpnSiteLinkConnectionGet() // get the collection of this VpnSiteLinkConnectionResource VpnSiteLinkConnectionCollection collection = vpnConnection.GetVpnSiteLinkConnections(); - // invoke the operation - string linkConnectionName = "Connection-Link1"; - VpnSiteLinkConnectionResource result = await collection.GetAsync(linkConnectionName); + // invoke the operation and iterate over the result + await foreach (VpnSiteLinkConnectionResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnSiteLinkConnectionData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnSiteLinkConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkConnectionResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkConnectionResource.cs index 242fad2ae91f1..c13f64a1054a5 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkConnectionResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteLinkConnectionResource.cs @@ -17,10 +17,10 @@ public partial class Sample_VpnSiteLinkConnectionResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task ResetConnectionVpnLinkConnection_ResetVpnLinkConnection() + public async Task Get_VpnSiteLinkConnectionGet() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkConnectionReset.json - // this example is just showing the usage of "VpnLinkConnections_ResetConnection" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkConnectionGet.json + // this example is just showing the usage of "VpnSiteLinkConnections_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -38,17 +38,21 @@ public async Task ResetConnectionVpnLinkConnection_ResetVpnLinkConnection() VpnSiteLinkConnectionResource vpnSiteLinkConnection = client.GetVpnSiteLinkConnectionResource(vpnSiteLinkConnectionResourceId); // invoke the operation - await vpnSiteLinkConnection.ResetConnectionVpnLinkConnectionAsync(WaitUntil.Completed); + VpnSiteLinkConnectionResource result = await vpnSiteLinkConnection.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnSiteLinkConnectionData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task GetIkeSasVpnLinkConnection_GetVpnLinkConnectionIkeSa() + public async Task ResetConnectionVpnLinkConnection_ResetVpnLinkConnection() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkConnectionGetIkeSas.json - // this example is just showing the usage of "VpnLinkConnections_GetIkeSas" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkConnectionReset.json + // this example is just showing the usage of "VpnLinkConnections_ResetConnection" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -66,18 +70,17 @@ public async Task GetIkeSasVpnLinkConnection_GetVpnLinkConnectionIkeSa() VpnSiteLinkConnectionResource vpnSiteLinkConnection = client.GetVpnSiteLinkConnectionResource(vpnSiteLinkConnectionResourceId); // invoke the operation - ArmOperation lro = await vpnSiteLinkConnection.GetIkeSasVpnLinkConnectionAsync(WaitUntil.Completed); - string result = lro.Value; + await vpnSiteLinkConnection.ResetConnectionVpnLinkConnectionAsync(WaitUntil.Completed); - Console.WriteLine($"Succeeded: {result}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_VpnSiteLinkConnectionGet() + public async Task GetIkeSasVpnLinkConnection_GetVpnLinkConnectionIkeSa() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkConnectionGet.json - // this example is just showing the usage of "VpnSiteLinkConnections_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteLinkConnectionGetIkeSas.json + // this example is just showing the usage of "VpnLinkConnections_GetIkeSas" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -95,13 +98,10 @@ public async Task Get_VpnSiteLinkConnectionGet() VpnSiteLinkConnectionResource vpnSiteLinkConnection = client.GetVpnSiteLinkConnectionResource(vpnSiteLinkConnectionResourceId); // invoke the operation - VpnSiteLinkConnectionResource result = await vpnSiteLinkConnection.GetAsync(); + ArmOperation lro = await vpnSiteLinkConnection.GetIkeSasVpnLinkConnectionAsync(WaitUntil.Completed); + string result = lro.Value; - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnSiteLinkConnectionData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine($"Succeeded: {result}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteResource.cs index 632581c84e666..02d8276b6154c 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_VpnSiteResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -49,10 +48,10 @@ public async Task Get_VpnSiteGet() [Test] [Ignore("Only validating compilation of examples")] - public async Task Update_VpnSiteUpdate() + public async Task Delete_VpnSiteDelete() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteUpdateTags.json - // this example is just showing the usage of "VpnSites_UpdateTags" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteDelete.json + // this example is just showing the usage of "VpnSites_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -68,29 +67,17 @@ public async Task Update_VpnSiteUpdate() VpnSiteResource vpnSite = client.GetVpnSiteResource(vpnSiteResourceId); // invoke the operation - NetworkTagsObject vpnSiteParameters = new NetworkTagsObject() - { - Tags = -{ -["key1"] = "value1", -["key2"] = "value2", -}, - }; - VpnSiteResource result = await vpnSite.UpdateAsync(vpnSiteParameters); + await vpnSite.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnSiteData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Delete_VpnSiteDelete() + public async Task Update_VpnSiteUpdate() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteDelete.json - // this example is just showing the usage of "VpnSites_Delete" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteUpdateTags.json + // this example is just showing the usage of "VpnSites_UpdateTags" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -106,40 +93,21 @@ public async Task Delete_VpnSiteDelete() VpnSiteResource vpnSite = client.GetVpnSiteResource(vpnSiteResourceId); // invoke the operation - await vpnSite.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetVpnSites_VpnSiteList() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/VpnSiteList.json - // this example is just showing the usage of "VpnSites_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource - string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); - - // invoke the operation and iterate over the result - await foreach (VpnSiteResource item in subscriptionResource.GetVpnSitesAsync()) + NetworkTagsObject vpnSiteParameters = new NetworkTagsObject { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - VpnSiteData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + Tags = +{ +["key1"] = "value1", +["key2"] = "value2" +}, + }; + VpnSiteResource result = await vpnSite.UpdateAsync(vpnSiteParameters); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + VpnSiteData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_WebApplicationFirewallPolicyCollection.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_WebApplicationFirewallPolicyCollection.cs index c44200b85065e..00dc8b57c9d95 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_WebApplicationFirewallPolicyCollection.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_WebApplicationFirewallPolicyCollection.cs @@ -17,144 +17,6 @@ namespace Azure.ResourceManager.Network.Samples { public partial class Sample_WebApplicationFirewallPolicyCollection { - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetAll_ListsAllWAFPoliciesInAResourceGroup() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafListPolicies.json - // this example is just showing the usage of "WebApplicationFirewallPolicies_List" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this WebApplicationFirewallPolicyResource - WebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetWebApplicationFirewallPolicies(); - - // invoke the operation and iterate over the result - await foreach (WebApplicationFirewallPolicyResource item in collection.GetAllAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebApplicationFirewallPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - Console.WriteLine("Succeeded"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAWAFPolicyWithinAResourceGroup() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafPolicyGet.json - // this example is just showing the usage of "WebApplicationFirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this WebApplicationFirewallPolicyResource - WebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetWebApplicationFirewallPolicies(); - - // invoke the operation - string policyName = "Policy1"; - WebApplicationFirewallPolicyResource result = await collection.GetAsync(policyName); - - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebApplicationFirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Exists_GetsAWAFPolicyWithinAResourceGroup() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafPolicyGet.json - // this example is just showing the usage of "WebApplicationFirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this WebApplicationFirewallPolicyResource - WebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetWebApplicationFirewallPolicies(); - - // invoke the operation - string policyName = "Policy1"; - bool result = await collection.ExistsAsync(policyName); - - Console.WriteLine($"Succeeded: {result}"); - } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task GetIfExists_GetsAWAFPolicyWithinAResourceGroup() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafPolicyGet.json - // this example is just showing the usage of "WebApplicationFirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this ResourceGroupResource created on azure - // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); - ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); - - // get the collection of this WebApplicationFirewallPolicyResource - WebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetWebApplicationFirewallPolicies(); - - // invoke the operation - string policyName = "Policy1"; - NullableResponse response = await collection.GetIfExistsAsync(policyName); - WebApplicationFirewallPolicyResource result = response.HasValue ? response.Value : null; - - if (result == null) - { - Console.WriteLine("Succeeded with null as result"); - } - else - { - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebApplicationFirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } - } - [Test] [Ignore("Only validating compilation of examples")] public async Task CreateOrUpdate_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup() @@ -179,30 +41,25 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup( // invoke the operation string policyName = "Policy1"; - WebApplicationFirewallPolicyData data = new WebApplicationFirewallPolicyData() + WebApplicationFirewallPolicyData data = new WebApplicationFirewallPolicyData { - PolicySettings = new PolicySettings() + PolicySettings = new PolicySettings { - LogScrubbing = new PolicySettingsLogScrubbing() + LogScrubbing = new PolicySettingsLogScrubbing { State = WebApplicationFirewallScrubbingState.Enabled, - ScrubbingRules = -{ -new WebApplicationFirewallScrubbingRules(ScrubbingRuleEntryMatchVariable.RequestArgNames,ScrubbingRuleEntryMatchOperator.EqualsValue) + ScrubbingRules = {new WebApplicationFirewallScrubbingRules(ScrubbingRuleEntryMatchVariable.RequestArgNames, ScrubbingRuleEntryMatchOperator.EqualsValue) { Selector = "test", State = ScrubbingRuleEntryState.Enabled, -},new WebApplicationFirewallScrubbingRules(ScrubbingRuleEntryMatchVariable.RequestIPAddress,ScrubbingRuleEntryMatchOperator.EqualsAny) +}, new WebApplicationFirewallScrubbingRules(ScrubbingRuleEntryMatchVariable.RequestIPAddress, ScrubbingRuleEntryMatchOperator.EqualsAny) { State = ScrubbingRuleEntryState.Enabled, -} -}, +}}, }, JsChallengeCookieExpirationInMins = 100, }, - CustomRules = -{ -new WebApplicationFirewallCustomRule(1,WebApplicationFirewallRuleType.MatchRule,new MatchCondition[] + CustomRules = {new WebApplicationFirewallCustomRule(1, WebApplicationFirewallRuleType.MatchRule, new MatchCondition[] { new MatchCondition(new MatchVariable[] { @@ -210,14 +67,11 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup( { Selector = null, } -},WebApplicationFirewallOperator.IPMatch,new string[] -{ -"192.168.1.0/24","10.0.0.0/24" -}) -},WebApplicationFirewallAction.Block) +}, WebApplicationFirewallOperator.IPMatch, new string[]{"192.168.1.0/24", "10.0.0.0/24"}) +}, WebApplicationFirewallAction.Block) { Name = "Rule1", -},new WebApplicationFirewallCustomRule(2,WebApplicationFirewallRuleType.MatchRule,new MatchCondition[] +}, new WebApplicationFirewallCustomRule(2, WebApplicationFirewallRuleType.MatchRule, new MatchCondition[] { new MatchCondition(new MatchVariable[] { @@ -225,23 +79,18 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup( { Selector = null, } -},WebApplicationFirewallOperator.IPMatch,new string[] -{ -"192.168.1.0/24" -}),new MatchCondition(new MatchVariable[] +}, WebApplicationFirewallOperator.IPMatch, new string[]{"192.168.1.0/24"}), +new MatchCondition(new MatchVariable[] { new MatchVariable(WebApplicationFirewallMatchVariable.RequestHeaders) { Selector = "UserAgent", } -},WebApplicationFirewallOperator.Contains,new string[] -{ -"Windows" -}) -},WebApplicationFirewallAction.Block) +}, WebApplicationFirewallOperator.Contains, new string[]{"Windows"}) +}, WebApplicationFirewallAction.Block) { Name = "Rule2", -},new WebApplicationFirewallCustomRule(3,WebApplicationFirewallRuleType.RateLimitRule,new MatchCondition[] +}, new WebApplicationFirewallCustomRule(3, WebApplicationFirewallRuleType.RateLimitRule, new MatchCondition[] { new MatchCondition(new MatchVariable[] { @@ -249,26 +98,20 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup( { Selector = null, } -},WebApplicationFirewallOperator.IPMatch,new string[] -{ -"192.168.1.0/24","10.0.0.0/24" -}) +}, WebApplicationFirewallOperator.IPMatch, new string[]{"192.168.1.0/24", "10.0.0.0/24"}) { NegationConditon = true, } -},WebApplicationFirewallAction.Block) +}, WebApplicationFirewallAction.Block) { Name = "RateLimitRule3", RateLimitDuration = ApplicationGatewayFirewallRateLimitDuration.OneMin, RateLimitThreshold = 10, -GroupByUserSession = -{ -new GroupByUserSession(new GroupByVariable[] +GroupByUserSession = {new GroupByUserSession(new GroupByVariable[] { new GroupByVariable(ApplicationGatewayFirewallUserSessionVariable.ClientAddr) -}) -}, -},new WebApplicationFirewallCustomRule(4,WebApplicationFirewallRuleType.MatchRule,new MatchCondition[] +})}, +}, new WebApplicationFirewallCustomRule(4, WebApplicationFirewallRuleType.MatchRule, new MatchCondition[] { new MatchCondition(new MatchVariable[] { @@ -276,169 +119,100 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup( { Selector = null, } -},WebApplicationFirewallOperator.IPMatch,new string[] -{ -"192.168.1.0/24" -}),new MatchCondition(new MatchVariable[] +}, WebApplicationFirewallOperator.IPMatch, new string[]{"192.168.1.0/24"}), +new MatchCondition(new MatchVariable[] { new MatchVariable(WebApplicationFirewallMatchVariable.RequestHeaders) { Selector = "UserAgent", } -},WebApplicationFirewallOperator.Contains,new string[] -{ -"Bot" -}) -},WebApplicationFirewallAction.JSChallenge) +}, WebApplicationFirewallOperator.Contains, new string[]{"Bot"}) +}, WebApplicationFirewallAction.JSChallenge) { Name = "Rule4", -} -}, +}}, ManagedRules = new ManagedRulesDefinition(new ManagedRuleSet[] { -new ManagedRuleSet("OWASP","3.2") -{ -RuleGroupOverrides = +new ManagedRuleSet("OWASP", "3.2") { -new ManagedRuleGroupOverride("REQUEST-931-APPLICATION-ATTACK-RFI") +RuleGroupOverrides = {new ManagedRuleGroupOverride("REQUEST-931-APPLICATION-ATTACK-RFI") { -Rules = -{ -new ManagedRuleOverride("931120") +Rules = {new ManagedRuleOverride("931120") { State = ManagedRuleEnabledState.Enabled, Action = RuleMatchActionType.Log, -},new ManagedRuleOverride("931130") +}, new ManagedRuleOverride("931130") { State = ManagedRuleEnabledState.Disabled, Action = RuleMatchActionType.AnomalyScoring, -} +}}, +}}, }, -} -}, -},new ManagedRuleSet("Microsoft_BotManagerRuleSet","1.0") -{ -RuleGroupOverrides = -{ -new ManagedRuleGroupOverride("UnknownBots") +new ManagedRuleSet("Microsoft_BotManagerRuleSet", "1.0") { -Rules = +RuleGroupOverrides = {new ManagedRuleGroupOverride("UnknownBots") { -new ManagedRuleOverride("300700") +Rules = {new ManagedRuleOverride("300700") { State = ManagedRuleEnabledState.Enabled, Action = RuleMatchActionType.JSChallenge, -} +}}, +}}, }, -} -}, -},new ManagedRuleSet("Microsoft_HTTPDDoSRuleSet","1.0") -{ -RuleGroupOverrides = -{ -new ManagedRuleGroupOverride("ExcessiveRequests") +new ManagedRuleSet("Microsoft_HTTPDDoSRuleSet", "1.0") { -Rules = +RuleGroupOverrides = {new ManagedRuleGroupOverride("ExcessiveRequests") { -new ManagedRuleOverride("500100") +Rules = {new ManagedRuleOverride("500100") { State = ManagedRuleEnabledState.Enabled, Action = RuleMatchActionType.Block, Sensitivity = ManagedRuleSensitivityType.High, -} -}, -} -}, +}}, +}}, } }) { - Exceptions = -{ -new ExceptionEntry(ExceptionEntryMatchVariable.RequestUri,ExceptionEntryValueMatchOperator.Contains) -{ -Values = -{ -"health","account/images","default.aspx" -}, -ExceptionManagedRuleSets = -{ -new ExclusionManagedRuleSet("OWASP","3.2") -}, -},new ExceptionEntry(ExceptionEntryMatchVariable.RequestHeader,ExceptionEntryValueMatchOperator.Contains) + Exceptions = {new ExceptionEntry(ExceptionEntryMatchVariable.RequestUri, ExceptionEntryValueMatchOperator.Contains) { -Values = +Values = {"health", "account/images", "default.aspx"}, +ExceptionManagedRuleSets = {new ExclusionManagedRuleSet("OWASP", "3.2")}, +}, new ExceptionEntry(ExceptionEntryMatchVariable.RequestHeader, ExceptionEntryValueMatchOperator.Contains) { -"Mozilla/5.0","Chrome/122.0.0.0" -}, +Values = {"Mozilla/5.0", "Chrome/122.0.0.0"}, SelectorMatchOperator = ExceptionEntrySelectorMatchOperator.StartsWith, Selector = "User-Agent", -ExceptionManagedRuleSets = -{ -new ExclusionManagedRuleSet("OWASP","3.2") -{ -RuleGroups = -{ -new ExclusionManagedRuleGroup("REQUEST-932-APPLICATION-ATTACK-RCE") -}, -} -}, -},new ExceptionEntry(ExceptionEntryMatchVariable.RemoteAddr,ExceptionEntryValueMatchOperator.IPMatch) -{ -Values = -{ -"1.2.3.4","10.0.0.1/6" -}, -ExceptionManagedRuleSets = -{ -new ExclusionManagedRuleSet("Microsoft_BotManagerRuleSet","1.0") -{ -RuleGroups = -{ -new ExclusionManagedRuleGroup("BadBots") -{ -Rules = -{ -new ExclusionManagedRule("100100") -}, -} -}, -} -}, -} -}, - Exclusions = +ExceptionManagedRuleSets = {new ExclusionManagedRuleSet("OWASP", "3.2") { -new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames,OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith,"hello") +RuleGroups = {new ExclusionManagedRuleGroup("REQUEST-932-APPLICATION-ATTACK-RCE")}, +}}, +}, new ExceptionEntry(ExceptionEntryMatchVariable.RemoteAddr, ExceptionEntryValueMatchOperator.IPMatch) { -ExclusionManagedRuleSets = +Values = {"1.2.3.4", "10.0.0.1/6"}, +ExceptionManagedRuleSets = {new ExclusionManagedRuleSet("Microsoft_BotManagerRuleSet", "1.0") { -new ExclusionManagedRuleSet("OWASP","3.2") +RuleGroups = {new ExclusionManagedRuleGroup("BadBots") { -RuleGroups = +Rules = {new ExclusionManagedRule("100100")}, +}}, +}}, +}}, + Exclusions = {new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames, OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith, "hello") { -new ExclusionManagedRuleGroup("REQUEST-930-APPLICATION-ATTACK-LFI") +ExclusionManagedRuleSets = {new ExclusionManagedRuleSet("OWASP", "3.2") { -Rules = +RuleGroups = {new ExclusionManagedRuleGroup("REQUEST-930-APPLICATION-ATTACK-LFI") { -new ExclusionManagedRule("930120") -}, -},new ExclusionManagedRuleGroup("REQUEST-932-APPLICATION-ATTACK-RCE") -}, -} -}, -},new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames,OwaspCrsExclusionEntrySelectorMatchOperator.EndsWith,"hello") -{ -ExclusionManagedRuleSets = -{ -new ExclusionManagedRuleSet("OWASP","3.1") +Rules = {new ExclusionManagedRule("930120")}, +}, new ExclusionManagedRuleGroup("REQUEST-932-APPLICATION-ATTACK-RCE")}, +}}, +}, new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames, OwaspCrsExclusionEntrySelectorMatchOperator.EndsWith, "hello") { -RuleGroups = +ExclusionManagedRuleSets = {new ExclusionManagedRuleSet("OWASP", "3.1") { -}, -} -}, -},new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames,OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith,"test"),new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgValues,OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith,"test") -}, +RuleGroups = {}, +}}, +}, new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames, OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith, "test"), new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgValues, OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith, "test")}, }, Location = new AzureLocation("WestUs"), }; @@ -451,5 +225,143 @@ public async Task CreateOrUpdate_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup( // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Get_GetsAWAFPolicyWithinAResourceGroup() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafPolicyGet.json + // this example is just showing the usage of "WebApplicationFirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WebApplicationFirewallPolicyResource + WebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetWebApplicationFirewallPolicies(); + + // invoke the operation + string policyName = "Policy1"; + WebApplicationFirewallPolicyResource result = await collection.GetAsync(policyName); + + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebApplicationFirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetAll_ListsAllWAFPoliciesInAResourceGroup() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafListPolicies.json + // this example is just showing the usage of "WebApplicationFirewallPolicies_List" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WebApplicationFirewallPolicyResource + WebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetWebApplicationFirewallPolicies(); + + // invoke the operation and iterate over the result + await foreach (WebApplicationFirewallPolicyResource item in collection.GetAllAsync()) + { + // the variable item is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebApplicationFirewallPolicyData resourceData = item.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + + Console.WriteLine("Succeeded"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task Exists_GetsAWAFPolicyWithinAResourceGroup() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafPolicyGet.json + // this example is just showing the usage of "WebApplicationFirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WebApplicationFirewallPolicyResource + WebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetWebApplicationFirewallPolicies(); + + // invoke the operation + string policyName = "Policy1"; + bool result = await collection.ExistsAsync(policyName); + + Console.WriteLine($"Succeeded: {result}"); + } + + [Test] + [Ignore("Only validating compilation of examples")] + public async Task GetIfExists_GetsAWAFPolicyWithinAResourceGroup() + { + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafPolicyGet.json + // this example is just showing the usage of "WebApplicationFirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. + + // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line + TokenCredential cred = new DefaultAzureCredential(); + // authenticate your client + ArmClient client = new ArmClient(cred); + + // this example assumes you already have this ResourceGroupResource created on azure + // for more information of creating ResourceGroupResource, please refer to the document of ResourceGroupResource + string subscriptionId = "subid"; + string resourceGroupName = "rg1"; + ResourceIdentifier resourceGroupResourceId = ResourceGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName); + ResourceGroupResource resourceGroupResource = client.GetResourceGroupResource(resourceGroupResourceId); + + // get the collection of this WebApplicationFirewallPolicyResource + WebApplicationFirewallPolicyCollection collection = resourceGroupResource.GetWebApplicationFirewallPolicies(); + + // invoke the operation + string policyName = "Policy1"; + NullableResponse response = await collection.GetIfExistsAsync(policyName); + WebApplicationFirewallPolicyResource result = response.HasValue ? response.Value : null; + + if (result == null) + { + Console.WriteLine("Succeeded with null as result"); + } + else + { + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebApplicationFirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + } + } } } diff --git a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_WebApplicationFirewallPolicyResource.cs b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_WebApplicationFirewallPolicyResource.cs index 71620c10513d2..3d94b977e47f4 100644 --- a/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_WebApplicationFirewallPolicyResource.cs +++ b/sdk/network/Azure.ResourceManager.Network/samples/Generated/Samples/Sample_WebApplicationFirewallPolicyResource.cs @@ -10,7 +10,6 @@ using Azure.Core; using Azure.Identity; using Azure.ResourceManager.Network.Models; -using Azure.ResourceManager.Resources; using NUnit.Framework; namespace Azure.ResourceManager.Network.Samples @@ -19,41 +18,40 @@ public partial class Sample_WebApplicationFirewallPolicyResource { [Test] [Ignore("Only validating compilation of examples")] - public async Task GetWebApplicationFirewallPolicies_ListsAllWAFPoliciesInASubscription() + public async Task Get_GetsAWAFPolicyWithinAResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafListAllPolicies.json - // this example is just showing the usage of "WebApplicationFirewallPolicies_ListAll" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafPolicyGet.json + // this example is just showing the usage of "WebApplicationFirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); // authenticate your client ArmClient client = new ArmClient(cred); - // this example assumes you already have this SubscriptionResource created on azure - // for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource + // this example assumes you already have this WebApplicationFirewallPolicyResource created on azure + // for more information of creating WebApplicationFirewallPolicyResource, please refer to the document of WebApplicationFirewallPolicyResource string subscriptionId = "subid"; - ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId); - SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId); + string resourceGroupName = "rg1"; + string policyName = "Policy1"; + ResourceIdentifier webApplicationFirewallPolicyResourceId = WebApplicationFirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, policyName); + WebApplicationFirewallPolicyResource webApplicationFirewallPolicy = client.GetWebApplicationFirewallPolicyResource(webApplicationFirewallPolicyResourceId); - // invoke the operation and iterate over the result - await foreach (WebApplicationFirewallPolicyResource item in subscriptionResource.GetWebApplicationFirewallPoliciesAsync()) - { - // the variable item is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebApplicationFirewallPolicyData resourceData = item.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); - } + // invoke the operation + WebApplicationFirewallPolicyResource result = await webApplicationFirewallPolicy.GetAsync(); - Console.WriteLine("Succeeded"); + // the variable result is a resource, you could call other operations on this instance as well + // but just for demo, we get its data from this resource instance + WebApplicationFirewallPolicyData resourceData = result.Data; + // for demo we just print out the id + Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } [Test] [Ignore("Only validating compilation of examples")] - public async Task Get_GetsAWAFPolicyWithinAResourceGroup() + public async Task Delete_DeletesAWAFPolicyWithinAResourceGroup() { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafPolicyGet.json - // this example is just showing the usage of "WebApplicationFirewallPolicies_Get" operation, for the dependent resources, they will have to be created separately. + // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafPolicyDelete.json + // this example is just showing the usage of "WebApplicationFirewallPolicies_Delete" operation, for the dependent resources, they will have to be created separately. // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line TokenCredential cred = new DefaultAzureCredential(); @@ -69,13 +67,9 @@ public async Task Get_GetsAWAFPolicyWithinAResourceGroup() WebApplicationFirewallPolicyResource webApplicationFirewallPolicy = client.GetWebApplicationFirewallPolicyResource(webApplicationFirewallPolicyResourceId); // invoke the operation - WebApplicationFirewallPolicyResource result = await webApplicationFirewallPolicy.GetAsync(); + await webApplicationFirewallPolicy.DeleteAsync(WaitUntil.Completed); - // the variable result is a resource, you could call other operations on this instance as well - // but just for demo, we get its data from this resource instance - WebApplicationFirewallPolicyData resourceData = result.Data; - // for demo we just print out the id - Console.WriteLine($"Succeeded on id: {resourceData.Id}"); + Console.WriteLine("Succeeded"); } [Test] @@ -99,30 +93,25 @@ public async Task Update_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup() WebApplicationFirewallPolicyResource webApplicationFirewallPolicy = client.GetWebApplicationFirewallPolicyResource(webApplicationFirewallPolicyResourceId); // invoke the operation - WebApplicationFirewallPolicyData data = new WebApplicationFirewallPolicyData() + WebApplicationFirewallPolicyData data = new WebApplicationFirewallPolicyData { - PolicySettings = new PolicySettings() + PolicySettings = new PolicySettings { - LogScrubbing = new PolicySettingsLogScrubbing() + LogScrubbing = new PolicySettingsLogScrubbing { State = WebApplicationFirewallScrubbingState.Enabled, - ScrubbingRules = -{ -new WebApplicationFirewallScrubbingRules(ScrubbingRuleEntryMatchVariable.RequestArgNames,ScrubbingRuleEntryMatchOperator.EqualsValue) + ScrubbingRules = {new WebApplicationFirewallScrubbingRules(ScrubbingRuleEntryMatchVariable.RequestArgNames, ScrubbingRuleEntryMatchOperator.EqualsValue) { Selector = "test", State = ScrubbingRuleEntryState.Enabled, -},new WebApplicationFirewallScrubbingRules(ScrubbingRuleEntryMatchVariable.RequestIPAddress,ScrubbingRuleEntryMatchOperator.EqualsAny) +}, new WebApplicationFirewallScrubbingRules(ScrubbingRuleEntryMatchVariable.RequestIPAddress, ScrubbingRuleEntryMatchOperator.EqualsAny) { State = ScrubbingRuleEntryState.Enabled, -} -}, +}}, }, JsChallengeCookieExpirationInMins = 100, }, - CustomRules = -{ -new WebApplicationFirewallCustomRule(1,WebApplicationFirewallRuleType.MatchRule,new MatchCondition[] + CustomRules = {new WebApplicationFirewallCustomRule(1, WebApplicationFirewallRuleType.MatchRule, new MatchCondition[] { new MatchCondition(new MatchVariable[] { @@ -130,14 +119,11 @@ public async Task Update_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup() { Selector = null, } -},WebApplicationFirewallOperator.IPMatch,new string[] -{ -"192.168.1.0/24","10.0.0.0/24" -}) -},WebApplicationFirewallAction.Block) +}, WebApplicationFirewallOperator.IPMatch, new string[]{"192.168.1.0/24", "10.0.0.0/24"}) +}, WebApplicationFirewallAction.Block) { Name = "Rule1", -},new WebApplicationFirewallCustomRule(2,WebApplicationFirewallRuleType.MatchRule,new MatchCondition[] +}, new WebApplicationFirewallCustomRule(2, WebApplicationFirewallRuleType.MatchRule, new MatchCondition[] { new MatchCondition(new MatchVariable[] { @@ -145,23 +131,18 @@ public async Task Update_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup() { Selector = null, } -},WebApplicationFirewallOperator.IPMatch,new string[] -{ -"192.168.1.0/24" -}),new MatchCondition(new MatchVariable[] +}, WebApplicationFirewallOperator.IPMatch, new string[]{"192.168.1.0/24"}), +new MatchCondition(new MatchVariable[] { new MatchVariable(WebApplicationFirewallMatchVariable.RequestHeaders) { Selector = "UserAgent", } -},WebApplicationFirewallOperator.Contains,new string[] -{ -"Windows" -}) -},WebApplicationFirewallAction.Block) +}, WebApplicationFirewallOperator.Contains, new string[]{"Windows"}) +}, WebApplicationFirewallAction.Block) { Name = "Rule2", -},new WebApplicationFirewallCustomRule(3,WebApplicationFirewallRuleType.RateLimitRule,new MatchCondition[] +}, new WebApplicationFirewallCustomRule(3, WebApplicationFirewallRuleType.RateLimitRule, new MatchCondition[] { new MatchCondition(new MatchVariable[] { @@ -169,26 +150,20 @@ public async Task Update_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup() { Selector = null, } -},WebApplicationFirewallOperator.IPMatch,new string[] -{ -"192.168.1.0/24","10.0.0.0/24" -}) +}, WebApplicationFirewallOperator.IPMatch, new string[]{"192.168.1.0/24", "10.0.0.0/24"}) { NegationConditon = true, } -},WebApplicationFirewallAction.Block) +}, WebApplicationFirewallAction.Block) { Name = "RateLimitRule3", RateLimitDuration = ApplicationGatewayFirewallRateLimitDuration.OneMin, RateLimitThreshold = 10, -GroupByUserSession = -{ -new GroupByUserSession(new GroupByVariable[] +GroupByUserSession = {new GroupByUserSession(new GroupByVariable[] { new GroupByVariable(ApplicationGatewayFirewallUserSessionVariable.ClientAddr) -}) -}, -},new WebApplicationFirewallCustomRule(4,WebApplicationFirewallRuleType.MatchRule,new MatchCondition[] +})}, +}, new WebApplicationFirewallCustomRule(4, WebApplicationFirewallRuleType.MatchRule, new MatchCondition[] { new MatchCondition(new MatchVariable[] { @@ -196,169 +171,100 @@ public async Task Update_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup() { Selector = null, } -},WebApplicationFirewallOperator.IPMatch,new string[] -{ -"192.168.1.0/24" -}),new MatchCondition(new MatchVariable[] +}, WebApplicationFirewallOperator.IPMatch, new string[]{"192.168.1.0/24"}), +new MatchCondition(new MatchVariable[] { new MatchVariable(WebApplicationFirewallMatchVariable.RequestHeaders) { Selector = "UserAgent", } -},WebApplicationFirewallOperator.Contains,new string[] -{ -"Bot" -}) -},WebApplicationFirewallAction.JSChallenge) +}, WebApplicationFirewallOperator.Contains, new string[]{"Bot"}) +}, WebApplicationFirewallAction.JSChallenge) { Name = "Rule4", -} -}, +}}, ManagedRules = new ManagedRulesDefinition(new ManagedRuleSet[] { -new ManagedRuleSet("OWASP","3.2") +new ManagedRuleSet("OWASP", "3.2") { -RuleGroupOverrides = +RuleGroupOverrides = {new ManagedRuleGroupOverride("REQUEST-931-APPLICATION-ATTACK-RFI") { -new ManagedRuleGroupOverride("REQUEST-931-APPLICATION-ATTACK-RFI") -{ -Rules = -{ -new ManagedRuleOverride("931120") +Rules = {new ManagedRuleOverride("931120") { State = ManagedRuleEnabledState.Enabled, Action = RuleMatchActionType.Log, -},new ManagedRuleOverride("931130") +}, new ManagedRuleOverride("931130") { State = ManagedRuleEnabledState.Disabled, Action = RuleMatchActionType.AnomalyScoring, -} -}, -} +}}, +}}, }, -},new ManagedRuleSet("Microsoft_BotManagerRuleSet","1.0") -{ -RuleGroupOverrides = +new ManagedRuleSet("Microsoft_BotManagerRuleSet", "1.0") { -new ManagedRuleGroupOverride("UnknownBots") +RuleGroupOverrides = {new ManagedRuleGroupOverride("UnknownBots") { -Rules = -{ -new ManagedRuleOverride("300700") +Rules = {new ManagedRuleOverride("300700") { State = ManagedRuleEnabledState.Enabled, Action = RuleMatchActionType.JSChallenge, -} +}}, +}}, }, -} -}, -},new ManagedRuleSet("Microsoft_HTTPDDoSRuleSet","1.0") -{ -RuleGroupOverrides = -{ -new ManagedRuleGroupOverride("ExcessiveRequests") +new ManagedRuleSet("Microsoft_HTTPDDoSRuleSet", "1.0") { -Rules = +RuleGroupOverrides = {new ManagedRuleGroupOverride("ExcessiveRequests") { -new ManagedRuleOverride("500100") +Rules = {new ManagedRuleOverride("500100") { State = ManagedRuleEnabledState.Enabled, Action = RuleMatchActionType.Block, Sensitivity = ManagedRuleSensitivityType.High, -} -}, -} -}, +}}, +}}, } }) { - Exceptions = + Exceptions = {new ExceptionEntry(ExceptionEntryMatchVariable.RequestUri, ExceptionEntryValueMatchOperator.Contains) { -new ExceptionEntry(ExceptionEntryMatchVariable.RequestUri,ExceptionEntryValueMatchOperator.Contains) +Values = {"health", "account/images", "default.aspx"}, +ExceptionManagedRuleSets = {new ExclusionManagedRuleSet("OWASP", "3.2")}, +}, new ExceptionEntry(ExceptionEntryMatchVariable.RequestHeader, ExceptionEntryValueMatchOperator.Contains) { -Values = -{ -"health","account/images","default.aspx" -}, -ExceptionManagedRuleSets = -{ -new ExclusionManagedRuleSet("OWASP","3.2") -}, -},new ExceptionEntry(ExceptionEntryMatchVariable.RequestHeader,ExceptionEntryValueMatchOperator.Contains) -{ -Values = -{ -"Mozilla/5.0","Chrome/122.0.0.0" -}, +Values = {"Mozilla/5.0", "Chrome/122.0.0.0"}, SelectorMatchOperator = ExceptionEntrySelectorMatchOperator.StartsWith, Selector = "User-Agent", -ExceptionManagedRuleSets = -{ -new ExclusionManagedRuleSet("OWASP","3.2") -{ -RuleGroups = -{ -new ExclusionManagedRuleGroup("REQUEST-932-APPLICATION-ATTACK-RCE") -}, -} -}, -},new ExceptionEntry(ExceptionEntryMatchVariable.RemoteAddr,ExceptionEntryValueMatchOperator.IPMatch) -{ -Values = -{ -"1.2.3.4","10.0.0.1/6" -}, -ExceptionManagedRuleSets = +ExceptionManagedRuleSets = {new ExclusionManagedRuleSet("OWASP", "3.2") { -new ExclusionManagedRuleSet("Microsoft_BotManagerRuleSet","1.0") +RuleGroups = {new ExclusionManagedRuleGroup("REQUEST-932-APPLICATION-ATTACK-RCE")}, +}}, +}, new ExceptionEntry(ExceptionEntryMatchVariable.RemoteAddr, ExceptionEntryValueMatchOperator.IPMatch) { -RuleGroups = +Values = {"1.2.3.4", "10.0.0.1/6"}, +ExceptionManagedRuleSets = {new ExclusionManagedRuleSet("Microsoft_BotManagerRuleSet", "1.0") { -new ExclusionManagedRuleGroup("BadBots") +RuleGroups = {new ExclusionManagedRuleGroup("BadBots") { -Rules = +Rules = {new ExclusionManagedRule("100100")}, +}}, +}}, +}}, + Exclusions = {new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames, OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith, "hello") { -new ExclusionManagedRule("100100") -}, -} -}, -} -}, -} -}, - Exclusions = -{ -new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames,OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith,"hello") -{ -ExclusionManagedRuleSets = -{ -new ExclusionManagedRuleSet("OWASP","3.2") -{ -RuleGroups = -{ -new ExclusionManagedRuleGroup("REQUEST-930-APPLICATION-ATTACK-LFI") -{ -Rules = -{ -new ExclusionManagedRule("930120") -}, -},new ExclusionManagedRuleGroup("REQUEST-932-APPLICATION-ATTACK-RCE") -}, -} -}, -},new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames,OwaspCrsExclusionEntrySelectorMatchOperator.EndsWith,"hello") +ExclusionManagedRuleSets = {new ExclusionManagedRuleSet("OWASP", "3.2") { -ExclusionManagedRuleSets = +RuleGroups = {new ExclusionManagedRuleGroup("REQUEST-930-APPLICATION-ATTACK-LFI") { -new ExclusionManagedRuleSet("OWASP","3.1") +Rules = {new ExclusionManagedRule("930120")}, +}, new ExclusionManagedRuleGroup("REQUEST-932-APPLICATION-ATTACK-RCE")}, +}}, +}, new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames, OwaspCrsExclusionEntrySelectorMatchOperator.EndsWith, "hello") { -RuleGroups = +ExclusionManagedRuleSets = {new ExclusionManagedRuleSet("OWASP", "3.1") { -}, -} -}, -},new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames,OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith,"test"),new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgValues,OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith,"test") -}, +RuleGroups = {}, +}}, +}, new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgNames, OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith, "test"), new OwaspCrsExclusionEntry(OwaspCrsExclusionEntryMatchVariable.RequestArgValues, OwaspCrsExclusionEntrySelectorMatchOperator.StartsWith, "test")}, }, Location = new AzureLocation("WestUs"), }; @@ -371,31 +277,5 @@ public async Task Update_CreatesOrUpdatesAWAFPolicyWithinAResourceGroup() // for demo we just print out the id Console.WriteLine($"Succeeded on id: {resourceData.Id}"); } - - [Test] - [Ignore("Only validating compilation of examples")] - public async Task Delete_DeletesAWAFPolicyWithinAResourceGroup() - { - // Generated from example definition: specification/network/resource-manager/Microsoft.Network/stable/2024-03-01/examples/WafPolicyDelete.json - // this example is just showing the usage of "WebApplicationFirewallPolicies_Delete" operation, for the dependent resources, they will have to be created separately. - - // get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line - TokenCredential cred = new DefaultAzureCredential(); - // authenticate your client - ArmClient client = new ArmClient(cred); - - // this example assumes you already have this WebApplicationFirewallPolicyResource created on azure - // for more information of creating WebApplicationFirewallPolicyResource, please refer to the document of WebApplicationFirewallPolicyResource - string subscriptionId = "subid"; - string resourceGroupName = "rg1"; - string policyName = "Policy1"; - ResourceIdentifier webApplicationFirewallPolicyResourceId = WebApplicationFirewallPolicyResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, policyName); - WebApplicationFirewallPolicyResource webApplicationFirewallPolicy = client.GetWebApplicationFirewallPolicyResource(webApplicationFirewallPolicyResourceId); - - // invoke the operation - await webApplicationFirewallPolicy.DeleteAsync(WaitUntil.Completed); - - Console.WriteLine("Succeeded"); - } } }